[
  {
    "path": "COPYING.txt",
    "content": "\t\t    GNU GENERAL PUBLIC LICENSE\n\t\t       Version 2, June 1991\n\n Copyright (C) 1989, 1991 Free Software Foundation, Inc.\n                       51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n\t\t\t    Preamble\n\n  The licenses for most software are designed to take away your\nfreedom to share and change it.  By contrast, the GNU General Public\nLicense is intended to guarantee your freedom to share and change free\nsoftware--to make sure the software is free for all its users.  This\nGeneral Public License applies to most of the Free Software\nFoundation's software and to any other program whose authors commit to\nusing it.  (Some other Free Software Foundation software is covered by\nthe GNU Library General Public License instead.)  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthis service if you wish), that you receive source code or can get it\nif you want it, that you can change the software or use pieces of it\nin new free programs; and that you know you can do these things.\n\n  To protect your rights, we need to make restrictions that forbid\nanyone to deny you these rights or to ask you to surrender the rights.\nThese restrictions translate to certain responsibilities for you if you\ndistribute copies of the software, or if you modify it.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must give the recipients all the rights that\nyou have.  You must make sure that they, too, receive or can get the\nsource code.  And you must show them these terms so they know their\nrights.\n\n  We protect your rights with two steps: (1) copyright the software, and\n(2) offer you this license which gives you legal permission to copy,\ndistribute and/or modify the software.\n\n  Also, for each author's protection and ours, we want to make certain\nthat everyone understands that there is no warranty for this free\nsoftware.  If the software is modified by someone else and passed on, we\nwant its recipients to know that what they have is not the original, so\nthat any problems introduced by others will not reflect on the original\nauthors' reputations.\n\n  Finally, any free program is threatened constantly by software\npatents.  We wish to avoid the danger that redistributors of a free\nprogram will individually obtain patent licenses, in effect making the\nprogram proprietary.  To prevent this, we have made it clear that any\npatent must be licensed for everyone's free use or not licensed at all.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\f\n\t\t    GNU GENERAL PUBLIC LICENSE\n   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n  0. This License applies to any program or other work which contains\na notice placed by the copyright holder saying it may be distributed\nunder the terms of this General Public License.  The \"Program\", below,\nrefers to any such program or work, and a \"work based on the Program\"\nmeans either the Program or any derivative work under copyright law:\nthat is to say, a work containing the Program or a portion of it,\neither verbatim or with modifications and/or translated into another\nlanguage.  (Hereinafter, translation is included without limitation in\nthe term \"modification\".)  Each licensee is addressed as \"you\".\n\nActivities other than copying, distribution and modification are not\ncovered by this License; they are outside its scope.  The act of\nrunning the Program is not restricted, and the output from the Program\nis covered only if its contents constitute a work based on the\nProgram (independent of having been made by running the Program).\nWhether that is true depends on what the Program does.\n\n  1. You may copy and distribute verbatim copies of the Program's\nsource code as you receive it, in any medium, provided that you\nconspicuously and appropriately publish on each copy an appropriate\ncopyright notice and disclaimer of warranty; keep intact all the\nnotices that refer to this License and to the absence of any warranty;\nand give any other recipients of the Program a copy of this License\nalong with the Program.\n\nYou may charge a fee for the physical act of transferring a copy, and\nyou may at your option offer warranty protection in exchange for a fee.\n\n  2. You may modify your copy or copies of the Program or any portion\nof it, thus forming a work based on the Program, and copy and\ndistribute such modifications or work under the terms of Section 1\nabove, provided that you also meet all of these conditions:\n\n    a) You must cause the modified files to carry prominent notices\n    stating that you changed the files and the date of any change.\n\n    b) You must cause any work that you distribute or publish, that in\n    whole or in part contains or is derived from the Program or any\n    part thereof, to be licensed as a whole at no charge to all third\n    parties under the terms of this License.\n\n    c) If the modified program normally reads commands interactively\n    when run, you must cause it, when started running for such\n    interactive use in the most ordinary way, to print or display an\n    announcement including an appropriate copyright notice and a\n    notice that there is no warranty (or else, saying that you provide\n    a warranty) and that users may redistribute the program under\n    these conditions, and telling the user how to view a copy of this\n    License.  (Exception: if the Program itself is interactive but\n    does not normally print such an announcement, your work based on\n    the Program is not required to print an announcement.)\n\f\nThese requirements apply to the modified work as a whole.  If\nidentifiable sections of that work are not derived from the Program,\nand can be reasonably considered independent and separate works in\nthemselves, then this License, and its terms, do not apply to those\nsections when you distribute them as separate works.  But when you\ndistribute the same sections as part of a whole which is a work based\non the Program, the distribution of the whole must be on the terms of\nthis License, whose permissions for other licensees extend to the\nentire whole, and thus to each and every part regardless of who wrote it.\n\nThus, it is not the intent of this section to claim rights or contest\nyour rights to work written entirely by you; rather, the intent is to\nexercise the right to control the distribution of derivative or\ncollective works based on the Program.\n\nIn addition, mere aggregation of another work not based on the Program\nwith the Program (or with a work based on the Program) on a volume of\na storage or distribution medium does not bring the other work under\nthe scope of this License.\n\n  3. You may copy and distribute the Program (or a work based on it,\nunder Section 2) in object code or executable form under the terms of\nSections 1 and 2 above provided that you also do one of the following:\n\n    a) Accompany it with the complete corresponding machine-readable\n    source code, which must be distributed under the terms of Sections\n    1 and 2 above on a medium customarily used for software interchange; or,\n\n    b) Accompany it with a written offer, valid for at least three\n    years, to give any third party, for a charge no more than your\n    cost of physically performing source distribution, a complete\n    machine-readable copy of the corresponding source code, to be\n    distributed under the terms of Sections 1 and 2 above on a medium\n    customarily used for software interchange; or,\n\n    c) Accompany it with the information you received as to the offer\n    to distribute corresponding source code.  (This alternative is\n    allowed only for noncommercial distribution and only if you\n    received the program in object code or executable form with such\n    an offer, in accord with Subsection b above.)\n\nThe source code for a work means the preferred form of the work for\nmaking modifications to it.  For an executable work, complete source\ncode means all the source code for all modules it contains, plus any\nassociated interface definition files, plus the scripts used to\ncontrol compilation and installation of the executable.  However, as a\nspecial exception, the source code distributed need not include\nanything that is normally distributed (in either source or binary\nform) with the major components (compiler, kernel, and so on) of the\noperating system on which the executable runs, unless that component\nitself accompanies the executable.\n\nIf distribution of executable or object code is made by offering\naccess to copy from a designated place, then offering equivalent\naccess to copy the source code from the same place counts as\ndistribution of the source code, even though third parties are not\ncompelled to copy the source along with the object code.\n\f\n  4. You may not copy, modify, sublicense, or distribute the Program\nexcept as expressly provided under this License.  Any attempt\notherwise to copy, modify, sublicense or distribute the Program is\nvoid, and will automatically terminate your rights under this License.\nHowever, parties who have received copies, or rights, from you under\nthis License will not have their licenses terminated so long as such\nparties remain in full compliance.\n\n  5. You are not required to accept this License, since you have not\nsigned it.  However, nothing else grants you permission to modify or\ndistribute the Program or its derivative works.  These actions are\nprohibited by law if you do not accept this License.  Therefore, by\nmodifying or distributing the Program (or any work based on the\nProgram), you indicate your acceptance of this License to do so, and\nall its terms and conditions for copying, distributing or modifying\nthe Program or works based on it.\n\n  6. Each time you redistribute the Program (or any work based on the\nProgram), the recipient automatically receives a license from the\noriginal licensor to copy, distribute or modify the Program subject to\nthese terms and conditions.  You may not impose any further\nrestrictions on the recipients' exercise of the rights granted herein.\nYou are not responsible for enforcing compliance by third parties to\nthis License.\n\n  7. If, as a consequence of a court judgment or allegation of patent\ninfringement or for any other reason (not limited to patent issues),\nconditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot\ndistribute so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you\nmay not distribute the Program at all.  For example, if a patent\nlicense would not permit royalty-free redistribution of the Program by\nall those who receive copies directly or indirectly through you, then\nthe only way you could satisfy both it and this License would be to\nrefrain entirely from distribution of the Program.\n\nIf any portion of this section is held invalid or unenforceable under\nany particular circumstance, the balance of the section is intended to\napply and the section as a whole is intended to apply in other\ncircumstances.\n\nIt is not the purpose of this section to induce you to infringe any\npatents or other property right claims or to contest validity of any\nsuch claims; this section has the sole purpose of protecting the\nintegrity of the free software distribution system, which is\nimplemented by public license practices.  Many people have made\ngenerous contributions to the wide range of software distributed\nthrough that system in reliance on consistent application of that\nsystem; it is up to the author/donor to decide if he or she is willing\nto distribute software through any other system and a licensee cannot\nimpose that choice.\n\nThis section is intended to make thoroughly clear what is believed to\nbe a consequence of the rest of this License.\n\f\n  8. If the distribution and/or use of the Program is restricted in\ncertain countries either by patents or by copyrighted interfaces, the\noriginal copyright holder who places the Program under this License\nmay add an explicit geographical distribution limitation excluding\nthose countries, so that distribution is permitted only in or among\ncountries not thus excluded.  In such case, this License incorporates\nthe limitation as if written in the body of this License.\n\n  9. The Free Software Foundation may publish revised and/or new versions\nof the General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\nEach version is given a distinguishing version number.  If the Program\nspecifies a version number of this License which applies to it and \"any\nlater version\", you have the option of following the terms and conditions\neither of that version or of any later version published by the Free\nSoftware Foundation.  If the Program does not specify a version number of\nthis License, you may choose any version ever published by the Free Software\nFoundation.\n\n  10. If you wish to incorporate parts of the Program into other free\nprograms whose distribution conditions are different, write to the author\nto ask for permission.  For software which is copyrighted by the Free\nSoftware Foundation, write to the Free Software Foundation; we sometimes\nmake exceptions for this.  Our decision will be guided by the two goals\nof preserving the free status of all derivatives of our free software and\nof promoting the sharing and reuse of software generally.\n\n\t\t\t    NO WARRANTY\n\n  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\nFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN\nOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\nPROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\nOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS\nTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE\nPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\nREPAIR OR CORRECTION.\n\n  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\nREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\nINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\nOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\nTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\nYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\nPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGES.\n\n\t\t     END OF TERMS AND CONDITIONS\n\f\n"
  },
  {
    "path": "README.txt",
    "content": "Quake III Arena GPL source release\n==================================\n\nThis file contains the following sections:\n\nLICENSE\nGENERAL NOTES\nCOMPILING ON WIN32\nCOMPILING ON GNU/LINUX\nCOMPILING ON MAC\n\nLICENSE\n=======\n\nSee COPYING.txt for the GNU GENERAL PUBLIC LICENSE\n\nSome source code in this release is not covered by the GPL:\n\nIO on .zip files using portions of zlib\n-----------------------------------------------------------------------------\nlines\tfile(s)\n4299\tcode/qcommon/unzip.c\n4546\tlibs/pak/unzip.cpp\nCopyright (C) 1998 Gilles Vollant\nzlib is Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\nMD4 Message-Digest Algorithm\n-----------------------------------------------------------------------------\nlines\tfile(s)\n299\t\tcode/qcommon/md4.c\n277\t\tcommon/md4.c\nCopyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved.\n\nLicense to copy and use this software is granted provided that it is identified \nas the <93>RSA Data Security, Inc. MD4 Message-Digest Algorithm<94> in all mater\nial mentioning or referencing this software or this function.\nLicense is also granted to make and use derivative works provided that such work\ns are identified as <93>derived from the RSA Data Security, Inc. MD4 Message-Dig\nest Algorithm<94> in all material mentioning or referencing the derived work.\nRSA Data Security, Inc. makes no representations concerning either the merchanta\nbility of this software or the suitability of this software for any particular p\nurpose. It is provided <93>as is<94> without express or implied warranty of any \nkind.\n\nchecksums are used to validate pak files\n\nstandard C library replacement routines\n-----------------------------------------------------------------------------\nlines\tfile(s)\n1324\tcode/game/bg_lib.c\nCopyright (c) 1992, 1993\nThe Regents of the University of California. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n1. Redistributions of source code must retain the above copyright\n   notice, this list of conditions and the following disclaimer.\n2. Redistributions in binary form must reproduce the above copyright\n   notice, this list of conditions and the following disclaimer in the\n   documentation and/or other materials provided with the distribution.\n3. All advertising materials mentioning features or use of this software\n   must display the following acknowledgement:\n     This product includes software developed by the University of\n     California, Berkeley and its contributors.\n4. Neither the name of the University nor the names of its contributors\n   may be used to endorse or promote products derived from this software\n   without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\nOR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\nHOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\nLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\nOUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGE.\n\nADPCM coder/decoder\n-----------------------------------------------------------------------------\nlines\tfile(s)\n330\t\tcode/client/snd_adpcm.c\nCopyright 1992 by Stichting Mathematisch Centrum, Amsterdam, The\nNetherlands.\n\n                        All Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its \ndocumentation for any purpose and without fee is hereby granted, \nprovided that the above copyright notice appear in all copies and that\nboth that copyright notice and this permission notice appear in \nsupporting documentation, and that the names of Stichting Mathematisch\nCentrum or CWI not be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior permission.\n\nSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO\nTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE\nFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\nACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT\nOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n\nJPEG library\n-----------------------------------------------------------------------------\ncode/jpeg-6\nlibs/jpeg6\nCopyright (C) 1991-1995, Thomas G. Lane\n\nPermission is hereby granted to use, copy, modify, and distribute this\nsoftware (or portions thereof) for any purpose, without fee, subject to these\nconditions:\n(1) If any part of the source code for this software is distributed, then this\nREADME file must be included, with this copyright and no-warranty notice\nunaltered; and any additions, deletions, or changes to the original files\nmust be clearly indicated in accompanying documentation.\n(2) If only executable code is distributed, then the accompanying\ndocumentation must state that \"this software is based in part on the work of\nthe Independent JPEG Group\".\n(3) Permission for use of this software is granted only if the user accepts\nfull responsibility for any undesirable consequences; the authors accept\nNO LIABILITY for damages of any kind.\n\nThese conditions apply to any software derived from or based on the IJG code,\nnot just to the unmodified library.  If you use our work, you ought to\nacknowledge us.\n\nNOTE: unfortunately the README that came with our copy of the library has\nbeen lost, so the one from release 6b is included instead. There are a few\n'glue type' modifications to the library to make it easier to use from\nthe engine, but otherwise the dependency can be easily cleaned up to a\nbetter release of the library.\n\n\nGENERAL NOTES\n=============\n\nA short summary of the file layout:\n\ncode/\t\t\t   \t\tQuake III Arena source code ( renderer, game code, OS layer etc. )\ncode/bspc\t\t\t\tbot routes compiler source code\nlcc/\t\t\t\t\tthe retargetable C compiler ( produces assembly to be turned into qvm bytecode by q3asm )\nq3asm/\t\t\t\t\tassembly to qvm bytecode compiler\nq3map/\t\t\t\t\tmap compiler ( .map -> .bsp ) - this is the version that comes with Q3Radiant 200f\nq3radiant/\t\t\t\tQ3Radiant map editor build 200f ( common/ and libs/ are support dirs for radiant )\n\nWhile we made sure we were still able to compile the game on Windows, GNU/Linux and Mac, this build didn't get any kind of extensive testing so it may not work completely right. Whenever an id game is released under GPL, several projects start making the source code more friendly to nowaday's compilers and environements. If you are picking up this release weeks/months/years after we uploaded it, you probably want to look around on the net for cleaned up versions of this codebase as well.\n\nCOMPILING ON WIN32\n==================\n\nVC7 / Visual C++ 2003 project files are provided:\ncode/quake3.sln\nq3radiant/Radiant.sln\n\nTo compile the qvms, you need to run some batch files:\nyou will need to have lcc.exe q3cpp.exe q3rcc.exe and q3asm.exe in your path\n( some precompiled binaries are provided in lcc/bin and code/win32/mod-sdk-setup/bin )\nthe qvm batch files are in code/game code/cgame code/q3_ui code/ui ..\n\nCOMPILING ON GNU/LINUX\n==================\n\nthe build system using cons, which may be known as scons's perl ancestor now\nyou don't have to track it down though, the build script is provided in the tree\nyou will need nasm and gcc 2.95\nmake sure you have the X Direct Graphics Access and X Video Mode extensions headers for your X11\na typical compile command goes like this:\n[..]/code$ ./unix/cons -- gcc=gcc-2.95 g++=g++-2.95\n\nCOMPILING ON MAC\n================\n\nproject file for OSX compile is in code/macosx/Quake3.pbproj\n"
  },
  {
    "path": "code/Construct",
    "content": "# -*- mode: perl -*-\n# cons script for cgame game q3_ui ui .so and .qvm builds\n#\n# Oct. 2001 TTimo <ttimo@idsoftware.com>\n#\n\n# the top directory is\n# <config>-<cpu>-<OS>-<libc version>\n# where:\n#   <config> is \"debug\" or \"release\"\n#   <cpu> is \"x86\" or \"ppc\"\n#   <OS> is \"Linux\" \"BSD\" \"IRIX\" etc.\n#   <libc version> is major.minor of libc config\n\n# source the compiler version utility\nBEGIN {\n  push @INC, './unix';\n}\nuse Cons_gcc;\n\n# defaults\n$config = 'debug';\n$do_smp = 1;\n$do_masterserver = 0;\n$do_authserver = 0;\n$do_authport = 0;\n$do_setup = 0;\n$do_bspc = 0;\n$do_sdk = 0;\n$do_pk3 = 0;\n# those are exported\n$DO_WIN32 = 0;\n$NO_VM = 0;\n$NO_SO = 0;\n$CC='gcc';\n$CXX='g++';\n\n# detect an sdk build (don't attempt client build and other things)\nif ( -r 'unix/Conscript-client' )\n{\n  $no_core = 0;\n}\nelse\n{\n  $no_core = 1;\n}\n\n# detection of CPU type\n$cpu = `uname -m`;\nchop ($cpu);\nif ($cpu +~ /i?86/)\n{\n  $cpu = 'x86';\n}\n# OS\n$OS = `uname`;\nchop ($OS);\n# hacky win32 detection and win32 specifics code\nif ($OS =~ CYGWIN)\n{\n\t$DO_WIN32 = 1;\n}\nelse\n{\n\t# libc .. do the little magic!\n\t$libc_cmd = '/lib/libc.so.6 |grep \"GNU C \"|grep version|awk -F \"version \" \\'{ print $2 }\\'|cut -b -3';\n\t$libc = `$libc_cmd`;\n\tchop ($libc);\n}\n\nif ($DO_WIN32 eq 1)\n{\n\tprint(\"Win32 build\\n\");\n\n\t$config = $ARGV[0];\n\n\t# TODO: option to override $Q3BASE from command line\n\t$Q3BASE = $ENV{Q3BASE}; # FIXME: this doesn't play nice with cygwin path syntax\n\tprint(\"\\$Q3BASE: $Q3BASE\\n\");\t\n\n\tif($config eq 'debug')\n\t{\n\t  $DIR = 'Debug';\n\t\tsystem(\"cp -v $DIR/quake3.exe \\$Q3BASE\");\n\t\tsystem(\"cp -v $DIR/cgamex86.dll $DIR/qagamex86.dll $DIR/uix86.dll \\$Q3BASE/baseq3\");\n\t}\n\telsif ($config eq 'debug-TA')\n\t{\n\t\t$DIR = 'Debug_TA';\n\t\tsystem(\"cp -v $DIR/quake3.exe \\$Q3BASE\");\n\t\tsystem(\"cp -v $DIR/cgamex86.dll $DIR/qagamex86.dll $DIR/uix86.dll \\$Q3BASE/missionpack\");\n\t}\n\telsif($config eq 'release-TA')\n\t{\n\t\t$DIR = 'Release_TA';\n\t\t# spank!\n\t\tsystem(\"./spank.sh\");\n\t\tsystem(\"cp -v $DIR/quake3.exe \\$Q3BASE\");\n\t}\n\telse\n\t{\n\t\tprintf(\"ERROR: no config option (debug debug-TA release-TA)\");\n\t\texit;\n\t}\n\n\t# copy selected stuff to shared media\n\t$DESTDIR='/cygdrive/e/incoming/Id/q3-1.32';\n\tsystem(\"cp -v $DIR/quake3.exe $DESTDIR\");\n\tsystem(\"cp -v /cygdrive/e/Q3SetupMedia/quake3/CHANGES-1.32.txt $DESTDIR\");\n\n\texit;\t\n}\n\nif(@ARGV gt 0)\n{\n  foreach $cmdopt (@ARGV)\n  {\n    if(lc($cmdopt) eq 'release')\n    {\n      $config = 'release';\n      next;\n    }\n    elsif(lc($cmdopt) eq 'debug')\n    {\n      $config = 'debug';\n      next;\n    }\n    elsif(lc($cmdopt) eq 'novm')\n    {\n      $NO_VM = 1;\n      next;\n    }\n    elsif(lc($cmdopt) eq 'noso')\n    {\n      $NO_SO = 1;\n      next;\n    }\n    elsif(lc($cmdopt) eq 'nosmp')\n    {\n      $do_smp = 0;\n      next;\n    }\n    elsif(lc($cmdopt) =~ 'master_server=.*')\n    {\n      $do_masterserver = 1;\n      $master_server = lc($cmdopt);\n      $master_server =~ s/master_server=(.*)/\\1/;\n      next;\n    }\n    elsif(lc($cmdopt) =~ 'auth_server=.*')\n    {\n      $do_authserver = 1;\n      $auth_server = lc($cmdopt);\n      $auth_server =~ s/auth_server=(.*)/\\1/;\n      next;\n    }\n    elsif(lc($cmdopt) =~ 'auth_port=.*')\n    {\n      $do_authport = 1;\n      $auth_port = lc($cmdopt);\n      $auth_port =~ s/auth_port=(.*)/\\1/;\n      next;\n    }\n    elsif(lc($cmdopt) =~ 'setup')\n    {\n      $do_setup = 1;\n      next;\n    }\n    elsif(lc($cmdopt) =~ 'bspc')\n    {\n      $do_bspc = 1;\n      next;\n    }\n    elsif(lc($cmdopt) =~ 'sdk')\n    {\n      $do_sdk = 1;\n      next;\n    }\n    elsif(lc($cmdopt) =~ 'pk3')\n    {\n      $do_pk3 = 1;\n      next;\n    }\n\telsif(lc($cmdopt) =~ 'gcc=.*')\n    {\n      $CC=lc($cmdopt);\n      $CC =~ s/gcc=(.*)/\\1/;\n      next;\n    }\n    elsif(lc($cmdopt) =~ 'g\\+\\+=.*')\n    {\n      $CXX=lc($cmdopt);\n      $CXX=~s/g\\+\\+=(.*)/\\1/;\n      next;\n    }\n    else\n    {\n      # output an error & exit\n      print(\"Error\\n  $0: Unknown command line option: [ $cmdopt ]\\n\");\n      system(\"cons -h\");\n      exit;\n    }\n  }\n}\n\nif (($do_setup eq 1) && ($config ne 'release'))\n{\n  print(\"Error\\n  $0: 'setup' requires 'release'\\n\");\n  exit;\n}\n\n# sdk\nif ($do_sdk eq 1)\n{\n  # extract the Q3 version from q_shared.h\n  $line = `cat game/q_shared.h | grep Q3_VERSION`;\n  chomp $line;\n  $line =~ s/.*Q3\\ (.*)\\\"/$1/;\n  $Q3_VER = $line;\n  $SDK_NAME = \"linuxq3a-sdk-$Q3_VER.x86.run\";\n  Default \"unix/$SDK_NAME\";\n  Export qw( SDK_NAME Q3_VER );\n  Build 'unix/Conscript-sdk';\n  return;\n}\n\n# build the config directory\n$CONFIG_DIR = $config . '-' . $cpu . '-' . $OS . '-' . $libc;\n\n$COMMON_CFLAGS = '-pipe -fsigned-char ';\n\nif ($config eq 'debug')\n{\n  # use -Werror for better QA  \n  $BASE_CFLAGS = $COMMON_CFLAGS . '-g -Wall -Werror -O ';\n\t$BSPC_BASE_CFLAGS = $COMMON_CFLAGS . '-g -O -DLINUX -DBSPC -Dstricmp=strcasecmp ';\n}\nelse\n{\n  $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 ';\n\t$BSPC_BASE_CFLAGS = $BASE_CFLAGS . '-DLINUX -DBSPC -Dstricmp=strcasecmp ';\n}\n\nif ($do_masterserver eq 1)\n{\n\t$BASE_CFLAGS .= \"-DMASTER_SERVER_NAME=\\\\\\\"$master_server\\\\\\\" \";\n}\n\nif ($do_authserver eq 1)\n{\n\t$BASE_CFLAGS .= \"-DAUTHORIZE_SERVER_NAME=\\\\\\\"$auth_server\\\\\\\" \";\n}\n\nif ($do_authport eq 1)\n{\n\t$BASE_CFLAGS .= \"-DPORT_AUTHORIZE=$auth_port \";\n}\n\nmy @gcc_version = Cons_gcc::get_gcc_version($CC);\nprint(\"GCC version: $gcc_version[1] - $gcc_version[2]\\n\");\n# with 2.95 you can link with gcc, this avoids nasty useless libstdc++ dependency\nif ($gcc_version[0] eq '2')\n{\n\t$LINK = $CC;\n} else {\n\t$LINK = $CXX;\n}\n\nmy @ccache = Cons_gcc::get_ccache();\nif ($ccache[0] eq '1')\n{\n  $CC = $ccache[1] . \" \" . $CC;\n  $CXX = $ccache[1] . \" \" . $CXX;\n}\n\nprint 'cpu : ' . $cpu . \"\\nOS  : \" . $OS . \"\\n\";\nprint \"libc: \" . $libc . \"\\n\";\nprint \"configured for \" . $config . \" build\\n\";\nprint 'CFLAGS: ' . $BASE_CFLAGS . \"\\n\";\n\n# install config\n$INSTALL_BASEDIR='#install';\n\nDefault $INSTALL_BASEDIR;\n\nsub build_tools {\n  system(\"mkdir qvmtools 2>/dev/null\");\n  if (@_[0] eq 'q3lcc')\n  {\n    system(\"cd ../lcc ; make all ; cp /tmp/lcc ../code/qvmtools/q3lcc ; cp /tmp/rcc ../code/qvmtools/q3rcc ; cp /tmp/cpp ../code/qvmtools/q3cpp\");\n  }\n  elsif (@_[0] eq 'q3asm')\n  {\n    system(\"cd ../q3asm ; make ; cp q3asm ../code/qvmtools\");\n  }\n  else\n  {\n    printf(\"build_tools: @_[0] unrecognized command\\n\");\n    die;\n  }\n  return 1;\n}\n\n# build tools\n$env_tools = new cons();\nCommand $env_tools 'qvmtools/q3lcc', '[perl] &build_tools(\\'q3lcc\\')';\nCommand $env_tools 'qvmtools/q3asm', '[perl] &build_tools(\\'q3asm\\')';\n\nif ($do_bspc eq 1)\n{\n\t# build bspc\n\t$BUILD_DIR = $CONFIG_DIR . '/bspc';\n\tLink $BUILD_DIR => '.';\n\t$INSTALL_DIR = $INSTALL_BASEDIR . '/utils';\n\tExport qw( BSPC_BASE_CFLAGS BUILD_DIR INSTALL_DIR CC CXX LINK );\n\tBuild $BUILD_DIR . '/bspc/Conscript';\n}\n\n# build vanilla Q3\n$TARGET_DIR='Q3';\n\n$INSTALL_DIR = $INSTALL_BASEDIR . '/baseq3';\n\n$BUILD_DIR = $CONFIG_DIR . '/' . $TARGET_DIR . '/cgame';\nLink $BUILD_DIR => '.';\nExport qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );\nBuild $BUILD_DIR . '/cgame/Conscript';\n\n$BUILD_DIR = $CONFIG_DIR . '/' . $TARGET_DIR . '/game';\nLink $BUILD_DIR => '.';\nExport qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );\nBuild $BUILD_DIR . '/game/Conscript';\n\n$BUILD_DIR = $CONFIG_DIR . '/' . $TARGET_DIR . '/q3_ui';\nLink $BUILD_DIR => '.';\nExport qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );\nBuild $BUILD_DIR . '/q3_ui/Conscript';\n  \n# build TA\n$TARGET_DIR='TA';\n\n$INSTALL_DIR = $INSTALL_BASEDIR . '/missionpack';\n\n$BUILD_DIR = $CONFIG_DIR . \"/\" . $TARGET_DIR . '/cgame';\nLink $BUILD_DIR => '.';\nExport qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );\nBuild $BUILD_DIR . '/cgame/Conscript';\n\n$BUILD_DIR = $CONFIG_DIR . \"/\" . $TARGET_DIR . '/game';\nLink $BUILD_DIR => '.';\nExport qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );\nBuild $BUILD_DIR . '/game/Conscript';\n\n$BUILD_DIR = $CONFIG_DIR . '/' . $TARGET_DIR . '/ui';\nLink $BUILD_DIR => '.';\nExport qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );\nBuild $BUILD_DIR . '/ui/Conscript';\n\n# core\nif ($no_core eq 1)\n{\n  return;\n}\n\n$INSTALL_DIR = $INSTALL_BASEDIR;\n$BUILD_DIR = $CONFIG_DIR . '/core/dedicated';\nLink $BUILD_DIR => '.';\n$hack = $BASE_CFLAGS; # hit me!\n$BASE_CFLAGS .= '-DDEDICATED ';\nExport qw( BASE_CFLAGS BUILD_DIR INSTALL_DIR CC CXX LINK );\nBuild $BUILD_DIR . '/unix/Conscript-dedicated';\n$BASE_CFLAGS = $hack;\n\n\n\n$TARGETNAME = 'linuxquake3';\n$BUILD_DIR = $CONFIG_DIR . '/core/client';\n$BASE_LDFLAGS = '';\n\nLink $BUILD_DIR => '.';\nExport qw( BASE_CFLAGS BASE_LDFLAGS BUILD_DIR INSTALL_DIR TARGETNAME CC CXX LINK );\nBuild $BUILD_DIR . '/unix/Conscript-client';\n\nif ($do_smp eq 1)\n{\n\t$TARGETNAME = 'linuxquake3-smp';\n\t$BUILD_DIR = $CONFIG_DIR . '/core/client-smp';\n\t$BASE_CFLAGS .= '-DSMP ';\n\t$BASE_LDFLAGS = '-lpthread ';\n\t\n  Link $BUILD_DIR => '.';\n  Export qw( BASE_CFLAGS BASE_LDFLAGS BUILD_DIR INSTALL_DIR TARGETNAME CC CXX LINK );\n  Build $BUILD_DIR . '/unix/Conscript-client';\t\n}\n\nif ($NO_VM eq 0 && $do_pk3 eq 1)\n{\n\t# build the PK3s\n\t$INSTALL_DIR = $INSTALL_BASEDIR;\n\t$BUILD_DIR = $CONFIG_DIR . '/pk3-builder';\n\tLink $BUILD_DIR => 'unix';\n\tExport qw( INSTALL_DIR BUILD_DIR CONFIG_DIR CC CXX LINK );\n\tBuild $BUILD_DIR . '/Conscript-pk3';\n}\n\nif ($do_setup eq 1)\n{\n  Link $CONFIG_DIR => '.';\n  Export qw( INSTALL_BASEDIR );\n  Build $CONFIG_DIR . '/unix/Conscript-setup';\n}\n\nHelp \n\"\nUsage: cons [-h] [ -- [release|debug] [novm] [noso] [nosmp] [master_server=<adr>] [auth_server=<adr>] [auth_port=<port>] [pk3] [bspc] [setup] [sdk]]\nDefault build type is Debug, specifying '-- release' on the\ncommand line builds a Release version (NOTE that this option\nonly affects the native libraries).\n\nnovm: will not build the VMs\nnoso: will not build the so\n\nbelow are for core builds only:\n\nnosmp : do not build the SMP-enabled version of the renderer\npk3   : generate the pk3s on the fly (defined in unix/Conscript-pk3)\nbspc  : build bspc\nsetup : build setup \nsdk   : build the mod sdk\n\"\n;\n"
  },
  {
    "path": "code/Makefile",
    "content": "# nasty ugly to get build system working from Anjuta\nall:\n\tif [ `hostname` == sparkle ] ; then ./unix/pcons-2.3.1 -j4 -- novm noso ; else ./unix/cons ; fi\n"
  },
  {
    "path": "code/botlib/aasfile.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n\n//NOTE:\tint =\tdefault signed\n//\t\t\t\tdefault long\n\n#define AASID\t\t\t\t\t\t(('S'<<24)+('A'<<16)+('A'<<8)+'E')\n#define AASVERSION_OLD\t\t\t\t4\n#define AASVERSION\t\t\t\t\t5\n\n//presence types\n#define PRESENCE_NONE\t\t\t\t1\n#define PRESENCE_NORMAL\t\t\t\t2\n#define PRESENCE_CROUCH\t\t\t\t4\n\n//travel types\n#define MAX_TRAVELTYPES\t\t\t\t32\n#define TRAVEL_INVALID\t\t\t\t1\t\t//temporary not possible\n#define TRAVEL_WALK\t\t\t\t\t2\t\t//walking\n#define TRAVEL_CROUCH\t\t\t\t3\t\t//crouching\n#define TRAVEL_BARRIERJUMP\t\t\t4\t\t//jumping onto a barrier\n#define TRAVEL_JUMP\t\t\t\t\t5\t\t//jumping\n#define TRAVEL_LADDER\t\t\t\t6\t\t//climbing a ladder\n#define TRAVEL_WALKOFFLEDGE\t\t\t7\t\t//walking of a ledge\n#define TRAVEL_SWIM\t\t\t\t\t8\t\t//swimming\n#define TRAVEL_WATERJUMP\t\t\t9\t\t//jump out of the water\n#define TRAVEL_TELEPORT\t\t\t\t10\t\t//teleportation\n#define TRAVEL_ELEVATOR\t\t\t\t11\t\t//travel by elevator\n#define TRAVEL_ROCKETJUMP\t\t\t12\t\t//rocket jumping required for travel\n#define TRAVEL_BFGJUMP\t\t\t\t13\t\t//bfg jumping required for travel\n#define TRAVEL_GRAPPLEHOOK\t\t\t14\t\t//grappling hook required for travel\n#define TRAVEL_DOUBLEJUMP\t\t\t15\t\t//double jump\n#define TRAVEL_RAMPJUMP\t\t\t\t16\t\t//ramp jump\n#define TRAVEL_STRAFEJUMP\t\t\t17\t\t//strafe jump\n#define TRAVEL_JUMPPAD\t\t\t\t18\t\t//jump pad\n#define TRAVEL_FUNCBOB\t\t\t\t19\t\t//func bob\n\n//additional travel flags\n#define TRAVELTYPE_MASK\t\t\t\t0xFFFFFF\n#define TRAVELFLAG_NOTTEAM1\t\t\t(1 << 24)\n#define TRAVELFLAG_NOTTEAM2\t\t\t(2 << 24)\n\n//face flags\n#define FACE_SOLID\t\t\t\t\t1\t\t//just solid at the other side\n#define FACE_LADDER\t\t\t\t\t2\t\t//ladder\n#define FACE_GROUND\t\t\t\t\t4\t\t//standing on ground when in this face\n#define FACE_GAP\t\t\t\t\t8\t\t//gap in the ground\n#define FACE_LIQUID\t\t\t\t\t16\t\t//face seperating two areas with liquid\n#define FACE_LIQUIDSURFACE\t\t\t32\t\t//face seperating liquid and air\n#define FACE_BRIDGE\t\t\t\t\t64\t\t//can walk over this face if bridge is closed\n\n//area contents\n#define AREACONTENTS_WATER\t\t\t\t1\n#define AREACONTENTS_LAVA\t\t\t\t2\n#define AREACONTENTS_SLIME\t\t\t\t4\n#define AREACONTENTS_CLUSTERPORTAL\t\t8\n#define AREACONTENTS_TELEPORTAL\t\t\t16\n#define AREACONTENTS_ROUTEPORTAL\t\t32\n#define AREACONTENTS_TELEPORTER\t\t\t64\n#define AREACONTENTS_JUMPPAD\t\t\t128\n#define AREACONTENTS_DONOTENTER\t\t\t256\n#define\tAREACONTENTS_VIEWPORTAL\t\t\t512\n#define AREACONTENTS_MOVER\t\t\t\t1024\n#define AREACONTENTS_NOTTEAM1\t\t\t2048\n#define AREACONTENTS_NOTTEAM2\t\t\t4096\n//number of model of the mover inside this area\n#define AREACONTENTS_MODELNUMSHIFT\t\t24\n#define AREACONTENTS_MAXMODELNUM\t\t0xFF\n#define AREACONTENTS_MODELNUM\t\t\t(AREACONTENTS_MAXMODELNUM << AREACONTENTS_MODELNUMSHIFT)\n\n//area flags\n#define AREA_GROUNDED\t\t\t\t1\t\t//bot can stand on the ground\n#define AREA_LADDER\t\t\t\t\t2\t\t//area contains one or more ladder faces\n#define AREA_LIQUID\t\t\t\t\t4\t\t//area contains a liquid\n#define AREA_DISABLED\t\t\t\t8\t\t//area is disabled for routing when set\n#define AREA_BRIDGE\t\t\t\t\t16\t\t//area ontop of a bridge\n\n//aas file header lumps\n#define AAS_LUMPS\t\t\t\t\t14\n#define AASLUMP_BBOXES\t\t\t\t0\n#define AASLUMP_VERTEXES\t\t\t1\n#define AASLUMP_PLANES\t\t\t\t2\n#define AASLUMP_EDGES\t\t\t\t3\n#define AASLUMP_EDGEINDEX\t\t\t4\n#define AASLUMP_FACES\t\t\t\t5\n#define AASLUMP_FACEINDEX\t\t\t6\n#define AASLUMP_AREAS\t\t\t\t7\n#define AASLUMP_AREASETTINGS\t\t8\n#define AASLUMP_REACHABILITY\t\t9\n#define AASLUMP_NODES\t\t\t\t10\n#define AASLUMP_PORTALS\t\t\t\t11\n#define AASLUMP_PORTALINDEX\t\t\t12\n#define AASLUMP_CLUSTERS\t\t\t13\n\n//========== bounding box =========\n\n//bounding box\ntypedef struct aas_bbox_s\n{\n\tint presencetype;\n\tint flags;\n\tvec3_t mins, maxs;\n} aas_bbox_t;\n\n//============ settings ===========\n\n//reachability to another area\ntypedef struct aas_reachability_s\n{\n\tint areanum;\t\t\t\t\t\t//number of the reachable area\n\tint facenum;\t\t\t\t\t\t//number of the face towards the other area\n\tint edgenum;\t\t\t\t\t\t//number of the edge towards the other area\n\tvec3_t start;\t\t\t\t\t\t//start point of inter area movement\n\tvec3_t end;\t\t\t\t\t\t\t//end point of inter area movement\n\tint traveltype;\t\t\t\t\t//type of travel required to get to the area\n\tunsigned short int traveltime;//travel time of the inter area movement\n} aas_reachability_t;\n\n//area settings\ntypedef struct aas_areasettings_s\n{\n\t//could also add all kind of statistic fields\n\tint contents;\t\t\t\t\t\t//contents of the area\n\tint areaflags;\t\t\t\t\t\t//several area flags\n\tint presencetype;\t\t\t\t\t//how a bot can be present in this area\n\tint cluster;\t\t\t\t\t\t//cluster the area belongs to, if negative it's a portal\n\tint clusterareanum;\t\t\t\t//number of the area in the cluster\n\tint numreachableareas;\t\t\t//number of reachable areas from this one\n\tint firstreachablearea;\t\t\t//first reachable area in the reachable area index\n} aas_areasettings_t;\n\n//cluster portal\ntypedef struct aas_portal_s\n{\n\tint areanum;\t\t\t\t\t\t//area that is the actual portal\n\tint frontcluster;\t\t\t\t\t//cluster at front of portal\n\tint backcluster;\t\t\t\t\t//cluster at back of portal\n\tint clusterareanum[2];\t\t\t//number of the area in the front and back cluster\n} aas_portal_t;\n\n//cluster portal index\ntypedef int aas_portalindex_t;\n\n//cluster\ntypedef struct aas_cluster_s\n{\n\tint numareas;\t\t\t\t\t\t//number of areas in the cluster\n\tint numreachabilityareas;\t\t\t//number of areas with reachabilities\n\tint numportals;\t\t\t\t\t\t//number of cluster portals\n\tint firstportal;\t\t\t\t\t//first cluster portal in the index\n} aas_cluster_t;\n\n//============ 3d definition ============\n\ntypedef vec3_t aas_vertex_t;\n\n//just a plane in the third dimension\ntypedef struct aas_plane_s\n{\n\tvec3_t normal;\t\t\t\t\t\t//normal vector of the plane\n\tfloat dist;\t\t\t\t\t\t\t//distance of the plane (normal vector * distance = point in plane)\n\tint type;\n} aas_plane_t;\n\n//edge\ntypedef struct aas_edge_s\n{\n\tint v[2];\t\t\t\t\t\t\t//numbers of the vertexes of this edge\n} aas_edge_t;\n\n//edge index, negative if vertexes are reversed\ntypedef int aas_edgeindex_t;\n\n//a face bounds an area, often it will also seperate two areas\ntypedef struct aas_face_s\n{\n\tint planenum;\t\t\t\t\t\t//number of the plane this face is in\n\tint faceflags;\t\t\t\t\t\t//face flags (no use to create face settings for just this field)\n\tint numedges;\t\t\t\t\t\t//number of edges in the boundary of the face\n\tint firstedge;\t\t\t\t\t\t//first edge in the edge index\n\tint frontarea;\t\t\t\t\t\t//area at the front of this face\n\tint backarea;\t\t\t\t\t\t//area at the back of this face\n} aas_face_t;\n\n//face index, stores a negative index if backside of face\ntypedef int aas_faceindex_t;\n\n//area with a boundary of faces\ntypedef struct aas_area_s\n{\n\tint areanum;\t\t\t\t\t\t//number of this area\n\t//3d definition\n\tint numfaces;\t\t\t\t\t\t//number of faces used for the boundary of the area\n\tint firstface;\t\t\t\t\t\t//first face in the face index used for the boundary of the area\n\tvec3_t mins;\t\t\t\t\t\t//mins of the area\n\tvec3_t maxs;\t\t\t\t\t\t//maxs of the area\n\tvec3_t center;\t\t\t\t\t\t//'center' of the area\n} aas_area_t;\n\n//nodes of the bsp tree\ntypedef struct aas_node_s\n{\n\tint planenum;\n\tint children[2];\t\t\t\t\t//child nodes of this node, or areas as leaves when negative\n\t\t\t\t\t\t\t\t\t\t//when a child is zero it's a solid leaf\n} aas_node_t;\n\n//=========== aas file ===============\n\n//header lump\ntypedef struct\n{\n\tint fileofs;\n\tint filelen;\n} aas_lump_t;\n\n//aas file header\ntypedef struct aas_header_s\n{\n\tint ident;\n\tint version;\n\tint bspchecksum;\n\t//data entries\n\taas_lump_t lumps[AAS_LUMPS];\n} aas_header_t;\n\n\n//====== additional information ======\n/*\n\n-\twhen a node child is a solid leaf the node child number is zero\n-\ttwo adjacent areas (sharing a plane at opposite sides) share a face\n\tthis face is a portal between the areas\n-\twhen an area uses a face from the faceindex with a positive index\n\tthen the face plane normal points into the area\n-\tthe face edges are stored counter clockwise using the edgeindex\n-\ttwo adjacent convex areas (sharing a face) only share One face\n\tthis is a simple result of the areas being convex\n-\tthe areas can't have a mixture of ground and gap faces\n\tother mixtures of faces in one area are allowed\n-\tareas with the AREACONTENTS_CLUSTERPORTAL in the settings have\n\tthe cluster number set to the negative portal number\n-\tedge zero is a dummy\n-\tface zero is a dummy\n-\tarea zero is a dummy\n-\tnode zero is a dummy\n*/\n"
  },
  {
    "path": "code/botlib/be_aas_bsp.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_bsp.h\n *\n * desc:\t\tAAS\n *\n * $Archive: /source/code/botlib/be_aas_bsp.h $\n *\n *****************************************************************************/\n\n#ifdef AASINTERN\n//loads the given BSP file\nint AAS_LoadBSPFile(void);\n//dump the loaded BSP data\nvoid AAS_DumpBSPData(void);\n//unlink the given entity from the bsp tree leaves\nvoid AAS_UnlinkFromBSPLeaves(bsp_link_t *leaves);\n//link the given entity to the bsp tree leaves of the given model\nbsp_link_t *AAS_BSPLinkEntity(vec3_t absmins,\n\t\t\t\t\t\t\t\t\t\tvec3_t absmaxs,\n\t\t\t\t\t\t\t\t\t\tint entnum,\n\t\t\t\t\t\t\t\t\t\tint modelnum);\n\n//calculates collision with given entity\nqboolean AAS_EntityCollision(int entnum,\n\t\t\t\t\t\t\t\t\t\tvec3_t start,\n\t\t\t\t\t\t\t\t\t\tvec3_t boxmins,\n\t\t\t\t\t\t\t\t\t\tvec3_t boxmaxs,\n\t\t\t\t\t\t\t\t\t\tvec3_t end,\n\t\t\t\t\t\t\t\t\t\tint contentmask,\n\t\t\t\t\t\t\t\t\t\tbsp_trace_t *trace);\n//for debugging\nvoid AAS_PrintFreeBSPLinks(char *str);\n//\n#endif //AASINTERN\n\n#define MAX_EPAIRKEY\t\t128\n\n//trace through the world\nbsp_trace_t AAS_Trace(\tvec3_t start,\n\t\t\t\t\t\t\t\tvec3_t mins,\n\t\t\t\t\t\t\t\tvec3_t maxs,\n\t\t\t\t\t\t\t\tvec3_t end,\n\t\t\t\t\t\t\t\tint passent,\n\t\t\t\t\t\t\t\tint contentmask);\n//returns the contents at the given point\nint AAS_PointContents(vec3_t point);\n//returns true when p2 is in the PVS of p1\nqboolean AAS_inPVS(vec3_t p1, vec3_t p2);\n//returns true when p2 is in the PHS of p1\nqboolean AAS_inPHS(vec3_t p1, vec3_t p2);\n//returns true if the given areas are connected\nqboolean AAS_AreasConnected(int area1, int area2);\n//creates a list with entities totally or partly within the given box\nint AAS_BoxEntities(vec3_t absmins, vec3_t absmaxs, int *list, int maxcount);\n//gets the mins, maxs and origin of a BSP model\nvoid AAS_BSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t mins, vec3_t maxs, vec3_t origin);\n//handle to the next bsp entity\nint AAS_NextBSPEntity(int ent);\n//return the value of the BSP epair key\nint AAS_ValueForBSPEpairKey(int ent, char *key, char *value, int size);\n//get a vector for the BSP epair key\nint AAS_VectorForBSPEpairKey(int ent, char *key, vec3_t v);\n//get a float for the BSP epair key\nint AAS_FloatForBSPEpairKey(int ent, char *key, float *value);\n//get an integer for the BSP epair key\nint AAS_IntForBSPEpairKey(int ent, char *key, int *value);\n\n"
  },
  {
    "path": "code/botlib/be_aas_bspq3.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_bspq3.c\n *\n * desc:\t\tBSP, Environment Sampling\n *\n * $Archive: /MissionPack/code/botlib/be_aas_bspq3.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_memory.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#include \"aasfile.h\"\n#include \"../game/botlib.h\"\n#include \"../game/be_aas.h\"\n#include \"be_aas_funcs.h\"\n#include \"be_aas_def.h\"\n\nextern botlib_import_t botimport;\n\n//#define TRACE_DEBUG\n\n#define ON_EPSILON\t\t0.005\n//#define DEG2RAD( a ) (( a * M_PI ) / 180.0F)\n\n#define MAX_BSPENTITIES\t\t2048\n\ntypedef struct rgb_s\n{\n\tint red;\n\tint green;\n\tint blue;\n} rgb_t;\n\n//bsp entity epair\ntypedef struct bsp_epair_s\n{\n\tchar *key;\n\tchar *value;\n\tstruct bsp_epair_s *next;\n} bsp_epair_t;\n\n//bsp data entity\ntypedef struct bsp_entity_s\n{\n\tbsp_epair_t *epairs;\n} bsp_entity_t;\n\n//id Sofware BSP data\ntypedef struct bsp_s\n{\n\t//true when bsp file is loaded\n\tint loaded;\n\t//entity data\n\tint entdatasize;\n\tchar *dentdata;\n\t//bsp entities\n\tint numentities;\n\tbsp_entity_t entities[MAX_BSPENTITIES];\n} bsp_t;\n\n//global bsp\nbsp_t bspworld;\n\n\n#ifdef BSP_DEBUG\ntypedef struct cname_s\n{\n\tint value;\n\tchar *name;\n} cname_t;\n\ncname_t contentnames[] =\n{\n\t{CONTENTS_SOLID,\"CONTENTS_SOLID\"},\n\t{CONTENTS_WINDOW,\"CONTENTS_WINDOW\"},\n\t{CONTENTS_AUX,\"CONTENTS_AUX\"},\n\t{CONTENTS_LAVA,\"CONTENTS_LAVA\"},\n\t{CONTENTS_SLIME,\"CONTENTS_SLIME\"},\n\t{CONTENTS_WATER,\"CONTENTS_WATER\"},\n\t{CONTENTS_MIST,\"CONTENTS_MIST\"},\n\t{LAST_VISIBLE_CONTENTS,\"LAST_VISIBLE_CONTENTS\"},\n\n\t{CONTENTS_AREAPORTAL,\"CONTENTS_AREAPORTAL\"},\n\t{CONTENTS_PLAYERCLIP,\"CONTENTS_PLAYERCLIP\"},\n\t{CONTENTS_MONSTERCLIP,\"CONTENTS_MONSTERCLIP\"},\n\t{CONTENTS_CURRENT_0,\"CONTENTS_CURRENT_0\"},\n\t{CONTENTS_CURRENT_90,\"CONTENTS_CURRENT_90\"},\n\t{CONTENTS_CURRENT_180,\"CONTENTS_CURRENT_180\"},\n\t{CONTENTS_CURRENT_270,\"CONTENTS_CURRENT_270\"},\n\t{CONTENTS_CURRENT_UP,\"CONTENTS_CURRENT_UP\"},\n\t{CONTENTS_CURRENT_DOWN,\"CONTENTS_CURRENT_DOWN\"},\n\t{CONTENTS_ORIGIN,\"CONTENTS_ORIGIN\"},\n\t{CONTENTS_MONSTER,\"CONTENTS_MONSTER\"},\n\t{CONTENTS_DEADMONSTER,\"CONTENTS_DEADMONSTER\"},\n\t{CONTENTS_DETAIL,\"CONTENTS_DETAIL\"},\n\t{CONTENTS_TRANSLUCENT,\"CONTENTS_TRANSLUCENT\"},\n\t{CONTENTS_LADDER,\"CONTENTS_LADDER\"},\n\t{0, 0}\n};\n\nvoid PrintContents(int contents)\n{\n\tint i;\n\n\tfor (i = 0; contentnames[i].value; i++)\n\t{\n\t\tif (contents & contentnames[i].value)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"%s\\n\", contentnames[i].name);\n\t\t} //end if\n\t} //end for\n} //end of the function PrintContents\n\n#endif // BSP_DEBUG\n//===========================================================================\n// traces axial boxes of any size through the world\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbsp_trace_t AAS_Trace(vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask)\n{\n\tbsp_trace_t bsptrace;\n\tbotimport.Trace(&bsptrace, start, mins, maxs, end, passent, contentmask);\n\treturn bsptrace;\n} //end of the function AAS_Trace\n//===========================================================================\n// returns the contents at the given point\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_PointContents(vec3_t point)\n{\n\treturn botimport.PointContents(point);\n} //end of the function AAS_PointContents\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_EntityCollision(int entnum,\n\t\t\t\t\tvec3_t start, vec3_t boxmins, vec3_t boxmaxs, vec3_t end,\n\t\t\t\t\t\t\t\tint contentmask, bsp_trace_t *trace)\n{\n\tbsp_trace_t enttrace;\n\n\tbotimport.EntityTrace(&enttrace, start, boxmins, boxmaxs, end, entnum, contentmask);\n\tif (enttrace.fraction < trace->fraction)\n\t{\n\t\tCom_Memcpy(trace, &enttrace, sizeof(bsp_trace_t));\n\t\treturn qtrue;\n\t} //end if\n\treturn qfalse;\n} //end of the function AAS_EntityCollision\n//===========================================================================\n// returns true if in Potentially Hearable Set\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_inPVS(vec3_t p1, vec3_t p2)\n{\n\treturn botimport.inPVS(p1, p2);\n} //end of the function AAS_InPVS\n//===========================================================================\n// returns true if in Potentially Visible Set\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_inPHS(vec3_t p1, vec3_t p2)\n{\n\treturn qtrue;\n} //end of the function AAS_inPHS\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_BSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t mins, vec3_t maxs, vec3_t origin)\n{\n\tbotimport.BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, origin);\n} //end of the function AAS_BSPModelMinsMaxs\n//===========================================================================\n// unlinks the entity from all leaves\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_UnlinkFromBSPLeaves(bsp_link_t *leaves)\n{\n} //end of the function AAS_UnlinkFromBSPLeaves\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbsp_link_t *AAS_BSPLinkEntity(vec3_t absmins, vec3_t absmaxs, int entnum, int modelnum)\n{\n\treturn NULL;\n} //end of the function AAS_BSPLinkEntity\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_BoxEntities(vec3_t absmins, vec3_t absmaxs, int *list, int maxcount)\n{\n\treturn 0;\n} //end of the function AAS_BoxEntities\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_NextBSPEntity(int ent)\n{\n\tent++;\n\tif (ent >= 1 && ent < bspworld.numentities) return ent;\n\treturn 0;\n} //end of the function AAS_NextBSPEntity\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_BSPEntityInRange(int ent)\n{\n\tif (ent <= 0 || ent >= bspworld.numentities)\n\t{\n\t\tbotimport.Print(PRT_MESSAGE, \"bsp entity out of range\\n\");\n\t\treturn qfalse;\n\t} //end if\n\treturn qtrue;\n} //end of the function AAS_BSPEntityInRange\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_ValueForBSPEpairKey(int ent, char *key, char *value, int size)\n{\n\tbsp_epair_t *epair;\n\n\tvalue[0] = '\\0';\n\tif (!AAS_BSPEntityInRange(ent)) return qfalse;\n\tfor (epair = bspworld.entities[ent].epairs; epair; epair = epair->next)\n\t{\n\t\tif (!strcmp(epair->key, key))\n\t\t{\n\t\t\tstrncpy(value, epair->value, size-1);\n\t\t\tvalue[size-1] = '\\0';\n\t\t\treturn qtrue;\n\t\t} //end if\n\t} //end for\n\treturn qfalse;\n} //end of the function AAS_FindBSPEpair\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_VectorForBSPEpairKey(int ent, char *key, vec3_t v)\n{\n\tchar buf[MAX_EPAIRKEY];\n\tdouble v1, v2, v3;\n\n\tVectorClear(v);\n\tif (!AAS_ValueForBSPEpairKey(ent, key, buf, MAX_EPAIRKEY)) return qfalse;\n\t//scanf into doubles, then assign, so it is vec_t size independent\n\tv1 = v2 = v3 = 0;\n\tsscanf(buf, \"%lf %lf %lf\", &v1, &v2, &v3);\n\tv[0] = v1;\n\tv[1] = v2;\n\tv[2] = v3;\n\treturn qtrue;\n} //end of the function AAS_VectorForBSPEpairKey\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_FloatForBSPEpairKey(int ent, char *key, float *value)\n{\n\tchar buf[MAX_EPAIRKEY];\n\t\n\t*value = 0;\n\tif (!AAS_ValueForBSPEpairKey(ent, key, buf, MAX_EPAIRKEY)) return qfalse;\n\t*value = atof(buf);\n\treturn qtrue;\n} //end of the function AAS_FloatForBSPEpairKey\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_IntForBSPEpairKey(int ent, char *key, int *value)\n{\n\tchar buf[MAX_EPAIRKEY];\n\t\n\t*value = 0;\n\tif (!AAS_ValueForBSPEpairKey(ent, key, buf, MAX_EPAIRKEY)) return qfalse;\n\t*value = atoi(buf);\n\treturn qtrue;\n} //end of the function AAS_IntForBSPEpairKey\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FreeBSPEntities(void)\n{\n\tint i;\n\tbsp_entity_t *ent;\n\tbsp_epair_t *epair, *nextepair;\n\n\tfor (i = 1; i < bspworld.numentities; i++)\n\t{\n\t\tent = &bspworld.entities[i];\n\t\tfor (epair = ent->epairs; epair; epair = nextepair)\n\t\t{\n\t\t\tnextepair = epair->next;\n\t\t\t//\n\t\t\tif (epair->key) FreeMemory(epair->key);\n\t\t\tif (epair->value) FreeMemory(epair->value);\n\t\t\tFreeMemory(epair);\n\t\t} //end for\n\t} //end for\n\tbspworld.numentities = 0;\n} //end of the function AAS_FreeBSPEntities\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ParseBSPEntities(void)\n{\n\tscript_t *script;\n\ttoken_t token;\n\tbsp_entity_t *ent;\n\tbsp_epair_t *epair;\n\n\tscript = LoadScriptMemory(bspworld.dentdata, bspworld.entdatasize, \"entdata\");\n\tSetScriptFlags(script, SCFL_NOSTRINGWHITESPACES|SCFL_NOSTRINGESCAPECHARS);//SCFL_PRIMITIVE);\n\n\tbspworld.numentities = 1;\n\n\twhile(PS_ReadToken(script, &token))\n\t{\n\t\tif (strcmp(token.string, \"{\"))\n\t\t{\n\t\t\tScriptError(script, \"invalid %s\\n\", token.string);\n\t\t\tAAS_FreeBSPEntities();\n\t\t\tFreeScript(script);\n\t\t\treturn;\n\t\t} //end if\n\t\tif (bspworld.numentities >= MAX_BSPENTITIES)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"too many entities in BSP file\\n\");\n\t\t\tbreak;\n\t\t} //end if\n\t\tent = &bspworld.entities[bspworld.numentities];\n\t\tbspworld.numentities++;\n\t\tent->epairs = NULL;\n\t\twhile(PS_ReadToken(script, &token))\n\t\t{\n\t\t\tif (!strcmp(token.string, \"}\")) break;\n\t\t\tepair = (bsp_epair_t *) GetClearedHunkMemory(sizeof(bsp_epair_t));\n\t\t\tepair->next = ent->epairs;\n\t\t\tent->epairs = epair;\n\t\t\tif (token.type != TT_STRING)\n\t\t\t{\n\t\t\t\tScriptError(script, \"invalid %s\\n\", token.string);\n\t\t\t\tAAS_FreeBSPEntities();\n\t\t\t\tFreeScript(script);\n\t\t\t\treturn;\n\t\t\t} //end if\n\t\t\tStripDoubleQuotes(token.string);\n\t\t\tepair->key = (char *) GetHunkMemory(strlen(token.string) + 1);\n\t\t\tstrcpy(epair->key, token.string);\n\t\t\tif (!PS_ExpectTokenType(script, TT_STRING, 0, &token))\n\t\t\t{\n\t\t\t\tAAS_FreeBSPEntities();\n\t\t\t\tFreeScript(script);\n\t\t\t\treturn;\n\t\t\t} //end if\n\t\t\tStripDoubleQuotes(token.string);\n\t\t\tepair->value = (char *) GetHunkMemory(strlen(token.string) + 1);\n\t\t\tstrcpy(epair->value, token.string);\n\t\t} //end while\n\t\tif (strcmp(token.string, \"}\"))\n\t\t{\n\t\t\tScriptError(script, \"missing }\\n\");\n\t\t\tAAS_FreeBSPEntities();\n\t\t\tFreeScript(script);\n\t\t\treturn;\n\t\t} //end if\n\t} //end while\n\tFreeScript(script);\n} //end of the function AAS_ParseBSPEntities\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_BSPTraceLight(vec3_t start, vec3_t end, vec3_t endpos, int *red, int *green, int *blue)\n{\n\treturn 0;\n} //end of the function AAS_BSPTraceLight\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_DumpBSPData(void)\n{\n\tAAS_FreeBSPEntities();\n\n\tif (bspworld.dentdata) FreeMemory(bspworld.dentdata);\n\tbspworld.dentdata = NULL;\n\tbspworld.entdatasize = 0;\n\t//\n\tbspworld.loaded = qfalse;\n\tCom_Memset( &bspworld, 0, sizeof(bspworld) );\n} //end of the function AAS_DumpBSPData\n//===========================================================================\n// load an bsp file\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_LoadBSPFile(void)\n{\n\tAAS_DumpBSPData();\n\tbspworld.entdatasize = strlen(botimport.BSPEntityData()) + 1;\n\tbspworld.dentdata = (char *) GetClearedHunkMemory(bspworld.entdatasize);\n\tCom_Memcpy(bspworld.dentdata, botimport.BSPEntityData(), bspworld.entdatasize);\n\tAAS_ParseBSPEntities();\n\tbspworld.loaded = qtrue;\n\treturn BLERR_NOERROR;\n} //end of the function AAS_LoadBSPFile\n"
  },
  {
    "path": "code/botlib/be_aas_cluster.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_cluster.c\n *\n * desc:\t\tarea clustering\n *\n * $Archive: /MissionPack/code/botlib/be_aas_cluster.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_memory.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#include \"l_log.h\"\n#include \"l_memory.h\"\n#include \"l_libvar.h\"\n#include \"aasfile.h\"\n#include \"../game/botlib.h\"\n#include \"../game/be_aas.h\"\n#include \"be_aas_funcs.h\"\n#include \"be_aas_def.h\"\n\nextern botlib_import_t botimport;\n\n#define AAS_MAX_PORTALS\t\t\t\t\t65536\n#define AAS_MAX_PORTALINDEXSIZE\t\t\t65536\n#define AAS_MAX_CLUSTERS\t\t\t\t65536\n//\n#define MAX_PORTALAREAS\t\t\t1024\n\n// do not flood through area faces, only use reachabilities\nint nofaceflood = qtrue;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_RemoveClusterAreas(void)\n{\n\tint i;\n\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\taasworld.areasettings[i].cluster = 0;\n\t} //end for\n} //end of the function AAS_RemoveClusterAreas\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ClearCluster(int clusternum)\n{\n\tint i;\n\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\tif (aasworld.areasettings[i].cluster == clusternum)\n\t\t{\n\t\t\taasworld.areasettings[i].cluster = 0;\n\t\t} //end if\n\t} //end for\n} //end of the function AAS_ClearCluster\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_RemovePortalsClusterReference(int clusternum)\n{\n\tint portalnum;\n\n\tfor (portalnum = 1; portalnum < aasworld.numportals; portalnum++)\n\t{\n\t\tif (aasworld.portals[portalnum].frontcluster == clusternum)\n\t\t{\n\t\t\taasworld.portals[portalnum].frontcluster = 0;\n\t\t} //end if\n\t\tif (aasworld.portals[portalnum].backcluster == clusternum)\n\t\t{\n\t\t\taasworld.portals[portalnum].backcluster = 0;\n\t\t} //end if\n\t} //end for\n} //end of the function AAS_RemovePortalsClusterReference\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_UpdatePortal(int areanum, int clusternum)\n{\n\tint portalnum;\n\taas_portal_t *portal;\n\taas_cluster_t *cluster;\n\n\t//find the portal of the area\n\tfor (portalnum = 1; portalnum < aasworld.numportals; portalnum++)\n\t{\n\t\tif (aasworld.portals[portalnum].areanum == areanum) break;\n\t} //end for\n\t//\n\tif (portalnum == aasworld.numportals)\n\t{\n\t\tAAS_Error(\"no portal of area %d\", areanum);\n\t\treturn qtrue;\n\t} //end if\n\t//\n\tportal = &aasworld.portals[portalnum];\n\t//if the portal is already fully updated\n\tif (portal->frontcluster == clusternum) return qtrue;\n\tif (portal->backcluster == clusternum) return qtrue;\n\t//if the portal has no front cluster yet\n\tif (!portal->frontcluster)\n\t{\n\t\tportal->frontcluster = clusternum;\n\t} //end if\n\t//if the portal has no back cluster yet\n\telse if (!portal->backcluster)\n\t{\n\t\tportal->backcluster = clusternum;\n\t} //end else if\n\telse\n\t{\n\t\t//remove the cluster portal flag contents\n\t\taasworld.areasettings[areanum].contents &= ~AREACONTENTS_CLUSTERPORTAL;\n\t\tLog_Write(\"portal area %d is seperating more than two clusters\\r\\n\", areanum);\n\t\treturn qfalse;\n\t} //end else\n\tif (aasworld.portalindexsize >= AAS_MAX_PORTALINDEXSIZE)\n\t{\n\t\tAAS_Error(\"AAS_MAX_PORTALINDEXSIZE\");\n\t\treturn qtrue;\n\t} //end if\n\t//set the area cluster number to the negative portal number\n\taasworld.areasettings[areanum].cluster = -portalnum;\n\t//add the portal to the cluster using the portal index\n\tcluster = &aasworld.clusters[clusternum];\n\taasworld.portalindex[cluster->firstportal + cluster->numportals] = portalnum;\n\taasworld.portalindexsize++;\n\tcluster->numportals++;\n\treturn qtrue;\n} //end of the function AAS_UpdatePortal\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_FloodClusterAreas_r(int areanum, int clusternum)\n{\n\taas_area_t *area;\n\taas_face_t *face;\n\tint facenum, i;\n\n\t//\n\tif (areanum <= 0 || areanum >= aasworld.numareas)\n\t{\n\t\tAAS_Error(\"AAS_FloodClusterAreas_r: areanum out of range\");\n\t\treturn qfalse;\n\t} //end if\n\t//if the area is already part of a cluster\n\tif (aasworld.areasettings[areanum].cluster > 0)\n\t{\n\t\tif (aasworld.areasettings[areanum].cluster == clusternum) return qtrue;\n\t\t//\n\t\t//there's a reachability going from one cluster to another only in one direction\n\t\t//\n\t\tAAS_Error(\"cluster %d touched cluster %d at area %d\\r\\n\",\n\t\t\t\tclusternum, aasworld.areasettings[areanum].cluster, areanum);\n\t\treturn qfalse;\n\t} //end if\n\t//don't add the cluster portal areas to the clusters\n\tif (aasworld.areasettings[areanum].contents & AREACONTENTS_CLUSTERPORTAL)\n\t{\n\t\treturn AAS_UpdatePortal(areanum, clusternum);\n\t} //end if\n\t//set the area cluster number\n\taasworld.areasettings[areanum].cluster = clusternum;\n\taasworld.areasettings[areanum].clusterareanum =\n\t\t\t\taasworld.clusters[clusternum].numareas;\n\t//the cluster has an extra area\n\taasworld.clusters[clusternum].numareas++;\n\n\tarea = &aasworld.areas[areanum];\n\t//use area faces to flood into adjacent areas\n\tif (!nofaceflood)\n\t{\n\t\tfor (i = 0; i < area->numfaces; i++)\n\t\t{\n\t\t\tfacenum = abs(aasworld.faceindex[area->firstface + i]);\n\t\t\tface = &aasworld.faces[facenum];\n\t\t\tif (face->frontarea == areanum)\n\t\t\t{\n\t\t\t\tif (face->backarea) if (!AAS_FloodClusterAreas_r(face->backarea, clusternum)) return qfalse;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (face->frontarea) if (!AAS_FloodClusterAreas_r(face->frontarea, clusternum)) return qfalse;\n\t\t\t} //end else\n\t\t} //end for\n\t} //end if\n\t//use the reachabilities to flood into other areas\n\tfor (i = 0; i < aasworld.areasettings[areanum].numreachableareas; i++)\n\t{\n\t\tif (!aasworld.reachability[\n\t\t\t\t\taasworld.areasettings[areanum].firstreachablearea + i].areanum)\n\t\t{\n\t\t\tcontinue;\n\t\t} //end if\n\t\tif (!AAS_FloodClusterAreas_r(aasworld.reachability[\n\t\t\t\taasworld.areasettings[areanum].firstreachablearea + i].areanum, clusternum)) return qfalse;\n\t} //end for\n\treturn qtrue;\n} //end of the function AAS_FloodClusterAreas_r\n//===========================================================================\n// try to flood from all areas without cluster into areas with a cluster set\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_FloodClusterAreasUsingReachabilities(int clusternum)\n{\n\tint i, j, areanum;\n\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\t//if this area already has a cluster set\n\t\tif (aasworld.areasettings[i].cluster)\n\t\t\tcontinue;\n\t\t//if this area is a cluster portal\n\t\tif (aasworld.areasettings[i].contents & AREACONTENTS_CLUSTERPORTAL)\n\t\t\tcontinue;\n\t\t//loop over the reachable areas from this area\n\t\tfor (j = 0; j < aasworld.areasettings[i].numreachableareas; j++)\n\t\t{\n\t\t\t//the reachable area\n\t\t\tareanum = aasworld.reachability[aasworld.areasettings[i].firstreachablearea + j].areanum;\n\t\t\t//if this area is a cluster portal\n\t\t\tif (aasworld.areasettings[areanum].contents & AREACONTENTS_CLUSTERPORTAL)\n\t\t\t\tcontinue;\n\t\t\t//if this area has a cluster set\n\t\t\tif (aasworld.areasettings[areanum].cluster)\n\t\t\t{\n\t\t\t\tif (!AAS_FloodClusterAreas_r(i, clusternum))\n\t\t\t\t\treturn qfalse;\n\t\t\t\ti = 0;\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\treturn qtrue;\n} //end of the function AAS_FloodClusterAreasUsingReachabilities\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_NumberClusterPortals(int clusternum)\n{\n\tint i, portalnum;\n\taas_cluster_t *cluster;\n\taas_portal_t *portal;\n\n\tcluster = &aasworld.clusters[clusternum];\n\tfor (i = 0; i < cluster->numportals; i++)\n\t{\n\t\tportalnum = aasworld.portalindex[cluster->firstportal + i];\n\t\tportal = &aasworld.portals[portalnum];\n\t\tif (portal->frontcluster == clusternum)\n\t\t{\n\t\t\tportal->clusterareanum[0] = cluster->numareas++;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tportal->clusterareanum[1] = cluster->numareas++;\n\t\t} //end else\n\t} //end for\n} //end of the function AAS_NumberClusterPortals\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_NumberClusterAreas(int clusternum)\n{\n\tint i, portalnum;\n\taas_cluster_t *cluster;\n\taas_portal_t *portal;\n\n\taasworld.clusters[clusternum].numareas = 0;\n\taasworld.clusters[clusternum].numreachabilityareas = 0;\n\t//number all areas in this cluster WITH reachabilities\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\t//\n\t\tif (aasworld.areasettings[i].cluster != clusternum) continue;\n\t\t//\n\t\tif (!AAS_AreaReachability(i)) continue;\n\t\t//\n\t\taasworld.areasettings[i].clusterareanum = aasworld.clusters[clusternum].numareas;\n\t\t//the cluster has an extra area\n\t\taasworld.clusters[clusternum].numareas++;\n\t\taasworld.clusters[clusternum].numreachabilityareas++;\n\t} //end for\n\t//number all portals in this cluster WITH reachabilities\n\tcluster = &aasworld.clusters[clusternum];\n\tfor (i = 0; i < cluster->numportals; i++)\n\t{\n\t\tportalnum = aasworld.portalindex[cluster->firstportal + i];\n\t\tportal = &aasworld.portals[portalnum];\n\t\tif (!AAS_AreaReachability(portal->areanum)) continue;\n\t\tif (portal->frontcluster == clusternum)\n\t\t{\n\t\t\tportal->clusterareanum[0] = cluster->numareas++;\n\t\t\taasworld.clusters[clusternum].numreachabilityareas++;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tportal->clusterareanum[1] = cluster->numareas++;\n\t\t\taasworld.clusters[clusternum].numreachabilityareas++;\n\t\t} //end else\n\t} //end for\n\t//number all areas in this cluster WITHOUT reachabilities\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\t//\n\t\tif (aasworld.areasettings[i].cluster != clusternum) continue;\n\t\t//\n\t\tif (AAS_AreaReachability(i)) continue;\n\t\t//\n\t\taasworld.areasettings[i].clusterareanum = aasworld.clusters[clusternum].numareas;\n\t\t//the cluster has an extra area\n\t\taasworld.clusters[clusternum].numareas++;\n\t} //end for\n\t//number all portals in this cluster WITHOUT reachabilities\n\tcluster = &aasworld.clusters[clusternum];\n\tfor (i = 0; i < cluster->numportals; i++)\n\t{\n\t\tportalnum = aasworld.portalindex[cluster->firstportal + i];\n\t\tportal = &aasworld.portals[portalnum];\n\t\tif (AAS_AreaReachability(portal->areanum)) continue;\n\t\tif (portal->frontcluster == clusternum)\n\t\t{\n\t\t\tportal->clusterareanum[0] = cluster->numareas++;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tportal->clusterareanum[1] = cluster->numareas++;\n\t\t} //end else\n\t} //end for\n} //end of the function AAS_NumberClusterAreas\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_FindClusters(void)\n{\n\tint i;\n\taas_cluster_t *cluster;\n\n\tAAS_RemoveClusterAreas();\n\t//\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\t//if the area is already part of a cluster\n\t\tif (aasworld.areasettings[i].cluster)\n\t\t\tcontinue;\n\t\t// if not flooding through faces only use areas that have reachabilities\n\t\tif (nofaceflood)\n\t\t{\n\t\t\tif (!aasworld.areasettings[i].numreachableareas)\n\t\t\t\tcontinue;\n\t\t} //end if\n\t\t//if the area is a cluster portal\n\t\tif (aasworld.areasettings[i].contents & AREACONTENTS_CLUSTERPORTAL)\n\t\t\tcontinue;\n\t\tif (aasworld.numclusters >= AAS_MAX_CLUSTERS)\n\t\t{\n\t\t\tAAS_Error(\"AAS_MAX_CLUSTERS\");\n\t\t\treturn qfalse;\n\t\t} //end if\n\t\tcluster = &aasworld.clusters[aasworld.numclusters];\n\t\tcluster->numareas = 0;\n\t\tcluster->numreachabilityareas = 0;\n\t\tcluster->firstportal = aasworld.portalindexsize;\n\t\tcluster->numportals = 0;\n\t\t//flood the areas in this cluster\n\t\tif (!AAS_FloodClusterAreas_r(i, aasworld.numclusters))\n\t\t\treturn qfalse;\n\t\tif (!AAS_FloodClusterAreasUsingReachabilities(aasworld.numclusters))\n\t\t\treturn qfalse;\n\t\t//number the cluster areas\n\t\t//AAS_NumberClusterPortals(aasworld.numclusters);\n\t\tAAS_NumberClusterAreas(aasworld.numclusters);\n\t\t//Log_Write(\"cluster %d has %d areas\\r\\n\", aasworld.numclusters, cluster->numareas);\n\t\taasworld.numclusters++;\n\t} //end for\n\treturn qtrue;\n} //end of the function AAS_FindClusters\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_CreatePortals(void)\n{\n\tint i;\n\taas_portal_t *portal;\n\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\t//if the area is a cluster portal\n\t\tif (aasworld.areasettings[i].contents & AREACONTENTS_CLUSTERPORTAL)\n\t\t{\n\t\t\tif (aasworld.numportals >= AAS_MAX_PORTALS)\n\t\t\t{\n\t\t\t\tAAS_Error(\"AAS_MAX_PORTALS\");\n\t\t\t\treturn;\n\t\t\t} //end if\n\t\t\tportal = &aasworld.portals[aasworld.numportals];\n\t\t\tportal->areanum = i;\n\t\t\tportal->frontcluster = 0;\n\t\t\tportal->backcluster = 0;\n\t\t\taasworld.numportals++;\n\t\t} //end if\n\t} //end for\n} //end of the function AAS_CreatePortals\n/*\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_MapContainsTeleporters(void)\n{\n\tbsp_entity_t *entities, *ent;\n\tchar *classname;\n\n\tentities = AAS_ParseBSPEntities();\n\n\tfor (ent = entities; ent; ent = ent->next)\n\t{\n\t\tclassname = AAS_ValueForBSPEpairKey(ent, \"classname\");\n\t\tif (classname && !strcmp(classname, \"misc_teleporter\"))\n\t\t{\n\t\t\tAAS_FreeBSPEntities(entities);\n\t\t\treturn qtrue;\n\t\t} //end if\n\t} //end for\n\treturn qfalse;\n} //end of the function AAS_MapContainsTeleporters\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_NonConvexFaces(aas_face_t *face1, aas_face_t *face2, int side1, int side2)\n{\n\tint i, j, edgenum;\n\taas_plane_t *plane1, *plane2;\n\taas_edge_t *edge;\n\t\n\n\tplane1 = &aasworld.planes[face1->planenum ^ side1];\n\tplane2 = &aasworld.planes[face2->planenum ^ side2];\n\n\t//check if one of the points of face1 is at the back of the plane of face2\n\tfor (i = 0; i < face1->numedges; i++)\n\t{\n\t\tedgenum = abs(aasworld.edgeindex[face1->firstedge + i]);\n\t\tedge = &aasworld.edges[edgenum];\n\t\tfor (j = 0; j < 2; j++)\n\t\t{\n\t\t\tif (DotProduct(plane2->normal, aasworld.vertexes[edge->v[j]]) -\n\t\t\t\t\t\t\tplane2->dist < -0.01) return qtrue;\n\t\t} //end for\n\t} //end for\n\tfor (i = 0; i < face2->numedges; i++)\n\t{\n\t\tedgenum = abs(aasworld.edgeindex[face2->firstedge + i]);\n\t\tedge = &aasworld.edges[edgenum];\n\t\tfor (j = 0; j < 2; j++)\n\t\t{\n\t\t\tif (DotProduct(plane1->normal, aasworld.vertexes[edge->v[j]]) -\n\t\t\t\t\t\t\tplane1->dist < -0.01) return qtrue;\n\t\t} //end for\n\t} //end for\n\n\treturn qfalse;\n} //end of the function AAS_NonConvexFaces\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_CanMergeAreas(int *areanums, int numareas)\n{\n\tint i, j, s, face1num, face2num, side1, side2, fn1, fn2;\n\taas_face_t *face1, *face2;\n\taas_area_t *area1, *area2;\n\n\tfor (i = 0; i < numareas; i++)\n\t{\n\t\tarea1 = &aasworld.areas[areanums[i]];\n\t\tfor (fn1 = 0; fn1 < area1->numfaces; fn1++)\n\t\t{\n\t\t\tface1num = abs(aasworld.faceindex[area1->firstface + fn1]);\n\t\t\tface1 = &aasworld.faces[face1num];\n\t\t\tside1 = face1->frontarea != areanums[i];\n\t\t\t//check if the face isn't a shared one with one of the other areas\n\t\t\tfor (s = 0; s < numareas; s++)\n\t\t\t{\n\t\t\t\tif (s == i) continue;\n\t\t\t\tif (face1->frontarea == s || face1->backarea == s) break;\n\t\t\t} //end for\n\t\t\t//if the face was a shared one\n\t\t\tif (s != numareas) continue;\n\t\t\t//\n\t\t\tfor (j = 0; j < numareas; j++)\n\t\t\t{\n\t\t\t\tif (j == i) continue;\n\t\t\t\tarea2 = &aasworld.areas[areanums[j]];\n\t\t\t\tfor (fn2 = 0; fn2 < area2->numfaces; fn2++)\n\t\t\t\t{\n\t\t\t\t\tface2num = abs(aasworld.faceindex[area2->firstface + fn2]);\n\t\t\t\t\tface2 = &aasworld.faces[face2num];\n\t\t\t\t\tside2 = face2->frontarea != areanums[j];\n\t\t\t\t\t//check if the face isn't a shared one with one of the other areas\n\t\t\t\t\tfor (s = 0; s < numareas; s++)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (s == j) continue;\n\t\t\t\t\t\tif (face2->frontarea == s || face2->backarea == s) break;\n\t\t\t\t\t} //end for\n\t\t\t\t\t//if the face was a shared one\n\t\t\t\t\tif (s != numareas) continue;\n\t\t\t\t\t//\n\t\t\t\t\tif (AAS_NonConvexFaces(face1, face2, side1, side2)) return qfalse;\n\t\t\t\t} //end for\n\t\t\t} //end for\n\t\t} //end for\n\t} //end for\n\treturn qtrue;\n} //end of the function AAS_CanMergeAreas\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_NonConvexEdges(aas_edge_t *edge1, aas_edge_t *edge2, int side1, int side2, int planenum)\n{\n\tint i;\n\tvec3_t edgevec1, edgevec2, normal1, normal2;\n\tfloat dist1, dist2;\n\taas_plane_t *plane;\n\n\tplane = &aasworld.planes[planenum];\n\tVectorSubtract(aasworld.vertexes[edge1->v[1]], aasworld.vertexes[edge1->v[0]], edgevec1);\n\tVectorSubtract(aasworld.vertexes[edge2->v[1]], aasworld.vertexes[edge2->v[0]], edgevec2);\n\tif (side1) VectorInverse(edgevec1);\n\tif (side2) VectorInverse(edgevec2);\n\t//\n\tCrossProduct(edgevec1, plane->normal, normal1);\n\tdist1 = DotProduct(normal1, aasworld.vertexes[edge1->v[0]]);\n\tCrossProduct(edgevec2, plane->normal, normal2);\n\tdist2 = DotProduct(normal2, aasworld.vertexes[edge2->v[0]]);\n\n\tfor (i = 0; i < 2; i++)\n\t{\n\t\tif (DotProduct(aasworld.vertexes[edge1->v[i]], normal2) - dist2 < -0.01) return qfalse;\n\t} //end for\n\tfor (i = 0; i < 2; i++)\n\t{\n\t\tif (DotProduct(aasworld.vertexes[edge2->v[i]], normal1) - dist1 < -0.01) return qfalse;\n\t} //end for\n\treturn qtrue;\n} //end of the function AAS_NonConvexEdges\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_CanMergeFaces(int *facenums, int numfaces, int planenum)\n{\n\tint i, j, s, edgenum1, edgenum2, side1, side2, en1, en2, ens;\n\taas_face_t *face1, *face2, *otherface;\n\taas_edge_t *edge1, *edge2;\n\n\tfor (i = 0; i < numfaces; i++)\n\t{\n\t\tface1 = &aasworld.faces[facenums[i]];\n\t\tfor (en1 = 0; en1 < face1->numedges; en1++)\n\t\t{\n\t\t\tedgenum1 = aasworld.edgeindex[face1->firstedge + en1];\n\t\t\tside1 = (edgenum1 < 0) ^ (face1->planenum != planenum);\n\t\t\tedgenum1 = abs(edgenum1);\n\t\t\tedge1 = &aasworld.edges[edgenum1];\n\t\t\t//check if the edge is shared with another face\n\t\t\tfor (s = 0; s < numfaces; s++)\n\t\t\t{\n\t\t\t\tif (s == i) continue;\n\t\t\t\totherface = &aasworld.faces[facenums[s]];\n\t\t\t\tfor (ens = 0; ens < otherface->numedges; ens++)\n\t\t\t\t{\n\t\t\t\t\tif (edgenum1 == abs(aasworld.edgeindex[otherface->firstedge + ens])) break;\n\t\t\t\t} //end for\n\t\t\t\tif (ens != otherface->numedges) break;\n\t\t\t} //end for\n\t\t\t//if the edge was shared\n\t\t\tif (s != numfaces) continue;\n\t\t\t//\n\t\t\tfor (j = 0; j < numfaces; j++)\n\t\t\t{\n\t\t\t\tif (j == i) continue;\n\t\t\t\tface2 = &aasworld.faces[facenums[j]];\n\t\t\t\tfor (en2 = 0; en2 < face2->numedges; en2++)\n\t\t\t\t{\n\t\t\t\t\tedgenum2 = aasworld.edgeindex[face2->firstedge + en2];\n\t\t\t\t\tside2 = (edgenum2 < 0) ^ (face2->planenum != planenum);\n\t\t\t\t\tedgenum2 = abs(edgenum2);\n\t\t\t\t\tedge2 = &aasworld.edges[edgenum2];\n\t\t\t\t\t//check if the edge is shared with another face\n\t\t\t\t\tfor (s = 0; s < numfaces; s++)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (s == i) continue;\n\t\t\t\t\t\totherface = &aasworld.faces[facenums[s]];\n\t\t\t\t\t\tfor (ens = 0; ens < otherface->numedges; ens++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (edgenum2 == abs(aasworld.edgeindex[otherface->firstedge + ens])) break;\n\t\t\t\t\t\t} //end for\n\t\t\t\t\t\tif (ens != otherface->numedges) break;\n\t\t\t\t\t} //end for\n\t\t\t\t\t//if the edge was shared\n\t\t\t\t\tif (s != numfaces) continue;\n\t\t\t\t\t//\n\t\t\t\t\tif (AAS_NonConvexEdges(edge1, edge2, side1, side2, planenum)) return qfalse;\n\t\t\t\t} //end for\n\t\t\t} //end for\n\t\t} //end for\n\t} //end for\n\treturn qtrue;\n} //end of the function AAS_CanMergeFaces*/\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ConnectedAreas_r(int *areanums, int numareas, int *connectedareas, int curarea)\n{\n\tint i, j, otherareanum, facenum;\n\taas_area_t *area;\n\taas_face_t *face;\n\n\tconnectedareas[curarea] = qtrue;\n\tarea = &aasworld.areas[areanums[curarea]];\n\tfor (i = 0; i < area->numfaces; i++)\n\t{\n\t\tfacenum = abs(aasworld.faceindex[area->firstface + i]);\n\t\tface = &aasworld.faces[facenum];\n\t\t//if the face is solid\n\t\tif (face->faceflags & FACE_SOLID) continue;\n\t\t//get the area at the other side of the face\n\t\tif (face->frontarea != areanums[curarea]) otherareanum = face->frontarea;\n\t\telse otherareanum = face->backarea;\n\t\t//check if the face is leading to one of the other areas\n\t\tfor (j = 0; j < numareas; j++)\n\t\t{\n\t\t\tif (areanums[j] == otherareanum) break;\n\t\t} //end for\n\t\t//if the face isn't leading to one of the other areas\n\t\tif (j == numareas) continue;\n\t\t//if the other area is already connected\n\t\tif (connectedareas[j]) continue;\n\t\t//recursively proceed with the other area\n\t\tAAS_ConnectedAreas_r(areanums, numareas, connectedareas, j);\n\t} //end for\n} //end of the function AAS_ConnectedAreas_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_ConnectedAreas(int *areanums, int numareas)\n{\n\tint connectedareas[MAX_PORTALAREAS], i;\n\n\tCom_Memset(connectedareas, 0, sizeof(connectedareas));\n\tif (numareas < 1) return qfalse;\n\tif (numareas == 1) return qtrue;\n\tAAS_ConnectedAreas_r(areanums, numareas, connectedareas, 0);\n\tfor (i = 0; i < numareas; i++)\n\t{\n\t\tif (!connectedareas[i]) return qfalse;\n\t} //end for\n\treturn qtrue;\n} //end of the function AAS_ConnectedAreas\n//===========================================================================\n// gets adjacent areas with less presence types recursively\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_GetAdjacentAreasWithLessPresenceTypes_r(int *areanums, int numareas, int curareanum)\n{\n\tint i, j, presencetype, otherpresencetype, otherareanum, facenum;\n\taas_area_t *area;\n\taas_face_t *face;\n\n\tareanums[numareas++] = curareanum;\n\tarea = &aasworld.areas[curareanum];\n\tpresencetype = aasworld.areasettings[curareanum].presencetype;\n\tfor (i = 0; i < area->numfaces; i++)\n\t{\n\t\tfacenum = abs(aasworld.faceindex[area->firstface + i]);\n\t\tface = &aasworld.faces[facenum];\n\t\t//if the face is solid\n\t\tif (face->faceflags & FACE_SOLID) continue;\n\t\t//the area at the other side of the face\n\t\tif (face->frontarea != curareanum) otherareanum = face->frontarea;\n\t\telse otherareanum = face->backarea;\n\t\t//\n\t\totherpresencetype = aasworld.areasettings[otherareanum].presencetype;\n\t\t//if the other area has less presence types\n\t\tif ((presencetype & ~otherpresencetype) &&\n\t\t\t\t!(otherpresencetype & ~presencetype))\n\t\t{\n\t\t\t//check if the other area isn't already in the list\n\t\t\tfor (j = 0; j < numareas; j++)\n\t\t\t{\n\t\t\t\tif (otherareanum == areanums[j]) break;\n\t\t\t} //end for\n\t\t\t//if the other area isn't already in the list\n\t\t\tif (j == numareas)\n\t\t\t{\n\t\t\t\tif (numareas >= MAX_PORTALAREAS)\n\t\t\t\t{\n\t\t\t\t\tAAS_Error(\"MAX_PORTALAREAS\");\n\t\t\t\t\treturn numareas;\n\t\t\t\t} //end if\n\t\t\t\tnumareas = AAS_GetAdjacentAreasWithLessPresenceTypes_r(areanums, numareas, otherareanum);\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n\treturn numareas;\n} //end of the function AAS_GetAdjacentAreasWithLessPresenceTypes_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_CheckAreaForPossiblePortals(int areanum)\n{\n\tint i, j, k, fen, ben, frontedgenum, backedgenum, facenum;\n\tint areanums[MAX_PORTALAREAS], numareas, otherareanum;\n\tint numareafrontfaces[MAX_PORTALAREAS], numareabackfaces[MAX_PORTALAREAS];\n\tint frontfacenums[MAX_PORTALAREAS], backfacenums[MAX_PORTALAREAS];\n\tint numfrontfaces, numbackfaces;\n\tint frontareanums[MAX_PORTALAREAS], backareanums[MAX_PORTALAREAS];\n\tint numfrontareas, numbackareas;\n\tint frontplanenum, backplanenum, faceplanenum;\n\taas_area_t *area;\n\taas_face_t *frontface, *backface, *face;\n\n\t//if it isn't already a portal\n\tif (aasworld.areasettings[areanum].contents & AREACONTENTS_CLUSTERPORTAL) return 0;\n\t//it must be a grounded area\n\tif (!(aasworld.areasettings[areanum].areaflags & AREA_GROUNDED)) return 0;\n\t//\n\tCom_Memset(numareafrontfaces, 0, sizeof(numareafrontfaces));\n\tCom_Memset(numareabackfaces, 0, sizeof(numareabackfaces));\n\tnumareas = numfrontfaces = numbackfaces = 0;\n\tnumfrontareas = numbackareas = 0;\n\tfrontplanenum = backplanenum = -1;\n\t//add any adjacent areas with less presence types\n\tnumareas = AAS_GetAdjacentAreasWithLessPresenceTypes_r(areanums, 0, areanum);\n\t//\n\tfor (i = 0; i < numareas; i++)\n\t{\n\t\tarea = &aasworld.areas[areanums[i]];\n\t\tfor (j = 0; j < area->numfaces; j++)\n\t\t{\n\t\t\tfacenum = abs(aasworld.faceindex[area->firstface + j]);\n\t\t\tface = &aasworld.faces[facenum];\n\t\t\t//if the face is solid\n\t\t\tif (face->faceflags & FACE_SOLID) continue;\n\t\t\t//check if the face is shared with one of the other areas\n\t\t\tfor (k = 0; k < numareas; k++)\n\t\t\t{\n\t\t\t\tif (k == i) continue;\n\t\t\t\tif (face->frontarea == areanums[k] || face->backarea == areanums[k]) break;\n\t\t\t} //end for\n\t\t\t//if the face is shared\n\t\t\tif (k != numareas) continue;\n\t\t\t//the number of the area at the other side of the face\n\t\t\tif (face->frontarea == areanums[i]) otherareanum = face->backarea;\n\t\t\telse otherareanum = face->frontarea;\n\t\t\t//if the other area already is a cluter portal\n\t\t\tif (aasworld.areasettings[otherareanum].contents & AREACONTENTS_CLUSTERPORTAL) return 0;\n\t\t\t//number of the plane of the area\n\t\t\tfaceplanenum = face->planenum & ~1;\n\t\t\t//\n\t\t\tif (frontplanenum < 0 || faceplanenum == frontplanenum)\n\t\t\t{\n\t\t\t\tfrontplanenum = faceplanenum;\n\t\t\t\tfrontfacenums[numfrontfaces++] = facenum;\n\t\t\t\tfor (k = 0; k < numfrontareas; k++)\n\t\t\t\t{\n\t\t\t\t\tif (frontareanums[k] == otherareanum) break;\n\t\t\t\t} //end for\n\t\t\t\tif (k == numfrontareas) frontareanums[numfrontareas++] = otherareanum;\n\t\t\t\tnumareafrontfaces[i]++;\n\t\t\t} //end if\n\t\t\telse if (backplanenum < 0 || faceplanenum == backplanenum)\n\t\t\t{\n\t\t\t\tbackplanenum = faceplanenum;\n\t\t\t\tbackfacenums[numbackfaces++] = facenum;\n\t\t\t\tfor (k = 0; k < numbackareas; k++)\n\t\t\t\t{\n\t\t\t\t\tif (backareanums[k] == otherareanum) break;\n\t\t\t\t} //end for\n\t\t\t\tif (k == numbackareas) backareanums[numbackareas++] = otherareanum;\n\t\t\t\tnumareabackfaces[i]++;\n\t\t\t} //end else\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn 0;\n\t\t\t} //end else\n\t\t} //end for\n\t} //end for\n\t//every area should have at least one front face and one back face\n\tfor (i = 0; i < numareas; i++)\n\t{\n\t\tif (!numareafrontfaces[i] || !numareabackfaces[i]) return 0;\n\t} //end for\n\t//the front areas should all be connected\n\tif (!AAS_ConnectedAreas(frontareanums, numfrontareas)) return 0;\n\t//the back areas should all be connected\n\tif (!AAS_ConnectedAreas(backareanums, numbackareas)) return 0;\n\t//none of the front faces should have a shared edge with a back face\n\tfor (i = 0; i < numfrontfaces; i++)\n\t{\n\t\tfrontface = &aasworld.faces[frontfacenums[i]];\n\t\tfor (fen = 0; fen < frontface->numedges; fen++)\n\t\t{\n\t\t\tfrontedgenum = abs(aasworld.edgeindex[frontface->firstedge + fen]);\n\t\t\tfor (j = 0; j < numbackfaces; j++)\n\t\t\t{\n\t\t\t\tbackface = &aasworld.faces[backfacenums[j]];\n\t\t\t\tfor (ben = 0; ben < backface->numedges; ben++)\n\t\t\t\t{\n\t\t\t\t\tbackedgenum = abs(aasworld.edgeindex[backface->firstedge + ben]);\n\t\t\t\t\tif (frontedgenum == backedgenum) break;\n\t\t\t\t} //end for\n\t\t\t\tif (ben != backface->numedges) break;\n\t\t\t} //end for\n\t\t\tif (j != numbackfaces) break;\n\t\t} //end for\n\t\tif (fen != frontface->numedges) break;\n\t} //end for\n\tif (i != numfrontfaces) return 0;\n\t//set the cluster portal contents\n\tfor (i = 0; i < numareas; i++)\n\t{\n\t\taasworld.areasettings[areanums[i]].contents |= AREACONTENTS_CLUSTERPORTAL;\n\t\t//this area can be used as a route portal\n\t\taasworld.areasettings[areanums[i]].contents |= AREACONTENTS_ROUTEPORTAL;\n\t\tLog_Write(\"possible portal: %d\\r\\n\", areanums[i]);\n\t} //end for\n\t//\n\treturn numareas;\n} //end of the function AAS_CheckAreaForPossiblePortals\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FindPossiblePortals(void)\n{\n\tint i, numpossibleportals;\n\n\tnumpossibleportals = 0;\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\tnumpossibleportals += AAS_CheckAreaForPossiblePortals(i);\n\t} //end for\n\tbotimport.Print(PRT_MESSAGE, \"\\r%6d possible portal areas\\n\", numpossibleportals);\n} //end of the function AAS_FindPossiblePortals\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_RemoveAllPortals(void)\n{\n\tint i;\n\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\taasworld.areasettings[i].contents &= ~AREACONTENTS_CLUSTERPORTAL;\n\t} //end for\n} //end of the function AAS_RemoveAllPortals\n\n#if 0\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FloodCluster_r(int areanum, int clusternum)\n{\n\tint i, otherareanum;\n\taas_face_t *face;\n\taas_area_t *area;\n\n\t//set cluster mark\n\taasworld.areasettings[areanum].cluster = clusternum;\n\t//if the area is a portal\n\t//if (aasworld.areasettings[areanum].contents & AREACONTENTS_CLUSTERPORTAL) return;\n\t//\n\tarea = &aasworld.areas[areanum];\n\t//use area faces to flood into adjacent areas\n\tfor (i = 0; i < area->numfaces; i++)\n\t{\n\t\tface = &aasworld.faces[abs(aasworld.faceindex[area->firstface + i])];\n\t\t//\n\t\tif (face->frontarea != areanum) otherareanum = face->frontarea;\n\t\telse otherareanum = face->backarea;\n\t\t//if there's no area at the other side\n\t\tif (!otherareanum) continue;\n\t\t//if the area is a portal\n\t\tif (aasworld.areasettings[otherareanum].contents & AREACONTENTS_CLUSTERPORTAL) continue;\n\t\t//if the area is already marked\n\t\tif (aasworld.areasettings[otherareanum].cluster) continue;\n\t\t//\n\t\tAAS_FloodCluster_r(otherareanum, clusternum);\n\t} //end for\n\t//use the reachabilities to flood into other areas\n\tfor (i = 0; i < aasworld.areasettings[areanum].numreachableareas; i++)\n\t{\n\t\totherareanum = aasworld.reachability[\n\t\t\t\t\taasworld.areasettings[areanum].firstreachablearea + i].areanum;\n\t\tif (!otherareanum)\n\t\t{\n\t\t\tcontinue;\n\t\t\tAAS_Error(\"reachability %d has zero area\\n\", aasworld.areasettings[areanum].firstreachablearea + i);\n\t\t} //end if\n\t\t//if the area is a portal\n\t\tif (aasworld.areasettings[otherareanum].contents & AREACONTENTS_CLUSTERPORTAL) continue;\n\t\t//if the area is already marked\n\t\tif (aasworld.areasettings[otherareanum].cluster) continue;\n\t\t//\n\t\tAAS_FloodCluster_r(otherareanum, clusternum);\n\t} //end for\n} //end of the function AAS_FloodCluster_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_RemoveTeleporterPortals(void)\n{\n\tint i, j, areanum;\n\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\tfor (j = 0; j < aasworld.areasettings[i].numreachableareas; j++)\n\t\t{\n\t\t\tareanum = aasworld.reachability[aasworld.areasettings[i].firstreachablearea + j].areanum;\n\t\t\tif (aasworld.reachability[aasworld.areasettings[i].firstreachablearea + j].traveltype == TRAVEL_TELEPORT)\n\t\t\t{\n\t\t\t\taasworld.areasettings[i].contents &= ~AREACONTENTS_CLUSTERPORTAL;\n\t\t\t\taasworld.areasettings[areanum].contents &= ~AREACONTENTS_CLUSTERPORTAL;\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n} //end of the function AAS_RemoveTeleporterPortals\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FloodClusterReachabilities(int clusternum)\n{\n\tint i, j, areanum;\n\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\t//if this area already has a cluster set\n\t\tif (aasworld.areasettings[i].cluster) continue;\n\t\t//if this area is a cluster portal\n\t\tif (aasworld.areasettings[i].contents & AREACONTENTS_CLUSTERPORTAL) continue;\n\t\t//loop over the reachable areas from this area\n\t\tfor (j = 0; j < aasworld.areasettings[i].numreachableareas; j++)\n\t\t{\n\t\t\t//the reachable area\n\t\t\tareanum = aasworld.reachability[aasworld.areasettings[i].firstreachablearea + j].areanum;\n\t\t\t//if this area is a cluster portal\n\t\t\tif (aasworld.areasettings[areanum].contents & AREACONTENTS_CLUSTERPORTAL) continue;\n\t\t\t//if this area has a cluster set\n\t\t\tif (aasworld.areasettings[areanum].cluster == clusternum)\n\t\t\t{\n\t\t\t\tAAS_FloodCluster_r(i, clusternum);\n\t\t\t\ti = 0;\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n} //end of the function AAS_FloodClusterReachabilities\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_RemoveNotClusterClosingPortals(void)\n{\n\tint i, j, k, facenum, otherareanum, nonclosingportals;\n\taas_area_t *area;\n\taas_face_t *face;\n\n\tAAS_RemoveTeleporterPortals();\n\t//\n\tnonclosingportals = 0;\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\tif (!(aasworld.areasettings[i].contents & AREACONTENTS_CLUSTERPORTAL)) continue;\n\t\t//find a non-portal area adjacent to the portal area and flood\n\t\t//the cluster from there\n\t\tarea = &aasworld.areas[i];\n\t\tfor (j = 0; j < area->numfaces; j++)\n\t\t{\n\t\t\tfacenum = abs(aasworld.faceindex[area->firstface + j]);\n\t\t\tface = &aasworld.faces[facenum];\n\t\t\t//\n\t\t\tif (face->frontarea != i) otherareanum = face->frontarea;\n\t\t\telse otherareanum = face->backarea;\n\t\t\t//\n\t\t\tif (!otherareanum) continue;\n\t\t\t//\n\t\t\tif (aasworld.areasettings[otherareanum].contents & AREACONTENTS_CLUSTERPORTAL)\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\t//reset all cluster fields\n\t\t\tAAS_RemoveClusterAreas();\n\t\t\t//\n\t\t\tAAS_FloodCluster_r(otherareanum, 1);\n\t\t\tAAS_FloodClusterReachabilities(1);\n\t\t\t//check if all adjacent non-portal areas have a cluster set\n\t\t\tfor (k = 0; k < area->numfaces; k++)\n\t\t\t{\n\t\t\t\tfacenum = abs(aasworld.faceindex[area->firstface + k]);\n\t\t\t\tface = &aasworld.faces[facenum];\n\t\t\t\t//\n\t\t\t\tif (face->frontarea != i) otherareanum = face->frontarea;\n\t\t\t\telse otherareanum = face->backarea;\n\t\t\t\t//\n\t\t\t\tif (!otherareanum) continue;\n\t\t\t\t//\n\t\t\t\tif (aasworld.areasettings[otherareanum].contents & AREACONTENTS_CLUSTERPORTAL)\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t} //end if\n\t\t\t\t//\n\t\t\t\tif (!aasworld.areasettings[otherareanum].cluster) break;\n\t\t\t} //end for\n\t\t\t//if all adjacent non-portal areas have a cluster set then the portal\n\t\t\t//didn't seal a cluster\n\t\t\tif (k >= area->numfaces)\n\t\t\t{\n\t\t\t\taasworld.areasettings[i].contents &= ~AREACONTENTS_CLUSTERPORTAL;\n\t\t\t\tnonclosingportals++;\n\t\t\t\t//recheck all the other portals again\n\t\t\t\ti = 0;\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\tbotimport.Print(PRT_MESSAGE, \"\\r%6d non closing portals removed\\n\", nonclosingportals);\n} //end of the function AAS_RemoveNotClusterClosingPortals\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n\nvoid AAS_RemoveNotClusterClosingPortals(void)\n{\n\tint i, j, facenum, otherareanum, nonclosingportals, numseperatedclusters;\n\taas_area_t *area;\n\taas_face_t *face;\n\n\tAAS_RemoveTeleporterPortals();\n\t//\n\tnonclosingportals = 0;\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\tif (!(aasworld.areasettings[i].contents & AREACONTENTS_CLUSTERPORTAL)) continue;\n\t\t//\n\t\tnumseperatedclusters = 0;\n\t\t//reset all cluster fields\n\t\tAAS_RemoveClusterAreas();\n\t\t//find a non-portal area adjacent to the portal area and flood\n\t\t//the cluster from there\n\t\tarea = &aasworld.areas[i];\n\t\tfor (j = 0; j < area->numfaces; j++)\n\t\t{\n\t\t\tfacenum = abs(aasworld.faceindex[area->firstface + j]);\n\t\t\tface = &aasworld.faces[facenum];\n\t\t\t//\n\t\t\tif (face->frontarea != i) otherareanum = face->frontarea;\n\t\t\telse otherareanum = face->backarea;\n\t\t\t//if not solid at the other side of the face\n\t\t\tif (!otherareanum) continue;\n\t\t\t//don't flood into other portals\n\t\t\tif (aasworld.areasettings[otherareanum].contents & AREACONTENTS_CLUSTERPORTAL) continue;\n\t\t\t//if the area already has a cluster set\n\t\t\tif (aasworld.areasettings[otherareanum].cluster) continue;\n\t\t\t//another cluster is seperated by this portal\n\t\t\tnumseperatedclusters++;\n\t\t\t//flood the cluster\n\t\t\tAAS_FloodCluster_r(otherareanum, numseperatedclusters);\n\t\t\tAAS_FloodClusterReachabilities(numseperatedclusters);\n\t\t} //end for\n\t\t//use the reachabilities to flood into other areas\n\t\tfor (j = 0; j < aasworld.areasettings[i].numreachableareas; j++)\n\t\t{\n\t\t\totherareanum = aasworld.reachability[\n\t\t\t\t\t\taasworld.areasettings[i].firstreachablearea + j].areanum;\n\t\t\t//this should never be qtrue but we check anyway\n\t\t\tif (!otherareanum) continue;\n\t\t\t//don't flood into other portals\n\t\t\tif (aasworld.areasettings[otherareanum].contents & AREACONTENTS_CLUSTERPORTAL) continue;\n\t\t\t//if the area already has a cluster set\n\t\t\tif (aasworld.areasettings[otherareanum].cluster) continue;\n\t\t\t//another cluster is seperated by this portal\n\t\t\tnumseperatedclusters++;\n\t\t\t//flood the cluster\n\t\t\tAAS_FloodCluster_r(otherareanum, numseperatedclusters);\n\t\t\tAAS_FloodClusterReachabilities(numseperatedclusters);\n\t\t} //end for\n\t\t//a portal must seperate no more and no less than 2 clusters\n\t\tif (numseperatedclusters != 2)\n\t\t{\n\t\t\taasworld.areasettings[i].contents &= ~AREACONTENTS_CLUSTERPORTAL;\n\t\t\tnonclosingportals++;\n\t\t\t//recheck all the other portals again\n\t\t\ti = 0;\n\t\t} //end if\n\t} //end for\n\tbotimport.Print(PRT_MESSAGE, \"\\r%6d non closing portals removed\\n\", nonclosingportals);\n} //end of the function AAS_RemoveNotClusterClosingPortals\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n\nvoid AAS_AddTeleporterPortals(void)\n{\n\tint j, area2num, facenum, otherareanum;\n\tchar *target, *targetname, *classname;\n\tbsp_entity_t *entities, *ent, *dest;\n\tvec3_t origin, destorigin, mins, maxs, end;\n\tvec3_t bbmins, bbmaxs;\n\taas_area_t *area;\n\taas_face_t *face;\n\taas_trace_t trace;\n\taas_link_t *areas, *link;\n\n\tentities = AAS_ParseBSPEntities();\n\n\tfor (ent = entities; ent; ent = ent->next)\n\t{\n\t\tclassname = AAS_ValueForBSPEpairKey(ent, \"classname\");\n\t\tif (classname && !strcmp(classname, \"misc_teleporter\"))\n\t\t{\n\t\t\tif (!AAS_VectorForBSPEpairKey(ent, \"origin\", origin))\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"teleporter (%s) without origin\\n\", target);\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\t//\n\t\t\ttarget = AAS_ValueForBSPEpairKey(ent, \"target\");\n\t\t\tif (!target)\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"teleporter (%s) without target\\n\", target);\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\tfor (dest = entities; dest; dest = dest->next)\n\t\t\t{\n\t\t\t\tclassname = AAS_ValueForBSPEpairKey(dest, \"classname\");\n\t\t\t\tif (classname && !strcmp(classname, \"misc_teleporter_dest\"))\n\t\t\t\t{\n\t\t\t\t\ttargetname = AAS_ValueForBSPEpairKey(dest, \"targetname\");\n\t\t\t\t\tif (targetname && !strcmp(targetname, target))\n\t\t\t\t\t{\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t} //end for\n\t\t\tif (!dest)\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"teleporter without destination (%s)\\n\", target);\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\tif (!AAS_VectorForBSPEpairKey(dest, \"origin\", destorigin))\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"teleporter destination (%s) without origin\\n\", target);\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\tdestorigin[2] += 24; //just for q2e1m2, the dork has put the telepads in the ground\n\t\t\tVectorCopy(destorigin, end);\n\t\t\tend[2] -= 100;\n\t\t\ttrace = AAS_TraceClientBBox(destorigin, end, PRESENCE_CROUCH, -1);\n\t\t\tif (trace.startsolid)\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"teleporter destination (%s) in solid\\n\", target);\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\tVectorCopy(trace.endpos, destorigin);\n\t\t\tarea2num = AAS_PointAreaNum(destorigin);\n\t\t\t//reset all cluster fields\n\t\t\tfor (j = 0; j < aasworld.numareas; j++)\n\t\t\t{\n\t\t\t\taasworld.areasettings[j].cluster = 0;\n\t\t\t} //end for\n\t\t\t//\n\t\t\tVectorSet(mins, -8, -8, 8);\n\t\t\tVectorSet(maxs, 8, 8, 24);\n\t\t\t//\n\t\t\tAAS_PresenceTypeBoundingBox(PRESENCE_CROUCH, bbmins, bbmaxs);\n\t\t\t//\n\t\t\tVectorAdd(origin, mins, mins);\n\t\t\tVectorAdd(origin, maxs, maxs);\n\t\t\t//add bounding box size\n\t\t\tVectorSubtract(mins, bbmaxs, mins);\n\t\t\tVectorSubtract(maxs, bbmins, maxs);\n\t\t\t//link an invalid (-1) entity\n\t\t\tareas = AAS_AASLinkEntity(mins, maxs, -1);\n\t\t\t//\n\t\t\tfor (link = areas; link; link = link->next_area)\n\t\t\t{\n\t\t\t\tif (!AAS_AreaGrounded(link->areanum)) continue;\n\t\t\t\t//add the teleporter portal mark\n\t\t\t\taasworld.areasettings[link->areanum].contents |= AREACONTENTS_CLUSTERPORTAL |\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAREACONTENTS_TELEPORTAL;\n\t\t\t} //end for\n\t\t\t//\n\t\t\tfor (link = areas; link; link = link->next_area)\n\t\t\t{\n\t\t\t\tif (!AAS_AreaGrounded(link->areanum)) continue;\n\t\t\t\t//find a non-portal area adjacent to the portal area and flood\n\t\t\t\t//the cluster from there\n\t\t\t\tarea = &aasworld.areas[link->areanum];\n\t\t\t\tfor (j = 0; j < area->numfaces; j++)\n\t\t\t\t{\n\t\t\t\t\tfacenum = abs(aasworld.faceindex[area->firstface + j]);\n\t\t\t\t\tface = &aasworld.faces[facenum];\n\t\t\t\t\t//\n\t\t\t\t\tif (face->frontarea != link->areanum) otherareanum = face->frontarea;\n\t\t\t\t\telse otherareanum = face->backarea;\n\t\t\t\t\t//\n\t\t\t\t\tif (!otherareanum) continue;\n\t\t\t\t\t//\n\t\t\t\t\tif (aasworld.areasettings[otherareanum].contents & AREACONTENTS_CLUSTERPORTAL)\n\t\t\t\t\t{\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} //end if\n\t\t\t\t\t//\n\t\t\t\t\tAAS_FloodCluster_r(otherareanum, 1);\n\t\t\t\t} //end for\n\t\t\t} //end for\n\t\t\t//if the teleport destination IS in the same cluster\n\t\t\tif (aasworld.areasettings[area2num].cluster)\n\t\t\t{\n\t\t\t\tfor (link = areas; link; link = link->next_area)\n\t\t\t\t{\n\t\t\t\t\tif (!AAS_AreaGrounded(link->areanum)) continue;\n\t\t\t\t\t//add the teleporter portal mark\n\t\t\t\t\taasworld.areasettings[link->areanum].contents &= ~(AREACONTENTS_CLUSTERPORTAL |\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAREACONTENTS_TELEPORTAL);\n\t\t\t\t} //end for\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n\tAAS_FreeBSPEntities(entities);\n} //end of the function AAS_AddTeleporterPortals\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_AddTeleporterPortals(void)\n{\n\tint i, j, areanum;\n\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\tfor (j = 0; j < aasworld.areasettings[i].numreachableareas; j++)\n\t\t{\n\t\t\tif (aasworld.reachability[aasworld.areasettings[i].firstreachablearea + j].traveltype != TRAVEL_TELEPORT) continue;\n\t\t\tareanum = aasworld.reachability[aasworld.areasettings[i].firstreachablearea + j].areanum;\n\t\t\taasworld.areasettings[areanum].contents |= AREACONTENTS_CLUSTERPORTAL;\n\t\t} //end for\n\t} //end for\n} //end of the function AAS_AddTeleporterPortals\n\n#endif\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_TestPortals(void)\n{\n\tint i;\n\taas_portal_t *portal;\n\n\tfor (i = 1; i < aasworld.numportals; i++)\n\t{\n\t\tportal = &aasworld.portals[i];\n\t\tif (!portal->frontcluster)\n\t\t{\n\t\t\taasworld.areasettings[portal->areanum].contents &= ~AREACONTENTS_CLUSTERPORTAL;\n\t\t\tLog_Write(\"portal area %d has no front cluster\\r\\n\", portal->areanum);\n\t\t\treturn qfalse;\n\t\t} //end if\n\t\tif (!portal->backcluster)\n\t\t{\n\t\t\taasworld.areasettings[portal->areanum].contents &= ~AREACONTENTS_CLUSTERPORTAL;\n\t\t\tLog_Write(\"portal area %d has no back cluster\\r\\n\", portal->areanum);\n\t\t\treturn qfalse;\n\t\t} //end if\n\t} //end for\n\treturn qtrue;\n} //end of the function\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_CountForcedClusterPortals(void)\n{\n\tint num, i;\n\n\tnum = 0;\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\tif (aasworld.areasettings[i].contents & AREACONTENTS_CLUSTERPORTAL)\n\t\t{\n\t\t\tLog_Write(\"area %d is a forced portal area\\r\\n\", i);\n\t\t\tnum++;\n\t\t} //end if\n\t} //end for\n\tbotimport.Print(PRT_MESSAGE, \"%6d forced portal areas\\n\", num);\n} //end of the function AAS_CountForcedClusterPortals\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_CreateViewPortals(void)\n{\n\tint i;\n\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\tif (aasworld.areasettings[i].contents & AREACONTENTS_CLUSTERPORTAL)\n\t\t{\n\t\t\taasworld.areasettings[i].contents |= AREACONTENTS_VIEWPORTAL;\n\t\t} //end if\n\t} //end for\n} //end of the function AAS_CreateViewPortals\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_SetViewPortalsAsClusterPortals(void)\n{\n\tint i;\n\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\tif (aasworld.areasettings[i].contents & AREACONTENTS_VIEWPORTAL)\n\t\t{\n\t\t\taasworld.areasettings[i].contents |= AREACONTENTS_CLUSTERPORTAL;\n\t\t} //end if\n\t} //end for\n} //end of the function AAS_SetViewPortalsAsClusterPortals\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_InitClustering(void)\n{\n\tint i, removedPortalAreas;\n\tint n, total, numreachabilityareas;\n\n\tif (!aasworld.loaded) return;\n\t//if there are clusters\n\tif (aasworld.numclusters >= 1)\n\t{\n#ifndef BSPC\n\t\t//if clustering isn't forced\n\t\tif (!((int)LibVarGetValue(\"forceclustering\")) &&\n\t\t\t!((int)LibVarGetValue(\"forcereachability\"))) return;\n#endif\n\t} //end if\n\t//set all view portals as cluster portals in case we re-calculate the reachabilities and clusters (with -reach)\n\tAAS_SetViewPortalsAsClusterPortals();\n\t//count the number of forced cluster portals\n\tAAS_CountForcedClusterPortals();\n\t//remove all area cluster marks\n\tAAS_RemoveClusterAreas();\n\t//find possible cluster portals\n\tAAS_FindPossiblePortals();\n\t//craete portals to for the bot view\n\tAAS_CreateViewPortals();\n\t//remove all portals that are not closing a cluster\n\t//AAS_RemoveNotClusterClosingPortals();\n\t//initialize portal memory\n\tif (aasworld.portals) FreeMemory(aasworld.portals);\n\taasworld.portals = (aas_portal_t *) GetClearedMemory(AAS_MAX_PORTALS * sizeof(aas_portal_t));\n\t//initialize portal index memory\n\tif (aasworld.portalindex) FreeMemory(aasworld.portalindex);\n\taasworld.portalindex = (aas_portalindex_t *) GetClearedMemory(AAS_MAX_PORTALINDEXSIZE * sizeof(aas_portalindex_t));\n\t//initialize cluster memory\n\tif (aasworld.clusters) FreeMemory(aasworld.clusters);\n\taasworld.clusters = (aas_cluster_t *) GetClearedMemory(AAS_MAX_CLUSTERS * sizeof(aas_cluster_t));\n\t//\n\tremovedPortalAreas = 0;\n\tbotimport.Print(PRT_MESSAGE, \"\\r%6d removed portal areas\", removedPortalAreas);\n\twhile(1)\n\t{\n\t\tbotimport.Print(PRT_MESSAGE, \"\\r%6d\", removedPortalAreas);\n\t\t//initialize the number of portals and clusters\n\t\taasworld.numportals = 1;\t\t//portal 0 is a dummy\n\t\taasworld.portalindexsize = 0;\n\t\taasworld.numclusters = 1;\t\t//cluster 0 is a dummy\n\t\t//create the portals from the portal areas\n\t\tAAS_CreatePortals();\n\t\t//\n\t\tremovedPortalAreas++;\n\t\t//find the clusters\n\t\tif (!AAS_FindClusters())\n\t\t\tcontinue;\n\t\t//test the portals\n\t\tif (!AAS_TestPortals())\n\t\t\tcontinue;\n\t\t//\n\t\tbreak;\n\t} //end while\n\tbotimport.Print(PRT_MESSAGE, \"\\n\");\n\t//the AAS file should be saved\n\taasworld.savefile = qtrue;\n\t//write the portal areas to the log file\n\tfor (i = 1; i < aasworld.numportals; i++)\n\t{\n\t\tLog_Write(\"portal %d: area %d\\r\\n\", i, aasworld.portals[i].areanum);\n\t} //end for\n\t// report cluster info\n\tbotimport.Print(PRT_MESSAGE, \"%6d portals created\\n\", aasworld.numportals);\n\tbotimport.Print(PRT_MESSAGE, \"%6d clusters created\\n\", aasworld.numclusters);\n\tfor (i = 1; i < aasworld.numclusters; i++)\n\t{\n\t\tbotimport.Print(PRT_MESSAGE, \"cluster %d has %d reachability areas\\n\", i,\n\t\t\t\taasworld.clusters[i].numreachabilityareas);\n\t} //end for\n\t// report AAS file efficiency\n\tnumreachabilityareas = 0;\n\ttotal = 0;\n\tfor (i = 0; i < aasworld.numclusters; i++) {\n\t\tn = aasworld.clusters[i].numreachabilityareas;\n\t\tnumreachabilityareas += n;\n\t\ttotal += n * n;\n\t}\n\ttotal += numreachabilityareas * aasworld.numportals;\n\t//\n\tbotimport.Print(PRT_MESSAGE, \"%6i total reachability areas\\n\", numreachabilityareas);\n\tbotimport.Print(PRT_MESSAGE, \"%6i AAS memory/CPU usage (the lower the better)\\n\", total * 3);\n} //end of the function AAS_InitClustering\n"
  },
  {
    "path": "code/botlib/be_aas_cluster.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_cluster.h\n *\n * desc:\t\tAAS\n *\n * $Archive: /source/code/botlib/be_aas_cluster.h $\n *\n *****************************************************************************/\n\n#ifdef AASINTERN\n//initialize the AAS clustering\nvoid AAS_InitClustering(void);\n//\nvoid AAS_SetViewPortalsAsClusterPortals(void);\n#endif //AASINTERN\n\n"
  },
  {
    "path": "code/botlib/be_aas_debug.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_debug.c\n *\n * desc:\t\tAAS debug code\n *\n * $Archive: /MissionPack/code/botlib/be_aas_debug.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_memory.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#include \"l_libvar.h\"\n#include \"aasfile.h\"\n#include \"../game/botlib.h\"\n#include \"../game/be_aas.h\"\n#include \"be_interface.h\"\n#include \"be_aas_funcs.h\"\n#include \"be_aas_def.h\"\n\n#define MAX_DEBUGLINES\t\t\t\t1024\n#define MAX_DEBUGPOLYGONS\t\t\t8192\n\nint debuglines[MAX_DEBUGLINES];\nint debuglinevisible[MAX_DEBUGLINES];\nint numdebuglines;\n\nstatic int debugpolygons[MAX_DEBUGPOLYGONS];\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ClearShownPolygons(void)\n{\n\tint i;\n//*\n\tfor (i = 0; i < MAX_DEBUGPOLYGONS; i++)\n\t{\n\t\tif (debugpolygons[i]) botimport.DebugPolygonDelete(debugpolygons[i]);\n\t\tdebugpolygons[i] = 0;\n\t} //end for\n//*/\n/*\n\tfor (i = 0; i < MAX_DEBUGPOLYGONS; i++)\n\t{\n\t\tbotimport.DebugPolygonDelete(i);\n\t\tdebugpolygons[i] = 0;\n\t} //end for\n*/\n} //end of the function AAS_ClearShownPolygons\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ShowPolygon(int color, int numpoints, vec3_t *points)\n{\n\tint i;\n\n\tfor (i = 0; i < MAX_DEBUGPOLYGONS; i++)\n\t{\n\t\tif (!debugpolygons[i])\n\t\t{\n\t\t\tdebugpolygons[i] = botimport.DebugPolygonCreate(color, numpoints, points);\n\t\t\tbreak;\n\t\t} //end if\n\t} //end for\n} //end of the function AAS_ShowPolygon\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ClearShownDebugLines(void)\n{\n\tint i;\n\n\t//make all lines invisible\n\tfor (i = 0; i < MAX_DEBUGLINES; i++)\n\t{\n\t\tif (debuglines[i])\n\t\t{\n\t\t\t//botimport.DebugLineShow(debuglines[i], NULL, NULL, LINECOLOR_NONE);\n\t\t\tbotimport.DebugLineDelete(debuglines[i]);\n\t\t\tdebuglines[i] = 0;\n\t\t\tdebuglinevisible[i] = qfalse;\n\t\t} //end if\n\t} //end for\n} //end of the function AAS_ClearShownDebugLines\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_DebugLine(vec3_t start, vec3_t end, int color)\n{\n\tint line;\n\n\tfor (line = 0; line < MAX_DEBUGLINES; line++)\n\t{\n\t\tif (!debuglines[line])\n\t\t{\n\t\t\tdebuglines[line] = botimport.DebugLineCreate();\n\t\t\tdebuglinevisible[line] = qfalse;\n\t\t\tnumdebuglines++;\n\t\t} //end if\n\t\tif (!debuglinevisible[line])\n\t\t{\n\t\t\tbotimport.DebugLineShow(debuglines[line], start, end, color);\n\t\t\tdebuglinevisible[line] = qtrue;\n\t\t\treturn;\n\t\t} //end else\n\t} //end for\n} //end of the function AAS_DebugLine\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_PermanentLine(vec3_t start, vec3_t end, int color)\n{\n\tint line;\n\n\tline = botimport.DebugLineCreate();\n\tbotimport.DebugLineShow(line, start, end, color);\n} //end of the function AAS_PermenentLine\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_DrawPermanentCross(vec3_t origin, float size, int color)\n{\n\tint i, debugline;\n\tvec3_t start, end;\n\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tVectorCopy(origin, start);\n\t\tstart[i] += size;\n\t\tVectorCopy(origin, end);\n\t\tend[i] -= size;\n\t\tAAS_DebugLine(start, end, color);\n\t\tdebugline = botimport.DebugLineCreate();\n\t\tbotimport.DebugLineShow(debugline, start, end, color);\n\t} //end for\n} //end of the function AAS_DrawPermanentCross\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_DrawPlaneCross(vec3_t point, vec3_t normal, float dist, int type, int color)\n{\n\tint n0, n1, n2, j, line, lines[2];\n\tvec3_t start1, end1, start2, end2;\n\n\t//make a cross in the hit plane at the hit point\n\tVectorCopy(point, start1);\n\tVectorCopy(point, end1);\n\tVectorCopy(point, start2);\n\tVectorCopy(point, end2);\n\n\tn0 = type % 3;\n\tn1 = (type + 1) % 3;\n\tn2 = (type + 2) % 3;\n\tstart1[n1] -= 6;\n\tstart1[n2] -= 6;\n\tend1[n1] += 6;\n\tend1[n2] += 6;\n\tstart2[n1] += 6;\n\tstart2[n2] -= 6;\n\tend2[n1] -= 6;\n\tend2[n2] += 6;\n\n\tstart1[n0] = (dist - (start1[n1] * normal[n1] +\n\t\t\t\tstart1[n2] * normal[n2])) / normal[n0];\n\tend1[n0] = (dist - (end1[n1] * normal[n1] +\n\t\t\t\tend1[n2] * normal[n2])) / normal[n0];\n\tstart2[n0] = (dist - (start2[n1] * normal[n1] +\n\t\t\t\tstart2[n2] * normal[n2])) / normal[n0];\n\tend2[n0] = (dist - (end2[n1] * normal[n1] +\n\t\t\t\tend2[n2] * normal[n2])) / normal[n0];\n\n\tfor (j = 0, line = 0; j < 2 && line < MAX_DEBUGLINES; line++)\n\t{\n\t\tif (!debuglines[line])\n\t\t{\n\t\t\tdebuglines[line] = botimport.DebugLineCreate();\n\t\t\tlines[j++] = debuglines[line];\n\t\t\tdebuglinevisible[line] = qtrue;\n\t\t\tnumdebuglines++;\n\t\t} //end if\n\t\telse if (!debuglinevisible[line])\n\t\t{\n\t\t\tlines[j++] = debuglines[line];\n\t\t\tdebuglinevisible[line] = qtrue;\n\t\t} //end else\n\t} //end for\n\tbotimport.DebugLineShow(lines[0], start1, end1, color);\n\tbotimport.DebugLineShow(lines[1], start2, end2, color);\n} //end of the function AAS_DrawPlaneCross\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ShowBoundingBox(vec3_t origin, vec3_t mins, vec3_t maxs)\n{\n\tvec3_t bboxcorners[8];\n\tint lines[3];\n\tint i, j, line;\n\n\t//upper corners\n\tbboxcorners[0][0] = origin[0] + maxs[0];\n\tbboxcorners[0][1] = origin[1] + maxs[1];\n\tbboxcorners[0][2] = origin[2] + maxs[2];\n\t//\n\tbboxcorners[1][0] = origin[0] + mins[0];\n\tbboxcorners[1][1] = origin[1] + maxs[1];\n\tbboxcorners[1][2] = origin[2] + maxs[2];\n\t//\n\tbboxcorners[2][0] = origin[0] + mins[0];\n\tbboxcorners[2][1] = origin[1] + mins[1];\n\tbboxcorners[2][2] = origin[2] + maxs[2];\n\t//\n\tbboxcorners[3][0] = origin[0] + maxs[0];\n\tbboxcorners[3][1] = origin[1] + mins[1];\n\tbboxcorners[3][2] = origin[2] + maxs[2];\n\t//lower corners\n\tCom_Memcpy(bboxcorners[4], bboxcorners[0], sizeof(vec3_t) * 4);\n\tfor (i = 0; i < 4; i++) bboxcorners[4 + i][2] = origin[2] + mins[2];\n\t//draw bounding box\n\tfor (i = 0; i < 4; i++)\n\t{\n\t\tfor (j = 0, line = 0; j < 3 && line < MAX_DEBUGLINES; line++)\n\t\t{\n\t\t\tif (!debuglines[line])\n\t\t\t{\n\t\t\t\tdebuglines[line] = botimport.DebugLineCreate();\n\t\t\t\tlines[j++] = debuglines[line];\n\t\t\t\tdebuglinevisible[line] = qtrue;\n\t\t\t\tnumdebuglines++;\n\t\t\t} //end if\n\t\t\telse if (!debuglinevisible[line])\n\t\t\t{\n\t\t\t\tlines[j++] = debuglines[line];\n\t\t\t\tdebuglinevisible[line] = qtrue;\n\t\t\t} //end else\n\t\t} //end for\n\t\t//top plane\n\t\tbotimport.DebugLineShow(lines[0], bboxcorners[i],\n\t\t\t\t\t\t\t\t\tbboxcorners[(i+1)&3], LINECOLOR_RED);\n\t\t//bottom plane\n\t\tbotimport.DebugLineShow(lines[1], bboxcorners[4+i],\n\t\t\t\t\t\t\t\t\tbboxcorners[4+((i+1)&3)], LINECOLOR_RED);\n\t\t//vertical lines\n\t\tbotimport.DebugLineShow(lines[2], bboxcorners[i],\n\t\t\t\t\t\t\t\t\tbboxcorners[4+i], LINECOLOR_RED);\n\t} //end for\n} //end of the function AAS_ShowBoundingBox\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ShowFace(int facenum)\n{\n\tint i, color, edgenum;\n\taas_edge_t *edge;\n\taas_face_t *face;\n\taas_plane_t *plane;\n\tvec3_t start, end;\n\n\tcolor = LINECOLOR_YELLOW;\n\t//check if face number is in range\n\tif (facenum >= aasworld.numfaces)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"facenum %d out of range\\n\", facenum);\n\t} //end if\n\tface = &aasworld.faces[facenum];\n\t//walk through the edges of the face\n\tfor (i = 0; i < face->numedges; i++)\n\t{\n\t\t//edge number\n\t\tedgenum = abs(aasworld.edgeindex[face->firstedge + i]);\n\t\t//check if edge number is in range\n\t\tif (edgenum >= aasworld.numedges)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"edgenum %d out of range\\n\", edgenum);\n\t\t} //end if\n\t\tedge = &aasworld.edges[edgenum];\n\t\tif (color == LINECOLOR_RED) color = LINECOLOR_GREEN;\n\t\telse if (color == LINECOLOR_GREEN) color = LINECOLOR_BLUE;\n\t\telse if (color == LINECOLOR_BLUE) color = LINECOLOR_YELLOW;\n\t\telse color = LINECOLOR_RED;\n\t\tAAS_DebugLine(aasworld.vertexes[edge->v[0]],\n\t\t\t\t\t\t\t\t\t\taasworld.vertexes[edge->v[1]],\n\t\t\t\t\t\t\t\t\t\tcolor);\n\t} //end for\n\tplane = &aasworld.planes[face->planenum];\n\tedgenum = abs(aasworld.edgeindex[face->firstedge]);\n\tedge = &aasworld.edges[edgenum];\n\tVectorCopy(aasworld.vertexes[edge->v[0]], start);\n\tVectorMA(start, 20, plane->normal, end);\n\tAAS_DebugLine(start, end, LINECOLOR_RED);\n} //end of the function AAS_ShowFace\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ShowFacePolygon(int facenum, int color, int flip)\n{\n\tint i, edgenum, numpoints;\n\tvec3_t points[128];\n\taas_edge_t *edge;\n\taas_face_t *face;\n\n\t//check if face number is in range\n\tif (facenum >= aasworld.numfaces)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"facenum %d out of range\\n\", facenum);\n\t} //end if\n\tface = &aasworld.faces[facenum];\n\t//walk through the edges of the face\n\tnumpoints = 0;\n\tif (flip)\n\t{\n\t\tfor (i = face->numedges-1; i >= 0; i--)\n\t\t{\n\t\t\t//edge number\n\t\t\tedgenum = aasworld.edgeindex[face->firstedge + i];\n\t\t\tedge = &aasworld.edges[abs(edgenum)];\n\t\t\tVectorCopy(aasworld.vertexes[edge->v[edgenum < 0]], points[numpoints]);\n\t\t\tnumpoints++;\n\t\t} //end for\n\t} //end if\n\telse\n\t{\n\t\tfor (i = 0; i < face->numedges; i++)\n\t\t{\n\t\t\t//edge number\n\t\t\tedgenum = aasworld.edgeindex[face->firstedge + i];\n\t\t\tedge = &aasworld.edges[abs(edgenum)];\n\t\t\tVectorCopy(aasworld.vertexes[edge->v[edgenum < 0]], points[numpoints]);\n\t\t\tnumpoints++;\n\t\t} //end for\n\t} //end else\n\tAAS_ShowPolygon(color, numpoints, points);\n} //end of the function AAS_ShowFacePolygon\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ShowArea(int areanum, int groundfacesonly)\n{\n\tint areaedges[MAX_DEBUGLINES];\n\tint numareaedges, i, j, n, color = 0, line;\n\tint facenum, edgenum;\n\taas_area_t *area;\n\taas_face_t *face;\n\taas_edge_t *edge;\n\n\t//\n\tnumareaedges = 0;\n\t//\n\tif (areanum < 0 || areanum >= aasworld.numareas)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"area %d out of range [0, %d]\\n\",\n\t\t\t\t\t\t\t\tareanum, aasworld.numareas);\n\t\treturn;\n\t} //end if\n\t//pointer to the convex area\n\tarea = &aasworld.areas[areanum];\n\t//walk through the faces of the area\n\tfor (i = 0; i < area->numfaces; i++)\n\t{\n\t\tfacenum = abs(aasworld.faceindex[area->firstface + i]);\n\t\t//check if face number is in range\n\t\tif (facenum >= aasworld.numfaces)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"facenum %d out of range\\n\", facenum);\n\t\t} //end if\n\t\tface = &aasworld.faces[facenum];\n\t\t//ground faces only\n\t\tif (groundfacesonly)\n\t\t{\n\t\t\tif (!(face->faceflags & (FACE_GROUND | FACE_LADDER))) continue;\n\t\t} //end if\n\t\t//walk through the edges of the face\n\t\tfor (j = 0; j < face->numedges; j++)\n\t\t{\n\t\t\t//edge number\n\t\t\tedgenum = abs(aasworld.edgeindex[face->firstedge + j]);\n\t\t\t//check if edge number is in range\n\t\t\tif (edgenum >= aasworld.numedges)\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"edgenum %d out of range\\n\", edgenum);\n\t\t\t} //end if\n\t\t\t//check if the edge is stored already\n\t\t\tfor (n = 0; n < numareaedges; n++)\n\t\t\t{\n\t\t\t\tif (areaedges[n] == edgenum) break;\n\t\t\t} //end for\n\t\t\tif (n == numareaedges && numareaedges < MAX_DEBUGLINES)\n\t\t\t{\n\t\t\t\tareaedges[numareaedges++] = edgenum;\n\t\t\t} //end if\n\t\t} //end for\n\t\t//AAS_ShowFace(facenum);\n\t} //end for\n\t//draw all the edges\n\tfor (n = 0; n < numareaedges; n++)\n\t{\n\t\tfor (line = 0; line < MAX_DEBUGLINES; line++)\n\t\t{\n\t\t\tif (!debuglines[line])\n\t\t\t{\n\t\t\t\tdebuglines[line] = botimport.DebugLineCreate();\n\t\t\t\tdebuglinevisible[line] = qfalse;\n\t\t\t\tnumdebuglines++;\n\t\t\t} //end if\n\t\t\tif (!debuglinevisible[line])\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t} //end else\n\t\t} //end for\n\t\tif (line >= MAX_DEBUGLINES) return;\n\t\tedge = &aasworld.edges[areaedges[n]];\n\t\tif (color == LINECOLOR_RED) color = LINECOLOR_BLUE;\n\t\telse if (color == LINECOLOR_BLUE) color = LINECOLOR_GREEN;\n\t\telse if (color == LINECOLOR_GREEN) color = LINECOLOR_YELLOW;\n\t\telse color = LINECOLOR_RED;\n\t\tbotimport.DebugLineShow(debuglines[line],\n\t\t\t\t\t\t\t\t\taasworld.vertexes[edge->v[0]],\n\t\t\t\t\t\t\t\t\taasworld.vertexes[edge->v[1]],\n\t\t\t\t\t\t\t\t\tcolor);\n\t\tdebuglinevisible[line] = qtrue;\n\t} //end for*/\n} //end of the function AAS_ShowArea\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ShowAreaPolygons(int areanum, int color, int groundfacesonly)\n{\n\tint i, facenum;\n\taas_area_t *area;\n\taas_face_t *face;\n\n\t//\n\tif (areanum < 0 || areanum >= aasworld.numareas)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"area %d out of range [0, %d]\\n\",\n\t\t\t\t\t\t\t\tareanum, aasworld.numareas);\n\t\treturn;\n\t} //end if\n\t//pointer to the convex area\n\tarea = &aasworld.areas[areanum];\n\t//walk through the faces of the area\n\tfor (i = 0; i < area->numfaces; i++)\n\t{\n\t\tfacenum = abs(aasworld.faceindex[area->firstface + i]);\n\t\t//check if face number is in range\n\t\tif (facenum >= aasworld.numfaces)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"facenum %d out of range\\n\", facenum);\n\t\t} //end if\n\t\tface = &aasworld.faces[facenum];\n\t\t//ground faces only\n\t\tif (groundfacesonly)\n\t\t{\n\t\t\tif (!(face->faceflags & (FACE_GROUND | FACE_LADDER))) continue;\n\t\t} //end if\n\t\tAAS_ShowFacePolygon(facenum, color, face->frontarea != areanum);\n\t} //end for\n} //end of the function AAS_ShowAreaPolygons\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_DrawCross(vec3_t origin, float size, int color)\n{\n\tint i;\n\tvec3_t start, end;\n\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tVectorCopy(origin, start);\n\t\tstart[i] += size;\n\t\tVectorCopy(origin, end);\n\t\tend[i] -= size;\n\t\tAAS_DebugLine(start, end, color);\n\t} //end for\n} //end of the function AAS_DrawCross\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_PrintTravelType(int traveltype)\n{\n#ifdef DEBUG\n\tchar *str;\n\t//\n\tswitch(traveltype & TRAVELTYPE_MASK)\n\t{\n\t\tcase TRAVEL_INVALID: str = \"TRAVEL_INVALID\"; break;\n\t\tcase TRAVEL_WALK: str = \"TRAVEL_WALK\"; break;\n\t\tcase TRAVEL_CROUCH: str = \"TRAVEL_CROUCH\"; break;\n\t\tcase TRAVEL_BARRIERJUMP: str = \"TRAVEL_BARRIERJUMP\"; break;\n\t\tcase TRAVEL_JUMP: str = \"TRAVEL_JUMP\"; break;\n\t\tcase TRAVEL_LADDER: str = \"TRAVEL_LADDER\"; break;\n\t\tcase TRAVEL_WALKOFFLEDGE: str = \"TRAVEL_WALKOFFLEDGE\"; break;\n\t\tcase TRAVEL_SWIM: str = \"TRAVEL_SWIM\"; break;\n\t\tcase TRAVEL_WATERJUMP: str = \"TRAVEL_WATERJUMP\"; break;\n\t\tcase TRAVEL_TELEPORT: str = \"TRAVEL_TELEPORT\"; break;\n\t\tcase TRAVEL_ELEVATOR: str = \"TRAVEL_ELEVATOR\"; break;\n\t\tcase TRAVEL_ROCKETJUMP: str = \"TRAVEL_ROCKETJUMP\"; break;\n\t\tcase TRAVEL_BFGJUMP: str = \"TRAVEL_BFGJUMP\"; break;\n\t\tcase TRAVEL_GRAPPLEHOOK: str = \"TRAVEL_GRAPPLEHOOK\"; break;\n\t\tcase TRAVEL_JUMPPAD: str = \"TRAVEL_JUMPPAD\"; break;\n\t\tcase TRAVEL_FUNCBOB: str = \"TRAVEL_FUNCBOB\"; break;\n\t\tdefault: str = \"UNKNOWN TRAVEL TYPE\"; break;\n\t} //end switch\n\tbotimport.Print(PRT_MESSAGE, \"%s\", str);\n#endif\n} //end of the function AAS_PrintTravelType\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_DrawArrow(vec3_t start, vec3_t end, int linecolor, int arrowcolor)\n{\n\tvec3_t dir, cross, p1, p2, up = {0, 0, 1};\n\tfloat dot;\n\n\tVectorSubtract(end, start, dir);\n\tVectorNormalize(dir);\n\tdot = DotProduct(dir, up);\n\tif (dot > 0.99 || dot < -0.99) VectorSet(cross, 1, 0, 0);\n\telse CrossProduct(dir, up, cross);\n\n\tVectorMA(end, -6, dir, p1);\n\tVectorCopy(p1, p2);\n\tVectorMA(p1, 6, cross, p1);\n\tVectorMA(p2, -6, cross, p2);\n\n\tAAS_DebugLine(start, end, linecolor);\n\tAAS_DebugLine(p1, end, arrowcolor);\n\tAAS_DebugLine(p2, end, arrowcolor);\n} //end of the function AAS_DrawArrow\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ShowReachability(aas_reachability_t *reach)\n{\n\tvec3_t dir, cmdmove, velocity;\n\tfloat speed, zvel;\n\taas_clientmove_t move;\n\n\tAAS_ShowAreaPolygons(reach->areanum, 5, qtrue);\n\t//AAS_ShowArea(reach->areanum, qtrue);\n\tAAS_DrawArrow(reach->start, reach->end, LINECOLOR_BLUE, LINECOLOR_YELLOW);\n\t//\n\tif ((reach->traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMP ||\n\t\t(reach->traveltype & TRAVELTYPE_MASK) == TRAVEL_WALKOFFLEDGE)\n\t{\n\t\tAAS_HorizontalVelocityForJump(aassettings.phys_jumpvel, reach->start, reach->end, &speed);\n\t\t//\n\t\tVectorSubtract(reach->end, reach->start, dir);\n\t\tdir[2] = 0;\n\t\tVectorNormalize(dir);\n\t\t//set the velocity\n\t\tVectorScale(dir, speed, velocity);\n\t\t//set the command movement\n\t\tVectorClear(cmdmove);\n\t\tcmdmove[2] = aassettings.phys_jumpvel;\n\t\t//\n\t\tAAS_PredictClientMovement(&move, -1, reach->start, PRESENCE_NORMAL, qtrue,\n\t\t\t\t\t\t\t\t\tvelocity, cmdmove, 3, 30, 0.1f,\n\t\t\t\t\t\t\t\t\tSE_HITGROUND|SE_ENTERWATER|SE_ENTERSLIME|\n\t\t\t\t\t\t\t\t\tSE_ENTERLAVA|SE_HITGROUNDDAMAGE, 0, qtrue);\n\t\t//\n\t\tif ((reach->traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMP)\n\t\t{\n\t\t\tAAS_JumpReachRunStart(reach, dir);\n\t\t\tAAS_DrawCross(dir, 4, LINECOLOR_BLUE);\n\t\t} //end if\n\t} //end if\n\telse if ((reach->traveltype & TRAVELTYPE_MASK) == TRAVEL_ROCKETJUMP)\n\t{\n\t\tzvel = AAS_RocketJumpZVelocity(reach->start);\n\t\tAAS_HorizontalVelocityForJump(zvel, reach->start, reach->end, &speed);\n\t\t//\n\t\tVectorSubtract(reach->end, reach->start, dir);\n\t\tdir[2] = 0;\n\t\tVectorNormalize(dir);\n\t\t//get command movement\n\t\tVectorScale(dir, speed, cmdmove);\n\t\tVectorSet(velocity, 0, 0, zvel);\n\t\t//\n\t\tAAS_PredictClientMovement(&move, -1, reach->start, PRESENCE_NORMAL, qtrue,\n\t\t\t\t\t\t\t\t\tvelocity, cmdmove, 30, 30, 0.1f,\n\t\t\t\t\t\t\t\t\tSE_ENTERWATER|SE_ENTERSLIME|\n\t\t\t\t\t\t\t\t\tSE_ENTERLAVA|SE_HITGROUNDDAMAGE|\n\t\t\t\t\t\t\t\t\tSE_TOUCHJUMPPAD|SE_HITGROUNDAREA, reach->areanum, qtrue);\n\t} //end else if\n\telse if ((reach->traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMPPAD)\n\t{\n\t\tVectorSet(cmdmove, 0, 0, 0);\n\t\t//\n\t\tVectorSubtract(reach->end, reach->start, dir);\n\t\tdir[2] = 0;\n\t\tVectorNormalize(dir);\n\t\t//set the velocity\n\t\t//NOTE: the edgenum is the horizontal velocity\n\t\tVectorScale(dir, reach->edgenum, velocity);\n\t\t//NOTE: the facenum is the Z velocity\n\t\tvelocity[2] = reach->facenum;\n\t\t//\n\t\tAAS_PredictClientMovement(&move, -1, reach->start, PRESENCE_NORMAL, qtrue,\n\t\t\t\t\t\t\t\t\tvelocity, cmdmove, 30, 30, 0.1f,\n\t\t\t\t\t\t\t\t\tSE_ENTERWATER|SE_ENTERSLIME|\n\t\t\t\t\t\t\t\t\tSE_ENTERLAVA|SE_HITGROUNDDAMAGE|\n\t\t\t\t\t\t\t\t\tSE_TOUCHJUMPPAD|SE_HITGROUNDAREA, reach->areanum, qtrue);\n\t} //end else if\n} //end of the function AAS_ShowReachability\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ShowReachableAreas(int areanum)\n{\n\taas_areasettings_t *settings;\n\tstatic aas_reachability_t reach;\n\tstatic int index, lastareanum;\n\tstatic float lasttime;\n\n\tif (areanum != lastareanum)\n\t{\n\t\tindex = 0;\n\t\tlastareanum = areanum;\n\t} //end if\n\tsettings = &aasworld.areasettings[areanum];\n\t//\n\tif (!settings->numreachableareas) return;\n\t//\n\tif (index >= settings->numreachableareas) index = 0;\n\t//\n\tif (AAS_Time() - lasttime > 1.5)\n\t{\n\t\tCom_Memcpy(&reach, &aasworld.reachability[settings->firstreachablearea + index], sizeof(aas_reachability_t));\n\t\tindex++;\n\t\tlasttime = AAS_Time();\n\t\tAAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK);\n\t\tbotimport.Print(PRT_MESSAGE, \"\\n\");\n\t} //end if\n\tAAS_ShowReachability(&reach);\n} //end of the function ShowReachableAreas\n\nvoid AAS_FloodAreas_r(int areanum, int cluster, int *done)\n{\n\tint nextareanum, i, facenum;\n\taas_area_t *area;\n\taas_face_t *face;\n\taas_areasettings_t *settings;\n\taas_reachability_t *reach;\n\n\tAAS_ShowAreaPolygons(areanum, 1, qtrue);\n\t//pointer to the convex area\n\tarea = &aasworld.areas[areanum];\n\tsettings = &aasworld.areasettings[areanum];\n\t//walk through the faces of the area\n\tfor (i = 0; i < area->numfaces; i++)\n\t{\n\t\tfacenum = abs(aasworld.faceindex[area->firstface + i]);\n\t\tface = &aasworld.faces[facenum];\n\t\tif (face->frontarea == areanum)\n\t\t\tnextareanum = face->backarea;\n\t\telse\n\t\t\tnextareanum = face->frontarea;\n\t\tif (!nextareanum)\n\t\t\tcontinue;\n\t\tif (done[nextareanum])\n\t\t\tcontinue;\n\t\tdone[nextareanum] = qtrue;\n\t\tif (aasworld.areasettings[nextareanum].contents & AREACONTENTS_VIEWPORTAL)\n\t\t\tcontinue;\n\t\tif (AAS_AreaCluster(nextareanum) != cluster)\n\t\t\tcontinue;\n\t\tAAS_FloodAreas_r(nextareanum, cluster, done);\n\t} //end for\n\t//\n\tfor (i = 0; i < settings->numreachableareas; i++)\n\t{\n\t\treach = &aasworld.reachability[settings->firstreachablearea + i];\n\t\tnextareanum = reach->areanum;\n\t\tif (!nextareanum)\n\t\t\tcontinue;\n\t\tif (done[nextareanum])\n\t\t\tcontinue;\n\t\tdone[nextareanum] = qtrue;\n\t\tif (aasworld.areasettings[nextareanum].contents & AREACONTENTS_VIEWPORTAL)\n\t\t\tcontinue;\n\t\tif (AAS_AreaCluster(nextareanum) != cluster)\n\t\t\tcontinue;\n\t\t/*\n\t\tif ((reach->traveltype & TRAVELTYPE_MASK) == TRAVEL_WALKOFFLEDGE)\n\t\t{\n\t\t\tAAS_DebugLine(reach->start, reach->end, 1);\n\t\t}\n\t\t*/\n\t\tAAS_FloodAreas_r(nextareanum, cluster, done);\n\t}\n}\n\nvoid AAS_FloodAreas(vec3_t origin)\n{\n\tint areanum, cluster, *done;\n\n\tdone = (int *) GetClearedMemory(aasworld.numareas * sizeof(int));\n\tareanum = AAS_PointAreaNum(origin);\n\tcluster = AAS_AreaCluster(areanum);\n\tAAS_FloodAreas_r(areanum, cluster, done);\n}\n"
  },
  {
    "path": "code/botlib/be_aas_debug.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_debug.h\n *\n * desc:\t\tAAS\n *\n * $Archive: /source/code/botlib/be_aas_debug.h $\n *\n *****************************************************************************/\n\n//clear the shown debug lines\nvoid AAS_ClearShownDebugLines(void);\n//\nvoid AAS_ClearShownPolygons(void);\n//show a debug line\nvoid AAS_DebugLine(vec3_t start, vec3_t end, int color);\n//show a permenent line\nvoid AAS_PermanentLine(vec3_t start, vec3_t end, int color);\n//show a permanent cross\nvoid AAS_DrawPermanentCross(vec3_t origin, float size, int color);\n//draw a cross in the plane\nvoid AAS_DrawPlaneCross(vec3_t point, vec3_t normal, float dist, int type, int color);\n//show a bounding box\nvoid AAS_ShowBoundingBox(vec3_t origin, vec3_t mins, vec3_t maxs);\n//show a face\nvoid AAS_ShowFace(int facenum);\n//show an area\nvoid AAS_ShowArea(int areanum, int groundfacesonly);\n//\nvoid AAS_ShowAreaPolygons(int areanum, int color, int groundfacesonly);\n//draw a cros\nvoid AAS_DrawCross(vec3_t origin, float size, int color);\n//print the travel type\nvoid AAS_PrintTravelType(int traveltype);\n//draw an arrow\nvoid AAS_DrawArrow(vec3_t start, vec3_t end, int linecolor, int arrowcolor);\n//visualize the given reachability\nvoid AAS_ShowReachability(struct aas_reachability_s *reach);\n//show the reachable areas from the given area\nvoid AAS_ShowReachableAreas(int areanum);\n\n"
  },
  {
    "path": "code/botlib/be_aas_def.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_def.h\n *\n * desc:\t\tAAS\n *\n * $Archive: /source/code/botlib/be_aas_def.h $\n *\n *****************************************************************************/\n\n//debugging on\n#define AAS_DEBUG\n\n#define MAX_CLIENTS\t\t\t64\n#define\tMAX_MODELS\t\t\t256\t\t// these are sent over the net as 8 bits\n#define\tMAX_SOUNDS\t\t\t256\t\t// so they cannot be blindly increased\n#define\tMAX_CONFIGSTRINGS\t1024\n\n#define\tCS_SCORES\t\t\t32\n#define\tCS_MODELS\t\t\t(CS_SCORES+MAX_CLIENTS)\n#define\tCS_SOUNDS\t\t\t(CS_MODELS+MAX_MODELS)\n\n#define DF_AASENTNUMBER(x)\t\t(x - aasworld.entities)\n#define DF_NUMBERAASENT(x)\t\t(&aasworld.entities[x])\n#define DF_AASENTCLIENT(x)\t\t(x - aasworld.entities - 1)\n#define DF_CLIENTAASENT(x)\t\t(&aasworld.entities[x + 1])\n\n#ifndef MAX_PATH\n\t#define MAX_PATH\t\t\t\tMAX_QPATH\n#endif\n\n//string index (for model, sound and image index)\ntypedef struct aas_stringindex_s\n{\n\tint numindexes;\n\tchar **index;\n} aas_stringindex_t;\n\n//structure to link entities to areas and areas to entities\ntypedef struct aas_link_s\n{\n\tint entnum;\n\tint areanum;\n\tstruct aas_link_s *next_ent, *prev_ent;\n\tstruct aas_link_s *next_area, *prev_area;\n} aas_link_t;\n\n//structure to link entities to leaves and leaves to entities\ntypedef struct bsp_link_s\n{\n\tint entnum;\n\tint leafnum;\n\tstruct bsp_link_s *next_ent, *prev_ent;\n\tstruct bsp_link_s *next_leaf, *prev_leaf;\n} bsp_link_t;\n\ntypedef struct bsp_entdata_s\n{\n\tvec3_t origin;\n\tvec3_t angles;\n\tvec3_t absmins;\n\tvec3_t absmaxs;\n\tint solid;\n\tint modelnum;\n} bsp_entdata_t;\n\n//entity\ntypedef struct aas_entity_s\n{\n\t//entity info\n\taas_entityinfo_t i;\n\t//links into the AAS areas\n\taas_link_t *areas;\n\t//links into the BSP leaves\n\tbsp_link_t *leaves;\n} aas_entity_t;\n\ntypedef struct aas_settings_s\n{\n\tvec3_t phys_gravitydirection;\n\tfloat phys_friction;\n\tfloat phys_stopspeed;\n\tfloat phys_gravity;\n\tfloat phys_waterfriction;\n\tfloat phys_watergravity;\n\tfloat phys_maxvelocity;\n\tfloat phys_maxwalkvelocity;\n\tfloat phys_maxcrouchvelocity;\n\tfloat phys_maxswimvelocity;\n\tfloat phys_walkaccelerate;\n\tfloat phys_airaccelerate;\n\tfloat phys_swimaccelerate;\n\tfloat phys_maxstep;\n\tfloat phys_maxsteepness;\n\tfloat phys_maxwaterjump;\n\tfloat phys_maxbarrier;\n\tfloat phys_jumpvel;\n\tfloat phys_falldelta5;\n\tfloat phys_falldelta10;\n\tfloat rs_waterjump;\n\tfloat rs_teleport;\n\tfloat rs_barrierjump;\n\tfloat rs_startcrouch;\n\tfloat rs_startgrapple;\n\tfloat rs_startwalkoffledge;\n\tfloat rs_startjump;\n\tfloat rs_rocketjump;\n\tfloat rs_bfgjump;\n\tfloat rs_jumppad;\n\tfloat rs_aircontrolledjumppad;\n\tfloat rs_funcbob;\n\tfloat rs_startelevator;\n\tfloat rs_falldamage5;\n\tfloat rs_falldamage10;\n\tfloat rs_maxfallheight;\n\tfloat rs_maxjumpfallheight;\n} aas_settings_t;\n\n#define CACHETYPE_PORTAL\t\t0\n#define CACHETYPE_AREA\t\t\t1\n\n//routing cache\ntypedef struct aas_routingcache_s\n{\n\tbyte type;\t\t\t\t\t\t\t\t\t//portal or area cache\n\tfloat time;\t\t\t\t\t\t\t\t\t//last time accessed or updated\n\tint size;\t\t\t\t\t\t\t\t\t//size of the routing cache\n\tint cluster;\t\t\t\t\t\t\t\t//cluster the cache is for\n\tint areanum;\t\t\t\t\t\t\t\t//area the cache is created for\n\tvec3_t origin;\t\t\t\t\t\t\t\t//origin within the area\n\tfloat starttraveltime;\t\t\t\t\t\t//travel time to start with\n\tint travelflags;\t\t\t\t\t\t\t//combinations of the travel flags\n\tstruct aas_routingcache_s *prev, *next;\n\tstruct aas_routingcache_s *time_prev, *time_next;\n\tunsigned char *reachabilities;\t\t\t\t//reachabilities used for routing\n\tunsigned short int traveltimes[1];\t\t\t//travel time for every area (variable sized)\n} aas_routingcache_t;\n\n//fields for the routing algorithm\ntypedef struct aas_routingupdate_s\n{\n\tint cluster;\n\tint areanum;\t\t\t\t\t\t\t\t//area number of the update\n\tvec3_t start;\t\t\t\t\t\t\t\t//start point the area was entered\n\tunsigned short int tmptraveltime;\t\t\t//temporary travel time\n\tunsigned short int *areatraveltimes;\t\t//travel times within the area\n\tqboolean inlist;\t\t\t\t\t\t\t//true if the update is in the list\n\tstruct aas_routingupdate_s *next;\n\tstruct aas_routingupdate_s *prev;\n} aas_routingupdate_t;\n\n//reversed reachability link\ntypedef struct aas_reversedlink_s\n{\n\tint linknum;\t\t\t\t\t\t\t\t//the aas_areareachability_t\n\tint areanum;\t\t\t\t\t\t\t\t//reachable from this area\n\tstruct aas_reversedlink_s *next;\t\t\t//next link\n} aas_reversedlink_t;\n\n//reversed area reachability\ntypedef struct aas_reversedreachability_s\n{\n\tint numlinks;\n\taas_reversedlink_t *first;\n} aas_reversedreachability_t;\n\n//areas a reachability goes through\ntypedef struct aas_reachabilityareas_s\n{\n\tint firstarea, numareas;\n} aas_reachabilityareas_t;\n\ntypedef struct aas_s\n{\n\tint loaded;\t\t\t\t\t\t\t\t\t//true when an AAS file is loaded\n\tint initialized;\t\t\t\t\t\t\t//true when AAS has been initialized\n\tint savefile;\t\t\t\t\t\t\t\t//set true when file should be saved\n\tint bspchecksum;\n\t//current time\n\tfloat time;\n\tint numframes;\n\t//name of the aas file\n\tchar filename[MAX_PATH];\n\tchar mapname[MAX_PATH];\n\t//bounding boxes\n\tint numbboxes;\n\taas_bbox_t *bboxes;\n\t//vertexes\n\tint numvertexes;\n\taas_vertex_t *vertexes;\n\t//planes\n\tint numplanes;\n\taas_plane_t *planes;\n\t//edges\n\tint numedges;\n\taas_edge_t *edges;\n\t//edge index\n\tint edgeindexsize;\n\taas_edgeindex_t *edgeindex;\n\t//faces\n\tint numfaces;\n\taas_face_t *faces;\n\t//face index\n\tint faceindexsize;\n\taas_faceindex_t *faceindex;\n\t//convex areas\n\tint numareas;\n\taas_area_t *areas;\n\t//convex area settings\n\tint numareasettings;\n\taas_areasettings_t *areasettings;\n\t//reachablity list\n\tint reachabilitysize;\n\taas_reachability_t *reachability;\n\t//nodes of the bsp tree\n\tint numnodes;\n\taas_node_t *nodes;\n\t//cluster portals\n\tint numportals;\n\taas_portal_t *portals;\n\t//cluster portal index\n\tint portalindexsize;\n\taas_portalindex_t *portalindex;\n\t//clusters\n\tint numclusters;\n\taas_cluster_t *clusters;\n\t//\n\tint numreachabilityareas;\n\tfloat reachabilitytime;\n\t//enities linked in the areas\n\taas_link_t *linkheap;\t\t\t\t\t\t//heap with link structures\n\tint linkheapsize;\t\t\t\t\t\t\t//size of the link heap\n\taas_link_t *freelinks;\t\t\t\t\t\t//first free link\n\taas_link_t **arealinkedentities;\t\t\t//entities linked into areas\n\t//entities\n\tint maxentities;\n\tint maxclients;\n\taas_entity_t *entities;\n\t//string indexes\n\tchar *configstrings[MAX_CONFIGSTRINGS];\n\tint indexessetup;\n\t//index to retrieve travel flag for a travel type\n\tint travelflagfortype[MAX_TRAVELTYPES];\n\t//travel flags for each area based on contents\n\tint *areacontentstravelflags;\n\t//routing update\n\taas_routingupdate_t *areaupdate;\n\taas_routingupdate_t *portalupdate;\n\t//number of routing updates during a frame (reset every frame)\n\tint frameroutingupdates;\n\t//reversed reachability links\n\taas_reversedreachability_t *reversedreachability;\n\t//travel times within the areas\n\tunsigned short ***areatraveltimes;\n\t//array of size numclusters with cluster cache\n\taas_routingcache_t ***clusterareacache;\n\taas_routingcache_t **portalcache;\n\t//cache list sorted on time\n\taas_routingcache_t *oldestcache;\t\t// start of cache list sorted on time\n\taas_routingcache_t *newestcache;\t\t// end of cache list sorted on time\n\t//maximum travel time through portal areas\n\tint *portalmaxtraveltimes;\n\t//areas the reachabilities go through\n\tint *reachabilityareaindex;\n\taas_reachabilityareas_t *reachabilityareas;\n} aas_t;\n\n#define AASINTERN\n\n#ifndef BSPCINCLUDE\n\n#include \"be_aas_main.h\"\n#include \"be_aas_entity.h\"\n#include \"be_aas_sample.h\"\n#include \"be_aas_cluster.h\"\n#include \"be_aas_reach.h\"\n#include \"be_aas_route.h\"\n#include \"be_aas_routealt.h\"\n#include \"be_aas_debug.h\"\n#include \"be_aas_file.h\"\n#include \"be_aas_optimize.h\"\n#include \"be_aas_bsp.h\"\n#include \"be_aas_move.h\"\n\n#endif //BSPCINCLUDE\n"
  },
  {
    "path": "code/botlib/be_aas_entity.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_entity.c\n *\n * desc:\t\tAAS entities\n *\n * $Archive: /MissionPack/code/botlib/be_aas_entity.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_memory.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#include \"l_utils.h\"\n#include \"l_log.h\"\n#include \"aasfile.h\"\n#include \"../game/botlib.h\"\n#include \"../game/be_aas.h\"\n#include \"be_aas_funcs.h\"\n#include \"be_interface.h\"\n#include \"be_aas_def.h\"\n\n#define MASK_SOLID\t\tCONTENTS_PLAYERCLIP\n\n//FIXME: these might change\nenum {\n\tET_GENERAL,\n\tET_PLAYER,\n\tET_ITEM,\n\tET_MISSILE,\n\tET_MOVER\n};\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_UpdateEntity(int entnum, bot_entitystate_t *state)\n{\n\tint relink;\n\taas_entity_t *ent;\n\tvec3_t absmins, absmaxs;\n\n\tif (!aasworld.loaded)\n\t{\n\t\tbotimport.Print(PRT_MESSAGE, \"AAS_UpdateEntity: not loaded\\n\");\n\t\treturn BLERR_NOAASFILE;\n\t} //end if\n\n\tent = &aasworld.entities[entnum];\n\n\tif (!state) {\n\t\t//unlink the entity\n\t\tAAS_UnlinkFromAreas(ent->areas);\n\t\t//unlink the entity from the BSP leaves\n\t\tAAS_UnlinkFromBSPLeaves(ent->leaves);\n\t\t//\n\t\tent->areas = NULL;\n\t\t//\n\t\tent->leaves = NULL;\n\t\treturn BLERR_NOERROR;\n\t}\n\n\tent->i.update_time = AAS_Time() - ent->i.ltime;\n\tent->i.type = state->type;\n\tent->i.flags = state->flags;\n\tent->i.ltime = AAS_Time();\n\tVectorCopy(ent->i.origin, ent->i.lastvisorigin);\n\tVectorCopy(state->old_origin, ent->i.old_origin);\n\tent->i.solid = state->solid;\n\tent->i.groundent = state->groundent;\n\tent->i.modelindex = state->modelindex;\n\tent->i.modelindex2 = state->modelindex2;\n\tent->i.frame = state->frame;\n\tent->i.event = state->event;\n\tent->i.eventParm = state->eventParm;\n\tent->i.powerups = state->powerups;\n\tent->i.weapon = state->weapon;\n\tent->i.legsAnim = state->legsAnim;\n\tent->i.torsoAnim = state->torsoAnim;\n\t//number of the entity\n\tent->i.number = entnum;\n\t//updated so set valid flag\n\tent->i.valid = qtrue;\n\t//link everything the first frame\n\tif (aasworld.numframes == 1) relink = qtrue;\n\telse relink = qfalse;\n\t//\n\tif (ent->i.solid == SOLID_BSP)\n\t{\n\t\t//if the angles of the model changed\n\t\tif (!VectorCompare(state->angles, ent->i.angles))\n\t\t{\n\t\t\tVectorCopy(state->angles, ent->i.angles);\n\t\t\trelink = qtrue;\n\t\t} //end if\n\t\t//get the mins and maxs of the model\n\t\t//FIXME: rotate mins and maxs\n\t\tAAS_BSPModelMinsMaxsOrigin(ent->i.modelindex, ent->i.angles, ent->i.mins, ent->i.maxs, NULL);\n\t} //end if\n\telse if (ent->i.solid == SOLID_BBOX)\n\t{\n\t\t//if the bounding box size changed\n\t\tif (!VectorCompare(state->mins, ent->i.mins) ||\n\t\t\t\t!VectorCompare(state->maxs, ent->i.maxs))\n\t\t{\n\t\t\tVectorCopy(state->mins, ent->i.mins);\n\t\t\tVectorCopy(state->maxs, ent->i.maxs);\n\t\t\trelink = qtrue;\n\t\t} //end if\n\t\tVectorCopy(state->angles, ent->i.angles);\n\t} //end if\n\t//if the origin changed\n\tif (!VectorCompare(state->origin, ent->i.origin))\n\t{\n\t\tVectorCopy(state->origin, ent->i.origin);\n\t\trelink = qtrue;\n\t} //end if\n\t//if the entity should be relinked\n\tif (relink)\n\t{\n\t\t//don't link the world model\n\t\tif (entnum != ENTITYNUM_WORLD)\n\t\t{\n\t\t\t//absolute mins and maxs\n\t\t\tVectorAdd(ent->i.mins, ent->i.origin, absmins);\n\t\t\tVectorAdd(ent->i.maxs, ent->i.origin, absmaxs);\n\t\t\t//unlink the entity\n\t\t\tAAS_UnlinkFromAreas(ent->areas);\n\t\t\t//relink the entity to the AAS areas (use the larges bbox)\n\t\t\tent->areas = AAS_LinkEntityClientBBox(absmins, absmaxs, entnum, PRESENCE_NORMAL);\n\t\t\t//unlink the entity from the BSP leaves\n\t\t\tAAS_UnlinkFromBSPLeaves(ent->leaves);\n\t\t\t//link the entity to the world BSP tree\n\t\t\tent->leaves = AAS_BSPLinkEntity(absmins, absmaxs, entnum, 0);\n\t\t} //end if\n\t} //end if\n\treturn BLERR_NOERROR;\n} //end of the function AAS_UpdateEntity\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_EntityInfo(int entnum, aas_entityinfo_t *info)\n{\n\tif (!aasworld.initialized)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"AAS_EntityInfo: aasworld not initialized\\n\");\n\t\tCom_Memset(info, 0, sizeof(aas_entityinfo_t));\n\t\treturn;\n\t} //end if\n\n\tif (entnum < 0 || entnum >= aasworld.maxentities)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"AAS_EntityInfo: entnum %d out of range\\n\", entnum);\n\t\tCom_Memset(info, 0, sizeof(aas_entityinfo_t));\n\t\treturn;\n\t} //end if\n\n\tCom_Memcpy(info, &aasworld.entities[entnum].i, sizeof(aas_entityinfo_t));\n} //end of the function AAS_EntityInfo\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_EntityOrigin(int entnum, vec3_t origin)\n{\n\tif (entnum < 0 || entnum >= aasworld.maxentities)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"AAS_EntityOrigin: entnum %d out of range\\n\", entnum);\n\t\tVectorClear(origin);\n\t\treturn;\n\t} //end if\n\n\tVectorCopy(aasworld.entities[entnum].i.origin, origin);\n} //end of the function AAS_EntityOrigin\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_EntityModelindex(int entnum)\n{\n\tif (entnum < 0 || entnum >= aasworld.maxentities)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"AAS_EntityModelindex: entnum %d out of range\\n\", entnum);\n\t\treturn 0;\n\t} //end if\n\treturn aasworld.entities[entnum].i.modelindex;\n} //end of the function AAS_EntityModelindex\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_EntityType(int entnum)\n{\n\tif (!aasworld.initialized) return 0;\n\n\tif (entnum < 0 || entnum >= aasworld.maxentities)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"AAS_EntityType: entnum %d out of range\\n\", entnum);\n\t\treturn 0;\n\t} //end if\n\treturn aasworld.entities[entnum].i.type;\n} //end of the AAS_EntityType\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_EntityModelNum(int entnum)\n{\n\tif (!aasworld.initialized) return 0;\n\n\tif (entnum < 0 || entnum >= aasworld.maxentities)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"AAS_EntityModelNum: entnum %d out of range\\n\", entnum);\n\t\treturn 0;\n\t} //end if\n\treturn aasworld.entities[entnum].i.modelindex;\n} //end of the function AAS_EntityModelNum\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_OriginOfMoverWithModelNum(int modelnum, vec3_t origin)\n{\n\tint i;\n\taas_entity_t *ent;\n\n\tfor (i = 0; i < aasworld.maxentities; i++)\n\t{\n\t\tent = &aasworld.entities[i];\n\t\tif (ent->i.type == ET_MOVER)\n\t\t{\n\t\t\tif (ent->i.modelindex == modelnum)\n\t\t\t{\n\t\t\t\tVectorCopy(ent->i.origin, origin);\n\t\t\t\treturn qtrue;\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n\treturn qfalse;\n} //end of the function AAS_OriginOfMoverWithModelNum\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_EntitySize(int entnum, vec3_t mins, vec3_t maxs)\n{\n\taas_entity_t *ent;\n\n\tif (!aasworld.initialized) return;\n\n\tif (entnum < 0 || entnum >= aasworld.maxentities)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"AAS_EntitySize: entnum %d out of range\\n\", entnum);\n\t\treturn;\n\t} //end if\n\n\tent = &aasworld.entities[entnum];\n\tVectorCopy(ent->i.mins, mins);\n\tVectorCopy(ent->i.maxs, maxs);\n} //end of the function AAS_EntitySize\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_EntityBSPData(int entnum, bsp_entdata_t *entdata)\n{\n\taas_entity_t *ent;\n\n\tent = &aasworld.entities[entnum];\n\tVectorCopy(ent->i.origin, entdata->origin);\n\tVectorCopy(ent->i.angles, entdata->angles);\n\tVectorAdd(ent->i.origin, ent->i.mins, entdata->absmins);\n\tVectorAdd(ent->i.origin, ent->i.maxs, entdata->absmaxs);\n\tentdata->solid = ent->i.solid;\n\tentdata->modelnum = ent->i.modelindex - 1;\n} //end of the function AAS_EntityBSPData\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ResetEntityLinks(void)\n{\n\tint i;\n\tfor (i = 0; i < aasworld.maxentities; i++)\n\t{\n\t\taasworld.entities[i].areas = NULL;\n\t\taasworld.entities[i].leaves = NULL;\n\t} //end for\n} //end of the function AAS_ResetEntityLinks\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_InvalidateEntities(void)\n{\n\tint i;\n\tfor (i = 0; i < aasworld.maxentities; i++)\n\t{\n\t\taasworld.entities[i].i.valid = qfalse;\n\t\taasworld.entities[i].i.number = i;\n\t} //end for\n} //end of the function AAS_InvalidateEntities\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_UnlinkInvalidEntities(void)\n{\n\tint i;\n\taas_entity_t *ent;\n\n\tfor (i = 0; i < aasworld.maxentities; i++)\n\t{\n\t\tent = &aasworld.entities[i];\n\t\tif (!ent->i.valid)\n\t\t{\n\t\t\tAAS_UnlinkFromAreas( ent->areas );\n\t\t\tent->areas = NULL;\n\t\t\tAAS_UnlinkFromBSPLeaves( ent->leaves );\n\t\t\tent->leaves = NULL;\n\t\t} //end for\n\t} //end for\n} //end of the function AAS_UnlinkInvalidEntities\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_NearestEntity(vec3_t origin, int modelindex)\n{\n\tint i, bestentnum;\n\tfloat dist, bestdist;\n\taas_entity_t *ent;\n\tvec3_t dir;\n\n\tbestentnum = 0;\n\tbestdist = 99999;\n\tfor (i = 0; i < aasworld.maxentities; i++)\n\t{\n\t\tent = &aasworld.entities[i];\n\t\tif (ent->i.modelindex != modelindex) continue;\n\t\tVectorSubtract(ent->i.origin, origin, dir);\n\t\tif (abs(dir[0]) < 40)\n\t\t{\n\t\t\tif (abs(dir[1]) < 40)\n\t\t\t{\n\t\t\t\tdist = VectorLength(dir);\n\t\t\t\tif (dist < bestdist)\n\t\t\t\t{\n\t\t\t\t\tbestdist = dist;\n\t\t\t\t\tbestentnum = i;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n\treturn bestentnum;\n} //end of the function AAS_NearestEntity\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_BestReachableEntityArea(int entnum)\n{\n\taas_entity_t *ent;\n\n\tent = &aasworld.entities[entnum];\n\treturn AAS_BestReachableLinkArea(ent->areas);\n} //end of the function AAS_BestReachableEntityArea\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_NextEntity(int entnum)\n{\n\tif (!aasworld.loaded) return 0;\n\n\tif (entnum < 0) entnum = -1;\n\twhile(++entnum < aasworld.maxentities)\n\t{\n\t\tif (aasworld.entities[entnum].i.valid) return entnum;\n\t} //end while\n\treturn 0;\n} //end of the function AAS_NextEntity\n"
  },
  {
    "path": "code/botlib/be_aas_entity.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_entity.h\n *\n * desc:\t\tAAS\n *\n * $Archive: /source/code/botlib/be_aas_entity.h $\n *\n *****************************************************************************/\n\n#ifdef AASINTERN\n//invalidates all entity infos\nvoid AAS_InvalidateEntities(void);\n//unlink not updated entities\nvoid AAS_UnlinkInvalidEntities(void);\n//resets the entity AAS and BSP links (sets areas and leaves pointers to NULL)\nvoid AAS_ResetEntityLinks(void);\n//updates an entity\nint AAS_UpdateEntity(int ent, bot_entitystate_t *state);\n//gives the entity data used for collision detection\nvoid AAS_EntityBSPData(int entnum, bsp_entdata_t *entdata);\n#endif //AASINTERN\n\n//returns the size of the entity bounding box in mins and maxs\nvoid AAS_EntitySize(int entnum, vec3_t mins, vec3_t maxs);\n//returns the BSP model number of the entity\nint AAS_EntityModelNum(int entnum);\n//returns the origin of an entity with the given model number\nint AAS_OriginOfMoverWithModelNum(int modelnum, vec3_t origin);\n//returns the best reachable area the entity is situated in\nint AAS_BestReachableEntityArea(int entnum);\n//returns the info of the given entity\nvoid AAS_EntityInfo(int entnum, aas_entityinfo_t *info);\n//returns the next entity\nint AAS_NextEntity(int entnum);\n//returns the origin of the entity\nvoid AAS_EntityOrigin(int entnum, vec3_t origin);\n//returns the entity type\nint AAS_EntityType(int entnum);\n//returns the model index of the entity\nint AAS_EntityModelindex(int entnum);\n\n"
  },
  {
    "path": "code/botlib/be_aas_file.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_file.c\n *\n * desc:\t\tAAS file loading/writing\n *\n * $Archive: /MissionPack/code/botlib/be_aas_file.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_memory.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#include \"l_libvar.h\"\n#include \"l_utils.h\"\n#include \"aasfile.h\"\n#include \"../game/botlib.h\"\n#include \"../game/be_aas.h\"\n#include \"be_aas_funcs.h\"\n#include \"be_interface.h\"\n#include \"be_aas_def.h\"\n\n//#define AASFILEDEBUG\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_SwapAASData(void)\n{\n\tint i, j;\n\t//bounding boxes\n\tfor (i = 0; i < aasworld.numbboxes; i++)\n\t{\n\t\taasworld.bboxes[i].presencetype = LittleLong(aasworld.bboxes[i].presencetype);\n\t\taasworld.bboxes[i].flags = LittleLong(aasworld.bboxes[i].flags);\n\t\tfor (j = 0; j < 3; j++)\n\t\t{\n\t\t\taasworld.bboxes[i].mins[j] = LittleLong(aasworld.bboxes[i].mins[j]);\n\t\t\taasworld.bboxes[i].maxs[j] = LittleLong(aasworld.bboxes[i].maxs[j]);\n\t\t} //end for\n\t} //end for\n\t//vertexes\n\tfor (i = 0; i < aasworld.numvertexes; i++)\n\t{\n\t\tfor (j = 0; j < 3; j++)\n\t\t\taasworld.vertexes[i][j] = LittleFloat(aasworld.vertexes[i][j]);\n\t} //end for\n\t//planes\n\tfor (i = 0; i < aasworld.numplanes; i++)\n\t{\n\t\tfor (j = 0; j < 3; j++)\n\t\t\taasworld.planes[i].normal[j] = LittleFloat(aasworld.planes[i].normal[j]);\n\t\taasworld.planes[i].dist = LittleFloat(aasworld.planes[i].dist);\n\t\taasworld.planes[i].type = LittleLong(aasworld.planes[i].type);\n\t} //end for\n\t//edges\n\tfor (i = 0; i < aasworld.numedges; i++)\n\t{\n\t\taasworld.edges[i].v[0] = LittleLong(aasworld.edges[i].v[0]);\n\t\taasworld.edges[i].v[1] = LittleLong(aasworld.edges[i].v[1]);\n\t} //end for\n\t//edgeindex\n\tfor (i = 0; i < aasworld.edgeindexsize; i++)\n\t{\n\t\taasworld.edgeindex[i] = LittleLong(aasworld.edgeindex[i]);\n\t} //end for\n\t//faces\n\tfor (i = 0; i < aasworld.numfaces; i++)\n\t{\n\t\taasworld.faces[i].planenum = LittleLong(aasworld.faces[i].planenum);\n\t\taasworld.faces[i].faceflags = LittleLong(aasworld.faces[i].faceflags);\n\t\taasworld.faces[i].numedges = LittleLong(aasworld.faces[i].numedges);\n\t\taasworld.faces[i].firstedge = LittleLong(aasworld.faces[i].firstedge);\n\t\taasworld.faces[i].frontarea = LittleLong(aasworld.faces[i].frontarea);\n\t\taasworld.faces[i].backarea = LittleLong(aasworld.faces[i].backarea);\n\t} //end for\n\t//face index\n\tfor (i = 0; i < aasworld.faceindexsize; i++)\n\t{\n\t\taasworld.faceindex[i] = LittleLong(aasworld.faceindex[i]);\n\t} //end for\n\t//convex areas\n\tfor (i = 0; i < aasworld.numareas; i++)\n\t{\n\t\taasworld.areas[i].areanum = LittleLong(aasworld.areas[i].areanum);\n\t\taasworld.areas[i].numfaces = LittleLong(aasworld.areas[i].numfaces);\n\t\taasworld.areas[i].firstface = LittleLong(aasworld.areas[i].firstface);\n\t\tfor (j = 0; j < 3; j++)\n\t\t{\n\t\t\taasworld.areas[i].mins[j] = LittleFloat(aasworld.areas[i].mins[j]);\n\t\t\taasworld.areas[i].maxs[j] = LittleFloat(aasworld.areas[i].maxs[j]);\n\t\t\taasworld.areas[i].center[j] = LittleFloat(aasworld.areas[i].center[j]);\n\t\t} //end for\n\t} //end for\n\t//area settings\n\tfor (i = 0; i < aasworld.numareasettings; i++)\n\t{\n\t\taasworld.areasettings[i].contents = LittleLong(aasworld.areasettings[i].contents);\n\t\taasworld.areasettings[i].areaflags = LittleLong(aasworld.areasettings[i].areaflags);\n\t\taasworld.areasettings[i].presencetype = LittleLong(aasworld.areasettings[i].presencetype);\n\t\taasworld.areasettings[i].cluster = LittleLong(aasworld.areasettings[i].cluster);\n\t\taasworld.areasettings[i].clusterareanum = LittleLong(aasworld.areasettings[i].clusterareanum);\n\t\taasworld.areasettings[i].numreachableareas = LittleLong(aasworld.areasettings[i].numreachableareas);\n\t\taasworld.areasettings[i].firstreachablearea = LittleLong(aasworld.areasettings[i].firstreachablearea);\n\t} //end for\n\t//area reachability\n\tfor (i = 0; i < aasworld.reachabilitysize; i++)\n\t{\n\t\taasworld.reachability[i].areanum = LittleLong(aasworld.reachability[i].areanum);\n\t\taasworld.reachability[i].facenum = LittleLong(aasworld.reachability[i].facenum);\n\t\taasworld.reachability[i].edgenum = LittleLong(aasworld.reachability[i].edgenum);\n\t\tfor (j = 0; j < 3; j++)\n\t\t{\n\t\t\taasworld.reachability[i].start[j] = LittleFloat(aasworld.reachability[i].start[j]);\n\t\t\taasworld.reachability[i].end[j] = LittleFloat(aasworld.reachability[i].end[j]);\n\t\t} //end for\n\t\taasworld.reachability[i].traveltype = LittleLong(aasworld.reachability[i].traveltype);\n\t\taasworld.reachability[i].traveltime = LittleShort(aasworld.reachability[i].traveltime);\n\t} //end for\n\t//nodes\n\tfor (i = 0; i < aasworld.numnodes; i++)\n\t{\n\t\taasworld.nodes[i].planenum = LittleLong(aasworld.nodes[i].planenum);\n\t\taasworld.nodes[i].children[0] = LittleLong(aasworld.nodes[i].children[0]);\n\t\taasworld.nodes[i].children[1] = LittleLong(aasworld.nodes[i].children[1]);\n\t} //end for\n\t//cluster portals\n\tfor (i = 0; i < aasworld.numportals; i++)\n\t{\n\t\taasworld.portals[i].areanum = LittleLong(aasworld.portals[i].areanum);\n\t\taasworld.portals[i].frontcluster = LittleLong(aasworld.portals[i].frontcluster);\n\t\taasworld.portals[i].backcluster = LittleLong(aasworld.portals[i].backcluster);\n\t\taasworld.portals[i].clusterareanum[0] = LittleLong(aasworld.portals[i].clusterareanum[0]);\n\t\taasworld.portals[i].clusterareanum[1] = LittleLong(aasworld.portals[i].clusterareanum[1]);\n\t} //end for\n\t//cluster portal index\n\tfor (i = 0; i < aasworld.portalindexsize; i++)\n\t{\n\t\taasworld.portalindex[i] = LittleLong(aasworld.portalindex[i]);\n\t} //end for\n\t//cluster\n\tfor (i = 0; i < aasworld.numclusters; i++)\n\t{\n\t\taasworld.clusters[i].numareas = LittleLong(aasworld.clusters[i].numareas);\n\t\taasworld.clusters[i].numreachabilityareas = LittleLong(aasworld.clusters[i].numreachabilityareas);\n\t\taasworld.clusters[i].numportals = LittleLong(aasworld.clusters[i].numportals);\n\t\taasworld.clusters[i].firstportal = LittleLong(aasworld.clusters[i].firstportal);\n\t} //end for\n} //end of the function AAS_SwapAASData\n//===========================================================================\n// dump the current loaded aas file\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_DumpAASData(void)\n{\n\taasworld.numbboxes = 0;\n\tif (aasworld.bboxes) FreeMemory(aasworld.bboxes);\n\taasworld.bboxes = NULL;\n\taasworld.numvertexes = 0;\n\tif (aasworld.vertexes) FreeMemory(aasworld.vertexes);\n\taasworld.vertexes = NULL;\n\taasworld.numplanes = 0;\n\tif (aasworld.planes) FreeMemory(aasworld.planes);\n\taasworld.planes = NULL;\n\taasworld.numedges = 0;\n\tif (aasworld.edges) FreeMemory(aasworld.edges);\n\taasworld.edges = NULL;\n\taasworld.edgeindexsize = 0;\n\tif (aasworld.edgeindex) FreeMemory(aasworld.edgeindex);\n\taasworld.edgeindex = NULL;\n\taasworld.numfaces = 0;\n\tif (aasworld.faces) FreeMemory(aasworld.faces);\n\taasworld.faces = NULL;\n\taasworld.faceindexsize = 0;\n\tif (aasworld.faceindex) FreeMemory(aasworld.faceindex);\n\taasworld.faceindex = NULL;\n\taasworld.numareas = 0;\n\tif (aasworld.areas) FreeMemory(aasworld.areas);\n\taasworld.areas = NULL;\n\taasworld.numareasettings = 0;\n\tif (aasworld.areasettings) FreeMemory(aasworld.areasettings);\n\taasworld.areasettings = NULL;\n\taasworld.reachabilitysize = 0;\n\tif (aasworld.reachability) FreeMemory(aasworld.reachability);\n\taasworld.reachability = NULL;\n\taasworld.numnodes = 0;\n\tif (aasworld.nodes) FreeMemory(aasworld.nodes);\n\taasworld.nodes = NULL;\n\taasworld.numportals = 0;\n\tif (aasworld.portals) FreeMemory(aasworld.portals);\n\taasworld.portals = NULL;\n\taasworld.numportals = 0;\n\tif (aasworld.portalindex) FreeMemory(aasworld.portalindex);\n\taasworld.portalindex = NULL;\n\taasworld.portalindexsize = 0;\n\tif (aasworld.clusters) FreeMemory(aasworld.clusters);\n\taasworld.clusters = NULL;\n\taasworld.numclusters = 0;\n\t//\n\taasworld.loaded = qfalse;\n\taasworld.initialized = qfalse;\n\taasworld.savefile = qfalse;\n} //end of the function AAS_DumpAASData\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#ifdef AASFILEDEBUG\nvoid AAS_FileInfo(void)\n{\n\tint i, n, optimized;\n\n\tbotimport.Print(PRT_MESSAGE, \"version = %d\\n\", AASVERSION);\n\tbotimport.Print(PRT_MESSAGE, \"numvertexes = %d\\n\", aasworld.numvertexes);\n\tbotimport.Print(PRT_MESSAGE, \"numplanes = %d\\n\", aasworld.numplanes);\n\tbotimport.Print(PRT_MESSAGE, \"numedges = %d\\n\", aasworld.numedges);\n\tbotimport.Print(PRT_MESSAGE, \"edgeindexsize = %d\\n\", aasworld.edgeindexsize);\n\tbotimport.Print(PRT_MESSAGE, \"numfaces = %d\\n\", aasworld.numfaces);\n\tbotimport.Print(PRT_MESSAGE, \"faceindexsize = %d\\n\", aasworld.faceindexsize);\n\tbotimport.Print(PRT_MESSAGE, \"numareas = %d\\n\", aasworld.numareas);\n\tbotimport.Print(PRT_MESSAGE, \"numareasettings = %d\\n\", aasworld.numareasettings);\n\tbotimport.Print(PRT_MESSAGE, \"reachabilitysize = %d\\n\", aasworld.reachabilitysize);\n\tbotimport.Print(PRT_MESSAGE, \"numnodes = %d\\n\", aasworld.numnodes);\n\tbotimport.Print(PRT_MESSAGE, \"numportals = %d\\n\", aasworld.numportals);\n\tbotimport.Print(PRT_MESSAGE, \"portalindexsize = %d\\n\", aasworld.portalindexsize);\n\tbotimport.Print(PRT_MESSAGE, \"numclusters = %d\\n\", aasworld.numclusters);\n\t//\n\tfor (n = 0, i = 0; i < aasworld.numareasettings; i++)\n\t{\n\t\tif (aasworld.areasettings[i].areaflags & AREA_GROUNDED) n++;\n\t} //end for\n\tbotimport.Print(PRT_MESSAGE, \"num grounded areas = %d\\n\", n);\n\t//\n\tbotimport.Print(PRT_MESSAGE, \"planes size %d bytes\\n\", aasworld.numplanes * sizeof(aas_plane_t));\n\tbotimport.Print(PRT_MESSAGE, \"areas size %d bytes\\n\", aasworld.numareas * sizeof(aas_area_t));\n\tbotimport.Print(PRT_MESSAGE, \"areasettings size %d bytes\\n\", aasworld.numareasettings * sizeof(aas_areasettings_t));\n\tbotimport.Print(PRT_MESSAGE, \"nodes size %d bytes\\n\", aasworld.numnodes * sizeof(aas_node_t));\n\tbotimport.Print(PRT_MESSAGE, \"reachability size %d bytes\\n\", aasworld.reachabilitysize * sizeof(aas_reachability_t));\n\tbotimport.Print(PRT_MESSAGE, \"portals size %d bytes\\n\", aasworld.numportals * sizeof(aas_portal_t));\n\tbotimport.Print(PRT_MESSAGE, \"clusters size %d bytes\\n\", aasworld.numclusters * sizeof(aas_cluster_t));\n\n\toptimized = aasworld.numplanes * sizeof(aas_plane_t) +\n\t\t\t\t\taasworld.numareas * sizeof(aas_area_t) +\n\t\t\t\t\taasworld.numareasettings * sizeof(aas_areasettings_t) +\n\t\t\t\t\taasworld.numnodes * sizeof(aas_node_t) +\n\t\t\t\t\taasworld.reachabilitysize * sizeof(aas_reachability_t) +\n\t\t\t\t\taasworld.numportals * sizeof(aas_portal_t) +\n\t\t\t\t\taasworld.numclusters * sizeof(aas_cluster_t);\n\tbotimport.Print(PRT_MESSAGE, \"optimzed size %d KB\\n\", optimized >> 10);\n} //end of the function AAS_FileInfo\n#endif //AASFILEDEBUG\n//===========================================================================\n// allocate memory and read a lump of a AAS file\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nchar *AAS_LoadAASLump(fileHandle_t fp, int offset, int length, int *lastoffset, int size)\n{\n\tchar *buf;\n\t//\n\tif (!length)\n\t{\n\t\t//just alloc a dummy\n\t\treturn (char *) GetClearedHunkMemory(size+1);\n\t} //end if\n\t//seek to the data\n\tif (offset != *lastoffset)\n\t{\n\t\tbotimport.Print(PRT_WARNING, \"AAS file not sequentially read\\n\");\n\t\tif (botimport.FS_Seek(fp, offset, FS_SEEK_SET))\n\t\t{\n\t\t\tAAS_Error(\"can't seek to aas lump\\n\");\n\t\t\tAAS_DumpAASData();\n\t\t\tbotimport.FS_FCloseFile(fp);\n\t\t\treturn 0;\n\t\t} //end if\n\t} //end if\n\t//allocate memory\n\tbuf = (char *) GetClearedHunkMemory(length+1);\n\t//read the data\n\tif (length)\n\t{\n\t\tbotimport.FS_Read(buf, length, fp );\n\t\t*lastoffset += length;\n\t} //end if\n\treturn buf;\n} //end of the function AAS_LoadAASLump\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_DData(unsigned char *data, int size)\n{\n\tint i;\n\n\tfor (i = 0; i < size; i++)\n\t{\n\t\tdata[i] ^= (unsigned char) i * 119;\n\t} //end for\n} //end of the function AAS_DData\n//===========================================================================\n// load an aas file\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_LoadAASFile(char *filename)\n{\n\tfileHandle_t fp;\n\taas_header_t header;\n\tint offset, length, lastoffset;\n\n\tbotimport.Print(PRT_MESSAGE, \"trying to load %s\\n\", filename);\n\t//dump current loaded aas file\n\tAAS_DumpAASData();\n\t//open the file\n\tbotimport.FS_FOpenFile( filename, &fp, FS_READ );\n\tif (!fp)\n\t{\n\t\tAAS_Error(\"can't open %s\\n\", filename);\n\t\treturn BLERR_CANNOTOPENAASFILE;\n\t} //end if\n\t//read the header\n\tbotimport.FS_Read(&header, sizeof(aas_header_t), fp );\n\tlastoffset = sizeof(aas_header_t);\n\t//check header identification\n\theader.ident = LittleLong(header.ident);\n\tif (header.ident != AASID)\n\t{\n\t\tAAS_Error(\"%s is not an AAS file\\n\", filename);\n\t\tbotimport.FS_FCloseFile(fp);\n\t\treturn BLERR_WRONGAASFILEID;\n\t} //end if\n\t//check the version\n\theader.version = LittleLong(header.version);\n\t//\n\tif (header.version != AASVERSION_OLD && header.version != AASVERSION)\n\t{\n\t\tAAS_Error(\"aas file %s is version %i, not %i\\n\", filename, header.version, AASVERSION);\n\t\tbotimport.FS_FCloseFile(fp);\n\t\treturn BLERR_WRONGAASFILEVERSION;\n\t} //end if\n\t//\n\tif (header.version == AASVERSION)\n\t{\n\t\tAAS_DData((unsigned char *) &header + 8, sizeof(aas_header_t) - 8);\n\t} //end if\n\t//\n\taasworld.bspchecksum = atoi(LibVarGetString( \"sv_mapChecksum\"));\n\tif (LittleLong(header.bspchecksum) != aasworld.bspchecksum)\n\t{\n\t\tAAS_Error(\"aas file %s is out of date\\n\", filename);\n\t\tbotimport.FS_FCloseFile(fp);\n\t\treturn BLERR_WRONGAASFILEVERSION;\n\t} //end if\n\t//load the lumps:\n\t//bounding boxes\n\toffset = LittleLong(header.lumps[AASLUMP_BBOXES].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_BBOXES].filelen);\n\taasworld.bboxes = (aas_bbox_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_bbox_t));\n\taasworld.numbboxes = length / sizeof(aas_bbox_t);\n\tif (aasworld.numbboxes && !aasworld.bboxes) return BLERR_CANNOTREADAASLUMP;\n\t//vertexes\n\toffset = LittleLong(header.lumps[AASLUMP_VERTEXES].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_VERTEXES].filelen);\n\taasworld.vertexes = (aas_vertex_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_vertex_t));\n\taasworld.numvertexes = length / sizeof(aas_vertex_t);\n\tif (aasworld.numvertexes && !aasworld.vertexes) return BLERR_CANNOTREADAASLUMP;\n\t//planes\n\toffset = LittleLong(header.lumps[AASLUMP_PLANES].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_PLANES].filelen);\n\taasworld.planes = (aas_plane_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_plane_t));\n\taasworld.numplanes = length / sizeof(aas_plane_t);\n\tif (aasworld.numplanes && !aasworld.planes) return BLERR_CANNOTREADAASLUMP;\n\t//edges\n\toffset = LittleLong(header.lumps[AASLUMP_EDGES].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_EDGES].filelen);\n\taasworld.edges = (aas_edge_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_edge_t));\n\taasworld.numedges = length / sizeof(aas_edge_t);\n\tif (aasworld.numedges && !aasworld.edges) return BLERR_CANNOTREADAASLUMP;\n\t//edgeindex\n\toffset = LittleLong(header.lumps[AASLUMP_EDGEINDEX].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_EDGEINDEX].filelen);\n\taasworld.edgeindex = (aas_edgeindex_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_edgeindex_t));\n\taasworld.edgeindexsize = length / sizeof(aas_edgeindex_t);\n\tif (aasworld.edgeindexsize && !aasworld.edgeindex) return BLERR_CANNOTREADAASLUMP;\n\t//faces\n\toffset = LittleLong(header.lumps[AASLUMP_FACES].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_FACES].filelen);\n\taasworld.faces = (aas_face_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_face_t));\n\taasworld.numfaces = length / sizeof(aas_face_t);\n\tif (aasworld.numfaces && !aasworld.faces) return BLERR_CANNOTREADAASLUMP;\n\t//faceindex\n\toffset = LittleLong(header.lumps[AASLUMP_FACEINDEX].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_FACEINDEX].filelen);\n\taasworld.faceindex = (aas_faceindex_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_faceindex_t));\n\taasworld.faceindexsize = length / sizeof(aas_faceindex_t);\n\tif (aasworld.faceindexsize && !aasworld.faceindex) return BLERR_CANNOTREADAASLUMP;\n\t//convex areas\n\toffset = LittleLong(header.lumps[AASLUMP_AREAS].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_AREAS].filelen);\n\taasworld.areas = (aas_area_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_area_t));\n\taasworld.numareas = length / sizeof(aas_area_t);\n\tif (aasworld.numareas && !aasworld.areas) return BLERR_CANNOTREADAASLUMP;\n\t//area settings\n\toffset = LittleLong(header.lumps[AASLUMP_AREASETTINGS].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_AREASETTINGS].filelen);\n\taasworld.areasettings = (aas_areasettings_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_areasettings_t));\n\taasworld.numareasettings = length / sizeof(aas_areasettings_t);\n\tif (aasworld.numareasettings && !aasworld.areasettings) return BLERR_CANNOTREADAASLUMP;\n\t//reachability list\n\toffset = LittleLong(header.lumps[AASLUMP_REACHABILITY].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_REACHABILITY].filelen);\n\taasworld.reachability = (aas_reachability_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_reachability_t));\n\taasworld.reachabilitysize = length / sizeof(aas_reachability_t);\n\tif (aasworld.reachabilitysize && !aasworld.reachability) return BLERR_CANNOTREADAASLUMP;\n\t//nodes\n\toffset = LittleLong(header.lumps[AASLUMP_NODES].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_NODES].filelen);\n\taasworld.nodes = (aas_node_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_node_t));\n\taasworld.numnodes = length / sizeof(aas_node_t);\n\tif (aasworld.numnodes && !aasworld.nodes) return BLERR_CANNOTREADAASLUMP;\n\t//cluster portals\n\toffset = LittleLong(header.lumps[AASLUMP_PORTALS].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_PORTALS].filelen);\n\taasworld.portals = (aas_portal_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_portal_t));\n\taasworld.numportals = length / sizeof(aas_portal_t);\n\tif (aasworld.numportals && !aasworld.portals) return BLERR_CANNOTREADAASLUMP;\n\t//cluster portal index\n\toffset = LittleLong(header.lumps[AASLUMP_PORTALINDEX].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_PORTALINDEX].filelen);\n\taasworld.portalindex = (aas_portalindex_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_portalindex_t));\n\taasworld.portalindexsize = length / sizeof(aas_portalindex_t);\n\tif (aasworld.portalindexsize && !aasworld.portalindex) return BLERR_CANNOTREADAASLUMP;\n\t//clusters\n\toffset = LittleLong(header.lumps[AASLUMP_CLUSTERS].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_CLUSTERS].filelen);\n\taasworld.clusters = (aas_cluster_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_cluster_t));\n\taasworld.numclusters = length / sizeof(aas_cluster_t);\n\tif (aasworld.numclusters && !aasworld.clusters) return BLERR_CANNOTREADAASLUMP;\n\t//swap everything\n\tAAS_SwapAASData();\n\t//aas file is loaded\n\taasworld.loaded = qtrue;\n\t//close the file\n\tbotimport.FS_FCloseFile(fp);\n\t//\n#ifdef AASFILEDEBUG\n\tAAS_FileInfo();\n#endif //AASFILEDEBUG\n\t//\n\treturn BLERR_NOERROR;\n} //end of the function AAS_LoadAASFile\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nstatic int AAS_WriteAASLump_offset;\n\nint AAS_WriteAASLump(fileHandle_t fp, aas_header_t *h, int lumpnum, void *data, int length)\n{\n\taas_lump_t *lump;\n\n\tlump = &h->lumps[lumpnum];\n\t\n\tlump->fileofs = LittleLong(AAS_WriteAASLump_offset);\t//LittleLong(ftell(fp));\n\tlump->filelen = LittleLong(length);\n\n\tif (length > 0)\n\t{\n\t\tbotimport.FS_Write(data, length, fp );\n\t} //end if\n\n\tAAS_WriteAASLump_offset += length;\n\n\treturn qtrue;\n} //end of the function AAS_WriteAASLump\n//===========================================================================\n// aas data is useless after writing to file because it is byte swapped\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_WriteAASFile(char *filename)\n{\n\taas_header_t header;\n\tfileHandle_t fp;\n\n\tbotimport.Print(PRT_MESSAGE, \"writing %s\\n\", filename);\n\t//swap the aas data\n\tAAS_SwapAASData();\n\t//initialize the file header\n\tCom_Memset(&header, 0, sizeof(aas_header_t));\n\theader.ident = LittleLong(AASID);\n\theader.version = LittleLong(AASVERSION);\n\theader.bspchecksum = LittleLong(aasworld.bspchecksum);\n\t//open a new file\n\tbotimport.FS_FOpenFile( filename, &fp, FS_WRITE );\n\tif (!fp)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"error opening %s\\n\", filename);\n\t\treturn qfalse;\n\t} //end if\n\t//write the header\n\tbotimport.FS_Write(&header, sizeof(aas_header_t), fp);\n\tAAS_WriteAASLump_offset = sizeof(aas_header_t);\n\t//add the data lumps to the file\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_BBOXES, aasworld.bboxes,\n\t\taasworld.numbboxes * sizeof(aas_bbox_t))) return qfalse;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_VERTEXES, aasworld.vertexes,\n\t\taasworld.numvertexes * sizeof(aas_vertex_t))) return qfalse;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_PLANES, aasworld.planes,\n\t\taasworld.numplanes * sizeof(aas_plane_t))) return qfalse;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_EDGES, aasworld.edges,\n\t\taasworld.numedges * sizeof(aas_edge_t))) return qfalse;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_EDGEINDEX, aasworld.edgeindex,\n\t\taasworld.edgeindexsize * sizeof(aas_edgeindex_t))) return qfalse;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_FACES, aasworld.faces,\n\t\taasworld.numfaces * sizeof(aas_face_t))) return qfalse;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_FACEINDEX, aasworld.faceindex,\n\t\taasworld.faceindexsize * sizeof(aas_faceindex_t))) return qfalse;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_AREAS, aasworld.areas,\n\t\taasworld.numareas * sizeof(aas_area_t))) return qfalse;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_AREASETTINGS, aasworld.areasettings,\n\t\taasworld.numareasettings * sizeof(aas_areasettings_t))) return qfalse;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_REACHABILITY, aasworld.reachability,\n\t\taasworld.reachabilitysize * sizeof(aas_reachability_t))) return qfalse;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_NODES, aasworld.nodes,\n\t\taasworld.numnodes * sizeof(aas_node_t))) return qfalse;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_PORTALS, aasworld.portals,\n\t\taasworld.numportals * sizeof(aas_portal_t))) return qfalse;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_PORTALINDEX, aasworld.portalindex,\n\t\taasworld.portalindexsize * sizeof(aas_portalindex_t))) return qfalse;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_CLUSTERS, aasworld.clusters,\n\t\taasworld.numclusters * sizeof(aas_cluster_t))) return qfalse;\n\t//rewrite the header with the added lumps\n\tbotimport.FS_Seek(fp, 0, FS_SEEK_SET);\n\tAAS_DData((unsigned char *) &header + 8, sizeof(aas_header_t) - 8);\n\tbotimport.FS_Write(&header, sizeof(aas_header_t), fp);\n\t//close the file\n\tbotimport.FS_FCloseFile(fp);\n\treturn qtrue;\n} //end of the function AAS_WriteAASFile\n"
  },
  {
    "path": "code/botlib/be_aas_file.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_file.h\n *\n * desc:\t\tAAS\n *\n * $Archive: /source/code/botlib/be_aas_file.h $\n *\n *****************************************************************************/\n\n#ifdef AASINTERN\n//loads the AAS file with the given name\nint AAS_LoadAASFile(char *filename);\n//writes an AAS file with the given name\nqboolean AAS_WriteAASFile(char *filename);\n//dumps the loaded AAS data\nvoid AAS_DumpAASData(void);\n//print AAS file information\nvoid AAS_FileInfo(void);\n#endif //AASINTERN\n\n"
  },
  {
    "path": "code/botlib/be_aas_funcs.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_funcs.h\n *\n * desc:\t\tAAS\n *\n * $Archive: /source/code/botlib/be_aas_funcs.h $\n *\n *****************************************************************************/\n\n#ifndef BSPCINCLUDE\n\n#include \"be_aas_main.h\"\n#include \"be_aas_entity.h\"\n#include \"be_aas_sample.h\"\n#include \"be_aas_cluster.h\"\n#include \"be_aas_reach.h\"\n#include \"be_aas_route.h\"\n#include \"be_aas_routealt.h\"\n#include \"be_aas_debug.h\"\n#include \"be_aas_file.h\"\n#include \"be_aas_optimize.h\"\n#include \"be_aas_bsp.h\"\n#include \"be_aas_move.h\"\n\n#endif //BSPCINCLUDE\n"
  },
  {
    "path": "code/botlib/be_aas_main.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_main.c\n *\n * desc:\t\tAAS\n *\n * $Archive: /MissionPack/code/botlib/be_aas_main.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_memory.h\"\n#include \"l_libvar.h\"\n#include \"l_utils.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#include \"l_log.h\"\n#include \"aasfile.h\"\n#include \"../game/botlib.h\"\n#include \"../game/be_aas.h\"\n#include \"be_aas_funcs.h\"\n#include \"be_interface.h\"\n#include \"be_aas_def.h\"\n\naas_t aasworld;\n\nlibvar_t *saveroutingcache;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid QDECL AAS_Error(char *fmt, ...)\n{\n\tchar str[1024];\n\tva_list arglist;\n\n\tva_start(arglist, fmt);\n\tvsprintf(str, fmt, arglist);\n\tva_end(arglist);\n\tbotimport.Print(PRT_FATAL, str);\n} //end of the function AAS_Error\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nchar *AAS_StringFromIndex(char *indexname, char *stringindex[], int numindexes, int index)\n{\n\tif (!aasworld.indexessetup)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"%s: index %d not setup\\n\", indexname, index);\n\t\treturn \"\";\n\t} //end if\n\tif (index < 0 || index >= numindexes)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"%s: index %d out of range\\n\", indexname, index);\n\t\treturn \"\";\n\t} //end if\n\tif (!stringindex[index])\n\t{\n\t\tif (index)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"%s: reference to unused index %d\\n\", indexname, index);\n\t\t} //end if\n\t\treturn \"\";\n\t} //end if\n\treturn stringindex[index];\n} //end of the function AAS_StringFromIndex\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_IndexFromString(char *indexname, char *stringindex[], int numindexes, char *string)\n{\n\tint i;\n\tif (!aasworld.indexessetup)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"%s: index not setup \\\"%s\\\"\\n\", indexname, string);\n\t\treturn 0;\n\t} //end if\n\tfor (i = 0; i < numindexes; i++)\n\t{\n\t\tif (!stringindex[i]) continue;\n\t\tif (!Q_stricmp(stringindex[i], string)) return i;\n\t} //end for\n\treturn 0;\n} //end of the function AAS_IndexFromString\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nchar *AAS_ModelFromIndex(int index)\n{\n\treturn AAS_StringFromIndex(\"ModelFromIndex\", &aasworld.configstrings[CS_MODELS], MAX_MODELS, index);\n} //end of the function AAS_ModelFromIndex\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_IndexFromModel(char *modelname)\n{\n\treturn AAS_IndexFromString(\"IndexFromModel\", &aasworld.configstrings[CS_MODELS], MAX_MODELS, modelname);\n} //end of the function AAS_IndexFromModel\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_UpdateStringIndexes(int numconfigstrings, char *configstrings[])\n{\n\tint i;\n\t//set string pointers and copy the strings\n\tfor (i = 0; i < numconfigstrings; i++)\n\t{\n\t\tif (configstrings[i])\n\t\t{\n\t\t\t//if (aasworld.configstrings[i]) FreeMemory(aasworld.configstrings[i]);\n\t\t\taasworld.configstrings[i] = (char *) GetMemory(strlen(configstrings[i]) + 1);\n\t\t\tstrcpy(aasworld.configstrings[i], configstrings[i]);\n\t\t} //end if\n\t} //end for\n\taasworld.indexessetup = qtrue;\n} //end of the function AAS_UpdateStringIndexes\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_Loaded(void)\n{\n\treturn aasworld.loaded;\n} //end of the function AAS_Loaded\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_Initialized(void)\n{\n\treturn aasworld.initialized;\n} //end of the function AAS_Initialized\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_SetInitialized(void)\n{\n\taasworld.initialized = qtrue;\n\tbotimport.Print(PRT_MESSAGE, \"AAS initialized.\\n\");\n#ifdef DEBUG\n\t//create all the routing cache\n\t//AAS_CreateAllRoutingCache();\n\t//\n\t//AAS_RoutingInfo();\n#endif\n} //end of the function AAS_SetInitialized\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ContinueInit(float time)\n{\n\t//if no AAS file loaded\n\tif (!aasworld.loaded) return;\n\t//if AAS is already initialized\n\tif (aasworld.initialized) return;\n\t//calculate reachability, if not finished return\n\tif (AAS_ContinueInitReachability(time)) return;\n\t//initialize clustering for the new map\n\tAAS_InitClustering();\n\t//if reachability has been calculated and an AAS file should be written\n\t//or there is a forced data optimization\n\tif (aasworld.savefile || ((int)LibVarGetValue(\"forcewrite\")))\n\t{\n\t\t//optimize the AAS data\n\t\tif ((int)LibVarValue(\"aasoptimize\", \"0\")) AAS_Optimize();\n\t\t//save the AAS file\n\t\tif (AAS_WriteAASFile(aasworld.filename))\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"%s written succesfully\\n\", aasworld.filename);\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"couldn't write %s\\n\", aasworld.filename);\n\t\t} //end else\n\t} //end if\n\t//initialize the routing\n\tAAS_InitRouting();\n\t//at this point AAS is initialized\n\tAAS_SetInitialized();\n} //end of the function AAS_ContinueInit\n//===========================================================================\n// called at the start of every frame\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_StartFrame(float time)\n{\n\taasworld.time = time;\n\t//unlink all entities that were not updated last frame\n\tAAS_UnlinkInvalidEntities();\n\t//invalidate the entities\n\tAAS_InvalidateEntities();\n\t//initialize AAS\n\tAAS_ContinueInit(time);\n\t//\n\taasworld.frameroutingupdates = 0;\n\t//\n\tif (bot_developer)\n\t{\n\t\tif (LibVarGetValue(\"showcacheupdates\"))\n\t\t{\n\t\t\tAAS_RoutingInfo();\n\t\t\tLibVarSet(\"showcacheupdates\", \"0\");\n\t\t} //end if\n\t\tif (LibVarGetValue(\"showmemoryusage\"))\n\t\t{\n\t\t\tPrintUsedMemorySize();\n\t\t\tLibVarSet(\"showmemoryusage\", \"0\");\n\t\t} //end if\n\t\tif (LibVarGetValue(\"memorydump\"))\n\t\t{\n\t\t\tPrintMemoryLabels();\n\t\t\tLibVarSet(\"memorydump\", \"0\");\n\t\t} //end if\n\t} //end if\n\t//\n\tif (saveroutingcache->value)\n\t{\n\t\tAAS_WriteRouteCache();\n\t\tLibVarSet(\"saveroutingcache\", \"0\");\n\t} //end if\n\t//\n\taasworld.numframes++;\n\treturn BLERR_NOERROR;\n} //end of the function AAS_StartFrame\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat AAS_Time(void)\n{\n\treturn aasworld.time;\n} //end of the function AAS_Time\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ProjectPointOntoVector( vec3_t point, vec3_t vStart, vec3_t vEnd, vec3_t vProj )\n{\n\tvec3_t pVec, vec;\n\n\tVectorSubtract( point, vStart, pVec );\n\tVectorSubtract( vEnd, vStart, vec );\n\tVectorNormalize( vec );\n\t// project onto the directional vector for this segment\n\tVectorMA( vStart, DotProduct( pVec, vec ), vec, vProj );\n} //end of the function AAS_ProjectPointOntoVector\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_LoadFiles(const char *mapname)\n{\n\tint errnum;\n\tchar aasfile[MAX_PATH];\n//\tchar bspfile[MAX_PATH];\n\n\tstrcpy(aasworld.mapname, mapname);\n\t//NOTE: first reset the entity links into the AAS areas and BSP leaves\n\t// the AAS link heap and BSP link heap are reset after respectively the\n\t// AAS file and BSP file are loaded\n\tAAS_ResetEntityLinks();\n\t// load bsp info\n\tAAS_LoadBSPFile();\n\n\t//load the aas file\n\tCom_sprintf(aasfile, MAX_PATH, \"maps/%s.aas\", mapname);\n\terrnum = AAS_LoadAASFile(aasfile);\n\tif (errnum != BLERR_NOERROR)\n\t\treturn errnum;\n\n\tbotimport.Print(PRT_MESSAGE, \"loaded %s\\n\", aasfile);\n\tstrncpy(aasworld.filename, aasfile, MAX_PATH);\n\treturn BLERR_NOERROR;\n} //end of the function AAS_LoadFiles\n//===========================================================================\n// called everytime a map changes\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_LoadMap(const char *mapname)\n{\n\tint\terrnum;\n\n\t//if no mapname is provided then the string indexes are updated\n\tif (!mapname)\n\t{\n\t\treturn 0;\n\t} //end if\n\t//\n\taasworld.initialized = qfalse;\n\t//NOTE: free the routing caches before loading a new map because\n\t// to free the caches the old number of areas, number of clusters\n\t// and number of areas in a clusters must be available\n\tAAS_FreeRoutingCaches();\n\t//load the map\n\terrnum = AAS_LoadFiles(mapname);\n\tif (errnum != BLERR_NOERROR)\n\t{\n\t\taasworld.loaded = qfalse;\n\t\treturn errnum;\n\t} //end if\n\t//\n\tAAS_InitSettings();\n\t//initialize the AAS link heap for the new map\n\tAAS_InitAASLinkHeap();\n\t//initialize the AAS linked entities for the new map\n\tAAS_InitAASLinkedEntities();\n\t//initialize reachability for the new map\n\tAAS_InitReachability();\n\t//initialize the alternative routing\n\tAAS_InitAlternativeRouting();\n\t//everything went ok\n\treturn 0;\n} //end of the function AAS_LoadMap\n//===========================================================================\n// called when the library is first loaded\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_Setup(void)\n{\n\taasworld.maxclients = (int) LibVarValue(\"maxclients\", \"128\");\n\taasworld.maxentities = (int) LibVarValue(\"maxentities\", \"1024\");\n\t// as soon as it's set to 1 the routing cache will be saved\n\tsaveroutingcache = LibVar(\"saveroutingcache\", \"0\");\n\t//allocate memory for the entities\n\tif (aasworld.entities) FreeMemory(aasworld.entities);\n\taasworld.entities = (aas_entity_t *) GetClearedHunkMemory(aasworld.maxentities * sizeof(aas_entity_t));\n\t//invalidate all the entities\n\tAAS_InvalidateEntities();\n\t//force some recalculations\n\t//LibVarSet(\"forceclustering\", \"1\");\t\t\t//force clustering calculation\n\t//LibVarSet(\"forcereachability\", \"1\");\t\t//force reachability calculation\n\taasworld.numframes = 0;\n\treturn BLERR_NOERROR;\n} //end of the function AAS_Setup\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_Shutdown(void)\n{\n\tAAS_ShutdownAlternativeRouting();\n\t//\n\tAAS_DumpBSPData();\n\t//free routing caches\n\tAAS_FreeRoutingCaches();\n\t//free aas link heap\n\tAAS_FreeAASLinkHeap();\n\t//free aas linked entities\n\tAAS_FreeAASLinkedEntities();\n\t//free the aas data\n\tAAS_DumpAASData();\n\t//free the entities\n\tif (aasworld.entities) FreeMemory(aasworld.entities);\n\t//clear the aasworld structure\n\tCom_Memset(&aasworld, 0, sizeof(aas_t));\n\t//aas has not been initialized\n\taasworld.initialized = qfalse;\n\t//NOTE: as soon as a new .bsp file is loaded the .bsp file memory is\n\t// freed an reallocated, so there's no need to free that memory here\n\t//print shutdown\n\tbotimport.Print(PRT_MESSAGE, \"AAS shutdown.\\n\");\n} //end of the function AAS_Shutdown\n"
  },
  {
    "path": "code/botlib/be_aas_main.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_main.h\n *\n * desc:\t\tAAS\n *\n * $Archive: /source/code/botlib/be_aas_main.h $\n *\n *****************************************************************************/\n\n#ifdef AASINTERN\n\nextern aas_t aasworld;\n\n//AAS error message\nvoid QDECL AAS_Error(char *fmt, ...);\n//set AAS initialized\nvoid AAS_SetInitialized(void);\n//setup AAS with the given number of entities and clients\nint AAS_Setup(void);\n//shutdown AAS\nvoid AAS_Shutdown(void);\n//start a new map\nint AAS_LoadMap(const char *mapname);\n//start a new time frame\nint AAS_StartFrame(float time);\n#endif //AASINTERN\n\n//returns true if AAS is initialized\nint AAS_Initialized(void);\n//returns true if the AAS file is loaded\nint AAS_Loaded(void);\n//returns the model name from the given index\nchar *AAS_ModelFromIndex(int index);\n//returns the index from the given model name\nint AAS_IndexFromModel(char *modelname);\n//returns the current time\nfloat AAS_Time(void);\n//\nvoid AAS_ProjectPointOntoVector( vec3_t point, vec3_t vStart, vec3_t vEnd, vec3_t vProj );\n"
  },
  {
    "path": "code/botlib/be_aas_move.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_move.c\n *\n * desc:\t\tAAS\n *\n * $Archive: /MissionPack/code/botlib/be_aas_move.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_memory.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#include \"l_libvar.h\"\n#include \"aasfile.h\"\n#include \"../game/botlib.h\"\n#include \"../game/be_aas.h\"\n#include \"be_aas_funcs.h\"\n#include \"be_aas_def.h\"\n\nextern botlib_import_t botimport;\n\naas_settings_t aassettings;\n\n//#define AAS_MOVE_DEBUG\n\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_DropToFloor(vec3_t origin, vec3_t mins, vec3_t maxs)\n{\n\tvec3_t end;\n\tbsp_trace_t trace;\n\n\tVectorCopy(origin, end);\n\tend[2] -= 100;\n\ttrace = AAS_Trace(origin, mins, maxs, end, 0, CONTENTS_SOLID);\n\tif (trace.startsolid) return qfalse;\n\tVectorCopy(trace.endpos, origin);\n\treturn qtrue;\n} //end of the function AAS_DropToFloor\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_InitSettings(void)\n{\n\taassettings.phys_gravitydirection[0]\t= 0;\n\taassettings.phys_gravitydirection[1]\t= 0;\n\taassettings.phys_gravitydirection[2]\t= -1;\n\taassettings.phys_friction\t\t\t\t= LibVarValue(\"phys_friction\", \"6\");\n\taassettings.phys_stopspeed\t\t\t\t= LibVarValue(\"phys_stopspeed\", \"100\");\n\taassettings.phys_gravity\t\t\t\t= LibVarValue(\"phys_gravity\", \"800\");\n\taassettings.phys_waterfriction\t\t\t= LibVarValue(\"phys_waterfriction\", \"1\");\n\taassettings.phys_watergravity\t\t\t= LibVarValue(\"phys_watergravity\", \"400\");\n\taassettings.phys_maxvelocity\t\t\t= LibVarValue(\"phys_maxvelocity\", \"320\");\n\taassettings.phys_maxwalkvelocity\t\t= LibVarValue(\"phys_maxwalkvelocity\", \"320\");\n\taassettings.phys_maxcrouchvelocity\t\t= LibVarValue(\"phys_maxcrouchvelocity\", \"100\");\n\taassettings.phys_maxswimvelocity\t\t= LibVarValue(\"phys_maxswimvelocity\", \"150\");\n\taassettings.phys_walkaccelerate\t\t\t= LibVarValue(\"phys_walkaccelerate\", \"10\");\n\taassettings.phys_airaccelerate\t\t\t= LibVarValue(\"phys_airaccelerate\", \"1\");\n\taassettings.phys_swimaccelerate\t\t\t= LibVarValue(\"phys_swimaccelerate\", \"4\");\n\taassettings.phys_maxstep\t\t\t\t= LibVarValue(\"phys_maxstep\", \"19\");\n\taassettings.phys_maxsteepness\t\t\t= LibVarValue(\"phys_maxsteepness\", \"0.7\");\n\taassettings.phys_maxwaterjump\t\t\t= LibVarValue(\"phys_maxwaterjump\", \"18\");\n\taassettings.phys_maxbarrier\t\t\t\t= LibVarValue(\"phys_maxbarrier\", \"33\");\n\taassettings.phys_jumpvel\t\t\t\t= LibVarValue(\"phys_jumpvel\", \"270\");\n\taassettings.phys_falldelta5\t\t\t\t= LibVarValue(\"phys_falldelta5\", \"40\");\n\taassettings.phys_falldelta10\t\t\t= LibVarValue(\"phys_falldelta10\", \"60\");\n\taassettings.rs_waterjump\t\t\t\t= LibVarValue(\"rs_waterjump\", \"400\");\n\taassettings.rs_teleport\t\t\t\t\t= LibVarValue(\"rs_teleport\", \"50\");\n\taassettings.rs_barrierjump\t\t\t\t= LibVarValue(\"rs_barrierjump\", \"100\");\n\taassettings.rs_startcrouch\t\t\t\t= LibVarValue(\"rs_startcrouch\", \"300\");\n\taassettings.rs_startgrapple\t\t\t\t= LibVarValue(\"rs_startgrapple\", \"500\");\n\taassettings.rs_startwalkoffledge\t\t= LibVarValue(\"rs_startwalkoffledge\", \"70\");\n\taassettings.rs_startjump\t\t\t\t= LibVarValue(\"rs_startjump\", \"300\");\n\taassettings.rs_rocketjump\t\t\t\t= LibVarValue(\"rs_rocketjump\", \"500\");\n\taassettings.rs_bfgjump\t\t\t\t\t= LibVarValue(\"rs_bfgjump\", \"500\");\n\taassettings.rs_jumppad\t\t\t\t\t= LibVarValue(\"rs_jumppad\", \"250\");\n\taassettings.rs_aircontrolledjumppad\t\t= LibVarValue(\"rs_aircontrolledjumppad\", \"300\");\n\taassettings.rs_funcbob\t\t\t\t\t= LibVarValue(\"rs_funcbob\", \"300\");\n\taassettings.rs_startelevator\t\t\t= LibVarValue(\"rs_startelevator\", \"50\");\n\taassettings.rs_falldamage5\t\t\t\t= LibVarValue(\"rs_falldamage5\", \"300\");\n\taassettings.rs_falldamage10\t\t\t\t= LibVarValue(\"rs_falldamage10\", \"500\");\n\taassettings.rs_maxfallheight\t\t\t= LibVarValue(\"rs_maxfallheight\", \"0\");\n\taassettings.rs_maxjumpfallheight\t\t= LibVarValue(\"rs_maxjumpfallheight\", \"450\");\n} //end of the function AAS_InitSettings\n//===========================================================================\n// returns qtrue if the bot is against a ladder\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AgainstLadder(vec3_t origin)\n{\n\tint areanum, i, facenum, side;\n\tvec3_t org;\n\taas_plane_t *plane;\n\taas_face_t *face;\n\taas_area_t *area;\n\n\tVectorCopy(origin, org);\n\tareanum = AAS_PointAreaNum(org);\n\tif (!areanum)\n\t{\n\t\torg[0] += 1;\n\t\tareanum = AAS_PointAreaNum(org);\n\t\tif (!areanum)\n\t\t{\n\t\t\torg[1] += 1;\n\t\t\tareanum = AAS_PointAreaNum(org);\n\t\t\tif (!areanum)\n\t\t\t{\n\t\t\t\torg[0] -= 2;\n\t\t\t\tareanum = AAS_PointAreaNum(org);\n\t\t\t\tif (!areanum)\n\t\t\t\t{\n\t\t\t\t\torg[1] -= 2;\n\t\t\t\t\tareanum = AAS_PointAreaNum(org);\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end if\n\t} //end if\n\t//if in solid... wrrr shouldn't happen\n\tif (!areanum) return qfalse;\n\t//if not in a ladder area\n\tif (!(aasworld.areasettings[areanum].areaflags & AREA_LADDER)) return qfalse;\n\t//if a crouch only area\n\tif (!(aasworld.areasettings[areanum].presencetype & PRESENCE_NORMAL)) return qfalse;\n\t//\n\tarea = &aasworld.areas[areanum];\n\tfor (i = 0; i < area->numfaces; i++)\n\t{\n\t\tfacenum = aasworld.faceindex[area->firstface + i];\n\t\tside = facenum < 0;\n\t\tface = &aasworld.faces[abs(facenum)];\n\t\t//if the face isn't a ladder face\n\t\tif (!(face->faceflags & FACE_LADDER)) continue;\n\t\t//get the plane the face is in\n\t\tplane = &aasworld.planes[face->planenum ^ side];\n\t\t//if the origin is pretty close to the plane\n\t\tif (abs(DotProduct(plane->normal, origin) - plane->dist) < 3)\n\t\t{\n\t\t\tif (AAS_PointInsideFace(abs(facenum), origin, 0.1f)) return qtrue;\n\t\t} //end if\n\t} //end for\n\treturn qfalse;\n} //end of the function AAS_AgainstLadder\n//===========================================================================\n// returns qtrue if the bot is on the ground\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_OnGround(vec3_t origin, int presencetype, int passent)\n{\n\taas_trace_t trace;\n\tvec3_t end, up = {0, 0, 1};\n\taas_plane_t *plane;\n\n\tVectorCopy(origin, end);\n\tend[2] -= 10;\n\n\ttrace = AAS_TraceClientBBox(origin, end, presencetype, passent);\n\n\t//if in solid\n\tif (trace.startsolid) return qfalse;\n\t//if nothing hit at all\n\tif (trace.fraction >= 1.0) return qfalse;\n\t//if too far from the hit plane\n\tif (origin[2] - trace.endpos[2] > 10) return qfalse;\n\t//check if the plane isn't too steep\n\tplane = AAS_PlaneFromNum(trace.planenum);\n\tif (DotProduct(plane->normal, up) < aassettings.phys_maxsteepness) return qfalse;\n\t//the bot is on the ground\n\treturn qtrue;\n} //end of the function AAS_OnGround\n//===========================================================================\n// returns qtrue if a bot at the given position is swimming\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_Swimming(vec3_t origin)\n{\n\tvec3_t testorg;\n\n\tVectorCopy(origin, testorg);\n\ttestorg[2] -= 2;\n\tif (AAS_PointContents(testorg) & (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER)) return qtrue;\n\treturn qfalse;\n} //end of the function AAS_Swimming\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nstatic vec3_t VEC_UP\t\t\t= {0, -1,  0};\nstatic vec3_t MOVEDIR_UP\t\t= {0,  0,  1};\nstatic vec3_t VEC_DOWN\t\t= {0, -2,  0};\nstatic vec3_t MOVEDIR_DOWN\t= {0,  0, -1};\n\nvoid AAS_SetMovedir(vec3_t angles, vec3_t movedir)\n{\n\tif (VectorCompare(angles, VEC_UP))\n\t{\n\t\tVectorCopy(MOVEDIR_UP, movedir);\n\t} //end if\n\telse if (VectorCompare(angles, VEC_DOWN))\n\t{\n\t\tVectorCopy(MOVEDIR_DOWN, movedir);\n\t} //end else if\n\telse\n\t{\n\t\tAngleVectors(angles, movedir, NULL, NULL);\n\t} //end else\n} //end of the function AAS_SetMovedir\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_JumpReachRunStart(aas_reachability_t *reach, vec3_t runstart)\n{\n\tvec3_t hordir, start, cmdmove;\n\taas_clientmove_t move;\n\n\t//\n\thordir[0] = reach->start[0] - reach->end[0];\n\thordir[1] = reach->start[1] - reach->end[1];\n\thordir[2] = 0;\n\tVectorNormalize(hordir);\n\t//start point\n\tVectorCopy(reach->start, start);\n\tstart[2] += 1;\n\t//get command movement\n\tVectorScale(hordir, 400, cmdmove);\n\t//\n\tAAS_PredictClientMovement(&move, -1, start, PRESENCE_NORMAL, qtrue,\n\t\t\t\t\t\t\t\tvec3_origin, cmdmove, 1, 2, 0.1f,\n\t\t\t\t\t\t\t\tSE_ENTERWATER|SE_ENTERSLIME|SE_ENTERLAVA|\n\t\t\t\t\t\t\t\tSE_HITGROUNDDAMAGE|SE_GAP, 0, qfalse);\n\tVectorCopy(move.endpos, runstart);\n\t//don't enter slime or lava and don't fall from too high\n\tif (move.stopevent & (SE_ENTERSLIME|SE_ENTERLAVA|SE_HITGROUNDDAMAGE))\n\t{\n\t\tVectorCopy(start, runstart);\n\t} //end if\n} //end of the function AAS_JumpReachRunStart\n//===========================================================================\n// returns the Z velocity when rocket jumping at the origin\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat AAS_WeaponJumpZVelocity(vec3_t origin, float radiusdamage)\n{\n\tvec3_t kvel, v, start, end, forward, right, viewangles, dir;\n\tfloat\tmass, knockback, points;\n\tvec3_t rocketoffset = {8, 8, -8};\n\tvec3_t botmins = {-16, -16, -24};\n\tvec3_t botmaxs = {16, 16, 32};\n\tbsp_trace_t bsptrace;\n\n\t//look down (90 degrees)\n\tviewangles[PITCH] = 90;\n\tviewangles[YAW] = 0;\n\tviewangles[ROLL] = 0;\n\t//get the start point shooting from\n\tVectorCopy(origin, start);\n\tstart[2] += 8; //view offset Z\n\tAngleVectors(viewangles, forward, right, NULL);\n\tstart[0] += forward[0] * rocketoffset[0] + right[0] * rocketoffset[1];\n\tstart[1] += forward[1] * rocketoffset[0] + right[1] * rocketoffset[1];\n\tstart[2] += forward[2] * rocketoffset[0] + right[2] * rocketoffset[1] + rocketoffset[2];\n\t//end point of the trace\n\tVectorMA(start, 500, forward, end);\n\t//trace a line to get the impact point\n\tbsptrace = AAS_Trace(start, NULL, NULL, end, 1, CONTENTS_SOLID);\n\t//calculate the damage the bot will get from the rocket impact\n\tVectorAdd(botmins, botmaxs, v);\n\tVectorMA(origin, 0.5, v, v);\n\tVectorSubtract(bsptrace.endpos, v, v);\n\t//\n\tpoints = radiusdamage - 0.5 * VectorLength(v);\n\tif (points < 0) points = 0;\n\t//the owner of the rocket gets half the damage\n\tpoints *= 0.5;\n\t//mass of the bot (p_client.c: PutClientInServer)\n\tmass = 200;\n\t//knockback is the same as the damage points\n\tknockback = points;\n\t//direction of the damage (from trace.endpos to bot origin)\n\tVectorSubtract(origin, bsptrace.endpos, dir);\n\tVectorNormalize(dir);\n\t//damage velocity\n\tVectorScale(dir, 1600.0 * (float)knockback / mass, kvel);\t//the rocket jump hack...\n\t//rocket impact velocity + jump velocity\n\treturn kvel[2] + aassettings.phys_jumpvel;\n} //end of the function AAS_WeaponJumpZVelocity\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat AAS_RocketJumpZVelocity(vec3_t origin)\n{\n\t//rocket radius damage is 120 (p_weapon.c: Weapon_RocketLauncher_Fire)\n\treturn AAS_WeaponJumpZVelocity(origin, 120);\n} //end of the function AAS_RocketJumpZVelocity\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat AAS_BFGJumpZVelocity(vec3_t origin)\n{\n\t//bfg radius damage is 1000 (p_weapon.c: weapon_bfg_fire)\n\treturn AAS_WeaponJumpZVelocity(origin, 120);\n} //end of the function AAS_BFGJumpZVelocity\n//===========================================================================\n// applies ground friction to the given velocity\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_Accelerate(vec3_t velocity, float frametime, vec3_t wishdir, float wishspeed, float accel)\n{\n\t// q2 style\n\tint\t\t\ti;\n\tfloat\t\taddspeed, accelspeed, currentspeed;\n\n\tcurrentspeed = DotProduct(velocity, wishdir);\n\taddspeed = wishspeed - currentspeed;\n\tif (addspeed <= 0) {\n\t\treturn;\n\t}\n\taccelspeed = accel*frametime*wishspeed;\n\tif (accelspeed > addspeed) {\n\t\taccelspeed = addspeed;\n\t}\n\t\n\tfor (i=0 ; i<3 ; i++) {\n\t\tvelocity[i] += accelspeed*wishdir[i];\t\n\t}\n} //end of the function AAS_Accelerate\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_AirControl(vec3_t start, vec3_t end, vec3_t velocity, vec3_t cmdmove)\n{\n\tvec3_t dir;\n\n\tVectorSubtract(end, start, dir);\n} //end of the function AAS_AirControl\n//===========================================================================\n// applies ground friction to the given velocity\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ApplyFriction(vec3_t vel, float friction, float stopspeed,\n\t\t\t\t\t\t\t\t\t\t\t\t\tfloat frametime)\n{\n\tfloat speed, control, newspeed;\n\n\t//horizontal speed\n\tspeed = sqrt(vel[0] * vel[0] + vel[1] * vel[1]);\n\tif (speed)\n\t{\n\t\tcontrol = speed < stopspeed ? stopspeed : speed;\n\t\tnewspeed = speed - frametime * control * friction;\n\t\tif (newspeed < 0) newspeed = 0;\n\t\tnewspeed /= speed;\n\t\tvel[0] *= newspeed;\n\t\tvel[1] *= newspeed;\n\t} //end if\n} //end of the function AAS_ApplyFriction\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_ClipToBBox(aas_trace_t *trace, vec3_t start, vec3_t end, int presencetype, vec3_t mins, vec3_t maxs)\n{\n\tint i, j, side;\n\tfloat front, back, frac, planedist;\n\tvec3_t bboxmins, bboxmaxs, absmins, absmaxs, dir, mid;\n\n\tAAS_PresenceTypeBoundingBox(presencetype, bboxmins, bboxmaxs);\n\tVectorSubtract(mins, bboxmaxs, absmins);\n\tVectorSubtract(maxs, bboxmins, absmaxs);\n\t//\n\tVectorCopy(end, trace->endpos);\n\ttrace->fraction = 1;\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tif (start[i] < absmins[i] && end[i] < absmins[i]) return qfalse;\n\t\tif (start[i] > absmaxs[i] && end[i] > absmaxs[i]) return qfalse;\n\t} //end for\n\t//check bounding box collision\n\tVectorSubtract(end, start, dir);\n\tfrac = 1;\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\t//get plane to test collision with for the current axis direction\n\t\tif (dir[i] > 0) planedist = absmins[i];\n\t\telse planedist = absmaxs[i];\n\t\t//calculate collision fraction\n\t\tfront = start[i] - planedist;\n\t\tback = end[i] - planedist;\n\t\tfrac = front / (front-back);\n\t\t//check if between bounding planes of next axis\n\t\tside = i + 1;\n\t\tif (side > 2) side = 0;\n\t\tmid[side] = start[side] + dir[side] * frac;\n\t\tif (mid[side] > absmins[side] && mid[side] < absmaxs[side])\n\t\t{\n\t\t\t//check if between bounding planes of next axis\n\t\t\tside++;\n\t\t\tif (side > 2) side = 0;\n\t\t\tmid[side] = start[side] + dir[side] * frac;\n\t\t\tif (mid[side] > absmins[side] && mid[side] < absmaxs[side])\n\t\t\t{\n\t\t\t\tmid[i] = planedist;\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n\t//if there was a collision\n\tif (i != 3)\n\t{\n\t\ttrace->startsolid = qfalse;\n\t\ttrace->fraction = frac;\n\t\ttrace->ent = 0;\n\t\ttrace->planenum = 0;\n\t\ttrace->area = 0;\n\t\ttrace->lastarea = 0;\n\t\t//trace endpos\n\t\tfor (j = 0; j < 3; j++) trace->endpos[j] = start[j] + dir[j] * frac;\n\t\treturn qtrue;\n\t} //end if\n\treturn qfalse;\n} //end of the function AAS_ClipToBBox\n//===========================================================================\n// predicts the movement\n// assumes regular bounding box sizes\n// NOTE: out of water jumping is not included\n// NOTE: grappling hook is not included\n//\n// Parameter:\t\t\torigin\t\t\t: origin to start with\n//\t\t\t\t\t\tpresencetype\t: presence type to start with\n//\t\t\t\t\t\tvelocity\t\t: velocity to start with\n//\t\t\t\t\t\tcmdmove\t\t\t: client command movement\n//\t\t\t\t\t\tcmdframes\t\t: number of frame cmdmove is valid\n//\t\t\t\t\t\tmaxframes\t\t: maximum number of predicted frames\n//\t\t\t\t\t\tframetime\t\t: duration of one predicted frame\n//\t\t\t\t\t\tstopevent\t\t: events that stop the prediction\n//\t\t\t\t\t\tstopareanum\t\t: stop as soon as entered this area\n// Returns:\t\t\t\taas_clientmove_t\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_ClientMovementPrediction(struct aas_clientmove_s *move,\n\t\t\t\t\t\t\t\tint entnum, vec3_t origin,\n\t\t\t\t\t\t\t\tint presencetype, int onground,\n\t\t\t\t\t\t\t\tvec3_t velocity, vec3_t cmdmove,\n\t\t\t\t\t\t\t\tint cmdframes,\n\t\t\t\t\t\t\t\tint maxframes, float frametime,\n\t\t\t\t\t\t\t\tint stopevent, int stopareanum,\n\t\t\t\t\t\t\t\tvec3_t mins, vec3_t maxs, int visualize)\n{\n\tfloat phys_friction, phys_stopspeed, phys_gravity, phys_waterfriction;\n\tfloat phys_watergravity;\n\tfloat phys_walkaccelerate, phys_airaccelerate, phys_swimaccelerate;\n\tfloat phys_maxwalkvelocity, phys_maxcrouchvelocity, phys_maxswimvelocity;\n\tfloat phys_maxstep, phys_maxsteepness, phys_jumpvel, friction;\n\tfloat gravity, delta, maxvel, wishspeed, accelerate;\n\t//float velchange, newvel;\n\tint n, i, j, pc, step, swimming, ax, crouch, event, jump_frame, areanum;\n\tint areas[20], numareas;\n\tvec3_t points[20];\n\tvec3_t org, end, feet, start, stepend, lastorg, wishdir;\n\tvec3_t frame_test_vel, old_frame_test_vel, left_test_vel;\n\tvec3_t up = {0, 0, 1};\n\taas_plane_t *plane, *plane2;\n\taas_trace_t trace, steptrace;\n\t\n\tif (frametime <= 0) frametime = 0.1f;\n\t//\n\tphys_friction = aassettings.phys_friction;\n\tphys_stopspeed = aassettings.phys_stopspeed;\n\tphys_gravity = aassettings.phys_gravity;\n\tphys_waterfriction = aassettings.phys_waterfriction;\n\tphys_watergravity = aassettings.phys_watergravity;\n\tphys_maxwalkvelocity = aassettings.phys_maxwalkvelocity;// * frametime;\n\tphys_maxcrouchvelocity = aassettings.phys_maxcrouchvelocity;// * frametime;\n\tphys_maxswimvelocity = aassettings.phys_maxswimvelocity;// * frametime;\n\tphys_walkaccelerate = aassettings.phys_walkaccelerate;\n\tphys_airaccelerate = aassettings.phys_airaccelerate;\n\tphys_swimaccelerate = aassettings.phys_swimaccelerate;\n\tphys_maxstep = aassettings.phys_maxstep;\n\tphys_maxsteepness = aassettings.phys_maxsteepness;\n\tphys_jumpvel = aassettings.phys_jumpvel * frametime;\n\t//\n\tCom_Memset(move, 0, sizeof(aas_clientmove_t));\n\tCom_Memset(&trace, 0, sizeof(aas_trace_t));\n\t//start at the current origin\n\tVectorCopy(origin, org);\n\torg[2] += 0.25;\n\t//velocity to test for the first frame\n\tVectorScale(velocity, frametime, frame_test_vel);\n\t//\n\tjump_frame = -1;\n\t//predict a maximum of 'maxframes' ahead\n\tfor (n = 0; n < maxframes; n++)\n\t{\n\t\tswimming = AAS_Swimming(org);\n\t\t//get gravity depending on swimming or not\n\t\tgravity = swimming ? phys_watergravity : phys_gravity;\n\t\t//apply gravity at the START of the frame\n\t\tframe_test_vel[2] = frame_test_vel[2] - (gravity * 0.1 * frametime);\n\t\t//if on the ground or swimming\n\t\tif (onground || swimming)\n\t\t{\n\t\t\tfriction = swimming ? phys_friction : phys_waterfriction;\n\t\t\t//apply friction\n\t\t\tVectorScale(frame_test_vel, 1/frametime, frame_test_vel);\n\t\t\tAAS_ApplyFriction(frame_test_vel, friction, phys_stopspeed, frametime);\n\t\t\tVectorScale(frame_test_vel, frametime, frame_test_vel);\n\t\t} //end if\n\t\tcrouch = qfalse;\n\t\t//apply command movement\n\t\tif (n < cmdframes)\n\t\t{\n\t\t\tax = 0;\n\t\t\tmaxvel = phys_maxwalkvelocity;\n\t\t\taccelerate = phys_airaccelerate;\n\t\t\tVectorCopy(cmdmove, wishdir);\n\t\t\tif (onground)\n\t\t\t{\n\t\t\t\tif (cmdmove[2] < -300)\n\t\t\t\t{\n\t\t\t\t\tcrouch = qtrue;\n\t\t\t\t\tmaxvel = phys_maxcrouchvelocity;\n\t\t\t\t} //end if\n\t\t\t\t//if not swimming and upmove is positive then jump\n\t\t\t\tif (!swimming && cmdmove[2] > 1)\n\t\t\t\t{\n\t\t\t\t\t//jump velocity minus the gravity for one frame + 5 for safety\n\t\t\t\t\tframe_test_vel[2] = phys_jumpvel - (gravity * 0.1 * frametime) + 5;\n\t\t\t\t\tjump_frame = n;\n\t\t\t\t\t//jumping so air accelerate\n\t\t\t\t\taccelerate = phys_airaccelerate;\n\t\t\t\t} //end if\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\taccelerate = phys_walkaccelerate;\n\t\t\t\t} //end else\n\t\t\t\tax = 2;\n\t\t\t} //end if\n\t\t\tif (swimming)\n\t\t\t{\n\t\t\t\tmaxvel = phys_maxswimvelocity;\n\t\t\t\taccelerate = phys_swimaccelerate;\n\t\t\t\tax = 3;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\twishdir[2] = 0;\n\t\t\t} //end else\n\t\t\t//\n\t\t\twishspeed = VectorNormalize(wishdir);\n\t\t\tif (wishspeed > maxvel) wishspeed = maxvel;\n\t\t\tVectorScale(frame_test_vel, 1/frametime, frame_test_vel);\n\t\t\tAAS_Accelerate(frame_test_vel, frametime, wishdir, wishspeed, accelerate);\n\t\t\tVectorScale(frame_test_vel, frametime, frame_test_vel);\n\t\t\t/*\n\t\t\tfor (i = 0; i < ax; i++)\n\t\t\t{\n\t\t\t\tvelchange = (cmdmove[i] * frametime) - frame_test_vel[i];\n\t\t\t\tif (velchange > phys_maxacceleration) velchange = phys_maxacceleration;\n\t\t\t\telse if (velchange < -phys_maxacceleration) velchange = -phys_maxacceleration;\n\t\t\t\tnewvel = frame_test_vel[i] + velchange;\n\t\t\t\t//\n\t\t\t\tif (frame_test_vel[i] <= maxvel && newvel > maxvel) frame_test_vel[i] = maxvel;\n\t\t\t\telse if (frame_test_vel[i] >= -maxvel && newvel < -maxvel) frame_test_vel[i] = -maxvel;\n\t\t\t\telse frame_test_vel[i] = newvel;\n\t\t\t} //end for\n\t\t\t*/\n\t\t} //end if\n\t\tif (crouch)\n\t\t{\n\t\t\tpresencetype = PRESENCE_CROUCH;\n\t\t} //end if\n\t\telse if (presencetype == PRESENCE_CROUCH)\n\t\t{\n\t\t\tif (AAS_PointPresenceType(org) & PRESENCE_NORMAL)\n\t\t\t{\n\t\t\t\tpresencetype = PRESENCE_NORMAL;\n\t\t\t} //end if\n\t\t} //end else\n\t\t//save the current origin\n\t\tVectorCopy(org, lastorg);\n\t\t//move linear during one frame\n\t\tVectorCopy(frame_test_vel, left_test_vel);\n\t\tj = 0;\n\t\tdo\n\t\t{\n\t\t\tVectorAdd(org, left_test_vel, end);\n\t\t\t//trace a bounding box\n\t\t\ttrace = AAS_TraceClientBBox(org, end, presencetype, entnum);\n\t\t\t//\n//#ifdef AAS_MOVE_DEBUG\n\t\t\tif (visualize)\n\t\t\t{\n\t\t\t\tif (trace.startsolid) botimport.Print(PRT_MESSAGE, \"PredictMovement: start solid\\n\");\n\t\t\t\tAAS_DebugLine(org, trace.endpos, LINECOLOR_RED);\n\t\t\t} //end if\n//#endif //AAS_MOVE_DEBUG\n\t\t\t//\n\t\t\tif (stopevent & (SE_ENTERAREA|SE_TOUCHJUMPPAD|SE_TOUCHTELEPORTER|SE_TOUCHCLUSTERPORTAL))\n\t\t\t{\n\t\t\t\tnumareas = AAS_TraceAreas(org, trace.endpos, areas, points, 20);\n\t\t\t\tfor (i = 0; i < numareas; i++)\n\t\t\t\t{\n\t\t\t\t\tif (stopevent & SE_ENTERAREA)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (areas[i] == stopareanum)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tVectorCopy(points[i], move->endpos);\n\t\t\t\t\t\t\tVectorScale(frame_test_vel, 1/frametime, move->velocity);\n\t\t\t\t\t\t\tmove->endarea = areas[i];\n\t\t\t\t\t\t\tmove->trace = trace;\n\t\t\t\t\t\t\tmove->stopevent = SE_ENTERAREA;\n\t\t\t\t\t\t\tmove->presencetype = presencetype;\n\t\t\t\t\t\t\tmove->endcontents = 0;\n\t\t\t\t\t\t\tmove->time = n * frametime;\n\t\t\t\t\t\t\tmove->frames = n;\n\t\t\t\t\t\t\treturn qtrue;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end if\n\t\t\t\t\t//NOTE: if not the first frame\n\t\t\t\t\tif ((stopevent & SE_TOUCHJUMPPAD) && n)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (aasworld.areasettings[areas[i]].contents & AREACONTENTS_JUMPPAD)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tVectorCopy(points[i], move->endpos);\n\t\t\t\t\t\t\tVectorScale(frame_test_vel, 1/frametime, move->velocity);\n\t\t\t\t\t\t\tmove->endarea = areas[i];\n\t\t\t\t\t\t\tmove->trace = trace;\n\t\t\t\t\t\t\tmove->stopevent = SE_TOUCHJUMPPAD;\n\t\t\t\t\t\t\tmove->presencetype = presencetype;\n\t\t\t\t\t\t\tmove->endcontents = 0;\n\t\t\t\t\t\t\tmove->time = n * frametime;\n\t\t\t\t\t\t\tmove->frames = n;\n\t\t\t\t\t\t\treturn qtrue;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end if\n\t\t\t\t\tif (stopevent & SE_TOUCHTELEPORTER)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (aasworld.areasettings[areas[i]].contents & AREACONTENTS_TELEPORTER)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tVectorCopy(points[i], move->endpos);\n\t\t\t\t\t\t\tmove->endarea = areas[i];\n\t\t\t\t\t\t\tVectorScale(frame_test_vel, 1/frametime, move->velocity);\n\t\t\t\t\t\t\tmove->trace = trace;\n\t\t\t\t\t\t\tmove->stopevent = SE_TOUCHTELEPORTER;\n\t\t\t\t\t\t\tmove->presencetype = presencetype;\n\t\t\t\t\t\t\tmove->endcontents = 0;\n\t\t\t\t\t\t\tmove->time = n * frametime;\n\t\t\t\t\t\t\tmove->frames = n;\n\t\t\t\t\t\t\treturn qtrue;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end if\n\t\t\t\t\tif (stopevent & SE_TOUCHCLUSTERPORTAL)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (aasworld.areasettings[areas[i]].contents & AREACONTENTS_CLUSTERPORTAL)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tVectorCopy(points[i], move->endpos);\n\t\t\t\t\t\t\tmove->endarea = areas[i];\n\t\t\t\t\t\t\tVectorScale(frame_test_vel, 1/frametime, move->velocity);\n\t\t\t\t\t\t\tmove->trace = trace;\n\t\t\t\t\t\t\tmove->stopevent = SE_TOUCHCLUSTERPORTAL;\n\t\t\t\t\t\t\tmove->presencetype = presencetype;\n\t\t\t\t\t\t\tmove->endcontents = 0;\n\t\t\t\t\t\t\tmove->time = n * frametime;\n\t\t\t\t\t\t\tmove->frames = n;\n\t\t\t\t\t\t\treturn qtrue;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end if\n\t\t\t\t} //end for\n\t\t\t} //end if\n\t\t\t//\n\t\t\tif (stopevent & SE_HITBOUNDINGBOX)\n\t\t\t{\n\t\t\t\tif (AAS_ClipToBBox(&trace, org, trace.endpos, presencetype, mins, maxs))\n\t\t\t\t{\n\t\t\t\t\tVectorCopy(trace.endpos, move->endpos);\n\t\t\t\t\tmove->endarea = AAS_PointAreaNum(move->endpos);\n\t\t\t\t\tVectorScale(frame_test_vel, 1/frametime, move->velocity);\n\t\t\t\t\tmove->trace = trace;\n\t\t\t\t\tmove->stopevent = SE_HITBOUNDINGBOX;\n\t\t\t\t\tmove->presencetype = presencetype;\n\t\t\t\t\tmove->endcontents = 0;\n\t\t\t\t\tmove->time = n * frametime;\n\t\t\t\t\tmove->frames = n;\n\t\t\t\t\treturn qtrue;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t\t//move the entity to the trace end point\n\t\t\tVectorCopy(trace.endpos, org);\n\t\t\t//if there was a collision\n\t\t\tif (trace.fraction < 1.0)\n\t\t\t{\n\t\t\t\t//get the plane the bounding box collided with\n\t\t\t\tplane = AAS_PlaneFromNum(trace.planenum);\n\t\t\t\t//\n\t\t\t\tif (stopevent & SE_HITGROUNDAREA)\n\t\t\t\t{\n\t\t\t\t\tif (DotProduct(plane->normal, up) > phys_maxsteepness)\n\t\t\t\t\t{\n\t\t\t\t\t\tVectorCopy(org, start);\n\t\t\t\t\t\tstart[2] += 0.5;\n\t\t\t\t\t\tif (AAS_PointAreaNum(start) == stopareanum)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tVectorCopy(start, move->endpos);\n\t\t\t\t\t\t\tmove->endarea = stopareanum;\n\t\t\t\t\t\t\tVectorScale(frame_test_vel, 1/frametime, move->velocity);\n\t\t\t\t\t\t\tmove->trace = trace;\n\t\t\t\t\t\t\tmove->stopevent = SE_HITGROUNDAREA;\n\t\t\t\t\t\t\tmove->presencetype = presencetype;\n\t\t\t\t\t\t\tmove->endcontents = 0;\n\t\t\t\t\t\t\tmove->time = n * frametime;\n\t\t\t\t\t\t\tmove->frames = n;\n\t\t\t\t\t\t\treturn qtrue;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t\t//assume there's no step\n\t\t\t\tstep = qfalse;\n\t\t\t\t//if it is a vertical plane and the bot didn't jump recently\n\t\t\t\tif (plane->normal[2] == 0 && (jump_frame < 0 || n - jump_frame > 2))\n\t\t\t\t{\n\t\t\t\t\t//check for a step\n\t\t\t\t\tVectorMA(org, -0.25, plane->normal, start);\n\t\t\t\t\tVectorCopy(start, stepend);\n\t\t\t\t\tstart[2] += phys_maxstep;\n\t\t\t\t\tsteptrace = AAS_TraceClientBBox(start, stepend, presencetype, entnum);\n\t\t\t\t\t//\n\t\t\t\t\tif (!steptrace.startsolid)\n\t\t\t\t\t{\n\t\t\t\t\t\tplane2 = AAS_PlaneFromNum(steptrace.planenum);\n\t\t\t\t\t\tif (DotProduct(plane2->normal, up) > phys_maxsteepness)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tVectorSubtract(end, steptrace.endpos, left_test_vel);\n\t\t\t\t\t\t\tleft_test_vel[2] = 0;\n\t\t\t\t\t\t\tframe_test_vel[2] = 0;\n//#ifdef AAS_MOVE_DEBUG\n\t\t\t\t\t\t\tif (visualize)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (steptrace.endpos[2] - org[2] > 0.125)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tVectorCopy(org, start);\n\t\t\t\t\t\t\t\t\tstart[2] = steptrace.endpos[2];\n\t\t\t\t\t\t\t\t\tAAS_DebugLine(org, start, LINECOLOR_BLUE);\n\t\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\t} //end if\n//#endif //AAS_MOVE_DEBUG\n\t\t\t\t\t\t\torg[2] = steptrace.endpos[2];\n\t\t\t\t\t\t\tstep = qtrue;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t\t//\n\t\t\t\tif (!step)\n\t\t\t\t{\n\t\t\t\t\t//velocity left to test for this frame is the projection\n\t\t\t\t\t//of the current test velocity into the hit plane \n\t\t\t\t\tVectorMA(left_test_vel, -DotProduct(left_test_vel, plane->normal),\n\t\t\t\t\t\t\t\t\t\tplane->normal, left_test_vel);\n\t\t\t\t\t//store the old velocity for landing check\n\t\t\t\t\tVectorCopy(frame_test_vel, old_frame_test_vel);\n\t\t\t\t\t//test velocity for the next frame is the projection\n\t\t\t\t\t//of the velocity of the current frame into the hit plane \n\t\t\t\t\tVectorMA(frame_test_vel, -DotProduct(frame_test_vel, plane->normal),\n\t\t\t\t\t\t\t\t\t\tplane->normal, frame_test_vel);\n\t\t\t\t\t//check for a landing on an almost horizontal floor\n\t\t\t\t\tif (DotProduct(plane->normal, up) > phys_maxsteepness)\n\t\t\t\t\t{\n\t\t\t\t\t\tonground = qtrue;\n\t\t\t\t\t} //end if\n\t\t\t\t\tif (stopevent & SE_HITGROUNDDAMAGE)\n\t\t\t\t\t{\n\t\t\t\t\t\tdelta = 0;\n\t\t\t\t\t\tif (old_frame_test_vel[2] < 0 &&\n\t\t\t\t\t\t\t\tframe_test_vel[2] > old_frame_test_vel[2] &&\n\t\t\t\t\t\t\t\t!onground)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdelta = old_frame_test_vel[2];\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\telse if (onground)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdelta = frame_test_vel[2] - old_frame_test_vel[2];\n\t\t\t\t\t\t} //end else\n\t\t\t\t\t\tif (delta)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdelta = delta * 10;\n\t\t\t\t\t\t\tdelta = delta * delta * 0.0001;\n\t\t\t\t\t\t\tif (swimming) delta = 0;\n\t\t\t\t\t\t\t// never take falling damage if completely underwater\n\t\t\t\t\t\t\t/*\n\t\t\t\t\t\t\tif (ent->waterlevel == 3) return;\n\t\t\t\t\t\t\tif (ent->waterlevel == 2) delta *= 0.25;\n\t\t\t\t\t\t\tif (ent->waterlevel == 1) delta *= 0.5;\n\t\t\t\t\t\t\t*/\n\t\t\t\t\t\t\tif (delta > 40)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tVectorCopy(org, move->endpos);\n\t\t\t\t\t\t\t\tmove->endarea = AAS_PointAreaNum(org);\n\t\t\t\t\t\t\t\tVectorCopy(frame_test_vel, move->velocity);\n\t\t\t\t\t\t\t\tmove->trace = trace;\n\t\t\t\t\t\t\t\tmove->stopevent = SE_HITGROUNDDAMAGE;\n\t\t\t\t\t\t\t\tmove->presencetype = presencetype;\n\t\t\t\t\t\t\t\tmove->endcontents = 0;\n\t\t\t\t\t\t\t\tmove->time = n * frametime;\n\t\t\t\t\t\t\t\tmove->frames = n;\n\t\t\t\t\t\t\t\treturn qtrue;\n\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t\t//extra check to prevent endless loop\n\t\t\tif (++j > 20) return qfalse;\n\t\t//while there is a plane hit\n\t\t} while(trace.fraction < 1.0);\n\t\t//if going down\n\t\tif (frame_test_vel[2] <= 10)\n\t\t{\n\t\t\t//check for a liquid at the feet of the bot\n\t\t\tVectorCopy(org, feet);\n\t\t\tfeet[2] -= 22;\n\t\t\tpc = AAS_PointContents(feet);\n\t\t\t//get event from pc\n\t\t\tevent = SE_NONE;\n\t\t\tif (pc & CONTENTS_LAVA) event |= SE_ENTERLAVA;\n\t\t\tif (pc & CONTENTS_SLIME) event |= SE_ENTERSLIME;\n\t\t\tif (pc & CONTENTS_WATER) event |= SE_ENTERWATER;\n\t\t\t//\n\t\t\tareanum = AAS_PointAreaNum(org);\n\t\t\tif (aasworld.areasettings[areanum].contents & AREACONTENTS_LAVA)\n\t\t\t\tevent |= SE_ENTERLAVA;\n\t\t\tif (aasworld.areasettings[areanum].contents & AREACONTENTS_SLIME)\n\t\t\t\tevent |= SE_ENTERSLIME;\n\t\t\tif (aasworld.areasettings[areanum].contents & AREACONTENTS_WATER)\n\t\t\t\tevent |= SE_ENTERWATER;\n\t\t\t//if in lava or slime\n\t\t\tif (event & stopevent)\n\t\t\t{\n\t\t\t\tVectorCopy(org, move->endpos);\n\t\t\t\tmove->endarea = areanum;\n\t\t\t\tVectorScale(frame_test_vel, 1/frametime, move->velocity);\n\t\t\t\tmove->stopevent = event & stopevent;\n\t\t\t\tmove->presencetype = presencetype;\n\t\t\t\tmove->endcontents = pc;\n\t\t\t\tmove->time = n * frametime;\n\t\t\t\tmove->frames = n;\n\t\t\t\treturn qtrue;\n\t\t\t} //end if\n\t\t} //end if\n\t\t//\n\t\tonground = AAS_OnGround(org, presencetype, entnum);\n\t\t//if onground and on the ground for at least one whole frame\n\t\tif (onground)\n\t\t{\n\t\t\tif (stopevent & SE_HITGROUND)\n\t\t\t{\n\t\t\t\tVectorCopy(org, move->endpos);\n\t\t\t\tmove->endarea = AAS_PointAreaNum(org);\n\t\t\t\tVectorScale(frame_test_vel, 1/frametime, move->velocity);\n\t\t\t\tmove->trace = trace;\n\t\t\t\tmove->stopevent = SE_HITGROUND;\n\t\t\t\tmove->presencetype = presencetype;\n\t\t\t\tmove->endcontents = 0;\n\t\t\t\tmove->time = n * frametime;\n\t\t\t\tmove->frames = n;\n\t\t\t\treturn qtrue;\n\t\t\t} //end if\n\t\t} //end if\n\t\telse if (stopevent & SE_LEAVEGROUND)\n\t\t{\n\t\t\tVectorCopy(org, move->endpos);\n\t\t\tmove->endarea = AAS_PointAreaNum(org);\n\t\t\tVectorScale(frame_test_vel, 1/frametime, move->velocity);\n\t\t\tmove->trace = trace;\n\t\t\tmove->stopevent = SE_LEAVEGROUND;\n\t\t\tmove->presencetype = presencetype;\n\t\t\tmove->endcontents = 0;\n\t\t\tmove->time = n * frametime;\n\t\t\tmove->frames = n;\n\t\t\treturn qtrue;\n\t\t} //end else if\n\t\telse if (stopevent & SE_GAP)\n\t\t{\n\t\t\taas_trace_t gaptrace;\n\n\t\t\tVectorCopy(org, start);\n\t\t\tVectorCopy(start, end);\n\t\t\tend[2] -= 48 + aassettings.phys_maxbarrier;\n\t\t\tgaptrace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, -1);\n\t\t\t//if solid is found the bot cannot walk any further and will not fall into a gap\n\t\t\tif (!gaptrace.startsolid)\n\t\t\t{\n\t\t\t\t//if it is a gap (lower than one step height)\n\t\t\t\tif (gaptrace.endpos[2] < org[2] - aassettings.phys_maxstep - 1)\n\t\t\t\t{\n\t\t\t\t\tif (!(AAS_PointContents(end) & CONTENTS_WATER))\n\t\t\t\t\t{\n\t\t\t\t\t\tVectorCopy(lastorg, move->endpos);\n\t\t\t\t\t\tmove->endarea = AAS_PointAreaNum(lastorg);\n\t\t\t\t\t\tVectorScale(frame_test_vel, 1/frametime, move->velocity);\n\t\t\t\t\t\tmove->trace = trace;\n\t\t\t\t\t\tmove->stopevent = SE_GAP;\n\t\t\t\t\t\tmove->presencetype = presencetype;\n\t\t\t\t\t\tmove->endcontents = 0;\n\t\t\t\t\t\tmove->time = n * frametime;\n\t\t\t\t\t\tmove->frames = n;\n\t\t\t\t\t\treturn qtrue;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end else if\n\t} //end for\n\t//\n\tVectorCopy(org, move->endpos);\n\tmove->endarea = AAS_PointAreaNum(org);\n\tVectorScale(frame_test_vel, 1/frametime, move->velocity);\n\tmove->stopevent = SE_NONE;\n\tmove->presencetype = presencetype;\n\tmove->endcontents = 0;\n\tmove->time = n * frametime;\n\tmove->frames = n;\n\t//\n\treturn qtrue;\n} //end of the function AAS_ClientMovementPrediction\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_PredictClientMovement(struct aas_clientmove_s *move,\n\t\t\t\t\t\t\t\tint entnum, vec3_t origin,\n\t\t\t\t\t\t\t\tint presencetype, int onground,\n\t\t\t\t\t\t\t\tvec3_t velocity, vec3_t cmdmove,\n\t\t\t\t\t\t\t\tint cmdframes,\n\t\t\t\t\t\t\t\tint maxframes, float frametime,\n\t\t\t\t\t\t\t\tint stopevent, int stopareanum, int visualize)\n{\n\tvec3_t mins, maxs;\n\treturn AAS_ClientMovementPrediction(move, entnum, origin, presencetype, onground,\n\t\t\t\t\t\t\t\t\t\tvelocity, cmdmove, cmdframes, maxframes,\n\t\t\t\t\t\t\t\t\t\tframetime, stopevent, stopareanum,\n\t\t\t\t\t\t\t\t\t\tmins, maxs, visualize);\n} //end of the function AAS_PredictClientMovement\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_ClientMovementHitBBox(struct aas_clientmove_s *move,\n\t\t\t\t\t\t\t\tint entnum, vec3_t origin,\n\t\t\t\t\t\t\t\tint presencetype, int onground,\n\t\t\t\t\t\t\t\tvec3_t velocity, vec3_t cmdmove,\n\t\t\t\t\t\t\t\tint cmdframes,\n\t\t\t\t\t\t\t\tint maxframes, float frametime,\n\t\t\t\t\t\t\t\tvec3_t mins, vec3_t maxs, int visualize)\n{\n\treturn AAS_ClientMovementPrediction(move, entnum, origin, presencetype, onground,\n\t\t\t\t\t\t\t\t\t\tvelocity, cmdmove, cmdframes, maxframes,\n\t\t\t\t\t\t\t\t\t\tframetime, SE_HITBOUNDINGBOX, 0,\n\t\t\t\t\t\t\t\t\t\tmins, maxs, visualize);\n} //end of the function AAS_ClientMovementHitBBox\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_TestMovementPrediction(int entnum, vec3_t origin, vec3_t dir)\n{\n\tvec3_t velocity, cmdmove;\n\taas_clientmove_t move;\n\n\tVectorClear(velocity);\n\tif (!AAS_Swimming(origin)) dir[2] = 0;\n\tVectorNormalize(dir);\n\tVectorScale(dir, 400, cmdmove);\n\tcmdmove[2] = 224;\n\tAAS_ClearShownDebugLines();\n\tAAS_PredictClientMovement(&move, entnum, origin, PRESENCE_NORMAL, qtrue,\n\t\t\t\t\t\t\t\t\tvelocity, cmdmove, 13, 13, 0.1f, SE_HITGROUND, 0, qtrue);//SE_LEAVEGROUND);\n\tif (move.stopevent & SE_LEAVEGROUND)\n\t{\n\t\tbotimport.Print(PRT_MESSAGE, \"leave ground\\n\");\n\t} //end if\n} //end of the function TestMovementPrediction\n//===========================================================================\n// calculates the horizontal velocity needed to perform a jump from start\n// to end\n//\n// Parameter:\t\t\tzvel\t: z velocity for jump\n//\t\t\t\t\t\tstart\t: start position of jump\n//\t\t\t\t\t\tend\t\t: end position of jump\n//\t\t\t\t\t\t*speed\t: returned speed for jump\n// Returns:\t\t\t\tqfalse if too high or too far from start to end\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_HorizontalVelocityForJump(float zvel, vec3_t start, vec3_t end, float *velocity)\n{\n\tfloat phys_gravity, phys_maxvelocity;\n\tfloat maxjump, height2fall, t, top;\n\tvec3_t dir;\n\n\tphys_gravity = aassettings.phys_gravity;\n\tphys_maxvelocity = aassettings.phys_maxvelocity;\n\n\t//maximum height a player can jump with the given initial z velocity\n\tmaxjump = 0.5 * phys_gravity * (zvel / phys_gravity) * (zvel / phys_gravity);\n\t//top of the parabolic jump\n\ttop = start[2] + maxjump;\n\t//height the bot will fall from the top\n\theight2fall = top - end[2];\n\t//if the goal is to high to jump to\n\tif (height2fall < 0)\n\t{\n\t\t*velocity = phys_maxvelocity;\n\t\treturn 0;\n\t} //end if\n\t//time a player takes to fall the height\n\tt = sqrt(height2fall / (0.5 * phys_gravity));\n  \t//direction from start to end\n\tVectorSubtract(end, start, dir);\n\t//\n\tif ( (t + zvel / phys_gravity) == 0.0f ) {\n\t\t*velocity = phys_maxvelocity;\n\t\treturn 0;\n\t}\n\t//calculate horizontal speed\n\t*velocity = sqrt(dir[0]*dir[0] + dir[1]*dir[1]) / (t + zvel / phys_gravity);\n\t//the horizontal speed must be lower than the max speed\n\tif (*velocity > phys_maxvelocity)\n\t{\n\t\t*velocity = phys_maxvelocity;\n\t\treturn 0;\n\t} //end if\n\treturn 1;\n} //end of the function AAS_HorizontalVelocityForJump\n"
  },
  {
    "path": "code/botlib/be_aas_move.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_move.h\n *\n * desc:\t\tAAS\n *\n * $Archive: /source/code/botlib/be_aas_move.h $\n *\n *****************************************************************************/\n\n#ifdef AASINTERN\nextern aas_settings_t aassettings;\n#endif //AASINTERN\n\n//movement prediction\nint AAS_PredictClientMovement(struct aas_clientmove_s *move,\n\t\t\t\t\t\t\tint entnum, vec3_t origin,\n\t\t\t\t\t\t\tint presencetype, int onground,\n\t\t\t\t\t\t\tvec3_t velocity, vec3_t cmdmove,\n\t\t\t\t\t\t\tint cmdframes,\n\t\t\t\t\t\t\tint maxframes, float frametime,\n\t\t\t\t\t\t\tint stopevent, int stopareanum, int visualize);\n//predict movement until bounding box is hit\nint AAS_ClientMovementHitBBox(struct aas_clientmove_s *move,\n\t\t\t\t\t\t\t\tint entnum, vec3_t origin,\n\t\t\t\t\t\t\t\tint presencetype, int onground,\n\t\t\t\t\t\t\t\tvec3_t velocity, vec3_t cmdmove,\n\t\t\t\t\t\t\t\tint cmdframes,\n\t\t\t\t\t\t\t\tint maxframes, float frametime,\n\t\t\t\t\t\t\t\tvec3_t mins, vec3_t maxs, int visualize);\n//returns true if on the ground at the given origin\nint AAS_OnGround(vec3_t origin, int presencetype, int passent);\n//returns true if swimming at the given origin\nint AAS_Swimming(vec3_t origin);\n//returns the jump reachability run start point\nvoid AAS_JumpReachRunStart(struct aas_reachability_s *reach, vec3_t runstart);\n//returns true if against a ladder at the given origin\nint AAS_AgainstLadder(vec3_t origin);\n//rocket jump Z velocity when rocket-jumping at origin\nfloat AAS_RocketJumpZVelocity(vec3_t origin);\n//bfg jump Z velocity when bfg-jumping at origin\nfloat AAS_BFGJumpZVelocity(vec3_t origin);\n//calculates the horizontal velocity needed for a jump and returns true this velocity could be calculated\nint AAS_HorizontalVelocityForJump(float zvel, vec3_t start, vec3_t end, float *velocity);\n//\nvoid AAS_SetMovedir(vec3_t angles, vec3_t movedir);\n//\nint AAS_DropToFloor(vec3_t origin, vec3_t mins, vec3_t maxs);\n//\nvoid AAS_InitSettings(void);\n"
  },
  {
    "path": "code/botlib/be_aas_optimize.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_optimize.c\n *\n * desc:\t\tdecreases the .aas file size after the reachabilities have\n *\t\t\t\tbeen calculated, just dumps all the faces, edges and vertexes\n *\n * $Archive: /MissionPack/code/botlib/be_aas_optimize.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_libvar.h\"\n#include \"l_memory.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#include \"aasfile.h\"\n#include \"../game/botlib.h\"\n#include \"../game/be_aas.h\"\n#include \"be_aas_funcs.h\"\n#include \"be_interface.h\"\n#include \"be_aas_def.h\"\n\ntypedef struct optimized_s\n{\n\t//vertexes\n\tint numvertexes;\n\taas_vertex_t *vertexes;\n\t//edges\n\tint numedges;\n\taas_edge_t *edges;\n\t//edge index\n\tint edgeindexsize;\n\taas_edgeindex_t *edgeindex;\n\t//faces\n\tint numfaces;\n\taas_face_t *faces;\n\t//face index\n\tint faceindexsize;\n\taas_faceindex_t *faceindex;\n\t//convex areas\n\tint numareas;\n\taas_area_t *areas;\n\t//\n\tint *vertexoptimizeindex;\n\tint *edgeoptimizeindex;\n\tint *faceoptimizeindex;\n} optimized_t;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_KeepEdge(aas_edge_t *edge)\n{\n\treturn 1;\n} //end of the function AAS_KeepFace\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_OptimizeEdge(optimized_t *optimized, int edgenum)\n{\n\tint i, optedgenum;\n\taas_edge_t *edge, *optedge;\n\n\tedge = &aasworld.edges[abs(edgenum)];\n\tif (!AAS_KeepEdge(edge)) return 0;\n\n\toptedgenum = optimized->edgeoptimizeindex[abs(edgenum)];\n\tif (optedgenum)\n\t{\n\t\t//keep the edge reversed sign\n\t\tif (edgenum > 0) return optedgenum;\n\t\telse return -optedgenum;\n\t} //end if\n\n\toptedge = &optimized->edges[optimized->numedges];\n\n\tfor (i = 0; i < 2; i++)\n\t{\n\t\tif (optimized->vertexoptimizeindex[edge->v[i]])\n\t\t{\n\t\t\toptedge->v[i] = optimized->vertexoptimizeindex[edge->v[i]];\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tVectorCopy(aasworld.vertexes[edge->v[i]], optimized->vertexes[optimized->numvertexes]);\n\t\t\toptedge->v[i] = optimized->numvertexes;\n\t\t\toptimized->vertexoptimizeindex[edge->v[i]] = optimized->numvertexes;\n\t\t\toptimized->numvertexes++;\n\t\t} //end else\n\t} //end for\n\toptimized->edgeoptimizeindex[abs(edgenum)] = optimized->numedges;\n\toptedgenum = optimized->numedges;\n\toptimized->numedges++;\n\t//keep the edge reversed sign\n\tif (edgenum > 0) return optedgenum;\n\telse return -optedgenum;\n} //end of the function AAS_OptimizeEdge\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_KeepFace(aas_face_t *face)\n{\n\tif (!(face->faceflags & FACE_LADDER)) return 0;\n\telse return 1;\n} //end of the function AAS_KeepFace\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_OptimizeFace(optimized_t *optimized, int facenum)\n{\n\tint i, edgenum, optedgenum, optfacenum;\n\taas_face_t *face, *optface;\n\n\tface = &aasworld.faces[abs(facenum)];\n\tif (!AAS_KeepFace(face)) return 0;\n\n\toptfacenum = optimized->faceoptimizeindex[abs(facenum)];\n\tif (optfacenum)\n\t{\n\t\t//keep the face side sign\n\t\tif (facenum > 0) return optfacenum;\n\t\telse return -optfacenum;\n\t} //end if\n\n\toptface = &optimized->faces[optimized->numfaces];\n\tCom_Memcpy(optface, face, sizeof(aas_face_t));\n\n\toptface->numedges = 0;\n\toptface->firstedge = optimized->edgeindexsize;\n\tfor (i = 0; i < face->numedges; i++)\n\t{\n\t\tedgenum = aasworld.edgeindex[face->firstedge + i];\n\t\toptedgenum = AAS_OptimizeEdge(optimized, edgenum);\n\t\tif (optedgenum)\n\t\t{\n\t\t\toptimized->edgeindex[optface->firstedge + optface->numedges] = optedgenum;\n\t\t\toptface->numedges++;\n\t\t\toptimized->edgeindexsize++;\n\t\t} //end if\n\t} //end for\n\toptimized->faceoptimizeindex[abs(facenum)] = optimized->numfaces;\n\toptfacenum = optimized->numfaces;\n\toptimized->numfaces++;\n\t//keep the face side sign\n\tif (facenum > 0) return optfacenum;\n\telse return -optfacenum;\n} //end of the function AAS_OptimizeFace\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_OptimizeArea(optimized_t *optimized, int areanum)\n{\n\tint i, facenum, optfacenum;\n\taas_area_t *area, *optarea;\n\n\tarea = &aasworld.areas[areanum];\n\toptarea = &optimized->areas[areanum];\n\tCom_Memcpy(optarea, area, sizeof(aas_area_t));\n\n\toptarea->numfaces = 0;\n\toptarea->firstface = optimized->faceindexsize;\n\tfor (i = 0; i < area->numfaces; i++)\n\t{\n\t\tfacenum = aasworld.faceindex[area->firstface + i];\n\t\toptfacenum = AAS_OptimizeFace(optimized, facenum);\n\t\tif (optfacenum)\n\t\t{\n\t\t\toptimized->faceindex[optarea->firstface + optarea->numfaces] = optfacenum;\n\t\t\toptarea->numfaces++;\n\t\t\toptimized->faceindexsize++;\n\t\t} //end if\n\t} //end for\n} //end of the function AAS_OptimizeArea\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_OptimizeAlloc(optimized_t *optimized)\n{\n\toptimized->vertexes = (aas_vertex_t *) GetClearedMemory(aasworld.numvertexes * sizeof(aas_vertex_t));\n\toptimized->numvertexes = 0;\n\toptimized->edges = (aas_edge_t *) GetClearedMemory(aasworld.numedges * sizeof(aas_edge_t));\n\toptimized->numedges = 1; //edge zero is a dummy\n\toptimized->edgeindex = (aas_edgeindex_t *) GetClearedMemory(aasworld.edgeindexsize * sizeof(aas_edgeindex_t));\n\toptimized->edgeindexsize = 0;\n\toptimized->faces = (aas_face_t *) GetClearedMemory(aasworld.numfaces * sizeof(aas_face_t));\n\toptimized->numfaces = 1; //face zero is a dummy\n\toptimized->faceindex = (aas_faceindex_t *) GetClearedMemory(aasworld.faceindexsize * sizeof(aas_faceindex_t));\n\toptimized->faceindexsize = 0;\n\toptimized->areas = (aas_area_t *) GetClearedMemory(aasworld.numareas * sizeof(aas_area_t));\n\toptimized->numareas = aasworld.numareas;\n\t//\n\toptimized->vertexoptimizeindex = (int *) GetClearedMemory(aasworld.numvertexes * sizeof(int));\n\toptimized->edgeoptimizeindex = (int *) GetClearedMemory(aasworld.numedges * sizeof(int));\n\toptimized->faceoptimizeindex = (int *) GetClearedMemory(aasworld.numfaces * sizeof(int));\n} //end of the function AAS_OptimizeAlloc\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_OptimizeStore(optimized_t *optimized)\n{\n\t//store the optimized vertexes\n\tif (aasworld.vertexes) FreeMemory(aasworld.vertexes);\n\taasworld.vertexes = optimized->vertexes;\n\taasworld.numvertexes = optimized->numvertexes;\n\t//store the optimized edges\n\tif (aasworld.edges) FreeMemory(aasworld.edges);\n\taasworld.edges = optimized->edges;\n\taasworld.numedges = optimized->numedges;\n\t//store the optimized edge index\n\tif (aasworld.edgeindex) FreeMemory(aasworld.edgeindex);\n\taasworld.edgeindex = optimized->edgeindex;\n\taasworld.edgeindexsize = optimized->edgeindexsize;\n\t//store the optimized faces\n\tif (aasworld.faces) FreeMemory(aasworld.faces);\n\taasworld.faces = optimized->faces;\n\taasworld.numfaces = optimized->numfaces;\n\t//store the optimized face index\n\tif (aasworld.faceindex) FreeMemory(aasworld.faceindex);\n\taasworld.faceindex = optimized->faceindex;\n\taasworld.faceindexsize = optimized->faceindexsize;\n\t//store the optimized areas\n\tif (aasworld.areas) FreeMemory(aasworld.areas);\n\taasworld.areas = optimized->areas;\n\taasworld.numareas = optimized->numareas;\n\t//free optimize indexes\n\tFreeMemory(optimized->vertexoptimizeindex);\n\tFreeMemory(optimized->edgeoptimizeindex);\n\tFreeMemory(optimized->faceoptimizeindex);\n} //end of the function AAS_OptimizeStore\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_Optimize(void)\n{\n\tint i, sign;\n\toptimized_t optimized;\n\n\tAAS_OptimizeAlloc(&optimized);\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\tAAS_OptimizeArea(&optimized, i);\n\t} //end for\n\t//reset the reachability face pointers\n\tfor (i = 0; i < aasworld.reachabilitysize; i++)\n\t{\n\t\t//NOTE: for TRAVEL_ELEVATOR the facenum is the model number of\n\t\t//\t\tthe elevator\n\t\tif ((aasworld.reachability[i].traveltype & TRAVELTYPE_MASK) == TRAVEL_ELEVATOR) continue;\n\t\t//NOTE: for TRAVEL_JUMPPAD the facenum is the Z velocity and the edgenum is the hor velocity\n\t\tif ((aasworld.reachability[i].traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMPPAD) continue;\n\t\t//NOTE: for TRAVEL_FUNCBOB the facenum and edgenum contain other coded information\n\t\tif ((aasworld.reachability[i].traveltype & TRAVELTYPE_MASK) == TRAVEL_FUNCBOB) continue;\n\t\t//\n\t\tsign = aasworld.reachability[i].facenum;\n\t\taasworld.reachability[i].facenum = optimized.faceoptimizeindex[abs(aasworld.reachability[i].facenum)];\n\t\tif (sign < 0) aasworld.reachability[i].facenum = -aasworld.reachability[i].facenum;\n\t\tsign = aasworld.reachability[i].edgenum;\n\t\taasworld.reachability[i].edgenum = optimized.edgeoptimizeindex[abs(aasworld.reachability[i].edgenum)];\n\t\tif (sign < 0) aasworld.reachability[i].edgenum = -aasworld.reachability[i].edgenum;\n\t} //end for\n\t//store the optimized AAS data into aasworld\n\tAAS_OptimizeStore(&optimized);\n\t//print some nice stuff :)\n\tbotimport.Print(PRT_MESSAGE, \"AAS data optimized.\\n\");\n} //end of the function AAS_Optimize\n"
  },
  {
    "path": "code/botlib/be_aas_optimize.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_optimize.h\n *\n * desc:\t\tAAS\n *\n * $Archive: /source/code/botlib/be_aas_optimize.h $\n *\n *****************************************************************************/\n\nvoid AAS_Optimize(void);\n\n"
  },
  {
    "path": "code/botlib/be_aas_reach.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_reach.c\n *\n * desc:\t\treachability calculations\n *\n * $Archive: /MissionPack/code/botlib/be_aas_reach.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_log.h\"\n#include \"l_memory.h\"\n#include \"l_script.h\"\n#include \"l_libvar.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#include \"aasfile.h\"\n#include \"../game/botlib.h\"\n#include \"../game/be_aas.h\"\n#include \"be_aas_funcs.h\"\n#include \"be_aas_def.h\"\n\nextern int Sys_MilliSeconds(void);\n\n\nextern botlib_import_t botimport;\n\n//#define REACH_DEBUG\n\n//NOTE: all travel times are in hundreth of a second\n//maximum number of reachability links\n#define AAS_MAX_REACHABILITYSIZE\t\t\t65536\n//number of areas reachability is calculated for each frame\n#define REACHABILITYAREASPERCYCLE\t\t\t15\n//number of units reachability points are placed inside the areas\n#define INSIDEUNITS\t\t\t\t\t\t\t2\n#define INSIDEUNITS_WALKEND\t\t\t\t\t5\n#define INSIDEUNITS_WALKSTART\t\t\t\t0.1\n#define INSIDEUNITS_WATERJUMP\t\t\t\t15\n//area flag used for weapon jumping\n#define AREA_WEAPONJUMP\t\t\t\t\t\t8192\t//valid area to weapon jump to\n//number of reachabilities of each type\nint reach_swim;\t\t\t//swim\nint reach_equalfloor;\t//walk on floors with equal height\nint reach_step;\t\t\t//step up\nint reach_walk;\t\t\t//walk of step\nint reach_barrier;\t\t//jump up to a barrier\nint reach_waterjump;\t//jump out of water\nint reach_walkoffledge;\t//walk of a ledge\nint reach_jump;\t\t\t//jump\nint reach_ladder;\t\t//climb or descent a ladder\nint reach_teleport;\t\t//teleport\nint reach_elevator;\t\t//use an elevator\nint reach_funcbob;\t\t//use a func bob\nint reach_grapple;\t\t//grapple hook\nint reach_doublejump;\t//double jump\nint reach_rampjump;\t\t//ramp jump\nint reach_strafejump;\t//strafe jump (just normal jump but further)\nint reach_rocketjump;\t//rocket jump\nint reach_bfgjump;\t\t//bfg jump\nint reach_jumppad;\t\t//jump pads\n//if true grapple reachabilities are skipped\nint calcgrapplereach;\n//linked reachability\ntypedef struct aas_lreachability_s\n{\n\tint areanum;\t\t\t\t\t//number of the reachable area\n\tint facenum;\t\t\t\t\t//number of the face towards the other area\n\tint edgenum;\t\t\t\t\t//number of the edge towards the other area\n\tvec3_t start;\t\t\t\t\t//start point of inter area movement\n\tvec3_t end;\t\t\t\t\t\t//end point of inter area movement\n\tint traveltype;\t\t\t\t\t//type of travel required to get to the area\n\tunsigned short int traveltime;\t//travel time of the inter area movement\n\t//\n\tstruct aas_lreachability_s *next;\n} aas_lreachability_t;\n//temporary reachabilities\naas_lreachability_t *reachabilityheap;\t//heap with reachabilities\naas_lreachability_t *nextreachability;\t//next free reachability from the heap\naas_lreachability_t **areareachability;\t//reachability links for every area\nint numlreachabilities;\n\n//===========================================================================\n// returns the surface area of the given face\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat AAS_FaceArea(aas_face_t *face)\n{\n\tint i, edgenum, side;\n\tfloat total;\n\tvec_t *v;\n\tvec3_t d1, d2, cross;\n\taas_edge_t *edge;\n\n\tedgenum = aasworld.edgeindex[face->firstedge];\n\tside = edgenum < 0;\n\tedge = &aasworld.edges[abs(edgenum)];\n\tv = aasworld.vertexes[edge->v[side]];\n\n\ttotal = 0;\n\tfor (i = 1; i < face->numedges - 1; i++)\n\t{\n\t\tedgenum = aasworld.edgeindex[face->firstedge + i];\n\t\tside = edgenum < 0;\n\t\tedge = &aasworld.edges[abs(edgenum)];\n\t\tVectorSubtract(aasworld.vertexes[edge->v[side]], v, d1);\n\t\tVectorSubtract(aasworld.vertexes[edge->v[!side]], v, d2);\n\t\tCrossProduct(d1, d2, cross);\n\t\ttotal += 0.5 * VectorLength(cross);\n\t} //end for\n\treturn total;\n} //end of the function AAS_FaceArea\n//===========================================================================\n// returns the volume of an area\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat AAS_AreaVolume(int areanum)\n{\n\tint i, edgenum, facenum, side;\n\tvec_t d, a, volume;\n\tvec3_t corner;\n\taas_plane_t *plane;\n\taas_edge_t *edge;\n\taas_face_t *face;\n\taas_area_t *area;\n\n\tarea = &aasworld.areas[areanum];\n\tfacenum = aasworld.faceindex[area->firstface];\n\tface = &aasworld.faces[abs(facenum)];\n\tedgenum = aasworld.edgeindex[face->firstedge];\n\tedge = &aasworld.edges[abs(edgenum)];\n\t//\n\tVectorCopy(aasworld.vertexes[edge->v[0]], corner);\n\n\t//make tetrahedrons to all other faces\n\tvolume = 0;\n\tfor (i = 0; i < area->numfaces; i++)\n\t{\n\t\tfacenum = abs(aasworld.faceindex[area->firstface + i]);\n\t\tface = &aasworld.faces[facenum];\n\t\tside = face->backarea != areanum;\n\t\tplane = &aasworld.planes[face->planenum ^ side];\n\t\td = -(DotProduct (corner, plane->normal) - plane->dist);\n\t\ta = AAS_FaceArea(face);\n\t\tvolume += d * a;\n\t} //end for\n\n\tvolume /= 3;\n\treturn volume;\n} //end of the function AAS_AreaVolume\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_BestReachableLinkArea(aas_link_t *areas)\n{\n\taas_link_t *link;\n\n\tfor (link = areas; link; link = link->next_area)\n\t{\n\t\tif (AAS_AreaGrounded(link->areanum) || AAS_AreaSwim(link->areanum))\n\t\t{\n\t\t\treturn link->areanum;\n\t\t} //end if\n\t} //end for\n\t//\n\tfor (link = areas; link; link = link->next_area)\n\t{\n\t\tif (link->areanum) return link->areanum;\n\t\t//FIXME: this is a bad idea when the reachability is not yet\n\t\t// calculated when the level items are loaded\n\t\tif (AAS_AreaReachability(link->areanum))\n\t\t\treturn link->areanum;\n\t} //end for\n\treturn 0;\n} //end of the function AAS_BestReachableLinkArea\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_GetJumpPadInfo(int ent, vec3_t areastart, vec3_t absmins, vec3_t absmaxs, vec3_t velocity)\n{\n\tint modelnum, ent2;\n\tfloat speed, height, gravity, time, dist, forward;\n\tvec3_t origin, angles, teststart, ent2origin;\n\taas_trace_t trace;\n\tchar model[MAX_EPAIRKEY];\n\tchar target[MAX_EPAIRKEY], targetname[MAX_EPAIRKEY];\n\n\t//\n\tAAS_FloatForBSPEpairKey(ent, \"speed\", &speed);\n\tif (!speed) speed = 1000;\n\tVectorClear(angles);\n\t//get the mins, maxs and origin of the model\n\tAAS_ValueForBSPEpairKey(ent, \"model\", model, MAX_EPAIRKEY);\n\tif (model[0]) modelnum = atoi(model+1);\n\telse modelnum = 0;\n\tAAS_BSPModelMinsMaxsOrigin(modelnum, angles, absmins, absmaxs, origin);\n\tVectorAdd(origin, absmins, absmins);\n\tVectorAdd(origin, absmaxs, absmaxs);\n\tVectorAdd(absmins, absmaxs, origin);\n\tVectorScale (origin, 0.5, origin);\n\n\t//get the start areas\n\tVectorCopy(origin, teststart);\n\tteststart[2] += 64;\n\ttrace = AAS_TraceClientBBox(teststart, origin, PRESENCE_CROUCH, -1);\n\tif (trace.startsolid)\n\t{\n\t\tbotimport.Print(PRT_MESSAGE, \"trigger_push start solid\\n\");\n\t\tVectorCopy(origin, areastart);\n\t} //end if\n\telse\n\t{\n\t\tVectorCopy(trace.endpos, areastart);\n\t} //end else\n\tareastart[2] += 0.125;\n\t//\n\t//AAS_DrawPermanentCross(origin, 4, 4);\n\t//get the target entity\n\tAAS_ValueForBSPEpairKey(ent, \"target\", target, MAX_EPAIRKEY);\n\tfor (ent2 = AAS_NextBSPEntity(0); ent2; ent2 = AAS_NextBSPEntity(ent2))\n\t{\n\t\tif (!AAS_ValueForBSPEpairKey(ent2, \"targetname\", targetname, MAX_EPAIRKEY)) continue;\n\t\tif (!strcmp(targetname, target)) break;\n\t} //end for\n\tif (!ent2)\n\t{\n\t\tbotimport.Print(PRT_MESSAGE, \"trigger_push without target entity %s\\n\", target);\n\t\treturn qfalse;\n\t} //end if\n\tAAS_VectorForBSPEpairKey(ent2, \"origin\", ent2origin);\n\t//\n\theight = ent2origin[2] - origin[2];\n\tgravity = aassettings.phys_gravity;\n\ttime = sqrt( height / ( 0.5 * gravity ) );\n\tif (!time)\n\t{\n\t\tbotimport.Print(PRT_MESSAGE, \"trigger_push without time\\n\");\n\t\treturn qfalse;\n\t} //end if\n\t// set s.origin2 to the push velocity\n\tVectorSubtract ( ent2origin, origin, velocity);\n\tdist = VectorNormalize( velocity);\n\tforward = dist / time;\n\t//FIXME: why multiply by 1.1\n\tforward *= 1.1f;\n\tVectorScale(velocity, forward, velocity);\n\tvelocity[2] = time * gravity;\n\treturn qtrue;\n} //end of the function AAS_GetJumpPadInfo\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_BestReachableFromJumpPadArea(vec3_t origin, vec3_t mins, vec3_t maxs)\n{\n\tint area2num, ent, bot_visualizejumppads, bestareanum;\n\tfloat volume, bestareavolume;\n\tvec3_t areastart, cmdmove, bboxmins, bboxmaxs;\n\tvec3_t absmins, absmaxs, velocity;\n\taas_clientmove_t move;\n\taas_link_t *areas, *link;\n\tchar classname[MAX_EPAIRKEY];\n\n#ifdef BSPC\n\tbot_visualizejumppads = 0;\n#else\n\tbot_visualizejumppads = LibVarValue(\"bot_visualizejumppads\", \"0\");\n#endif\n\tVectorAdd(origin, mins, bboxmins);\n\tVectorAdd(origin, maxs, bboxmaxs);\n\tfor (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent))\n\t{\n\t\tif (!AAS_ValueForBSPEpairKey(ent, \"classname\", classname, MAX_EPAIRKEY)) continue;\n\t\tif (strcmp(classname, \"trigger_push\")) continue;\n\t\t//\n\t\tif (!AAS_GetJumpPadInfo(ent, areastart, absmins, absmaxs, velocity)) continue;\n\t\t//get the areas the jump pad brush is in\n\t\tareas = AAS_LinkEntityClientBBox(absmins, absmaxs, -1, PRESENCE_CROUCH);\n\t\tfor (link = areas; link; link = link->next_area)\n\t\t{\n\t\t\tif (AAS_AreaJumpPad(link->areanum)) break;\n\t\t} //end for\n\t\tif (!link)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"trigger_push not in any jump pad area\\n\");\n\t\t\tAAS_UnlinkFromAreas(areas);\n\t\t\tcontinue;\n\t\t} //end if\n\t\t//\n\t\t//botimport.Print(PRT_MESSAGE, \"found a trigger_push with velocity %f %f %f\\n\", velocity[0], velocity[1], velocity[2]);\n\t\t//\n\t\tVectorSet(cmdmove, 0, 0, 0);\n\t\tCom_Memset(&move, 0, sizeof(aas_clientmove_t));\n\t\tarea2num = 0;\n\t\tAAS_ClientMovementHitBBox(&move, -1, areastart, PRESENCE_NORMAL, qfalse,\n\t\t\t\t\t\t\t\tvelocity, cmdmove, 0, 30, 0.1f, bboxmins, bboxmaxs, bot_visualizejumppads);\n\t\tif (move.frames < 30)\n\t\t{\n\t\t\tbestareanum = 0;\n\t\t\tbestareavolume = 0;\n\t\t\tfor (link = areas; link; link = link->next_area)\n\t\t\t{\n\t\t\t\tif (!AAS_AreaJumpPad(link->areanum)) continue;\n\t\t\t\tvolume = AAS_AreaVolume(link->areanum);\n\t\t\t\tif (volume >= bestareavolume)\n\t\t\t\t{\n\t\t\t\t\tbestareanum = link->areanum;\n\t\t\t\t\tbestareavolume = volume;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t\tAAS_UnlinkFromAreas(areas);\n\t\t\treturn bestareanum;\n\t\t} //end if\n\t\tAAS_UnlinkFromAreas(areas);\n\t} //end for\n\treturn 0;\n} //end of the function AAS_BestReachableFromJumpPadArea\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_BestReachableArea(vec3_t origin, vec3_t mins, vec3_t maxs, vec3_t goalorigin)\n{\n\tint areanum, i, j, k, l;\n\taas_link_t *areas;\n\tvec3_t absmins, absmaxs;\n\t//vec3_t bbmins, bbmaxs;\n\tvec3_t start, end;\n\taas_trace_t trace;\n\n\tif (!aasworld.loaded)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"AAS_BestReachableArea: aas not loaded\\n\");\n\t\treturn 0;\n\t} //end if\n\t//find a point in an area\n\tVectorCopy(origin, start);\n\tareanum = AAS_PointAreaNum(start);\n\t//while no area found fudge around a little\n\tfor (i = 0; i < 5 && !areanum; i++)\n\t{\n\t\tfor (j = 0; j < 5 && !areanum; j++)\n\t\t{\n\t\t\tfor (k = -1; k <= 1 && !areanum; k++)\n\t\t\t{\n\t\t\t\tfor (l = -1; l <= 1 && !areanum; l++)\n\t\t\t\t{\n\t\t\t\t\tVectorCopy(origin, start);\n\t\t\t\t\tstart[0] += (float) j * 4 * k;\n\t\t\t\t\tstart[1] += (float) j * 4 * l;\n\t\t\t\t\tstart[2] += (float) i * 4;\n\t\t\t\t\tareanum = AAS_PointAreaNum(start);\n\t\t\t\t} //end for\n\t\t\t} //end for\n\t\t} //end for\n\t} //end for\n\t//if an area was found\n\tif (areanum)\n\t{\n\t\t//drop client bbox down and try again\n\t\tVectorCopy(start, end);\n\t\tstart[2] += 0.25;\n\t\tend[2] -= 50;\n\t\ttrace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, -1);\n\t\tif (!trace.startsolid)\n\t\t{\n\t\t\tareanum = AAS_PointAreaNum(trace.endpos);\n\t\t\tVectorCopy(trace.endpos, goalorigin);\n\t\t\t//FIXME: cannot enable next line right now because the reachability\n\t\t\t// does not have to be calculated when the level items are loaded\n\t\t\t//if the origin is in an area with reachability\n\t\t\t//if (AAS_AreaReachability(areanum)) return areanum;\n\t\t\tif (areanum) return areanum;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\t//it can very well happen that the AAS_PointAreaNum function tells that\n\t\t\t//a point is in an area and that starting a AAS_TraceClientBBox from that\n\t\t\t//point will return trace.startsolid qtrue\n#if 0\n\t\t\tif (AAS_PointAreaNum(start))\n\t\t\t{\n\t\t\t\tLog_Write(\"point %f %f %f in area %d but trace startsolid\", start[0], start[1], start[2], areanum);\n\t\t\t\tAAS_DrawPermanentCross(start, 4, LINECOLOR_RED);\n\t\t\t} //end if\n\t\t\tbotimport.Print(PRT_MESSAGE, \"AAS_BestReachableArea: start solid\\n\");\n#endif\n\t\t\tVectorCopy(start, goalorigin);\n\t\t\treturn areanum;\n\t\t} //end else\n\t} //end if\n\t//\n\t//AAS_PresenceTypeBoundingBox(PRESENCE_CROUCH, bbmins, bbmaxs);\n\t//NOTE: the goal origin does not have to be in the goal area\n\t// because the bot will have to move towards the item origin anyway\n\tVectorCopy(origin, goalorigin);\n\t//\n\tVectorAdd(origin, mins, absmins);\n\tVectorAdd(origin, maxs, absmaxs);\n\t//add bounding box size\n\t//VectorSubtract(absmins, bbmaxs, absmins);\n\t//VectorSubtract(absmaxs, bbmins, absmaxs);\n\t//link an invalid (-1) entity\n\tareas = AAS_LinkEntityClientBBox(absmins, absmaxs, -1, PRESENCE_CROUCH);\n\t//get the reachable link arae\n\tareanum = AAS_BestReachableLinkArea(areas);\n\t//unlink the invalid entity\n\tAAS_UnlinkFromAreas(areas);\n\t//\n\treturn areanum;\n} //end of the function AAS_BestReachableArea\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_SetupReachabilityHeap(void)\n{\n\tint i;\n\n\treachabilityheap = (aas_lreachability_t *) GetClearedMemory(\n\t\t\t\t\t\tAAS_MAX_REACHABILITYSIZE * sizeof(aas_lreachability_t));\n\tfor (i = 0; i < AAS_MAX_REACHABILITYSIZE-1; i++)\n\t{\n\t\treachabilityheap[i].next = &reachabilityheap[i+1];\n\t} //end for\n\treachabilityheap[AAS_MAX_REACHABILITYSIZE-1].next = NULL;\n\tnextreachability = reachabilityheap;\n\tnumlreachabilities = 0;\n} //end of the function AAS_InitReachabilityHeap\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ShutDownReachabilityHeap(void)\n{\n\tFreeMemory(reachabilityheap);\n\tnumlreachabilities = 0;\n} //end of the function AAS_ShutDownReachabilityHeap\n//===========================================================================\n// returns a reachability link\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\naas_lreachability_t *AAS_AllocReachability(void)\n{\n\taas_lreachability_t *r;\n\n\tif (!nextreachability) return NULL;\n\t//make sure the error message only shows up once\n\tif (!nextreachability->next) AAS_Error(\"AAS_MAX_REACHABILITYSIZE\");\n\t//\n\tr = nextreachability;\n\tnextreachability = nextreachability->next;\n\tnumlreachabilities++;\n\treturn r;\n} //end of the function AAS_AllocReachability\n//===========================================================================\n// frees a reachability link\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FreeReachability(aas_lreachability_t *lreach)\n{\n\tCom_Memset(lreach, 0, sizeof(aas_lreachability_t));\n\n\tlreach->next = nextreachability;\n\tnextreachability = lreach;\n\tnumlreachabilities--;\n} //end of the function AAS_FreeReachability\n//===========================================================================\n// returns qtrue if the area has reachability links\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AreaReachability(int areanum)\n{\n\tif (areanum < 0 || areanum >= aasworld.numareas)\n\t{\n\t\tAAS_Error(\"AAS_AreaReachability: areanum %d out of range\", areanum);\n\t\treturn 0;\n\t} //end if\n\treturn aasworld.areasettings[areanum].numreachableareas;\n} //end of the function AAS_AreaReachability\n//===========================================================================\n// returns the surface area of all ground faces together of the area\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat AAS_AreaGroundFaceArea(int areanum)\n{\n\tint i;\n\tfloat total;\n\taas_area_t *area;\n\taas_face_t *face;\n\n\ttotal = 0;\n\tarea = &aasworld.areas[areanum];\n\tfor (i = 0; i < area->numfaces; i++)\n\t{\n\t\tface = &aasworld.faces[abs(aasworld.faceindex[area->firstface + i])];\n\t\tif (!(face->faceflags & FACE_GROUND)) continue;\n\t\t//\n\t\ttotal += AAS_FaceArea(face);\n\t} //end for\n\treturn total;\n} //end of the function AAS_AreaGroundFaceArea\n//===========================================================================\n// returns the center of a face\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FaceCenter(int facenum, vec3_t center)\n{\n\tint i;\n\tfloat scale;\n\taas_face_t *face;\n\taas_edge_t *edge;\n\n\tface = &aasworld.faces[facenum];\n\n\tVectorClear(center);\n\tfor (i = 0; i < face->numedges; i++)\n\t{\n\t\tedge = &aasworld.edges[abs(aasworld.edgeindex[face->firstedge + i])];\n\t\tVectorAdd(center, aasworld.vertexes[edge->v[0]], center);\n\t\tVectorAdd(center, aasworld.vertexes[edge->v[1]], center);\n\t} //end for\n\tscale = 0.5 / face->numedges;\n\tVectorScale(center, scale, center);\n} //end of the function AAS_FaceCenter\n//===========================================================================\n// returns the maximum distance a player can fall before being damaged\n// damage = deltavelocity*deltavelocity  * 0.0001\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_FallDamageDistance(void)\n{\n\tfloat maxzvelocity, gravity, t;\n\n\tmaxzvelocity = sqrt(30 * 10000);\n\tgravity = aassettings.phys_gravity;\n\tt = maxzvelocity / gravity;\n\treturn 0.5 * gravity * t * t;\n} //end of the function AAS_FallDamageDistance\n//===========================================================================\n// distance = 0.5 * gravity * t * t\n// vel = t * gravity\n// damage = vel * vel * 0.0001\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat AAS_FallDelta(float distance)\n{\n\tfloat t, delta, gravity;\n\n\tgravity = aassettings.phys_gravity;\n\tt = sqrt(fabs(distance) * 2 / gravity);\n\tdelta = t * gravity;\n\treturn delta * delta * 0.0001;\n} //end of the function AAS_FallDelta\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat AAS_MaxJumpHeight(float phys_jumpvel)\n{\n\tfloat phys_gravity;\n\n\tphys_gravity = aassettings.phys_gravity;\n\t//maximum height a player can jump with the given initial z velocity\n\treturn 0.5 * phys_gravity * (phys_jumpvel / phys_gravity) * (phys_jumpvel / phys_gravity);\n} //end of the function MaxJumpHeight\n//===========================================================================\n// returns true if a player can only crouch in the area\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat AAS_MaxJumpDistance(float phys_jumpvel)\n{\n\tfloat phys_gravity, phys_maxvelocity, t;\n\n\tphys_gravity = aassettings.phys_gravity;\n\tphys_maxvelocity = aassettings.phys_maxvelocity;\n\t//time a player takes to fall the height\n\tt = sqrt(aassettings.rs_maxjumpfallheight / (0.5 * phys_gravity));\n   //maximum distance\n\treturn phys_maxvelocity * (t + phys_jumpvel / phys_gravity);\n} //end of the function AAS_MaxJumpDistance\n//===========================================================================\n// returns true if a player can only crouch in the area\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AreaCrouch(int areanum)\n{\n\tif (!(aasworld.areasettings[areanum].presencetype & PRESENCE_NORMAL)) return qtrue;\n\telse return qfalse;\n} //end of the function AAS_AreaCrouch\n//===========================================================================\n// returns qtrue if it is possible to swim in the area\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AreaSwim(int areanum)\n{\n\tif (aasworld.areasettings[areanum].areaflags & AREA_LIQUID) return qtrue;\n\telse return qfalse;\n} //end of the function AAS_AreaSwim\n//===========================================================================\n// returns qtrue if the area contains a liquid\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AreaLiquid(int areanum)\n{\n\tif (aasworld.areasettings[areanum].areaflags & AREA_LIQUID) return qtrue;\n\telse return qfalse;\n} //end of the function AAS_AreaLiquid\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AreaLava(int areanum)\n{\n\treturn (aasworld.areasettings[areanum].contents & AREACONTENTS_LAVA);\n} //end of the function AAS_AreaLava\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AreaSlime(int areanum)\n{\n\treturn (aasworld.areasettings[areanum].contents & AREACONTENTS_SLIME);\n} //end of the function AAS_AreaSlime\n//===========================================================================\n// returns qtrue if the area contains ground faces\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AreaGrounded(int areanum)\n{\n\treturn (aasworld.areasettings[areanum].areaflags & AREA_GROUNDED);\n} //end of the function AAS_AreaGround\n//===========================================================================\n// returns true if the area contains ladder faces\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AreaLadder(int areanum)\n{\n\treturn (aasworld.areasettings[areanum].areaflags & AREA_LADDER);\n} //end of the function AAS_AreaLadder\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AreaJumpPad(int areanum)\n{\n\treturn (aasworld.areasettings[areanum].contents & AREACONTENTS_JUMPPAD);\n} //end of the function AAS_AreaJumpPad\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AreaTeleporter(int areanum)\n{\n\treturn (aasworld.areasettings[areanum].contents & AREACONTENTS_TELEPORTER);\n} //end of the function AAS_AreaTeleporter\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AreaClusterPortal(int areanum)\n{\n\treturn (aasworld.areasettings[areanum].contents & AREACONTENTS_CLUSTERPORTAL);\n} //end of the function AAS_AreaClusterPortal\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AreaDoNotEnter(int areanum)\n{\n\treturn (aasworld.areasettings[areanum].contents & AREACONTENTS_DONOTENTER);\n} //end of the function AAS_AreaDoNotEnter\n//===========================================================================\n// returns the time it takes perform a barrier jump\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nunsigned short int AAS_BarrierJumpTravelTime(void)\n{\n\treturn aassettings.phys_jumpvel / (aassettings.phys_gravity * 0.1);\n} //end op the function AAS_BarrierJumpTravelTime\n//===========================================================================\n// returns true if there already exists a reachability from area1 to area2\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_ReachabilityExists(int area1num, int area2num)\n{\n\taas_lreachability_t *r;\n\n\tfor (r = areareachability[area1num]; r; r = r->next)\n\t{\n\t\tif (r->areanum == area2num) return qtrue;\n\t} //end for\n\treturn qfalse;\n} //end of the function AAS_ReachabilityExists\n//===========================================================================\n// returns true if there is a solid just after the end point when going\n// from start to end\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_NearbySolidOrGap(vec3_t start, vec3_t end)\n{\n\tvec3_t dir, testpoint;\n\tint areanum;\n\n\tVectorSubtract(end, start, dir);\n\tdir[2] = 0;\n\tVectorNormalize(dir);\n\tVectorMA(end, 48, dir, testpoint);\n\n\tareanum = AAS_PointAreaNum(testpoint);\n\tif (!areanum)\n\t{\n\t\ttestpoint[2] += 16;\n\t\tareanum = AAS_PointAreaNum(testpoint);\n\t\tif (!areanum) return qtrue;\n\t} //end if\n\tVectorMA(end, 64, dir, testpoint);\n\tareanum = AAS_PointAreaNum(testpoint);\n\tif (areanum)\n\t{\n\t\tif (!AAS_AreaSwim(areanum) && !AAS_AreaGrounded(areanum)) return qtrue;\n\t} //end if\n\treturn qfalse;\n} //end of the function AAS_SolidGapTime\n//===========================================================================\n// searches for swim reachabilities between adjacent areas\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_Reachability_Swim(int area1num, int area2num)\n{\n\tint i, j, face1num, face2num, side1;\n\taas_area_t *area1, *area2;\n\taas_areasettings_t *areasettings;\n\taas_lreachability_t *lreach;\n\taas_face_t *face1;\n\taas_plane_t *plane;\n\tvec3_t start;\n\n\tif (!AAS_AreaSwim(area1num) || !AAS_AreaSwim(area2num)) return qfalse;\n\t//if the second area is crouch only\n\tif (!(aasworld.areasettings[area2num].presencetype & PRESENCE_NORMAL)) return qfalse;\n\n\tarea1 = &aasworld.areas[area1num];\n\tarea2 = &aasworld.areas[area2num];\n\n\t//if the areas are not near anough\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tif (area1->mins[i] > area2->maxs[i] + 10) return qfalse;\n\t\tif (area1->maxs[i] < area2->mins[i] - 10) return qfalse;\n\t} //end for\n\t//find a shared face and create a reachability link\n\tfor (i = 0; i < area1->numfaces; i++)\n\t{\n\t\tface1num = aasworld.faceindex[area1->firstface + i];\n\t\tside1 = face1num < 0;\n\t\tface1num = abs(face1num);\n\t\t//\n\t\tfor (j = 0; j < area2->numfaces; j++)\n\t\t{\n\t\t\tface2num = abs(aasworld.faceindex[area2->firstface + j]);\n\t\t\t//\n\t\t\tif (face1num == face2num)\n\t\t\t{\n\t\t\t\tAAS_FaceCenter(face1num, start);\n\t\t\t\t//\n\t\t\t\tif (AAS_PointContents(start) & (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER))\n\t\t\t\t{\n\t\t\t\t\t//\n\t\t\t\t\tface1 = &aasworld.faces[face1num];\n\t\t\t\t\tareasettings = &aasworld.areasettings[area1num];\n\t\t\t\t\t//create a new reachability link\n\t\t\t\t\tlreach = AAS_AllocReachability();\n\t\t\t\t\tif (!lreach) return qfalse;\n\t\t\t\t\tlreach->areanum = area2num;\n\t\t\t\t\tlreach->facenum = face1num;\n\t\t\t\t\tlreach->edgenum = 0;\n\t\t\t\t\tVectorCopy(start, lreach->start);\n\t\t\t\t\tplane = &aasworld.planes[face1->planenum ^ side1];\n\t\t\t\t\tVectorMA(lreach->start, -INSIDEUNITS, plane->normal, lreach->end);\n\t\t\t\t\tlreach->traveltype = TRAVEL_SWIM;\n\t\t\t\t\tlreach->traveltime = 1;\n\t\t\t\t\t//if the volume of the area is rather small\n\t\t\t\t\tif (AAS_AreaVolume(area2num) < 800)\n\t\t\t\t\t\tlreach->traveltime += 200;\n\t\t\t\t\t//if (!(AAS_PointContents(start) & MASK_WATER)) lreach->traveltime += 500;\n\t\t\t\t\t//link the reachability\n\t\t\t\t\tlreach->next = areareachability[area1num];\n\t\t\t\t\tareareachability[area1num] = lreach;\n\t\t\t\t\treach_swim++;\n\t\t\t\t\treturn qtrue;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\treturn qfalse;\n} //end of the function AAS_Reachability_Swim\n//===========================================================================\n// searches for reachabilities between adjacent areas with equal floor\n// heights\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_Reachability_EqualFloorHeight(int area1num, int area2num)\n{\n\tint i, j, edgenum, edgenum1, edgenum2, foundreach, side;\n\tfloat height, bestheight, length, bestlength;\n\tvec3_t dir, start, end, normal, invgravity, gravitydirection = {0, 0, -1};\n\tvec3_t edgevec;\n\taas_area_t *area1, *area2;\n\taas_face_t *face1, *face2;\n\taas_edge_t *edge;\n\taas_plane_t *plane2;\n\taas_lreachability_t lr, *lreach;\n\n\tif (!AAS_AreaGrounded(area1num) || !AAS_AreaGrounded(area2num)) return qfalse;\n\n\tarea1 = &aasworld.areas[area1num];\n\tarea2 = &aasworld.areas[area2num];\n\t//if the areas are not near anough in the x-y direction\n\tfor (i = 0; i < 2; i++)\n\t{\n\t\tif (area1->mins[i] > area2->maxs[i] + 10) return qfalse;\n\t\tif (area1->maxs[i] < area2->mins[i] - 10) return qfalse;\n\t} //end for\n\t//if area 2 is too high above area 1\n\tif (area2->mins[2] > area1->maxs[2]) return qfalse;\n\t//\n\tVectorCopy(gravitydirection, invgravity);\n\tVectorInverse(invgravity);\n\t//\n\tbestheight = 99999;\n\tbestlength = 0;\n\tfoundreach = qfalse;\n\tCom_Memset(&lr, 0, sizeof(aas_lreachability_t)); //make the compiler happy\n\t//\n\t//check if the areas have ground faces with a common edge\n\t//if existing use the lowest common edge for a reachability link\n\tfor (i = 0; i < area1->numfaces; i++)\n\t{\n\t\tface1 = &aasworld.faces[abs(aasworld.faceindex[area1->firstface + i])];\n\t\tif (!(face1->faceflags & FACE_GROUND)) continue;\n\t\t//\n\t\tfor (j = 0; j < area2->numfaces; j++)\n\t\t{\n\t\t\tface2 = &aasworld.faces[abs(aasworld.faceindex[area2->firstface + j])];\n\t\t\tif (!(face2->faceflags & FACE_GROUND)) continue;\n\t\t\t//if there is a common edge\n\t\t\tfor (edgenum1 = 0; edgenum1 < face1->numedges; edgenum1++)\n\t\t\t{\n\t\t\t\tfor (edgenum2 = 0; edgenum2 < face2->numedges; edgenum2++)\n\t\t\t\t{\n\t\t\t\t\tif (abs(aasworld.edgeindex[face1->firstedge + edgenum1]) !=\n\t\t\t\t\t\t\tabs(aasworld.edgeindex[face2->firstedge + edgenum2]))\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\tedgenum = aasworld.edgeindex[face1->firstedge + edgenum1];\n\t\t\t\t\tside = edgenum < 0;\n\t\t\t\t\tedge = &aasworld.edges[abs(edgenum)];\n\t\t\t\t\t//get the length of the edge\n\t\t\t\t\tVectorSubtract(aasworld.vertexes[edge->v[1]],\n\t\t\t\t\t\t\t\taasworld.vertexes[edge->v[0]], dir);\n\t\t\t\t\tlength = VectorLength(dir);\n\t\t\t\t\t//get the start point\n\t\t\t\t\tVectorAdd(aasworld.vertexes[edge->v[0]],\n\t\t\t\t\t\t\t\taasworld.vertexes[edge->v[1]], start);\n\t\t\t\t\tVectorScale(start, 0.5, start);\n\t\t\t\t\tVectorCopy(start, end);\n\t\t\t\t\t//get the end point several units inside area2\n\t\t\t\t\t//and the start point several units inside area1\n\t\t\t\t\t//NOTE: normal is pointing into area2 because the\n\t\t\t\t\t//face edges are stored counter clockwise\n\t\t\t\t\tVectorSubtract(aasworld.vertexes[edge->v[side]],\n\t\t\t\t\t\t\t\taasworld.vertexes[edge->v[!side]], edgevec);\n\t\t\t\t\tplane2 = &aasworld.planes[face2->planenum];\n\t\t\t\t\tCrossProduct(edgevec, plane2->normal, normal);\n\t\t\t\t\tVectorNormalize(normal);\n\t\t\t\t\t//\n\t\t\t\t\t//VectorMA(start, -1, normal, start);\n\t\t\t\t\tVectorMA(end, INSIDEUNITS_WALKEND, normal, end);\n\t\t\t\t\tVectorMA(start, INSIDEUNITS_WALKSTART, normal, start);\n\t\t\t\t\tend[2] += 0.125;\n\t\t\t\t\t//\n\t\t\t\t\theight = DotProduct(invgravity, start);\n\t\t\t\t\t//NOTE: if there's nearby solid or a gap area after this area\n\t\t\t\t\t//disabled this crap\n\t\t\t\t\t//if (AAS_NearbySolidOrGap(start, end)) height += 200;\n\t\t\t\t\t//NOTE: disabled because it disables reachabilities to very small areas\n\t\t\t\t\t//if (AAS_PointAreaNum(end) != area2num) continue;\n\t\t\t\t\t//get the longest lowest edge\n\t\t\t\t\tif (height < bestheight ||\n\t\t\t\t\t\t\t(height < bestheight + 1 && length > bestlength))\n\t\t\t\t\t{\n\t\t\t\t\t\tbestheight = height;\n\t\t\t\t\t\tbestlength = length;\n\t\t\t\t\t\t//create a new reachability link\n\t\t\t\t\t\tlr.areanum = area2num;\n\t\t\t\t\t\tlr.facenum = 0;\n\t\t\t\t\t\tlr.edgenum = edgenum;\n\t\t\t\t\t\tVectorCopy(start, lr.start);\n\t\t\t\t\t\tVectorCopy(end, lr.end);\n\t\t\t\t\t\tlr.traveltype = TRAVEL_WALK;\n\t\t\t\t\t\tlr.traveltime = 1;\n\t\t\t\t\t\tfoundreach = qtrue;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end for\n\t\t\t} //end for\n\t\t} //end for\n\t} //end for\n\tif (foundreach)\n\t{\n\t\t//create a new reachability link\n\t\tlreach = AAS_AllocReachability();\n\t\tif (!lreach) return qfalse;\n\t\tlreach->areanum = lr.areanum;\n\t\tlreach->facenum = lr.facenum;\n\t\tlreach->edgenum = lr.edgenum;\n\t\tVectorCopy(lr.start, lreach->start);\n\t\tVectorCopy(lr.end, lreach->end);\n\t\tlreach->traveltype = lr.traveltype;\n\t\tlreach->traveltime = lr.traveltime;\n\t\tlreach->next = areareachability[area1num];\n\t\tareareachability[area1num] = lreach;\n\t\t//if going into a crouch area\n\t\tif (!AAS_AreaCrouch(area1num) && AAS_AreaCrouch(area2num))\n\t\t{\n\t\t\tlreach->traveltime += aassettings.rs_startcrouch;\n\t\t} //end if\n\t\t/*\n\t\t//NOTE: if there's nearby solid or a gap area after this area\n\t\tif (!AAS_NearbySolidOrGap(lreach->start, lreach->end))\n\t\t{\n\t\t\tlreach->traveltime += 100;\n\t\t} //end if\n\t\t*/\n\t\t//avoid rather small areas\n\t\t//if (AAS_AreaGroundFaceArea(lreach->areanum) < 500) lreach->traveltime += 100;\n\t\t//\n\t\treach_equalfloor++;\n\t\treturn qtrue;\n\t} //end if\n\treturn qfalse;\n} //end of the function AAS_Reachability_EqualFloorHeight\n//===========================================================================\n// searches step, barrier, waterjump and walk off ledge reachabilities\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(int area1num, int area2num)\n{\n\tint i, j, k, l, edge1num, edge2num, areas[10], numareas;\n\tint ground_bestarea2groundedgenum, ground_foundreach;\n\tint water_bestarea2groundedgenum, water_foundreach;\n\tint side1, area1swim, faceside1, groundface1num;\n\tfloat dist, dist1, dist2, diff, invgravitydot, ortdot;\n\tfloat x1, x2, x3, x4, y1, y2, y3, y4, tmp, y;\n\tfloat length, ground_bestlength, water_bestlength, ground_bestdist, water_bestdist;\n\tvec3_t v1, v2, v3, v4, tmpv, p1area1, p1area2, p2area1, p2area2;\n\tvec3_t normal, ort, edgevec, start, end, dir;\n\tvec3_t ground_beststart, ground_bestend, ground_bestnormal;\n\tvec3_t water_beststart, water_bestend, water_bestnormal;\n\tvec3_t invgravity = {0, 0, 1};\n\tvec3_t testpoint;\n\taas_plane_t *plane;\n\taas_area_t *area1, *area2;\n\taas_face_t *groundface1, *groundface2, *ground_bestface1, *water_bestface1;\n\taas_edge_t *edge1, *edge2;\n\taas_lreachability_t *lreach;\n\taas_trace_t trace;\n\n\t//must be able to walk or swim in the first area\n\tif (!AAS_AreaGrounded(area1num) && !AAS_AreaSwim(area1num)) return qfalse;\n\t//\n\tif (!AAS_AreaGrounded(area2num) && !AAS_AreaSwim(area2num)) return qfalse;\n\t//\n\tarea1 = &aasworld.areas[area1num];\n\tarea2 = &aasworld.areas[area2num];\n\t//if the first area contains a liquid\n\tarea1swim = AAS_AreaSwim(area1num);\n\t//if the areas are not near anough in the x-y direction\n\tfor (i = 0; i < 2; i++)\n\t{\n\t\tif (area1->mins[i] > area2->maxs[i] + 10) return qfalse;\n\t\tif (area1->maxs[i] < area2->mins[i] - 10) return qfalse;\n\t} //end for\n\t//\n\tground_foundreach = qfalse;\n\tground_bestdist = 99999;\n\tground_bestlength = 0;\n\tground_bestarea2groundedgenum = 0;\n\t//\n\twater_foundreach = qfalse;\n\twater_bestdist = 99999;\n\twater_bestlength = 0;\n\twater_bestarea2groundedgenum = 0;\n\t//\n\tfor (i = 0; i < area1->numfaces; i++)\n\t{\n\t\tgroundface1num = aasworld.faceindex[area1->firstface + i];\n\t\tfaceside1 = groundface1num < 0;\n\t\tgroundface1 = &aasworld.faces[abs(groundface1num)];\n\t\t//if this isn't a ground face\n\t\tif (!(groundface1->faceflags & FACE_GROUND))\n\t\t{\n\t\t\t//if we can swim in the first area\n\t\t\tif (area1swim)\n\t\t\t{\n\t\t\t\t//face plane must be more or less horizontal\n\t\t\t\tplane = &aasworld.planes[groundface1->planenum ^ (!faceside1)];\n\t\t\t\tif (DotProduct(plane->normal, invgravity) < 0.7) continue;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\t//if we can't swim in the area it must be a ground face\n\t\t\t\tcontinue;\n\t\t\t} //end else\n\t\t} //end if\n\t\t//\n\t\tfor (k = 0; k < groundface1->numedges; k++)\n\t\t{\n\t\t\tedge1num = aasworld.edgeindex[groundface1->firstedge + k];\n\t\t\tside1 = (edge1num < 0);\n\t\t\t//NOTE: for water faces we must take the side area 1 is\n\t\t\t// on into account because the face is shared and doesn't\n\t\t\t// have to be oriented correctly\n\t\t\tif (!(groundface1->faceflags & FACE_GROUND)) side1 = (side1 == faceside1);\n\t\t\tedge1num = abs(edge1num);\n\t\t\tedge1 = &aasworld.edges[edge1num];\n\t\t\t//vertexes of the edge\n\t\t\tVectorCopy(aasworld.vertexes[edge1->v[!side1]], v1);\n\t\t\tVectorCopy(aasworld.vertexes[edge1->v[side1]], v2);\n\t\t\t//get a vertical plane through the edge\n\t\t\t//NOTE: normal is pointing into area 2 because the\n\t\t\t//face edges are stored counter clockwise\n\t\t\tVectorSubtract(v2, v1, edgevec);\n\t\t\tCrossProduct(edgevec, invgravity, normal);\n\t\t\tVectorNormalize(normal);\n\t\t\tdist = DotProduct(normal, v1);\n\t\t\t//check the faces from the second area\n\t\t\tfor (j = 0; j < area2->numfaces; j++)\n\t\t\t{\n\t\t\t\tgroundface2 = &aasworld.faces[abs(aasworld.faceindex[area2->firstface + j])];\n\t\t\t\t//must be a ground face\n\t\t\t\tif (!(groundface2->faceflags & FACE_GROUND)) continue;\n\t\t\t\t//check the edges of this ground face\n\t\t\t\tfor (l = 0; l < groundface2->numedges; l++)\n\t\t\t\t{\n\t\t\t\t\tedge2num = abs(aasworld.edgeindex[groundface2->firstedge + l]);\n\t\t\t\t\tedge2 = &aasworld.edges[edge2num];\n\t\t\t\t\t//vertexes of the edge\n\t\t\t\t\tVectorCopy(aasworld.vertexes[edge2->v[0]], v3);\n\t\t\t\t\tVectorCopy(aasworld.vertexes[edge2->v[1]], v4);\n\t\t\t\t\t//check the distance between the two points and the vertical plane\n\t\t\t\t\t//through the edge of area1\n\t\t\t\t\tdiff = DotProduct(normal, v3) - dist;\n\t\t\t\t\tif (diff < -0.1 || diff > 0.1) continue;\n\t\t\t\t\tdiff = DotProduct(normal, v4) - dist;\n\t\t\t\t\tif (diff < -0.1 || diff > 0.1) continue;\n\t\t\t\t\t//\n\t\t\t\t\t//project the two ground edges into the step side plane\n\t\t\t\t\t//and calculate the shortest distance between the two\n\t\t\t\t\t//edges if they overlap in the direction orthogonal to\n\t\t\t\t\t//the gravity direction\n\t\t\t\t\tCrossProduct(invgravity, normal, ort);\n\t\t\t\t\tinvgravitydot = DotProduct(invgravity, invgravity);\n\t\t\t\t\tortdot = DotProduct(ort, ort);\n\t\t\t\t\t//projection into the step plane\n\t\t\t\t\t//NOTE: since gravity is vertical this is just the z coordinate\n\t\t\t\t\ty1 = v1[2];//DotProduct(v1, invgravity) / invgravitydot;\n\t\t\t\t\ty2 = v2[2];//DotProduct(v2, invgravity) / invgravitydot;\n\t\t\t\t\ty3 = v3[2];//DotProduct(v3, invgravity) / invgravitydot;\n\t\t\t\t\ty4 = v4[2];//DotProduct(v4, invgravity) / invgravitydot;\n\t\t\t\t\t//\n\t\t\t\t\tx1 = DotProduct(v1, ort) / ortdot;\n\t\t\t\t\tx2 = DotProduct(v2, ort) / ortdot;\n\t\t\t\t\tx3 = DotProduct(v3, ort) / ortdot;\n\t\t\t\t\tx4 = DotProduct(v4, ort) / ortdot;\n\t\t\t\t\t//\n\t\t\t\t\tif (x1 > x2)\n\t\t\t\t\t{\n\t\t\t\t\t\ttmp = x1; x1 = x2; x2 = tmp;\n\t\t\t\t\t\ttmp = y1; y1 = y2; y2 = tmp;\n\t\t\t\t\t\tVectorCopy(v1, tmpv); VectorCopy(v2, v1); VectorCopy(tmpv, v2);\n\t\t\t\t\t} //end if\n\t\t\t\t\tif (x3 > x4)\n\t\t\t\t\t{\n\t\t\t\t\t\ttmp = x3; x3 = x4; x4 = tmp;\n\t\t\t\t\t\ttmp = y3; y3 = y4; y4 = tmp;\n\t\t\t\t\t\tVectorCopy(v3, tmpv); VectorCopy(v4, v3); VectorCopy(tmpv, v4);\n\t\t\t\t\t} //end if\n\t\t\t\t\t//if the two projected edge lines have no overlap\n\t\t\t\t\tif (x2 <= x3 || x4 <= x1)\n\t\t\t\t\t{\n//\t\t\t\t\t\tLog_Write(\"lines no overlap: from area %d to %d\\r\\n\", area1num, area2num);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} //end if\n\t\t\t\t\t//if the two lines fully overlap\n\t\t\t\t\tif ((x1 - 0.5 < x3 && x4 < x2 + 0.5) &&\n\t\t\t\t\t\t\t(x3 - 0.5 < x1 && x2 < x4 + 0.5))\n\t\t\t\t\t{\n\t\t\t\t\t\tdist1 = y3 - y1;\n\t\t\t\t\t\tdist2 = y4 - y2;\n\t\t\t\t\t\tVectorCopy(v1, p1area1);\n\t\t\t\t\t\tVectorCopy(v2, p2area1);\n\t\t\t\t\t\tVectorCopy(v3, p1area2);\n\t\t\t\t\t\tVectorCopy(v4, p2area2);\n\t\t\t\t\t} //end if\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t//if the points are equal\n\t\t\t\t\t\tif (x1 > x3 - 0.1 && x1 < x3 + 0.1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdist1 = y3 - y1;\n\t\t\t\t\t\t\tVectorCopy(v1, p1area1);\n\t\t\t\t\t\t\tVectorCopy(v3, p1area2);\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\telse if (x1 < x3)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ty = y1 + (x3 - x1) * (y2 - y1) / (x2 - x1);\n\t\t\t\t\t\t\tdist1 = y3 - y;\n\t\t\t\t\t\t\tVectorCopy(v3, p1area1);\n\t\t\t\t\t\t\tp1area1[2] = y;\n\t\t\t\t\t\t\tVectorCopy(v3, p1area2);\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ty = y3 + (x1 - x3) * (y4 - y3) / (x4 - x3);\n\t\t\t\t\t\t\tdist1 = y - y1;\n\t\t\t\t\t\t\tVectorCopy(v1, p1area1);\n\t\t\t\t\t\t\tVectorCopy(v1, p1area2);\n\t\t\t\t\t\t\tp1area2[2] = y;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t//if the points are equal\n\t\t\t\t\t\tif (x2 > x4 - 0.1 && x2 < x4 + 0.1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdist2 = y4 - y2;\n\t\t\t\t\t\t\tVectorCopy(v2, p2area1);\n\t\t\t\t\t\t\tVectorCopy(v4, p2area2);\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\telse if (x2 < x4)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ty = y3 + (x2 - x3) * (y4 - y3) / (x4 - x3);\n\t\t\t\t\t\t\tdist2 = y - y2;\n\t\t\t\t\t\t\tVectorCopy(v2, p2area1);\n\t\t\t\t\t\t\tVectorCopy(v2, p2area2);\n\t\t\t\t\t\t\tp2area2[2] = y;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ty = y1 + (x4 - x1) * (y2 - y1) / (x2 - x1);\n\t\t\t\t\t\t\tdist2 = y4 - y;\n\t\t\t\t\t\t\tVectorCopy(v4, p2area1);\n\t\t\t\t\t\t\tp2area1[2] = y;\n\t\t\t\t\t\t\tVectorCopy(v4, p2area2);\n\t\t\t\t\t\t} //end else\n\t\t\t\t\t} //end else\n\t\t\t\t\t//if both distances are pretty much equal\n\t\t\t\t\t//then we take the middle of the points\n\t\t\t\t\tif (dist1 > dist2 - 1 && dist1 < dist2 + 1)\n\t\t\t\t\t{\n\t\t\t\t\t\tdist = dist1;\n\t\t\t\t\t\tVectorAdd(p1area1, p2area1, start);\n\t\t\t\t\t\tVectorScale(start, 0.5, start);\n\t\t\t\t\t\tVectorAdd(p1area2, p2area2, end);\n\t\t\t\t\t\tVectorScale(end, 0.5, end);\n\t\t\t\t\t} //end if\n\t\t\t\t\telse if (dist1 < dist2)\n\t\t\t\t\t{\n\t\t\t\t\t\tdist = dist1;\n\t\t\t\t\t\tVectorCopy(p1area1, start);\n\t\t\t\t\t\tVectorCopy(p1area2, end);\n\t\t\t\t\t} //end else if\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tdist = dist2;\n\t\t\t\t\t\tVectorCopy(p2area1, start);\n\t\t\t\t\t\tVectorCopy(p2area2, end);\n\t\t\t\t\t} //end else\n\t\t\t\t\t//get the length of the overlapping part of the edges of the two areas\n\t\t\t\t\tVectorSubtract(p2area2, p1area2, dir);\n\t\t\t\t\tlength = VectorLength(dir);\n\t\t\t\t\t//\n\t\t\t\t\tif (groundface1->faceflags & FACE_GROUND)\n\t\t\t\t\t{\n\t\t\t\t\t\t//if the vertical distance is smaller\n\t\t\t\t\t\tif (dist < ground_bestdist ||\n\t\t\t\t\t\t\t\t//or the vertical distance is pretty much the same\n\t\t\t\t\t\t\t\t//but the overlapping part of the edges is longer\n\t\t\t\t\t\t\t\t(dist < ground_bestdist + 1 && length > ground_bestlength))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tground_bestdist = dist;\n\t\t\t\t\t\t\tground_bestlength = length;\n\t\t\t\t\t\t\tground_foundreach = qtrue;\n\t\t\t\t\t\t\tground_bestarea2groundedgenum = edge1num;\n\t\t\t\t\t\t\tground_bestface1 = groundface1;\n\t\t\t\t\t\t\t//best point towards area1\n\t\t\t\t\t\t\tVectorCopy(start, ground_beststart);\n\t\t\t\t\t\t\t//normal is pointing into area2\n\t\t\t\t\t\t\tVectorCopy(normal, ground_bestnormal);\n\t\t\t\t\t\t\t//best point towards area2\n\t\t\t\t\t\t\tVectorCopy(end, ground_bestend);\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end if\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t//if the vertical distance is smaller\n\t\t\t\t\t\tif (dist < water_bestdist ||\n\t\t\t\t\t\t\t\t//or the vertical distance is pretty much the same\n\t\t\t\t\t\t\t\t//but the overlapping part of the edges is longer\n\t\t\t\t\t\t\t\t(dist < water_bestdist + 1 && length > water_bestlength))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\twater_bestdist = dist;\n\t\t\t\t\t\t\twater_bestlength = length;\n\t\t\t\t\t\t\twater_foundreach = qtrue;\n\t\t\t\t\t\t\twater_bestarea2groundedgenum = edge1num;\n\t\t\t\t\t\t\twater_bestface1 = groundface1;\n\t\t\t\t\t\t\t//best point towards area1\n\t\t\t\t\t\t\tVectorCopy(start, water_beststart);\n\t\t\t\t\t\t\t//normal is pointing into area2\n\t\t\t\t\t\t\tVectorCopy(normal, water_bestnormal);\n\t\t\t\t\t\t\t//best point towards area2\n\t\t\t\t\t\t\tVectorCopy(end, water_bestend);\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end else\n\t\t\t\t} //end for\n\t\t\t} //end for\n\t\t} //end for\n\t} //end for\n\t//\n\t// NOTE: swim reachabilities are already filtered out\n\t//\n\t// Steps\n\t//\n\t//        ---------\n\t//        |          step height -> TRAVEL_WALK\n\t//--------|\n\t//\n\t//        ---------\n\t//~~~~~~~~|          step height and low water -> TRAVEL_WALK\n\t//--------|\n\t//\n\t//~~~~~~~~~~~~~~~~~~\n\t//        ---------\n\t//        |          step height and low water up to the step -> TRAVEL_WALK\n\t//--------|\n\t//\n\t//check for a step reachability\n\tif (ground_foundreach)\n\t{\n\t\t//if area2 is higher but lower than the maximum step height\n\t\t//NOTE: ground_bestdist >= 0 also catches equal floor reachabilities\n\t\tif (ground_bestdist >= 0 && ground_bestdist < aassettings.phys_maxstep)\n\t\t{\n\t\t\t//create walk reachability from area1 to area2\n\t\t\tlreach = AAS_AllocReachability();\n\t\t\tif (!lreach) return qfalse;\n\t\t\tlreach->areanum = area2num;\n\t\t\tlreach->facenum = 0;\n\t\t\tlreach->edgenum = ground_bestarea2groundedgenum;\n\t\t\tVectorMA(ground_beststart, INSIDEUNITS_WALKSTART, ground_bestnormal, lreach->start);\n\t\t\tVectorMA(ground_bestend, INSIDEUNITS_WALKEND, ground_bestnormal, lreach->end);\n\t\t\tlreach->traveltype = TRAVEL_WALK;\n\t\t\tlreach->traveltime = 0;//1;\n\t\t\t//if going into a crouch area\n\t\t\tif (!AAS_AreaCrouch(area1num) && AAS_AreaCrouch(area2num))\n\t\t\t{\n\t\t\t\tlreach->traveltime += aassettings.rs_startcrouch;\n\t\t\t} //end if\n\t\t\tlreach->next = areareachability[area1num];\n\t\t\tareareachability[area1num] = lreach;\n\t\t\t//NOTE: if there's nearby solid or a gap area after this area\n\t\t\t/*\n\t\t\tif (!AAS_NearbySolidOrGap(lreach->start, lreach->end))\n\t\t\t{\n\t\t\t\tlreach->traveltime += 100;\n\t\t\t} //end if\n\t\t\t*/\n\t\t\t//avoid rather small areas\n\t\t\t//if (AAS_AreaGroundFaceArea(lreach->areanum) < 500) lreach->traveltime += 100;\n\t\t\t//\n\t\t\treach_step++;\n\t\t\treturn qtrue;\n\t\t} //end if\n\t} //end if\n\t//\n\t// Water Jumps\n\t//\n\t//        ---------\n\t//        |\n\t//~~~~~~~~|\n\t//        |\n\t//        |          higher than step height and water up to waterjump height -> TRAVEL_WATERJUMP\n\t//--------|\n\t//\n\t//~~~~~~~~~~~~~~~~~~\n\t//        ---------\n\t//        |\n\t//        |\n\t//        |\n\t//        |          higher than step height and low water up to the step -> TRAVEL_WATERJUMP\n\t//--------|\n\t//\n\t//check for a waterjump reachability\n\tif (water_foundreach)\n\t{\n\t\t//get a test point a little bit towards area1\n\t\tVectorMA(water_bestend, -INSIDEUNITS, water_bestnormal, testpoint);\n\t\t//go down the maximum waterjump height\n\t\ttestpoint[2] -= aassettings.phys_maxwaterjump;\n\t\t//if there IS water the sv_maxwaterjump height below the bestend point\n\t\tif (aasworld.areasettings[AAS_PointAreaNum(testpoint)].areaflags & AREA_LIQUID)\n\t\t{\n\t\t\t//don't create rediculous water jump reachabilities from areas very far below\n\t\t\t//the water surface\n\t\t\tif (water_bestdist < aassettings.phys_maxwaterjump + 24)\n\t\t\t{\n\t\t\t\t//waterjumping from or towards a crouch only area is not possible in Quake2\n\t\t\t\tif ((aasworld.areasettings[area1num].presencetype & PRESENCE_NORMAL) &&\n\t\t\t\t\t\t(aasworld.areasettings[area2num].presencetype & PRESENCE_NORMAL))\n\t\t\t\t{\n\t\t\t\t\t//create water jump reachability from area1 to area2\n\t\t\t\t\tlreach = AAS_AllocReachability();\n\t\t\t\t\tif (!lreach) return qfalse;\n\t\t\t\t\tlreach->areanum = area2num;\n\t\t\t\t\tlreach->facenum = 0;\n\t\t\t\t\tlreach->edgenum = water_bestarea2groundedgenum;\n\t\t\t\t\tVectorCopy(water_beststart, lreach->start);\n\t\t\t\t\tVectorMA(water_bestend, INSIDEUNITS_WATERJUMP, water_bestnormal, lreach->end);\n\t\t\t\t\tlreach->traveltype = TRAVEL_WATERJUMP;\n\t\t\t\t\tlreach->traveltime = aassettings.rs_waterjump;\n\t\t\t\t\tlreach->next = areareachability[area1num];\n\t\t\t\t\tareareachability[area1num] = lreach;\n\t\t\t\t\t//we've got another waterjump reachability\n\t\t\t\t\treach_waterjump++;\n\t\t\t\t\treturn qtrue;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end if\n\t} //end if\n\t//\n\t// Barrier Jumps\n\t//\n\t//        ---------\n\t//        |\n\t//        |\n\t//        |\n\t//        |         higher than step height lower than barrier height -> TRAVEL_BARRIERJUMP\n\t//--------|\n\t//\n\t//        ---------\n\t//        |\n\t//        |\n\t//        |\n\t//~~~~~~~~|         higher than step height lower than barrier height\n\t//--------|         and a thin layer of water in the area to jump from -> TRAVEL_BARRIERJUMP\n\t//\n\t//check for a barrier jump reachability\n\tif (ground_foundreach)\n\t{\n\t\t//if area2 is higher but lower than the maximum barrier jump height\n\t\tif (ground_bestdist > 0 && ground_bestdist < aassettings.phys_maxbarrier)\n\t\t{\n\t\t\t//if no water in area1 or a very thin layer of water on the ground\n\t\t\tif (!water_foundreach || (ground_bestdist - water_bestdist < 16))\n\t\t\t{\n\t\t\t\t//cannot perform a barrier jump towards or from a crouch area in Quake2\n\t\t\t\tif (!AAS_AreaCrouch(area1num) && !AAS_AreaCrouch(area2num))\n\t\t\t\t{\n\t\t\t\t\t//create barrier jump reachability from area1 to area2\n\t\t\t\t\tlreach = AAS_AllocReachability();\n\t\t\t\t\tif (!lreach) return qfalse;\n\t\t\t\t\tlreach->areanum = area2num;\n\t\t\t\t\tlreach->facenum = 0;\n\t\t\t\t\tlreach->edgenum = ground_bestarea2groundedgenum;\n\t\t\t\t\tVectorMA(ground_beststart, INSIDEUNITS_WALKSTART, ground_bestnormal, lreach->start);\n\t\t\t\t\tVectorMA(ground_bestend, INSIDEUNITS_WALKEND, ground_bestnormal, lreach->end);\n\t\t\t\t\tlreach->traveltype = TRAVEL_BARRIERJUMP;\n\t\t\t\t\tlreach->traveltime = aassettings.rs_barrierjump;//AAS_BarrierJumpTravelTime();\n\t\t\t\t\tlreach->next = areareachability[area1num];\n\t\t\t\t\tareareachability[area1num] = lreach;\n\t\t\t\t\t//we've got another barrierjump reachability\n\t\t\t\t\treach_barrier++;\n\t\t\t\t\treturn qtrue;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end if\n\t} //end if\n\t//\n\t// Walk and Walk Off Ledge\n\t//\n\t//--------|\n\t//        |          can walk or step back -> TRAVEL_WALK\n\t//        ---------\n\t//\n\t//--------|\n\t//        |\n\t//        |\n\t//        |\n\t//        |          cannot walk/step back -> TRAVEL_WALKOFFLEDGE\n\t//        ---------\n\t//\n\t//--------|\n\t//        |\n\t//        |~~~~~~~~\n\t//        |\n\t//        |          cannot step back but can waterjump back -> TRAVEL_WALKOFFLEDGE\n\t//        ---------  FIXME: create TRAVEL_WALK reach??\n\t//\n\t//check for a walk or walk off ledge reachability\n\tif (ground_foundreach)\n\t{\n\t\tif (ground_bestdist < 0)\n\t\t{\n\t\t\tif (ground_bestdist > -aassettings.phys_maxstep)\n\t\t\t{\n\t\t\t\t//create walk reachability from area1 to area2\n\t\t\t\tlreach = AAS_AllocReachability();\n\t\t\t\tif (!lreach) return qfalse;\n\t\t\t\tlreach->areanum = area2num;\n\t\t\t\tlreach->facenum = 0;\n\t\t\t\tlreach->edgenum = ground_bestarea2groundedgenum;\n\t\t\t\tVectorMA(ground_beststart, INSIDEUNITS_WALKSTART, ground_bestnormal, lreach->start);\n\t\t\t\tVectorMA(ground_bestend, INSIDEUNITS_WALKEND, ground_bestnormal, lreach->end);\n\t\t\t\tlreach->traveltype = TRAVEL_WALK;\n\t\t\t\tlreach->traveltime = 1;\n\t\t\t\tlreach->next = areareachability[area1num];\n\t\t\t\tareareachability[area1num] = lreach;\n\t\t\t\t//we've got another walk reachability\n\t\t\t\treach_walk++;\n\t\t\t\treturn qtrue;\n\t\t\t} //end if\n\t\t\t// if no maximum fall height set or less than the max\n\t\t\tif (!aassettings.rs_maxfallheight || fabs(ground_bestdist) < aassettings.rs_maxfallheight) {\n\t\t\t\t//trace a bounding box vertically to check for solids\n\t\t\t\tVectorMA(ground_bestend, INSIDEUNITS, ground_bestnormal, ground_bestend);\n\t\t\t\tVectorCopy(ground_bestend, start);\n\t\t\t\tstart[2] = ground_beststart[2];\n\t\t\t\tVectorCopy(ground_bestend, end);\n\t\t\t\tend[2] += 4;\n\t\t\t\ttrace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, -1);\n\t\t\t\t//if no solids were found\n\t\t\t\tif (!trace.startsolid && trace.fraction >= 1.0)\n\t\t\t\t{\n\t\t\t\t\t//the trace end point must be in the goal area\n\t\t\t\t\ttrace.endpos[2] += 1;\n\t\t\t\t\tif (AAS_PointAreaNum(trace.endpos) == area2num)\n\t\t\t\t\t{\n\t\t\t\t\t\t//if not going through a cluster portal\n\t\t\t\t\t\tnumareas = AAS_TraceAreas(start, end, areas, NULL, sizeof(areas) / sizeof(int));\n\t\t\t\t\t\tfor (i = 0; i < numareas; i++)\n\t\t\t\t\t\t\tif (AAS_AreaClusterPortal(areas[i]))\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tif (i >= numareas)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t//create a walk off ledge reachability from area1 to area2\n\t\t\t\t\t\t\tlreach = AAS_AllocReachability();\n\t\t\t\t\t\t\tif (!lreach) return qfalse;\n\t\t\t\t\t\t\tlreach->areanum = area2num;\n\t\t\t\t\t\t\tlreach->facenum = 0;\n\t\t\t\t\t\t\tlreach->edgenum = ground_bestarea2groundedgenum;\n\t\t\t\t\t\t\tVectorCopy(ground_beststart, lreach->start);\n\t\t\t\t\t\t\tVectorCopy(ground_bestend, lreach->end);\n\t\t\t\t\t\t\tlreach->traveltype = TRAVEL_WALKOFFLEDGE;\n\t\t\t\t\t\t\tlreach->traveltime = aassettings.rs_startwalkoffledge + fabs(ground_bestdist) * 50 / aassettings.phys_gravity;\n\t\t\t\t\t\t\t//if falling from too high and not falling into water\n\t\t\t\t\t\t\tif (!AAS_AreaSwim(area2num) && !AAS_AreaJumpPad(area2num))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (AAS_FallDelta(ground_bestdist) > aassettings.phys_falldelta5)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlreach->traveltime += aassettings.rs_falldamage5;\n\t\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\t\tif (AAS_FallDelta(ground_bestdist) > aassettings.phys_falldelta10)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlreach->traveltime += aassettings.rs_falldamage10;\n\t\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\tlreach->next = areareachability[area1num];\n\t\t\t\t\t\t\tareareachability[area1num] = lreach;\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\treach_walkoffledge++;\n\t\t\t\t\t\t\t//NOTE: don't create a weapon (rl, bfg) jump reachability here\n\t\t\t\t\t\t\t//because it interferes with other reachabilities\n\t\t\t\t\t\t\t//like the ladder reachability\n\t\t\t\t\t\t\treturn qtrue;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end else\n\t} //end if\n\treturn qfalse;\n} //end of the function AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge\n//===========================================================================\n// returns the distance between the two vectors\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat VectorDistance(vec3_t v1, vec3_t v2)\n{\n\tvec3_t dir;\n\n\tVectorSubtract(v2, v1, dir);\n\treturn VectorLength(dir);\n} //end of the function VectorDistance\n//===========================================================================\n// returns true if the first vector is between the last two vectors\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint VectorBetweenVectors(vec3_t v, vec3_t v1, vec3_t v2)\n{\n\tvec3_t dir1, dir2;\n\n\tVectorSubtract(v, v1, dir1);\n\tVectorSubtract(v, v2, dir2);\n\treturn (DotProduct(dir1, dir2) <= 0);\n} //end of the function VectorBetweenVectors\n//===========================================================================\n// returns the mid point between the two vectors\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid VectorMiddle(vec3_t v1, vec3_t v2, vec3_t middle)\n{\n\tVectorAdd(v1, v2, middle);\n\tVectorScale(middle, 0.5, middle);\n} //end of the function VectorMiddle\n//===========================================================================\n// calculate a range of points closest to each other on both edges\n//\n// Parameter:\t\t\tbeststart1\t\tstart of the range of points on edge v1-v2\n//\t\t\t\t\t\tbeststart2\t\tend of the range of points  on edge v1-v2\n//\t\t\t\t\t\tbestend1\t\tstart of the range of points on edge v3-v4\n//\t\t\t\t\t\tbestend2\t\tend of the range of points  on edge v3-v4\n//\t\t\t\t\t\tbestdist\t\tbest distance so far\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n/*\nfloat AAS_ClosestEdgePoints(vec3_t v1, vec3_t v2, vec3_t v3, vec3_t v4,\n\t\t\t\t\t\t\taas_plane_t *plane1, aas_plane_t *plane2,\n\t\t\t\t\t\t\tvec3_t beststart, vec3_t bestend, float bestdist)\n{\n\tvec3_t dir1, dir2, p1, p2, p3, p4;\n\tfloat a1, a2, b1, b2, dist;\n\tint founddist;\n\n\t//edge vectors\n\tVectorSubtract(v2, v1, dir1);\n\tVectorSubtract(v4, v3, dir2);\n\t//get the horizontal directions\n\tdir1[2] = 0;\n\tdir2[2] = 0;\n\t//\n\t// p1 = point on an edge vector of area2 closest to v1\n\t// p2 = point on an edge vector of area2 closest to v2\n\t// p3 = point on an edge vector of area1 closest to v3\n\t// p4 = point on an edge vector of area1 closest to v4\n\t//\n\tif (dir2[0])\n\t{\n\t\ta2 = dir2[1] / dir2[0];\n\t\tb2 = v3[1] - a2 * v3[0];\n\t\t//point on the edge vector of area2 closest to v1\n\t\tp1[0] = (DotProduct(v1, dir2) - (a2 * dir2[0] + b2 * dir2[1])) / dir2[0];\n\t\tp1[1] = a2 * p1[0] + b2;\n\t\t//point on the edge vector of area2 closest to v2\n\t\tp2[0] = (DotProduct(v2, dir2) - (a2 * dir2[0] + b2 * dir2[1])) / dir2[0];\n\t\tp2[1] = a2 * p2[0] + b2;\n\t} //end if\n\telse\n\t{\n\t\t//point on the edge vector of area2 closest to v1\n\t\tp1[0] = v3[0];\n\t\tp1[1] = v1[1];\n\t\t//point on the edge vector of area2 closest to v2\n\t\tp2[0] = v3[0];\n\t\tp2[1] = v2[1];\n\t} //end else\n\t//\n\tif (dir1[0])\n\t{\n\t\t//\n\t\ta1 = dir1[1] / dir1[0];\n\t\tb1 = v1[1] - a1 * v1[0];\n\t\t//point on the edge vector of area1 closest to v3\n\t\tp3[0] = (DotProduct(v3, dir1) - (a1 * dir1[0] + b1 * dir1[1])) / dir1[0];\n\t\tp3[1] = a1 * p3[0] + b1;\n\t\t//point on the edge vector of area1 closest to v4\n\t\tp4[0] = (DotProduct(v4, dir1) - (a1 * dir1[0] + b1 * dir1[1])) / dir1[0];\n\t\tp4[1] = a1 * p4[0] + b1;\n\t} //end if\n\telse\n\t{\n\t\t//point on the edge vector of area1 closest to v3\n\t\tp3[0] = v1[0];\n\t\tp3[1] = v3[1];\n\t\t//point on the edge vector of area1 closest to v4\n\t\tp4[0] = v1[0];\n\t\tp4[1] = v4[1];\n\t} //end else\n\t//start with zero z-coordinates\n\tp1[2] = 0;\n\tp2[2] = 0;\n\tp3[2] = 0;\n\tp4[2] = 0;\n\t//calculate the z-coordinates from the ground planes\n\tp1[2] = (plane2->dist - DotProduct(plane2->normal, p1)) / plane2->normal[2];\n\tp2[2] = (plane2->dist - DotProduct(plane2->normal, p2)) / plane2->normal[2];\n\tp3[2] = (plane1->dist - DotProduct(plane1->normal, p3)) / plane1->normal[2];\n\tp4[2] = (plane1->dist - DotProduct(plane1->normal, p4)) / plane1->normal[2];\n\t//\n\tfounddist = qfalse;\n\t//\n\tif (VectorBetweenVectors(p1, v3, v4))\n\t{\n\t\tdist = VectorDistance(v1, p1);\n\t\tif (dist > bestdist - 0.5 && dist < bestdist + 0.5)\n\t\t{\n\t\t\tVectorMiddle(beststart, v1, beststart);\n\t\t\tVectorMiddle(bestend, p1, bestend);\n\t\t} //end if\n\t\telse if (dist < bestdist)\n\t\t{\n\t\t\tbestdist = dist;\n\t\t\tVectorCopy(v1, beststart);\n\t\t\tVectorCopy(p1, bestend);\n\t\t} //end if\n\t\tfounddist = qtrue;\n\t} //end if\n\tif (VectorBetweenVectors(p2, v3, v4))\n\t{\n\t\tdist = VectorDistance(v2, p2);\n\t\tif (dist > bestdist - 0.5 && dist < bestdist + 0.5)\n\t\t{\n\t\t\tVectorMiddle(beststart, v2, beststart);\n\t\t\tVectorMiddle(bestend, p2, bestend);\n\t\t} //end if\n\t\telse if (dist < bestdist)\n\t\t{\n\t\t\tbestdist = dist;\n\t\t\tVectorCopy(v2, beststart);\n\t\t\tVectorCopy(p2, bestend);\n\t\t} //end if\n\t\tfounddist = qtrue;\n\t} //end else if\n\tif (VectorBetweenVectors(p3, v1, v2))\n\t{\n\t\tdist = VectorDistance(v3, p3);\n\t\tif (dist > bestdist - 0.5 && dist < bestdist + 0.5)\n\t\t{\n\t\t\tVectorMiddle(beststart, p3, beststart);\n\t\t\tVectorMiddle(bestend, v3, bestend);\n\t\t} //end if\n\t\telse if (dist < bestdist)\n\t\t{\n\t\t\tbestdist = dist;\n\t\t\tVectorCopy(p3, beststart);\n\t\t\tVectorCopy(v3, bestend);\n\t\t} //end if\n\t\tfounddist = qtrue;\n\t} //end else if\n\tif (VectorBetweenVectors(p4, v1, v2))\n\t{\n\t\tdist = VectorDistance(v4, p4);\n\t\tif (dist > bestdist - 0.5 && dist < bestdist + 0.5)\n\t\t{\n\t\t\tVectorMiddle(beststart, p4, beststart);\n\t\t\tVectorMiddle(bestend, v4, bestend);\n\t\t} //end if\n\t\telse if (dist < bestdist)\n\t\t{\n\t\t\tbestdist = dist;\n\t\t\tVectorCopy(p4, beststart);\n\t\t\tVectorCopy(v4, bestend);\n\t\t} //end if\n\t\tfounddist = qtrue;\n\t} //end else if\n\t//if no shortest distance was found the shortest distance\n\t//is between one of the vertexes of edge1 and one of edge2\n\tif (!founddist)\n\t{\n\t\tdist = VectorDistance(v1, v3);\n\t\tif (dist < bestdist)\n\t\t{\n\t\t\tbestdist = dist;\n\t\t\tVectorCopy(v1, beststart);\n\t\t\tVectorCopy(v3, bestend);\n\t\t} //end if\n\t\tdist = VectorDistance(v1, v4);\n\t\tif (dist < bestdist)\n\t\t{\n\t\t\tbestdist = dist;\n\t\t\tVectorCopy(v1, beststart);\n\t\t\tVectorCopy(v4, bestend);\n\t\t} //end if\n\t\tdist = VectorDistance(v2, v3);\n\t\tif (dist < bestdist)\n\t\t{\n\t\t\tbestdist = dist;\n\t\t\tVectorCopy(v2, beststart);\n\t\t\tVectorCopy(v3, bestend);\n\t\t} //end if\n\t\tdist = VectorDistance(v2, v4);\n\t\tif (dist < bestdist)\n\t\t{\n\t\t\tbestdist = dist;\n\t\t\tVectorCopy(v2, beststart);\n\t\t\tVectorCopy(v4, bestend);\n\t\t} //end if\n\t} //end if\n\treturn bestdist;\n} //end of the function AAS_ClosestEdgePoints*/\n\nfloat AAS_ClosestEdgePoints(vec3_t v1, vec3_t v2, vec3_t v3, vec3_t v4,\n\t\t\t\t\t\t\taas_plane_t *plane1, aas_plane_t *plane2,\n\t\t\t\t\t\t\tvec3_t beststart1, vec3_t bestend1,\n\t\t\t\t\t\t\tvec3_t beststart2, vec3_t bestend2, float bestdist)\n{\n\tvec3_t dir1, dir2, p1, p2, p3, p4;\n\tfloat a1, a2, b1, b2, dist, dist1, dist2;\n\tint founddist;\n\n\t//edge vectors\n\tVectorSubtract(v2, v1, dir1);\n\tVectorSubtract(v4, v3, dir2);\n\t//get the horizontal directions\n\tdir1[2] = 0;\n\tdir2[2] = 0;\n\t//\n\t// p1 = point on an edge vector of area2 closest to v1\n\t// p2 = point on an edge vector of area2 closest to v2\n\t// p3 = point on an edge vector of area1 closest to v3\n\t// p4 = point on an edge vector of area1 closest to v4\n\t//\n\tif (dir2[0])\n\t{\n\t\ta2 = dir2[1] / dir2[0];\n\t\tb2 = v3[1] - a2 * v3[0];\n\t\t//point on the edge vector of area2 closest to v1\n\t\tp1[0] = (DotProduct(v1, dir2) - (a2 * dir2[0] + b2 * dir2[1])) / dir2[0];\n\t\tp1[1] = a2 * p1[0] + b2;\n\t\t//point on the edge vector of area2 closest to v2\n\t\tp2[0] = (DotProduct(v2, dir2) - (a2 * dir2[0] + b2 * dir2[1])) / dir2[0];\n\t\tp2[1] = a2 * p2[0] + b2;\n\t} //end if\n\telse\n\t{\n\t\t//point on the edge vector of area2 closest to v1\n\t\tp1[0] = v3[0];\n\t\tp1[1] = v1[1];\n\t\t//point on the edge vector of area2 closest to v2\n\t\tp2[0] = v3[0];\n\t\tp2[1] = v2[1];\n\t} //end else\n\t//\n\tif (dir1[0])\n\t{\n\t\t//\n\t\ta1 = dir1[1] / dir1[0];\n\t\tb1 = v1[1] - a1 * v1[0];\n\t\t//point on the edge vector of area1 closest to v3\n\t\tp3[0] = (DotProduct(v3, dir1) - (a1 * dir1[0] + b1 * dir1[1])) / dir1[0];\n\t\tp3[1] = a1 * p3[0] + b1;\n\t\t//point on the edge vector of area1 closest to v4\n\t\tp4[0] = (DotProduct(v4, dir1) - (a1 * dir1[0] + b1 * dir1[1])) / dir1[0];\n\t\tp4[1] = a1 * p4[0] + b1;\n\t} //end if\n\telse\n\t{\n\t\t//point on the edge vector of area1 closest to v3\n\t\tp3[0] = v1[0];\n\t\tp3[1] = v3[1];\n\t\t//point on the edge vector of area1 closest to v4\n\t\tp4[0] = v1[0];\n\t\tp4[1] = v4[1];\n\t} //end else\n\t//start with zero z-coordinates\n\tp1[2] = 0;\n\tp2[2] = 0;\n\tp3[2] = 0;\n\tp4[2] = 0;\n\t//calculate the z-coordinates from the ground planes\n\tp1[2] = (plane2->dist - DotProduct(plane2->normal, p1)) / plane2->normal[2];\n\tp2[2] = (plane2->dist - DotProduct(plane2->normal, p2)) / plane2->normal[2];\n\tp3[2] = (plane1->dist - DotProduct(plane1->normal, p3)) / plane1->normal[2];\n\tp4[2] = (plane1->dist - DotProduct(plane1->normal, p4)) / plane1->normal[2];\n\t//\n\tfounddist = qfalse;\n\t//\n\tif (VectorBetweenVectors(p1, v3, v4))\n\t{\n\t\tdist = VectorDistance(v1, p1);\n\t\tif (dist > bestdist - 0.5 && dist < bestdist + 0.5)\n\t\t{\n\t\t\tdist1 = VectorDistance(beststart1, v1);\n\t\t\tdist2 = VectorDistance(beststart2, v1);\n\t\t\tif (dist1 > dist2)\n\t\t\t{\n\t\t\t\tif (dist1 > VectorDistance(beststart1, beststart2)) VectorCopy(v1, beststart2);\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (dist2 > VectorDistance(beststart1, beststart2)) VectorCopy(v1, beststart1);\n\t\t\t} //end else\n\t\t\tdist1 = VectorDistance(bestend1, p1);\n\t\t\tdist2 = VectorDistance(bestend2, p1);\n\t\t\tif (dist1 > dist2)\n\t\t\t{\n\t\t\t\tif (dist1 > VectorDistance(bestend1, bestend2)) VectorCopy(p1, bestend2);\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (dist2 > VectorDistance(bestend1, bestend2)) VectorCopy(p1, bestend1);\n\t\t\t} //end else\n\t\t} //end if\n\t\telse if (dist < bestdist)\n\t\t{\n\t\t\tbestdist = dist;\n\t\t\tVectorCopy(v1, beststart1);\n\t\t\tVectorCopy(v1, beststart2);\n\t\t\tVectorCopy(p1, bestend1);\n\t\t\tVectorCopy(p1, bestend2);\n\t\t} //end if\n\t\tfounddist = qtrue;\n\t} //end if\n\tif (VectorBetweenVectors(p2, v3, v4))\n\t{\n\t\tdist = VectorDistance(v2, p2);\n\t\tif (dist > bestdist - 0.5 && dist < bestdist + 0.5)\n\t\t{\n\t\t\tdist1 = VectorDistance(beststart1, v2);\n\t\t\tdist2 = VectorDistance(beststart2, v2);\n\t\t\tif (dist1 > dist2)\n\t\t\t{\n\t\t\t\tif (dist1 > VectorDistance(beststart1, beststart2)) VectorCopy(v2, beststart2);\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (dist2 > VectorDistance(beststart1, beststart2)) VectorCopy(v2, beststart1);\n\t\t\t} //end else\n\t\t\tdist1 = VectorDistance(bestend1, p2);\n\t\t\tdist2 = VectorDistance(bestend2, p2);\n\t\t\tif (dist1 > dist2)\n\t\t\t{\n\t\t\t\tif (dist1 > VectorDistance(bestend1, bestend2)) VectorCopy(p2, bestend2);\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (dist2 > VectorDistance(bestend1, bestend2)) VectorCopy(p2, bestend1);\n\t\t\t} //end else\n\t\t} //end if\n\t\telse if (dist < bestdist)\n\t\t{\n\t\t\tbestdist = dist;\n\t\t\tVectorCopy(v2, beststart1);\n\t\t\tVectorCopy(v2, beststart2);\n\t\t\tVectorCopy(p2, bestend1);\n\t\t\tVectorCopy(p2, bestend2);\n\t\t} //end if\n\t\tfounddist = qtrue;\n\t} //end else if\n\tif (VectorBetweenVectors(p3, v1, v2))\n\t{\n\t\tdist = VectorDistance(v3, p3);\n\t\tif (dist > bestdist - 0.5 && dist < bestdist + 0.5)\n\t\t{\n\t\t\tdist1 = VectorDistance(beststart1, p3);\n\t\t\tdist2 = VectorDistance(beststart2, p3);\n\t\t\tif (dist1 > dist2)\n\t\t\t{\n\t\t\t\tif (dist1 > VectorDistance(beststart1, beststart2)) VectorCopy(p3, beststart2);\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (dist2 > VectorDistance(beststart1, beststart2)) VectorCopy(p3, beststart1);\n\t\t\t} //end else\n\t\t\tdist1 = VectorDistance(bestend1, v3);\n\t\t\tdist2 = VectorDistance(bestend2, v3);\n\t\t\tif (dist1 > dist2)\n\t\t\t{\n\t\t\t\tif (dist1 > VectorDistance(bestend1, bestend2)) VectorCopy(v3, bestend2);\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (dist2 > VectorDistance(bestend1, bestend2)) VectorCopy(v3, bestend1);\n\t\t\t} //end else\n\t\t} //end if\n\t\telse if (dist < bestdist)\n\t\t{\n\t\t\tbestdist = dist;\n\t\t\tVectorCopy(p3, beststart1);\n\t\t\tVectorCopy(p3, beststart2);\n\t\t\tVectorCopy(v3, bestend1);\n\t\t\tVectorCopy(v3, bestend2);\n\t\t} //end if\n\t\tfounddist = qtrue;\n\t} //end else if\n\tif (VectorBetweenVectors(p4, v1, v2))\n\t{\n\t\tdist = VectorDistance(v4, p4);\n\t\tif (dist > bestdist - 0.5 && dist < bestdist + 0.5)\n\t\t{\n\t\t\tdist1 = VectorDistance(beststart1, p4);\n\t\t\tdist2 = VectorDistance(beststart2, p4);\n\t\t\tif (dist1 > dist2)\n\t\t\t{\n\t\t\t\tif (dist1 > VectorDistance(beststart1, beststart2)) VectorCopy(p4, beststart2);\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (dist2 > VectorDistance(beststart1, beststart2)) VectorCopy(p4, beststart1);\n\t\t\t} //end else\n\t\t\tdist1 = VectorDistance(bestend1, v4);\n\t\t\tdist2 = VectorDistance(bestend2, v4);\n\t\t\tif (dist1 > dist2)\n\t\t\t{\n\t\t\t\tif (dist1 > VectorDistance(bestend1, bestend2)) VectorCopy(v4, bestend2);\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (dist2 > VectorDistance(bestend1, bestend2)) VectorCopy(v4, bestend1);\n\t\t\t} //end else\n\t\t} //end if\n\t\telse if (dist < bestdist)\n\t\t{\n\t\t\tbestdist = dist;\n\t\t\tVectorCopy(p4, beststart1);\n\t\t\tVectorCopy(p4, beststart2);\n\t\t\tVectorCopy(v4, bestend1);\n\t\t\tVectorCopy(v4, bestend2);\n\t\t} //end if\n\t\tfounddist = qtrue;\n\t} //end else if\n\t//if no shortest distance was found the shortest distance\n\t//is between one of the vertexes of edge1 and one of edge2\n\tif (!founddist)\n\t{\n\t\tdist = VectorDistance(v1, v3);\n\t\tif (dist < bestdist)\n\t\t{\n\t\t\tbestdist = dist;\n\t\t\tVectorCopy(v1, beststart1);\n\t\t\tVectorCopy(v1, beststart2);\n\t\t\tVectorCopy(v3, bestend1);\n\t\t\tVectorCopy(v3, bestend2);\n\t\t} //end if\n\t\tdist = VectorDistance(v1, v4);\n\t\tif (dist < bestdist)\n\t\t{\n\t\t\tbestdist = dist;\n\t\t\tVectorCopy(v1, beststart1);\n\t\t\tVectorCopy(v1, beststart2);\n\t\t\tVectorCopy(v4, bestend1);\n\t\t\tVectorCopy(v4, bestend2);\n\t\t} //end if\n\t\tdist = VectorDistance(v2, v3);\n\t\tif (dist < bestdist)\n\t\t{\n\t\t\tbestdist = dist;\n\t\t\tVectorCopy(v2, beststart1);\n\t\t\tVectorCopy(v2, beststart2);\n\t\t\tVectorCopy(v3, bestend1);\n\t\t\tVectorCopy(v3, bestend2);\n\t\t} //end if\n\t\tdist = VectorDistance(v2, v4);\n\t\tif (dist < bestdist)\n\t\t{\n\t\t\tbestdist = dist;\n\t\t\tVectorCopy(v2, beststart1);\n\t\t\tVectorCopy(v2, beststart2);\n\t\t\tVectorCopy(v4, bestend1);\n\t\t\tVectorCopy(v4, bestend2);\n\t\t} //end if\n\t} //end if\n\treturn bestdist;\n} //end of the function AAS_ClosestEdgePoints\n//===========================================================================\n// creates possible jump reachabilities between the areas\n//\n// The two closest points on the ground of the areas are calculated\n// One of the points will be on an edge of a ground face of area1 and\n// one on an edge of a ground face of area2.\n// If there is a range of closest points the point in the middle of this range\n// is selected.\n// Between these two points there must be one or more gaps.\n// If the gaps exist a potential jump is predicted.\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_Reachability_Jump(int area1num, int area2num)\n{\n\tint i, j, k, l, face1num, face2num, edge1num, edge2num, traveltype;\n\tint stopevent, areas[10], numareas;\n\tfloat phys_jumpvel, maxjumpdistance, maxjumpheight, height, bestdist, speed;\n\tvec_t *v1, *v2, *v3, *v4;\n\tvec3_t beststart, beststart2, bestend, bestend2;\n\tvec3_t teststart, testend, dir, velocity, cmdmove, up = {0, 0, 1}, sidewards;\n\taas_area_t *area1, *area2;\n\taas_face_t *face1, *face2;\n\taas_edge_t *edge1, *edge2;\n\taas_plane_t *plane1, *plane2, *plane;\n\taas_trace_t trace;\n\taas_clientmove_t move;\n\taas_lreachability_t *lreach;\n\n\tif (!AAS_AreaGrounded(area1num) || !AAS_AreaGrounded(area2num)) return qfalse;\n\t//cannot jump from or to a crouch area\n\tif (AAS_AreaCrouch(area1num) || AAS_AreaCrouch(area2num)) return qfalse;\n\t//\n\tarea1 = &aasworld.areas[area1num];\n\tarea2 = &aasworld.areas[area2num];\n\t//\n\tphys_jumpvel = aassettings.phys_jumpvel;\n\t//maximum distance a player can jump\n\tmaxjumpdistance = 2 * AAS_MaxJumpDistance(phys_jumpvel);\n\t//maximum height a player can jump with the given initial z velocity\n\tmaxjumpheight = AAS_MaxJumpHeight(phys_jumpvel);\n\n\t//if the areas are not near anough in the x-y direction\n\tfor (i = 0; i < 2; i++)\n\t{\n\t\tif (area1->mins[i] > area2->maxs[i] + maxjumpdistance) return qfalse;\n\t\tif (area1->maxs[i] < area2->mins[i] - maxjumpdistance) return qfalse;\n\t} //end for\n\t//if area2 is way to high to jump up to\n\tif (area2->mins[2] > area1->maxs[2] + maxjumpheight) return qfalse;\n\t//\n\tbestdist = 999999;\n\t//\n\tfor (i = 0; i < area1->numfaces; i++)\n\t{\n\t\tface1num = aasworld.faceindex[area1->firstface + i];\n\t\tface1 = &aasworld.faces[abs(face1num)];\n\t\t//if not a ground face\n\t\tif (!(face1->faceflags & FACE_GROUND)) continue;\n\t\t//\n\t\tfor (j = 0; j < area2->numfaces; j++)\n\t\t{\n\t\t\tface2num = aasworld.faceindex[area2->firstface + j];\n\t\t\tface2 = &aasworld.faces[abs(face2num)];\n\t\t\t//if not a ground face\n\t\t\tif (!(face2->faceflags & FACE_GROUND)) continue;\n\t\t\t//\n\t\t\tfor (k = 0; k < face1->numedges; k++)\n\t\t\t{\n\t\t\t\tedge1num = abs(aasworld.edgeindex[face1->firstedge + k]);\n\t\t\t\tedge1 = &aasworld.edges[edge1num];\n\t\t\t\tfor (l = 0; l < face2->numedges; l++)\n\t\t\t\t{\n\t\t\t\t\tedge2num = abs(aasworld.edgeindex[face2->firstedge + l]);\n\t\t\t\t\tedge2 = &aasworld.edges[edge2num];\n\t\t\t\t\t//calculate the minimum distance between the two edges\n\t\t\t\t\tv1 = aasworld.vertexes[edge1->v[0]];\n\t\t\t\t\tv2 = aasworld.vertexes[edge1->v[1]];\n\t\t\t\t\tv3 = aasworld.vertexes[edge2->v[0]];\n\t\t\t\t\tv4 = aasworld.vertexes[edge2->v[1]];\n\t\t\t\t\t//get the ground planes\n\t\t\t\t\tplane1 = &aasworld.planes[face1->planenum];\n\t\t\t\t\tplane2 = &aasworld.planes[face2->planenum];\n\t\t\t\t\t//\n\t\t\t\t\tbestdist = AAS_ClosestEdgePoints(v1, v2, v3, v4, plane1, plane2,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tbeststart, bestend,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tbeststart2, bestend2, bestdist);\n\t\t\t\t} //end for\n\t\t\t} //end for\n\t\t} //end for\n\t} //end for\n\tVectorMiddle(beststart, beststart2, beststart);\n\tVectorMiddle(bestend, bestend2, bestend);\n\tif (bestdist > 4 && bestdist < maxjumpdistance)\n\t{\n//\t\tLog_Write(\"shortest distance between %d and %d is %f\\r\\n\", area1num, area2num, bestdist);\n\t\t// if very close and almost no height difference then the bot can walk\n\t\tif (bestdist <= 48 && fabs(beststart[2] - bestend[2]) < 8)\n\t\t{\n\t\t\tspeed = 400;\n\t\t\ttraveltype = TRAVEL_WALKOFFLEDGE;\n\t\t} //end if\n\t\telse if (AAS_HorizontalVelocityForJump(0, beststart, bestend, &speed))\n\t\t{\n\t\t\t//FIXME: why multiply with 1.2???\n\t\t\tspeed *= 1.2f;\n\t\t\ttraveltype = TRAVEL_WALKOFFLEDGE;\n\t\t} //end else if\n\t\telse\n\t\t{\n\t\t\t//get the horizontal speed for the jump, if it isn't possible to calculate this\n\t\t\t//speed (the jump is not possible) then there's no jump reachability created\n\t\t\tif (!AAS_HorizontalVelocityForJump(phys_jumpvel, beststart, bestend, &speed))\n\t\t\t\treturn qfalse;\n\t\t\tspeed *= 1.05f;\n\t\t\ttraveltype = TRAVEL_JUMP;\n\t\t\t//\n\t\t\t//NOTE: test if the horizontal distance isn't too small\n\t\t\tVectorSubtract(bestend, beststart, dir);\n\t\t\tdir[2] = 0;\n\t\t\tif (VectorLength(dir) < 10)\n\t\t\t\treturn qfalse;\n\t\t} //end if\n\t\t//\n\t\tVectorSubtract(bestend, beststart, dir);\n\t\tVectorNormalize(dir);\n\t\tVectorMA(beststart, 1, dir, teststart);\n\t\t//\n\t\tVectorCopy(teststart, testend);\n\t\ttestend[2] -= 100;\n\t\ttrace = AAS_TraceClientBBox(teststart, testend, PRESENCE_NORMAL, -1);\n\t\t//\n\t\tif (trace.startsolid)\n\t\t\treturn qfalse;\n\t\tif (trace.fraction < 1)\n\t\t{\n\t\t\tplane = &aasworld.planes[trace.planenum];\n\t\t\t// if the bot can stand on the surface\n\t\t\tif (DotProduct(plane->normal, up) >= 0.7)\n\t\t\t{\n\t\t\t\t// if no lava or slime below\n\t\t\t\tif (!(AAS_PointContents(trace.endpos) & (CONTENTS_LAVA|CONTENTS_SLIME)))\n\t\t\t\t{\n\t\t\t\t\tif (teststart[2] - trace.endpos[2] <= aassettings.phys_maxbarrier)\n\t\t\t\t\t\treturn qfalse;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end if\n\t\t//\n\t\tVectorMA(bestend, -1, dir, teststart);\n\t\t//\n\t\tVectorCopy(teststart, testend);\n\t\ttestend[2] -= 100;\n\t\ttrace = AAS_TraceClientBBox(teststart, testend, PRESENCE_NORMAL, -1);\n\t\t//\n\t\tif (trace.startsolid)\n\t\t\treturn qfalse;\n\t\tif (trace.fraction < 1)\n\t\t{\n\t\t\tplane = &aasworld.planes[trace.planenum];\n\t\t\t// if the bot can stand on the surface\n\t\t\tif (DotProduct(plane->normal, up) >= 0.7)\n\t\t\t{\n\t\t\t\t// if no lava or slime below\n\t\t\t\tif (!(AAS_PointContents(trace.endpos) & (CONTENTS_LAVA|CONTENTS_SLIME)))\n\t\t\t\t{\n\t\t\t\t\tif (teststart[2] - trace.endpos[2] <= aassettings.phys_maxbarrier)\n\t\t\t\t\t\treturn qfalse;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end if\n\t\t//\n\t\t// get command movement\n\t\tVectorClear(cmdmove);\n\t\tif ((traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMP)\n\t\t\tcmdmove[2] = aassettings.phys_jumpvel;\n\t\telse\n\t\t\tcmdmove[2] = 0;\n\t\t//\n\t\tVectorSubtract(bestend, beststart, dir);\n\t\tdir[2] = 0;\n\t\tVectorNormalize(dir);\n\t\tCrossProduct(dir, up, sidewards);\n\t\t//\n\t\tstopevent = SE_HITGROUND|SE_ENTERWATER|SE_ENTERSLIME|SE_ENTERLAVA|SE_HITGROUNDDAMAGE;\n\t\tif (!AAS_AreaClusterPortal(area1num) && !AAS_AreaClusterPortal(area2num))\n\t\t\tstopevent |= SE_TOUCHCLUSTERPORTAL;\n\t\t//\n\t\tfor (i = 0; i < 3; i++)\n\t\t{\n\t\t\t//\n\t\t\tif (i == 1)\n\t\t\t\tVectorAdd(testend, sidewards, testend);\n\t\t\telse if (i == 2)\n\t\t\t\tVectorSubtract(bestend, sidewards, testend);\n\t\t\telse\n\t\t\t\tVectorCopy(bestend, testend);\n\t\t\tVectorSubtract(testend, beststart, dir);\n\t\t\tdir[2] = 0;\n\t\t\tVectorNormalize(dir);\n\t\t\tVectorScale(dir, speed, velocity);\n\t\t\t//\n\t\t\tAAS_PredictClientMovement(&move, -1, beststart, PRESENCE_NORMAL, qtrue,\n\t\t\t\t\t\t\t\t\t\tvelocity, cmdmove, 3, 30, 0.1f,\n\t\t\t\t\t\t\t\t\t\tstopevent, 0, qfalse);\n\t\t\t// if prediction time wasn't enough to fully predict the movement\n\t\t\tif (move.frames >= 30)\n\t\t\t\treturn qfalse;\n\t\t\t// don't enter slime or lava and don't fall from too high\n\t\t\tif (move.stopevent & (SE_ENTERSLIME|SE_ENTERLAVA))\n\t\t\t\treturn qfalse;\n\t\t\t// never jump or fall through a cluster portal\n\t\t\tif (move.stopevent & SE_TOUCHCLUSTERPORTAL)\n\t\t\t\treturn qfalse;\n\t\t\t//the end position should be in area2, also test a little bit back\n\t\t\t//because the predicted jump could have rushed through the area\n\t\t\tVectorMA(move.endpos, -64, dir, teststart);\n\t\t\tteststart[2] += 1;\n\t\t\tnumareas = AAS_TraceAreas(move.endpos, teststart, areas, NULL, sizeof(areas) / sizeof(int));\n\t\t\tfor (j = 0; j < numareas; j++)\n\t\t\t{\n\t\t\t\tif (areas[j] == area2num)\n\t\t\t\t\tbreak;\n\t\t\t} //end for\n\t\t\tif (j < numareas)\n\t\t\t\tbreak;\n\t\t}\n\t\tif (i >= 3)\n\t\t\treturn qfalse;\n\t\t//\n#ifdef REACH_DEBUG\n\t\t//create the reachability\n\t\tLog_Write(\"jump reachability between %d and %d\\r\\n\", area1num, area2num);\n#endif //REACH_DEBUG\n\t\t//create a new reachability link\n\t\tlreach = AAS_AllocReachability();\n\t\tif (!lreach) return qfalse;\n\t\tlreach->areanum = area2num;\n\t\tlreach->facenum = 0;\n\t\tlreach->edgenum = 0;\n\t\tVectorCopy(beststart, lreach->start);\n\t\tVectorCopy(bestend, lreach->end);\n\t\tlreach->traveltype = traveltype;\n\n\t\tVectorSubtract(bestend, beststart, dir);\n\t\theight = dir[2];\n\t\tdir[2] = 0;\n\t\tif ((traveltype & TRAVELTYPE_MASK) == TRAVEL_WALKOFFLEDGE && height > VectorLength(dir))\n\t\t{\n\t\t\tlreach->traveltime = aassettings.rs_startwalkoffledge + height * 50 / aassettings.phys_gravity;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tlreach->traveltime = aassettings.rs_startjump + VectorDistance(bestend, beststart) * 240 / aassettings.phys_maxwalkvelocity;\n\t\t} //end if\n\t\t//\n\t\tif (!AAS_AreaJumpPad(area2num))\n\t\t{\n\t\t\tif (AAS_FallDelta(beststart[2] - bestend[2]) > aassettings.phys_falldelta5)\n\t\t\t{\n\t\t\t\tlreach->traveltime += aassettings.rs_falldamage5;\n\t\t\t} //end if\n\t\t\telse if (AAS_FallDelta(beststart[2] - bestend[2]) > aassettings.phys_falldelta10)\n\t\t\t{\n\t\t\t\tlreach->traveltime += aassettings.rs_falldamage10;\n\t\t\t} //end if\n\t\t} //end if\n\t\tlreach->next = areareachability[area1num];\n\t\tareareachability[area1num] = lreach;\n\t\t//\n\t\tif ((traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMP)\n\t\t\treach_jump++;\n\t\telse\n\t\t\treach_walkoffledge++;\n\t} //end if\n\treturn qfalse;\n} //end of the function AAS_Reachability_Jump\n//===========================================================================\n// create a possible ladder reachability from area1 to area2\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_Reachability_Ladder(int area1num, int area2num)\n{\n\tint i, j, k, l, edge1num, edge2num, sharededgenum, lowestedgenum;\n\tint face1num, face2num, ladderface1num, ladderface2num;\n\tint ladderface1vertical, ladderface2vertical, firstv;\n\tfloat face1area, face2area, bestface1area, bestface2area;\n\tfloat phys_jumpvel, maxjumpheight;\n\tvec3_t area1point, area2point, v1, v2, up = {0, 0, 1};\n\tvec3_t mid, lowestpoint, start, end, sharededgevec, dir;\n\taas_area_t *area1, *area2;\n\taas_face_t *face1, *face2, *ladderface1, *ladderface2;\n\taas_plane_t *plane1, *plane2;\n\taas_edge_t *sharededge, *edge1;\n\taas_lreachability_t *lreach;\n\taas_trace_t trace;\n\n\tif (!AAS_AreaLadder(area1num) || !AAS_AreaLadder(area2num)) return qfalse;\n\t//\n\tphys_jumpvel = aassettings.phys_jumpvel;\n\t//maximum height a player can jump with the given initial z velocity\n\tmaxjumpheight = AAS_MaxJumpHeight(phys_jumpvel);\n\n\tarea1 = &aasworld.areas[area1num];\n\tarea2 = &aasworld.areas[area2num];\n\t//\n\tladderface1 = NULL;\n\tladderface2 = NULL;\n\tladderface1num = 0; //make compiler happy\n\tladderface2num = 0; //make compiler happy\n\tbestface1area = -9999;\n\tbestface2area = -9999;\n\tsharededgenum = 0; //make compiler happy\n\tlowestedgenum = 0; //make compiler happy\n\t//\n\tfor (i = 0; i < area1->numfaces; i++)\n\t{\n\t\tface1num = aasworld.faceindex[area1->firstface + i];\n\t\tface1 = &aasworld.faces[abs(face1num)];\n\t\t//if not a ladder face\n\t\tif (!(face1->faceflags & FACE_LADDER)) continue;\n\t\t//\n\t\tfor (j = 0; j < area2->numfaces; j++)\n\t\t{\n\t\t\tface2num = aasworld.faceindex[area2->firstface + j];\n\t\t\tface2 = &aasworld.faces[abs(face2num)];\n\t\t\t//if not a ladder face\n\t\t\tif (!(face2->faceflags & FACE_LADDER)) continue;\n\t\t\t//check if the faces share an edge\n\t\t\tfor (k = 0; k < face1->numedges; k++)\n\t\t\t{\n\t\t\t\tedge1num = aasworld.edgeindex[face1->firstedge + k];\n\t\t\t\tfor (l = 0; l < face2->numedges; l++)\n\t\t\t\t{\n\t\t\t\t\tedge2num = aasworld.edgeindex[face2->firstedge + l];\n\t\t\t\t\tif (abs(edge1num) == abs(edge2num))\n\t\t\t\t\t{\n\t\t\t\t\t\t//get the face with the largest area\n\t\t\t\t\t\tface1area = AAS_FaceArea(face1);\n\t\t\t\t\t\tface2area = AAS_FaceArea(face2);\n\t\t\t\t\t\tif (face1area > bestface1area && face2area > bestface2area)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tbestface1area = face1area;\n\t\t\t\t\t\t\tbestface2area = face2area;\n\t\t\t\t\t\t\tladderface1 = face1;\n\t\t\t\t\t\t\tladderface2 = face2;\n\t\t\t\t\t\t\tladderface1num = face1num;\n\t\t\t\t\t\t\tladderface2num = face2num;\n\t\t\t\t\t\t\tsharededgenum = edge1num;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end for\n\t\t\t\tif (l != face2->numedges) break;\n\t\t\t} //end for\n\t\t} //end for\n\t} //end for\n\t//\n\tif (ladderface1 && ladderface2)\n\t{\n\t\t//get the middle of the shared edge\n\t\tsharededge = &aasworld.edges[abs(sharededgenum)];\n\t\tfirstv = sharededgenum < 0;\n\t\t//\n\t\tVectorCopy(aasworld.vertexes[sharededge->v[firstv]], v1);\n\t\tVectorCopy(aasworld.vertexes[sharededge->v[!firstv]], v2);\n\t\tVectorAdd(v1, v2, area1point);\n\t\tVectorScale(area1point, 0.5, area1point);\n\t\tVectorCopy(area1point, area2point);\n\t\t//\n\t\t//if the face plane in area 1 is pretty much vertical\n\t\tplane1 = &aasworld.planes[ladderface1->planenum ^ (ladderface1num < 0)];\n\t\tplane2 = &aasworld.planes[ladderface2->planenum ^ (ladderface2num < 0)];\n\t\t//\n\t\t//get the points really into the areas\n\t\tVectorSubtract(v2, v1, sharededgevec);\n\t\tCrossProduct(plane1->normal, sharededgevec, dir);\n\t\tVectorNormalize(dir);\n\t\t//NOTE: 32 because that's larger than 16 (bot bbox x,y)\n\t\tVectorMA(area1point, -32, dir, area1point);\n\t\tVectorMA(area2point, 32, dir, area2point);\n\t\t//\n\t\tladderface1vertical = abs(DotProduct(plane1->normal, up)) < 0.1;\n\t\tladderface2vertical = abs(DotProduct(plane2->normal, up)) < 0.1;\n\t\t//there's only reachability between vertical ladder faces\n\t\tif (!ladderface1vertical && !ladderface2vertical) return qfalse;\n\t\t//if both vertical ladder faces\n\t\tif (ladderface1vertical && ladderface2vertical\n\t\t\t\t\t//and the ladder faces do not make a sharp corner\n\t\t\t\t\t&& DotProduct(plane1->normal, plane2->normal) > 0.7\n\t\t\t\t\t//and the shared edge is not too vertical\n\t\t\t\t\t&& abs(DotProduct(sharededgevec, up)) < 0.7)\n\t\t{\n\t\t\t//create a new reachability link\n\t\t\tlreach = AAS_AllocReachability();\n\t\t\tif (!lreach) return qfalse;\n\t\t\tlreach->areanum = area2num;\n\t\t\tlreach->facenum = ladderface1num;\n\t\t\tlreach->edgenum = abs(sharededgenum);\n\t\t\tVectorCopy(area1point, lreach->start);\n\t\t\t//VectorCopy(area2point, lreach->end);\n\t\t\tVectorMA(area2point, -3, plane1->normal, lreach->end);\n\t\t\tlreach->traveltype = TRAVEL_LADDER;\n\t\t\tlreach->traveltime = 10;\n\t\t\tlreach->next = areareachability[area1num];\n\t\t\tareareachability[area1num] = lreach;\n\t\t\t//\n\t\t\treach_ladder++;\n\t\t\t//create a new reachability link\n\t\t\tlreach = AAS_AllocReachability();\n\t\t\tif (!lreach) return qfalse;\n\t\t\tlreach->areanum = area1num;\n\t\t\tlreach->facenum = ladderface2num;\n\t\t\tlreach->edgenum = abs(sharededgenum);\n\t\t\tVectorCopy(area2point, lreach->start);\n\t\t\t//VectorCopy(area1point, lreach->end);\n\t\t\tVectorMA(area1point, -3, plane1->normal, lreach->end);\n\t\t\tlreach->traveltype = TRAVEL_LADDER;\n\t\t\tlreach->traveltime = 10;\n\t\t\tlreach->next = areareachability[area2num];\n\t\t\tareareachability[area2num] = lreach;\n\t\t\t//\n\t\t\treach_ladder++;\n\t\t\t//\n\t\t\treturn qtrue;\n\t\t} //end if\n\t\t//if the second ladder face is also a ground face\n\t\t//create ladder end (just ladder) reachability and\n\t\t//walk off a ladder (ledge) reachability\n\t\tif (ladderface1vertical && (ladderface2->faceflags & FACE_GROUND))\n\t\t{\n\t\t\t//create a new reachability link\n\t\t\tlreach = AAS_AllocReachability();\n\t\t\tif (!lreach) return qfalse;\n\t\t\tlreach->areanum = area2num;\n\t\t\tlreach->facenum = ladderface1num;\n\t\t\tlreach->edgenum = abs(sharededgenum);\n\t\t\tVectorCopy(area1point, lreach->start);\n\t\t\tVectorCopy(area2point, lreach->end);\n\t\t\tlreach->end[2] += 16;\n\t\t\tVectorMA(lreach->end, -15, plane1->normal, lreach->end);\n\t\t\tlreach->traveltype = TRAVEL_LADDER;\n\t\t\tlreach->traveltime = 10;\n\t\t\tlreach->next = areareachability[area1num];\n\t\t\tareareachability[area1num] = lreach;\n\t\t\t//\n\t\t\treach_ladder++;\n\t\t\t//create a new reachability link\n\t\t\tlreach = AAS_AllocReachability();\n\t\t\tif (!lreach) return qfalse;\n\t\t\tlreach->areanum = area1num;\n\t\t\tlreach->facenum = ladderface2num;\n\t\t\tlreach->edgenum = abs(sharededgenum);\n\t\t\tVectorCopy(area2point, lreach->start);\n\t\t\tVectorCopy(area1point, lreach->end);\n\t\t\tlreach->traveltype = TRAVEL_WALKOFFLEDGE;\n\t\t\tlreach->traveltime = 10;\n\t\t\tlreach->next = areareachability[area2num];\n\t\t\tareareachability[area2num] = lreach;\n\t\t\t//\n\t\t\treach_walkoffledge++;\n\t\t\t//\n\t\t\treturn qtrue;\n\t\t} //end if\n\t\t//\n\t\tif (ladderface1vertical)\n\t\t{\n\t\t\t//find lowest edge of the ladder face\n\t\t\tlowestpoint[2] = 99999;\n\t\t\tfor (i = 0; i < ladderface1->numedges; i++)\n\t\t\t{\n\t\t\t\tedge1num = abs(aasworld.edgeindex[ladderface1->firstedge + i]);\n\t\t\t\tedge1 = &aasworld.edges[edge1num];\n\t\t\t\t//\n\t\t\t\tVectorCopy(aasworld.vertexes[edge1->v[0]], v1);\n\t\t\t\tVectorCopy(aasworld.vertexes[edge1->v[1]], v2);\n\t\t\t\t//\n\t\t\t\tVectorAdd(v1, v2, mid);\n\t\t\t\tVectorScale(mid, 0.5, mid);\n\t\t\t\t//\n\t\t\t\tif (mid[2] < lowestpoint[2])\n\t\t\t\t{\n\t\t\t\t\tVectorCopy(mid, lowestpoint);\n\t\t\t\t\tlowestedgenum = edge1num;\n\t\t\t\t} //end if\n\t\t\t} //end for\n\t\t\t//\n\t\t\tplane1 = &aasworld.planes[ladderface1->planenum];\n\t\t\t//trace down in the middle of this edge\n\t\t\tVectorMA(lowestpoint, 5, plane1->normal, start);\n\t\t\tVectorCopy(start, end);\n\t\t\tstart[2] += 5;\n\t\t\tend[2] -= 100;\n\t\t\t//trace without entity collision\n\t\t\ttrace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, -1);\n\t\t\t//\n\t\t\t//\n#ifdef REACH_DEBUG\n\t\t\tif (trace.startsolid)\n\t\t\t{\n\t\t\t\tLog_Write(\"trace from area %d started in solid\\r\\n\", area1num);\n\t\t\t} //end if\n#endif //REACH_DEBUG\n\t\t\t//\n\t\t\ttrace.endpos[2] += 1;\n\t\t\tarea2num = AAS_PointAreaNum(trace.endpos);\n\t\t\t//\n\t\t\tarea2 = &aasworld.areas[area2num];\n\t\t\tfor (i = 0; i < area2->numfaces; i++)\n\t\t\t{\n\t\t\t\tface2num = aasworld.faceindex[area2->firstface + i];\n\t\t\t\tface2 = &aasworld.faces[abs(face2num)];\n\t\t\t\t//\n\t\t\t\tif (face2->faceflags & FACE_LADDER)\n\t\t\t\t{\n\t\t\t\t\tplane2 = &aasworld.planes[face2->planenum];\n\t\t\t\t\tif (abs(DotProduct(plane2->normal, up)) < 0.1) break;\n\t\t\t\t} //end if\n\t\t\t} //end for\n\t\t\t//if from another area without vertical ladder faces\n\t\t\tif (i >= area2->numfaces && area2num != area1num &&\n\t\t\t\t\t\t//the reachabilities shouldn't exist already\n\t\t\t\t\t\t!AAS_ReachabilityExists(area1num, area2num) &&\n\t\t\t\t\t\t!AAS_ReachabilityExists(area2num, area1num))\n\t\t\t{\n\t\t\t\t//if the height is jumpable\n\t\t\t\tif (start[2] - trace.endpos[2] < maxjumpheight)\n\t\t\t\t{\n\t\t\t\t\t//create a new reachability link\n\t\t\t\t\tlreach = AAS_AllocReachability();\n\t\t\t\t\tif (!lreach) return qfalse;\n\t\t\t\t\tlreach->areanum = area2num;\n\t\t\t\t\tlreach->facenum = ladderface1num;\n\t\t\t\t\tlreach->edgenum = lowestedgenum;\n\t\t\t\t\tVectorCopy(lowestpoint, lreach->start);\n\t\t\t\t\tVectorCopy(trace.endpos, lreach->end);\n\t\t\t\t\tlreach->traveltype = TRAVEL_LADDER;\n\t\t\t\t\tlreach->traveltime = 10;\n\t\t\t\t\tlreach->next = areareachability[area1num];\n\t\t\t\t\tareareachability[area1num] = lreach;\n\t\t\t\t\t//\n\t\t\t\t\treach_ladder++;\n\t\t\t\t\t//create a new reachability link\n\t\t\t\t\tlreach = AAS_AllocReachability();\n\t\t\t\t\tif (!lreach) return qfalse;\n\t\t\t\t\tlreach->areanum = area1num;\n\t\t\t\t\tlreach->facenum = ladderface1num;\n\t\t\t\t\tlreach->edgenum = lowestedgenum;\n\t\t\t\t\tVectorCopy(trace.endpos, lreach->start);\n\t\t\t\t\t//get the end point a little bit into the ladder\n\t\t\t\t\tVectorMA(lowestpoint, -5, plane1->normal, lreach->end);\n\t\t\t\t\t//get the end point a little higher\n\t\t\t\t\tlreach->end[2] += 10;\n\t\t\t\t\tlreach->traveltype = TRAVEL_JUMP;\n\t\t\t\t\tlreach->traveltime = 10;\n\t\t\t\t\tlreach->next = areareachability[area2num];\n\t\t\t\t\tareareachability[area2num] = lreach;\n\t\t\t\t\t//\n\t\t\t\t\treach_jump++;\t\n\t\t\t\t\t//\n\t\t\t\t\treturn qtrue;\n#ifdef REACH_DEBUG\n\t\t\t\t\tLog_Write(\"jump up to ladder reach between %d and %d\\r\\n\", area2num, area1num);\n#endif //REACH_DEBUG\n\t\t\t\t} //end if\n#ifdef REACH_DEBUG\n\t\t\t\telse Log_Write(\"jump too high between area %d and %d\\r\\n\", area2num, area1num);\n#endif //REACH_DEBUG\n\t\t\t} //end if\n\t\t\t/*//if slime or lava below the ladder\n\t\t\t//try jump reachability from far towards the ladder\n\t\t\tif (aasworld.areasettings[area2num].contents & (AREACONTENTS_SLIME\n\t\t\t\t\t\t\t\t\t\t\t\t\t| AREACONTENTS_LAVA))\n\t\t\t{\n\t\t\t\tfor (i = 20; i <= 120; i += 20)\n\t\t\t\t{\n\t\t\t\t\t//trace down in the middle of this edge\n\t\t\t\t\tVectorMA(lowestpoint, i, plane1->normal, start);\n\t\t\t\t\tVectorCopy(start, end);\n\t\t\t\t\tstart[2] += 5;\n\t\t\t\t\tend[2] -= 100;\n\t\t\t\t\t//trace without entity collision\n\t\t\t\t\ttrace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, -1);\n\t\t\t\t\t//\n\t\t\t\t\tif (trace.startsolid) break;\n\t\t\t\t\ttrace.endpos[2] += 1;\n\t\t\t\t\tarea2num = AAS_PointAreaNum(trace.endpos);\n\t\t\t\t\tif (area2num == area1num) continue;\n\t\t\t\t\t//\n\t\t\t\t\tif (start[2] - trace.endpos[2] > maxjumpheight) continue;\n\t\t\t\t\tif (aasworld.areasettings[area2num].contents & (AREACONTENTS_SLIME\n\t\t\t\t\t\t\t\t\t\t\t\t| AREACONTENTS_LAVA)) continue;\n\t\t\t\t\t//\n\t\t\t\t\t//create a new reachability link\n\t\t\t\t\tlreach = AAS_AllocReachability();\n\t\t\t\t\tif (!lreach) return qfalse;\n\t\t\t\t\tlreach->areanum = area1num;\n\t\t\t\t\tlreach->facenum = ladderface1num;\n\t\t\t\t\tlreach->edgenum = lowestedgenum;\n\t\t\t\t\tVectorCopy(trace.endpos, lreach->start);\n\t\t\t\t\tVectorCopy(lowestpoint, lreach->end);\n\t\t\t\t\tlreach->end[2] += 5;\n\t\t\t\t\tlreach->traveltype = TRAVEL_JUMP;\n\t\t\t\t\tlreach->traveltime = 10;\n\t\t\t\t\tlreach->next = areareachability[area2num];\n\t\t\t\t\tareareachability[area2num] = lreach;\n\t\t\t\t\t//\n\t\t\t\t\treach_jump++;\n\t\t\t\t\t//\n\t\t\t\t\tLog_Write(\"jump far to ladder reach between %d and %d\\r\\n\", area2num, area1num);\n\t\t\t\t\t//\n\t\t\t\t\tbreak;\n\t\t\t\t} //end for\n\t\t\t} //end if*/\n\t\t} //end if\n\t} //end if\n\treturn qfalse;\n} //end of the function AAS_Reachability_Ladder\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_TravelFlagsForTeam(int ent)\n{\n\tint notteam;\n\n\tif (!AAS_IntForBSPEpairKey(ent, \"bot_notteam\", &notteam))\n\t\treturn 0;\n\tif (notteam == 1)\n\t\treturn TRAVELFLAG_NOTTEAM1;\n\tif (notteam == 2)\n\t\treturn TRAVELFLAG_NOTTEAM2;\n\treturn 0;\n} //end of the function AAS_TravelFlagsForTeam\n//===========================================================================\n// create possible teleporter reachabilities\n// this is very game dependent.... :(\n//\n// classname = trigger_multiple or trigger_teleport\n// target = \"t1\"\n//\n// classname = target_teleporter\n// targetname = \"t1\"\n// target = \"t2\"\n//\n// classname = misc_teleporter_dest\n// targetname = \"t2\"\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_Reachability_Teleport(void)\n{\n\tint area1num, area2num;\n\tchar target[MAX_EPAIRKEY], targetname[MAX_EPAIRKEY];\n\tchar classname[MAX_EPAIRKEY], model[MAX_EPAIRKEY];\n\tint ent, dest;\n\tfloat angle;\n\tvec3_t origin, destorigin, mins, maxs, end, angles;\n\tvec3_t mid, velocity, cmdmove;\n\taas_lreachability_t *lreach;\n\taas_clientmove_t move;\n\taas_trace_t trace;\n\taas_link_t *areas, *link;\n\n\tfor (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent))\n\t{\n\t\tif (!AAS_ValueForBSPEpairKey(ent, \"classname\", classname, MAX_EPAIRKEY)) continue;\n\t\tif (!strcmp(classname, \"trigger_multiple\"))\n\t\t{\n\t\t\tAAS_ValueForBSPEpairKey(ent, \"model\", model, MAX_EPAIRKEY);\n//#ifdef REACH_DEBUG\n\t\t\tbotimport.Print(PRT_MESSAGE, \"trigger_multiple model = \\\"%s\\\"\\n\", model);\n//#endif REACH_DEBUG\n\t\t\tVectorClear(angles);\n\t\t\tAAS_BSPModelMinsMaxsOrigin(atoi(model+1), angles, mins, maxs, origin);\n\t\t\t//\n\t\t\tif (!AAS_ValueForBSPEpairKey(ent, \"target\", target, MAX_EPAIRKEY))\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"trigger_multiple at %1.0f %1.0f %1.0f without target\\n\",\n\t\t\t\t\t\t\t\t\torigin[0], origin[1], origin[2]);\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\tfor (dest = AAS_NextBSPEntity(0); dest; dest = AAS_NextBSPEntity(dest))\n\t\t\t{\n\t\t\t\tif (!AAS_ValueForBSPEpairKey(dest, \"classname\", classname, MAX_EPAIRKEY)) continue;\n\t\t\t\tif (!strcmp(classname, \"target_teleporter\"))\n\t\t\t\t{\n\t\t\t\t\tif (!AAS_ValueForBSPEpairKey(dest, \"targetname\", targetname, MAX_EPAIRKEY)) continue;\n\t\t\t\t\tif (!strcmp(targetname, target))\n\t\t\t\t\t{\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t} //end for\n\t\t\tif (!dest)\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\tif (!AAS_ValueForBSPEpairKey(dest, \"target\", target, MAX_EPAIRKEY))\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"target_teleporter without target\\n\");\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t} //end else\n\t\telse if (!strcmp(classname, \"trigger_teleport\"))\n\t\t{\n\t\t\tAAS_ValueForBSPEpairKey(ent, \"model\", model, MAX_EPAIRKEY);\n//#ifdef REACH_DEBUG\n\t\t\tbotimport.Print(PRT_MESSAGE, \"trigger_teleport model = \\\"%s\\\"\\n\", model);\n//#endif REACH_DEBUG\n\t\t\tVectorClear(angles);\n\t\t\tAAS_BSPModelMinsMaxsOrigin(atoi(model+1), angles, mins, maxs, origin);\n\t\t\t//\n\t\t\tif (!AAS_ValueForBSPEpairKey(ent, \"target\", target, MAX_EPAIRKEY))\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"trigger_teleport at %1.0f %1.0f %1.0f without target\\n\",\n\t\t\t\t\t\t\t\t\torigin[0], origin[1], origin[2]);\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tcontinue;\n\t\t} //end else\n\t\t//\n\t\tfor (dest = AAS_NextBSPEntity(0); dest; dest = AAS_NextBSPEntity(dest))\n\t\t{\n\t\t\t//classname should be misc_teleporter_dest\n\t\t\t//but I've also seen target_position and actually any\n\t\t\t//entity could be used... burp\n\t\t\tif (AAS_ValueForBSPEpairKey(dest, \"targetname\", targetname, MAX_EPAIRKEY))\n\t\t\t{\n\t\t\t\tif (!strcmp(targetname, target))\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end for\n\t\tif (!dest)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"teleporter without misc_teleporter_dest (%s)\\n\", target);\n\t\t\tcontinue;\n\t\t} //end if\n\t\tif (!AAS_VectorForBSPEpairKey(dest, \"origin\", destorigin))\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"teleporter destination (%s) without origin\\n\", target);\n\t\t\tcontinue;\n\t\t} //end if\n\t\t//\n\t\tarea2num = AAS_PointAreaNum(destorigin);\n\t\t//if not teleported into a teleporter or into a jumppad\n\t\tif (!AAS_AreaTeleporter(area2num) && !AAS_AreaJumpPad(area2num))\n\t\t{\n\t\t\tVectorCopy(destorigin, end);\n\t\t\tend[2] -= 64;\n\t\t\ttrace = AAS_TraceClientBBox(destorigin, end, PRESENCE_CROUCH, -1);\n\t\t\tif (trace.startsolid)\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"teleporter destination (%s) in solid\\n\", target);\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\tarea2num = AAS_PointAreaNum(trace.endpos);\n\t\t\t//\n\t\t\t/*\n\t\t\tif (!AAS_AreaTeleporter(area2num) &&\n\t\t\t\t!AAS_AreaJumpPad(area2num) &&\n\t\t\t\t!AAS_AreaGrounded(area2num))\n\t\t\t{\n\t\t\t\tVectorCopy(trace.endpos, destorigin);\n\t\t\t}\n\t\t\telse*/\n\t\t\t{\n\t\t\t\t//predict where you'll end up\n\t\t\t\tAAS_FloatForBSPEpairKey(dest, \"angle\", &angle);\n\t\t\t\tif (angle)\n\t\t\t\t{\n\t\t\t\t\tVectorSet(angles, 0, angle, 0);\n\t\t\t\t\tAngleVectors(angles, velocity, NULL, NULL);\n\t\t\t\t\tVectorScale(velocity, 400, velocity);\n\t\t\t\t} //end if\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tVectorClear(velocity);\n\t\t\t\t} //end else\n\t\t\t\tVectorClear(cmdmove);\n\t\t\t\tAAS_PredictClientMovement(&move, -1, destorigin, PRESENCE_NORMAL, qfalse,\n\t\t\t\t\t\t\t\t\t\tvelocity, cmdmove, 0, 30, 0.1f,\n\t\t\t\t\t\t\t\t\t\tSE_HITGROUND|SE_ENTERWATER|SE_ENTERSLIME|\n\t\t\t\t\t\t\t\t\t\tSE_ENTERLAVA|SE_HITGROUNDDAMAGE|SE_TOUCHJUMPPAD|SE_TOUCHTELEPORTER, 0, qfalse); //qtrue);\n\t\t\t\tarea2num = AAS_PointAreaNum(move.endpos);\n\t\t\t\tif (move.stopevent & (SE_ENTERSLIME|SE_ENTERLAVA))\n\t\t\t\t{\n\t\t\t\t\tbotimport.Print(PRT_WARNING, \"teleported into slime or lava at dest %s\\n\", target);\n\t\t\t\t} //end if\n\t\t\t\tVectorCopy(move.endpos, destorigin);\n\t\t\t} //end else\n\t\t} //end if\n\t\t//\n\t\t//botimport.Print(PRT_MESSAGE, \"teleporter brush origin at %f %f %f\\n\", origin[0], origin[1], origin[2]);\n\t\t//botimport.Print(PRT_MESSAGE, \"teleporter brush mins = %f %f %f\\n\", mins[0], mins[1], mins[2]);\n\t\t//botimport.Print(PRT_MESSAGE, \"teleporter brush maxs = %f %f %f\\n\", maxs[0], maxs[1], maxs[2]);\n\t\tVectorAdd(origin, mins, mins);\n\t\tVectorAdd(origin, maxs, maxs);\n\t\t//\n\t\tVectorAdd(mins, maxs, mid);\n\t\tVectorScale(mid, 0.5, mid);\n\t\t//link an invalid (-1) entity\n\t\tareas = AAS_LinkEntityClientBBox(mins, maxs, -1, PRESENCE_CROUCH);\n\t\tif (!areas) botimport.Print(PRT_MESSAGE, \"trigger_multiple not in any area\\n\");\n\t\t//\n\t\tfor (link = areas; link; link = link->next_area)\n\t\t{\n\t\t\t//if (!AAS_AreaGrounded(link->areanum)) continue;\n\t\t\tif (!AAS_AreaTeleporter(link->areanum)) continue;\n\t\t\t//\n\t\t\tarea1num = link->areanum;\n\t\t\t//create a new reachability link\n\t\t\tlreach = AAS_AllocReachability();\n\t\t\tif (!lreach) break;\n\t\t\tlreach->areanum = area2num;\n\t\t\tlreach->facenum = 0;\n\t\t\tlreach->edgenum = 0;\n\t\t\tVectorCopy(mid, lreach->start);\n\t\t\tVectorCopy(destorigin, lreach->end);\n\t\t\tlreach->traveltype = TRAVEL_TELEPORT;\n\t\t\tlreach->traveltype |= AAS_TravelFlagsForTeam(ent);\n\t\t\tlreach->traveltime = aassettings.rs_teleport;\n\t\t\tlreach->next = areareachability[area1num];\n\t\t\tareareachability[area1num] = lreach;\n\t\t\t//\n\t\t\treach_teleport++;\n\t\t} //end for\n\t\t//unlink the invalid entity\n\t\tAAS_UnlinkFromAreas(areas);\n\t} //end for\n} //end of the function AAS_Reachability_Teleport\n//===========================================================================\n// create possible elevator (func_plat) reachabilities\n// this is very game dependent.... :(\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_Reachability_Elevator(void)\n{\n\tint area1num, area2num, modelnum, i, j, k, l, n, p;\n\tfloat lip, height, speed;\n\tchar model[MAX_EPAIRKEY], classname[MAX_EPAIRKEY];\n\tint ent;\n\tvec3_t mins, maxs, origin, angles = {0, 0, 0};\n\tvec3_t pos1, pos2, mids, platbottom, plattop;\n\tvec3_t bottomorg, toporg, start, end, dir;\n\tvec_t xvals[8], yvals[8], xvals_top[8], yvals_top[8];\n\taas_lreachability_t *lreach;\n\taas_trace_t trace;\n\n#ifdef REACH_DEBUG\n\tLog_Write(\"AAS_Reachability_Elevator\\r\\n\");\n#endif //REACH_DEBUG\n\tfor (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent))\n\t{\n\t\tif (!AAS_ValueForBSPEpairKey(ent, \"classname\", classname, MAX_EPAIRKEY)) continue;\n\t\tif (!strcmp(classname, \"func_plat\"))\n\t\t{\n#ifdef REACH_DEBUG\n\t\t\tLog_Write(\"found func plat\\r\\n\");\n#endif //REACH_DEBUG\n\t\t\tif (!AAS_ValueForBSPEpairKey(ent, \"model\", model, MAX_EPAIRKEY))\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"func_plat without model\\n\");\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\t//get the model number, and skip the leading *\n\t\t\tmodelnum = atoi(model+1);\n\t\t\tif (modelnum <= 0)\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"func_plat with invalid model number\\n\");\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\t//get the mins, maxs and origin of the model\n\t\t\t//NOTE: the origin is usually (0,0,0) and the mins and maxs\n\t\t\t//      are the absolute mins and maxs\n\t\t\tAAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, origin);\n\t\t\t//\n\t\t\tAAS_VectorForBSPEpairKey(ent, \"origin\", origin);\n\t\t\t//pos1 is the top position, pos2 is the bottom\n\t\t\tVectorCopy(origin, pos1);\n\t\t\tVectorCopy(origin, pos2);\n\t\t\t//get the lip of the plat\n\t\t\tAAS_FloatForBSPEpairKey(ent, \"lip\", &lip);\n\t\t\tif (!lip) lip = 8;\n\t\t\t//get the movement height of the plat\n\t\t\tAAS_FloatForBSPEpairKey(ent, \"height\", &height);\n\t\t\tif (!height) height = (maxs[2] - mins[2]) - lip;\n\t\t\t//get the speed of the plat\n\t\t\tAAS_FloatForBSPEpairKey(ent, \"speed\", &speed);\n\t\t\tif (!speed) speed = 200;\n\t\t\t//get bottom position below pos1\n\t\t\tpos2[2] -= height;\n\t\t\t//\n\t\t\t//get a point just above the plat in the bottom position\n\t\t\tVectorAdd(mins, maxs, mids);\n\t\t\tVectorMA(pos2, 0.5, mids, platbottom);\n\t\t\tplatbottom[2] = maxs[2] - (pos1[2] - pos2[2]) + 2;\n\t\t\t//get a point just above the plat in the top position\n\t\t\tVectorAdd(mins, maxs, mids);\n\t\t\tVectorMA(pos2, 0.5, mids, plattop);\n\t\t\tplattop[2] = maxs[2] + 2;\n\t\t\t//\n\t\t\t/*if (!area1num)\n\t\t\t{\n\t\t\t\tLog_Write(\"no grounded area near plat bottom\\r\\n\");\n\t\t\t\tcontinue;\n\t\t\t} //end if*/\n\t\t\t//get the mins and maxs a little larger\n\t\t\tfor (i = 0; i < 3; i++)\n\t\t\t{\n\t\t\t\tmins[i] -= 1;\n\t\t\t\tmaxs[i] += 1;\n\t\t\t} //end for\n\t\t\t//\n\t\t\t//botimport.Print(PRT_MESSAGE, \"platbottom[2] = %1.1f plattop[2] = %1.1f\\n\", platbottom[2], plattop[2]);\n\t\t\t//\n\t\t\tVectorAdd(mins, maxs, mids);\n\t\t\tVectorScale(mids, 0.5, mids);\n\t\t\t//\n\t\t\txvals[0] = mins[0]; xvals[1] = mids[0]; xvals[2] = maxs[0]; xvals[3] = mids[0];\n\t\t\tyvals[0] = mids[1]; yvals[1] = maxs[1]; yvals[2] = mids[1]; yvals[3] = mins[1];\n\t\t\t//\n\t\t\txvals[4] = mins[0]; xvals[5] = maxs[0]; xvals[6] = maxs[0]; xvals[7] = mins[0];\n\t\t\tyvals[4] = maxs[1]; yvals[5] = maxs[1]; yvals[6] = mins[1]; yvals[7] = mins[1];\n\t\t\t//find adjacent areas around the bottom of the plat\n\t\t\tfor (i = 0; i < 9; i++)\n\t\t\t{\n\t\t\t\tif (i < 8) //check at the sides of the plat\n\t\t\t\t{\n\t\t\t\t\tbottomorg[0] = origin[0] + xvals[i];\n\t\t\t\t\tbottomorg[1] = origin[1] + yvals[i];\n\t\t\t\t\tbottomorg[2] = platbottom[2] + 16;\n\t\t\t\t\t//get a grounded or swim area near the plat in the bottom position\n\t\t\t\t\tarea1num = AAS_PointAreaNum(bottomorg);\n\t\t\t\t\tfor (k = 0; k < 16; k++)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (area1num)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (AAS_AreaGrounded(area1num) || AAS_AreaSwim(area1num)) break;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\tbottomorg[2] += 4;\n\t\t\t\t\t\tarea1num = AAS_PointAreaNum(bottomorg);\n\t\t\t\t\t} //end if\n\t\t\t\t\t//if in solid\n\t\t\t\t\tif (k >= 16)\n\t\t\t\t\t{\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t\telse //at the middle of the plat\n\t\t\t\t{\n\t\t\t\t\tVectorCopy(plattop, bottomorg);\n\t\t\t\t\tbottomorg[2] += 24;\n\t\t\t\t\tarea1num = AAS_PointAreaNum(bottomorg);\n\t\t\t\t\tif (!area1num) continue;\n\t\t\t\t\tVectorCopy(platbottom, bottomorg);\n\t\t\t\t\tbottomorg[2] += 24;\n\t\t\t\t} //end else\n\t\t\t\t//look at adjacent areas around the top of the plat\n\t\t\t\t//make larger steps to outside the plat everytime\n\t\t\t\tfor (n = 0; n < 3; n++)\n\t\t\t\t{\n\t\t\t\t\tfor (k = 0; k < 3; k++)\n\t\t\t\t\t{\n\t\t\t\t\t\tmins[k] -= 4;\n\t\t\t\t\t\tmaxs[k] += 4;\n\t\t\t\t\t} //end for\n\t\t\t\t\txvals_top[0] = mins[0]; xvals_top[1] = mids[0]; xvals_top[2] = maxs[0]; xvals_top[3] = mids[0];\n\t\t\t\t\tyvals_top[0] = mids[1]; yvals_top[1] = maxs[1]; yvals_top[2] = mids[1]; yvals_top[3] = mins[1];\n\t\t\t\t\t//\n\t\t\t\t\txvals_top[4] = mins[0]; xvals_top[5] = maxs[0]; xvals_top[6] = maxs[0]; xvals_top[7] = mins[0];\n\t\t\t\t\tyvals_top[4] = maxs[1]; yvals_top[5] = maxs[1]; yvals_top[6] = mins[1]; yvals_top[7] = mins[1];\n\t\t\t\t\t//\n\t\t\t\t\tfor (j = 0; j < 8; j++)\n\t\t\t\t\t{\n\t\t\t\t\t\ttoporg[0] = origin[0] + xvals_top[j];\n\t\t\t\t\t\ttoporg[1] = origin[1] + yvals_top[j];\n\t\t\t\t\t\ttoporg[2] = plattop[2] + 16;\n\t\t\t\t\t\t//get a grounded or swim area near the plat in the top position\n\t\t\t\t\t\tarea2num = AAS_PointAreaNum(toporg);\n\t\t\t\t\t\tfor (l = 0; l < 16; l++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (area2num)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (AAS_AreaGrounded(area2num) || AAS_AreaSwim(area2num))\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tVectorCopy(plattop, start);\n\t\t\t\t\t\t\t\t\tstart[2] += 32;\n\t\t\t\t\t\t\t\t\tVectorCopy(toporg, end);\n\t\t\t\t\t\t\t\t\tend[2] += 1;\n\t\t\t\t\t\t\t\t\ttrace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, -1);\n\t\t\t\t\t\t\t\t\tif (trace.fraction >= 1) break;\n\t\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\ttoporg[2] += 4;\n\t\t\t\t\t\t\tarea2num = AAS_PointAreaNum(toporg);\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t//if in solid\n\t\t\t\t\t\tif (l >= 16) continue;\n\t\t\t\t\t\t//never create a reachability in the same area\n\t\t\t\t\t\tif (area2num == area1num) continue;\n\t\t\t\t\t\t//if the area isn't grounded\n\t\t\t\t\t\tif (!AAS_AreaGrounded(area2num)) continue;\n\t\t\t\t\t\t//if there already exists reachability between the areas\n\t\t\t\t\t\tif (AAS_ReachabilityExists(area1num, area2num)) continue;\n\t\t\t\t\t\t//if the reachability start is within the elevator bounding box\n\t\t\t\t\t\tVectorSubtract(bottomorg, platbottom, dir);\n\t\t\t\t\t\tVectorNormalize(dir);\n\t\t\t\t\t\tdir[0] = bottomorg[0] + 24 * dir[0];\n\t\t\t\t\t\tdir[1] = bottomorg[1] + 24 * dir[1];\n\t\t\t\t\t\tdir[2] = bottomorg[2];\n\t\t\t\t\t\t//\n\t\t\t\t\t\tfor (p = 0; p < 3; p++)\n\t\t\t\t\t\t\tif (dir[p] < origin[p] + mins[p] || dir[p] > origin[p] + maxs[p]) break;\n\t\t\t\t\t\tif (p >= 3) continue;\n\t\t\t\t\t\t//create a new reachability link\n\t\t\t\t\t\tlreach = AAS_AllocReachability();\n\t\t\t\t\t\tif (!lreach) continue;\n\t\t\t\t\t\tlreach->areanum = area2num;\n\t\t\t\t\t\t//the facenum is the model number\n\t\t\t\t\t\tlreach->facenum = modelnum;\n\t\t\t\t\t\t//the edgenum is the height\n\t\t\t\t\t\tlreach->edgenum = (int) height;\n\t\t\t\t\t\t//\n\t\t\t\t\t\tVectorCopy(dir, lreach->start);\n\t\t\t\t\t\tVectorCopy(toporg, lreach->end);\n\t\t\t\t\t\tlreach->traveltype = TRAVEL_ELEVATOR;\n\t\t\t\t\t\tlreach->traveltype |= AAS_TravelFlagsForTeam(ent);\n\t\t\t\t\t\tlreach->traveltime = aassettings.rs_startelevator + height * 100 / speed;\n\t\t\t\t\t\tlreach->next = areareachability[area1num];\n\t\t\t\t\t\tareareachability[area1num] = lreach;\n\t\t\t\t\t\t//don't go any further to the outside\n\t\t\t\t\t\tn = 9999;\n\t\t\t\t\t\t//\n#ifdef REACH_DEBUG\n\t\t\t\t\t\tLog_Write(\"elevator reach from %d to %d\\r\\n\", area1num, area2num);\n#endif //REACH_DEBUG\n\t\t\t\t\t\t//\n\t\t\t\t\t\treach_elevator++;\n\t\t\t\t\t} //end for\n\t\t\t\t} //end for\n\t\t\t} //end for\n\t\t} //end if\n\t} //end for\n} //end of the function AAS_Reachability_Elevator\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\naas_lreachability_t *AAS_FindFaceReachabilities(vec3_t *facepoints, int numpoints, aas_plane_t *plane, int towardsface)\n{\n\tint i, j, k, l;\n\tint facenum, edgenum, bestfacenum;\n\tfloat *v1, *v2, *v3, *v4;\n\tfloat bestdist, speed, hordist, dist;\n\tvec3_t beststart, beststart2, bestend, bestend2, tmp, hordir, testpoint;\n\taas_lreachability_t *lreach, *lreachabilities;\n\taas_area_t *area;\n\taas_face_t *face;\n\taas_edge_t *edge;\n\taas_plane_t *faceplane, *bestfaceplane;\n\n\t//\n\tlreachabilities = NULL;\n\tbestfacenum = 0;\n\tbestfaceplane = NULL;\n\t//\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\tarea = &aasworld.areas[i];\n\t\t// get the shortest distance between one of the func_bob start edges and\n\t\t// one of the face edges of area1\n\t\tbestdist = 999999;\n\t\tfor (j = 0; j < area->numfaces; j++)\n\t\t{\n\t\t\tfacenum = aasworld.faceindex[area->firstface + j];\n\t\t\tface = &aasworld.faces[abs(facenum)];\n\t\t\t//if not a ground face\n\t\t\tif (!(face->faceflags & FACE_GROUND)) continue;\n\t\t\t//get the ground planes\n\t\t\tfaceplane = &aasworld.planes[face->planenum];\n\t\t\t//\n\t\t\tfor (k = 0; k < face->numedges; k++)\n\t\t\t{\n\t\t\t\tedgenum = abs(aasworld.edgeindex[face->firstedge + k]);\n\t\t\t\tedge = &aasworld.edges[edgenum];\n\t\t\t\t//calculate the minimum distance between the two edges\n\t\t\t\tv1 = aasworld.vertexes[edge->v[0]];\n\t\t\t\tv2 = aasworld.vertexes[edge->v[1]];\n\t\t\t\t//\n\t\t\t\tfor (l = 0; l < numpoints; l++)\n\t\t\t\t{\n\t\t\t\t\tv3 = facepoints[l];\n\t\t\t\t\tv4 = facepoints[(l+1) % numpoints];\n\t\t\t\t\tdist = AAS_ClosestEdgePoints(v1, v2, v3, v4, faceplane, plane,\n\t\t\t\t\t\t\t\t\t\t\t\t\tbeststart, bestend,\n\t\t\t\t\t\t\t\t\t\t\t\t\tbeststart2, bestend2, bestdist);\n\t\t\t\t\tif (dist < bestdist)\n\t\t\t\t\t{\n\t\t\t\t\t\tbestfacenum = facenum;\n\t\t\t\t\t\tbestfaceplane = faceplane;\n\t\t\t\t\t\tbestdist = dist;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end for\n\t\t\t} //end for\n\t\t} //end for\n\t\t//\n\t\tif (bestdist > 192) continue;\n\t\t//\n\t\tVectorMiddle(beststart, beststart2, beststart);\n\t\tVectorMiddle(bestend, bestend2, bestend);\n\t\t//\n\t\tif (!towardsface)\n\t\t{\n\t\t\tVectorCopy(beststart, tmp);\n\t\t\tVectorCopy(bestend, beststart);\n\t\t\tVectorCopy(tmp, bestend);\n\t\t} //end if\n\t\t//\n\t\tVectorSubtract(bestend, beststart, hordir);\n\t\thordir[2] = 0;\n\t\thordist = VectorLength(hordir);\n\t\t//\n\t\tif (hordist > 2 * AAS_MaxJumpDistance(aassettings.phys_jumpvel)) continue;\n\t\t//the end point should not be significantly higher than the start point\n\t\tif (bestend[2] - 32 > beststart[2]) continue;\n\t\t//don't fall down too far\n\t\tif (bestend[2] < beststart[2] - 128) continue;\n\t\t//the distance should not be too far\n\t\tif (hordist > 32)\n\t\t{\n\t\t\t//check for walk off ledge\n\t\t\tif (!AAS_HorizontalVelocityForJump(0, beststart, bestend, &speed)) continue;\n\t\t} //end if\n\t\t//\n\t\tbeststart[2] += 1;\n\t\tbestend[2] += 1;\n\t\t//\n\t\tif (towardsface) VectorCopy(bestend, testpoint);\n\t\telse VectorCopy(beststart, testpoint);\n\t\ttestpoint[2] = 0;\n\t\ttestpoint[2] = (bestfaceplane->dist - DotProduct(bestfaceplane->normal, testpoint)) / bestfaceplane->normal[2];\n\t\t//\n\t\tif (!AAS_PointInsideFace(bestfacenum, testpoint, 0.1f))\n\t\t{\n\t\t\t//if the faces are not overlapping then only go down\n\t\t\tif (bestend[2] - 16 > beststart[2]) continue;\n\t\t} //end if\n\t\tlreach = AAS_AllocReachability();\n\t\tif (!lreach) return lreachabilities;\n\t\tlreach->areanum = i;\n\t\tlreach->facenum = 0;\n\t\tlreach->edgenum = 0;\n\t\tVectorCopy(beststart, lreach->start);\n\t\tVectorCopy(bestend, lreach->end);\n\t\tlreach->traveltype = 0;\n\t\tlreach->traveltime = 0;\n\t\tlreach->next = lreachabilities;\n\t\tlreachabilities = lreach;\n#ifndef BSPC\n\t\tif (towardsface) AAS_PermanentLine(lreach->start, lreach->end, 1);\n\t\telse AAS_PermanentLine(lreach->start, lreach->end, 2);\n#endif\n\t} //end for\n\treturn lreachabilities;\n} //end of the function AAS_FindFaceReachabilities\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_Reachability_FuncBobbing(void)\n{\n\tint ent, spawnflags, modelnum, axis;\n\tint i, numareas, areas[10];\n\tchar classname[MAX_EPAIRKEY], model[MAX_EPAIRKEY];\n\tvec3_t origin, move_end, move_start, move_start_top, move_end_top;\n\tvec3_t mins, maxs, angles = {0, 0, 0};\n\tvec3_t start_edgeverts[4], end_edgeverts[4], mid;\n\tvec3_t org, start, end, dir, points[10];\n\tfloat height;\n\taas_plane_t start_plane, end_plane;\n\taas_lreachability_t *startreach, *endreach, *nextstartreach, *nextendreach, *lreach;\n\taas_lreachability_t *firststartreach, *firstendreach;\n\n\tfor (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent))\n\t{\n\t\tif (!AAS_ValueForBSPEpairKey(ent, \"classname\", classname, MAX_EPAIRKEY)) continue;\n\t\tif (strcmp(classname, \"func_bobbing\")) continue;\n\t\tAAS_FloatForBSPEpairKey(ent, \"height\", &height);\n\t\tif (!height) height = 32;\n\t\t//\n\t\tif (!AAS_ValueForBSPEpairKey(ent, \"model\", model, MAX_EPAIRKEY))\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"func_bobbing without model\\n\");\n\t\t\tcontinue;\n\t\t} //end if\n\t\t//get the model number, and skip the leading *\n\t\tmodelnum = atoi(model+1);\n\t\tif (modelnum <= 0)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"func_bobbing with invalid model number\\n\");\n\t\t\tcontinue;\n\t\t} //end if\n\t\t//if the entity has an origin set then use it\n\t\tif (!AAS_VectorForBSPEpairKey(ent, \"origin\", origin))\n\t\t\tVectorSet(origin, 0, 0, 0);\n\t\t//\n\t\tAAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, NULL);\n\t\t//\n\t\tVectorAdd(mins, origin, mins);\n\t\tVectorAdd(maxs, origin, maxs);\n\t\t//\n\t\tVectorAdd(mins, maxs, mid);\n\t\tVectorScale(mid, 0.5, mid);\n\t\tVectorCopy(mid, origin);\n\t\t//\n\t\tVectorCopy(origin, move_end);\n\t\tVectorCopy(origin, move_start);\n\t\t//\n\t\tAAS_IntForBSPEpairKey(ent, \"spawnflags\", &spawnflags);\n\t\t// set the axis of bobbing\n\t\tif (spawnflags & 1) axis = 0;\n\t\telse if (spawnflags & 2) axis = 1;\n\t\telse axis = 2;\n\t\t//\n\t\tmove_start[axis] -= height;\n\t\tmove_end[axis] += height;\n\t\t//\n\t\tLog_Write(\"funcbob model %d, start = {%1.1f, %1.1f, %1.1f} end = {%1.1f, %1.1f, %1.1f}\\n\",\n\t\t\t\t\tmodelnum, move_start[0], move_start[1], move_start[2], move_end[0], move_end[1], move_end[2]);\n\t\t//\n#ifndef BSPC\n\t\t/*\n\t\tAAS_DrawPermanentCross(move_start, 4, 1);\n\t\tAAS_DrawPermanentCross(move_end, 4, 2);\n\t\t*/\n#endif\n\t\t//\n\t\tfor (i = 0; i < 4; i++)\n\t\t{\n\t\t\tVectorCopy(move_start, start_edgeverts[i]);\n\t\t\tstart_edgeverts[i][2] += maxs[2] - mid[2]; //+ bbox maxs z\n\t\t\tstart_edgeverts[i][2] += 24;\t//+ player origin to ground dist\n\t\t} //end for\n\t\tstart_edgeverts[0][0] += maxs[0] - mid[0];\n\t\tstart_edgeverts[0][1] += maxs[1] - mid[1];\n\t\tstart_edgeverts[1][0] += maxs[0] - mid[0];\n\t\tstart_edgeverts[1][1] += mins[1] - mid[1];\n\t\tstart_edgeverts[2][0] += mins[0] - mid[0];\n\t\tstart_edgeverts[2][1] += mins[1] - mid[1];\n\t\tstart_edgeverts[3][0] += mins[0] - mid[0];\n\t\tstart_edgeverts[3][1] += maxs[1] - mid[1];\n\t\t//\n\t\tstart_plane.dist = start_edgeverts[0][2];\n\t\tVectorSet(start_plane.normal, 0, 0, 1);\n\t\t//\n\t\tfor (i = 0; i < 4; i++)\n\t\t{\n\t\t\tVectorCopy(move_end, end_edgeverts[i]);\n\t\t\tend_edgeverts[i][2] += maxs[2] - mid[2]; //+ bbox maxs z\n\t\t\tend_edgeverts[i][2] += 24;\t//+ player origin to ground dist\n\t\t} //end for\n\t\tend_edgeverts[0][0] += maxs[0] - mid[0];\n\t\tend_edgeverts[0][1] += maxs[1] - mid[1];\n\t\tend_edgeverts[1][0] += maxs[0] - mid[0];\n\t\tend_edgeverts[1][1] += mins[1] - mid[1];\n\t\tend_edgeverts[2][0] += mins[0] - mid[0];\n\t\tend_edgeverts[2][1] += mins[1] - mid[1];\n\t\tend_edgeverts[3][0] += mins[0] - mid[0];\n\t\tend_edgeverts[3][1] += maxs[1] - mid[1];\n\t\t//\n\t\tend_plane.dist = end_edgeverts[0][2];\n\t\tVectorSet(end_plane.normal, 0, 0, 1);\n\t\t//\n#ifndef BSPC\n#if 0\n\t\tfor (i = 0; i < 4; i++)\n\t\t{\n\t\t\tAAS_PermanentLine(start_edgeverts[i], start_edgeverts[(i+1)%4], 1);\n\t\t\tAAS_PermanentLine(end_edgeverts[i], end_edgeverts[(i+1)%4], 1);\n\t\t} //end for\n#endif\n#endif\n\t\tVectorCopy(move_start, move_start_top);\n\t\tmove_start_top[2] += maxs[2] - mid[2] + 24; //+ bbox maxs z\n\t\tVectorCopy(move_end, move_end_top);\n\t\tmove_end_top[2] += maxs[2] - mid[2] + 24; //+ bbox maxs z\n\t\t//\n\t\tif (!AAS_PointAreaNum(move_start_top)) continue;\n\t\tif (!AAS_PointAreaNum(move_end_top)) continue;\n\t\t//\n\t\tfor (i = 0; i < 2; i++)\n\t\t{\n\t\t\tfirststartreach = firstendreach = NULL;\n\t\t\t//\n\t\t\tif (i == 0)\n\t\t\t{\n\t\t\t\tfirststartreach = AAS_FindFaceReachabilities(start_edgeverts, 4, &start_plane, qtrue);\n\t\t\t\tfirstendreach = AAS_FindFaceReachabilities(end_edgeverts, 4, &end_plane, qfalse);\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tfirststartreach = AAS_FindFaceReachabilities(end_edgeverts, 4, &end_plane, qtrue);\n\t\t\t\tfirstendreach = AAS_FindFaceReachabilities(start_edgeverts, 4, &start_plane, qfalse);\n\t\t\t} //end else\n\t\t\t//\n\t\t\t//create reachabilities from start to end\n\t\t\tfor (startreach = firststartreach; startreach; startreach = nextstartreach)\n\t\t\t{\n\t\t\t\tnextstartreach = startreach->next;\n\t\t\t\t//\n\t\t\t\t//trace = AAS_TraceClientBBox(startreach->start, move_start_top, PRESENCE_NORMAL, -1);\n\t\t\t\t//if (trace.fraction < 1) continue;\n\t\t\t\t//\n\t\t\t\tfor (endreach = firstendreach; endreach; endreach = nextendreach)\n\t\t\t\t{\n\t\t\t\t\tnextendreach = endreach->next;\n\t\t\t\t\t//\n\t\t\t\t\t//trace = AAS_TraceClientBBox(endreach->end, move_end_top, PRESENCE_NORMAL, -1);\n\t\t\t\t\t//if (trace.fraction < 1) continue;\n\t\t\t\t\t//\n\t\t\t\t\tLog_Write(\"funcbob reach from area %d to %d\\n\", startreach->areanum, endreach->areanum);\n\t\t\t\t\t//\n\t\t\t\t\t//\n\t\t\t\t\tif (i == 0) VectorCopy(move_start_top, org);\n\t\t\t\t\telse VectorCopy(move_end_top, org);\n\t\t\t\t\tVectorSubtract(startreach->start, org, dir);\n\t\t\t\t\tdir[2] = 0;\n\t\t\t\t\tVectorNormalize(dir);\n\t\t\t\t\tVectorCopy(startreach->start, start);\n\t\t\t\t\tVectorMA(startreach->start, 1, dir, start);\n\t\t\t\t\tstart[2] += 1;\n\t\t\t\t\tVectorMA(startreach->start, 16, dir, end);\n\t\t\t\t\tend[2] += 1;\n\t\t\t\t\t//\n\t\t\t\t\tnumareas = AAS_TraceAreas(start, end, areas, points, 10);\n\t\t\t\t\tif (numareas <= 0) continue;\n\t\t\t\t\tif (numareas > 1) VectorCopy(points[1], startreach->start);\n\t\t\t\t\telse VectorCopy(end, startreach->start);\n\t\t\t\t\t//\n\t\t\t\t\tif (!AAS_PointAreaNum(startreach->start)) continue;\n\t\t\t\t\tif (!AAS_PointAreaNum(endreach->end)) continue;\n\t\t\t\t\t//\n\t\t\t\t\tlreach = AAS_AllocReachability();\n\t\t\t\t\tlreach->areanum = endreach->areanum;\n\t\t\t\t\tif (i == 0) lreach->edgenum = ((int)move_start[axis] << 16) | ((int) move_end[axis] & 0x0000ffff);\n\t\t\t\t\telse lreach->edgenum = ((int)move_end[axis] << 16) | ((int) move_start[axis] & 0x0000ffff);\n\t\t\t\t\tlreach->facenum = (spawnflags << 16) | modelnum;\n\t\t\t\t\tVectorCopy(startreach->start, lreach->start);\n\t\t\t\t\tVectorCopy(endreach->end, lreach->end);\n#ifndef BSPC\n//\t\t\t\t\tAAS_DrawArrow(lreach->start, lreach->end, LINECOLOR_BLUE, LINECOLOR_YELLOW);\n//\t\t\t\t\tAAS_PermanentLine(lreach->start, lreach->end, 1);\n#endif\n\t\t\t\t\tlreach->traveltype = TRAVEL_FUNCBOB;\n\t\t\t\t\tlreach->traveltype |= AAS_TravelFlagsForTeam(ent);\n\t\t\t\t\tlreach->traveltime = aassettings.rs_funcbob;\n\t\t\t\t\treach_funcbob++;\n\t\t\t\t\tlreach->next = areareachability[startreach->areanum];\n\t\t\t\t\tareareachability[startreach->areanum] = lreach;\n\t\t\t\t\t//\n\t\t\t\t} //end for\n\t\t\t} //end for\n\t\t\tfor (startreach = firststartreach; startreach; startreach = nextstartreach)\n\t\t\t{\n\t\t\t\tnextstartreach = startreach->next;\n\t\t\t\tAAS_FreeReachability(startreach);\n\t\t\t} //end for\n\t\t\tfor (endreach = firstendreach; endreach; endreach = nextendreach)\n\t\t\t{\n\t\t\t\tnextendreach = endreach->next;\n\t\t\t\tAAS_FreeReachability(endreach);\n\t\t\t} //end for\n\t\t\t//only go up with func_bobbing entities that go up and down\n\t\t\tif (!(spawnflags & 1) && !(spawnflags & 2)) break;\n\t\t} //end for\n\t} //end for\n} //end of the function AAS_Reachability_FuncBobbing\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_Reachability_JumpPad(void)\n{\n\tint face2num, i, ret, area2num, visualize, ent, bot_visualizejumppads;\n\t//int modelnum, ent2;\n\t//float dist, time, height, gravity, forward;\n\tfloat speed, zvel, hordist;\n\taas_face_t *face2;\n\taas_area_t *area2;\n\taas_lreachability_t *lreach;\n\tvec3_t areastart, facecenter, dir, cmdmove;\n\tvec3_t velocity, absmins, absmaxs;\n\t//vec3_t origin, ent2origin, angles, teststart;\n\taas_clientmove_t move;\n\t//aas_trace_t trace;\n\taas_link_t *areas, *link;\n\t//char target[MAX_EPAIRKEY], targetname[MAX_EPAIRKEY], model[MAX_EPAIRKEY];\n\tchar classname[MAX_EPAIRKEY];\n\n#ifdef BSPC\n\tbot_visualizejumppads = 0;\n#else\n\tbot_visualizejumppads = LibVarValue(\"bot_visualizejumppads\", \"0\");\n#endif\n\tfor (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent))\n\t{\n\t\tif (!AAS_ValueForBSPEpairKey(ent, \"classname\", classname, MAX_EPAIRKEY)) continue;\n\t\tif (strcmp(classname, \"trigger_push\")) continue;\n\t\t//\n\t\tif (!AAS_GetJumpPadInfo(ent, areastart, absmins, absmaxs, velocity)) continue;\n\t\t/*\n\t\t//\n\t\tAAS_FloatForBSPEpairKey(ent, \"speed\", &speed);\n\t\tif (!speed) speed = 1000;\n//\t\tAAS_VectorForBSPEpairKey(ent, \"angles\", angles);\n//\t\tAAS_SetMovedir(angles, velocity);\n//\t\tVectorScale(velocity, speed, velocity);\n\t\tVectorClear(angles);\n\t\t//get the mins, maxs and origin of the model\n\t\tAAS_ValueForBSPEpairKey(ent, \"model\", model, MAX_EPAIRKEY);\n\t\tif (model[0]) modelnum = atoi(model+1);\n\t\telse modelnum = 0;\n\t\tAAS_BSPModelMinsMaxsOrigin(modelnum, angles, absmins, absmaxs, origin);\n\t\tVectorAdd(origin, absmins, absmins);\n\t\tVectorAdd(origin, absmaxs, absmaxs);\n\t\t//\n#ifdef REACH_DEBUG\n\t\tbotimport.Print(PRT_MESSAGE, \"absmins = %f %f %f\\n\", absmins[0], absmins[1], absmins[2]);\n\t\tbotimport.Print(PRT_MESSAGE, \"absmaxs = %f %f %f\\n\", absmaxs[0], absmaxs[1], absmaxs[2]);\n#endif REACH_DEBUG\n\t\tVectorAdd(absmins, absmaxs, origin);\n\t\tVectorScale (origin, 0.5, origin);\n\n\t\t//get the start areas\n\t\tVectorCopy(origin, teststart);\n\t\tteststart[2] += 64;\n\t\ttrace = AAS_TraceClientBBox(teststart, origin, PRESENCE_CROUCH, -1);\n\t\tif (trace.startsolid)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"trigger_push start solid\\n\");\n\t\t\tVectorCopy(origin, areastart);\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tVectorCopy(trace.endpos, areastart);\n\t\t} //end else\n\t\tareastart[2] += 0.125;\n\t\t//\n\t\t//AAS_DrawPermanentCross(origin, 4, 4);\n\t\t//get the target entity\n\t\tAAS_ValueForBSPEpairKey(ent, \"target\", target, MAX_EPAIRKEY);\n\t\tfor (ent2 = AAS_NextBSPEntity(0); ent2; ent2 = AAS_NextBSPEntity(ent2))\n\t\t{\n\t\t\tif (!AAS_ValueForBSPEpairKey(ent2, \"targetname\", targetname, MAX_EPAIRKEY)) continue;\n\t\t\tif (!strcmp(targetname, target)) break;\n\t\t} //end for\n\t\tif (!ent2)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"trigger_push without target entity %s\\n\", target);\n\t\t\tcontinue;\n\t\t} //end if\n\t\tAAS_VectorForBSPEpairKey(ent2, \"origin\", ent2origin);\n\t\t//\n\t\theight = ent2origin[2] - origin[2];\n\t\tgravity = aassettings.sv_gravity;\n\t\ttime = sqrt( height / ( 0.5 * gravity ) );\n\t\tif (!time)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"trigger_push without time\\n\");\n\t\t\tcontinue;\n\t\t} //end if\n\t\t// set s.origin2 to the push velocity\n\t\tVectorSubtract ( ent2origin, origin, velocity);\n\t\tdist = VectorNormalize( velocity);\n\t\tforward = dist / time;\n\t\t//FIXME: why multiply by 1.1\n\t\tforward *= 1.1;\n\t\tVectorScale(velocity, forward, velocity);\n\t\tvelocity[2] = time * gravity;\n\t\t*/\n\t\t//get the areas the jump pad brush is in\n\t\tareas = AAS_LinkEntityClientBBox(absmins, absmaxs, -1, PRESENCE_CROUCH);\n\t\t/*\n\t\tfor (link = areas; link; link = link->next_area)\n\t\t{\n\t\t\tif (link->areanum == 563)\n\t\t\t{\n\t\t\t\tret = qfalse;\n\t\t\t}\n\t\t}\n        */\n\t\tfor (link = areas; link; link = link->next_area)\n\t\t{\n\t\t\tif (AAS_AreaJumpPad(link->areanum)) break;\n\t\t} //end for\n\t\tif (!link)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"trigger_push not in any jump pad area\\n\");\n\t\t\tAAS_UnlinkFromAreas(areas);\n\t\t\tcontinue;\n\t\t} //end if\n\t\t//\n\t\tbotimport.Print(PRT_MESSAGE, \"found a trigger_push with velocity %f %f %f\\n\", velocity[0], velocity[1], velocity[2]);\n\t\t//if there is a horizontal velocity check for a reachability without air control\n\t\tif (velocity[0] || velocity[1])\n\t\t{\n\t\t\tVectorSet(cmdmove, 0, 0, 0);\n\t\t\t//VectorCopy(velocity, cmdmove);\n\t\t\t//cmdmove[2] = 0;\n\t\t\tCom_Memset(&move, 0, sizeof(aas_clientmove_t));\n\t\t\tarea2num = 0;\n\t\t\tfor (i = 0; i < 20; i++)\n\t\t\t{\n\t\t\t\tAAS_PredictClientMovement(&move, -1, areastart, PRESENCE_NORMAL, qfalse,\n\t\t\t\t\t\t\t\t\t\tvelocity, cmdmove, 0, 30, 0.1f,\n\t\t\t\t\t\t\t\t\t\tSE_HITGROUND|SE_ENTERWATER|SE_ENTERSLIME|\n\t\t\t\t\t\t\t\t\t\tSE_ENTERLAVA|SE_HITGROUNDDAMAGE|SE_TOUCHJUMPPAD|SE_TOUCHTELEPORTER, 0, bot_visualizejumppads);\n\t\t\t\tarea2num = move.endarea;\n\t\t\t\tfor (link = areas; link; link = link->next_area)\n\t\t\t\t{\n\t\t\t\t\tif (!AAS_AreaJumpPad(link->areanum)) continue;\n\t\t\t\t\tif (link->areanum == area2num) break;\n\t\t\t\t} //end if\n\t\t\t\tif (!link) break;\n\t\t\t\tVectorCopy(move.endpos, areastart);\n\t\t\t\tVectorCopy(move.velocity, velocity);\n\t\t\t} //end for\n\t\t\tif (area2num && i < 20)\n\t\t\t{\n\t\t\t\tfor (link = areas; link; link = link->next_area)\n\t\t\t\t{\n\t\t\t\t\tif (!AAS_AreaJumpPad(link->areanum)) continue;\n\t\t\t\t\tif (AAS_ReachabilityExists(link->areanum, area2num)) continue;\n\t\t\t\t\t//create a rocket or bfg jump reachability from area1 to area2\n\t\t\t\t\tlreach = AAS_AllocReachability();\n\t\t\t\t\tif (!lreach)\n\t\t\t\t\t{\n\t\t\t\t\t\tAAS_UnlinkFromAreas(areas);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t} //end if\n\t\t\t\t\tlreach->areanum = area2num;\n\t\t\t\t\t//NOTE: the facenum is the Z velocity\n\t\t\t\t\tlreach->facenum = velocity[2];\n\t\t\t\t\t//NOTE: the edgenum is the horizontal velocity\n\t\t\t\t\tlreach->edgenum = sqrt(velocity[0] * velocity[0] + velocity[1] * velocity[1]);\n\t\t\t\t\tVectorCopy(areastart, lreach->start);\n\t\t\t\t\tVectorCopy(move.endpos, lreach->end);\n\t\t\t\t\tlreach->traveltype = TRAVEL_JUMPPAD;\n\t\t\t\t\tlreach->traveltype |= AAS_TravelFlagsForTeam(ent);\n\t\t\t\t\tlreach->traveltime = aassettings.rs_jumppad;\n\t\t\t\t\tlreach->next = areareachability[link->areanum];\n\t\t\t\t\tareareachability[link->areanum] = lreach;\n\t\t\t\t\t//\n\t\t\t\t\treach_jumppad++;\n\t\t\t\t} //end for\n\t\t\t} //end if\n\t\t} //end if\n\t\t//\n\t\tif (fabs(velocity[0]) > 100 || fabs(velocity[1]) > 100) continue;\n\t\t//check for areas we can reach with air control\n\t\tfor (area2num = 1; area2num < aasworld.numareas; area2num++)\n\t\t{\n\t\t\tvisualize = qfalse;\n\t\t\t/*\n\t\t\tif (area2num == 3568)\n\t\t\t{\n\t\t\t\tfor (link = areas; link; link = link->next_area)\n\t\t\t\t{\n\t\t\t\t\tif (link->areanum == 3380)\n\t\t\t\t\t{\n\t\t\t\t\t\tvisualize = qtrue;\n\t\t\t\t\t\tbotimport.Print(PRT_MESSAGE, \"bah\\n\");\n\t\t\t\t\t} //end if\n\t\t\t\t} //end for\n\t\t\t} //end if*/\n\t\t\t//never try to go back to one of the original jumppad areas\n\t\t\t//and don't create reachabilities if they already exist\n\t\t\tfor (link = areas; link; link = link->next_area)\n\t\t\t{\n\t\t\t\tif (AAS_ReachabilityExists(link->areanum, area2num)) break;\n\t\t\t\tif (AAS_AreaJumpPad(link->areanum))\n\t\t\t\t{\n\t\t\t\t\tif (link->areanum == area2num) break;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t\tif (link) continue;\n\t\t\t//\n\t\t\tarea2 = &aasworld.areas[area2num];\n\t\t\tfor (i = 0; i < area2->numfaces; i++)\n\t\t\t{\n\t\t\t\tface2num = aasworld.faceindex[area2->firstface + i];\n\t\t\t\tface2 = &aasworld.faces[abs(face2num)];\n\t\t\t\t//if it is not a ground face\n\t\t\t\tif (!(face2->faceflags & FACE_GROUND)) continue;\n\t\t\t\t//get the center of the face\n\t\t\t\tAAS_FaceCenter(face2num, facecenter);\n\t\t\t\t//only go higher up\n\t\t\t\tif (facecenter[2] < areastart[2]) continue;\n\t\t\t\t//get the jumppad jump z velocity\n\t\t\t\tzvel = velocity[2];\n\t\t\t\t//get the horizontal speed for the jump, if it isn't possible to calculate this\n\t\t\t\t//speed\n\t\t\t\tret = AAS_HorizontalVelocityForJump(zvel, areastart, facecenter, &speed);\n\t\t\t\tif (ret && speed < 150)\n\t\t\t\t{\n\t\t\t\t\t//direction towards the face center\n\t\t\t\t\tVectorSubtract(facecenter, areastart, dir);\n\t\t\t\t\tdir[2] = 0;\n\t\t\t\t\thordist = VectorNormalize(dir);\n\t\t\t\t\t//if (hordist < 1.6 * facecenter[2] - areastart[2])\n\t\t\t\t\t{\n\t\t\t\t\t\t//get command movement\n\t\t\t\t\t\tVectorScale(dir, speed, cmdmove);\n\t\t\t\t\t\t//\n\t\t\t\t\t\tAAS_PredictClientMovement(&move, -1, areastart, PRESENCE_NORMAL, qfalse,\n\t\t\t\t\t\t\t\t\t\t\t\t\tvelocity, cmdmove, 30, 30, 0.1f,\n\t\t\t\t\t\t\t\t\t\t\t\t\tSE_ENTERWATER|SE_ENTERSLIME|\n\t\t\t\t\t\t\t\t\t\t\t\t\tSE_ENTERLAVA|SE_HITGROUNDDAMAGE|\n\t\t\t\t\t\t\t\t\t\t\t\t\tSE_TOUCHJUMPPAD|SE_TOUCHTELEPORTER|SE_HITGROUNDAREA, area2num, visualize);\n\t\t\t\t\t\t//if prediction time wasn't enough to fully predict the movement\n\t\t\t\t\t\t//don't enter slime or lava and don't fall from too high\n\t\t\t\t\t\tif (move.frames < 30 && \n\t\t\t\t\t\t\t\t!(move.stopevent & (SE_ENTERSLIME|SE_ENTERLAVA|SE_HITGROUNDDAMAGE))\n\t\t\t\t\t\t\t\t&& (move.stopevent & (SE_HITGROUNDAREA|SE_TOUCHJUMPPAD|SE_TOUCHTELEPORTER)))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t//never go back to the same jumppad\n\t\t\t\t\t\t\tfor (link = areas; link; link = link->next_area)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (link->areanum == move.endarea) break;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!link)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfor (link = areas; link; link = link->next_area)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tif (!AAS_AreaJumpPad(link->areanum)) continue;\n\t\t\t\t\t\t\t\t\tif (AAS_ReachabilityExists(link->areanum, area2num)) continue;\n\t\t\t\t\t\t\t\t\t//create a jumppad reachability from area1 to area2\n\t\t\t\t\t\t\t\t\tlreach = AAS_AllocReachability();\n\t\t\t\t\t\t\t\t\tif (!lreach)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tAAS_UnlinkFromAreas(areas);\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\t\t\tlreach->areanum = move.endarea;\n\t\t\t\t\t\t\t\t\t//NOTE: the facenum is the Z velocity\n\t\t\t\t\t\t\t\t\tlreach->facenum = velocity[2];\n\t\t\t\t\t\t\t\t\t//NOTE: the edgenum is the horizontal velocity\n\t\t\t\t\t\t\t\t\tlreach->edgenum = sqrt(cmdmove[0] * cmdmove[0] + cmdmove[1] * cmdmove[1]);\n\t\t\t\t\t\t\t\t\tVectorCopy(areastart, lreach->start);\n\t\t\t\t\t\t\t\t\tVectorCopy(facecenter, lreach->end);\n\t\t\t\t\t\t\t\t\tlreach->traveltype = TRAVEL_JUMPPAD;\n\t\t\t\t\t\t\t\t\tlreach->traveltype |= AAS_TravelFlagsForTeam(ent);\n\t\t\t\t\t\t\t\t\tlreach->traveltime = aassettings.rs_aircontrolledjumppad;\n\t\t\t\t\t\t\t\t\tlreach->next = areareachability[link->areanum];\n\t\t\t\t\t\t\t\t\tareareachability[link->areanum] = lreach;\n\t\t\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t\t\treach_jumppad++;\n\t\t\t\t\t\t\t\t} //end for\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end if\n\t\t\t\t} //end for\n\t\t\t} //end for\n\t\t} //end for\n\t\tAAS_UnlinkFromAreas(areas);\n\t} //end for\n} //end of the function AAS_Reachability_JumpPad\n//===========================================================================\n// never point at ground faces\n// always a higher and pretty far area\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_Reachability_Grapple(int area1num, int area2num)\n{\n\tint face2num, i, j, areanum, numareas, areas[20];\n\tfloat mingrappleangle, z, hordist;\n\tbsp_trace_t bsptrace;\n\taas_trace_t trace;\n\taas_face_t *face2;\n\taas_area_t *area1, *area2;\n\taas_lreachability_t *lreach;\n\tvec3_t areastart, facecenter, start, end, dir, down = {0, 0, -1};\n\tvec_t *v;\n\n\t//only grapple when on the ground or swimming\n\tif (!AAS_AreaGrounded(area1num) && !AAS_AreaSwim(area1num)) return qfalse;\n\t//don't grapple from a crouch area\n\tif (!(AAS_AreaPresenceType(area1num) & PRESENCE_NORMAL)) return qfalse;\n\t//NOTE: disabled area swim it doesn't work right\n\tif (AAS_AreaSwim(area1num)) return qfalse;\n\t//\n\tarea1 = &aasworld.areas[area1num];\n\tarea2 = &aasworld.areas[area2num];\n\t//don't grapple towards way lower areas\n\tif (area2->maxs[2] < area1->mins[2]) return qfalse;\n\t//\n\tVectorCopy(aasworld.areas[area1num].center, start);\n\t//if not a swim area\n\tif (!AAS_AreaSwim(area1num))\n\t{\n\t\tif (!AAS_PointAreaNum(start)) Log_Write(\"area %d center %f %f %f in solid?\\r\\n\", area1num,\n\t\t\t\t\t\t\t\tstart[0], start[1], start[2]);\n\t\tVectorCopy(start, end);\n\t\tend[2] -= 1000;\n\t\ttrace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, -1);\n\t\tif (trace.startsolid) return qfalse;\n\t\tVectorCopy(trace.endpos, areastart);\n\t} //end if\n\telse\n\t{\n\t\tif (!(AAS_PointContents(start) & (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER))) return qfalse;\n\t} //end else\n\t//\n\t//start is now the start point\n\t//\n\tfor (i = 0; i < area2->numfaces; i++)\n\t{\n\t\tface2num = aasworld.faceindex[area2->firstface + i];\n\t\tface2 = &aasworld.faces[abs(face2num)];\n\t\t//if it is not a solid face\n\t\tif (!(face2->faceflags & FACE_SOLID)) continue;\n\t\t//direction towards the first vertex of the face\n\t\tv = aasworld.vertexes[aasworld.edges[abs(aasworld.edgeindex[face2->firstedge])].v[0]];\n\t\tVectorSubtract(v, areastart, dir);\n\t\t//if the face plane is facing away\n\t\tif (DotProduct(aasworld.planes[face2->planenum].normal, dir) > 0) continue;\n\t\t//get the center of the face\n\t\tAAS_FaceCenter(face2num, facecenter);\n\t\t//only go higher up with the grapple\n\t\tif (facecenter[2] < areastart[2] + 64) continue;\n\t\t//only use vertical faces or downward facing faces\n\t\tif (DotProduct(aasworld.planes[face2->planenum].normal, down) < 0) continue;\n\t\t//direction towards the face center\n\t\tVectorSubtract(facecenter, areastart, dir);\n\t\t//\n\t\tz = dir[2];\n\t\tdir[2] = 0;\n\t\thordist = VectorLength(dir);\n\t\tif (!hordist) continue;\n\t\t//if too far\n\t\tif (hordist > 2000) continue;\n\t\t//check the minimal angle of the movement\n\t\tmingrappleangle = 15; //15 degrees\n\t\tif (z / hordist < tan(2 * M_PI * mingrappleangle / 360)) continue;\n\t\t//\n\t\tVectorCopy(facecenter, start);\n\t\tVectorMA(facecenter, -500, aasworld.planes[face2->planenum].normal, end);\n\t\t//\n\t\tbsptrace = AAS_Trace(start, NULL, NULL, end, 0, CONTENTS_SOLID);\n\t\t//the grapple won't stick to the sky and the grapple point should be near the AAS wall\n\t\tif ((bsptrace.surface.flags & SURF_SKY) || (bsptrace.fraction * 500 > 32)) continue;\n\t\t//trace a full bounding box from the area center on the ground to\n\t\t//the center of the face\n\t\tVectorSubtract(facecenter, areastart, dir);\n\t\tVectorNormalize(dir);\n\t\tVectorMA(areastart, 4, dir, start);\n\t\tVectorCopy(bsptrace.endpos, end);\n\t\ttrace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, -1);\n\t\tVectorSubtract(trace.endpos, facecenter, dir);\n\t\tif (VectorLength(dir) > 24) continue;\n\t\t//\n\t\tVectorCopy(trace.endpos, start);\n\t\tVectorCopy(trace.endpos, end);\n\t\tend[2] -= AAS_FallDamageDistance();\n\t\ttrace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, -1);\n\t\tif (trace.fraction >= 1) continue;\n\t\t//area to end in\n\t\tareanum = AAS_PointAreaNum(trace.endpos);\n\t\t//if not in lava or slime\n\t\tif (aasworld.areasettings[areanum].contents & (AREACONTENTS_SLIME|AREACONTENTS_LAVA))\n\t\t{\n\t\t\tcontinue;\n\t\t} //end if\n\t\t//do not go the the source area\n\t\tif (areanum == area1num) continue;\n\t\t//don't create reachabilities if they already exist\n\t\tif (AAS_ReachabilityExists(area1num, areanum)) continue;\n\t\t//only end in areas we can stand\n\t\tif (!AAS_AreaGrounded(areanum)) continue;\n\t\t//never go through cluster portals!!\n\t\tnumareas = AAS_TraceAreas(areastart, bsptrace.endpos, areas, NULL, 20);\n\t\tif (numareas >= 20) continue;\n\t\tfor (j = 0; j < numareas; j++)\n\t\t{\n\t\t\tif (aasworld.areasettings[areas[j]].contents & AREACONTENTS_CLUSTERPORTAL) break;\n\t\t} //end for\n\t\tif (j < numareas) continue;\n\t\t//create a new reachability link\n\t\tlreach = AAS_AllocReachability();\n\t\tif (!lreach) return qfalse;\n\t\tlreach->areanum = areanum;\n\t\tlreach->facenum = face2num;\n\t\tlreach->edgenum = 0;\n\t\tVectorCopy(areastart, lreach->start);\n\t\t//VectorCopy(facecenter, lreach->end);\n\t\tVectorCopy(bsptrace.endpos, lreach->end);\n\t\tlreach->traveltype = TRAVEL_GRAPPLEHOOK;\n\t\tVectorSubtract(lreach->end, lreach->start, dir);\n\t\tlreach->traveltime = aassettings.rs_startgrapple + VectorLength(dir) * 0.25;\n\t\tlreach->next = areareachability[area1num];\n\t\tareareachability[area1num] = lreach;\n\t\t//\n\t\treach_grapple++;\n\t} //end for\n\t//\n\treturn qfalse;\n} //end of the function AAS_Reachability_Grapple\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_SetWeaponJumpAreaFlags(void)\n{\n\tint ent, i;\n\tvec3_t mins = {-15, -15, -15}, maxs = {15, 15, 15};\n\tvec3_t origin;\n\tint areanum, weaponjumpareas, spawnflags;\n\tchar classname[MAX_EPAIRKEY];\n\n\tweaponjumpareas = 0;\n\tfor (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent))\n\t{\n\t\tif (!AAS_ValueForBSPEpairKey(ent, \"classname\", classname, MAX_EPAIRKEY)) continue;\n\t\tif (\n\t\t\t!strcmp(classname, \"item_armor_body\") ||\n\t\t\t!strcmp(classname, \"item_armor_combat\") ||\n\t\t\t!strcmp(classname, \"item_health_mega\") ||\n\t\t\t!strcmp(classname, \"weapon_grenadelauncher\") ||\n\t\t\t!strcmp(classname, \"weapon_rocketlauncher\") ||\n\t\t\t!strcmp(classname, \"weapon_lightning\") ||\n\t\t\t!strcmp(classname, \"weapon_plasmagun\") ||\n\t\t\t!strcmp(classname, \"weapon_railgun\") ||\n\t\t\t!strcmp(classname, \"weapon_bfg\") ||\n\t\t\t!strcmp(classname, \"item_quad\") ||\n\t\t\t!strcmp(classname, \"item_regen\") ||\n\t\t\t!strcmp(classname, \"item_invulnerability\"))\n\t\t{\n\t\t\tif (AAS_VectorForBSPEpairKey(ent, \"origin\", origin))\n\t\t\t{\n\t\t\t\tspawnflags = 0;\n\t\t\t\tAAS_IntForBSPEpairKey(ent, \"spawnflags\", &spawnflags);\n\t\t\t\t//if not a stationary item\n\t\t\t\tif (!(spawnflags & 1))\n\t\t\t\t{\n\t\t\t\t\tif (!AAS_DropToFloor(origin, mins, maxs))\n\t\t\t\t\t{\n\t\t\t\t\t\tbotimport.Print(PRT_MESSAGE, \"%s in solid at (%1.1f %1.1f %1.1f)\\n\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tclassname, origin[0], origin[1], origin[2]);\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t\t//areanum = AAS_PointAreaNum(origin);\n\t\t\t\tareanum = AAS_BestReachableArea(origin, mins, maxs, origin);\n\t\t\t\t//the bot may rocket jump towards this area\n\t\t\t\taasworld.areasettings[areanum].areaflags |= AREA_WEAPONJUMP;\n\t\t\t\t//\n\t\t\t\t//if (!AAS_AreaGrounded(areanum))\n\t\t\t\t//\tbotimport.Print(PRT_MESSAGE, \"area not grounded\\n\");\n\t\t\t\t//\n\t\t\t\tweaponjumpareas++;\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\tif (aasworld.areasettings[i].contents & AREACONTENTS_JUMPPAD)\n\t\t{\n\t\t\taasworld.areasettings[i].areaflags |= AREA_WEAPONJUMP;\n\t\t\tweaponjumpareas++;\n\t\t} //end if\n\t} //end for\n\tbotimport.Print(PRT_MESSAGE, \"%d weapon jump areas\\n\", weaponjumpareas);\n} //end of the function AAS_SetWeaponJumpAreaFlags\n//===========================================================================\n// create a possible weapon jump reachability from area1 to area2\n//\n// check if there's a cool item in the second area\n// check if area1 is lower than area2\n// check if the bot can rocketjump from area1 to area2\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_Reachability_WeaponJump(int area1num, int area2num)\n{\n\tint face2num, i, n, ret, visualize;\n\tfloat speed, zvel, hordist;\n\taas_face_t *face2;\n\taas_area_t *area1, *area2;\n\taas_lreachability_t *lreach;\n\tvec3_t areastart, facecenter, start, end, dir, cmdmove;// teststart;\n\tvec3_t velocity;\n\taas_clientmove_t move;\n\taas_trace_t trace;\n\n\tvisualize = qfalse;\n//\tif (area1num == 4436 && area2num == 4318)\n//\t{\n//\t\tvisualize = qtrue;\n//\t}\n\tif (!AAS_AreaGrounded(area1num) || AAS_AreaSwim(area1num)) return qfalse;\n\tif (!AAS_AreaGrounded(area2num)) return qfalse;\n\t//NOTE: only weapon jump towards areas with an interesting item in it??\n\tif (!(aasworld.areasettings[area2num].areaflags & AREA_WEAPONJUMP)) return qfalse;\n\t//\n\tarea1 = &aasworld.areas[area1num];\n\tarea2 = &aasworld.areas[area2num];\n\t//don't weapon jump towards way lower areas\n\tif (area2->maxs[2] < area1->mins[2]) return qfalse;\n\t//\n\tVectorCopy(aasworld.areas[area1num].center, start);\n\t//if not a swim area\n\tif (!AAS_PointAreaNum(start)) Log_Write(\"area %d center %f %f %f in solid?\\r\\n\", area1num,\n\t\t\t\t\t\t\tstart[0], start[1], start[2]);\n\tVectorCopy(start, end);\n\tend[2] -= 1000;\n\ttrace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, -1);\n\tif (trace.startsolid) return qfalse;\n\tVectorCopy(trace.endpos, areastart);\n\t//\n\t//areastart is now the start point\n\t//\n\tfor (i = 0; i < area2->numfaces; i++)\n\t{\n\t\tface2num = aasworld.faceindex[area2->firstface + i];\n\t\tface2 = &aasworld.faces[abs(face2num)];\n\t\t//if it is not a solid face\n\t\tif (!(face2->faceflags & FACE_GROUND)) continue;\n\t\t//get the center of the face\n\t\tAAS_FaceCenter(face2num, facecenter);\n\t\t//only go higher up with weapon jumps\n\t\tif (facecenter[2] < areastart[2] + 64) continue;\n\t\t//NOTE: set to 2 to allow bfg jump reachabilities\n\t\tfor (n = 0; n < 1/*2*/; n++)\n\t\t{\n\t\t\t//get the rocket jump z velocity\n\t\t\tif (n) zvel = AAS_BFGJumpZVelocity(areastart);\n\t\t\telse zvel = AAS_RocketJumpZVelocity(areastart);\n\t\t\t//get the horizontal speed for the jump, if it isn't possible to calculate this\n\t\t\t//speed (the jump is not possible) then there's no jump reachability created\n\t\t\tret = AAS_HorizontalVelocityForJump(zvel, areastart, facecenter, &speed);\n\t\t\tif (ret && speed < 300)\n\t\t\t{\n\t\t\t\t//direction towards the face center\n\t\t\t\tVectorSubtract(facecenter, areastart, dir);\n\t\t\t\tdir[2] = 0;\n\t\t\t\thordist = VectorNormalize(dir);\n\t\t\t\t//if (hordist < 1.6 * (facecenter[2] - areastart[2]))\n\t\t\t\t{\n\t\t\t\t\t//get command movement\n\t\t\t\t\tVectorScale(dir, speed, cmdmove);\n\t\t\t\t\tVectorSet(velocity, 0, 0, zvel);\n\t\t\t\t\t/*\n\t\t\t\t\t//get command movement\n\t\t\t\t\tVectorScale(dir, speed, velocity);\n\t\t\t\t\tvelocity[2] = zvel;\n\t\t\t\t\tVectorSet(cmdmove, 0, 0, 0);\n\t\t\t\t\t*/\n\t\t\t\t\t//\n\t\t\t\t\tAAS_PredictClientMovement(&move, -1, areastart, PRESENCE_NORMAL, qtrue,\n\t\t\t\t\t\t\t\t\t\t\t\tvelocity, cmdmove, 30, 30, 0.1f,\n\t\t\t\t\t\t\t\t\t\t\t\tSE_ENTERWATER|SE_ENTERSLIME|\n\t\t\t\t\t\t\t\t\t\t\t\tSE_ENTERLAVA|SE_HITGROUNDDAMAGE|\n\t\t\t\t\t\t\t\t\t\t\t\tSE_TOUCHJUMPPAD|SE_HITGROUND|SE_HITGROUNDAREA, area2num, visualize);\n\t\t\t\t\t//if prediction time wasn't enough to fully predict the movement\n\t\t\t\t\t//don't enter slime or lava and don't fall from too high\n\t\t\t\t\tif (move.frames < 30 && \n\t\t\t\t\t\t\t!(move.stopevent & (SE_ENTERSLIME|SE_ENTERLAVA|SE_HITGROUNDDAMAGE))\n\t\t\t\t\t\t\t\t&& (move.stopevent & (SE_HITGROUNDAREA|SE_TOUCHJUMPPAD)))\n\t\t\t\t\t{\n\t\t\t\t\t\t//create a rocket or bfg jump reachability from area1 to area2\n\t\t\t\t\t\tlreach = AAS_AllocReachability();\n\t\t\t\t\t\tif (!lreach) return qfalse;\n\t\t\t\t\t\tlreach->areanum = area2num;\n\t\t\t\t\t\tlreach->facenum = 0;\n\t\t\t\t\t\tlreach->edgenum = 0;\n\t\t\t\t\t\tVectorCopy(areastart, lreach->start);\n\t\t\t\t\t\tVectorCopy(facecenter, lreach->end);\n\t\t\t\t\t\tif (n)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlreach->traveltype = TRAVEL_BFGJUMP;\n\t\t\t\t\t\t\tlreach->traveltime = aassettings.rs_bfgjump;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlreach->traveltype = TRAVEL_ROCKETJUMP;\n\t\t\t\t\t\t\tlreach->traveltime = aassettings.rs_rocketjump;\n\t\t\t\t\t\t} //end else\n\t\t\t\t\t\tlreach->next = areareachability[area1num];\n\t\t\t\t\t\tareareachability[area1num] = lreach;\n\t\t\t\t\t\t//\n\t\t\t\t\t\treach_rocketjump++;\n\t\t\t\t\t\treturn qtrue;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\t//\n\treturn qfalse;\n} //end of the function AAS_Reachability_WeaponJump\n//===========================================================================\n// calculates additional walk off ledge reachabilities for the given area\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_Reachability_WalkOffLedge(int areanum)\n{\n\tint i, j, k, l, m, n, p, areas[10], numareas;\n\tint face1num, face2num, face3num, edge1num, edge2num, edge3num;\n\tint otherareanum, gap, reachareanum, side;\n\taas_area_t *area, *area2;\n\taas_face_t *face1, *face2, *face3;\n\taas_edge_t *edge;\n\taas_plane_t *plane;\n\tvec_t *v1, *v2;\n\tvec3_t sharededgevec, mid, dir, testend;\n\taas_lreachability_t *lreach;\n\taas_trace_t trace;\n\n\tif (!AAS_AreaGrounded(areanum) || AAS_AreaSwim(areanum)) return;\n\t//\n\tarea = &aasworld.areas[areanum];\n\t//\n\tfor (i = 0; i < area->numfaces; i++)\n\t{\n\t\tface1num = aasworld.faceindex[area->firstface + i];\n\t\tface1 = &aasworld.faces[abs(face1num)];\n\t\t//face 1 must be a ground face\n\t\tif (!(face1->faceflags & FACE_GROUND)) continue;\n\t\t//go through all the edges of this ground face\n\t\tfor (k = 0; k < face1->numedges; k++)\n\t\t{\n\t\t\tedge1num = aasworld.edgeindex[face1->firstedge + k];\n\t\t\t//find another not ground face using this same edge\n\t\t\tfor (j = 0; j < area->numfaces; j++)\n\t\t\t{\n\t\t\t\tface2num = aasworld.faceindex[area->firstface + j];\n\t\t\t\tface2 = &aasworld.faces[abs(face2num)];\n\t\t\t\t//face 2 may not be a ground face\n\t\t\t\tif (face2->faceflags & FACE_GROUND) continue;\n\t\t\t\t//compare all the edges\n\t\t\t\tfor (l = 0; l < face2->numedges; l++)\n\t\t\t\t{\n\t\t\t\t\tedge2num = aasworld.edgeindex[face2->firstedge + l];\n\t\t\t\t\tif (abs(edge1num) == abs(edge2num))\n\t\t\t\t\t{\n\t\t\t\t\t\t//get the area at the other side of the face\n\t\t\t\t\t\tif (face2->frontarea == areanum) otherareanum = face2->backarea;\n\t\t\t\t\t\telse otherareanum = face2->frontarea;\n\t\t\t\t\t\t//\n\t\t\t\t\t\tarea2 = &aasworld.areas[otherareanum];\n\t\t\t\t\t\t//if the other area is grounded!\n\t\t\t\t\t\tif (aasworld.areasettings[otherareanum].areaflags & AREA_GROUNDED)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t//check for a possible gap\n\t\t\t\t\t\t\tgap = qfalse;\n\t\t\t\t\t\t\tfor (n = 0; n < area2->numfaces; n++)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tface3num = aasworld.faceindex[area2->firstface + n];\n\t\t\t\t\t\t\t\t//may not be the shared face of the two areas\n\t\t\t\t\t\t\t\tif (abs(face3num) == abs(face2num)) continue;\n\t\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t\tface3 = &aasworld.faces[abs(face3num)];\n\t\t\t\t\t\t\t\t//find an edge shared by all three faces\n\t\t\t\t\t\t\t\tfor (m = 0; m < face3->numedges; m++)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tedge3num = aasworld.edgeindex[face3->firstedge + m];\n\t\t\t\t\t\t\t\t\t//but the edge should be shared by all three faces\n\t\t\t\t\t\t\t\t\tif (abs(edge3num) == abs(edge1num))\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tif (!(face3->faceflags & FACE_SOLID))\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tgap = qtrue;\n\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t\t\t\tif (face3->faceflags & FACE_GROUND)\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tgap = qfalse;\n\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\t\t\t\t//FIXME: there are more situations to be handled\n\t\t\t\t\t\t\t\t\t\tgap = qtrue;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\t\t} //end for\n\t\t\t\t\t\t\t\tif (m < face3->numedges) break;\n\t\t\t\t\t\t\t} //end for\n\t\t\t\t\t\t\tif (!gap) break;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t//check for a walk off ledge reachability\n\t\t\t\t\t\tedge = &aasworld.edges[abs(edge1num)];\n\t\t\t\t\t\tside = edge1num < 0;\n\t\t\t\t\t\t//\n\t\t\t\t\t\tv1 = aasworld.vertexes[edge->v[side]];\n\t\t\t\t\t\tv2 = aasworld.vertexes[edge->v[!side]];\n\t\t\t\t\t\t//\n\t\t\t\t\t\tplane = &aasworld.planes[face1->planenum];\n\t\t\t\t\t\t//get the points really into the areas\n\t\t\t\t\t\tVectorSubtract(v2, v1, sharededgevec);\n\t\t\t\t\t\tCrossProduct(plane->normal, sharededgevec, dir);\n\t\t\t\t\t\tVectorNormalize(dir);\n\t\t\t\t\t\t//\n\t\t\t\t\t\tVectorAdd(v1, v2, mid);\n\t\t\t\t\t\tVectorScale(mid, 0.5, mid);\n\t\t\t\t\t\tVectorMA(mid, 8, dir, mid);\n\t\t\t\t\t\t//\n\t\t\t\t\t\tVectorCopy(mid, testend);\n\t\t\t\t\t\ttestend[2] -= 1000;\n\t\t\t\t\t\ttrace = AAS_TraceClientBBox(mid, testend, PRESENCE_CROUCH, -1);\n\t\t\t\t\t\t//\n\t\t\t\t\t\tif (trace.startsolid)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t//Log_Write(\"area %d: trace.startsolid\\r\\n\", areanum);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\treachareanum = AAS_PointAreaNum(trace.endpos);\n\t\t\t\t\t\tif (reachareanum == areanum)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t//Log_Write(\"area %d: same area\\r\\n\", areanum);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\tif (AAS_ReachabilityExists(areanum, reachareanum))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t//Log_Write(\"area %d: reachability already exists\\r\\n\", areanum);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\tif (!AAS_AreaGrounded(reachareanum) && !AAS_AreaSwim(reachareanum))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t//Log_Write(\"area %d, reach area %d: not grounded and not swim\\r\\n\", areanum, reachareanum);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t//\n\t\t\t\t\t\tif (aasworld.areasettings[reachareanum].contents & (AREACONTENTS_SLIME\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| AREACONTENTS_LAVA))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t//Log_Write(\"area %d, reach area %d: lava or slime\\r\\n\", areanum, reachareanum);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t//if not going through a cluster portal\n\t\t\t\t\t\tnumareas = AAS_TraceAreas(mid, testend, areas, NULL, sizeof(areas) / sizeof(int));\n\t\t\t\t\t\tfor (p = 0; p < numareas; p++)\n\t\t\t\t\t\t\tif (AAS_AreaClusterPortal(areas[p]))\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tif (p < numareas)\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t// if a maximum fall height is set and the bot would fall down further\n\t\t\t\t\t\tif (aassettings.rs_maxfallheight && fabs(mid[2] - trace.endpos[2]) > aassettings.rs_maxfallheight)\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t//\n\t\t\t\t\t\tlreach = AAS_AllocReachability();\n\t\t\t\t\t\tif (!lreach) break;\n\t\t\t\t\t\tlreach->areanum = reachareanum;\n\t\t\t\t\t\tlreach->facenum = 0;\n\t\t\t\t\t\tlreach->edgenum = edge1num;\n\t\t\t\t\t\tVectorCopy(mid, lreach->start);\n\t\t\t\t\t\tVectorCopy(trace.endpos, lreach->end);\n\t\t\t\t\t\tlreach->traveltype = TRAVEL_WALKOFFLEDGE;\n\t\t\t\t\t\tlreach->traveltime = aassettings.rs_startwalkoffledge + fabs(mid[2] - trace.endpos[2]) * 50 / aassettings.phys_gravity;\n\t\t\t\t\t\tif (!AAS_AreaSwim(reachareanum) && !AAS_AreaJumpPad(reachareanum))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (AAS_FallDelta(mid[2] - trace.endpos[2]) > aassettings.phys_falldelta5)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlreach->traveltime += aassettings.rs_falldamage5;\n\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\telse if (AAS_FallDelta(mid[2] - trace.endpos[2]) > aassettings.phys_falldelta10)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlreach->traveltime += aassettings.rs_falldamage10;\n\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\tlreach->next = areareachability[areanum];\n\t\t\t\t\t\tareareachability[areanum] = lreach;\n\t\t\t\t\t\t//we've got another walk off ledge reachability\n\t\t\t\t\t\treach_walkoffledge++;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end for\n\t\t\t} //end for\n\t\t} //end for\n\t} //end for\n} //end of the function AAS_Reachability_WalkOffLedge\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_StoreReachability(void)\n{\n\tint i;\n\taas_areasettings_t *areasettings;\n\taas_lreachability_t *lreach;\n\taas_reachability_t *reach;\n\n\tif (aasworld.reachability) FreeMemory(aasworld.reachability);\n\taasworld.reachability = (aas_reachability_t *) GetClearedMemory((numlreachabilities + 10) * sizeof(aas_reachability_t));\n\taasworld.reachabilitysize = 1;\n\tfor (i = 0; i < aasworld.numareas; i++)\n\t{\n\t\tareasettings = &aasworld.areasettings[i];\n\t\tareasettings->firstreachablearea = aasworld.reachabilitysize;\n\t\tareasettings->numreachableareas = 0;\n\t\tfor (lreach = areareachability[i]; lreach; lreach = lreach->next)\n\t\t{\n\t\t\treach = &aasworld.reachability[areasettings->firstreachablearea +\n\t\t\t\t\t\t\t\t\t\t\t\t\tareasettings->numreachableareas];\n\t\t\treach->areanum = lreach->areanum;\n\t\t\treach->facenum = lreach->facenum;\n\t\t\treach->edgenum = lreach->edgenum;\n\t\t\tVectorCopy(lreach->start, reach->start);\n\t\t\tVectorCopy(lreach->end, reach->end);\n\t\t\treach->traveltype = lreach->traveltype;\n\t\t\treach->traveltime = lreach->traveltime;\n\t\t\t//\n\t\t\tareasettings->numreachableareas++;\n\t\t} //end for\n\t\taasworld.reachabilitysize += areasettings->numreachableareas;\n\t} //end for\n} //end of the function AAS_StoreReachability\n//===========================================================================\n//\n// TRAVEL_WALK\t\t\t\t\t100%\tequal floor height + steps\n// TRAVEL_CROUCH\t\t\t\t100%\n// TRAVEL_BARRIERJUMP\t\t\t100%\n// TRAVEL_JUMP\t\t\t\t\t 80%\n// TRAVEL_LADDER\t\t\t\t100%\t+ fall down from ladder + jump up to ladder\n// TRAVEL_WALKOFFLEDGE\t\t\t 90%\twalk off very steep walls?\n// TRAVEL_SWIM\t\t\t\t\t100%\n// TRAVEL_WATERJUMP\t\t\t\t100%\n// TRAVEL_TELEPORT\t\t\t\t100%\n// TRAVEL_ELEVATOR\t\t\t\t100%\n// TRAVEL_GRAPPLEHOOK\t\t\t100%\n// TRAVEL_DOUBLEJUMP\t\t\t  0%\n// TRAVEL_RAMPJUMP\t\t\t\t  0%\n// TRAVEL_STRAFEJUMP\t\t\t  0%\n// TRAVEL_ROCKETJUMP\t\t\t100%\t(currently limited towards areas with items)\n// TRAVEL_BFGJUMP\t\t\t\t  0%\t(currently disabled)\n// TRAVEL_JUMPPAD\t\t\t\t100%\n// TRAVEL_FUNCBOB\t\t\t\t100%\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\ttrue if NOT finished\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_ContinueInitReachability(float time)\n{\n\tint i, j, todo, start_time;\n\tstatic float framereachability, reachability_delay;\n\tstatic int lastpercentage;\n\n\tif (!aasworld.loaded) return qfalse;\n\t//if reachability is calculated for all areas\n\tif (aasworld.numreachabilityareas >= aasworld.numareas + 2) return qfalse;\n\t//if starting with area 1 (area 0 is a dummy)\n\tif (aasworld.numreachabilityareas == 1)\n\t{\n\t\tbotimport.Print(PRT_MESSAGE, \"calculating reachability...\\n\");\n\t\tlastpercentage = 0;\n\t\tframereachability = 2000;\n\t\treachability_delay = 1000;\n\t} //end if\n\t//number of areas to calculate reachability for this cycle\n\ttodo = aasworld.numreachabilityareas + (int) framereachability;\n\tstart_time = Sys_MilliSeconds();\n\t//loop over the areas\n\tfor (i = aasworld.numreachabilityareas; i < aasworld.numareas && i < todo; i++)\n\t{\n\t\taasworld.numreachabilityareas++;\n\t\t//only create jumppad reachabilities from jumppad areas\n\t\tif (aasworld.areasettings[i].contents & AREACONTENTS_JUMPPAD)\n\t\t{\n\t\t\tcontinue;\n\t\t} //end if\n\t\t//loop over the areas\n\t\tfor (j = 1; j < aasworld.numareas; j++)\n\t\t{\n\t\t\tif (i == j) continue;\n\t\t\t//never create reachabilities from teleporter or jumppad areas to regular areas\n\t\t\tif (aasworld.areasettings[i].contents & (AREACONTENTS_TELEPORTER|AREACONTENTS_JUMPPAD))\n\t\t\t{\n\t\t\t\tif (!(aasworld.areasettings[j].contents & (AREACONTENTS_TELEPORTER|AREACONTENTS_JUMPPAD)))\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t\t//if there already is a reachability link from area i to j\n\t\t\tif (AAS_ReachabilityExists(i, j)) continue;\n\t\t\t//check for a swim reachability\n\t\t\tif (AAS_Reachability_Swim(i, j)) continue;\n\t\t\t//check for a simple walk on equal floor height reachability\n\t\t\tif (AAS_Reachability_EqualFloorHeight(i, j)) continue;\n\t\t\t//check for step, barrier, waterjump and walk off ledge reachabilities\n\t\t\tif (AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(i, j)) continue;\n\t\t\t//check for ladder reachabilities\n\t\t\tif (AAS_Reachability_Ladder(i, j)) continue;\n\t\t\t//check for a jump reachability\n\t\t\tif (AAS_Reachability_Jump(i, j)) continue;\n\t\t} //end for\n\t\t//never create these reachabilities from teleporter or jumppad areas\n\t\tif (aasworld.areasettings[i].contents & (AREACONTENTS_TELEPORTER|AREACONTENTS_JUMPPAD))\n\t\t{\n\t\t\tcontinue;\n\t\t} //end if\n\t\t//loop over the areas\n\t\tfor (j = 1; j < aasworld.numareas; j++)\n\t\t{\n\t\t\tif (i == j) continue;\n\t\t\t//\n\t\t\tif (AAS_ReachabilityExists(i, j)) continue;\n\t\t\t//check for a grapple hook reachability\n\t\t\tif (calcgrapplereach) AAS_Reachability_Grapple(i, j);\n\t\t\t//check for a weapon jump reachability\n\t\t\tAAS_Reachability_WeaponJump(i, j);\n\t\t} //end for\n\t\t//if the calculation took more time than the max reachability delay\n\t\tif (Sys_MilliSeconds() - start_time > (int) reachability_delay) break;\n\t\t//\n\t\tif (aasworld.numreachabilityareas * 1000 / aasworld.numareas > lastpercentage) break;\n\t} //end for\n\t//\n\tif (aasworld.numreachabilityareas == aasworld.numareas)\n\t{\n\t\tbotimport.Print(PRT_MESSAGE, \"\\r%6.1f%%\", (float) 100.0);\n\t\tbotimport.Print(PRT_MESSAGE, \"\\nplease wait while storing reachability...\\n\");\n\t\taasworld.numreachabilityareas++;\n\t} //end if\n\t//if this is the last step in the reachability calculations\n\telse if (aasworld.numreachabilityareas == aasworld.numareas + 1)\n\t{\n\t\t//create additional walk off ledge reachabilities for every area\n\t\tfor (i = 1; i < aasworld.numareas; i++)\n\t\t{\n\t\t\t//only create jumppad reachabilities from jumppad areas\n\t\t\tif (aasworld.areasettings[i].contents & AREACONTENTS_JUMPPAD)\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\tAAS_Reachability_WalkOffLedge(i);\n\t\t} //end for\n\t\t//create jump pad reachabilities\n\t\tAAS_Reachability_JumpPad();\n\t\t//create teleporter reachabilities\n\t\tAAS_Reachability_Teleport();\n\t\t//create elevator (func_plat) reachabilities\n\t\tAAS_Reachability_Elevator();\n\t\t//create func_bobbing reachabilities\n\t\tAAS_Reachability_FuncBobbing();\n\t\t//\n#ifdef DEBUG\n\t\tbotimport.Print(PRT_MESSAGE, \"%6d reach swim\\n\", reach_swim);\n\t\tbotimport.Print(PRT_MESSAGE, \"%6d reach equal floor\\n\", reach_equalfloor);\n\t\tbotimport.Print(PRT_MESSAGE, \"%6d reach step\\n\", reach_step);\n\t\tbotimport.Print(PRT_MESSAGE, \"%6d reach barrier\\n\", reach_barrier);\n\t\tbotimport.Print(PRT_MESSAGE, \"%6d reach waterjump\\n\", reach_waterjump);\n\t\tbotimport.Print(PRT_MESSAGE, \"%6d reach walkoffledge\\n\", reach_walkoffledge);\n\t\tbotimport.Print(PRT_MESSAGE, \"%6d reach jump\\n\", reach_jump);\n\t\tbotimport.Print(PRT_MESSAGE, \"%6d reach ladder\\n\", reach_ladder);\n\t\tbotimport.Print(PRT_MESSAGE, \"%6d reach walk\\n\", reach_walk);\n\t\tbotimport.Print(PRT_MESSAGE, \"%6d reach teleport\\n\", reach_teleport);\n\t\tbotimport.Print(PRT_MESSAGE, \"%6d reach funcbob\\n\", reach_funcbob);\n\t\tbotimport.Print(PRT_MESSAGE, \"%6d reach elevator\\n\", reach_elevator);\n\t\tbotimport.Print(PRT_MESSAGE, \"%6d reach grapple\\n\", reach_grapple);\n\t\tbotimport.Print(PRT_MESSAGE, \"%6d reach rocketjump\\n\", reach_rocketjump);\n\t\tbotimport.Print(PRT_MESSAGE, \"%6d reach jumppad\\n\", reach_jumppad);\n#endif\n\t\t//*/\n\t\t//store all the reachabilities\n\t\tAAS_StoreReachability();\n\t\t//free the reachability link heap\n\t\tAAS_ShutDownReachabilityHeap();\n\t\t//\n\t\tFreeMemory(areareachability);\n\t\t//\n\t\taasworld.numreachabilityareas++;\n\t\t//\n\t\tbotimport.Print(PRT_MESSAGE, \"calculating clusters...\\n\");\n\t} //end if\n\telse\n\t{\n\t\tlastpercentage = aasworld.numreachabilityareas * 1000 / aasworld.numareas;\n\t\tbotimport.Print(PRT_MESSAGE, \"\\r%6.1f%%\", (float) lastpercentage / 10);\n\t} //end else\n\t//not yet finished\n\treturn qtrue;\n} //end of the function AAS_ContinueInitReachability\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_InitReachability(void)\n{\n\tif (!aasworld.loaded) return;\n\n\tif (aasworld.reachabilitysize)\n\t{\n#ifndef BSPC\n\t\tif (!((int)LibVarGetValue(\"forcereachability\")))\n\t\t{\n\t\t\taasworld.numreachabilityareas = aasworld.numareas + 2;\n\t\t\treturn;\n\t\t} //end if\n#else\n\t\taasworld.numreachabilityareas = aasworld.numareas + 2;\n\t\treturn;\n#endif //BSPC\n\t} //end if\n#ifndef BSPC\n\tcalcgrapplereach = LibVarGetValue(\"grapplereach\");\n#endif\n\taasworld.savefile = qtrue;\n\t//start with area 1 because area zero is a dummy\n\taasworld.numreachabilityareas = 1;\n\t////aasworld.numreachabilityareas = aasworld.numareas + 1;\t\t//only calculate entity reachabilities\n\t//setup the heap with reachability links\n\tAAS_SetupReachabilityHeap();\n\t//allocate area reachability link array\n\tareareachability = (aas_lreachability_t **) GetClearedMemory(\n\t\t\t\t\t\t\t\t\taasworld.numareas * sizeof(aas_lreachability_t *));\n\t//\n\tAAS_SetWeaponJumpAreaFlags();\n} //end of the function AAS_InitReachable\n"
  },
  {
    "path": "code/botlib/be_aas_reach.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_reach.h\n *\n * desc:\t\tAAS\n *\n * $Archive: /source/code/botlib/be_aas_reach.h $\n *\n *****************************************************************************/\n\n#ifdef AASINTERN\n//initialize calculating the reachabilities\nvoid AAS_InitReachability(void);\n//continue calculating the reachabilities\nint AAS_ContinueInitReachability(float time);\n//\nint AAS_BestReachableLinkArea(aas_link_t *areas);\n#endif //AASINTERN\n\n//returns true if the are has reachabilities to other areas\nint AAS_AreaReachability(int areanum);\n//returns the best reachable area and goal origin for a bounding box at the given origin\nint AAS_BestReachableArea(vec3_t origin, vec3_t mins, vec3_t maxs, vec3_t goalorigin);\n//returns the best jumppad area from which the bbox at origin is reachable\nint AAS_BestReachableFromJumpPadArea(vec3_t origin, vec3_t mins, vec3_t maxs);\n//returns the next reachability using the given model\nint AAS_NextModelReachability(int num, int modelnum);\n//returns the total area of the ground faces of the given area\nfloat AAS_AreaGroundFaceArea(int areanum);\n//returns true if the area is crouch only\nint AAS_AreaCrouch(int areanum);\n//returns true if a player can swim in this area\nint AAS_AreaSwim(int areanum);\n//returns true if the area is filled with a liquid\nint AAS_AreaLiquid(int areanum);\n//returns true if the area contains lava\nint AAS_AreaLava(int areanum);\n//returns true if the area contains slime\nint AAS_AreaSlime(int areanum);\n//returns true if the area has one or more ground faces\nint AAS_AreaGrounded(int areanum);\n//returns true if the area has one or more ladder faces\nint AAS_AreaLadder(int areanum);\n//returns true if the area is a jump pad\nint AAS_AreaJumpPad(int areanum);\n//returns true if the area is donotenter\nint AAS_AreaDoNotEnter(int areanum);\n"
  },
  {
    "path": "code/botlib/be_aas_route.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_route.c\n *\n * desc:\t\tAAS\n *\n * $Archive: /MissionPack/code/botlib/be_aas_route.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_utils.h\"\n#include \"l_memory.h\"\n#include \"l_log.h\"\n#include \"l_crc.h\"\n#include \"l_libvar.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#include \"aasfile.h\"\n#include \"../game/botlib.h\"\n#include \"../game/be_aas.h\"\n#include \"be_aas_funcs.h\"\n#include \"be_interface.h\"\n#include \"be_aas_def.h\"\n\n#define ROUTING_DEBUG\n\n//travel time in hundreths of a second = distance * 100 / speed\n#define DISTANCEFACTOR_CROUCH\t\t1.3f\t\t//crouch speed = 100\n#define DISTANCEFACTOR_SWIM\t\t\t1\t\t//should be 0.66, swim speed = 150\n#define DISTANCEFACTOR_WALK\t\t\t0.33f\t//walk speed = 300\n\n//cache refresh time\n#define CACHE_REFRESHTIME\t\t15.0f\t//15 seconds refresh time\n\n//maximum number of routing updates each frame\n#define MAX_FRAMEROUTINGUPDATES\t\t10\n\n\n/*\n\n  area routing cache:\n  stores the distances within one cluster to a specific goal area\n  this goal area is in this same cluster and could be a cluster portal\n  for every cluster there's a list with routing cache for every area\n  in that cluster (including the portals of that cluster)\n  area cache stores aasworld.clusters[?].numreachabilityareas travel times\n\n  portal routing cache:\n  stores the distances of all portals to a specific goal area\n  this goal area could be in any cluster and could also be a cluster portal\n  for every area (aasworld.numareas) the portal cache stores\n  aasworld.numportals travel times\n\n*/\n\n#ifdef ROUTING_DEBUG\nint numareacacheupdates;\nint numportalcacheupdates;\n#endif //ROUTING_DEBUG\n\nint routingcachesize;\nint max_routingcachesize;\n\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#ifdef ROUTING_DEBUG\nvoid AAS_RoutingInfo(void)\n{\n\tbotimport.Print(PRT_MESSAGE, \"%d area cache updates\\n\", numareacacheupdates);\n\tbotimport.Print(PRT_MESSAGE, \"%d portal cache updates\\n\", numportalcacheupdates);\n\tbotimport.Print(PRT_MESSAGE, \"%d bytes routing cache\\n\", routingcachesize);\n} //end of the function AAS_RoutingInfo\n#endif //ROUTING_DEBUG\n//===========================================================================\n// returns the number of the area in the cluster\n// assumes the given area is in the given cluster or a portal of the cluster\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n__inline int AAS_ClusterAreaNum(int cluster, int areanum)\n{\n\tint side, areacluster;\n\n\tareacluster = aasworld.areasettings[areanum].cluster;\n\tif (areacluster > 0) return aasworld.areasettings[areanum].clusterareanum;\n\telse\n\t{\n/*#ifdef ROUTING_DEBUG\n\t\tif (aasworld.portals[-areacluster].frontcluster != cluster &&\n\t\t\t\taasworld.portals[-areacluster].backcluster != cluster)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"portal %d: does not belong to cluster %d\\n\"\n\t\t\t\t\t\t\t\t\t\t\t, -areacluster, cluster);\n\t\t} //end if\n#endif //ROUTING_DEBUG*/\n\t\tside = aasworld.portals[-areacluster].frontcluster != cluster;\n\t\treturn aasworld.portals[-areacluster].clusterareanum[side];\n\t} //end else\n} //end of the function AAS_ClusterAreaNum\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_InitTravelFlagFromType(void)\n{\n\tint i;\n\n\tfor (i = 0; i < MAX_TRAVELTYPES; i++)\n\t{\n\t\taasworld.travelflagfortype[i] = TFL_INVALID;\n\t} //end for\n\taasworld.travelflagfortype[TRAVEL_INVALID] = TFL_INVALID;\n\taasworld.travelflagfortype[TRAVEL_WALK] = TFL_WALK;\n\taasworld.travelflagfortype[TRAVEL_CROUCH] = TFL_CROUCH;\n\taasworld.travelflagfortype[TRAVEL_BARRIERJUMP] = TFL_BARRIERJUMP;\n\taasworld.travelflagfortype[TRAVEL_JUMP] = TFL_JUMP;\n\taasworld.travelflagfortype[TRAVEL_LADDER] = TFL_LADDER;\n\taasworld.travelflagfortype[TRAVEL_WALKOFFLEDGE] = TFL_WALKOFFLEDGE;\n\taasworld.travelflagfortype[TRAVEL_SWIM] = TFL_SWIM;\n\taasworld.travelflagfortype[TRAVEL_WATERJUMP] = TFL_WATERJUMP;\n\taasworld.travelflagfortype[TRAVEL_TELEPORT] = TFL_TELEPORT;\n\taasworld.travelflagfortype[TRAVEL_ELEVATOR] = TFL_ELEVATOR;\n\taasworld.travelflagfortype[TRAVEL_ROCKETJUMP] = TFL_ROCKETJUMP;\n\taasworld.travelflagfortype[TRAVEL_BFGJUMP] = TFL_BFGJUMP;\n\taasworld.travelflagfortype[TRAVEL_GRAPPLEHOOK] = TFL_GRAPPLEHOOK;\n\taasworld.travelflagfortype[TRAVEL_DOUBLEJUMP] = TFL_DOUBLEJUMP;\n\taasworld.travelflagfortype[TRAVEL_RAMPJUMP] = TFL_RAMPJUMP;\n\taasworld.travelflagfortype[TRAVEL_STRAFEJUMP] = TFL_STRAFEJUMP;\n\taasworld.travelflagfortype[TRAVEL_JUMPPAD] = TFL_JUMPPAD;\n\taasworld.travelflagfortype[TRAVEL_FUNCBOB] = TFL_FUNCBOB;\n} //end of the function AAS_InitTravelFlagFromType\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n__inline int AAS_TravelFlagForType_inline(int traveltype)\n{\n\tint tfl;\n\n\ttfl = 0;\n\tif (tfl & TRAVELFLAG_NOTTEAM1)\n\t\ttfl |= TFL_NOTTEAM1;\n\tif (tfl & TRAVELFLAG_NOTTEAM2)\n\t\ttfl |= TFL_NOTTEAM2;\n\ttraveltype &= TRAVELTYPE_MASK;\n\tif (traveltype < 0 || traveltype >= MAX_TRAVELTYPES)\n\t\treturn TFL_INVALID;\n\ttfl |= aasworld.travelflagfortype[traveltype];\n\treturn tfl;\n} //end of the function AAS_TravelFlagForType_inline\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_TravelFlagForType(int traveltype)\n{\n\treturn AAS_TravelFlagForType_inline(traveltype);\n} //end of the function AAS_TravelFlagForType_inline\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_UnlinkCache(aas_routingcache_t *cache)\n{\n\tif (cache->time_next) cache->time_next->time_prev = cache->time_prev;\n\telse aasworld.newestcache = cache->time_prev;\n\tif (cache->time_prev) cache->time_prev->time_next = cache->time_next;\n\telse aasworld.oldestcache = cache->time_next;\n\tcache->time_next = NULL;\n\tcache->time_prev = NULL;\n} //end of the function AAS_UnlinkCache\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_LinkCache(aas_routingcache_t *cache)\n{\n\tif (aasworld.newestcache)\n\t{\n\t\taasworld.newestcache->time_next = cache;\n\t\tcache->time_prev = aasworld.newestcache;\n\t} //end if\n\telse\n\t{\n\t\taasworld.oldestcache = cache;\n\t\tcache->time_prev = NULL;\n\t} //end else\n\tcache->time_next = NULL;\n\taasworld.newestcache = cache;\n} //end of the function AAS_LinkCache\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FreeRoutingCache(aas_routingcache_t *cache)\n{\n\tAAS_UnlinkCache(cache);\n\troutingcachesize -= cache->size;\n\tFreeMemory(cache);\n} //end of the function AAS_FreeRoutingCache\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_RemoveRoutingCacheInCluster( int clusternum )\n{\n\tint i;\n\taas_routingcache_t *cache, *nextcache;\n\taas_cluster_t *cluster;\n\n\tif (!aasworld.clusterareacache)\n\t\treturn;\n\tcluster = &aasworld.clusters[clusternum];\n\tfor (i = 0; i < cluster->numareas; i++)\n\t{\n\t\tfor (cache = aasworld.clusterareacache[clusternum][i]; cache; cache = nextcache)\n\t\t{\n\t\t\tnextcache = cache->next;\n\t\t\tAAS_FreeRoutingCache(cache);\n\t\t} //end for\n\t\taasworld.clusterareacache[clusternum][i] = NULL;\n\t} //end for\n} //end of the function AAS_RemoveRoutingCacheInCluster\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_RemoveRoutingCacheUsingArea( int areanum )\n{\n\tint i, clusternum;\n\taas_routingcache_t *cache, *nextcache;\n\n\tclusternum = aasworld.areasettings[areanum].cluster;\n\tif (clusternum > 0)\n\t{\n\t\t//remove all the cache in the cluster the area is in\n\t\tAAS_RemoveRoutingCacheInCluster( clusternum );\n\t} //end if\n\telse\n\t{\n\t\t// if this is a portal remove all cache in both the front and back cluster\n\t\tAAS_RemoveRoutingCacheInCluster( aasworld.portals[-clusternum].frontcluster );\n\t\tAAS_RemoveRoutingCacheInCluster( aasworld.portals[-clusternum].backcluster );\n\t} //end else\n\t// remove all portal cache\n\tfor (i = 0; i < aasworld.numareas; i++)\n\t{\n\t\t//refresh portal cache\n\t\tfor (cache = aasworld.portalcache[i]; cache; cache = nextcache)\n\t\t{\n\t\t\tnextcache = cache->next;\n\t\t\tAAS_FreeRoutingCache(cache);\n\t\t} //end for\n\t\taasworld.portalcache[i] = NULL;\n\t} //end for\n} //end of the function AAS_RemoveRoutingCacheUsingArea\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_EnableRoutingArea(int areanum, int enable)\n{\n\tint flags;\n\n\tif (areanum <= 0 || areanum >= aasworld.numareas)\n\t{\n\t\tif (bot_developer)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"AAS_EnableRoutingArea: areanum %d out of range\\n\", areanum);\n\t\t} //end if\n\t\treturn 0;\n\t} //end if\n\tflags = aasworld.areasettings[areanum].areaflags & AREA_DISABLED;\n\tif (enable < 0)\n\t\treturn !flags;\n\n\tif (enable)\n\t\taasworld.areasettings[areanum].areaflags &= ~AREA_DISABLED;\n\telse\n\t\taasworld.areasettings[areanum].areaflags |= AREA_DISABLED;\n\t// if the status of the area changed\n\tif ( (flags & AREA_DISABLED) != (aasworld.areasettings[areanum].areaflags & AREA_DISABLED) )\n\t{\n\t\t//remove all routing cache involving this area\n\t\tAAS_RemoveRoutingCacheUsingArea( areanum );\n\t} //end if\n\treturn !flags;\n} //end of the function AAS_EnableRoutingArea\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n__inline float AAS_RoutingTime(void)\n{\n\treturn AAS_Time();\n} //end of the function AAS_RoutingTime\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_GetAreaContentsTravelFlags(int areanum)\n{\n\tint contents, tfl;\n\n\tcontents = aasworld.areasettings[areanum].contents;\n\ttfl = 0;\n\tif (contents & AREACONTENTS_WATER)\n\t\ttfl |= TFL_WATER;\n\telse if (contents & AREACONTENTS_SLIME)\n\t\ttfl |= TFL_SLIME;\n\telse if (contents & AREACONTENTS_LAVA)\n\t\ttfl |= TFL_LAVA;\n\telse\n\t\ttfl |= TFL_AIR;\n\tif (contents & AREACONTENTS_DONOTENTER)\n\t\ttfl |= TFL_DONOTENTER;\n\tif (contents & AREACONTENTS_NOTTEAM1)\n\t\ttfl |= TFL_NOTTEAM1;\n\tif (contents & AREACONTENTS_NOTTEAM2)\n\t\ttfl |= TFL_NOTTEAM2;\n\tif (aasworld.areasettings[areanum].areaflags & AREA_BRIDGE)\n\t\ttfl |= TFL_BRIDGE;\n\treturn tfl;\n} //end of the function AAS_GetAreaContentsTravelFlags\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n__inline int AAS_AreaContentsTravelFlags_inline(int areanum)\n{\n\treturn aasworld.areacontentstravelflags[areanum];\n} //end of the function AAS_AreaContentsTravelFlags\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AreaContentsTravelFlags(int areanum)\n{\n\treturn aasworld.areacontentstravelflags[areanum];\n} //end of the function AAS_AreaContentsTravelFlags\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_InitAreaContentsTravelFlags(void)\n{\n\tint i;\n\n\tif (aasworld.areacontentstravelflags) FreeMemory(aasworld.areacontentstravelflags);\n\taasworld.areacontentstravelflags = (int *) GetClearedMemory(aasworld.numareas * sizeof(int));\n\t//\n\tfor (i = 0; i < aasworld.numareas; i++) {\n\t\taasworld.areacontentstravelflags[i] = AAS_GetAreaContentsTravelFlags(i);\n\t}\n} //end of the function AAS_InitAreaContentsTravelFlags\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_CreateReversedReachability(void)\n{\n\tint i, n;\n\taas_reversedlink_t *revlink;\n\taas_reachability_t *reach;\n\taas_areasettings_t *settings;\n\tchar *ptr;\n#ifdef DEBUG\n\tint starttime;\n\n\tstarttime = Sys_MilliSeconds();\n#endif\n\t//free reversed links that have already been created\n\tif (aasworld.reversedreachability) FreeMemory(aasworld.reversedreachability);\n\t//allocate memory for the reversed reachability links\n\tptr = (char *) GetClearedMemory(aasworld.numareas * sizeof(aas_reversedreachability_t) +\n\t\t\t\t\t\t\taasworld.reachabilitysize * sizeof(aas_reversedlink_t));\n\t//\n\taasworld.reversedreachability = (aas_reversedreachability_t *) ptr;\n\t//pointer to the memory for the reversed links\n\tptr += aasworld.numareas * sizeof(aas_reversedreachability_t);\n\t//check all reachabilities of all areas\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\t//settings of the area\n\t\tsettings = &aasworld.areasettings[i];\n\t\t//\n\t\tif (settings->numreachableareas >= 128)\n\t\t\tbotimport.Print(PRT_WARNING, \"area %d has more than 128 reachabilities\\n\", i);\n\t\t//create reversed links for the reachabilities\n\t\tfor (n = 0; n < settings->numreachableareas && n < 128; n++)\n\t\t{\n\t\t\t//reachability link\n\t\t\treach = &aasworld.reachability[settings->firstreachablearea + n];\n\t\t\t//\n\t\t\trevlink = (aas_reversedlink_t *) ptr;\n\t\t\tptr += sizeof(aas_reversedlink_t);\n\t\t\t//\n\t\t\trevlink->areanum = i;\n\t\t\trevlink->linknum = settings->firstreachablearea + n;\n\t\t\trevlink->next = aasworld.reversedreachability[reach->areanum].first;\n\t\t\taasworld.reversedreachability[reach->areanum].first = revlink;\n\t\t\taasworld.reversedreachability[reach->areanum].numlinks++;\n\t\t} //end for\n\t} //end for\n#ifdef DEBUG\n\tbotimport.Print(PRT_MESSAGE, \"reversed reachability %d msec\\n\", Sys_MilliSeconds() - starttime);\n#endif\n} //end of the function AAS_CreateReversedReachability\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nunsigned short int AAS_AreaTravelTime(int areanum, vec3_t start, vec3_t end)\n{\n\tint intdist;\n\tfloat dist;\n\tvec3_t dir;\n\n\tVectorSubtract(start, end, dir);\n\tdist = VectorLength(dir);\n\t//if crouch only area\n\tif (AAS_AreaCrouch(areanum)) dist *= DISTANCEFACTOR_CROUCH;\n\t//if swim area\n\telse if (AAS_AreaSwim(areanum)) dist *= DISTANCEFACTOR_SWIM;\n\t//normal walk area\n\telse dist *= DISTANCEFACTOR_WALK;\n\t//\n\tintdist = (int) dist;\n\t//make sure the distance isn't zero\n\tif (intdist <= 0) intdist = 1;\n\treturn intdist;\n} //end of the function AAS_AreaTravelTime\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_CalculateAreaTravelTimes(void)\n{\n\tint i, l, n, size;\n\tchar *ptr;\n\tvec3_t end;\n\taas_reversedreachability_t *revreach;\n\taas_reversedlink_t *revlink;\n\taas_reachability_t *reach;\n\taas_areasettings_t *settings;\n\tint starttime;\n\n\tstarttime = Sys_MilliSeconds();\n\t//if there are still area travel times, free the memory\n\tif (aasworld.areatraveltimes) FreeMemory(aasworld.areatraveltimes);\n\t//get the total size of all the area travel times\n\tsize = aasworld.numareas * sizeof(unsigned short **);\n\tfor (i = 0; i < aasworld.numareas; i++)\n\t{\n\t\trevreach = &aasworld.reversedreachability[i];\n\t\t//settings of the area\n\t\tsettings = &aasworld.areasettings[i];\n\t\t//\n\t\tsize += settings->numreachableareas * sizeof(unsigned short *);\n\t\t//\n\t\tsize += settings->numreachableareas * revreach->numlinks * sizeof(unsigned short);\n\t} //end for\n\t//allocate memory for the area travel times\n\tptr = (char *) GetClearedMemory(size);\n\taasworld.areatraveltimes = (unsigned short ***) ptr;\n\tptr += aasworld.numareas * sizeof(unsigned short **);\n\t//calcluate the travel times for all the areas\n\tfor (i = 0; i < aasworld.numareas; i++)\n\t{\n\t\t//reversed reachabilities of this area\n\t\trevreach = &aasworld.reversedreachability[i];\n\t\t//settings of the area\n\t\tsettings = &aasworld.areasettings[i];\n\t\t//\n\t\taasworld.areatraveltimes[i] = (unsigned short **) ptr;\n\t\tptr += settings->numreachableareas * sizeof(unsigned short *);\n\t\t//\n\t\tfor (l = 0; l < settings->numreachableareas; l++)\n\t\t{\n\t\t\taasworld.areatraveltimes[i][l] = (unsigned short *) ptr;\n\t\t\tptr += revreach->numlinks * sizeof(unsigned short);\n\t\t\t//reachability link\n\t\t\treach = &aasworld.reachability[settings->firstreachablearea + l];\n\t\t\t//\n\t\t\tfor (n = 0, revlink = revreach->first; revlink; revlink = revlink->next, n++)\n\t\t\t{\n\t\t\t\tVectorCopy(aasworld.reachability[revlink->linknum].end, end);\n\t\t\t\t//\n\t\t\t\taasworld.areatraveltimes[i][l][n] = AAS_AreaTravelTime(i, end, reach->start);\n\t\t\t} //end for\n\t\t} //end for\n\t} //end for\n#ifdef DEBUG\n\tbotimport.Print(PRT_MESSAGE, \"area travel times %d msec\\n\", Sys_MilliSeconds() - starttime);\n#endif\n} //end of the function AAS_CalculateAreaTravelTimes\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_PortalMaxTravelTime(int portalnum)\n{\n\tint l, n, t, maxt;\n\taas_portal_t *portal;\n\taas_reversedreachability_t *revreach;\n\taas_reversedlink_t *revlink;\n\taas_areasettings_t *settings;\n\n\tportal = &aasworld.portals[portalnum];\n\t//reversed reachabilities of this portal area\n\trevreach = &aasworld.reversedreachability[portal->areanum];\n\t//settings of the portal area\n\tsettings = &aasworld.areasettings[portal->areanum];\n\t//\n\tmaxt = 0;\n\tfor (l = 0; l < settings->numreachableareas; l++)\n\t{\n\t\tfor (n = 0, revlink = revreach->first; revlink; revlink = revlink->next, n++)\n\t\t{\n\t\t\tt = aasworld.areatraveltimes[portal->areanum][l][n];\n\t\t\tif (t > maxt)\n\t\t\t{\n\t\t\t\tmaxt = t;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\treturn maxt;\n} //end of the function AAS_PortalMaxTravelTime\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_InitPortalMaxTravelTimes(void)\n{\n\tint i;\n\n\tif (aasworld.portalmaxtraveltimes) FreeMemory(aasworld.portalmaxtraveltimes);\n\n\taasworld.portalmaxtraveltimes = (int *) GetClearedMemory(aasworld.numportals * sizeof(int));\n\n\tfor (i = 0; i < aasworld.numportals; i++)\n\t{\n\t\taasworld.portalmaxtraveltimes[i] = AAS_PortalMaxTravelTime(i);\n\t\t//botimport.Print(PRT_MESSAGE, \"portal %d max tt = %d\\n\", i, aasworld.portalmaxtraveltimes[i]);\n\t} //end for\n} //end of the function AAS_InitPortalMaxTravelTimes\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n/*\nint AAS_FreeOldestCache(void)\n{\n\tint i, j, bestcluster, bestarea, freed;\n\tfloat besttime;\n\taas_routingcache_t *cache, *bestcache;\n\n\tfreed = qfalse;\n\tbesttime = 999999999;\n\tbestcache = NULL;\n\tbestcluster = 0;\n\tbestarea = 0;\n\t//refresh cluster cache\n\tfor (i = 0; i < aasworld.numclusters; i++)\n\t{\n\t\tfor (j = 0; j < aasworld.clusters[i].numareas; j++)\n\t\t{\n\t\t\tfor (cache = aasworld.clusterareacache[i][j]; cache; cache = cache->next)\n\t\t\t{\n\t\t\t\t//never remove cache leading towards a portal\n\t\t\t\tif (aasworld.areasettings[cache->areanum].cluster < 0) continue;\n\t\t\t\t//if this cache is older than the cache we found so far\n\t\t\t\tif (cache->time < besttime)\n\t\t\t\t{\n\t\t\t\t\tbestcache = cache;\n\t\t\t\t\tbestcluster = i;\n\t\t\t\t\tbestarea = j;\n\t\t\t\t\tbesttime = cache->time;\n\t\t\t\t} //end if\n\t\t\t} //end for\n\t\t} //end for\n\t} //end for\n\tif (bestcache)\n\t{\n\t\tcache = bestcache;\n\t\tif (cache->prev) cache->prev->next = cache->next;\n\t\telse aasworld.clusterareacache[bestcluster][bestarea] = cache->next;\n\t\tif (cache->next) cache->next->prev = cache->prev;\n\t\tAAS_FreeRoutingCache(cache);\n\t\tfreed = qtrue;\n\t} //end if\n\tbesttime = 999999999;\n\tbestcache = NULL;\n\tbestarea = 0;\n\tfor (i = 0; i < aasworld.numareas; i++)\n\t{\n\t\t//refresh portal cache\n\t\tfor (cache = aasworld.portalcache[i]; cache; cache = cache->next)\n\t\t{\n\t\t\tif (cache->time < besttime)\n\t\t\t{\n\t\t\t\tbestcache = cache;\n\t\t\t\tbestarea = i;\n\t\t\t\tbesttime = cache->time;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\tif (bestcache)\n\t{\n\t\tcache = bestcache;\n\t\tif (cache->prev) cache->prev->next = cache->next;\n\t\telse aasworld.portalcache[bestarea] = cache->next;\n\t\tif (cache->next) cache->next->prev = cache->prev;\n\t\tAAS_FreeRoutingCache(cache);\n\t\tfreed = qtrue;\n\t} //end if\n\treturn freed;\n} //end of the function AAS_FreeOldestCache\n*/\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_FreeOldestCache(void)\n{\n\tint clusterareanum;\n\taas_routingcache_t *cache;\n\n\tfor (cache = aasworld.oldestcache; cache; cache = cache->time_next) {\n\t\t// never free area cache leading towards a portal\n\t\tif (cache->type == CACHETYPE_AREA && aasworld.areasettings[cache->areanum].cluster < 0) {\n\t\t\tcontinue;\n\t\t}\n\t\tbreak;\n\t}\n\tif (cache) {\n\t\t// unlink the cache\n\t\tif (cache->type == CACHETYPE_AREA) {\n\t\t\t//number of the area in the cluster\n\t\t\tclusterareanum = AAS_ClusterAreaNum(cache->cluster, cache->areanum);\n\t\t\t// unlink from cluster area cache\n\t\t\tif (cache->prev) cache->prev->next = cache->next;\n\t\t\telse aasworld.clusterareacache[cache->cluster][clusterareanum] = cache->next;\n\t\t\tif (cache->next) cache->next->prev = cache->prev;\n\t\t}\n\t\telse {\n\t\t\t// unlink from portal cache\n\t\t\tif (cache->prev) cache->prev->next = cache->next;\n\t\t\telse aasworld.portalcache[cache->areanum] = cache->next;\n\t\t\tif (cache->next) cache->next->prev = cache->prev;\n\t\t}\n\t\tAAS_FreeRoutingCache(cache);\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n} //end of the function AAS_FreeOldestCache\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\naas_routingcache_t *AAS_AllocRoutingCache(int numtraveltimes)\n{\n\taas_routingcache_t *cache;\n\tint size;\n\n\t//\n\tsize = sizeof(aas_routingcache_t)\n\t\t\t\t\t\t+ numtraveltimes * sizeof(unsigned short int)\n\t\t\t\t\t\t+ numtraveltimes * sizeof(unsigned char);\n\t//\n\troutingcachesize += size;\n\t//\n\tcache = (aas_routingcache_t *) GetClearedMemory(size);\n\tcache->reachabilities = (unsigned char *) cache + sizeof(aas_routingcache_t)\n\t\t\t\t\t\t\t\t+ numtraveltimes * sizeof(unsigned short int);\n\tcache->size = size;\n\treturn cache;\n} //end of the function AAS_AllocRoutingCache\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FreeAllClusterAreaCache(void)\n{\n\tint i, j;\n\taas_routingcache_t *cache, *nextcache;\n\taas_cluster_t *cluster;\n\n\t//free all cluster cache if existing\n\tif (!aasworld.clusterareacache) return;\n\t//free caches\n\tfor (i = 0; i < aasworld.numclusters; i++)\n\t{\n\t\tcluster = &aasworld.clusters[i];\n\t\tfor (j = 0; j < cluster->numareas; j++)\n\t\t{\n\t\t\tfor (cache = aasworld.clusterareacache[i][j]; cache; cache = nextcache)\n\t\t\t{\n\t\t\t\tnextcache = cache->next;\n\t\t\t\tAAS_FreeRoutingCache(cache);\n\t\t\t} //end for\n\t\t\taasworld.clusterareacache[i][j] = NULL;\n\t\t} //end for\n\t} //end for\n\t//free the cluster cache array\n\tFreeMemory(aasworld.clusterareacache);\n\taasworld.clusterareacache = NULL;\n} //end of the function AAS_FreeAllClusterAreaCache\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_InitClusterAreaCache(void)\n{\n\tint i, size;\n\tchar *ptr;\n\n\t//\n\tfor (size = 0, i = 0; i < aasworld.numclusters; i++)\n\t{\n\t\tsize += aasworld.clusters[i].numareas;\n\t} //end for\n\t//two dimensional array with pointers for every cluster to routing cache\n\t//for every area in that cluster\n\tptr = (char *) GetClearedMemory(\n\t\t\t\taasworld.numclusters * sizeof(aas_routingcache_t **) +\n\t\t\t\tsize * sizeof(aas_routingcache_t *));\n\taasworld.clusterareacache = (aas_routingcache_t ***) ptr;\n\tptr += aasworld.numclusters * sizeof(aas_routingcache_t **);\n\tfor (i = 0; i < aasworld.numclusters; i++)\n\t{\n\t\taasworld.clusterareacache[i] = (aas_routingcache_t **) ptr;\n\t\tptr += aasworld.clusters[i].numareas * sizeof(aas_routingcache_t *);\n\t} //end for\n} //end of the function AAS_InitClusterAreaCache\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FreeAllPortalCache(void)\n{\n\tint i;\n\taas_routingcache_t *cache, *nextcache;\n\n\t//free all portal cache if existing\n\tif (!aasworld.portalcache) return;\n\t//free portal caches\n\tfor (i = 0; i < aasworld.numareas; i++)\n\t{\n\t\tfor (cache = aasworld.portalcache[i]; cache; cache = nextcache)\n\t\t{\n\t\t\tnextcache = cache->next;\n\t\t\tAAS_FreeRoutingCache(cache);\n\t\t} //end for\n\t\taasworld.portalcache[i] = NULL;\n\t} //end for\n\tFreeMemory(aasworld.portalcache);\n\taasworld.portalcache = NULL;\n} //end of the function AAS_FreeAllPortalCache\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_InitPortalCache(void)\n{\n\t//\n\taasworld.portalcache = (aas_routingcache_t **) GetClearedMemory(\n\t\t\t\t\t\t\t\taasworld.numareas * sizeof(aas_routingcache_t *));\n} //end of the function AAS_InitPortalCache\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_InitRoutingUpdate(void)\n{\n\tint i, maxreachabilityareas;\n\n\t//free routing update fields if already existing\n\tif (aasworld.areaupdate) FreeMemory(aasworld.areaupdate);\n\t//\n\tmaxreachabilityareas = 0;\n\tfor (i = 0; i < aasworld.numclusters; i++)\n\t{\n\t\tif (aasworld.clusters[i].numreachabilityareas > maxreachabilityareas)\n\t\t{\n\t\t\tmaxreachabilityareas = aasworld.clusters[i].numreachabilityareas;\n\t\t} //end if\n\t} //end for\n\t//allocate memory for the routing update fields\n\taasworld.areaupdate = (aas_routingupdate_t *) GetClearedMemory(\n\t\t\t\t\t\t\t\t\tmaxreachabilityareas * sizeof(aas_routingupdate_t));\n\t//\n\tif (aasworld.portalupdate) FreeMemory(aasworld.portalupdate);\n\t//allocate memory for the portal update fields\n\taasworld.portalupdate = (aas_routingupdate_t *) GetClearedMemory(\n\t\t\t\t\t\t\t\t\t(aasworld.numportals+1) * sizeof(aas_routingupdate_t));\n} //end of the function AAS_InitRoutingUpdate\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_CreateAllRoutingCache(void)\n{\n\tint i, j, t;\n\n\taasworld.initialized = qtrue;\n\tbotimport.Print(PRT_MESSAGE, \"AAS_CreateAllRoutingCache\\n\");\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\tif (!AAS_AreaReachability(i)) continue;\n\t\tfor (j = 1; j < aasworld.numareas; j++)\n\t\t{\n\t\t\tif (i == j) continue;\n\t\t\tif (!AAS_AreaReachability(j)) continue;\n\t\t\tt = AAS_AreaTravelTimeToGoalArea(i, aasworld.areas[i].center, j, TFL_DEFAULT);\n\t\t\t//Log_Write(\"traveltime from %d to %d is %d\", i, j, t);\n\t\t} //end for\n\t} //end for\n\taasworld.initialized = qfalse;\n} //end of the function AAS_CreateAllRoutingCache\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n\n//the route cache header\n//this header is followed by numportalcache + numareacache aas_routingcache_t\n//structures that store routing cache\ntypedef struct routecacheheader_s\n{\n\tint ident;\n\tint version;\n\tint numareas;\n\tint numclusters;\n\tint areacrc;\n\tint clustercrc;\n\tint numportalcache;\n\tint numareacache;\n} routecacheheader_t;\n\n#define RCID\t\t\t\t\t\t(('C'<<24)+('R'<<16)+('E'<<8)+'M')\n#define RCVERSION\t\t\t\t\t2\n\n//void AAS_DecompressVis(byte *in, int numareas, byte *decompressed);\n//int AAS_CompressVis(byte *vis, int numareas, byte *dest);\n\nvoid AAS_WriteRouteCache(void)\n{\n\tint i, j, numportalcache, numareacache, totalsize;\n\taas_routingcache_t *cache;\n\taas_cluster_t *cluster;\n\tfileHandle_t fp;\n\tchar filename[MAX_QPATH];\n\troutecacheheader_t routecacheheader;\n\n\tnumportalcache = 0;\n\tfor (i = 0; i < aasworld.numareas; i++)\n\t{\n\t\tfor (cache = aasworld.portalcache[i]; cache; cache = cache->next)\n\t\t{\n\t\t\tnumportalcache++;\n\t\t} //end for\n\t} //end for\n\tnumareacache = 0;\n\tfor (i = 0; i < aasworld.numclusters; i++)\n\t{\n\t\tcluster = &aasworld.clusters[i];\n\t\tfor (j = 0; j < cluster->numareas; j++)\n\t\t{\n\t\t\tfor (cache = aasworld.clusterareacache[i][j]; cache; cache = cache->next)\n\t\t\t{\n\t\t\t\tnumareacache++;\n\t\t\t} //end for\n\t\t} //end for\n\t} //end for\n\t// open the file for writing\n\tCom_sprintf(filename, MAX_QPATH, \"maps/%s.rcd\", aasworld.mapname);\n\tbotimport.FS_FOpenFile( filename, &fp, FS_WRITE );\n\tif (!fp)\n\t{\n\t\tAAS_Error(\"Unable to open file: %s\\n\", filename);\n\t\treturn;\n\t} //end if\n\t//create the header\n\troutecacheheader.ident = RCID;\n\troutecacheheader.version = RCVERSION;\n\troutecacheheader.numareas = aasworld.numareas;\n\troutecacheheader.numclusters = aasworld.numclusters;\n\troutecacheheader.areacrc = CRC_ProcessString( (unsigned char *)aasworld.areas, sizeof(aas_area_t) * aasworld.numareas );\n\troutecacheheader.clustercrc = CRC_ProcessString( (unsigned char *)aasworld.clusters, sizeof(aas_cluster_t) * aasworld.numclusters );\n\troutecacheheader.numportalcache = numportalcache;\n\troutecacheheader.numareacache = numareacache;\n\t//write the header\n\tbotimport.FS_Write(&routecacheheader, sizeof(routecacheheader_t), fp);\n\t//\n\ttotalsize = 0;\n\t//write all the cache\n\tfor (i = 0; i < aasworld.numareas; i++)\n\t{\n\t\tfor (cache = aasworld.portalcache[i]; cache; cache = cache->next)\n\t\t{\n\t\t\tbotimport.FS_Write(cache, cache->size, fp);\n\t\t\ttotalsize += cache->size;\n\t\t} //end for\n\t} //end for\n\tfor (i = 0; i < aasworld.numclusters; i++)\n\t{\n\t\tcluster = &aasworld.clusters[i];\n\t\tfor (j = 0; j < cluster->numareas; j++)\n\t\t{\n\t\t\tfor (cache = aasworld.clusterareacache[i][j]; cache; cache = cache->next)\n\t\t\t{\n\t\t\t\tbotimport.FS_Write(cache, cache->size, fp);\n\t\t\t\ttotalsize += cache->size;\n\t\t\t} //end for\n\t\t} //end for\n\t} //end for\n\t// write the visareas\n\t/*\n\tfor (i = 0; i < aasworld.numareas; i++)\n\t{\n\t\tif (!aasworld.areavisibility[i]) {\n\t\t\tsize = 0;\n\t\t\tbotimport.FS_Write(&size, sizeof(int), fp);\n\t\t\tcontinue;\n\t\t}\n\t\tAAS_DecompressVis( aasworld.areavisibility[i], aasworld.numareas, aasworld.decompressedvis );\n\t\tsize = AAS_CompressVis( aasworld.decompressedvis, aasworld.numareas, aasworld.decompressedvis );\n\t\tbotimport.FS_Write(&size, sizeof(int), fp);\n\t\tbotimport.FS_Write(aasworld.decompressedvis, size, fp);\n\t}\n\t*/\n\t//\n\tbotimport.FS_FCloseFile(fp);\n\tbotimport.Print(PRT_MESSAGE, \"\\nroute cache written to %s\\n\", filename);\n\tbotimport.Print(PRT_MESSAGE, \"written %d bytes of routing cache\\n\", totalsize);\n} //end of the function AAS_WriteRouteCache\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\naas_routingcache_t *AAS_ReadCache(fileHandle_t fp)\n{\n\tint size;\n\taas_routingcache_t *cache;\n\n\tbotimport.FS_Read(&size, sizeof(size), fp);\n\tcache = (aas_routingcache_t *) GetMemory(size);\n\tcache->size = size;\n\tbotimport.FS_Read((unsigned char *)cache + sizeof(size), size - sizeof(size), fp);\n\tcache->reachabilities = (unsigned char *) cache + sizeof(aas_routingcache_t) - sizeof(unsigned short) +\n\t\t(size - sizeof(aas_routingcache_t) + sizeof(unsigned short)) / 3 * 2;\n\treturn cache;\n} //end of the function AAS_ReadCache\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_ReadRouteCache(void)\n{\n\tint i, clusterareanum;//, size;\n\tfileHandle_t fp;\n\tchar filename[MAX_QPATH];\n\troutecacheheader_t routecacheheader;\n\taas_routingcache_t *cache;\n\n\tCom_sprintf(filename, MAX_QPATH, \"maps/%s.rcd\", aasworld.mapname);\n\tbotimport.FS_FOpenFile( filename, &fp, FS_READ );\n\tif (!fp)\n\t{\n\t\treturn qfalse;\n\t} //end if\n\tbotimport.FS_Read(&routecacheheader, sizeof(routecacheheader_t), fp );\n\tif (routecacheheader.ident != RCID)\n\t{\n\t\tAAS_Error(\"%s is not a route cache dump\\n\");\n\t\treturn qfalse;\n\t} //end if\n\tif (routecacheheader.version != RCVERSION)\n\t{\n\t\tAAS_Error(\"route cache dump has wrong version %d, should be %d\", routecacheheader.version, RCVERSION);\n\t\treturn qfalse;\n\t} //end if\n\tif (routecacheheader.numareas != aasworld.numareas)\n\t{\n\t\t//AAS_Error(\"route cache dump has wrong number of areas\\n\");\n\t\treturn qfalse;\n\t} //end if\n\tif (routecacheheader.numclusters != aasworld.numclusters)\n\t{\n\t\t//AAS_Error(\"route cache dump has wrong number of clusters\\n\");\n\t\treturn qfalse;\n\t} //end if\n\tif (routecacheheader.areacrc !=\n\t\tCRC_ProcessString( (unsigned char *)aasworld.areas, sizeof(aas_area_t) * aasworld.numareas ))\n\t{\n\t\t//AAS_Error(\"route cache dump area CRC incorrect\\n\");\n\t\treturn qfalse;\n\t} //end if\n\tif (routecacheheader.clustercrc !=\n\t\tCRC_ProcessString( (unsigned char *)aasworld.clusters, sizeof(aas_cluster_t) * aasworld.numclusters ))\n\t{\n\t\t//AAS_Error(\"route cache dump cluster CRC incorrect\\n\");\n\t\treturn qfalse;\n\t} //end if\n\t//read all the portal cache\n\tfor (i = 0; i < routecacheheader.numportalcache; i++)\n\t{\n\t\tcache = AAS_ReadCache(fp);\n\t\tcache->next = aasworld.portalcache[cache->areanum];\n\t\tcache->prev = NULL;\n\t\tif (aasworld.portalcache[cache->areanum])\n\t\t\taasworld.portalcache[cache->areanum]->prev = cache;\n\t\taasworld.portalcache[cache->areanum] = cache;\n\t} //end for\n\t//read all the cluster area cache\n\tfor (i = 0; i < routecacheheader.numareacache; i++)\n\t{\n\t\tcache = AAS_ReadCache(fp);\n\t\tclusterareanum = AAS_ClusterAreaNum(cache->cluster, cache->areanum);\n\t\tcache->next = aasworld.clusterareacache[cache->cluster][clusterareanum];\n\t\tcache->prev = NULL;\n\t\tif (aasworld.clusterareacache[cache->cluster][clusterareanum])\n\t\t\taasworld.clusterareacache[cache->cluster][clusterareanum]->prev = cache;\n\t\taasworld.clusterareacache[cache->cluster][clusterareanum] = cache;\n\t} //end for\n\t// read the visareas\n\t/*\n\taasworld.areavisibility = (byte **) GetClearedMemory(aasworld.numareas * sizeof(byte *));\n\taasworld.decompressedvis = (byte *) GetClearedMemory(aasworld.numareas * sizeof(byte));\n\tfor (i = 0; i < aasworld.numareas; i++)\n\t{\n\t\tbotimport.FS_Read(&size, sizeof(size), fp );\n\t\tif (size) {\n\t\t\taasworld.areavisibility[i] = (byte *) GetMemory(size);\n\t\t\tbotimport.FS_Read(aasworld.areavisibility[i], size, fp );\n\t\t}\n\t}\n\t*/\n\t//\n\tbotimport.FS_FCloseFile(fp);\n\treturn qtrue;\n} //end of the function AAS_ReadRouteCache\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#define MAX_REACHABILITYPASSAREAS\t\t32\n\nvoid AAS_InitReachabilityAreas(void)\n{\n\tint i, j, numareas, areas[MAX_REACHABILITYPASSAREAS];\n\tint numreachareas;\n\taas_reachability_t *reach;\n\tvec3_t start, end;\n\n\tif (aasworld.reachabilityareas)\n\t\tFreeMemory(aasworld.reachabilityareas);\n\tif (aasworld.reachabilityareaindex)\n\t\tFreeMemory(aasworld.reachabilityareaindex);\n\n\taasworld.reachabilityareas = (aas_reachabilityareas_t *)\n\t\t\t\tGetClearedMemory(aasworld.reachabilitysize * sizeof(aas_reachabilityareas_t));\n\taasworld.reachabilityareaindex = (int *)\n\t\t\t\tGetClearedMemory(aasworld.reachabilitysize * MAX_REACHABILITYPASSAREAS * sizeof(int));\n\tnumreachareas = 0;\n\tfor (i = 0; i < aasworld.reachabilitysize; i++)\n\t{\n\t\treach = &aasworld.reachability[i];\n\t\tnumareas = 0;\n\t\tswitch(reach->traveltype & TRAVELTYPE_MASK)\n\t\t{\n\t\t\t//trace areas from start to end\n\t\t\tcase TRAVEL_BARRIERJUMP:\n\t\t\tcase TRAVEL_WATERJUMP:\n\t\t\t\tVectorCopy(reach->start, end);\n\t\t\t\tend[2] = reach->end[2];\n\t\t\t\tnumareas = AAS_TraceAreas(reach->start, end, areas, NULL, MAX_REACHABILITYPASSAREAS);\n\t\t\t\tbreak;\n\t\t\tcase TRAVEL_WALKOFFLEDGE:\n\t\t\t\tVectorCopy(reach->end, start);\n\t\t\t\tstart[2] = reach->start[2];\n\t\t\t\tnumareas = AAS_TraceAreas(start, reach->end, areas, NULL, MAX_REACHABILITYPASSAREAS);\n\t\t\t\tbreak;\n\t\t\tcase TRAVEL_GRAPPLEHOOK:\n\t\t\t\tnumareas = AAS_TraceAreas(reach->start, reach->end, areas, NULL, MAX_REACHABILITYPASSAREAS);\n\t\t\t\tbreak;\n\n\t\t\t//trace arch\n\t\t\tcase TRAVEL_JUMP: break;\n\t\t\tcase TRAVEL_ROCKETJUMP: break;\n\t\t\tcase TRAVEL_BFGJUMP: break;\n\t\t\tcase TRAVEL_JUMPPAD: break;\n\n\t\t\t//trace from reach->start to entity center, along entity movement\n\t\t\t//and from entity center to reach->end\n\t\t\tcase TRAVEL_ELEVATOR: break;\n\t\t\tcase TRAVEL_FUNCBOB: break;\n\n\t\t\t//no areas in between\n\t\t\tcase TRAVEL_WALK: break;\n\t\t\tcase TRAVEL_CROUCH: break;\n\t\t\tcase TRAVEL_LADDER: break;\n\t\t\tcase TRAVEL_SWIM: break;\n\t\t\tcase TRAVEL_TELEPORT: break;\n\t\t\tdefault: break;\n\t\t} //end switch\n\t\taasworld.reachabilityareas[i].firstarea = numreachareas;\n\t\taasworld.reachabilityareas[i].numareas = numareas;\n\t\tfor (j = 0; j < numareas; j++)\n\t\t{\n\t\t\taasworld.reachabilityareaindex[numreachareas++] = areas[j];\n\t\t} //end for\n\t} //end for\n} //end of the function AAS_InitReachabilityAreas\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_InitRouting(void)\n{\n\tAAS_InitTravelFlagFromType();\n\t//\n\tAAS_InitAreaContentsTravelFlags();\n\t//initialize the routing update fields\n\tAAS_InitRoutingUpdate();\n\t//create reversed reachability links used by the routing update algorithm\n\tAAS_CreateReversedReachability();\n\t//initialize the cluster cache\n\tAAS_InitClusterAreaCache();\n\t//initialize portal cache\n\tAAS_InitPortalCache();\n\t//initialize the area travel times\n\tAAS_CalculateAreaTravelTimes();\n\t//calculate the maximum travel times through portals\n\tAAS_InitPortalMaxTravelTimes();\n\t//get the areas reachabilities go through\n\tAAS_InitReachabilityAreas();\n\t//\n#ifdef ROUTING_DEBUG\n\tnumareacacheupdates = 0;\n\tnumportalcacheupdates = 0;\n#endif //ROUTING_DEBUG\n\t//\n\troutingcachesize = 0;\n\tmax_routingcachesize = 1024 * (int) LibVarValue(\"max_routingcache\", \"4096\");\n\t// read any routing cache if available\n\tAAS_ReadRouteCache();\n} //end of the function AAS_InitRouting\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FreeRoutingCaches(void)\n{\n\t// free all the existing cluster area cache\n\tAAS_FreeAllClusterAreaCache();\n\t// free all the existing portal cache\n\tAAS_FreeAllPortalCache();\n\t// free cached travel times within areas\n\tif (aasworld.areatraveltimes) FreeMemory(aasworld.areatraveltimes);\n\taasworld.areatraveltimes = NULL;\n\t// free cached maximum travel time through cluster portals\n\tif (aasworld.portalmaxtraveltimes) FreeMemory(aasworld.portalmaxtraveltimes);\n\taasworld.portalmaxtraveltimes = NULL;\n\t// free reversed reachability links\n\tif (aasworld.reversedreachability) FreeMemory(aasworld.reversedreachability);\n\taasworld.reversedreachability = NULL;\n\t// free routing algorithm memory\n\tif (aasworld.areaupdate) FreeMemory(aasworld.areaupdate);\n\taasworld.areaupdate = NULL;\n\tif (aasworld.portalupdate) FreeMemory(aasworld.portalupdate);\n\taasworld.portalupdate = NULL;\n\t// free lists with areas the reachabilities go through\n\tif (aasworld.reachabilityareas) FreeMemory(aasworld.reachabilityareas);\n\taasworld.reachabilityareas = NULL;\n\t// free the reachability area index\n\tif (aasworld.reachabilityareaindex) FreeMemory(aasworld.reachabilityareaindex);\n\taasworld.reachabilityareaindex = NULL;\n\t// free area contents travel flags look up table\n\tif (aasworld.areacontentstravelflags) FreeMemory(aasworld.areacontentstravelflags);\n\taasworld.areacontentstravelflags = NULL;\n} //end of the function AAS_FreeRoutingCaches\n//===========================================================================\n// update the given routing cache\n//\n// Parameter:\t\t\tareacache\t\t: routing cache to update\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_UpdateAreaRoutingCache(aas_routingcache_t *areacache)\n{\n\tint i, nextareanum, cluster, badtravelflags, clusterareanum, linknum;\n\tint numreachabilityareas;\n\tunsigned short int t, startareatraveltimes[128]; //NOTE: not more than 128 reachabilities per area allowed\n\taas_routingupdate_t *updateliststart, *updatelistend, *curupdate, *nextupdate;\n\taas_reachability_t *reach;\n\taas_reversedreachability_t *revreach;\n\taas_reversedlink_t *revlink;\n\n#ifdef ROUTING_DEBUG\n\tnumareacacheupdates++;\n#endif //ROUTING_DEBUG\n\t//number of reachability areas within this cluster\n\tnumreachabilityareas = aasworld.clusters[areacache->cluster].numreachabilityareas;\n\t//\n\taasworld.frameroutingupdates++;\n\t//clear the routing update fields\n//\tCom_Memset(aasworld.areaupdate, 0, aasworld.numareas * sizeof(aas_routingupdate_t));\n\t//\n\tbadtravelflags = ~areacache->travelflags;\n\t//\n\tclusterareanum = AAS_ClusterAreaNum(areacache->cluster, areacache->areanum);\n\tif (clusterareanum >= numreachabilityareas) return;\n\t//\n\tCom_Memset(startareatraveltimes, 0, sizeof(startareatraveltimes));\n\t//\n\tcurupdate = &aasworld.areaupdate[clusterareanum];\n\tcurupdate->areanum = areacache->areanum;\n\t//VectorCopy(areacache->origin, curupdate->start);\n\tcurupdate->areatraveltimes = startareatraveltimes;\n\tcurupdate->tmptraveltime = areacache->starttraveltime;\n\t//\n\tareacache->traveltimes[clusterareanum] = areacache->starttraveltime;\n\t//put the area to start with in the current read list\n\tcurupdate->next = NULL;\n\tcurupdate->prev = NULL;\n\tupdateliststart = curupdate;\n\tupdatelistend = curupdate;\n\t//while there are updates in the current list\n\twhile (updateliststart)\n\t{\n\t\tcurupdate = updateliststart;\n\t\t//\n\t\tif (curupdate->next) curupdate->next->prev = NULL;\n\t\telse updatelistend = NULL;\n\t\tupdateliststart = curupdate->next;\n\t\t//\n\t\tcurupdate->inlist = qfalse;\n\t\t//check all reversed reachability links\n\t\trevreach = &aasworld.reversedreachability[curupdate->areanum];\n\t\t//\n\t\tfor (i = 0, revlink = revreach->first; revlink; revlink = revlink->next, i++)\n\t\t{\n\t\t\tlinknum = revlink->linknum;\n\t\t\treach = &aasworld.reachability[linknum];\n\t\t\t//if there is used an undesired travel type\n\t\t\tif (AAS_TravelFlagForType_inline(reach->traveltype) & badtravelflags) continue;\n\t\t\t//if not allowed to enter the next area\n\t\t\tif (aasworld.areasettings[reach->areanum].areaflags & AREA_DISABLED) continue;\n\t\t\t//if the next area has a not allowed travel flag\n\t\t\tif (AAS_AreaContentsTravelFlags_inline(reach->areanum) & badtravelflags) continue;\n\t\t\t//number of the area the reversed reachability leads to\n\t\t\tnextareanum = revlink->areanum;\n\t\t\t//get the cluster number of the area\n\t\t\tcluster = aasworld.areasettings[nextareanum].cluster;\n\t\t\t//don't leave the cluster\n\t\t\tif (cluster > 0 && cluster != areacache->cluster) continue;\n\t\t\t//get the number of the area in the cluster\n\t\t\tclusterareanum = AAS_ClusterAreaNum(areacache->cluster, nextareanum);\n\t\t\tif (clusterareanum >= numreachabilityareas) continue;\n\t\t\t//time already travelled plus the traveltime through\n\t\t\t//the current area plus the travel time from the reachability\n\t\t\tt = curupdate->tmptraveltime +\n\t\t\t\t\t\t//AAS_AreaTravelTime(curupdate->areanum, curupdate->start, reach->end) +\n\t\t\t\t\t\tcurupdate->areatraveltimes[i] +\n\t\t\t\t\t\t\treach->traveltime;\n\t\t\t//\n\t\t\tif (!areacache->traveltimes[clusterareanum] ||\n\t\t\t\t\tareacache->traveltimes[clusterareanum] > t)\n\t\t\t{\n\t\t\t\tareacache->traveltimes[clusterareanum] = t;\n\t\t\t\tareacache->reachabilities[clusterareanum] = linknum - aasworld.areasettings[nextareanum].firstreachablearea;\n\t\t\t\tnextupdate = &aasworld.areaupdate[clusterareanum];\n\t\t\t\tnextupdate->areanum = nextareanum;\n\t\t\t\tnextupdate->tmptraveltime = t;\n\t\t\t\t//VectorCopy(reach->start, nextupdate->start);\n\t\t\t\tnextupdate->areatraveltimes = aasworld.areatraveltimes[nextareanum][linknum -\n\t\t\t\t\t\t\t\t\t\t\t\t\taasworld.areasettings[nextareanum].firstreachablearea];\n\t\t\t\tif (!nextupdate->inlist)\n\t\t\t\t{\n\t\t\t\t\t// we add the update to the end of the list\n\t\t\t\t\t// we could also use a B+ tree to have a real sorted list\n\t\t\t\t\t// on travel time which makes for faster routing updates\n\t\t\t\t\tnextupdate->next = NULL;\n\t\t\t\t\tnextupdate->prev = updatelistend;\n\t\t\t\t\tif (updatelistend) updatelistend->next = nextupdate;\n\t\t\t\t\telse updateliststart = nextupdate;\n\t\t\t\t\tupdatelistend = nextupdate;\n\t\t\t\t\tnextupdate->inlist = qtrue;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end for\n\t} //end while\n} //end of the function AAS_UpdateAreaRoutingCache\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\naas_routingcache_t *AAS_GetAreaRoutingCache(int clusternum, int areanum, int travelflags)\n{\n\tint clusterareanum;\n\taas_routingcache_t *cache, *clustercache;\n\n\t//number of the area in the cluster\n\tclusterareanum = AAS_ClusterAreaNum(clusternum, areanum);\n\t//pointer to the cache for the area in the cluster\n\tclustercache = aasworld.clusterareacache[clusternum][clusterareanum];\n\t//find the cache without undesired travel flags\n\tfor (cache = clustercache; cache; cache = cache->next)\n\t{\n\t\t//if there aren't used any undesired travel types for the cache\n\t\tif (cache->travelflags == travelflags) break;\n\t} //end for\n\t//if there was no cache\n\tif (!cache)\n\t{\n\t\tcache = AAS_AllocRoutingCache(aasworld.clusters[clusternum].numreachabilityareas);\n\t\tcache->cluster = clusternum;\n\t\tcache->areanum = areanum;\n\t\tVectorCopy(aasworld.areas[areanum].center, cache->origin);\n\t\tcache->starttraveltime = 1;\n\t\tcache->travelflags = travelflags;\n\t\tcache->prev = NULL;\n\t\tcache->next = clustercache;\n\t\tif (clustercache) clustercache->prev = cache;\n\t\taasworld.clusterareacache[clusternum][clusterareanum] = cache;\n\t\tAAS_UpdateAreaRoutingCache(cache);\n\t} //end if\n\telse\n\t{\n\t\tAAS_UnlinkCache(cache);\n\t} //end else\n\t//the cache has been accessed\n\tcache->time = AAS_RoutingTime();\n\tcache->type = CACHETYPE_AREA;\n\tAAS_LinkCache(cache);\n\treturn cache;\n} //end of the function AAS_GetAreaRoutingCache\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_UpdatePortalRoutingCache(aas_routingcache_t *portalcache)\n{\n\tint i, portalnum, clusterareanum, clusternum;\n\tunsigned short int t;\n\taas_portal_t *portal;\n\taas_cluster_t *cluster;\n\taas_routingcache_t *cache;\n\taas_routingupdate_t *updateliststart, *updatelistend, *curupdate, *nextupdate;\n\n#ifdef ROUTING_DEBUG\n\tnumportalcacheupdates++;\n#endif //ROUTING_DEBUG\n\t//clear the routing update fields\n//\tCom_Memset(aasworld.portalupdate, 0, (aasworld.numportals+1) * sizeof(aas_routingupdate_t));\n\t//\n\tcurupdate = &aasworld.portalupdate[aasworld.numportals];\n\tcurupdate->cluster = portalcache->cluster;\n\tcurupdate->areanum = portalcache->areanum;\n\tcurupdate->tmptraveltime = portalcache->starttraveltime;\n\t//if the start area is a cluster portal, store the travel time for that portal\n\tclusternum = aasworld.areasettings[portalcache->areanum].cluster;\n\tif (clusternum < 0)\n\t{\n\t\tportalcache->traveltimes[-clusternum] = portalcache->starttraveltime;\n\t} //end if\n\t//put the area to start with in the current read list\n\tcurupdate->next = NULL;\n\tcurupdate->prev = NULL;\n\tupdateliststart = curupdate;\n\tupdatelistend = curupdate;\n\t//while there are updates in the current list\n\twhile (updateliststart)\n\t{\n\t\tcurupdate = updateliststart;\n\t\t//remove the current update from the list\n\t\tif (curupdate->next) curupdate->next->prev = NULL;\n\t\telse updatelistend = NULL;\n\t\tupdateliststart = curupdate->next;\n\t\t//current update is removed from the list\n\t\tcurupdate->inlist = qfalse;\n\t\t//\n\t\tcluster = &aasworld.clusters[curupdate->cluster];\n\t\t//\n\t\tcache = AAS_GetAreaRoutingCache(curupdate->cluster,\n\t\t\t\t\t\t\t\tcurupdate->areanum, portalcache->travelflags);\n\t\t//take all portals of the cluster\n\t\tfor (i = 0; i < cluster->numportals; i++)\n\t\t{\n\t\t\tportalnum = aasworld.portalindex[cluster->firstportal + i];\n\t\t\tportal = &aasworld.portals[portalnum];\n\t\t\t//if this is the portal of the current update continue\n\t\t\tif (portal->areanum == curupdate->areanum) continue;\n\t\t\t//\n\t\t\tclusterareanum = AAS_ClusterAreaNum(curupdate->cluster, portal->areanum);\n\t\t\tif (clusterareanum >= cluster->numreachabilityareas) continue;\n\t\t\t//\n\t\t\tt = cache->traveltimes[clusterareanum];\n\t\t\tif (!t) continue;\n\t\t\tt += curupdate->tmptraveltime;\n\t\t\t//\n\t\t\tif (!portalcache->traveltimes[portalnum] ||\n\t\t\t\t\tportalcache->traveltimes[portalnum] > t)\n\t\t\t{\n\t\t\t\tportalcache->traveltimes[portalnum] = t;\n\t\t\t\tnextupdate = &aasworld.portalupdate[portalnum];\n\t\t\t\tif (portal->frontcluster == curupdate->cluster)\n\t\t\t\t{\n\t\t\t\t\tnextupdate->cluster = portal->backcluster;\n\t\t\t\t} //end if\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tnextupdate->cluster = portal->frontcluster;\n\t\t\t\t} //end else\n\t\t\t\tnextupdate->areanum = portal->areanum;\n\t\t\t\t//add travel time through the actual portal area for the next update\n\t\t\t\tnextupdate->tmptraveltime = t + aasworld.portalmaxtraveltimes[portalnum];\n\t\t\t\tif (!nextupdate->inlist)\n\t\t\t\t{\n\t\t\t\t\t// we add the update to the end of the list\n\t\t\t\t\t// we could also use a B+ tree to have a real sorted list\n\t\t\t\t\t// on travel time which makes for faster routing updates\n\t\t\t\t\tnextupdate->next = NULL;\n\t\t\t\t\tnextupdate->prev = updatelistend;\n\t\t\t\t\tif (updatelistend) updatelistend->next = nextupdate;\n\t\t\t\t\telse updateliststart = nextupdate;\n\t\t\t\t\tupdatelistend = nextupdate;\n\t\t\t\t\tnextupdate->inlist = qtrue;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end for\n\t} //end while\n} //end of the function AAS_UpdatePortalRoutingCache\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\naas_routingcache_t *AAS_GetPortalRoutingCache(int clusternum, int areanum, int travelflags)\n{\n\taas_routingcache_t *cache;\n\n\t//find the cached portal routing if existing\n\tfor (cache = aasworld.portalcache[areanum]; cache; cache = cache->next)\n\t{\n\t\tif (cache->travelflags == travelflags) break;\n\t} //end for\n\t//if the portal routing isn't cached\n\tif (!cache)\n\t{\n\t\tcache = AAS_AllocRoutingCache(aasworld.numportals);\n\t\tcache->cluster = clusternum;\n\t\tcache->areanum = areanum;\n\t\tVectorCopy(aasworld.areas[areanum].center, cache->origin);\n\t\tcache->starttraveltime = 1;\n\t\tcache->travelflags = travelflags;\n\t\t//add the cache to the cache list\n\t\tcache->prev = NULL;\n\t\tcache->next = aasworld.portalcache[areanum];\n\t\tif (aasworld.portalcache[areanum]) aasworld.portalcache[areanum]->prev = cache;\n\t\taasworld.portalcache[areanum] = cache;\n\t\t//update the cache\n\t\tAAS_UpdatePortalRoutingCache(cache);\n\t} //end if\n\telse\n\t{\n\t\tAAS_UnlinkCache(cache);\n\t} //end else\n\t//the cache has been accessed\n\tcache->time = AAS_RoutingTime();\n\tcache->type = CACHETYPE_PORTAL;\n\tAAS_LinkCache(cache);\n\treturn cache;\n} //end of the function AAS_GetPortalRoutingCache\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AreaRouteToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags, int *traveltime, int *reachnum)\n{\n\tint clusternum, goalclusternum, portalnum, i, clusterareanum, bestreachnum;\n\tunsigned short int t, besttime;\n\taas_portal_t *portal;\n\taas_cluster_t *cluster;\n\taas_routingcache_t *areacache, *portalcache;\n\taas_reachability_t *reach;\n\n\tif (!aasworld.initialized) return qfalse;\n\n\tif (areanum == goalareanum)\n\t{\n\t\t*traveltime = 1;\n\t\t*reachnum = 0;\n\t\treturn qtrue;\n\t}\n\t//\n\tif (areanum <= 0 || areanum >= aasworld.numareas)\n\t{\n\t\tif (bot_developer)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"AAS_AreaTravelTimeToGoalArea: areanum %d out of range\\n\", areanum);\n\t\t} //end if\n\t\treturn qfalse;\n\t} //end if\n\tif (goalareanum <= 0 || goalareanum >= aasworld.numareas)\n\t{\n\t\tif (bot_developer)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"AAS_AreaTravelTimeToGoalArea: goalareanum %d out of range\\n\", goalareanum);\n\t\t} //end if\n\t\treturn qfalse;\n\t} //end if\n\t// make sure the routing cache doesn't grow to large\n\twhile(AvailableMemory() < 1 * 1024 * 1024) {\n\t\tif (!AAS_FreeOldestCache()) break;\n\t}\n\t//\n\tif (AAS_AreaDoNotEnter(areanum) || AAS_AreaDoNotEnter(goalareanum))\n\t{\n\t\ttravelflags |= TFL_DONOTENTER;\n\t} //end if\n\t//NOTE: the number of routing updates is limited per frame\n\t/*\n\tif (aasworld.frameroutingupdates > MAX_FRAMEROUTINGUPDATES)\n\t{\n#ifdef DEBUG\n\t\t//Log_Write(\"WARNING: AAS_AreaTravelTimeToGoalArea: frame routing updates overflowed\");\n#endif\n\t\treturn 0;\n\t} //end if\n\t*/\n\t//\n\tclusternum = aasworld.areasettings[areanum].cluster;\n\tgoalclusternum = aasworld.areasettings[goalareanum].cluster;\n\t//check if the area is a portal of the goal area cluster\n\tif (clusternum < 0 && goalclusternum > 0)\n\t{\n\t\tportal = &aasworld.portals[-clusternum];\n\t\tif (portal->frontcluster == goalclusternum ||\n\t\t\t\tportal->backcluster == goalclusternum)\n\t\t{\n\t\t\tclusternum = goalclusternum;\n\t\t} //end if\n\t} //end if\n\t//check if the goalarea is a portal of the area cluster\n\telse if (clusternum > 0 && goalclusternum < 0)\n\t{\n\t\tportal = &aasworld.portals[-goalclusternum];\n\t\tif (portal->frontcluster == clusternum ||\n\t\t\t\tportal->backcluster == clusternum)\n\t\t{\n\t\t\tgoalclusternum = clusternum;\n\t\t} //end if\n\t} //end if\n\t//if both areas are in the same cluster\n\t//NOTE: there might be a shorter route via another cluster!!! but we don't care\n\tif (clusternum > 0 && goalclusternum > 0 && clusternum == goalclusternum)\n\t{\n\t\t//\n\t\tareacache = AAS_GetAreaRoutingCache(clusternum, goalareanum, travelflags);\n\t\t//the number of the area in the cluster\n\t\tclusterareanum = AAS_ClusterAreaNum(clusternum, areanum);\n\t\t//the cluster the area is in\n\t\tcluster = &aasworld.clusters[clusternum];\n\t\t//if the area is NOT a reachability area\n\t\tif (clusterareanum >= cluster->numreachabilityareas) return 0;\n\t\t//if it is possible to travel to the goal area through this cluster\n\t\tif (areacache->traveltimes[clusterareanum] != 0)\n\t\t{\n\t\t\t*reachnum = aasworld.areasettings[areanum].firstreachablearea +\n\t\t\t\t\t\t\tareacache->reachabilities[clusterareanum];\n\t\t\tif (!origin) {\n\t\t\t\t*traveltime = areacache->traveltimes[clusterareanum];\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t\treach = &aasworld.reachability[*reachnum];\n\t\t\t*traveltime = areacache->traveltimes[clusterareanum] +\n\t\t\t\t\t\t\tAAS_AreaTravelTime(areanum, origin, reach->start);\n\t\t\t//\n\t\t\treturn qtrue;\n\t\t} //end if\n\t} //end if\n\t//\n\tclusternum = aasworld.areasettings[areanum].cluster;\n\tgoalclusternum = aasworld.areasettings[goalareanum].cluster;\n\t//if the goal area is a portal\n\tif (goalclusternum < 0)\n\t{\n\t\t//just assume the goal area is part of the front cluster\n\t\tportal = &aasworld.portals[-goalclusternum];\n\t\tgoalclusternum = portal->frontcluster;\n\t} //end if\n\t//get the portal routing cache\n\tportalcache = AAS_GetPortalRoutingCache(goalclusternum, goalareanum, travelflags);\n\t//if the area is a cluster portal, read directly from the portal cache\n\tif (clusternum < 0)\n\t{\n\t\t*traveltime = portalcache->traveltimes[-clusternum];\n\t\t*reachnum = aasworld.areasettings[areanum].firstreachablearea +\n\t\t\t\t\t\tportalcache->reachabilities[-clusternum];\n\t\treturn qtrue;\n\t} //end if\n\t//\n\tbesttime = 0;\n\tbestreachnum = -1;\n\t//the cluster the area is in\n\tcluster = &aasworld.clusters[clusternum];\n\t//find the portal of the area cluster leading towards the goal area\n\tfor (i = 0; i < cluster->numportals; i++)\n\t{\n\t\tportalnum = aasworld.portalindex[cluster->firstportal + i];\n\t\t//if the goal area isn't reachable from the portal\n\t\tif (!portalcache->traveltimes[portalnum]) continue;\n\t\t//\n\t\tportal = &aasworld.portals[portalnum];\n\t\t//get the cache of the portal area\n\t\tareacache = AAS_GetAreaRoutingCache(clusternum, portal->areanum, travelflags);\n\t\t//current area inside the current cluster\n\t\tclusterareanum = AAS_ClusterAreaNum(clusternum, areanum);\n\t\t//if the area is NOT a reachability area\n\t\tif (clusterareanum >= cluster->numreachabilityareas) continue;\n\t\t//if the portal is NOT reachable from this area\n\t\tif (!areacache->traveltimes[clusterareanum]) continue;\n\t\t//total travel time is the travel time the portal area is from\n\t\t//the goal area plus the travel time towards the portal area\n\t\tt = portalcache->traveltimes[portalnum] + areacache->traveltimes[clusterareanum];\n\t\t//FIXME: add the exact travel time through the actual portal area\n\t\t//NOTE: for now we just add the largest travel time through the portal area\n\t\t//\t\tbecause we can't directly calculate the exact travel time\n\t\t//\t\tto be more specific we don't know which reachability was used to travel\n\t\t//\t\tinto the portal area\n\t\tt += aasworld.portalmaxtraveltimes[portalnum];\n\t\t//\n\t\tif (origin)\n\t\t{\n\t\t\t*reachnum = aasworld.areasettings[areanum].firstreachablearea +\n\t\t\t\t\t\t\tareacache->reachabilities[clusterareanum];\n\t\t\treach = aasworld.reachability + *reachnum;\n\t\t\tt += AAS_AreaTravelTime(areanum, origin, reach->start);\n\t\t} //end if\n\t\t//if the time is better than the one already found\n\t\tif (!besttime || t < besttime)\n\t\t{\n\t\t\tbestreachnum = *reachnum;\n\t\t\tbesttime = t;\n\t\t} //end if\n\t} //end for\n\tif (bestreachnum < 0) {\n\t\treturn qfalse;\n\t}\n\t*reachnum = bestreachnum;\n\t*traveltime = besttime;\n\treturn qtrue;\n} //end of the function AAS_AreaRouteToGoalArea\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AreaTravelTimeToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags)\n{\n\tint traveltime, reachnum;\n\n\tif (AAS_AreaRouteToGoalArea(areanum, origin, goalareanum, travelflags, &traveltime, &reachnum))\n\t{\n\t\treturn traveltime;\n\t}\n\treturn 0;\n} //end of the function AAS_AreaTravelTimeToGoalArea\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AreaReachabilityToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags)\n{\n\tint traveltime, reachnum;\n\n\tif (AAS_AreaRouteToGoalArea(areanum, origin, goalareanum, travelflags, &traveltime, &reachnum))\n\t{\n\t\treturn reachnum;\n\t}\n\treturn 0;\n} //end of the function AAS_AreaReachabilityToGoalArea\n//===========================================================================\n// predict the route and stop on one of the stop events\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_PredictRoute(struct aas_predictroute_s *route, int areanum, vec3_t origin,\n\t\t\t\t\t\t\tint goalareanum, int travelflags, int maxareas, int maxtime,\n\t\t\t\t\t\t\tint stopevent, int stopcontents, int stoptfl, int stopareanum)\n{\n\tint curareanum, reachnum, i, j, testareanum;\n\tvec3_t curorigin;\n\taas_reachability_t *reach;\n\taas_reachabilityareas_t *reachareas;\n\n\t//init output\n\troute->stopevent = RSE_NONE;\n\troute->endarea = goalareanum;\n\troute->endcontents = 0;\n\troute->endtravelflags = 0;\n\tVectorCopy(origin, route->endpos);\n\troute->time = 0;\n\n\tcurareanum = areanum;\n\tVectorCopy(origin, curorigin);\n\n\tfor (i = 0; curareanum != goalareanum && (!maxareas || i < maxareas) && i < aasworld.numareas; i++)\n\t{\n\t\treachnum = AAS_AreaReachabilityToGoalArea(curareanum, curorigin, goalareanum, travelflags);\n\t\tif (!reachnum)\n\t\t{\n\t\t\troute->stopevent = RSE_NOROUTE;\n\t\t\treturn qfalse;\n\t\t} //end if\n\t\treach = &aasworld.reachability[reachnum];\n\t\t//\n\t\tif (stopevent & RSE_USETRAVELTYPE)\n\t\t{\n\t\t\tif (AAS_TravelFlagForType_inline(reach->traveltype) & stoptfl)\n\t\t\t{\n\t\t\t\troute->stopevent = RSE_USETRAVELTYPE;\n\t\t\t\troute->endarea = curareanum;\n\t\t\t\troute->endcontents = aasworld.areasettings[curareanum].contents;\n\t\t\t\troute->endtravelflags = AAS_TravelFlagForType_inline(reach->traveltype);\n\t\t\t\tVectorCopy(reach->start, route->endpos);\n\t\t\t\treturn qtrue;\n\t\t\t} //end if\n\t\t\tif (AAS_AreaContentsTravelFlags_inline(reach->areanum) & stoptfl)\n\t\t\t{\n\t\t\t\troute->stopevent = RSE_USETRAVELTYPE;\n\t\t\t\troute->endarea = reach->areanum;\n\t\t\t\troute->endcontents = aasworld.areasettings[reach->areanum].contents;\n\t\t\t\troute->endtravelflags = AAS_AreaContentsTravelFlags_inline(reach->areanum);\n\t\t\t\tVectorCopy(reach->end, route->endpos);\n\t\t\t\troute->time += AAS_AreaTravelTime(areanum, origin, reach->start);\n\t\t\t\troute->time += reach->traveltime;\n\t\t\t\treturn qtrue;\n\t\t\t} //end if\n\t\t} //end if\n\t\treachareas = &aasworld.reachabilityareas[reachnum];\n\t\tfor (j = 0; j < reachareas->numareas + 1; j++)\n\t\t{\n\t\t\tif (j >= reachareas->numareas)\n\t\t\t\ttestareanum = reach->areanum;\n\t\t\telse\n\t\t\t\ttestareanum = aasworld.reachabilityareaindex[reachareas->firstarea + j];\n\t\t\tif (stopevent & RSE_ENTERCONTENTS)\n\t\t\t{\n\t\t\t\tif (aasworld.areasettings[testareanum].contents & stopcontents)\n\t\t\t\t{\n\t\t\t\t\troute->stopevent = RSE_ENTERCONTENTS;\n\t\t\t\t\troute->endarea = testareanum;\n\t\t\t\t\troute->endcontents = aasworld.areasettings[testareanum].contents;\n\t\t\t\t\tVectorCopy(reach->end, route->endpos);\n\t\t\t\t\troute->time += AAS_AreaTravelTime(areanum, origin, reach->start);\n\t\t\t\t\troute->time += reach->traveltime;\n\t\t\t\t\treturn qtrue;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t\tif (stopevent & RSE_ENTERAREA)\n\t\t\t{\n\t\t\t\tif (testareanum == stopareanum)\n\t\t\t\t{\n\t\t\t\t\troute->stopevent = RSE_ENTERAREA;\n\t\t\t\t\troute->endarea = testareanum;\n\t\t\t\t\troute->endcontents = aasworld.areasettings[testareanum].contents;\n\t\t\t\t\tVectorCopy(reach->start, route->endpos);\n\t\t\t\t\treturn qtrue;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end for\n\n\t\troute->time += AAS_AreaTravelTime(areanum, origin, reach->start);\n\t\troute->time += reach->traveltime;\n\t\troute->endarea = reach->areanum;\n\t\troute->endcontents = aasworld.areasettings[reach->areanum].contents;\n\t\troute->endtravelflags = AAS_TravelFlagForType_inline(reach->traveltype);\n\t\tVectorCopy(reach->end, route->endpos);\n\t\t//\n\t\tcurareanum = reach->areanum;\n\t\tVectorCopy(reach->end, curorigin);\n\t\t//\n\t\tif (maxtime && route->time > maxtime)\n\t\t\tbreak;\n\t} //end while\n\tif (curareanum != goalareanum)\n\t\treturn qfalse;\n\treturn qtrue;\n} //end of the function AAS_PredictRoute\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_BridgeWalkable(int areanum)\n{\n\treturn qfalse;\n} //end of the function AAS_BridgeWalkable\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ReachabilityFromNum(int num, struct aas_reachability_s *reach)\n{\n\tif (!aasworld.initialized)\n\t{\n\t\tCom_Memset(reach, 0, sizeof(aas_reachability_t));\n\t\treturn;\n\t} //end if\n\tif (num < 0 || num >= aasworld.reachabilitysize)\n\t{\n\t\tCom_Memset(reach, 0, sizeof(aas_reachability_t));\n\t\treturn;\n\t} //end if\n\tCom_Memcpy(reach, &aasworld.reachability[num], sizeof(aas_reachability_t));;\n} //end of the function AAS_ReachabilityFromNum\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_NextAreaReachability(int areanum, int reachnum)\n{\n\taas_areasettings_t *settings;\n\n\tif (!aasworld.initialized) return 0;\n\n\tif (areanum <= 0 || areanum >= aasworld.numareas)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"AAS_NextAreaReachability: areanum %d out of range\\n\", areanum);\n\t\treturn 0;\n\t} //end if\n\n\tsettings = &aasworld.areasettings[areanum];\n\tif (!reachnum)\n\t{\n\t\treturn settings->firstreachablearea;\n\t} //end if\n\tif (reachnum < settings->firstreachablearea)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"AAS_NextAreaReachability: reachnum < settings->firstreachableara\");\n\t\treturn 0;\n\t} //end if\n\treachnum++;\n\tif (reachnum >= settings->firstreachablearea + settings->numreachableareas)\n\t{\n\t\treturn 0;\n\t} //end if\n\treturn reachnum;\n} //end of the function AAS_NextAreaReachability\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_NextModelReachability(int num, int modelnum)\n{\n\tint i;\n\n\tif (num <= 0) num = 1;\n\telse if (num >= aasworld.reachabilitysize) return 0;\n\telse num++;\n\t//\n\tfor (i = num; i < aasworld.reachabilitysize; i++)\n\t{\n\t\tif ((aasworld.reachability[i].traveltype & TRAVELTYPE_MASK) == TRAVEL_ELEVATOR)\n\t\t{\n\t\t\tif (aasworld.reachability[i].facenum == modelnum) return i;\n\t\t} //end if\n\t\telse if ((aasworld.reachability[i].traveltype & TRAVELTYPE_MASK) == TRAVEL_FUNCBOB)\n\t\t{\n\t\t\tif ((aasworld.reachability[i].facenum & 0x0000FFFF) == modelnum) return i;\n\t\t} //end if\n\t} //end for\n\treturn 0;\n} //end of the function AAS_NextModelReachability\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_RandomGoalArea(int areanum, int travelflags, int *goalareanum, vec3_t goalorigin)\n{\n\tint i, n, t;\n\tvec3_t start, end;\n\taas_trace_t trace;\n\n\t//if the area has no reachabilities\n\tif (!AAS_AreaReachability(areanum)) return qfalse;\n\t//\n\tn = aasworld.numareas * random();\n\tfor (i = 0; i < aasworld.numareas; i++)\n\t{\n\t\tif (n <= 0) n = 1;\n\t\tif (n >= aasworld.numareas) n = 1;\n\t\tif (AAS_AreaReachability(n))\n\t\t{\n\t\t\tt = AAS_AreaTravelTimeToGoalArea(areanum, aasworld.areas[areanum].center, n, travelflags);\n\t\t\t//if the goal is reachable\n\t\t\tif (t > 0)\n\t\t\t{\n\t\t\t\tif (AAS_AreaSwim(n))\n\t\t\t\t{\n\t\t\t\t\t*goalareanum = n;\n\t\t\t\t\tVectorCopy(aasworld.areas[n].center, goalorigin);\n\t\t\t\t\t//botimport.Print(PRT_MESSAGE, \"found random goal area %d\\n\", *goalareanum);\n\t\t\t\t\treturn qtrue;\n\t\t\t\t} //end if\n\t\t\t\tVectorCopy(aasworld.areas[n].center, start);\n\t\t\t\tif (!AAS_PointAreaNum(start))\n\t\t\t\t\tLog_Write(\"area %d center %f %f %f in solid?\", n, start[0], start[1], start[2]);\n\t\t\t\tVectorCopy(start, end);\n\t\t\t\tend[2] -= 300;\n\t\t\t\ttrace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, -1);\n\t\t\t\tif (!trace.startsolid && trace.fraction < 1 && AAS_PointAreaNum(trace.endpos) == n)\n\t\t\t\t{\n\t\t\t\t\tif (AAS_AreaGroundFaceArea(n) > 300)\n\t\t\t\t\t{\n\t\t\t\t\t\t*goalareanum = n;\n\t\t\t\t\t\tVectorCopy(trace.endpos, goalorigin);\n\t\t\t\t\t\t//botimport.Print(PRT_MESSAGE, \"found random goal area %d\\n\", *goalareanum);\n\t\t\t\t\t\treturn qtrue;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end if\n\t\tn++;\n\t} //end for\n\treturn qfalse;\n} //end of the function AAS_RandomGoalArea\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AreaVisible(int srcarea, int destarea)\n{\n\treturn qfalse;\n} //end of the function AAS_AreaVisible\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat DistancePointToLine(vec3_t v1, vec3_t v2, vec3_t point)\n{\n\tvec3_t vec, p2;\n\n\tAAS_ProjectPointOntoVector(point, v1, v2, p2);\n\tVectorSubtract(point, p2, vec);\n\treturn VectorLength(vec);\n} //end of the function DistancePointToLine\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_NearestHideArea(int srcnum, vec3_t origin, int areanum, int enemynum, vec3_t enemyorigin, int enemyareanum, int travelflags)\n{\n\tint i, j, nextareanum, badtravelflags, numreach, bestarea;\n\tunsigned short int t, besttraveltime;\n\tstatic unsigned short int *hidetraveltimes;\n\taas_routingupdate_t *updateliststart, *updatelistend, *curupdate, *nextupdate;\n\taas_reachability_t *reach;\n\tfloat dist1, dist2;\n\tvec3_t v1, v2, p;\n\tqboolean startVisible;\n\n\t//\n\tif (!hidetraveltimes)\n\t{\n\t\thidetraveltimes = (unsigned short int *) GetClearedMemory(aasworld.numareas * sizeof(unsigned short int));\n\t} //end if\n\telse\n\t{\n\t\tCom_Memset(hidetraveltimes, 0, aasworld.numareas * sizeof(unsigned short int));\n\t} //end else\n\tbesttraveltime = 0;\n\tbestarea = 0;\n\t//assume visible\n\tstartVisible = qtrue;\n\t//\n\tbadtravelflags = ~travelflags;\n\t//\n\tcurupdate = &aasworld.areaupdate[areanum];\n\tcurupdate->areanum = areanum;\n\tVectorCopy(origin, curupdate->start);\n\tcurupdate->areatraveltimes = aasworld.areatraveltimes[areanum][0];\n\tcurupdate->tmptraveltime = 0;\n\t//put the area to start with in the current read list\n\tcurupdate->next = NULL;\n\tcurupdate->prev = NULL;\n\tupdateliststart = curupdate;\n\tupdatelistend = curupdate;\n\t//while there are updates in the list\n\twhile (updateliststart)\n\t{\n\t\tcurupdate = updateliststart;\n\t\t//\n\t\tif (curupdate->next) curupdate->next->prev = NULL;\n\t\telse updatelistend = NULL;\n\t\tupdateliststart = curupdate->next;\n\t\t//\n\t\tcurupdate->inlist = qfalse;\n\t\t//check all reversed reachability links\n\t\tnumreach = aasworld.areasettings[curupdate->areanum].numreachableareas;\n\t\treach = &aasworld.reachability[aasworld.areasettings[curupdate->areanum].firstreachablearea];\n\t\t//\n\t\tfor (i = 0; i < numreach; i++, reach++)\n\t\t{\n\t\t\t//if an undesired travel type is used\n\t\t\tif (AAS_TravelFlagForType_inline(reach->traveltype) & badtravelflags) continue;\n\t\t\t//\n\t\t\tif (AAS_AreaContentsTravelFlags_inline(reach->areanum) & badtravelflags) continue;\n\t\t\t//number of the area the reachability leads to\n\t\t\tnextareanum = reach->areanum;\n\t\t\t// if this moves us into the enemies area, skip it\n\t\t\tif (nextareanum == enemyareanum) continue;\n\t\t\t//time already travelled plus the traveltime through\n\t\t\t//the current area plus the travel time from the reachability\n\t\t\tt = curupdate->tmptraveltime +\n\t\t\t\t\t\tAAS_AreaTravelTime(curupdate->areanum, curupdate->start, reach->start) +\n\t\t\t\t\t\t\treach->traveltime;\n\n\t\t\t//avoid going near the enemy\n\t\t\tAAS_ProjectPointOntoVector(enemyorigin, curupdate->start, reach->end, p);\n\t\t\tfor (j = 0; j < 3; j++)\n\t\t\t\tif ((p[j] > curupdate->start[j] && p[j] > reach->end[j]) ||\n\t\t\t\t\t(p[j] < curupdate->start[j] && p[j] < reach->end[j]))\n\t\t\t\t\tbreak;\n\t\t\tif (j < 3)\n\t\t\t{\n\t\t\t\tVectorSubtract(enemyorigin, reach->end, v2);\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tVectorSubtract(enemyorigin, p, v2);\n\t\t\t} //end else\n\t\t\tdist2 = VectorLength(v2);\n\t\t\t//never go through the enemy\n\t\t\tif (dist2 < 40) continue;\n\t\t\t//\n\t\t\tVectorSubtract(enemyorigin, curupdate->start, v1);\n\t\t\tdist1 = VectorLength(v1);\n\t\t\t//\n\t\t\tif (dist2 < dist1)\n\t\t\t{\n\t\t\t\tt += (dist1 - dist2) * 10;\n\t\t\t}\n\t\t\t// if we weren't visible when starting, make sure we don't move into their view\n\t\t\tif (!startVisible && AAS_AreaVisible(enemyareanum, nextareanum)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t//\n\t\t\tif (besttraveltime && t >= besttraveltime) continue;\n\t\t\t//\n\t\t\tif (!hidetraveltimes[nextareanum] ||\n\t\t\t\t\thidetraveltimes[nextareanum] > t)\n\t\t\t{\n\t\t\t\t//if the nextarea is not visible from the enemy area\n\t\t\t\tif (!AAS_AreaVisible(enemyareanum, nextareanum))\n\t\t\t\t{\n\t\t\t\t\tbesttraveltime = t;\n\t\t\t\t\tbestarea = nextareanum;\n\t\t\t\t} //end if\n\t\t\t\thidetraveltimes[nextareanum] = t;\n\t\t\t\tnextupdate = &aasworld.areaupdate[nextareanum];\n\t\t\t\tnextupdate->areanum = nextareanum;\n\t\t\t\tnextupdate->tmptraveltime = t;\n\t\t\t\t//remember where we entered this area\n\t\t\t\tVectorCopy(reach->end, nextupdate->start);\n\t\t\t\t//if this update is not in the list yet\n\t\t\t\tif (!nextupdate->inlist)\n\t\t\t\t{\n\t\t\t\t\t//add the new update to the end of the list\n\t\t\t\t\tnextupdate->next = NULL;\n\t\t\t\t\tnextupdate->prev = updatelistend;\n\t\t\t\t\tif (updatelistend) updatelistend->next = nextupdate;\n\t\t\t\t\telse updateliststart = nextupdate;\n\t\t\t\t\tupdatelistend = nextupdate;\n\t\t\t\t\tnextupdate->inlist = qtrue;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end for\n\t} //end while\n\treturn bestarea;\n} //end of the function AAS_NearestHideArea\n"
  },
  {
    "path": "code/botlib/be_aas_route.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_route.h\n *\n * desc:\t\tAAS\n *\n * $Archive: /source/code/botlib/be_aas_route.h $\n *\n *****************************************************************************/\n\n#ifdef AASINTERN\n//initialize the AAS routing\nvoid AAS_InitRouting(void);\n//free the AAS routing caches\nvoid AAS_FreeRoutingCaches(void);\n//returns the travel time from start to end in the given area\nunsigned short int AAS_AreaTravelTime(int areanum, vec3_t start, vec3_t end);\n//\nvoid AAS_CreateAllRoutingCache(void);\nvoid AAS_WriteRouteCache(void);\n//\nvoid AAS_RoutingInfo(void);\n#endif //AASINTERN\n\n//returns the travel flag for the given travel type\nint AAS_TravelFlagForType(int traveltype);\n//return the travel flag(s) for traveling through this area\nint AAS_AreaContentsTravelFlags(int areanum);\n//returns the index of the next reachability for the given area\nint AAS_NextAreaReachability(int areanum, int reachnum);\n//returns the reachability with the given index\nvoid AAS_ReachabilityFromNum(int num, struct aas_reachability_s *reach);\n//returns a random goal area and goal origin\nint AAS_RandomGoalArea(int areanum, int travelflags, int *goalareanum, vec3_t goalorigin);\n//enable or disable an area for routing\nint AAS_EnableRoutingArea(int areanum, int enable);\n//returns the travel time within the given area from start to end\nunsigned short int AAS_AreaTravelTime(int areanum, vec3_t start, vec3_t end);\n//returns the travel time from the area to the goal area using the given travel flags\nint AAS_AreaTravelTimeToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags);\n//predict a route up to a stop event\nint AAS_PredictRoute(struct aas_predictroute_s *route, int areanum, vec3_t origin,\n\t\t\t\t\t\t\tint goalareanum, int travelflags, int maxareas, int maxtime,\n\t\t\t\t\t\t\tint stopevent, int stopcontents, int stoptfl, int stopareanum);\n\n\n"
  },
  {
    "path": "code/botlib/be_aas_routealt.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_routealt.c\n *\n * desc:\t\tAAS\n *\n * $Archive: /MissionPack/code/botlib/be_aas_routealt.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_utils.h\"\n#include \"l_memory.h\"\n#include \"l_log.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#include \"aasfile.h\"\n#include \"../game/botlib.h\"\n#include \"../game/be_aas.h\"\n#include \"be_aas_funcs.h\"\n#include \"be_interface.h\"\n#include \"be_aas_def.h\"\n\n#define ENABLE_ALTROUTING\n//#define ALTROUTE_DEBUG\n\ntypedef struct midrangearea_s\n{\n\tint valid;\n\tunsigned short starttime;\n\tunsigned short goaltime;\n} midrangearea_t;\n\nmidrangearea_t *midrangeareas;\nint *clusterareas;\nint numclusterareas;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_AltRoutingFloodCluster_r(int areanum)\n{\n\tint i, otherareanum;\n\taas_area_t *area;\n\taas_face_t *face;\n\n\t//add the current area to the areas of the current cluster\n\tclusterareas[numclusterareas] = areanum;\n\tnumclusterareas++;\n\t//remove the area from the mid range areas\n\tmidrangeareas[areanum].valid = qfalse;\n\t//flood to other areas through the faces of this area\n\tarea = &aasworld.areas[areanum];\n\tfor (i = 0; i < area->numfaces; i++)\n\t{\n\t\tface = &aasworld.faces[abs(aasworld.faceindex[area->firstface + i])];\n\t\t//get the area at the other side of the face\n\t\tif (face->frontarea == areanum) otherareanum = face->backarea;\n\t\telse otherareanum = face->frontarea;\n\t\t//if there is an area at the other side of this face\n\t\tif (!otherareanum) continue;\n\t\t//if the other area is not a midrange area\n\t\tif (!midrangeareas[otherareanum].valid) continue;\n\t\t//\n\t\tAAS_AltRoutingFloodCluster_r(otherareanum);\n\t} //end for\n} //end of the function AAS_AltRoutingFloodCluster_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AlternativeRouteGoals(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags,\n\t\t\t\t\t\t\t\t\t\t aas_altroutegoal_t *altroutegoals, int maxaltroutegoals,\n\t\t\t\t\t\t\t\t\t\t int type)\n{\n#ifndef ENABLE_ALTROUTING\n\treturn 0;\n#else\n\tint i, j, bestareanum;\n\tint numaltroutegoals, nummidrangeareas;\n\tint starttime, goaltime, goaltraveltime;\n\tfloat dist, bestdist;\n\tvec3_t mid, dir;\n#ifdef ALTROUTE_DEBUG\n\tint startmillisecs;\n\n\tstartmillisecs = Sys_MilliSeconds();\n#endif\n\n\tif (!startareanum || !goalareanum)\n\t\treturn 0;\n\t//travel time towards the goal area\n\tgoaltraveltime = AAS_AreaTravelTimeToGoalArea(startareanum, start, goalareanum, travelflags);\n\t//clear the midrange areas\n\tCom_Memset(midrangeareas, 0, aasworld.numareas * sizeof(midrangearea_t));\n\tnumaltroutegoals = 0;\n\t//\n\tnummidrangeareas = 0;\n\t//\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\t//\n\t\tif (!(type & ALTROUTEGOAL_ALL))\n\t\t{\n\t\t\tif (!(type & ALTROUTEGOAL_CLUSTERPORTALS && (aasworld.areasettings[i].contents & AREACONTENTS_CLUSTERPORTAL)))\n\t\t\t{\n\t\t\t\tif (!(type & ALTROUTEGOAL_VIEWPORTALS && (aasworld.areasettings[i].contents & AREACONTENTS_VIEWPORTAL)))\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end if\n\t\t//if the area has no reachabilities\n\t\tif (!AAS_AreaReachability(i)) continue;\n\t\t//tavel time from the area to the start area\n\t\tstarttime = AAS_AreaTravelTimeToGoalArea(startareanum, start, i, travelflags);\n\t\tif (!starttime) continue;\n\t\t//if the travel time from the start to the area is greater than the shortest goal travel time\n\t\tif (starttime > (float) 1.1 * goaltraveltime) continue;\n\t\t//travel time from the area to the goal area\n\t\tgoaltime = AAS_AreaTravelTimeToGoalArea(i, NULL, goalareanum, travelflags);\n\t\tif (!goaltime) continue;\n\t\t//if the travel time from the area to the goal is greater than the shortest goal travel time\n\t\tif (goaltime > (float) 0.8 * goaltraveltime) continue;\n\t\t//this is a mid range area\n\t\tmidrangeareas[i].valid = qtrue;\n\t\tmidrangeareas[i].starttime = starttime;\n\t\tmidrangeareas[i].goaltime = goaltime;\n\t\tLog_Write(\"%d midrange area %d\", nummidrangeareas, i);\n\t\tnummidrangeareas++;\n\t} //end for\n\t//\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\tif (!midrangeareas[i].valid) continue;\n\t\t//get the areas in one cluster\n\t\tnumclusterareas = 0;\n\t\tAAS_AltRoutingFloodCluster_r(i);\n\t\t//now we've got a cluster with areas through which an alternative route could go\n\t\t//get the 'center' of the cluster\n\t\tVectorClear(mid);\n\t\tfor (j = 0; j < numclusterareas; j++)\n\t\t{\n\t\t\tVectorAdd(mid, aasworld.areas[clusterareas[j]].center, mid);\n\t\t} //end for\n\t\tVectorScale(mid, 1.0 / numclusterareas, mid);\n\t\t//get the area closest to the center of the cluster\n\t\tbestdist = 999999;\n\t\tbestareanum = 0;\n\t\tfor (j = 0; j < numclusterareas; j++)\n\t\t{\n\t\t\tVectorSubtract(mid, aasworld.areas[clusterareas[j]].center, dir);\n\t\t\tdist = VectorLength(dir);\n\t\t\tif (dist < bestdist)\n\t\t\t{\n\t\t\t\tbestdist = dist;\n\t\t\t\tbestareanum = clusterareas[j];\n\t\t\t} //end if\n\t\t} //end for\n\t\t//now we've got an area for an alternative route\n\t\t//FIXME: add alternative goal origin\n\t\tVectorCopy(aasworld.areas[bestareanum].center, altroutegoals[numaltroutegoals].origin);\n\t\taltroutegoals[numaltroutegoals].areanum = bestareanum;\n\t\taltroutegoals[numaltroutegoals].starttraveltime = midrangeareas[bestareanum].starttime;\n\t\taltroutegoals[numaltroutegoals].goaltraveltime = midrangeareas[bestareanum].goaltime;\n\t\taltroutegoals[numaltroutegoals].extratraveltime =\n\t\t\t\t\t(midrangeareas[bestareanum].starttime + midrangeareas[bestareanum].goaltime) -\n\t\t\t\t\t\t\t\tgoaltraveltime;\n\t\tnumaltroutegoals++;\n\t\t//\n#ifdef ALTROUTE_DEBUG\n\t\tAAS_ShowAreaPolygons(bestareanum, 1, qtrue);\n#endif\n\t\t//don't return more than the maximum alternative route goals\n\t\tif (numaltroutegoals >= maxaltroutegoals) break;\n\t} //end for\n#ifdef ALTROUTE_DEBUG\n\tbotimport.Print(PRT_MESSAGE, \"alternative route goals in %d msec\\n\", Sys_MilliSeconds() - startmillisecs);\n#endif\n\treturn numaltroutegoals;\n#endif\n} //end of the function AAS_AlternativeRouteGoals\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_InitAlternativeRouting(void)\n{\n#ifdef ENABLE_ALTROUTING\n\tif (midrangeareas) FreeMemory(midrangeareas);\n\tmidrangeareas = (midrangearea_t *) GetMemory(aasworld.numareas * sizeof(midrangearea_t));\n\tif (clusterareas) FreeMemory(clusterareas);\n\tclusterareas = (int *) GetMemory(aasworld.numareas * sizeof(int));\n#endif\n} //end of the function AAS_InitAlternativeRouting\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ShutdownAlternativeRouting(void)\n{\n#ifdef ENABLE_ALTROUTING\n\tif (midrangeareas) FreeMemory(midrangeareas);\n\tmidrangeareas = NULL;\n\tif (clusterareas) FreeMemory(clusterareas);\n\tclusterareas = NULL;\n\tnumclusterareas = 0;\n#endif\n} //end of the function AAS_ShutdownAlternativeRouting\n"
  },
  {
    "path": "code/botlib/be_aas_routealt.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_routealt.h\n *\n * desc:\t\tAAS\n *\n * $Archive: /source/code/botlib/be_aas_routealt.h $\n *\n *****************************************************************************/\n\n#ifdef AASINTERN\nvoid AAS_InitAlternativeRouting(void);\nvoid AAS_ShutdownAlternativeRouting(void);\n#endif //AASINTERN\n\n\nint AAS_AlternativeRouteGoals(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags,\n\t\t\t\t\t\t\t\t\t\taas_altroutegoal_t *altroutegoals, int maxaltroutegoals,\n\t\t\t\t\t\t\t\t\t\tint type);\n"
  },
  {
    "path": "code/botlib/be_aas_sample.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_sample.c\n *\n * desc:\t\tAAS environment sampling\n *\n * $Archive: /MissionPack/code/botlib/be_aas_sample.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_memory.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#ifndef BSPC\n#include \"l_libvar.h\"\n#endif\n#include \"aasfile.h\"\n#include \"../game/botlib.h\"\n#include \"../game/be_aas.h\"\n#include \"be_interface.h\"\n#include \"be_aas_funcs.h\"\n#include \"be_aas_def.h\"\n\nextern botlib_import_t botimport;\n\n//#define AAS_SAMPLE_DEBUG\n\n#define BBOX_NORMAL_EPSILON\t\t0.001\n\n#define ON_EPSILON\t\t\t\t\t0 //0.0005\n\n#define TRACEPLANE_EPSILON\t\t\t0.125\n\ntypedef struct aas_tracestack_s\n{\n\tvec3_t start;\t\t//start point of the piece of line to trace\n\tvec3_t end;\t\t\t//end point of the piece of line to trace\n\tint planenum;\t\t//last plane used as splitter\n\tint nodenum;\t\t//node found after splitting with planenum\n} aas_tracestack_t;\n\nint numaaslinks;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_PresenceTypeBoundingBox(int presencetype, vec3_t mins, vec3_t maxs)\n{\n\tint index;\n\t//bounding box size for each presence type\n\tvec3_t boxmins[3] = {{0, 0, 0}, {-15, -15, -24}, {-15, -15, -24}};\n\tvec3_t boxmaxs[3] = {{0, 0, 0}, { 15,  15,  32}, { 15,  15,   8}};\n\n\tif (presencetype == PRESENCE_NORMAL) index = 1;\n\telse if (presencetype == PRESENCE_CROUCH) index = 2;\n\telse\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"AAS_PresenceTypeBoundingBox: unknown presence type\\n\");\n\t\tindex = 2;\n\t} //end if\n\tVectorCopy(boxmins[index], mins);\n\tVectorCopy(boxmaxs[index], maxs);\n} //end of the function AAS_PresenceTypeBoundingBox\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_InitAASLinkHeap(void)\n{\n\tint i, max_aaslinks;\n\n\tmax_aaslinks = aasworld.linkheapsize;\n\t//if there's no link heap present\n\tif (!aasworld.linkheap)\n\t{\n#ifdef BSPC\n\t\tmax_aaslinks = 6144;\n#else\n\t\tmax_aaslinks = (int) LibVarValue(\"max_aaslinks\", \"6144\");\n#endif\n\t\tif (max_aaslinks < 0) max_aaslinks = 0;\n\t\taasworld.linkheapsize = max_aaslinks;\n\t\taasworld.linkheap = (aas_link_t *) GetHunkMemory(max_aaslinks * sizeof(aas_link_t));\n\t} //end if\n\t//link the links on the heap\n\taasworld.linkheap[0].prev_ent = NULL;\n\taasworld.linkheap[0].next_ent = &aasworld.linkheap[1];\n\tfor (i = 1; i < max_aaslinks-1; i++)\n\t{\n\t\taasworld.linkheap[i].prev_ent = &aasworld.linkheap[i - 1];\n\t\taasworld.linkheap[i].next_ent = &aasworld.linkheap[i + 1];\n\t} //end for\n\taasworld.linkheap[max_aaslinks-1].prev_ent = &aasworld.linkheap[max_aaslinks-2];\n\taasworld.linkheap[max_aaslinks-1].next_ent = NULL;\n\t//pointer to the first free link\n\taasworld.freelinks = &aasworld.linkheap[0];\n\t//\n\tnumaaslinks = max_aaslinks;\n} //end of the function AAS_InitAASLinkHeap\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FreeAASLinkHeap(void)\n{\n\tif (aasworld.linkheap) FreeMemory(aasworld.linkheap);\n\taasworld.linkheap = NULL;\n\taasworld.linkheapsize = 0;\n} //end of the function AAS_FreeAASLinkHeap\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\naas_link_t *AAS_AllocAASLink(void)\n{\n\taas_link_t *link;\n\n\tlink = aasworld.freelinks;\n\tif (!link)\n\t{\n#ifndef BSPC\n\t\tif (bot_developer)\n#endif\n\t\t{\n\t\t\tbotimport.Print(PRT_FATAL, \"empty aas link heap\\n\");\n\t\t} //end if\n\t\treturn NULL;\n\t} //end if\n\tif (aasworld.freelinks) aasworld.freelinks = aasworld.freelinks->next_ent;\n\tif (aasworld.freelinks) aasworld.freelinks->prev_ent = NULL;\n\tnumaaslinks--;\n\treturn link;\n} //end of the function AAS_AllocAASLink\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_DeAllocAASLink(aas_link_t *link)\n{\n\tif (aasworld.freelinks) aasworld.freelinks->prev_ent = link;\n\tlink->prev_ent = NULL;\n\tlink->next_ent = aasworld.freelinks;\n\tlink->prev_area = NULL;\n\tlink->next_area = NULL;\n\taasworld.freelinks = link;\n\tnumaaslinks++;\n} //end of the function AAS_DeAllocAASLink\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_InitAASLinkedEntities(void)\n{\n\tif (!aasworld.loaded) return;\n\tif (aasworld.arealinkedentities) FreeMemory(aasworld.arealinkedentities);\n\taasworld.arealinkedentities = (aas_link_t **) GetClearedHunkMemory(\n\t\t\t\t\t\taasworld.numareas * sizeof(aas_link_t *));\n} //end of the function AAS_InitAASLinkedEntities\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FreeAASLinkedEntities(void)\n{\n\tif (aasworld.arealinkedentities) FreeMemory(aasworld.arealinkedentities);\n\taasworld.arealinkedentities = NULL;\n} //end of the function AAS_InitAASLinkedEntities\n//===========================================================================\n// returns the AAS area the point is in\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_PointAreaNum(vec3_t point)\n{\n\tint nodenum;\n\tvec_t\tdist;\n\taas_node_t *node;\n\taas_plane_t *plane;\n\n\tif (!aasworld.loaded)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"AAS_PointAreaNum: aas not loaded\\n\");\n\t\treturn 0;\n\t} //end if\n\n\t//start with node 1 because node zero is a dummy used for solid leafs\n\tnodenum = 1;\n\twhile (nodenum > 0)\n\t{\n//\t\tbotimport.Print(PRT_MESSAGE, \"[%d]\", nodenum);\n#ifdef AAS_SAMPLE_DEBUG\n\t\tif (nodenum >= aasworld.numnodes)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"nodenum = %d >= aasworld.numnodes = %d\\n\", nodenum, aasworld.numnodes);\n\t\t\treturn 0;\n\t\t} //end if\n#endif //AAS_SAMPLE_DEBUG\n\t\tnode = &aasworld.nodes[nodenum];\n#ifdef AAS_SAMPLE_DEBUG\n\t\tif (node->planenum < 0 || node->planenum >= aasworld.numplanes)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"node->planenum = %d >= aasworld.numplanes = %d\\n\", node->planenum, aasworld.numplanes);\n\t\t\treturn 0;\n\t\t} //end if\n#endif //AAS_SAMPLE_DEBUG\n\t\tplane = &aasworld.planes[node->planenum];\n\t\tdist = DotProduct(point, plane->normal) - plane->dist;\n\t\tif (dist > 0) nodenum = node->children[0];\n\t\telse nodenum = node->children[1];\n\t} //end while\n\tif (!nodenum)\n\t{\n#ifdef AAS_SAMPLE_DEBUG\n\t\tbotimport.Print(PRT_MESSAGE, \"in solid\\n\");\n#endif //AAS_SAMPLE_DEBUG\n\t\treturn 0;\n\t} //end if\n\treturn -nodenum;\n} //end of the function AAS_PointAreaNum\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_PointReachabilityAreaIndex( vec3_t origin )\n{\n\tint areanum, cluster, i, index;\n\n\tif (!aasworld.initialized)\n\t\treturn 0;\n\n\tif ( !origin )\n\t{\n\t\tindex = 0;\n\t\tfor (i = 0; i < aasworld.numclusters; i++)\n\t\t{\n\t\t\tindex += aasworld.clusters[i].numreachabilityareas;\n\t\t} //end for\n\t\treturn index;\n\t} //end if\n\n\tareanum = AAS_PointAreaNum( origin );\n\tif ( !areanum || !AAS_AreaReachability(areanum) )\n\t\treturn 0;\n\tcluster = aasworld.areasettings[areanum].cluster;\n\tareanum = aasworld.areasettings[areanum].clusterareanum;\n\tif (cluster < 0)\n\t{\n\t\tcluster = aasworld.portals[-cluster].frontcluster;\n\t\tareanum = aasworld.portals[-cluster].clusterareanum[0];\n\t} //end if\n\n\tindex = 0;\n\tfor (i = 0; i < cluster; i++)\n\t{\n\t\tindex += aasworld.clusters[i].numreachabilityareas;\n\t} //end for\n\tindex += areanum;\n\treturn index;\n} //end of the function AAS_PointReachabilityAreaIndex\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AreaCluster(int areanum)\n{\n\tif (areanum <= 0 || areanum >= aasworld.numareas)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"AAS_AreaCluster: invalid area number\\n\");\n\t\treturn 0;\n\t} //end if\n\treturn aasworld.areasettings[areanum].cluster;\n} //end of the function AAS_AreaCluster\n//===========================================================================\n// returns the presence types of the given area\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AreaPresenceType(int areanum)\n{\n\tif (!aasworld.loaded) return 0;\n\tif (areanum <= 0 || areanum >= aasworld.numareas)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"AAS_AreaPresenceType: invalid area number\\n\");\n\t\treturn 0;\n\t} //end if\n\treturn aasworld.areasettings[areanum].presencetype;\n} //end of the function AAS_AreaPresenceType\n//===========================================================================\n// returns the presence type at the given point\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_PointPresenceType(vec3_t point)\n{\n\tint areanum;\n\n\tif (!aasworld.loaded) return 0;\n\n\tareanum = AAS_PointAreaNum(point);\n\tif (!areanum) return PRESENCE_NONE;\n\treturn aasworld.areasettings[areanum].presencetype;\n} //end of the function AAS_PointPresenceType\n//===========================================================================\n// calculates the minimum distance between the origin of the box and the\n// given plane when both will collide on the given side of the plane\n//\n// normal\t=\tnormal vector of plane to calculate distance from\n// mins\t\t=\tminimums of box relative to origin\n// maxs\t\t=\tmaximums of box relative to origin\n// side\t\t=\tside of the plane we want to calculate the distance from\n//\t\t\t\t\t0 normal vector side\n//\t\t\t\t\t1 not normal vector side\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvec_t AAS_BoxOriginDistanceFromPlane(vec3_t normal, vec3_t mins, vec3_t maxs, int side)\n{\n\tvec3_t v1, v2;\n\tint i;\n\n\t//swap maxs and mins when on the other side of the plane\n\tif (side)\n\t{\n\t\t//get a point of the box that would be one of the first\n\t\t//to collide with the plane\n\t\tfor (i = 0; i < 3; i++)\n\t\t{\n\t\t\tif (normal[i] > BBOX_NORMAL_EPSILON) v1[i] = maxs[i];\n\t\t\telse if (normal[i] < -BBOX_NORMAL_EPSILON) v1[i] = mins[i];\n\t\t\telse v1[i] = 0;\n\t\t} //end for\n\t} //end if\n\telse\n\t{\n\t\t//get a point of the box that would be one of the first\n\t\t//to collide with the plane\n\t\tfor (i = 0; i < 3; i++)\n\t\t{\n\t\t\tif (normal[i] > BBOX_NORMAL_EPSILON) v1[i] = mins[i];\n\t\t\telse if (normal[i] < -BBOX_NORMAL_EPSILON) v1[i] = maxs[i];\n\t\t\telse v1[i] = 0;\n\t\t} //end for\n\t} //end else\n\t//\n\tVectorCopy(normal, v2);\n\tVectorInverse(v2);\n//\tVectorNegate(normal, v2);\n\treturn DotProduct(v1, v2);\n} //end of the function AAS_BoxOriginDistanceFromPlane\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_AreaEntityCollision(int areanum, vec3_t start, vec3_t end,\n\t\t\t\t\t\t\t\t\t\tint presencetype, int passent, aas_trace_t *trace)\n{\n\tint collision;\n\tvec3_t boxmins, boxmaxs;\n\taas_link_t *link;\n\tbsp_trace_t bsptrace;\n\n\tAAS_PresenceTypeBoundingBox(presencetype, boxmins, boxmaxs);\n\n\tCom_Memset(&bsptrace, 0, sizeof(bsp_trace_t)); //make compiler happy\n\t//assume no collision\n\tbsptrace.fraction = 1;\n\tcollision = qfalse;\n\tfor (link = aasworld.arealinkedentities[areanum]; link; link = link->next_ent)\n\t{\n\t\t//ignore the pass entity\n\t\tif (link->entnum == passent) continue;\n\t\t//\n\t\tif (AAS_EntityCollision(link->entnum, start, boxmins, boxmaxs, end,\n\t\t\t\t\t\t\t\t\t\t\t\tCONTENTS_SOLID|CONTENTS_PLAYERCLIP, &bsptrace))\n\t\t{\n\t\t\tcollision = qtrue;\n\t\t} //end if\n\t} //end for\n\tif (collision)\n\t{\n\t\ttrace->startsolid = bsptrace.startsolid;\n\t\ttrace->ent = bsptrace.ent;\n\t\tVectorCopy(bsptrace.endpos, trace->endpos);\n\t\ttrace->area = 0;\n\t\ttrace->planenum = 0;\n\t\treturn qtrue;\n\t} //end if\n\treturn qfalse;\n} //end of the function AAS_AreaEntityCollision\n//===========================================================================\n// recursive subdivision of the line by the BSP tree.\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\naas_trace_t AAS_TraceClientBBox(vec3_t start, vec3_t end, int presencetype,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tint passent)\n{\n\tint side, nodenum, tmpplanenum;\n\tfloat front, back, frac;\n\tvec3_t cur_start, cur_end, cur_mid, v1, v2;\n\taas_tracestack_t tracestack[127];\n\taas_tracestack_t *tstack_p;\n\taas_node_t *aasnode;\n\taas_plane_t *plane;\n\taas_trace_t trace;\n\n\t//clear the trace structure\n\tCom_Memset(&trace, 0, sizeof(aas_trace_t));\n\n\tif (!aasworld.loaded) return trace;\n\t\n\ttstack_p = tracestack;\n\t//we start with the whole line on the stack\n\tVectorCopy(start, tstack_p->start);\n\tVectorCopy(end, tstack_p->end);\n\ttstack_p->planenum = 0;\n\t//start with node 1 because node zero is a dummy for a solid leaf\n\ttstack_p->nodenum = 1;\t\t//starting at the root of the tree\n\ttstack_p++;\n\t\n\twhile (1)\n\t{\n\t\t//pop up the stack\n\t\ttstack_p--;\n\t\t//if the trace stack is empty (ended up with a piece of the\n\t\t//line to be traced in an area)\n\t\tif (tstack_p < tracestack)\n\t\t{\n\t\t\ttstack_p++;\n\t\t\t//nothing was hit\n\t\t\ttrace.startsolid = qfalse;\n\t\t\ttrace.fraction = 1.0;\n\t\t\t//endpos is the end of the line\n\t\t\tVectorCopy(end, trace.endpos);\n\t\t\t//nothing hit\n\t\t\ttrace.ent = 0;\n\t\t\ttrace.area = 0;\n\t\t\ttrace.planenum = 0;\n\t\t\treturn trace;\n\t\t} //end if\n\t\t//number of the current node to test the line against\n\t\tnodenum = tstack_p->nodenum;\n\t\t//if it is an area\n\t\tif (nodenum < 0)\n\t\t{\n#ifdef AAS_SAMPLE_DEBUG\n\t\t\tif (-nodenum > aasworld.numareasettings)\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"AAS_TraceBoundingBox: -nodenum out of range\\n\");\n\t\t\t\treturn trace;\n\t\t\t} //end if\n#endif //AAS_SAMPLE_DEBUG\n\t\t\t//botimport.Print(PRT_MESSAGE, \"areanum = %d, must be %d\\n\", -nodenum, AAS_PointAreaNum(start));\n\t\t\t//if can't enter the area because it hasn't got the right presence type\n\t\t\tif (!(aasworld.areasettings[-nodenum].presencetype & presencetype))\n\t\t\t{\n\t\t\t\t//if the start point is still the initial start point\n\t\t\t\t//NOTE: no need for epsilons because the points will be\n\t\t\t\t//exactly the same when they're both the start point\n\t\t\t\tif (tstack_p->start[0] == start[0] &&\n\t\t\t\t\t\ttstack_p->start[1] == start[1] &&\n\t\t\t\t\t\ttstack_p->start[2] == start[2])\n\t\t\t\t{\n\t\t\t\t\ttrace.startsolid = qtrue;\n\t\t\t\t\ttrace.fraction = 0.0;\n\t\t\t\t\tVectorClear(v1);\n\t\t\t\t} //end if\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\ttrace.startsolid = qfalse;\n\t\t\t\t\tVectorSubtract(end, start, v1);\n\t\t\t\t\tVectorSubtract(tstack_p->start, start, v2);\n\t\t\t\t\ttrace.fraction = VectorLength(v2) / VectorNormalize(v1);\n\t\t\t\t\tVectorMA(tstack_p->start, -0.125, v1, tstack_p->start);\n\t\t\t\t} //end else\n\t\t\t\tVectorCopy(tstack_p->start, trace.endpos);\n\t\t\t\ttrace.ent = 0;\n\t\t\t\ttrace.area = -nodenum;\n//\t\t\t\tVectorSubtract(end, start, v1);\n\t\t\t\ttrace.planenum = tstack_p->planenum;\n\t\t\t\t//always take the plane with normal facing towards the trace start\n\t\t\t\tplane = &aasworld.planes[trace.planenum];\n\t\t\t\tif (DotProduct(v1, plane->normal) > 0) trace.planenum ^= 1;\n\t\t\t\treturn trace;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (passent >= 0)\n\t\t\t\t{\n\t\t\t\t\tif (AAS_AreaEntityCollision(-nodenum, tstack_p->start,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttstack_p->end, presencetype, passent,\n\t\t\t\t\t\t\t\t\t\t\t\t\t&trace))\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!trace.startsolid)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tVectorSubtract(end, start, v1);\n\t\t\t\t\t\t\tVectorSubtract(trace.endpos, start, v2);\n\t\t\t\t\t\t\ttrace.fraction = VectorLength(v2) / VectorLength(v1);\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\treturn trace;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t} //end else\n\t\t\ttrace.lastarea = -nodenum;\n\t\t\tcontinue;\n\t\t} //end if\n\t\t//if it is a solid leaf\n\t\tif (!nodenum)\n\t\t{\n\t\t\t//if the start point is still the initial start point\n\t\t\t//NOTE: no need for epsilons because the points will be\n\t\t\t//exactly the same when they're both the start point\n\t\t\tif (tstack_p->start[0] == start[0] &&\n\t\t\t\t\ttstack_p->start[1] == start[1] &&\n\t\t\t\t\ttstack_p->start[2] == start[2])\n\t\t\t{\n\t\t\t\ttrace.startsolid = qtrue;\n\t\t\t\ttrace.fraction = 0.0;\n\t\t\t\tVectorClear(v1);\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\ttrace.startsolid = qfalse;\n\t\t\t\tVectorSubtract(end, start, v1);\n\t\t\t\tVectorSubtract(tstack_p->start, start, v2);\n\t\t\t\ttrace.fraction = VectorLength(v2) / VectorNormalize(v1);\n\t\t\t\tVectorMA(tstack_p->start, -0.125, v1, tstack_p->start);\n\t\t\t} //end else\n\t\t\tVectorCopy(tstack_p->start, trace.endpos);\n\t\t\ttrace.ent = 0;\n\t\t\ttrace.area = 0;\t//hit solid leaf\n//\t\t\tVectorSubtract(end, start, v1);\n\t\t\ttrace.planenum = tstack_p->planenum;\n\t\t\t//always take the plane with normal facing towards the trace start\n\t\t\tplane = &aasworld.planes[trace.planenum];\n\t\t\tif (DotProduct(v1, plane->normal) > 0) trace.planenum ^= 1;\n\t\t\treturn trace;\n\t\t} //end if\n#ifdef AAS_SAMPLE_DEBUG\n\t\tif (nodenum > aasworld.numnodes)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"AAS_TraceBoundingBox: nodenum out of range\\n\");\n\t\t\treturn trace;\n\t\t} //end if\n#endif //AAS_SAMPLE_DEBUG\n\t\t//the node to test against\n\t\taasnode = &aasworld.nodes[nodenum];\n\t\t//start point of current line to test against node\n\t\tVectorCopy(tstack_p->start, cur_start);\n\t\t//end point of the current line to test against node\n\t\tVectorCopy(tstack_p->end, cur_end);\n\t\t//the current node plane\n\t\tplane = &aasworld.planes[aasnode->planenum];\n\n\t\tswitch(plane->type)\n\t\t{/*FIXME: wtf doesn't this work? obviously the axial node planes aren't always facing positive!!!\n\t\t\t//check for axial planes\n\t\t\tcase PLANE_X:\n\t\t\t{\n\t\t\t\tfront = cur_start[0] - plane->dist;\n\t\t\t\tback = cur_end[0] - plane->dist;\n\t\t\t\tbreak;\n\t\t\t} //end case\n\t\t\tcase PLANE_Y:\n\t\t\t{\n\t\t\t\tfront = cur_start[1] - plane->dist;\n\t\t\t\tback = cur_end[1] - plane->dist;\n\t\t\t\tbreak;\n\t\t\t} //end case\n\t\t\tcase PLANE_Z:\n\t\t\t{\n\t\t\t\tfront = cur_start[2] - plane->dist;\n\t\t\t\tback = cur_end[2] - plane->dist;\n\t\t\t\tbreak;\n\t\t\t} //end case*/\n\t\t\tdefault: //gee it's not an axial plane\n\t\t\t{\n\t\t\t\tfront = DotProduct(cur_start, plane->normal) - plane->dist;\n\t\t\t\tback = DotProduct(cur_end, plane->normal) - plane->dist;\n\t\t\t\tbreak;\n\t\t\t} //end default\n\t\t} //end switch\n\t\t// bk010221 - old location of FPE hack and divide by zero expression\n\t\t//if the whole to be traced line is totally at the front of this node\n\t\t//only go down the tree with the front child\n\t\tif ((front >= -ON_EPSILON && back >= -ON_EPSILON))\n\t\t{\n\t\t\t//keep the current start and end point on the stack\n\t\t\t//and go down the tree with the front child\n\t\t\ttstack_p->nodenum = aasnode->children[0];\n\t\t\ttstack_p++;\n\t\t\tif (tstack_p >= &tracestack[127])\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"AAS_TraceBoundingBox: stack overflow\\n\");\n\t\t\t\treturn trace;\n\t\t\t} //end if\n\t\t} //end if\n\t\t//if the whole to be traced line is totally at the back of this node\n\t\t//only go down the tree with the back child\n\t\telse if ((front < ON_EPSILON && back < ON_EPSILON))\n\t\t{\n\t\t\t//keep the current start and end point on the stack\n\t\t\t//and go down the tree with the back child\n\t\t\ttstack_p->nodenum = aasnode->children[1];\n\t\t\ttstack_p++;\n\t\t\tif (tstack_p >= &tracestack[127])\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"AAS_TraceBoundingBox: stack overflow\\n\");\n\t\t\t\treturn trace;\n\t\t\t} //end if\n\t\t} //end if\n\t\t//go down the tree both at the front and back of the node\n\t\telse\n\t\t{\n\t\t\ttmpplanenum = tstack_p->planenum;\n\t\t\t// bk010221 - new location of divide by zero (see above)\n\t\t\tif ( front == back ) front -= 0.001f; // bk0101022 - hack/FPE \n                \t//calculate the hitpoint with the node (split point of the line)\n\t\t\t//put the crosspoint TRACEPLANE_EPSILON pixels on the near side\n\t\t\tif (front < 0) frac = (front + TRACEPLANE_EPSILON)/(front-back);\n\t\t\telse frac = (front - TRACEPLANE_EPSILON)/(front-back); // bk010221\n\t\t\t//\n\t\t\tif (frac < 0)\n\t\t\t\tfrac = 0.001f; //0\n\t\t\telse if (frac > 1)\n\t\t\t\tfrac = 0.999f; //1\n\t\t\t//frac = front / (front-back);\n\t\t\t//\n\t\t\tcur_mid[0] = cur_start[0] + (cur_end[0] - cur_start[0]) * frac;\n\t\t\tcur_mid[1] = cur_start[1] + (cur_end[1] - cur_start[1]) * frac;\n\t\t\tcur_mid[2] = cur_start[2] + (cur_end[2] - cur_start[2]) * frac;\n\n//\t\t\tAAS_DrawPlaneCross(cur_mid, plane->normal, plane->dist, plane->type, LINECOLOR_RED);\n\t\t\t//side the front part of the line is on\n\t\t\tside = front < 0;\n\t\t\t//first put the end part of the line on the stack (back side)\n\t\t\tVectorCopy(cur_mid, tstack_p->start);\n\t\t\t//not necesary to store because still on stack\n\t\t\t//VectorCopy(cur_end, tstack_p->end);\n\t\t\ttstack_p->planenum = aasnode->planenum;\n\t\t\ttstack_p->nodenum = aasnode->children[!side];\n\t\t\ttstack_p++;\n\t\t\tif (tstack_p >= &tracestack[127])\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"AAS_TraceBoundingBox: stack overflow\\n\");\n\t\t\t\treturn trace;\n\t\t\t} //end if\n\t\t\t//now put the part near the start of the line on the stack so we will\n\t\t\t//continue with thats part first. This way we'll find the first\n\t\t\t//hit of the bbox\n\t\t\tVectorCopy(cur_start, tstack_p->start);\n\t\t\tVectorCopy(cur_mid, tstack_p->end);\n\t\t\ttstack_p->planenum = tmpplanenum;\n\t\t\ttstack_p->nodenum = aasnode->children[side];\n\t\t\ttstack_p++;\n\t\t\tif (tstack_p >= &tracestack[127])\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"AAS_TraceBoundingBox: stack overflow\\n\");\n\t\t\t\treturn trace;\n\t\t\t} //end if\n\t\t} //end else\n\t} //end while\n//\treturn trace;\n} //end of the function AAS_TraceClientBBox\n//===========================================================================\n// recursive subdivision of the line by the BSP tree.\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_TraceAreas(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas)\n{\n\tint side, nodenum, tmpplanenum;\n\tint numareas;\n\tfloat front, back, frac;\n\tvec3_t cur_start, cur_end, cur_mid;\n\taas_tracestack_t tracestack[127];\n\taas_tracestack_t *tstack_p;\n\taas_node_t *aasnode;\n\taas_plane_t *plane;\n\n\tnumareas = 0;\n\tareas[0] = 0;\n\tif (!aasworld.loaded) return numareas;\n\n\ttstack_p = tracestack;\n\t//we start with the whole line on the stack\n\tVectorCopy(start, tstack_p->start);\n\tVectorCopy(end, tstack_p->end);\n\ttstack_p->planenum = 0;\n\t//start with node 1 because node zero is a dummy for a solid leaf\n\ttstack_p->nodenum = 1;\t\t//starting at the root of the tree\n\ttstack_p++;\n\n\twhile (1)\n\t{\n\t\t//pop up the stack\n\t\ttstack_p--;\n\t\t//if the trace stack is empty (ended up with a piece of the\n\t\t//line to be traced in an area)\n\t\tif (tstack_p < tracestack)\n\t\t{\n\t\t\treturn numareas;\n\t\t} //end if\n\t\t//number of the current node to test the line against\n\t\tnodenum = tstack_p->nodenum;\n\t\t//if it is an area\n\t\tif (nodenum < 0)\n\t\t{\n#ifdef AAS_SAMPLE_DEBUG\n\t\t\tif (-nodenum > aasworld.numareasettings)\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"AAS_TraceAreas: -nodenum = %d out of range\\n\", -nodenum);\n\t\t\t\treturn numareas;\n\t\t\t} //end if\n#endif //AAS_SAMPLE_DEBUG\n\t\t\t//botimport.Print(PRT_MESSAGE, \"areanum = %d, must be %d\\n\", -nodenum, AAS_PointAreaNum(start));\n\t\t\tareas[numareas] = -nodenum;\n\t\t\tif (points) VectorCopy(tstack_p->start, points[numareas]);\n\t\t\tnumareas++;\n\t\t\tif (numareas >= maxareas) return numareas;\n\t\t\tcontinue;\n\t\t} //end if\n\t\t//if it is a solid leaf\n\t\tif (!nodenum)\n\t\t{\n\t\t\tcontinue;\n\t\t} //end if\n#ifdef AAS_SAMPLE_DEBUG\n\t\tif (nodenum > aasworld.numnodes)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"AAS_TraceAreas: nodenum out of range\\n\");\n\t\t\treturn numareas;\n\t\t} //end if\n#endif //AAS_SAMPLE_DEBUG\n\t\t//the node to test against\n\t\taasnode = &aasworld.nodes[nodenum];\n\t\t//start point of current line to test against node\n\t\tVectorCopy(tstack_p->start, cur_start);\n\t\t//end point of the current line to test against node\n\t\tVectorCopy(tstack_p->end, cur_end);\n\t\t//the current node plane\n\t\tplane = &aasworld.planes[aasnode->planenum];\n\n\t\tswitch(plane->type)\n\t\t{/*FIXME: wtf doesn't this work? obviously the node planes aren't always facing positive!!!\n\t\t\t//check for axial planes\n\t\t\tcase PLANE_X:\n\t\t\t{\n\t\t\t\tfront = cur_start[0] - plane->dist;\n\t\t\t\tback = cur_end[0] - plane->dist;\n\t\t\t\tbreak;\n\t\t\t} //end case\n\t\t\tcase PLANE_Y:\n\t\t\t{\n\t\t\t\tfront = cur_start[1] - plane->dist;\n\t\t\t\tback = cur_end[1] - plane->dist;\n\t\t\t\tbreak;\n\t\t\t} //end case\n\t\t\tcase PLANE_Z:\n\t\t\t{\n\t\t\t\tfront = cur_start[2] - plane->dist;\n\t\t\t\tback = cur_end[2] - plane->dist;\n\t\t\t\tbreak;\n\t\t\t} //end case*/\n\t\t\tdefault: //gee it's not an axial plane\n\t\t\t{\n\t\t\t\tfront = DotProduct(cur_start, plane->normal) - plane->dist;\n\t\t\t\tback = DotProduct(cur_end, plane->normal) - plane->dist;\n\t\t\t\tbreak;\n\t\t\t} //end default\n\t\t} //end switch\n\n\t\t//if the whole to be traced line is totally at the front of this node\n\t\t//only go down the tree with the front child\n\t\tif (front > 0 && back > 0)\n\t\t{\n\t\t\t//keep the current start and end point on the stack\n\t\t\t//and go down the tree with the front child\n\t\t\ttstack_p->nodenum = aasnode->children[0];\n\t\t\ttstack_p++;\n\t\t\tif (tstack_p >= &tracestack[127])\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"AAS_TraceAreas: stack overflow\\n\");\n\t\t\t\treturn numareas;\n\t\t\t} //end if\n\t\t} //end if\n\t\t//if the whole to be traced line is totally at the back of this node\n\t\t//only go down the tree with the back child\n\t\telse if (front <= 0 && back <= 0)\n\t\t{\n\t\t\t//keep the current start and end point on the stack\n\t\t\t//and go down the tree with the back child\n\t\t\ttstack_p->nodenum = aasnode->children[1];\n\t\t\ttstack_p++;\n\t\t\tif (tstack_p >= &tracestack[127])\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"AAS_TraceAreas: stack overflow\\n\");\n\t\t\t\treturn numareas;\n\t\t\t} //end if\n\t\t} //end if\n\t\t//go down the tree both at the front and back of the node\n\t\telse\n\t\t{\n\t\t\ttmpplanenum = tstack_p->planenum;\n\t\t\t//calculate the hitpoint with the node (split point of the line)\n\t\t\t//put the crosspoint TRACEPLANE_EPSILON pixels on the near side\n\t\t\tif (front < 0) frac = (front)/(front-back);\n\t\t\telse frac = (front)/(front-back);\n\t\t\tif (frac < 0) frac = 0;\n\t\t\telse if (frac > 1) frac = 1;\n\t\t\t//frac = front / (front-back);\n\t\t\t//\n\t\t\tcur_mid[0] = cur_start[0] + (cur_end[0] - cur_start[0]) * frac;\n\t\t\tcur_mid[1] = cur_start[1] + (cur_end[1] - cur_start[1]) * frac;\n\t\t\tcur_mid[2] = cur_start[2] + (cur_end[2] - cur_start[2]) * frac;\n\n//\t\t\tAAS_DrawPlaneCross(cur_mid, plane->normal, plane->dist, plane->type, LINECOLOR_RED);\n\t\t\t//side the front part of the line is on\n\t\t\tside = front < 0;\n\t\t\t//first put the end part of the line on the stack (back side)\n\t\t\tVectorCopy(cur_mid, tstack_p->start);\n\t\t\t//not necesary to store because still on stack\n\t\t\t//VectorCopy(cur_end, tstack_p->end);\n\t\t\ttstack_p->planenum = aasnode->planenum;\n\t\t\ttstack_p->nodenum = aasnode->children[!side];\n\t\t\ttstack_p++;\n\t\t\tif (tstack_p >= &tracestack[127])\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"AAS_TraceAreas: stack overflow\\n\");\n\t\t\t\treturn numareas;\n\t\t\t} //end if\n\t\t\t//now put the part near the start of the line on the stack so we will\n\t\t\t//continue with thats part first. This way we'll find the first\n\t\t\t//hit of the bbox\n\t\t\tVectorCopy(cur_start, tstack_p->start);\n\t\t\tVectorCopy(cur_mid, tstack_p->end);\n\t\t\ttstack_p->planenum = tmpplanenum;\n\t\t\ttstack_p->nodenum = aasnode->children[side];\n\t\t\ttstack_p++;\n\t\t\tif (tstack_p >= &tracestack[127])\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"AAS_TraceAreas: stack overflow\\n\");\n\t\t\t\treturn numareas;\n\t\t\t} //end if\n\t\t} //end else\n\t} //end while\n//\treturn numareas;\n} //end of the function AAS_TraceAreas\n//===========================================================================\n// a simple cross product\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n// void AAS_OrthogonalToVectors(vec3_t v1, vec3_t v2, vec3_t res)\n#define AAS_OrthogonalToVectors(v1, v2, res) \\\n\t(res)[0] = ((v1)[1] * (v2)[2]) - ((v1)[2] * (v2)[1]);\\\n\t(res)[1] = ((v1)[2] * (v2)[0]) - ((v1)[0] * (v2)[2]);\\\n\t(res)[2] = ((v1)[0] * (v2)[1]) - ((v1)[1] * (v2)[0]);\n//===========================================================================\n// tests if the given point is within the face boundaries\n//\n// Parameter:\t\t\t\tface\t\t: face to test if the point is in it\n//\t\t\t\t\t\t\t\tpnormal\t: normal of the plane to use for the face\n//\t\t\t\t\t\t\t\tpoint\t\t: point to test if inside face boundaries\n// Returns:\t\t\t\t\tqtrue if the point is within the face boundaries\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_InsideFace(aas_face_t *face, vec3_t pnormal, vec3_t point, float epsilon)\n{\n\tint i, firstvertex, edgenum;\n\tvec3_t v0;\n\tvec3_t edgevec, pointvec, sepnormal;\n\taas_edge_t *edge;\n#ifdef AAS_SAMPLE_DEBUG\n\tint lastvertex = 0;\n#endif //AAS_SAMPLE_DEBUG\n\n\tif (!aasworld.loaded) return qfalse;\n\n\tfor (i = 0; i < face->numedges; i++)\n\t{\n\t\tedgenum = aasworld.edgeindex[face->firstedge + i];\n\t\tedge = &aasworld.edges[abs(edgenum)];\n\t\t//get the first vertex of the edge\n\t\tfirstvertex = edgenum < 0;\n\t\tVectorCopy(aasworld.vertexes[edge->v[firstvertex]], v0);\n\t\t//edge vector\n\t\tVectorSubtract(aasworld.vertexes[edge->v[!firstvertex]], v0, edgevec);\n\t\t//\n#ifdef AAS_SAMPLE_DEBUG\n\t\tif (lastvertex && lastvertex != edge->v[firstvertex])\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"winding not counter clockwise\\n\");\n\t\t} //end if\n\t\tlastvertex = edge->v[!firstvertex];\n#endif //AAS_SAMPLE_DEBUG\n\t\t//vector from first edge point to point possible in face\n\t\tVectorSubtract(point, v0, pointvec);\n\t\t//get a vector pointing inside the face orthogonal to both the\n\t\t//edge vector and the normal vector of the plane the face is in\n\t\t//this vector defines a plane through the origin (first vertex of\n\t\t//edge) and through both the edge vector and the normal vector\n\t\t//of the plane\n\t\tAAS_OrthogonalToVectors(edgevec, pnormal, sepnormal);\n\t\t//check on wich side of the above plane the point is\n\t\t//this is done by checking the sign of the dot product of the\n\t\t//vector orthogonal vector from above and the vector from the\n\t\t//origin (first vertex of edge) to the point \n\t\t//if the dotproduct is smaller than zero the point is outside the face\n\t\tif (DotProduct(pointvec, sepnormal) < -epsilon) return qfalse;\n\t} //end for\n\treturn qtrue;\n} //end of the function AAS_InsideFace\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_PointInsideFace(int facenum, vec3_t point, float epsilon)\n{\n\tint i, firstvertex, edgenum;\n\tvec_t *v1, *v2;\n\tvec3_t edgevec, pointvec, sepnormal;\n\taas_edge_t *edge;\n\taas_plane_t *plane;\n\taas_face_t *face;\n\n\tif (!aasworld.loaded) return qfalse;\n\n\tface = &aasworld.faces[facenum];\n\tplane = &aasworld.planes[face->planenum];\n\t//\n\tfor (i = 0; i < face->numedges; i++)\n\t{\n\t\tedgenum = aasworld.edgeindex[face->firstedge + i];\n\t\tedge = &aasworld.edges[abs(edgenum)];\n\t\t//get the first vertex of the edge\n\t\tfirstvertex = edgenum < 0;\n\t\tv1 = aasworld.vertexes[edge->v[firstvertex]];\n\t\tv2 = aasworld.vertexes[edge->v[!firstvertex]];\n\t\t//edge vector\n\t\tVectorSubtract(v2, v1, edgevec);\n\t\t//vector from first edge point to point possible in face\n\t\tVectorSubtract(point, v1, pointvec);\n\t\t//\n\t\tCrossProduct(edgevec, plane->normal, sepnormal);\n\t\t//\n\t\tif (DotProduct(pointvec, sepnormal) < -epsilon) return qfalse;\n\t} //end for\n\treturn qtrue;\n} //end of the function AAS_PointInsideFace\n//===========================================================================\n// returns the ground face the given point is above in the given area\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\naas_face_t *AAS_AreaGroundFace(int areanum, vec3_t point)\n{\n\tint i, facenum;\n\tvec3_t up = {0, 0, 1};\n\tvec3_t normal;\n\taas_area_t *area;\n\taas_face_t *face;\n\n\tif (!aasworld.loaded) return NULL;\n\n\tarea = &aasworld.areas[areanum];\n\tfor (i = 0; i < area->numfaces; i++)\n\t{\n\t\tfacenum = aasworld.faceindex[area->firstface + i];\n\t\tface = &aasworld.faces[abs(facenum)];\n\t\t//if this is a ground face\n\t\tif (face->faceflags & FACE_GROUND)\n\t\t{\n\t\t\t//get the up or down normal\n\t\t\tif (aasworld.planes[face->planenum].normal[2] < 0) VectorNegate(up, normal);\n\t\t\telse VectorCopy(up, normal);\n\t\t\t//check if the point is in the face\n\t\t\tif (AAS_InsideFace(face, normal, point, 0.01f)) return face;\n\t\t} //end if\n\t} //end for\n\treturn NULL;\n} //end of the function AAS_AreaGroundFace\n//===========================================================================\n// returns the face the trace end position is situated in\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FacePlane(int facenum, vec3_t normal, float *dist)\n{\n\taas_plane_t *plane;\n\n\tplane = &aasworld.planes[aasworld.faces[facenum].planenum];\n\tVectorCopy(plane->normal, normal);\n\t*dist = plane->dist;\n} //end of the function AAS_FacePlane\n//===========================================================================\n// returns the face the trace end position is situated in\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\naas_face_t *AAS_TraceEndFace(aas_trace_t *trace)\n{\n\tint i, facenum;\n\taas_area_t *area;\n\taas_face_t *face, *firstface = NULL;\n\n\tif (!aasworld.loaded) return NULL;\n\n\t//if started in solid no face was hit\n\tif (trace->startsolid) return NULL;\n\t//trace->lastarea is the last area the trace was in\n\tarea = &aasworld.areas[trace->lastarea];\n\t//check which face the trace.endpos was in\n\tfor (i = 0; i < area->numfaces; i++)\n\t{\n\t\tfacenum = aasworld.faceindex[area->firstface + i];\n\t\tface = &aasworld.faces[abs(facenum)];\n\t\t//if the face is in the same plane as the trace end point\n\t\tif ((face->planenum & ~1) == (trace->planenum & ~1))\n\t\t{\n\t\t\t//firstface is used for optimization, if theres only one\n\t\t\t//face in the plane then it has to be the good one\n\t\t\t//if there are more faces in the same plane then always\n\t\t\t//check the one with the fewest edges first\n/*\t\t\tif (firstface)\n\t\t\t{\n\t\t\t\tif (firstface->numedges < face->numedges)\n\t\t\t\t{\n\t\t\t\t\tif (AAS_InsideFace(firstface,\n\t\t\t\t\t\taasworld.planes[face->planenum].normal, trace->endpos))\n\t\t\t\t\t{\n\t\t\t\t\t\treturn firstface;\n\t\t\t\t\t} //end if\n\t\t\t\t\tfirstface = face;\n\t\t\t\t} //end if\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (AAS_InsideFace(face,\n\t\t\t\t\t\taasworld.planes[face->planenum].normal, trace->endpos))\n\t\t\t\t\t{\n\t\t\t\t\t\treturn face;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end else\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tfirstface = face;\n\t\t\t} //end else*/\n\t\t\tif (AAS_InsideFace(face,\n\t\t\t\t\t\taasworld.planes[face->planenum].normal, trace->endpos, 0.01f)) return face;\n\t\t} //end if\n\t} //end for\n\treturn firstface;\n} //end of the function AAS_TraceEndFace\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_BoxOnPlaneSide2(vec3_t absmins, vec3_t absmaxs, aas_plane_t *p)\n{\n\tint i, sides;\n\tfloat dist1, dist2;\n\tvec3_t corners[2];\n\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tif (p->normal[i] < 0)\n\t\t{\n\t\t\tcorners[0][i] = absmins[i];\n\t\t\tcorners[1][i] = absmaxs[i];\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tcorners[1][i] = absmins[i];\n\t\t\tcorners[0][i] = absmaxs[i];\n\t\t} //end else\n\t} //end for\n\tdist1 = DotProduct(p->normal, corners[0]) - p->dist;\n\tdist2 = DotProduct(p->normal, corners[1]) - p->dist;\n\tsides = 0;\n\tif (dist1 >= 0) sides = 1;\n\tif (dist2 < 0) sides |= 2;\n\n\treturn sides;\n} //end of the function AAS_BoxOnPlaneSide2\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n//int AAS_BoxOnPlaneSide(vec3_t absmins, vec3_t absmaxs, aas_plane_t *p)\n#define AAS_BoxOnPlaneSide(absmins, absmaxs, p) (\\\n\t( (p)->type < 3) ?\\\n\t(\\\n\t\t( (p)->dist <= (absmins)[(p)->type]) ?\\\n\t\t(\\\n\t\t\t1\\\n\t\t)\\\n\t\t:\\\n\t\t(\\\n\t\t\t( (p)->dist >= (absmaxs)[(p)->type]) ?\\\n\t\t\t(\\\n\t\t\t\t2\\\n\t\t\t)\\\n\t\t\t:\\\n\t\t\t(\\\n\t\t\t\t3\\\n\t\t\t)\\\n\t\t)\\\n\t)\\\n\t:\\\n\t(\\\n\t\tAAS_BoxOnPlaneSide2((absmins), (absmaxs), (p))\\\n\t)\\\n) //end of the function AAS_BoxOnPlaneSide\n//===========================================================================\n// remove the links to this entity from all areas\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_UnlinkFromAreas(aas_link_t *areas)\n{\n\taas_link_t *link, *nextlink;\n\n\tfor (link = areas; link; link = nextlink)\n\t{\n\t\t//next area the entity is linked in\n\t\tnextlink = link->next_area;\n\t\t//remove the entity from the linked list of this area\n\t\tif (link->prev_ent) link->prev_ent->next_ent = link->next_ent;\n\t\telse aasworld.arealinkedentities[link->areanum] = link->next_ent;\n\t\tif (link->next_ent) link->next_ent->prev_ent = link->prev_ent;\n\t\t//deallocate the link structure\n\t\tAAS_DeAllocAASLink(link);\n\t} //end for\n} //end of the function AAS_UnlinkFromAreas\n//===========================================================================\n// link the entity to the areas the bounding box is totally or partly\n// situated in. This is done with recursion down the tree using the\n// bounding box to test for plane sides\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n\ntypedef struct\n{\n\tint nodenum;\t\t//node found after splitting\n} aas_linkstack_t;\n\naas_link_t *AAS_AASLinkEntity(vec3_t absmins, vec3_t absmaxs, int entnum)\n{\n\tint side, nodenum;\n\taas_linkstack_t linkstack[128];\n\taas_linkstack_t *lstack_p;\n\taas_node_t *aasnode;\n\taas_plane_t *plane;\n\taas_link_t *link, *areas;\n\n\tif (!aasworld.loaded)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"AAS_LinkEntity: aas not loaded\\n\");\n\t\treturn NULL;\n\t} //end if\n\n\tareas = NULL;\n\t//\n\tlstack_p = linkstack;\n\t//we start with the whole line on the stack\n\t//start with node 1 because node zero is a dummy used for solid leafs\n\tlstack_p->nodenum = 1;\t\t//starting at the root of the tree\n\tlstack_p++;\n\t\n\twhile (1)\n\t{\n\t\t//pop up the stack\n\t\tlstack_p--;\n\t\t//if the trace stack is empty (ended up with a piece of the\n\t\t//line to be traced in an area)\n\t\tif (lstack_p < linkstack) break;\n\t\t//number of the current node to test the line against\n\t\tnodenum = lstack_p->nodenum;\n\t\t//if it is an area\n\t\tif (nodenum < 0)\n\t\t{\n\t\t\t//NOTE: the entity might have already been linked into this area\n\t\t\t// because several node children can point to the same area\n\t\t\tfor (link = aasworld.arealinkedentities[-nodenum]; link; link = link->next_ent)\n\t\t\t{\n\t\t\t\tif (link->entnum == entnum) break;\n\t\t\t} //end for\n\t\t\tif (link) continue;\n\t\t\t//\n\t\t\tlink = AAS_AllocAASLink();\n\t\t\tif (!link) return areas;\n\t\t\tlink->entnum = entnum;\n\t\t\tlink->areanum = -nodenum;\n\t\t\t//put the link into the double linked area list of the entity\n\t\t\tlink->prev_area = NULL;\n\t\t\tlink->next_area = areas;\n\t\t\tif (areas) areas->prev_area = link;\n\t\t\tareas = link;\n\t\t\t//put the link into the double linked entity list of the area\n\t\t\tlink->prev_ent = NULL;\n\t\t\tlink->next_ent = aasworld.arealinkedentities[-nodenum];\n\t\t\tif (aasworld.arealinkedentities[-nodenum])\n\t\t\t\t\taasworld.arealinkedentities[-nodenum]->prev_ent = link;\n\t\t\taasworld.arealinkedentities[-nodenum] = link;\n\t\t\t//\n\t\t\tcontinue;\n\t\t} //end if\n\t\t//if solid leaf\n\t\tif (!nodenum) continue;\n\t\t//the node to test against\n\t\taasnode = &aasworld.nodes[nodenum];\n\t\t//the current node plane\n\t\tplane = &aasworld.planes[aasnode->planenum];\n\t\t//get the side(s) the box is situated relative to the plane\n\t\tside = AAS_BoxOnPlaneSide2(absmins, absmaxs, plane);\n\t\t//if on the front side of the node\n\t\tif (side & 1)\n\t\t{\n\t\t\tlstack_p->nodenum = aasnode->children[0];\n\t\t\tlstack_p++;\n\t\t} //end if\n\t\tif (lstack_p >= &linkstack[127])\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"AAS_LinkEntity: stack overflow\\n\");\n\t\t\tbreak;\n\t\t} //end if\n\t\t//if on the back side of the node\n\t\tif (side & 2)\n\t\t{\n\t\t\tlstack_p->nodenum = aasnode->children[1];\n\t\t\tlstack_p++;\n\t\t} //end if\n\t\tif (lstack_p >= &linkstack[127])\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"AAS_LinkEntity: stack overflow\\n\");\n\t\t\tbreak;\n\t\t} //end if\n\t} //end while\n\treturn areas;\n} //end of the function AAS_AASLinkEntity\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\naas_link_t *AAS_LinkEntityClientBBox(vec3_t absmins, vec3_t absmaxs, int entnum, int presencetype)\n{\n\tvec3_t mins, maxs;\n\tvec3_t newabsmins, newabsmaxs;\n\n\tAAS_PresenceTypeBoundingBox(presencetype, mins, maxs);\n\tVectorSubtract(absmins, maxs, newabsmins);\n\tVectorSubtract(absmaxs, mins, newabsmaxs);\n\t//relink the entity\n\treturn AAS_AASLinkEntity(newabsmins, newabsmaxs, entnum);\n} //end of the function AAS_LinkEntityClientBBox\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_BBoxAreas(vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas)\n{\n\taas_link_t *linkedareas, *link;\n\tint num;\n\n\tlinkedareas = AAS_AASLinkEntity(absmins, absmaxs, -1);\n\tnum = 0;\n\tfor (link = linkedareas; link; link = link->next_area)\n\t{\n\t\tareas[num] = link->areanum;\n\t\tnum++;\n\t\tif (num >= maxareas)\n\t\t\tbreak;\n\t} //end for\n\tAAS_UnlinkFromAreas(linkedareas);\n\treturn num;\n} //end of the function AAS_BBoxAreas\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_AreaInfo( int areanum, aas_areainfo_t *info )\n{\n\taas_areasettings_t *settings;\n\tif (!info)\n\t\treturn 0;\n\tif (areanum <= 0 || areanum >= aasworld.numareas)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"AAS_AreaInfo: areanum %d out of range\\n\", areanum);\n\t\treturn 0;\n\t} //end if\n\tsettings = &aasworld.areasettings[areanum];\n\tinfo->cluster = settings->cluster;\n\tinfo->contents = settings->contents;\n\tinfo->flags = settings->areaflags;\n\tinfo->presencetype = settings->presencetype;\n\tVectorCopy(aasworld.areas[areanum].mins, info->mins);\n\tVectorCopy(aasworld.areas[areanum].maxs, info->maxs);\n\tVectorCopy(aasworld.areas[areanum].center, info->center);\n\treturn sizeof(aas_areainfo_t);\n} //end of the function AAS_AreaInfo\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\naas_plane_t *AAS_PlaneFromNum(int planenum)\n{\n\tif (!aasworld.loaded) return 0;\n\n\treturn &aasworld.planes[planenum];\n} //end of the function AAS_PlaneFromNum\n"
  },
  {
    "path": "code/botlib/be_aas_sample.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_aas_sample.h\n *\n * desc:\t\tAAS\n *\n * $Archive: /source/code/botlib/be_aas_sample.h $\n *\n *****************************************************************************/\n\n#ifdef AASINTERN\nvoid AAS_InitAASLinkHeap(void);\nvoid AAS_InitAASLinkedEntities(void);\nvoid AAS_FreeAASLinkHeap(void);\nvoid AAS_FreeAASLinkedEntities(void);\naas_face_t *AAS_AreaGroundFace(int areanum, vec3_t point);\naas_face_t *AAS_TraceEndFace(aas_trace_t *trace);\naas_plane_t *AAS_PlaneFromNum(int planenum);\naas_link_t *AAS_AASLinkEntity(vec3_t absmins, vec3_t absmaxs, int entnum);\naas_link_t *AAS_LinkEntityClientBBox(vec3_t absmins, vec3_t absmaxs, int entnum, int presencetype);\nqboolean AAS_PointInsideFace(int facenum, vec3_t point, float epsilon);\nqboolean AAS_InsideFace(aas_face_t *face, vec3_t pnormal, vec3_t point, float epsilon);\nvoid AAS_UnlinkFromAreas(aas_link_t *areas);\n#endif //AASINTERN\n\n//returns the mins and maxs of the bounding box for the given presence type\nvoid AAS_PresenceTypeBoundingBox(int presencetype, vec3_t mins, vec3_t maxs);\n//returns the cluster the area is in (negative portal number if the area is a portal)\nint AAS_AreaCluster(int areanum);\n//returns the presence type(s) of the area\nint AAS_AreaPresenceType(int areanum);\n//returns the presence type(s) at the given point\nint AAS_PointPresenceType(vec3_t point);\n//returns the result of the trace of a client bbox\naas_trace_t AAS_TraceClientBBox(vec3_t start, vec3_t end, int presencetype, int passent);\n//stores the areas the trace went through and returns the number of passed areas\nint AAS_TraceAreas(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas);\n//returns the areas the bounding box is in\nint AAS_BBoxAreas(vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas);\n//return area information\nint AAS_AreaInfo( int areanum, aas_areainfo_t *info );\n//returns the area the point is in\nint AAS_PointAreaNum(vec3_t point);\n//\nint AAS_PointReachabilityAreaIndex( vec3_t point );\n//returns the plane the given face is in\nvoid AAS_FacePlane(int facenum, vec3_t normal, float *dist);\n\n"
  },
  {
    "path": "code/botlib/be_ai_char.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_ai_char.c\n *\n * desc:\t\tbot characters\n *\n * $Archive: /MissionPack/code/botlib/be_ai_char.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_log.h\"\n#include \"l_memory.h\"\n#include \"l_utils.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#include \"l_libvar.h\"\n#include \"aasfile.h\"\n#include \"../game/botlib.h\"\n#include \"../game/be_aas.h\"\n#include \"be_aas_funcs.h\"\n#include \"be_interface.h\"\n#include \"../game/be_ai_char.h\"\n\n#define MAX_CHARACTERISTICS\t\t80\n\n#define CT_INTEGER\t\t\t\t1\n#define CT_FLOAT\t\t\t\t2\n#define CT_STRING\t\t\t\t3\n\n#define DEFAULT_CHARACTER\t\t\"bots/default_c.c\"\n\n//characteristic value\nunion cvalue\n{\n\tint integer;\n\tfloat _float;\n\tchar *string;\n};\n//a characteristic\ntypedef struct bot_characteristic_s\n{\n\tchar type;\t\t\t\t\t\t//characteristic type\n\tunion cvalue value;\t\t\t\t//characteristic value\n} bot_characteristic_t;\n\n//a bot character\ntypedef struct bot_character_s\n{\n\tchar filename[MAX_QPATH];\n\tfloat skill;\n\tbot_characteristic_t c[1];\t\t//variable sized\n} bot_character_t;\n\nbot_character_t *botcharacters[MAX_CLIENTS + 1];\n\n//========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//========================================================================\nbot_character_t *BotCharacterFromHandle(int handle)\n{\n\tif (handle <= 0 || handle > MAX_CLIENTS)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"character handle %d out of range\\n\", handle);\n\t\treturn NULL;\n\t} //end if\n\tif (!botcharacters[handle])\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"invalid character %d\\n\", handle);\n\t\treturn NULL;\n\t} //end if\n\treturn botcharacters[handle];\n} //end of the function BotCharacterFromHandle\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotDumpCharacter(bot_character_t *ch)\n{\n\tint i;\n\n\tLog_Write(\"%s\", ch->filename);\n\tLog_Write(\"skill %d\\n\", ch->skill);\n\tLog_Write(\"{\\n\");\n\tfor (i = 0; i < MAX_CHARACTERISTICS; i++)\n\t{\n\t\tswitch(ch->c[i].type)\n\t\t{\n\t\t\tcase CT_INTEGER: Log_Write(\" %4d %d\\n\", i, ch->c[i].value.integer); break;\n\t\t\tcase CT_FLOAT: Log_Write(\" %4d %f\\n\", i, ch->c[i].value._float); break;\n\t\t\tcase CT_STRING: Log_Write(\" %4d %s\\n\", i, ch->c[i].value.string); break;\n\t\t} //end case\n\t} //end for\n\tLog_Write(\"}\\n\");\n} //end of the function BotDumpCharacter\n//========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//========================================================================\nvoid BotFreeCharacterStrings(bot_character_t *ch)\n{\n\tint i;\n\n\tfor (i = 0; i < MAX_CHARACTERISTICS; i++)\n\t{\n\t\tif (ch->c[i].type == CT_STRING)\n\t\t{\n\t\t\tFreeMemory(ch->c[i].value.string);\n\t\t} //end if\n\t} //end for\n} //end of the function BotFreeCharacterStrings\n//========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//========================================================================\nvoid BotFreeCharacter2(int handle)\n{\n\tif (handle <= 0 || handle > MAX_CLIENTS)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"character handle %d out of range\\n\", handle);\n\t\treturn;\n\t} //end if\n\tif (!botcharacters[handle])\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"invalid character %d\\n\", handle);\n\t\treturn;\n\t} //end if\n\tBotFreeCharacterStrings(botcharacters[handle]);\n\tFreeMemory(botcharacters[handle]);\n\tbotcharacters[handle] = NULL;\n} //end of the function BotFreeCharacter2\n//========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//========================================================================\nvoid BotFreeCharacter(int handle)\n{\n\tif (!LibVarGetValue(\"bot_reloadcharacters\")) return;\n\tBotFreeCharacter2(handle);\n} //end of the function BotFreeCharacter\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotDefaultCharacteristics(bot_character_t *ch, bot_character_t *defaultch)\n{\n\tint i;\n\n\tfor (i = 0; i < MAX_CHARACTERISTICS; i++)\n\t{\n\t\tif (ch->c[i].type) continue;\n\t\t//\n\t\tif (defaultch->c[i].type == CT_FLOAT)\n\t\t{\n\t\t\tch->c[i].type = CT_FLOAT;\n\t\t\tch->c[i].value._float = defaultch->c[i].value._float;\n\t\t} //end if\n\t\telse if (defaultch->c[i].type == CT_INTEGER)\n\t\t{\n\t\t\tch->c[i].type = CT_INTEGER;\n\t\t\tch->c[i].value.integer = defaultch->c[i].value.integer;\n\t\t} //end else if\n\t\telse if (defaultch->c[i].type == CT_STRING)\n\t\t{\n\t\t\tch->c[i].type = CT_STRING;\n\t\t\tch->c[i].value.string = (char *) GetMemory(strlen(defaultch->c[i].value.string)+1);\n\t\t\tstrcpy(ch->c[i].value.string, defaultch->c[i].value.string);\n\t\t} //end else if\n\t} //end for\n} //end of the function BotDefaultCharacteristics\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_character_t *BotLoadCharacterFromFile(char *charfile, int skill)\n{\n\tint indent, index, foundcharacter;\n\tbot_character_t *ch;\n\tsource_t *source;\n\ttoken_t token;\n\n\tfoundcharacter = qfalse;\n\t//a bot character is parsed in two phases\n\tPC_SetBaseFolder(BOTFILESBASEFOLDER);\n\tsource = LoadSourceFile(charfile);\n\tif (!source)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"counldn't load %s\\n\", charfile);\n\t\treturn NULL;\n\t} //end if\n\tch = (bot_character_t *) GetClearedMemory(sizeof(bot_character_t) +\n\t\t\t\t\tMAX_CHARACTERISTICS * sizeof(bot_characteristic_t));\n\tstrcpy(ch->filename, charfile);\n\twhile(PC_ReadToken(source, &token))\n\t{\n\t\tif (!strcmp(token.string, \"skill\"))\n\t\t{\n\t\t\tif (!PC_ExpectTokenType(source, TT_NUMBER, 0, &token))\n\t\t\t{\n\t\t\t\tFreeSource(source);\n\t\t\t\tBotFreeCharacterStrings(ch);\n\t\t\t\tFreeMemory(ch);\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t\tif (!PC_ExpectTokenString(source, \"{\"))\n\t\t\t{\n\t\t\t\tFreeSource(source);\n\t\t\t\tBotFreeCharacterStrings(ch);\n\t\t\t\tFreeMemory(ch);\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t\t//if it's the correct skill\n\t\t\tif (skill < 0 || token.intvalue == skill)\n\t\t\t{\n\t\t\t\tfoundcharacter = qtrue;\n\t\t\t\tch->skill = token.intvalue;\n\t\t\t\twhile(PC_ExpectAnyToken(source, &token))\n\t\t\t\t{\n\t\t\t\t\tif (!strcmp(token.string, \"}\")) break;\n\t\t\t\t\tif (token.type != TT_NUMBER || !(token.subtype & TT_INTEGER))\n\t\t\t\t\t{\n\t\t\t\t\t\tSourceError(source, \"expected integer index, found %s\\n\", token.string);\n\t\t\t\t\t\tFreeSource(source);\n\t\t\t\t\t\tBotFreeCharacterStrings(ch);\n\t\t\t\t\t\tFreeMemory(ch);\n\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t} //end if\n\t\t\t\t\tindex = token.intvalue;\n\t\t\t\t\tif (index < 0 || index > MAX_CHARACTERISTICS)\n\t\t\t\t\t{\n\t\t\t\t\t\tSourceError(source, \"characteristic index out of range [0, %d]\\n\", MAX_CHARACTERISTICS);\n\t\t\t\t\t\tFreeSource(source);\n\t\t\t\t\t\tBotFreeCharacterStrings(ch);\n\t\t\t\t\t\tFreeMemory(ch);\n\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t} //end if\n\t\t\t\t\tif (ch->c[index].type)\n\t\t\t\t\t{\n\t\t\t\t\t\tSourceError(source, \"characteristic %d already initialized\\n\", index);\n\t\t\t\t\t\tFreeSource(source);\n\t\t\t\t\t\tBotFreeCharacterStrings(ch);\n\t\t\t\t\t\tFreeMemory(ch);\n\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t} //end if\n\t\t\t\t\tif (!PC_ExpectAnyToken(source, &token))\n\t\t\t\t\t{\n\t\t\t\t\t\tFreeSource(source);\n\t\t\t\t\t\tBotFreeCharacterStrings(ch);\n\t\t\t\t\t\tFreeMemory(ch);\n\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t} //end if\n\t\t\t\t\tif (token.type == TT_NUMBER)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (token.subtype & TT_FLOAT)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tch->c[index].value._float = token.floatvalue;\n\t\t\t\t\t\t\tch->c[index].type = CT_FLOAT;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tch->c[index].value.integer = token.intvalue;\n\t\t\t\t\t\t\tch->c[index].type = CT_INTEGER;\n\t\t\t\t\t\t} //end else\n\t\t\t\t\t} //end if\n\t\t\t\t\telse if (token.type == TT_STRING)\n\t\t\t\t\t{\n\t\t\t\t\t\tStripDoubleQuotes(token.string);\n\t\t\t\t\t\tch->c[index].value.string = GetMemory(strlen(token.string)+1);\n\t\t\t\t\t\tstrcpy(ch->c[index].value.string, token.string);\n\t\t\t\t\t\tch->c[index].type = CT_STRING;\n\t\t\t\t\t} //end else if\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tSourceError(source, \"expected integer, float or string, found %s\\n\", token.string);\n\t\t\t\t\t\tFreeSource(source);\n\t\t\t\t\t\tBotFreeCharacterStrings(ch);\n\t\t\t\t\t\tFreeMemory(ch);\n\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t} //end else\n\t\t\t\t} //end if\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tindent = 1;\n\t\t\t\twhile(indent)\n\t\t\t\t{\n\t\t\t\t\tif (!PC_ExpectAnyToken(source, &token))\n\t\t\t\t\t{\n\t\t\t\t\t\tFreeSource(source);\n\t\t\t\t\t\tBotFreeCharacterStrings(ch);\n\t\t\t\t\t\tFreeMemory(ch);\n\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t} //end if\n\t\t\t\t\tif (!strcmp(token.string, \"{\")) indent++;\n\t\t\t\t\telse if (!strcmp(token.string, \"}\")) indent--;\n\t\t\t\t} //end while\n\t\t\t} //end else\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tSourceError(source, \"unknown definition %s\\n\", token.string);\n\t\t\tFreeSource(source);\n\t\t\tBotFreeCharacterStrings(ch);\n\t\t\tFreeMemory(ch);\n\t\t\treturn NULL;\n\t\t} //end else\n\t} //end while\n\tFreeSource(source);\n\t//\n\tif (!foundcharacter)\n\t{\n\t\tBotFreeCharacterStrings(ch);\n\t\tFreeMemory(ch);\n\t\treturn NULL;\n\t} //end if\n\treturn ch;\n} //end of the function BotLoadCharacterFromFile\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotFindCachedCharacter(char *charfile, float skill)\n{\n\tint handle;\n\n\tfor (handle = 1; handle <= MAX_CLIENTS; handle++)\n\t{\n\t\tif ( !botcharacters[handle] ) continue;\n\t\tif ( strcmp( botcharacters[handle]->filename, charfile ) == 0 &&\n\t\t\t(skill < 0 || fabs(botcharacters[handle]->skill - skill) < 0.01) )\n\t\t{\n\t\t\treturn handle;\n\t\t} //end if\n\t} //end for\n\treturn 0;\n} //end of the function BotFindCachedCharacter\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotLoadCachedCharacter(char *charfile, float skill, int reload)\n{\n\tint handle, cachedhandle, intskill;\n\tbot_character_t *ch = NULL;\n#ifdef DEBUG\n\tint starttime;\n\n\tstarttime = Sys_MilliSeconds();\n#endif //DEBUG\n\n\t//find a free spot for a character\n\tfor (handle = 1; handle <= MAX_CLIENTS; handle++)\n\t{\n\t\tif (!botcharacters[handle]) break;\n\t} //end for\n\tif (handle > MAX_CLIENTS) return 0;\n\t//try to load a cached character with the given skill\n\tif (!reload)\n\t{\n\t\tcachedhandle = BotFindCachedCharacter(charfile, skill);\n\t\tif (cachedhandle)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"loaded cached skill %f from %s\\n\", skill, charfile);\n\t\t\treturn cachedhandle;\n\t\t} //end if\n\t} //end else\n\t//\n\tintskill = (int) (skill + 0.5);\n\t//try to load the character with the given skill\n\tch = BotLoadCharacterFromFile(charfile, intskill);\n\tif (ch)\n\t{\n\t\tbotcharacters[handle] = ch;\n\t\t//\n\t\tbotimport.Print(PRT_MESSAGE, \"loaded skill %d from %s\\n\", intskill, charfile);\n#ifdef DEBUG\n\t\tif (bot_developer)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"skill %d loaded in %d msec from %s\\n\", intskill, Sys_MilliSeconds() - starttime, charfile);\n\t\t} //end if\n#endif //DEBUG\n\t\treturn handle;\n\t} //end if\n\t//\n\tbotimport.Print(PRT_WARNING, \"couldn't find skill %d in %s\\n\", intskill, charfile);\n\t//\n\tif (!reload)\n\t{\n\t\t//try to load a cached default character with the given skill\n\t\tcachedhandle = BotFindCachedCharacter(DEFAULT_CHARACTER, skill);\n\t\tif (cachedhandle)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"loaded cached default skill %d from %s\\n\", intskill, charfile);\n\t\t\treturn cachedhandle;\n\t\t} //end if\n\t} //end if\n\t//try to load the default character with the given skill\n\tch = BotLoadCharacterFromFile(DEFAULT_CHARACTER, intskill);\n\tif (ch)\n\t{\n\t\tbotcharacters[handle] = ch;\n\t\tbotimport.Print(PRT_MESSAGE, \"loaded default skill %d from %s\\n\", intskill, charfile);\n\t\treturn handle;\n\t} //end if\n\t//\n\tif (!reload)\n\t{\n\t\t//try to load a cached character with any skill\n\t\tcachedhandle = BotFindCachedCharacter(charfile, -1);\n\t\tif (cachedhandle)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"loaded cached skill %f from %s\\n\", botcharacters[cachedhandle]->skill, charfile);\n\t\t\treturn cachedhandle;\n\t\t} //end if\n\t} //end if\n\t//try to load a character with any skill\n\tch = BotLoadCharacterFromFile(charfile, -1);\n\tif (ch)\n\t{\n\t\tbotcharacters[handle] = ch;\n\t\tbotimport.Print(PRT_MESSAGE, \"loaded skill %f from %s\\n\", ch->skill, charfile);\n\t\treturn handle;\n\t} //end if\n\t//\n\tif (!reload)\n\t{\n\t\t//try to load a cached character with any skill\n\t\tcachedhandle = BotFindCachedCharacter(DEFAULT_CHARACTER, -1);\n\t\tif (cachedhandle)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"loaded cached default skill %f from %s\\n\", botcharacters[cachedhandle]->skill, charfile);\n\t\t\treturn cachedhandle;\n\t\t} //end if\n\t} //end if\n\t//try to load a character with any skill\n\tch = BotLoadCharacterFromFile(DEFAULT_CHARACTER, -1);\n\tif (ch)\n\t{\n\t\tbotcharacters[handle] = ch;\n\t\tbotimport.Print(PRT_MESSAGE, \"loaded default skill %f from %s\\n\", ch->skill, charfile);\n\t\treturn handle;\n\t} //end if\n\t//\n\tbotimport.Print(PRT_WARNING, \"couldn't load any skill from %s\\n\", charfile);\n\t//couldn't load any character\n\treturn 0;\n} //end of the function BotLoadCachedCharacter\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotLoadCharacterSkill(char *charfile, float skill)\n{\n\tint ch, defaultch;\n\n\tdefaultch = BotLoadCachedCharacter(DEFAULT_CHARACTER, skill, qfalse);\n\tch = BotLoadCachedCharacter(charfile, skill, LibVarGetValue(\"bot_reloadcharacters\"));\n\n\tif (defaultch && ch)\n\t{\n\t\tBotDefaultCharacteristics(botcharacters[ch], botcharacters[defaultch]);\n\t} //end if\n\n\treturn ch;\n} //end of the function BotLoadCharacterSkill\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotInterpolateCharacters(int handle1, int handle2, float desiredskill)\n{\n\tbot_character_t *ch1, *ch2, *out;\n\tint i, handle;\n\tfloat scale;\n\n\tch1 = BotCharacterFromHandle(handle1);\n\tch2 = BotCharacterFromHandle(handle2);\n\tif (!ch1 || !ch2)\n\t\treturn 0;\n\t//find a free spot for a character\n\tfor (handle = 1; handle <= MAX_CLIENTS; handle++)\n\t{\n\t\tif (!botcharacters[handle]) break;\n\t} //end for\n\tif (handle > MAX_CLIENTS) return 0;\n\tout = (bot_character_t *) GetClearedMemory(sizeof(bot_character_t) +\n\t\t\t\t\tMAX_CHARACTERISTICS * sizeof(bot_characteristic_t));\n\tout->skill = desiredskill;\n\tstrcpy(out->filename, ch1->filename);\n\tbotcharacters[handle] = out;\n\n\tscale = (float) (desiredskill - ch1->skill) / (ch2->skill - ch1->skill);\n\tfor (i = 0; i < MAX_CHARACTERISTICS; i++)\n\t{\n\t\t//\n\t\tif (ch1->c[i].type == CT_FLOAT && ch2->c[i].type == CT_FLOAT)\n\t\t{\n\t\t\tout->c[i].type = CT_FLOAT;\n\t\t\tout->c[i].value._float = ch1->c[i].value._float +\n\t\t\t\t\t\t\t\t(ch2->c[i].value._float - ch1->c[i].value._float) * scale;\n\t\t} //end if\n\t\telse if (ch1->c[i].type == CT_INTEGER)\n\t\t{\n\t\t\tout->c[i].type = CT_INTEGER;\n\t\t\tout->c[i].value.integer = ch1->c[i].value.integer;\n\t\t} //end else if\n\t\telse if (ch1->c[i].type == CT_STRING)\n\t\t{\n\t\t\tout->c[i].type = CT_STRING;\n\t\t\tout->c[i].value.string = (char *) GetMemory(strlen(ch1->c[i].value.string)+1);\n\t\t\tstrcpy(out->c[i].value.string, ch1->c[i].value.string);\n\t\t} //end else if\n\t} //end for\n\treturn handle;\n} //end of the function BotInterpolateCharacters\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotLoadCharacter(char *charfile, float skill)\n{\n\tint firstskill, secondskill, handle;\n\n\t//make sure the skill is in the valid range\n\tif (skill < 1.0) skill = 1.0;\n\telse if (skill > 5.0) skill = 5.0;\n\t//skill 1, 4 and 5 should be available in the character files\n\tif (skill == 1.0 || skill == 4.0 || skill == 5.0)\n\t{\n\t\treturn BotLoadCharacterSkill(charfile, skill);\n\t} //end if\n\t//check if there's a cached skill\n\thandle = BotFindCachedCharacter(charfile, skill);\n\tif (handle)\n\t{\n\t\tbotimport.Print(PRT_MESSAGE, \"loaded cached skill %f from %s\\n\", skill, charfile);\n\t\treturn handle;\n\t} //end if\n\tif (skill < 4.0)\n\t{\n\t\t//load skill 1 and 4\n\t\tfirstskill = BotLoadCharacterSkill(charfile, 1);\n\t\tif (!firstskill) return 0;\n\t\tsecondskill = BotLoadCharacterSkill(charfile, 4);\n\t\tif (!secondskill) return firstskill;\n\t} //end if\n\telse\n\t{\n\t\t//load skill 4 and 5\n\t\tfirstskill = BotLoadCharacterSkill(charfile, 4);\n\t\tif (!firstskill) return 0;\n\t\tsecondskill = BotLoadCharacterSkill(charfile, 5);\n\t\tif (!secondskill) return firstskill;\n\t} //end else\n\t//interpolate between the two skills\n\thandle = BotInterpolateCharacters(firstskill, secondskill, skill);\n\tif (!handle) return 0;\n\t//write the character to the log file\n\tBotDumpCharacter(botcharacters[handle]);\n\t//\n\treturn handle;\n} //end of the function BotLoadCharacter\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint CheckCharacteristicIndex(int character, int index)\n{\n\tbot_character_t *ch;\n\n\tch = BotCharacterFromHandle(character);\n\tif (!ch) return qfalse;\n\tif (index < 0 || index >= MAX_CHARACTERISTICS)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"characteristic %d does not exist\\n\", index);\n\t\treturn qfalse;\n\t} //end if\n\tif (!ch->c[index].type)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"characteristic %d is not initialized\\n\", index);\n\t\treturn qfalse;\n\t} //end if\n\treturn qtrue;\n} //end of the function CheckCharacteristicIndex\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat Characteristic_Float(int character, int index)\n{\n\tbot_character_t *ch;\n\n\tch = BotCharacterFromHandle(character);\n\tif (!ch) return 0;\n\t//check if the index is in range\n\tif (!CheckCharacteristicIndex(character, index)) return 0;\n\t//an integer will be converted to a float\n\tif (ch->c[index].type == CT_INTEGER)\n\t{\n\t\treturn (float) ch->c[index].value.integer;\n\t} //end if\n\t//floats are just returned\n\telse if (ch->c[index].type == CT_FLOAT)\n\t{\n\t\treturn ch->c[index].value._float;\n\t} //end else if\n\t//cannot convert a string pointer to a float\n\telse\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"characteristic %d is not a float\\n\", index);\n\t\treturn 0;\n\t} //end else if\n//\treturn 0;\n} //end of the function Characteristic_Float\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat Characteristic_BFloat(int character, int index, float min, float max)\n{\n\tfloat value;\n\tbot_character_t *ch;\n\n\tch = BotCharacterFromHandle(character);\n\tif (!ch) return 0;\n\tif (min > max)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"cannot bound characteristic %d between %f and %f\\n\", index, min, max);\n\t\treturn 0;\n\t} //end if\n\tvalue = Characteristic_Float(character, index);\n\tif (value < min) return min;\n\tif (value > max) return max;\n\treturn value;\n} //end of the function Characteristic_BFloat\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint Characteristic_Integer(int character, int index)\n{\n\tbot_character_t *ch;\n\n\tch = BotCharacterFromHandle(character);\n\tif (!ch) return 0;\n\t//check if the index is in range\n\tif (!CheckCharacteristicIndex(character, index)) return 0;\n\t//an integer will just be returned\n\tif (ch->c[index].type == CT_INTEGER)\n\t{\n\t\treturn ch->c[index].value.integer;\n\t} //end if\n\t//floats are casted to integers\n\telse if (ch->c[index].type == CT_FLOAT)\n\t{\n\t\treturn (int) ch->c[index].value._float;\n\t} //end else if\n\telse\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"characteristic %d is not a integer\\n\", index);\n\t\treturn 0;\n\t} //end else if\n//\treturn 0;\n} //end of the function Characteristic_Integer\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint Characteristic_BInteger(int character, int index, int min, int max)\n{\n\tint value;\n\tbot_character_t *ch;\n\n\tch = BotCharacterFromHandle(character);\n\tif (!ch) return 0;\n\tif (min > max)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"cannot bound characteristic %d between %d and %d\\n\", index, min, max);\n\t\treturn 0;\n\t} //end if\n\tvalue = Characteristic_Integer(character, index);\n\tif (value < min) return min;\n\tif (value > max) return max;\n\treturn value;\n} //end of the function Characteristic_BInteger\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Characteristic_String(int character, int index, char *buf, int size)\n{\n\tbot_character_t *ch;\n\n\tch = BotCharacterFromHandle(character);\n\tif (!ch) return;\n\t//check if the index is in range\n\tif (!CheckCharacteristicIndex(character, index)) return;\n\t//an integer will be converted to a float\n\tif (ch->c[index].type == CT_STRING)\n\t{\n\t\tstrncpy(buf, ch->c[index].value.string, size-1);\n\t\tbuf[size-1] = '\\0';\n\t\treturn;\n\t} //end if\n\telse\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"characteristic %d is not a string\\n\", index);\n\t\treturn;\n\t} //end else if\n\treturn;\n} //end of the function Characteristic_String\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotShutdownCharacters(void)\n{\n\tint handle;\n\n\tfor (handle = 1; handle <= MAX_CLIENTS; handle++)\n\t{\n\t\tif (botcharacters[handle])\n\t\t{\n\t\t\tBotFreeCharacter2(handle);\n\t\t} //end if\n\t} //end for\n} //end of the function BotShutdownCharacters\n\n"
  },
  {
    "path": "code/botlib/be_ai_chat.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_ai_chat.c\n *\n * desc:\t\tbot chat AI\n *\n * $Archive: /MissionPack/code/botlib/be_ai_chat.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_memory.h\"\n#include \"l_libvar.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#include \"l_utils.h\"\n#include \"l_log.h\"\n#include \"aasfile.h\"\n#include \"../game/botlib.h\"\n#include \"../game/be_aas.h\"\n#include \"be_aas_funcs.h\"\n#include \"be_interface.h\"\n#include \"../game/be_ea.h\"\n#include \"../game/be_ai_chat.h\"\n\n\n//escape character\n#define ESCAPE_CHAR\t\t\t\t0x01\t//'_'\n//\n// \"hi \", people, \" \", 0, \" entered the game\"\n//becomes:\n// \"hi _rpeople_ _v0_ entered the game\"\n//\n\n//match piece types\n#define MT_VARIABLE\t\t\t\t\t1\t\t//variable match piece\n#define MT_STRING\t\t\t\t\t2\t\t//string match piece\n//reply chat key flags\n#define RCKFL_AND\t\t\t\t\t1\t\t//key must be present\n#define RCKFL_NOT\t\t\t\t\t2\t\t//key must be absent\n#define RCKFL_NAME\t\t\t\t\t4\t\t//name of bot must be present\n#define RCKFL_STRING\t\t\t\t8\t\t//key is a string\n#define RCKFL_VARIABLES\t\t\t\t16\t\t//key is a match template\n#define RCKFL_BOTNAMES\t\t\t\t32\t\t//key is a series of botnames\n#define RCKFL_GENDERFEMALE\t\t\t64\t\t//bot must be female\n#define RCKFL_GENDERMALE\t\t\t128\t\t//bot must be male\n#define RCKFL_GENDERLESS\t\t\t256\t\t//bot must be genderless\n//time to ignore a chat message after using it\n#define CHATMESSAGE_RECENTTIME\t20\n\n//the actuall chat messages\ntypedef struct bot_chatmessage_s\n{\n\tchar *chatmessage;\t\t\t\t\t//chat message string\n\tfloat time;\t\t\t\t\t\t\t//last time used\n\tstruct bot_chatmessage_s *next;\t\t//next chat message in a list\n} bot_chatmessage_t;\n//bot chat type with chat lines\ntypedef struct bot_chattype_s\n{\n\tchar name[MAX_CHATTYPE_NAME];\n\tint numchatmessages;\n\tbot_chatmessage_t *firstchatmessage;\n\tstruct bot_chattype_s *next;\n} bot_chattype_t;\n//bot chat lines\ntypedef struct bot_chat_s\n{\n\tbot_chattype_t *types;\n} bot_chat_t;\n\n//random string\ntypedef struct bot_randomstring_s\n{\n\tchar *string;\n\tstruct bot_randomstring_s *next;\n} bot_randomstring_t;\n//list with random strings\ntypedef struct bot_randomlist_s\n{\n\tchar *string;\n\tint numstrings;\n\tbot_randomstring_t *firstrandomstring;\n\tstruct bot_randomlist_s *next;\n} bot_randomlist_t;\n\n//synonym\ntypedef struct bot_synonym_s\n{\n\tchar *string;\n\tfloat weight;\n\tstruct bot_synonym_s *next;\n} bot_synonym_t;\n//list with synonyms\ntypedef struct bot_synonymlist_s\n{\n\tunsigned long int context;\n\tfloat totalweight;\n\tbot_synonym_t *firstsynonym;\n\tstruct bot_synonymlist_s *next;\n} bot_synonymlist_t;\n\n//fixed match string\ntypedef struct bot_matchstring_s\n{\n\tchar *string;\n\tstruct bot_matchstring_s *next;\n} bot_matchstring_t;\n\n//piece of a match template\ntypedef struct bot_matchpiece_s\n{\n\tint type;\n\tbot_matchstring_t *firststring;\n\tint variable;\n\tstruct bot_matchpiece_s *next;\n} bot_matchpiece_t;\n//match template\ntypedef struct bot_matchtemplate_s\n{\n\tunsigned long int context;\n\tint type;\n\tint subtype;\n\tbot_matchpiece_t *first;\n\tstruct bot_matchtemplate_s *next;\n} bot_matchtemplate_t;\n\n//reply chat key\ntypedef struct bot_replychatkey_s\n{\n\tint flags;\n\tchar *string;\n\tbot_matchpiece_t *match;\n\tstruct bot_replychatkey_s *next;\n} bot_replychatkey_t;\n//reply chat\ntypedef struct bot_replychat_s\n{\n\tbot_replychatkey_t *keys;\n\tfloat priority;\n\tint numchatmessages;\n\tbot_chatmessage_t *firstchatmessage;\n\tstruct bot_replychat_s *next;\n} bot_replychat_t;\n\n//string list\ntypedef struct bot_stringlist_s\n{\n\tchar *string;\n\tstruct bot_stringlist_s *next;\n} bot_stringlist_t;\n\n//chat state of a bot\ntypedef struct bot_chatstate_s\n{\n\tint gender;\t\t\t\t\t\t\t\t\t\t\t//0=it, 1=female, 2=male\n\tint client;\t\t\t\t\t\t\t\t\t\t\t//client number\n\tchar name[32];\t\t\t\t\t\t\t\t\t\t//name of the bot\n\tchar chatmessage[MAX_MESSAGE_SIZE];\n\tint handle;\n\t//the console messages visible to the bot\n\tbot_consolemessage_t *firstmessage;\t\t\t//first message is the first typed message\n\tbot_consolemessage_t *lastmessage;\t\t\t//last message is the last typed message, bottom of console\n\t//number of console messages stored in the state\n\tint numconsolemessages;\n\t//the bot chat lines\n\tbot_chat_t *chat;\n} bot_chatstate_t;\n\ntypedef struct {\n\tbot_chat_t\t*chat;\n\tchar\t\tfilename[MAX_QPATH];\n\tchar\t\tchatname[MAX_QPATH];\n} bot_ichatdata_t;\n\nbot_ichatdata_t\t*ichatdata[MAX_CLIENTS];\n\nbot_chatstate_t *botchatstates[MAX_CLIENTS+1];\n//console message heap\nbot_consolemessage_t *consolemessageheap = NULL;\nbot_consolemessage_t *freeconsolemessages = NULL;\n//list with match strings\nbot_matchtemplate_t *matchtemplates = NULL;\n//list with synonyms\nbot_synonymlist_t *synonyms = NULL;\n//list with random strings\nbot_randomlist_t *randomstrings = NULL;\n//reply chats\nbot_replychat_t *replychats = NULL;\n\n//========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//========================================================================\nbot_chatstate_t *BotChatStateFromHandle(int handle)\n{\n\tif (handle <= 0 || handle > MAX_CLIENTS)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"chat state handle %d out of range\\n\", handle);\n\t\treturn NULL;\n\t} //end if\n\tif (!botchatstates[handle])\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"invalid chat state %d\\n\", handle);\n\t\treturn NULL;\n\t} //end if\n\treturn botchatstates[handle];\n} //end of the function BotChatStateFromHandle\n//===========================================================================\n// initialize the heap with unused console messages\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid InitConsoleMessageHeap(void)\n{\n\tint i, max_messages;\n\n\tif (consolemessageheap) FreeMemory(consolemessageheap);\n\t//\n\tmax_messages = (int) LibVarValue(\"max_messages\", \"1024\");\n\tconsolemessageheap = (bot_consolemessage_t *) GetClearedHunkMemory(max_messages *\n\t\t\t\t\t\t\t\t\t\t\t\tsizeof(bot_consolemessage_t));\n\tconsolemessageheap[0].prev = NULL;\n\tconsolemessageheap[0].next = &consolemessageheap[1];\n\tfor (i = 1; i < max_messages-1; i++)\n\t{\n\t\tconsolemessageheap[i].prev = &consolemessageheap[i - 1];\n\t\tconsolemessageheap[i].next = &consolemessageheap[i + 1];\n\t} //end for\n\tconsolemessageheap[max_messages-1].prev = &consolemessageheap[max_messages-2];\n\tconsolemessageheap[max_messages-1].next = NULL;\n\t//pointer to the free console messages\n\tfreeconsolemessages = consolemessageheap;\n} //end of the function InitConsoleMessageHeap\n//===========================================================================\n// allocate one console message from the heap\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_consolemessage_t *AllocConsoleMessage(void)\n{\n\tbot_consolemessage_t *message;\n\tmessage = freeconsolemessages;\n\tif (freeconsolemessages) freeconsolemessages = freeconsolemessages->next;\n\tif (freeconsolemessages) freeconsolemessages->prev = NULL;\n\treturn message;\n} //end of the function AllocConsoleMessage\n//===========================================================================\n// deallocate one console message from the heap\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid FreeConsoleMessage(bot_consolemessage_t *message)\n{\n\tif (freeconsolemessages) freeconsolemessages->prev = message;\n\tmessage->prev = NULL;\n\tmessage->next = freeconsolemessages;\n\tfreeconsolemessages = message;\n} //end of the function FreeConsoleMessage\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotRemoveConsoleMessage(int chatstate, int handle)\n{\n\tbot_consolemessage_t *m, *nextm;\n\tbot_chatstate_t *cs;\n\n\tcs = BotChatStateFromHandle(chatstate);\n\tif (!cs) return;\n\n\tfor (m = cs->firstmessage; m; m = nextm)\n\t{\n\t\tnextm = m->next;\n\t\tif (m->handle == handle)\n\t\t{\n\t\t\tif (m->next) m->next->prev = m->prev;\n\t\t\telse cs->lastmessage = m->prev;\n\t\t\tif (m->prev) m->prev->next = m->next;\n\t\t\telse cs->firstmessage = m->next;\n\n\t\t\tFreeConsoleMessage(m);\n\t\t\tcs->numconsolemessages--;\n\t\t\tbreak;\n\t\t} //end if\n\t} //end for\n} //end of the function BotRemoveConsoleMessage\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotQueueConsoleMessage(int chatstate, int type, char *message)\n{\n\tbot_consolemessage_t *m;\n\tbot_chatstate_t *cs;\n\n\tcs = BotChatStateFromHandle(chatstate);\n\tif (!cs) return;\n\n\tm = AllocConsoleMessage();\n\tif (!m)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"empty console message heap\\n\");\n\t\treturn;\n\t} //end if\n\tcs->handle++;\n\tif (cs->handle <= 0 || cs->handle > 8192) cs->handle = 1;\n\tm->handle = cs->handle;\n\tm->time = AAS_Time();\n\tm->type = type;\n\tstrncpy(m->message, message, MAX_MESSAGE_SIZE);\n\tm->next = NULL;\n\tif (cs->lastmessage)\n\t{\n\t\tcs->lastmessage->next = m;\n\t\tm->prev = cs->lastmessage;\n\t\tcs->lastmessage = m;\n\t} //end if\n\telse\n\t{\n\t\tcs->lastmessage = m;\n\t\tcs->firstmessage = m;\n\t\tm->prev = NULL;\n\t} //end if\n\tcs->numconsolemessages++;\n} //end of the function BotQueueConsoleMessage\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotNextConsoleMessage(int chatstate, bot_consolemessage_t *cm)\n{\n\tbot_chatstate_t *cs;\n\n\tcs = BotChatStateFromHandle(chatstate);\n\tif (!cs) return 0;\n\tif (cs->firstmessage)\n\t{\n\t\tCom_Memcpy(cm, cs->firstmessage, sizeof(bot_consolemessage_t));\n\t\tcm->next = cm->prev = NULL;\n\t\treturn cm->handle;\n\t} //end if\n\treturn 0;\n} //end of the function BotConsoleMessage\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotNumConsoleMessages(int chatstate)\n{\n\tbot_chatstate_t *cs;\n\n\tcs = BotChatStateFromHandle(chatstate);\n\tif (!cs) return 0;\n\treturn cs->numconsolemessages;\n} //end of the function BotNumConsoleMessages\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint IsWhiteSpace(char c)\n{\n\tif ((c >= 'a' && c <= 'z')\n\t\t|| (c >= 'A' && c <= 'Z')\n\t\t|| (c >= '0' && c <= '9')\n\t\t|| c == '(' || c == ')'\n\t\t|| c == '?' || c == ':'\n\t\t|| c == '\\''|| c == '/'\n\t\t|| c == ',' || c == '.'\n\t\t|| c == '['\t|| c == ']'\n\t\t|| c == '-' || c == '_'\n\t\t|| c == '+' || c == '=') return qfalse;\n\treturn qtrue;\n} //end of the function IsWhiteSpace\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotRemoveTildes(char *message)\n{\n\tint i;\n\n\t//remove all tildes from the chat message\n\tfor (i = 0; message[i]; i++)\n\t{\n\t\tif (message[i] == '~')\n\t\t{\n\t\t\tmemmove(&message[i], &message[i+1], strlen(&message[i+1])+1);\n\t\t} //end if\n\t} //end for\n} //end of the function BotRemoveTildes\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid UnifyWhiteSpaces(char *string)\n{\n\tchar *ptr, *oldptr;\n\n\tfor (ptr = oldptr = string; *ptr; oldptr = ptr)\n\t{\n\t\twhile(*ptr && IsWhiteSpace(*ptr)) ptr++;\n\t\tif (ptr > oldptr)\n\t\t{\n\t\t\t//if not at the start and not at the end of the string\n\t\t\t//write only one space\n\t\t\tif (oldptr > string && *ptr) *oldptr++ = ' ';\n\t\t\t//remove all other white spaces\n\t\t\tif (ptr > oldptr) memmove(oldptr, ptr, strlen(ptr)+1);\n\t\t} //end if\n\t\twhile(*ptr && !IsWhiteSpace(*ptr)) ptr++;\n\t} //end while\n} //end of the function UnifyWhiteSpaces\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint StringContains(char *str1, char *str2, int casesensitive)\n{\n\tint len, i, j, index;\n\n\tif (str1 == NULL || str2 == NULL) return -1;\n\n\tlen = strlen(str1) - strlen(str2);\n\tindex = 0;\n\tfor (i = 0; i <= len; i++, str1++, index++)\n\t{\n\t\tfor (j = 0; str2[j]; j++)\n\t\t{\n\t\t\tif (casesensitive)\n\t\t\t{\n\t\t\t\tif (str1[j] != str2[j]) break;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (toupper(str1[j]) != toupper(str2[j])) break;\n\t\t\t} //end else\n\t\t} //end for\n\t\tif (!str2[j]) return index;\n\t} //end for\n\treturn -1;\n} //end of the function StringContains\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nchar *StringContainsWord(char *str1, char *str2, int casesensitive)\n{\n\tint len, i, j;\n\n\tlen = strlen(str1) - strlen(str2);\n\tfor (i = 0; i <= len; i++, str1++)\n\t{\n\t\t//if not at the start of the string\n\t\tif (i)\n\t\t{\n\t\t\t//skip to the start of the next word\n\t\t\twhile(*str1 && *str1 != ' ' && *str1 != '.' && *str1 != ',' && *str1 != '!') str1++;\n\t\t\tif (!*str1) break;\n\t\t\tstr1++;\n\t\t} //end for\n\t\t//compare the word\n\t\tfor (j = 0; str2[j]; j++)\n\t\t{\n\t\t\tif (casesensitive)\n\t\t\t{\n\t\t\t\tif (str1[j] != str2[j]) break;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (toupper(str1[j]) != toupper(str2[j])) break;\n\t\t\t} //end else\n\t\t} //end for\n\t\t//if there was a word match\n\t\tif (!str2[j])\n\t\t{\n\t\t\t//if the first string has an end of word\n\t\t\tif (!str1[j] || str1[j] == ' ' || str1[j] == '.' || str1[j] == ',' || str1[j] == '!') return str1;\n\t\t} //end if\n\t} //end for\n\treturn NULL;\n} //end of the function StringContainsWord\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid StringReplaceWords(char *string, char *synonym, char *replacement)\n{\n\tchar *str, *str2;\n\n\t//find the synonym in the string\n\tstr = StringContainsWord(string, synonym, qfalse);\n\t//if the synonym occured in the string\n\twhile(str)\n\t{\n\t\t//if the synonym isn't part of the replacement which is already in the string\n\t\t//usefull for abreviations\n\t\tstr2 = StringContainsWord(string, replacement, qfalse);\n\t\twhile(str2)\n\t\t{\n\t\t\tif (str2 <= str && str < str2 + strlen(replacement)) break;\n\t\t\tstr2 = StringContainsWord(str2+1, replacement, qfalse);\n\t\t} //end while\n\t\tif (!str2)\n\t\t{\n\t\t\tmemmove(str + strlen(replacement), str+strlen(synonym), strlen(str+strlen(synonym))+1);\n\t\t\t//append the synonum replacement\n\t\t\tCom_Memcpy(str, replacement, strlen(replacement));\n\t\t} //end if\n\t\t//find the next synonym in the string\n\t\tstr = StringContainsWord(str+strlen(replacement), synonym, qfalse);\n\t} //end if\n} //end of the function StringReplaceWords\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotDumpSynonymList(bot_synonymlist_t *synlist)\n{\n\tFILE *fp;\n\tbot_synonymlist_t *syn;\n\tbot_synonym_t *synonym;\n\n\tfp = Log_FilePointer();\n\tif (!fp) return;\n\tfor (syn = synlist; syn; syn = syn->next)\n\t{\n\t        fprintf(fp, \"%ld : [\", syn->context);\n\t\tfor (synonym = syn->firstsynonym; synonym; synonym = synonym->next)\n\t\t{\n\t\t\tfprintf(fp, \"(\\\"%s\\\", %1.2f)\", synonym->string, synonym->weight);\n\t\t\tif (synonym->next) fprintf(fp, \", \");\n\t\t} //end for\n\t\tfprintf(fp, \"]\\n\");\n\t} //end for\n} //end of the function BotDumpSynonymList\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_synonymlist_t *BotLoadSynonyms(char *filename)\n{\n\tint pass, size, contextlevel, numsynonyms;\n\tunsigned long int context, contextstack[32];\n\tchar *ptr = NULL;\n\tsource_t *source;\n\ttoken_t token;\n\tbot_synonymlist_t *synlist, *lastsyn, *syn;\n\tbot_synonym_t *synonym, *lastsynonym;\n\n\tsize = 0;\n\tsynlist = NULL; //make compiler happy\n\tsyn = NULL; //make compiler happy\n\tsynonym = NULL; //make compiler happy\n\t//the synonyms are parsed in two phases\n\tfor (pass = 0; pass < 2; pass++)\n\t{\n\t\t//\n\t\tif (pass && size) ptr = (char *) GetClearedHunkMemory(size);\n\t\t//\n\t\tPC_SetBaseFolder(BOTFILESBASEFOLDER);\n\t\tsource = LoadSourceFile(filename);\n\t\tif (!source)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"counldn't load %s\\n\", filename);\n\t\t\treturn NULL;\n\t\t} //end if\n\t\t//\n\t\tcontext = 0;\n\t\tcontextlevel = 0;\n\t\tsynlist = NULL; //list synonyms\n\t\tlastsyn = NULL; //last synonym in the list\n\t\t//\n\t\twhile(PC_ReadToken(source, &token))\n\t\t{\n\t\t\tif (token.type == TT_NUMBER)\n\t\t\t{\n\t\t\t\tcontext |= token.intvalue;\n\t\t\t\tcontextstack[contextlevel] = token.intvalue;\n\t\t\t\tcontextlevel++;\n\t\t\t\tif (contextlevel >= 32)\n\t\t\t\t{\n\t\t\t\t\tSourceError(source, \"more than 32 context levels\");\n\t\t\t\t\tFreeSource(source);\n\t\t\t\t\treturn NULL;\n\t\t\t\t} //end if\n\t\t\t\tif (!PC_ExpectTokenString(source, \"{\"))\n\t\t\t\t{\n\t\t\t\t\tFreeSource(source);\n\t\t\t\t\treturn NULL;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t\telse if (token.type == TT_PUNCTUATION)\n\t\t\t{\n\t\t\t\tif (!strcmp(token.string, \"}\"))\n\t\t\t\t{\n\t\t\t\t\tcontextlevel--;\n\t\t\t\t\tif (contextlevel < 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tSourceError(source, \"too many }\");\n\t\t\t\t\t\tFreeSource(source);\n\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t} //end if\n\t\t\t\t\tcontext &= ~contextstack[contextlevel];\n\t\t\t\t} //end if\n\t\t\t\telse if (!strcmp(token.string, \"[\"))\n\t\t\t\t{\n\t\t\t\t\tsize += sizeof(bot_synonymlist_t);\n\t\t\t\t\tif (pass)\n\t\t\t\t\t{\n\t\t\t\t\t\tsyn = (bot_synonymlist_t *) ptr;\n\t\t\t\t\t\tptr += sizeof(bot_synonymlist_t);\n\t\t\t\t\t\tsyn->context = context;\n\t\t\t\t\t\tsyn->firstsynonym = NULL;\n\t\t\t\t\t\tsyn->next = NULL;\n\t\t\t\t\t\tif (lastsyn) lastsyn->next = syn;\n\t\t\t\t\t\telse synlist = syn;\n\t\t\t\t\t\tlastsyn = syn;\n\t\t\t\t\t} //end if\n\t\t\t\t\tnumsynonyms = 0;\n\t\t\t\t\tlastsynonym = NULL;\n\t\t\t\t\twhile(1)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!PC_ExpectTokenString(source, \"(\") ||\n\t\t\t\t\t\t\t!PC_ExpectTokenType(source, TT_STRING, 0, &token))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tFreeSource(source);\n\t\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\tStripDoubleQuotes(token.string);\n\t\t\t\t\t\tif (strlen(token.string) <= 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourceError(source, \"empty string\", token.string);\n\t\t\t\t\t\t\tFreeSource(source);\n\t\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\tsize += sizeof(bot_synonym_t) + strlen(token.string) + 1;\n\t\t\t\t\t\tif (pass)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsynonym = (bot_synonym_t *) ptr;\n\t\t\t\t\t\t\tptr += sizeof(bot_synonym_t);\n\t\t\t\t\t\t\tsynonym->string = ptr;\n\t\t\t\t\t\t\tptr += strlen(token.string) + 1;\n\t\t\t\t\t\t\tstrcpy(synonym->string, token.string);\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\tif (lastsynonym) lastsynonym->next = synonym;\n\t\t\t\t\t\t\telse syn->firstsynonym = synonym;\n\t\t\t\t\t\t\tlastsynonym = synonym;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\tnumsynonyms++;\n\t\t\t\t\t\tif (!PC_ExpectTokenString(source, \",\") ||\n\t\t\t\t\t\t\t!PC_ExpectTokenType(source, TT_NUMBER, 0, &token) ||\n\t\t\t\t\t\t\t!PC_ExpectTokenString(source, \")\"))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tFreeSource(source);\n\t\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\tif (pass)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsynonym->weight = token.floatvalue;\n\t\t\t\t\t\t\tsyn->totalweight += synonym->weight;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\tif (PC_CheckTokenString(source, \"]\")) break;\n\t\t\t\t\t\tif (!PC_ExpectTokenString(source, \",\"))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tFreeSource(source);\n\t\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end while\n\t\t\t\t\tif (numsynonyms < 2)\n\t\t\t\t\t{\n\t\t\t\t\t\tSourceError(source, \"synonym must have at least two entries\\n\");\n\t\t\t\t\t\tFreeSource(source);\n\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end else\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tSourceError(source, \"unexpected %s\", token.string);\n\t\t\t\t\tFreeSource(source);\n\t\t\t\t\treturn NULL;\n\t\t\t\t} //end if\n\t\t\t} //end else if\n\t\t} //end while\n\t\t//\n\t\tFreeSource(source);\n\t\t//\n\t\tif (contextlevel > 0)\n\t\t{\n\t\t\tSourceError(source, \"missing }\");\n\t\t\treturn NULL;\n\t\t} //end if\n\t} //end for\n\tbotimport.Print(PRT_MESSAGE, \"loaded %s\\n\", filename);\n\t//\n\t//BotDumpSynonymList(synlist);\n\t//\n\treturn synlist;\n} //end of the function BotLoadSynonyms\n//===========================================================================\n// replace all the synonyms in the string\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotReplaceSynonyms(char *string, unsigned long int context)\n{\n\tbot_synonymlist_t *syn;\n\tbot_synonym_t *synonym;\n\n\tfor (syn = synonyms; syn; syn = syn->next)\n\t{\n\t\tif (!(syn->context & context)) continue;\n\t\tfor (synonym = syn->firstsynonym->next; synonym; synonym = synonym->next)\n\t\t{\n\t\t\tStringReplaceWords(string, synonym->string, syn->firstsynonym->string);\n\t\t} //end for\n\t} //end for\n} //end of the function BotReplaceSynonyms\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotReplaceWeightedSynonyms(char *string, unsigned long int context)\n{\n\tbot_synonymlist_t *syn;\n\tbot_synonym_t *synonym, *replacement;\n\tfloat weight, curweight;\n\n\tfor (syn = synonyms; syn; syn = syn->next)\n\t{\n\t\tif (!(syn->context & context)) continue;\n\t\t//choose a weighted random replacement synonym\n\t\tweight = random() * syn->totalweight;\n\t\tif (!weight) continue;\n\t\tcurweight = 0;\n\t\tfor (replacement = syn->firstsynonym; replacement; replacement = replacement->next)\n\t\t{\n\t\t\tcurweight += replacement->weight;\n\t\t\tif (weight < curweight) break;\n\t\t} //end for\n\t\tif (!replacement) continue;\n\t\t//replace all synonyms with the replacement\n\t\tfor (synonym = syn->firstsynonym; synonym; synonym = synonym->next)\n\t\t{\n\t\t\tif (synonym == replacement) continue;\n\t\t\tStringReplaceWords(string, synonym->string, replacement->string);\n\t\t} //end for\n\t} //end for\n} //end of the function BotReplaceWeightedSynonyms\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotReplaceReplySynonyms(char *string, unsigned long int context)\n{\n\tchar *str1, *str2, *replacement;\n\tbot_synonymlist_t *syn;\n\tbot_synonym_t *synonym;\n\n\tfor (str1 = string; *str1; )\n\t{\n\t\t//go to the start of the next word\n\t\twhile(*str1 && *str1 <= ' ') str1++;\n\t\tif (!*str1) break;\n\t\t//\n\t\tfor (syn = synonyms; syn; syn = syn->next)\n\t\t{\n\t\t\tif (!(syn->context & context)) continue;\n\t\t\tfor (synonym = syn->firstsynonym->next; synonym; synonym = synonym->next)\n\t\t\t{\n\t\t\t\tstr2 = synonym->string;\n\t\t\t\t//if the synonym is not at the front of the string continue\n\t\t\t\tstr2 = StringContainsWord(str1, synonym->string, qfalse);\n\t\t\t\tif (!str2 || str2 != str1) continue;\n\t\t\t\t//\n\t\t\t\treplacement = syn->firstsynonym->string;\n\t\t\t\t//if the replacement IS in front of the string continue\n\t\t\t\tstr2 = StringContainsWord(str1, replacement, qfalse);\n\t\t\t\tif (str2 && str2 == str1) continue;\n\t\t\t\t//\n\t\t\t\tmemmove(str1 + strlen(replacement), str1+strlen(synonym->string),\n\t\t\t\t\t\t\tstrlen(str1+strlen(synonym->string)) + 1);\n\t\t\t\t//append the synonum replacement\n\t\t\t\tCom_Memcpy(str1, replacement, strlen(replacement));\n\t\t\t\t//\n\t\t\t\tbreak;\n\t\t\t} //end for\n\t\t\t//if a synonym has been replaced\n\t\t\tif (synonym) break;\n\t\t} //end for\n\t\t//skip over this word\n\t\twhile(*str1 && *str1 > ' ') str1++;\n\t\tif (!*str1) break;\n\t} //end while\n} //end of the function BotReplaceReplySynonyms\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotLoadChatMessage(source_t *source, char *chatmessagestring)\n{\n\tchar *ptr;\n\ttoken_t token;\n\n\tptr = chatmessagestring;\n\t*ptr = 0;\n\t//\n\twhile(1)\n\t{\n\t\tif (!PC_ExpectAnyToken(source, &token)) return qfalse;\n\t\t//fixed string\n\t\tif (token.type == TT_STRING)\n\t\t{\n\t\t\tStripDoubleQuotes(token.string);\n\t\t\tif (strlen(ptr) + strlen(token.string) + 1 > MAX_MESSAGE_SIZE)\n\t\t\t{\n\t\t\t\tSourceError(source, \"chat message too long\\n\");\n\t\t\t\treturn qfalse;\n\t\t\t} //end if\n\t\t\tstrcat(ptr, token.string);\n\t\t} //end else if\n\t\t//variable string\n\t\telse if (token.type == TT_NUMBER && (token.subtype & TT_INTEGER))\n\t\t{\n\t\t\tif (strlen(ptr) + 7 > MAX_MESSAGE_SIZE)\n\t\t\t{\n\t\t\t\tSourceError(source, \"chat message too long\\n\");\n\t\t\t\treturn qfalse;\n\t\t\t} //end if\n\t\t\tsprintf(&ptr[strlen(ptr)], \"%cv%ld%c\", ESCAPE_CHAR, token.intvalue, ESCAPE_CHAR);\n\t\t} //end if\n\t\t//random string\n\t\telse if (token.type == TT_NAME)\n\t\t{\n\t\t\tif (strlen(ptr) + 7 > MAX_MESSAGE_SIZE)\n\t\t\t{\n\t\t\t\tSourceError(source, \"chat message too long\\n\");\n\t\t\t\treturn qfalse;\n\t\t\t} //end if\n\t\t\tsprintf(&ptr[strlen(ptr)], \"%cr%s%c\", ESCAPE_CHAR, token.string, ESCAPE_CHAR);\n\t\t} //end else if\n\t\telse\n\t\t{\n\t\t\tSourceError(source, \"unknown message component %s\\n\", token.string);\n\t\t\treturn qfalse;\n\t\t} //end else\n\t\tif (PC_CheckTokenString(source, \";\")) break;\n\t\tif (!PC_ExpectTokenString(source, \",\")) return qfalse;\n\t} //end while\n\t//\n\treturn qtrue;\n} //end of the function BotLoadChatMessage\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotDumpRandomStringList(bot_randomlist_t *randomlist)\n{\n\tFILE *fp;\n\tbot_randomlist_t *random;\n\tbot_randomstring_t *rs;\n\n\tfp = Log_FilePointer();\n\tif (!fp) return;\n\tfor (random = randomlist; random; random = random->next)\n\t{\n\t\tfprintf(fp, \"%s = {\", random->string);\n\t\tfor (rs = random->firstrandomstring; rs; rs = rs->next)\n\t\t{\n\t\t\tfprintf(fp, \"\\\"%s\\\"\", rs->string);\n\t\t\tif (rs->next) fprintf(fp, \", \");\n\t\t\telse fprintf(fp, \"}\\n\");\n\t\t} //end for\n\t} //end for\n} //end of the function BotDumpRandomStringList\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_randomlist_t *BotLoadRandomStrings(char *filename)\n{\n\tint pass, size;\n\tchar *ptr = NULL, chatmessagestring[MAX_MESSAGE_SIZE];\n\tsource_t *source;\n\ttoken_t token;\n\tbot_randomlist_t *randomlist, *lastrandom, *random;\n\tbot_randomstring_t *randomstring;\n\n#ifdef DEBUG\n\tint starttime = Sys_MilliSeconds();\n#endif //DEBUG\n\n\tsize = 0;\n\trandomlist = NULL;\n\trandom = NULL;\n\t//the synonyms are parsed in two phases\n\tfor (pass = 0; pass < 2; pass++)\n\t{\n\t\t//\n\t\tif (pass && size) ptr = (char *) GetClearedHunkMemory(size);\n\t\t//\n\t\tPC_SetBaseFolder(BOTFILESBASEFOLDER);\n\t\tsource = LoadSourceFile(filename);\n\t\tif (!source)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"counldn't load %s\\n\", filename);\n\t\t\treturn NULL;\n\t\t} //end if\n\t\t//\n\t\trandomlist = NULL; //list\n\t\tlastrandom = NULL; //last\n\t\t//\n\t\twhile(PC_ReadToken(source, &token))\n\t\t{\n\t\t\tif (token.type != TT_NAME)\n\t\t\t{\n\t\t\t\tSourceError(source, \"unknown random %s\", token.string);\n\t\t\t\tFreeSource(source);\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t\tsize += sizeof(bot_randomlist_t) + strlen(token.string) + 1;\n\t\t\tif (pass)\n\t\t\t{\n\t\t\t\trandom = (bot_randomlist_t *) ptr;\n\t\t\t\tptr += sizeof(bot_randomlist_t);\n\t\t\t\trandom->string = ptr;\n\t\t\t\tptr += strlen(token.string) + 1;\n\t\t\t\tstrcpy(random->string, token.string);\n\t\t\t\trandom->firstrandomstring = NULL;\n\t\t\t\trandom->numstrings = 0;\n\t\t\t\t//\n\t\t\t\tif (lastrandom) lastrandom->next = random;\n\t\t\t\telse randomlist = random;\n\t\t\t\tlastrandom = random;\n\t\t\t} //end if\n\t\t\tif (!PC_ExpectTokenString(source, \"=\") ||\n\t\t\t\t!PC_ExpectTokenString(source, \"{\"))\n\t\t\t{\n\t\t\t\tFreeSource(source);\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t\twhile(!PC_CheckTokenString(source, \"}\"))\n\t\t\t{\n\t\t\t\tif (!BotLoadChatMessage(source, chatmessagestring))\n\t\t\t\t{\n\t\t\t\t\tFreeSource(source);\n\t\t\t\t\treturn NULL;\n\t\t\t\t} //end if\n\t\t\t\tsize += sizeof(bot_randomstring_t) + strlen(chatmessagestring) + 1;\n\t\t\t\tif (pass)\n\t\t\t\t{\n\t\t\t\t\trandomstring = (bot_randomstring_t *) ptr;\n\t\t\t\t\tptr += sizeof(bot_randomstring_t);\n\t\t\t\t\trandomstring->string = ptr;\n\t\t\t\t\tptr += strlen(chatmessagestring) + 1;\n\t\t\t\t\tstrcpy(randomstring->string, chatmessagestring);\n\t\t\t\t\t//\n\t\t\t\t\trandom->numstrings++;\n\t\t\t\t\trandomstring->next = random->firstrandomstring;\n\t\t\t\t\trandom->firstrandomstring = randomstring;\n\t\t\t\t} //end if\n\t\t\t} //end while\n\t\t} //end while\n\t\t//free the source after one pass\n\t\tFreeSource(source);\n\t} //end for\n\tbotimport.Print(PRT_MESSAGE, \"loaded %s\\n\", filename);\n\t//\n#ifdef DEBUG\n\tbotimport.Print(PRT_MESSAGE, \"random strings %d msec\\n\", Sys_MilliSeconds() - starttime);\n\t//BotDumpRandomStringList(randomlist);\n#endif //DEBUG\n\t//\n\treturn randomlist;\n} //end of the function BotLoadRandomStrings\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nchar *RandomString(char *name)\n{\n\tbot_randomlist_t *random;\n\tbot_randomstring_t *rs;\n\tint i;\n\n\tfor (random = randomstrings; random; random = random->next)\n\t{\n\t\tif (!strcmp(random->string, name))\n\t\t{\n\t\t\ti = random() * random->numstrings;\n\t\t\tfor (rs = random->firstrandomstring; rs; rs = rs->next)\n\t\t\t{\n\t\t\t\tif (--i < 0) break;\n\t\t\t} //end for\n\t\t\tif (rs)\n\t\t\t{\n\t\t\t\treturn rs->string;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\treturn NULL;\n} //end of the function RandomString\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotDumpMatchTemplates(bot_matchtemplate_t *matches)\n{\n\tFILE *fp;\n\tbot_matchtemplate_t *mt;\n\tbot_matchpiece_t *mp;\n\tbot_matchstring_t *ms;\n\n\tfp = Log_FilePointer();\n\tif (!fp) return;\n\tfor (mt = matches; mt; mt = mt->next)\n\t{\n\t        fprintf(fp, \"{ \" );\n\t\tfor (mp = mt->first; mp; mp = mp->next)\n\t\t{\n\t\t\tif (mp->type == MT_STRING)\n\t\t\t{\n\t\t\t\tfor (ms = mp->firststring; ms; ms = ms->next)\n\t\t\t\t{\n\t\t\t\t\tfprintf(fp, \"\\\"%s\\\"\", ms->string);\n\t\t\t\t\tif (ms->next) fprintf(fp, \"|\");\n\t\t\t\t} //end for\n\t\t\t} //end if\n\t\t\telse if (mp->type == MT_VARIABLE)\n\t\t\t{\n\t\t\t\tfprintf(fp, \"%d\", mp->variable);\n\t\t\t} //end else if\n\t\t\tif (mp->next) fprintf(fp, \", \");\n\t\t} //end for\n\t\tfprintf(fp, \" = (%d, %d);}\\n\", mt->type, mt->subtype);\n\t} //end for\n} //end of the function BotDumpMatchTemplates\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotFreeMatchPieces(bot_matchpiece_t *matchpieces)\n{\n\tbot_matchpiece_t *mp, *nextmp;\n\tbot_matchstring_t *ms, *nextms;\n\n\tfor (mp = matchpieces; mp; mp = nextmp)\n\t{\n\t\tnextmp = mp->next;\n\t\tif (mp->type == MT_STRING)\n\t\t{\n\t\t\tfor (ms = mp->firststring; ms; ms = nextms)\n\t\t\t{\n\t\t\t\tnextms = ms->next;\n\t\t\t\tFreeMemory(ms);\n\t\t\t} //end for\n\t\t} //end if\n\t\tFreeMemory(mp);\n\t} //end for\n} //end of the function BotFreeMatchPieces\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_matchpiece_t *BotLoadMatchPieces(source_t *source, char *endtoken)\n{\n\tint lastwasvariable, emptystring;\n\ttoken_t token;\n\tbot_matchpiece_t *matchpiece, *firstpiece, *lastpiece;\n\tbot_matchstring_t *matchstring, *lastmatchstring;\n\n\tfirstpiece = NULL;\n\tlastpiece = NULL;\n\t//\n\tlastwasvariable = qfalse;\n\t//\n\twhile(PC_ReadToken(source, &token))\n\t{\n\t\tif (token.type == TT_NUMBER && (token.subtype & TT_INTEGER))\n\t\t{\n\t\t\tif (token.intvalue < 0 || token.intvalue >= MAX_MATCHVARIABLES)\n\t\t\t{\n\t\t\t\tSourceError(source, \"can't have more than %d match variables\\n\", MAX_MATCHVARIABLES);\n\t\t\t\tFreeSource(source);\n\t\t\t\tBotFreeMatchPieces(firstpiece);\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t\tif (lastwasvariable)\n\t\t\t{\n\t\t\t\tSourceError(source, \"not allowed to have adjacent variables\\n\");\n\t\t\t\tFreeSource(source);\n\t\t\t\tBotFreeMatchPieces(firstpiece);\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t\tlastwasvariable = qtrue;\n\t\t\t//\n\t\t\tmatchpiece = (bot_matchpiece_t *) GetClearedHunkMemory(sizeof(bot_matchpiece_t));\n\t\t\tmatchpiece->type = MT_VARIABLE;\n\t\t\tmatchpiece->variable = token.intvalue;\n\t\t\tmatchpiece->next = NULL;\n\t\t\tif (lastpiece) lastpiece->next = matchpiece;\n\t\t\telse firstpiece = matchpiece;\n\t\t\tlastpiece = matchpiece;\n\t\t} //end if\n\t\telse if (token.type == TT_STRING)\n\t\t{\n\t\t\t//\n\t\t\tmatchpiece = (bot_matchpiece_t *) GetClearedHunkMemory(sizeof(bot_matchpiece_t));\n\t\t\tmatchpiece->firststring = NULL;\n\t\t\tmatchpiece->type = MT_STRING;\n\t\t\tmatchpiece->variable = 0;\n\t\t\tmatchpiece->next = NULL;\n\t\t\tif (lastpiece) lastpiece->next = matchpiece;\n\t\t\telse firstpiece = matchpiece;\n\t\t\tlastpiece = matchpiece;\n\t\t\t//\n\t\t\tlastmatchstring = NULL;\n\t\t\temptystring = qfalse;\n\t\t\t//\n\t\t\tdo\n\t\t\t{\n\t\t\t\tif (matchpiece->firststring)\n\t\t\t\t{\n\t\t\t\t\tif (!PC_ExpectTokenType(source, TT_STRING, 0, &token))\n\t\t\t\t\t{\n\t\t\t\t\t\tFreeSource(source);\n\t\t\t\t\t\tBotFreeMatchPieces(firstpiece);\n\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t\tStripDoubleQuotes(token.string);\n\t\t\t\tmatchstring = (bot_matchstring_t *) GetClearedHunkMemory(sizeof(bot_matchstring_t) + strlen(token.string) + 1);\n\t\t\t\tmatchstring->string = (char *) matchstring + sizeof(bot_matchstring_t);\n\t\t\t\tstrcpy(matchstring->string, token.string);\n\t\t\t\tif (!strlen(token.string)) emptystring = qtrue;\n\t\t\t\tmatchstring->next = NULL;\n\t\t\t\tif (lastmatchstring) lastmatchstring->next = matchstring;\n\t\t\t\telse matchpiece->firststring = matchstring;\n\t\t\t\tlastmatchstring = matchstring;\n\t\t\t} while(PC_CheckTokenString(source, \"|\"));\n\t\t\t//if there was no empty string found\n\t\t\tif (!emptystring) lastwasvariable = qfalse;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tSourceError(source, \"invalid token %s\\n\", token.string);\n\t\t\tFreeSource(source);\n\t\t\tBotFreeMatchPieces(firstpiece);\n\t\t\treturn NULL;\n\t\t} //end else\n\t\tif (PC_CheckTokenString(source, endtoken)) break;\n\t\tif (!PC_ExpectTokenString(source, \",\"))\n\t\t{\n\t\t\tFreeSource(source);\n\t\t\tBotFreeMatchPieces(firstpiece);\n\t\t\treturn NULL;\n\t\t} //end if\n\t} //end while\n\treturn firstpiece;\n} //end of the function BotLoadMatchPieces\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotFreeMatchTemplates(bot_matchtemplate_t *mt)\n{\n\tbot_matchtemplate_t *nextmt;\n\n\tfor (; mt; mt = nextmt)\n\t{\n\t\tnextmt = mt->next;\n\t\tBotFreeMatchPieces(mt->first);\n\t\tFreeMemory(mt);\n\t} //end for\n} //end of the function BotFreeMatchTemplates\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_matchtemplate_t *BotLoadMatchTemplates(char *matchfile)\n{\n\tsource_t *source;\n\ttoken_t token;\n\tbot_matchtemplate_t *matchtemplate, *matches, *lastmatch;\n\tunsigned long int context;\n\n\tPC_SetBaseFolder(BOTFILESBASEFOLDER);\n\tsource = LoadSourceFile(matchfile);\n\tif (!source)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"counldn't load %s\\n\", matchfile);\n\t\treturn NULL;\n\t} //end if\n\t//\n\tmatches = NULL; //list with matches\n\tlastmatch = NULL; //last match in the list\n\n\twhile(PC_ReadToken(source, &token))\n\t{\n\t\tif (token.type != TT_NUMBER || !(token.subtype & TT_INTEGER))\n\t\t{\n\t\t\tSourceError(source, \"expected integer, found %s\\n\", token.string);\n\t\t\tBotFreeMatchTemplates(matches);\n\t\t\tFreeSource(source);\n\t\t\treturn NULL;\n\t\t} //end if\n\t\t//the context\n\t\tcontext = token.intvalue;\n\t\t//\n\t\tif (!PC_ExpectTokenString(source, \"{\"))\n\t\t{\n\t\t\tBotFreeMatchTemplates(matches);\n\t\t\tFreeSource(source);\n\t\t\treturn NULL;\n\t\t} //end if\n\t\t//\n\t\twhile(PC_ReadToken(source, &token))\n\t\t{\n\t\t\tif (!strcmp(token.string, \"}\")) break;\n\t\t\t//\n\t\t\tPC_UnreadLastToken(source);\n\t\t\t//\n\t\t\tmatchtemplate = (bot_matchtemplate_t *) GetClearedHunkMemory(sizeof(bot_matchtemplate_t));\n\t\t\tmatchtemplate->context = context;\n\t\t\tmatchtemplate->next = NULL;\n\t\t\t//add the match template to the list\n\t\t\tif (lastmatch) lastmatch->next = matchtemplate;\n\t\t\telse matches = matchtemplate;\n\t\t\tlastmatch = matchtemplate;\n\t\t\t//load the match template\n\t\t\tmatchtemplate->first = BotLoadMatchPieces(source, \"=\");\n\t\t\tif (!matchtemplate->first)\n\t\t\t{\n\t\t\t\tBotFreeMatchTemplates(matches);\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t\t//read the match type\n\t\t\tif (!PC_ExpectTokenString(source, \"(\") ||\n\t\t\t\t!PC_ExpectTokenType(source, TT_NUMBER, TT_INTEGER, &token))\n\t\t\t{\n\t\t\t\tBotFreeMatchTemplates(matches);\n\t\t\t\tFreeSource(source);\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t\tmatchtemplate->type = token.intvalue;\n\t\t\t//read the match subtype\n\t\t\tif (!PC_ExpectTokenString(source, \",\") ||\n\t\t\t\t!PC_ExpectTokenType(source, TT_NUMBER, TT_INTEGER, &token))\n\t\t\t{\n\t\t\t\tBotFreeMatchTemplates(matches);\n\t\t\t\tFreeSource(source);\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t\tmatchtemplate->subtype = token.intvalue;\n\t\t\t//read trailing punctuations\n\t\t\tif (!PC_ExpectTokenString(source, \")\") ||\n\t\t\t\t!PC_ExpectTokenString(source, \";\"))\n\t\t\t{\n\t\t\t\tBotFreeMatchTemplates(matches);\n\t\t\t\tFreeSource(source);\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t} //end while\n\t} //end while\n\t//free the source\n\tFreeSource(source);\n\tbotimport.Print(PRT_MESSAGE, \"loaded %s\\n\", matchfile);\n\t//\n\t//BotDumpMatchTemplates(matches);\n\t//\n\treturn matches;\n} //end of the function BotLoadMatchTemplates\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint StringsMatch(bot_matchpiece_t *pieces, bot_match_t *match)\n{\n\tint lastvariable, index;\n\tchar *strptr, *newstrptr;\n\tbot_matchpiece_t *mp;\n\tbot_matchstring_t *ms;\n\n\t//no last variable\n\tlastvariable = -1;\n\t//pointer to the string to compare the match string with\n\tstrptr = match->string;\n\t//Log_Write(\"match: %s\", strptr);\n\t//compare the string with the current match string\n\tfor (mp = pieces; mp; mp = mp->next)\n\t{\n\t\t//if it is a piece of string\n\t\tif (mp->type == MT_STRING)\n\t\t{\n\t\t\tnewstrptr = NULL;\n\t\t\tfor (ms = mp->firststring; ms; ms = ms->next)\n\t\t\t{\n\t\t\t\tif (!strlen(ms->string))\n\t\t\t\t{\n\t\t\t\t\tnewstrptr = strptr;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t\t//Log_Write(\"MT_STRING: %s\", mp->string);\n\t\t\t\tindex = StringContains(strptr, ms->string, qfalse);\n\t\t\t\tif (index >= 0)\n\t\t\t\t{\n\t\t\t\t\tnewstrptr = strptr + index;\n\t\t\t\t\tif (lastvariable >= 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tmatch->variables[lastvariable].length =\n\t\t\t\t\t\t\t\t(newstrptr - match->string) - match->variables[lastvariable].offset;\n\t\t\t\t\t\t\t\t//newstrptr - match->variables[lastvariable].ptr;\n\t\t\t\t\t\tlastvariable = -1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} //end if\n\t\t\t\t\telse if (index == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} //end else\n\t\t\t\t\tnewstrptr = NULL;\n\t\t\t\t} //end if\n\t\t\t} //end for\n\t\t\tif (!newstrptr) return qfalse;\n\t\t\tstrptr = newstrptr + strlen(ms->string);\n\t\t} //end if\n\t\t//if it is a variable piece of string\n\t\telse if (mp->type == MT_VARIABLE)\n\t\t{\n\t\t\t//Log_Write(\"MT_VARIABLE\");\n\t\t\tmatch->variables[mp->variable].offset = strptr - match->string;\n\t\t\tlastvariable = mp->variable;\n\t\t} //end else if\n\t} //end for\n\t//if a match was found\n\tif (!mp && (lastvariable >= 0 || !strlen(strptr)))\n\t{\n\t\t//if the last piece was a variable string\n\t\tif (lastvariable >= 0)\n\t\t{\n        \t\tassert( match->variables[lastvariable].offset >= 0 ); // bk001204\n\t\t\tmatch->variables[lastvariable].length =\n\t\t\t\tstrlen(&match->string[ (int) match->variables[lastvariable].offset]);\n\t\t} //end if\n\t\treturn qtrue;\n\t} //end if\n\treturn qfalse;\n} //end of the function StringsMatch\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotFindMatch(char *str, bot_match_t *match, unsigned long int context)\n{\n\tint i;\n\tbot_matchtemplate_t *ms;\n\n\tstrncpy(match->string, str, MAX_MESSAGE_SIZE);\n\t//remove any trailing enters\n\twhile(strlen(match->string) &&\n\t\t\tmatch->string[strlen(match->string)-1] == '\\n')\n\t{\n\t\tmatch->string[strlen(match->string)-1] = '\\0';\n\t} //end while\n\t//compare the string with all the match strings\n\tfor (ms = matchtemplates; ms; ms = ms->next)\n\t{\n\t\tif (!(ms->context & context)) continue;\n\t\t//reset the match variable offsets\n\t\tfor (i = 0; i < MAX_MATCHVARIABLES; i++) match->variables[i].offset = -1;\n\t\t//\n\t\tif (StringsMatch(ms->first, match))\n\t\t{\n\t\t\tmatch->type = ms->type;\n\t\t\tmatch->subtype = ms->subtype;\n\t\t\treturn qtrue;\n\t\t} //end if\n\t} //end for\n\treturn qfalse;\n} //end of the function BotFindMatch\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotMatchVariable(bot_match_t *match, int variable, char *buf, int size)\n{\n\tif (variable < 0 || variable >= MAX_MATCHVARIABLES)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"BotMatchVariable: variable out of range\\n\");\n\t\tstrcpy(buf, \"\");\n\t\treturn;\n\t} //end if\n\n\tif (match->variables[variable].offset >= 0)\n\t{\n\t\tif (match->variables[variable].length < size)\n\t\t\tsize = match->variables[variable].length+1;\n\t\tassert( match->variables[variable].offset >= 0 ); // bk001204\n\t\tstrncpy(buf, &match->string[ (int) match->variables[variable].offset], size-1);\n\t\tbuf[size-1] = '\\0';\n\t} //end if\n\telse\n\t{\n\t\tstrcpy(buf, \"\");\n\t} //end else\n\treturn;\n} //end of the function BotMatchVariable\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_stringlist_t *BotFindStringInList(bot_stringlist_t *list, char *string)\n{\n\tbot_stringlist_t *s;\n\n\tfor (s = list; s; s = s->next)\n\t{\n\t\tif (!strcmp(s->string, string)) return s;\n\t} //end for\n\treturn NULL;\n} //end of the function BotFindStringInList\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_stringlist_t *BotCheckChatMessageIntegrety(char *message, bot_stringlist_t *stringlist)\n{\n\tint i;\n\tchar *msgptr;\n\tchar temp[MAX_MESSAGE_SIZE];\n\tbot_stringlist_t *s;\n\n\tmsgptr = message;\n\t//\n\twhile(*msgptr)\n\t{\n\t\tif (*msgptr == ESCAPE_CHAR)\n\t\t{\n\t\t\tmsgptr++;\n\t\t\tswitch(*msgptr)\n\t\t\t{\n\t\t\t\tcase 'v': //variable\n\t\t\t\t{\n\t\t\t\t\t//step over the 'v'\n\t\t\t\t\tmsgptr++;\n\t\t\t\t\twhile(*msgptr && *msgptr != ESCAPE_CHAR) msgptr++;\n\t\t\t\t\t//step over the trailing escape char\n\t\t\t\t\tif (*msgptr) msgptr++;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end case\n\t\t\t\tcase 'r': //random\n\t\t\t\t{\n\t\t\t\t\t//step over the 'r'\n\t\t\t\t\tmsgptr++;\n\t\t\t\t\tfor (i = 0; (*msgptr && *msgptr != ESCAPE_CHAR); i++)\n\t\t\t\t\t{\n\t\t\t\t\t\ttemp[i] = *msgptr++;\n\t\t\t\t\t} //end while\n\t\t\t\t\ttemp[i] = '\\0';\n\t\t\t\t\t//step over the trailing escape char\n\t\t\t\t\tif (*msgptr) msgptr++;\n\t\t\t\t\t//find the random keyword\n\t\t\t\t\tif (!RandomString(temp))\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!BotFindStringInList(stringlist, temp))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tLog_Write(\"%s = {\\\"%s\\\"} //MISSING RANDOM\\r\\n\", temp, temp);\n\t\t\t\t\t\t\ts = GetClearedMemory(sizeof(bot_stringlist_t) + strlen(temp) + 1);\n\t\t\t\t\t\t\ts->string = (char *) s + sizeof(bot_stringlist_t);\n\t\t\t\t\t\t\tstrcpy(s->string, temp);\n\t\t\t\t\t\t\ts->next = stringlist;\n\t\t\t\t\t\t\tstringlist = s;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end if\n\t\t\t\t\tbreak;\n\t\t\t\t} //end case\n\t\t\t\tdefault:\n\t\t\t\t{\n\t\t\t\t\tbotimport.Print(PRT_FATAL, \"BotCheckChatMessageIntegrety: message \\\"%s\\\" invalid escape char\\n\", message);\n\t\t\t\t\tbreak;\n\t\t\t\t} //end default\n\t\t\t} //end switch\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tmsgptr++;\n\t\t} //end else\n\t} //end while\n\treturn stringlist;\n} //end of the function BotCheckChatMessageIntegrety\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotCheckInitialChatIntegrety(bot_chat_t *chat)\n{\n\tbot_chattype_t *t;\n\tbot_chatmessage_t *cm;\n\tbot_stringlist_t *stringlist, *s, *nexts;\n\n\tstringlist = NULL;\n\tfor (t = chat->types; t; t = t->next)\n\t{\n\t\tfor (cm = t->firstchatmessage; cm; cm = cm->next)\n\t\t{\n\t\t\tstringlist = BotCheckChatMessageIntegrety(cm->chatmessage, stringlist);\n\t\t} //end for\n\t} //end for\n\tfor (s = stringlist; s; s = nexts)\n\t{\n\t\tnexts = s->next;\n\t\tFreeMemory(s);\n\t} //end for\n} //end of the function BotCheckInitialChatIntegrety\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotCheckReplyChatIntegrety(bot_replychat_t *replychat)\n{\n\tbot_replychat_t *rp;\n\tbot_chatmessage_t *cm;\n\tbot_stringlist_t *stringlist, *s, *nexts;\n\n\tstringlist = NULL;\n\tfor (rp = replychat; rp; rp = rp->next)\n\t{\n\t\tfor (cm = rp->firstchatmessage; cm; cm = cm->next)\n\t\t{\n\t\t\tstringlist = BotCheckChatMessageIntegrety(cm->chatmessage, stringlist);\n\t\t} //end for\n\t} //end for\n\tfor (s = stringlist; s; s = nexts)\n\t{\n\t\tnexts = s->next;\n\t\tFreeMemory(s);\n\t} //end for\n} //end of the function BotCheckReplyChatIntegrety\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotDumpReplyChat(bot_replychat_t *replychat)\n{\n\tFILE *fp;\n\tbot_replychat_t *rp;\n\tbot_replychatkey_t *key;\n\tbot_chatmessage_t *cm;\n\tbot_matchpiece_t *mp;\n\n\tfp = Log_FilePointer();\n\tif (!fp) return;\n\tfprintf(fp, \"BotDumpReplyChat:\\n\");\n\tfor (rp = replychat; rp; rp = rp->next)\n\t{\n\t\tfprintf(fp, \"[\");\n\t\tfor (key = rp->keys; key; key = key->next)\n\t\t{\n\t\t\tif (key->flags & RCKFL_AND) fprintf(fp, \"&\");\n\t\t\telse if (key->flags & RCKFL_NOT) fprintf(fp, \"!\");\n\t\t\t//\n\t\t\tif (key->flags & RCKFL_NAME) fprintf(fp, \"name\");\n\t\t\telse if (key->flags & RCKFL_GENDERFEMALE) fprintf(fp, \"female\");\n\t\t\telse if (key->flags & RCKFL_GENDERMALE) fprintf(fp, \"male\");\n\t\t\telse if (key->flags & RCKFL_GENDERLESS) fprintf(fp, \"it\");\n\t\t\telse if (key->flags & RCKFL_VARIABLES)\n\t\t\t{\n\t\t\t\tfprintf(fp, \"(\");\n\t\t\t\tfor (mp = key->match; mp; mp = mp->next)\n\t\t\t\t{\n\t\t\t\t\tif (mp->type == MT_STRING) fprintf(fp, \"\\\"%s\\\"\", mp->firststring->string);\n\t\t\t\t\telse fprintf(fp, \"%d\", mp->variable);\n\t\t\t\t\tif (mp->next) fprintf(fp, \", \");\n\t\t\t\t} //end for\n\t\t\t\tfprintf(fp, \")\");\n\t\t\t} //end if\n\t\t\telse if (key->flags & RCKFL_STRING)\n\t\t\t{\n\t\t\t\tfprintf(fp, \"\\\"%s\\\"\", key->string);\n\t\t\t} //end if\n\t\t\tif (key->next) fprintf(fp, \", \");\n\t\t\telse fprintf(fp, \"] = %1.0f\\n\", rp->priority);\n\t\t} //end for\n\t\tfprintf(fp, \"{\\n\");\n\t\tfor (cm = rp->firstchatmessage; cm; cm = cm->next)\n\t\t{\n\t\t\tfprintf(fp, \"\\t\\\"%s\\\";\\n\", cm->chatmessage);\n\t\t} //end for\n\t\tfprintf(fp, \"}\\n\");\n\t} //end for\n} //end of the function BotDumpReplyChat\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotFreeReplyChat(bot_replychat_t *replychat)\n{\n\tbot_replychat_t *rp, *nextrp;\n\tbot_replychatkey_t *key, *nextkey;\n\tbot_chatmessage_t *cm, *nextcm;\n\n\tfor (rp = replychat; rp; rp = nextrp)\n\t{\n\t\tnextrp = rp->next;\n\t\tfor (key = rp->keys; key; key = nextkey)\n\t\t{\n\t\t\tnextkey = key->next;\n\t\t\tif (key->match) BotFreeMatchPieces(key->match);\n\t\t\tif (key->string) FreeMemory(key->string);\n\t\t\tFreeMemory(key);\n\t\t} //end for\n\t\tfor (cm = rp->firstchatmessage; cm; cm = nextcm)\n\t\t{\n\t\t\tnextcm = cm->next;\n\t\t\tFreeMemory(cm);\n\t\t} //end for\n\t\tFreeMemory(rp);\n\t} //end for\n} //end of the function BotFreeReplyChat\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotCheckValidReplyChatKeySet(source_t *source, bot_replychatkey_t *keys)\n{\n\tint allprefixed, hasvariableskey, hasstringkey;\n\tbot_matchpiece_t *m;\n\tbot_matchstring_t *ms;\n\tbot_replychatkey_t *key, *key2;\n\n\t//\n\tallprefixed = qtrue;\n\thasvariableskey = hasstringkey = qfalse;\n\tfor (key = keys; key; key = key->next)\n\t{\n\t\tif (!(key->flags & (RCKFL_AND|RCKFL_NOT)))\n\t\t{\n\t\t\tallprefixed = qfalse;\n\t\t\tif (key->flags & RCKFL_VARIABLES)\n\t\t\t{\n\t\t\t\tfor (m = key->match; m; m = m->next)\n\t\t\t\t{\n\t\t\t\t\tif (m->type == MT_VARIABLE) hasvariableskey = qtrue;\n\t\t\t\t} //end for\n\t\t\t} //end if\n\t\t\telse if (key->flags & RCKFL_STRING)\n\t\t\t{\n\t\t\t\thasstringkey = qtrue;\n\t\t\t} //end else if\n\t\t} //end if\n\t\telse if ((key->flags & RCKFL_AND) && (key->flags & RCKFL_STRING))\n\t\t{\n\t\t\tfor (key2 = keys; key2; key2 = key2->next)\n\t\t\t{\n\t\t\t\tif (key2 == key) continue;\n\t\t\t\tif (key2->flags & RCKFL_NOT) continue;\n\t\t\t\tif (key2->flags & RCKFL_VARIABLES)\n\t\t\t\t{\n\t\t\t\t\tfor (m = key2->match; m; m = m->next)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (m->type == MT_STRING)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfor (ms = m->firststring; ms; ms = ms->next)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (StringContains(ms->string, key->string, qfalse) != -1)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\t} //end for\n\t\t\t\t\t\t\tif (ms) break;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\telse if (m->type == MT_VARIABLE)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end for\n\t\t\t\t\tif (!m)\n\t\t\t\t\t{\n\t\t\t\t\t\tSourceWarning(source, \"one of the match templates does not \"\n\t\t\t\t\t\t\t\t\t\t\"leave space for the key %s with the & prefix\", key->string);\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t} //end for\n\t\t} //end else\n\t\tif ((key->flags & RCKFL_NOT) && (key->flags & RCKFL_STRING))\n\t\t{\n\t\t\tfor (key2 = keys; key2; key2 = key2->next)\n\t\t\t{\n\t\t\t\tif (key2 == key) continue;\n\t\t\t\tif (key2->flags & RCKFL_NOT) continue;\n\t\t\t\tif (key2->flags & RCKFL_STRING)\n\t\t\t\t{\n\t\t\t\t\tif (StringContains(key2->string, key->string, qfalse) != -1)\n\t\t\t\t\t{\n\t\t\t\t\t\tSourceWarning(source, \"the key %s with prefix ! is inside the key %s\", key->string, key2->string);\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t\telse if (key2->flags & RCKFL_VARIABLES)\n\t\t\t\t{\n\t\t\t\t\tfor (m = key2->match; m; m = m->next)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (m->type == MT_STRING)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfor (ms = m->firststring; ms; ms = ms->next)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (StringContains(ms->string, key->string, qfalse) != -1)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tSourceWarning(source, \"the key %s with prefix ! is inside \"\n\t\t\t\t\t\t\t\t\t\t\t\t\"the match template string %s\", key->string, ms->string);\n\t\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\t} //end for\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end for\n\t\t\t\t} //end else if\n\t\t\t} //end for\n\t\t} //end if\n\t} //end for\n\tif (allprefixed) SourceWarning(source, \"all keys have a & or ! prefix\");\n\tif (hasvariableskey && hasstringkey)\n\t{\n\t\tSourceWarning(source, \"variables from the match template(s) could be \"\n\t\t\t\t\t\t\t\t\"invalid when outputting one of the chat messages\");\n\t} //end if\n} //end of the function BotCheckValidReplyChatKeySet\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_replychat_t *BotLoadReplyChat(char *filename)\n{\n\tchar chatmessagestring[MAX_MESSAGE_SIZE];\n\tchar namebuffer[MAX_MESSAGE_SIZE];\n\tsource_t *source;\n\ttoken_t token;\n\tbot_chatmessage_t *chatmessage = NULL;\n\tbot_replychat_t *replychat, *replychatlist;\n\tbot_replychatkey_t *key;\n\n\tPC_SetBaseFolder(BOTFILESBASEFOLDER);\n\tsource = LoadSourceFile(filename);\n\tif (!source)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"counldn't load %s\\n\", filename);\n\t\treturn NULL;\n\t} //end if\n\t//\n\treplychatlist = NULL;\n\t//\n\twhile(PC_ReadToken(source, &token))\n\t{\n\t\tif (strcmp(token.string, \"[\"))\n\t\t{\n\t\t\tSourceError(source, \"expected [, found %s\", token.string);\n\t\t\tBotFreeReplyChat(replychatlist);\n\t\t\tFreeSource(source);\n\t\t\treturn NULL;\n\t\t} //end if\n\t\t//\n\t\treplychat = GetClearedHunkMemory(sizeof(bot_replychat_t));\n\t\treplychat->keys = NULL;\n\t\treplychat->next = replychatlist;\n\t\treplychatlist = replychat;\n\t\t//read the keys, there must be at least one key\n\t\tdo\n\t\t{\n\t\t\t//allocate a key\n\t\t\tkey = (bot_replychatkey_t *) GetClearedHunkMemory(sizeof(bot_replychatkey_t));\n\t\t\tkey->flags = 0;\n\t\t\tkey->string = NULL;\n\t\t\tkey->match = NULL;\n\t\t\tkey->next = replychat->keys;\n\t\t\treplychat->keys = key;\n\t\t\t//check for MUST BE PRESENT and MUST BE ABSENT keys\n\t\t\tif (PC_CheckTokenString(source, \"&\")) key->flags |= RCKFL_AND;\n\t\t\telse if (PC_CheckTokenString(source, \"!\")) key->flags |= RCKFL_NOT;\n\t\t\t//special keys\n\t\t\tif (PC_CheckTokenString(source, \"name\")) key->flags |= RCKFL_NAME;\n\t\t\telse if (PC_CheckTokenString(source, \"female\")) key->flags |= RCKFL_GENDERFEMALE;\n\t\t\telse if (PC_CheckTokenString(source, \"male\")) key->flags |= RCKFL_GENDERMALE;\n\t\t\telse if (PC_CheckTokenString(source, \"it\")) key->flags |= RCKFL_GENDERLESS;\n\t\t\telse if (PC_CheckTokenString(source, \"(\")) //match key\n\t\t\t{\n\t\t\t\tkey->flags |= RCKFL_VARIABLES;\n\t\t\t\tkey->match = BotLoadMatchPieces(source, \")\");\n\t\t\t\tif (!key->match)\n\t\t\t\t{\n\t\t\t\t\tBotFreeReplyChat(replychatlist);\n\t\t\t\t\treturn NULL;\n\t\t\t\t} //end if\n\t\t\t} //end else if\n\t\t\telse if (PC_CheckTokenString(source, \"<\")) //bot names\n\t\t\t{\n\t\t\t\tkey->flags |= RCKFL_BOTNAMES;\n\t\t\t\tstrcpy(namebuffer, \"\");\n\t\t\t\tdo\n\t\t\t\t{\n\t\t\t\t\tif (!PC_ExpectTokenType(source, TT_STRING, 0, &token))\n\t\t\t\t\t{\n\t\t\t\t\t\tBotFreeReplyChat(replychatlist);\n\t\t\t\t\t\tFreeSource(source);\n\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t} //end if\n\t\t\t\t\tStripDoubleQuotes(token.string);\n\t\t\t\t\tif (strlen(namebuffer)) strcat(namebuffer, \"\\\\\");\n\t\t\t\t\tstrcat(namebuffer, token.string);\n\t\t\t\t} while(PC_CheckTokenString(source, \",\"));\n\t\t\t\tif (!PC_ExpectTokenString(source, \">\"))\n\t\t\t\t{\n\t\t\t\t\tBotFreeReplyChat(replychatlist);\n\t\t\t\t\tFreeSource(source);\n\t\t\t\t\treturn NULL;\n\t\t\t\t} //end if\n\t\t\t\tkey->string = (char *) GetClearedHunkMemory(strlen(namebuffer) + 1);\n\t\t\t\tstrcpy(key->string, namebuffer);\n\t\t\t} //end else if\n\t\t\telse //normal string key\n\t\t\t{\n\t\t\t\tkey->flags |= RCKFL_STRING;\n\t\t\t\tif (!PC_ExpectTokenType(source, TT_STRING, 0, &token))\n\t\t\t\t{\n\t\t\t\t\tBotFreeReplyChat(replychatlist);\n\t\t\t\t\tFreeSource(source);\n\t\t\t\t\treturn NULL;\n\t\t\t\t} //end if\n\t\t\t\tStripDoubleQuotes(token.string);\n\t\t\t\tkey->string = (char *) GetClearedHunkMemory(strlen(token.string) + 1);\n\t\t\t\tstrcpy(key->string, token.string);\n\t\t\t} //end else\n\t\t\t//\n\t\t\tPC_CheckTokenString(source, \",\");\n\t\t} while(!PC_CheckTokenString(source, \"]\"));\n\t\t//\n\t\tBotCheckValidReplyChatKeySet(source, replychat->keys);\n\t\t//read the = sign and the priority\n\t\tif (!PC_ExpectTokenString(source, \"=\") ||\n\t\t\t!PC_ExpectTokenType(source, TT_NUMBER, 0, &token))\n\t\t{\n\t\t\tBotFreeReplyChat(replychatlist);\n\t\t\tFreeSource(source);\n\t\t\treturn NULL;\n\t\t} //end if\n\t\treplychat->priority = token.floatvalue;\n\t\t//read the leading {\n\t\tif (!PC_ExpectTokenString(source, \"{\"))\n\t\t{\n\t\t\tBotFreeReplyChat(replychatlist);\n\t\t\tFreeSource(source);\n\t\t\treturn NULL;\n\t\t} //end if\n\t\treplychat->numchatmessages = 0;\n\t\t//while the trailing } is not found\n\t\twhile(!PC_CheckTokenString(source, \"}\"))\n\t\t{\n\t\t\tif (!BotLoadChatMessage(source, chatmessagestring))\n\t\t\t{\n\t\t\t\tBotFreeReplyChat(replychatlist);\n\t\t\t\tFreeSource(source);\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t\tchatmessage = (bot_chatmessage_t *) GetClearedHunkMemory(sizeof(bot_chatmessage_t) + strlen(chatmessagestring) + 1);\n\t\t\tchatmessage->chatmessage = (char *) chatmessage + sizeof(bot_chatmessage_t);\n\t\t\tstrcpy(chatmessage->chatmessage, chatmessagestring);\n\t\t\tchatmessage->time = -2*CHATMESSAGE_RECENTTIME;\n\t\t\tchatmessage->next = replychat->firstchatmessage;\n\t\t\t//add the chat message to the reply chat\n\t\t\treplychat->firstchatmessage = chatmessage;\n\t\t\treplychat->numchatmessages++;\n\t\t} //end while\n\t} //end while\n\tFreeSource(source);\n\tbotimport.Print(PRT_MESSAGE, \"loaded %s\\n\", filename);\n\t//\n\t//BotDumpReplyChat(replychatlist);\n\tif (bot_developer)\n\t{\n\t\tBotCheckReplyChatIntegrety(replychatlist);\n\t} //end if\n\t//\n\tif (!replychatlist) botimport.Print(PRT_MESSAGE, \"no rchats\\n\");\n\t//\n\treturn replychatlist;\n} //end of the function BotLoadReplyChat\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotDumpInitialChat(bot_chat_t *chat)\n{\n\tbot_chattype_t *t;\n\tbot_chatmessage_t *m;\n\n\tLog_Write(\"{\");\n\tfor (t = chat->types; t; t = t->next)\n\t{\n\t\tLog_Write(\" type \\\"%s\\\"\", t->name);\n\t\tLog_Write(\" {\");\n\t\tLog_Write(\"  numchatmessages = %d\", t->numchatmessages);\n\t\tfor (m = t->firstchatmessage; m; m = m->next)\n\t\t{\n\t\t\tLog_Write(\"  \\\"%s\\\"\", m->chatmessage);\n\t\t} //end for\n\t\tLog_Write(\" }\");\n\t} //end for\n\tLog_Write(\"}\");\n} //end of the function BotDumpInitialChat\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_chat_t *BotLoadInitialChat(char *chatfile, char *chatname)\n{\n\tint pass, foundchat, indent, size;\n\tchar *ptr = NULL;\n\tchar chatmessagestring[MAX_MESSAGE_SIZE];\n\tsource_t *source;\n\ttoken_t token;\n\tbot_chat_t *chat = NULL;\n\tbot_chattype_t *chattype = NULL;\n\tbot_chatmessage_t *chatmessage = NULL;\n#ifdef DEBUG\n\tint starttime;\n\n\tstarttime = Sys_MilliSeconds();\n#endif //DEBUG\n\t//\n\tsize = 0;\n\tfoundchat = qfalse;\n\t//a bot chat is parsed in two phases\n\tfor (pass = 0; pass < 2; pass++)\n\t{\n\t\t//allocate memory\n\t\tif (pass && size) ptr = (char *) GetClearedMemory(size);\n\t\t//load the source file\n\t\tPC_SetBaseFolder(BOTFILESBASEFOLDER);\n\t\tsource = LoadSourceFile(chatfile);\n\t\tif (!source)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"counldn't load %s\\n\", chatfile);\n\t\t\treturn NULL;\n\t\t} //end if\n\t\t//chat structure\n\t\tif (pass)\n\t\t{\n\t\t\tchat = (bot_chat_t *) ptr;\n\t\t\tptr += sizeof(bot_chat_t);\n\t\t} //end if\n\t\tsize = sizeof(bot_chat_t);\n\t\t//\n\t\twhile(PC_ReadToken(source, &token))\n\t\t{\n\t\t\tif (!strcmp(token.string, \"chat\"))\n\t\t\t{\n\t\t\t\tif (!PC_ExpectTokenType(source, TT_STRING, 0, &token))\n\t\t\t\t{\n\t\t\t\t\tFreeSource(source);\n\t\t\t\t\treturn NULL;\n\t\t\t\t} //end if\n\t\t\t\tStripDoubleQuotes(token.string);\n\t\t\t\t//after the chat name we expect a opening brace\n\t\t\t\tif (!PC_ExpectTokenString(source, \"{\"))\n\t\t\t\t{\n\t\t\t\t\tFreeSource(source);\n\t\t\t\t\treturn NULL;\n\t\t\t\t} //end if\n\t\t\t\t//if the chat name is found\n\t\t\t\tif (!Q_stricmp(token.string, chatname))\n\t\t\t\t{\n\t\t\t\t\tfoundchat = qtrue;\n\t\t\t\t\t//read the chat types\n\t\t\t\t\twhile(1)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!PC_ExpectAnyToken(source, &token))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tFreeSource(source);\n\t\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\tif (!strcmp(token.string, \"}\")) break;\n\t\t\t\t\t\tif (strcmp(token.string, \"type\"))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourceError(source, \"expected type found %s\\n\", token.string);\n\t\t\t\t\t\t\tFreeSource(source);\n\t\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t//expect the chat type name\n\t\t\t\t\t\tif (!PC_ExpectTokenType(source, TT_STRING, 0, &token) ||\n\t\t\t\t\t\t\t!PC_ExpectTokenString(source, \"{\"))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tFreeSource(source);\n\t\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\tStripDoubleQuotes(token.string);\n\t\t\t\t\t\tif (pass)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tchattype = (bot_chattype_t *) ptr;\n\t\t\t\t\t\t\tstrncpy(chattype->name, token.string, MAX_CHATTYPE_NAME);\n\t\t\t\t\t\t\tchattype->firstchatmessage = NULL;\n\t\t\t\t\t\t\t//add the chat type to the chat\n\t\t\t\t\t\t\tchattype->next = chat->types;\n\t\t\t\t\t\t\tchat->types = chattype;\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\tptr += sizeof(bot_chattype_t);\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\tsize += sizeof(bot_chattype_t);\n\t\t\t\t\t\t//read the chat messages\n\t\t\t\t\t\twhile(!PC_CheckTokenString(source, \"}\"))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (!BotLoadChatMessage(source, chatmessagestring))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tFreeSource(source);\n\t\t\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\tif (pass)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tchatmessage = (bot_chatmessage_t *) ptr;\n\t\t\t\t\t\t\t\tchatmessage->time = -2*CHATMESSAGE_RECENTTIME;\n\t\t\t\t\t\t\t\t//put the chat message in the list\n\t\t\t\t\t\t\t\tchatmessage->next = chattype->firstchatmessage;\n\t\t\t\t\t\t\t\tchattype->firstchatmessage = chatmessage;\n\t\t\t\t\t\t\t\t//store the chat message\n\t\t\t\t\t\t\t\tptr += sizeof(bot_chatmessage_t);\n\t\t\t\t\t\t\t\tchatmessage->chatmessage = ptr;\n\t\t\t\t\t\t\t\tstrcpy(chatmessage->chatmessage, chatmessagestring);\n\t\t\t\t\t\t\t\tptr += strlen(chatmessagestring) + 1;\n\t\t\t\t\t\t\t\t//the number of chat messages increased\n\t\t\t\t\t\t\t\tchattype->numchatmessages++;\n\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\tsize += sizeof(bot_chatmessage_t) + strlen(chatmessagestring) + 1;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end while\n\t\t\t\t} //end if\n\t\t\t\telse //skip the bot chat\n\t\t\t\t{\n\t\t\t\t\tindent = 1;\n\t\t\t\t\twhile(indent)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!PC_ExpectAnyToken(source, &token))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tFreeSource(source);\n\t\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\tif (!strcmp(token.string, \"{\")) indent++;\n\t\t\t\t\t\telse if (!strcmp(token.string, \"}\")) indent--;\n\t\t\t\t\t} //end while\n\t\t\t\t} //end else\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tSourceError(source, \"unknown definition %s\\n\", token.string);\n\t\t\t\tFreeSource(source);\n\t\t\t\treturn NULL;\n\t\t\t} //end else\n\t\t} //end while\n\t\t//free the source\n\t\tFreeSource(source);\n\t\t//if the requested character is not found\n\t\tif (!foundchat)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"couldn't find chat %s in %s\\n\", chatname, chatfile);\n\t\t\treturn NULL;\n\t\t} //end if\n\t} //end for\n\t//\n\tbotimport.Print(PRT_MESSAGE, \"loaded %s from %s\\n\", chatname, chatfile);\n\t//\n\t//BotDumpInitialChat(chat);\n\tif (bot_developer)\n\t{\n\t\tBotCheckInitialChatIntegrety(chat);\n\t} //end if\n#ifdef DEBUG\n\tbotimport.Print(PRT_MESSAGE, \"initial chats loaded in %d msec\\n\", Sys_MilliSeconds() - starttime);\n#endif //DEBUG\n\t//character was read succesfully\n\treturn chat;\n} //end of the function BotLoadInitialChat\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotFreeChatFile(int chatstate)\n{\n\tbot_chatstate_t *cs;\n\n\tcs = BotChatStateFromHandle(chatstate);\n\tif (!cs) return;\n\tif (cs->chat) FreeMemory(cs->chat);\n\tcs->chat = NULL;\n} //end of the function BotFreeChatFile\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotLoadChatFile(int chatstate, char *chatfile, char *chatname)\n{\n\tbot_chatstate_t *cs;\n\tint n, avail = 0;\n\n\tcs = BotChatStateFromHandle(chatstate);\n\tif (!cs) return BLERR_CANNOTLOADICHAT;\n\tBotFreeChatFile(chatstate);\n\n\tif (!LibVarGetValue(\"bot_reloadcharacters\"))\n\t{\n\t\tavail = -1;\n\t\tfor( n = 0; n < MAX_CLIENTS; n++ ) {\n\t\t\tif( !ichatdata[n] ) {\n\t\t\t\tif( avail == -1 ) {\n\t\t\t\t\tavail = n;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif( strcmp( chatfile, ichatdata[n]->filename ) != 0 ) { \n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif( strcmp( chatname, ichatdata[n]->chatname ) != 0 ) { \n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tcs->chat = ichatdata[n]->chat;\n\t\t//\t\tbotimport.Print( PRT_MESSAGE, \"retained %s from %s\\n\", chatname, chatfile );\n\t\t\treturn BLERR_NOERROR;\n\t\t}\n\n\t\tif( avail == -1 ) {\n\t\t\tbotimport.Print(PRT_FATAL, \"ichatdata table full; couldn't load chat %s from %s\\n\", chatname, chatfile);\n\t\t\treturn BLERR_CANNOTLOADICHAT;\n\t\t}\n\t}\n\n\tcs->chat = BotLoadInitialChat(chatfile, chatname);\n\tif (!cs->chat)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"couldn't load chat %s from %s\\n\", chatname, chatfile);\n\t\treturn BLERR_CANNOTLOADICHAT;\n\t} //end if\n\tif (!LibVarGetValue(\"bot_reloadcharacters\"))\n\t{\n\t\tichatdata[avail] = GetClearedMemory( sizeof(bot_ichatdata_t) );\n\t\tichatdata[avail]->chat = cs->chat;\n\t\tQ_strncpyz( ichatdata[avail]->chatname, chatname, sizeof(ichatdata[avail]->chatname) );\n\t\tQ_strncpyz( ichatdata[avail]->filename, chatfile, sizeof(ichatdata[avail]->filename) );\n\t} //end if\n\n\treturn BLERR_NOERROR;\n} //end of the function BotLoadChatFile\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotExpandChatMessage(char *outmessage, char *message, unsigned long mcontext,\n\t\t\t\t\t\t\t bot_match_t *match, unsigned long vcontext, int reply)\n{\n\tint num, len, i, expansion;\n\tchar *outputbuf, *ptr, *msgptr;\n\tchar temp[MAX_MESSAGE_SIZE];\n\n\texpansion = qfalse;\n\tmsgptr = message;\n\toutputbuf = outmessage;\n\tlen = 0;\n\t//\n\twhile(*msgptr)\n\t{\n\t\tif (*msgptr == ESCAPE_CHAR)\n\t\t{\n\t\t\tmsgptr++;\n\t\t\tswitch(*msgptr)\n\t\t\t{\n\t\t\t\tcase 'v': //variable\n\t\t\t\t{\n\t\t\t\t\tmsgptr++;\n\t\t\t\t\tnum = 0;\n\t\t\t\t\twhile(*msgptr && *msgptr != ESCAPE_CHAR)\n\t\t\t\t\t{\n\t\t\t\t\t\tnum = num * 10 + (*msgptr++) - '0';\n\t\t\t\t\t} //end while\n\t\t\t\t\t//step over the trailing escape char\n\t\t\t\t\tif (*msgptr) msgptr++;\n\t\t\t\t\tif (num > MAX_MATCHVARIABLES)\n\t\t\t\t\t{\n\t\t\t\t\t\tbotimport.Print(PRT_ERROR, \"BotConstructChat: message %s variable %d out of range\\n\", message, num);\n\t\t\t\t\t\treturn qfalse;\n\t\t\t\t\t} //end if\n\t\t\t\t\tif (match->variables[num].offset >= 0)\n\t\t\t\t\t{\n\t\t\t\t\t        assert( match->variables[num].offset >= 0 ); // bk001204\n\t\t\t\t\t\tptr = &match->string[ (int) match->variables[num].offset];\n\t\t\t\t\t\tfor (i = 0; i < match->variables[num].length; i++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttemp[i] = ptr[i];\n\t\t\t\t\t\t} //end for\n\t\t\t\t\t\ttemp[i] = 0;\n\t\t\t\t\t\t//if it's a reply message\n\t\t\t\t\t\tif (reply)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t//replace the reply synonyms in the variables\n\t\t\t\t\t\t\tBotReplaceReplySynonyms(temp, vcontext);\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\telse \n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t//replace synonyms in the variable context\n\t\t\t\t\t\t\tBotReplaceSynonyms(temp, vcontext);\n\t\t\t\t\t\t} //end else\n\t\t\t\t\t\t//\n\t\t\t\t\t\tif (len + strlen(temp) >= MAX_MESSAGE_SIZE)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tbotimport.Print(PRT_ERROR, \"BotConstructChat: message %s too long\\n\", message);\n\t\t\t\t\t\t\treturn qfalse;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\tstrcpy(&outputbuf[len], temp);\n\t\t\t\t\t\tlen += strlen(temp);\n\t\t\t\t\t} //end if\n\t\t\t\t\tbreak;\n\t\t\t\t} //end case\n\t\t\t\tcase 'r': //random\n\t\t\t\t{\n\t\t\t\t\tmsgptr++;\n\t\t\t\t\tfor (i = 0; (*msgptr && *msgptr != ESCAPE_CHAR); i++)\n\t\t\t\t\t{\n\t\t\t\t\t\ttemp[i] = *msgptr++;\n\t\t\t\t\t} //end while\n\t\t\t\t\ttemp[i] = '\\0';\n\t\t\t\t\t//step over the trailing escape char\n\t\t\t\t\tif (*msgptr) msgptr++;\n\t\t\t\t\t//find the random keyword\n\t\t\t\t\tptr = RandomString(temp);\n\t\t\t\t\tif (!ptr)\n\t\t\t\t\t{\n\t\t\t\t\t\tbotimport.Print(PRT_ERROR, \"BotConstructChat: unknown random string %s\\n\", temp);\n\t\t\t\t\t\treturn qfalse;\n\t\t\t\t\t} //end if\n\t\t\t\t\tif (len + strlen(ptr) >= MAX_MESSAGE_SIZE)\n\t\t\t\t\t{\n\t\t\t\t\t\tbotimport.Print(PRT_ERROR, \"BotConstructChat: message \\\"%s\\\" too long\\n\", message);\n\t\t\t\t\t\treturn qfalse;\n\t\t\t\t\t} //end if\n\t\t\t\t\tstrcpy(&outputbuf[len], ptr);\n\t\t\t\t\tlen += strlen(ptr);\n\t\t\t\t\texpansion = qtrue;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end case\n\t\t\t\tdefault:\n\t\t\t\t{\n\t\t\t\t\tbotimport.Print(PRT_FATAL, \"BotConstructChat: message \\\"%s\\\" invalid escape char\\n\", message);\n\t\t\t\t\tbreak;\n\t\t\t\t} //end default\n\t\t\t} //end switch\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\toutputbuf[len++] = *msgptr++;\n\t\t\tif (len >= MAX_MESSAGE_SIZE)\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"BotConstructChat: message \\\"%s\\\" too long\\n\", message);\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t} //end else\n\t} //end while\n\toutputbuf[len] = '\\0';\n\t//replace synonyms weighted in the message context\n\tBotReplaceWeightedSynonyms(outputbuf, mcontext);\n\t//return true if a random was expanded\n\treturn expansion;\n} //end of the function BotExpandChatMessage\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotConstructChatMessage(bot_chatstate_t *chatstate, char *message, unsigned long mcontext,\n\t\t\t\t\t\t\t bot_match_t *match, unsigned long vcontext, int reply)\n{\n\tint i;\n\tchar srcmessage[MAX_MESSAGE_SIZE];\n\n\tstrcpy(srcmessage, message);\n\tfor (i = 0; i < 10; i++)\n\t{\n\t\tif (!BotExpandChatMessage(chatstate->chatmessage, srcmessage, mcontext, match, vcontext, reply))\n\t\t{\n\t\t\tbreak;\n\t\t} //end if\n\t\tstrcpy(srcmessage, chatstate->chatmessage);\n\t} //end for\n\tif (i >= 10)\n\t{\n\t\tbotimport.Print(PRT_WARNING, \"too many expansions in chat message\\n\");\n\t\tbotimport.Print(PRT_WARNING, \"%s\\n\", chatstate->chatmessage);\n\t} //end if\n} //end of the function BotConstructChatMessage\n//===========================================================================\n// randomly chooses one of the chat message of the given type\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nchar *BotChooseInitialChatMessage(bot_chatstate_t *cs, char *type)\n{\n\tint n, numchatmessages;\n\tfloat besttime;\n\tbot_chattype_t *t;\n\tbot_chatmessage_t *m, *bestchatmessage;\n\tbot_chat_t *chat;\n\n\tchat = cs->chat;\n\tfor (t = chat->types; t; t = t->next)\n\t{\n\t\tif (!Q_stricmp(t->name, type))\n\t\t{\n\t\t\tnumchatmessages = 0;\n\t\t\tfor (m = t->firstchatmessage; m; m = m->next)\n\t\t\t{\n\t\t\t\tif (m->time > AAS_Time()) continue;\n\t\t\t\tnumchatmessages++;\n\t\t\t} //end if\n\t\t\t//if all chat messages have been used recently\n\t\t\tif (numchatmessages <= 0)\n\t\t\t{\n\t\t\t\tbesttime = 0;\n\t\t\t\tbestchatmessage = NULL;\n\t\t\t\tfor (m = t->firstchatmessage; m; m = m->next)\n\t\t\t\t{\n\t\t\t\t\tif (!besttime || m->time < besttime)\n\t\t\t\t\t{\n\t\t\t\t\t\tbestchatmessage = m;\n\t\t\t\t\t\tbesttime = m->time;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end for\n\t\t\t\tif (bestchatmessage) return bestchatmessage->chatmessage;\n\t\t\t} //end if\n\t\t\telse //choose a chat message randomly\n\t\t\t{\n\t\t\t\tn = random() * numchatmessages;\n\t\t\t\tfor (m = t->firstchatmessage; m; m = m->next)\n\t\t\t\t{\n\t\t\t\t\tif (m->time > AAS_Time()) continue;\n\t\t\t\t\tif (--n < 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tm->time = AAS_Time() + CHATMESSAGE_RECENTTIME;\n\t\t\t\t\t\treturn m->chatmessage;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end for\n\t\t\t} //end else\n\t\t\treturn NULL;\n\t\t} //end if\n\t} //end for\n\treturn NULL;\n} //end of the function BotChooseInitialChatMessage\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotNumInitialChats(int chatstate, char *type)\n{\n\tbot_chatstate_t *cs;\n\tbot_chattype_t *t;\n\n\tcs = BotChatStateFromHandle(chatstate);\n\tif (!cs) return 0;\n\n\tfor (t = cs->chat->types; t; t = t->next)\n\t{\n\t\tif (!Q_stricmp(t->name, type))\n\t\t{\n\t\t\tif (LibVarGetValue(\"bot_testichat\")) {\n\t\t\t\tbotimport.Print(PRT_MESSAGE, \"%s has %d chat lines\\n\", type, t->numchatmessages);\n\t\t\t\tbotimport.Print(PRT_MESSAGE, \"-------------------\\n\");\n\t\t\t}\n\t\t\treturn t->numchatmessages;\n\t\t} //end if\n\t} //end for\n\treturn 0;\n} //end of the function BotNumInitialChats\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotInitialChat(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7)\n{\n\tchar *message;\n\tint index;\n\tbot_match_t match;\n\tbot_chatstate_t *cs;\n\n\tcs = BotChatStateFromHandle(chatstate);\n\tif (!cs) return;\n\t//if no chat file is loaded\n\tif (!cs->chat) return;\n\t//choose a chat message randomly of the given type\n\tmessage = BotChooseInitialChatMessage(cs, type);\n\t//if there's no message of the given type\n\tif (!message)\n\t{\n#ifdef DEBUG\n\t\tbotimport.Print(PRT_MESSAGE, \"no chat messages of type %s\\n\", type);\n#endif //DEBUG\n\t\treturn;\n\t} //end if\n\t//\n\tCom_Memset(&match, 0, sizeof(match));\n\tindex = 0;\n\tif( var0 ) {\n\t\tstrcat(match.string, var0);\n\t\tmatch.variables[0].offset = index;\n\t\tmatch.variables[0].length = strlen(var0);\n\t\tindex += strlen(var0);\n\t}\n\tif( var1 ) {\n\t\tstrcat(match.string, var1);\n\t\tmatch.variables[1].offset = index;\n\t\tmatch.variables[1].length = strlen(var1);\n\t\tindex += strlen(var1);\n\t}\n\tif( var2 ) {\n\t\tstrcat(match.string, var2);\n\t\tmatch.variables[2].offset = index;\n\t\tmatch.variables[2].length = strlen(var2);\n\t\tindex += strlen(var2);\n\t}\n\tif( var3 ) {\n\t\tstrcat(match.string, var3);\n\t\tmatch.variables[3].offset = index;\n\t\tmatch.variables[3].length = strlen(var3);\n\t\tindex += strlen(var3);\n\t}\n\tif( var4 ) {\n\t\tstrcat(match.string, var4);\n\t\tmatch.variables[4].offset = index;\n\t\tmatch.variables[4].length = strlen(var4);\n\t\tindex += strlen(var4);\n\t}\n\tif( var5 ) {\n\t\tstrcat(match.string, var5);\n\t\tmatch.variables[5].offset = index;\n\t\tmatch.variables[5].length = strlen(var5);\n\t\tindex += strlen(var5);\n\t}\n\tif( var6 ) {\n\t\tstrcat(match.string, var6);\n\t\tmatch.variables[6].offset = index;\n\t\tmatch.variables[6].length = strlen(var6);\n\t\tindex += strlen(var6);\n\t}\n\tif( var7 ) {\n\t\tstrcat(match.string, var7);\n\t\tmatch.variables[7].offset = index;\n\t\tmatch.variables[7].length = strlen(var7);\n\t\tindex += strlen(var7);\n\t}\n \t//\n\tBotConstructChatMessage(cs, message, mcontext, &match, 0, qfalse);\n} //end of the function BotInitialChat\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotPrintReplyChatKeys(bot_replychat_t *replychat)\n{\n\tbot_replychatkey_t *key;\n\tbot_matchpiece_t *mp;\n\n\tbotimport.Print(PRT_MESSAGE, \"[\");\n\tfor (key = replychat->keys; key; key = key->next)\n\t{\n\t\tif (key->flags & RCKFL_AND) botimport.Print(PRT_MESSAGE, \"&\");\n\t\telse if (key->flags & RCKFL_NOT) botimport.Print(PRT_MESSAGE, \"!\");\n\t\t//\n\t\tif (key->flags & RCKFL_NAME) botimport.Print(PRT_MESSAGE, \"name\");\n\t\telse if (key->flags & RCKFL_GENDERFEMALE) botimport.Print(PRT_MESSAGE, \"female\");\n\t\telse if (key->flags & RCKFL_GENDERMALE) botimport.Print(PRT_MESSAGE, \"male\");\n\t\telse if (key->flags & RCKFL_GENDERLESS) botimport.Print(PRT_MESSAGE, \"it\");\n\t\telse if (key->flags & RCKFL_VARIABLES)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"(\");\n\t\t\tfor (mp = key->match; mp; mp = mp->next)\n\t\t\t{\n\t\t\t\tif (mp->type == MT_STRING) botimport.Print(PRT_MESSAGE, \"\\\"%s\\\"\", mp->firststring->string);\n\t\t\t\telse botimport.Print(PRT_MESSAGE, \"%d\", mp->variable);\n\t\t\t\tif (mp->next) botimport.Print(PRT_MESSAGE, \", \");\n\t\t\t} //end for\n\t\t\tbotimport.Print(PRT_MESSAGE, \")\");\n\t\t} //end if\n\t\telse if (key->flags & RCKFL_STRING)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"\\\"%s\\\"\", key->string);\n\t\t} //end if\n\t\tif (key->next) botimport.Print(PRT_MESSAGE, \", \");\n\t\telse botimport.Print(PRT_MESSAGE, \"] = %1.0f\\n\", replychat->priority);\n\t} //end for\n\tbotimport.Print(PRT_MESSAGE, \"{\\n\");\n} //end of the function BotPrintReplyChatKeys\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotReplyChat(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7)\n{\n\tbot_replychat_t *rchat, *bestrchat;\n\tbot_replychatkey_t *key;\n\tbot_chatmessage_t *m, *bestchatmessage;\n\tbot_match_t match, bestmatch;\n\tint bestpriority, num, found, res, numchatmessages, index;\n\tbot_chatstate_t *cs;\n\n\tcs = BotChatStateFromHandle(chatstate);\n\tif (!cs) return qfalse;\n\tCom_Memset(&match, 0, sizeof(bot_match_t));\n\tstrcpy(match.string, message);\n\tbestpriority = -1;\n\tbestchatmessage = NULL;\n\tbestrchat = NULL;\n\t//go through all the reply chats\n\tfor (rchat = replychats; rchat; rchat = rchat->next)\n\t{\n\t\tfound = qfalse;\n\t\tfor (key = rchat->keys; key; key = key->next)\n\t\t{\n\t\t\tres = qfalse;\n\t\t\t//get the match result\n\t\t\tif (key->flags & RCKFL_NAME) res = (StringContains(message, cs->name, qfalse) != -1);\n\t\t\telse if (key->flags & RCKFL_BOTNAMES) res = (StringContains(key->string, cs->name, qfalse) != -1);\n\t\t\telse if (key->flags & RCKFL_GENDERFEMALE) res = (cs->gender == CHAT_GENDERFEMALE);\n\t\t\telse if (key->flags & RCKFL_GENDERMALE) res = (cs->gender == CHAT_GENDERMALE);\n\t\t\telse if (key->flags & RCKFL_GENDERLESS) res = (cs->gender == CHAT_GENDERLESS);\n\t\t\telse if (key->flags & RCKFL_VARIABLES) res = StringsMatch(key->match, &match);\n\t\t\telse if (key->flags & RCKFL_STRING) res = (StringContainsWord(message, key->string, qfalse) != NULL);\n\t\t\t//if the key must be present\n\t\t\tif (key->flags & RCKFL_AND)\n\t\t\t{\n\t\t\t\tif (!res)\n\t\t\t\t{\n\t\t\t\t\tfound = qfalse;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t} //end else if\n\t\t\t//if the key must be absent\n\t\t\telse if (key->flags & RCKFL_NOT)\n\t\t\t{\n\t\t\t\tif (res)\n\t\t\t\t{\n\t\t\t\t\tfound = qfalse;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t\telse if (res)\n\t\t\t{\n\t\t\t\tfound = qtrue;\n\t\t\t} //end else\n\t\t} //end for\n\t\t//\n\t\tif (found)\n\t\t{\n\t\t\tif (rchat->priority > bestpriority)\n\t\t\t{\n\t\t\t\tnumchatmessages = 0;\n\t\t\t\tfor (m = rchat->firstchatmessage; m; m = m->next)\n\t\t\t\t{\n\t\t\t\t\tif (m->time > AAS_Time()) continue;\n\t\t\t\t\tnumchatmessages++;\n\t\t\t\t} //end if\n\t\t\t\tnum = random() * numchatmessages;\n\t\t\t\tfor (m = rchat->firstchatmessage; m; m = m->next)\n\t\t\t\t{\n\t\t\t\t\tif (--num < 0) break;\n\t\t\t\t\tif (m->time > AAS_Time()) continue;\n\t\t\t\t} //end for\n\t\t\t\t//if the reply chat has a message\n\t\t\t\tif (m)\n\t\t\t\t{\n\t\t\t\t\tCom_Memcpy(&bestmatch, &match, sizeof(bot_match_t));\n\t\t\t\t\tbestchatmessage = m;\n\t\t\t\t\tbestrchat = rchat;\n\t\t\t\t\tbestpriority = rchat->priority;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n\tif (bestchatmessage)\n\t{\n\t\tindex = strlen(bestmatch.string);\n\t\tif( var0 ) {\n\t\t\tstrcat(bestmatch.string, var0);\n\t\t\tbestmatch.variables[0].offset = index;\n\t\t\tbestmatch.variables[0].length = strlen(var0);\n\t\t\tindex += strlen(var0);\n\t\t}\n\t\tif( var1 ) {\n\t\t\tstrcat(bestmatch.string, var1);\n\t\t\tbestmatch.variables[1].offset = index;\n\t\t\tbestmatch.variables[1].length = strlen(var1);\n\t\t\tindex += strlen(var1);\n\t\t}\n\t\tif( var2 ) {\n\t\t\tstrcat(bestmatch.string, var2);\n\t\t\tbestmatch.variables[2].offset = index;\n\t\t\tbestmatch.variables[2].length = strlen(var2);\n\t\t\tindex += strlen(var2);\n\t\t}\n\t\tif( var3 ) {\n\t\t\tstrcat(bestmatch.string, var3);\n\t\t\tbestmatch.variables[3].offset = index;\n\t\t\tbestmatch.variables[3].length = strlen(var3);\n\t\t\tindex += strlen(var3);\n\t\t}\n\t\tif( var4 ) {\n\t\t\tstrcat(bestmatch.string, var4);\n\t\t\tbestmatch.variables[4].offset = index;\n\t\t\tbestmatch.variables[4].length = strlen(var4);\n\t\t\tindex += strlen(var4);\n\t\t}\n\t\tif( var5 ) {\n\t\t\tstrcat(bestmatch.string, var5);\n\t\t\tbestmatch.variables[5].offset = index;\n\t\t\tbestmatch.variables[5].length = strlen(var5);\n\t\t\tindex += strlen(var5);\n\t\t}\n\t\tif( var6 ) {\n\t\t\tstrcat(bestmatch.string, var6);\n\t\t\tbestmatch.variables[6].offset = index;\n\t\t\tbestmatch.variables[6].length = strlen(var6);\n\t\t\tindex += strlen(var6);\n\t\t}\n\t\tif( var7 ) {\n\t\t\tstrcat(bestmatch.string, var7);\n\t\t\tbestmatch.variables[7].offset = index;\n\t\t\tbestmatch.variables[7].length = strlen(var7);\n\t\t\tindex += strlen(var7);\n\t\t}\n\t\tif (LibVarGetValue(\"bot_testrchat\"))\n\t\t{\n\t\t\tfor (m = bestrchat->firstchatmessage; m; m = m->next)\n\t\t\t{\n\t\t\t\tBotConstructChatMessage(cs, m->chatmessage, mcontext, &bestmatch, vcontext, qtrue);\n\t\t\t\tBotRemoveTildes(cs->chatmessage);\n\t\t\t\tbotimport.Print(PRT_MESSAGE, \"%s\\n\", cs->chatmessage);\n\t\t\t} //end if\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tbestchatmessage->time = AAS_Time() + CHATMESSAGE_RECENTTIME;\n\t\t\tBotConstructChatMessage(cs, bestchatmessage->chatmessage, mcontext, &bestmatch, vcontext, qtrue);\n\t\t} //end else\n\t\treturn qtrue;\n\t} //end if\n\treturn qfalse;\n} //end of the function BotReplyChat\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotChatLength(int chatstate)\n{\n\tbot_chatstate_t *cs;\n\n\tcs = BotChatStateFromHandle(chatstate);\n\tif (!cs) return 0;\n\treturn strlen(cs->chatmessage);\n} //end of the function BotChatLength\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotEnterChat(int chatstate, int clientto, int sendto)\n{\n\tbot_chatstate_t *cs;\n\n\tcs = BotChatStateFromHandle(chatstate);\n\tif (!cs) return;\n\n\tif (strlen(cs->chatmessage))\n\t{\n\t\tBotRemoveTildes(cs->chatmessage);\n\t\tif (LibVarGetValue(\"bot_testichat\")) {\n\t\t\tbotimport.Print(PRT_MESSAGE, \"%s\\n\", cs->chatmessage);\n\t\t}\n\t\telse {\n\t\t\tswitch(sendto) {\n\t\t\t\tcase CHAT_TEAM:\n\t\t\t\t\tEA_Command(cs->client, va(\"say_team %s\", cs->chatmessage));\n\t\t\t\t\tbreak;\n\t\t\t\tcase CHAT_TELL:\n\t\t\t\t\tEA_Command(cs->client, va(\"tell %d %s\", clientto, cs->chatmessage));\n\t\t\t\t\tbreak;\n\t\t\t\tdefault: //CHAT_ALL\n\t\t\t\t\tEA_Command(cs->client, va(\"say %s\", cs->chatmessage));\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t//clear the chat message from the state\n\t\tstrcpy(cs->chatmessage, \"\");\n\t} //end if\n} //end of the function BotEnterChat\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotGetChatMessage(int chatstate, char *buf, int size)\n{\n\tbot_chatstate_t *cs;\n\n\tcs = BotChatStateFromHandle(chatstate);\n\tif (!cs) return;\n\n\tBotRemoveTildes(cs->chatmessage);\n\tstrncpy(buf, cs->chatmessage, size-1);\n\tbuf[size-1] = '\\0';\n\t//clear the chat message from the state\n\tstrcpy(cs->chatmessage, \"\");\n} //end of the function BotGetChatMessage\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotSetChatGender(int chatstate, int gender)\n{\n\tbot_chatstate_t *cs;\n\n\tcs = BotChatStateFromHandle(chatstate);\n\tif (!cs) return;\n\tswitch(gender)\n\t{\n\t\tcase CHAT_GENDERFEMALE: cs->gender = CHAT_GENDERFEMALE; break;\n\t\tcase CHAT_GENDERMALE: cs->gender = CHAT_GENDERMALE; break;\n\t\tdefault: cs->gender = CHAT_GENDERLESS; break;\n\t} //end switch\n} //end of the function BotSetChatGender\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotSetChatName(int chatstate, char *name, int client)\n{\n\tbot_chatstate_t *cs;\n\n\tcs = BotChatStateFromHandle(chatstate);\n\tif (!cs) return;\n\tcs->client = client;\n\tCom_Memset(cs->name, 0, sizeof(cs->name));\n\tstrncpy(cs->name, name, sizeof(cs->name));\n\tcs->name[sizeof(cs->name)-1] = '\\0';\n} //end of the function BotSetChatName\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotResetChatAI(void)\n{\n\tbot_replychat_t *rchat;\n\tbot_chatmessage_t *m;\n\n\tfor (rchat = replychats; rchat; rchat = rchat->next)\n\t{\n\t\tfor (m = rchat->firstchatmessage; m; m = m->next)\n\t\t{\n\t\t\tm->time = 0;\n\t\t} //end for\n\t} //end for\n} //end of the function BotResetChatAI\n//========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//========================================================================\nint BotAllocChatState(void)\n{\n\tint i;\n\n\tfor (i = 1; i <= MAX_CLIENTS; i++)\n\t{\n\t\tif (!botchatstates[i])\n\t\t{\n\t\t\tbotchatstates[i] = GetClearedMemory(sizeof(bot_chatstate_t));\n\t\t\treturn i;\n\t\t} //end if\n\t} //end for\n\treturn 0;\n} //end of the function BotAllocChatState\n//========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//========================================================================\nvoid BotFreeChatState(int handle)\n{\n\tbot_chatstate_t *cs;\n\tbot_consolemessage_t m;\n\tint h;\n\n\tif (handle <= 0 || handle > MAX_CLIENTS)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"chat state handle %d out of range\\n\", handle);\n\t\treturn;\n\t} //end if\n\tif (!botchatstates[handle])\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"invalid chat state %d\\n\", handle);\n\t\treturn;\n\t} //end if\n\tcs = botchatstates[handle];\n\tif (LibVarGetValue(\"bot_reloadcharacters\"))\n\t{\n\t\tBotFreeChatFile(handle);\n\t} //end if\n\t//free all the console messages left in the chat state\n\tfor (h = BotNextConsoleMessage(handle, &m); h; h = BotNextConsoleMessage(handle, &m))\n\t{\n\t\t//remove the console message\n\t\tBotRemoveConsoleMessage(handle, h);\n\t} //end for\n\tFreeMemory(botchatstates[handle]);\n\tbotchatstates[handle] = NULL;\n} //end of the function BotFreeChatState\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotSetupChatAI(void)\n{\n\tchar *file;\n\n#ifdef DEBUG\n\tint starttime = Sys_MilliSeconds();\n#endif //DEBUG\n\n\tfile = LibVarString(\"synfile\", \"syn.c\");\n\tsynonyms = BotLoadSynonyms(file);\n\tfile = LibVarString(\"rndfile\", \"rnd.c\");\n\trandomstrings = BotLoadRandomStrings(file);\n\tfile = LibVarString(\"matchfile\", \"match.c\");\n\tmatchtemplates = BotLoadMatchTemplates(file);\n\t//\n\tif (!LibVarValue(\"nochat\", \"0\"))\n\t{\n\t\tfile = LibVarString(\"rchatfile\", \"rchat.c\");\n\t\treplychats = BotLoadReplyChat(file);\n\t} //end if\n\n\tInitConsoleMessageHeap();\n\n#ifdef DEBUG\n\tbotimport.Print(PRT_MESSAGE, \"setup chat AI %d msec\\n\", Sys_MilliSeconds() - starttime);\n#endif //DEBUG\n\treturn BLERR_NOERROR;\n} //end of the function BotSetupChatAI\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotShutdownChatAI(void)\n{\n\tint i;\n\n\t//free all remaining chat states\n\tfor(i = 0; i < MAX_CLIENTS; i++)\n\t{\n\t\tif (botchatstates[i])\n\t\t{\n\t\t\tBotFreeChatState(i);\n\t\t} //end if\n\t} //end for\n\t//free all cached chats\n\tfor(i = 0; i < MAX_CLIENTS; i++)\n\t{\n\t\tif (ichatdata[i])\n\t\t{\n\t\t\tFreeMemory(ichatdata[i]->chat);\n\t\t\tFreeMemory(ichatdata[i]);\n\t\t\tichatdata[i] = NULL;\n\t\t} //end if\n\t} //end for\n\tif (consolemessageheap) FreeMemory(consolemessageheap);\n\tconsolemessageheap = NULL;\n\tif (matchtemplates) BotFreeMatchTemplates(matchtemplates);\n\tmatchtemplates = NULL;\n\tif (randomstrings) FreeMemory(randomstrings);\n\trandomstrings = NULL;\n\tif (synonyms) FreeMemory(synonyms);\n\tsynonyms = NULL;\n\tif (replychats) BotFreeReplyChat(replychats);\n\treplychats = NULL;\n} //end of the function BotShutdownChatAI\n"
  },
  {
    "path": "code/botlib/be_ai_gen.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_ai_gen.c\n *\n * desc:\t\tgenetic selection\n *\n * $Archive: /MissionPack/code/botlib/be_ai_gen.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_memory.h\"\n#include \"l_log.h\"\n#include \"l_utils.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#include \"aasfile.h\"\n#include \"../game/botlib.h\"\n#include \"../game/be_aas.h\"\n#include \"be_aas_funcs.h\"\n#include \"be_interface.h\"\n#include \"../game/be_ai_gen.h\"\n\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint GeneticSelection(int numranks, float *rankings)\n{\n\tfloat sum, select;\n\tint i, index;\n\n\tsum = 0;\n\tfor (i = 0; i < numranks; i++)\n\t{\n\t\tif (rankings[i] < 0) continue;\n\t\tsum += rankings[i];\n\t} //end for\n\tif (sum > 0)\n\t{\n\t\t//select a bot where the ones with the higest rankings have\n\t\t//the highest chance of being selected\n\t\tselect = random() * sum;\n\t\tfor (i = 0; i < numranks; i++)\n\t\t{\n\t\t\tif (rankings[i] < 0) continue;\n\t\t\tsum -= rankings[i];\n\t\t\tif (sum <= 0) return i;\n\t\t} //end for\n\t} //end if\n\t//select a bot randomly\n\tindex = random() * numranks;\n\tfor (i = 0; i < numranks; i++)\n\t{\n\t\tif (rankings[index] >= 0) return index;\n\t\tindex = (index + 1) % numranks;\n\t} //end for\n\treturn 0;\n} //end of the function GeneticSelection\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint GeneticParentsAndChildSelection(int numranks, float *ranks, int *parent1, int *parent2, int *child)\n{\n\tfloat rankings[256], max;\n\tint i;\n\n\tif (numranks > 256)\n\t{\n\t\tbotimport.Print(PRT_WARNING, \"GeneticParentsAndChildSelection: too many bots\\n\");\n\t\t*parent1 = *parent2 = *child = 0;\n\t\treturn qfalse;\n\t} //end if\n\tfor (max = 0, i = 0; i < numranks; i++)\n\t{\n\t\tif (ranks[i] < 0) continue;\n\t\tmax++;\n\t} //end for\n\tif (max < 3)\n\t{\n\t\tbotimport.Print(PRT_WARNING, \"GeneticParentsAndChildSelection: too few valid bots\\n\");\n\t\t*parent1 = *parent2 = *child = 0;\n\t\treturn qfalse;\n\t} //end if\n\tCom_Memcpy(rankings, ranks, sizeof(float) * numranks);\n\t//select first parent\n\t*parent1 = GeneticSelection(numranks, rankings);\n\trankings[*parent1] = -1;\n\t//select second parent\n\t*parent2 = GeneticSelection(numranks, rankings);\n\trankings[*parent2] = -1;\n\t//reverse the rankings\n\tmax = 0;\n\tfor (i = 0; i < numranks; i++)\n\t{\n\t\tif (rankings[i] < 0) continue;\n\t\tif (rankings[i] > max) max = rankings[i];\n\t} //end for\n\tfor (i = 0; i < numranks; i++)\n\t{\n\t\tif (rankings[i] < 0) continue;\n\t\trankings[i] = max - rankings[i];\n\t} //end for\n\t//select child\n\t*child = GeneticSelection(numranks, rankings);\n\treturn qtrue;\n} //end of the function GeneticParentsAndChildSelection\n"
  },
  {
    "path": "code/botlib/be_ai_goal.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_ai_goal.c\n *\n * desc:\t\tgoal AI\n *\n * $Archive: /MissionPack/code/botlib/be_ai_goal.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_utils.h\"\n#include \"l_libvar.h\"\n#include \"l_memory.h\"\n#include \"l_log.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#include \"aasfile.h\"\n#include \"../game/botlib.h\"\n#include \"../game/be_aas.h\"\n#include \"be_aas_funcs.h\"\n#include \"be_interface.h\"\n#include \"be_ai_weight.h\"\n#include \"../game/be_ai_goal.h\"\n#include \"../game/be_ai_move.h\"\n\n//#define DEBUG_AI_GOAL\n#ifdef RANDOMIZE\n#define UNDECIDEDFUZZY\n#endif //RANDOMIZE\n#define DROPPEDWEIGHT\n//minimum avoid goal time\n#define AVOID_MINIMUM_TIME\t\t10\n//default avoid goal time\n#define AVOID_DEFAULT_TIME\t\t30\n//avoid dropped goal time\n#define AVOID_DROPPED_TIME\t\t10\n//\n#define TRAVELTIME_SCALE\t\t0.01\n//item flags\n#define IFL_NOTFREE\t\t\t\t1\t\t//not in free for all\n#define IFL_NOTTEAM\t\t\t\t2\t\t//not in team play\n#define IFL_NOTSINGLE\t\t\t4\t\t//not in single player\n#define IFL_NOTBOT\t\t\t\t8\t\t//bot should never go for this\n#define IFL_ROAM\t\t\t\t16\t\t//bot roam goal\n\n//location in the map \"target_location\"\ntypedef struct maplocation_s\n{\n\tvec3_t origin;\n\tint areanum;\n\tchar name[MAX_EPAIRKEY];\n\tstruct maplocation_s *next;\n} maplocation_t;\n\n//camp spots \"info_camp\"\ntypedef struct campspot_s\n{\n\tvec3_t origin;\n\tint areanum;\n\tchar name[MAX_EPAIRKEY];\n\tfloat range;\n\tfloat weight;\n\tfloat wait;\n\tfloat random;\n\tstruct campspot_s *next;\n} campspot_t;\n\n//FIXME: these are game specific\ntypedef enum {\n\tGT_FFA,\t\t\t\t// free for all\n\tGT_TOURNAMENT,\t\t// one on one tournament\n\tGT_SINGLE_PLAYER,\t// single player tournament\n\n\t//-- team games go after this --\n\n\tGT_TEAM,\t\t\t// team deathmatch\n\tGT_CTF,\t\t\t\t// capture the flag\n#ifdef MISSIONPACK\n\tGT_1FCTF,\n\tGT_OBELISK,\n\tGT_HARVESTER,\n#endif\n\tGT_MAX_GAME_TYPE\n} gametype_t;\n\ntypedef struct levelitem_s\n{\n\tint number;\t\t\t\t\t\t\t//number of the level item\n\tint iteminfo;\t\t\t\t\t\t//index into the item info\n\tint flags;\t\t\t\t\t\t\t//item flags\n\tfloat weight;\t\t\t\t\t\t//fixed roam weight\n\tvec3_t origin;\t\t\t\t\t\t//origin of the item\n\tint goalareanum;\t\t\t\t\t//area the item is in\n\tvec3_t goalorigin;\t\t\t\t\t//goal origin within the area\n\tint entitynum;\t\t\t\t\t\t//entity number\n\tfloat timeout;\t\t\t\t\t\t//item is removed after this time\n\tstruct levelitem_s *prev, *next;\n} levelitem_t;\n\ntypedef struct iteminfo_s\n{\n\tchar classname[32];\t\t\t\t\t//classname of the item\n\tchar name[MAX_STRINGFIELD];\t\t\t//name of the item\n\tchar model[MAX_STRINGFIELD];\t\t//model of the item\n\tint modelindex;\t\t\t\t\t\t//model index\n\tint type;\t\t\t\t\t\t\t//item type\n\tint index;\t\t\t\t\t\t\t//index in the inventory\n\tfloat respawntime;\t\t\t\t\t//respawn time\n\tvec3_t mins;\t\t\t\t\t\t//mins of the item\n\tvec3_t maxs;\t\t\t\t\t\t//maxs of the item\n\tint number;\t\t\t\t\t\t\t//number of the item info\n} iteminfo_t;\n\n#define ITEMINFO_OFS(x)\t(int)&(((iteminfo_t *)0)->x)\n\nfielddef_t iteminfo_fields[] =\n{\n{\"name\", ITEMINFO_OFS(name), FT_STRING},\n{\"model\", ITEMINFO_OFS(model), FT_STRING},\n{\"modelindex\", ITEMINFO_OFS(modelindex), FT_INT},\n{\"type\", ITEMINFO_OFS(type), FT_INT},\n{\"index\", ITEMINFO_OFS(index), FT_INT},\n{\"respawntime\", ITEMINFO_OFS(respawntime), FT_FLOAT},\n{\"mins\", ITEMINFO_OFS(mins), FT_FLOAT|FT_ARRAY, 3},\n{\"maxs\", ITEMINFO_OFS(maxs), FT_FLOAT|FT_ARRAY, 3},\n{0, 0, 0}\n};\n\nstructdef_t iteminfo_struct =\n{\n\tsizeof(iteminfo_t), iteminfo_fields\n};\n\ntypedef struct itemconfig_s\n{\n\tint numiteminfo;\n\titeminfo_t *iteminfo;\n} itemconfig_t;\n\n//goal state\ntypedef struct bot_goalstate_s\n{\n\tstruct weightconfig_s *itemweightconfig;\t//weight config\n\tint *itemweightindex;\t\t\t\t\t\t//index from item to weight\n\t//\n\tint client;\t\t\t\t\t\t\t\t\t//client using this goal state\n\tint lastreachabilityarea;\t\t\t\t\t//last area with reachabilities the bot was in\n\t//\n\tbot_goal_t goalstack[MAX_GOALSTACK];\t\t//goal stack\n\tint goalstacktop;\t\t\t\t\t\t\t//the top of the goal stack\n\t//\n\tint avoidgoals[MAX_AVOIDGOALS];\t\t\t\t//goals to avoid\n\tfloat avoidgoaltimes[MAX_AVOIDGOALS];\t\t//times to avoid the goals\n} bot_goalstate_t;\n\nbot_goalstate_t *botgoalstates[MAX_CLIENTS + 1]; // bk001206 - FIXME: init?\n//item configuration\nitemconfig_t *itemconfig = NULL; // bk001206 - init\n//level items\nlevelitem_t *levelitemheap = NULL; // bk001206 - init\nlevelitem_t *freelevelitems = NULL; // bk001206 - init\nlevelitem_t *levelitems = NULL; // bk001206 - init\nint numlevelitems = 0;\n//map locations\nmaplocation_t *maplocations = NULL; // bk001206 - init\n//camp spots\ncampspot_t *campspots = NULL; // bk001206 - init\n//the game type\nint g_gametype = 0; // bk001206 - init\n//additional dropped item weight\nlibvar_t *droppedweight = NULL; // bk001206 - init\n\n//========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//========================================================================\nbot_goalstate_t *BotGoalStateFromHandle(int handle)\n{\n\tif (handle <= 0 || handle > MAX_CLIENTS)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"goal state handle %d out of range\\n\", handle);\n\t\treturn NULL;\n\t} //end if\n\tif (!botgoalstates[handle])\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"invalid goal state %d\\n\", handle);\n\t\treturn NULL;\n\t} //end if\n\treturn botgoalstates[handle];\n} //end of the function BotGoalStateFromHandle\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child)\n{\n\tbot_goalstate_t *p1, *p2, *c;\n\n\tp1 = BotGoalStateFromHandle(parent1);\n\tp2 = BotGoalStateFromHandle(parent2);\n\tc = BotGoalStateFromHandle(child);\n\n\tInterbreedWeightConfigs(p1->itemweightconfig, p2->itemweightconfig,\n\t\t\t\t\t\t\t\t\tc->itemweightconfig);\n} //end of the function BotInterbreedingGoalFuzzyLogic\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotSaveGoalFuzzyLogic(int goalstate, char *filename)\n{\n\tbot_goalstate_t *gs;\n\n\tgs = BotGoalStateFromHandle(goalstate);\n\n\t//WriteWeightConfig(filename, gs->itemweightconfig);\n} //end of the function BotSaveGoalFuzzyLogic\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotMutateGoalFuzzyLogic(int goalstate, float range)\n{\n\tbot_goalstate_t *gs;\n\n\tgs = BotGoalStateFromHandle(goalstate);\n\n\tEvolveWeightConfig(gs->itemweightconfig);\n} //end of the function BotMutateGoalFuzzyLogic\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nitemconfig_t *LoadItemConfig(char *filename)\n{\n\tint max_iteminfo;\n\ttoken_t token;\n\tchar path[MAX_PATH];\n\tsource_t *source;\n\titemconfig_t *ic;\n\titeminfo_t *ii;\n\n\tmax_iteminfo = (int) LibVarValue(\"max_iteminfo\", \"256\");\n\tif (max_iteminfo < 0)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"max_iteminfo = %d\\n\", max_iteminfo);\n\t\tmax_iteminfo = 256;\n\t\tLibVarSet( \"max_iteminfo\", \"256\" );\n\t}\n\n\tstrncpy( path, filename, MAX_PATH );\n\tPC_SetBaseFolder(BOTFILESBASEFOLDER);\n\tsource = LoadSourceFile( path );\n\tif( !source ) {\n\t\tbotimport.Print( PRT_ERROR, \"counldn't load %s\\n\", path );\n\t\treturn NULL;\n\t} //end if\n\t//initialize item config\n\tic = (itemconfig_t *) GetClearedHunkMemory(sizeof(itemconfig_t) +\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmax_iteminfo * sizeof(iteminfo_t));\n\tic->iteminfo = (iteminfo_t *) ((char *) ic + sizeof(itemconfig_t));\n\tic->numiteminfo = 0;\n\t//parse the item config file\n\twhile(PC_ReadToken(source, &token))\n\t{\n\t\tif (!strcmp(token.string, \"iteminfo\"))\n\t\t{\n\t\t\tif (ic->numiteminfo >= max_iteminfo)\n\t\t\t{\n\t\t\t\tSourceError(source, \"more than %d item info defined\\n\", max_iteminfo);\n\t\t\t\tFreeMemory(ic);\n\t\t\t\tFreeSource(source);\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t\tii = &ic->iteminfo[ic->numiteminfo];\n\t\t\tCom_Memset(ii, 0, sizeof(iteminfo_t));\n\t\t\tif (!PC_ExpectTokenType(source, TT_STRING, 0, &token))\n\t\t\t{\n\t\t\t\tFreeMemory(ic);\n\t\t\t\tFreeMemory(source);\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t\tStripDoubleQuotes(token.string);\n\t\t\tstrncpy(ii->classname, token.string, sizeof(ii->classname)-1);\n\t\t\tif (!ReadStructure(source, &iteminfo_struct, (char *) ii))\n\t\t\t{\n\t\t\t\tFreeMemory(ic);\n\t\t\t\tFreeSource(source);\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t\tii->number = ic->numiteminfo;\n\t\t\tic->numiteminfo++;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tSourceError(source, \"unknown definition %s\\n\", token.string);\n\t\t\tFreeMemory(ic);\n\t\t\tFreeSource(source);\n\t\t\treturn NULL;\n\t\t} //end else\n\t} //end while\n\tFreeSource(source);\n\t//\n\tif (!ic->numiteminfo) botimport.Print(PRT_WARNING, \"no item info loaded\\n\");\n\tbotimport.Print(PRT_MESSAGE, \"loaded %s\\n\", path);\n\treturn ic;\n} //end of the function LoadItemConfig\n//===========================================================================\n// index to find the weight function of an iteminfo\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint *ItemWeightIndex(weightconfig_t *iwc, itemconfig_t *ic)\n{\n\tint *index, i;\n\n\t//initialize item weight index\n\tindex = (int *) GetClearedMemory(sizeof(int) * ic->numiteminfo);\n\n\tfor (i = 0; i < ic->numiteminfo; i++)\n\t{\n\t\tindex[i] = FindFuzzyWeight(iwc, ic->iteminfo[i].classname);\n\t\tif (index[i] < 0)\n\t\t{\n\t\t\tLog_Write(\"item info %d \\\"%s\\\" has no fuzzy weight\\r\\n\", i, ic->iteminfo[i].classname);\n\t\t} //end if\n\t} //end for\n\treturn index;\n} //end of the function ItemWeightIndex\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid InitLevelItemHeap(void)\n{\n\tint i, max_levelitems;\n\n\tif (levelitemheap) FreeMemory(levelitemheap);\n\n\tmax_levelitems = (int) LibVarValue(\"max_levelitems\", \"256\");\n\tlevelitemheap = (levelitem_t *) GetClearedMemory(max_levelitems * sizeof(levelitem_t));\n\n\tfor (i = 0; i < max_levelitems-1; i++)\n\t{\n\t\tlevelitemheap[i].next = &levelitemheap[i + 1];\n\t} //end for\n\tlevelitemheap[max_levelitems-1].next = NULL;\n\t//\n\tfreelevelitems = levelitemheap;\n} //end of the function InitLevelItemHeap\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nlevelitem_t *AllocLevelItem(void)\n{\n\tlevelitem_t *li;\n\n\tli = freelevelitems;\n\tif (!li)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"out of level items\\n\");\n\t\treturn NULL;\n\t} //end if\n\t//\n\tfreelevelitems = freelevelitems->next;\n\tCom_Memset(li, 0, sizeof(levelitem_t));\n\treturn li;\n} //end of the function AllocLevelItem\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid FreeLevelItem(levelitem_t *li)\n{\n\tli->next = freelevelitems;\n\tfreelevelitems = li;\n} //end of the function FreeLevelItem\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AddLevelItemToList(levelitem_t *li)\n{\n\tif (levelitems) levelitems->prev = li;\n\tli->prev = NULL;\n\tli->next = levelitems;\n\tlevelitems = li;\n} //end of the function AddLevelItemToList\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid RemoveLevelItemFromList(levelitem_t *li)\n{\n\tif (li->prev) li->prev->next = li->next;\n\telse levelitems = li->next;\n\tif (li->next) li->next->prev = li->prev;\n} //end of the function RemoveLevelItemFromList\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotFreeInfoEntities(void)\n{\n\tmaplocation_t *ml, *nextml;\n\tcampspot_t *cs, *nextcs;\n\n\tfor (ml = maplocations; ml; ml = nextml)\n\t{\n\t\tnextml = ml->next;\n\t\tFreeMemory(ml);\n\t} //end for\n\tmaplocations = NULL;\n\tfor (cs = campspots; cs; cs = nextcs)\n\t{\n\t\tnextcs = cs->next;\n\t\tFreeMemory(cs);\n\t} //end for\n\tcampspots = NULL;\n} //end of the function BotFreeInfoEntities\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotInitInfoEntities(void)\n{\n\tchar classname[MAX_EPAIRKEY];\n\tmaplocation_t *ml;\n\tcampspot_t *cs;\n\tint ent, numlocations, numcampspots;\n\n\tBotFreeInfoEntities();\n\t//\n\tnumlocations = 0;\n\tnumcampspots = 0;\n\tfor (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent))\n\t{\n\t\tif (!AAS_ValueForBSPEpairKey(ent, \"classname\", classname, MAX_EPAIRKEY)) continue;\n\n\t\t//map locations\n\t\tif (!strcmp(classname, \"target_location\"))\n\t\t{\n\t\t\tml = (maplocation_t *) GetClearedMemory(sizeof(maplocation_t));\n\t\t\tAAS_VectorForBSPEpairKey(ent, \"origin\", ml->origin);\n\t\t\tAAS_ValueForBSPEpairKey(ent, \"message\", ml->name, sizeof(ml->name));\n\t\t\tml->areanum = AAS_PointAreaNum(ml->origin);\n\t\t\tml->next = maplocations;\n\t\t\tmaplocations = ml;\n\t\t\tnumlocations++;\n\t\t} //end if\n\t\t//camp spots\n\t\telse if (!strcmp(classname, \"info_camp\"))\n\t\t{\n\t\t\tcs = (campspot_t *) GetClearedMemory(sizeof(campspot_t));\n\t\t\tAAS_VectorForBSPEpairKey(ent, \"origin\", cs->origin);\n\t\t\t//cs->origin[2] += 16;\n\t\t\tAAS_ValueForBSPEpairKey(ent, \"message\", cs->name, sizeof(cs->name));\n\t\t\tAAS_FloatForBSPEpairKey(ent, \"range\", &cs->range);\n\t\t\tAAS_FloatForBSPEpairKey(ent, \"weight\", &cs->weight);\n\t\t\tAAS_FloatForBSPEpairKey(ent, \"wait\", &cs->wait);\n\t\t\tAAS_FloatForBSPEpairKey(ent, \"random\", &cs->random);\n\t\t\tcs->areanum = AAS_PointAreaNum(cs->origin);\n\t\t\tif (!cs->areanum)\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_MESSAGE, \"camp spot at %1.1f %1.1f %1.1f in solid\\n\", cs->origin[0], cs->origin[1], cs->origin[2]);\n\t\t\t\tFreeMemory(cs);\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\tcs->next = campspots;\n\t\t\tcampspots = cs;\n\t\t\t//AAS_DrawPermanentCross(cs->origin, 4, LINECOLOR_YELLOW);\n\t\t\tnumcampspots++;\n\t\t} //end else if\n\t} //end for\n\tif (bot_developer)\n\t{\n\t\tbotimport.Print(PRT_MESSAGE, \"%d map locations\\n\", numlocations);\n\t\tbotimport.Print(PRT_MESSAGE, \"%d camp spots\\n\", numcampspots);\n\t} //end if\n} //end of the function BotInitInfoEntities\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotInitLevelItems(void)\n{\n\tint i, spawnflags, value;\n\tchar classname[MAX_EPAIRKEY];\n\tvec3_t origin, end;\n\tint ent, goalareanum;\n\titemconfig_t *ic;\n\tlevelitem_t *li;\n\tbsp_trace_t trace;\n\n\t//initialize the map locations and camp spots\n\tBotInitInfoEntities();\n\n\t//initialize the level item heap\n\tInitLevelItemHeap();\n\tlevelitems = NULL;\n\tnumlevelitems = 0;\n\t//\n\tic = itemconfig;\n\tif (!ic) return;\n\n\t//if there's no AAS file loaded\n\tif (!AAS_Loaded()) return;\n\n\t//update the modelindexes of the item info\n\tfor (i = 0; i < ic->numiteminfo; i++)\n\t{\n\t\t//ic->iteminfo[i].modelindex = AAS_IndexFromModel(ic->iteminfo[i].model);\n\t\tif (!ic->iteminfo[i].modelindex)\n\t\t{\n\t\t\tLog_Write(\"item %s has modelindex 0\", ic->iteminfo[i].classname);\n\t\t} //end if\n\t} //end for\n\n\tfor (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent))\n\t{\n\t\tif (!AAS_ValueForBSPEpairKey(ent, \"classname\", classname, MAX_EPAIRKEY)) continue;\n\t\t//\n\t\tspawnflags = 0;\n\t\tAAS_IntForBSPEpairKey(ent, \"spawnflags\", &spawnflags);\n\t\t//\n\t\tfor (i = 0; i < ic->numiteminfo; i++)\n\t\t{\n\t\t\tif (!strcmp(classname, ic->iteminfo[i].classname)) break;\n\t\t} //end for\n\t\tif (i >= ic->numiteminfo)\n\t\t{\n\t\t\tLog_Write(\"entity %s unknown item\\r\\n\", classname);\n\t\t\tcontinue;\n\t\t} //end if\n\t\t//get the origin of the item\n\t\tif (!AAS_VectorForBSPEpairKey(ent, \"origin\", origin))\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"item %s without origin\\n\", classname);\n\t\t\tcontinue;\n\t\t} //end else\n\t\t//\n\t\tgoalareanum = 0;\n\t\t//if it is a floating item\n\t\tif (spawnflags & 1)\n\t\t{\n\t\t\t//if the item is not floating in water\n\t\t\tif (!(AAS_PointContents(origin) & CONTENTS_WATER))\n\t\t\t{\n\t\t\t\tVectorCopy(origin, end);\n\t\t\t\tend[2] -= 32;\n\t\t\t\ttrace = AAS_Trace(origin, ic->iteminfo[i].mins, ic->iteminfo[i].maxs, end, -1, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);\n\t\t\t\t//if the item not near the ground\n\t\t\t\tif (trace.fraction >= 1)\n\t\t\t\t{\n\t\t\t\t\t//if the item is not reachable from a jumppad\n\t\t\t\t\tgoalareanum = AAS_BestReachableFromJumpPadArea(origin, ic->iteminfo[i].mins, ic->iteminfo[i].maxs);\n\t\t\t\t\tLog_Write(\"item %s reachable from jumppad area %d\\r\\n\", ic->iteminfo[i].classname, goalareanum);\n\t\t\t\t\t//botimport.Print(PRT_MESSAGE, \"item %s reachable from jumppad area %d\\r\\n\", ic->iteminfo[i].classname, goalareanum);\n\t\t\t\t\tif (!goalareanum) continue;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end if\n\n\t\tli = AllocLevelItem();\n\t\tif (!li) return;\n\t\t//\n\t\tli->number = ++numlevelitems;\n\t\tli->timeout = 0;\n\t\tli->entitynum = 0;\n\t\t//\n\t\tli->flags = 0;\n\t\tAAS_IntForBSPEpairKey(ent, \"notfree\", &value);\n\t\tif (value) li->flags |= IFL_NOTFREE;\n\t\tAAS_IntForBSPEpairKey(ent, \"notteam\", &value);\n\t\tif (value) li->flags |= IFL_NOTTEAM;\n\t\tAAS_IntForBSPEpairKey(ent, \"notsingle\", &value);\n\t\tif (value) li->flags |= IFL_NOTSINGLE;\n\t\tAAS_IntForBSPEpairKey(ent, \"notbot\", &value);\n\t\tif (value) li->flags |= IFL_NOTBOT;\n\t\tif (!strcmp(classname, \"item_botroam\"))\n\t\t{\n\t\t\tli->flags |= IFL_ROAM;\n\t\t\tAAS_FloatForBSPEpairKey(ent, \"weight\", &li->weight);\n\t\t} //end if\n\t\t//if not a stationary item\n\t\tif (!(spawnflags & 1))\n\t\t{\n\t\t\tif (!AAS_DropToFloor(origin, ic->iteminfo[i].mins, ic->iteminfo[i].maxs))\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_MESSAGE, \"%s in solid at (%1.1f %1.1f %1.1f)\\n\",\n\t\t\t\t\t\t\t\t\t\t\t\tclassname, origin[0], origin[1], origin[2]);\n\t\t\t} //end if\n\t\t} //end if\n\t\t//item info of the level item\n\t\tli->iteminfo = i;\n\t\t//origin of the item\n\t\tVectorCopy(origin, li->origin);\n\t\t//\n\t\tif (goalareanum)\n\t\t{\n\t\t\tli->goalareanum = goalareanum;\n\t\t\tVectorCopy(origin, li->goalorigin);\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\t//get the item goal area and goal origin\n\t\t\tli->goalareanum = AAS_BestReachableArea(origin,\n\t\t\t\t\t\t\tic->iteminfo[i].mins, ic->iteminfo[i].maxs,\n\t\t\t\t\t\t\tli->goalorigin);\n\t\t\tif (!li->goalareanum)\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_MESSAGE, \"%s not reachable for bots at (%1.1f %1.1f %1.1f)\\n\",\n\t\t\t\t\t\t\t\t\t\t\t\tclassname, origin[0], origin[1], origin[2]);\n\t\t\t} //end if\n\t\t} //end else\n\t\t//\n\t\tAddLevelItemToList(li);\n\t} //end for\n\tbotimport.Print(PRT_MESSAGE, \"found %d level items\\n\", numlevelitems);\n} //end of the function BotInitLevelItems\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotGoalName(int number, char *name, int size)\n{\n\tlevelitem_t *li;\n\n\tif (!itemconfig) return;\n\t//\n\tfor (li = levelitems; li; li = li->next)\n\t{\n\t\tif (li->number == number)\n\t\t{\n\t\t\tstrncpy(name, itemconfig->iteminfo[li->iteminfo].name, size-1);\n\t\t\tname[size-1] = '\\0';\n\t\t\treturn;\n\t\t} //end for\n\t} //end for\n\tstrcpy(name, \"\");\n\treturn;\n} //end of the function BotGoalName\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotResetAvoidGoals(int goalstate)\n{\n\tbot_goalstate_t *gs;\n\n\tgs = BotGoalStateFromHandle(goalstate);\n\tif (!gs) return;\n\tCom_Memset(gs->avoidgoals, 0, MAX_AVOIDGOALS * sizeof(int));\n\tCom_Memset(gs->avoidgoaltimes, 0, MAX_AVOIDGOALS * sizeof(float));\n} //end of the function BotResetAvoidGoals\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotDumpAvoidGoals(int goalstate)\n{\n\tint i;\n\tbot_goalstate_t *gs;\n\tchar name[32];\n\n\tgs = BotGoalStateFromHandle(goalstate);\n\tif (!gs) return;\n\tfor (i = 0; i < MAX_AVOIDGOALS; i++)\n\t{\n\t\tif (gs->avoidgoaltimes[i] >= AAS_Time())\n\t\t{\n\t\t\tBotGoalName(gs->avoidgoals[i], name, 32);\n\t\t\tLog_Write(\"avoid goal %s, number %d for %f seconds\", name,\n\t\t\t\tgs->avoidgoals[i], gs->avoidgoaltimes[i] - AAS_Time());\n\t\t} //end if\n\t} //end for\n} //end of the function BotDumpAvoidGoals\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotAddToAvoidGoals(bot_goalstate_t *gs, int number, float avoidtime)\n{\n\tint i;\n\n\tfor (i = 0; i < MAX_AVOIDGOALS; i++)\n\t{\n\t\t//if the avoid goal is already stored\n\t\tif (gs->avoidgoals[i] == number)\n\t\t{\n\t\t\tgs->avoidgoals[i] = number;\n\t\t\tgs->avoidgoaltimes[i] = AAS_Time() + avoidtime;\n\t\t\treturn;\n\t\t} //end if\n\t} //end for\n\n\tfor (i = 0; i < MAX_AVOIDGOALS; i++)\n\t{\n\t\t//if this avoid goal has expired\n\t\tif (gs->avoidgoaltimes[i] < AAS_Time())\n\t\t{\n\t\t\tgs->avoidgoals[i] = number;\n\t\t\tgs->avoidgoaltimes[i] = AAS_Time() + avoidtime;\n\t\t\treturn;\n\t\t} //end if\n\t} //end for\n} //end of the function BotAddToAvoidGoals\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotRemoveFromAvoidGoals(int goalstate, int number)\n{\n\tint i;\n\tbot_goalstate_t *gs;\n\n\tgs = BotGoalStateFromHandle(goalstate);\n\tif (!gs) return;\n\t//don't use the goals the bot wants to avoid\n\tfor (i = 0; i < MAX_AVOIDGOALS; i++)\n\t{\n\t\tif (gs->avoidgoals[i] == number && gs->avoidgoaltimes[i] >= AAS_Time())\n\t\t{\n\t\t\tgs->avoidgoaltimes[i] = 0;\n\t\t\treturn;\n\t\t} //end if\n\t} //end for\n} //end of the function BotRemoveFromAvoidGoals\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat BotAvoidGoalTime(int goalstate, int number)\n{\n\tint i;\n\tbot_goalstate_t *gs;\n\n\tgs = BotGoalStateFromHandle(goalstate);\n\tif (!gs) return 0;\n\t//don't use the goals the bot wants to avoid\n\tfor (i = 0; i < MAX_AVOIDGOALS; i++)\n\t{\n\t\tif (gs->avoidgoals[i] == number && gs->avoidgoaltimes[i] >= AAS_Time())\n\t\t{\n\t\t\treturn gs->avoidgoaltimes[i] - AAS_Time();\n\t\t} //end if\n\t} //end for\n\treturn 0;\n} //end of the function BotAvoidGoalTime\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotSetAvoidGoalTime(int goalstate, int number, float avoidtime)\n{\n\tbot_goalstate_t *gs;\n\tlevelitem_t *li;\n\n\tgs = BotGoalStateFromHandle(goalstate);\n\tif (!gs)\n\t\treturn;\n\tif (avoidtime < 0)\n\t{\n\t\tif (!itemconfig)\n\t\t\treturn;\n\t\t//\n\t\tfor (li = levelitems; li; li = li->next)\n\t\t{\n\t\t\tif (li->number == number)\n\t\t\t{\n\t\t\t\tavoidtime = itemconfig->iteminfo[li->iteminfo].respawntime;\n\t\t\t\tif (!avoidtime)\n\t\t\t\t\tavoidtime = AVOID_DEFAULT_TIME;\n\t\t\t\tif (avoidtime < AVOID_MINIMUM_TIME)\n\t\t\t\t\tavoidtime = AVOID_MINIMUM_TIME;\n\t\t\t\tBotAddToAvoidGoals(gs, number, avoidtime);\n\t\t\t\treturn;\n\t\t\t} //end for\n\t\t} //end for\n\t\treturn;\n\t} //end if\n\telse\n\t{\n\t\tBotAddToAvoidGoals(gs, number, avoidtime);\n\t} //end else\n} //end of the function BotSetAvoidGoalTime\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotGetLevelItemGoal(int index, char *name, bot_goal_t *goal)\n{\n\tlevelitem_t *li;\n\n\tif (!itemconfig) return -1;\n\tli = levelitems;\n\tif (index >= 0)\n\t{\n\t\tfor (; li; li = li->next)\n\t\t{\n\t\t\tif (li->number == index)\n\t\t\t{\n\t\t\t\tli = li->next;\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\tfor (; li; li = li->next)\n\t{\n\t\t//\n\t\tif (g_gametype == GT_SINGLE_PLAYER) {\n\t\t\tif (li->flags & IFL_NOTSINGLE) continue;\n\t\t}\n\t\telse if (g_gametype >= GT_TEAM) {\n\t\t\tif (li->flags & IFL_NOTTEAM) continue;\n\t\t}\n\t\telse {\n\t\t\tif (li->flags & IFL_NOTFREE) continue;\n\t\t}\n\t\tif (li->flags & IFL_NOTBOT) continue;\n\t\t//\n\t\tif (!Q_stricmp(name, itemconfig->iteminfo[li->iteminfo].name))\n\t\t{\n\t\t\tgoal->areanum = li->goalareanum;\n\t\t\tVectorCopy(li->goalorigin, goal->origin);\n\t\t\tgoal->entitynum = li->entitynum;\n\t\t\tVectorCopy(itemconfig->iteminfo[li->iteminfo].mins, goal->mins);\n\t\t\tVectorCopy(itemconfig->iteminfo[li->iteminfo].maxs, goal->maxs);\n\t\t\tgoal->number = li->number;\n\t\t\tgoal->flags = GFL_ITEM;\n\t\t\tif (li->timeout) goal->flags |= GFL_DROPPED;\n\t\t\t//botimport.Print(PRT_MESSAGE, \"found li %s\\n\", itemconfig->iteminfo[li->iteminfo].name);\n\t\t\treturn li->number;\n\t\t} //end if\n\t} //end for\n\treturn -1;\n} //end of the function BotGetLevelItemGoal\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotGetMapLocationGoal(char *name, bot_goal_t *goal)\n{\n\tmaplocation_t *ml;\n\tvec3_t mins = {-8, -8, -8}, maxs = {8, 8, 8};\n\n\tfor (ml = maplocations; ml; ml = ml->next)\n\t{\n\t\tif (!Q_stricmp(ml->name, name))\n\t\t{\n\t\t\tgoal->areanum = ml->areanum;\n\t\t\tVectorCopy(ml->origin, goal->origin);\n\t\t\tgoal->entitynum = 0;\n\t\t\tVectorCopy(mins, goal->mins);\n\t\t\tVectorCopy(maxs, goal->maxs);\n\t\t\treturn qtrue;\n\t\t} //end if\n\t} //end for\n\treturn qfalse;\n} //end of the function BotGetMapLocationGoal\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotGetNextCampSpotGoal(int num, bot_goal_t *goal)\n{\n\tint i;\n\tcampspot_t *cs;\n\tvec3_t mins = {-8, -8, -8}, maxs = {8, 8, 8};\n\n\tif (num < 0) num = 0;\n\ti = num;\n\tfor (cs = campspots; cs; cs = cs->next)\n\t{\n\t\tif (--i < 0)\n\t\t{\n\t\t\tgoal->areanum = cs->areanum;\n\t\t\tVectorCopy(cs->origin, goal->origin);\n\t\t\tgoal->entitynum = 0;\n\t\t\tVectorCopy(mins, goal->mins);\n\t\t\tVectorCopy(maxs, goal->maxs);\n\t\t\treturn num+1;\n\t\t} //end if\n\t} //end for\n\treturn 0;\n} //end of the function BotGetNextCampSpotGoal\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotFindEntityForLevelItem(levelitem_t *li)\n{\n\tint ent, modelindex;\n\titemconfig_t *ic;\n\taas_entityinfo_t entinfo;\n\tvec3_t dir;\n\n\tic = itemconfig;\n\tif (!itemconfig) return;\n\tfor (ent = AAS_NextEntity(0); ent; ent = AAS_NextEntity(ent))\n\t{\n\t\t//get the model index of the entity\n\t\tmodelindex = AAS_EntityModelindex(ent);\n\t\t//\n\t\tif (!modelindex) continue;\n\t\t//get info about the entity\n\t\tAAS_EntityInfo(ent, &entinfo);\n\t\t//if the entity is still moving\n\t\tif (entinfo.origin[0] != entinfo.lastvisorigin[0] ||\n\t\t\t\tentinfo.origin[1] != entinfo.lastvisorigin[1] ||\n\t\t\t\tentinfo.origin[2] != entinfo.lastvisorigin[2]) continue;\n\t\t//\n\t\tif (ic->iteminfo[li->iteminfo].modelindex == modelindex)\n\t\t{\n\t\t\t//check if the entity is very close\n\t\t\tVectorSubtract(li->origin, entinfo.origin, dir);\n\t\t\tif (VectorLength(dir) < 30)\n\t\t\t{\n\t\t\t\t//found an entity for this level item\n\t\t\t\tli->entitynum = ent;\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n} //end of the function BotFindEntityForLevelItem\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n\n//NOTE: enum entityType_t in bg_public.h\n#define ET_ITEM\t\t\t2\n\nvoid BotUpdateEntityItems(void)\n{\n\tint ent, i, modelindex;\n\tvec3_t dir;\n\tlevelitem_t *li, *nextli;\n\taas_entityinfo_t entinfo;\n\titemconfig_t *ic;\n\n\t//timeout current entity items if necessary\n\tfor (li = levelitems; li; li = nextli)\n\t{\n\t\tnextli = li->next;\n\t\t//if it is a item that will time out\n\t\tif (li->timeout)\n\t\t{\n\t\t\t//timeout the item\n\t\t\tif (li->timeout < AAS_Time())\n\t\t\t{\n\t\t\t\tRemoveLevelItemFromList(li);\n\t\t\t\tFreeLevelItem(li);\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n\t//find new entity items\n\tic = itemconfig;\n\tif (!itemconfig) return;\n\t//\n\tfor (ent = AAS_NextEntity(0); ent; ent = AAS_NextEntity(ent))\n\t{\n\t\tif (AAS_EntityType(ent) != ET_ITEM) continue;\n\t\t//get the model index of the entity\n\t\tmodelindex = AAS_EntityModelindex(ent);\n\t\t//\n\t\tif (!modelindex) continue;\n\t\t//get info about the entity\n\t\tAAS_EntityInfo(ent, &entinfo);\n\t\t//FIXME: don't do this\n\t\t//skip all floating items for now\n\t\t//if (entinfo.groundent != ENTITYNUM_WORLD) continue;\n\t\t//if the entity is still moving\n\t\tif (entinfo.origin[0] != entinfo.lastvisorigin[0] ||\n\t\t\t\tentinfo.origin[1] != entinfo.lastvisorigin[1] ||\n\t\t\t\tentinfo.origin[2] != entinfo.lastvisorigin[2]) continue;\n\t\t//check if the entity is already stored as a level item\n\t\tfor (li = levelitems; li; li = li->next)\n\t\t{\n\t\t\t//if the level item is linked to an entity\n\t\t\tif (li->entitynum && li->entitynum == ent)\n\t\t\t{\n\t\t\t\t//the entity is re-used if the models are different\n\t\t\t\tif (ic->iteminfo[li->iteminfo].modelindex != modelindex)\n\t\t\t\t{\n\t\t\t\t\t//remove this level item\n\t\t\t\t\tRemoveLevelItemFromList(li);\n\t\t\t\t\tFreeLevelItem(li);\n\t\t\t\t\tli = NULL;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (entinfo.origin[0] != li->origin[0] ||\n\t\t\t\t\t\tentinfo.origin[1] != li->origin[1] ||\n\t\t\t\t\t\tentinfo.origin[2] != li->origin[2])\n\t\t\t\t\t{\n\t\t\t\t\t\tVectorCopy(entinfo.origin, li->origin);\n\t\t\t\t\t\t//also update the goal area number\n\t\t\t\t\t\tli->goalareanum = AAS_BestReachableArea(li->origin,\n\t\t\t\t\t\t\t\t\t\tic->iteminfo[li->iteminfo].mins, ic->iteminfo[li->iteminfo].maxs,\n\t\t\t\t\t\t\t\t\t\tli->goalorigin);\n\t\t\t\t\t} //end if\n\t\t\t\t\tbreak;\n\t\t\t\t} //end else\n\t\t\t} //end if\n\t\t} //end for\n\t\tif (li) continue;\n\t\t//try to link the entity to a level item\n\t\tfor (li = levelitems; li; li = li->next)\n\t\t{\n\t\t\t//if this level item is already linked\n\t\t\tif (li->entitynum) continue;\n\t\t\t//\n\t\t\tif (g_gametype == GT_SINGLE_PLAYER) {\n\t\t\t\tif (li->flags & IFL_NOTSINGLE) continue;\n\t\t\t}\n\t\t\telse if (g_gametype >= GT_TEAM) {\n\t\t\t\tif (li->flags & IFL_NOTTEAM) continue;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (li->flags & IFL_NOTFREE) continue;\n\t\t\t}\n\t\t\t//if the model of the level item and the entity are the same\n\t\t\tif (ic->iteminfo[li->iteminfo].modelindex == modelindex)\n\t\t\t{\n\t\t\t\t//check if the entity is very close\n\t\t\t\tVectorSubtract(li->origin, entinfo.origin, dir);\n\t\t\t\tif (VectorLength(dir) < 30)\n\t\t\t\t{\n\t\t\t\t\t//found an entity for this level item\n\t\t\t\t\tli->entitynum = ent;\n\t\t\t\t\t//if the origin is different\n\t\t\t\t\tif (entinfo.origin[0] != li->origin[0] ||\n\t\t\t\t\t\tentinfo.origin[1] != li->origin[1] ||\n\t\t\t\t\t\tentinfo.origin[2] != li->origin[2])\n\t\t\t\t\t{\n\t\t\t\t\t\t//update the level item origin\n\t\t\t\t\t\tVectorCopy(entinfo.origin, li->origin);\n\t\t\t\t\t\t//also update the goal area number\n\t\t\t\t\t\tli->goalareanum = AAS_BestReachableArea(li->origin,\n\t\t\t\t\t\t\t\t\t\tic->iteminfo[li->iteminfo].mins, ic->iteminfo[li->iteminfo].maxs,\n\t\t\t\t\t\t\t\t\t\tli->goalorigin);\n\t\t\t\t\t} //end if\n#ifdef DEBUG\n\t\t\t\t\tLog_Write(\"linked item %s to an entity\", ic->iteminfo[li->iteminfo].classname);\n#endif //DEBUG\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t} //end else\n\t\t} //end for\n\t\tif (li) continue;\n\t\t//check if the model is from a known item\n\t\tfor (i = 0; i < ic->numiteminfo; i++)\n\t\t{\n\t\t\tif (ic->iteminfo[i].modelindex == modelindex)\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t} //end for\n\t\t//if the model is not from a known item\n\t\tif (i >= ic->numiteminfo) continue;\n\t\t//allocate a new level item\n\t\tli = AllocLevelItem();\n\t\t//\n\t\tif (!li) continue;\n\t\t//entity number of the level item\n\t\tli->entitynum = ent;\n\t\t//number for the level item\n\t\tli->number = numlevelitems + ent;\n\t\t//set the item info index for the level item\n\t\tli->iteminfo = i;\n\t\t//origin of the item\n\t\tVectorCopy(entinfo.origin, li->origin);\n\t\t//get the item goal area and goal origin\n\t\tli->goalareanum = AAS_BestReachableArea(li->origin,\n\t\t\t\t\t\t\t\t\tic->iteminfo[i].mins, ic->iteminfo[i].maxs,\n\t\t\t\t\t\t\t\t\tli->goalorigin);\n\t\t//never go for items dropped into jumppads\n\t\tif (AAS_AreaJumpPad(li->goalareanum))\n\t\t{\n\t\t\tFreeLevelItem(li);\n\t\t\tcontinue;\n\t\t} //end if\n\t\t//time this item out after 30 seconds\n\t\t//dropped items disappear after 30 seconds\n\t\tli->timeout = AAS_Time() + 30;\n\t\t//add the level item to the list\n\t\tAddLevelItemToList(li);\n\t\t//botimport.Print(PRT_MESSAGE, \"found new level item %s\\n\", ic->iteminfo[i].classname);\n\t} //end for\n\t/*\n\tfor (li = levelitems; li; li = li->next)\n\t{\n\t\tif (!li->entitynum)\n\t\t{\n\t\t\tBotFindEntityForLevelItem(li);\n\t\t} //end if\n\t} //end for*/\n} //end of the function BotUpdateEntityItems\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotDumpGoalStack(int goalstate)\n{\n\tint i;\n\tbot_goalstate_t *gs;\n\tchar name[32];\n\n\tgs = BotGoalStateFromHandle(goalstate);\n\tif (!gs) return;\n\tfor (i = 1; i <= gs->goalstacktop; i++)\n\t{\n\t\tBotGoalName(gs->goalstack[i].number, name, 32);\n\t\tLog_Write(\"%d: %s\", i, name);\n\t} //end for\n} //end of the function BotDumpGoalStack\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotPushGoal(int goalstate, bot_goal_t *goal)\n{\n\tbot_goalstate_t *gs;\n\n\tgs = BotGoalStateFromHandle(goalstate);\n\tif (!gs) return;\n\tif (gs->goalstacktop >= MAX_GOALSTACK-1)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"goal heap overflow\\n\");\n\t\tBotDumpGoalStack(goalstate);\n\t\treturn;\n\t} //end if\n\tgs->goalstacktop++;\n\tCom_Memcpy(&gs->goalstack[gs->goalstacktop], goal, sizeof(bot_goal_t));\n} //end of the function BotPushGoal\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotPopGoal(int goalstate)\n{\n\tbot_goalstate_t *gs;\n\n\tgs = BotGoalStateFromHandle(goalstate);\n\tif (!gs) return;\n\tif (gs->goalstacktop > 0) gs->goalstacktop--;\n} //end of the function BotPopGoal\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotEmptyGoalStack(int goalstate)\n{\n\tbot_goalstate_t *gs;\n\n\tgs = BotGoalStateFromHandle(goalstate);\n\tif (!gs) return;\n\tgs->goalstacktop = 0;\n} //end of the function BotEmptyGoalStack\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotGetTopGoal(int goalstate, bot_goal_t *goal)\n{\n\tbot_goalstate_t *gs;\n\n\tgs = BotGoalStateFromHandle(goalstate);\n\tif (!gs) return qfalse;\n\tif (!gs->goalstacktop) return qfalse;\n\tCom_Memcpy(goal, &gs->goalstack[gs->goalstacktop], sizeof(bot_goal_t));\n\treturn qtrue;\n} //end of the function BotGetTopGoal\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotGetSecondGoal(int goalstate, bot_goal_t *goal)\n{\n\tbot_goalstate_t *gs;\n\n\tgs = BotGoalStateFromHandle(goalstate);\n\tif (!gs) return qfalse;\n\tif (gs->goalstacktop <= 1) return qfalse;\n\tCom_Memcpy(goal, &gs->goalstack[gs->goalstacktop-1], sizeof(bot_goal_t));\n\treturn qtrue;\n} //end of the function BotGetSecondGoal\n//===========================================================================\n// pops a new long term goal on the goal stack in the goalstate\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelflags)\n{\n\tint areanum, t, weightnum;\n\tfloat weight, bestweight, avoidtime;\n\titeminfo_t *iteminfo;\n\titemconfig_t *ic;\n\tlevelitem_t *li, *bestitem;\n\tbot_goal_t goal;\n\tbot_goalstate_t *gs;\n\n\tgs = BotGoalStateFromHandle(goalstate);\n\tif (!gs)\n\t\treturn qfalse;\n\tif (!gs->itemweightconfig)\n\t\treturn qfalse;\n\t//get the area the bot is in\n\tareanum = BotReachabilityArea(origin, gs->client);\n\t//if the bot is in solid or if the area the bot is in has no reachability links\n\tif (!areanum || !AAS_AreaReachability(areanum))\n\t{\n\t\t//use the last valid area the bot was in\n\t\tareanum = gs->lastreachabilityarea;\n\t} //end if\n\t//remember the last area with reachabilities the bot was in\n\tgs->lastreachabilityarea = areanum;\n\t//if still in solid\n\tif (!areanum)\n\t\treturn qfalse;\n\t//the item configuration\n\tic = itemconfig;\n\tif (!itemconfig)\n\t\treturn qfalse;\n\t//best weight and item so far\n\tbestweight = 0;\n\tbestitem = NULL;\n\tCom_Memset(&goal, 0, sizeof(bot_goal_t));\n\t//go through the items in the level\n\tfor (li = levelitems; li; li = li->next)\n\t{\n\t\tif (g_gametype == GT_SINGLE_PLAYER) {\n\t\t\tif (li->flags & IFL_NOTSINGLE)\n\t\t\t\tcontinue;\n\t\t}\n\t\telse if (g_gametype >= GT_TEAM) {\n\t\t\tif (li->flags & IFL_NOTTEAM)\n\t\t\t\tcontinue;\n\t\t}\n\t\telse {\n\t\t\tif (li->flags & IFL_NOTFREE)\n\t\t\t\tcontinue;\n\t\t}\n\t\tif (li->flags & IFL_NOTBOT)\n\t\t\tcontinue;\n\t\t//if the item is not in a possible goal area\n\t\tif (!li->goalareanum)\n\t\t\tcontinue;\n\t\t//FIXME: is this a good thing? added this for items that never spawned into the game (f.i. CTF flags in obelisk)\n\t\tif (!li->entitynum && !(li->flags & IFL_ROAM))\n\t\t\tcontinue;\n\t\t//get the fuzzy weight function for this item\n\t\titeminfo = &ic->iteminfo[li->iteminfo];\n\t\tweightnum = gs->itemweightindex[iteminfo->number];\n\t\tif (weightnum < 0)\n\t\t\tcontinue;\n\n#ifdef UNDECIDEDFUZZY\n\t\tweight = FuzzyWeightUndecided(inventory, gs->itemweightconfig, weightnum);\n#else\n\t\tweight = FuzzyWeight(inventory, gs->itemweightconfig, weightnum);\n#endif //UNDECIDEDFUZZY\n#ifdef DROPPEDWEIGHT\n\t\t//HACK: to make dropped items more attractive\n\t\tif (li->timeout)\n\t\t\tweight += droppedweight->value;\n#endif //DROPPEDWEIGHT\n\t\t//use weight scale for item_botroam\n\t\tif (li->flags & IFL_ROAM) weight *= li->weight;\n\t\t//\n\t\tif (weight > 0)\n\t\t{\n\t\t\t//get the travel time towards the goal area\n\t\t\tt = AAS_AreaTravelTimeToGoalArea(areanum, origin, li->goalareanum, travelflags);\n\t\t\t//if the goal is reachable\n\t\t\tif (t > 0)\n\t\t\t{\n\t\t\t\t//if this item won't respawn before we get there\n\t\t\t\tavoidtime = BotAvoidGoalTime(goalstate, li->number);\n\t\t\t\tif (avoidtime - t * 0.009 > 0)\n\t\t\t\t\tcontinue;\n\t\t\t\t//\n\t\t\t\tweight /= (float) t * TRAVELTIME_SCALE;\n\t\t\t\t//\n\t\t\t\tif (weight > bestweight)\n\t\t\t\t{\n\t\t\t\t\tbestweight = weight;\n\t\t\t\t\tbestitem = li;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n\t//if no goal item found\n\tif (!bestitem)\n\t{\n\t\t/*\n\t\t//if not in lava or slime\n\t\tif (!AAS_AreaLava(areanum) && !AAS_AreaSlime(areanum))\n\t\t{\n\t\t\tif (AAS_RandomGoalArea(areanum, travelflags, &goal.areanum, goal.origin))\n\t\t\t{\n\t\t\t\tVectorSet(goal.mins, -15, -15, -15);\n\t\t\t\tVectorSet(goal.maxs, 15, 15, 15);\n\t\t\t\tgoal.entitynum = 0;\n\t\t\t\tgoal.number = 0;\n\t\t\t\tgoal.flags = GFL_ROAM;\n\t\t\t\tgoal.iteminfo = 0;\n\t\t\t\t//push the goal on the stack\n\t\t\t\tBotPushGoal(goalstate, &goal);\n\t\t\t\t//\n#ifdef DEBUG\n\t\t\t\tbotimport.Print(PRT_MESSAGE, \"chosen roam goal area %d\\n\", goal.areanum);\n#endif //DEBUG\n\t\t\t\treturn qtrue;\n\t\t\t} //end if\n\t\t} //end if\n\t\t*/\n\t\treturn qfalse;\n\t} //end if\n\t//create a bot goal for this item\n\titeminfo = &ic->iteminfo[bestitem->iteminfo];\n\tVectorCopy(bestitem->goalorigin, goal.origin);\n\tVectorCopy(iteminfo->mins, goal.mins);\n\tVectorCopy(iteminfo->maxs, goal.maxs);\n\tgoal.areanum = bestitem->goalareanum;\n\tgoal.entitynum = bestitem->entitynum;\n\tgoal.number = bestitem->number;\n\tgoal.flags = GFL_ITEM;\n\tif (bestitem->timeout)\n\t\tgoal.flags |= GFL_DROPPED;\n\tif (bestitem->flags & IFL_ROAM)\n\t\tgoal.flags |= GFL_ROAM;\n\tgoal.iteminfo = bestitem->iteminfo;\n\t//if it's a dropped item\n\tif (bestitem->timeout)\n\t{\n\t\tavoidtime = AVOID_DROPPED_TIME;\n\t} //end if\n\telse\n\t{\n\t\tavoidtime = iteminfo->respawntime;\n\t\tif (!avoidtime)\n\t\t\tavoidtime = AVOID_DEFAULT_TIME;\n\t\tif (avoidtime < AVOID_MINIMUM_TIME)\n\t\t\tavoidtime = AVOID_MINIMUM_TIME;\n\t} //end else\n\t//add the chosen goal to the goals to avoid for a while\n\tBotAddToAvoidGoals(gs, bestitem->number, avoidtime);\n\t//push the goal on the stack\n\tBotPushGoal(goalstate, &goal);\n\t//\n\treturn qtrue;\n} //end of the function BotChooseLTGItem\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelflags,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tbot_goal_t *ltg, float maxtime)\n{\n\tint areanum, t, weightnum, ltg_time;\n\tfloat weight, bestweight, avoidtime;\n\titeminfo_t *iteminfo;\n\titemconfig_t *ic;\n\tlevelitem_t *li, *bestitem;\n\tbot_goal_t goal;\n\tbot_goalstate_t *gs;\n\n\tgs = BotGoalStateFromHandle(goalstate);\n\tif (!gs)\n\t\treturn qfalse;\n\tif (!gs->itemweightconfig)\n\t\treturn qfalse;\n\t//get the area the bot is in\n\tareanum = BotReachabilityArea(origin, gs->client);\n\t//if the bot is in solid or if the area the bot is in has no reachability links\n\tif (!areanum || !AAS_AreaReachability(areanum))\n\t{\n\t\t//use the last valid area the bot was in\n\t\tareanum = gs->lastreachabilityarea;\n\t} //end if\n\t//remember the last area with reachabilities the bot was in\n\tgs->lastreachabilityarea = areanum;\n\t//if still in solid\n\tif (!areanum)\n\t\treturn qfalse;\n\t//\n\tif (ltg) ltg_time = AAS_AreaTravelTimeToGoalArea(areanum, origin, ltg->areanum, travelflags);\n\telse ltg_time = 99999;\n\t//the item configuration\n\tic = itemconfig;\n\tif (!itemconfig)\n\t\treturn qfalse;\n\t//best weight and item so far\n\tbestweight = 0;\n\tbestitem = NULL;\n\tCom_Memset(&goal, 0, sizeof(bot_goal_t));\n\t//go through the items in the level\n\tfor (li = levelitems; li; li = li->next)\n\t{\n\t\tif (g_gametype == GT_SINGLE_PLAYER) {\n\t\t\tif (li->flags & IFL_NOTSINGLE)\n\t\t\t\tcontinue;\n\t\t}\n\t\telse if (g_gametype >= GT_TEAM) {\n\t\t\tif (li->flags & IFL_NOTTEAM)\n\t\t\t\tcontinue;\n\t\t}\n\t\telse {\n\t\t\tif (li->flags & IFL_NOTFREE)\n\t\t\t\tcontinue;\n\t\t}\n\t\tif (li->flags & IFL_NOTBOT)\n\t\t\tcontinue;\n\t\t//if the item is in a possible goal area\n\t\tif (!li->goalareanum)\n\t\t\tcontinue;\n\t\t//FIXME: is this a good thing? added this for items that never spawned into the game (f.i. CTF flags in obelisk)\n\t\tif (!li->entitynum && !(li->flags & IFL_ROAM))\n\t\t\tcontinue;\n\t\t//get the fuzzy weight function for this item\n\t\titeminfo = &ic->iteminfo[li->iteminfo];\n\t\tweightnum = gs->itemweightindex[iteminfo->number];\n\t\tif (weightnum < 0)\n\t\t\tcontinue;\n\t\t//\n#ifdef UNDECIDEDFUZZY\n\t\tweight = FuzzyWeightUndecided(inventory, gs->itemweightconfig, weightnum);\n#else\n\t\tweight = FuzzyWeight(inventory, gs->itemweightconfig, weightnum);\n#endif //UNDECIDEDFUZZY\n#ifdef DROPPEDWEIGHT\n\t\t//HACK: to make dropped items more attractive\n\t\tif (li->timeout)\n\t\t\tweight += droppedweight->value;\n#endif //DROPPEDWEIGHT\n\t\t//use weight scale for item_botroam\n\t\tif (li->flags & IFL_ROAM) weight *= li->weight;\n\t\t//\n\t\tif (weight > 0)\n\t\t{\n\t\t\t//get the travel time towards the goal area\n\t\t\tt = AAS_AreaTravelTimeToGoalArea(areanum, origin, li->goalareanum, travelflags);\n\t\t\t//if the goal is reachable\n\t\t\tif (t > 0 && t < maxtime)\n\t\t\t{\n\t\t\t\t//if this item won't respawn before we get there\n\t\t\t\tavoidtime = BotAvoidGoalTime(goalstate, li->number);\n\t\t\t\tif (avoidtime - t * 0.009 > 0)\n\t\t\t\t\tcontinue;\n\t\t\t\t//\n\t\t\t\tweight /= (float) t * TRAVELTIME_SCALE;\n\t\t\t\t//\n\t\t\t\tif (weight > bestweight)\n\t\t\t\t{\n\t\t\t\t\tt = 0;\n\t\t\t\t\tif (ltg && !li->timeout)\n\t\t\t\t\t{\n\t\t\t\t\t\t//get the travel time from the goal to the long term goal\n\t\t\t\t\t\tt = AAS_AreaTravelTimeToGoalArea(li->goalareanum, li->goalorigin, ltg->areanum, travelflags);\n\t\t\t\t\t} //end if\n\t\t\t\t\t//if the travel back is possible and doesn't take too long\n\t\t\t\t\tif (t <= ltg_time)\n\t\t\t\t\t{\n\t\t\t\t\t\tbestweight = weight;\n\t\t\t\t\t\tbestitem = li;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n\t//if no goal item found\n\tif (!bestitem)\n\t\treturn qfalse;\n\t//create a bot goal for this item\n\titeminfo = &ic->iteminfo[bestitem->iteminfo];\n\tVectorCopy(bestitem->goalorigin, goal.origin);\n\tVectorCopy(iteminfo->mins, goal.mins);\n\tVectorCopy(iteminfo->maxs, goal.maxs);\n\tgoal.areanum = bestitem->goalareanum;\n\tgoal.entitynum = bestitem->entitynum;\n\tgoal.number = bestitem->number;\n\tgoal.flags = GFL_ITEM;\n\tif (bestitem->timeout)\n\t\tgoal.flags |= GFL_DROPPED;\n\tif (bestitem->flags & IFL_ROAM)\n\t\tgoal.flags |= GFL_ROAM;\n\tgoal.iteminfo = bestitem->iteminfo;\n\t//if it's a dropped item\n\tif (bestitem->timeout)\n\t{\n\t\tavoidtime = AVOID_DROPPED_TIME;\n\t} //end if\n\telse\n\t{\n\t\tavoidtime = iteminfo->respawntime;\n\t\tif (!avoidtime)\n\t\t\tavoidtime = AVOID_DEFAULT_TIME;\n\t\tif (avoidtime < AVOID_MINIMUM_TIME)\n\t\t\tavoidtime = AVOID_MINIMUM_TIME;\n\t} //end else\n\t//add the chosen goal to the goals to avoid for a while\n\tBotAddToAvoidGoals(gs, bestitem->number, avoidtime);\n\t//push the goal on the stack\n\tBotPushGoal(goalstate, &goal);\n\t//\n\treturn qtrue;\n} //end of the function BotChooseNBGItem\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotTouchingGoal(vec3_t origin, bot_goal_t *goal)\n{\n\tint i;\n\tvec3_t boxmins, boxmaxs;\n\tvec3_t absmins, absmaxs;\n\tvec3_t safety_maxs = {0, 0, 0}; //{4, 4, 10};\n\tvec3_t safety_mins = {0, 0, 0}; //{-4, -4, 0};\n\n\tAAS_PresenceTypeBoundingBox(PRESENCE_NORMAL, boxmins, boxmaxs);\n\tVectorSubtract(goal->mins, boxmaxs, absmins);\n\tVectorSubtract(goal->maxs, boxmins, absmaxs);\n\tVectorAdd(absmins, goal->origin, absmins);\n\tVectorAdd(absmaxs, goal->origin, absmaxs);\n\t//make the box a little smaller for safety\n\tVectorSubtract(absmaxs, safety_maxs, absmaxs);\n\tVectorSubtract(absmins, safety_mins, absmins);\n\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tif (origin[i] < absmins[i] || origin[i] > absmaxs[i]) return qfalse;\n\t} //end for\n\treturn qtrue;\n} //end of the function BotTouchingGoal\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, bot_goal_t *goal)\n{\n\taas_entityinfo_t entinfo;\n\tbsp_trace_t trace;\n\tvec3_t middle;\n\n\tif (!(goal->flags & GFL_ITEM)) return qfalse;\n\t//\n\tVectorAdd(goal->mins, goal->mins, middle);\n\tVectorScale(middle, 0.5, middle);\n\tVectorAdd(goal->origin, middle, middle);\n\t//\n\ttrace = AAS_Trace(eye, NULL, NULL, middle, viewer, CONTENTS_SOLID);\n\t//if the goal middle point is visible\n\tif (trace.fraction >= 1)\n\t{\n\t\t//the goal entity number doesn't have to be valid\n\t\t//just assume it's valid\n\t\tif (goal->entitynum <= 0)\n\t\t\treturn qfalse;\n\t\t//\n\t\t//if the entity data isn't valid\n\t\tAAS_EntityInfo(goal->entitynum, &entinfo);\n\t\t//NOTE: for some wacko reason entities are sometimes\n\t\t// not updated\n\t\t//if (!entinfo.valid) return qtrue;\n\t\tif (entinfo.ltime < AAS_Time() - 0.5)\n\t\t\treturn qtrue;\n\t} //end if\n\treturn qfalse;\n} //end of the function BotItemGoalInVisButNotVisible\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotResetGoalState(int goalstate)\n{\n\tbot_goalstate_t *gs;\n\n\tgs = BotGoalStateFromHandle(goalstate);\n\tif (!gs) return;\n\tCom_Memset(gs->goalstack, 0, MAX_GOALSTACK * sizeof(bot_goal_t));\n\tgs->goalstacktop = 0;\n\tBotResetAvoidGoals(goalstate);\n} //end of the function BotResetGoalState\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotLoadItemWeights(int goalstate, char *filename)\n{\n\tbot_goalstate_t *gs;\n\n\tgs = BotGoalStateFromHandle(goalstate);\n\tif (!gs) return BLERR_CANNOTLOADITEMWEIGHTS;\n\t//load the weight configuration\n\tgs->itemweightconfig = ReadWeightConfig(filename);\n\tif (!gs->itemweightconfig)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"couldn't load weights\\n\");\n\t\treturn BLERR_CANNOTLOADITEMWEIGHTS;\n\t} //end if\n\t//if there's no item configuration\n\tif (!itemconfig) return BLERR_CANNOTLOADITEMWEIGHTS;\n\t//create the item weight index\n\tgs->itemweightindex = ItemWeightIndex(gs->itemweightconfig, itemconfig);\n\t//everything went ok\n\treturn BLERR_NOERROR;\n} //end of the function BotLoadItemWeights\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotFreeItemWeights(int goalstate)\n{\n\tbot_goalstate_t *gs;\n\n\tgs = BotGoalStateFromHandle(goalstate);\n\tif (!gs) return;\n\tif (gs->itemweightconfig) FreeWeightConfig(gs->itemweightconfig);\n\tif (gs->itemweightindex) FreeMemory(gs->itemweightindex);\n} //end of the function BotFreeItemWeights\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotAllocGoalState(int client)\n{\n\tint i;\n\n\tfor (i = 1; i <= MAX_CLIENTS; i++)\n\t{\n\t\tif (!botgoalstates[i])\n\t\t{\n\t\t\tbotgoalstates[i] = GetClearedMemory(sizeof(bot_goalstate_t));\n\t\t\tbotgoalstates[i]->client = client;\n\t\t\treturn i;\n\t\t} //end if\n\t} //end for\n\treturn 0;\n} //end of the function BotAllocGoalState\n//========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//========================================================================\nvoid BotFreeGoalState(int handle)\n{\n\tif (handle <= 0 || handle > MAX_CLIENTS)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"goal state handle %d out of range\\n\", handle);\n\t\treturn;\n\t} //end if\n\tif (!botgoalstates[handle])\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"invalid goal state handle %d\\n\", handle);\n\t\treturn;\n\t} //end if\n\tBotFreeItemWeights(handle);\n\tFreeMemory(botgoalstates[handle]);\n\tbotgoalstates[handle] = NULL;\n} //end of the function BotFreeGoalState\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotSetupGoalAI(void)\n{\n\tchar *filename;\n\n\t//check if teamplay is on\n\tg_gametype = LibVarValue(\"g_gametype\", \"0\");\n\t//item configuration file\n\tfilename = LibVarString(\"itemconfig\", \"items.c\");\n\t//load the item configuration\n\titemconfig = LoadItemConfig(filename);\n\tif (!itemconfig)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"couldn't load item config\\n\");\n\t\treturn BLERR_CANNOTLOADITEMCONFIG;\n\t} //end if\n\t//\n\tdroppedweight = LibVar(\"droppedweight\", \"1000\");\n\t//everything went ok\n\treturn BLERR_NOERROR;\n} //end of the function BotSetupGoalAI\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotShutdownGoalAI(void)\n{\n\tint i;\n\n\tif (itemconfig) FreeMemory(itemconfig);\n\titemconfig = NULL;\n\tif (levelitemheap) FreeMemory(levelitemheap);\n\tlevelitemheap = NULL;\n\tfreelevelitems = NULL;\n\tlevelitems = NULL;\n\tnumlevelitems = 0;\n\n\tBotFreeInfoEntities();\n\n\tfor (i = 1; i <= MAX_CLIENTS; i++)\n\t{\n\t\tif (botgoalstates[i])\n\t\t{\n\t\t\tBotFreeGoalState(i);\n\t\t} //end if\n\t} //end for\n} //end of the function BotShutdownGoalAI\n"
  },
  {
    "path": "code/botlib/be_ai_move.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_ai_move.c\n *\n * desc:\t\tbot movement AI\n *\n * $Archive: /MissionPack/code/botlib/be_ai_move.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_memory.h\"\n#include \"l_libvar.h\"\n#include \"l_utils.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#include \"aasfile.h\"\n#include \"../game/botlib.h\"\n#include \"../game/be_aas.h\"\n#include \"be_aas_funcs.h\"\n#include \"be_interface.h\"\n\n#include \"../game/be_ea.h\"\n#include \"../game/be_ai_goal.h\"\n#include \"../game/be_ai_move.h\"\n\n\n//#define DEBUG_AI_MOVE\n//#define DEBUG_ELEVATOR\n//#define DEBUG_GRAPPLE\n\n// bk001204 - redundant bot_avoidspot_t, see ../game/be_ai_move.h\n\n//movement state\n//NOTE: the moveflags MFL_ONGROUND, MFL_TELEPORTED, MFL_WATERJUMP and\n//\t\tMFL_GRAPPLEPULL must be set outside the movement code\ntypedef struct bot_movestate_s\n{\n\t//input vars (all set outside the movement code)\n\tvec3_t origin;\t\t\t\t\t\t\t\t//origin of the bot\n\tvec3_t velocity;\t\t\t\t\t\t\t//velocity of the bot\n\tvec3_t viewoffset;\t\t\t\t\t\t\t//view offset\n\tint entitynum;\t\t\t\t\t\t\t\t//entity number of the bot\n\tint client;\t\t\t\t\t\t\t\t\t//client number of the bot\n\tfloat thinktime;\t\t\t\t\t\t\t//time the bot thinks\n\tint presencetype;\t\t\t\t\t\t\t//presencetype of the bot\n\tvec3_t viewangles;\t\t\t\t\t\t\t//view angles of the bot\n\t//state vars\n\tint areanum;\t\t\t\t\t\t\t\t//area the bot is in\n\tint lastareanum;\t\t\t\t\t\t\t//last area the bot was in\n\tint lastgoalareanum;\t\t\t\t\t\t//last goal area number\n\tint lastreachnum;\t\t\t\t\t\t\t//last reachability number\n\tvec3_t lastorigin;\t\t\t\t\t\t\t//origin previous cycle\n\tint reachareanum;\t\t\t\t\t\t\t//area number of the reachabilty\n\tint moveflags;\t\t\t\t\t\t\t\t//movement flags\n\tint jumpreach;\t\t\t\t\t\t\t\t//set when jumped\n\tfloat grapplevisible_time;\t\t\t\t\t//last time the grapple was visible\n\tfloat lastgrappledist;\t\t\t\t\t\t//last distance to the grapple end\n\tfloat reachability_time;\t\t\t\t\t//time to use current reachability\n\tint avoidreach[MAX_AVOIDREACH];\t\t\t\t//reachabilities to avoid\n\tfloat avoidreachtimes[MAX_AVOIDREACH];\t\t//times to avoid the reachabilities\n\tint avoidreachtries[MAX_AVOIDREACH];\t\t//number of tries before avoiding\n\t//\n\tbot_avoidspot_t avoidspots[MAX_AVOIDSPOTS];\t//spots to avoid\n\tint numavoidspots;\n} bot_movestate_t;\n\n//used to avoid reachability links for some time after being used\n#define AVOIDREACH\n#define AVOIDREACH_TIME\t\t\t6\t\t//avoid links for 6 seconds after use\n#define AVOIDREACH_TRIES\t\t4\n//prediction times\n#define PREDICTIONTIME_JUMP\t3\t\t//in seconds\n#define PREDICTIONTIME_MOVE\t2\t\t//in seconds\n//weapon indexes for weapon jumping\n#define WEAPONINDEX_ROCKET_LAUNCHER\t\t5\n#define WEAPONINDEX_BFG\t\t\t\t\t9\n\n#define MODELTYPE_FUNC_PLAT\t\t1\n#define MODELTYPE_FUNC_BOB\t\t2\n#define MODELTYPE_FUNC_DOOR\t\t3\n#define MODELTYPE_FUNC_STATIC\t4\n\nlibvar_t *sv_maxstep;\nlibvar_t *sv_maxbarrier;\nlibvar_t *sv_gravity;\nlibvar_t *weapindex_rocketlauncher;\nlibvar_t *weapindex_bfg10k;\nlibvar_t *weapindex_grapple;\nlibvar_t *entitytypemissile;\nlibvar_t *offhandgrapple;\nlibvar_t *cmd_grappleoff;\nlibvar_t *cmd_grappleon;\n//type of model, func_plat or func_bobbing\nint modeltypes[MAX_MODELS];\n\nbot_movestate_t *botmovestates[MAX_CLIENTS+1];\n\n//========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//========================================================================\nint BotAllocMoveState(void)\n{\n\tint i;\n\n\tfor (i = 1; i <= MAX_CLIENTS; i++)\n\t{\n\t\tif (!botmovestates[i])\n\t\t{\n\t\t\tbotmovestates[i] = GetClearedMemory(sizeof(bot_movestate_t));\n\t\t\treturn i;\n\t\t} //end if\n\t} //end for\n\treturn 0;\n} //end of the function BotAllocMoveState\n//========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//========================================================================\nvoid BotFreeMoveState(int handle)\n{\n\tif (handle <= 0 || handle > MAX_CLIENTS)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"move state handle %d out of range\\n\", handle);\n\t\treturn;\n\t} //end if\n\tif (!botmovestates[handle])\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"invalid move state %d\\n\", handle);\n\t\treturn;\n\t} //end if\n\tFreeMemory(botmovestates[handle]);\n\tbotmovestates[handle] = NULL;\n} //end of the function BotFreeMoveState\n//========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//========================================================================\nbot_movestate_t *BotMoveStateFromHandle(int handle)\n{\n\tif (handle <= 0 || handle > MAX_CLIENTS)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"move state handle %d out of range\\n\", handle);\n\t\treturn NULL;\n\t} //end if\n\tif (!botmovestates[handle])\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"invalid move state %d\\n\", handle);\n\t\treturn NULL;\n\t} //end if\n\treturn botmovestates[handle];\n} //end of the function BotMoveStateFromHandle\n//========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//========================================================================\nvoid BotInitMoveState(int handle, bot_initmove_t *initmove)\n{\n\tbot_movestate_t *ms;\n\n\tms = BotMoveStateFromHandle(handle);\n\tif (!ms) return;\n\tVectorCopy(initmove->origin, ms->origin);\n\tVectorCopy(initmove->velocity, ms->velocity);\n\tVectorCopy(initmove->viewoffset, ms->viewoffset);\n\tms->entitynum = initmove->entitynum;\n\tms->client = initmove->client;\n\tms->thinktime = initmove->thinktime;\n\tms->presencetype = initmove->presencetype;\n\tVectorCopy(initmove->viewangles, ms->viewangles);\n\t//\n\tms->moveflags &= ~MFL_ONGROUND;\n\tif (initmove->or_moveflags & MFL_ONGROUND) ms->moveflags |= MFL_ONGROUND;\n\tms->moveflags &= ~MFL_TELEPORTED;\t\n\tif (initmove->or_moveflags & MFL_TELEPORTED) ms->moveflags |= MFL_TELEPORTED;\n\tms->moveflags &= ~MFL_WATERJUMP;\n\tif (initmove->or_moveflags & MFL_WATERJUMP) ms->moveflags |= MFL_WATERJUMP;\n\tms->moveflags &= ~MFL_WALK;\n\tif (initmove->or_moveflags & MFL_WALK) ms->moveflags |= MFL_WALK;\n\tms->moveflags &= ~MFL_GRAPPLEPULL;\n\tif (initmove->or_moveflags & MFL_GRAPPLEPULL) ms->moveflags |= MFL_GRAPPLEPULL;\n} //end of the function BotInitMoveState\n//========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//========================================================================\nfloat AngleDiff(float ang1, float ang2)\n{\n\tfloat diff;\n\n\tdiff = ang1 - ang2;\n\tif (ang1 > ang2)\n\t{\n\t\tif (diff > 180.0) diff -= 360.0;\n\t} //end if\n\telse\n\t{\n\t\tif (diff < -180.0) diff += 360.0;\n\t} //end else\n\treturn diff;\n} //end of the function AngleDiff\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotFuzzyPointReachabilityArea(vec3_t origin)\n{\n\tint firstareanum, j, x, y, z;\n\tint areas[10], numareas, areanum, bestareanum;\n\tfloat dist, bestdist;\n\tvec3_t points[10], v, end;\n\n\tfirstareanum = 0;\n\tareanum = AAS_PointAreaNum(origin);\n\tif (areanum)\n\t{\n\t\tfirstareanum = areanum;\n\t\tif (AAS_AreaReachability(areanum)) return areanum;\n\t} //end if\n\tVectorCopy(origin, end);\n\tend[2] += 4;\n\tnumareas = AAS_TraceAreas(origin, end, areas, points, 10);\n\tfor (j = 0; j < numareas; j++)\n\t{\n\t\tif (AAS_AreaReachability(areas[j])) return areas[j];\n\t} //end for\n\tbestdist = 999999;\n\tbestareanum = 0;\n\tfor (z = 1; z >= -1; z -= 1)\n\t{\n\t\tfor (x = 1; x >= -1; x -= 1)\n\t\t{\n\t\t\tfor (y = 1; y >= -1; y -= 1)\n\t\t\t{\n\t\t\t\tVectorCopy(origin, end);\n\t\t\t\tend[0] += x * 8;\n\t\t\t\tend[1] += y * 8;\n\t\t\t\tend[2] += z * 12;\n\t\t\t\tnumareas = AAS_TraceAreas(origin, end, areas, points, 10);\n\t\t\t\tfor (j = 0; j < numareas; j++)\n\t\t\t\t{\n\t\t\t\t\tif (AAS_AreaReachability(areas[j]))\n\t\t\t\t\t{\n\t\t\t\t\t\tVectorSubtract(points[j], origin, v);\n\t\t\t\t\t\tdist = VectorLength(v);\n\t\t\t\t\t\tif (dist < bestdist)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tbestareanum = areas[j];\n\t\t\t\t\t\t\tbestdist = dist;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end if\n\t\t\t\t\tif (!firstareanum) firstareanum = areas[j];\n\t\t\t\t} //end for\n\t\t\t} //end for\n\t\t} //end for\n\t\tif (bestareanum) return bestareanum;\n\t} //end for\n\treturn firstareanum;\n} //end of the function BotFuzzyPointReachabilityArea\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotReachabilityArea(vec3_t origin, int client)\n{\n\tint modelnum, modeltype, reachnum, areanum;\n\taas_reachability_t reach;\n\tvec3_t org, end, mins, maxs, up = {0, 0, 1};\n\tbsp_trace_t bsptrace;\n\taas_trace_t trace;\n\n\t//check if the bot is standing on something\n\tAAS_PresenceTypeBoundingBox(PRESENCE_CROUCH, mins, maxs);\n\tVectorMA(origin, -3, up, end);\n\tbsptrace = AAS_Trace(origin, mins, maxs, end, client, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);\n\tif (!bsptrace.startsolid && bsptrace.fraction < 1 && bsptrace.ent != ENTITYNUM_NONE)\n\t{\n\t\t//if standing on the world the bot should be in a valid area\n\t\tif (bsptrace.ent == ENTITYNUM_WORLD)\n\t\t{\n\t\t\treturn BotFuzzyPointReachabilityArea(origin);\n\t\t} //end if\n\n\t\tmodelnum = AAS_EntityModelindex(bsptrace.ent);\n\t\tmodeltype = modeltypes[modelnum];\n\n\t\t//if standing on a func_plat or func_bobbing then the bot is assumed to be\n\t\t//in the area the reachability points to\n\t\tif (modeltype == MODELTYPE_FUNC_PLAT || modeltype == MODELTYPE_FUNC_BOB)\n\t\t{\n\t\t\treachnum = AAS_NextModelReachability(0, modelnum);\n\t\t\tif (reachnum)\n\t\t\t{\n\t\t\t\tAAS_ReachabilityFromNum(reachnum, &reach);\n\t\t\t\treturn reach.areanum;\n\t\t\t} //end if\n\t\t} //end else if\n\n\t\t//if the bot is swimming the bot should be in a valid area\n\t\tif (AAS_Swimming(origin))\n\t\t{\n\t\t\treturn BotFuzzyPointReachabilityArea(origin);\n\t\t} //end if\n\t\t//\n\t\tareanum = BotFuzzyPointReachabilityArea(origin);\n\t\t//if the bot is in an area with reachabilities\n\t\tif (areanum && AAS_AreaReachability(areanum)) return areanum;\n\t\t//trace down till the ground is hit because the bot is standing on some other entity\n\t\tVectorCopy(origin, org);\n\t\tVectorCopy(org, end);\n\t\tend[2] -= 800;\n\t\ttrace = AAS_TraceClientBBox(org, end, PRESENCE_CROUCH, -1);\n\t\tif (!trace.startsolid)\n\t\t{\n\t\t\tVectorCopy(trace.endpos, org);\n\t\t} //end if\n\t\t//\n\t\treturn BotFuzzyPointReachabilityArea(org);\n\t} //end if\n\t//\n\treturn BotFuzzyPointReachabilityArea(origin);\n} //end of the function BotReachabilityArea\n//===========================================================================\n// returns the reachability area the bot is in\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n/*\nint BotReachabilityArea(vec3_t origin, int testground)\n{\n\tint firstareanum, i, j, x, y, z;\n\tint areas[10], numareas, areanum, bestareanum;\n\tfloat dist, bestdist;\n\tvec3_t org, end, points[10], v;\n\taas_trace_t trace;\n\n\tfirstareanum = 0;\n\tfor (i = 0; i < 2; i++)\n\t{\n\t\tVectorCopy(origin, org);\n\t\t//if test at the ground (used when bot is standing on an entity)\n\t\tif (i > 0)\n\t\t{\n\t\t\tVectorCopy(origin, end);\n\t\t\tend[2] -= 800;\n\t\t\ttrace = AAS_TraceClientBBox(origin, end, PRESENCE_CROUCH, -1);\n\t\t\tif (!trace.startsolid)\n\t\t\t{\n\t\t\t\tVectorCopy(trace.endpos, org);\n\t\t\t} //end if\n\t\t} //end if\n\n\t\tfirstareanum = 0;\n\t\tareanum = AAS_PointAreaNum(org);\n\t\tif (areanum)\n\t\t{\n\t\t\tfirstareanum = areanum;\n\t\t\tif (AAS_AreaReachability(areanum)) return areanum;\n\t\t} //end if\n\t\tbestdist = 999999;\n\t\tbestareanum = 0;\n\t\tfor (z = 1; z >= -1; z -= 1)\n\t\t{\n\t\t\tfor (x = 1; x >= -1; x -= 1)\n\t\t\t{\n\t\t\t\tfor (y = 1; y >= -1; y -= 1)\n\t\t\t\t{\n\t\t\t\t\tVectorCopy(org, end);\n\t\t\t\t\tend[0] += x * 8;\n\t\t\t\t\tend[1] += y * 8;\n\t\t\t\t\tend[2] += z * 12;\n\t\t\t\t\tnumareas = AAS_TraceAreas(org, end, areas, points, 10);\n\t\t\t\t\tfor (j = 0; j < numareas; j++)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (AAS_AreaReachability(areas[j]))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tVectorSubtract(points[j], org, v);\n\t\t\t\t\t\t\tdist = VectorLength(v);\n\t\t\t\t\t\t\tif (dist < bestdist)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbestareanum = areas[j];\n\t\t\t\t\t\t\t\tbestdist = dist;\n\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end for\n\t\t\t\t} //end for\n\t\t\t} //end for\n\t\t\tif (bestareanum) return bestareanum;\n\t\t} //end for\n\t\tif (!testground) break;\n\t} //end for\n//#ifdef DEBUG\n\t//botimport.Print(PRT_MESSAGE, \"no reachability area\\n\");\n//#endif //DEBUG\n\treturn firstareanum;\n} //end of the function BotReachabilityArea*/\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotOnMover(vec3_t origin, int entnum, aas_reachability_t *reach)\n{\n\tint i, modelnum;\n\tvec3_t mins, maxs, modelorigin, org, end;\n\tvec3_t angles = {0, 0, 0};\n\tvec3_t boxmins = {-16, -16, -8}, boxmaxs = {16, 16, 8};\n\tbsp_trace_t trace;\n\n\tmodelnum = reach->facenum & 0x0000FFFF;\n\t//get some bsp model info\n\tAAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, NULL);\n\t//\n\tif (!AAS_OriginOfMoverWithModelNum(modelnum, modelorigin))\n\t{\n\t\tbotimport.Print(PRT_MESSAGE, \"no entity with model %d\\n\", modelnum);\n\t\treturn qfalse;\n\t} //end if\n\t//\n\tfor (i = 0; i < 2; i++)\n\t{\n\t\tif (origin[i] > modelorigin[i] + maxs[i] + 16) return qfalse;\n\t\tif (origin[i] < modelorigin[i] + mins[i] - 16) return qfalse;\n\t} //end for\n\t//\n\tVectorCopy(origin, org);\n\torg[2] += 24;\n\tVectorCopy(origin, end);\n\tend[2] -= 48;\n\t//\n\ttrace = AAS_Trace(org, boxmins, boxmaxs, end, entnum, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);\n\tif (!trace.startsolid && !trace.allsolid)\n\t{\n\t\t//NOTE: the reachability face number is the model number of the elevator\n\t\tif (trace.ent != ENTITYNUM_NONE && AAS_EntityModelNum(trace.ent) == modelnum)\n\t\t{\n\t\t\treturn qtrue;\n\t\t} //end if\n\t} //end if\n\treturn qfalse;\n} //end of the function BotOnMover\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint MoverDown(aas_reachability_t *reach)\n{\n\tint modelnum;\n\tvec3_t mins, maxs, origin;\n\tvec3_t angles = {0, 0, 0};\n\n\tmodelnum = reach->facenum & 0x0000FFFF;\n\t//get some bsp model info\n\tAAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, origin);\n\t//\n\tif (!AAS_OriginOfMoverWithModelNum(modelnum, origin))\n\t{\n\t\tbotimport.Print(PRT_MESSAGE, \"no entity with model %d\\n\", modelnum);\n\t\treturn qfalse;\n\t} //end if\n\t//if the top of the plat is below the reachability start point\n\tif (origin[2] + maxs[2] < reach->start[2]) return qtrue;\n\treturn qfalse;\n} //end of the function MoverDown\n//========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//========================================================================\nvoid BotSetBrushModelTypes(void)\n{\n\tint ent, modelnum;\n\tchar classname[MAX_EPAIRKEY], model[MAX_EPAIRKEY];\n\n\tCom_Memset(modeltypes, 0, MAX_MODELS * sizeof(int));\n\t//\n\tfor (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent))\n\t{\n\t\tif (!AAS_ValueForBSPEpairKey(ent, \"classname\", classname, MAX_EPAIRKEY)) continue;\n\t\tif (!AAS_ValueForBSPEpairKey(ent, \"model\", model, MAX_EPAIRKEY)) continue;\n\t\tif (model[0]) modelnum = atoi(model+1);\n\t\telse modelnum = 0;\n\n\t\tif (modelnum < 0 || modelnum > MAX_MODELS)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"entity %s model number out of range\\n\", classname);\n\t\t\tcontinue;\n\t\t} //end if\n\n\t\tif (!Q_stricmp(classname, \"func_bobbing\"))\n\t\t\tmodeltypes[modelnum] = MODELTYPE_FUNC_BOB;\n\t\telse if (!Q_stricmp(classname, \"func_plat\"))\n\t\t\tmodeltypes[modelnum] = MODELTYPE_FUNC_PLAT;\n\t\telse if (!Q_stricmp(classname, \"func_door\"))\n\t\t\tmodeltypes[modelnum] = MODELTYPE_FUNC_DOOR;\n\t\telse if (!Q_stricmp(classname, \"func_static\"))\n\t\t\tmodeltypes[modelnum] = MODELTYPE_FUNC_STATIC;\n\t} //end for\n} //end of the function BotSetBrushModelTypes\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotOnTopOfEntity(bot_movestate_t *ms)\n{\n\tvec3_t mins, maxs, end, up = {0, 0, 1};\n\tbsp_trace_t trace;\n\n\tAAS_PresenceTypeBoundingBox(ms->presencetype, mins, maxs);\n\tVectorMA(ms->origin, -3, up, end);\n\ttrace = AAS_Trace(ms->origin, mins, maxs, end, ms->entitynum, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);\n\tif (!trace.startsolid && (trace.ent != ENTITYNUM_WORLD && trace.ent != ENTITYNUM_NONE) )\n\t{\n\t\treturn trace.ent;\n\t} //end if\n\treturn -1;\n} //end of the function BotOnTopOfEntity\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotValidTravel(vec3_t origin, aas_reachability_t *reach, int travelflags)\n{\n\t//if the reachability uses an unwanted travel type\n\tif (AAS_TravelFlagForType(reach->traveltype) & ~travelflags) return qfalse;\n\t//don't go into areas with bad travel types\n\tif (AAS_AreaContentsTravelFlags(reach->areanum) & ~travelflags) return qfalse;\n\treturn qtrue;\n} //end of the function BotValidTravel\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotAddToAvoidReach(bot_movestate_t *ms, int number, float avoidtime)\n{\n\tint i;\n\n\tfor (i = 0; i < MAX_AVOIDREACH; i++)\n\t{\n\t\tif (ms->avoidreach[i] == number)\n\t\t{\n\t\t\tif (ms->avoidreachtimes[i] > AAS_Time()) ms->avoidreachtries[i]++;\n\t\t\telse ms->avoidreachtries[i] = 1;\n\t\t\tms->avoidreachtimes[i] = AAS_Time() + avoidtime;\n\t\t\treturn;\n\t\t} //end if\n\t} //end for\n\t//add the reachability to the reachabilities to avoid for a while\n\tfor (i = 0; i < MAX_AVOIDREACH; i++)\n\t{\n\t\tif (ms->avoidreachtimes[i] < AAS_Time())\n\t\t{\n\t\t\tms->avoidreach[i] = number;\n\t\t\tms->avoidreachtimes[i] = AAS_Time() + avoidtime;\n\t\t\tms->avoidreachtries[i] = 1;\n\t\t\treturn;\n\t\t} //end if\n\t} //end for\n} //end of the function BotAddToAvoidReach\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat DistanceFromLineSquared(vec3_t p, vec3_t lp1, vec3_t lp2)\n{\n\tvec3_t proj, dir;\n\tint j;\n\n\tAAS_ProjectPointOntoVector(p, lp1, lp2, proj);\n\tfor (j = 0; j < 3; j++)\n\t\tif ((proj[j] > lp1[j] && proj[j] > lp2[j]) ||\n\t\t\t(proj[j] < lp1[j] && proj[j] < lp2[j]))\n\t\t\tbreak;\n\tif (j < 3) {\n\t\tif (fabs(proj[j] - lp1[j]) < fabs(proj[j] - lp2[j]))\n\t\t\tVectorSubtract(p, lp1, dir);\n\t\telse\n\t\t\tVectorSubtract(p, lp2, dir);\n\t\treturn VectorLengthSquared(dir);\n\t}\n\tVectorSubtract(p, proj, dir);\n\treturn VectorLengthSquared(dir);\n} //end of the function DistanceFromLineSquared\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat VectorDistanceSquared(vec3_t p1, vec3_t p2)\n{\n\tvec3_t dir;\n\tVectorSubtract(p2, p1, dir);\n\treturn VectorLengthSquared(dir);\n} //end of the function VectorDistanceSquared\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotAvoidSpots(vec3_t origin, aas_reachability_t *reach, bot_avoidspot_t *avoidspots, int numavoidspots)\n{\n\tint checkbetween, i, type;\n\tfloat squareddist, squaredradius;\n\n\tswitch(reach->traveltype & TRAVELTYPE_MASK)\n\t{\n\t\tcase TRAVEL_WALK: checkbetween = qtrue; break;\n\t\tcase TRAVEL_CROUCH: checkbetween = qtrue; break;\n\t\tcase TRAVEL_BARRIERJUMP: checkbetween = qtrue; break;\n\t\tcase TRAVEL_LADDER: checkbetween = qtrue; break;\n\t\tcase TRAVEL_WALKOFFLEDGE: checkbetween = qfalse; break;\n\t\tcase TRAVEL_JUMP: checkbetween = qfalse; break;\n\t\tcase TRAVEL_SWIM: checkbetween = qtrue; break;\n\t\tcase TRAVEL_WATERJUMP: checkbetween = qtrue; break;\n\t\tcase TRAVEL_TELEPORT: checkbetween = qfalse; break;\n\t\tcase TRAVEL_ELEVATOR: checkbetween = qfalse; break;\n\t\tcase TRAVEL_GRAPPLEHOOK: checkbetween = qfalse; break;\n\t\tcase TRAVEL_ROCKETJUMP: checkbetween = qfalse; break;\n\t\tcase TRAVEL_BFGJUMP: checkbetween = qfalse; break;\n\t\tcase TRAVEL_JUMPPAD: checkbetween = qfalse; break;\n\t\tcase TRAVEL_FUNCBOB: checkbetween = qfalse; break;\n\t\tdefault: checkbetween = qtrue; break;\n\t} //end switch\n\n\ttype = AVOID_CLEAR;\n\tfor (i = 0; i < numavoidspots; i++)\n\t{\n\t\tsquaredradius = Square(avoidspots[i].radius);\n\t\tsquareddist = DistanceFromLineSquared(avoidspots[i].origin, origin, reach->start);\n\t\t// if moving towards the avoid spot\n\t\tif (squareddist < squaredradius &&\n\t\t\tVectorDistanceSquared(avoidspots[i].origin, origin) > squareddist)\n\t\t{\n\t\t\ttype = avoidspots[i].type;\n\t\t} //end if\n\t\telse if (checkbetween) {\n\t\t\tsquareddist = DistanceFromLineSquared(avoidspots[i].origin, reach->start, reach->end);\n\t\t\t// if moving towards the avoid spot\n\t\t\tif (squareddist < squaredradius &&\n\t\t\t\tVectorDistanceSquared(avoidspots[i].origin, reach->start) > squareddist)\n\t\t\t{\n\t\t\t\ttype = avoidspots[i].type;\n\t\t\t} //end if\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tVectorDistanceSquared(avoidspots[i].origin, reach->end);\n\t\t\t// if the reachability leads closer to the avoid spot\n\t\t\tif (squareddist < squaredradius && \n\t\t\t\tVectorDistanceSquared(avoidspots[i].origin, reach->start) > squareddist)\n\t\t\t{\n\t\t\t\ttype = avoidspots[i].type;\n\t\t\t} //end if\n\t\t} //end else\n\t\tif (type == AVOID_ALWAYS)\n\t\t\treturn type;\n\t} //end for\n\treturn type;\n} //end of the function BotAvoidSpots\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotAddAvoidSpot(int movestate, vec3_t origin, float radius, int type)\n{\n\tbot_movestate_t *ms;\n\n\tms = BotMoveStateFromHandle(movestate);\n\tif (!ms) return;\n\tif (type == AVOID_CLEAR)\n\t{\n\t\tms->numavoidspots = 0;\n\t\treturn;\n\t} //end if\n\n\tif (ms->numavoidspots >= MAX_AVOIDSPOTS)\n\t\treturn;\n\tVectorCopy(origin, ms->avoidspots[ms->numavoidspots].origin);\n\tms->avoidspots[ms->numavoidspots].radius = radius;\n\tms->avoidspots[ms->numavoidspots].type = type;\n\tms->numavoidspots++;\n} //end of the function BotAddAvoidSpot\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotGetReachabilityToGoal(vec3_t origin, int areanum,\n\t\t\t\t\t\t\t\t\t  int lastgoalareanum, int lastareanum,\n\t\t\t\t\t\t\t\t\t  int *avoidreach, float *avoidreachtimes, int *avoidreachtries,\n\t\t\t\t\t\t\t\t\t  bot_goal_t *goal, int travelflags, int movetravelflags,\n\t\t\t\t\t\t\t\t\t  struct bot_avoidspot_s *avoidspots, int numavoidspots, int *flags)\n{\n\tint i, t, besttime, bestreachnum, reachnum;\n\taas_reachability_t reach;\n\n\t//if not in a valid area\n\tif (!areanum) return 0;\n\t//\n\tif (AAS_AreaDoNotEnter(areanum) || AAS_AreaDoNotEnter(goal->areanum))\n\t{\n\t\ttravelflags |= TFL_DONOTENTER;\n\t\tmovetravelflags |= TFL_DONOTENTER;\n\t} //end if\n\t//use the routing to find the next area to go to\n\tbesttime = 0;\n\tbestreachnum = 0;\n\t//\n\tfor (reachnum = AAS_NextAreaReachability(areanum, 0); reachnum;\n\t\treachnum = AAS_NextAreaReachability(areanum, reachnum))\n\t{\n#ifdef AVOIDREACH\n\t\t//check if it isn't an reachability to avoid\n\t\tfor (i = 0; i < MAX_AVOIDREACH; i++)\n\t\t{\n\t\t\tif (avoidreach[i] == reachnum && avoidreachtimes[i] >= AAS_Time()) break;\n\t\t} //end for\n\t\tif (i != MAX_AVOIDREACH && avoidreachtries[i] > AVOIDREACH_TRIES)\n\t\t{\n#ifdef DEBUG\n\t\t\tif (bot_developer)\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_MESSAGE, \"avoiding reachability %d\\n\", avoidreach[i]);\n\t\t\t} //end if\n#endif //DEBUG\n\t\t\tcontinue;\n\t\t} //end if\n#endif //AVOIDREACH\n\t\t//get the reachability from the number\n\t\tAAS_ReachabilityFromNum(reachnum, &reach);\n\t\t//NOTE: do not go back to the previous area if the goal didn't change\n\t\t//NOTE: is this actually avoidance of local routing minima between two areas???\n\t\tif (lastgoalareanum == goal->areanum && reach.areanum == lastareanum) continue;\n\t\t//if (AAS_AreaContentsTravelFlags(reach.areanum) & ~travelflags) continue;\n\t\t//if the travel isn't valid\n\t\tif (!BotValidTravel(origin, &reach, movetravelflags)) continue;\n\t\t//get the travel time\n\t\tt = AAS_AreaTravelTimeToGoalArea(reach.areanum, reach.end, goal->areanum, travelflags);\n\t\t//if the goal area isn't reachable from the reachable area\n\t\tif (!t) continue;\n\t\t//if the bot should not use this reachability to avoid bad spots\n\t\tif (BotAvoidSpots(origin, &reach, avoidspots, numavoidspots)) {\n\t\t\tif (flags) {\n\t\t\t\t*flags |= MOVERESULT_BLOCKEDBYAVOIDSPOT;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\t//add the travel time towards the area\n\t\tt += reach.traveltime;// + AAS_AreaTravelTime(areanum, origin, reach.start);\n\t\t//if the travel time is better than the ones already found\n\t\tif (!besttime || t < besttime)\n\t\t{\n\t\t\tbesttime = t;\n\t\t\tbestreachnum = reachnum;\n\t\t} //end if\n\t} //end for\n\t//\n\treturn bestreachnum;\n} //end of the function BotGetReachabilityToGoal\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotAddToTarget(vec3_t start, vec3_t end, float maxdist, float *dist, vec3_t target)\n{\n\tvec3_t dir;\n\tfloat curdist;\n\n\tVectorSubtract(end, start, dir);\n\tcurdist = VectorNormalize(dir);\n\tif (*dist + curdist < maxdist)\n\t{\n\t\tVectorCopy(end, target);\n\t\t*dist += curdist;\n\t\treturn qfalse;\n\t} //end if\n\telse\n\t{\n\t\tVectorMA(start, maxdist - *dist, dir, target);\n\t\t*dist = maxdist;\n\t\treturn qtrue;\n\t} //end else\n} //end of the function BotAddToTarget\n\nint BotMovementViewTarget(int movestate, bot_goal_t *goal, int travelflags, float lookahead, vec3_t target)\n{\n\taas_reachability_t reach;\n\tint reachnum, lastareanum;\n\tbot_movestate_t *ms;\n\tvec3_t end;\n\tfloat dist;\n\n\tms = BotMoveStateFromHandle(movestate);\n\tif (!ms) return qfalse;\n\treachnum = 0;\n\t//if the bot has no goal or no last reachability\n\tif (!ms->lastreachnum || !goal) return qfalse;\n\n\treachnum = ms->lastreachnum;\n\tVectorCopy(ms->origin, end);\n\tlastareanum = ms->lastareanum;\n\tdist = 0;\n\twhile(reachnum && dist < lookahead)\n\t{\n\t\tAAS_ReachabilityFromNum(reachnum, &reach);\n\t\tif (BotAddToTarget(end, reach.start, lookahead, &dist, target)) return qtrue;\n\t\t//never look beyond teleporters\n\t\tif ((reach.traveltype & TRAVELTYPE_MASK) == TRAVEL_TELEPORT) return qtrue;\n\t\t//never look beyond the weapon jump point\n\t\tif ((reach.traveltype & TRAVELTYPE_MASK) == TRAVEL_ROCKETJUMP) return qtrue;\n\t\tif ((reach.traveltype & TRAVELTYPE_MASK) == TRAVEL_BFGJUMP) return qtrue;\n\t\t//don't add jump pad distances\n\t\tif ((reach.traveltype & TRAVELTYPE_MASK) != TRAVEL_JUMPPAD &&\n\t\t\t(reach.traveltype & TRAVELTYPE_MASK) != TRAVEL_ELEVATOR &&\n\t\t\t(reach.traveltype & TRAVELTYPE_MASK) != TRAVEL_FUNCBOB)\n\t\t{\n\t\t\tif (BotAddToTarget(reach.start, reach.end, lookahead, &dist, target)) return qtrue;\n\t\t} //end if\n\t\treachnum = BotGetReachabilityToGoal(reach.end, reach.areanum,\n\t\t\t\t\t\tms->lastgoalareanum, lastareanum,\n\t\t\t\t\t\t\tms->avoidreach, ms->avoidreachtimes, ms->avoidreachtries,\n\t\t\t\t\t\t\t\t\tgoal, travelflags, travelflags, NULL, 0, NULL);\n\t\tVectorCopy(reach.end, end);\n\t\tlastareanum = reach.areanum;\n\t\tif (lastareanum == goal->areanum)\n\t\t{\n\t\t\tBotAddToTarget(reach.end, goal->origin, lookahead, &dist, target);\n\t\t\treturn qtrue;\n\t\t} //end if\n\t} //end while\n\t//\n\treturn qfalse;\n} //end of the function BotMovementViewTarget\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotVisible(int ent, vec3_t eye, vec3_t target)\n{\n\tbsp_trace_t trace;\n\n\ttrace = AAS_Trace(eye, NULL, NULL, target, ent, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);\n\tif (trace.fraction >= 1) return qtrue;\n\treturn qfalse;\n} //end of the function BotVisible\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotPredictVisiblePosition(vec3_t origin, int areanum, bot_goal_t *goal, int travelflags, vec3_t target)\n{\n\taas_reachability_t reach;\n\tint reachnum, lastgoalareanum, lastareanum, i;\n\tint avoidreach[MAX_AVOIDREACH];\n\tfloat avoidreachtimes[MAX_AVOIDREACH];\n\tint avoidreachtries[MAX_AVOIDREACH];\n\tvec3_t end;\n\n\t//if the bot has no goal or no last reachability\n\tif (!goal) return qfalse;\n\t//if the areanum is not valid\n\tif (!areanum) return qfalse;\n\t//if the goal areanum is not valid\n\tif (!goal->areanum) return qfalse;\n\n\tCom_Memset(avoidreach, 0, MAX_AVOIDREACH * sizeof(int));\n\tlastgoalareanum = goal->areanum;\n\tlastareanum = areanum;\n\tVectorCopy(origin, end);\n\t//only do 20 hops\n\tfor (i = 0; i < 20 && (areanum != goal->areanum); i++)\n\t{\n\t\t//\n\t\treachnum = BotGetReachabilityToGoal(end, areanum,\n\t\t\t\t\t\tlastgoalareanum, lastareanum,\n\t\t\t\t\t\t\tavoidreach, avoidreachtimes, avoidreachtries,\n\t\t\t\t\t\t\t\t\tgoal, travelflags, travelflags, NULL, 0, NULL);\n\t\tif (!reachnum) return qfalse;\n\t\tAAS_ReachabilityFromNum(reachnum, &reach);\n\t\t//\n\t\tif (BotVisible(goal->entitynum, goal->origin, reach.start))\n\t\t{\n\t\t\tVectorCopy(reach.start, target);\n\t\t\treturn qtrue;\n\t\t} //end if\n\t\t//\n\t\tif (BotVisible(goal->entitynum, goal->origin, reach.end))\n\t\t{\n\t\t\tVectorCopy(reach.end, target);\n\t\t\treturn qtrue;\n\t\t} //end if\n\t\t//\n\t\tif (reach.areanum == goal->areanum)\n\t\t{\n\t\t\tVectorCopy(reach.end, target);\n\t\t\treturn qtrue;\n\t\t} //end if\n\t\t//\n\t\tlastareanum = areanum;\n\t\tareanum = reach.areanum;\n\t\tVectorCopy(reach.end, end);\n\t\t//\n\t} //end while\n\t//\n\treturn qfalse;\n} //end of the function BotPredictVisiblePosition\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid MoverBottomCenter(aas_reachability_t *reach, vec3_t bottomcenter)\n{\n\tint modelnum;\n\tvec3_t mins, maxs, origin, mids;\n\tvec3_t angles = {0, 0, 0};\n\n\tmodelnum = reach->facenum & 0x0000FFFF;\n\t//get some bsp model info\n\tAAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, origin);\n\t//\n\tif (!AAS_OriginOfMoverWithModelNum(modelnum, origin))\n\t{\n\t\tbotimport.Print(PRT_MESSAGE, \"no entity with model %d\\n\", modelnum);\n\t} //end if\n\t//get a point just above the plat in the bottom position\n\tVectorAdd(mins, maxs, mids);\n\tVectorMA(origin, 0.5, mids, bottomcenter);\n\tbottomcenter[2] = reach->start[2];\n} //end of the function MoverBottomCenter\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat BotGapDistance(vec3_t origin, vec3_t hordir, int entnum)\n{\n\tfloat dist, startz;\n\tvec3_t start, end;\n\taas_trace_t trace;\n\n\t//do gap checking\n\tstartz = origin[2];\n\t//this enables walking down stairs more fluidly\n\t{\n\t\tVectorCopy(origin, start);\n\t\tVectorCopy(origin, end);\n\t\tend[2] -= 60;\n\t\ttrace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, entnum);\n\t\tif (trace.fraction >= 1) return 1;\n\t\tstartz = trace.endpos[2] + 1;\n\t}\n\t//\n\tfor (dist = 8; dist <= 100; dist += 8)\n\t{\n\t\tVectorMA(origin, dist, hordir, start);\n\t\tstart[2] = startz + 24;\n\t\tVectorCopy(start, end);\n\t\tend[2] -= 48 + sv_maxbarrier->value;\n\t\ttrace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, entnum);\n\t\t//if solid is found the bot can't walk any further and fall into a gap\n\t\tif (!trace.startsolid)\n\t\t{\n\t\t\t//if it is a gap\n\t\t\tif (trace.endpos[2] < startz - sv_maxstep->value - 8)\n\t\t\t{\n\t\t\t\tVectorCopy(trace.endpos, end);\n\t\t\t\tend[2] -= 20;\n\t\t\t\tif (AAS_PointContents(end) & CONTENTS_WATER) break;\n\t\t\t\t//if a gap is found slow down\n\t\t\t\t//botimport.Print(PRT_MESSAGE, \"gap at %f\\n\", dist);\n\t\t\t\treturn dist;\n\t\t\t} //end if\n\t\t\tstartz = trace.endpos[2];\n\t\t} //end if\n\t} //end for\n\treturn 0;\n} //end of the function BotGapDistance\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotCheckBarrierJump(bot_movestate_t *ms, vec3_t dir, float speed)\n{\n\tvec3_t start, hordir, end;\n\taas_trace_t trace;\n\n\tVectorCopy(ms->origin, end);\n\tend[2] += sv_maxbarrier->value;\n\t//trace right up\n\ttrace = AAS_TraceClientBBox(ms->origin, end, PRESENCE_NORMAL, ms->entitynum);\n\t//this shouldn't happen... but we check anyway\n\tif (trace.startsolid) return qfalse;\n\t//if very low ceiling it isn't possible to jump up to a barrier\n\tif (trace.endpos[2] - ms->origin[2] < sv_maxstep->value) return qfalse;\n\t//\n\thordir[0] = dir[0];\n\thordir[1] = dir[1];\n\thordir[2] = 0;\n\tVectorNormalize(hordir);\n\tVectorMA(ms->origin, ms->thinktime * speed * 0.5, hordir, end);\n\tVectorCopy(trace.endpos, start);\n\tend[2] = trace.endpos[2];\n\t//trace from previous trace end pos horizontally in the move direction\n\ttrace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, ms->entitynum);\n\t//again this shouldn't happen\n\tif (trace.startsolid) return qfalse;\n\t//\n\tVectorCopy(trace.endpos, start);\n\tVectorCopy(trace.endpos, end);\n\tend[2] = ms->origin[2];\n\t//trace down from the previous trace end pos\n\ttrace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, ms->entitynum);\n\t//if solid\n\tif (trace.startsolid) return qfalse;\n\t//if no obstacle at all\n\tif (trace.fraction >= 1.0) return qfalse;\n\t//if less than the maximum step height\n\tif (trace.endpos[2] - ms->origin[2] < sv_maxstep->value) return qfalse;\n\t//\n\tEA_Jump(ms->client);\n\tEA_Move(ms->client, hordir, speed);\n\tms->moveflags |= MFL_BARRIERJUMP;\n\t//there is a barrier\n\treturn qtrue;\n} //end of the function BotCheckBarrierJump\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotSwimInDirection(bot_movestate_t *ms, vec3_t dir, float speed, int type)\n{\n\tvec3_t normdir;\n\n\tVectorCopy(dir, normdir);\n\tVectorNormalize(normdir);\n\tEA_Move(ms->client, normdir, speed);\n\treturn qtrue;\n} //end of the function BotSwimInDirection\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotWalkInDirection(bot_movestate_t *ms, vec3_t dir, float speed, int type)\n{\n\tvec3_t hordir, cmdmove, velocity, tmpdir, origin;\n\tint presencetype, maxframes, cmdframes, stopevent;\n\taas_clientmove_t move;\n\tfloat dist;\n\n\tif (AAS_OnGround(ms->origin, ms->presencetype, ms->entitynum)) ms->moveflags |= MFL_ONGROUND;\n\t//if the bot is on the ground\n\tif (ms->moveflags & MFL_ONGROUND)\n\t{\n\t\t//if there is a barrier the bot can jump on\n\t\tif (BotCheckBarrierJump(ms, dir, speed)) return qtrue;\n\t\t//remove barrier jump flag\n\t\tms->moveflags &= ~MFL_BARRIERJUMP;\n\t\t//get the presence type for the movement\n\t\tif ((type & MOVE_CROUCH) && !(type & MOVE_JUMP)) presencetype = PRESENCE_CROUCH;\n\t\telse presencetype = PRESENCE_NORMAL;\n\t\t//horizontal direction\n\t\thordir[0] = dir[0];\n\t\thordir[1] = dir[1];\n\t\thordir[2] = 0;\n\t\tVectorNormalize(hordir);\n\t\t//if the bot is not supposed to jump\n\t\tif (!(type & MOVE_JUMP))\n\t\t{\n\t\t\t//if there is a gap, try to jump over it\n\t\t\tif (BotGapDistance(ms->origin, hordir, ms->entitynum) > 0) type |= MOVE_JUMP;\n\t\t} //end if\n\t\t//get command movement\n\t\tVectorScale(hordir, speed, cmdmove);\n\t\tVectorCopy(ms->velocity, velocity);\n\t\t//\n\t\tif (type & MOVE_JUMP)\n\t\t{\n\t\t\t//botimport.Print(PRT_MESSAGE, \"trying jump\\n\");\n\t\t\tcmdmove[2] = 400;\n\t\t\tmaxframes = PREDICTIONTIME_JUMP / 0.1;\n\t\t\tcmdframes = 1;\n\t\t\tstopevent = SE_HITGROUND|SE_HITGROUNDDAMAGE|\n\t\t\t\t\t\tSE_ENTERWATER|SE_ENTERSLIME|SE_ENTERLAVA;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tmaxframes = 2;\n\t\t\tcmdframes = 2;\n\t\t\tstopevent = SE_HITGROUNDDAMAGE|\n\t\t\t\t\t\tSE_ENTERWATER|SE_ENTERSLIME|SE_ENTERLAVA;\n\t\t} //end else\n\t\t//AAS_ClearShownDebugLines();\n\t\t//\n\t\tVectorCopy(ms->origin, origin);\n\t\torigin[2] += 0.5;\n\t\tAAS_PredictClientMovement(&move, ms->entitynum, origin, presencetype, qtrue,\n\t\t\t\t\t\t\t\t\tvelocity, cmdmove, cmdframes, maxframes, 0.1f,\n\t\t\t\t\t\t\t\t\tstopevent, 0, qfalse);//qtrue);\n\t\t//if prediction time wasn't enough to fully predict the movement\n\t\tif (move.frames >= maxframes && (type & MOVE_JUMP))\n\t\t{\n\t\t\t//botimport.Print(PRT_MESSAGE, \"client %d: max prediction frames\\n\", ms->client);\n\t\t\treturn qfalse;\n\t\t} //end if\n\t\t//don't enter slime or lava and don't fall from too high\n\t\tif (move.stopevent & (SE_ENTERSLIME|SE_ENTERLAVA|SE_HITGROUNDDAMAGE))\n\t\t{\n\t\t\t//botimport.Print(PRT_MESSAGE, \"client %d: would be hurt \", ms->client);\n\t\t\t//if (move.stopevent & SE_ENTERSLIME) botimport.Print(PRT_MESSAGE, \"slime\\n\");\n\t\t\t//if (move.stopevent & SE_ENTERLAVA) botimport.Print(PRT_MESSAGE, \"lava\\n\");\n\t\t\t//if (move.stopevent & SE_HITGROUNDDAMAGE) botimport.Print(PRT_MESSAGE, \"hitground\\n\");\n\t\t\treturn qfalse;\n\t\t} //end if\n\t\t//if ground was hit\n\t\tif (move.stopevent & SE_HITGROUND)\n\t\t{\n\t\t\t//check for nearby gap\n\t\t\tVectorNormalize2(move.velocity, tmpdir);\n\t\t\tdist = BotGapDistance(move.endpos, tmpdir, ms->entitynum);\n\t\t\tif (dist > 0) return qfalse;\n\t\t\t//\n\t\t\tdist = BotGapDistance(move.endpos, hordir, ms->entitynum);\n\t\t\tif (dist > 0) return qfalse;\n\t\t} //end if\n\t\t//get horizontal movement\n\t\ttmpdir[0] = move.endpos[0] - ms->origin[0];\n\t\ttmpdir[1] = move.endpos[1] - ms->origin[1];\n\t\ttmpdir[2] = 0;\n\t\t//\n\t\t//AAS_DrawCross(move.endpos, 4, LINECOLOR_BLUE);\n\t\t//the bot is blocked by something\n\t\tif (VectorLength(tmpdir) < speed * ms->thinktime * 0.5) return qfalse;\n\t\t//perform the movement\n\t\tif (type & MOVE_JUMP) EA_Jump(ms->client);\n\t\tif (type & MOVE_CROUCH) EA_Crouch(ms->client);\n\t\tEA_Move(ms->client, hordir, speed);\n\t\t//movement was succesfull\n\t\treturn qtrue;\n\t} //end if\n\telse\n\t{\n\t\tif (ms->moveflags & MFL_BARRIERJUMP)\n\t\t{\n\t\t\t//if near the top or going down\n\t\t\tif (ms->velocity[2] < 50)\n\t\t\t{\n\t\t\t\tEA_Move(ms->client, dir, speed);\n\t\t\t} //end if\n\t\t} //end if\n\t\t//FIXME: do air control to avoid hazards\n\t\treturn qtrue;\n\t} //end else\n} //end of the function BotWalkInDirection\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotMoveInDirection(int movestate, vec3_t dir, float speed, int type)\n{\n\tbot_movestate_t *ms;\n\n\tms = BotMoveStateFromHandle(movestate);\n\tif (!ms) return qfalse;\n\t//if swimming\n\tif (AAS_Swimming(ms->origin))\n\t{\n\t\treturn BotSwimInDirection(ms, dir, speed, type);\n\t} //end if\n\telse\n\t{\n\t\treturn BotWalkInDirection(ms, dir, speed, type);\n\t} //end else\n} //end of the function BotMoveInDirection\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint Intersection(vec2_t p1, vec2_t p2, vec2_t p3, vec2_t p4, vec2_t out)\n{\n   float x1, dx1, dy1, x2, dx2, dy2, d;\n\n   dx1 = p2[0] - p1[0];\n   dy1 = p2[1] - p1[1];\n   dx2 = p4[0] - p3[0];\n   dy2 = p4[1] - p3[1];\n\n   d = dy1 * dx2 - dx1 * dy2;\n   if (d != 0)\n   {\n      x1 = p1[1] * dx1 - p1[0] * dy1;\n      x2 = p3[1] * dx2 - p3[0] * dy2;\n      out[0] = (int) ((dx1 * x2 - dx2 * x1) / d);\n      out[1] = (int) ((dy1 * x2 - dy2 * x1) / d);\n\t\treturn qtrue;\n   } //end if\n   else\n   {\n      return qfalse;\n   } //end else\n} //end of the function Intersection\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotCheckBlocked(bot_movestate_t *ms, vec3_t dir, int checkbottom, bot_moveresult_t *result)\n{\n\tvec3_t mins, maxs, end, up = {0, 0, 1};\n\tbsp_trace_t trace;\n\n\t//test for entities obstructing the bot's path\n\tAAS_PresenceTypeBoundingBox(ms->presencetype, mins, maxs);\n\t//\n\tif (fabs(DotProduct(dir, up)) < 0.7)\n\t{\n\t\tmins[2] += sv_maxstep->value; //if the bot can step on\n\t\tmaxs[2] -= 10; //a little lower to avoid low ceiling\n\t} //end if\n\tVectorMA(ms->origin, 3, dir, end);\n\ttrace = AAS_Trace(ms->origin, mins, maxs, end, ms->entitynum, CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_BODY);\n\t//if not started in solid and not hitting the world entity\n\tif (!trace.startsolid && (trace.ent != ENTITYNUM_WORLD && trace.ent != ENTITYNUM_NONE) )\n\t{\n\t\tresult->blocked = qtrue;\n\t\tresult->blockentity = trace.ent;\n#ifdef DEBUG\n\t\t//botimport.Print(PRT_MESSAGE, \"%d: BotCheckBlocked: I'm blocked\\n\", ms->client);\n#endif //DEBUG\n\t} //end if\n\t//if not in an area with reachability\n\telse if (checkbottom && !AAS_AreaReachability(ms->areanum))\n\t{\n\t\t//check if the bot is standing on something\n\t\tAAS_PresenceTypeBoundingBox(ms->presencetype, mins, maxs);\n\t\tVectorMA(ms->origin, -3, up, end);\n\t\ttrace = AAS_Trace(ms->origin, mins, maxs, end, ms->entitynum, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);\n\t\tif (!trace.startsolid && (trace.ent != ENTITYNUM_WORLD && trace.ent != ENTITYNUM_NONE) )\n\t\t{\n\t\t\tresult->blocked = qtrue;\n\t\t\tresult->blockentity = trace.ent;\n\t\t\tresult->flags |= MOVERESULT_ONTOPOFOBSTACLE;\n#ifdef DEBUG\n\t\t\t//botimport.Print(PRT_MESSAGE, \"%d: BotCheckBlocked: I'm blocked\\n\", ms->client);\n#endif //DEBUG\n\t\t} //end if\n\t} //end else\n} //end of the function BotCheckBlocked\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotClearMoveResult(bot_moveresult_t *moveresult)\n{\n\tmoveresult->failure = qfalse;\n\tmoveresult->type = 0;\n\tmoveresult->blocked = qfalse;\n\tmoveresult->blockentity = 0;\n\tmoveresult->traveltype = 0;\n\tmoveresult->flags = 0;\n} //end of the function BotClearMoveResult\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotTravel_Walk(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tfloat dist, speed;\n\tvec3_t hordir;\n\tbot_moveresult_t result;\n\n\tBotClearMoveResult(&result);\n\t//first walk straight to the reachability start\n\thordir[0] = reach->start[0] - ms->origin[0];\n\thordir[1] = reach->start[1] - ms->origin[1];\n\thordir[2] = 0;\n\tdist = VectorNormalize(hordir);\n\t//\n\tBotCheckBlocked(ms, hordir, qtrue, &result);\n\t//\n\tif (dist < 10)\n\t{\n\t\t//walk straight to the reachability end\n\t\thordir[0] = reach->end[0] - ms->origin[0];\n\t\thordir[1] = reach->end[1] - ms->origin[1];\n\t\thordir[2] = 0;\n\t\tdist = VectorNormalize(hordir);\n\t} //end if\n\t//if going towards a crouch area\n\tif (!(AAS_AreaPresenceType(reach->areanum) & PRESENCE_NORMAL))\n\t{\n\t\t//if pretty close to the reachable area\n\t\tif (dist < 20) EA_Crouch(ms->client);\n\t} //end if\n\t//\n\tdist = BotGapDistance(ms->origin, hordir, ms->entitynum);\n\t//\n\tif (ms->moveflags & MFL_WALK)\n\t{\n\t\tif (dist > 0) speed = 200 - (180 - 1 * dist);\n\t\telse speed = 200;\n\t\tEA_Walk(ms->client);\n\t} //end if\n\telse\n\t{\n\t\tif (dist > 0) speed = 400 - (360 - 2 * dist);\n\t\telse speed = 400;\n\t} //end else\n\t//elemantary action move in direction\n\tEA_Move(ms->client, hordir, speed);\n\tVectorCopy(hordir, result.movedir);\n\t//\n\treturn result;\n} //end of the function BotTravel_Walk\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotFinishTravel_Walk(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tvec3_t hordir;\n\tfloat dist, speed;\n\tbot_moveresult_t result;\n\n\tBotClearMoveResult(&result);\n\t//if not on the ground and changed areas... don't walk back!!\n\t//(doesn't seem to help)\n\t/*\n\tms->areanum = BotFuzzyPointReachabilityArea(ms->origin);\n\tif (ms->areanum == reach->areanum)\n\t{\n#ifdef DEBUG\n\t\tbotimport.Print(PRT_MESSAGE, \"BotFinishTravel_Walk: already in reach area\\n\");\n#endif //DEBUG\n\t\treturn result;\n\t} //end if*/\n\t//go straight to the reachability end\n\thordir[0] = reach->end[0] - ms->origin[0];\n\thordir[1] = reach->end[1] - ms->origin[1];\n\thordir[2] = 0;\n\tdist = VectorNormalize(hordir);\n\t//\n\tif (dist > 100) dist = 100;\n\tspeed = 400 - (400 - 3 * dist);\n\t//\n\tEA_Move(ms->client, hordir, speed);\n\tVectorCopy(hordir, result.movedir);\n\t//\n\treturn result;\n} //end of the function BotFinishTravel_Walk\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotTravel_Crouch(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tfloat speed;\n\tvec3_t hordir;\n\tbot_moveresult_t result;\n\n\tBotClearMoveResult(&result);\n\t//\n\tspeed = 400;\n\t//walk straight to reachability end\n\thordir[0] = reach->end[0] - ms->origin[0];\n\thordir[1] = reach->end[1] - ms->origin[1];\n\thordir[2] = 0;\n\tVectorNormalize(hordir);\n\t//\n\tBotCheckBlocked(ms, hordir, qtrue, &result);\n\t//elemantary actions\n\tEA_Crouch(ms->client);\n\tEA_Move(ms->client, hordir, speed);\n\t//\n\tVectorCopy(hordir, result.movedir);\n\t//\n\treturn result;\n} //end of the function BotTravel_Crouch\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotTravel_BarrierJump(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tfloat dist, speed;\n\tvec3_t hordir;\n\tbot_moveresult_t result;\n\n\tBotClearMoveResult(&result);\n\t//walk straight to reachability start\n\thordir[0] = reach->start[0] - ms->origin[0];\n\thordir[1] = reach->start[1] - ms->origin[1];\n\thordir[2] = 0;\n\tdist = VectorNormalize(hordir);\n\t//\n\tBotCheckBlocked(ms, hordir, qtrue, &result);\n\t//if pretty close to the barrier\n\tif (dist < 9)\n\t{\n\t\tEA_Jump(ms->client);\n\t} //end if\n\telse\n\t{\n\t\tif (dist > 60) dist = 60;\n\t\tspeed = 360 - (360 - 6 * dist);\n\t\tEA_Move(ms->client, hordir, speed);\n\t} //end else\n\tVectorCopy(hordir, result.movedir);\n\t//\n\treturn result;\n} //end of the function BotTravel_BarrierJump\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotFinishTravel_BarrierJump(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tfloat dist;\n\tvec3_t hordir;\n\tbot_moveresult_t result;\n\n\tBotClearMoveResult(&result);\n\t//if near the top or going down\n\tif (ms->velocity[2] < 250)\n\t{\n\t\thordir[0] = reach->end[0] - ms->origin[0];\n\t\thordir[1] = reach->end[1] - ms->origin[1];\n\t\thordir[2] = 0;\n\t\tdist = VectorNormalize(hordir);\n\t\t//\n\t\tBotCheckBlocked(ms, hordir, qtrue, &result);\n\t\t//\n\t\tEA_Move(ms->client, hordir, 400);\n\t\tVectorCopy(hordir, result.movedir);\n\t} //end if\n\t//\n\treturn result;\n} //end of the function BotFinishTravel_BarrierJump\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotTravel_Swim(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tvec3_t dir;\n\tbot_moveresult_t result;\n\n\tBotClearMoveResult(&result);\n\t//swim straight to reachability end\n\tVectorSubtract(reach->start, ms->origin, dir);\n\tVectorNormalize(dir);\n\t//\n\tBotCheckBlocked(ms, dir, qtrue, &result);\n\t//elemantary actions\n\tEA_Move(ms->client, dir, 400);\n\t//\n\tVectorCopy(dir, result.movedir);\n\tVector2Angles(dir, result.ideal_viewangles);\n\tresult.flags |= MOVERESULT_SWIMVIEW;\n\t//\n\treturn result;\n} //end of the function BotTravel_Swim\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotTravel_WaterJump(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tvec3_t dir, hordir;\n\tfloat dist;\n\tbot_moveresult_t result;\n\n\tBotClearMoveResult(&result);\n\t//swim straight to reachability end\n\tVectorSubtract(reach->end, ms->origin, dir);\n\tVectorCopy(dir, hordir);\n\thordir[2] = 0;\n\tdir[2] += 15 + crandom() * 40;\n\t//botimport.Print(PRT_MESSAGE, \"BotTravel_WaterJump: dir[2] = %f\\n\", dir[2]);\n\tVectorNormalize(dir);\n\tdist = VectorNormalize(hordir);\n\t//elemantary actions\n\t//EA_Move(ms->client, dir, 400);\n\tEA_MoveForward(ms->client);\n\t//move up if close to the actual out of water jump spot\n\tif (dist < 40) EA_MoveUp(ms->client);\n\t//set the ideal view angles\n\tVector2Angles(dir, result.ideal_viewangles);\n\tresult.flags |= MOVERESULT_MOVEMENTVIEW;\n\t//\n\tVectorCopy(dir, result.movedir);\n\t//\n\treturn result;\n} //end of the function BotTravel_WaterJump\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotFinishTravel_WaterJump(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tvec3_t dir, pnt;\n\tfloat dist;\n\tbot_moveresult_t result;\n\n\t//botimport.Print(PRT_MESSAGE, \"BotFinishTravel_WaterJump\\n\");\n\tBotClearMoveResult(&result);\n\t//if waterjumping there's nothing to do\n\tif (ms->moveflags & MFL_WATERJUMP) return result;\n\t//if not touching any water anymore don't do anything\n\t//otherwise the bot sometimes keeps jumping?\n\tVectorCopy(ms->origin, pnt);\n\tpnt[2] -= 32;\t//extra for q2dm4 near red armor/mega health\n\tif (!(AAS_PointContents(pnt) & (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER))) return result;\n\t//swim straight to reachability end\n\tVectorSubtract(reach->end, ms->origin, dir);\n\tdir[0] += crandom() * 10;\n\tdir[1] += crandom() * 10;\n\tdir[2] += 70 + crandom() * 10;\n\tdist = VectorNormalize(dir);\n\t//elemantary actions\n\tEA_Move(ms->client, dir, 400);\n\t//set the ideal view angles\n\tVector2Angles(dir, result.ideal_viewangles);\n\tresult.flags |= MOVERESULT_MOVEMENTVIEW;\n\t//\n\tVectorCopy(dir, result.movedir);\n\t//\n\treturn result;\n} //end of the function BotFinishTravel_WaterJump\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotTravel_WalkOffLedge(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tvec3_t hordir, dir;\n\tfloat dist, speed, reachhordist;\n\tbot_moveresult_t result;\n\n\tBotClearMoveResult(&result);\n\t//check if the bot is blocked by anything\n\tVectorSubtract(reach->start, ms->origin, dir);\n\tVectorNormalize(dir);\n\tBotCheckBlocked(ms, dir, qtrue, &result);\n\t//if the reachability start and end are practially above each other\n\tVectorSubtract(reach->end, reach->start, dir);\n\tdir[2] = 0;\n\treachhordist = VectorLength(dir);\n\t//walk straight to the reachability start\n\thordir[0] = reach->start[0] - ms->origin[0];\n\thordir[1] = reach->start[1] - ms->origin[1];\n\thordir[2] = 0;\n\tdist = VectorNormalize(hordir);\n\t//if pretty close to the start focus on the reachability end\n\tif (dist < 48)\n\t{\n\t\thordir[0] = reach->end[0] - ms->origin[0];\n\t\thordir[1] = reach->end[1] - ms->origin[1];\n\t\thordir[2] = 0;\n\t\tVectorNormalize(hordir);\n\t\t//\n\t\tif (reachhordist < 20)\n\t\t{\n\t\t\tspeed = 100;\n\t\t} //end if\n\t\telse if (!AAS_HorizontalVelocityForJump(0, reach->start, reach->end, &speed))\n\t\t{\n\t\t\tspeed = 400;\n\t\t} //end if\n\t} //end if\n\telse\n\t{\n\t\tif (reachhordist < 20)\n\t\t{\n\t\t\tif (dist > 64) dist = 64;\n\t\t\tspeed = 400 - (256 - 4 * dist);\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tspeed = 400;\n\t\t} //end else\n\t} //end else\n\t//\n\tBotCheckBlocked(ms, hordir, qtrue, &result);\n\t//elemantary action\n\tEA_Move(ms->client, hordir, speed);\n\tVectorCopy(hordir, result.movedir);\n\t//\n\treturn result;\n} //end of the function BotTravel_WalkOffLedge\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotAirControl(vec3_t origin, vec3_t velocity, vec3_t goal, vec3_t dir, float *speed)\n{\n\tvec3_t org, vel;\n\tfloat dist;\n\tint i;\n\n\tVectorCopy(origin, org);\n\tVectorScale(velocity, 0.1, vel);\n\tfor (i = 0; i < 50; i++)\n\t{\n\t\tvel[2] -= sv_gravity->value * 0.01;\n\t\t//if going down and next position would be below the goal\n\t\tif (vel[2] < 0 && org[2] + vel[2] < goal[2])\n\t\t{\n\t\t\tVectorScale(vel, (goal[2] - org[2]) / vel[2], vel);\n\t\t\tVectorAdd(org, vel, org);\n\t\t\tVectorSubtract(goal, org, dir);\n\t\t\tdist = VectorNormalize(dir);\n\t\t\tif (dist > 32) dist = 32;\n\t\t\t*speed = 400 - (400 - 13 * dist);\n\t\t\treturn qtrue;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tVectorAdd(org, vel, org);\n\t\t} //end else\n\t} //end for\n\tVectorSet(dir, 0, 0, 0);\n\t*speed = 400;\n\treturn qfalse;\n} //end of the function BotAirControl\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotFinishTravel_WalkOffLedge(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tvec3_t dir, hordir, end, v;\n\tfloat dist, speed;\n\tbot_moveresult_t result;\n\n\tBotClearMoveResult(&result);\n\t//\n\tVectorSubtract(reach->end, ms->origin, dir);\n\tBotCheckBlocked(ms, dir, qtrue, &result);\n\t//\n\tVectorSubtract(reach->end, ms->origin, v);\n\tv[2] = 0;\n\tdist = VectorNormalize(v);\n\tif (dist > 16) VectorMA(reach->end, 16, v, end);\n\telse VectorCopy(reach->end, end);\n\t//\n\tif (!BotAirControl(ms->origin, ms->velocity, end, hordir, &speed))\n\t{\n\t\t//go straight to the reachability end\n\t\tVectorCopy(dir, hordir);\n\t\thordir[2] = 0;\n\t\t//\n\t\tdist = VectorNormalize(hordir);\n\t\tspeed = 400;\n\t} //end if\n\t//\n\tEA_Move(ms->client, hordir, speed);\n\tVectorCopy(hordir, result.movedir);\n\t//\n\treturn result;\n} //end of the function BotFinishTravel_WalkOffLedge\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n/*\nbot_moveresult_t BotTravel_Jump(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tvec3_t hordir;\n\tfloat dist, gapdist, speed, horspeed, sv_jumpvel;\n\tbot_moveresult_t result;\n\n\tBotClearMoveResult(&result);\n\t//\n\tsv_jumpvel = botlibglobals.sv_jumpvel->value;\n\t//walk straight to the reachability start\n\thordir[0] = reach->start[0] - ms->origin[0];\n\thordir[1] = reach->start[1] - ms->origin[1];\n\thordir[2] = 0;\n\tdist = VectorNormalize(hordir);\n\t//\n\tspeed = 350;\n\t//\n\tgapdist = BotGapDistance(ms, hordir, ms->entitynum);\n\t//if pretty close to the start focus on the reachability end\n\tif (dist < 50 || (gapdist && gapdist < 50))\n\t{\n\t\t//NOTE: using max speed (400) works best\n\t\t//if (AAS_HorizontalVelocityForJump(sv_jumpvel, ms->origin, reach->end, &horspeed))\n\t\t//{\n\t\t//\tspeed = horspeed * 400 / botlibglobals.sv_maxwalkvelocity->value;\n\t\t//} //end if\n\t\thordir[0] = reach->end[0] - ms->origin[0];\n\t\thordir[1] = reach->end[1] - ms->origin[1];\n\t\tVectorNormalize(hordir);\n\t\t//elemantary action jump\n\t\tEA_Jump(ms->client);\n\t\t//\n\t\tms->jumpreach = ms->lastreachnum;\n\t\tspeed = 600;\n\t} //end if\n\telse\n\t{\n\t\tif (AAS_HorizontalVelocityForJump(sv_jumpvel, reach->start, reach->end, &horspeed))\n\t\t{\n\t\t\tspeed = horspeed * 400 / botlibglobals.sv_maxwalkvelocity->value;\n\t\t} //end if\n\t} //end else\n\t//elemantary action\n\tEA_Move(ms->client, hordir, speed);\n\tVectorCopy(hordir, result.movedir);\n\t//\n\treturn result;\n} //end of the function BotTravel_Jump*/\n/*\nbot_moveresult_t BotTravel_Jump(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tvec3_t hordir, dir1, dir2, mins, maxs, start, end;\n\tfloat dist1, dist2, speed;\n\tbot_moveresult_t result;\n\tbsp_trace_t trace;\n\n\tBotClearMoveResult(&result);\n\t//\n\thordir[0] = reach->start[0] - reach->end[0];\n\thordir[1] = reach->start[1] - reach->end[1];\n\thordir[2] = 0;\n\tVectorNormalize(hordir);\n\t//\n\tVectorCopy(reach->start, start);\n\tstart[2] += 1;\n\t//minus back the bouding box size plus 16\n\tVectorMA(reach->start, 80, hordir, end);\n\t//\n\tAAS_PresenceTypeBoundingBox(PRESENCE_NORMAL, mins, maxs);\n\t//check for solids\n\ttrace = AAS_Trace(start, mins, maxs, end, ms->entitynum, MASK_PLAYERSOLID);\n\tif (trace.startsolid) VectorCopy(start, trace.endpos);\n\t//check for a gap\n\tfor (dist1 = 0; dist1 < 80; dist1 += 10)\n\t{\n\t\tVectorMA(start, dist1+10, hordir, end);\n\t\tend[2] += 1;\n\t\tif (AAS_PointAreaNum(end) != ms->reachareanum) break;\n\t} //end for\n\tif (dist1 < 80) VectorMA(reach->start, dist1, hordir, trace.endpos);\n//\tdist1 = BotGapDistance(start, hordir, ms->entitynum);\n//\tif (dist1 && dist1 <= trace.fraction * 80) VectorMA(reach->start, dist1-20, hordir, trace.endpos);\n\t//\n\tVectorSubtract(ms->origin, reach->start, dir1);\n\tdir1[2] = 0;\n\tdist1 = VectorNormalize(dir1);\n\tVectorSubtract(ms->origin, trace.endpos, dir2);\n\tdir2[2] = 0;\n\tdist2 = VectorNormalize(dir2);\n\t//if just before the reachability start\n\tif (DotProduct(dir1, dir2) < -0.8 || dist2 < 5)\n\t{\n\t\t//botimport.Print(PRT_MESSAGE, \"between jump start and run to point\\n\");\n\t\thordir[0] = reach->end[0] - ms->origin[0];\n\t\thordir[1] = reach->end[1] - ms->origin[1];\n\t\thordir[2] = 0;\n\t\tVectorNormalize(hordir);\n\t\t//elemantary action jump\n\t\tif (dist1 < 24) EA_Jump(ms->client);\n\t\telse if (dist1 < 32) EA_DelayedJump(ms->client);\n\t\tEA_Move(ms->client, hordir, 600);\n\t\t//\n\t\tms->jumpreach = ms->lastreachnum;\n\t} //end if\n\telse\n\t{\n\t\t//botimport.Print(PRT_MESSAGE, \"going towards run to point\\n\");\n\t\thordir[0] = trace.endpos[0] - ms->origin[0];\n\t\thordir[1] = trace.endpos[1] - ms->origin[1];\n\t\thordir[2] = 0;\n\t\tVectorNormalize(hordir);\n\t\t//\n\t\tif (dist2 > 80) dist2 = 80;\n\t\tspeed = 400 - (400 - 5 * dist2);\n\t\tEA_Move(ms->client, hordir, speed);\n\t} //end else\n\tVectorCopy(hordir, result.movedir);\n\t//\n\treturn result;\n} //end of the function BotTravel_Jump*/\n//*\nbot_moveresult_t BotTravel_Jump(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tvec3_t hordir, dir1, dir2, start, end, runstart;\n//\tvec3_t runstart, dir1, dir2, hordir;\n\tfloat dist1, dist2, speed;\n\tbot_moveresult_t result;\n\n\tBotClearMoveResult(&result);\n\t//\n\tAAS_JumpReachRunStart(reach, runstart);\n\t//*\n\thordir[0] = runstart[0] - reach->start[0];\n\thordir[1] = runstart[1] - reach->start[1];\n\thordir[2] = 0;\n\tVectorNormalize(hordir);\n\t//\n\tVectorCopy(reach->start, start);\n\tstart[2] += 1;\n\tVectorMA(reach->start, 80, hordir, runstart);\n\t//check for a gap\n\tfor (dist1 = 0; dist1 < 80; dist1 += 10)\n\t{\n\t\tVectorMA(start, dist1+10, hordir, end);\n\t\tend[2] += 1;\n\t\tif (AAS_PointAreaNum(end) != ms->reachareanum) break;\n\t} //end for\n\tif (dist1 < 80) VectorMA(reach->start, dist1, hordir, runstart);\n\t//\n\tVectorSubtract(ms->origin, reach->start, dir1);\n\tdir1[2] = 0;\n\tdist1 = VectorNormalize(dir1);\n\tVectorSubtract(ms->origin, runstart, dir2);\n\tdir2[2] = 0;\n\tdist2 = VectorNormalize(dir2);\n\t//if just before the reachability start\n\tif (DotProduct(dir1, dir2) < -0.8 || dist2 < 5)\n\t{\n//\t\tbotimport.Print(PRT_MESSAGE, \"between jump start and run start point\\n\");\n\t\thordir[0] = reach->end[0] - ms->origin[0];\n\t\thordir[1] = reach->end[1] - ms->origin[1];\n\t\thordir[2] = 0;\n\t\tVectorNormalize(hordir);\n\t\t//elemantary action jump\n\t\tif (dist1 < 24) EA_Jump(ms->client);\n\t\telse if (dist1 < 32) EA_DelayedJump(ms->client);\n\t\tEA_Move(ms->client, hordir, 600);\n\t\t//\n\t\tms->jumpreach = ms->lastreachnum;\n\t} //end if\n\telse\n\t{\n//\t\tbotimport.Print(PRT_MESSAGE, \"going towards run start point\\n\");\n\t\thordir[0] = runstart[0] - ms->origin[0];\n\t\thordir[1] = runstart[1] - ms->origin[1];\n\t\thordir[2] = 0;\n\t\tVectorNormalize(hordir);\n\t\t//\n\t\tif (dist2 > 80) dist2 = 80;\n\t\tspeed = 400 - (400 - 5 * dist2);\n\t\tEA_Move(ms->client, hordir, speed);\n\t} //end else\n\tVectorCopy(hordir, result.movedir);\n\t//\n\treturn result;\n} //end of the function BotTravel_Jump*/\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotFinishTravel_Jump(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tvec3_t hordir, hordir2;\n\tfloat speed, dist;\n\tbot_moveresult_t result;\n\n\tBotClearMoveResult(&result);\n\t//if not jumped yet\n\tif (!ms->jumpreach) return result;\n\t//go straight to the reachability end\n\thordir[0] = reach->end[0] - ms->origin[0];\n\thordir[1] = reach->end[1] - ms->origin[1];\n\thordir[2] = 0;\n\tdist = VectorNormalize(hordir);\n\t//\n\thordir2[0] = reach->end[0] - reach->start[0];\n\thordir2[1] = reach->end[1] - reach->start[1];\n\thordir2[2] = 0;\n\tVectorNormalize(hordir2);\n\t//\n\tif (DotProduct(hordir, hordir2) < -0.5 && dist < 24) return result;\n\t//always use max speed when traveling through the air\n\tspeed = 800;\n\t//\n\tEA_Move(ms->client, hordir, speed);\n\tVectorCopy(hordir, result.movedir);\n\t//\n\treturn result;\n} //end of the function BotFinishTravel_Jump\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotTravel_Ladder(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\t//float dist, speed;\n\tvec3_t dir, viewdir;//, hordir;\n\tvec3_t origin = {0, 0, 0};\n//\tvec3_t up = {0, 0, 1};\n\tbot_moveresult_t result;\n\n\tBotClearMoveResult(&result);\n\t//\n//\tif ((ms->moveflags & MFL_AGAINSTLADDER))\n\t\t//NOTE: not a good idea for ladders starting in water\n\t\t// || !(ms->moveflags & MFL_ONGROUND))\n\t{\n\t\t//botimport.Print(PRT_MESSAGE, \"against ladder or not on ground\\n\");\n\t\tVectorSubtract(reach->end, ms->origin, dir);\n\t\tVectorNormalize(dir);\n\t\t//set the ideal view angles, facing the ladder up or down\n\t\tviewdir[0] = dir[0];\n\t\tviewdir[1] = dir[1];\n\t\tviewdir[2] = 3 * dir[2];\n\t\tVector2Angles(viewdir, result.ideal_viewangles);\n\t\t//elemantary action\n\t\tEA_Move(ms->client, origin, 0);\n\t\tEA_MoveForward(ms->client);\n\t\t//set movement view flag so the AI can see the view is focussed\n\t\tresult.flags |= MOVERESULT_MOVEMENTVIEW;\n\t} //end if\n/*\telse\n\t{\n\t\t//botimport.Print(PRT_MESSAGE, \"moving towards ladder\\n\");\n\t\tVectorSubtract(reach->end, ms->origin, dir);\n\t\t//make sure the horizontal movement is large anough\n\t\tVectorCopy(dir, hordir);\n\t\thordir[2] = 0;\n\t\tdist = VectorNormalize(hordir);\n\t\t//\n\t\tdir[0] = hordir[0];\n\t\tdir[1] = hordir[1];\n\t\tif (dir[2] > 0) dir[2] = 1;\n\t\telse dir[2] = -1;\n\t\tif (dist > 50) dist = 50;\n\t\tspeed = 400 - (200 - 4 * dist);\n\t\tEA_Move(ms->client, dir, speed);\n\t} //end else*/\n\t//save the movement direction\n\tVectorCopy(dir, result.movedir);\n\t//\n\treturn result;\n} //end of the function BotTravel_Ladder\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotTravel_Teleport(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tvec3_t hordir;\n\tfloat dist;\n\tbot_moveresult_t result;\n\n\tBotClearMoveResult(&result);\n\t//if the bot is being teleported\n\tif (ms->moveflags & MFL_TELEPORTED) return result;\n\n\t//walk straight to center of the teleporter\n\tVectorSubtract(reach->start, ms->origin, hordir);\n\tif (!(ms->moveflags & MFL_SWIMMING)) hordir[2] = 0;\n\tdist = VectorNormalize(hordir);\n\t//\n\tBotCheckBlocked(ms, hordir, qtrue, &result);\n\n\tif (dist < 30) EA_Move(ms->client, hordir, 200);\n\telse EA_Move(ms->client, hordir, 400);\n\n\tif (ms->moveflags & MFL_SWIMMING) result.flags |= MOVERESULT_SWIMVIEW;\n\n\tVectorCopy(hordir, result.movedir);\n\treturn result;\n} //end of the function BotTravel_Teleport\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotTravel_Elevator(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tvec3_t dir, dir1, dir2, hordir, bottomcenter;\n\tfloat dist, dist1, dist2, speed;\n\tbot_moveresult_t result;\n\n\tBotClearMoveResult(&result);\n\t//if standing on the plat\n\tif (BotOnMover(ms->origin, ms->entitynum, reach))\n\t{\n#ifdef DEBUG_ELEVATOR\n\t\tbotimport.Print(PRT_MESSAGE, \"bot on elevator\\n\");\n#endif //DEBUG_ELEVATOR\n\t\t//if vertically not too far from the end point\n\t\tif (abs(ms->origin[2] - reach->end[2]) < sv_maxbarrier->value)\n\t\t{\n#ifdef DEBUG_ELEVATOR\n\t\t\tbotimport.Print(PRT_MESSAGE, \"bot moving to end\\n\");\n#endif //DEBUG_ELEVATOR\n\t\t\t//move to the end point\n\t\t\tVectorSubtract(reach->end, ms->origin, hordir);\n\t\t\thordir[2] = 0;\n\t\t\tVectorNormalize(hordir);\n\t\t\tif (!BotCheckBarrierJump(ms, hordir, 100))\n\t\t\t{\n\t\t\t\tEA_Move(ms->client, hordir, 400);\n\t\t\t} //end if\n\t\t\tVectorCopy(hordir, result.movedir);\n\t\t} //end else\n\t\t//if not really close to the center of the elevator\n\t\telse\n\t\t{\n\t\t\tMoverBottomCenter(reach, bottomcenter);\n\t\t\tVectorSubtract(bottomcenter, ms->origin, hordir);\n\t\t\thordir[2] = 0;\n\t\t\tdist = VectorNormalize(hordir);\n\t\t\t//\n\t\t\tif (dist > 10)\n\t\t\t{\n#ifdef DEBUG_ELEVATOR\n\t\t\t\tbotimport.Print(PRT_MESSAGE, \"bot moving to center\\n\");\n#endif //DEBUG_ELEVATOR\n\t\t\t\t//move to the center of the plat\n\t\t\t\tif (dist > 100) dist = 100;\n\t\t\t\tspeed = 400 - (400 - 4 * dist);\n\t\t\t\t//\n\t\t\t\tEA_Move(ms->client, hordir, speed);\n\t\t\t\tVectorCopy(hordir, result.movedir);\n\t\t\t} //end if\n\t\t} //end else\n\t} //end if\n\telse\n\t{\n#ifdef DEBUG_ELEVATOR\n\t\tbotimport.Print(PRT_MESSAGE, \"bot not on elevator\\n\");\n#endif //DEBUG_ELEVATOR\n\t\t//if very near the reachability end\n\t\tVectorSubtract(reach->end, ms->origin, dir);\n\t\tdist = VectorLength(dir);\n\t\tif (dist < 64)\n\t\t{\n\t\t\tif (dist > 60) dist = 60;\n\t\t\tspeed = 360 - (360 - 6 * dist);\n\t\t\t//\n\t\t\tif ((ms->moveflags & MFL_SWIMMING) || !BotCheckBarrierJump(ms, dir, 50))\n\t\t\t{\n\t\t\t\tif (speed > 5) EA_Move(ms->client, dir, speed);\n\t\t\t} //end if\n\t\t\tVectorCopy(dir, result.movedir);\n\t\t\t//\n\t\t\tif (ms->moveflags & MFL_SWIMMING) result.flags |= MOVERESULT_SWIMVIEW;\n\t\t\t//stop using this reachability\n\t\t\tms->reachability_time = 0;\n\t\t\treturn result;\n\t\t} //end if\n\t\t//get direction and distance to reachability start\n\t\tVectorSubtract(reach->start, ms->origin, dir1);\n\t\tif (!(ms->moveflags & MFL_SWIMMING)) dir1[2] = 0;\n\t\tdist1 = VectorNormalize(dir1);\n\t\t//if the elevator isn't down\n\t\tif (!MoverDown(reach))\n\t\t{\n#ifdef DEBUG_ELEVATOR\n\t\t\tbotimport.Print(PRT_MESSAGE, \"elevator not down\\n\");\n#endif //DEBUG_ELEVATOR\n\t\t\tdist = dist1;\n\t\t\tVectorCopy(dir1, dir);\n\t\t\t//\n\t\t\tBotCheckBlocked(ms, dir, qfalse, &result);\n\t\t\t//\n\t\t\tif (dist > 60) dist = 60;\n\t\t\tspeed = 360 - (360 - 6 * dist);\n\t\t\t//\n\t\t\tif (!(ms->moveflags & MFL_SWIMMING) && !BotCheckBarrierJump(ms, dir, 50))\n\t\t\t{\n\t\t\t\tif (speed > 5) EA_Move(ms->client, dir, speed);\n\t\t\t} //end if\n\t\t\tVectorCopy(dir, result.movedir);\n\t\t\t//\n\t\t\tif (ms->moveflags & MFL_SWIMMING) result.flags |= MOVERESULT_SWIMVIEW;\n\t\t\t//this isn't a failure... just wait till the elevator comes down\n\t\t\tresult.type = RESULTTYPE_ELEVATORUP;\n\t\t\tresult.flags |= MOVERESULT_WAITING;\n\t\t\treturn result;\n\t\t} //end if\n\t\t//get direction and distance to elevator bottom center\n\t\tMoverBottomCenter(reach, bottomcenter);\n\t\tVectorSubtract(bottomcenter, ms->origin, dir2);\n\t\tif (!(ms->moveflags & MFL_SWIMMING)) dir2[2] = 0;\n\t\tdist2 = VectorNormalize(dir2);\n\t\t//if very close to the reachability start or\n\t\t//closer to the elevator center or\n\t\t//between reachability start and elevator center\n\t\tif (dist1 < 20 || dist2 < dist1 || DotProduct(dir1, dir2) < 0)\n\t\t{\n#ifdef DEBUG_ELEVATOR\n\t\t\tbotimport.Print(PRT_MESSAGE, \"bot moving to center\\n\");\n#endif //DEBUG_ELEVATOR\n\t\t\tdist = dist2;\n\t\t\tVectorCopy(dir2, dir);\n\t\t} //end if\n\t\telse //closer to the reachability start\n\t\t{\n#ifdef DEBUG_ELEVATOR\n\t\t\tbotimport.Print(PRT_MESSAGE, \"bot moving to start\\n\");\n#endif //DEBUG_ELEVATOR\n\t\t\tdist = dist1;\n\t\t\tVectorCopy(dir1, dir);\n\t\t} //end else\n\t\t//\n\t\tBotCheckBlocked(ms, dir, qfalse, &result);\n\t\t//\n\t\tif (dist > 60) dist = 60;\n\t\tspeed = 400 - (400 - 6 * dist);\n\t\t//\n\t\tif (!(ms->moveflags & MFL_SWIMMING) && !BotCheckBarrierJump(ms, dir, 50))\n\t\t{\n\t\t\tEA_Move(ms->client, dir, speed);\n\t\t} //end if\n\t\tVectorCopy(dir, result.movedir);\n\t\t//\n\t\tif (ms->moveflags & MFL_SWIMMING) result.flags |= MOVERESULT_SWIMVIEW;\n\t} //end else\n\treturn result;\n} //end of the function BotTravel_Elevator\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotFinishTravel_Elevator(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tvec3_t bottomcenter, bottomdir, topdir;\n\tbot_moveresult_t result;\n\n\tBotClearMoveResult(&result);\n\t//\n\tMoverBottomCenter(reach, bottomcenter);\n\tVectorSubtract(bottomcenter, ms->origin, bottomdir);\n\t//\n\tVectorSubtract(reach->end, ms->origin, topdir);\n\t//\n\tif (fabs(bottomdir[2]) < fabs(topdir[2]))\n\t{\n\t\tVectorNormalize(bottomdir);\n\t\tEA_Move(ms->client, bottomdir, 300);\n\t} //end if\n\telse\n\t{\n\t\tVectorNormalize(topdir);\n\t\tEA_Move(ms->client, topdir, 300);\n\t} //end else\n\treturn result;\n} //end of the function BotFinishTravel_Elevator\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotFuncBobStartEnd(aas_reachability_t *reach, vec3_t start, vec3_t end, vec3_t origin)\n{\n\tint spawnflags, modelnum;\n\tvec3_t mins, maxs, mid, angles = {0, 0, 0};\n\tint num0, num1;\n\n\tmodelnum = reach->facenum & 0x0000FFFF;\n\tif (!AAS_OriginOfMoverWithModelNum(modelnum, origin))\n\t{\n\t\tbotimport.Print(PRT_MESSAGE, \"BotFuncBobStartEnd: no entity with model %d\\n\", modelnum);\n\t\tVectorSet(start, 0, 0, 0);\n\t\tVectorSet(end, 0, 0, 0);\n\t\treturn;\n\t} //end if\n\tAAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, NULL);\n\tVectorAdd(mins, maxs, mid);\n\tVectorScale(mid, 0.5, mid);\n\tVectorCopy(mid, start);\n\tVectorCopy(mid, end);\n\tspawnflags = reach->facenum >> 16;\n\tnum0 = reach->edgenum >> 16;\n\tif (num0 > 0x00007FFF) num0 |= 0xFFFF0000;\n\tnum1 = reach->edgenum & 0x0000FFFF;\n\tif (num1 > 0x00007FFF) num1 |= 0xFFFF0000;\n\tif (spawnflags & 1)\n\t{\n\t\tstart[0] = num0;\n\t\tend[0] = num1;\n\t\t//\n\t\torigin[0] += mid[0];\n\t\torigin[1] = mid[1];\n\t\torigin[2] = mid[2];\n\t} //end if\n\telse if (spawnflags & 2)\n\t{\n\t\tstart[1] = num0;\n\t\tend[1] = num1;\n\t\t//\n\t\torigin[0] = mid[0];\n\t\torigin[1] += mid[1];\n\t\torigin[2] = mid[2];\n\t} //end else if\n\telse\n\t{\n\t\tstart[2] = num0;\n\t\tend[2] = num1;\n\t\t//\n\t\torigin[0] = mid[0];\n\t\torigin[1] = mid[1];\n\t\torigin[2] += mid[2];\n\t} //end else\n} //end of the function BotFuncBobStartEnd\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotTravel_FuncBobbing(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tvec3_t dir, dir1, dir2, hordir, bottomcenter, bob_start, bob_end, bob_origin;\n\tfloat dist, dist1, dist2, speed;\n\tbot_moveresult_t result;\n\n\tBotClearMoveResult(&result);\n\t//\n\tBotFuncBobStartEnd(reach, bob_start, bob_end, bob_origin);\n\t//if standing ontop of the func_bobbing\n\tif (BotOnMover(ms->origin, ms->entitynum, reach))\n\t{\n#ifdef DEBUG_FUNCBOB\n\t\tbotimport.Print(PRT_MESSAGE, \"bot on func_bobbing\\n\");\n#endif\n\t\t//if near end point of reachability\n\t\tVectorSubtract(bob_origin, bob_end, dir);\n\t\tif (VectorLength(dir) < 24)\n\t\t{\n#ifdef DEBUG_FUNCBOB\n\t\t\tbotimport.Print(PRT_MESSAGE, \"bot moving to reachability end\\n\");\n#endif\n\t\t\t//move to the end point\n\t\t\tVectorSubtract(reach->end, ms->origin, hordir);\n\t\t\thordir[2] = 0;\n\t\t\tVectorNormalize(hordir);\n\t\t\tif (!BotCheckBarrierJump(ms, hordir, 100))\n\t\t\t{\n\t\t\t\tEA_Move(ms->client, hordir, 400);\n\t\t\t} //end if\n\t\t\tVectorCopy(hordir, result.movedir);\n\t\t} //end else\n\t\t//if not really close to the center of the elevator\n\t\telse\n\t\t{\n\t\t\tMoverBottomCenter(reach, bottomcenter);\n\t\t\tVectorSubtract(bottomcenter, ms->origin, hordir);\n\t\t\thordir[2] = 0;\n\t\t\tdist = VectorNormalize(hordir);\n\t\t\t//\n\t\t\tif (dist > 10)\n\t\t\t{\n#ifdef DEBUG_FUNCBOB\n\t\t\t\tbotimport.Print(PRT_MESSAGE, \"bot moving to func_bobbing center\\n\");\n#endif\n\t\t\t\t//move to the center of the plat\n\t\t\t\tif (dist > 100) dist = 100;\n\t\t\t\tspeed = 400 - (400 - 4 * dist);\n\t\t\t\t//\n\t\t\t\tEA_Move(ms->client, hordir, speed);\n\t\t\t\tVectorCopy(hordir, result.movedir);\n\t\t\t} //end if\n\t\t} //end else\n\t} //end if\n\telse\n\t{\n#ifdef DEBUG_FUNCBOB\n\t\tbotimport.Print(PRT_MESSAGE, \"bot not ontop of func_bobbing\\n\");\n#endif\n\t\t//if very near the reachability end\n\t\tVectorSubtract(reach->end, ms->origin, dir);\n\t\tdist = VectorLength(dir);\n\t\tif (dist < 64)\n\t\t{\n#ifdef DEBUG_FUNCBOB\n\t\t\tbotimport.Print(PRT_MESSAGE, \"bot moving to end\\n\");\n#endif\n\t\t\tif (dist > 60) dist = 60;\n\t\t\tspeed = 360 - (360 - 6 * dist);\n\t\t\t//if swimming or no barrier jump\n\t\t\tif ((ms->moveflags & MFL_SWIMMING) || !BotCheckBarrierJump(ms, dir, 50))\n\t\t\t{\n\t\t\t\tif (speed > 5) EA_Move(ms->client, dir, speed);\n\t\t\t} //end if\n\t\t\tVectorCopy(dir, result.movedir);\n\t\t\t//\n\t\t\tif (ms->moveflags & MFL_SWIMMING) result.flags |= MOVERESULT_SWIMVIEW;\n\t\t\t//stop using this reachability\n\t\t\tms->reachability_time = 0;\n\t\t\treturn result;\n\t\t} //end if\n\t\t//get direction and distance to reachability start\n\t\tVectorSubtract(reach->start, ms->origin, dir1);\n\t\tif (!(ms->moveflags & MFL_SWIMMING)) dir1[2] = 0;\n\t\tdist1 = VectorNormalize(dir1);\n\t\t//if func_bobbing is Not it's start position\n\t\tVectorSubtract(bob_origin, bob_start, dir);\n\t\tif (VectorLength(dir) > 16)\n\t\t{\n#ifdef DEBUG_FUNCBOB\n\t\t\tbotimport.Print(PRT_MESSAGE, \"func_bobbing not at start\\n\");\n#endif\n\t\t\tdist = dist1;\n\t\t\tVectorCopy(dir1, dir);\n\t\t\t//\n\t\t\tBotCheckBlocked(ms, dir, qfalse, &result);\n\t\t\t//\n\t\t\tif (dist > 60) dist = 60;\n\t\t\tspeed = 360 - (360 - 6 * dist);\n\t\t\t//\n\t\t\tif (!(ms->moveflags & MFL_SWIMMING) && !BotCheckBarrierJump(ms, dir, 50))\n\t\t\t{\n\t\t\t\tif (speed > 5) EA_Move(ms->client, dir, speed);\n\t\t\t} //end if\n\t\t\tVectorCopy(dir, result.movedir);\n\t\t\t//\n\t\t\tif (ms->moveflags & MFL_SWIMMING) result.flags |= MOVERESULT_SWIMVIEW;\n\t\t\t//this isn't a failure... just wait till the func_bobbing arrives\n\t\t\tresult.type = RESULTTYPE_WAITFORFUNCBOBBING;\n\t\t\tresult.flags |= MOVERESULT_WAITING;\n\t\t\treturn result;\n\t\t} //end if\n\t\t//get direction and distance to func_bob bottom center\n\t\tMoverBottomCenter(reach, bottomcenter);\n\t\tVectorSubtract(bottomcenter, ms->origin, dir2);\n\t\tif (!(ms->moveflags & MFL_SWIMMING)) dir2[2] = 0;\n\t\tdist2 = VectorNormalize(dir2);\n\t\t//if very close to the reachability start or\n\t\t//closer to the elevator center or\n\t\t//between reachability start and func_bobbing center\n\t\tif (dist1 < 20 || dist2 < dist1 || DotProduct(dir1, dir2) < 0)\n\t\t{\n#ifdef DEBUG_FUNCBOB\n\t\t\tbotimport.Print(PRT_MESSAGE, \"bot moving to func_bobbing center\\n\");\n#endif\n\t\t\tdist = dist2;\n\t\t\tVectorCopy(dir2, dir);\n\t\t} //end if\n\t\telse //closer to the reachability start\n\t\t{\n#ifdef DEBUG_FUNCBOB\n\t\t\tbotimport.Print(PRT_MESSAGE, \"bot moving to reachability start\\n\");\n#endif\n\t\t\tdist = dist1;\n\t\t\tVectorCopy(dir1, dir);\n\t\t} //end else\n\t\t//\n\t\tBotCheckBlocked(ms, dir, qfalse, &result);\n\t\t//\n\t\tif (dist > 60) dist = 60;\n\t\tspeed = 400 - (400 - 6 * dist);\n\t\t//\n\t\tif (!(ms->moveflags & MFL_SWIMMING) && !BotCheckBarrierJump(ms, dir, 50))\n\t\t{\n\t\t\tEA_Move(ms->client, dir, speed);\n\t\t} //end if\n\t\tVectorCopy(dir, result.movedir);\n\t\t//\n\t\tif (ms->moveflags & MFL_SWIMMING) result.flags |= MOVERESULT_SWIMVIEW;\n\t} //end else\n\treturn result;\n} //end of the function BotTravel_FuncBobbing\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotFinishTravel_FuncBobbing(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tvec3_t bob_origin, bob_start, bob_end, dir, hordir, bottomcenter;\n\tbot_moveresult_t result;\n\tfloat dist, speed;\n\n\tBotClearMoveResult(&result);\n\t//\n\tBotFuncBobStartEnd(reach, bob_start, bob_end, bob_origin);\n\t//\n\tVectorSubtract(bob_origin, bob_end, dir);\n\tdist = VectorLength(dir);\n\t//if the func_bobbing is near the end\n\tif (dist < 16)\n\t{\n\t\tVectorSubtract(reach->end, ms->origin, hordir);\n\t\tif (!(ms->moveflags & MFL_SWIMMING)) hordir[2] = 0;\n\t\tdist = VectorNormalize(hordir);\n\t\t//\n\t\tif (dist > 60) dist = 60;\n\t\tspeed = 360 - (360 - 6 * dist);\n\t\t//\n\t\tif (speed > 5) EA_Move(ms->client, dir, speed);\n\t\tVectorCopy(dir, result.movedir);\n\t\t//\n\t\tif (ms->moveflags & MFL_SWIMMING) result.flags |= MOVERESULT_SWIMVIEW;\n\t} //end if\n\telse\n\t{\n\t\tMoverBottomCenter(reach, bottomcenter);\n\t\tVectorSubtract(bottomcenter, ms->origin, hordir);\n\t\tif (!(ms->moveflags & MFL_SWIMMING)) hordir[2] = 0;\n\t\tdist = VectorNormalize(hordir);\n\t\t//\n\t\tif (dist > 5)\n\t\t{\n\t\t\t//move to the center of the plat\n\t\t\tif (dist > 100) dist = 100;\n\t\t\tspeed = 400 - (400 - 4 * dist);\n\t\t\t//\n\t\t\tEA_Move(ms->client, hordir, speed);\n\t\t\tVectorCopy(hordir, result.movedir);\n\t\t} //end if\n\t} //end else\n\treturn result;\n} //end of the function BotFinishTravel_FuncBobbing\n//===========================================================================\n// 0  no valid grapple hook visible\n// 1  the grapple hook is still flying\n// 2  the grapple hooked into a wall\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint GrappleState(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tint i;\n\taas_entityinfo_t entinfo;\n\n\t//if the grapple hook is pulling\n\tif (ms->moveflags & MFL_GRAPPLEPULL)\n\t\treturn 2;\n\t//check for a visible grapple missile entity\n\t//or visible grapple entity\n\tfor (i = AAS_NextEntity(0); i; i = AAS_NextEntity(i))\n\t{\n\t\tif (AAS_EntityType(i) == (int) entitytypemissile->value)\n\t\t{\n\t\t\tAAS_EntityInfo(i, &entinfo);\n\t\t\tif (entinfo.weapon == (int) weapindex_grapple->value)\n\t\t\t{\n\t\t\t\treturn 1;\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n\t//no valid grapple at all\n\treturn 0;\n} //end of the function GrappleState\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotResetGrapple(bot_movestate_t *ms)\n{\n\taas_reachability_t reach;\n\n\tAAS_ReachabilityFromNum(ms->lastreachnum, &reach);\n\t//if not using the grapple hook reachability anymore\n\tif ((reach.traveltype & TRAVELTYPE_MASK) != TRAVEL_GRAPPLEHOOK)\n\t{\n\t\tif ((ms->moveflags & MFL_ACTIVEGRAPPLE) || ms->grapplevisible_time)\n\t\t{\n\t\t\tif (offhandgrapple->value)\n\t\t\t\tEA_Command(ms->client, cmd_grappleoff->string);\n\t\t\tms->moveflags &= ~MFL_ACTIVEGRAPPLE;\n\t\t\tms->grapplevisible_time = 0;\n#ifdef DEBUG_GRAPPLE\n\t\t\tbotimport.Print(PRT_MESSAGE, \"reset grapple\\n\");\n#endif //DEBUG_GRAPPLE\n\t\t} //end if\n\t} //end if\n} //end of the function BotResetGrapple\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotTravel_Grapple(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tbot_moveresult_t result;\n\tfloat dist, speed;\n\tvec3_t dir, viewdir, org;\n\tint state, areanum;\n\tbsp_trace_t trace;\n\n#ifdef DEBUG_GRAPPLE\n\tstatic int debugline;\n\tif (!debugline) debugline = botimport.DebugLineCreate();\n\tbotimport.DebugLineShow(debugline, reach->start, reach->end, LINECOLOR_BLUE);\n#endif //DEBUG_GRAPPLE\n\n\tBotClearMoveResult(&result);\n\t//\n\tif (ms->moveflags & MFL_GRAPPLERESET)\n\t{\n\t\tif (offhandgrapple->value)\n\t\t\tEA_Command(ms->client, cmd_grappleoff->string);\n\t\tms->moveflags &= ~MFL_ACTIVEGRAPPLE;\n\t\treturn result;\n\t} //end if\n\t//\n\tif (!(int) offhandgrapple->value)\n\t{\n\t\tresult.weapon = weapindex_grapple->value;\n\t\tresult.flags |= MOVERESULT_MOVEMENTWEAPON;\n\t} //end if\n\t//\n\tif (ms->moveflags & MFL_ACTIVEGRAPPLE)\n\t{\n#ifdef DEBUG_GRAPPLE\n\t\tbotimport.Print(PRT_MESSAGE, \"BotTravel_Grapple: active grapple\\n\");\n#endif //DEBUG_GRAPPLE\n\t\t//\n\t\tstate = GrappleState(ms, reach);\n\t\t//\n\t\tVectorSubtract(reach->end, ms->origin, dir);\n\t\tdir[2] = 0;\n\t\tdist = VectorLength(dir);\n\t\t//if very close to the grapple end or the grappled is hooked and\n\t\t//the bot doesn't get any closer\n\t\tif (state && dist < 48)\n\t\t{\n\t\t\tif (ms->lastgrappledist - dist < 1)\n\t\t\t{\n#ifdef DEBUG_GRAPPLE\n\t\t\t\tbotimport.Print(PRT_ERROR, \"grapple normal end\\n\");\n#endif //DEBUG_GRAPPLE\n\t\t\t\tif (offhandgrapple->value)\n\t\t\t\t\tEA_Command(ms->client, cmd_grappleoff->string);\n\t\t\t\tms->moveflags &= ~MFL_ACTIVEGRAPPLE;\n\t\t\t\tms->moveflags |= MFL_GRAPPLERESET;\n\t\t\t\tms->reachability_time = 0;\t//end the reachability\n\t\t\t\treturn result;\n\t\t\t} //end if\n\t\t} //end if\n\t\t//if no valid grapple at all, or the grapple hooked and the bot\n\t\t//isn't moving anymore\n\t\telse if (!state || (state == 2 && dist > ms->lastgrappledist - 2))\n\t\t{\n\t\t\tif (ms->grapplevisible_time < AAS_Time() - 0.4)\n\t\t\t{\n#ifdef DEBUG_GRAPPLE\n\t\t\t\tbotimport.Print(PRT_ERROR, \"grapple not visible\\n\");\n#endif //DEBUG_GRAPPLE\n\t\t\t\tif (offhandgrapple->value)\n\t\t\t\t\tEA_Command(ms->client, cmd_grappleoff->string);\n\t\t\t\tms->moveflags &= ~MFL_ACTIVEGRAPPLE;\n\t\t\t\tms->moveflags |= MFL_GRAPPLERESET;\n\t\t\t\tms->reachability_time = 0;\t//end the reachability\n\t\t\t\treturn result;\n\t\t\t} //end if\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tms->grapplevisible_time = AAS_Time();\n\t\t} //end else\n\t\t//\n\t\tif (!(int) offhandgrapple->value)\n\t\t{\n\t\t\tEA_Attack(ms->client);\n\t\t} //end if\n\t\t//remember the current grapple distance\n\t\tms->lastgrappledist = dist;\n\t} //end if\n\telse\n\t{\n#ifdef DEBUG_GRAPPLE\n\t\tbotimport.Print(PRT_MESSAGE, \"BotTravel_Grapple: inactive grapple\\n\");\n#endif //DEBUG_GRAPPLE\n\t\t//\n\t\tms->grapplevisible_time = AAS_Time();\n\t\t//\n\t\tVectorSubtract(reach->start, ms->origin, dir);\n\t\tif (!(ms->moveflags & MFL_SWIMMING)) dir[2] = 0;\n\t\tVectorAdd(ms->origin, ms->viewoffset, org);\n\t\tVectorSubtract(reach->end, org, viewdir);\n\t\t//\n\t\tdist = VectorNormalize(dir);\n\t\tVector2Angles(viewdir, result.ideal_viewangles);\n\t\tresult.flags |= MOVERESULT_MOVEMENTVIEW;\n\t\t//\n\t\tif (dist < 5 &&\n\t\t\tfabs(AngleDiff(result.ideal_viewangles[0], ms->viewangles[0])) < 2 &&\n\t\t\tfabs(AngleDiff(result.ideal_viewangles[1], ms->viewangles[1])) < 2)\n\t\t{\n#ifdef DEBUG_GRAPPLE\n\t\t\tbotimport.Print(PRT_MESSAGE, \"BotTravel_Grapple: activating grapple\\n\");\n#endif //DEBUG_GRAPPLE\n\t\t\t//check if the grapple missile path is clear\n\t\t\tVectorAdd(ms->origin, ms->viewoffset, org);\n\t\t\ttrace = AAS_Trace(org, NULL, NULL, reach->end, ms->entitynum, CONTENTS_SOLID);\n\t\t\tVectorSubtract(reach->end, trace.endpos, dir);\n\t\t\tif (VectorLength(dir) > 16)\n\t\t\t{\n\t\t\t\tresult.failure = qtrue;\n\t\t\t\treturn result;\n\t\t\t} //end if\n\t\t\t//activate the grapple\n\t\t\tif (offhandgrapple->value)\n\t\t\t{\n\t\t\t\tEA_Command(ms->client, cmd_grappleon->string);\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tEA_Attack(ms->client);\n\t\t\t} //end else\n\t\t\tms->moveflags |= MFL_ACTIVEGRAPPLE;\n\t\t\tms->lastgrappledist = 999999;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tif (dist < 70) speed = 300 - (300 - 4 * dist);\n\t\t\telse speed = 400;\n\t\t\t//\n\t\t\tBotCheckBlocked(ms, dir, qtrue, &result);\n\t\t\t//elemantary action move in direction\n\t\t\tEA_Move(ms->client, dir, speed);\n\t\t\tVectorCopy(dir, result.movedir);\n\t\t} //end else\n\t\t//if in another area before actually grappling\n\t\tareanum = AAS_PointAreaNum(ms->origin);\n\t\tif (areanum && areanum != ms->reachareanum) ms->reachability_time = 0;\n\t} //end else\n\treturn result;\n} //end of the function BotTravel_Grapple\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t\t-\n//===========================================================================\nbot_moveresult_t BotTravel_RocketJump(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tvec3_t hordir;\n\tfloat dist, speed;\n\tbot_moveresult_t result;\n\n\t//botimport.Print(PRT_MESSAGE, \"BotTravel_RocketJump: bah\\n\");\n\tBotClearMoveResult(&result);\n\t//\n\thordir[0] = reach->start[0] - ms->origin[0];\n\thordir[1] = reach->start[1] - ms->origin[1];\n\thordir[2] = 0;\n\t//\n\tdist = VectorNormalize(hordir);\n\t//look in the movement direction\n\tVector2Angles(hordir, result.ideal_viewangles);\n\t//look straight down\n\tresult.ideal_viewangles[PITCH] = 90;\n\t//\n\tif (dist < 5 &&\n\t\t\tfabs(AngleDiff(result.ideal_viewangles[0], ms->viewangles[0])) < 5 &&\n\t\t\tfabs(AngleDiff(result.ideal_viewangles[1], ms->viewangles[1])) < 5)\n\t{\n\t\t//botimport.Print(PRT_MESSAGE, \"between jump start and run start point\\n\");\n\t\thordir[0] = reach->end[0] - ms->origin[0];\n\t\thordir[1] = reach->end[1] - ms->origin[1];\n\t\thordir[2] = 0;\n\t\tVectorNormalize(hordir);\n\t\t//elemantary action jump\n\t\tEA_Jump(ms->client);\n\t\tEA_Attack(ms->client);\n\t\tEA_Move(ms->client, hordir, 800);\n\t\t//\n\t\tms->jumpreach = ms->lastreachnum;\n\t} //end if\n\telse\n\t{\n\t\tif (dist > 80) dist = 80;\n\t\tspeed = 400 - (400 - 5 * dist);\n\t\tEA_Move(ms->client, hordir, speed);\n\t} //end else\n\t//look in the movement direction\n\tVector2Angles(hordir, result.ideal_viewangles);\n\t//look straight down\n\tresult.ideal_viewangles[PITCH] = 90;\n\t//set the view angles directly\n\tEA_View(ms->client, result.ideal_viewangles);\n\t//view is important for the movment\n\tresult.flags |= MOVERESULT_MOVEMENTVIEWSET;\n\t//select the rocket launcher\n\tEA_SelectWeapon(ms->client, (int) weapindex_rocketlauncher->value);\n\t//weapon is used for movement\n\tresult.weapon = (int) weapindex_rocketlauncher->value;\n\tresult.flags |= MOVERESULT_MOVEMENTWEAPON;\n\t//\n\tVectorCopy(hordir, result.movedir);\n\t//\n\treturn result;\n} //end of the function BotTravel_RocketJump\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotTravel_BFGJump(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tvec3_t hordir;\n\tfloat dist, speed;\n\tbot_moveresult_t result;\n\n\t//botimport.Print(PRT_MESSAGE, \"BotTravel_BFGJump: bah\\n\");\n\tBotClearMoveResult(&result);\n\t//\n\thordir[0] = reach->start[0] - ms->origin[0];\n\thordir[1] = reach->start[1] - ms->origin[1];\n\thordir[2] = 0;\n\t//\n\tdist = VectorNormalize(hordir);\n\t//\n\tif (dist < 5 &&\n\t\t\tfabs(AngleDiff(result.ideal_viewangles[0], ms->viewangles[0])) < 5 &&\n\t\t\tfabs(AngleDiff(result.ideal_viewangles[1], ms->viewangles[1])) < 5)\n\t{\n\t\t//botimport.Print(PRT_MESSAGE, \"between jump start and run start point\\n\");\n\t\thordir[0] = reach->end[0] - ms->origin[0];\n\t\thordir[1] = reach->end[1] - ms->origin[1];\n\t\thordir[2] = 0;\n\t\tVectorNormalize(hordir);\n\t\t//elemantary action jump\n\t\tEA_Jump(ms->client);\n\t\tEA_Attack(ms->client);\n\t\tEA_Move(ms->client, hordir, 800);\n\t\t//\n\t\tms->jumpreach = ms->lastreachnum;\n\t} //end if\n\telse\n\t{\n\t\tif (dist > 80) dist = 80;\n\t\tspeed = 400 - (400 - 5 * dist);\n\t\tEA_Move(ms->client, hordir, speed);\n\t} //end else\n\t//look in the movement direction\n\tVector2Angles(hordir, result.ideal_viewangles);\n\t//look straight down\n\tresult.ideal_viewangles[PITCH] = 90;\n\t//set the view angles directly\n\tEA_View(ms->client, result.ideal_viewangles);\n\t//view is important for the movment\n\tresult.flags |= MOVERESULT_MOVEMENTVIEWSET;\n\t//select the rocket launcher\n\tEA_SelectWeapon(ms->client, (int) weapindex_bfg10k->value);\n\t//weapon is used for movement\n\tresult.weapon = (int) weapindex_bfg10k->value;\n\tresult.flags |= MOVERESULT_MOVEMENTWEAPON;\n\t//\n\tVectorCopy(hordir, result.movedir);\n\t//\n\treturn result;\n} //end of the function BotTravel_BFGJump\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotFinishTravel_WeaponJump(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tvec3_t hordir;\n\tfloat speed;\n\tbot_moveresult_t result;\n\n\tBotClearMoveResult(&result);\n\t//if not jumped yet\n\tif (!ms->jumpreach) return result;\n\t/*\n\t//go straight to the reachability end\n\thordir[0] = reach->end[0] - ms->origin[0];\n\thordir[1] = reach->end[1] - ms->origin[1];\n\thordir[2] = 0;\n\tVectorNormalize(hordir);\n\t//always use max speed when traveling through the air\n\tEA_Move(ms->client, hordir, 800);\n\tVectorCopy(hordir, result.movedir);\n\t*/\n\t//\n\tif (!BotAirControl(ms->origin, ms->velocity, reach->end, hordir, &speed))\n\t{\n\t\t//go straight to the reachability end\n\t\tVectorSubtract(reach->end, ms->origin, hordir);\n\t\thordir[2] = 0;\n\t\tVectorNormalize(hordir);\n\t\tspeed = 400;\n\t} //end if\n\t//\n\tEA_Move(ms->client, hordir, speed);\n\tVectorCopy(hordir, result.movedir);\n\t//\n\treturn result;\n} //end of the function BotFinishTravel_WeaponJump\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotTravel_JumpPad(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tfloat dist, speed;\n\tvec3_t hordir;\n\tbot_moveresult_t result;\n\n\tBotClearMoveResult(&result);\n\t//first walk straight to the reachability start\n\thordir[0] = reach->start[0] - ms->origin[0];\n\thordir[1] = reach->start[1] - ms->origin[1];\n\thordir[2] = 0;\n\tdist = VectorNormalize(hordir);\n\t//\n\tBotCheckBlocked(ms, hordir, qtrue, &result);\n\tspeed = 400;\n\t//elemantary action move in direction\n\tEA_Move(ms->client, hordir, speed);\n\tVectorCopy(hordir, result.movedir);\n\t//\n\treturn result;\n} //end of the function BotTravel_JumpPad\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotFinishTravel_JumpPad(bot_movestate_t *ms, aas_reachability_t *reach)\n{\n\tfloat speed;\n\tvec3_t hordir;\n\tbot_moveresult_t result;\n\n\tBotClearMoveResult(&result);\n\tif (!BotAirControl(ms->origin, ms->velocity, reach->end, hordir, &speed))\n\t{\n\t\thordir[0] = reach->end[0] - ms->origin[0];\n\t\thordir[1] = reach->end[1] - ms->origin[1];\n\t\thordir[2] = 0;\n\t\tVectorNormalize(hordir);\n\t\tspeed = 400;\n\t} //end if\n\tBotCheckBlocked(ms, hordir, qtrue, &result);\n\t//elemantary action move in direction\n\tEA_Move(ms->client, hordir, speed);\n\tVectorCopy(hordir, result.movedir);\n\t//\n\treturn result;\n} //end of the function BotFinishTravel_JumpPad\n//===========================================================================\n// time before the reachability times out\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotReachabilityTime(aas_reachability_t *reach)\n{\n\tswitch(reach->traveltype & TRAVELTYPE_MASK)\n\t{\n\t\tcase TRAVEL_WALK: return 5;\n\t\tcase TRAVEL_CROUCH: return 5;\n\t\tcase TRAVEL_BARRIERJUMP: return 5;\n\t\tcase TRAVEL_LADDER: return 6;\n\t\tcase TRAVEL_WALKOFFLEDGE: return 5;\n\t\tcase TRAVEL_JUMP: return 5;\n\t\tcase TRAVEL_SWIM: return 5;\n\t\tcase TRAVEL_WATERJUMP: return 5;\n\t\tcase TRAVEL_TELEPORT: return 5;\n\t\tcase TRAVEL_ELEVATOR: return 10;\n\t\tcase TRAVEL_GRAPPLEHOOK: return 8;\n\t\tcase TRAVEL_ROCKETJUMP: return 6;\n\t\tcase TRAVEL_BFGJUMP: return 6;\n\t\tcase TRAVEL_JUMPPAD: return 10;\n\t\tcase TRAVEL_FUNCBOB: return 10;\n\t\tdefault:\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"travel type %d not implemented yet\\n\", reach->traveltype);\n\t\t\treturn 8;\n\t\t} //end case\n\t} //end switch\n} //end of the function BotReachabilityTime\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbot_moveresult_t BotMoveInGoalArea(bot_movestate_t *ms, bot_goal_t *goal)\n{\n\tbot_moveresult_t result;\n\tvec3_t dir;\n\tfloat dist, speed;\n\n#ifdef DEBUG\n\t//botimport.Print(PRT_MESSAGE, \"%s: moving straight to goal\\n\", ClientName(ms->entitynum-1));\n\t//AAS_ClearShownDebugLines();\n\t//AAS_DebugLine(ms->origin, goal->origin, LINECOLOR_RED);\n#endif //DEBUG\n\tBotClearMoveResult(&result);\n\t//walk straight to the goal origin\n\tdir[0] = goal->origin[0] - ms->origin[0];\n\tdir[1] = goal->origin[1] - ms->origin[1];\n\tif (ms->moveflags & MFL_SWIMMING)\n\t{\n\t\tdir[2] = goal->origin[2] - ms->origin[2];\n\t\tresult.traveltype = TRAVEL_SWIM;\n\t} //end if\n\telse\n\t{\n\t\tdir[2] = 0;\n\t\tresult.traveltype = TRAVEL_WALK;\n\t} //endif\n\t//\n\tdist = VectorNormalize(dir);\n\tif (dist > 100) dist = 100;\n\tspeed = 400 - (400 - 4 * dist);\n\tif (speed < 10) speed = 0;\n\t//\n\tBotCheckBlocked(ms, dir, qtrue, &result);\n\t//elemantary action move in direction\n\tEA_Move(ms->client, dir, speed);\n\tVectorCopy(dir, result.movedir);\n\t//\n\tif (ms->moveflags & MFL_SWIMMING)\n\t{\n\t\tVector2Angles(dir, result.ideal_viewangles);\n\t\tresult.flags |= MOVERESULT_SWIMVIEW;\n\t} //end if\n\t//if (!debugline) debugline = botimport.DebugLineCreate();\n\t//botimport.DebugLineShow(debugline, ms->origin, goal->origin, LINECOLOR_BLUE);\n\t//\n\tms->lastreachnum = 0;\n\tms->lastareanum = 0;\n\tms->lastgoalareanum = goal->areanum;\n\tVectorCopy(ms->origin, ms->lastorigin);\n\t//\n\treturn result;\n} //end of the function BotMoveInGoalArea\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, int travelflags)\n{\n\tint reachnum, lastreachnum, foundjumppad, ent, resultflags;\n\taas_reachability_t reach, lastreach;\n\tbot_movestate_t *ms;\n\t//vec3_t mins, maxs, up = {0, 0, 1};\n\t//bsp_trace_t trace;\n\t//static int debugline;\n\n\n\tBotClearMoveResult(result);\n\t//\n\tms = BotMoveStateFromHandle(movestate);\n\tif (!ms) return;\n\t//reset the grapple before testing if the bot has a valid goal\n\t//because the bot could loose all it's goals when stuck to a wall\n\tBotResetGrapple(ms);\n\t//\n\tif (!goal)\n\t{\n#ifdef DEBUG\n\t\tbotimport.Print(PRT_MESSAGE, \"client %d: movetogoal -> no goal\\n\", ms->client);\n#endif //DEBUG\n\t\tresult->failure = qtrue;\n\t\treturn;\n\t} //end if\n\t//botimport.Print(PRT_MESSAGE, \"numavoidreach = %d\\n\", ms->numavoidreach);\n\t//remove some of the move flags\n\tms->moveflags &= ~(MFL_SWIMMING|MFL_AGAINSTLADDER);\n\t//set some of the move flags\n\t//NOTE: the MFL_ONGROUND flag is also set in the higher AI\n\tif (AAS_OnGround(ms->origin, ms->presencetype, ms->entitynum)) ms->moveflags |= MFL_ONGROUND;\n\t//\n\tif (ms->moveflags & MFL_ONGROUND)\n\t{\n\t\tint modeltype, modelnum;\n\n\t\tent = BotOnTopOfEntity(ms);\n\n\t\tif (ent != -1)\n\t\t{\n\t\t\tmodelnum = AAS_EntityModelindex(ent);\n\t\t\tif (modelnum >= 0 && modelnum < MAX_MODELS)\n\t\t\t{\n\t\t\t\tmodeltype = modeltypes[modelnum];\n\n\t\t\t\tif (modeltype == MODELTYPE_FUNC_PLAT)\n\t\t\t\t{\n\t\t\t\t\tAAS_ReachabilityFromNum(ms->lastreachnum, &reach);\n\t\t\t\t\t//if the bot is Not using the elevator\n\t\t\t\t\tif ((reach.traveltype & TRAVELTYPE_MASK) != TRAVEL_ELEVATOR ||\n\t\t\t\t\t\t//NOTE: the face number is the plat model number\n\t\t\t\t\t\t(reach.facenum & 0x0000FFFF) != modelnum)\n\t\t\t\t\t{\n\t\t\t\t\t\treachnum = AAS_NextModelReachability(0, modelnum);\n\t\t\t\t\t\tif (reachnum)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t//botimport.Print(PRT_MESSAGE, \"client %d: accidentally ended up on func_plat\\n\", ms->client);\n\t\t\t\t\t\t\tAAS_ReachabilityFromNum(reachnum, &reach);\n\t\t\t\t\t\t\tms->lastreachnum = reachnum;\n\t\t\t\t\t\t\tms->reachability_time = AAS_Time() + BotReachabilityTime(&reach);\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (bot_developer)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbotimport.Print(PRT_MESSAGE, \"client %d: on func_plat without reachability\\n\", ms->client);\n\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\tresult->blocked = qtrue;\n\t\t\t\t\t\t\tresult->blockentity = ent;\n\t\t\t\t\t\t\tresult->flags |= MOVERESULT_ONTOPOFOBSTACLE;\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t} //end else\n\t\t\t\t\t} //end if\n\t\t\t\t\tresult->flags |= MOVERESULT_ONTOPOF_ELEVATOR;\n\t\t\t\t} //end if\n\t\t\t\telse if (modeltype == MODELTYPE_FUNC_BOB)\n\t\t\t\t{\n\t\t\t\t\tAAS_ReachabilityFromNum(ms->lastreachnum, &reach);\n\t\t\t\t\t//if the bot is Not using the func bobbing\n\t\t\t\t\tif ((reach.traveltype & TRAVELTYPE_MASK) != TRAVEL_FUNCBOB ||\n\t\t\t\t\t\t//NOTE: the face number is the func_bobbing model number\n\t\t\t\t\t\t(reach.facenum & 0x0000FFFF) != modelnum)\n\t\t\t\t\t{\n\t\t\t\t\t\treachnum = AAS_NextModelReachability(0, modelnum);\n\t\t\t\t\t\tif (reachnum)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t//botimport.Print(PRT_MESSAGE, \"client %d: accidentally ended up on func_bobbing\\n\", ms->client);\n\t\t\t\t\t\t\tAAS_ReachabilityFromNum(reachnum, &reach);\n\t\t\t\t\t\t\tms->lastreachnum = reachnum;\n\t\t\t\t\t\t\tms->reachability_time = AAS_Time() + BotReachabilityTime(&reach);\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (bot_developer)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbotimport.Print(PRT_MESSAGE, \"client %d: on func_bobbing without reachability\\n\", ms->client);\n\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\tresult->blocked = qtrue;\n\t\t\t\t\t\t\tresult->blockentity = ent;\n\t\t\t\t\t\t\tresult->flags |= MOVERESULT_ONTOPOFOBSTACLE;\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t} //end else\n\t\t\t\t\t} //end if\n\t\t\t\t\tresult->flags |= MOVERESULT_ONTOPOF_FUNCBOB;\n\t\t\t\t} //end if\n\t\t\t\telse if (modeltype == MODELTYPE_FUNC_STATIC || modeltype == MODELTYPE_FUNC_DOOR)\n\t\t\t\t{\n\t\t\t\t\t// check if ontop of a door bridge ?\n\t\t\t\t\tms->areanum = BotFuzzyPointReachabilityArea(ms->origin);\n\t\t\t\t\t// if not in a reachability area\n\t\t\t\t\tif (!AAS_AreaReachability(ms->areanum))\n\t\t\t\t\t{\n\t\t\t\t\t\tresult->blocked = qtrue;\n\t\t\t\t\t\tresult->blockentity = ent;\n\t\t\t\t\t\tresult->flags |= MOVERESULT_ONTOPOFOBSTACLE;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end else if\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tresult->blocked = qtrue;\n\t\t\t\t\tresult->blockentity = ent;\n\t\t\t\t\tresult->flags |= MOVERESULT_ONTOPOFOBSTACLE;\n\t\t\t\t\treturn;\n\t\t\t\t} //end else\n\t\t\t} //end if\n\t\t} //end if\n\t} //end if\n\t//if swimming\n\tif (AAS_Swimming(ms->origin)) ms->moveflags |= MFL_SWIMMING;\n\t//if against a ladder\n\tif (AAS_AgainstLadder(ms->origin)) ms->moveflags |= MFL_AGAINSTLADDER;\n\t//if the bot is on the ground, swimming or against a ladder\n\tif (ms->moveflags & (MFL_ONGROUND|MFL_SWIMMING|MFL_AGAINSTLADDER))\n\t{\n\t\t//botimport.Print(PRT_MESSAGE, \"%s: onground, swimming or against ladder\\n\", ClientName(ms->entitynum-1));\n\t\t//\n\t\tAAS_ReachabilityFromNum(ms->lastreachnum, &lastreach);\n\t\t//reachability area the bot is in\n\t\t//ms->areanum = BotReachabilityArea(ms->origin, ((lastreach.traveltype & TRAVELTYPE_MASK) != TRAVEL_ELEVATOR));\n\t\tms->areanum = BotFuzzyPointReachabilityArea(ms->origin);\n\t\t//\n\t\tif ( !ms->areanum )\n\t\t{\n\t\t\tresult->failure = qtrue;\n\t\t\tresult->blocked = qtrue;\n\t\t\tresult->blockentity = 0;\n\t\t\tresult->type = RESULTTYPE_INSOLIDAREA;\n\t\t\treturn;\n\t\t} //end if\n\t\t//if the bot is in the goal area\n\t\tif (ms->areanum == goal->areanum)\n\t\t{\n\t\t\t*result = BotMoveInGoalArea(ms, goal);\n\t\t\treturn;\n\t\t} //end if\n\t\t//assume we can use the reachability from the last frame\n\t\treachnum = ms->lastreachnum;\n\t\t//if there is a last reachability\n\t\tif (reachnum)\n\t\t{\n\t\t\tAAS_ReachabilityFromNum(reachnum, &reach);\n\t\t\t//check if the reachability is still valid\n\t\t\tif (!(AAS_TravelFlagForType(reach.traveltype) & travelflags))\n\t\t\t{\n\t\t\t\treachnum = 0;\n\t\t\t} //end if\n\t\t\t//special grapple hook case\n\t\t\telse if ((reach.traveltype & TRAVELTYPE_MASK) == TRAVEL_GRAPPLEHOOK)\n\t\t\t{\n\t\t\t\tif (ms->reachability_time < AAS_Time() ||\n\t\t\t\t\t(ms->moveflags & MFL_GRAPPLERESET))\n\t\t\t\t{\n\t\t\t\t\treachnum = 0;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t\t//special elevator case\n\t\t\telse if ((reach.traveltype & TRAVELTYPE_MASK) == TRAVEL_ELEVATOR ||\n\t\t\t\t(reach.traveltype & TRAVELTYPE_MASK) == TRAVEL_FUNCBOB)\n\t\t\t{\n\t\t\t\tif ((result->flags & MOVERESULT_ONTOPOF_FUNCBOB) ||\n\t\t\t\t\t(result->flags & MOVERESULT_ONTOPOF_FUNCBOB))\n\t\t\t\t{\n\t\t\t\t\tms->reachability_time = AAS_Time() + 5;\n\t\t\t\t} //end if\n\t\t\t\t//if the bot was going for an elevator and reached the reachability area\n\t\t\t\tif (ms->areanum == reach.areanum ||\n\t\t\t\t\tms->reachability_time < AAS_Time())\n\t\t\t\t{\n\t\t\t\t\treachnum = 0;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n#ifdef DEBUG\n\t\t\t\tif (bot_developer)\n\t\t\t\t{\n\t\t\t\t\tif (ms->reachability_time < AAS_Time())\n\t\t\t\t\t{\n\t\t\t\t\t\tbotimport.Print(PRT_MESSAGE, \"client %d: reachability timeout in \", ms->client);\n\t\t\t\t\t\tAAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK);\n\t\t\t\t\t\tbotimport.Print(PRT_MESSAGE, \"\\n\");\n\t\t\t\t\t} //end if\n\t\t\t\t\t/*\n\t\t\t\t\tif (ms->lastareanum != ms->areanum)\n\t\t\t\t\t{\n\t\t\t\t\t\tbotimport.Print(PRT_MESSAGE, \"changed from area %d to %d\\n\", ms->lastareanum, ms->areanum);\n\t\t\t\t\t} //end if*/\n\t\t\t\t} //end if\n#endif //DEBUG\n\t\t\t\t//if the goal area changed or the reachability timed out\n\t\t\t\t//or the area changed\n\t\t\t\tif (ms->lastgoalareanum != goal->areanum ||\n\t\t\t\t\t\tms->reachability_time < AAS_Time() ||\n\t\t\t\t\t\tms->lastareanum != ms->areanum)\n\t\t\t\t{\n\t\t\t\t\treachnum = 0;\n\t\t\t\t\t//botimport.Print(PRT_MESSAGE, \"area change or timeout\\n\");\n\t\t\t\t} //end else if\n\t\t\t} //end else\n\t\t} //end if\n\t\tresultflags = 0;\n\t\t//if the bot needs a new reachability\n\t\tif (!reachnum)\n\t\t{\n\t\t\t//if the area has no reachability links\n\t\t\tif (!AAS_AreaReachability(ms->areanum))\n\t\t\t{\n#ifdef DEBUG\n\t\t\t\tif (bot_developer)\n\t\t\t\t{\n\t\t\t\t\tbotimport.Print(PRT_MESSAGE, \"area %d no reachability\\n\", ms->areanum);\n\t\t\t\t} //end if\n#endif //DEBUG\n\t\t\t} //end if\n\t\t\t//get a new reachability leading towards the goal\n\t\t\treachnum = BotGetReachabilityToGoal(ms->origin, ms->areanum,\n\t\t\t\t\t\t\t\tms->lastgoalareanum, ms->lastareanum,\n\t\t\t\t\t\t\t\t\t\t\tms->avoidreach, ms->avoidreachtimes, ms->avoidreachtries,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tgoal, travelflags, travelflags,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tms->avoidspots, ms->numavoidspots, &resultflags);\n\t\t\t//the area number the reachability starts in\n\t\t\tms->reachareanum = ms->areanum;\n\t\t\t//reset some state variables\n\t\t\tms->jumpreach = 0;\t\t\t\t\t\t//for TRAVEL_JUMP\n\t\t\tms->moveflags &= ~MFL_GRAPPLERESET;\t//for TRAVEL_GRAPPLEHOOK\n\t\t\t//if there is a reachability to the goal\n\t\t\tif (reachnum)\n\t\t\t{\n\t\t\t\tAAS_ReachabilityFromNum(reachnum, &reach);\n\t\t\t\t//set a timeout for this reachability\n\t\t\t\tms->reachability_time = AAS_Time() + BotReachabilityTime(&reach);\n\t\t\t\t//\n#ifdef AVOIDREACH\n\t\t\t\t//add the reachability to the reachabilities to avoid for a while\n\t\t\t\tBotAddToAvoidReach(ms, reachnum, AVOIDREACH_TIME);\n#endif //AVOIDREACH\n\t\t\t} //end if\n#ifdef DEBUG\n\t\t\t\n\t\t\telse if (bot_developer)\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_MESSAGE, \"goal not reachable\\n\");\n\t\t\t\tCom_Memset(&reach, 0, sizeof(aas_reachability_t)); //make compiler happy\n\t\t\t} //end else\n\t\t\tif (bot_developer)\n\t\t\t{\n\t\t\t\t//if still going for the same goal\n\t\t\t\tif (ms->lastgoalareanum == goal->areanum)\n\t\t\t\t{\n\t\t\t\t\tif (ms->lastareanum == reach.areanum)\n\t\t\t\t\t{\n\t\t\t\t\t\tbotimport.Print(PRT_MESSAGE, \"same goal, going back to previous area\\n\");\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t} //end if\n#endif //DEBUG\n\t\t} //end else\n\t\t//\n\t\tms->lastreachnum = reachnum;\n\t\tms->lastgoalareanum = goal->areanum;\n\t\tms->lastareanum = ms->areanum;\n\t\t//if the bot has a reachability\n\t\tif (reachnum)\n\t\t{\n\t\t\t//get the reachability from the number\n\t\t\tAAS_ReachabilityFromNum(reachnum, &reach);\n\t\t\tresult->traveltype = reach.traveltype;\n\t\t\t//\n#ifdef DEBUG_AI_MOVE\n\t\t\tAAS_ClearShownDebugLines();\n\t\t\tAAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK);\n\t\t\tAAS_ShowReachability(&reach);\n#endif //DEBUG_AI_MOVE\n\t\t\t//\n#ifdef DEBUG\n\t\t\t//botimport.Print(PRT_MESSAGE, \"client %d: \", ms->client);\n\t\t\t//AAS_PrintTravelType(reach.traveltype);\n\t\t\t//botimport.Print(PRT_MESSAGE, \"\\n\");\n#endif //DEBUG\n\t\t\tswitch(reach.traveltype & TRAVELTYPE_MASK)\n\t\t\t{\n\t\t\t\tcase TRAVEL_WALK: *result = BotTravel_Walk(ms, &reach); break;\n\t\t\t\tcase TRAVEL_CROUCH: *result = BotTravel_Crouch(ms, &reach); break;\n\t\t\t\tcase TRAVEL_BARRIERJUMP: *result = BotTravel_BarrierJump(ms, &reach); break;\n\t\t\t\tcase TRAVEL_LADDER: *result = BotTravel_Ladder(ms, &reach); break;\n\t\t\t\tcase TRAVEL_WALKOFFLEDGE: *result = BotTravel_WalkOffLedge(ms, &reach); break;\n\t\t\t\tcase TRAVEL_JUMP: *result = BotTravel_Jump(ms, &reach); break;\n\t\t\t\tcase TRAVEL_SWIM: *result = BotTravel_Swim(ms, &reach); break;\n\t\t\t\tcase TRAVEL_WATERJUMP: *result = BotTravel_WaterJump(ms, &reach); break;\n\t\t\t\tcase TRAVEL_TELEPORT: *result = BotTravel_Teleport(ms, &reach); break;\n\t\t\t\tcase TRAVEL_ELEVATOR: *result = BotTravel_Elevator(ms, &reach); break;\n\t\t\t\tcase TRAVEL_GRAPPLEHOOK: *result = BotTravel_Grapple(ms, &reach); break;\n\t\t\t\tcase TRAVEL_ROCKETJUMP: *result = BotTravel_RocketJump(ms, &reach); break;\n\t\t\t\tcase TRAVEL_BFGJUMP: *result = BotTravel_BFGJump(ms, &reach); break;\n\t\t\t\tcase TRAVEL_JUMPPAD: *result = BotTravel_JumpPad(ms, &reach); break;\n\t\t\t\tcase TRAVEL_FUNCBOB: *result = BotTravel_FuncBobbing(ms, &reach); break;\n\t\t\t\tdefault:\n\t\t\t\t{\n\t\t\t\t\tbotimport.Print(PRT_FATAL, \"travel type %d not implemented yet\\n\", (reach.traveltype & TRAVELTYPE_MASK));\n\t\t\t\t\tbreak;\n\t\t\t\t} //end case\n\t\t\t} //end switch\n\t\t\tresult->traveltype = reach.traveltype;\n\t\t\tresult->flags |= resultflags;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tresult->failure = qtrue;\n\t\t\tresult->flags |= resultflags;\n\t\t\tCom_Memset(&reach, 0, sizeof(aas_reachability_t));\n\t\t} //end else\n#ifdef DEBUG\n\t\tif (bot_developer)\n\t\t{\n\t\t\tif (result->failure)\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_MESSAGE, \"client %d: movement failure in \", ms->client);\n\t\t\t\tAAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK);\n\t\t\t\tbotimport.Print(PRT_MESSAGE, \"\\n\");\n\t\t\t} //end if\n\t\t} //end if\n#endif //DEBUG\n\t} //end if\n\telse\n\t{\n\t\tint i, numareas, areas[16];\n\t\tvec3_t end;\n\n\t\t//special handling of jump pads when the bot uses a jump pad without knowing it\n\t\tfoundjumppad = qfalse;\n\t\tVectorMA(ms->origin, -2 * ms->thinktime, ms->velocity, end);\n\t\tnumareas = AAS_TraceAreas(ms->origin, end, areas, NULL, 16);\n\t\tfor (i = numareas-1; i >= 0; i--)\n\t\t{\n\t\t\tif (AAS_AreaJumpPad(areas[i]))\n\t\t\t{\n\t\t\t\t//botimport.Print(PRT_MESSAGE, \"client %d used a jumppad without knowing, area %d\\n\", ms->client, areas[i]);\n\t\t\t\tfoundjumppad = qtrue;\n\t\t\t\tlastreachnum = BotGetReachabilityToGoal(end, areas[i],\n\t\t\t\t\t\t\tms->lastgoalareanum, ms->lastareanum,\n\t\t\t\t\t\t\tms->avoidreach, ms->avoidreachtimes, ms->avoidreachtries,\n\t\t\t\t\t\t\tgoal, travelflags, TFL_JUMPPAD, ms->avoidspots, ms->numavoidspots, NULL);\n\t\t\t\tif (lastreachnum)\n\t\t\t\t{\n\t\t\t\t\tms->lastreachnum = lastreachnum;\n\t\t\t\t\tms->lastareanum = areas[i];\n\t\t\t\t\t//botimport.Print(PRT_MESSAGE, \"found jumppad reachability\\n\");\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tfor (lastreachnum = AAS_NextAreaReachability(areas[i], 0); lastreachnum;\n\t\t\t\t\t\tlastreachnum = AAS_NextAreaReachability(areas[i], lastreachnum))\n\t\t\t\t\t{\n\t\t\t\t\t\t//get the reachability from the number\n\t\t\t\t\t\tAAS_ReachabilityFromNum(lastreachnum, &reach);\n\t\t\t\t\t\tif ((reach.traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMPPAD)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tms->lastreachnum = lastreachnum;\n\t\t\t\t\t\t\tms->lastareanum = areas[i];\n\t\t\t\t\t\t\t//botimport.Print(PRT_MESSAGE, \"found jumppad reachability hard!!\\n\");\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end for\n\t\t\t\t\tif (lastreachnum) break;\n\t\t\t\t} //end else\n\t\t\t} //end if\n\t\t} //end for\n\t\tif (bot_developer)\n\t\t{\n\t\t\t//if a jumppad is found with the trace but no reachability is found\n\t\t\tif (foundjumppad && !ms->lastreachnum)\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_MESSAGE, \"client %d didn't find jumppad reachability\\n\", ms->client);\n\t\t\t} //end if\n\t\t} //end if\n\t\t//\n\t\tif (ms->lastreachnum)\n\t\t{\n\t\t\t//botimport.Print(PRT_MESSAGE, \"%s: NOT onground, swimming or against ladder\\n\", ClientName(ms->entitynum-1));\n\t\t\tAAS_ReachabilityFromNum(ms->lastreachnum, &reach);\n\t\t\tresult->traveltype = reach.traveltype;\n#ifdef DEBUG\n\t\t\t//botimport.Print(PRT_MESSAGE, \"client %d finish: \", ms->client);\n\t\t\t//AAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK);\n\t\t\t//botimport.Print(PRT_MESSAGE, \"\\n\");\n#endif //DEBUG\n\t\t\t//\n\t\t\tswitch(reach.traveltype & TRAVELTYPE_MASK)\n\t\t\t{\n\t\t\t\tcase TRAVEL_WALK: *result = BotTravel_Walk(ms, &reach); break;//BotFinishTravel_Walk(ms, &reach); break;\n\t\t\t\tcase TRAVEL_CROUCH: /*do nothing*/ break;\n\t\t\t\tcase TRAVEL_BARRIERJUMP: *result = BotFinishTravel_BarrierJump(ms, &reach); break;\n\t\t\t\tcase TRAVEL_LADDER: *result = BotTravel_Ladder(ms, &reach); break;\n\t\t\t\tcase TRAVEL_WALKOFFLEDGE: *result = BotFinishTravel_WalkOffLedge(ms, &reach); break;\n\t\t\t\tcase TRAVEL_JUMP: *result = BotFinishTravel_Jump(ms, &reach); break;\n\t\t\t\tcase TRAVEL_SWIM: *result = BotTravel_Swim(ms, &reach); break;\n\t\t\t\tcase TRAVEL_WATERJUMP: *result = BotFinishTravel_WaterJump(ms, &reach); break;\n\t\t\t\tcase TRAVEL_TELEPORT: /*do nothing*/ break;\n\t\t\t\tcase TRAVEL_ELEVATOR: *result = BotFinishTravel_Elevator(ms, &reach); break;\n\t\t\t\tcase TRAVEL_GRAPPLEHOOK: *result = BotTravel_Grapple(ms, &reach); break;\n\t\t\t\tcase TRAVEL_ROCKETJUMP:\n\t\t\t\tcase TRAVEL_BFGJUMP: *result = BotFinishTravel_WeaponJump(ms, &reach); break;\n\t\t\t\tcase TRAVEL_JUMPPAD: *result = BotFinishTravel_JumpPad(ms, &reach); break;\n\t\t\t\tcase TRAVEL_FUNCBOB: *result = BotFinishTravel_FuncBobbing(ms, &reach); break;\n\t\t\t\tdefault:\n\t\t\t\t{\n\t\t\t\t\tbotimport.Print(PRT_FATAL, \"(last) travel type %d not implemented yet\\n\", (reach.traveltype & TRAVELTYPE_MASK));\n\t\t\t\t\tbreak;\n\t\t\t\t} //end case\n\t\t\t} //end switch\n\t\t\tresult->traveltype = reach.traveltype;\n#ifdef DEBUG\n\t\t\tif (bot_developer)\n\t\t\t{\n\t\t\t\tif (result->failure)\n\t\t\t\t{\n\t\t\t\t\tbotimport.Print(PRT_MESSAGE, \"client %d: movement failure in finish \", ms->client);\n\t\t\t\t\tAAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK);\n\t\t\t\t\tbotimport.Print(PRT_MESSAGE, \"\\n\");\n\t\t\t\t} //end if\n\t\t\t} //end if\n#endif //DEBUG\n\t\t} //end if\n\t} //end else\n\t//FIXME: is it right to do this here?\n\tif (result->blocked) ms->reachability_time -= 10 * ms->thinktime;\n\t//copy the last origin\n\tVectorCopy(ms->origin, ms->lastorigin);\n\t//return the movement result\n\treturn;\n} //end of the function BotMoveToGoal\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotResetAvoidReach(int movestate)\n{\n\tbot_movestate_t *ms;\n\n\tms = BotMoveStateFromHandle(movestate);\n\tif (!ms) return;\n\tCom_Memset(ms->avoidreach, 0, MAX_AVOIDREACH * sizeof(int));\n\tCom_Memset(ms->avoidreachtimes, 0, MAX_AVOIDREACH * sizeof(float));\n\tCom_Memset(ms->avoidreachtries, 0, MAX_AVOIDREACH * sizeof(int));\n} //end of the function BotResetAvoidReach\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotResetLastAvoidReach(int movestate)\n{\n\tint i, latest;\n\tfloat latesttime;\n\tbot_movestate_t *ms;\n\n\tms = BotMoveStateFromHandle(movestate);\n\tif (!ms) return;\n\tlatesttime = 0;\n\tlatest = 0;\n\tfor (i = 0; i < MAX_AVOIDREACH; i++)\n\t{\n\t\tif (ms->avoidreachtimes[i] > latesttime)\n\t\t{\n\t\t\tlatesttime = ms->avoidreachtimes[i];\n\t\t\tlatest = i;\n\t\t} //end if\n\t} //end for\n\tif (latesttime)\n\t{\n\t\tms->avoidreachtimes[latest] = 0;\n\t\tif (ms->avoidreachtries[i] > 0) ms->avoidreachtries[latest]--;\n\t} //end if\n} //end of the function BotResetLastAvoidReach\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotResetMoveState(int movestate)\n{\n\tbot_movestate_t *ms;\n\n\tms = BotMoveStateFromHandle(movestate);\n\tif (!ms) return;\n\tCom_Memset(ms, 0, sizeof(bot_movestate_t));\n} //end of the function BotResetMoveState\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotSetupMoveAI(void)\n{\n\tBotSetBrushModelTypes();\n\tsv_maxstep = LibVar(\"sv_step\", \"18\");\n\tsv_maxbarrier = LibVar(\"sv_maxbarrier\", \"32\");\n\tsv_gravity = LibVar(\"sv_gravity\", \"800\");\n\tweapindex_rocketlauncher = LibVar(\"weapindex_rocketlauncher\", \"5\");\n\tweapindex_bfg10k = LibVar(\"weapindex_bfg10k\", \"9\");\n\tweapindex_grapple = LibVar(\"weapindex_grapple\", \"10\");\n\tentitytypemissile = LibVar(\"entitytypemissile\", \"3\");\n\toffhandgrapple = LibVar(\"offhandgrapple\", \"0\");\n\tcmd_grappleon = LibVar(\"cmd_grappleon\", \"grappleon\");\n\tcmd_grappleoff = LibVar(\"cmd_grappleoff\", \"grappleoff\");\n\treturn BLERR_NOERROR;\n} //end of the function BotSetupMoveAI\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotShutdownMoveAI(void)\n{\n\tint i;\n\n\tfor (i = 1; i <= MAX_CLIENTS; i++)\n\t{\n\t\tif (botmovestates[i])\n\t\t{\n\t\t\tFreeMemory(botmovestates[i]);\n\t\t\tbotmovestates[i] = NULL;\n\t\t} //end if\n\t} //end for\n} //end of the function BotShutdownMoveAI\n\n\n"
  },
  {
    "path": "code/botlib/be_ai_weap.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_ai_weap.c\n *\n * desc:\t\tweapon AI\n *\n * $Archive: /MissionPack/code/botlib/be_ai_weap.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_libvar.h\"\n#include \"l_log.h\"\n#include \"l_memory.h\"\n#include \"l_utils.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#include \"aasfile.h\"\n#include \"../game/botlib.h\"\n#include \"../game/be_aas.h\"\n#include \"be_aas_funcs.h\"\n#include \"be_interface.h\"\n#include \"be_ai_weight.h\"\t\t//fuzzy weights\n#include \"../game/be_ai_weap.h\"\n\n//#define DEBUG_AI_WEAP\n\n//structure field offsets\n#define WEAPON_OFS(x) (int)&(((weaponinfo_t *)0)->x)\n#define PROJECTILE_OFS(x) (int)&(((projectileinfo_t *)0)->x)\n\n//weapon definition // bk001212 - static\nstatic fielddef_t weaponinfo_fields[] =\n{\n{\"number\", WEAPON_OFS(number), FT_INT},\t\t\t\t\t\t//weapon number\n{\"name\", WEAPON_OFS(name), FT_STRING},\t\t\t\t\t\t\t//name of the weapon\n{\"level\", WEAPON_OFS(level), FT_INT},\n{\"model\", WEAPON_OFS(model), FT_STRING},\t\t\t\t\t\t//model of the weapon\n{\"weaponindex\", WEAPON_OFS(weaponindex), FT_INT},\t\t\t//index of weapon in inventory\n{\"flags\", WEAPON_OFS(flags), FT_INT},\t\t\t\t\t\t\t//special flags\n{\"projectile\", WEAPON_OFS(projectile), FT_STRING},\t\t\t//projectile used by the weapon\n{\"numprojectiles\", WEAPON_OFS(numprojectiles), FT_INT},\t//number of projectiles\n{\"hspread\", WEAPON_OFS(hspread), FT_FLOAT},\t\t\t\t\t//horizontal spread of projectiles (degrees from middle)\n{\"vspread\", WEAPON_OFS(vspread), FT_FLOAT},\t\t\t\t\t//vertical spread of projectiles (degrees from middle)\n{\"speed\", WEAPON_OFS(speed), FT_FLOAT},\t\t\t\t\t\t//speed of the projectile (0 = instant hit)\n{\"acceleration\", WEAPON_OFS(acceleration), FT_FLOAT},\t\t//\"acceleration\" * time (in seconds) + \"speed\" = projectile speed\n{\"recoil\", WEAPON_OFS(recoil), FT_FLOAT|FT_ARRAY, 3},\t\t//amount of recoil the player gets from the weapon\n{\"offset\", WEAPON_OFS(offset), FT_FLOAT|FT_ARRAY, 3},\t\t//projectile start offset relative to eye and view angles\n{\"angleoffset\", WEAPON_OFS(angleoffset), FT_FLOAT|FT_ARRAY, 3},//offset of the shoot angles relative to the view angles\n{\"extrazvelocity\", WEAPON_OFS(extrazvelocity), FT_FLOAT},//extra z velocity the projectile gets\n{\"ammoamount\", WEAPON_OFS(ammoamount), FT_INT},\t\t\t\t//ammo amount used per shot\n{\"ammoindex\", WEAPON_OFS(ammoindex), FT_INT},\t\t\t\t//index of ammo in inventory\n{\"activate\", WEAPON_OFS(activate), FT_FLOAT},\t\t\t\t//time it takes to select the weapon\n{\"reload\", WEAPON_OFS(reload), FT_FLOAT},\t\t\t\t\t\t//time it takes to reload the weapon\n{\"spinup\", WEAPON_OFS(spinup), FT_FLOAT},\t\t\t\t\t\t//time it takes before first shot\n{\"spindown\", WEAPON_OFS(spindown), FT_FLOAT},\t\t\t\t//time it takes before weapon stops firing\n{NULL, 0, 0, 0}\n};\n\n//projectile definition\nstatic fielddef_t projectileinfo_fields[] =\n{\n{\"name\", PROJECTILE_OFS(name), FT_STRING},\t\t\t\t\t//name of the projectile\n{\"model\", WEAPON_OFS(model), FT_STRING},\t\t\t\t\t\t//model of the projectile\n{\"flags\", PROJECTILE_OFS(flags), FT_INT},\t\t\t\t\t\t//special flags\n{\"gravity\", PROJECTILE_OFS(gravity), FT_FLOAT},\t\t\t\t//amount of gravity applied to the projectile [0,1]\n{\"damage\", PROJECTILE_OFS(damage), FT_INT},\t\t\t\t\t//damage of the projectile\n{\"radius\", PROJECTILE_OFS(radius), FT_FLOAT},\t\t\t\t//radius of damage\n{\"visdamage\", PROJECTILE_OFS(visdamage), FT_INT},\t\t\t//damage of the projectile to visible entities\n{\"damagetype\", PROJECTILE_OFS(damagetype), FT_INT},\t\t//type of damage (combination of the DAMAGETYPE_? flags)\n{\"healthinc\", PROJECTILE_OFS(healthinc), FT_INT},\t\t\t//health increase the owner gets\n{\"push\", PROJECTILE_OFS(push), FT_FLOAT},\t\t\t\t\t\t//amount a player is pushed away from the projectile impact\n{\"detonation\", PROJECTILE_OFS(detonation), FT_FLOAT},\t\t//time before projectile explodes after fire pressed\n{\"bounce\", PROJECTILE_OFS(bounce), FT_FLOAT},\t\t\t\t//amount the projectile bounces\n{\"bouncefric\", PROJECTILE_OFS(bouncefric), FT_FLOAT}, \t//amount the bounce decreases per bounce\n{\"bouncestop\", PROJECTILE_OFS(bouncestop), FT_FLOAT},\t\t//minimum bounce value before bouncing stops\n//recurive projectile definition??\n{NULL, 0, 0, 0}\n};\n\nstatic structdef_t weaponinfo_struct =\n{\n\tsizeof(weaponinfo_t), weaponinfo_fields\n};\nstatic structdef_t projectileinfo_struct =\n{\n\tsizeof(projectileinfo_t), projectileinfo_fields\n};\n\n//weapon configuration: set of weapons with projectiles\ntypedef struct weaponconfig_s\n{\n\tint numweapons;\n\tint numprojectiles;\n\tprojectileinfo_t *projectileinfo;\n\tweaponinfo_t *weaponinfo;\n} weaponconfig_t;\n\n//the bot weapon state\ntypedef struct bot_weaponstate_s\n{\n\tstruct weightconfig_s *weaponweightconfig;\t\t//weapon weight configuration\n\tint *weaponweightindex;\t\t\t\t\t\t\t//weapon weight index\n} bot_weaponstate_t;\n\nstatic bot_weaponstate_t *botweaponstates[MAX_CLIENTS+1];\nstatic weaponconfig_t *weaponconfig;\n\n//========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//========================================================================\nint BotValidWeaponNumber(int weaponnum)\n{\n\tif (weaponnum <= 0 || weaponnum > weaponconfig->numweapons)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"weapon number out of range\\n\");\n\t\treturn qfalse;\n\t} //end if\n\treturn qtrue;\n} //end of the function BotValidWeaponNumber\n//========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//========================================================================\nbot_weaponstate_t *BotWeaponStateFromHandle(int handle)\n{\n\tif (handle <= 0 || handle > MAX_CLIENTS)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"move state handle %d out of range\\n\", handle);\n\t\treturn NULL;\n\t} //end if\n\tif (!botweaponstates[handle])\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"invalid move state %d\\n\", handle);\n\t\treturn NULL;\n\t} //end if\n\treturn botweaponstates[handle];\n} //end of the function BotWeaponStateFromHandle\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#ifdef DEBUG_AI_WEAP\nvoid DumpWeaponConfig(weaponconfig_t *wc)\n{\n\tFILE *fp;\n\tint i;\n\n\tfp = Log_FileStruct();\n\tif (!fp) return;\n\tfor (i = 0; i < wc->numprojectiles; i++)\n\t{\n\t\tWriteStructure(fp, &projectileinfo_struct, (char *) &wc->projectileinfo[i]);\n\t\tLog_Flush();\n\t} //end for\n\tfor (i = 0; i < wc->numweapons; i++)\n\t{\n\t\tWriteStructure(fp, &weaponinfo_struct, (char *) &wc->weaponinfo[i]);\n\t\tLog_Flush();\n\t} //end for\n} //end of the function DumpWeaponConfig\n#endif //DEBUG_AI_WEAP\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nweaponconfig_t *LoadWeaponConfig(char *filename)\n{\n\tint max_weaponinfo, max_projectileinfo;\n\ttoken_t token;\n\tchar path[MAX_PATH];\n\tint i, j;\n\tsource_t *source;\n\tweaponconfig_t *wc;\n\tweaponinfo_t weaponinfo;\n\n\tmax_weaponinfo = (int) LibVarValue(\"max_weaponinfo\", \"32\");\n\tif (max_weaponinfo < 0)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"max_weaponinfo = %d\\n\", max_weaponinfo);\n\t\tmax_weaponinfo = 32;\n\t\tLibVarSet(\"max_weaponinfo\", \"32\");\n\t} //end if\n\tmax_projectileinfo = (int) LibVarValue(\"max_projectileinfo\", \"32\");\n\tif (max_projectileinfo < 0)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"max_projectileinfo = %d\\n\", max_projectileinfo);\n\t\tmax_projectileinfo = 32;\n\t\tLibVarSet(\"max_projectileinfo\", \"32\");\n\t} //end if\n\tstrncpy(path, filename, MAX_PATH);\n\tPC_SetBaseFolder(BOTFILESBASEFOLDER);\n\tsource = LoadSourceFile(path);\n\tif (!source)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"counldn't load %s\\n\", path);\n\t\treturn NULL;\n\t} //end if\n\t//initialize weapon config\n\twc = (weaponconfig_t *) GetClearedHunkMemory(sizeof(weaponconfig_t) +\n\t\t\t\t\t\t\t\t\t\tmax_weaponinfo * sizeof(weaponinfo_t) +\n\t\t\t\t\t\t\t\t\t\tmax_projectileinfo * sizeof(projectileinfo_t));\n\twc->weaponinfo = (weaponinfo_t *) ((char *) wc + sizeof(weaponconfig_t));\n\twc->projectileinfo = (projectileinfo_t *) ((char *) wc->weaponinfo +\n\t\t\t\t\t\t\t\t\t\tmax_weaponinfo * sizeof(weaponinfo_t));\n\twc->numweapons = max_weaponinfo;\n\twc->numprojectiles = 0;\n\t//parse the source file\n\twhile(PC_ReadToken(source, &token))\n\t{\n\t\tif (!strcmp(token.string, \"weaponinfo\"))\n\t\t{\n\t\t\tCom_Memset(&weaponinfo, 0, sizeof(weaponinfo_t));\n\t\t\tif (!ReadStructure(source, &weaponinfo_struct, (char *) &weaponinfo))\n\t\t\t{\n\t\t\t\tFreeMemory(wc);\n\t\t\t\tFreeSource(source);\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t\tif (weaponinfo.number < 0 || weaponinfo.number >= max_weaponinfo)\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"weapon info number %d out of range in %s\\n\", weaponinfo.number, path);\n\t\t\t\tFreeMemory(wc);\n\t\t\t\tFreeSource(source);\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t\tCom_Memcpy(&wc->weaponinfo[weaponinfo.number], &weaponinfo, sizeof(weaponinfo_t));\n\t\t\twc->weaponinfo[weaponinfo.number].valid = qtrue;\n\t\t} //end if\n\t\telse if (!strcmp(token.string, \"projectileinfo\"))\n\t\t{\n\t\t\tif (wc->numprojectiles >= max_projectileinfo)\n\t\t\t{\n\t\t\t\tbotimport.Print(PRT_ERROR, \"more than %d projectiles defined in %s\\n\", max_projectileinfo, path);\n\t\t\t\tFreeMemory(wc);\n\t\t\t\tFreeSource(source);\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t\tCom_Memset(&wc->projectileinfo[wc->numprojectiles], 0, sizeof(projectileinfo_t));\n\t\t\tif (!ReadStructure(source, &projectileinfo_struct, (char *) &wc->projectileinfo[wc->numprojectiles]))\n\t\t\t{\n\t\t\t\tFreeMemory(wc);\n\t\t\t\tFreeSource(source);\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t\twc->numprojectiles++;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"unknown definition %s in %s\\n\", token.string, path);\n\t\t\tFreeMemory(wc);\n\t\t\tFreeSource(source);\n\t\t\treturn NULL;\n\t\t} //end else\n\t} //end while\n\tFreeSource(source);\n\t//fix up weapons\n\tfor (i = 0; i < wc->numweapons; i++)\n\t{\n\t\tif (!wc->weaponinfo[i].valid) continue;\n\t\tif (!wc->weaponinfo[i].name[0])\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"weapon %d has no name in %s\\n\", i, path);\n\t\t\tFreeMemory(wc);\n\t\t\treturn NULL;\n\t\t} //end if\n\t\tif (!wc->weaponinfo[i].projectile[0])\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"weapon %s has no projectile in %s\\n\", wc->weaponinfo[i].name, path);\n\t\t\tFreeMemory(wc);\n\t\t\treturn NULL;\n\t\t} //end if\n\t\t//find the projectile info and copy it to the weapon info\n\t\tfor (j = 0; j < wc->numprojectiles; j++)\n\t\t{\n\t\t\tif (!strcmp(wc->projectileinfo[j].name, wc->weaponinfo[i].projectile))\n\t\t\t{\n\t\t\t\tCom_Memcpy(&wc->weaponinfo[i].proj, &wc->projectileinfo[j], sizeof(projectileinfo_t));\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t} //end for\n\t\tif (j == wc->numprojectiles)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"weapon %s uses undefined projectile in %s\\n\", wc->weaponinfo[i].name, path);\n\t\t\tFreeMemory(wc);\n\t\t\treturn NULL;\n\t\t} //end if\n\t} //end for\n\tif (!wc->numweapons) botimport.Print(PRT_WARNING, \"no weapon info loaded\\n\");\n\tbotimport.Print(PRT_MESSAGE, \"loaded %s\\n\", path);\n\treturn wc;\n} //end of the function LoadWeaponConfig\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint *WeaponWeightIndex(weightconfig_t *wwc, weaponconfig_t *wc)\n{\n\tint *index, i;\n\n\t//initialize item weight index\n\tindex = (int *) GetClearedMemory(sizeof(int) * wc->numweapons);\n\n\tfor (i = 0; i < wc->numweapons; i++)\n\t{\n\t\tindex[i] = FindFuzzyWeight(wwc, wc->weaponinfo[i].name);\n\t} //end for\n\treturn index;\n} //end of the function WeaponWeightIndex\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotFreeWeaponWeights(int weaponstate)\n{\n\tbot_weaponstate_t *ws;\n\n\tws = BotWeaponStateFromHandle(weaponstate);\n\tif (!ws) return;\n\tif (ws->weaponweightconfig) FreeWeightConfig(ws->weaponweightconfig);\n\tif (ws->weaponweightindex) FreeMemory(ws->weaponweightindex);\n} //end of the function BotFreeWeaponWeights\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotLoadWeaponWeights(int weaponstate, char *filename)\n{\n\tbot_weaponstate_t *ws;\n\n\tws = BotWeaponStateFromHandle(weaponstate);\n\tif (!ws) return BLERR_CANNOTLOADWEAPONWEIGHTS;\n\tBotFreeWeaponWeights(weaponstate);\n\t//\n\tws->weaponweightconfig = ReadWeightConfig(filename);\n\tif (!ws->weaponweightconfig)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"couldn't load weapon config %s\\n\", filename);\n\t\treturn BLERR_CANNOTLOADWEAPONWEIGHTS;\n\t} //end if\n\tif (!weaponconfig) return BLERR_CANNOTLOADWEAPONCONFIG;\n\tws->weaponweightindex = WeaponWeightIndex(ws->weaponweightconfig, weaponconfig);\n\treturn BLERR_NOERROR;\n} //end of the function BotLoadWeaponWeights\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotGetWeaponInfo(int weaponstate, int weapon, weaponinfo_t *weaponinfo)\n{\n\tbot_weaponstate_t *ws;\n\n\tif (!BotValidWeaponNumber(weapon)) return;\n\tws = BotWeaponStateFromHandle(weaponstate);\n\tif (!ws) return;\n\tif (!weaponconfig) return;\n\tCom_Memcpy(weaponinfo, &weaponconfig->weaponinfo[weapon], sizeof(weaponinfo_t));\n} //end of the function BotGetWeaponInfo\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotChooseBestFightWeapon(int weaponstate, int *inventory)\n{\n\tint i, index, bestweapon;\n\tfloat weight, bestweight;\n\tweaponconfig_t *wc;\n\tbot_weaponstate_t *ws;\n\n\tws = BotWeaponStateFromHandle(weaponstate);\n\tif (!ws) return 0;\n\twc = weaponconfig;\n\tif (!weaponconfig) return 0;\n\n\t//if the bot has no weapon weight configuration\n\tif (!ws->weaponweightconfig) return 0;\n\n\tbestweight = 0;\n\tbestweapon = 0;\n\tfor (i = 0; i < wc->numweapons; i++)\n\t{\n\t\tif (!wc->weaponinfo[i].valid) continue;\n\t\tindex = ws->weaponweightindex[i];\n\t\tif (index < 0) continue;\n\t\tweight = FuzzyWeight(inventory, ws->weaponweightconfig, index);\n\t\tif (weight > bestweight)\n\t\t{\n\t\t\tbestweight = weight;\n\t\t\tbestweapon = i;\n\t\t} //end if\n\t} //end for\n\treturn bestweapon;\n} //end of the function BotChooseBestFightWeapon\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotResetWeaponState(int weaponstate)\n{\n\tstruct weightconfig_s *weaponweightconfig;\n\tint *weaponweightindex;\n\tbot_weaponstate_t *ws;\n\n\tws = BotWeaponStateFromHandle(weaponstate);\n\tif (!ws) return;\n\tweaponweightconfig = ws->weaponweightconfig;\n\tweaponweightindex = ws->weaponweightindex;\n\n\t//Com_Memset(ws, 0, sizeof(bot_weaponstate_t));\n\tws->weaponweightconfig = weaponweightconfig;\n\tws->weaponweightindex = weaponweightindex;\n} //end of the function BotResetWeaponState\n//========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//========================================================================\nint BotAllocWeaponState(void)\n{\n\tint i;\n\n\tfor (i = 1; i <= MAX_CLIENTS; i++)\n\t{\n\t\tif (!botweaponstates[i])\n\t\t{\n\t\t\tbotweaponstates[i] = GetClearedMemory(sizeof(bot_weaponstate_t));\n\t\t\treturn i;\n\t\t} //end if\n\t} //end for\n\treturn 0;\n} //end of the function BotAllocWeaponState\n//========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//========================================================================\nvoid BotFreeWeaponState(int handle)\n{\n\tif (handle <= 0 || handle > MAX_CLIENTS)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"move state handle %d out of range\\n\", handle);\n\t\treturn;\n\t} //end if\n\tif (!botweaponstates[handle])\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"invalid move state %d\\n\", handle);\n\t\treturn;\n\t} //end if\n\tBotFreeWeaponWeights(handle);\n\tFreeMemory(botweaponstates[handle]);\n\tbotweaponstates[handle] = NULL;\n} //end of the function BotFreeWeaponState\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotSetupWeaponAI(void)\n{\n\tchar *file;\n\n\tfile = LibVarString(\"weaponconfig\", \"weapons.c\");\n\tweaponconfig = LoadWeaponConfig(file);\n\tif (!weaponconfig)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"couldn't load the weapon config\\n\");\n\t\treturn BLERR_CANNOTLOADWEAPONCONFIG;\n\t} //end if\n\n#ifdef DEBUG_AI_WEAP\n\tDumpWeaponConfig(weaponconfig);\n#endif //DEBUG_AI_WEAP\n\t//\n\treturn BLERR_NOERROR;\n} //end of the function BotSetupWeaponAI\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotShutdownWeaponAI(void)\n{\n\tint i;\n\n\tif (weaponconfig) FreeMemory(weaponconfig);\n\tweaponconfig = NULL;\n\n\tfor (i = 1; i <= MAX_CLIENTS; i++)\n\t{\n\t\tif (botweaponstates[i])\n\t\t{\n\t\t\tBotFreeWeaponState(i);\n\t\t} //end if\n\t} //end for\n} //end of the function BotShutdownWeaponAI\n\n"
  },
  {
    "path": "code/botlib/be_ai_weight.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_ai_weight.c\n *\n * desc:\t\tfuzzy logic\n *\n * $Archive: /MissionPack/code/botlib/be_ai_weight.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_memory.h\"\n#include \"l_log.h\"\n#include \"l_utils.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#include \"l_libvar.h\"\n#include \"aasfile.h\"\n#include \"../game/botlib.h\"\n#include \"../game/be_aas.h\"\n#include \"be_aas_funcs.h\"\n#include \"be_interface.h\"\n#include \"be_ai_weight.h\"\n\n#define MAX_INVENTORYVALUE\t\t\t999999\n#define EVALUATERECURSIVELY\n\n#define MAX_WEIGHT_FILES\t\t\t128\nweightconfig_t\t*weightFileList[MAX_WEIGHT_FILES];\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint ReadValue(source_t *source, float *value)\n{\n\ttoken_t token;\n\n\tif (!PC_ExpectAnyToken(source, &token)) return qfalse;\n\tif (!strcmp(token.string, \"-\"))\n\t{\n\t\tSourceWarning(source, \"negative value set to zero\\n\");\n\t\tif (!PC_ExpectTokenType(source, TT_NUMBER, 0, &token)) return qfalse;\n\t} //end if\n\tif (token.type != TT_NUMBER)\n\t{\n\t\tSourceError(source, \"invalid return value %s\\n\", token.string);\n\t\treturn qfalse;\n\t} //end if\n\t*value = token.floatvalue;\n\treturn qtrue;\n} //end of the function ReadValue\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint ReadFuzzyWeight(source_t *source, fuzzyseperator_t *fs)\n{\n\tif (PC_CheckTokenString(source, \"balance\"))\n\t{\n\t\tfs->type = WT_BALANCE;\n\t\tif (!PC_ExpectTokenString(source, \"(\")) return qfalse;\n\t\tif (!ReadValue(source, &fs->weight)) return qfalse;\n\t\tif (!PC_ExpectTokenString(source, \",\")) return qfalse;\n\t\tif (!ReadValue(source, &fs->minweight)) return qfalse;\n\t\tif (!PC_ExpectTokenString(source, \",\")) return qfalse;\n\t\tif (!ReadValue(source, &fs->maxweight)) return qfalse;\n\t\tif (!PC_ExpectTokenString(source, \")\")) return qfalse;\n\t} //end if\n\telse\n\t{\n\t\tfs->type = 0;\n\t\tif (!ReadValue(source, &fs->weight)) return qfalse;\n\t\tfs->minweight = fs->weight;\n\t\tfs->maxweight = fs->weight;\n\t} //end if\n\tif (!PC_ExpectTokenString(source, \";\")) return qfalse;\n\treturn qtrue;\n} //end of the function ReadFuzzyWeight\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid FreeFuzzySeperators_r(fuzzyseperator_t *fs)\n{\n\tif (!fs) return;\n\tif (fs->child) FreeFuzzySeperators_r(fs->child);\n\tif (fs->next) FreeFuzzySeperators_r(fs->next);\n\tFreeMemory(fs);\n} //end of the function FreeFuzzySeperators\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid FreeWeightConfig2(weightconfig_t *config)\n{\n\tint i;\n\n\tfor (i = 0; i < config->numweights; i++)\n\t{\n\t\tFreeFuzzySeperators_r(config->weights[i].firstseperator);\n\t\tif (config->weights[i].name) FreeMemory(config->weights[i].name);\n\t} //end for\n\tFreeMemory(config);\n} //end of the function FreeWeightConfig2\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid FreeWeightConfig(weightconfig_t *config)\n{\n\tif (!LibVarGetValue(\"bot_reloadcharacters\")) return;\n\tFreeWeightConfig2(config);\n} //end of the function FreeWeightConfig\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfuzzyseperator_t *ReadFuzzySeperators_r(source_t *source)\n{\n\tint newindent, index, def, founddefault;\n\ttoken_t token;\n\tfuzzyseperator_t *fs, *lastfs, *firstfs;\n\n\tfounddefault = qfalse;\n\tfirstfs = NULL;\n\tlastfs = NULL;\n\tif (!PC_ExpectTokenString(source, \"(\")) return NULL;\n\tif (!PC_ExpectTokenType(source, TT_NUMBER, TT_INTEGER, &token)) return NULL;\n\tindex = token.intvalue;\n\tif (!PC_ExpectTokenString(source, \")\")) return NULL;\n\tif (!PC_ExpectTokenString(source, \"{\")) return NULL;\n\tif (!PC_ExpectAnyToken(source, &token)) return NULL;\n\tdo\n\t{\n\t\tdef = !strcmp(token.string, \"default\");\n\t\tif (def || !strcmp(token.string, \"case\"))\n\t\t{\n\t\t\tfs = (fuzzyseperator_t *) GetClearedMemory(sizeof(fuzzyseperator_t));\n\t\t\tfs->index = index;\n\t\t\tif (lastfs) lastfs->next = fs;\n\t\t\telse firstfs = fs;\n\t\t\tlastfs = fs;\n\t\t\tif (def)\n\t\t\t{\n\t\t\t\tif (founddefault)\n\t\t\t\t{\n\t\t\t\t\tSourceError(source, \"switch already has a default\\n\");\n\t\t\t\t\tFreeFuzzySeperators_r(firstfs);\n\t\t\t\t\treturn NULL;\n\t\t\t\t} //end if\n\t\t\t\tfs->value = MAX_INVENTORYVALUE;\n\t\t\t\tfounddefault = qtrue;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (!PC_ExpectTokenType(source, TT_NUMBER, TT_INTEGER, &token))\n\t\t\t\t{\n\t\t\t\t\tFreeFuzzySeperators_r(firstfs);\n\t\t\t\t\treturn NULL;\n\t\t\t\t} //end if\n\t\t\t\tfs->value = token.intvalue;\n\t\t\t} //end else\n\t\t\tif (!PC_ExpectTokenString(source, \":\") || !PC_ExpectAnyToken(source, &token))\n\t\t\t{\n\t\t\t\tFreeFuzzySeperators_r(firstfs);\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t\tnewindent = qfalse;\n\t\t\tif (!strcmp(token.string, \"{\"))\n\t\t\t{\n\t\t\t\tnewindent = qtrue;\n\t\t\t\tif (!PC_ExpectAnyToken(source, &token))\n\t\t\t\t{\n\t\t\t\t\tFreeFuzzySeperators_r(firstfs);\n\t\t\t\t\treturn NULL;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t\tif (!strcmp(token.string, \"return\"))\n\t\t\t{\n\t\t\t\tif (!ReadFuzzyWeight(source, fs))\n\t\t\t\t{\n\t\t\t\t\tFreeFuzzySeperators_r(firstfs);\n\t\t\t\t\treturn NULL;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t\telse if (!strcmp(token.string, \"switch\"))\n\t\t\t{\n\t\t\t\tfs->child = ReadFuzzySeperators_r(source);\n\t\t\t\tif (!fs->child)\n\t\t\t\t{\n\t\t\t\t\tFreeFuzzySeperators_r(firstfs);\n\t\t\t\t\treturn NULL;\n\t\t\t\t} //end if\n\t\t\t} //end else if\n\t\t\telse\n\t\t\t{\n\t\t\t\tSourceError(source, \"invalid name %s\\n\", token.string);\n\t\t\t\treturn NULL;\n\t\t\t} //end else\n\t\t\tif (newindent)\n\t\t\t{\n\t\t\t\tif (!PC_ExpectTokenString(source, \"}\"))\n\t\t\t\t{\n\t\t\t\t\tFreeFuzzySeperators_r(firstfs);\n\t\t\t\t\treturn NULL;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tFreeFuzzySeperators_r(firstfs);\n\t\t\tSourceError(source, \"invalid name %s\\n\", token.string);\n\t\t\treturn NULL;\n\t\t} //end else\n\t\tif (!PC_ExpectAnyToken(source, &token))\n\t\t{\n\t\t\tFreeFuzzySeperators_r(firstfs);\n\t\t\treturn NULL;\n\t\t} //end if\n\t} while(strcmp(token.string, \"}\"));\n\t//\n\tif (!founddefault)\n\t{\n\t\tSourceWarning(source, \"switch without default\\n\");\n\t\tfs = (fuzzyseperator_t *) GetClearedMemory(sizeof(fuzzyseperator_t));\n\t\tfs->index = index;\n\t\tfs->value = MAX_INVENTORYVALUE;\n\t\tfs->weight = 0;\n\t\tfs->next = NULL;\n\t\tfs->child = NULL;\n\t\tif (lastfs) lastfs->next = fs;\n\t\telse firstfs = fs;\n\t\tlastfs = fs;\n\t} //end if\n\t//\n\treturn firstfs;\n} //end of the function ReadFuzzySeperators_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nweightconfig_t *ReadWeightConfig(char *filename)\n{\n\tint newindent, avail = 0, n;\n\ttoken_t token;\n\tsource_t *source;\n\tfuzzyseperator_t *fs;\n\tweightconfig_t *config = NULL;\n#ifdef DEBUG\n\tint starttime;\n\n\tstarttime = Sys_MilliSeconds();\n#endif //DEBUG\n\n\tif (!LibVarGetValue(\"bot_reloadcharacters\"))\n\t{\n\t\tavail = -1;\n\t\tfor( n = 0; n < MAX_WEIGHT_FILES; n++ )\n\t\t{\n\t\t\tconfig = weightFileList[n];\n\t\t\tif( !config )\n\t\t\t{\n\t\t\t\tif( avail == -1 )\n\t\t\t\t{\n\t\t\t\t\tavail = n;\n\t\t\t\t} //end if\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\tif( strcmp( filename, config->filename ) == 0 )\n\t\t\t{\n\t\t\t\t//botimport.Print( PRT_MESSAGE, \"retained %s\\n\", filename );\n\t\t\t\treturn config;\n\t\t\t} //end if\n\t\t} //end for\n\n\t\tif( avail == -1 )\n\t\t{\n\t\t\tbotimport.Print( PRT_ERROR, \"weightFileList was full trying to load %s\\n\", filename );\n\t\t\treturn NULL;\n\t\t} //end if\n\t} //end if\n\n\tPC_SetBaseFolder(BOTFILESBASEFOLDER);\n\tsource = LoadSourceFile(filename);\n\tif (!source)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"counldn't load %s\\n\", filename);\n\t\treturn NULL;\n\t} //end if\n\t//\n\tconfig = (weightconfig_t *) GetClearedMemory(sizeof(weightconfig_t));\n\tconfig->numweights = 0;\n\tQ_strncpyz( config->filename, filename, sizeof(config->filename) );\n\t//parse the item config file\n\twhile(PC_ReadToken(source, &token))\n\t{\n\t\tif (!strcmp(token.string, \"weight\"))\n\t\t{\n\t\t\tif (config->numweights >= MAX_WEIGHTS)\n\t\t\t{\n\t\t\t\tSourceWarning(source, \"too many fuzzy weights\\n\");\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t\tif (!PC_ExpectTokenType(source, TT_STRING, 0, &token))\n\t\t\t{\n\t\t\t\tFreeWeightConfig(config);\n\t\t\t\tFreeSource(source);\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t\tStripDoubleQuotes(token.string);\n\t\t\tconfig->weights[config->numweights].name = (char *) GetClearedMemory(strlen(token.string) + 1);\n\t\t\tstrcpy(config->weights[config->numweights].name, token.string);\n\t\t\tif (!PC_ExpectAnyToken(source, &token))\n\t\t\t{\n\t\t\t\tFreeWeightConfig(config);\n\t\t\t\tFreeSource(source);\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t\tnewindent = qfalse;\n\t\t\tif (!strcmp(token.string, \"{\"))\n\t\t\t{\n\t\t\t\tnewindent = qtrue;\n\t\t\t\tif (!PC_ExpectAnyToken(source, &token))\n\t\t\t\t{\n\t\t\t\t\tFreeWeightConfig(config);\n\t\t\t\t\tFreeSource(source);\n\t\t\t\t\treturn NULL;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t\tif (!strcmp(token.string, \"switch\"))\n\t\t\t{\n\t\t\t\tfs = ReadFuzzySeperators_r(source);\n\t\t\t\tif (!fs)\n\t\t\t\t{\n\t\t\t\t\tFreeWeightConfig(config);\n\t\t\t\t\tFreeSource(source);\n\t\t\t\t\treturn NULL;\n\t\t\t\t} //end if\n\t\t\t\tconfig->weights[config->numweights].firstseperator = fs;\n\t\t\t} //end if\n\t\t\telse if (!strcmp(token.string, \"return\"))\n\t\t\t{\n\t\t\t\tfs = (fuzzyseperator_t *) GetClearedMemory(sizeof(fuzzyseperator_t));\n\t\t\t\tfs->index = 0;\n\t\t\t\tfs->value = MAX_INVENTORYVALUE;\n\t\t\t\tfs->next = NULL;\n\t\t\t\tfs->child = NULL;\n\t\t\t\tif (!ReadFuzzyWeight(source, fs))\n\t\t\t\t{\n\t\t\t\t\tFreeMemory(fs);\n\t\t\t\t\tFreeWeightConfig(config);\n\t\t\t\t\tFreeSource(source);\n\t\t\t\t\treturn NULL;\n\t\t\t\t} //end if\n\t\t\t\tconfig->weights[config->numweights].firstseperator = fs;\n\t\t\t} //end else if\n\t\t\telse\n\t\t\t{\n\t\t\t\tSourceError(source, \"invalid name %s\\n\", token.string);\n\t\t\t\tFreeWeightConfig(config);\n\t\t\t\tFreeSource(source);\n\t\t\t\treturn NULL;\n\t\t\t} //end else\n\t\t\tif (newindent)\n\t\t\t{\n\t\t\t\tif (!PC_ExpectTokenString(source, \"}\"))\n\t\t\t\t{\n\t\t\t\t\tFreeWeightConfig(config);\n\t\t\t\t\tFreeSource(source);\n\t\t\t\t\treturn NULL;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t\tconfig->numweights++;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tSourceError(source, \"invalid name %s\\n\", token.string);\n\t\t\tFreeWeightConfig(config);\n\t\t\tFreeSource(source);\n\t\t\treturn NULL;\n\t\t} //end else\n\t} //end while\n\t//free the source at the end of a pass\n\tFreeSource(source);\n\t//if the file was located in a pak file\n\tbotimport.Print(PRT_MESSAGE, \"loaded %s\\n\", filename);\n#ifdef DEBUG\n\tif (bot_developer)\n\t{\n\t\tbotimport.Print(PRT_MESSAGE, \"weights loaded in %d msec\\n\", Sys_MilliSeconds() - starttime);\n\t} //end if\n#endif //DEBUG\n\t//\n\tif (!LibVarGetValue(\"bot_reloadcharacters\"))\n\t{\n\t\tweightFileList[avail] = config;\n\t} //end if\n\t//\n\treturn config;\n} //end of the function ReadWeightConfig\n#if 0\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean WriteFuzzyWeight(FILE *fp, fuzzyseperator_t *fs)\n{\n\tif (fs->type == WT_BALANCE)\n\t{\n\t\tif (fprintf(fp, \" return balance(\") < 0) return qfalse;\n\t\tif (!WriteFloat(fp, fs->weight)) return qfalse;\n\t\tif (fprintf(fp, \",\") < 0) return qfalse;\n\t\tif (!WriteFloat(fp, fs->minweight)) return qfalse;\n\t\tif (fprintf(fp, \",\") < 0) return qfalse;\n\t\tif (!WriteFloat(fp, fs->maxweight)) return qfalse;\n\t\tif (fprintf(fp, \");\\n\") < 0) return qfalse;\n\t} //end if\n\telse\n\t{\n\t\tif (fprintf(fp, \" return \") < 0) return qfalse;\n\t\tif (!WriteFloat(fp, fs->weight)) return qfalse;\n\t\tif (fprintf(fp, \";\\n\") < 0) return qfalse;\n\t} //end else\n\treturn qtrue;\n} //end of the function WriteFuzzyWeight\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean WriteFuzzySeperators_r(FILE *fp, fuzzyseperator_t *fs, int indent)\n{\n\tif (!WriteIndent(fp, indent)) return qfalse;\n\tif (fprintf(fp, \"switch(%d)\\n\", fs->index) < 0) return qfalse;\n\tif (!WriteIndent(fp, indent)) return qfalse;\n\tif (fprintf(fp, \"{\\n\") < 0) return qfalse;\n\tindent++;\n\tdo\n\t{\n\t\tif (!WriteIndent(fp, indent)) return qfalse;\n\t\tif (fs->next)\n\t\t{\n\t\t\tif (fprintf(fp, \"case %d:\", fs->value) < 0) return qfalse;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tif (fprintf(fp, \"default:\") < 0) return qfalse;\n\t\t} //end else\n\t\tif (fs->child)\n\t\t{\n\t\t\tif (fprintf(fp, \"\\n\") < 0) return qfalse;\n\t\t\tif (!WriteIndent(fp, indent)) return qfalse;\n\t\t\tif (fprintf(fp, \"{\\n\") < 0) return qfalse;\n\t\t\tif (!WriteFuzzySeperators_r(fp, fs->child, indent + 1)) return qfalse;\n\t\t\tif (!WriteIndent(fp, indent)) return qfalse;\n\t\t\tif (fs->next)\n\t\t\t{\n\t\t\t\tif (fprintf(fp, \"} //end case\\n\") < 0) return qfalse;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (fprintf(fp, \"} //end default\\n\") < 0) return qfalse;\n\t\t\t} //end else\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tif (!WriteFuzzyWeight(fp, fs)) return qfalse;\n\t\t} //end else\n\t\tfs = fs->next;\n\t} while(fs);\n\tindent--;\n\tif (!WriteIndent(fp, indent)) return qfalse;\n\tif (fprintf(fp, \"} //end switch\\n\") < 0) return qfalse;\n\treturn qtrue;\n} //end of the function WriteItemFuzzyWeights_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean WriteWeightConfig(char *filename, weightconfig_t *config)\n{\n\tint i;\n\tFILE *fp;\n\tweight_t *ifw;\n\n\tfp = fopen(filename, \"wb\");\n\tif (!fp) return qfalse;\n\n\tfor (i = 0; i < config->numweights; i++)\n\t{\n\t\tifw = &config->weights[i];\n\t\tif (fprintf(fp, \"\\nweight \\\"%s\\\"\\n\", ifw->name) < 0) return qfalse;\n\t\tif (fprintf(fp, \"{\\n\") < 0) return qfalse;\n\t\tif (ifw->firstseperator->index > 0)\n\t\t{\n\t\t\tif (!WriteFuzzySeperators_r(fp, ifw->firstseperator, 1)) return qfalse;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tif (!WriteIndent(fp, 1)) return qfalse;\n\t\t\tif (!WriteFuzzyWeight(fp, ifw->firstseperator)) return qfalse;\n\t\t} //end else\n\t\tif (fprintf(fp, \"} //end weight\\n\") < 0) return qfalse;\n\t} //end for\n\tfclose(fp);\n\treturn qtrue;\n} //end of the function WriteWeightConfig\n#endif\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint FindFuzzyWeight(weightconfig_t *wc, char *name)\n{\n\tint i;\n\n\tfor (i = 0; i < wc->numweights; i++)\n\t{\n\t\tif (!strcmp(wc->weights[i].name, name))\n\t\t{\n\t\t\treturn i;\n\t\t} //end if\n\t} //end if\n\treturn -1;\n} //end of the function FindFuzzyWeight\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat FuzzyWeight_r(int *inventory, fuzzyseperator_t *fs)\n{\n\tfloat scale, w1, w2;\n\n\tif (inventory[fs->index] < fs->value)\n\t{\n\t\tif (fs->child) return FuzzyWeight_r(inventory, fs->child);\n\t\telse return fs->weight;\n\t} //end if\n\telse if (fs->next)\n\t{\n\t\tif (inventory[fs->index] < fs->next->value)\n\t\t{\n\t\t\t//first weight\n\t\t\tif (fs->child) w1 = FuzzyWeight_r(inventory, fs->child);\n\t\t\telse w1 = fs->weight;\n\t\t\t//second weight\n\t\t\tif (fs->next->child) w2 = FuzzyWeight_r(inventory, fs->next->child);\n\t\t\telse w2 = fs->next->weight;\n\t\t\t//the scale factor\n\t\t\tscale = (inventory[fs->index] - fs->value) / (fs->next->value - fs->value);\n\t\t\t//scale between the two weights\n\t\t\treturn scale * w1 + (1 - scale) * w2;\n\t\t} //end if\n\t\treturn FuzzyWeight_r(inventory, fs->next);\n\t} //end else if\n\treturn fs->weight;\n} //end of the function FuzzyWeight_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat FuzzyWeightUndecided_r(int *inventory, fuzzyseperator_t *fs)\n{\n\tfloat scale, w1, w2;\n\n\tif (inventory[fs->index] < fs->value)\n\t{\n\t\tif (fs->child) return FuzzyWeightUndecided_r(inventory, fs->child);\n\t\telse return fs->minweight + random() * (fs->maxweight - fs->minweight);\n\t} //end if\n\telse if (fs->next)\n\t{\n\t\tif (inventory[fs->index] < fs->next->value)\n\t\t{\n\t\t\t//first weight\n\t\t\tif (fs->child) w1 = FuzzyWeightUndecided_r(inventory, fs->child);\n\t\t\telse w1 = fs->minweight + random() * (fs->maxweight - fs->minweight);\n\t\t\t//second weight\n\t\t\tif (fs->next->child) w2 = FuzzyWeight_r(inventory, fs->next->child);\n\t\t\telse w2 = fs->next->minweight + random() * (fs->next->maxweight - fs->next->minweight);\n\t\t\t//the scale factor\n\t\t\tscale = (inventory[fs->index] - fs->value) / (fs->next->value - fs->value);\n\t\t\t//scale between the two weights\n\t\t\treturn scale * w1 + (1 - scale) * w2;\n\t\t} //end if\n\t\treturn FuzzyWeightUndecided_r(inventory, fs->next);\n\t} //end else if\n\treturn fs->weight;\n} //end of the function FuzzyWeightUndecided_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat FuzzyWeight(int *inventory, weightconfig_t *wc, int weightnum)\n{\n#ifdef EVALUATERECURSIVELY\n\treturn FuzzyWeight_r(inventory, wc->weights[weightnum].firstseperator);\n#else\n\tfuzzyseperator_t *s;\n\n\ts = wc->weights[weightnum].firstseperator;\n\tif (!s) return 0;\n\twhile(1)\n\t{\n\t\tif (inventory[s->index] < s->value)\n\t\t{\n\t\t\tif (s->child) s = s->child;\n\t\t\telse return s->weight;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tif (s->next) s = s->next;\n\t\t\telse return s->weight;\n\t\t} //end else\n\t} //end if\n\treturn 0;\n#endif\n} //end of the function FuzzyWeight\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat FuzzyWeightUndecided(int *inventory, weightconfig_t *wc, int weightnum)\n{\n#ifdef EVALUATERECURSIVELY\n\treturn FuzzyWeightUndecided_r(inventory, wc->weights[weightnum].firstseperator);\n#else\n\tfuzzyseperator_t *s;\n\n\ts = wc->weights[weightnum].firstseperator;\n\tif (!s) return 0;\n\twhile(1)\n\t{\n\t\tif (inventory[s->index] < s->value)\n\t\t{\n\t\t\tif (s->child) s = s->child;\n\t\t\telse return s->minweight + random() * (s->maxweight - s->minweight);\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tif (s->next) s = s->next;\n\t\t\telse return s->minweight + random() * (s->maxweight - s->minweight);\n\t\t} //end else\n\t} //end if\n\treturn 0;\n#endif\n} //end of the function FuzzyWeightUndecided\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EvolveFuzzySeperator_r(fuzzyseperator_t *fs)\n{\n\tif (fs->child)\n\t{\n\t\tEvolveFuzzySeperator_r(fs->child);\n\t} //end if\n\telse if (fs->type == WT_BALANCE)\n\t{\n\t\t//every once in a while an evolution leap occurs, mutation\n\t\tif (random() < 0.01) fs->weight += crandom() * (fs->maxweight - fs->minweight);\n\t\telse fs->weight += crandom() * (fs->maxweight - fs->minweight) * 0.5;\n\t\t//modify bounds if necesary because of mutation\n\t\tif (fs->weight < fs->minweight) fs->minweight = fs->weight;\n\t\telse if (fs->weight > fs->maxweight) fs->maxweight = fs->weight;\n\t} //end else if\n\tif (fs->next) EvolveFuzzySeperator_r(fs->next);\n} //end of the function EvolveFuzzySeperator_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EvolveWeightConfig(weightconfig_t *config)\n{\n\tint i;\n\n\tfor (i = 0; i < config->numweights; i++)\n\t{\n\t\tEvolveFuzzySeperator_r(config->weights[i].firstseperator);\n\t} //end for\n} //end of the function EvolveWeightConfig\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ScaleFuzzySeperator_r(fuzzyseperator_t *fs, float scale)\n{\n\tif (fs->child)\n\t{\n\t\tScaleFuzzySeperator_r(fs->child, scale);\n\t} //end if\n\telse if (fs->type == WT_BALANCE)\n\t{\n\t\t//\n\t\tfs->weight = (fs->maxweight + fs->minweight) * scale;\n\t\t//get the weight between bounds\n\t\tif (fs->weight < fs->minweight) fs->weight = fs->minweight;\n\t\telse if (fs->weight > fs->maxweight) fs->weight = fs->maxweight;\n\t} //end else if\n\tif (fs->next) ScaleFuzzySeperator_r(fs->next, scale);\n} //end of the function ScaleFuzzySeperator_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ScaleWeight(weightconfig_t *config, char *name, float scale)\n{\n\tint i;\n\n\tif (scale < 0) scale = 0;\n\telse if (scale > 1) scale = 1;\n\tfor (i = 0; i < config->numweights; i++)\n\t{\n\t\tif (!strcmp(name, config->weights[i].name))\n\t\t{\n\t\t\tScaleFuzzySeperator_r(config->weights[i].firstseperator, scale);\n\t\t\tbreak;\n\t\t} //end if\n\t} //end for\n} //end of the function ScaleWeight\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ScaleFuzzySeperatorBalanceRange_r(fuzzyseperator_t *fs, float scale)\n{\n\tif (fs->child)\n\t{\n\t\tScaleFuzzySeperatorBalanceRange_r(fs->child, scale);\n\t} //end if\n\telse if (fs->type == WT_BALANCE)\n\t{\n\t\tfloat mid = (fs->minweight + fs->maxweight) * 0.5;\n\t\t//get the weight between bounds\n\t\tfs->maxweight = mid + (fs->maxweight - mid) * scale;\n\t\tfs->minweight = mid + (fs->minweight - mid) * scale;\n\t\tif (fs->maxweight < fs->minweight)\n\t\t{\n\t\t\tfs->maxweight = fs->minweight;\n\t\t} //end if\n\t} //end else if\n\tif (fs->next) ScaleFuzzySeperatorBalanceRange_r(fs->next, scale);\n} //end of the function ScaleFuzzySeperatorBalanceRange_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ScaleFuzzyBalanceRange(weightconfig_t *config, float scale)\n{\n\tint i;\n\n\tif (scale < 0) scale = 0;\n\telse if (scale > 100) scale = 100;\n\tfor (i = 0; i < config->numweights; i++)\n\t{\n\t\tScaleFuzzySeperatorBalanceRange_r(config->weights[i].firstseperator, scale);\n\t} //end for\n} //end of the function ScaleFuzzyBalanceRange\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint InterbreedFuzzySeperator_r(fuzzyseperator_t *fs1, fuzzyseperator_t *fs2,\n\t\t\t\t\t\t\t\tfuzzyseperator_t *fsout)\n{\n\tif (fs1->child)\n\t{\n\t\tif (!fs2->child || !fsout->child)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"cannot interbreed weight configs, unequal child\\n\");\n\t\t\treturn qfalse;\n\t\t} //end if\n\t\tif (!InterbreedFuzzySeperator_r(fs2->child, fs2->child, fsout->child))\n\t\t{\n\t\t\treturn qfalse;\n\t\t} //end if\n\t} //end if\n\telse if (fs1->type == WT_BALANCE)\n\t{\n\t\tif (fs2->type != WT_BALANCE || fsout->type != WT_BALANCE)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"cannot interbreed weight configs, unequal balance\\n\");\n\t\t\treturn qfalse;\n\t\t} //end if\n\t\tfsout->weight = (fs1->weight + fs2->weight) / 2;\n\t\tif (fsout->weight > fsout->maxweight) fsout->maxweight = fsout->weight;\n\t\tif (fsout->weight > fsout->minweight) fsout->minweight = fsout->weight;\n\t} //end else if\n\tif (fs1->next)\n\t{\n\t\tif (!fs2->next || !fsout->next)\n\t\t{\n\t\t\tbotimport.Print(PRT_ERROR, \"cannot interbreed weight configs, unequal next\\n\");\n\t\t\treturn qfalse;\n\t\t} //end if\n\t\tif (!InterbreedFuzzySeperator_r(fs1->next, fs2->next, fsout->next))\n\t\t{\n\t\t\treturn qfalse;\n\t\t} //end if\n\t} //end if\n\treturn qtrue;\n} //end of the function InterbreedFuzzySeperator_r\n//===========================================================================\n// config1 and config2 are interbreeded and stored in configout\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid InterbreedWeightConfigs(weightconfig_t *config1, weightconfig_t *config2,\n\t\t\t\t\t\t\t\tweightconfig_t *configout)\n{\n\tint i;\n\n\tif (config1->numweights != config2->numweights ||\n\t\tconfig1->numweights != configout->numweights)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"cannot interbreed weight configs, unequal numweights\\n\");\n\t\treturn;\n\t} //end if\n\tfor (i = 0; i < config1->numweights; i++)\n\t{\n\t\tInterbreedFuzzySeperator_r(config1->weights[i].firstseperator,\n\t\t\t\t\t\t\t\t\tconfig2->weights[i].firstseperator,\n\t\t\t\t\t\t\t\t\tconfigout->weights[i].firstseperator);\n\t} //end for\n} //end of the function InterbreedWeightConfigs\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotShutdownWeights(void)\n{\n\tint i;\n\n\tfor( i = 0; i < MAX_WEIGHT_FILES; i++ )\n\t{\n\t\tif (weightFileList[i])\n\t\t{\n\t\t\tFreeWeightConfig2(weightFileList[i]);\n\t\t\tweightFileList[i] = NULL;\n\t\t} //end if\n\t} //end for\n} //end of the function BotShutdownWeights\n"
  },
  {
    "path": "code/botlib/be_ai_weight.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_ai_weight.h\n *\n * desc:\t\tfuzzy weights\n *\n * $Archive: /source/code/botlib/be_ai_weight.h $\n *\n *****************************************************************************/\n\n#define WT_BALANCE\t\t\t1\n#define MAX_WEIGHTS\t\t\t128\n\n//fuzzy seperator\ntypedef struct fuzzyseperator_s\n{\n\tint index;\n\tint value;\n\tint type;\n\tfloat weight;\n\tfloat minweight;\n\tfloat maxweight;\n\tstruct fuzzyseperator_s *child;\n\tstruct fuzzyseperator_s *next;\n} fuzzyseperator_t;\n\n//fuzzy weight\ntypedef struct weight_s\n{\n\tchar *name;\n\tstruct fuzzyseperator_s *firstseperator;\n} weight_t;\n\n//weight configuration\ntypedef struct weightconfig_s\n{\n\tint numweights;\n\tweight_t weights[MAX_WEIGHTS];\n\tchar\t\tfilename[MAX_QPATH];\n} weightconfig_t;\n\n//reads a weight configuration\nweightconfig_t *ReadWeightConfig(char *filename);\n//free a weight configuration\nvoid FreeWeightConfig(weightconfig_t *config);\n//writes a weight configuration, returns true if successfull\nqboolean WriteWeightConfig(char *filename, weightconfig_t *config);\n//find the fuzzy weight with the given name\nint FindFuzzyWeight(weightconfig_t *wc, char *name);\n//returns the fuzzy weight for the given inventory and weight\nfloat FuzzyWeight(int *inventory, weightconfig_t *wc, int weightnum);\nfloat FuzzyWeightUndecided(int *inventory, weightconfig_t *wc, int weightnum);\n//scales the weight with the given name\nvoid ScaleWeight(weightconfig_t *config, char *name, float scale);\n//scale the balance range\nvoid ScaleBalanceRange(weightconfig_t *config, float scale);\n//evolves the weight configuration\nvoid EvolveWeightConfig(weightconfig_t *config);\n//interbreed the weight configurations and stores the interbreeded one in configout\nvoid InterbreedWeightConfigs(weightconfig_t *config1, weightconfig_t *config2, weightconfig_t *configout);\n//frees cached weight configurations\nvoid BotShutdownWeights(void);\n"
  },
  {
    "path": "code/botlib/be_ea.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_ea.c\n *\n * desc:\t\telementary actions\n *\n * $Archive: /MissionPack/code/botlib/be_ea.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_memory.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#include \"../game/botlib.h\"\n#include \"be_interface.h\"\n\n#define MAX_USERMOVE\t\t\t\t400\n#define MAX_COMMANDARGUMENTS\t\t10\n#define ACTION_JUMPEDLASTFRAME\t\t128\n\nbot_input_t *botinputs;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_Say(int client, char *str)\n{\n\tbotimport.BotClientCommand(client, va(\"say %s\", str) );\n} //end of the function EA_Say\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_SayTeam(int client, char *str)\n{\n\tbotimport.BotClientCommand(client, va(\"say_team %s\", str));\n} //end of the function EA_SayTeam\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_Tell(int client, int clientto, char *str)\n{\n\tbotimport.BotClientCommand(client, va(\"tell %d, %s\", clientto, str));\n} //end of the function EA_SayTeam\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_UseItem(int client, char *it)\n{\n\tbotimport.BotClientCommand(client, va(\"use %s\", it));\n} //end of the function EA_UseItem\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_DropItem(int client, char *it)\n{\n\tbotimport.BotClientCommand(client, va(\"drop %s\", it));\n} //end of the function EA_DropItem\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_UseInv(int client, char *inv)\n{\n\tbotimport.BotClientCommand(client, va(\"invuse %s\", inv));\n} //end of the function EA_UseInv\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_DropInv(int client, char *inv)\n{\n\tbotimport.BotClientCommand(client, va(\"invdrop %s\", inv));\n} //end of the function EA_DropInv\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_Gesture(int client)\n{\n\tbot_input_t *bi;\n\n\tbi = &botinputs[client];\n\n\tbi->actionflags |= ACTION_GESTURE;\n} //end of the function EA_Gesture\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_Command(int client, char *command)\n{\n\tbotimport.BotClientCommand(client, command);\n} //end of the function EA_Command\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_SelectWeapon(int client, int weapon)\n{\n\tbot_input_t *bi;\n\n\tbi = &botinputs[client];\n\n\tbi->weapon = weapon;\n} //end of the function EA_SelectWeapon\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_Attack(int client)\n{\n\tbot_input_t *bi;\n\n\tbi = &botinputs[client];\n\n\tbi->actionflags |= ACTION_ATTACK;\n} //end of the function EA_Attack\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_Talk(int client)\n{\n\tbot_input_t *bi;\n\n\tbi = &botinputs[client];\n\n\tbi->actionflags |= ACTION_TALK;\n} //end of the function EA_Talk\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_Use(int client)\n{\n\tbot_input_t *bi;\n\n\tbi = &botinputs[client];\n\n\tbi->actionflags |= ACTION_USE;\n} //end of the function EA_Use\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_Respawn(int client)\n{\n\tbot_input_t *bi;\n\n\tbi = &botinputs[client];\n\n\tbi->actionflags |= ACTION_RESPAWN;\n} //end of the function EA_Respawn\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_Jump(int client)\n{\n\tbot_input_t *bi;\n\n\tbi = &botinputs[client];\n\n\tif (bi->actionflags & ACTION_JUMPEDLASTFRAME)\n\t{\n\t\tbi->actionflags &= ~ACTION_JUMP;\n\t} //end if\n\telse\n\t{\n\t\tbi->actionflags |= ACTION_JUMP;\n\t} //end if\n} //end of the function EA_Jump\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_DelayedJump(int client)\n{\n\tbot_input_t *bi;\n\n\tbi = &botinputs[client];\n\n\tif (bi->actionflags & ACTION_JUMPEDLASTFRAME)\n\t{\n\t\tbi->actionflags &= ~ACTION_DELAYEDJUMP;\n\t} //end if\n\telse\n\t{\n\t\tbi->actionflags |= ACTION_DELAYEDJUMP;\n\t} //end if\n} //end of the function EA_DelayedJump\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_Crouch(int client)\n{\n\tbot_input_t *bi;\n\n\tbi = &botinputs[client];\n\n\tbi->actionflags |= ACTION_CROUCH;\n} //end of the function EA_Crouch\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_Walk(int client)\n{\n\tbot_input_t *bi;\n\n\tbi = &botinputs[client];\n\n\tbi->actionflags |= ACTION_WALK;\n} //end of the function EA_Walk\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_Action(int client, int action)\n{\n\tbot_input_t *bi;\n\n\tbi = &botinputs[client];\n\n\tbi->actionflags |= action;\n} //end of function EA_Action\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_MoveUp(int client)\n{\n\tbot_input_t *bi;\n\n\tbi = &botinputs[client];\n\n\tbi->actionflags |= ACTION_MOVEUP;\n} //end of the function EA_MoveUp\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_MoveDown(int client)\n{\n\tbot_input_t *bi;\n\n\tbi = &botinputs[client];\n\n\tbi->actionflags |= ACTION_MOVEDOWN;\n} //end of the function EA_MoveDown\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_MoveForward(int client)\n{\n\tbot_input_t *bi;\n\n\tbi = &botinputs[client];\n\n\tbi->actionflags |= ACTION_MOVEFORWARD;\n} //end of the function EA_MoveForward\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_MoveBack(int client)\n{\n\tbot_input_t *bi;\n\n\tbi = &botinputs[client];\n\n\tbi->actionflags |= ACTION_MOVEBACK;\n} //end of the function EA_MoveBack\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_MoveLeft(int client)\n{\n\tbot_input_t *bi;\n\n\tbi = &botinputs[client];\n\n\tbi->actionflags |= ACTION_MOVELEFT;\n} //end of the function EA_MoveLeft\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_MoveRight(int client)\n{\n\tbot_input_t *bi;\n\n\tbi = &botinputs[client];\n\n\tbi->actionflags |= ACTION_MOVERIGHT;\n} //end of the function EA_MoveRight\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_Move(int client, vec3_t dir, float speed)\n{\n\tbot_input_t *bi;\n\n\tbi = &botinputs[client];\n\n\tVectorCopy(dir, bi->dir);\n\t//cap speed\n\tif (speed > MAX_USERMOVE) speed = MAX_USERMOVE;\n\telse if (speed < -MAX_USERMOVE) speed = -MAX_USERMOVE;\n\tbi->speed = speed;\n} //end of the function EA_Move\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_View(int client, vec3_t viewangles)\n{\n\tbot_input_t *bi;\n\n\tbi = &botinputs[client];\n\n\tVectorCopy(viewangles, bi->viewangles);\n} //end of the function EA_View\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_EndRegular(int client, float thinktime)\n{\n/*\n\tbot_input_t *bi;\n\tint jumped = qfalse;\n\n\tbi = &botinputs[client];\n\n\tbi->actionflags &= ~ACTION_JUMPEDLASTFRAME;\n\n\tbi->thinktime = thinktime;\n\tbotimport.BotInput(client, bi);\n\n\tbi->thinktime = 0;\n\tVectorClear(bi->dir);\n\tbi->speed = 0;\n\tjumped = bi->actionflags & ACTION_JUMP;\n\tbi->actionflags = 0;\n\tif (jumped) bi->actionflags |= ACTION_JUMPEDLASTFRAME;\n*/\n} //end of the function EA_EndRegular\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_GetInput(int client, float thinktime, bot_input_t *input)\n{\n\tbot_input_t *bi;\n//\tint jumped = qfalse;\n\n\tbi = &botinputs[client];\n\n//\tbi->actionflags &= ~ACTION_JUMPEDLASTFRAME;\n\n\tbi->thinktime = thinktime;\n\tCom_Memcpy(input, bi, sizeof(bot_input_t));\n\n\t/*\n\tbi->thinktime = 0;\n\tVectorClear(bi->dir);\n\tbi->speed = 0;\n\tjumped = bi->actionflags & ACTION_JUMP;\n\tbi->actionflags = 0;\n\tif (jumped) bi->actionflags |= ACTION_JUMPEDLASTFRAME;\n\t*/\n} //end of the function EA_GetInput\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_ResetInput(int client)\n{\n\tbot_input_t *bi;\n\tint jumped = qfalse;\n\n\tbi = &botinputs[client];\n\tbi->actionflags &= ~ACTION_JUMPEDLASTFRAME;\n\n\tbi->thinktime = 0;\n\tVectorClear(bi->dir);\n\tbi->speed = 0;\n\tjumped = bi->actionflags & ACTION_JUMP;\n\tbi->actionflags = 0;\n\tif (jumped) bi->actionflags |= ACTION_JUMPEDLASTFRAME;\n} //end of the function EA_ResetInput\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint EA_Setup(void)\n{\n\t//initialize the bot inputs\n\tbotinputs = (bot_input_t *) GetClearedHunkMemory(\n\t\t\t\t\t\t\t\t\tbotlibglobals.maxclients * sizeof(bot_input_t));\n\treturn BLERR_NOERROR;\n} //end of the function EA_Setup\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid EA_Shutdown(void)\n{\n\tFreeMemory(botinputs);\n\tbotinputs = NULL;\n} //end of the function EA_Shutdown\n"
  },
  {
    "path": "code/botlib/be_interface.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_interface.c // bk010221 - FIXME - DEAD code elimination\n *\n * desc:\t\tbot library interface\n *\n * $Archive: /MissionPack/code/botlib/be_interface.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_memory.h\"\n#include \"l_log.h\"\n#include \"l_libvar.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#include \"aasfile.h\"\n#include \"../game/botlib.h\"\n#include \"../game/be_aas.h\"\n#include \"be_aas_funcs.h\"\n#include \"be_aas_def.h\"\n#include \"be_interface.h\"\n\n#include \"../game/be_ea.h\"\n#include \"be_ai_weight.h\"\n#include \"../game/be_ai_goal.h\"\n#include \"../game/be_ai_move.h\"\n#include \"../game/be_ai_weap.h\"\n#include \"../game/be_ai_chat.h\"\n#include \"../game/be_ai_char.h\"\n#include \"../game/be_ai_gen.h\"\n\n//library globals in a structure\nbotlib_globals_t botlibglobals;\n\nbotlib_export_t be_botlib_export;\nbotlib_import_t botimport;\n//\nint bot_developer;\n//qtrue if the library is setup\nint botlibsetup = qfalse;\n\n//===========================================================================\n//\n// several functions used by the exported functions\n//\n//===========================================================================\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint Sys_MilliSeconds(void)\n{\n\treturn clock() * 1000 / CLOCKS_PER_SEC;\n} //end of the function Sys_MilliSeconds\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean ValidClientNumber(int num, char *str)\n{\n\tif (num < 0 || num > botlibglobals.maxclients)\n\t{\n\t\t//weird: the disabled stuff results in a crash\n\t\tbotimport.Print(PRT_ERROR, \"%s: invalid client number %d, [0, %d]\\n\",\n\t\t\t\t\t\t\t\t\t\tstr, num, botlibglobals.maxclients);\n\t\treturn qfalse;\n\t} //end if\n\treturn qtrue;\n} //end of the function BotValidateClientNumber\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean ValidEntityNumber(int num, char *str)\n{\n\tif (num < 0 || num > botlibglobals.maxentities)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"%s: invalid entity number %d, [0, %d]\\n\",\n\t\t\t\t\t\t\t\t\t\tstr, num, botlibglobals.maxentities);\n\t\treturn qfalse;\n\t} //end if\n\treturn qtrue;\n} //end of the function BotValidateClientNumber\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean BotLibSetup(char *str)\n{\n\tif (!botlibglobals.botlibsetup)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"%s: bot library used before being setup\\n\", str);\n\t\treturn qfalse;\n\t} //end if\n\treturn qtrue;\n} //end of the function BotLibSetup\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint Export_BotLibSetup(void)\n{\n\tint\t\terrnum;\n\t\n\tbot_developer = LibVarGetValue(\"bot_developer\");\n  memset( &botlibglobals, 0, sizeof(botlibglobals) ); // bk001207 - init\n\t//initialize byte swapping (litte endian etc.)\n//\tSwap_Init();\n\tLog_Open(\"botlib.log\");\n\t//\n\tbotimport.Print(PRT_MESSAGE, \"------- BotLib Initialization -------\\n\");\n\t//\n\tbotlibglobals.maxclients = (int) LibVarValue(\"maxclients\", \"128\");\n\tbotlibglobals.maxentities = (int) LibVarValue(\"maxentities\", \"1024\");\n\n\terrnum = AAS_Setup();\t\t\t//be_aas_main.c\n\tif (errnum != BLERR_NOERROR) return errnum;\n\terrnum = EA_Setup();\t\t\t//be_ea.c\n\tif (errnum != BLERR_NOERROR) return errnum;\n\terrnum = BotSetupWeaponAI();\t//be_ai_weap.c\n\tif (errnum != BLERR_NOERROR)return errnum;\n\terrnum = BotSetupGoalAI();\t\t//be_ai_goal.c\n\tif (errnum != BLERR_NOERROR) return errnum;\n\terrnum = BotSetupChatAI();\t\t//be_ai_chat.c\n\tif (errnum != BLERR_NOERROR) return errnum;\n\terrnum = BotSetupMoveAI();\t\t//be_ai_move.c\n\tif (errnum != BLERR_NOERROR) return errnum;\n\n\tbotlibsetup = qtrue;\n\tbotlibglobals.botlibsetup = qtrue;\n\n\treturn BLERR_NOERROR;\n} //end of the function Export_BotLibSetup\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint Export_BotLibShutdown(void)\n{\n\tif (!BotLibSetup(\"BotLibShutdown\")) return BLERR_LIBRARYNOTSETUP;\n#ifndef DEMO\n\t//DumpFileCRCs();\n#endif //DEMO\n\t//\n\tBotShutdownChatAI();\t\t//be_ai_chat.c\n\tBotShutdownMoveAI();\t\t//be_ai_move.c\n\tBotShutdownGoalAI();\t\t//be_ai_goal.c\n\tBotShutdownWeaponAI();\t\t//be_ai_weap.c\n\tBotShutdownWeights();\t\t//be_ai_weight.c\n\tBotShutdownCharacters();\t//be_ai_char.c\n\t//shud down aas\n\tAAS_Shutdown();\n\t//shut down bot elemantary actions\n\tEA_Shutdown();\n\t//free all libvars\n\tLibVarDeAllocAll();\n\t//remove all global defines from the pre compiler\n\tPC_RemoveAllGlobalDefines();\n\n\t//dump all allocated memory\n//\tDumpMemory();\n#ifdef DEBUG\n\tPrintMemoryLabels();\n#endif\n\t//shut down library log file\n\tLog_Shutdown();\n\t//\n\tbotlibsetup = qfalse;\n\tbotlibglobals.botlibsetup = qfalse;\n\t// print any files still open\n\tPC_CheckOpenSourceHandles();\n\t//\n\treturn BLERR_NOERROR;\n} //end of the function Export_BotLibShutdown\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint Export_BotLibVarSet(char *var_name, char *value)\n{\n\tLibVarSet(var_name, value);\n\treturn BLERR_NOERROR;\n} //end of the function Export_BotLibVarSet\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint Export_BotLibVarGet(char *var_name, char *value, int size)\n{\n\tchar *varvalue;\n\n\tvarvalue = LibVarGetString(var_name);\n\tstrncpy(value, varvalue, size-1);\n\tvalue[size-1] = '\\0';\n\treturn BLERR_NOERROR;\n} //end of the function Export_BotLibVarGet\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint Export_BotLibStartFrame(float time)\n{\n\tif (!BotLibSetup(\"BotStartFrame\")) return BLERR_LIBRARYNOTSETUP;\n\treturn AAS_StartFrame(time);\n} //end of the function Export_BotLibStartFrame\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint Export_BotLibLoadMap(const char *mapname)\n{\n#ifdef DEBUG\n\tint starttime = Sys_MilliSeconds();\n#endif\n\tint errnum;\n\n\tif (!BotLibSetup(\"BotLoadMap\")) return BLERR_LIBRARYNOTSETUP;\n\t//\n\tbotimport.Print(PRT_MESSAGE, \"------------ Map Loading ------------\\n\");\n\t//startup AAS for the current map, model and sound index\n\terrnum = AAS_LoadMap(mapname);\n\tif (errnum != BLERR_NOERROR) return errnum;\n\t//initialize the items in the level\n\tBotInitLevelItems();\t\t//be_ai_goal.h\n\tBotSetBrushModelTypes();\t//be_ai_move.h\n\t//\n\tbotimport.Print(PRT_MESSAGE, \"-------------------------------------\\n\");\n#ifdef DEBUG\n\tbotimport.Print(PRT_MESSAGE, \"map loaded in %d msec\\n\", Sys_MilliSeconds() - starttime);\n#endif\n\t//\n\treturn BLERR_NOERROR;\n} //end of the function Export_BotLibLoadMap\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint Export_BotLibUpdateEntity(int ent, bot_entitystate_t *state)\n{\n\tif (!BotLibSetup(\"BotUpdateEntity\")) return BLERR_LIBRARYNOTSETUP;\n\tif (!ValidEntityNumber(ent, \"BotUpdateEntity\")) return BLERR_INVALIDENTITYNUMBER;\n\n\treturn AAS_UpdateEntity(ent, state);\n} //end of the function Export_BotLibUpdateEntity\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_TestMovementPrediction(int entnum, vec3_t origin, vec3_t dir);\nvoid ElevatorBottomCenter(aas_reachability_t *reach, vec3_t bottomcenter);\nint BotGetReachabilityToGoal(vec3_t origin, int areanum,\n\t\t\t\t\t\t\t\t\t  int lastgoalareanum, int lastareanum,\n\t\t\t\t\t\t\t\t\t  int *avoidreach, float *avoidreachtimes, int *avoidreachtries,\n\t\t\t\t\t\t\t\t\t  bot_goal_t *goal, int travelflags, int movetravelflags,\n\t\t\t\t\t\t\t\t\t  struct bot_avoidspot_s *avoidspots, int numavoidspots, int *flags);\n\nint AAS_PointLight(vec3_t origin, int *red, int *green, int *blue);\n\nint AAS_TraceAreas(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas);\n\nint AAS_Reachability_WeaponJump(int area1num, int area2num);\n\nint BotFuzzyPointReachabilityArea(vec3_t origin);\n\nfloat BotGapDistance(vec3_t origin, vec3_t hordir, int entnum);\n\nvoid AAS_FloodAreas(vec3_t origin);\n\nint BotExportTest(int parm0, char *parm1, vec3_t parm2, vec3_t parm3)\n{\n\n//\treturn AAS_PointLight(parm2, NULL, NULL, NULL);\n\n#ifdef DEBUG\n\tstatic int area = -1;\n\tstatic int line[2];\n\tint newarea, i, highlightarea, flood;\n//\tint reachnum;\n\tvec3_t eye, forward, right, end, origin;\n//\tvec3_t bottomcenter;\n//\taas_trace_t trace;\n//\taas_face_t *face;\n//\taas_entity_t *ent;\n//\tbsp_trace_t bsptrace;\n//\taas_reachability_t reach;\n//\tbot_goal_t goal;\n\n\t// clock_t start_time, end_time;\n\tvec3_t mins = {-16, -16, -24};\n\tvec3_t maxs = {16, 16, 32};\n\n//\tint areas[10], numareas;\n\n\n\t//return 0;\n\n\tif (!aasworld.loaded) return 0;\n\n\t/*\n\tif (parm0 & 1)\n\t{\n\t\tAAS_ClearShownPolygons();\n\t\tAAS_FloodAreas(parm2);\n\t} //end if\n\treturn 0;\n\t*/\n\tfor (i = 0; i < 2; i++) if (!line[i]) line[i] = botimport.DebugLineCreate();\n\n//\tAAS_ClearShownDebugLines();\n\n\t//if (AAS_AgainstLadder(parm2)) botimport.Print(PRT_MESSAGE, \"against ladder\\n\");\n\t//BotOnGround(parm2, PRESENCE_NORMAL, 1, &newarea, &newarea);\n\t//botimport.Print(PRT_MESSAGE, \"%f %f %f\\n\", parm2[0], parm2[1], parm2[2]);\n\t//*\n\thighlightarea = LibVarGetValue(\"bot_highlightarea\");\n\tif (highlightarea > 0)\n\t{\n\t\tnewarea = highlightarea;\n\t} //end if\n\telse\n\t{\n\t\tVectorCopy(parm2, origin);\n\t\torigin[2] += 0.5;\n\t\t//newarea = AAS_PointAreaNum(origin);\n\t\tnewarea = BotFuzzyPointReachabilityArea(origin);\n\t} //end else\n\n\tbotimport.Print(PRT_MESSAGE, \"\\rtravel time to goal (%d) = %d  \", botlibglobals.goalareanum,\n\t\tAAS_AreaTravelTimeToGoalArea(newarea, origin, botlibglobals.goalareanum, TFL_DEFAULT));\n\t//newarea = BotReachabilityArea(origin, qtrue);\n\tif (newarea != area)\n\t{\n\t\tbotimport.Print(PRT_MESSAGE, \"origin = %f, %f, %f\\n\", origin[0], origin[1], origin[2]);\n\t\tarea = newarea;\n\t\tbotimport.Print(PRT_MESSAGE, \"new area %d, cluster %d, presence type %d\\n\",\n\t\t\t\t\tarea, AAS_AreaCluster(area), AAS_PointPresenceType(origin));\n\t\tbotimport.Print(PRT_MESSAGE, \"area contents: \");\n\t\tif (aasworld.areasettings[area].contents & AREACONTENTS_WATER)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"water &\");\n\t\t} //end if\n\t\tif (aasworld.areasettings[area].contents & AREACONTENTS_LAVA)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"lava &\");\n\t\t} //end if\n\t\tif (aasworld.areasettings[area].contents & AREACONTENTS_SLIME)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"slime &\");\n\t\t} //end if\n\t\tif (aasworld.areasettings[area].contents & AREACONTENTS_JUMPPAD)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"jump pad &\");\n\t\t} //end if\n\t\tif (aasworld.areasettings[area].contents & AREACONTENTS_CLUSTERPORTAL)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"cluster portal &\");\n\t\t} //end if\n\t\tif (aasworld.areasettings[area].contents & AREACONTENTS_VIEWPORTAL)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"view portal &\");\n\t\t} //end if\n\t\tif (aasworld.areasettings[area].contents & AREACONTENTS_DONOTENTER)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"do not enter &\");\n\t\t} //end if\n\t\tif (aasworld.areasettings[area].contents & AREACONTENTS_MOVER)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"mover &\");\n\t\t} //end if\n\t\tif (!aasworld.areasettings[area].contents)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"empty\");\n\t\t} //end if\n\t\tbotimport.Print(PRT_MESSAGE, \"\\n\");\n\t\tbotimport.Print(PRT_MESSAGE, \"travel time to goal (%d) = %d\\n\", botlibglobals.goalareanum,\n\t\t\t\t\tAAS_AreaTravelTimeToGoalArea(newarea, origin, botlibglobals.goalareanum, TFL_DEFAULT|TFL_ROCKETJUMP));\n\t\t/*\n\t\tVectorCopy(origin, end);\n\t\tend[2] += 5;\n\t\tnumareas = AAS_TraceAreas(origin, end, areas, NULL, 10);\n\t\tAAS_TraceClientBBox(origin, end, PRESENCE_CROUCH, -1);\n\t\tbotimport.Print(PRT_MESSAGE, \"num areas = %d, area = %d\\n\", numareas, areas[0]);\n\t\t*/\n\t\t/*\n\t\tbotlibglobals.goalareanum = newarea;\n\t\tVectorCopy(parm2, botlibglobals.goalorigin);\n\t\tbotimport.Print(PRT_MESSAGE, \"new goal %2.1f %2.1f %2.1f area %d\\n\",\n\t\t\t\t\t\t\t\torigin[0], origin[1], origin[2], newarea);\n\t\t*/\n\t} //end if\n\t//*\n\tflood = LibVarGetValue(\"bot_flood\");\n\tif (parm0 & 1)\n\t{\n\t\tif (flood)\n\t\t{\n\t\t\tAAS_ClearShownPolygons();\n\t\t\tAAS_ClearShownDebugLines();\n\t\t\tAAS_FloodAreas(parm2);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tbotlibglobals.goalareanum = newarea;\n\t\t\tVectorCopy(parm2, botlibglobals.goalorigin);\n\t\t\tbotimport.Print(PRT_MESSAGE, \"new goal %2.1f %2.1f %2.1f area %d\\n\",\n\t\t\t\t\t\t\t\t\torigin[0], origin[1], origin[2], newarea);\n\t\t}\n\t} //end if*/\n\tif (flood)\n\t\treturn 0;\n//\tif (parm0 & BUTTON_USE)\n//\t{\n//\t\tbotlibglobals.runai = !botlibglobals.runai;\n//\t\tif (botlibglobals.runai) botimport.Print(PRT_MESSAGE, \"started AI\\n\");\n//\t\telse botimport.Print(PRT_MESSAGE, \"stopped AI\\n\");\n\t\t//* /\n\t\t/*\n\t\tgoal.areanum = botlibglobals.goalareanum;\n\t\treachnum = BotGetReachabilityToGoal(parm2, newarea, 1,\n\t\t\t\t\t\t\t\t\t\tms.avoidreach, ms.avoidreachtimes,\n\t\t\t\t\t\t\t\t\t\t&goal, TFL_DEFAULT);\n\t\tif (!reachnum)\n\t\t{\n\t\t\tbotimport.Print(PRT_MESSAGE, \"goal not reachable\\n\");\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tAAS_ReachabilityFromNum(reachnum, &reach);\n\t\t\tAAS_ClearShownDebugLines();\n\t\t\tAAS_ShowArea(area, qtrue);\n\t\t\tAAS_ShowArea(reach.areanum, qtrue);\n\t\t\tAAS_DrawCross(reach.start, 6, LINECOLOR_BLUE);\n\t\t\tAAS_DrawCross(reach.end, 6, LINECOLOR_RED);\n\t\t\t//\n\t\t\tif ((reach.traveltype & TRAVELTYPE_MASK) == TRAVEL_ELEVATOR)\n\t\t\t{\n\t\t\t\tElevatorBottomCenter(&reach, bottomcenter);\n\t\t\t\tAAS_DrawCross(bottomcenter, 10, LINECOLOR_GREEN);\n\t\t\t} //end if\n\t\t} //end else*/\n//\t\tbotimport.Print(PRT_MESSAGE, \"travel time to goal = %d\\n\",\n//\t\t\t\t\tAAS_AreaTravelTimeToGoalArea(area, origin, botlibglobals.goalareanum, TFL_DEFAULT));\n//\t\tbotimport.Print(PRT_MESSAGE, \"test rj from 703 to 716\\n\");\n//\t\tAAS_Reachability_WeaponJump(703, 716);\n//\t} //end if*/\n\n/*\tface = AAS_AreaGroundFace(newarea, parm2);\n\tif (face)\n\t{\n\t\tAAS_ShowFace(face - aasworld.faces);\n\t} //end if*/\n\t/*\n\tAAS_ClearShownDebugLines();\n\tAAS_ShowArea(newarea, parm0 & BUTTON_USE);\n\tAAS_ShowReachableAreas(area);\n\t*/\n\tAAS_ClearShownPolygons();\n\tAAS_ClearShownDebugLines();\n\tAAS_ShowAreaPolygons(newarea, 1, parm0 & 4);\n\tif (parm0 & 2) AAS_ShowReachableAreas(area);\n\telse\n\t{\n\t\tstatic int lastgoalareanum, lastareanum;\n\t\tstatic int avoidreach[MAX_AVOIDREACH];\n\t\tstatic float avoidreachtimes[MAX_AVOIDREACH];\n\t\tstatic int avoidreachtries[MAX_AVOIDREACH];\n\t\tint reachnum, resultFlags;\n\t\tbot_goal_t goal;\n\t\taas_reachability_t reach;\n\n\t\t/*\n\t\tgoal.areanum = botlibglobals.goalareanum;\n\t\tVectorCopy(botlibglobals.goalorigin, goal.origin);\n\t\treachnum = BotGetReachabilityToGoal(origin, newarea,\n\t\t\t\t\t\t\t\t\t  lastgoalareanum, lastareanum,\n\t\t\t\t\t\t\t\t\t  avoidreach, avoidreachtimes, avoidreachtries,\n\t\t\t\t\t\t\t\t\t  &goal, TFL_DEFAULT|TFL_FUNCBOB|TFL_ROCKETJUMP, TFL_DEFAULT|TFL_FUNCBOB|TFL_ROCKETJUMP,\n\t\t\t\t\t\t\t\t\t  NULL, 0, &resultFlags);\n\t\tAAS_ReachabilityFromNum(reachnum, &reach);\n\t\tAAS_ShowReachability(&reach);\n\t\t*/\n\t\tint curarea;\n\t\tvec3_t curorigin;\n\n\t\tgoal.areanum = botlibglobals.goalareanum;\n\t\tVectorCopy(botlibglobals.goalorigin, goal.origin);\n\t\tVectorCopy(origin, curorigin);\n\t\tcurarea = newarea;\n\t\tfor ( i = 0; i < 100; i++ ) {\n\t\t\tif ( curarea == goal.areanum ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\treachnum = BotGetReachabilityToGoal(curorigin, curarea,\n\t\t\t\t\t\t\t\t\t\t  lastgoalareanum, lastareanum,\n\t\t\t\t\t\t\t\t\t\t  avoidreach, avoidreachtimes, avoidreachtries,\n\t\t\t\t\t\t\t\t\t\t  &goal, TFL_DEFAULT|TFL_FUNCBOB|TFL_ROCKETJUMP, TFL_DEFAULT|TFL_FUNCBOB|TFL_ROCKETJUMP,\n\t\t\t\t\t\t\t\t\t\t  NULL, 0, &resultFlags);\n\t\t\tAAS_ReachabilityFromNum(reachnum, &reach);\n\t\t\tAAS_ShowReachability(&reach);\n\t\t\tVectorCopy(reach.end, origin);\n\t\t\tlastareanum = curarea;\n\t\t\tcurarea = reach.areanum;\n\t\t}\n\t} //end else\n\tVectorClear(forward);\n\t//BotGapDistance(origin, forward, 0);\n\t/*\n\tif (parm0 & BUTTON_USE)\n\t{\n\t\tbotimport.Print(PRT_MESSAGE, \"test rj from 703 to 716\\n\");\n\t\tAAS_Reachability_WeaponJump(703, 716);\n\t} //end if*/\n\n\tAngleVectors(parm3, forward, right, NULL);\n\t//get the eye 16 units to the right of the origin\n\tVectorMA(parm2, 8, right, eye);\n\t//get the eye 24 units up\n\teye[2] += 24;\n\t//get the end point for the line to be traced\n\tVectorMA(eye, 800, forward, end);\n\n//\tAAS_TestMovementPrediction(1, parm2, forward);\n/*\n    //trace the line to find the hit point\n\ttrace = AAS_TraceClientBBox(eye, end, PRESENCE_NORMAL, 1);\n\tif (!line[0]) line[0] = botimport.DebugLineCreate();\n\tbotimport.DebugLineShow(line[0], eye, trace.endpos, LINECOLOR_BLUE);\n\t//\n\tAAS_ClearShownDebugLines();\n\tif (trace.ent)\n\t{\n\t\tent = &aasworld.entities[trace.ent];\n\t\tAAS_ShowBoundingBox(ent->origin, ent->mins, ent->maxs);\n\t} //end if\n*/\n\n/*\n\tstart_time = clock();\n\tfor (i = 0; i < 2000; i++)\n\t{\n\t\tAAS_Trace2(eye, mins, maxs, end, 1, MASK_PLAYERSOLID);\n//\t\tAAS_TraceClientBBox(eye, end, PRESENCE_NORMAL, 1);\n\t} //end for\n\tend_time = clock();\n\tbotimport.Print(PRT_MESSAGE, \"me %lu clocks, %lu CLOCKS_PER_SEC\\n\", end_time - start_time, CLOCKS_PER_SEC);\n\tstart_time = clock();\n\tfor (i = 0; i < 2000; i++)\n\t{\n\t\tAAS_Trace(eye, mins, maxs, end, 1, MASK_PLAYERSOLID);\n\t} //end for\n\tend_time = clock();\n\tbotimport.Print(PRT_MESSAGE, \"id %lu clocks, %lu CLOCKS_PER_SEC\\n\", end_time - start_time, CLOCKS_PER_SEC);\n*/\n\n    // TTimo: nested comments are BAD for gcc -Werror, use #if 0 instead..\n#if 0\n\tAAS_ClearShownDebugLines();\n\t//bsptrace = AAS_Trace(eye, NULL, NULL, end, 1, MASK_PLAYERSOLID);\n\tbsptrace = AAS_Trace(eye, mins, maxs, end, 1, MASK_PLAYERSOLID);\n\tif (!line[0]) line[0] = botimport.DebugLineCreate();\n\tbotimport.DebugLineShow(line[0], eye, bsptrace.endpos, LINECOLOR_YELLOW);\n\tif (bsptrace.fraction < 1.0)\n\t{\n\t\tface = AAS_TraceEndFace(&trace);\n\t\tif (face)\n\t\t{\n\t\t\tAAS_ShowFace(face - aasworld.faces);\n\t\t} //end if\n\t\t\n\t\tAAS_DrawPlaneCross(bsptrace.endpos,\n\t\t\t\t\t\t\t\t\tbsptrace.plane.normal,\n\t\t\t\t\t\t\t\t\tbsptrace.plane.dist + bsptrace.exp_dist,\n\t\t\t\t\t\t\t\t\tbsptrace.plane.type, LINECOLOR_GREEN);\n\t\tif (trace.ent)\n\t\t{\n\t\t\tent = &aasworld.entities[trace.ent];\n\t\t\tAAS_ShowBoundingBox(ent->origin, ent->mins, ent->maxs);\n\t\t} //end if\n\t} //end if\n\t//bsptrace = AAS_Trace2(eye, NULL, NULL, end, 1, MASK_PLAYERSOLID);\n\tbsptrace = AAS_Trace2(eye, mins, maxs, end, 1, MASK_PLAYERSOLID);\n\tbotimport.DebugLineShow(line[1], eye, bsptrace.endpos, LINECOLOR_BLUE);\n\tif (bsptrace.fraction < 1.0)\n\t{\n\t\tAAS_DrawPlaneCross(bsptrace.endpos,\n\t\t\t\t\t\t\t\t\tbsptrace.plane.normal,\n\t\t\t\t\t\t\t\t\tbsptrace.plane.dist,// + bsptrace.exp_dist,\n\t\t\t\t\t\t\t\t\tbsptrace.plane.type, LINECOLOR_RED);\n\t\tif (bsptrace.ent)\n\t\t{\n\t\t\tent = &aasworld.entities[bsptrace.ent];\n\t\t\tAAS_ShowBoundingBox(ent->origin, ent->mins, ent->maxs);\n\t\t} //end if\n\t} //end if\n#endif\n#endif\n\treturn 0;\n} //end of the function BotExportTest\n\n\n/*\n============\nInit_AAS_Export\n============\n*/\nstatic void Init_AAS_Export( aas_export_t *aas ) {\n\t//--------------------------------------------\n\t// be_aas_entity.c\n\t//--------------------------------------------\n\taas->AAS_EntityInfo = AAS_EntityInfo;\n\t//--------------------------------------------\n\t// be_aas_main.c\n\t//--------------------------------------------\n\taas->AAS_Initialized = AAS_Initialized;\n\taas->AAS_PresenceTypeBoundingBox = AAS_PresenceTypeBoundingBox;\n\taas->AAS_Time = AAS_Time;\n\t//--------------------------------------------\n\t// be_aas_sample.c\n\t//--------------------------------------------\n\taas->AAS_PointAreaNum = AAS_PointAreaNum;\n\taas->AAS_PointReachabilityAreaIndex = AAS_PointReachabilityAreaIndex;\n\taas->AAS_TraceAreas = AAS_TraceAreas;\n\taas->AAS_BBoxAreas = AAS_BBoxAreas;\n\taas->AAS_AreaInfo = AAS_AreaInfo;\n\t//--------------------------------------------\n\t// be_aas_bspq3.c\n\t//--------------------------------------------\n\taas->AAS_PointContents = AAS_PointContents;\n\taas->AAS_NextBSPEntity = AAS_NextBSPEntity;\n\taas->AAS_ValueForBSPEpairKey = AAS_ValueForBSPEpairKey;\n\taas->AAS_VectorForBSPEpairKey = AAS_VectorForBSPEpairKey;\n\taas->AAS_FloatForBSPEpairKey = AAS_FloatForBSPEpairKey;\n\taas->AAS_IntForBSPEpairKey = AAS_IntForBSPEpairKey;\n\t//--------------------------------------------\n\t// be_aas_reach.c\n\t//--------------------------------------------\n\taas->AAS_AreaReachability = AAS_AreaReachability;\n\t//--------------------------------------------\n\t// be_aas_route.c\n\t//--------------------------------------------\n\taas->AAS_AreaTravelTimeToGoalArea = AAS_AreaTravelTimeToGoalArea;\n\taas->AAS_EnableRoutingArea = AAS_EnableRoutingArea;\n\taas->AAS_PredictRoute = AAS_PredictRoute;\n\t//--------------------------------------------\n\t// be_aas_altroute.c\n\t//--------------------------------------------\n\taas->AAS_AlternativeRouteGoals = AAS_AlternativeRouteGoals;\n\t//--------------------------------------------\n\t// be_aas_move.c\n\t//--------------------------------------------\n\taas->AAS_Swimming = AAS_Swimming;\n\taas->AAS_PredictClientMovement = AAS_PredictClientMovement;\n}\n\n  \n/*\n============\nInit_EA_Export\n============\n*/\nstatic void Init_EA_Export( ea_export_t *ea ) {\n\t//ClientCommand elementary actions\n\tea->EA_Command = EA_Command;\n\tea->EA_Say = EA_Say;\n\tea->EA_SayTeam = EA_SayTeam;\n\n\tea->EA_Action = EA_Action;\n\tea->EA_Gesture = EA_Gesture;\n\tea->EA_Talk = EA_Talk;\n\tea->EA_Attack = EA_Attack;\n\tea->EA_Use = EA_Use;\n\tea->EA_Respawn = EA_Respawn;\n\tea->EA_Crouch = EA_Crouch;\n\tea->EA_MoveUp = EA_MoveUp;\n\tea->EA_MoveDown = EA_MoveDown;\n\tea->EA_MoveForward = EA_MoveForward;\n\tea->EA_MoveBack = EA_MoveBack;\n\tea->EA_MoveLeft = EA_MoveLeft;\n\tea->EA_MoveRight = EA_MoveRight;\n\n\tea->EA_SelectWeapon = EA_SelectWeapon;\n\tea->EA_Jump = EA_Jump;\n\tea->EA_DelayedJump = EA_DelayedJump;\n\tea->EA_Move = EA_Move;\n\tea->EA_View = EA_View;\n\tea->EA_GetInput = EA_GetInput;\n\tea->EA_EndRegular = EA_EndRegular;\n\tea->EA_ResetInput = EA_ResetInput;\n}\n\n\n/*\n============\nInit_AI_Export\n============\n*/\nstatic void Init_AI_Export( ai_export_t *ai ) {\n\t//-----------------------------------\n\t// be_ai_char.h\n\t//-----------------------------------\n\tai->BotLoadCharacter = BotLoadCharacter;\n\tai->BotFreeCharacter = BotFreeCharacter;\n\tai->Characteristic_Float = Characteristic_Float;\n\tai->Characteristic_BFloat = Characteristic_BFloat;\n\tai->Characteristic_Integer = Characteristic_Integer;\n\tai->Characteristic_BInteger = Characteristic_BInteger;\n\tai->Characteristic_String = Characteristic_String;\n\t//-----------------------------------\n\t// be_ai_chat.h\n\t//-----------------------------------\n\tai->BotAllocChatState = BotAllocChatState;\n\tai->BotFreeChatState = BotFreeChatState;\n\tai->BotQueueConsoleMessage = BotQueueConsoleMessage;\n\tai->BotRemoveConsoleMessage = BotRemoveConsoleMessage;\n\tai->BotNextConsoleMessage = BotNextConsoleMessage;\n\tai->BotNumConsoleMessages = BotNumConsoleMessages;\n\tai->BotInitialChat = BotInitialChat;\n\tai->BotNumInitialChats = BotNumInitialChats;\n\tai->BotReplyChat = BotReplyChat;\n\tai->BotChatLength = BotChatLength;\n\tai->BotEnterChat = BotEnterChat;\n\tai->BotGetChatMessage = BotGetChatMessage;\n\tai->StringContains = StringContains;\n\tai->BotFindMatch = BotFindMatch;\n\tai->BotMatchVariable = BotMatchVariable;\n\tai->UnifyWhiteSpaces = UnifyWhiteSpaces;\n\tai->BotReplaceSynonyms = BotReplaceSynonyms;\n\tai->BotLoadChatFile = BotLoadChatFile;\n\tai->BotSetChatGender = BotSetChatGender;\n\tai->BotSetChatName = BotSetChatName;\n\t//-----------------------------------\n\t// be_ai_goal.h\n\t//-----------------------------------\n\tai->BotResetGoalState = BotResetGoalState;\n\tai->BotResetAvoidGoals = BotResetAvoidGoals;\n\tai->BotRemoveFromAvoidGoals = BotRemoveFromAvoidGoals;\n\tai->BotPushGoal = BotPushGoal;\n\tai->BotPopGoal = BotPopGoal;\n\tai->BotEmptyGoalStack = BotEmptyGoalStack;\n\tai->BotDumpAvoidGoals = BotDumpAvoidGoals;\n\tai->BotDumpGoalStack = BotDumpGoalStack;\n\tai->BotGoalName = BotGoalName;\n\tai->BotGetTopGoal = BotGetTopGoal;\n\tai->BotGetSecondGoal = BotGetSecondGoal;\n\tai->BotChooseLTGItem = BotChooseLTGItem;\n\tai->BotChooseNBGItem = BotChooseNBGItem;\n\tai->BotTouchingGoal = BotTouchingGoal;\n\tai->BotItemGoalInVisButNotVisible = BotItemGoalInVisButNotVisible;\n\tai->BotGetLevelItemGoal = BotGetLevelItemGoal;\n\tai->BotGetNextCampSpotGoal = BotGetNextCampSpotGoal;\n\tai->BotGetMapLocationGoal = BotGetMapLocationGoal;\n\tai->BotAvoidGoalTime = BotAvoidGoalTime;\n\tai->BotSetAvoidGoalTime = BotSetAvoidGoalTime;\n\tai->BotInitLevelItems = BotInitLevelItems;\n\tai->BotUpdateEntityItems = BotUpdateEntityItems;\n\tai->BotLoadItemWeights = BotLoadItemWeights;\n\tai->BotFreeItemWeights = BotFreeItemWeights;\n\tai->BotInterbreedGoalFuzzyLogic = BotInterbreedGoalFuzzyLogic;\n\tai->BotSaveGoalFuzzyLogic = BotSaveGoalFuzzyLogic;\n\tai->BotMutateGoalFuzzyLogic = BotMutateGoalFuzzyLogic;\n\tai->BotAllocGoalState = BotAllocGoalState;\n\tai->BotFreeGoalState = BotFreeGoalState;\n\t//-----------------------------------\n\t// be_ai_move.h\n\t//-----------------------------------\n\tai->BotResetMoveState = BotResetMoveState;\n\tai->BotMoveToGoal = BotMoveToGoal;\n\tai->BotMoveInDirection = BotMoveInDirection;\n\tai->BotResetAvoidReach = BotResetAvoidReach;\n\tai->BotResetLastAvoidReach = BotResetLastAvoidReach;\n\tai->BotReachabilityArea = BotReachabilityArea;\n\tai->BotMovementViewTarget = BotMovementViewTarget;\n\tai->BotPredictVisiblePosition = BotPredictVisiblePosition;\n\tai->BotAllocMoveState = BotAllocMoveState;\n\tai->BotFreeMoveState = BotFreeMoveState;\n\tai->BotInitMoveState = BotInitMoveState;\n\tai->BotAddAvoidSpot = BotAddAvoidSpot;\n\t//-----------------------------------\n\t// be_ai_weap.h\n\t//-----------------------------------\n\tai->BotChooseBestFightWeapon = BotChooseBestFightWeapon;\n\tai->BotGetWeaponInfo = BotGetWeaponInfo;\n\tai->BotLoadWeaponWeights = BotLoadWeaponWeights;\n\tai->BotAllocWeaponState = BotAllocWeaponState;\n\tai->BotFreeWeaponState = BotFreeWeaponState;\n\tai->BotResetWeaponState = BotResetWeaponState;\n\t//-----------------------------------\n\t// be_ai_gen.h\n\t//-----------------------------------\n\tai->GeneticParentsAndChildSelection = GeneticParentsAndChildSelection;\n}\n\n\n/*\n============\nGetBotLibAPI\n============\n*/\nbotlib_export_t *GetBotLibAPI(int apiVersion, botlib_import_t *import) {\n\tassert(import);   // bk001129 - this wasn't set for baseq3/\n  botimport = *import;\n  assert(botimport.Print);   // bk001129 - pars pro toto\n\n\tCom_Memset( &be_botlib_export, 0, sizeof( be_botlib_export ) );\n\n\tif ( apiVersion != BOTLIB_API_VERSION ) {\n\t\tbotimport.Print( PRT_ERROR, \"Mismatched BOTLIB_API_VERSION: expected %i, got %i\\n\", BOTLIB_API_VERSION, apiVersion );\n\t\treturn NULL;\n\t}\n\n\tInit_AAS_Export(&be_botlib_export.aas);\n\tInit_EA_Export(&be_botlib_export.ea);\n\tInit_AI_Export(&be_botlib_export.ai);\n\n\tbe_botlib_export.BotLibSetup = Export_BotLibSetup;\n\tbe_botlib_export.BotLibShutdown = Export_BotLibShutdown;\n\tbe_botlib_export.BotLibVarSet = Export_BotLibVarSet;\n\tbe_botlib_export.BotLibVarGet = Export_BotLibVarGet;\n\n\tbe_botlib_export.PC_AddGlobalDefine = PC_AddGlobalDefine;\n\tbe_botlib_export.PC_LoadSourceHandle = PC_LoadSourceHandle;\n\tbe_botlib_export.PC_FreeSourceHandle = PC_FreeSourceHandle;\n\tbe_botlib_export.PC_ReadTokenHandle = PC_ReadTokenHandle;\n\tbe_botlib_export.PC_SourceFileAndLine = PC_SourceFileAndLine;\n\n\tbe_botlib_export.BotLibStartFrame = Export_BotLibStartFrame;\n\tbe_botlib_export.BotLibLoadMap = Export_BotLibLoadMap;\n\tbe_botlib_export.BotLibUpdateEntity = Export_BotLibUpdateEntity;\n\tbe_botlib_export.Test = BotExportTest;\n\n\treturn &be_botlib_export;\n}\n"
  },
  {
    "path": "code/botlib/be_interface.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tbe_interface.h\n *\n * desc:\t\tbotlib interface\n *\n * $Archive: /source/code/botlib/be_interface.h $\n *\n *****************************************************************************/\n\n//#define DEBUG\t\t\t//debug code\n#define RANDOMIZE\t\t//randomize bot behaviour\n\n//FIXME: get rid of this global structure\ntypedef struct botlib_globals_s\n{\n\tint botlibsetup;\t\t\t\t\t\t//true when the bot library has been setup\n\tint maxentities;\t\t\t\t\t\t//maximum number of entities\n\tint maxclients;\t\t\t\t\t\t\t//maximum number of clients\n\tfloat time;\t\t\t\t\t\t\t\t//the global time\n#ifdef DEBUG\n\tqboolean debug;\t\t\t\t\t\t\t//true if debug is on\n\tint goalareanum;\n\tvec3_t goalorigin;\n\tint runai;\n#endif\n} botlib_globals_t;\n\n\nextern botlib_globals_t botlibglobals;\nextern botlib_import_t botimport;\nextern int bot_developer;\t\t\t\t\t//true if developer is on\n\n//\nint Sys_MilliSeconds(void);\n\n"
  },
  {
    "path": "code/botlib/botlib.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<VisualStudioProject\n\tProjectType=\"Visual C++\"\n\tVersion=\"7.10\"\n\tName=\"botlib\"\n\tSccProjectName=\"&quot;$/MissionPack/code/botlib&quot;, HBAAAAAA\"\n\tSccLocalPath=\".\">\n\t<Platforms>\n\t\t<Platform\n\t\t\tName=\"Win32\"/>\n\t</Platforms>\n\t<Configurations>\n\t\t<Configuration\n\t\t\tName=\"Debug TA|Win32\"\n\t\t\tOutputDirectory=\".\\Debug_TA\"\n\t\t\tIntermediateDirectory=\".\\Debug_TA\"\n\t\t\tConfigurationType=\"4\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tOptimizeForProcessor=\"1\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_LIB;BOTLIB;DEBUG\"\n\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Debug_TA/botlib.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug_TA/\"\n\t\t\t\tObjectFile=\".\\Debug_TA/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Debug_TA/\"\n\t\t\t\tBrowseInformation=\"1\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLibrarianTool\"\n\t\t\t\tOutputFile=\".\\Debug_TA\\botlib.lib\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Release|Win32\"\n\t\t\tOutputDirectory=\".\\Release\"\n\t\t\tIntermediateDirectory=\".\\Release\"\n\t\t\tConfigurationType=\"4\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tOptimizeForProcessor=\"2\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_LIB;BOTLIB\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"4\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release/botlib.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release/\"\n\t\t\t\tObjectFile=\".\\Release/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release/\"\n\t\t\t\tWarningLevel=\"4\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLibrarianTool\"\n\t\t\t\tOutputFile=\".\\Release\\botlib.lib\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"vector|Win32\"\n\t\t\tOutputDirectory=\".\\botlib___Win32_vector0\"\n\t\t\tIntermediateDirectory=\".\\botlib___Win32_vector0\"\n\t\t\tConfigurationType=\"4\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tAdditionalOptions=\"/vec /vec:stats /vec:pii /vec:o10 /vec:yes \"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tOptimizeForProcessor=\"2\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_LIB;BOTLIB\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"4\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\botlib___Win32_vector0/botlib.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\botlib___Win32_vector0/\"\n\t\t\t\tObjectFile=\".\\botlib___Win32_vector0/\"\n\t\t\t\tProgramDataBaseFileName=\".\\botlib___Win32_vector0/\"\n\t\t\t\tWarningLevel=\"4\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLibrarianTool\"\n\t\t\t\tOutputFile=\".\\botlib___Win32_vector0\\botlib.lib\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Debug|Win32\"\n\t\t\tOutputDirectory=\".\\Debug\"\n\t\t\tIntermediateDirectory=\".\\Debug\"\n\t\t\tConfigurationType=\"4\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tOptimizeForProcessor=\"1\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_LIB;BOTLIB;DEBUG\"\n\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Debug/botlib.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug/\"\n\t\t\t\tObjectFile=\".\\Debug/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Debug/\"\n\t\t\t\tBrowseInformation=\"1\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLibrarianTool\"\n\t\t\t\tOutputFile=\".\\Debug\\botlib.lib\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Release TA|Win32\"\n\t\t\tOutputDirectory=\".\\Release_TA\"\n\t\t\tIntermediateDirectory=\".\\Release_TA\"\n\t\t\tConfigurationType=\"4\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tOptimizeForProcessor=\"2\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_LIB;BOTLIB\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"4\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release_TA/botlib.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release_TA/\"\n\t\t\t\tObjectFile=\".\\Release_TA/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release_TA/\"\n\t\t\t\tWarningLevel=\"4\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLibrarianTool\"\n\t\t\t\tOutputFile=\".\\Release_TA\\botlib.lib\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t</Configurations>\n\t<References>\n\t</References>\n\t<Files>\n\t\t<Filter\n\t\t\tName=\"Source Files\"\n\t\t\tFilter=\"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_bspq3.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_cluster.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_debug.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_entity.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_file.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_main.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_move.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_optimize.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_reach.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_route.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_routealt.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_sample.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_ai_char.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_ai_chat.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_ai_gen.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_ai_goal.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_ai_move.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_ai_weap.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_ai_weight.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_ea.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_interface.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_crc.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_libvar.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_log.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_memory.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_precomp.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_script.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_struct.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Header Files\"\n\t\t\tFilter=\"h;hpp;hxx;hm;inl\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"aasfile.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_bsp.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_cluster.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_debug.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_def.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_entity.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_file.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_funcs.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_main.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_move.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_optimize.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_reach.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_route.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_routealt.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_sample.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_ai_weight.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_interface.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\bg_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\qcommon\\cm_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\g_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_crc.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_libvar.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_log.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_memory.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_precomp.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_script.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_struct.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_utils.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\q_shared.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\qcommon\\qcommon.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\qcommon\\qfiles.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\server\\server.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\surfaceflags.h\">\n\t\t\t</File>\n\t\t</Filter>\n\t</Files>\n\t<Globals>\n\t</Globals>\n</VisualStudioProject>\n"
  },
  {
    "path": "code/botlib/l_crc.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tl_crc.c\n *\n * desc:\t\tCRC calculation\n *\n * $Archive: /MissionPack/CODE/botlib/l_crc.c $\n *\n *****************************************************************************/\n\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n\n#include \"../game/q_shared.h\"\n#include \"../game/botlib.h\"\n#include \"be_interface.h\"\t\t\t//for botimport.Print\n\n\n// FIXME: byte swap?\n\n// this is a 16 bit, non-reflected CRC using the polynomial 0x1021\n// and the initial and final xor values shown below...  in other words, the\n// CCITT standard CRC used by XMODEM\n\n#define CRC_INIT_VALUE\t0xffff\n#define CRC_XOR_VALUE\t0x0000\n\nunsigned short crctable[257] =\n{\n\t0x0000,\t0x1021,\t0x2042,\t0x3063,\t0x4084,\t0x50a5,\t0x60c6,\t0x70e7,\n\t0x8108,\t0x9129,\t0xa14a,\t0xb16b,\t0xc18c,\t0xd1ad,\t0xe1ce,\t0xf1ef,\n\t0x1231,\t0x0210,\t0x3273,\t0x2252,\t0x52b5,\t0x4294,\t0x72f7,\t0x62d6,\n\t0x9339,\t0x8318,\t0xb37b,\t0xa35a,\t0xd3bd,\t0xc39c,\t0xf3ff,\t0xe3de,\n\t0x2462,\t0x3443,\t0x0420,\t0x1401,\t0x64e6,\t0x74c7,\t0x44a4,\t0x5485,\n\t0xa56a,\t0xb54b,\t0x8528,\t0x9509,\t0xe5ee,\t0xf5cf,\t0xc5ac,\t0xd58d,\n\t0x3653,\t0x2672,\t0x1611,\t0x0630,\t0x76d7,\t0x66f6,\t0x5695,\t0x46b4,\n\t0xb75b,\t0xa77a,\t0x9719,\t0x8738,\t0xf7df,\t0xe7fe,\t0xd79d,\t0xc7bc,\n\t0x48c4,\t0x58e5,\t0x6886,\t0x78a7,\t0x0840,\t0x1861,\t0x2802,\t0x3823,\n\t0xc9cc,\t0xd9ed,\t0xe98e,\t0xf9af,\t0x8948,\t0x9969,\t0xa90a,\t0xb92b,\n\t0x5af5,\t0x4ad4,\t0x7ab7,\t0x6a96,\t0x1a71,\t0x0a50,\t0x3a33,\t0x2a12,\n\t0xdbfd,\t0xcbdc,\t0xfbbf,\t0xeb9e,\t0x9b79,\t0x8b58,\t0xbb3b,\t0xab1a,\n\t0x6ca6,\t0x7c87,\t0x4ce4,\t0x5cc5,\t0x2c22,\t0x3c03,\t0x0c60,\t0x1c41,\n\t0xedae,\t0xfd8f,\t0xcdec,\t0xddcd,\t0xad2a,\t0xbd0b,\t0x8d68,\t0x9d49,\n\t0x7e97,\t0x6eb6,\t0x5ed5,\t0x4ef4,\t0x3e13,\t0x2e32,\t0x1e51,\t0x0e70,\n\t0xff9f,\t0xefbe,\t0xdfdd,\t0xcffc,\t0xbf1b,\t0xaf3a,\t0x9f59,\t0x8f78,\n\t0x9188,\t0x81a9,\t0xb1ca,\t0xa1eb,\t0xd10c,\t0xc12d,\t0xf14e,\t0xe16f,\n\t0x1080,\t0x00a1,\t0x30c2,\t0x20e3,\t0x5004,\t0x4025,\t0x7046,\t0x6067,\n\t0x83b9,\t0x9398,\t0xa3fb,\t0xb3da,\t0xc33d,\t0xd31c,\t0xe37f,\t0xf35e,\n\t0x02b1,\t0x1290,\t0x22f3,\t0x32d2,\t0x4235,\t0x5214,\t0x6277,\t0x7256,\n\t0xb5ea,\t0xa5cb,\t0x95a8,\t0x8589,\t0xf56e,\t0xe54f,\t0xd52c,\t0xc50d,\n\t0x34e2,\t0x24c3,\t0x14a0,\t0x0481,\t0x7466,\t0x6447,\t0x5424,\t0x4405,\n\t0xa7db,\t0xb7fa,\t0x8799,\t0x97b8,\t0xe75f,\t0xf77e,\t0xc71d,\t0xd73c,\n\t0x26d3,\t0x36f2,\t0x0691,\t0x16b0,\t0x6657,\t0x7676,\t0x4615,\t0x5634,\n\t0xd94c,\t0xc96d,\t0xf90e,\t0xe92f,\t0x99c8,\t0x89e9,\t0xb98a,\t0xa9ab,\n\t0x5844,\t0x4865,\t0x7806,\t0x6827,\t0x18c0,\t0x08e1,\t0x3882,\t0x28a3,\n\t0xcb7d,\t0xdb5c,\t0xeb3f,\t0xfb1e,\t0x8bf9,\t0x9bd8,\t0xabbb,\t0xbb9a,\n\t0x4a75,\t0x5a54,\t0x6a37,\t0x7a16,\t0x0af1,\t0x1ad0,\t0x2ab3,\t0x3a92,\n\t0xfd2e,\t0xed0f,\t0xdd6c,\t0xcd4d,\t0xbdaa,\t0xad8b,\t0x9de8,\t0x8dc9,\n\t0x7c26,\t0x6c07,\t0x5c64,\t0x4c45,\t0x3ca2,\t0x2c83,\t0x1ce0,\t0x0cc1,\n\t0xef1f,\t0xff3e,\t0xcf5d,\t0xdf7c,\t0xaf9b,\t0xbfba,\t0x8fd9,\t0x9ff8,\n\t0x6e17,\t0x7e36,\t0x4e55,\t0x5e74,\t0x2e93,\t0x3eb2,\t0x0ed1,\t0x1ef0\n};\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid CRC_Init(unsigned short *crcvalue)\n{\n\t*crcvalue = CRC_INIT_VALUE;\n} //end of the function CRC_Init\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid CRC_ProcessByte(unsigned short *crcvalue, byte data)\n{\n\t*crcvalue = (*crcvalue << 8) ^ crctable[(*crcvalue >> 8) ^ data];\n} //end of the function CRC_ProcessByte\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nunsigned short CRC_Value(unsigned short crcvalue)\n{\n\treturn crcvalue ^ CRC_XOR_VALUE;\n} //end of the function CRC_Value\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nunsigned short CRC_ProcessString(unsigned char *data, int length)\n{\n\tunsigned short crcvalue;\n\tint i, ind;\n\n\tCRC_Init(&crcvalue);\n\n\tfor (i = 0; i < length; i++)\n\t{\n\t\tind = (crcvalue >> 8) ^ data[i];\n\t\tif (ind < 0 || ind > 256) ind = 0;\n\t\tcrcvalue = (crcvalue << 8) ^ crctable[ind];\n\t} //end for\n\treturn CRC_Value(crcvalue);\n} //end of the function CRC_ProcessString\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid CRC_ContinueProcessString(unsigned short *crc, char *data, int length)\n{\n\tint i;\n\n\tfor (i = 0; i < length; i++)\n\t{\n\t\t*crc = (*crc << 8) ^ crctable[(*crc >> 8) ^ data[i]];\n\t} //end for\n} //end of the function CRC_ProcessString\n"
  },
  {
    "path": "code/botlib/l_crc.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\ntypedef unsigned short crc_t;\n\nvoid CRC_Init(unsigned short *crcvalue);\nvoid CRC_ProcessByte(unsigned short *crcvalue, byte data);\nunsigned short CRC_Value(unsigned short crcvalue);\nunsigned short CRC_ProcessString(unsigned char *data, int length);\nvoid CRC_ContinueProcessString(unsigned short *crc, char *data, int length);\n"
  },
  {
    "path": "code/botlib/l_libvar.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tl_libvar.c\n *\n * desc:\t\tbot library variables\n *\n * $Archive: /MissionPack/code/botlib/l_libvar.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"l_memory.h\"\n#include \"l_libvar.h\"\n\n//list with library variables\nlibvar_t *libvarlist;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat LibVarStringValue(char *string)\n{\n\tint dotfound = 0;\n\tfloat value = 0;\n\n\twhile(*string)\n\t{\n\t\tif (*string < '0' || *string > '9')\n\t\t{\n\t\t\tif (dotfound || *string != '.')\n\t\t\t{\n\t\t\t\treturn 0;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tdotfound = 10;\n\t\t\t\tstring++;\n\t\t\t} //end if\n\t\t} //end if\n\t\tif (dotfound)\n\t\t{\n\t\t\tvalue = value + (float) (*string - '0') / (float) dotfound;\n\t\t\tdotfound *= 10;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tvalue = value * 10.0 + (float) (*string - '0');\n\t\t} //end else\n\t\tstring++;\n\t} //end while\n\treturn value;\n} //end of the function LibVarStringValue\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nlibvar_t *LibVarAlloc(char *var_name)\n{\n\tlibvar_t *v;\n\n\tv = (libvar_t *) GetMemory(sizeof(libvar_t) + strlen(var_name) + 1);\n\tCom_Memset(v, 0, sizeof(libvar_t));\n\tv->name = (char *) v + sizeof(libvar_t);\n\tstrcpy(v->name, var_name);\n\t//add the variable in the list\n\tv->next = libvarlist;\n\tlibvarlist = v;\n\treturn v;\n} //end of the function LibVarAlloc\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid LibVarDeAlloc(libvar_t *v)\n{\n\tif (v->string) FreeMemory(v->string);\n\tFreeMemory(v);\n} //end of the function LibVarDeAlloc\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid LibVarDeAllocAll(void)\n{\n\tlibvar_t *v;\n\n\tfor (v = libvarlist; v; v = libvarlist)\n\t{\n\t\tlibvarlist = libvarlist->next;\n\t\tLibVarDeAlloc(v);\n\t} //end for\n\tlibvarlist = NULL;\n} //end of the function LibVarDeAllocAll\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nlibvar_t *LibVarGet(char *var_name)\n{\n\tlibvar_t *v;\n\n\tfor (v = libvarlist; v; v = v->next)\n\t{\n\t\tif (!Q_stricmp(v->name, var_name))\n\t\t{\n\t\t\treturn v;\n\t\t} //end if\n\t} //end for\n\treturn NULL;\n} //end of the function LibVarGet\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nchar *LibVarGetString(char *var_name)\n{\n\tlibvar_t *v;\n\n\tv = LibVarGet(var_name);\n\tif (v)\n\t{\n\t\treturn v->string;\n\t} //end if\n\telse\n\t{\n\t\treturn \"\";\n\t} //end else\n} //end of the function LibVarGetString\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat LibVarGetValue(char *var_name)\n{\n\tlibvar_t *v;\n\n\tv = LibVarGet(var_name);\n\tif (v)\n\t{\n\t\treturn v->value;\n\t} //end if\n\telse\n\t{\n\t\treturn 0;\n\t} //end else\n} //end of the function LibVarGetValue\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nlibvar_t *LibVar(char *var_name, char *value)\n{\n\tlibvar_t *v;\n\tv = LibVarGet(var_name);\n\tif (v) return v;\n\t//create new variable\n\tv = LibVarAlloc(var_name);\n\t//variable string\n\tv->string = (char *) GetMemory(strlen(value) + 1);\n\tstrcpy(v->string, value);\n\t//the value\n\tv->value = LibVarStringValue(v->string);\n\t//variable is modified\n\tv->modified = qtrue;\n\t//\n\treturn v;\n} //end of the function LibVar\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nchar *LibVarString(char *var_name, char *value)\n{\n\tlibvar_t *v;\n\n\tv = LibVar(var_name, value);\n\treturn v->string;\n} //end of the function LibVarString\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat LibVarValue(char *var_name, char *value)\n{\n\tlibvar_t *v;\n\n\tv = LibVar(var_name, value);\n\treturn v->value;\n} //end of the function LibVarValue\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid LibVarSet(char *var_name, char *value)\n{\n\tlibvar_t *v;\n\n\tv = LibVarGet(var_name);\n\tif (v)\n\t{\n\t\tFreeMemory(v->string);\n\t} //end if\n\telse\n\t{\n\t\tv = LibVarAlloc(var_name);\n\t} //end else\n\t//variable string\n\tv->string = (char *) GetMemory(strlen(value) + 1);\n\tstrcpy(v->string, value);\n\t//the value\n\tv->value = LibVarStringValue(v->string);\n\t//variable is modified\n\tv->modified = qtrue;\n} //end of the function LibVarSet\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean LibVarChanged(char *var_name)\n{\n\tlibvar_t *v;\n\n\tv = LibVarGet(var_name);\n\tif (v)\n\t{\n\t\treturn v->modified;\n\t} //end if\n\telse\n\t{\n\t\treturn qfalse;\n\t} //end else\n} //end of the function LibVarChanged\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid LibVarSetNotModified(char *var_name)\n{\n\tlibvar_t *v;\n\n\tv = LibVarGet(var_name);\n\tif (v)\n\t{\n\t\tv->modified = qfalse;\n\t} //end if\n} //end of the function LibVarSetNotModified\n"
  },
  {
    "path": "code/botlib/l_libvar.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tl_libvar.h\n *\n * desc:\t\tbotlib vars\n *\n * $Archive: /source/code/botlib/l_libvar.h $\n *\n *****************************************************************************/\n\n//library variable\ntypedef struct libvar_s\n{\n\tchar\t\t*name;\n\tchar\t\t*string;\n\tint\t\tflags;\n\tqboolean\tmodified;\t// set each time the cvar is changed\n\tfloat\t\tvalue;\n\tstruct\tlibvar_s *next;\n} libvar_t;\n\n//removes all library variables\nvoid LibVarDeAllocAll(void);\n//gets the library variable with the given name\nlibvar_t *LibVarGet(char *var_name);\n//gets the string of the library variable with the given name\nchar *LibVarGetString(char *var_name);\n//gets the value of the library variable with the given name\nfloat LibVarGetValue(char *var_name);\n//creates the library variable if not existing already and returns it\nlibvar_t *LibVar(char *var_name, char *value);\n//creates the library variable if not existing already and returns the value\nfloat LibVarValue(char *var_name, char *value);\n//creates the library variable if not existing already and returns the value string\nchar *LibVarString(char *var_name, char *value);\n//sets the library variable\nvoid LibVarSet(char *var_name, char *value);\n//returns true if the library variable has been modified\nqboolean LibVarChanged(char *var_name);\n//sets the library variable to unmodified\nvoid LibVarSetNotModified(char *var_name);\n\n"
  },
  {
    "path": "code/botlib/l_log.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tl_log.c\n *\n * desc:\t\tlog file\n *\n * $Archive: /MissionPack/CODE/botlib/l_log.c $\n *\n *****************************************************************************/\n\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n\n#include \"../game/q_shared.h\"\n#include \"../game/botlib.h\"\n#include \"be_interface.h\"\t\t\t//for botimport.Print\n#include \"l_libvar.h\"\n\n#define MAX_LOGFILENAMESIZE\t\t1024\n\ntypedef struct logfile_s\n{\n\tchar filename[MAX_LOGFILENAMESIZE];\n\tFILE *fp;\n\tint numwrites;\n} logfile_t;\n\nstatic logfile_t logfile;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Log_Open(char *filename)\n{\n\tif (!LibVarValue(\"log\", \"0\")) return;\n\tif (!filename || !strlen(filename))\n\t{\n\t\tbotimport.Print(PRT_MESSAGE, \"openlog <filename>\\n\");\n\t\treturn;\n\t} //end if\n\tif (logfile.fp)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"log file %s is already opened\\n\", logfile.filename);\n\t\treturn;\n\t} //end if\n\tlogfile.fp = fopen(filename, \"wb\");\n\tif (!logfile.fp)\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"can't open the log file %s\\n\", filename);\n\t\treturn;\n\t} //end if\n\tstrncpy(logfile.filename, filename, MAX_LOGFILENAMESIZE);\n\tbotimport.Print(PRT_MESSAGE, \"Opened log %s\\n\", logfile.filename);\n} //end of the function Log_Create\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Log_Close(void)\n{\n\tif (!logfile.fp) return;\n\tif (fclose(logfile.fp))\n\t{\n\t\tbotimport.Print(PRT_ERROR, \"can't close log file %s\\n\", logfile.filename);\n\t\treturn;\n\t} //end if\n\tlogfile.fp = NULL;\n\tbotimport.Print(PRT_MESSAGE, \"Closed log %s\\n\", logfile.filename);\n} //end of the function Log_Close\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Log_Shutdown(void)\n{\n\tif (logfile.fp) Log_Close();\n} //end of the function Log_Shutdown\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid QDECL Log_Write(char *fmt, ...)\n{\n\tva_list ap;\n\n\tif (!logfile.fp) return;\n\tva_start(ap, fmt);\n\tvfprintf(logfile.fp, fmt, ap);\n\tva_end(ap);\n\t//fprintf(logfile.fp, \"\\r\\n\");\n\tfflush(logfile.fp);\n} //end of the function Log_Write\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid QDECL Log_WriteTimeStamped(char *fmt, ...)\n{\n\tva_list ap;\n\n\tif (!logfile.fp) return;\n\tfprintf(logfile.fp, \"%d   %02d:%02d:%02d:%02d   \",\n\t\t\t\t\tlogfile.numwrites,\n\t\t\t\t\t(int) (botlibglobals.time / 60 / 60),\n\t\t\t\t\t(int) (botlibglobals.time / 60),\n\t\t\t\t\t(int) (botlibglobals.time),\n\t\t\t\t\t(int) ((int) (botlibglobals.time * 100)) -\n\t\t\t\t\t\t\t((int) botlibglobals.time) * 100);\n\tva_start(ap, fmt);\n\tvfprintf(logfile.fp, fmt, ap);\n\tva_end(ap);\n\tfprintf(logfile.fp, \"\\r\\n\");\n\tlogfile.numwrites++;\n\tfflush(logfile.fp);\n} //end of the function Log_Write\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nFILE *Log_FilePointer(void)\n{\n\treturn logfile.fp;\n} //end of the function Log_FilePointer\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Log_Flush(void)\n{\n\tif (logfile.fp) fflush(logfile.fp);\n} //end of the function Log_Flush\n\n"
  },
  {
    "path": "code/botlib/l_log.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tl_log.h\n *\n * desc:\t\tlog file\n *\n * $Archive: /source/code/botlib/l_log.h $\n *\n *****************************************************************************/\n\n//open a log file\nvoid Log_Open(char *filename);\n//close the current log file\nvoid Log_Close(void);\n//close log file if present\nvoid Log_Shutdown(void);\n//write to the current opened log file\nvoid QDECL Log_Write(char *fmt, ...);\n//write to the current opened log file with a time stamp\nvoid QDECL Log_WriteTimeStamped(char *fmt, ...);\n//returns a pointer to the log file\nFILE *Log_FilePointer(void);\n//flush log file\nvoid Log_Flush(void);\n\n"
  },
  {
    "path": "code/botlib/l_memory.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tl_memory.c\n *\n * desc:\t\tmemory allocation\n *\n * $Archive: /MissionPack/code/botlib/l_memory.c $\n *\n *****************************************************************************/\n\n#include \"../game/q_shared.h\"\n#include \"../game/botlib.h\"\n#include \"l_log.h\"\n#include \"be_interface.h\"\n\n//#define MEMDEBUG\n//#define MEMORYMANEGER\n\n#define MEM_ID\t\t0x12345678l\n#define HUNK_ID\t\t0x87654321l\n\nint allocatedmemory;\nint totalmemorysize;\nint numblocks;\n\n#ifdef MEMORYMANEGER\n\ntypedef struct memoryblock_s\n{\n\tunsigned long int id;\n\tvoid *ptr;\n\tint size;\n#ifdef MEMDEBUG\n\tchar *label;\n\tchar *file;\n\tint line;\n#endif //MEMDEBUG\n\tstruct memoryblock_s *prev, *next;\n} memoryblock_t;\n\nmemoryblock_t *memory;\n\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid LinkMemoryBlock(memoryblock_t *block)\n{\n\tblock->prev = NULL;\n\tblock->next = memory;\n\tif (memory) memory->prev = block;\n\tmemory = block;\n} //end of the function LinkMemoryBlock\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid UnlinkMemoryBlock(memoryblock_t *block)\n{\n\tif (block->prev) block->prev->next = block->next;\n\telse memory = block->next;\n\tif (block->next) block->next->prev = block->prev;\n} //end of the function UnlinkMemoryBlock\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#ifdef MEMDEBUG\nvoid *GetMemoryDebug(unsigned long size, char *label, char *file, int line)\n#else\nvoid *GetMemory(unsigned long size)\n#endif //MEMDEBUG\n{\n\tvoid *ptr;\n\tmemoryblock_t *block;\n  assert(botimport.GetMemory); // bk001129 - was NULL'ed\n\tptr = botimport.GetMemory(size + sizeof(memoryblock_t));\n\tblock = (memoryblock_t *) ptr;\n\tblock->id = MEM_ID;\n\tblock->ptr = (char *) ptr + sizeof(memoryblock_t);\n\tblock->size = size + sizeof(memoryblock_t);\n#ifdef MEMDEBUG\n\tblock->label = label;\n\tblock->file = file;\n\tblock->line = line;\n#endif //MEMDEBUG\n\tLinkMemoryBlock(block);\n\tallocatedmemory += block->size;\n\ttotalmemorysize += block->size + sizeof(memoryblock_t);\n\tnumblocks++;\n\treturn block->ptr;\n} //end of the function GetMemoryDebug\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#ifdef MEMDEBUG\nvoid *GetClearedMemoryDebug(unsigned long size, char *label, char *file, int line)\n#else\nvoid *GetClearedMemory(unsigned long size)\n#endif //MEMDEBUG\n{\n\tvoid *ptr;\n#ifdef MEMDEBUG\n\tptr = GetMemoryDebug(size, label, file, line);\n#else\n\tptr = GetMemory(size);\n#endif //MEMDEBUG\n\tCom_Memset(ptr, 0, size);\n\treturn ptr;\n} //end of the function GetClearedMemory\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#ifdef MEMDEBUG\nvoid *GetHunkMemoryDebug(unsigned long size, char *label, char *file, int line)\n#else\nvoid *GetHunkMemory(unsigned long size)\n#endif //MEMDEBUG\n{\n\tvoid *ptr;\n\tmemoryblock_t *block;\n\n\tptr = botimport.HunkAlloc(size + sizeof(memoryblock_t));\n\tblock = (memoryblock_t *) ptr;\n\tblock->id = HUNK_ID;\n\tblock->ptr = (char *) ptr + sizeof(memoryblock_t);\n\tblock->size = size + sizeof(memoryblock_t);\n#ifdef MEMDEBUG\n\tblock->label = label;\n\tblock->file = file;\n\tblock->line = line;\n#endif //MEMDEBUG\n\tLinkMemoryBlock(block);\n\tallocatedmemory += block->size;\n\ttotalmemorysize += block->size + sizeof(memoryblock_t);\n\tnumblocks++;\n\treturn block->ptr;\n} //end of the function GetHunkMemoryDebug\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#ifdef MEMDEBUG\nvoid *GetClearedHunkMemoryDebug(unsigned long size, char *label, char *file, int line)\n#else\nvoid *GetClearedHunkMemory(unsigned long size)\n#endif //MEMDEBUG\n{\n\tvoid *ptr;\n#ifdef MEMDEBUG\n\tptr = GetHunkMemoryDebug(size, label, file, line);\n#else\n\tptr = GetHunkMemory(size);\n#endif //MEMDEBUG\n\tCom_Memset(ptr, 0, size);\n\treturn ptr;\n} //end of the function GetClearedHunkMemory\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nmemoryblock_t *BlockFromPointer(void *ptr, char *str)\n{\n\tmemoryblock_t *block;\n\n\tif (!ptr)\n\t{\n#ifdef MEMDEBUG\n\t\t//char *crash = (char *) NULL;\n\t\t//crash[0] = 1;\n\t\tbotimport.Print(PRT_FATAL, \"%s: NULL pointer\\n\", str);\n#endif // MEMDEBUG\n\t\treturn NULL;\n\t} //end if\n\tblock = (memoryblock_t *) ((char *) ptr - sizeof(memoryblock_t));\n\tif (block->id != MEM_ID && block->id != HUNK_ID)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"%s: invalid memory block\\n\", str);\n\t\treturn NULL;\n\t} //end if\n\tif (block->ptr != ptr)\n\t{\n\t\tbotimport.Print(PRT_FATAL, \"%s: memory block pointer invalid\\n\", str);\n\t\treturn NULL;\n\t} //end if\n\treturn block;\n} //end of the function BlockFromPointer\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid FreeMemory(void *ptr)\n{\n\tmemoryblock_t *block;\n\n\tblock = BlockFromPointer(ptr, \"FreeMemory\");\n\tif (!block) return;\n\tUnlinkMemoryBlock(block);\n\tallocatedmemory -= block->size;\n\ttotalmemorysize -= block->size + sizeof(memoryblock_t);\n\tnumblocks--;\n\t//\n\tif (block->id == MEM_ID)\n\t{\n\t\tbotimport.FreeMemory(block);\n\t} //end if\n} //end of the function FreeMemory\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AvailableMemory(void)\n{\n\treturn botimport.AvailableMemory();\n} //end of the function AvailableMemory\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint MemoryByteSize(void *ptr)\n{\n\tmemoryblock_t *block;\n\n\tblock = BlockFromPointer(ptr, \"MemoryByteSize\");\n\tif (!block) return 0;\n\treturn block->size;\n} //end of the function MemoryByteSize\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid PrintUsedMemorySize(void)\n{\n\tbotimport.Print(PRT_MESSAGE, \"total allocated memory: %d KB\\n\", allocatedmemory >> 10);\n\tbotimport.Print(PRT_MESSAGE, \"total botlib memory: %d KB\\n\", totalmemorysize >> 10);\n\tbotimport.Print(PRT_MESSAGE, \"total memory blocks: %d\\n\", numblocks);\n} //end of the function PrintUsedMemorySize\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid PrintMemoryLabels(void)\n{\n\tmemoryblock_t *block;\n\tint i;\n\n\tPrintUsedMemorySize();\n\ti = 0;\n\tLog_Write(\"============= Botlib memory log ==============\\r\\n\");\n\tLog_Write(\"\\r\\n\");\n\tfor (block = memory; block; block = block->next)\n\t{\n#ifdef MEMDEBUG\n\t\tif (block->id == HUNK_ID)\n\t\t{\n\t\t\tLog_Write(\"%6d, hunk %p, %8d: %24s line %6d: %s\\r\\n\", i, block->ptr, block->size, block->file, block->line, block->label);\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tLog_Write(\"%6d,      %p, %8d: %24s line %6d: %s\\r\\n\", i, block->ptr, block->size, block->file, block->line, block->label);\n\t\t} //end else\n#endif //MEMDEBUG\n\t\ti++;\n\t} //end for\n} //end of the function PrintMemoryLabels\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid DumpMemory(void)\n{\n\tmemoryblock_t *block;\n\n\tfor (block = memory; block; block = memory)\n\t{\n\t\tFreeMemory(block->ptr);\n\t} //end for\n\ttotalmemorysize = 0;\n\tallocatedmemory = 0;\n} //end of the function DumpMemory\n\n#else\n\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#ifdef MEMDEBUG\nvoid *GetMemoryDebug(unsigned long size, char *label, char *file, int line)\n#else\nvoid *GetMemory(unsigned long size)\n#endif //MEMDEBUG\n{\n\tvoid *ptr;\n\tunsigned long int *memid;\n\n\tptr = botimport.GetMemory(size + sizeof(unsigned long int));\n\tif (!ptr) return NULL;\n\tmemid = (unsigned long int *) ptr;\n\t*memid = MEM_ID;\n\treturn (unsigned long int *) ((char *) ptr + sizeof(unsigned long int));\n} //end of the function GetMemory\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#ifdef MEMDEBUG\nvoid *GetClearedMemoryDebug(unsigned long size, char *label, char *file, int line)\n#else\nvoid *GetClearedMemory(unsigned long size)\n#endif //MEMDEBUG\n{\n\tvoid *ptr;\n#ifdef MEMDEBUG\n\tptr = GetMemoryDebug(size, label, file, line);\n#else\n\tptr = GetMemory(size);\n#endif //MEMDEBUG\n\tCom_Memset(ptr, 0, size);\n\treturn ptr;\n} //end of the function GetClearedMemory\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#ifdef MEMDEBUG\nvoid *GetHunkMemoryDebug(unsigned long size, char *label, char *file, int line)\n#else\nvoid *GetHunkMemory(unsigned long size)\n#endif //MEMDEBUG\n{\n\tvoid *ptr;\n\tunsigned long int *memid;\n\n\tptr = botimport.HunkAlloc(size + sizeof(unsigned long int));\n\tif (!ptr) return NULL;\n\tmemid = (unsigned long int *) ptr;\n\t*memid = HUNK_ID;\n\treturn (unsigned long int *) ((char *) ptr + sizeof(unsigned long int));\n} //end of the function GetHunkMemory\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#ifdef MEMDEBUG\nvoid *GetClearedHunkMemoryDebug(unsigned long size, char *label, char *file, int line)\n#else\nvoid *GetClearedHunkMemory(unsigned long size)\n#endif //MEMDEBUG\n{\n\tvoid *ptr;\n#ifdef MEMDEBUG\n\tptr = GetHunkMemoryDebug(size, label, file, line);\n#else\n\tptr = GetHunkMemory(size);\n#endif //MEMDEBUG\n\tCom_Memset(ptr, 0, size);\n\treturn ptr;\n} //end of the function GetClearedHunkMemory\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid FreeMemory(void *ptr)\n{\n\tunsigned long int *memid;\n\n\tmemid = (unsigned long int *) ((char *) ptr - sizeof(unsigned long int));\n\n\tif (*memid == MEM_ID)\n\t{\n\t\tbotimport.FreeMemory(memid);\n\t} //end if\n} //end of the function FreeMemory\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AvailableMemory(void)\n{\n\treturn botimport.AvailableMemory();\n} //end of the function AvailableMemory\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid PrintUsedMemorySize(void)\n{\n} //end of the function PrintUsedMemorySize\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid PrintMemoryLabels(void)\n{\n} //end of the function PrintMemoryLabels\n\n#endif\n"
  },
  {
    "path": "code/botlib/l_memory.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tl_memory.h\n *\n * desc:\t\tmemory management\n *\n * $Archive: /source/code/botlib/l_memory.h $\n *\n *****************************************************************************/\n\n//#define MEMDEBUG\n\n#ifdef MEMDEBUG\n#define GetMemory(size)\t\t\t\tGetMemoryDebug(size, #size, __FILE__, __LINE__);\n#define GetClearedMemory(size)\t\tGetClearedMemoryDebug(size, #size, __FILE__, __LINE__);\n//allocate a memory block of the given size\nvoid *GetMemoryDebug(unsigned long size, char *label, char *file, int line);\n//allocate a memory block of the given size and clear it\nvoid *GetClearedMemoryDebug(unsigned long size, char *label, char *file, int line);\n//\n#define GetHunkMemory(size)\t\t\tGetHunkMemoryDebug(size, #size, __FILE__, __LINE__);\n#define GetClearedHunkMemory(size)\tGetClearedHunkMemoryDebug(size, #size, __FILE__, __LINE__);\n//allocate a memory block of the given size\nvoid *GetHunkMemoryDebug(unsigned long size, char *label, char *file, int line);\n//allocate a memory block of the given size and clear it\nvoid *GetClearedHunkMemoryDebug(unsigned long size, char *label, char *file, int line);\n#else\n//allocate a memory block of the given size\nvoid *GetMemory(unsigned long size);\n//allocate a memory block of the given size and clear it\nvoid *GetClearedMemory(unsigned long size);\n//\n#ifdef BSPC\n#define GetHunkMemory GetMemory\n#define GetClearedHunkMemory GetClearedMemory\n#else\n//allocate a memory block of the given size\nvoid *GetHunkMemory(unsigned long size);\n//allocate a memory block of the given size and clear it\nvoid *GetClearedHunkMemory(unsigned long size);\n#endif\n#endif\n\n//free the given memory block\nvoid FreeMemory(void *ptr);\n//returns the amount available memory\nint AvailableMemory(void);\n//prints the total used memory size\nvoid PrintUsedMemorySize(void);\n//print all memory blocks with label\nvoid PrintMemoryLabels(void);\n//returns the size of the memory block in bytes\nint MemoryByteSize(void *ptr);\n//free all allocated memory\nvoid DumpMemory(void);\n"
  },
  {
    "path": "code/botlib/l_precomp.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n/*****************************************************************************\n * name:\t\tl_precomp.c\n *\n * desc:\t\tpre compiler\n *\n * $Archive: /MissionPack/code/botlib/l_precomp.c $\n *\n *****************************************************************************/\n\n//Notes:\t\t\tfix: PC_StringizeTokens\n\n//#define SCREWUP\n//#define BOTLIB\n//#define QUAKE\n//#define QUAKEC\n//#define MEQCC\n\n#ifdef SCREWUP\n#include <stdio.h>\n#include <stdlib.h>\n#include <limits.h>\n#include <string.h>\n#include <stdarg.h>\n#include <time.h>\n#include \"l_memory.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n\ntypedef enum {qfalse, qtrue}\tqboolean;\n#endif //SCREWUP\n\n#ifdef BOTLIB\n#include \"../game/q_shared.h\"\n#include \"../game/botlib.h\"\n#include \"be_interface.h\"\n#include \"l_memory.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_log.h\"\n#endif //BOTLIB\n\n#ifdef MEQCC\n#include \"qcc.h\"\n#include \"time.h\"   //time & ctime\n#include \"math.h\"   //fabs\n#include \"l_memory.h\"\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_log.h\"\n\n#define qtrue\ttrue\n#define qfalse\tfalse\n#endif //MEQCC\n\n#ifdef BSPC\n//include files for usage in the BSP Converter\n#include \"../bspc/qbsp.h\"\n#include \"../bspc/l_log.h\"\n#include \"../bspc/l_mem.h\"\n#include \"l_precomp.h\"\n\n#define qtrue\ttrue\n#define qfalse\tfalse\n#define Q_stricmp\tstricmp\n\n#endif //BSPC\n\n#if defined(QUAKE) && !defined(BSPC)\n#include \"l_utils.h\"\n#endif //QUAKE\n\n//#define DEBUG_EVAL\n\n#define MAX_DEFINEPARMS\t\t\t128\n\n#define DEFINEHASHING\t\t\t1\n\n//directive name with parse function\ntypedef struct directive_s\n{\n\tchar *name;\n\tint (*func)(source_t *source);\n} directive_t;\n\n#define DEFINEHASHSIZE\t\t1024\n\n#define TOKEN_HEAP_SIZE\t\t4096\n\nint numtokens;\n/*\nint tokenheapinitialized;\t\t\t\t//true when the token heap is initialized\ntoken_t token_heap[TOKEN_HEAP_SIZE];\t//heap with tokens\ntoken_t *freetokens;\t\t\t\t\t//free tokens from the heap\n*/\n\n//list with global defines added to every source loaded\ndefine_t *globaldefines;\n\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid QDECL SourceError(source_t *source, char *str, ...)\n{\n\tchar text[1024];\n\tva_list ap;\n\n\tva_start(ap, str);\n\tvsprintf(text, str, ap);\n\tva_end(ap);\n#ifdef BOTLIB\n\tbotimport.Print(PRT_ERROR, \"file %s, line %d: %s\\n\", source->scriptstack->filename, source->scriptstack->line, text);\n#endif\t//BOTLIB\n#ifdef MEQCC\n\tprintf(\"error: file %s, line %d: %s\\n\", source->scriptstack->filename, source->scriptstack->line, text);\n#endif //MEQCC\n#ifdef BSPC\n\tLog_Print(\"error: file %s, line %d: %s\\n\", source->scriptstack->filename, source->scriptstack->line, text);\n#endif //BSPC\n} //end of the function SourceError\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid QDECL SourceWarning(source_t *source, char *str, ...)\n{\n\tchar text[1024];\n\tva_list ap;\n\n\tva_start(ap, str);\n\tvsprintf(text, str, ap);\n\tva_end(ap);\n#ifdef BOTLIB\n\tbotimport.Print(PRT_WARNING, \"file %s, line %d: %s\\n\", source->scriptstack->filename, source->scriptstack->line, text);\n#endif //BOTLIB\n#ifdef MEQCC\n\tprintf(\"warning: file %s, line %d: %s\\n\", source->scriptstack->filename, source->scriptstack->line, text);\n#endif //MEQCC\n#ifdef BSPC\n\tLog_Print(\"warning: file %s, line %d: %s\\n\", source->scriptstack->filename, source->scriptstack->line, text);\n#endif //BSPC\n} //end of the function ScriptWarning\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PC_PushIndent(source_t *source, int type, int skip)\n{\n\tindent_t *indent;\n\n\tindent = (indent_t *) GetMemory(sizeof(indent_t));\n\tindent->type = type;\n\tindent->script = source->scriptstack;\n\tindent->skip = (skip != 0);\n\tsource->skip += indent->skip;\n\tindent->next = source->indentstack;\n\tsource->indentstack = indent;\n} //end of the function PC_PushIndent\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PC_PopIndent(source_t *source, int *type, int *skip)\n{\n\tindent_t *indent;\n\n\t*type = 0;\n\t*skip = 0;\n\n\tindent = source->indentstack;\n\tif (!indent) return;\n\n\t//must be an indent from the current script\n\tif (source->indentstack->script != source->scriptstack) return;\n\n\t*type = indent->type;\n\t*skip = indent->skip;\n\tsource->indentstack = source->indentstack->next;\n\tsource->skip -= indent->skip;\n\tFreeMemory(indent);\n} //end of the function PC_PopIndent\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PC_PushScript(source_t *source, script_t *script)\n{\n\tscript_t *s;\n\n\tfor (s = source->scriptstack; s; s = s->next)\n\t{\n\t\tif (!Q_stricmp(s->filename, script->filename))\n\t\t{\n\t\t\tSourceError(source, \"%s recursively included\", script->filename);\n\t\t\treturn;\n\t\t} //end if\n\t} //end for\n\t//push the script on the script stack\n\tscript->next = source->scriptstack;\n\tsource->scriptstack = script;\n} //end of the function PC_PushScript\n//============================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PC_InitTokenHeap(void)\n{\n\t/*\n\tint i;\n\n\tif (tokenheapinitialized) return;\n\tfreetokens = NULL;\n\tfor (i = 0; i < TOKEN_HEAP_SIZE; i++)\n\t{\n\t\ttoken_heap[i].next = freetokens;\n\t\tfreetokens = &token_heap[i];\n\t} //end for\n\ttokenheapinitialized = qtrue;\n\t*/\n} //end of the function PC_InitTokenHeap\n//============================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\ntoken_t *PC_CopyToken(token_t *token)\n{\n\ttoken_t *t;\n\n//\tt = (token_t *) malloc(sizeof(token_t));\n\tt = (token_t *) GetMemory(sizeof(token_t));\n//\tt = freetokens;\n\tif (!t)\n\t{\n#ifdef BSPC\n\t\tError(\"out of token space\\n\");\n#else\n\t\tCom_Error(ERR_FATAL, \"out of token space\\n\");\n#endif\n\t\treturn NULL;\n\t} //end if\n//\tfreetokens = freetokens->next;\n\tCom_Memcpy(t, token, sizeof(token_t));\n\tt->next = NULL;\n\tnumtokens++;\n\treturn t;\n} //end of the function PC_CopyToken\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PC_FreeToken(token_t *token)\n{\n\t//free(token);\n\tFreeMemory(token);\n//\ttoken->next = freetokens;\n//\tfreetokens = token;\n\tnumtokens--;\n} //end of the function PC_FreeToken\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_ReadSourceToken(source_t *source, token_t *token)\n{\n\ttoken_t *t;\n\tscript_t *script;\n\tint type, skip;\n\n\t//if there's no token already available\n\twhile(!source->tokens)\n\t{\n\t\t//if there's a token to read from the script\n\t\tif (PS_ReadToken(source->scriptstack, token)) return qtrue;\n\t\t//if at the end of the script\n\t\tif (EndOfScript(source->scriptstack))\n\t\t{\n\t\t\t//remove all indents of the script\n\t\t\twhile(source->indentstack &&\n\t\t\t\t\tsource->indentstack->script == source->scriptstack)\n\t\t\t{\n\t\t\t\tSourceWarning(source, \"missing #endif\");\n\t\t\t\tPC_PopIndent(source, &type, &skip);\n\t\t\t} //end if\n\t\t} //end if\n\t\t//if this was the initial script\n\t\tif (!source->scriptstack->next) return qfalse;\n\t\t//remove the script and return to the last one\n\t\tscript = source->scriptstack;\n\t\tsource->scriptstack = source->scriptstack->next;\n\t\tFreeScript(script);\n\t} //end while\n\t//copy the already available token\n\tCom_Memcpy(token, source->tokens, sizeof(token_t));\n\t//free the read token\n\tt = source->tokens;\n\tsource->tokens = source->tokens->next;\n\tPC_FreeToken(t);\n\treturn qtrue;\n} //end of the function PC_ReadSourceToken\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_UnreadSourceToken(source_t *source, token_t *token)\n{\n\ttoken_t *t;\n\n\tt = PC_CopyToken(token);\n\tt->next = source->tokens;\n\tsource->tokens = t;\n\treturn qtrue;\n} //end of the function PC_UnreadSourceToken\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_ReadDefineParms(source_t *source, define_t *define, token_t **parms, int maxparms)\n{\n\ttoken_t token, *t, *last;\n\tint i, done, lastcomma, numparms, indent;\n\n\tif (!PC_ReadSourceToken(source, &token))\n\t{\n\t\tSourceError(source, \"define %s missing parms\", define->name);\n\t\treturn qfalse;\n\t} //end if\n\t//\n\tif (define->numparms > maxparms)\n\t{\n\t\tSourceError(source, \"define with more than %d parameters\", maxparms);\n\t\treturn qfalse;\n\t} //end if\n\t//\n\tfor (i = 0; i < define->numparms; i++) parms[i] = NULL;\n\t//if no leading \"(\"\n\tif (strcmp(token.string, \"(\"))\n\t{\n\t\tPC_UnreadSourceToken(source, &token);\n\t\tSourceError(source, \"define %s missing parms\", define->name);\n\t\treturn qfalse;\n\t} //end if\n\t//read the define parameters\n\tfor (done = 0, numparms = 0, indent = 0; !done;)\n\t{\n\t\tif (numparms >= maxparms)\n\t\t{\n\t\t\tSourceError(source, \"define %s with too many parms\", define->name);\n\t\t\treturn qfalse;\n\t\t} //end if\n\t\tif (numparms >= define->numparms)\n\t\t{\n\t\t\tSourceWarning(source, \"define %s has too many parms\", define->name);\n\t\t\treturn qfalse;\n\t\t} //end if\n\t\tparms[numparms] = NULL;\n\t\tlastcomma = 1;\n\t\tlast = NULL;\n\t\twhile(!done)\n\t\t{\n\t\t\t//\n\t\t\tif (!PC_ReadSourceToken(source, &token))\n\t\t\t{\n\t\t\t\tSourceError(source, \"define %s incomplete\", define->name);\n\t\t\t\treturn qfalse;\n\t\t\t} //end if\n\t\t\t//\n\t\t\tif (!strcmp(token.string, \",\"))\n\t\t\t{\n\t\t\t\tif (indent <= 0)\n\t\t\t\t{\n\t\t\t\t\tif (lastcomma) SourceWarning(source, \"too many comma's\");\n\t\t\t\t\tlastcomma = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t\tlastcomma = 0;\n\t\t\t//\n\t\t\tif (!strcmp(token.string, \"(\"))\n\t\t\t{\n\t\t\t\tindent++;\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\telse if (!strcmp(token.string, \")\"))\n\t\t\t{\n\t\t\t\tif (--indent <= 0)\n\t\t\t\t{\n\t\t\t\t\tif (!parms[define->numparms-1])\n\t\t\t\t\t{\n\t\t\t\t\t\tSourceWarning(source, \"too few define parms\");\n\t\t\t\t\t} //end if\n\t\t\t\t\tdone = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t\t//\n\t\t\tif (numparms < define->numparms)\n\t\t\t{\n\t\t\t\t//\n\t\t\t\tt = PC_CopyToken(&token);\n\t\t\t\tt->next = NULL;\n\t\t\t\tif (last) last->next = t;\n\t\t\t\telse parms[numparms] = t;\n\t\t\t\tlast = t;\n\t\t\t} //end if\n\t\t} //end while\n\t\tnumparms++;\n\t} //end for\n\treturn qtrue;\n} //end of the function PC_ReadDefineParms\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_StringizeTokens(token_t *tokens, token_t *token)\n{\n\ttoken_t *t;\n\n\ttoken->type = TT_STRING;\n\ttoken->whitespace_p = NULL;\n\ttoken->endwhitespace_p = NULL;\n\ttoken->string[0] = '\\0';\n\tstrcat(token->string, \"\\\"\");\n\tfor (t = tokens; t; t = t->next)\n\t{\n\t\tstrncat(token->string, t->string, MAX_TOKEN - strlen(token->string));\n\t} //end for\n\tstrncat(token->string, \"\\\"\", MAX_TOKEN - strlen(token->string));\n\treturn qtrue;\n} //end of the function PC_StringizeTokens\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_MergeTokens(token_t *t1, token_t *t2)\n{\n\t//merging of a name with a name or number\n\tif (t1->type == TT_NAME && (t2->type == TT_NAME || t2->type == TT_NUMBER))\n\t{\n\t\tstrcat(t1->string, t2->string);\n\t\treturn qtrue;\n\t} //end if\n\t//merging of two strings\n\tif (t1->type == TT_STRING && t2->type == TT_STRING)\n\t{\n\t\t//remove trailing double quote\n\t\tt1->string[strlen(t1->string)-1] = '\\0';\n\t\t//concat without leading double quote\n\t\tstrcat(t1->string, &t2->string[1]);\n\t\treturn qtrue;\n\t} //end if\n\t//FIXME: merging of two number of the same sub type\n\treturn qfalse;\n} //end of the function PC_MergeTokens\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\n/*\nvoid PC_PrintDefine(define_t *define)\n{\n\tprintf(\"define->name = %s\\n\", define->name);\n\tprintf(\"define->flags = %d\\n\", define->flags);\n\tprintf(\"define->builtin = %d\\n\", define->builtin);\n\tprintf(\"define->numparms = %d\\n\", define->numparms);\n//\ttoken_t *parms;\t\t\t\t\t//define parameters\n//\ttoken_t *tokens;\t\t\t\t\t//macro tokens (possibly containing parm tokens)\n//\tstruct define_s *next;\t\t\t//next defined macro in a list\n} //end of the function PC_PrintDefine*/\n#if DEFINEHASHING\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PC_PrintDefineHashTable(define_t **definehash)\n{\n\tint i;\n\tdefine_t *d;\n\n\tfor (i = 0; i < DEFINEHASHSIZE; i++)\n\t{\n\t\tLog_Write(\"%4d:\", i);\n\t\tfor (d = definehash[i]; d; d = d->hashnext)\n\t\t{\n\t\t\tLog_Write(\" %s\", d->name);\n\t\t} //end for\n\t\tLog_Write(\"\\n\");\n\t} //end for\n} //end of the function PC_PrintDefineHashTable\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\n//char primes[16] = {1, 3, 5, 7, 11, 13, 17, 19, 23, 27, 29, 31, 37, 41, 43, 47};\n\nint PC_NameHash(char *name)\n{\n\tint register hash, i;\n\n\thash = 0;\n\tfor (i = 0; name[i] != '\\0'; i++)\n\t{\n\t\thash += name[i] * (119 + i);\n\t\t//hash += (name[i] << 7) + i;\n\t\t//hash += (name[i] << (i&15));\n\t} //end while\n\thash = (hash ^ (hash >> 10) ^ (hash >> 20)) & (DEFINEHASHSIZE-1);\n\treturn hash;\n} //end of the function PC_NameHash\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PC_AddDefineToHash(define_t *define, define_t **definehash)\n{\n\tint hash;\n\n\thash = PC_NameHash(define->name);\n\tdefine->hashnext = definehash[hash];\n\tdefinehash[hash] = define;\n} //end of the function PC_AddDefineToHash\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\ndefine_t *PC_FindHashedDefine(define_t **definehash, char *name)\n{\n\tdefine_t *d;\n\tint hash;\n\n\thash = PC_NameHash(name);\n\tfor (d = definehash[hash]; d; d = d->hashnext)\n\t{\n\t\tif (!strcmp(d->name, name)) return d;\n\t} //end for\n\treturn NULL;\n} //end of the function PC_FindHashedDefine\n#endif //DEFINEHASHING\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\ndefine_t *PC_FindDefine(define_t *defines, char *name)\n{\n\tdefine_t *d;\n\n\tfor (d = defines; d; d = d->next)\n\t{\n\t\tif (!strcmp(d->name, name)) return d;\n\t} //end for\n\treturn NULL;\n} //end of the function PC_FindDefine\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\tnumber of the parm\n//\t\t\t\t\t\t\t\tif no parm found with the given name -1 is returned\n// Changes Globals:\t\t-\n//============================================================================\nint PC_FindDefineParm(define_t *define, char *name)\n{\n\ttoken_t *p;\n\tint i;\n\n\ti = 0;\n\tfor (p = define->parms; p; p = p->next)\n\t{\n\t\tif (!strcmp(p->string, name)) return i;\n\t\ti++;\n\t} //end for\n\treturn -1;\n} //end of the function PC_FindDefineParm\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PC_FreeDefine(define_t *define)\n{\n\ttoken_t *t, *next;\n\n\t//free the define parameters\n\tfor (t = define->parms; t; t = next)\n\t{\n\t\tnext = t->next;\n\t\tPC_FreeToken(t);\n\t} //end for\n\t//free the define tokens\n\tfor (t = define->tokens; t; t = next)\n\t{\n\t\tnext = t->next;\n\t\tPC_FreeToken(t);\n\t} //end for\n\t//free the define\n\tFreeMemory(define);\n} //end of the function PC_FreeDefine\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PC_AddBuiltinDefines(source_t *source)\n{\n\tint i;\n\tdefine_t *define;\n\tstruct builtin\n\t{\n\t\tchar *string;\n\t\tint builtin;\n\t} builtin[] = { // bk001204 - brackets\n\t\t{ \"__LINE__\",\tBUILTIN_LINE },\n\t\t{ \"__FILE__\",\tBUILTIN_FILE },\n\t\t{ \"__DATE__\",\tBUILTIN_DATE },\n\t\t{ \"__TIME__\",\tBUILTIN_TIME },\n//\t\t{ \"__STDC__\", BUILTIN_STDC },\n\t\t{ NULL, 0 }\n\t};\n\n\tfor (i = 0; builtin[i].string; i++)\n\t{\n\t\tdefine = (define_t *) GetMemory(sizeof(define_t) + strlen(builtin[i].string) + 1);\n\t\tCom_Memset(define, 0, sizeof(define_t));\n\t\tdefine->name = (char *) define + sizeof(define_t);\n\t\tstrcpy(define->name, builtin[i].string);\n\t\tdefine->flags |= DEFINE_FIXED;\n\t\tdefine->builtin = builtin[i].builtin;\n\t\t//add the define to the source\n#if DEFINEHASHING\n\t\tPC_AddDefineToHash(define, source->definehash);\n#else\n\t\tdefine->next = source->defines;\n\t\tsource->defines = define;\n#endif //DEFINEHASHING\n\t} //end for\n} //end of the function PC_AddBuiltinDefines\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_ExpandBuiltinDefine(source_t *source, token_t *deftoken, define_t *define,\n\t\t\t\t\t\t\t\t\t\ttoken_t **firsttoken, token_t **lasttoken)\n{\n\ttoken_t *token;\n\tunsigned long t;\t//\ttime_t t; //to prevent LCC warning\n\tchar *curtime;\n\n\ttoken = PC_CopyToken(deftoken);\n\tswitch(define->builtin)\n\t{\n\t\tcase BUILTIN_LINE:\n\t\t{\n\t\t\tsprintf(token->string, \"%d\", deftoken->line);\n#ifdef NUMBERVALUE\n\t\t\ttoken->intvalue = deftoken->line;\n\t\t\ttoken->floatvalue = deftoken->line;\n#endif //NUMBERVALUE\n\t\t\ttoken->type = TT_NUMBER;\n\t\t\ttoken->subtype = TT_DECIMAL | TT_INTEGER;\n\t\t\t*firsttoken = token;\n\t\t\t*lasttoken = token;\n\t\t\tbreak;\n\t\t} //end case\n\t\tcase BUILTIN_FILE:\n\t\t{\n\t\t\tstrcpy(token->string, source->scriptstack->filename);\n\t\t\ttoken->type = TT_NAME;\n\t\t\ttoken->subtype = strlen(token->string);\n\t\t\t*firsttoken = token;\n\t\t\t*lasttoken = token;\n\t\t\tbreak;\n\t\t} //end case\n\t\tcase BUILTIN_DATE:\n\t\t{\n\t\t\tt = time(NULL);\n\t\t\tcurtime = ctime(&t);\n\t\t\tstrcpy(token->string, \"\\\"\");\n\t\t\tstrncat(token->string, curtime+4, 7);\n\t\t\tstrncat(token->string+7, curtime+20, 4);\n\t\t\tstrcat(token->string, \"\\\"\");\n\t\t\tfree(curtime);\n\t\t\ttoken->type = TT_NAME;\n\t\t\ttoken->subtype = strlen(token->string);\n\t\t\t*firsttoken = token;\n\t\t\t*lasttoken = token;\n\t\t\tbreak;\n\t\t} //end case\n\t\tcase BUILTIN_TIME:\n\t\t{\n\t\t\tt = time(NULL);\n\t\t\tcurtime = ctime(&t);\n\t\t\tstrcpy(token->string, \"\\\"\");\n\t\t\tstrncat(token->string, curtime+11, 8);\n\t\t\tstrcat(token->string, \"\\\"\");\n\t\t\tfree(curtime);\n\t\t\ttoken->type = TT_NAME;\n\t\t\ttoken->subtype = strlen(token->string);\n\t\t\t*firsttoken = token;\n\t\t\t*lasttoken = token;\n\t\t\tbreak;\n\t\t} //end case\n\t\tcase BUILTIN_STDC:\n\t\tdefault:\n\t\t{\n\t\t\t*firsttoken = NULL;\n\t\t\t*lasttoken = NULL;\n\t\t\tbreak;\n\t\t} //end case\n\t} //end switch\n\treturn qtrue;\n} //end of the function PC_ExpandBuiltinDefine\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_ExpandDefine(source_t *source, token_t *deftoken, define_t *define,\n\t\t\t\t\t\t\t\t\t\ttoken_t **firsttoken, token_t **lasttoken)\n{\n\ttoken_t *parms[MAX_DEFINEPARMS], *dt, *pt, *t;\n\ttoken_t *t1, *t2, *first, *last, *nextpt, token;\n\tint parmnum, i;\n\n\t//if it is a builtin define\n\tif (define->builtin)\n\t{\n\t\treturn PC_ExpandBuiltinDefine(source, deftoken, define, firsttoken, lasttoken);\n\t} //end if\n\t//if the define has parameters\n\tif (define->numparms)\n\t{\n\t\tif (!PC_ReadDefineParms(source, define, parms, MAX_DEFINEPARMS)) return qfalse;\n#ifdef DEBUG_EVAL\n\t\tfor (i = 0; i < define->numparms; i++)\n\t\t{\n\t\t\tLog_Write(\"define parms %d:\", i);\n\t\t\tfor (pt = parms[i]; pt; pt = pt->next)\n\t\t\t{\n\t\t\t\tLog_Write(\"%s\", pt->string);\n\t\t\t} //end for\n\t\t} //end for\n#endif //DEBUG_EVAL\n\t} //end if\n\t//empty list at first\n\tfirst = NULL;\n\tlast = NULL;\n\t//create a list with tokens of the expanded define\n\tfor (dt = define->tokens; dt; dt = dt->next)\n\t{\n\t\tparmnum = -1;\n\t\t//if the token is a name, it could be a define parameter\n\t\tif (dt->type == TT_NAME)\n\t\t{\n\t\t\tparmnum = PC_FindDefineParm(define, dt->string);\n\t\t} //end if\n\t\t//if it is a define parameter\n\t\tif (parmnum >= 0)\n\t\t{\n\t\t\tfor (pt = parms[parmnum]; pt; pt = pt->next)\n\t\t\t{\n\t\t\t\tt = PC_CopyToken(pt);\n\t\t\t\t//add the token to the list\n\t\t\t\tt->next = NULL;\n\t\t\t\tif (last) last->next = t;\n\t\t\t\telse first = t;\n\t\t\t\tlast = t;\n\t\t\t} //end for\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\t//if stringizing operator\n\t\t\tif (dt->string[0] == '#' && dt->string[1] == '\\0')\n\t\t\t{\n\t\t\t\t//the stringizing operator must be followed by a define parameter\n\t\t\t\tif (dt->next) parmnum = PC_FindDefineParm(define, dt->next->string);\n\t\t\t\telse parmnum = -1;\n\t\t\t\t//\n\t\t\t\tif (parmnum >= 0)\n\t\t\t\t{\n\t\t\t\t\t//step over the stringizing operator\n\t\t\t\t\tdt = dt->next;\n\t\t\t\t\t//stringize the define parameter tokens\n\t\t\t\t\tif (!PC_StringizeTokens(parms[parmnum], &token))\n\t\t\t\t\t{\n\t\t\t\t\t\tSourceError(source, \"can't stringize tokens\");\n\t\t\t\t\t\treturn qfalse;\n\t\t\t\t\t} //end if\n\t\t\t\t\tt = PC_CopyToken(&token);\n\t\t\t\t} //end if\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tSourceWarning(source, \"stringizing operator without define parameter\");\n\t\t\t\t\tcontinue;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tt = PC_CopyToken(dt);\n\t\t\t} //end else\n\t\t\t//add the token to the list\n\t\t\tt->next = NULL;\n\t\t\tif (last) last->next = t;\n\t\t\telse first = t;\n\t\t\tlast = t;\n\t\t} //end else\n\t} //end for\n\t//check for the merging operator\n\tfor (t = first; t; )\n\t{\n\t\tif (t->next)\n\t\t{\n\t\t\t//if the merging operator\n\t\t\tif (t->next->string[0] == '#' && t->next->string[1] == '#')\n\t\t\t{\n\t\t\t\tt1 = t;\n\t\t\t\tt2 = t->next->next;\n\t\t\t\tif (t2)\n\t\t\t\t{\n\t\t\t\t\tif (!PC_MergeTokens(t1, t2))\n\t\t\t\t\t{\n\t\t\t\t\t\tSourceError(source, \"can't merge %s with %s\", t1->string, t2->string);\n\t\t\t\t\t\treturn qfalse;\n\t\t\t\t\t} //end if\n\t\t\t\t\tPC_FreeToken(t1->next);\n\t\t\t\t\tt1->next = t2->next;\n\t\t\t\t\tif (t2 == last) last = t1;\n\t\t\t\t\tPC_FreeToken(t2);\n\t\t\t\t\tcontinue;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end if\n\t\tt = t->next;\n\t} //end for\n\t//store the first and last token of the list\n\t*firsttoken = first;\n\t*lasttoken = last;\n\t//free all the parameter tokens\n\tfor (i = 0; i < define->numparms; i++)\n\t{\n\t\tfor (pt = parms[i]; pt; pt = nextpt)\n\t\t{\n\t\t\tnextpt = pt->next;\n\t\t\tPC_FreeToken(pt);\n\t\t} //end for\n\t} //end for\n\t//\n\treturn qtrue;\n} //end of the function PC_ExpandDefine\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_ExpandDefineIntoSource(source_t *source, token_t *deftoken, define_t *define)\n{\n\ttoken_t *firsttoken, *lasttoken;\n\n\tif (!PC_ExpandDefine(source, deftoken, define, &firsttoken, &lasttoken)) return qfalse;\n\n\tif (firsttoken && lasttoken)\n\t{\n\t\tlasttoken->next = source->tokens;\n\t\tsource->tokens = firsttoken;\n\t\treturn qtrue;\n\t} //end if\n\treturn qfalse;\n} //end of the function PC_ExpandDefineIntoSource\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PC_ConvertPath(char *path)\n{\n\tchar *ptr;\n\n\t//remove double path seperators\n\tfor (ptr = path; *ptr;)\n\t{\n\t\tif ((*ptr == '\\\\' || *ptr == '/') &&\n\t\t\t\t(*(ptr+1) == '\\\\' || *(ptr+1) == '/'))\n\t\t{\n\t\t\tstrcpy(ptr, ptr+1);\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tptr++;\n\t\t} //end else\n\t} //end while\n\t//set OS dependent path seperators\n\tfor (ptr = path; *ptr;)\n\t{\n\t\tif (*ptr == '/' || *ptr == '\\\\') *ptr = PATHSEPERATOR_CHAR;\n\t\tptr++;\n\t} //end while\n} //end of the function PC_ConvertPath\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_Directive_include(source_t *source)\n{\n\tscript_t *script;\n\ttoken_t token;\n\tchar path[MAX_PATH];\n#ifdef QUAKE\n\tfoundfile_t file;\n#endif //QUAKE\n\n\tif (source->skip > 0) return qtrue;\n\t//\n\tif (!PC_ReadSourceToken(source, &token))\n\t{\n\t\tSourceError(source, \"#include without file name\");\n\t\treturn qfalse;\n\t} //end if\n\tif (token.linescrossed > 0)\n\t{\n\t\tSourceError(source, \"#include without file name\");\n\t\treturn qfalse;\n\t} //end if\n\tif (token.type == TT_STRING)\n\t{\n\t\tStripDoubleQuotes(token.string);\n\t\tPC_ConvertPath(token.string);\n\t\tscript = LoadScriptFile(token.string);\n\t\tif (!script)\n\t\t{\n\t\t\tstrcpy(path, source->includepath);\n\t\t\tstrcat(path, token.string);\n\t\t\tscript = LoadScriptFile(path);\n\t\t} //end if\n\t} //end if\n\telse if (token.type == TT_PUNCTUATION && *token.string == '<')\n\t{\n\t\tstrcpy(path, source->includepath);\n\t\twhile(PC_ReadSourceToken(source, &token))\n\t\t{\n\t\t\tif (token.linescrossed > 0)\n\t\t\t{\n\t\t\t\tPC_UnreadSourceToken(source, &token);\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t\tif (token.type == TT_PUNCTUATION && *token.string == '>') break;\n\t\t\tstrncat(path, token.string, MAX_PATH);\n\t\t} //end while\n\t\tif (*token.string != '>')\n\t\t{\n\t\t\tSourceWarning(source, \"#include missing trailing >\");\n\t\t} //end if\n\t\tif (!strlen(path))\n\t\t{\n\t\t\tSourceError(source, \"#include without file name between < >\");\n\t\t\treturn qfalse;\n\t\t} //end if\n\t\tPC_ConvertPath(path);\n\t\tscript = LoadScriptFile(path);\n\t} //end if\n\telse\n\t{\n\t\tSourceError(source, \"#include without file name\");\n\t\treturn qfalse;\n\t} //end else\n#ifdef QUAKE\n\tif (!script)\n\t{\n\t\tCom_Memset(&file, 0, sizeof(foundfile_t));\n\t\tscript = LoadScriptFile(path);\n\t\tif (script) strncpy(script->filename, path, MAX_PATH);\n\t} //end if\n#endif //QUAKE\n\tif (!script)\n\t{\n#ifdef SCREWUP\n\t\tSourceWarning(source, \"file %s not found\", path);\n\t\treturn qtrue;\n#else\n\t\tSourceError(source, \"file %s not found\", path);\n\t\treturn qfalse;\n#endif //SCREWUP\n\t} //end if\n\tPC_PushScript(source, script);\n\treturn qtrue;\n} //end of the function PC_Directive_include\n//============================================================================\n// reads a token from the current line, continues reading on the next\n// line only if a backslash '\\' is encountered.\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_ReadLine(source_t *source, token_t *token)\n{\n\tint crossline;\n\n\tcrossline = 0;\n\tdo\n\t{\n\t\tif (!PC_ReadSourceToken(source, token)) return qfalse;\n\t\t\n\t\tif (token->linescrossed > crossline)\n\t\t{\n\t\t\tPC_UnreadSourceToken(source, token);\n\t\t\treturn qfalse;\n\t\t} //end if\n\t\tcrossline = 1;\n\t} while(!strcmp(token->string, \"\\\\\"));\n\treturn qtrue;\n} //end of the function PC_ReadLine\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_WhiteSpaceBeforeToken(token_t *token)\n{\n\treturn token->endwhitespace_p - token->whitespace_p > 0;\n} //end of the function PC_WhiteSpaceBeforeToken\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PC_ClearTokenWhiteSpace(token_t *token)\n{\n\ttoken->whitespace_p = NULL;\n\ttoken->endwhitespace_p = NULL;\n\ttoken->linescrossed = 0;\n} //end of the function PC_ClearTokenWhiteSpace\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_Directive_undef(source_t *source)\n{\n\ttoken_t token;\n\tdefine_t *define, *lastdefine;\n\tint hash;\n\n\tif (source->skip > 0) return qtrue;\n\t//\n\tif (!PC_ReadLine(source, &token))\n\t{\n\t\tSourceError(source, \"undef without name\");\n\t\treturn qfalse;\n\t} //end if\n\tif (token.type != TT_NAME)\n\t{\n\t\tPC_UnreadSourceToken(source, &token);\n\t\tSourceError(source, \"expected name, found %s\", token.string);\n\t\treturn qfalse;\n\t} //end if\n#if DEFINEHASHING\n\n\thash = PC_NameHash(token.string);\n\tfor (lastdefine = NULL, define = source->definehash[hash]; define; define = define->hashnext)\n\t{\n\t\tif (!strcmp(define->name, token.string))\n\t\t{\n\t\t\tif (define->flags & DEFINE_FIXED)\n\t\t\t{\n\t\t\t\tSourceWarning(source, \"can't undef %s\", token.string);\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (lastdefine) lastdefine->hashnext = define->hashnext;\n\t\t\t\telse source->definehash[hash] = define->hashnext;\n\t\t\t\tPC_FreeDefine(define);\n\t\t\t} //end else\n\t\t\tbreak;\n\t\t} //end if\n\t\tlastdefine = define;\n\t} //end for\n#else //DEFINEHASHING\n\tfor (lastdefine = NULL, define = source->defines; define; define = define->next)\n\t{\n\t\tif (!strcmp(define->name, token.string))\n\t\t{\n\t\t\tif (define->flags & DEFINE_FIXED)\n\t\t\t{\n\t\t\t\tSourceWarning(source, \"can't undef %s\", token.string);\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (lastdefine) lastdefine->next = define->next;\n\t\t\t\telse source->defines = define->next;\n\t\t\t\tPC_FreeDefine(define);\n\t\t\t} //end else\n\t\t\tbreak;\n\t\t} //end if\n\t\tlastdefine = define;\n\t} //end for\n#endif //DEFINEHASHING\n\treturn qtrue;\n} //end of the function PC_Directive_undef\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_Directive_define(source_t *source)\n{\n\ttoken_t token, *t, *last;\n\tdefine_t *define;\n\n\tif (source->skip > 0) return qtrue;\n\t//\n\tif (!PC_ReadLine(source, &token))\n\t{\n\t\tSourceError(source, \"#define without name\");\n\t\treturn qfalse;\n\t} //end if\n\tif (token.type != TT_NAME)\n\t{\n\t\tPC_UnreadSourceToken(source, &token);\n\t\tSourceError(source, \"expected name after #define, found %s\", token.string);\n\t\treturn qfalse;\n\t} //end if\n\t//check if the define already exists\n#if DEFINEHASHING\n\tdefine = PC_FindHashedDefine(source->definehash, token.string);\n#else\n\tdefine = PC_FindDefine(source->defines, token.string);\n#endif //DEFINEHASHING\n\tif (define)\n\t{\n\t\tif (define->flags & DEFINE_FIXED)\n\t\t{\n\t\t\tSourceError(source, \"can't redefine %s\", token.string);\n\t\t\treturn qfalse;\n\t\t} //end if\n\t\tSourceWarning(source, \"redefinition of %s\", token.string);\n\t\t//unread the define name before executing the #undef directive\n\t\tPC_UnreadSourceToken(source, &token);\n\t\tif (!PC_Directive_undef(source)) return qfalse;\n\t\t//if the define was not removed (define->flags & DEFINE_FIXED)\n#if DEFINEHASHING\n\t\tdefine = PC_FindHashedDefine(source->definehash, token.string);\n#else\n\t\tdefine = PC_FindDefine(source->defines, token.string);\n#endif //DEFINEHASHING\n\t} //end if\n\t//allocate define\n\tdefine = (define_t *) GetMemory(sizeof(define_t) + strlen(token.string) + 1);\n\tCom_Memset(define, 0, sizeof(define_t));\n\tdefine->name = (char *) define + sizeof(define_t);\n\tstrcpy(define->name, token.string);\n\t//add the define to the source\n#if DEFINEHASHING\n\tPC_AddDefineToHash(define, source->definehash);\n#else //DEFINEHASHING\n\tdefine->next = source->defines;\n\tsource->defines = define;\n#endif //DEFINEHASHING\n\t//if nothing is defined, just return\n\tif (!PC_ReadLine(source, &token)) return qtrue;\n\t//if it is a define with parameters\n\tif (!PC_WhiteSpaceBeforeToken(&token) && !strcmp(token.string, \"(\"))\n\t{\n\t\t//read the define parameters\n\t\tlast = NULL;\n\t\tif (!PC_CheckTokenString(source, \")\"))\n\t\t{\n\t\t\twhile(1)\n\t\t\t{\n\t\t\t\tif (!PC_ReadLine(source, &token))\n\t\t\t\t{\n\t\t\t\t\tSourceError(source, \"expected define parameter\");\n\t\t\t\t\treturn qfalse;\n\t\t\t\t} //end if\n\t\t\t\t//if it isn't a name\n\t\t\t\tif (token.type != TT_NAME)\n\t\t\t\t{\n\t\t\t\t\tSourceError(source, \"invalid define parameter\");\n\t\t\t\t\treturn qfalse;\n\t\t\t\t} //end if\n\t\t\t\t//\n\t\t\t\tif (PC_FindDefineParm(define, token.string) >= 0)\n\t\t\t\t{\n\t\t\t\t\tSourceError(source, \"two the same define parameters\");\n\t\t\t\t\treturn qfalse;\n\t\t\t\t} //end if\n\t\t\t\t//add the define parm\n\t\t\t\tt = PC_CopyToken(&token);\n\t\t\t\tPC_ClearTokenWhiteSpace(t);\n\t\t\t\tt->next = NULL;\n\t\t\t\tif (last) last->next = t;\n\t\t\t\telse define->parms = t;\n\t\t\t\tlast = t;\n\t\t\t\tdefine->numparms++;\n\t\t\t\t//read next token\n\t\t\t\tif (!PC_ReadLine(source, &token))\n\t\t\t\t{\n\t\t\t\t\tSourceError(source, \"define parameters not terminated\");\n\t\t\t\t\treturn qfalse;\n\t\t\t\t} //end if\n\t\t\t\t//\n\t\t\t\tif (!strcmp(token.string, \")\")) break;\n\t\t\t\t//then it must be a comma\n\t\t\t\tif (strcmp(token.string, \",\"))\n\t\t\t\t{\n\t\t\t\t\tSourceError(source, \"define not terminated\");\n\t\t\t\t\treturn qfalse;\n\t\t\t\t} //end if\n\t\t\t} //end while\n\t\t} //end if\n\t\tif (!PC_ReadLine(source, &token)) return qtrue;\n\t} //end if\n\t//read the defined stuff\n\tlast = NULL;\n\tdo\n\t{\n\t\tt = PC_CopyToken(&token);\n\t\tif (t->type == TT_NAME && !strcmp(t->string, define->name))\n\t\t{\n\t\t\tSourceError(source, \"recursive define (removed recursion)\");\n\t\t\tcontinue;\n\t\t} //end if\n\t\tPC_ClearTokenWhiteSpace(t);\n\t\tt->next = NULL;\n\t\tif (last) last->next = t;\n\t\telse define->tokens = t;\n\t\tlast = t;\n\t} while(PC_ReadLine(source, &token));\n\t//\n\tif (last)\n\t{\n\t\t//check for merge operators at the beginning or end\n\t\tif (!strcmp(define->tokens->string, \"##\") ||\n\t\t\t\t!strcmp(last->string, \"##\"))\n\t\t{\n\t\t\tSourceError(source, \"define with misplaced ##\");\n\t\t\treturn qfalse;\n\t\t} //end if\n\t} //end if\n\treturn qtrue;\n} //end of the function PC_Directive_define\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\ndefine_t *PC_DefineFromString(char *string)\n{\n\tscript_t *script;\n\tsource_t src;\n\ttoken_t *t;\n\tint res, i;\n\tdefine_t *def;\n\n\tPC_InitTokenHeap();\n\n\tscript = LoadScriptMemory(string, strlen(string), \"*extern\");\n\t//create a new source\n\tCom_Memset(&src, 0, sizeof(source_t));\n\tstrncpy(src.filename, \"*extern\", MAX_PATH);\n\tsrc.scriptstack = script;\n#if DEFINEHASHING\n\tsrc.definehash = GetClearedMemory(DEFINEHASHSIZE * sizeof(define_t *));\n#endif //DEFINEHASHING\n\t//create a define from the source\n\tres = PC_Directive_define(&src);\n\t//free any tokens if left\n\tfor (t = src.tokens; t; t = src.tokens)\n\t{\n\t\tsrc.tokens = src.tokens->next;\n\t\tPC_FreeToken(t);\n\t} //end for\n#ifdef DEFINEHASHING\n\tdef = NULL;\n\tfor (i = 0; i < DEFINEHASHSIZE; i++)\n\t{\n\t\tif (src.definehash[i])\n\t\t{\n\t\t\tdef = src.definehash[i];\n\t\t\tbreak;\n\t\t} //end if\n\t} //end for\n#else\n\tdef = src.defines;\n#endif //DEFINEHASHING\n\t//\n#if DEFINEHASHING\n\tFreeMemory(src.definehash);\n#endif //DEFINEHASHING\n\t//\n\tFreeScript(script);\n\t//if the define was created succesfully\n\tif (res > 0) return def;\n\t//free the define is created\n\tif (src.defines) PC_FreeDefine(def);\n\t//\n\treturn NULL;\n} //end of the function PC_DefineFromString\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_AddDefine(source_t *source, char *string)\n{\n\tdefine_t *define;\n\n\tdefine = PC_DefineFromString(string);\n\tif (!define) return qfalse;\n#if DEFINEHASHING\n\tPC_AddDefineToHash(define, source->definehash);\n#else //DEFINEHASHING\n\tdefine->next = source->defines;\n\tsource->defines = define;\n#endif //DEFINEHASHING\n\treturn qtrue;\n} //end of the function PC_AddDefine\n//============================================================================\n// add a globals define that will be added to all opened sources\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_AddGlobalDefine(char *string)\n{\n\tdefine_t *define;\n\n\tdefine = PC_DefineFromString(string);\n\tif (!define) return qfalse;\n\tdefine->next = globaldefines;\n\tglobaldefines = define;\n\treturn qtrue;\n} //end of the function PC_AddGlobalDefine\n//============================================================================\n// remove the given global define\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_RemoveGlobalDefine(char *name)\n{\n\tdefine_t *define;\n\n\tdefine = PC_FindDefine(globaldefines, name);\n\tif (define)\n\t{\n\t\tPC_FreeDefine(define);\n\t\treturn qtrue;\n\t} //end if\n\treturn qfalse;\n} //end of the function PC_RemoveGlobalDefine\n//============================================================================\n// remove all globals defines\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PC_RemoveAllGlobalDefines(void)\n{\n\tdefine_t *define;\n\n\tfor (define = globaldefines; define; define = globaldefines)\n\t{\n\t\tglobaldefines = globaldefines->next;\n\t\tPC_FreeDefine(define);\n\t} //end for\n} //end of the function PC_RemoveAllGlobalDefines\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\ndefine_t *PC_CopyDefine(source_t *source, define_t *define)\n{\n\tdefine_t *newdefine;\n\ttoken_t *token, *newtoken, *lasttoken;\n\n\tnewdefine = (define_t *) GetMemory(sizeof(define_t) + strlen(define->name) + 1);\n\t//copy the define name\n\tnewdefine->name = (char *) newdefine + sizeof(define_t);\n\tstrcpy(newdefine->name, define->name);\n\tnewdefine->flags = define->flags;\n\tnewdefine->builtin = define->builtin;\n\tnewdefine->numparms = define->numparms;\n\t//the define is not linked\n\tnewdefine->next = NULL;\n\tnewdefine->hashnext = NULL;\n\t//copy the define tokens\n\tnewdefine->tokens = NULL;\n\tfor (lasttoken = NULL, token = define->tokens; token; token = token->next)\n\t{\n\t\tnewtoken = PC_CopyToken(token);\n\t\tnewtoken->next = NULL;\n\t\tif (lasttoken) lasttoken->next = newtoken;\n\t\telse newdefine->tokens = newtoken;\n\t\tlasttoken = newtoken;\n\t} //end for\n\t//copy the define parameters\n\tnewdefine->parms = NULL;\n\tfor (lasttoken = NULL, token = define->parms; token; token = token->next)\n\t{\n\t\tnewtoken = PC_CopyToken(token);\n\t\tnewtoken->next = NULL;\n\t\tif (lasttoken) lasttoken->next = newtoken;\n\t\telse newdefine->parms = newtoken;\n\t\tlasttoken = newtoken;\n\t} //end for\n\treturn newdefine;\n} //end of the function PC_CopyDefine\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PC_AddGlobalDefinesToSource(source_t *source)\n{\n\tdefine_t *define, *newdefine;\n\n\tfor (define = globaldefines; define; define = define->next)\n\t{\n\t\tnewdefine = PC_CopyDefine(source, define);\n#if DEFINEHASHING\n\t\tPC_AddDefineToHash(newdefine, source->definehash);\n#else //DEFINEHASHING\n\t\tnewdefine->next = source->defines;\n\t\tsource->defines = newdefine;\n#endif //DEFINEHASHING\n\t} //end for\n} //end of the function PC_AddGlobalDefinesToSource\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_Directive_if_def(source_t *source, int type)\n{\n\ttoken_t token;\n\tdefine_t *d;\n\tint skip;\n\n\tif (!PC_ReadLine(source, &token))\n\t{\n\t\tSourceError(source, \"#ifdef without name\");\n\t\treturn qfalse;\n\t} //end if\n\tif (token.type != TT_NAME)\n\t{\n\t\tPC_UnreadSourceToken(source, &token);\n\t\tSourceError(source, \"expected name after #ifdef, found %s\", token.string);\n\t\treturn qfalse;\n\t} //end if\n#if DEFINEHASHING\n\td = PC_FindHashedDefine(source->definehash, token.string);\n#else\n\td = PC_FindDefine(source->defines, token.string);\n#endif //DEFINEHASHING\n\tskip = (type == INDENT_IFDEF) == (d == NULL);\n\tPC_PushIndent(source, type, skip);\n\treturn qtrue;\n} //end of the function PC_Directiveif_def\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_Directive_ifdef(source_t *source)\n{\n\treturn PC_Directive_if_def(source, INDENT_IFDEF);\n} //end of the function PC_Directive_ifdef\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_Directive_ifndef(source_t *source)\n{\n\treturn PC_Directive_if_def(source, INDENT_IFNDEF);\n} //end of the function PC_Directive_ifndef\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_Directive_else(source_t *source)\n{\n\tint type, skip;\n\n\tPC_PopIndent(source, &type, &skip);\n\tif (!type)\n\t{\n\t\tSourceError(source, \"misplaced #else\");\n\t\treturn qfalse;\n\t} //end if\n\tif (type == INDENT_ELSE)\n\t{\n\t\tSourceError(source, \"#else after #else\");\n\t\treturn qfalse;\n\t} //end if\n\tPC_PushIndent(source, INDENT_ELSE, !skip);\n\treturn qtrue;\n} //end of the function PC_Directive_else\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_Directive_endif(source_t *source)\n{\n\tint type, skip;\n\n\tPC_PopIndent(source, &type, &skip);\n\tif (!type)\n\t{\n\t\tSourceError(source, \"misplaced #endif\");\n\t\treturn qfalse;\n\t} //end if\n\treturn qtrue;\n} //end of the function PC_Directive_endif\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\ntypedef struct operator_s\n{\n\tint operator;\n\tint priority;\n\tint parentheses;\n\tstruct operator_s *prev, *next;\n} operator_t;\n\ntypedef struct value_s\n{\n\tsigned long int intvalue;\n\tdouble floatvalue;\n\tint parentheses;\n\tstruct value_s *prev, *next;\n} value_t;\n\nint PC_OperatorPriority(int op)\n{\n\tswitch(op)\n\t{\n\t\tcase P_MUL: return 15;\n\t\tcase P_DIV: return 15;\n\t\tcase P_MOD: return 15;\n\t\tcase P_ADD: return 14;\n\t\tcase P_SUB: return 14;\n\n\t\tcase P_LOGIC_AND: return 7;\n\t\tcase P_LOGIC_OR: return 6;\n\t\tcase P_LOGIC_GEQ: return 12;\n\t\tcase P_LOGIC_LEQ: return 12;\n\t\tcase P_LOGIC_EQ: return 11;\n\t\tcase P_LOGIC_UNEQ: return 11;\n\n\t\tcase P_LOGIC_NOT: return 16;\n\t\tcase P_LOGIC_GREATER: return 12;\n\t\tcase P_LOGIC_LESS: return 12;\n\n\t\tcase P_RSHIFT: return 13;\n\t\tcase P_LSHIFT: return 13;\n\n\t\tcase P_BIN_AND: return 10;\n\t\tcase P_BIN_OR: return 8;\n\t\tcase P_BIN_XOR: return 9;\n\t\tcase P_BIN_NOT: return 16;\n\n\t\tcase P_COLON: return 5;\n\t\tcase P_QUESTIONMARK: return 5;\n\t} //end switch\n\treturn qfalse;\n} //end of the function PC_OperatorPriority\n\n//#define AllocValue()\t\t\tGetClearedMemory(sizeof(value_t));\n//#define FreeValue(val)\t\tFreeMemory(val)\n//#define AllocOperator(op)\t\top = (operator_t *) GetClearedMemory(sizeof(operator_t));\n//#define FreeOperator(op)\t\tFreeMemory(op);\n\n#define MAX_VALUES\t\t64\n#define MAX_OPERATORS\t64\n#define AllocValue(val)\t\t\t\t\t\t\t\t\t\\\n\tif (numvalues >= MAX_VALUES) {\t\t\t\t\t\t\\\n\t\tSourceError(source, \"out of value space\\n\");\t\t\\\n\t\terror = 1;\t\t\t\t\t\t\t\t\t\t\\\n\t\tbreak;\t\t\t\t\t\t\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\t\t\t\t\t\\\n\telse\t\t\t\t\t\t\t\t\t\t\t\t\\\n\t\tval = &value_heap[numvalues++];\n#define FreeValue(val)\n//\n#define AllocOperator(op)\t\t\t\t\t\t\t\t\\\n\tif (numoperators >= MAX_OPERATORS) {\t\t\t\t\\\n\t\tSourceError(source, \"out of operator space\\n\");\t\\\n\t\terror = 1;\t\t\t\t\t\t\t\t\t\t\\\n\t\tbreak;\t\t\t\t\t\t\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\t\t\t\t\t\\\n\telse\t\t\t\t\t\t\t\t\t\t\t\t\\\n\t\top = &operator_heap[numoperators++];\n#define FreeOperator(op)\n\nint PC_EvaluateTokens(source_t *source, token_t *tokens, signed long int *intvalue,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdouble *floatvalue, int integer)\n{\n\toperator_t *o, *firstoperator, *lastoperator;\n\tvalue_t *v, *firstvalue, *lastvalue, *v1, *v2;\n\ttoken_t *t;\n\tint brace = 0;\n\tint parentheses = 0;\n\tint error = 0;\n\tint lastwasvalue = 0;\n\tint negativevalue = 0;\n\tint questmarkintvalue = 0;\n\tdouble questmarkfloatvalue = 0;\n\tint gotquestmarkvalue = qfalse;\n\tint lastoperatortype = 0;\n\t//\n\toperator_t operator_heap[MAX_OPERATORS];\n\tint numoperators = 0;\n\tvalue_t value_heap[MAX_VALUES];\n\tint numvalues = 0;\n\n\tfirstoperator = lastoperator = NULL;\n\tfirstvalue = lastvalue = NULL;\n\tif (intvalue) *intvalue = 0;\n\tif (floatvalue) *floatvalue = 0;\n\tfor (t = tokens; t; t = t->next)\n\t{\n\t\tswitch(t->type)\n\t\t{\n\t\t\tcase TT_NAME:\n\t\t\t{\n\t\t\t\tif (lastwasvalue || negativevalue)\n\t\t\t\t{\n\t\t\t\t\tSourceError(source, \"syntax error in #if/#elif\");\n\t\t\t\t\terror = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t\tif (strcmp(t->string, \"defined\"))\n\t\t\t\t{\n\t\t\t\t\tSourceError(source, \"undefined name %s in #if/#elif\", t->string);\n\t\t\t\t\terror = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t\tt = t->next;\n\t\t\t\tif (!strcmp(t->string, \"(\"))\n\t\t\t\t{\n\t\t\t\t\tbrace = qtrue;\n\t\t\t\t\tt = t->next;\n\t\t\t\t} //end if\n\t\t\t\tif (!t || t->type != TT_NAME)\n\t\t\t\t{\n\t\t\t\t\tSourceError(source, \"defined without name in #if/#elif\");\n\t\t\t\t\terror = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t\t//v = (value_t *) GetClearedMemory(sizeof(value_t));\n\t\t\t\tAllocValue(v);\n#if DEFINEHASHING\n\t\t\t\tif (PC_FindHashedDefine(source->definehash, t->string))\n#else\t\t\t\n\t\t\t\tif (PC_FindDefine(source->defines, t->string))\n#endif //DEFINEHASHING\n\t\t\t\t{\n\t\t\t\t\tv->intvalue = 1;\n\t\t\t\t\tv->floatvalue = 1;\n\t\t\t\t} //end if\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tv->intvalue = 0;\n\t\t\t\t\tv->floatvalue = 0;\n\t\t\t\t} //end else\n\t\t\t\tv->parentheses = parentheses;\n\t\t\t\tv->next = NULL;\n\t\t\t\tv->prev = lastvalue;\n\t\t\t\tif (lastvalue) lastvalue->next = v;\n\t\t\t\telse firstvalue = v;\n\t\t\t\tlastvalue = v;\n\t\t\t\tif (brace)\n\t\t\t\t{\n\t\t\t\t\tt = t->next;\n\t\t\t\t\tif (!t || strcmp(t->string, \")\"))\n\t\t\t\t\t{\n\t\t\t\t\t\tSourceError(source, \"defined without ) in #if/#elif\");\n\t\t\t\t\t\terror = 1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t\tbrace = qfalse;\n\t\t\t\t// defined() creates a value\n\t\t\t\tlastwasvalue = 1;\n\t\t\t\tbreak;\n\t\t\t} //end case\n\t\t\tcase TT_NUMBER:\n\t\t\t{\n\t\t\t\tif (lastwasvalue)\n\t\t\t\t{\n\t\t\t\t\tSourceError(source, \"syntax error in #if/#elif\");\n\t\t\t\t\terror = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t\t//v = (value_t *) GetClearedMemory(sizeof(value_t));\n\t\t\t\tAllocValue(v);\n\t\t\t\tif (negativevalue)\n\t\t\t\t{\n\t\t\t\t\tv->intvalue = - (signed int) t->intvalue;\n\t\t\t\t\tv->floatvalue = - t->floatvalue;\n\t\t\t\t} //end if\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tv->intvalue = t->intvalue;\n\t\t\t\t\tv->floatvalue = t->floatvalue;\n\t\t\t\t} //end else\n\t\t\t\tv->parentheses = parentheses;\n\t\t\t\tv->next = NULL;\n\t\t\t\tv->prev = lastvalue;\n\t\t\t\tif (lastvalue) lastvalue->next = v;\n\t\t\t\telse firstvalue = v;\n\t\t\t\tlastvalue = v;\n\t\t\t\t//last token was a value\n\t\t\t\tlastwasvalue = 1;\n\t\t\t\t//\n\t\t\t\tnegativevalue = 0;\n\t\t\t\tbreak;\n\t\t\t} //end case\n\t\t\tcase TT_PUNCTUATION:\n\t\t\t{\n\t\t\t\tif (negativevalue)\n\t\t\t\t{\n\t\t\t\t\tSourceError(source, \"misplaced minus sign in #if/#elif\");\n\t\t\t\t\terror = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t\tif (t->subtype == P_PARENTHESESOPEN)\n\t\t\t\t{\n\t\t\t\t\tparentheses++;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t\telse if (t->subtype == P_PARENTHESESCLOSE)\n\t\t\t\t{\n\t\t\t\t\tparentheses--;\n\t\t\t\t\tif (parentheses < 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tSourceError(source, \"too many ) in #if/#elsif\");\n\t\t\t\t\t\terror = 1;\n\t\t\t\t\t} //end if\n\t\t\t\t\tbreak;\n\t\t\t\t} //end else if\n\t\t\t\t//check for invalid operators on floating point values\n\t\t\t\tif (!integer)\n\t\t\t\t{\n\t\t\t\t\tif (t->subtype == P_BIN_NOT || t->subtype == P_MOD ||\n\t\t\t\t\t\tt->subtype == P_RSHIFT || t->subtype == P_LSHIFT ||\n\t\t\t\t\t\tt->subtype == P_BIN_AND || t->subtype == P_BIN_OR ||\n\t\t\t\t\t\tt->subtype == P_BIN_XOR)\n\t\t\t\t\t{\n\t\t\t\t\t\tSourceError(source, \"illigal operator %s on floating point operands\\n\", t->string);\n\t\t\t\t\t\terror = 1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t\tswitch(t->subtype)\n\t\t\t\t{\n\t\t\t\t\tcase P_LOGIC_NOT:\n\t\t\t\t\tcase P_BIN_NOT:\n\t\t\t\t\t{\n\t\t\t\t\t\tif (lastwasvalue)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourceError(source, \"! or ~ after value in #if/#elif\");\n\t\t\t\t\t\t\terror = 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} //end case\n\t\t\t\t\tcase P_INC:\n\t\t\t\t\tcase P_DEC:\n\t\t\t\t\t{\n\t\t\t\t\t\tSourceError(source, \"++ or -- used in #if/#elif\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} //end case\n\t\t\t\t\tcase P_SUB:\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!lastwasvalue)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tnegativevalue = 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end case\n\t\t\t\t\t\n\t\t\t\t\tcase P_MUL:\n\t\t\t\t\tcase P_DIV:\n\t\t\t\t\tcase P_MOD:\n\t\t\t\t\tcase P_ADD:\n\n\t\t\t\t\tcase P_LOGIC_AND:\n\t\t\t\t\tcase P_LOGIC_OR:\n\t\t\t\t\tcase P_LOGIC_GEQ:\n\t\t\t\t\tcase P_LOGIC_LEQ:\n\t\t\t\t\tcase P_LOGIC_EQ:\n\t\t\t\t\tcase P_LOGIC_UNEQ:\n\n\t\t\t\t\tcase P_LOGIC_GREATER:\n\t\t\t\t\tcase P_LOGIC_LESS:\n\n\t\t\t\t\tcase P_RSHIFT:\n\t\t\t\t\tcase P_LSHIFT:\n\n\t\t\t\t\tcase P_BIN_AND:\n\t\t\t\t\tcase P_BIN_OR:\n\t\t\t\t\tcase P_BIN_XOR:\n\n\t\t\t\t\tcase P_COLON:\n\t\t\t\t\tcase P_QUESTIONMARK:\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!lastwasvalue)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourceError(source, \"operator %s after operator in #if/#elif\", t->string);\n\t\t\t\t\t\t\terror = 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} //end case\n\t\t\t\t\tdefault:\n\t\t\t\t\t{\n\t\t\t\t\t\tSourceError(source, \"invalid operator %s in #if/#elif\", t->string);\n\t\t\t\t\t\terror = 1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} //end default\n\t\t\t\t} //end switch\n\t\t\t\tif (!error && !negativevalue)\n\t\t\t\t{\n\t\t\t\t\t//o = (operator_t *) GetClearedMemory(sizeof(operator_t));\n\t\t\t\t\tAllocOperator(o);\n\t\t\t\t\to->operator = t->subtype;\n\t\t\t\t\to->priority = PC_OperatorPriority(t->subtype);\n\t\t\t\t\to->parentheses = parentheses;\n\t\t\t\t\to->next = NULL;\n\t\t\t\t\to->prev = lastoperator;\n\t\t\t\t\tif (lastoperator) lastoperator->next = o;\n\t\t\t\t\telse firstoperator = o;\n\t\t\t\t\tlastoperator = o;\n\t\t\t\t\tlastwasvalue = 0;\n\t\t\t\t} //end if\n\t\t\t\tbreak;\n\t\t\t} //end case\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\tSourceError(source, \"unknown %s in #if/#elif\", t->string);\n\t\t\t\terror = 1;\n\t\t\t\tbreak;\n\t\t\t} //end default\n\t\t} //end switch\n\t\tif (error) break;\n\t} //end for\n\tif (!error)\n\t{\n\t\tif (!lastwasvalue)\n\t\t{\n\t\t\tSourceError(source, \"trailing operator in #if/#elif\");\n\t\t\terror = 1;\n\t\t} //end if\n\t\telse if (parentheses)\n\t\t{\n\t\t\tSourceError(source, \"too many ( in #if/#elif\");\n\t\t\terror = 1;\n\t\t} //end else if\n\t} //end if\n\t//\n\tgotquestmarkvalue = qfalse;\n\tquestmarkintvalue = 0;\n\tquestmarkfloatvalue = 0;\n\t//while there are operators\n\twhile(!error && firstoperator)\n\t{\n\t\tv = firstvalue;\n\t\tfor (o = firstoperator; o->next; o = o->next)\n\t\t{\n\t\t\t//if the current operator is nested deeper in parentheses\n\t\t\t//than the next operator\n\t\t\tif (o->parentheses > o->next->parentheses) break;\n\t\t\t//if the current and next operator are nested equally deep in parentheses\n\t\t\tif (o->parentheses == o->next->parentheses)\n\t\t\t{\n\t\t\t\t//if the priority of the current operator is equal or higher\n\t\t\t\t//than the priority of the next operator\n\t\t\t\tif (o->priority >= o->next->priority) break;\n\t\t\t} //end if\n\t\t\t//if the arity of the operator isn't equal to 1\n\t\t\tif (o->operator != P_LOGIC_NOT\n\t\t\t\t\t&& o->operator != P_BIN_NOT) v = v->next;\n\t\t\t//if there's no value or no next value\n\t\t\tif (!v)\n\t\t\t{\n\t\t\t\tSourceError(source, \"mising values in #if/#elif\");\n\t\t\t\terror = 1;\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t} //end for\n\t\tif (error) break;\n\t\tv1 = v;\n\t\tv2 = v->next;\n#ifdef DEBUG_EVAL\n\t\tif (integer)\n\t\t{\n\t\t\tLog_Write(\"operator %s, value1 = %d\", PunctuationFromNum(source->scriptstack, o->operator), v1->intvalue);\n\t\t\tif (v2) Log_Write(\"value2 = %d\", v2->intvalue);\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tLog_Write(\"operator %s, value1 = %f\", PunctuationFromNum(source->scriptstack, o->operator), v1->floatvalue);\n\t\t\tif (v2) Log_Write(\"value2 = %f\", v2->floatvalue);\n\t\t} //end else\n#endif //DEBUG_EVAL\n\t\tswitch(o->operator)\n\t\t{\n\t\t\tcase P_LOGIC_NOT:\t\tv1->intvalue = !v1->intvalue;\n\t\t\t\t\t\t\t\t\tv1->floatvalue = !v1->floatvalue; break;\n\t\t\tcase P_BIN_NOT:\t\t\tv1->intvalue = ~v1->intvalue;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\tcase P_MUL:\t\t\t\tv1->intvalue *= v2->intvalue;\n\t\t\t\t\t\t\t\t\tv1->floatvalue *= v2->floatvalue; break;\n\t\t\tcase P_DIV:\t\t\t\tif (!v2->intvalue || !v2->floatvalue)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tSourceError(source, \"divide by zero in #if/#elif\\n\");\n\t\t\t\t\t\t\t\t\t\terror = 1;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tv1->intvalue /= v2->intvalue;\n\t\t\t\t\t\t\t\t\tv1->floatvalue /= v2->floatvalue; break;\n\t\t\tcase P_MOD:\t\t\t\tif (!v2->intvalue)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tSourceError(source, \"divide by zero in #if/#elif\\n\");\n\t\t\t\t\t\t\t\t\t\terror = 1;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tv1->intvalue %= v2->intvalue; break;\n\t\t\tcase P_ADD:\t\t\t\tv1->intvalue += v2->intvalue;\n\t\t\t\t\t\t\t\t\tv1->floatvalue += v2->floatvalue; break;\n\t\t\tcase P_SUB:\t\t\t\tv1->intvalue -= v2->intvalue;\n\t\t\t\t\t\t\t\t\tv1->floatvalue -= v2->floatvalue; break;\n\t\t\tcase P_LOGIC_AND:\t\tv1->intvalue = v1->intvalue && v2->intvalue;\n\t\t\t\t\t\t\t\t\tv1->floatvalue = v1->floatvalue && v2->floatvalue; break;\n\t\t\tcase P_LOGIC_OR:\t\tv1->intvalue = v1->intvalue || v2->intvalue;\n\t\t\t\t\t\t\t\t\tv1->floatvalue = v1->floatvalue || v2->floatvalue; break;\n\t\t\tcase P_LOGIC_GEQ:\t\tv1->intvalue = v1->intvalue >= v2->intvalue;\n\t\t\t\t\t\t\t\t\tv1->floatvalue = v1->floatvalue >= v2->floatvalue; break;\n\t\t\tcase P_LOGIC_LEQ:\t\tv1->intvalue = v1->intvalue <= v2->intvalue;\n\t\t\t\t\t\t\t\t\tv1->floatvalue = v1->floatvalue <= v2->floatvalue; break;\n\t\t\tcase P_LOGIC_EQ:\t\tv1->intvalue = v1->intvalue == v2->intvalue;\n\t\t\t\t\t\t\t\t\tv1->floatvalue = v1->floatvalue == v2->floatvalue; break;\n\t\t\tcase P_LOGIC_UNEQ:\t\tv1->intvalue = v1->intvalue != v2->intvalue;\n\t\t\t\t\t\t\t\t\tv1->floatvalue = v1->floatvalue != v2->floatvalue; break;\n\t\t\tcase P_LOGIC_GREATER:\tv1->intvalue = v1->intvalue > v2->intvalue;\n\t\t\t\t\t\t\t\t\tv1->floatvalue = v1->floatvalue > v2->floatvalue; break;\n\t\t\tcase P_LOGIC_LESS:\t\tv1->intvalue = v1->intvalue < v2->intvalue;\n\t\t\t\t\t\t\t\t\tv1->floatvalue = v1->floatvalue < v2->floatvalue; break;\n\t\t\tcase P_RSHIFT:\t\t\tv1->intvalue >>= v2->intvalue;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\tcase P_LSHIFT:\t\t\tv1->intvalue <<= v2->intvalue;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\tcase P_BIN_AND:\t\t\tv1->intvalue &= v2->intvalue;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\tcase P_BIN_OR:\t\t\tv1->intvalue |= v2->intvalue;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\tcase P_BIN_XOR:\t\t\tv1->intvalue ^= v2->intvalue;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\tcase P_COLON:\n\t\t\t{\n\t\t\t\tif (!gotquestmarkvalue)\n\t\t\t\t{\n\t\t\t\t\tSourceError(source, \": without ? in #if/#elif\");\n\t\t\t\t\terror = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t\tif (integer)\n\t\t\t\t{\n\t\t\t\t\tif (!questmarkintvalue) v1->intvalue = v2->intvalue;\n\t\t\t\t} //end if\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (!questmarkfloatvalue) v1->floatvalue = v2->floatvalue;\n\t\t\t\t} //end else\n\t\t\t\tgotquestmarkvalue = qfalse;\n\t\t\t\tbreak;\n\t\t\t} //end case\n\t\t\tcase P_QUESTIONMARK:\n\t\t\t{\n\t\t\t\tif (gotquestmarkvalue)\n\t\t\t\t{\n\t\t\t\t\tSourceError(source, \"? after ? in #if/#elif\");\n\t\t\t\t\terror = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t\tquestmarkintvalue = v1->intvalue;\n\t\t\t\tquestmarkfloatvalue = v1->floatvalue;\n\t\t\t\tgotquestmarkvalue = qtrue;\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t} //end switch\n#ifdef DEBUG_EVAL\n\t\tif (integer) Log_Write(\"result value = %d\", v1->intvalue);\n\t\telse Log_Write(\"result value = %f\", v1->floatvalue);\n#endif //DEBUG_EVAL\n\t\tif (error) break;\n\t\tlastoperatortype = o->operator;\n\t\t//if not an operator with arity 1\n\t\tif (o->operator != P_LOGIC_NOT\n\t\t\t\t&& o->operator != P_BIN_NOT)\n\t\t{\n\t\t\t//remove the second value if not question mark operator\n\t\t\tif (o->operator != P_QUESTIONMARK) v = v->next;\n\t\t\t//\n\t\t\tif (v->prev) v->prev->next = v->next;\n\t\t\telse firstvalue = v->next;\n\t\t\tif (v->next) v->next->prev = v->prev;\n\t\t\telse lastvalue = v->prev;\n\t\t\t//FreeMemory(v);\n\t\t\tFreeValue(v);\n\t\t} //end if\n\t\t//remove the operator\n\t\tif (o->prev) o->prev->next = o->next;\n\t\telse firstoperator = o->next;\n\t\tif (o->next) o->next->prev = o->prev;\n\t\telse lastoperator = o->prev;\n\t\t//FreeMemory(o);\n\t\tFreeOperator(o);\n\t} //end while\n\tif (firstvalue)\n\t{\n\t\tif (intvalue) *intvalue = firstvalue->intvalue;\n\t\tif (floatvalue) *floatvalue = firstvalue->floatvalue;\n\t} //end if\n\tfor (o = firstoperator; o; o = lastoperator)\n\t{\n\t\tlastoperator = o->next;\n\t\t//FreeMemory(o);\n\t\tFreeOperator(o);\n\t} //end for\n\tfor (v = firstvalue; v; v = lastvalue)\n\t{\n\t\tlastvalue = v->next;\n\t\t//FreeMemory(v);\n\t\tFreeValue(v);\n\t} //end for\n\tif (!error) return qtrue;\n\tif (intvalue) *intvalue = 0;\n\tif (floatvalue) *floatvalue = 0;\n\treturn qfalse;\n} //end of the function PC_EvaluateTokens\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_Evaluate(source_t *source, signed long int *intvalue,\n\t\t\t\t\t\t\t\t\t\t\t\tdouble *floatvalue, int integer)\n{\n\ttoken_t token, *firsttoken, *lasttoken;\n\ttoken_t *t, *nexttoken;\n\tdefine_t *define;\n\tint defined = qfalse;\n\n\tif (intvalue) *intvalue = 0;\n\tif (floatvalue) *floatvalue = 0;\n\t//\n\tif (!PC_ReadLine(source, &token))\n\t{\n\t\tSourceError(source, \"no value after #if/#elif\");\n\t\treturn qfalse;\n\t} //end if\n\tfirsttoken = NULL;\n\tlasttoken = NULL;\n\tdo\n\t{\n\t\t//if the token is a name\n\t\tif (token.type == TT_NAME)\n\t\t{\n\t\t\tif (defined)\n\t\t\t{\n\t\t\t\tdefined = qfalse;\n\t\t\t\tt = PC_CopyToken(&token);\n\t\t\t\tt->next = NULL;\n\t\t\t\tif (lasttoken) lasttoken->next = t;\n\t\t\t\telse firsttoken = t;\n\t\t\t\tlasttoken = t;\n\t\t\t} //end if\n\t\t\telse if (!strcmp(token.string, \"defined\"))\n\t\t\t{\n\t\t\t\tdefined = qtrue;\n\t\t\t\tt = PC_CopyToken(&token);\n\t\t\t\tt->next = NULL;\n\t\t\t\tif (lasttoken) lasttoken->next = t;\n\t\t\t\telse firsttoken = t;\n\t\t\t\tlasttoken = t;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\t//then it must be a define\n#if DEFINEHASHING\n\t\t\t\tdefine = PC_FindHashedDefine(source->definehash, token.string);\n#else\n\t\t\t\tdefine = PC_FindDefine(source->defines, token.string);\n#endif //DEFINEHASHING\n\t\t\t\tif (!define)\n\t\t\t\t{\n\t\t\t\t\tSourceError(source, \"can't evaluate %s, not defined\", token.string);\n\t\t\t\t\treturn qfalse;\n\t\t\t\t} //end if\n\t\t\t\tif (!PC_ExpandDefineIntoSource(source, &token, define)) return qfalse;\n\t\t\t} //end else\n\t\t} //end if\n\t\t//if the token is a number or a punctuation\n\t\telse if (token.type == TT_NUMBER || token.type == TT_PUNCTUATION)\n\t\t{\n\t\t\tt = PC_CopyToken(&token);\n\t\t\tt->next = NULL;\n\t\t\tif (lasttoken) lasttoken->next = t;\n\t\t\telse firsttoken = t;\n\t\t\tlasttoken = t;\n\t\t} //end else\n\t\telse //can't evaluate the token\n\t\t{\n\t\t\tSourceError(source, \"can't evaluate %s\", token.string);\n\t\t\treturn qfalse;\n\t\t} //end else\n\t} while(PC_ReadLine(source, &token));\n\t//\n\tif (!PC_EvaluateTokens(source, firsttoken, intvalue, floatvalue, integer)) return qfalse;\n\t//\n#ifdef DEBUG_EVAL\n\tLog_Write(\"eval:\");\n#endif //DEBUG_EVAL\n\tfor (t = firsttoken; t; t = nexttoken)\n\t{\n#ifdef DEBUG_EVAL\n\t\tLog_Write(\" %s\", t->string);\n#endif //DEBUG_EVAL\n\t\tnexttoken = t->next;\n\t\tPC_FreeToken(t);\n\t} //end for\n#ifdef DEBUG_EVAL\n\tif (integer) Log_Write(\"eval result: %d\", *intvalue);\n\telse Log_Write(\"eval result: %f\", *floatvalue);\n#endif //DEBUG_EVAL\n\t//\n\treturn qtrue;\n} //end of the function PC_Evaluate\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_DollarEvaluate(source_t *source, signed long int *intvalue,\n\t\t\t\t\t\t\t\t\t\t\t\tdouble *floatvalue, int integer)\n{\n\tint indent, defined = qfalse;\n\ttoken_t token, *firsttoken, *lasttoken;\n\ttoken_t *t, *nexttoken;\n\tdefine_t *define;\n\n\tif (intvalue) *intvalue = 0;\n\tif (floatvalue) *floatvalue = 0;\n\t//\n\tif (!PC_ReadSourceToken(source, &token))\n\t{\n\t\tSourceError(source, \"no leading ( after $evalint/$evalfloat\");\n\t\treturn qfalse;\n\t} //end if\n\tif (!PC_ReadSourceToken(source, &token))\n\t{\n\t\tSourceError(source, \"nothing to evaluate\");\n\t\treturn qfalse;\n\t} //end if\n\tindent = 1;\n\tfirsttoken = NULL;\n\tlasttoken = NULL;\n\tdo\n\t{\n\t\t//if the token is a name\n\t\tif (token.type == TT_NAME)\n\t\t{\n\t\t\tif (defined)\n\t\t\t{\n\t\t\t\tdefined = qfalse;\n\t\t\t\tt = PC_CopyToken(&token);\n\t\t\t\tt->next = NULL;\n\t\t\t\tif (lasttoken) lasttoken->next = t;\n\t\t\t\telse firsttoken = t;\n\t\t\t\tlasttoken = t;\n\t\t\t} //end if\n\t\t\telse if (!strcmp(token.string, \"defined\"))\n\t\t\t{\n\t\t\t\tdefined = qtrue;\n\t\t\t\tt = PC_CopyToken(&token);\n\t\t\t\tt->next = NULL;\n\t\t\t\tif (lasttoken) lasttoken->next = t;\n\t\t\t\telse firsttoken = t;\n\t\t\t\tlasttoken = t;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\t//then it must be a define\n#if DEFINEHASHING\n\t\t\t\tdefine = PC_FindHashedDefine(source->definehash, token.string);\n#else\n\t\t\t\tdefine = PC_FindDefine(source->defines, token.string);\n#endif //DEFINEHASHING\n\t\t\t\tif (!define)\n\t\t\t\t{\n\t\t\t\t\tSourceError(source, \"can't evaluate %s, not defined\", token.string);\n\t\t\t\t\treturn qfalse;\n\t\t\t\t} //end if\n\t\t\t\tif (!PC_ExpandDefineIntoSource(source, &token, define)) return qfalse;\n\t\t\t} //end else\n\t\t} //end if\n\t\t//if the token is a number or a punctuation\n\t\telse if (token.type == TT_NUMBER || token.type == TT_PUNCTUATION)\n\t\t{\n\t\t\tif (*token.string == '(') indent++;\n\t\t\telse if (*token.string == ')') indent--;\n\t\t\tif (indent <= 0) break;\n\t\t\tt = PC_CopyToken(&token);\n\t\t\tt->next = NULL;\n\t\t\tif (lasttoken) lasttoken->next = t;\n\t\t\telse firsttoken = t;\n\t\t\tlasttoken = t;\n\t\t} //end else\n\t\telse //can't evaluate the token\n\t\t{\n\t\t\tSourceError(source, \"can't evaluate %s\", token.string);\n\t\t\treturn qfalse;\n\t\t} //end else\n\t} while(PC_ReadSourceToken(source, &token));\n\t//\n\tif (!PC_EvaluateTokens(source, firsttoken, intvalue, floatvalue, integer)) return qfalse;\n\t//\n#ifdef DEBUG_EVAL\n\tLog_Write(\"$eval:\");\n#endif //DEBUG_EVAL\n\tfor (t = firsttoken; t; t = nexttoken)\n\t{\n#ifdef DEBUG_EVAL\n\t\tLog_Write(\" %s\", t->string);\n#endif //DEBUG_EVAL\n\t\tnexttoken = t->next;\n\t\tPC_FreeToken(t);\n\t} //end for\n#ifdef DEBUG_EVAL\n\tif (integer) Log_Write(\"$eval result: %d\", *intvalue);\n\telse Log_Write(\"$eval result: %f\", *floatvalue);\n#endif //DEBUG_EVAL\n\t//\n\treturn qtrue;\n} //end of the function PC_DollarEvaluate\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_Directive_elif(source_t *source)\n{\n\tsigned long int value;\n\tint type, skip;\n\n\tPC_PopIndent(source, &type, &skip);\n\tif (!type || type == INDENT_ELSE)\n\t{\n\t\tSourceError(source, \"misplaced #elif\");\n\t\treturn qfalse;\n\t} //end if\n\tif (!PC_Evaluate(source, &value, NULL, qtrue)) return qfalse;\n\tskip = (value == 0);\n\tPC_PushIndent(source, INDENT_ELIF, skip);\n\treturn qtrue;\n} //end of the function PC_Directive_elif\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_Directive_if(source_t *source)\n{\n\tsigned long int value;\n\tint skip;\n\n\tif (!PC_Evaluate(source, &value, NULL, qtrue)) return qfalse;\n\tskip = (value == 0);\n\tPC_PushIndent(source, INDENT_IF, skip);\n\treturn qtrue;\n} //end of the function PC_Directive\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_Directive_line(source_t *source)\n{\n\tSourceError(source, \"#line directive not supported\");\n\treturn qfalse;\n} //end of the function PC_Directive_line\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_Directive_error(source_t *source)\n{\n\ttoken_t token;\n\n\tstrcpy(token.string, \"\");\n\tPC_ReadSourceToken(source, &token);\n\tSourceError(source, \"#error directive: %s\", token.string);\n\treturn qfalse;\n} //end of the function PC_Directive_error\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_Directive_pragma(source_t *source)\n{\n\ttoken_t token;\n\n\tSourceWarning(source, \"#pragma directive not supported\");\n\twhile(PC_ReadLine(source, &token)) ;\n\treturn qtrue;\n} //end of the function PC_Directive_pragma\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid UnreadSignToken(source_t *source)\n{\n\ttoken_t token;\n\n\ttoken.line = source->scriptstack->line;\n\ttoken.whitespace_p = source->scriptstack->script_p;\n\ttoken.endwhitespace_p = source->scriptstack->script_p;\n\ttoken.linescrossed = 0;\n\tstrcpy(token.string, \"-\");\n\ttoken.type = TT_PUNCTUATION;\n\ttoken.subtype = P_SUB;\n\tPC_UnreadSourceToken(source, &token);\n} //end of the function UnreadSignToken\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_Directive_eval(source_t *source)\n{\n\tsigned long int value;\n\ttoken_t token;\n\n\tif (!PC_Evaluate(source, &value, NULL, qtrue)) return qfalse;\n\t//\n\ttoken.line = source->scriptstack->line;\n\ttoken.whitespace_p = source->scriptstack->script_p;\n\ttoken.endwhitespace_p = source->scriptstack->script_p;\n\ttoken.linescrossed = 0;\n\tsprintf(token.string, \"%d\", abs(value));\n\ttoken.type = TT_NUMBER;\n\ttoken.subtype = TT_INTEGER|TT_LONG|TT_DECIMAL;\n\tPC_UnreadSourceToken(source, &token);\n\tif (value < 0) UnreadSignToken(source);\n\treturn qtrue;\n} //end of the function PC_Directive_eval\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_Directive_evalfloat(source_t *source)\n{\n\tdouble value;\n\ttoken_t token;\n\n\tif (!PC_Evaluate(source, NULL, &value, qfalse)) return qfalse;\n\ttoken.line = source->scriptstack->line;\n\ttoken.whitespace_p = source->scriptstack->script_p;\n\ttoken.endwhitespace_p = source->scriptstack->script_p;\n\ttoken.linescrossed = 0;\n\tsprintf(token.string, \"%1.2f\", fabs(value));\n\ttoken.type = TT_NUMBER;\n\ttoken.subtype = TT_FLOAT|TT_LONG|TT_DECIMAL;\n\tPC_UnreadSourceToken(source, &token);\n\tif (value < 0) UnreadSignToken(source);\n\treturn qtrue;\n} //end of the function PC_Directive_evalfloat\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\ndirective_t directives[20] =\n{\n\t{\"if\", PC_Directive_if},\n\t{\"ifdef\", PC_Directive_ifdef},\n\t{\"ifndef\", PC_Directive_ifndef},\n\t{\"elif\", PC_Directive_elif},\n\t{\"else\", PC_Directive_else},\n\t{\"endif\", PC_Directive_endif},\n\t{\"include\", PC_Directive_include},\n\t{\"define\", PC_Directive_define},\n\t{\"undef\", PC_Directive_undef},\n\t{\"line\", PC_Directive_line},\n\t{\"error\", PC_Directive_error},\n\t{\"pragma\", PC_Directive_pragma},\n\t{\"eval\", PC_Directive_eval},\n\t{\"evalfloat\", PC_Directive_evalfloat},\n\t{NULL, NULL}\n};\n\nint PC_ReadDirective(source_t *source)\n{\n\ttoken_t token;\n\tint i;\n\n\t//read the directive name\n\tif (!PC_ReadSourceToken(source, &token))\n\t{\n\t\tSourceError(source, \"found # without name\");\n\t\treturn qfalse;\n\t} //end if\n\t//directive name must be on the same line\n\tif (token.linescrossed > 0)\n\t{\n\t\tPC_UnreadSourceToken(source, &token);\n\t\tSourceError(source, \"found # at end of line\");\n\t\treturn qfalse;\n\t} //end if\n\t//if if is a name\n\tif (token.type == TT_NAME)\n\t{\n\t\t//find the precompiler directive\n\t\tfor (i = 0; directives[i].name; i++)\n\t\t{\n\t\t\tif (!strcmp(directives[i].name, token.string))\n\t\t\t{\n\t\t\t\treturn directives[i].func(source);\n\t\t\t} //end if\n\t\t} //end for\n\t} //end if\n\tSourceError(source, \"unknown precompiler directive %s\", token.string);\n\treturn qfalse;\n} //end of the function PC_ReadDirective\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_DollarDirective_evalint(source_t *source)\n{\n\tsigned long int value;\n\ttoken_t token;\n\n\tif (!PC_DollarEvaluate(source, &value, NULL, qtrue)) return qfalse;\n\t//\n\ttoken.line = source->scriptstack->line;\n\ttoken.whitespace_p = source->scriptstack->script_p;\n\ttoken.endwhitespace_p = source->scriptstack->script_p;\n\ttoken.linescrossed = 0;\n\tsprintf(token.string, \"%d\", abs(value));\n\ttoken.type = TT_NUMBER;\n\ttoken.subtype = TT_INTEGER|TT_LONG|TT_DECIMAL;\n#ifdef NUMBERVALUE\n\ttoken.intvalue = value;\n\ttoken.floatvalue = value;\n#endif //NUMBERVALUE\n\tPC_UnreadSourceToken(source, &token);\n\tif (value < 0) UnreadSignToken(source);\n\treturn qtrue;\n} //end of the function PC_DollarDirective_evalint\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_DollarDirective_evalfloat(source_t *source)\n{\n\tdouble value;\n\ttoken_t token;\n\n\tif (!PC_DollarEvaluate(source, NULL, &value, qfalse)) return qfalse;\n\ttoken.line = source->scriptstack->line;\n\ttoken.whitespace_p = source->scriptstack->script_p;\n\ttoken.endwhitespace_p = source->scriptstack->script_p;\n\ttoken.linescrossed = 0;\n\tsprintf(token.string, \"%1.2f\", fabs(value));\n\ttoken.type = TT_NUMBER;\n\ttoken.subtype = TT_FLOAT|TT_LONG|TT_DECIMAL;\n#ifdef NUMBERVALUE\n\ttoken.intvalue = (unsigned long) value;\n\ttoken.floatvalue = value;\n#endif //NUMBERVALUE\n\tPC_UnreadSourceToken(source, &token);\n\tif (value < 0) UnreadSignToken(source);\n\treturn qtrue;\n} //end of the function PC_DollarDirective_evalfloat\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\ndirective_t dollardirectives[20] =\n{\n\t{\"evalint\", PC_DollarDirective_evalint},\n\t{\"evalfloat\", PC_DollarDirective_evalfloat},\n\t{NULL, NULL}\n};\n\nint PC_ReadDollarDirective(source_t *source)\n{\n\ttoken_t token;\n\tint i;\n\n\t//read the directive name\n\tif (!PC_ReadSourceToken(source, &token))\n\t{\n\t\tSourceError(source, \"found $ without name\");\n\t\treturn qfalse;\n\t} //end if\n\t//directive name must be on the same line\n\tif (token.linescrossed > 0)\n\t{\n\t\tPC_UnreadSourceToken(source, &token);\n\t\tSourceError(source, \"found $ at end of line\");\n\t\treturn qfalse;\n\t} //end if\n\t//if if is a name\n\tif (token.type == TT_NAME)\n\t{\n\t\t//find the precompiler directive\n\t\tfor (i = 0; dollardirectives[i].name; i++)\n\t\t{\n\t\t\tif (!strcmp(dollardirectives[i].name, token.string))\n\t\t\t{\n\t\t\t\treturn dollardirectives[i].func(source);\n\t\t\t} //end if\n\t\t} //end for\n\t} //end if\n\tPC_UnreadSourceToken(source, &token);\n\tSourceError(source, \"unknown precompiler directive %s\", token.string);\n\treturn qfalse;\n} //end of the function PC_ReadDirective\n\n#ifdef QUAKEC\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint BuiltinFunction(source_t *source)\n{\n\ttoken_t token;\n\n\tif (!PC_ReadSourceToken(source, &token)) return qfalse;\n\tif (token.type == TT_NUMBER)\n\t{\n\t\tPC_UnreadSourceToken(source, &token);\n\t\treturn qtrue;\n\t} //end if\n\telse\n\t{\n\t\tPC_UnreadSourceToken(source, &token);\n\t\treturn qfalse;\n\t} //end else\n} //end of the function BuiltinFunction\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint QuakeCMacro(source_t *source)\n{\n\tint i;\n\ttoken_t token;\n\n\tif (!PC_ReadSourceToken(source, &token)) return qtrue;\n\tif (token.type != TT_NAME)\n\t{\n\t\tPC_UnreadSourceToken(source, &token);\n\t\treturn qtrue;\n\t} //end if\n\t//find the precompiler directive\n\tfor (i = 0; dollardirectives[i].name; i++)\n\t{\n\t\tif (!strcmp(dollardirectives[i].name, token.string))\n\t\t{\n\t\t\tPC_UnreadSourceToken(source, &token);\n\t\t\treturn qfalse;\n\t\t} //end if\n\t} //end for\n\tPC_UnreadSourceToken(source, &token);\n\treturn qtrue;\n} //end of the function QuakeCMacro\n#endif //QUAKEC\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_ReadToken(source_t *source, token_t *token)\n{\n\tdefine_t *define;\n\n\twhile(1)\n\t{\n\t\tif (!PC_ReadSourceToken(source, token)) return qfalse;\n\t\t//check for precompiler directives\n\t\tif (token->type == TT_PUNCTUATION && *token->string == '#')\n\t\t{\n#ifdef QUAKEC\n\t\t\tif (!BuiltinFunction(source))\n#endif //QUAKC\n\t\t\t{\n\t\t\t\t//read the precompiler directive\n\t\t\t\tif (!PC_ReadDirective(source)) return qfalse;\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t} //end if\n\t\tif (token->type == TT_PUNCTUATION && *token->string == '$')\n\t\t{\n#ifdef QUAKEC\n\t\t\tif (!QuakeCMacro(source))\n#endif //QUAKEC\n\t\t\t{\n\t\t\t\t//read the precompiler directive\n\t\t\t\tif (!PC_ReadDollarDirective(source)) return qfalse;\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t} //end if\n\t\t// recursively concatenate strings that are behind each other still resolving defines\n\t\tif (token->type == TT_STRING)\n\t\t{\n\t\t\ttoken_t newtoken;\n\t\t\tif (PC_ReadToken(source, &newtoken))\n\t\t\t{\n\t\t\t\tif (newtoken.type == TT_STRING)\n\t\t\t\t{\n\t\t\t\t\ttoken->string[strlen(token->string)-1] = '\\0';\n\t\t\t\t\tif (strlen(token->string) + strlen(newtoken.string+1) + 1 >= MAX_TOKEN)\n\t\t\t\t\t{\n\t\t\t\t\t\tSourceError(source, \"string longer than MAX_TOKEN %d\\n\", MAX_TOKEN);\n\t\t\t\t\t\treturn qfalse;\n\t\t\t\t\t}\n\t\t\t\t\tstrcat(token->string, newtoken.string+1);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tPC_UnreadToken(source, &newtoken);\n\t\t\t\t}\n\t\t\t}\n\t\t} //end if\n\t\t//if skipping source because of conditional compilation\n\t\tif (source->skip) continue;\n\t\t//if the token is a name\n\t\tif (token->type == TT_NAME)\n\t\t{\n\t\t\t//check if the name is a define macro\n#if DEFINEHASHING\n\t\t\tdefine = PC_FindHashedDefine(source->definehash, token->string);\n#else\n\t\t\tdefine = PC_FindDefine(source->defines, token->string);\n#endif //DEFINEHASHING\n\t\t\t//if it is a define macro\n\t\t\tif (define)\n\t\t\t{\n\t\t\t\t//expand the defined macro\n\t\t\t\tif (!PC_ExpandDefineIntoSource(source, token, define)) return qfalse;\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t} //end if\n\t\t//copy token for unreading\n\t\tCom_Memcpy(&source->token, token, sizeof(token_t));\n\t\t//found a token\n\t\treturn qtrue;\n\t} //end while\n} //end of the function PC_ReadToken\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_ExpectTokenString(source_t *source, char *string)\n{\n\ttoken_t token;\n\n\tif (!PC_ReadToken(source, &token))\n\t{\n\t\tSourceError(source, \"couldn't find expected %s\", string);\n\t\treturn qfalse;\n\t} //end if\n\n\tif (strcmp(token.string, string))\n\t{\n\t\tSourceError(source, \"expected %s, found %s\", string, token.string);\n\t\treturn qfalse;\n\t} //end if\n\treturn qtrue;\n} //end of the function PC_ExpectTokenString\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_ExpectTokenType(source_t *source, int type, int subtype, token_t *token)\n{\n\tchar str[MAX_TOKEN];\n\n\tif (!PC_ReadToken(source, token))\n\t{\n\t\tSourceError(source, \"couldn't read expected token\");\n\t\treturn qfalse;\n\t} //end if\n\n\tif (token->type != type)\n\t{\n\t\tstrcpy(str, \"\");\n\t\tif (type == TT_STRING) strcpy(str, \"string\");\n\t\tif (type == TT_LITERAL) strcpy(str, \"literal\");\n\t\tif (type == TT_NUMBER) strcpy(str, \"number\");\n\t\tif (type == TT_NAME) strcpy(str, \"name\");\n\t\tif (type == TT_PUNCTUATION) strcpy(str, \"punctuation\");\n\t\tSourceError(source, \"expected a %s, found %s\", str, token->string);\n\t\treturn qfalse;\n\t} //end if\n\tif (token->type == TT_NUMBER)\n\t{\n\t\tif ((token->subtype & subtype) != subtype)\n\t\t{\n\t\t\tif (subtype & TT_DECIMAL) strcpy(str, \"decimal\");\n\t\t\tif (subtype & TT_HEX) strcpy(str, \"hex\");\n\t\t\tif (subtype & TT_OCTAL) strcpy(str, \"octal\");\n\t\t\tif (subtype & TT_BINARY) strcpy(str, \"binary\");\n\t\t\tif (subtype & TT_LONG) strcat(str, \" long\");\n\t\t\tif (subtype & TT_UNSIGNED) strcat(str, \" unsigned\");\n\t\t\tif (subtype & TT_FLOAT) strcat(str, \" float\");\n\t\t\tif (subtype & TT_INTEGER) strcat(str, \" integer\");\n\t\t\tSourceError(source, \"expected %s, found %s\", str, token->string);\n\t\t\treturn qfalse;\n\t\t} //end if\n\t} //end if\n\telse if (token->type == TT_PUNCTUATION)\n\t{\n\t\tif (token->subtype != subtype)\n\t\t{\n\t\t\tSourceError(source, \"found %s\", token->string);\n\t\t\treturn qfalse;\n\t\t} //end if\n\t} //end else if\n\treturn qtrue;\n} //end of the function PC_ExpectTokenType\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_ExpectAnyToken(source_t *source, token_t *token)\n{\n\tif (!PC_ReadToken(source, token))\n\t{\n\t\tSourceError(source, \"couldn't read expected token\");\n\t\treturn qfalse;\n\t} //end if\n\telse\n\t{\n\t\treturn qtrue;\n\t} //end else\n} //end of the function PC_ExpectAnyToken\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_CheckTokenString(source_t *source, char *string)\n{\n\ttoken_t tok;\n\n\tif (!PC_ReadToken(source, &tok)) return qfalse;\n\t//if the token is available\n\tif (!strcmp(tok.string, string)) return qtrue;\n\t//\n\tPC_UnreadSourceToken(source, &tok);\n\treturn qfalse;\n} //end of the function PC_CheckTokenString\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_CheckTokenType(source_t *source, int type, int subtype, token_t *token)\n{\n\ttoken_t tok;\n\n\tif (!PC_ReadToken(source, &tok)) return qfalse;\n\t//if the type matches\n\tif (tok.type == type &&\n\t\t\t(tok.subtype & subtype) == subtype)\n\t{\n\t\tCom_Memcpy(token, &tok, sizeof(token_t));\n\t\treturn qtrue;\n\t} //end if\n\t//\n\tPC_UnreadSourceToken(source, &tok);\n\treturn qfalse;\n} //end of the function PC_CheckTokenType\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_SkipUntilString(source_t *source, char *string)\n{\n\ttoken_t token;\n\n\twhile(PC_ReadToken(source, &token))\n\t{\n\t\tif (!strcmp(token.string, string)) return qtrue;\n\t} //end while\n\treturn qfalse;\n} //end of the function PC_SkipUntilString\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PC_UnreadLastToken(source_t *source)\n{\n\tPC_UnreadSourceToken(source, &source->token);\n} //end of the function PC_UnreadLastToken\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PC_UnreadToken(source_t *source, token_t *token)\n{\n\tPC_UnreadSourceToken(source, token);\n} //end of the function PC_UnreadToken\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PC_SetIncludePath(source_t *source, char *path)\n{\n\tstrncpy(source->includepath, path, MAX_PATH);\n\t//add trailing path seperator\n\tif (source->includepath[strlen(source->includepath)-1] != '\\\\' &&\n\t\tsource->includepath[strlen(source->includepath)-1] != '/')\n\t{\n\t\tstrcat(source->includepath, PATHSEPERATOR_STR);\n\t} //end if\n} //end of the function PC_SetIncludePath\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PC_SetPunctuations(source_t *source, punctuation_t *p)\n{\n\tsource->punctuations = p;\n} //end of the function PC_SetPunctuations\n//============================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nsource_t *LoadSourceFile(const char *filename)\n{\n\tsource_t *source;\n\tscript_t *script;\n\n\tPC_InitTokenHeap();\n\n\tscript = LoadScriptFile(filename);\n\tif (!script) return NULL;\n\n\tscript->next = NULL;\n\n\tsource = (source_t *) GetMemory(sizeof(source_t));\n\tCom_Memset(source, 0, sizeof(source_t));\n\n\tstrncpy(source->filename, filename, MAX_PATH);\n\tsource->scriptstack = script;\n\tsource->tokens = NULL;\n\tsource->defines = NULL;\n\tsource->indentstack = NULL;\n\tsource->skip = 0;\n\n#if DEFINEHASHING\n\tsource->definehash = GetClearedMemory(DEFINEHASHSIZE * sizeof(define_t *));\n#endif //DEFINEHASHING\n\tPC_AddGlobalDefinesToSource(source);\n\treturn source;\n} //end of the function LoadSourceFile\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nsource_t *LoadSourceMemory(char *ptr, int length, char *name)\n{\n\tsource_t *source;\n\tscript_t *script;\n\n\tPC_InitTokenHeap();\n\n\tscript = LoadScriptMemory(ptr, length, name);\n\tif (!script) return NULL;\n\tscript->next = NULL;\n\n\tsource = (source_t *) GetMemory(sizeof(source_t));\n\tCom_Memset(source, 0, sizeof(source_t));\n\n\tstrncpy(source->filename, name, MAX_PATH);\n\tsource->scriptstack = script;\n\tsource->tokens = NULL;\n\tsource->defines = NULL;\n\tsource->indentstack = NULL;\n\tsource->skip = 0;\n\n#if DEFINEHASHING\n\tsource->definehash = GetClearedMemory(DEFINEHASHSIZE * sizeof(define_t *));\n#endif //DEFINEHASHING\n\tPC_AddGlobalDefinesToSource(source);\n\treturn source;\n} //end of the function LoadSourceMemory\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid FreeSource(source_t *source)\n{\n\tscript_t *script;\n\ttoken_t *token;\n\tdefine_t *define;\n\tindent_t *indent;\n\tint i;\n\n\t//PC_PrintDefineHashTable(source->definehash);\n\t//free all the scripts\n\twhile(source->scriptstack)\n\t{\n\t\tscript = source->scriptstack;\n\t\tsource->scriptstack = source->scriptstack->next;\n\t\tFreeScript(script);\n\t} //end for\n\t//free all the tokens\n\twhile(source->tokens)\n\t{\n\t\ttoken = source->tokens;\n\t\tsource->tokens = source->tokens->next;\n\t\tPC_FreeToken(token);\n\t} //end for\n#if DEFINEHASHING\n\tfor (i = 0; i < DEFINEHASHSIZE; i++)\n\t{\n\t\twhile(source->definehash[i])\n\t\t{\n\t\t\tdefine = source->definehash[i];\n\t\t\tsource->definehash[i] = source->definehash[i]->hashnext;\n\t\t\tPC_FreeDefine(define);\n\t\t} //end while\n\t} //end for\n#else //DEFINEHASHING\n\t//free all defines\n\twhile(source->defines)\n\t{\n\t\tdefine = source->defines;\n\t\tsource->defines = source->defines->next;\n\t\tPC_FreeDefine(define);\n\t} //end for\n#endif //DEFINEHASHING\n\t//free all indents\n\twhile(source->indentstack)\n\t{\n\t\tindent = source->indentstack;\n\t\tsource->indentstack = source->indentstack->next;\n\t\tFreeMemory(indent);\n\t} //end for\n#if DEFINEHASHING\n\t//\n\tif (source->definehash) FreeMemory(source->definehash);\n#endif //DEFINEHASHING\n\t//free the source itself\n\tFreeMemory(source);\n} //end of the function FreeSource\n//============================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\n\n#define MAX_SOURCEFILES\t\t64\n\nsource_t *sourceFiles[MAX_SOURCEFILES];\n\nint PC_LoadSourceHandle(const char *filename)\n{\n\tsource_t *source;\n\tint i;\n\n\tfor (i = 1; i < MAX_SOURCEFILES; i++)\n\t{\n\t\tif (!sourceFiles[i])\n\t\t\tbreak;\n\t} //end for\n\tif (i >= MAX_SOURCEFILES)\n\t\treturn 0;\n\tPS_SetBaseFolder(\"\");\n\tsource = LoadSourceFile(filename);\n\tif (!source)\n\t\treturn 0;\n\tsourceFiles[i] = source;\n\treturn i;\n} //end of the function PC_LoadSourceHandle\n//============================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_FreeSourceHandle(int handle)\n{\n\tif (handle < 1 || handle >= MAX_SOURCEFILES)\n\t\treturn qfalse;\n\tif (!sourceFiles[handle])\n\t\treturn qfalse;\n\n\tFreeSource(sourceFiles[handle]);\n\tsourceFiles[handle] = NULL;\n\treturn qtrue;\n} //end of the function PC_FreeSourceHandle\n//============================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_ReadTokenHandle(int handle, pc_token_t *pc_token)\n{\n\ttoken_t token;\n\tint ret;\n\n\tif (handle < 1 || handle >= MAX_SOURCEFILES)\n\t\treturn 0;\n\tif (!sourceFiles[handle])\n\t\treturn 0;\n\n\tret = PC_ReadToken(sourceFiles[handle], &token);\n\tstrcpy(pc_token->string, token.string);\n\tpc_token->type = token.type;\n\tpc_token->subtype = token.subtype;\n\tpc_token->intvalue = token.intvalue;\n\tpc_token->floatvalue = token.floatvalue;\n\tif (pc_token->type == TT_STRING)\n\t\tStripDoubleQuotes(pc_token->string);\n\treturn ret;\n} //end of the function PC_ReadTokenHandle\n//============================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PC_SourceFileAndLine(int handle, char *filename, int *line)\n{\n\tif (handle < 1 || handle >= MAX_SOURCEFILES)\n\t\treturn qfalse;\n\tif (!sourceFiles[handle])\n\t\treturn qfalse;\n\n\tstrcpy(filename, sourceFiles[handle]->filename);\n\tif (sourceFiles[handle]->scriptstack)\n\t\t*line = sourceFiles[handle]->scriptstack->line;\n\telse\n\t\t*line = 0;\n\treturn qtrue;\n} //end of the function PC_SourceFileAndLine\n//============================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PC_SetBaseFolder(char *path)\n{\n\tPS_SetBaseFolder(path);\n} //end of the function PC_SetBaseFolder\n//============================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PC_CheckOpenSourceHandles(void)\n{\n\tint i;\n\n\tfor (i = 1; i < MAX_SOURCEFILES; i++)\n\t{\n\t\tif (sourceFiles[i])\n\t\t{\n#ifdef BOTLIB\n\t\t\tbotimport.Print(PRT_ERROR, \"file %s still open in precompiler\\n\", sourceFiles[i]->scriptstack->filename);\n#endif\t//BOTLIB\n\t\t} //end if\n\t} //end for\n} //end of the function PC_CheckOpenSourceHandles\n\n"
  },
  {
    "path": "code/botlib/l_precomp.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tl_precomp.h\n *\n * desc:\t\tpre compiler\n *\n * $Archive: /source/code/botlib/l_precomp.h $\n *\n *****************************************************************************/\n\n#ifndef MAX_PATH\n\t#define MAX_PATH\t\t\tMAX_QPATH\n#endif\n\n#ifndef PATH_SEPERATORSTR\n\t#if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__)\n\t\t#define PATHSEPERATOR_STR\t\t\"\\\\\"\n\t#else\n\t\t#define PATHSEPERATOR_STR\t\t\"/\"\n\t#endif\n#endif\n#ifndef PATH_SEPERATORCHAR\n\t#if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__)\n\t\t#define PATHSEPERATOR_CHAR\t\t'\\\\'\n\t#else\n\t\t#define PATHSEPERATOR_CHAR\t\t'/'\n\t#endif\n#endif\n\n#if defined(BSPC) && !defined(QDECL)\n#define QDECL\n#endif\n\n\n#define DEFINE_FIXED\t\t\t0x0001\n\n#define BUILTIN_LINE\t\t\t1\n#define BUILTIN_FILE\t\t\t2\n#define BUILTIN_DATE\t\t\t3\n#define BUILTIN_TIME\t\t\t4\n#define BUILTIN_STDC\t\t\t5\n\n#define INDENT_IF\t\t\t\t0x0001\n#define INDENT_ELSE\t\t\t\t0x0002\n#define INDENT_ELIF\t\t\t\t0x0004\n#define INDENT_IFDEF\t\t\t0x0008\n#define INDENT_IFNDEF\t\t\t0x0010\n\n//macro definitions\ntypedef struct define_s\n{\n\tchar *name;\t\t\t\t\t\t\t//define name\n\tint flags;\t\t\t\t\t\t\t//define flags\n\tint builtin;\t\t\t\t\t\t// > 0 if builtin define\n\tint numparms;\t\t\t\t\t\t//number of define parameters\n\ttoken_t *parms;\t\t\t\t\t\t//define parameters\n\ttoken_t *tokens;\t\t\t\t\t//macro tokens (possibly containing parm tokens)\n\tstruct define_s *next;\t\t\t\t//next defined macro in a list\n\tstruct define_s *hashnext;\t\t\t//next define in the hash chain\n} define_t;\n\n//indents\n//used for conditional compilation directives:\n//#if, #else, #elif, #ifdef, #ifndef\ntypedef struct indent_s\n{\n\tint type;\t\t\t\t\t\t\t\t//indent type\n\tint skip;\t\t\t\t\t\t\t\t//true if skipping current indent\n\tscript_t *script;\t\t\t\t\t\t//script the indent was in\n\tstruct indent_s *next;\t\t\t\t\t//next indent on the indent stack\n} indent_t;\n\n//source file\ntypedef struct source_s\n{\n\tchar filename[1024];\t\t\t\t\t//file name of the script\n\tchar includepath[1024];\t\t\t\t\t//path to include files\n\tpunctuation_t *punctuations;\t\t\t//punctuations to use\n\tscript_t *scriptstack;\t\t\t\t\t//stack with scripts of the source\n\ttoken_t *tokens;\t\t\t\t\t\t//tokens to read first\n\tdefine_t *defines;\t\t\t\t\t\t//list with macro definitions\n\tdefine_t **definehash;\t\t\t\t\t//hash chain with defines\n\tindent_t *indentstack;\t\t\t\t\t//stack with indents\n\tint skip;\t\t\t\t\t\t\t\t// > 0 if skipping conditional code\n\ttoken_t token;\t\t\t\t\t\t\t//last read token\n} source_t;\n\n\n//read a token from the source\nint PC_ReadToken(source_t *source, token_t *token);\n//expect a certain token\nint PC_ExpectTokenString(source_t *source, char *string);\n//expect a certain token type\nint PC_ExpectTokenType(source_t *source, int type, int subtype, token_t *token);\n//expect a token\nint PC_ExpectAnyToken(source_t *source, token_t *token);\n//returns true when the token is available\nint PC_CheckTokenString(source_t *source, char *string);\n//returns true an reads the token when a token with the given type is available\nint PC_CheckTokenType(source_t *source, int type, int subtype, token_t *token);\n//skip tokens until the given token string is read\nint PC_SkipUntilString(source_t *source, char *string);\n//unread the last token read from the script\nvoid PC_UnreadLastToken(source_t *source);\n//unread the given token\nvoid PC_UnreadToken(source_t *source, token_t *token);\n//read a token only if on the same line, lines are concatenated with a slash\nint PC_ReadLine(source_t *source, token_t *token);\n//returns true if there was a white space in front of the token\nint PC_WhiteSpaceBeforeToken(token_t *token);\n//add a define to the source\nint PC_AddDefine(source_t *source, char *string);\n//add a globals define that will be added to all opened sources\nint PC_AddGlobalDefine(char *string);\n//remove the given global define\nint PC_RemoveGlobalDefine(char *name);\n//remove all globals defines\nvoid PC_RemoveAllGlobalDefines(void);\n//add builtin defines\nvoid PC_AddBuiltinDefines(source_t *source);\n//set the source include path\nvoid PC_SetIncludePath(source_t *source, char *path);\n//set the punction set\nvoid PC_SetPunctuations(source_t *source, punctuation_t *p);\n//set the base folder to load files from\nvoid PC_SetBaseFolder(char *path);\n//load a source file\nsource_t *LoadSourceFile(const char *filename);\n//load a source from memory\nsource_t *LoadSourceMemory(char *ptr, int length, char *name);\n//free the given source\nvoid FreeSource(source_t *source);\n//print a source error\nvoid QDECL SourceError(source_t *source, char *str, ...);\n//print a source warning\nvoid QDECL SourceWarning(source_t *source, char *str, ...);\n\n#ifdef BSPC\n// some of BSPC source does include game/q_shared.h and some does not\n// we define pc_token_s pc_token_t if needed (yes, it's ugly)\n#ifndef __Q_SHARED_H\n#define MAX_TOKENLENGTH\t\t1024\ntypedef struct pc_token_s\n{\n\tint type;\n\tint subtype;\n\tint intvalue;\n\tfloat floatvalue;\n\tchar string[MAX_TOKENLENGTH];\n} pc_token_t;\n#endif //!_Q_SHARED_H\n#endif //BSPC\n\n//\nint PC_LoadSourceHandle(const char *filename);\nint PC_FreeSourceHandle(int handle);\nint PC_ReadTokenHandle(int handle, pc_token_t *pc_token);\nint PC_SourceFileAndLine(int handle, char *filename, int *line);\nvoid PC_CheckOpenSourceHandles(void);\n"
  },
  {
    "path": "code/botlib/l_script.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tl_script.c\n *\n * desc:\t\tlexicographical parser\n *\n * $Archive: /MissionPack/code/botlib/l_script.c $\n *\n *****************************************************************************/\n\n//#define SCREWUP\n//#define BOTLIB\n//#define MEQCC\n//#define BSPC\n\n#ifdef SCREWUP\n#include <stdio.h>\n#include <stdlib.h>\n#include <limits.h>\n#include <string.h>\n#include <stdarg.h>\n#include \"l_memory.h\"\n#include \"l_script.h\"\n\ntypedef enum {qfalse, qtrue}\tqboolean;\n\n#endif //SCREWUP\n\n#ifdef BOTLIB\n//include files for usage in the bot library\n#include \"../game/q_shared.h\"\n#include \"../game/botlib.h\"\n#include \"be_interface.h\"\n#include \"l_script.h\"\n#include \"l_memory.h\"\n#include \"l_log.h\"\n#include \"l_libvar.h\"\n#endif //BOTLIB\n\n#ifdef MEQCC\n//include files for usage in MrElusive's QuakeC Compiler\n#include \"qcc.h\"\n#include \"l_script.h\"\n#include \"l_memory.h\"\n#include \"l_log.h\"\n\n#define qtrue\ttrue\n#define qfalse\tfalse\n#endif //MEQCC\n\n#ifdef BSPC\n//include files for usage in the BSP Converter\n#include \"../bspc/qbsp.h\"\n#include \"../bspc/l_log.h\"\n#include \"../bspc/l_mem.h\"\n\n#define qtrue\ttrue\n#define qfalse\tfalse\n#endif //BSPC\n\n\n#define PUNCTABLE\n\n//longer punctuations first\npunctuation_t default_punctuations[] =\n{\n\t//binary operators\n\t{\">>=\",P_RSHIFT_ASSIGN, NULL},\n\t{\"<<=\",P_LSHIFT_ASSIGN, NULL},\n\t//\n\t{\"...\",P_PARMS, NULL},\n\t//define merge operator\n\t{\"##\",P_PRECOMPMERGE, NULL},\n\t//logic operators\n\t{\"&&\",P_LOGIC_AND, NULL},\n\t{\"||\",P_LOGIC_OR, NULL},\n\t{\">=\",P_LOGIC_GEQ, NULL},\n\t{\"<=\",P_LOGIC_LEQ, NULL},\n\t{\"==\",P_LOGIC_EQ, NULL},\n\t{\"!=\",P_LOGIC_UNEQ, NULL},\n\t//arithmatic operators\n\t{\"*=\",P_MUL_ASSIGN, NULL},\n\t{\"/=\",P_DIV_ASSIGN, NULL},\n\t{\"%=\",P_MOD_ASSIGN, NULL},\n\t{\"+=\",P_ADD_ASSIGN, NULL},\n\t{\"-=\",P_SUB_ASSIGN, NULL},\n\t{\"++\",P_INC, NULL},\n\t{\"--\",P_DEC, NULL},\n\t//binary operators\n\t{\"&=\",P_BIN_AND_ASSIGN, NULL},\n\t{\"|=\",P_BIN_OR_ASSIGN, NULL},\n\t{\"^=\",P_BIN_XOR_ASSIGN, NULL},\n\t{\">>\",P_RSHIFT, NULL},\n\t{\"<<\",P_LSHIFT, NULL},\n\t//reference operators\n\t{\"->\",P_POINTERREF, NULL},\n\t//C++\n\t{\"::\",P_CPP1, NULL},\n\t{\".*\",P_CPP2, NULL},\n\t//arithmatic operators\n\t{\"*\",P_MUL, NULL},\n\t{\"/\",P_DIV, NULL},\n\t{\"%\",P_MOD, NULL},\n\t{\"+\",P_ADD, NULL},\n\t{\"-\",P_SUB, NULL},\n\t{\"=\",P_ASSIGN, NULL},\n\t//binary operators\n\t{\"&\",P_BIN_AND, NULL},\n\t{\"|\",P_BIN_OR, NULL},\n\t{\"^\",P_BIN_XOR, NULL},\n\t{\"~\",P_BIN_NOT, NULL},\n\t//logic operators\n\t{\"!\",P_LOGIC_NOT, NULL},\n\t{\">\",P_LOGIC_GREATER, NULL},\n\t{\"<\",P_LOGIC_LESS, NULL},\n\t//reference operator\n\t{\".\",P_REF, NULL},\n\t//seperators\n\t{\",\",P_COMMA, NULL},\n\t{\";\",P_SEMICOLON, NULL},\n\t//label indication\n\t{\":\",P_COLON, NULL},\n\t//if statement\n\t{\"?\",P_QUESTIONMARK, NULL},\n\t//embracements\n\t{\"(\",P_PARENTHESESOPEN, NULL},\n\t{\")\",P_PARENTHESESCLOSE, NULL},\n\t{\"{\",P_BRACEOPEN, NULL},\n\t{\"}\",P_BRACECLOSE, NULL},\n\t{\"[\",P_SQBRACKETOPEN, NULL},\n\t{\"]\",P_SQBRACKETCLOSE, NULL},\n\t//\n\t{\"\\\\\",P_BACKSLASH, NULL},\n\t//precompiler operator\n\t{\"#\",P_PRECOMP, NULL},\n#ifdef DOLLAR\n\t{\"$\",P_DOLLAR, NULL},\n#endif //DOLLAR\n\t{NULL, 0}\n};\n\n#ifdef BSPC\nchar basefolder[MAX_PATH];\n#else\nchar basefolder[MAX_QPATH];\n#endif\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid PS_CreatePunctuationTable(script_t *script, punctuation_t *punctuations)\n{\n\tint i;\n\tpunctuation_t *p, *lastp, *newp;\n\n\t//get memory for the table\n\tif (!script->punctuationtable) script->punctuationtable = (punctuation_t **)\n\t\t\t\t\t\t\t\t\t\t\t\tGetMemory(256 * sizeof(punctuation_t *));\n\tCom_Memset(script->punctuationtable, 0, 256 * sizeof(punctuation_t *));\n\t//add the punctuations in the list to the punctuation table\n\tfor (i = 0; punctuations[i].p; i++)\n\t{\n\t\tnewp = &punctuations[i];\n\t\tlastp = NULL;\n\t\t//sort the punctuations in this table entry on length (longer punctuations first)\n\t\tfor (p = script->punctuationtable[(unsigned int) newp->p[0]]; p; p = p->next)\n\t\t{\n\t\t\tif (strlen(p->p) < strlen(newp->p))\n\t\t\t{\n\t\t\t\tnewp->next = p;\n\t\t\t\tif (lastp) lastp->next = newp;\n\t\t\t\telse script->punctuationtable[(unsigned int) newp->p[0]] = newp;\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t\tlastp = p;\n\t\t} //end for\n\t\tif (!p)\n\t\t{\n\t\t\tnewp->next = NULL;\n\t\t\tif (lastp) lastp->next = newp;\n\t\t\telse script->punctuationtable[(unsigned int) newp->p[0]] = newp;\n\t\t} //end if\n\t} //end for\n} //end of the function PS_CreatePunctuationTable\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nchar *PunctuationFromNum(script_t *script, int num)\n{\n\tint i;\n\n\tfor (i = 0; script->punctuations[i].p; i++)\n\t{\n\t\tif (script->punctuations[i].n == num) return script->punctuations[i].p;\n\t} //end for\n\treturn \"unkown punctuation\";\n} //end of the function PunctuationFromNum\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid QDECL ScriptError(script_t *script, char *str, ...)\n{\n\tchar text[1024];\n\tva_list ap;\n\n\tif (script->flags & SCFL_NOERRORS) return;\n\n\tva_start(ap, str);\n\tvsprintf(text, str, ap);\n\tva_end(ap);\n#ifdef BOTLIB\n\tbotimport.Print(PRT_ERROR, \"file %s, line %d: %s\\n\", script->filename, script->line, text);\n#endif //BOTLIB\n#ifdef MEQCC\n\tprintf(\"error: file %s, line %d: %s\\n\", script->filename, script->line, text);\n#endif //MEQCC\n#ifdef BSPC\n\tLog_Print(\"error: file %s, line %d: %s\\n\", script->filename, script->line, text);\n#endif //BSPC\n} //end of the function ScriptError\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid QDECL ScriptWarning(script_t *script, char *str, ...)\n{\n\tchar text[1024];\n\tva_list ap;\n\n\tif (script->flags & SCFL_NOWARNINGS) return;\n\n\tva_start(ap, str);\n\tvsprintf(text, str, ap);\n\tva_end(ap);\n#ifdef BOTLIB\n\tbotimport.Print(PRT_WARNING, \"file %s, line %d: %s\\n\", script->filename, script->line, text);\n#endif //BOTLIB\n#ifdef MEQCC\n\tprintf(\"warning: file %s, line %d: %s\\n\", script->filename, script->line, text);\n#endif //MEQCC\n#ifdef BSPC\n\tLog_Print(\"warning: file %s, line %d: %s\\n\", script->filename, script->line, text);\n#endif //BSPC\n} //end of the function ScriptWarning\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid SetScriptPunctuations(script_t *script, punctuation_t *p)\n{\n#ifdef PUNCTABLE\n\tif (p) PS_CreatePunctuationTable(script, p);\n\telse  PS_CreatePunctuationTable(script, default_punctuations);\n#endif //PUNCTABLE\n\tif (p) script->punctuations = p;\n\telse script->punctuations = default_punctuations;\n} //end of the function SetScriptPunctuations\n//============================================================================\n// Reads spaces, tabs, C-like comments etc.\n// When a newline character is found the scripts line counter is increased.\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PS_ReadWhiteSpace(script_t *script)\n{\n\twhile(1)\n\t{\n\t\t//skip white space\n\t\twhile(*script->script_p <= ' ')\n\t\t{\n\t\t\tif (!*script->script_p) return 0;\n\t\t\tif (*script->script_p == '\\n') script->line++;\n\t\t\tscript->script_p++;\n\t\t} //end while\n\t\t//skip comments\n\t\tif (*script->script_p == '/')\n\t\t{\n\t\t\t//comments //\n\t\t\tif (*(script->script_p+1) == '/')\n\t\t\t{\n\t\t\t\tscript->script_p++;\n\t\t\t\tdo\n\t\t\t\t{\n\t\t\t\t\tscript->script_p++;\n\t\t\t\t\tif (!*script->script_p) return 0;\n\t\t\t\t} //end do\n\t\t\t\twhile(*script->script_p != '\\n');\n\t\t\t\tscript->line++;\n\t\t\t\tscript->script_p++;\n\t\t\t\tif (!*script->script_p) return 0;\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\t//comments /* */\n\t\t\telse if (*(script->script_p+1) == '*')\n\t\t\t{\n\t\t\t\tscript->script_p++;\n\t\t\t\tdo\n\t\t\t\t{\n\t\t\t\t\tscript->script_p++;\n\t\t\t\t\tif (!*script->script_p) return 0;\n\t\t\t\t\tif (*script->script_p == '\\n') script->line++;\n\t\t\t\t} //end do\n\t\t\t\twhile(!(*script->script_p == '*' && *(script->script_p+1) == '/'));\n\t\t\t\tscript->script_p++;\n\t\t\t\tif (!*script->script_p) return 0;\n\t\t\t\tscript->script_p++;\n\t\t\t\tif (!*script->script_p) return 0;\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t} //end if\n\t\tbreak;\n\t} //end while\n\treturn 1;\n} //end of the function PS_ReadWhiteSpace\n//============================================================================\n// Reads an escape character.\n//\n// Parameter:\t\t\t\tscript\t\t: script to read from\n//\t\t\t\t\t\t\t\tch\t\t\t\t: place to store the read escape character\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PS_ReadEscapeCharacter(script_t *script, char *ch)\n{\n\tint c, val, i;\n\n\t//step over the leading '\\\\'\n\tscript->script_p++;\n\t//determine the escape character\n\tswitch(*script->script_p)\n\t{\n\t\tcase '\\\\': c = '\\\\'; break;\n\t\tcase 'n': c = '\\n'; break;\n\t\tcase 'r': c = '\\r'; break;\n\t\tcase 't': c = '\\t'; break;\n\t\tcase 'v': c = '\\v'; break;\n\t\tcase 'b': c = '\\b'; break;\n\t\tcase 'f': c = '\\f'; break;\n\t\tcase 'a': c = '\\a'; break;\n\t\tcase '\\'': c = '\\''; break;\n\t\tcase '\\\"': c = '\\\"'; break;\n\t\tcase '\\?': c = '\\?'; break;\n\t\tcase 'x':\n\t\t{\n\t\t\tscript->script_p++;\n\t\t\tfor (i = 0, val = 0; ; i++, script->script_p++)\n\t\t\t{\n\t\t\t\tc = *script->script_p;\n\t\t\t\tif (c >= '0' && c <= '9') c = c - '0';\n\t\t\t\telse if (c >= 'A' && c <= 'Z') c = c - 'A' + 10;\n\t\t\t\telse if (c >= 'a' && c <= 'z') c = c - 'a' + 10;\n\t\t\t\telse break;\n\t\t\t\tval = (val << 4) + c;\n\t\t\t} //end for\n\t\t\tscript->script_p--;\n\t\t\tif (val > 0xFF)\n\t\t\t{\n\t\t\t\tScriptWarning(script, \"too large value in escape character\");\n\t\t\t\tval = 0xFF;\n\t\t\t} //end if\n\t\t\tc = val;\n\t\t\tbreak;\n\t\t} //end case\n\t\tdefault: //NOTE: decimal ASCII code, NOT octal\n\t\t{\n\t\t\tif (*script->script_p < '0' || *script->script_p > '9') ScriptError(script, \"unknown escape char\");\n\t\t\tfor (i = 0, val = 0; ; i++, script->script_p++)\n\t\t\t{\n\t\t\t\tc = *script->script_p;\n\t\t\t\tif (c >= '0' && c <= '9') c = c - '0';\n\t\t\t\telse break;\n\t\t\t\tval = val * 10 + c;\n\t\t\t} //end for\n\t\t\tscript->script_p--;\n\t\t\tif (val > 0xFF)\n\t\t\t{\n\t\t\t\tScriptWarning(script, \"too large value in escape character\");\n\t\t\t\tval = 0xFF;\n\t\t\t} //end if\n\t\t\tc = val;\n\t\t\tbreak;\n\t\t} //end default\n\t} //end switch\n\t//step over the escape character or the last digit of the number\n\tscript->script_p++;\n\t//store the escape character\n\t*ch = c;\n\t//succesfully read escape character\n\treturn 1;\n} //end of the function PS_ReadEscapeCharacter\n//============================================================================\n// Reads C-like string. Escape characters are interpretted.\n// Quotes are included with the string.\n// Reads two strings with a white space between them as one string.\n//\n// Parameter:\t\t\t\tscript\t\t: script to read from\n//\t\t\t\t\t\t\t\ttoken\t\t\t: buffer to store the string\n// Returns:\t\t\t\t\tqtrue when a string was read succesfully\n// Changes Globals:\t\t-\n//============================================================================\nint PS_ReadString(script_t *script, token_t *token, int quote)\n{\n\tint len, tmpline;\n\tchar *tmpscript_p;\n\n\tif (quote == '\\\"') token->type = TT_STRING;\n\telse token->type = TT_LITERAL;\n\n\tlen = 0;\n\t//leading quote\n\ttoken->string[len++] = *script->script_p++;\n\t//\n\twhile(1)\n\t{\n\t\t//minus 2 because trailing double quote and zero have to be appended\n\t\tif (len >= MAX_TOKEN - 2)\n\t\t{\n\t\t\tScriptError(script, \"string longer than MAX_TOKEN = %d\", MAX_TOKEN);\n\t\t\treturn 0;\n\t\t} //end if\n\t\t//if there is an escape character and\n\t\t//if escape characters inside a string are allowed\n\t\tif (*script->script_p == '\\\\' && !(script->flags & SCFL_NOSTRINGESCAPECHARS))\n\t\t{\n\t\t\tif (!PS_ReadEscapeCharacter(script, &token->string[len]))\n\t\t\t{\n\t\t\t\ttoken->string[len] = 0;\n\t\t\t\treturn 0;\n\t\t\t} //end if\n\t\t\tlen++;\n\t\t} //end if\n\t\t//if a trailing quote\n\t\telse if (*script->script_p == quote)\n\t\t{\n\t\t\t//step over the double quote\n\t\t\tscript->script_p++;\n\t\t\t//if white spaces in a string are not allowed\n\t\t\tif (script->flags & SCFL_NOSTRINGWHITESPACES) break;\n\t\t\t//\n\t\t\ttmpscript_p = script->script_p;\n\t\t\ttmpline = script->line;\n\t\t\t//read unusefull stuff between possible two following strings\n\t\t\tif (!PS_ReadWhiteSpace(script))\n\t\t\t{\n\t\t\t\tscript->script_p = tmpscript_p;\n\t\t\t\tscript->line = tmpline;\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t\t//if there's no leading double qoute\n\t\t\tif (*script->script_p != quote)\n\t\t\t{\n\t\t\t\tscript->script_p = tmpscript_p;\n\t\t\t\tscript->line = tmpline;\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t\t//step over the new leading double quote\n\t\t\tscript->script_p++;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tif (*script->script_p == '\\0')\n\t\t\t{\n\t\t\t\ttoken->string[len] = 0;\n\t\t\t\tScriptError(script, \"missing trailing quote\");\n\t\t\t\treturn 0;\n\t\t\t} //end if\n\t      if (*script->script_p == '\\n')\n\t\t\t{\n\t\t\t\ttoken->string[len] = 0;\n\t\t\t\tScriptError(script, \"newline inside string %s\", token->string);\n\t\t\t\treturn 0;\n\t\t\t} //end if\n\t\t\ttoken->string[len++] = *script->script_p++;\n\t\t} //end else\n\t} //end while\n\t//trailing quote\n\ttoken->string[len++] = quote;\n\t//end string with a zero\n\ttoken->string[len] = '\\0';\n\t//the sub type is the length of the string\n\ttoken->subtype = len;\n\treturn 1;\n} //end of the function PS_ReadString\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PS_ReadName(script_t *script, token_t *token)\n{\n\tint len = 0;\n\tchar c;\n\n\ttoken->type = TT_NAME;\n\tdo\n\t{\n\t\ttoken->string[len++] = *script->script_p++;\n\t\tif (len >= MAX_TOKEN)\n\t\t{\n\t\t\tScriptError(script, \"name longer than MAX_TOKEN = %d\", MAX_TOKEN);\n\t\t\treturn 0;\n\t\t} //end if\n\t\tc = *script->script_p;\n   } while ((c >= 'a' && c <= 'z') ||\n\t\t\t\t(c >= 'A' && c <= 'Z') ||\n\t\t\t\t(c >= '0' && c <= '9') ||\n\t\t\t\tc == '_');\n\ttoken->string[len] = '\\0';\n\t//the sub type is the length of the name\n\ttoken->subtype = len;\n\treturn 1;\n} //end of the function PS_ReadName\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid NumberValue(char *string, int subtype, unsigned long int *intvalue,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlong double *floatvalue)\n{\n\tunsigned long int dotfound = 0;\n\n\t*intvalue = 0;\n\t*floatvalue = 0;\n\t//floating point number\n\tif (subtype & TT_FLOAT)\n\t{\n\t\twhile(*string)\n\t\t{\n\t\t\tif (*string == '.')\n\t\t\t{\n\t\t\t\tif (dotfound) return;\n\t\t\t\tdotfound = 10;\n\t\t\t\tstring++;\n\t\t\t} //end if\n\t\t\tif (dotfound)\n\t\t\t{\n\t\t\t\t*floatvalue = *floatvalue + (long double) (*string - '0') /\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(long double) dotfound;\n\t\t\t\tdotfound *= 10;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\t*floatvalue = *floatvalue * 10.0 + (long double) (*string - '0');\n\t\t\t} //end else\n\t\t\tstring++;\n\t\t} //end while\n\t\t*intvalue = (unsigned long) *floatvalue;\n\t} //end if\n\telse if (subtype & TT_DECIMAL)\n\t{\n\t\twhile(*string) *intvalue = *intvalue * 10 + (*string++ - '0');\n\t\t*floatvalue = *intvalue;\n\t} //end else if\n\telse if (subtype & TT_HEX)\n\t{\n\t\t//step over the leading 0x or 0X\n\t\tstring += 2;\n\t\twhile(*string)\n\t\t{\n\t\t\t*intvalue <<= 4;\n\t\t\tif (*string >= 'a' && *string <= 'f') *intvalue += *string - 'a' + 10;\n\t\t\telse if (*string >= 'A' && *string <= 'F') *intvalue += *string - 'A' + 10;\n\t\t\telse *intvalue += *string - '0';\n\t\t\tstring++;\n\t\t} //end while\n\t\t*floatvalue = *intvalue;\n\t} //end else if\n\telse if (subtype & TT_OCTAL)\n\t{\n\t\t//step over the first zero\n\t\tstring += 1;\n\t\twhile(*string) *intvalue = (*intvalue << 3) + (*string++ - '0');\n\t\t*floatvalue = *intvalue;\n\t} //end else if\n\telse if (subtype & TT_BINARY)\n\t{\n\t\t//step over the leading 0b or 0B\n\t\tstring += 2;\n\t\twhile(*string) *intvalue = (*intvalue << 1) + (*string++ - '0');\n\t\t*floatvalue = *intvalue;\n\t} //end else if\n} //end of the function NumberValue\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PS_ReadNumber(script_t *script, token_t *token)\n{\n\tint len = 0, i;\n\tint octal, dot;\n\tchar c;\n//\tunsigned long int intvalue = 0;\n//\tlong double floatvalue = 0;\n\n\ttoken->type = TT_NUMBER;\n\t//check for a hexadecimal number\n\tif (*script->script_p == '0' &&\n\t\t(*(script->script_p + 1) == 'x' ||\n\t\t*(script->script_p + 1) == 'X'))\n\t{\n\t\ttoken->string[len++] = *script->script_p++;\n\t\ttoken->string[len++] = *script->script_p++;\n\t\tc = *script->script_p;\n\t\t//hexadecimal\n\t\twhile((c >= '0' && c <= '9') ||\n\t\t\t\t\t(c >= 'a' && c <= 'f') ||\n\t\t\t\t\t(c >= 'A' && c <= 'A'))\n\t\t{\n\t\t\ttoken->string[len++] = *script->script_p++;\n\t\t\tif (len >= MAX_TOKEN)\n\t\t\t{\n\t\t\t\tScriptError(script, \"hexadecimal number longer than MAX_TOKEN = %d\", MAX_TOKEN);\n\t\t\t\treturn 0;\n\t\t\t} //end if\n\t\t\tc = *script->script_p;\n\t\t} //end while\n\t\ttoken->subtype |= TT_HEX;\n\t} //end if\n#ifdef BINARYNUMBERS\n\t//check for a binary number\n\telse if (*script->script_p == '0' &&\n\t\t(*(script->script_p + 1) == 'b' ||\n\t\t*(script->script_p + 1) == 'B'))\n\t{\n\t\ttoken->string[len++] = *script->script_p++;\n\t\ttoken->string[len++] = *script->script_p++;\n\t\tc = *script->script_p;\n\t\t//binary\n\t\twhile(c == '0' || c == '1')\n\t\t{\n\t\t\ttoken->string[len++] = *script->script_p++;\n\t\t\tif (len >= MAX_TOKEN)\n\t\t\t{\n\t\t\t\tScriptError(script, \"binary number longer than MAX_TOKEN = %d\", MAX_TOKEN);\n\t\t\t\treturn 0;\n\t\t\t} //end if\n\t\t\tc = *script->script_p;\n\t\t} //end while\n\t\ttoken->subtype |= TT_BINARY;\n\t} //end if\n#endif //BINARYNUMBERS\n\telse //decimal or octal integer or floating point number\n\t{\n\t\toctal = qfalse;\n\t\tdot = qfalse;\n\t\tif (*script->script_p == '0') octal = qtrue;\n\t\twhile(1)\n\t\t{\n\t\t\tc = *script->script_p;\n\t\t\tif (c == '.') dot = qtrue;\n\t\t\telse if (c == '8' || c == '9') octal = qfalse;\n\t\t\telse if (c < '0' || c > '9') break;\n\t\t\ttoken->string[len++] = *script->script_p++;\n\t\t\tif (len >= MAX_TOKEN - 1)\n\t\t\t{\n\t\t\t\tScriptError(script, \"number longer than MAX_TOKEN = %d\", MAX_TOKEN);\n\t\t\t\treturn 0;\n\t\t\t} //end if\n\t\t} //end while\n\t\tif (octal) token->subtype |= TT_OCTAL;\n\t\telse token->subtype |= TT_DECIMAL;\n\t\tif (dot) token->subtype |= TT_FLOAT;\n\t} //end else\n\tfor (i = 0; i < 2; i++)\n\t{\n\t\tc = *script->script_p;\n\t\t//check for a LONG number\n\t\tif ( (c == 'l' || c == 'L') // bk001204 - brackets \n\t\t     && !(token->subtype & TT_LONG))\n\t\t{\n\t\t\tscript->script_p++;\n\t\t\ttoken->subtype |= TT_LONG;\n\t\t} //end if\n\t\t//check for an UNSIGNED number\n\t\telse if ( (c == 'u' || c == 'U') // bk001204 - brackets \n\t\t\t  && !(token->subtype & (TT_UNSIGNED | TT_FLOAT)))\n\t\t{\n\t\t\tscript->script_p++;\n\t\t\ttoken->subtype |= TT_UNSIGNED;\n\t\t} //end if\n\t} //end for\n\ttoken->string[len] = '\\0';\n#ifdef NUMBERVALUE\n\tNumberValue(token->string, token->subtype, &token->intvalue, &token->floatvalue);\n#endif //NUMBERVALUE\n\tif (!(token->subtype & TT_FLOAT)) token->subtype |= TT_INTEGER;\n\treturn 1;\n} //end of the function PS_ReadNumber\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PS_ReadLiteral(script_t *script, token_t *token)\n{\n\ttoken->type = TT_LITERAL;\n\t//first quote\n\ttoken->string[0] = *script->script_p++;\n\t//check for end of file\n\tif (!*script->script_p)\n\t{\n\t\tScriptError(script, \"end of file before trailing \\'\");\n\t\treturn 0;\n\t} //end if\n\t//if it is an escape character\n\tif (*script->script_p == '\\\\')\n\t{\n\t\tif (!PS_ReadEscapeCharacter(script, &token->string[1])) return 0;\n\t} //end if\n\telse\n\t{\n\t\ttoken->string[1] = *script->script_p++;\n\t} //end else\n\t//check for trailing quote\n\tif (*script->script_p != '\\'')\n\t{\n\t\tScriptWarning(script, \"too many characters in literal, ignored\");\n\t\twhile(*script->script_p &&\n\t\t\t\t*script->script_p != '\\'' &&\n\t\t\t\t*script->script_p != '\\n')\n\t\t{\n\t\t\tscript->script_p++;\n\t\t} //end while\n\t\tif (*script->script_p == '\\'') script->script_p++;\n\t} //end if\n\t//store the trailing quote\n\ttoken->string[2] = *script->script_p++;\n\t//store trailing zero to end the string\n\ttoken->string[3] = '\\0';\n\t//the sub type is the integer literal value\n\ttoken->subtype = token->string[1];\n\t//\n\treturn 1;\n} //end of the function PS_ReadLiteral\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PS_ReadPunctuation(script_t *script, token_t *token)\n{\n\tint len;\n\tchar *p;\n\tpunctuation_t *punc;\n\n#ifdef PUNCTABLE\n\tfor (punc = script->punctuationtable[(unsigned int)*script->script_p]; punc; punc = punc->next)\n\t{\n#else\n\tint i;\n\n\tfor (i = 0; script->punctuations[i].p; i++)\n\t{\n\t\tpunc = &script->punctuations[i];\n#endif //PUNCTABLE\n\t\tp = punc->p;\n\t\tlen = strlen(p);\n\t\t//if the script contains at least as much characters as the punctuation\n\t\tif (script->script_p + len <= script->end_p)\n\t\t{\n\t\t\t//if the script contains the punctuation\n\t\t\tif (!strncmp(script->script_p, p, len))\n\t\t\t{\n\t\t\t\tstrncpy(token->string, p, MAX_TOKEN);\n\t\t\t\tscript->script_p += len;\n\t\t\t\ttoken->type = TT_PUNCTUATION;\n\t\t\t\t//sub type is the number of the punctuation\n\t\t\t\ttoken->subtype = punc->n;\n\t\t\t\treturn 1;\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n\treturn 0;\n} //end of the function PS_ReadPunctuation\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PS_ReadPrimitive(script_t *script, token_t *token)\n{\n\tint len;\n\n\tlen = 0;\n\twhile(*script->script_p > ' ' && *script->script_p != ';')\n\t{\n\t\tif (len >= MAX_TOKEN)\n\t\t{\n\t\t\tScriptError(script, \"primitive token longer than MAX_TOKEN = %d\", MAX_TOKEN);\n\t\t\treturn 0;\n\t\t} //end if\n\t\ttoken->string[len++] = *script->script_p++;\n\t} //end while\n\ttoken->string[len] = 0;\n\t//copy the token into the script structure\n\tCom_Memcpy(&script->token, token, sizeof(token_t));\n\t//primitive reading successfull\n\treturn 1;\n} //end of the function PS_ReadPrimitive\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PS_ReadToken(script_t *script, token_t *token)\n{\n\t//if there is a token available (from UnreadToken)\n\tif (script->tokenavailable)\n\t{\n\t\tscript->tokenavailable = 0;\n\t\tCom_Memcpy(token, &script->token, sizeof(token_t));\n\t\treturn 1;\n\t} //end if\n\t//save script pointer\n\tscript->lastscript_p = script->script_p;\n\t//save line counter\n\tscript->lastline = script->line;\n\t//clear the token stuff\n\tCom_Memset(token, 0, sizeof(token_t));\n\t//start of the white space\n\tscript->whitespace_p = script->script_p;\n\ttoken->whitespace_p = script->script_p;\n\t//read unusefull stuff\n\tif (!PS_ReadWhiteSpace(script)) return 0;\n\t//end of the white space\n\tscript->endwhitespace_p = script->script_p;\n\ttoken->endwhitespace_p = script->script_p;\n\t//line the token is on\n\ttoken->line = script->line;\n\t//number of lines crossed before token\n\ttoken->linescrossed = script->line - script->lastline;\n\t//if there is a leading double quote\n\tif (*script->script_p == '\\\"')\n\t{\n\t\tif (!PS_ReadString(script, token, '\\\"')) return 0;\n\t} //end if\n\t//if an literal\n\telse if (*script->script_p == '\\'')\n\t{\n\t\t//if (!PS_ReadLiteral(script, token)) return 0;\n\t\tif (!PS_ReadString(script, token, '\\'')) return 0;\n\t} //end if\n\t//if there is a number\n\telse if ((*script->script_p >= '0' && *script->script_p <= '9') ||\n\t\t\t\t(*script->script_p == '.' &&\n\t\t\t\t(*(script->script_p + 1) >= '0' && *(script->script_p + 1) <= '9')))\n\t{\n\t\tif (!PS_ReadNumber(script, token)) return 0;\n\t} //end if\n\t//if this is a primitive script\n\telse if (script->flags & SCFL_PRIMITIVE)\n\t{\n\t\treturn PS_ReadPrimitive(script, token);\n\t} //end else if\n\t//if there is a name\n\telse if ((*script->script_p >= 'a' && *script->script_p <= 'z') ||\n\t\t(*script->script_p >= 'A' && *script->script_p <= 'Z') ||\n\t\t*script->script_p == '_')\n\t{\n\t\tif (!PS_ReadName(script, token)) return 0;\n\t} //end if\n\t//check for punctuations\n\telse if (!PS_ReadPunctuation(script, token))\n\t{\n\t\tScriptError(script, \"can't read token\");\n\t\treturn 0;\n\t} //end if\n\t//copy the token into the script structure\n\tCom_Memcpy(&script->token, token, sizeof(token_t));\n\t//succesfully read a token\n\treturn 1;\n} //end of the function PS_ReadToken\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PS_ExpectTokenString(script_t *script, char *string)\n{\n\ttoken_t token;\n\n\tif (!PS_ReadToken(script, &token))\n\t{\n\t\tScriptError(script, \"couldn't find expected %s\", string);\n\t\treturn 0;\n\t} //end if\n\n\tif (strcmp(token.string, string))\n\t{\n\t\tScriptError(script, \"expected %s, found %s\", string, token.string);\n\t\treturn 0;\n\t} //end if\n\treturn 1;\n} //end of the function PS_ExpectToken\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PS_ExpectTokenType(script_t *script, int type, int subtype, token_t *token)\n{\n\tchar str[MAX_TOKEN];\n\n\tif (!PS_ReadToken(script, token))\n\t{\n\t\tScriptError(script, \"couldn't read expected token\");\n\t\treturn 0;\n\t} //end if\n\n\tif (token->type != type)\n\t{\n\t\tif (type == TT_STRING) strcpy(str, \"string\");\n\t\tif (type == TT_LITERAL) strcpy(str, \"literal\");\n\t\tif (type == TT_NUMBER) strcpy(str, \"number\");\n\t\tif (type == TT_NAME) strcpy(str, \"name\");\n\t\tif (type == TT_PUNCTUATION) strcpy(str, \"punctuation\");\n\t\tScriptError(script, \"expected a %s, found %s\", str, token->string);\n\t\treturn 0;\n\t} //end if\n\tif (token->type == TT_NUMBER)\n\t{\n\t\tif ((token->subtype & subtype) != subtype)\n\t\t{\n\t\t\tif (subtype & TT_DECIMAL) strcpy(str, \"decimal\");\n\t\t\tif (subtype & TT_HEX) strcpy(str, \"hex\");\n\t\t\tif (subtype & TT_OCTAL) strcpy(str, \"octal\");\n\t\t\tif (subtype & TT_BINARY) strcpy(str, \"binary\");\n\t\t\tif (subtype & TT_LONG) strcat(str, \" long\");\n\t\t\tif (subtype & TT_UNSIGNED) strcat(str, \" unsigned\");\n\t\t\tif (subtype & TT_FLOAT) strcat(str, \" float\");\n\t\t\tif (subtype & TT_INTEGER) strcat(str, \" integer\");\n\t\t\tScriptError(script, \"expected %s, found %s\", str, token->string);\n\t\t\treturn 0;\n\t\t} //end if\n\t} //end if\n\telse if (token->type == TT_PUNCTUATION)\n\t{\n\t\tif (subtype < 0)\n\t\t{\n\t\t\tScriptError(script, \"BUG: wrong punctuation subtype\");\n\t\t\treturn 0;\n\t\t} //end if\n\t\tif (token->subtype != subtype)\n\t\t{\n\t\t\tScriptError(script, \"expected %s, found %s\",\n\t\t\t\t\t\t\tscript->punctuations[subtype], token->string);\n\t\t\treturn 0;\n\t\t} //end if\n\t} //end else if\n\treturn 1;\n} //end of the function PS_ExpectTokenType\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PS_ExpectAnyToken(script_t *script, token_t *token)\n{\n\tif (!PS_ReadToken(script, token))\n\t{\n\t\tScriptError(script, \"couldn't read expected token\");\n\t\treturn 0;\n\t} //end if\n\telse\n\t{\n\t\treturn 1;\n\t} //end else\n} //end of the function PS_ExpectAnyToken\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PS_CheckTokenString(script_t *script, char *string)\n{\n\ttoken_t tok;\n\n\tif (!PS_ReadToken(script, &tok)) return 0;\n\t//if the token is available\n\tif (!strcmp(tok.string, string)) return 1;\n\t//token not available\n\tscript->script_p = script->lastscript_p;\n\treturn 0;\n} //end of the function PS_CheckTokenString\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PS_CheckTokenType(script_t *script, int type, int subtype, token_t *token)\n{\n\ttoken_t tok;\n\n\tif (!PS_ReadToken(script, &tok)) return 0;\n\t//if the type matches\n\tif (tok.type == type &&\n\t\t\t(tok.subtype & subtype) == subtype)\n\t{\n\t\tCom_Memcpy(token, &tok, sizeof(token_t));\n\t\treturn 1;\n\t} //end if\n\t//token is not available\n\tscript->script_p = script->lastscript_p;\n\treturn 0;\n} //end of the function PS_CheckTokenType\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint PS_SkipUntilString(script_t *script, char *string)\n{\n\ttoken_t token;\n\n\twhile(PS_ReadToken(script, &token))\n\t{\n\t\tif (!strcmp(token.string, string)) return 1;\n\t} //end while\n\treturn 0;\n} //end of the function PS_SkipUntilString\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PS_UnreadLastToken(script_t *script)\n{\n\tscript->tokenavailable = 1;\n} //end of the function UnreadLastToken\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PS_UnreadToken(script_t *script, token_t *token)\n{\n\tCom_Memcpy(&script->token, token, sizeof(token_t));\n\tscript->tokenavailable = 1;\n} //end of the function UnreadToken\n//============================================================================\n// returns the next character of the read white space, returns NULL if none\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nchar PS_NextWhiteSpaceChar(script_t *script)\n{\n\tif (script->whitespace_p != script->endwhitespace_p)\n\t{\n\t\treturn *script->whitespace_p++;\n\t} //end if\n\telse\n\t{\n\t\treturn 0;\n\t} //end else\n} //end of the function PS_NextWhiteSpaceChar\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid StripDoubleQuotes(char *string)\n{\n\tif (*string == '\\\"')\n\t{\n\t\tstrcpy(string, string+1);\n\t} //end if\n\tif (string[strlen(string)-1] == '\\\"')\n\t{\n\t\tstring[strlen(string)-1] = '\\0';\n\t} //end if\n} //end of the function StripDoubleQuotes\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid StripSingleQuotes(char *string)\n{\n\tif (*string == '\\'')\n\t{\n\t\tstrcpy(string, string+1);\n\t} //end if\n\tif (string[strlen(string)-1] == '\\'')\n\t{\n\t\tstring[strlen(string)-1] = '\\0';\n\t} //end if\n} //end of the function StripSingleQuotes\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nlong double ReadSignedFloat(script_t *script)\n{\n\ttoken_t token;\n\tlong double sign = 1;\n\n\tPS_ExpectAnyToken(script, &token);\n\tif (!strcmp(token.string, \"-\"))\n\t{\n\t\tsign = -1;\n\t\tPS_ExpectTokenType(script, TT_NUMBER, 0, &token);\n\t} //end if\n\telse if (token.type != TT_NUMBER)\n\t{\n\t\tScriptError(script, \"expected float value, found %s\\n\", token.string);\n\t} //end else if\n\treturn sign * token.floatvalue;\n} //end of the function ReadSignedFloat\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nsigned long int ReadSignedInt(script_t *script)\n{\n\ttoken_t token;\n\tsigned long int sign = 1;\n\n\tPS_ExpectAnyToken(script, &token);\n\tif (!strcmp(token.string, \"-\"))\n\t{\n\t\tsign = -1;\n\t\tPS_ExpectTokenType(script, TT_NUMBER, TT_INTEGER, &token);\n\t} //end if\n\telse if (token.type != TT_NUMBER || token.subtype == TT_FLOAT)\n\t{\n\t\tScriptError(script, \"expected integer value, found %s\\n\", token.string);\n\t} //end else if\n\treturn sign * token.intvalue;\n} //end of the function ReadSignedInt\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid SetScriptFlags(script_t *script, int flags)\n{\n\tscript->flags = flags;\n} //end of the function SetScriptFlags\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint GetScriptFlags(script_t *script)\n{\n\treturn script->flags;\n} //end of the function GetScriptFlags\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid ResetScript(script_t *script)\n{\n\t//pointer in script buffer\n\tscript->script_p = script->buffer;\n\t//pointer in script buffer before reading token\n\tscript->lastscript_p = script->buffer;\n\t//begin of white space\n\tscript->whitespace_p = NULL;\n\t//end of white space\n\tscript->endwhitespace_p = NULL;\n\t//set if there's a token available in script->token\n\tscript->tokenavailable = 0;\n\t//\n\tscript->line = 1;\n\tscript->lastline = 1;\n\t//clear the saved token\n\tCom_Memset(&script->token, 0, sizeof(token_t));\n} //end of the function ResetScript\n//============================================================================\n// returns true if at the end of the script\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint EndOfScript(script_t *script)\n{\n\treturn script->script_p >= script->end_p;\n} //end of the function EndOfScript\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint NumLinesCrossed(script_t *script)\n{\n\treturn script->line - script->lastline;\n} //end of the function NumLinesCrossed\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint ScriptSkipTo(script_t *script, char *value)\n{\n\tint len;\n\tchar firstchar;\n\n\tfirstchar = *value;\n\tlen = strlen(value);\n\tdo\n\t{\n\t\tif (!PS_ReadWhiteSpace(script)) return 0;\n\t\tif (*script->script_p == firstchar)\n\t\t{\n\t\t\tif (!strncmp(script->script_p, value, len))\n\t\t\t{\n\t\t\t\treturn 1;\n\t\t\t} //end if\n\t\t} //end if\n\t\tscript->script_p++;\n\t} while(1);\n} //end of the function ScriptSkipTo\n#ifndef BOTLIB\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nint FileLength(FILE *fp)\n{\n\tint pos;\n\tint end;\n\n\tpos = ftell(fp);\n\tfseek(fp, 0, SEEK_END);\n\tend = ftell(fp);\n\tfseek(fp, pos, SEEK_SET);\n\n\treturn end;\n} //end of the function FileLength\n#endif\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nscript_t *LoadScriptFile(const char *filename)\n{\n#ifdef BOTLIB\n\tfileHandle_t fp;\n\tchar pathname[MAX_QPATH];\n#else\n\tFILE *fp;\n#endif\n\tint length;\n\tvoid *buffer;\n\tscript_t *script;\n\n#ifdef BOTLIB\n\tif (strlen(basefolder))\n\t\tCom_sprintf(pathname, sizeof(pathname), \"%s/%s\", basefolder, filename);\n\telse\n\t\tCom_sprintf(pathname, sizeof(pathname), \"%s\", filename);\n\tlength = botimport.FS_FOpenFile( pathname, &fp, FS_READ );\n\tif (!fp) return NULL;\n#else\n\tfp = fopen(filename, \"rb\");\n\tif (!fp) return NULL;\n\n\tlength = FileLength(fp);\n#endif\n\n\tbuffer = GetClearedMemory(sizeof(script_t) + length + 1);\n\tscript = (script_t *) buffer;\n\tCom_Memset(script, 0, sizeof(script_t));\n\tstrcpy(script->filename, filename);\n\tscript->buffer = (char *) buffer + sizeof(script_t);\n\tscript->buffer[length] = 0;\n\tscript->length = length;\n\t//pointer in script buffer\n\tscript->script_p = script->buffer;\n\t//pointer in script buffer before reading token\n\tscript->lastscript_p = script->buffer;\n\t//pointer to end of script buffer\n\tscript->end_p = &script->buffer[length];\n\t//set if there's a token available in script->token\n\tscript->tokenavailable = 0;\n\t//\n\tscript->line = 1;\n\tscript->lastline = 1;\n\t//\n\tSetScriptPunctuations(script, NULL);\n\t//\n#ifdef BOTLIB\n\tbotimport.FS_Read(script->buffer, length, fp);\n\tbotimport.FS_FCloseFile(fp);\n#else\n\tif (fread(script->buffer, length, 1, fp) != 1)\n\t{\n\t\tFreeMemory(buffer);\n\t\tscript = NULL;\n\t} //end if\n\tfclose(fp);\n#endif\n\t//\n\tscript->length = COM_Compress(script->buffer);\n\n\treturn script;\n} //end of the function LoadScriptFile\n//============================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nscript_t *LoadScriptMemory(char *ptr, int length, char *name)\n{\n\tvoid *buffer;\n\tscript_t *script;\n\n\tbuffer = GetClearedMemory(sizeof(script_t) + length + 1);\n\tscript = (script_t *) buffer;\n\tCom_Memset(script, 0, sizeof(script_t));\n\tstrcpy(script->filename, name);\n\tscript->buffer = (char *) buffer + sizeof(script_t);\n\tscript->buffer[length] = 0;\n\tscript->length = length;\n\t//pointer in script buffer\n\tscript->script_p = script->buffer;\n\t//pointer in script buffer before reading token\n\tscript->lastscript_p = script->buffer;\n\t//pointer to end of script buffer\n\tscript->end_p = &script->buffer[length];\n\t//set if there's a token available in script->token\n\tscript->tokenavailable = 0;\n\t//\n\tscript->line = 1;\n\tscript->lastline = 1;\n\t//\n\tSetScriptPunctuations(script, NULL);\n\t//\n\tCom_Memcpy(script->buffer, ptr, length);\n\t//\n\treturn script;\n} //end of the function LoadScriptMemory\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid FreeScript(script_t *script)\n{\n#ifdef PUNCTABLE\n\tif (script->punctuationtable) FreeMemory(script->punctuationtable);\n#endif //PUNCTABLE\n\tFreeMemory(script);\n} //end of the function FreeScript\n//============================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//============================================================================\nvoid PS_SetBaseFolder(char *path)\n{\n#ifdef BSPC\n\tsprintf(basefolder, path);\n#else\n\tCom_sprintf(basefolder, sizeof(basefolder), path);\n#endif\n} //end of the function PS_SetBaseFolder\n"
  },
  {
    "path": "code/botlib/l_script.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tl_script.h\n *\n * desc:\t\tlexicographical parser\n *\n * $Archive: /source/code/botlib/l_script.h $\n *\n *****************************************************************************/\n\n//undef if binary numbers of the form 0b... or 0B... are not allowed\n#define BINARYNUMBERS\n//undef if not using the token.intvalue and token.floatvalue\n#define NUMBERVALUE\n//use dollar sign also as punctuation\n#define DOLLAR\n\n//maximum token length\n#define MAX_TOKEN\t\t\t\t\t1024\n\n#if defined(BSPC) && !defined(QDECL)\n#define QDECL\n#endif\n\n\n//script flags\n#define SCFL_NOERRORS\t\t\t\t0x0001\n#define SCFL_NOWARNINGS\t\t\t\t0x0002\n#define SCFL_NOSTRINGWHITESPACES\t0x0004\n#define SCFL_NOSTRINGESCAPECHARS\t0x0008\n#define SCFL_PRIMITIVE\t\t\t\t0x0010\n#define SCFL_NOBINARYNUMBERS\t\t0x0020\n#define SCFL_NONUMBERVALUES\t\t0x0040\n\n//token types\n#define TT_STRING\t\t\t\t\t\t1\t\t\t// string\n#define TT_LITERAL\t\t\t\t\t2\t\t\t// literal\n#define TT_NUMBER\t\t\t\t\t\t3\t\t\t// number\n#define TT_NAME\t\t\t\t\t\t4\t\t\t// name\n#define TT_PUNCTUATION\t\t\t\t5\t\t\t// punctuation\n\n//string sub type\n//---------------\n//\t\tthe length of the string\n//literal sub type\n//----------------\n//\t\tthe ASCII code of the literal\n//number sub type\n//---------------\n#define TT_DECIMAL\t\t\t\t\t0x0008\t// decimal number\n#define TT_HEX\t\t\t\t\t\t\t0x0100\t// hexadecimal number\n#define TT_OCTAL\t\t\t\t\t\t0x0200\t// octal number\n#ifdef BINARYNUMBERS\n#define TT_BINARY\t\t\t\t\t\t0x0400\t// binary number\n#endif //BINARYNUMBERS\n#define TT_FLOAT\t\t\t\t\t\t0x0800\t// floating point number\n#define TT_INTEGER\t\t\t\t\t0x1000\t// integer number\n#define TT_LONG\t\t\t\t\t\t0x2000\t// long number\n#define TT_UNSIGNED\t\t\t\t\t0x4000\t// unsigned number\n//punctuation sub type\n//--------------------\n#define P_RSHIFT_ASSIGN\t\t\t\t1\n#define P_LSHIFT_ASSIGN\t\t\t\t2\n#define P_PARMS\t\t\t\t\t\t3\n#define P_PRECOMPMERGE\t\t\t\t4\n\n#define P_LOGIC_AND\t\t\t\t\t5\n#define P_LOGIC_OR\t\t\t\t\t6\n#define P_LOGIC_GEQ\t\t\t\t\t7\n#define P_LOGIC_LEQ\t\t\t\t\t8\n#define P_LOGIC_EQ\t\t\t\t\t9\n#define P_LOGIC_UNEQ\t\t\t\t\t10\n\n#define P_MUL_ASSIGN\t\t\t\t\t11\n#define P_DIV_ASSIGN\t\t\t\t\t12\n#define P_MOD_ASSIGN\t\t\t\t\t13\n#define P_ADD_ASSIGN\t\t\t\t\t14\n#define P_SUB_ASSIGN\t\t\t\t\t15\n#define P_INC\t\t\t\t\t\t\t16\n#define P_DEC\t\t\t\t\t\t\t17\n\n#define P_BIN_AND_ASSIGN\t\t\t18\n#define P_BIN_OR_ASSIGN\t\t\t\t19\n#define P_BIN_XOR_ASSIGN\t\t\t20\n#define P_RSHIFT\t\t\t\t\t\t21\n#define P_LSHIFT\t\t\t\t\t\t22\n\n#define P_POINTERREF\t\t\t\t\t23\n#define P_CPP1\t\t\t\t\t\t\t24\n#define P_CPP2\t\t\t\t\t\t\t25\n#define P_MUL\t\t\t\t\t\t\t26\n#define P_DIV\t\t\t\t\t\t\t27\n#define P_MOD\t\t\t\t\t\t\t28\n#define P_ADD\t\t\t\t\t\t\t29\n#define P_SUB\t\t\t\t\t\t\t30\n#define P_ASSIGN\t\t\t\t\t\t31\n\n#define P_BIN_AND\t\t\t\t\t\t32\n#define P_BIN_OR\t\t\t\t\t\t33\n#define P_BIN_XOR\t\t\t\t\t\t34\n#define P_BIN_NOT\t\t\t\t\t\t35\n\n#define P_LOGIC_NOT\t\t\t\t\t36\n#define P_LOGIC_GREATER\t\t\t\t37\n#define P_LOGIC_LESS\t\t\t\t\t38\n\n#define P_REF\t\t\t\t\t\t\t39\n#define P_COMMA\t\t\t\t\t\t40\n#define P_SEMICOLON\t\t\t\t\t41\n#define P_COLON\t\t\t\t\t\t42\n#define P_QUESTIONMARK\t\t\t\t43\n\n#define P_PARENTHESESOPEN\t\t\t44\n#define P_PARENTHESESCLOSE\t\t\t45\n#define P_BRACEOPEN\t\t\t\t\t46\n#define P_BRACECLOSE\t\t\t\t\t47\n#define P_SQBRACKETOPEN\t\t\t\t48\n#define P_SQBRACKETCLOSE\t\t\t49\n#define P_BACKSLASH\t\t\t\t\t50\n\n#define P_PRECOMP\t\t\t\t\t\t51\n#define P_DOLLAR\t\t\t\t\t\t52\n//name sub type\n//-------------\n//\t\tthe length of the name\n\n//punctuation\ntypedef struct punctuation_s\n{\n\tchar *p;\t\t\t\t\t\t//punctuation character(s)\n\tint n;\t\t\t\t\t\t\t//punctuation indication\n\tstruct punctuation_s *next;\t\t//next punctuation\n} punctuation_t;\n\n//token\ntypedef struct token_s\n{\n\tchar string[MAX_TOKEN];\t\t\t//available token\n\tint type;\t\t\t\t\t\t//last read token type\n\tint subtype;\t\t\t\t\t//last read token sub type\n#ifdef NUMBERVALUE\n\tunsigned long int intvalue;\t//integer value\n\tlong double floatvalue;\t\t\t//floating point value\n#endif //NUMBERVALUE\n\tchar *whitespace_p;\t\t\t\t//start of white space before token\n\tchar *endwhitespace_p;\t\t\t//start of white space before token\n\tint line;\t\t\t\t\t\t//line the token was on\n\tint linescrossed;\t\t\t\t//lines crossed in white space\n\tstruct token_s *next;\t\t\t//next token in chain\n} token_t;\n\n//script file\ntypedef struct script_s\n{\n\tchar filename[1024];\t\t\t//file name of the script\n\tchar *buffer;\t\t\t\t\t//buffer containing the script\n\tchar *script_p;\t\t\t\t\t//current pointer in the script\n\tchar *end_p;\t\t\t\t\t//pointer to the end of the script\n\tchar *lastscript_p;\t\t\t\t//script pointer before reading token\n\tchar *whitespace_p;\t\t\t\t//begin of the white space\n\tchar *endwhitespace_p;\t\t\t//end of the white space\n\tint length;\t\t\t\t\t\t//length of the script in bytes\n\tint line;\t\t\t\t\t\t//current line in script\n\tint lastline;\t\t\t\t\t//line before reading token\n\tint tokenavailable;\t\t\t\t//set by UnreadLastToken\n\tint flags;\t\t\t\t\t\t//several script flags\n\tpunctuation_t *punctuations;\t//the punctuations used in the script\n\tpunctuation_t **punctuationtable;\n\ttoken_t token;\t\t\t\t\t//available token\n\tstruct script_s *next;\t\t\t//next script in a chain\n} script_t;\n\n//read a token from the script\nint PS_ReadToken(script_t *script, token_t *token);\n//expect a certain token\nint PS_ExpectTokenString(script_t *script, char *string);\n//expect a certain token type\nint PS_ExpectTokenType(script_t *script, int type, int subtype, token_t *token);\n//expect a token\nint PS_ExpectAnyToken(script_t *script, token_t *token);\n//returns true when the token is available\nint PS_CheckTokenString(script_t *script, char *string);\n//returns true an reads the token when a token with the given type is available\nint PS_CheckTokenType(script_t *script, int type, int subtype, token_t *token);\n//skip tokens until the given token string is read\nint PS_SkipUntilString(script_t *script, char *string);\n//unread the last token read from the script\nvoid PS_UnreadLastToken(script_t *script);\n//unread the given token\nvoid PS_UnreadToken(script_t *script, token_t *token);\n//returns the next character of the read white space, returns NULL if none\nchar PS_NextWhiteSpaceChar(script_t *script);\n//remove any leading and trailing double quotes from the token\nvoid StripDoubleQuotes(char *string);\n//remove any leading and trailing single quotes from the token\nvoid StripSingleQuotes(char *string);\n//read a possible signed integer\nsigned long int ReadSignedInt(script_t *script);\n//read a possible signed floating point number\nlong double ReadSignedFloat(script_t *script);\n//set an array with punctuations, NULL restores default C/C++ set\nvoid SetScriptPunctuations(script_t *script, punctuation_t *p);\n//set script flags\nvoid SetScriptFlags(script_t *script, int flags);\n//get script flags\nint GetScriptFlags(script_t *script);\n//reset a script\nvoid ResetScript(script_t *script);\n//returns true if at the end of the script\nint EndOfScript(script_t *script);\n//returns a pointer to the punctuation with the given number\nchar *PunctuationFromNum(script_t *script, int num);\n//load a script from the given file at the given offset with the given length\nscript_t *LoadScriptFile(const char *filename);\n//load a script from the given memory with the given length\nscript_t *LoadScriptMemory(char *ptr, int length, char *name);\n//free a script\nvoid FreeScript(script_t *script);\n//set the base folder to load files from\nvoid PS_SetBaseFolder(char *path);\n//print a script error with filename and line number\nvoid QDECL ScriptError(script_t *script, char *str, ...);\n//print a script warning with filename and line number\nvoid QDECL ScriptWarning(script_t *script, char *str, ...);\n\n\n"
  },
  {
    "path": "code/botlib/l_struct.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tl_struct.c\n *\n * desc:\t\tstructure reading / writing\n *\n * $Archive: /MissionPack/CODE/botlib/l_struct.c $\n *\n *****************************************************************************/\n\n#ifdef BOTLIB\n#include \"../game/q_shared.h\"\n#include \"../game/botlib.h\"\t\t\t\t//for the include of be_interface.h\n#include \"l_script.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n#include \"l_utils.h\"\n#include \"be_interface.h\"\n#endif //BOTLIB\n\n#ifdef BSPC\n//include files for usage in the BSP Converter\n#include \"../bspc/qbsp.h\"\n#include \"../bspc/l_log.h\"\n#include \"../bspc/l_mem.h\"\n#include \"l_precomp.h\"\n#include \"l_struct.h\"\n\n#define qtrue\ttrue\n#define qfalse\tfalse\n#endif //BSPC\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfielddef_t *FindField(fielddef_t *defs, char *name)\n{\n\tint i;\n\n\tfor (i = 0; defs[i].name; i++)\n\t{\n\t\tif (!strcmp(defs[i].name, name)) return &defs[i];\n\t} //end for\n\treturn NULL;\n} //end of the function FindField\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean ReadNumber(source_t *source, fielddef_t *fd, void *p)\n{\n\ttoken_t token;\n\tint negative = qfalse;\n\tlong int intval, intmin = 0, intmax = 0;\n\tdouble floatval;\n\n\tif (!PC_ExpectAnyToken(source, &token)) return 0;\n\n\t//check for minus sign\n\tif (token.type == TT_PUNCTUATION)\n\t{\n\t\tif (fd->type & FT_UNSIGNED)\n\t\t{\n\t\t\tSourceError(source, \"expected unsigned value, found %s\", token.string);\n\t\t\treturn 0;\n\t\t} //end if\n\t\t//if not a minus sign\n\t\tif (strcmp(token.string, \"-\"))\n\t\t{\n\t\t\tSourceError(source, \"unexpected punctuation %s\", token.string);\n\t\t\treturn 0;\n\t\t} //end if\n\t\tnegative = qtrue;\n\t\t//read the number\n\t\tif (!PC_ExpectAnyToken(source, &token)) return 0;\n\t} //end if\n\t//check if it is a number\n\tif (token.type != TT_NUMBER)\n\t{\n\t\tSourceError(source, \"expected number, found %s\", token.string);\n\t\treturn 0;\n\t} //end if\n\t//check for a float value\n\tif (token.subtype & TT_FLOAT)\n\t{\n\t\tif ((fd->type & FT_TYPE) != FT_FLOAT)\n\t\t{\n\t\t\tSourceError(source, \"unexpected float\");\n\t\t\treturn 0;\n\t\t} //end if\n\t\tfloatval = token.floatvalue;\n\t\tif (negative) floatval = -floatval;\n\t\tif (fd->type & FT_BOUNDED)\n\t\t{\n\t\t\tif (floatval < fd->floatmin || floatval > fd->floatmax)\n\t\t\t{\n\t\t\t\tSourceError(source, \"float out of range [%f, %f]\", fd->floatmin, fd->floatmax);\n\t\t\t\treturn 0;\n\t\t\t} //end if\n\t\t} //end if\n\t\t*(float *) p = (float) floatval;\n\t\treturn 1;\n\t} //end if\n\t//\n\tintval = token.intvalue;\n\tif (negative) intval = -intval;\n\t//check bounds\n\tif ((fd->type & FT_TYPE) == FT_CHAR)\n\t{\n\t\tif (fd->type & FT_UNSIGNED) {intmin = 0; intmax = 255;}\n\t\telse {intmin = -128; intmax = 127;}\n\t} //end if\n\tif ((fd->type & FT_TYPE) == FT_INT)\n\t{\n\t\tif (fd->type & FT_UNSIGNED) {intmin = 0; intmax = 65535;}\n\t\telse {intmin = -32768; intmax = 32767;}\n\t} //end else if\n\tif ((fd->type & FT_TYPE) == FT_CHAR || (fd->type & FT_TYPE) == FT_INT)\n\t{\n\t\tif (fd->type & FT_BOUNDED)\n\t\t{\n\t\t\tintmin = Maximum(intmin, fd->floatmin);\n\t\t\tintmax = Minimum(intmax, fd->floatmax);\n\t\t} //end if\n\t\tif (intval < intmin || intval > intmax)\n\t\t{\n\t\t\tSourceError(source, \"value %d out of range [%d, %d]\", intval, intmin, intmax);\n\t\t\treturn 0;\n\t\t} //end if\n\t} //end if\n\telse if ((fd->type & FT_TYPE) == FT_FLOAT)\n\t{\n\t\tif (fd->type & FT_BOUNDED)\n\t\t{\n\t\t\tif (intval < fd->floatmin || intval > fd->floatmax)\n\t\t\t{\n\t\t\t\tSourceError(source, \"value %d out of range [%f, %f]\", intval, fd->floatmin, fd->floatmax);\n\t\t\t\treturn 0;\n\t\t\t} //end if\n\t\t} //end if\n\t} //end else if\n\t//store the value\n\tif ((fd->type & FT_TYPE) == FT_CHAR)\n\t{\n\t\tif (fd->type & FT_UNSIGNED) *(unsigned char *) p = (unsigned char) intval;\n\t\telse *(char *) p = (char) intval;\n\t} //end if\n\telse if ((fd->type & FT_TYPE) == FT_INT)\n\t{\n\t\tif (fd->type & FT_UNSIGNED) *(unsigned int *) p = (unsigned int) intval;\n\t\telse *(int *) p = (int) intval;\n\t} //end else\n\telse if ((fd->type & FT_TYPE) == FT_FLOAT)\n\t{\n\t\t*(float *) p = (float) intval;\n\t} //end else\n\treturn 1;\n} //end of the function ReadNumber\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean ReadChar(source_t *source, fielddef_t *fd, void *p)\n{\n\ttoken_t token;\n\n\tif (!PC_ExpectAnyToken(source, &token)) return 0;\n\n\t//take literals into account\n\tif (token.type == TT_LITERAL)\n\t{\n\t\tStripSingleQuotes(token.string);\n\t\t*(char *) p = token.string[0];\n\t} //end if\n\telse\n\t{\n\t\tPC_UnreadLastToken(source);\n\t\tif (!ReadNumber(source, fd, p)) return 0;\n\t} //end if\n\treturn 1;\n} //end of the function ReadChar\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint ReadString(source_t *source, fielddef_t *fd, void *p)\n{\n\ttoken_t token;\n\n\tif (!PC_ExpectTokenType(source, TT_STRING, 0, &token)) return 0;\n\t//remove the double quotes\n\tStripDoubleQuotes(token.string);\n\t//copy the string\n\tstrncpy((char *) p, token.string, MAX_STRINGFIELD);\n\t//make sure the string is closed with a zero\n\t((char *)p)[MAX_STRINGFIELD-1] = '\\0';\n\t//\n\treturn 1;\n} //end of the function ReadString\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint ReadStructure(source_t *source, structdef_t *def, char *structure)\n{\n\ttoken_t token;\n\tfielddef_t *fd;\n\tvoid *p;\n\tint num;\n\n\tif (!PC_ExpectTokenString(source, \"{\")) return 0;\n\twhile(1)\n\t{\n\t\tif (!PC_ExpectAnyToken(source, &token)) return qfalse;\n\t\t//if end of structure\n\t\tif (!strcmp(token.string, \"}\")) break;\n\t\t//find the field with the name\n\t\tfd = FindField(def->fields, token.string);\n\t\tif (!fd)\n\t\t{\n\t\t\tSourceError(source, \"unknown structure field %s\", token.string);\n\t\t\treturn qfalse;\n\t\t} //end if\n\t\tif (fd->type & FT_ARRAY)\n\t\t{\n\t\t\tnum = fd->maxarray;\n\t\t\tif (!PC_ExpectTokenString(source, \"{\")) return qfalse;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tnum = 1;\n\t\t} //end else\n\t\tp = (void *)(structure + fd->offset);\n\t\twhile (num-- > 0)\n\t\t{\n\t\t\tif (fd->type & FT_ARRAY)\n\t\t\t{\n\t\t\t\tif (PC_CheckTokenString(source, \"}\")) break;\n\t\t\t} //end if\n\t\t\tswitch(fd->type & FT_TYPE)\n\t\t\t{\n\t\t\t\tcase FT_CHAR:\n\t\t\t\t{\n\t\t\t\t\tif (!ReadChar(source, fd, p)) return qfalse;\n\t\t\t\t\tp = (char *) p + sizeof(char);\n\t\t\t\t\tbreak;\n\t\t\t\t} //end case\n\t\t\t\tcase FT_INT:\n\t\t\t\t{\n\t\t\t\t\tif (!ReadNumber(source, fd, p)) return qfalse;\n\t\t\t\t\tp = (char *) p + sizeof(int);\n\t\t\t\t\tbreak;\n\t\t\t\t} //end case\n\t\t\t\tcase FT_FLOAT:\n\t\t\t\t{\n\t\t\t\t\tif (!ReadNumber(source, fd, p)) return qfalse;\n\t\t\t\t\tp = (char *) p + sizeof(float);\n\t\t\t\t\tbreak;\n\t\t\t\t} //end case\n\t\t\t\tcase FT_STRING:\n\t\t\t\t{\n\t\t\t\t\tif (!ReadString(source, fd, p)) return qfalse;\n\t\t\t\t\tp = (char *) p + MAX_STRINGFIELD;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end case\n\t\t\t\tcase FT_STRUCT:\n\t\t\t\t{\n\t\t\t\t\tif (!fd->substruct)\n\t\t\t\t\t{\n\t\t\t\t\t\tSourceError(source, \"BUG: no sub structure defined\");\n\t\t\t\t\t\treturn qfalse;\n\t\t\t\t\t} //end if\n\t\t\t\t\tReadStructure(source, fd->substruct, (char *) p);\n\t\t\t\t\tp = (char *) p + fd->substruct->size;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end case\n\t\t\t} //end switch\n\t\t\tif (fd->type & FT_ARRAY)\n\t\t\t{\n\t\t\t\tif (!PC_ExpectAnyToken(source, &token)) return qfalse;\n\t\t\t\tif (!strcmp(token.string, \"}\")) break;\n\t\t\t\tif (strcmp(token.string, \",\"))\n\t\t\t\t{\n\t\t\t\t\tSourceError(source, \"expected a comma, found %s\", token.string);\n\t\t\t\t\treturn qfalse;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end while\n\t} //end while\n\treturn qtrue;\n} //end of the function ReadStructure\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint WriteIndent(FILE *fp, int indent)\n{\n\twhile(indent-- > 0)\n\t{\n\t\tif (fprintf(fp, \"\\t\") < 0) return qfalse;\n\t} //end while\n\treturn qtrue;\n} //end of the function WriteIndent\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint WriteFloat(FILE *fp, float value)\n{\n\tchar buf[128];\n\tint l;\n\n\tsprintf(buf, \"%f\", value);\n\tl = strlen(buf);\n\t//strip any trailing zeros\n\twhile(l-- > 1)\n\t{\n\t\tif (buf[l] != '0' && buf[l] != '.') break;\n\t\tif (buf[l] == '.')\n\t\t{\n\t\t\tbuf[l] = 0;\n\t\t\tbreak;\n\t\t} //end if\n\t\tbuf[l] = 0;\n\t} //end while\n\t//write the float to file\n\tif (fprintf(fp, \"%s\", buf) < 0) return 0;\n\treturn 1;\n} //end of the function WriteFloat\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint WriteStructWithIndent(FILE *fp, structdef_t *def, char *structure, int indent)\n{\n\tint i, num;\n\tvoid *p;\n\tfielddef_t *fd;\n\n\tif (!WriteIndent(fp, indent)) return qfalse;\n\tif (fprintf(fp, \"{\\r\\n\") < 0) return qfalse;\n\n\tindent++;\n\tfor (i = 0; def->fields[i].name; i++)\n\t{\n\t\tfd = &def->fields[i];\n\t\tif (!WriteIndent(fp, indent)) return qfalse;\n\t\tif (fprintf(fp, \"%s\\t\", fd->name) < 0) return qfalse;\n\t\tp = (void *)(structure + fd->offset);\n\t\tif (fd->type & FT_ARRAY)\n\t\t{\n\t\t\tnum = fd->maxarray;\n\t\t\tif (fprintf(fp, \"{\") < 0) return qfalse;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tnum = 1;\n\t\t} //end else\n\t\twhile(num-- > 0)\n\t\t{\n\t\t\tswitch(fd->type & FT_TYPE)\n\t\t\t{\n\t\t\t\tcase FT_CHAR:\n\t\t\t\t{\n\t\t\t\t\tif (fprintf(fp, \"%d\", *(char *) p) < 0) return qfalse;\n\t\t\t\t\tp = (char *) p + sizeof(char);\n\t\t\t\t\tbreak;\n\t\t\t\t} //end case\n\t\t\t\tcase FT_INT:\n\t\t\t\t{\n\t\t\t\t\tif (fprintf(fp, \"%d\", *(int *) p) < 0) return qfalse;\n\t\t\t\t\tp = (char *) p + sizeof(int);\n\t\t\t\t\tbreak;\n\t\t\t\t} //end case\n\t\t\t\tcase FT_FLOAT:\n\t\t\t\t{\n\t\t\t\t\tif (!WriteFloat(fp, *(float *)p)) return qfalse;\n\t\t\t\t\tp = (char *) p + sizeof(float);\n\t\t\t\t\tbreak;\n\t\t\t\t} //end case\n\t\t\t\tcase FT_STRING:\n\t\t\t\t{\n\t\t\t\t\tif (fprintf(fp, \"\\\"%s\\\"\", (char *) p) < 0) return qfalse;\n\t\t\t\t\tp = (char *) p + MAX_STRINGFIELD;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end case\n\t\t\t\tcase FT_STRUCT:\n\t\t\t\t{\n\t\t\t\t\tif (!WriteStructWithIndent(fp, fd->substruct, structure, indent)) return qfalse;\n\t\t\t\t\tp = (char *) p + fd->substruct->size;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end case\n\t\t\t} //end switch\n\t\t\tif (fd->type & FT_ARRAY)\n\t\t\t{\n\t\t\t\tif (num > 0)\n\t\t\t\t{\n\t\t\t\t\tif (fprintf(fp, \",\") < 0) return qfalse;\n\t\t\t\t} //end if\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (fprintf(fp, \"}\") < 0) return qfalse;\n\t\t\t\t} //end else\n\t\t\t} //end if\n\t\t} //end while\n\t\tif (fprintf(fp, \"\\r\\n\") < 0) return qfalse;\n\t} //end for\n\tindent--;\n\n\tif (!WriteIndent(fp, indent)) return qfalse;\n\tif (fprintf(fp, \"}\\r\\n\") < 0) return qfalse;\n\treturn qtrue;\n} //end of the function WriteStructWithIndent\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint WriteStructure(FILE *fp, structdef_t *def, char *structure)\n{\n\treturn WriteStructWithIndent(fp, def, structure, 0);\n} //end of the function WriteStructure\n\n"
  },
  {
    "path": "code/botlib/l_struct.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tl_struct.h\n *\n * desc:\t\tstructure reading/writing\n *\n * $Archive: /source/code/botlib/l_struct.h $\n *\n *****************************************************************************/\n\n\n#define MAX_STRINGFIELD\t\t\t\t80\n//field types\n#define FT_CHAR\t\t\t\t\t\t1\t\t\t// char\n#define FT_INT\t\t\t\t\t\t\t2\t\t\t// int\n#define FT_FLOAT\t\t\t\t\t\t3\t\t\t// float\n#define FT_STRING\t\t\t\t\t\t4\t\t\t// char [MAX_STRINGFIELD]\n#define FT_STRUCT\t\t\t\t\t\t6\t\t\t// struct (sub structure)\n//type only mask\n#define FT_TYPE\t\t\t\t\t\t0x00FF\t// only type, clear subtype\n//sub types\n#define FT_ARRAY\t\t\t\t\t\t0x0100\t// array of type\n#define FT_BOUNDED\t\t\t\t\t0x0200\t// bounded value\n#define FT_UNSIGNED\t\t\t\t\t0x0400\n\n//structure field definition\ntypedef struct fielddef_s\n{\n\tchar *name;\t\t\t\t\t\t\t\t\t\t//name of the field\n\tint offset;\t\t\t\t\t\t\t\t\t\t//offset in the structure\n\tint type;\t\t\t\t\t\t\t\t\t\t//type of the field\n\t//type specific fields\n\tint maxarray;\t\t\t\t\t\t\t\t\t//maximum array size\n\tfloat floatmin, floatmax;\t\t\t\t\t//float min and max\n\tstruct structdef_s *substruct;\t\t\t//sub structure\n} fielddef_t;\n\n//structure definition\ntypedef struct structdef_s\n{\n\tint size;\n\tfielddef_t *fields;\n} structdef_t;\n\n//read a structure from a script\nint ReadStructure(source_t *source, structdef_t *def, char *structure);\n//write a structure to a file\nint WriteStructure(FILE *fp, structdef_t *def, char *structure);\n//writes indents\nint WriteIndent(FILE *fp, int indent);\n//writes a float without traling zeros\nint WriteFloat(FILE *fp, float value);\n\n\n"
  },
  {
    "path": "code/botlib/l_utils.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tl_util.h\n *\n * desc:\t\tutils\n *\n * $Archive: /source/code/botlib/l_util.h $\n *\n *****************************************************************************/\n\n#define Vector2Angles(v,a)\t\tvectoangles(v,a)\n#define MAX_PATH\t\t\t\tMAX_QPATH\n#define Maximum(x,y)\t\t\t(x > y ? x : y)\n#define Minimum(x,y)\t\t\t(x < y ? x : y)\n"
  },
  {
    "path": "code/botlib/lcc.mak",
    "content": "#\n# Makefile for Gladiator Bot library: gladiator.dll\n# Intended for LCC-Win32\n#\n\nCC=lcc\nCFLAGS=-DC_ONLY -o\nOBJS= be_aas_bspq2.obj \\\n\tbe_aas_bsphl.obj \\\n\tbe_aas_cluster.obj \\\n\tbe_aas_debug.obj \\\n\tbe_aas_entity.obj \\\n\tbe_aas_file.obj \\\n\tbe_aas_light.obj \\\n\tbe_aas_main.obj \\\n\tbe_aas_move.obj \\\n\tbe_aas_optimize.obj \\\n\tbe_aas_reach.obj \\\n\tbe_aas_route.obj \\\n\tbe_aas_routealt.obj \\\n\tbe_aas_sample.obj \\\n\tbe_aas_sound.obj \\\n\tbe_ai2_dm.obj \\\n\tbe_ai2_dmnet.obj \\\n\tbe_ai2_main.obj \\\n\tbe_ai_char.obj \\\n\tbe_ai_chat.obj \\\n\tbe_ai_goal.obj \\\n\tbe_ai_load.obj \\\n\tbe_ai_move.obj \\\n\tbe_ai_weap.obj \\\n\tbe_ai_weight.obj \\\n\tbe_ea.obj \\\n\tbe_interface.obj \\\n\tl_crc.obj \\\n\tl_libvar.obj \\\n\tl_log.obj \\\n\tl_memory.obj \\\n\tl_precomp.obj \\\n\tl_script.obj \\\n\tl_struct.obj \\\n\tl_utils.obj \\\n\tq_shared.obj\n\nall:\tgladiator.dll\n\ngladiator.dll:\t$(OBJS)\n\tlcclnk -dll -entry GetBotAPI *.obj botlib.def -o gladiator.dll\n\nclean:\n\tdel *.obj gladiator.dll\n\n%.obj: %.c\n\t$(CC) $(CFLAGS) $<\n\n"
  },
  {
    "path": "code/botlib/linux-i386.mak",
    "content": "#\n# Makefile for Gladiator Bot library: gladiator.so\n# Intended for gcc/Linux\n#\n\nARCH=i386\nCC=gcc\nBASE_CFLAGS=-Dstricmp=strcasecmp\n\n#use these cflags to optimize it\nCFLAGS=$(BASE_CFLAGS) -m486 -O6 -ffast-math -funroll-loops \\\n\t-fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \\\n\t-malign-jumps=2 -malign-functions=2\n#use these when debugging \n#CFLAGS=$(BASE_CFLAGS) -g\n\nLDFLAGS=-ldl -lm\nSHLIBEXT=so\nSHLIBCFLAGS=-fPIC\nSHLIBLDFLAGS=-shared\n\nDO_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<\n\n#############################################################################\n# SETUP AND BUILD\n# GLADIATOR BOT\n#############################################################################\n\n.c.o:\n\t$(DO_CC)\n\nGAME_OBJS = \\\n\tbe_aas_bsphl.o\\\n\tbe_aas_bspq2.o\\\n\tbe_aas_cluster.o\\\n\tbe_aas_debug.o\\\n\tbe_aas_entity.o\\\n\tbe_aas_file.o\\\n\tbe_aas_light.o\\\n\tbe_aas_main.o\\\n\tbe_aas_move.o\\\n\tbe_aas_optimize.o\\\n\tbe_aas_reach.o\\\n\tbe_aas_route.o\\\n\tbe_aas_routealt.o\\\n\tbe_aas_sample.o\\\n\tbe_aas_sound.o\\\n\tbe_ai2_dmq2.o\\\n\tbe_ai2_dmhl.o\\\n\tbe_ai2_dmnet.o\\\n\tbe_ai2_main.o\\\n\tbe_ai_char.o\\\n\tbe_ai_chat.o\\\n\tbe_ai_goal.o\\\n\tbe_ai_load.o\\\n\tbe_ai_move.o\\\n\tbe_ai_weap.o\\\n\tbe_ai_weight.o\\\n\tbe_ea.o\\\n\tbe_interface.o\\\n\tl_crc.o\\\n\tl_libvar.o\\\n\tl_log.o\\\n\tl_memory.o\\\n\tl_precomp.o\\\n\tl_script.o\\\n\tl_struct.o\\\n\tl_utils.o\\\n\tq_shared.o\n\nglad$(ARCH).$(SHLIBEXT) : $(GAME_OBJS)\n\t$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(GAME_OBJS)\n\n\n#############################################################################\n# MISC\n#############################################################################\n\nclean:\n\t-rm -f $(GAME_OBJS)\n\ndepend:\n\tgcc -MM $(GAME_OBJS:.o=.c)\n\n\ninstall:\n\tcp gladiator.so ..\n\n#\n# From \"make depend\"\n#\n\n"
  },
  {
    "path": "code/bspc/Conscript",
    "content": "# bspc compile\n\nImport qw( BSPC_BASE_CFLAGS BUILD_DIR INSTALL_DIR CC CXX LINK );\n\n@BSPC_FILES = qw(\n\taas_areamerging.c\n\taas_cfg.c\n\taas_create.c\n\taas_edgemelting.c\n\taas_facemerging.c\n\taas_file.c\n\taas_gsubdiv.c\n\taas_map.c\n\taas_prunenodes.c\n\taas_store.c\n\tbe_aas_bspc.c\n\t../botlib/be_aas_bspq3.c\n\t../botlib/be_aas_cluster.c\n\t../botlib/be_aas_move.c\n\t../botlib/be_aas_optimize.c\n\t../botlib/be_aas_reach.c\n\t../botlib/be_aas_sample.c\n\tbrushbsp.c\n\tbspc.c\n\t../qcommon/cm_load.c\n\t../qcommon/cm_patch.c\n\t../qcommon/cm_test.c\n\t../qcommon/cm_trace.c\n\tcsg.c\n\tglfile.c\n\tl_bsp_ent.c\n\tl_bsp_hl.c\n\tl_bsp_q1.c\n\tl_bsp_q2.c\n\tl_bsp_q3.c\n\tl_bsp_sin.c\n\tl_cmd.c\n\t../botlib/l_libvar.c\n\tl_log.c\n\tl_math.c\n\tl_mem.c\n\tl_poly.c\n\t../botlib/l_precomp.c\n\tl_qfiles.c\n\t../botlib/l_script.c\n\t../botlib/l_struct.c\n\tl_threads.c\n\tl_utils.c\n\tleakfile.c\n\tmap.c\n\tmap_hl.c\n\tmap_q1.c\n\tmap_q2.c\n\tmap_q3.c\n\tmap_sin.c\n\t../qcommon/md4.c\n\tnodraw.c\n\tportals.c\n\ttextures.c\n\ttree.c\n\t../qcommon/unzip.c\n  );\n$BSPC_REF = \\@BSPC_FILES;\n\n$env = new cons(\n  CC => $CC,\n  CXX => $CXX,\n  LINK => $LINK,\n  CFLAGS => $BSPC_BASE_CFLAGS,\n  LIBS => '-ldl -lm -lpthread'\n);\n\nProgram $env 'bspc', @$BSPC_REF;\n# this should install to Q3 or something?\nInstall $env $INSTALL_DIR, 'bspc';\n"
  },
  {
    "path": "code/bspc/Makefile",
    "content": "#\n# Makefile for the BSPC tool for the Gladiator Bot\n# Intended for gcc/Linux\n#\n# TTimo 5/15/2001\n# some cleanup .. only used on i386 for GtkRadiant setups AFAIK .. removing the i386 tag\n# TODO: the intermediate object files should go into their own directory\n#   specially for ../botlib and ../qcommon, the compilation flags on those might not be what you expect\n\n#ARCH=i386\nCC=gcc\nBASE_CFLAGS=-Dstricmp=strcasecmp\n\n#use these cflags to optimize it\nCFLAGS=$(BASE_CFLAGS) -m486 -O6 -ffast-math -funroll-loops \\\n\t-fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \\\n\t-malign-jumps=2 -malign-functions=2 -DLINUX -DBSPC\n#use these when debugging \n#CFLAGS=$(BASE_CFLAGS) -g\n\nLDFLAGS=-ldl -lm -lpthread\n\nDO_CC=$(CC) $(CFLAGS) -o $@ -c $<\n\n#############################################################################\n# SETUP AND BUILD BSPC\n#############################################################################\n\n.c.o:\n\t$(DO_CC)\n\nGAME_OBJS = \\\n\t_files.o\\\n\taas_areamerging.o\\\n\taas_cfg.o\\\n\taas_create.o\\\n\taas_edgemelting.o\\\n\taas_facemerging.o\\\n\taas_file.o\\\n\taas_gsubdiv.o\\\n\taas_map.o\\\n\taas_prunenodes.o\\\n\taas_store.o\\\n\tbe_aas_bspc.o\\\n\t../botlib/be_aas_bspq3.o\\\n\t../botlib/be_aas_cluster.o\\\n\t../botlib/be_aas_move.o\\\n\t../botlib/be_aas_optimize.o\\\n\t../botlib/be_aas_reach.o\\\n\t../botlib/be_aas_sample.o\\\n\tbrushbsp.o\\\n\tbspc.o\\\n\t../qcommon/cm_load.o\\\n\t../qcommon/cm_patch.o\\\n\t../qcommon/cm_test.o\\\n\t../qcommon/cm_trace.o\\\n\tcsg.o\\\n\tglfile.o\\\n\tl_bsp_ent.o\\\n\tl_bsp_hl.o\\\n\tl_bsp_q1.o\\\n\tl_bsp_q2.o\\\n\tl_bsp_q3.o\\\n\tl_bsp_sin.o\\\n\tl_cmd.o\\\n\t../botlib/l_libvar.o\\\n\tl_log.o\\\n\tl_math.o\\\n\tl_mem.o\\\n\tl_poly.o\\\n\t../botlib/l_precomp.o\\\n\tl_qfiles.o\\\n\t../botlib/l_script.o\\\n\t../botlib/l_struct.o\\\n\tl_threads.o\\\n\tl_utils.o\\\n\tleakfile.o\\\n\tmap.o\\\n\tmap_hl.o\\\n\tmap_q1.o\\\n\tmap_q2.o\\\n\tmap_q3.o\\\n\tmap_sin.o\\\n\t../qcommon/md4.o\\\n\tnodraw.o\\\n\tportals.o\\\n\ttextures.o\\\n\ttree.o\\\n\t../qcommon/unzip.o\n\n        #tetrahedron.o\n\nbspc : $(GAME_OBJS)\n\t$(CC) $(CFLAGS) -o $@ $(GAME_OBJS) $(LDFLAGS)\n\tstrip $@\n\n\n#############################################################################\n# MISC\n#############################################################################\n\nclean:\n\t-rm -f $(GAME_OBJS)\n\ndepend:\n\tgcc -MM $(GAME_OBJS:.o=.c)\n\n#install:\n#\tcp bspci386 ..\n\n#\n# From \"make depend\"\n#\n\n"
  },
  {
    "path": "code/bspc/_files.c",
    "content": "//===========================================================================\n//\n// Name:\t\t\t_files.c\n// Function:\n// Programmer:\t\tMr Elusive\n// Last update:\t\t1999-12-02\n// Tab Size:\t\t4\n//===========================================================================\n\n/*\n\naas_areamerging.c\t\t\t//AAS area merging\naas_cfg.c\t\t\t\t\t//AAS configuration for different games\naas_create.c\t\t\t\t//AAS creating\naas_edgemelting.c\t\t\t//AAS edge melting\naas_facemerging.c\t\t\t//AAS face merging\naas_file.c\t\t\t\t\t//AAS file writing\naas_gsubdiv.c\t\t\t\t//AAS gravitational and ladder subdivision\naas_map.c\t\t\t\t\t//AAS map brush creation\naas_prunenodes.c\t\t\t//AAS node pruning\naas_store.c\t\t\t\t\t//AAS file storing\n\nmap.c\t\t\t\t\t\t//map file loading and writing\nmap_hl.c\t\t\t\t\t//Half-Life map loading\nmap_q1.c\t\t\t\t\t//Quake1 map loading\nmap_q2.c\t\t\t\t\t//Quake2 map loading\nmap_q3.c\t\t\t\t\t//Quake3 map loading\nmap_sin.c\t\t\t\t\t//Sin map loading\ntree.c\t\t\t\t\t\t//BSP tree management + node pruning\t\t\t(*)\nbrushbsp.c\t\t\t\t\t//brush bsp creation\t\t\t\t\t\t\t(*)\nportals.c\t\t\t\t\t//BSP portal creation and leaf filling\t\t\t(*)\ncsg.c\t\t\t\t\t\t//Constructive Solid Geometry brush chopping\t(*)\nleakfile.c\t\t\t\t\t//leak file writing\t\t\t\t\t\t\t\t(*)\ntextures.c\t\t\t\t\t//Quake2 BSP textures\t\t\t\t\t\t\t(*)\n\nl_bsp_ent.c\t\t\t\t\t//BSP entity parsing\nl_bsp_hl.c\t\t\t\t\t//Half-Life BSP loading and writing\nl_bsp_q1.c\t\t\t\t\t//Quake1 BSP loading and writing\nl_bsp_q2.c\t\t\t\t\t//Quake2 BSP loading and writing\nl_bsp_q3.c\t\t\t\t\t//Quake2 BSP loading and writing\nl_bsp_sin.c\t\t\t\t\t//Sin BSP loading and writing\nl_cmd.c\t\t\t\t\t\t//cmd library\nl_log.c\t\t\t\t\t\t//log file library\nl_math.c\t\t\t\t\t//math library\nl_mem.c\t\t\t\t\t\t//memory management library\nl_poly.c\t\t\t\t\t//polygon (winding) library\nl_script.c\t\t\t\t\t//script file parsing library\nl_threads.c\t\t\t\t\t//multi-threading library\nl_utils.c\t\t\t\t\t//utility library\nl_qfiles.c\t\t\t\t\t//loading of quake files\n\ngldraw.c\t\t\t\t\t//GL drawing\t\t\t\t\t\t\t\t\t(*)\nglfile.c\t\t\t\t\t//GL file writing\t\t\t\t\t\t\t\t(*)\nnodraw.c\t\t\t\t\t//no draw module\t\t\t\t\t\t\t\t(*)\n\nbspc.c\t\t\t\t\t\t//BSPC Win32 console version\nwinbspc.c\t\t\t\t\t//WinBSPC Win32 GUI version\nwin32_terminal.c\t\t\t//Win32 terminal output\nwin32_qfiles.c\t\t\t\t//Win32 game file management (also .pak .sin)\nwin32_font.c\t\t\t\t//Win32 fonts\nwin32_folder.c\t\t\t\t//Win32 folder dialogs\n\n*/\n"
  },
  {
    "path": "code/bspc/aas_areamerging.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n#include \"../botlib/aasfile.h\"\n#include \"aas_create.h\"\n#include \"aas_store.h\"\n\n#define CONVEX_EPSILON\t\t0.3\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\ntmp_node_t *AAS_RefreshMergedTree_r(tmp_node_t *tmpnode)\n{\n\ttmp_area_t *tmparea;\n\n\t//if this is a solid leaf\n\tif (!tmpnode) return NULL;\n\t//if this is an area leaf\n\tif (tmpnode->tmparea)\n\t{\n\t\ttmparea = tmpnode->tmparea;\n\t\twhile(tmparea->mergedarea) tmparea = tmparea->mergedarea;\n\t\ttmpnode->tmparea = tmparea;\n\t\treturn tmpnode;\n\t} //end if\n\t//do the children recursively\n\ttmpnode->children[0] = AAS_RefreshMergedTree_r(tmpnode->children[0]);\n\ttmpnode->children[1] = AAS_RefreshMergedTree_r(tmpnode->children[1]);\n\treturn tmpnode;\n} //end of the function AAS_RefreshMergedTree_r\n//===========================================================================\n// returns true if the two given faces would create a non-convex area at\n// the given sides, otherwise false is returned\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint NonConvex(tmp_face_t *face1, tmp_face_t *face2, int side1, int side2)\n{\n\tint i;\n\twinding_t *w1, *w2;\n\tplane_t *plane1, *plane2;\n\t\n\tw1 = face1->winding;\n\tw2 = face2->winding;\n\n\tplane1 = &mapplanes[face1->planenum ^ side1];\n\tplane2 = &mapplanes[face2->planenum ^ side2];\n\n\t//check if one of the points of face1 is at the back of the plane of face2\n\tfor (i = 0; i < w1->numpoints; i++)\n\t{\n\t\tif (DotProduct(plane2->normal, w1->p[i]) - plane2->dist < -CONVEX_EPSILON) return true;\n\t} //end for\n\t//check if one of the points of face2 is at the back of the plane of face1\n\tfor (i = 0; i < w2->numpoints; i++)\n\t{\n\t\tif (DotProduct(plane1->normal, w2->p[i]) - plane1->dist < -CONVEX_EPSILON) return true;\n\t} //end for\n\n\treturn false;\n} //end of the function NonConvex\n//===========================================================================\n// try to merge the areas at both sides of the given face\n//\n// Parameter:\t\t\t\tseperatingface\t\t: face that seperates two areas\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_TryMergeFaceAreas(tmp_face_t *seperatingface)\n{\n\tint side1, side2, area1faceflags, area2faceflags;\n\ttmp_area_t *tmparea1, *tmparea2, *newarea;\n\ttmp_face_t *face1, *face2, *nextface1, *nextface2;\n\n\ttmparea1 = seperatingface->frontarea;\n\ttmparea2 = seperatingface->backarea;\n\n\t//areas must have the same presence type\n\tif (tmparea1->presencetype != tmparea2->presencetype) return false;\n\t//areas must have the same area contents\n\tif (tmparea1->contents != tmparea2->contents) return false;\n\t//areas must have the same bsp model inside (or both none)\n\tif (tmparea1->modelnum != tmparea2->modelnum) return false;\n\n\tarea1faceflags = 0;\n\tarea2faceflags = 0;\n\tfor (face1 = tmparea1->tmpfaces; face1; face1 = face1->next[side1])\n\t{\n\t\tside1 = (face1->frontarea != tmparea1);\n\t\t//debug: check if the area belongs to the area\n\t\tif (face1->frontarea != tmparea1 &&\n\t\t\t\tface1->backarea != tmparea1) Error(\"face does not belong to area1\");\n\t\t//just continue if the face is seperating the two areas\n\t\t//NOTE: a result of this is that ground and gap areas can\n\t\t//      be merged if the seperating face is the gap\n\t\tif ((face1->frontarea == tmparea1 &&\n\t\t\t\tface1->backarea == tmparea2) ||\n\t\t\t\t(face1->frontarea == tmparea2 &&\n\t\t\t\tface1->backarea == tmparea1)) continue;\n\t\t//get area1 face flags\n\t\tarea1faceflags |= face1->faceflags;\n\t\tif (AAS_GapFace(face1, side1)) area1faceflags |= FACE_GAP;\n\t\t//\n\t\tfor (face2 = tmparea2->tmpfaces; face2; face2 = face2->next[side2])\n\t\t{\n\t\t\tside2 = (face2->frontarea != tmparea2);\n\t\t\t//debug: check if the area belongs to the area\n\t\t\tif (face2->frontarea != tmparea2 &&\n\t\t\t\t\tface2->backarea != tmparea2) Error(\"face does not belong to area2\");\n\t\t\t//just continue if the face is seperating the two areas\n\t\t\t//NOTE: a result of this is that ground and gap areas can\n\t\t\t//      be merged if the seperating face is the gap\n\t\t\tif ((face2->frontarea == tmparea1 &&\n\t\t\t\t\tface2->backarea == tmparea2) ||\n\t\t\t\t\t(face2->frontarea == tmparea2 &&\n\t\t\t\t\tface2->backarea == tmparea1)) continue;\n\t\t\t//get area2 face flags\n\t\t\tarea2faceflags |= face2->faceflags;\n\t\t\tif (AAS_GapFace(face2, side2)) area2faceflags |= FACE_GAP;\n\t\t\t//if the two faces would create a non-convex area\n\t\t\tif (NonConvex(face1, face2, side1, side2)) return false;\n\t\t} //end for\n\t} //end for\n\t//if one area has gap faces (that aren't seperating the two areas)\n\t//and the other has ground faces (that aren't seperating the two areas),\n\t//the areas can't be merged\n\tif (((area1faceflags & FACE_GROUND) && (area2faceflags & FACE_GAP)) ||\n\t\t\t((area2faceflags & FACE_GROUND) && (area1faceflags & FACE_GAP)))\n\t{\n//\t\tLog_Print(\"   can't merge: ground/gap\\n\");\n\t\treturn false;\n\t} //end if\n\n//\tLog_Print(\"merged area %d & %d to %d with %d faces\\n\", tmparea1->areanum, tmparea2->areanum, newarea->areanum, numfaces);\n//\treturn false;\n\t//\n\t//AAS_CheckArea(tmparea1);\n\t//AAS_CheckArea(tmparea2);\n\t//create the new area\n\tnewarea = AAS_AllocTmpArea();\n\tnewarea->presencetype = tmparea1->presencetype;\n\tnewarea->contents = tmparea1->contents;\n\tnewarea->modelnum = tmparea1->modelnum;\n\tnewarea->tmpfaces = NULL;\n\n\t//add all the faces (except the seperating ones) from the first area\n\t//to the new area\n\tfor (face1 = tmparea1->tmpfaces; face1; face1 = nextface1)\n\t{\n\t\tside1 = (face1->frontarea != tmparea1);\n\t\tnextface1 = face1->next[side1];\n\t\t//don't add seperating faces\n\t\tif ((face1->frontarea == tmparea1 &&\n\t\t\t\tface1->backarea == tmparea2) ||\n\t\t\t\t(face1->frontarea == tmparea2 &&\n\t\t\t\tface1->backarea == tmparea1))\n\t\t{\n\t\t\tcontinue;\n\t\t} //end if\n\t\t//\n\t\tAAS_RemoveFaceFromArea(face1, tmparea1);\n\t\tAAS_AddFaceSideToArea(face1, side1, newarea);\n\t} //end for\n\t//add all the faces (except the seperating ones) from the second area\n\t//to the new area\n\tfor (face2 = tmparea2->tmpfaces; face2; face2 = nextface2)\n\t{\n\t\tside2 = (face2->frontarea != tmparea2);\n\t\tnextface2 = face2->next[side2];\n\t\t//don't add seperating faces\n\t\tif ((face2->frontarea == tmparea1 &&\n\t\t\t\tface2->backarea == tmparea2) ||\n\t\t\t\t(face2->frontarea == tmparea2 &&\n\t\t\t\tface2->backarea == tmparea1))\n\t\t{\n\t\t\tcontinue;\n\t\t} //end if\n\t\t//\n\t\tAAS_RemoveFaceFromArea(face2, tmparea2);\n\t\tAAS_AddFaceSideToArea(face2, side2, newarea);\n\t} //end for\n\t//free all shared faces\n\tfor (face1 = tmparea1->tmpfaces; face1; face1 = nextface1)\n\t{\n\t\tside1 = (face1->frontarea != tmparea1);\n\t\tnextface1 = face1->next[side1];\n\t\t//\n\t\tAAS_RemoveFaceFromArea(face1, face1->frontarea);\n\t\tAAS_RemoveFaceFromArea(face1, face1->backarea);\n\t\tAAS_FreeTmpFace(face1);\n\t} //end for\n\t//\n\ttmparea1->mergedarea = newarea;\n\ttmparea1->invalid = true;\n\ttmparea2->mergedarea = newarea;\n\ttmparea2->invalid = true;\n\t//\n\tAAS_CheckArea(newarea);\n\tAAS_FlipAreaFaces(newarea);\n//\tLog_Print(\"merged area %d & %d to %d with %d faces\\n\", tmparea1->areanum, tmparea2->areanum, newarea->areanum);\n\treturn true;\n} //end of the function AAS_TryMergeFaceAreas\n//===========================================================================\n// try to merge areas\n// merged areas are added to the end of the convex area list so merging\n// will be tried for those areas as well\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\ttmpaasworld\n//===========================================================================\n/*\nvoid AAS_MergeAreas(void)\n{\n\tint side, nummerges;\n\ttmp_area_t *tmparea, *othertmparea;\n\ttmp_face_t *face;\n\n\tnummerges = 0;\n\tLog_Write(\"AAS_MergeAreas\\r\\n\");\n\tqprintf(\"%6d areas merged\", 1);\n\t//first merge grounded areas only\n\t//NOTE: this is useless because the area settings aren't available yet\n\tfor (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)\n\t{\n//\t\tLog_Print(\"checking area %d\\n\", i);\n\t\t//if the area is invalid\n\t\tif (tmparea->invalid)\n\t\t{\n//\t\t\tLog_Print(\"   area invalid\\n\");\n\t\t\tcontinue;\n\t\t} //end if\n\t\t//\n//\t\tif (!(tmparea->settings->areaflags & AREA_GROUNDED)) continue;\n\t\t//\n\t\tfor (face = tmparea->tmpfaces; face; face = face->next[side])\n\t\t{\n\t\t\tside = (face->frontarea != tmparea);\n\t\t\t//if the face has both a front and back area\n\t\t\tif (face->frontarea && face->backarea)\n\t\t\t{\n\t\t\t\t//\n\t\t\t\tif (face->frontarea == tmparea) othertmparea = face->backarea;\n\t\t\t\telse othertmparea = face->frontarea;\n//\t\t\t\tif (!(othertmparea->settings->areaflags & AREA_GROUNDED)) continue;\n//\t\t\t\tLog_Print(\"  checking area %d with %d\\n\", face->frontarea, face->backarea);\n\t\t\t\tif (AAS_TryMergeFaceAreas(face))\n\t\t\t\t{\n\t\t\t\t\tqprintf(\"\\r%6d\", ++nummerges);\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\t//merge all areas\n\tfor (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)\n\t{\n//\t\tLog_Print(\"checking area %d\\n\", i);\n\t\t//if the area is invalid\n\t\tif (tmparea->invalid)\n\t\t{\n//\t\t\tLog_Print(\"   area invalid\\n\");\n\t\t\tcontinue;\n\t\t} //end if\n\t\t//\n\t\tfor (face = tmparea->tmpfaces; face; face = face->next[side])\n\t\t{\n\t\t\tside = (face->frontarea != tmparea);\n\t\t\t//if the face has both a front and back area\n\t\t\tif (face->frontarea && face->backarea)\n\t\t\t{\n//\t\t\t\tLog_Print(\"  checking area %d with %d\\n\", face->frontarea, face->backarea);\n\t\t\t\tif (AAS_TryMergeFaceAreas(face))\n\t\t\t\t{\n\t\t\t\t\tqprintf(\"\\r%6d\", ++nummerges);\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\tLog_Print(\"\\r%6d areas merged\\n\", nummerges);\n\t//refresh the merged tree\n\tAAS_RefreshMergedTree_r(tmpaasworld.nodes);\n} //end of the function AAS_MergeAreas*/\n\nint AAS_GroundArea(tmp_area_t *tmparea)\n{\n\ttmp_face_t *face;\n\tint side;\n\n\tfor (face = tmparea->tmpfaces; face; face = face->next[side])\n\t{\n\t\tside = (face->frontarea != tmparea);\n\t\tif (face->faceflags & FACE_GROUND) return true;\n\t} //end for\n\treturn false;\n} //end of the function AAS_GroundArea\n\nvoid AAS_MergeAreas(void)\n{\n\tint side, nummerges, merges, groundfirst;\n\ttmp_area_t *tmparea, *othertmparea;\n\ttmp_face_t *face;\n\n\tnummerges = 0;\n\tLog_Write(\"AAS_MergeAreas\\r\\n\");\n\tqprintf(\"%6d areas merged\", 1);\n\t//\n\tgroundfirst = true;\n\t//for (i = 0; i < 4 || merges; i++)\n\twhile(1)\n\t{\n\t\t//if (i < 2) groundfirst = true;\n\t\t//else groundfirst = false;\n\t\t//\n\t\tmerges = 0;\n\t\t//first merge grounded areas only\n\t\tfor (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)\n\t\t{\n\t\t\t//if the area is invalid\n\t\t\tif (tmparea->invalid)\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\t//\n\t\t\tif (groundfirst)\n\t\t\t{\n\t\t\t\tif (!AAS_GroundArea(tmparea)) continue;\n\t\t\t} //end if\n\t\t\t//\n\t\t\tfor (face = tmparea->tmpfaces; face; face = face->next[side])\n\t\t\t{\n\t\t\t\tside = (face->frontarea != tmparea);\n\t\t\t\t//if the face has both a front and back area\n\t\t\t\tif (face->frontarea && face->backarea)\n\t\t\t\t{\n\t\t\t\t\t//\n\t\t\t\t\tif (face->frontarea == tmparea) othertmparea = face->backarea;\n\t\t\t\t\telse othertmparea = face->frontarea;\n\t\t\t\t\t//\n\t\t\t\t\tif (groundfirst)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!AAS_GroundArea(othertmparea)) continue;\n\t\t\t\t\t} //end if\n\t\t\t\t\tif (AAS_TryMergeFaceAreas(face))\n\t\t\t\t\t{\n\t\t\t\t\t\tqprintf(\"\\r%6d\", ++nummerges);\n\t\t\t\t\t\tmerges++;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t} //end for\n\t\t} //end for\n\t\tif (!merges)\n\t\t{\n\t\t\tif (groundfirst) groundfirst = false;\n\t\t\telse break;\n\t\t} //end if\n\t} //end for\n\tqprintf(\"\\n\");\n\tLog_Write(\"%6d areas merged\\r\\n\", nummerges);\n\t//refresh the merged tree\n\tAAS_RefreshMergedTree_r(tmpaasworld.nodes);\n} //end of the function AAS_MergeAreas\n"
  },
  {
    "path": "code/bspc/aas_areamerging.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\nvoid AAS_MergeAreas(void);\n\n"
  },
  {
    "path": "code/bspc/aas_cfg.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n#include \"float.h\"\n#include \"../botlib/aasfile.h\"\n#include \"aas_store.h\"\n#include \"aas_cfg.h\"\n#include \"../botlib/l_precomp.h\"\n#include \"../botlib/l_struct.h\"\n#include \"../botlib/l_libvar.h\"\n\n//structure field offsets\n#define BBOX_OFS(x) (int)&(((aas_bbox_t *)0)->x)\n#define CFG_OFS(x) (int)&(((cfg_t *)0)->x)\n\n//bounding box definition\nfielddef_t bbox_fields[] =\n{\n\t{\"presencetype\", BBOX_OFS(presencetype), FT_INT},\n\t{\"flags\", BBOX_OFS(flags), FT_INT},\n\t{\"mins\", BBOX_OFS(mins), FT_FLOAT|FT_ARRAY, 3},\n\t{\"maxs\", BBOX_OFS(maxs), FT_FLOAT|FT_ARRAY, 3},\n\t{NULL, 0, 0, 0}\n};\n\nfielddef_t cfg_fields[] =\n{\n\t{\"phys_gravitydirection\", CFG_OFS(phys_gravitydirection), FT_FLOAT|FT_ARRAY, 3},\n\t{\"phys_friction\", CFG_OFS(phys_friction), FT_FLOAT},\n\t{\"phys_stopspeed\", CFG_OFS(phys_stopspeed), FT_FLOAT},\n\t{\"phys_gravity\", CFG_OFS(phys_gravity), FT_FLOAT},\n\t{\"phys_waterfriction\", CFG_OFS(phys_waterfriction), FT_FLOAT},\n\t{\"phys_watergravity\", CFG_OFS(phys_watergravity), FT_FLOAT},\n\t{\"phys_maxvelocity\", CFG_OFS(phys_maxvelocity), FT_FLOAT},\n\t{\"phys_maxwalkvelocity\", CFG_OFS(phys_maxwalkvelocity), FT_FLOAT},\n\t{\"phys_maxcrouchvelocity\", CFG_OFS(phys_maxcrouchvelocity), FT_FLOAT},\n\t{\"phys_maxswimvelocity\", CFG_OFS(phys_maxswimvelocity), FT_FLOAT},\n\t{\"phys_walkaccelerate\", CFG_OFS(phys_walkaccelerate), FT_FLOAT},\n\t{\"phys_airaccelerate\", CFG_OFS(phys_airaccelerate), FT_FLOAT},\n\t{\"phys_swimaccelerate\", CFG_OFS(phys_swimaccelerate), FT_FLOAT},\n\t{\"phys_maxstep\", CFG_OFS(phys_maxstep), FT_FLOAT},\n\t{\"phys_maxsteepness\", CFG_OFS(phys_maxsteepness), FT_FLOAT},\n\t{\"phys_maxwaterjump\", CFG_OFS(phys_maxwaterjump), FT_FLOAT},\n\t{\"phys_maxbarrier\", CFG_OFS(phys_maxbarrier), FT_FLOAT},\n\t{\"phys_jumpvel\", CFG_OFS(phys_jumpvel), FT_FLOAT},\n\t{\"phys_falldelta5\", CFG_OFS(phys_falldelta5), FT_FLOAT},\n\t{\"phys_falldelta10\", CFG_OFS(phys_falldelta10), FT_FLOAT},\n\t{\"rs_waterjump\", CFG_OFS(rs_waterjump), FT_FLOAT},\n\t{\"rs_teleport\", CFG_OFS(rs_teleport), FT_FLOAT},\n\t{\"rs_barrierjump\", CFG_OFS(rs_barrierjump), FT_FLOAT},\n\t{\"rs_startcrouch\", CFG_OFS(rs_startcrouch), FT_FLOAT},\n\t{\"rs_startgrapple\", CFG_OFS(rs_startgrapple), FT_FLOAT},\n\t{\"rs_startwalkoffledge\", CFG_OFS(rs_startwalkoffledge), FT_FLOAT},\n\t{\"rs_startjump\", CFG_OFS(rs_startjump), FT_FLOAT},\n\t{\"rs_rocketjump\", CFG_OFS(rs_rocketjump), FT_FLOAT},\n\t{\"rs_bfgjump\", CFG_OFS(rs_bfgjump), FT_FLOAT},\n\t{\"rs_jumppad\", CFG_OFS(rs_jumppad), FT_FLOAT},\n\t{\"rs_aircontrolledjumppad\", CFG_OFS(rs_aircontrolledjumppad), FT_FLOAT},\n\t{\"rs_funcbob\", CFG_OFS(rs_funcbob), FT_FLOAT},\n\t{\"rs_startelevator\", CFG_OFS(rs_startelevator), FT_FLOAT},\n\t{\"rs_falldamage5\", CFG_OFS(rs_falldamage5), FT_FLOAT},\n\t{\"rs_falldamage10\", CFG_OFS(rs_falldamage10), FT_FLOAT},\n\t{\"rs_maxjumpfallheight\", CFG_OFS(rs_maxjumpfallheight), FT_FLOAT},\n\t{NULL, 0, 0, 0}\n};\n\nstructdef_t bbox_struct =\n{\n\tsizeof(aas_bbox_t), bbox_fields\n};\nstructdef_t cfg_struct =\n{\n\tsizeof(cfg_t), cfg_fields\n};\n\n//global cfg\ncfg_t cfg;\n\n//===========================================================================\n// the default Q3A configuration\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid DefaultCfg(void)\n{\n\tint i;\n\n\t// default all float values to infinite\n\tfor (i = 0; cfg_fields[i].name; i++)\n\t{\n\t\tif ((cfg_fields[i].type & FT_TYPE) == FT_FLOAT)\n\t\t\t*(float *)( ((char*)&cfg) + cfg_fields[i].offset ) = FLT_MAX;\n\t} //end for\n\t//\n\tcfg.numbboxes = 2;\n\t//bbox 0\n\tcfg.bboxes[0].presencetype = PRESENCE_NORMAL;\n\tcfg.bboxes[0].flags = 0;\n\tcfg.bboxes[0].mins[0] = -15;\n\tcfg.bboxes[0].mins[1] = -15;\n\tcfg.bboxes[0].mins[2] = -24;\n\tcfg.bboxes[0].maxs[0] = 15;\n\tcfg.bboxes[0].maxs[1] = 15;\n\tcfg.bboxes[0].maxs[2] = 32;\n\t//bbox 1\n\tcfg.bboxes[1].presencetype = PRESENCE_CROUCH;\n\tcfg.bboxes[1].flags = 1;\n\tcfg.bboxes[1].mins[0] = -15;\n\tcfg.bboxes[1].mins[1] = -15;\n\tcfg.bboxes[1].mins[2] = -24;\n\tcfg.bboxes[1].maxs[0] = 15;\n\tcfg.bboxes[1].maxs[1] = 15;\n\tcfg.bboxes[1].maxs[2] = 16;\n\t//\n\tcfg.allpresencetypes = PRESENCE_NORMAL|PRESENCE_CROUCH;\n\tcfg.phys_gravitydirection[0]\t= 0;\n\tcfg.phys_gravitydirection[1]\t= 0;\n\tcfg.phys_gravitydirection[2]\t= -1;\n\tcfg.phys_maxsteepness\t\t\t= 0.7;\n} //end of the function DefaultCfg\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nchar\t* QDECL va( char *format, ... )\n{\n\tva_list\t\targptr;\n\tstatic char\t\tstring[2][32000];\t// in case va is called by nested functions\n\tstatic int\t\tindex = 0;\n\tchar\t*buf;\n\n\tbuf = string[index & 1];\n\tindex++;\n\n\tva_start (argptr, format);\n\tvsprintf (buf, format,argptr);\n\tva_end (argptr);\n\n\treturn buf;\n} //end of the function va\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid SetCfgLibVars(void)\n{\n\tint i;\n\tfloat value;\n\n\tfor (i = 0; cfg_fields[i].name; i++)\n\t{\n\t\tif ((cfg_fields[i].type & FT_TYPE) == FT_FLOAT)\n\t\t{\n\t\t\tvalue = *(float *)(((char*)&cfg) + cfg_fields[i].offset);\n\t\t\tif (value != FLT_MAX)\n\t\t\t{\n\t\t\t\tLibVarSet(cfg_fields[i].name, va(\"%f\", value));\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n} //end of the function SetCfgLibVars\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint LoadCfgFile(char *filename)\n{\n\tsource_t *source;\n\ttoken_t token;\n\tint settingsdefined;\n\n\tsource = LoadSourceFile(filename);\n\tif (!source)\n\t{\n\t\tLog_Print(\"couldn't open cfg file %s\\n\", filename);\n\t\treturn false;\n\t} //end if\n\n\tsettingsdefined = false;\n\tmemset(&cfg, 0, sizeof(cfg_t));\n\n\twhile(PC_ReadToken(source, &token))\n\t{\n\t\tif (!stricmp(token.string, \"bbox\"))\n\t\t{\n\t\t\tif (cfg.numbboxes >= AAS_MAX_BBOXES)\n\t\t\t{\n\t\t\t\tSourceError(source, \"too many bounding box volumes defined\");\n\t\t\t} //end if\n\t\t\tif (!ReadStructure(source, &bbox_struct, (char *) &cfg.bboxes[cfg.numbboxes]))\n\t\t\t{\n\t\t\t\tFreeSource(source);\n\t\t\t\treturn false;\n\t\t\t} //end if\n\t\t\tcfg.allpresencetypes |= cfg.bboxes[cfg.numbboxes].presencetype;\n\t\t\tcfg.numbboxes++;\n\t\t} //end if\n\t\telse if (!stricmp(token.string, \"settings\"))\n\t\t{\n\t\t\tif (settingsdefined)\n\t\t\t{\n\t\t\t\tSourceWarning(source, \"settings already defined\\n\");\n\t\t\t} //end if\n\t\t\tsettingsdefined = true;\n\t\t\tif (!ReadStructure(source, &cfg_struct, (char *) &cfg))\n\t\t\t{\n\t\t\t\tFreeSource(source);\n\t\t\t\treturn false;\n\t\t\t} //end if\n\t\t} //end else if\n\t} //end while\n\tif (VectorLength(cfg.phys_gravitydirection) < 0.9 || VectorLength(cfg.phys_gravitydirection) > 1.1)\n\t{\n\t\tSourceError(source, \"invalid gravity direction specified\");\n\t} //end if\n\tif (cfg.numbboxes <= 0)\n\t{\n\t\tSourceError(source, \"no bounding volumes specified\");\n\t} //end if\n\tFreeSource(source);\n\tSetCfgLibVars();\n\tLog_Print(\"using cfg file %s\\n\", filename);\n\treturn true;\n} //end of the function LoadCfgFile\n"
  },
  {
    "path": "code/bspc/aas_cfg.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#define BBOXFL_GROUNDED\t\t\t1\t//bounding box only valid when on ground\n#define BBOXFL_NOTGROUNDED\t\t2\t//bounding box only valid when NOT on ground\n\ntypedef struct cfg_s\n{\n\tint numbboxes;\t\t\t\t\t\t//number of bounding boxes\n\taas_bbox_t bboxes[AAS_MAX_BBOXES];\t//all the bounding boxes\n\tint allpresencetypes;\t\t\t\t//or of all presence types\n\t// aas settings\n\tvec3_t phys_gravitydirection;\n\tfloat phys_friction;\n\tfloat phys_stopspeed;\n\tfloat phys_gravity;\n\tfloat phys_waterfriction;\n\tfloat phys_watergravity;\n\tfloat phys_maxvelocity;\n\tfloat phys_maxwalkvelocity;\n\tfloat phys_maxcrouchvelocity;\n\tfloat phys_maxswimvelocity;\n\tfloat phys_walkaccelerate;\n\tfloat phys_airaccelerate;\n\tfloat phys_swimaccelerate;\n\tfloat phys_maxstep;\n\tfloat phys_maxsteepness;\n\tfloat phys_maxwaterjump;\n\tfloat phys_maxbarrier;\n\tfloat phys_jumpvel;\n\tfloat phys_falldelta5;\n\tfloat phys_falldelta10;\n\tfloat rs_waterjump;\n\tfloat rs_teleport;\n\tfloat rs_barrierjump;\n\tfloat rs_startcrouch;\n\tfloat rs_startgrapple;\n\tfloat rs_startwalkoffledge;\n\tfloat rs_startjump;\n\tfloat rs_rocketjump;\n\tfloat rs_bfgjump;\n\tfloat rs_jumppad;\n\tfloat rs_aircontrolledjumppad;\n\tfloat rs_funcbob;\n\tfloat rs_startelevator;\n\tfloat rs_falldamage5;\n\tfloat rs_falldamage10;\n\tfloat rs_maxjumpfallheight;\n} cfg_t;\n\nextern cfg_t cfg;\n\nvoid DefaultCfg(void);\nint LoadCfgFile(char *filename);\n"
  },
  {
    "path": "code/bspc/aas_create.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n#include \"../botlib/aasfile.h\"\n#include \"aas_create.h\"\n#include \"aas_store.h\"\n#include \"aas_gsubdiv.h\"\n#include \"aas_facemerging.h\"\n#include \"aas_areamerging.h\"\n#include \"aas_edgemelting.h\"\n#include \"aas_prunenodes.h\"\n#include \"aas_cfg.h\"\n#include \"../game/surfaceflags.h\"\n\n//#define AW_DEBUG\n//#define L_DEBUG\n\n#define AREAONFACESIDE(face, area)\t\t(face->frontarea != area)\n\ntmp_aas_t tmpaasworld;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_InitTmpAAS(void)\n{\n\t//tmp faces\n\ttmpaasworld.numfaces = 0;\n\ttmpaasworld.facenum = 0;\n\ttmpaasworld.faces = NULL;\n\t//tmp convex areas\n\ttmpaasworld.numareas = 0;\n\ttmpaasworld.areanum = 0;\n\ttmpaasworld.areas = NULL;\n\t//tmp nodes\n\ttmpaasworld.numnodes = 0;\n\ttmpaasworld.nodes = NULL;\n\t//\n\ttmpaasworld.nodebuffer = NULL;\n} //end of the function AAS_InitTmpAAS\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FreeTmpAAS(void)\n{\n\ttmp_face_t *f, *nextf;\n\ttmp_area_t *a, *nexta;\n\ttmp_nodebuf_t *nb, *nextnb;\n\n\t//free all the faces\n\tfor (f = tmpaasworld.faces; f; f = nextf)\n\t{\n\t\tnextf = f->l_next;\n\t\tif (f->winding) FreeWinding(f->winding);\n\t\tFreeMemory(f);\n\t} //end if\n\t//free all tmp areas\n\tfor (a = tmpaasworld.areas; a; a = nexta)\n\t{\n\t\tnexta = a->l_next;\n\t\tif (a->settings) FreeMemory(a->settings);\n\t\tFreeMemory(a);\n\t} //end for\n\t//free all the tmp nodes\n\tfor (nb = tmpaasworld.nodebuffer; nb; nb = nextnb)\n\t{\n\t\tnextnb = nb->next;\n\t\tFreeMemory(nb);\n\t} //end for\n} //end of the function AAS_FreeTmpAAS\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\ntmp_face_t *AAS_AllocTmpFace(void)\n{\n\ttmp_face_t *tmpface;\n\n\ttmpface = (tmp_face_t *) GetClearedMemory(sizeof(tmp_face_t));\n\ttmpface->num = tmpaasworld.facenum++;\n\ttmpface->l_prev = NULL;\n\ttmpface->l_next = tmpaasworld.faces;\n\tif (tmpaasworld.faces) tmpaasworld.faces->l_prev = tmpface;\n\ttmpaasworld.faces = tmpface;\n\ttmpaasworld.numfaces++;\n\treturn tmpface;\n} //end of the function AAS_AllocTmpFace\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FreeTmpFace(tmp_face_t *tmpface)\n{\n\tif (tmpface->l_next) tmpface->l_next->l_prev = tmpface->l_prev;\n\tif (tmpface->l_prev) tmpface->l_prev->l_next = tmpface->l_next;\n\telse tmpaasworld.faces = tmpface->l_next;\n\t//free the winding\n\tif (tmpface->winding) FreeWinding(tmpface->winding);\n\t//free the face\n\tFreeMemory(tmpface);\n\ttmpaasworld.numfaces--;\n} //end of the function AAS_FreeTmpFace\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\ntmp_area_t *AAS_AllocTmpArea(void)\n{\n\ttmp_area_t *tmparea;\n\n\ttmparea = (tmp_area_t *) GetClearedMemory(sizeof(tmp_area_t));\n\ttmparea->areanum = tmpaasworld.areanum++;\n\ttmparea->l_prev = NULL;\n\ttmparea->l_next = tmpaasworld.areas;\n\tif (tmpaasworld.areas) tmpaasworld.areas->l_prev = tmparea;\n\ttmpaasworld.areas = tmparea;\n\ttmpaasworld.numareas++;\n\treturn tmparea;\n} //end of the function AAS_AllocTmpArea\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FreeTmpArea(tmp_area_t *tmparea)\n{\n\tif (tmparea->l_next) tmparea->l_next->l_prev = tmparea->l_prev;\n\tif (tmparea->l_prev) tmparea->l_prev->l_next = tmparea->l_next;\n\telse tmpaasworld.areas = tmparea->l_next;\n\tif (tmparea->settings) FreeMemory(tmparea->settings);\n\tFreeMemory(tmparea);\n\ttmpaasworld.numareas--;\n} //end of the function AAS_FreeTmpArea\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\ntmp_node_t *AAS_AllocTmpNode(void)\n{\n\ttmp_nodebuf_t *nodebuf;\n\n\tif (!tmpaasworld.nodebuffer ||\n\t\t\ttmpaasworld.nodebuffer->numnodes >= NODEBUF_SIZE)\n\t{\n\t\tnodebuf = (tmp_nodebuf_t *) GetClearedMemory(sizeof(tmp_nodebuf_t));\n\t\tnodebuf->next = tmpaasworld.nodebuffer;\n\t\tnodebuf->numnodes = 0;\n\t\ttmpaasworld.nodebuffer = nodebuf;\n\t} //end if\n\ttmpaasworld.numnodes++;\n\treturn &tmpaasworld.nodebuffer->nodes[tmpaasworld.nodebuffer->numnodes++];\n} //end of the function AAS_AllocTmpNode\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FreeTmpNode(tmp_node_t *tmpnode)\n{\n\ttmpaasworld.numnodes--;\n} //end of the function AAS_FreeTmpNode\n//===========================================================================\n// returns true if the face is a gap from the given side\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_GapFace(tmp_face_t *tmpface, int side)\n{\n\tvec3_t invgravity;\n\n\t//if the face is a solid or ground face it can't be a gap\n\tif (tmpface->faceflags & (FACE_GROUND | FACE_SOLID)) return 0;\n\n\tVectorCopy(cfg.phys_gravitydirection, invgravity);\n\tVectorInverse(invgravity);\n\n\treturn (DotProduct(invgravity, mapplanes[tmpface->planenum ^ side].normal) > cfg.phys_maxsteepness);\n} //end of the function AAS_GapFace\n//===========================================================================\n// returns true if the face is a ground face\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_GroundFace(tmp_face_t *tmpface)\n{\n\tvec3_t invgravity;\n\n\t//must be a solid face\n\tif (!(tmpface->faceflags & FACE_SOLID)) return 0;\n\n\tVectorCopy(cfg.phys_gravitydirection, invgravity);\n\tVectorInverse(invgravity);\n\n\treturn (DotProduct(invgravity, mapplanes[tmpface->planenum].normal) > cfg.phys_maxsteepness);\n} //end of the function AAS_GroundFace\n//===========================================================================\n// adds the side of a face to an area\n//\n// side :\t0 = front side\n//\t\t\t\t1 = back side\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_AddFaceSideToArea(tmp_face_t *tmpface, int side, tmp_area_t *tmparea)\n{\n\tint tmpfaceside;\n\n\tif (side)\n\t{\n\t\tif (tmpface->backarea) Error(\"AAS_AddFaceSideToArea: already a back area\\n\");\n\t} //end if\n\telse\n\t{\n\t\tif (tmpface->frontarea) Error(\"AAS_AddFaceSideToArea: already a front area\\n\");\n\t} //end else\n\n\tif (side) tmpface->backarea = tmparea;\n\telse tmpface->frontarea = tmparea;\n\n\tif (tmparea->tmpfaces)\n\t{\n\t\ttmpfaceside = tmparea->tmpfaces->frontarea != tmparea;\n\t\ttmparea->tmpfaces->prev[tmpfaceside] = tmpface;\n\t} //end if\n\ttmpface->next[side] = tmparea->tmpfaces;\n\ttmpface->prev[side] = NULL;\n\ttmparea->tmpfaces = tmpface;\n} //end of the function AAS_AddFaceSideToArea\n//===========================================================================\n// remove (a side of) a face from an area\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_RemoveFaceFromArea(tmp_face_t *tmpface, tmp_area_t *tmparea)\n{\n\tint side, prevside, nextside;\n\n\tif (tmpface->frontarea != tmparea &&\n\t\t\ttmpface->backarea != tmparea)\n\t{\n\t\tError(\"AAS_RemoveFaceFromArea: face not part of the area\");\n\t} //end if\n\tside = tmpface->frontarea != tmparea;\n\tif (tmpface->prev[side])\n\t{\n\t\tprevside = tmpface->prev[side]->frontarea != tmparea;\n\t\ttmpface->prev[side]->next[prevside] = tmpface->next[side];\n\t} //end if\n\telse\n\t{\n\t\ttmparea->tmpfaces = tmpface->next[side];\n\t} //end else\n\tif (tmpface->next[side])\n\t{\n\t\tnextside = tmpface->next[side]->frontarea != tmparea;\n\t\ttmpface->next[side]->prev[nextside] = tmpface->prev[side];\n\t} //end if\n\t//remove the area number from the face depending on the side\n\tif (side) tmpface->backarea = NULL;\n\telse tmpface->frontarea = NULL;\n\ttmpface->prev[side] = NULL;\n\ttmpface->next[side] = NULL;\n} //end of the function AAS_RemoveFaceFromArea\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_CheckArea(tmp_area_t *tmparea)\n{\n\tint side;\n\ttmp_face_t *face;\n\tplane_t *plane;\n\tvec3_t wcenter, acenter = {0, 0, 0};\n\tvec3_t normal;\n\tfloat n, dist;\n\n\tif (tmparea->invalid) Log_Print(\"AAS_CheckArea: invalid area\\n\");\n\tfor (n = 0, face = tmparea->tmpfaces; face; face = face->next[side])\n\t{\n\t\t//side of the face the area is on\n\t\tside = face->frontarea != tmparea;\n\t\tWindingCenter(face->winding, wcenter);\n\t\tVectorAdd(acenter, wcenter, acenter);\n\t\tn++;\n\t} //end for\n\tn = 1 / n;\n\tVectorScale(acenter, n, acenter);\n\tfor (face = tmparea->tmpfaces; face; face = face->next[side])\n\t{\n\t\t//side of the face the area is on\n\t\tside = face->frontarea != tmparea;\n\n#ifdef L_DEBUG\n\t\tif (WindingError(face->winding))\n\t\t{\n\t\t\tLog_Write(\"AAS_CheckArea: area %d face %d: %s\\r\\n\", tmparea->areanum,\n\t\t\t\t\t\tface->num, WindingErrorString());\n\t\t} //end if\n#endif L_DEBUG\n\n\t\tplane = &mapplanes[face->planenum ^ side];\n\n\t\tif (DotProduct(plane->normal, acenter) - plane->dist < 0)\n\t\t{\n\t\t\tLog_Print(\"AAS_CheckArea: area %d face %d is flipped\\n\", tmparea->areanum, face->num);\n\t\t\tLog_Print(\"AAS_CheckArea: area %d center is %f %f %f\\n\", tmparea->areanum, acenter[0], acenter[1], acenter[2]);\n\t\t} //end if\n\t\t//check if the winding plane is the same as the face plane\n\t\tWindingPlane(face->winding, normal, &dist);\n\t\tplane = &mapplanes[face->planenum];\n#ifdef L_DEBUG\n\t\tif (fabs(dist - plane->dist) > 0.4 ||\n\t\t\t\tfabs(normal[0] - plane->normal[0]) > 0.0001 ||\n\t\t\t\tfabs(normal[1] - plane->normal[1]) > 0.0001 ||\n\t\t\t\tfabs(normal[2] - plane->normal[2]) > 0.0001)\n\t\t{\n\t\t\tLog_Write(\"AAS_CheckArea: area %d face %d winding plane unequal to face plane\\r\\n\",\n\t\t\t\t\t\t\t\t\t\ttmparea->areanum, face->num);\n\t\t} //end if\n#endif L_DEBUG\n\t} //end for\n} //end of the function AAS_CheckArea\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_CheckFaceWindingPlane(tmp_face_t *face)\n{\n\tfloat dist, sign1, sign2;\n\tvec3_t normal;\n\tplane_t *plane;\n\twinding_t *w;\n\n\t//check if the winding plane is the same as the face plane\n\tWindingPlane(face->winding, normal, &dist);\n\tplane = &mapplanes[face->planenum];\n\t//\n\tsign1 = DotProduct(plane->normal, normal);\n\t//\n\tif (fabs(dist - plane->dist) > 0.4 ||\n\t\t\tfabs(normal[0] - plane->normal[0]) > 0.0001 ||\n\t\t\tfabs(normal[1] - plane->normal[1]) > 0.0001 ||\n\t\t\tfabs(normal[2] - plane->normal[2]) > 0.0001)\n\t{\n\t\tVectorInverse(normal);\n\t\tdist = -dist;\n\t\tif (fabs(dist - plane->dist) > 0.4 ||\n\t\t\t\tfabs(normal[0] - plane->normal[0]) > 0.0001 ||\n\t\t\t\tfabs(normal[1] - plane->normal[1]) > 0.0001 ||\n\t\t\t\tfabs(normal[2] - plane->normal[2]) > 0.0001)\n\t\t{\n\t\t\tLog_Write(\"AAS_CheckFaceWindingPlane: face %d winding plane unequal to face plane\\r\\n\",\n\t\t\t\t\t\t\t\t\tface->num);\n\t\t\t//\n\t\t\tsign2 = DotProduct(plane->normal, normal);\n\t\t\tif ((sign1 < 0 && sign2 > 0) ||\n\t\t\t\t\t(sign1 > 0 && sign2 < 0))\n\t\t\t{\n\t\t\t\tLog_Write(\"AAS_CheckFaceWindingPlane: face %d winding reversed\\r\\n\",\n\t\t\t\t\t\t\t\t\tface->num);\n\t\t\t\tw = face->winding;\n\t\t\t\tface->winding = ReverseWinding(w);\n\t\t\t\tFreeWinding(w);\n\t\t\t} //end if\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tLog_Write(\"AAS_CheckFaceWindingPlane: face %d winding reversed\\r\\n\",\n\t\t\t\t\t\t\t\t\tface->num);\n\t\t\tw = face->winding;\n\t\t\tface->winding = ReverseWinding(w);\n\t\t\tFreeWinding(w);\n\t\t} //end else\n\t} //end if\n} //end of the function AAS_CheckFaceWindingPlane\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_CheckAreaWindingPlanes(void)\n{\n\tint side;\n\ttmp_area_t *tmparea;\n\ttmp_face_t *face;\n\n\tLog_Write(\"AAS_CheckAreaWindingPlanes:\\r\\n\");\n\tfor (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)\n\t{\n\t\tif (tmparea->invalid) continue;\n\t\tfor (face = tmparea->tmpfaces; face; face = face->next[side])\n\t\t{\n\t\t\tside = face->frontarea != tmparea;\n\t\t\tAAS_CheckFaceWindingPlane(face);\n\t\t} //end for\n\t} //end for\n} //end of the function AAS_CheckAreaWindingPlanes\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FlipAreaFaces(tmp_area_t *tmparea)\n{\n\tint side;\n\ttmp_face_t *face;\n\tplane_t *plane;\n\tvec3_t wcenter, acenter = {0, 0, 0};\n\t//winding_t *w;\n\tfloat n;\n\n\tfor (n = 0, face = tmparea->tmpfaces; face; face = face->next[side])\n\t{\n\t\tif (!face->frontarea) Error(\"face %d has no front area\\n\", face->num);\n\t\t//side of the face the area is on\n\t\tside = face->frontarea != tmparea;\n\t\tWindingCenter(face->winding, wcenter);\n\t\tVectorAdd(acenter, wcenter, acenter);\n\t\tn++;\n\t} //end for\n\tn = 1 / n;\n\tVectorScale(acenter, n, acenter);\n\tfor (face = tmparea->tmpfaces; face; face = face->next[side])\n\t{\n\t\t//side of the face the area is on\n\t\tside = face->frontarea != tmparea;\n\n\t\tplane = &mapplanes[face->planenum ^ side];\n\n\t\tif (DotProduct(plane->normal, acenter) - plane->dist < 0)\n\t\t{\n\t\t\tLog_Print(\"area %d face %d flipped: front area %d, back area %d\\n\", tmparea->areanum, face->num,\n\t\t\t\t\tface->frontarea ? face->frontarea->areanum : 0,\n\t\t\t\t\tface->backarea ? face->backarea->areanum : 0);\n\t\t\t/*\n\t\t\tface->planenum = face->planenum ^ 1;\n\t\t\tw = face->winding;\n\t\t\tface->winding = ReverseWinding(w);\n\t\t\tFreeWinding(w);\n\t\t\t*/\n\t\t} //end if\n#ifdef L_DEBUG\n\t\t{\n\t\t\tfloat dist;\n\t\t\tvec3_t normal;\n\n\t\t\t//check if the winding plane is the same as the face plane\n\t\t\tWindingPlane(face->winding, normal, &dist);\n\t\t\tplane = &mapplanes[face->planenum];\n\t\t\tif (fabs(dist - plane->dist) > 0.4 ||\n\t\t\t\t\tfabs(normal[0] - plane->normal[0]) > 0.0001 ||\n\t\t\t\t\tfabs(normal[1] - plane->normal[1]) > 0.0001 ||\n\t\t\t\t\tfabs(normal[2] - plane->normal[2]) > 0.0001)\n\t\t\t{\n\t\t\t\tLog_Write(\"area %d face %d winding plane unequal to face plane\\r\\n\",\n\t\t\t\t\t\t\t\t\t\t\ttmparea->areanum, face->num);\n\t\t\t} //end if\n\t\t}\n#endif\n\t} //end for\n} //end of the function AAS_FlipAreaFaces\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_RemoveAreaFaceColinearPoints(void)\n{\n\tint side;\n\ttmp_face_t *face;\n\ttmp_area_t *tmparea;\n\n\t//FIXME: loop over the faces instead of area->faces\n\tfor (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)\n\t{\n\t\tfor (face = tmparea->tmpfaces; face; face = face->next[side])\n\t\t{\n\t\t\tside = face->frontarea != tmparea;\n\t\t\tRemoveColinearPoints(face->winding);\n//\t\t\tRemoveEqualPoints(face->winding, 0.1);\n\t\t} //end for\n\t} //end for\n} //end of the function AAS_RemoveAreaFaceColinearPoints\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_RemoveTinyFaces(void)\n{\n\tint side, num;\n\ttmp_face_t *face, *nextface;\n\ttmp_area_t *tmparea;\n\n\t//FIXME: loop over the faces instead of area->faces\n\tLog_Write(\"AAS_RemoveTinyFaces\\r\\n\");\n\tnum = 0;\n\tfor (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)\n\t{\n\t\tfor (face = tmparea->tmpfaces; face; face = nextface)\n\t\t{\n\t\t\tside = face->frontarea != tmparea;\n\t\t\tnextface = face->next[side];\n\t\t\t//\n\t\t\tif (WindingArea(face->winding) < 1)\n\t\t\t{\n\t\t\t\tif (face->frontarea) AAS_RemoveFaceFromArea(face, face->frontarea);\n\t\t\t\tif (face->backarea) AAS_RemoveFaceFromArea(face, face->backarea);\n\t\t\t\tAAS_FreeTmpFace(face);\n\t\t\t\t//Log_Write(\"area %d face %d is tiny\\r\\n\", tmparea->areanum, face->num);\n\t\t\t\tnum++;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\tLog_Write(\"%d tiny faces removed\\r\\n\", num);\n} //end of the function AAS_RemoveTinyFaces\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_CreateAreaSettings(void)\n{\n\tint i, flags, side, numgrounded, numladderareas, numliquidareas;\n\ttmp_face_t *face;\n\ttmp_area_t *tmparea;\n\n\tnumgrounded = 0;\n\tnumladderareas = 0;\n\tnumliquidareas = 0;\n\tLog_Write(\"AAS_CreateAreaSettings\\r\\n\");\n\ti = 0;\n\tqprintf(\"%6d areas provided with settings\", i);\n\tfor (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)\n\t{\n\t\t//if the area is invalid there no need to create settings for it\n\t\tif (tmparea->invalid) continue;\n\n\t\ttmparea->settings = (tmp_areasettings_t *) GetClearedMemory(sizeof(tmp_areasettings_t));\n\t\ttmparea->settings->contents = tmparea->contents;\n\t\ttmparea->settings->modelnum = tmparea->modelnum;\n\t\tflags = 0;\n\t\tfor (face = tmparea->tmpfaces; face; face = face->next[side])\n\t\t{\n\t\t\tside = face->frontarea != tmparea;\n\t\t\tflags |= face->faceflags;\n\t\t} //end for\n\t\ttmparea->settings->areaflags = 0;\n\t\tif (flags & FACE_GROUND)\n\t\t{\n\t\t\ttmparea->settings->areaflags |= AREA_GROUNDED;\n\t\t\tnumgrounded++;\n\t\t} //end if\n\t\tif (flags & FACE_LADDER)\n\t\t{\n\t\t\ttmparea->settings->areaflags |= AREA_LADDER;\n\t\t\tnumladderareas++;\n\t\t} //end if\n\t\tif (tmparea->contents & (AREACONTENTS_WATER |\n\t\t\t\t\t\t\t\t\t\t\tAREACONTENTS_SLIME |\n\t\t\t\t\t\t\t\t\t\t\tAREACONTENTS_LAVA))\n\t\t{\n\t\t\ttmparea->settings->areaflags |= AREA_LIQUID;\n\t\t\tnumliquidareas++;\n\t\t} //end if\n\t\t//presence type of the area\n\t\ttmparea->settings->presencetype = tmparea->presencetype;\n\t\t//\n\t\tqprintf(\"\\r%6d\", ++i);\n\t} //end for\n\tqprintf(\"\\n\");\n#ifdef AASINFO\n\tLog_Print(\"%6d grounded areas\\n\", numgrounded);\n\tLog_Print(\"%6d ladder areas\\n\", numladderareas);\n\tLog_Print(\"%6d liquid areas\\n\", numliquidareas);\n#endif //AASINFO\n} //end of the function AAS_CreateAreaSettings\n//===========================================================================\n// create a tmp AAS area from a leaf node\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\ntmp_node_t *AAS_CreateArea(node_t *node)\n{\n\tint pside;\n\tint areafaceflags;\n\tportal_t\t*p;\n\ttmp_face_t *tmpface;\n\ttmp_area_t *tmparea;\n\ttmp_node_t *tmpnode;\n\tvec3_t up = {0, 0, 1};\n\n\t//create an area from this leaf\n\ttmparea = AAS_AllocTmpArea();\n\ttmparea->tmpfaces = NULL;\n\t//clear the area face flags\n\tareafaceflags = 0;\n\t//make aas faces from the portals\n\tfor (p = node->portals; p; p = p->next[pside])\n\t{\n\t\tpside = (p->nodes[1] == node);\n\t\t//don't create faces from very small portals\n//\t\tif (WindingArea(p->winding) < 1) continue;\n\t\t//if there's already a face created for this portal\n\t\tif (p->tmpface)\n\t\t{\n\t\t\t//add the back side of the face to the area\n\t\t\tAAS_AddFaceSideToArea(p->tmpface, 1, tmparea);\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\ttmpface = AAS_AllocTmpFace();\n\t\t\t//set the face pointer at the portal so we can see from\n\t\t\t//the portal there's a face created for it\n\t\t\tp->tmpface = tmpface;\n\t\t\t//FIXME: test this change\n\t\t\t//tmpface->planenum = (p->planenum & ~1) | pside;\n\t\t\ttmpface->planenum = p->planenum ^ pside;\n\t\t\tif (pside) tmpface->winding = ReverseWinding(p->winding);\n\t\t\telse tmpface->winding = CopyWinding(p->winding);\n#ifdef L_DEBUG\n\t\t\t//\n\t\t\tAAS_CheckFaceWindingPlane(tmpface);\n#endif //L_DEBUG\n\t\t\t//if there's solid at the other side of the portal\n\t\t\tif (p->nodes[!pside]->contents & (CONTENTS_SOLID | CONTENTS_PLAYERCLIP))\n\t\t\t{\n\t\t\t\ttmpface->faceflags |= FACE_SOLID;\n\t\t\t} //end if\n\t\t\t//else there is no solid at the other side and if there\n\t\t\t//is a liquid at this side\n\t\t\telse if (node->contents & (CONTENTS_WATER|CONTENTS_SLIME|CONTENTS_LAVA))\n\t\t\t{\n\t\t\t\ttmpface->faceflags |= FACE_LIQUID;\n\t\t\t\t//if there's no liquid at the other side\n\t\t\t\tif (!(p->nodes[!pside]->contents & (CONTENTS_WATER|CONTENTS_SLIME|CONTENTS_LAVA)))\n\t\t\t\t{\n\t\t\t\t\ttmpface->faceflags |= FACE_LIQUIDSURFACE;\n\t\t\t\t} //end if\n\t\t\t} //end else\n\t\t\t//if there's ladder contents at other side of the portal\n\t\t\tif ((p->nodes[pside]->contents & CONTENTS_LADDER) ||\n\t\t\t\t\t(p->nodes[!pside]->contents & CONTENTS_LADDER))\n\t\t\t{\n\n\t\t\t\t//NOTE: doesn't have to be solid at the other side because\n\t\t\t\t// when standing one can use a crouch area (which is not solid)\n\t\t\t\t// as a ladder\n\t\t\t\t// imagine a ladder one can walk underthrough,\n\t\t\t\t// under the ladder against the ladder is a crouch area\n\t\t\t\t// the (vertical) sides of this crouch area area also used as\n\t\t\t\t// ladder sides when standing (not crouched)\n\t\t\t\ttmpface->faceflags |= FACE_LADDER;\n\t\t\t} //end if\n\t\t\t//if it is possible to stand on the face\n\t\t\tif (AAS_GroundFace(tmpface))\n\t\t\t{\n\t\t\t\ttmpface->faceflags |= FACE_GROUND;\n\t\t\t} //end if\n\t\t\t//\n\t\t\tareafaceflags |= tmpface->faceflags;\n\t\t\t//no aas face number yet (zero is a dummy in the aasworld faces)\n\t\t\ttmpface->aasfacenum = 0;\n\t\t\t//add the front side of the face to the area\n\t\t\tAAS_AddFaceSideToArea(tmpface, 0, tmparea);\n\t\t} //end else\n\t} //end for\n\tqprintf(\"\\r%6d\", tmparea->areanum);\n\t//presence type in the area\n\ttmparea->presencetype = ~node->expansionbboxes & cfg.allpresencetypes;\n\t//\n\ttmparea->contents = 0;\n\tif (node->contents & CONTENTS_CLUSTERPORTAL) tmparea->contents |= AREACONTENTS_CLUSTERPORTAL;\n\tif (node->contents & CONTENTS_MOVER) tmparea->contents |= AREACONTENTS_MOVER;\n\tif (node->contents & CONTENTS_TELEPORTER) tmparea->contents |= AREACONTENTS_TELEPORTER;\n\tif (node->contents & CONTENTS_JUMPPAD) tmparea->contents |= AREACONTENTS_JUMPPAD;\n\tif (node->contents & CONTENTS_DONOTENTER) tmparea->contents |= AREACONTENTS_DONOTENTER;\n\tif (node->contents & CONTENTS_WATER) tmparea->contents |= AREACONTENTS_WATER;\n\tif (node->contents & CONTENTS_LAVA) tmparea->contents |= AREACONTENTS_LAVA;\n\tif (node->contents & CONTENTS_SLIME) tmparea->contents |= AREACONTENTS_SLIME;\n\tif (node->contents & CONTENTS_NOTTEAM1) tmparea->contents |= AREACONTENTS_NOTTEAM1;\n\tif (node->contents & CONTENTS_NOTTEAM2) tmparea->contents |= AREACONTENTS_NOTTEAM2;\n\n\t//store the bsp model that's inside this node\n\ttmparea->modelnum = node->modelnum;\n\t//sorta check for flipped area faces (remove??)\n\tAAS_FlipAreaFaces(tmparea);\n\t//check if the area is ok (remove??)\n\tAAS_CheckArea(tmparea);\n\t//\n\ttmpnode = AAS_AllocTmpNode();\n\ttmpnode->planenum = 0;\n\ttmpnode->children[0] = 0;\n\ttmpnode->children[1] = 0;\n\ttmpnode->tmparea = tmparea;\n\t//\n\treturn tmpnode;\n} //end of the function AAS_CreateArea\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\ntmp_node_t *AAS_CreateAreas_r(node_t *node)\n{\n\ttmp_node_t *tmpnode;\n\n\t//recurse down to leafs\n\tif (node->planenum != PLANENUM_LEAF)\n\t{\n\t\t//the first tmp node is a dummy\n\t\ttmpnode = AAS_AllocTmpNode();\n\t\ttmpnode->planenum = node->planenum;\n\t\ttmpnode->children[0] = AAS_CreateAreas_r(node->children[0]);\n\t\ttmpnode->children[1] = AAS_CreateAreas_r(node->children[1]);\n\t\treturn tmpnode;\n\t} //end if\n\t//areas won't be created for solid leafs\n\tif (node->contents & CONTENTS_SOLID)\n\t{\n\t\t//just return zero for a solid leaf (in tmp AAS NULL is a solid leaf)\n\t\treturn NULL;\n\t} //end if\n\n\treturn AAS_CreateArea(node);\n} //end of the function AAS_CreateAreas_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_CreateAreas(node_t *node)\n{\n\tLog_Write(\"AAS_CreateAreas\\r\\n\");\n\tqprintf(\"%6d areas created\", 0);\n\ttmpaasworld.nodes = AAS_CreateAreas_r(node);\n\tqprintf(\"\\n\");\n\tLog_Write(\"%6d areas created\\r\\n\", tmpaasworld.numareas);\n} //end of the function AAS_CreateAreas\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_PrintNumGroundFaces(void)\n{\n\ttmp_face_t *tmpface;\n\tint numgroundfaces = 0;\n\n\tfor (tmpface = tmpaasworld.faces; tmpface; tmpface = tmpface->l_next)\n\t{\n\t\tif (tmpface->faceflags & FACE_GROUND)\n\t\t{\n\t\t\tnumgroundfaces++;\n\t\t} //end if\n\t} //end for\n\tqprintf(\"%6d ground faces\\n\", numgroundfaces);\n} //end of the function AAS_PrintNumGroundFaces\n//===========================================================================\n// checks the number of shared faces between the given two areas\n// since areas are convex they should only have ONE shared face\n// however due to crappy face merging there are sometimes several\n// shared faces\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_CheckAreaSharedFaces(tmp_area_t *tmparea1, tmp_area_t *tmparea2)\n{\n\tint numsharedfaces, side;\n\ttmp_face_t *face1, *sharedface;\n\n\tif (tmparea1->invalid || tmparea2->invalid) return;\n\n\tsharedface = NULL;\n\tnumsharedfaces = 0;\n\tfor (face1 = tmparea1->tmpfaces; face1; face1 = face1->next[side])\n\t{\n\t\tside = face1->frontarea != tmparea1;\n\t\tif (face1->backarea == tmparea2 || face1->frontarea == tmparea2)\n\t\t{\n\t\t\tsharedface = face1;\n\t\t\tnumsharedfaces++;\n\t\t} //end if\n\t} //end if\n\tif (!sharedface) return;\n\t//the areas should only have one shared face\n\tif (numsharedfaces > 1)\n\t{\n\t\tLog_Write(\"---- tmp area %d and %d have %d shared faces\\r\\n\",\n\t\t\t\t\t\t\t\t\ttmparea1->areanum, tmparea2->areanum, numsharedfaces);\n\t\tfor (face1 = tmparea1->tmpfaces; face1; face1 = face1->next[side])\n\t\t{\n\t\t\tside = face1->frontarea != tmparea1;\n\t\t\tif (face1->backarea == tmparea2 || face1->frontarea == tmparea2)\n\t\t\t{\n\t\t\t\tLog_Write(\"face %d, planenum = %d, face->frontarea = %d face->backarea = %d\\r\\n\",\n\t\t\t\t\t\t\t\tface1->num, face1->planenum, face1->frontarea->areanum, face1->backarea->areanum);\n\t\t\t} //end if\n\t\t} //end if\n\t} //end if\n} //end of the function AAS_CheckAreaSharedFaces\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_CheckSharedFaces(void)\n{\n\ttmp_area_t *tmparea1, *tmparea2;\n\n\tfor (tmparea1 = tmpaasworld.areas; tmparea1; tmparea1 = tmparea1->l_next)\n\t{\n\t\tfor (tmparea2 = tmpaasworld.areas; tmparea2; tmparea2 = tmparea2->l_next)\n\t\t{\n\t\t\tif (tmparea1 == tmparea2) continue;\n\t\t\tAAS_CheckAreaSharedFaces(tmparea1, tmparea2);\n\t\t} //end for\n\t} //end for\n} //end of the function AAS_CheckSharedFaces\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FlipFace(tmp_face_t *face)\n{\n\ttmp_area_t *frontarea, *backarea;\n\twinding_t *w;\n\n\tfrontarea = face->frontarea;\n\tbackarea = face->backarea;\n\t//must have an area at both sides before flipping is allowed\n\tif (!frontarea || !backarea) return;\n\t//flip the face winding\n\tw = face->winding;\n\tface->winding = ReverseWinding(w);\n\tFreeWinding(w);\n\t//flip the face plane\n\tface->planenum ^= 1;\n\t//flip the face areas\n\tAAS_RemoveFaceFromArea(face, frontarea);\n\tAAS_RemoveFaceFromArea(face, backarea);\n\tAAS_AddFaceSideToArea(face, 1, frontarea);\n\tAAS_AddFaceSideToArea(face, 0, backarea);\n} //end of the function AAS_FlipFace\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n/*\nvoid AAS_FlipAreaSharedFaces(tmp_area_t *tmparea1, tmp_area_t *tmparea2)\n{\n\tint numsharedfaces, side, area1facing, area2facing;\n\ttmp_face_t *face1, *sharedface;\n\n\tif (tmparea1->invalid || tmparea2->invalid) return;\n\n\tsharedface = NULL;\n\tnumsharedfaces = 0;\n\tarea1facing = 0;\t\t//number of shared faces facing towards area 1\n\tarea2facing = 0;\t\t//number of shared faces facing towards area 2\n\tfor (face1 = tmparea1->tmpfaces; face1; face1 = face1->next[side])\n\t{\n\t\tside = face1->frontarea != tmparea1;\n\t\tif (face1->backarea == tmparea2 || face1->frontarea == tmparea2)\n\t\t{\n\t\t\tsharedface = face1;\n\t\t\tnumsharedfaces++;\n\t\t\tif (face1->frontarea == tmparea1) area1facing++;\n\t\t\telse area2facing++;\n\t\t} //end if\n\t} //end if\n\tif (!sharedface) return;\n\t//if there's only one shared face\n\tif (numsharedfaces <= 1) return;\n\t//if all the shared faces are facing to the same area\n\tif (numsharedfaces == area1facing || numsharedfaces == area2facing) return;\n\t//\n\tdo\n\t{\n\t\tfor (face1 = tmparea1->tmpfaces; face1; face1 = face1->next[side])\n\t\t{\n\t\t\tside = face1->frontarea != tmparea1;\n\t\t\tif (face1->backarea == tmparea2 || face1->frontarea == tmparea2)\n\t\t\t{\n\t\t\t\tif (face1->frontarea != tmparea1)\n\t\t\t\t{\n\t\t\t\t\tAAS_FlipFace(face1);\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end for\n\t} while(face1);\n} //end of the function AAS_FlipAreaSharedFaces\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FlipSharedFaces(void)\n{\n\tint i;\n\ttmp_area_t *tmparea1, *tmparea2;\n\n\ti = 0;\n\tqprintf(\"%6d areas checked for shared face flipping\", i);\n\tfor (tmparea1 = tmpaasworld.areas; tmparea1; tmparea1 = tmparea1->l_next)\n\t{\n\t\tif (tmparea1->invalid) continue;\n\t\tfor (tmparea2 = tmpaasworld.areas; tmparea2; tmparea2 = tmparea2->l_next)\n\t\t{\n\t\t\tif (tmparea2->invalid) continue;\n\t\t\tif (tmparea1 == tmparea2) continue;\n\t\t\tAAS_FlipAreaSharedFaces(tmparea1, tmparea2);\n\t\t} //end for\n\t\tqprintf(\"\\r%6d\", ++i);\n\t} //end for\n\tLog_Print(\"\\r%6d areas checked for shared face flipping\\n\", i);\n} //end of the function AAS_FlipSharedFaces\n*/\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FlipSharedFaces(void)\n{\n\tint i, side1, side2;\n\ttmp_area_t *tmparea1;\n\ttmp_face_t *face1, *face2;\n\n\ti = 0;\n\tqprintf(\"%6d areas checked for shared face flipping\", i);\n\tfor (tmparea1 = tmpaasworld.areas; tmparea1; tmparea1 = tmparea1->l_next)\n\t{\n\t\tif (tmparea1->invalid) continue;\n\t\tfor (face1 = tmparea1->tmpfaces; face1; face1 = face1->next[side1])\n\t\t{\n\t\t\tside1 = face1->frontarea != tmparea1;\n\t\t\tif (!face1->frontarea || !face1->backarea) continue;\n\t\t\t//\n\t\t\tfor (face2 = face1->next[side1]; face2; face2 = face2->next[side2])\n\t\t\t{\n\t\t\t\tside2 = face2->frontarea != tmparea1;\n\t\t\t\tif (!face2->frontarea || !face2->backarea) continue;\n\t\t\t\t//\n\t\t\t\tif (face1->frontarea == face2->backarea &&\n\t\t\t\t\tface1->backarea == face2->frontarea)\n\t\t\t\t{\n\t\t\t\t\tAAS_FlipFace(face2);\n\t\t\t\t} //end if\n\t\t\t\t//recheck side\n\t\t\t\tside2 = face2->frontarea != tmparea1;\n\t\t\t} //end for\n\t\t} //end for\n\t\tqprintf(\"\\r%6d\", ++i);\n\t} //end for\n\tqprintf(\"\\n\");\n\tLog_Write(\"%6d areas checked for shared face flipping\\r\\n\", i);\n} //end of the function AAS_FlipSharedFaces\n//===========================================================================\n// creates an .AAS file with the given name\n// a MAP should be loaded before calling this\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_Create(char *aasfile)\n{\n\tentity_t\t*e;\n\ttree_t *tree;\n\tdouble start_time;\n\n\t//for a possible leak file\n\tstrcpy(source, aasfile);\n\tStripExtension(source);\n\t//the time started\n\tstart_time = I_FloatTime();\n\t//set the default number of threads (depends on number of processors)\n\tThreadSetDefault();\n\t//set the global entity number to the world model\n\tentity_num = 0;\n\t//the world entity\n\te = &entities[entity_num];\n\t//process the whole world\n\ttree = ProcessWorldBrushes(e->firstbrush, e->firstbrush + e->numbrushes);\n\t//if the conversion is cancelled\n\tif (cancelconversion)\n\t{\n\t\tTree_Free(tree);\n\t\treturn;\n\t} //end if\n\t//display BSP tree creation time\n\tLog_Print(\"BSP tree created in %5.0f seconds\\n\", I_FloatTime() - start_time);\n\t//prune the bsp tree\n\tTree_PruneNodes(tree->headnode);\n\t//if the conversion is cancelled\n\tif (cancelconversion)\n\t{\n\t\tTree_Free(tree);\n\t\treturn;\n\t} //end if\n\t//create the tree portals\n\tMakeTreePortals(tree);\n\t//if the conversion is cancelled\n\tif (cancelconversion)\n\t{\n\t\tTree_Free(tree);\n\t\treturn;\n\t} //end if\n\t//Marks all nodes that can be reached by entites\n\tif (FloodEntities(tree))\n\t{\n\t\t//fill out nodes that can't be reached\n\t\tFillOutside(tree->headnode);\n\t} //end if\n\telse\n\t{\n\t\tLeakFile(tree);\n\t\tError(\"**** leaked ****\\n\");\n\t\treturn;\n\t} //end else\n\t//create AAS from the BSP tree\n\t//==========================================\n\t//initialize tmp aas\n\tAAS_InitTmpAAS();\n\t//create the convex areas from the leaves\n\tAAS_CreateAreas(tree->headnode);\n\t//free the BSP tree because it isn't used anymore\n\tif (freetree) Tree_Free(tree);\n\t//try to merge area faces\n\tAAS_MergeAreaFaces();\n\t//do gravitational subdivision\n\tAAS_GravitationalSubdivision();\n\t//merge faces if possible\n\tAAS_MergeAreaFaces();\n\tAAS_RemoveAreaFaceColinearPoints();\n\t//merge areas if possible\n\tAAS_MergeAreas();\n\t//NOTE: prune nodes directly after area merging\n\tAAS_PruneNodes();\n\t//flip shared faces so they are all facing to the same area\n\tAAS_FlipSharedFaces();\n\tAAS_RemoveAreaFaceColinearPoints();\n\t//merge faces if possible\n\tAAS_MergeAreaFaces();\n\t//merge area faces in the same plane\n\tAAS_MergeAreaPlaneFaces();\n\t//do ladder subdivision\n\tAAS_LadderSubdivision();\n\t//FIXME: melting is buggy\n\tAAS_MeltAreaFaceWindings();\n\t//remove tiny faces\n\tAAS_RemoveTinyFaces();\n\t//create area settings\n\tAAS_CreateAreaSettings();\n\t//check if the winding plane is equal to the face plane\n\t//AAS_CheckAreaWindingPlanes();\n\t//\n\t//AAS_CheckSharedFaces();\n\t//==========================================\n\t//if the conversion is cancelled\n\tif (cancelconversion)\n\t{\n\t\tTree_Free(tree);\n\t\tAAS_FreeTmpAAS();\n\t\treturn;\n\t} //end if\n\t//store the created AAS stuff in the AAS file format and write the file\n\tAAS_StoreFile(aasfile);\n\t//free the temporary AAS memory\n\tAAS_FreeTmpAAS();\n\t//display creation time\n\tLog_Print(\"\\nAAS created in %5.0f seconds\\n\", I_FloatTime() - start_time);\n} //end of the function AAS_Create\n"
  },
  {
    "path": "code/bspc/aas_create.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#define AREA_PORTAL\t\t\t1\n\n//temporary AAS face\ntypedef struct tmp_face_s\n{\n\tint num;\t\t\t\t\t\t//face number\n\tint planenum;\t\t\t\t\t//number of the plane the face is in\n\twinding_t *winding;\t\t\t\t//winding of the face\n\tstruct tmp_area_s *frontarea;\t//area at the front of the face\n\tstruct tmp_area_s *backarea;\t//area at the back of the face\n\tint faceflags;\t\t\t\t\t//flags of this face\n\tint aasfacenum;\t\t\t\t\t//the number of the aas face used for this face\n\t//double link list pointers for front and back area\n\tstruct tmp_face_s *prev[2], *next[2];\n\t//links in the list with faces\n\tstruct tmp_face_s *l_prev, *l_next;\n} tmp_face_t;\n\n//temporary AAS area settings\ntypedef struct tmp_areasettings_s\n{\n\t//could also add all kind of statistic fields\n\tint contents;\t\t\t\t\t//contents of the area\n\tint modelnum;\t\t\t\t\t//bsp model inside this area\n\tint areaflags;\t\t\t\t\t//area flags\n\tint presencetype;\t\t\t\t//how a bot can be present in this area\n\tint numreachableareas;\t\t\t//number of reachable areas from this one\n\tint firstreachablearea;\t\t\t//first reachable area in the reachable area index\n} tmp_areasettings_t;\n\n//temporary AAS area\ntypedef struct tmp_area_s\n{\n\tint areanum;\t\t\t\t\t\t//number of the area\n\tstruct tmp_face_s *tmpfaces;\t\t//the faces of the area\n\tint presencetype;\t\t\t\t\t//presence type of the area\n\tint contents;\t\t\t\t\t\t//area contents\n\tint modelnum;\t\t\t\t\t\t//bsp model inside this area\n\tint invalid;\t\t\t\t\t\t//true if the area is invalid\n\ttmp_areasettings_t *settings;\t\t//area settings\n\tstruct tmp_area_s *mergedarea;\t\t//points to the new area after merging\n\t\t\t\t\t\t\t\t\t\t//when mergedarea != 0 the area has only the\n\t\t\t\t\t\t\t\t\t\t//seperating face of the merged areas\n\tint aasareanum;\t\t\t\t\t\t//number of the aas area created for this tmp area\n\t//links in the list with areas\n\tstruct tmp_area_s *l_prev, *l_next;\n} tmp_area_t;\n\n//temporary AAS node\ntypedef struct tmp_node_s\n{\n\tint planenum;\t\t\t\t\t//node plane number\n\tstruct tmp_area_s *tmparea;\t\t//points to an area if this node is an area\n\tstruct tmp_node_s *children[2];\t//child nodes of this node\n} tmp_node_t;\n\n#define NODEBUF_SIZE\t\t\t128\n//node buffer\ntypedef struct tmp_nodebuf_s\n{\n\tint numnodes;\n\tstruct tmp_nodebuf_s *next;\n\ttmp_node_t nodes[NODEBUF_SIZE];\n} tmp_nodebuf_t;\n\n//the whole temorary AAS\ntypedef struct tmp_aas_s\n{\n\t//faces\n\tint numfaces;\n\tint facenum;\n\ttmp_face_t *faces;\n\t//areas\n\tint numareas;\n\tint areanum;\n\ttmp_area_t *areas;\n\t//area settings\n\tint numareasettings;\n\ttmp_areasettings_t *areasettings;\n\t//nodes\n\tint numnodes;\n\ttmp_node_t *nodes;\n\t//node buffer\n\ttmp_nodebuf_t *nodebuffer;\n} tmp_aas_t;\n\nextern tmp_aas_t tmpaasworld;\n\n//creates a .AAS file with the given name from an already loaded map\nvoid AAS_Create(char *aasfile);\n//adds a face side to an area\nvoid AAS_AddFaceSideToArea(tmp_face_t *tmpface, int side, tmp_area_t *tmparea);\n//remvoes a face from an area\nvoid AAS_RemoveFaceFromArea(tmp_face_t *tmpface, tmp_area_t *tmparea);\n//allocate a tmp face\ntmp_face_t *AAS_AllocTmpFace(void);\n//free the tmp face\nvoid AAS_FreeTmpFace(tmp_face_t *tmpface);\n//allocate a tmp area\ntmp_area_t *AAS_AllocTmpArea(void);\n//free a tmp area\nvoid AAS_FreeTmpArea(tmp_area_t *tmparea);\n//allocate a tmp node\ntmp_node_t *AAS_AllocTmpNode(void);\n//free a tmp node\nvoid AAS_FreeTmpNode(tmp_node_t *node);\n//checks if an area is ok\nvoid AAS_CheckArea(tmp_area_t *tmparea);\n//flips the area faces where needed\nvoid AAS_FlipAreaFaces(tmp_area_t *tmparea);\n//returns true if the face is a gap seen from the given side\nint AAS_GapFace(tmp_face_t *tmpface, int side);\n//returns true if the face is a ground face\nint AAS_GroundFace(tmp_face_t *tmpface);\n"
  },
  {
    "path": "code/bspc/aas_edgemelting.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n#include \"../botlib/aasfile.h\"\n#include \"aas_create.h\"\n\n//===========================================================================\n// try to melt the windings of the two faces\n// FIXME: this is buggy\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_MeltFaceWinding(tmp_face_t *face1, tmp_face_t *face2)\n{\n\tint i, n;\n\tint splits = 0;\n\twinding_t *w2, *neww;\n\tplane_t *plane1;\n\n#ifdef DEBUG\n\tif (!face1->winding) Error(\"face1 %d without winding\", face1->num);\n\tif (!face2->winding) Error(\"face2 %d without winding\", face2->num);\n#endif //DEBUG\n\tw2 = face2->winding;\n\tplane1 = &mapplanes[face1->planenum];\n\tfor (i = 0; i < w2->numpoints; i++)\n\t{\n\t\tif (PointOnWinding(face1->winding, plane1->normal, plane1->dist, w2->p[i], &n))\n\t\t{\n\t\t\tneww = AddWindingPoint(face1->winding, w2->p[i], n);\n\t\t\tFreeWinding(face1->winding);\n\t\t\tface1->winding = neww;\n\n\t\t\tsplits++;\n\t\t} //end if\n\t} //end for\n\treturn splits;\n} //end of the function AAS_MeltFaceWinding\n//===========================================================================\n// melt the windings of the area faces\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_MeltFaceWindingsOfArea(tmp_area_t *tmparea)\n{\n\tint side1, side2, num_windingsplits = 0;\n\ttmp_face_t *face1, *face2;\n\n\tfor (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1])\n\t{\n\t\tside1 = face1->frontarea != tmparea;\n\t\tfor (face2 = tmparea->tmpfaces; face2; face2 = face2->next[side2])\n\t\t{\n\t\t\tside2 = face2->frontarea != tmparea;\n\t\t\tif (face1 == face2) continue;\n\t\t\tnum_windingsplits += AAS_MeltFaceWinding(face1, face2);\n\t\t} //end for\n\t} //end for\n\treturn num_windingsplits;\n} //end of the function AAS_MeltFaceWindingsOfArea\n//===========================================================================\n// melt the windings of the faces of all areas\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_MeltAreaFaceWindings(void)\n{\n\ttmp_area_t *tmparea;\n\tint num_windingsplits = 0;\n\n\tLog_Write(\"AAS_MeltAreaFaceWindings\\r\\n\");\n\tqprintf(\"%6d edges melted\", num_windingsplits);\n\t//NOTE: first convex area (zero) is a dummy\n\tfor (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)\n\t{\n\t\tnum_windingsplits += AAS_MeltFaceWindingsOfArea(tmparea);\n\t\tqprintf(\"\\r%6d\", num_windingsplits);\n\t} //end for\n\tqprintf(\"\\n\");\n\tLog_Write(\"%6d edges melted\\r\\n\", num_windingsplits);\n} //end of the function AAS_MeltAreaFaceWindings\n\n"
  },
  {
    "path": "code/bspc/aas_edgemelting.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\nvoid AAS_MeltAreaFaceWindings(void);\n\n"
  },
  {
    "path": "code/bspc/aas_facemerging.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n#include \"../botlib/aasfile.h\"\n#include \"aas_create.h\"\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_TryMergeFaces(tmp_face_t *face1, tmp_face_t *face2)\n{\n\twinding_t *neww;\n\n#ifdef DEBUG\n\tif (!face1->winding) Error(\"face1 %d without winding\", face1->num);\n\tif (!face2->winding) Error(\"face2 %d without winding\", face2->num);\n#endif //DEBUG\n\t//\n\tif (face1->faceflags != face2->faceflags) return false;\n\t//NOTE: if the front or back area is zero this doesn't mean there's\n\t//a real area. It means there's solid at that side of the face\n\t//if both faces have the same front area\n\tif (face1->frontarea == face2->frontarea)\n\t{\n\t\t//if both faces have the same back area\n\t\tif (face1->backarea == face2->backarea)\n\t\t{\n\t\t\t//if the faces are in the same plane\n\t\t\tif (face1->planenum == face2->planenum)\n\t\t\t{\n\t\t\t\t//if they have both a front and a back area (no solid on either side)\n\t\t\t\tif (face1->frontarea && face1->backarea)\n\t\t\t\t{\n\t\t\t\t\tneww = MergeWindings(face1->winding, face2->winding,\n\t\t\t\t\t\t\t\tmapplanes[face1->planenum].normal);\n\t\t\t\t} //end if\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t//this function is to be found in l_poly.c\n\t\t\t\t\tneww = TryMergeWinding(face1->winding, face2->winding,\n\t\t\t\t\t\t\t\t\tmapplanes[face1->planenum].normal);\n\t\t\t\t} //end else\n\t\t\t\tif (neww)\n\t\t\t\t{\n\t\t\t\t\tFreeWinding(face1->winding);\n\t\t\t\t\tface1->winding = neww;\n\t\t\t\t\tif (face2->frontarea) AAS_RemoveFaceFromArea(face2, face2->frontarea);\n\t\t\t\t\tif (face2->backarea) AAS_RemoveFaceFromArea(face2, face2->backarea);\n\t\t\t\t\tAAS_FreeTmpFace(face2);\n\t\t\t\t\treturn true;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t\telse if ((face1->planenum & ~1) == (face2->planenum & ~1))\n\t\t\t{\n\t\t\t\tLog_Write(\"face %d and %d, same front and back area but flipped planes\\r\\n\",\n\t\t\t\t\t\t\tface1->num, face2->num);\n\t\t\t} //end if\n\t\t} //end if\n\t} //end if\n\treturn false;\n} //end of the function AAS_TryMergeFaces\n/*\nint AAS_TryMergeFaces(tmp_face_t *face1, tmp_face_t *face2)\n{\n\twinding_t *neww;\n\n#ifdef DEBUG\n\tif (!face1->winding) Error(\"face1 %d without winding\", face1->num);\n\tif (!face2->winding) Error(\"face2 %d without winding\", face2->num);\n#endif //DEBUG\n\t//if the faces are in the same plane\n\tif ((face1->planenum & ~1) != (face2->planenum & ~1)) return false;\n//\tif (face1->planenum != face2->planenum) return false;\n\t//NOTE: if the front or back area is zero this doesn't mean there's\n\t//a real area. It means there's solid at that side of the face\n\t//if both faces have the same front area\n\tif (face1->frontarea != face2->frontarea ||\n\t\tface1->backarea != face2->backarea)\n\t{\n\t\tif (!face1->frontarea || !face1->backarea ||\n\t\t\t\t!face2->frontarea || !face2->backarea) return false;\n\t\telse if (face1->frontarea != face2->backarea ||\n\t\t\t\t\tface1->backarea != face2->frontarea) return false;\n//\t\treturn false;\n\t} //end if\n\t//this function is to be found in l_poly.c\n\tneww = TryMergeWinding(face1->winding, face2->winding,\n\t\t\t\t\tmapplanes[face1->planenum].normal);\n\tif (!neww) return false;\n\t//\n\tFreeWinding(face1->winding);\n\tface1->winding = neww;\n\t//remove face2\n\tif (face2->frontarea)\n\t\tAAS_RemoveFaceFromArea(face2, &tmpaasworld.areas[face2->frontarea]);\n\tif (face2->backarea)\n\t\tAAS_RemoveFaceFromArea(face2, &tmpaasworld.areas[face2->backarea]);\n\treturn true;\n} //end of the function AAS_TryMergeFaces*/\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_MergeAreaFaces(void)\n{\n\tint num_facemerges = 0;\n\tint side1, side2, restart;\n\ttmp_area_t *tmparea, *lasttmparea;\n\ttmp_face_t *face1, *face2;\n\n\tLog_Write(\"AAS_MergeAreaFaces\\r\\n\");\n\tqprintf(\"%6d face merges\", num_facemerges);\n\t//NOTE: first convex area is a dummy\n\tlasttmparea = tmpaasworld.areas;\n\tfor (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)\n\t{\n\t\trestart = false;\n\t\t//\n\t\tif (tmparea->invalid) continue;\n\t\t//\n\t\tfor (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1])\n\t\t{\n\t\t\tside1 = face1->frontarea != tmparea;\n\t\t\tfor (face2 = face1->next[side1]; face2; face2 = face2->next[side2])\n\t\t\t{\n\t\t\t\tside2 = face2->frontarea != tmparea;\n\t\t\t\t//if succesfully merged\n\t\t\t\tif (AAS_TryMergeFaces(face1, face2))\n\t\t\t\t{\n\t\t\t\t\t//start over again after merging two faces\n\t\t\t\t\trestart = true;\n\t\t\t\t\tnum_facemerges++;\n\t\t\t\t\tqprintf(\"\\r%6d\", num_facemerges);\n\t\t\t\t\tAAS_CheckArea(tmparea);\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t} //end for\n\t\t\tif (restart)\n\t\t\t{\n\t\t\t\ttmparea = lasttmparea;\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t} //end for\n\t\tlasttmparea = tmparea;\n\t} //end for\n\tqprintf(\"\\n\");\n\tLog_Write(\"%6d face merges\\r\\n\", num_facemerges);\n} //end of the function AAS_MergeAreaFaces\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_MergePlaneFaces(tmp_area_t *tmparea, int planenum)\n{\n\ttmp_face_t *face1, *face2, *nextface2;\n\twinding_t *neww;\n\tint side1, side2;\n\n\tfor (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1])\n\t{\n\t\tside1 = face1->frontarea != tmparea;\n\t\tif (face1->planenum != planenum) continue;\n\t\t//\n\t\tfor (face2 = face1->next[side1]; face2; face2 = nextface2)\n\t\t{\n\t\t\tside2 = face2->frontarea != tmparea;\n\t\t\tnextface2 = face2->next[side2];\n\t\t\t//\n\t\t\tif ((face2->planenum & ~1) != (planenum & ~1)) continue;\n\t\t\t//\n\t\t\tneww = MergeWindings(face1->winding, face2->winding,\n\t\t\t\t\t\t\t\tmapplanes[face1->planenum].normal);\n\t\t\tFreeWinding(face1->winding);\n\t\t\tface1->winding = neww;\n\t\t\tif (face2->frontarea) AAS_RemoveFaceFromArea(face2, face2->frontarea);\n\t\t\tif (face2->backarea) AAS_RemoveFaceFromArea(face2, face2->backarea);\n\t\t\tAAS_FreeTmpFace(face2);\n\t\t\t//\n\t\t\tnextface2 = face1->next[side1];\n\t\t} //end for\n\t} //end for\n} //end of the function AAS_MergePlaneFaces\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_CanMergePlaneFaces(tmp_area_t *tmparea, int planenum)\n{\n\ttmp_area_t *frontarea, *backarea;\n\ttmp_face_t *face1;\n\tint side1, merge, faceflags;\n\n\tfrontarea = backarea = NULL;\n\tmerge = false;\n\tfor (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1])\n\t{\n\t\tside1 = face1->frontarea != tmparea;\n\t\tif ((face1->planenum & ~1) != (planenum & ~1)) continue;\n\t\tif (!frontarea && !backarea)\n\t\t{\n\t\t\tfrontarea = face1->frontarea;\n\t\t\tbackarea = face1->backarea;\n\t\t\tfaceflags = face1->faceflags;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tif (frontarea != face1->frontarea) return false;\n\t\t\tif (backarea != face1->backarea) return false;\n\t\t\tif (faceflags != face1->faceflags) return false;\n\t\t\tmerge = true;\n\t\t} //end else\n\t} //end for\n\treturn merge;\n} //end of the function AAS_CanMergePlaneFaces\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_MergeAreaPlaneFaces(void)\n{\n\tint num_facemerges = 0;\n\tint side1;\n\ttmp_area_t *tmparea, *nexttmparea;\n\ttmp_face_t *face1;\n\n\tLog_Write(\"AAS_MergePlaneFaces\\r\\n\");\n\tqprintf(\"%6d plane face merges\", num_facemerges);\n\t//NOTE: first convex area is a dummy\n\tfor (tmparea = tmpaasworld.areas; tmparea; tmparea = nexttmparea)\n\t{\n\t\tnexttmparea = tmparea->l_next;\n\t\t//\n\t\tif (tmparea->invalid) continue;\n\t\t//\n\t\tfor (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1])\n\t\t{\n\t\t\tside1 = face1->frontarea != tmparea;\n\t\t\t//\n\t\t\tif (AAS_CanMergePlaneFaces(tmparea, face1->planenum))\n\t\t\t{\n\t\t\t\tAAS_MergePlaneFaces(tmparea, face1->planenum);\n\t\t\t\tnexttmparea = tmparea;\n\t\t\t\tnum_facemerges++;\n\t\t\t\tqprintf(\"\\r%6d\", num_facemerges);\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\tqprintf(\"\\n\");\n\tLog_Write(\"%6d plane face merges\\r\\n\", num_facemerges);\n} //end of the function AAS_MergeAreaPlaneFaces\n"
  },
  {
    "path": "code/bspc/aas_facemerging.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\nvoid AAS_MergeAreaFaces(void);\nvoid AAS_MergeAreaPlaneFaces(void);\n"
  },
  {
    "path": "code/bspc/aas_file.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n#include \"../botlib/aasfile.h\"\n#include \"aas_file.h\"\n#include \"aas_store.h\"\n#include \"aas_create.h\"\n\n#define AAS_Error\t\t\tError\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_SwapAASData(void)\n{\n\tint i, j;\n\t//bounding boxes\n\tfor (i = 0; i < aasworld.numbboxes; i++)\n\t{\n\t\taasworld.bboxes[i].presencetype = LittleLong(aasworld.bboxes[i].presencetype);\n\t\taasworld.bboxes[i].flags = LittleLong(aasworld.bboxes[i].flags);\n\t\tfor (j = 0; j < 3; j++)\n\t\t{\n\t\t\taasworld.bboxes[i].mins[j] = LittleLong(aasworld.bboxes[i].mins[j]);\n\t\t\taasworld.bboxes[i].maxs[j] = LittleLong(aasworld.bboxes[i].maxs[j]);\n\t\t} //end for\n\t} //end for\n\t//vertexes\n\tfor (i = 0; i < aasworld.numvertexes; i++)\n\t{\n\t\tfor (j = 0; j < 3; j++)\n\t\t\taasworld.vertexes[i][j] = LittleFloat(aasworld.vertexes[i][j]);\n\t} //end for\n\t//planes\n\tfor (i = 0; i < aasworld.numplanes; i++)\n\t{\n\t\tfor (j = 0; j < 3; j++)\n\t\t\taasworld.planes[i].normal[j] = LittleFloat(aasworld.planes[i].normal[j]);\n\t\taasworld.planes[i].dist = LittleFloat(aasworld.planes[i].dist);\n\t\taasworld.planes[i].type = LittleLong(aasworld.planes[i].type);\n\t} //end for\n\t//edges\n\tfor (i = 0; i < aasworld.numedges; i++)\n\t{\n\t\taasworld.edges[i].v[0] = LittleLong(aasworld.edges[i].v[0]);\n\t\taasworld.edges[i].v[1] = LittleLong(aasworld.edges[i].v[1]);\n\t} //end for\n\t//edgeindex\n\tfor (i = 0; i < aasworld.edgeindexsize; i++)\n\t{\n\t\taasworld.edgeindex[i] = LittleLong(aasworld.edgeindex[i]);\n\t} //end for\n\t//faces\n\tfor (i = 0; i < aasworld.numfaces; i++)\n\t{\n\t\taasworld.faces[i].planenum = LittleLong(aasworld.faces[i].planenum);\n\t\taasworld.faces[i].faceflags = LittleLong(aasworld.faces[i].faceflags);\n\t\taasworld.faces[i].numedges = LittleLong(aasworld.faces[i].numedges);\n\t\taasworld.faces[i].firstedge = LittleLong(aasworld.faces[i].firstedge);\n\t\taasworld.faces[i].frontarea = LittleLong(aasworld.faces[i].frontarea);\n\t\taasworld.faces[i].backarea = LittleLong(aasworld.faces[i].backarea);\n\t} //end for\n\t//face index\n\tfor (i = 0; i < aasworld.faceindexsize; i++)\n\t{\n\t\taasworld.faceindex[i] = LittleLong(aasworld.faceindex[i]);\n\t} //end for\n\t//convex areas\n\tfor (i = 0; i < aasworld.numareas; i++)\n\t{\n\t\taasworld.areas[i].areanum = LittleLong(aasworld.areas[i].areanum);\n\t\taasworld.areas[i].numfaces = LittleLong(aasworld.areas[i].numfaces);\n\t\taasworld.areas[i].firstface = LittleLong(aasworld.areas[i].firstface);\n\t\tfor (j = 0; j < 3; j++)\n\t\t{\n\t\t\taasworld.areas[i].mins[j] = LittleFloat(aasworld.areas[i].mins[j]);\n\t\t\taasworld.areas[i].maxs[j] = LittleFloat(aasworld.areas[i].maxs[j]);\n\t\t\taasworld.areas[i].center[j] = LittleFloat(aasworld.areas[i].center[j]);\n\t\t} //end for\n\t} //end for\n\t//area settings\n\tfor (i = 0; i < aasworld.numareasettings; i++)\n\t{\n\t\taasworld.areasettings[i].contents = LittleLong(aasworld.areasettings[i].contents);\n\t\taasworld.areasettings[i].areaflags = LittleLong(aasworld.areasettings[i].areaflags);\n\t\taasworld.areasettings[i].presencetype = LittleLong(aasworld.areasettings[i].presencetype);\n\t\taasworld.areasettings[i].cluster = LittleLong(aasworld.areasettings[i].cluster);\n\t\taasworld.areasettings[i].clusterareanum = LittleLong(aasworld.areasettings[i].clusterareanum);\n\t\taasworld.areasettings[i].numreachableareas = LittleLong(aasworld.areasettings[i].numreachableareas);\n\t\taasworld.areasettings[i].firstreachablearea = LittleLong(aasworld.areasettings[i].firstreachablearea);\n\t} //end for\n\t//area reachability\n\tfor (i = 0; i < aasworld.reachabilitysize; i++)\n\t{\n\t\taasworld.reachability[i].areanum = LittleLong(aasworld.reachability[i].areanum);\n\t\taasworld.reachability[i].facenum = LittleLong(aasworld.reachability[i].facenum);\n\t\taasworld.reachability[i].edgenum = LittleLong(aasworld.reachability[i].edgenum);\n\t\tfor (j = 0; j < 3; j++)\n\t\t{\n\t\t\taasworld.reachability[i].start[j] = LittleFloat(aasworld.reachability[i].start[j]);\n\t\t\taasworld.reachability[i].end[j] = LittleFloat(aasworld.reachability[i].end[j]);\n\t\t} //end for\n\t\taasworld.reachability[i].traveltype = LittleLong(aasworld.reachability[i].traveltype);\n\t\taasworld.reachability[i].traveltime = LittleShort(aasworld.reachability[i].traveltime);\n\t} //end for\n\t//nodes\n\tfor (i = 0; i < aasworld.numnodes; i++)\n\t{\n\t\taasworld.nodes[i].planenum = LittleLong(aasworld.nodes[i].planenum);\n\t\taasworld.nodes[i].children[0] = LittleLong(aasworld.nodes[i].children[0]);\n\t\taasworld.nodes[i].children[1] = LittleLong(aasworld.nodes[i].children[1]);\n\t} //end for\n\t//cluster portals\n\tfor (i = 0; i < aasworld.numportals; i++)\n\t{\n\t\taasworld.portals[i].areanum = LittleLong(aasworld.portals[i].areanum);\n\t\taasworld.portals[i].frontcluster = LittleLong(aasworld.portals[i].frontcluster);\n\t\taasworld.portals[i].backcluster = LittleLong(aasworld.portals[i].backcluster);\n\t\taasworld.portals[i].clusterareanum[0] = LittleLong(aasworld.portals[i].clusterareanum[0]);\n\t\taasworld.portals[i].clusterareanum[1] = LittleLong(aasworld.portals[i].clusterareanum[1]);\n\t} //end for\n\t//cluster portal index\n\tfor (i = 0; i < aasworld.portalindexsize; i++)\n\t{\n\t\taasworld.portalindex[i] = LittleLong(aasworld.portalindex[i]);\n\t} //end for\n\t//cluster\n\tfor (i = 0; i < aasworld.numclusters; i++)\n\t{\n\t\taasworld.clusters[i].numareas = LittleLong(aasworld.clusters[i].numareas);\n\t\taasworld.clusters[i].numportals = LittleLong(aasworld.clusters[i].numportals);\n\t\taasworld.clusters[i].firstportal = LittleLong(aasworld.clusters[i].firstportal);\n\t} //end for\n} //end of the function AAS_SwapAASData\n//===========================================================================\n// dump the current loaded aas file\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_DumpAASData(void)\n{\n\t/*\n\tif (aasworld.vertexes) FreeMemory(aasworld.vertexes);\n\taasworld.vertexes = NULL;\n\tif (aasworld.planes) FreeMemory(aasworld.planes);\n\taasworld.planes = NULL;\n\tif (aasworld.edges) FreeMemory(aasworld.edges);\n\taasworld.edges = NULL;\n\tif (aasworld.edgeindex) FreeMemory(aasworld.edgeindex);\n\taasworld.edgeindex = NULL;\n\tif (aasworld.faces) FreeMemory(aasworld.faces);\n\taasworld.faces = NULL;\n\tif (aasworld.faceindex) FreeMemory(aasworld.faceindex);\n\taasworld.faceindex = NULL;\n\tif (aasworld.areas) FreeMemory(aasworld.areas);\n\taasworld.areas = NULL;\n\tif (aasworld.areasettings) FreeMemory(aasworld.areasettings);\n\taasworld.areasettings = NULL;\n\tif (aasworld.reachability) FreeMemory(aasworld.reachability);\n\taasworld.reachability = NULL;\n\t*/\n\taasworld.loaded = false;\n} //end of the function AAS_DumpAASData\n//===========================================================================\n// allocate memory and read a lump of a AAS file\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nchar *AAS_LoadAASLump(FILE *fp, int offset, int length, void *buf)\n{\n\tif (!length)\n\t{\n\t\tprintf(\"lump size 0\\n\");\n\t\treturn buf;\n\t} //end if\n\t//seek to the data\n\tif (fseek(fp, offset, SEEK_SET))\n\t{\n\t\tAAS_Error(\"can't seek to lump\\n\");\n\t\tAAS_DumpAASData();\n\t\tfclose(fp);\n\t\treturn 0;\n\t} //end if\n\t//allocate memory\n\tif (!buf) buf = (void *) GetClearedMemory(length);\n\t//read the data\n\tif (fread((char *) buf, 1, length, fp) != length)\n\t{\n\t\tAAS_Error(\"can't read lump\\n\");\n\t\tFreeMemory(buf);\n\t\tAAS_DumpAASData();\n\t\tfclose(fp);\n\t\treturn NULL;\n\t} //end if\n\treturn buf;\n} //end of the function AAS_LoadAASLump\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_DData(unsigned char *data, int size)\n{\n\tint i;\n\n\tfor (i = 0; i < size; i++)\n\t{\n\t\tdata[i] ^= (unsigned char) i * 119;\n\t} //end for\n} //end of the function AAS_DData\n//===========================================================================\n// load an aas file\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_LoadAASFile(char *filename, int fpoffset, int fplength)\n{\n\tFILE *fp;\n\taas_header_t header;\n\tint offset, length;\n\n\t//dump current loaded aas file\n\tAAS_DumpAASData();\n\t//open the file\n\tfp = fopen(filename, \"rb\");\n\tif (!fp)\n\t{\n\t\tAAS_Error(\"can't open %s\\n\", filename);\n\t\treturn false;\n\t} //end if\n\t//seek to the correct position (in the pak file)\n\tif (fseek(fp, fpoffset, SEEK_SET))\n\t{\n\t\tAAS_Error(\"can't seek to file %s\\n\");\n\t\tfclose(fp);\n\t\treturn false;\n\t} //end if\n\t//read the header\n\tif (fread(&header, sizeof(aas_header_t), 1, fp) != 1)\n\t{\n\t\tAAS_Error(\"can't read header of file %s\\n\", filename);\n\t\tfclose(fp);\n\t\treturn false;\n\t} //end if\n\t//check header identification\n\theader.ident = LittleLong(header.ident);\n\tif (header.ident != AASID)\n\t{\n\t\tAAS_Error(\"%s is not an AAS file\\n\", filename);\n\t\tfclose(fp);\n\t\treturn false;\n\t} //end if\n\t//check the version\n\theader.version = LittleLong(header.version);\n\tif (header.version != AASVERSION_OLD && header.version != AASVERSION)\n\t{\n\t\tAAS_Error(\"%s is version %i, not %i\\n\", filename, header.version, AASVERSION);\n\t\tfclose(fp);\n\t\treturn false;\n\t} //end if\n\t//\n\tif (header.version == AASVERSION)\n\t{\n\t\tAAS_DData((unsigned char *) &header + 8, sizeof(aas_header_t) - 8);\n\t} //end if\n\taasworld.bspchecksum = LittleLong(header.bspchecksum);\n\t//load the lumps:\n\t//bounding boxes\n\toffset = fpoffset + LittleLong(header.lumps[AASLUMP_BBOXES].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_BBOXES].filelen);\n\taasworld.bboxes = (aas_bbox_t *) AAS_LoadAASLump(fp, offset, length, aasworld.bboxes);\n\tif (!aasworld.bboxes) return false;\n\taasworld.numbboxes = length / sizeof(aas_bbox_t);\n\t//vertexes\n\toffset = fpoffset + LittleLong(header.lumps[AASLUMP_VERTEXES].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_VERTEXES].filelen);\n\taasworld.vertexes = (aas_vertex_t *) AAS_LoadAASLump(fp, offset, length, aasworld.vertexes);\n\tif (!aasworld.vertexes) return false;\n\taasworld.numvertexes = length / sizeof(aas_vertex_t);\n\t//planes\n\toffset = fpoffset + LittleLong(header.lumps[AASLUMP_PLANES].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_PLANES].filelen);\n\taasworld.planes = (aas_plane_t *) AAS_LoadAASLump(fp, offset, length, aasworld.planes);\n\tif (!aasworld.planes) return false;\n\taasworld.numplanes = length / sizeof(aas_plane_t);\n\t//edges\n\toffset = fpoffset + LittleLong(header.lumps[AASLUMP_EDGES].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_EDGES].filelen);\n\taasworld.edges = (aas_edge_t *) AAS_LoadAASLump(fp, offset, length, aasworld.edges);\n\tif (!aasworld.edges) return false;\n\taasworld.numedges = length / sizeof(aas_edge_t);\n\t//edgeindex\n\toffset = fpoffset + LittleLong(header.lumps[AASLUMP_EDGEINDEX].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_EDGEINDEX].filelen);\n\taasworld.edgeindex = (aas_edgeindex_t *) AAS_LoadAASLump(fp, offset, length, aasworld.edgeindex);\n\tif (!aasworld.edgeindex) return false;\n\taasworld.edgeindexsize = length / sizeof(aas_edgeindex_t);\n\t//faces\n\toffset = fpoffset + LittleLong(header.lumps[AASLUMP_FACES].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_FACES].filelen);\n\taasworld.faces = (aas_face_t *) AAS_LoadAASLump(fp, offset, length, aasworld.faces);\n\tif (!aasworld.faces) return false;\n\taasworld.numfaces = length / sizeof(aas_face_t);\n\t//faceindex\n\toffset = fpoffset + LittleLong(header.lumps[AASLUMP_FACEINDEX].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_FACEINDEX].filelen);\n\taasworld.faceindex = (aas_faceindex_t *) AAS_LoadAASLump(fp, offset, length, aasworld.faceindex);\n\tif (!aasworld.faceindex) return false;\n\taasworld.faceindexsize = length / sizeof(int);\n\t//convex areas\n\toffset = fpoffset + LittleLong(header.lumps[AASLUMP_AREAS].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_AREAS].filelen);\n\taasworld.areas = (aas_area_t *) AAS_LoadAASLump(fp, offset, length, aasworld.areas);\n\tif (!aasworld.areas) return false;\n\taasworld.numareas = length / sizeof(aas_area_t);\n\t//area settings\n\toffset = fpoffset + LittleLong(header.lumps[AASLUMP_AREASETTINGS].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_AREASETTINGS].filelen);\n\taasworld.areasettings = (aas_areasettings_t *) AAS_LoadAASLump(fp, offset, length, aasworld.areasettings);\n\tif (!aasworld.areasettings) return false;\n\taasworld.numareasettings = length / sizeof(aas_areasettings_t);\n\t//reachability list\n\toffset = fpoffset + LittleLong(header.lumps[AASLUMP_REACHABILITY].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_REACHABILITY].filelen);\n\taasworld.reachability = (aas_reachability_t *) AAS_LoadAASLump(fp, offset, length, aasworld.reachability);\n\tif (length && !aasworld.reachability) return false;\n\taasworld.reachabilitysize = length / sizeof(aas_reachability_t);\n\t//nodes\n\toffset = fpoffset + LittleLong(header.lumps[AASLUMP_NODES].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_NODES].filelen);\n\taasworld.nodes = (aas_node_t *) AAS_LoadAASLump(fp, offset, length, aasworld.nodes);\n\tif (!aasworld.nodes) return false;\n\taasworld.numnodes = length / sizeof(aas_node_t);\n\t//cluster portals\n\toffset = fpoffset + LittleLong(header.lumps[AASLUMP_PORTALS].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_PORTALS].filelen);\n\taasworld.portals = (aas_portal_t *) AAS_LoadAASLump(fp, offset, length, aasworld.portals);\n\tif (length && !aasworld.portals) return false;\n\taasworld.numportals = length / sizeof(aas_portal_t);\n\t//cluster portal index\n\toffset = fpoffset + LittleLong(header.lumps[AASLUMP_PORTALINDEX].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_PORTALINDEX].filelen);\n\taasworld.portalindex = (aas_portalindex_t *) AAS_LoadAASLump(fp, offset, length, aasworld.portalindex);\n\tif (length && !aasworld.portalindex) return false;\n\taasworld.portalindexsize = length / sizeof(aas_portalindex_t);\n\t//clusters\n\toffset = fpoffset + LittleLong(header.lumps[AASLUMP_CLUSTERS].fileofs);\n\tlength = LittleLong(header.lumps[AASLUMP_CLUSTERS].filelen);\n\taasworld.clusters = (aas_cluster_t *) AAS_LoadAASLump(fp, offset, length, aasworld.clusters);\n\tif (length && !aasworld.clusters) return false;\n\taasworld.numclusters = length / sizeof(aas_cluster_t);\n\t//swap everything\n\tAAS_SwapAASData();\n\t//aas file is loaded\n\taasworld.loaded = true;\n\t//close the file\n\tfclose(fp);\n\treturn true;\n} //end of the function AAS_LoadAASFile\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_WriteAASLump(FILE *fp, aas_header_t *h, int lumpnum, void *data, int length)\n{\n\taas_lump_t *lump;\n\n\tlump = &h->lumps[lumpnum];\n\t\n\tlump->fileofs = LittleLong(ftell(fp));\n\tlump->filelen = LittleLong(length);\n\n\tif (length > 0)\n\t{\n\t\tif (fwrite(data, length, 1, fp) < 1)\n\t\t{\n\t\t\tLog_Print(\"error writing lump %s\\n\", lumpnum);\n\t\t\tfclose(fp);\n\t\t\treturn false;\n\t\t} //end if\n\t} //end if\n\treturn true;\n} //end of the function AAS_WriteAASLump\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ShowNumReachabilities(int tt, char *name)\n{\n\tint i, num;\n\n\tnum = 0;\n\tfor (i = 0; i < aasworld.reachabilitysize; i++)\n\t{\n\t\tif ((aasworld.reachability[i].traveltype & TRAVELTYPE_MASK) == tt)\n\t\t\tnum++;\n\t} //end for\n\tLog_Print(\"%6d %s\\n\", num, name);\n} //end of the function AAS_ShowNumReachabilities\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ShowTotals(void)\n{\n\tLog_Print(\"numvertexes = %d\\r\\n\", aasworld.numvertexes);\n\tLog_Print(\"numplanes = %d\\r\\n\", aasworld.numplanes);\n\tLog_Print(\"numedges = %d\\r\\n\", aasworld.numedges);\n\tLog_Print(\"edgeindexsize = %d\\r\\n\", aasworld.edgeindexsize);\n\tLog_Print(\"numfaces = %d\\r\\n\", aasworld.numfaces);\n\tLog_Print(\"faceindexsize = %d\\r\\n\", aasworld.faceindexsize);\n\tLog_Print(\"numareas = %d\\r\\n\", aasworld.numareas);\n\tLog_Print(\"numareasettings = %d\\r\\n\", aasworld.numareasettings);\n\tLog_Print(\"reachabilitysize = %d\\r\\n\", aasworld.reachabilitysize);\n\tLog_Print(\"numnodes = %d\\r\\n\", aasworld.numnodes);\n\tLog_Print(\"numportals = %d\\r\\n\", aasworld.numportals);\n\tLog_Print(\"portalindexsize = %d\\r\\n\", aasworld.portalindexsize);\n\tLog_Print(\"numclusters = %d\\r\\n\", aasworld.numclusters);\n\tAAS_ShowNumReachabilities(TRAVEL_WALK, \"walk\");\n\tAAS_ShowNumReachabilities(TRAVEL_CROUCH, \"crouch\");\n\tAAS_ShowNumReachabilities(TRAVEL_BARRIERJUMP, \"barrier jump\");\n\tAAS_ShowNumReachabilities(TRAVEL_JUMP, \"jump\");\n\tAAS_ShowNumReachabilities(TRAVEL_LADDER, \"ladder\");\n\tAAS_ShowNumReachabilities(TRAVEL_WALKOFFLEDGE, \"walk off ledge\");\n\tAAS_ShowNumReachabilities(TRAVEL_SWIM, \"swim\");\n\tAAS_ShowNumReachabilities(TRAVEL_WATERJUMP, \"water jump\");\n\tAAS_ShowNumReachabilities(TRAVEL_TELEPORT, \"teleport\");\n\tAAS_ShowNumReachabilities(TRAVEL_ELEVATOR, \"elevator\");\n\tAAS_ShowNumReachabilities(TRAVEL_ROCKETJUMP, \"rocket jump\");\n\tAAS_ShowNumReachabilities(TRAVEL_BFGJUMP, \"bfg jump\");\n\tAAS_ShowNumReachabilities(TRAVEL_GRAPPLEHOOK, \"grapple hook\");\n\tAAS_ShowNumReachabilities(TRAVEL_DOUBLEJUMP, \"double jump\");\n\tAAS_ShowNumReachabilities(TRAVEL_RAMPJUMP, \"ramp jump\");\n\tAAS_ShowNumReachabilities(TRAVEL_STRAFEJUMP, \"strafe jump\");\n\tAAS_ShowNumReachabilities(TRAVEL_JUMPPAD, \"jump pad\");\n\tAAS_ShowNumReachabilities(TRAVEL_FUNCBOB, \"func bob\");\n} //end of the function AAS_ShowTotals\n//===========================================================================\n// aas data is useless after writing to file because it is byte swapped\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_WriteAASFile(char *filename)\n{\n\taas_header_t header;\n\tFILE *fp;\n\n\tLog_Print(\"writing %s\\n\", filename);\n\tAAS_ShowTotals();\n\t//swap the aas data\n\tAAS_SwapAASData();\n\t//initialize the file header\n\tmemset(&header, 0, sizeof(aas_header_t));\n\theader.ident = LittleLong(AASID);\n\theader.version = LittleLong(AASVERSION);\n\theader.bspchecksum = LittleLong(aasworld.bspchecksum);\n\t//open a new file\n\tfp = fopen(filename, \"wb\");\n\tif (!fp)\n\t{\n\t\tLog_Print(\"error opening %s\\n\", filename);\n\t\treturn false;\n\t} //end if\n\t//write the header\n\tif (fwrite(&header, sizeof(aas_header_t), 1, fp) < 1)\n\t{\n\t\tfclose(fp);\n\t\treturn false;\n\t} //end if\n\t//add the data lumps to the file\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_BBOXES, aasworld.bboxes,\n\t\taasworld.numbboxes * sizeof(aas_bbox_t))) return false;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_VERTEXES, aasworld.vertexes,\n\t\taasworld.numvertexes * sizeof(aas_vertex_t))) return false;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_PLANES, aasworld.planes,\n\t\taasworld.numplanes * sizeof(aas_plane_t))) return false;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_EDGES, aasworld.edges,\n\t\taasworld.numedges * sizeof(aas_edge_t))) return false;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_EDGEINDEX, aasworld.edgeindex,\n\t\taasworld.edgeindexsize * sizeof(aas_edgeindex_t))) return false;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_FACES, aasworld.faces,\n\t\taasworld.numfaces * sizeof(aas_face_t))) return false;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_FACEINDEX, aasworld.faceindex,\n\t\taasworld.faceindexsize * sizeof(aas_faceindex_t))) return false;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_AREAS, aasworld.areas,\n\t\taasworld.numareas * sizeof(aas_area_t))) return false;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_AREASETTINGS, aasworld.areasettings,\n\t\taasworld.numareasettings * sizeof(aas_areasettings_t))) return false;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_REACHABILITY, aasworld.reachability,\n\t\taasworld.reachabilitysize * sizeof(aas_reachability_t))) return false;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_NODES, aasworld.nodes,\n\t\taasworld.numnodes * sizeof(aas_node_t))) return false;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_PORTALS, aasworld.portals,\n\t\taasworld.numportals * sizeof(aas_portal_t))) return false;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_PORTALINDEX, aasworld.portalindex,\n\t\taasworld.portalindexsize * sizeof(aas_portalindex_t))) return false;\n\tif (!AAS_WriteAASLump(fp, &header, AASLUMP_CLUSTERS, aasworld.clusters,\n\t\taasworld.numclusters * sizeof(aas_cluster_t))) return false;\n\t//rewrite the header with the added lumps\n\tfseek(fp, 0, SEEK_SET);\n\tAAS_DData((unsigned char *) &header + 8, sizeof(aas_header_t) - 8);\n\tif (fwrite(&header, sizeof(aas_header_t), 1, fp) < 1)\n\t{\n\t\tfclose(fp);\n\t\treturn false;\n\t} //end if\n\t//close the file\n\tfclose(fp);\n\treturn true;\n} //end of the function AAS_WriteAASFile\n\n"
  },
  {
    "path": "code/bspc/aas_file.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\nqboolean AAS_WriteAASFile(char *filename);\nqboolean AAS_LoadAASFile(char *filename, int fpoffset, int fplength);\n\n"
  },
  {
    "path": "code/bspc/aas_gsubdiv.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n#include \"../botlib/aasfile.h\"\n#include \"aas_create.h\"\n#include \"aas_store.h\"\n#include \"aas_cfg.h\"\n\n#define FACECLIP_EPSILON\t\t\t0.2\n#define FACE_EPSILON\t\t\t\t\t1.0\n\nint numgravitationalsubdivisions = 0;\nint numladdersubdivisions = 0;\n\n//NOTE: only do gravitational subdivision BEFORE area merging!!!!!!!\n//\t\t\tbecause the bsp tree isn't refreshes like with ladder subdivision\n\n//===========================================================================\n// NOTE: the original face is invalid after splitting\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_SplitFace(tmp_face_t *face, vec3_t normal, float dist,\n\t\t\t\t\t\t\ttmp_face_t **frontface, tmp_face_t **backface)\n{\n\twinding_t *frontw, *backw;\n\n\t//\n\t*frontface = *backface = NULL;\n\n\tClipWindingEpsilon(face->winding, normal, dist, FACECLIP_EPSILON, &frontw, &backw);\n\n#ifdef DEBUG\n\t//\n\tif (frontw)\n\t{\n\t\tif (WindingIsTiny(frontw))\n\t\t{\n\t\t\tLog_Write(\"AAS_SplitFace: tiny back face\\r\\n\");\n\t\t\tFreeWinding(frontw);\n\t\t\tfrontw = NULL;\n\t\t} //end if\n\t} //end if\n\tif (backw)\n\t{\n\t\tif (WindingIsTiny(backw))\n\t\t{\n\t\t\tLog_Write(\"AAS_SplitFace: tiny back face\\r\\n\");\n\t\t\tFreeWinding(backw);\n\t\t\tbackw = NULL;\n\t\t} //end if\n\t} //end if\n#endif //DEBUG\n\t//if the winding was split\n\tif (frontw)\n\t{\n\t\t//check bounds\n\t\t(*frontface) = AAS_AllocTmpFace();\n\t\t(*frontface)->planenum = face->planenum;\n\t\t(*frontface)->winding = frontw;\n\t\t(*frontface)->faceflags = face->faceflags;\n\t} //end if\n\tif (backw)\n\t{\n\t\t//check bounds\n\t\t(*backface) = AAS_AllocTmpFace();\n\t\t(*backface)->planenum = face->planenum;\n\t\t(*backface)->winding = backw;\n\t\t(*backface)->faceflags = face->faceflags;\n\t} //end if\n} //end of the function AAS_SplitFace\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nwinding_t *AAS_SplitWinding(tmp_area_t *tmparea, int planenum)\n{\n\ttmp_face_t *face;\n\tplane_t *plane;\n\tint side;\n\twinding_t *splitwinding;\n\n\t//\n\tplane = &mapplanes[planenum];\n\t//create a split winding, first base winding for plane\n\tsplitwinding = BaseWindingForPlane(plane->normal, plane->dist);\n\t//chop with all the faces of the area\n\tfor (face = tmparea->tmpfaces; face && splitwinding; face = face->next[side])\n\t{\n\t\t//side of the face the original area was on\n\t\tside = face->frontarea != tmparea;\n\t\tplane = &mapplanes[face->planenum ^ side];\n\t\tChopWindingInPlace(&splitwinding, plane->normal, plane->dist, 0); // PLANESIDE_EPSILON);\n\t} //end for\n\treturn splitwinding;\n} //end of the function AAS_SplitWinding\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_TestSplitPlane(tmp_area_t *tmparea, vec3_t normal, float dist,\n\t\t\t\t\t\t\tint *facesplits, int *groundsplits, int *epsilonfaces)\n{\n\tint j, side, front, back, planenum;\n\tfloat d, d_front, d_back;\n\ttmp_face_t *face;\n\twinding_t *w;\n\n\t*facesplits = *groundsplits = *epsilonfaces = 0;\n\n\tplanenum = FindFloatPlane(normal, dist);\n\n\tw = AAS_SplitWinding(tmparea, planenum);\n\tif (!w) return false;\n\tFreeWinding(w);\n\t//\n\tfor (face = tmparea->tmpfaces; face; face = face->next[side])\n\t{\n\t\t//side of the face the area is on\n\t\tside = face->frontarea != tmparea;\n\n\t\tif ((face->planenum & ~1) == (planenum & ~1))\n\t\t{\n\t\t\tLog_Print(\"AAS_TestSplitPlane: tried face plane as splitter\\n\");\n\t\t\treturn false;\n\t\t} //end if\n\t\tw = face->winding;\n\t\t//reset distance at front and back side of plane\n\t\td_front = d_back = 0;\n\t\t//reset front and back flags\n\t\tfront = back = 0;\n\t\tfor (j = 0; j < w->numpoints; j++)\n\t\t{\n\t\t\td = DotProduct(w->p[j], normal) - dist;\n\t\t\tif (d > d_front) d_front = d;\n\t\t\tif (d < d_back) d_back = d;\n\n\t\t\tif (d > 0.4) // PLANESIDE_EPSILON)\n\t\t\t\tfront = 1;\n\t\t\tif (d < -0.4) // PLANESIDE_EPSILON)\n\t\t\t\tback = 1;\n\t\t} //end for\n\t\t//check for an epsilon face\n\t\tif ( (d_front > FACECLIP_EPSILON && d_front < FACE_EPSILON)\n\t\t\t|| (d_back < -FACECLIP_EPSILON && d_back > -FACE_EPSILON) )\n\t\t{\n\t\t\t(*epsilonfaces)++;\n\t\t} //end if\n\t\t//if the face has points at both sides of the plane\n\t\tif (front && back)\n\t\t{\n\t\t\t(*facesplits)++;\n\t\t\tif (face->faceflags & FACE_GROUND)\n\t\t\t{\n\t\t\t\t(*groundsplits)++;\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n\treturn true;\n} //end of the function AAS_TestSplitPlane\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_SplitArea(tmp_area_t *tmparea, int planenum, tmp_area_t **frontarea, tmp_area_t **backarea)\n{\n\tint side;\n\ttmp_area_t *facefrontarea, *facebackarea, *faceotherarea;\n\ttmp_face_t *face, *frontface, *backface, *splitface, *nextface;\n\twinding_t *splitwinding;\n\tplane_t *splitplane;\n\n/*\n#ifdef AW_DEBUG\n\tint facesplits, groundsplits, epsilonface;\n\tLog_Print(\"\\n----------------------\\n\");\n\tLog_Print(\"splitting area %d\\n\", areanum);\n\tLog_Print(\"with normal = \\'%f %f %f\\', dist = %f\\n\", normal[0], normal[1], normal[2], dist);\n\tAAS_TestSplitPlane(areanum, normal, dist,\n\t\t\t\t\t\t\t\t\t\t&facesplits, &groundsplits, &epsilonface);\n\tLog_Print(\"face splits = %d\\nground splits = %d\\n\", facesplits, groundsplits);\n\tif (epsilonface) Log_Print(\"aaahh epsilon face\\n\");\n#endif //AW_DEBUG*/\n\t//the original area\n\n\tAAS_FlipAreaFaces(tmparea);\n\tAAS_CheckArea(tmparea);\n\t//\n\tsplitplane = &mapplanes[planenum];\n/*\t//create a split winding, first base winding for plane\n\tsplitwinding = BaseWindingForPlane(splitplane->normal, splitplane->dist);\n\t//chop with all the faces of the area\n\tfor (face = tmparea->tmpfaces; face && splitwinding; face = face->next[side])\n\t{\n\t\t//side of the face the original area was on\n\t\tside = face->frontarea != tmparea->areanum;\n\t\tplane = &mapplanes[face->planenum ^ side];\n\t\tChopWindingInPlace(&splitwinding, plane->normal, plane->dist, 0); // PLANESIDE_EPSILON);\n\t} //end for*/\n\tsplitwinding = AAS_SplitWinding(tmparea, planenum);\n\tif (!splitwinding)\n\t{\n/*\n#ifdef DEBUG\n\t\tAAS_TestSplitPlane(areanum, normal, dist,\n\t\t\t\t\t\t\t\t\t\t\t&facesplits, &groundsplits, &epsilonface);\n\t\tLog_Print(\"\\nface splits = %d\\nground splits = %d\\n\", facesplits, groundsplits);\n\t\tif (epsilonface) Log_Print(\"aaahh epsilon face\\n\");\n#endif //DEBUG*/\n\t\tError(\"AAS_SplitArea: no split winding when splitting area %d\\n\", tmparea->areanum);\n\t} //end if\n\t//create a split face\n\tsplitface = AAS_AllocTmpFace();\n\t//get the map plane\n\tsplitface->planenum = planenum;\n\t//store the split winding\n\tsplitface->winding = splitwinding;\n\t//the new front area\n\t(*frontarea) = AAS_AllocTmpArea();\n\t(*frontarea)->presencetype = tmparea->presencetype;\n\t(*frontarea)->contents = tmparea->contents;\n\t(*frontarea)->modelnum = tmparea->modelnum;\n\t(*frontarea)->tmpfaces = NULL;\n\t//the new back area\n\t(*backarea) = AAS_AllocTmpArea();\n\t(*backarea)->presencetype = tmparea->presencetype;\n\t(*backarea)->contents = tmparea->contents;\n\t(*backarea)->modelnum = tmparea->modelnum;\n\t(*backarea)->tmpfaces = NULL;\n\t//add the split face to the new areas\n\tAAS_AddFaceSideToArea(splitface, 0, (*frontarea));\n\tAAS_AddFaceSideToArea(splitface, 1, (*backarea));\n\n\t//split all the faces of the original area\n\tfor (face = tmparea->tmpfaces; face; face = nextface)\n\t{\n\t\t//side of the face the original area was on\n\t\tside = face->frontarea != tmparea;\n\t\t//next face of the original area\n\t\tnextface = face->next[side];\n\t\t//front area of the face\n\t\tfacefrontarea = face->frontarea;\n\t\t//back area of the face\n\t\tfacebackarea = face->backarea;\n\t\t//remove the face from both the front and back areas\n\t\tif (facefrontarea) AAS_RemoveFaceFromArea(face, facefrontarea);\n\t\tif (facebackarea) AAS_RemoveFaceFromArea(face, facebackarea);\n\t\t//split the face\n\t\tAAS_SplitFace(face, splitplane->normal, splitplane->dist, &frontface, &backface);\n\t\t//free the original face\n\t\tAAS_FreeTmpFace(face);\n\t\t//get the number of the area at the other side of the face\n\t\tif (side) faceotherarea = facefrontarea;\n\t\telse faceotherarea = facebackarea;\n\t\t//if there is an area at the other side of the original face\n\t\tif (faceotherarea)\n\t\t{\n\t\t\tif (frontface) AAS_AddFaceSideToArea(frontface, !side, faceotherarea);\n\t\t\tif (backface) AAS_AddFaceSideToArea(backface, !side, faceotherarea);\n\t\t} //end if\n\t\t//add the front and back part left after splitting the original face to the new areas\n\t\tif (frontface) AAS_AddFaceSideToArea(frontface, side, (*frontarea));\n\t\tif (backface) AAS_AddFaceSideToArea(backface, side, (*backarea));\n\t} //end for\n\n\tif (!(*frontarea)->tmpfaces) Log_Print(\"AAS_SplitArea: front area without faces\\n\");\n\tif (!(*backarea)->tmpfaces) Log_Print(\"AAS_SplitArea: back area without faces\\n\");\n\n\ttmparea->invalid = true;\n/*\n#ifdef AW_DEBUG\n\tfor (i = 0, face = frontarea->tmpfaces; face; face = face->next[side])\n\t{\n\t\tside = face->frontarea != frontarea->areanum;\n\t\ti++;\n\t} //end for\n\tLog_Print(\"created front area %d with %d faces\\n\", frontarea->areanum, i);\n\n\tfor (i = 0, face = backarea->tmpfaces; face; face = face->next[side])\n\t{\n\t\tside = face->frontarea != backarea->areanum;\n\t\ti++;\n\t} //end for\n\tLog_Print(\"created back area %d with %d faces\\n\", backarea->areanum, i);\n#endif //AW_DEBUG*/\n\n\tAAS_FlipAreaFaces((*frontarea));\n\tAAS_FlipAreaFaces((*backarea));\n\t//\n\tAAS_CheckArea((*frontarea));\n\tAAS_CheckArea((*backarea));\n} //end of the function AAS_SplitArea\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_FindBestAreaSplitPlane(tmp_area_t *tmparea, vec3_t normal, float *dist)\n{\n\tint side1, side2;\n\tint foundsplitter, facesplits, groundsplits, epsilonfaces, bestepsilonfaces;\n\tfloat bestvalue, value;\n\ttmp_face_t *face1, *face2;\n\tvec3_t tmpnormal, invgravity;\n\tfloat tmpdist;\n\n\t//get inverse of gravity direction\n\tVectorCopy(cfg.phys_gravitydirection, invgravity);\n\tVectorInverse(invgravity);\n\n\tfoundsplitter = false;\n\tbestvalue = -999999;\n\tbestepsilonfaces = 0;\n\t//\n#ifdef AW_DEBUG\n\tLog_Print(\"finding split plane for area %d\\n\", tmparea->areanum);\n#endif //AW_DEBUG\n\tfor (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1])\n\t{\n\t\t//side of the face the area is on\n\t\tside1 = face1->frontarea != tmparea;\n\t\t//\n\t\tif (WindingIsTiny(face1->winding))\n\t\t{\n\t\t\tLog_Write(\"gsubdiv: area %d has a tiny winding\\r\\n\", tmparea->areanum);\n\t\t\tcontinue;\n\t\t} //end if\n\t\t//if the face isn't a gap or ground there's no split edge\n\t\tif (!(face1->faceflags & FACE_GROUND) && !AAS_GapFace(face1, side1)) continue;\n\t\t//\n\t\tfor (face2 = face1->next[side1]; face2; face2 = face2->next[side2])\n\t\t{\n\t\t\t//side of the face the area is on\n\t\t\tside2 = face2->frontarea != tmparea;\n\t\t\t//\n\t\t\tif (WindingIsTiny(face1->winding))\n\t\t\t{\n\t\t\t\tLog_Write(\"gsubdiv: area %d has a tiny winding\\r\\n\", tmparea->areanum);\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\t//if the face isn't a gap or ground there's no split edge\n\t\t\tif (!(face2->faceflags & FACE_GROUND) && !AAS_GapFace(face2, side2)) continue;\n\t\t\t//only split between gaps and ground\n\t\t\tif (!(((face1->faceflags & FACE_GROUND) && AAS_GapFace(face2, side2)) ||\n\t\t\t\t\t((face2->faceflags & FACE_GROUND) && AAS_GapFace(face1, side1)))) continue;\n\t\t\t//find a plane seperating the windings of the faces\n\t\t\tif (!FindPlaneSeperatingWindings(face1->winding, face2->winding, invgravity,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttmpnormal, &tmpdist)) continue;\n#ifdef AW_DEBUG\n\t\t\tLog_Print(\"normal = \\'%f %f %f\\', dist = %f\\n\",\n\t\t\t\t\t\t\ttmpnormal[0], tmpnormal[1], tmpnormal[2], tmpdist);\n#endif //AW_DEBUG\n\t\t\t//get metrics for this vertical plane\n\t\t\tif (!AAS_TestSplitPlane(tmparea, tmpnormal, tmpdist,\n\t\t\t\t\t\t\t\t\t\t&facesplits, &groundsplits, &epsilonfaces))\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t} //end if\n#ifdef AW_DEBUG\n\t\t\tLog_Print(\"face splits = %d\\nground splits = %d\\n\",\n\t\t\t\t\t\t\tfacesplits, groundsplits);\n#endif //AW_DEBUG\n\t\t\tvalue = 100 - facesplits - 2 * groundsplits;\n\t\t\t//avoid epsilon faces\n\t\t\tvalue += epsilonfaces * -1000;\n\t\t\tif (value > bestvalue)\n\t\t\t{\n\t\t\t\tVectorCopy(tmpnormal, normal);\n\t\t\t\t*dist = tmpdist;\n\t\t\t\tbestvalue = value;\n\t\t\t\tbestepsilonfaces = epsilonfaces;\n\t\t\t\tfoundsplitter = true;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\tif (bestepsilonfaces)\n\t{\n\t\tLog_Write(\"found %d epsilon faces trying to split area %d\\r\\n\",\n\t\t\t\t\t\t\t\t\tepsilonfaces, tmparea->areanum);\n\t} //end else\n\treturn foundsplitter;\n} //end of the function AAS_FindBestAreaSplitPlane\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\ntmp_node_t *AAS_SubdivideArea_r(tmp_node_t *tmpnode)\n{\n\tint planenum;\n\ttmp_area_t *frontarea, *backarea;\n\ttmp_node_t *tmpnode1, *tmpnode2;\n\tvec3_t normal;\n\tfloat dist;\n\n\tif (AAS_FindBestAreaSplitPlane(tmpnode->tmparea, normal, &dist))\n\t{\n\t\tqprintf(\"\\r%6d\", ++numgravitationalsubdivisions);\n\t\t//\n\t\tplanenum = FindFloatPlane(normal, dist);\n\t\t//split the area\n\t\tAAS_SplitArea(tmpnode->tmparea, planenum, &frontarea, &backarea);\n\t\t//\n\t\ttmpnode->tmparea = NULL;\n\t\ttmpnode->planenum = FindFloatPlane(normal, dist);\n\t\t//\n\t\ttmpnode1 = AAS_AllocTmpNode();\n\t\ttmpnode1->planenum = 0;\n\t\ttmpnode1->tmparea = frontarea;\n\t\t//\n\t\ttmpnode2 = AAS_AllocTmpNode();\n\t\ttmpnode2->planenum = 0;\n\t\ttmpnode2->tmparea = backarea;\n\t\t//subdivide the areas created by splitting recursively\n\t\ttmpnode->children[0] = AAS_SubdivideArea_r(tmpnode1);\n\t\ttmpnode->children[1] = AAS_SubdivideArea_r(tmpnode2);\n\t} //end if\n\treturn tmpnode;\n} //end of the function AAS_SubdivideArea_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\ntmp_node_t *AAS_GravitationalSubdivision_r(tmp_node_t *tmpnode)\n{\n\t//if this is a solid leaf\n\tif (!tmpnode) return NULL;\n\t//negative so it's an area\n\tif (tmpnode->tmparea) return AAS_SubdivideArea_r(tmpnode);\n\t//do the children recursively\n\ttmpnode->children[0] = AAS_GravitationalSubdivision_r(tmpnode->children[0]);\n\ttmpnode->children[1] = AAS_GravitationalSubdivision_r(tmpnode->children[1]);\n\treturn tmpnode;\n} //end of the function AAS_GravitationalSubdivision_r\n//===========================================================================\n// NOTE: merge faces and melt edges first\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_GravitationalSubdivision(void)\n{\n\tLog_Write(\"AAS_GravitationalSubdivision\\r\\n\");\n\tnumgravitationalsubdivisions = 0;\n\tqprintf(\"%6i gravitational subdivisions\", numgravitationalsubdivisions);\n\t//start with the head node\n\tAAS_GravitationalSubdivision_r(tmpaasworld.nodes);\n\tqprintf(\"\\n\");\n\tLog_Write(\"%6i gravitational subdivisions\\r\\n\", numgravitationalsubdivisions);\n} //end of the function AAS_GravitationalSubdivision\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\ntmp_node_t *AAS_RefreshLadderSubdividedTree_r(tmp_node_t *tmpnode, tmp_area_t *tmparea,\n\t\t\t\t\t\t\t\t\t\t\t\t  tmp_node_t *tmpnode1, tmp_node_t *tmpnode2, int planenum)\n{\n\t//if this is a solid leaf\n\tif (!tmpnode) return NULL;\n\t//negative so it's an area\n\tif (tmpnode->tmparea)\n\t{\n\t\tif (tmpnode->tmparea == tmparea)\n\t\t{\n\t\t\ttmpnode->tmparea = NULL;\n\t\t\ttmpnode->planenum = planenum;\n\t\t\ttmpnode->children[0] = tmpnode1;\n\t\t\ttmpnode->children[1] = tmpnode2;\n\t\t} //end if\n\t\treturn tmpnode;\n\t} //end if\n\t//do the children recursively\n\ttmpnode->children[0] = AAS_RefreshLadderSubdividedTree_r(tmpnode->children[0],\n\t\t\t\t\t\t\t\t\ttmparea, tmpnode1, tmpnode2, planenum);\n\ttmpnode->children[1] = AAS_RefreshLadderSubdividedTree_r(tmpnode->children[1],\n\t\t\t\t\t\t\t\t\ttmparea, tmpnode1, tmpnode2, planenum);\n\treturn tmpnode;\n} //end of the function AAS_RefreshLadderSubdividedTree_r\n//===========================================================================\n// find an area with ladder faces and ground faces that are not connected\n// split the area with a horizontal plane at the lowest vertex of all\n// ladder faces in the area\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\ntmp_node_t *AAS_LadderSubdivideArea_r(tmp_node_t *tmpnode)\n{\n\tint side1, i, planenum;\n\tint foundladderface, foundgroundface;\n\tfloat dist;\n\ttmp_area_t *tmparea, *frontarea, *backarea;\n\ttmp_face_t *face1;\n\ttmp_node_t *tmpnode1, *tmpnode2;\n\tvec3_t lowestpoint, normal = {0, 0, 1};\n\tplane_t *plane;\n\twinding_t *w;\n\n\ttmparea = tmpnode->tmparea;\n\t//skip areas with a liquid\n\tif (tmparea->contents & (AREACONTENTS_WATER\n\t\t\t\t\t\t\t\t\t| AREACONTENTS_LAVA\n\t\t\t\t\t\t\t\t\t| AREACONTENTS_SLIME)) return tmpnode;\n\t//must be possible to stand in the area\n\tif (!(tmparea->presencetype & PRESENCE_NORMAL)) return tmpnode;\n\t//\n\tfoundladderface = false;\n\tfoundgroundface = false;\n\tlowestpoint[2] = 99999;\n\t//\n\tfor (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1])\n\t{\n\t\t//side of the face the area is on\n\t\tside1 = face1->frontarea != tmparea;\n\t\t//if the face is a ladder face\n\t\tif (face1->faceflags & FACE_LADDER)\n\t\t{\n\t\t\tplane = &mapplanes[face1->planenum];\n\t\t\t//the ladder face plane should be pretty much vertical\n\t\t\tif (DotProduct(plane->normal, normal) > -0.1)\n\t\t\t{\n\t\t\t\tfoundladderface = true;\n\t\t\t\t//find lowest point\n\t\t\t\tfor (i = 0; i < face1->winding->numpoints; i++)\n\t\t\t\t{\n\t\t\t\t\tif (face1->winding->p[i][2] < lowestpoint[2])\n\t\t\t\t\t{\n\t\t\t\t\t\tVectorCopy(face1->winding->p[i], lowestpoint);\n\t\t\t\t\t} //end if\n\t\t\t\t} //end for\n\t\t\t} //end if\n\t\t} //end if\n\t\telse if (face1->faceflags & FACE_GROUND)\n\t\t{\n\t\t\tfoundgroundface = true;\n\t\t} //end else if\n\t} //end for\n\t//\n\tif ((!foundladderface) || (!foundgroundface)) return tmpnode;\n\t//\n\tfor (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1])\n\t{\n\t\t//side of the face the area is on\n\t\tside1 = face1->frontarea != tmparea;\n\t\t//if the face isn't a ground face\n\t\tif (!(face1->faceflags & FACE_GROUND)) continue;\n\t\t//the ground plane\n\t\tplane = &mapplanes[face1->planenum];\n\t\t//get the difference between the ground plane and the lowest point\n\t\tdist = DotProduct(plane->normal, lowestpoint) - plane->dist;\n\t\t//if the lowest point is very near one of the ground planes\n\t\tif (dist > -1 && dist < 1)\n\t\t{\n\t\t\treturn tmpnode;\n\t\t} //end if\n\t} //end for\n\t//\n\tdist = DotProduct(normal, lowestpoint);\n\tplanenum = FindFloatPlane(normal, dist);\n\t//\n\tw = AAS_SplitWinding(tmparea, planenum);\n\tif (!w) return tmpnode;\n\tFreeWinding(w);\n\t//split the area with a horizontal plane through the lowest point\n\tqprintf(\"\\r%6d\", ++numladdersubdivisions);\n\t//\n\tAAS_SplitArea(tmparea, planenum, &frontarea, &backarea);\n\t//\n\ttmpnode->tmparea = NULL;\n\ttmpnode->planenum = planenum;\n\t//\n\ttmpnode1 = AAS_AllocTmpNode();\n\ttmpnode1->planenum = 0;\n\ttmpnode1->tmparea = frontarea;\n\t//\n\ttmpnode2 = AAS_AllocTmpNode();\n\ttmpnode2->planenum = 0;\n\ttmpnode2->tmparea = backarea;\n\t//subdivide the areas created by splitting recursively\n\ttmpnode->children[0] = AAS_LadderSubdivideArea_r(tmpnode1);\n\ttmpnode->children[1] = AAS_LadderSubdivideArea_r(tmpnode2);\n\t//refresh the tree\n\tAAS_RefreshLadderSubdividedTree_r(tmpaasworld.nodes, tmparea, tmpnode1, tmpnode2, planenum);\n\t//\n\treturn tmpnode;\n} //end of the function AAS_LadderSubdivideArea_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\ntmp_node_t *AAS_LadderSubdivision_r(tmp_node_t *tmpnode)\n{\n\t//if this is a solid leaf\n\tif (!tmpnode) return 0;\n\t//negative so it's an area\n\tif (tmpnode->tmparea) return AAS_LadderSubdivideArea_r(tmpnode);\n\t//do the children recursively\n\ttmpnode->children[0] = AAS_LadderSubdivision_r(tmpnode->children[0]);\n\ttmpnode->children[1] = AAS_LadderSubdivision_r(tmpnode->children[1]);\n\treturn tmpnode;\n} //end of the function AAS_LadderSubdivision_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_LadderSubdivision(void)\n{\n\tLog_Write(\"AAS_LadderSubdivision\\r\\n\");\n\tnumladdersubdivisions = 0;\n\tqprintf(\"%6i ladder subdivisions\", numladdersubdivisions);\n\t//start with the head node\n\tAAS_LadderSubdivision_r(tmpaasworld.nodes);\n\t//\n\tqprintf(\"\\n\");\n\tLog_Write(\"%6i ladder subdivisions\\r\\n\", numladdersubdivisions);\n} //end of the function AAS_LadderSubdivision\n"
  },
  {
    "path": "code/bspc/aas_gsubdiv.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n//works with the global tmpaasworld\nvoid AAS_GravitationalSubdivision(void);\nvoid AAS_LadderSubdivision(void);\n"
  },
  {
    "path": "code/bspc/aas_map.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n#include \"l_mem.h\"\n#include \"../botlib/aasfile.h\"\t\t//aas_bbox_t\n#include \"aas_store.h\"\t\t\t\t//AAS_MAX_BBOXES\n#include \"aas_cfg.h\"\n#include \"../game/surfaceflags.h\"\n\n#define SPAWNFLAG_NOT_EASY\t\t\t0x00000100\n#define SPAWNFLAG_NOT_MEDIUM\t\t0x00000200\n#define SPAWNFLAG_NOT_HARD\t\t\t0x00000400\n#define SPAWNFLAG_NOT_DEATHMATCH\t0x00000800\n#define SPAWNFLAG_NOT_COOP\t\t\t0x00001000\n\n#define STATE_TOP\t\t\t\t0\n#define STATE_BOTTOM\t\t\t1\n#define STATE_UP\t\t\t\t2\n#define STATE_DOWN\t\t\t3\n\n#define DOOR_START_OPEN\t\t1\n#define DOOR_REVERSE\t\t\t2\n#define DOOR_CRUSHER\t\t\t4\n#define DOOR_NOMONSTER\t\t8\n#define DOOR_TOGGLE\t\t\t32\n#define DOOR_X_AXIS\t\t\t64\n#define DOOR_Y_AXIS\t\t\t128\n\n#define BBOX_NORMAL_EPSILON\t\t\t0.0001\n\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvec_t BoxOriginDistanceFromPlane(vec3_t normal, vec3_t mins, vec3_t maxs, int side)\n{\n\tvec3_t v1, v2;\n\tint i;\n\n\tif (side)\n\t{\n\t\tfor (i = 0; i < 3; i++)\n\t\t{\n\t\t\tif (normal[i] > BBOX_NORMAL_EPSILON) v1[i] = maxs[i];\n\t\t\telse if (normal[i] < -BBOX_NORMAL_EPSILON) v1[i] = mins[i];\n\t\t\telse v1[i] = 0;\n\t\t} //end for\n\t} //end if\n\telse\n\t{\n\t\tfor (i = 0; i < 3; i++)\n\t\t{\n\t\t\tif (normal[i] > BBOX_NORMAL_EPSILON) v1[i] = mins[i];\n\t\t\telse if (normal[i] < -BBOX_NORMAL_EPSILON) v1[i] = maxs[i];\n\t\t\telse v1[i] = 0;\n\t\t} //end for\n\t} //end else\n\tVectorCopy(normal, v2);\n\tVectorInverse(v2);\n\treturn DotProduct(v1, v2);\n} //end of the function BoxOriginDistanceFromPlane\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvec_t CapsuleOriginDistanceFromPlane(vec3_t normal, vec3_t mins, vec3_t maxs)\n{\n\tfloat offset_up, offset_down, width, radius;\n\n\twidth = maxs[0] - mins[0];\n\t// if the box is less high then it is wide\n\tif (maxs[2] - mins[2] < width) {\n\t\twidth = maxs[2] - mins[2];\n\t}\n\tradius = width * 0.5;\n\t// offset to upper and lower sphere\n\toffset_up = maxs[2] - radius;\n\toffset_down = -mins[2] - radius;\n\n\t// if normal points upward\n\tif ( normal[2] > 0 ) {\n\t\t// touches lower sphere first\n\t\treturn normal[2] * offset_down + radius;\n\t}\n\telse {\n\t\t// touched upper sphere first\n\t\treturn -normal[2] * offset_up + radius;\n\t}\n}\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ExpandMapBrush(mapbrush_t *brush, vec3_t mins, vec3_t maxs)\n{\n\tint sn;\n\tfloat dist;\n\tside_t *s;\n\tplane_t *plane;\n\n\tfor (sn = 0; sn < brush->numsides; sn++)\n\t{\n\t\ts = brush->original_sides + sn;\n\t\tplane = &mapplanes[s->planenum];\n\t\tdist = plane->dist;\n\t\tif (capsule_collision) {\n\t\t\tdist += CapsuleOriginDistanceFromPlane(plane->normal, mins, maxs);\n\t\t}\n\t\telse {\n\t\t\tdist += BoxOriginDistanceFromPlane(plane->normal, mins, maxs, 0);\n\t\t}\n\t\ts->planenum = FindFloatPlane(plane->normal, dist);\n\t\t//the side isn't a bevel after expanding\n\t\ts->flags &= ~SFL_BEVEL;\n\t\t//don't skip the surface\n\t\ts->surf &= ~SURF_SKIP;\n\t\t//make sure the texinfo is not TEXINFO_NODE\n\t\t//when player clip contents brushes are read from the bsp tree\n\t\t//they have the texinfo field set to TEXINFO_NODE\n\t\t//s->texinfo = 0;\n\t} //end for\n} //end of the function AAS_ExpandMapBrush\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_SetTexinfo(mapbrush_t *brush)\n{\n\tint n;\n\tside_t *side;\n\n\tif (brush->contents & (CONTENTS_LADDER\n\t\t\t\t\t\t\t\t\t| CONTENTS_AREAPORTAL\n\t\t\t\t\t\t\t\t\t| CONTENTS_CLUSTERPORTAL\n\t\t\t\t\t\t\t\t\t| CONTENTS_TELEPORTER\n\t\t\t\t\t\t\t\t\t| CONTENTS_JUMPPAD\n\t\t\t\t\t\t\t\t\t| CONTENTS_DONOTENTER\n\t\t\t\t\t\t\t\t\t| CONTENTS_WATER\n\t\t\t\t\t\t\t\t\t| CONTENTS_LAVA\n\t\t\t\t\t\t\t\t\t| CONTENTS_SLIME\n\t\t\t\t\t\t\t\t\t| CONTENTS_WINDOW\n\t\t\t\t\t\t\t\t\t| CONTENTS_PLAYERCLIP))\n\t{\n\t\t//we just set texinfo to 0 because these brush sides MUST be used as\n\t\t//bsp splitters textured or not textured\n\t\tfor (n = 0; n < brush->numsides; n++)\n\t\t{\n\t\t\tside = brush->original_sides + n;\n\t\t\t//side->flags |= SFL_TEXTURED|SFL_VISIBLE;\n\t\t\tside->texinfo = 0;\n\t\t} //end for\n\t} //end if\n\telse\n\t{\n\t\t//only use brush sides as splitters if they are textured\n\t\t//texinfo of non-textured sides will be set to TEXINFO_NODE\n\t\tfor (n = 0; n < brush->numsides; n++)\n\t\t{\n\t\t\tside = brush->original_sides + n;\n\t\t\t//don't use side as splitter (set texinfo to TEXINFO_NODE) if not textured\n\t\t\tif (side->flags & (SFL_TEXTURED|SFL_BEVEL)) side->texinfo = 0;\n\t\t\telse side->texinfo = TEXINFO_NODE;\n\t\t} //end for\n\t} //end else\n} //end of the function AAS_SetTexinfo\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid FreeBrushWindings(mapbrush_t *brush)\n{\n\tint n;\n\tside_t *side;\n\t//\n\tfor (n = 0; n < brush->numsides; n++)\n\t{\n\t\tside = brush->original_sides + n;\n\t\t//\n\t\tif (side->winding) FreeWinding(side->winding);\n\t} //end for\n} //end of the function FreeBrushWindings\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_AddMapBrushSide(mapbrush_t *brush, int planenum)\n{\n\tside_t *side;\n\t//\n\tif (nummapbrushsides >= MAX_MAPFILE_BRUSHSIDES)\n\t\tError (\"MAX_MAPFILE_BRUSHSIDES\");\n\t//\n\tside = brush->original_sides + brush->numsides;\n\tside->original = NULL;\n\tside->winding = NULL;\n\tside->contents = brush->contents;\n\tside->flags &= ~(SFL_BEVEL|SFL_VISIBLE);\n\tside->surf = 0;\n\tside->planenum = planenum;\n\tside->texinfo = 0;\n\t//\n\tnummapbrushsides++;\n\tbrush->numsides++;\n} //end of the function AAS_AddMapBrushSide\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FixMapBrush(mapbrush_t *brush)\n{\n\tint i, j, planenum;\n\tfloat dist;\n\twinding_t *w;\n\tplane_t *plane, *plane1, *plane2;\n\tside_t *side;\n\tvec3_t normal;\n\n\t//calculate the brush bounds\n\tClearBounds(brush->mins, brush->maxs);\n\tfor (i = 0; i < brush->numsides; i++)\n\t{\n\t\tplane = &mapplanes[brush->original_sides[i].planenum];\n\t\tw = BaseWindingForPlane(plane->normal, plane->dist);\n\t\tfor (j = 0; j < brush->numsides && w; j++)\n\t\t{\n\t\t\tif (i == j) continue;\n\t\t\t//there are no brush bevels marked but who cares :)\n\t\t\tif (brush->original_sides[j].flags & SFL_BEVEL) continue;\n\t\t\tplane = &mapplanes[brush->original_sides[j].planenum^1];\n\t\t\tChopWindingInPlace(&w, plane->normal, plane->dist, 0); //CLIP_EPSILON);\n\t\t} //end for\n\n\t\tside = &brush->original_sides[i];\n\t\tside->winding = w;\n\t\tif (w)\n\t\t{\n\t\t\tfor (j = 0; j < w->numpoints; j++)\n\t\t\t{\n\t\t\t\tAddPointToBounds(w->p[j], brush->mins, brush->maxs);\n\t\t\t} //end for\n\t\t} //end if\n\t} //end for\n\t//\n\tfor (i = 0; i < brush->numsides; i++)\n\t{\n\t\tfor (j = 0; j < brush->numsides; j++)\n\t\t{\n\t\t\tif (i == j) continue;\n\t\t\tplane1 = &mapplanes[brush->original_sides[i].planenum];\n\t\t\tplane2 = &mapplanes[brush->original_sides[j].planenum];\n\t\t\tif (WindingsNonConvex(brush->original_sides[i].winding,\n\t\t\t\t\t\t\t\t\tbrush->original_sides[j].winding,\n\t\t\t\t\t\t\t\t\tplane1->normal, plane2->normal,\n\t\t\t\t\t\t\t\t\tplane1->dist, plane2->dist))\n\t\t\t{\n\t\t\t\tLog_Print(\"non convex brush\");\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\n\t//NOW close the fucking brush!!\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tif (brush->mins[i] < -MAX_MAP_BOUNDS)\n\t\t{\n\t\t\tVectorClear(normal);\n\t\t\tnormal[i] = -1;\n\t\t\tdist = MAX_MAP_BOUNDS - 10;\n\t\t\tplanenum = FindFloatPlane(normal, dist);\n\t\t\t//\n\t\t\tLog_Print(\"mins out of range: added extra brush side\\n\");\n\t\t\tAAS_AddMapBrushSide(brush, planenum);\n\t\t} //end if\n\t\tif (brush->maxs[i] > MAX_MAP_BOUNDS)\n\t\t{\n\t\t\tVectorClear(normal);\n\t\t\tnormal[i] = 1;\n\t\t\tdist = MAX_MAP_BOUNDS - 10;\n\t\t\tplanenum = FindFloatPlane(normal, dist);\n\t\t\t//\n\t\t\tLog_Print(\"maxs out of range: added extra brush side\\n\");\n\t\t\tAAS_AddMapBrushSide(brush, planenum);\n\t\t} //end if\n\t\tif (brush->mins[i] > MAX_MAP_BOUNDS || brush->maxs[i] < -MAX_MAP_BOUNDS)\n\t\t{\n\t\t\tLog_Print(\"entity %i, brush %i: no visible sides on brush\\n\", brush->entitynum, brush->brushnum);\n\t\t} //end if\n\t} //end for\n\t//free all the windings\n\tFreeBrushWindings(brush);\n} //end of the function AAS_FixMapBrush\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_MakeBrushWindings(mapbrush_t *ob)\n{\n\tint\t\t\ti, j;\n\twinding_t\t*w;\n\tside_t\t\t*side;\n\tplane_t\t\t*plane, *plane1, *plane2;\n\n\tClearBounds (ob->mins, ob->maxs);\n\n\tfor (i = 0; i < ob->numsides; i++)\n\t{\n\t\tplane = &mapplanes[ob->original_sides[i].planenum];\n\t\tw = BaseWindingForPlane(plane->normal, plane->dist);\n\t\tfor (j = 0; j <ob->numsides && w; j++)\n\t\t{\n\t\t\tif (i == j) continue;\n\t\t\tif (ob->original_sides[j].flags & SFL_BEVEL) continue;\n\t\t\tplane = &mapplanes[ob->original_sides[j].planenum^1];\n\t\t\tChopWindingInPlace(&w, plane->normal, plane->dist, 0); //CLIP_EPSILON);\n\t\t}\n\n\t\tside = &ob->original_sides[i];\n\t\tside->winding = w;\n\t\tif (w)\n\t\t{\n\t\t\tside->flags |= SFL_VISIBLE;\n\t\t\tfor (j = 0; j < w->numpoints; j++)\n\t\t\t\tAddPointToBounds (w->p[j], ob->mins, ob->maxs);\n\t\t}\n\t}\n\t//check if the brush is convex\n\tfor (i = 0; i < ob->numsides; i++)\n\t{\n\t\tfor (j = 0; j < ob->numsides; j++)\n\t\t{\n\t\t\tif (i == j) continue;\n\t\t\tplane1 = &mapplanes[ob->original_sides[i].planenum];\n\t\t\tplane2 = &mapplanes[ob->original_sides[j].planenum];\n\t\t\tif (WindingsNonConvex(ob->original_sides[i].winding,\n\t\t\t\t\t\t\t\t\tob->original_sides[j].winding,\n\t\t\t\t\t\t\t\t\tplane1->normal, plane2->normal,\n\t\t\t\t\t\t\t\t\tplane1->dist, plane2->dist))\n\t\t\t{\n\t\t\t\tLog_Print(\"non convex brush\");\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\t//check for out of bound brushes\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\t//IDBUG: all the indexes into the mins and maxs were zero (not using i)\n\t\tif (ob->mins[i] < -MAX_MAP_BOUNDS || ob->maxs[i] > MAX_MAP_BOUNDS)\n\t\t{\n\t\t\tLog_Print(\"entity %i, brush %i: bounds out of range\\n\", ob->entitynum, ob->brushnum);\n\t\t\tLog_Print(\"ob->mins[%d] = %f, ob->maxs[%d] = %f\\n\", i, ob->mins[i], i, ob->maxs[i]);\n\t\t\tob->numsides = 0; //remove the brush\n\t\t\tbreak;\n\t\t} //end if\n\t\tif (ob->mins[i] > MAX_MAP_BOUNDS || ob->maxs[i] < -MAX_MAP_BOUNDS)\n\t\t{\n\t\t\tLog_Print(\"entity %i, brush %i: no visible sides on brush\\n\", ob->entitynum, ob->brushnum);\n\t\t\tLog_Print(\"ob->mins[%d] = %f, ob->maxs[%d] = %f\\n\", i, ob->mins[i], i, ob->maxs[i]);\n\t\t\tob->numsides = 0; //remove the brush\n\t\t\tbreak;\n\t\t} //end if\n\t} //end for\n\treturn true;\n} //end of the function AAS_MakeBrushWindings\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nmapbrush_t *AAS_CopyMapBrush(mapbrush_t *brush, entity_t *mapent)\n{\n\tint n;\n\tmapbrush_t *newbrush;\n\tside_t *side, *newside;\n\n\tif (nummapbrushes >= MAX_MAPFILE_BRUSHES)\n\t\tError (\"MAX_MAPFILE_BRUSHES\");\n\n\tnewbrush = &mapbrushes[nummapbrushes];\n\tnewbrush->original_sides = &brushsides[nummapbrushsides];\n\tnewbrush->entitynum = brush->entitynum;\n\tnewbrush->brushnum = nummapbrushes - mapent->firstbrush;\n\tnewbrush->numsides = brush->numsides;\n\tnewbrush->contents = brush->contents;\n\n\t//copy the sides\n\tfor (n = 0; n < brush->numsides; n++)\n\t{\n\t\tif (nummapbrushsides >= MAX_MAPFILE_BRUSHSIDES)\n\t\t\tError (\"MAX_MAPFILE_BRUSHSIDES\");\n\t\tside = brush->original_sides + n;\n\n\t\tnewside = newbrush->original_sides + n;\n\t\tnewside->original = NULL;\n\t\tnewside->winding = NULL;\n\t\tnewside->contents = side->contents;\n\t\tnewside->flags = side->flags;\n\t\tnewside->surf = side->surf;\n\t\tnewside->planenum = side->planenum;\n\t\tnewside->texinfo = side->texinfo;\n\t\tnummapbrushsides++;\n\t} //end for\n\t//\n\tnummapbrushes++;\n\tmapent->numbrushes++;\n\treturn newbrush;\n} //end of the function AAS_CopyMapBrush\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint mark_entities[MAX_MAP_ENTITIES];\n\nint AAS_AlwaysTriggered_r(char *targetname)\n{\n\tint i;\n\n\tif (!strlen(targetname)) {\n\t\treturn false;\n\t}\n\t//\n\tfor (i = 0; i < num_entities; i++) {\n\t\t// if the entity will activate the given targetname\n\t\tif ( !strcmp(targetname, ValueForKey(&entities[i], \"target\")) ) {\n\t\t\t// if this activator is present in deathmatch\n\t\t\tif (!(atoi(ValueForKey(&entities[i], \"spawnflags\")) & SPAWNFLAG_NOT_DEATHMATCH)) {\n\t\t\t\t// if it is a trigger_always entity\n\t\t\t\tif (!strcmp(\"trigger_always\", ValueForKey(&entities[i], \"classname\"))) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\t// check for possible trigger_always entities activating this entity\n\t\t\t\tif ( mark_entities[i] ) {\n\t\t\t\t\tWarning( \"entity %d, classname %s has recursive targetname %s\\n\", i,\n\t\t\t\t\t\t\t\t\t\tValueForKey(&entities[i], \"classname\"), targetname );\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tmark_entities[i] = true;\n\t\t\t\tif ( AAS_AlwaysTriggered_r(ValueForKey(&entities[i], \"targetname\")) ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n}\n\nint AAS_AlwaysTriggered(char *targetname) {\n\tmemset( mark_entities, 0, sizeof(mark_entities) );\n\treturn AAS_AlwaysTriggered_r( targetname );\n}\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_ValidEntity(entity_t *mapent)\n{\n\tint i;\n\tchar target[1024];\n\n\t//all world brushes are used for AAS\n\tif (mapent == &entities[0])\n\t{\n\t\treturn true;\n\t} //end if\n\t//some of the func_wall brushes are also used for AAS\n\telse if (!strcmp(\"func_wall\", ValueForKey(mapent, \"classname\")))\n\t{\n\t\t//Log_Print(\"found func_wall entity %d\\n\", mapent - entities);\n\t\t//if the func wall is used in deathmatch\n\t\tif (!(atoi(ValueForKey(mapent, \"spawnflags\")) & SPAWNFLAG_NOT_DEATHMATCH))\n\t\t{\n\t\t\t//Log_Print(\"func_wall USED in deathmatch mode %d\\n\", atoi(ValueForKey(mapent, \"spawnflags\")));\n\t\t\treturn true;\n\t\t} //end if\n\t} //end else if\n\telse if (!strcmp(\"func_door_rotating\", ValueForKey(mapent, \"classname\")))\n\t{\n\t\t//if the func_door_rotating is present in deathmatch\n\t\tif (!(atoi(ValueForKey(mapent, \"spawnflags\")) & SPAWNFLAG_NOT_DEATHMATCH))\n\t\t{\n\t\t\t//if the func_door_rotating is always activated in deathmatch\n\t\t\tif (AAS_AlwaysTriggered(ValueForKey(mapent, \"targetname\")))\n\t\t\t{\n\t\t\t\t//Log_Print(\"found func_door_rotating in deathmatch\\ntargetname %s\\n\", ValueForKey(mapent, \"targetname\"));\n\t\t\t\treturn true;\n\t\t\t} //end if\n\t\t} //end if\n\t} //end else if\n\telse if (!strcmp(\"trigger_hurt\", ValueForKey(mapent, \"classname\")))\n\t{\n\t\t//\"dmg\" is the damage, for instance: \"dmg\" \"666\"\n\t\treturn true;\n\t} //end else if\n\telse if (!strcmp(\"trigger_push\", ValueForKey(mapent, \"classname\")))\n\t{\n\t\treturn true;\n\t} //end else if\n\telse if (!strcmp(\"trigger_multiple\", ValueForKey(mapent, \"classname\")))\n\t{\n\t\t//find out if the trigger_multiple is pointing to a target_teleporter\n\t\tstrcpy(target, ValueForKey(mapent, \"target\"));\n\t\tfor (i = 0; i < num_entities; i++)\n\t\t{\n\t\t\t//if the entity will activate the given targetname\n\t\t\tif (!strcmp(target, ValueForKey(&entities[i], \"targetname\")))\n\t\t\t{\n\t\t\t\tif (!strcmp(\"target_teleporter\", ValueForKey(&entities[i], \"classname\")))\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end for\n\t} //end else if\n\telse if (!strcmp(\"trigger_teleport\", ValueForKey(mapent, \"classname\")))\n\t{\n\t\treturn true;\n\t} //end else if\n\telse if (!strcmp(\"func_static\", ValueForKey(mapent, \"classname\")))\n\t{\n\t\t//FIXME: easy/medium/hard/deathmatch specific?\n\t\treturn true;\n\t} //end else if\n\telse if (!strcmp(\"func_door\", ValueForKey(mapent, \"classname\")))\n\t{\n\t\treturn true;\n\t} //end else if\n\treturn false;\n} //end of the function AAS_ValidEntity\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_TransformPlane(int planenum, vec3_t origin, vec3_t angles)\n{\n\tfloat newdist, matrix[3][3];\n\tvec3_t normal;\n\n\t//rotate the node plane\n\tVectorCopy(mapplanes[planenum].normal, normal);\n\tCreateRotationMatrix(angles, matrix);\n\tRotatePoint(normal, matrix);\n\tnewdist = mapplanes[planenum].dist + DotProduct(normal, origin);\n\treturn FindFloatPlane(normal, newdist);\n} //end of the function AAS_TransformPlane\n//===========================================================================\n// this function sets the func_rotating_door in it's final position\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_PositionFuncRotatingBrush(entity_t *mapent, mapbrush_t *brush)\n{\n\tint spawnflags, i;\n\tfloat distance;\n\tvec3_t movedir, angles, pos1, pos2;\n\tside_t *s;\n\n\tspawnflags = FloatForKey(mapent, \"spawnflags\");\n\tVectorClear(movedir);\n\tif (spawnflags & DOOR_X_AXIS)\n\t\tmovedir[2] = 1.0;\t\t//roll\n\telse if (spawnflags & DOOR_Y_AXIS)\n\t\tmovedir[0] = 1.0;\t\t//pitch\n\telse // Z_AXIS\n\t\tmovedir[1] = 1.0;\t\t//yaw\n\n\t// check for reverse rotation\n\tif (spawnflags & DOOR_REVERSE)\n\t\tVectorInverse(movedir);\n\n\tdistance = FloatForKey(mapent, \"distance\");\n\tif (!distance) distance = 90;\n\n\tGetVectorForKey(mapent, \"angles\", angles);\n\tVectorCopy(angles, pos1);\n\tVectorMA(angles, -distance, movedir, pos2);\n\t// if it starts open, switch the positions\n\tif (spawnflags & DOOR_START_OPEN)\n\t{\n\t\tVectorCopy(pos2, angles);\n\t\tVectorCopy(pos1, pos2);\n\t\tVectorCopy(angles, pos1);\n\t\tVectorInverse(movedir);\n\t} //end if\n\t//\n\tfor (i = 0; i < brush->numsides; i++)\n\t{\n\t\ts = &brush->original_sides[i];\n\t\ts->planenum = AAS_TransformPlane(s->planenum, mapent->origin, pos2);\n\t} //end for\n\t//\n\tFreeBrushWindings(brush);\n\tAAS_MakeBrushWindings(brush);\n\tAddBrushBevels(brush);\n\tFreeBrushWindings(brush);\n} //end of the function AAS_PositionFuncRotatingBrush\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_PositionBrush(entity_t *mapent, mapbrush_t *brush)\n{\n\tside_t *s;\n\tfloat newdist;\n\tint i, notteam;\n\tchar *model;\n\n\tif (!strcmp(ValueForKey(mapent, \"classname\"), \"func_door_rotating\"))\n\t{\n\t\tAAS_PositionFuncRotatingBrush(mapent, brush);\n\t} //end if\n\telse\n\t{\n\t\tif (mapent->origin[0] || mapent->origin[1] || mapent->origin[2])\n\t\t{\n\t\t\tfor (i = 0; i < brush->numsides; i++)\n\t\t\t{\n\t\t\t\ts = &brush->original_sides[i];\n\t\t\t\tnewdist = mapplanes[s->planenum].dist +\n\t\t\t\t\t\tDotProduct(mapplanes[s->planenum].normal, mapent->origin);\n\t\t\t\ts->planenum = FindFloatPlane(mapplanes[s->planenum].normal, newdist);\n\t\t\t} //end for\n\t\t} //end if\n\t\t//if it's a trigger hurt\n\t\tif (!strcmp(\"trigger_hurt\", ValueForKey(mapent, \"classname\")))\n\t\t{\n\t\t\tnotteam = FloatForKey(mapent, \"bot_notteam\");\n\t\t\tif ( notteam == 1 ) {\n\t\t\t\tbrush->contents |= CONTENTS_NOTTEAM1;\n\t\t\t}\n\t\t\telse if ( notteam == 2 ) {\n\t\t\t\tbrush->contents |= CONTENTS_NOTTEAM2;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// always avoid so set lava contents\n\t\t\t\tbrush->contents |= CONTENTS_LAVA;\n\t\t\t}\n\t\t} //end if\n\t\t//\n\t\telse if (!strcmp(\"trigger_push\", ValueForKey(mapent, \"classname\")))\n\t\t{\n\t\t\t//set the jumppad contents\n\t\t\tbrush->contents = CONTENTS_JUMPPAD;\n\t\t\t//Log_Print(\"found trigger_push brush\\n\");\n\t\t} //end if\n\t\t//\n\t\telse if (!strcmp(\"trigger_multiple\", ValueForKey(mapent, \"classname\")))\n\t\t{\n\t\t\t//set teleporter contents\n\t\t\tbrush->contents = CONTENTS_TELEPORTER;\n\t\t\t//Log_Print(\"found trigger_multiple teleporter brush\\n\");\n\t\t} //end if\n\t\t//\n\t\telse if (!strcmp(\"trigger_teleport\", ValueForKey(mapent, \"classname\")))\n\t\t{\n\t\t\t//set teleporter contents\n\t\t\tbrush->contents = CONTENTS_TELEPORTER;\n\t\t\t//Log_Print(\"found trigger_teleport teleporter brush\\n\");\n\t\t} //end if\n\t\telse if (!strcmp(\"func_door\", ValueForKey(mapent, \"classname\")))\n\t\t{\n\t\t\t//set mover contents\n\t\t\tbrush->contents = CONTENTS_MOVER;\n\t\t\t//get the model number\n\t\t\tmodel = ValueForKey(mapent, \"model\");\n\t\t\tbrush->modelnum = atoi(model+1);\n\t\t} //end if\n\t} //end else\n} //end of the function AAS_PositionBrush\n//===========================================================================\n// uses the global cfg_t cfg\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_CreateMapBrushes(mapbrush_t *brush, entity_t *mapent, int addbevels)\n{\n\tint i;\n\t//side_t *s;\n\tmapbrush_t *bboxbrushes[16];\n\n\t//if the brushes are not from an entity used for AAS\n\tif (!AAS_ValidEntity(mapent))\n\t{\n\t\tnummapbrushsides -= brush->numsides;\n\t\tbrush->numsides = 0;\n\t\treturn;\n\t} //end if\n\t//\n\tAAS_PositionBrush(mapent, brush);\n\t//from all normal solid brushes only the textured brush sides will\n\t//be used as bsp splitters, so set the right texinfo reference here\n\tAAS_SetTexinfo(brush);\n\t//remove contents detail flag, otherwise player clip contents won't be\n\t//bsped correctly for AAS!\n\tbrush->contents &= ~CONTENTS_DETAIL;\n\t//if the brush has contents area portal it should be the only contents\n\tif (brush->contents & (CONTENTS_AREAPORTAL|CONTENTS_CLUSTERPORTAL))\n\t{\n\t\tbrush->contents = CONTENTS_CLUSTERPORTAL;\n\t\tbrush->leafnum = -1;\n\t} //end if\n\t//window and playerclip are used for player clipping, make them solid\n\tif (brush->contents & (CONTENTS_WINDOW | CONTENTS_PLAYERCLIP))\n\t{\n\t\t//\n\t\tbrush->contents &= ~(CONTENTS_WINDOW | CONTENTS_PLAYERCLIP);\n\t\tbrush->contents |= CONTENTS_SOLID;\n\t\tbrush->leafnum = -1;\n\t} //end if\n\t//\n\tif (brush->contents & CONTENTS_BOTCLIP)\n\t{\n\t\tbrush->contents = CONTENTS_SOLID;\n\t\tbrush->leafnum = -1;\n\t} //end if\n\t//\n\t//Log_Write(\"brush %d contents = \", brush->brushnum);\n\t//PrintContents(brush->contents);\n\t//Log_Write(\"\\r\\n\");\n\t//if not one of the following brushes then the brush is NOT used for AAS\n\tif (!(brush->contents & (CONTENTS_SOLID\n\t\t\t\t\t\t\t\t\t| CONTENTS_LADDER\n\t\t\t\t\t\t\t\t\t| CONTENTS_CLUSTERPORTAL\n\t\t\t\t\t\t\t\t\t| CONTENTS_DONOTENTER\n\t\t\t\t\t\t\t\t\t| CONTENTS_TELEPORTER\n\t\t\t\t\t\t\t\t\t| CONTENTS_JUMPPAD\n\t\t\t\t\t\t\t\t\t| CONTENTS_WATER\n\t\t\t\t\t\t\t\t\t| CONTENTS_LAVA\n\t\t\t\t\t\t\t\t\t| CONTENTS_SLIME\n\t\t\t\t\t\t\t\t\t| CONTENTS_MOVER\n\t\t\t\t\t\t\t\t\t)))\n\t{\n\t\tnummapbrushsides -= brush->numsides;\n\t\tbrush->numsides = 0;\n\t\treturn;\n\t} //end if\n\t//fix the map brush\n\t//AAS_FixMapBrush(brush);\n\t//if brush bevels should be added (for real map brushes, not bsp map brushes)\n\tif (addbevels)\n\t{\n\t\t//NOTE: we first have to get the mins and maxs of the brush before\n\t\t//\t\t\tcreating the brush bevels... the mins and maxs are used to\n\t\t//\t\t\tcreate them. so we call MakeBrushWindings to get the mins\n\t\t//\t\t\tand maxs and then after creating the bevels we free the\n\t\t//\t\t\twindings because they are created for all sides (including\n\t\t//\t\t\tbevels) a little later\n\t\tAAS_MakeBrushWindings(brush);\n\t\tAddBrushBevels(brush);\n\t\tFreeBrushWindings(brush);\n\t} //end if\n\t//NOTE: add the brush to the WORLD entity!!!\n\tmapent = &entities[0];\n\t//there's at least one new brush for now\n\tnummapbrushes++;\n\tmapent->numbrushes++;\n\t//liquid brushes are expanded for the maximum possible bounding box\n\tif (brush->contents & (CONTENTS_WATER\n\t\t\t\t\t\t\t\t\t| CONTENTS_LAVA\n\t\t\t\t\t\t\t\t\t| CONTENTS_SLIME \n\t\t\t\t\t\t\t\t\t| CONTENTS_TELEPORTER\n\t\t\t\t\t\t\t\t\t| CONTENTS_JUMPPAD\n\t\t\t\t\t\t\t\t\t| CONTENTS_DONOTENTER\n\t\t\t\t\t\t\t\t\t| CONTENTS_MOVER\n\t\t\t\t\t\t\t\t\t))\n\t{\n\t\tbrush->expansionbbox = 0;\n\t\t//NOTE: the first bounding box is the max\n\t\t//FIXME: use max bounding box created from all bboxes\n\t\tAAS_ExpandMapBrush(brush, cfg.bboxes[0].mins, cfg.bboxes[0].maxs);\n\t\tAAS_MakeBrushWindings(brush);\n\t} //end if\n\t//area portal brushes are NOT expanded\n\telse if (brush->contents & CONTENTS_CLUSTERPORTAL)\n\t{\n\t\tbrush->expansionbbox = 0;\n\t\t//NOTE: the first bounding box is the max\n\t\t//FIXME: use max bounding box created from all bboxes\n\t\tAAS_ExpandMapBrush(brush, cfg.bboxes[0].mins, cfg.bboxes[0].maxs);\n\t\tAAS_MakeBrushWindings(brush);\n\t} //end if\n\t//all solid brushes are expanded for all bounding boxes\n\telse if (brush->contents & (CONTENTS_SOLID\n\t\t\t\t\t\t\t\t\t\t| CONTENTS_LADDER\n\t\t\t\t\t\t\t\t\t\t))\n\t{\n\t\t//brush for the first bounding box\n\t\tbboxbrushes[0] = brush;\n\t\t//make a copy for the other bounding boxes\n\t\tfor (i = 1; i < cfg.numbboxes; i++)\n\t\t{\n\t\t\tbboxbrushes[i] = AAS_CopyMapBrush(brush, mapent);\n\t\t} //end for\n\t\t//expand every brush for it's bounding box and create windings\n\t\tfor (i = 0; i < cfg.numbboxes; i++)\n\t\t{\n\t\t\tAAS_ExpandMapBrush(bboxbrushes[i], cfg.bboxes[i].mins, cfg.bboxes[i].maxs);\n\t\t\tbboxbrushes[i]->expansionbbox = cfg.bboxes[i].presencetype;\n\t\t\tAAS_MakeBrushWindings(bboxbrushes[i]);\n\t\t} //end for\n\t} //end else\n} //end of the function AAS_CreateMapBrushes\n"
  },
  {
    "path": "code/bspc/aas_map.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\nvoid AAS_CreateMapBrushes(mapbrush_t *brush, entity_t *mapent, int addbevels);\n"
  },
  {
    "path": "code/bspc/aas_prunenodes.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n#include \"../botlib/aasfile.h\"\n#include \"aas_create.h\"\n\nint c_numprunes;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\ntmp_node_t *AAS_PruneNodes_r(tmp_node_t *tmpnode)\n{\n\ttmp_area_t *tmparea1, *tmparea2;\n\n\t//if it is a solid leaf\n\tif (!tmpnode) return NULL;\n\t//\n\tif (tmpnode->tmparea) return tmpnode;\n\t//process the children first\n\ttmpnode->children[0] = AAS_PruneNodes_r(tmpnode->children[0]);\n\ttmpnode->children[1] = AAS_PruneNodes_r(tmpnode->children[1]);\n\t//if both children are areas\n\tif (tmpnode->children[0] && tmpnode->children[1] &&\n\t\t\ttmpnode->children[0]->tmparea && tmpnode->children[1]->tmparea)\n\t{\n\t\ttmparea1 = tmpnode->children[0]->tmparea;\n\t\twhile(tmparea1->mergedarea) tmparea1 = tmparea1->mergedarea;\n\n\t\ttmparea2 = tmpnode->children[1]->tmparea;\n\t\twhile(tmparea2->mergedarea) tmparea2 = tmparea2->mergedarea;\n\n\t\tif (tmparea1 == tmparea2)\n\t\t{\n\t\t\tc_numprunes++;\n\t\t\ttmpnode->tmparea = tmparea1;\n\t\t\ttmpnode->planenum = 0;\n\t\t\tAAS_FreeTmpNode(tmpnode->children[0]);\n\t\t\tAAS_FreeTmpNode(tmpnode->children[1]);\n\t\t\ttmpnode->children[0] = NULL;\n\t\t\ttmpnode->children[1] = NULL;\n\t\t\treturn tmpnode;\n\t\t} //end if\n\t} //end if\n\t//if both solid leafs\n\tif (!tmpnode->children[0] && !tmpnode->children[1])\n\t{\n\t\tc_numprunes++;\n\t\tAAS_FreeTmpNode(tmpnode);\n\t\treturn NULL;\n\t} //end if\n\t//\n\treturn tmpnode;\n} //end of the function AAS_PruneNodes_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_PruneNodes(void)\n{\n\tLog_Write(\"AAS_PruneNodes\\r\\n\");\n\tAAS_PruneNodes_r(tmpaasworld.nodes);\n\tLog_Print(\"%6d nodes pruned\\r\\n\", c_numprunes);\n} //end of the function AAS_PruneNodes\n"
  },
  {
    "path": "code/bspc/aas_prunenodes.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\nvoid AAS_PruneNodes(void);\n\n"
  },
  {
    "path": "code/bspc/aas_store.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n#include \"../botlib/aasfile.h\"\n#include \"aas_file.h\"\n#include \"aas_store.h\"\n#include \"aas_create.h\"\n#include \"aas_cfg.h\"\n\n\n//#define NOTHREEVERTEXFACES\n\n#define STOREPLANESDOUBLE\n\n#define VERTEX_EPSILON\t\t\t0.1\t\t\t//NOTE: changed from 0.5\n#define DIST_EPSILON\t\t\t0.05\t\t//NOTE: changed from 0.9\n#define NORMAL_EPSILON\t\t\t0.0001\t\t//NOTE: changed from 0.005\n#define INTEGRAL_EPSILON\t\t0.01\n\n#define VERTEX_HASHING\n#define VERTEX_HASH_SHIFT\t\t7\n#define VERTEX_HASH_SIZE\t\t((MAX_MAP_BOUNDS>>(VERTEX_HASH_SHIFT-1))+1)\t//was 64\n//\n#define PLANE_HASHING\n#define PLANE_HASH_SIZE\t\t\t1024\t\t//must be power of 2\n//\n#define EDGE_HASHING\n#define EDGE_HASH_SIZE\t\t\t1024\t\t//must be power of 2\n\naas_t aasworld;\n\n//vertex hash\nint *aas_vertexchain;\t\t\t\t\t\t// the next vertex in a hash chain\nint aas_hashverts[VERTEX_HASH_SIZE*VERTEX_HASH_SIZE];\t// a vertex number, or 0 for no verts\n//plane hash\nint *aas_planechain;\nint aas_hashplanes[PLANE_HASH_SIZE];\n//edge hash\nint *aas_edgechain;\nint aas_hashedges[EDGE_HASH_SIZE];\n\nint allocatedaasmem = 0;\n\nint groundfacesonly = false;//true;\n//\ntypedef struct max_aas_s\n{\n\tint max_bboxes;\n\tint max_vertexes;\n\tint max_planes;\n\tint max_edges;\n\tint max_edgeindexsize;\n\tint max_faces;\n\tint max_faceindexsize;\n\tint max_areas;\n\tint max_areasettings;\n\tint max_reachabilitysize;\n\tint max_nodes;\n\tint max_portals;\n\tint max_portalindexsize;\n\tint max_clusters;\n} max_aas_t;\n//maximums of everything\nmax_aas_t max_aas;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_CountTmpNodes(tmp_node_t *tmpnode)\n{\n\tif (!tmpnode) return 0;\n\treturn AAS_CountTmpNodes(tmpnode->children[0]) +\n\t\t\t\tAAS_CountTmpNodes(tmpnode->children[1]) + 1;\n} //end of the function AAS_CountTmpNodes\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_InitMaxAAS(void)\n{\n\tint numfaces, numpoints, numareas;\n\ttmp_face_t *f;\n\ttmp_area_t *a;\n\n\tnumpoints = 0;\n\tnumfaces = 0;\n\tfor (f = tmpaasworld.faces; f; f = f->l_next)\n\t{\n\t\tnumfaces++;\n\t\tif (f->winding) numpoints += f->winding->numpoints;\n\t} //end for\n\t//\n\tnumareas = 0;\n\tfor (a = tmpaasworld.areas; a; a = a->l_next)\n\t{\n\t\tnumareas++;\n\t} //end for\n\tmax_aas.max_bboxes = AAS_MAX_BBOXES;\n\tmax_aas.max_vertexes = numpoints + 1;\n\tmax_aas.max_planes = nummapplanes;\n\tmax_aas.max_edges = numpoints + 1;\n\tmax_aas.max_edgeindexsize = (numpoints + 1) * 3;\n\tmax_aas.max_faces = numfaces + 10;\n\tmax_aas.max_faceindexsize = (numfaces + 10) * 2;\n\tmax_aas.max_areas = numareas + 10;\n\tmax_aas.max_areasettings = numareas + 10;\n\tmax_aas.max_reachabilitysize = 0;\n\tmax_aas.max_nodes = AAS_CountTmpNodes(tmpaasworld.nodes) + 10;\n\tmax_aas.max_portals = 0;\n\tmax_aas.max_portalindexsize = 0;\n\tmax_aas.max_clusters = 0;\n} //end of the function AAS_InitMaxAAS\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_AllocMaxAAS(void)\n{\n\tint i;\n\n\tAAS_InitMaxAAS();\n\t//bounding boxes\n\taasworld.numbboxes = 0;\n\taasworld.bboxes = (aas_bbox_t *) GetClearedMemory(max_aas.max_bboxes * sizeof(aas_bbox_t));\n\tallocatedaasmem += max_aas.max_bboxes * sizeof(aas_bbox_t);\n\t//vertexes\n\taasworld.numvertexes = 0;\n\taasworld.vertexes = (aas_vertex_t *) GetClearedMemory(max_aas.max_vertexes * sizeof(aas_vertex_t));\n\tallocatedaasmem += max_aas.max_vertexes * sizeof(aas_vertex_t);\n\t//planes\n\taasworld.numplanes = 0;\n\taasworld.planes = (aas_plane_t *) GetClearedMemory(max_aas.max_planes * sizeof(aas_plane_t));\n\tallocatedaasmem += max_aas.max_planes * sizeof(aas_plane_t);\n\t//edges\n\taasworld.numedges = 0;\n\taasworld.edges = (aas_edge_t *) GetClearedMemory(max_aas.max_edges * sizeof(aas_edge_t));\n\tallocatedaasmem += max_aas.max_edges * sizeof(aas_edge_t);\n\t//edge index\n\taasworld.edgeindexsize = 0;\n\taasworld.edgeindex = (aas_edgeindex_t *) GetClearedMemory(max_aas.max_edgeindexsize * sizeof(aas_edgeindex_t));\n\tallocatedaasmem += max_aas.max_edgeindexsize * sizeof(aas_edgeindex_t);\n\t//faces\n\taasworld.numfaces = 0;\n\taasworld.faces = (aas_face_t *) GetClearedMemory(max_aas.max_faces * sizeof(aas_face_t));\n\tallocatedaasmem += max_aas.max_faces * sizeof(aas_face_t);\n\t//face index\n\taasworld.faceindexsize = 0;\n\taasworld.faceindex = (aas_faceindex_t *) GetClearedMemory(max_aas.max_faceindexsize * sizeof(aas_faceindex_t));\n\tallocatedaasmem += max_aas.max_faceindexsize * sizeof(aas_faceindex_t);\n\t//convex areas\n\taasworld.numareas = 0;\n\taasworld.areas = (aas_area_t *) GetClearedMemory(max_aas.max_areas * sizeof(aas_area_t));\n\tallocatedaasmem += max_aas.max_areas * sizeof(aas_area_t);\n\t//convex area settings\n\taasworld.numareasettings = 0;\n\taasworld.areasettings = (aas_areasettings_t *) GetClearedMemory(max_aas.max_areasettings * sizeof(aas_areasettings_t));\n\tallocatedaasmem += max_aas.max_areasettings * sizeof(aas_areasettings_t);\n\t//reachablity list\n\taasworld.reachabilitysize = 0;\n\taasworld.reachability = (aas_reachability_t *) GetClearedMemory(max_aas.max_reachabilitysize * sizeof(aas_reachability_t));\n\tallocatedaasmem += max_aas.max_reachabilitysize * sizeof(aas_reachability_t);\n\t//nodes of the bsp tree\n\taasworld.numnodes = 0;\n\taasworld.nodes = (aas_node_t *) GetClearedMemory(max_aas.max_nodes * sizeof(aas_node_t));\n\tallocatedaasmem += max_aas.max_nodes * sizeof(aas_node_t);\n\t//cluster portals\n\taasworld.numportals = 0;\n\taasworld.portals = (aas_portal_t *) GetClearedMemory(max_aas.max_portals * sizeof(aas_portal_t));\n\tallocatedaasmem += max_aas.max_portals * sizeof(aas_portal_t);\n\t//cluster portal index\n\taasworld.portalindexsize = 0;\n\taasworld.portalindex = (aas_portalindex_t *) GetClearedMemory(max_aas.max_portalindexsize * sizeof(aas_portalindex_t));\n\tallocatedaasmem += max_aas.max_portalindexsize * sizeof(aas_portalindex_t);\n\t//cluster\n\taasworld.numclusters = 0;\n\taasworld.clusters = (aas_cluster_t *) GetClearedMemory(max_aas.max_clusters * sizeof(aas_cluster_t));\n\tallocatedaasmem += max_aas.max_clusters * sizeof(aas_cluster_t);\n\t//\n\tLog_Print(\"allocated \");\n\tPrintMemorySize(allocatedaasmem);\n\tLog_Print(\" of AAS memory\\n\");\n\t//reset the has stuff\n\taas_vertexchain = (int *) GetClearedMemory(max_aas.max_vertexes * sizeof(int));\n\taas_planechain = (int *) GetClearedMemory(max_aas.max_planes * sizeof(int));\n\taas_edgechain = (int *) GetClearedMemory(max_aas.max_edges * sizeof(int));\n\t//\n\tfor (i = 0; i < max_aas.max_vertexes; i++) aas_vertexchain[i] = -1;\n\tfor (i = 0; i < VERTEX_HASH_SIZE * VERTEX_HASH_SIZE; i++) aas_hashverts[i] = -1;\n\t//\n\tfor (i = 0; i < max_aas.max_planes; i++) aas_planechain[i] = -1;\n\tfor (i = 0; i < PLANE_HASH_SIZE; i++) aas_hashplanes[i] = -1;\n\t//\n\tfor (i = 0; i < max_aas.max_edges; i++) aas_edgechain[i] = -1;\n\tfor (i = 0; i < EDGE_HASH_SIZE; i++) aas_hashedges[i] = -1;\n} //end of the function AAS_AllocMaxAAS\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_FreeMaxAAS(void)\n{\n\t//bounding boxes\n\tif (aasworld.bboxes) FreeMemory(aasworld.bboxes);\n\taasworld.bboxes = NULL;\n\taasworld.numbboxes = 0;\n\t//vertexes\n\tif (aasworld.vertexes) FreeMemory(aasworld.vertexes);\n\taasworld.vertexes = NULL;\n\taasworld.numvertexes = 0;\n\t//planes\n\tif (aasworld.planes) FreeMemory(aasworld.planes);\n\taasworld.planes = NULL;\n\taasworld.numplanes = 0;\n\t//edges\n\tif (aasworld.edges) FreeMemory(aasworld.edges);\n\taasworld.edges = NULL;\n\taasworld.numedges = 0;\n\t//edge index\n\tif (aasworld.edgeindex) FreeMemory(aasworld.edgeindex);\n\taasworld.edgeindex = NULL;\n\taasworld.edgeindexsize = 0;\n\t//faces\n\tif (aasworld.faces) FreeMemory(aasworld.faces);\n\taasworld.faces = NULL;\n\taasworld.numfaces = 0;\n\t//face index\n\tif (aasworld.faceindex) FreeMemory(aasworld.faceindex);\n\taasworld.faceindex = NULL;\n\taasworld.faceindexsize = 0;\n\t//convex areas\n\tif (aasworld.areas) FreeMemory(aasworld.areas);\n\taasworld.areas = NULL;\n\taasworld.numareas = 0;\n\t//convex area settings\n\tif (aasworld.areasettings) FreeMemory(aasworld.areasettings);\n\taasworld.areasettings = NULL;\n\taasworld.numareasettings = 0;\n\t//reachablity list\n\tif (aasworld.reachability) FreeMemory(aasworld.reachability);\n\taasworld.reachability = NULL;\n\taasworld.reachabilitysize = 0;\n\t//nodes of the bsp tree\n\tif (aasworld.nodes) FreeMemory(aasworld.nodes);\n\taasworld.nodes = NULL;\n\taasworld.numnodes = 0;\n\t//cluster portals\n\tif (aasworld.portals) FreeMemory(aasworld.portals);\n\taasworld.portals = NULL;\n\taasworld.numportals = 0;\n\t//cluster portal index\n\tif (aasworld.portalindex) FreeMemory(aasworld.portalindex);\n\taasworld.portalindex = NULL;\n\taasworld.portalindexsize = 0;\n\t//clusters\n\tif (aasworld.clusters) FreeMemory(aasworld.clusters);\n\taasworld.clusters = NULL;\n\taasworld.numclusters = 0;\n\t\n\tLog_Print(\"freed \");\n\tPrintMemorySize(allocatedaasmem);\n\tLog_Print(\" of AAS memory\\n\");\n\tallocatedaasmem = 0;\n\t//\n\tif (aas_vertexchain) FreeMemory(aas_vertexchain);\n\taas_vertexchain = NULL;\n\tif (aas_planechain) FreeMemory(aas_planechain);\n\taas_planechain = NULL;\n\tif (aas_edgechain) FreeMemory(aas_edgechain);\n\taas_edgechain = NULL;\n} //end of the function AAS_FreeMaxAAS\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nunsigned AAS_HashVec(vec3_t vec)\n{\n\tint x, y;\n\n\tx = (MAX_MAP_BOUNDS + (int)(vec[0]+0.5)) >> VERTEX_HASH_SHIFT;\n\ty = (MAX_MAP_BOUNDS + (int)(vec[1]+0.5)) >> VERTEX_HASH_SHIFT;\n\n\tif (x < 0 || x >= VERTEX_HASH_SIZE || y < 0 || y >= VERTEX_HASH_SIZE)\n\t{\n\t\tLog_Print(\"WARNING! HashVec: point %f %f %f outside valid range\\n\", vec[0], vec[1], vec[2]);\n\t\tLog_Print(\"This should never happen!\\n\");\n\t\treturn -1;\n\t} //end if\n\t\n\treturn y*VERTEX_HASH_SIZE + x;\n} //end of the function AAS_HashVec\n//===========================================================================\n// returns true if the vertex was found in the list\n// stores the vertex number in *vnum\n// stores a new vertex if not stored already\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_GetVertex(vec3_t v, int *vnum)\n{\n\tint i;\n#ifndef VERTEX_HASHING\n\tfloat diff;\n#endif //VERTEX_HASHING\n\n#ifdef VERTEX_HASHING\n\tint h, vn;\n\tvec3_t vert;\n\t\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tif ( fabs(v[i] - Q_rint(v[i])) < INTEGRAL_EPSILON)\n\t\t\tvert[i] = Q_rint(v[i]);\n\t\telse\n\t\t\tvert[i] = v[i];\n\t} //end for\n\n\th = AAS_HashVec(vert);\n\t//if the vertex was outside the valid range\n\tif (h == -1)\n\t{\n\t\t*vnum = -1;\n\t\treturn true;\n\t} //end if\n\n\tfor (vn = aas_hashverts[h]; vn >= 0; vn = aas_vertexchain[vn])\n\t{\n\t\tif (fabs(aasworld.vertexes[vn][0] - vert[0]) < VERTEX_EPSILON\n\t\t\t\t&& fabs(aasworld.vertexes[vn][1] - vert[1]) < VERTEX_EPSILON\n\t\t\t\t&& fabs(aasworld.vertexes[vn][2] - vert[2]) < VERTEX_EPSILON)\n\t\t{\n\t\t\t*vnum = vn;\n\t\t\treturn true;\n\t\t} //end if\n\t} //end for\n#else //VERTEX_HASHING\n\t//check if the vertex is already stored\n\t//stupid linear search\n\tfor (i = 0; i < aasworld.numvertexes; i++)\n\t{\n\t\tdiff = vert[0] - aasworld.vertexes[i][0];\n\t\tif (diff < VERTEX_EPSILON && diff > -VERTEX_EPSILON)\n\t\t{\n\t\t\tdiff = vert[1] - aasworld.vertexes[i][1];\n\t\t\tif (diff < VERTEX_EPSILON && diff > -VERTEX_EPSILON)\n\t\t\t{\n\t\t\t\tdiff = vert[2] - aasworld.vertexes[i][2];\n\t\t\t\tif (diff < VERTEX_EPSILON && diff > -VERTEX_EPSILON)\n\t\t\t\t{\n\t\t\t\t\t*vnum = i;\n\t\t\t\t\treturn true;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n#endif //VERTEX_HASHING\n\n\tif (aasworld.numvertexes >= max_aas.max_vertexes)\n\t{\n\t\tError(\"AAS_MAX_VERTEXES = %d\", max_aas.max_vertexes);\n\t} //end if\n\tVectorCopy(vert, aasworld.vertexes[aasworld.numvertexes]);\n\t*vnum = aasworld.numvertexes;\n\n#ifdef VERTEX_HASHING\n\taas_vertexchain[aasworld.numvertexes] = aas_hashverts[h];\n\taas_hashverts[h] = aasworld.numvertexes;\n#endif //VERTEX_HASHING\n\n\taasworld.numvertexes++;\n\treturn false;\n} //end of the function AAS_GetVertex\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nunsigned AAS_HashEdge(int v1, int v2)\n{\n\tint vnum1, vnum2;\n\t//\n\tif (v1 < v2)\n\t{\n\t\tvnum1 = v1;\n\t\tvnum2 = v2;\n\t} //end if\n\telse\n\t{\n\t\tvnum1 = v2;\n\t\tvnum2 = v1;\n\t} //end else\n\treturn (vnum1 + vnum2) & (EDGE_HASH_SIZE-1);\n} //end of the function AAS_HashVec\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_AddEdgeToHash(int edgenum)\n{\n\tint hash;\n\taas_edge_t *edge;\n\n\tedge = &aasworld.edges[edgenum];\n\n\thash = AAS_HashEdge(edge->v[0], edge->v[1]);\n\n\taas_edgechain[edgenum] = aas_hashedges[hash];\n\taas_hashedges[hash] = edgenum;\n} //end of the function AAS_AddEdgeToHash\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_FindHashedEdge(int v1num, int v2num, int *edgenum)\n{\n\tint e, hash;\n\taas_edge_t *edge;\n\n\thash = AAS_HashEdge(v1num, v2num);\n\tfor (e = aas_hashedges[hash]; e >= 0; e = aas_edgechain[e])\n\t{\n\t\tedge = &aasworld.edges[e];\n\t\tif (edge->v[0] == v1num)\n\t\t{\n\t\t\tif (edge->v[1] == v2num)\n\t\t\t{\n\t\t\t\t*edgenum = e;\n\t\t\t\treturn true;\n\t\t\t} //end if\n\t\t} //end if\n\t\telse if (edge->v[1] == v1num)\n\t\t{\n\t\t\tif (edge->v[0] == v2num)\n\t\t\t{\n\t\t\t\t//negative for a reversed edge\n\t\t\t\t*edgenum = -e;\n\t\t\t\treturn true;\n\t\t\t} //end if\n\t\t} //end else\n\t} //end for\n\treturn false;\n} //end of the function AAS_FindHashedPlane\n//===========================================================================\n// returns true if the edge was found\n// stores the edge number in *edgenum (negative if reversed edge)\n// stores new edge if not stored already\n// returns zero when the edge is degenerate\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_GetEdge(vec3_t v1, vec3_t v2, int *edgenum)\n{\n\tint v1num, v2num;\n\tqboolean found;\n\n\t//the first edge is a dummy\n\tif (aasworld.numedges == 0) aasworld.numedges = 1;\n\n\tfound = AAS_GetVertex(v1, &v1num);\n\tfound &= AAS_GetVertex(v2, &v2num);\n\t//if one of the vertexes was outside the valid range\n\tif (v1num == -1 || v2num == -1)\n\t{\n\t\t*edgenum = 0;\n\t\treturn true;\n\t} //end if\n\t//if both vertexes are the same or snapped onto each other\n\tif (v1num == v2num)\n\t{\n\t\t*edgenum = 0;\n\t\treturn true;\n\t} //end if\n\t//if both vertexes where already stored\n\tif (found)\n\t{\n#ifdef EDGE_HASHING\n\t\tif (AAS_FindHashedEdge(v1num, v2num, edgenum)) return true;\n#else\n\t\tint i;\n\t\tfor (i = 1; i < aasworld.numedges; i++)\n\t\t{\n\t\t\tif (aasworld.edges[i].v[0] == v1num)\n\t\t\t{\n\t\t\t\tif (aasworld.edges[i].v[1] == v2num)\n\t\t\t\t{\n\t\t\t\t\t*edgenum = i;\n\t\t\t\t\treturn true;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t\telse if (aasworld.edges[i].v[1] == v1num)\n\t\t\t{\n\t\t\t\tif (aasworld.edges[i].v[0] == v2num)\n\t\t\t\t{\n\t\t\t\t\t//negative for a reversed edge\n\t\t\t\t\t*edgenum = -i;\n\t\t\t\t\treturn true;\n\t\t\t\t} //end if\n\t\t\t} //end else\n\t\t} //end for\n#endif //EDGE_HASHING\n\t} //end if\n\tif (aasworld.numedges >= max_aas.max_edges)\n\t{\n\t\tError(\"AAS_MAX_EDGES = %d\", max_aas.max_edges);\n\t} //end if\n\taasworld.edges[aasworld.numedges].v[0] = v1num;\n\taasworld.edges[aasworld.numedges].v[1] = v2num;\n\t*edgenum = aasworld.numedges;\n#ifdef EDGE_HASHING\n\tAAS_AddEdgeToHash(*edgenum);\n#endif //EDGE_HASHING\n\taasworld.numedges++;\n\treturn false;\n} //end of the function AAS_GetEdge\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_PlaneTypeForNormal(vec3_t normal)\n{\n\tvec_t\tax, ay, az;\n\t\n\t//NOTE: epsilon used\n\tif (\t(normal[0] >= 1.0 -NORMAL_EPSILON) ||\n\t\t\t(normal[0] <= -1.0 + NORMAL_EPSILON)) return PLANE_X;\n\tif (\t(normal[1] >= 1.0 -NORMAL_EPSILON) ||\n\t\t\t(normal[1] <= -1.0 + NORMAL_EPSILON)) return PLANE_Y;\n\tif (\t(normal[2] >= 1.0 -NORMAL_EPSILON) ||\n\t\t\t(normal[2] <= -1.0 + NORMAL_EPSILON)) return PLANE_Z;\n\t\t\n\tax = fabs(normal[0]);\n\tay = fabs(normal[1]);\n\taz = fabs(normal[2]);\n\t\n\tif (ax >= ay && ax >= az) return PLANE_ANYX;\n\tif (ay >= ax && ay >= az) return PLANE_ANYY;\n\treturn PLANE_ANYZ;\n} //end of the function AAS_PlaneTypeForNormal\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_AddPlaneToHash(int planenum)\n{\n\tint hash;\n\taas_plane_t *plane;\n\n\tplane = &aasworld.planes[planenum];\n\n\thash = (int)fabs(plane->dist) / 8;\n\thash &= (PLANE_HASH_SIZE-1);\n\n\taas_planechain[planenum] = aas_hashplanes[hash];\n\taas_hashplanes[hash] = planenum;\n} //end of the function AAS_AddPlaneToHash\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_PlaneEqual(vec3_t normal, float dist, int planenum)\n{\n\tfloat diff;\n\n\tdiff = dist - aasworld.planes[planenum].dist;\n\tif (diff > -DIST_EPSILON && diff < DIST_EPSILON)\n\t{\n\t\tdiff = normal[0] - aasworld.planes[planenum].normal[0];\n\t\tif (diff > -NORMAL_EPSILON && diff < NORMAL_EPSILON)\n\t\t{\n\t\t\tdiff = normal[1] - aasworld.planes[planenum].normal[1];\n\t\t\tif (diff > -NORMAL_EPSILON && diff < NORMAL_EPSILON)\n\t\t\t{\n\t\t\t\tdiff = normal[2] - aasworld.planes[planenum].normal[2];\n\t\t\t\tif (diff > -NORMAL_EPSILON && diff < NORMAL_EPSILON)\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end if\n\t} //end if\n\treturn false;\n} //end of the function AAS_PlaneEqual\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_FindPlane(vec3_t normal, float dist, int *planenum)\n{\n\tint i;\n\n\tfor (i = 0; i < aasworld.numplanes; i++)\n\t{\n\t\tif (AAS_PlaneEqual(normal, dist, i))\n\t\t{\n\t\t\t*planenum = i;\n\t\t\treturn true;\n\t\t} //end if\n\t} //end for\n\treturn false;\n} //end of the function AAS_FindPlane\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_FindHashedPlane(vec3_t normal, float dist, int *planenum)\n{\n\tint i, p;\n\taas_plane_t *plane;\n\tint hash, h;\n\n\thash = (int)fabs(dist) / 8;\n\thash &= (PLANE_HASH_SIZE-1);\n\n\t//search the border bins as well\n\tfor (i = -1; i <= 1; i++)\n\t{\n\t\th = (hash+i)&(PLANE_HASH_SIZE-1);\n\t\tfor (p = aas_hashplanes[h]; p >= 0; p = aas_planechain[p])\n\t\t{\n\t\t\tplane = &aasworld.planes[p];\n\t\t\tif (AAS_PlaneEqual(normal, dist, p))\n\t\t\t{\n\t\t\t\t*planenum = p;\n\t\t\t\treturn true;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\treturn false;\n} //end of the function AAS_FindHashedPlane\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_GetPlane(vec3_t normal, vec_t dist, int *planenum)\n{\n\taas_plane_t *plane, temp;\n\n\t//if (AAS_FindPlane(normal, dist, planenum)) return true;\n\tif (AAS_FindHashedPlane(normal, dist, planenum)) return true;\n\n\tif (aasworld.numplanes >= max_aas.max_planes-1)\n\t{\n\t\tError(\"AAS_MAX_PLANES = %d\", max_aas.max_planes);\n\t} //end if\n\n#ifdef STOREPLANESDOUBLE\n\tplane = &aasworld.planes[aasworld.numplanes];\n\tVectorCopy(normal, plane->normal);\n\tplane->dist = dist;\n\tplane->type = (plane+1)->type = PlaneTypeForNormal(plane->normal);\n\n\tVectorCopy(normal, (plane+1)->normal);\n\tVectorNegate((plane+1)->normal, (plane+1)->normal);\n\t(plane+1)->dist = -dist;\n\n\taasworld.numplanes += 2;\n\n\t//allways put axial planes facing positive first\n\tif (plane->type < 3)\n\t{\n\t\tif (plane->normal[0] < 0 || plane->normal[1] < 0 || plane->normal[2] < 0)\n\t\t{\n\t\t\t// flip order\n\t\t\ttemp = *plane;\n\t\t\t*plane = *(plane+1);\n\t\t\t*(plane+1) = temp;\n\t\t\t*planenum = aasworld.numplanes - 1;\n\t\t\treturn false;\n\t\t} //end if\n\t} //end if\n\t*planenum = aasworld.numplanes - 2;\n\t//add the planes to the hash\n\tAAS_AddPlaneToHash(aasworld.numplanes - 1);\n\tAAS_AddPlaneToHash(aasworld.numplanes - 2);\n\treturn false;\n#else\n\tplane = &aasworld.planes[aasworld.numplanes];\n\tVectorCopy(normal, plane->normal);\n\tplane->dist = dist;\n\tplane->type = AAS_PlaneTypeForNormal(normal);\n\n\t*planenum = aasworld.numplanes;\n\taasworld.numplanes++;\n\t//add the plane to the hash\n\tAAS_AddPlaneToHash(aasworld.numplanes - 1);\n\treturn false;\n#endif //STOREPLANESDOUBLE\n} //end of the function AAS_GetPlane\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean AAS_GetFace(winding_t *w, plane_t *p, int side, int *facenum)\n{\n\tint edgenum, i, j;\n\taas_face_t *face;\n\n\t//face zero is a dummy, because of the face index with negative numbers\n\tif (aasworld.numfaces == 0) aasworld.numfaces = 1;\n\n\tif (aasworld.numfaces >= max_aas.max_faces)\n\t{\n\t\tError(\"AAS_MAX_FACES = %d\", max_aas.max_faces);\n\t} //end if\n\tface = &aasworld.faces[aasworld.numfaces];\n\tAAS_GetPlane(p->normal, p->dist, &face->planenum);\n\tface->faceflags = 0;\n\tface->firstedge = aasworld.edgeindexsize;\n\tface->frontarea = 0;\n\tface->backarea = 0;\n\tface->numedges = 0;\n\tfor (i = 0; i < w->numpoints; i++)\n\t{\n\t\tif (aasworld.edgeindexsize >= max_aas.max_edgeindexsize)\n\t\t{\n\t\t\tError(\"AAS_MAX_EDGEINDEXSIZE = %d\", max_aas.max_edgeindexsize);\n\t\t} //end if\n\t\tj = (i+1) % w->numpoints;\n\t\tAAS_GetEdge(w->p[i], w->p[j], &edgenum);\n\t\t//if the edge wasn't degenerate\n\t\tif (edgenum)\n\t\t{\n\t\t\taasworld.edgeindex[aasworld.edgeindexsize++] = edgenum;\n\t\t\tface->numedges++;\n\t\t} //end if\n\t\telse if (verbose)\n\t\t{\n\t\t\tLog_Write(\"AAS_GetFace: face %d had degenerate edge %d-%d\\r\\n\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\taasworld.numfaces, i, j);\n\t\t} //end else\n\t} //end for\n\tif (face->numedges < 1\n#ifdef NOTHREEVERTEXFACES\n\t\t|| face->numedges < 3\n#endif //NOTHREEVERTEXFACES\n\t\t)\n\t{\n\t\tmemset(&aasworld.faces[aasworld.numfaces], 0, sizeof(aas_face_t));\n\t\tLog_Write(\"AAS_GetFace: face %d was tiny\\r\\n\", aasworld.numfaces);\n\t\treturn false;\n\t} //end if\n\t*facenum = aasworld.numfaces;\n\taasworld.numfaces++;\n\treturn true;\n} //end of the function AAS_GetFace\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n/*\nqboolean AAS_GetFace(winding_t *w, plane_t *p, int side, int *facenum)\n{\n\taas_edgeindex_t edges[1024];\n\tint planenum, numedges, i;\n\tint j, edgenum;\n\tqboolean foundplane, foundedges;\n\taas_face_t *face;\n\n\t//face zero is a dummy, because of the face index with negative numbers\n\tif (aasworld.numfaces == 0) aasworld.numfaces = 1;\n\n\tfoundplane = AAS_GetPlane(p->normal, p->dist, &planenum);\n\n\tfoundedges = true;\n\tnumedges = w->numpoints;\n\tfor (i = 0; i < w->numpoints; i++)\n\t{\n\t\tif (i >= 1024) Error(\"AAS_GetFace: more than %d edges\\n\", 1024);\n\t\tfoundedges &= AAS_GetEdge(w->p[i], w->p[(i+1 >= w->numpoints ? 0 : i+1)], &edges[i]);\n\t} //end for\n\n\t//FIXME: use portal number instead of a search\n\t//if the plane and all edges already existed\n\tif (foundplane && foundedges)\n\t{\n\t\tfor (i = 0; i < aasworld.numfaces; i++)\n\t\t{\n\t\t\tface = &aasworld.faces[i];\n\t\t\tif (planenum == face->planenum)\n\t\t\t{\n\t\t\t\tif (numedges == face->numedges)\n\t\t\t\t{\n\t\t\t\t\tfor (j = 0; j < numedges; j++)\n\t\t\t\t\t{\n\t\t\t\t\t\tedgenum = abs(aasworld.edgeindex[face->firstedge + j]);\n\t\t\t\t\t\tif (abs(edges[i]) != edgenum) break;\n\t\t\t\t\t} //end for\n\t\t\t\t\tif (j == numedges)\n\t\t\t\t\t{\n\t\t\t\t\t\t//jippy found the face\n\t\t\t\t\t\t*facenum = -i;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end for\n\t} //end if\n\tif (aasworld.numfaces >= max_aas.max_faces)\n\t{\n\t\tError(\"AAS_MAX_FACES = %d\", max_aas.max_faces);\n\t} //end if\n\tface = &aasworld.faces[aasworld.numfaces];\n\tface->planenum = planenum;\n\tface->faceflags = 0;\n\tface->numedges = numedges;\n\tface->firstedge = aasworld.edgeindexsize;\n\tface->frontarea = 0;\n\tface->backarea = 0;\n\tfor (i = 0; i < numedges; i++)\n\t{\n\t\tif (aasworld.edgeindexsize >= max_aas.max_edgeindexsize)\n\t\t{\n\t\t\tError(\"AAS_MAX_EDGEINDEXSIZE = %d\", max_aas.max_edgeindexsize);\n\t\t} //end if\n\t\taasworld.edgeindex[aasworld.edgeindexsize++] = edges[i];\n\t} //end for\n\t*facenum = aasworld.numfaces;\n\taasworld.numfaces++;\n\treturn false;\n} //end of the function AAS_GetFace*/\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_StoreAreaSettings(tmp_areasettings_t *tmpareasettings)\n{\n\taas_areasettings_t *areasettings;\n\n\tif (aasworld.numareasettings == 0) aasworld.numareasettings = 1;\n\tareasettings = &aasworld.areasettings[aasworld.numareasettings++];\n\tareasettings->areaflags = tmpareasettings->areaflags;\n\tareasettings->presencetype = tmpareasettings->presencetype;\n\tareasettings->contents = tmpareasettings->contents;\n\tif (tmpareasettings->modelnum > AREACONTENTS_MAXMODELNUM)\n\t\tLog_Print(\"WARNING: more than %d mover models\\n\", AREACONTENTS_MAXMODELNUM);\n\tareasettings->contents |= (tmpareasettings->modelnum & AREACONTENTS_MAXMODELNUM) << AREACONTENTS_MODELNUMSHIFT;\n} //end of the function AAS_StoreAreaSettings\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_StoreArea(tmp_area_t *tmparea)\n{\n\tint side, edgenum, i;\n\tplane_t *plane;\n\ttmp_face_t *tmpface;\n\taas_area_t *aasarea;\n\taas_edge_t *edge;\n\taas_face_t *aasface;\n\taas_faceindex_t aasfacenum;\n\tvec3_t facecenter;\n\twinding_t *w;\n\n\t//when the area is merged go to the merged area\n\t//FIXME: this isn't necessary anymore because the tree\n\t//\t\t\tis refreshed after area merging\n\twhile(tmparea->mergedarea) tmparea = tmparea->mergedarea;\n\t//\n\tif (tmparea->invalid) Error(\"AAS_StoreArea: tried to store invalid area\");\n\t//if there is an aas area already stored for this tmp area\n\tif (tmparea->aasareanum) return -tmparea->aasareanum;\n\t//\n\tif (aasworld.numareas >= max_aas.max_areas)\n\t{\n\t\tError(\"AAS_MAX_AREAS = %d\", max_aas.max_areas);\n\t} //end if\n\t//area zero is a dummy\n\tif (aasworld.numareas == 0) aasworld.numareas = 1;\n\t//create an area from this leaf\n\taasarea = &aasworld.areas[aasworld.numareas];\n\taasarea->areanum = aasworld.numareas;\n\taasarea->numfaces = 0;\n\taasarea->firstface = aasworld.faceindexsize;\n\tClearBounds(aasarea->mins, aasarea->maxs);\n\tVectorClear(aasarea->center);\n\t//\n//\tLog_Write(\"tmparea %d became aasarea %d\\r\\n\", tmparea->areanum, aasarea->areanum);\n\t//store the aas area number at the tmp area\n\ttmparea->aasareanum = aasarea->areanum;\n\t//\n\tfor (tmpface = tmparea->tmpfaces; tmpface; tmpface = tmpface->next[side])\n\t{\n\t\tside = tmpface->frontarea != tmparea;\n\t\t//if there's an aas face created for the tmp face already\n\t\tif (tmpface->aasfacenum)\n\t\t{\n\t\t\t//we're at the back of the face so use a negative index\n\t\t\taasfacenum = -tmpface->aasfacenum;\n#ifdef DEBUG\n\t\t\tif (tmpface->aasfacenum < 0 || tmpface->aasfacenum > max_aas.max_faces)\n\t\t\t{\n\t\t\t\tError(\"AAS_CreateTree_r: face number out of range\");\n\t\t\t} //end if\n#endif //DEBUG\n\t\t\taasface = &aasworld.faces[tmpface->aasfacenum];\n\t\t\taasface->backarea = aasarea->areanum;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tplane = &mapplanes[tmpface->planenum ^ side];\n\t\t\tif (side)\n\t\t\t{\n\t\t\t\tw = tmpface->winding;\n\t\t\t\ttmpface->winding = ReverseWinding(tmpface->winding);\n\t\t\t} //end if\n\t\t\tif (!AAS_GetFace(tmpface->winding, plane, 0, &aasfacenum)) continue;\n\t\t\tif (side)\n\t\t\t{\n\t\t\t\tFreeWinding(tmpface->winding);\n\t\t\t\ttmpface->winding = w;\n\t\t\t} //end if\n\t\t\taasface = &aasworld.faces[aasfacenum];\n\t\t\taasface->frontarea = aasarea->areanum;\n\t\t\taasface->backarea = 0;\n\t\t\taasface->faceflags = tmpface->faceflags;\n\t\t\t//set the face number at the tmp face\n\t\t\ttmpface->aasfacenum = aasfacenum;\n\t\t} //end else\n\t\t//add face points to the area bounds and\n\t\t//calculate the face 'center'\n\t\tVectorClear(facecenter);\n\t\tfor (edgenum = 0; edgenum < aasface->numedges; edgenum++)\n\t\t{\n\t\t\tedge = &aasworld.edges[abs(aasworld.edgeindex[aasface->firstedge + edgenum])];\n\t\t\tfor (i = 0; i < 2; i++)\n\t\t\t{\n\t\t\t\tAddPointToBounds(aasworld.vertexes[edge->v[i]], aasarea->mins, aasarea->maxs);\n\t\t\t\tVectorAdd(aasworld.vertexes[edge->v[i]], facecenter, facecenter);\n\t\t\t} //end for\n\t\t} //end for\n\t\tVectorScale(facecenter, 1.0 / (aasface->numedges * 2.0), facecenter);\n\t\t//add the face 'center' to the area 'center'\n\t\tVectorAdd(aasarea->center, facecenter, aasarea->center);\n\t\t//\n\t\tif (aasworld.faceindexsize >= max_aas.max_faceindexsize)\n\t\t{\n\t\t\tError(\"AAS_MAX_FACEINDEXSIZE = %d\", max_aas.max_faceindexsize);\n\t\t} //end if\n\t\taasworld.faceindex[aasworld.faceindexsize++] = aasfacenum;\n\t\taasarea->numfaces++;\n\t} //end for\n\t//if the area has no faces at all (return 0, = solid leaf)\n\tif (!aasarea->numfaces) return 0;\n\t//\n\tVectorScale(aasarea->center, 1.0 / aasarea->numfaces, aasarea->center);\n\t//Log_Write(\"area %d center %f %f %f\\r\\n\", aasworld.numareas,\n\t//\t\t\t\taasarea->center[0], aasarea->center[1], aasarea->center[2]);\n\t//store the area settings\n\tAAS_StoreAreaSettings(tmparea->settings);\n\t//\n\t//Log_Write(\"tmp area %d became aas area %d\\r\\n\", tmpareanum, aasarea->areanum);\n\tqprintf(\"\\r%6d\", aasarea->areanum);\n\t//\n\taasworld.numareas++;\n\treturn -(aasworld.numareas - 1);\n} //end of the function AAS_StoreArea\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint AAS_StoreTree_r(tmp_node_t *tmpnode)\n{\n\tint aasnodenum;\n\tplane_t *plane;\n\taas_node_t *aasnode;\n\n\t//if it is a solid leaf\n\tif (!tmpnode) return 0;\n\t//negative so it's an area\n\tif (tmpnode->tmparea) return AAS_StoreArea(tmpnode->tmparea);\n\t//it's another node\n\t//the first node is a dummy\n\tif (aasworld.numnodes == 0) aasworld.numnodes = 1;\n\tif (aasworld.numnodes >= max_aas.max_nodes)\n\t{\n\t\tError(\"AAS_MAX_NODES = %d\", max_aas.max_nodes);\n\t} //end if\n\taasnodenum = aasworld.numnodes;\n\taasnode = &aasworld.nodes[aasworld.numnodes++];\n\tplane = &mapplanes[tmpnode->planenum];\n\tAAS_GetPlane(plane->normal, plane->dist, &aasnode->planenum);\n\taasnode->children[0] = AAS_StoreTree_r(tmpnode->children[0]);\n\taasnode->children[1] = AAS_StoreTree_r(tmpnode->children[1]);\n\treturn aasnodenum;\n} //end of the function AAS_StoreTree_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_StoreBoundingBoxes(void)\n{\n\tif (cfg.numbboxes > max_aas.max_bboxes)\n\t{\n\t\tError(\"more than %d bounding boxes\", max_aas.max_bboxes);\n\t} //end if\n\taasworld.numbboxes = cfg.numbboxes;\n\tmemcpy(aasworld.bboxes, cfg.bboxes, cfg.numbboxes * sizeof(aas_bbox_t));\n} //end of the function AAS_StoreBoundingBoxes\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_StoreFile(char *filename)\n{\n\tAAS_AllocMaxAAS();\n\n\tLog_Write(\"AAS_StoreFile\\r\\n\");\n\t//\n\tAAS_StoreBoundingBoxes();\n\t//\n\tqprintf(\"%6d areas stored\", 0);\n\t//start with node 1 because node zero is a dummy\n\tAAS_StoreTree_r(tmpaasworld.nodes);\n\tqprintf(\"\\n\");\n\tLog_Write(\"%6d areas stored\\r\\n\", aasworld.numareas);\n\taasworld.loaded = true;\n} //end of the function AAS_StoreFile\n"
  },
  {
    "path": "code/bspc/aas_store.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#define AAS_MAX_BBOXES\t\t\t\t\t\t5\n#define AAS_MAX_VERTEXES\t\t\t\t\t512000\n#define AAS_MAX_PLANES\t\t\t\t\t\t65536\n#define AAS_MAX_EDGES\t\t\t\t\t\t512000\n#define AAS_MAX_EDGEINDEXSIZE\t\t\t\t512000\n#define AAS_MAX_FACES\t\t\t\t\t\t512000\n#define AAS_MAX_FACEINDEXSIZE\t\t\t\t512000\n#define AAS_MAX_AREAS\t\t\t\t\t\t65536\n#define AAS_MAX_AREASETTINGS\t\t\t\t65536\n#define AAS_MAX_REACHABILITYSIZE\t\t\t65536\n#define AAS_MAX_NODES\t\t\t\t\t\t256000\n#define AAS_MAX_PORTALS\t\t\t\t\t\t65536\n#define AAS_MAX_PORTALINDEXSIZE\t\t\t\t65536\n#define AAS_MAX_CLUSTERS\t\t\t\t\t65536\n\n#define BSPCINCLUDE\n#include \"../game/be_aas.h\"\n#include \"../botlib/be_aas_def.h\"\n\n/*\ntypedef struct bspc_aas_s\n{\n\tint loaded;\n\tint initialized;\t\t\t\t\t\t\t\t//true when AAS has been initialized\n\tint savefile;\t\t\t\t\t\t\t\t\t//set true when file should be saved\n\t//bounding boxes\n\tint numbboxes;\n\taas_bbox_t *bboxes;\n\t//vertexes\n\tint numvertexes;\n\taas_vertex_t *vertexes;\n\t//planes\n\tint numplanes;\n\taas_plane_t *planes;\n\t//edges\n\tint numedges;\n\taas_edge_t *edges;\n\t//edge index\n\tint edgeindexsize;\n\taas_edgeindex_t *edgeindex;\n\t//faces\n\tint numfaces;\n\taas_face_t *faces;\n\t//face index\n\tint faceindexsize;\n\taas_faceindex_t *faceindex;\n\t//convex areas\n\tint numareas;\n\taas_area_t *areas;\n\t//convex area settings\n\tint numareasettings;\n\taas_areasettings_t *areasettings;\n\t//reachablity list\n\tint reachabilitysize;\n\taas_reachability_t *reachability;\n\t//nodes of the bsp tree\n\tint numnodes;\n\taas_node_t *nodes;\n\t//cluster portals\n\tint numportals;\n\taas_portal_t *portals;\n\t//cluster portal index\n\tint portalindexsize;\n\taas_portalindex_t *portalindex;\n\t//clusters\n\tint numclusters;\n\taas_cluster_t *clusters;\n\t//\n\tint numreachabilityareas;\n\tfloat reachabilitytime;\n} bspc_aas_t;\n\nextern bspc_aas_t aasworld;\n//*/\n\nextern aas_t aasworld;\n\n//stores the AAS file from the temporary AAS\nvoid AAS_StoreFile(char *filename);\n//returns a number of the given plane\nqboolean AAS_FindPlane(vec3_t normal, float dist, int *planenum);\n//allocates the maximum AAS memory for storage\nvoid AAS_AllocMaxAAS(void);\n//frees the maximum AAS memory for storage\nvoid AAS_FreeMaxAAS(void);\n"
  },
  {
    "path": "code/bspc/aasfile.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n\n//NOTE:\tint =\tdefault signed\n//\t\t\t\tdefault long\n\n#define AASID\t\t\t\t\t\t(('S'<<24)+('A'<<16)+('A'<<8)+'E')\n#define AASVERSION_OLD\t\t\t\t4\n#define AASVERSION\t\t\t\t\t5\n\n//presence types\n#define PRESENCE_NONE\t\t\t\t1\n#define PRESENCE_NORMAL\t\t\t\t2\n#define PRESENCE_CROUCH\t\t\t\t4\n\n//travel types\n#define MAX_TRAVELTYPES\t\t\t\t32\n#define TRAVEL_INVALID\t\t\t\t1\t\t//temporary not possible\n#define TRAVEL_WALK\t\t\t\t\t2\t\t//walking\n#define TRAVEL_CROUCH\t\t\t\t3\t\t//crouching\n#define TRAVEL_BARRIERJUMP\t\t\t4\t\t//jumping onto a barrier\n#define TRAVEL_JUMP\t\t\t\t\t5\t\t//jumping\n#define TRAVEL_LADDER\t\t\t\t6\t\t//climbing a ladder\n#define TRAVEL_WALKOFFLEDGE\t\t\t7\t\t//walking of a ledge\n#define TRAVEL_SWIM\t\t\t\t\t8\t\t//swimming\n#define TRAVEL_WATERJUMP\t\t\t9\t\t//jump out of the water\n#define TRAVEL_TELEPORT\t\t\t\t10\t\t//teleportation\n#define TRAVEL_ELEVATOR\t\t\t\t11\t\t//travel by elevator\n#define TRAVEL_ROCKETJUMP\t\t\t12\t\t//rocket jumping required for travel\n#define TRAVEL_BFGJUMP\t\t\t\t13\t\t//bfg jumping required for travel\n#define TRAVEL_GRAPPLEHOOK\t\t\t14\t\t//grappling hook required for travel\n#define TRAVEL_DOUBLEJUMP\t\t\t15\t\t//double jump\n#define TRAVEL_RAMPJUMP\t\t\t\t16\t\t//ramp jump\n#define TRAVEL_STRAFEJUMP\t\t\t17\t\t//strafe jump\n#define TRAVEL_JUMPPAD\t\t\t\t18\t\t//jump pad\n#define TRAVEL_FUNCBOB\t\t\t\t19\t\t//func bob\n\n//face flags\n#define FACE_SOLID\t\t\t\t\t1\t\t//just solid at the other side\n#define FACE_LADDER\t\t\t\t\t2\t\t//ladder\n#define FACE_GROUND\t\t\t\t\t4\t\t//standing on ground when in this face\n#define FACE_GAP\t\t\t\t\t8\t\t//gap in the ground\n#define FACE_LIQUID\t\t\t\t\t16\n#define FACE_LIQUIDSURFACE\t\t\t32\n\n//area contents\n#define AREACONTENTS_WATER\t\t\t\t1\n#define AREACONTENTS_LAVA\t\t\t\t2\n#define AREACONTENTS_SLIME\t\t\t\t4\n#define AREACONTENTS_CLUSTERPORTAL\t\t8\n#define AREACONTENTS_TELEPORTAL\t\t\t16\n#define AREACONTENTS_ROUTEPORTAL\t\t32\n#define AREACONTENTS_TELEPORTER\t\t\t64\n#define AREACONTENTS_JUMPPAD\t\t\t128\n#define AREACONTENTS_DONOTENTER\t\t\t256\n#define\tAREACONTENTS_VIEWPORTAL\t\t\t512\n\n//area flags\n#define AREA_GROUNDED\t\t\t\t1\t\t//bot can stand on the ground\n#define AREA_LADDER\t\t\t\t\t2\t\t//area contains one or more ladder faces\n#define AREA_LIQUID\t\t\t\t\t4\t\t//area contains a liquid\n\n//aas file header lumps\n#define AAS_LUMPS\t\t\t\t\t14\n#define AASLUMP_BBOXES\t\t\t\t0\n#define AASLUMP_VERTEXES\t\t\t1\n#define AASLUMP_PLANES\t\t\t\t2\n#define AASLUMP_EDGES\t\t\t\t3\n#define AASLUMP_EDGEINDEX\t\t\t4\n#define AASLUMP_FACES\t\t\t\t5\n#define AASLUMP_FACEINDEX\t\t\t6\n#define AASLUMP_AREAS\t\t\t\t7\n#define AASLUMP_AREASETTINGS\t\t8\n#define AASLUMP_REACHABILITY\t\t9\n#define AASLUMP_NODES\t\t\t\t10\n#define AASLUMP_PORTALS\t\t\t\t11\n#define AASLUMP_PORTALINDEX\t\t\t12\n#define AASLUMP_CLUSTERS\t\t\t13\n\n//========== bounding box =========\n\n//bounding box\ntypedef struct aas_bbox_s\n{\n\tint presencetype;\n\tint flags;\n\tvec3_t mins, maxs;\n} aas_bbox_t;\n\n//============ settings ===========\n\n//reachability to another area\ntypedef struct aas_reachability_s\n{\n\tint areanum;\t\t\t\t\t\t//number of the reachable area\n\tint facenum;\t\t\t\t\t\t//number of the face towards the other area\n\tint edgenum;\t\t\t\t\t\t//number of the edge towards the other area\n\tvec3_t start;\t\t\t\t\t\t//start point of inter area movement\n\tvec3_t end;\t\t\t\t\t\t\t//end point of inter area movement\n\tint traveltype;\t\t\t\t\t//type of travel required to get to the area\n\tunsigned short int traveltime;//travel time of the inter area movement\n} aas_reachability_t;\n\n//area settings\ntypedef struct aas_areasettings_s\n{\n\t//could also add all kind of statistic fields\n\tint contents;\t\t\t\t\t\t//contents of the convex area\n\tint areaflags;\t\t\t\t\t\t//several area flags\n\tint presencetype;\t\t\t\t\t//how a bot can be present in this convex area\n\tint cluster;\t\t\t\t\t\t//cluster the area belongs to, if negative it's a portal\n\tint clusterareanum;\t\t\t\t//number of the area in the cluster\n\tint numreachableareas;\t\t\t//number of reachable areas from this one\n\tint firstreachablearea;\t\t\t//first reachable area in the reachable area index\n} aas_areasettings_t;\n\n//cluster portal\ntypedef struct aas_portal_s\n{\n\tint areanum;\t\t\t\t\t\t//area that is the actual portal\n\tint frontcluster;\t\t\t\t\t//cluster at front of portal\n\tint backcluster;\t\t\t\t\t//cluster at back of portal\n\tint clusterareanum[2];\t\t\t//number of the area in the front and back cluster\n} aas_portal_t;\n\n//cluster portal index\ntypedef int aas_portalindex_t;\n\n//cluster\ntypedef struct aas_cluster_s\n{\n\tint numareas;\t\t\t\t\t\t//number of areas in the cluster\n\tint numreachabilityareas;\t\t\t//number of areas with reachabilities\n\tint numportals;\t\t\t\t\t\t//number of cluster portals\n\tint firstportal;\t\t\t\t\t//first cluster portal in the index\n} aas_cluster_t;\n\n//============ 3d definition ============\n\ntypedef vec3_t aas_vertex_t;\n\n//just a plane in the third dimension\ntypedef struct aas_plane_s\n{\n\tvec3_t normal;\t\t\t\t\t\t//normal vector of the plane\n\tfloat dist;\t\t\t\t\t\t\t//distance of the plane (normal vector * distance = point in plane)\n\tint type;\n} aas_plane_t;\n\n//edge\ntypedef struct aas_edge_s\n{\n\tint v[2];\t\t\t\t\t\t\t//numbers of the vertexes of this edge\n} aas_edge_t;\n\n//edge index, negative if vertexes are reversed\ntypedef int aas_edgeindex_t;\n\n//a face bounds a convex area, often it will also seperate two convex areas\ntypedef struct aas_face_s\n{\n\tint planenum;\t\t\t\t\t\t//number of the plane this face is in\n\tint faceflags;\t\t\t\t\t\t//face flags (no use to create face settings for just this field)\n\tint numedges;\t\t\t\t\t\t//number of edges in the boundary of the face\n\tint firstedge;\t\t\t\t\t\t//first edge in the edge index\n\tint frontarea;\t\t\t\t\t\t//convex area at the front of this face\n\tint backarea;\t\t\t\t\t\t//convex area at the back of this face\n} aas_face_t;\n\n//face index, stores a negative index if backside of face\ntypedef int aas_faceindex_t;\n\n//convex area with a boundary of faces\ntypedef struct aas_area_s\n{\n\tint areanum;\t\t\t\t\t\t//number of this area\n\t//3d definition\n\tint numfaces;\t\t\t\t\t\t//number of faces used for the boundary of the convex area\n\tint firstface;\t\t\t\t\t\t//first face in the face index used for the boundary of the convex area\n\tvec3_t mins;\t\t\t\t\t\t//mins of the convex area\n\tvec3_t maxs;\t\t\t\t\t\t//maxs of the convex area\n\tvec3_t center;\t\t\t\t\t\t//'center' of the convex area\n} aas_area_t;\n\n//nodes of the bsp tree\ntypedef struct aas_node_s\n{\n\tint planenum;\n\tint children[2];\t\t\t\t\t//child nodes of this node, or convex areas as leaves when negative\n\t\t\t\t\t\t\t\t\t\t//when a child is zero it's a solid leaf\n} aas_node_t;\n\n//=========== aas file ===============\n\n//header lump\ntypedef struct\n{\n\tint fileofs;\n\tint filelen;\n} aas_lump_t;\n\n//aas file header\ntypedef struct aas_header_s\n{\n\tint ident;\n\tint version;\n\tint bspchecksum;\n\t//data entries\n\taas_lump_t lumps[AAS_LUMPS];\n} aas_header_t;\n\n\n//====== additional information ======\n/*\n\n-\twhen a node child is a solid leaf the node child number is zero\n-\ttwo adjacent areas (sharing a plane at opposite sides) share a face\n\tthis face is a portal between the areas\n-\twhen an area uses a face from the faceindex with a positive index\n\tthen the face plane normal points into the area\n-\tthe face edges are stored counter clockwise using the edgeindex\n-\ttwo adjacent convex areas (sharing a face) only share One face\n\tthis is a simple result of the areas being convex\n-\tthe convex areas can't have a mixture of ground and gap faces\n\tother mixtures of faces in one area are allowed\n-\tareas with the AREACONTENTS_CLUSTERPORTAL in the settings have\n\tcluster number zero\n-\tedge zero is a dummy\n-\tface zero is a dummy\n-\tarea zero is a dummy\n-\tnode zero is a dummy\n*/\n"
  },
  {
    "path": "code/bspc/be_aas_bspc.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"../game/q_shared.h\"\n#include \"../bspc/l_log.h\"\n#include \"../bspc/l_qfiles.h\"\n#include \"../botlib/l_memory.h\"\n#include \"../botlib/l_script.h\"\n#include \"../botlib/l_precomp.h\"\n#include \"../botlib/l_struct.h\"\n#include \"../botlib/aasfile.h\"\n#include \"../game/botlib.h\"\n#include \"../game/be_aas.h\"\n#include \"../botlib/be_aas_def.h\"\n#include \"../qcommon/cm_public.h\"\n\n//#define BSPC\n\nextern botlib_import_t botimport;\nextern\tqboolean capsule_collision;\n\nbotlib_import_t botimport;\nclipHandle_t worldmodel;\n\nvoid Error (char *error, ...);\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_Error(char *fmt, ...)\n{\n\tva_list argptr;\n\tchar text[1024];\n\n\tva_start(argptr, fmt);\n\tvsprintf(text, fmt, argptr);\n\tva_end(argptr);\n\n\tError(text);\n} //end of the function AAS_Error\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint Sys_MilliSeconds(void)\n{\n\treturn clock() * 1000 / CLOCKS_PER_SEC;\n} //end of the function Sys_MilliSeconds\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_DebugLine(vec3_t start, vec3_t end, int color)\n{\n} //end of the function AAS_DebugLine\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ClearShownDebugLines(void)\n{\n} //end of the function AAS_ClearShownDebugLines\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nchar *BotImport_BSPEntityData(void)\n{\n\treturn CM_EntityString();\n} //end of the function AAS_GetEntityData\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotImport_Trace(bsp_trace_t *bsptrace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask)\n{\n\ttrace_t result;\n\n\tCM_BoxTrace(&result, start, end, mins, maxs, worldmodel, contentmask, capsule_collision);\n\n\tbsptrace->allsolid = result.allsolid;\n\tbsptrace->contents = result.contents;\n\tVectorCopy(result.endpos, bsptrace->endpos);\n\tbsptrace->ent = result.entityNum;\n\tbsptrace->fraction = result.fraction;\n\tbsptrace->exp_dist = 0;\n\tbsptrace->plane.dist = result.plane.dist;\n\tVectorCopy(result.plane.normal, bsptrace->plane.normal);\n\tbsptrace->plane.signbits = result.plane.signbits;\n\tbsptrace->plane.type = result.plane.type;\n\tbsptrace->sidenum = 0;\n\tbsptrace->startsolid = result.startsolid;\n\tbsptrace->surface.flags = result.surfaceFlags;\n} //end of the function BotImport_Trace\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BotImport_PointContents(vec3_t p)\n{\n\treturn CM_PointContents(p, worldmodel);\n} //end of the function BotImport_PointContents\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid *BotImport_GetMemory(int size)\n{\n\treturn GetMemory(size);\n} //end of the function BotImport_GetMemory\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotImport_Print(int type, char *fmt, ...)\n{\n\tva_list argptr;\n\tchar buf[1024];\n\n\tva_start(argptr, fmt);\n\tvsprintf(buf, fmt, argptr);\n\tprintf(buf);\n\tif (buf[0] != '\\r') Log_Write(buf);\n\tva_end(argptr);\n} //end of the function BotImport_Print\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BotImport_BSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t outmins, vec3_t outmaxs, vec3_t origin)\n{\n\tclipHandle_t h;\n\tvec3_t mins, maxs;\n\tfloat max;\n\tint\ti;\n\n\th = CM_InlineModel(modelnum);\n\tCM_ModelBounds(h, mins, maxs);\n\t//if the model is rotated\n\tif ((angles[0] || angles[1] || angles[2]))\n\t{\t// expand for rotation\n\n\t\tmax = RadiusFromBounds(mins, maxs);\n\t\tfor (i = 0; i < 3; i++)\n\t\t{\n\t\t\tmins[i] = (mins[i] + maxs[i]) * 0.5 - max;\n\t\t\tmaxs[i] = (mins[i] + maxs[i]) * 0.5 + max;\n\t\t} //end for\n\t} //end if\n\tif (outmins) VectorCopy(mins, outmins);\n\tif (outmaxs) VectorCopy(maxs, outmaxs);\n\tif (origin) VectorClear(origin);\n} //end of the function BotImport_BSPModelMinsMaxsOrigin\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Com_DPrintf(char *fmt, ...)\n{\n\tva_list argptr;\n\tchar buf[1024];\n\n\tva_start(argptr, fmt);\n\tvsprintf(buf, fmt, argptr);\n\tprintf(buf);\n\tif (buf[0] != '\\r') Log_Write(buf);\n\tva_end(argptr);\n} //end of the function Com_DPrintf\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint COM_Compress( char *data_p ) {\n\treturn strlen(data_p);\n}\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Com_Memset (void* dest, const int val, const size_t count) {\n\tmemset(dest, val, count);\n}\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Com_Memcpy (void* dest, const void* src, const size_t count) {\n\tmemcpy(dest, src, count);\n}\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_InitBotImport(void)\n{\n\tbotimport.BSPEntityData = BotImport_BSPEntityData;\n\tbotimport.GetMemory = BotImport_GetMemory;\n\tbotimport.FreeMemory = FreeMemory;\n\tbotimport.Trace = BotImport_Trace;\n\tbotimport.PointContents = BotImport_PointContents;\n\tbotimport.Print = BotImport_Print;\n\tbotimport.BSPModelMinsMaxsOrigin = BotImport_BSPModelMinsMaxsOrigin;\n} //end of the function AAS_InitBotImport\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_CalcReachAndClusters(struct quakefile_s *qf)\n{\n\tfloat time;\n\n\tLog_Print(\"loading collision map...\\n\");\n\t//\n\tif (!qf->pakfile[0]) strcpy(qf->pakfile, qf->filename);\n\t//load the map\n\tCM_LoadMap((char *) qf, qfalse, &aasworld.bspchecksum);\n\t//get a handle to the world model\n\tworldmodel = CM_InlineModel(0);\t\t// 0 = world, 1 + are bmodels\n\t//initialize bot import structure\n\tAAS_InitBotImport();\n\t//load the BSP entity string\n\tAAS_LoadBSPFile();\n\t//init physics settings\n\tAAS_InitSettings();\n\t//initialize AAS link heap\n\tAAS_InitAASLinkHeap();\n\t//initialize the AAS linked entities for the new map\n\tAAS_InitAASLinkedEntities();\n\t//reset all reachabilities and clusters\n\taasworld.reachabilitysize = 0;\n\taasworld.numclusters = 0;\n\t//set all view portals as cluster portals in case we re-calculate the reachabilities and clusters (with -reach)\n\tAAS_SetViewPortalsAsClusterPortals();\n\t//calculate reachabilities\n\tAAS_InitReachability();\n\ttime = 0;\n\twhile(AAS_ContinueInitReachability(time)) time++;\n\t//calculate clusters\n\tAAS_InitClustering();\n} //end of the function AAS_CalcReachAndClusters\n"
  },
  {
    "path": "code/bspc/be_aas_bspc.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\nvoid AAS_CalcReachAndClusters(struct quakefile_s *qf);\n"
  },
  {
    "path": "code/bspc/brushbsp.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n#include \"l_mem.h\"\n#include \"../botlib/aasfile.h\"\n#include \"aas_store.h\"\n#include \"aas_cfg.h\"\n\n#include <assert.h>\n\n/*\neach side has a count of the other sides it splits\n\nthe best split will be the one that minimizes the total split counts\nof all remaining sides\n\nprecalc side on plane table\n\nevaluate split side\n{\ncost = 0\nfor all sides\n\tfor all sides\n\t\tget \n\t\tif side splits side and splitside is on same child\n\t\t\tcost++;\n}\n*/\n\nint c_nodes;\nint c_nonvis;\nint c_active_brushes;\nint c_solidleafnodes;\nint c_totalsides;\nint c_brushmemory;\nint c_peak_brushmemory;\nint c_nodememory;\nint c_peak_totalbspmemory;\n\n// if a brush just barely pokes onto the other side,\n// let it slide by without chopping\n#define\tPLANESIDE_EPSILON\t0.001\n//0.1\n\n//#ifdef DEBUG\ntypedef struct cname_s\n{\n\tint value;\n\tchar *name;\n} cname_t;\n\ncname_t contentnames[] =\n{\n\t{CONTENTS_SOLID,\"CONTENTS_SOLID\"},\n\t{CONTENTS_WINDOW,\"CONTENTS_WINDOW\"},\n\t{CONTENTS_AUX,\"CONTENTS_AUX\"},\n\t{CONTENTS_LAVA,\"CONTENTS_LAVA\"},\n\t{CONTENTS_SLIME,\"CONTENTS_SLIME\"},\n\t{CONTENTS_WATER,\"CONTENTS_WATER\"},\n\t{CONTENTS_MIST,\"CONTENTS_MIST\"},\n\t{LAST_VISIBLE_CONTENTS,\"LAST_VISIBLE_CONTENTS\"},\n\n\t{CONTENTS_AREAPORTAL,\"CONTENTS_AREAPORTAL\"},\n\t{CONTENTS_PLAYERCLIP,\"CONTENTS_PLAYERCLIP\"},\n\t{CONTENTS_MONSTERCLIP,\"CONTENTS_MONSTERCLIP\"},\n\t{CONTENTS_CURRENT_0,\"CONTENTS_CURRENT_0\"},\n\t{CONTENTS_CURRENT_90,\"CONTENTS_CURRENT_90\"},\n\t{CONTENTS_CURRENT_180,\"CONTENTS_CURRENT_180\"},\n\t{CONTENTS_CURRENT_270,\"CONTENTS_CURRENT_270\"},\n\t{CONTENTS_CURRENT_UP,\"CONTENTS_CURRENT_UP\"},\n\t{CONTENTS_CURRENT_DOWN,\"CONTENTS_CURRENT_DOWN\"},\n\t{CONTENTS_ORIGIN,\"CONTENTS_ORIGIN\"},\n\t{CONTENTS_MONSTER,\"CONTENTS_MONSTER\"},\n\t{CONTENTS_DEADMONSTER,\"CONTENTS_DEADMONSTER\"},\n\t{CONTENTS_DETAIL,\"CONTENTS_DETAIL\"},\n\t{CONTENTS_Q2TRANSLUCENT,\"CONTENTS_TRANSLUCENT\"},\n\t{CONTENTS_LADDER,\"CONTENTS_LADDER\"},\n\t{0, 0}\n};\n\nvoid PrintContents(int contents)\n{\n\tint i;\n\n\tfor (i = 0; contentnames[i].value; i++)\n\t{\n\t\tif (contents & contentnames[i].value)\n\t\t{\n\t\t\tLog_Write(\"%s,\", contentnames[i].name);\n\t\t} //end if\n\t} //end for\n} //end of the function PrintContents\n\n//#endif DEBUG\n\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ResetBrushBSP(void)\n{\n\tc_nodes = 0;\n\tc_nonvis = 0;\n\tc_active_brushes = 0;\n\tc_solidleafnodes = 0;\n\tc_totalsides = 0;\n\tc_brushmemory = 0;\n\tc_peak_brushmemory = 0;\n\tc_nodememory = 0;\n\tc_peak_totalbspmemory = 0;\n} //end of the function ResetBrushBSP\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid FindBrushInTree (node_t *node, int brushnum)\n{\n\tbspbrush_t\t*b;\n\n\tif (node->planenum == PLANENUM_LEAF)\n\t{\n\t\tfor (b=node->brushlist ; b ; b=b->next)\n\t\t\tif (b->original->brushnum == brushnum)\n\t\t\t\tLog_Print (\"here\\n\");\n\t\treturn;\n\t}\n\tFindBrushInTree(node->children[0], brushnum);\n\tFindBrushInTree(node->children[1], brushnum);\n} //end of the function FindBrushInTree\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid DrawBrushList (bspbrush_t *brush, node_t *node)\n{\n\tint\t\ti;\n\tside_t\t*s;\n\n\tGLS_BeginScene ();\n\tfor ( ; brush ; brush=brush->next)\n\t{\n\t\tfor (i=0 ; i<brush->numsides ; i++)\n\t\t{\n\t\t\ts = &brush->sides[i];\n\t\t\tif (!s->winding)\n\t\t\t\tcontinue;\n\t\t\tif (s->texinfo == TEXINFO_NODE)\n\t\t\t\tGLS_Winding (s->winding, 1);\n\t\t\telse if (!(s->flags & SFL_VISIBLE))\n\t\t\t\tGLS_Winding (s->winding, 2);\n\t\t\telse\n\t\t\t\tGLS_Winding (s->winding, 0);\n\t\t}\n\t}\n\tGLS_EndScene ();\n} //end of the function DrawBrushList\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid WriteBrushList (char *name, bspbrush_t *brush, qboolean onlyvis)\n{\n\tint\t\ti;\n\tside_t\t*s;\n\tFILE\t*f;\n\n\tqprintf (\"writing %s\\n\", name);\n\tf = SafeOpenWrite (name);\n\n\tfor ( ; brush ; brush=brush->next)\n\t{\n\t\tfor (i=0 ; i<brush->numsides ; i++)\n\t\t{\n\t\t\ts = &brush->sides[i];\n\t\t\tif (!s->winding)\n\t\t\t\tcontinue;\n\t\t\tif (onlyvis && !(s->flags & SFL_VISIBLE))\n\t\t\t\tcontinue;\n\t\t\tOutputWinding (brush->sides[i].winding, f);\n\t\t}\n\t}\n\n\tfclose (f);\n} //end of the function WriteBrushList\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid PrintBrush (bspbrush_t *brush)\n{\n\tint\t\ti;\n\n\tprintf (\"brush: %p\\n\", brush);\n\tfor (i=0;i<brush->numsides ; i++)\n\t{\n\t\tpw(brush->sides[i].winding);\n\t\tprintf (\"\\n\");\n\t} //end for\n} //end of the function PrintBrush\n//===========================================================================\n// Sets the mins/maxs based on the windings\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BoundBrush (bspbrush_t *brush)\n{\n\tint\t\t\ti, j;\n\twinding_t\t*w;\n\n\tClearBounds (brush->mins, brush->maxs);\n\tfor (i=0 ; i<brush->numsides ; i++)\n\t{\n\t\tw = brush->sides[i].winding;\n\t\tif (!w)\n\t\t\tcontinue;\n\t\tfor (j=0 ; j<w->numpoints ; j++)\n\t\t\tAddPointToBounds (w->p[j], brush->mins, brush->maxs);\n\t}\n} //end of the function BoundBrush\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid CreateBrushWindings (bspbrush_t *brush)\n{\n\tint\t\t\ti, j;\n\twinding_t\t*w;\n\tside_t\t\t*side;\n\tplane_t\t\t*plane;\n\n\tfor (i=0 ; i<brush->numsides ; i++)\n\t{\n\t\tside = &brush->sides[i];\n\t\tplane = &mapplanes[side->planenum];\n\t\tw = BaseWindingForPlane (plane->normal, plane->dist);\n\t\tfor (j=0 ; j<brush->numsides && w; j++)\n\t\t{\n\t\t\tif (i == j)\n\t\t\t\tcontinue;\n\t\t\tif (brush->sides[j].flags & SFL_BEVEL)\n\t\t\t\tcontinue;\n\t\t\tplane = &mapplanes[brush->sides[j].planenum^1];\n\t\t\tChopWindingInPlace (&w, plane->normal, plane->dist, 0); //CLIP_EPSILON);\n\t\t}\n\n\t\tside->winding = w;\n\t}\n\n\tBoundBrush (brush);\n} //end of the function CreateBrushWindings\n//===========================================================================\n// Creates a new axial brush\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t\t*BrushFromBounds (vec3_t mins, vec3_t maxs)\n{\n\tbspbrush_t *b;\n\tint i;\n\tvec3_t normal;\n\tvec_t dist;\n\n\tb = AllocBrush (6);\n\tb->numsides = 6;\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tVectorClear (normal);\n\t\tnormal[i] = 1;\n\t\tdist = maxs[i];\n\t\tb->sides[i].planenum = FindFloatPlane (normal, dist);\n\n\t\tnormal[i] = -1;\n\t\tdist = -mins[i];\n\t\tb->sides[3+i].planenum = FindFloatPlane (normal, dist);\n\t}\n\n\tCreateBrushWindings (b);\n\n\treturn b;\n} //end of the function BrushFromBounds\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BrushOutOfBounds(bspbrush_t *brush, vec3_t mins, vec3_t maxs, float epsilon)\n{\n\tint i, j, n;\n\twinding_t *w;\n\tside_t *side;\n\n\tfor (i = 0; i < brush->numsides; i++)\n\t{\n\t\tside = &brush->sides[i];\n\t\tw = side->winding;\n\t\tfor (j = 0; j < w->numpoints; j++)\n\t\t{\n\t\t\tfor (n = 0; n < 3; n++)\n\t\t\t{\n\t\t\t\tif (w->p[j][n] < (mins[n] + epsilon) || w->p[j][n] > (maxs[n] - epsilon)) return true;\n\t\t\t} //end for\n\t\t} //end for\n\t} //end for\n\treturn false;\n} //end of the function BrushOutOfBounds\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvec_t BrushVolume (bspbrush_t *brush)\n{\n\tint i;\n\twinding_t *w;\n\tvec3_t corner;\n\tvec_t d, area, volume;\n\tplane_t *plane;\n\n\tif (!brush) return 0;\n\n\t// grab the first valid point as the corner\n\tw = NULL;\n\tfor (i = 0; i < brush->numsides; i++)\n\t{\n\t\tw = brush->sides[i].winding;\n\t\tif (w) break;\n\t} //end for\n\tif (!w) return 0;\n\tVectorCopy (w->p[0], corner);\n\n\t// make tetrahedrons to all other faces\n\tvolume = 0;\n\tfor ( ; i < brush->numsides; i++)\n\t{\n\t\tw = brush->sides[i].winding;\n\t\tif (!w) continue;\n\t\tplane = &mapplanes[brush->sides[i].planenum];\n\t\td = -(DotProduct (corner, plane->normal) - plane->dist);\n\t\tarea = WindingArea(w);\n\t\tvolume += d * area;\n\t} //end for\n\n\tvolume /= 3;\n\treturn volume;\n} //end of the function BrushVolume\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint CountBrushList (bspbrush_t *brushes)\n{\n\tint c;\n\n\tc = 0;\n\tfor ( ; brushes; brushes = brushes->next) c++;\n\treturn c;\n} //end of the function CountBrushList\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nnode_t *AllocNode (void)\n{\n\tnode_t\t*node;\n\n\tnode = GetMemory(sizeof(*node));\n\tmemset (node, 0, sizeof(*node));\n\tif (numthreads == 1)\n\t{\n\t\tc_nodememory += MemorySize(node);\n\t} //end if\n\treturn node;\n} //end of the function AllocNode\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *AllocBrush (int numsides)\n{\n\tbspbrush_t\t*bb;\n\tint\t\t\tc;\n\n\tc = (int)&(((bspbrush_t *)0)->sides[numsides]);\n\tbb = GetMemory(c);\n\tmemset (bb, 0, c);\n\tif (numthreads == 1)\n\t{\n\t\tc_active_brushes++;\n\t\tc_brushmemory += MemorySize(bb);\n\t\tif (c_brushmemory > c_peak_brushmemory)\n\t\t\t\tc_peak_brushmemory = c_brushmemory;\n\t} //end if\n\treturn bb;\n} //end of the function AllocBrush\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid FreeBrush (bspbrush_t *brushes)\n{\n\tint\t\t\ti;\n\n\tfor (i=0 ; i<brushes->numsides ; i++)\n\t\tif (brushes->sides[i].winding)\n\t\t\tFreeWinding(brushes->sides[i].winding);\n\tif (numthreads == 1)\n\t{\n\t\tc_active_brushes--;\n\t\tc_brushmemory -= MemorySize(brushes);\n\t\tif (c_brushmemory < 0) c_brushmemory = 0;\n\t} //end if\n\tFreeMemory(brushes);\n} //end of the function FreeBrush\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid FreeBrushList (bspbrush_t *brushes)\n{\n\tbspbrush_t\t*next;\n\n\tfor ( ; brushes; brushes = next)\n\t{\n\t\tnext = brushes->next;\n\n\t\tFreeBrush(brushes);\n\t} //end for\n} //end of the function FreeBrushList\n//===========================================================================\n// Duplicates the brush, the sides, and the windings\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *CopyBrush (bspbrush_t *brush)\n{\n\tbspbrush_t *newbrush;\n\tint\t\t\tsize;\n\tint\t\t\ti;\n\t\n\tsize = (int)&(((bspbrush_t *)0)->sides[brush->numsides]);\n\n\tnewbrush = AllocBrush (brush->numsides);\n\tmemcpy (newbrush, brush, size);\n\n\tfor (i=0 ; i<brush->numsides ; i++)\n\t{\n\t\tif (brush->sides[i].winding)\n\t\t\tnewbrush->sides[i].winding = CopyWinding (brush->sides[i].winding);\n\t}\n\n\treturn newbrush;\n} //end of the function CopyBrush\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nnode_t *PointInLeaf (node_t *node, vec3_t point)\n{\n\tvec_t\t\td;\n\tplane_t\t\t*plane;\n\n\twhile (node->planenum != PLANENUM_LEAF)\n\t{\n\t\tplane = &mapplanes[node->planenum];\n\t\td = DotProduct (point, plane->normal) - plane->dist;\n\t\tif (d > 0)\n\t\t\tnode = node->children[0];\n\t\telse\n\t\t\tnode = node->children[1];\n\t}\n\n\treturn node;\n} //end of the function PointInLeaf\n//===========================================================================\n// Returns PSIDE_FRONT, PSIDE_BACK, or PSIDE_BOTH\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#if 0\nint BoxOnPlaneSide (vec3_t mins, vec3_t maxs, plane_t *plane)\n{\n\tint\t\tside;\n\tint\t\ti;\n\tvec3_t\tcorners[2];\n\tvec_t\tdist1, dist2;\n\n\t// axial planes are easy\n\tif (plane->type < 3)\n\t{\n\t\tside = 0;\n\t\tif (maxs[plane->type] > plane->dist+PLANESIDE_EPSILON)\n\t\t\tside |= PSIDE_FRONT;\n\t\tif (mins[plane->type] < plane->dist-PLANESIDE_EPSILON)\n\t\t\tside |= PSIDE_BACK;\n\t\treturn side;\n\t}\n\n\t// create the proper leading and trailing verts for the box\n\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tif (plane->normal[i] < 0)\n\t\t{\n\t\t\tcorners[0][i] = mins[i];\n\t\t\tcorners[1][i] = maxs[i];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcorners[1][i] = mins[i];\n\t\t\tcorners[0][i] = maxs[i];\n\t\t}\n\t}\n\n\tdist1 = DotProduct (plane->normal, corners[0]) - plane->dist;\n\tdist2 = DotProduct (plane->normal, corners[1]) - plane->dist;\n\tside = 0;\n\tif (dist1 >= PLANESIDE_EPSILON)\n\t\tside = PSIDE_FRONT;\n\tif (dist2 < PLANESIDE_EPSILON)\n\t\tside |= PSIDE_BACK;\n\n\treturn side;\n}\n#else\nint BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, plane_t *p)\n{\n\tfloat\tdist1, dist2;\n\tint sides;\n\n\t// axial planes are easy\n\tif (p->type < 3)\n\t{\n\t\tsides = 0;\n\t\tif (emaxs[p->type] > p->dist+PLANESIDE_EPSILON) sides |= PSIDE_FRONT;\n\t\tif (emins[p->type] < p->dist-PLANESIDE_EPSILON) sides |= PSIDE_BACK;\n\t\treturn sides;\n\t} //end if\n\t\n// general case\n\tswitch (p->signbits)\n\t{\n\tcase 0:\n\t\tdist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];\n\t\tdist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];\n\t\tbreak;\n\tcase 1:\n\t\tdist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];\n\t\tdist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];\n\t\tbreak;\n\tcase 2:\n\t\tdist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];\n\t\tdist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];\n\t\tbreak;\n\tcase 3:\n\t\tdist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];\n\t\tdist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];\n\t\tbreak;\n\tcase 4:\n\t\tdist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];\n\t\tdist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];\n\t\tbreak;\n\tcase 5:\n\t\tdist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];\n\t\tdist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];\n\t\tbreak;\n\tcase 6:\n\t\tdist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];\n\t\tdist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];\n\t\tbreak;\n\tcase 7:\n\t\tdist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];\n\t\tdist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];\n\t\tbreak;\n\tdefault:\n\t\tdist1 = dist2 = 0;\t\t// shut up compiler\n//\t\tassert( 0 );\n\t\tbreak;\n\t}\n\n\tsides = 0;\n\tif (dist1 - p->dist >= PLANESIDE_EPSILON) sides = PSIDE_FRONT;\n\tif (dist2 - p->dist < PLANESIDE_EPSILON) sides |= PSIDE_BACK;\n\n//\tassert(sides != 0);\n\n\treturn sides;\n}\n#endif\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint QuickTestBrushToPlanenum (bspbrush_t *brush, int planenum, int *numsplits)\n{\n\tint i, num;\n\tplane_t *plane;\n\tint s;\n\n\t*numsplits = 0;\n\n\tplane = &mapplanes[planenum];\n\n#ifdef ME\n\t//fast axial cases\n\tif (plane->type < 3)\n\t{\n\t\tif (plane->dist + PLANESIDE_EPSILON < brush->mins[plane->type])\n\t\t\treturn PSIDE_FRONT;\n\t\tif (plane->dist - PLANESIDE_EPSILON > brush->maxs[plane->type])\n\t\t\treturn PSIDE_BACK;\n\t} //end if\n#endif //ME*/\n\n\t// if the brush actually uses the planenum,\n\t// we can tell the side for sure\n\tfor (i = 0; i < brush->numsides; i++)\n\t{\n\t\tnum = brush->sides[i].planenum;\n\t\tif (num >= MAX_MAPFILE_PLANES)\n\t\t\tError (\"bad planenum\");\n\t\tif (num == planenum)\n\t\t\treturn PSIDE_BACK|PSIDE_FACING;\n\t\tif (num == (planenum ^ 1) )\n\t\t\treturn PSIDE_FRONT|PSIDE_FACING;\n\n\t}\n\n\t// box on plane side\n\ts = BoxOnPlaneSide (brush->mins, brush->maxs, plane);\n\n\t// if both sides, count the visible faces split\n\tif (s == PSIDE_BOTH)\n\t{\n\t\t*numsplits += 3;\n\t}\n\n\treturn s;\n} //end of the function QuickTestBrushToPlanenum\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TestBrushToPlanenum (bspbrush_t *brush, int planenum,\n\t\t\t\t\t\t int *numsplits, qboolean *hintsplit, int *epsilonbrush)\n{\n\tint i, j, num;\n\tplane_t *plane;\n\tint s = 0;\n\twinding_t *w;\n\tvec_t d, d_front, d_back;\n\tint front, back;\n\tint type;\n\tfloat dist;\n\n\t*numsplits = 0;\n\t*hintsplit = false;\n\n\tplane = &mapplanes[planenum];\n\n#ifdef ME\n\t//fast axial cases\n\ttype = plane->type;\n\tif (type < 3)\n\t{\n\t\tdist = plane->dist;\n\t\tif (dist + PLANESIDE_EPSILON < brush->mins[type]) return PSIDE_FRONT;\n\t\tif (dist - PLANESIDE_EPSILON > brush->maxs[type]) return PSIDE_BACK;\n\t\tif (brush->mins[type] < dist - PLANESIDE_EPSILON &&\n\t\t\t\t\tbrush->maxs[type] > dist + PLANESIDE_EPSILON) s = PSIDE_BOTH;\n\t} //end if\n\n\tif (s != PSIDE_BOTH)\n#endif //ME\n\t{\n\t\t// if the brush actually uses the planenum,\n\t\t// we can tell the side for sure\n\t\tfor (i = 0; i < brush->numsides; i++)\n\t\t{\n\t\t\tnum = brush->sides[i].planenum;\n\t\t\tif (num >= MAX_MAPFILE_PLANES) Error (\"bad planenum\");\n\t\t\tif (num == planenum)\n\t\t\t{\n\t\t\t\t//we don't need to test this side plane again\n\t\t\t\tbrush->sides[i].flags |= SFL_TESTED;\n\t\t\t\treturn PSIDE_BACK|PSIDE_FACING;\n\t\t\t} //end if\n\t\t\tif (num == (planenum ^ 1) )\n\t\t\t{\n\t\t\t\t//we don't need to test this side plane again\n\t\t\t\tbrush->sides[i].flags |= SFL_TESTED;\n\t\t\t\treturn PSIDE_FRONT|PSIDE_FACING;\n\t\t\t} //end if\n\t\t} //end for\n\n\t\t// box on plane side\n\t\ts = BoxOnPlaneSide (brush->mins, brush->maxs, plane);\n\n\t\tif (s != PSIDE_BOTH) return s;\n\t} //end if\n\n\t// if both sides, count the visible faces split\n\td_front = d_back = 0;\n\n\tfor (i = 0; i < brush->numsides; i++)\n\t{\n\t\tif (brush->sides[i].texinfo == TEXINFO_NODE)\n\t\t\tcontinue;\t\t// on node, don't worry about splits\n\t\tif (!(brush->sides[i].flags & SFL_VISIBLE))\n\t\t\tcontinue;\t\t// we don't care about non-visible\n\t\tw = brush->sides[i].winding;\n\t\tif (!w) continue;\n\t\tfront = back = 0;\n\t\tfor (j = 0; j < w->numpoints; j++)\n\t\t{\n\t\t\td = DotProduct(w->p[j], plane->normal) - plane->dist;\n\t\t\tif (d > d_front) d_front = d;\n\t\t\tif (d < d_back) d_back = d;\n\t\t\tif (d > 0.1) // PLANESIDE_EPSILON)\n\t\t\t\tfront = 1;\n\t\t\tif (d < -0.1) // PLANESIDE_EPSILON)\n\t\t\t\tback = 1;\n\t\t} //end for\n\t\tif (front && back)\n\t\t{\n\t\t\tif ( !(brush->sides[i].surf & SURF_SKIP) )\n\t\t\t{\n\t\t\t\t(*numsplits)++;\n\t\t\t\tif (brush->sides[i].surf & SURF_HINT)\n\t\t\t\t{\n\t\t\t\t\t*hintsplit = true;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n\n\tif ( (d_front > 0.0 && d_front < 1.0)\n\t\t|| (d_back < 0.0 && d_back > -1.0) )\n\t\t(*epsilonbrush)++;\n\n#if 0\n\tif (*numsplits == 0)\n\t{\t//\tdidn't really need to be split\n\t\tif (front) s = PSIDE_FRONT;\n\t\telse if (back) s = PSIDE_BACK;\n\t\telse s = 0;\n\t}\n#endif\n\n\treturn s;\n} //end of the function TestBrushToPlanenum\n//===========================================================================\n// Returns true if the winding would be crunched out of\n// existance by the vertex snapping.\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#define\tEDGE_LENGTH\t0.2\nqboolean WindingIsTiny (winding_t *w)\n{\n#if 0\n\tif (WindingArea (w) < 1)\n\t\treturn true;\n\treturn false;\n#else\n\tint\t\ti, j;\n\tvec_t\tlen;\n\tvec3_t\tdelta;\n\tint\t\tedges;\n\n\tedges = 0;\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tj = i == w->numpoints - 1 ? 0 : i+1;\n\t\tVectorSubtract (w->p[j], w->p[i], delta);\n\t\tlen = VectorLength (delta);\n\t\tif (len > EDGE_LENGTH)\n\t\t{\n\t\t\tif (++edges == 3)\n\t\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n#endif\n} //end of the function WindingIsTiny\n//===========================================================================\n// Returns true if the winding still has one of the points\n// from basewinding for plane\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean WindingIsHuge (winding_t *w)\n{\n\tint\t\ti, j;\n\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t\tif (w->p[i][j] < -BOGUS_RANGE+1 || w->p[i][j] > BOGUS_RANGE-1)\n\t\t\t\treturn true;\n\t}\n\treturn false;\n} //end of the function WindingIsHuge\n//===========================================================================\n// creates a leaf out of the given nodes with the given brushes\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid LeafNode(node_t *node, bspbrush_t *brushes)\n{\n\tbspbrush_t *b;\n\tint i;\n\n\tnode->side = NULL;\n\tnode->planenum = PLANENUM_LEAF;\n\tnode->contents = 0;\n\n\tfor (b = brushes; b; b = b->next)\n\t{\n\t\t// if the brush is solid and all of its sides are on nodes,\n\t\t// it eats everything\n\t\tif (b->original->contents & CONTENTS_SOLID)\n\t\t{\n\t\t\tfor (i=0 ; i<b->numsides ; i++)\n\t\t\t\tif (b->sides[i].texinfo != TEXINFO_NODE)\n\t\t\t\t\tbreak;\n\t\t\tif (i == b->numsides)\n\t\t\t{\n\t\t\t\tnode->contents = CONTENTS_SOLID;\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t} //end if\n\t\tnode->contents |= b->original->contents;\n\t} //end for\n\n\tif (create_aas)\n\t{\n\t\tnode->expansionbboxes = 0;\n\t\tnode->contents = 0;\n\t\tfor (b = brushes; b; b = b->next)\n\t\t{\n\t\t\tnode->expansionbboxes |= b->original->expansionbbox;\n\t\t\tnode->contents |= b->original->contents;\n\t\t\tif (b->original->modelnum)\n\t\t\t\tnode->modelnum = b->original->modelnum;\n\t\t} //end for\n\t\tif (node->contents & CONTENTS_SOLID)\n\t\t{\n\t\t\tif (node->expansionbboxes != cfg.allpresencetypes)\n\t\t\t{\n\t\t\t\tnode->contents &= ~CONTENTS_SOLID;\n\t\t\t} //end if\n\t\t} //end if\n\t} //end if\n\n\tnode->brushlist = brushes;\n} //end of the function LeafNode\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid CheckPlaneAgainstParents (int pnum, node_t *node)\n{\n\tnode_t\t*p;\n\n\tfor (p = node->parent; p; p = p->parent)\n\t{\n\t\tif (p->planenum == pnum) Error(\"Tried parent\");\n\t} //end for\n} //end of the function CheckPlaneAgainstParants\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean CheckPlaneAgainstVolume (int pnum, node_t *node)\n{\n\tbspbrush_t\t*front, *back;\n\tqboolean\tgood;\n\n\tSplitBrush (node->volume, pnum, &front, &back);\n\n\tgood = (front && back);\n\n\tif (front) FreeBrush (front);\n\tif (back) FreeBrush (back);\n\n\treturn good;\n} //end of the function CheckPlaneAgaintsVolume\n//===========================================================================\n// Using a hueristic, choses one of the sides out of the brushlist\n// to partition the brushes with.\n// Returns NULL if there are no valid planes to split with..\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nside_t *SelectSplitSide (bspbrush_t *brushes, node_t *node)\n{\n\tint\t\t\tvalue, bestvalue;\n\tbspbrush_t\t*brush, *test;\n\tside_t\t\t*side, *bestside;\n\tint\t\t\ti, pass, numpasses;\n\tint\t\t\tpnum;\n\tint\t\t\ts;\n\tint\t\t\tfront, back, both, facing, splits;\n\tint\t\t\tbsplits;\n\tint\t\t\tbestsplits;\n\tint\t\t\tepsilonbrush;\n\tqboolean\thintsplit = false;\n\n\tbestside = NULL;\n\tbestvalue = -99999;\n\tbestsplits = 0;\n\n\t// the search order goes: visible-structural, visible-detail,\n\t// nonvisible-structural, nonvisible-detail.\n\t// If any valid plane is available in a pass, no further\n\t// passes will be tried.\n\tnumpasses = 2;\n\tfor (pass = 0; pass < numpasses; pass++)\n\t{\n\t\tfor (brush = brushes; brush; brush = brush->next)\n\t\t{\n\t\t\t// only check detail the second pass\n//\t\t\tif ( (pass & 1) && !(brush->original->contents & CONTENTS_DETAIL) )\n//\t\t\t\tcontinue;\n//\t\t\tif ( !(pass & 1) && (brush->original->contents & CONTENTS_DETAIL) )\n//\t\t\t\tcontinue;\n\t\t\tfor (i = 0; i < brush->numsides; i++)\n\t\t\t{\n\t\t\t\tside = brush->sides + i;\n//\t\t\t\tif (side->flags & SFL_BEVEL)\n//\t\t\t\t\tcontinue;\t// never use a bevel as a spliter\n\t\t\t\tif (!side->winding)\n\t\t\t\t\tcontinue;\t// nothing visible, so it can't split\n\t\t\t\tif (side->texinfo == TEXINFO_NODE)\n\t\t\t\t\tcontinue;\t// allready a node splitter\n\t\t\t\tif (side->flags & SFL_TESTED)\n\t\t\t\t\tcontinue;\t// we allready have metrics for this plane\n//\t\t\t\tif (side->surf & SURF_SKIP)\n//\t\t\t\t\tcontinue;\t// skip surfaces are never chosen\n\n//\t\t\t\tif (!(side->flags & SFL_VISIBLE) && (pass < 2))\n//\t\t\t\t\tcontinue;\t// only check visible faces on first pass\n\n\t\t\t\tif ((side->flags & SFL_CURVE) && (pass < 1))\n\t\t\t\t\tcontinue;\t// only check curves the second pass\n\n\t\t\t\tpnum = side->planenum;\n\t\t\t\tpnum &= ~1;\t// allways use positive facing plane\n\n\t\t\t\tCheckPlaneAgainstParents (pnum, node);\n\n\t\t\t\tif (!CheckPlaneAgainstVolume (pnum, node))\n\t\t\t\t\tcontinue;\t// would produce a tiny volume\n\n\t\t\t\tfront = 0;\n\t\t\t\tback = 0;\n\t\t\t\tboth = 0;\n\t\t\t\tfacing = 0;\n\t\t\t\tsplits = 0;\n\t\t\t\tepsilonbrush = 0;\n\n\t\t\t\t //inner loop: optimize\n\t\t\t\tfor (test = brushes; test; test = test->next)\n\t\t\t\t{\n\t\t\t\t\ts = TestBrushToPlanenum (test, pnum, &bsplits, &hintsplit, &epsilonbrush);\n\n\t\t\t\t\tsplits += bsplits;\n//\t\t\t\t\tif (bsplits && (s&PSIDE_FACING) )\n//\t\t\t\t\t\tError (\"PSIDE_FACING with splits\");\n\n\t\t\t\t\ttest->testside = s;\n\t\t\t\t\t//\n\t\t\t\t\tif (s & PSIDE_FACING) facing++;\n\t\t\t\t\tif (s & PSIDE_FRONT) front++;\n\t\t\t\t\tif (s & PSIDE_BACK) back++;\n\t\t\t\t\tif (s == PSIDE_BOTH) both++;\n\t\t\t\t} //end for\n\n\t\t\t\t// give a value estimate for using this plane\n\t\t\t\tvalue =  5*facing - 5*splits - abs(front-back);\n//\t\t\t\t\tvalue =  -5*splits;\n//\t\t\t\t\tvalue =  5*facing - 5*splits;\n\t\t\t\tif (mapplanes[pnum].type < 3)\n\t\t\t\t\tvalue+=5;\t\t// axial is better\n\n\t\t\t\tvalue -= epsilonbrush * 1000;\t// avoid!\n\n\t\t\t\t// never split a hint side except with another hint\n\t\t\t\tif (hintsplit && !(side->surf & SURF_HINT) )\n\t\t\t\t\tvalue = -9999999;\n\n\t\t\t\t// save off the side test so we don't need\n\t\t\t\t// to recalculate it when we actually seperate\n\t\t\t\t// the brushes\n\t\t\t\tif (value > bestvalue)\n\t\t\t\t{\n\t\t\t\t\tbestvalue = value;\n\t\t\t\t\tbestside = side;\n\t\t\t\t\tbestsplits = splits;\n\t\t\t\t\tfor (test = brushes; test ; test = test->next)\n\t\t\t\t\t\ttest->side = test->testside;\n\t\t\t\t} //end if\n\t\t\t} //end for\n\t\t} //end for (brush = brushes;\n\n\t\t// if we found a good plane, don't bother trying any\n\t\t// other passes\n\t\tif (bestside)\n\t\t{\n\t\t\tif (pass > 1)\n\t\t\t{\n\t\t\t\tif (numthreads == 1) c_nonvis++;\n\t\t\t}\n\t\t\tif (pass > 0) node->detail_seperator = true;\t// not needed for vis\n\t\t\tbreak;\n\t\t} //end if\n\t} //end for (pass = 0;\n\n\t//\n\t// clear all the tested flags we set\n\t//\n\tfor (brush = brushes ; brush ; brush=brush->next)\n\t{\n\t\tfor (i = 0; i < brush->numsides; i++)\n\t\t{\n\t\t\tbrush->sides[i].flags &= ~SFL_TESTED;\n\t\t} //end for\n\t} //end for\n\n\treturn bestside;\n} //end of the function SelectSplitSide\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BrushMostlyOnSide (bspbrush_t *brush, plane_t *plane)\n{\n\tint\t\t\ti, j;\n\twinding_t\t*w;\n\tvec_t\t\td, max;\n\tint\t\t\tside;\n\n\tmax = 0;\n\tside = PSIDE_FRONT;\n\tfor (i=0 ; i<brush->numsides ; i++)\n\t{\n\t\tw = brush->sides[i].winding;\n\t\tif (!w)\n\t\t\tcontinue;\n\t\tfor (j=0 ; j<w->numpoints ; j++)\n\t\t{\n\t\t\td = DotProduct (w->p[j], plane->normal) - plane->dist;\n\t\t\tif (d > max)\n\t\t\t{\n\t\t\t\tmax = d;\n\t\t\t\tside = PSIDE_FRONT;\n\t\t\t}\n\t\t\tif (-d > max)\n\t\t\t{\n\t\t\t\tmax = -d;\n\t\t\t\tside = PSIDE_BACK;\n\t\t\t}\n\t\t}\n\t}\n\treturn side;\n} //end of the function BrushMostlyOnSide\n//===========================================================================\n// Generates two new brushes, leaving the original\n// unchanged\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid SplitBrush (bspbrush_t *brush, int planenum,\n\tbspbrush_t **front, bspbrush_t **back)\n{\n\tbspbrush_t\t*b[2];\n\tint\t\t\ti, j;\n\twinding_t\t*w, *cw[2], *midwinding;\n\tplane_t\t\t*plane, *plane2;\n\tside_t\t\t*s, *cs;\n\tfloat d, d_front, d_back;\n\n\t*front = *back = NULL;\n\tplane = &mapplanes[planenum];\n\n\t// check all points\n\td_front = d_back = 0;\n\tfor (i=0 ; i<brush->numsides ; i++)\n\t{\n\t\tw = brush->sides[i].winding;\n\t\tif (!w)\n\t\t\tcontinue;\n\t\tfor (j=0 ; j<w->numpoints ; j++)\n\t\t{\n\t\t\td = DotProduct (w->p[j], plane->normal) - plane->dist;\n\t\t\tif (d > 0 && d > d_front)\n\t\t\t\td_front = d;\n\t\t\tif (d < 0 && d < d_back)\n\t\t\t\td_back = d;\n\t\t}\n\t}\n\n\tif (d_front < 0.2) // PLANESIDE_EPSILON)\n\t{\t// only on back\n\t\t*back = CopyBrush (brush);\n\t\treturn;\n\t}\n\tif (d_back > -0.2) // PLANESIDE_EPSILON)\n\t{\t// only on front\n\t\t*front = CopyBrush (brush);\n\t\treturn;\n\t}\n\n\t// create a new winding from the split plane\n\n\tw = BaseWindingForPlane (plane->normal, plane->dist);\n\tfor (i=0 ; i<brush->numsides && w ; i++)\n\t{\n\t\tplane2 = &mapplanes[brush->sides[i].planenum ^ 1];\n\t\tChopWindingInPlace (&w, plane2->normal, plane2->dist, 0); // PLANESIDE_EPSILON);\n\t}\n\n\tif (!w || WindingIsTiny(w))\n\t{\t// the brush isn't really split\n\t\tint\t\tside;\n\n\t\tside = BrushMostlyOnSide (brush, plane);\n\t\tif (side == PSIDE_FRONT)\n\t\t\t*front = CopyBrush (brush);\n\t\tif (side == PSIDE_BACK)\n\t\t\t*back = CopyBrush (brush);\n\t\t//free a possible winding\n\t\tif (w) FreeWinding(w);\n\t\treturn;\n\t}\n\n\tif (WindingIsHuge (w))\n\t{\n\t\tLog_Write(\"WARNING: huge winding\\n\");\n\t}\n\n\tmidwinding = w;\n\n\t// split it for real\n\n\tfor (i=0 ; i<2 ; i++)\n\t{\n\t\tb[i] = AllocBrush (brush->numsides+1);\n\t\tb[i]->original = brush->original;\n\t}\n\n\t// split all the current windings\n\n\tfor (i=0 ; i<brush->numsides ; i++)\n\t{\n\t\ts = &brush->sides[i];\n\t\tw = s->winding;\n\t\tif (!w)\n\t\t\tcontinue;\n\t\tClipWindingEpsilon (w, plane->normal, plane->dist,\n\t\t\t0 /*PLANESIDE_EPSILON*/, &cw[0], &cw[1]);\n\t\tfor (j=0 ; j<2 ; j++)\n\t\t{\n\t\t\tif (!cw[j])\n\t\t\t\tcontinue;\n#if 0\n\t\t\tif (WindingIsTiny (cw[j]))\n\t\t\t{\n\t\t\t\tFreeWinding (cw[j]);\n\t\t\t\tcontinue;\n\t\t\t}\n#endif\n\t\t\tcs = &b[j]->sides[b[j]->numsides];\n\t\t\tb[j]->numsides++;\n\t\t\t*cs = *s;\n//\t\t\tcs->planenum = s->planenum;\n//\t\t\tcs->texinfo = s->texinfo;\n//\t\t\tcs->original = s->original;\n\t\t\tcs->winding = cw[j];\n\t\t\tcs->flags &= ~SFL_TESTED;\n\t\t}\n\t}\n\n\n\t// see if we have valid polygons on both sides\n\n\tfor (i=0 ; i<2 ; i++)\n\t{\n\t\tBoundBrush (b[i]);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\tif (b[i]->mins[j] < -MAX_MAP_BOUNDS || b[i]->maxs[j] > MAX_MAP_BOUNDS)\n\t\t\t{\n\t\t\t\tLog_Write(\"bogus brush after clip\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (b[i]->numsides < 3 || j < 3)\n\t\t{\n\t\t\tFreeBrush (b[i]);\n\t\t\tb[i] = NULL;\n\t\t}\n\t}\n\n\tif ( !(b[0] && b[1]) )\n\t{\n\t\tif (!b[0] && !b[1])\n\t\t\tLog_Write(\"split removed brush\\r\\n\");\n\t\telse\n\t\t\tLog_Write(\"split not on both sides\\r\\n\");\n\t\tif (b[0])\n\t\t{\n\t\t\tFreeBrush (b[0]);\n\t\t\t*front = CopyBrush (brush);\n\t\t}\n\t\tif (b[1])\n\t\t{\n\t\t\tFreeBrush (b[1]);\n\t\t\t*back = CopyBrush (brush);\n\t\t}\n\t\treturn;\n\t}\n\n\t// add the midwinding to both sides\n\tfor (i=0 ; i<2 ; i++)\n\t{\n\t\tcs = &b[i]->sides[b[i]->numsides];\n\t\tb[i]->numsides++;\n\n\t\tcs->planenum = planenum^i^1;\n\t\tcs->texinfo = TEXINFO_NODE; //never use these sides as splitters\n\t\tcs->flags &= ~SFL_VISIBLE;\n\t\tcs->flags &= ~SFL_TESTED;\n\t\tif (i==0)\n\t\t\tcs->winding = CopyWinding (midwinding);\n\t\telse\n\t\t\tcs->winding = midwinding;\n\t}\n\n{\n\tvec_t\tv1;\n\tint i;\n\n\tfor (i = 0; i < 2; i++)\n\t{\n\t\tv1 = BrushVolume (b[i]);\n\t\tif (v1 < 1.0)\n\t\t{\n\t\t\tFreeBrush(b[i]);\n\t\t\tb[i] = NULL;\n\t\t\t//Log_Write(\"tiny volume after clip\");\n\t\t}\n\t}\n\tif (!b[0] && !b[1])\n\t{\n\t\tLog_Write(\"two tiny brushes\\r\\n\");\n\t} //end if\n}\n\n\t*front = b[0];\n\t*back = b[1];\n} //end of the function SplitBrush\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid SplitBrushList (bspbrush_t *brushes, \n\tnode_t *node, bspbrush_t **front, bspbrush_t **back)\n{\n\tbspbrush_t\t*brush, *newbrush, *newbrush2;\n\tside_t\t\t*side;\n\tint\t\t\tsides;\n\tint\t\t\ti;\n\n\t*front = *back = NULL;\n\n\tfor (brush = brushes; brush; brush = brush->next)\n\t{\n\t\tsides = brush->side;\n\n\t\tif (sides == PSIDE_BOTH)\n\t\t{\t// split into two brushes\n\t\t\tSplitBrush (brush, node->planenum, &newbrush, &newbrush2);\n\t\t\tif (newbrush)\n\t\t\t{\n\t\t\t\tnewbrush->next = *front;\n\t\t\t\t*front = newbrush;\n\t\t\t} //end if\n\t\t\tif (newbrush2)\n\t\t\t{\n\t\t\t\tnewbrush2->next = *back;\n\t\t\t\t*back = newbrush2;\n\t\t\t} //end if\n\t\t\tcontinue;\n\t\t} //end if\n\n\t\tnewbrush = CopyBrush (brush);\n\n\t\t// if the planenum is actualy a part of the brush\n\t\t// find the plane and flag it as used so it won't be tried\n\t\t// as a splitter again\n\t\tif (sides & PSIDE_FACING)\n\t\t{\n\t\t\tfor (i=0 ; i<newbrush->numsides ; i++)\n\t\t\t{\n\t\t\t\tside = newbrush->sides + i;\n\t\t\t\tif ( (side->planenum& ~1) == node->planenum)\n\t\t\t\t\tside->texinfo = TEXINFO_NODE;\n\t\t\t} //end for\n\t\t} //end if\n\t\tif (sides & PSIDE_FRONT)\n\t\t{\n\t\t\tnewbrush->next = *front;\n\t\t\t*front = newbrush;\n\t\t\tcontinue;\n\t\t} //end if\n\t\tif (sides & PSIDE_BACK)\n\t\t{\n\t\t\tnewbrush->next = *back;\n\t\t\t*back = newbrush;\n\t\t\tcontinue;\n\t\t} //end if\n\t} //end for\n} //end of the function SplitBrushList\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid CheckBrushLists(bspbrush_t *brushlist1, bspbrush_t *brushlist2)\n{\n\tbspbrush_t *brush1, *brush2;\n\n\tfor (brush1 = brushlist1; brush1; brush1 = brush1->next)\n\t{\n\t\tfor (brush2 = brushlist2; brush2; brush2 = brush2->next)\n\t\t{\n\t\t\tassert(brush1 != brush2);\n\t\t} //end for\n\t} //end for\n} //end of the function CheckBrushLists\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint numrecurse = 0;\n\nnode_t *BuildTree_r (node_t *node, bspbrush_t *brushes)\n{\n\tnode_t\t\t*newnode;\n\tside_t\t\t*bestside;\n\tint\t\t\ti, totalmem;\n\tbspbrush_t\t*children[2];\n\n\tqprintf(\"\\r%6d\", numrecurse);\n\tnumrecurse++;\n\n\tif (numthreads == 1)\n\t{\n\t\ttotalmem = WindingMemory() + c_nodememory + c_brushmemory;\n\t\tif (totalmem > c_peak_totalbspmemory)\n\t\t\tc_peak_totalbspmemory = totalmem;\n\t\tc_nodes++;\n\t} //endif\n\n\tif (drawflag)\n\t\tDrawBrushList(brushes, node);\n\n\t// find the best plane to use as a splitter\n\tbestside = SelectSplitSide (brushes, node);\n\tif (!bestside)\n\t{\n\t\t// leaf node\n\t\tnode->side = NULL;\n\t\tnode->planenum = -1;\n\t\tLeafNode(node, brushes);\n\t\tif (node->contents & CONTENTS_SOLID) c_solidleafnodes++;\n\t\tif (create_aas)\n\t\t{\n\t\t\t//free up memory!!!\n\t\t\tFreeBrushList(node->brushlist);\n\t\t\tnode->brushlist = NULL;\n\t\t\t//free the node volume brush\n\t\t\tif (node->volume)\n\t\t\t{\n\t\t\t\tFreeBrush(node->volume);\n\t\t\t\tnode->volume = NULL;\n\t\t\t} //end if\n\t\t} //end if\n\t\treturn node;\n\t} //end if\n\n\t// this is a splitplane node\n\tnode->side = bestside;\n\tnode->planenum = bestside->planenum & ~1;\t// always use front facing\n\n\t//split the brush list in two for both children\n\tSplitBrushList (brushes, node, &children[0], &children[1]);\n\t//free the old brush list\n\tFreeBrushList (brushes);\n\n\t// allocate children before recursing\n\tfor (i = 0; i < 2; i++)\n\t{\n\t\tnewnode = AllocNode ();\n\t\tnewnode->parent = node;\n\t\tnode->children[i] = newnode;\n\t} //end for\n\n\t//split the volume brush of the node for the children\n\tSplitBrush (node->volume, node->planenum, &node->children[0]->volume,\n\t\t&node->children[1]->volume);\n\n\tif (create_aas)\n\t{\n\t\t//free the volume brush\n\t\tif (node->volume)\n\t\t{\n\t\t\tFreeBrush(node->volume);\n\t\t\tnode->volume = NULL;\n\t\t} //end if\n\t} //end if\n\t// recursively process children\n\tfor (i = 0; i < 2; i++)\n\t{\n\t\tnode->children[i] = BuildTree_r(node->children[i], children[i]);\n\t} //end for\n\n\treturn node;\n} //end of the function BuildTree_r\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nnode_t *firstnode;\t\t//first node in the list\nnode_t *lastnode;\t\t\t//last node in the list\nint nodelistsize;\t\t\t//number of nodes in the list\nint use_nodequeue = 0;\t//use nodequeue, otherwise a node stack is used\nint numwaiting = 0;\n\nvoid (*AddNodeToList)(node_t *node);\n\n//add the node to the front of the node list\n//(effectively using a node stack)\nvoid AddNodeToStack(node_t *node)\n{\n\tThreadLock();\n\n\tnode->next = firstnode;\n\tfirstnode = node;\n\tif (!lastnode) lastnode = node;\n\tnodelistsize++;\n\n\tThreadUnlock();\n\t//\n\tThreadSemaphoreIncrease(1);\n} //end of the function AddNodeToStack\n//add the node to the end of the node list\n//(effectively using a node queue)\nvoid AddNodeToQueue(node_t *node)\n{\n\tThreadLock();\n\n\tnode->next = NULL;\n\tif (lastnode) lastnode->next = node;\n\telse firstnode = node;\n\tlastnode = node;\n\tnodelistsize++;\n\n\tThreadUnlock();\n\t//\n\tThreadSemaphoreIncrease(1);\n} //end of the function AddNodeToQueue\n//get the first node from the front of the node list\nnode_t *NextNodeFromList(void)\n{\n\tnode_t *node;\n\n\tThreadLock();\n\tnumwaiting++;\n\tif (!firstnode)\n\t{\n\t\tif (numwaiting >= GetNumThreads()) ThreadSemaphoreIncrease(GetNumThreads());\n\t} //end if\n\tThreadUnlock();\n\n\tThreadSemaphoreWait();\n\n\tThreadLock();\n\n\tnumwaiting--;\n\n\tnode = firstnode;\n\tif (firstnode)\n\t{\n\t\tfirstnode = firstnode->next;\n\t\tnodelistsize--;\n\t} //end if\n\tif (!firstnode) lastnode = NULL;\n\n\tThreadUnlock();\n\n\treturn node;\n} //end of the function NextNodeFromList\n//returns the size of the node list\nint NodeListSize(void)\n{\n\tint size;\n\n\tThreadLock();\n\tsize = nodelistsize;\n\tThreadUnlock();\n\n\treturn size;\n} //end of the function NodeListSize\n//\nvoid IncreaseNodeCounter(void)\n{\n\tThreadLock();\n\t//if (verbose) printf(\"\\r%6d\", numrecurse++);\n\tqprintf(\"\\r%6d\", numrecurse++);\n\t//qprintf(\"\\r%6d %d, %5d \", numrecurse++, GetNumThreads(), nodelistsize);\n\tThreadUnlock();\n} //end of the function IncreaseNodeCounter\n//thread function, gets nodes from the nodelist and processes them\nvoid BuildTreeThread(int threadid)\n{\n\tnode_t *newnode, *node;\n\tside_t *bestside;\n\tint i, totalmem;\n\tbspbrush_t *brushes;\n\n\tfor (node = NextNodeFromList(); node; )\n\t{\n\t\t//if the nodelist isn't empty try to add another thread\n\t\t//if (NodeListSize() > 10) AddThread(BuildTreeThread);\n\t\t//display the number of nodes processed so far\n\t\tif (numthreads == 1)\n\t\t\tIncreaseNodeCounter();\n\n\t\tbrushes = node->brushlist;\n\n\t\tif (numthreads == 1)\n\t\t{\n\t\t\ttotalmem = WindingMemory() + c_nodememory + c_brushmemory;\n\t\t\tif (totalmem > c_peak_totalbspmemory)\n\t\t\t{\n\t\t\t\tc_peak_totalbspmemory = totalmem;\n\t\t\t} //end if\n\t\t\tc_nodes++;\n\t\t} //endif\n\n\t\tif (drawflag)\n\t\t{\n\t\t\tDrawBrushList(brushes, node);\n\t\t} //end if\n\n\t\tif (cancelconversion)\n\t\t{\n\t\t\tbestside = NULL;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\t// find the best plane to use as a splitter\n\t\t\tbestside = SelectSplitSide(brushes, node);\n\t\t} //end else\n\t\t//if there's no split side left\n\t\tif (!bestside)\n\t\t{\n\t\t\t//create a leaf out of the node\n\t\t\tLeafNode(node, brushes);\n\t\t\tif (node->contents & CONTENTS_SOLID) c_solidleafnodes++;\n\t\t\tif (create_aas)\n\t\t\t{\n\t\t\t\t//free up memory!!!\n\t\t\t\tFreeBrushList(node->brushlist);\n\t\t\t\tnode->brushlist = NULL;\n\t\t\t} //end if\n\t\t\t//free the node volume brush (it is not used anymore)\n\t\t\tif (node->volume)\n\t\t\t{\n\t\t\t\tFreeBrush(node->volume);\n\t\t\t\tnode->volume = NULL;\n\t\t\t} //end if\n\t\t\tnode = NextNodeFromList();\n\t\t\tcontinue;\n\t\t} //end if\n\n\t\t// this is a splitplane node\n\t\tnode->side = bestside;\n\t\tnode->planenum = bestside->planenum & ~1;\t//always use front facing\n\n\t\t//allocate children\n\t\tfor (i = 0; i < 2; i++)\n\t\t{\n\t\t\tnewnode = AllocNode();\n\t\t\tnewnode->parent = node;\n\t\t\tnode->children[i] = newnode;\n\t\t} //end for\n\n\t\t//split the brush list in two for both children\n\t\tSplitBrushList(brushes, node, &node->children[0]->brushlist, &node->children[1]->brushlist);\n\n\t\tCheckBrushLists(node->children[0]->brushlist, node->children[1]->brushlist);\n\t\t//free the old brush list\n\t\tFreeBrushList(brushes);\n\t\tnode->brushlist = NULL;\n\n\t\t//split the volume brush of the node for the children\n\t\tSplitBrush(node->volume, node->planenum, &node->children[0]->volume,\n\t\t\t\t\t\t\t\t&node->children[1]->volume);\n\n\t\tif (!node->children[0]->volume || !node->children[1]->volume)\n\t\t{\n\t\t\tError(\"child without volume brush\");\n\t\t} //end if\n\n\t\t//free the volume brush\n\t\tif (node->volume)\n\t\t{\n\t\t\tFreeBrush(node->volume);\n\t\t\tnode->volume = NULL;\n\t\t} //end if\n\t\t//add both children to the node list\n\t\t//AddNodeToList(node->children[0]);\n\t\tAddNodeToList(node->children[1]);\n\t\tnode = node->children[0];\n\t} //end while\n\tRemoveThread(threadid);\n} //end of the function BuildTreeThread\n//===========================================================================\n// build the bsp tree using a node list\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BuildTree(tree_t *tree)\n{\n\tint i;\n\n\tfirstnode = NULL;\n\tlastnode = NULL;\n\t//use a node queue or node stack\n\tif (use_nodequeue) AddNodeToList = AddNodeToQueue;\n\telse AddNodeToList = AddNodeToStack;\n\t//setup thread locking\n\tThreadSetupLock();\n\tThreadSetupSemaphore();\n\tnumwaiting = 0;\n\t//\n\tLog_Print(\"%6d threads max\\n\", numthreads);\n\tif (use_nodequeue) Log_Print(\"breadth first bsp building\\n\");\n\telse Log_Print(\"depth first bsp building\\n\");\n\tqprintf(\"%6d splits\", 0);\n\t//add the first node to the list\n\tAddNodeToList(tree->headnode);\n\t//start the threads\n\tfor (i = 0; i < numthreads; i++)\n\t\tAddThread(BuildTreeThread);\n\t//wait for all added threads to be finished\n\tWaitForAllThreadsFinished();\n\t//shutdown the thread locking\n\tThreadShutdownLock();\n\tThreadShutdownSemaphore();\n} //end of the function BuildTree\n//===========================================================================\n// The incoming brush list will be freed before exiting\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\ntree_t *BrushBSP(bspbrush_t *brushlist, vec3_t mins, vec3_t maxs)\n{\n\tint i, c_faces, c_nonvisfaces, c_brushes;\n\tbspbrush_t *b;\n\tnode_t *node;\n\ttree_t *tree;\n\tvec_t volume;\n//\tvec3_t point;\n\n\tLog_Print(\"-------- Brush BSP ---------\\n\");\n\n\ttree = Tree_Alloc();\n\n\tc_faces = 0;\n\tc_nonvisfaces = 0;\n\tc_brushes = 0;\n\tc_totalsides = 0;\n\tfor (b = brushlist; b; b = b->next)\n\t{\n\t\tc_brushes++;\n\n\t\tvolume = BrushVolume(b);\n\t\tif (volume < microvolume)\n\t\t{\n\t\t\tLog_Print(\"WARNING: entity %i, brush %i: microbrush\\n\",\n\t\t\t\tb->original->entitynum, b->original->brushnum);\n\t\t} //end if\n\n\t\tfor (i=0 ; i<b->numsides ; i++)\n\t\t{\n\t\t\tif (b->sides[i].flags & SFL_BEVEL)\n\t\t\t\tcontinue;\n\t\t\tif (!b->sides[i].winding)\n\t\t\t\tcontinue;\n\t\t\tif (b->sides[i].texinfo == TEXINFO_NODE)\n\t\t\t\tcontinue;\n\t\t\tif (b->sides[i].flags & SFL_VISIBLE)\n\t\t\t{\n\t\t\t\tc_faces++;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tc_nonvisfaces++;\n\t\t\t\t//if (create_aas) b->sides[i].texinfo = TEXINFO_NODE;\n\t\t\t} //end if\n\t\t} //end for\n\t\tc_totalsides += b->numsides;\n\n\t\tAddPointToBounds (b->mins, tree->mins, tree->maxs);\n\t\tAddPointToBounds (b->maxs, tree->mins, tree->maxs);\n\t} //end for\n\n\tLog_Print(\"%6i brushes\\n\", c_brushes);\n\tLog_Print(\"%6i visible faces\\n\", c_faces);\n\tLog_Print(\"%6i nonvisible faces\\n\", c_nonvisfaces);\n\tLog_Print(\"%6i total sides\\n\", c_totalsides);\n\n\tc_active_brushes = c_brushes;\n\tc_nodememory = 0;\n\tc_brushmemory = 0;\n\tc_peak_brushmemory = 0;\n\n\tc_nodes = 0;\n\tc_nonvis = 0;\n\tnode = AllocNode ();\n\n\t//volume of first node (head node)\n\tnode->volume = BrushFromBounds (mins, maxs);\n\t//\n\ttree->headnode = node;\n\t//just get some statistics and the mins/maxs of the node\n\tnumrecurse = 0;\n//\tqprintf(\"%6d splits\", numrecurse);\n\n\ttree->headnode->brushlist = brushlist;\n\tBuildTree(tree);\n\n\t//build the bsp tree with the start node from the brushlist\n//\tnode = BuildTree_r(node, brushlist);\n\n\t//if the conversion is cancelled\n\tif (cancelconversion) return tree;\n\n\tqprintf(\"\\n\");\n\tLog_Write(\"%6d splits\\r\\n\", numrecurse);\n//\tLog_Print(\"%6i visible nodes\\n\", c_nodes/2 - c_nonvis);\n//\tLog_Print(\"%6i nonvis nodes\\n\", c_nonvis);\n//\tLog_Print(\"%6i leaves\\n\", (c_nodes+1)/2);\n//\tLog_Print(\"%6i solid leaf nodes\\n\", c_solidleafnodes);\n//\tLog_Print(\"%6i active brushes\\n\", c_active_brushes);\n\tif (numthreads == 1)\n\t{\n//\t\tLog_Print(\"%6i KB of node memory\\n\", c_nodememory >> 10);\n//\t\tLog_Print(\"%6i KB of brush memory\\n\", c_brushmemory >> 10);\n//\t\tLog_Print(\"%6i KB of peak brush memory\\n\", c_peak_brushmemory >> 10);\n//\t\tLog_Print(\"%6i KB of winding memory\\n\", WindingMemory() >> 10);\n//\t\tLog_Print(\"%6i KB of peak winding memory\\n\", WindingPeakMemory() >> 10);\n\t\tLog_Print(\"%6i KB of peak total bsp memory\\n\", c_peak_totalbspmemory >> 10);\n\t} //end if\n\n\t/*\n\tpoint[0] = 1485;\n\tpoint[1] = 956.125;\n\tpoint[2] = 352.125;\n\tnode = PointInLeaf(tree->headnode, point);\n\tif (node->planenum != PLANENUM_LEAF)\n\t{\n\t\tLog_Print(\"node not a leaf\\n\");\n\t} //end if\n\tLog_Print(\"at %f %f %f:\\n\", point[0], point[1], point[2]);\n\tPrintContents(node->contents);\n\tLog_Print(\"node->expansionbboxes = %d\\n\", node->expansionbboxes);\n\t//*/\n\treturn tree;\n} //end of the function BrushBSP\n\n"
  },
  {
    "path": "code/bspc/bspc.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#if defined(WIN32) || defined(_WIN32)\n#include <direct.h>\n#include <windows.h>\n#include <sys/types.h>\n#include <sys/stat.h>\n#else\n#include <unistd.h>\n#include <glob.h>\n#include <sys/stat.h>\n#include <unistd.h>\n#endif\n#include \"qbsp.h\"\n#include \"l_mem.h\"\n#include \"../botlib/aasfile.h\"\n#include \"../botlib/be_aas_cluster.h\"\n#include \"../botlib/be_aas_optimize.h\"\n#include \"aas_create.h\"\n#include \"aas_store.h\"\n#include \"aas_file.h\"\n#include \"aas_cfg.h\"\n#include \"be_aas_bspc.h\"\n\nextern\tint use_nodequeue;\t\t//brushbsp.c\nextern\tint calcgrapplereach;\t//be_aas_reach.c\n\nfloat\t\t\tsubdivide_size = 240;\nchar\t\t\tsource[1024];\nchar\t\t\tname[1024];\nvec_t\t\t\tmicrovolume = 1.0;\nchar\t\t\toutbase[32];\nint\t\t\t\tentity_num;\naas_settings_t\taassettings;\n\nqboolean\tnoprune;\t\t\t//don't prune nodes (bspc.c)\nqboolean\tglview;\t\t\t\t//create a gl view\nqboolean\tnodetail;\t\t\t//don't use detail brushes (map.c)\nqboolean\tfulldetail;\t\t\t//use but don't mark detail brushes (map.c)\nqboolean\tonlyents;\t\t\t//only process the entities (bspc.c)\nqboolean\tnomerge;\t\t\t//don't merge bsp node faces (faces.c)\nqboolean\tnowater;\t\t\t//don't use the water brushes (map.c)\nqboolean\tnocsg;\t\t\t\t//don't carve intersecting brushes (bspc.c)\nqboolean\tnoweld;\t\t\t\t//use unique face vertexes (faces.c)\nqboolean\tnoshare;\t\t\t//don't share bsp edges (faces.c)\nqboolean\tnosubdiv;\t\t\t//don't subdivide bsp node faces (faces.c)\nqboolean\tnotjunc;\t\t\t//don't create tjunctions (edge melting) (faces.c)\nqboolean\toptimize;\t\t\t//enable optimisation\nqboolean\tleaktest;\t\t\t//perform a leak test\nqboolean\tverboseentities;\nqboolean\tfreetree;\t\t\t//free the bsp tree when not needed anymore\nqboolean\tcreate_aas;\t\t\t//create an .AAS file\nqboolean\tnobrushmerge;\t\t//don't merge brushes\nqboolean\tlessbrushes;\t\t//create less brushes instead of correct texture placement\nqboolean\tcancelconversion;\t//true if the conversion is being cancelled\nqboolean\tnoliquids;\t\t\t//no liquids when writing map file\nqboolean\tforcesidesvisible;\t//force all brush sides to be visible when loaded from bsp\nqboolean\tcapsule_collision = 0;\n\n/*\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ProcessWorldModel (void)\n{\n\tentity_t\t*e;\n\ttree_t *tree;\n\tqboolean\tleaked;\n\tint brush_start, brush_end;\n\n\te = &entities[entity_num];\n\n\tbrush_start = e->firstbrush;\n\tbrush_end = brush_start + e->numbrushes;\n\tleaked = false;\n\n\t//process the whole world in one time\n\ttree = ProcessWorldBrushes(brush_start, brush_end);\n\t//create the bsp tree portals\n\tMakeTreePortals(tree);\n\t//mark all leafs that can be reached by entities\n\tif (FloodEntities(tree))\n\t{\n\t\tFillOutside(tree->headnode);\n\t} //end if\n\telse\n\t{\n\t\tLog_Print(\"**** leaked ****\\n\");\n\t\tleaked = true;\n\t\tLeakFile(tree);\n\t\tif (leaktest)\n\t\t{\n\t\t\tLog_Print(\"--- MAP LEAKED ---\\n\");\n\t\t\texit(0);\n\t\t} //end if\n\t} //end else\n\n\tMarkVisibleSides (tree, brush_start, brush_end);\n\n\tFloodAreas (tree);\n\n#ifndef ME\n\tif (glview) WriteGLView(tree, source);\n#endif\n\tMakeFaces(tree->headnode);\n\tFixTjuncs(tree->headnode);\n\n\t//NOTE: Never prune the nodes because the portals\n\t//\t\tare screwed when prunning is done and as\n\t//\t\ta result portal writing will crash\n\t//if (!noprune) PruneNodes(tree->headnode);\n\n\tWriteBSP(tree->headnode);\n\n\tif (!leaked) WritePortalFile(tree);\n\n\tTree_Free(tree);\n} //end of the function ProcessWorldModel\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ProcessSubModel (void)\n{\n\tentity_t\t*e;\n\tint start, end;\n\ttree_t *tree;\n\tbspbrush_t *list;\n\tvec3_t mins, maxs;\n\n\te = &entities[entity_num];\n\n\tstart = e->firstbrush;\n\tend = start + e->numbrushes;\n\n\tmins[0] = mins[1] = mins[2] = -4096;\n\tmaxs[0] = maxs[1] = maxs[2] = 4096;\n\tlist = MakeBspBrushList(start, end, mins, maxs);\n\tif (!nocsg) list = ChopBrushes (list);\n\ttree = BrushBSP (list, mins, maxs);\n\tMakeTreePortals (tree);\n\tMarkVisibleSides (tree, start, end);\n\tMakeFaces (tree->headnode);\n\tFixTjuncs (tree->headnode);\n\tWriteBSP (tree->headnode);\n\tTree_Free(tree);\n} //end of the function ProcessSubModel\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ProcessModels (void)\n{\n\tBeginBSPFile();\n\n\tfor (entity_num = 0; entity_num < num_entities; entity_num++)\n\t{\n\t\tif (!entities[entity_num].numbrushes)\n\t\t\tcontinue;\n\n\t\tLog_Print(\"############### model %i ###############\\n\", nummodels);\n\t\tBeginModel();\n\t\tif (entity_num == 0) ProcessWorldModel();\n\t\telse ProcessSubModel();\n\t\tEndModel();\n\n\t\tif (!verboseentities)\n\t\t\tverbose = false;\t// don't bother printing submodels\n\t} //end for\n\tEndBSPFile();\n} //end of the function ProcessModels\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Win_Map2Bsp(char *bspfilename)\n{\n\tdouble start, end;\n\tchar path[1024];\n\n\tstart = I_FloatTime();\n\n\tThreadSetDefault();\n\t//yeah sure Carmack\n\t//numthreads = 1;\t\t// multiple threads aren't helping...\n\n\tstrcpy(source, ExpandArg(bspfilename));\n\tStripExtension(source);\n\n\t//delete portal and line files\n\tsprintf(path, \"%s.prt\", source);\n\tremove(path);\n\tsprintf(path, \"%s.lin\", source);\n\tremove(path);\n\n\tstrcpy(name, ExpandArg(bspfilename));\t\n\tDefaultExtension(name, \".map\");\t// might be .reg\n\n\tQ2_AllocMaxBSP();\n\t//\n\tSetModelNumbers();\n\tSetLightStyles();\n\tProcessModels();\n\t//write the BSP\n\tQ2_WriteBSPFile(bspfilename);\n\n\tQ2_FreeMaxBSP();\n\n\tend = I_FloatTime();\n\tLog_Print(\"%5.0f seconds elapsed\\n\", end-start);\n} //end of the function Win_Map2Bsp\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Map2Bsp(char *mapfilename, char *outputfilename)\n{\n\tdouble start, end;\n\tchar path[1024];\n\n\tstart = I_FloatTime ();\n\n\tThreadSetDefault ();\n\t//yeah sure Carmack\n\t//numthreads = 1;\t\t//multiple threads aren't helping...\n\t//SetQdirFromPath(bspfilename);\n\n\tstrcpy(source, ExpandArg(mapfilename));\n\tStripExtension(source);\n\n\t// delete portal and line files\n\tsprintf(path, \"%s.prt\", source);\n\tremove(path);\n\tsprintf(path, \"%s.lin\", source);\n\tremove(path);\n\n\tstrcpy(name, ExpandArg(mapfilename));\n\tDefaultExtension(name, \".map\");\t// might be .reg\n\n\t//\n\t// if onlyents, just grab the entites and resave\n\t//\n\tif (onlyents)\n\t{\n\t\tchar out[1024];\n\n\t\tQ2_AllocMaxBSP();\n\t\tsprintf (out, \"%s.bsp\", source);\n\t\tQ2_LoadBSPFile(out, 0, 0);\n\t\tnum_entities = 0;\n\n\t\tQ2_LoadMapFile(name);\n\t\tSetModelNumbers();\n\t\tSetLightStyles();\n\n\t\tQ2_UnparseEntities();\n\n\t\tQ2_WriteBSPFile(out);\n\t\t//\n\t\tQ2_FreeMaxBSP();\n\t} //end if\n\telse\n\t{\n\t\t//\n\t\t// start from scratch\n\t\t//\n\t\tQ2_AllocMaxBSP();\n\t\t//load the map\n\t\tQ2_LoadMapFile(name);\n\t\t//create the .bsp file\n\t\tSetModelNumbers();\n\t\tSetLightStyles();\n\t\tProcessModels();\n\t\t//write the BSP\n\t\tQ2_WriteBSPFile(outputfilename);\n\t\t//\n\t\tQ2_FreeMaxBSP();\n\t} //end else\n\n\tend = I_FloatTime();\n\tLog_Print(\"%5.0f seconds elapsed\\n\", end-start);\n} //end of the function Map2Bsp\n*/\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AASOuputFile(quakefile_t *qf, char *outputpath, char *filename)\n{\n\tchar ext[MAX_PATH];\n\n\t//\n\tif (strlen(outputpath))\n\t{\n\t\tstrcpy(filename, outputpath);\n\t\t//append the bsp file base\n\t\tAppendPathSeperator(filename, MAX_PATH);\n\t\tExtractFileBase(qf->origname, &filename[strlen(filename)]);\n\t\t//append .aas\n\t\tstrcat(filename, \".aas\");\n\t\treturn;\n\t} //end if\n\t//\n\tExtractFileExtension(qf->filename, ext);\n\tif (!stricmp(ext, \"pk3\") || !stricmp(ext, \"pak\") || !stricmp(ext, \"sin\"))\n\t{\n\t\tstrcpy(filename, qf->filename);\n\t\twhile(strlen(filename) &&\n\t\t\t\tfilename[strlen(filename)-1] != '\\\\' &&\n\t\t\t\tfilename[strlen(filename)-1] != '/')\n\t\t{\n\t\t\tfilename[strlen(filename)-1] = '\\0';\n\t\t} //end while\n\t\tstrcat(filename, \"maps\");\n\t\tif (access(filename, 0x04)) CreatePath(filename);\n\t\t//append the bsp file base\n\t\tAppendPathSeperator(filename, MAX_PATH);\n\t\tExtractFileBase(qf->origname, &filename[strlen(filename)]);\n\t\t//append .aas\n\t\tstrcat(filename, \".aas\");\n\t} //end if\n\telse\n\t{\n\t\tstrcpy(filename, qf->filename);\n\t\twhile(strlen(filename) &&\n\t\t\t\tfilename[strlen(filename)-1] != '.')\n\t\t{\n\t\t\tfilename[strlen(filename)-1] = '\\0';\n\t\t} //end while\n\t\tstrcat(filename, \"aas\");\n\t} //end else\n} //end of the function AASOutputFile\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid CreateAASFilesForAllBSPFiles(char *quakepath)\n{\n#if defined(WIN32)|defined(_WIN32)\n\tWIN32_FIND_DATA filedata;\n\tHWND handle;\n\tstruct _stat statbuf;\n#else\n\tglob_t globbuf;\n\tstruct stat statbuf;\n\tint j;\n#endif\n\tint done;\n\tchar filter[_MAX_PATH], bspfilter[_MAX_PATH], aasfilter[_MAX_PATH];\n\tchar aasfile[_MAX_PATH], buf[_MAX_PATH], foldername[_MAX_PATH];\n\tquakefile_t *qf, *qf2, *files, *bspfiles, *aasfiles;\n\n\tstrcpy(filter, quakepath);\n\tAppendPathSeperator(filter, sizeof(filter));\n\tstrcat(filter, \"*\");\n\n#if defined(WIN32)|defined(_WIN32)\n\thandle = FindFirstFile(filter, &filedata);\n\tdone = (handle == INVALID_HANDLE_VALUE);\n\twhile(!done)\n\t{\n\t\t_splitpath(filter, foldername, NULL, NULL, NULL);\n\t\t_splitpath(filter, NULL, &foldername[strlen(foldername)], NULL, NULL);\n\t\tAppendPathSeperator(foldername, _MAX_PATH);\n\t\tstrcat(foldername, filedata.cFileName);\n\t\t_stat(foldername, &statbuf);\n#else\n\tglob(filter, 0, NULL, &globbuf);\n\tfor (j = 0; j < globbuf.gl_pathc; j++)\n\t{\n\t\tstrcpy(foldername, globbuf.gl_pathv[j]);\n\t\tstat(foldername, &statbuf);\n#endif\n\t\t//if it is a folder\n\t\tif (statbuf.st_mode & S_IFDIR)\n\t\t{\n\t\t\t//\n\t\t\tAppendPathSeperator(foldername, sizeof(foldername));\n\t\t\t//get all the bsp files\n\t\t\tstrcpy(bspfilter, foldername);\n\t\t\tstrcat(bspfilter, \"maps/*.bsp\");\n\t\t\tfiles = FindQuakeFiles(bspfilter);\n\t\t\tstrcpy(bspfilter, foldername);\n\t\t\tstrcat(bspfilter, \"*.pk3/maps/*.bsp\");\n\t\t\tbspfiles = FindQuakeFiles(bspfilter);\n\t\t\tfor (qf = bspfiles; qf; qf = qf->next) if (!qf->next) break;\n\t\t\tif (qf) qf->next = files;\n\t\t\telse bspfiles = files;\n\t\t\t//get all the aas files\n\t\t\tstrcpy(aasfilter, foldername);\n\t\t\tstrcat(aasfilter, \"maps/*.aas\");\n\t\t\tfiles = FindQuakeFiles(aasfilter);\n\t\t\tstrcpy(aasfilter, foldername);\n\t\t\tstrcat(aasfilter, \"*.pk3/maps/*.aas\");\n\t\t\taasfiles = FindQuakeFiles(aasfilter);\n\t\t\tfor (qf = aasfiles; qf; qf = qf->next) if (!qf->next) break;\n\t\t\tif (qf) qf->next = files;\n\t\t\telse aasfiles = files;\n\t\t\t//\n\t\t\tfor (qf = bspfiles; qf; qf = qf->next)\n\t\t\t{\n\t\t\t\tsprintf(aasfile, \"%s/%s\", qf->pakfile, qf->origname);\n\t\t\t\tLog_Print(\"found %s\\n\", aasfile);\n\t\t\t\tstrcpy(&aasfile[strlen(aasfile)-strlen(\".bsp\")], \".aas\");\n\t\t\t\tfor (qf2 = aasfiles; qf2; qf2 = qf2->next)\n\t\t\t\t{\n\t\t\t\t\tsprintf(buf, \"%s/%s\", qf2->pakfile, qf2->origname);\n\t\t\t\t\tif (!stricmp(aasfile, buf))\n\t\t\t\t\t{\n\t\t\t\t\t\tLog_Print(\"found %s\\n\", buf);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end for\n\t\t\t} //end for\n\t\t} //end if\n#if defined(WIN32)|defined(_WIN32)\n\t\t//find the next file\n\t\tdone = !FindNextFile(handle, &filedata);\n\t} //end while\n#else\n\t} //end for\n\tglobfree(&globbuf);\n#endif\n} //end of the function CreateAASFilesForAllBSPFiles\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nquakefile_t *GetArgumentFiles(int argc, char *argv[], int *i, char *ext)\n{\n\tquakefile_t *qfiles, *lastqf, *qf;\n\tint j;\n\tchar buf[1024];\n\n\tqfiles = NULL;\n\tlastqf = NULL;\n\tfor (; (*i)+1 < argc && argv[(*i)+1][0] != '-'; (*i)++)\n\t{\n\t\tstrcpy(buf, argv[(*i)+1]);\n\t\tfor (j = strlen(buf)-1; j >= strlen(buf)-4; j--)\n\t\t\tif (buf[j] == '.') break;\n\t\tif (j >= strlen(buf)-4)\n\t\t\tstrcpy(&buf[j+1], ext);\n\t\tqf = FindQuakeFiles(buf);\n\t\tif (!qf) continue;\n\t\tif (lastqf) lastqf->next = qf;\n\t\telse qfiles = qf;\n\t\tlastqf = qf;\n\t\twhile(lastqf->next) lastqf = lastqf->next;\n\t} //end for\n\treturn qfiles;\n} //end of the function GetArgumentFiles\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n\n#define COMP_BSP2MAP\t\t1\n#define COMP_BSP2AAS\t\t2\n#define COMP_REACH\t\t\t3\n#define COMP_CLUSTER\t\t4\n#define COMP_AASOPTIMIZE\t5\n#define COMP_AASINFO\t\t6\n\nint main (int argc, char **argv)\n{\n\tint i, comp = 0;\n\tchar outputpath[MAX_PATH] = \"\";\n\tchar filename[MAX_PATH] = \"unknown\";\n\tquakefile_t *qfiles, *qf;\n\tdouble start_time;\n\n\tmyargc = argc;\n\tmyargv = argv;\n\n\tstart_time = I_FloatTime();\n\n\tLog_Open(\"bspc.log\");\t\t//open a log file\n\tLog_Print(\"BSPC version \"BSPC_VERSION\", %s %s\\n\", __DATE__, __TIME__);\n\n\tDefaultCfg();\n\tfor (i = 1; i < argc; i++)\n\t{\n\t\tif (!stricmp(argv[i],\"-threads\"))\n\t\t{\n\t\t\tif (i + 1 >= argc) {i = 0; break;}\n\t\t\tnumthreads = atoi(argv[++i]);\n\t\t\tLog_Print(\"threads = %d\\n\", numthreads);\n\t\t} //end if\n\t\telse if (!stricmp(argv[i], \"-noverbose\"))\n\t\t{\n\t\t\tLog_Print(\"verbose = false\\n\");\n\t\t\tverbose = false;\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-nocsg\"))\n\t\t{\n\t\t\tLog_Print(\"nocsg = true\\n\");\n\t\t\tnocsg = true;\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-optimize\"))\n\t\t{\n\t\t\tLog_Print(\"optimize = true\\n\");\n\t\t\toptimize = true;\n\t\t} //end else if\n\t\t/*\n\t\telse if (!stricmp(argv[i],\"-glview\"))\n\t\t{\n\t\t\tglview = true;\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-draw\"))\n\t\t{\n\t\t\tLog_Print(\"drawflag = true\\n\");\n\t\t\tdrawflag = true;\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-noweld\"))\n\t\t{\n\t\t\tLog_Print(\"noweld = true\\n\");\n\t\t\tnoweld = true;\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-noshare\"))\n\t\t{\n\t\t\tLog_Print(\"noshare = true\\n\");\n\t\t\tnoshare = true;\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-notjunc\"))\n\t\t{\n\t\t\tLog_Print(\"notjunc = true\\n\");\n\t\t\tnotjunc = true;\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-nowater\"))\n\t\t{\n\t\t\tLog_Print(\"nowater = true\\n\");\n\t\t\tnowater = true;\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-noprune\"))\n\t\t{\n\t\t\tLog_Print(\"noprune = true\\n\");\n\t\t\tnoprune = true;\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-nomerge\"))\n\t\t{\n\t\t\tLog_Print(\"nomerge = true\\n\");\n\t\t\tnomerge = true;\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-nosubdiv\"))\n\t\t{\n\t\t\tLog_Print(\"nosubdiv = true\\n\");\n\t\t\tnosubdiv = true;\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-nodetail\"))\n\t\t{\n\t\t\tLog_Print(\"nodetail = true\\n\");\n\t\t\tnodetail = true;\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-fulldetail\"))\n\t\t{\n\t\t\tLog_Print(\"fulldetail = true\\n\");\n\t\t\tfulldetail = true;\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-onlyents\"))\n\t\t{\n\t\t\tLog_Print(\"onlyents = true\\n\");\n\t\t\tonlyents = true;\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-micro\"))\n\t\t{\n\t\t\tif (i + 1 >= argc) {i = 0; break;}\n\t\t\tmicrovolume = atof(argv[++i]);\n\t\t\tLog_Print(\"microvolume = %f\\n\", microvolume);\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-leaktest\"))\n\t\t{\n\t\t\tLog_Print(\"leaktest = true\\n\");\n\t\t\tleaktest = true;\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-verboseentities\"))\n\t\t{\n\t\t\tLog_Print(\"verboseentities = true\\n\");\n\t\t\tverboseentities = true;\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-chop\"))\n\t\t{\n\t\t\tif (i + 1 >= argc) {i = 0; break;}\n\t\t\tsubdivide_size = atof(argv[++i]);\n\t\t\tLog_Print(\"subdivide_size = %f\\n\", subdivide_size);\n\t\t} //end else if\n\t\telse if (!stricmp (argv[i], \"-tmpout\"))\n\t\t{\n\t\t\tstrcpy (outbase, \"/tmp\");\n\t\t\tLog_Print(\"temp output\\n\");\n\t\t} //end else if\n\t\t*/\n#ifdef ME\n\t\telse if (!stricmp(argv[i], \"-freetree\"))\n\t\t{\n\t\t\tfreetree = true;\n\t\t\tLog_Print(\"freetree = true\\n\");\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-grapplereach\"))\n\t\t{\n\t\t\tcalcgrapplereach = true;\n\t\t\tLog_Print(\"grapplereach = true\\n\");\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-nobrushmerge\"))\n\t\t{\n\t\t\tnobrushmerge = true;\n\t\t\tLog_Print(\"nobrushmerge = true\\n\");\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-noliquids\"))\n\t\t{\n\t\t\tnoliquids = true;\n\t\t\tLog_Print(\"noliquids = true\\n\");\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-forcesidesvisible\"))\n\t\t{\n\t\t\tforcesidesvisible = true;\n\t\t\tLog_Print(\"forcesidesvisible = true\\n\");\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-output\"))\n\t\t{\n\t\t\tif (i + 1 >= argc) {i = 0; break;}\n\t\t\tif (access(argv[i+1], 0x04)) Warning(\"the folder %s does not exist\", argv[i+1]);\n\t\t\tstrcpy(outputpath, argv[++i]);\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-breadthfirst\"))\n\t\t{\n\t\t\tuse_nodequeue = true;\n\t\t\tLog_Print(\"breadthfirst = true\\n\");\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-capsule\"))\n\t\t{\n\t\t\tcapsule_collision = true;\n\t\t\tLog_Print(\"capsule_collision = true\\n\");\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-cfg\"))\n\t\t{\n\t\t\tif (i + 1 >= argc) {i = 0; break;}\n\t\t\tif (!LoadCfgFile(argv[++i]))\n\t\t\t\texit(0);\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-bsp2map\"))\n\t\t{\n\t\t\tif (i + 1 >= argc) {i = 0; break;}\n\t\t\tcomp = COMP_BSP2MAP;\n\t\t\tqfiles = GetArgumentFiles(argc, argv, &i, \"bsp\");\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-bsp2aas\"))\n\t\t{\n\t\t\tif (i + 1 >= argc) {i = 0; break;}\n\t\t\tcomp = COMP_BSP2AAS;\n\t\t\tqfiles = GetArgumentFiles(argc, argv, &i, \"bsp\");\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-aasall\"))\n\t\t{\n\t\t\tif (i + 1 >= argc) {i = 0; break;}\n\t\t\tCreateAASFilesForAllBSPFiles(argv[++i]);\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-reach\"))\n\t\t{\n\t\t\tif (i + 1 >= argc) {i = 0; break;}\n\t\t\tcomp = COMP_REACH;\n\t\t\tqfiles = GetArgumentFiles(argc, argv, &i, \"bsp\");\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-cluster\"))\n\t\t{\n\t\t\tif (i + 1 >= argc) {i = 0; break;}\n\t\t\tcomp = COMP_CLUSTER;\n\t\t\tqfiles = GetArgumentFiles(argc, argv, &i, \"bsp\");\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-aasinfo\"))\n\t\t{\n\t\t\tif (i + 1 >= argc) {i = 0; break;}\n\t\t\tcomp = COMP_AASINFO;\n\t\t\tqfiles = GetArgumentFiles(argc, argv, &i, \"aas\");\n\t\t} //end else if\n\t\telse if (!stricmp(argv[i], \"-aasopt\"))\n\t\t{\n\t\t\tif (i + 1 >= argc) {i = 0; break;}\n\t\t\tcomp = COMP_AASOPTIMIZE;\n\t\t\tqfiles = GetArgumentFiles(argc, argv, &i, \"aas\");\n\t\t} //end else if\n#endif //ME\n\t\telse\n\t\t{\n\t\t\tLog_Print(\"unknown parameter %s\\n\", argv[i]);\n\t\t\tbreak;\n\t\t} //end else\n\t} //end for\n\n\t//if there are parameters and there's no mismatch in one of the parameters\n\tif (argc > 1 && i == argc)\n\t{\n\t\tswitch(comp)\n\t\t{\n\t\t\tcase COMP_BSP2MAP:\n\t\t\t{\n\t\t\t\tif (!qfiles) Log_Print(\"no files found\\n\");\n\t\t\t\tfor (qf = qfiles; qf; qf = qf->next)\n\t\t\t\t{\n\t\t\t\t\t//copy the output path\n\t\t\t\t\tstrcpy(filename, outputpath);\n\t\t\t\t\t//append the bsp file base\n\t\t\t\t\tAppendPathSeperator(filename, MAX_PATH);\n\t\t\t\t\tExtractFileBase(qf->origname, &filename[strlen(filename)]);\n\t\t\t\t\t//append .map\n\t\t\t\t\tstrcat(filename, \".map\");\n\t\t\t\t\t//\n\t\t\t\t\tLog_Print(\"bsp2map: %s to %s\\n\", qf->origname, filename);\n\t\t\t\t\tif (qf->type != QFILETYPE_BSP) Warning(\"%s is probably not a BSP file\\n\", qf->origname);\n\t\t\t\t\t//\n\t\t\t\t\tLoadMapFromBSP(qf);\n\t\t\t\t\t//write the map file\n\t\t\t\t\tWriteMapFile(filename);\n\t\t\t\t} //end for\n\t\t\t\tbreak;\n\t\t\t} //end case\n\t\t\tcase COMP_BSP2AAS:\n\t\t\t{\n\t\t\t\tif (!qfiles) Log_Print(\"no files found\\n\");\n\t\t\t\tfor (qf = qfiles; qf; qf = qf->next)\n\t\t\t\t{\n\t\t\t\t\tAASOuputFile(qf, outputpath, filename);\n\t\t\t\t\t//\n\t\t\t\t\tLog_Print(\"bsp2aas: %s to %s\\n\", qf->origname, filename);\n\t\t\t\t\tif (qf->type != QFILETYPE_BSP) Warning(\"%s is probably not a BSP file\\n\", qf->origname);\n\t\t\t\t\t//set before map loading\n\t\t\t\t\tcreate_aas = 1;\n\t\t\t\t\tLoadMapFromBSP(qf);\n\t\t\t\t\t//create the AAS file\n\t\t\t\t\tAAS_Create(filename);\n\t\t\t\t\t//if it's a Quake3 map calculate the reachabilities and clusters\n\t\t\t\t\tif (loadedmaptype == MAPTYPE_QUAKE3) AAS_CalcReachAndClusters(qf);\n\t\t\t\t\t//\n\t\t\t\t\tif (optimize) AAS_Optimize();\n\t\t\t\t\t//\n\t\t\t\t\t//write out the stored AAS file\n\t\t\t\t\tif (!AAS_WriteAASFile(filename))\n\t\t\t\t\t{\n\t\t\t\t\t\tError(\"error writing %s\\n\", filename);\n\t\t\t\t\t} //end if\n\t\t\t\t\t//deallocate memory\n\t\t\t\t\tAAS_FreeMaxAAS();\n\t\t\t\t} //end for\n\t\t\t\tbreak;\n\t\t\t} //end case\n\t\t\tcase COMP_REACH:\n\t\t\t{\n\t\t\t\tif (!qfiles) Log_Print(\"no files found\\n\");\n\t\t\t\tfor (qf = qfiles; qf; qf = qf->next)\n\t\t\t\t{\n\t\t\t\t\tAASOuputFile(qf, outputpath, filename);\n\t\t\t\t\t//\n\t\t\t\t\tLog_Print(\"reach: %s to %s\\n\", qf->origname, filename);\n\t\t\t\t\tif (qf->type != QFILETYPE_BSP) Warning(\"%s is probably not a BSP file\\n\", qf->origname);\n\t\t\t\t\t//if the AAS file exists in the output directory\n\t\t\t\t\tif (!access(filename, 0x04))\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!AAS_LoadAASFile(filename, 0, 0))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tError(\"error loading aas file %s\\n\", filename);\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t//assume it's a Quake3 BSP file\n\t\t\t\t\t\tloadedmaptype = MAPTYPE_QUAKE3;\n\t\t\t\t\t} //end if\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tWarning(\"AAS file %s not found in output folder\\n\", filename);\n\t\t\t\t\t\tLog_Print(\"creating %s...\\n\", filename);\n\t\t\t\t\t\t//set before map loading\n\t\t\t\t\t\tcreate_aas = 1;\n\t\t\t\t\t\tLoadMapFromBSP(qf);\n\t\t\t\t\t\t//create the AAS file\n\t\t\t\t\t\tAAS_Create(filename);\n\t\t\t\t\t} //end else\n\t\t\t\t\t//if it's a Quake3 map calculate the reachabilities and clusters\n\t\t\t\t\tif (loadedmaptype == MAPTYPE_QUAKE3)\n\t\t\t\t\t{\n\t\t\t\t\t\tAAS_CalcReachAndClusters(qf);\n\t\t\t\t\t} //end if\n\t\t\t\t\t//\n\t\t\t\t\tif (optimize) AAS_Optimize();\n\t\t\t\t\t//write out the stored AAS file\n\t\t\t\t\tif (!AAS_WriteAASFile(filename))\n\t\t\t\t\t{\n\t\t\t\t\t\tError(\"error writing %s\\n\", filename);\n\t\t\t\t\t} //end if\n\t\t\t\t\t//deallocate memory\n\t\t\t\t\tAAS_FreeMaxAAS();\n\t\t\t\t} //end for\n\t\t\t\tbreak;\n\t\t\t} //end case\n\t\t\tcase COMP_CLUSTER:\n\t\t\t{\n\t\t\t\tif (!qfiles) Log_Print(\"no files found\\n\");\n\t\t\t\tfor (qf = qfiles; qf; qf = qf->next)\n\t\t\t\t{\n\t\t\t\t\tAASOuputFile(qf, outputpath, filename);\n\t\t\t\t\t//\n\t\t\t\t\tLog_Print(\"cluster: %s to %s\\n\", qf->origname, filename);\n\t\t\t\t\tif (qf->type != QFILETYPE_BSP) Warning(\"%s is probably not a BSP file\\n\", qf->origname);\n\t\t\t\t\t//if the AAS file exists in the output directory\n\t\t\t\t\tif (!access(filename, 0x04))\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!AAS_LoadAASFile(filename, 0, 0))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tError(\"error loading aas file %s\\n\", filename);\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t//assume it's a Quake3 BSP file\n\t\t\t\t\t\tloadedmaptype = MAPTYPE_QUAKE3;\n\t\t\t\t\t\t//if it's a Quake3 map calculate the clusters\n\t\t\t\t\t\tif (loadedmaptype == MAPTYPE_QUAKE3)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\taasworld.numclusters = 0;\n\t\t\t\t\t\t\tAAS_InitBotImport();\n\t\t\t\t\t\t\tAAS_InitClustering();\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end if\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tWarning(\"AAS file %s not found in output folder\\n\", filename);\n\t\t\t\t\t\tLog_Print(\"creating %s...\\n\", filename);\n\t\t\t\t\t\t//set before map loading\n\t\t\t\t\t\tcreate_aas = 1;\n\t\t\t\t\t\tLoadMapFromBSP(qf);\n\t\t\t\t\t\t//create the AAS file\n\t\t\t\t\t\tAAS_Create(filename);\n\t\t\t\t\t\t//if it's a Quake3 map calculate the reachabilities and clusters\n\t\t\t\t\t\tif (loadedmaptype == MAPTYPE_QUAKE3) AAS_CalcReachAndClusters(qf);\n\t\t\t\t\t} //end else\n\t\t\t\t\t//\n\t\t\t\t\tif (optimize) AAS_Optimize();\n\t\t\t\t\t//write out the stored AAS file\n\t\t\t\t\tif (!AAS_WriteAASFile(filename))\n\t\t\t\t\t{\n\t\t\t\t\t\tError(\"error writing %s\\n\", filename);\n\t\t\t\t\t} //end if\n\t\t\t\t\t//deallocate memory\n\t\t\t\t\tAAS_FreeMaxAAS();\n\t\t\t\t} //end for\n\t\t\t\tbreak;\n\t\t\t} //end case\n\t\t\tcase COMP_AASOPTIMIZE:\n\t\t\t{\n\t\t\t\tif (!qfiles) Log_Print(\"no files found\\n\");\n\t\t\t\tfor (qf = qfiles; qf; qf = qf->next)\n\t\t\t\t{\n\t\t\t\t\tAASOuputFile(qf, outputpath, filename);\n\t\t\t\t\t//\n\t\t\t\t\tLog_Print(\"optimizing: %s to %s\\n\", qf->origname, filename);\n\t\t\t\t\tif (qf->type != QFILETYPE_AAS) Warning(\"%s is probably not a AAS file\\n\", qf->origname);\n\t\t\t\t\t//\n\t\t\t\t\tAAS_InitBotImport();\n\t\t\t\t\t//\n\t\t\t\t\tif (!AAS_LoadAASFile(qf->filename, qf->offset, qf->length))\n\t\t\t\t\t{\n\t\t\t\t\t\tError(\"error loading aas file %s\\n\", qf->filename);\n\t\t\t\t\t} //end if\n\t\t\t\t\tAAS_Optimize();\n\t\t\t\t\t//write out the stored AAS file\n\t\t\t\t\tif (!AAS_WriteAASFile(filename))\n\t\t\t\t\t{\n\t\t\t\t\t\tError(\"error writing %s\\n\", filename);\n\t\t\t\t\t} //end if\n\t\t\t\t\t//deallocate memory\n\t\t\t\t\tAAS_FreeMaxAAS();\n\t\t\t\t} //end for\n\t\t\t\tbreak;\n\t\t\t} //end case\n\t\t\tcase COMP_AASINFO:\n\t\t\t{\n\t\t\t\tif (!qfiles) Log_Print(\"no files found\\n\");\n\t\t\t\tfor (qf = qfiles; qf; qf = qf->next)\n\t\t\t\t{\n\t\t\t\t\tAASOuputFile(qf, outputpath, filename);\n\t\t\t\t\t//\n\t\t\t\t\tLog_Print(\"aas info for: %s\\n\", filename);\n\t\t\t\t\tif (qf->type != QFILETYPE_AAS) Warning(\"%s is probably not a AAS file\\n\", qf->origname);\n\t\t\t\t\t//\n\t\t\t\t\tAAS_InitBotImport();\n\t\t\t\t\t//\n\t\t\t\t\tif (!AAS_LoadAASFile(qf->filename, qf->offset, qf->length))\n\t\t\t\t\t{\n\t\t\t\t\t\tError(\"error loading aas file %s\\n\", qf->filename);\n\t\t\t\t\t} //end if\n\t\t\t\t\tAAS_ShowTotals();\n\t\t\t\t} //end for\n\t\t\t} //end case\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\tLog_Print(\"don't know what to do\\n\");\n\t\t\t\tbreak;\n\t\t\t} //end default\n\t\t} //end switch\n\t} //end if\n\telse\n\t{\n\t\tLog_Print(\"Usage:   bspc [-<switch> [-<switch> ...]]\\n\"\n#if defined(WIN32) || defined(_WIN32)\n\t\t\t\"Example 1: bspc -bsp2aas d:\\\\quake3\\\\baseq3\\\\maps\\\\mymap?.bsp\\n\"\n\t\t\t\"Example 2: bspc -bsp2aas d:\\\\quake3\\\\baseq3\\\\pak0.pk3\\\\maps/q3dm*.bsp\\n\"\n#else\n\t\t\t\"Example 1: bspc -bsp2aas /quake3/baseq3/maps/mymap?.bsp\\n\"\n\t\t\t\"Example 2: bspc -bsp2aas /quake3/baseq3/pak0.pk3/maps/q3dm*.bsp\\n\"\n#endif\n\t\t\t\"\\n\"\n\t\t\t\"Switches:\\n\"\n\t\t\t//\"   bsp2map  <[pakfilter/]filter.bsp>    = convert BSP to MAP\\n\"\n\t\t\t//\"   aasall   <quake3folder>              = create AAS files for all BSPs\\n\"\n\t\t\t\"   bsp2aas  <[pakfilter/]filter.bsp>    = convert BSP to AAS\\n\"\n\t\t\t\"   reach    <filter.bsp>                = compute reachability & clusters\\n\"\n\t\t\t\"   cluster  <filter.aas>                = compute clusters\\n\"\n\t\t\t\"   aasopt   <filter.aas>                = optimize aas file\\n\"\n\t\t\t\"   aasinfo  <filter.aas>                = show AAS file info\\n\"\n\t\t\t\"   output   <output path>               = set output path\\n\"\n\t\t\t\"   threads  <X>                         = set number of threads to X\\n\"\n\t\t\t\"   cfg      <filename>                  = use this cfg file\\n\"\n\t\t\t\"   optimize                             = enable optimization\\n\"\n\t\t\t\"   noverbose                            = disable verbose output\\n\"\n\t\t\t\"   breadthfirst                         = breadth first bsp building\\n\"\n\t\t\t\"   nobrushmerge                         = don't merge brushes\\n\"\n\t\t\t\"   noliquids                            = don't write liquids to map\\n\"\n\t\t\t\"   freetree                             = free the bsp tree\\n\"\n\t\t\t\"   nocsg                                = disables brush chopping\\n\"\n\t\t\t\"   forcesidesvisible                    = force all sides to be visible\\n\"\n\t\t\t\"   grapplereach                         = calculate grapple reachabilities\\n\"\n\n/*\t\t\t\"   glview     = output a GL view\\n\"\n\t\t\t\"   draw       = enables drawing\\n\"\n\t\t\t\"   noweld     = disables weld\\n\"\n\t\t\t\"   noshare    = disables sharing\\n\"\n\t\t\t\"   notjunc    = disables juncs\\n\"\n\t\t\t\"   nowater    = disables water brushes\\n\"\n\t\t\t\"   noprune    = disables node prunes\\n\"\n\t\t\t\"   nomerge    = disables face merging\\n\"\n\t\t\t\"   nosubdiv   = disables subdeviding\\n\"\n\t\t\t\"   nodetail   = disables detail brushes\\n\"\n\t\t\t\"   fulldetail = enables full detail\\n\"\n\t\t\t\"   onlyents   = only compile entities with bsp\\n\"\n\t\t\t\"   micro <volume>\\n\"\n\t\t\t\"              = sets the micro volume to the given float\\n\"\n\t\t\t\"   leaktest   = perform a leak test\\n\"\n\t\t\t\"   verboseentities\\n\"\n\t\t\t\"              = enable entity verbose mode\\n\"\n\t\t\t\"   chop <subdivide_size>\\n\"\n\t\t\t\"              = sets the subdivide size to the given float\\n\"*/\n\t\t\t\"\\n\");\n\t} //end else\n\tLog_Print(\"BSPC run time is %5.0f seconds\\n\", I_FloatTime() - start_time);\n\tLog_Close();\t\t\t\t\t\t//close the log file\n\treturn 0;\n} //end of the function main\n\n"
  },
  {
    "path": "code/bspc/bspc.sln",
    "content": "Microsoft Visual Studio Solution File, Format Version 8.00\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"bspc\", \"bspc.vcproj\", \"{4E4EBC16-F345-4667-84E1-86633BAFDAE6}\"\n\tProjectSection(ProjectDependencies) = postProject\n\tEndProjectSection\nEndProject\nGlobal\n\tGlobalSection(SourceCodeControl) = preSolution\n\t\tSccNumberOfProjects = 1\n\t\tSccProjectUniqueName0 = bspc.vcproj\n\t\tSccProjectName0 = \\u0022$/source/code/bspc\\u0022,\\u0020IGAAAAAA\n\t\tSccLocalPath0 = .\n\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM\n\tEndGlobalSection\n\tGlobalSection(SolutionConfiguration) = preSolution\n\t\tDebug = Debug\n\t\tRelease = Release\n\tEndGlobalSection\n\tGlobalSection(ProjectConfiguration) = postSolution\n\t\t{4E4EBC16-F345-4667-84E1-86633BAFDAE6}.Debug.ActiveCfg = Debug|Win32\n\t\t{4E4EBC16-F345-4667-84E1-86633BAFDAE6}.Debug.Build.0 = Debug|Win32\n\t\t{4E4EBC16-F345-4667-84E1-86633BAFDAE6}.Release.ActiveCfg = Release|Win32\n\t\t{4E4EBC16-F345-4667-84E1-86633BAFDAE6}.Release.Build.0 = Release|Win32\n\tEndGlobalSection\n\tGlobalSection(ExtensibilityGlobals) = postSolution\n\tEndGlobalSection\n\tGlobalSection(ExtensibilityAddIns) = postSolution\n\tEndGlobalSection\nEndGlobal\n"
  },
  {
    "path": "code/bspc/bspc.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<VisualStudioProject\n\tProjectType=\"Visual C++\"\n\tVersion=\"7.10\"\n\tName=\"bspc\"\n\tSccProjectName=\"&quot;$/source/code/bspc&quot;, IGAAAAAA\"\n\tSccLocalPath=\".\">\n\t<Platforms>\n\t\t<Platform\n\t\t\tName=\"Win32\"/>\n\t</Platforms>\n\t<Configurations>\n\t\t<Configuration\n\t\t\tName=\"Debug|Win32\"\n\t\t\tOutputDirectory=\".\\Debug\"\n\t\t\tIntermediateDirectory=\".\\Debug\"\n\t\t\tConfigurationType=\"1\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_CONSOLE;BSPC\"\n\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Debug/bspc.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug/\"\n\t\t\t\tObjectFile=\".\\Debug/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Debug/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tOutputFile=\"..\\Debug\\bspc.exe\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\Debug/bspc.pdb\"\n\t\t\t\tSubSystem=\"1\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tTypeLibraryName=\".\\Debug/bspc.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Release|Win32\"\n\t\t\tOutputDirectory=\".\\Release\"\n\t\t\tIntermediateDirectory=\".\\Release\"\n\t\t\tConfigurationType=\"1\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_CONSOLE;BSPC\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"0\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release/bspc.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release/\"\n\t\t\t\tObjectFile=\".\\Release/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tOutputFile=\"..\\Release\\bspc.exe\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\Release/bspc.pdb\"\n\t\t\t\tSubSystem=\"1\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tTypeLibraryName=\".\\Release/bspc.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t</Configurations>\n\t<References>\n\t</References>\n\t<Files>\n\t\t<Filter\n\t\t\tName=\"Source Files\"\n\t\t\tFilter=\"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"_files.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"aas_areamerging.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"aas_cfg.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"aas_create.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"aas_edgemelting.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"aas_facemerging.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"aas_file.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"aas_gsubdiv.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"aas_map.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"aas_prunenodes.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"aas_store.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_bspc.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\be_aas_bspq3.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\be_aas_cluster.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\be_aas_move.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\be_aas_optimize.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\be_aas_reach.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\be_aas_sample.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"brushbsp.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"bspc.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\qcommon\\cm_load.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\qcommon\\cm_patch.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\qcommon\\cm_test.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\qcommon\\cm_trace.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"csg.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"glfile.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_bsp_ent.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_bsp_hl.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_bsp_q1.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_bsp_q2.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_bsp_q3.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_bsp_sin.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_cmd.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\l_libvar.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_log.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_math.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_mem.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_poly.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\l_precomp.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_qfiles.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\l_script.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\l_struct.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_threads.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_utils.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"leakfile.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"map.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"map_hl.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"map_q1.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"map_q2.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"map_q3.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"map_sin.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\qcommon\\md4.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"nodraw.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"portals.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"textures.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tree.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\qcommon\\unzip.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Header Files\"\n\t\t\tFilter=\"h;hpp;hxx;hm;inl\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"aas_areamerging.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"aas_cfg.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"aas_create.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"aas_edgemelting.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"aas_facemerging.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"aas_file.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"aas_gsubdiv.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"aas_map.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"aas_prunenodes.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"aas_store.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\aasfile.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\be_aas_bsp.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas_bspc.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\be_aas_cluster.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\be_aas_debug.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\be_aas_def.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\be_aas_entity.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\be_aas_file.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\be_aas_funcs.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\be_aas_main.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\be_aas_move.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\be_aas_optimize.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\be_aas_reach.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\be_aas_route.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\be_aas_routealt.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\be_aas_sample.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\be_interface.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\bg_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\cgame\\cg_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\client\\client.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\qcommon\\cm_local.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\qcommon\\cm_patch.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\qcommon\\cm_polylib.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\qcommon\\cm_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ui\\keycodes.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\client\\keys.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_bsp_ent.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_bsp_hl.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_bsp_q1.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_bsp_q2.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_bsp_q3.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_bsp_sin.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_cmd.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\l_libvar.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_log.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\l_log.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_math.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_mem.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\l_memory.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_poly.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\l_precomp.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_qfiles.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\l_script.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\botlib\\l_struct.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_threads.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"l_utils.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"q2files.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"q3files.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\q_shared.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qbsp.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\qcommon\\qcommon.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\qcommon\\qfiles.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"sinfiles.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\client\\snd_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\surfaceflags.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\renderer\\tr_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\cgame\\tr_types.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ui\\ui_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\qcommon\\unzip.h\">\n\t\t\t</File>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Resource Files\"\n\t\t\tFilter=\"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\">\n\t\t</Filter>\n\t</Files>\n\t<Globals>\n\t</Globals>\n</VisualStudioProject>\n"
  },
  {
    "path": "code/bspc/cfgq3.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//===========================================================================\n// BSPC configuration file\n// Quake3\n//===========================================================================\n\n#define PRESENCE_NONE\t\t\t\t1\n#define PRESENCE_NORMAL\t\t\t\t2\n#define PRESENCE_CROUCH\t\t\t\t4\n\nbbox\t//30x30x56\n{\n\tpresencetype\tPRESENCE_NORMAL\n\tflags\t\t\t0x0000\n\tmins\t\t\t{-15, -15, -24}\n\tmaxs\t\t\t{15, 15, 32}\n} //end bbox\n\nbbox\t//30x30x40\n{\n\tpresencetype\tPRESENCE_CROUCH\n\tflags\t\t\t0x0001\n\tmins\t\t\t{-15, -15, -24}\n\tmaxs\t\t\t{15, 15, 16}\n} //end bbox\n\nsettings\n{\n\tphys_gravitydirection\t\t{0, 0, -1}\n\tphys_friction\t\t\t\t6\n\tphys_stopspeed\t\t\t\t100\n\tphys_gravity\t\t\t\t800\n\tphys_waterfriction\t\t\t1\n\tphys_watergravity\t\t\t400\n\tphys_maxvelocity\t\t\t320\n\tphys_maxwalkvelocity\t\t320\n\tphys_maxcrouchvelocity\t\t100\n\tphys_maxswimvelocity\t\t150\n\tphys_maxacceleration\t\t2200\n\tphys_airaccelerate\t\t\t0\n\tphys_maxstep\t\t\t\t18\n\tphys_maxsteepness\t\t\t0.7\n\tphys_maxwaterjump\t\t\t19\n\tphys_maxbarrier\t\t\t\t33\n\tphys_jumpvel\t\t\t\t270\n\tphys_falldelta5\t\t\t\t40\n\tphys_falldelta10\t\t\t60\n\trs_waterjump\t\t\t\t400\n\trs_teleport\t\t\t\t\t50\n\trs_barrierjump\t\t\t\t100\n\trs_startcrouch\t\t\t\t300\n\trs_startgrapple\t\t\t\t500\n\trs_startwalkoffledge\t\t70\n\trs_startjump\t\t\t\t300\n\trs_rocketjump\t\t\t\t500\n\trs_bfgjump\t\t\t\t\t500\n\trs_jumppad\t\t\t\t\t250\n\trs_aircontrolledjumppad\t\t300\n\trs_funcbob\t\t\t\t\t300\n\trs_startelevator\t\t\t50\n\trs_falldamage5\t\t\t\t300\n\trs_falldamage10\t\t\t\t500\n\trs_maxjumpfallheight\t\t450\n} //end settings\n"
  },
  {
    "path": "code/bspc/csg.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n\n/*\n\ntag all brushes with original contents\nbrushes may contain multiple contents\nthere will be no brush overlap after csg phase\n\n*/\n\nint minplanenums[3];\nint maxplanenums[3];\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid CheckBSPBrush(bspbrush_t *brush)\n{\n\tint i, j;\n\tplane_t *plane1, *plane2;\n\n\t//check if the brush is convex... flipped planes make a brush non-convex\n\tfor (i = 0; i < brush->numsides; i++)\n\t{\n\t\tfor (j = 0; j < brush->numsides; j++)\n\t\t{\n\t\t\tif (i == j) continue;\n\t\t\tplane1 = &mapplanes[brush->sides[i].planenum];\n\t\t\tplane2 = &mapplanes[brush->sides[j].planenum];\n\t\t\t//\n\t\t\tif (WindingsNonConvex(brush->sides[i].winding,\n\t\t\t\t\t\t\t\t\tbrush->sides[j].winding,\n\t\t\t\t\t\t\t\t\tplane1->normal, plane2->normal,\n\t\t\t\t\t\t\t\t\tplane1->dist, plane2->dist))\n\t\t\t{\n\t\t\t\tLog_Print(\"non convex brush\");\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\tBoundBrush(brush);\n\t//check for out of bound brushes\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tif (brush->mins[i] < -MAX_MAP_BOUNDS || brush->maxs[i] > MAX_MAP_BOUNDS)\n\t\t{\n\t\t\tLog_Print(\"brush: bounds out of range\\n\");\n\t\t\tLog_Print(\"ob->mins[%d] = %f, ob->maxs[%d] = %f\\n\", i, brush->mins[i], i, brush->maxs[i]);\n\t\t\tbreak;\n\t\t} //end if\n\t\tif (brush->mins[i] > MAX_MAP_BOUNDS || brush->maxs[i] < -MAX_MAP_BOUNDS)\n\t\t{\n\t\t\tLog_Print(\"brush: no visible sides on brush\\n\");\n\t\t\tLog_Print(\"ob->mins[%d] = %f, ob->maxs[%d] = %f\\n\", i, brush->mins[i], i, brush->maxs[i]);\n\t\t\tbreak;\n\t\t} //end if\n\t} //end for\n} //end of the function CheckBSPBrush\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid BSPBrushWindings(bspbrush_t *brush)\n{\n\tint i, j;\n\twinding_t *w;\n\tplane_t *plane;\n\n\tfor (i = 0; i < brush->numsides; i++)\n\t{\n\t\tplane = &mapplanes[brush->sides[i].planenum];\n\t\tw = BaseWindingForPlane(plane->normal, plane->dist);\n\t\tfor (j = 0; j < brush->numsides && w; j++)\n\t\t{\n\t\t\tif (i == j) continue;\n\t\t\tplane = &mapplanes[brush->sides[j].planenum^1];\n\t\t\tChopWindingInPlace(&w, plane->normal, plane->dist, 0); //CLIP_EPSILON);\n\t\t} //end for\n\t\tbrush->sides[i].winding = w;\n\t} //end for\n} //end of the function BSPBrushWindings\n//===========================================================================\n// NOTE: can't keep brush->original intact\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *TryMergeBrushes(bspbrush_t *brush1, bspbrush_t *brush2)\n{\n\tint i, j, k, n, shared;\n\tside_t *side1, *side2, *cs;\n\tplane_t *plane1, *plane2;\n\tbspbrush_t *newbrush;\n\n\t//check for bounding box overlapp\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tif (brush1->mins[i] > brush2->maxs[i] + 2\n\t\t\t\t|| brush1->maxs[i] < brush2->mins[i] - 2)\n\t\t{\n\t\t\treturn NULL;\n\t\t} //end if\n\t} //end for\n\t//\n\tshared = 0;\n\t//check if the brush is convex... flipped planes make a brush non-convex\n\tfor (i = 0; i < brush1->numsides; i++)\n\t{\n\t\tside1 = &brush1->sides[i];\n\t\t//don't check the \"shared\" sides\n\t\tfor (k = 0; k < brush2->numsides; k++)\n\t\t{\n\t\t\tside2 = &brush2->sides[k];\n\t\t\tif (side1->planenum == (side2->planenum^1))\n\t\t\t{\n\t\t\t\tshared++;\n\t\t\t\t//there may only be ONE shared side\n\t\t\t\tif (shared > 1) return NULL;\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t} //end for\n\t\tif (k < brush2->numsides) continue;\n\t\t//\n\t\tfor (j = 0; j < brush2->numsides; j++)\n\t\t{\n\t\t\tside2 = &brush2->sides[j];\n\t\t\t//don't check the \"shared\" sides\n\t\t\tfor (n = 0; n < brush1->numsides; n++)\n\t\t\t{\n\t\t\t\tside1 = &brush1->sides[n];\n\t\t\t\tif (side1->planenum == (side2->planenum^1)) break;\n\t\t\t} //end for\n\t\t\tif (n < brush1->numsides) continue;\n\t\t\t//\n\t\t\tside1 = &brush1->sides[i];\n\t\t\t//if the side is in the same plane\n\t\t\t//*\n\t\t\tif (side1->planenum == side2->planenum)\n\t\t\t{\n\t\t\t\tif (side1->texinfo != TEXINFO_NODE &&\n\t\t\t\t\tside2->texinfo != TEXINFO_NODE &&\n\t\t\t\t\tside1->texinfo != side2->texinfo) return NULL;\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\t//\n\t\t\tplane1 = &mapplanes[side1->planenum];\n\t\t\tplane2 = &mapplanes[side2->planenum];\n\t\t\t//\n\t\t\tif (WindingsNonConvex(side1->winding, side2->winding,\n\t\t\t\t\t\t\t\t\tplane1->normal, plane2->normal,\n\t\t\t\t\t\t\t\t\tplane1->dist, plane2->dist))\n\t\t\t{\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\tnewbrush = AllocBrush(brush1->numsides + brush2->numsides);\n\tnewbrush->original = brush1->original;\n\tnewbrush->numsides = 0;\n\t//newbrush->side = brush1->side;\t//brush contents\n\t//fix texinfos for sides lying in the same plane\n\tfor (i = 0; i < brush1->numsides; i++)\n\t{\n\t\tside1 = &brush1->sides[i];\n\t\t//\n\t\tfor (n = 0; n < brush2->numsides; n++)\n\t\t{\n\t\t\tside2 = &brush2->sides[n];\n\t\t\t//if both sides are in the same plane get the texinfo right\n\t\t\tif (side1->planenum == side2->planenum)\n\t\t\t{\n\t\t\t\tif (side1->texinfo == TEXINFO_NODE) side1->texinfo = side2->texinfo;\n\t\t\t\tif (side2->texinfo == TEXINFO_NODE) side2->texinfo = side1->texinfo;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\t//\n\tfor (i = 0; i < brush1->numsides; i++)\n\t{\n\t\tside1 = &brush1->sides[i];\n\t\t//don't add the \"shared\" sides\n\t\tfor (n = 0; n < brush2->numsides; n++)\n\t\t{\n\t\t\tside2 = &brush2->sides[n];\n\t\t\tif (side1->planenum == (side2->planenum ^ 1)) break;\n\t\t} //end for\n\t\tif (n < brush2->numsides) continue;\n\t\t//\n\t\tfor (n = 0; n < newbrush->numsides; n++)\n\t\t{\n\t\t\tcs = &newbrush->sides[n];\n\t\t\tif (cs->planenum == side1->planenum)\n\t\t\t{\n\t\t\t\tLog_Print(\"brush duplicate plane\\n\");\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t} //end if\n\t\tif (n < newbrush->numsides) continue;\n\t\t//add this side\n\t\tcs = &newbrush->sides[newbrush->numsides];\n\t\tnewbrush->numsides++;\n\t\t*cs = *side1;\n\t} //end for\n\tfor (j = 0; j < brush2->numsides; j++)\n\t{\n\t\tside2 = &brush2->sides[j];\n\t\tfor (n = 0; n < brush1->numsides; n++)\n\t\t{\n\t\t\tside1 = &brush1->sides[n];\n\t\t\t//if the side is in the same plane\n\t\t\tif (side2->planenum == side1->planenum) break;\n\t\t\t//don't add the \"shared\" sides\n\t\t\tif (side2->planenum == (side1->planenum ^ 1)) break;\n\t\t} //end for\n\t\tif (n < brush1->numsides) continue;\n\t\t//\n\t\tfor (n = 0; n < newbrush->numsides; n++)\n\t\t{\n\t\t\tcs = &newbrush->sides[n];\n\t\t\tif (cs->planenum == side2->planenum)\n\t\t\t{\n\t\t\t\tLog_Print(\"brush duplicate plane\\n\");\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t} //end if\n\t\tif (n < newbrush->numsides) continue;\n\t\t//add this side\n\t\tcs = &newbrush->sides[newbrush->numsides];\n\t\tnewbrush->numsides++;\n\t\t*cs = *side2;\n\t} //end for\n\tBSPBrushWindings(newbrush);\n\tBoundBrush(newbrush);\n\tCheckBSPBrush(newbrush);\n\treturn newbrush;\n} //end of the function TryMergeBrushes\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *MergeBrushes(bspbrush_t *brushlist)\n{\n\tint nummerges, merged;\n\tbspbrush_t *b1, *b2, *tail, *newbrush, *newbrushlist;\n\tbspbrush_t *lastb2;\n\n\tif (!brushlist) return NULL;\n\n\tqprintf(\"%5d brushes merged\", nummerges = 0);\n\tdo\n\t{\n\t\tfor (tail = brushlist; tail; tail = tail->next)\n\t\t{\n\t\t\tif (!tail->next) break;\n\t\t} //end for\n\t\tmerged = 0;\n\t\tnewbrushlist = NULL;\n\t\tfor (b1 = brushlist; b1; b1 = brushlist)\n\t\t{\n\t\t\tlastb2 = b1;\n\t\t\tfor (b2 = b1->next; b2; b2 = b2->next)\n\t\t\t{\n\t\t\t\t//if the brushes don't have the same contents\n\t\t\t\tif (b1->original->contents != b2->original->contents ||\n\t\t\t\t\tb1->original->expansionbbox != b2->original->expansionbbox) newbrush = NULL;\n\t\t\t\telse newbrush = TryMergeBrushes(b1, b2);\n\t\t\t\tif (newbrush)\n\t\t\t\t{\n\t\t\t\t\ttail->next = newbrush;\n\t\t\t\t\tlastb2->next = b2->next;\n\t\t\t\t\tbrushlist = brushlist->next;\n\t\t\t\t\tFreeBrush(b1);\n\t\t\t\t\tFreeBrush(b2);\n\t\t\t\t\tfor (tail = brushlist; tail; tail = tail->next)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!tail->next) break;\n\t\t\t\t\t} //end for\n\t\t\t\t\tmerged++;\n\t\t\t\t\tqprintf(\"\\r%5d\", nummerges++);\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t\tlastb2 = b2;\n\t\t\t} //end for\n\t\t\t//if b1 can't be merged with any of the other brushes\n\t\t\tif (!b2)\n\t\t\t{\n\t\t\t\tbrushlist = brushlist->next;\n\t\t\t\t//keep b1\n\t\t\t\tb1->next = newbrushlist;\n\t\t\t\tnewbrushlist = b1;\n\t\t\t} //end else\n\t\t} //end for\n\t\tbrushlist = newbrushlist;\n\t} while(merged);\n\tqprintf(\"\\n\");\n\treturn newbrushlist;\n} //end of the function MergeBrushes\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid SplitBrush2 (bspbrush_t *brush, int planenum,\n\tbspbrush_t **front, bspbrush_t **back)\n{\n\tSplitBrush (brush, planenum, front, back);\n#if 0\n\tif (*front && (*front)->sides[(*front)->numsides-1].texinfo == -1)\n\t\t(*front)->sides[(*front)->numsides-1].texinfo = (*front)->sides[0].texinfo;\t// not -1\n\tif (*back && (*back)->sides[(*back)->numsides-1].texinfo == -1)\n\t\t(*back)->sides[(*back)->numsides-1].texinfo = (*back)->sides[0].texinfo;\t// not -1\n#endif\n} //end of the function SplitBrush2\n//===========================================================================\n// Returns a list of brushes that remain after B is subtracted from A.\n// May by empty if A is contained inside B.\n// The originals are undisturbed.\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *SubtractBrush (bspbrush_t *a, bspbrush_t *b)\n{\t// a - b = out (list)\n\tint\t\ti;\n\tbspbrush_t\t*front, *back;\n\tbspbrush_t\t*out, *in;\n\n\tin = a;\n\tout = NULL;\n\tfor (i = 0; i < b->numsides && in; i++)\n\t{\n\t\tSplitBrush2(in, b->sides[i].planenum, &front, &back);\n\t\tif (in != a) FreeBrush(in);\n\t\tif (front)\n\t\t{\t// add to list\n\t\t\tfront->next = out;\n\t\t\tout = front;\n\t\t} //end if\n\t\tin = back;\n\t} //end for\n\tif (in)\n\t{\n\t\tFreeBrush (in);\n\t} //end if\n\telse\n\t{\t// didn't really intersect\n\t\tFreeBrushList (out);\n\t\treturn a;\n\t} //end else\n\treturn out;\n} //end of the function SubtractBrush\n//===========================================================================\n// Returns a single brush made up by the intersection of the\n// two provided brushes, or NULL if they are disjoint.\n//\n// The originals are undisturbed.\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *IntersectBrush (bspbrush_t *a, bspbrush_t *b)\n{\n\tint\t\ti;\n\tbspbrush_t\t*front, *back;\n\tbspbrush_t\t*in;\n\n\tin = a;\n\tfor (i=0 ; i<b->numsides && in ; i++)\n\t{\n\t\tSplitBrush2(in, b->sides[i].planenum, &front, &back);\n\t\tif (in != a) FreeBrush(in);\n\t\tif (front) FreeBrush(front);\n\t\tin = back;\n\t} //end for\n\n\tif (in == a) return NULL;\n\n\tin->next = NULL;\n\treturn in;\n} //end of the function IntersectBrush\n//===========================================================================\n// Returns true if the two brushes definately do not intersect.\n// There will be false negatives for some non-axial combinations.\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean BrushesDisjoint (bspbrush_t *a, bspbrush_t *b)\n{\n\tint\t\ti, j;\n\n\t// check bounding boxes\n\tfor (i=0 ; i<3 ; i++)\n\t\tif (a->mins[i] >= b->maxs[i]\n\t\t|| a->maxs[i] <= b->mins[i])\n\t\t\treturn true;\t// bounding boxes don't overlap\n\n\t// check for opposing planes\n\tfor (i=0 ; i<a->numsides ; i++)\n\t{\n\t\tfor (j=0 ; j<b->numsides ; j++)\n\t\t{\n\t\t\tif (a->sides[i].planenum ==\n\t\t\t(b->sides[j].planenum^1) )\n\t\t\t\treturn true;\t// opposite planes, so not touching\n\t\t}\n\t}\n\n\treturn false;\t// might intersect\n} //end of the function BrushesDisjoint\n//===========================================================================\n// Returns a content word for the intersection of two brushes.\n// Some combinations will generate a combination (water + clip),\n// but most will be the stronger of the two contents.\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint IntersectionContents (int c1, int c2)\n{\n\tint out;\n\n\tout = c1 | c2;\n\n\tif (out & CONTENTS_SOLID) out = CONTENTS_SOLID;\n\n\treturn out;\n} //end of the function IntersectionContents\n//===========================================================================\n// Any planes shared with the box edge will be set to no texinfo\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *ClipBrushToBox(bspbrush_t *brush, vec3_t clipmins, vec3_t clipmaxs)\n{\n\tint\t\ti, j;\n\tbspbrush_t\t*front,\t*back;\n\tint\t\tp;\n\n\tfor (j=0 ; j<2 ; j++)\n\t{\n\t\tif (brush->maxs[j] > clipmaxs[j])\n\t\t{\n\t\t\tSplitBrush (brush, maxplanenums[j], &front, &back);\n\t\t\tif (front)\n\t\t\t\tFreeBrush (front);\n\t\t\tbrush = back;\n\t\t\tif (!brush)\n\t\t\t\treturn NULL;\n\t\t}\n\t\tif (brush->mins[j] < clipmins[j])\n\t\t{\n\t\t\tSplitBrush (brush, minplanenums[j], &front, &back);\n\t\t\tif (back)\n\t\t\t\tFreeBrush (back);\n\t\t\tbrush = front;\n\t\t\tif (!brush)\n\t\t\t\treturn NULL;\n\t\t}\n\t}\n\n\t// remove any colinear faces\n\n\tfor (i=0 ; i<brush->numsides ; i++)\n\t{\n\t\tp = brush->sides[i].planenum & ~1;\n\t\tif (p == maxplanenums[0] || p == maxplanenums[1] \n\t\t\t|| p == minplanenums[0] || p == minplanenums[1])\n\t\t{\n\t\t\tbrush->sides[i].texinfo = TEXINFO_NODE;\n\t\t\tbrush->sides[i].flags &= ~SFL_VISIBLE;\n\t\t}\n\t}\n\treturn brush;\n} //end of the function ClipBrushToBox\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *MakeBspBrushList(int startbrush, int endbrush,\n\t\t\t\t\t\t\t\t\t\t\tvec3_t clipmins, vec3_t clipmaxs)\n{\n\tmapbrush_t\t*mb;\n\tbspbrush_t\t*brushlist, *newbrush;\n\tint\t\t\ti, j;\n\tint\t\t\tc_faces;\n\tint\t\t\tc_brushes;\n\tint\t\t\tnumsides;\n\tint\t\t\tvis;\n\tvec3_t\t\tnormal;\n\tfloat\t\tdist;\n\n\tfor (i=0 ; i<2 ; i++)\n\t{\n\t\tVectorClear (normal);\n\t\tnormal[i] = 1;\n\t\tdist = clipmaxs[i];\n\t\tmaxplanenums[i] = FindFloatPlane(normal, dist);\n\t\tdist = clipmins[i];\n\t\tminplanenums[i] = FindFloatPlane(normal, dist);\n\t}\n\n\tbrushlist = NULL;\n\tc_faces = 0;\n\tc_brushes = 0;\n\n\tfor (i=startbrush ; i<endbrush ; i++)\n\t{\n\t\tmb = &mapbrushes[i];\n\n\t\tnumsides = mb->numsides;\n\t\tif (!numsides)\n\t\t\tcontinue;\n\n\t\t// make sure the brush has at least one face showing\n\t\tvis = 0;\n\t\tfor (j=0 ; j<numsides ; j++)\n\t\t\tif ((mb->original_sides[j].flags & SFL_VISIBLE) && mb->original_sides[j].winding)\n\t\t\t\tvis++;\n#if 0\n\t\tif (!vis)\n\t\t\tcontinue;\t// no faces at all\n#endif\n\t\t// if the brush is outside the clip area, skip it\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t\tif (mb->mins[j] >= clipmaxs[j]\n\t\t\t|| mb->maxs[j] <= clipmins[j])\n\t\t\tbreak;\n\t\tif (j != 3)\n\t\t\tcontinue;\n\n\t\t//\n\t\t// make a copy of the brush\n\t\t//\n\t\tnewbrush = AllocBrush (mb->numsides);\n\t\tnewbrush->original = mb;\n\t\tnewbrush->numsides = mb->numsides;\n\t\tmemcpy (newbrush->sides, mb->original_sides, numsides*sizeof(side_t));\n\t\tfor (j=0 ; j<numsides ; j++)\n\t\t{\n\t\t\tif (newbrush->sides[j].winding)\n\t\t\t\tnewbrush->sides[j].winding = CopyWinding (newbrush->sides[j].winding);\n\t\t\tif (newbrush->sides[j].surf & SURF_HINT)\n\t\t\t\tnewbrush->sides[j].flags |= SFL_VISIBLE;\t// hints are always visible\n\t\t}\n\t\tVectorCopy (mb->mins, newbrush->mins);\n\t\tVectorCopy (mb->maxs, newbrush->maxs);\n\n\t\t//\n\t\t// carve off anything outside the clip box\n\t\t//\n\t\tnewbrush = ClipBrushToBox (newbrush, clipmins, clipmaxs);\n\t\tif (!newbrush)\n\t\t\tcontinue;\n\n\t\tc_faces += vis;\n\t\tc_brushes++;\n\n\t\tnewbrush->next = brushlist;\n\t\tbrushlist = newbrush;\n\t}\n\n\treturn brushlist;\n} //end of the function MakeBspBrushList\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *AddBrushListToTail (bspbrush_t *list, bspbrush_t *tail)\n{\n\tbspbrush_t\t*walk, *next;\n\n\tfor (walk=list ; walk ; walk=next)\n\t{\t// add to end of list\n\t\tnext = walk->next;\n\t\twalk->next = NULL;\n\t\ttail->next = walk;\n\t\ttail = walk;\n\t} //end for\n\treturn tail;\n} //end of the function AddBrushListToTail\n//===========================================================================\n// Builds a new list that doesn't hold the given brush\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *CullList(bspbrush_t *list, bspbrush_t *skip1)\n{\n\tbspbrush_t\t*newlist;\n\tbspbrush_t\t*next;\n\n\tnewlist = NULL;\n\n\tfor ( ; list ; list = next)\n\t{\n\t\tnext = list->next;\n\t\tif (list == skip1)\n\t\t{\n\t\t\tFreeBrush (list);\n\t\t\tcontinue;\n\t\t}\n\t\tlist->next = newlist;\n\t\tnewlist = list;\n\t}\n\treturn newlist;\n} //end of the function CullList\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n/*\nvoid WriteBrushMap(char *name, bspbrush_t *list)\n{\n\tFILE\t*f;\n\tside_t\t*s;\n\tint\t\ti;\n\twinding_t\t*w;\n\n\tLog_Print(\"writing %s\\n\", name);\n\tf = fopen (name, \"wb\");\n\tif (!f)\n\t\tError (\"Can't write %s\\b\", name);\n\n\tfprintf (f, \"{\\n\\\"classname\\\" \\\"worldspawn\\\"\\n\");\n\n\tfor ( ; list ; list=list->next )\n\t{\n\t\tfprintf (f, \"{\\n\");\n\t\tfor (i=0,s=list->sides ; i<list->numsides ; i++,s++)\n\t\t{\n\t\t\tw = BaseWindingForPlane (mapplanes[s->planenum].normal, mapplanes[s->planenum].dist);\n\n\t\t\tfprintf (f,\"( %i %i %i ) \", (int)w->p[0][0], (int)w->p[0][1], (int)w->p[0][2]);\n\t\t\tfprintf (f,\"( %i %i %i ) \", (int)w->p[1][0], (int)w->p[1][1], (int)w->p[1][2]);\n\t\t\tfprintf (f,\"( %i %i %i ) \", (int)w->p[2][0], (int)w->p[2][1], (int)w->p[2][2]);\n\n\t\t\tfprintf (f, \"%s 0 0 0 1 1\\n\", texinfo[s->texinfo].texture);\n\t\t\tFreeWinding (w);\n\t\t}\n\t\tfprintf (f, \"}\\n\");\n\t}\n\tfprintf (f, \"}\\n\");\n\n\tfclose (f);\n} //end of the function WriteBrushMap\n*/\n//===========================================================================\n// Returns true if b1 is allowed to bite b2\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean BrushGE (bspbrush_t *b1, bspbrush_t *b2)\n{\n#ifdef ME\n\tif (create_aas)\n\t{\n\t\tif (b1->original->expansionbbox != b2->original->expansionbbox)\n\t\t{\n\t\t\treturn false;\n\t\t} //end if\n\t\t//never have something else bite a ladder brush\n\t\t//never have a ladder brush bite something else\n\t\tif ( (b1->original->contents & CONTENTS_LADDER)\n\t\t\t&& !(b2->original->contents & CONTENTS_LADDER))\n\t\t{ \n\t\t\treturn false;\n\t\t} //end if\n\t} //end if\n#endif //ME\n\t// detail brushes never bite structural brushes\n\tif ( (b1->original->contents & CONTENTS_DETAIL) \n\t\t&& !(b2->original->contents & CONTENTS_DETAIL) )\n\t{\n\t\treturn false;\n\t} //end if\n\tif (b1->original->contents & CONTENTS_SOLID)\n\t{\n\t\treturn true;\n\t} //end if\n\treturn false;\n} //end of the function BrushGE\n//===========================================================================\n// Carves any intersecting solid brushes into the minimum number\n// of non-intersecting brushes.\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *ChopBrushes (bspbrush_t *head)\n{\n\tbspbrush_t\t*b1, *b2, *next;\n\tbspbrush_t\t*tail;\n\tbspbrush_t\t*keep;\n\tbspbrush_t\t*sub, *sub2;\n\tint\t\t\tc1, c2;\n\tint num_csg_iterations;\n\n\tLog_Print(\"-------- Brush CSG ---------\\n\");\n\tLog_Print(\"%6d original brushes\\n\", CountBrushList (head));\n\n\tnum_csg_iterations = 0;\n\tqprintf(\"%6d output brushes\", num_csg_iterations);\n\n#if 0\n\tif (startbrush == 0)\n\t\tWriteBrushList (\"before.gl\", head, false);\n#endif\n\tkeep = NULL;\n\nnewlist:\n\t// find tail\n\tif (!head) return NULL;\n\n\tfor (tail = head; tail->next; tail = tail->next)\n\t\t;\n\n\tfor (b1=head ; b1 ; b1=next)\n\t{\n\t\tnext = b1->next;\n\n\t\t//if the conversion is cancelled\n\t\tif (cancelconversion)\n\t\t{\n\t\t\tb1->next = keep;\n\t\t\tkeep = b1;\n\t\t\tcontinue;\n\t\t} //end if\n\t\t\n\t\tfor (b2 = b1->next; b2; b2 = b2->next)\n\t\t{\n\t\t\tif (BrushesDisjoint (b1, b2))\n\t\t\t\tcontinue;\n\n\t\t\tsub = NULL;\n\t\t\tsub2 = NULL;\n\t\t\tc1 = 999999;\n\t\t\tc2 = 999999;\n\n\t\t\tif (BrushGE (b2, b1))\n\t\t\t{\n\t\t\t\tsub = SubtractBrush (b1, b2);\n\t\t\t\tif (sub == b1)\n\t\t\t\t{\n\t\t\t\t\tcontinue;\t\t// didn't really intersect\n\t\t\t\t} //end if\n\t\t\t\tif (!sub)\n\t\t\t\t{\t// b1 is swallowed by b2\n\t\t\t\t\thead = CullList (b1, b1);\n\t\t\t\t\tgoto newlist;\n\t\t\t\t}\n\t\t\t\tc1 = CountBrushList (sub);\n\t\t\t}\n\n\t\t\tif ( BrushGE (b1, b2) )\n\t\t\t{\n\t\t\t\tsub2 = SubtractBrush (b2, b1);\n\t\t\t\tif (sub2 == b2)\n\t\t\t\t\tcontinue;\t\t// didn't really intersect\n\t\t\t\tif (!sub2)\n\t\t\t\t{\t// b2 is swallowed by b1\n\t\t\t\t\tFreeBrushList (sub);\n\t\t\t\t\thead = CullList (b1, b2);\n\t\t\t\t\tgoto newlist;\n\t\t\t\t}\n\t\t\t\tc2 = CountBrushList (sub2);\n\t\t\t}\n\n\t\t\tif (!sub && !sub2)\n\t\t\t\tcontinue;\t\t// neither one can bite\n\n\t\t\t// only accept if it didn't fragment\n\t\t\t// (commenting this out allows full fragmentation)\n\t\t\tif (c1 > 1 && c2 > 1)\n\t\t\t{\n\t\t\t\tif (sub2)\n\t\t\t\t\tFreeBrushList (sub2);\n\t\t\t\tif (sub)\n\t\t\t\t\tFreeBrushList (sub);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (c1 < c2)\n\t\t\t{\n\t\t\t\tif (sub2) FreeBrushList (sub2);\n\t\t\t\ttail = AddBrushListToTail (sub, tail);\n\t\t\t\thead = CullList (b1, b1);\n\t\t\t\tgoto newlist;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (sub) FreeBrushList (sub);\n\t\t\t\ttail = AddBrushListToTail (sub2, tail);\n\t\t\t\thead = CullList (b1, b2);\n\t\t\t\tgoto newlist;\n\t\t\t} //end else\n\t\t} //end for\n\n\t\tif (!b2)\n\t\t{\t// b1 is no longer intersecting anything, so keep it\n\t\t\tb1->next = keep;\n\t\t\tkeep = b1;\n\t\t} //end if\n\t\tnum_csg_iterations++;\n\t\tqprintf(\"\\r%6d\", num_csg_iterations);\n\t} //end for\n\n\tif (cancelconversion) return keep;\n\t//\n\tqprintf(\"\\n\");\n\tLog_Write(\"%6d output brushes\\r\\n\", num_csg_iterations);\n\n#if 0\n\t{\n\t\tWriteBrushList (\"after.gl\", keep, false);\n\t\tWriteBrushMap (\"after.map\", keep);\n\t}\n#endif\n\n\treturn keep;\n} //end of the function ChopBrushes\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *InitialBrushList (bspbrush_t *list)\n{\n\tbspbrush_t *b;\n\tbspbrush_t\t*out, *newb;\n\tint\t\t\ti;\n\n\t// only return brushes that have visible faces\n\tout = NULL;\n\tfor (b=list ; b ; b=b->next)\n\t{\n#if 0\n\t\tfor (i=0 ; i<b->numsides ; i++)\n\t\t\tif (b->sides[i].flags & SFL_VISIBLE)\n\t\t\t\tbreak;\n\t\tif (i == b->numsides)\n\t\t\tcontinue;\n#endif\n\t\tnewb = CopyBrush (b);\n\t\tnewb->next = out;\n\t\tout = newb;\n\n\t\t// clear visible, so it must be set by MarkVisibleFaces_r\n\t\t// to be used in the optimized list\n\t\tfor (i=0 ; i<b->numsides ; i++)\n\t\t{\n\t\t\tnewb->sides[i].original = &b->sides[i];\n//\t\t\tnewb->sides[i].visible = true;\n\t\t\tb->sides[i].flags &= ~SFL_VISIBLE;\n\t\t}\n\t}\n\n\treturn out;\n} //end of the function InitialBrushList\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *OptimizedBrushList (bspbrush_t *list)\n{\n\tbspbrush_t *b;\n\tbspbrush_t\t*out, *newb;\n\tint\t\t\ti;\n\n\t// only return brushes that have visible faces\n\tout = NULL;\n\tfor (b=list ; b ; b=b->next)\n\t{\n\t\tfor (i=0 ; i<b->numsides ; i++)\n\t\t\tif (b->sides[i].flags & SFL_VISIBLE)\n\t\t\t\tbreak;\n\t\tif (i == b->numsides)\n\t\t\tcontinue;\n\t\tnewb = CopyBrush (b);\n\t\tnewb->next = out;\n\t\tout = newb;\n\t} //end for\n\n//\tWriteBrushList (\"vis.gl\", out, true);\n\treturn out;\n} //end of the function OptimizeBrushList\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\ntree_t *ProcessWorldBrushes(int brush_start, int brush_end)\n{\n\tbspbrush_t *brushes;\n\ttree_t *tree;\n\tnode_t *node;\n\tvec3_t mins, maxs;\n\n\t//take the whole world\n\tmins[0] = map_mins[0] - 8;\n\tmins[1] = map_mins[1] - 8;\n\tmins[2] = map_mins[2] - 8;\n\n\tmaxs[0] = map_maxs[0] + 8;\n\tmaxs[1] = map_maxs[1] + 8;\n\tmaxs[2] = map_maxs[2] + 8;\n\n\t//reset the brush bsp\n\tResetBrushBSP();\n\n\t// the makelist and chopbrushes could be cached between the passes...\n\n\t//create a list with brushes that are within the given mins/maxs\n\t//some brushes will be cut and only the part that falls within the\n\t//mins/maxs will be in the bush list\n\tbrushes = MakeBspBrushList(brush_start, brush_end, mins, maxs);\n\t//\n\n\tif (!brushes)\n\t{\n\t\tnode = AllocNode ();\n\t\tnode->planenum = PLANENUM_LEAF;\n\t\tnode->contents = CONTENTS_SOLID;\n\n\t\ttree = Tree_Alloc();\n\t\ttree->headnode = node;\n\t\tVectorCopy(mins, tree->mins);\n\t\tVectorCopy(maxs, tree->maxs);\n\t} //end if\n\telse\n\t{\n\t\t//Carves any intersecting solid brushes into the minimum number\n\t\t//of non-intersecting brushes. \n\t\tif (!nocsg)\n\t\t{\n\t\t\tbrushes = ChopBrushes(brushes);\n\t\t\t/*\n\t\t\tif (create_aas)\n\t\t\t{\n\t\t\t\tbrushes = MergeBrushes(brushes);\n\t\t\t} //end if*/\n\t\t} //end if\n\t\t//if the conversion is cancelled\n\t\tif (cancelconversion)\n\t\t{\n\t\t\tFreeBrushList(brushes);\n\t\t\treturn NULL;\n\t\t} //end if\n\t\t//create the actual bsp tree\n\t\ttree = BrushBSP(brushes, mins, maxs);\n\t} //end else\n\t//return the tree\n\treturn tree;\n} //end of the function ProcessWorldBrushes\n"
  },
  {
    "path": "code/bspc/faces.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// faces.c\n\n#include \"qbsp.h\"\n#include \"l_mem.h\"\n\n/*\n\n  some faces will be removed before saving, but still form nodes:\n\n  the insides of sky volumes\n  meeting planes of different water current volumes\n\n*/\n\n// undefine for dumb linear searches\n#define\tUSE_HASHING\n\n#define\tINTEGRAL_EPSILON\t0.01\n#define\tPOINT_EPSILON\t\t0.5\n#define\tOFF_EPSILON\t\t\t0.5\n\nint\tc_merge;\nint\tc_subdivide;\n\nint\tc_totalverts;\nint\tc_uniqueverts;\nint\tc_degenerate;\nint\tc_tjunctions;\nint\tc_faceoverflows;\nint\tc_facecollapse;\nint\tc_badstartverts;\n\n#define\tMAX_SUPERVERTS\t512\nint\tsuperverts[MAX_SUPERVERTS];\nint\tnumsuperverts;\n\nface_t\t\t*edgefaces[MAX_MAP_EDGES][2];\nint\t\tfirstmodeledge = 1;\nint\t\tfirstmodelface;\n\nint\tc_tryedges;\n\nvec3_t\tedge_dir;\nvec3_t\tedge_start;\nvec_t\tedge_len;\n\nint\t\tnum_edge_verts;\nint\t\tedge_verts[MAX_MAP_VERTS];\n\nface_t *NewFaceFromFace (face_t *f);\n\n//===========================================================================\n\ntypedef struct hashvert_s\n{\n\tstruct hashvert_s\t*next;\n\tint\t\tnum;\n} hashvert_t;\n\n\n#define\tHASH_SIZE\t64\n\n\nint\tvertexchain[MAX_MAP_VERTS];\t\t// the next vertex in a hash chain\nint\thashverts[HASH_SIZE*HASH_SIZE];\t// a vertex number, or 0 for no verts\n\nface_t\t\t*edgefaces[MAX_MAP_EDGES][2];\n\n//============================================================================\n\n\nunsigned HashVec (vec3_t vec)\n{\n\tint\t\t\tx, y;\n\n\tx = (4096 + (int)(vec[0]+0.5)) >> 7;\n\ty = (4096 + (int)(vec[1]+0.5)) >> 7;\n\n\tif ( x < 0 || x >= HASH_SIZE || y < 0 || y >= HASH_SIZE )\n\t\tError (\"HashVec: point outside valid range\");\n\t\n\treturn y*HASH_SIZE + x;\n}\n\n#ifdef USE_HASHING\n/*\n=============\nGetVertex\n\nUses hashing\n=============\n*/\nint\tGetVertexnum (vec3_t in)\n{\n\tint\t\t\th;\n\tint\t\t\ti;\n\tfloat\t\t*p;\n\tvec3_t\t\tvert;\n\tint\t\t\tvnum;\n\n\tc_totalverts++;\n\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tif ( fabs(in[i] - Q_rint(in[i])) < INTEGRAL_EPSILON)\n\t\t\tvert[i] = Q_rint(in[i]);\n\t\telse\n\t\t\tvert[i] = in[i];\n\t}\n\t\n\th = HashVec (vert);\n\t\n\tfor (vnum=hashverts[h] ; vnum ; vnum=vertexchain[vnum])\n\t{\n\t\tp = dvertexes[vnum].point;\n\t\tif ( fabs(p[0]-vert[0])<POINT_EPSILON\n\t\t&& fabs(p[1]-vert[1])<POINT_EPSILON\n\t\t&& fabs(p[2]-vert[2])<POINT_EPSILON )\n\t\t\treturn vnum;\n\t}\n\t\n// emit a vertex\n\tif (numvertexes == MAX_MAP_VERTS)\n\t\tError (\"numvertexes == MAX_MAP_VERTS\");\n\n\tdvertexes[numvertexes].point[0] = vert[0];\n\tdvertexes[numvertexes].point[1] = vert[1];\n\tdvertexes[numvertexes].point[2] = vert[2];\n\n\tvertexchain[numvertexes] = hashverts[h];\n\thashverts[h] = numvertexes;\n\n\tc_uniqueverts++;\n\n\tnumvertexes++;\n\t\t\n\treturn numvertexes-1;\n}\n#else\n/*\n==================\nGetVertexnum\n\nDumb linear search\n==================\n*/\nint\tGetVertexnum (vec3_t v)\n{\n\tint\t\t\ti, j;\n\tdvertex_t\t*dv;\n\tvec_t\t\td;\n\n\tc_totalverts++;\n\n\t// make really close values exactly integral\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tif ( fabs(v[i] - (int)(v[i]+0.5)) < INTEGRAL_EPSILON )\n\t\t\tv[i] = (int)(v[i]+0.5);\n\t\tif (v[i] < -4096 || v[i] > 4096)\n\t\t\tError (\"GetVertexnum: outside +/- 4096\");\n\t}\n\n\t// search for an existing vertex match\n\tfor (i=0, dv=dvertexes ; i<numvertexes ; i++, dv++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\td = v[j] - dv->point[j];\n\t\t\tif ( d > POINT_EPSILON || d < -POINT_EPSILON)\n\t\t\t\tbreak;\n\t\t}\n\t\tif (j == 3)\n\t\t\treturn i;\t\t// a match\n\t}\n\n\t// new point\n\tif (numvertexes == MAX_MAP_VERTS)\n\t\tError (\"MAX_MAP_VERTS\");\n\tVectorCopy (v, dv->point);\n\tnumvertexes++;\n\tc_uniqueverts++;\n\n\treturn numvertexes-1;\n}\n#endif\n\n\n/*\n==================\nFaceFromSuperverts\n\nThe faces vertexes have been added to the superverts[] array,\nand there may be more there than can be held in a face (MAXEDGES).\n\nIf less, the faces vertexnums[] will be filled in, otherwise\nface will reference a tree of split[] faces until all of the\nvertexnums can be added.\n\nsuperverts[base] will become face->vertexnums[0], and the others\nwill be circularly filled in.\n==================\n*/\nvoid FaceFromSuperverts (node_t *node, face_t *f, int base)\n{\n\tface_t\t*newf;\n\tint\t\tremaining;\n\tint\t\ti;\n\n\tremaining = numsuperverts;\n\twhile (remaining > MAXEDGES)\n\t{\t// must split into two faces, because of vertex overload\n\t\tc_faceoverflows++;\n\n\t\tnewf = f->split[0] = NewFaceFromFace (f);\n\t\tnewf = f->split[0];\n\t\tnewf->next = node->faces;\n\t\tnode->faces = newf;\n\n\t\tnewf->numpoints = MAXEDGES;\n\t\tfor (i=0 ; i<MAXEDGES ; i++)\n\t\t\tnewf->vertexnums[i] = superverts[(i+base)%numsuperverts];\n\n\t\tf->split[1] = NewFaceFromFace (f);\n\t\tf = f->split[1];\n\t\tf->next = node->faces;\n\t\tnode->faces = f;\n\n\t\tremaining -= (MAXEDGES-2);\n\t\tbase = (base+MAXEDGES-1)%numsuperverts;\n\t}\n\n\t// copy the vertexes back to the face\n\tf->numpoints = remaining;\n\tfor (i=0 ; i<remaining ; i++)\n\t\tf->vertexnums[i] = superverts[(i+base)%numsuperverts];\n}\n\n\n/*\n==================\nEmitFaceVertexes\n==================\n*/\nvoid EmitFaceVertexes (node_t *node, face_t *f)\n{\n\twinding_t\t*w;\n\tint\t\t\ti;\n\n\tif (f->merged || f->split[0] || f->split[1])\n\t\treturn;\n\n\tw = f->w;\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tif (noweld)\n\t\t{\t// make every point unique\n\t\t\tif (numvertexes == MAX_MAP_VERTS)\n\t\t\t\tError (\"MAX_MAP_VERTS\");\n\t\t\tsuperverts[i] = numvertexes;\n\t\t\tVectorCopy (w->p[i], dvertexes[numvertexes].point);\n\t\t\tnumvertexes++;\n\t\t\tc_uniqueverts++;\n\t\t\tc_totalverts++;\n\t\t}\n\t\telse\n\t\t\tsuperverts[i] = GetVertexnum (w->p[i]);\n\t}\n\tnumsuperverts = w->numpoints;\n\n\t// this may fragment the face if > MAXEDGES\n\tFaceFromSuperverts (node, f, 0);\n}\n\n/*\n==================\nEmitVertexes_r\n==================\n*/\nvoid EmitVertexes_r (node_t *node)\n{\n\tint\t\ti;\n\tface_t\t*f;\n\n\tif (node->planenum == PLANENUM_LEAF)\n\t\treturn;\n\n\tfor (f=node->faces ; f ; f=f->next)\n\t{\n\t\tEmitFaceVertexes (node, f);\n\t}\n\n\tfor (i=0 ; i<2 ; i++)\n\t\tEmitVertexes_r (node->children[i]);\n}\n\n\n#ifdef USE_HASHING\n/*\n==========\nFindEdgeVerts\n\nUses the hash tables to cut down to a small number\n==========\n*/\nvoid FindEdgeVerts (vec3_t v1, vec3_t v2)\n{\n\tint\t\tx1, x2, y1, y2, t;\n\tint\t\tx, y;\n\tint\t\tvnum;\n\n#if 0\n{\n\tint\t\ti;\n\tnum_edge_verts = numvertexes-1;\n\tfor (i=0 ; i<numvertexes-1 ; i++)\n\t\tedge_verts[i] = i+1;\n}\n#endif\n\n\tx1 = (4096 + (int)(v1[0]+0.5)) >> 7;\n\ty1 = (4096 + (int)(v1[1]+0.5)) >> 7;\n\tx2 = (4096 + (int)(v2[0]+0.5)) >> 7;\n\ty2 = (4096 + (int)(v2[1]+0.5)) >> 7;\n\n\tif (x1 > x2)\n\t{\n\t\tt = x1;\n\t\tx1 = x2;\n\t\tx2 = t;\n\t}\n\tif (y1 > y2)\n\t{\n\t\tt = y1;\n\t\ty1 = y2;\n\t\ty2 = t;\n\t}\n#if 0\n\tx1--;\n\tx2++;\n\ty1--;\n\ty2++;\n\tif (x1 < 0)\n\t\tx1 = 0;\n\tif (x2 >= HASH_SIZE)\n\t\tx2 = HASH_SIZE;\n\tif (y1 < 0)\n\t\ty1 = 0;\n\tif (y2 >= HASH_SIZE)\n\t\ty2 = HASH_SIZE;\n#endif\n\tnum_edge_verts = 0;\n\tfor (x=x1 ; x <= x2 ; x++)\n\t{\n\t\tfor (y=y1 ; y <= y2 ; y++)\n\t\t{\n\t\t\tfor (vnum=hashverts[y*HASH_SIZE+x] ; vnum ; vnum=vertexchain[vnum])\n\t\t\t{\n\t\t\t\tedge_verts[num_edge_verts++] = vnum;\n\t\t\t}\n\t\t}\n\t}\n}\n\n#else\n/*\n==========\nFindEdgeVerts\n\nForced a dumb check of everything\n==========\n*/\nvoid FindEdgeVerts (vec3_t v1, vec3_t v2)\n{\n\tint\t\ti;\n\n\tnum_edge_verts = numvertexes-1;\n\tfor (i=0 ; i<num_edge_verts ; i++)\n\t\tedge_verts[i] = i+1;\n}\n#endif\n\n/*\n==========\nTestEdge\n\nCan be recursively reentered\n==========\n*/\nvoid TestEdge (vec_t start, vec_t end, int p1, int p2, int startvert)\n{\n\tint\t\tj, k;\n\tvec_t\tdist;\n\tvec3_t\tdelta;\n\tvec3_t\texact;\n\tvec3_t\toff;\n\tvec_t\terror;\n\tvec3_t\tp;\n\n\tif (p1 == p2)\n\t{\n\t\tc_degenerate++;\n\t\treturn;\t\t// degenerate edge\n\t}\n\n\tfor (k=startvert ; k<num_edge_verts ; k++)\n\t{\n\t\tj = edge_verts[k];\n\t\tif (j==p1 || j == p2)\n\t\t\tcontinue;\n\n\t\tVectorCopy (dvertexes[j].point, p);\n\n\t\tVectorSubtract (p, edge_start, delta);\n\t\tdist = DotProduct (delta, edge_dir);\n\t\tif (dist <=start || dist >= end)\n\t\t\tcontinue;\t\t// off an end\n\t\tVectorMA (edge_start, dist, edge_dir, exact);\n\t\tVectorSubtract (p, exact, off);\n\t\terror = VectorLength (off);\n\n\t\tif (fabs(error) > OFF_EPSILON)\n\t\t\tcontinue;\t\t// not on the edge\n\n\t\t// break the edge\n\t\tc_tjunctions++;\n\t\tTestEdge (start, dist, p1, j, k+1);\n\t\tTestEdge (dist, end, j, p2, k+1);\n\t\treturn;\n\t}\n\n\t// the edge p1 to p2 is now free of tjunctions\n\tif (numsuperverts >= MAX_SUPERVERTS)\n\t\tError (\"MAX_SUPERVERTS\");\n\tsuperverts[numsuperverts] = p1;\n\tnumsuperverts++;\n}\n\n/*\n==================\nFixFaceEdges\n\n==================\n*/\nvoid FixFaceEdges (node_t *node, face_t *f)\n{\n\tint\t\tp1, p2;\n\tint\t\ti;\n\tvec3_t\te2;\n\tvec_t\tlen;\n\tint\t\tcount[MAX_SUPERVERTS], start[MAX_SUPERVERTS];\n\tint\t\tbase;\n\n\tif (f->merged || f->split[0] || f->split[1])\n\t\treturn;\n\n\tnumsuperverts = 0;\n\n\tfor (i=0 ; i<f->numpoints ; i++)\n\t{\n\t\tp1 = f->vertexnums[i];\n\t\tp2 = f->vertexnums[(i+1)%f->numpoints];\n\n\t\tVectorCopy (dvertexes[p1].point, edge_start);\n\t\tVectorCopy (dvertexes[p2].point, e2);\n\n\t\tFindEdgeVerts (edge_start, e2);\n\n\t\tVectorSubtract (e2, edge_start, edge_dir);\n\t\tlen = VectorNormalize(edge_dir);\n\n\t\tstart[i] = numsuperverts;\n\t\tTestEdge (0, len, p1, p2, 0);\n\n\t\tcount[i] = numsuperverts - start[i];\n\t}\n\n\tif (numsuperverts < 3)\n\t{\t// entire face collapsed\n\t\tf->numpoints = 0;\n\t\tc_facecollapse++;\n\t\treturn;\n\t}\n\n\t// we want to pick a vertex that doesn't have tjunctions\n\t// on either side, which can cause artifacts on trifans,\n\t// especially underwater\n\tfor (i=0 ; i<f->numpoints ; i++)\n\t{\n\t\tif (count[i] == 1 && count[(i+f->numpoints-1)%f->numpoints] == 1)\n\t\t\tbreak;\n\t}\n\tif (i == f->numpoints)\n\t{\n\t\tf->badstartvert = true;\n\t\tc_badstartverts++;\n\t\tbase = 0;\n\t}\n\telse\n\t{\t// rotate the vertex order\n\t\tbase = start[i];\n\t}\n\n\t// this may fragment the face if > MAXEDGES\n\tFaceFromSuperverts (node, f, base);\n}\n\n/*\n==================\nFixEdges_r\n==================\n*/\nvoid FixEdges_r (node_t *node)\n{\n\tint\t\ti;\n\tface_t\t*f;\n\n\tif (node->planenum == PLANENUM_LEAF)\n\t\treturn;\n\n\tfor (f=node->faces ; f ; f=f->next)\n\t\tFixFaceEdges (node, f);\n\n\tfor (i=0 ; i<2 ; i++)\n\t\tFixEdges_r (node->children[i]);\n}\n\n/*\n===========\nFixTjuncs\n\n===========\n*/\nvoid FixTjuncs (node_t *headnode)\n{\n\t// snap and merge all vertexes\n\tqprintf (\"---- snap verts ----\\n\");\n\tmemset (hashverts, 0, sizeof(hashverts));\n\tc_totalverts = 0;\n\tc_uniqueverts = 0;\n\tc_faceoverflows = 0;\n\tEmitVertexes_r (headnode);\n\tqprintf (\"%i unique from %i\\n\", c_uniqueverts, c_totalverts);\n\n\t// break edges on tjunctions\n\tqprintf (\"---- tjunc ----\\n\");\n\tc_tryedges = 0;\n\tc_degenerate = 0;\n\tc_facecollapse = 0;\n\tc_tjunctions = 0;\n\tif (!notjunc)\n\t\tFixEdges_r (headnode);\n\tqprintf (\"%5i edges degenerated\\n\", c_degenerate);\n\tqprintf (\"%5i faces degenerated\\n\", c_facecollapse);\n\tqprintf (\"%5i edges added by tjunctions\\n\", c_tjunctions);\n\tqprintf (\"%5i faces added by tjunctions\\n\", c_faceoverflows);\n\tqprintf (\"%5i bad start verts\\n\", c_badstartverts);\n}\n\n\n//========================================================\n\nint\t\tc_faces;\n\nface_t\t*AllocFace (void)\n{\n\tface_t\t*f;\n\n\tf = GetMemory(sizeof(*f));\n\tmemset (f, 0, sizeof(*f));\n\tc_faces++;\n\n\treturn f;\n}\n\nface_t *NewFaceFromFace (face_t *f)\n{\n\tface_t\t*newf;\n\n\tnewf = AllocFace ();\n\t*newf = *f;\n\tnewf->merged = NULL;\n\tnewf->split[0] = newf->split[1] = NULL;\n\tnewf->w = NULL;\n\treturn newf;\n}\n\nvoid FreeFace (face_t *f)\n{\n\tif (f->w)\n\t\tFreeWinding (f->w);\n\tFreeMemory(f);\n\tc_faces--;\n}\n\n//========================================================\n\n/*\n==================\nGetEdge\n\nCalled by writebsp.\nDon't allow four way edges\n==================\n*/\nint GetEdge2 (int v1, int v2,  face_t *f)\n{\n\tdedge_t\t*edge;\n\tint\t\ti;\n\n\tc_tryedges++;\n\n\tif (!noshare)\n\t{\n\t\tfor (i=firstmodeledge ; i < numedges ; i++)\n\t\t{\n\t\t\tedge = &dedges[i];\n\t\t\tif (v1 == edge->v[1] && v2 == edge->v[0]\n\t\t\t&& edgefaces[i][0]->contents == f->contents)\n\t\t\t{\n\t\t\t\tif (edgefaces[i][1])\n\t//\t\t\t\tprintf (\"WARNING: multiple backward edge\\n\");\n\t\t\t\t\tcontinue;\n\t\t\t\tedgefaces[i][1] = f;\n\t\t\t\treturn -i;\n\t\t\t}\n\t#if 0\n\t\t\tif (v1 == edge->v[0] && v2 == edge->v[1])\n\t\t\t{\n\t\t\t\tprintf (\"WARNING: multiple forward edge\\n\");\n\t\t\t\treturn i;\n\t\t\t}\n\t#endif\n\t\t}\n\t}\n\n// emit an edge\n\tif (numedges >= MAX_MAP_EDGES)\n\t\tError (\"numedges == MAX_MAP_EDGES\");\n\tedge = &dedges[numedges];\n\tnumedges++;\n\tedge->v[0] = v1;\n\tedge->v[1] = v2;\n\tedgefaces[numedges-1][0] = f;\n\t\n\treturn numedges-1;\n}\n\n/*\n===========================================================================\n\nFACE MERGING\n\n===========================================================================\n*/\n\n/*\n=============\nTryMerge\n\nIf two polygons share a common edge and the edges that meet at the\ncommon points are both inside the other polygons, merge them\n\nReturns NULL if the faces couldn't be merged, or the new face.\nThe originals will NOT be freed.\n=============\n*/\nface_t *TryMerge (face_t *f1, face_t *f2, vec3_t planenormal)\n{\n\tface_t\t\t*newf;\n\twinding_t\t*nw;\n\n\tif (!f1->w || !f2->w)\n\t\treturn NULL;\n\tif (f1->texinfo != f2->texinfo)\n\t\treturn NULL;\n\tif (f1->planenum != f2->planenum)\t// on front and back sides\n\t\treturn NULL;\n\tif (f1->contents != f2->contents)\n\t\treturn NULL;\n\t\t\n\n\tnw = TryMergeWinding (f1->w, f2->w, planenormal);\n\tif (!nw)\n\t\treturn NULL;\n\n\tc_merge++;\n\tnewf = NewFaceFromFace (f1);\n\tnewf->w = nw;\n\n\tf1->merged = newf;\n\tf2->merged = newf;\n\n\treturn newf;\n}\n\n/*\n===============\nMergeNodeFaces\n===============\n*/\nvoid MergeNodeFaces (node_t *node)\n{\n\tface_t\t*f1, *f2, *end;\n\tface_t\t*merged;\n\tplane_t\t*plane;\n\n\tplane = &mapplanes[node->planenum];\n\tmerged = NULL;\n\t\n\tfor (f1 = node->faces ; f1 ; f1 = f1->next)\n\t{\n\t\tif (f1->merged || f1->split[0] || f1->split[1])\n\t\t\tcontinue;\n\n\t\tfor (f2 = node->faces ; f2 != f1 ; f2=f2->next)\n\t\t{\n\t\t\tif (f2->merged || f2->split[0] || f2->split[1])\n\t\t\t\tcontinue;\n\n\t\t\t//IDBUG: always passes the face's node's normal to TryMerge()\n\t\t\t//regardless of which side the face is on. Approximately 50% of\n\t\t\t//the time the face will be on the other side of node, and thus\n\t\t\t//the result of the convex/concave test in TryMergeWinding(),\n\t\t\t//which depends on the normal, is flipped. This causes faces\n\t\t\t//that shouldn't be merged to be merged and faces that\n\t\t\t//should be merged to not be merged. \n\t\t\t//the following added line fixes this bug\n\t\t\t//thanks to: Alexander Malmberg <alexander@malmberg.org>\n\t\t\tplane = &mapplanes[f1->planenum];\n\t\t\t//\n\t\t\tmerged = TryMerge (f1, f2, plane->normal);\n\t\t\tif (!merged)\n\t\t\t\tcontinue;\n\n\t\t\t// add merged to the end of the node face list \n\t\t\t// so it will be checked against all the faces again\n\t\t\tfor (end = node->faces ; end->next ; end = end->next)\n\t\t\t;\n\t\t\tmerged->next = NULL;\n\t\t\tend->next = merged;\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n//=====================================================================\n\n/*\n===============\nSubdivideFace\n\nChop up faces that are larger than we want in the surface cache\n===============\n*/\nvoid SubdivideFace (node_t *node, face_t *f)\n{\n\tfloat\t\tmins, maxs;\n\tvec_t\t\tv;\n\tint\t\t\taxis, i;\n\ttexinfo_t\t*tex;\n\tvec3_t\t\ttemp;\n\tvec_t\t\tdist;\n\twinding_t\t*w, *frontw, *backw;\n\n\tif (f->merged)\n\t\treturn;\n\n// special (non-surface cached) faces don't need subdivision\n\ttex = &texinfo[f->texinfo];\n\n\tif ( tex->flags & (SURF_WARP|SURF_SKY) )\n\t{\n\t\treturn;\n\t}\n\n\tfor (axis = 0 ; axis < 2 ; axis++)\n\t{\n\t\twhile (1)\n\t\t{\n\t\t\tmins = 999999;\n\t\t\tmaxs = -999999;\n\t\t\t\n\t\t\tVectorCopy (tex->vecs[axis], temp);\n\t\t\tw = f->w;\n\t\t\tfor (i=0 ; i<w->numpoints ; i++)\n\t\t\t{\n\t\t\t\tv = DotProduct (w->p[i], temp);\n\t\t\t\tif (v < mins)\n\t\t\t\t\tmins = v;\n\t\t\t\tif (v > maxs)\n\t\t\t\t\tmaxs = v;\n\t\t\t}\n#if 0\n\t\t\tif (maxs - mins <= 0)\n\t\t\t\tError (\"zero extents\");\n#endif\n\t\t\tif (axis == 2)\n\t\t\t{\t// allow double high walls\n\t\t\t\tif (maxs - mins <= subdivide_size/* *2 */)\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (maxs - mins <= subdivide_size)\n\t\t\t\tbreak;\n\t\t\t\n\t\t// split it\n\t\t\tc_subdivide++;\n\t\t\t\n\t\t\tv = VectorNormalize (temp);\n\n\t\t\tdist = (mins + subdivide_size - 16)/v;\n\n\t\t\tClipWindingEpsilon (w, temp, dist, ON_EPSILON, &frontw, &backw);\n\t\t\tif (!frontw || !backw)\n\t\t\t\tError (\"SubdivideFace: didn't split the polygon\");\n\n\t\t\tf->split[0] = NewFaceFromFace (f);\n\t\t\tf->split[0]->w = frontw;\n\t\t\tf->split[0]->next = node->faces;\n\t\t\tnode->faces = f->split[0];\n\n\t\t\tf->split[1] = NewFaceFromFace (f);\n\t\t\tf->split[1]->w = backw;\n\t\t\tf->split[1]->next = node->faces;\n\t\t\tnode->faces = f->split[1];\n\n\t\t\tSubdivideFace (node, f->split[0]);\n\t\t\tSubdivideFace (node, f->split[1]);\n\t\t\treturn;\n\t\t}\n\t}\n}\n\nvoid SubdivideNodeFaces (node_t *node)\n{\n\tface_t\t*f;\n\n\tfor (f = node->faces ; f ; f=f->next)\n\t{\n\t\tSubdivideFace (node, f);\n\t}\n}\n\n//===========================================================================\n\nint\tc_nodefaces;\n\n\n/*\n============\nFaceFromPortal\n\n============\n*/\nface_t *FaceFromPortal (portal_t *p, int pside)\n{\n\tface_t\t*f;\n\tside_t\t*side;\n\n\tside = p->side;\n\tif (!side)\n\t\treturn NULL;\t// portal does not bridge different visible contents\n\n\tf = AllocFace ();\n\n\tf->texinfo = side->texinfo;\n\tf->planenum = (side->planenum & ~1) | pside;\n\tf->portal = p;\n\n\tif ( (p->nodes[pside]->contents & CONTENTS_WINDOW)\n\t\t&& VisibleContents(p->nodes[!pside]->contents^p->nodes[pside]->contents) == CONTENTS_WINDOW )\n\t\treturn NULL;\t// don't show insides of windows\n\n\tif (pside)\n\t{\n\t\tf->w = ReverseWinding(p->winding);\n\t\tf->contents = p->nodes[1]->contents;\n\t}\n\telse\n\t{\n\t\tf->w = CopyWinding(p->winding);\n\t\tf->contents = p->nodes[0]->contents;\n\t}\n\treturn f;\n}\n\n\n/*\n===============\nMakeFaces_r\n\nIf a portal will make a visible face,\nmark the side that originally created it\n\n  solid / empty : solid\n  solid / water : solid\n  water / empty : water\n  water / water : none\n===============\n*/\nvoid MakeFaces_r (node_t *node)\n{\n\tportal_t\t*p;\n\tint\t\t\ts;\n\n\t// recurse down to leafs\n\tif (node->planenum != PLANENUM_LEAF)\n\t{\n\t\tMakeFaces_r (node->children[0]);\n\t\tMakeFaces_r (node->children[1]);\n\n\t\t// merge together all visible faces on the node\n\t\tif (!nomerge)\n\t\t\tMergeNodeFaces (node);\n\t\tif (!nosubdiv)\n\t\t\tSubdivideNodeFaces (node);\n\n\t\treturn;\n\t}\n\n\t// solid leafs never have visible faces\n\tif (node->contents & CONTENTS_SOLID)\n\t\treturn;\n\n\t// see which portals are valid\n\tfor (p=node->portals ; p ; p = p->next[s])\n\t{\n\t\ts = (p->nodes[1] == node);\n\n\t\tp->face[s] = FaceFromPortal (p, s);\n\t\tif (p->face[s])\n\t\t{\n\t\t\tc_nodefaces++;\n\t\t\tp->face[s]->next = p->onnode->faces;\n\t\t\tp->onnode->faces = p->face[s];\n\t\t}\n\t}\n}\n\n/*\n============\nMakeFaces\n============\n*/\nvoid MakeFaces (node_t *node)\n{\n\tqprintf (\"--- MakeFaces ---\\n\");\n\tc_merge = 0;\n\tc_subdivide = 0;\n\tc_nodefaces = 0;\n\n\tMakeFaces_r (node);\n\n\tqprintf (\"%5i makefaces\\n\", c_nodefaces);\n\tqprintf (\"%5i merged\\n\", c_merge);\n\tqprintf (\"%5i subdivided\\n\", c_subdivide);\n}\n"
  },
  {
    "path": "code/bspc/gldraw.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include <windows.h>\n#include <GL/gl.h>\n#include <GL/glu.h>\n#include <GL/glaux.h>\n\n#include \"qbsp.h\"\n\n// can't use the glvertex3fv functions, because the vec3_t fields\n// could be either floats or doubles, depending on DOUBLEVEC_T\n\nqboolean\tdrawflag;\nvec3_t\tdraw_mins, draw_maxs;\n\n\n#define\tWIN_SIZE\t512\n\nvoid InitWindow (void)\n{\n    auxInitDisplayMode (AUX_SINGLE | AUX_RGB);\n    auxInitPosition (0, 0, WIN_SIZE, WIN_SIZE);\n    auxInitWindow (\"qcsg\");\n}\n\nvoid Draw_ClearWindow (void)\n{\n\tstatic int\tinit;\n\tint\t\tw, h, g;\n\tvec_t\tmx, my;\n\n\tif (!drawflag)\n\t\treturn;\n\n\tif (!init)\n\t{\n\t\tinit = true;\n\t\tInitWindow ();\n\t}\n\n\tglClearColor (1,0.8,0.8,0);\n\tglClear (GL_COLOR_BUFFER_BIT);\n\n\tw = (draw_maxs[0] - draw_mins[0]);\n\th = (draw_maxs[1] - draw_mins[1]);\n\n\tmx = draw_mins[0] + w/2;\n\tmy = draw_mins[1] + h/2;\n\n\tg = w > h ? w : h;\n\n\tglLoadIdentity ();\n    gluPerspective (90,  1,  2,  16384);\n\tgluLookAt (mx, my, draw_maxs[2] + g/2, mx , my, draw_maxs[2], 0, 1, 0);\n\n\tglColor3f (0,0,0);\n//\tglPolygonMode (GL_FRONT_AND_BACK, GL_LINE);\n\tglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);\n\tglDisable (GL_DEPTH_TEST);\n\tglEnable (GL_BLEND);\n\tglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\n\n#if 0\n\tglColor4f (1,0,0,0.5);\n\tglBegin (GL_POLYGON);\n\n\tglVertex3f (0, 500, 0);\n\tglVertex3f (0, 900, 0);\n\tglVertex3f (0, 900, 100);\n\tglVertex3f (0, 500, 100);\n\n\tglEnd ();\n#endif\n\n\tglFlush ();\n\n}\n\nvoid Draw_SetRed (void)\n{\n\tif (!drawflag)\n\t\treturn;\n\n\tglColor3f (1,0,0);\n}\n\nvoid Draw_SetGrey (void)\n{\n\tif (!drawflag)\n\t\treturn;\n\n\tglColor3f (0.5,0.5,0.5);\n}\n\nvoid Draw_SetBlack (void)\n{\n\tif (!drawflag)\n\t\treturn;\n\n\tglColor3f (0,0,0);\n}\n\nvoid DrawWinding (winding_t *w)\n{\n\tint\t\ti;\n\n\tif (!drawflag)\n\t\treturn;\n\n\tglColor4f (0,0,0,0.5);\n\tglBegin (GL_LINE_LOOP);\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\tglVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );\n\tglEnd ();\n\n\tglColor4f (0,1,0,0.3);\n\tglBegin (GL_POLYGON);\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\tglVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );\n\tglEnd ();\n\n\tglFlush ();\n}\n\nvoid DrawAuxWinding (winding_t *w)\n{\n\tint\t\ti;\n\n\tif (!drawflag)\n\t\treturn;\n\n\tglColor4f (0,0,0,0.5);\n\tglBegin (GL_LINE_LOOP);\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\tglVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );\n\tglEnd ();\n\n\tglColor4f (1,0,0,0.3);\n\tglBegin (GL_POLYGON);\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\tglVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );\n\tglEnd ();\n\n\tglFlush ();\n}\n\n//============================================================\n\n#define\tGLSERV_PORT\t25001\n\nqboolean\twins_init;\nint\t\t\tdraw_socket;\n\nvoid GLS_BeginScene (void)\n{\n\tWSADATA\twinsockdata;\n\tWORD\twVersionRequested; \n\tstruct sockaddr_in\taddress;\n\tint\t\tr;\n\n\tif (!wins_init)\n\t{\n\t\twins_init = true;\n\n\t\twVersionRequested = MAKEWORD(1, 1); \n\n\t\tr = WSAStartup (MAKEWORD(1, 1), &winsockdata);\n\n\t\tif (r)\n\t\t\tError (\"Winsock initialization failed.\");\n\n\t}\n\n\t// connect a socket to the server\n\n\tdraw_socket = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);\n\tif (draw_socket == -1)\n\t\tError (\"draw_socket failed\");\n\n\taddress.sin_family = AF_INET;\n\taddress.sin_addr.s_addr = htonl(INADDR_LOOPBACK);\n\taddress.sin_port = GLSERV_PORT;\n\tr = connect (draw_socket, (struct sockaddr *)&address, sizeof(address));\n\tif (r == -1)\n\t{\n\t\tclosesocket (draw_socket);\n\t\tdraw_socket = 0;\n\t}\n}\n\nvoid GLS_Winding (winding_t *w, int code)\n{\n\tbyte\tbuf[1024];\n\tint\t\ti, j;\n\n\tif (!draw_socket)\n\t\treturn;\n\n\t((int *)buf)[0] = w->numpoints;\n\t((int *)buf)[1] = code;\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t\t((float *)buf)[2+i*3+j] = w->p[i][j];\n\n\tsend (draw_socket, buf, w->numpoints*12+8, 0);\n}\n\nvoid GLS_EndScene (void)\n{\n\tclosesocket (draw_socket);\n\tdraw_socket = 0;\n}\n"
  },
  {
    "path": "code/bspc/glfile.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n\nint\t\tc_glfaces;\n\nint PortalVisibleSides (portal_t *p)\n{\n\tint\t\tfcon, bcon;\n\n\tif (!p->onnode)\n\t\treturn 0;\t\t// outside\n\n\tfcon = p->nodes[0]->contents;\n\tbcon = p->nodes[1]->contents;\n\n\t// same contents never create a face\n\tif (fcon == bcon)\n\t\treturn 0;\n\n\t// FIXME: is this correct now?\n\tif (!fcon)\n\t\treturn 1;\n\tif (!bcon)\n\t\treturn 2;\n\treturn 0;\n}\n\nvoid OutputWinding (winding_t *w, FILE *glview)\n{\n\tstatic\tint\tlevel = 128;\n\tvec_t\t\tlight;\n\tint\t\t\ti;\n\n\tfprintf (glview, \"%i\\n\", w->numpoints);\n\tlevel+=28;\n\tlight = (level&255)/255.0;\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tfprintf (glview, \"%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f\\n\",\n\t\t\tw->p[i][0],\n\t\t\tw->p[i][1],\n\t\t\tw->p[i][2],\n\t\t\tlight,\n\t\t\tlight,\n\t\t\tlight);\n\t}\n\tfprintf (glview, \"\\n\");\n}\n\n/*\n=============\nOutputPortal\n=============\n*/\nvoid OutputPortal (portal_t *p, FILE *glview)\n{\n\twinding_t\t*w;\n\tint\t\tsides;\n\n\tsides = PortalVisibleSides (p);\n\tif (!sides)\n\t\treturn;\n\n\tc_glfaces++;\n\n\tw = p->winding;\n\n\tif (sides == 2)\t\t// back side\n\t\tw = ReverseWinding (w);\n\n\tOutputWinding (w, glview);\n\n\tif (sides == 2)\n\t\tFreeWinding(w);\n}\n\n/*\n=============\nWriteGLView_r\n=============\n*/\nvoid WriteGLView_r (node_t *node, FILE *glview)\n{\n\tportal_t\t*p, *nextp;\n\n\tif (node->planenum != PLANENUM_LEAF)\n\t{\n\t\tWriteGLView_r (node->children[0], glview);\n\t\tWriteGLView_r (node->children[1], glview);\n\t\treturn;\n\t}\n\n\t// write all the portals\n\tfor (p=node->portals ; p ; p=nextp)\n\t{\n\t\tif (p->nodes[0] == node)\n\t\t{\n\t\t\tOutputPortal (p, glview);\n\t\t\tnextp = p->next[0];\n\t\t}\n\t\telse\n\t\t\tnextp = p->next[1];\n\t}\n}\n\n/*\n=============\nWriteGLView\n=============\n*/\nvoid WriteGLView (tree_t *tree, char *source)\n{\n\tchar\tname[1024];\n\tFILE\t*glview;\n\n\tc_glfaces = 0;\n\tsprintf (name, \"%s%s.gl\",outbase, source);\n\tprintf (\"Writing %s\\n\", name);\n\n\tglview = fopen (name, \"w\");\n\tif (!glview)\n\t\tError (\"Couldn't open %s\", name);\n\tWriteGLView_r (tree->headnode, glview);\n\tfclose (glview);\n\n\tprintf (\"%5i c_glfaces\\n\", c_glfaces);\n}\n\n"
  },
  {
    "path": "code/bspc/l_bsp_ent.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"l_cmd.h\"\n#include \"l_math.h\"\n#include \"l_mem.h\"\n#include \"l_log.h\"\n#include \"../botlib/l_script.h\"\n#include \"l_bsp_ent.h\"\n\n#define\tMAX_KEY\t\t32\n#define\tMAX_VALUE\t1024\n\nint num_entities;\nentity_t\tentities[MAX_MAP_ENTITIES];\n\nvoid StripTrailing(char *e)\n{\n\tchar\t*s;\n\n\ts = e + strlen(e)-1;\n\twhile (s >= e && *s <= 32)\n\t{\n\t\t*s = 0;\n\t\ts--;\n\t}\n}\n\n/*\n=================\nParseEpair\n=================\n*/\nepair_t *ParseEpair(script_t *script)\n{\n\tepair_t *e;\n\ttoken_t token;\n\n\te = GetMemory(sizeof(epair_t));\n\tmemset (e, 0, sizeof(epair_t));\n\t\n\tPS_ExpectAnyToken(script, &token);\n\tStripDoubleQuotes(token.string);\n\tif (strlen(token.string) >= MAX_KEY-1)\n\t\tError (\"ParseEpair: token %s too long\", token.string);\n\te->key = copystring(token.string);\n\tPS_ExpectAnyToken(script, &token);\n\tStripDoubleQuotes(token.string);\n\tif (strlen(token.string) >= MAX_VALUE-1)\n\t\tError (\"ParseEpair: token %s too long\", token.string);\n\te->value = copystring(token.string);\n\n\t// strip trailing spaces\n\tStripTrailing(e->key);\n\tStripTrailing(e->value);\n\n\treturn e;\n} //end of the function ParseEpair\n\n\n/*\n================\nParseEntity\n================\n*/\nqboolean\tParseEntity(script_t *script)\n{\n\tepair_t *e;\n\tentity_t\t*mapent;\n\ttoken_t token;\n\n\tif (!PS_ReadToken(script, &token))\n\t\treturn false;\n\n\tif (strcmp(token.string, \"{\"))\n\t\tError (\"ParseEntity: { not found\");\n\t\n\tif (num_entities == MAX_MAP_ENTITIES)\n\t\tError (\"num_entities == MAX_MAP_ENTITIES\");\n\n\tmapent = &entities[num_entities];\n\tnum_entities++;\n\n\tdo\n\t{\n\t\tif (!PS_ReadToken(script, &token))\n\t\t\tError (\"ParseEntity: EOF without closing brace\");\n\t\tif (!strcmp(token.string, \"}\") )\n\t\t\tbreak;\n\t\tPS_UnreadLastToken(script);\n\t\te = ParseEpair(script);\n\t\te->next = mapent->epairs;\n\t\tmapent->epairs = e;\n\t} while (1);\n\t\n\treturn true;\n} //end of the function ParseEntity\n\nvoid PrintEntity (entity_t *ent)\n{\n\tepair_t\t*ep;\n\t\n\tprintf (\"------- entity %p -------\\n\", ent);\n\tfor (ep=ent->epairs ; ep ; ep=ep->next)\n\t{\n\t\tprintf (\"%s = %s\\n\", ep->key, ep->value);\n\t}\n\n}\n\nvoid \tSetKeyValue (entity_t *ent, char *key, char *value)\n{\n\tepair_t\t*ep;\n\t\n\tfor (ep=ent->epairs ; ep ; ep=ep->next)\n\t\tif (!strcmp (ep->key, key) )\n\t\t{\n\t\t\tFreeMemory(ep->value);\n\t\t\tep->value = copystring(value);\n\t\t\treturn;\n\t\t}\n\tep = GetMemory(sizeof(*ep));\n\tep->next = ent->epairs;\n\tent->epairs = ep;\n\tep->key = copystring(key);\n\tep->value = copystring(value);\n}\n\nchar \t*ValueForKey (entity_t *ent, char *key)\n{\n\tepair_t\t*ep;\n\t\n\tfor (ep=ent->epairs ; ep ; ep=ep->next)\n\t\tif (!strcmp (ep->key, key) )\n\t\t\treturn ep->value;\n\treturn \"\";\n}\n\nvec_t\tFloatForKey (entity_t *ent, char *key)\n{\n\tchar\t*k;\n\t\n\tk = ValueForKey (ent, key);\n\treturn atof(k);\n}\n\nvoid \tGetVectorForKey (entity_t *ent, char *key, vec3_t vec)\n{\n\tchar\t*k;\n\tdouble\tv1, v2, v3;\n\n\tk = ValueForKey (ent, key);\n// scanf into doubles, then assign, so it is vec_t size independent\n\tv1 = v2 = v3 = 0;\n\tsscanf (k, \"%lf %lf %lf\", &v1, &v2, &v3);\n\tvec[0] = v1;\n\tvec[1] = v2;\n\tvec[2] = v3;\n}\n\n\n"
  },
  {
    "path": "code/bspc/l_bsp_ent.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#ifndef MAX_MAP_ENTITIES\n#define\tMAX_MAP_ENTITIES\t2048\n#endif\n\ntypedef struct epair_s\n{\n\tstruct epair_s\t*next;\n\tchar\t*key;\n\tchar\t*value;\n} epair_t;\n\ntypedef struct\n{\n\tvec3_t\t\torigin;\n\tint\t\t\tfirstbrush;\n\tint\t\t\tnumbrushes;\n\tepair_t\t\t*epairs;\n\t// only valid for func_areaportals\n\tint\t\t\tareaportalnum;\n\tint\t\t\tportalareas[2];\n\tint\t\t\tmodelnum;\t//for bsp 2 map conversion\n   qboolean\t\twasdetail;\t//for SIN\n} entity_t;\n\nextern\tint num_entities;\nextern\tentity_t entities[MAX_MAP_ENTITIES];\n\nvoid StripTrailing(char *e);\nvoid SetKeyValue(entity_t *ent, char *key, char *value);\nchar *ValueForKey(entity_t *ent, char *key); // will return \"\" if not present\nvec_t FloatForKey(entity_t *ent, char *key);\nvoid GetVectorForKey(entity_t *ent, char *key, vec3_t vec);\nqboolean ParseEntity(script_t *script);\nepair_t *ParseEpair(script_t *script);\nvoid PrintEntity(entity_t *ent);\n\n"
  },
  {
    "path": "code/bspc/l_bsp_hl.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"l_cmd.h\"\n#include \"l_math.h\"\n#include \"l_mem.h\"\n#include \"l_log.h\"\n#include \"../botlib/l_script.h\"\n#include \"l_bsp_hl.h\"\n#include \"l_bsp_ent.h\"\n\n//=============================================================================\n\nint\t\t\t\thl_nummodels;\nhl_dmodel_t\t\t*hl_dmodels;//[HL_MAX_MAP_MODELS];\nint\t\t\t\thl_dmodels_checksum;\n\nint\t\t\t\thl_visdatasize;\nbyte\t\t\t\t*hl_dvisdata;//[HL_MAX_MAP_VISIBILITY];\nint\t\t\t\thl_dvisdata_checksum;\n\nint\t\t\t\thl_lightdatasize;\nbyte\t\t\t\t*hl_dlightdata;//[HL_MAX_MAP_LIGHTING];\nint\t\t\t\thl_dlightdata_checksum;\n\nint\t\t\t\thl_texdatasize;\nbyte\t\t\t\t*hl_dtexdata;//[HL_MAX_MAP_MIPTEX]; // (dmiptexlump_t)\nint\t\t\t\thl_dtexdata_checksum;\n\nint\t\t\t\thl_entdatasize;\nchar\t\t\t\t*hl_dentdata;//[HL_MAX_MAP_ENTSTRING];\nint\t\t\t\thl_dentdata_checksum;\n\nint\t\t\t\thl_numleafs;\nhl_dleaf_t\t\t*hl_dleafs;//[HL_MAX_MAP_LEAFS];\nint\t\t\t\thl_dleafs_checksum;\n\nint\t\t\t\thl_numplanes;\nhl_dplane_t\t\t*hl_dplanes;//[HL_MAX_MAP_PLANES];\nint\t\t\t\thl_dplanes_checksum;\n\nint\t\t\t\thl_numvertexes;\nhl_dvertex_t\t*hl_dvertexes;//[HL_MAX_MAP_VERTS];\nint\t\t\t\thl_dvertexes_checksum;\n\nint\t\t\t\thl_numnodes;\nhl_dnode_t\t\t*hl_dnodes;//[HL_MAX_MAP_NODES];\nint\t\t\t\thl_dnodes_checksum;\n\nint\t\t\t\thl_numtexinfo;\nhl_texinfo_t\t*hl_texinfo;//[HL_MAX_MAP_TEXINFO];\nint\t\t\t\thl_texinfo_checksum;\n\nint\t\t\t\thl_numfaces;\nhl_dface_t\t\t*hl_dfaces;//[HL_MAX_MAP_FACES];\nint\t\t\t\thl_dfaces_checksum;\n\nint\t\t\t\thl_numclipnodes;\nhl_dclipnode_t\t*hl_dclipnodes;//[HL_MAX_MAP_CLIPNODES];\nint\t\t\t\thl_dclipnodes_checksum;\n\nint\t\t\t\thl_numedges;\nhl_dedge_t\t\t*hl_dedges;//[HL_MAX_MAP_EDGES];\nint\t\t\t\thl_dedges_checksum;\n\nint\t\t\t\thl_nummarksurfaces;\nunsigned short\t*hl_dmarksurfaces;//[HL_MAX_MAP_MARKSURFACES];\nint\t\t\t\thl_dmarksurfaces_checksum;\n\nint\t\t\t\thl_numsurfedges;\nint\t\t\t\t*hl_dsurfedges;//[HL_MAX_MAP_SURFEDGES];\nint\t\t\t\thl_dsurfedges_checksum;\n\n//int\t\t\t\tnum_entities;\n//entity_t\t\t\tentities[HL_MAX_MAP_ENTITIES];\n\n\n//#ifdef //ME\n\nint hl_bspallocated = false;\nint hl_allocatedbspmem = 0;\n\nvoid HL_AllocMaxBSP(void)\n{\n\t//models\n\thl_nummodels = 0;\n\thl_dmodels = (hl_dmodel_t *) GetMemory(HL_MAX_MAP_MODELS * sizeof(hl_dmodel_t));\n\thl_allocatedbspmem = HL_MAX_MAP_MODELS * sizeof(hl_dmodel_t);\n\t//visibility\n\thl_visdatasize = 0;\n\thl_dvisdata = (byte *) GetMemory(HL_MAX_MAP_VISIBILITY * sizeof(byte));\n\thl_allocatedbspmem += HL_MAX_MAP_VISIBILITY * sizeof(byte);\n\t//light data\n\thl_lightdatasize = 0;\n\thl_dlightdata = (byte *) GetMemory(HL_MAX_MAP_LIGHTING * sizeof(byte));\n\thl_allocatedbspmem += HL_MAX_MAP_LIGHTING * sizeof(byte);\n\t//texture data\n\thl_texdatasize = 0;\n\thl_dtexdata = (byte *) GetMemory(HL_MAX_MAP_MIPTEX * sizeof(byte)); // (dmiptexlump_t)\n\thl_allocatedbspmem += HL_MAX_MAP_MIPTEX * sizeof(byte);\n\t//entities\n\thl_entdatasize = 0;\n\thl_dentdata = (char *) GetMemory(HL_MAX_MAP_ENTSTRING * sizeof(char));\n\thl_allocatedbspmem += HL_MAX_MAP_ENTSTRING * sizeof(char);\n\t//leaves\n\thl_numleafs = 0;\n\thl_dleafs = (hl_dleaf_t *) GetMemory(HL_MAX_MAP_LEAFS * sizeof(hl_dleaf_t));\n\thl_allocatedbspmem += HL_MAX_MAP_LEAFS * sizeof(hl_dleaf_t);\n\t//planes\n\thl_numplanes = 0;\n\thl_dplanes = (hl_dplane_t *) GetMemory(HL_MAX_MAP_PLANES * sizeof(hl_dplane_t));\n\thl_allocatedbspmem += HL_MAX_MAP_PLANES * sizeof(hl_dplane_t);\n\t//vertexes\n\thl_numvertexes = 0;\n\thl_dvertexes = (hl_dvertex_t *) GetMemory(HL_MAX_MAP_VERTS * sizeof(hl_dvertex_t));\n\thl_allocatedbspmem += HL_MAX_MAP_VERTS * sizeof(hl_dvertex_t);\n\t//nodes\n\thl_numnodes = 0;\n\thl_dnodes = (hl_dnode_t *) GetMemory(HL_MAX_MAP_NODES * sizeof(hl_dnode_t));\n\thl_allocatedbspmem += HL_MAX_MAP_NODES * sizeof(hl_dnode_t);\n\t//texture info\n\thl_numtexinfo = 0;\n\thl_texinfo = (hl_texinfo_t *) GetMemory(HL_MAX_MAP_TEXINFO * sizeof(hl_texinfo_t));\n\thl_allocatedbspmem += HL_MAX_MAP_TEXINFO * sizeof(hl_texinfo_t);\n\t//faces\n\thl_numfaces = 0;\n\thl_dfaces = (hl_dface_t *) GetMemory(HL_MAX_MAP_FACES * sizeof(hl_dface_t));\n\thl_allocatedbspmem += HL_MAX_MAP_FACES * sizeof(hl_dface_t);\n\t//clip nodes\n\thl_numclipnodes = 0;\n\thl_dclipnodes = (hl_dclipnode_t *) GetMemory(HL_MAX_MAP_CLIPNODES * sizeof(hl_dclipnode_t));\n\thl_allocatedbspmem += HL_MAX_MAP_CLIPNODES * sizeof(hl_dclipnode_t);\n\t//edges\n\thl_numedges = 0;\n\thl_dedges = (hl_dedge_t *) GetMemory(HL_MAX_MAP_EDGES * sizeof(hl_dedge_t));\n\thl_allocatedbspmem += HL_MAX_MAP_EDGES, sizeof(hl_dedge_t);\n\t//mark surfaces\n\thl_nummarksurfaces = 0;\n\thl_dmarksurfaces = (unsigned short *) GetMemory(HL_MAX_MAP_MARKSURFACES * sizeof(unsigned short));\n\thl_allocatedbspmem += HL_MAX_MAP_MARKSURFACES * sizeof(unsigned short);\n\t//surface edges\n\thl_numsurfedges = 0;\n\thl_dsurfedges = (int *) GetMemory(HL_MAX_MAP_SURFEDGES * sizeof(int));\n\thl_allocatedbspmem += HL_MAX_MAP_SURFEDGES * sizeof(int);\n\t//print allocated memory\n\tLog_Print(\"allocated \");\n\tPrintMemorySize(hl_allocatedbspmem);\n\tLog_Print(\" of BSP memory\\n\");\n} //end of the function HL_AllocMaxBSP\n\nvoid HL_FreeMaxBSP(void)\n{\n\t//models\n\thl_nummodels = 0;\n\tFreeMemory(hl_dmodels);\n\thl_dmodels = NULL;\n\t//visibility\n\thl_visdatasize = 0;\n\tFreeMemory(hl_dvisdata);\n\thl_dvisdata = NULL;\n\t//light data\n\thl_lightdatasize = 0;\n\tFreeMemory(hl_dlightdata);\n\thl_dlightdata = NULL;\n\t//texture data\n\thl_texdatasize = 0;\n\tFreeMemory(hl_dtexdata);\n\thl_dtexdata = NULL;\n\t//entities\n\thl_entdatasize = 0;\n\tFreeMemory(hl_dentdata);\n\thl_dentdata = NULL;\n\t//leaves\n\thl_numleafs = 0;\n\tFreeMemory(hl_dleafs);\n\thl_dleafs = NULL;\n\t//planes\n\thl_numplanes = 0;\n\tFreeMemory(hl_dplanes);\n\thl_dplanes = NULL;\n\t//vertexes\n\thl_numvertexes = 0;\n\tFreeMemory(hl_dvertexes);\n\thl_dvertexes = NULL;\n\t//nodes\n\thl_numnodes = 0;\n\tFreeMemory(hl_dnodes);\n\thl_dnodes = NULL;\n\t//texture info\n\thl_numtexinfo = 0;\n\tFreeMemory(hl_texinfo);\n\thl_texinfo = NULL;\n\t//faces\n\thl_numfaces = 0;\n\tFreeMemory(hl_dfaces);\n\thl_dfaces = NULL;\n\t//clip nodes\n\thl_numclipnodes = 0;\n\tFreeMemory(hl_dclipnodes);\n\thl_dclipnodes = NULL;\n\t//edges\n\thl_numedges = 0;\n\tFreeMemory(hl_dedges);\n\thl_dedges = NULL;\n\t//mark surfaces\n\thl_nummarksurfaces = 0;\n\tFreeMemory(hl_dmarksurfaces);\n\thl_dmarksurfaces = NULL;\n\t//surface edges\n\thl_numsurfedges = 0;\n\tFreeMemory(hl_dsurfedges);\n\thl_dsurfedges = NULL;\n\t//\n\tLog_Print(\"freed \");\n\tPrintMemorySize(hl_allocatedbspmem);\n\tLog_Print(\" of BSP memory\\n\");\n\thl_allocatedbspmem = 0;\n} //end of the function HL_FreeMaxBSP\n//#endif //ME\n\n/*\n===============\nFastChecksum\n===============\n*/\n\nint FastChecksum(void *buffer, int bytes)\n{\n\tint\tchecksum = 0;\n\n\twhile( bytes-- )  \n\t\tchecksum = (checksum << 4) ^ *((char *)buffer)++;\n\n\treturn checksum;\n}\n\n/*\n===============\nHL_CompressVis\n===============\n*/\nint HL_CompressVis(byte *vis, byte *dest)\n{\n\tint\t\tj;\n\tint\t\trep;\n\tint\t\tvisrow;\n\tbyte\t*dest_p;\n\t\n\tdest_p = dest;\n\tvisrow = (hl_numleafs + 7)>>3;\n\t\n\tfor (j=0 ; j<visrow ; j++)\n\t{\n\t\t*dest_p++ = vis[j];\n\t\tif (vis[j])\n\t\t\tcontinue;\n\n\t\trep = 1;\n\t\tfor ( j++; j<visrow ; j++)\n\t\t\tif (vis[j] || rep == 255)\n\t\t\t\tbreak;\n\t\t\telse\n\t\t\t\trep++;\n\t\t*dest_p++ = rep;\n\t\tj--;\n\t}\n\t\n\treturn dest_p - dest;\n}\n\n\n/*\n===================\nHL_DecompressVis\n===================\n*/\nvoid HL_DecompressVis (byte *in, byte *decompressed)\n{\n\tint\t\tc;\n\tbyte\t*out;\n\tint\t\trow;\n\n\trow = (hl_numleafs+7)>>3;\t\n\tout = decompressed;\n\n\tdo\n\t{\n\t\tif (*in)\n\t\t{\n\t\t\t*out++ = *in++;\n\t\t\tcontinue;\n\t\t}\n\t\n\t\tc = in[1];\n\t\tin += 2;\n\t\twhile (c)\n\t\t{\n\t\t\t*out++ = 0;\n\t\t\tc--;\n\t\t}\n\t} while (out - decompressed < row);\n}\n\n//=============================================================================\n\n/*\n=============\nHL_SwapBSPFile\n\nByte swaps all data in a bsp file.\n=============\n*/\nvoid HL_SwapBSPFile (qboolean todisk)\n{\n\tint i, j, c;\n\thl_dmodel_t *d;\n\thl_dmiptexlump_t *mtl;\n\n\t\n// models\t\n\tfor (i = 0; i < hl_nummodels; i++)\n\t{\n\t\td = &hl_dmodels[i];\n\n\t\tfor (j = 0; j < HL_MAX_MAP_HULLS; j++)\n\t\t\td->headnode[j] = LittleLong(d->headnode[j]);\n\n\t\td->visleafs = LittleLong(d->visleafs);\n\t\td->firstface = LittleLong(d->firstface);\n\t\td->numfaces = LittleLong(d->numfaces);\n\t\t\n\t\tfor (j = 0; j < 3; j++)\n\t\t{\n\t\t\td->mins[j] = LittleFloat(d->mins[j]);\n\t\t\td->maxs[j] = LittleFloat(d->maxs[j]);\n\t\t\td->origin[j] = LittleFloat(d->origin[j]);\n\t\t}\n\t}\n\n//\n// vertexes\n//\n\tfor (i = 0; i < hl_numvertexes; i++)\n\t{\n\t\tfor (j = 0; j < 3; j++)\n\t\t\thl_dvertexes[i].point[j] = LittleFloat (hl_dvertexes[i].point[j]);\n\t}\n\t\t\n//\n// planes\n//\t\n\tfor (i=0 ; i<hl_numplanes ; i++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t\thl_dplanes[i].normal[j] = LittleFloat (hl_dplanes[i].normal[j]);\n\t\thl_dplanes[i].dist = LittleFloat (hl_dplanes[i].dist);\n\t\thl_dplanes[i].type = LittleLong (hl_dplanes[i].type);\n\t}\n\t\n//\n// texinfos\n//\t\n\tfor (i=0 ; i<hl_numtexinfo ; i++)\n\t{\n\t\tfor (j=0 ; j<8 ; j++)\n\t\t\thl_texinfo[i].vecs[0][j] = LittleFloat (hl_texinfo[i].vecs[0][j]);\n\t\thl_texinfo[i].miptex = LittleLong (hl_texinfo[i].miptex);\n\t\thl_texinfo[i].flags = LittleLong (hl_texinfo[i].flags);\n\t}\n\t\n//\n// faces\n//\n\tfor (i=0 ; i<hl_numfaces ; i++)\n\t{\n\t\thl_dfaces[i].texinfo = LittleShort (hl_dfaces[i].texinfo);\n\t\thl_dfaces[i].planenum = LittleShort (hl_dfaces[i].planenum);\n\t\thl_dfaces[i].side = LittleShort (hl_dfaces[i].side);\n\t\thl_dfaces[i].lightofs = LittleLong (hl_dfaces[i].lightofs);\n\t\thl_dfaces[i].firstedge = LittleLong (hl_dfaces[i].firstedge);\n\t\thl_dfaces[i].numedges = LittleShort (hl_dfaces[i].numedges);\n\t}\n\n//\n// nodes\n//\n\tfor (i=0 ; i<hl_numnodes ; i++)\n\t{\n\t\thl_dnodes[i].planenum = LittleLong (hl_dnodes[i].planenum);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\thl_dnodes[i].mins[j] = LittleShort (hl_dnodes[i].mins[j]);\n\t\t\thl_dnodes[i].maxs[j] = LittleShort (hl_dnodes[i].maxs[j]);\n\t\t}\n\t\thl_dnodes[i].children[0] = LittleShort (hl_dnodes[i].children[0]);\n\t\thl_dnodes[i].children[1] = LittleShort (hl_dnodes[i].children[1]);\n\t\thl_dnodes[i].firstface = LittleShort (hl_dnodes[i].firstface);\n\t\thl_dnodes[i].numfaces = LittleShort (hl_dnodes[i].numfaces);\n\t}\n\n//\n// leafs\n//\n\tfor (i=0 ; i<hl_numleafs ; i++)\n\t{\n\t\thl_dleafs[i].contents = LittleLong (hl_dleafs[i].contents);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\thl_dleafs[i].mins[j] = LittleShort (hl_dleafs[i].mins[j]);\n\t\t\thl_dleafs[i].maxs[j] = LittleShort (hl_dleafs[i].maxs[j]);\n\t\t}\n\n\t\thl_dleafs[i].firstmarksurface = LittleShort (hl_dleafs[i].firstmarksurface);\n\t\thl_dleafs[i].nummarksurfaces = LittleShort (hl_dleafs[i].nummarksurfaces);\n\t\thl_dleafs[i].visofs = LittleLong (hl_dleafs[i].visofs);\n\t}\n\n//\n// clipnodes\n//\n\tfor (i=0 ; i<hl_numclipnodes ; i++)\n\t{\n\t\thl_dclipnodes[i].planenum = LittleLong (hl_dclipnodes[i].planenum);\n\t\thl_dclipnodes[i].children[0] = LittleShort (hl_dclipnodes[i].children[0]);\n\t\thl_dclipnodes[i].children[1] = LittleShort (hl_dclipnodes[i].children[1]);\n\t}\n\n//\n// miptex\n//\n\tif (hl_texdatasize)\n\t{\n\t\tmtl = (hl_dmiptexlump_t *)hl_dtexdata;\n\t\tif (todisk)\n\t\t\tc = mtl->nummiptex;\n\t\telse\n\t\t\tc = LittleLong(mtl->nummiptex);\n\t\tmtl->nummiptex = LittleLong (mtl->nummiptex);\n\t\tfor (i=0 ; i<c ; i++)\n\t\t\tmtl->dataofs[i] = LittleLong(mtl->dataofs[i]);\n\t}\n\t\n//\n// marksurfaces\n//\n\tfor (i=0 ; i<hl_nummarksurfaces ; i++)\n\t\thl_dmarksurfaces[i] = LittleShort (hl_dmarksurfaces[i]);\n\n//\n// surfedges\n//\n\tfor (i=0 ; i<hl_numsurfedges ; i++)\n\t\thl_dsurfedges[i] = LittleLong (hl_dsurfedges[i]);\n\n//\n// edges\n//\n\tfor (i=0 ; i<hl_numedges ; i++)\n\t{\n\t\thl_dedges[i].v[0] = LittleShort (hl_dedges[i].v[0]);\n\t\thl_dedges[i].v[1] = LittleShort (hl_dedges[i].v[1]);\n\t}\n} //end of the function HL_SwapBSPFile\n\n\nhl_dheader_t\t*hl_header;\nint\t\t\t\thl_fileLength;\n\nint HL_CopyLump (int lump, void *dest, int size, int maxsize)\n{\n\tint\t\tlength, ofs;\n\n\tlength = hl_header->lumps[lump].filelen;\n\tofs = hl_header->lumps[lump].fileofs;\n\t\n\tif (length % size) {\n\t\tError (\"LoadBSPFile: odd lump size\");\n\t}\n\t// somehow things got out of range\n\tif ((length/size) > maxsize) {\n\t\tprintf(\"WARNING: exceeded max size for lump %d size %d > maxsize %d\\n\", lump, (length/size), maxsize);\n\t\tlength = maxsize * size;\n\t}\n\tif ( ofs + length > hl_fileLength ) {\n\t\tprintf(\"WARNING: exceeded file length for lump %d\\n\", lump);\n\t\tlength = hl_fileLength - ofs;\n\t\tif ( length <= 0 ) {\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tmemcpy (dest, (byte *)hl_header + ofs, length);\n\n\treturn length / size;\n}\n\n/*\n=============\nHL_LoadBSPFile\n=============\n*/\nvoid\tHL_LoadBSPFile (char *filename, int offset, int length)\n{\n\tint\t\t\ti;\n\t\n//\n// load the file header\n//\n\thl_fileLength = LoadFile (filename, (void **)&hl_header, offset, length);\n\n// swap the header\n\tfor (i=0 ; i< sizeof(hl_dheader_t)/4 ; i++)\n\t\t((int *)hl_header)[i] = LittleLong ( ((int *)hl_header)[i]);\n\n\tif (hl_header->version != HL_BSPVERSION)\n\t\tError (\"%s is version %i, not %i\", filename, hl_header->version, HL_BSPVERSION);\n\n\thl_nummodels = HL_CopyLump (HL_LUMP_MODELS, hl_dmodels, sizeof(hl_dmodel_t), HL_MAX_MAP_MODELS );\n\thl_numvertexes = HL_CopyLump (HL_LUMP_VERTEXES, hl_dvertexes, sizeof(hl_dvertex_t), HL_MAX_MAP_VERTS );\n\thl_numplanes = HL_CopyLump (HL_LUMP_PLANES, hl_dplanes, sizeof(hl_dplane_t), HL_MAX_MAP_PLANES );\n\thl_numleafs = HL_CopyLump (HL_LUMP_LEAFS, hl_dleafs, sizeof(hl_dleaf_t), HL_MAX_MAP_LEAFS );\n\thl_numnodes = HL_CopyLump (HL_LUMP_NODES, hl_dnodes, sizeof(hl_dnode_t), HL_MAX_MAP_NODES );\n\thl_numtexinfo = HL_CopyLump (HL_LUMP_TEXINFO, hl_texinfo, sizeof(hl_texinfo_t), HL_MAX_MAP_TEXINFO );\n\thl_numclipnodes = HL_CopyLump (HL_LUMP_CLIPNODES, hl_dclipnodes, sizeof(hl_dclipnode_t), HL_MAX_MAP_CLIPNODES );\n\thl_numfaces = HL_CopyLump (HL_LUMP_FACES, hl_dfaces, sizeof(hl_dface_t), HL_MAX_MAP_FACES );\n\thl_nummarksurfaces = HL_CopyLump (HL_LUMP_MARKSURFACES, hl_dmarksurfaces, sizeof(hl_dmarksurfaces[0]), HL_MAX_MAP_MARKSURFACES );\n\thl_numsurfedges = HL_CopyLump (HL_LUMP_SURFEDGES, hl_dsurfedges, sizeof(hl_dsurfedges[0]), HL_MAX_MAP_SURFEDGES );\n\thl_numedges = HL_CopyLump (HL_LUMP_EDGES, hl_dedges, sizeof(hl_dedge_t), HL_MAX_MAP_EDGES );\n\n\thl_texdatasize = HL_CopyLump (HL_LUMP_TEXTURES, hl_dtexdata, 1, HL_MAX_MAP_MIPTEX );\n\thl_visdatasize = HL_CopyLump (HL_LUMP_VISIBILITY, hl_dvisdata, 1, HL_MAX_MAP_VISIBILITY );\n\thl_lightdatasize = HL_CopyLump (HL_LUMP_LIGHTING, hl_dlightdata, 1, HL_MAX_MAP_LIGHTING );\n\thl_entdatasize = HL_CopyLump (HL_LUMP_ENTITIES, hl_dentdata, 1, HL_MAX_MAP_ENTSTRING );\n\n\tFreeMemory(hl_header);\t\t// everything has been copied out\n\t\t\n//\n// swap everything\n//\t\n\tHL_SwapBSPFile (false);\n\n\thl_dmodels_checksum = FastChecksum( hl_dmodels, hl_nummodels*sizeof(hl_dmodels[0]) );\n\thl_dvertexes_checksum = FastChecksum( hl_dvertexes, hl_numvertexes*sizeof(hl_dvertexes[0]) );\n\thl_dplanes_checksum = FastChecksum( hl_dplanes, hl_numplanes*sizeof(hl_dplanes[0]) );\n\thl_dleafs_checksum = FastChecksum( hl_dleafs, hl_numleafs*sizeof(hl_dleafs[0]) );\n\thl_dnodes_checksum = FastChecksum( hl_dnodes, hl_numnodes*sizeof(hl_dnodes[0]) );\n\thl_texinfo_checksum = FastChecksum( hl_texinfo, hl_numtexinfo*sizeof(hl_texinfo[0]) );\n\thl_dclipnodes_checksum = FastChecksum( hl_dclipnodes, hl_numclipnodes*sizeof(hl_dclipnodes[0]) );\n\thl_dfaces_checksum = FastChecksum( hl_dfaces, hl_numfaces*sizeof(hl_dfaces[0]) );\n\thl_dmarksurfaces_checksum = FastChecksum( hl_dmarksurfaces, hl_nummarksurfaces*sizeof(hl_dmarksurfaces[0]) );\n\thl_dsurfedges_checksum = FastChecksum( hl_dsurfedges, hl_numsurfedges*sizeof(hl_dsurfedges[0]) );\n\thl_dedges_checksum = FastChecksum( hl_dedges, hl_numedges*sizeof(hl_dedges[0]) );\n\thl_dtexdata_checksum = FastChecksum( hl_dtexdata, hl_numedges*sizeof(hl_dtexdata[0]) );\n\thl_dvisdata_checksum = FastChecksum( hl_dvisdata, hl_visdatasize*sizeof(hl_dvisdata[0]) );\n\thl_dlightdata_checksum = FastChecksum( hl_dlightdata, hl_lightdatasize*sizeof(hl_dlightdata[0]) );\n\thl_dentdata_checksum = FastChecksum( hl_dentdata, hl_entdatasize*sizeof(hl_dentdata[0]) );\n\n}\n\n//============================================================================\n\nFILE\t\t*wadfile;\nhl_dheader_t\toutheader;\n\nvoid HL_AddLump (int lumpnum, void *data, int len)\n{\n\thl_lump_t *lump;\n\n\tlump = &hl_header->lumps[lumpnum];\n\t\n\tlump->fileofs = LittleLong( ftell(wadfile) );\n\tlump->filelen = LittleLong(len);\n\tSafeWrite (wadfile, data, (len+3)&~3);\n}\n\n/*\n=============\nHL_WriteBSPFile\n\nSwaps the bsp file in place, so it should not be referenced again\n=============\n*/\nvoid HL_WriteBSPFile (char *filename)\n{\t\t\n\thl_header = &outheader;\n\tmemset (hl_header, 0, sizeof(hl_dheader_t));\n\t\n\tHL_SwapBSPFile (true);\n\n\thl_header->version = LittleLong (HL_BSPVERSION);\n\t\n\twadfile = SafeOpenWrite (filename);\n\tSafeWrite (wadfile, hl_header, sizeof(hl_dheader_t));\t// overwritten later\n\n\tHL_AddLump (HL_LUMP_PLANES, hl_dplanes, hl_numplanes*sizeof(hl_dplane_t));\n\tHL_AddLump (HL_LUMP_LEAFS, hl_dleafs, hl_numleafs*sizeof(hl_dleaf_t));\n\tHL_AddLump (HL_LUMP_VERTEXES, hl_dvertexes, hl_numvertexes*sizeof(hl_dvertex_t));\n\tHL_AddLump (HL_LUMP_NODES, hl_dnodes, hl_numnodes*sizeof(hl_dnode_t));\n\tHL_AddLump (HL_LUMP_TEXINFO, hl_texinfo, hl_numtexinfo*sizeof(hl_texinfo_t));\n\tHL_AddLump (HL_LUMP_FACES, hl_dfaces, hl_numfaces*sizeof(hl_dface_t));\n\tHL_AddLump (HL_LUMP_CLIPNODES, hl_dclipnodes, hl_numclipnodes*sizeof(hl_dclipnode_t));\n\tHL_AddLump (HL_LUMP_MARKSURFACES, hl_dmarksurfaces, hl_nummarksurfaces*sizeof(hl_dmarksurfaces[0]));\n\tHL_AddLump (HL_LUMP_SURFEDGES, hl_dsurfedges, hl_numsurfedges*sizeof(hl_dsurfedges[0]));\n\tHL_AddLump (HL_LUMP_EDGES, hl_dedges, hl_numedges*sizeof(hl_dedge_t));\n\tHL_AddLump (HL_LUMP_MODELS, hl_dmodels, hl_nummodels*sizeof(hl_dmodel_t));\n\n\tHL_AddLump (HL_LUMP_LIGHTING, hl_dlightdata, hl_lightdatasize);\n\tHL_AddLump (HL_LUMP_VISIBILITY, hl_dvisdata, hl_visdatasize);\n\tHL_AddLump (HL_LUMP_ENTITIES, hl_dentdata, hl_entdatasize);\n\tHL_AddLump (HL_LUMP_TEXTURES, hl_dtexdata, hl_texdatasize);\n\t\n\tfseek (wadfile, 0, SEEK_SET);\n\tSafeWrite (wadfile, hl_header, sizeof(hl_dheader_t));\n\tfclose (wadfile);\t\n}\n\n//============================================================================\n\n#define ENTRIES(a)\t\t(sizeof(a)/sizeof(*(a)))\n#define ENTRYSIZE(a)\t(sizeof(*(a)))\n\nArrayUsage( char *szItem, int items, int maxitems, int itemsize )\n{\n\tfloat\tpercentage = maxitems ? items * 100.0 / maxitems : 0.0;\n\n   qprintf(\"%-12s  %7i/%-7i  %7i/%-7i  (%4.1f%%)\", \n\t\t\t\tszItem, items, maxitems, items * itemsize, maxitems * itemsize, percentage );\n\tif ( percentage > 80.0 )\n\t\tqprintf( \"VERY FULL!\\n\" );\n\telse if ( percentage > 95.0 )\n\t\tqprintf( \"SIZE DANGER!\\n\" );\n\telse if ( percentage > 99.9 )\n\t\tqprintf( \"SIZE OVERFLOW!!!\\n\" );\n\telse\n\t\tqprintf( \"\\n\" );\n\treturn items * itemsize;\n}\n\nGlobUsage( char *szItem, int itemstorage, int maxstorage )\n{\n\tfloat\tpercentage = maxstorage ? itemstorage * 100.0 / maxstorage : 0.0;\n\n\tqprintf(\"%-12s     [variable]    %7i/%-7i  (%4.1f%%)\", \n\t\t\t\tszItem, itemstorage, maxstorage, percentage );\n\tif ( percentage > 80.0 )\n\t\tqprintf( \"VERY FULL!\\n\" );\n\telse if ( percentage > 95.0 )\n\t\tqprintf( \"SIZE DANGER!\\n\" );\n\telse if ( percentage > 99.9 )\n\t\tqprintf( \"SIZE OVERFLOW!!!\\n\" );\n\telse\n\t\tqprintf( \"\\n\" );\n\treturn itemstorage;\n}\n\n/*\n=============\nHL_PrintBSPFileSizes\n\nDumps info about current file\n=============\n*/\nvoid HL_PrintBSPFileSizes(void)\n{\n\tint\tnumtextures = hl_texdatasize ? ((hl_dmiptexlump_t*)hl_dtexdata)->nummiptex : 0;\n\tint\ttotalmemory = 0;\n\n\tqprintf(\"\\n\");\n\tqprintf(\"Object names  Objects/Maxobjs  Memory / Maxmem  Fullness\\n\" );\n\tqprintf(\"------------  ---------------  ---------------  --------\\n\" );\n\n\ttotalmemory += ArrayUsage( \"models\",\t\thl_nummodels,\t\tENTRIES(hl_dmodels),\t\tENTRYSIZE(hl_dmodels) );\n\ttotalmemory += ArrayUsage( \"planes\",\t\thl_numplanes,\t\tENTRIES(hl_dplanes),\t\tENTRYSIZE(hl_dplanes) );\n\ttotalmemory += ArrayUsage( \"vertexes\",\t\thl_numvertexes,\tENTRIES(hl_dvertexes),\tENTRYSIZE(hl_dvertexes) );\n\ttotalmemory += ArrayUsage( \"nodes\",\t\t\thl_numnodes,\t\tENTRIES(hl_dnodes),\t\tENTRYSIZE(hl_dnodes) );\n\ttotalmemory += ArrayUsage( \"texinfos\",\t\thl_numtexinfo,\t\tENTRIES(hl_texinfo),\t\tENTRYSIZE(hl_texinfo) );\n\ttotalmemory += ArrayUsage( \"faces\",\t\t\thl_numfaces,\t\tENTRIES(hl_dfaces),\t\tENTRYSIZE(hl_dfaces) );\n\ttotalmemory += ArrayUsage( \"clipnodes\",\thl_numclipnodes,\tENTRIES(hl_dclipnodes),\tENTRYSIZE(hl_dclipnodes) );\n\ttotalmemory += ArrayUsage( \"leaves\",\t\thl_numleafs,\t\tENTRIES(hl_dleafs),\t\tENTRYSIZE(hl_dleafs) );\n\ttotalmemory += ArrayUsage( \"marksurfaces\",hl_nummarksurfaces,ENTRIES(hl_dmarksurfaces),ENTRYSIZE(hl_dmarksurfaces) );\n\ttotalmemory += ArrayUsage( \"surfedges\",\thl_numsurfedges,\tENTRIES(hl_dsurfedges),\tENTRYSIZE(hl_dsurfedges) );\n\ttotalmemory += ArrayUsage( \"edges\",\t\t\thl_numedges,\t\tENTRIES(hl_dedges),\t\tENTRYSIZE(hl_dedges) );\n\n\ttotalmemory += GlobUsage( \"texdata\",\t\thl_texdatasize,\tsizeof(hl_dtexdata) );\n\ttotalmemory += GlobUsage( \"lightdata\",\t\thl_lightdatasize,\tsizeof(hl_dlightdata) );\n\ttotalmemory += GlobUsage( \"visdata\",\t\thl_visdatasize,\tsizeof(hl_dvisdata) );\n\ttotalmemory += GlobUsage( \"entdata\",\t\thl_entdatasize,\tsizeof(hl_dentdata) );\n\n\tqprintf( \"=== Total BSP file data space used: %d bytes ===\\n\\n\", totalmemory );\n}\n\n\n\n/*\n=================\nParseEpair\n=================\n* /\nepair_t *ParseEpair (void)\n{\n\tepair_t\t*e;\n\t\n\te = malloc (sizeof(epair_t));\n\tmemset (e, 0, sizeof(epair_t));\n\t\n\tif (strlen(token) >= MAX_KEY-1)\n\t\tError (\"ParseEpar: token too long\");\n\te->key = copystring(token);\n\tGetToken (false);\n\tif (strlen(token) >= MAX_VALUE-1)\n\t\tError (\"ParseEpar: token too long\");\n\te->value = copystring(token);\n\n\treturn e;\n} //*/\n\n\n/*\n================\nParseEntity\n================\n* /\nqboolean\tParseEntity (void)\n{\n\tepair_t\t\t*e;\n\tentity_t\t*mapent;\n\n\tif (!GetToken (true))\n\t\treturn false;\n\n\tif (strcmp (token, \"{\") )\n\t\tError (\"ParseEntity: { not found\");\n\t\n\tif (num_entities == HL_MAX_MAP_ENTITIES)\n\t\tError (\"num_entities == HL_MAX_MAP_ENTITIES\");\n\n\tmapent = &entities[num_entities];\n\tnum_entities++;\n\n\tdo\n\t{\n\t\tif (!GetToken (true))\n\t\t\tError (\"ParseEntity: EOF without closing brace\");\n\t\tif (!strcmp (token, \"}\") )\n\t\t\tbreak;\n\t\te = ParseEpair ();\n\t\te->next = mapent->epairs;\n\t\tmapent->epairs = e;\n\t} while (1);\n\t\n\treturn true;\n} //*/\n\n/*\n================\nParseEntities\n\nParses the dentdata string into entities\n================\n*/\nvoid HL_ParseEntities (void)\n{\n\tscript_t *script;\n\n\tnum_entities = 0;\n\tscript = LoadScriptMemory(hl_dentdata, hl_entdatasize, \"*Half-Life bsp file\");\n\tSetScriptFlags(script, SCFL_NOSTRINGWHITESPACES |\n\t\t\t\t\t\t\t\t\tSCFL_NOSTRINGESCAPECHARS);\n\n\twhile(ParseEntity(script))\n\t{\n\t} //end while\n\n\tFreeScript(script);\n} //end of the function HL_ParseEntities\n\n\n/*\n================\nUnparseEntities\n\nGenerates the dentdata string from all the entities\n================\n*/\nvoid HL_UnparseEntities (void)\n{\n\tchar *buf, *end;\n\tepair_t *ep;\n\tchar line[2048];\n\tint i;\n\t\n\tbuf = hl_dentdata;\n\tend = buf;\n\t*end = 0;\n\t\n\tfor (i=0 ; i<num_entities ; i++)\n\t{\n\t\tep = entities[i].epairs;\n\t\tif (!ep)\n\t\t\tcontinue;\t// ent got removed\n\t\t\n\t\tstrcat (end,\"{\\n\");\n\t\tend += 2;\n\t\t\t\t\n\t\tfor (ep = entities[i].epairs ; ep ; ep=ep->next)\n\t\t{\n\t\t\tsprintf (line, \"\\\"%s\\\" \\\"%s\\\"\\n\", ep->key, ep->value);\n\t\t\tstrcat (end, line);\n\t\t\tend += strlen(line);\n\t\t}\n\t\tstrcat (end,\"}\\n\");\n\t\tend += 2;\n\n\t\tif (end > buf + HL_MAX_MAP_ENTSTRING)\n\t\t\tError (\"Entity text too long\");\n\t}\n\thl_entdatasize = end - buf + 1;\n} //end of the function HL_UnparseEntities\n\n\n/*\nvoid \tSetKeyValue (entity_t *ent, char *key, char *value)\n{\n\tepair_t\t*ep;\n\t\n\tfor (ep=ent->epairs ; ep ; ep=ep->next)\n\t\tif (!strcmp (ep->key, key) )\n\t\t{\n\t\t\tfree (ep->value);\n\t\t\tep->value = copystring(value);\n\t\t\treturn;\n\t\t}\n\tep = malloc (sizeof(*ep));\n\tep->next = ent->epairs;\n\tent->epairs = ep;\n\tep->key = copystring(key);\n\tep->value = copystring(value);\n}\n\nchar \t*ValueForKey (entity_t *ent, char *key)\n{\n\tepair_t\t*ep;\n\t\n\tfor (ep=ent->epairs ; ep ; ep=ep->next)\n\t\tif (!strcmp (ep->key, key) )\n\t\t\treturn ep->value;\n\treturn \"\";\n}\n\nvec_t\tFloatForKey (entity_t *ent, char *key)\n{\n\tchar\t*k;\n\t\n\tk = ValueForKey (ent, key);\n\treturn atof(k);\n}\n\nvoid \tGetVectorForKey (entity_t *ent, char *key, vec3_t vec)\n{\n\tchar\t*k;\n\tdouble\tv1, v2, v3;\n\n\tk = ValueForKey (ent, key);\n// scanf into doubles, then assign, so it is vec_t size independent\n\tv1 = v2 = v3 = 0;\n\tsscanf (k, \"%lf %lf %lf\", &v1, &v2, &v3);\n\tvec[0] = v1;\n\tvec[1] = v2;\n\tvec[2] = v3;\n} //*/\n"
  },
  {
    "path": "code/bspc/l_bsp_hl.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// upper design bounds\n\n#define\tHL_MAX_MAP_HULLS\t\t\t4\n\n#define\tHL_MAX_MAP_MODELS\t\t\t400\n#define\tHL_MAX_MAP_BRUSHES\t\t4096\n#define\tHL_MAX_MAP_ENTITIES\t\t1024\n#define\tHL_MAX_MAP_ENTSTRING\t\t(128*1024)\n\n#define\tHL_MAX_MAP_PLANES\t\t\t32767\n#define\tHL_MAX_MAP_NODES\t\t\t32767\t\t// because negative shorts are contents\n#define\tHL_MAX_MAP_CLIPNODES\t\t32767\t\t//\n#define\tHL_MAX_MAP_LEAFS\t\t\t8192\n#define\tHL_MAX_MAP_VERTS\t\t\t65535\n#define\tHL_MAX_MAP_FACES\t\t\t65535\n#define\tHL_MAX_MAP_MARKSURFACES 65535\n#define\tHL_MAX_MAP_TEXINFO\t\t8192\n#define\tHL_MAX_MAP_EDGES\t\t\t256000\n#define\tHL_MAX_MAP_SURFEDGES\t\t512000\n#define\tHL_MAX_MAP_TEXTURES\t\t512\n#define\tHL_MAX_MAP_MIPTEX\t\t\t0x200000\n#define\tHL_MAX_MAP_LIGHTING\t\t0x200000\n#define\tHL_MAX_MAP_VISIBILITY\t0x200000\n\n#define\tHL_MAX_MAP_PORTALS\t\t65536\n\n// key / value pair sizes\n\n#define\tMAX_KEY\t\t32\n#define\tMAX_VALUE\t1024\n\n//=============================================================================\n\n\n#define HL_BSPVERSION\t30\n#define HL_TOOLVERSION\t2\n\n\ntypedef struct\n{\n\tint\t\tfileofs, filelen;\n} hl_lump_t;\n\n#define\tHL_LUMP_ENTITIES\t0\n#define\tHL_LUMP_PLANES\t\t1\n#define\tHL_LUMP_TEXTURES\t2\n#define\tHL_LUMP_VERTEXES\t3\n#define\tHL_LUMP_VISIBILITY\t4\n#define\tHL_LUMP_NODES\t\t5\n#define\tHL_LUMP_TEXINFO\t6\n#define\tHL_LUMP_FACES\t\t7\n#define\tHL_LUMP_LIGHTING\t8\n#define\tHL_LUMP_CLIPNODES\t9\n#define\tHL_LUMP_LEAFS\t\t10\n#define\tHL_LUMP_MARKSURFACES 11\n#define\tHL_LUMP_EDGES\t\t12\n#define\tHL_LUMP_SURFEDGES\t13\n#define\tHL_LUMP_MODELS\t\t14\n\n#define\tHL_HEADER_LUMPS\t15\n\ntypedef struct\n{\n\tfloat\t\tmins[3], maxs[3];\n\tfloat\t\torigin[3];\n\tint\t\theadnode[HL_MAX_MAP_HULLS];\n\tint\t\tvisleafs;\t\t// not including the solid leaf 0\n\tint\t\tfirstface, numfaces;\n} hl_dmodel_t;\n\ntypedef struct\n{\n\tint\t\t\tversion;\t\n\thl_lump_t\tlumps[HL_HEADER_LUMPS];\n} hl_dheader_t;\n\ntypedef struct\n{\n\tint\t\t\tnummiptex;\n\tint\t\t\tdataofs[4];\t\t// [nummiptex]\n} hl_dmiptexlump_t;\n\n#define\tMIPLEVELS\t4\ntypedef struct hl_miptex_s\n{\n\tchar\t\tname[16];\n\tunsigned\twidth, height;\n\tunsigned\toffsets[MIPLEVELS];\t\t// four mip maps stored\n} hl_miptex_t;\n\n\ntypedef struct\n{\n\tfloat\tpoint[3];\n} hl_dvertex_t;\n\n\n// 0-2 are axial planes\n#define\tPLANE_X\t\t\t0\n#define\tPLANE_Y\t\t\t1\n#define\tPLANE_Z\t\t\t2\n\n// 3-5 are non-axial planes snapped to the nearest\n#define\tPLANE_ANYX\t\t3\n#define\tPLANE_ANYY\t\t4\n#define\tPLANE_ANYZ\t\t5\n\ntypedef struct\n{\n\tfloat\tnormal[3];\n\tfloat\tdist;\n\tint\ttype;\t\t// PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate\n} hl_dplane_t;\n\n\n\n#define\tHL_CONTENTS_EMPTY\t\t\t\t-1\n#define\tHL_CONTENTS_SOLID\t\t\t\t-2\n#define\tHL_CONTENTS_WATER\t\t\t\t-3\n#define\tHL_CONTENTS_SLIME\t\t\t\t-4\n#define\tHL_CONTENTS_LAVA\t\t\t\t-5\n#define\tHL_CONTENTS_SKY\t\t\t\t-6\n#define\tHL_CONTENTS_ORIGIN\t\t\t-7\t\t// removed at csg time\n#define\tHL_CONTENTS_CLIP\t\t\t\t-8\t\t// changed to contents_solid\n\n#define\tHL_CONTENTS_CURRENT_0\t\t-9\n#define\tHL_CONTENTS_CURRENT_90\t\t-10\n#define\tHL_CONTENTS_CURRENT_180\t\t-11\n#define\tHL_CONTENTS_CURRENT_270\t\t-12\n#define\tHL_CONTENTS_CURRENT_UP\t\t-13\n#define\tHL_CONTENTS_CURRENT_DOWN\t-14\n\n#define HL_CONTENTS_TRANSLUCENT\t\t-15\n\n// !!! if this is changed, it must be changed in asm_i386.h too !!!\ntypedef struct\n{\n\tint\t\tplanenum;\n\tshort\t\tchildren[2];\t// negative numbers are -(leafs+1), not nodes\n\tshort\t\tmins[3];\t\t// for sphere culling\n\tshort\t\tmaxs[3];\n\tunsigned short\tfirstface;\n\tunsigned short\tnumfaces;\t// counting both sides\n} hl_dnode_t;\n\ntypedef struct\n{\n\tint\t\tplanenum;\n\tshort\t\tchildren[2];\t// negative numbers are contents\n} hl_dclipnode_t;\n\n\ntypedef struct hl_texinfo_s\n{\n\tfloat\t\tvecs[2][4];\t\t// [s/t][xyz offset]\n\tint\t\tmiptex;\n\tint\t\tflags;\n} hl_texinfo_t;\n#define\tTEX_SPECIAL\t\t1\t\t// sky or slime, no lightmap or 256 subdivision\n\n// note that edge 0 is never used, because negative edge nums are used for\n// counterclockwise use of the edge in a face\ntypedef struct\n{\n\tunsigned short\tv[2];\t\t// vertex numbers\n} hl_dedge_t;\n\n#define\tMAXLIGHTMAPS\t4\ntypedef struct\n{\n\tshort\t\tplanenum;\n\tshort\t\tside;\n\n\tint\t\tfirstedge;\t\t// we must support > 64k edges\n\tshort\t\tnumedges;\t\n\tshort\t\ttexinfo;\n\n// lighting info\n\tbyte\t\tstyles[MAXLIGHTMAPS];\n\tint\t\tlightofs;\t\t// start of [numstyles*surfsize] samples\n} hl_dface_t;\n\n\n#define\tAMBIENT_WATER\t0\n#define\tAMBIENT_SKY\t\t1\n#define\tAMBIENT_SLIME\t2\n#define\tAMBIENT_LAVA\t3\n\n#define\tNUM_AMBIENTS\t\t\t4\t\t// automatic ambient sounds\n\n// leaf 0 is the generic HL_CONTENTS_SOLID leaf, used for all solid areas\n// all other leafs need visibility info\ntypedef struct\n{\n\tint\t\t\tcontents;\n\tint\t\t\tvisofs;\t\t\t\t// -1 = no visibility info\n\n\tshort\t\t\tmins[3];\t\t\t// for frustum culling\n\tshort\t\t\tmaxs[3];\n\n\tunsigned short\t\tfirstmarksurface;\n\tunsigned short\t\tnummarksurfaces;\n\n\tbyte\t\tambient_level[NUM_AMBIENTS];\n} hl_dleaf_t;\n\n\n//============================================================================\n\n#ifndef QUAKE_GAME\n\n#define\tANGLE_UP\t-1\n#define\tANGLE_DOWN\t-2\n\n\n// the utilities get to be lazy and just use large static arrays\n\nextern\tint\t\t\t\thl_nummodels;\nextern\thl_dmodel_t\t\t*hl_dmodels;//[MAX_MAP_MODELS];\nextern\tint\t\t\t\thl_dmodels_checksum;\n\nextern\tint\t\t\t\thl_visdatasize;\nextern\tbyte\t\t\t\t*hl_dvisdata;//[MAX_MAP_VISIBILITY];\nextern\tint\t\t\t\thl_dvisdata_checksum;\n\nextern\tint\t\t\t\thl_lightdatasize;\nextern\tbyte\t\t\t\t*hl_dlightdata;//[MAX_MAP_LIGHTING];\nextern\tint\t\t\t\thl_dlightdata_checksum;\n\nextern\tint\t\t\t\thl_texdatasize;\nextern\tbyte\t\t\t\t*hl_dtexdata;//[MAX_MAP_MIPTEX]; // (dmiptexlump_t)\nextern\tint\t\t\t\thl_dtexdata_checksum;\n\nextern\tint\t\t\t\thl_entdatasize;\nextern\tchar\t\t\t\t*hl_dentdata;//[MAX_MAP_ENTSTRING];\nextern\tint\t\t\t\thl_dentdata_checksum;\n\nextern\tint\t\t\t\thl_numleafs;\nextern\thl_dleaf_t\t\t*hl_dleafs;//[MAX_MAP_LEAFS];\nextern\tint\t\t\t\thl_dleafs_checksum;\n\nextern\tint\t\t\t\thl_numplanes;\nextern\thl_dplane_t\t\t*hl_dplanes;//[MAX_MAP_PLANES];\nextern\tint\t\t\t\thl_dplanes_checksum;\n\nextern\tint\t\t\t\thl_numvertexes;\nextern\thl_dvertex_t\t*hl_dvertexes;//[MAX_MAP_VERTS];\nextern\tint\t\t\t\thl_dvertexes_checksum;\n\nextern\tint\t\t\t\thl_numnodes;\nextern\thl_dnode_t\t\t*hl_dnodes;//[MAX_MAP_NODES];\nextern\tint\t\t\t\thl_dnodes_checksum;\n\nextern\tint\t\t\t\thl_numtexinfo;\nextern\thl_texinfo_t\t*hl_texinfo;//[MAX_MAP_TEXINFO];\nextern\tint\t\t\t\thl_texinfo_checksum;\n\nextern\tint\t\t\t\thl_numfaces;\nextern\thl_dface_t\t\t*hl_dfaces;//[MAX_MAP_FACES];\nextern\tint\t\t\t\thl_dfaces_checksum;\n\nextern\tint\t\t\t\thl_numclipnodes;\nextern\thl_dclipnode_t\t*hl_dclipnodes;//[MAX_MAP_CLIPNODES];\nextern\tint\t\t\t\thl_dclipnodes_checksum;\n\nextern\tint\t\t\t\thl_numedges;\nextern\thl_dedge_t\t\t*hl_dedges;//[MAX_MAP_EDGES];\nextern\tint\t\t\t\thl_dedges_checksum;\n\nextern\tint\t\t\t\thl_nummarksurfaces;\nextern\tunsigned short\t*hl_dmarksurfaces;//[MAX_MAP_MARKSURFACES];\nextern\tint\t\t\t\thl_dmarksurfaces_checksum;\n\nextern\tint\t\t\t\thl_numsurfedges;\nextern\tint\t\t\t\t*hl_dsurfedges;//[MAX_MAP_SURFEDGES];\nextern\tint\t\t\t\thl_dsurfedges_checksum;\n\nint FastChecksum(void *buffer, int bytes);\n\nvoid HL_AllocMaxBSP(void);\nvoid HL_FreeMaxBSP(void);\n\nvoid HL_DecompressVis(byte *in, byte *decompressed);\nint HL_CompressVis(byte *vis, byte *dest);\n\nvoid HL_LoadBSPFile(char *filename, int offset, int length);\nvoid HL_WriteBSPFile(char *filename);\nvoid HL_PrintBSPFileSizes(void);\nvoid HL_PrintBSPFileSizes(void);\nvoid HL_ParseEntities(void);\nvoid HL_UnparseEntities(void);\n\n#endif\n"
  },
  {
    "path": "code/bspc/l_bsp_q1.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"l_cmd.h\"\n#include \"l_math.h\"\n#include \"l_mem.h\"\n#include \"l_log.h\"\n#include \"../botlib/l_script.h\"\n#include \"l_bsp_q1.h\"\n#include \"l_bsp_ent.h\"\n\n//=============================================================================\n\nint\t\t\t\tq1_nummodels;\nq1_dmodel_t\t\t*q1_dmodels;//[MAX_MAP_MODELS];\n\nint\t\t\t\tq1_visdatasize;\nbyte\t\t\t\t*q1_dvisdata;//[MAX_MAP_VISIBILITY];\n\nint\t\t\t\tq1_lightdatasize;\nbyte\t\t\t\t*q1_dlightdata;//[MAX_MAP_LIGHTING];\n\nint\t\t\t\tq1_texdatasize;\nbyte\t\t\t\t*q1_dtexdata;//[MAX_MAP_MIPTEX]; // (dmiptexlump_t)\n\nint\t\t\t\tq1_entdatasize;\nchar\t\t\t\t*q1_dentdata;//[MAX_MAP_ENTSTRING];\n\nint\t\t\t\tq1_numleafs;\nq1_dleaf_t\t\t*q1_dleafs;//[MAX_MAP_LEAFS];\n\nint\t\t\t\tq1_numplanes;\nq1_dplane_t\t\t*q1_dplanes;//[MAX_MAP_PLANES];\n\nint\t\t\t\tq1_numvertexes;\nq1_dvertex_t\t*q1_dvertexes;//[MAX_MAP_VERTS];\n\nint\t\t\t\tq1_numnodes;\nq1_dnode_t\t\t*q1_dnodes;//[MAX_MAP_NODES];\n\nint\t\t\t\tq1_numtexinfo;\nq1_texinfo_t\t*q1_texinfo;//[MAX_MAP_TEXINFO];\n\nint\t\t\t\tq1_numfaces;\nq1_dface_t\t\t*q1_dfaces;//[MAX_MAP_FACES];\n\nint\t\t\t\tq1_numclipnodes;\nq1_dclipnode_t\t*q1_dclipnodes;//[MAX_MAP_CLIPNODES];\n\nint\t\t\t\tq1_numedges;\nq1_dedge_t\t\t*q1_dedges;//[MAX_MAP_EDGES];\n\nint\t\t\t\tq1_nummarksurfaces;\nunsigned short\t*q1_dmarksurfaces;//[MAX_MAP_MARKSURFACES];\n\nint\t\t\t\tq1_numsurfedges;\nint\t\t\t\t*q1_dsurfedges;//[MAX_MAP_SURFEDGES];\n\n//=============================================================================\n\nint q1_bspallocated = false;\nint q1_allocatedbspmem = 0;\n\nvoid Q1_AllocMaxBSP(void)\n{\n\t//models\n\tq1_nummodels = 0;\n\tq1_dmodels = (q1_dmodel_t *) GetMemory(Q1_MAX_MAP_MODELS * sizeof(q1_dmodel_t));\n\tq1_allocatedbspmem = Q1_MAX_MAP_MODELS * sizeof(q1_dmodel_t);\n\t//visibility\n\tq1_visdatasize = 0;\n\tq1_dvisdata = (byte *) GetMemory(Q1_MAX_MAP_VISIBILITY * sizeof(byte));\n\tq1_allocatedbspmem += Q1_MAX_MAP_VISIBILITY * sizeof(byte);\n\t//light data\n\tq1_lightdatasize = 0;\n\tq1_dlightdata = (byte *) GetMemory(Q1_MAX_MAP_LIGHTING * sizeof(byte));\n\tq1_allocatedbspmem += Q1_MAX_MAP_LIGHTING * sizeof(byte);\n\t//texture data\n\tq1_texdatasize = 0;\n\tq1_dtexdata = (byte *) GetMemory(Q1_MAX_MAP_MIPTEX * sizeof(byte)); // (dmiptexlump_t)\n\tq1_allocatedbspmem += Q1_MAX_MAP_MIPTEX * sizeof(byte);\n\t//entities\n\tq1_entdatasize = 0;\n\tq1_dentdata = (char *) GetMemory(Q1_MAX_MAP_ENTSTRING * sizeof(char));\n\tq1_allocatedbspmem += Q1_MAX_MAP_ENTSTRING * sizeof(char);\n\t//leaves\n\tq1_numleafs = 0;\n\tq1_dleafs = (q1_dleaf_t *) GetMemory(Q1_MAX_MAP_LEAFS * sizeof(q1_dleaf_t));\n\tq1_allocatedbspmem += Q1_MAX_MAP_LEAFS * sizeof(q1_dleaf_t);\n\t//planes\n\tq1_numplanes = 0;\n\tq1_dplanes = (q1_dplane_t *) GetMemory(Q1_MAX_MAP_PLANES * sizeof(q1_dplane_t));\n\tq1_allocatedbspmem += Q1_MAX_MAP_PLANES * sizeof(q1_dplane_t);\n\t//vertexes\n\tq1_numvertexes = 0;\n\tq1_dvertexes = (q1_dvertex_t *) GetMemory(Q1_MAX_MAP_VERTS * sizeof(q1_dvertex_t));\n\tq1_allocatedbspmem += Q1_MAX_MAP_VERTS * sizeof(q1_dvertex_t);\n\t//nodes\n\tq1_numnodes = 0;\n\tq1_dnodes = (q1_dnode_t *) GetMemory(Q1_MAX_MAP_NODES * sizeof(q1_dnode_t));\n\tq1_allocatedbspmem += Q1_MAX_MAP_NODES * sizeof(q1_dnode_t);\n\t//texture info\n\tq1_numtexinfo = 0;\n\tq1_texinfo = (q1_texinfo_t *) GetMemory(Q1_MAX_MAP_TEXINFO * sizeof(q1_texinfo_t));\n\tq1_allocatedbspmem += Q1_MAX_MAP_TEXINFO * sizeof(q1_texinfo_t);\n\t//faces\n\tq1_numfaces = 0;\n\tq1_dfaces = (q1_dface_t *) GetMemory(Q1_MAX_MAP_FACES * sizeof(q1_dface_t));\n\tq1_allocatedbspmem += Q1_MAX_MAP_FACES * sizeof(q1_dface_t);\n\t//clip nodes\n\tq1_numclipnodes = 0;\n\tq1_dclipnodes = (q1_dclipnode_t *) GetMemory(Q1_MAX_MAP_CLIPNODES * sizeof(q1_dclipnode_t));\n\tq1_allocatedbspmem += Q1_MAX_MAP_CLIPNODES * sizeof(q1_dclipnode_t);\n\t//edges\n\tq1_numedges = 0;\n\tq1_dedges = (q1_dedge_t *) GetMemory(Q1_MAX_MAP_EDGES * sizeof(q1_dedge_t));\n\tq1_allocatedbspmem += Q1_MAX_MAP_EDGES, sizeof(q1_dedge_t);\n\t//mark surfaces\n\tq1_nummarksurfaces = 0;\n\tq1_dmarksurfaces = (unsigned short *) GetMemory(Q1_MAX_MAP_MARKSURFACES * sizeof(unsigned short));\n\tq1_allocatedbspmem += Q1_MAX_MAP_MARKSURFACES * sizeof(unsigned short);\n\t//surface edges\n\tq1_numsurfedges = 0;\n\tq1_dsurfedges = (int *) GetMemory(Q1_MAX_MAP_SURFEDGES * sizeof(int));\n\tq1_allocatedbspmem += Q1_MAX_MAP_SURFEDGES * sizeof(int);\n\t//print allocated memory\n\tLog_Print(\"allocated \");\n\tPrintMemorySize(q1_allocatedbspmem);\n\tLog_Print(\" of BSP memory\\n\");\n} //end of the function Q1_AllocMaxBSP\n\nvoid Q1_FreeMaxBSP(void)\n{\n\t//models\n\tq1_nummodels = 0;\n\tFreeMemory(q1_dmodels);\n\tq1_dmodels = NULL;\n\t//visibility\n\tq1_visdatasize = 0;\n\tFreeMemory(q1_dvisdata);\n\tq1_dvisdata = NULL;\n\t//light data\n\tq1_lightdatasize = 0;\n\tFreeMemory(q1_dlightdata);\n\tq1_dlightdata = NULL;\n\t//texture data\n\tq1_texdatasize = 0;\n\tFreeMemory(q1_dtexdata);\n\tq1_dtexdata = NULL;\n\t//entities\n\tq1_entdatasize = 0;\n\tFreeMemory(q1_dentdata);\n\tq1_dentdata = NULL;\n\t//leaves\n\tq1_numleafs = 0;\n\tFreeMemory(q1_dleafs);\n\tq1_dleafs = NULL;\n\t//planes\n\tq1_numplanes = 0;\n\tFreeMemory(q1_dplanes);\n\tq1_dplanes = NULL;\n\t//vertexes\n\tq1_numvertexes = 0;\n\tFreeMemory(q1_dvertexes);\n\tq1_dvertexes = NULL;\n\t//nodes\n\tq1_numnodes = 0;\n\tFreeMemory(q1_dnodes);\n\tq1_dnodes = NULL;\n\t//texture info\n\tq1_numtexinfo = 0;\n\tFreeMemory(q1_texinfo);\n\tq1_texinfo = NULL;\n\t//faces\n\tq1_numfaces = 0;\n\tFreeMemory(q1_dfaces);\n\tq1_dfaces = NULL;\n\t//clip nodes\n\tq1_numclipnodes = 0;\n\tFreeMemory(q1_dclipnodes);\n\tq1_dclipnodes = NULL;\n\t//edges\n\tq1_numedges = 0;\n\tFreeMemory(q1_dedges);\n\tq1_dedges = NULL;\n\t//mark surfaces\n\tq1_nummarksurfaces = 0;\n\tFreeMemory(q1_dmarksurfaces);\n\tq1_dmarksurfaces = NULL;\n\t//surface edges\n\tq1_numsurfedges = 0;\n\tFreeMemory(q1_dsurfedges);\n\tq1_dsurfedges = NULL;\n\t//\n\tLog_Print(\"freed \");\n\tPrintMemorySize(q1_allocatedbspmem);\n\tLog_Print(\" of BSP memory\\n\");\n\tq1_allocatedbspmem = 0;\n} //end of the function Q1_FreeMaxBSP\n//#endif //ME\n\n/*\n=============\nQ1_SwapBSPFile\n\nByte swaps all data in a bsp file.\n=============\n*/\nvoid Q1_SwapBSPFile (qboolean todisk)\n{\n\tint i, j, c;\n\tq1_dmodel_t *d;\n\tq1_dmiptexlump_t *mtl;\n\n\t\n// models\t\n\tfor (i=0 ; i<q1_nummodels ; i++)\n\t{\n\t\td = &q1_dmodels[i];\n\n\t\tfor (j=0 ; j<Q1_MAX_MAP_HULLS ; j++)\n\t\t\td->headnode[j] = LittleLong (d->headnode[j]);\n\n\t\td->visleafs = LittleLong (d->visleafs);\n\t\td->firstface = LittleLong (d->firstface);\n\t\td->numfaces = LittleLong (d->numfaces);\n\t\t\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\td->mins[j] = LittleFloat(d->mins[j]);\n\t\t\td->maxs[j] = LittleFloat(d->maxs[j]);\n\t\t\td->origin[j] = LittleFloat(d->origin[j]);\n\t\t}\n\t}\n\n//\n// vertexes\n//\n\tfor (i=0 ; i<q1_numvertexes ; i++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t\tq1_dvertexes[i].point[j] = LittleFloat(q1_dvertexes[i].point[j]);\n\t}\n\t\t\n//\n// planes\n//\t\n\tfor (i=0 ; i<q1_numplanes ; i++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t\tq1_dplanes[i].normal[j] = LittleFloat(q1_dplanes[i].normal[j]);\n\t\tq1_dplanes[i].dist = LittleFloat(q1_dplanes[i].dist);\n\t\tq1_dplanes[i].type = LittleLong(q1_dplanes[i].type);\n\t}\n\t\n//\n// texinfos\n//\t\n\tfor (i=0 ; i<q1_numtexinfo ; i++)\n\t{\n\t\tfor (j=0 ; j<8 ; j++)\n\t\t\tq1_texinfo[i].vecs[0][j] = LittleFloat(q1_texinfo[i].vecs[0][j]);\n\t\tq1_texinfo[i].miptex = LittleLong(q1_texinfo[i].miptex);\n\t\tq1_texinfo[i].flags = LittleLong(q1_texinfo[i].flags);\n\t}\n\t\n//\n// faces\n//\n\tfor (i=0 ; i<q1_numfaces ; i++)\n\t{\n\t\tq1_dfaces[i].texinfo = LittleShort(q1_dfaces[i].texinfo);\n\t\tq1_dfaces[i].planenum = LittleShort(q1_dfaces[i].planenum);\n\t\tq1_dfaces[i].side = LittleShort(q1_dfaces[i].side);\n\t\tq1_dfaces[i].lightofs = LittleLong(q1_dfaces[i].lightofs);\n\t\tq1_dfaces[i].firstedge = LittleLong(q1_dfaces[i].firstedge);\n\t\tq1_dfaces[i].numedges = LittleShort(q1_dfaces[i].numedges);\n\t}\n\n//\n// nodes\n//\n\tfor (i=0 ; i<q1_numnodes ; i++)\n\t{\n\t\tq1_dnodes[i].planenum = LittleLong(q1_dnodes[i].planenum);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\tq1_dnodes[i].mins[j] = LittleShort(q1_dnodes[i].mins[j]);\n\t\t\tq1_dnodes[i].maxs[j] = LittleShort(q1_dnodes[i].maxs[j]);\n\t\t}\n\t\tq1_dnodes[i].children[0] = LittleShort(q1_dnodes[i].children[0]);\n\t\tq1_dnodes[i].children[1] = LittleShort(q1_dnodes[i].children[1]);\n\t\tq1_dnodes[i].firstface = LittleShort(q1_dnodes[i].firstface);\n\t\tq1_dnodes[i].numfaces = LittleShort(q1_dnodes[i].numfaces);\n\t}\n\n//\n// leafs\n//\n\tfor (i=0 ; i<q1_numleafs ; i++)\n\t{\n\t\tq1_dleafs[i].contents = LittleLong(q1_dleafs[i].contents);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\tq1_dleafs[i].mins[j] = LittleShort(q1_dleafs[i].mins[j]);\n\t\t\tq1_dleafs[i].maxs[j] = LittleShort(q1_dleafs[i].maxs[j]);\n\t\t}\n\n\t\tq1_dleafs[i].firstmarksurface = LittleShort(q1_dleafs[i].firstmarksurface);\n\t\tq1_dleafs[i].nummarksurfaces = LittleShort(q1_dleafs[i].nummarksurfaces);\n\t\tq1_dleafs[i].visofs = LittleLong(q1_dleafs[i].visofs);\n\t}\n\n//\n// clipnodes\n//\n\tfor (i=0 ; i<q1_numclipnodes ; i++)\n\t{\n\t\tq1_dclipnodes[i].planenum = LittleLong(q1_dclipnodes[i].planenum);\n\t\tq1_dclipnodes[i].children[0] = LittleShort(q1_dclipnodes[i].children[0]);\n\t\tq1_dclipnodes[i].children[1] = LittleShort(q1_dclipnodes[i].children[1]);\n\t}\n\n//\n// miptex\n//\n\tif (q1_texdatasize)\n\t{\n\t\tmtl = (q1_dmiptexlump_t *)q1_dtexdata;\n\t\tif (todisk)\n\t\t\tc = mtl->nummiptex;\n\t\telse\n\t\t\tc = LittleLong(mtl->nummiptex);\n\t\tmtl->nummiptex = LittleLong (mtl->nummiptex);\n\t\tfor (i=0 ; i<c ; i++)\n\t\t\tmtl->dataofs[i] = LittleLong(mtl->dataofs[i]);\n\t}\n\t\n//\n// marksurfaces\n//\n\tfor (i=0 ; i<q1_nummarksurfaces ; i++)\n\t\tq1_dmarksurfaces[i] = LittleShort(q1_dmarksurfaces[i]);\n\n//\n// surfedges\n//\n\tfor (i=0 ; i<q1_numsurfedges ; i++)\n\t\tq1_dsurfedges[i] = LittleLong(q1_dsurfedges[i]);\n\n//\n// edges\n//\n\tfor (i=0 ; i<q1_numedges ; i++)\n\t{\n\t\tq1_dedges[i].v[0] = LittleShort(q1_dedges[i].v[0]);\n\t\tq1_dedges[i].v[1] = LittleShort(q1_dedges[i].v[1]);\n\t}\n}\n\n\nq1_dheader_t *q1_header;\nint\t\t\tq1_fileLength;\n\nint Q1_CopyLump (int lump, void *dest, int size, int maxsize)\n{\n\tint\t\tlength, ofs;\n\n\tlength = q1_header->lumps[lump].filelen;\n\tofs = q1_header->lumps[lump].fileofs;\n\t\n\tif (length % size) {\n\t\tError (\"LoadBSPFile: odd lump size\");\n\t}\n\t// somehow things got out of range\n\tif ((length/size) > maxsize) {\n\t\tprintf(\"WARNING: exceeded max size for lump %d size %d > maxsize %d\\n\", lump, (length/size), maxsize);\n\t\tlength = maxsize * size;\n\t}\n\tif ( ofs + length > q1_fileLength ) {\n\t\tprintf(\"WARNING: exceeded file length for lump %d\\n\", lump);\n\t\tlength = q1_fileLength - ofs;\n\t\tif ( length <= 0 ) {\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tmemcpy (dest, (byte *)q1_header + ofs, length);\n\n\treturn length / size;\n}\n\n/*\n=============\nQ1_LoadBSPFile\n=============\n*/\nvoid\tQ1_LoadBSPFile(char *filename, int offset, int length)\n{\n\tint\t\t\ti;\n\t\n//\n// load the file header\n//\n\tq1_fileLength = LoadFile(filename, (void **)&q1_header, offset, length);\n\n// swap the header\n\tfor (i=0 ; i< sizeof(q1_dheader_t)/4 ; i++)\n\t\t((int *)q1_header)[i] = LittleLong ( ((int *)q1_header)[i]);\n\n\tif (q1_header->version != Q1_BSPVERSION)\n\t\tError (\"%s is version %i, not %i\", filename, i, Q1_BSPVERSION);\n\n\tq1_nummodels = Q1_CopyLump (Q1_LUMP_MODELS, q1_dmodels, sizeof(q1_dmodel_t), Q1_MAX_MAP_MODELS );\n\tq1_numvertexes = Q1_CopyLump (Q1_LUMP_VERTEXES, q1_dvertexes, sizeof(q1_dvertex_t), Q1_MAX_MAP_VERTS );\n\tq1_numplanes = Q1_CopyLump (Q1_LUMP_PLANES, q1_dplanes, sizeof(q1_dplane_t), Q1_MAX_MAP_PLANES );\n\tq1_numleafs = Q1_CopyLump (Q1_LUMP_LEAFS, q1_dleafs, sizeof(q1_dleaf_t), Q1_MAX_MAP_LEAFS );\n\tq1_numnodes = Q1_CopyLump (Q1_LUMP_NODES, q1_dnodes, sizeof(q1_dnode_t), Q1_MAX_MAP_NODES );\n\tq1_numtexinfo = Q1_CopyLump (Q1_LUMP_TEXINFO, q1_texinfo, sizeof(q1_texinfo_t), Q1_MAX_MAP_TEXINFO );\n\tq1_numclipnodes = Q1_CopyLump (Q1_LUMP_CLIPNODES, q1_dclipnodes, sizeof(q1_dclipnode_t), Q1_MAX_MAP_CLIPNODES );\n\tq1_numfaces = Q1_CopyLump (Q1_LUMP_FACES, q1_dfaces, sizeof(q1_dface_t), Q1_MAX_MAP_FACES );\n\tq1_nummarksurfaces = Q1_CopyLump (Q1_LUMP_MARKSURFACES, q1_dmarksurfaces, sizeof(q1_dmarksurfaces[0]), Q1_MAX_MAP_MARKSURFACES );\n\tq1_numsurfedges = Q1_CopyLump (Q1_LUMP_SURFEDGES, q1_dsurfedges, sizeof(q1_dsurfedges[0]), Q1_MAX_MAP_SURFEDGES );\n\tq1_numedges = Q1_CopyLump (Q1_LUMP_EDGES, q1_dedges, sizeof(q1_dedge_t), Q1_MAX_MAP_EDGES );\n\n\tq1_texdatasize = Q1_CopyLump (Q1_LUMP_TEXTURES, q1_dtexdata, 1, Q1_MAX_MAP_MIPTEX );\n\tq1_visdatasize = Q1_CopyLump (Q1_LUMP_VISIBILITY, q1_dvisdata, 1, Q1_MAX_MAP_VISIBILITY );\n\tq1_lightdatasize = Q1_CopyLump (Q1_LUMP_LIGHTING, q1_dlightdata, 1, Q1_MAX_MAP_LIGHTING );\n\tq1_entdatasize = Q1_CopyLump (Q1_LUMP_ENTITIES, q1_dentdata, 1, Q1_MAX_MAP_ENTSTRING );\n\n\tFreeMemory(q1_header);\t\t// everything has been copied out\n\t\t\n//\n// swap everything\n//\t\n\tQ1_SwapBSPFile (false);\n}\n\n//============================================================================\n\nFILE *q1_wadfile;\nq1_dheader_t q1_outheader;\n\nvoid Q1_AddLump (int lumpnum, void *data, int len)\n{\n\tq1_lump_t *lump;\n\n\tlump = &q1_header->lumps[lumpnum];\n\t\n\tlump->fileofs = LittleLong(ftell(q1_wadfile));\n\tlump->filelen = LittleLong(len);\n\tSafeWrite(q1_wadfile, data, (len+3)&~3);\n}\n\n/*\n=============\nQ1_WriteBSPFile\n\nSwaps the bsp file in place, so it should not be referenced again\n=============\n*/\nvoid\tQ1_WriteBSPFile (char *filename)\n{\t\t\n\tq1_header = &q1_outheader;\n\tmemset (q1_header, 0, sizeof(q1_dheader_t));\n\t\n\tQ1_SwapBSPFile (true);\n\n\tq1_header->version = LittleLong (Q1_BSPVERSION);\n\t\n\tq1_wadfile = SafeOpenWrite (filename);\n\tSafeWrite (q1_wadfile, q1_header, sizeof(q1_dheader_t));\t// overwritten later\n\n\tQ1_AddLump (Q1_LUMP_PLANES, q1_dplanes, q1_numplanes*sizeof(q1_dplane_t));\n\tQ1_AddLump (Q1_LUMP_LEAFS, q1_dleafs, q1_numleafs*sizeof(q1_dleaf_t));\n\tQ1_AddLump (Q1_LUMP_VERTEXES, q1_dvertexes, q1_numvertexes*sizeof(q1_dvertex_t));\n\tQ1_AddLump (Q1_LUMP_NODES, q1_dnodes, q1_numnodes*sizeof(q1_dnode_t));\n\tQ1_AddLump (Q1_LUMP_TEXINFO, q1_texinfo, q1_numtexinfo*sizeof(q1_texinfo_t));\n\tQ1_AddLump (Q1_LUMP_FACES, q1_dfaces, q1_numfaces*sizeof(q1_dface_t));\n\tQ1_AddLump (Q1_LUMP_CLIPNODES, q1_dclipnodes, q1_numclipnodes*sizeof(q1_dclipnode_t));\n\tQ1_AddLump (Q1_LUMP_MARKSURFACES, q1_dmarksurfaces, q1_nummarksurfaces*sizeof(q1_dmarksurfaces[0]));\n\tQ1_AddLump (Q1_LUMP_SURFEDGES, q1_dsurfedges, q1_numsurfedges*sizeof(q1_dsurfedges[0]));\n\tQ1_AddLump (Q1_LUMP_EDGES, q1_dedges, q1_numedges*sizeof(q1_dedge_t));\n\tQ1_AddLump (Q1_LUMP_MODELS, q1_dmodels, q1_nummodels*sizeof(q1_dmodel_t));\n\n\tQ1_AddLump (Q1_LUMP_LIGHTING, q1_dlightdata, q1_lightdatasize);\n\tQ1_AddLump (Q1_LUMP_VISIBILITY, q1_dvisdata, q1_visdatasize);\n\tQ1_AddLump (Q1_LUMP_ENTITIES, q1_dentdata, q1_entdatasize);\n\tQ1_AddLump (Q1_LUMP_TEXTURES, q1_dtexdata, q1_texdatasize);\n\t\n\tfseek (q1_wadfile, 0, SEEK_SET);\n\tSafeWrite (q1_wadfile, q1_header, sizeof(q1_dheader_t));\n\tfclose (q1_wadfile);\t\n}\n\n//============================================================================\n\n/*\n=============\nQ1_PrintBSPFileSizes\n\nDumps info about current file\n=============\n*/\nvoid Q1_PrintBSPFileSizes (void)\n{\n\tprintf (\"%5i planes       %6i\\n\"\n\t\t,q1_numplanes, (int)(q1_numplanes*sizeof(q1_dplane_t)));\n\tprintf (\"%5i vertexes     %6i\\n\"\n\t\t,q1_numvertexes, (int)(q1_numvertexes*sizeof(q1_dvertex_t)));\n\tprintf (\"%5i nodes        %6i\\n\"\n\t\t,q1_numnodes, (int)(q1_numnodes*sizeof(q1_dnode_t)));\n\tprintf (\"%5i texinfo      %6i\\n\"\n\t\t,q1_numtexinfo, (int)(q1_numtexinfo*sizeof(q1_texinfo_t)));\n\tprintf (\"%5i faces        %6i\\n\"\n\t\t,q1_numfaces, (int)(q1_numfaces*sizeof(q1_dface_t)));\n\tprintf (\"%5i clipnodes    %6i\\n\"\n\t\t,q1_numclipnodes, (int)(q1_numclipnodes*sizeof(q1_dclipnode_t)));\n\tprintf (\"%5i leafs        %6i\\n\"\n\t\t,q1_numleafs, (int)(q1_numleafs*sizeof(q1_dleaf_t)));\n\tprintf (\"%5i marksurfaces %6i\\n\"\n\t\t,q1_nummarksurfaces, (int)(q1_nummarksurfaces*sizeof(q1_dmarksurfaces[0])));\n\tprintf (\"%5i surfedges    %6i\\n\"\n\t\t,q1_numsurfedges, (int)(q1_numsurfedges*sizeof(q1_dmarksurfaces[0])));\n\tprintf (\"%5i edges        %6i\\n\"\n\t\t,q1_numedges, (int)(q1_numedges*sizeof(q1_dedge_t)));\n\tif (!q1_texdatasize)\n\t\tprintf (\"    0 textures          0\\n\");\n\telse\n\t\tprintf (\"%5i textures     %6i\\n\",((q1_dmiptexlump_t*)q1_dtexdata)->nummiptex, q1_texdatasize);\n\tprintf (\"      lightdata    %6i\\n\", q1_lightdatasize);\n\tprintf (\"      visdata      %6i\\n\", q1_visdatasize);\n\tprintf (\"      entdata      %6i\\n\", q1_entdatasize);\n} //end of the function Q1_PrintBSPFileSizes\n\n\n/*\n================\nQ1_ParseEntities\n\nParses the dentdata string into entities\n================\n*/\nvoid Q1_ParseEntities (void)\n{\n\tscript_t *script;\n\n\tnum_entities = 0;\n\tscript = LoadScriptMemory(q1_dentdata, q1_entdatasize, \"*Quake1 bsp file\");\n\tSetScriptFlags(script, SCFL_NOSTRINGWHITESPACES |\n\t\t\t\t\t\t\t\t\tSCFL_NOSTRINGESCAPECHARS);\n\n\twhile(ParseEntity(script))\n\t{\n\t} //end while\n\n\tFreeScript(script);\n} //end of the function Q1_ParseEntities\n\n\n/*\n================\nQ1_UnparseEntities\n\nGenerates the dentdata string from all the entities\n================\n*/\nvoid Q1_UnparseEntities (void)\n{\n\tchar *buf, *end;\n\tepair_t *ep;\n\tchar line[2048];\n\tint i;\n\t\n\tbuf = q1_dentdata;\n\tend = buf;\n\t*end = 0;\n\t\n\tfor (i=0 ; i<num_entities ; i++)\n\t{\n\t\tep = entities[i].epairs;\n\t\tif (!ep)\n\t\t\tcontinue;\t// ent got removed\n\t\t\n\t\tstrcat (end,\"{\\n\");\n\t\tend += 2;\n\t\t\t\t\n\t\tfor (ep = entities[i].epairs ; ep ; ep=ep->next)\n\t\t{\n\t\t\tsprintf (line, \"\\\"%s\\\" \\\"%s\\\"\\n\", ep->key, ep->value);\n\t\t\tstrcat (end, line);\n\t\t\tend += strlen(line);\n\t\t}\n\t\tstrcat (end,\"}\\n\");\n\t\tend += 2;\n\n\t\tif (end > buf + Q1_MAX_MAP_ENTSTRING)\n\t\t\tError (\"Entity text too long\");\n\t}\n\tq1_entdatasize = end - buf + 1;\n} //end of the function Q1_UnparseEntities\n"
  },
  {
    "path": "code/bspc/l_bsp_q1.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n\n// upper design bounds\n\n#define\tQ1_MAX_MAP_HULLS\t\t4\n\n#define\tQ1_MAX_MAP_MODELS\t\t256\n#define\tQ1_MAX_MAP_BRUSHES\t\t4096\n#define\tQ1_MAX_MAP_ENTITIES\t1024\n#define\tQ1_MAX_MAP_ENTSTRING\t65536\n\n#define\tQ1_MAX_MAP_PLANES\t\t8192\n#define\tQ1_MAX_MAP_NODES\t\t32767\t\t// because negative shorts are contents\n#define\tQ1_MAX_MAP_CLIPNODES\t32767\t\t//\n#define\tQ1_MAX_MAP_LEAFS\t\t32767\t\t// \n#define\tQ1_MAX_MAP_VERTS\t\t65535\n#define\tQ1_MAX_MAP_FACES\t\t65535\n#define\tQ1_MAX_MAP_MARKSURFACES 65535\n#define\tQ1_MAX_MAP_TEXINFO\t\t4096\n#define\tQ1_MAX_MAP_EDGES\t\t256000\n#define\tQ1_MAX_MAP_SURFEDGES\t512000\n#define\tQ1_MAX_MAP_MIPTEX\t\t0x200000\n#define\tQ1_MAX_MAP_LIGHTING\t0x100000\n#define\tQ1_MAX_MAP_VISIBILITY\t0x100000\n\n// key / value pair sizes\n\n#define\tMAX_KEY\t\t32\n#define\tMAX_VALUE\t1024\n\n//=============================================================================\n\n\n#define Q1_BSPVERSION\t29\n\ntypedef struct\n{\n\tint fileofs, filelen;\n} q1_lump_t;\n\n#define\tQ1_LUMP_ENTITIES\t0\n#define\tQ1_LUMP_PLANES\t\t1\n#define\tQ1_LUMP_TEXTURES\t2\n#define\tQ1_LUMP_VERTEXES\t3\n#define\tQ1_LUMP_VISIBILITY\t4\n#define\tQ1_LUMP_NODES\t\t5\n#define\tQ1_LUMP_TEXINFO\t6\n#define\tQ1_LUMP_FACES\t\t7\n#define\tQ1_LUMP_LIGHTING\t8\n#define\tQ1_LUMP_CLIPNODES\t9\n#define\tQ1_LUMP_LEAFS\t\t10\n#define\tQ1_LUMP_MARKSURFACES 11\n#define\tQ1_LUMP_EDGES\t\t12\n#define\tQ1_LUMP_SURFEDGES\t13\n#define\tQ1_LUMP_MODELS\t\t14\n\n#define\tQ1_HEADER_LUMPS\t15\n\ntypedef struct\n{\n\tfloat\t\tmins[3], maxs[3];\n\tfloat\t\torigin[3];\n\tint\t\theadnode[Q1_MAX_MAP_HULLS];\n\tint\t\tvisleafs;\t\t// not including the solid leaf 0\n\tint\t\tfirstface, numfaces;\n} q1_dmodel_t;\n\ntypedef struct\n{\n\tint\t\t\tversion;\t\n\tq1_lump_t\tlumps[Q1_HEADER_LUMPS];\n} q1_dheader_t;\n\ntypedef struct\n{\n\tint\t\tnummiptex;\n\tint\t\tdataofs[4];\t\t// [nummiptex]\n} q1_dmiptexlump_t;\n\n#define\tMIPLEVELS\t4\ntypedef struct q1_miptex_s\n{\n\tchar\t\tname[16];\n\tunsigned\twidth, height;\n\tunsigned\toffsets[MIPLEVELS];\t\t// four mip maps stored\n} q1_miptex_t;\n\n\ntypedef struct\n{\n\tfloat\tpoint[3];\n} q1_dvertex_t;\n\n\n// 0-2 are axial planes\n#define\tPLANE_X\t\t\t0\n#define\tPLANE_Y\t\t\t1\n#define\tPLANE_Z\t\t\t2\n\n// 3-5 are non-axial planes snapped to the nearest\n#define\tPLANE_ANYX\t\t3\n#define\tPLANE_ANYY\t\t4\n#define\tPLANE_ANYZ\t\t5\n\ntypedef struct\n{\n\tfloat\tnormal[3];\n\tfloat\tdist;\n\tint\t\ttype;\t\t// PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate\n} q1_dplane_t;\n\n\n\n#define\tQ1_CONTENTS_EMPTY\t\t-1\n#define\tQ1_CONTENTS_SOLID\t\t-2\n#define\tQ1_CONTENTS_WATER\t\t-3\n#define\tQ1_CONTENTS_SLIME\t\t-4\n#define\tQ1_CONTENTS_LAVA\t\t-5\n#define\tQ1_CONTENTS_SKY\t\t-6\n\n// !!! if this is changed, it must be changed in asm_i386.h too !!!\ntypedef struct\n{\n\tint\t\tplanenum;\n\tshort\t\tchildren[2];\t// negative numbers are -(leafs+1), not nodes\n\tshort\t\tmins[3];\t\t// for sphere culling\n\tshort\t\tmaxs[3];\n\tunsigned short\tfirstface;\n\tunsigned short\tnumfaces;\t// counting both sides\n} q1_dnode_t;\n\ntypedef struct\n{\n\tint\t\tplanenum;\n\tshort\t\tchildren[2];\t// negative numbers are contents\n} q1_dclipnode_t;\n\n\ntypedef struct q1_texinfo_s\n{\n\tfloat\t\tvecs[2][4];\t\t// [s/t][xyz offset]\n\tint\t\tmiptex;\n\tint\t\tflags;\n} q1_texinfo_t;\n#define\tTEX_SPECIAL\t\t1\t\t// sky or slime, no lightmap or 256 subdivision\n\n// note that edge 0 is never used, because negative edge nums are used for\n// counterclockwise use of the edge in a face\ntypedef struct\n{\n\tunsigned short\tv[2];\t\t// vertex numbers\n} q1_dedge_t;\n\n#define\tMAXLIGHTMAPS\t4\ntypedef struct\n{\n\tshort\t\tplanenum;\n\tshort\t\tside;\n\n\tint\t\tfirstedge;\t\t// we must support > 64k edges\n\tshort\t\tnumedges;\t\n\tshort\t\ttexinfo;\n\n// lighting info\n\tbyte\t\tstyles[MAXLIGHTMAPS];\n\tint\t\tlightofs;\t\t// start of [numstyles*surfsize] samples\n} q1_dface_t;\n\n\n\n#define\tAMBIENT_WATER\t0\n#define\tAMBIENT_SKY\t\t1\n#define\tAMBIENT_SLIME\t2\n#define\tAMBIENT_LAVA\t3\n\n#define\tNUM_AMBIENTS\t\t\t4\t\t// automatic ambient sounds\n\n// leaf 0 is the generic Q1_CONTENTS_SOLID leaf, used for all solid areas\n// all other leafs need visibility info\ntypedef struct\n{\n\tint\t\t\t\tcontents;\n\tint\t\t\t\tvisofs;\t\t\t\t// -1 = no visibility info\n\n\tshort\t\t\t\tmins[3];\t\t\t// for frustum culling\n\tshort\t\t\t\tmaxs[3];\n\n\tunsigned short\tfirstmarksurface;\n\tunsigned short\tnummarksurfaces;\n\n\tbyte\t\tambient_level[NUM_AMBIENTS];\n} q1_dleaf_t;\n\n//============================================================================\n\n#ifndef QUAKE_GAME\n\n// the utilities get to be lazy and just use large static arrays\n\nextern\tint\t\t\t\tq1_nummodels;\nextern\tq1_dmodel_t\t\t*q1_dmodels;//[MAX_MAP_MODELS];\n\nextern\tint\t\t\t\tq1_visdatasize;\nextern\tbyte\t\t\t\t*q1_dvisdata;//[MAX_MAP_VISIBILITY];\n\nextern\tint\t\t\t\tq1_lightdatasize;\nextern\tbyte\t\t\t\t*q1_dlightdata;//[MAX_MAP_LIGHTING];\n\nextern\tint\t\t\t\tq1_texdatasize;\nextern\tbyte\t\t\t\t*q1_dtexdata;//[MAX_MAP_MIPTEX]; // (dmiptexlump_t)\n\nextern\tint\t\t\t\tq1_entdatasize;\nextern\tchar\t\t\t\t*q1_dentdata;//[MAX_MAP_ENTSTRING];\n\nextern\tint\t\t\t\tq1_numleafs;\nextern\tq1_dleaf_t\t\t*q1_dleafs;//[MAX_MAP_LEAFS];\n\nextern\tint\t\t\t\tq1_numplanes;\nextern\tq1_dplane_t\t\t*q1_dplanes;//[MAX_MAP_PLANES];\n\nextern\tint\t\t\t\tq1_numvertexes;\nextern\tq1_dvertex_t\t*q1_dvertexes;//[MAX_MAP_VERTS];\n\nextern\tint\t\t\t\tq1_numnodes;\nextern\tq1_dnode_t\t\t*q1_dnodes;//[MAX_MAP_NODES];\n\nextern\tint\t\t\t\tq1_numtexinfo;\nextern\tq1_texinfo_t\t*q1_texinfo;//[MAX_MAP_TEXINFO];\n\nextern\tint\t\t\t\tq1_numfaces;\nextern\tq1_dface_t\t\t*q1_dfaces;//[MAX_MAP_FACES];\n\nextern\tint\t\t\t\tq1_numclipnodes;\nextern\tq1_dclipnode_t\t*q1_dclipnodes;//[MAX_MAP_CLIPNODES];\n\nextern\tint\t\t\t\tq1_numedges;\nextern\tq1_dedge_t\t\t*q1_dedges;//[MAX_MAP_EDGES];\n\nextern\tint\t\t\t\tq1_nummarksurfaces;\nextern\tunsigned short\t*q1_dmarksurfaces;//[MAX_MAP_MARKSURFACES];\n\nextern\tint\t\t\t\tq1_numsurfedges;\nextern\tint\t\t\t\t*q1_dsurfedges;//[MAX_MAP_SURFEDGES];\n\n\nvoid Q1_AllocMaxBSP(void);\nvoid Q1_FreeMaxBSP(void);\nvoid Q1_LoadBSPFile(char *filename, int offset, int length);\nvoid Q1_WriteBSPFile(char *filename);\nvoid Q1_PrintBSPFileSizes(void);\nvoid Q1_ParseEntities(void);\nvoid Q1_UnparseEntities(void);\n\n#endif\n"
  },
  {
    "path": "code/bspc/l_bsp_q2.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"l_cmd.h\"\n#include \"l_math.h\"\n#include \"l_mem.h\"\n#include \"l_log.h\"\n#include \"l_poly.h\"\n#include \"../botlib/l_script.h\"\n#include \"q2files.h\"\n#include \"l_bsp_q2.h\"\n#include \"l_bsp_ent.h\"\n\n#define q2_dmodel_t\t\t\tdmodel_t\n#define q2_lump_t\t\t\t\tlump_t\n#define q2_dheader_t\t\t\tdheader_t\n#define q2_dmodel_t\t\t\tdmodel_t\n#define q2_dvertex_t\t\t\tdvertex_t\n#define q2_dplane_t\t\t\tdplane_t\n#define q2_dnode_t\t\t\tdnode_t\n#define q2_texinfo_t\t\t\ttexinfo_t\n#define q2_dedge_t\t\t\tdedge_t\n#define q2_dface_t\t\t\tdface_t\n#define q2_dleaf_t\t\t\tdleaf_t\n#define q2_dbrushside_t\t\tdbrushside_t\n#define q2_dbrush_t\t\t\tdbrush_t\n#define q2_dvis_t\t\t\t\tdvis_t\n#define q2_dareaportal_t\tdareaportal_t\n#define q2_darea_t\t\t\tdarea_t\n\n#define q2_nummodels\t\t\tnummodels\n#define q2_dmodels\t\t\tdmodels\n#define q2_numleafs\t\t\tnumleafs\n#define q2_dleafs\t\t\t\tdleafs\n#define q2_numplanes\t\t\tnumplanes\n#define q2_dplanes\t\t\tdplanes\n#define q2_numvertexes\t\tnumvertexes\n#define q2_dvertexes\t\t\tdvertexes\n#define q2_numnodes\t\t\tnumnodes\n#define q2_dnodes\t\t\t\tdnodes\n#define q2_numtexinfo\t\tnumtexinfo\n#define q2_texinfo\t\t\ttexinfo\n#define q2_numfaces\t\t\tnumfaces\n#define q2_dfaces\t\t\t\tdfaces\n#define q2_numedges\t\t\tnumedges\n#define q2_dedges\t\t\t\tdedges\n#define q2_numleaffaces\t\tnumleaffaces\n#define q2_dleaffaces\t\tdleaffaces\n#define q2_numleafbrushes\tnumleafbrushes\n#define q2_dleafbrushes\t\tdleafbrushes\n#define q2_dsurfedges\t\tdsurfedges\n#define q2_numbrushes\t\tnumbrushes\n#define q2_dbrushes\t\t\tdbrushes\n#define q2_numbrushsides\tnumbrushsides\n#define q2_dbrushsides\t\tdbrushsides\n#define q2_numareas\t\t\tnumareas\n#define q2_dareas\t\t\t\tdareas\n#define q2_numareaportals\tnumareaportals\n#define q2_dareaportals\t\tdareaportals\n\nvoid GetLeafNums (void);\n\n//=============================================================================\n\nint\t\t\t\tnummodels;\ndmodel_t\t\t\t*dmodels;//[MAX_MAP_MODELS];\n\nint\t\t\t\tvisdatasize;\nbyte\t\t\t\t*dvisdata;//[MAX_MAP_VISIBILITY];\ndvis_t\t\t\t*dvis;// = (dvis_t *)dvisdata;\n\nint\t\t\t\tlightdatasize;\nbyte\t\t\t\t*dlightdata;//[MAX_MAP_LIGHTING];\n\nint\t\t\t\tentdatasize;\nchar\t\t\t\t*dentdata;//[MAX_MAP_ENTSTRING];\n\nint\t\t\t\tnumleafs;\ndleaf_t\t\t\t*dleafs;//[MAX_MAP_LEAFS];\n\nint\t\t\t\tnumplanes;\ndplane_t\t\t\t*dplanes;//[MAX_MAP_PLANES];\n\nint\t\t\t\tnumvertexes;\ndvertex_t\t\t*dvertexes;//[MAX_MAP_VERTS];\n\nint\t\t\t\tnumnodes;\ndnode_t\t\t\t*dnodes;//[MAX_MAP_NODES];\n\n//NOTE: must be static for q2 .map to q2 .bsp\nint\t\t\t\tnumtexinfo;\ntexinfo_t\t\ttexinfo[MAX_MAP_TEXINFO];\n\nint\t\t\t\tnumfaces;\ndface_t\t\t\t*dfaces;//[MAX_MAP_FACES];\n\nint\t\t\t\tnumedges;\ndedge_t\t\t\t*dedges;//[MAX_MAP_EDGES];\n\nint\t\t\t\tnumleaffaces;\nunsigned short\t*dleaffaces;//[MAX_MAP_LEAFFACES];\n\nint\t\t\t\tnumleafbrushes;\nunsigned short\t*dleafbrushes;//[MAX_MAP_LEAFBRUSHES];\n\nint\t\t\t\tnumsurfedges;\nint\t\t\t\t*dsurfedges;//[MAX_MAP_SURFEDGES];\n\nint\t\t\t\tnumbrushes;\ndbrush_t\t\t\t*dbrushes;//[MAX_MAP_BRUSHES];\n\nint\t\t\t\tnumbrushsides;\ndbrushside_t\t*dbrushsides;//[MAX_MAP_BRUSHSIDES];\n\nint\t\t\t\tnumareas;\ndarea_t\t\t\t*dareas;//[MAX_MAP_AREAS];\n\nint\t\t\t\tnumareaportals;\ndareaportal_t\t*dareaportals;//[MAX_MAP_AREAPORTALS];\n\n#define MAX_MAP_DPOP\t\t\t256\nbyte\t\t\t\tdpop[MAX_MAP_DPOP];\n\n//\nchar brushsidetextured[MAX_MAP_BRUSHSIDES];\n\n//#ifdef ME\n\nint bspallocated = false;\nint allocatedbspmem = 0;\n\nvoid Q2_AllocMaxBSP(void)\n{\n\t//models\n\tnummodels = 0;\n\tdmodels = (dmodel_t *) GetClearedMemory(MAX_MAP_MODELS * sizeof(dmodel_t));\n\tallocatedbspmem += MAX_MAP_MODELS * sizeof(dmodel_t);\n\t//vis data\n\tvisdatasize = 0;\n\tdvisdata = (byte *) GetClearedMemory(MAX_MAP_VISIBILITY * sizeof(byte));\n\tdvis = (dvis_t *) dvisdata;\n\tallocatedbspmem += MAX_MAP_VISIBILITY * sizeof(byte);\n\t//light data\n\tlightdatasize = 0;\n\tdlightdata = (byte *) GetClearedMemory(MAX_MAP_LIGHTING * sizeof(byte));\n\tallocatedbspmem += MAX_MAP_LIGHTING * sizeof(byte);\n\t//entity data\n\tentdatasize = 0;\n\tdentdata = (char *) GetClearedMemory(MAX_MAP_ENTSTRING * sizeof(char));\n\tallocatedbspmem += MAX_MAP_ENTSTRING * sizeof(char);\n\t//leafs\n\tnumleafs = 0;\n\tdleafs = (dleaf_t *) GetClearedMemory(MAX_MAP_LEAFS * sizeof(dleaf_t));\n\tallocatedbspmem += MAX_MAP_LEAFS * sizeof(dleaf_t);\n\t//planes\n\tnumplanes = 0;\n\tdplanes = (dplane_t *) GetClearedMemory(MAX_MAP_PLANES * sizeof(dplane_t));\n\tallocatedbspmem += MAX_MAP_PLANES * sizeof(dplane_t);\n\t//vertexes\n\tnumvertexes = 0;\n\tdvertexes = (dvertex_t *) GetClearedMemory(MAX_MAP_VERTS * sizeof(dvertex_t));\n\tallocatedbspmem += MAX_MAP_VERTS * sizeof(dvertex_t);\n\t//nodes\n\tnumnodes = 0;\n\tdnodes = (dnode_t *) GetClearedMemory(MAX_MAP_NODES * sizeof(dnode_t));\n\tallocatedbspmem += MAX_MAP_NODES * sizeof(dnode_t);\n\t/*\n\t//texture info\n\tnumtexinfo = 0;\n\ttexinfo = (texinfo_t *) GetClearedMemory(MAX_MAP_TEXINFO * sizeof(texinfo_t));\n\tallocatedbspmem += MAX_MAP_TEXINFO * sizeof(texinfo_t);\n\t//*/\n\t//faces\n\tnumfaces = 0;\n\tdfaces = (dface_t *) GetClearedMemory(MAX_MAP_FACES * sizeof(dface_t));\n\tallocatedbspmem += MAX_MAP_FACES * sizeof(dface_t);\n\t//edges\n\tnumedges = 0;\n\tdedges = (dedge_t *) GetClearedMemory(MAX_MAP_EDGES * sizeof(dedge_t));\n\tallocatedbspmem += MAX_MAP_EDGES * sizeof(dedge_t);\n\t//leaf faces\n\tnumleaffaces = 0;\n\tdleaffaces = (unsigned short *) GetClearedMemory(MAX_MAP_LEAFFACES * sizeof(unsigned short));\n\tallocatedbspmem += MAX_MAP_LEAFFACES * sizeof(unsigned short);\n\t//leaf brushes\n\tnumleafbrushes = 0;\n\tdleafbrushes = (unsigned short *) GetClearedMemory(MAX_MAP_LEAFBRUSHES * sizeof(unsigned short));\n\tallocatedbspmem += MAX_MAP_LEAFBRUSHES * sizeof(unsigned short);\n\t//surface edges\n\tnumsurfedges = 0;\n\tdsurfedges = (int *) GetClearedMemory(MAX_MAP_SURFEDGES * sizeof(int));\n\tallocatedbspmem += MAX_MAP_SURFEDGES * sizeof(int);\n\t//brushes\n\tnumbrushes = 0;\n\tdbrushes = (dbrush_t *) GetClearedMemory(MAX_MAP_BRUSHES * sizeof(dbrush_t));\n\tallocatedbspmem += MAX_MAP_BRUSHES * sizeof(dbrush_t);\n\t//brushsides\n\tnumbrushsides = 0;\n\tdbrushsides = (dbrushside_t *) GetClearedMemory(MAX_MAP_BRUSHSIDES * sizeof(dbrushside_t));\n\tallocatedbspmem += MAX_MAP_BRUSHSIDES * sizeof(dbrushside_t);\n\t//areas\n\tnumareas = 0;\n\tdareas = (darea_t *) GetClearedMemory(MAX_MAP_AREAS * sizeof(darea_t));\n\tallocatedbspmem += MAX_MAP_AREAS * sizeof(darea_t);\n\t//area portals\n\tnumareaportals = 0;\n\tdareaportals = (dareaportal_t *) GetClearedMemory(MAX_MAP_AREAPORTALS * sizeof(dareaportal_t));\n\tallocatedbspmem += MAX_MAP_AREAPORTALS * sizeof(dareaportal_t);\n\t//print allocated memory\n\tLog_Print(\"allocated \");\n\tPrintMemorySize(allocatedbspmem);\n\tLog_Print(\" of BSP memory\\n\");\n} //end of the function Q2_AllocMaxBSP\n\nvoid Q2_FreeMaxBSP(void)\n{\n\t//models\n\tnummodels = 0;\n\tFreeMemory(dmodels);\n\tdmodels = NULL;\n\t//vis data\n\tvisdatasize = 0;\n\tFreeMemory(dvisdata);\n\tdvisdata = NULL;\n\tdvis = NULL;\n\t//light data\n\tlightdatasize = 0;\n\tFreeMemory(dlightdata);\n\tdlightdata = NULL;\n\t//entity data\n\tentdatasize = 0;\n\tFreeMemory(dentdata);\n\tdentdata = NULL;\n\t//leafs\n\tnumleafs = 0;\n\tFreeMemory(dleafs);\n\tdleafs = NULL;\n\t//planes\n\tnumplanes = 0;\n\tFreeMemory(dplanes);\n\tdplanes = NULL;\n\t//vertexes\n\tnumvertexes = 0;\n\tFreeMemory(dvertexes);\n\tdvertexes = NULL;\n\t//nodes\n\tnumnodes = 0;\n\tFreeMemory(dnodes);\n\tdnodes = NULL;\n\t/*\n\t//texture info\n\tnumtexinfo = 0;\n\tFreeMemory(texinfo);\n\ttexinfo = NULL;\n\t//*/\n\t//faces\n\tnumfaces = 0;\n\tFreeMemory(dfaces);\n\tdfaces = NULL;\n\t//edges\n\tnumedges = 0;\n\tFreeMemory(dedges);\n\tdedges = NULL;\n\t//leaf faces\n\tnumleaffaces = 0;\n\tFreeMemory(dleaffaces);\n\tdleaffaces = NULL;\n\t//leaf brushes\n\tnumleafbrushes = 0;\n\tFreeMemory(dleafbrushes);\n\tdleafbrushes = NULL;\n\t//surface edges\n\tnumsurfedges = 0;\n\tFreeMemory(dsurfedges);\n\tdsurfedges = NULL;\n\t//brushes\n\tnumbrushes = 0;\n\tFreeMemory(dbrushes);\n\tdbrushes = NULL;\n\t//brushsides\n\tnumbrushsides = 0;\n\tFreeMemory(dbrushsides);\n\tdbrushsides = NULL;\n\t//areas\n\tnumareas = 0;\n\tFreeMemory(dareas);\n\tdareas = NULL;\n\t//area portals\n\tnumareaportals = 0;\n\tFreeMemory(dareaportals);\n\tdareaportals = NULL;\n\t//\n\tLog_Print(\"freed \");\n\tPrintMemorySize(allocatedbspmem);\n\tLog_Print(\" of BSP memory\\n\");\n\tallocatedbspmem = 0;\n} //end of the function Q2_FreeMaxBSP\n\n#define WCONVEX_EPSILON\t\t0.5\n\nint InsideWinding(winding_t *w, vec3_t point, int planenum)\n{\n\tint i;\n\tfloat dist;\n\tvec_t *v1, *v2;\n\tvec3_t normal, edgevec;\n\tdplane_t *plane;\n\n\tfor (i = 1; i <= w->numpoints; i++)\n\t{\n\t\tv1 = w->p[i % w->numpoints];\n\t\tv2 = w->p[(i + 1) % w->numpoints];\n\n\t\tVectorSubtract(v2, v1, edgevec);\n\t\tplane = &dplanes[planenum];\n\t\tCrossProduct(plane->normal, edgevec, normal);\n\t\tVectorNormalize(normal);\n\t\tdist = DotProduct(normal, v1);\n\t\t//\n\t\tif (DotProduct(normal, point) - dist > WCONVEX_EPSILON) return false;\n\t} //end for\n\treturn true;\n} //end of the function InsideWinding\n\nint InsideFace(dface_t *face, vec3_t point)\n{\n\tint i, edgenum, side;\n\tfloat dist;\n\tvec_t *v1, *v2;\n\tvec3_t normal, edgevec;\n\tdplane_t *plane;\n\n\tfor (i = 0; i < face->numedges; i++)\n\t{\n\t\t//get the first and second vertex of the edge\n\t\tedgenum = dsurfedges[face->firstedge + i];\n\t\tside = edgenum < 0;\n\t\tv1 = dvertexes[dedges[abs(edgenum)].v[side]].point;\n\t\tv2 = dvertexes[dedges[abs(edgenum)].v[!side]].point;\n\t\t//create a plane through the edge vector, orthogonal to the face plane\n\t\t//and with the normal vector pointing out of the face\n\t\tVectorSubtract(v1, v2, edgevec);\n\t\tplane = &dplanes[face->planenum];\n\t\tCrossProduct(plane->normal, edgevec, normal);\n\t\tVectorNormalize(normal);\n\t\tdist = DotProduct(normal, v1);\n\t\t//\n\t\tif (DotProduct(normal, point) - dist > WCONVEX_EPSILON) return false;\n\t} //end for\n\treturn true;\n} //end of the function InsideFace\n//===========================================================================\n// returns the amount the face and the winding overlap\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat Q2_FaceOnWinding(q2_dface_t *face, winding_t *winding)\n{\n\tint i, edgenum, side;\n\tfloat dist, area;\n\tq2_dplane_t plane;\n\tvec_t *v1, *v2;\n\tvec3_t normal, edgevec;\n\twinding_t *w;\n\n\t//\n\tw = CopyWinding(winding);\n\tmemcpy(&plane, &q2_dplanes[face->planenum], sizeof(q2_dplane_t));\n\t//check on which side of the plane the face is\n\tif (face->side)\n\t{\n\t\tVectorNegate(plane.normal, plane.normal);\n\t\tplane.dist = -plane.dist;\n\t} //end if\n\tfor (i = 0; i < face->numedges && w; i++)\n\t{\n\t\t//get the first and second vertex of the edge\n\t\tedgenum = q2_dsurfedges[face->firstedge + i];\n\t\tside = edgenum > 0;\n\t\t//if the face plane is flipped\n\t\tv1 = q2_dvertexes[q2_dedges[abs(edgenum)].v[side]].point;\n\t\tv2 = q2_dvertexes[q2_dedges[abs(edgenum)].v[!side]].point;\n\t\t//create a plane through the edge vector, orthogonal to the face plane\n\t\t//and with the normal vector pointing inward\n\t\tVectorSubtract(v1, v2, edgevec);\n\t\tCrossProduct(edgevec, plane.normal, normal);\n\t\tVectorNormalize(normal);\n\t\tdist = DotProduct(normal, v1);\n\t\t//\n\t\tChopWindingInPlace(&w, normal, dist, -0.1); //CLIP_EPSILON\n\t} //end for\n\tif (w)\n\t{\n\t\tarea = WindingArea(w);\n\t\tFreeWinding(w);\n\t\treturn area;\n\t} //end if\n\treturn 0;\n} //end of the function Q2_FaceOnWinding\n//===========================================================================\n// creates a winding for the given brush side on the given brush\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nwinding_t *Q2_BrushSideWinding(dbrush_t *brush, dbrushside_t *baseside)\n{\n\tint i;\n\tdplane_t *baseplane, *plane;\n\twinding_t *w;\n\tdbrushside_t *side;\n\t\n\t//create a winding for the brush side with the given planenumber\n\tbaseplane = &dplanes[baseside->planenum];\n\tw = BaseWindingForPlane(baseplane->normal, baseplane->dist);\n\tfor (i = 0; i < brush->numsides && w; i++)\n\t{\n\t\tside = &dbrushsides[brush->firstside + i];\n\t\t//don't chop with the base plane\n\t\tif (side->planenum == baseside->planenum) continue;\n\t\t//also don't use planes that are almost equal\n\t\tplane = &dplanes[side->planenum];\n\t\tif (DotProduct(baseplane->normal, plane->normal) > 0.999\n\t\t\t\t&& fabs(baseplane->dist - plane->dist) < 0.01) continue;\n\t\t//\n\t\tplane = &dplanes[side->planenum^1];\n\t\tChopWindingInPlace(&w, plane->normal, plane->dist, -0.1); //CLIP_EPSILON);\n\t} //end for\n\treturn w;\n} //end of the function Q2_BrushSideWinding\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint Q2_HintSkipBrush(dbrush_t *brush)\n{\n\tint j;\n\tdbrushside_t *brushside;\n\n\tfor (j = 0; j < brush->numsides; j++)\n\t{\n\t\tbrushside = &dbrushsides[brush->firstside + j];\n\t\tif (brushside->texinfo > 0)\n\t\t{\n\t\t\tif (texinfo[brushside->texinfo].flags & (SURF_SKIP|SURF_HINT))\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n\treturn false;\n} //end of the function Q2_HintSkipBrush\n//===========================================================================\n// fix screwed brush texture references\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean WindingIsTiny(winding_t *w);\n\nvoid Q2_FixTextureReferences(void)\n{\n\tint i, j, k, we;\n\tdbrushside_t *brushside;\n\tdbrush_t *brush;\n\tdface_t *face;\n\twinding_t *w;\n\n\tmemset(brushsidetextured, false, MAX_MAP_BRUSHSIDES);\n\t//go over all the brushes\n   for (i = 0; i < numbrushes; i++)\n   {\n\t\tbrush = &dbrushes[i];\n\t\t//hint brushes are not textured\n\t\tif (Q2_HintSkipBrush(brush)) continue;\n\t\t//go over all the sides of the brush\n\t\tfor (j = 0; j < brush->numsides; j++)\n\t\t{\n\t\t\tbrushside = &dbrushsides[brush->firstside + j];\n\t\t\t//\n\t\t\tw = Q2_BrushSideWinding(brush, brushside);\n\t\t\tif (!w)\n\t\t\t{\n\t\t\t\tbrushsidetextured[brush->firstside + j] = true;\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\t//RemoveEqualPoints(w, 0.2);\n\t\t\t\tif (WindingIsTiny(w))\n\t\t\t\t{\n\t\t\t\t\tFreeWinding(w);\n\t\t\t\t\tbrushsidetextured[brush->firstside + j] = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t} //end if\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\twe = WindingError(w);\n\t\t\t\t\tif (we == WE_NOTENOUGHPOINTS\n\t\t\t\t\t\t|| we == WE_SMALLAREA\n\t\t\t\t\t\t|| we == WE_POINTBOGUSRANGE\n//\t\t\t\t\t\t|| we == WE_NONCONVEX\n\t\t\t\t\t\t)\n\t\t\t\t\t{\n\t\t\t\t\t\tFreeWinding(w);\n\t\t\t\t\t\tbrushsidetextured[brush->firstside + j] = true;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end else\n\t\t\t} //end else\n\t\t\tif (WindingArea(w) < 20)\n\t\t\t{\n\t\t\t\tbrushsidetextured[brush->firstside + j] = true;\n\t\t\t} //end if\n\t\t\t//find a face for texturing this brush\n\t\t\tfor (k = 0; k < numfaces; k++)\n\t\t\t{\n\t\t\t\tface = &dfaces[k];\n\t\t\t\t//if the face is in the same plane as the brush side\n\t\t\t\tif ((face->planenum&~1) != (brushside->planenum&~1)) continue;\n\t\t\t\t//if the face is partly or totally on the brush side\n\t\t\t\tif (Q2_FaceOnWinding(face, w))\n\t\t\t\t{\n\t\t\t\t\tbrushside->texinfo = face->texinfo;\n\t\t\t\t\tbrushsidetextured[brush->firstside + j] = true;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t} //end for\n\t\t\tFreeWinding(w);\n\t\t} //end for\n\t} //end for\n} //end of the function Q2_FixTextureReferences*/\n\n//#endif //ME\n\n\n/*\n===============\nCompressVis\n\n===============\n*/\nint Q2_CompressVis (byte *vis, byte *dest)\n{\n\tint\t\tj;\n\tint\t\trep;\n\tint\t\tvisrow;\n\tbyte\t*dest_p;\n\t\n\tdest_p = dest;\n//\tvisrow = (r_numvisleafs + 7)>>3;\n\tvisrow = (dvis->numclusters + 7)>>3;\n\t\n\tfor (j=0 ; j<visrow ; j++)\n\t{\n\t\t*dest_p++ = vis[j];\n\t\tif (vis[j])\n\t\t\tcontinue;\n\n\t\trep = 1;\n\t\tfor ( j++; j<visrow ; j++)\n\t\t\tif (vis[j] || rep == 255)\n\t\t\t\tbreak;\n\t\t\telse\n\t\t\t\trep++;\n\t\t*dest_p++ = rep;\n\t\tj--;\n\t}\n\t\n\treturn dest_p - dest;\n}\n\n\n/*\n===================\nDecompressVis\n===================\n*/\nvoid Q2_DecompressVis (byte *in, byte *decompressed)\n{\n\tint\t\tc;\n\tbyte\t*out;\n\tint\t\trow;\n\n//\trow = (r_numvisleafs+7)>>3;\t\n\trow = (dvis->numclusters+7)>>3;\t\n\tout = decompressed;\n\n\tdo\n\t{\n\t\tif (*in)\n\t\t{\n\t\t\t*out++ = *in++;\n\t\t\tcontinue;\n\t\t}\n\t\n\t\tc = in[1];\n\t\tif (!c)\n\t\t\tError (\"DecompressVis: 0 repeat\");\n\t\tin += 2;\n\t\twhile (c)\n\t\t{\n\t\t\t*out++ = 0;\n\t\t\tc--;\n\t\t}\n\t} while (out - decompressed < row);\n}\n\n//=============================================================================\n\n/*\n=============\nSwapBSPFile\n\nByte swaps all data in a bsp file.\n=============\n*/\nvoid Q2_SwapBSPFile (qboolean todisk)\n{\n\tint\t\t\t\ti, j;\n\tdmodel_t\t\t*d;\n\n\t\n// models\t\n\tfor (i=0 ; i<nummodels ; i++)\n\t{\n\t\td = &dmodels[i];\n\n\t\td->firstface = LittleLong (d->firstface);\n\t\td->numfaces = LittleLong (d->numfaces);\n\t\td->headnode = LittleLong (d->headnode);\n\t\t\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\td->mins[j] = LittleFloat(d->mins[j]);\n\t\t\td->maxs[j] = LittleFloat(d->maxs[j]);\n\t\t\td->origin[j] = LittleFloat(d->origin[j]);\n\t\t}\n\t}\n\n//\n// vertexes\n//\n\tfor (i=0 ; i<numvertexes ; i++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t\tdvertexes[i].point[j] = LittleFloat (dvertexes[i].point[j]);\n\t}\n\t\t\n//\n// planes\n//\t\n\tfor (i=0 ; i<numplanes ; i++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t\tdplanes[i].normal[j] = LittleFloat (dplanes[i].normal[j]);\n\t\tdplanes[i].dist = LittleFloat (dplanes[i].dist);\n\t\tdplanes[i].type = LittleLong (dplanes[i].type);\n\t}\n\t\n//\n// texinfos\n//\t\n\tfor (i=0 ; i<numtexinfo ; i++)\n\t{\n\t\tfor (j=0 ; j<8 ; j++)\n\t\t\ttexinfo[i].vecs[0][j] = LittleFloat (texinfo[i].vecs[0][j]);\n\t\ttexinfo[i].flags = LittleLong (texinfo[i].flags);\n\t\ttexinfo[i].value = LittleLong (texinfo[i].value);\n\t\ttexinfo[i].nexttexinfo = LittleLong (texinfo[i].nexttexinfo);\n\t}\n\t\n//\n// faces\n//\n\tfor (i=0 ; i<numfaces ; i++)\n\t{\n\t\tdfaces[i].texinfo = LittleShort (dfaces[i].texinfo);\n\t\tdfaces[i].planenum = LittleShort (dfaces[i].planenum);\n\t\tdfaces[i].side = LittleShort (dfaces[i].side);\n\t\tdfaces[i].lightofs = LittleLong (dfaces[i].lightofs);\n\t\tdfaces[i].firstedge = LittleLong (dfaces[i].firstedge);\n\t\tdfaces[i].numedges = LittleShort (dfaces[i].numedges);\n\t}\n\n//\n// nodes\n//\n\tfor (i=0 ; i<numnodes ; i++)\n\t{\n\t\tdnodes[i].planenum = LittleLong (dnodes[i].planenum);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\tdnodes[i].mins[j] = LittleShort (dnodes[i].mins[j]);\n\t\t\tdnodes[i].maxs[j] = LittleShort (dnodes[i].maxs[j]);\n\t\t}\n\t\tdnodes[i].children[0] = LittleLong (dnodes[i].children[0]);\n\t\tdnodes[i].children[1] = LittleLong (dnodes[i].children[1]);\n\t\tdnodes[i].firstface = LittleShort (dnodes[i].firstface);\n\t\tdnodes[i].numfaces = LittleShort (dnodes[i].numfaces);\n\t}\n\n//\n// leafs\n//\n\tfor (i=0 ; i<numleafs ; i++)\n\t{\n\t\tdleafs[i].contents = LittleLong (dleafs[i].contents);\n\t\tdleafs[i].cluster = LittleShort (dleafs[i].cluster);\n\t\tdleafs[i].area = LittleShort (dleafs[i].area);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\tdleafs[i].mins[j] = LittleShort (dleafs[i].mins[j]);\n\t\t\tdleafs[i].maxs[j] = LittleShort (dleafs[i].maxs[j]);\n\t\t}\n\n\t\tdleafs[i].firstleafface = LittleShort (dleafs[i].firstleafface);\n\t\tdleafs[i].numleaffaces = LittleShort (dleafs[i].numleaffaces);\n\t\tdleafs[i].firstleafbrush = LittleShort (dleafs[i].firstleafbrush);\n\t\tdleafs[i].numleafbrushes = LittleShort (dleafs[i].numleafbrushes);\n\t}\n\n//\n// leaffaces\n//\n\tfor (i=0 ; i<numleaffaces ; i++)\n\t\tdleaffaces[i] = LittleShort (dleaffaces[i]);\n\n//\n// leafbrushes\n//\n\tfor (i=0 ; i<numleafbrushes ; i++)\n\t\tdleafbrushes[i] = LittleShort (dleafbrushes[i]);\n\n//\n// surfedges\n//\n\tfor (i=0 ; i<numsurfedges ; i++)\n\t\tdsurfedges[i] = LittleLong (dsurfedges[i]);\n\n//\n// edges\n//\n\tfor (i=0 ; i<numedges ; i++)\n\t{\n\t\tdedges[i].v[0] = LittleShort (dedges[i].v[0]);\n\t\tdedges[i].v[1] = LittleShort (dedges[i].v[1]);\n\t}\n\n//\n// brushes\n//\n\tfor (i=0 ; i<numbrushes ; i++)\n\t{\n\t\tdbrushes[i].firstside = LittleLong (dbrushes[i].firstside);\n\t\tdbrushes[i].numsides = LittleLong (dbrushes[i].numsides);\n\t\tdbrushes[i].contents = LittleLong (dbrushes[i].contents);\n\t}\n\n//\n// areas\n//\n\tfor (i=0 ; i<numareas ; i++)\n\t{\n\t\tdareas[i].numareaportals = LittleLong (dareas[i].numareaportals);\n\t\tdareas[i].firstareaportal = LittleLong (dareas[i].firstareaportal);\n\t}\n\n//\n// areasportals\n//\n\tfor (i=0 ; i<numareaportals ; i++)\n\t{\n\t\tdareaportals[i].portalnum = LittleLong (dareaportals[i].portalnum);\n\t\tdareaportals[i].otherarea = LittleLong (dareaportals[i].otherarea);\n\t}\n\n//\n// brushsides\n//\n\tfor (i=0 ; i<numbrushsides ; i++)\n\t{\n\t\tdbrushsides[i].planenum = LittleShort (dbrushsides[i].planenum);\n\t\tdbrushsides[i].texinfo = LittleShort (dbrushsides[i].texinfo);\n\t}\n\n//\n// visibility\n//\n\tif (todisk)\n\t\tj = dvis->numclusters;\n\telse\n\t\tj = LittleLong(dvis->numclusters);\n\tdvis->numclusters = LittleLong (dvis->numclusters);\n\tfor (i=0 ; i<j ; i++)\n\t{\n\t\tdvis->bitofs[i][0] = LittleLong (dvis->bitofs[i][0]);\n\t\tdvis->bitofs[i][1] = LittleLong (dvis->bitofs[i][1]);\n\t}\n} //end of the function Q2_SwapBSPFile\n\n\ndheader_t\t*header;\n\nint Q2_CopyLump (int lump, void *dest, int size, int maxsize)\n{\n\tint\t\tlength, ofs;\n\n\tlength = header->lumps[lump].filelen;\n\tofs = header->lumps[lump].fileofs;\n\t\n\tif (length % size)\n\t\tError (\"LoadBSPFile: odd lump size\");\n\n   if ((length/size) > maxsize)\n      Error (\"Q2_LoadBSPFile: exceeded max size for lump %d size %d > maxsize %d\\n\", lump, (length/size), maxsize);\n\n\tmemcpy (dest, (byte *)header + ofs, length);\n\n\treturn length / size;\n} //end of the function Q2_CopyLump\n\n/*\n=============\nLoadBSPFile\n=============\n*/\nvoid Q2_LoadBSPFile(char *filename, int offset, int length)\n{\n\tint\t\t\ti;\n\t\n//\n// load the file header\n//\n\tLoadFile (filename, (void **)&header, offset, length);\n\n// swap the header\n\tfor (i=0 ; i< sizeof(dheader_t)/4 ; i++)\n\t\t((int *)header)[i] = LittleLong ( ((int *)header)[i]);\n\n\tif (header->ident != IDBSPHEADER)\n\t\tError (\"%s is not a IBSP file\", filename);\n\tif (header->version != BSPVERSION)\n\t\tError (\"%s is version %i, not %i\", filename, header->version, BSPVERSION);\n\n\tnummodels = Q2_CopyLump (LUMP_MODELS, dmodels, sizeof(dmodel_t), MAX_MAP_MODELS);\n\tnumvertexes = Q2_CopyLump (LUMP_VERTEXES, dvertexes, sizeof(dvertex_t), MAX_MAP_VERTS);\n\tnumplanes = Q2_CopyLump (LUMP_PLANES, dplanes, sizeof(dplane_t), MAX_MAP_PLANES);\n\tnumleafs = Q2_CopyLump (LUMP_LEAFS, dleafs, sizeof(dleaf_t), MAX_MAP_LEAFS);\n\tnumnodes = Q2_CopyLump (LUMP_NODES, dnodes, sizeof(dnode_t), MAX_MAP_NODES);\n\tnumtexinfo = Q2_CopyLump (LUMP_TEXINFO, texinfo, sizeof(texinfo_t), MAX_MAP_TEXINFO);\n\tnumfaces = Q2_CopyLump (LUMP_FACES, dfaces, sizeof(dface_t), MAX_MAP_FACES);\n\tnumleaffaces = Q2_CopyLump (LUMP_LEAFFACES, dleaffaces, sizeof(dleaffaces[0]), MAX_MAP_LEAFFACES);\n\tnumleafbrushes = Q2_CopyLump (LUMP_LEAFBRUSHES, dleafbrushes, sizeof(dleafbrushes[0]), MAX_MAP_LEAFBRUSHES);\n\tnumsurfedges = Q2_CopyLump (LUMP_SURFEDGES, dsurfedges, sizeof(dsurfedges[0]), MAX_MAP_SURFEDGES);\n\tnumedges = Q2_CopyLump (LUMP_EDGES, dedges, sizeof(dedge_t), MAX_MAP_EDGES);\n\tnumbrushes = Q2_CopyLump (LUMP_BRUSHES, dbrushes, sizeof(dbrush_t), MAX_MAP_BRUSHES);\n\tnumbrushsides = Q2_CopyLump (LUMP_BRUSHSIDES, dbrushsides, sizeof(dbrushside_t), MAX_MAP_BRUSHSIDES);\n\tnumareas = Q2_CopyLump (LUMP_AREAS, dareas, sizeof(darea_t), MAX_MAP_AREAS);\n\tnumareaportals = Q2_CopyLump (LUMP_AREAPORTALS, dareaportals, sizeof(dareaportal_t), MAX_MAP_AREAPORTALS);\n\n\tvisdatasize = Q2_CopyLump (LUMP_VISIBILITY, dvisdata, 1, MAX_MAP_VISIBILITY);\n\tlightdatasize = Q2_CopyLump (LUMP_LIGHTING, dlightdata, 1, MAX_MAP_LIGHTING);\n\tentdatasize = Q2_CopyLump (LUMP_ENTITIES, dentdata, 1, MAX_MAP_ENTSTRING);\n\n\tQ2_CopyLump (LUMP_POP, dpop, 1, MAX_MAP_DPOP);\n\n\tFreeMemory(header);\t\t// everything has been copied out\n\t\t\n//\n// swap everything\n//\t\n\tQ2_SwapBSPFile (false);\n\n\tQ2_FixTextureReferences();\n} //end of the function Q2_LoadBSPFile\n\n\n/*\n=============\nLoadBSPFileTexinfo\n\nOnly loads the texinfo lump, so qdata can scan for textures\n=============\n*/\nvoid\tQ2_LoadBSPFileTexinfo (char *filename)\n{\n\tint\t\t\ti;\n\tFILE\t\t*f;\n\tint\t\tlength, ofs;\n\n\theader = GetMemory(sizeof(dheader_t));\n\n\tf = fopen (filename, \"rb\");\n\tfread (header, sizeof(dheader_t), 1, f);\n\n// swap the header\n\tfor (i=0 ; i< sizeof(dheader_t)/4 ; i++)\n\t\t((int *)header)[i] = LittleLong ( ((int *)header)[i]);\n\n\tif (header->ident != IDBSPHEADER)\n\t\tError (\"%s is not a IBSP file\", filename);\n\tif (header->version != BSPVERSION)\n\t\tError (\"%s is version %i, not %i\", filename, header->version, BSPVERSION);\n\n\n\tlength = header->lumps[LUMP_TEXINFO].filelen;\n\tofs = header->lumps[LUMP_TEXINFO].fileofs;\n\n\tfseek (f, ofs, SEEK_SET);\n\tfread (texinfo, length, 1, f);\n\tfclose (f);\n\n\tnumtexinfo = length / sizeof(texinfo_t);\n\n\tFreeMemory(header);\t\t// everything has been copied out\n\t\t\n\tQ2_SwapBSPFile (false);\n} //end of the function Q2_LoadBSPFileTexinfo\n\n\n//============================================================================\n\nFILE\t\t*wadfile;\ndheader_t\toutheader;\n\nvoid Q2_AddLump (int lumpnum, void *data, int len)\n{\n\tlump_t *lump;\n\n\tlump = &header->lumps[lumpnum];\n\t\n\tlump->fileofs = LittleLong( ftell(wadfile) );\n\tlump->filelen = LittleLong(len);\n\tSafeWrite (wadfile, data, (len+3)&~3);\n} //end of the function Q2_AddLump\n\n/*\n=============\nWriteBSPFile\n\nSwaps the bsp file in place, so it should not be referenced again\n=============\n*/\nvoid\tQ2_WriteBSPFile (char *filename)\n{\t\t\n\theader = &outheader;\n\tmemset (header, 0, sizeof(dheader_t));\n\t\n\tQ2_SwapBSPFile (true);\n\n\theader->ident = LittleLong (IDBSPHEADER);\n\theader->version = LittleLong (BSPVERSION);\n\t\n\twadfile = SafeOpenWrite (filename);\n\tSafeWrite (wadfile, header, sizeof(dheader_t));\t// overwritten later\n\n\tQ2_AddLump (LUMP_PLANES, dplanes, numplanes*sizeof(dplane_t));\n\tQ2_AddLump (LUMP_LEAFS, dleafs, numleafs*sizeof(dleaf_t));\n\tQ2_AddLump (LUMP_VERTEXES, dvertexes, numvertexes*sizeof(dvertex_t));\n\tQ2_AddLump (LUMP_NODES, dnodes, numnodes*sizeof(dnode_t));\n\tQ2_AddLump (LUMP_TEXINFO, texinfo, numtexinfo*sizeof(texinfo_t));\n\tQ2_AddLump (LUMP_FACES, dfaces, numfaces*sizeof(dface_t));\n\tQ2_AddLump (LUMP_BRUSHES, dbrushes, numbrushes*sizeof(dbrush_t));\n\tQ2_AddLump (LUMP_BRUSHSIDES, dbrushsides, numbrushsides*sizeof(dbrushside_t));\n\tQ2_AddLump (LUMP_LEAFFACES, dleaffaces, numleaffaces*sizeof(dleaffaces[0]));\n\tQ2_AddLump (LUMP_LEAFBRUSHES, dleafbrushes, numleafbrushes*sizeof(dleafbrushes[0]));\n\tQ2_AddLump (LUMP_SURFEDGES, dsurfedges, numsurfedges*sizeof(dsurfedges[0]));\n\tQ2_AddLump (LUMP_EDGES, dedges, numedges*sizeof(dedge_t));\n\tQ2_AddLump (LUMP_MODELS, dmodels, nummodels*sizeof(dmodel_t));\n\tQ2_AddLump (LUMP_AREAS, dareas, numareas*sizeof(darea_t));\n\tQ2_AddLump (LUMP_AREAPORTALS, dareaportals, numareaportals*sizeof(dareaportal_t));\n\n\tQ2_AddLump (LUMP_LIGHTING, dlightdata, lightdatasize);\n\tQ2_AddLump (LUMP_VISIBILITY, dvisdata, visdatasize);\n\tQ2_AddLump (LUMP_ENTITIES, dentdata, entdatasize);\n\tQ2_AddLump (LUMP_POP, dpop, sizeof(dpop));\n\t\n\tfseek (wadfile, 0, SEEK_SET);\n\tSafeWrite (wadfile, header, sizeof(dheader_t));\n\tfclose (wadfile);\t\n} //end of the function Q2_WriteBSPFile\n\n//============================================================================\n\n/*\n=============\nPrintBSPFileSizes\n\nDumps info about current file\n=============\n*/\nvoid Q2_PrintBSPFileSizes (void)\n{\n\tif (!num_entities)\n\t\tQ2_ParseEntities();\n\n\tprintf (\"%6i models       %7i\\n\"\n\t\t,nummodels, (int)(nummodels*sizeof(dmodel_t)));\n\tprintf (\"%6i brushes      %7i\\n\"\n\t\t,numbrushes, (int)(numbrushes*sizeof(dbrush_t)));\n\tprintf (\"%6i brushsides   %7i\\n\"\n\t\t,numbrushsides, (int)(numbrushsides*sizeof(dbrushside_t)));\n\tprintf (\"%6i planes       %7i\\n\"\n\t\t,numplanes, (int)(numplanes*sizeof(dplane_t)));\n\tprintf (\"%6i texinfo      %7i\\n\"\n\t\t,numtexinfo, (int)(numtexinfo*sizeof(texinfo_t)));\n\tprintf (\"%6i entdata      %7i\\n\", num_entities, entdatasize);\n\n\tprintf (\"\\n\");\n\n\tprintf (\"%6i vertexes     %7i\\n\"\n\t\t,numvertexes, (int)(numvertexes*sizeof(dvertex_t)));\n\tprintf (\"%6i nodes        %7i\\n\"\n\t\t,numnodes, (int)(numnodes*sizeof(dnode_t)));\n\tprintf (\"%6i faces        %7i\\n\"\n\t\t,numfaces, (int)(numfaces*sizeof(dface_t)));\n\tprintf (\"%6i leafs        %7i\\n\"\n\t\t,numleafs, (int)(numleafs*sizeof(dleaf_t)));\n\tprintf (\"%6i leaffaces    %7i\\n\"\n\t\t,numleaffaces, (int)(numleaffaces*sizeof(dleaffaces[0])));\n\tprintf (\"%6i leafbrushes  %7i\\n\"\n\t\t,numleafbrushes, (int)(numleafbrushes*sizeof(dleafbrushes[0])));\n\tprintf (\"%6i surfedges    %7i\\n\"\n\t\t,numsurfedges, (int)(numsurfedges*sizeof(dsurfedges[0])));\n\tprintf (\"%6i edges        %7i\\n\"\n\t\t,numedges, (int)(numedges*sizeof(dedge_t)));\n//NEW\n\tprintf (\"%6i areas        %7i\\n\"\n\t\t,numareas, (int)(numareas*sizeof(darea_t)));\n\tprintf (\"%6i areaportals  %7i\\n\"\n\t\t,numareaportals, (int)(numareaportals*sizeof(dareaportal_t)));\n//ENDNEW\n\tprintf (\"      lightdata    %7i\\n\", lightdatasize);\n\tprintf (\"      visdata      %7i\\n\", visdatasize);\n} //end of the function Q2_PrintBSPFileSizes\n\n/*\n================\nParseEntities\n\nParses the dentdata string into entities\n================\n*/\nvoid Q2_ParseEntities (void)\n{\n\tscript_t *script;\n\n\tnum_entities = 0;\n\tscript = LoadScriptMemory(dentdata, entdatasize, \"*Quake2 bsp file\");\n\tSetScriptFlags(script, SCFL_NOSTRINGWHITESPACES |\n\t\t\t\t\t\t\t\t\tSCFL_NOSTRINGESCAPECHARS);\n\n\twhile(ParseEntity(script))\n\t{\n\t} //end while\n\n\tFreeScript(script);\n} //end of the function Q2_ParseEntities\n\n\n/*\n================\nUnparseEntities\n\nGenerates the dentdata string from all the entities\n================\n*/\nvoid Q2_UnparseEntities (void)\n{\n\tchar\t*buf, *end;\n\tepair_t\t*ep;\n\tchar\tline[2048];\n\tint\t\ti;\n\tchar\tkey[1024], value[1024];\n\n\tbuf = dentdata;\n\tend = buf;\n\t*end = 0;\n\t\n\tfor (i=0 ; i<num_entities ; i++)\n\t{\n\t\tep = entities[i].epairs;\n\t\tif (!ep)\n\t\t\tcontinue;\t// ent got removed\n\t\t\n\t\tstrcat (end,\"{\\n\");\n\t\tend += 2;\n\t\t\t\t\n\t\tfor (ep = entities[i].epairs ; ep ; ep=ep->next)\n\t\t{\n\t\t\tstrcpy (key, ep->key);\n\t\t\tStripTrailing (key);\n\t\t\tstrcpy (value, ep->value);\n\t\t\tStripTrailing (value);\n\t\t\t\t\n\t\t\tsprintf (line, \"\\\"%s\\\" \\\"%s\\\"\\n\", key, value);\n\t\t\tstrcat (end, line);\n\t\t\tend += strlen(line);\n\t\t}\n\t\tstrcat (end,\"}\\n\");\n\t\tend += 2;\n\n\t\tif (end > buf + MAX_MAP_ENTSTRING)\n\t\t\tError (\"Entity text too long\");\n\t}\n\tentdatasize = end - buf + 1;\n} //end of the function Q2_UnparseEntities\n\n"
  },
  {
    "path": "code/bspc/l_bsp_q2.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#ifndef ME\n#define ME\n#endif //ME\n\nextern\tint\t\t\t\tnummodels;\nextern\tdmodel_t\t\t\t*dmodels;//[MAX_MAP_MODELS];\n\nextern\tint\t\t\t\tvisdatasize;\nextern\tbyte\t\t\t\t*dvisdata;//[MAX_MAP_VISIBILITY];\nextern\tdvis_t\t\t\t*dvis;\n\nextern\tint\t\t\t\tlightdatasize;\nextern\tbyte\t\t\t\t*dlightdata;//[MAX_MAP_LIGHTING];\n\nextern\tint\t\t\t\tentdatasize;\nextern\tchar\t\t\t\t*dentdata;//[MAX_MAP_ENTSTRING];\n\nextern\tint\t\t\t\tnumleafs;\nextern\tdleaf_t\t\t\t*dleafs;//[MAX_MAP_LEAFS];\n\nextern\tint\t\t\t\tnumplanes;\nextern\tdplane_t\t\t\t*dplanes;//[MAX_MAP_PLANES];\n\nextern\tint\t\t\t\tnumvertexes;\nextern\tdvertex_t\t\t*dvertexes;//[MAX_MAP_VERTS];\n\nextern\tint\t\t\t\tnumnodes;\nextern\tdnode_t\t\t\t*dnodes;//[MAX_MAP_NODES];\n\nextern\tint\t\t\t\tnumtexinfo;\nextern\ttexinfo_t\t\ttexinfo[MAX_MAP_TEXINFO];\n\nextern\tint\t\t\t\tnumfaces;\nextern\tdface_t\t\t\t*dfaces;//[MAX_MAP_FACES];\n\nextern\tint\t\t\t\tnumedges;\nextern\tdedge_t\t\t\t*dedges;//[MAX_MAP_EDGES];\n\nextern\tint\t\t\t\tnumleaffaces;\nextern\tunsigned short\t*dleaffaces;//[MAX_MAP_LEAFFACES];\n\nextern\tint\t\t\t\tnumleafbrushes;\nextern\tunsigned short\t*dleafbrushes;//[MAX_MAP_LEAFBRUSHES];\n\nextern\tint\t\t\t\tnumsurfedges;\nextern\tint\t\t\t\t*dsurfedges;//[MAX_MAP_SURFEDGES];\n\nextern\tint\t\t\t\tnumareas;\nextern\tdarea_t\t\t\t*dareas;//[MAX_MAP_AREAS];\n\nextern\tint\t\t\t\tnumareaportals;\nextern\tdareaportal_t\t*dareaportals;//[MAX_MAP_AREAPORTALS];\n\nextern\tint\t\t\t\tnumbrushes;\nextern\tdbrush_t\t\t\t*dbrushes;//[MAX_MAP_BRUSHES];\n\nextern\tint\t\t\t\tnumbrushsides;\nextern\tdbrushside_t\t*dbrushsides;//[MAX_MAP_BRUSHSIDES];\n\nextern\tbyte\t\tdpop[256];\n\nextern\tchar brushsidetextured[MAX_MAP_BRUSHSIDES];\n\nvoid Q2_AllocMaxBSP(void);\nvoid Q2_FreeMaxBSP(void);\n\nvoid Q2_DecompressVis(byte *in, byte *decompressed);\nint Q2_CompressVis(byte *vis, byte *dest);\n\nvoid Q2_LoadBSPFile(char *filename, int offset, int length);\nvoid Q2_LoadBSPFileTexinfo(char *filename);\t// just for qdata\nvoid Q2_WriteBSPFile(char *filename);\nvoid Q2_PrintBSPFileSizes(void);\nvoid Q2_ParseEntities(void);\nvoid Q2_UnparseEntities(void);\n\n"
  },
  {
    "path": "code/bspc/l_bsp_q3.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"l_cmd.h\"\n#include \"l_math.h\"\n#include \"l_mem.h\"\n#include \"l_log.h\"\n#include \"l_poly.h\"\n#include \"../botlib/l_script.h\"\n#include \"l_qfiles.h\"\n#include \"l_bsp_q3.h\"\n#include \"l_bsp_ent.h\"\n\nvoid Q3_ParseEntities (void);\nvoid Q3_PrintBSPFileSizes(void);\n\nvoid GetLeafNums (void);\n\n//=============================================================================\n\n#define WCONVEX_EPSILON\t\t0.5\n\n\nint\t\t\t\tq3_nummodels;\nq3_dmodel_t\t\t*q3_dmodels;//[MAX_MAP_MODELS];\n\nint\t\t\t\tq3_numShaders;\nq3_dshader_t\t*q3_dshaders;//[Q3_MAX_MAP_SHADERS];\n\nint\t\t\t\tq3_entdatasize;\nchar\t\t\t*q3_dentdata;//[Q3_MAX_MAP_ENTSTRING];\n\nint\t\t\t\tq3_numleafs;\nq3_dleaf_t\t\t*q3_dleafs;//[Q3_MAX_MAP_LEAFS];\n\nint\t\t\t\tq3_numplanes;\nq3_dplane_t\t\t*q3_dplanes;//[Q3_MAX_MAP_PLANES];\n\nint\t\t\t\tq3_numnodes;\nq3_dnode_t\t\t*q3_dnodes;//[Q3_MAX_MAP_NODES];\n\nint\t\t\t\tq3_numleafsurfaces;\nint\t\t\t\t*q3_dleafsurfaces;//[Q3_MAX_MAP_LEAFFACES];\n\nint\t\t\t\tq3_numleafbrushes;\nint\t\t\t\t*q3_dleafbrushes;//[Q3_MAX_MAP_LEAFBRUSHES];\n\nint\t\t\t\tq3_numbrushes;\nq3_dbrush_t\t\t*q3_dbrushes;//[Q3_MAX_MAP_BRUSHES];\n\nint\t\t\t\tq3_numbrushsides;\nq3_dbrushside_t\t*q3_dbrushsides;//[Q3_MAX_MAP_BRUSHSIDES];\n\nint\t\t\t\tq3_numLightBytes;\nbyte\t\t\t*q3_lightBytes;//[Q3_MAX_MAP_LIGHTING];\n\nint\t\t\t\tq3_numGridPoints;\nbyte\t\t\t*q3_gridData;//[Q3_MAX_MAP_LIGHTGRID];\n\nint\t\t\t\tq3_numVisBytes;\nbyte\t\t\t*q3_visBytes;//[Q3_MAX_MAP_VISIBILITY];\n\nint\t\t\t\tq3_numDrawVerts;\nq3_drawVert_t\t*q3_drawVerts;//[Q3_MAX_MAP_DRAW_VERTS];\n\nint\t\t\t\tq3_numDrawIndexes;\nint\t\t\t\t*q3_drawIndexes;//[Q3_MAX_MAP_DRAW_INDEXES];\n\nint\t\t\t\tq3_numDrawSurfaces;\nq3_dsurface_t\t*q3_drawSurfaces;//[Q3_MAX_MAP_DRAW_SURFS];\n\nint\t\t\t\tq3_numFogs;\nq3_dfog_t\t\t*q3_dfogs;//[Q3_MAX_MAP_FOGS];\n\nchar\t\t\tq3_dbrushsidetextured[Q3_MAX_MAP_BRUSHSIDES];\n\nextern qboolean forcesidesvisible;\n\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Q3_FreeMaxBSP(void)\n{\n\tif (q3_dmodels) FreeMemory(q3_dmodels);\n\tq3_dmodels = NULL;\n\tq3_nummodels = 0;\n\tif (q3_dshaders) FreeMemory(q3_dshaders);\n\tq3_dshaders = NULL;\n\tq3_numShaders = 0;\n\tif (q3_dentdata) FreeMemory(q3_dentdata);\n\tq3_dentdata = NULL;\n\tq3_entdatasize = 0;\n\tif (q3_dleafs) FreeMemory(q3_dleafs);\n\tq3_dleafs = NULL;\n\tq3_numleafs = 0;\n\tif (q3_dplanes) FreeMemory(q3_dplanes);\n\tq3_dplanes = NULL;\n\tq3_numplanes = 0;\n\tif (q3_dnodes) FreeMemory(q3_dnodes);\n\tq3_dnodes = NULL;\n\tq3_numnodes = 0;\n\tif (q3_dleafsurfaces) FreeMemory(q3_dleafsurfaces);\n\tq3_dleafsurfaces = NULL;\n\tq3_numleafsurfaces = 0;\n\tif (q3_dleafbrushes) FreeMemory(q3_dleafbrushes);\n\tq3_dleafbrushes = NULL;\n\tq3_numleafbrushes = 0;\n\tif (q3_dbrushes) FreeMemory(q3_dbrushes);\n\tq3_dbrushes = NULL;\n\tq3_numbrushes = 0;\n\tif (q3_dbrushsides) FreeMemory(q3_dbrushsides);\n\tq3_dbrushsides = NULL;\n\tq3_numbrushsides = 0;\n\tif (q3_lightBytes) FreeMemory(q3_lightBytes);\n\tq3_lightBytes = NULL;\n\tq3_numLightBytes = 0;\n\tif (q3_gridData) FreeMemory(q3_gridData);\n\tq3_gridData = NULL;\n\tq3_numGridPoints = 0;\n\tif (q3_visBytes) FreeMemory(q3_visBytes);\n\tq3_visBytes = NULL;\n\tq3_numVisBytes = 0;\n\tif (q3_drawVerts) FreeMemory(q3_drawVerts);\n\tq3_drawVerts = NULL;\n\tq3_numDrawVerts = 0;\n\tif (q3_drawIndexes) FreeMemory(q3_drawIndexes);\n\tq3_drawIndexes = NULL;\n\tq3_numDrawIndexes = 0;\n\tif (q3_drawSurfaces) FreeMemory(q3_drawSurfaces);\n\tq3_drawSurfaces = NULL;\n\tq3_numDrawSurfaces = 0;\n\tif (q3_dfogs) FreeMemory(q3_dfogs);\n\tq3_dfogs = NULL;\n\tq3_numFogs = 0;\n} //end of the function Q3_FreeMaxBSP\n\n\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Q3_PlaneFromPoints(vec3_t p0, vec3_t p1, vec3_t p2, vec3_t normal, float *dist)\n{\n\tvec3_t t1, t2;\n\n\tVectorSubtract(p0, p1, t1);\n\tVectorSubtract(p2, p1, t2);\n\tCrossProduct(t1, t2, normal);\n\tVectorNormalize(normal);\n\n\t*dist = DotProduct(p0, normal);\n} //end of the function PlaneFromPoints\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Q3_SurfacePlane(q3_dsurface_t *surface, vec3_t normal, float *dist)\n{\n\tint i;\n\tfloat *p0, *p1, *p2;\n\tvec3_t t1, t2;\n\n\tp0 = q3_drawVerts[surface->firstVert].xyz;\n\tfor (i = 1; i < surface->numVerts-1; i++)\n\t{\n\t\tp1 = q3_drawVerts[surface->firstVert + ((i) % surface->numVerts)].xyz;\n\t\tp2 = q3_drawVerts[surface->firstVert + ((i+1) % surface->numVerts)].xyz;\n\t\tVectorSubtract(p0, p1, t1);\n\t\tVectorSubtract(p2, p1, t2);\n\t\tCrossProduct(t1, t2, normal);\n\t\tVectorNormalize(normal);\n\t\tif (VectorLength(normal)) break;\n\t} //end for*/\n/*\n\tfloat dot;\n\tfor (i = 0; i < surface->numVerts; i++)\n\t{\n\t\tp0 = q3_drawVerts[surface->firstVert + ((i) % surface->numVerts)].xyz;\n\t\tp1 = q3_drawVerts[surface->firstVert + ((i+1) % surface->numVerts)].xyz;\n\t\tp2 = q3_drawVerts[surface->firstVert + ((i+2) % surface->numVerts)].xyz;\n\t\tVectorSubtract(p0, p1, t1);\n\t\tVectorSubtract(p2, p1, t2);\n\t\tVectorNormalize(t1);\n\t\tVectorNormalize(t2);\n\t\tdot = DotProduct(t1, t2);\n\t\tif (dot > -0.9 && dot < 0.9 &&\n\t\t\tVectorLength(t1) > 0.1 && VectorLength(t2) > 0.1) break;\n\t} //end for\n\tCrossProduct(t1, t2, normal);\n\tVectorNormalize(normal);\n*/\n\tif (VectorLength(normal) < 0.9)\n\t{\n\t\tprintf(\"surface %d bogus normal vector %f %f %f\\n\", surface - q3_drawSurfaces, normal[0], normal[1], normal[2]);\n\t\tprintf(\"t1 = %f %f %f, t2 = %f %f %f\\n\", t1[0], t1[1], t1[2], t2[0], t2[1], t2[2]);\n\t\tfor (i = 0; i < surface->numVerts; i++)\n\t\t{\n\t\t\tp1 = q3_drawVerts[surface->firstVert + ((i) % surface->numVerts)].xyz;\n\t\t\tLog_Print(\"p%d = %f %f %f\\n\", i, p1[0], p1[1], p1[2]);\n\t\t} //end for\n\t} //end if\n\t*dist = DotProduct(p0, normal);\n} //end of the function Q3_SurfacePlane\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nq3_dplane_t *q3_surfaceplanes;\n\nvoid Q3_CreatePlanarSurfacePlanes(void)\n{\n\tint i;\n\tq3_dsurface_t *surface;\n\n\tLog_Print(\"creating planar surface planes...\\n\");\n\tq3_surfaceplanes = (q3_dplane_t *) GetClearedMemory(q3_numDrawSurfaces * sizeof(q3_dplane_t));\n\n\tfor (i = 0; i < q3_numDrawSurfaces; i++)\n\t{\n\t\tsurface = &q3_drawSurfaces[i];\n\t\tif (surface->surfaceType != MST_PLANAR) continue;\n\t\tQ3_SurfacePlane(surface, q3_surfaceplanes[i].normal, &q3_surfaceplanes[i].dist);\n\t\t//Log_Print(\"normal = %f %f %f, dist = %f\\n\", q3_surfaceplanes[i].normal[0],\n\t\t//\t\t\t\t\t\t\t\t\t\t\tq3_surfaceplanes[i].normal[1],\n\t\t//\t\t\t\t\t\t\t\t\t\t\tq3_surfaceplanes[i].normal[2], q3_surfaceplanes[i].dist);\n\t} //end for\n} //end of the function Q3_CreatePlanarSurfacePlanes\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n/*\nvoid Q3_SurfacePlane(q3_dsurface_t *surface, vec3_t normal, float *dist)\n{\n\t//take the plane information from the lightmap vector\n\t//VectorCopy(surface->lightmapVecs[2], normal);\n\t//calculate plane dist with first surface vertex\n\t//*dist = DotProduct(q3_drawVerts[surface->firstVert].xyz, normal);\n\tQ3_PlaneFromPoints(q3_drawVerts[surface->firstVert].xyz,\n\t\t\t\t\t\tq3_drawVerts[surface->firstVert+1].xyz,\n\t\t\t\t\t\tq3_drawVerts[surface->firstVert+2].xyz, normal, dist);\n} //end of the function Q3_SurfacePlane*/\n//===========================================================================\n// returns the amount the face and the winding overlap\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat Q3_FaceOnWinding(q3_dsurface_t *surface, winding_t *winding)\n{\n\tint i;\n\tfloat dist, area;\n\tq3_dplane_t plane;\n\tvec_t *v1, *v2;\n\tvec3_t normal, edgevec;\n\twinding_t *w;\n\n\t//copy the winding before chopping\n\tw = CopyWinding(winding);\n\t//retrieve the surface plane\n\tQ3_SurfacePlane(surface, plane.normal, &plane.dist);\n\t//chop the winding with the surface edge planes\n\tfor (i = 0; i < surface->numVerts && w; i++)\n\t{\n\t\tv1 = q3_drawVerts[surface->firstVert + ((i) % surface->numVerts)].xyz;\n\t\tv2 = q3_drawVerts[surface->firstVert + ((i+1) % surface->numVerts)].xyz;\n\t\t//create a plane through the edge from v1 to v2, orthogonal to the\n\t\t//surface plane and with the normal vector pointing inward\n\t\tVectorSubtract(v2, v1, edgevec);\n\t\tCrossProduct(edgevec, plane.normal, normal);\n\t\tVectorNormalize(normal);\n\t\tdist = DotProduct(normal, v1);\n\t\t//\n\t\tChopWindingInPlace(&w, normal, dist, -0.1); //CLIP_EPSILON\n\t} //end for\n\tif (w)\n\t{\n\t\tarea = WindingArea(w);\n\t\tFreeWinding(w);\n\t\treturn area;\n\t} //end if\n\treturn 0;\n} //end of the function Q3_FaceOnWinding\n//===========================================================================\n// creates a winding for the given brush side on the given brush\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nwinding_t *Q3_BrushSideWinding(q3_dbrush_t *brush, q3_dbrushside_t *baseside)\n{\n\tint i;\n\tq3_dplane_t *baseplane, *plane;\n\twinding_t *w;\n\tq3_dbrushside_t *side;\n\t\n\t//create a winding for the brush side with the given planenumber\n\tbaseplane = &q3_dplanes[baseside->planeNum];\n\tw = BaseWindingForPlane(baseplane->normal, baseplane->dist);\n\tfor (i = 0; i < brush->numSides && w; i++)\n\t{\n\t\tside = &q3_dbrushsides[brush->firstSide + i];\n\t\t//don't chop with the base plane\n\t\tif (side->planeNum == baseside->planeNum) continue;\n\t\t//also don't use planes that are almost equal\n\t\tplane = &q3_dplanes[side->planeNum];\n\t\tif (DotProduct(baseplane->normal, plane->normal) > 0.999\n\t\t\t\t&& fabs(baseplane->dist - plane->dist) < 0.01) continue;\n\t\t//\n\t\tplane = &q3_dplanes[side->planeNum^1];\n\t\tChopWindingInPlace(&w, plane->normal, plane->dist, -0.1); //CLIP_EPSILON);\n\t} //end for\n\treturn w;\n} //end of the function Q3_BrushSideWinding\n//===========================================================================\n// fix screwed brush texture references\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean WindingIsTiny(winding_t *w);\n\nvoid Q3_FindVisibleBrushSides(void)\n{\n\tint i, j, k, we, numtextured, numsides;\n\tfloat dot;\n\tq3_dplane_t *plane;\n\tq3_dbrushside_t *brushside;\n\tq3_dbrush_t *brush;\n\tq3_dsurface_t *surface;\n\twinding_t *w;\n\n\tmemset(q3_dbrushsidetextured, false, Q3_MAX_MAP_BRUSHSIDES);\n\t//\n\tnumsides = 0;\n\t//create planes for the planar surfaces\n\tQ3_CreatePlanarSurfacePlanes();\n\tLog_Print(\"searching visible brush sides...\\n\");\n\tLog_Print(\"%6d brush sides\", numsides);\n\t//go over all the brushes\n\tfor (i = 0; i < q3_numbrushes; i++)\n\t{\n\t\tbrush = &q3_dbrushes[i];\n\t\t//go over all the sides of the brush\n\t\tfor (j = 0; j < brush->numSides; j++)\n\t\t{\n\t\t\tqprintf(\"\\r%6d\", numsides++);\n\t\t\tbrushside = &q3_dbrushsides[brush->firstSide + j];\n\t\t\t//\n\t\t\tw = Q3_BrushSideWinding(brush, brushside);\n\t\t\tif (!w)\n\t\t\t{\n\t\t\t\tq3_dbrushsidetextured[brush->firstSide + j] = true;\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\t//RemoveEqualPoints(w, 0.2);\n\t\t\t\tif (WindingIsTiny(w))\n\t\t\t\t{\n\t\t\t\t\tFreeWinding(w);\n\t\t\t\t\tq3_dbrushsidetextured[brush->firstSide + j] = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t} //end if\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\twe = WindingError(w);\n\t\t\t\t\tif (we == WE_NOTENOUGHPOINTS\n\t\t\t\t\t\t|| we == WE_SMALLAREA\n\t\t\t\t\t\t|| we == WE_POINTBOGUSRANGE\n//\t\t\t\t\t\t|| we == WE_NONCONVEX\n\t\t\t\t\t\t)\n\t\t\t\t\t{\n\t\t\t\t\t\tFreeWinding(w);\n\t\t\t\t\t\tq3_dbrushsidetextured[brush->firstSide + j] = true;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end else\n\t\t\t} //end else\n\t\t\tif (WindingArea(w) < 20)\n\t\t\t{\n\t\t\t\tq3_dbrushsidetextured[brush->firstSide + j] = true;\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\t//find a face for texturing this brush\n\t\t\tfor (k = 0; k < q3_numDrawSurfaces; k++)\n\t\t\t{\n\t\t\t\tsurface = &q3_drawSurfaces[k];\n\t\t\t\tif (surface->surfaceType != MST_PLANAR) continue;\n\t\t\t\t//\n\t\t\t\t//Q3_SurfacePlane(surface, plane.normal, &plane.dist);\n\t\t\t\tplane = &q3_surfaceplanes[k];\n\t\t\t\t//the surface plane and the brush side plane should be pretty much the same\n\t\t\t\tif (fabs(fabs(plane->dist) - fabs(q3_dplanes[brushside->planeNum].dist)) > 5) continue;\n\t\t\t\tdot = DotProduct(plane->normal, q3_dplanes[brushside->planeNum].normal);\n\t\t\t\tif (dot > -0.9 && dot < 0.9) continue;\n\t\t\t\t//if the face is partly or totally on the brush side\n\t\t\t\tif (Q3_FaceOnWinding(surface, w))\n\t\t\t\t{\n\t\t\t\t\tq3_dbrushsidetextured[brush->firstSide + j] = true;\n\t\t\t\t\t//Log_Write(\"Q3_FaceOnWinding\");\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t} //end for\n\t\t\tFreeWinding(w);\n\t\t} //end for\n\t} //end for\n\tqprintf(\"\\r%6d brush sides\\n\", numsides);\n\tnumtextured = 0;\n\tfor (i = 0; i < q3_numbrushsides; i++)\n\t{\n\t\tif (forcesidesvisible) q3_dbrushsidetextured[i] = true;\n\t\tif (q3_dbrushsidetextured[i]) numtextured++;\n\t} //end for\n\tLog_Print(\"%d brush sides textured out of %d\\n\", numtextured, q3_numbrushsides);\n} //end of the function Q3_FindVisibleBrushSides\n\n/*\n=============\nQ3_SwapBlock\n\nIf all values are 32 bits, this can be used to swap everything\n=============\n*/\nvoid Q3_SwapBlock( int *block, int sizeOfBlock ) {\n\tint\t\ti;\n\n\tsizeOfBlock >>= 2;\n\tfor ( i = 0 ; i < sizeOfBlock ; i++ ) {\n\t\tblock[i] = LittleLong( block[i] );\n\t}\n} //end of the function Q3_SwapBlock\n\n/*\n=============\nQ3_SwapBSPFile\n\nByte swaps all data in a bsp file.\n=============\n*/\nvoid Q3_SwapBSPFile( void ) {\n\tint\t\t\t\ti;\n\t\n\t// models\t\n\tQ3_SwapBlock( (int *)q3_dmodels, q3_nummodels * sizeof( q3_dmodels[0] ) );\n\n\t// shaders (don't swap the name)\n\tfor ( i = 0 ; i < q3_numShaders ; i++ ) {\n\t\tq3_dshaders[i].contentFlags = LittleLong( q3_dshaders[i].contentFlags );\n\t\tq3_dshaders[i].surfaceFlags = LittleLong( q3_dshaders[i].surfaceFlags );\n\t}\n\n\t// planes\n\tQ3_SwapBlock( (int *)q3_dplanes, q3_numplanes * sizeof( q3_dplanes[0] ) );\n\t\n\t// nodes\n\tQ3_SwapBlock( (int *)q3_dnodes, q3_numnodes * sizeof( q3_dnodes[0] ) );\n\n\t// leafs\n\tQ3_SwapBlock( (int *)q3_dleafs, q3_numleafs * sizeof( q3_dleafs[0] ) );\n\n\t// leaffaces\n\tQ3_SwapBlock( (int *)q3_dleafsurfaces, q3_numleafsurfaces * sizeof( q3_dleafsurfaces[0] ) );\n\n\t// leafbrushes\n\tQ3_SwapBlock( (int *)q3_dleafbrushes, q3_numleafbrushes * sizeof( q3_dleafbrushes[0] ) );\n\n\t// brushes\n\tQ3_SwapBlock( (int *)q3_dbrushes, q3_numbrushes * sizeof( q3_dbrushes[0] ) );\n\n\t// brushsides\n\tQ3_SwapBlock( (int *)q3_dbrushsides, q3_numbrushsides * sizeof( q3_dbrushsides[0] ) );\n\n\t// vis\n\t((int *)&q3_visBytes)[0] = LittleLong( ((int *)&q3_visBytes)[0] );\n\t((int *)&q3_visBytes)[1] = LittleLong( ((int *)&q3_visBytes)[1] );\n\n\t// drawverts (don't swap colors )\n\tfor ( i = 0 ; i < q3_numDrawVerts ; i++ ) {\n\t\tq3_drawVerts[i].lightmap[0] = LittleFloat( q3_drawVerts[i].lightmap[0] );\n\t\tq3_drawVerts[i].lightmap[1] = LittleFloat( q3_drawVerts[i].lightmap[1] );\n\t\tq3_drawVerts[i].st[0] = LittleFloat( q3_drawVerts[i].st[0] );\n\t\tq3_drawVerts[i].st[1] = LittleFloat( q3_drawVerts[i].st[1] );\n\t\tq3_drawVerts[i].xyz[0] = LittleFloat( q3_drawVerts[i].xyz[0] );\n\t\tq3_drawVerts[i].xyz[1] = LittleFloat( q3_drawVerts[i].xyz[1] );\n\t\tq3_drawVerts[i].xyz[2] = LittleFloat( q3_drawVerts[i].xyz[2] );\n\t\tq3_drawVerts[i].normal[0] = LittleFloat( q3_drawVerts[i].normal[0] );\n\t\tq3_drawVerts[i].normal[1] = LittleFloat( q3_drawVerts[i].normal[1] );\n\t\tq3_drawVerts[i].normal[2] = LittleFloat( q3_drawVerts[i].normal[2] );\n\t}\n\n\t// drawindexes\n\tQ3_SwapBlock( (int *)q3_drawIndexes, q3_numDrawIndexes * sizeof( q3_drawIndexes[0] ) );\n\n\t// drawsurfs\n\tQ3_SwapBlock( (int *)q3_drawSurfaces, q3_numDrawSurfaces * sizeof( q3_drawSurfaces[0] ) );\n\n\t// fogs\n\tfor ( i = 0 ; i < q3_numFogs ; i++ ) {\n\t\tq3_dfogs[i].brushNum = LittleLong( q3_dfogs[i].brushNum );\n\t}\n}\n\n\n\n/*\n=============\nQ3_CopyLump\n=============\n*/\nint Q3_CopyLump( q3_dheader_t\t*header, int lump, void **dest, int size ) {\n\tint\t\tlength, ofs;\n\n\tlength = header->lumps[lump].filelen;\n\tofs = header->lumps[lump].fileofs;\n\t\n\tif ( length % size ) {\n\t\tError (\"Q3_LoadBSPFile: odd lump size\");\n\t}\n\n\t*dest = GetMemory(length);\n\n\tmemcpy( *dest, (byte *)header + ofs, length );\n\n\treturn length / size;\n}\n\n/*\n=============\nCountTriangles\n=============\n*/\nvoid CountTriangles( void ) {\n\tint i, numTris, numPatchTris;\n\tq3_dsurface_t *surface;\n\n\tnumTris = numPatchTris = 0;\n\tfor ( i = 0; i < q3_numDrawSurfaces; i++ ) {\n\t\tsurface = &q3_drawSurfaces[i];\n\n\t\tnumTris += surface->numIndexes / 3;\n\n\t\tif ( surface->patchWidth ) {\n\t\t\tnumPatchTris += surface->patchWidth * surface->patchHeight * 2;\n\t\t}\n\t}\n\n\tLog_Print( \"%6d triangles\\n\", numTris );\n\tLog_Print( \"%6d patch tris\\n\", numPatchTris );\n}\n\n/*\n=============\nQ3_LoadBSPFile\n=============\n*/\nvoid\tQ3_LoadBSPFile(struct quakefile_s *qf)\n{\n\tq3_dheader_t\t*header;\n\n\t// load the file header\n\t//LoadFile(filename, (void **)&header, offset, length);\n\t//\n\tLoadQuakeFile(qf, (void **)&header);\n\n\t// swap the header\n\tQ3_SwapBlock( (int *)header, sizeof(*header) );\n\n\tif ( header->ident != Q3_BSP_IDENT ) {\n\t\tError( \"%s is not a IBSP file\", qf->filename );\n\t}\n\tif ( header->version != Q3_BSP_VERSION ) {\n\t\tError( \"%s is version %i, not %i\", qf->filename, header->version, Q3_BSP_VERSION );\n\t}\n\n\tq3_numShaders = Q3_CopyLump( header, Q3_LUMP_SHADERS, (void *) &q3_dshaders, sizeof(q3_dshader_t) );\n\tq3_nummodels = Q3_CopyLump( header, Q3_LUMP_MODELS, (void *) &q3_dmodels, sizeof(q3_dmodel_t) );\n\tq3_numplanes = Q3_CopyLump( header, Q3_LUMP_PLANES, (void *) &q3_dplanes, sizeof(q3_dplane_t) );\n\tq3_numleafs = Q3_CopyLump( header, Q3_LUMP_LEAFS, (void *) &q3_dleafs, sizeof(q3_dleaf_t) );\n\tq3_numnodes = Q3_CopyLump( header, Q3_LUMP_NODES, (void *) &q3_dnodes, sizeof(q3_dnode_t) );\n\tq3_numleafsurfaces = Q3_CopyLump( header, Q3_LUMP_LEAFSURFACES, (void *) &q3_dleafsurfaces, sizeof(q3_dleafsurfaces[0]) );\n\tq3_numleafbrushes = Q3_CopyLump( header, Q3_LUMP_LEAFBRUSHES, (void *) &q3_dleafbrushes, sizeof(q3_dleafbrushes[0]) );\n\tq3_numbrushes = Q3_CopyLump( header, Q3_LUMP_BRUSHES, (void *) &q3_dbrushes, sizeof(q3_dbrush_t) );\n\tq3_numbrushsides = Q3_CopyLump( header, Q3_LUMP_BRUSHSIDES, (void *) &q3_dbrushsides, sizeof(q3_dbrushside_t) );\n\tq3_numDrawVerts = Q3_CopyLump( header, Q3_LUMP_DRAWVERTS, (void *) &q3_drawVerts, sizeof(q3_drawVert_t) );\n\tq3_numDrawSurfaces = Q3_CopyLump( header, Q3_LUMP_SURFACES, (void *) &q3_drawSurfaces, sizeof(q3_dsurface_t) );\n\tq3_numFogs = Q3_CopyLump( header, Q3_LUMP_FOGS, (void *) &q3_dfogs, sizeof(q3_dfog_t) );\n\tq3_numDrawIndexes = Q3_CopyLump( header, Q3_LUMP_DRAWINDEXES, (void *) &q3_drawIndexes, sizeof(q3_drawIndexes[0]) );\n\n\tq3_numVisBytes = Q3_CopyLump( header, Q3_LUMP_VISIBILITY, (void *) &q3_visBytes, 1 );\n\tq3_numLightBytes = Q3_CopyLump( header, Q3_LUMP_LIGHTMAPS, (void *) &q3_lightBytes, 1 );\n\tq3_entdatasize = Q3_CopyLump( header, Q3_LUMP_ENTITIES, (void *) &q3_dentdata, 1);\n\n\tq3_numGridPoints = Q3_CopyLump( header, Q3_LUMP_LIGHTGRID, (void *) &q3_gridData, 8 );\n\n\tCountTriangles();\n\n\tFreeMemory( header );\t\t// everything has been copied out\n\t\t\n\t// swap everything\n\tQ3_SwapBSPFile();\n\n\tQ3_FindVisibleBrushSides();\n\n\t//Q3_PrintBSPFileSizes();\n}\n\n\n//============================================================================\n\n/*\n=============\nQ3_AddLump\n=============\n*/\nvoid Q3_AddLump( FILE *bspfile, q3_dheader_t *header, int lumpnum, void *data, int len ) {\n\tq3_lump_t *lump;\n\n\tlump = &header->lumps[lumpnum];\n\t\n\tlump->fileofs = LittleLong( ftell(bspfile) );\n\tlump->filelen = LittleLong( len );\n\tSafeWrite( bspfile, data, (len+3)&~3 );\n}\n\n/*\n=============\nQ3_WriteBSPFile\n\nSwaps the bsp file in place, so it should not be referenced again\n=============\n*/\nvoid\tQ3_WriteBSPFile( char *filename )\n{\n\tq3_dheader_t\toutheader, *header;\n\tFILE\t\t*bspfile;\n\n\theader = &outheader;\n\tmemset( header, 0, sizeof(q3_dheader_t) );\n\t\n\tQ3_SwapBSPFile();\n\n\theader->ident = LittleLong( Q3_BSP_IDENT );\n\theader->version = LittleLong( Q3_BSP_VERSION );\n\t\n\tbspfile = SafeOpenWrite( filename );\n\tSafeWrite( bspfile, header, sizeof(q3_dheader_t) );\t// overwritten later\n\n\tQ3_AddLump( bspfile, header, Q3_LUMP_SHADERS, q3_dshaders, q3_numShaders*sizeof(q3_dshader_t) );\n\tQ3_AddLump( bspfile, header, Q3_LUMP_PLANES, q3_dplanes, q3_numplanes*sizeof(q3_dplane_t) );\n\tQ3_AddLump( bspfile, header, Q3_LUMP_LEAFS, q3_dleafs, q3_numleafs*sizeof(q3_dleaf_t) );\n\tQ3_AddLump( bspfile, header, Q3_LUMP_NODES, q3_dnodes, q3_numnodes*sizeof(q3_dnode_t) );\n\tQ3_AddLump( bspfile, header, Q3_LUMP_BRUSHES, q3_dbrushes, q3_numbrushes*sizeof(q3_dbrush_t) );\n\tQ3_AddLump( bspfile, header, Q3_LUMP_BRUSHSIDES, q3_dbrushsides, q3_numbrushsides*sizeof(q3_dbrushside_t) );\n\tQ3_AddLump( bspfile, header, Q3_LUMP_LEAFSURFACES, q3_dleafsurfaces, q3_numleafsurfaces*sizeof(q3_dleafsurfaces[0]) );\n\tQ3_AddLump( bspfile, header, Q3_LUMP_LEAFBRUSHES, q3_dleafbrushes, q3_numleafbrushes*sizeof(q3_dleafbrushes[0]) );\n\tQ3_AddLump( bspfile, header, Q3_LUMP_MODELS, q3_dmodels, q3_nummodels*sizeof(q3_dmodel_t) );\n\tQ3_AddLump( bspfile, header, Q3_LUMP_DRAWVERTS, q3_drawVerts, q3_numDrawVerts*sizeof(q3_drawVert_t) );\n\tQ3_AddLump( bspfile, header, Q3_LUMP_SURFACES, q3_drawSurfaces, q3_numDrawSurfaces*sizeof(q3_dsurface_t) );\n\tQ3_AddLump( bspfile, header, Q3_LUMP_VISIBILITY, q3_visBytes, q3_numVisBytes );\n\tQ3_AddLump( bspfile, header, Q3_LUMP_LIGHTMAPS, q3_lightBytes, q3_numLightBytes );\n\tQ3_AddLump( bspfile, header, Q3_LUMP_LIGHTGRID, q3_gridData, 8 * q3_numGridPoints );\n\tQ3_AddLump( bspfile, header, Q3_LUMP_ENTITIES, q3_dentdata, q3_entdatasize );\n\tQ3_AddLump( bspfile, header, Q3_LUMP_FOGS, q3_dfogs, q3_numFogs * sizeof(q3_dfog_t) );\n\tQ3_AddLump( bspfile, header, Q3_LUMP_DRAWINDEXES, q3_drawIndexes, q3_numDrawIndexes * sizeof(q3_drawIndexes[0]) );\n\t\n\tfseek (bspfile, 0, SEEK_SET);\n\tSafeWrite (bspfile, header, sizeof(q3_dheader_t));\n\tfclose (bspfile);\t\n}\n\n//============================================================================\n\n/*\n=============\nQ3_PrintBSPFileSizes\n\nDumps info about current file\n=============\n*/\nvoid Q3_PrintBSPFileSizes( void )\n{\n\tif ( !num_entities )\n\t{\n\t\tQ3_ParseEntities();\n\t}\n\n\tLog_Print (\"%6i models       %7i\\n\"\n\t\t,q3_nummodels, (int)(q3_nummodels*sizeof(q3_dmodel_t)));\n\tLog_Print (\"%6i shaders      %7i\\n\"\n\t\t,q3_numShaders, (int)(q3_numShaders*sizeof(q3_dshader_t)));\n\tLog_Print (\"%6i brushes      %7i\\n\"\n\t\t,q3_numbrushes, (int)(q3_numbrushes*sizeof(q3_dbrush_t)));\n\tLog_Print (\"%6i brushsides   %7i\\n\"\n\t\t,q3_numbrushsides, (int)(q3_numbrushsides*sizeof(q3_dbrushside_t)));\n\tLog_Print (\"%6i fogs         %7i\\n\"\n\t\t,q3_numFogs, (int)(q3_numFogs*sizeof(q3_dfog_t)));\n\tLog_Print (\"%6i planes       %7i\\n\"\n\t\t,q3_numplanes, (int)(q3_numplanes*sizeof(q3_dplane_t)));\n\tLog_Print (\"%6i entdata      %7i\\n\", num_entities, q3_entdatasize);\n\n\tLog_Print (\"\\n\");\n\n\tLog_Print (\"%6i nodes        %7i\\n\"\n\t\t,q3_numnodes, (int)(q3_numnodes*sizeof(q3_dnode_t)));\n\tLog_Print (\"%6i leafs        %7i\\n\"\n\t\t,q3_numleafs, (int)(q3_numleafs*sizeof(q3_dleaf_t)));\n\tLog_Print (\"%6i leafsurfaces %7i\\n\"\n\t\t,q3_numleafsurfaces, (int)(q3_numleafsurfaces*sizeof(q3_dleafsurfaces[0])));\n\tLog_Print (\"%6i leafbrushes  %7i\\n\"\n\t\t,q3_numleafbrushes, (int)(q3_numleafbrushes*sizeof(q3_dleafbrushes[0])));\n\tLog_Print (\"%6i drawverts    %7i\\n\"\n\t\t,q3_numDrawVerts, (int)(q3_numDrawVerts*sizeof(q3_drawVerts[0])));\n\tLog_Print (\"%6i drawindexes  %7i\\n\"\n\t\t,q3_numDrawIndexes, (int)(q3_numDrawIndexes*sizeof(q3_drawIndexes[0])));\n\tLog_Print (\"%6i drawsurfaces %7i\\n\"\n\t\t,q3_numDrawSurfaces, (int)(q3_numDrawSurfaces*sizeof(q3_drawSurfaces[0])));\n\n\tLog_Print (\"%6i lightmaps    %7i\\n\"\n\t\t,q3_numLightBytes / (LIGHTMAP_WIDTH*LIGHTMAP_HEIGHT*3), q3_numLightBytes );\n\tLog_Print (\"       visibility   %7i\\n\"\n\t\t, q3_numVisBytes );\n}\n\n/*\n================\nQ3_ParseEntities\n\nParses the q3_dentdata string into entities\n================\n*/\nvoid Q3_ParseEntities (void)\n{\n\tscript_t *script;\n\n\tnum_entities = 0;\n\tscript = LoadScriptMemory(q3_dentdata, q3_entdatasize, \"*Quake3 bsp file\");\n\tSetScriptFlags(script, SCFL_NOSTRINGWHITESPACES |\n\t\t\t\t\t\t\t\t\tSCFL_NOSTRINGESCAPECHARS);\n\n\twhile(ParseEntity(script))\n\t{\n\t} //end while\n\n\tFreeScript(script);\n} //end of the function Q3_ParseEntities\n\n\n/*\n================\nQ3_UnparseEntities\n\nGenerates the q3_dentdata string from all the entities\n================\n*/\nvoid Q3_UnparseEntities (void)\n{\n\tchar *buf, *end;\n\tepair_t *ep;\n\tchar line[2048];\n\tint i;\n\t\n\tbuf = q3_dentdata;\n\tend = buf;\n\t*end = 0;\n\t\n\tfor (i=0 ; i<num_entities ; i++)\n\t{\n\t\tep = entities[i].epairs;\n\t\tif (!ep)\n\t\t\tcontinue;\t// ent got removed\n\t\t\n\t\tstrcat (end,\"{\\n\");\n\t\tend += 2;\n\t\t\t\t\n\t\tfor (ep = entities[i].epairs ; ep ; ep=ep->next)\n\t\t{\n\t\t\tsprintf (line, \"\\\"%s\\\" \\\"%s\\\"\\n\", ep->key, ep->value);\n\t\t\tstrcat (end, line);\n\t\t\tend += strlen(line);\n\t\t}\n\t\tstrcat (end,\"}\\n\");\n\t\tend += 2;\n\n\t\tif (end > buf + Q3_MAX_MAP_ENTSTRING)\n\t\t\tError (\"Entity text too long\");\n\t}\n\tq3_entdatasize = end - buf + 1;\n} //end of the function Q3_UnparseEntities\n\n\n"
  },
  {
    "path": "code/bspc/l_bsp_q3.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"q3files.h\"\n//#include \"surfaceflags.h\"\n\nextern\tint\t\t\t\tq3_nummodels;\nextern\tq3_dmodel_t\t\t*q3_dmodels;//[MAX_MAP_MODELS];\n\nextern\tint\t\t\t\tq3_numShaders;\nextern\tq3_dshader_t\t*q3_dshaders;//[Q3_MAX_MAP_SHADERS];\n\nextern\tint\t\t\t\tq3_entdatasize;\nextern\tchar\t\t\t*q3_dentdata;//[Q3_MAX_MAP_ENTSTRING];\n\nextern\tint\t\t\t\tq3_numleafs;\nextern\tq3_dleaf_t\t\t*q3_dleafs;//[Q3_MAX_MAP_LEAFS];\n\nextern\tint\t\t\t\tq3_numplanes;\nextern\tq3_dplane_t\t\t*q3_dplanes;//[Q3_MAX_MAP_PLANES];\n\nextern\tint\t\t\t\tq3_numnodes;\nextern\tq3_dnode_t\t\t*q3_dnodes;//[Q3_MAX_MAP_NODES];\n\nextern\tint\t\t\t\tq3_numleafsurfaces;\nextern\tint\t\t\t\t*q3_dleafsurfaces;//[Q3_MAX_MAP_LEAFFACES];\n\nextern\tint\t\t\t\tq3_numleafbrushes;\nextern\tint\t\t\t\t*q3_dleafbrushes;//[Q3_MAX_MAP_LEAFBRUSHES];\n\nextern\tint\t\t\t\tq3_numbrushes;\nextern\tq3_dbrush_t\t\t*q3_dbrushes;//[Q3_MAX_MAP_BRUSHES];\n\nextern\tint\t\t\t\tq3_numbrushsides;\nextern\tq3_dbrushside_t\t*q3_dbrushsides;//[Q3_MAX_MAP_BRUSHSIDES];\n\nextern\tint\t\t\t\tq3_numLightBytes;\nextern\tbyte\t\t\t*q3_lightBytes;//[Q3_MAX_MAP_LIGHTING];\n\nextern\tint\t\t\t\tq3_numGridPoints;\nextern\tbyte\t\t\t*q3_gridData;//[Q3_MAX_MAP_LIGHTGRID];\n\nextern\tint\t\t\t\tq3_numVisBytes;\nextern\tbyte\t\t\t*q3_visBytes;//[Q3_MAX_MAP_VISIBILITY];\n\nextern\tint\t\t\t\tq3_numDrawVerts;\nextern\tq3_drawVert_t\t*q3_drawVerts;//[Q3_MAX_MAP_DRAW_VERTS];\n\nextern\tint\t\t\t\tq3_numDrawIndexes;\nextern\tint\t\t\t\t*q3_drawIndexes;//[Q3_MAX_MAP_DRAW_INDEXES];\n\nextern\tint\t\t\t\tq3_numDrawSurfaces;\nextern\tq3_dsurface_t\t*q3_drawSurfaces;//[Q3_MAX_MAP_DRAW_SURFS];\n\nextern\tint\t\t\t\tq3_numFogs;\nextern\tq3_dfog_t\t\t*q3_dfogs;//[Q3_MAX_MAP_FOGS];\n\nextern\tchar\t\t\tq3_dbrushsidetextured[Q3_MAX_MAP_BRUSHSIDES];\n\nvoid Q3_LoadBSPFile(struct quakefile_s *qf);\nvoid Q3_FreeMaxBSP(void);\nvoid Q3_ParseEntities (void);\n"
  },
  {
    "path": "code/bspc/l_bsp_sin.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"l_cmd.h\"\n#include \"l_math.h\"\n#include \"l_mem.h\"\n#include \"l_log.h\"\n#include \"l_poly.h\"\n#include \"../botlib/l_script.h\"\n#include \"l_bsp_ent.h\"\n#include \"l_bsp_sin.h\"\n\nvoid GetLeafNums (void);\n\n//=============================================================================\n\nint\t\t\t\t\tsin_nummodels;\nsin_dmodel_t\t\t*sin_dmodels;//[SIN_MAX_MAP_MODELS];\n\nint\t\t\t\t\tsin_visdatasize;\nbyte\t\t\t\t*sin_dvisdata;//[SIN_MAX_MAP_VISIBILITY];\nsin_dvis_t\t\t\t*sin_dvis;// = (sin_dvis_t *)sin_sin_dvisdata;\n\nint\t\t\t\t\tsin_lightdatasize;\nbyte\t\t\t\t*sin_dlightdata;//[SIN_MAX_MAP_LIGHTING];\n\nint\t\t\t\t\tsin_entdatasize;\nchar\t\t\t\t*sin_dentdata;//[SIN_MAX_MAP_ENTSTRING];\n\nint\t\t\t\t\tsin_numleafs;\nsin_dleaf_t\t\t\t*sin_dleafs;//[SIN_MAX_MAP_LEAFS];\n\nint\t\t\t\t\tsin_numplanes;\nsin_dplane_t\t\t*sin_dplanes;//[SIN_MAX_MAP_PLANES];\n\nint\t\t\t\t\tsin_numvertexes;\nsin_dvertex_t\t\t*sin_dvertexes;//[SIN_MAX_MAP_VERTS];\n\nint\t\t\t\t\tsin_numnodes;\nsin_dnode_t\t\t\t*sin_dnodes;//[SIN_MAX_MAP_NODES];\n\nint\t\t\t\t\tsin_numtexinfo;\nsin_texinfo_t\t\t*sin_texinfo;//[SIN_MAX_MAP_sin_texinfo];\n\nint\t\t\t\t\tsin_numfaces;\nsin_dface_t\t\t\t*sin_dfaces;//[SIN_MAX_MAP_FACES];\n\nint\t\t\t\t\tsin_numedges;\nsin_dedge_t\t\t\t*sin_dedges;//[SIN_MAX_MAP_EDGES];\n\nint\t\t\t\t\tsin_numleaffaces;\nunsigned short\t\t*sin_dleaffaces;//[SIN_MAX_MAP_LEAFFACES];\n\nint\t\t\t\t\tsin_numleafbrushes;\nunsigned short\t\t*sin_dleafbrushes;//[SIN_MAX_MAP_LEAFBRUSHES];\n\nint\t\t\t\t\tsin_numsurfedges;\nint\t\t\t\t\t*sin_dsurfedges;//[SIN_MAX_MAP_SURFEDGES];\n\nint\t\t\t\t\tsin_numbrushes;\nsin_dbrush_t\t\t*sin_dbrushes;//[SIN_MAX_MAP_BRUSHES];\n\nint\t\t\t\t\tsin_numbrushsides;\nsin_dbrushside_t\t*sin_dbrushsides;//[SIN_MAX_MAP_BRUSHSIDES];\n\nint\t\t\t\t\tsin_numareas;\nsin_darea_t\t\t\t*sin_dareas;//[SIN_MAX_MAP_AREAS];\n\nint\t\t\t\t\tsin_numareaportals;\nsin_dareaportal_t\t*sin_dareaportals;//[SIN_MAX_MAP_AREAPORTALS];\n\nint\t\t\t\t\tsin_numlightinfo;\nsin_lightvalue_t\t*sin_lightinfo;//[SIN_MAX_MAP_LIGHTINFO];\n\nbyte\t\t\t\tsin_dpop[256];\n\nchar\t\t\t\tsin_dbrushsidetextured[SIN_MAX_MAP_BRUSHSIDES];\n\nint sin_bspallocated = false;\nint sin_allocatedbspmem = 0;\n\nvoid Sin_AllocMaxBSP(void)\n{\n\t//models\n\tsin_nummodels = 0;\n\tsin_dmodels = (sin_dmodel_t *) GetClearedMemory(SIN_MAX_MAP_MODELS * sizeof(sin_dmodel_t));\n\tsin_allocatedbspmem += SIN_MAX_MAP_MODELS * sizeof(sin_dmodel_t);\n\t//vis data\n\tsin_visdatasize = 0;\n\tsin_dvisdata = (byte *) GetClearedMemory(SIN_MAX_MAP_VISIBILITY * sizeof(byte));\n\tsin_dvis = (sin_dvis_t *) sin_dvisdata;\n\tsin_allocatedbspmem += SIN_MAX_MAP_VISIBILITY * sizeof(byte);\n\t//light data\n\tsin_lightdatasize = 0;\n\tsin_dlightdata = (byte *) GetClearedMemory(SIN_MAX_MAP_LIGHTING * sizeof(byte));\n\tsin_allocatedbspmem += SIN_MAX_MAP_LIGHTING * sizeof(byte);\n\t//entity data\n\tsin_entdatasize = 0;\n\tsin_dentdata = (char *) GetClearedMemory(SIN_MAX_MAP_ENTSTRING * sizeof(char));\n\tsin_allocatedbspmem += SIN_MAX_MAP_ENTSTRING * sizeof(char);\n\t//leafs\n\tsin_numleafs = 0;\n\tsin_dleafs = (sin_dleaf_t *) GetClearedMemory(SIN_MAX_MAP_LEAFS * sizeof(sin_dleaf_t));\n\tsin_allocatedbspmem += SIN_MAX_MAP_LEAFS * sizeof(sin_dleaf_t);\n\t//planes\n\tsin_numplanes = 0;\n\tsin_dplanes = (sin_dplane_t *) GetClearedMemory(SIN_MAX_MAP_PLANES * sizeof(sin_dplane_t));\n\tsin_allocatedbspmem += SIN_MAX_MAP_PLANES * sizeof(sin_dplane_t);\n\t//vertexes\n\tsin_numvertexes = 0;\n\tsin_dvertexes = (sin_dvertex_t *) GetClearedMemory(SIN_MAX_MAP_VERTS * sizeof(sin_dvertex_t));\n\tsin_allocatedbspmem += SIN_MAX_MAP_VERTS * sizeof(sin_dvertex_t);\n\t//nodes\n\tsin_numnodes = 0;\n\tsin_dnodes = (sin_dnode_t *) GetClearedMemory(SIN_MAX_MAP_NODES * sizeof(sin_dnode_t));\n\tsin_allocatedbspmem += SIN_MAX_MAP_NODES * sizeof(sin_dnode_t);\n\t//texture info\n\tsin_numtexinfo = 0;\n\tsin_texinfo = (sin_texinfo_t *) GetClearedMemory(SIN_MAX_MAP_TEXINFO * sizeof(sin_texinfo_t));\n\tsin_allocatedbspmem += SIN_MAX_MAP_TEXINFO * sizeof(sin_texinfo_t);\n\t//faces\n\tsin_numfaces = 0;\n\tsin_dfaces = (sin_dface_t *) GetClearedMemory(SIN_MAX_MAP_FACES * sizeof(sin_dface_t));\n\tsin_allocatedbspmem += SIN_MAX_MAP_FACES * sizeof(sin_dface_t);\n\t//edges\n\tsin_numedges = 0;\n\tsin_dedges = (sin_dedge_t *) GetClearedMemory(SIN_MAX_MAP_EDGES * sizeof(sin_dedge_t));\n\tsin_allocatedbspmem += SIN_MAX_MAP_EDGES * sizeof(sin_dedge_t);\n\t//leaf faces\n\tsin_numleaffaces = 0;\n\tsin_dleaffaces = (unsigned short *) GetClearedMemory(SIN_MAX_MAP_LEAFFACES * sizeof(unsigned short));\n\tsin_allocatedbspmem += SIN_MAX_MAP_LEAFFACES * sizeof(unsigned short);\n\t//leaf brushes\n\tsin_numleafbrushes = 0;\n\tsin_dleafbrushes = (unsigned short *) GetClearedMemory(SIN_MAX_MAP_LEAFBRUSHES * sizeof(unsigned short));\n\tsin_allocatedbspmem += SIN_MAX_MAP_LEAFBRUSHES * sizeof(unsigned short);\n\t//surface edges\n\tsin_numsurfedges = 0;\n\tsin_dsurfedges = (int *) GetClearedMemory(SIN_MAX_MAP_SURFEDGES * sizeof(int));\n\tsin_allocatedbspmem += SIN_MAX_MAP_SURFEDGES * sizeof(int);\n\t//brushes\n\tsin_numbrushes = 0;\n\tsin_dbrushes = (sin_dbrush_t *) GetClearedMemory(SIN_MAX_MAP_BRUSHES * sizeof(sin_dbrush_t));\n\tsin_allocatedbspmem += SIN_MAX_MAP_BRUSHES * sizeof(sin_dbrush_t);\n\t//brushsides\n\tsin_numbrushsides = 0;\n\tsin_dbrushsides = (sin_dbrushside_t *) GetClearedMemory(SIN_MAX_MAP_BRUSHSIDES * sizeof(sin_dbrushside_t));\n\tsin_allocatedbspmem += SIN_MAX_MAP_BRUSHSIDES * sizeof(sin_dbrushside_t);\n\t//areas\n\tsin_numareas = 0;\n\tsin_dareas = (sin_darea_t *) GetClearedMemory(SIN_MAX_MAP_AREAS * sizeof(sin_darea_t));\n\tsin_allocatedbspmem += SIN_MAX_MAP_AREAS * sizeof(sin_darea_t);\n\t//area portals\n\tsin_numareaportals = 0;\n\tsin_dareaportals = (sin_dareaportal_t *) GetClearedMemory(SIN_MAX_MAP_AREAPORTALS * sizeof(sin_dareaportal_t));\n\tsin_allocatedbspmem += SIN_MAX_MAP_AREAPORTALS * sizeof(sin_dareaportal_t);\n\t//light info\n\tsin_numlightinfo = 0;\n\tsin_lightinfo = (sin_lightvalue_t *) GetClearedMemory(SIN_MAX_MAP_LIGHTINFO * sizeof(sin_lightvalue_t));\n\tsin_allocatedbspmem += SIN_MAX_MAP_LIGHTINFO * sizeof(sin_lightvalue_t);\n\t//print allocated memory\n\tLog_Print(\"allocated \");\n\tPrintMemorySize(sin_allocatedbspmem);\n\tLog_Print(\" of BSP memory\\n\");\n} //end of the function Sin_AllocMaxBSP\n\nvoid Sin_FreeMaxBSP(void)\n{\n\t//models\n\tsin_nummodels = 0;\n\tFreeMemory(sin_dmodels);\n\tsin_dmodels = NULL;\n\t//vis data\n\tsin_visdatasize = 0;\n\tFreeMemory(sin_dvisdata);\n\tsin_dvisdata = NULL;\n\tsin_dvis = NULL;\n\t//light data\n\tsin_lightdatasize = 0;\n\tFreeMemory(sin_dlightdata);\n\tsin_dlightdata = NULL;\n\t//entity data\n\tsin_entdatasize = 0;\n\tFreeMemory(sin_dentdata);\n\tsin_dentdata = NULL;\n\t//leafs\n\tsin_numleafs = 0;\n\tFreeMemory(sin_dleafs);\n\tsin_dleafs = NULL;\n\t//planes\n\tsin_numplanes = 0;\n\tFreeMemory(sin_dplanes);\n\tsin_dplanes = NULL;\n\t//vertexes\n\tsin_numvertexes = 0;\n\tFreeMemory(sin_dvertexes);\n\tsin_dvertexes = NULL;\n\t//nodes\n\tsin_numnodes = 0;\n\tFreeMemory(sin_dnodes);\n\tsin_dnodes = NULL;\n\t//texture info\n\tsin_numtexinfo = 0;\n\tFreeMemory(sin_texinfo);\n\tsin_texinfo = NULL;\n\t//faces\n\tsin_numfaces = 0;\n\tFreeMemory(sin_dfaces);\n\tsin_dfaces = NULL;\n\t//edges\n\tsin_numedges = 0;\n\tFreeMemory(sin_dedges);\n\tsin_dedges = NULL;\n\t//leaf faces\n\tsin_numleaffaces = 0;\n\tFreeMemory(sin_dleaffaces);\n\tsin_dleaffaces = NULL;\n\t//leaf brushes\n\tsin_numleafbrushes = 0;\n\tFreeMemory(sin_dleafbrushes);\n\tsin_dleafbrushes = NULL;\n\t//surface edges\n\tsin_numsurfedges = 0;\n\tFreeMemory(sin_dsurfedges);\n\tsin_dsurfedges = NULL;\n\t//brushes\n\tsin_numbrushes = 0;\n\tFreeMemory(sin_dbrushes);\n\tsin_dbrushes = NULL;\n\t//brushsides\n\tsin_numbrushsides = 0;\n\tFreeMemory(sin_dbrushsides);\n\tsin_dbrushsides = NULL;\n\t//areas\n\tsin_numareas = 0;\n\tFreeMemory(sin_dareas);\n\tsin_dareas = NULL;\n\t//area portals\n\tsin_numareaportals = 0;\n\tFreeMemory(sin_dareaportals);\n\tsin_dareaportals = NULL;\n\t//light info\n\tsin_numlightinfo = 0;\n\tFreeMemory(sin_lightinfo);\n\tsin_lightinfo = NULL;\n\t//\n\tLog_Print(\"freed \");\n\tPrintMemorySize(sin_allocatedbspmem);\n\tLog_Print(\" of BSP memory\\n\");\n\tsin_allocatedbspmem = 0;\n} //end of the function Sin_FreeMaxBSP\n\n#define WCONVEX_EPSILON\t\t0.5\n\n//===========================================================================\n// returns the amount the face and the winding overlap\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat Sin_FaceOnWinding(sin_dface_t *face, winding_t *winding)\n{\n\tint i, edgenum, side;\n\tfloat dist, area;\n\tsin_dplane_t plane;\n\tvec_t *v1, *v2;\n\tvec3_t normal, edgevec;\n\twinding_t *w;\n\n\t//\n\tw = CopyWinding(winding);\n\tmemcpy(&plane, &sin_dplanes[face->planenum], sizeof(sin_dplane_t));\n\t//check on which side of the plane the face is\n\tif (face->side)\n\t{\n\t\tVectorNegate(plane.normal, plane.normal);\n\t\tplane.dist = -plane.dist;\n\t} //end if\n\tfor (i = 0; i < face->numedges && w; i++)\n\t{\n\t\t//get the first and second vertex of the edge\n\t\tedgenum = sin_dsurfedges[face->firstedge + i];\n\t\tside = edgenum > 0;\n\t\t//if the face plane is flipped\n\t\tv1 = sin_dvertexes[sin_dedges[abs(edgenum)].v[side]].point;\n\t\tv2 = sin_dvertexes[sin_dedges[abs(edgenum)].v[!side]].point;\n\t\t//create a plane through the edge vector, orthogonal to the face plane\n\t\t//and with the normal vector pointing out of the face\n\t\tVectorSubtract(v1, v2, edgevec);\n\t\tCrossProduct(edgevec, plane.normal, normal);\n\t\tVectorNormalize(normal);\n\t\tdist = DotProduct(normal, v1);\n\t\t//\n\t\tChopWindingInPlace(&w, normal, dist, 0.9); //CLIP_EPSILON\n\t} //end for\n\tif (w)\n\t{\n\t\tarea = WindingArea(w);\n\t\tFreeWinding(w);\n\t\treturn area;\n\t} //end if\n\treturn 0;\n} //end of the function Sin_FaceOnWinding\n//===========================================================================\n// creates a winding for the given brush side on the given brush\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nwinding_t *Sin_BrushSideWinding(sin_dbrush_t *brush, sin_dbrushside_t *baseside)\n{\n\tint i;\n\tsin_dplane_t *baseplane, *plane;\n\tsin_dbrushside_t *side;\n\twinding_t *w;\n\t\n\t//create a winding for the brush side with the given planenumber\n\tbaseplane = &sin_dplanes[baseside->planenum];\n\tw = BaseWindingForPlane(baseplane->normal, baseplane->dist);\n\tfor (i = 0; i < brush->numsides && w; i++)\n\t{\n\t\tside = &sin_dbrushsides[brush->firstside + i];\n\t\t//don't chop with the base plane\n\t\tif (side->planenum == baseside->planenum) continue;\n\t\t//also don't use planes that are almost equal\n\t\tplane = &sin_dplanes[side->planenum];\n\t\tif (DotProduct(baseplane->normal, plane->normal) > 0.999\n\t\t\t\t&& fabs(baseplane->dist - plane->dist) < 0.01) continue;\n\t\t//\n\t\tplane = &sin_dplanes[side->planenum^1];\n\t\tChopWindingInPlace(&w, plane->normal, plane->dist, 0); //CLIP_EPSILON);\n\t} //end for\n\treturn w;\n} //end of the function Sin_BrushSideWinding\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint Sin_HintSkipBrush(sin_dbrush_t *brush)\n{\n\tint j;\n\tsin_dbrushside_t *brushside;\n\n\tfor (j = 0; j < brush->numsides; j++)\n\t{\n\t\tbrushside = &sin_dbrushsides[brush->firstside + j];\n\t\tif (brushside->texinfo > 0)\n\t\t{\n\t\t\tif (sin_texinfo[brushside->texinfo].flags & (SURF_SKIP|SURF_HINT))\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n\treturn false;\n} //end of the function Sin_HintSkipBrush\n//===========================================================================\n// fix screwed brush texture references\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean WindingIsTiny(winding_t *w);\n\nvoid Sin_FixTextureReferences(void)\n{\n\tint i, j, k, we;\n\tsin_dbrushside_t *brushside;\n\tsin_dbrush_t *brush;\n\tsin_dface_t *face;\n\twinding_t *w;\n\n\tmemset(sin_dbrushsidetextured, false, SIN_MAX_MAP_BRUSHSIDES);\n\t//go over all the brushes\n   for (i = 0; i < sin_numbrushes; i++)\n   {\n\t\tbrush = &sin_dbrushes[i];\n\t\t//hint brushes are not textured\n\t\tif (Sin_HintSkipBrush(brush)) continue;\n\t\t//go over all the sides of the brush\n\t\tfor (j = 0; j < brush->numsides; j++)\n\t\t{\n\t\t\tbrushside = &sin_dbrushsides[brush->firstside + j];\n\t\t\t//\n\t\t\tw = Sin_BrushSideWinding(brush, brushside);\n\t\t\tif (!w)\n\t\t\t{\n\t\t\t\tsin_dbrushsidetextured[brush->firstside + j] = true;\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\t//RemoveEqualPoints(w, 0.2);\n\t\t\t\tif (WindingIsTiny(w))\n\t\t\t\t{\n\t\t\t\t\tFreeWinding(w);\n\t\t\t\t\tsin_dbrushsidetextured[brush->firstside + j] = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t} //end if\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\twe = WindingError(w);\n\t\t\t\t\tif (we == WE_NOTENOUGHPOINTS\n\t\t\t\t\t\t|| we == WE_SMALLAREA\n\t\t\t\t\t\t|| we == WE_POINTBOGUSRANGE\n//\t\t\t\t\t\t|| we == WE_NONCONVEX\n\t\t\t\t\t\t)\n\t\t\t\t\t{\n\t\t\t\t\t\tFreeWinding(w);\n\t\t\t\t\t\tsin_dbrushsidetextured[brush->firstside + j] = true;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end else\n\t\t\t} //end else\n\t\t\tif (WindingArea(w) < 20)\n\t\t\t{\n\t\t\t\tsin_dbrushsidetextured[brush->firstside + j] = true;\n\t\t\t} //end if\n\t\t\t//find a face for texturing this brush\n\t\t\tfor (k = 0; k < sin_numfaces; k++)\n\t\t\t{\n\t\t\t\tface = &sin_dfaces[k];\n\t\t\t\t//if the face is in the same plane as the brush side\n\t\t\t\tif ((face->planenum&~1) != (brushside->planenum&~1)) continue;\n\t\t\t\t//if the face is partly or totally on the brush side\n\t\t\t\tif (Sin_FaceOnWinding(face, w))\n\t\t\t\t{\n\t\t\t\t\tbrushside->texinfo = face->texinfo;\n\t\t\t\t\tsin_dbrushsidetextured[brush->firstside + j] = true;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t} //end for\n\t\t\tFreeWinding(w);\n\t\t} //end for\n\t} //end for\n} //end of the function Sin_FixTextureReferences*/\n\n/*\n===============\nCompressVis\n\n===============\n*/\nint Sin_CompressVis (byte *vis, byte *dest)\n{\n\tint\t\tj;\n\tint\t\trep;\n\tint\t\tvisrow;\n\tbyte\t*dest_p;\n\t\n\tdest_p = dest;\n//\tvisrow = (r_numvisleafs + 7)>>3;\n\tvisrow = (sin_dvis->numclusters + 7)>>3;\n\t\n\tfor (j=0 ; j<visrow ; j++)\n\t{\n\t\t*dest_p++ = vis[j];\n\t\tif (vis[j])\n\t\t\tcontinue;\n\n\t\trep = 1;\n\t\tfor ( j++; j<visrow ; j++)\n\t\t\tif (vis[j] || rep == 255)\n\t\t\t\tbreak;\n\t\t\telse\n\t\t\t\trep++;\n\t\t*dest_p++ = rep;\n\t\tj--;\n\t}\n\t\n\treturn dest_p - dest;\n} //end of the function Sin_CompressVis\n\n\n/*\n===================\nDecompressVis\n===================\n*/\nvoid Sin_DecompressVis (byte *in, byte *decompressed)\n{\n\tint\t\tc;\n\tbyte\t*out;\n\tint\t\trow;\n\n//\trow = (r_numvisleafs+7)>>3;\t\n\trow = (sin_dvis->numclusters+7)>>3;\t\n\tout = decompressed;\n\n\tdo\n\t{\n\t\tif (*in)\n\t\t{\n\t\t\t*out++ = *in++;\n\t\t\tcontinue;\n\t\t}\n\t\n\t\tc = in[1];\n\t\tif (!c)\n\t\t\tError (\"DecompressVis: 0 repeat\");\n\t\tin += 2;\n\t\twhile (c)\n\t\t{\n\t\t\t*out++ = 0;\n\t\t\tc--;\n\t\t}\n\t} while (out - decompressed < row);\n} //end of the function Sin_DecompressVis\n\n//=============================================================================\n\n/*\n=============\nSin_SwapBSPFile\n\nByte swaps all data in a bsp file.\n=============\n*/\nvoid Sin_SwapBSPFile (qboolean todisk)\n{\n\tint\t\t\t\ti, j;\n\tsin_dmodel_t\t\t*d;\n\n\t\n// models\t\n\tfor (i=0 ; i<sin_nummodels ; i++)\n\t{\n\t\td = &sin_dmodels[i];\n\n\t\td->firstface = LittleLong (d->firstface);\n\t\td->numfaces = LittleLong (d->numfaces);\n\t\td->headnode = LittleLong (d->headnode);\n\t\t\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\td->mins[j] = LittleFloat(d->mins[j]);\n\t\t\td->maxs[j] = LittleFloat(d->maxs[j]);\n\t\t\td->origin[j] = LittleFloat(d->origin[j]);\n\t\t}\n\t}\n\n//\n// vertexes\n//\n\tfor (i=0 ; i<sin_numvertexes ; i++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t\tsin_dvertexes[i].point[j] = LittleFloat (sin_dvertexes[i].point[j]);\n\t}\n\t\t\n//\n// planes\n//\t\n\tfor (i=0 ; i<sin_numplanes ; i++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t\tsin_dplanes[i].normal[j] = LittleFloat (sin_dplanes[i].normal[j]);\n\t\tsin_dplanes[i].dist = LittleFloat (sin_dplanes[i].dist);\n\t\tsin_dplanes[i].type = LittleLong (sin_dplanes[i].type);\n\t}\n\t\n//\n// sin_texinfos\n//\t\n\tfor (i = 0; i < sin_numtexinfo; i++)\n\t{\n\t\tfor (j=0 ; j<8 ; j++)\n\t\t\tsin_texinfo[i].vecs[0][j] = LittleFloat (sin_texinfo[i].vecs[0][j]);\n#ifdef SIN\n      sin_texinfo[i].trans_mag = LittleFloat( sin_texinfo[i].trans_mag );     \n      sin_texinfo[i].trans_angle = LittleLong( sin_texinfo[i].trans_angle );     \n      sin_texinfo[i].animtime = LittleFloat( sin_texinfo[i].animtime );     \n      sin_texinfo[i].nonlit = LittleFloat( sin_texinfo[i].nonlit );     \n      sin_texinfo[i].translucence = LittleFloat( sin_texinfo[i].translucence );     \n      sin_texinfo[i].friction = LittleFloat( sin_texinfo[i].friction );     \n      sin_texinfo[i].restitution = LittleFloat( sin_texinfo[i].restitution );     \n\t\tsin_texinfo[i].flags = LittleUnsigned (sin_texinfo[i].flags);\n#else\n\t\tsin_texinfo[i].value = LittleLong (sin_texinfo[i].value);\n\t\tsin_texinfo[i].flags = LittleLong (sin_texinfo[i].flags);\n#endif\n\t\tsin_texinfo[i].nexttexinfo = LittleLong (sin_texinfo[i].nexttexinfo);\n\t}\n\n#ifdef SIN\n//\n// lightinfos\n//\t\n\tfor (i = 0; i < sin_numlightinfo; i++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n         {\n\t\t\tsin_lightinfo[i].color[j] = LittleFloat (sin_lightinfo[i].color[j]);\n         }\n\t\tsin_lightinfo[i].value = LittleLong (sin_lightinfo[i].value);\n      sin_lightinfo[i].direct = LittleFloat( sin_lightinfo[i].direct );     \n      sin_lightinfo[i].directangle = LittleFloat( sin_lightinfo[i].directangle );     \n      sin_lightinfo[i].directstyle = LittleFloat( sin_lightinfo[i].directstyle );     \n\t}\n#endif\n\t\n//\n// faces\n//\n\tfor (i=0 ; i<sin_numfaces ; i++)\n\t{\n\t\tsin_dfaces[i].texinfo = LittleShort (sin_dfaces[i].texinfo);\n#ifdef SIN\n\t\tsin_dfaces[i].lightinfo = LittleLong (sin_dfaces[i].lightinfo);\n\t\tsin_dfaces[i].planenum = LittleUnsignedShort (sin_dfaces[i].planenum);\n#else\n\t\tsin_dfaces[i].planenum = LittleShort (sin_dfaces[i].planenum);\n#endif\n\t\tsin_dfaces[i].side = LittleShort (sin_dfaces[i].side);\n\t\tsin_dfaces[i].lightofs = LittleLong (sin_dfaces[i].lightofs);\n\t\tsin_dfaces[i].firstedge = LittleLong (sin_dfaces[i].firstedge);\n\t\tsin_dfaces[i].numedges = LittleShort (sin_dfaces[i].numedges);\n\t}\n\n//\n// nodes\n//\n\tfor (i=0 ; i<sin_numnodes ; i++)\n\t{\n\t\tsin_dnodes[i].planenum = LittleLong (sin_dnodes[i].planenum);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\tsin_dnodes[i].mins[j] = LittleShort (sin_dnodes[i].mins[j]);\n\t\t\tsin_dnodes[i].maxs[j] = LittleShort (sin_dnodes[i].maxs[j]);\n\t\t}\n\t\tsin_dnodes[i].children[0] = LittleLong (sin_dnodes[i].children[0]);\n\t\tsin_dnodes[i].children[1] = LittleLong (sin_dnodes[i].children[1]);\n#ifdef SIN\n\t\tsin_dnodes[i].firstface = LittleUnsignedShort (sin_dnodes[i].firstface);\n\t\tsin_dnodes[i].numfaces = LittleUnsignedShort (sin_dnodes[i].numfaces);\n#else\n\t\tsin_dnodes[i].firstface = LittleShort (sin_dnodes[i].firstface);\n\t\tsin_dnodes[i].numfaces = LittleShort (sin_dnodes[i].numfaces);\n#endif\n\t}\n\n//\n// leafs\n//\n\tfor (i=0 ; i<sin_numleafs ; i++)\n\t{\n\t\tsin_dleafs[i].contents = LittleLong (sin_dleafs[i].contents);\n\t\tsin_dleafs[i].cluster = LittleShort (sin_dleafs[i].cluster);\n\t\tsin_dleafs[i].area = LittleShort (sin_dleafs[i].area);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\tsin_dleafs[i].mins[j] = LittleShort (sin_dleafs[i].mins[j]);\n\t\t\tsin_dleafs[i].maxs[j] = LittleShort (sin_dleafs[i].maxs[j]);\n\t\t}\n#ifdef SIN\n\t\tsin_dleafs[i].firstleafface = LittleUnsignedShort (sin_dleafs[i].firstleafface);\n\t\tsin_dleafs[i].numleaffaces = LittleUnsignedShort (sin_dleafs[i].numleaffaces);\n\t\tsin_dleafs[i].firstleafbrush = LittleUnsignedShort (sin_dleafs[i].firstleafbrush);\n\t\tsin_dleafs[i].numleafbrushes = LittleUnsignedShort (sin_dleafs[i].numleafbrushes);\n#else\n\t\tsin_dleafs[i].firstleafface = LittleShort (sin_dleafs[i].firstleafface);\n\t\tsin_dleafs[i].numleaffaces = LittleShort (sin_dleafs[i].numleaffaces);\n\t\tsin_dleafs[i].firstleafbrush = LittleShort (sin_dleafs[i].firstleafbrush);\n\t\tsin_dleafs[i].numleafbrushes = LittleShort (sin_dleafs[i].numleafbrushes);\n#endif\n\t}\n\n//\n// leaffaces\n//\n\tfor (i=0 ; i<sin_numleaffaces ; i++)\n\t\tsin_dleaffaces[i] = LittleShort (sin_dleaffaces[i]);\n\n//\n// leafbrushes\n//\n\tfor (i=0 ; i<sin_numleafbrushes ; i++)\n\t\tsin_dleafbrushes[i] = LittleShort (sin_dleafbrushes[i]);\n\n//\n// surfedges\n//\n\tfor (i=0 ; i<sin_numsurfedges ; i++)\n\t\tsin_dsurfedges[i] = LittleLong (sin_dsurfedges[i]);\n\n//\n// edges\n//\n\tfor (i=0 ; i<sin_numedges ; i++)\n\t{\n#ifdef SIN\n\t\tsin_dedges[i].v[0] = LittleUnsignedShort (sin_dedges[i].v[0]);\n\t\tsin_dedges[i].v[1] = LittleUnsignedShort (sin_dedges[i].v[1]);\n#else\n\t\tsin_dedges[i].v[0] = LittleShort (sin_dedges[i].v[0]);\n\t\tsin_dedges[i].v[1] = LittleShort (sin_dedges[i].v[1]);\n#endif\n\t}\n\n//\n// brushes\n//\n\tfor (i=0 ; i<sin_numbrushes ; i++)\n\t{\n\t\tsin_dbrushes[i].firstside = LittleLong (sin_dbrushes[i].firstside);\n\t\tsin_dbrushes[i].numsides = LittleLong (sin_dbrushes[i].numsides);\n\t\tsin_dbrushes[i].contents = LittleLong (sin_dbrushes[i].contents);\n\t}\n\n//\n// areas\n//\n\tfor (i=0 ; i<sin_numareas ; i++)\n\t{\n\t\tsin_dareas[i].numareaportals = LittleLong (sin_dareas[i].numareaportals);\n\t\tsin_dareas[i].firstareaportal = LittleLong (sin_dareas[i].firstareaportal);\n\t}\n\n//\n// areasportals\n//\n\tfor (i=0 ; i<sin_numareaportals ; i++)\n\t{\n\t\tsin_dareaportals[i].portalnum = LittleLong (sin_dareaportals[i].portalnum);\n\t\tsin_dareaportals[i].otherarea = LittleLong (sin_dareaportals[i].otherarea);\n\t}\n\n//\n// brushsides\n//\n\tfor (i=0 ; i<sin_numbrushsides ; i++)\n\t{\n#ifdef SIN\n\t\tsin_dbrushsides[i].planenum = LittleUnsignedShort (sin_dbrushsides[i].planenum);\n#else\n\t\tsin_dbrushsides[i].planenum = LittleShort (sin_dbrushsides[i].planenum);\n#endif\n\t\tsin_dbrushsides[i].texinfo = LittleShort (sin_dbrushsides[i].texinfo);\n#ifdef SIN\n\t\tsin_dbrushsides[i].lightinfo = LittleLong (sin_dbrushsides[i].lightinfo);\n#endif\n\t}\n\n//\n// visibility\n//\n\tif (todisk)\n\t\tj = sin_dvis->numclusters;\n\telse\n\t\tj = LittleLong(sin_dvis->numclusters);\n\tsin_dvis->numclusters = LittleLong (sin_dvis->numclusters);\n\tfor (i=0 ; i<j ; i++)\n\t{\n\t\tsin_dvis->bitofs[i][0] = LittleLong (sin_dvis->bitofs[i][0]);\n\t\tsin_dvis->bitofs[i][1] = LittleLong (sin_dvis->bitofs[i][1]);\n\t}\n} //end of the function Sin_SwapBSPFile\n\n\nsin_dheader_t\t*header;\n#ifdef SIN\nint Sin_CopyLump (int lump, void *dest, int size, int maxsize)\n{\n\tint\t\tlength, ofs;\n\n\tlength = header->lumps[lump].filelen;\n\tofs = header->lumps[lump].fileofs;\n\t\n\tif (length % size)\n\t\tError (\"Sin_LoadBSPFile: odd lump size\");\n\n   if ((length/size) > maxsize)\n      Error (\"Sin_LoadBSPFile: exceeded max size for lump %d size %d > maxsize %d\\n\", lump, (length/size), maxsize );\n\t\n\tmemcpy (dest, (byte *)header + ofs, length);\n\n\treturn length / size;\n}\n#else\nint Sin_CopyLump (int lump, void *dest, int size)\n{\n\tint\t\tlength, ofs;\n\n\tlength = header->lumps[lump].filelen;\n\tofs = header->lumps[lump].fileofs;\n\t\n\tif (length % size)\n\t\tError (\"Sin_LoadBSPFile: odd lump size\");\n\t\n\tmemcpy (dest, (byte *)header + ofs, length);\n\n\treturn length / size;\n}\n#endif\n\n/*\n=============\nSin_LoadBSPFile\n=============\n*/\nvoid\tSin_LoadBSPFile(char *filename, int offset, int length)\n{\n\tint\t\t\ti;\n\t\n//\n// load the file header\n//\n\tLoadFile (filename, (void **)&header, offset, length);\n\n// swap the header\n\tfor (i=0 ; i< sizeof(sin_dheader_t)/4 ; i++)\n\t\t((int *)header)[i] = LittleLong ( ((int *)header)[i]);\n\n\tif (header->ident != SIN_BSPHEADER && header->ident != SINGAME_BSPHEADER)\n\t\tError (\"%s is not a IBSP file\", filename);\n\tif (header->version != SIN_BSPVERSION && header->version != SINGAME_BSPVERSION)\n\t\tError (\"%s is version %i, not %i\", filename, header->version, SIN_BSPVERSION);\n\n#ifdef SIN\n\tsin_nummodels = Sin_CopyLump (SIN_LUMP_MODELS, sin_dmodels, sizeof(sin_dmodel_t), SIN_MAX_MAP_MODELS);\n\tsin_numvertexes = Sin_CopyLump (SIN_LUMP_VERTEXES, sin_dvertexes, sizeof(sin_dvertex_t), SIN_MAX_MAP_VERTS);\n\tsin_numplanes = Sin_CopyLump (SIN_LUMP_PLANES, sin_dplanes, sizeof(sin_dplane_t), SIN_MAX_MAP_PLANES);\n\tsin_numleafs = Sin_CopyLump (SIN_LUMP_LEAFS, sin_dleafs, sizeof(sin_dleaf_t), SIN_MAX_MAP_LEAFS);\n\tsin_numnodes = Sin_CopyLump (SIN_LUMP_NODES, sin_dnodes, sizeof(sin_dnode_t), SIN_MAX_MAP_NODES);\n\tsin_numtexinfo = Sin_CopyLump (SIN_LUMP_TEXINFO, sin_texinfo, sizeof(sin_texinfo_t), SIN_MAX_MAP_TEXINFO);\n\tsin_numfaces = Sin_CopyLump (SIN_LUMP_FACES, sin_dfaces, sizeof(sin_dface_t), SIN_MAX_MAP_FACES);\n\tsin_numleaffaces = Sin_CopyLump (SIN_LUMP_LEAFFACES, sin_dleaffaces, sizeof(sin_dleaffaces[0]), SIN_MAX_MAP_LEAFFACES);\n\tsin_numleafbrushes = Sin_CopyLump (SIN_LUMP_LEAFBRUSHES, sin_dleafbrushes, sizeof(sin_dleafbrushes[0]), SIN_MAX_MAP_LEAFBRUSHES);\n\tsin_numsurfedges = Sin_CopyLump (SIN_LUMP_SURFEDGES, sin_dsurfedges, sizeof(sin_dsurfedges[0]), SIN_MAX_MAP_SURFEDGES);\n\tsin_numedges = Sin_CopyLump (SIN_LUMP_EDGES, sin_dedges, sizeof(sin_dedge_t), SIN_MAX_MAP_EDGES);\n\tsin_numbrushes = Sin_CopyLump (SIN_LUMP_BRUSHES, sin_dbrushes, sizeof(sin_dbrush_t), SIN_MAX_MAP_BRUSHES);\n\tsin_numbrushsides = Sin_CopyLump (SIN_LUMP_BRUSHSIDES, sin_dbrushsides, sizeof(sin_dbrushside_t), SIN_MAX_MAP_BRUSHSIDES);\n\tsin_numareas = Sin_CopyLump (SIN_LUMP_AREAS, sin_dareas, sizeof(sin_darea_t), SIN_MAX_MAP_AREAS);\n\tsin_numareaportals = Sin_CopyLump (SIN_LUMP_AREAPORTALS, sin_dareaportals, sizeof(sin_dareaportal_t), SIN_MAX_MAP_AREAPORTALS);\n\tsin_numlightinfo = Sin_CopyLump (SIN_LUMP_LIGHTINFO, sin_lightinfo, sizeof(sin_lightvalue_t), SIN_MAX_MAP_LIGHTINFO);\n\n\tsin_visdatasize = Sin_CopyLump (SIN_LUMP_VISIBILITY, sin_dvisdata, 1, SIN_MAX_MAP_VISIBILITY);\n\tsin_lightdatasize = Sin_CopyLump (SIN_LUMP_LIGHTING, sin_dlightdata, 1, SIN_MAX_MAP_LIGHTING);\n\tsin_entdatasize = Sin_CopyLump (SIN_LUMP_ENTITIES, sin_dentdata, 1, SIN_MAX_MAP_ENTSTRING);\n\n\tSin_CopyLump (SIN_LUMP_POP, sin_dpop, 1, sizeof(sin_dpop));\n#else\n\tsin_nummodels = Sin_CopyLump (SIN_LUMP_MODELS, sin_dmodels, sizeof(sin_dmodel_t));\n\tsin_numvertexes = Sin_CopyLump (SIN_LUMP_VERTEXES, sin_dvertexes, sizeof(sin_dvertex_t));\n\tsin_numplanes = Sin_CopyLump (SIN_LUMP_PLANES, sin_dplanes, sizeof(sin_dplane_t));\n\tsin_numleafs = Sin_CopyLump (SIN_LUMP_LEAFS, sin_dleafs, sizeof(sin_dleaf_t));\n\tsin_numnodes = Sin_CopyLump (SIN_LUMP_NODES, sin_dnodes, sizeof(sin_dnode_t));\n\tsin_numtexinfo = Sin_CopyLump (SIN_LUMP_TEXINFO, sin_texinfo, sizeof(sin_texinfo_t));\n\tsin_numfaces = Sin_CopyLump (SIN_LUMP_FACES, sin_dfaces, sizeof(sin_dface_t));\n\tsin_numleaffaces = Sin_CopyLump (SIN_LUMP_LEAFFACES, sin_dleaffaces, sizeof(sin_dleaffaces[0]));\n\tsin_numleafbrushes = Sin_CopyLump (SIN_LUMP_LEAFBRUSHES, sin_dleafbrushes, sizeof(sin_dleafbrushes[0]));\n\tsin_numsurfedges = Sin_CopyLump (SIN_LUMP_SURFEDGES, sin_dsurfedges, sizeof(sin_dsurfedges[0]));\n\tsin_numedges = Sin_CopyLump (SIN_LUMP_EDGES, sin_dedges, sizeof(sin_dedge_t));\n\tsin_numbrushes = Sin_CopyLump (SIN_LUMP_BRUSHES, sin_dbrushes, sizeof(sin_dbrush_t));\n\tsin_numbrushsides = Sin_CopyLump (SIN_LUMP_BRUSHSIDES, sin_dbrushsides, sizeof(sin_dbrushside_t));\n\tsin_numareas = Sin_CopyLump (SIN_LUMP_AREAS, sin_dareas, sizeof(sin_darea_t));\n\tsin_numareaportals = Sin_CopyLump (SIN_LUMP_AREAPORTALS, sin_dareaportals, sizeof(sin_dareaportal_t));\n\n\tsin_visdatasize = Sin_CopyLump (SIN_LUMP_VISIBILITY, sin_dvisdata, 1);\n\tsin_lightdatasize = Sin_CopyLump (SIN_LUMP_LIGHTING, sin_dlightdata, 1);\n\tsin_entdatasize = Sin_CopyLump (SIN_LUMP_ENTITIES, sin_dentdata, 1);\n\n\tSin_CopyLump (SIN_LUMP_POP, sin_dpop, 1);\n#endif\n\n\tFreeMemory(header);\t\t// everything has been copied out\n\t\t\n//\n// swap everything\n//\t\n\tSin_SwapBSPFile (false);\n} //end of the function Sin_LoadBSPFile\n\n/*\n=============\nSin_LoadBSPFilesTexinfo\n\nOnly loads the sin_texinfo lump, so qdata can scan for textures\n=============\n*/\nvoid\tSin_LoadBSPFileTexinfo (char *filename)\n{\n\tint\t\t\ti;\n\tFILE\t\t*f;\n\tint\t\tlength, ofs;\n\n\theader = GetMemory(sizeof(sin_dheader_t));\n\n\tf = fopen (filename, \"rb\");\n\tfread (header, sizeof(sin_dheader_t), 1, f);\n\n// swap the header\n\tfor (i=0 ; i< sizeof(sin_dheader_t)/4 ; i++)\n\t\t((int *)header)[i] = LittleLong ( ((int *)header)[i]);\n\n\tif (header->ident != SIN_BSPHEADER && header->ident != SINGAME_BSPHEADER)\n\t\tError (\"%s is not a IBSP file\", filename);\n\tif (header->version != SIN_BSPVERSION && header->version != SINGAME_BSPVERSION)\n\t\tError (\"%s is version %i, not %i\", filename, header->version, SIN_BSPVERSION);\n\n\n\tlength = header->lumps[SIN_LUMP_TEXINFO].filelen;\n\tofs = header->lumps[SIN_LUMP_TEXINFO].fileofs;\n\n\tfseek (f, ofs, SEEK_SET);\n\tfread (sin_texinfo, length, 1, f);\n\tfclose (f);\n\n\tsin_numtexinfo = length / sizeof(sin_texinfo_t);\n\n\tFreeMemory(header);\t\t// everything has been copied out\n\t\t\n\tSin_SwapBSPFile (false);\n} //end of the function Sin_LoadBSPFilesTexinfo\n\n\n//============================================================================\n\nFILE\t\t*wadfile;\nsin_dheader_t\toutheader;\n\n#ifdef SIN\nvoid Sin_AddLump (int lumpnum, void *data, int len, int size, int maxsize)\n{\n\tsin_lump_t *lump;\n\tint totallength;\n\n\ttotallength = len*size;\n\n\tif (len > maxsize)\n\t\tError (\"Sin_WriteBSPFile: exceeded max size for lump %d size %d > maxsize %d\\n\", lumpnum, len, maxsize );\n\n\tlump = &header->lumps[lumpnum];\n\t\n\tlump->fileofs = LittleLong( ftell(wadfile) );\n\tlump->filelen = LittleLong(totallength);\n\tSafeWrite (wadfile, data, (totallength+3)&~3);\n}\n#else\nvoid Sin_AddLump (int lumpnum, void *data, int len)\n{\n\tsin_lump_t *lump;\n\n\tlump = &header->lumps[lumpnum];\n\t\n\tlump->fileofs = LittleLong( ftell(wadfile) );\n\tlump->filelen = LittleLong(len);\n\tSafeWrite (wadfile, data, (len+3)&~3);\n}\n#endif\n/*\n=============\nSin_WriteBSPFile\n\nSwaps the bsp file in place, so it should not be referenced again\n=============\n*/\nvoid\tSin_WriteBSPFile (char *filename)\n{\t\t\n\theader = &outheader;\n\tmemset (header, 0, sizeof(sin_dheader_t));\n\t\n\tSin_SwapBSPFile (true);\n\n\theader->ident = LittleLong (SIN_BSPHEADER);\n\theader->version = LittleLong (SIN_BSPVERSION);\n\t\n\twadfile = SafeOpenWrite (filename);\n\tSafeWrite (wadfile, header, sizeof(sin_dheader_t));\t// overwritten later\n\n#ifdef SIN\n\tSin_AddLump (SIN_LUMP_PLANES, sin_dplanes, sin_numplanes, sizeof(sin_dplane_t), SIN_MAX_MAP_PLANES);\n\tSin_AddLump (SIN_LUMP_LEAFS, sin_dleafs, sin_numleafs, sizeof(sin_dleaf_t), SIN_MAX_MAP_LEAFS);\n\tSin_AddLump (SIN_LUMP_VERTEXES, sin_dvertexes, sin_numvertexes, sizeof(sin_dvertex_t), SIN_MAX_MAP_VERTS);\n\tSin_AddLump (SIN_LUMP_NODES, sin_dnodes, sin_numnodes, sizeof(sin_dnode_t), SIN_MAX_MAP_NODES);\n\tSin_AddLump (SIN_LUMP_TEXINFO, sin_texinfo, sin_numtexinfo, sizeof(sin_texinfo_t), SIN_MAX_MAP_TEXINFO);\n\tSin_AddLump (SIN_LUMP_FACES, sin_dfaces, sin_numfaces, sizeof(sin_dface_t), SIN_MAX_MAP_FACES);\n\tSin_AddLump (SIN_LUMP_BRUSHES, sin_dbrushes, sin_numbrushes, sizeof(sin_dbrush_t), SIN_MAX_MAP_BRUSHES);\n\tSin_AddLump (SIN_LUMP_BRUSHSIDES, sin_dbrushsides, sin_numbrushsides, sizeof(sin_dbrushside_t), SIN_MAX_MAP_BRUSHSIDES);\n\tSin_AddLump (SIN_LUMP_LEAFFACES, sin_dleaffaces, sin_numleaffaces, sizeof(sin_dleaffaces[0]), SIN_MAX_MAP_LEAFFACES);\n\tSin_AddLump (SIN_LUMP_LEAFBRUSHES, sin_dleafbrushes, sin_numleafbrushes, sizeof(sin_dleafbrushes[0]), SIN_MAX_MAP_LEAFBRUSHES);\n\tSin_AddLump (SIN_LUMP_SURFEDGES, sin_dsurfedges, sin_numsurfedges, sizeof(sin_dsurfedges[0]), SIN_MAX_MAP_SURFEDGES);\n\tSin_AddLump (SIN_LUMP_EDGES, sin_dedges, sin_numedges, sizeof(sin_dedge_t), SIN_MAX_MAP_EDGES);\n\tSin_AddLump (SIN_LUMP_MODELS, sin_dmodels, sin_nummodels, sizeof(sin_dmodel_t), SIN_MAX_MAP_MODELS);\n\tSin_AddLump (SIN_LUMP_AREAS, sin_dareas, sin_numareas, sizeof(sin_darea_t), SIN_MAX_MAP_AREAS);\n\tSin_AddLump (SIN_LUMP_AREAPORTALS, sin_dareaportals, sin_numareaportals, sizeof(sin_dareaportal_t), SIN_MAX_MAP_AREAPORTALS);\n\tSin_AddLump (SIN_LUMP_LIGHTINFO, sin_lightinfo, sin_numlightinfo, sizeof(sin_lightvalue_t), SIN_MAX_MAP_LIGHTINFO);\n\n\tSin_AddLump (SIN_LUMP_LIGHTING, sin_dlightdata, sin_lightdatasize, 1, SIN_MAX_MAP_LIGHTING);\n\tSin_AddLump (SIN_LUMP_VISIBILITY, sin_dvisdata, sin_visdatasize, 1, SIN_MAX_MAP_VISIBILITY);\n\tSin_AddLump (SIN_LUMP_ENTITIES, sin_dentdata, sin_entdatasize, 1, SIN_MAX_MAP_ENTSTRING);\n\tSin_AddLump (SIN_LUMP_POP, sin_dpop, sizeof(sin_dpop), 1, sizeof(sin_dpop));\n#else\n\tSin_AddLump (SIN_LUMP_PLANES, sin_dplanes, sin_numplanes*sizeof(sin_dplane_t));\n\tSin_AddLump (SIN_LUMP_LEAFS, sin_dleafs, sin_numleafs*sizeof(sin_dleaf_t));\n\tSin_AddLump (SIN_LUMP_VERTEXES, sin_dvertexes, sin_numvertexes*sizeof(sin_dvertex_t));\n\tSin_AddLump (SIN_LUMP_NODES, sin_dnodes, sin_numnodes*sizeof(sin_dnode_t));\n\tSin_AddLump (SIN_LUMP_TEXINFO, sin_texinfo, sin_numtexinfo*sizeof(sin_texinfo_t));\n\tSin_AddLump (SIN_LUMP_FACES, sin_dfaces, sin_numfaces*sizeof(sin_dface_t));\n\tSin_AddLump (SIN_LUMP_BRUSHES, sin_dbrushes, sin_numbrushes*sizeof(sin_dbrush_t));\n\tSin_AddLump (SIN_LUMP_BRUSHSIDES, sin_dbrushsides, sin_numbrushsides*sizeof(sin_dbrushside_t));\n\tSin_AddLump (SIN_LUMP_LEAFFACES, sin_dleaffaces, sin_numleaffaces*sizeof(sin_dleaffaces[0]));\n\tSin_AddLump (SIN_LUMP_LEAFBRUSHES, sin_dleafbrushes, sin_numleafbrushes*sizeof(sin_dleafbrushes[0]));\n\tSin_AddLump (SIN_LUMP_SURFEDGES, sin_dsurfedges, sin_numsurfedges*sizeof(sin_dsurfedges[0]));\n\tSin_AddLump (SIN_LUMP_EDGES, sin_dedges, sin_numedges*sizeof(sin_dedge_t));\n\tSin_AddLump (SIN_LUMP_MODELS, sin_dmodels, sin_nummodels*sizeof(sin_dmodel_t));\n\tSin_AddLump (SIN_LUMP_AREAS, sin_dareas, sin_numareas*sizeof(sin_darea_t));\n\tSin_AddLump (SIN_LUMP_AREAPORTALS, sin_dareaportals, sin_numareaportals*sizeof(sin_dareaportal_t));\n\n\tSin_AddLump (SIN_LUMP_LIGHTING, sin_dlightdata, sin_lightdatasize);\n\tSin_AddLump (SIN_LUMP_VISIBILITY, sin_dvisdata, sin_visdatasize);\n\tSin_AddLump (SIN_LUMP_ENTITIES, sin_dentdata, sin_entdatasize);\n\tSin_AddLump (SIN_LUMP_POP, sin_dpop, sizeof(sin_dpop));\n#endif\n\t\n\tfseek (wadfile, 0, SEEK_SET);\n\tSafeWrite (wadfile, header, sizeof(sin_dheader_t));\n\tfclose (wadfile);\t\n}\n\n//============================================================================\n\n\n//============================================\n\n/*\n================\nParseEntities\n\nParses the sin_dentdata string into entities\n================\n*/\nvoid Sin_ParseEntities (void)\n{\n\tscript_t *script;\n\n\tnum_entities = 0;\n\tscript = LoadScriptMemory(sin_dentdata, sin_entdatasize, \"*sin bsp file\");\n\tSetScriptFlags(script, SCFL_NOSTRINGWHITESPACES |\n\t\t\t\t\t\t\t\t\tSCFL_NOSTRINGESCAPECHARS);\n\n\twhile(ParseEntity(script))\n\t{\n\t} //end while\n\n\tFreeScript(script);\n} //end of the function Sin_ParseEntities\n\n\n/*\n================\nUnparseEntities\n\nGenerates the sin_dentdata string from all the entities\n================\n*/\nvoid Sin_UnparseEntities (void)\n{\n\tchar\t*buf, *end;\n\tepair_t\t*ep;\n\tchar\tline[2048];\n\tint\t\ti;\n\tchar\tkey[1024], value[1024];\n\n\tbuf = sin_dentdata;\n\tend = buf;\n\t*end = 0;\n\t\n\tfor (i=0 ; i<num_entities ; i++)\n\t{\n\t\tep = entities[i].epairs;\n\t\tif (!ep)\n\t\t\tcontinue;\t// ent got removed\n\t\t\n\t\tstrcat (end,\"{\\n\");\n\t\tend += 2;\n\t\t\t\t\n\t\tfor (ep = entities[i].epairs ; ep ; ep=ep->next)\n\t\t{\n\t\t\tstrcpy (key, ep->key);\n\t\t\tStripTrailing (key);\n\t\t\tstrcpy (value, ep->value);\n\t\t\tStripTrailing (value);\n\t\t\t\t\n\t\t\tsprintf (line, \"\\\"%s\\\" \\\"%s\\\"\\n\", key, value);\n\t\t\tstrcat (end, line);\n\t\t\tend += strlen(line);\n\t\t}\n\t\tstrcat (end,\"}\\n\");\n\t\tend += 2;\n\n\t\tif (end > buf + SIN_MAX_MAP_ENTSTRING)\n\t\t\tError (\"Entity text too long\");\n\t}\n\tsin_entdatasize = end - buf + 1;\n} //end of the function Sin_UnparseEntities\n\n#ifdef SIN\nvoid  FreeValueKeys(entity_t *ent)\n{\n\tepair_t\t*ep,*next;\n\n\tfor (ep=ent->epairs ; ep ; ep=next)\n\t{\n\t\tnext = ep->next;\n\t\tFreeMemory(ep->value);\n\t\tFreeMemory(ep->key);\n\t\tFreeMemory(ep);\n\t}\n\tent->epairs = NULL;\n}\n#endif\n\n/*\n=============\nSin_PrintBSPFileSizes\n\nDumps info about current file\n=============\n*/\nvoid Sin_PrintBSPFileSizes (void)\n{\n\tif (!num_entities)\n\t\tSin_ParseEntities ();\n\n\tLog_Print(\"%6i models       %7i\\n\"\n\t\t,sin_nummodels, (int)(sin_nummodels*sizeof(sin_dmodel_t)));\n\tLog_Print(\"%6i brushes      %7i\\n\"\n\t\t,sin_numbrushes, (int)(sin_numbrushes*sizeof(sin_dbrush_t)));\n\tLog_Print(\"%6i brushsides   %7i\\n\"\n\t\t,sin_numbrushsides, (int)(sin_numbrushsides*sizeof(sin_dbrushside_t)));\n\tLog_Print(\"%6i planes       %7i\\n\"\n\t\t,sin_numplanes, (int)(sin_numplanes*sizeof(sin_dplane_t)));\n\tLog_Print(\"%6i texinfo      %7i\\n\"\n\t\t,sin_numtexinfo, (int)(sin_numtexinfo*sizeof(sin_texinfo_t)));\n#ifdef SIN\n\tLog_Print(\"%6i lightinfo    %7i\\n\"\n\t\t,sin_numlightinfo, (int)(sin_numlightinfo*sizeof(sin_lightvalue_t)));\n#endif\n\tLog_Print(\"%6i entdata      %7i\\n\", num_entities, sin_entdatasize);\n\n\tLog_Print(\"\\n\");\n\n\tLog_Print(\"%6i vertexes     %7i\\n\"\n\t\t,sin_numvertexes, (int)(sin_numvertexes*sizeof(sin_dvertex_t)));\n\tLog_Print(\"%6i nodes        %7i\\n\"\n\t\t,sin_numnodes, (int)(sin_numnodes*sizeof(sin_dnode_t)));\n\tLog_Print(\"%6i faces        %7i\\n\"\n\t\t,sin_numfaces, (int)(sin_numfaces*sizeof(sin_dface_t)));\n\tLog_Print(\"%6i leafs        %7i\\n\"\n\t\t,sin_numleafs, (int)(sin_numleafs*sizeof(sin_dleaf_t)));\n\tLog_Print(\"%6i leaffaces    %7i\\n\"\n\t\t,sin_numleaffaces, (int)(sin_numleaffaces*sizeof(sin_dleaffaces[0])));\n\tLog_Print(\"%6i leafbrushes  %7i\\n\"\n\t\t,sin_numleafbrushes, (int)(sin_numleafbrushes*sizeof(sin_dleafbrushes[0])));\n\tLog_Print(\"%6i surfedges    %7i\\n\"\n\t\t,sin_numsurfedges, (int)(sin_numsurfedges*sizeof(sin_dsurfedges[0])));\n\tLog_Print(\"%6i edges        %7i\\n\"\n\t\t,sin_numedges, (int)(sin_numedges*sizeof(sin_dedge_t)));\n\tLog_Print(\"       lightdata    %7i\\n\", sin_lightdatasize);\n\tLog_Print(\"       visdata      %7i\\n\", sin_visdatasize);\n}\n"
  },
  {
    "path": "code/bspc/l_bsp_sin.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"sinfiles.h\"\n\n#define SINGAME_BSPHEADER\t\t(('P'<<24)+('S'<<16)+('B'<<8)+'R')\t//RBSP\n#define SINGAME_BSPVERSION\t\t1\n\n#define SIN_BSPHEADER\t\t\t(('P'<<24)+('S'<<16)+('B'<<8)+'I')\t//IBSP\n#define SIN_BSPVERSION\t41\n\n\nextern\tint\t\t\t\t\tsin_nummodels;\nextern\tsin_dmodel_t\t\t*sin_dmodels;//[MAX_MAP_MODELS];\n\nextern\tint\t\t\t\t\tsin_visdatasize;\nextern\tbyte\t\t\t\t*sin_dvisdata;//[MAX_MAP_VISIBILITY];\nextern\tsin_dvis_t\t\t\t*sin_dvis;// = (dvis_t *)sin_sin_dvisdata;\n\nextern\tint\t\t\t\t\tsin_lightdatasize;\nextern\tbyte\t\t\t\t*sin_dlightdata;//[MAX_MAP_LIGHTING];\n\nextern\tint\t\t\t\t\tsin_entdatasize;\nextern\tchar\t\t\t\t*sin_dentdata;//[MAX_MAP_ENTSTRING];\n\nextern\tint\t\t\t\t\tsin_numleafs;\nextern\tsin_dleaf_t\t\t\t*sin_dleafs;//[MAX_MAP_LEAFS];\n\nextern\tint\t\t\t\t\tsin_numplanes;\nextern\tsin_dplane_t\t\t*sin_dplanes;//[MAX_MAP_PLANES];\n\nextern\tint\t\t\t\t\tsin_numvertexes;\nextern\tsin_dvertex_t\t\t*sin_dvertexes;//[MAX_MAP_VERTS];\n\nextern\tint\t\t\t\t\tsin_numnodes;\nextern\tsin_dnode_t\t\t\t*sin_dnodes;//[MAX_MAP_NODES];\n\nextern\tint\t\t\t\t\tsin_numtexinfo;\nextern\tsin_texinfo_t\t\t*sin_texinfo;//[MAX_MAP_sin_texinfo];\n\nextern\tint\t\t\t\t\tsin_numfaces;\nextern\tsin_dface_t\t\t\t*sin_dfaces;//[MAX_MAP_FACES];\n\nextern\tint\t\t\t\t\tsin_numedges;\nextern\tsin_dedge_t\t\t\t*sin_dedges;//[MAX_MAP_EDGES];\n\nextern\tint\t\t\t\t\tsin_numleaffaces;\nextern\tunsigned short\t\t*sin_dleaffaces;//[MAX_MAP_LEAFFACES];\n\nextern\tint\t\t\t\t\tsin_numleafbrushes;\nextern\tunsigned short\t\t*sin_dleafbrushes;//[MAX_MAP_LEAFBRUSHES];\n\nextern\tint\t\t\t\t\tsin_numsurfedges;\nextern\tint\t\t\t\t\t*sin_dsurfedges;//[MAX_MAP_SURFEDGES];\n\nextern\tint\t\t\t\t\tsin_numbrushes;\nextern\tsin_dbrush_t\t\t*sin_dbrushes;//[MAX_MAP_BRUSHES];\n\nextern\tint\t\t\t\t\tsin_numbrushsides;\nextern\tsin_dbrushside_t\t*sin_dbrushsides;//[MAX_MAP_BRUSHSIDES];\n\nextern\tint\t\t\t\t\tsin_numareas;\nextern\tsin_darea_t\t\t\t*sin_dareas;//[MAX_MAP_AREAS];\n\nextern\tint\t\t\t\t\tsin_numareaportals;\nextern\tsin_dareaportal_t\t*sin_dareaportals;//[MAX_MAP_AREAPORTALS];\n\nextern\tint\t\t\t\t\tsin_numlightinfo;\nextern\tsin_lightvalue_t\t*sin_lightinfo;//[MAX_MAP_LIGHTINFO];\n\nextern\tbyte\t\t\t\tsin_dpop[256];\n\nextern\tchar\t\t\t\tsin_dbrushsidetextured[SIN_MAX_MAP_BRUSHSIDES];\n\nvoid Sin_AllocMaxBSP(void);\nvoid Sin_FreeMaxBSP(void);\n\nvoid Sin_DecompressVis(byte *in, byte *decompressed);\nint Sin_CompressVis(byte *vis, byte *dest);\n\nvoid Sin_LoadBSPFile (char *filename, int offset, int length);\nvoid Sin_LoadBSPFileTexinfo (char *filename);\t// just for qdata\nvoid Sin_WriteBSPFile (char *filename);\nvoid Sin_PrintBSPFileSizes (void);\nvoid Sin_ParseEntities(void);\nvoid Sin_UnparseEntities(void);\n\n"
  },
  {
    "path": "code/bspc/l_cmd.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n// cmdlib.c\n\n#include \"l_cmd.h\"\n#include \"l_log.h\"\n#include \"l_mem.h\"\n#include <sys/types.h>\n#include <sys/stat.h>\n\n#ifndef SIN\n#define SIN\n#endif //SIN\n\n#if defined(WIN32) || defined(_WIN32)\n#include <direct.h>\n#else\n#include <unistd.h>\n#endif\n\n#ifdef NeXT\n#include <libc.h>\n#endif\n\n#define\tBASEDIRNAME\t\"quake2\"\n#define PATHSEPERATOR   '/'\n\n// set these before calling CheckParm\nint myargc;\nchar **myargv;\n\nchar\t\tcom_token[1024];\nqboolean\tcom_eof;\n\nqboolean\t\tarchive;\nchar\t\t\tarchivedir[1024];\n\n\n/*\n===================\nExpandWildcards\n\nMimic unix command line expansion\n===================\n*/\n#define\tMAX_EX_ARGC\t1024\nint\t\tex_argc;\nchar\t*ex_argv[MAX_EX_ARGC];\n#ifdef _WIN32\n#include \"io.h\"\nvoid ExpandWildcards (int *argc, char ***argv)\n{\n\tstruct _finddata_t fileinfo;\n\tint\t\thandle;\n\tint\t\ti;\n\tchar\tfilename[1024];\n\tchar\tfilebase[1024];\n\tchar\t*path;\n\n\tex_argc = 0;\n\tfor (i=0 ; i<*argc ; i++)\n\t{\n\t\tpath = (*argv)[i];\n\t\tif ( path[0] == '-'\n\t\t\t|| ( !strstr(path, \"*\") && !strstr(path, \"?\") ) )\n\t\t{\n\t\t\tex_argv[ex_argc++] = path;\n\t\t\tcontinue;\n\t\t}\n\n\t\thandle = _findfirst (path, &fileinfo);\n\t\tif (handle == -1)\n\t\t\treturn;\n\n\t\tExtractFilePath (path, filebase);\n\n\t\tdo\n\t\t{\n\t\t\tsprintf (filename, \"%s%s\", filebase, fileinfo.name);\n\t\t\tex_argv[ex_argc++] = copystring (filename);\n\t\t} while (_findnext( handle, &fileinfo ) != -1);\n\n\t\t_findclose (handle);\n\t}\n\n\t*argc = ex_argc;\n\t*argv = ex_argv;\n}\n#else\nvoid ExpandWildcards (int *argc, char ***argv)\n{\n}\n#endif\n\n#ifdef WINBSPC\n\n#include <windows.h>\n\nHWND program_hwnd;\n\nvoid SetProgramHandle(HWND hwnd)\n{\n\tprogram_hwnd = hwnd;\n} //end of the function SetProgramHandle\n\n/*\n=================\nError\n\nFor abnormal program terminations in windowed apps\n=================\n*/\nvoid Error (char *error, ...)\n{\n\tva_list argptr;\n\tchar text[1024];\n\tchar text2[1024];\n\tint err;\n\n\terr = GetLastError ();\n\n\tva_start(argptr, error);\n\tvsprintf(text, error, argptr);\n\tva_end(argptr);\n\n\tsprintf(text2, \"%s\\nGetLastError() = %i\", text, err);\n   MessageBox(program_hwnd, text2, \"Error\", 0 /* MB_OK */ );\n\n\tLog_Write(text);\n\tLog_Close();\n\n\texit(1);\n} //end of the function Error\n\nvoid Warning(char *szFormat, ...)\n{\n\tchar szBuffer[256];\n\tva_list argptr;\n\n\tva_start (argptr, szFormat);\n\tvsprintf(szBuffer, szFormat, argptr);\n\tva_end (argptr);\n\n\tMessageBox(program_hwnd, szBuffer, \"Warning\", MB_OK);\n\n\tLog_Write(szBuffer);\n} //end of the function Warning\n\n\n#else\n/*\n=================\nError\n\nFor abnormal program terminations in console apps\n=================\n*/\nvoid Error (char *error, ...)\n{\n\tva_list argptr;\n\tchar\ttext[1024];\n\n\tva_start(argptr, error);\n\tvsprintf(text, error, argptr);\n\tva_end(argptr);\n\tprintf(\"ERROR: %s\\n\", text);\n\n\tLog_Write(text);\n\tLog_Close();\n\n\texit (1);\n} //end of the function Error\n\nvoid Warning(char *warning, ...)\n{\n\tva_list argptr;\n\tchar text[1024];\n\n\tva_start(argptr, warning);\n\tvsprintf(text, warning, argptr);\n\tva_end(argptr);\n\tprintf(\"WARNING: %s\\n\", text);\n\n\tLog_Write(text);\n} //end of the function Warning\n\n#endif\n\n//only printf if in verbose mode\nqboolean verbose = true;\n\nvoid qprintf(char *format, ...)\n{\n\tva_list argptr;\n#ifdef WINBSPC\n\tchar buf[2048];\n#endif //WINBSPC\n\n\tif (!verbose)\n\t\treturn;\n\n\tva_start(argptr,format);\n#ifdef WINBSPC\n\tvsprintf(buf, format, argptr);\n\tWinBSPCPrint(buf);\n#else\n\tvprintf(format, argptr);\n#endif //WINBSPC\n\tva_end(argptr);\n} //end of the function qprintf\n\nvoid Com_Error(int level, char *error, ...)\n{\n\tva_list argptr;\n\tchar text[1024];\n\n\tva_start(argptr, error);\n\tvsprintf(text, error, argptr);\n\tva_end(argptr);\n\tError(text);\n} //end of the funcion Com_Error\n\nvoid Com_Printf( const char *fmt, ... )\n{\n\tva_list argptr;\n\tchar text[1024];\n\n\tva_start(argptr, fmt);\n\tvsprintf(text, fmt, argptr);\n\tva_end(argptr);\n\tLog_Print(text);\n} //end of the funcion Com_Printf\n\n/*\n\nqdir will hold the path up to the quake directory, including the slash\n\n  f:\\quake\\\n  /raid/quake/\n\ngamedir will hold qdir + the game directory (id1, id2, etc)\n\n  */\n\nchar\t\tqdir[1024];\nchar\t\tgamedir[1024];\n\nvoid SetQdirFromPath (char *path)\n{\n\tchar\ttemp[1024];\n\tchar\t*c;\n\tint\t\tlen;\n\n\tif (!(path[0] == '/' || path[0] == '\\\\' || path[1] == ':'))\n\t{\t// path is partial\n\t\tQ_getwd (temp);\n\t\tstrcat (temp, path);\n\t\tpath = temp;\n\t}\n\n\t// search for \"quake2\" in path\n\n\tlen = strlen(BASEDIRNAME);\n\tfor (c=path+strlen(path)-1 ; c != path ; c--)\n\t\tif (!Q_strncasecmp (c, BASEDIRNAME, len))\n\t\t{\n\t\t\tstrncpy (qdir, path, c+len+1-path);\n\t\t\tqprintf (\"qdir: %s\\n\", qdir);\n\t\t\tc += len+1;\n\t\t\twhile (*c)\n\t\t\t{\n\t\t\t\tif (*c == '/' || *c == '\\\\')\n\t\t\t\t{\n\t\t\t\t\tstrncpy (gamedir, path, c+1-path);\n\t\t\t\t\tqprintf (\"gamedir: %s\\n\", gamedir);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tc++;\n\t\t\t}\n\t\t\tError (\"No gamedir in %s\", path);\n\t\t\treturn;\n\t\t}\n\tError (\"SetQdirFromPath: no '%s' in %s\", BASEDIRNAME, path);\n}\n\nchar *ExpandArg (char *path)\n{\n\tstatic char full[1024];\n\n\tif (path[0] != '/' && path[0] != '\\\\' && path[1] != ':')\n\t{\n\t\tQ_getwd (full);\n\t\tstrcat (full, path);\n\t}\n\telse\n\t\tstrcpy (full, path);\n\treturn full;\n}\n\nchar *ExpandPath (char *path)\n{\n\tstatic char full[1024];\n\tif (!qdir)\n\t\tError (\"ExpandPath called without qdir set\");\n\tif (path[0] == '/' || path[0] == '\\\\' || path[1] == ':')\n\t\treturn path;\n\tsprintf (full, \"%s%s\", qdir, path);\n\treturn full;\n}\n\nchar *ExpandPathAndArchive (char *path)\n{\n\tchar\t*expanded;\n\tchar\tarchivename[1024];\n\n\texpanded = ExpandPath (path);\n\n\tif (archive)\n\t{\n\t\tsprintf (archivename, \"%s/%s\", archivedir, path);\n\t\tQCopyFile (expanded, archivename);\n\t}\n\treturn expanded;\n}\n\n\nchar *copystring(char *s)\n{\n\tchar\t*b;\n\tb = GetMemory(strlen(s)+1);\n\tstrcpy (b, s);\n\treturn b;\n}\n\n\n\n/*\n================\nI_FloatTime\n================\n*/\ndouble I_FloatTime (void)\n{\n\ttime_t\tt;\n\t\n\ttime (&t);\n\t\n\treturn t;\n#if 0\n// more precise, less portable\n\tstruct timeval tp;\n\tstruct timezone tzp;\n\tstatic int\t\tsecbase;\n\n\tgettimeofday(&tp, &tzp);\n\t\n\tif (!secbase)\n\t{\n\t\tsecbase = tp.tv_sec;\n\t\treturn tp.tv_usec/1000000.0;\n\t}\n\t\n\treturn (tp.tv_sec - secbase) + tp.tv_usec/1000000.0;\n#endif\n}\n\nvoid Q_getwd (char *out)\n{\n#if defined(WIN32) || defined(_WIN32)\n   getcwd (out, 256);\n   strcat (out, \"\\\\\");\n#else\n   getwd(out);\n   strcat(out, \"/\");\n#endif\n}\n\n\nvoid Q_mkdir (char *path)\n{\n#ifdef WIN32\n\tif (_mkdir (path) != -1)\n\t\treturn;\n#else\n\tif (mkdir (path, 0777) != -1)\n\t\treturn;\n#endif\n\tif (errno != EEXIST)\n\t\tError (\"mkdir %s: %s\",path, strerror(errno));\n}\n\n/*\n============\nFileTime\n\nreturns -1 if not present\n============\n*/\nint\tFileTime (char *path)\n{\n\tstruct\tstat\tbuf;\n\t\n\tif (stat (path,&buf) == -1)\n\t\treturn -1;\n\t\n\treturn buf.st_mtime;\n}\n\n\n\n/*\n==============\nCOM_Parse\n\nParse a token out of a string\n==============\n*/\nchar *COM_Parse (char *data)\n{\n\tint\t\tc;\n\tint\t\tlen;\n\t\n\tlen = 0;\n\tcom_token[0] = 0;\n\t\n\tif (!data)\n\t\treturn NULL;\n\t\t\n// skip whitespace\nskipwhite:\n\twhile ( (c = *data) <= ' ')\n\t{\n\t\tif (c == 0)\n\t\t{\n\t\t\tcom_eof = true;\n\t\t\treturn NULL;\t\t\t// end of file;\n\t\t}\n\t\tdata++;\n\t}\n\t\n// skip // comments\n\tif (c=='/' && data[1] == '/')\n\t{\n\t\twhile (*data && *data != '\\n')\n\t\t\tdata++;\n\t\tgoto skipwhite;\n\t}\n\t\n\n// handle quoted strings specially\n\tif (c == '\\\"')\n\t{\n\t\tdata++;\n\t\tdo\n\t\t{\n\t\t\tc = *data++;\n\t\t\tif (c=='\\\"')\n\t\t\t{\n\t\t\t\tcom_token[len] = 0;\n\t\t\t\treturn data;\n\t\t\t}\n\t\t\tcom_token[len] = c;\n\t\t\tlen++;\n\t\t} while (1);\n\t}\n\n// parse single characters\n\tif (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\\'' || c==':')\n\t{\n\t\tcom_token[len] = c;\n\t\tlen++;\n\t\tcom_token[len] = 0;\n\t\treturn data+1;\n\t}\n\n// parse a regular word\n\tdo\n\t{\n\t\tcom_token[len] = c;\n\t\tdata++;\n\t\tlen++;\n\t\tc = *data;\n\tif (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\\'' || c==':')\n\t\t\tbreak;\n\t} while (c>32);\n\t\n\tcom_token[len] = 0;\n\treturn data;\n}\n\n\nint Q_strncasecmp (char *s1, char *s2, int n)\n{\n\tint\t\tc1, c2;\n\t\n\tdo\n\t{\n\t\tc1 = *s1++;\n\t\tc2 = *s2++;\n\n\t\tif (!n--)\n\t\t\treturn 0;\t\t// strings are equal until end point\n\t\t\n\t\tif (c1 != c2)\n\t\t{\n\t\t\tif (c1 >= 'a' && c1 <= 'z')\n\t\t\t\tc1 -= ('a' - 'A');\n\t\t\tif (c2 >= 'a' && c2 <= 'z')\n\t\t\t\tc2 -= ('a' - 'A');\n\t\t\tif (c1 != c2)\n\t\t\t\treturn -1;\t\t// strings not equal\n\t\t}\n\t} while (c1);\n\t\n\treturn 0;\t\t// strings are equal\n}\n\nint Q_strcasecmp (char *s1, char *s2)\n{\n\treturn Q_strncasecmp (s1, s2, 99999);\n}\n\nint Q_stricmp (char *s1, char *s2)\n{\n\treturn Q_strncasecmp (s1, s2, 99999);\n}\n\nvoid Q_strncpyz( char *dest, const char *src, int destsize ) {\n\tstrncpy( dest, src, destsize-1 );\n    dest[destsize-1] = 0;\n}\n\nchar *strupr (char *start)\n{\n\tchar\t*in;\n\tin = start;\n\twhile (*in)\n\t{\n\t\t*in = toupper(*in);\n\t\tin++;\n\t}\n\treturn start;\n}\n\nchar *strlower (char *start)\n{\n\tchar\t*in;\n\tin = start;\n\twhile (*in)\n\t{\n\t\t*in = tolower(*in); \n\t\tin++;\n\t}\n\treturn start;\n}\n\n\n/*\n=============================================================================\n\n\t\t\t\t\t\tMISC FUNCTIONS\n\n=============================================================================\n*/\n\n\n/*\n=================\nCheckParm\n\nChecks for the given parameter in the program's command line arguments\nReturns the argument number (1 to argc-1) or 0 if not present\n=================\n*/\nint CheckParm (char *check)\n{\n\tint             i;\n\n\tfor (i = 1;i<myargc;i++)\n\t{\n\t\tif ( !Q_strcasecmp(check, myargv[i]) )\n\t\t\treturn i;\n\t}\n\n\treturn 0;\n}\n\n\n\n/*\n================\nQ_filelength\n================\n*/\nint Q_filelength (FILE *f)\n{\n\tint\t\tpos;\n\tint\t\tend;\n\n\tpos = ftell (f);\n\tfseek (f, 0, SEEK_END);\n\tend = ftell (f);\n\tfseek (f, pos, SEEK_SET);\n\n\treturn end;\n}\n\n\nFILE *SafeOpenWrite (char *filename)\n{\n\tFILE\t*f;\n\n\tf = fopen(filename, \"wb\");\n\n\tif (!f)\n\t\tError (\"Error opening %s: %s\",filename,strerror(errno));\n\n\treturn f;\n}\n\nFILE *SafeOpenRead (char *filename)\n{\n\tFILE\t*f;\n\n\tf = fopen(filename, \"rb\");\n\n\tif (!f)\n\t\tError (\"Error opening %s: %s\",filename,strerror(errno));\n\n\treturn f;\n}\n\n\nvoid SafeRead (FILE *f, void *buffer, int count)\n{\n\tif ( fread (buffer, 1, count, f) != (size_t)count)\n\t\tError (\"File read failure\");\n}\n\n\nvoid SafeWrite (FILE *f, void *buffer, int count)\n{\n\tif (fwrite (buffer, 1, count, f) != (size_t)count)\n\t\tError (\"File write failure\");\n}\n\n\n/*\n==============\nFileExists\n==============\n*/\nqboolean\tFileExists (char *filename)\n{\n\tFILE\t*f;\n\n\tf = fopen (filename, \"r\");\n\tif (!f)\n\t\treturn false;\n\tfclose (f);\n\treturn true;\n}\n\n/*\n==============\nLoadFile\n==============\n*/\nint    LoadFile (char *filename, void **bufferptr, int offset, int length)\n{\n\tFILE\t*f;\n\tvoid    *buffer;\n\n\tf = SafeOpenRead(filename);\n\tfseek(f, offset, SEEK_SET);\n\tif (!length) length = Q_filelength(f);\n\tbuffer = GetMemory(length+1);\n\t((char *)buffer)[length] = 0;\n\tSafeRead(f, buffer, length);\n\tfclose(f);\n\n\t*bufferptr = buffer;\n\treturn length;\n}\n\n\n/*\n==============\nTryLoadFile\n\nAllows failure\n==============\n*/\nint    TryLoadFile (char *filename, void **bufferptr)\n{\n\tFILE\t*f;\n\tint    length;\n\tvoid    *buffer;\n\n\t*bufferptr = NULL;\n\n\tf = fopen (filename, \"rb\");\n\tif (!f)\n\t\treturn -1;\n\tlength = Q_filelength (f);\n\tbuffer = GetMemory(length+1);\n\t((char *)buffer)[length] = 0;\n\tSafeRead (f, buffer, length);\n\tfclose (f);\n\n\t*bufferptr = buffer;\n\treturn length;\n}\n\n\n/*\n==============\nSaveFile\n==============\n*/\nvoid    SaveFile (char *filename, void *buffer, int count)\n{\n\tFILE\t*f;\n\n\tf = SafeOpenWrite (filename);\n\tSafeWrite (f, buffer, count);\n\tfclose (f);\n}\n\n\n\nvoid DefaultExtension (char *path, char *extension)\n{\n\tchar    *src;\n//\n// if path doesnt have a .EXT, append extension\n// (extension should include the .)\n//\n\tsrc = path + strlen(path) - 1;\n\n\twhile (*src != PATHSEPERATOR && src != path)\n\t{\n\t\tif (*src == '.')\n\t\t\treturn;                 // it has an extension\n\t\tsrc--;\n\t}\n\n\tstrcat (path, extension);\n}\n\n\nvoid DefaultPath (char *path, char *basepath)\n{\n\tchar    temp[128];\n\n\tif (path[0] == PATHSEPERATOR)\n\t\treturn;                   // absolute path location\n\tstrcpy (temp,path);\n\tstrcpy (path,basepath);\n\tstrcat (path,temp);\n}\n\n\nvoid    StripFilename (char *path)\n{\n\tint             length;\n\n\tlength = strlen(path)-1;\n\twhile (length > 0 && path[length] != PATHSEPERATOR)\n\t\tlength--;\n\tpath[length] = 0;\n}\n\nvoid    StripExtension (char *path)\n{\n\tint             length;\n\n\tlength = strlen(path)-1;\n\twhile (length > 0 && path[length] != '.')\n\t{\n\t\tlength--;\n\t\tif (path[length] == '/')\n\t\t\treturn;\t\t// no extension\n\t}\n\tif (length)\n\t\tpath[length] = 0;\n}\n\n\n/*\n====================\nExtract file parts\n====================\n*/\n// FIXME: should include the slash, otherwise\n// backing to an empty path will be wrong when appending a slash\nvoid ExtractFilePath (char *path, char *dest)\n{\n\tchar    *src;\n\n\tsrc = path + strlen(path) - 1;\n\n//\n// back up until a \\ or the start\n//\n\twhile (src != path && *(src-1) != '\\\\' && *(src-1) != '/')\n\t\tsrc--;\n\n\tmemcpy (dest, path, src-path);\n\tdest[src-path] = 0;\n}\n\nvoid ExtractFileBase (char *path, char *dest)\n{\n\tchar    *src;\n\n\tsrc = path + strlen(path) - 1;\n\n//\n// back up until a \\ or the start\n//\n\twhile (src != path && *(src-1) != '\\\\' && *(src-1) != '/')\n\t\tsrc--;\n\n\twhile (*src && *src != '.')\n\t{\n\t\t*dest++ = *src++;\n\t}\n\t*dest = 0;\n}\n\nvoid ExtractFileExtension (char *path, char *dest)\n{\n\tchar    *src;\n\n\tsrc = path + strlen(path) - 1;\n\n//\n// back up until a . or the start\n//\n\twhile (src != path && *(src-1) != '.')\n\t\tsrc--;\n\tif (src == path)\n\t{\n\t\t*dest = 0;\t// no extension\n\t\treturn;\n\t}\n\n\tstrcpy (dest,src);\n}\n\n\n/*\n==============\nParseNum / ParseHex\n==============\n*/\nint ParseHex (char *hex)\n{\n\tchar    *str;\n\tint    num;\n\n\tnum = 0;\n\tstr = hex;\n\n\twhile (*str)\n\t{\n\t\tnum <<= 4;\n\t\tif (*str >= '0' && *str <= '9')\n\t\t\tnum += *str-'0';\n\t\telse if (*str >= 'a' && *str <= 'f')\n\t\t\tnum += 10 + *str-'a';\n\t\telse if (*str >= 'A' && *str <= 'F')\n\t\t\tnum += 10 + *str-'A';\n\t\telse\n\t\t\tError (\"Bad hex number: %s\",hex);\n\t\tstr++;\n\t}\n\n\treturn num;\n}\n\n\nint ParseNum (char *str)\n{\n\tif (str[0] == '$')\n\t\treturn ParseHex (str+1);\n\tif (str[0] == '0' && str[1] == 'x')\n\t\treturn ParseHex (str+2);\n\treturn atol (str);\n}\n\n\n\n/*\n============================================================================\n\n\t\t\t\t\tBYTE ORDER FUNCTIONS\n\n============================================================================\n*/\n\n#ifdef _SGI_SOURCE\n#define\t__BIG_ENDIAN__\n#endif\n\n#ifdef __BIG_ENDIAN__\n\nshort   LittleShort (short l)\n{\n\tbyte    b1,b2;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\n\treturn (b1<<8) + b2;\n}\n\nshort   BigShort (short l)\n{\n\treturn l;\n}\n\n\nint    LittleLong (int l)\n{\n\tbyte    b1,b2,b3,b4;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\tb3 = (l>>16)&255;\n\tb4 = (l>>24)&255;\n\n\treturn ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;\n}\n\nint    BigLong (int l)\n{\n\treturn l;\n}\n\n\nfloat\tLittleFloat (float l)\n{\n\tunion {byte b[4]; float f;} in, out;\n\t\n\tin.f = l;\n\tout.b[0] = in.b[3];\n\tout.b[1] = in.b[2];\n\tout.b[2] = in.b[1];\n\tout.b[3] = in.b[0];\n\t\n\treturn out.f;\n}\n\nfloat\tBigFloat (float l)\n{\n\treturn l;\n}\n\n#ifdef SIN\nunsigned short   LittleUnsignedShort (unsigned short l)\n{\n\tbyte    b1,b2;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\n\treturn (b1<<8) + b2;\n}\n\nunsigned short   BigUnsignedShort (unsigned short l)\n{\n\treturn l;\n}\n\nunsigned    LittleUnsigned (unsigned l)\n{\n\tbyte    b1,b2,b3,b4;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\tb3 = (l>>16)&255;\n\tb4 = (l>>24)&255;\n\n\treturn ((unsigned)b1<<24) + ((unsigned)b2<<16) + ((unsigned)b3<<8) + b4;\n}\n\nunsigned    BigUnsigned (unsigned l)\n{\n\treturn l;\n}\n#endif\n\n\n#else\n\n\nshort   BigShort (short l)\n{\n\tbyte    b1,b2;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\n\treturn (b1<<8) + b2;\n}\n\nshort   LittleShort (short l)\n{\n\treturn l;\n}\n\n\nint    BigLong (int l)\n{\n\tbyte    b1,b2,b3,b4;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\tb3 = (l>>16)&255;\n\tb4 = (l>>24)&255;\n\n\treturn ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;\n}\n\nint    LittleLong (int l)\n{\n\treturn l;\n}\n\nfloat\tBigFloat (float l)\n{\n\tunion {byte b[4]; float f;} in, out;\n\t\n\tin.f = l;\n\tout.b[0] = in.b[3];\n\tout.b[1] = in.b[2];\n\tout.b[2] = in.b[1];\n\tout.b[3] = in.b[0];\n\t\n\treturn out.f;\n}\n\nfloat\tLittleFloat (float l)\n{\n\treturn l;\n}\n\n#ifdef SIN\nunsigned short   BigUnsignedShort (unsigned short l)\n{\n\tbyte    b1,b2;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\n\treturn (b1<<8) + b2;\n}\n\nunsigned short   LittleUnsignedShort (unsigned short l)\n{\n\treturn l;\n}\n\n\nunsigned    BigUnsigned (unsigned l)\n{\n\tbyte    b1,b2,b3,b4;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\tb3 = (l>>16)&255;\n\tb4 = (l>>24)&255;\n\n\treturn ((unsigned)b1<<24) + ((unsigned)b2<<16) + ((unsigned)b3<<8) + b4;\n}\n\nunsigned    LittleUnsigned (unsigned l)\n{\n\treturn l;\n}\n#endif\n\n\n#endif\n\n\n//=======================================================\n\n\n// FIXME: byte swap?\n\n// this is a 16 bit, non-reflected CRC using the polynomial 0x1021\n// and the initial and final xor values shown below...  in other words, the\n// CCITT standard CRC used by XMODEM\n\n#define CRC_INIT_VALUE\t0xffff\n#define CRC_XOR_VALUE\t0x0000\n\nstatic unsigned short crctable[256] =\n{\n\t0x0000,\t0x1021,\t0x2042,\t0x3063,\t0x4084,\t0x50a5,\t0x60c6,\t0x70e7,\n\t0x8108,\t0x9129,\t0xa14a,\t0xb16b,\t0xc18c,\t0xd1ad,\t0xe1ce,\t0xf1ef,\n\t0x1231,\t0x0210,\t0x3273,\t0x2252,\t0x52b5,\t0x4294,\t0x72f7,\t0x62d6,\n\t0x9339,\t0x8318,\t0xb37b,\t0xa35a,\t0xd3bd,\t0xc39c,\t0xf3ff,\t0xe3de,\n\t0x2462,\t0x3443,\t0x0420,\t0x1401,\t0x64e6,\t0x74c7,\t0x44a4,\t0x5485,\n\t0xa56a,\t0xb54b,\t0x8528,\t0x9509,\t0xe5ee,\t0xf5cf,\t0xc5ac,\t0xd58d,\n\t0x3653,\t0x2672,\t0x1611,\t0x0630,\t0x76d7,\t0x66f6,\t0x5695,\t0x46b4,\n\t0xb75b,\t0xa77a,\t0x9719,\t0x8738,\t0xf7df,\t0xe7fe,\t0xd79d,\t0xc7bc,\n\t0x48c4,\t0x58e5,\t0x6886,\t0x78a7,\t0x0840,\t0x1861,\t0x2802,\t0x3823,\n\t0xc9cc,\t0xd9ed,\t0xe98e,\t0xf9af,\t0x8948,\t0x9969,\t0xa90a,\t0xb92b,\n\t0x5af5,\t0x4ad4,\t0x7ab7,\t0x6a96,\t0x1a71,\t0x0a50,\t0x3a33,\t0x2a12,\n\t0xdbfd,\t0xcbdc,\t0xfbbf,\t0xeb9e,\t0x9b79,\t0x8b58,\t0xbb3b,\t0xab1a,\n\t0x6ca6,\t0x7c87,\t0x4ce4,\t0x5cc5,\t0x2c22,\t0x3c03,\t0x0c60,\t0x1c41,\n\t0xedae,\t0xfd8f,\t0xcdec,\t0xddcd,\t0xad2a,\t0xbd0b,\t0x8d68,\t0x9d49,\n\t0x7e97,\t0x6eb6,\t0x5ed5,\t0x4ef4,\t0x3e13,\t0x2e32,\t0x1e51,\t0x0e70,\n\t0xff9f,\t0xefbe,\t0xdfdd,\t0xcffc,\t0xbf1b,\t0xaf3a,\t0x9f59,\t0x8f78,\n\t0x9188,\t0x81a9,\t0xb1ca,\t0xa1eb,\t0xd10c,\t0xc12d,\t0xf14e,\t0xe16f,\n\t0x1080,\t0x00a1,\t0x30c2,\t0x20e3,\t0x5004,\t0x4025,\t0x7046,\t0x6067,\n\t0x83b9,\t0x9398,\t0xa3fb,\t0xb3da,\t0xc33d,\t0xd31c,\t0xe37f,\t0xf35e,\n\t0x02b1,\t0x1290,\t0x22f3,\t0x32d2,\t0x4235,\t0x5214,\t0x6277,\t0x7256,\n\t0xb5ea,\t0xa5cb,\t0x95a8,\t0x8589,\t0xf56e,\t0xe54f,\t0xd52c,\t0xc50d,\n\t0x34e2,\t0x24c3,\t0x14a0,\t0x0481,\t0x7466,\t0x6447,\t0x5424,\t0x4405,\n\t0xa7db,\t0xb7fa,\t0x8799,\t0x97b8,\t0xe75f,\t0xf77e,\t0xc71d,\t0xd73c,\n\t0x26d3,\t0x36f2,\t0x0691,\t0x16b0,\t0x6657,\t0x7676,\t0x4615,\t0x5634,\n\t0xd94c,\t0xc96d,\t0xf90e,\t0xe92f,\t0x99c8,\t0x89e9,\t0xb98a,\t0xa9ab,\n\t0x5844,\t0x4865,\t0x7806,\t0x6827,\t0x18c0,\t0x08e1,\t0x3882,\t0x28a3,\n\t0xcb7d,\t0xdb5c,\t0xeb3f,\t0xfb1e,\t0x8bf9,\t0x9bd8,\t0xabbb,\t0xbb9a,\n\t0x4a75,\t0x5a54,\t0x6a37,\t0x7a16,\t0x0af1,\t0x1ad0,\t0x2ab3,\t0x3a92,\n\t0xfd2e,\t0xed0f,\t0xdd6c,\t0xcd4d,\t0xbdaa,\t0xad8b,\t0x9de8,\t0x8dc9,\n\t0x7c26,\t0x6c07,\t0x5c64,\t0x4c45,\t0x3ca2,\t0x2c83,\t0x1ce0,\t0x0cc1,\n\t0xef1f,\t0xff3e,\t0xcf5d,\t0xdf7c,\t0xaf9b,\t0xbfba,\t0x8fd9,\t0x9ff8,\n\t0x6e17,\t0x7e36,\t0x4e55,\t0x5e74,\t0x2e93,\t0x3eb2,\t0x0ed1,\t0x1ef0\n};\n\nvoid CRC_Init(unsigned short *crcvalue)\n{\n\t*crcvalue = CRC_INIT_VALUE;\n}\n\nvoid CRC_ProcessByte(unsigned short *crcvalue, byte data)\n{\n\t*crcvalue = (*crcvalue << 8) ^ crctable[(*crcvalue >> 8) ^ data];\n}\n\nunsigned short CRC_Value(unsigned short crcvalue)\n{\n\treturn crcvalue ^ CRC_XOR_VALUE;\n}\n//=============================================================================\n\n/*\n============\nCreatePath\n============\n*/\nvoid\tCreatePath (char *path)\n{\n\tchar\t*ofs, c;\n\n\tif (path[1] == ':')\n\t\tpath += 2;\n\n\tfor (ofs = path+1 ; *ofs ; ofs++)\n\t{\n\t\tc = *ofs;\n\t\tif (c == '/' || c == '\\\\')\n\t\t{\t// create the directory\n\t\t\t*ofs = 0;\n\t\t\tQ_mkdir (path);\n\t\t\t*ofs = c;\n\t\t}\n\t}\n}\n\n\n/*\n============\nQCopyFile\n\n  Used to archive source files\n============\n*/\nvoid QCopyFile (char *from, char *to)\n{\n\tvoid\t*buffer;\n\tint\t\tlength;\n\n\tlength = LoadFile (from, &buffer, 0, 0);\n\tCreatePath (to);\n\tSaveFile (to, buffer, length);\n\tFreeMemory(buffer);\n}\n\nvoid FS_FreeFile(void *buf)\n{\n\tFreeMemory(buf);\n} //end of the function FS_FreeFile\n\nint FS_ReadFileAndCache(const char *qpath, void **buffer)\n{\n\treturn LoadFile((char *) qpath, buffer, 0, 0);\n} //end of the function FS_ReadFileAndCache\n\nint FS_FOpenFileRead( const char *filename, FILE **file, qboolean uniqueFILE )\n{\n\t*file = fopen(filename, \"rb\");\n\treturn (*file != NULL);\n} //end of the function FS_FOpenFileRead\n"
  },
  {
    "path": "code/bspc/l_cmd.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// cmdlib.h\n\n#ifndef SIN\n#define SIN\n#endif //SIN\n\n#ifndef __CMDLIB__\n#define __CMDLIB__\n\n#ifdef _WIN32\n#pragma warning(disable : 4244)     // MIPS\n#pragma warning(disable : 4136)     // X86\n#pragma warning(disable : 4051)     // ALPHA\n\n#pragma warning(disable : 4018)     // signed/unsigned mismatch\n#pragma warning(disable : 4305)     // truncate from double to float\n#endif\n\n#include <stdio.h>\n#include <string.h>\n#include <stdlib.h>\n#include <errno.h>\n#include <ctype.h>\n#include <time.h>\n#include <stdarg.h>\n\n#ifndef __BYTEBOOL__\n#define __BYTEBOOL__\ntypedef enum {false, true} qboolean;\ntypedef unsigned char byte;\n#endif\n\n// the dec offsetof macro doesnt work very well...\n#define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier)\n\n\n// set these before calling CheckParm\nextern int myargc;\nextern char **myargv;\n\nchar *strupr (char *in);\nchar *strlower (char *in);\nint Q_strncasecmp (char *s1, char *s2, int n);\nint Q_strcasecmp (char *s1, char *s2);\nvoid Q_getwd (char *out);\n\nint Q_filelength (FILE *f);\nint\tFileTime (char *path);\n\nvoid\tQ_mkdir (char *path);\n\nextern\tchar\t\tqdir[1024];\nextern\tchar\t\tgamedir[1024];\nvoid SetQdirFromPath (char *path);\nchar *ExpandArg (char *path);\t// from cmd line\nchar *ExpandPath (char *path);\t// from scripts\nchar *ExpandPathAndArchive (char *path);\n\n\ndouble I_FloatTime (void);\n\nvoid Error(char *error, ...);\nvoid Warning(char *warning, ...);\n\nint\t\tCheckParm (char *check);\n\nFILE\t*SafeOpenWrite (char *filename);\nFILE\t*SafeOpenRead (char *filename);\nvoid\tSafeRead (FILE *f, void *buffer, int count);\nvoid\tSafeWrite (FILE *f, void *buffer, int count);\n\nint LoadFile (char *filename, void **bufferptr, int offset, int length);\nint TryLoadFile (char *filename, void **bufferptr);\nvoid SaveFile (char *filename, void *buffer, int count);\nqboolean\tFileExists (char *filename);\n\nvoid \tDefaultExtension (char *path, char *extension);\nvoid \tDefaultPath (char *path, char *basepath);\nvoid \tStripFilename (char *path);\nvoid \tStripExtension (char *path);\n\nvoid \tExtractFilePath (char *path, char *dest);\nvoid \tExtractFileBase (char *path, char *dest);\nvoid\tExtractFileExtension (char *path, char *dest);\n\nint \tParseNum (char *str);\n\nshort\tBigShort (short l);\nshort\tLittleShort (short l);\nint\t\tBigLong (int l);\nint\t\tLittleLong (int l);\nfloat\tBigFloat (float l);\nfloat\tLittleFloat (float l);\n\n#ifdef SIN\nunsigned short\tBigUnsignedShort (unsigned short l);\nunsigned short\tLittleUnsignedShort (unsigned short l);\nunsigned\t      BigUnsigned (unsigned l);\nunsigned\t      LittleUnsigned (unsigned l);\n#endif\n\n\nchar *COM_Parse (char *data);\n\nextern\tchar\t\tcom_token[1024];\nextern\tqboolean\tcom_eof;\n\nchar *copystring(char *s);\n\n\nvoid CRC_Init(unsigned short *crcvalue);\nvoid CRC_ProcessByte(unsigned short *crcvalue, byte data);\nunsigned short CRC_Value(unsigned short crcvalue);\n\nvoid\tCreatePath (char *path);\nvoid\tQCopyFile (char *from, char *to);\n\nextern\tqboolean\t\tarchive;\nextern\tchar\t\t\tarchivedir[1024];\n\n\nextern\tqboolean verbose;\nvoid qprintf (char *format, ...);\n\nvoid ExpandWildcards (int *argc, char ***argv);\n\n\n// for compression routines\ntypedef struct\n{\n\tbyte\t*data;\n\tint\t\tcount;\n} cblock_t;\n\n#endif\n\n"
  },
  {
    "path": "code/bspc/l_log.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n\n#include \"qbsp.h\"\n\n#define MAX_LOGFILENAMESIZE\t\t1024\n\ntypedef struct logfile_s\n{\n\tchar filename[MAX_LOGFILENAMESIZE];\n\tFILE *fp;\n\tint numwrites;\n} logfile_t;\n\nlogfile_t logfile;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Log_Open(char *filename)\n{\n\tif (!filename || !strlen(filename))\n\t{\n\t\tprintf(\"openlog <filename>\\n\");\n\t\treturn;\n\t} //end if\n\tif (logfile.fp)\n\t{\n\t\tprintf(\"log file %s is already opened\\n\", logfile.filename);\n\t\treturn;\n\t} //end if\n\tlogfile.fp = fopen(filename, \"wb\");\n\tif (!logfile.fp)\n\t{\n\t\tprintf(\"can't open the log file %s\\n\", filename);\n\t\treturn;\n\t} //end if\n\tstrncpy(logfile.filename, filename, MAX_LOGFILENAMESIZE);\n\tprintf(\"Opened log %s\\n\", logfile.filename);\n} //end of the function Log_Create\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Log_Close(void)\n{\n\tif (!logfile.fp)\n\t{\n\t\tprintf(\"no log file to close\\n\");\n\t\treturn;\n\t} //end if\n\tif (fclose(logfile.fp))\n\t{\n\t\tprintf(\"can't close log file %s\\n\", logfile.filename);\n\t\treturn;\n\t} //end if\n\tlogfile.fp = NULL;\n\tprintf(\"Closed log %s\\n\", logfile.filename);\n} //end of the function Log_Close\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Log_Shutdown(void)\n{\n\tif (logfile.fp) Log_Close();\n} //end of the function Log_Shutdown\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Log_UnifyEndOfLine(char *buf)\n{\n\tint i;\n\n\tfor (i = 0; buf[i]; i++)\n\t{\n\t\tif (buf[i] == '\\n')\n\t\t{\n\t\t\tif (i <= 0 || buf[i-1] != '\\r')\n\t\t\t{\n\t\t\t\tmemmove(&buf[i+1], &buf[i], strlen(&buf[i])+1);\n\t\t\t\tbuf[i] = '\\r';\n\t\t\t\ti++;\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n} //end of the function Log_UnifyEndOfLine\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Log_Print(char *fmt, ...)\n{\n\tva_list ap;\n\tchar buf[2048];\n\n\tva_start(ap, fmt);\n\tvsprintf(buf, fmt, ap);\n\tva_end(ap);\n\n\tif (verbose)\n\t{\n#ifdef WINBSPC\n\t\tWinBSPCPrint(buf);\n#else\n\t\tprintf(\"%s\", buf);\n#endif //WINBSPS\n\t} //end if\n\n\tif (logfile.fp)\n\t{\n\t\tLog_UnifyEndOfLine(buf);\n\t\tfprintf(logfile.fp, \"%s\", buf);\n\t\tfflush(logfile.fp);\n\t} //end if\n} //end of the function Log_Print\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Log_Write(char *fmt, ...)\n{\n\tva_list ap;\n\tchar buf[2048];\n\n\tif (!logfile.fp) return;\n\tva_start(ap, fmt);\n\tvsprintf(buf, fmt, ap);\n\tva_end(ap);\n\tLog_UnifyEndOfLine(buf);\n\tfprintf(logfile.fp, \"%s\", buf);\n\tfflush(logfile.fp);\n} //end of the function Log_Write\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Log_WriteTimeStamped(char *fmt, ...)\n{\n\tva_list ap;\n\n\tif (!logfile.fp) return;\n/*\tfprintf(logfile.fp, \"%d   %02d:%02d:%02d:%02d   \",\n\t\t\t\t\tlogfile.numwrites,\n\t\t\t\t\t(int) (botlibglobals.time / 60 / 60),\n\t\t\t\t\t(int) (botlibglobals.time / 60),\n\t\t\t\t\t(int) (botlibglobals.time),\n\t\t\t\t\t(int) ((int) (botlibglobals.time * 100)) -\n\t\t\t\t\t\t\t((int) botlibglobals.time) * 100);*/\n\tva_start(ap, fmt);\n\tvfprintf(logfile.fp, fmt, ap);\n\tva_end(ap);\n\tlogfile.numwrites++;\n\tfflush(logfile.fp);\n} //end of the function Log_Write\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nFILE *Log_FileStruct(void)\n{\n\treturn logfile.fp;\n} //end of the function Log_FileStruct\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Log_Flush(void)\n{\n\tif (logfile.fp) fflush(logfile.fp);\n} //end of the function Log_Flush\n\n"
  },
  {
    "path": "code/bspc/l_log.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n//open a log file\nvoid Log_Open(char *filename);\n//close the current log file\nvoid Log_Close(void);\n//close log file if present\nvoid Log_Shutdown(void);\n//print on stdout and write to the current opened log file\nvoid Log_Print(char *fmt, ...);\n//write to the current opened log file\nvoid Log_Write(char *fmt, ...);\n//write to the current opened log file with a time stamp\nvoid Log_WriteTimeStamped(char *fmt, ...);\n//returns the log file structure\nFILE *Log_FileStruct(void);\n//flush log file\nvoid Log_Flush(void);\n\n#ifdef WINBSPC\nvoid WinBSPCPrint(char *str);\n#endif //WINBSPC\n"
  },
  {
    "path": "code/bspc/l_math.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// mathlib.c -- math primitives\n\n#include \"l_cmd.h\"\n#include \"l_math.h\"\n\nvec3_t vec3_origin = {0,0,0};\n\nvoid AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)\n{\n\tfloat\t\tangle;\n\tstatic float\t\tsr, sp, sy, cr, cp, cy;\n\t// static to help MS compiler fp bugs\n\n\tangle = angles[YAW] * (M_PI*2 / 360);\n\tsy = sin(angle);\n\tcy = cos(angle);\n\tangle = angles[PITCH] * (M_PI*2 / 360);\n\tsp = sin(angle);\n\tcp = cos(angle);\n\tangle = angles[ROLL] * (M_PI*2 / 360);\n\tsr = sin(angle);\n\tcr = cos(angle);\n\n\tif (forward)\n\t{\n\t\tforward[0] = cp*cy;\n\t\tforward[1] = cp*sy;\n\t\tforward[2] = -sp;\n\t}\n\tif (right)\n\t{\n\t\tright[0] = (-1*sr*sp*cy+-1*cr*-sy);\n\t\tright[1] = (-1*sr*sp*sy+-1*cr*cy);\n\t\tright[2] = -1*sr*cp;\n\t}\n\tif (up)\n\t{\n\t\tup[0] = (cr*sp*cy+-sr*-sy);\n\t\tup[1] = (cr*sp*sy+-sr*cy);\n\t\tup[2] = cr*cp;\n\t}\n}\n\n/*\n=================\nRadiusFromBounds\n=================\n*/\nfloat RadiusFromBounds( const vec3_t mins, const vec3_t maxs ) {\n\tint\t\ti;\n\tvec3_t\tcorner;\n\tfloat\ta, b;\n\n\tfor (i=0 ; i<3 ; i++) {\n\t\ta = fabs( mins[i] );\n\t\tb = fabs( maxs[i] );\n\t\tcorner[i] = a > b ? a : b;\n\t}\n\n\treturn VectorLength (corner);\n}\n\n/*\n================\nR_ConcatRotations\n================\n*/\nvoid R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3])\n{\n\tout[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] +\n\t\t\t\tin1[0][2] * in2[2][0];\n\tout[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] +\n\t\t\t\tin1[0][2] * in2[2][1];\n\tout[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] +\n\t\t\t\tin1[0][2] * in2[2][2];\n\tout[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] +\n\t\t\t\tin1[1][2] * in2[2][0];\n\tout[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] +\n\t\t\t\tin1[1][2] * in2[2][1];\n\tout[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] +\n\t\t\t\tin1[1][2] * in2[2][2];\n\tout[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] +\n\t\t\t\tin1[2][2] * in2[2][0];\n\tout[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] +\n\t\t\t\tin1[2][2] * in2[2][1];\n\tout[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] +\n\t\t\t\tin1[2][2] * in2[2][2];\n}\n\nvoid AxisClear( vec3_t axis[3] ) {\n\taxis[0][0] = 1;\n\taxis[0][1] = 0;\n\taxis[0][2] = 0;\n\taxis[1][0] = 0;\n\taxis[1][1] = 1;\n\taxis[1][2] = 0;\n\taxis[2][0] = 0;\n\taxis[2][1] = 0;\n\taxis[2][2] = 1;\n}\n\nfloat VectorLengthSquared(vec3_t v) {\n\treturn DotProduct(v, v);\n}\n\ndouble VectorLength(vec3_t v)\n{\n\tint\t\ti;\n\tdouble\tlength;\n\t\n\tlength = 0;\n\tfor (i=0 ; i< 3 ; i++)\n\t\tlength += v[i]*v[i];\n\tlength = sqrt (length);\t\t// FIXME\n\n\treturn length;\n}\n\nqboolean VectorCompare (vec3_t v1, vec3_t v2)\n{\n\tint\t\ti;\n\t\n\tfor (i=0 ; i<3 ; i++)\n\t\tif (fabs(v1[i]-v2[i]) > EQUAL_EPSILON)\n\t\t\treturn false;\n\t\t\t\n\treturn true;\n}\n\nvec_t Q_rint (vec_t in)\n{\n\treturn floor(in + 0.5);\n}\n\nvoid CrossProduct (const vec3_t v1, const vec3_t v2, vec3_t cross)\n{\n\tcross[0] = v1[1]*v2[2] - v1[2]*v2[1];\n\tcross[1] = v1[2]*v2[0] - v1[0]*v2[2];\n\tcross[2] = v1[0]*v2[1] - v1[1]*v2[0];\n}\n\nvoid _VectorMA (vec3_t va, double scale, vec3_t vb, vec3_t vc)\n{\n\tvc[0] = va[0] + scale*vb[0];\n\tvc[1] = va[1] + scale*vb[1];\n\tvc[2] = va[2] + scale*vb[2];\n}\n\nvec_t _DotProduct (vec3_t v1, vec3_t v2)\n{\n\treturn v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];\n}\n\nvoid _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out)\n{\n\tout[0] = va[0]-vb[0];\n\tout[1] = va[1]-vb[1];\n\tout[2] = va[2]-vb[2];\n}\n\nvoid _VectorAdd (vec3_t va, vec3_t vb, vec3_t out)\n{\n\tout[0] = va[0]+vb[0];\n\tout[1] = va[1]+vb[1];\n\tout[2] = va[2]+vb[2];\n}\n\nvoid _VectorCopy (vec3_t in, vec3_t out)\n{\n\tout[0] = in[0];\n\tout[1] = in[1];\n\tout[2] = in[2];\n}\n\nvoid _VectorScale (vec3_t v, vec_t scale, vec3_t out)\n{\n\tout[0] = v[0] * scale;\n\tout[1] = v[1] * scale;\n\tout[2] = v[2] * scale;\n}\n\nvec_t VectorNormalize(vec3_t inout)\n{\n\tvec_t\tlength, ilength;\n\n\tlength = sqrt (inout[0]*inout[0] + inout[1]*inout[1] + inout[2]*inout[2]);\n\tif (length == 0)\n\t{\n\t\tVectorClear (inout);\n\t\treturn 0;\n\t}\n\n\tilength = 1.0/length;\n\tinout[0] = inout[0]*ilength;\n\tinout[1] = inout[1]*ilength;\n\tinout[2] = inout[2]*ilength;\n\n\treturn length;\n}\n\nvec_t VectorNormalize2(const vec3_t in, vec3_t out)\n{\n\tvec_t\tlength, ilength;\n\n\tlength = sqrt (in[0]*in[0] + in[1]*in[1] + in[2]*in[2]);\n\tif (length == 0)\n\t{\n\t\tVectorClear (out);\n\t\treturn 0;\n\t}\n\n\tilength = 1.0/length;\n\tout[0] = in[0]*ilength;\n\tout[1] = in[1]*ilength;\n\tout[2] = in[2]*ilength;\n\n\treturn length;\n}\n\nvec_t ColorNormalize (vec3_t in, vec3_t out)\n{\n\tfloat\tmax, scale;\n\n\tmax = in[0];\n\tif (in[1] > max)\n\t\tmax = in[1];\n\tif (in[2] > max)\n\t\tmax = in[2];\n\n\tif (max == 0)\n\t\treturn 0;\n\n\tscale = 1.0 / max;\n\n\tVectorScale (in, scale, out);\n\n\treturn max;\n}\n\n\n\nvoid VectorInverse (vec3_t v)\n{\n\tv[0] = -v[0];\n\tv[1] = -v[1];\n\tv[2] = -v[2];\n}\n\nvoid ClearBounds(vec3_t mins, vec3_t maxs)\n{\n\tmins[0] = mins[1] = mins[2] = 99999;\n\tmaxs[0] = maxs[1] = maxs[2] = -99999;\n}\n\nvoid AddPointToBounds(const vec3_t v, vec3_t mins, vec3_t maxs)\n{\n\tint\t\ti;\n\tvec_t\tval;\n\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tval = v[i];\n\t\tif (val < mins[i])\n\t\t\tmins[i] = val;\n\t\tif (val > maxs[i])\n\t\t\tmaxs[i] = val;\n\t}\n}\n"
  },
  {
    "path": "code/bspc/l_math.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __MATHLIB__\n#define __MATHLIB__\n\n// mathlib.h\n\n#include <math.h>\n\n#ifdef DOUBLEVEC_T\ntypedef double vec_t;\n#else\ntypedef float vec_t;\n#endif\ntypedef vec_t vec3_t[3];\ntypedef vec_t vec4_t[4];\n\n#define\tSIDE_FRONT\t\t0\n#define\tSIDE_ON\t\t\t2\n#define\tSIDE_BACK\t\t1\n#define\tSIDE_CROSS\t\t-2\n\n#define PITCH\t\t0\n#define YAW\t\t\t1\n#define ROLL\t\t2\n\n#define\tQ_PI\t3.14159265358979323846\n\n#define DEG2RAD( a ) ( a * M_PI ) / 180.0F\n\n#ifndef M_PI\n#define M_PI\t\t3.14159265358979323846\t// matches value in gcc v2 math.h\n#endif\n\nextern vec3_t vec3_origin;\n\n#define\tEQUAL_EPSILON\t0.001\n\nqboolean VectorCompare (vec3_t v1, vec3_t v2);\n\n#define DotProduct(x,y)\t\t\t(x[0]*y[0]+x[1]*y[1]+x[2]*y[2])\n#define VectorSubtract(a,b,c)\t{c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];}\n#define VectorAdd(a,b,c)\t\t{c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];}\n#define VectorCopy(a,b)\t\t\t{b[0]=a[0];b[1]=a[1];b[2]=a[2];}\n#define Vector4Copy(a,b)\t\t{b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];}\n#define\tVectorScale(v, s, o)\t((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s))\n#define VectorClear(x)\t\t\t{x[0] = x[1] = x[2] = 0;}\n#define VectorNegate(x, y)\t\t{y[0]=-x[0];y[1]=-x[1];y[2]=-x[2];}\n#define\tVectorMA(v, s, b, o)\t((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s))\n\nvec_t Q_rint (vec_t in);\nvec_t _DotProduct (vec3_t v1, vec3_t v2);\nvoid _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out);\nvoid _VectorAdd (vec3_t va, vec3_t vb, vec3_t out);\nvoid _VectorCopy (vec3_t in, vec3_t out);\nvoid _VectorScale (vec3_t v, vec_t scale, vec3_t out);\nvoid _VectorMA(vec3_t va, double scale, vec3_t vb, vec3_t vc);\n\ndouble VectorLength(vec3_t v);\nvoid CrossProduct(const vec3_t v1, const vec3_t v2, vec3_t cross);\nvec_t VectorNormalize(vec3_t inout);\nvec_t ColorNormalize(vec3_t in, vec3_t out);\nvec_t VectorNormalize2(const vec3_t v, vec3_t out);\nvoid VectorInverse (vec3_t v);\n\nvoid ClearBounds (vec3_t mins, vec3_t maxs);\nvoid AddPointToBounds (const vec3_t v, vec3_t mins, vec3_t maxs);\n\nvoid AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);\nvoid R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]);\nvoid RotatePoint(vec3_t point, float matrix[3][3]);\nvoid CreateRotationMatrix(vec3_t angles, float matrix[3][3]);\n\n#endif\n"
  },
  {
    "path": "code/bspc/l_mem.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n#include \"l_log.h\"\n\nint allocedmemory;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid PrintMemorySize(unsigned long size)\n{\n\tunsigned long number1, number2, number3;\n\tnumber1 = size >> 20;\n\tnumber2 = (size & 0xFFFFF) >> 10;\n\tnumber3 = (size & 0x3FF);\n\tif (number1) Log_Print(\"%ld MB\", number1);\n\tif (number1 && number2) Log_Print(\" and \");\n\tif (number2) Log_Print(\"%ld KB\", number2);\n\tif (number2 && number3) Log_Print(\" and \");\n\tif (number3) Log_Print(\"%ld bytes\", number3);\n} //end of the function PrintFileSize\n\n#ifndef MEMDEBUG\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint MemorySize(void *ptr)\n{\n#if defined(WIN32) || defined(_WIN32)\n\t#ifdef __WATCOMC__\n\t\t//Intel 32 bits memory addressing, 16 bytes aligned\n\treturn (_msize(ptr) + 15) >> 4 << 4;\n\t#else\n\treturn _msize(ptr);\n\t#endif\n#else\n\treturn 0;\n#endif\n} //end of the function MemorySize\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid *GetClearedMemory(int size)\n{\n\tvoid *ptr;\n\n\tptr = (void *) malloc(size);\n\tif (!ptr) Error(\"out of memory\");\n\tmemset(ptr, 0, size);\n\tallocedmemory += MemorySize(ptr);\n\treturn ptr;\n} //end of the function GetClearedMemory\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid *GetMemory(unsigned long size)\n{\n\tvoid *ptr;\n\tptr = malloc(size);\n\tif (!ptr) Error(\"out of memory\");\n\tallocedmemory += MemorySize(ptr);\n\treturn ptr;\n} //end of the function GetMemory\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid FreeMemory(void *ptr)\n{\n\tallocedmemory -= MemorySize(ptr);\n\tfree(ptr);\n} //end of the function FreeMemory\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TotalAllocatedMemory(void)\n{\n\treturn allocedmemory;\n} //end of the function TotalAllocatedMemory\n\n#else\n\n#define MEM_ID\t\t0x12345678l\n\nint totalmemorysize;\nint numblocks;\n\ntypedef struct memoryblock_s\n{\n\tunsigned long int id;\n\tvoid *ptr;\n\tint size;\n#ifdef MEMDEBUG\n\tchar *label;\n\tchar *file;\n\tint line;\n#endif //MEMDEBUG\n\tstruct memoryblock_s *prev, *next;\n} memoryblock_t;\n\nmemoryblock_t *memory;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid LinkMemoryBlock(memoryblock_t *block)\n{\n\tblock->prev = NULL;\n\tblock->next = memory;\n\tif (memory) memory->prev = block;\n\tmemory = block;\n} //end of the function LinkMemoryBlock\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid UnlinkMemoryBlock(memoryblock_t *block)\n{\n\tif (block->prev) block->prev->next = block->next;\n\telse memory = block->next;\n\tif (block->next) block->next->prev = block->prev;\n} //end of the function UnlinkMemoryBlock\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#ifdef MEMDEBUG\nvoid *GetMemoryDebug(unsigned long size, char *label, char *file, int line)\n#else\nvoid *GetMemory(unsigned long size)\n#endif //MEMDEBUG\n{\n\tvoid *ptr;\n\tmemoryblock_t *block;\n\n\tptr = malloc(size + sizeof(memoryblock_t));\n\tblock = (memoryblock_t *) ptr;\n\tblock->id = MEM_ID;\n\tblock->ptr = (char *) ptr + sizeof(memoryblock_t);\n\tblock->size = size + sizeof(memoryblock_t);\n#ifdef MEMDEBUG\n\tblock->label = label;\n\tblock->file = file;\n\tblock->line = line;\n#endif //MEMDEBUG\n\tLinkMemoryBlock(block);\n\ttotalmemorysize += block->size;\n\tnumblocks++;\n\treturn block->ptr;\n} //end of the function GetMemoryDebug\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#ifdef MEMDEBUG\nvoid *GetClearedMemoryDebug(unsigned long size, char *label, char *file, int line)\n#else\nvoid *GetClearedMemory(unsigned long size)\n#endif //MEMDEBUG\n{\n\tvoid *ptr;\n#ifdef MEMDEBUG\n\tptr = GetMemoryDebug(size, label, file, line);\n#else\n\tptr = GetMemory(size);\n#endif //MEMDEBUG\n\tmemset(ptr, 0, size);\n\treturn ptr;\n} //end of the function GetClearedMemoryLabelled\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid *GetClearedHunkMemory(unsigned long size)\n{\n\treturn GetClearedMemory(size);\n} //end of the function GetClearedHunkMemory\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid *GetHunkMemory(unsigned long size)\n{\n\treturn GetMemory(size);\n} //end of the function GetHunkMemory\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nmemoryblock_t *BlockFromPointer(void *ptr, char *str)\n{\n\tmemoryblock_t *block;\n\n\tif (!ptr)\n\t{\n#ifdef MEMDEBUG\n\t\t//char *crash = (char *) NULL;\n\t\t//crash[0] = 1;\n\t\tError(\"%s: NULL pointer\\n\", str);\n#endif MEMDEBUG\n\t\treturn NULL;\n\t} //end if\n\tblock = (memoryblock_t *) ((char *) ptr - sizeof(memoryblock_t));\n\tif (block->id != MEM_ID)\n\t{\n\t\tError(\"%s: invalid memory block\\n\", str);\n\t} //end if\n\tif (block->ptr != ptr)\n\t{\n\t\t\n\t\tError(\"%s: memory block pointer invalid\\n\", str);\n\t} //end if\n\treturn block;\n} //end of the function BlockFromPointer\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid FreeMemory(void *ptr)\n{\n\tmemoryblock_t *block;\n\n\tblock = BlockFromPointer(ptr, \"FreeMemory\");\n\tif (!block) return;\n\tUnlinkMemoryBlock(block);\n\ttotalmemorysize -= block->size;\n\tnumblocks--;\n\t//\n\tfree(block);\n} //end of the function FreeMemory\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint MemoryByteSize(void *ptr)\n{\n\tmemoryblock_t *block;\n\n\tblock = BlockFromPointer(ptr, \"MemoryByteSize\");\n\tif (!block) return 0;\n\treturn block->size;\n} //end of the function MemoryByteSize\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint MemorySize(void *ptr)\n{\n\treturn MemoryByteSize(ptr);\n} //end of the function MemorySize\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid PrintUsedMemorySize(void)\n{\n\tprintf(\"total botlib memory: %d KB\\n\", totalmemorysize >> 10);\n\tprintf(\"total memory blocks: %d\\n\", numblocks);\n} //end of the function PrintUsedMemorySize\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid PrintMemoryLabels(void)\n{\n\tmemoryblock_t *block;\n\tint i;\n\n\tPrintUsedMemorySize();\n\ti = 0;\n\tfor (block = memory; block; block = block->next)\n\t{\n#ifdef MEMDEBUG\n\t\tLog_Write(\"%6d, %p, %8d: %24s line %6d: %s\", i, block->ptr, block->size, block->file, block->line, block->label);\n#endif //MEMDEBUG\n\t\ti++;\n\t} //end for\n} //end of the function PrintMemoryLabels\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid DumpMemory(void)\n{\n\tmemoryblock_t *block;\n\n\tfor (block = memory; block; block = memory)\n\t{\n\t\tFreeMemory(block->ptr);\n\t} //end for\n\ttotalmemorysize = 0;\n} //end of the function DumpMemory\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TotalAllocatedMemory(void)\n{\n\treturn totalmemorysize;\n} //end of the function TotalAllocatedMemory\n#endif\n\n//===========================================================================\n// Q3 Hunk and Z_ memory management\n//===========================================================================\n\ntypedef struct memhunk_s\n{\n\tvoid *ptr;\n\tstruct memhunk_s *next;\n} memhunk_t;\n\nmemhunk_t *memhunk_high;\nmemhunk_t *memhunk_low;\nint memhunk_high_size = 16 * 1024 * 1024;\nint memhunk_low_size = 0;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Hunk_ClearHigh(void)\n{\n\tmemhunk_t *h, *nexth;\n\n\tfor (h = memhunk_high; h; h = nexth)\n\t{\n\t\tnexth = h->next;\n\t\tFreeMemory(h);\n\t} //end for\n\tmemhunk_high = NULL;\n\tmemhunk_high_size = 16 * 1024 * 1024;\n} //end of the function Hunk_ClearHigh\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid *Hunk_Alloc(int size)\n{\n\tmemhunk_t *h;\n\n\tif (!size) return (void *) memhunk_high_size;\n\t//\n\th = GetClearedMemory(size + sizeof(memhunk_t));\n\th->ptr = (char *) h + sizeof(memhunk_t);\n\th->next = memhunk_high;\n\tmemhunk_high = h;\n\tmemhunk_high_size -= size;\n\treturn h->ptr;\n} //end of the function Hunk_Alloc\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid *Z_Malloc(int size)\n{\n\treturn GetClearedMemory(size);\n} //end of the function Z_Malloc\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Z_Free (void *ptr)\n{\n\tFreeMemory(ptr);\n} //end of the function Z_Free\n"
  },
  {
    "path": "code/bspc/l_mem.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n\n//=============================================================================\n\n// memory.h\n//#define MEMDEBUG\n#undef MEMDEBUG\n\n#ifndef MEMDEBUG\n\nvoid *GetClearedMemory(int size);\nvoid *GetMemory(unsigned long size);\n\n#else\n\n#define GetMemory(size)\t\t\t\tGetMemoryDebug(size, #size, __FILE__, __LINE__);\n#define GetClearedMemory(size)\tGetClearedMemoryDebug(size, #size, __FILE__, __LINE__);\n//allocate a memory block of the given size\nvoid *GetMemoryDebug(unsigned long size, char *label, char *file, int line);\n//allocate a memory block of the given size and clear it\nvoid *GetClearedMemoryDebug(unsigned long size, char *label, char *file, int line);\n//\nvoid PrintMemoryLabels(void);\n#endif //MEMDEBUG\n\nvoid FreeMemory(void *ptr);\nint MemorySize(void *ptr);\nvoid PrintMemorySize(unsigned long size);\nint TotalAllocatedMemory(void);\n\n"
  },
  {
    "path": "code/bspc/l_poly.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include <malloc.h>\n#include \"l_cmd.h\"\n#include \"l_math.h\"\n#include \"l_poly.h\"\n#include \"l_log.h\"\n#include \"l_mem.h\"\n\n#define\tBOGUS_RANGE\t\t65535\n\nextern int numthreads;\n\n// counters are only bumped when running single threaded,\n// because they are an awefull coherence problem\nint c_active_windings;\nint c_peak_windings;\nint c_winding_allocs;\nint c_winding_points;\nint c_windingmemory;\nint c_peak_windingmemory;\n\nchar windingerror[1024];\n\nvoid pw(winding_t *w)\n{\n\tint\t\ti;\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\tprintf (\"(%5.3f, %5.3f, %5.3f)\\n\",w->p[i][0], w->p[i][1],w->p[i][2]);\n}\n\n\nvoid ResetWindings(void)\n{\n\tc_active_windings = 0;\n\tc_peak_windings = 0;\n\tc_winding_allocs = 0;\n\tc_winding_points = 0;\n\tc_windingmemory = 0;\n\tc_peak_windingmemory = 0;\n\n\tstrcpy(windingerror, \"\");\n} //end of the function ResetWindings\n/*\n=============\nAllocWinding\n=============\n*/\nwinding_t *AllocWinding (int points)\n{\n\twinding_t\t*w;\n\tint\t\t\ts;\n\n\ts = sizeof(vec_t)*3*points + sizeof(int);\n\tw = GetMemory(s);\n\tmemset(w, 0, s);\n\n\tif (numthreads == 1)\n\t{\n\t\tc_winding_allocs++;\n\t\tc_winding_points += points;\n\t\tc_active_windings++;\n\t\tif (c_active_windings > c_peak_windings)\n\t\t\tc_peak_windings = c_active_windings;\n\t\tc_windingmemory += MemorySize(w);\n\t\tif (c_windingmemory > c_peak_windingmemory)\n\t\t\tc_peak_windingmemory = c_windingmemory;\n\t} //end if\n\treturn w;\n} //end of the function AllocWinding\n\nvoid FreeWinding (winding_t *w)\n{\n\tif (*(unsigned *)w == 0xdeaddead)\n\t\tError (\"FreeWinding: freed a freed winding\");\n\n\tif (numthreads == 1)\n\t{\n\t\tc_active_windings--;\n\t\tc_windingmemory -= MemorySize(w);\n\t} //end if\n\n\t*(unsigned *)w = 0xdeaddead;\n\n\tFreeMemory(w);\n} //end of the function FreeWinding\n\nint WindingMemory(void)\n{\n\treturn c_windingmemory;\n} //end of the function WindingMemory\n\nint WindingPeakMemory(void)\n{\n\treturn c_peak_windingmemory;\n} //end of the function WindingPeakMemory\n\nint ActiveWindings(void)\n{\n\treturn c_active_windings;\n} //end of the function ActiveWindings\n/*\n============\nRemoveColinearPoints\n============\n*/\nint\tc_removed;\n\nvoid RemoveColinearPoints (winding_t *w)\n{\n\tint\t\ti, j, k;\n\tvec3_t\tv1, v2;\n\tint\t\tnump;\n\tvec3_t\tp[MAX_POINTS_ON_WINDING];\n\n\tnump = 0;\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tj = (i+1)%w->numpoints;\n\t\tk = (i+w->numpoints-1)%w->numpoints;\n\t\tVectorSubtract (w->p[j], w->p[i], v1);\n\t\tVectorSubtract (w->p[i], w->p[k], v2);\n\t\tVectorNormalize(v1);\n\t\tVectorNormalize(v2);\n\t\tif (DotProduct(v1, v2) < 0.999)\n\t\t{\n\t\t\tif (nump >= MAX_POINTS_ON_WINDING)\n\t\t\t\tError(\"RemoveColinearPoints: MAX_POINTS_ON_WINDING\");\n\t\t\tVectorCopy (w->p[i], p[nump]);\n\t\t\tnump++;\n\t\t}\n\t}\n\n\tif (nump == w->numpoints)\n\t\treturn;\n\n\tif (numthreads == 1)\n\t\tc_removed += w->numpoints - nump;\n\tw->numpoints = nump;\n\tmemcpy (w->p, p, nump*sizeof(p[0]));\n}\n\n/*\n============\nWindingPlane\n============\n*/\nvoid WindingPlane (winding_t *w, vec3_t normal, vec_t *dist)\n{\n\tvec3_t v1, v2;\n\tint i;\n\n\t//find two vectors each longer than 0.5 units\n\tfor (i = 0; i < w->numpoints; i++)\n\t{\n\t\tVectorSubtract(w->p[(i+1) % w->numpoints], w->p[i], v1);\n\t\tVectorSubtract(w->p[(i+2) % w->numpoints], w->p[i], v2);\n\t\tif (VectorLength(v1) > 0.5 && VectorLength(v2) > 0.5) break;\n\t} //end for\n\tCrossProduct(v2, v1, normal);\n\tVectorNormalize(normal);\n\t*dist = DotProduct(w->p[0], normal);\n} //end of the function WindingPlane\n\n/*\n=============\nWindingArea\n=============\n*/\nvec_t\tWindingArea (winding_t *w)\n{\n\tint\t\ti;\n\tvec3_t\td1, d2, cross;\n\tvec_t\ttotal;\n\n\ttotal = 0;\n\tfor (i=2 ; i<w->numpoints ; i++)\n\t{\n\t\tVectorSubtract (w->p[i-1], w->p[0], d1);\n\t\tVectorSubtract (w->p[i], w->p[0], d2);\n\t\tCrossProduct (d1, d2, cross);\n\t\ttotal += 0.5 * VectorLength ( cross );\n\t}\n\treturn total;\n}\n\nvoid WindingBounds (winding_t *w, vec3_t mins, vec3_t maxs)\n{\n\tvec_t\tv;\n\tint\t\ti,j;\n\n\tmins[0] = mins[1] = mins[2] = 99999;\n\tmaxs[0] = maxs[1] = maxs[2] = -99999;\n\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\tv = w->p[i][j];\n\t\t\tif (v < mins[j])\n\t\t\t\tmins[j] = v;\n\t\t\tif (v > maxs[j])\n\t\t\t\tmaxs[j] = v;\n\t\t}\n\t}\n}\n\n/*\n=============\nWindingCenter\n=============\n*/\nvoid\tWindingCenter (winding_t *w, vec3_t center)\n{\n\tint\t\ti;\n\tfloat\tscale;\n\n\tVectorCopy (vec3_origin, center);\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\tVectorAdd (w->p[i], center, center);\n\n\tscale = 1.0/w->numpoints;\n\tVectorScale (center, scale, center);\n}\n\n/*\n=================\nBaseWindingForPlane\n=================\n*/\nwinding_t *BaseWindingForPlane (vec3_t normal, vec_t dist)\n{\n\tint\t\ti, x;\n\tvec_t\tmax, v;\n\tvec3_t\torg, vright, vup;\n\twinding_t\t*w;\n\t\n// find the major axis\n\n\tmax = -BOGUS_RANGE;\n\tx = -1;\n\tfor (i=0 ; i<3; i++)\n\t{\n\t\tv = fabs(normal[i]);\n\t\tif (v > max)\n\t\t{\n\t\t\tx = i;\n\t\t\tmax = v;\n\t\t}\n\t}\n\tif (x==-1)\n\t\tError (\"BaseWindingForPlane: no axis found\");\n\t\t\n\tVectorCopy (vec3_origin, vup);\t\n\tswitch (x)\n\t{\n\tcase 0:\n\tcase 1:\n\t\tvup[2] = 1;\n\t\tbreak;\t\t\n\tcase 2:\n\t\tvup[0] = 1;\n\t\tbreak;\t\t\n\t}\n\n\tv = DotProduct (vup, normal);\n\tVectorMA (vup, -v, normal, vup);\n\tVectorNormalize (vup);\n\t\t\n\tVectorScale (normal, dist, org);\n\t\n\tCrossProduct (vup, normal, vright);\n\t\n\tVectorScale (vup, BOGUS_RANGE, vup);\n\tVectorScale (vright, BOGUS_RANGE, vright);\n\n// project a really big\taxis aligned box onto the plane\n\tw = AllocWinding (4);\n\t\n\tVectorSubtract (org, vright, w->p[0]);\n\tVectorAdd (w->p[0], vup, w->p[0]);\n\t\n\tVectorAdd (org, vright, w->p[1]);\n\tVectorAdd (w->p[1], vup, w->p[1]);\n\t\n\tVectorAdd (org, vright, w->p[2]);\n\tVectorSubtract (w->p[2], vup, w->p[2]);\n\t\n\tVectorSubtract (org, vright, w->p[3]);\n\tVectorSubtract (w->p[3], vup, w->p[3]);\n\t\n\tw->numpoints = 4;\n\t\n\treturn w;\t\n}\n\n/*\n==================\nCopyWinding\n==================\n*/\nwinding_t *CopyWinding (winding_t *w)\n{\n\tint\t\t\tsize;\n\twinding_t\t*c;\n\n\tc = AllocWinding (w->numpoints);\n\tsize = (int)((winding_t *)0)->p[w->numpoints];\n\tmemcpy (c, w, size);\n\treturn c;\n}\n\n/*\n==================\nReverseWinding\n==================\n*/\nwinding_t\t*ReverseWinding (winding_t *w)\n{\n\tint\t\t\ti;\n\twinding_t\t*c;\n\n\tc = AllocWinding (w->numpoints);\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tVectorCopy (w->p[w->numpoints-1-i], c->p[i]);\n\t}\n\tc->numpoints = w->numpoints;\n\treturn c;\n}\n\n\n/*\n=============\nClipWindingEpsilon\n=============\n*/\nvoid ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist, \n\t\t\t\tvec_t epsilon, winding_t **front, winding_t **back)\n{\n\tvec_t\tdists[MAX_POINTS_ON_WINDING+4];\n\tint\t\tsides[MAX_POINTS_ON_WINDING+4];\n\tint\t\tcounts[3];\n\t//MrElusive: DOH can't use statics when unsing multithreading!!!\n\tvec_t dot;\t\t// VC 4.2 optimizer bug if not static\n\tint\t\ti, j;\n\tvec_t\t*p1, *p2;\n\tvec3_t\tmid;\n\twinding_t\t*f, *b;\n\tint\t\tmaxpts;\n\t\n\tcounts[0] = counts[1] = counts[2] = 0;\n\n// determine sides for each point\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tdot = DotProduct (in->p[i], normal);\n\t\tdot -= dist;\n\t\tdists[i] = dot;\n\t\tif (dot > epsilon)\n\t\t\tsides[i] = SIDE_FRONT;\n\t\telse if (dot < -epsilon)\n\t\t\tsides[i] = SIDE_BACK;\n\t\telse\n\t\t{\n\t\t\tsides[i] = SIDE_ON;\n\t\t}\n\t\tcounts[sides[i]]++;\n\t}\n\tsides[i] = sides[0];\n\tdists[i] = dists[0];\n\t\n\t*front = *back = NULL;\n\n\tif (!counts[0])\n\t{\n\t\t*back = CopyWinding (in);\n\t\treturn;\n\t}\n\tif (!counts[1])\n\t{\n\t\t*front = CopyWinding (in);\n\t\treturn;\n\t}\n\n\tmaxpts = in->numpoints+4;\t// cant use counts[0]+2 because\n\t\t\t\t\t\t\t\t// of fp grouping errors\n\n\t*front = f = AllocWinding (maxpts);\n\t*back = b = AllocWinding (maxpts);\n\t\t\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tp1 = in->p[i];\n\t\t\n\t\tif (sides[i] == SIDE_ON)\n\t\t{\n\t\t\tVectorCopy (p1, f->p[f->numpoints]);\n\t\t\tf->numpoints++;\n\t\t\tVectorCopy (p1, b->p[b->numpoints]);\n\t\t\tb->numpoints++;\n\t\t\tcontinue;\n\t\t}\n\t\n\t\tif (sides[i] == SIDE_FRONT)\n\t\t{\n\t\t\tVectorCopy (p1, f->p[f->numpoints]);\n\t\t\tf->numpoints++;\n\t\t}\n\t\tif (sides[i] == SIDE_BACK)\n\t\t{\n\t\t\tVectorCopy (p1, b->p[b->numpoints]);\n\t\t\tb->numpoints++;\n\t\t}\n\n\t\tif (sides[i+1] == SIDE_ON || sides[i+1] == sides[i])\n\t\t\tcontinue;\n\t\t\t\n\t// generate a split point\n\t\tp2 = in->p[(i+1)%in->numpoints];\n\t\t\n\t\tdot = dists[i] / (dists[i]-dists[i+1]);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\t// avoid round off error when possible\n\t\t\tif (normal[j] == 1)\n\t\t\t\tmid[j] = dist;\n\t\t\telse if (normal[j] == -1)\n\t\t\t\tmid[j] = -dist;\n\t\t\telse\n\t\t\t\tmid[j] = p1[j] + dot*(p2[j]-p1[j]);\n\t\t}\n\t\t\t\n\t\tVectorCopy (mid, f->p[f->numpoints]);\n\t\tf->numpoints++;\n\t\tVectorCopy (mid, b->p[b->numpoints]);\n\t\tb->numpoints++;\n\t}\n\t\n\tif (f->numpoints > maxpts || b->numpoints > maxpts)\n\t\tError (\"ClipWinding: points exceeded estimate\");\n\tif (f->numpoints > MAX_POINTS_ON_WINDING || b->numpoints > MAX_POINTS_ON_WINDING)\n\t\tError (\"ClipWinding: MAX_POINTS_ON_WINDING\");\n}\n\n\n/*\n=============\nChopWindingInPlace\n=============\n*/\nvoid ChopWindingInPlace (winding_t **inout, vec3_t normal, vec_t dist, vec_t epsilon)\n{\n\twinding_t *in;\n\tvec_t\tdists[MAX_POINTS_ON_WINDING+4];\n\tint sides[MAX_POINTS_ON_WINDING+4];\n\tint counts[3];\n\t//MrElusive: DOH can't use statics when unsing multithreading!!!\n\tvec_t dot;\t\t// VC 4.2 optimizer bug if not static\n\tint i, j;\n\tvec_t *p1, *p2;\n\tvec3_t mid;\n\twinding_t *f;\n\tint maxpts;\n\n\tin = *inout;\n\tcounts[0] = counts[1] = counts[2] = 0;\n\n// determine sides for each point\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tdot = DotProduct (in->p[i], normal);\n\t\tdot -= dist;\n\t\tdists[i] = dot;\n\t\tif (dot > epsilon)\n\t\t\tsides[i] = SIDE_FRONT;\n\t\telse if (dot < -epsilon)\n\t\t\tsides[i] = SIDE_BACK;\n\t\telse\n\t\t{\n\t\t\tsides[i] = SIDE_ON;\n\t\t}\n\t\tcounts[sides[i]]++;\n\t}\n\tsides[i] = sides[0];\n\tdists[i] = dists[0];\n\t\n\tif (!counts[0])\n\t{\n\t\tFreeWinding (in);\n\t\t*inout = NULL;\n\t\treturn;\n\t}\n\tif (!counts[1])\n\t\treturn;\t\t// inout stays the same\n\n\tmaxpts = in->numpoints+4;\t// cant use counts[0]+2 because\n\t\t\t\t\t\t\t\t// of fp grouping errors\n\n\tf = AllocWinding (maxpts);\n\t\t\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tp1 = in->p[i];\n\t\t\n\t\tif (sides[i] == SIDE_ON)\n\t\t{\n\t\t\tVectorCopy (p1, f->p[f->numpoints]);\n\t\t\tf->numpoints++;\n\t\t\tcontinue;\n\t\t}\n\t\n\t\tif (sides[i] == SIDE_FRONT)\n\t\t{\n\t\t\tVectorCopy (p1, f->p[f->numpoints]);\n\t\t\tf->numpoints++;\n\t\t}\n\n\t\tif (sides[i+1] == SIDE_ON || sides[i+1] == sides[i])\n\t\t\tcontinue;\n\t\t\t\n\t// generate a split point\n\t\tp2 = in->p[(i+1)%in->numpoints];\n\t\t\n\t\tdot = dists[i] / (dists[i]-dists[i+1]);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\t// avoid round off error when possible\n\t\t\tif (normal[j] == 1)\n\t\t\t\tmid[j] = dist;\n\t\t\telse if (normal[j] == -1)\n\t\t\t\tmid[j] = -dist;\n\t\t\telse\n\t\t\t\tmid[j] = p1[j] + dot*(p2[j]-p1[j]);\n\t\t}\n\t\t\t\n\t\tVectorCopy (mid, f->p[f->numpoints]);\n\t\tf->numpoints++;\n\t}\n\t\n\tif (f->numpoints > maxpts)\n\t\tError (\"ClipWinding: points exceeded estimate\");\n\tif (f->numpoints > MAX_POINTS_ON_WINDING)\n\t\tError (\"ClipWinding: MAX_POINTS_ON_WINDING\");\n\n\tFreeWinding (in);\n\t*inout = f;\n}\n\n\n/*\n=================\nChopWinding\n\nReturns the fragment of in that is on the front side\nof the cliping plane.  The original is freed.\n=================\n*/\nwinding_t\t*ChopWinding (winding_t *in, vec3_t normal, vec_t dist)\n{\n\twinding_t\t*f, *b;\n\n\tClipWindingEpsilon (in, normal, dist, ON_EPSILON, &f, &b);\n\tFreeWinding (in);\n\tif (b)\n\t\tFreeWinding (b);\n\treturn f;\n}\n\n\n/*\n=================\nCheckWinding\n\n=================\n*/\nvoid CheckWinding (winding_t *w)\n{\n\tint\t\ti, j;\n\tvec_t\t*p1, *p2;\n\tvec_t\td, edgedist;\n\tvec3_t\tdir, edgenormal, facenormal;\n\tvec_t\tarea;\n\tvec_t\tfacedist;\n\n\tif (w->numpoints < 3)\n\t\tError (\"CheckWinding: %i points\",w->numpoints);\n\t\n\tarea = WindingArea(w);\n\tif (area < 1)\n\t\tError (\"CheckWinding: %f area\", area);\n\n\tWindingPlane (w, facenormal, &facedist);\n\t\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tp1 = w->p[i];\n\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t\tif (p1[j] > BOGUS_RANGE || p1[j] < -BOGUS_RANGE)\n\t\t\t\tError (\"CheckWinding: BUGUS_RANGE: %f\",p1[j]);\n\n\t\tj = i+1 == w->numpoints ? 0 : i+1;\n\t\t\n\t// check the point is on the face plane\n\t\td = DotProduct (p1, facenormal) - facedist;\n\t\tif (d < -ON_EPSILON || d > ON_EPSILON)\n\t\t\tError (\"CheckWinding: point off plane\");\n\t\n\t// check the edge isnt degenerate\n\t\tp2 = w->p[j];\n\t\tVectorSubtract (p2, p1, dir);\n\t\t\n\t\tif (VectorLength (dir) < ON_EPSILON)\n\t\t\tError (\"CheckWinding: degenerate edge\");\n\t\t\t\n\t\tCrossProduct (facenormal, dir, edgenormal);\n\t\tVectorNormalize (edgenormal);\n\t\tedgedist = DotProduct (p1, edgenormal);\n\t\tedgedist += ON_EPSILON;\n\t\t\n\t// all other points must be on front side\n\t\tfor (j=0 ; j<w->numpoints ; j++)\n\t\t{\n\t\t\tif (j == i)\n\t\t\t\tcontinue;\n\t\t\td = DotProduct (w->p[j], edgenormal);\n\t\t\tif (d > edgedist)\n\t\t\t\tError (\"CheckWinding: non-convex\");\n\t\t}\n\t}\n}\n\n\n/*\n============\nWindingOnPlaneSide\n============\n*/\nint WindingOnPlaneSide (winding_t *w, vec3_t normal, vec_t dist)\n{\n\tqboolean\tfront, back;\n\tint\t\t\ti;\n\tvec_t\t\td;\n\n\tfront = false;\n\tback = false;\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\td = DotProduct (w->p[i], normal) - dist;\n\t\tif (d < -ON_EPSILON)\n\t\t{\n\t\t\tif (front)\n\t\t\t\treturn SIDE_CROSS;\n\t\t\tback = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (d > ON_EPSILON)\n\t\t{\n\t\t\tif (back)\n\t\t\t\treturn SIDE_CROSS;\n\t\t\tfront = true;\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\tif (back)\n\t\treturn SIDE_BACK;\n\tif (front)\n\t\treturn SIDE_FRONT;\n\treturn SIDE_ON;\n}\n\n//#ifdef ME\n\t#define\tCONTINUOUS_EPSILON\t0.005\n//#else\n//\t#define\tCONTINUOUS_EPSILON\t0.001\n//#endif\n\n/*\n=============\nTryMergeWinding\n\nIf two polygons share a common edge and the edges that meet at the\ncommon points are both inside the other polygons, merge them\n\nReturns NULL if the faces couldn't be merged, or the new face.\nThe originals will NOT be freed.\n=============\n*/\n\nwinding_t *TryMergeWinding (winding_t *f1, winding_t *f2, vec3_t planenormal)\n{\n\tvec_t\t\t*p1, *p2, *p3, *p4, *back;\n\twinding_t\t*newf;\n\tint\t\t\ti, j, k, l;\n\tvec3_t\t\tnormal, delta;\n\tvec_t\t\tdot;\n\tqboolean\tkeep1, keep2;\n\t\n\n\t//\n\t// find a common edge\n\t//\t\n\tp1 = p2 = NULL;\t// stop compiler warning\n\tj = 0;\t\t\t// \n\t\n\tfor (i = 0; i < f1->numpoints; i++)\n\t{\n\t\tp1 = f1->p[i];\n\t\tp2 = f1->p[(i+1) % f1->numpoints];\n\t\tfor (j = 0; j < f2->numpoints; j++)\n\t\t{\n\t\t\tp3 = f2->p[j];\n\t\t\tp4 = f2->p[(j+1) % f2->numpoints];\n\t\t\tfor (k = 0; k < 3; k++)\n\t\t\t{\n\t\t\t\tif (fabs(p1[k] - p4[k]) > 0.1)//EQUAL_EPSILON) //ME\n\t\t\t\t\tbreak;\n\t\t\t\tif (fabs(p2[k] - p3[k]) > 0.1)//EQUAL_EPSILON) //ME\n\t\t\t\t\tbreak;\n\t\t\t} //end for\n\t\t\tif (k==3)\n\t\t\t\tbreak;\n\t\t} //end for\n\t\tif (j < f2->numpoints)\n\t\t\tbreak;\n\t} //end for\n\t\n\tif (i == f1->numpoints)\n\t\treturn NULL;\t\t\t// no matching edges\n\n\t//\n\t// check slope of connected lines\n\t// if the slopes are colinear, the point can be removed\n\t//\n\tback = f1->p[(i+f1->numpoints-1)%f1->numpoints];\n\tVectorSubtract (p1, back, delta);\n\tCrossProduct (planenormal, delta, normal);\n\tVectorNormalize (normal);\n\t\n\tback = f2->p[(j+2)%f2->numpoints];\n\tVectorSubtract (back, p1, delta);\n\tdot = DotProduct (delta, normal);\n\tif (dot > CONTINUOUS_EPSILON)\n\t\treturn NULL;\t\t\t// not a convex polygon\n\tkeep1 = (qboolean)(dot < -CONTINUOUS_EPSILON);\n\t\n\tback = f1->p[(i+2)%f1->numpoints];\n\tVectorSubtract (back, p2, delta);\n\tCrossProduct (planenormal, delta, normal);\n\tVectorNormalize (normal);\n\n\tback = f2->p[(j+f2->numpoints-1)%f2->numpoints];\n\tVectorSubtract (back, p2, delta);\n\tdot = DotProduct (delta, normal);\n\tif (dot > CONTINUOUS_EPSILON)\n\t\treturn NULL;\t\t\t// not a convex polygon\n\tkeep2 = (qboolean)(dot < -CONTINUOUS_EPSILON);\n\n\t//\n\t// build the new polygon\n\t//\n\tnewf = AllocWinding (f1->numpoints + f2->numpoints);\n\t\n\t// copy first polygon\n\tfor (k=(i+1)%f1->numpoints ; k != i ; k=(k+1)%f1->numpoints)\n\t{\n\t\tif (k==(i+1)%f1->numpoints && !keep2)\n\t\t\tcontinue;\n\t\t\n\t\tVectorCopy (f1->p[k], newf->p[newf->numpoints]);\n\t\tnewf->numpoints++;\n\t}\n\t\n\t// copy second polygon\n\tfor (l= (j+1)%f2->numpoints ; l != j ; l=(l+1)%f2->numpoints)\n\t{\n\t\tif (l==(j+1)%f2->numpoints && !keep1)\n\t\t\tcontinue;\n\t\tVectorCopy (f2->p[l], newf->p[newf->numpoints]);\n\t\tnewf->numpoints++;\n\t}\n\n\treturn newf;\n}\n\n//#ifdef ME\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nwinding_t *MergeWindings(winding_t *w1, winding_t *w2, vec3_t planenormal)\n{\n\twinding_t *neww;\n\tfloat dist;\n\tint i, j, n, found, insertafter;\n\tint sides[MAX_POINTS_ON_WINDING+4];\n\tvec3_t newp[MAX_POINTS_ON_WINDING+4];\n\tint numpoints;\n\tvec3_t edgevec, sepnormal, v;\n\n\tRemoveEqualPoints(w1, 0.2);\n\tnumpoints = w1->numpoints;\n\tmemcpy(newp, w1->p, w1->numpoints * sizeof(vec3_t));\n\t//\n\tfor (i = 0; i < w2->numpoints; i++)\n\t{\n\t\tVectorCopy(w2->p[i], v);\n\t\tfor (j = 0; j < numpoints; j++)\n\t\t{\n\t\t\tVectorSubtract(newp[(j+1)%numpoints],\n\t\t\t\t\t\t\tnewp[(j)%numpoints], edgevec);\n\t\t\tCrossProduct(edgevec, planenormal, sepnormal);\n\t\t\tVectorNormalize(sepnormal);\n\t\t\tif (VectorLength(sepnormal) < 0.9)\n\t\t\t{\n\t\t\t\t//remove the point from the new winding\n\t\t\t\tfor (n = j; n < numpoints-1; n++)\n\t\t\t\t{\n\t\t\t\t\tVectorCopy(newp[n+1], newp[n]);\n\t\t\t\t\tsides[n] = sides[n+1];\n\t\t\t\t} //end for\n\t\t\t\tnumpoints--;\n\t\t\t\tj--;\n\t\t\t\tLog_Print(\"MergeWindings: degenerate edge on winding %f %f %f\\n\", sepnormal[0],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsepnormal[1],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsepnormal[2]);\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\tdist = DotProduct(newp[(j)%numpoints], sepnormal);\n\t\t\tif (DotProduct(v, sepnormal) - dist < -0.1) sides[j] = SIDE_BACK;\n\t\t\telse sides[j] = SIDE_FRONT;\n\t\t} //end for\n\t\t//remove all unnecesary points\n\t\tfor (j = 0; j < numpoints;)\n\t\t{\n\t\t\tif (sides[j] == SIDE_BACK\n\t\t\t\t&& sides[(j+1)%numpoints] == SIDE_BACK)\n\t\t\t{\n\t\t\t\t//remove the point from the new winding\n\t\t\t\tfor (n = (j+1)%numpoints; n < numpoints-1; n++)\n\t\t\t\t{\n\t\t\t\t\tVectorCopy(newp[n+1], newp[n]);\n\t\t\t\t\tsides[n] = sides[n+1];\n\t\t\t\t} //end for\n\t\t\t\tnumpoints--;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tj++;\n\t\t\t} //end else\n\t\t} //end for\n\t\t//\n\t\tfound = false;\n\t\tfor (j = 0; j < numpoints; j++)\n\t\t{\n\t\t\tif (sides[j] == SIDE_FRONT\n\t\t\t\t&& sides[(j+1)%numpoints] == SIDE_BACK)\n\t\t\t{\n\t\t\t\tif (found) Log_Print(\"Warning: MergeWindings: front to back found twice\\n\");\n\t\t\t\tfound = true;\n\t\t\t} //end if\n\t\t} //end for\n\t\t//\n\t\tfor (j = 0; j < numpoints; j++)\n\t\t{\n\t\t\tif (sides[j] == SIDE_FRONT\n\t\t\t\t&& sides[(j+1)%numpoints] == SIDE_BACK)\n\t\t\t{\n\t\t\t\tinsertafter = (j+1)%numpoints;\n\t\t\t\t//insert the new point after j+1\n\t\t\t\tfor (n = numpoints-1; n > insertafter; n--)\n\t\t\t\t{\n\t\t\t\t\tVectorCopy(newp[n], newp[n+1]);\n\t\t\t\t} //end for\n\t\t\t\tnumpoints++;\n\t\t\t\tVectorCopy(v, newp[(insertafter+1)%numpoints]);\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\tneww = AllocWinding(numpoints);\n\tneww->numpoints = numpoints;\n\tmemcpy(neww->p, newp, numpoints * sizeof(vec3_t));\n\tRemoveColinearPoints(neww);\n\treturn neww;\n} //end of the function MergeWindings\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nchar *WindingErrorString(void)\n{\n\treturn windingerror;\n} //end of the function WindingErrorString\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint WindingError(winding_t *w)\n{\n\tint\t\ti, j;\n\tvec_t\t*p1, *p2;\n\tvec_t\td, edgedist;\n\tvec3_t\tdir, edgenormal, facenormal;\n\tvec_t\tarea;\n\tvec_t\tfacedist;\n\n\tif (w->numpoints < 3)\n\t{\n\t\tsprintf(windingerror, \"winding %i points\", w->numpoints);\n\t\treturn WE_NOTENOUGHPOINTS;\n\t} //end if\n\t\n\tarea = WindingArea(w);\n\tif (area < 1)\n\t{\n\t\tsprintf(windingerror, \"winding %f area\", area);\n\t\treturn WE_SMALLAREA;\n\t} //end if\n\n\tWindingPlane (w, facenormal, &facedist);\n\t\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tp1 = w->p[i];\n\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\tif (p1[j] > BOGUS_RANGE || p1[j] < -BOGUS_RANGE)\n\t\t\t{\n\t\t\t\tsprintf(windingerror, \"winding point %d BUGUS_RANGE \\'%f %f %f\\'\", j, p1[0], p1[1], p1[2]);\n\t\t\t\treturn WE_POINTBOGUSRANGE;\n\t\t\t} //end if\n\t\t} //end for\n\n\t\tj = i+1 == w->numpoints ? 0 : i+1;\n\t\t\n\t// check the point is on the face plane\n\t\td = DotProduct (p1, facenormal) - facedist;\n\t\tif (d < -ON_EPSILON || d > ON_EPSILON)\n\t\t{\n\t\t\tsprintf(windingerror, \"winding point %d off plane\", i);\n\t\t\treturn WE_POINTOFFPLANE;\n\t\t} //end if\n\t\n\t// check the edge isnt degenerate\n\t\tp2 = w->p[j];\n\t\tVectorSubtract (p2, p1, dir);\n\t\t\n\t\tif (VectorLength (dir) < ON_EPSILON)\n\t\t{\n\t\t\tsprintf(windingerror, \"winding degenerate edge %d-%d\", i, j);\n\t\t\treturn WE_DEGENERATEEDGE;\n\t\t} //end if\n\t\t\t\n\t\tCrossProduct (facenormal, dir, edgenormal);\n\t\tVectorNormalize (edgenormal);\n\t\tedgedist = DotProduct (p1, edgenormal);\n\t\tedgedist += ON_EPSILON;\n\t\t\n\t// all other points must be on front side\n\t\tfor (j=0 ; j<w->numpoints ; j++)\n\t\t{\n\t\t\tif (j == i)\n\t\t\t\tcontinue;\n\t\t\td = DotProduct (w->p[j], edgenormal);\n\t\t\tif (d > edgedist)\n\t\t\t{\n\t\t\t\tsprintf(windingerror, \"winding non-convex\");\n\t\t\t\treturn WE_NONCONVEX;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\treturn WE_NONE;\n} //end of the function WindingError\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid RemoveEqualPoints(winding_t *w, float epsilon)\n{\n\tint i, nump;\n\tvec3_t v;\n\tvec3_t p[MAX_POINTS_ON_WINDING];\n\n\tVectorCopy(w->p[0], p[0]);\n\tnump = 1;\n\tfor (i = 1; i < w->numpoints; i++)\n\t{\n\t\tVectorSubtract(w->p[i], p[nump-1], v);\n\t\tif (VectorLength(v) > epsilon)\n\t\t{\n\t\t\tif (nump >= MAX_POINTS_ON_WINDING)\n\t\t\t\tError(\"RemoveColinearPoints: MAX_POINTS_ON_WINDING\");\n\t\t\tVectorCopy (w->p[i], p[nump]);\n\t\t\tnump++;\n\t\t} //end if\n\t} //end for\n\n\tif (nump == w->numpoints)\n\t\treturn;\n\n\tw->numpoints = nump;\n\tmemcpy(w->p, p, nump * sizeof(p[0]));\n} //end of the function RemoveEqualPoints\n//===========================================================================\n// adds the given point to a winding at the given spot\n// (for instance when spot is zero then the point is added at position zero)\n// the original winding is NOT freed\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\tthe new winding with the added point\n// Changes Globals:\t\t-\n//===========================================================================\nwinding_t *AddWindingPoint(winding_t *w, vec3_t point, int spot)\n{\n\tint i, j;\n\twinding_t *neww;\n\n\tif (spot > w->numpoints)\n\t{\n\t\tError(\"AddWindingPoint: num > w->numpoints\");\n\t} //end if\n\tif (spot < 0)\n\t{\n\t\tError(\"AddWindingPoint: num < 0\");\n\t} //end if\n\tneww = AllocWinding(w->numpoints + 1);\n\tneww->numpoints = w->numpoints + 1;\n\tfor (i = 0, j = 0; i < neww->numpoints; i++)\n\t{\n\t\tif (i == spot)\n\t\t{\n\t\t\tVectorCopy(point, neww->p[i]);\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tVectorCopy(w->p[j], neww->p[i]);\n\t\t\tj++;\n\t\t} //end else\n\t} //end for\n\treturn neww;\n} //end of the function AddWindingPoint\n//===========================================================================\n// the position where the new point should be added in the winding is\n// stored in *spot\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\ttrue if the point is on the winding\n// Changes Globals:\t\t-\n//===========================================================================\n#define MELT_ON_EPSILON\t\t0.2\n\nint PointOnWinding(winding_t *w, vec3_t normal, float dist, vec3_t point, int *spot)\n{\n\tint i, j;\n\tvec3_t v1, v2;\n\tvec3_t edgenormal, edgevec;\n\tfloat edgedist, dot;\n\n\t*spot = 0;\n\t//the point must be on the winding plane\n\tdot = DotProduct(point, normal) - dist;\n\tif (dot < -MELT_ON_EPSILON || dot > MELT_ON_EPSILON) return false;\n\t//\n\tfor (i = 0; i < w->numpoints; i++)\n\t{\n\t\tj = (i+1) % w->numpoints;\n\t\t//get a plane orthogonal to the winding plane through the edge\n\t\tVectorSubtract(w->p[j], w->p[i], edgevec);\n\t\tCrossProduct(normal, edgevec, edgenormal);\n\t\tVectorNormalize(edgenormal);\n\t\tedgedist = DotProduct(edgenormal, w->p[i]);\n\t\t//point must be not too far from the plane\n\t\tdot = DotProduct(point, edgenormal) - edgedist;\n\t\tif (dot < -MELT_ON_EPSILON || dot > MELT_ON_EPSILON) continue;\n\t\t//vector from first point of winding to the point to test\n\t\tVectorSubtract(point, w->p[i], v1);\n\t\t//vector from second point of winding to the point to test\n\t\tVectorSubtract(point, w->p[j], v2);\n\t\t//if the length of the vector is not larger than 0.5 units then\n\t\t//the point is assumend to be the same as one of the winding points\n\t\tif (VectorNormalize(v1) < 0.5) return false;\n\t\tif (VectorNormalize(v2) < 0.5) return false;\n\t\t//point must be between the two winding points\n\t\t//(the two vectors must be directed towards each other, and on the\n\t\t//same straight line)\n\t\tif (DotProduct(v1, v2) < -0.99)\n\t\t{\n\t\t\t*spot = i + 1;\n\t\t\treturn true;\n\t\t} //end if\n\t} //end for\n\treturn false;\n} //end of the function PointOnWinding\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint FindPlaneSeperatingWindings(winding_t *w1, winding_t *w2, vec3_t dir,\n\t\t\t\t\t\t\t\t\t\t\tvec3_t normal, float *dist)\n{\n\tint i, i2, j, j2, n;\n\tint sides1[3], sides2[3];\n\tfloat dist1, dist2, dot, diff;\n\tvec3_t normal1, normal2;\n\tvec3_t v1, v2;\n\n\tfor (i = 0; i < w1->numpoints; i++)\n\t{\n\t\ti2 = (i+1) % w1->numpoints;\n\t\t//\n\t\tVectorSubtract(w1->p[i2], w1->p[i], v1);\n\t\tif (VectorLength(v1) < 0.1)\n\t\t{\n\t\t\t//Log_Write(\"FindPlaneSeperatingWindings: winding1 with degenerate edge\\r\\n\");\n\t\t\tcontinue;\n\t\t} //end if\n\t\tCrossProduct(v1, dir, normal1);\n\t\tVectorNormalize(normal1);\n\t\tdist1 = DotProduct(normal1, w1->p[i]);\n\t\t//\n\t\tfor (j = 0; j < w2->numpoints; j++)\n\t\t{\n\t\t\tj2 = (j+1) % w2->numpoints;\n\t\t\t//\n\t\t\tVectorSubtract(w2->p[j2], w2->p[j], v2);\n\t\t\tif (VectorLength(v2) < 0.1)\n\t\t\t{\n\t\t\t\t//Log_Write(\"FindPlaneSeperatingWindings: winding2 with degenerate edge\\r\\n\");\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\tCrossProduct(v2, dir, normal2);\n\t\t\tVectorNormalize(normal2);\n\t\t\tdist2 = DotProduct(normal2, w2->p[j]);\n\t\t\t//\n\t\t\tdiff = dist1 - dist2;\n\t\t\tif (diff < -0.1 || diff > 0.1)\n\t\t\t{\n\t\t\t\tdist2 = -dist2;\n\t\t\t\tVectorNegate(normal2, normal2);\n\t\t\t\tdiff = dist1 - dist2;\n\t\t\t\tif (diff < -0.1 || diff > 0.1) continue;\n\t\t\t} //end if\n\t\t\t//check if the normal vectors are equal\n\t\t\tfor (n = 0; n < 3; n++)\n\t\t\t{\n\t\t\t\tdiff = normal1[n] - normal2[n];\n\t\t\t\tif (diff < -0.0001 || diff > 0.0001) break;\n\t\t\t} //end for\n\t\t\tif (n != 3) continue;\n\t\t\t//check on which side of the seperating plane the points of\n\t\t\t//the first winding are\n\t\t\tsides1[0] = sides1[1] = sides1[2] = 0;\n\t\t\tfor (n = 0; n < w1->numpoints; n++)\n\t\t\t{\n\t\t\t\tdot = DotProduct(w1->p[n], normal1) - dist1;\n\t\t\t\tif (dot > 0.1) sides1[0]++;\n\t\t\t\telse if (dot < -0.1) sides1[1]++;\n\t\t\t\telse sides1[2]++;\n\t\t\t} //end for\n\t\t\t//check on which side of the seperating plane the points of\n\t\t\t//the second winding are\n\t\t\tsides2[0] = sides2[1] = sides2[2] = 0;\n\t\t\tfor (n = 0; n < w2->numpoints; n++)\n\t\t\t{\n\t\t\t\t//used normal1 and dist1 (they are equal to normal2 and dist2)\n\t\t\t\tdot = DotProduct(w2->p[n], normal1) - dist1;\n\t\t\t\tif (dot > 0.1) sides2[0]++;\n\t\t\t\telse if (dot < -0.1) sides2[1]++;\n\t\t\t\telse sides2[2]++;\n\t\t\t} //end for\n\t\t\t//if the first winding has points at both sides\n\t\t\tif (sides1[0] && sides1[1])\n\t\t\t{\n\t\t\t\tLog_Write(\"FindPlaneSeperatingWindings: winding1 non-convex\\r\\n\");\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\t//if the second winding has points at both sides\n\t\t\tif (sides2[0] && sides2[1])\n\t\t\t{\n\t\t\t\tLog_Write(\"FindPlaneSeperatingWindings: winding2 non-convex\\r\\n\");\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\t//\n\t\t\tif ((!sides1[0] && !sides1[1]) || (!sides2[0] && !sides2[1]))\n\t\t\t{\n\t\t\t\t//don't use one of the winding planes as the seperating plane\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\t//the windings must be at different sides of the seperating plane\n\t\t\tif ((!sides1[0] && !sides2[1]) || (!sides1[1] && !sides2[0]))\n\t\t\t{\n\t\t\t\tVectorCopy(normal1, normal);\n\t\t\t\t*dist = dist1;\n\t\t\t\treturn true;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\treturn false;\n} //end of the function FindPlaneSeperatingWindings\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#define WCONVEX_EPSILON\t\t0.2\n\nint WindingsNonConvex(winding_t *w1, winding_t *w2,\n\t\t\t\t\t\t\t vec3_t normal1, vec3_t normal2,\n\t\t\t\t\t\t\t float dist1, float dist2)\n{\n\tint i;\n\n\tif (!w1 || !w2) return false;\n\n\t//check if one of the points of face1 is at the back of the plane of face2\n\tfor (i = 0; i < w1->numpoints; i++)\n\t{\n\t\tif (DotProduct(normal2, w1->p[i]) - dist2 > WCONVEX_EPSILON) return true;\n\t} //end for\n\t//check if one of the points of face2 is at the back of the plane of face1\n\tfor (i = 0; i < w2->numpoints; i++)\n\t{\n\t\tif (DotProduct(normal1, w2->p[i]) - dist1 > WCONVEX_EPSILON) return true;\n\t} //end for\n\n\treturn false;\n} //end of the function WindingsNonConvex\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n/*\n#define VERTEX_EPSILON\t\t0.5\n\nqboolean EqualVertexes(vec3_t v1, vec3_t v2)\n{\n\tfloat diff;\n\n\tdiff = v1[0] - v2[0];\n\tif (diff > -VERTEX_EPSILON && diff < VERTEX_EPSILON)\n\t{\n\t\tdiff = v1[1] - v2[1];\n\t\tif (diff > -VERTEX_EPSILON && diff < VERTEX_EPSILON)\n\t\t{\n\t\t\tdiff = v1[2] - v2[2];\n\t\t\tif (diff > -VERTEX_EPSILON && diff < VERTEX_EPSILON)\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t} //end if\n\t\t} //end if\n\t} //end if\n\treturn false;\n} //end of the function EqualVertexes\n\n#define\tCONTINUOUS_EPSILON\t0.001\n\nwinding_t *AAS_MergeWindings(winding_t *w1, winding_t *w2, vec3_t windingnormal)\n{\n\tint n, i, k;\n\tvec3_t normal, delta;\n\twinding_t *winding, *neww;\n\tfloat dist, dot;\n\tint p1, p2;\n\tint points[2][64];\n\tint numpoints[2] = {0, 0};\n\tint newnumpoints;\n\tint keep[2];\n\n\tif (!FindPlaneSeperatingWindings(w1, w2, windingnormal, normal, &dist)) return NULL;\n\n\t//for both windings\n\tfor (n = 0; n < 2; n++)\n\t{\n\t\tif (n == 0) winding = w1;\n\t\telse winding = w2;\n\t\t//get the points of the winding which are on the seperating plane\n\t\tfor (i = 0; i < winding->numpoints; i++)\n\t\t{\n\t\t\tdot = DotProduct(winding->p[i], normal) - dist;\n\t\t\tif (dot > -ON_EPSILON && dot < ON_EPSILON)\n\t\t\t{\n\t\t\t\t//don't allow more than 64 points on the seperating plane\n\t\t\t\tif (numpoints[n] >= 64) Error(\"AAS_MergeWindings: more than 64 points on seperating plane\\n\");\n\t\t\t\tpoints[n][numpoints[n]++] = i;\n\t\t\t} //end if\n\t\t} //end for\n\t\t//there must be at least two points of each winding on the seperating plane\n\t\tif (numpoints[n] < 2) return NULL;\n\t} //end for\n\n\t//if the first point of winding1 (which is on the seperating plane) is unequal\n\t//to the last point of winding2 (which is on the seperating plane)\n\tif (!EqualVertexes(w1->p[points[0][0]], w2->p[points[1][numpoints[1]-1]]))\n\t{\n\t\treturn NULL;\n\t} //end if\n\t//if the last point of winding1 (which is on the seperating plane) is unequal\n\t//to the first point of winding2 (which is on the seperating plane)\n\tif (!EqualVertexes(w1->p[points[0][numpoints[0]-1]], w2->p[points[1][0]]))\n\t{\n\t\treturn NULL;\n\t} //end if\n\t//\n\t// check slope of connected lines\n\t// if the slopes are colinear, the point can be removed\n\t//\n\t//first point of winding1 which is on the seperating plane\n\tp1 = points[0][0];\n\t//point before p1\n\tp2 = (p1 + w1->numpoints - 1) % w1->numpoints;\n\tVectorSubtract(w1->p[p1], w1->p[p2], delta);\n\tCrossProduct(windingnormal, delta, normal);\n\tVectorNormalize(normal, normal);\n\n\t//last point of winding2 which is on the seperating plane\n\tp1 = points[1][numpoints[1]-1];\n\t//point after p1\n\tp2 = (p1 + 1) % w2->numpoints;\n\tVectorSubtract(w2->p[p2], w2->p[p1], delta);\n\tdot = DotProduct(delta, normal);\n\tif (dot > CONTINUOUS_EPSILON) return NULL; //merging would create a non-convex polygon\n\tkeep[0] = (qboolean)(dot < -CONTINUOUS_EPSILON);\n\n\t//first point of winding2 which is on the seperating plane\n\tp1 = points[1][0];\n\t//point before p1\n\tp2 = (p1 + w2->numpoints - 1) % w2->numpoints;\n\tVectorSubtract(w2->p[p1], w2->p[p2], delta);\n\tCrossProduct(windingnormal, delta, normal);\n\tVectorNormalize(normal, normal);\n\n\t//last point of winding1 which is on the seperating plane\n\tp1 = points[0][numpoints[0]-1];\n\t//point after p1\n\tp2 = (p1 + 1) % w1->numpoints;\n\tVectorSubtract(w1->p[p2], w1->p[p1], delta);\n\tdot = DotProduct(delta, normal);\n\tif (dot > CONTINUOUS_EPSILON) return NULL; //merging would create a non-convex polygon\n\tkeep[1] = (qboolean)(dot < -CONTINUOUS_EPSILON);\n\n\t//number of points on the new winding\n\tnewnumpoints = w1->numpoints - numpoints[0] + w2->numpoints - numpoints[1] + 2;\n\t//allocate the winding\n\tneww = AllocWinding(newnumpoints);\n\tneww->numpoints = newnumpoints;\n\t//copy all the points\n\tk = 0;\n\t//for both windings\n\tfor (n = 0; n < 2; n++)\n\t{\n\t\tif (n == 0) winding = w1;\n\t\telse winding = w2;\n\t\t//copy the points of the winding starting with the last point on the\n\t\t//seperating plane and ending before the first point on the seperating plane\n\t\tfor (i = points[n][numpoints[n]-1]; i != points[n][0]; i = (i+1)%winding->numpoints)\n\t\t{\n\t\t\tif (k >= newnumpoints)\n\t\t\t{\n\t\t\t\tLog_Print(\"numpoints[0] = %d\\n\", numpoints[0]);\n\t\t\t\tLog_Print(\"numpoints[1] = %d\\n\", numpoints[1]);\n\t\t\t\tError(\"AAS_MergeWindings: k = %d >= newnumpoints = %d\\n\", k, newnumpoints);\n\t\t\t} //end if\n\t\t\tVectorCopy(winding->p[i], neww->p[k]);\n\t\t\tk++;\n\t\t} //end for\n\t} //end for\n\tRemoveEqualPoints(neww);\n\tif (!WindingIsOk(neww, 1))\n\t{\n\t\tLog_Print(\"AAS_MergeWindings: winding not ok after merging\\n\");\n\t\tFreeWinding(neww);\n\t\treturn NULL;\n\t} //end if\n\treturn neww;\n} //end of the function AAS_MergeWindings*/\n//#endif //ME\n"
  },
  {
    "path": "code/bspc/l_poly.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n//a winding gives the bounding points of a convex polygon\ntypedef struct\n{\n\tint\t\tnumpoints;\n\tvec3_t\tp[4];\t\t\t//variable sized\n} winding_t;\n\n#define\tMAX_POINTS_ON_WINDING\t96\n\n//you can define on_epsilon in the makefile as tighter\n#ifndef\tON_EPSILON\n#define\tON_EPSILON\t0.1\n#endif\n//winding errors\n#define WE_NONE\t\t\t\t\t\t0\n#define WE_NOTENOUGHPOINTS\t\t\t1\n#define WE_SMALLAREA\t\t\t\t\t2\n#define WE_POINTBOGUSRANGE\t\t\t3\n#define WE_POINTOFFPLANE\t\t\t4\n#define WE_DEGENERATEEDGE\t\t\t5\n#define WE_NONCONVEX\t\t\t\t\t6\n\n//allocates a winding\nwinding_t *AllocWinding (int points);\n//returns the area of the winding\nvec_t WindingArea (winding_t *w);\n//gives the center of the winding\nvoid WindingCenter (winding_t *w, vec3_t center);\n//clips the given winding to the given plane and gives the front\n//and back part of the clipped winding\nvoid ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist, \n\t\t\t\t\tvec_t epsilon, winding_t **front, winding_t **back);\n//returns the fragment of the given winding that is on the front\n//side of the cliping plane. The original is freed.\nwinding_t *ChopWinding (winding_t *in, vec3_t normal, vec_t dist);\n//returns a copy of the given winding\nwinding_t *CopyWinding (winding_t *w);\n//returns the reversed winding of the given one\nwinding_t *ReverseWinding (winding_t *w);\n//returns a base winding for the given plane\nwinding_t *BaseWindingForPlane (vec3_t normal, vec_t dist);\n//checks the winding for errors\nvoid CheckWinding (winding_t *w);\n//returns the plane normal and dist the winding is in\nvoid WindingPlane(winding_t *w, vec3_t normal, vec_t *dist);\n//removes colinear points from the winding\nvoid RemoveColinearPoints(winding_t *w);\n//returns on which side of the plane the winding is situated\nint WindingOnPlaneSide(winding_t *w, vec3_t normal, vec_t dist);\n//frees the winding\nvoid FreeWinding(winding_t *w);\n//gets the bounds of the winding\nvoid WindingBounds(winding_t *w, vec3_t mins, vec3_t maxs);\n//chops the winding with the given plane, the original winding is freed if clipped\nvoid ChopWindingInPlace (winding_t **w, vec3_t normal, vec_t dist, vec_t epsilon);\n//prints the winding points on STDOUT\nvoid pw(winding_t *w);\n//try to merge the two windings which are in the given plane\n//the original windings are undisturbed\n//the merged winding is returned when merging was possible\n//NULL is returned otherwise\nwinding_t *TryMergeWinding (winding_t *f1, winding_t *f2, vec3_t planenormal);\n//brute force winding merging... creates a convex winding out of\n//the two whatsoever\nwinding_t *MergeWindings(winding_t *w1, winding_t *w2, vec3_t planenormal);\n\n//#ifdef ME\nvoid ResetWindings(void);\n//returns the amount of winding memory\nint WindingMemory(void);\nint WindingPeakMemory(void);\nint ActiveWindings(void);\n//returns the winding error string\nchar *WindingErrorString(void);\n//returns one of the WE_ flags when the winding has errors\nint WindingError(winding_t *w);\n//removes equal points from the winding\nvoid RemoveEqualPoints(winding_t *w, float epsilon);\n//returns a winding with a point added at the given spot to the\n//given winding, original winding is NOT freed\nwinding_t *AddWindingPoint(winding_t *w, vec3_t point, int spot);\n//returns true if the point is on one of the winding 'edges'\n//when the point is on one of the edged the number of the first\n//point of the edge is stored in 'spot' \nint PointOnWinding(winding_t *w, vec3_t normal, float dist, vec3_t point, int *spot);\n//find a plane seperating the two windings\n//true is returned when the windings area adjacent\n//the seperating plane normal and distance area stored in 'normal' and 'dist'\n//this plane will contain both the piece of common edge of the two windings\n//and the vector 'dir'\nint FindPlaneSeperatingWindings(winding_t *w1, winding_t *w2, vec3_t dir,\n\t\t\t\t\t\t\t\t\t\t\tvec3_t normal, float *dist);\n//\nint WindingsNonConvex(winding_t *w1, winding_t *w2,\n\t\t\t\t\t\t\t vec3_t normal1, vec3_t normal2,\n\t\t\t\t\t\t\t float dist1, float dist2);\n//#endif //ME\n\n"
  },
  {
    "path": "code/bspc/l_qfiles.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#if defined(WIN32)|defined(_WIN32)\n#include <windows.h>\n#include <sys/types.h>\n#include <sys/stat.h>\n#else\n#include <glob.h>\n#include <sys/stat.h>\n#include <unistd.h>\n#endif\n\n#include \"qbsp.h\"\n\n//file extensions with their type\ntypedef struct qfile_exttype_s\n{\n\tchar *extension;\n\tint type;\n} qfile_exttyp_t;\n\nqfile_exttyp_t quakefiletypes[] =\n{\n\t{QFILEEXT_UNKNOWN, QFILETYPE_UNKNOWN},\n\t{QFILEEXT_PAK, QFILETYPE_PAK},\n\t{QFILEEXT_PK3, QFILETYPE_PK3},\n\t{QFILEEXT_SIN, QFILETYPE_PAK},\n\t{QFILEEXT_BSP, QFILETYPE_BSP},\n\t{QFILEEXT_MAP, QFILETYPE_MAP},\n\t{QFILEEXT_MDL, QFILETYPE_MDL},\n\t{QFILEEXT_MD2, QFILETYPE_MD2},\n\t{QFILEEXT_MD3, QFILETYPE_MD3},\n\t{QFILEEXT_WAL, QFILETYPE_WAL},\n\t{QFILEEXT_WAV, QFILETYPE_WAV},\n\t{QFILEEXT_AAS, QFILETYPE_AAS},\n\t{NULL, 0}\n};\n\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint QuakeFileExtensionType(char *extension)\n{\n\tint i;\n\n\tfor (i = 0; quakefiletypes[i].extension; i++)\n\t{\n\t\tif (!stricmp(extension, quakefiletypes[i].extension))\n\t\t{\n\t\t\treturn quakefiletypes[i].type;\n\t\t} //end if\n\t} //end for\n\treturn QFILETYPE_UNKNOWN;\n} //end of the function QuakeFileExtensionType\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nchar *QuakeFileTypeExtension(int type)\n{\n\tint i;\n\n\tfor (i = 0; quakefiletypes[i].extension; i++)\n\t{\n\t\tif (quakefiletypes[i].type == type)\n\t\t{\n\t\t\treturn quakefiletypes[i].extension;\n\t\t} //end if\n\t} //end for\n\treturn QFILEEXT_UNKNOWN;\n} //end of the function QuakeFileExtension\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint QuakeFileType(char *filename)\n{\n\tchar ext[_MAX_PATH] = \".\";\n\n\tExtractFileExtension(filename, ext+1);\n\treturn QuakeFileExtensionType(ext);\n} //end of the function QuakeFileTypeFromFileName\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nchar *StringContains(char *str1, char *str2, int casesensitive)\n{\n\tint len, i, j;\n\n\tlen = strlen(str1) - strlen(str2);\n\tfor (i = 0; i <= len; i++, str1++)\n\t{\n\t\tfor (j = 0; str2[j]; j++)\n\t\t{\n\t\t\tif (casesensitive)\n\t\t\t{\n\t\t\t\tif (str1[j] != str2[j]) break;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (toupper(str1[j]) != toupper(str2[j])) break;\n\t\t\t} //end else\n\t\t} //end for\n\t\tif (!str2[j]) return str1;\n\t} //end for\n\treturn NULL;\n} //end of the function StringContains\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint FileFilter(char *filter, char *filename, int casesensitive)\n{\n\tchar buf[1024];\n\tchar *ptr;\n\tint i, found;\n\n\twhile(*filter)\n\t{\n\t\tif (*filter == '*')\n\t\t{\n\t\t\tfilter++;\n\t\t\tfor (i = 0; *filter; i++)\n\t\t\t{\n\t\t\t\tif (*filter == '*' || *filter == '?') break;\n\t\t\t\tbuf[i] = *filter;\n\t\t\t\tfilter++;\n\t\t\t} //end for\n\t\t\tbuf[i] = '\\0';\n\t\t\tif (strlen(buf))\n\t\t\t{\n\t\t\t\tptr = StringContains(filename, buf, casesensitive);\n\t\t\t\tif (!ptr) return false;\n\t\t\t\tfilename = ptr + strlen(buf);\n\t\t\t} //end if\n\t\t} //end if\n\t\telse if (*filter == '?')\n\t\t{\n\t\t\tfilter++;\n\t\t\tfilename++;\n\t\t} //end else if\n\t\telse if (*filter == '[' && *(filter+1) == '[')\n\t\t{\n\t\t\tfilter++;\n\t\t} //end if\n\t\telse if (*filter == '[')\n\t\t{\n\t\t\tfilter++;\n\t\t\tfound = false;\n\t\t\twhile(*filter && !found)\n\t\t\t{\n\t\t\t\tif (*filter == ']' && *(filter+1) != ']') break;\n\t\t\t\tif (*(filter+1) == '-' && *(filter+2) && (*(filter+2) != ']' || *(filter+3) == ']'))\n\t\t\t\t{\n\t\t\t\t\tif (casesensitive)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (*filename >= *filter && *filename <= *(filter+2)) found = true;\n\t\t\t\t\t} //end if\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tif (toupper(*filename) >= toupper(*filter) &&\n\t\t\t\t\t\t\ttoupper(*filename) <= toupper(*(filter+2))) found = true;\n\t\t\t\t\t} //end else\n\t\t\t\t\tfilter += 3;\n\t\t\t\t} //end if\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (casesensitive)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (*filter == *filename) found = true;\n\t\t\t\t\t} //end if\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tif (toupper(*filter) == toupper(*filename)) found = true;\n\t\t\t\t\t} //end else\n\t\t\t\t\tfilter++;\n\t\t\t\t} //end else\n\t\t\t} //end while\n\t\t\tif (!found) return false;\n\t\t\twhile(*filter)\n\t\t\t{\n\t\t\t\tif (*filter == ']' && *(filter+1) != ']') break;\n\t\t\t\tfilter++;\n\t\t\t} //end while\n\t\t\tfilter++;\n\t\t\tfilename++;\n\t\t} //end else if\n\t\telse\n\t\t{\n\t\t\tif (casesensitive)\n\t\t\t{\n\t\t\t\tif (*filter != *filename) return false;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (toupper(*filter) != toupper(*filename)) return false;\n\t\t\t} //end else\n\t\t\tfilter++;\n\t\t\tfilename++;\n\t\t} //end else\n\t} //end while\n\treturn true;\n} //end of the function FileFilter\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nquakefile_t *FindQuakeFilesInZip(char *zipfile, char *filter)\n{\n\tunzFile\t\t\tuf;\n\tint\t\t\t\terr;\n\tunz_global_info gi;\n\tchar\t\t\tfilename_inzip[MAX_PATH];\n\tunz_file_info\tfile_info;\n\tint\t\t\t\ti;\n\tquakefile_t\t\t*qfiles, *lastqf, *qf;\n\n\tuf = unzOpen(zipfile);\n\terr = unzGetGlobalInfo(uf, &gi);\n\n\tif (err != UNZ_OK) return NULL;\n\n\tunzGoToFirstFile(uf);\n\n\tqfiles = NULL;\n\tlastqf = NULL;\n\tfor (i = 0; i < gi.number_entry; i++)\n\t{\n\t\terr = unzGetCurrentFileInfo(uf, &file_info, filename_inzip, sizeof(filename_inzip), NULL,0,NULL,0);\n\t\tif (err != UNZ_OK) break;\n\n\t\tConvertPath(filename_inzip);\n\t\tif (FileFilter(filter, filename_inzip, false))\n\t\t{\n\t\t\tqf = malloc(sizeof(quakefile_t));\n\t\t\tif (!qf) Error(\"out of memory\");\n\t\t\tmemset(qf, 0, sizeof(quakefile_t));\n\t\t\tstrcpy(qf->pakfile, zipfile);\n\t\t\tstrcpy(qf->filename, zipfile);\n\t\t\tstrcpy(qf->origname, filename_inzip);\n\t\t\tqf->zipfile = true;\n\t\t\t//memcpy( &buildBuffer[i].zipfileinfo, (unz_s*)uf, sizeof(unz_s));\n\t\t\tmemcpy(&qf->zipinfo, (unz_s*)uf, sizeof(unz_s));\n\t\t\tqf->offset = 0;\n\t\t\tqf->length = file_info.uncompressed_size;\n\t\t\tqf->type = QuakeFileType(filename_inzip);\n\t\t\t//add the file ot the list\n\t\t\tqf->next = NULL;\n\t\t\tif (lastqf) lastqf->next = qf;\n\t\t\telse qfiles = qf;\n\t\t\tlastqf = qf;\n\t\t} //end if\n\t\tunzGoToNextFile(uf);\n\t} //end for\n\n\tunzClose(uf);\n\n\treturn qfiles;\n} //end of the function FindQuakeFilesInZip\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nquakefile_t *FindQuakeFilesInPak(char *pakfile, char *filter)\n{\n\tFILE *fp;\n\tdpackheader_t packheader;\n\tdsinpackfile_t *packfiles;\n\tdpackfile_t *idpackfiles;\n\tquakefile_t *qfiles, *lastqf, *qf;\n\tint numpackdirs, i;\n\n\tqfiles = NULL;\n\tlastqf = NULL;\n\t//open the pak file\n\tfp = fopen(pakfile, \"rb\");\n\tif (!fp)\n\t{\n\t\tWarning(\"can't open pak file %s\", pakfile);\n\t\treturn NULL;\n\t} //end if\n\t//read pak header, check for valid pak id and seek to the dir entries\n\tif ((fread(&packheader, 1, sizeof(dpackheader_t), fp) != sizeof(dpackheader_t))\n\t\t|| (packheader.ident != IDPAKHEADER && packheader.ident != SINPAKHEADER)\n\t\t||\t(fseek(fp, LittleLong(packheader.dirofs), SEEK_SET))\n\t\t)\n\t{\n\t\tfclose(fp);\n\t\tWarning(\"invalid pak file %s\", pakfile);\n\t\treturn NULL;\n\t} //end if\n\t//if it is a pak file from id software\n\tif (packheader.ident == IDPAKHEADER)\n\t{\n\t\t//number of dir entries in the pak file\n\t\tnumpackdirs = LittleLong(packheader.dirlen) / sizeof(dpackfile_t);\n\t\tidpackfiles = (dpackfile_t *) malloc(numpackdirs * sizeof(dpackfile_t));\n\t\tif (!idpackfiles) Error(\"out of memory\");\n\t\t//read the dir entry\n\t\tif (fread(idpackfiles, sizeof(dpackfile_t), numpackdirs, fp) != numpackdirs)\n\t\t{\n\t\t\tfclose(fp);\n\t\t\tfree(idpackfiles);\n\t\t\tWarning(\"can't read the Quake pak file dir entries from %s\", pakfile);\n\t\t\treturn NULL;\n\t\t} //end if\n\t\tfclose(fp);\n\t\t//convert to sin pack files\n\t\tpackfiles = (dsinpackfile_t *) malloc(numpackdirs * sizeof(dsinpackfile_t));\n\t\tif (!packfiles) Error(\"out of memory\");\n\t\tfor (i = 0; i < numpackdirs; i++)\n\t\t{\n\t\t\tstrcpy(packfiles[i].name, idpackfiles[i].name);\n\t\t\tpackfiles[i].filepos = LittleLong(idpackfiles[i].filepos);\n\t\t\tpackfiles[i].filelen = LittleLong(idpackfiles[i].filelen);\n\t\t} //end for\n\t\tfree(idpackfiles);\n\t} //end if\n\telse //its a Sin pack file\n\t{\n\t\t//number of dir entries in the pak file\n\t\tnumpackdirs = LittleLong(packheader.dirlen) / sizeof(dsinpackfile_t);\n\t\tpackfiles = (dsinpackfile_t *) malloc(numpackdirs * sizeof(dsinpackfile_t));\n\t\tif (!packfiles) Error(\"out of memory\");\n\t\t//read the dir entry\n\t\tif (fread(packfiles, sizeof(dsinpackfile_t), numpackdirs, fp) != numpackdirs)\n\t\t{\n\t\t\tfclose(fp);\n\t\t\tfree(packfiles);\n\t\t\tWarning(\"can't read the Sin pak file dir entries from %s\", pakfile);\n\t\t\treturn NULL;\n\t\t} //end if\n\t\tfclose(fp);\n\t\tfor (i = 0; i < numpackdirs; i++)\n\t\t{\n\t\t\tpackfiles[i].filepos = LittleLong(packfiles[i].filepos);\n\t\t\tpackfiles[i].filelen = LittleLong(packfiles[i].filelen);\n\t\t} //end for\n\t} //end else\n\t//\n\tfor (i = 0; i < numpackdirs; i++)\n\t{\n\t\tConvertPath(packfiles[i].name);\n\t\tif (FileFilter(filter, packfiles[i].name, false))\n\t\t{\n\t\t\tqf = malloc(sizeof(quakefile_t));\n\t\t\tif (!qf) Error(\"out of memory\");\n\t\t\tmemset(qf, 0, sizeof(quakefile_t));\n\t\t\tstrcpy(qf->pakfile, pakfile);\n\t\t\tstrcpy(qf->filename, pakfile);\n\t\t\tstrcpy(qf->origname, packfiles[i].name);\n\t\t\tqf->zipfile = false;\n\t\t\tqf->offset = packfiles[i].filepos;\n\t\t\tqf->length = packfiles[i].filelen;\n\t\t\tqf->type = QuakeFileType(packfiles[i].name);\n\t\t\t//add the file ot the list\n\t\t\tqf->next = NULL;\n\t\t\tif (lastqf) lastqf->next = qf;\n\t\t\telse qfiles = qf;\n\t\t\tlastqf = qf;\n\t\t} //end if\n\t} //end for\n\tfree(packfiles);\n\treturn qfiles;\n} //end of the function FindQuakeFilesInPak\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nquakefile_t *FindQuakeFilesWithPakFilter(char *pakfilter, char *filter)\n{\n#if defined(WIN32)|defined(_WIN32)\n\tWIN32_FIND_DATA filedata;\n\tHWND handle;\n\tstruct _stat statbuf;\n#else\n\tglob_t globbuf;\n\tstruct stat statbuf;\n\tint j;\n#endif\n\tquakefile_t *qfiles, *lastqf, *qf;\n\tchar pakfile[_MAX_PATH], filename[_MAX_PATH], *str;\n\tint done;\n\n\tqfiles = NULL;\n\tlastqf = NULL;\n\tif (pakfilter && strlen(pakfilter))\n\t{\n#if defined(WIN32)|defined(_WIN32)\n\t\thandle = FindFirstFile(pakfilter, &filedata);\n\t\tdone = (handle == INVALID_HANDLE_VALUE);\n\t\twhile(!done)\n\t\t{\n\t\t\t_splitpath(pakfilter, pakfile, NULL, NULL, NULL);\n\t\t\t_splitpath(pakfilter, NULL, &pakfile[strlen(pakfile)], NULL, NULL);\n\t\t\tAppendPathSeperator(pakfile, _MAX_PATH);\n\t\t\tstrcat(pakfile, filedata.cFileName);\n\t\t\t_stat(pakfile, &statbuf);\n#else\n\t\tglob(pakfilter, 0, NULL, &globbuf);\n\t\tfor (j = 0; j < globbuf.gl_pathc; j++)\n\t\t{\n\t\t\tstrcpy(pakfile, globbuf.gl_pathv[j]);\n\t\t\tstat(pakfile, &statbuf);\n#endif\n\t\t\t//if the file with .pak or .pk3 is a folder\n\t\t\tif (statbuf.st_mode & S_IFDIR)\n\t\t\t{\n\t\t\t\tstrcpy(filename, pakfilter);\n\t\t\t\tAppendPathSeperator(filename, _MAX_PATH);\n\t\t\t\tstrcat(filename, filter);\n\t\t\t\tqf = FindQuakeFilesWithPakFilter(NULL, filename);\n\t\t\t\tif (lastqf) lastqf->next = qf;\n\t\t\t\telse qfiles = qf;\n\t\t\t\tlastqf = qf;\n\t\t\t\twhile(lastqf->next) lastqf = lastqf->next;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n#if defined(WIN32)|defined(_WIN32)\n\t\t\t\tstr = StringContains(pakfile, \".pk3\", false);\n#else\n\t\t\t\tstr = StringContains(pakfile, \".pk3\", true);\n#endif\n\t\t\t\tif (str && str == pakfile + strlen(pakfile) - strlen(\".pk3\"))\n\t\t\t\t{\n\t\t\t\t\tqf = FindQuakeFilesInZip(pakfile, filter);\n\t\t\t\t} //end if\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tqf = FindQuakeFilesInPak(pakfile, filter);\n\t\t\t\t} //end else\n\t\t\t\t//\n\t\t\t\tif (qf)\n\t\t\t\t{\n\t\t\t\t\tif (lastqf) lastqf->next = qf;\n\t\t\t\t\telse qfiles = qf;\n\t\t\t\t\tlastqf = qf;\n\t\t\t\t\twhile(lastqf->next) lastqf = lastqf->next;\n\t\t\t\t} //end if\n\t\t\t} //end else\n\t\t\t//\n#if defined(WIN32)|defined(_WIN32)\n\t\t\t//find the next file\n\t\t\tdone = !FindNextFile(handle, &filedata);\n\t\t} //end while\n#else\n\t\t} //end for\n\t\tglobfree(&globbuf);\n#endif\n\t} //end if\n\telse\n\t{\n#if defined(WIN32)|defined(_WIN32)\n\t\thandle = FindFirstFile(filter, &filedata);\n\t\tdone = (handle == INVALID_HANDLE_VALUE);\n\t\twhile(!done)\n\t\t{\n\t\t\t_splitpath(filter, filename, NULL, NULL, NULL);\n\t\t\t_splitpath(filter, NULL, &filename[strlen(filename)], NULL, NULL);\n\t\t\tAppendPathSeperator(filename, _MAX_PATH);\n\t\t\tstrcat(filename, filedata.cFileName);\n#else\n\t\tglob(filter, 0, NULL, &globbuf);\n\t\tfor (j = 0; j < globbuf.gl_pathc; j++)\n\t\t{\n\t\t\tstrcpy(filename, globbuf.gl_pathv[j]);\n#endif\n\t\t\t//\n\t\t\tqf = malloc(sizeof(quakefile_t));\n\t\t\tif (!qf) Error(\"out of memory\");\n\t\t\tmemset(qf, 0, sizeof(quakefile_t));\n\t\t\tstrcpy(qf->pakfile, \"\");\n\t\t\tstrcpy(qf->filename, filename);\n\t\t\tstrcpy(qf->origname, filename);\n\t\t\tqf->offset = 0;\n\t\t\tqf->length = 0;\n\t\t\tqf->type = QuakeFileType(filename);\n\t\t\t//add the file ot the list\n\t\t\tqf->next = NULL;\n\t\t\tif (lastqf) lastqf->next = qf;\n\t\t\telse qfiles = qf;\n\t\t\tlastqf = qf;\n#if defined(WIN32)|defined(_WIN32)\n\t\t\t//find the next file\n\t\t\tdone = !FindNextFile(handle, &filedata);\n\t\t} //end while\n#else\n\t\t} //end for\n\t\tglobfree(&globbuf);\n#endif\n\t} //end else\n\treturn qfiles;\n} //end of the function FindQuakeFilesWithPakFilter\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nquakefile_t *FindQuakeFiles(char *filter)\n{\n\tchar *str;\n\tchar newfilter[_MAX_PATH];\n\tchar pakfilter[_MAX_PATH];\n\tchar filefilter[_MAX_PATH];\n\n\tstrcpy(newfilter, filter);\n\tConvertPath(newfilter);\n\tstrcpy(pakfilter, newfilter);\n\n\tstr = StringContains(pakfilter, \".pak\", false);\n\tif (!str) str = StringContains(pakfilter, \".pk3\", false);\n\n\tif (str)\n\t{\n\t\tstr += strlen(\".pak\");\n\t\tif (*str)\n\t\t{\n\t\t\t*str++ = '\\0';\n\t\t\twhile(*str == '\\\\' || *str == '/') str++;\n\t\t\tstrcpy(filefilter, str);\n\t\t\treturn FindQuakeFilesWithPakFilter(pakfilter, filefilter);\n\t\t} //end if\n\t} //end else\n\treturn FindQuakeFilesWithPakFilter(NULL, newfilter);\n} //end of the function FindQuakeFiles\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint LoadQuakeFile(quakefile_t *qf, void **bufferptr)\n{\n\tFILE *fp;\n\tvoid *buffer;\n\tint length;\n\tunzFile zf;\n\n\tif (qf->zipfile)\n\t{\n\t\t//open the zip file\n\t\tzf = unzOpen(qf->pakfile);\n\t\t//set the file pointer\n\t\tqf->zipinfo.file = ((unz_s *) zf)->file;\n\t\t//open the Quake file in the zip file\n\t\tunzOpenCurrentFile(&qf->zipinfo);\n\t\t//allocate memory for the buffer\n\t\tlength = qf->length;\n\t\tbuffer = GetMemory(length+1);\n\t\t//read the Quake file from the zip file\n\t\tlength = unzReadCurrentFile(&qf->zipinfo, buffer, length);\n\t\t//close the Quake file in the zip file\n\t\tunzCloseCurrentFile(&qf->zipinfo);\n\t\t//close the zip file\n\t\tunzClose(zf);\n\n\t\t*bufferptr = buffer;\n\t\treturn length;\n\t} //end if\n\telse\n\t{\n\t\tfp = SafeOpenRead(qf->filename);\n\t\tif (qf->offset) fseek(fp, qf->offset, SEEK_SET);\n\t\tlength = qf->length;\n\t\tif (!length) length = Q_filelength(fp);\n\t\tbuffer = GetMemory(length+1);\n\t\t((char *)buffer)[length] = 0;\n\t\tSafeRead(fp, buffer, length);\n\t\tfclose(fp);\n\n\t\t*bufferptr = buffer;\n\t\treturn length;\n\t} //end else\n} //end of the function LoadQuakeFile\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint ReadQuakeFile(quakefile_t *qf, void *buffer, int offset, int length)\n{\n\tFILE *fp;\n\tint read;\n\tunzFile zf;\n\tchar tmpbuf[1024];\n\n\tif (qf->zipfile)\n\t{\n\t\t//open the zip file\n\t\tzf = unzOpen(qf->pakfile);\n\t\t//set the file pointer\n\t\tqf->zipinfo.file = ((unz_s *) zf)->file;\n\t\t//open the Quake file in the zip file\n\t\tunzOpenCurrentFile(&qf->zipinfo);\n\t\t//\n\t\twhile(offset > 0)\n\t\t{\n\t\t\tread = offset;\n\t\t\tif (read > sizeof(tmpbuf)) read = sizeof(tmpbuf);\n\t\t\tunzReadCurrentFile(&qf->zipinfo, tmpbuf, read);\n\t\t\toffset -= read;\n\t\t} //end while\n\t\t//read the Quake file from the zip file\n\t\tlength = unzReadCurrentFile(&qf->zipinfo, buffer, length);\n\t\t//close the Quake file in the zip file\n\t\tunzCloseCurrentFile(&qf->zipinfo);\n\t\t//close the zip file\n\t\tunzClose(zf);\n\n\t\treturn length;\n\t} //end if\n\telse\n\t{\n\t\tfp = SafeOpenRead(qf->filename);\n\t\tif (qf->offset) fseek(fp, qf->offset, SEEK_SET);\n\t\tif (offset) fseek(fp, offset, SEEK_CUR);\n\t\tSafeRead(fp, buffer, length);\n\t\tfclose(fp);\n\n\t\treturn length;\n\t} //end else\n} //end of the function ReadQuakeFile\n"
  },
  {
    "path": "code/bspc/l_qfiles.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"../qcommon/unzip.h\"\n\n#define QFILETYPE_UNKNOWN\t\t\t0x8000\n#define QFILETYPE_PAK\t\t\t\t0x0001\n#define QFILETYPE_PK3\t\t\t\t0x0002\n#define QFILETYPE_BSP\t\t\t\t0x0004\n#define QFILETYPE_MAP\t\t\t\t0x0008\n#define QFILETYPE_MDL\t\t\t\t0x0010\n#define QFILETYPE_MD2\t\t\t\t0x0020\n#define QFILETYPE_MD3\t\t\t\t0x0040\n#define QFILETYPE_WAL\t\t\t\t0x0080\n#define QFILETYPE_WAV\t\t\t\t0x0100\n#define QFILETYPE_AAS\t\t\t\t0x4000\n\n#define QFILEEXT_UNKNOWN\t\t\t\"\"\n#define QFILEEXT_PAK\t\t\t\t\".PAK\"\n#define QFILEEXT_PK3\t\t\t\t\".PK3\"\n#define QFILEEXT_SIN\t\t\t\t\".SIN\"\n#define QFILEEXT_BSP\t\t\t\t\".BSP\"\n#define QFILEEXT_MAP\t\t\t\t\".MAP\"\n#define QFILEEXT_MDL\t\t\t\t\".MDL\"\n#define QFILEEXT_MD2\t\t\t\t\".MD2\"\n#define QFILEEXT_MD3\t\t\t\t\".MD3\"\n#define QFILEEXT_WAL\t\t\t\t\".WAL\"\n#define QFILEEXT_WAV\t\t\t\t\".WAV\"\n#define QFILEEXT_AAS\t\t\t\t\".AAS\"\n\n//maximum path length\n#ifndef _MAX_PATH\n\t#define _MAX_PATH\t\t\t\t1024\n#endif\n\n//for Sin packs\n#define MAX_PAK_FILENAME_LENGTH 120\n#define SINPAKHEADER\t\t(('K'<<24)+('A'<<16)+('P'<<8)+'S')\n\ntypedef struct\n{\n\tchar\tname[MAX_PAK_FILENAME_LENGTH];\n\tint\tfilepos, filelen;\n} dsinpackfile_t;\n\ntypedef struct quakefile_s\n{\n\tchar pakfile[_MAX_PATH];\n\tchar filename[_MAX_PATH];\n\tchar origname[_MAX_PATH];\n\tint zipfile;\n\tint type;\n\tint offset;\n\tint length;\n\tunz_s zipinfo;\n\tstruct quakefile_s *next;\n} quakefile_t;\n\n//returns the file extension for the given type\nchar *QuakeFileTypeExtension(int type);\n//returns the file type for the given extension\nint QuakeFileExtensionType(char *extension);\n//return the Quake file type for the given file\nint QuakeFileType(char *filename);\n//returns true if the filename complies to the filter\nint FileFilter(char *filter, char *filename, int casesensitive);\n//find Quake files using the given filter\nquakefile_t *FindQuakeFiles(char *filter);\n//load the given Quake file, returns the length of the file\nint LoadQuakeFile(quakefile_t *qf, void **bufferptr);\n//read part of a Quake file into the buffer\nint ReadQuakeFile(quakefile_t *qf, void *buffer, int offset, int length);\n"
  },
  {
    "path": "code/bspc/l_threads.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"l_cmd.h\"\n#include \"l_threads.h\"\n#include \"l_log.h\"\n#include \"l_mem.h\"\n\n#define\tMAX_THREADS\t64\n\n//#define THREAD_DEBUG\n\nint dispatch;\nint workcount;\nint oldf;\nqboolean pacifier;\nqboolean\tthreaded;\nvoid (*workfunction) (int);\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint GetThreadWork(void)\n{\n\tint\tr;\n\tint\tf;\n\n\tThreadLock();\n\n\tif (dispatch == workcount)\n\t{\n\t\tThreadUnlock ();\n\t\treturn -1;\n\t}\n\n\tf = 10*dispatch / workcount;\n\tif (f != oldf)\n\t{\n\t\toldf = f;\n\t\tif (pacifier)\n\t\t\tprintf (\"%i...\", f);\n\t} //end if\n\n\tr = dispatch;\n\tdispatch++;\n\tThreadUnlock ();\n\n\treturn r;\n} //end of the function GetThreadWork\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadWorkerFunction(int threadnum)\n{\n\tint\t\twork;\n\n\twhile(1)\n\t{\n\t\twork = GetThreadWork ();\n\t\tif (work == -1)\n\t\t\tbreak;\n//printf (\"thread %i, work %i\\n\", threadnum, work);\n\t\tworkfunction(work);\n\t} //end while\n} //end of the function ThreadWorkerFunction\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid RunThreadsOnIndividual (int workcnt, qboolean showpacifier, void(*func)(int))\n{\n\tif (numthreads == -1)\n\t\tThreadSetDefault ();\n\tworkfunction = func;\n\tRunThreadsOn (workcnt, showpacifier, ThreadWorkerFunction);\n} //end of the function RunThreadsOnIndividual\n\n\n//===================================================================\n//\n// WIN32\n//\n//===================================================================\n\n#if defined(WIN32) || defined(_WIN32)\n\n#define USED\n\n#include <windows.h>\n\ntypedef struct thread_s\n{\n\tHANDLE handle;\n\tint threadid;\n\tint id;\n\tstruct thread_s *next;\n} thread_t;\n\nthread_t *firstthread;\nthread_t *lastthread;\nint currentnumthreads;\nint currentthreadid;\n\nint numthreads = 1;\nCRITICAL_SECTION crit;\nHANDLE semaphore;\nstatic int enter;\nstatic int numwaitingthreads = 0;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadSetDefault(void)\n{\n\tSYSTEM_INFO info;\n\n\tif (numthreads == -1)\t// not set manually\n\t{\n\t\tGetSystemInfo (&info);\n\t\tnumthreads = info.dwNumberOfProcessors;\n\t\tif (numthreads < 1 || numthreads > 32)\n\t\t\tnumthreads = 1;\n\t} //end if\n\tqprintf (\"%i threads\\n\", numthreads);\n} //end of the function ThreadSetDefault\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadLock(void)\n{\n\tif (!threaded)\n\t{\n\t\tError(\"ThreadLock: !threaded\");\n\t\treturn;\n\t} //end if\n\tEnterCriticalSection(&crit);\n\tif (enter)\n\t\tError(\"Recursive ThreadLock\\n\");\n\tenter = 1;\n} //end of the function ThreadLock\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadUnlock (void)\n{\n\tif (!threaded)\n\t{\n\t\tError(\"ThreadUnlock: !threaded\");\n\t\treturn;\n\t} //end if\n\tif (!enter)\n\t\tError(\"ThreadUnlock without lock\\n\");\n\tenter = 0;\n\tLeaveCriticalSection(&crit);\n} //end of the function ThreadUnlock\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadSetupLock(void)\n{\n\tLog_Print(\"Win32 multi-threading\\n\");\n\tInitializeCriticalSection(&crit);\n\tthreaded = true;\t//Stupid me... forgot this!!!\n\tcurrentnumthreads = 0;\n\tcurrentthreadid = 0;\n} //end of the function ThreadInitLock\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadShutdownLock(void)\n{\n\tDeleteCriticalSection(&crit);\n\tthreaded = false;\t//Stupid me... forgot this!!!\n} //end of the function ThreadShutdownLock\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadSetupSemaphore(void)\n{\n\tsemaphore = CreateSemaphore(NULL, 0, 99999999, \"bspc\");\n} //end of the function ThreadSetupSemaphore\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadShutdownSemaphore(void)\n{\n} //end of the function ThreadShutdownSemaphore\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadSemaphoreWait(void)\n{\n\tWaitForSingleObject(semaphore, INFINITE);\n} //end of the function ThreadSemaphoreWait\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadSemaphoreIncrease(int count)\n{\n\tReleaseSemaphore(semaphore, count, NULL);\n} //end of the function ThreadSemaphoreIncrease\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid RunThreadsOn(int workcnt, qboolean showpacifier, void(*func)(int))\n{\n\tint\t\tthreadid[MAX_THREADS];\n\tHANDLE\tthreadhandle[MAX_THREADS];\n\tint\t\ti;\n\tint\t\tstart, end;\n\n\tLog_Print(\"Win32 multi-threading\\n\");\n\tstart = I_FloatTime ();\n\tdispatch = 0;\n\tworkcount = workcnt;\n\toldf = -1;\n\tpacifier = showpacifier;\n\tthreaded = true;\n\n\tif (numthreads == -1)\n\t\tThreadSetDefault ();\n\n\tif (numthreads < 1 || numthreads > MAX_THREADS) numthreads = 1;\n\t//\n\t// run threads in parallel\n\t//\n\tInitializeCriticalSection (&crit);\n\n\tnumwaitingthreads = 0;\n\n\tif (numthreads == 1)\n\t{\t// use same thread\n\t\tfunc (0);\n\t} //end if\n\telse\n\t{\n//\t\tprintf(\"starting %d threads\\n\", numthreads);\n\t\tfor (i = 0; i < numthreads; i++)\n\t\t{\n\t\t\tthreadhandle[i] = CreateThread(\n\t\t\t   NULL,\t// LPSECURITY_ATTRIBUTES lpsa,\n\t\t\t   0,\t\t// DWORD cbStack,\n\t\t\t   (LPTHREAD_START_ROUTINE)func,\t// LPTHREAD_START_ROUTINE lpStartAddr,\n\t\t\t   (LPVOID)i,\t// LPVOID lpvThreadParm,\n\t\t\t   0,\t\t\t//   DWORD fdwCreate,\n\t\t\t   &threadid[i]);\n//\t\t\tprintf(\"started thread %d\\n\", i);\n\t\t} //end for\n\n\t\tfor (i = 0; i < numthreads; i++)\n\t\t\tWaitForSingleObject (threadhandle[i], INFINITE);\n\t} //end else\n\tDeleteCriticalSection (&crit);\n\n\tthreaded = false;\n\tend = I_FloatTime ();\n\tif (pacifier) printf (\" (%i)\\n\", end-start);\n} //end of the function RunThreadsOn\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AddThread(void (*func)(int))\n{\n\tthread_t *thread;\n\n\tif (numthreads == 1)\n\t{\n\t\tif (currentnumthreads >= numthreads) return;\n\t\tcurrentnumthreads++;\n\t\tfunc(-1);\n\t\tcurrentnumthreads--;\n\t} //end if\n\telse\n\t{\n\t\tThreadLock();\n\t\tif (currentnumthreads >= numthreads)\n\t\t{\n\t\t\tThreadUnlock();\n\t\t\treturn;\n\t\t} //end if\n\t\t//allocate new thread\n\t\tthread = GetMemory(sizeof(thread_t));\n\t\tif (!thread) Error(\"can't allocate memory for thread\\n\");\n\n\t\t//\n\t\tthread->threadid = currentthreadid;\n\t\tthread->handle = CreateThread(\n\t\t\t\t   NULL,\t// LPSECURITY_ATTRIBUTES lpsa,\n\t\t\t\t   0,\t\t// DWORD cbStack,\n\t\t\t\t   (LPTHREAD_START_ROUTINE)func,\t// LPTHREAD_START_ROUTINE lpStartAddr,\n\t\t\t\t   (LPVOID) thread->threadid,\t\t\t// LPVOID lpvThreadParm,\n\t\t\t\t\t0,\t\t\t\t\t\t// DWORD fdwCreate,\n\t\t\t\t\t&thread->id);\n\n\t\t//add the thread to the end of the list\n\t\tthread->next = NULL;\n\t\tif (lastthread) lastthread->next = thread;\n\t\telse firstthread = thread;\n\t\tlastthread = thread;\n\t\t//\n#ifdef THREAD_DEBUG\n\t\tqprintf(\"added thread with id %d\\n\", thread->threadid);\n#endif //THREAD_DEBUG\n\t\t//\n\t\tcurrentnumthreads++;\n\t\tcurrentthreadid++;\n\t\t//\n\t\tThreadUnlock();\n\t} //end else\n} //end of the function AddThread\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid RemoveThread(int threadid)\n{\n\tthread_t *thread, *last;\n\n\t//if a single thread\n\tif (threadid == -1) return;\n\t//\n\tThreadLock();\n\tlast = NULL;\n\tfor (thread = firstthread; thread; thread = thread->next)\n\t{\n\t\tif (thread->threadid == threadid)\n\t\t{\n\t\t\tif (last) last->next = thread->next;\n\t\t\telse firstthread = thread->next;\n\t\t\tif (!thread->next) lastthread = last;\n\t\t\t//\n\t\t\tFreeMemory(thread);\n\t\t\tcurrentnumthreads--;\n#ifdef THREAD_DEBUG\n\t\t\tqprintf(\"removed thread with id %d\\n\", threadid);\n#endif //THREAD_DEBUG\n\t\t\tbreak;\n\t\t} //end if\n\t\tlast = thread;\n\t} //end if\n\tif (!thread) Error(\"couldn't find thread with id %d\", threadid);\n\tThreadUnlock();\n} //end of the function RemoveThread\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid WaitForAllThreadsFinished(void)\n{\n\tHANDLE handle;\n\n\tThreadLock();\n\twhile(firstthread)\n\t{\n\t\thandle = firstthread->handle;\n\t\tThreadUnlock();\n\n\t\tWaitForSingleObject(handle, INFINITE);\n\n\t\tThreadLock();\n\t} //end while\n\tThreadUnlock();\n} //end of the function WaitForAllThreadsFinished\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint GetNumThreads(void)\n{\n\treturn currentnumthreads;\n} //end of the function GetNumThreads\n\n#endif\n\n\n//===================================================================\n//\n// OSF1\n//\n//===================================================================\n\n#if defined(__osf__)\n\n#define\tUSED\n\n#include <pthread.h>\n\ntypedef struct thread_s\n{\n\tpthread_t thread;\n\tint threadid;\n\tint id;\n\tstruct thread_s *next;\n} thread_t;\n\nthread_t *firstthread;\nthread_t *lastthread;\nint currentnumthreads;\nint currentthreadid;\n\nint numthreads = 1;\npthread_mutex_t my_mutex;\npthread_attr_t\tattrib;\nstatic int enter;\nstatic int numwaitingthreads = 0;\n\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadSetDefault(void)\n{\n\tif (numthreads == -1)\t// not set manually\n\t{\n\t\tnumthreads = 1;\n\t} //end if\n\tqprintf(\"%i threads\\n\", numthreads);\n} //end of the function ThreadSetDefault\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadLock(void)\n{\n\tif (!threaded)\n\t{\n\t\tError(\"ThreadLock: !threaded\");\n\t\treturn;\n\t} //end if\n\tif (my_mutex)\n\t{\n\t\tpthread_mutex_lock(my_mutex);\n\t} //end if\n\tif (enter)\n\t\tError(\"Recursive ThreadLock\\n\");\n\tenter = 1;\n} //end of the function ThreadLock\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadUnlock(void)\n{\n\tif (!threaded)\n\t{\n\t\tError(\"ThreadUnlock: !threaded\");\n\t\treturn;\n\t} //end if\n\tif (!enter)\n\t\tError(\"ThreadUnlock without lock\\n\");\n\tenter = 0;\n\tif (my_mutex)\n\t{\n\t\tpthread_mutex_unlock(my_mutex);\n\t} //end if\n} //end of the function ThreadUnlock\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadSetupLock(void)\n{\n\tpthread_mutexattr_t mattrib;\n\n\tLog_Print(\"pthread multi-threading\\n\");\n\n\tif (!my_mutex)\n\t{\n\t\tmy_mutex = GetMemory(sizeof(*my_mutex));\n\t\tif (pthread_mutexattr_create (&mattrib) == -1)\n\t\t\tError (\"pthread_mutex_attr_create failed\");\n\t\tif (pthread_mutexattr_setkind_np (&mattrib, MUTEX_FAST_NP) == -1)\n\t\t\tError (\"pthread_mutexattr_setkind_np failed\");\n\t\tif (pthread_mutex_init (my_mutex, mattrib) == -1)\n\t\t\tError (\"pthread_mutex_init failed\");\n\t}\n\n\tif (pthread_attr_create (&attrib) == -1)\n\t\tError (\"pthread_attr_create failed\");\n\tif (pthread_attr_setstacksize (&attrib, 0x100000) == -1)\n\t\tError (\"pthread_attr_setstacksize failed\");\n\n\tthreaded = true;\n\tcurrentnumthreads = 0;\n\tcurrentthreadid = 0;\n} //end of the function ThreadInitLock\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadShutdownLock(void)\n{\n\tthreaded = false;\n} //end of the function ThreadShutdownLock\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid RunThreadsOn(int workcnt, qboolean showpacifier, void(*func)(int))\n{\n\tint\t\ti;\n\tpthread_t\twork_threads[MAX_THREADS];\n\tpthread_addr_t\tstatus;\n\tpthread_attr_t\tattrib;\n\tpthread_mutexattr_t\tmattrib;\n\tint\t\tstart, end;\n\n\tLog_Print(\"pthread multi-threading\\n\");\n\n\tstart = I_FloatTime ();\n\tdispatch = 0;\n\tworkcount = workcnt;\n\toldf = -1;\n\tpacifier = showpacifier;\n\tthreaded = true;\n\n\tif (numthreads < 1 || numthreads > MAX_THREADS) numthreads = 1;\n\n\tif (pacifier)\n\t\tsetbuf (stdout, NULL);\n\n\tif (!my_mutex)\n\t{\n\t\tmy_mutex = GetMemory(sizeof(*my_mutex));\n\t\tif (pthread_mutexattr_create (&mattrib) == -1)\n\t\t\tError (\"pthread_mutex_attr_create failed\");\n\t\tif (pthread_mutexattr_setkind_np (&mattrib, MUTEX_FAST_NP) == -1)\n\t\t\tError (\"pthread_mutexattr_setkind_np failed\");\n\t\tif (pthread_mutex_init (my_mutex, mattrib) == -1)\n\t\t\tError (\"pthread_mutex_init failed\");\n\t}\n\n\tif (pthread_attr_create (&attrib) == -1)\n\t\tError (\"pthread_attr_create failed\");\n\tif (pthread_attr_setstacksize (&attrib, 0x100000) == -1)\n\t\tError (\"pthread_attr_setstacksize failed\");\n\t\n\tfor (i=0 ; i<numthreads ; i++)\n\t{\n  \t\tif (pthread_create(&work_threads[i], attrib\n\t\t, (pthread_startroutine_t)func, (pthread_addr_t)i) == -1)\n\t\t\tError (\"pthread_create failed\");\n\t}\n\t\t\n\tfor (i=0 ; i<numthreads ; i++)\n\t{\n\t\tif (pthread_join (work_threads[i], &status) == -1)\n\t\t\tError (\"pthread_join failed\");\n\t}\n\n\tthreaded = false;\n\n\tend = I_FloatTime ();\n\tif (pacifier)\n\t\tprintf (\" (%i)\\n\", end-start);\n} //end of the function RunThreadsOn\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AddThread(void (*func)(int))\n{\n\tthread_t *thread;\n\n\tif (numthreads == 1)\n\t{\n\t\tif (currentnumthreads >= numthreads) return;\n\t\tcurrentnumthreads++;\n\t\tfunc(-1);\n\t\tcurrentnumthreads--;\n\t} //end if\n\telse\n\t{\n\t\tThreadLock();\n\t\tif (currentnumthreads >= numthreads)\n\t\t{\n\t\t\tThreadUnlock();\n\t\t\treturn;\n\t\t} //end if\n\t\t//allocate new thread\n\t\tthread = GetMemory(sizeof(thread_t));\n\t\tif (!thread) Error(\"can't allocate memory for thread\\n\");\n\t\t//\n\t\tthread->threadid = currentthreadid;\n\n\t\tif (pthread_create(&thread->thread, attrib, (pthread_startroutine_t)func, (pthread_addr_t)thread->threadid) == -1)\n\t\t\tError (\"pthread_create failed\");\n\n\t\t//add the thread to the end of the list\n\t\tthread->next = NULL;\n\t\tif (lastthread) lastthread->next = thread;\n\t\telse firstthread = thread;\n\t\tlastthread = thread;\n\t\t//\n#ifdef THREAD_DEBUG\n\t\tqprintf(\"added thread with id %d\\n\", thread->threadid);\n#endif //THREAD_DEBUG\n\t\t//\n\t\tcurrentnumthreads++;\n\t\tcurrentthreadid++;\n\t\t//\n\t\tThreadUnlock();\n\t} //end else\n} //end of the function AddThread\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid RemoveThread(int threadid)\n{\n\tthread_t *thread, *last;\n\n\t//if a single thread\n\tif (threadid == -1) return;\n\t//\n\tThreadLock();\n\tlast = NULL;\n\tfor (thread = firstthread; thread; thread = thread->next)\n\t{\n\t\tif (thread->threadid == threadid)\n\t\t{\n\t\t\tif (last) last->next = thread->next;\n\t\t\telse firstthread = thread->next;\n\t\t\tif (!thread->next) lastthread = last;\n\t\t\t//\n\t\t\tFreeMemory(thread);\n\t\t\tcurrentnumthreads--;\n#ifdef THREAD_DEBUG\n\t\t\tqprintf(\"removed thread with id %d\\n\", threadid);\n#endif //THREAD_DEBUG\n\t\t\tbreak;\n\t\t} //end if\n\t\tlast = thread;\n\t} //end if\n\tif (!thread) Error(\"couldn't find thread with id %d\", threadid);\n\tThreadUnlock();\n} //end of the function RemoveThread\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid WaitForAllThreadsFinished(void)\n{\n\tpthread_t *thread;\n\tpthread_addr_t\tstatus;\n\n\tThreadLock();\n\twhile(firstthread)\n\t{\n\t\tthread = &firstthread->thread;\n\t\tThreadUnlock();\n\n\t\tif (pthread_join(*thread, &status) == -1)\n\t\t\tError(\"pthread_join failed\");\n\n\t\tThreadLock();\n\t} //end while\n\tThreadUnlock();\n} //end of the function WaitForAllThreadsFinished\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint GetNumThreads(void)\n{\n\treturn currentnumthreads;\n} //end of the function GetNumThreads\n\n#endif\n\n//===================================================================\n//\n// LINUX\n//\n//===================================================================\n\n#if defined(LINUX)\n\n#define\tUSED\n\n#include <pthread.h>\n#include <semaphore.h>\n\ntypedef struct thread_s\n{\n\tpthread_t thread;\n\tint threadid;\n\tint id;\n\tstruct thread_s *next;\n} thread_t;\n\nthread_t *firstthread;\nthread_t *lastthread;\nint currentnumthreads;\nint currentthreadid;\n\nint numthreads = 1;\npthread_mutex_t my_mutex = PTHREAD_MUTEX_INITIALIZER;\npthread_attr_t\tattrib;\nsem_t semaphore;\nstatic int enter;\nstatic int numwaitingthreads = 0;\n\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadSetDefault(void)\n{\n\tif (numthreads == -1)\t// not set manually\n\t{\n\t\tnumthreads = 1;\n\t} //end if\n\tqprintf(\"%i threads\\n\", numthreads);\n} //end of the function ThreadSetDefault\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadLock(void)\n{\n\tif (!threaded)\n\t{\n\t\tError(\"ThreadLock: !threaded\");\n\t\treturn;\n\t} //end if\n\tpthread_mutex_lock(&my_mutex);\n\tif (enter)\n\t\tError(\"Recursive ThreadLock\\n\");\n\tenter = 1;\n} //end of the function ThreadLock\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadUnlock(void)\n{\n\tif (!threaded)\n\t{\n\t\tError(\"ThreadUnlock: !threaded\");\n\t\treturn;\n\t} //end if\n\tif (!enter)\n\t\tError(\"ThreadUnlock without lock\\n\");\n\tenter = 0;\n\tpthread_mutex_unlock(&my_mutex);\n} //end of the function ThreadUnlock\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadSetupLock(void)\n{\n\tpthread_mutexattr_t mattrib;\n\n\tLog_Print(\"pthread multi-threading\\n\");\n\n\tthreaded = true;\n\tcurrentnumthreads = 0;\n\tcurrentthreadid = 0;\n} //end of the function ThreadInitLock\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadShutdownLock(void)\n{\n\tthreaded = false;\n} //end of the function ThreadShutdownLock\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadSetupSemaphore(void)\n{\n\tsem_init(&semaphore, 0, 0);\n} //end of the function ThreadSetupSemaphore\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadShutdownSemaphore(void)\n{\n\tsem_destroy(&semaphore);\n} //end of the function ThreadShutdownSemaphore\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadSemaphoreWait(void)\n{\n\tsem_wait(&semaphore);\n} //end of the function ThreadSemaphoreWait\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadSemaphoreIncrease(int count)\n{\n\tint i;\n\n\tfor (i = 0; i < count; i++)\n\t{\n\t\tsem_post(&semaphore);\n\t} //end for\n} //end of the function ThreadSemaphoreIncrease\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid RunThreadsOn(int workcnt, qboolean showpacifier, void(*func)(int))\n{\n\tint\t\ti;\n\tpthread_t\twork_threads[MAX_THREADS];\n\tvoid *pthread_return;\n\tpthread_attr_t\tattrib;\n\tpthread_mutexattr_t\tmattrib;\n\tint\t\tstart, end;\n\n\tLog_Print(\"pthread multi-threading\\n\");\n\n\tstart = I_FloatTime ();\n\tdispatch = 0;\n\tworkcount = workcnt;\n\toldf = -1;\n\tpacifier = showpacifier;\n\tthreaded = true;\n\n\tif (numthreads < 1 || numthreads > MAX_THREADS) numthreads = 1;\n\n\tif (pacifier)\n\t\tsetbuf (stdout, NULL);\n\n\tfor (i=0 ; i<numthreads ; i++)\n\t{\n\t\tif (pthread_create(&work_threads[i], NULL, (void *)func, (void *)i) == -1)\n\t\t\tError (\"pthread_create failed\");\n\t}\n\t\t\n\tfor (i=0 ; i<numthreads ; i++)\n\t{\n\t\tif (pthread_join(work_threads[i], &pthread_return) == -1)\n\t\t\tError (\"pthread_join failed\");\n\t}\n\n\tthreaded = false;\n\n\tend = I_FloatTime ();\n\tif (pacifier)\n\t\tprintf (\" (%i)\\n\", end-start);\n} //end of the function RunThreadsOn\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AddThread(void (*func)(int))\n{\n\tthread_t *thread;\n\n\tif (numthreads == 1)\n\t{\n\t\tif (currentnumthreads >= numthreads) return;\n\t\tcurrentnumthreads++;\n\t\tfunc(-1);\n\t\tcurrentnumthreads--;\n\t} //end if\n\telse\n\t{\n\t\tThreadLock();\n\t\tif (currentnumthreads >= numthreads)\n\t\t{\n\t\t\tThreadUnlock();\n\t\t\treturn;\n\t\t} //end if\n\t\t//allocate new thread\n\t\tthread = GetMemory(sizeof(thread_t));\n\t\tif (!thread) Error(\"can't allocate memory for thread\\n\");\n\t\t//\n\t\tthread->threadid = currentthreadid;\n\n\t\tif (pthread_create(&thread->thread, NULL, (void *)func, (void *)thread->threadid) == -1)\n\t\t\tError (\"pthread_create failed\");\n\n\t\t//add the thread to the end of the list\n\t\tthread->next = NULL;\n\t\tif (lastthread) lastthread->next = thread;\n\t\telse firstthread = thread;\n\t\tlastthread = thread;\n\t\t//\n#ifdef THREAD_DEBUG\n\t\tqprintf(\"added thread with id %d\\n\", thread->threadid);\n#endif //THREAD_DEBUG\n\t\t//\n\t\tcurrentnumthreads++;\n\t\tcurrentthreadid++;\n\t\t//\n\t\tThreadUnlock();\n\t} //end else\n} //end of the function AddThread\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid RemoveThread(int threadid)\n{\n\tthread_t *thread, *last;\n\n\t//if a single thread\n\tif (threadid == -1) return;\n\t//\n\tThreadLock();\n\tlast = NULL;\n\tfor (thread = firstthread; thread; thread = thread->next)\n\t{\n\t\tif (thread->threadid == threadid)\n\t\t{\n\t\t\tif (last) last->next = thread->next;\n\t\t\telse firstthread = thread->next;\n\t\t\tif (!thread->next) lastthread = last;\n\t\t\t//\n\t\t\tFreeMemory(thread);\n\t\t\tcurrentnumthreads--;\n#ifdef THREAD_DEBUG\n\t\t\tqprintf(\"removed thread with id %d\\n\", threadid);\n#endif //THREAD_DEBUG\n\t\t\tbreak;\n\t\t} //end if\n\t\tlast = thread;\n\t} //end if\n\tif (!thread) Error(\"couldn't find thread with id %d\", threadid);\n\tThreadUnlock();\n} //end of the function RemoveThread\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid WaitForAllThreadsFinished(void)\n{\n\tpthread_t *thread;\n\tvoid *pthread_return;\n\n\tThreadLock();\n\twhile(firstthread)\n\t{\n\t\tthread = &firstthread->thread;\n\t\tThreadUnlock();\n\n\t\tif (pthread_join(*thread, &pthread_return) == -1)\n\t\t\tError(\"pthread_join failed\");\n\n\t\tThreadLock();\n\t} //end while\n\tThreadUnlock();\n} //end of the function WaitForAllThreadsFinished\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint GetNumThreads(void)\n{\n\treturn currentnumthreads;\n} //end of the function GetNumThreads\n\n#endif //LINUX\n\n\n//===================================================================\n//\n// IRIX\n//\n//===================================================================\n\n#ifdef _MIPS_ISA \n\n#define\tUSED\n\n#include <task.h>\n#include <abi_mutex.h>\n#include <sys/types.h>\n#include <sys/prctl.h>\n\ntypedef struct thread_s\n{\n\tint threadid;\n\tint id;\n\tstruct thread_s *next;\n} thread_t;\n\nthread_t *firstthread;\nthread_t *lastthread;\nint currentnumthreads;\nint currentthreadid;\n\nint numthreads = 1;\nstatic int enter;\nstatic int numwaitingthreads = 0;\n\nabilock_t\t\tlck;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadSetDefault (void)\n{\n\tif (numthreads == -1)\n\t\tnumthreads = prctl(PR_MAXPPROCS);\n\tprintf (\"%i threads\\n\", numthreads);\n//@@\n\tusconfig (CONF_INITUSERS, numthreads);\n} //end of the function ThreadSetDefault\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadLock (void)\n{\n\tspin_lock (&lck);\n} //end of the function ThreadLock\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadUnlock (void)\n{\n\trelease_lock(&lck);\n} //end of the function ThreadUnlock\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadSetupLock(void)\n{\n\tinit_lock (&lck);\n\n\tLog_Print(\"IRIX multi-threading\\n\");\n\n\tthreaded = true;\n\tcurrentnumthreads = 0;\n\tcurrentthreadid = 0;\n} //end of the function ThreadInitLock\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadShutdownLock(void)\n{\n\tthreaded = false;\n} //end of the function ThreadShutdownLock\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int))\n{\n\tint\t\ti;\n\tint\t\tpid[MAX_THREADS];\n\tint\t\tstart, end;\n\n\tstart = I_FloatTime ();\n\tdispatch = 0;\n\tworkcount = workcnt;\n\toldf = -1;\n\tpacifier = showpacifier;\n\tthreaded = true;\n\n\tif (numthreads < 1 || numthreads > MAX_THREADS) numthreads = 1;\n\n\tif (pacifier)\n\t\tsetbuf (stdout, NULL);\n\n\tinit_lock (&lck);\n\n\tfor (i=0 ; i<numthreads-1 ; i++)\n\t{\n\t\tpid[i] = sprocsp ( (void (*)(void *, size_t))func, PR_SALL, (void *)i\n\t\t\t, NULL, 0x100000);\n//\t\tpid[i] = sprocsp ( (void (*)(void *, size_t))func, PR_SALL, (void *)i\n//\t\t\t, NULL, 0x80000);\n\t\tif (pid[i] == -1)\n\t\t{\n\t\t\tperror (\"sproc\");\n\t\t\tError (\"sproc failed\");\n\t\t}\n\t}\n\t\t\n\tfunc(i);\n\t\t\t\n\tfor (i=0 ; i<numthreads-1 ; i++)\n\t\twait (NULL);\n\n\tthreaded = false;\n\n\tend = I_FloatTime ();\n\tif (pacifier)\n\t\tprintf (\" (%i)\\n\", end-start);\n} //end of the function RunThreadsOn\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AddThread(void (*func)(int))\n{\n\tthread_t *thread;\n\n\tif (numthreads == 1)\n\t{\n\t\tif (currentnumthreads >= numthreads) return;\n\t\tcurrentnumthreads++;\n\t\tfunc(-1);\n\t\tcurrentnumthreads--;\n\t} //end if\n\telse\n\t{\n\t\tThreadLock();\n\t\tif (currentnumthreads >= numthreads)\n\t\t{\n\t\t\tThreadUnlock();\n\t\t\treturn;\n\t\t} //end if\n\t\t//allocate new thread\n\t\tthread = GetMemory(sizeof(thread_t));\n\t\tif (!thread) Error(\"can't allocate memory for thread\\n\");\n\t\t//\n\t\tthread->threadid = currentthreadid;\n\n\t\tthread->id = sprocsp ( (void (*)(void *, size_t))func, PR_SALL, (void *)thread->threadid, NULL, 0x100000);\n\t\tif (thread->id == -1)\n\t\t{\n\t\t\tperror (\"sproc\");\n\t\t\tError (\"sproc failed\");\n\t\t}\n\n\t\t//add the thread to the end of the list\n\t\tthread->next = NULL;\n\t\tif (lastthread) lastthread->next = thread;\n\t\telse firstthread = thread;\n\t\tlastthread = thread;\n\t\t//\n#ifdef THREAD_DEBUG\n\t\tqprintf(\"added thread with id %d\\n\", thread->threadid);\n#endif //THREAD_DEBUG\n\t\t//\n\t\tcurrentnumthreads++;\n\t\tcurrentthreadid++;\n\t\t//\n\t\tThreadUnlock();\n\t} //end else\n} //end of the function AddThread\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid RemoveThread(int threadid)\n{\n\tthread_t *thread, *last;\n\n\t//if a single thread\n\tif (threadid == -1) return;\n\t//\n\tThreadLock();\n\tlast = NULL;\n\tfor (thread = firstthread; thread; thread = thread->next)\n\t{\n\t\tif (thread->threadid == threadid)\n\t\t{\n\t\t\tif (last) last->next = thread->next;\n\t\t\telse firstthread = thread->next;\n\t\t\tif (!thread->next) lastthread = last;\n\t\t\t//\n\t\t\tFreeMemory(thread);\n\t\t\tcurrentnumthreads--;\n#ifdef THREAD_DEBUG\n\t\t\tqprintf(\"removed thread with id %d\\n\", threadid);\n#endif //THREAD_DEBUG\n\t\t\tbreak;\n\t\t} //end if\n\t\tlast = thread;\n\t} //end if\n\tif (!thread) Error(\"couldn't find thread with id %d\", threadid);\n\tThreadUnlock();\n} //end of the function RemoveThread\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid WaitForAllThreadsFinished(void)\n{\n\tThreadLock();\n\twhile(firstthread)\n\t{\n\t\tThreadUnlock();\n\n\t\t//wait (NULL);\n\n\t\tThreadLock();\n\t} //end while\n\tThreadUnlock();\n} //end of the function WaitForAllThreadsFinished\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint GetNumThreads(void)\n{\n\treturn currentnumthreads;\n} //end of the function GetNumThreads\n\n#endif //_MIPS_ISA\n\n\n//=======================================================================\n//\n// SINGLE THREAD\n//\n//=======================================================================\n\n#ifndef USED\n\nint numthreads = 1;\nint currentnumthreads = 0;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadSetDefault(void)\n{\n\tnumthreads = 1;\n} //end of the function ThreadSetDefault\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadLock(void)\n{\n} //end of the function ThreadLock\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadUnlock(void)\n{\n} //end of the function ThreadUnlock\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadSetupLock(void)\n{\n\tLog_Print(\"no multi-threading\\n\");\n} //end of the function ThreadInitLock\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadShutdownLock(void)\n{\n} //end of the function ThreadShutdownLock\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadSetupSemaphore(void)\n{\n} //end of the function ThreadSetupSemaphore\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadShutdownSemaphore(void)\n{\n} //end of the function ThreadShutdownSemaphore\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadSemaphoreWait(void)\n{\n} //end of the function ThreadSemaphoreWait\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ThreadSemaphoreIncrease(int count)\n{\n} //end of the function ThreadSemaphoreIncrease\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid RunThreadsOn(int workcnt, qboolean showpacifier, void(*func)(int))\n{\n\tint start, end;\n\n\tLog_Print(\"no multi-threading\\n\");\n\tdispatch = 0;\n\tworkcount = workcnt;\n\toldf = -1;\n\tpacifier = showpacifier;\n\tstart = I_FloatTime (); \n#ifdef NeXT\n\tif (pacifier)\n\t\tsetbuf (stdout, NULL);\n#endif\n\tfunc(0);\n\n\tend = I_FloatTime ();\n\tif (pacifier)\n\t\tprintf (\" (%i)\\n\", end-start);\n} //end of the function RunThreadsOn\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AddThread(void (*func)(int))\n{\n\tif (currentnumthreads >= numthreads) return;\n\tcurrentnumthreads++;\n\tfunc(-1);\n\tcurrentnumthreads--;\n} //end of the function AddThread\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid RemoveThread(int threadid)\n{\n} //end of the function RemoveThread\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid WaitForAllThreadsFinished(void)\n{\n} //end of the function WaitForAllThreadsFinished\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint GetNumThreads(void)\n{\n\treturn currentnumthreads;\n} //end of the function GetNumThreads\n\n#endif //USED\n"
  },
  {
    "path": "code/bspc/l_threads.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\nextern int numthreads;\n\nvoid ThreadSetDefault (void);\nint GetThreadWork (void);\nvoid RunThreadsOnIndividual (int workcnt, qboolean showpacifier, void(*func)(int));\nvoid RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int));\n\n//mutex\nvoid ThreadSetupLock(void);\nvoid ThreadShutdownLock(void);\nvoid ThreadLock (void);\nvoid ThreadUnlock (void);\n//semaphore\nvoid ThreadSetupSemaphore(void);\nvoid ThreadShutdownSemaphore(void);\nvoid ThreadSemaphoreWait(void);\nvoid ThreadSemaphoreIncrease(int count);\n//add/remove threads\nvoid AddThread(void (*func)(int));\nvoid RemoveThread(int threadid);\nvoid WaitForAllThreadsFinished(void);\nint GetNumThreads(void);\n\n"
  },
  {
    "path": "code/bspc/l_utils.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n//#ifndef BOTLIB\n//#define BOTLIB\n//#endif //BOTLIB\n\n#ifdef BOTLIB\n#include \"q_shared.h\"\n#include \"qfiles.h\"\n#include \"botlib.h\"\n#include \"l_log.h\"\n#include \"l_libvar.h\"\n#include \"l_memory.h\"\n//#include \"l_utils.h\"\n#include \"be_interface.h\"\n#else //BOTLIB\n#include \"qbsp.h\"\n#include \"l_mem.h\"\n#endif //BOTLIB\n\n#ifdef BOTLIB\n//========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//========================================================================\nvoid Vector2Angles(vec3_t value1, vec3_t angles)\n{\n\tfloat\tforward;\n\tfloat\tyaw, pitch;\n\t\n\tif (value1[1] == 0 && value1[0] == 0)\n\t{\n\t\tyaw = 0;\n\t\tif (value1[2] > 0) pitch = 90;\n\t\telse pitch = 270;\n\t} //end if\n\telse\n\t{\n\t\tyaw = (int) (atan2(value1[1], value1[0]) * 180 / M_PI);\n\t\tif (yaw < 0) yaw += 360;\n\n\t\tforward = sqrt (value1[0]*value1[0] + value1[1]*value1[1]);\n\t\tpitch = (int) (atan2(value1[2], forward) * 180 / M_PI);\n\t\tif (pitch < 0) pitch += 360;\n\t} //end else\n\n\tangles[PITCH] = -pitch;\n\tangles[YAW] = yaw;\n\tangles[ROLL] = 0;\n} //end of the function Vector2Angles\n#endif //BOTLIB\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ConvertPath(char *path)\n{\n\twhile(*path)\n\t{\n\t\tif (*path == '/' || *path == '\\\\') *path = PATHSEPERATOR_CHAR;\n\t\tpath++;\n\t} //end while\n} //end of the function ConvertPath\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AppendPathSeperator(char *path, int length)\n{\n\tint pathlen = strlen(path);\n\n\tif (strlen(path) && length-pathlen > 1 && path[pathlen-1] != '/' && path[pathlen-1] != '\\\\')\n\t{\n\t\tpath[pathlen] = PATHSEPERATOR_CHAR;\n\t\tpath[pathlen+1] = '\\0';\n\t} //end if\n} //end of the function AppenPathSeperator\n\n#if 0\n//===========================================================================\n// returns pointer to file handle\n// sets offset to and length of 'filename' in the pak file\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean FindFileInPak(char *pakfile, char *filename, foundfile_t *file)\n{\n\tFILE *fp;\n\tdpackheader_t packheader;\n\tdpackfile_t *packfiles;\n\tint numdirs, i;\n\tchar path[MAX_PATH];\n\n\t//open the pak file\n\tfp = fopen(pakfile, \"rb\");\n\tif (!fp)\n\t{\n\t\treturn false;\n\t} //end if\n\t//read pak header, check for valid pak id and seek to the dir entries\n\tif ((fread(&packheader, 1, sizeof(dpackheader_t), fp) != sizeof(dpackheader_t))\n\t\t|| (packheader.ident != IDPAKHEADER)\n\t\t||\t(fseek(fp, LittleLong(packheader.dirofs), SEEK_SET))\n\t\t)\n\t{\n\t\tfclose(fp);\n\t\treturn false;\n\t} //end if\n\t//number of dir entries in the pak file\n\tnumdirs = LittleLong(packheader.dirlen) / sizeof(dpackfile_t);\n\tpackfiles = (dpackfile_t *) GetMemory(numdirs * sizeof(dpackfile_t));\n\t//read the dir entry\n\tif (fread(packfiles, sizeof(dpackfile_t), numdirs, fp) != numdirs)\n\t{\n\t\tfclose(fp);\n\t\tFreeMemory(packfiles);\n\t\treturn false;\n\t} //end if\n\tfclose(fp);\n\t//\n\tstrcpy(path, filename);\n\tConvertPath(path);\n\t//find the dir entry in the pak file\n\tfor (i = 0; i < numdirs; i++)\n\t{\n\t\t//convert the dir entry name\n\t\tConvertPath(packfiles[i].name);\n\t\t//compare the dir entry name with the filename\n\t\tif (Q_strcasecmp(packfiles[i].name, path) == 0)\n\t\t{\n\t\t\tstrcpy(file->filename, pakfile);\n\t\t\tfile->offset = LittleLong(packfiles[i].filepos);\n\t\t\tfile->length = LittleLong(packfiles[i].filelen);\n\t\t\tFreeMemory(packfiles);\n\t\t\treturn true;\n\t\t} //end if\n\t} //end for\n\tFreeMemory(packfiles);\n\treturn false;\n} //end of the function FindFileInPak\n//===========================================================================\n// find a Quake2 file\n// returns full path in 'filename'\n// sets offset and length of the file\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean FindQuakeFile2(char *basedir, char *gamedir, char *filename, foundfile_t *file)\n{\n\tint dir, i;\n\t//NOTE: 3 is necessary (LCC bug???)\n\tchar gamedirs[3][MAX_PATH] = {\"\",\"\",\"\"};\n\tchar filedir[MAX_PATH] = \"\";\n\n\t//\n\tif (gamedir) strncpy(gamedirs[0], gamedir, MAX_PATH);\n\tstrncpy(gamedirs[1], \"baseq2\", MAX_PATH);\n\t//\n\t//find the file in the two game directories\n\tfor (dir = 0; dir < 2; dir++)\n\t{\n\t\t//check if the file is in a directory\n\t\tfiledir[0] = 0;\n\t\tif (basedir && strlen(basedir))\n\t\t{\n\t\t\tstrncpy(filedir, basedir, MAX_PATH);\n\t\t\tAppendPathSeperator(filedir, MAX_PATH);\n\t\t} //end if\n\t\tif (strlen(gamedirs[dir]))\n\t\t{\n\t\t\tstrncat(filedir, gamedirs[dir], MAX_PATH - strlen(filedir));\n\t\t\tAppendPathSeperator(filedir, MAX_PATH);\n\t\t} //end if\n\t\tstrncat(filedir, filename, MAX_PATH - strlen(filedir));\n\t\tConvertPath(filedir);\n\t\tLog_Write(\"accessing %s\", filedir);\n\t\tif (!access(filedir, 0x04))\n\t\t{\n\t\t\tstrcpy(file->filename, filedir);\n\t\t\tfile->length = 0;\n\t\t\tfile->offset = 0;\n\t\t\treturn true;\n\t\t} //end if\n\t\t//check if the file is in a pak?.pak\n\t\tfor (i = 0; i < 10; i++)\n\t\t{\n\t\t\tfiledir[0] = 0;\n\t\t\tif (basedir && strlen(basedir))\n\t\t\t{\n\t\t\t\tstrncpy(filedir, basedir, MAX_PATH);\n\t\t\t\tAppendPathSeperator(filedir, MAX_PATH);\n\t\t\t} //end if\n\t\t\tif (strlen(gamedirs[dir]))\n\t\t\t{\n\t\t\t\tstrncat(filedir, gamedirs[dir], MAX_PATH - strlen(filedir));\n\t\t\t\tAppendPathSeperator(filedir, MAX_PATH);\n\t\t\t} //end if\n\t\t\tsprintf(&filedir[strlen(filedir)], \"pak%d.pak\\0\", i);\n\t\t\tif (!access(filedir, 0x04))\n\t\t\t{\n\t\t\t\tLog_Write(\"searching %s in %s\", filename, filedir);\n\t\t\t\tif (FindFileInPak(filedir, filename, file)) return true;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\tfile->offset = 0;\n\tfile->length = 0;\n\treturn false;\n} //end of the function FindQuakeFile2\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#ifdef BOTLIB\nqboolean FindQuakeFile(char *filename, foundfile_t *file)\n{\n\treturn FindQuakeFile2(LibVarGetString(\"basedir\"),\n\t\t\t\tLibVarGetString(\"gamedir\"), filename, file);\n} //end of the function FindQuakeFile\n#else //BOTLIB\nqboolean FindQuakeFile(char *basedir, char *gamedir, char *filename, foundfile_t *file)\n{\n\treturn FindQuakeFile2(basedir, gamedir, filename, file);\n} //end of the function FindQuakeFile\n#endif //BOTLIB\n\n#endif\n"
  },
  {
    "path": "code/bspc/l_utils.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#ifndef MAX_PATH\n\t#define MAX_PATH\t\t\t64\n#endif\n\n#ifndef PATH_SEPERATORSTR\n\t#if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__)\n\t\t#define PATHSEPERATOR_STR\t\t\"\\\\\"\n\t#else\n\t\t#define PATHSEPERATOR_STR\t\t\"/\"\n\t#endif\n#endif\n#ifndef PATH_SEPERATORCHAR\n\t#if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__)\n\t\t#define PATHSEPERATOR_CHAR\t\t'\\\\'\n\t#else\n\t\t#define PATHSEPERATOR_CHAR\t\t'/'\n\t#endif\n#endif\n\n//random in the range [0, 1]\n#define random()\t\t\t((rand () & 0x7fff) / ((float)0x7fff))\n//random in the range [-1, 1]\n#define crandom()\t\t\t(2.0 * (random() - 0.5))\n//min and max\n#define Maximum(x,y)\t\t(x > y ? x : y)\n#define Minimum(x,y)\t\t(x < y ? x : y)\n//absolute value\n#define FloatAbs(x)\t\t(*(float *) &((* (int *) &(x)) & 0x7FFFFFFF))\n#define IntAbs(x)\t\t\t(~(x))\n//coordinates\n#define _X\t\t0\n#define _Y\t\t1\n#define _Z\t\t2\n\ntypedef struct foundfile_s\n{\n\tint offset;\n\tint length;\n\tchar filename[MAX_PATH];\t\t//screw LCC, array must be at end of struct\n} foundfile_t;\n\nvoid Vector2Angles(vec3_t value1, vec3_t angles);\n//set the correct path seperators\nvoid ConvertPath(char *path);\n//append a path seperator to the given path not exceeding the length\nvoid AppendPathSeperator(char *path, int length);\n//find a file in a pak file\nqboolean FindFileInPak(char *pakfile, char *filename, foundfile_t *file);\n//find a quake file\n#ifdef BOTLIB\nqboolean FindQuakeFile(char *filename, foundfile_t *file);\n#else //BOTLIB\nqboolean FindQuakeFile(char *basedir, char *gamedir, char *filename, foundfile_t *file);\n#endif //BOTLIB\n\n\n\n"
  },
  {
    "path": "code/bspc/lcc.mak",
    "content": "#\n# Makefile for the BSPC tool for the Gladiator Bot\n# Intended for LCC-Win32\n#\n\nCC=lcc\nCFLAGS=-DC_ONLY -o\nOBJS= _files.obj\\\n\taas_areamerging.obj\\\n\taas_cfg.obj\\\n\taas_create.obj\\\n\taas_edgemelting.obj\\\n\taas_facemerging.obj\\\n\taas_file.obj\\\n\taas_gsubdiv.obj\\\n\taas_map.obj\\\n\taas_prunenodes.obj\\\n\taas_store.obj\\\n\tbrushbsp.obj\\\n\tbspc.obj\\\n\tcsg.obj\\\n\tfaces.obj\\\n\tglfile.obj\\\n\tl_bsp_hl.obj\\\n\tl_bsp_q1.obj\\\n\tl_bsp_q2.obj\\\n\tl_bsp_sin.obj\\\n\tl_cmd.obj\\\n\tl_log.obj\\\n\tl_math.obj\\\n\tl_mem.obj\\\n\tl_poly.obj\\\n\tl_qfiles.obj\\\n\tl_script.obj\\\n\tl_threads.obj\\\n\tl_utils.obj\\\n\tleakfile.obj\\\n\tmap.obj\\\n\tmap_hl.obj\\\n\tmap_q1.obj\\\n\tmap_q2.obj\\\n\tmap_q2_new.obj\\\n\tmap_sin.obj\\\n\tnodraw.obj\\\n\tportals.obj\\\n\tprtfile.obj\\\n\ttextures.obj\\\n\ttree.obj\\\n\twritebsp.obj\n\nall:\tbspc.exe\n\nbspc.exe:\t$(OBJS)\n\tlcclnk\n\nclean:\n\tdel *.obj bspc.exe\n\n%.obj: %.c\n\t$(CC) $(CFLAGS) $<\n\n"
  },
  {
    "path": "code/bspc/leakfile.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n\n/*\n==============================================================================\n\nLEAF FILE GENERATION\n\nSave out name.line for qe3 to read\n==============================================================================\n*/\n\n\n/*\n=============\nLeakFile\n\nFinds the shortest possible chain of portals\nthat leads from the outside leaf to a specifically\noccupied leaf\n=============\n*/\nvoid LeakFile (tree_t *tree)\n{\n\tvec3_t\tmid;\n\tFILE\t*linefile;\n\tchar\tfilename[1024];\n\tnode_t\t*node;\n\tint\t\tcount;\n\n\tif (!tree->outside_node.occupied)\n\t\treturn;\n\n\tqprintf (\"--- LeakFile ---\\n\");\n\n\t//\n\t// write the points to the file\n\t//\n\tsprintf (filename, \"%s.lin\", source);\n\tqprintf (\"%s\\n\", filename);\n\tlinefile = fopen (filename, \"w\");\n\tif (!linefile)\n\t\tError (\"Couldn't open %s\\n\", filename);\n\n\tcount = 0;\n\tnode = &tree->outside_node;\n\twhile (node->occupied > 1)\n\t{\n\t\tint\t\t\tnext;\n\t\tportal_t\t*p, *nextportal;\n\t\tnode_t\t\t*nextnode;\n\t\tint\t\t\ts;\n\n\t\t// find the best portal exit\n\t\tnext = node->occupied;\n\t\tfor (p=node->portals ; p ; p = p->next[!s])\n\t\t{\n\t\t\ts = (p->nodes[0] == node);\n\t\t\tif (p->nodes[s]->occupied\n\t\t\t\t&& p->nodes[s]->occupied < next)\n\t\t\t{\n\t\t\t\tnextportal = p;\n\t\t\t\tnextnode = p->nodes[s];\n\t\t\t\tnext = nextnode->occupied;\n\t\t\t}\n\t\t}\n\t\tnode = nextnode;\n\t\tWindingCenter (nextportal->winding, mid);\n\t\tfprintf (linefile, \"%f %f %f\\n\", mid[0], mid[1], mid[2]);\n\t\tcount++;\n\t}\n\t// add the occupant center\n\tGetVectorForKey (node->occupant, \"origin\", mid);\n\n\tfprintf (linefile, \"%f %f %f\\n\", mid[0], mid[1], mid[2]);\n\tqprintf (\"%5i point linefile\\n\", count+1);\n\n\tfclose (linefile);\n}\n\n"
  },
  {
    "path": "code/bspc/linux-i386.mak",
    "content": "#\n# Makefile for the BSPC tool for the Gladiator Bot\n# Intended for gcc/Linux\n#\n\nARCH=i386\nCC=gcc\nBASE_CFLAGS=-Dstricmp=strcasecmp\n\n#use these cflags to optimize it\nCFLAGS=$(BASE_CFLAGS) -m486 -O6 -ffast-math -funroll-loops \\\n\t-fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \\\n\t-malign-jumps=2 -malign-functions=2 -DLINUX -DBSPC\n#use these when debugging \n#CFLAGS=$(BASE_CFLAGS) -g\n\nLDFLAGS=-ldl -lm -lpthread\n\nDO_CC=$(CC) $(CFLAGS) -o $@ -c $<\n\n#############################################################################\n# SETUP AND BUILD BSPC\n#############################################################################\n\n.c.o:\n\t$(DO_CC)\n\nGAME_OBJS = \\\n\t_files.o\\\n\taas_areamerging.o\\\n\taas_cfg.o\\\n\taas_create.o\\\n\taas_edgemelting.o\\\n\taas_facemerging.o\\\n\taas_file.o\\\n\taas_gsubdiv.o\\\n\taas_map.o\\\n\taas_prunenodes.o\\\n\taas_store.o\\\n\tbe_aas_bspc.o\\\n\t../botlib/be_aas_bspq3.o\\\n\t../botlib/be_aas_cluster.o\\\n\t../botlib/be_aas_move.o\\\n\t../botlib/be_aas_optimize.o\\\n\t../botlib/be_aas_reach.o\\\n\t../botlib/be_aas_sample.o\\\n\tbrushbsp.o\\\n\tbspc.o\\\n\t../qcommon/cm_load.o\\\n\t../qcommon/cm_patch.o\\\n\t../qcommon/cm_test.o\\\n\t../qcommon/cm_trace.o\\\n\tcsg.o\\\n\tglfile.o\\\n\tl_bsp_ent.o\\\n\tl_bsp_hl.o\\\n\tl_bsp_q1.o\\\n\tl_bsp_q2.o\\\n\tl_bsp_q3.o\\\n\tl_bsp_sin.o\\\n\tl_cmd.o\\\n\t../botlib/l_libvar.o\\\n\tl_log.o\\\n\tl_math.o\\\n\tl_mem.o\\\n\tl_poly.o\\\n\t../botlib/l_precomp.o\\\n\tl_qfiles.o\\\n\t../botlib/l_script.o\\\n\t../botlib/l_struct.o\\\n\tl_threads.o\\\n\tl_utils.o\\\n\tleakfile.o\\\n\tmap.o\\\n\tmap_hl.o\\\n\tmap_q1.o\\\n\tmap_q2.o\\\n\tmap_q3.o\\\n\tmap_sin.o\\\n\t../qcommon/md4.o\\\n\tnodraw.o\\\n\tportals.o\\\n\ttetrahedron.o\\\n\ttextures.o\\\n\ttree.o\\\n\t../qcommon/unzip.o\n\nbspc$(ARCH) : $(GAME_OBJS)\n\t$(CC) $(CFLAGS) -o $@ $(GAME_OBJS) $(LDFLAGS)\n\n\n#############################################################################\n# MISC\n#############################################################################\n\nclean:\n\t-rm -f $(GAME_OBJS)\n\ndepend:\n\tgcc -MM $(GAME_OBJS:.o=.c)\n\n\ninstall:\n\tcp bspci386 ..\n\n#\n# From \"make depend\"\n#\n\n"
  },
  {
    "path": "code/bspc/map.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n#include \"l_bsp_hl.h\"\n#include \"l_bsp_q1.h\"\n#include \"l_bsp_q2.h\"\n#include \"l_bsp_q3.h\"\n#include \"l_bsp_sin.h\"\n#include \"l_mem.h\"\n#include \"../botlib/aasfile.h\"\t\t//aas_bbox_t\n#include \"aas_store.h\"\t\t//AAS_MAX_BBOXES\n#include \"aas_cfg.h\"\n\n#define Sign(x)\t\t(x < 0 ? 1 : 0)\n\nint\t\t\t\t\tnummapbrushes;\nmapbrush_t\t\t\tmapbrushes[MAX_MAPFILE_BRUSHES];\n\nint\t\t\t\t\tnummapbrushsides;\nside_t\t\t\t\tbrushsides[MAX_MAPFILE_BRUSHSIDES];\nbrush_texture_t\t\tside_brushtextures[MAX_MAPFILE_BRUSHSIDES];\n\nint\t\t\t\t\tnummapplanes;\nplane_t\t\t\t\tmapplanes[MAX_MAPFILE_PLANES];\nint\t\t\t\t\tmapplaneusers[MAX_MAPFILE_PLANES];\n\n#define\t\t\t\tPLANE_HASHES\t1024\nplane_t\t\t\t\t*planehash[PLANE_HASHES];\nvec3_t\t\t\t\tmap_mins, map_maxs;\n\n#ifdef SIN\ntextureref_t\t\tside_newrefs[MAX_MAPFILE_BRUSHSIDES];\n#endif\n\nmap_texinfo_t\t\tmap_texinfo[MAX_MAPFILE_TEXINFO];\nint\t\t\t\t\tmap_numtexinfo;\nint\t\t\t\t\tloadedmaptype;\t\t//loaded map type\n\n// undefine to make plane finding use linear sort\n#define\tUSE_HASHING\n\nint c_boxbevels;\nint c_edgebevels;\nint c_areaportals;\nint c_clipbrushes;\nint c_squattbrushes;\nint c_writtenbrushes;\n\n/*\n=============================================================================\n\nPLANE FINDING\n\n=============================================================================\n*/\n\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint PlaneSignBits(vec3_t normal)\n{\n\tint i, signbits;\n\n\tsignbits = 0;\n\tfor (i = 2; i >= 0; i--)\n\t{\n\t\tsignbits = (signbits << 1) + Sign(normal[i]);\n\t} //end for\n\treturn signbits;\n} //end of the function PlaneSignBits\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint PlaneTypeForNormal(vec3_t normal)\n{\n\tvec_t\tax, ay, az;\n\t\n// NOTE: should these have an epsilon around 1.0?\t\t\n\tif (normal[0] == 1.0 || normal[0] == -1.0)\n\t\treturn PLANE_X;\n\tif (normal[1] == 1.0 || normal[1] == -1.0)\n\t\treturn PLANE_Y;\n\tif (normal[2] == 1.0 || normal[2] == -1.0)\n\t\treturn PLANE_Z;\n\t\t\n\tax = fabs(normal[0]);\n\tay = fabs(normal[1]);\n\taz = fabs(normal[2]);\n\t\n\tif (ax >= ay && ax >= az)\n\t\treturn PLANE_ANYX;\n\tif (ay >= ax && ay >= az)\n\t\treturn PLANE_ANYY;\n\treturn PLANE_ANYZ;\n} //end of the function PlaneTypeForNormal\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n//ME NOTE: changed from 0.00001\n#define\tNORMAL_EPSILON\t0.0001\n//ME NOTE: changed from 0.01\n#define\tDIST_EPSILON\t0.02\nqboolean\tPlaneEqual(plane_t *p, vec3_t normal, vec_t dist)\n{\n#if 1\n\tif (\n\t   fabs(p->normal[0] - normal[0]) < NORMAL_EPSILON\n\t&& fabs(p->normal[1] - normal[1]) < NORMAL_EPSILON\n\t&& fabs(p->normal[2] - normal[2]) < NORMAL_EPSILON\n\t&& fabs(p->dist - dist) < DIST_EPSILON )\n\t\treturn true;\n#else\n\tif (p->normal[0] == normal[0]\n\t\t&& p->normal[1] == normal[1]\n\t\t&& p->normal[2] == normal[2]\n\t\t&& p->dist == dist)\n\t\treturn true;\n#endif\n\treturn false;\n} //end of the function PlaneEqual\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AddPlaneToHash(plane_t *p)\n{\n\tint\t\thash;\n\n\thash = (int)fabs(p->dist) / 8;\n\thash &= (PLANE_HASHES-1);\n\n\tp->hash_chain = planehash[hash];\n\tplanehash[hash] = p;\n} //end of the function AddPlaneToHash\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint CreateNewFloatPlane (vec3_t normal, vec_t dist)\n{\n\tplane_t\t*p, temp;\n\n\tif (VectorLength(normal) < 0.5)\n\t\tError (\"FloatPlane: bad normal\");\n\t// create a new plane\n\tif (nummapplanes+2 > MAX_MAPFILE_PLANES)\n\t\tError (\"MAX_MAPFILE_PLANES\");\n\n\tp = &mapplanes[nummapplanes];\n\tVectorCopy (normal, p->normal);\n\tp->dist = dist;\n\tp->type = (p+1)->type = PlaneTypeForNormal (p->normal);\n\tp->signbits = PlaneSignBits(p->normal);\n\n\tVectorSubtract (vec3_origin, normal, (p+1)->normal);\n\t(p+1)->dist = -dist;\n\t(p+1)->signbits = PlaneSignBits((p+1)->normal);\n\n\tnummapplanes += 2;\n\n\t// allways put axial planes facing positive first\n\tif (p->type < 3)\n\t{\n\t\tif (p->normal[0] < 0 || p->normal[1] < 0 || p->normal[2] < 0)\n\t\t{\n\t\t\t// flip order\n\t\t\ttemp = *p;\n\t\t\t*p = *(p+1);\n\t\t\t*(p+1) = temp;\n\n\t\t\tAddPlaneToHash (p);\n\t\t\tAddPlaneToHash (p+1);\n\t\t\treturn nummapplanes - 1;\n\t\t}\n\t}\n\n\tAddPlaneToHash (p);\n\tAddPlaneToHash (p+1);\n\treturn nummapplanes - 2;\n} //end of the function CreateNewFloatPlane\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid SnapVector(vec3_t normal)\n{\n\tint\t\ti;\n\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tif ( fabs(normal[i] - 1) < NORMAL_EPSILON )\n\t\t{\n\t\t\tVectorClear (normal);\n\t\t\tnormal[i] = 1;\n\t\t\tbreak;\n\t\t}\n\t\tif ( fabs(normal[i] - -1) < NORMAL_EPSILON )\n\t\t{\n\t\t\tVectorClear (normal);\n\t\t\tnormal[i] = -1;\n\t\t\tbreak;\n\t\t}\n\t}\n} //end of the function SnapVector\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid SnapPlane(vec3_t normal, vec_t *dist)\n{\n\tSnapVector(normal);\n\n\tif (fabs(*dist-Q_rint(*dist)) < DIST_EPSILON)\n\t\t*dist = Q_rint(*dist);\n} //end of the function SnapPlane\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#ifndef USE_HASHING\nint FindFloatPlane(vec3_t normal, vec_t dist)\n{\n\tint i;\n\tplane_t *p;\n\n\tSnapPlane(normal, &dist);\n\tfor (i = 0, p = mapplanes; i < nummapplanes; i++, p++)\n\t{\n\t\tif (PlaneEqual (p, normal, dist))\n\t\t{\n\t\t\tmapplaneusers[i]++;\n\t\t\treturn i;\n\t\t} //end if\n\t} //end for\n\ti = CreateNewFloatPlane (normal, dist);\n\tmapplaneusers[i]++;\n\treturn i;\n} //end of the function FindFloatPlane\n#else\nint FindFloatPlane (vec3_t normal, vec_t dist)\n{\n\tint i;\n\tplane_t *p;\n\tint hash, h;\n\n\tSnapPlane (normal, &dist);\n\thash = (int)fabs(dist) / 8;\n\thash &= (PLANE_HASHES-1);\n\n\t// search the border bins as well\n\tfor (i = -1; i <= 1; i++)\n\t{\n\t\th = (hash+i)&(PLANE_HASHES-1);\n\t\tfor (p = planehash[h]; p; p = p->hash_chain)\n\t\t{\n\t\t\tif (PlaneEqual(p, normal, dist))\n\t\t\t{\n\t\t\t\tmapplaneusers[p-mapplanes]++;\n\t\t\t\treturn p - mapplanes;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\ti = CreateNewFloatPlane (normal, dist);\n\tmapplaneusers[i]++;\n\treturn i;\n} //end of the function FindFloatPlane\n#endif\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint PlaneFromPoints (int *p0, int *p1, int *p2)\n{\n\tvec3_t\tt1, t2, normal;\n\tvec_t\tdist;\n\n\tVectorSubtract (p0, p1, t1);\n\tVectorSubtract (p2, p1, t2);\n\tCrossProduct (t1, t2, normal);\n\tVectorNormalize (normal);\n\n\tdist = DotProduct (p0, normal);\n\n\treturn FindFloatPlane (normal, dist);\n} //end of the function PlaneFromPoints\n//===========================================================================\n// Adds any additional planes necessary to allow the brush to be expanded\n// against axial bounding boxes\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AddBrushBevels (mapbrush_t *b)\n{\n\tint\t\taxis, dir;\n\tint\t\ti, j, k, l, order;\n\tside_t\tsidetemp;\n\tbrush_texture_t\ttdtemp;\n#ifdef SIN\n   textureref_t trtemp;\n#endif\n\tside_t\t*s, *s2;\n\tvec3_t\tnormal;\n\tfloat\tdist;\n\twinding_t\t*w, *w2;\n\tvec3_t\tvec, vec2;\n\tfloat\td;\n\n\t//\n\t// add the axial planes\n\t//\n\torder = 0;\n\tfor (axis=0 ; axis <3 ; axis++)\n\t{\n\t\tfor (dir=-1 ; dir <= 1 ; dir+=2, order++)\n\t\t{\n\t\t\t// see if the plane is allready present\n\t\t\tfor (i=0, s=b->original_sides ; i<b->numsides ; i++,s++)\n\t\t\t{\n\t\t\t\tif (mapplanes[s->planenum].normal[axis] == dir)\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (i == b->numsides)\n\t\t\t{\t// add a new side\n\t\t\t\tif (nummapbrushsides == MAX_MAP_BRUSHSIDES)\n\t\t\t\t\tError (\"MAX_MAP_BRUSHSIDES\");\n\t\t\t\tnummapbrushsides++;\n\t\t\t\tb->numsides++;\n\t\t\t\tVectorClear (normal);\n\t\t\t\tnormal[axis] = dir;\n\t\t\t\tif (dir == 1)\n\t\t\t\t\tdist = b->maxs[axis];\n\t\t\t\telse\n\t\t\t\t\tdist = -b->mins[axis];\n\t\t\t\ts->planenum = FindFloatPlane (normal, dist);\n\t\t\t\ts->texinfo = b->original_sides[0].texinfo;\n#ifdef SIN\n\t\t\t\ts->lightinfo = b->original_sides[0].lightinfo;\n#endif\n\t\t\t\ts->contents = b->original_sides[0].contents;\n\t\t\t\ts->flags |= SFL_BEVEL;\n\t\t\t\tc_boxbevels++;\n\t\t\t}\n\n\t\t\t// if the plane is not in it canonical order, swap it\n\t\t\tif (i != order)\n\t\t\t{\n\t\t\t\tsidetemp = b->original_sides[order];\n\t\t\t\tb->original_sides[order] = b->original_sides[i];\n\t\t\t\tb->original_sides[i] = sidetemp;\n\n\t\t\t\tj = b->original_sides - brushsides;\n\t\t\t\ttdtemp = side_brushtextures[j+order];\n\t\t\t\tside_brushtextures[j+order] = side_brushtextures[j+i];\n\t\t\t\tside_brushtextures[j+i] = tdtemp;\n\n#ifdef SIN\n\t\t\t\ttrtemp = side_newrefs[j+order];\n\t\t\t\tside_newrefs[j+order] = side_newrefs[j+i];\n\t\t\t\tside_newrefs[j+i] = trtemp;\n#endif\n\t\t\t}\n\t\t}\n\t}\n\n\t//\n\t// add the edge bevels\n\t//\n\tif (b->numsides == 6)\n\t\treturn;\t\t// pure axial\n\n\t// test the non-axial plane edges\n\tfor (i=6 ; i<b->numsides ; i++)\n\t{\n\t\ts = b->original_sides + i;\n\t\tw = s->winding;\n\t\tif (!w)\n\t\t\tcontinue;\n\t\tfor (j=0 ; j<w->numpoints ; j++)\n\t\t{\n\t\t\tk = (j+1)%w->numpoints;\n\t\t\tVectorSubtract (w->p[j], w->p[k], vec);\n\t\t\tif (VectorNormalize (vec) < 0.5)\n\t\t\t\tcontinue;\n\t\t\tSnapVector (vec);\n\t\t\tfor (k=0 ; k<3 ; k++)\n\t\t\t\tif ( vec[k] == -1 || vec[k] == 1)\n\t\t\t\t\tbreak;\t// axial\n\t\t\tif (k != 3)\n\t\t\t\tcontinue;\t// only test non-axial edges\n\n\t\t\t// try the six possible slanted axials from this edge\n\t\t\tfor (axis=0 ; axis <3 ; axis++)\n\t\t\t{\n\t\t\t\tfor (dir=-1 ; dir <= 1 ; dir+=2)\n\t\t\t\t{\n\t\t\t\t\t// construct a plane\n\t\t\t\t\tVectorClear (vec2);\n\t\t\t\t\tvec2[axis] = dir;\n\t\t\t\t\tCrossProduct (vec, vec2, normal);\n\t\t\t\t\tif (VectorNormalize (normal) < 0.5)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tdist = DotProduct (w->p[j], normal);\n\n\t\t\t\t\t// if all the points on all the sides are\n\t\t\t\t\t// behind this plane, it is a proper edge bevel\n\t\t\t\t\tfor (k=0 ; k<b->numsides ; k++)\n\t\t\t\t\t{\n\t\t\t\t\t\t// if this plane has allready been used, skip it\n\t\t\t\t\t\tif (PlaneEqual (&mapplanes[b->original_sides[k].planenum]\n\t\t\t\t\t\t\t, normal, dist) )\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tw2 = b->original_sides[k].winding;\n\t\t\t\t\t\tif (!w2)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tfor (l=0 ; l<w2->numpoints ; l++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\td = DotProduct (w2->p[l], normal) - dist;\n\t\t\t\t\t\t\tif (d > 0.1)\n\t\t\t\t\t\t\t\tbreak;\t// point in front\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (l != w2->numpoints)\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (k != b->numsides)\n\t\t\t\t\t\tcontinue;\t// wasn't part of the outer hull\n\t\t\t\t\t// add this plane\n\t\t\t\t\tif (nummapbrushsides == MAX_MAP_BRUSHSIDES)\n\t\t\t\t\t\tError (\"MAX_MAP_BRUSHSIDES\");\n\t\t\t\t\tnummapbrushsides++;\n\t\t\t\t\ts2 = &b->original_sides[b->numsides];\n\t\t\t\t\ts2->planenum = FindFloatPlane (normal, dist);\n\t\t\t\t\ts2->texinfo = b->original_sides[0].texinfo;\n#ifdef SIN\n\t\t\t\t\ts2->lightinfo = b->original_sides[0].lightinfo;\n#endif\n\t\t\t\t\ts2->contents = b->original_sides[0].contents;\n\t\t\t\t\ts2->flags |= SFL_BEVEL;\n\t\t\t\t\tc_edgebevels++;\n\t\t\t\t\tb->numsides++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n} //end of the function AddBrushBevels\n//===========================================================================\n// creates windigs for sides and mins / maxs for the brush\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean MakeBrushWindings(mapbrush_t *ob)\n{\n\tint\t\t\ti, j;\n\twinding_t\t*w;\n\tside_t\t\t*side;\n\tplane_t\t\t*plane;\n\n\tClearBounds (ob->mins, ob->maxs);\n\n\tfor (i = 0; i < ob->numsides; i++)\n\t{\n\t\tplane = &mapplanes[ob->original_sides[i].planenum];\n\t\tw = BaseWindingForPlane(plane->normal, plane->dist);\n\t\tfor (j = 0; j <ob->numsides && w; j++)\n\t\t{\n\t\t\tif (i == j) continue;\n\t\t\tif (ob->original_sides[j].flags & SFL_BEVEL) continue;\n\t\t\tplane = &mapplanes[ob->original_sides[j].planenum^1];\n\t\t\tChopWindingInPlace(&w, plane->normal, plane->dist, 0); //CLIP_EPSILON);\n\t\t}\n\n\t\tside = &ob->original_sides[i];\n\t\tside->winding = w;\n\t\tif (w)\n\t\t{\n\t\t\tside->flags |= SFL_VISIBLE;\n\t\t\tfor (j = 0; j < w->numpoints; j++)\n\t\t\t\tAddPointToBounds (w->p[j], ob->mins, ob->maxs);\n\t\t}\n\t}\n\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\t//IDBUG: all the indexes into the mins and maxs were zero (not using i)\n\t\tif (ob->mins[i] < -MAX_MAP_BOUNDS || ob->maxs[i] > MAX_MAP_BOUNDS)\n\t\t{\n\t\t\tLog_Print(\"entity %i, brush %i: bounds out of range\\n\", ob->entitynum, ob->brushnum);\n\t\t\tob->numsides = 0; //remove the brush\n\t\t\tbreak;\n\t\t} //end if\n\t\tif (ob->mins[i] > MAX_MAP_BOUNDS || ob->maxs[i] < -MAX_MAP_BOUNDS)\n\t\t{\n\t\t\tLog_Print(\"entity %i, brush %i: no visible sides on brush\\n\", ob->entitynum, ob->brushnum);\n\t\t\tob->numsides = 0; //remove the brush\n\t\t\tbreak;\n\t\t} //end if\n\t} //end for\n\treturn true;\n} //end of the function MakeBrushWindings\n//===========================================================================\n// FIXME: currently doesn't mark all bevels\n// NOTE: when one brush bevel is found the remaining sides of the brush\n//       are bevels as well (when the brush isn't expanded for AAS :))\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid MarkBrushBevels(mapbrush_t *brush)\n{\n\tint i;\n\tint we;\n\tside_t *s;\n\n\t//check all the sides of the brush\n\tfor (i = 0; i < brush->numsides; i++)\n\t{\n\t\ts = brush->original_sides + i;\n\t\t//if the side has no winding\n\t\tif (!s->winding)\n\t\t{\n\t\t\tLog_Write(\"MarkBrushBevels: brush %d no winding\", brush->brushnum);\n\t\t\ts->flags |= SFL_BEVEL;\n\t\t} //end if\n\t\t//if the winding is tiny\n\t\telse if (WindingIsTiny(s->winding))\n\t\t{\n\t\t\ts->flags |= SFL_BEVEL;\n\t\t\tLog_Write(\"MarkBrushBevels: brush %d tiny winding\", brush->brushnum);\n\t\t} //end else if\n\t\t//if the winding has errors\n\t\telse\n\t\t{\n\t\t\twe = WindingError(s->winding);\n\t\t\tif (we == WE_NOTENOUGHPOINTS\n\t\t\t\t\t|| we == WE_SMALLAREA\n\t\t\t\t\t|| we == WE_POINTBOGUSRANGE\n//\t\t\t\t\t|| we == WE_NONCONVEX\n\t\t\t\t\t)\n\t\t\t{\n\t\t\t\tLog_Write(\"MarkBrushBevels: brush %d %s\", brush->brushnum, WindingErrorString());\n\t\t\t\ts->flags |= SFL_BEVEL;\n\t\t\t} //end else if\n\t\t} //end else\n\t\tif (s->flags & SFL_BEVEL)\n\t\t{\n\t\t\ts->flags &= ~SFL_VISIBLE;\n\t\t\t//if the side has a valid plane\n\t\t\tif (s->planenum > 0 && s->planenum < nummapplanes)\n\t\t\t{\n\t\t\t\t//if it is an axial plane\n\t\t\t\tif (mapplanes[s->planenum].type < 3) c_boxbevels++;\n\t\t\t\telse c_edgebevels++;\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n} //end of the function MarkBrushBevels\n//===========================================================================\n// returns true if the map brush already exists\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint BrushExists(mapbrush_t *brush)\n{\n\tint i, s1, s2;\n\tside_t *side1, *side2;\n\tmapbrush_t *brush1, *brush2;\n\n\tfor (i = 0; i < nummapbrushes; i++)\n\t{\n\t\tbrush1 = brush;\n\t\tbrush2 = &mapbrushes[i];\n\t\t//compare the brushes\n\t\tif (brush1->entitynum != brush2->entitynum) continue;\n\t\t//if (brush1->contents != brush2->contents) continue;\n\t\tif (brush1->numsides != brush2->numsides) continue;\n\t\tfor (s1 = 0; s1 < brush1->numsides; s1++)\n\t\t{\n\t\t\tside1 = brush1->original_sides + s1;\n\t\t\t//\n\t\t\tfor (s2 = 0; s2 < brush2->numsides; s2++)\n\t\t\t{\n\t\t\t\tside2 = brush2->original_sides + s2;\n\t\t\t\t//\n\t\t\t\tif ((side1->planenum & ~1) == (side2->planenum & ~1)\n//\t\t\t\t\t\t&& side1->texinfo == side2->texinfo\n//\t\t\t\t\t\t&& side1->contents == side2->contents\n//\t\t\t\t\t\t&& side1->surf == side2->surf\n\t\t\t\t\t) break;\n\t\t\t} //end if\n\t\t\tif (s2 >= brush2->numsides) break;\n\t\t} //end for\n\t\tif (s1 >= brush1->numsides) return true;\n\t} //end for\n\treturn false;\n} //end of the function BrushExists\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean WriteMapBrush(FILE *fp, mapbrush_t *brush, vec3_t origin)\n{\n\tint sn, rotate, shift[2], sv, tv, planenum, p1, i, j;\n\tfloat scale[2], originshift[2], ang1, ang2, newdist;\n\tvec3_t vecs[2], axis[2];\n\tmap_texinfo_t *ti;\n\twinding_t *w;\n\tside_t *s;\n\tplane_t *plane;\n\n\tif (noliquids)\n\t{\n\t\tif (brush->contents & (CONTENTS_WATER|CONTENTS_SLIME|CONTENTS_LAVA))\n\t\t{\n\t\t\treturn true;\n\t\t} //end if\n\t} //end if\n\t//if the brush has no contents\n\tif (!brush->contents) return true;\n\t//print the leading {\n\tif (fprintf(fp, \" { //brush %d\\n\", brush->brushnum) < 0) return false;\n\t//write brush sides\n\tfor (sn = 0; sn < brush->numsides; sn++)\n\t{\n\t\ts = brush->original_sides + sn;\n\t\t//don't write out bevels\n\t\tif (!(s->flags & SFL_BEVEL))\n\t\t{\n\t\t\t//if the entity has an origin set\n\t\t\tif (origin[0] || origin[1] || origin[2])\n\t\t\t{\n\t\t\t\tnewdist = mapplanes[s->planenum].dist +\n\t\t\t\t\tDotProduct(mapplanes[s->planenum].normal, origin);\n\t\t\t\tplanenum = FindFloatPlane(mapplanes[s->planenum].normal, newdist);\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tplanenum = s->planenum;\n\t\t\t} //end else\n\t\t\t//always take the first plane, then flip the points if necesary\n\t\t\tplane = &mapplanes[planenum & ~1];\n\t\t\tw = BaseWindingForPlane(plane->normal, plane->dist);\n\t\t\t//\n\t\t\tfor (i = 0; i < 3; i++)\n\t\t\t{\n\t\t\t\tfor (j = 0; j < 3; j++)\n\t\t\t\t{\n\t\t\t\t\tif (fabs(w->p[i][j]) < 0.2) w->p[i][j] = 0;\n\t\t\t\t\telse if (fabs((int)w->p[i][j] - w->p[i][j]) < 0.3) w->p[i][j] = (int) w->p[i][j];\n\t\t\t\t\t//w->p[i][j] = (int) (w->p[i][j] + 0.2);\n\t\t\t\t} //end for\n\t\t\t} //end for\n\t\t\t//three non-colinear points to define the plane\n\t\t\tif (planenum & 1) p1 = 1;\n\t\t\telse p1 = 0;\n\t\t\tif (fprintf(fp,\"  ( %5i %5i %5i ) \", (int)w->p[p1][0], (int)w->p[p1][1], (int)w->p[p1][2]) < 0) return false;\n\t\t\tif (fprintf(fp,\"( %5i %5i %5i ) \", (int)w->p[!p1][0], (int)w->p[!p1][1], (int)w->p[!p1][2]) < 0) return false;\n\t\t\tif (fprintf(fp,\"( %5i %5i %5i ) \", (int)w->p[2][0], (int)w->p[2][1], (int)w->p[2][2]) < 0) return false;\n\t\t\t//free the winding\n\t\t\tFreeWinding(w);\n\t\t\t//\n\t\t\tif (s->texinfo == TEXINFO_NODE)\n\t\t\t{\n\t\t\t\tif (brush->contents & CONTENTS_PLAYERCLIP)\n\t\t\t\t{\n\t\t\t\t\t//player clip\n\t\t\t\t\tif (loadedmaptype == MAPTYPE_SIN)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (fprintf(fp, \"generic/misc/clip 0 0 0 1 1\") < 0) return false;\n\t\t\t\t\t} //end if\n\t\t\t\t\telse if (loadedmaptype == MAPTYPE_QUAKE2)\n\t\t\t\t\t{\t//FIXME: don't always use e1u1\n\t\t\t\t\t\tif (fprintf(fp, \"e1u1/clip 0 0 0 1 1\") < 0) return false;\n\t\t\t\t\t} //end else\n\t\t\t\t\telse if (loadedmaptype == MAPTYPE_QUAKE3)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (fprintf(fp, \"e1u1/clip 0 0 0 1 1\") < 0) return false;\n\t\t\t\t\t} //end else if\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tif (fprintf(fp, \"clip 0 0 0 1 1\") < 0) return false;\n\t\t\t\t\t} //end else\n\t\t\t\t} //end if\n\t\t\t\telse if (brush->contents == CONTENTS_MONSTERCLIP)\n\t\t\t\t{\n\t\t\t\t\t//monster clip\n\t\t\t\t\tif (loadedmaptype == MAPTYPE_SIN)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (fprintf(fp, \"generic/misc/monster 0 0 0 1 1\") < 0) return false;\n\t\t\t\t\t} //end if\n\t\t\t\t\telse if (loadedmaptype == MAPTYPE_QUAKE2)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (fprintf(fp, \"e1u1/clip_mon 0 0 0 1 1\") < 0) return false;\n\t\t\t\t\t} //end else\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tif (fprintf(fp, \"clip 0 0 0 1 1\") < 0) return false;\n\t\t\t\t\t} //end else\n\t\t\t\t} //end else\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (fprintf(fp, \"clip 0 0 0 1 1\") < 0) return false;\n\t\t\t\t\tLog_Write(\"brush->contents = %d\\n\", brush->contents);\n\t\t\t\t} //end else\n\t\t\t} //end if\n\t\t\telse if (loadedmaptype == MAPTYPE_SIN && s->texinfo == 0)\n\t\t\t{\n\t\t\t\tif (brush->contents & CONTENTS_DUMMYFENCE)\n\t\t\t\t{\n\t\t\t\t\tif (fprintf(fp, \"generic/misc/fence 0 0 0 1 1\") < 0) return false;\n\t\t\t\t} //end if\n\t\t\t\telse if (brush->contents & CONTENTS_MIST)\n\t\t\t\t{\n\t\t\t\t\tif (fprintf(fp, \"generic/misc/volumetric_base 0 0 0 1 1\") < 0) return false;\n\t\t\t\t} //end if\n\t\t\t\telse //unknown so far\n\t\t\t\t{\n\t\t\t\t\tif (fprintf(fp, \"generic/misc/red 0 0 0 1 1\") < 0) return false;\n\t\t\t\t} //end else\n\t\t\t} //end if\n\t\t\telse if (loadedmaptype == MAPTYPE_QUAKE3)\n\t\t\t{\n\t\t\t\t//always use the same texture\n\t\t\t\tif (fprintf(fp, \"e2u3/floor1_2 0 0 0 1 1 1 0 0\") < 0) return false;\n\t\t\t} //end else if\n\t\t\telse\n\t\t\t{\n\t\t\t\t//*\n\t\t\t\tti = &map_texinfo[s->texinfo];\n\t\t\t\t//the scaling of the texture\n\t\t\t\tscale[0] = 1 / VectorNormalize2(ti->vecs[0], vecs[0]);\n\t\t\t\tscale[1] = 1 / VectorNormalize2(ti->vecs[1], vecs[1]);\n\t\t\t\t//\n\t\t\t\tTextureAxisFromPlane(plane, axis[0], axis[1]);\n\t\t\t\t//calculate texture shift done by entity origin\n\t\t\t\toriginshift[0] = DotProduct(origin, axis[0]);\n\t\t\t\toriginshift[1] = DotProduct(origin, axis[1]);\n\t\t\t\t//the texture shift without origin shift\n\t\t\t\tshift[0] = ti->vecs[0][3] - originshift[0];\n\t\t\t\tshift[1] = ti->vecs[1][3] - originshift[1];\n\t\t\t\t//\n\t\t\t\tif (axis[0][0]) sv = 0;\n\t\t\t\telse if (axis[0][1]) sv = 1;\n\t\t\t\telse sv = 2;\n\t\t\t\tif (axis[1][0]) tv = 0;\n\t\t\t\telse if (axis[1][1]) tv = 1;\n\t\t\t\telse tv = 2;\n\t\t\t\t//calculate rotation of texture\n\t\t\t\tif (vecs[0][tv] == 0) ang1 = vecs[0][sv] > 0 ? 90.0 : -90.0;\n\t\t\t\telse ang1 = atan2(vecs[0][sv], vecs[0][tv]) * 180 / Q_PI;\n\t\t\t\tif (ang1 < 0) ang1 += 360;\n\t\t\t\tif (ang1 >= 360) ang1 -= 360;\n\t\t\t\tif (axis[0][tv] == 0) ang2 = axis[0][sv] > 0 ? 90.0 : -90.0;\n\t\t\t\telse ang2 = atan2(axis[0][sv], axis[0][tv]) * 180 / Q_PI;\n\t\t\t\tif (ang2 < 0) ang2 += 360;\n\t\t\t\tif (ang2 >= 360) ang2 -= 360;\n\t\t\t\trotate = ang2 - ang1;\n\t\t\t\tif (rotate < 0) rotate += 360;\n\t\t\t\tif (rotate >= 360) rotate -= 360;\n\t\t\t\t//write the texture info\n\t\t\t\tif (fprintf(fp, \"%s %d %d %d\", ti->texture, shift[0], shift[1], rotate) < 0) return false;\n\t\t\t\tif (fabs(scale[0] - ((int) scale[0])) < 0.001)\n\t\t\t\t{\n\t\t\t\t\tif (fprintf(fp, \" %d\", (int) scale[0]) < 0) return false;\n\t\t\t\t} //end if\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (fprintf(fp, \" %4f\", scale[0]) < 0) return false;\n\t\t\t\t} //end if\n\t\t\t\tif (fabs(scale[1] - ((int) scale[1])) < 0.001)\n\t\t\t\t{\n\t\t\t\t\tif (fprintf(fp, \" %d\", (int) scale[1]) < 0) return false;\n\t\t\t\t} //end if\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (fprintf(fp, \" %4f\", scale[1]) < 0) return false;\n\t\t\t\t} //end else\n\t\t\t\t//write the extra brush side info\n\t\t\t\tif (loadedmaptype == MAPTYPE_QUAKE2)\n\t\t\t\t{\n\t\t\t\t\tif (fprintf(fp, \" %ld %ld %ld\", s->contents, ti->flags, ti->value) < 0) return false;\n\t\t\t\t} //end if\n\t\t\t\t//*/\n\t\t\t} //end else\n\t\t\tif (fprintf(fp, \"\\n\") < 0) return false;\n\t\t} //end if\n\t} //end if\n\tif (fprintf(fp, \" }\\n\") < 0) return false;\n\tc_writtenbrushes++;\n\treturn true;\n} //end of the function WriteMapBrush\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean WriteOriginBrush(FILE *fp, vec3_t origin)\n{\n\tvec3_t normal;\n\tfloat dist;\n\tint i, s;\n\twinding_t *w;\n\n\tif (fprintf(fp, \" {\\n\") < 0) return false;\n\t//\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tfor (s = -1; s <= 1; s += 2)\n\t\t{\n\t\t\t//\n\t\t\tVectorClear(normal);\n\t\t\tnormal[i] = s;\n\t\t\tdist = origin[i] * s + 16;\n\t\t\t//\n\t\t\tw = BaseWindingForPlane(normal, dist);\n\t\t\t//three non-colinear points to define the plane\n\t\t\tif (fprintf(fp,\"  ( %5i %5i %5i ) \", (int)w->p[0][0], (int)w->p[0][1], (int)w->p[0][2]) < 0) return false;\n\t\t\tif (fprintf(fp,\"( %5i %5i %5i ) \", (int)w->p[1][0], (int)w->p[1][1], (int)w->p[1][2]) < 0) return false;\n\t\t\tif (fprintf(fp,\"( %5i %5i %5i ) \", (int)w->p[2][0], (int)w->p[2][1], (int)w->p[2][2]) < 0) return false;\n\t\t\t//free the winding\n\t\t\tFreeWinding(w);\n\t\t\t//write origin texture:\n\t\t\t// CONTENTS_ORIGIN = 16777216\n\t\t\t// SURF_NODRAW = 128\n\t\t\tif (loadedmaptype == MAPTYPE_SIN)\n\t\t\t{\n\t\t\t\tif (fprintf(fp, \"generic/misc/origin 0 0 0 1 1\") < 0) return false;\n\t\t\t} //end if\n\t\t\telse if (loadedmaptype == MAPTYPE_HALFLIFE)\n\t\t\t{\n\t\t\t\tif (fprintf(fp, \"origin 0 0 0 1 1\") < 0) return false;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (fprintf(fp, \"e1u1/origin 0 0 0 1 1\") < 0) return false;\n\t\t\t} //end else\n\t\t\t//Quake2 extra brush side info\n\t\t\tif (loadedmaptype == MAPTYPE_QUAKE2)\n\t\t\t{\n\t\t\t\t//if (fprintf(fp, \" 16777216 128 0\") < 0) return false;\n\t\t\t} //end if\n\t\t\tif (fprintf(fp, \"\\n\") < 0) return false;\n\t\t} //end for\n\t} //end for\n\tif (fprintf(fp, \" }\\n\") < 0) return false;\n\tc_writtenbrushes++;\n\treturn true;\n} //end of the function WriteOriginBrush\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nmapbrush_t *GetAreaPortalBrush(entity_t *mapent)\n{\n\tint portalnum, bn;\n\tmapbrush_t *brush;\n\n\t//the area portal number\n\tportalnum = mapent->areaportalnum;\n\t//find the area portal brush in the world brushes\n\tfor (bn = 0; bn < nummapbrushes && portalnum; bn++)\n\t{\n\t\tbrush = &mapbrushes[bn];\n\t\t//must be in world entity\n\t\tif (brush->entitynum == 0)\n\t\t{\n\t\t\tif (brush->contents & CONTENTS_AREAPORTAL)\n\t\t\t{\n\t\t\t\tportalnum--;\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n\tif (bn < nummapbrushes)\n\t{\n\t\treturn brush;\n\t} //end if\n\telse\n\t{\n\t\tLog_Print(\"area portal %d brush not found\\n\", mapent->areaportalnum);\n\t\treturn NULL;\n\t} //end else\n} //end of the function GetAreaPortalBrush\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean WriteMapFileSafe(FILE *fp)\n{\n\tchar key[1024], value[1024];\n\tint i, bn, entitybrushes;\n\tepair_t *ep;\n\tmapbrush_t *brush;\n\tentity_t *mapent;\n\t//vec3_t vec_origin = {0, 0, 0};\n\n\t//\n\tif (fprintf(fp,\"//=====================================================\\n\"\n\t\t\t\"//\\n\"\n\t\t\t\"// map file created with BSPC \"BSPC_VERSION\"\\n\"\n\t\t\t\"//\\n\"\n\t\t\t\"// BSPC is designed to decompile material in which you own the copyright\\n\"\n\t\t\t\"// or have obtained permission to decompile from the copyright owner. Unless\\n\"\n\t\t\t\"// you own the copyright or have permission to decompile from the copyright\\n\"\n\t\t\t\"// owner, you may be violating copyright law and be subject to payment of\\n\"\n\t\t\t\"// damages and other remedies. If you are uncertain about your rights, contact\\n\"\n\t\t\t\"// your legal advisor.\\n\"\n\t\t\t\"//\\n\") < 0) return false;\n\tif (loadedmaptype == MAPTYPE_SIN)\n\t{\n\t\tif (fprintf(fp,\n\t\t\t\t\t\t\"// generic/misc/red is used for unknown textures\\n\") < 0) return false;\n\t} //end if\n\tif (fprintf(fp,\"//\\n\"\n\t\t\t\t\t\t\"//=====================================================\\n\") < 0) return false;\n\t//write out all the entities\n\tfor (i = 0; i < num_entities; i++)\n\t{\n\t\tmapent = &entities[i];\n\t\tif (!mapent->epairs)\n\t\t{\n\t\t\tcontinue;\n\t\t} //end if\n\t\tif (fprintf(fp, \"{\\n\") < 0) return false;\n\t\t//\n\t\tif (loadedmaptype == MAPTYPE_QUAKE3)\n\t\t{\n\t\t\tif (!stricmp(ValueForKey(mapent, \"classname\"), \"light\"))\n\t\t\t{\n\t\t\t\tSetKeyValue(mapent, \"light\", \"10000\");\n\t\t\t} //end if\n\t\t} //end if\n\t\t//write epairs\n\t\tfor (ep = mapent->epairs; ep; ep = ep->next)\n\t\t{\n\t\t\tstrcpy(key, ep->key);\n\t\t\tStripTrailing (key);\n\t\t\tstrcpy(value, ep->value);\n\t\t\tStripTrailing(value);\n\t\t\t//\n\t\t\tif (loadedmaptype == MAPTYPE_QUAKE2 ||\n\t\t\t\t\tloadedmaptype == MAPTYPE_SIN)\n\t\t\t{\n\t\t\t\t//don't write an origin for BSP models\n\t\t\t\tif (mapent->modelnum >= 0 && !strcmp(key, \"origin\")) continue;\n\t\t\t} //end if\n\t\t\t//don't write BSP model numbers\n\t\t\tif (mapent->modelnum >= 0 && !strcmp(key, \"model\") && value[0] == '*') continue;\n\t\t\t//\n\t\t\tif (fprintf(fp, \" \\\"%s\\\" \\\"%s\\\"\\n\", key, value) < 0) return false;\n\t\t} //end for\n\t\t//\n\t\tif (ValueForKey(mapent, \"origin\")) GetVectorForKey(mapent, \"origin\", mapent->origin);\n\t\telse mapent->origin[0] = mapent->origin[1] = mapent->origin[2] = 0;\n\t\t//if this is an area portal entity\n\t\tif (!strcmp(\"func_areaportal\", ValueForKey(mapent, \"classname\")))\n\t\t{\n\t\t\tbrush = GetAreaPortalBrush(mapent);\n\t\t\tif (!brush) return false;\n\t\t\tif (!WriteMapBrush(fp, brush, mapent->origin)) return false;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tentitybrushes = false;\n\t\t\t//write brushes\n\t\t\tfor (bn = 0; bn < nummapbrushes; bn++)\n\t\t\t{\n\t\t\t\tbrush = &mapbrushes[bn];\n\t\t\t\t//if the brush is part of this entity\n\t\t\t\tif (brush->entitynum == i)\n\t\t\t\t{\n\t\t\t\t\t//don't write out area portal brushes in the world\n\t\t\t\t\tif (!((brush->contents & CONTENTS_AREAPORTAL) && brush->entitynum == 0))\n\t\t\t\t\t{\n\t\t\t\t\t\t/*\n\t\t\t\t\t\tif (!strcmp(\"func_door_rotating\", ValueForKey(mapent, \"classname\")))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tAAS_PositionFuncRotatingBrush(mapent, brush);\n\t\t\t\t\t\t\tif (!WriteMapBrush(fp, brush, vec_origin)) return false;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t\telse //*/\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (!WriteMapBrush(fp, brush, mapent->origin)) return false;\n\t\t\t\t\t\t} //end else\n\t\t\t\t\t\tentitybrushes = true;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t} //end for\n\t\t\t//if the entity had brushes\n\t\t\tif (entitybrushes)\n\t\t\t{\n\t\t\t\t//if the entity has an origin set\n\t\t\t\tif (mapent->origin[0] || mapent->origin[1] || mapent->origin[2])\n\t\t\t\t{\n\t\t\t\t\tif (!WriteOriginBrush(fp, mapent->origin)) return false;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end else\n\t\tif (fprintf(fp, \"}\\n\") < 0) return false;\n\t} //end for\n\tif (fprintf(fp, \"//total of %d brushes\\n\", c_writtenbrushes) < 0) return false;\n\treturn true;\n} //end of the function WriteMapFileSafe\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid WriteMapFile(char *filename)\n{\n\tFILE *fp;\n\tdouble start_time;\n\n\tc_writtenbrushes = 0;\n\t//the time started\n\tstart_time = I_FloatTime();\n\t//\n\tLog_Print(\"writing %s\\n\", filename);\n\tfp = fopen(filename, \"wb\");\n\tif (!fp)\n\t{\n\t\tLog_Print(\"can't open %s\\n\", filename);\n\t\treturn;\n\t} //end if\n\tif (!WriteMapFileSafe(fp))\n\t{\n\t\tfclose(fp);\n\t\tLog_Print(\"error writing map file %s\\n\", filename);\n\t\treturn;\n\t} //end if\n\tfclose(fp);\n\t//display creation time\n\tLog_Print(\"written %d brushes\\n\", c_writtenbrushes);\n\tLog_Print(\"map file written in %5.0f seconds\\n\", I_FloatTime() - start_time);\n} //end of the function WriteMapFile\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid PrintMapInfo(void)\n{\n\tLog_Print(\"\\n\");\n\tLog_Print(\"%6i brushes\\n\", nummapbrushes);\n\tLog_Print(\"%6i brush sides\\n\", nummapbrushsides);\n//\tLog_Print(\"%6i clipbrushes\\n\", c_clipbrushes);\n//\tLog_Print(\"%6i total sides\\n\", nummapbrushsides);\n//\tLog_Print(\"%6i boxbevels\\n\", c_boxbevels);\n//\tLog_Print(\"%6i edgebevels\\n\", c_edgebevels);\n//\tLog_Print(\"%6i entities\\n\", num_entities);\n//\tLog_Print(\"%6i planes\\n\", nummapplanes);\n//\tLog_Print(\"%6i areaportals\\n\", c_areaportals);\n//\tLog_Print(\"%6i squatt brushes\\n\", c_squattbrushes);\n//\tLog_Print(\"size: %5.0f,%5.0f,%5.0f to %5.0f,%5.0f,%5.0f\\n\", map_mins[0],map_mins[1],map_mins[2],\n//\t\tmap_maxs[0],map_maxs[1],map_maxs[2]);\n} //end of the function PrintMapInfo\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid ResetMapLoading(void)\n{\n\tint i;\n\tepair_t *ep, *nextep;\n\n\tQ2_ResetMapLoading();\n\tSin_ResetMapLoading();\n\n\t//free all map brush side windings\n\tfor (i = 0; i < nummapbrushsides; i++)\n\t{\n\t\tif (brushsides[i].winding)\n\t\t{\n\t\t\tFreeWinding(brushsides[i].winding);\n\t\t} //end for\n\t} //end for\n\n\t//reset regular stuff\n\tnummapbrushes = 0;\n\tmemset(mapbrushes, 0, MAX_MAPFILE_BRUSHES * sizeof(mapbrush_t));\n\t//\n\tnummapbrushsides = 0;\n\tmemset(brushsides, 0, MAX_MAPFILE_BRUSHSIDES * sizeof(side_t));\n\tmemset(side_brushtextures, 0, MAX_MAPFILE_BRUSHSIDES * sizeof(brush_texture_t));\n\t//\n\tnummapplanes = 0;\n\tmemset(mapplanes, 0, MAX_MAPFILE_PLANES * sizeof(plane_t));\n\t//\n\tmemset(planehash, 0, PLANE_HASHES * sizeof(plane_t *));\n\t//\n\tmemset(map_texinfo, 0, MAX_MAPFILE_TEXINFO * sizeof(map_texinfo_t));\n\tmap_numtexinfo = 0;\n\t//\n\tVectorClear(map_mins);\n\tVectorClear(map_maxs);\n\t//\n\tc_boxbevels = 0;\n\tc_edgebevels = 0;\n\tc_areaportals = 0;\n\tc_clipbrushes = 0;\n\tc_writtenbrushes = 0;\n\t//clear the entities\n\tfor (i = 0; i < num_entities; i++)\n\t{\n\t\tfor (ep = entities[i].epairs; ep; ep = nextep)\n\t\t{\n\t\t\tnextep = ep->next;\n\t\t\tFreeMemory(ep->key);\n\t\t\tFreeMemory(ep->value);\n\t\t\tFreeMemory(ep);\n\t\t} //end for\n\t} //end for\n\tnum_entities = 0;\n\tmemset(entities, 0, MAX_MAP_ENTITIES * sizeof(entity_t));\n} //end of the function ResetMapLoading\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#ifndef Q1_BSPVERSION\n#define Q1_BSPVERSION\t29\n#endif\n#ifndef HL_BSPVERSION\n#define HL_BSPVERSION\t30\n#endif\n\n#define Q2_BSPHEADER\t\t\t\t(('P'<<24)+('S'<<16)+('B'<<8)+'I')\t//IBSP\n#define Q2_BSPVERSION\t38\n\n#define SINGAME_BSPHEADER\t\t(('P'<<24)+('S'<<16)+('B'<<8)+'R')\t//RBSP\n#define SINGAME_BSPVERSION\t\t1\n\n#define SIN_BSPHEADER\t\t\t(('P'<<24)+('S'<<16)+('B'<<8)+'I')\t//IBSP\n#define SIN_BSPVERSION\t41\n\ntypedef struct\n{\n\tint ident;\n\tint version;\n} idheader_t;\n\nint LoadMapFromBSP(struct quakefile_s *qf)\n{\n\tidheader_t idheader;\n\n\tif (ReadQuakeFile(qf, &idheader, 0, sizeof(idheader_t)) != sizeof(idheader_t))\n\t{\n\t\treturn false;\n\t} //end if\n\n\tidheader.ident = LittleLong(idheader.ident);\n\tidheader.version = LittleLong(idheader.version);\n\t//Quake3 BSP file\n\tif (idheader.ident == Q3_BSP_IDENT && idheader.version == Q3_BSP_VERSION)\n\t{\n\t\tResetMapLoading();\n\t\tQ3_LoadMapFromBSP(qf);\n\t\tQ3_FreeMaxBSP();\n\t} //end if\n\t//Quake2 BSP file\n\telse if (idheader.ident == Q2_BSPHEADER && idheader.version == Q2_BSPVERSION)\n\t{\n\t\tResetMapLoading();\n\t\tQ2_AllocMaxBSP();\n\t\tQ2_LoadMapFromBSP(qf->filename, qf->offset, qf->length);\n\t\tQ2_FreeMaxBSP();\n\t} //endif\n\t//Sin BSP file\n\telse if ((idheader.ident == SIN_BSPHEADER && idheader.version == SIN_BSPVERSION) ||\n\t\t\t\t//the dorks gave the same format another ident and verions\n\t\t\t\t(idheader.ident == SINGAME_BSPHEADER && idheader.version == SINGAME_BSPVERSION))\n\t{\n\t\tResetMapLoading();\n\t\tSin_AllocMaxBSP();\n\t\tSin_LoadMapFromBSP(qf->filename, qf->offset, qf->length);\n\t\tSin_FreeMaxBSP();\n\t} //end if\n\t//the Quake1 bsp files don't have a ident only a version\n\telse if (idheader.ident == Q1_BSPVERSION)\n\t{\n\t\tResetMapLoading();\n\t\tQ1_AllocMaxBSP();\n\t\tQ1_LoadMapFromBSP(qf->filename, qf->offset, qf->length);\n\t\tQ1_FreeMaxBSP();\n\t} //end if\n\t//Half-Life also only uses a version number\n\telse if (idheader.ident == HL_BSPVERSION)\n\t{\n\t\tResetMapLoading();\n\t\tHL_AllocMaxBSP();\n\t\tHL_LoadMapFromBSP(qf->filename, qf->offset, qf->length);\n\t\tHL_FreeMaxBSP();\n\t} //end if\n\telse\n\t{\n\t\tError(\"unknown BSP format %c%c%c%c, version %d\\n\",\n\t\t\t\t\t\t\t\t\t\t(idheader.ident & 0xFF),\n\t\t\t\t\t\t\t\t\t\t((idheader.ident >> 8) & 0xFF),\n\t\t\t\t\t\t\t\t\t\t((idheader.ident >> 16) & 0xFF),\n\t\t\t\t\t\t\t\t\t\t((idheader.ident >> 24) & 0xFF), idheader.version);\n\t\treturn false;\n\t} //end if\n\t//\n\treturn true;\n} //end of the function LoadMapFromBSP\n"
  },
  {
    "path": "code/bspc/map_hl.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n#include \"l_bsp_hl.h\"\n#include \"aas_map.h\"\t\t\t//AAS_CreateMapBrushes\n\nint hl_numbrushes;\nint hl_numclipbrushes;\n\n//#define HL_PRINT\n#define HLCONTENTS\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint HL_TextureContents(char *name)\n{\n\tif (!Q_strncasecmp (name, \"sky\",3))\n\t\treturn CONTENTS_SOLID;\n\n\tif (!Q_strncasecmp(name+1,\"!lava\",5))\n\t\treturn CONTENTS_LAVA;\n\n\tif (!Q_strncasecmp(name+1,\"!slime\",6))\n\t\treturn CONTENTS_SLIME;\n\n\t/*\n\tif (!Q_strncasecmp (name, \"!cur_90\",7))\n\t\treturn CONTENTS_CURRENT_90;\n\tif (!Q_strncasecmp (name, \"!cur_0\",6))\n\t\treturn CONTENTS_CURRENT_0;\n\tif (!Q_strncasecmp (name, \"!cur_270\",8))\n\t\treturn CONTENTS_CURRENT_270;\n\tif (!Q_strncasecmp (name, \"!cur_180\",8))\n\t\treturn CONTENTS_CURRENT_180;\n\tif (!Q_strncasecmp (name, \"!cur_up\",7))\n\t\treturn CONTENTS_CURRENT_UP;\n\tif (!Q_strncasecmp (name, \"!cur_dwn\",8))\n\t\treturn CONTENTS_CURRENT_DOWN;\n\t//*/\n\tif (name[0] == '!')\n\t\treturn CONTENTS_WATER;\n\t/*\n\tif (!Q_strncasecmp (name, \"origin\",6))\n\t\treturn CONTENTS_ORIGIN;\n\tif (!Q_strncasecmp (name, \"clip\",4))\n\t\treturn CONTENTS_CLIP;\n\tif( !Q_strncasecmp( name, \"translucent\", 11 ) )\n\t\treturn CONTENTS_TRANSLUCENT;\n\tif( name[0] == '@' )\n\t\treturn CONTENTS_TRANSLUCENT;\n\t//*/\n\n\treturn CONTENTS_SOLID;\n} //end of the function HL_TextureContents\n//===========================================================================\n// Generates two new brushes, leaving the original\n// unchanged\n//\n// modified for Half-Life because there are quite a lot of tiny node leaves\n// in the Half-Life bsps\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid HL_SplitBrush(bspbrush_t *brush, int planenum, int nodenum,\n\t\t\t\t\t\t bspbrush_t **front, bspbrush_t **back)\n{\n\tbspbrush_t *b[2];\n\tint i, j;\n\twinding_t *w, *cw[2], *midwinding;\n\tplane_t *plane, *plane2;\n\tside_t *s, *cs;\n\tfloat d, d_front, d_back;\n\n\t*front = *back = NULL;\n\tplane = &mapplanes[planenum];\n\n\t// check all points\n\td_front = d_back = 0;\n\tfor (i=0 ; i<brush->numsides ; i++)\n\t{\n\t\tw = brush->sides[i].winding;\n\t\tif (!w)\n\t\t\tcontinue;\n\t\tfor (j=0 ; j<w->numpoints ; j++)\n\t\t{\n\t\t\td = DotProduct (w->p[j], plane->normal) - plane->dist;\n\t\t\tif (d > 0 && d > d_front)\n\t\t\t\td_front = d;\n\t\t\tif (d < 0 && d < d_back)\n\t\t\t\td_back = d;\n\t\t} //end for\n\t} //end for\n\n\tif (d_front < 0.1) // PLANESIDE_EPSILON)\n\t{\t// only on back\n\t\t*back = CopyBrush (brush);\n\t\tLog_Print(\"HL_SplitBrush: only on back\\n\");\n\t\treturn;\n\t} //end if\n\tif (d_back > -0.1) // PLANESIDE_EPSILON)\n\t{\t// only on front\n\t\t*front = CopyBrush (brush);\n\t\tLog_Print(\"HL_SplitBrush: only on front\\n\");\n\t\treturn;\n\t} //end if\n\n\t// create a new winding from the split plane\n\n\tw = BaseWindingForPlane (plane->normal, plane->dist);\n\tfor (i = 0; i < brush->numsides && w; i++)\n\t{\n\t\tplane2 = &mapplanes[brush->sides[i].planenum ^ 1];\n\t\tChopWindingInPlace(&w, plane2->normal, plane2->dist, 0); // PLANESIDE_EPSILON);\n\t} //end for\n\n\tif (!w || WindingIsTiny(w))\n\t{\t// the brush isn't really split\n\t\tint\t\tside;\n\n\t\tLog_Print(\"HL_SplitBrush: no split winding\\n\");\n\t\tside = BrushMostlyOnSide (brush, plane);\n\t\tif (side == PSIDE_FRONT)\n\t\t\t*front = CopyBrush (brush);\n\t\tif (side == PSIDE_BACK)\n\t\t\t*back = CopyBrush (brush);\n\t\treturn;\n\t}\n\n\tif (WindingIsHuge(w))\n\t{\n\t\tLog_Print(\"HL_SplitBrush: WARNING huge split winding\\n\");\n\t} //end of\n\n\tmidwinding = w;\n\n\t// split it for real\n\n\tfor (i = 0; i < 2; i++)\n\t{\n\t\tb[i] = AllocBrush (brush->numsides+1);\n\t\tb[i]->original = brush->original;\n\t} //end for\n\n\t// split all the current windings\n\n\tfor (i=0 ; i<brush->numsides ; i++)\n\t{\n\t\ts = &brush->sides[i];\n\t\tw = s->winding;\n\t\tif (!w)\n\t\t\tcontinue;\n\t\tClipWindingEpsilon (w, plane->normal, plane->dist,\n\t\t\t0 /*PLANESIDE_EPSILON*/, &cw[0], &cw[1]);\n\t\tfor (j=0 ; j<2 ; j++)\n\t\t{\n\t\t\tif (!cw[j])\n\t\t\t\tcontinue;\n#if 0\n\t\t\tif (WindingIsTiny (cw[j]))\n\t\t\t{\n\t\t\t\tFreeWinding (cw[j]);\n\t\t\t\tcontinue;\n\t\t\t}\n#endif\n\t\t\tcs = &b[j]->sides[b[j]->numsides];\n\t\t\tb[j]->numsides++;\n\t\t\t*cs = *s;\n//\t\t\tcs->planenum = s->planenum;\n//\t\t\tcs->texinfo = s->texinfo;\n//\t\t\tcs->visible = s->visible;\n//\t\t\tcs->original = s->original;\n\t\t\tcs->winding = cw[j];\n\t\t\tcs->flags &= ~SFL_TESTED;\n\t\t} //end for\n\t} //end for\n\n\n\t// see if we have valid polygons on both sides\n\n\tfor (i=0 ; i<2 ; i++)\n\t{\n\t\tBoundBrush (b[i]);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\tif (b[i]->mins[j] < -4096 || b[i]->maxs[j] > 4096)\n\t\t\t{\n\t\t\t\tLog_Print(\"HL_SplitBrush: bogus brush after clip\\n\");\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t} //end for\n\n\t\tif (b[i]->numsides < 3 || j < 3)\n\t\t{\n\t\t\tFreeBrush (b[i]);\n\t\t\tb[i] = NULL;\n\t\t\tLog_Print(\"HL_SplitBrush: numsides < 3\\n\");\n\t\t} //end if\n\t} //end for\n\n\tif ( !(b[0] && b[1]) )\n\t{\n\t\tif (!b[0] && !b[1])\n\t\t\tLog_Print(\"HL_SplitBrush: split removed brush\\n\");\n\t\telse\n\t\t\tLog_Print(\"HL_SplitBrush: split not on both sides\\n\");\n\t\tif (b[0])\n\t\t{\n\t\t\tFreeBrush (b[0]);\n\t\t\t*front = CopyBrush (brush);\n\t\t} //end if\n\t\tif (b[1])\n\t\t{\n\t\t\tFreeBrush (b[1]);\n\t\t\t*back = CopyBrush (brush);\n\t\t} //end if\n\t\treturn;\n\t} //end if\n\n\t// add the midwinding to both sides\n\tfor (i = 0; i < 2; i++)\n\t{\n\t\tcs = &b[i]->sides[b[i]->numsides];\n\t\tb[i]->numsides++;\n\n\t\tcs->planenum = planenum^i^1;\n\t\tcs->texinfo = 0;\n\t\t//store the node number in the surf to find the texinfo later on\n\t\tcs->surf = nodenum;\n\t\t//\n\t\tcs->flags &= ~SFL_VISIBLE;\n\t\tcs->flags &= ~SFL_TESTED;\n\t\tif (i==0)\n\t\t\tcs->winding = CopyWinding (midwinding);\n\t\telse\n\t\t\tcs->winding = midwinding;\n\t} //end for\n\n\n{\n\tvec_t v1;\n\tint i;\n\n\tfor (i=0 ; i<2 ; i++)\n\t{\n\t\tv1 = BrushVolume (b[i]);\n\t\tif (v1 < 1)\n\t\t{\n\t\t\tFreeBrush (b[i]);\n\t\t\tb[i] = NULL;\n\t\t\tLog_Print(\"HL_SplitBrush: tiny volume after clip\\n\");\n\t\t} //end if\n\t} //end for\n} //*/\n\n\t*front = b[0];\n\t*back = b[1];\n} //end of the function HL_SplitBrush\n//===========================================================================\n// returns true if the tree starting at nodenum has only solid leaves\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint HL_SolidTree_r(int nodenum)\n{\n\tif (nodenum < 0)\n\t{\n\t\tswitch(hl_dleafs[(-nodenum) - 1].contents)\n\t\t{\n\t\t\tcase HL_CONTENTS_EMPTY:\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t} //end case\n\t\t\tcase HL_CONTENTS_SOLID:\n#ifdef HLCONTENTS\n\t\t\tcase HL_CONTENTS_CLIP:\n#endif //HLCONTENTS\n\t\t\tcase HL_CONTENTS_SKY:\n#ifdef HLCONTENTS\n\t\t\tcase HL_CONTENTS_TRANSLUCENT:\n#endif //HLCONTENTS\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t} //end case\n\t\t\tcase HL_CONTENTS_WATER:\n\t\t\tcase HL_CONTENTS_SLIME:\n\t\t\tcase HL_CONTENTS_LAVA:\n#ifdef HLCONTENTS\n\t\t\t//these contents should not be found in the BSP\n\t\t\tcase HL_CONTENTS_ORIGIN:\n\t\t\tcase HL_CONTENTS_CURRENT_0:\n\t\t\tcase HL_CONTENTS_CURRENT_90:\n\t\t\tcase HL_CONTENTS_CURRENT_180:\n\t\t\tcase HL_CONTENTS_CURRENT_270:\n\t\t\tcase HL_CONTENTS_CURRENT_UP:\n\t\t\tcase HL_CONTENTS_CURRENT_DOWN:\n#endif //HLCONTENTS\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t} //end default\n\t\t} //end switch\n\t\treturn false;\n\t} //end if\n\tif (!HL_SolidTree_r(hl_dnodes[nodenum].children[0])) return false;\n\tif (!HL_SolidTree_r(hl_dnodes[nodenum].children[1])) return false;\n\treturn true;\n} //end of the function HL_SolidTree_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *HL_CreateBrushes_r(bspbrush_t *brush, int nodenum)\n{\n\tint planenum;\n\tbspbrush_t *front, *back;\n\thl_dleaf_t *leaf;\n\n\t//if it is a leaf\n\tif (nodenum < 0)\n\t{\n\t\tleaf = &hl_dleafs[(-nodenum) - 1];\n\t\tif (leaf->contents != HL_CONTENTS_EMPTY)\n\t\t{\n#ifdef HL_PRINT\n\t\t\tqprintf(\"\\r%5i\", ++hl_numbrushes);\n#endif //HL_PRINT\n\t\t} //end if\n\t\tswitch(leaf->contents)\n\t\t{\n\t\t\tcase HL_CONTENTS_EMPTY:\n\t\t\t{\n\t\t\t\tFreeBrush(brush);\n\t\t\t\treturn NULL;\n\t\t\t} //end case\n\t\t\tcase HL_CONTENTS_SOLID:\n#ifdef HLCONTENTS\n\t\t\tcase HL_CONTENTS_CLIP:\n#endif //HLCONTENTS\n\t\t\tcase HL_CONTENTS_SKY:\n#ifdef HLCONTENTS\n\t\t\tcase HL_CONTENTS_TRANSLUCENT:\n#endif //HLCONTENTS\n\t\t\t{\n\t\t\t\tbrush->side = CONTENTS_SOLID;\n\t\t\t\treturn brush;\n\t\t\t} //end case\n\t\t\tcase HL_CONTENTS_WATER:\n\t\t\t{\n\t\t\t\tbrush->side = CONTENTS_WATER;\n\t\t\t\treturn brush;\n\t\t\t} //end case\n\t\t\tcase HL_CONTENTS_SLIME:\n\t\t\t{\n\t\t\t\tbrush->side = CONTENTS_SLIME;\n\t\t\t\treturn brush;\n\t\t\t} //end case\n\t\t\tcase HL_CONTENTS_LAVA:\n\t\t\t{\n\t\t\t\tbrush->side = CONTENTS_LAVA;\n\t\t\t\treturn brush;\n\t\t\t} //end case\n#ifdef HLCONTENTS\n\t\t\t//these contents should not be found in the BSP\n\t\t\tcase HL_CONTENTS_ORIGIN:\n\t\t\tcase HL_CONTENTS_CURRENT_0:\n\t\t\tcase HL_CONTENTS_CURRENT_90:\n\t\t\tcase HL_CONTENTS_CURRENT_180:\n\t\t\tcase HL_CONTENTS_CURRENT_270:\n\t\t\tcase HL_CONTENTS_CURRENT_UP:\n\t\t\tcase HL_CONTENTS_CURRENT_DOWN:\n\t\t\t{\n\t\t\t\tError(\"HL_CreateBrushes_r: found contents %d in Half-Life BSP\", leaf->contents);\n\t\t\t\treturn NULL;\n\t\t\t} //end case\n#endif //HLCONTENTS\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\tError(\"HL_CreateBrushes_r: unknown contents %d in Half-Life BSP\", leaf->contents);\n\t\t\t\treturn NULL;\n\t\t\t} //end default\n\t\t} //end switch\n\t\treturn NULL;\n\t} //end if\n\t//if the rest of the tree is solid\n\t/*if (HL_SolidTree_r(nodenum))\n\t{\n\t\tbrush->side = CONTENTS_SOLID;\n\t\treturn brush;\n\t} //end if*/\n\t//\n\tplanenum = hl_dnodes[nodenum].planenum;\n\tplanenum = FindFloatPlane(hl_dplanes[planenum].normal, hl_dplanes[planenum].dist);\n\t//split the brush with the node plane\n\tHL_SplitBrush(brush, planenum, nodenum, &front, &back);\n\t//free the original brush\n\tFreeBrush(brush);\n\t//every node must split the brush in two\n\tif (!front || !back)\n\t{\n\t\tLog_Print(\"HL_CreateBrushes_r: WARNING node not splitting brush\\n\");\n\t\t//return NULL;\n\t} //end if\n\t//create brushes recursively\n\tif (front) front = HL_CreateBrushes_r(front, hl_dnodes[nodenum].children[0]);\n\tif (back) back = HL_CreateBrushes_r(back, hl_dnodes[nodenum].children[1]);\n\t//link the brushes if possible and return them\n\tif (front)\n\t{\n\t\tfor (brush = front; brush->next; brush = brush->next);\n\t\tbrush->next = back;\n\t\treturn front;\n\t} //end if\n\telse\n\t{\n\t\treturn back;\n\t} //end else\n} //end of the function HL_CreateBrushes_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *HL_CreateBrushesFromBSP(int modelnum)\n{\n\tbspbrush_t *brushlist;\n\tbspbrush_t *brush;\n\thl_dnode_t *headnode;\n\tvec3_t mins, maxs;\n\tint i;\n\n\t//\n\theadnode = &hl_dnodes[hl_dmodels[modelnum].headnode[0]];\n\t//get the mins and maxs of the world\n\tVectorCopy(headnode->mins, mins);\n\tVectorCopy(headnode->maxs, maxs);\n\t//enlarge these mins and maxs\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tmins[i] -= 8;\n\t\tmaxs[i] += 8;\n\t} //end for\n\t//NOTE: have to add the BSP tree mins and maxs to the MAP mins and maxs\n\tAddPointToBounds(mins, map_mins, map_maxs);\n\tAddPointToBounds(maxs, map_mins, map_maxs);\n\t//\n\tif (!modelnum)\n\t{\n\t\tLog_Print(\"brush size: %5.0f,%5.0f,%5.0f to %5.0f,%5.0f,%5.0f\\n\",\n\t\t\t\t\t\t\tmap_mins[0], map_mins[1], map_mins[2],\n\t\t\t\t\t\t\tmap_maxs[0], map_maxs[1], map_maxs[2]);\n\t} //end if\n\t//create one huge brush containing the whole world\n\tbrush = BrushFromBounds(mins, maxs);\n\tVectorCopy(mins, brush->mins);\n\tVectorCopy(maxs, brush->maxs);\n\t//\n#ifdef HL_PRINT\n\tqprintf(\"creating Half-Life brushes\\n\");\n\tqprintf(\"%5d brushes\", hl_numbrushes = 0);\n#endif //HL_PRINT\n\t//create the brushes\n\tbrushlist = HL_CreateBrushes_r(brush, hl_dmodels[modelnum].headnode[0]);\n\t//\n#ifdef HL_PRINT\n\tqprintf(\"\\n\");\n#endif //HL_PRINT\n\t//now we've got a list with brushes!\n\treturn brushlist;\n} //end of the function HL_CreateBrushesFromBSP\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *HL_MergeBrushes(bspbrush_t *brushlist, int modelnum)\n{\n\tint nummerges, merged;\n\tbspbrush_t *b1, *b2, *tail, *newbrush, *newbrushlist;\n\tbspbrush_t *lastb2;\n\n\tif (!brushlist) return NULL;\n\n\tif (!modelnum) qprintf(\"%5d brushes merged\", nummerges = 0);\n\tdo\n\t{\n\t\tfor (tail = brushlist; tail; tail = tail->next)\n\t\t{\n\t\t\tif (!tail->next) break;\n\t\t} //end for\n\t\tmerged = 0;\n\t\tnewbrushlist = NULL;\n\t\tfor (b1 = brushlist; b1; b1 = brushlist)\n\t\t{\n\t\t\tlastb2 = b1;\n\t\t\tfor (b2 = b1->next; b2; b2 = b2->next)\n\t\t\t{\n\t\t\t\t//can't merge brushes with different contents\n\t\t\t\tif (b1->side != b2->side) newbrush = NULL;\n\t\t\t\telse newbrush = TryMergeBrushes(b1, b2);\n\t\t\t\t//if a merged brush is created\n\t\t\t\tif (newbrush)\n\t\t\t\t{\n\t\t\t\t\t//copy the brush contents\n\t\t\t\t\tnewbrush->side = b1->side;\n\t\t\t\t\t//add the new brush to the end of the list\n\t\t\t\t\ttail->next = newbrush;\n\t\t\t\t\t//remove the second brush from the list\n\t\t\t\t\tlastb2->next = b2->next;\n\t\t\t\t\t//remove the first brush from the list\n\t\t\t\t\tbrushlist = brushlist->next;\n\t\t\t\t\t//free the merged brushes\n\t\t\t\t\tFreeBrush(b1);\n\t\t\t\t\tFreeBrush(b2);\n\t\t\t\t\t//get a new tail brush\n\t\t\t\t\tfor (tail = brushlist; tail; tail = tail->next)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!tail->next) break;\n\t\t\t\t\t} //end for\n\t\t\t\t\tmerged++;\n\t\t\t\t\tif (!modelnum) qprintf(\"\\r%5d\", nummerges++);\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t\tlastb2 = b2;\n\t\t\t} //end for\n\t\t\t//if b1 can't be merged with any of the other brushes\n\t\t\tif (!b2)\n\t\t\t{\n\t\t\t\tbrushlist = brushlist->next;\n\t\t\t\t//keep b1\n\t\t\t\tb1->next = newbrushlist;\n\t\t\t\tnewbrushlist = b1;\n\t\t\t} //end else\n\t\t} //end for\n\t\tbrushlist = newbrushlist;\n\t} while(merged);\n\tif (!modelnum) qprintf(\"\\n\");\n\treturn newbrushlist;\n} //end of the function HL_MergeBrushes\n//===========================================================================\n// returns the amount the face and the winding have overlap\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat HL_FaceOnWinding(hl_dface_t *face, winding_t *winding)\n{\n\tint i, edgenum, side;\n\tfloat dist, area;\n\thl_dplane_t plane;\n\tvec_t *v1, *v2;\n\tvec3_t normal, edgevec;\n\twinding_t *w;\n\n\t//\n\tw = CopyWinding(winding);\n\tmemcpy(&plane, &hl_dplanes[face->planenum], sizeof(hl_dplane_t));\n\t//check on which side of the plane the face is\n\tif (face->side)\n\t{\n\t\tVectorNegate(plane.normal, plane.normal);\n\t\tplane.dist = -plane.dist;\n\t} //end if\n\tfor (i = 0; i < face->numedges && w; i++)\n\t{\n\t\t//get the first and second vertex of the edge\n\t\tedgenum = hl_dsurfedges[face->firstedge + i];\n\t\tside = edgenum > 0;\n\t\t//if the face plane is flipped\n\t\tv1 = hl_dvertexes[hl_dedges[abs(edgenum)].v[side]].point;\n\t\tv2 = hl_dvertexes[hl_dedges[abs(edgenum)].v[!side]].point;\n\t\t//create a plane through the edge vector, orthogonal to the face plane\n\t\t//and with the normal vector pointing out of the face\n\t\tVectorSubtract(v1, v2, edgevec);\n\t\tCrossProduct(edgevec, plane.normal, normal);\n\t\tVectorNormalize(normal);\n\t\tdist = DotProduct(normal, v1);\n\t\t//\n\t\tChopWindingInPlace(&w, normal, dist, 0.9); //CLIP_EPSILON\n\t} //end for\n\tif (w)\n\t{\n\t\tarea = WindingArea(w);\n\t\tFreeWinding(w);\n\t\treturn area;\n\t} //end if\n\treturn 0;\n} //end of the function HL_FaceOnWinding\n//===========================================================================\n// returns a list with brushes created by splitting the given brush with\n// planes that go through the face edges and are orthogonal to the face plane\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *HL_SplitBrushWithFace(bspbrush_t *brush, hl_dface_t *face)\n{\n\tint i, edgenum, side, planenum, splits;\n\tfloat dist;\n\thl_dplane_t plane;\n\tvec_t *v1, *v2;\n\tvec3_t normal, edgevec;\n\tbspbrush_t *front, *back, *brushlist;\n\n\tmemcpy(&plane, &hl_dplanes[face->planenum], sizeof(hl_dplane_t));\n\t//check on which side of the plane the face is\n\tif (face->side)\n\t{\n\t\tVectorNegate(plane.normal, plane.normal);\n\t\tplane.dist = -plane.dist;\n\t} //end if\n\tsplits = 0;\n\tbrushlist = NULL;\n\tfor (i = 0; i < face->numedges; i++)\n\t{\n\t\t//get the first and second vertex of the edge\n\t\tedgenum = hl_dsurfedges[face->firstedge + i];\n\t\tside = edgenum > 0;\n\t\t//if the face plane is flipped\n\t\tv1 = hl_dvertexes[hl_dedges[abs(edgenum)].v[side]].point;\n\t\tv2 = hl_dvertexes[hl_dedges[abs(edgenum)].v[!side]].point;\n\t\t//create a plane through the edge vector, orthogonal to the face plane\n\t\t//and with the normal vector pointing out of the face\n\t\tVectorSubtract(v1, v2, edgevec);\n\t\tCrossProduct(edgevec, plane.normal, normal);\n\t\tVectorNormalize(normal);\n\t\tdist = DotProduct(normal, v1);\n\t\t//\n\t\tplanenum = FindFloatPlane(normal, dist);\n\t\t//split the current brush\n\t\tSplitBrush(brush, planenum, &front, &back);\n\t\t//if there is a back brush just put it in the list\n\t\tif (back)\n\t\t{\n\t\t\t//copy the brush contents\n\t\t\tback->side = brush->side;\n\t\t\t//\n\t\t\tback->next = brushlist;\n\t\t\tbrushlist = back;\n\t\t\tsplits++;\n\t\t} //end if\n\t\tif (!front)\n\t\t{\n\t\t\tLog_Print(\"HL_SplitBrushWithFace: no new brush\\n\");\n\t\t\tFreeBrushList(brushlist);\n\t\t\treturn NULL;\n\t\t} //end if\n\t\t//copy the brush contents\n\t\tfront->side = brush->side;\n\t\t//continue splitting the front brush\n\t\tbrush = front;\n\t} //end for\n\tif (!splits)\n\t{\n\t\tFreeBrush(front);\n\t\treturn NULL;\n\t} //end if\n\tfront->next = brushlist;\n\tbrushlist = front;\n\treturn brushlist;\n} //end of the function HL_SplitBrushWithFace\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *HL_TextureBrushes(bspbrush_t *brushlist, int modelnum)\n{\n\tfloat area, largestarea;\n\tint i, n, texinfonum, sn, numbrushes, ofs;\n\tint bestfacenum, sidenodenum;\n\tside_t *side;\n\thl_dmiptexlump_t *miptexlump;\n\thl_miptex_t *miptex;\n\tbspbrush_t *brush, *nextbrush, *prevbrush, *newbrushes, *brushlistend;\n\tvec_t defaultvec[4] = {1, 0, 0, 0};\n\n\tif (!modelnum) qprintf(\"texturing brushes\\n\");\n\tif (!modelnum) qprintf(\"%5d brushes\", numbrushes = 0);\n\t//get a pointer to the last brush in the list\n\tfor (brushlistend = brushlist; brushlistend; brushlistend = brushlistend->next)\n\t{\n\t\tif (!brushlistend->next) break;\n\t} //end for\n\t//there's no previous brush when at the start of the list\n\tprevbrush = NULL;\n\t//go over the brush list\n\tfor (brush = brushlist; brush; brush = nextbrush)\n\t{\n\t\tnextbrush = brush->next;\n\t\t//find a texinfo for every brush side\n\t\tfor (sn = 0; sn < brush->numsides; sn++)\n\t\t{\n\t\t\tside = &brush->sides[sn];\n\t\t\t//\n\t\t\tif (side->flags & SFL_TEXTURED) continue;\n\t\t\t//number of the node that created this brush side\n\t\t\tsidenodenum = side->surf;\t//see midwinding in HL_SplitBrush\n\t\t\t//no face found yet\n\t\t\tbestfacenum = -1;\n\t\t\t//minimum face size\n\t\t\tlargestarea = 1;\n\t\t\t//if optimizing the texture placement and not going for the\n\t\t\t//least number of brushes\n\t\t\tif (!lessbrushes)\n\t\t\t{\n\t\t\t\tfor (i = 0; i < hl_numfaces; i++)\n\t\t\t\t{\n\t\t\t\t\t//the face must be in the same plane as the node plane that created\n\t\t\t\t\t//this brush side\n\t\t\t\t\tif (hl_dfaces[i].planenum == hl_dnodes[sidenodenum].planenum)\n\t\t\t\t\t{\n\t\t\t\t\t\t//get the area the face and the brush side overlap\n\t\t\t\t\t\tarea = HL_FaceOnWinding(&hl_dfaces[i], side->winding);\n\t\t\t\t\t\t//if this face overlaps the brush side winding more than previous faces\n\t\t\t\t\t\tif (area > largestarea)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t//if there already was a face for texturing this brush side with\n\t\t\t\t\t\t\t//a different texture\n\t\t\t\t\t\t\tif (bestfacenum >= 0 &&\n\t\t\t\t\t\t\t\t\t(hl_dfaces[bestfacenum].texinfo != hl_dfaces[i].texinfo))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t//split the brush to fit the texture\n\t\t\t\t\t\t\t\tnewbrushes = HL_SplitBrushWithFace(brush, &hl_dfaces[i]);\n\t\t\t\t\t\t\t\t//if new brushes where created\n\t\t\t\t\t\t\t\tif (newbrushes)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t//remove the current brush from the list\n\t\t\t\t\t\t\t\t\tif (prevbrush) prevbrush->next = brush->next;\n\t\t\t\t\t\t\t\t\telse brushlist = brush->next;\n\t\t\t\t\t\t\t\t\tif (brushlistend == brush)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tbrushlistend = prevbrush;\n\t\t\t\t\t\t\t\t\t\tnextbrush = newbrushes;\n\t\t\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\t\t\t//add the new brushes to the end of the list\n\t\t\t\t\t\t\t\t\tif (brushlistend) brushlistend->next = newbrushes;\n\t\t\t\t\t\t\t\t\telse brushlist = newbrushes;\n\t\t\t\t\t\t\t\t\t//free the current brush\n\t\t\t\t\t\t\t\t\tFreeBrush(brush);\n\t\t\t\t\t\t\t\t\t//don't forget about the prevbrush pointer at the bottom of\n\t\t\t\t\t\t\t\t\t//the outer loop\n\t\t\t\t\t\t\t\t\tbrush = prevbrush;\n\t\t\t\t\t\t\t\t\t//find the end of the list\n\t\t\t\t\t\t\t\t\tfor (brushlistend = brushlist; brushlistend; brushlistend = brushlistend->next)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tif (!brushlistend->next) break;\n\t\t\t\t\t\t\t\t\t} //end for\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tLog_Write(\"brush %d: no real texture split\", numbrushes);\n\t\t\t\t\t\t\t\t} //end else\n\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t//best face for texturing this brush side\n\t\t\t\t\t\t\t\tbestfacenum = i;\n\t\t\t\t\t\t\t} //end else\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end if\n\t\t\t\t} //end for\n\t\t\t\t//if the brush was split the original brush is removed\n\t\t\t\t//and we just continue with the next one in the list\n\t\t\t\tif (i < hl_numfaces) break;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\t//find the face with the largest overlap with this brush side\n\t\t\t\t//for texturing the brush side\n\t\t\t\tfor (i = 0; i < hl_numfaces; i++)\n\t\t\t\t{\n\t\t\t\t\t//the face must be in the same plane as the node plane that created\n\t\t\t\t\t//this brush side\n\t\t\t\t\tif (hl_dfaces[i].planenum == hl_dnodes[sidenodenum].planenum)\n\t\t\t\t\t{\n\t\t\t\t\t\t//get the area the face and the brush side overlap\n\t\t\t\t\t\tarea = HL_FaceOnWinding(&hl_dfaces[i], side->winding);\n\t\t\t\t\t\t//if this face overlaps the brush side winding more than previous faces\n\t\t\t\t\t\tif (area > largestarea)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlargestarea = area;\n\t\t\t\t\t\t\tbestfacenum = i;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end if\n\t\t\t\t} //end for\n\t\t\t} //end else\n\t\t\t//if a face was found for texturing this brush side\n\t\t\tif (bestfacenum >= 0)\n\t\t\t{\n\t\t\t\t//set the MAP texinfo values\n\t\t\t\ttexinfonum = hl_dfaces[bestfacenum].texinfo;\n\t\t\t\tfor (n = 0; n < 4; n++)\n\t\t\t\t{\n\t\t\t\t\tmap_texinfo[texinfonum].vecs[0][n] = hl_texinfo[texinfonum].vecs[0][n];\n\t\t\t\t\tmap_texinfo[texinfonum].vecs[1][n] = hl_texinfo[texinfonum].vecs[1][n];\n\t\t\t\t} //end for\n\t\t\t\t//make sure the two vectors aren't of zero length otherwise use the default\n\t\t\t\t//vector to prevent a divide by zero in the map writing\n\t\t\t\tif (VectorLength(map_texinfo[texinfonum].vecs[0]) < 0.01)\n\t\t\t\t\tmemcpy(map_texinfo[texinfonum].vecs[0], defaultvec, sizeof(defaultvec));\n\t\t\t\tif (VectorLength(map_texinfo[texinfonum].vecs[1]) < 0.01)\n\t\t\t\t\tmemcpy(map_texinfo[texinfonum].vecs[1], defaultvec, sizeof(defaultvec));\n\t\t\t\t//\n\t\t\t\tmap_texinfo[texinfonum].flags = hl_texinfo[texinfonum].flags;\n\t\t\t\tmap_texinfo[texinfonum].value = 0; //HL_ and HL texinfos don't have a value\n\t\t\t\t//the mip texture\n\t\t\t\tmiptexlump = (hl_dmiptexlump_t *) hl_dtexdata;\n\t\t\t\tofs = miptexlump->dataofs[hl_texinfo[texinfonum].miptex];\n\t\t\t\tif ( ofs > hl_texdatasize ) {\n\t\t\t\t\tofs = miptexlump->dataofs[0];\n\t\t\t\t}\n\t\t\t\tmiptex = (hl_miptex_t *)((byte *)miptexlump + ofs );\n\t\t\t\t//get the mip texture name\n\t\t\t\tstrcpy(map_texinfo[texinfonum].texture, miptex->name);\n\t\t\t\t//no animations in Quake1 and Half-Life mip textures\n\t\t\t\tmap_texinfo[texinfonum].nexttexinfo = -1;\n\t\t\t\t//store the texinfo number\n\t\t\t\tside->texinfo = texinfonum;\n\t\t\t\t//\n\t\t\t\tif (texinfonum > map_numtexinfo) map_numtexinfo = texinfonum;\n\t\t\t\t//this side is textured\n\t\t\t\tside->flags |= SFL_TEXTURED;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\t//no texture for this side\n\t\t\t\tside->texinfo = TEXINFO_NODE;\n\t\t\t\t//this side is textured\n\t\t\t\tside->flags |= SFL_TEXTURED;\n\t\t\t} //end if\n\t\t} //end for\n\t\t//\n\t\tif (!modelnum && prevbrush != brush) qprintf(\"\\r%5d\", ++numbrushes);\n\t\t//previous brush in the list\n\t\tprevbrush = brush;\n\t} //end for\n\tif (!modelnum) qprintf(\"\\n\");\n\t//return the new list with brushes\n\treturn brushlist;\n} //end of the function HL_TextureBrushes\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid HL_FixContentsTextures(bspbrush_t *brushlist)\n{\n\tint i, texinfonum;\n\tbspbrush_t *brush;\n\n\tfor (brush = brushlist; brush; brush = brush->next)\n\t{\n\t\t//only fix the textures of water, slime and lava brushes\n\t\tif (brush->side != CONTENTS_WATER &&\n\t\t\tbrush->side != CONTENTS_SLIME &&\n\t\t\tbrush->side != CONTENTS_LAVA) continue;\n\t\t//\n\t\tfor (i = 0; i < brush->numsides; i++)\n\t\t{\n\t\t\ttexinfonum = brush->sides[i].texinfo;\n\t\t\tif (HL_TextureContents(map_texinfo[texinfonum].texture) == brush->side) break;\n\t\t} //end for\n\t\t//if no specific contents texture was found\n\t\tif (i >= brush->numsides)\n\t\t{\n\t\t\ttexinfonum = -1;\n\t\t\tfor (i = 0; i < map_numtexinfo; i++)\n\t\t\t{\n\t\t\t\tif (HL_TextureContents(map_texinfo[i].texture) == brush->side)\n\t\t\t\t{\n\t\t\t\t\ttexinfonum = i;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t} //end for\n\t\t} //end if\n\t\t//\n\t\tif (texinfonum >= 0)\n\t\t{\n\t\t\t//give all the brush sides this contents texture\n\t\t\tfor (i = 0; i < brush->numsides; i++)\n\t\t\t{\n\t\t\t\tbrush->sides[i].texinfo = texinfonum;\n\t\t\t} //end for\n\t\t} //end if\n\t\telse Log_Print(\"brush contents %d with wrong textures\\n\", brush->side);\n\t\t//\n\t} //end for\n\t/*\n\tfor (brush = brushlist; brush; brush = brush->next)\n\t{\n\t\t//give all the brush sides this contents texture\n\t\tfor (i = 0; i < brush->numsides; i++)\n\t\t{\n\t\t\tif (HL_TextureContents(map_texinfo[texinfonum].texture) != brush->side)\n\t\t\t{\n\t\t\t\tError(\"brush contents %d with wrong contents textures %s\\n\", brush->side,\n\t\t\t\t\t\t\tHL_TextureContents(map_texinfo[texinfonum].texture));\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for*/\n} //end of the function HL_FixContentsTextures\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid HL_BSPBrushToMapBrush(bspbrush_t *bspbrush, entity_t *mapent)\n{\n\tmapbrush_t *mapbrush;\n\tside_t *side;\n\tint i, besttexinfo;\n\n\tif (nummapbrushes >= MAX_MAPFILE_BRUSHES)\n\tError (\"nummapbrushes == MAX_MAPFILE_BRUSHES\");\n\n\tmapbrush = &mapbrushes[nummapbrushes];\n\tmapbrush->original_sides = &brushsides[nummapbrushsides];\n\tmapbrush->entitynum = mapent - entities;\n\tmapbrush->brushnum = nummapbrushes - mapent->firstbrush;\n\tmapbrush->leafnum = -1;\n\tmapbrush->numsides = 0;\n\n\tbesttexinfo = TEXINFO_NODE;\n\tfor (i = 0; i < bspbrush->numsides; i++)\n\t{\n\t\tif (!bspbrush->sides[i].winding) continue;\n\t\t//\n\t\tif (nummapbrushsides >= MAX_MAPFILE_BRUSHSIDES)\n\t\t\tError (\"MAX_MAPFILE_BRUSHSIDES\");\n\t\tside = &brushsides[nummapbrushsides];\n\t\t//the contents of the bsp brush is stored in the side variable\n\t\tside->contents = bspbrush->side;\n\t\tside->surf = 0;\n\t\tside->planenum = bspbrush->sides[i].planenum;\n\t\tside->texinfo = bspbrush->sides[i].texinfo;\n\t\tif (side->texinfo != TEXINFO_NODE)\n\t\t{\n\t\t\t//this brush side is textured\n\t\t\tside->flags |= SFL_TEXTURED;\n\t\t\tbesttexinfo = side->texinfo;\n\t\t} //end if\n\t\t//\n\t\tnummapbrushsides++;\n\t\tmapbrush->numsides++;\n\t} //end for\n\t//\n\tif (besttexinfo == TEXINFO_NODE)\n\t{\n\t\tmapbrush->numsides = 0;\n\t\thl_numclipbrushes++;\n\t\treturn;\n\t} //end if\n\t//set the texinfo for all the brush sides without texture\n\tfor (i = 0; i < mapbrush->numsides; i++)\n\t{\n\t\tif (mapbrush->original_sides[i].texinfo == TEXINFO_NODE)\n\t\t{\n\t\t\tmapbrush->original_sides[i].texinfo = besttexinfo;\n\t\t} //end if\n\t} //end for\n\t//contents of the brush\n\tmapbrush->contents = bspbrush->side;\n\t//\n\tif (create_aas)\n\t{\n\t\t//create the AAS brushes from this brush, add brush bevels\n\t\tAAS_CreateMapBrushes(mapbrush, mapent, true);\n\t\treturn;\n\t} //end if\n\t//create windings for sides and bounds for brush\n\tMakeBrushWindings(mapbrush);\n\t//add brush bevels\n\tAddBrushBevels(mapbrush);\n\t//a new brush has been created\n\tnummapbrushes++;\n\tmapent->numbrushes++;\n} //end of the function HL_BSPBrushToMapBrush\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid HL_CreateMapBrushes(entity_t *mapent, int modelnum)\n{\n\tbspbrush_t *brushlist, *brush, *nextbrush;\n\tint i;\n\n\t//create brushes from the model BSP tree\n\tbrushlist = HL_CreateBrushesFromBSP(modelnum);\n\t//texture the brushes and split them when necesary\n\tbrushlist = HL_TextureBrushes(brushlist, modelnum);\n\t//fix the contents textures of all brushes\n\tHL_FixContentsTextures(brushlist);\n\t//\n\tif (!nobrushmerge)\n\t{\n\t\tbrushlist = HL_MergeBrushes(brushlist, modelnum);\n\t\t//brushlist = HL_MergeBrushes(brushlist, modelnum);\n\t} //end if\n\t//\n\tif (!modelnum) qprintf(\"converting brushes to map brushes\\n\");\n\tif (!modelnum) qprintf(\"%5d brushes\", i = 0);\n\tfor (brush = brushlist; brush; brush = nextbrush)\n\t{\n\t\tnextbrush = brush->next;\n\t\tHL_BSPBrushToMapBrush(brush, mapent);\n\t\tbrush->next = NULL;\n\t\tFreeBrush(brush);\n\t\tif (!modelnum) qprintf(\"\\r%5d\", ++i);\n\t} //end for\n\tif (!modelnum) qprintf(\"\\n\");\n} //end of the function HL_CreateMapBrushes\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid HL_ResetMapLoading(void)\n{\n} //end of the function HL_ResetMapLoading\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid HL_LoadMapFromBSP(char *filename, int offset, int length)\n{\n\tint i, modelnum;\n\tchar *model, *classname;\n\n\tLog_Print(\"-- HL_LoadMapFromBSP --\\n\");\n\t//loaded map type\n\tloadedmaptype = MAPTYPE_HALFLIFE;\n\t//\n\tqprintf(\"loading map from %s at %d\\n\", filename, offset);\n\t//load the Half-Life BSP file\n\tHL_LoadBSPFile(filename, offset, length);\n\t//\n\thl_numclipbrushes = 0;\n\t//parse the entities from the BSP\n\tHL_ParseEntities();\n\t//clear the map mins and maxs\n\tClearBounds(map_mins, map_maxs);\n\t//\n\tqprintf(\"creating Half-Life brushes\\n\");\n\tif (lessbrushes) qprintf(\"creating minimum number of brushes\\n\");\n\telse qprintf(\"placing textures correctly\\n\");\n\t//\n\tfor (i = 0; i < num_entities; i++)\n\t{\n\t\tentities[i].firstbrush = nummapbrushes;\n\t\tentities[i].numbrushes = 0;\n\t\t//\n\t\tclassname = ValueForKey(&entities[i], \"classname\");\n\t\tif (classname && !strcmp(classname, \"worldspawn\"))\n\t\t{\n\t\t\tmodelnum = 0;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\t//\n\t\t\tmodel = ValueForKey(&entities[i], \"model\");\n\t\t\tif (!model || *model != '*') continue;\n\t\t\tmodel++;\n\t\t\tmodelnum = atoi(model);\n\t\t} //end else\n\t\t//create map brushes for the entity\n\t\tHL_CreateMapBrushes(&entities[i], modelnum);\n\t} //end for\n\t//\n\tqprintf(\"%5d map brushes\\n\", nummapbrushes);\n\tqprintf(\"%5d clip brushes\\n\", hl_numclipbrushes);\n} //end of the function HL_LoadMapFromBSP\n"
  },
  {
    "path": "code/bspc/map_q1.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n#include \"l_bsp_q1.h\"\n#include \"aas_map.h\"\t\t\t//AAS_CreateMapBrushes\n\nint q1_numbrushes;\nint q1_numclipbrushes;\n\n//#define Q1_PRINT\n\n//===========================================================================\n// water, slime and lava brush textures names always start with a *\n// followed by the type: \"slime\", \"lava\" or otherwise water\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint Q1_TextureContents(char *name)\n{\n\tif (!Q_strcasecmp(name, \"clip\")) return CONTENTS_SOLID;\n\tif (name[0] == '*')\n\t{\n\t\tif (!Q_strncasecmp(name+1,\"lava\",4)) return CONTENTS_LAVA;\n\t\telse if (!Q_strncasecmp(name+1,\"slime\",5)) return CONTENTS_SLIME;\n\t\telse return CONTENTS_WATER;\n\t} //end if\n\telse if (!Q_strncasecmp(name, \"sky\", 3)) return CONTENTS_SOLID;\n\telse return CONTENTS_SOLID;\n} //end of the function Q1_TextureContents\n//===========================================================================\n// Generates two new brushes, leaving the original\n// unchanged\n//\n// modified for Half-Life because there are quite a lot of tiny node leaves\n// in the Half-Life bsps\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Q1_SplitBrush(bspbrush_t *brush, int planenum, int nodenum,\n\t\t\t\t\t\t bspbrush_t **front, bspbrush_t **back)\n{\n\tbspbrush_t *b[2];\n\tint i, j;\n\twinding_t *w, *cw[2], *midwinding;\n\tplane_t *plane, *plane2;\n\tside_t *s, *cs;\n\tfloat d, d_front, d_back;\n\n\t*front = *back = NULL;\n\tplane = &mapplanes[planenum];\n\n\t// check all points\n\td_front = d_back = 0;\n\tfor (i=0 ; i<brush->numsides ; i++)\n\t{\n\t\tw = brush->sides[i].winding;\n\t\tif (!w)\n\t\t\tcontinue;\n\t\tfor (j=0 ; j<w->numpoints ; j++)\n\t\t{\n\t\t\td = DotProduct (w->p[j], plane->normal) - plane->dist;\n\t\t\tif (d > 0 && d > d_front)\n\t\t\t\td_front = d;\n\t\t\tif (d < 0 && d < d_back)\n\t\t\t\td_back = d;\n\t\t} //end for\n\t} //end for\n\n\tif (d_front < 0.1) // PLANESIDE_EPSILON)\n\t{\t// only on back\n\t\t*back = CopyBrush (brush);\n\t\tLog_Print(\"Q1_SplitBrush: only on back\\n\");\n\t\treturn;\n\t} //end if\n\tif (d_back > -0.1) // PLANESIDE_EPSILON)\n\t{\t// only on front\n\t\t*front = CopyBrush (brush);\n\t\tLog_Print(\"Q1_SplitBrush: only on front\\n\");\n\t\treturn;\n\t} //end if\n\n\t// create a new winding from the split plane\n\n\tw = BaseWindingForPlane (plane->normal, plane->dist);\n\tfor (i = 0; i < brush->numsides && w; i++)\n\t{\n\t\tplane2 = &mapplanes[brush->sides[i].planenum ^ 1];\n\t\tChopWindingInPlace(&w, plane2->normal, plane2->dist, 0); // PLANESIDE_EPSILON);\n\t} //end for\n\n\tif (!w || WindingIsTiny(w))\n\t{\t// the brush isn't really split\n\t\tint\t\tside;\n\n\t\tLog_Print(\"Q1_SplitBrush: no split winding\\n\");\n\t\tside = BrushMostlyOnSide (brush, plane);\n\t\tif (side == PSIDE_FRONT)\n\t\t\t*front = CopyBrush (brush);\n\t\tif (side == PSIDE_BACK)\n\t\t\t*back = CopyBrush (brush);\n\t\treturn;\n\t}\n\n\tif (WindingIsHuge(w))\n\t{\n\t\tLog_Print(\"Q1_SplitBrush: WARNING huge split winding\\n\");\n\t} //end of\n\n\tmidwinding = w;\n\n\t// split it for real\n\n\tfor (i = 0; i < 2; i++)\n\t{\n\t\tb[i] = AllocBrush (brush->numsides+1);\n\t\tb[i]->original = brush->original;\n\t} //end for\n\n\t// split all the current windings\n\n\tfor (i=0 ; i<brush->numsides ; i++)\n\t{\n\t\ts = &brush->sides[i];\n\t\tw = s->winding;\n\t\tif (!w)\n\t\t\tcontinue;\n\t\tClipWindingEpsilon (w, plane->normal, plane->dist,\n\t\t\t0 /*PLANESIDE_EPSILON*/, &cw[0], &cw[1]);\n\t\tfor (j=0 ; j<2 ; j++)\n\t\t{\n\t\t\tif (!cw[j])\n\t\t\t\tcontinue;\n#if 0\n\t\t\tif (WindingIsTiny (cw[j]))\n\t\t\t{\n\t\t\t\tFreeWinding (cw[j]);\n\t\t\t\tcontinue;\n\t\t\t}\n#endif\n\t\t\tcs = &b[j]->sides[b[j]->numsides];\n\t\t\tb[j]->numsides++;\n\t\t\t*cs = *s;\n//\t\t\tcs->planenum = s->planenum;\n//\t\t\tcs->texinfo = s->texinfo;\n//\t\t\tcs->visible = s->visible;\n//\t\t\tcs->original = s->original;\n\t\t\tcs->winding = cw[j];\n\t\t\tcs->flags &= ~SFL_TESTED;\n\t\t} //end for\n\t} //end for\n\n\n\t// see if we have valid polygons on both sides\n\n\tfor (i=0 ; i<2 ; i++)\n\t{\n\t\tBoundBrush (b[i]);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\tif (b[i]->mins[j] < -4096 || b[i]->maxs[j] > 4096)\n\t\t\t{\n\t\t\t\tLog_Print(\"Q1_SplitBrush: bogus brush after clip\\n\");\n\t\t\t\tbreak;\n\t\t\t} //end if\n\t\t} //end for\n\n\t\tif (b[i]->numsides < 3 || j < 3)\n\t\t{\n\t\t\tFreeBrush (b[i]);\n\t\t\tb[i] = NULL;\n\t\t\tLog_Print(\"Q1_SplitBrush: numsides < 3\\n\");\n\t\t} //end if\n\t} //end for\n\n\tif ( !(b[0] && b[1]) )\n\t{\n\t\tif (!b[0] && !b[1])\n\t\t\tLog_Print(\"Q1_SplitBrush: split removed brush\\n\");\n\t\telse\n\t\t\tLog_Print(\"Q1_SplitBrush: split not on both sides\\n\");\n\t\tif (b[0])\n\t\t{\n\t\t\tFreeBrush (b[0]);\n\t\t\t*front = CopyBrush (brush);\n\t\t} //end if\n\t\tif (b[1])\n\t\t{\n\t\t\tFreeBrush (b[1]);\n\t\t\t*back = CopyBrush (brush);\n\t\t} //end if\n\t\treturn;\n\t} //end if\n\n\t// add the midwinding to both sides\n\tfor (i = 0; i < 2; i++)\n\t{\n\t\tcs = &b[i]->sides[b[i]->numsides];\n\t\tb[i]->numsides++;\n\n\t\tcs->planenum = planenum^i^1;\n\t\tcs->texinfo = 0;\n\t\t//store the node number in the surf to find the texinfo later on\n\t\tcs->surf = nodenum;\n\t\t//\n\t\tcs->flags &= ~SFL_VISIBLE;\n\t\tcs->flags &= ~SFL_TESTED;\n\t\tcs->flags &= ~SFL_TEXTURED;\n\t\tif (i==0)\n\t\t\tcs->winding = CopyWinding (midwinding);\n\t\telse\n\t\t\tcs->winding = midwinding;\n\t} //end for\n\n\n{\n\tvec_t v1;\n\tint i;\n\n\tfor (i=0 ; i<2 ; i++)\n\t{\n\t\tv1 = BrushVolume (b[i]);\n\t\tif (v1 < 1)\n\t\t{\n\t\t\tFreeBrush (b[i]);\n\t\t\tb[i] = NULL;\n\t\t\tLog_Print(\"Q1_SplitBrush: tiny volume after clip\\n\");\n\t\t} //end if\n\t} //end for\n} //*/\n\n\t*front = b[0];\n\t*back = b[1];\n} //end of the function Q1_SplitBrush\n//===========================================================================\n// returns true if the tree starting at nodenum has only solid leaves\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint Q1_SolidTree_r(int nodenum)\n{\n\tif (nodenum < 0)\n\t{\n\t\tswitch(q1_dleafs[(-nodenum) - 1].contents)\n\t\t{\n\t\t\tcase Q1_CONTENTS_EMPTY:\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t} //end case\n\t\t\tcase Q1_CONTENTS_SOLID:\n#ifdef HLCONTENTS\n\t\t\tcase Q1_CONTENTS_CLIP:\n#endif HLCONTENTS\n\t\t\tcase Q1_CONTENTS_SKY:\n#ifdef HLCONTENTS\n\t\t\tcase Q1_CONTENTS_TRANSLUCENT:\n#endif HLCONTENTS\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t} //end case\n\t\t\tcase Q1_CONTENTS_WATER:\n\t\t\tcase Q1_CONTENTS_SLIME:\n\t\t\tcase Q1_CONTENTS_LAVA:\n#ifdef HLCONTENTS\n\t\t\t//these contents should not be found in the BSP\n\t\t\tcase Q1_CONTENTS_ORIGIN:\n\t\t\tcase Q1_CONTENTS_CURRENT_0:\n\t\t\tcase Q1_CONTENTS_CURRENT_90:\n\t\t\tcase Q1_CONTENTS_CURRENT_180:\n\t\t\tcase Q1_CONTENTS_CURRENT_270:\n\t\t\tcase Q1_CONTENTS_CURRENT_UP:\n\t\t\tcase Q1_CONTENTS_CURRENT_DOWN:\n#endif HLCONTENTS\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t} //end default\n\t\t} //end switch\n\t\treturn false;\n\t} //end if\n\tif (!Q1_SolidTree_r(q1_dnodes[nodenum].children[0])) return false;\n\tif (!Q1_SolidTree_r(q1_dnodes[nodenum].children[1])) return false;\n\treturn true;\n} //end of the function Q1_SolidTree_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *Q1_CreateBrushes_r(bspbrush_t *brush, int nodenum)\n{\n\tint planenum;\n\tbspbrush_t *front, *back;\n\tq1_dleaf_t *leaf;\n\n\t//if it is a leaf\n\tif (nodenum < 0)\n\t{\n\t\tleaf = &q1_dleafs[(-nodenum) - 1];\n\t\tif (leaf->contents != Q1_CONTENTS_EMPTY)\n\t\t{\n#ifdef Q1_PRINT\n\t\t\tqprintf(\"\\r%5i\", ++q1_numbrushes);\n#endif //Q1_PRINT\n\t\t} //end if\n\t\tswitch(leaf->contents)\n\t\t{\n\t\t\tcase Q1_CONTENTS_EMPTY:\n\t\t\t{\n\t\t\t\tFreeBrush(brush);\n\t\t\t\treturn NULL;\n\t\t\t} //end case\n\t\t\tcase Q1_CONTENTS_SOLID:\n#ifdef HLCONTENTS\n\t\t\tcase Q1_CONTENTS_CLIP:\n#endif HLCONTENTS\n\t\t\tcase Q1_CONTENTS_SKY:\n#ifdef HLCONTENTS\n\t\t\tcase Q1_CONTENTS_TRANSLUCENT:\n#endif HLCONTENTS\n\t\t\t{\n\t\t\t\tbrush->side = CONTENTS_SOLID;\n\t\t\t\treturn brush;\n\t\t\t} //end case\n\t\t\tcase Q1_CONTENTS_WATER:\n\t\t\t{\n\t\t\t\tbrush->side = CONTENTS_WATER;\n\t\t\t\treturn brush;\n\t\t\t} //end case\n\t\t\tcase Q1_CONTENTS_SLIME:\n\t\t\t{\n\t\t\t\tbrush->side = CONTENTS_SLIME;\n\t\t\t\treturn brush;\n\t\t\t} //end case\n\t\t\tcase Q1_CONTENTS_LAVA:\n\t\t\t{\n\t\t\t\tbrush->side = CONTENTS_LAVA;\n\t\t\t\treturn brush;\n\t\t\t} //end case\n#ifdef HLCONTENTS\n\t\t\t//these contents should not be found in the BSP\n\t\t\tcase Q1_CONTENTS_ORIGIN:\n\t\t\tcase Q1_CONTENTS_CURRENT_0:\n\t\t\tcase Q1_CONTENTS_CURRENT_90:\n\t\t\tcase Q1_CONTENTS_CURRENT_180:\n\t\t\tcase Q1_CONTENTS_CURRENT_270:\n\t\t\tcase Q1_CONTENTS_CURRENT_UP:\n\t\t\tcase Q1_CONTENTS_CURRENT_DOWN:\n\t\t\t{\n\t\t\t\tError(\"Q1_CreateBrushes_r: found contents %d in Half-Life BSP\", leaf->contents);\n\t\t\t\treturn NULL;\n\t\t\t} //end case\n#endif HLCONTENTS\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\tError(\"Q1_CreateBrushes_r: unknown contents %d in Half-Life BSP\", leaf->contents);\n\t\t\t\treturn NULL;\n\t\t\t} //end default\n\t\t} //end switch\n\t\treturn NULL;\n\t} //end if\n\t//if the rest of the tree is solid\n\t/*if (Q1_SolidTree_r(nodenum))\n\t{\n\t\tbrush->side = CONTENTS_SOLID;\n\t\treturn brush;\n\t} //end if*/\n\t//\n\tplanenum = q1_dnodes[nodenum].planenum;\n\tplanenum = FindFloatPlane(q1_dplanes[planenum].normal, q1_dplanes[planenum].dist);\n\t//split the brush with the node plane\n\tQ1_SplitBrush(brush, planenum, nodenum, &front, &back);\n\t//free the original brush\n\tFreeBrush(brush);\n\t//every node must split the brush in two\n\tif (!front || !back)\n\t{\n\t\tLog_Print(\"Q1_CreateBrushes_r: WARNING node not splitting brush\\n\");\n\t\t//return NULL;\n\t} //end if\n\t//create brushes recursively\n\tif (front) front = Q1_CreateBrushes_r(front, q1_dnodes[nodenum].children[0]);\n\tif (back) back = Q1_CreateBrushes_r(back, q1_dnodes[nodenum].children[1]);\n\t//link the brushes if possible and return them\n\tif (front)\n\t{\n\t\tfor (brush = front; brush->next; brush = brush->next);\n\t\tbrush->next = back;\n\t\treturn front;\n\t} //end if\n\telse\n\t{\n\t\treturn back;\n\t} //end else\n} //end of the function Q1_CreateBrushes_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *Q1_CreateBrushesFromBSP(int modelnum)\n{\n\tbspbrush_t *brushlist;\n\tbspbrush_t *brush;\n\tq1_dnode_t *headnode;\n\tvec3_t mins, maxs;\n\tint i;\n\n\t//\n\theadnode = &q1_dnodes[q1_dmodels[modelnum].headnode[0]];\n\t//get the mins and maxs of the world\n\tVectorCopy(headnode->mins, mins);\n\tVectorCopy(headnode->maxs, maxs);\n\t//enlarge these mins and maxs\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tmins[i] -= 8;\n\t\tmaxs[i] += 8;\n\t} //end for\n\t//NOTE: have to add the BSP tree mins and maxs to the MAP mins and maxs\n\tAddPointToBounds(mins, map_mins, map_maxs);\n\tAddPointToBounds(maxs, map_mins, map_maxs);\n\t//\n\tif (!modelnum)\n\t{\n\t\tLog_Print(\"brush size: %5.0f,%5.0f,%5.0f to %5.0f,%5.0f,%5.0f\\n\",\n\t\t\t\t\t\t\tmap_mins[0], map_mins[1], map_mins[2],\n\t\t\t\t\t\t\tmap_maxs[0], map_maxs[1], map_maxs[2]);\n\t} //end if\n\t//create one huge brush containing the whole world\n\tbrush = BrushFromBounds(mins, maxs);\n\tVectorCopy(mins, brush->mins);\n\tVectorCopy(maxs, brush->maxs);\n\t//\n#ifdef Q1_PRINT\n\tqprintf(\"creating Quake brushes\\n\");\n\tqprintf(\"%5d brushes\", q1_numbrushes = 0);\n#endif //Q1_PRINT\n\t//create the brushes\n\tbrushlist = Q1_CreateBrushes_r(brush, q1_dmodels[modelnum].headnode[0]);\n\t//\n#ifdef Q1_PRINT\n\tqprintf(\"\\n\");\n#endif //Q1_PRINT\n\t//now we've got a list with brushes!\n\treturn brushlist;\n} //end of the function Q1_CreateBrushesFromBSP\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nq1_dleaf_t *Q1_PointInLeaf(int startnode, vec3_t point)\n{\n\tint nodenum;\n\tvec_t\tdist;\n\tq1_dnode_t *node;\n\tq1_dplane_t *plane;\n\n\tnodenum = startnode;\n\twhile (nodenum >= 0)\n\t{\n\t\tnode = &q1_dnodes[nodenum];\n\t\tplane = &q1_dplanes[node->planenum];\n\t\tdist = DotProduct(point, plane->normal) - plane->dist;\n\t\tif (dist > 0)\n\t\t\tnodenum = node->children[0];\n\t\telse\n\t\t\tnodenum = node->children[1];\n\t} //end while\n\n\treturn &q1_dleafs[-nodenum - 1];\n} //end of the function Q1_PointInLeaf\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat Q1_FaceArea(q1_dface_t *face)\n{\n\tint i;\n\tfloat total;\n\tvec_t *v;\n\tvec3_t d1, d2, cross;\n\tq1_dedge_t *edge;\n\n\tedge = &q1_dedges[face->firstedge];\n\tv = q1_dvertexes[edge->v[0]].point;\n\n\ttotal = 0;\n\tfor (i = 1; i < face->numedges - 1; i++)\n\t{\n\t\tedge = &q1_dedges[face->firstedge + i];\n\t\tVectorSubtract(q1_dvertexes[edge->v[0]].point, v, d1);\n\t\tVectorSubtract(q1_dvertexes[edge->v[1]].point, v, d2);\n\t\tCrossProduct(d1, d2, cross);\n\t\ttotal += 0.5 * VectorLength(cross);\n\t} //end for\n\treturn total;\n} //end of the function AAS_FaceArea\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Q1_FacePlane(q1_dface_t *face, vec3_t normal, float *dist)\n{\n\tvec_t *v1, *v2, *v3;\n\tvec3_t vec1, vec2;\n\tint side, edgenum;\n\n\tedgenum = q1_dsurfedges[face->firstedge];\n\tside = edgenum < 0;\n\tv1 = q1_dvertexes[q1_dedges[abs(edgenum)].v[side]].point;\n\tv2 = q1_dvertexes[q1_dedges[abs(edgenum)].v[!side]].point;\n\tedgenum = q1_dsurfedges[face->firstedge+1];\n\tside = edgenum < 0;\n\tv3 = q1_dvertexes[q1_dedges[abs(edgenum)].v[!side]].point;\n\t//\n\tVectorSubtract(v2, v1, vec1);\n\tVectorSubtract(v3, v1, vec2);\n\n\tCrossProduct(vec1, vec2, normal);\n\tVectorNormalize(normal);\n\t*dist = DotProduct(v1, normal);\n} //end of the function Q1_FacePlane\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *Q1_MergeBrushes(bspbrush_t *brushlist, int modelnum)\n{\n\tint nummerges, merged;\n\tbspbrush_t *b1, *b2, *tail, *newbrush, *newbrushlist;\n\tbspbrush_t *lastb2;\n\n\tif (!brushlist) return NULL;\n\n\tif (!modelnum) qprintf(\"%5d brushes merged\", nummerges = 0);\n\tdo\n\t{\n\t\tfor (tail = brushlist; tail; tail = tail->next)\n\t\t{\n\t\t\tif (!tail->next) break;\n\t\t} //end for\n\t\tmerged = 0;\n\t\tnewbrushlist = NULL;\n\t\tfor (b1 = brushlist; b1; b1 = brushlist)\n\t\t{\n\t\t\tlastb2 = b1;\n\t\t\tfor (b2 = b1->next; b2; b2 = b2->next)\n\t\t\t{\n\t\t\t\t//can't merge brushes with different contents\n\t\t\t\tif (b1->side != b2->side) newbrush = NULL;\n\t\t\t\telse newbrush = TryMergeBrushes(b1, b2);\n\t\t\t\t//if a merged brush is created\n\t\t\t\tif (newbrush)\n\t\t\t\t{\n\t\t\t\t\t//copy the brush contents\n\t\t\t\t\tnewbrush->side = b1->side;\n\t\t\t\t\t//add the new brush to the end of the list\n\t\t\t\t\ttail->next = newbrush;\n\t\t\t\t\t//remove the second brush from the list\n\t\t\t\t\tlastb2->next = b2->next;\n\t\t\t\t\t//remove the first brush from the list\n\t\t\t\t\tbrushlist = brushlist->next;\n\t\t\t\t\t//free the merged brushes\n\t\t\t\t\tFreeBrush(b1);\n\t\t\t\t\tFreeBrush(b2);\n\t\t\t\t\t//get a new tail brush\n\t\t\t\t\tfor (tail = brushlist; tail; tail = tail->next)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!tail->next) break;\n\t\t\t\t\t} //end for\n\t\t\t\t\tmerged++;\n\t\t\t\t\tif (!modelnum) qprintf(\"\\r%5d\", nummerges++);\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t\tlastb2 = b2;\n\t\t\t} //end for\n\t\t\t//if b1 can't be merged with any of the other brushes\n\t\t\tif (!b2)\n\t\t\t{\n\t\t\t\tbrushlist = brushlist->next;\n\t\t\t\t//keep b1\n\t\t\t\tb1->next = newbrushlist;\n\t\t\t\tnewbrushlist = b1;\n\t\t\t} //end else\n\t\t} //end for\n\t\tbrushlist = newbrushlist;\n\t} while(merged);\n\tif (!modelnum) qprintf(\"\\n\");\n\treturn newbrushlist;\n} //end of the function Q1_MergeBrushes\n//===========================================================================\n// returns the amount the face and the winding overlap\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat Q1_FaceOnWinding(q1_dface_t *face, winding_t *winding)\n{\n\tint i, edgenum, side;\n\tfloat dist, area;\n\tq1_dplane_t plane;\n\tvec_t *v1, *v2;\n\tvec3_t normal, edgevec;\n\twinding_t *w;\n\n\t//\n\tw = CopyWinding(winding);\n\tmemcpy(&plane, &q1_dplanes[face->planenum], sizeof(q1_dplane_t));\n\t//check on which side of the plane the face is\n\tif (face->side)\n\t{\n\t\tVectorNegate(plane.normal, plane.normal);\n\t\tplane.dist = -plane.dist;\n\t} //end if\n\tfor (i = 0; i < face->numedges && w; i++)\n\t{\n\t\t//get the first and second vertex of the edge\n\t\tedgenum = q1_dsurfedges[face->firstedge + i];\n\t\tside = edgenum > 0;\n\t\t//if the face plane is flipped\n\t\tv1 = q1_dvertexes[q1_dedges[abs(edgenum)].v[side]].point;\n\t\tv2 = q1_dvertexes[q1_dedges[abs(edgenum)].v[!side]].point;\n\t\t//create a plane through the edge vector, orthogonal to the face plane\n\t\t//and with the normal vector pointing out of the face\n\t\tVectorSubtract(v1, v2, edgevec);\n\t\tCrossProduct(edgevec, plane.normal, normal);\n\t\tVectorNormalize(normal);\n\t\tdist = DotProduct(normal, v1);\n\t\t//\n\t\tChopWindingInPlace(&w, normal, dist, 0.9); //CLIP_EPSILON\n\t} //end for\n\tif (w)\n\t{\n\t\tarea = WindingArea(w);\n\t\tFreeWinding(w);\n\t\treturn area;\n\t} //end if\n\treturn 0;\n} //end of the function Q1_FaceOnWinding\n//===========================================================================\n// returns a list with brushes created by splitting the given brush with\n// planes that go through the face edges and are orthogonal to the face plane\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *Q1_SplitBrushWithFace(bspbrush_t *brush, q1_dface_t *face)\n{\n\tint i, edgenum, side, planenum, splits;\n\tfloat dist;\n\tq1_dplane_t plane;\n\tvec_t *v1, *v2;\n\tvec3_t normal, edgevec;\n\tbspbrush_t *front, *back, *brushlist;\n\n\tmemcpy(&plane, &q1_dplanes[face->planenum], sizeof(q1_dplane_t));\n\t//check on which side of the plane the face is\n\tif (face->side)\n\t{\n\t\tVectorNegate(plane.normal, plane.normal);\n\t\tplane.dist = -plane.dist;\n\t} //end if\n\tsplits = 0;\n\tbrushlist = NULL;\n\tfor (i = 0; i < face->numedges; i++)\n\t{\n\t\t//get the first and second vertex of the edge\n\t\tedgenum = q1_dsurfedges[face->firstedge + i];\n\t\tside = edgenum > 0;\n\t\t//if the face plane is flipped\n\t\tv1 = q1_dvertexes[q1_dedges[abs(edgenum)].v[side]].point;\n\t\tv2 = q1_dvertexes[q1_dedges[abs(edgenum)].v[!side]].point;\n\t\t//create a plane through the edge vector, orthogonal to the face plane\n\t\t//and with the normal vector pointing out of the face\n\t\tVectorSubtract(v1, v2, edgevec);\n\t\tCrossProduct(edgevec, plane.normal, normal);\n\t\tVectorNormalize(normal);\n\t\tdist = DotProduct(normal, v1);\n\t\t//\n\t\tplanenum = FindFloatPlane(normal, dist);\n\t\t//split the current brush\n\t\tSplitBrush(brush, planenum, &front, &back);\n\t\t//if there is a back brush just put it in the list\n\t\tif (back)\n\t\t{\n\t\t\t//copy the brush contents\n\t\t\tback->side = brush->side;\n\t\t\t//\n\t\t\tback->next = brushlist;\n\t\t\tbrushlist = back;\n\t\t\tsplits++;\n\t\t} //end if\n\t\tif (!front)\n\t\t{\n\t\t\tLog_Print(\"Q1_SplitBrushWithFace: no new brush\\n\");\n\t\t\tFreeBrushList(brushlist);\n\t\t\treturn NULL;\n\t\t} //end if\n\t\t//copy the brush contents\n\t\tfront->side = brush->side;\n\t\t//continue splitting the front brush\n\t\tbrush = front;\n\t} //end for\n\tif (!splits)\n\t{\n\t\tFreeBrush(front);\n\t\treturn NULL;\n\t} //end if\n\tfront->next = brushlist;\n\tbrushlist = front;\n\treturn brushlist;\n} //end of the function Q1_SplitBrushWithFace\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nbspbrush_t *Q1_TextureBrushes(bspbrush_t *brushlist, int modelnum)\n{\n\tfloat area, largestarea;\n\tint i, n, texinfonum, sn, numbrushes, ofs;\n\tint bestfacenum, sidenodenum;\n\tside_t *side;\n\tq1_dmiptexlump_t *miptexlump;\n\tq1_miptex_t *miptex;\n\tbspbrush_t *brush, *nextbrush, *prevbrush, *newbrushes, *brushlistend;\n\tvec_t defaultvec[4] = {1, 0, 0, 0};\n\n\tif (!modelnum) qprintf(\"texturing brushes\\n\");\n\tif (!modelnum) qprintf(\"%5d brushes\", numbrushes = 0);\n\t//get a pointer to the last brush in the list\n\tfor (brushlistend = brushlist; brushlistend; brushlistend = brushlistend->next)\n\t{\n\t\tif (!brushlistend->next) break;\n\t} //end for\n\t//there's no previous brush when at the start of the list\n\tprevbrush = NULL;\n\t//go over the brush list\n\tfor (brush = brushlist; brush; brush = nextbrush)\n\t{\n\t\tnextbrush = brush->next;\n\t\t//find a texinfo for every brush side\n\t\tfor (sn = 0; sn < brush->numsides; sn++)\n\t\t{\n\t\t\tside = &brush->sides[sn];\n\t\t\t//\n\t\t\tif (side->flags & SFL_TEXTURED) continue;\n\t\t\t//number of the node that created this brush side\n\t\t\tsidenodenum = side->surf;\t//see midwinding in Q1_SplitBrush\n\t\t\t//no face found yet\n\t\t\tbestfacenum = -1;\n\t\t\t//minimum face size\n\t\t\tlargestarea = 1;\n\t\t\t//if optimizing the texture placement and not going for the\n\t\t\t//least number of brushes\n\t\t\tif (!lessbrushes)\n\t\t\t{\n\t\t\t\tfor (i = 0; i < q1_numfaces; i++)\n\t\t\t\t{\n\t\t\t\t\t//the face must be in the same plane as the node plane that created\n\t\t\t\t\t//this brush side\n\t\t\t\t\tif (q1_dfaces[i].planenum == q1_dnodes[sidenodenum].planenum)\n\t\t\t\t\t{\n\t\t\t\t\t\t//get the area the face and the brush side overlap\n\t\t\t\t\t\tarea = Q1_FaceOnWinding(&q1_dfaces[i], side->winding);\n\t\t\t\t\t\t//if this face overlaps the brush side winding more than previous faces\n\t\t\t\t\t\tif (area > largestarea)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t//if there already was a face for texturing this brush side with\n\t\t\t\t\t\t\t//a different texture\n\t\t\t\t\t\t\tif (bestfacenum >= 0 &&\n\t\t\t\t\t\t\t\t\t(q1_dfaces[bestfacenum].texinfo != q1_dfaces[i].texinfo))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t//split the brush to fit the texture\n\t\t\t\t\t\t\t\tnewbrushes = Q1_SplitBrushWithFace(brush, &q1_dfaces[i]);\n\t\t\t\t\t\t\t\t//if new brushes where created\n\t\t\t\t\t\t\t\tif (newbrushes)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t//remove the current brush from the list\n\t\t\t\t\t\t\t\t\tif (prevbrush) prevbrush->next = brush->next;\n\t\t\t\t\t\t\t\t\telse brushlist = brush->next;\n\t\t\t\t\t\t\t\t\tif (brushlistend == brush)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tbrushlistend = prevbrush;\n\t\t\t\t\t\t\t\t\t\tnextbrush = newbrushes;\n\t\t\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\t\t\t//add the new brushes to the end of the list\n\t\t\t\t\t\t\t\t\tif (brushlistend) brushlistend->next = newbrushes;\n\t\t\t\t\t\t\t\t\telse brushlist = newbrushes;\n\t\t\t\t\t\t\t\t\t//free the current brush\n\t\t\t\t\t\t\t\t\tFreeBrush(brush);\n\t\t\t\t\t\t\t\t\t//don't forget about the prevbrush pointer at the bottom of\n\t\t\t\t\t\t\t\t\t//the outer loop\n\t\t\t\t\t\t\t\t\tbrush = prevbrush;\n\t\t\t\t\t\t\t\t\t//find the end of the list\n\t\t\t\t\t\t\t\t\tfor (brushlistend = brushlist; brushlistend; brushlistend = brushlistend->next)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tif (!brushlistend->next) break;\n\t\t\t\t\t\t\t\t\t} //end for\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tLog_Write(\"brush %d: no real texture split\", numbrushes);\n\t\t\t\t\t\t\t\t} //end else\n\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t//best face for texturing this brush side\n\t\t\t\t\t\t\t\tbestfacenum = i;\n\t\t\t\t\t\t\t} //end else\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end if\n\t\t\t\t} //end for\n\t\t\t\t//if the brush was split the original brush is removed\n\t\t\t\t//and we just continue with the next one in the list\n\t\t\t\tif (i < q1_numfaces) break;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\t//find the face with the largest overlap with this brush side\n\t\t\t\t//for texturing the brush side\n\t\t\t\tfor (i = 0; i < q1_numfaces; i++)\n\t\t\t\t{\n\t\t\t\t\t//the face must be in the same plane as the node plane that created\n\t\t\t\t\t//this brush side\n\t\t\t\t\tif (q1_dfaces[i].planenum == q1_dnodes[sidenodenum].planenum)\n\t\t\t\t\t{\n\t\t\t\t\t\t//get the area the face and the brush side overlap\n\t\t\t\t\t\tarea = Q1_FaceOnWinding(&q1_dfaces[i], side->winding);\n\t\t\t\t\t\t//if this face overlaps the brush side winding more than previous faces\n\t\t\t\t\t\tif (area > largestarea)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlargestarea = area;\n\t\t\t\t\t\t\tbestfacenum = i;\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end if\n\t\t\t\t} //end for\n\t\t\t} //end else\n\t\t\t//if a face was found for texturing this brush side\n\t\t\tif (bestfacenum >= 0)\n\t\t\t{\n\t\t\t\t//set the MAP texinfo values\n\t\t\t\ttexinfonum = q1_dfaces[bestfacenum].texinfo;\n\t\t\t\tfor (n = 0; n < 4; n++)\n\t\t\t\t{\n\t\t\t\t\tmap_texinfo[texinfonum].vecs[0][n] = q1_texinfo[texinfonum].vecs[0][n];\n\t\t\t\t\tmap_texinfo[texinfonum].vecs[1][n] = q1_texinfo[texinfonum].vecs[1][n];\n\t\t\t\t} //end for\n\t\t\t\t//make sure the two vectors aren't of zero length otherwise use the default\n\t\t\t\t//vector to prevent a divide by zero in the map writing\n\t\t\t\tif (VectorLength(map_texinfo[texinfonum].vecs[0]) < 0.01)\n\t\t\t\t\tmemcpy(map_texinfo[texinfonum].vecs[0], defaultvec, sizeof(defaultvec));\n\t\t\t\tif (VectorLength(map_texinfo[texinfonum].vecs[1]) < 0.01)\n\t\t\t\t\tmemcpy(map_texinfo[texinfonum].vecs[1], defaultvec, sizeof(defaultvec));\n\t\t\t\t//\n\t\t\t\tmap_texinfo[texinfonum].flags = q1_texinfo[texinfonum].flags;\n\t\t\t\tmap_texinfo[texinfonum].value = 0; //Q1 and HL texinfos don't have a value\n\t\t\t\t//the mip texture\n\t\t\t\tmiptexlump = (q1_dmiptexlump_t *) q1_dtexdata;\n\t\t\t\tofs = miptexlump->dataofs[q1_texinfo[texinfonum].miptex];\n\t\t\t\tif ( ofs > q1_texdatasize ) {\n\t\t\t\t\tofs = miptexlump->dataofs[0];\n\t\t\t\t}\n\t\t\t\tmiptex = (q1_miptex_t *)((byte *)miptexlump + ofs);\n\t\t\t\t//get the mip texture name\n\t\t\t\tstrcpy(map_texinfo[texinfonum].texture, miptex->name);\n\t\t\t\t//no animations in Quake1 and Half-Life mip textures\n\t\t\t\tmap_texinfo[texinfonum].nexttexinfo = -1;\n\t\t\t\t//store the texinfo number\n\t\t\t\tside->texinfo = texinfonum;\n\t\t\t\t//\n\t\t\t\tif (texinfonum > map_numtexinfo) map_numtexinfo = texinfonum;\n\t\t\t\t//this side is textured\n\t\t\t\tside->flags |= SFL_TEXTURED;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\t//no texture for this side\n\t\t\t\tside->texinfo = TEXINFO_NODE;\n\t\t\t\t//this side is textured\n\t\t\t\tside->flags |= SFL_TEXTURED;\n\t\t\t} //end if\n\t\t} //end for\n\t\t//\n\t\tif (!modelnum && prevbrush != brush) qprintf(\"\\r%5d\", ++numbrushes);\n\t\t//previous brush in the list\n\t\tprevbrush = brush;\n\t} //end for\n\tif (!modelnum) qprintf(\"\\n\");\n\t//return the new list with brushes\n\treturn brushlist;\n} //end of the function Q1_TextureBrushes\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Q1_FixContentsTextures(bspbrush_t *brushlist)\n{\n\tint i, texinfonum;\n\tbspbrush_t *brush;\n\n\tfor (brush = brushlist; brush; brush = brush->next)\n\t{\n\t\t//only fix the textures of water, slime and lava brushes\n\t\tif (brush->side != CONTENTS_WATER &&\n\t\t\tbrush->side != CONTENTS_SLIME &&\n\t\t\tbrush->side != CONTENTS_LAVA) continue;\n\t\t//\n\t\tfor (i = 0; i < brush->numsides; i++)\n\t\t{\n\t\t\ttexinfonum = brush->sides[i].texinfo;\n\t\t\tif (Q1_TextureContents(map_texinfo[texinfonum].texture) == brush->side) break;\n\t\t} //end for\n\t\t//if no specific contents texture was found\n\t\tif (i >= brush->numsides)\n\t\t{\n\t\t\ttexinfonum = -1;\n\t\t\tfor (i = 0; i < map_numtexinfo; i++)\n\t\t\t{\n\t\t\t\tif (Q1_TextureContents(map_texinfo[i].texture) == brush->side)\n\t\t\t\t{\n\t\t\t\t\ttexinfonum = i;\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t} //end for\n\t\t} //end if\n\t\t//\n\t\tif (texinfonum >= 0)\n\t\t{\n\t\t\t//give all the brush sides this contents texture\n\t\t\tfor (i = 0; i < brush->numsides; i++)\n\t\t\t{\n\t\t\t\tbrush->sides[i].texinfo = texinfonum;\n\t\t\t} //end for\n\t\t} //end if\n\t\telse Log_Print(\"brush contents %d with wrong textures\\n\", brush->side);\n\t\t//\n\t} //end for\n\t/*\n\tfor (brush = brushlist; brush; brush = brush->next)\n\t{\n\t\t//give all the brush sides this contents texture\n\t\tfor (i = 0; i < brush->numsides; i++)\n\t\t{\n\t\t\tif (Q1_TextureContents(map_texinfo[texinfonum].texture) != brush->side)\n\t\t\t{\n\t\t\t\tError(\"brush contents %d with wrong contents textures %s\\n\", brush->side,\n\t\t\t\t\t\t\tQ1_TextureContents(map_texinfo[texinfonum].texture));\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for*/\n} //end of the function Q1_FixContentsTextures\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Q1_BSPBrushToMapBrush(bspbrush_t *bspbrush, entity_t *mapent)\n{\n\tmapbrush_t *mapbrush;\n\tside_t *side;\n\tint i, besttexinfo;\n\n\tCheckBSPBrush(bspbrush);\n\n\tif (nummapbrushes >= MAX_MAPFILE_BRUSHES)\n\tError (\"nummapbrushes == MAX_MAPFILE_BRUSHES\");\n\n\tmapbrush = &mapbrushes[nummapbrushes];\n\tmapbrush->original_sides = &brushsides[nummapbrushsides];\n\tmapbrush->entitynum = mapent - entities;\n\tmapbrush->brushnum = nummapbrushes - mapent->firstbrush;\n\tmapbrush->leafnum = -1;\n\tmapbrush->numsides = 0;\n\n\tbesttexinfo = TEXINFO_NODE;\n\tfor (i = 0; i < bspbrush->numsides; i++)\n\t{\n\t\tif (!bspbrush->sides[i].winding) continue;\n\t\t//\n\t\tif (nummapbrushsides >= MAX_MAPFILE_BRUSHSIDES)\n\t\t\tError (\"MAX_MAPFILE_BRUSHSIDES\");\n\t\tside = &brushsides[nummapbrushsides];\n\t\t//the contents of the bsp brush is stored in the side variable\n\t\tside->contents = bspbrush->side;\n\t\tside->surf = 0;\n\t\tside->planenum = bspbrush->sides[i].planenum;\n\t\tside->texinfo = bspbrush->sides[i].texinfo;\n\t\tif (side->texinfo != TEXINFO_NODE)\n\t\t{\n\t\t\t//this brush side is textured\n\t\t\tside->flags |= SFL_TEXTURED;\n\t\t\tbesttexinfo = side->texinfo;\n\t\t} //end if\n\t\t//\n\t\tnummapbrushsides++;\n\t\tmapbrush->numsides++;\n\t} //end for\n\t//\n\tif (besttexinfo == TEXINFO_NODE)\n\t{\n\t\tmapbrush->numsides = 0;\n\t\tq1_numclipbrushes++;\n\t\treturn;\n\t} //end if\n\t//set the texinfo for all the brush sides without texture\n\tfor (i = 0; i < mapbrush->numsides; i++)\n\t{\n\t\tif (mapbrush->original_sides[i].texinfo == TEXINFO_NODE)\n\t\t{\n\t\t\tmapbrush->original_sides[i].texinfo = besttexinfo;\n\t\t} //end if\n\t} //end for\n\t//contents of the brush\n\tmapbrush->contents = bspbrush->side;\n\t//\n\tif (create_aas)\n\t{\n\t\t//create the AAS brushes from this brush, add brush bevels\n\t\tAAS_CreateMapBrushes(mapbrush, mapent, true);\n\t\treturn;\n\t} //end if\n\t//create windings for sides and bounds for brush\n\tMakeBrushWindings(mapbrush);\n\t//add brush bevels\n\tAddBrushBevels(mapbrush);\n\t//a new brush has been created\n\tnummapbrushes++;\n\tmapent->numbrushes++;\n} //end of the function Q1_BSPBrushToMapBrush\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Q1_CreateMapBrushes(entity_t *mapent, int modelnum)\n{\n\tbspbrush_t *brushlist, *brush, *nextbrush;\n\tint i;\n\n\t//create brushes from the model BSP tree\n\tbrushlist = Q1_CreateBrushesFromBSP(modelnum);\n\t//texture the brushes and split them when necesary\n\tbrushlist = Q1_TextureBrushes(brushlist, modelnum);\n\t//fix the contents textures of all brushes\n\tQ1_FixContentsTextures(brushlist);\n\t//\n\tif (!nobrushmerge)\n\t{\n\t\tbrushlist = Q1_MergeBrushes(brushlist, modelnum);\n\t\t//brushlist = Q1_MergeBrushes(brushlist, modelnum);\n\t} //end if\n\t//\n\tif (!modelnum) qprintf(\"converting brushes to map brushes\\n\");\n\tif (!modelnum) qprintf(\"%5d brushes\", i = 0);\n\tfor (brush = brushlist; brush; brush = nextbrush)\n\t{\n\t\tnextbrush = brush->next;\n\t\tQ1_BSPBrushToMapBrush(brush, mapent);\n\t\tbrush->next = NULL;\n\t\tFreeBrush(brush);\n\t\tif (!modelnum) qprintf(\"\\r%5d\", ++i);\n\t} //end for\n\tif (!modelnum) qprintf(\"\\n\");\n} //end of the function Q1_CreateMapBrushes\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Q1_ResetMapLoading(void)\n{\n} //end of the function Q1_ResetMapLoading\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Q1_LoadMapFromBSP(char *filename, int offset, int length)\n{\n\tint i, modelnum;\n\tchar *model, *classname;\n\n\tLog_Print(\"-- Q1_LoadMapFromBSP --\\n\");\n\t//the loaded map type\n\tloadedmaptype = MAPTYPE_QUAKE1;\n\t//\n\tqprintf(\"loading map from %s at %d\\n\", filename, offset);\n\t//load the Half-Life BSP file\n\tQ1_LoadBSPFile(filename, offset, length);\n\t//\n\tq1_numclipbrushes = 0;\n\t//CreatePath(path);\n\t//Q1_CreateQ2WALFiles(path);\n\t//parse the entities from the BSP\n\tQ1_ParseEntities();\n\t//clear the map mins and maxs\n\tClearBounds(map_mins, map_maxs);\n\t//\n\tqprintf(\"creating Quake1 brushes\\n\");\n\tif (lessbrushes) qprintf(\"creating minimum number of brushes\\n\");\n\telse qprintf(\"placing textures correctly\\n\");\n\t//\n\tfor (i = 0; i < num_entities; i++)\n\t{\n\t\tentities[i].firstbrush = nummapbrushes;\n\t\tentities[i].numbrushes = 0;\n\t\t//\n\t\tclassname = ValueForKey(&entities[i], \"classname\");\n\t\tif (classname && !strcmp(classname, \"worldspawn\"))\n\t\t{\n\t\t\tmodelnum = 0;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\t//\n\t\t\tmodel = ValueForKey(&entities[i], \"model\");\n\t\t\tif (!model || *model != '*') continue;\n\t\t\tmodel++;\n\t\t\tmodelnum = atoi(model);\n\t\t} //end else\n\t\t//create map brushes for the entity\n\t\tQ1_CreateMapBrushes(&entities[i], modelnum);\n\t} //end for\n\t//\n\tqprintf(\"%5d map brushes\\n\", nummapbrushes);\n\tqprintf(\"%5d clip brushes\\n\", q1_numclipbrushes);\n} //end of the function Q1_LoadMapFromBSP\n"
  },
  {
    "path": "code/bspc/map_q2.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n//===========================================================================\n// ANSI, Area Navigational System Interface\n// AAS,  Area Awareness System\n//===========================================================================\n\n#include \"qbsp.h\"\n#include \"l_mem.h\"\n#include \"../botlib/aasfile.h\"\t\t\t//aas_bbox_t\n#include \"aas_store.h\"\t\t//AAS_MAX_BBOXES\n#include \"aas_cfg.h\"\n#include \"aas_map.h\"\t\t\t//AAS_CreateMapBrushes\n#include \"l_bsp_q2.h\"\n\n\n#ifdef ME\n\n#define NODESTACKSIZE\t\t1024\n\nint nodestack[NODESTACKSIZE];\nint *nodestackptr;\nint nodestacksize = 0;\nint brushmodelnumbers[MAX_MAPFILE_BRUSHES];\nint dbrushleafnums[MAX_MAPFILE_BRUSHES];\nint dplanes2mapplanes[MAX_MAPFILE_PLANES];\n\n#endif //ME\n\n//====================================================================\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Q2_CreateMapTexinfo(void)\n{\n\tint i;\n\n\tfor (i = 0; i < numtexinfo; i++)\n\t{\n\t\tmemcpy(map_texinfo[i].vecs, texinfo[i].vecs, sizeof(float) * 2 * 4);\n\t\tmap_texinfo[i].flags = texinfo[i].flags;\n\t\tmap_texinfo[i].value = texinfo[i].value;\n\t\tstrcpy(map_texinfo[i].texture, texinfo[i].texture);\n\t\tmap_texinfo[i].nexttexinfo = 0;\n\t} //end for\n} //end of the function Q2_CreateMapTexinfo\n\n/*\n===========\nQ2_BrushContents\n===========\n*/\nint\tQ2_BrushContents (mapbrush_t *b)\n{\n\tint\t\t\tcontents;\n\tside_t\t\t*s;\n\tint\t\t\ti;\n\tint\t\t\ttrans;\n\n\ts = &b->original_sides[0];\n\tcontents = s->contents;\n\ttrans = texinfo[s->texinfo].flags;\n\tfor (i = 1; i < b->numsides; i++, s++)\n\t{\n\t\ts = &b->original_sides[i];\n\t\ttrans |= texinfo[s->texinfo].flags;\n\t\tif (s->contents != contents)\n\t\t{\n\t\t\tLog_Print(\"Entity %i, Brush %i: mixed face contents\\n\"\n\t\t\t\t, b->entitynum, b->brushnum);\n\t\t\tLog_Print(\"texture name = %s\\n\", texinfo[s->texinfo].texture);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// if any side is translucent, mark the contents\n\t// and change solid to window\n\tif ( trans & (SURF_TRANS33|SURF_TRANS66) )\n\t{\n\t\tcontents |= CONTENTS_Q2TRANSLUCENT;\n\t\tif (contents & CONTENTS_SOLID)\n\t\t{\n\t\t\tcontents &= ~CONTENTS_SOLID;\n\t\t\tcontents |= CONTENTS_WINDOW;\n\t\t}\n\t}\n\n\treturn contents;\n}\n\n#ifdef ME\n\n#define BBOX_NORMAL_EPSILON\t\t\t0.0001\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid MakeAreaPortalBrush(mapbrush_t *brush)\n{\n\tint sn;\n\tside_t *s;\n\n\tbrush->contents = CONTENTS_AREAPORTAL;\n\n\tfor (sn = 0; sn < brush->numsides; sn++)\n\t{\n\t\ts = brush->original_sides + sn;\n\t\t//make sure the surfaces are not hint or skip\n\t\ts->surf &= ~(SURF_HINT|SURF_SKIP);\n\t\t//\n\t\ts->texinfo = 0;\n\t\ts->contents = CONTENTS_AREAPORTAL;\n\t} //end for\n} //end of the function MakeAreaPortalBrush\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid DPlanes2MapPlanes(void)\n{\n\tint i;\n\n\tfor (i = 0; i < numplanes; i++)\n\t{\n\t\tdplanes2mapplanes[i] = FindFloatPlane(dplanes[i].normal, dplanes[i].dist);\n\t} //end for\n} //end of the function DPlanes2MapPlanes\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid MarkVisibleBrushSides(mapbrush_t *brush)\n{\n\tint n, i, planenum;\n\tside_t *side;\n\tdface_t *face;\n\t//\n\tfor (n = 0; n < brush->numsides; n++)\n\t{\n\t\tside = brush->original_sides + n;\n\t\t//if this side is a bevel or the leaf number of the brush is unknown\n\t\tif ((side->flags & SFL_BEVEL) || brush->leafnum < 0)\n\t\t{\n\t\t\t//this side is a valid splitter\n\t\t\tside->flags |= SFL_VISIBLE;\n\t\t\tcontinue;\n\t\t} //end if\n\t\t//assum this side will not be used as a splitter\n\t\tside->flags &= ~SFL_VISIBLE;\n\t\t//check if the side plane is used by a visible face\n\t\tfor (i = 0; i < numfaces; i++)\n\t\t{\n\t\t\tface = &dfaces[i];\n\t\t\tplanenum = dplanes2mapplanes[face->planenum];\n\t\t\tif ((planenum & ~1) == (side->planenum & ~1))\n\t\t\t{\n\t\t\t\t//this side is a valid splitter\n\t\t\t\tside->flags |= SFL_VISIBLE;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n} //end of the function MarkVisibleBrushSides\n\n#endif //ME\n\n/*\n=================\nQ2_ParseBrush\n=================\n*/\nvoid Q2_ParseBrush (script_t *script, entity_t *mapent)\n{\n\tmapbrush_t *b;\n\tint i, j, k;\n\tint mt;\n\tside_t *side, *s2;\n\tint planenum;\n\tbrush_texture_t td;\n\tint planepts[3][3];\n\ttoken_t token;\n\n\tif (nummapbrushes >= MAX_MAPFILE_BRUSHES)\n\t\tError (\"nummapbrushes == MAX_MAPFILE_BRUSHES\");\n\n\tb = &mapbrushes[nummapbrushes];\n\tb->original_sides = &brushsides[nummapbrushsides];\n\tb->entitynum = num_entities-1;\n\tb->brushnum = nummapbrushes - mapent->firstbrush;\n\tb->leafnum = -1;\n\n\tdo\n\t{\n\t\tif (!PS_ReadToken(script, &token))\n\t\t\tbreak;\n\t\tif (!strcmp(token.string, \"}\") )\n\t\t\tbreak;\n\n\t\t//IDBUG: mixed use of MAX_MAPFILE_? and MAX_MAP_? this could\n\t\t//\t\t\tlead to out of bound indexing of the arrays\n\t\tif (nummapbrushsides >= MAX_MAPFILE_BRUSHSIDES)\n\t\t\tError (\"MAX_MAPFILE_BRUSHSIDES\");\n\t\tside = &brushsides[nummapbrushsides];\n\n\t\t//read the three point plane definition\n\t\tfor (i = 0; i < 3; i++)\n\t\t{\n\t\t\tif (i != 0) PS_ExpectTokenString(script, \"(\");\n\t\t\tfor (j = 0; j < 3; j++)\n\t\t\t{\n\t\t\t\tPS_ExpectAnyToken(script, &token);\n\t\t\t\tplanepts[i][j] = atof(token.string);\n\t\t\t} //end for\n\t\t\tPS_ExpectTokenString(script, \")\");\n\t\t} //end for\n\n\t\t//\n\t\t//read the texturedef\n\t\t//\n\t\tPS_ExpectAnyToken(script, &token);\n\t\tstrcpy(td.name, token.string);\n\n\t\tPS_ExpectAnyToken(script, &token);\n\t\ttd.shift[0] = atol(token.string);\n\t\tPS_ExpectAnyToken(script, &token);\n\t\ttd.shift[1] = atol(token.string);\n\t\tPS_ExpectAnyToken(script, &token);\n\t\ttd.rotate = atol(token.string);\n\t\tPS_ExpectAnyToken(script, &token);\n\t\ttd.scale[0] = atof(token.string);\n\t\tPS_ExpectAnyToken(script, &token);\n\t\ttd.scale[1] = atof(token.string);\n\n\t\t//find default flags and values\n\t\tmt = FindMiptex (td.name);\n\t\ttd.flags = textureref[mt].flags;\n\t\ttd.value = textureref[mt].value;\n\t\tside->contents = textureref[mt].contents;\n\t\tside->surf = td.flags = textureref[mt].flags;\n\n\t\t//check if there's a number available\n\t\tif (PS_CheckTokenType(script, TT_NUMBER, 0, &token))\n\t\t{\n\t\t\tside->contents = token.intvalue;\n\t\t\tPS_ExpectTokenType(script, TT_NUMBER, 0, &token);\n\t\t\tside->surf = td.flags = token.intvalue;\n\t\t\tPS_ExpectTokenType(script, TT_NUMBER, 0, &token);\n\t\t\ttd.value = token.intvalue;\n\t\t}\n\n\t\t// translucent objects are automatically classified as detail\n\t\tif (side->surf & (SURF_TRANS33|SURF_TRANS66) )\n\t\t\tside->contents |= CONTENTS_DETAIL;\n\t\tif (side->contents & (CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP) )\n\t\t\tside->contents |= CONTENTS_DETAIL;\n\t\tif (fulldetail)\n\t\t\tside->contents &= ~CONTENTS_DETAIL;\n\t\tif (!(side->contents & ((LAST_VISIBLE_CONTENTS-1) \n\t\t\t| CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP|CONTENTS_MIST)  ) )\n\t\t\tside->contents |= CONTENTS_SOLID;\n\n\t\t// hints and skips are never detail, and have no content\n\t\tif (side->surf & (SURF_HINT|SURF_SKIP) )\n\t\t{\n\t\t\tside->contents = 0;\n\t\t\tside->surf &= ~CONTENTS_DETAIL;\n\t\t}\n\n#ifdef ME\n\t\t//for creating AAS... this side is textured\n\t\tside->flags |= SFL_TEXTURED;\n#endif //ME\n\t\t//\n\t\t// find the plane number\n\t\t//\n\t\tplanenum = PlaneFromPoints (planepts[0], planepts[1], planepts[2]);\n\t\tif (planenum == -1)\n\t\t{\n\t\t\tLog_Print(\"Entity %i, Brush %i: plane with no normal\\n\"\n\t\t\t\t, b->entitynum, b->brushnum);\n\t\t\tcontinue;\n\t\t}\n\n\t\t//\n\t\t// see if the plane has been used already\n\t\t//\n\t\tfor (k=0 ; k<b->numsides ; k++)\n\t\t{\n\t\t\ts2 = b->original_sides + k;\n\t\t\tif (s2->planenum == planenum)\n\t\t\t{\n\t\t\t\tLog_Print(\"Entity %i, Brush %i: duplicate plane\\n\"\n\t\t\t\t\t, b->entitynum, b->brushnum);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( s2->planenum == (planenum^1) )\n\t\t\t{\n\t\t\t\tLog_Print(\"Entity %i, Brush %i: mirrored plane\\n\"\n\t\t\t\t\t, b->entitynum, b->brushnum);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (k != b->numsides)\n\t\t\tcontinue;\t\t// duplicated\n\n\t\t//\n\t\t// keep this side\n\t\t//\n\n\t\tside = b->original_sides + b->numsides;\n\t\tside->planenum = planenum;\n\t\tside->texinfo = TexinfoForBrushTexture (&mapplanes[planenum],\n\t\t\t&td, vec3_origin);\n\n\t\t// save the td off in case there is an origin brush and we\n\t\t// have to recalculate the texinfo\n\t\tside_brushtextures[nummapbrushsides] = td;\n\n\t\tnummapbrushsides++;\n\t\tb->numsides++;\n\t} while (1);\n\n\t// get the content for the entire brush\n\tb->contents = Q2_BrushContents (b);\n\n#ifdef ME\n\tif (BrushExists(b))\n\t{\n\t\tc_squattbrushes++;\n\t\tb->numsides = 0;\n\t\treturn;\n\t} //end if\n\n\tif (create_aas)\n\t{\n\t\t//create AAS brushes, and add brush bevels\n\t\tAAS_CreateMapBrushes(b, mapent, true);\n\t\t//NOTE: if we return here then duplicate plane errors occur for the non world entities\n\t\treturn;\n\t} //end if\n#endif //ME\n\n\t// allow detail brushes to be removed \n\tif (nodetail && (b->contents & CONTENTS_DETAIL) )\n\t{\n\t\tb->numsides = 0;\n\t\treturn;\n\t}\n\n\t// allow water brushes to be removed\n\tif (nowater && (b->contents & (CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_WATER)) )\n\t{\n\t\tb->numsides = 0;\n\t\treturn;\n\t}\n\n\t// create windings for sides and bounds for brush\n\tMakeBrushWindings (b);\n\n\t// brushes that will not be visible at all will never be\n\t// used as bsp splitters\n\tif (b->contents & (CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP) )\n\t{\n\t\tc_clipbrushes++;\n\t\tfor (i=0 ; i<b->numsides ; i++)\n\t\t\tb->original_sides[i].texinfo = TEXINFO_NODE;\n\t}\n\n\t//\n\t// origin brushes are removed, but they set\n\t// the rotation origin for the rest of the brushes\n\t// in the entity.  After the entire entity is parsed,\n\t// the planenums and texinfos will be adjusted for\n\t// the origin brush\n\t//\n\tif (b->contents & CONTENTS_ORIGIN)\n\t{\n\t\tchar\tstring[32];\n\t\tvec3_t\torigin;\n\n\t\tif (num_entities == 1)\n\t\t{\n\t\t\tError (\"Entity %i, Brush %i: origin brushes not allowed in world\"\n\t\t\t\t, b->entitynum, b->brushnum);\n\t\t\treturn;\n\t\t}\n\n\t\tVectorAdd (b->mins, b->maxs, origin);\n\t\tVectorScale (origin, 0.5, origin);\n\n\t\tsprintf (string, \"%i %i %i\", (int)origin[0], (int)origin[1], (int)origin[2]);\n\t\tSetKeyValue (&entities[b->entitynum], \"origin\", string);\n\n\t\tVectorCopy (origin, entities[b->entitynum].origin);\n\n\t\t// don't keep this brush\n\t\tb->numsides = 0;\n\n\t\treturn;\n\t}\n\n\tAddBrushBevels(b);\n\n\tnummapbrushes++;\n\tmapent->numbrushes++;\t\t\n}\n\n/*\n================\nQ2_MoveBrushesToWorld\n\nTakes all of the brushes from the current entity and\nadds them to the world's brush list.\n\nUsed by func_group and func_areaportal\n================\n*/\nvoid Q2_MoveBrushesToWorld (entity_t *mapent)\n{\n\tint\t\t\tnewbrushes;\n\tint\t\t\tworldbrushes;\n\tmapbrush_t\t*temp;\n\tint\t\t\ti;\n\n\t// this is pretty gross, because the brushes are expected to be\n\t// in linear order for each entity\n\n\tnewbrushes = mapent->numbrushes;\n\tworldbrushes = entities[0].numbrushes;\n\n\ttemp = GetMemory(newbrushes*sizeof(mapbrush_t));\n\tmemcpy (temp, mapbrushes + mapent->firstbrush, newbrushes*sizeof(mapbrush_t));\n\n#if\t0\t\t// let them keep their original brush numbers\n\tfor (i=0 ; i<newbrushes ; i++)\n\t\ttemp[i].entitynum = 0;\n#endif\n\n\t// make space to move the brushes (overlapped copy)\n\tmemmove (mapbrushes + worldbrushes + newbrushes,\n\t\tmapbrushes + worldbrushes,\n\t\tsizeof(mapbrush_t) * (nummapbrushes - worldbrushes - newbrushes) );\n\n\t// copy the new brushes down\n\tmemcpy (mapbrushes + worldbrushes, temp, sizeof(mapbrush_t) * newbrushes);\n\n\t// fix up indexes\n\tentities[0].numbrushes += newbrushes;\n\tfor (i=1 ; i<num_entities ; i++)\n\t\tentities[i].firstbrush += newbrushes;\n\tFreeMemory(temp);\n\n\tmapent->numbrushes = 0;\n}\n\n/*\n================\nQ2_ParseMapEntity\n================\n*/\nqboolean\tQ2_ParseMapEntity(script_t *script)\n{\n\tentity_t\t*mapent;\n\tepair_t *e;\n\tside_t *s;\n\tint i, j;\n\tint startbrush, startsides;\n\tvec_t newdist;\n\tmapbrush_t *b;\n\ttoken_t token;\n\n\tif (!PS_ReadToken(script, &token)) return false;\n\n\tif (strcmp(token.string, \"{\") )\n\t\tError (\"ParseEntity: { not found\");\n\t\n\tif (num_entities == MAX_MAP_ENTITIES)\n\t\tError (\"num_entities == MAX_MAP_ENTITIES\");\n\n\tstartbrush = nummapbrushes;\n\tstartsides = nummapbrushsides;\n\n\tmapent = &entities[num_entities];\n\tnum_entities++;\n\tmemset (mapent, 0, sizeof(*mapent));\n\tmapent->firstbrush = nummapbrushes;\n\tmapent->numbrushes = 0;\n//\tmapent->portalareas[0] = -1;\n//\tmapent->portalareas[1] = -1;\n\n\tdo\n\t{\n\t\tif (!PS_ReadToken(script, &token))\n\t\t{\n\t\t\tError(\"ParseEntity: EOF without closing brace\");\n\t\t} //end if\n\t\tif (!strcmp(token.string, \"}\")) break;\n\t\tif (!strcmp(token.string, \"{\"))\n\t\t{\n\t\t\tQ2_ParseBrush(script, mapent);\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tPS_UnreadLastToken(script);\n\t\t\te = ParseEpair(script);\n\t\t\te->next = mapent->epairs;\n\t\t\tmapent->epairs = e;\n\t\t} //end else\n\t} while(1);\n\n\tGetVectorForKey(mapent, \"origin\", mapent->origin);\n\n\t//\n\t// if there was an origin brush, offset all of the planes and texinfo\n\t//\n\tif (mapent->origin[0] || mapent->origin[1] || mapent->origin[2])\n\t{\n\t\tfor (i=0 ; i<mapent->numbrushes ; i++)\n\t\t{\n\t\t\tb = &mapbrushes[mapent->firstbrush + i];\n\t\t\tfor (j=0 ; j<b->numsides ; j++)\n\t\t\t{\n\t\t\t\ts = &b->original_sides[j];\n\t\t\t\tnewdist = mapplanes[s->planenum].dist -\n\t\t\t\t\tDotProduct (mapplanes[s->planenum].normal, mapent->origin);\n\t\t\t\ts->planenum = FindFloatPlane (mapplanes[s->planenum].normal, newdist);\n\t\t\t\ts->texinfo = TexinfoForBrushTexture (&mapplanes[s->planenum],\n\t\t\t\t\t&side_brushtextures[s-brushsides], mapent->origin);\n\t\t\t}\n\t\t\tMakeBrushWindings (b);\n\t\t}\n\t}\n\n\t// group entities are just for editor convenience\n\t// toss all brushes into the world entity\n\tif (!strcmp (\"func_group\", ValueForKey (mapent, \"classname\")))\n\t{\n\t\tQ2_MoveBrushesToWorld (mapent);\n\t\tmapent->numbrushes = 0;\n\t\treturn true;\n\t}\n\n\t// areaportal entities move their brushes, but don't eliminate\n\t// the entity\n\tif (!strcmp (\"func_areaportal\", ValueForKey (mapent, \"classname\")))\n\t{\n\t\tchar\tstr[128];\n\n\t\tif (mapent->numbrushes != 1)\n\t\t\tError (\"Entity %i: func_areaportal can only be a single brush\", num_entities-1);\n\n\t\tb = &mapbrushes[nummapbrushes-1];\n\t\tb->contents = CONTENTS_AREAPORTAL;\n\t\tc_areaportals++;\n\t\tmapent->areaportalnum = c_areaportals;\n\t\t// set the portal number as \"style\"\n\t\tsprintf (str, \"%i\", c_areaportals);\n\t\tSetKeyValue (mapent, \"style\", str);\n\t\tQ2_MoveBrushesToWorld (mapent);\n\t\treturn true;\n\t}\n\n\treturn true;\n}\n\n//===================================================================\n\n/*\n================\nLoadMapFile\n================\n*/\nvoid Q2_LoadMapFile(char *filename)\n{\t\t\n\tint i;\n\tscript_t *script;\n\n\tLog_Print(\"-- Q2_LoadMapFile --\\n\");\n#ifdef ME\n\t//loaded map type\n\tloadedmaptype = MAPTYPE_QUAKE2;\n\t//reset the map loading\n\tResetMapLoading();\n#endif //ME\n\n\tscript = LoadScriptFile(filename);\n\tif (!script)\n\t{\n\t\tLog_Print(\"couldn't open %s\\n\", filename);\n\t\treturn;\n\t} //end if\n\t//white spaces and escape characters inside a string are not allowed\n\tSetScriptFlags(script, SCFL_NOSTRINGWHITESPACES |\n\t\t\t\t\t\t\t\t\tSCFL_NOSTRINGESCAPECHARS |\n\t\t\t\t\t\t\t\t\tSCFL_PRIMITIVE);\n\n\tnummapbrushsides = 0;\n\tnum_entities = 0;\n\t\n\twhile (Q2_ParseMapEntity(script))\n\t{\n\t}\n\n\tClearBounds (map_mins, map_maxs);\n\tfor (i=0 ; i<entities[0].numbrushes ; i++)\n\t{\n\t\tif (mapbrushes[i].mins[0] > 4096)\n\t\t\tcontinue;\t// no valid points\n\t\tAddPointToBounds (mapbrushes[i].mins, map_mins, map_maxs);\n\t\tAddPointToBounds (mapbrushes[i].maxs, map_mins, map_maxs);\n\t} //end for\n\n\tPrintMapInfo();\n\n\t//free the script\n\tFreeScript(script);\n//\tTestExpandBrushes ();\n\t//\n\tQ2_CreateMapTexinfo();\n} //end of the function Q2_LoadMapFile\n\n#ifdef ME\t\t//Begin MAP loading from BSP file\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Q2_SetLeafBrushesModelNumbers(int leafnum, int modelnum)\n{\n\tint i, brushnum;\n\tdleaf_t *leaf;\n\n\tleaf = &dleafs[leafnum];\n\tfor (i = 0; i < leaf->numleafbrushes; i++)\n\t{\n\t\tbrushnum = dleafbrushes[leaf->firstleafbrush + i];\n\t\tbrushmodelnumbers[brushnum] = modelnum;\n\t\tdbrushleafnums[brushnum] = leafnum;\n\t} //end for\n} //end of the function Q2_SetLeafBrushesModelNumbers\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Q2_InitNodeStack(void)\n{\n\tnodestackptr = nodestack;\n\tnodestacksize = 0;\n} //end of the function Q2_InitNodeStack\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Q2_PushNodeStack(int num)\n{\n\t*nodestackptr = num;\n\tnodestackptr++;\n\tnodestacksize++;\n\t//\n\tif (nodestackptr >= &nodestack[NODESTACKSIZE])\n\t{\n\t\tError(\"Q2_PushNodeStack: stack overflow\\n\");\n\t} //end if\n} //end of the function Q2_PushNodeStack\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint Q2_PopNodeStack(void)\n{\n\t//if the stack is empty\n\tif (nodestackptr <= nodestack) return -1;\n\t//decrease stack pointer\n\tnodestackptr--;\n\tnodestacksize--;\n\t//return the top value from the stack\n\treturn *nodestackptr;\n} //end of the function Q2_PopNodeStack\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Q2_SetBrushModelNumbers(entity_t *mapent)\n{\n\tint n, pn;\n\tint leafnum;\n\n\t//\n\tQ2_InitNodeStack();\n\t//head node (root) of the bsp tree\n\tn = dmodels[mapent->modelnum].headnode;\n\tpn = 0;\n\t\n\tdo\n\t{\n\t\t//if we are in a leaf (negative node number)\n\t\tif (n < 0)\n\t\t{\n\t\t\t//number of the leaf\n\t\t\tleafnum = (-n) - 1;\n\t\t\t//set the brush numbers\n\t\t\tQ2_SetLeafBrushesModelNumbers(leafnum, mapent->modelnum);\n\t\t\t//walk back into the tree to find a second child to continue with\n\t\t\tfor (pn = Q2_PopNodeStack(); pn >= 0; n = pn, pn = Q2_PopNodeStack())\n\t\t\t{\n\t\t\t\t//if we took the first child at the parent node\n\t\t\t\tif (dnodes[pn].children[0] == n) break;\n\t\t\t} //end for\n\t\t\t//if the stack wasn't empty (if not processed whole tree)\n\t\t\tif (pn >= 0)\n\t\t\t{\n\t\t\t\t//push the parent node again\n\t\t\t\tQ2_PushNodeStack(pn);\n\t\t\t\t//we proceed with the second child of the parent node\n\t\t\t\tn = dnodes[pn].children[1];\n\t\t\t} //end if\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\t//push the current node onto the stack\n\t\t\tQ2_PushNodeStack(n);\n\t\t\t//walk forward into the tree to the first child\n\t\t\tn = dnodes[n].children[0];\n\t\t} //end else\n\t} while(pn >= 0);\n} //end of the function Q2_SetBrushModelNumbers\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Q2_BSPBrushToMapBrush(dbrush_t *bspbrush, entity_t *mapent)\n{\n\tmapbrush_t *b;\n\tint i, k, n;\n\tside_t *side, *s2;\n\tint planenum;\n\tdbrushside_t *bspbrushside;\n\tdplane_t *bspplane;\n\n\tif (nummapbrushes >= MAX_MAPFILE_BRUSHES)\n\t\tError (\"nummapbrushes >= MAX_MAPFILE_BRUSHES\");\n\n\tb = &mapbrushes[nummapbrushes];\n\tb->original_sides = &brushsides[nummapbrushsides];\n\tb->entitynum = mapent-entities;\n\tb->brushnum = nummapbrushes - mapent->firstbrush;\n\tb->leafnum = dbrushleafnums[bspbrush - dbrushes];\n\n\tfor (n = 0; n < bspbrush->numsides; n++)\n\t{\n\t\t//pointer to the bsp brush side\n\t\tbspbrushside = &dbrushsides[bspbrush->firstside + n];\n\n\t\tif (nummapbrushsides >= MAX_MAPFILE_BRUSHSIDES)\n\t\t{\n\t\t\tError (\"MAX_MAPFILE_BRUSHSIDES\");\n\t\t} //end if\n\t\t//pointer to the map brush side\n\t\tside = &brushsides[nummapbrushsides];\n\t\t//if the BSP brush side is textured\n\t\tif (brushsidetextured[bspbrush->firstside + n]) side->flags |= SFL_TEXTURED;\n\t\telse side->flags &= ~SFL_TEXTURED;\n\t\t//ME: can get side contents and surf directly from BSP file\n\t\tside->contents = bspbrush->contents;\n\t\t//if the texinfo is TEXINFO_NODE\n\t\tif (bspbrushside->texinfo < 0) side->surf = 0;\n\t\telse side->surf = texinfo[bspbrushside->texinfo].flags;\n\n\t\t// translucent objects are automatically classified as detail\n\t\tif (side->surf & (SURF_TRANS33|SURF_TRANS66) )\n\t\t\tside->contents |= CONTENTS_DETAIL;\n\t\tif (side->contents & (CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP) )\n\t\t\tside->contents |= CONTENTS_DETAIL;\n\t\tif (fulldetail)\n\t\t\tside->contents &= ~CONTENTS_DETAIL;\n\t\tif (!(side->contents & ((LAST_VISIBLE_CONTENTS-1) \n\t\t\t| CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP|CONTENTS_MIST)  ) )\n\t\t\tside->contents |= CONTENTS_SOLID;\n\n\t\t// hints and skips are never detail, and have no content\n\t\tif (side->surf & (SURF_HINT|SURF_SKIP) )\n\t\t{\n\t\t\tside->contents = 0;\n\t\t\tside->surf &= ~CONTENTS_DETAIL;\n\t\t}\n\n\t\t//ME: get a plane for this side\n\t\tbspplane = &dplanes[bspbrushside->planenum];\n\t\tplanenum = FindFloatPlane(bspplane->normal, bspplane->dist);\n\t\t//\n\t\t// see if the plane has been used already\n\t\t//\n\t\t//ME: this really shouldn't happen!!!\n\t\t//ME: otherwise the bsp file is corrupted??\n\t\t//ME: still it seems to happen, maybe Johny Boy's\n\t\t//ME: brush bevel adding is crappy ?\n\t\tfor (k = 0; k < b->numsides; k++)\n\t\t{\n\t\t\ts2 = b->original_sides + k;\n//\t\t\tif (DotProduct (mapplanes[s2->planenum].normal, mapplanes[planenum].normal) > 0.999\n//\t\t\t\t\t\t\t&& fabs(mapplanes[s2->planenum].dist - mapplanes[planenum].dist) < 0.01 )\n\n\t\t\tif (s2->planenum == planenum)\n\t\t\t{\n\t\t\t\tLog_Print(\"Entity %i, Brush %i: duplicate plane\\n\"\n\t\t\t\t\t, b->entitynum, b->brushnum);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( s2->planenum == (planenum^1) )\n\t\t\t{\n\t\t\t\tLog_Print(\"Entity %i, Brush %i: mirrored plane\\n\"\n\t\t\t\t\t, b->entitynum, b->brushnum);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (k != b->numsides)\n\t\t\tcontinue;\t\t// duplicated\n\n\t\t//\n\t\t// keep this side\n\t\t//\n\t\t//ME: reset pointer to side, why? hell I dunno (pointer is set above already)\n\t\tside = b->original_sides + b->numsides;\n\t\t//ME: store the plane number\n\t\tside->planenum = planenum;\n\t\t//ME: texinfo is already stored when bsp is loaded\n\t\t//NOTE: check for TEXINFO_NODE, otherwise crash in Q2_BrushContents\n\t\tif (bspbrushside->texinfo < 0) side->texinfo = 0;\n\t\telse side->texinfo = bspbrushside->texinfo;\n\n\t\t// save the td off in case there is an origin brush and we\n\t\t// have to recalculate the texinfo\n\t\t// ME: don't need to recalculate because it's already done\n\t\t//     (for non-world entities) in the BSP file\n//\t\tside_brushtextures[nummapbrushsides] = td;\n\n\t\tnummapbrushsides++;\n\t\tb->numsides++;\n\t} //end for\n\n\t// get the content for the entire brush\n\tb->contents = bspbrush->contents;\n\tQ2_BrushContents(b);\n\n\tif (BrushExists(b))\n\t{\n\t\tc_squattbrushes++;\n\t\tb->numsides = 0;\n\t\treturn;\n\t} //end if\n\n\t//if we're creating AAS\n\tif (create_aas)\n\t{\n\t\t//create the AAS brushes from this brush, don't add brush bevels\n\t\tAAS_CreateMapBrushes(b, mapent, false);\n\t\treturn;\n\t} //end if\n\n\t// allow detail brushes to be removed \n\tif (nodetail && (b->contents & CONTENTS_DETAIL) )\n\t{\n\t\tb->numsides = 0;\n\t\treturn;\n\t} //end if\n\n\t// allow water brushes to be removed\n\tif (nowater && (b->contents & (CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_WATER)) )\n\t{\n\t\tb->numsides = 0;\n\t\treturn;\n\t} //end if\n\n\t// create windings for sides and bounds for brush\n\tMakeBrushWindings(b);\n\n\t//mark brushes without winding or with a tiny window as bevels\n\tMarkBrushBevels(b);\n\n\t// brushes that will not be visible at all will never be\n\t// used as bsp splitters\n\tif (b->contents & (CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP) )\n\t{\n\t\t\tc_clipbrushes++;\n\t\tfor (i = 0; i < b->numsides; i++)\n\t\t\tb->original_sides[i].texinfo = TEXINFO_NODE;\n\t} //end for\n\n\t//\n\t// origin brushes are removed, but they set\n\t// the rotation origin for the rest of the brushes\n\t// in the entity.  After the entire entity is parsed,\n\t// the planenums and texinfos will be adjusted for\n\t// the origin brush\n\t//\n\t//ME: not needed because the entities in the BSP file already\n\t//    have an origin set\n//\tif (b->contents & CONTENTS_ORIGIN)\n//\t{\n//\t\tchar\tstring[32];\n//\t\tvec3_t\torigin;\n//\n//\t\tif (num_entities == 1)\n//\t\t{\n//\t\t\tError (\"Entity %i, Brush %i: origin brushes not allowed in world\"\n//\t\t\t\t, b->entitynum, b->brushnum);\n//\t\t\treturn;\n//\t\t}\n//\n//\t\tVectorAdd (b->mins, b->maxs, origin);\n//\t\tVectorScale (origin, 0.5, origin);\n//\n//\t\tsprintf (string, \"%i %i %i\", (int)origin[0], (int)origin[1], (int)origin[2]);\n//\t\tSetKeyValue (&entities[b->entitynum], \"origin\", string);\n//\n//\t\tVectorCopy (origin, entities[b->entitynum].origin);\n//\n//\t\t// don't keep this brush\n//\t\tb->numsides = 0;\n//\n//\t\treturn;\n//\t}\n\n\t//ME: the bsp brushes already have bevels, so we won't try to\n\t//    add them again (especially since Johny Boy's bevel adding might\n\t//    be crappy)\n//\tAddBrushBevels(b);\n\n\tnummapbrushes++;\n\tmapent->numbrushes++;\n} //end of the function Q2_BSPBrushToMapBrush\n//===========================================================================\n//===========================================================================\nvoid Q2_ParseBSPBrushes(entity_t *mapent)\n{\n\tint i;\n\n\t//give all the brushes that belong to this entity the number of the\n\t//BSP model used by this entity\n\tQ2_SetBrushModelNumbers(mapent);\n\t//now parse all the brushes with the correct mapent->modelnum\n\tfor (i = 0; i < numbrushes; i++)\n\t{\n\t\tif (brushmodelnumbers[i] == mapent->modelnum)\n\t\t{\n\t\t\tQ2_BSPBrushToMapBrush(&dbrushes[i], mapent);\n\t\t} //end if\n\t} //end for\n} //end of the function Q2_ParseBSPBrushes\n//===========================================================================\n//===========================================================================\nqboolean Q2_ParseBSPEntity(int entnum)\n{\n\tentity_t\t*mapent;\n\tchar *model;\n\tint startbrush, startsides;\n\n\tstartbrush = nummapbrushes;\n\tstartsides = nummapbrushsides;\n\n\tmapent = &entities[entnum];//num_entities];\n\tmapent->firstbrush = nummapbrushes;\n\tmapent->numbrushes = 0;\n\tmapent->modelnum = -1;\t//-1 = no model\n\n\tmodel = ValueForKey(mapent, \"model\");\n\tif (model && strlen(model))\n\t{\n\t\tif (*model != '*')\n\t\t{\n\t\t\tError(\"Q2_ParseBSPEntity: model number without leading *\");\n\t\t} //end if\n\t\t//get the model number of this entity (skip the leading *)\n\t\tmapent->modelnum = atoi(&model[1]);\n\t} //end if\n\n\tGetVectorForKey(mapent, \"origin\", mapent->origin);\n\n\t//if this is the world entity it has model number zero\n\t//the world entity has no model key\n\tif (!strcmp(\"worldspawn\", ValueForKey(mapent, \"classname\")))\n\t{\n\t\tmapent->modelnum = 0;\n\t} //end if\n\t//if the map entity has a BSP model (a modelnum of -1 is used for\n\t//entities that aren't using a BSP model)\n\tif (mapent->modelnum >= 0)\n\t{\n\t\t//parse the bsp brushes\n\t\tQ2_ParseBSPBrushes(mapent);\n\t} //end if\n\t//\n\t//the origin of the entity is already taken into account\n\t//\n\t//func_group entities can't be in the bsp file\n\t//\n\t//check out the func_areaportal entities\n\tif (!strcmp (\"func_areaportal\", ValueForKey (mapent, \"classname\")))\n\t{\n\t\tc_areaportals++;\n\t\tmapent->areaportalnum = c_areaportals;\n\t\treturn true;\n\t} //end if\n\treturn true;\n} //end of the function Q2_ParseBSPEntity\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Q2_LoadMapFromBSP(char *filename, int offset, int length)\n{\n\tint i;\n\n\tLog_Print(\"-- Q2_LoadMapFromBSP --\\n\");\n\t//loaded map type\n\tloadedmaptype = MAPTYPE_QUAKE2;\n\n\tLog_Print(\"Loading map from %s...\\n\", filename);\n\t//load the bsp file\n\tQ2_LoadBSPFile(filename, offset, length);\n\n\t//create an index from bsp planes to map planes\n\t//DPlanes2MapPlanes();\n\t//clear brush model numbers\n\tfor (i = 0; i < MAX_MAPFILE_BRUSHES; i++)\n\t\tbrushmodelnumbers[i] = -1;\n\n\tnummapbrushsides = 0;\n\tnum_entities = 0;\n\n\tQ2_ParseEntities();\n\t//\n\tfor (i = 0; i < num_entities; i++)\n\t{\n\t\tQ2_ParseBSPEntity(i);\n\t} //end for\n\n\t//get the map mins and maxs from the world model\n\tClearBounds(map_mins, map_maxs);\n\tfor (i = 0; i < entities[0].numbrushes; i++)\n\t{\n\t\tif (mapbrushes[i].mins[0] > 4096)\n\t\t\tcontinue;\t//no valid points\n\t\tAddPointToBounds (mapbrushes[i].mins, map_mins, map_maxs);\n\t\tAddPointToBounds (mapbrushes[i].maxs, map_mins, map_maxs);\n\t} //end for\n\n\tPrintMapInfo();\n\t//\n\tQ2_CreateMapTexinfo();\n} //end of the function Q2_LoadMapFromBSP\n\nvoid Q2_ResetMapLoading(void)\n{\n\t//reset for map loading from bsp\n\tmemset(nodestack, 0, NODESTACKSIZE * sizeof(int));\n\tnodestackptr = NULL;\n\tnodestacksize = 0;\n\tmemset(brushmodelnumbers, 0, MAX_MAPFILE_BRUSHES * sizeof(int));\n} //end of the function Q2_ResetMapLoading\n\n//End MAP loading from BSP file\n#endif //ME\n\n//====================================================================\n\n/*\n================\nTestExpandBrushes\n\nExpands all the brush planes and saves a new map out\n================\n*/\nvoid TestExpandBrushes (void)\n{\n\tFILE\t*f;\n\tside_t\t*s;\n\tint\t\ti, j, bn;\n\twinding_t\t*w;\n\tchar\t*name = \"expanded.map\";\n\tmapbrush_t\t*brush;\n\tvec_t\tdist;\n\n\tLog_Print(\"writing %s\\n\", name);\n\tf = fopen (name, \"wb\");\n\tif (!f)\n\t\tError (\"Can't write %s\\n\", name);\n\n\tfprintf (f, \"{\\n\\\"classname\\\" \\\"worldspawn\\\"\\n\");\n\n\tfor (bn=0 ; bn<nummapbrushes ; bn++)\n\t{\n\t\tbrush = &mapbrushes[bn];\n\t\tfprintf (f, \"{\\n\");\n\t\tfor (i=0 ; i<brush->numsides ; i++)\n\t\t{\n\t\t\ts = brush->original_sides + i;\n\t\t\tdist = mapplanes[s->planenum].dist;\n\t\t\tfor (j=0 ; j<3 ; j++)\n\t\t\t\tdist += fabs( 16 * mapplanes[s->planenum].normal[j] );\n\n\t\t\tw = BaseWindingForPlane (mapplanes[s->planenum].normal, dist);\n\n\t\t\tfprintf (f,\"( %i %i %i ) \", (int)w->p[0][0], (int)w->p[0][1], (int)w->p[0][2]);\n\t\t\tfprintf (f,\"( %i %i %i ) \", (int)w->p[1][0], (int)w->p[1][1], (int)w->p[1][2]);\n\t\t\tfprintf (f,\"( %i %i %i ) \", (int)w->p[2][0], (int)w->p[2][1], (int)w->p[2][2]);\n\n\t\t\tfprintf (f, \"%s 0 0 0 1 1\\n\", texinfo[s->texinfo].texture);\n\t\t\tFreeWinding (w);\n\t\t}\n\t\tfprintf (f, \"}\\n\");\n\t}\n\tfprintf (f, \"}\\n\");\n\n\tfclose (f);\n\n\tError (\"can't proceed after expanding brushes\");\n} //end of the function TestExpandBrushes\n\n"
  },
  {
    "path": "code/bspc/map_q3.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n#include \"l_mem.h\"\n#include \"../botlib/aasfile.h\"\t//aas_bbox_t\n#include \"aas_store.h\"\t\t\t//AAS_MAX_BBOXES\n#include \"aas_cfg.h\"\n#include \"aas_map.h\"\t\t\t//AAS_CreateMapBrushes\n#include \"l_bsp_q3.h\"\n#include \"../qcommon/cm_patch.h\"\n#include \"../game/surfaceflags.h\"\n\n#define NODESTACKSIZE\t\t1024\n\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid PrintContents(int contents);\n\nint\tQ3_BrushContents(mapbrush_t *b)\n{\n\tint contents, i, mixed, hint;\n\tside_t *s;\n\n\ts = &b->original_sides[0];\n\tcontents = s->contents;\n\t//\n\tmixed = false;\n\thint = false;\n\tfor (i = 1; i < b->numsides; i++)\n\t{\n\t\ts = &b->original_sides[i];\n\t\tif (s->contents != contents) mixed = true;\n\t\tif (s->surf & (SURF_HINT|SURF_SKIP)) hint = true;\n\t\tcontents |= s->contents;\n\t} //end for\n\t//\n\tif (hint)\n\t{\n\t\tif (contents)\n\t\t{\n\t\t\tLog_Write(\"WARNING: hint brush with contents: \");\n\t\t\tPrintContents(contents);\n\t\t\tLog_Write(\"\\r\\n\");\n\t\t\t//\n\t\t\tLog_Write(\"brush contents is: \");\n\t\t\tPrintContents(b->contents);\n\t\t\tLog_Write(\"\\r\\n\");\n\t\t} //end if\n\t\treturn 0;\n\t} //end if\n\t//Log_Write(\"brush %d contents \", nummapbrushes);\n\t//PrintContents(contents);\n\t//Log_Write(\"\\r\\n\");\n\t//remove ladder and fog contents\n\tcontents &= ~(CONTENTS_LADDER|CONTENTS_FOG);\n\t//\n\tif (mixed)\n\t{\n\t\tLog_Write(\"Entity %i, Brush %i: mixed face contents \"\n\t\t\t, b->entitynum, b->brushnum);\n\t\tPrintContents(contents);\n\t\tLog_Write(\"\\r\\n\");\n\t\t//\n\t\tLog_Write(\"brush contents is: \");\n\t\tPrintContents(b->contents);\n\t\tLog_Write(\"\\r\\n\");\n\t\t//\n\t\tif (contents & CONTENTS_DONOTENTER) return CONTENTS_DONOTENTER;//Log_Print(\"mixed contents with donotenter\\n\");\n\t\t/*\n\t\tLog_Print(\"contents:\"); PrintContents(contents);\n\t\tLog_Print(\"\\ncontents:\"); PrintContents(s->contents);\n\t\tLog_Print(\"\\n\");\n\t\tLog_Print(\"texture name = %s\\n\", texinfo[s->texinfo].texture);\n\t\t*/\n\t\t//if liquid brush\n\t\tif (contents & (CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_WATER))\n\t\t{\n\t\t\treturn (contents & (CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_WATER));\n\t\t} //end if\n\t\tif (contents & CONTENTS_PLAYERCLIP) return (contents & CONTENTS_PLAYERCLIP);\n\t\treturn (contents & CONTENTS_SOLID);\n\t} //end if\n\t/*\n\tif (contents & CONTENTS_AREAPORTAL)\n\t{\n\t\tstatic int num;\n\t\tLog_Write(\"Entity %i, Brush %i: area portal %d\\r\\n\", b->entitynum, b->brushnum, num++);\n\t} //end if*/\n\tif (contents == (contents & CONTENTS_STRUCTURAL))\n\t{\n\t\t//Log_Print(\"brush %i is only structural\\n\", b->brushnum);\n\t\tcontents = 0;\n\t} //end if\n\tif (contents & CONTENTS_DONOTENTER)\n\t{\n\t\tLog_Print(\"brush %i is a donotenter brush, c = %X\\n\", b->brushnum, contents);\n\t} //end if\n\treturn contents;\n} //end of the function Q3_BrushContents\n#define BBOX_NORMAL_EPSILON\t\t\t0.0001\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Q3_DPlanes2MapPlanes(void)\n{\n\tint i;\n\n\tfor (i = 0; i < q3_numplanes; i++)\n\t{\n\t\tdplanes2mapplanes[i] = FindFloatPlane(q3_dplanes[i].normal, q3_dplanes[i].dist);\n\t} //end for\n} //end of the function Q3_DPlanes2MapPlanes\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Q3_BSPBrushToMapBrush(q3_dbrush_t *bspbrush, entity_t *mapent)\n{\n\tmapbrush_t *b;\n\tint i, k, n;\n\tside_t *side, *s2;\n\tint planenum;\n\tq3_dbrushside_t *bspbrushside;\n\tq3_dplane_t *bspplane;\n\n\tif (nummapbrushes >= MAX_MAPFILE_BRUSHES)\n\t\tError (\"nummapbrushes >= MAX_MAPFILE_BRUSHES\");\n\n\tb = &mapbrushes[nummapbrushes];\n\tb->original_sides = &brushsides[nummapbrushsides];\n\tb->entitynum = mapent-entities;\n\tb->brushnum = nummapbrushes - mapent->firstbrush;\n\tb->leafnum = dbrushleafnums[bspbrush - q3_dbrushes];\n\n\tfor (n = 0; n < bspbrush->numSides; n++)\n\t{\n\t\t//pointer to the bsp brush side\n\t\tbspbrushside = &q3_dbrushsides[bspbrush->firstSide + n];\n\n\t\tif (nummapbrushsides >= MAX_MAPFILE_BRUSHSIDES)\n\t\t{\n\t\t\tError (\"MAX_MAPFILE_BRUSHSIDES\");\n\t\t} //end if\n\t\t//pointer to the map brush side\n\t\tside = &brushsides[nummapbrushsides];\n\t\t//if the BSP brush side is textured\n\t\tif (q3_dbrushsidetextured[bspbrush->firstSide + n]) side->flags |= SFL_TEXTURED|SFL_VISIBLE;\n\t\telse side->flags &= ~SFL_TEXTURED;\n\t\t//NOTE: all Quake3 sides are assumed textured\n\t\t//side->flags |= SFL_TEXTURED|SFL_VISIBLE;\n\t\t//\n\t\tif (bspbrushside->shaderNum < 0)\n\t\t{\n\t\t\tside->contents = 0;\n\t\t\tside->surf = 0;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tside->contents = q3_dshaders[bspbrushside->shaderNum].contentFlags;\n\t\t\tside->surf = q3_dshaders[bspbrushside->shaderNum].surfaceFlags;\n\t\t\tif (strstr(q3_dshaders[bspbrushside->shaderNum].shader, \"common/hint\"))\n\t\t\t{\n\t\t\t\t//Log_Print(\"found hint side\\n\");\n\t\t\t\tside->surf |= SURF_HINT;\n\t\t\t} //end if\n\t\t} //end else\n\t\t//\n\t\tif (side->surf & SURF_NODRAW)\n\t\t{\n\t\t\tside->flags |= SFL_TEXTURED|SFL_VISIBLE;\n\t\t} //end if\n\t\t/*\n\t\tif (side->contents & (CONTENTS_TRANSLUCENT|CONTENTS_STRUCTURAL))\n\t\t{\n\t\t\tside->flags |= SFL_TEXTURED|SFL_VISIBLE;\n\t\t} //end if*/\n\n\t\t// hints and skips are never detail, and have no content\n\t\tif (side->surf & (SURF_HINT|SURF_SKIP) )\n\t\t{\n\t\t\tside->contents = 0;\n\t\t\t//Log_Print(\"found hint brush side\\n\");\n\t\t}\n\t\t/*\n\t\tif ((side->surf & SURF_NODRAW) && (side->surf & SURF_NOIMPACT))\n\t\t{\n\t\t\tside->contents = 0;\n\t\t\tside->surf &= ~CONTENTS_DETAIL;\n\t\t\tLog_Print(\"probably found hint brush in a BSP without hints being used\\n\");\n\t\t} //end if*/\n\n\t\t//ME: get a plane for this side\n\t\tbspplane = &q3_dplanes[bspbrushside->planeNum];\n\t\tplanenum = FindFloatPlane(bspplane->normal, bspplane->dist);\n\t\t//\n\t\t// see if the plane has been used already\n\t\t//\n\t\t//ME: this really shouldn't happen!!!\n\t\t//ME: otherwise the bsp file is corrupted??\n\t\t//ME: still it seems to happen, maybe Johny Boy's\n\t\t//ME: brush bevel adding is crappy ?\n\t\tfor (k = 0; k < b->numsides; k++)\n\t\t{\n\t\t\ts2 = b->original_sides + k;\n//\t\t\tif (DotProduct (mapplanes[s2->planenum].normal, mapplanes[planenum].normal) > 0.999\n//\t\t\t\t\t\t\t&& fabs(mapplanes[s2->planenum].dist - mapplanes[planenum].dist) < 0.01 )\n\n\t\t\tif (s2->planenum == planenum)\n\t\t\t{\n\t\t\t\tLog_Print(\"Entity %i, Brush %i: duplicate plane\\n\"\n\t\t\t\t\t, b->entitynum, b->brushnum);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( s2->planenum == (planenum^1) )\n\t\t\t{\n\t\t\t\tLog_Print(\"Entity %i, Brush %i: mirrored plane\\n\"\n\t\t\t\t\t, b->entitynum, b->brushnum);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (k != b->numsides)\n\t\t\tcontinue;\t\t// duplicated\n\n\t\t//\n\t\t// keep this side\n\t\t//\n\t\t//ME: reset pointer to side, why? hell I dunno (pointer is set above already)\n\t\tside = b->original_sides + b->numsides;\n\t\t//ME: store the plane number\n\t\tside->planenum = planenum;\n\t\t//ME: texinfo is already stored when bsp is loaded\n\t\t//NOTE: check for TEXINFO_NODE, otherwise crash in Q3_BrushContents\n\t\t//if (bspbrushside->texinfo < 0) side->texinfo = 0;\n\t\t//else side->texinfo = bspbrushside->texinfo;\n\n\t\t// save the td off in case there is an origin brush and we\n\t\t// have to recalculate the texinfo\n\t\t// ME: don't need to recalculate because it's already done\n\t\t//     (for non-world entities) in the BSP file\n//\t\tside_brushtextures[nummapbrushsides] = td;\n\n\t\tnummapbrushsides++;\n\t\tb->numsides++;\n\t} //end for\n\n\t// get the content for the entire brush\n\tb->contents = q3_dshaders[bspbrush->shaderNum].contentFlags;\n\tb->contents &= ~(CONTENTS_LADDER|CONTENTS_FOG|CONTENTS_STRUCTURAL);\n//\tb->contents = Q3_BrushContents(b);\n\t//\n\n\tif (BrushExists(b))\n\t{\n\t\tc_squattbrushes++;\n\t\tb->numsides = 0;\n\t\treturn;\n\t} //end if\n\n\t//if we're creating AAS\n\tif (create_aas)\n\t{\n\t\t//create the AAS brushes from this brush, don't add brush bevels\n\t\tAAS_CreateMapBrushes(b, mapent, false);\n\t\treturn;\n\t} //end if\n\n\t// allow detail brushes to be removed \n\tif (nodetail && (b->contents & CONTENTS_DETAIL) )\n\t{\n\t\tb->numsides = 0;\n\t\treturn;\n\t} //end if\n\n\t// allow water brushes to be removed\n\tif (nowater && (b->contents & (CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_WATER)) )\n\t{\n\t\tb->numsides = 0;\n\t\treturn;\n\t} //end if\n\n\t// create windings for sides and bounds for brush\n\tMakeBrushWindings(b);\n\n\t//mark brushes without winding or with a tiny window as bevels\n\tMarkBrushBevels(b);\n\n\t// brushes that will not be visible at all will never be\n\t// used as bsp splitters\n\tif (b->contents & (CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP) )\n\t{\n\t\t\tc_clipbrushes++;\n\t\tfor (i = 0; i < b->numsides; i++)\n\t\t\tb->original_sides[i].texinfo = TEXINFO_NODE;\n\t} //end for\n\n\t//\n\t// origin brushes are removed, but they set\n\t// the rotation origin for the rest of the brushes\n\t// in the entity.  After the entire entity is parsed,\n\t// the planenums and texinfos will be adjusted for\n\t// the origin brush\n\t//\n\t//ME: not needed because the entities in the BSP file already\n\t//    have an origin set\n//\tif (b->contents & CONTENTS_ORIGIN)\n//\t{\n//\t\tchar\tstring[32];\n//\t\tvec3_t\torigin;\n//\n//\t\tif (num_entities == 1)\n//\t\t{\n//\t\t\tError (\"Entity %i, Brush %i: origin brushes not allowed in world\"\n//\t\t\t\t, b->entitynum, b->brushnum);\n//\t\t\treturn;\n//\t\t}\n//\n//\t\tVectorAdd (b->mins, b->maxs, origin);\n//\t\tVectorScale (origin, 0.5, origin);\n//\n//\t\tsprintf (string, \"%i %i %i\", (int)origin[0], (int)origin[1], (int)origin[2]);\n//\t\tSetKeyValue (&entities[b->entitynum], \"origin\", string);\n//\n//\t\tVectorCopy (origin, entities[b->entitynum].origin);\n//\n//\t\t// don't keep this brush\n//\t\tb->numsides = 0;\n//\n//\t\treturn;\n//\t}\n\n\t//ME: the bsp brushes already have bevels, so we won't try to\n\t//    add them again (especially since Johny Boy's bevel adding might\n\t//    be crappy)\n//\tAddBrushBevels(b);\n\n\tnummapbrushes++;\n\tmapent->numbrushes++;\n} //end of the function Q3_BSPBrushToMapBrush\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Q3_ParseBSPBrushes(entity_t *mapent)\n{\n\tint i;\n\n\tfor (i = 0; i < q3_dmodels[mapent->modelnum].numBrushes; i++)\n\t{\n\t\tQ3_BSPBrushToMapBrush(&q3_dbrushes[q3_dmodels[mapent->modelnum].firstBrush + i], mapent);\n\t} //end for\n} //end of the function Q3_ParseBSPBrushes\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean Q3_ParseBSPEntity(int entnum)\n{\n\tentity_t *mapent;\n\tchar *model;\n\tint startbrush, startsides;\n\n\tstartbrush = nummapbrushes;\n\tstartsides = nummapbrushsides;\n\n\tmapent = &entities[entnum];//num_entities];\n\tmapent->firstbrush = nummapbrushes;\n\tmapent->numbrushes = 0;\n\tmapent->modelnum = -1;\t//-1 = no BSP model\n\n\tmodel = ValueForKey(mapent, \"model\");\n\tif (model && strlen(model))\n\t{\n\t\tif (*model == '*')\n\t\t{\n\t\t\t//get the model number of this entity (skip the leading *)\n\t\t\tmapent->modelnum = atoi(&model[1]);\n\t\t} //end if\n\t} //end if\n\n\tGetVectorForKey(mapent, \"origin\", mapent->origin);\n\n\t//if this is the world entity it has model number zero\n\t//the world entity has no model key\n\tif (!strcmp(\"worldspawn\", ValueForKey(mapent, \"classname\")))\n\t{\n\t\tmapent->modelnum = 0;\n\t} //end if\n\t//if the map entity has a BSP model (a modelnum of -1 is used for\n\t//entities that aren't using a BSP model)\n\tif (mapent->modelnum >= 0)\n\t{\n\t\t//parse the bsp brushes\n\t\tQ3_ParseBSPBrushes(mapent);\n\t} //end if\n\t//\n\t//the origin of the entity is already taken into account\n\t//\n\t//func_group entities can't be in the bsp file\n\t//\n\t//check out the func_areaportal entities\n\tif (!strcmp (\"func_areaportal\", ValueForKey (mapent, \"classname\")))\n\t{\n\t\tc_areaportals++;\n\t\tmapent->areaportalnum = c_areaportals;\n\t\treturn true;\n\t} //end if\n\treturn true;\n} //end of the function Q3_ParseBSPEntity\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#define\tMAX_PATCH_VERTS\t\t1024\n\nvoid AAS_CreateCurveBrushes(void)\n{\n\tint i, j, n, planenum, numcurvebrushes = 0;\n\tq3_dsurface_t *surface;\n\tq3_drawVert_t *dv_p;\n\tvec3_t points[MAX_PATCH_VERTS];\n\tint width, height, c;\n\tpatchCollide_t *pc;\n\tfacet_t *facet;\n\tmapbrush_t *brush;\n\tside_t *side;\n\tentity_t *mapent;\n\twinding_t *winding;\n\n\tqprintf(\"nummapbrushsides = %d\\n\", nummapbrushsides);\n\tmapent = &entities[0];\n\tfor (i = 0; i < q3_numDrawSurfaces; i++)\n\t{\n\t\tsurface = &q3_drawSurfaces[i];\n\t\tif ( ! surface->patchWidth ) continue;\n\t\t// if the curve is not solid\n\t\tif (!(q3_dshaders[surface->shaderNum].contentFlags & (CONTENTS_SOLID|CONTENTS_PLAYERCLIP)))\n\t\t{\n\t\t\t//Log_Print(\"skipped non-solid curve\\n\");\n\t\t\tcontinue;\n\t\t} //end if\n\t\t// if this curve should not be used for AAS\n\t\tif ( q3_dshaders[surface->shaderNum].contentFlags & CONTENTS_NOBOTCLIP ) {\n\t\t\tcontinue;\n\t\t}\n\t\t//\n\t\twidth = surface->patchWidth;\n\t\theight = surface->patchHeight;\n\t\tc = width * height;\n\t\tif (c > MAX_PATCH_VERTS)\n\t\t{\n\t\t\tError(\"ParseMesh: MAX_PATCH_VERTS\");\n\t\t} //end if\n\n\t\tdv_p = q3_drawVerts + surface->firstVert;\n\t\tfor ( j = 0 ; j < c ; j++, dv_p++ )\n\t\t{\n\t\t\tpoints[j][0] = dv_p->xyz[0];\n\t\t\tpoints[j][1] = dv_p->xyz[1];\n\t\t\tpoints[j][2] = dv_p->xyz[2];\n\t\t} //end for\n\t\t// create the internal facet structure\n\t\tpc = CM_GeneratePatchCollide(width, height, points);\n\t\t//\n\t\tfor (j = 0; j < pc->numFacets; j++)\n\t\t{\n\t\t\tfacet = &pc->facets[j];\n\t\t\t//\n\t\t\tbrush = &mapbrushes[nummapbrushes];\n\t\t\tbrush->original_sides = &brushsides[nummapbrushsides];\n\t\t\tbrush->entitynum = 0;\n\t\t\tbrush->brushnum = nummapbrushes - mapent->firstbrush;\n\t\t\t//\n\t\t\tbrush->numsides = facet->numBorders + 2;\n\t\t\tnummapbrushsides += brush->numsides;\n\t\t\tbrush->contents = CONTENTS_SOLID;\n\t\t\t//\n\t\t\t//qprintf(\"\\r%6d curve brushes\", nummapbrushsides);//++numcurvebrushes);\n\t\t\tqprintf(\"\\r%6d curve brushes\", ++numcurvebrushes);\n\t\t\t//\n\t\t\tplanenum = FindFloatPlane(pc->planes[facet->surfacePlane].plane, pc->planes[facet->surfacePlane].plane[3]);\n\t\t\t//\n\t\t\tside = &brush->original_sides[0];\n\t\t\tside->planenum = planenum;\n\t\t\tside->contents = CONTENTS_SOLID;\n\t\t\tside->flags |= SFL_TEXTURED|SFL_VISIBLE|SFL_CURVE;\n\t\t\tside->surf = 0;\n\t\t\t//\n\t\t\tside = &brush->original_sides[1];\n\t\t\tif (create_aas)\n\t\t\t{\n\t\t\t\t//the plane is expanded later so it's not a problem that\n\t\t\t\t//these first two opposite sides are coplanar\n\t\t\t\tside->planenum = planenum ^ 1;\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tside->planenum = FindFloatPlane(mapplanes[planenum^1].normal, mapplanes[planenum^1].dist + 1);\n\t\t\t\tside->flags |= SFL_TEXTURED|SFL_VISIBLE;\n\t\t\t} //end else\n\t\t\tside->contents = CONTENTS_SOLID;\n\t\t\tside->flags |= SFL_CURVE;\n\t\t\tside->surf = 0;\n\t\t\t//\n\t\t\twinding = BaseWindingForPlane(mapplanes[side->planenum].normal, mapplanes[side->planenum].dist);\n\t\t\tfor (n = 0; n < facet->numBorders; n++)\n\t\t\t{\n\t\t\t\t//never use the surface plane as a border\n\t\t\t\tif (facet->borderPlanes[n] == facet->surfacePlane) continue;\n\t\t\t\t//\n\t\t\t\tside = &brush->original_sides[2 + n];\n\t\t\t\tside->planenum = FindFloatPlane(pc->planes[facet->borderPlanes[n]].plane, pc->planes[facet->borderPlanes[n]].plane[3]);\n\t\t\t\tif (facet->borderInward[n]) side->planenum ^= 1;\n\t\t\t\tside->contents = CONTENTS_SOLID;\n\t\t\t\tside->flags |= SFL_TEXTURED|SFL_CURVE;\n\t\t\t\tside->surf = 0;\n\t\t\t\t//chop the winding in place\n\t\t\t\tif (winding) ChopWindingInPlace(&winding, mapplanes[side->planenum^1].normal, mapplanes[side->planenum^1].dist, 0.1); //CLIP_EPSILON);\n\t\t\t} //end for\n\t\t\t//VectorCopy(pc->bounds[0], brush->mins);\n\t\t\t//VectorCopy(pc->bounds[1], brush->maxs);\n\t\t\tif (!winding)\n\t\t\t{\n\t\t\t\tLog_Print(\"WARNING: AAS_CreateCurveBrushes: no winding\\n\");\n\t\t\t\tbrush->numsides = 0;\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\tbrush->original_sides[0].winding = winding;\n\t\t\tWindingBounds(winding, brush->mins, brush->maxs);\n\t\t\tfor (n = 0; n < 3; n++)\n\t\t\t{\n\t\t\t\t//IDBUG: all the indexes into the mins and maxs were zero (not using i)\n\t\t\t\tif (brush->mins[n] < -MAX_MAP_BOUNDS || brush->maxs[n] > MAX_MAP_BOUNDS)\n\t\t\t\t{\n\t\t\t\t\tLog_Print(\"entity %i, brush %i: bounds out of range\\n\", brush->entitynum, brush->brushnum);\n\t\t\t\t\tLog_Print(\"brush->mins[%d] = %f, brush->maxs[%d] = %f\\n\", n, brush->mins[n], n, brush->maxs[n]);\n\t\t\t\t\tbrush->numsides = 0; //remove the brush\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t\tif (brush->mins[n] > MAX_MAP_BOUNDS || brush->maxs[n] < -MAX_MAP_BOUNDS)\n\t\t\t\t{\n\t\t\t\t\tLog_Print(\"entity %i, brush %i: no visible sides on brush\\n\", brush->entitynum, brush->brushnum);\n\t\t\t\t\tLog_Print(\"brush->mins[%d] = %f, brush->maxs[%d] = %f\\n\", n, brush->mins[n], n, brush->maxs[n]);\n\t\t\t\t\tbrush->numsides = 0; //remove the brush\n\t\t\t\t\tbreak;\n\t\t\t\t} //end if\n\t\t\t} //end for\n\t\t\tif (create_aas)\n\t\t\t{\n\t\t\t\t//NOTE: brush bevels now already added\n\t\t\t\t//AddBrushBevels(brush);\n\t\t\t\tAAS_CreateMapBrushes(brush, mapent, false);\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\t// create windings for sides and bounds for brush\n\t\t\t\tMakeBrushWindings(brush);\n\t\t\t\tAddBrushBevels(brush);\n\t\t\t\tnummapbrushes++;\n\t\t\t\tmapent->numbrushes++;\n\t\t\t} //end else\n\t\t} //end for\n\t} //end for\n\t//qprintf(\"\\r%6d curve brushes\", nummapbrushsides);//++numcurvebrushes);\n\tqprintf(\"\\r%6d curve brushes\\n\", numcurvebrushes);\n} //end of the function AAS_CreateCurveBrushes\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AAS_ExpandMapBrush(mapbrush_t *brush, vec3_t mins, vec3_t maxs);\n\nvoid Q3_LoadMapFromBSP(struct quakefile_s *qf)\n{\n\tint i;\n\tvec3_t mins = {-1,-1,-1}, maxs = {1, 1, 1};\n\n\tLog_Print(\"-- Q3_LoadMapFromBSP --\\n\");\n\t//loaded map type\n\tloadedmaptype = MAPTYPE_QUAKE3;\n\n\tLog_Print(\"Loading map from %s...\\n\", qf->filename);\n\t//load the bsp file\n\tQ3_LoadBSPFile(qf);\n\n\t//create an index from bsp planes to map planes\n\t//DPlanes2MapPlanes();\n\t//clear brush model numbers\n\tfor (i = 0; i < MAX_MAPFILE_BRUSHES; i++)\n\t\tbrushmodelnumbers[i] = -1;\n\n\tnummapbrushsides = 0;\n\tnum_entities = 0;\n\n\tQ3_ParseEntities();\n\t//\n\tfor (i = 0; i < num_entities; i++)\n\t{\n\t\tQ3_ParseBSPEntity(i);\n\t} //end for\n\n\tAAS_CreateCurveBrushes();\n\t//get the map mins and maxs from the world model\n\tClearBounds(map_mins, map_maxs);\n\tfor (i = 0; i < entities[0].numbrushes; i++)\n\t{\n\t\tif (mapbrushes[i].numsides <= 0)\n\t\t\tcontinue;\n\t\tAddPointToBounds (mapbrushes[i].mins, map_mins, map_maxs);\n\t\tAddPointToBounds (mapbrushes[i].maxs, map_mins, map_maxs);\n\t} //end for\n\t/*/\n\tfor (i = 0; i < nummapbrushes; i++)\n\t{\n\t\t//if (!mapbrushes[i].original_sides) continue;\n\t\t//AddBrushBevels(&mapbrushes[i]);\n\t\t//AAS_ExpandMapBrush(&mapbrushes[i], mins, maxs);\n\t} //end for*/\n\t/*\n\tfor (i = 0; i < nummapbrushsides; i++)\n\t{\n\t\tLog_Write(\"side %d flags = %d\", i, brushsides[i].flags);\n\t} //end for\n\tfor (i = 0; i < nummapbrushes; i++)\n\t{\n\t\tLog_Write(\"brush contents: \");\n\t\tPrintContents(mapbrushes[i].contents);\n\t\tLog_Print(\"\\n\");\n\t} //end for*/\n} //end of the function Q3_LoadMapFromBSP\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Q3_ResetMapLoading(void)\n{\n\t//reset for map loading from bsp\n\tmemset(nodestack, 0, NODESTACKSIZE * sizeof(int));\n\tnodestackptr = NULL;\n\tnodestacksize = 0;\n\tmemset(brushmodelnumbers, 0, MAX_MAPFILE_BRUSHES * sizeof(int));\n} //end of the function Q3_ResetMapLoading\n\n"
  },
  {
    "path": "code/bspc/map_sin.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//-----------------------------------------------------------------------------\n//\n//  $Logfile:: /MissionPack/code/bspc/map_sin.c                               $\n\n#include \"qbsp.h\"\n#include \"l_bsp_sin.h\"\n#include \"aas_map.h\"\t\t\t//AAS_CreateMapBrushes\n\n\n//====================================================================\n\n\n/*\n===========\nSin_BrushContents\n===========\n*/\n\nint Sin_BrushContents(mapbrush_t *b)\n{\n\tint\t\t\tcontents;\n\tside_t\t\t*s;\n\tint\t\t\ti;\n#ifdef SIN\n\tfloat\t\t\ttrans = 0;\n#else\n\tint\t\t\ttrans;\n#endif\n\n\ts = &b->original_sides[0];\n\tcontents = s->contents;\n\n#ifdef SIN\n\ttrans = sin_texinfo[s->texinfo].translucence;\n#else\n\ttrans = texinfo[s->texinfo].flags;\n#endif\n\tfor (i=1 ; i<b->numsides ; i++, s++)\n\t{\n\t\ts = &b->original_sides[i];\n#ifdef SIN\n\t\ttrans += sin_texinfo[s->texinfo].translucence;\n#else\n\t\ttrans |= texinfo[s->texinfo].flags;\n#endif\n\t\tif (s->contents != contents)\n\t\t{\n#ifdef SIN\n      if ( \n            ( s->contents & CONTENTS_DETAIL && !(contents & CONTENTS_DETAIL) ) ||\n            ( !(s->contents & CONTENTS_DETAIL) && contents & CONTENTS_DETAIL ) \n         )\n         {\n         s->contents |= CONTENTS_DETAIL;\n         contents |= CONTENTS_DETAIL;\n         continue;\n         }\n#endif\n\t\t\tprintf (\"Entity %i, Brush %i: mixed face contents\\n\"\n\t\t\t\t, b->entitynum, b->brushnum);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\n#ifdef SIN\n\tif (contents & CONTENTS_FENCE)\n\t{\n//\t\tcontents |= CONTENTS_TRANSLUCENT;\n\t\tcontents |= CONTENTS_DETAIL;\n\t\tcontents |= CONTENTS_DUMMYFENCE;\n\t\tcontents &= ~CONTENTS_SOLID;\n\t\tcontents &= ~CONTENTS_FENCE;\n\t\tcontents |= CONTENTS_WINDOW;\n\t}\n#endif\n\n\t// if any side is translucent, mark the contents\n\t// and change solid to window\n#ifdef SIN\n\tif ( trans > 0 )\n#else\n\tif ( trans & (SURF_TRANS33|SURF_TRANS66) )\n#endif\n\t{\n\t\tcontents |= CONTENTS_Q2TRANSLUCENT;\n\t\tif (contents & CONTENTS_SOLID)\n\t\t{\n\t\t\tcontents &= ~CONTENTS_SOLID;\n\t\t\tcontents |= CONTENTS_WINDOW;\n\t\t}\n\t}\n\n\treturn contents;\n} //*/\n\n\n//============================================================================\n\n\n\n/*\n=================\nParseBrush\n=================\n* /\nvoid ParseBrush (entity_t *mapent)\n{\n\tmapbrush_t\t\t*b;\n\tint\t\t\ti,j, k;\n\tint\t\t\tmt;\n\tside_t\t\t*side, *s2;\n\tint\t\t\tplanenum;\n\tbrush_texture_t\ttd;\n#ifdef SIN\n   textureref_t newref;\n#endif\n\tint\t\t\tplanepts[3][3];\n\n\tif (nummapbrushes == MAX_MAP_BRUSHES)\n\t\tError (\"nummapbrushes == MAX_MAP_BRUSHES\");\n\n\tb = &mapbrushes[nummapbrushes];\n\tb->original_sides = &brushsides[nummapbrushsides];\n\tb->entitynum = num_entities-1;\n\tb->brushnum = nummapbrushes - mapent->firstbrush;\n\n\tdo\n\t{\n\t\tif (!GetToken (true))\n\t\t\tbreak;\n\t\tif (!strcmp (token, \"}\") )\n\t\t\tbreak;\n\n\t\tif (nummapbrushsides == MAX_MAP_BRUSHSIDES)\n\t\t\tError (\"MAX_MAP_BRUSHSIDES\");\n\t\tside = &brushsides[nummapbrushsides];\n\n\t\t// read the three point plane definition\n\t\tfor (i=0 ; i<3 ; i++)\n\t\t{\n\t\t\tif (i != 0)\n\t\t\t\tGetToken (true);\n\t\t\tif (strcmp (token, \"(\") )\n\t\t\t\tError (\"parsing brush\");\n\t\t\t\n\t\t\tfor (j=0 ; j<3 ; j++)\n\t\t\t{\n\t\t\t\tGetToken (false);\n\t\t\t\tplanepts[i][j] = atoi(token);\n\t\t\t}\n\t\t\t\n\t\t\tGetToken (false);\n\t\t\tif (strcmp (token, \")\") )\n\t\t\t\tError (\"parsing brush\");\n\t\t\t\t\n\t\t}\n\n\n\t\t//\n\t\t// read the texturedef\n\t\t//\n\t\tGetToken (false);\n\t\tstrcpy (td.name, token);\n\n\t\tGetToken (false);\n\t\ttd.shift[0] = atoi(token);\n\t\tGetToken (false);\n\t\ttd.shift[1] = atoi(token);\n\t\tGetToken (false);\n#ifdef SIN\n\t\ttd.rotate = atof(token);\t\n#else\n\t\ttd.rotate = atoi(token);\t\n#endif\n\t\tGetToken (false);\n\t\ttd.scale[0] = atof(token);\n\t\tGetToken (false);\n\t\ttd.scale[1] = atof(token);\n\n\t\t// find default flags and values\n\t\tmt = FindMiptex (td.name);\n#ifdef SIN\n      // clear out the masks on newref\n      memset(&newref,0,sizeof(newref));\n      // copy over the name\n      strcpy( newref.name, td.name );\n\n      ParseSurfaceInfo( &newref );\n      MergeRefs( &bsp_textureref[mt], &newref, &td.tref );\n      side->contents = td.tref.contents;\n      side->surf = td.tref.flags;\n#else\n\t\ttd.flags = textureref[mt].flags;\n\t\ttd.value = textureref[mt].value;\n\t\tside->contents = textureref[mt].contents;\n\t\tside->surf = td.flags = textureref[mt].flags;\n\n\t\tif (TokenAvailable())\n\t\t{\n\t\t\tGetToken (false);\n\t\t\tside->contents = atoi(token);\n\t\t\tGetToken (false);\n\t\t\tside->surf = td.flags = atoi(token);\n\t\t\tGetToken (false);\n\t\t\ttd.value = atoi(token);\n\t\t}\n#endif\n\n\t\t// translucent objects are automatically classified as detail\n#ifdef SIN\n\t\tif ( td.tref.translucence > 0 )\n#else\n\t\tif (side->surf & (SURF_TRANS33|SURF_TRANS66) )\n#endif\n\t\t\tside->contents |= CONTENTS_DETAIL;\n\t\tif (side->contents & (CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP) )\n\t\t\tside->contents |= CONTENTS_DETAIL;\n\t\tif (fulldetail)\n\t\t\tside->contents &= ~CONTENTS_DETAIL;\n\t\tif (!(side->contents & ((LAST_VISIBLE_CONTENTS-1) \n\t\t\t| CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP|CONTENTS_MIST)  ) )\n\t\t\tside->contents |= CONTENTS_SOLID;\n\n\t\t// hints and skips are never detail, and have no content\n\t\tif (side->surf & (SURF_HINT|SURF_SKIP) )\n\t\t{\n\t\t\tside->contents = 0;\n#ifndef SIN // I think this is a bug of some kind\n\t\t\tside->surf &= ~CONTENTS_DETAIL;\n#endif\n\t\t}\n\n\t\t//\n\t\t// find the plane number\n\t\t//\n\t\tplanenum = PlaneFromPoints (planepts[0], planepts[1], planepts[2]);\n\t\tif (planenum == -1)\n\t\t{\n\t\t\tprintf (\"Entity %i, Brush %i: plane with no normal\\n\"\n\t\t\t\t, b->entitynum, b->brushnum);\n\t\t\tcontinue;\n\t\t}\n\n\t\t//\n\t\t// see if the plane has been used already\n\t\t//\n\t\tfor (k=0 ; k<b->numsides ; k++)\n\t\t{\n\t\t\ts2 = b->original_sides + k;\n\t\t\tif (s2->planenum == planenum)\n\t\t\t{\n\t\t\t\tprintf (\"Entity %i, Brush %i: duplicate plane\\n\"\n\t\t\t\t\t, b->entitynum, b->brushnum);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( s2->planenum == (planenum^1) )\n\t\t\t{\n\t\t\t\tprintf (\"Entity %i, Brush %i: mirrored plane\\n\"\n\t\t\t\t\t, b->entitynum, b->brushnum);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (k != b->numsides)\n\t\t\tcontinue;\t\t// duplicated\n\n\t\t//\n\t\t// keep this side\n\t\t//\n\n\t\tside = b->original_sides + b->numsides;\n\t\tside->planenum = planenum;\n#ifdef SIN\n\t\tside->texinfo = TexinfoForBrushTexture (&mapplanes[planenum],\n\t\t\t&td, vec3_origin, &newref);\n      // \n      // save off lightinfo\n      //\n\t\tside->lightinfo = LightinfoForBrushTexture ( &td );\n#else\n\t\tside->texinfo = TexinfoForBrushTexture (&mapplanes[planenum],\n\t\t\t&td, vec3_origin);\n\n#endif\n\n\t\t// save the td off in case there is an origin brush and we\n\t\t// have to recalculate the texinfo\n\t\tside_brushtextures[nummapbrushsides] = td;\n#ifdef SIN\n      // save off the merged tref for animating textures\n\t\tside_newrefs[nummapbrushsides] = newref;\n#endif\n\n\t\tnummapbrushsides++;\n\t\tb->numsides++;\n\t} while (1);\n\n\t// get the content for the entire brush\n\tb->contents = Sin_BrushContents (b);\n\n\t// allow detail brushes to be removed \n\tif (nodetail && (b->contents & CONTENTS_DETAIL) )\n\t{\n\t\tb->numsides = 0;\n\t\treturn;\n\t}\n\n\t// allow water brushes to be removed\n\tif (nowater && (b->contents & (CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_WATER)) )\n\t{\n\t\tb->numsides = 0;\n\t\treturn;\n\t}\n\n\t// create windings for sides and bounds for brush\n\tMakeBrushWindings (b);\n\n\t// brushes that will not be visible at all will never be\n\t// used as bsp splitters\n\tif (b->contents & (CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP) )\n\t{\n\t\tc_clipbrushes++;\n\t\tfor (i=0 ; i<b->numsides ; i++)\n\t\t\tb->original_sides[i].texinfo = TEXINFO_NODE;\n\t}\n\n\t//\n\t// origin brushes are removed, but they set\n\t// the rotation origin for the rest of the brushes\n\t// in the entity.  After the entire entity is parsed,\n\t// the planenums and texinfos will be adjusted for\n\t// the origin brush\n\t//\n\tif (b->contents & CONTENTS_ORIGIN)\n\t{\n\t\tchar\tstring[32];\n\t\tvec3_t\torigin;\n\n\t\tif (num_entities == 1)\n\t\t{\n\t\t\tError (\"Entity %i, Brush %i: origin brushes not allowed in world\"\n\t\t\t\t, b->entitynum, b->brushnum);\n\t\t\treturn;\n\t\t}\n\n\t\tVectorAdd (b->mins, b->maxs, origin);\n\t\tVectorScale (origin, 0.5, origin);\n\n\t\tsprintf (string, \"%i %i %i\", (int)origin[0], (int)origin[1], (int)origin[2]);\n\t\tSetKeyValue (&entities[b->entitynum], \"origin\", string);\n\n\t\tVectorCopy (origin, entities[b->entitynum].origin);\n\n\t\t// don't keep this brush\n\t\tb->numsides = 0;\n\n\t\treturn;\n\t}\n\n\tAddBrushBevels (b);\n\n\tnummapbrushes++;\n\tmapent->numbrushes++;\t\t\n} //*/\n\n/*\n================\nMoveBrushesToWorld\n\nTakes all of the brushes from the current entity and\nadds them to the world's brush list.\n\nUsed by func_group and func_areaportal\n================\n* /\nvoid MoveBrushesToWorld (entity_t *mapent)\n{\n\tint\t\t\tnewbrushes;\n\tint\t\t\tworldbrushes;\n\tmapbrush_t\t*temp;\n\tint\t\t\ti;\n\n\t// this is pretty gross, because the brushes are expected to be\n\t// in linear order for each entity\n\n\tnewbrushes = mapent->numbrushes;\n\tworldbrushes = entities[0].numbrushes;\n\n\ttemp = malloc(newbrushes*sizeof(mapbrush_t));\n\tmemcpy (temp, mapbrushes + mapent->firstbrush, newbrushes*sizeof(mapbrush_t));\n\n#if\t0\t\t// let them keep their original brush numbers\n\tfor (i=0 ; i<newbrushes ; i++)\n\t\ttemp[i].entitynum = 0;\n#endif\n\n\t// make space to move the brushes (overlapped copy)\n\tmemmove (mapbrushes + worldbrushes + newbrushes,\n\t\tmapbrushes + worldbrushes,\n\t\tsizeof(mapbrush_t) * (nummapbrushes - worldbrushes - newbrushes) );\n\n\t// copy the new brushes down\n\tmemcpy (mapbrushes + worldbrushes, temp, sizeof(mapbrush_t) * newbrushes);\n\n\t// fix up indexes\n\tentities[0].numbrushes += newbrushes;\n\tfor (i=1 ; i<num_entities ; i++)\n\t\tentities[i].firstbrush += newbrushes;\n\tfree (temp);\n\n\tmapent->numbrushes = 0;\n} //*/\n\n/*\n================\nParseMapEntity\n================\n* /\nqboolean\tSin_ParseMapEntity (void)\n{\n\tentity_t\t*mapent;\n\tepair_t\t\t*e;\n\tside_t\t\t*s;\n\tint\t\t\ti, j;\n\tint\t\t\tstartbrush, startsides;\n\tvec_t\t\tnewdist;\n\tmapbrush_t\t*b;\n\n\tif (!GetToken (true))\n\t\treturn false;\n\n\tif (strcmp (token, \"{\") )\n\t\tError (\"ParseEntity: { not found\");\n\t\n\tif (num_entities == MAX_MAP_ENTITIES)\n\t\tError (\"num_entities == MAX_MAP_ENTITIES\");\n\n\tstartbrush = nummapbrushes;\n\tstartsides = nummapbrushsides;\n\n\tmapent = &entities[num_entities];\n\tnum_entities++;\n\tmemset (mapent, 0, sizeof(*mapent));\n\tmapent->firstbrush = nummapbrushes;\n\tmapent->numbrushes = 0;\n//\tmapent->portalareas[0] = -1;\n//\tmapent->portalareas[1] = -1;\n\n\tdo\n\t{\n\t\tif (!GetToken (true))\n\t\t\tError (\"ParseEntity: EOF without closing brace\");\n\t\tif (!strcmp (token, \"}\") )\n\t\t\tbreak;\n\t\tif (!strcmp (token, \"{\") )\n\t\t\tParseBrush (mapent);\n\t\telse\n\t\t{\n\t\t\te = ParseEpair ();\n#ifdef SIN\n         //HACK HACK HACK\n         // MED Gotta do this here\n         if ( !stricmp(e->key, \"surfacefile\") )\n            {\n            if (!surfacefile[0])\n               {\n               strcpy( surfacefile, e->value );\n               }\n\t\t      printf (\"--- ParseSurfaceFile ---\\n\");\n\t\t      printf (\"Surface script: %s\\n\", surfacefile);\n\t\t      if (!ParseSurfaceFile(surfacefile))\n               {\n\t\t         Error (\"Script file not found: %s\\n\", surfacefile);\n               }\n            }\n#endif\n\t\t\te->next = mapent->epairs;\n\t\t\tmapent->epairs = e;\n\t\t}\n\t} while (1);\n\n#ifdef SIN\n    if (!(strlen(ValueForKey(mapent, \"origin\")))  && ((num_entities-1) != 0))\n        {\n        mapbrush_t     *brush;\n        vec3_t\t\t    origin;\n  \t    char\t\t    string[32];\n        vec3_t          mins, maxs;\n        int\t\t\t    start, end;\n        // Calculate bounds\n\n        start = mapent->firstbrush;\n\t    end = start + mapent->numbrushes;\n\t    ClearBounds (mins, maxs);\n\n\t    for (j=start ; j<end ; j++)\n            {\n\t        brush = &mapbrushes[j];\n\t\t    if (!brush->numsides)\n\t\t\t    continue;\t// not a real brush (origin brush) - shouldn't happen\n\t\t    AddPointToBounds (brush->mins, mins, maxs);\n\t\t    AddPointToBounds (brush->maxs, mins, maxs);\n            }\n\n        // Set the origin to be the centroid of the entity.\n        VectorAdd ( mins, maxs, origin);\n\t\tVectorScale( origin, 0.5f, origin );\n\n\t\tsprintf (string, \"%i %i %i\", (int)origin[0], (int)origin[1], (int)origin[2]);\n\t\tSetKeyValue ( mapent, \"origin\", string);\n//        qprintf(\"Setting origin to %s\\n\",string);\n        }\n#endif\n\n\tGetVectorForKey (mapent, \"origin\", mapent->origin);\n\n#ifdef SIN\n\tif (\n         (!strcmp (\"func_areaportal\", ValueForKey (mapent, \"classname\"))) ||\n         (!strcmp (\"func_group\", ValueForKey (mapent, \"classname\"))) ||\n      \t(!strcmp (\"detail\", ValueForKey (mapent, \"classname\")) && !entitydetails)\n      )\n      {\n      VectorClear( mapent->origin );\n      }\n#endif\n\n\t//\n\t// if there was an origin brush, offset all of the planes and texinfo\n\t//\n\tif (mapent->origin[0] || mapent->origin[1] || mapent->origin[2])\n\t{\n\t\tfor (i=0 ; i<mapent->numbrushes ; i++)\n\t\t{\n\t\t\tb = &mapbrushes[mapent->firstbrush + i];\n\t\t\tfor (j=0 ; j<b->numsides ; j++)\n\t\t\t{\n\t\t\t\ts = &b->original_sides[j];\n\t\t\t\tnewdist = mapplanes[s->planenum].dist -\n\t\t\t\t\tDotProduct (mapplanes[s->planenum].normal, mapent->origin);\n\t\t\t\ts->planenum = FindFloatPlane (mapplanes[s->planenum].normal, newdist);\n#ifdef SIN\n\t\t\t\ts->texinfo = TexinfoForBrushTexture (&mapplanes[s->planenum],\n\t\t\t\t\t&side_brushtextures[s-brushsides], mapent->origin, &side_newrefs[s-brushsides]);\n            // \n            // save off lightinfo\n            //\n            s->lightinfo = LightinfoForBrushTexture (\t&side_brushtextures[s-brushsides] );\n#else\n\t\t\t\ts->texinfo = TexinfoForBrushTexture (&mapplanes[s->planenum],\n\t\t\t\t\t&side_brushtextures[s-brushsides], mapent->origin);\n#endif\n\t\t\t}\n\t\t\tMakeBrushWindings (b);\n\t\t}\n\t}\n\n\t// group entities are just for editor convenience\n\t// toss all brushes into the world entity\n\tif (!strcmp (\"func_group\", ValueForKey (mapent, \"classname\")))\n\t{\n\t\tMoveBrushesToWorld (mapent);\n\t\tmapent->numbrushes = 0;\n\t\tmapent->wasdetail = true;\n      FreeValueKeys( mapent );\n\t\treturn true;\n\t}\n#ifdef SIN\n\t// detail entities are just for editor convenience\n\t// toss all brushes into the world entity as detail brushes\n\tif (!strcmp (\"detail\", ValueForKey (mapent, \"classname\")) && !entitydetails)\n\t{\n\t\tfor (i=0 ; i<mapent->numbrushes ; i++)\n\t\t{\n         int j;\n         side_t * s;\n\t\t\tb = &mapbrushes[mapent->firstbrush + i];\n   \t   if (nodetail)\n            {\n            b->numsides = 0;\n            continue;\n            }\n         if (!fulldetail)\n            {\n   \t      // set the contents for the entire brush\n\t         b->contents |= CONTENTS_DETAIL;\n\t\t\t   // set the contents in the sides as well\n\t\t\t   for (j=0, s=b->original_sides ; j<b->numsides ; j++,s++)\n\t\t   \t   {\n               s->contents |= CONTENTS_DETAIL;\n\t   \t   \t}\n            }\n         else\n            {\n   \t      // set the contents for the entire brush\n\t         b->contents |= CONTENTS_SOLID;\n\t\t\t   // set the contents in the sides as well\n\t\t\t   for (j=0, s=b->original_sides ; j<b->numsides ; j++,s++)\n\t\t   \t   {\n               s->contents |= CONTENTS_SOLID;\n\t   \t   \t}\n            }\n\t\t}\n\t\tMoveBrushesToWorld (mapent);\n\t\tmapent->wasdetail = true;\n      FreeValueKeys( mapent );\n      // kill off the entity\n   \t// num_entities--;\n\t\treturn true;\n\t}\n#endif\n\n\t// areaportal entities move their brushes, but don't eliminate\n\t// the entity\n\tif (!strcmp (\"func_areaportal\", ValueForKey (mapent, \"classname\")))\n\t{\n\t\tchar\tstr[128];\n\n\t\tif (mapent->numbrushes != 1)\n\t\t\tError (\"Entity %i: func_areaportal can only be a single brush\", num_entities-1);\n\n\t\tb = &mapbrushes[nummapbrushes-1];\n\t\tb->contents = CONTENTS_AREAPORTAL;\n\t\tc_areaportals++;\n\t\tmapent->areaportalnum = c_areaportals;\n\t\t// set the portal number as \"style\"\n\t\tsprintf (str, \"%i\", c_areaportals);\n\t\tSetKeyValue (mapent, \"style\", str);\n\t\tMoveBrushesToWorld (mapent);\n\t\treturn true;\n\t}\n\n\treturn true;\n} //end of the function Sin_ParseMapEntity */\n\n//===================================================================\n\n/*\n================\nLoadMapFile\n================\n* /\nvoid Sin_LoadMapFile (char *filename)\n{\t\t\n\tint\t\ti;\n#ifdef SIN\n   int num_detailsides=0;\n   int num_detailbrushes=0;\n   int num_worldsides=0;\n   int num_worldbrushes=0;\n   int      j,k;\n#endif\n\n\tqprintf (\"--- LoadMapFile ---\\n\");\n\n\tLoadScriptFile (filename);\n\n\tnummapbrushsides = 0;\n\tnum_entities = 0;\n\t\n\twhile (ParseMapEntity ())\n\t{\n\t}\n\n\tClearBounds (map_mins, map_maxs);\n\tfor (i=0 ; i<entities[0].numbrushes ; i++)\n\t{\n\t\tif (mapbrushes[i].mins[0] > 4096)\n\t\t\tcontinue;\t// no valid points\n\t\tAddPointToBounds (mapbrushes[i].mins, map_mins, map_maxs);\n\t\tAddPointToBounds (mapbrushes[i].maxs, map_mins, map_maxs);\n\t}\n#ifdef SIN\n   for (j=0;  j<num_entities; j++)\n      {\n\t   for (i=0 ; i<entities[j].numbrushes ; i++)\n\t      {\n         side_t * s;\n         mapbrush_t *b;\n\t\t\tb = &mapbrushes[entities[j].firstbrush + i];\n         if (b->numsides && b->contents & CONTENTS_DETAIL)\n            num_detailbrushes++;\n         else if (b->numsides)\n            num_worldbrushes++;\n\t\t\tfor (k=0, s=b->original_sides ; k<b->numsides ; k++,s++)\n\t\t\t   {\n            if (s->contents & CONTENTS_DETAIL)\n               num_detailsides++;\n            else\n               num_worldsides++;\n\t\t\t   }\n   \t   }\n      }\n#endif\n\n\tqprintf (\"%5i brushes\\n\", nummapbrushes);\n\tqprintf (\"%5i clipbrushes\\n\", c_clipbrushes);\n\tqprintf (\"%5i total sides\\n\", nummapbrushsides);\n\tqprintf (\"%5i boxbevels\\n\", c_boxbevels);\n\tqprintf (\"%5i edgebevels\\n\", c_edgebevels);\n\tqprintf (\"%5i entities\\n\", num_entities);\n\tqprintf (\"%5i planes\\n\", nummapplanes);\n\tqprintf (\"%5i areaportals\\n\", c_areaportals);\n\tqprintf (\"size: %5.0f,%5.0f,%5.0f to %5.0f,%5.0f,%5.0f\\n\", map_mins[0],map_mins[1],map_mins[2],\n\t\tmap_maxs[0],map_maxs[1],map_maxs[2]);\n#ifdef SIN\n\tqprintf (\"%5i detailbrushes\\n\", num_detailbrushes);\n\tqprintf (\"%5i worldbrushes\\n\", num_worldbrushes);\n\tqprintf (\"%5i detailsides\\n\", num_detailsides);\n\tqprintf (\"%5i worldsides\\n\", num_worldsides);\n#endif\n\n} //end of the function Sin_LoadMap */\n\n\n#ifdef ME\t\t//Begin MAP loading from BSP file\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Sin_CreateMapTexinfo(void)\n{\n\tint i;\n\tvec_t defaultvec[4] = {1, 0, 0, 0};\n\n\tmemcpy(map_texinfo[0].vecs[0], defaultvec, sizeof(defaultvec));\n\tmemcpy(map_texinfo[0].vecs[1], defaultvec, sizeof(defaultvec));\n\tmap_texinfo[0].flags = 0;\n\tmap_texinfo[0].value = 0;\n\tstrcpy(map_texinfo[0].texture, \"generic/misc/red\");\t//no texture\n\tmap_texinfo[0].nexttexinfo = -1;\n\tfor (i = 1; i < sin_numtexinfo; i++)\n\t{\n\t\tmemcpy(map_texinfo[i].vecs, sin_texinfo[i].vecs, sizeof(float) * 2 * 4);\n\t\tmap_texinfo[i].flags = sin_texinfo[i].flags;\n\t\tmap_texinfo[i].value = 0;\n\t\tstrcpy(map_texinfo[i].texture, sin_texinfo[i].texture);\n\t\tmap_texinfo[i].nexttexinfo = -1;\n\t} //end for\n} //end of the function Sin_CreateMapTexinfo\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Sin_SetLeafBrushesModelNumbers(int leafnum, int modelnum)\n{\n\tint i, brushnum;\n\tsin_dleaf_t *leaf;\n\n\tleaf = &sin_dleafs[leafnum];\n\tfor (i = 0; i < leaf->numleafbrushes; i++)\n\t{\n\t\tbrushnum = sin_dleafbrushes[leaf->firstleafbrush + i];\n\t\tbrushmodelnumbers[brushnum] = modelnum;\n\t\tdbrushleafnums[brushnum] = leafnum;\n\t} //end for\n} //end of the function Sin_SetLeafBrushesModelNumbers\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Sin_InitNodeStack(void)\n{\n\tnodestackptr = nodestack;\n\tnodestacksize = 0;\n} //end of the function Sin_InitNodeStack\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Sin_PushNodeStack(int num)\n{\n\t*nodestackptr = num;\n\tnodestackptr++;\n\tnodestacksize++;\n\t//\n\tif (nodestackptr >= &nodestack[NODESTACKSIZE])\n\t{\n\t\tError(\"Sin_PushNodeStack: stack overflow\\n\");\n\t} //end if\n} //end of the function Sin_PushNodeStack\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint Sin_PopNodeStack(void)\n{\n\t//if the stack is empty\n\tif (nodestackptr <= nodestack) return -1;\n\t//decrease stack pointer\n\tnodestackptr--;\n\tnodestacksize--;\n\t//return the top value from the stack\n\treturn *nodestackptr;\n} //end of the function Sin_PopNodeStack\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Sin_SetBrushModelNumbers(entity_t *mapent)\n{\n\tint n, pn;\n\tint leafnum;\n\n\t//\n\tSin_InitNodeStack();\n\t//head node (root) of the bsp tree\n\tn = sin_dmodels[mapent->modelnum].headnode;\n\tpn = 0;\n\t\n\tdo\n\t{\n\t\t//if we are in a leaf (negative node number)\n\t\tif (n < 0)\n\t\t{\n\t\t\t//number of the leaf\n\t\t\tleafnum = (-n) - 1;\n\t\t\t//set the brush numbers\n\t\t\tSin_SetLeafBrushesModelNumbers(leafnum, mapent->modelnum);\n\t\t\t//walk back into the tree to find a second child to continue with\n\t\t\tfor (pn = Sin_PopNodeStack(); pn >= 0; n = pn, pn = Sin_PopNodeStack())\n\t\t\t{\n\t\t\t\t//if we took the first child at the parent node\n\t\t\t\tif (sin_dnodes[pn].children[0] == n) break;\n\t\t\t} //end for\n\t\t\t//if the stack wasn't empty (if not processed whole tree)\n\t\t\tif (pn >= 0)\n\t\t\t{\n\t\t\t\t//push the parent node again\n\t\t\t\tSin_PushNodeStack(pn);\n\t\t\t\t//we proceed with the second child of the parent node\n\t\t\t\tn = sin_dnodes[pn].children[1];\n\t\t\t} //end if\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\t//push the current node onto the stack\n\t\t\tSin_PushNodeStack(n);\n\t\t\t//walk forward into the tree to the first child\n\t\t\tn = sin_dnodes[n].children[0];\n\t\t} //end else\n\t} while(pn >= 0);\n} //end of the function Sin_SetBrushModelNumbers\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Sin_BSPBrushToMapBrush(sin_dbrush_t *bspbrush, entity_t *mapent)\n{\n\tmapbrush_t *b;\n\tint i, k, n;\n\tside_t *side, *s2;\n\tint planenum;\n\tsin_dbrushside_t *bspbrushside;\n\tsin_dplane_t *bspplane;\n\n\tif (nummapbrushes >= MAX_MAPFILE_BRUSHES)\n\t\tError (\"nummapbrushes >= MAX_MAPFILE_BRUSHES\");\n\n\tb = &mapbrushes[nummapbrushes];\n\tb->original_sides = &brushsides[nummapbrushsides];\n\tb->entitynum = mapent-entities;\n\tb->brushnum = nummapbrushes - mapent->firstbrush;\n\tb->leafnum = dbrushleafnums[bspbrush - sin_dbrushes];\n\n\tfor (n = 0; n < bspbrush->numsides; n++)\n\t{\n\t\t//pointer to the bsp brush side\n\t\tbspbrushside = &sin_dbrushsides[bspbrush->firstside + n];\n\n\t\tif (nummapbrushsides >= MAX_MAPFILE_BRUSHSIDES)\n\t\t{\n\t\t\tError (\"MAX_MAPFILE_BRUSHSIDES\");\n\t\t} //end if\n\t\t//pointer to the map brush side\n\t\tside = &brushsides[nummapbrushsides];\n\t\t//if the BSP brush side is textured\n\t\tif (sin_dbrushsidetextured[bspbrush->firstside + n]) side->flags |= SFL_TEXTURED;\n\t\telse side->flags &= ~SFL_TEXTURED;\n\t\t//ME: can get side contents and surf directly from BSP file\n\t\tside->contents = bspbrush->contents;\n\t\t//if the texinfo is TEXINFO_NODE\n\t\tif (bspbrushside->texinfo < 0) side->surf = 0;\n\t\telse side->surf = sin_texinfo[bspbrushside->texinfo].flags;\n\n\t\t// translucent objects are automatically classified as detail\n\t\tif (side->surf & (SURF_TRANS33|SURF_TRANS66) )\n\t\t\tside->contents |= CONTENTS_DETAIL;\n\t\tif (side->contents & (CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP) )\n\t\t\tside->contents |= CONTENTS_DETAIL;\n\t\tif (fulldetail)\n\t\t\tside->contents &= ~CONTENTS_DETAIL;\n\t\tif (!(side->contents & ((LAST_VISIBLE_CONTENTS-1) \n\t\t\t| CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP|CONTENTS_MIST)  ) )\n\t\t\tside->contents |= CONTENTS_SOLID;\n\n\t\t// hints and skips are never detail, and have no content\n\t\tif (side->surf & (SURF_HINT|SURF_SKIP) )\n\t\t{\n\t\t\tside->contents = 0;\n\t\t\tside->surf &= ~CONTENTS_DETAIL;\n\t\t}\n\n\t\t//ME: get a plane for this side\n\t\tbspplane = &sin_dplanes[bspbrushside->planenum];\n\t\tplanenum = FindFloatPlane(bspplane->normal, bspplane->dist);\n\t\t//\n\t\t// see if the plane has been used already\n\t\t//\n\t\t//ME: this really shouldn't happen!!!\n\t\t//ME: otherwise the bsp file is corrupted??\n\t\t//ME: still it seems to happen, maybe Johny Boy's\n\t\t//ME: brush bevel adding is crappy ?\n\t\tfor (k = 0; k < b->numsides; k++)\n\t\t{\n\t\t\ts2 = b->original_sides + k;\n\t\t\tif (s2->planenum == planenum)\n\t\t\t{\n\t\t\t\tLog_Print(\"Entity %i, Brush %i: duplicate plane\\n\"\n\t\t\t\t\t, b->entitynum, b->brushnum);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( s2->planenum == (planenum^1) )\n\t\t\t{\n\t\t\t\tLog_Print(\"Entity %i, Brush %i: mirrored plane\\n\"\n\t\t\t\t\t, b->entitynum, b->brushnum);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (k != b->numsides)\n\t\t\tcontinue;\t\t// duplicated\n\n\t\t//\n\t\t// keep this side\n\t\t//\n\t\t//ME: reset pointer to side, why? hell I dunno (pointer is set above already)\n\t\tside = b->original_sides + b->numsides;\n\t\t//ME: store the plane number\n\t\tside->planenum = planenum;\n\t\t//ME: texinfo is already stored when bsp is loaded\n\t\t//NOTE: check for TEXINFO_NODE, otherwise crash in Sin_BrushContents\n\t\tif (bspbrushside->texinfo < 0) side->texinfo = 0;\n\t\telse side->texinfo = bspbrushside->texinfo;\n\n\t\t// save the td off in case there is an origin brush and we\n\t\t// have to recalculate the texinfo\n\t\t// ME: don't need to recalculate because it's already done\n\t\t//     (for non-world entities) in the BSP file\n//\t\tside_brushtextures[nummapbrushsides] = td;\n\n\t\tnummapbrushsides++;\n\t\tb->numsides++;\n\t} //end for\n\n\t// get the content for the entire brush\n\tb->contents = bspbrush->contents;\n\tSin_BrushContents(b);\n\n\tif (BrushExists(b))\n\t{\n\t\tc_squattbrushes++;\n\t\tb->numsides = 0;\n\t\treturn;\n\t} //end if\n\n\t//if we're creating AAS\n\tif (create_aas)\n\t{\n\t\t//create the AAS brushes from this brush, don't add brush bevels\n\t\tAAS_CreateMapBrushes(b, mapent, false);\n\t\treturn;\n\t} //end if\n\n\t// allow detail brushes to be removed \n\tif (nodetail && (b->contents & CONTENTS_DETAIL) )\n\t{\n\t\tb->numsides = 0;\n\t\treturn;\n\t} //end if\n\n\t// allow water brushes to be removed\n\tif (nowater && (b->contents & (CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_WATER)) )\n\t{\n\t\tb->numsides = 0;\n\t\treturn;\n\t} //end if\n\n\t// create windings for sides and bounds for brush\n\tMakeBrushWindings(b);\n\n\t//mark brushes without winding or with a tiny window as bevels\n\tMarkBrushBevels(b);\n\n\t// brushes that will not be visible at all will never be\n\t// used as bsp splitters\n\tif (b->contents & (CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP) )\n\t{\n\t\t\tc_clipbrushes++;\n\t\tfor (i = 0; i < b->numsides; i++)\n\t\t\tb->original_sides[i].texinfo = TEXINFO_NODE;\n\t} //end for\n\n\t//\n\t// origin brushes are removed, but they set\n\t// the rotation origin for the rest of the brushes\n\t// in the entity.  After the entire entity is parsed,\n\t// the planenums and texinfos will be adjusted for\n\t// the origin brush\n\t//\n\t//ME: not needed because the entities in the BSP file already\n\t//    have an origin set\n//\tif (b->contents & CONTENTS_ORIGIN)\n//\t{\n//\t\tchar\tstring[32];\n//\t\tvec3_t\torigin;\n//\n//\t\tif (num_entities == 1)\n//\t\t{\n//\t\t\tError (\"Entity %i, Brush %i: origin brushes not allowed in world\"\n//\t\t\t\t, b->entitynum, b->brushnum);\n//\t\t\treturn;\n//\t\t}\n//\n//\t\tVectorAdd (b->mins, b->maxs, origin);\n//\t\tVectorScale (origin, 0.5, origin);\n//\n//\t\tsprintf (string, \"%i %i %i\", (int)origin[0], (int)origin[1], (int)origin[2]);\n//\t\tSetKeyValue (&entities[b->entitynum], \"origin\", string);\n//\n//\t\tVectorCopy (origin, entities[b->entitynum].origin);\n//\n//\t\t// don't keep this brush\n//\t\tb->numsides = 0;\n//\n//\t\treturn;\n//\t}\n\n\t//ME: the bsp brushes already have bevels, so we won't try to\n\t//    add them again (especially since Johny Boy's bevel adding might\n\t//    be crappy)\n//\tAddBrushBevels(b);\n\n\tnummapbrushes++;\n\tmapent->numbrushes++;\n} //end of the function Sin_BSPBrushToMapBrush\n//===========================================================================\n//===========================================================================\nvoid Sin_ParseBSPBrushes(entity_t *mapent)\n{\n\tint i, testnum = 0;\n\n\t//give all the brushes that belong to this entity the number of the\n\t//BSP model used by this entity\n\tSin_SetBrushModelNumbers(mapent);\n\t//now parse all the brushes with the correct mapent->modelnum\n\tfor (i = 0; i < sin_numbrushes; i++)\n\t{\n\t\tif (brushmodelnumbers[i] == mapent->modelnum)\n\t\t{\n\t\t\ttestnum++;\n\t\t\tSin_BSPBrushToMapBrush(&sin_dbrushes[i], mapent);\n\t\t} //end if\n\t} //end for\n} //end of the function Sin_ParseBSPBrushes\n//===========================================================================\n//===========================================================================\nqboolean Sin_ParseBSPEntity(int entnum)\n{\n\tentity_t\t*mapent;\n\tchar *model;\n\tint startbrush, startsides;\n\n\tstartbrush = nummapbrushes;\n\tstartsides = nummapbrushsides;\n\n\tmapent = &entities[entnum];//num_entities];\n\tmapent->firstbrush = nummapbrushes;\n\tmapent->numbrushes = 0;\n\tmapent->modelnum = -1;\t//-1 = no model\n\n\tmodel = ValueForKey(mapent, \"model\");\n\tif (model && *model == '*')\n\t{\n\t\tmapent->modelnum = atoi(&model[1]);\n\t\t//Log_Print(\"model = %s\\n\", model);\n\t\t//Log_Print(\"mapent->modelnum = %d\\n\", mapent->modelnum);\n\t} //end if\n\n\tGetVectorForKey(mapent, \"origin\", mapent->origin);\n\n\t//if this is the world entity it has model number zero\n\t//the world entity has no model key\n\tif (!strcmp(\"worldspawn\", ValueForKey(mapent, \"classname\")))\n\t{\n\t\tmapent->modelnum = 0;\n\t} //end if\n\t//if the map entity has a BSP model (a modelnum of -1 is used for\n\t//entities that aren't using a BSP model)\n\tif (mapent->modelnum >= 0)\n\t{\n\t\t//parse the bsp brushes\n\t\tSin_ParseBSPBrushes(mapent);\n\t} //end if\n\t//\n\t//the origin of the entity is already taken into account\n\t//\n\t//func_group entities can't be in the bsp file\n\t//\n\t//check out the func_areaportal entities\n\tif (!strcmp (\"func_areaportal\", ValueForKey (mapent, \"classname\")))\n\t{\n\t\tc_areaportals++;\n\t\tmapent->areaportalnum = c_areaportals;\n\t\treturn true;\n\t} //end if\n\treturn true;\n} //end of the function Sin_ParseBSPEntity\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Sin_LoadMapFromBSP(char *filename, int offset, int length)\n{\n\tint i;\n\n\tLog_Print(\"-- Sin_LoadMapFromBSP --\\n\");\n\t//loaded map type\n\tloadedmaptype = MAPTYPE_SIN;\n\n\tLog_Print(\"Loading map from %s...\\n\", filename);\n\t//load the bsp file\n\tSin_LoadBSPFile(filename, offset, length);\n\n\t//create an index from bsp planes to map planes\n\t//DPlanes2MapPlanes();\n\t//clear brush model numbers\n\tfor (i = 0; i < MAX_MAPFILE_BRUSHES; i++)\n\t\tbrushmodelnumbers[i] = -1;\n\n\tnummapbrushsides = 0;\n\tnum_entities = 0;\n\n\tSin_ParseEntities();\n\t//\n\tfor (i = 0; i < num_entities; i++)\n\t{\n\t\tSin_ParseBSPEntity(i);\n\t} //end for\n\n\t//get the map mins and maxs from the world model\n\tClearBounds(map_mins, map_maxs);\n\tfor (i = 0; i < entities[0].numbrushes; i++)\n\t{\n\t\tif (mapbrushes[i].mins[0] > 4096)\n\t\t\tcontinue;\t//no valid points\n\t\tAddPointToBounds (mapbrushes[i].mins, map_mins, map_maxs);\n\t\tAddPointToBounds (mapbrushes[i].maxs, map_mins, map_maxs);\n\t} //end for\n\t//\n\tSin_CreateMapTexinfo();\n} //end of the function Sin_LoadMapFromBSP\n\nvoid Sin_ResetMapLoading(void)\n{\n\t//reset for map loading from bsp\n\tmemset(nodestack, 0, NODESTACKSIZE * sizeof(int));\n\tnodestackptr = NULL;\n\tnodestacksize = 0;\n\tmemset(brushmodelnumbers, 0, MAX_MAPFILE_BRUSHES * sizeof(int));\n} //end of the function Sin_ResetMapLoading\n\n//End MAP loading from BSP file\n\n#endif //ME\n"
  },
  {
    "path": "code/bspc/nodraw.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n\nvec3_t draw_mins, draw_maxs;\nqboolean\tdrawflag;\n\nvoid Draw_ClearWindow (void)\n{\n}\n\n//============================================================\n\n#define\tGLSERV_PORT\t25001\n\n\nvoid GLS_BeginScene (void)\n{\n}\n\nvoid GLS_Winding (winding_t *w, int code)\n{\n}\n\nvoid GLS_EndScene (void)\n{\n}\n"
  },
  {
    "path": "code/bspc/portals.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n#include \"l_mem.h\"\n\nint\t\tc_active_portals;\nint\t\tc_peak_portals;\nint\t\tc_boundary;\nint\t\tc_boundary_sides;\nint\t\tc_portalmemory;\n\n//portal_t *portallist = NULL;\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nportal_t *AllocPortal (void)\n{\n\tportal_t\t*p;\n\t\n\tp = GetMemory(sizeof(portal_t));\n\tmemset (p, 0, sizeof(portal_t));\n\n\tif (numthreads == 1)\n\t{\n\t\tc_active_portals++;\n\t\tif (c_active_portals > c_peak_portals)\n\t\t{\n\t\t\tc_peak_portals = c_active_portals;\n\t\t} //end if\n\t\tc_portalmemory += MemorySize(p);\t\n\t} //end if\n\n//\tp->nextportal = portallist;\n//\tportallist = p;\n\t\n\treturn p;\n} //end of the function AllocPortal\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid FreePortal (portal_t *p)\n{\n\tif (p->winding) FreeWinding(p->winding);\n\tif (numthreads == 1)\n\t{\n\t\tc_active_portals--;\n\t\tc_portalmemory -= MemorySize(p);\n\t} //end if\n\tFreeMemory(p);\n} //end of the function FreePortal\n//===========================================================================\n// Returns the single content bit of the\n// strongest visible content present\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint VisibleContents (int contents)\n{\n\tint\t\ti;\n\n\tfor (i=1 ; i<=LAST_VISIBLE_CONTENTS ; i<<=1)\n\t\tif (contents & i )\n\t\t\treturn i;\n\n\treturn 0;\n} //end of the function VisibleContents\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint ClusterContents (node_t *node)\n{\n\tint\t\tc1, c2, c;\n\n\tif (node->planenum == PLANENUM_LEAF)\n\t\treturn node->contents;\n\n\tc1 = ClusterContents(node->children[0]);\n\tc2 = ClusterContents(node->children[1]);\n\tc = c1|c2;\n\n\t// a cluster may include some solid detail areas, but\n\t// still be seen into\n\tif ( ! (c1&CONTENTS_SOLID) || ! (c2&CONTENTS_SOLID) )\n\t\tc &= ~CONTENTS_SOLID;\n\treturn c;\n} //end of the function ClusterContents\n\n//===========================================================================\n// Returns true if the portal is empty or translucent, allowing\n// the PVS calculation to see through it.\n// The nodes on either side of the portal may actually be clusters,\n// not leaves, so all contents should be ored together\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean Portal_VisFlood (portal_t *p)\n{\n\tint\t\tc1, c2;\n\n\tif (!p->onnode)\n\t\treturn false;\t// to global outsideleaf\n\n\tc1 = ClusterContents(p->nodes[0]);\n\tc2 = ClusterContents(p->nodes[1]);\n\n\tif (!VisibleContents (c1^c2))\n\t\treturn true;\n\n\tif (c1 & (CONTENTS_Q2TRANSLUCENT|CONTENTS_DETAIL))\n\t\tc1 = 0;\n\tif (c2 & (CONTENTS_Q2TRANSLUCENT|CONTENTS_DETAIL))\n\t\tc2 = 0;\n\n\tif ( (c1|c2) & CONTENTS_SOLID )\n\t\treturn false;\t\t// can't see through solid\n\n\tif (! (c1 ^ c2))\n\t\treturn true;\t\t// identical on both sides\n\n\tif (!VisibleContents (c1^c2))\n\t\treturn true;\n\treturn false;\n} //end of the function Portal_VisFlood\n//===========================================================================\n// The entity flood determines which areas are\n// \"outside\" on the map, which are then filled in.\n// Flowing from side s to side !s\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean Portal_EntityFlood (portal_t *p, int s)\n{\n\tif (p->nodes[0]->planenum != PLANENUM_LEAF\n\t\t|| p->nodes[1]->planenum != PLANENUM_LEAF)\n\t\tError (\"Portal_EntityFlood: not a leaf\");\n\n\t// can never cross to a solid \n\tif ( (p->nodes[0]->contents & CONTENTS_SOLID)\n\t|| (p->nodes[1]->contents & CONTENTS_SOLID) )\n\t\treturn false;\n\n\t// can flood through everything else\n\treturn true;\n}\n\n\n//=============================================================================\n\nint\t\tc_tinyportals;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid AddPortalToNodes (portal_t *p, node_t *front, node_t *back)\n{\n\tif (p->nodes[0] || p->nodes[1])\n\t\tError (\"AddPortalToNode: allready included\");\n\n\tp->nodes[0] = front;\n\tp->next[0] = front->portals;\n\tfront->portals = p;\n\t\n\tp->nodes[1] = back;\n\tp->next[1] = back->portals;\n\tback->portals = p;\n} //end of the function AddPortalToNodes\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid RemovePortalFromNode (portal_t *portal, node_t *l)\n{\n\tportal_t\t**pp, *t;\n\n\tint s, i, n;\n\tportal_t *p;\n\tportal_t *portals[4096];\n\t\n// remove reference to the current portal\n\tpp = &l->portals;\n\twhile (1)\n\t{\n\t\tt = *pp;\n\t\tif (!t)\n\t\t\tError (\"RemovePortalFromNode: portal not in leaf\");\t\n\n\t\tif ( t == portal )\n\t\t\tbreak;\n\n\t\tif (t->nodes[0] == l)\n\t\t\tpp = &t->next[0];\n\t\telse if (t->nodes[1] == l)\n\t\t\tpp = &t->next[1];\n\t\telse\n\t\t\tError (\"RemovePortalFromNode: portal not bounding leaf\");\n\t}\n\t\n\tif (portal->nodes[0] == l)\n\t{\n\t\t*pp = portal->next[0];\n\t\tportal->nodes[0] = NULL;\n\t} //end if\n\telse if (portal->nodes[1] == l)\n\t{\n\t\t*pp = portal->next[1];\t\n\t\tportal->nodes[1] = NULL;\n\t} //end else if\n\telse\n\t{\n\t\tError(\"RemovePortalFromNode: mislinked portal\");\n\t} //end else\n//#ifdef ME\n\tn = 0;\n\tfor (p = l->portals; p; p = p->next[s])\n\t{\n\t\tfor (i = 0; i < n; i++)\n\t\t{\n\t\t\tif (p == portals[i]) Error(\"RemovePortalFromNode: circular linked\\n\");\n\t\t} //end for\n\t\tif (p->nodes[0] != l && p->nodes[1] != l)\n\t\t{\n\t\t\tError(\"RemovePortalFromNodes: portal does not belong to node\\n\");\n\t\t} //end if\n\t\tportals[n] = p;\n\t\ts = (p->nodes[1] == l);\n//\t\tif (++n >= 4096) Error(\"RemovePortalFromNode: more than 4096 portals\\n\");\n\t} //end for\n//#endif\n} //end of the function RemovePortalFromNode\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid PrintPortal (portal_t *p)\n{\n\tint\t\t\ti;\n\twinding_t\t*w;\n\t\n\tw = p->winding;\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\tprintf (\"(%5.0f,%5.0f,%5.0f)\\n\",w->p[i][0]\n\t\t, w->p[i][1], w->p[i][2]);\n} //end of the function PrintPortal\n//===========================================================================\n// The created portals will face the global outside_node\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#define\tSIDESPACE\t8\n\nvoid MakeHeadnodePortals (tree_t *tree)\n{\n\tvec3_t\t\tbounds[2];\n\tint\t\t\ti, j, n;\n\tportal_t\t*p, *portals[6];\n\tplane_t\t\tbplanes[6], *pl;\n\tnode_t *node;\n\n\tnode = tree->headnode;\n\n// pad with some space so there will never be null volume leaves\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tbounds[0][i] = tree->mins[i] - SIDESPACE;\n\t\tbounds[1][i] = tree->maxs[i] + SIDESPACE;\n\t\tif ( bounds[0][i] > bounds[1][i] ) {\n\t\t\tError(\"empty BSP tree\");\n\t\t}\n\t}\n\t\n\ttree->outside_node.planenum = PLANENUM_LEAF;\n\ttree->outside_node.brushlist = NULL;\n\ttree->outside_node.portals = NULL;\n\ttree->outside_node.contents = 0;\n\n\tfor (i=0 ; i<3 ; i++)\n\t\tfor (j=0 ; j<2 ; j++)\n\t\t{\n\t\t\tn = j*3 + i;\n\n\t\t\tp = AllocPortal ();\n\t\t\tportals[n] = p;\n\t\t\t\n\t\t\tpl = &bplanes[n];\n\t\t\tmemset (pl, 0, sizeof(*pl));\n\t\t\tif (j)\n\t\t\t{\n\t\t\t\tpl->normal[i] = -1;\n\t\t\t\tpl->dist = -bounds[j][i];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tpl->normal[i] = 1;\n\t\t\t\tpl->dist = bounds[j][i];\n\t\t\t}\n\t\t\tp->plane = *pl;\n\t\t\tp->winding = BaseWindingForPlane (pl->normal, pl->dist);\n\t\t\tAddPortalToNodes (p, node, &tree->outside_node);\n\t\t}\n\t\t\n// clip the basewindings by all the other planes\n\tfor (i=0 ; i<6 ; i++)\n\t{\n\t\tfor (j=0 ; j<6 ; j++)\n\t\t{\n\t\t\tif (j == i) continue;\n\t\t\tChopWindingInPlace (&portals[i]->winding, bplanes[j].normal, bplanes[j].dist, ON_EPSILON);\n\t\t} //end for\n\t} //end for\n} //end of the function MakeHeadNodePortals\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#define\tBASE_WINDING_EPSILON\t\t0.001\n#define\tSPLIT_WINDING_EPSILON\t0.001\n\nwinding_t *BaseWindingForNode (node_t *node)\n{\n\twinding_t\t*w;\n\tnode_t\t\t*n;\n\tplane_t\t\t*plane;\n\tvec3_t\t\tnormal;\n\tvec_t\t\tdist;\n\n\tw = BaseWindingForPlane (mapplanes[node->planenum].normal\n\t\t, mapplanes[node->planenum].dist);\n\n\t// clip by all the parents\n\tfor (n=node->parent ; n && w ; )\n\t{\n\t\tplane = &mapplanes[n->planenum];\n\n\t\tif (n->children[0] == node)\n\t\t{\t// take front\n\t\t\tChopWindingInPlace (&w, plane->normal, plane->dist, BASE_WINDING_EPSILON);\n\t\t}\n\t\telse\n\t\t{\t// take back\n\t\t\tVectorSubtract (vec3_origin, plane->normal, normal);\n\t\t\tdist = -plane->dist;\n\t\t\tChopWindingInPlace (&w, normal, dist, BASE_WINDING_EPSILON);\n\t\t}\n\t\tnode = n;\n\t\tn = n->parent;\n\t}\n\n\treturn w;\n} //end of the function BaseWindingForNode\n//===========================================================================\n// create the new portal by taking the full plane winding for the cutting\n// plane and clipping it by all of parents of this node\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean WindingIsTiny (winding_t *w);\n\nvoid MakeNodePortal (node_t *node)\n{\n\tportal_t\t*new_portal, *p;\n\twinding_t\t*w;\n\tvec3_t\t\tnormal;\n\tfloat\t\tdist;\n\tint\t\t\tside;\n\n\tw = BaseWindingForNode (node);\n\n\t// clip the portal by all the other portals in the node\n\tfor (p = node->portals; p && w; p = p->next[side])\t\n\t{\n\t\tif (p->nodes[0] == node)\n\t\t{\n\t\t\tside = 0;\n\t\t\tVectorCopy (p->plane.normal, normal);\n\t\t\tdist = p->plane.dist;\n\t\t} //end if\n\t\telse if (p->nodes[1] == node)\n\t\t{\n\t\t\tside = 1;\n\t\t\tVectorSubtract (vec3_origin, p->plane.normal, normal);\n\t\t\tdist = -p->plane.dist;\n\t\t} //end else if\n\t\telse\n\t\t{\n\t\t\tError (\"MakeNodePortal: mislinked portal\");\n\t\t} //end else\n\t\tChopWindingInPlace (&w, normal, dist, 0.1);\n\t} //end for\n\n\tif (!w)\n\t{\n\t\treturn;\n\t} //end if\n\n\tif (WindingIsTiny (w))\n\t{\n\t\tc_tinyportals++;\n\t\tFreeWinding(w);\n\t\treturn;\n\t} //end if\n\n#ifdef DEBUG\n/* //NOTE: don't use this winding ok check\n\t// all the invalid windings only have a degenerate edge\n\tif (WindingError(w))\n\t{\n\t\tLog_Print(\"MakeNodePortal: %s\\n\", WindingErrorString());\n\t\tFreeWinding(w);\n\t\treturn;\n\t} //end if*/\n#endif //DEBUG\n\n\n\tnew_portal = AllocPortal();\n\tnew_portal->plane = mapplanes[node->planenum];\n\n#ifdef ME\n\tnew_portal->planenum = node->planenum;\n#endif //ME\n\n\tnew_portal->onnode = node;\n\tnew_portal->winding = w;\n\tAddPortalToNodes (new_portal, node->children[0], node->children[1]);\n} //end of the function MakeNodePortal\n//===========================================================================\n// Move or split the portals that bound node so that the node's\n// children have portals instead of node.\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid SplitNodePortals (node_t *node)\n{\n\tportal_t\t*p, *next_portal, *new_portal;\n\tnode_t *f, *b, *other_node;\n\tint side;\n\tplane_t *plane;\n\twinding_t *frontwinding, *backwinding;\n\n\tplane = &mapplanes[node->planenum];\n\tf = node->children[0];\n\tb = node->children[1];\n\n\tfor (p = node->portals ; p ; p = next_portal)\t\n\t{\n\t\tif (p->nodes[0] == node) side = 0;\n\t\telse if (p->nodes[1] == node) side = 1;\n\t\telse Error (\"SplitNodePortals: mislinked portal\");\n\t\tnext_portal = p->next[side];\n\n\t\tother_node = p->nodes[!side];\n\t\tRemovePortalFromNode (p, p->nodes[0]);\n\t\tRemovePortalFromNode (p, p->nodes[1]);\n\n//\n// cut the portal into two portals, one on each side of the cut plane\n//\n\t\tClipWindingEpsilon (p->winding, plane->normal, plane->dist,\n\t\t\t\tSPLIT_WINDING_EPSILON, &frontwinding, &backwinding);\n\n\t\tif (frontwinding && WindingIsTiny(frontwinding))\n\t\t{\n\t\t\tFreeWinding (frontwinding);\n\t\t\tfrontwinding = NULL;\n\t\t\tc_tinyportals++;\n\t\t} //end if\n\n\t\tif (backwinding && WindingIsTiny(backwinding))\n\t\t{\n\t\t\tFreeWinding (backwinding);\n\t\t\tbackwinding = NULL;\n\t\t\tc_tinyportals++;\n\t\t} //end if\n\n#ifdef DEBUG\n/* \t//NOTE: don't use this winding ok check\n\t\t// all the invalid windings only have a degenerate edge\n\t\tif (frontwinding && WindingError(frontwinding))\n\t\t{\n\t\t\tLog_Print(\"SplitNodePortals: front %s\\n\", WindingErrorString());\n\t\t\tFreeWinding(frontwinding);\n\t\t\tfrontwinding = NULL;\n\t\t} //end if\n\t\tif (backwinding && WindingError(backwinding))\n\t\t{\n\t\t\tLog_Print(\"SplitNodePortals: back %s\\n\", WindingErrorString());\n\t\t\tFreeWinding(backwinding);\n\t\t\tbackwinding = NULL;\n\t\t} //end if*/\n#endif //DEBUG\n\n\t\tif (!frontwinding && !backwinding)\n\t\t{\t// tiny windings on both sides\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!frontwinding)\n\t\t{\n\t\t\tFreeWinding (backwinding);\n\t\t\tif (side == 0) AddPortalToNodes (p, b, other_node);\n\t\t\telse AddPortalToNodes (p, other_node, b);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!backwinding)\n\t\t{\n\t\t\tFreeWinding (frontwinding);\n\t\t\tif (side == 0) AddPortalToNodes (p, f, other_node);\n\t\t\telse AddPortalToNodes (p, other_node, f);\n\t\t\tcontinue;\n\t\t}\n\t\t\n\t// the winding is split\n\t\tnew_portal = AllocPortal();\n\t\t*new_portal = *p;\n\t\tnew_portal->winding = backwinding;\n\t\tFreeWinding (p->winding);\n\t\tp->winding = frontwinding;\n\n\t\tif (side == 0)\n\t\t{\n\t\t\tAddPortalToNodes (p, f, other_node);\n\t\t\tAddPortalToNodes (new_portal, b, other_node);\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tAddPortalToNodes (p, other_node, f);\n\t\t\tAddPortalToNodes (new_portal, other_node, b);\n\t\t} //end else\n\t}\n\n\tnode->portals = NULL;\n} //end of the function SplitNodePortals\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid CalcNodeBounds (node_t *node)\n{\n\tportal_t\t*p;\n\tint\t\t\ts;\n\tint\t\t\ti;\n\n\t// calc mins/maxs for both leaves and nodes\n\tClearBounds (node->mins, node->maxs);\n\tfor (p = node->portals ; p ; p = p->next[s])\t\n\t{\n\t\ts = (p->nodes[1] == node);\n\t\tfor (i=0 ; i<p->winding->numpoints ; i++)\n\t\t\tAddPointToBounds (p->winding->p[i], node->mins, node->maxs);\n\t}\n} //end of the function CalcNodeBounds\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint c_numportalizednodes;\n\nvoid MakeTreePortals_r (node_t *node)\n{\n\tint\t\ti;\n\n#ifdef ME\n\tqprintf(\"\\r%6d\", ++c_numportalizednodes);\n\tif (cancelconversion) return;\n#endif //ME\n\n\tCalcNodeBounds (node);\n\tif (node->mins[0] >= node->maxs[0])\n\t{\n\t\tLog_Print(\"WARNING: node without a volume\\n\");\n\t}\n\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tif (node->mins[i] < -MAX_MAP_BOUNDS || node->maxs[i] > MAX_MAP_BOUNDS)\n\t\t{\n\t\t\tLog_Print(\"WARNING: node with unbounded volume\\n\");\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (node->planenum == PLANENUM_LEAF)\n\t\treturn;\n\n\tMakeNodePortal (node);\n\tSplitNodePortals (node);\n\n\tMakeTreePortals_r (node->children[0]);\n\tMakeTreePortals_r (node->children[1]);\n} //end of the function MakeTreePortals_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid MakeTreePortals(tree_t *tree)\n{\n\n#ifdef ME\n\tLog_Print(\"---- Node Portalization ----\\n\");\n\tc_numportalizednodes = 0;\n\tc_portalmemory = 0;\n\tqprintf(\"%6d nodes portalized\", c_numportalizednodes);\n#endif //ME\n\n\tMakeHeadnodePortals(tree);\n\tMakeTreePortals_r(tree->headnode);\n\n#ifdef ME\n\tqprintf(\"\\n\");\n\tLog_Write(\"%6d nodes portalized\\r\\n\", c_numportalizednodes);\n\tLog_Print(\"%6d tiny portals\\r\\n\", c_tinyportals);\n\tLog_Print(\"%6d KB of portal memory\\r\\n\", c_portalmemory >> 10);\n\tLog_Print(\"%6i KB of winding memory\\r\\n\", WindingMemory() >> 10);\n#endif //ME\n} //end of the function MakeTreePortals\n\n/*\n=========================================================\n\nFLOOD ENTITIES\n\n=========================================================\n*/\n//#define P_NODESTACK\n\nnode_t *p_firstnode;\nnode_t *p_lastnode;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n#ifdef P_NODESTACK\nvoid P_AddNodeToList(node_t *node)\n{\n\tnode->next = p_firstnode;\n\tp_firstnode = node;\n\tif (!p_lastnode) p_lastnode = node;\n} //end of the function P_AddNodeToList\n#else //it's a node queue\n//add the node to the end of the node list\nvoid P_AddNodeToList(node_t *node)\n{\n\tnode->next = NULL;\n\tif (p_lastnode) p_lastnode->next = node;\n\telse p_firstnode = node;\n\tp_lastnode = node;\n} //end of the function P_AddNodeToList\n#endif //P_NODESTACK\n//===========================================================================\n// get the first node from the front of the node list\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nnode_t *P_NextNodeFromList(void)\n{\n\tnode_t *node;\n\n\tnode = p_firstnode;\n\tif (p_firstnode) p_firstnode = p_firstnode->next;\n\tif (!p_firstnode) p_lastnode = NULL;\n\treturn node;\n} //end of the function P_NextNodeFromList\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid FloodPortals(node_t *firstnode)\n{\n\tnode_t *node;\n\tportal_t *p;\n\tint s;\n\n\tfirstnode->occupied = 1;\n\tP_AddNodeToList(firstnode);\n\n\tfor (node = P_NextNodeFromList(); node; node = P_NextNodeFromList())\n\t{\n\t\tfor (p = node->portals; p; p = p->next[s])\n\t\t{\n\t\t\ts = (p->nodes[1] == node);\n\t\t\t//if the node at the other side of the portal is occupied already\n\t\t\tif (p->nodes[!s]->occupied) continue;\n\t\t\t//if it isn't possible to flood through this portal\n\t\t\tif (!Portal_EntityFlood(p, s)) continue;\n\t\t\t//\n\t\t\tp->nodes[!s]->occupied = node->occupied + 1;\n\t\t\t//\n\t\t\tP_AddNodeToList(p->nodes[!s]);\n\t\t} //end for\n\t} //end for\n} //end of the function FloodPortals\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint numrec;\n\nvoid FloodPortals_r (node_t *node, int dist)\n{\n\tportal_t *p;\n\tint s;\n//\tint i;\n\n\tLog_Print(\"\\r%6d\", ++numrec);\n\n\tif (node->occupied) Error(\"FloodPortals_r: node already occupied\\n\");\n\tif (!node)\n\t{\n\t\tError(\"FloodPortals_r: NULL node\\n\");\n\t} //end if*/\n\tnode->occupied = dist;\n\n\tfor (p = node->portals; p; p = p->next[s])\n\t{\n\t\ts = (p->nodes[1] == node);\n\t\t//if the node at the other side of the portal is occupied already\n\t\tif (p->nodes[!s]->occupied) continue;\n\t\t//if it isn't possible to flood through this portal\n\t\tif (!Portal_EntityFlood(p, s)) continue;\n\t\t//flood recursively through the current portal\n\t\tFloodPortals_r(p->nodes[!s], dist+1);\n\t} //end for\n\tLog_Print(\"\\r%6d\", --numrec);\n} //end of the function FloodPortals_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean PlaceOccupant (node_t *headnode, vec3_t origin, entity_t *occupant)\n{\n\tnode_t *node;\n\tvec_t\td;\n\tplane_t *plane;\n\n\t//find the leaf to start in\n\tnode = headnode;\n\twhile(node->planenum != PLANENUM_LEAF)\n\t{\n\t\tif (node->planenum < 0 || node->planenum > nummapplanes)\n\t\t{\n\t\t\tError(\"PlaceOccupant: invalid node->planenum\\n\");\n\t\t} //end if\n\t\tplane = &mapplanes[node->planenum];\n\t\td = DotProduct(origin, plane->normal) - plane->dist;\n\t\tif (d >= 0) node = node->children[0];\n\t\telse node = node->children[1];\n\t\tif (!node)\n\t\t{\n\t\t\tError(\"PlaceOccupant: invalid child %d\\n\", d < 0);\n\t\t} //end if\n\t} //end while\n\t//don't start in solid\n//\tif (node->contents == CONTENTS_SOLID)\n\t//ME: replaced because in LeafNode in brushbsp.c\n\t//    some nodes have contents solid with other contents\n\tif (node->contents & CONTENTS_SOLID) return false;\n\t//if the node is already occupied\n\tif (node->occupied) return false;\n\n\t//place the occupant in the first leaf\n\tnode->occupant = occupant;\n\n\tnumrec = 0;\n//\tLog_Print(\"%6d recurses\", numrec);\n//\tFloodPortals_r(node, 1);\n//\tLog_Print(\"\\n\");\n\tFloodPortals(node);\n\n\treturn true;\n} //end of the function PlaceOccupant\n//===========================================================================\n// Marks all nodes that can be reached by entites\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean FloodEntities (tree_t *tree)\n{\n\tint i;\n\tint x, y;\n\tvec3_t origin;\n\tchar *cl;\n\tqboolean inside;\n\tnode_t *headnode;\n\n\theadnode = tree->headnode;\n\tLog_Print(\"------ FloodEntities -------\\n\");\n\tinside = false;\n\ttree->outside_node.occupied = 0;\n\n\t//start at entity 1 not the world ( = 0)\n\tfor (i = 1; i < num_entities; i++)\n\t{\n\t\tGetVectorForKey(&entities[i], \"origin\", origin);\n\t\tif (VectorCompare(origin, vec3_origin)) continue;\n\n\t\tcl = ValueForKey(&entities[i], \"classname\");\n\t\torigin[2] += 1;\t//so objects on floor are ok\n\n//\t\tLog_Print(\"flooding from entity %d: %s\\n\", i, cl);\n\t\t//nudge playerstart around if needed so clipping hulls allways\n\t\t//have a valid point\n\t\tif (!strcmp(cl, \"info_player_start\"))\n\t\t{\n\t\t\tfor (x = -16; x <= 16; x += 16)\n\t\t\t{\n\t\t\t\tfor (y = -16; y <= 16; y += 16)\n\t\t\t\t{\n\t\t\t\t\torigin[0] += x;\n\t\t\t\t\torigin[1] += y;\n\t\t\t\t\tif (PlaceOccupant(headnode, origin, &entities[i]))\n\t\t\t\t\t{\n\t\t\t\t\t\tinside = true;\n\t\t\t\t\t\tx = 999; //stop for this info_player_start\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} //end if\n\t\t\t\t\torigin[0] -= x;\n\t\t\t\t\torigin[1] -= y;\n\t\t\t\t} //end for\n\t\t\t} //end for\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tif (PlaceOccupant(headnode, origin, &entities[i]))\n\t\t\t{\n\t\t\t\tinside = true;\n\t\t\t} //end if\n\t\t} //end else\n\t} //end for\n\n\tif (!inside)\n\t{\n\t\tLog_Print(\"WARNING: no entities inside\\n\");\n\t} //end if\n\telse if (tree->outside_node.occupied)\n\t{\n\t\tLog_Print(\"WARNING: entity reached from outside\\n\");\n\t} //end else if\n\n\treturn (qboolean)(inside && !tree->outside_node.occupied);\n} //end of the function FloodEntities\n\n/*\n=========================================================\n\nFILL OUTSIDE\n\n=========================================================\n*/\n\nint c_outside;\nint c_inside;\nint c_solid;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid FillOutside_r (node_t *node)\n{\n\tif (node->planenum != PLANENUM_LEAF)\n\t{\n\t\tFillOutside_r (node->children[0]);\n\t\tFillOutside_r (node->children[1]);\n\t\treturn;\n\t} //end if\n\t// anything not reachable by an entity\n\t// can be filled away (by setting solid contents)\n\tif (!node->occupied)\n\t{\n\t\tif (!(node->contents & CONTENTS_SOLID))\n\t\t{\n\t\t\tc_outside++;\n\t\t\tnode->contents |= CONTENTS_SOLID;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tc_solid++;\n\t\t} //end else\n\t} //end if\n\telse\n\t{\n\t\tc_inside++;\n\t} //end else\n} //end of the function FillOutside_r\n//===========================================================================\n// Fill all nodes that can't be reached by entities\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid FillOutside (node_t *headnode)\n{\n\tc_outside = 0;\n\tc_inside = 0;\n\tc_solid = 0;\n\tLog_Print(\"------- FillOutside --------\\n\");\n\tFillOutside_r (headnode);\n\tLog_Print(\"%5i solid leaves\\n\", c_solid);\n\tLog_Print(\"%5i leaves filled\\n\", c_outside);\n\tLog_Print(\"%5i inside leaves\\n\", c_inside);\n} //end of the function FillOutside\n\n/*\n=========================================================\n\nFLOOD AREAS\n\n=========================================================\n*/\n\nint\t\tc_areas;\n\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid FloodAreas_r (node_t *node)\n{\n\tportal_t\t*p;\n\tint\t\t\ts;\n\tbspbrush_t\t*b;\n\tentity_t\t*e;\n\n\tif (node->contents == CONTENTS_AREAPORTAL)\n\t{\n\t\t// this node is part of an area portal\n\t\tb = node->brushlist;\n\t\te = &entities[b->original->entitynum];\n\n\t\t// if the current area has allready touched this\n\t\t// portal, we are done\n\t\tif (e->portalareas[0] == c_areas || e->portalareas[1] == c_areas)\n\t\t\treturn;\n\n\t\t// note the current area as bounding the portal\n\t\tif (e->portalareas[1])\n\t\t{\n\t\t\tLog_Print(\"WARNING: areaportal entity %i touches > 2 areas\\n\", b->original->entitynum);\n\t\t\treturn;\n\t\t}\n\t\tif (e->portalareas[0])\n\t\t\te->portalareas[1] = c_areas;\n\t\telse\n\t\t\te->portalareas[0] = c_areas;\n\n\t\treturn;\n\t} //end if\n\n\tif (node->area)\n\t\treturn;\t\t// allready got it\n\tnode->area = c_areas;\n\n\tfor (p=node->portals ; p ; p = p->next[s])\n\t{\n\t\ts = (p->nodes[1] == node);\n#if 0\n\t\tif (p->nodes[!s]->occupied)\n\t\t\tcontinue;\n#endif\n\t\tif (!Portal_EntityFlood (p, s))\n\t\t\tcontinue;\n\n\t\tFloodAreas_r (p->nodes[!s]);\n\t} //end for\n} //end of the function FloodAreas_r\n//===========================================================================\n// Just decend the tree, and for each node that hasn't had an\n// area set, flood fill out from there\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid FindAreas_r (node_t *node)\n{\n\tif (node->planenum != PLANENUM_LEAF)\n\t{\n\t\tFindAreas_r (node->children[0]);\n\t\tFindAreas_r (node->children[1]);\n\t\treturn;\n\t}\n\n\tif (node->area)\n\t\treturn;\t\t// allready got it\n\n\tif (node->contents & CONTENTS_SOLID)\n\t\treturn;\n\n\tif (!node->occupied)\n\t\treturn;\t\t\t// not reachable by entities\n\n\t// area portals are allways only flooded into, never\n\t// out of\n\tif (node->contents == CONTENTS_AREAPORTAL)\n\t\treturn;\n\n\tc_areas++;\n\tFloodAreas_r (node);\n} //end of the function FindAreas_r\n//===========================================================================\n// Just decend the tree, and for each node that hasn't had an\n// area set, flood fill out from there\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid SetAreaPortalAreas_r (node_t *node)\n{\n\tbspbrush_t\t*b;\n\tentity_t\t*e;\n\n\tif (node->planenum != PLANENUM_LEAF)\n\t{\n\t\tSetAreaPortalAreas_r (node->children[0]);\n\t\tSetAreaPortalAreas_r (node->children[1]);\n\t\treturn;\n\t} //end if\n\n\tif (node->contents == CONTENTS_AREAPORTAL)\n\t{\n\t\tif (node->area)\n\t\t\treturn;\t\t// allready set\n\n\t\tb = node->brushlist;\n\t\te = &entities[b->original->entitynum];\n\t\tnode->area = e->portalareas[0];\n\t\tif (!e->portalareas[1])\n\t\t{\n\t\t\tLog_Print(\"WARNING: areaportal entity %i doesn't touch two areas\\n\", b->original->entitynum);\n\t\t\treturn;\n\t\t} //end if\n\t} //end if\n} //end of the function SetAreaPortalAreas_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\n/*\nvoid EmitAreaPortals(node_t *headnode)\n{\n\tint\t\t\t\ti, j;\n\tentity_t\t\t*e;\n\tdareaportal_t\t*dp;\n\n\tif (c_areas > MAX_MAP_AREAS)\n\t\tError (\"MAX_MAP_AREAS\");\n\tnumareas = c_areas+1;\n\tnumareaportals = 1;\t\t// leave 0 as an error\n\n\tfor (i=1 ; i<=c_areas ; i++)\n\t{\n\t\tdareas[i].firstareaportal = numareaportals;\n\t\tfor (j=0 ; j<num_entities ; j++)\n\t\t{\n\t\t\te = &entities[j];\n\t\t\tif (!e->areaportalnum)\n\t\t\t\tcontinue;\n\t\t\tdp = &dareaportals[numareaportals];\n\t\t\tif (e->portalareas[0] == i)\n\t\t\t{\n\t\t\t\tdp->portalnum = e->areaportalnum;\n\t\t\t\tdp->otherarea = e->portalareas[1];\n\t\t\t\tnumareaportals++;\n\t\t\t} //end if\n\t\t\telse if (e->portalareas[1] == i)\n\t\t\t{\n\t\t\t\tdp->portalnum = e->areaportalnum;\n\t\t\t\tdp->otherarea = e->portalareas[0];\n\t\t\t\tnumareaportals++;\n\t\t\t} //end else if\n\t\t} //end for\n\t\tdareas[i].numareaportals = numareaportals - dareas[i].firstareaportal;\n\t} //end for\n\n\tLog_Print(\"%5i numareas\\n\", numareas);\n\tLog_Print(\"%5i numareaportals\\n\", numareaportals);\n} //end of the function EmitAreaPortals\n*/\n//===========================================================================\n// Mark each leaf with an area, bounded by CONTENTS_AREAPORTAL\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid FloodAreas (tree_t *tree)\n{\n\tLog_Print(\"--- FloodAreas ---\\n\");\n\tFindAreas_r (tree->headnode);\n\tSetAreaPortalAreas_r (tree->headnode);\n\tLog_Print(\"%5i areas\\n\", c_areas);\n} //end of the function FloodAreas\n//===========================================================================\n// Finds a brush side to use for texturing the given portal\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid FindPortalSide (portal_t *p)\n{\n\tint\t\t\tviscontents;\n\tbspbrush_t\t*bb;\n\tmapbrush_t\t*brush;\n\tnode_t\t\t*n;\n\tint\t\t\ti,j;\n\tint\t\t\tplanenum;\n\tside_t\t\t*side, *bestside;\n\tfloat\t\tdot, bestdot;\n\tplane_t\t\t*p1, *p2;\n\n\t// decide which content change is strongest\n\t// solid > lava > water, etc\n\tviscontents = VisibleContents (p->nodes[0]->contents ^ p->nodes[1]->contents);\n\tif (!viscontents)\n\t\treturn;\n\n\tplanenum = p->onnode->planenum;\n\tbestside = NULL;\n\tbestdot = 0;\n\n\tfor (j=0 ; j<2 ; j++)\n\t{\n\t\tn = p->nodes[j];\n\t\tp1 = &mapplanes[p->onnode->planenum];\n\t\tfor (bb=n->brushlist ; bb ; bb=bb->next)\n\t\t{\n\t\t\tbrush = bb->original;\n\t\t\tif ( !(brush->contents & viscontents) )\n\t\t\t\tcontinue;\n\t\t\tfor (i=0 ; i<brush->numsides ; i++)\n\t\t\t{\n\t\t\t\tside = &brush->original_sides[i];\n\t\t\t\tif (side->flags & SFL_BEVEL)\n\t\t\t\t\tcontinue;\n\t\t\t\tif (side->texinfo == TEXINFO_NODE)\n\t\t\t\t\tcontinue;\t\t// non-visible\n\t\t\t\tif ((side->planenum&~1) == planenum)\n\t\t\t\t{\t// exact match\n\t\t\t\t\tbestside = &brush->original_sides[i];\n\t\t\t\t\tgoto gotit;\n\t\t\t\t} //end if\n\t\t\t\t// see how close the match is\n\t\t\t\tp2 = &mapplanes[side->planenum&~1];\n\t\t\t\tdot = DotProduct (p1->normal, p2->normal);\n\t\t\t\tif (dot > bestdot)\n\t\t\t\t{\n\t\t\t\t\tbestdot = dot;\n\t\t\t\t\tbestside = side;\n\t\t\t\t} //end if\n\t\t\t} //end for\n\t\t} //end for\n\t} //end for\n\ngotit:\n\tif (!bestside)\n\t\tLog_Print(\"WARNING: side not found for portal\\n\");\n\n\tp->sidefound = true;\n\tp->side = bestside;\n} //end of the function FindPortalSide\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid MarkVisibleSides_r (node_t *node)\n{\n\tportal_t *p;\n\tint s;\n\n\tif (node->planenum != PLANENUM_LEAF)\n\t{\n\t\tMarkVisibleSides_r (node->children[0]);\n\t\tMarkVisibleSides_r (node->children[1]);\n\t\treturn;\n\t} //end if\n\n\t// empty leaves are never boundary leaves\n\tif (!node->contents) return;\n\n\t// see if there is a visible face\n\tfor (p=node->portals ; p ; p = p->next[!s])\n\t{\n\t\ts = (p->nodes[0] == node);\n\t\tif (!p->onnode)\n\t\t\tcontinue;\t\t// edge of world\n\t\tif (!p->sidefound)\n\t\t\tFindPortalSide (p);\n\t\tif (p->side)\n\t\t\tp->side->flags |= SFL_VISIBLE;\n\t} //end for\n} //end of the function MarkVisibleSides_r\n//===========================================================================\n//\n// Parameter:\t\t\t\t-\n// Returns:\t\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid MarkVisibleSides(tree_t *tree, int startbrush, int endbrush)\n{\n\tint\t\ti, j;\n\tmapbrush_t\t*mb;\n\tint\t\tnumsides;\n\n\tLog_Print(\"--- MarkVisibleSides ---\\n\");\n\n\t// clear all the visible flags\n\tfor (i=startbrush ; i<endbrush ; i++)\n\t{\n\t\tmb = &mapbrushes[i];\n\n\t\tnumsides = mb->numsides;\n\t\tfor (j=0 ; j<numsides ; j++)\n\t\t\tmb->original_sides[j].flags &= ~SFL_VISIBLE;\n\t}\n\n\t// set visible flags on the sides that are used by portals\n\tMarkVisibleSides_r (tree->headnode);\n} //end of the function MarkVisibleSides\n\n"
  },
  {
    "path": "code/bspc/prtfile.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n\n/*\n==============================================================================\n\nPORTAL FILE GENERATION\n\nSave out name.prt for qvis to read\n==============================================================================\n*/\n\n\n#define\tPORTALFILE\t\"PRT1\"\n\nFILE\t*pf;\nint\t\tnum_visclusters;\t\t\t\t// clusters the player can be in\nint\t\tnum_visportals;\n\nvoid WriteFloat2 (FILE *f, vec_t v)\n{\n\tif ( fabs(v - Q_rint(v)) < 0.001 )\n\t\tfprintf (f,\"%i \",(int)Q_rint(v));\n\telse\n\t\tfprintf (f,\"%f \",v);\n}\n\n/*\n=================\nWritePortalFile_r\n=================\n*/\nvoid WritePortalFile_r (node_t *node)\n{\n\tint\t\t\ti, s;\t\n\tportal_t\t*p;\n\twinding_t\t*w;\n\tvec3_t\t\tnormal;\n\tvec_t\t\tdist;\n\n\t// decision node\n\tif (node->planenum != PLANENUM_LEAF && !node->detail_seperator)\n\t{\n\t\tWritePortalFile_r (node->children[0]);\n\t\tWritePortalFile_r (node->children[1]);\n\t\treturn;\n\t}\n\t\n\tif (node->contents & CONTENTS_SOLID)\n\t\treturn;\n\n\tfor (p = node->portals ; p ; p=p->next[s])\n\t{\n\t\tw = p->winding;\n\t\ts = (p->nodes[1] == node);\n\t\tif (w && p->nodes[0] == node)\n\t\t{\n\t\t\tif (!Portal_VisFlood (p))\n\t\t\t\tcontinue;\n\t\t// write out to the file\n\t\t\n\t\t// sometimes planes get turned around when they are very near\n\t\t// the changeover point between different axis.  interpret the\n\t\t// plane the same way vis will, and flip the side orders if needed\n\t\t\t// FIXME: is this still relevent?\n\t\t\tWindingPlane (w, normal, &dist);\n\t\t\tif ( DotProduct (p->plane.normal, normal) < 0.99 )\n\t\t\t{\t// backwards...\n\t\t\t\tfprintf (pf,\"%i %i %i \",w->numpoints, p->nodes[1]->cluster, p->nodes[0]->cluster);\n\t\t\t}\n\t\t\telse\n\t\t\t\tfprintf (pf,\"%i %i %i \",w->numpoints, p->nodes[0]->cluster, p->nodes[1]->cluster);\n\t\t\tfor (i=0 ; i<w->numpoints ; i++)\n\t\t\t{\n\t\t\t\tfprintf (pf,\"(\");\n\t\t\t\tWriteFloat2 (pf, w->p[i][0]);\n\t\t\t\tWriteFloat2 (pf, w->p[i][1]);\n\t\t\t\tWriteFloat2 (pf, w->p[i][2]);\n\t\t\t\tfprintf (pf,\") \");\n\t\t\t}\n\t\t\tfprintf (pf,\"\\n\");\n\t\t}\n\t}\n\n}\n\n/*\n================\nFillLeafNumbers_r\n\nAll of the leafs under node will have the same cluster\n================\n*/\nvoid FillLeafNumbers_r (node_t *node, int num)\n{\n\tif (node->planenum == PLANENUM_LEAF)\n\t{\n\t\tif (node->contents & CONTENTS_SOLID)\n\t\t\tnode->cluster = -1;\n\t\telse\n\t\t\tnode->cluster = num;\n\t\treturn;\n\t}\n\tnode->cluster = num;\n\tFillLeafNumbers_r (node->children[0], num);\n\tFillLeafNumbers_r (node->children[1], num);\n}\n\n/*\n================\nNumberLeafs_r\n================\n*/\nvoid NumberLeafs_r (node_t *node)\n{\n\tportal_t\t*p;\n\n\tif (node->planenum != PLANENUM_LEAF && !node->detail_seperator)\n\t{\t// decision node\n\t\tnode->cluster = -99;\n\t\tNumberLeafs_r (node->children[0]);\n\t\tNumberLeafs_r (node->children[1]);\n\t\treturn;\n\t}\n\t\n\t// either a leaf or a detail cluster\n\n\tif ( node->contents & CONTENTS_SOLID )\n\t{\t// solid block, viewpoint never inside\n\t\tnode->cluster = -1;\n\t\treturn;\n\t}\n\n\tFillLeafNumbers_r (node, num_visclusters);\n\tnum_visclusters++;\n\n\t// count the portals\n\tfor (p = node->portals ; p ; )\n\t{\n\t\tif (p->nodes[0] == node)\t\t// only write out from first leaf\n\t\t{\n\t\t\tif (Portal_VisFlood (p))\n\t\t\t\tnum_visportals++;\n\t\t\tp = p->next[0];\n\t\t}\n\t\telse\n\t\t\tp = p->next[1];\t\t\n\t}\n\n}\n\n\n/*\n================\nCreateVisPortals_r\n================\n*/\nvoid CreateVisPortals_r (node_t *node)\n{\n\t// stop as soon as we get to a detail_seperator, which\n\t// means that everything below is in a single cluster\n\tif (node->planenum == PLANENUM_LEAF || node->detail_seperator )\n\t\treturn;\n\n\tMakeNodePortal (node);\n\tSplitNodePortals (node);\n\n\tCreateVisPortals_r (node->children[0]);\n\tCreateVisPortals_r (node->children[1]);\n}\n\n/*\n================\nFinishVisPortals_r\n================\n*/\nvoid FinishVisPortals2_r (node_t *node)\n{\n\tif (node->planenum == PLANENUM_LEAF)\n\t\treturn;\n\n\tMakeNodePortal (node);\n\tSplitNodePortals (node);\n\n\tFinishVisPortals2_r (node->children[0]);\n\tFinishVisPortals2_r (node->children[1]);\n}\n\nvoid FinishVisPortals_r (node_t *node)\n{\n\tif (node->planenum == PLANENUM_LEAF)\n\t\treturn;\n\n\tif (node->detail_seperator)\n\t{\n\t\tFinishVisPortals2_r (node);\n\t\treturn;\n\t}\n\n\tFinishVisPortals_r (node->children[0]);\n\tFinishVisPortals_r (node->children[1]);\n}\n\n\nint\t\tclusterleaf;\nvoid SaveClusters_r (node_t *node)\n{\n\tif (node->planenum == PLANENUM_LEAF)\n\t{\n\t\tdleafs[clusterleaf++].cluster = node->cluster;\n\t\treturn;\n\t}\n\tSaveClusters_r (node->children[0]);\n\tSaveClusters_r (node->children[1]);\n}\n\n/*\n================\nWritePortalFile\n================\n*/\nvoid WritePortalFile (tree_t *tree)\n{\n\tchar\tfilename[1024];\n\tnode_t *headnode;\n\n\tqprintf (\"--- WritePortalFile ---\\n\");\n\n\theadnode = tree->headnode;\n\tnum_visclusters = 0;\n\tnum_visportals = 0;\n\n\tTree_FreePortals_r (headnode);\n\n\tMakeHeadnodePortals (tree);\n\n\tCreateVisPortals_r (headnode);\n\n// set the cluster field in every leaf and count the total number of portals\n\n\tNumberLeafs_r (headnode);\n\t\n// write the file\n\tsprintf (filename, \"%s.prt\", source);\n\tprintf (\"writing %s\\n\", filename);\n\tpf = fopen (filename, \"w\");\n\tif (!pf)\n\t\tError (\"Error opening %s\", filename);\n\t\t\n\tfprintf (pf, \"%s\\n\", PORTALFILE);\n\tfprintf (pf, \"%i\\n\", num_visclusters);\n\tfprintf (pf, \"%i\\n\", num_visportals);\n\n\tqprintf (\"%5i visclusters\\n\", num_visclusters);\n\tqprintf (\"%5i visportals\\n\", num_visportals);\n\n\tWritePortalFile_r (headnode);\n\n\tfclose (pf);\n\n\t// we need to store the clusters out now because ordering\n\t// issues made us do this after writebsp...\n\tclusterleaf = 1;\n\tSaveClusters_r (headnode);\n}\n\n"
  },
  {
    "path": "code/bspc/q2files.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n//\n// qfiles.h: quake file formats\n// This file must be identical in the quake and utils directories\n//\n\n/*\n========================================================================\n\nThe .pak files are just a linear collapse of a directory tree\n\n========================================================================\n*/\n\n#define IDPAKHEADER\t\t(('K'<<24)+('C'<<16)+('A'<<8)+'P')\n\ntypedef struct\n{\n\tchar\tname[56];\n\tint\t\tfilepos, filelen;\n} dpackfile_t;\n\ntypedef struct\n{\n\tint\t\tident;\t\t// == IDPAKHEADER\n\tint\t\tdirofs;\n\tint\t\tdirlen;\n} dpackheader_t;\n\n#define\tMAX_FILES_IN_PACK\t4096\n\n\n/*\n========================================================================\n\nPCX files are used for as many images as possible\n\n========================================================================\n*/\n\ntypedef struct\n{\n    char\tmanufacturer;\n    char\tversion;\n    char\tencoding;\n    char\tbits_per_pixel;\n    unsigned short\txmin,ymin,xmax,ymax;\n    unsigned short\thres,vres;\n    unsigned char\tpalette[48];\n    char\treserved;\n    char\tcolor_planes;\n    unsigned short\tbytes_per_line;\n    unsigned short\tpalette_type;\n    char\tfiller[58];\n    unsigned char\tdata;\t\t\t// unbounded\n} pcx_t;\n\n\n/*\n========================================================================\n\n.MD2 triangle model file format\n\n========================================================================\n*/\n\n#define IDALIASHEADER\t\t(('2'<<24)+('P'<<16)+('D'<<8)+'I')\n#define ALIAS_VERSION\t8\n\n#define\tMAX_TRIANGLES\t4096\n#define MAX_VERTS\t\t2048\n#define MAX_FRAMES\t\t512\n#define MAX_MD2SKINS\t32\n#define\tMAX_SKINNAME\t64\n\ntypedef struct\n{\n\tshort\ts;\n\tshort\tt;\n} dstvert_t;\n\ntypedef struct \n{\n\tshort\tindex_xyz[3];\n\tshort\tindex_st[3];\n} dtriangle_t;\n\ntypedef struct\n{\n\tbyte\tv[3];\t\t\t// scaled byte to fit in frame mins/maxs\n\tbyte\tlightnormalindex;\n} dtrivertx_t;\n\n#define DTRIVERTX_V0   0\n#define DTRIVERTX_V1   1\n#define DTRIVERTX_V2   2\n#define DTRIVERTX_LNI  3\n#define DTRIVERTX_SIZE 4\n\ntypedef struct\n{\n\tfloat\t\tscale[3];\t// multiply byte verts by this\n\tfloat\t\ttranslate[3];\t// then add this\n\tchar\t\tname[16];\t// frame name from grabbing\n\tdtrivertx_t\tverts[1];\t// variable sized\n} daliasframe_t;\n\n\n// the glcmd format:\n// a positive integer starts a tristrip command, followed by that many\n// vertex structures.\n// a negative integer starts a trifan command, followed by -x vertexes\n// a zero indicates the end of the command list.\n// a vertex consists of a floating point s, a floating point t,\n// and an integer vertex index.\n\n\ntypedef struct\n{\n\tint\t\t\tident;\n\tint\t\t\tversion;\n\n\tint\t\t\tskinwidth;\n\tint\t\t\tskinheight;\n\tint\t\t\tframesize;\t\t// byte size of each frame\n\n\tint\t\t\tnum_skins;\n\tint\t\t\tnum_xyz;\n\tint\t\t\tnum_st;\t\t\t// greater than num_xyz for seams\n\tint\t\t\tnum_tris;\n\tint\t\t\tnum_glcmds;\t\t// dwords in strip/fan command list\n\tint\t\t\tnum_frames;\n\n\tint\t\t\tofs_skins;\t\t// each skin is a MAX_SKINNAME string\n\tint\t\t\tofs_st;\t\t\t// byte offset from start for stverts\n\tint\t\t\tofs_tris;\t\t// offset for dtriangles\n\tint\t\t\tofs_frames;\t\t// offset for first frame\n\tint\t\t\tofs_glcmds;\t\n\tint\t\t\tofs_end;\t\t// end of file\n\n} dmdl_t;\n\n/*\n========================================================================\n\n.SP2 sprite file format\n\n========================================================================\n*/\n\n#define IDSPRITEHEADER\t(('2'<<24)+('S'<<16)+('D'<<8)+'I')\n\t\t// little-endian \"IDS2\"\n#define SPRITE_VERSION\t2\n\ntypedef struct\n{\n\tint\t\twidth, height;\n\tint\t\torigin_x, origin_y;\t\t// raster coordinates inside pic\n\tchar\tname[MAX_SKINNAME];\t\t// name of pcx file\n} dsprframe_t;\n\ntypedef struct {\n\tint\t\t\tident;\n\tint\t\t\tversion;\n\tint\t\t\tnumframes;\n\tdsprframe_t\tframes[1];\t\t\t// variable sized\n} dsprite_t;\n\n/*\n==============================================================================\n\n  .WAL texture file format\n\n==============================================================================\n*/\n\n\n#define\tMIPLEVELS\t4\ntypedef struct miptex_s\n{\n\tchar\t\tname[32];\n\tunsigned\twidth, height;\n\tunsigned\toffsets[MIPLEVELS];\t\t// four mip maps stored\n\tchar\t\tanimname[32];\t\t\t// next frame in animation chain\n\tint\t\t\tflags;\n\tint\t\t\tcontents;\n\tint\t\t\tvalue;\n} miptex_t;\n\n\n\n/*\n==============================================================================\n\n  .BSP file format\n\n==============================================================================\n*/\n\n#define IDBSPHEADER\t(('P'<<24)+('S'<<16)+('B'<<8)+'I')\n\t\t// little-endian \"IBSP\"\n\n#define BSPVERSION\t38\n\n\n// upper design bounds\n// leaffaces, leafbrushes, planes, and verts are still bounded by\n// 16 bit short limits\n#define\tMAX_MAP_MODELS\t\t1024\n#define\tMAX_MAP_BRUSHES\t\t8192\n#define\tMAX_MAP_ENTITIES\t2048\n#define\tMAX_MAP_ENTSTRING\t0x40000\n#define\tMAX_MAP_TEXINFO\t\t8192\n\n#define\tMAX_MAP_AREAS\t\t256\n#define\tMAX_MAP_AREAPORTALS\t1024\n#define\tMAX_MAP_PLANES\t\t65536\n#define\tMAX_MAP_NODES\t\t65536\n#define\tMAX_MAP_BRUSHSIDES\t65536\n#define\tMAX_MAP_LEAFS\t\t65536\n#define\tMAX_MAP_VERTS\t\t65536\n#define\tMAX_MAP_FACES\t\t65536\n#define\tMAX_MAP_LEAFFACES\t65536\n#define\tMAX_MAP_LEAFBRUSHES 65536\n#define\tMAX_MAP_PORTALS\t\t65536\n#define\tMAX_MAP_EDGES\t\t128000\n#define\tMAX_MAP_SURFEDGES\t256000\n#define\tMAX_MAP_LIGHTING\t0x320000\n#define\tMAX_MAP_VISIBILITY\t0x280000\n\n// key / value pair sizes\n\n#define\tMAX_KEY\t\t32\n#define\tMAX_VALUE\t1024\n\n//=============================================================================\n\ntypedef struct\n{\n\tint\t\tfileofs, filelen;\n} lump_t;\n\n#define\tLUMP_ENTITIES\t\t0\n#define\tLUMP_PLANES\t\t\t1\n#define\tLUMP_VERTEXES\t\t2\n#define\tLUMP_VISIBILITY\t\t3\n#define\tLUMP_NODES\t\t\t4\n#define\tLUMP_TEXINFO\t\t5\n#define\tLUMP_FACES\t\t\t6\n#define\tLUMP_LIGHTING\t\t7\n#define\tLUMP_LEAFS\t\t\t8\n#define\tLUMP_LEAFFACES\t\t9\n#define\tLUMP_LEAFBRUSHES\t10\n#define\tLUMP_EDGES\t\t\t11\n#define\tLUMP_SURFEDGES\t\t12\n#define\tLUMP_MODELS\t\t\t13\n#define\tLUMP_BRUSHES\t\t14\n#define\tLUMP_BRUSHSIDES\t\t15\n#define\tLUMP_POP\t\t\t16\n#define\tLUMP_AREAS\t\t\t17\n#define\tLUMP_AREAPORTALS\t18\n#define\tHEADER_LUMPS\t\t19\n\ntypedef struct\n{\n\tint\t\t\tident;\n\tint\t\t\tversion;\t\n\tlump_t\t\tlumps[HEADER_LUMPS];\n} dheader_t;\n\ntypedef struct\n{\n\tfloat\t\tmins[3], maxs[3];\n\tfloat\t\torigin[3];\t\t// for sounds or lights\n\tint\t\t\theadnode;\n\tint\t\t\tfirstface, numfaces;\t// submodels just draw faces\n\t\t\t\t\t\t\t\t\t\t// without walking the bsp tree\n} dmodel_t;\n\n\ntypedef struct\n{\n\tfloat\tpoint[3];\n} dvertex_t;\n\n\n// 0-2 are axial planes\n#define\tPLANE_X\t\t\t0\n#define\tPLANE_Y\t\t\t1\n#define\tPLANE_Z\t\t\t2\n\n// 3-5 are non-axial planes snapped to the nearest\n#define\tPLANE_ANYX\t\t3\n#define\tPLANE_ANYY\t\t4\n#define\tPLANE_ANYZ\t\t5\n\n// planes (x&~1) and (x&~1)+1 are allways opposites\n\ntypedef struct\n{\n\tfloat\tnormal[3];\n\tfloat\tdist;\n\tint\t\ttype;\t\t// PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate\n} dplane_t;\n\n\n// contents flags are seperate bits\n// a given brush can contribute multiple content bits\n// multiple brushes can be in a single leaf\n\n// these definitions also need to be in q_shared.h!\n\n// lower bits are stronger, and will eat weaker brushes completely\n#define\tCONTENTS_SOLID\t\t\t1\t\t// an eye is never valid in a solid\n#define\tCONTENTS_WINDOW\t\t\t2\t\t// translucent, but not watery\n#define\tCONTENTS_AUX\t\t\t4\n#define\tCONTENTS_LAVA\t\t\t8\n#define\tCONTENTS_SLIME\t\t\t16\n#define\tCONTENTS_WATER\t\t\t32\n#define\tCONTENTS_MIST\t\t\t64\n#define\tLAST_VISIBLE_CONTENTS\t64\n\n// remaining contents are non-visible, and don't eat brushes\n\n#define\tCONTENTS_AREAPORTAL\t\t0x8000\n\n#define\tCONTENTS_PLAYERCLIP\t\t0x10000\n#define\tCONTENTS_MONSTERCLIP\t0x20000\n\n// currents can be added to any other contents, and may be mixed\n#define\tCONTENTS_CURRENT_0\t\t0x40000\n#define\tCONTENTS_CURRENT_90\t\t0x80000\n#define\tCONTENTS_CURRENT_180\t0x100000\n#define\tCONTENTS_CURRENT_270\t0x200000\n#define\tCONTENTS_CURRENT_UP\t\t0x400000\n#define\tCONTENTS_CURRENT_DOWN\t0x800000\n\n#define\tCONTENTS_ORIGIN\t\t\t0x1000000\t// removed before bsping an entity\n\n#define\tCONTENTS_MONSTER\t\t0x2000000\t// should never be on a brush, only in game\n#define\tCONTENTS_DEADMONSTER\t0x4000000\n#define\tCONTENTS_DETAIL\t\t\t0x8000000\t// brushes to be added after vis leafs\n//renamed because it's in conflict with the Q3A translucent contents\n#define\tCONTENTS_Q2TRANSLUCENT\t0x10000000\t// auto set if any surface has trans\n#define\tCONTENTS_LADDER\t\t\t0x20000000\n\n\n\n#define\tSURF_LIGHT\t\t0x1\t\t// value will hold the light strength\n\n#define\tSURF_SLICK\t\t0x2\t\t// effects game physics\n\n#define\tSURF_SKY\t\t0x4\t\t// don't draw, but add to skybox\n#define\tSURF_WARP\t\t0x8\t\t// turbulent water warp\n#define\tSURF_TRANS33\t0x10\n#define\tSURF_TRANS66\t0x20\n#define\tSURF_FLOWING\t0x40\t// scroll towards angle\n#define\tSURF_NODRAW\t\t0x80\t// don't bother referencing the texture\n\n#define\tSURF_HINT\t\t0x100\t// make a primary bsp splitter\n#define\tSURF_SKIP\t\t0x200\t// completely ignore, allowing non-closed brushes\n\n\n\ntypedef struct\n{\n\tint\t\t\tplanenum;\n\tint\t\t\tchildren[2];\t// negative numbers are -(leafs+1), not nodes\n\tshort\t\tmins[3];\t\t// for frustom culling\n\tshort\t\tmaxs[3];\n\tunsigned short\tfirstface;\n\tunsigned short\tnumfaces;\t// counting both sides\n} dnode_t;\n\n\ntypedef struct texinfo_s\n{\n\tfloat\t\tvecs[2][4];\t\t// [s/t][xyz offset]\n\tint\t\t\tflags;\t\t\t// miptex flags + overrides\n\tint\t\t\tvalue;\t\t\t// light emission, etc\n\tchar\t\ttexture[32];\t// texture name (textures/*.wal)\n\tint\t\t\tnexttexinfo;\t// for animations, -1 = end of chain\n} texinfo_t;\n\n\n// note that edge 0 is never used, because negative edge nums are used for\n// counterclockwise use of the edge in a face\ntypedef struct\n{\n\tunsigned short\tv[2];\t\t// vertex numbers\n} dedge_t;\n\n#define\tMAXLIGHTMAPS\t4\ntypedef struct\n{\n\tunsigned short\tplanenum;\n\tshort\t\tside;\n\n\tint\t\t\tfirstedge;\t\t// we must support > 64k edges\n\tshort\t\tnumedges;\t\n\tshort\t\ttexinfo;\n\n// lighting info\n\tbyte\t\tstyles[MAXLIGHTMAPS];\n\tint\t\t\tlightofs;\t\t// start of [numstyles*surfsize] samples\n} dface_t;\n\ntypedef struct\n{\n\tint\t\t\t\tcontents;\t\t\t// OR of all brushes (not needed?)\n\n\tshort\t\t\tcluster;\n\tshort\t\t\tarea;\n\n\tshort\t\t\tmins[3];\t\t\t// for frustum culling\n\tshort\t\t\tmaxs[3];\n\n\tunsigned short\tfirstleafface;\n\tunsigned short\tnumleaffaces;\n\n\tunsigned short\tfirstleafbrush;\n\tunsigned short\tnumleafbrushes;\n} dleaf_t;\n\ntypedef struct\n{\n\tunsigned short\tplanenum;\t\t// facing out of the leaf\n\tshort\ttexinfo;\n} dbrushside_t;\n\ntypedef struct\n{\n\tint\t\t\tfirstside;\n\tint\t\t\tnumsides;\n\tint\t\t\tcontents;\n} dbrush_t;\n\n#define\tANGLE_UP\t-1\n#define\tANGLE_DOWN\t-2\n\n\n// the visibility lump consists of a header with a count, then\n// byte offsets for the PVS and PHS of each cluster, then the raw\n// compressed bit vectors\n#define\tDVIS_PVS\t0\n#define\tDVIS_PHS\t1\ntypedef struct\n{\n\tint\t\t\tnumclusters;\n\tint\t\t\tbitofs[8][2];\t// bitofs[numclusters][2]\n} dvis_t;\n\n// each area has a list of portals that lead into other areas\n// when portals are closed, other areas may not be visible or\n// hearable even if the vis info says that it should be\ntypedef struct\n{\n\tint\t\tportalnum;\n\tint\t\totherarea;\n} dareaportal_t;\n\ntypedef struct\n{\n\tint\t\tnumareaportals;\n\tint\t\tfirstareaportal;\n} darea_t;\n"
  },
  {
    "path": "code/bspc/q3files.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __QFILES_H__\n#define __QFILES_H__\n\n//\n// qfiles.h: quake file formats\n// This file must be identical in the quake and utils directories\n//\n\n// surface geometry should not exceed these limits\n#define\tSHADER_MAX_VERTEXES\t1000\n#define\tSHADER_MAX_INDEXES\t(6*SHADER_MAX_VERTEXES)\n\n\n// the maximum size of game reletive pathnames\n#define\tMAX_QPATH\t\t64\n\n\n/*\n========================================================================\n\nPCX files are used for 8 bit images\n\n========================================================================\n* \n\ntypedef struct {\n    char\tmanufacturer;\n    char\tversion;\n    char\tencoding;\n    char\tbits_per_pixel;\n    unsigned short\txmin,ymin,xmax,ymax;\n    unsigned short\thres,vres;\n    unsigned char\tpalette[48];\n    char\treserved;\n    char\tcolor_planes;\n    unsigned short\tbytes_per_line;\n    unsigned short\tpalette_type;\n    char\tfiller[58];\n    unsigned char\tdata;\t\t\t// unbounded\n} pcx_t;\n\n\n/*\n========================================================================\n\nTGA files are used for 24/32 bit images\n\n========================================================================\n* \n\ntypedef struct _TargaHeader {\n\tunsigned char \tid_length, colormap_type, image_type;\n\tunsigned short\tcolormap_index, colormap_length;\n\tunsigned char\tcolormap_size;\n\tunsigned short\tx_origin, y_origin, width, height;\n\tunsigned char\tpixel_size, attributes;\n} TargaHeader;\n\n\n*/\n\n/*\n========================================================================\n\n.MD3 triangle model file format\n\n========================================================================\n*/\n\n#define MD3_IDENT\t\t\t(('3'<<24)+('P'<<16)+('D'<<8)+'I')\n#define MD3_VERSION\t\t\t15\n\n// limits\n#define MD3_MAX_LODS\t\t4\n#define\tMD3_MAX_TRIANGLES\t8192\t// per surface\n#define MD3_MAX_VERTS\t\t4096\t// per surface\n#define MD3_MAX_SHADERS\t\t256\t\t// per surface\n#define MD3_MAX_FRAMES\t\t1024\t// per model\n#define\tMD3_MAX_SURFACES\t32\t\t// per model\n#define MD3_MAX_TAGS\t\t16\t\t// per frame\n\n// vertex scales\n#define\tMD3_XYZ_SCALE\t\t(1.0/64)\n\ntypedef struct md3Frame_s {\n\tvec3_t\t\tbounds[2];\n\tvec3_t\t\tlocalOrigin;\n\tfloat\t\tradius;\n\tchar\t\tname[16];\n} md3Frame_t;\n\ntypedef struct md3Tag_s {\n\tchar\t\tname[MAX_QPATH];\t// tag name\n\tvec3_t\t\torigin;\n\tvec3_t\t\taxis[3];\n} md3Tag_t;\n\n/*\n** md3Surface_t\n**\n** CHUNK\t\t\tSIZE\n** header\t\t\tsizeof( md3Surface_t )\n** shaders\t\t\tsizeof( md3Shader_t ) * numShaders\n** triangles[0]\t\tsizeof( md3Triangle_t ) * numTriangles\n** st\t\t\t\tsizeof( md3St_t ) * numVerts\n** XyzNormals\t\tsizeof( md3XyzNormal_t ) * numVerts * numFrames\n*/\n\ntypedef struct {\n\tint\t\tident;\t\t\t\t// \n\n\tchar\tname[MAX_QPATH];\t// polyset name\n\n\tint\t\tflags;\n\tint\t\tnumFrames;\t\t\t// all surfaces in a model should have the same\n\n\tint\t\tnumShaders;\t\t\t// all surfaces in a model should have the same\n\tint\t\tnumVerts;\n\n\tint\t\tnumTriangles;\n\tint\t\tofsTriangles;\n\n\tint\t\tofsShaders;\t\t\t// offset from start of md3Surface_t\n\tint\t\tofsSt;\t\t\t\t// texture coords are common for all frames\n\tint\t\tofsXyzNormals;\t\t// numVerts * numFrames\n\n\tint\t\tofsEnd;\t\t\t\t// next surface follows\n} md3Surface_t;\n\ntypedef struct {\n\tchar\t\t\tname[MAX_QPATH];\n\tint\t\t\t\tshaderIndex;\t// for in-game use\n} md3Shader_t;\n\ntypedef struct {\n\tint\t\t\tindexes[3];\n} md3Triangle_t;\n\ntypedef struct {\n\tfloat\t\tst[2];\n} md3St_t;\n\ntypedef struct {\n\tshort\t\txyz[3];\n\tshort\t\tnormal;\n} md3XyzNormal_t;\n\ntypedef struct {\n\tint\t\t\tident;\n\tint\t\t\tversion;\n\n\tchar\t\tname[MAX_QPATH];\t// model name\n\n\tint\t\t\tflags;\n\n\tint\t\t\tnumFrames;\n\tint\t\t\tnumTags;\t\t\t\n\tint\t\t\tnumSurfaces;\n\n\tint\t\t\tnumSkins;\n\n\tint\t\t\tofsFrames;\t\t\t// offset for first frame\n\tint\t\t\tofsTags;\t\t\t// numFrames * numTags\n\tint\t\t\tofsSurfaces;\t\t// first surface, others follow\n\n\tint\t\t\tofsEnd;\t\t\t\t// end of file\n} md3Header_t;\n\n\n\n/*\n==============================================================================\n\n  .BSP file format\n\n==============================================================================\n*/\n\n\n#define Q3_BSP_IDENT\t(('P'<<24)+('S'<<16)+('B'<<8)+'I')\n\t\t// little-endian \"IBSP\"\n\n#define Q3_BSP_VERSION\t\t\t46\n\n\n// there shouldn't be any problem with increasing these values at the\n// expense of more memory allocation in the utilities\n#define\tQ3_MAX_MAP_MODELS\t\t0x400\n#define\tQ3_MAX_MAP_BRUSHES\t\t0x8000\n#define\tQ3_MAX_MAP_ENTITIES\t0x800\n#define\tQ3_MAX_MAP_ENTSTRING\t0x10000\n#define\tQ3_MAX_MAP_SHADERS\t\t0x400\n\n#define\tQ3_MAX_MAP_AREAS\t\t0x100\t// MAX_MAP_AREA_BYTES in q_shared must match!\n#define\tQ3_MAX_MAP_FOGS\t\t0x100\n#define\tQ3_MAX_MAP_PLANES\t\t0x10000\n#define\tQ3_MAX_MAP_NODES\t\t0x10000\n#define\tQ3_MAX_MAP_BRUSHSIDES\t0x10000\n#define\tQ3_MAX_MAP_LEAFS\t\t0x10000\n#define\tQ3_MAX_MAP_LEAFFACES\t0x10000\n#define\tQ3_MAX_MAP_LEAFBRUSHES\t0x10000\n#define\tQ3_MAX_MAP_PORTALS\t\t0x10000\n#define\tQ3_MAX_MAP_LIGHTING\t0x400000\n#define\tQ3_MAX_MAP_LIGHTGRID\t0x400000\n#define\tQ3_MAX_MAP_VISIBILITY\t0x200000\n\n#define\tQ3_MAX_MAP_DRAW_SURFS\t0x20000\n#define\tQ3_MAX_MAP_DRAW_VERTS\t0x80000\n#define\tQ3_MAX_MAP_DRAW_INDEXES\t0x80000\n\n\n// key / value pair sizes in the entities lump\n#define\tQ3_MAX_KEY\t\t\t\t32\n#define\tQ3_MAX_VALUE\t\t\t1024\n\n// the editor uses these predefined yaw angles to orient entities up or down\n#define\tANGLE_UP\t\t\t-1\n#define\tANGLE_DOWN\t\t\t-2\n\n#define\tLIGHTMAP_WIDTH\t\t128\n#define\tLIGHTMAP_HEIGHT\t\t128\n\n\n//=============================================================================\n\n\ntypedef struct {\n\tint\t\tfileofs, filelen;\n} q3_lump_t;\n\n#define\tQ3_LUMP_ENTITIES\t\t0\n#define\tQ3_LUMP_SHADERS\t\t1\n#define\tQ3_LUMP_PLANES\t\t\t2\n#define\tQ3_LUMP_NODES\t\t\t3\n#define\tQ3_LUMP_LEAFS\t\t\t4\n#define\tQ3_LUMP_LEAFSURFACES\t5\n#define\tQ3_LUMP_LEAFBRUSHES\t6\n#define\tQ3_LUMP_MODELS\t\t\t7\n#define\tQ3_LUMP_BRUSHES\t\t8\n#define\tQ3_LUMP_BRUSHSIDES\t\t9\n#define\tQ3_LUMP_DRAWVERTS\t\t10\n#define\tQ3_LUMP_DRAWINDEXES\t11\n#define\tQ3_LUMP_FOGS\t\t\t12\n#define\tQ3_LUMP_SURFACES\t\t13\n#define\tQ3_LUMP_LIGHTMAPS\t\t14\n#define\tQ3_LUMP_LIGHTGRID\t\t15\n#define\tQ3_LUMP_VISIBILITY\t\t16\n#define\tQ3_HEADER_LUMPS\t\t17\n\ntypedef struct {\n\tint\t\t\tident;\n\tint\t\t\tversion;\n\n\tq3_lump_t\t\tlumps[Q3_HEADER_LUMPS];\n} q3_dheader_t;\n\ntypedef struct {\n\tfloat\t\tmins[3], maxs[3];\n\tint\t\t\tfirstSurface, numSurfaces;\n\tint\t\t\tfirstBrush, numBrushes;\n} q3_dmodel_t;\n\ntypedef struct {\n\tchar\t\tshader[MAX_QPATH];\n\tint\t\t\tsurfaceFlags;\n\tint\t\t\tcontentFlags;\n} q3_dshader_t;\n\n// planes (x&~1) and (x&~1)+1 are allways opposites\n\ntypedef struct {\n\tfloat\t\tnormal[3];\n\tfloat\t\tdist;\n} q3_dplane_t;\n\ntypedef struct {\n\tint\t\t\tplaneNum;\n\tint\t\t\tchildren[2];\t// negative numbers are -(leafs+1), not nodes\n\tint\t\t\tmins[3];\t\t// for frustom culling\n\tint\t\t\tmaxs[3];\n} q3_dnode_t;\n\ntypedef struct {\n\tint\t\t\tcluster;\t\t\t// -1 = opaque cluster (do I still store these?)\n\tint\t\t\tarea;\n\n\tint\t\t\tmins[3];\t\t\t// for frustum culling\n\tint\t\t\tmaxs[3];\n\n\tint\t\t\tfirstLeafSurface;\n\tint\t\t\tnumLeafSurfaces;\n\n\tint\t\t\tfirstLeafBrush;\n\tint\t\t\tnumLeafBrushes;\n} q3_dleaf_t;\n\ntypedef struct {\n\tint\t\t\tplaneNum;\t\t\t// positive plane side faces out of the leaf\n\tint\t\t\tshaderNum;\n} q3_dbrushside_t;\n\ntypedef struct {\n\tint\t\t\tfirstSide;\n\tint\t\t\tnumSides;\n\tint\t\t\tshaderNum;\t\t// the shader that determines the contents flags\n} q3_dbrush_t;\n\ntypedef struct {\n\tchar\t\tshader[MAX_QPATH];\n\tint\t\t\tbrushNum;\n\tint\t\t\tvisibleSide;\t// the brush side that ray tests need to clip against (-1 == none)\n} q3_dfog_t;\n\ntypedef struct {\n\tvec3_t\t\txyz;\n\tfloat\t\tst[2];\n\tfloat\t\tlightmap[2];\n\tvec3_t\t\tnormal;\n\tbyte\t\tcolor[4];\n} q3_drawVert_t;\n\ntypedef enum {\n\tMST_BAD,\n\tMST_PLANAR,\n\tMST_PATCH,\n\tMST_TRIANGLE_SOUP,\n\tMST_FLARE\n} q3_mapSurfaceType_t;\n\ntypedef struct {\n\tint\t\t\tshaderNum;\n\tint\t\t\tfogNum;\n\tint\t\t\tsurfaceType;\n\n\tint\t\t\tfirstVert;\n\tint\t\t\tnumVerts;\n\n\tint\t\t\tfirstIndex;\n\tint\t\t\tnumIndexes;\n\n\tint\t\t\tlightmapNum;\n\tint\t\t\tlightmapX, lightmapY;\n\tint\t\t\tlightmapWidth, lightmapHeight;\n\n\tvec3_t\t\tlightmapOrigin;\n\tvec3_t\t\tlightmapVecs[3];\t// for patches, [0] and [1] are lodbounds\n\n\tint\t\t\tpatchWidth;\n\tint\t\t\tpatchHeight;\n} q3_dsurface_t;\n\n\n#endif\n"
  },
  {
    "path": "code/bspc/qbsp.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n\n#if defined(WIN32) || defined(_WIN32)\n#include <io.h>\n#endif\n#include <malloc.h>\n#include \"l_cmd.h\"\n#include \"l_math.h\"\n#include \"l_poly.h\"\n#include \"l_threads.h\"\n#include \"../botlib/l_script.h\"\n#include \"l_bsp_ent.h\"\n#include \"q2files.h\"\n#include \"l_mem.h\"\n#include \"l_utils.h\"\n#include \"l_log.h\"\n#include \"l_qfiles.h\"\n\n#define BSPC_VERSION\t\t\"2.1h\"\n\n#define ME\n#define DEBUG\n#define NODELIST\n#define SIN\n\n#define MAX_BRUSH_SIDES\t\t128\t\t//maximum number of sides per brush\n#define CLIP_EPSILON\t\t0.1\n#define MAX_MAP_BOUNDS\t\t65535\n#define BOGUS_RANGE\t\t\t(MAX_MAP_BOUNDS+128)\t//somewhere outside the map\n#define TEXINFO_NODE\t\t-1\t\t//side is allready on a node\n#define PLANENUM_LEAF\t\t-1\t\t//used for leaf nodes\n#define MAXEDGES\t\t\t20\t\t//maximum number of face edges\n#define MAX_NODE_BRUSHES\t8\t\t//maximum brushes in a node\n//side flags\n#define SFL_TESTED\t\t\t1\n#define SFL_VISIBLE\t\t\t2\n#define SFL_BEVEL\t\t\t4\n#define SFL_TEXTURED\t\t8\n#define SFL_CURVE\t\t\t16\n\n//map plane\ntypedef struct plane_s\n{\n\tvec3_t normal;\n\tvec_t dist;\n\tint type;\n\tint signbits;\n\tstruct plane_s\t*hash_chain;\n} plane_t;\n//brush texture\ntypedef struct\n{\n\tvec_t\tshift[2];\n\tvec_t\trotate;\n\tvec_t\tscale[2];\n\tchar\tname[32];\n\tint\t\tflags;\n\tint\t\tvalue;\n} brush_texture_t;\n//brush side\ntypedef struct side_s\n{\n\tint\t\t\t\tplanenum;\t// map plane this side is in\n\tint\t\t\t\ttexinfo;\t\t// texture reference\n\twinding_t\t\t*winding;\t// winding of this side\n\tstruct side_s\t*original;\t// bspbrush_t sides will reference the mapbrush_t sides\n   int\t\t\t\tlightinfo;\t// for SIN only\n\tint\t\t\t\tcontents;\t// from miptex\n\tint\t\t\t\tsurf;\t\t\t// from miptex\n\tunsigned short flags;\t\t// side flags\n} side_t;\t\t//sizeof(side_t) = 36\n//map brush\ntypedef struct mapbrush_s\n{\n\tint\t\tentitynum;\n\tint\t\tbrushnum;\n\n\tint\t\tcontents;\n#ifdef ME\n\tint\t\texpansionbbox;\t\t\t//bbox used for expansion of the brush\n\tint\t\tleafnum;\n\tint\t\tmodelnum;\n#endif\n\n\tvec3_t\tmins, maxs;\n\n\tint\t\tnumsides;\n\tside_t\t*original_sides;\n} mapbrush_t;\n//bsp face\ntypedef struct face_s\n{\n\tstruct face_s\t\t*next;\t\t// on node\n\n\t// the chain of faces off of a node can be merged or split,\n\t// but each face_t along the way will remain in the chain\n\t// until the entire tree is freed\n\tstruct face_s\t\t*merged;\t// if set, this face isn't valid anymore\n\tstruct face_s\t\t*split[2];\t// if set, this face isn't valid anymore\n\n\tstruct portal_s\t*portal;\n\tint\t\t\t\t\ttexinfo;\n#ifdef SIN\n   int\t\t\t\t\tlightinfo;\n#endif\n\tint\t\t\t\t\tplanenum;\n\tint\t\t\t\t\tcontents;\t// faces in different contents can't merge\n\tint\t\t\t\t\toutputnumber;\n\twinding_t\t\t\t*w;\n\tint\t\t\t\t\tnumpoints;\n\tqboolean\t\t\t\tbadstartvert;\t// tjunctions cannot be fixed without a midpoint vertex\n\tint\t\t\t\t\tvertexnums[MAXEDGES];\n} face_t;\n//bsp brush\ntypedef struct bspbrush_s\n{\n\tstruct\t\tbspbrush_s\t*next;\n\tvec3_t\t\tmins, maxs;\n\tint\t\t\tside, testside;\t\t// side of node during construction\n\tmapbrush_t\t*original;\n\tint\t\t\tnumsides;\n\tside_t\t\tsides[6];\t\t\t// variably sized\n} bspbrush_t;\t//sizeof(bspbrush_t) = 44 + numsides * sizeof(side_t)\n//bsp node\ntypedef struct node_s\n{\n\t//both leafs and nodes\n\tint\t\t\t\tplanenum;\t// -1 = leaf node\n\tstruct node_s\t*parent;\n\tvec3_t\t\t\tmins, maxs;\t// valid after portalization\n\tbspbrush_t\t\t*volume;\t\t// one for each leaf/node\n\n\t// nodes only\n\tqboolean\t\t\tdetail_seperator;\t// a detail brush caused the split\n\tside_t\t\t\t*side;\t\t// the side that created the node\n\tstruct node_s\t*children[2];\n\tface_t\t\t\t*faces;\n\n\t// leafs only\n\tbspbrush_t\t\t*brushlist;\t// fragments of all brushes in this leaf\n\tint\t\t\t\tcontents;\t// OR of all brush contents\n\tint\t\t\t\toccupied;\t// 1 or greater can reach entity\n\tentity_t\t\t\t*occupant;\t// for leak file testing\n\tint\t\t\t\tcluster;\t\t// for portalfile writing\n\tint\t\t\t\tarea;\t\t\t// for areaportals\n\tstruct portal_s *portals;\t// also on nodes during construction\n#ifdef NODELIST\n\tstruct node_s *next;\t\t\t//next node in the nodelist\n#endif\n#ifdef ME\n\tint expansionbboxes;\t\t\t//OR of all bboxes used for expansion of the brushes\n\tint modelnum;\n#endif\n} node_t;\t\t//sizeof(node_t) = 80 bytes\n//bsp portal\ntypedef struct portal_s\n{\n\tplane_t plane;\n\tnode_t *onnode;\t\t\t\t\t// NULL = outside box\n\tnode_t *nodes[2];\t\t\t\t// [0] = front side of plane\n\tstruct portal_s *next[2];\n\twinding_t *winding;\n\n\tqboolean\tsidefound;\t\t\t// false if ->side hasn't been checked\n\tside_t *side;\t\t\t\t\t// NULL = non-visible\n\tface_t *face[2];\t\t\t\t// output face in bsp file\n#ifdef ME\n\tstruct tmp_face_s *tmpface;\t\t//pointer to the tmpface created for this portal\n\tint planenum;\t\t\t\t\t//number of the map plane used by the portal\n#endif\n} portal_t;\n//bsp tree\ntypedef struct\n{\n\tnode_t\t\t*headnode;\n\tnode_t\t\toutside_node;\n\tvec3_t\t\tmins, maxs;\n} tree_t;\n\n//=============================================================================\n// bspc.c\n//=============================================================================\n\nextern\tqboolean noprune;\nextern\tqboolean nodetail;\nextern\tqboolean fulldetail;\nextern\tqboolean nomerge;\nextern\tqboolean nosubdiv;\nextern\tqboolean nowater;\nextern\tqboolean noweld;\nextern\tqboolean noshare;\nextern\tqboolean notjunc;\nextern\tqboolean onlyents;\n#ifdef ME\nextern\tqboolean nocsg;\nextern\tqboolean create_aas;\nextern\tqboolean freetree;\nextern\tqboolean lessbrushes;\nextern\tqboolean nobrushmerge;\nextern\tqboolean cancelconversion;\nextern\tqboolean noliquids;\nextern\tqboolean capsule_collision;\n#endif //ME\n\nextern\tfloat subdivide_size;\nextern\tvec_t microvolume;\n\nextern\tchar outbase[32];\nextern\tchar source[1024];\n\n//=============================================================================\n// map.c\n//=============================================================================\n\n#define MAX_MAPFILE_PLANES\t\t\t256000\n#define MAX_MAPFILE_BRUSHES\t\t\t65535\n#define MAX_MAPFILE_BRUSHSIDES\t\t(MAX_MAPFILE_BRUSHES*8)\n#define MAX_MAPFILE_TEXINFO\t\t\t8192\n\nextern\tint\t\t\tentity_num;\n\nextern\tplane_t\t\tmapplanes[MAX_MAPFILE_PLANES];\nextern\tint\t\t\tnummapplanes;\nextern\tint\t\t\tmapplaneusers[MAX_MAPFILE_PLANES];\n\nextern\tint\t\t\tnummapbrushes;\nextern\tmapbrush_t\tmapbrushes[MAX_MAPFILE_BRUSHES];\n\nextern\tvec3_t\t\tmap_mins, map_maxs;\n\nextern\tint\t\t\tnummapbrushsides;\nextern\tside_t\t\tbrushsides[MAX_MAPFILE_BRUSHSIDES];\nextern\tbrush_texture_t\tside_brushtextures[MAX_MAPFILE_BRUSHSIDES];\n\n#ifdef ME\n\ntypedef struct\n{\n\tfloat\tvecs[2][4];\t\t// [s/t][xyz offset]\n\tint\t\tflags;\t\t\t// miptex flags + overrides\n\tint\t\tvalue;\n\tchar\ttexture[64];\t// texture name (textures/*.wal)\n\tint\t\tnexttexinfo;\t// for animations, -1 = end of chain\n} map_texinfo_t;\n\nextern\tmap_texinfo_t\t\tmap_texinfo[MAX_MAPFILE_TEXINFO];\nextern\tint\t\t\t\t\tmap_numtexinfo;\n#define NODESTACKSIZE\t\t1024\n\n#define MAPTYPE_QUAKE1\t\t1\n#define MAPTYPE_QUAKE2\t\t2\n#define MAPTYPE_QUAKE3\t\t3\n#define MAPTYPE_HALFLIFE\t4\n#define MAPTYPE_SIN\t\t\t5\n\nextern\tint nodestack[NODESTACKSIZE];\nextern\tint *nodestackptr;\nextern\tint nodestacksize;\nextern\tint brushmodelnumbers[MAX_MAPFILE_BRUSHES];\nextern\tint dbrushleafnums[MAX_MAPFILE_BRUSHES];\nextern\tint dplanes2mapplanes[MAX_MAPFILE_PLANES];\n\nextern\tint loadedmaptype;\n#endif //ME\n\nextern\tint c_boxbevels;\nextern\tint c_edgebevels;\nextern\tint c_areaportals;\nextern\tint c_clipbrushes;\nextern\tint c_squattbrushes;\n\n//finds a float plane for the given normal and distance\nint FindFloatPlane(vec3_t normal, vec_t dist);\n//returns the plane type for the given normal\nint PlaneTypeForNormal(vec3_t normal);\n//returns the plane defined by the three given points\nint PlaneFromPoints(int *p0, int *p1, int *p2);\n//add bevels to the map brush\nvoid AddBrushBevels(mapbrush_t *b);\n//makes brush side windings for the brush\nqboolean MakeBrushWindings(mapbrush_t *ob);\n//marks brush bevels of the brush as bevel\nvoid MarkBrushBevels(mapbrush_t *brush);\n//returns true if the map brush already exists\nint BrushExists(mapbrush_t *brush);\n//loads a map from a bsp file\nint LoadMapFromBSP(struct quakefile_s *qf);\n//resets map loading\nvoid ResetMapLoading(void);\n//print some map info\nvoid PrintMapInfo(void);\n//writes a map file (type depending on loaded map type)\nvoid WriteMapFile(char *filename);\n\n//=============================================================================\n// map_q2.c\n//=============================================================================\n\nvoid Q2_ResetMapLoading(void);\n//loads a Quake2 map file\nvoid Q2_LoadMapFile(char *filename);\n//loads a map from a Quake2 bsp file\nvoid Q2_LoadMapFromBSP(char *filename, int offset, int length);\n\n//=============================================================================\n// map_q1.c\n//=============================================================================\n\nvoid Q1_ResetMapLoading(void);\n//loads a Quake2 map file\nvoid Q1_LoadMapFile(char *filename);\n//loads a map from a Quake1 bsp file\nvoid Q1_LoadMapFromBSP(char *filename, int offset, int length);\n\n//=============================================================================\n// map_q3.c\n//=============================================================================\nvoid Q3_ResetMapLoading(void);\n//loads a map from a Quake3 bsp file\nvoid Q3_LoadMapFromBSP(struct quakefile_s *qf);\n\n//=============================================================================\n// map_sin.c\n//=============================================================================\n\nvoid Sin_ResetMapLoading(void);\n//loads a Sin map file\nvoid Sin_LoadMapFile(char *filename);\n//loads a map from a Sin bsp file\nvoid Sin_LoadMapFromBSP(char *filename, int offset, int length);\n\n//=============================================================================\n// map_hl.c\n//=============================================================================\n\nvoid HL_ResetMapLoading(void);\n//loads a Half-Life map file\nvoid HL_LoadMapFile(char *filename);\n//loads a map from a Half-Life bsp file\nvoid HL_LoadMapFromBSP(char *filename, int offset, int length);\n\n//=============================================================================\n// textures.c\n//=============================================================================\n\ntypedef struct\n{\n\tchar\tname[64];\n\tint\t\tflags;\n\tint\t\tvalue;\n\tint\t\tcontents;\n\tchar\tanimname[64];\n} textureref_t;\n\n#define\tMAX_MAP_TEXTURES\t1024\n\nextern\ttextureref_t\ttextureref[MAX_MAP_TEXTURES];\n\nint FindMiptex(char *name);\nint TexinfoForBrushTexture(plane_t *plane, brush_texture_t *bt, vec3_t origin);\nvoid TextureAxisFromPlane(plane_t *pln, vec3_t xv, vec3_t yv);\n\n//=============================================================================\n// csg\n//=============================================================================\n\nbspbrush_t *MakeBspBrushList(int startbrush, int endbrush, vec3_t clipmins, vec3_t clipmaxs);\nbspbrush_t *ChopBrushes(bspbrush_t *head);\nbspbrush_t *InitialBrushList(bspbrush_t *list);\nbspbrush_t *OptimizedBrushList(bspbrush_t *list);\nvoid WriteBrushMap(char *name, bspbrush_t *list);\nvoid CheckBSPBrush(bspbrush_t *brush);\nvoid BSPBrushWindings(bspbrush_t *brush);\nbspbrush_t *TryMergeBrushes(bspbrush_t *brush1, bspbrush_t *brush2);\ntree_t *ProcessWorldBrushes(int brush_start, int brush_end);\n\n//=============================================================================\n// brushbsp\n//=============================================================================\n\n#define\tPSIDE_FRONT\t\t\t1\n#define\tPSIDE_BACK\t\t\t2\n#define\tPSIDE_BOTH\t\t\t(PSIDE_FRONT|PSIDE_BACK)\n#define\tPSIDE_FACING\t\t4\n\nvoid WriteBrushList(char *name, bspbrush_t *brush, qboolean onlyvis);\nbspbrush_t *CopyBrush(bspbrush_t *brush);\nvoid SplitBrush(bspbrush_t *brush, int planenum, bspbrush_t **front, bspbrush_t **back);\nnode_t *AllocNode(void);\nbspbrush_t *AllocBrush(int numsides);\nint CountBrushList(bspbrush_t *brushes);\nvoid FreeBrush(bspbrush_t *brushes);\nvec_t BrushVolume(bspbrush_t *brush);\nvoid BoundBrush(bspbrush_t *brush);\nvoid FreeBrushList(bspbrush_t *brushes);\ntree_t *BrushBSP(bspbrush_t *brushlist, vec3_t mins, vec3_t maxs);\nbspbrush_t *BrushFromBounds(vec3_t mins, vec3_t maxs);\nint BrushMostlyOnSide(bspbrush_t *brush, plane_t *plane);\nqboolean WindingIsHuge(winding_t *w);\nqboolean WindingIsTiny(winding_t *w);\nvoid ResetBrushBSP(void);\n\n//=============================================================================\n// portals.c\n//=============================================================================\n\nint VisibleContents (int contents);\nvoid MakeHeadnodePortals (tree_t *tree);\nvoid MakeNodePortal (node_t *node);\nvoid SplitNodePortals (node_t *node);\nqboolean Portal_VisFlood (portal_t *p);\nqboolean FloodEntities (tree_t *tree);\nvoid FillOutside (node_t *headnode);\nvoid FloodAreas (tree_t *tree);\nvoid MarkVisibleSides (tree_t *tree, int start, int end);\nvoid FreePortal (portal_t *p);\nvoid EmitAreaPortals (node_t *headnode);\nvoid MakeTreePortals (tree_t *tree);\n\n//=============================================================================\n// glfile.c\n//=============================================================================\n\nvoid OutputWinding(winding_t *w, FILE *glview);\nvoid WriteGLView(tree_t *tree, char *source);\n\n//=============================================================================\n// gldraw.c\n//=============================================================================\n\nextern vec3_t draw_mins, draw_maxs;\nextern qboolean drawflag;\n\nvoid Draw_ClearWindow (void);\nvoid DrawWinding (winding_t *w);\nvoid GLS_BeginScene (void);\nvoid GLS_Winding (winding_t *w, int code);\nvoid GLS_EndScene (void);\n\n//=============================================================================\n// leakfile.c\n//=============================================================================\n\nvoid LeakFile (tree_t *tree);\n\n//=============================================================================\n// tree.c\n//=============================================================================\n\ntree_t *Tree_Alloc(void);\nvoid Tree_Free(tree_t *tree);\nvoid Tree_Free_r(node_t *node);\nvoid Tree_Print_r(node_t *node, int depth);\nvoid Tree_FreePortals_r(node_t *node);\nvoid Tree_PruneNodes_r(node_t *node);\nvoid Tree_PruneNodes(node_t *node);\n"
  },
  {
    "path": "code/bspc/qfiles.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n//\n// qfiles.h: quake file formats\n// This file must be identical in the quake and utils directories\n//\n\n/*\n========================================================================\n\nThe .pak files are just a linear collapse of a directory tree\n\n========================================================================\n*/\n\n#define IDPAKHEADER\t\t(('K'<<24)+('C'<<16)+('A'<<8)+'P')\n\ntypedef struct\n{\n\tchar\tname[56];\n\tint\t\tfilepos, filelen;\n} dpackfile_t;\n\ntypedef struct\n{\n\tint\t\tident;\t\t// == IDPAKHEADER\n\tint\t\tdirofs;\n\tint\t\tdirlen;\n} dpackheader_t;\n\n#define\tMAX_FILES_IN_PACK\t4096\n\n\n/*\n========================================================================\n\nPCX files are used for as many images as possible\n\n========================================================================\n*/\n\ntypedef struct\n{\n    char\tmanufacturer;\n    char\tversion;\n    char\tencoding;\n    char\tbits_per_pixel;\n    unsigned short\txmin,ymin,xmax,ymax;\n    unsigned short\thres,vres;\n    unsigned char\tpalette[48];\n    char\treserved;\n    char\tcolor_planes;\n    unsigned short\tbytes_per_line;\n    unsigned short\tpalette_type;\n    char\tfiller[58];\n    unsigned char\tdata;\t\t\t// unbounded\n} pcx_t;\n\n\n/*\n========================================================================\n\n.MD2 triangle model file format\n\n========================================================================\n*/\n\n#define IDALIASHEADER\t\t(('2'<<24)+('P'<<16)+('D'<<8)+'I')\n#define ALIAS_VERSION\t8\n\n#define\tMAX_TRIANGLES\t4096\n#define MAX_VERTS\t\t2048\n#define MAX_FRAMES\t\t512\n#define MAX_MD2SKINS\t32\n#define\tMAX_SKINNAME\t64\n\ntypedef struct\n{\n\tshort\ts;\n\tshort\tt;\n} dstvert_t;\n\ntypedef struct \n{\n\tshort\tindex_xyz[3];\n\tshort\tindex_st[3];\n} dtriangle_t;\n\ntypedef struct\n{\n\tbyte\tv[3];\t\t\t// scaled byte to fit in frame mins/maxs\n\tbyte\tlightnormalindex;\n} dtrivertx_t;\n\n#define DTRIVERTX_V0   0\n#define DTRIVERTX_V1   1\n#define DTRIVERTX_V2   2\n#define DTRIVERTX_LNI  3\n#define DTRIVERTX_SIZE 4\n\ntypedef struct\n{\n\tfloat\t\tscale[3];\t// multiply byte verts by this\n\tfloat\t\ttranslate[3];\t// then add this\n\tchar\t\tname[16];\t// frame name from grabbing\n\tdtrivertx_t\tverts[1];\t// variable sized\n} daliasframe_t;\n\n\n// the glcmd format:\n// a positive integer starts a tristrip command, followed by that many\n// vertex structures.\n// a negative integer starts a trifan command, followed by -x vertexes\n// a zero indicates the end of the command list.\n// a vertex consists of a floating point s, a floating point t,\n// and an integer vertex index.\n\n\ntypedef struct\n{\n\tint\t\t\tident;\n\tint\t\t\tversion;\n\n\tint\t\t\tskinwidth;\n\tint\t\t\tskinheight;\n\tint\t\t\tframesize;\t\t// byte size of each frame\n\n\tint\t\t\tnum_skins;\n\tint\t\t\tnum_xyz;\n\tint\t\t\tnum_st;\t\t\t// greater than num_xyz for seams\n\tint\t\t\tnum_tris;\n\tint\t\t\tnum_glcmds;\t\t// dwords in strip/fan command list\n\tint\t\t\tnum_frames;\n\n\tint\t\t\tofs_skins;\t\t// each skin is a MAX_SKINNAME string\n\tint\t\t\tofs_st;\t\t\t// byte offset from start for stverts\n\tint\t\t\tofs_tris;\t\t// offset for dtriangles\n\tint\t\t\tofs_frames;\t\t// offset for first frame\n\tint\t\t\tofs_glcmds;\t\n\tint\t\t\tofs_end;\t\t// end of file\n\n} dmdl_t;\n\n/*\n========================================================================\n\n.SP2 sprite file format\n\n========================================================================\n*/\n\n#define IDSPRITEHEADER\t(('2'<<24)+('S'<<16)+('D'<<8)+'I')\n\t\t// little-endian \"IDS2\"\n#define SPRITE_VERSION\t2\n\ntypedef struct\n{\n\tint\t\twidth, height;\n\tint\t\torigin_x, origin_y;\t\t// raster coordinates inside pic\n\tchar\tname[MAX_SKINNAME];\t\t// name of pcx file\n} dsprframe_t;\n\ntypedef struct {\n\tint\t\t\tident;\n\tint\t\t\tversion;\n\tint\t\t\tnumframes;\n\tdsprframe_t\tframes[1];\t\t\t// variable sized\n} dsprite_t;\n\n/*\n==============================================================================\n\n  .WAL texture file format\n\n==============================================================================\n*/\n\n\n#define\tMIPLEVELS\t4\ntypedef struct miptex_s\n{\n\tchar\t\tname[32];\n\tunsigned\twidth, height;\n\tunsigned\toffsets[MIPLEVELS];\t\t// four mip maps stored\n\tchar\t\tanimname[32];\t\t\t// next frame in animation chain\n\tint\t\t\tflags;\n\tint\t\t\tcontents;\n\tint\t\t\tvalue;\n} miptex_t;\n\n\n\n/*\n==============================================================================\n\n  .BSP file format\n\n==============================================================================\n*/\n\n#define IDBSPHEADER\t(('P'<<24)+('S'<<16)+('B'<<8)+'I')\n\t\t// little-endian \"IBSP\"\n\n#define BSPVERSION\t38\n\n\n// upper design bounds\n// leaffaces, leafbrushes, planes, and verts are still bounded by\n// 16 bit short limits\n#define\tMAX_MAP_MODELS\t\t1024\n#define\tMAX_MAP_BRUSHES\t\t8192\n#define\tMAX_MAP_ENTITIES\t2048\n#define\tMAX_MAP_ENTSTRING\t0x40000\n#define\tMAX_MAP_TEXINFO\t\t8192\n\n#define\tMAX_MAP_AREAS\t\t256\n#define\tMAX_MAP_AREAPORTALS\t1024\n#define\tMAX_MAP_PLANES\t\t65536\n#define\tMAX_MAP_NODES\t\t65536\n#define\tMAX_MAP_BRUSHSIDES\t65536\n#define\tMAX_MAP_LEAFS\t\t65536\n#define\tMAX_MAP_VERTS\t\t65536\n#define\tMAX_MAP_FACES\t\t65536\n#define\tMAX_MAP_LEAFFACES\t65536\n#define\tMAX_MAP_LEAFBRUSHES 65536\n#define\tMAX_MAP_PORTALS\t\t65536\n#define\tMAX_MAP_EDGES\t\t128000\n#define\tMAX_MAP_SURFEDGES\t256000\n#define\tMAX_MAP_LIGHTING\t0x320000\n#define\tMAX_MAP_VISIBILITY\t0x280000\n\n// key / value pair sizes\n\n#define\tMAX_KEY\t\t32\n#define\tMAX_VALUE\t1024\n\n//=============================================================================\n\ntypedef struct\n{\n\tint\t\tfileofs, filelen;\n} lump_t;\n\n#define\tLUMP_ENTITIES\t\t0\n#define\tLUMP_PLANES\t\t\t1\n#define\tLUMP_VERTEXES\t\t2\n#define\tLUMP_VISIBILITY\t\t3\n#define\tLUMP_NODES\t\t\t4\n#define\tLUMP_TEXINFO\t\t5\n#define\tLUMP_FACES\t\t\t6\n#define\tLUMP_LIGHTING\t\t7\n#define\tLUMP_LEAFS\t\t\t8\n#define\tLUMP_LEAFFACES\t\t9\n#define\tLUMP_LEAFBRUSHES\t10\n#define\tLUMP_EDGES\t\t\t11\n#define\tLUMP_SURFEDGES\t\t12\n#define\tLUMP_MODELS\t\t\t13\n#define\tLUMP_BRUSHES\t\t14\n#define\tLUMP_BRUSHSIDES\t\t15\n#define\tLUMP_POP\t\t\t16\n#define\tLUMP_AREAS\t\t\t17\n#define\tLUMP_AREAPORTALS\t18\n#define\tHEADER_LUMPS\t\t19\n\ntypedef struct\n{\n\tint\t\t\tident;\n\tint\t\t\tversion;\t\n\tlump_t\t\tlumps[HEADER_LUMPS];\n} dheader_t;\n\ntypedef struct\n{\n\tfloat\t\tmins[3], maxs[3];\n\tfloat\t\torigin[3];\t\t// for sounds or lights\n\tint\t\t\theadnode;\n\tint\t\t\tfirstface, numfaces;\t// submodels just draw faces\n\t\t\t\t\t\t\t\t\t\t// without walking the bsp tree\n} dmodel_t;\n\n\ntypedef struct\n{\n\tfloat\tpoint[3];\n} dvertex_t;\n\n\n// 0-2 are axial planes\n#define\tPLANE_X\t\t\t0\n#define\tPLANE_Y\t\t\t1\n#define\tPLANE_Z\t\t\t2\n\n// 3-5 are non-axial planes snapped to the nearest\n#define\tPLANE_ANYX\t\t3\n#define\tPLANE_ANYY\t\t4\n#define\tPLANE_ANYZ\t\t5\n\n// planes (x&~1) and (x&~1)+1 are allways opposites\n\ntypedef struct\n{\n\tfloat\tnormal[3];\n\tfloat\tdist;\n\tint\t\ttype;\t\t// PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate\n} dplane_t;\n\n\n// contents flags are seperate bits\n// a given brush can contribute multiple content bits\n// multiple brushes can be in a single leaf\n\n// these definitions also need to be in q_shared.h!\n\n// lower bits are stronger, and will eat weaker brushes completely\n#define\tCONTENTS_SOLID\t\t\t1\t\t// an eye is never valid in a solid\n#define\tCONTENTS_WINDOW\t\t\t2\t\t// translucent, but not watery\n#define\tCONTENTS_AUX\t\t\t4\n#define\tCONTENTS_LAVA\t\t\t8\n#define\tCONTENTS_SLIME\t\t\t16\n#define\tCONTENTS_WATER\t\t\t32\n#define\tCONTENTS_MIST\t\t\t64\n#define\tLAST_VISIBLE_CONTENTS\t64\n\n// remaining contents are non-visible, and don't eat brushes\n\n#define\tCONTENTS_AREAPORTAL\t\t0x8000\n\n#define\tCONTENTS_PLAYERCLIP\t\t0x10000\n#define\tCONTENTS_MONSTERCLIP\t0x20000\n\n// currents can be added to any other contents, and may be mixed\n#define\tCONTENTS_CURRENT_0\t\t0x40000\n#define\tCONTENTS_CURRENT_90\t\t0x80000\n#define\tCONTENTS_CURRENT_180\t0x100000\n#define\tCONTENTS_CURRENT_270\t0x200000\n#define\tCONTENTS_CURRENT_UP\t\t0x400000\n#define\tCONTENTS_CURRENT_DOWN\t0x800000\n\n#define\tCONTENTS_ORIGIN\t\t\t0x1000000\t// removed before bsping an entity\n\n#define\tCONTENTS_MONSTER\t\t0x2000000\t// should never be on a brush, only in game\n#define\tCONTENTS_DEADMONSTER\t0x4000000\n#define\tCONTENTS_DETAIL\t\t\t0x8000000\t// brushes to be added after vis leafs\n//renamed because it's in conflict with the Q3A translucent contents\n#define\tCONTENTS_Q2TRANSLUCENT\t0x10000000\t// auto set if any surface has trans\n#define\tCONTENTS_LADDER\t\t\t0x20000000\n\n\n\n#define\tSURF_LIGHT\t\t0x1\t\t// value will hold the light strength\n\n#define\tSURF_SLICK\t\t0x2\t\t// effects game physics\n\n#define\tSURF_SKY\t\t0x4\t\t// don't draw, but add to skybox\n#define\tSURF_WARP\t\t0x8\t\t// turbulent water warp\n#define\tSURF_TRANS33\t0x10\n#define\tSURF_TRANS66\t0x20\n#define\tSURF_FLOWING\t0x40\t// scroll towards angle\n#define\tSURF_NODRAW\t\t0x80\t// don't bother referencing the texture\n\n#define\tSURF_HINT\t\t0x100\t// make a primary bsp splitter\n#define\tSURF_SKIP\t\t0x200\t// completely ignore, allowing non-closed brushes\n\n\n\ntypedef struct\n{\n\tint\t\t\tplanenum;\n\tint\t\t\tchildren[2];\t// negative numbers are -(leafs+1), not nodes\n\tshort\t\tmins[3];\t\t// for frustom culling\n\tshort\t\tmaxs[3];\n\tunsigned short\tfirstface;\n\tunsigned short\tnumfaces;\t// counting both sides\n} dnode_t;\n\n\ntypedef struct texinfo_s\n{\n\tfloat\t\tvecs[2][4];\t\t// [s/t][xyz offset]\n\tint\t\t\tflags;\t\t\t// miptex flags + overrides\n\tint\t\t\tvalue;\t\t\t// light emission, etc\n\tchar\t\ttexture[32];\t// texture name (textures/*.wal)\n\tint\t\t\tnexttexinfo;\t// for animations, -1 = end of chain\n} texinfo_t;\n\n\n// note that edge 0 is never used, because negative edge nums are used for\n// counterclockwise use of the edge in a face\ntypedef struct\n{\n\tunsigned short\tv[2];\t\t// vertex numbers\n} dedge_t;\n\n#define\tMAXLIGHTMAPS\t4\ntypedef struct\n{\n\tunsigned short\tplanenum;\n\tshort\t\tside;\n\n\tint\t\t\tfirstedge;\t\t// we must support > 64k edges\n\tshort\t\tnumedges;\t\n\tshort\t\ttexinfo;\n\n// lighting info\n\tbyte\t\tstyles[MAXLIGHTMAPS];\n\tint\t\t\tlightofs;\t\t// start of [numstyles*surfsize] samples\n} dface_t;\n\ntypedef struct\n{\n\tint\t\t\t\tcontents;\t\t\t// OR of all brushes (not needed?)\n\n\tshort\t\t\tcluster;\n\tshort\t\t\tarea;\n\n\tshort\t\t\tmins[3];\t\t\t// for frustum culling\n\tshort\t\t\tmaxs[3];\n\n\tunsigned short\tfirstleafface;\n\tunsigned short\tnumleaffaces;\n\n\tunsigned short\tfirstleafbrush;\n\tunsigned short\tnumleafbrushes;\n} dleaf_t;\n\ntypedef struct\n{\n\tunsigned short\tplanenum;\t\t// facing out of the leaf\n\tshort\ttexinfo;\n} dbrushside_t;\n\ntypedef struct\n{\n\tint\t\t\tfirstside;\n\tint\t\t\tnumsides;\n\tint\t\t\tcontents;\n} dbrush_t;\n\n#define\tANGLE_UP\t-1\n#define\tANGLE_DOWN\t-2\n\n\n// the visibility lump consists of a header with a count, then\n// byte offsets for the PVS and PHS of each cluster, then the raw\n// compressed bit vectors\n#define\tDVIS_PVS\t0\n#define\tDVIS_PHS\t1\ntypedef struct\n{\n\tint\t\t\tnumclusters;\n\tint\t\t\tbitofs[8][2];\t// bitofs[numclusters][2]\n} dvis_t;\n\n// each area has a list of portals that lead into other areas\n// when portals are closed, other areas may not be visible or\n// hearable even if the vis info says that it should be\ntypedef struct\n{\n\tint\t\tportalnum;\n\tint\t\totherarea;\n} dareaportal_t;\n\ntypedef struct\n{\n\tint\t\tnumareaportals;\n\tint\t\tfirstareaportal;\n} darea_t;\n"
  },
  {
    "path": "code/bspc/sinfiles.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*\n==============================================================================\n\n  .BSP file format\n\n==============================================================================\n*/\n\n#define SIN\n\n#define SINBSPVERSION\t41\n\n// upper design bounds\n// leaffaces, leafbrushes, planes, and verts are still bounded by\n// 16 bit short limits\n#define\tSIN_MAX_MAP_MODELS\t\t1024\n#define\tSIN_MAX_MAP_BRUSHES\t\t8192\n#define\tSIN_MAX_MAP_ENTITIES\t2048\n#define\tSIN_MAX_MAP_ENTSTRING\t0x40000\n#define\tSIN_MAX_MAP_TEXINFO\t\t8192\n\n#define\tSIN_MAX_MAP_AREAS\t\t256\n#define\tSIN_MAX_MAP_AREAPORTALS\t1024\n#define\tSIN_MAX_MAP_PLANES\t\t65536\n#define\tSIN_MAX_MAP_NODES\t\t65536\n#define\tSIN_MAX_MAP_BRUSHSIDES\t65536\n#define\tSIN_MAX_MAP_LEAFS\t\t65536\n#define\tSIN_MAX_MAP_VERTS\t\t65536\n#define\tSIN_MAX_MAP_FACES\t\t65536\n#define\tSIN_MAX_MAP_LEAFFACES\t65536\n#define\tSIN_MAX_MAP_LEAFBRUSHES 65536\n#define\tSIN_MAX_MAP_PORTALS\t\t65536\n#define\tSIN_MAX_MAP_EDGES\t\t128000\n#define\tSIN_MAX_MAP_SURFEDGES\t256000\n#define\tSIN_MAX_MAP_LIGHTING\t0x320000\n#define\tSIN_MAX_MAP_VISIBILITY\t0x280000\n\n#ifdef SIN\n#define\tSIN_MAX_MAP_LIGHTINFO\t\t8192\n#endif\n\n#ifdef SIN\n#undef SIN_MAX_MAP_LIGHTING\t//undef the Quake2 bsp version\n#define\tSIN_MAX_MAP_LIGHTING\t0x300000\n#endif\n\n#ifdef SIN\n#undef SIN_MAX_MAP_VISIBILITY\t//undef the Quake2 bsp version\n#define\tSIN_MAX_MAP_VISIBILITY\t0x280000\n#endif\n\n//=============================================================================\n\ntypedef struct\n{\n\tint\t\tfileofs, filelen;\n} sin_lump_t;\n\n#define\tSIN_LUMP_ENTITIES\t\t0\n#define\tSIN_LUMP_PLANES\t\t\t1\n#define\tSIN_LUMP_VERTEXES\t\t2\n#define\tSIN_LUMP_VISIBILITY\t\t3\n#define\tSIN_LUMP_NODES\t\t\t4\n#define\tSIN_LUMP_TEXINFO\t\t5\n#define\tSIN_LUMP_FACES\t\t\t6\n#define\tSIN_LUMP_LIGHTING\t\t7\n#define\tSIN_LUMP_LEAFS\t\t\t8\n#define\tSIN_LUMP_LEAFFACES\t\t9\n#define\tSIN_LUMP_LEAFBRUSHES\t10\n#define\tSIN_LUMP_EDGES\t\t\t11\n#define\tSIN_LUMP_SURFEDGES\t\t12\n#define\tSIN_LUMP_MODELS\t\t\t13\n#define\tSIN_LUMP_BRUSHES\t\t14\n#define\tSIN_LUMP_BRUSHSIDES\t\t15\n#define\tSIN_LUMP_POP\t\t\t16\n#define\tSIN_LUMP_AREAS\t\t\t17\n#define\tSIN_LUMP_AREAPORTALS\t18\n\n#ifdef SIN\n#define\tSIN_LUMP_LIGHTINFO \t19\n#define\tSINHEADER_LUMPS\t\t20\n#endif\n\ntypedef struct\n{\n\tint\t\t\tident;\n\tint\t\t\tversion;\t\n\tsin_lump_t\tlumps[SINHEADER_LUMPS];\n} sin_dheader_t;\n\ntypedef struct\n{\n\tfloat\t\tmins[3], maxs[3];\n\tfloat\t\torigin[3];\t\t// for sounds or lights\n\tint\t\t\theadnode;\n\tint\t\t\tfirstface, numfaces;\t// submodels just draw faces\n\t\t\t\t\t\t\t\t\t\t// without walking the bsp tree\n} sin_dmodel_t;\n\ntypedef struct\n{\n\tfloat\tpoint[3];\n} sin_dvertex_t;\n\n\n// 0-2 are axial planes\n#define\tPLANE_X\t\t\t0\n#define\tPLANE_Y\t\t\t1\n#define\tPLANE_Z\t\t\t2\n\n// 3-5 are non-axial planes snapped to the nearest\n#define\tPLANE_ANYX\t\t3\n#define\tPLANE_ANYY\t\t4\n#define\tPLANE_ANYZ\t\t5\n\n// planes (x&~1) and (x&~1)+1 are allways opposites\n\ntypedef struct\n{\n\tfloat\tnormal[3];\n\tfloat\tdist;\n\tint\t\ttype;\t\t// PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate\n} sin_dplane_t;\n\n\n// contents flags are seperate bits\n// a given brush can contribute multiple content bits\n// multiple brushes can be in a single leaf\n\n// these definitions also need to be in q_shared.h!\n\n// lower bits are stronger, and will eat weaker brushes completely\n#ifdef SIN\n#define\tCONTENTS_FENCE\t\t\t4\n#endif\n// remaining contents are non-visible, and don't eat brushes\n\n#ifdef SIN\n#define\tCONTENTS_DUMMYFENCE\t0x1000\n#endif\n\n#ifdef SIN\n#define\tSURF_MASKED\t\t0x2\t\t// surface texture is masked\n#endif\n\n#define\tSURF_SKY\t\t0x4\t\t// don't draw, but add to skybox\n#define\tSURF_WARP\t\t0x8\t\t// turbulent water warp\n\n#ifdef SIN\n#define\tSURF_NONLIT\t   0x10\t// surface is not lit\n#define\tSURF_NOFILTER  0x20\t// surface is not bi-linear filtered\n#endif\n\n#define\tSURF_FLOWING\t0x40\t// scroll towards angle\n#define\tSURF_NODRAW\t\t0x80\t// don't bother referencing the texture\n\n#define\tSURF_HINT\t\t0x100\t// make a primary bsp splitter\n#define\tSURF_SKIP\t\t0x200\t// completely ignore, allowing non-closed brushes\n\n#ifdef SIN\n#define\tSURF_CONVEYOR  0x40\t// surface is not lit\n#endif\n\n#ifdef SIN\n#define\tSURF_WAVY            0x400       // surface has waves\n#define\tSURF_RICOCHET\t\t   0x800\t      // projectiles bounce literally bounce off this surface\n#define\tSURF_PRELIT\t\t      0x1000\t   // surface has intensity information for pre-lighting\n#define\tSURF_MIRROR\t\t      0x2000\t   // surface is a mirror\n#define\tSURF_CONSOLE         0x4000\t   // surface is a console\n#define\tSURF_USECOLOR        0x8000\t   // surface is lit with non-lit * color\n#define\tSURF_HARDWAREONLY    0x10000     // surface has been damaged\n#define\tSURF_DAMAGE          0x20000     // surface can be damaged\n#define\tSURF_WEAK            0x40000     // surface has weak hit points\n#define\tSURF_NORMAL          0x80000     // surface has normal hit points\n#define\tSURF_ADD             0x100000    // surface will be additive\n#define\tSURF_ENVMAPPED       0x200000    // surface is envmapped\n#define\tSURF_RANDOMANIMATE   0x400000    // surface start animating on a random frame\n#define\tSURF_ANIMATE         0x800000    // surface animates\n#define\tSURF_RNDTIME         0x1000000   // time between animations is random\n#define\tSURF_TRANSLATE       0x2000000   // surface translates\n#define\tSURF_NOMERGE         0x4000000   // surface is not merged in csg phase\n#define  SURF_TYPE_BIT0       0x8000000   // 0 bit of surface type\n#define  SURF_TYPE_BIT1       0x10000000  // 1 bit of surface type\n#define  SURF_TYPE_BIT2       0x20000000  // 2 bit of surface type\n#define  SURF_TYPE_BIT3       0x40000000  // 3 bit of surface type\n\n#define SURF_START_BIT        27\n#define SURFACETYPE_FROM_FLAGS( x ) ( ( x >> (SURF_START_BIT) ) & 0xf )\n\n\n#define  SURF_TYPE_SHIFT(x)   ( (x) << (SURF_START_BIT) ) // macro for getting proper bit mask\n\n#define  SURF_TYPE_NONE       SURF_TYPE_SHIFT(0)\n#define  SURF_TYPE_WOOD       SURF_TYPE_SHIFT(1)\n#define  SURF_TYPE_METAL      SURF_TYPE_SHIFT(2)\n#define  SURF_TYPE_STONE      SURF_TYPE_SHIFT(3)\n#define  SURF_TYPE_CONCRETE   SURF_TYPE_SHIFT(4)\n#define  SURF_TYPE_DIRT       SURF_TYPE_SHIFT(5)\n#define  SURF_TYPE_FLESH      SURF_TYPE_SHIFT(6)\n#define  SURF_TYPE_GRILL      SURF_TYPE_SHIFT(7)\n#define  SURF_TYPE_GLASS      SURF_TYPE_SHIFT(8)\n#define  SURF_TYPE_FABRIC     SURF_TYPE_SHIFT(9)\n#define  SURF_TYPE_MONITOR    SURF_TYPE_SHIFT(10)\n#define  SURF_TYPE_GRAVEL     SURF_TYPE_SHIFT(11)\n#define  SURF_TYPE_VEGETATION SURF_TYPE_SHIFT(12)\n#define  SURF_TYPE_PAPER      SURF_TYPE_SHIFT(13)\n#define  SURF_TYPE_DUCT       SURF_TYPE_SHIFT(14)\n#define  SURF_TYPE_WATER      SURF_TYPE_SHIFT(15)\n#endif\n\n\ntypedef struct\n{\n\tint\t\t\tplanenum;\n\tint\t\t\tchildren[2];\t// negative numbers are -(leafs+1), not nodes\n\tshort\t\tmins[3];\t\t// for frustom culling\n\tshort\t\tmaxs[3];\n\tunsigned short\tfirstface;\n\tunsigned short\tnumfaces;\t// counting both sides\n} sin_dnode_t;\n\n#ifdef SIN\n\ntypedef struct sin_lightvalue_s\n{\n    int\t\tvalue;\t\t\t// light emission, etc\n    vec3_t\tcolor;\n    float\tdirect;\n    float\tdirectangle;\n    float\tdirectstyle;\n    char\t\tdirectstylename[32];\n} sin_lightvalue_t;\n\ntypedef struct sin_texinfo_s\n{\n    float\t\tvecs[2][4];\t\t// [s/t][xyz offset]\n    int\t\t\tflags;\t\t\t// miptex flags + overrides\n    char\t\t   texture[64];\t// texture name (textures/*.wal)\n    int\t\t\tnexttexinfo;\t// for animations, -1 = end of chain\n    float      trans_mag;\n    int        trans_angle;\n    int        base_angle;\n    float      animtime;\n    float      nonlit;\n    float      translucence;\n    float      friction;\n    float      restitution;\n    vec3_t     color;\n    char       groupname[32];\n} sin_texinfo_t;\n\n#endif //SIN\n\n// note that edge 0 is never used, because negative edge nums are used for\n// counterclockwise use of the edge in a face\ntypedef struct\n{\n\tunsigned short\tv[2];\t\t// vertex numbers\n} sin_dedge_t;\n\n#ifdef MAXLIGHTMAPS\n#undef MAXLIGHTMAPS\n#endif\n#define\tMAXLIGHTMAPS\t16\ntypedef struct\n{\n\tunsigned short\tplanenum;\n\tshort\t\tside;\n\n\tint\t\tfirstedge;\t\t// we must support > 64k edges\n\tshort\t\tnumedges;\t\n\tshort\t\ttexinfo;\n\n// lighting info\n\tbyte\t\tstyles[MAXLIGHTMAPS];\n\tint\t\tlightofs;\t\t// start of [numstyles*surfsize] samples\n#ifdef SIN\n   int      lightinfo;\n#endif\n} sin_dface_t;\n\ntypedef struct\n{\n\tint\t\t\t\tcontents;\t\t\t// OR of all brushes (not needed?)\n\n\tshort\t\t\tcluster;\n\tshort\t\t\tarea;\n\n\tshort\t\t\tmins[3];\t\t\t// for frustum culling\n\tshort\t\t\tmaxs[3];\n\n\tunsigned short\tfirstleafface;\n\tunsigned short\tnumleaffaces;\n\n\tunsigned short\tfirstleafbrush;\n\tunsigned short\tnumleafbrushes;\n} sin_dleaf_t;\n\ntypedef struct\n{\n\tunsigned short\tplanenum;\t\t// facing out of the leaf\n\tshort\ttexinfo;\n#ifdef SIN\n   int lightinfo;\n#endif\n} sin_dbrushside_t;\n\ntypedef struct\n{\n\tint\t\t\tfirstside;\n\tint\t\t\tnumsides;\n\tint\t\t\tcontents;\n} sin_dbrush_t;\n\n#define\tANGLE_UP\t-1\n#define\tANGLE_DOWN\t-2\n\n\n// the visibility lump consists of a header with a count, then\n// byte offsets for the PVS and PHS of each cluster, then the raw\n// compressed bit vectors\n#define\tDVIS_PVS\t0\n#define\tDVIS_PHS\t1\ntypedef struct\n{\n\tint\t\t\tnumclusters;\n\tint\t\t\tbitofs[8][2];\t// bitofs[numclusters][2]\n} sin_dvis_t;\n\n// each area has a list of portals that lead into other areas\n// when portals are closed, other areas may not be visible or\n// hearable even if the vis info says that it should be\ntypedef struct\n{\n\tint\t\tportalnum;\n\tint\t\totherarea;\n} sin_dareaportal_t;\n\ntypedef struct\n{\n\tint\t\tnumareaportals;\n\tint\t\tfirstareaportal;\n} sin_darea_t;\n"
  },
  {
    "path": "code/bspc/tetrahedron.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n#include \"l_mem.h\"\n#include \"../botlib/aasfile.h\"\n#include \"aas_store.h\"\n#include \"aas_cfg.h\"\n#include \"aas_file.h\"\n\n//\n// creating tetrahedrons from a arbitrary world bounded by triangles\n//\n// a triangle has 3 corners and 3 edges\n// a tetrahedron is build out of 4 triangles\n// a tetrahedron has 6 edges\n// we start with a world bounded by triangles, a side of a triangle facing\n// towards the oudside of the world is marked as part of tetrahedron -1\n//\n// a tetrahedron is defined by two non-coplanar triangles with a shared edge\n//\n// a tetrahedron is defined by one triangle and a vertex not in the triangle plane\n//\n// if all triangles using a specific vertex have tetrahedrons\n// at both sides then this vertex will never be part of a new tetrahedron\n//\n// if all triangles using a specific edge have tetrahedrons\n// at both sides then this vertex will never be part of a new tetrahedron\n//\n// each triangle can only be shared by two tetrahedrons\n// when all triangles have tetrahedrons at both sides then we're done\n//\n// if we cannot create any new tetrahedrons and there is at least one triangle\n// which has a tetrahedron only at one side then the world leaks\n//\n\n#define Sign(x)\t\t(x < 0 ? 1 : 0)\n\n#define MAX_TH_VERTEXES\t\t\t128000\n#define MAX_TH_PLANES\t\t\t128000\n#define MAX_TH_EDGES\t\t\t512000\n#define MAX_TH_TRIANGLES\t\t51200\n#define MAX_TH_TETRAHEDRONS\t\t12800\n\n#define PLANEHASH_SIZE\t\t\t1024\n#define EDGEHASH_SIZE\t\t\t1024\n#define TRIANGLEHASH_SIZE\t\t1024\n#define VERTEXHASH_SHIFT\t\t7\n#define VERTEXHASH_SIZE\t\t\t((MAX_MAP_BOUNDS>>(VERTEXHASH_SHIFT-1))+1)\t//was 64\n\n#define\tNORMAL_EPSILON\t\t\t0.0001\n#define DIST_EPSILON\t\t\t0.1\n#define VERTEX_EPSILON\t\t\t0.01\n#define INTEGRAL_EPSILON\t\t0.01\n\n\n//plane\ntypedef struct th_plane_s\n{\n\tvec3_t normal;\n\tfloat dist;\n\tint type;\n\tint signbits;\n\tstruct th_plane_s *hashnext;\t\t//next plane in hash\n} th_plane_t;\n\n//vertex\ntypedef struct th_vertex_s\n{\n\tvec3_t v;\n\tint usercount;\t\t\t\t\t\t//2x the number of to be processed\n\t\t\t\t\t\t\t\t\t\t//triangles using this vertex\n\tstruct th_vertex_s *hashnext;\t\t//next vertex in hash\n} th_vertex_t;\n\n//edge\ntypedef struct th_edge_s\n{\n\tint v[2];\t\t\t\t\t\t\t//vertex indexes\n\tint usercount;\t\t\t\t\t\t//number of to be processed\n\t\t\t\t\t\t\t\t\t\t//triangles using this edge\n\tstruct th_edge_s *hashnext;\t\t\t//next edge in hash\n} th_edge_t;\n\n//triangle\ntypedef struct th_triangle_s\n{\n\tint edges[3];\t\t\t\t\t\t//negative if edge is flipped\n\tth_plane_t planes[3];\t\t\t\t//triangle bounding planes\n\tint planenum;\t\t\t\t\t\t//plane the triangle is in\n\tint front;\t\t\t\t\t\t\t//tetrahedron at the front\n\tint back;\t\t\t\t\t\t\t//tetrahedron at the back\n\tvec3_t mins, maxs;\t\t\t\t\t//triangle bounding box\n\tstruct th_triangle_s *prev, *next;\t//links in linked triangle lists\n\tstruct th_triangle_s *hashnext;\t\t//next triangle in hash\n} th_triangle_t;\n\n//tetrahedron\ntypedef struct th_tetrahedron_s\n{\n\tint triangles[4];\t\t\t\t\t//negative if at backside of triangle\n\tfloat volume;\t\t\t\t\t\t//tetrahedron volume\n} th_tetrahedron_t;\n\ntypedef struct th_s\n{\n\t//vertexes\n\tint numvertexes;\n\tth_vertex_t *vertexes;\n\tth_vertex_t *vertexhash[VERTEXHASH_SIZE * VERTEXHASH_SIZE];\n\t//planes\n\tint numplanes;\n\tth_plane_t *planes;\n\tth_plane_t *planehash[PLANEHASH_SIZE];\n\t//edges\n\tint numedges;\n\tth_edge_t *edges;\n\tth_edge_t *edgehash[EDGEHASH_SIZE];\n\t//triangles\n\tint numtriangles;\n\tth_triangle_t *triangles;\n\tth_triangle_t *trianglehash[TRIANGLEHASH_SIZE];\n\t//tetrahedrons\n\tint numtetrahedrons;\n\tth_tetrahedron_t *tetrahedrons;\n} th_t;\n\nth_t thworld;\n\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid TH_InitMaxTH(void)\n{\n\t//get memory for the tetrahedron data\n\tthworld.vertexes = (th_vertex_t *) GetClearedMemory(MAX_TH_VERTEXES * sizeof(th_vertex_t));\n\tthworld.planes = (th_plane_t *) GetClearedMemory(MAX_TH_PLANES * sizeof(th_plane_t));\n\tthworld.edges = (th_edge_t *) GetClearedMemory(MAX_TH_EDGES * sizeof(th_edge_t));\n\tthworld.triangles = (th_triangle_t *) GetClearedMemory(MAX_TH_TRIANGLES * sizeof(th_triangle_t));\n\tthworld.tetrahedrons = (th_tetrahedron_t *) GetClearedMemory(MAX_TH_TETRAHEDRONS * sizeof(th_tetrahedron_t));\n\t//reset the hash tables\n\tmemset(thworld.vertexhash, 0, VERTEXHASH_SIZE * sizeof(th_vertex_t *));\n\tmemset(thworld.planehash, 0, PLANEHASH_SIZE * sizeof(th_plane_t *));\n\tmemset(thworld.edgehash, 0, EDGEHASH_SIZE * sizeof(th_edge_t *));\n\tmemset(thworld.trianglehash, 0, TRIANGLEHASH_SIZE * sizeof(th_triangle_t *));\n} //end of the function TH_InitMaxTH\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid TH_FreeMaxTH(void)\n{\n\tif (thworld.vertexes) FreeMemory(thworld.vertexes);\n\tthworld.vertexes = NULL;\n\tthworld.numvertexes = 0;\n\tif (thworld.planes) FreeMemory(thworld.planes);\n\tthworld.planes = NULL;\n\tthworld.numplanes = 0;\n\tif (thworld.edges) FreeMemory(thworld.edges);\n\tthworld.edges = NULL;\n\tthworld.numedges = 0;\n\tif (thworld.triangles) FreeMemory(thworld.triangles);\n\tthworld.triangles = NULL;\n\tthworld.numtriangles = 0;\n\tif (thworld.tetrahedrons) FreeMemory(thworld.tetrahedrons);\n\tthworld.tetrahedrons = NULL;\n\tthworld.numtetrahedrons = 0;\n} //end of the function TH_FreeMaxTH\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat TH_TriangleArea(th_triangle_t *tri)\n{\n\treturn 0;\n} //end of the function TH_TriangleArea\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nfloat TH_TetrahedronVolume(th_tetrahedron_t *tetrahedron)\n{\n\tint edgenum, verts[3], i, j, v2;\n\tfloat volume, d;\n\tth_triangle_t *tri, *tri2;\n\tth_plane_t *plane;\n\n\ttri = &thworld.triangles[abs(tetrahedron->triangles[0])];\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tedgenum = tri->edges[i];\n\t\tif (edgenum < 0) verts[i] = thworld.edges[abs(edgenum)].v[1];\n\t\telse verts[i] = thworld.edges[edgenum].v[0];\n\t} //end for\n\t//\n\ttri2 = &thworld.triangles[abs(tetrahedron->triangles[1])];\n\tfor (j = 0; j < 3; j++)\n\t{\n\t\tedgenum = tri2->edges[i];\n\t\tif (edgenum < 0) v2 = thworld.edges[abs(edgenum)].v[1];\n\t\telse v2 = thworld.edges[edgenum].v[0];\n\t\tif (v2 != verts[0] &&\n\t\t\tv2 != verts[1] &&\n\t\t\tv2 != verts[2]) break;\n\t} //end for\n\n\tplane = &thworld.planes[tri->planenum];\n\td = -(DotProduct (thworld.vertexes[v2].v, plane->normal) - plane->dist);\n\tvolume = TH_TriangleArea(tri) * d / 3;\n\treturn volume;\n} //end of the function TH_TetrahedronVolume\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TH_PlaneSignBits(vec3_t normal)\n{\n\tint i, signbits;\n\n\tsignbits = 0;\n\tfor (i = 2; i >= 0; i--)\n\t{\n\t\tsignbits = (signbits << 1) + Sign(normal[i]);\n\t} //end for\n\treturn signbits;\n} //end of the function TH_PlaneSignBits\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TH_PlaneTypeForNormal(vec3_t normal)\n{\n\tvec_t\tax, ay, az;\n\t\n// NOTE: should these have an epsilon around 1.0?\t\t\n\tif (normal[0] == 1.0 || normal[0] == -1.0)\n\t\treturn PLANE_X;\n\tif (normal[1] == 1.0 || normal[1] == -1.0)\n\t\treturn PLANE_Y;\n\tif (normal[2] == 1.0 || normal[2] == -1.0)\n\t\treturn PLANE_Z;\n\t\t\n\tax = fabs(normal[0]);\n\tay = fabs(normal[1]);\n\taz = fabs(normal[2]);\n\t\n\tif (ax >= ay && ax >= az)\n\t\treturn PLANE_ANYX;\n\tif (ay >= ax && ay >= az)\n\t\treturn PLANE_ANYY;\n\treturn PLANE_ANYZ;\n} //end of the function TH_PlaneTypeForNormal\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nqboolean TH_PlaneEqual(th_plane_t *p, vec3_t normal, vec_t dist)\n{\n\tif (\n\t   fabs(p->normal[0] - normal[0]) < NORMAL_EPSILON\n\t&& fabs(p->normal[1] - normal[1]) < NORMAL_EPSILON\n\t&& fabs(p->normal[2] - normal[2]) < NORMAL_EPSILON\n\t&& fabs(p->dist - dist) < DIST_EPSILON )\n\t\treturn true;\n\treturn false;\n} //end of the function TH_PlaneEqual\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid TH_AddPlaneToHash(th_plane_t *p)\n{\n\tint hash;\n\n\thash = (int)fabs(p->dist) / 8;\n\thash &= (PLANEHASH_SIZE-1);\n\n\tp->hashnext = thworld.planehash[hash];\n\tthworld.planehash[hash] = p;\n} //end of the function TH_AddPlaneToHash\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TH_CreateFloatPlane(vec3_t normal, vec_t dist)\n{\n\tth_plane_t *p, temp;\n\n\tif (VectorLength(normal) < 0.5)\n\t\tError (\"FloatPlane: bad normal\");\n\t// create a new plane\n\tif (thworld.numplanes+2 > MAX_TH_PLANES)\n\t\tError (\"MAX_TH_PLANES\");\n\n\tp = &thworld.planes[thworld.numplanes];\n\tVectorCopy (normal, p->normal);\n\tp->dist = dist;\n\tp->type = (p+1)->type = TH_PlaneTypeForNormal (p->normal);\n\tp->signbits = TH_PlaneSignBits(p->normal);\n\n\tVectorSubtract (vec3_origin, normal, (p+1)->normal);\n\t(p+1)->dist = -dist;\n\t(p+1)->signbits = TH_PlaneSignBits((p+1)->normal);\n\n\tthworld.numplanes += 2;\n\n\t// allways put axial planes facing positive first\n\tif (p->type < 3)\n\t{\n\t\tif (p->normal[0] < 0 || p->normal[1] < 0 || p->normal[2] < 0)\n\t\t{\n\t\t\t// flip order\n\t\t\ttemp = *p;\n\t\t\t*p = *(p+1);\n\t\t\t*(p+1) = temp;\n\n\t\t\tTH_AddPlaneToHash(p);\n\t\t\tTH_AddPlaneToHash(p+1);\n\t\t\treturn thworld.numplanes - 1;\n\t\t} //end if\n\t} //end if\n\n\tTH_AddPlaneToHash(p);\n\tTH_AddPlaneToHash(p+1);\n\treturn thworld.numplanes - 2;\n} //end of the function TH_CreateFloatPlane\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid TH_SnapVector(vec3_t normal)\n{\n\tint\t\ti;\n\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tif ( fabs(normal[i] - 1) < NORMAL_EPSILON )\n\t\t{\n\t\t\tVectorClear (normal);\n\t\t\tnormal[i] = 1;\n\t\t\tbreak;\n\t\t} //end if\n\t\tif ( fabs(normal[i] - -1) < NORMAL_EPSILON )\n\t\t{\n\t\t\tVectorClear (normal);\n\t\t\tnormal[i] = -1;\n\t\t\tbreak;\n\t\t} //end if\n\t} //end for\n} //end of the function TH_SnapVector\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid TH_SnapPlane(vec3_t normal, vec_t *dist)\n{\n\tTH_SnapVector(normal);\n\n\tif (fabs(*dist-Q_rint(*dist)) < DIST_EPSILON)\n\t\t*dist = Q_rint(*dist);\n} //end of the function TH_SnapPlane\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TH_FindFloatPlane(vec3_t normal, vec_t dist)\n{\n\tint i;\n\tth_plane_t *p;\n\tint hash, h;\n\n\tTH_SnapPlane (normal, &dist);\n\thash = (int)fabs(dist) / 8;\n\thash &= (PLANEHASH_SIZE-1);\n\n\t// search the border bins as well\n\tfor (i = -1; i <= 1; i++)\n\t{\n\t\th = (hash+i)&(PLANEHASH_SIZE-1);\n\t\tfor (p = thworld.planehash[h]; p; p = p->hashnext)\n\t\t{\n\t\t\tif (TH_PlaneEqual(p, normal, dist))\n\t\t\t{\n\t\t\t\treturn p - thworld.planes;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\treturn TH_CreateFloatPlane(normal, dist);\n} //end of the function TH_FindFloatPlane\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TH_PlaneFromPoints(int v1, int v2, int v3)\n{\n\tvec3_t t1, t2, normal;\n\tvec_t dist;\n\tfloat *p0, *p1, *p2;\n\n\tp0 = thworld.vertexes[v1].v;\n\tp1 = thworld.vertexes[v2].v;\n\tp2 = thworld.vertexes[v3].v;\n\n\tVectorSubtract(p0, p1, t1);\n\tVectorSubtract(p2, p1, t2);\n\tCrossProduct(t1, t2, normal);\n\tVectorNormalize(normal);\n\n\tdist = DotProduct(p0, normal);\n\n\treturn TH_FindFloatPlane(normal, dist);\n} //end of the function TH_PlaneFromPoints\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid TH_AddEdgeUser(int edgenum)\n{\n\tth_edge_t *edge;\n\n\tedge = &thworld.edges[abs(edgenum)];\n\t//increase edge user count\n\tedge->usercount++;\n\t//increase vertex user count as well\n\tthworld.vertexes[edge->v[0]].usercount++;\n\tthworld.vertexes[edge->v[1]].usercount++;\n} //end of the function TH_AddEdgeUser\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid TH_RemoveEdgeUser(int edgenum)\n{\n\tth_edge_t *edge;\n\n\tedge = &thworld.edges[abs(edgenum)];\n\t//decrease edge user count\n\tedge->usercount--;\n\t//decrease vertex user count as well\n\tthworld.vertexes[edge->v[0]].usercount--;\n\tthworld.vertexes[edge->v[1]].usercount--;\n} //end of the function TH_RemoveEdgeUser\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid TH_FreeTriangleEdges(th_triangle_t *tri)\n{\n\tint i;\n\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tTH_RemoveEdgeUser(abs(tri->edges[i]));\n\t} //end for\n} //end of the function TH_FreeTriangleEdges\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nunsigned TH_HashVec(vec3_t vec)\n{\n\tint x, y;\n\n\tx = (MAX_MAP_BOUNDS + (int)(vec[0]+0.5)) >> VERTEXHASH_SHIFT;\n\ty = (MAX_MAP_BOUNDS + (int)(vec[1]+0.5)) >> VERTEXHASH_SHIFT;\n\n\tif (x < 0 || x >= VERTEXHASH_SIZE || y < 0 || y >= VERTEXHASH_SIZE)\n\t\tError(\"HashVec: point %f %f %f outside valid range\", vec[0], vec[1], vec[2]);\n\t\n\treturn y*VERTEXHASH_SIZE + x;\n} //end of the function TH_HashVec\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TH_FindVertex(vec3_t v)\n{\n\tint i, h;\n\tth_vertex_t *vertex;\n\tvec3_t vert;\n\t\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tif ( fabs(v[i] - Q_rint(v[i])) < INTEGRAL_EPSILON)\n\t\t\tvert[i] = Q_rint(v[i]);\n\t\telse\n\t\t\tvert[i] = v[i];\n\t} //end for\n\n\th = TH_HashVec(vert);\n\n\tfor (vertex = thworld.vertexhash[h]; vertex; vertex = vertex->hashnext)\n\t{\n\t\tif (fabs(vertex->v[0] - vert[0]) < VERTEX_EPSILON &&\n\t\t\tfabs(vertex->v[1] - vert[1]) < VERTEX_EPSILON &&\n\t\t\tfabs(vertex->v[2] - vert[2]) < VERTEX_EPSILON)\n\t\t{\n\t\t\treturn vertex - thworld.vertexes;\n\t\t} //end if\n\t} //end for\n\treturn 0;\n} //end of the function TH_FindVertex\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid TH_AddVertexToHash(th_vertex_t *vertex)\n{\n\tint hashvalue;\n\n\thashvalue = TH_HashVec(vertex->v);\n\tvertex->hashnext = thworld.vertexhash[hashvalue];\n\tthworld.vertexhash[hashvalue] = vertex;\n} //end of the function TH_AddVertexToHash\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TH_CreateVertex(vec3_t v)\n{\n\tif (thworld.numvertexes == 0) thworld.numvertexes = 1;\n\tif (thworld.numvertexes >= MAX_TH_VERTEXES)\n\t\tError(\"MAX_TH_VERTEXES\");\n\tVectorCopy(v, thworld.vertexes[thworld.numvertexes].v);\n\tthworld.vertexes[thworld.numvertexes].usercount = 0;\n\tTH_AddVertexToHash(&thworld.vertexes[thworld.numvertexes]);\n\tthworld.numvertexes++;\n\treturn thworld.numvertexes-1;\n} //end of the function TH_CreateVertex\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TH_FindOrCreateVertex(vec3_t v)\n{\n\tint vertexnum;\n\n\tvertexnum = TH_FindVertex(v);\n\tif (!vertexnum) vertexnum = TH_CreateVertex(v);\n\treturn vertexnum;\n} //end of the function TH_FindOrCreateVertex\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TH_FindEdge(int v1, int v2)\n{\n\tint hashvalue;\n\tth_edge_t *edge;\n\n\thashvalue = (v1 + v2) & (EDGEHASH_SIZE-1);\n\n\tfor (edge = thworld.edgehash[hashvalue]; edge; edge = edge->hashnext)\n\t{\n\t\tif (edge->v[0] == v1 && edge->v[1] == v2) return edge - thworld.edges;\n\t\tif (edge->v[1] == v1 && edge->v[0] == v2) return -(edge - thworld.edges);\n\t} //end for\n\treturn 0;\n} //end of the function TH_FindEdge\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid TH_AddEdgeToHash(th_edge_t *edge)\n{\n\tint hashvalue;\n\n\thashvalue = (edge->v[0] + edge->v[1]) & (EDGEHASH_SIZE-1);\n\tedge->hashnext = thworld.edgehash[hashvalue];\n\tthworld.edgehash[hashvalue] = edge;\n} //end of the function TH_AddEdgeToHash\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TH_CreateEdge(int v1, int v2)\n{\n\tth_edge_t *edge;\n\n\tif (thworld.numedges == 0) thworld.numedges = 1;\n\tif (thworld.numedges >= MAX_TH_EDGES)\n\t\tError(\"MAX_TH_EDGES\");\n\tedge = &thworld.edges[thworld.numedges++];\n\tedge->v[0] = v1;\n\tedge->v[1] = v2;\n\tTH_AddEdgeToHash(edge);\n\treturn thworld.numedges-1;\n} //end of the function TH_CreateEdge\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TH_FindOrCreateEdge(int v1, int v2)\n{\n\tint edgenum;\n\n\tedgenum = TH_FindEdge(v1, v2);\n\tif (!edgenum) edgenum = TH_CreateEdge(v1, v2);\n\treturn edgenum;\n} //end of the function TH_FindOrCreateEdge\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TH_FindTriangle(int verts[3])\n{\n\tint i, hashvalue, edges[3];\n\tth_triangle_t *tri;\n\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tedges[i] = TH_FindEdge(verts[i], verts[(i+1)%3]);\n\t\tif (!edges[i]) return false;\n\t} //end for\n\thashvalue = (abs(edges[0]) + abs(edges[1]) + abs(edges[2])) & (TRIANGLEHASH_SIZE-1);\n\tfor (tri = thworld.trianglehash[hashvalue]; tri; tri = tri->next)\n\t{\n\t\tfor (i = 0; i < 3; i++)\n\t\t{\n\t\t\tif (abs(tri->edges[i]) != abs(edges[0]) &&\n\t\t\t\tabs(tri->edges[i]) != abs(edges[1]) &&\n\t\t\t\tabs(tri->edges[i]) != abs(edges[2])) break;\n\t\t} //end for\n\t\tif (i >= 3) return tri - thworld.triangles;\n\t} //end for\n\treturn 0;\n} //end of the function TH_FindTriangle\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid TH_AddTriangleToHash(th_triangle_t *tri)\n{\n\tint hashvalue;\n\n\thashvalue = (abs(tri->edges[0]) + abs(tri->edges[1]) + abs(tri->edges[2])) & (TRIANGLEHASH_SIZE-1);\n\ttri->hashnext = thworld.trianglehash[hashvalue];\n\tthworld.trianglehash[hashvalue] = tri;\n} //end of the function TH_AddTriangleToHash\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid TH_CreateTrianglePlanes(int verts[3], th_plane_t *triplane, th_plane_t *planes)\n{\n\tint i;\n\tvec3_t dir;\n\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tVectorSubtract(thworld.vertexes[verts[(i+1)%3]].v, thworld.vertexes[verts[i]].v, dir);\n\t\tCrossProduct(dir, triplane->normal, planes[i].normal);\n\t\tVectorNormalize(planes[i].normal);\n\t\tplanes[i].dist = DotProduct(thworld.vertexes[verts[i]].v, planes[i].normal);\n\t} //end for\n} //end of the function TH_CreateTrianglePlanes\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TH_CreateTriangle(int verts[3])\n{\n\tth_triangle_t *tri;\n\tint i;\n\n\tif (thworld.numtriangles == 0) thworld.numtriangles = 1;\n\tif (thworld.numtriangles >= MAX_TH_TRIANGLES)\n\t\tError(\"MAX_TH_TRIANGLES\");\n\ttri = &thworld.triangles[thworld.numtriangles++];\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\ttri->edges[i] = TH_FindOrCreateEdge(verts[i], verts[(i+1)%3]);\n\t\tTH_AddEdgeUser(abs(tri->edges[i]));\n\t} //end for\n\ttri->front = 0;\n\ttri->back = 0;\n\ttri->planenum = TH_PlaneFromPoints(verts[0], verts[1], verts[2]);\n\ttri->prev = NULL;\n\ttri->next = NULL;\n\ttri->hashnext = NULL;\n\tTH_CreateTrianglePlanes(verts, &thworld.planes[tri->planenum], tri->planes);\n\tTH_AddTriangleToHash(tri);\n\tClearBounds(tri->mins, tri->maxs);\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tAddPointToBounds(thworld.vertexes[verts[i]].v, tri->mins, tri->maxs);\n\t} //end for\n\treturn thworld.numtriangles-1;\n} //end of the function TH_CreateTriangle\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TH_CreateTetrahedron(int triangles[4])\n{\n\tth_tetrahedron_t *tetrahedron;\n\tint i;\n\n\tif (thworld.numtetrahedrons == 0) thworld.numtetrahedrons = 1;\n\tif (thworld.numtetrahedrons >= MAX_TH_TETRAHEDRONS)\n\t\tError(\"MAX_TH_TETRAHEDRONS\");\n\ttetrahedron = &thworld.tetrahedrons[thworld.numtetrahedrons++];\n\tfor (i = 0; i < 4; i++)\n\t{\n\t\ttetrahedron->triangles[i] = triangles[i];\n\t\tif (thworld.triangles[abs(triangles[i])].front)\n\t\t{\n\t\t\tthworld.triangles[abs(triangles[i])].back = thworld.numtetrahedrons-1;\n\t\t} //end if\n\t\telse\n\t\t{\n\t\t\tthworld.triangles[abs(triangles[i])].front = thworld.numtetrahedrons-1;\n\t\t} //end else\n\t} //end for\n\ttetrahedron->volume = 0;\n\treturn thworld.numtetrahedrons-1;\n} //end of the function TH_CreateTetrahedron\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TH_IntersectTrianglePlanes(int v1, int v2, th_plane_t *triplane, th_plane_t *planes)\n{\n\tfloat *p1, *p2, front, back, frac, d;\n\tint i, side, lastside;\n\tvec3_t mid;\n\n\tp1 = thworld.vertexes[v1].v;\n\tp2 = thworld.vertexes[v2].v;\n\n\tfront = DotProduct(p1, triplane->normal) - triplane->dist;\n\tback = DotProduct(p2, triplane->normal) - triplane->dist;\n\t//if both points at the same side of the plane\n\tif (front < 0.1 && back < 0.1) return false;\n\tif (front > -0.1 && back > -0.1) return false;\n\t//\n\tfrac = front/(front-back);\n\tmid[0] = p1[0] + (p2[0] - p1[0]) * frac;\n\tmid[1] = p1[1] + (p2[1] - p1[1]) * frac;\n\tmid[2] = p1[2] + (p2[2] - p1[2]) * frac;\n\t//if the mid point is at the same side of all the tri bounding planes\n\tlastside = 0;\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\td = DotProduct(mid, planes[i].normal) - planes[i].dist;\n\t\tside = d < 0;\n\t\tif (i && side != lastside) return false;\n\t\tlastside = side;\n\t} //end for\n\treturn true;\n} //end of the function TH_IntersectTrianglePlanes\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TH_OutsideBoundingBox(int v1, int v2, vec3_t mins, vec3_t maxs)\n{\n\tfloat *p1, *p2;\n\tint i;\n\n\tp1 = thworld.vertexes[v1].v;\n\tp2 = thworld.vertexes[v2].v;\n\t//if both points are at the outer side of one of the bounding box planes\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tif (p1[i] < mins[i] && p2[i] < mins[i]) return true;\n\t\tif (p1[i] > maxs[i] && p2[i] > maxs[i]) return true;\n\t} //end for\n\treturn false;\n} //end of the function TH_OutsideBoundingBox\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TH_TryEdge(int v1, int v2)\n{\n\tint i, j, v;\n\tth_plane_t *plane;\n\tth_triangle_t *tri;\n\n\t//if the edge already exists it must be valid\n\tif (TH_FindEdge(v1, v2)) return true;\n\t//test the edge with all existing triangles\n\tfor (i = 1; i < thworld.numtriangles; i++)\n\t{\n\t\ttri = &thworld.triangles[i];\n\t\t//if triangle is enclosed by two tetrahedrons we don't have to test it\n\t\t//because the edge always has to go through another triangle of those\n\t\t//tetrahedrons first to reach the enclosed triangle\n\t\tif (tri->front && tri->back) continue;\n\t\t//if the edges is totally outside the triangle bounding box\n\t\tif (TH_OutsideBoundingBox(v1, v2, tri->mins, tri->maxs)) continue;\n\t\t//if one of the edge vertexes is used by this triangle\n\t\tfor (j = 0; j < 3; j++)\n\t\t{\n\t\t\tv = thworld.edges[abs(tri->edges[j])].v[tri->edges[j] < 0];\n\t\t\tif (v == v1 || v == v2) break;\n\t\t} //end for\n\t\tif (j < 3) continue;\n\t\t//get the triangle plane\n\t\tplane = &thworld.planes[tri->planenum];\n\t\t//if the edge intersects with a triangle then it's not valid\n\t\tif (TH_IntersectTrianglePlanes(v1, v2, plane, tri->planes)) return false;\n\t} //end for\n\treturn true;\n} //end of the function TH_TryEdge\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TH_TryTriangle(int verts[3])\n{\n\tth_plane_t planes[3], triplane;\n\tvec3_t t1, t2;\n\tfloat *p0, *p1, *p2;\n\tint i, j;\n\n\tp0 = thworld.vertexes[verts[0]].v;\n\tp1 = thworld.vertexes[verts[1]].v;\n\tp2 = thworld.vertexes[verts[2]].v;\n\n\tVectorSubtract(p0, p1, t1);\n\tVectorSubtract(p2, p1, t2);\n\tCrossProduct(t1, t2, triplane.normal);\n\tVectorNormalize(triplane.normal);\n\ttriplane.dist = DotProduct(p0, triplane.normal);\n\t//\n\tTH_CreateTrianglePlanes(verts, &triplane, planes);\n\t//test if any existing edge intersects with this triangle\n\tfor (i = 1; i < thworld.numedges; i++)\n\t{\n\t\t//if the edge is only used by triangles with tetrahedrons at both sides\n\t\tif (!thworld.edges[i].usercount) continue;\n\t\t//if one of the triangle vertexes is used by this edge\n\t\tfor (j = 0; j < 3; j++)\n\t\t{\n\t\t\tif (verts[j] == thworld.edges[j].v[0] ||\n\t\t\t\tverts[j] == thworld.edges[j].v[1]) break;\n\t\t} //end for\n\t\tif (j < 3) continue;\n\t\t//if this edge intersects with the triangle\n\t\tif (TH_IntersectTrianglePlanes(thworld.edges[i].v[0], thworld.edges[i].v[1], &triplane, planes)) return false;\n\t} //end for\n\treturn true;\n} //end of the function TH_TryTriangle\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid TH_AddTriangleToList(th_triangle_t **trianglelist, th_triangle_t *tri)\n{\n\ttri->prev = NULL;\n\ttri->next = *trianglelist;\n\tif (*trianglelist) (*trianglelist)->prev = tri;\n\t*trianglelist = tri;\n} //end of the function TH_AddTriangleToList\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid TH_RemoveTriangleFromList(th_triangle_t **trianglelist, th_triangle_t *tri)\n{\n\tif (tri->next) tri->next->prev = tri->prev;\n\tif (tri->prev) tri->prev->next = tri->next;\n\telse *trianglelist = tri->next;\n} //end of the function TH_RemoveTriangleFromList\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TH_FindTetrahedron1(th_triangle_t *tri, int *triangles)\n{\n\tint i, j, edgenum, side, v1, v2, v3, v4;\n\tint verts1[3], verts2[3];\n\tth_triangle_t *tri2;\n\n\t//find another triangle with a shared edge\n\tfor (tri2 = tri->next; tri2; tri2 = tri2->next)\n\t{\n\t\t//if the triangles are in the same plane\n\t\tif ((tri->planenum & ~1) == (tri2->planenum & ~1)) continue;\n\t\t//try to find a shared edge\n\t\tfor (i = 0; i < 3; i++)\n\t\t{\n\t\t\tedgenum = abs(tri->edges[i]);\n\t\t\tfor (j = 0; j < 3; j++)\n\t\t\t{\n\t\t\t\tif (edgenum == abs(tri2->edges[j])) break;\n\t\t\t} //end for\n\t\t\tif (j < 3) break;\n\t\t} //end for\n\t\t//if the triangles have a shared edge\n\t\tif (i < 3)\n\t\t{\n\t\t\tedgenum = tri->edges[(i+1)%3];\n\t\t\tif (edgenum < 0) v1 = thworld.edges[abs(edgenum)].v[0];\n\t\t\telse v1 = thworld.edges[edgenum].v[1];\n\t\t\tedgenum = tri2->edges[(j+1)%3];\n\t\t\tif (edgenum < 0) v2 = thworld.edges[abs(edgenum)].v[0];\n\t\t\telse v2 = thworld.edges[edgenum].v[1];\n\t\t\t//try the new edge\n\t\t\tif (TH_TryEdge(v1, v2))\n\t\t\t{\n\t\t\t\tedgenum = tri->edges[i];\n\t\t\t\tside = edgenum < 0;\n\t\t\t\t//get the vertexes of the shared edge\n\t\t\t\tv3 = thworld.edges[abs(edgenum)].v[side];\n\t\t\t\tv4 = thworld.edges[abs(edgenum)].v[!side];\n\t\t\t\t//try the two new triangles\n\t\t\t\tverts1[0] = v1;\n\t\t\t\tverts1[1] = v2;\n\t\t\t\tverts1[2] = v3;\n\t\t\t\ttriangles[2] = TH_FindTriangle(verts1);\n\t\t\t\tif (triangles[2] || TH_TryTriangle(verts1))\n\t\t\t\t{\n\t\t\t\t\tverts2[0] = v2;\n\t\t\t\t\tverts2[1] = v1;\n\t\t\t\t\tverts2[2] = v4;\n\t\t\t\t\ttriangles[3] = TH_FindTriangle(verts2);\n\t\t\t\t\tif (triangles[3] || TH_TryTriangle(verts2))\n\t\t\t\t\t{\n\t\t\t\t\t\ttriangles[0] = tri - thworld.triangles;\n\t\t\t\t\t\ttriangles[1] = tri2 - thworld.triangles;\n\t\t\t\t\t\tif (!triangles[2]) triangles[2] = TH_CreateTriangle(verts1);\n\t\t\t\t\t\tif (!triangles[3]) triangles[3] = TH_CreateTriangle(verts2);\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t} //end if\n\t} //end for\n\treturn false;\n} //end of the function TH_FindTetrahedron\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TH_FindTetrahedron2(th_triangle_t *tri, int *triangles)\n{\n\tint i, edgenum, v1, verts[3], triverts[3];\n\tfloat d;\n\tth_plane_t *plane;\n\n\t//get the verts of this triangle\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tedgenum = tri->edges[i];\n\t\tif (edgenum < 0) verts[i] = thworld.edges[abs(edgenum)].v[1];\n\t\telse verts[i] = thworld.edges[edgenum].v[0];\n\t} //end for\n\t//\n\tplane = &thworld.planes[tri->planenum];\n\tfor (v1 = 0; v1 < thworld.numvertexes; v1++)\n\t{\n\t\t//if the vertex is only used by triangles with tetrahedrons at both sides\n\t\tif (!thworld.vertexes[v1].usercount) continue;\n\t\t//check if the vertex is not coplanar with the triangle\n\t\td = DotProduct(thworld.vertexes[v1].v, plane->normal) - plane->dist;\n\t\tif (fabs(d) < 1) continue;\n\t\t//check if we can create edges from the triangle towards this new vertex\n\t\tfor (i = 0; i < 3; i++)\n\t\t{\n\t\t\tif (v1 == verts[i]) break;\n\t\t\tif (!TH_TryEdge(v1, verts[i])) break;\n\t\t} //end for\n\t\tif (i < 3) continue;\n\t\t//check if the triangles are valid\n\t\tfor (i = 0; i < 3; i++)\n\t\t{\n\t\t\ttriverts[0] = v1;\n\t\t\ttriverts[1] = verts[i];\n\t\t\ttriverts[2] = verts[(i+1)%3];\n\t\t\t//if the triangle already exists then it is valid\n\t\t\ttriangles[i] = TH_FindTriangle(triverts);\n\t\t\tif (!triangles[i])\n\t\t\t{\n\t\t\t\tif (!TH_TryTriangle(triverts)) break;\n\t\t\t} //end if\n\t\t} //end for\n\t\tif (i < 3) continue;\n\t\t//create the tetrahedron triangles using the new vertex\n\t\tfor (i = 0; i < 3; i++)\n\t\t{\n\t\t\tif (!triangles[i])\n\t\t\t{\n\t\t\t\ttriverts[0] = v1;\n\t\t\t\ttriverts[1] = verts[i];\n\t\t\t\ttriverts[2] = verts[(i+1)%3];\n\t\t\t\ttriangles[i] = TH_CreateTriangle(triverts);\n\t\t\t} //end if\n\t\t} //end for\n\t\t//add the existing triangle\n\t\ttriangles[3] = tri - thworld.triangles;\n\t\t//\n\t\treturn true;\n\t} //end for\n\treturn false;\n} //end of the function TH_FindTetrahedron2\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid TH_TetrahedralDecomposition(th_triangle_t *triangles)\n{\n\tint i, thtriangles[4], numtriangles;\n\tth_triangle_t *donetriangles, *tri;\n\n\tdonetriangles = NULL;\n\n\t/*\n\tnumtriangles = 0;\n\tqprintf(\"%6d triangles\", numtriangles);\n\tfor (tri = triangles; tri; tri = triangles)\n\t{\n\t\tqprintf(\"\\r%6d\", numtriangles++);\n\t\tif (!TH_FindTetrahedron1(tri, thtriangles))\n\t\t{\n//\t\t\tif (!TH_FindTetrahedron2(tri, thtriangles))\n\t\t\t{\n//\t\t\t\tError(\"triangle without tetrahedron\");\n\t\t\t\tTH_RemoveTriangleFromList(&triangles, tri);\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t} //end if\n\t\t//create a tetrahedron from the triangles\n\t\tTH_CreateTetrahedron(thtriangles);\n\t\t//\n\t\tfor (i = 0; i < 4; i++)\n\t\t{\n\t\t\tif (thworld.triangles[abs(thtriangles[i])].front &&\n\t\t\t\tthworld.triangles[abs(thtriangles[i])].back)\n\t\t\t{\n\t\t\t\tTH_RemoveTriangleFromList(&triangles, &thworld.triangles[abs(thtriangles[i])]);\n\t\t\t\tTH_AddTriangleToList(&donetriangles, &thworld.triangles[abs(thtriangles[i])]);\n\t\t\t\tTH_FreeTriangleEdges(&thworld.triangles[abs(thtriangles[i])]);\n\t\t\t} //end if\n\t\t\telse\n\t\t\t{\n\t\t\t\tTH_AddTriangleToList(&triangles, &thworld.triangles[abs(thtriangles[i])]);\n\t\t\t} //end else\n\t\t} //end for\n\t} //end for*/\n\tqprintf(\"%6d tetrahedrons\", thworld.numtetrahedrons);\n\tdo\n\t{\n\t\tdo\n\t\t{\n\t\t\tnumtriangles = 0;\n\t\t\tfor (i = 1; i < thworld.numtriangles; i++)\n\t\t\t{\n\t\t\t\ttri = &thworld.triangles[i];\n\t\t\t\tif (tri->front && tri->back) continue;\n\t\t\t\t//qprintf(\"\\r%6d\", numtriangles++);\n\t\t\t\tif (!TH_FindTetrahedron1(tri, thtriangles))\n\t\t\t\t{\n//\t\t\t\t\tif (!TH_FindTetrahedron2(tri, thtriangles))\n\t\t\t\t\t{\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if\n\t\t\t\tnumtriangles++;\n\t\t\t\t//create a tetrahedron from the triangles\n\t\t\t\tTH_CreateTetrahedron(thtriangles);\n\t\t\t\tqprintf(\"\\r%6d\", thworld.numtetrahedrons);\n\t\t\t} //end for\n\t\t} while(numtriangles);\n \t\tfor (i = 1; i < thworld.numtriangles; i++)\n\t\t{\n\t\t\ttri = &thworld.triangles[i];\n\t\t\tif (tri->front && tri->back) continue;\n\t\t\t//qprintf(\"\\r%6d\", numtriangles++);\n//\t\t\tif (!TH_FindTetrahedron1(tri, thtriangles))\n\t\t\t{\n\t\t\t\tif (!TH_FindTetrahedron2(tri, thtriangles))\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t} //end if\n\t\t\t} //end if\n\t\t\tnumtriangles++;\n\t\t\t//create a tetrahedron from the triangles\n\t\t\tTH_CreateTetrahedron(thtriangles);\n\t\t\tqprintf(\"\\r%6d\", thworld.numtetrahedrons);\n\t\t} //end for\n\t} while(numtriangles);\n\t//\n\tnumtriangles = 0;\n\tfor (i = 1; i < thworld.numtriangles; i++)\n\t{\n\t\ttri = &thworld.triangles[i];\n\t\tif (!tri->front && !tri->back) numtriangles++;\n\t} //end for\n\tLog_Print(\"\\r%6d triangles with front only\\n\", numtriangles);\n\tLog_Print(\"\\r%6d tetrahedrons\\n\", thworld.numtetrahedrons-1);\n} //end of the function TH_TetrahedralDecomposition\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid TH_AASFaceVertex(aas_face_t *face, int index, vec3_t vertex)\n{\n\tint edgenum, side;\n\n\tedgenum = aasworld.edgeindex[face->firstedge + index];\n\tside = edgenum < 0;\n\tVectorCopy(aasworld.vertexes[aasworld.edges[abs(edgenum)].v[side]], vertex);\n} //end of the function TH_AASFaceVertex\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TH_Colinear(float *v0, float *v1, float *v2)\n{\n\tvec3_t t1, t2, vcross;\n\tfloat d;\n\t\n\tVectorSubtract(v1, v0, t1);\n\tVectorSubtract(v2, v0, t2);\n\tCrossProduct (t1, t2, vcross);\n\td = VectorLength( vcross );\n\n\t// if cross product is zero point is colinear\n\tif (d < 10)\n\t{\n\t\treturn true;\n\t} //end if\n\treturn false;\n} //end of the function TH_Colinear\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid TH_FaceCenter(aas_face_t *face, vec3_t center)\n{\n\tint i, edgenum, side;\n\taas_edge_t *edge;\n\n\tVectorClear(center);\n\tfor (i = 0; i < face->numedges; i++)\n\t{\n\t\tedgenum = abs(aasworld.edgeindex[face->firstedge + i]);\n\t\tside = edgenum < 0;\n\t\tedge = &aasworld.edges[abs(edgenum)];\n\t\tVectorAdd(aasworld.vertexes[edge->v[side]], center, center);\n\t} //end for\n\tVectorScale(center, 1.0 / face->numedges, center);\n} //end of the function TH_FaceCenter\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nth_triangle_t *TH_CreateAASFaceTriangles(aas_face_t *face)\n{\n\tint i, first, verts[3], trinum;\n\tvec3_t p0, p1, p2, p3, p4, center;\n\tth_triangle_t *tri, *triangles;\n\n\ttriangles = NULL;\n\t//find three points that are not colinear\n\tfor (i = 0; i < face->numedges; i++)\n\t{\n\t\tTH_AASFaceVertex(face, (face->numedges + i-2)%face->numedges, p0);\n\t\tTH_AASFaceVertex(face, (face->numedges + i-1)%face->numedges, p1);\n\t\tTH_AASFaceVertex(face, (i  )%face->numedges, p2);\n\t\tif (TH_Colinear(p2, p0, p1)) continue;\n\t\tTH_AASFaceVertex(face, (i+1)%face->numedges, p3);\n\t\tTH_AASFaceVertex(face, (i+2)%face->numedges, p4);\n\t\tif (TH_Colinear(p2, p3, p4)) continue;\n\t\tbreak;\n\t} //end for\n\t//if there are three points that are not colinear\n\tif (i < face->numedges)\n\t{\n\t\t//normal triangulation\n\t\tfirst = i; //left and right most point of three non-colinear points\n\t\tTH_AASFaceVertex(face, first, p0);\n\t\tverts[0] = TH_FindOrCreateVertex(p0);\n\t\tfor (i = 1; i < face->numedges-1; i++)\n\t\t{\n\t\t\tTH_AASFaceVertex(face, (first+i  )%face->numedges, p1);\n\t\t\tTH_AASFaceVertex(face, (first+i+1)%face->numedges, p2);\n\t\t\tverts[1] = TH_FindOrCreateVertex(p1);\n\t\t\tverts[2] = TH_FindOrCreateVertex(p2);\n\t\t\ttrinum = TH_CreateTriangle(verts);\n\t\t\ttri = &thworld.triangles[trinum];\n\t\t\ttri->front = -1;\n\t\t\tTH_AddTriangleToList(&triangles, tri);\n\t\t} //end for\n\t} //end if\n\telse\n\t{\n\t\t//fan triangulation\n\t\tTH_FaceCenter(face, center);\n\t\t//\n\t\tverts[0] = TH_FindOrCreateVertex(center);\n\t\tfor (i = 0; i < face->numedges; i++)\n\t\t{\n\t\t\tTH_AASFaceVertex(face, (i  )%face->numedges, p1);\n\t\t\tTH_AASFaceVertex(face, (i+1)%face->numedges, p2);\n\t\t\tif (TH_Colinear(center, p1, p2)) continue;\n\t\t\tverts[1] = TH_FindOrCreateVertex(p1);\n\t\t\tverts[2] = TH_FindOrCreateVertex(p2);\n\t\t\ttrinum = TH_CreateTriangle(verts);\n\t\t\ttri = &thworld.triangles[trinum];\n\t\t\ttri->front = -1;\n\t\t\tTH_AddTriangleToList(&triangles, tri);\n\t\t} //end for\n\t} //end else\n\treturn triangles;\n} //end of the function TH_CreateAASFaceTriangles\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nth_triangle_t *TH_AASToTriangleMesh(void)\n{\n\tint i, j, facenum, otherareanum;\n\taas_face_t *face;\n\tth_triangle_t *tri, *nexttri, *triangles;\n\n\ttriangles = NULL;\n\tfor (i = 1; i < aasworld.numareas; i++)\n\t{\n\t\t//if (!(aasworld.areasettings[i].presencetype & PRESENCE_NORMAL)) continue;\n\t\tfor (j = 0; j < aasworld.areas[i].numfaces; j++)\n\t\t{\n\t\t\tfacenum = abs(aasworld.faceindex[aasworld.areas[i].firstface + j]);\n\t\t\tface = &aasworld.faces[facenum];\n\t\t\t//only convert solid faces into triangles\n\t\t\tif (!(face->faceflags & FACE_SOLID))\n\t\t\t{\n\t\t\t\t/*\n\t\t\t\tif (face->frontarea == i) otherareanum = face->backarea;\n\t\t\t\telse otherareanum = face->frontarea;\n\t\t\t\tif (aasworld.areasettings[otherareanum].presencetype & PRESENCE_NORMAL) continue;\n\t\t\t\t*/\n\t\t\t\tcontinue;\n\t\t\t} //end if\n\t\t\t//\n\t\t\ttri = TH_CreateAASFaceTriangles(face);\n\t\t\tfor (; tri; tri = nexttri)\n\t\t\t{\n\t\t\t\tnexttri = tri->next;\n\t\t\t\tTH_AddTriangleToList(&triangles, tri);\n\t\t\t} //end for\n\t\t} //end if\n\t} //end for\n\treturn triangles;\n} //end of the function TH_AASToTriangleMesh\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid TH_AASToTetrahedrons(char *filename)\n{\n\tth_triangle_t *triangles, *tri, *lasttri;\n\tint cnt;\n\n\tif (!AAS_LoadAASFile(filename, 0, 0))\n\t\tError(\"couldn't load %s\\n\", filename);\n\n\t//\n\tTH_InitMaxTH();\n\t//create a triangle mesh from the solid faces in the AAS file\n\ttriangles = TH_AASToTriangleMesh();\n\t//\n\tcnt = 0;\n\tlasttri = NULL;\n\tfor (tri = triangles; tri; tri = tri->next)\n\t{\n\t\tcnt++;\n\t\tif (tri->prev != lasttri) Log_Print(\"BAH\\n\");\n\t\tlasttri = tri;\n\t} //end for\n\tLog_Print(\"%6d triangles\\n\", cnt);\n\t//create a tetrahedral decomposition of the world bounded by triangles\n\tTH_TetrahedralDecomposition(triangles);\n\t//\n\tTH_FreeMaxTH();\n} //end of the function TH_AASToTetrahedrons\n"
  },
  {
    "path": "code/bspc/tetrahedron.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\nvoid TH_AASToTetrahedrons(char *filename);\n\n"
  },
  {
    "path": "code/bspc/textures.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n#include \"l_bsp_q2.h\"\n\nint nummiptex;\ntextureref_t textureref[MAX_MAP_TEXTURES];\n\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint FindMiptex (char *name)\n{\n\tint i;\n\tchar path[1024];\n\tmiptex_t\t*mt;\n\n\tfor (i = 0; i < nummiptex; i++)\n\t{\n\t\tif (!strcmp (name, textureref[i].name))\n\t\t{\n\t\t\treturn i;\n\t\t} //end if\n\t} //end for\n\tif (nummiptex == MAX_MAP_TEXTURES)\n\t\tError (\"MAX_MAP_TEXTURES\");\n\tstrcpy (textureref[i].name, name);\n\n\t// load the miptex to get the flags and values\n\tsprintf (path, \"%stextures/%s.wal\", gamedir, name);\n\tif (TryLoadFile (path, (void **)&mt) != -1)\n\t{\n\t\ttextureref[i].value = LittleLong (mt->value);\n\t\ttextureref[i].flags = LittleLong (mt->flags);\n\t\ttextureref[i].contents = LittleLong (mt->contents);\n\t\tstrcpy (textureref[i].animname, mt->animname);\n\t\tFreeMemory(mt);\n\t} //end if\n\tnummiptex++;\n\n\tif (textureref[i].animname[0])\n\t\tFindMiptex (textureref[i].animname);\n\n\treturn i;\n} //end of the function FindMipTex\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvec3_t\tbaseaxis[18] =\n{\n{0,0,1}, {1,0,0}, {0,-1,0},\t\t// floor\n{0,0,-1}, {1,0,0}, {0,-1,0},\t\t// ceiling\n{1,0,0}, {0,1,0}, {0,0,-1},\t\t// west wall\n{-1,0,0}, {0,1,0}, {0,0,-1},\t\t// east wall\n{0,1,0}, {1,0,0}, {0,0,-1},\t\t// south wall\n{0,-1,0}, {1,0,0}, {0,0,-1}\t\t// north wall\n};\n\nvoid TextureAxisFromPlane(plane_t *pln, vec3_t xv, vec3_t yv)\n{\n\tint\t\tbestaxis;\n\tvec_t\tdot,best;\n\tint\t\ti;\n\t\n\tbest = 0;\n\tbestaxis = 0;\n\t\n\tfor (i=0 ; i<6 ; i++)\n\t{\n\t\tdot = DotProduct (pln->normal, baseaxis[i*3]);\n\t\tif (dot > best)\n\t\t{\n\t\t\tbest = dot;\n\t\t\tbestaxis = i;\n\t\t}\n\t}\n\t\n\tVectorCopy (baseaxis[bestaxis*3+1], xv);\n\tVectorCopy (baseaxis[bestaxis*3+2], yv);\n} //end of the function TextureAxisFromPlane\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nint TexinfoForBrushTexture(plane_t *plane, brush_texture_t *bt, vec3_t origin)\n{\n\tvec3_t\tvecs[2];\n\tint\t\tsv, tv;\n\tvec_t\tang, sinv, cosv;\n\tvec_t\tns, nt;\n\ttexinfo_t\ttx, *tc;\n\tint\t\ti, j, k;\n\tfloat\tshift[2];\n\tbrush_texture_t\t\tanim;\n\tint\t\t\t\tmt;\n\n\tif (!bt->name[0])\n\t\treturn 0;\n\n\tmemset (&tx, 0, sizeof(tx));\n\tstrcpy (tx.texture, bt->name);\n\n\tTextureAxisFromPlane(plane, vecs[0], vecs[1]);\n\n\tshift[0] = DotProduct (origin, vecs[0]);\n\tshift[1] = DotProduct (origin, vecs[1]);\n\n\tif (!bt->scale[0])\n\t\tbt->scale[0] = 1;\n\tif (!bt->scale[1])\n\t\tbt->scale[1] = 1;\n\n\n// rotate axis\n\tif (bt->rotate == 0)\n\t\t{ sinv = 0 ; cosv = 1; }\n\telse if (bt->rotate == 90)\n\t\t{ sinv = 1 ; cosv = 0; }\n\telse if (bt->rotate == 180)\n\t\t{ sinv = 0 ; cosv = -1; }\n\telse if (bt->rotate == 270)\n\t\t{ sinv = -1 ; cosv = 0; }\n\telse\n\t{\t\n\t\tang = bt->rotate / 180 * Q_PI;\n\t\tsinv = sin(ang);\n\t\tcosv = cos(ang);\n\t}\n\n\tif (vecs[0][0])\n\t\tsv = 0;\n\telse if (vecs[0][1])\n\t\tsv = 1;\n\telse\n\t\tsv = 2;\n\t\t\t\t\n\tif (vecs[1][0])\n\t\ttv = 0;\n\telse if (vecs[1][1])\n\t\ttv = 1;\n\telse\n\t\ttv = 2;\n\t\t\t\t\t\n\tfor (i=0 ; i<2 ; i++)\n\t{\n\t\tns = cosv * vecs[i][sv] - sinv * vecs[i][tv];\n\t\tnt = sinv * vecs[i][sv] +  cosv * vecs[i][tv];\n\t\tvecs[i][sv] = ns;\n\t\tvecs[i][tv] = nt;\n\t}\n\n\tfor (i=0 ; i<2 ; i++)\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t\ttx.vecs[i][j] = vecs[i][j] / bt->scale[i];\n\n\ttx.vecs[0][3] = bt->shift[0] + shift[0];\n\ttx.vecs[1][3] = bt->shift[1] + shift[1];\n\ttx.flags = bt->flags;\n\ttx.value = bt->value;\n\n\t//\n\t// find the texinfo\n\t//\n\ttc = texinfo;\n\tfor (i=0 ; i<numtexinfo ; i++, tc++)\n\t{\n\t\tif (tc->flags != tx.flags)\n\t\t\tcontinue;\n\t\tif (tc->value != tx.value)\n\t\t\tcontinue;\n\t\tfor (j=0 ; j<2 ; j++)\n\t\t{\n\t\t\tif (strcmp (tc->texture, tx.texture))\n\t\t\t\tgoto skip;\n\t\t\tfor (k=0 ; k<4 ; k++)\n\t\t\t{\n\t\t\t\tif (tc->vecs[j][k] != tx.vecs[j][k])\n\t\t\t\t\tgoto skip;\n\t\t\t}\n\t\t}\n\t\treturn i;\nskip:;\n\t}\n\t*tc = tx;\n\tnumtexinfo++;\n\n\t// load the next animation\n\tmt = FindMiptex (bt->name);\n\tif (textureref[mt].animname[0])\n\t{\n\t\tanim = *bt;\n\t\tstrcpy (anim.name, textureref[mt].animname);\n\t\ttc->nexttexinfo = TexinfoForBrushTexture (plane, &anim, origin);\n\t}\n\telse\n\t\ttc->nexttexinfo = -1;\n\n\n\treturn i;\n} //end of the function TexinfoForBrushTexture\n"
  },
  {
    "path": "code/bspc/tree.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n\nextern int c_nodes;\nint\tc_pruned;\nint freedtreemem = 0;\n\nvoid RemovePortalFromNode (portal_t *portal, node_t *l);\n\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nnode_t *NodeForPoint (node_t *node, vec3_t origin)\n{\n\tplane_t\t*plane;\n\tvec_t\td;\n\n\twhile (node->planenum != PLANENUM_LEAF)\n\t{\n\t\tplane = &mapplanes[node->planenum];\n\t\td = DotProduct (origin, plane->normal) - plane->dist;\n\t\tif (d >= 0)\n\t\t\tnode = node->children[0];\n\t\telse\n\t\t\tnode = node->children[1];\n\t}\n\treturn node;\n} //end of the function NodeForPoint\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Tree_FreePortals_r (node_t *node)\n{\n\tportal_t\t*p, *nextp;\n\tint\t\t\ts;\n\n\t// free children\n\tif (node->planenum != PLANENUM_LEAF)\n\t{\n\t\tTree_FreePortals_r(node->children[0]);\n\t\tTree_FreePortals_r(node->children[1]);\n\t}\n\n\t// free portals\n\tfor (p = node->portals; p; p = nextp)\n\t{\n\t\ts = (p->nodes[1] == node);\n\t\tnextp = p->next[s];\n\n\t\tRemovePortalFromNode (p, p->nodes[!s]);\n#ifdef ME\n\t\tif (p->winding) freedtreemem += MemorySize(p->winding);\n\t\tfreedtreemem += MemorySize(p);\n#endif //ME\n\t\tFreePortal(p);\n\t}\n\tnode->portals = NULL;\n} //end of the function Tree_FreePortals_r\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Tree_Free_r (node_t *node)\n{\n//\tface_t *f, *nextf;\n\tbspbrush_t *brush, *nextbrush;\n\n\t//free children\n\tif (node->planenum != PLANENUM_LEAF)\n\t{\n\t\tTree_Free_r (node->children[0]);\n\t\tTree_Free_r (node->children[1]);\n\t} //end if\n\t//free bspbrushes\n//\tFreeBrushList (node->brushlist);\n\tfor (brush = node->brushlist; brush; brush = nextbrush)\n\t{\n\t\tnextbrush = brush->next;\n#ifdef ME\n\t\tfreedtreemem += MemorySize(brush);\n#endif //ME\n\t\tFreeBrush(brush);\n\t} //end for\n\tnode->brushlist = NULL;\n\n\t/*\n\tNOTE: only used when creating Q2 bsp\n\t// free faces\n\tfor (f = node->faces; f; f = nextf)\n\t{\n\t\tnextf = f->next;\n#ifdef ME\n\t\tif (f->w) freedtreemem += MemorySize(f->w);\n\t\tfreedtreemem += sizeof(face_t);\n#endif //ME\n\t\tFreeFace(f);\n\t} //end for\n\t*/\n\n\t// free the node\n\tif (node->volume)\n\t{\n#ifdef ME\n\t\tfreedtreemem += MemorySize(node->volume);\n#endif //ME\n\t\tFreeBrush (node->volume);\n\t} //end if\n\n\tif (numthreads == 1) c_nodes--;\n#ifdef ME\n\tfreedtreemem += MemorySize(node);\n#endif //ME\n\tFreeMemory(node);\n} //end of the function Tree_Free_r\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Tree_Free(tree_t *tree)\n{\n\t//if no tree just return\n\tif (!tree) return;\n\t//\n\tfreedtreemem = 0;\n\t//\n\tTree_FreePortals_r(tree->headnode);\n\tTree_Free_r(tree->headnode);\n#ifdef ME\n\tfreedtreemem += MemorySize(tree);\n#endif //ME\n\tFreeMemory(tree);\n#ifdef ME\n\tLog_Print(\"freed \");\n\tPrintMemorySize(freedtreemem);\n\tLog_Print(\" of tree memory\\n\");\n#endif //ME\n} //end of the function Tree_Free\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\ntree_t *Tree_Alloc(void)\n{\n\ttree_t\t*tree;\n\n\ttree = GetMemory(sizeof(*tree));\n\tmemset (tree, 0, sizeof(*tree));\n\tClearBounds (tree->mins, tree->maxs);\n\n\treturn tree;\n} //end of the function Tree_Alloc\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Tree_Print_r (node_t *node, int depth)\n{\n\tint\t\ti;\n\tplane_t\t*plane;\n\tbspbrush_t\t*bb;\n\n\tfor (i=0 ; i<depth ; i++)\n\t\tprintf (\"  \");\n\tif (node->planenum == PLANENUM_LEAF)\n\t{\n\t\tif (!node->brushlist)\n\t\t\tprintf (\"NULL\\n\");\n\t\telse\n\t\t{\n\t\t\tfor (bb=node->brushlist ; bb ; bb=bb->next)\n\t\t\t\tprintf (\"%i \", bb->original->brushnum);\n\t\t\tprintf (\"\\n\");\n\t\t}\n\t\treturn;\n\t}\n\n\tplane = &mapplanes[node->planenum];\n\tprintf (\"#%i (%5.2f %5.2f %5.2f):%5.2f\\n\", node->planenum,\n\t\tplane->normal[0], plane->normal[1], plane->normal[2],\n\t\tplane->dist);\n\tTree_Print_r (node->children[0], depth+1);\n\tTree_Print_r (node->children[1], depth+1);\n} //end of the function Tree_Print_r\n//===========================================================================\n// NODES THAT DON'T SEPERATE DIFFERENT CONTENTS CAN BE PRUNED\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Tree_PruneNodes_r (node_t *node)\n{\n\tbspbrush_t *b, *next;\n\n\tif (node->planenum == PLANENUM_LEAF) return;\n\n\tTree_PruneNodes_r (node->children[0]);\n\tTree_PruneNodes_r (node->children[1]);\n\n\tif (create_aas)\n\t{\n\t\tif ((node->children[0]->contents & CONTENTS_LADDER) ||\n\t\t\t\t(node->children[1]->contents & CONTENTS_LADDER)) return;\n\t}\n\n\tif ((node->children[0]->contents & CONTENTS_SOLID)\n\t\t&& (node->children[1]->contents & CONTENTS_SOLID))\n\t{\n\t\tif (node->faces)\n\t\t\tError (\"node->faces seperating CONTENTS_SOLID\");\n\t\tif (node->children[0]->faces || node->children[1]->faces)\n\t\t\tError (\"!node->faces with children\");\n\t\t// FIXME: free stuff\n\t\tnode->planenum = PLANENUM_LEAF;\n\t\tnode->contents = CONTENTS_SOLID;\n\t\tnode->detail_seperator = false;\n\n\t\tif (node->brushlist)\n\t\t\tError (\"PruneNodes: node->brushlist\");\n\t\t// combine brush lists\n\t\tnode->brushlist = node->children[1]->brushlist;\n\n\t\tfor (b = node->children[0]->brushlist; b; b = next)\n\t\t{\n\t\t\tnext = b->next;\n\t\t\tb->next = node->brushlist;\n\t\t\tnode->brushlist = b;\n\t\t} //end for\n\t\t//free the child nodes\n\t\tFreeMemory(node->children[0]);\n\t\tFreeMemory(node->children[1]);\n\t\t//two nodes are cut away\n\t\tc_pruned += 2;\n\t} //end if\n} //end of the function Tree_PruneNodes_r\n//===========================================================================\n//\n// Parameter:\t\t\t-\n// Returns:\t\t\t\t-\n// Changes Globals:\t\t-\n//===========================================================================\nvoid Tree_PruneNodes(node_t *node)\n{\n\tLog_Print(\"------- Prune Nodes --------\\n\");\n\tc_pruned = 0;\n\tTree_PruneNodes_r(node);\n\tLog_Print(\"%5i pruned nodes\\n\", c_pruned);\n} //end of the function Tree_PruneNodes\n"
  },
  {
    "path": "code/bspc/writebsp.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"qbsp.h\"\n\nint\t\tc_nofaces;\nint\t\tc_facenodes;\n\n\n/*\n=========================================================\n\nONLY SAVE OUT PLANES THAT ARE ACTUALLY USED AS NODES\n\n=========================================================\n*/\n\nint\t\tplaneused[MAX_MAP_PLANES];\n\n/*\n============\nEmitPlanes\n\nThere is no oportunity to discard planes, because all of the original\nbrushes will be saved in the map.\n============\n*/\nvoid EmitPlanes (void)\n{\n\tint\t\t\ti;\n\tdplane_t\t*dp;\n\tplane_t\t\t*mp;\n\t//ME: this causes a crash??\n//\tint\t\tplanetranslate[MAX_MAP_PLANES];\n\n\tmp = mapplanes;\n\tfor (i=0 ; i<nummapplanes ; i++, mp++)\n\t{\n\t\tdp = &dplanes[numplanes];\n//\t\tplanetranslate[i] = numplanes;\n\t\tVectorCopy ( mp->normal, dp->normal);\n\t\tdp->dist = mp->dist;\n\t\tdp->type = mp->type;\n\t\tnumplanes++;\n\t\tif (numplanes >= MAX_MAP_PLANES)\n\t\t\tError(\"MAX_MAP_PLANES\");\n\t}\n}\n\n\n//========================================================\n\nvoid EmitMarkFace (dleaf_t *leaf_p, face_t *f)\n{\n\tint\t\t\ti;\n\tint\t\t\tfacenum;\n\n\twhile (f->merged)\n\t\tf = f->merged;\n\n\tif (f->split[0])\n\t{\n\t\tEmitMarkFace (leaf_p, f->split[0]);\n\t\tEmitMarkFace (leaf_p, f->split[1]);\n\t\treturn;\n\t}\n\n\tfacenum = f->outputnumber;\n\tif (facenum == -1)\n\t\treturn;\t// degenerate face\n\n\tif (facenum < 0 || facenum >= numfaces)\n\t\tError (\"Bad leafface\");\n\tfor (i=leaf_p->firstleafface ; i<numleaffaces ; i++)\n\t\tif (dleaffaces[i] == facenum)\n\t\t\tbreak;\t\t// merged out face\n\tif (i == numleaffaces)\n\t{\n\t\tif (numleaffaces >= MAX_MAP_LEAFFACES)\n\t\t\tError (\"MAX_MAP_LEAFFACES\");\n\n\t\tdleaffaces[numleaffaces] =  facenum;\n\t\tnumleaffaces++;\n\t}\n\n}\n\n\n/*\n==================\nEmitLeaf\n==================\n*/\nvoid EmitLeaf (node_t *node)\n{\n\tdleaf_t\t\t*leaf_p;\n\tportal_t\t*p;\n\tint\t\t\ts;\n\tface_t\t\t*f;\n\tbspbrush_t\t*b;\n\tint\t\t\ti;\n\tint\t\t\tbrushnum;\n\n\t// emit a leaf\n\tif (numleafs >= MAX_MAP_LEAFS)\n\t\tError (\"MAX_MAP_LEAFS\");\n\n\tleaf_p = &dleafs[numleafs];\n\tnumleafs++;\n\n\tleaf_p->contents = node->contents;\n\tleaf_p->cluster = node->cluster;\n\tleaf_p->area = node->area;\n\n\t//\n\t// write bounding box info\n\t//\t\n\tVectorCopy (node->mins, leaf_p->mins);\n\tVectorCopy (node->maxs, leaf_p->maxs);\n\t\n\t//\n\t// write the leafbrushes\n\t//\n\tleaf_p->firstleafbrush = numleafbrushes;\n\tfor (b=node->brushlist ; b ; b=b->next)\n\t{\n\t\tif (numleafbrushes >= MAX_MAP_LEAFBRUSHES)\n\t\t\tError (\"MAX_MAP_LEAFBRUSHES\");\n\n\t\tbrushnum = b->original - mapbrushes;\n\t\tfor (i=leaf_p->firstleafbrush ; i<numleafbrushes ; i++)\n\t\t\tif (dleafbrushes[i] == brushnum)\n\t\t\t\tbreak;\n\t\tif (i == numleafbrushes)\n\t\t{\n\t\t\tdleafbrushes[numleafbrushes] = brushnum;\n\t\t\tnumleafbrushes++;\n\t\t}\n\t}\n\tleaf_p->numleafbrushes = numleafbrushes - leaf_p->firstleafbrush;\n\n\t//\n\t// write the leaffaces\n\t//\n\tif (leaf_p->contents & CONTENTS_SOLID)\n\t\treturn;\t\t// no leaffaces in solids\n\n\tleaf_p->firstleafface = numleaffaces;\n\n\tfor (p = node->portals ; p ; p = p->next[s])\t\n\t{\n\t\ts = (p->nodes[1] == node);\n\t\tf = p->face[s];\n\t\tif (!f)\n\t\t\tcontinue;\t// not a visible portal\n\n\t\tEmitMarkFace (leaf_p, f);\n\t}\n\t\n\tleaf_p->numleaffaces = numleaffaces - leaf_p->firstleafface;\n}\n\n\n/*\n==================\nEmitFace\n==================\n*/\nvoid EmitFace (face_t *f)\n{\n\tdface_t\t*df;\n\tint\t\ti;\n\tint\t\te;\n\n\tf->outputnumber = -1;\n\n\tif (f->numpoints < 3)\n\t{\n\t\treturn;\t\t// degenerated\n\t}\n\tif (f->merged || f->split[0] || f->split[1])\n\t{\n\t\treturn;\t\t// not a final face\n\t}\n\n\t// save output number so leaffaces can use\n\tf->outputnumber = numfaces;\n\n\tif (numfaces >= MAX_MAP_FACES)\n\t\tError (\"numfaces == MAX_MAP_FACES\");\n\tdf = &dfaces[numfaces];\n\tnumfaces++;\n\n\t// planenum is used by qlight, but not quake\n\tdf->planenum = f->planenum & (~1);\n\tdf->side = f->planenum & 1;\n\n\tdf->firstedge = numsurfedges;\n\tdf->numedges = f->numpoints;\n\tdf->texinfo = f->texinfo;\n\tfor (i=0 ; i<f->numpoints ; i++)\n\t{\n//\t\te = GetEdge (f->pts[i], f->pts[(i+1)%f->numpoints], f);\n\t\te = GetEdge2 (f->vertexnums[i], f->vertexnums[(i+1)%f->numpoints], f);\n\t\tif (numsurfedges >= MAX_MAP_SURFEDGES)\n\t\t\tError (\"numsurfedges == MAX_MAP_SURFEDGES\");\n\t\tdsurfedges[numsurfedges] = e;\n\t\tnumsurfedges++;\n\t}\n}\n\n/*\n============\nEmitDrawingNode_r\n============\n*/\nint EmitDrawNode_r (node_t *node)\n{\n\tdnode_t\t*n;\n\tface_t\t*f;\n\tint\t\ti;\n\n\tif (node->planenum == PLANENUM_LEAF)\n\t{\n\t\tEmitLeaf (node);\n\t\treturn -numleafs;\n\t}\n\n\t// emit a node\t\n\tif (numnodes == MAX_MAP_NODES)\n\t\tError (\"MAX_MAP_NODES\");\n\tn = &dnodes[numnodes];\n\tnumnodes++;\n\n\tVectorCopy (node->mins, n->mins);\n\tVectorCopy (node->maxs, n->maxs);\n\n\tplaneused[node->planenum]++;\n\tplaneused[node->planenum^1]++;\n\n\tif (node->planenum & 1)\n\t\tError (\"WriteDrawNodes_r: odd planenum\");\n\tn->planenum = node->planenum;\n\tn->firstface = numfaces;\n\n\tif (!node->faces)\n\t\tc_nofaces++;\n\telse\n\t\tc_facenodes++;\n\n\tfor (f=node->faces ; f ; f=f->next)\n\t\tEmitFace (f);\n\n\tn->numfaces = numfaces - n->firstface;\n\n\n\t//\n\t// recursively output the other nodes\n\t//\t\n\tfor (i=0 ; i<2 ; i++)\n\t{\n\t\tif (node->children[i]->planenum == PLANENUM_LEAF)\n\t\t{\n\t\t\tn->children[i] = -(numleafs + 1);\n\t\t\tEmitLeaf (node->children[i]);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tn->children[i] = numnodes;\t\n\t\t\tEmitDrawNode_r (node->children[i]);\n\t\t}\n\t}\n\n\treturn n - dnodes;\n}\n\n//=========================================================\n\n\n/*\n============\nWriteBSP\n============\n*/\nvoid WriteBSP (node_t *headnode)\n{\n\tint\t\toldfaces;\n\n\tc_nofaces = 0;\n\tc_facenodes = 0;\n\n\tqprintf (\"--- WriteBSP ---\\n\");\n\n\toldfaces = numfaces;\n\tdmodels[nummodels].headnode = EmitDrawNode_r (headnode);\n\tEmitAreaPortals (headnode);\n\n\tqprintf (\"%5i nodes with faces\\n\", c_facenodes);\n\tqprintf (\"%5i nodes without faces\\n\", c_nofaces);\n\tqprintf (\"%5i faces\\n\", numfaces-oldfaces);\n}\n\n//===========================================================\n\n/*\n============\nSetModelNumbers\n============\n*/\nvoid SetModelNumbers (void)\n{\n\tint\t\ti;\n\tint\t\tmodels;\n\tchar\tvalue[10];\n\n\tmodels = 1;\n\tfor (i=1 ; i<num_entities ; i++)\n\t{\n\t\tif (entities[i].numbrushes)\n\t\t{\n\t\t\tsprintf (value, \"*%i\", models);\n\t\t\tmodels++;\n\t\t\tSetKeyValue (&entities[i], \"model\", value);\n\t\t}\n\t}\n\n}\n\n/*\n============\nSetLightStyles\n============\n*/\n#define\tMAX_SWITCHED_LIGHTS\t32\nvoid SetLightStyles (void)\n{\n\tint\t\tstylenum;\n\tchar\t*t;\n\tentity_t\t*e;\n\tint\t\ti, j;\n\tchar\tvalue[10];\n\tchar\tlighttargets[MAX_SWITCHED_LIGHTS][64];\n\n\n\t// any light that is controlled (has a targetname)\n\t// must have a unique style number generated for it\n\n\tstylenum = 0;\n\tfor (i=1 ; i<num_entities ; i++)\n\t{\n\t\te = &entities[i];\n\n\t\tt = ValueForKey (e, \"classname\");\n\t\tif (Q_strncasecmp (t, \"light\", 5))\n\t\t\tcontinue;\n\t\tt = ValueForKey (e, \"targetname\");\n\t\tif (!t[0])\n\t\t\tcontinue;\n\t\t\n\t\t// find this targetname\n\t\tfor (j=0 ; j<stylenum ; j++)\n\t\t\tif (!strcmp (lighttargets[j], t))\n\t\t\t\tbreak;\n\t\tif (j == stylenum)\n\t\t{\n\t\t\tif (stylenum == MAX_SWITCHED_LIGHTS)\n\t\t\t\tError (\"stylenum == MAX_SWITCHED_LIGHTS\");\n\t\t\tstrcpy (lighttargets[j], t);\n\t\t\tstylenum++;\n\t\t}\n\t\tsprintf (value, \"%i\", 32 + j);\n\t\tSetKeyValue (e, \"style\", value);\n\t}\n\n}\n\n//===========================================================\n\n/*\n============\nEmitBrushes\n============\n*/\nvoid EmitBrushes (void)\n{\n\tint\t\t\ti, j, bnum, s, x;\n\tdbrush_t\t*db;\n\tmapbrush_t\t\t*b;\n\tdbrushside_t\t*cp;\n\tvec3_t\t\tnormal;\n\tvec_t\t\tdist;\n\tint\t\t\tplanenum;\n\n\tnumbrushsides = 0;\n\tnumbrushes = nummapbrushes;\n\n\tfor (bnum=0 ; bnum<nummapbrushes ; bnum++)\n\t{\n\t\tb = &mapbrushes[bnum];\n\t\tdb = &dbrushes[bnum];\n\n\t\tdb->contents = b->contents;\n\t\tdb->firstside = numbrushsides;\n\t\tdb->numsides = b->numsides;\n\t\tfor (j=0 ; j<b->numsides ; j++)\n\t\t{\n\t\t\tif (numbrushsides == MAX_MAP_BRUSHSIDES)\n\t\t\t\tError (\"MAX_MAP_BRUSHSIDES\");\n\t\t\tcp = &dbrushsides[numbrushsides];\n\t\t\tnumbrushsides++;\n\t\t\tcp->planenum = b->original_sides[j].planenum;\n\t\t\tcp->texinfo = b->original_sides[j].texinfo;\n\t\t}\n\n#ifdef ME\n\t//for collision detection, bounding boxes are axial :)\n\t//brushes are convex so just add dot or line touching planes on the sides of\n\t//the brush parallell to the axis planes\n#endif\n\t\t// add any axis planes not contained in the brush to bevel off corners\n\t\tfor (x=0 ; x<3 ; x++)\n\t\t\tfor (s=-1 ; s<=1 ; s+=2)\n\t\t\t{\n\t\t\t// add the plane\n\t\t\t\tVectorCopy (vec3_origin, normal);\n\t\t\t\tnormal[x] = s;\n\t\t\t\tif (s == -1)\n\t\t\t\t\tdist = -b->mins[x];\n\t\t\t\telse\n\t\t\t\t\tdist = b->maxs[x];\n\t\t\t\tplanenum = FindFloatPlane (normal, dist);\n\t\t\t\tfor (i=0 ; i<b->numsides ; i++)\n\t\t\t\t\tif (b->original_sides[i].planenum == planenum)\n\t\t\t\t\t\tbreak;\n\t\t\t\tif (i == b->numsides)\n\t\t\t\t{\n\t\t\t\t\tif (numbrushsides >= MAX_MAP_BRUSHSIDES)\n\t\t\t\t\t\tError (\"MAX_MAP_BRUSHSIDES\");\n\n\t\t\t\t\tdbrushsides[numbrushsides].planenum = planenum;\n\t\t\t\t\tdbrushsides[numbrushsides].texinfo =\n\t\t\t\t\t\tdbrushsides[numbrushsides-1].texinfo;\n\t\t\t\t\tnumbrushsides++;\n\t\t\t\t\tdb->numsides++;\n\t\t\t\t}\n\t\t\t}\n\n\t}\n\n}\n\n//===========================================================\n\n/*\n==================\nBeginBSPFile\n==================\n*/\nvoid BeginBSPFile (void)\n{\n\t// these values may actually be initialized\n\t// if the file existed when loaded, so clear them explicitly\n\tnummodels = 0;\n\tnumfaces = 0;\n\tnumnodes = 0;\n\tnumbrushsides = 0;\n\tnumvertexes = 0;\n\tnumleaffaces = 0;\n\tnumleafbrushes = 0;\n\tnumsurfedges = 0;\n\n\t// edge 0 is not used, because 0 can't be negated\n\tnumedges = 1;\n\n\t// leave vertex 0 as an error\n\tnumvertexes = 1;\n\n\t// leave leaf 0 as an error\n\tnumleafs = 1;\n\tdleafs[0].contents = CONTENTS_SOLID;\n}\n\n\n/*\n============\nEndBSPFile\n============\n*/\nvoid EndBSPFile (void)\n{\n#if 0\n\tchar\tpath[1024];\n\tint\t\tlen;\n\tbyte\t*buf;\n#endif\n\n\n\tEmitBrushes ();\n\tEmitPlanes ();\n\tQ2_UnparseEntities ();\n\n\t// load the pop\n#if 0\n\tsprintf (path, \"%s/pics/pop.lmp\", gamedir);\n\tlen = LoadFile (path, &buf);\n\tmemcpy (dpop, buf, sizeof(dpop));\n\tFreeMemory(buf);\n#endif\n}\n\n\n/*\n==================\nBeginModel\n==================\n*/\nint\tfirstmodleaf;\nextern\tint firstmodeledge;\nextern\tint\tfirstmodelface;\nvoid BeginModel (void)\n{\n\tdmodel_t\t*mod;\n\tint\t\t\tstart, end;\n\tmapbrush_t\t*b;\n\tint\t\t\tj;\n\tentity_t\t*e;\n\tvec3_t\t\tmins, maxs;\n\n\tif (nummodels == MAX_MAP_MODELS)\n\t\tError (\"MAX_MAP_MODELS\");\n\tmod = &dmodels[nummodels];\n\n\tmod->firstface = numfaces;\n\n\tfirstmodleaf = numleafs;\n\tfirstmodeledge = numedges;\n\tfirstmodelface = numfaces;\n\n\t//\n\t// bound the brushes\n\t//\n\te = &entities[entity_num];\n\n\tstart = e->firstbrush;\n\tend = start + e->numbrushes;\n\tClearBounds (mins, maxs);\n\n\tfor (j=start ; j<end ; j++)\n\t{\n\t\tb = &mapbrushes[j];\n\t\tif (!b->numsides)\n\t\t\tcontinue;\t// not a real brush (origin brush)\n\t\tAddPointToBounds (b->mins, mins, maxs);\n\t\tAddPointToBounds (b->maxs, mins, maxs);\n\t}\n\n\tVectorCopy (mins, mod->mins);\n\tVectorCopy (maxs, mod->maxs);\n}\n\n\n/*\n==================\nEndModel\n==================\n*/\nvoid EndModel (void)\n{\n\tdmodel_t\t*mod;\n\n\tmod = &dmodels[nummodels];\n\n\tmod->numfaces = numfaces - mod->firstface;\n\n\tnummodels++;\n}\n\n"
  },
  {
    "path": "code/cgame/Conscript",
    "content": "# cgame building\n# builds the cgame for vanilla Q3 and TA\n\n# there are slight differences between Q3 and TA build:\n#   -DMISSIONPACK\n#   TA has cg_newdraw.c and ../ui/ui_shared.c\n# the config is passed in the imported variable TARGET_DIR\n\n# qvm building against native:\n# only native has cg_syscalls.c\n# only qvm has ../game/bg_lib.c\n# qvm uses a custom cg_syscalls.asm with equ stubs\n\nImport qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );\n\n$env = new cons(\n  # the code has the very bad habit of doing things like #include \"../ui/ui_shared.h\"\n  # this seems to confuse the dependency analysis, explicit toplevel includes seem to fix\n  CPPPATH => '#cgame:#game:#q3_ui',\n  CC => $CC,\n  CXX => $CXX,\n  LINK => $LINK,\n\tENV => { PATH => $ENV{PATH}, HOME => $ENV{HOME} },\n  CFLAGS => $BASE_CFLAGS . '-fPIC',\n  LDFLAGS => '-shared -ldl -lm'\n);\n\n# for TA, use -DMISSIONPACK\n%ta_env_hash = $env->copy(\n  CPPPATH => '#cgame:#game:#ui'\n  );\n$ta_env_hash{CFLAGS} = '-DMISSIONPACK ' . $ta_env_hash{CFLAGS};\n$ta_env = new cons(%ta_env_hash);\n\n# qvm building\n# we heavily customize the cons environment\n$vm_env = new cons(\n  # the code has the very bad habit of doing things like #include \"../ui/ui_shared.h\"\n  # this seems to confuse the dependency analysis, explicit toplevel includes seem to fix\n  CPPPATH => '#cgame:#game:#q3_ui',\n  CC => 'q3lcc',\n  CCCOM => '%CC %CFLAGS %_IFLAGS -c %< -o %>',\n  SUFOBJ => '.asm',\n  LINK => 'q3asm',\n  CFLAGS => '-DQ3_VM -DCGAME -S -Wf-target=bytecode -Wf-g',\n  # need to know where to find the compiler tools\n  ENV => { PATH => $ENV{PATH} . \":./qvmtools\", },\n);\n\n# TA qvm building\n%vm_ta_env_hash = $vm_env->copy(\n  CPPPATH => '#cgame:#game:#ui'\n  );\n$vm_ta_env_hash{CFLAGS} = '-DMISSIONPACK ' . $vm_ta_env_hash{CFLAGS};\n$vm_ta_env = new cons(%vm_ta_env_hash);\n\n# the file with vmMain function MUST be the first one of the list\n@FILES = qw(\n  cg_main.c\n  ../game/bg_misc.c\n  ../game/bg_pmove.c\n  ../game/bg_slidemove.c\n  ../game/q_math.c\n  ../game/q_shared.c\n  cg_consolecmds.c  \n  cg_draw.c\n  cg_drawtools.c\n  cg_effects.c\n  cg_ents.c\n  cg_event.c\n  cg_info.c\n  cg_localents.c\n  cg_marks.c\n  cg_players.c\n  cg_playerstate.c\n  cg_predict.c\n  cg_scoreboard.c\n  cg_servercmds.c\n  cg_snapshot.c\n  cg_view.c\n  cg_weapons.c\n  );\n$FILESREF = \\@FILES;\n\n# only in .so\n# (VM uses a custom .asm with equ stubs)\n@SO_FILES = qw(\n  cg_syscalls.c\n  );\n$SO_FILESREF = \\@SO_FILES;\n  \n# only for VM\n@VM_FILES = qw(\n  ../game/bg_lib.c\n  cg_syscalls.asm\n  );\n$VM_FILESREF = \\@VM_FILES;  \n\n# common additionals for TA\n@TA_FILES = qw(\n  cg_newdraw.c\n  ../ui/ui_shared.c\n  );\n$TA_FILESREF = \\@TA_FILES;\n\n# FIXME CPU string  \nif ($TARGET_DIR eq 'Q3')\n{\n\tif ($NO_SO eq 0)\n\t{\n\t\tProgram $env 'cgamei386.so', @$FILESREF, @$SO_FILESREF;\n\t\tInstall $env $INSTALL_DIR, 'cgamei386.so';\n\t}\n\tif ($NO_VM eq 0)\n\t{\n    Depends $vm_env 'cgame.qvm', '#qvmtools/q3lcc';\n    Depends $vm_env 'cgame.qvm', '#qvmtools/q3asm';\n\t\tProgram $vm_env 'cgame.qvm', @$FILESREF, @$VM_FILESREF;\n\t\tInstall $vm_env $INSTALL_DIR . '/vm', 'cgame.qvm';\n\t}\n}\nelse\n{\n\tif ($NO_SO eq 0)\n\t{\n\t\tProgram $ta_env 'cgamei386.so',\n\t\t\t@$FILESREF, @$SO_FILESREF, @$TA_FILESREF;\n\t\tInstall $ta_env $INSTALL_DIR, 'cgamei386.so';\n\t}\n\tif ($NO_VM eq 0)\n\t{\n    Depends $vm_env 'cgame.qvm', '#qvmtools/q3lcc';\n    Depends $vm_env 'cgame.qvm', '#qvmtools/q3asm';\n\t\tProgram $vm_ta_env 'cgame.qvm', \n\t\t\t@$FILESREF, @$VM_FILESREF, @$TA_FILESREF;\n\t\tInstall $vm_ta_env $INSTALL_DIR . '/vm', 'cgame.qvm';\n\t}\t\n}\n"
  },
  {
    "path": "code/cgame/cg_consolecmds.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// cg_consolecmds.c -- text commands typed in at the local console, or\n// executed by a key binding\n\n#include \"cg_local.h\"\n#include \"../ui/ui_shared.h\"\n#ifdef MISSIONPACK\nextern menuDef_t *menuScoreboard;\n#endif\n\n\n\nvoid CG_TargetCommand_f( void ) {\n\tint\t\ttargetNum;\n\tchar\ttest[4];\n\n\ttargetNum = CG_CrosshairPlayer();\n\tif (!targetNum ) {\n\t\treturn;\n\t}\n\n\ttrap_Argv( 1, test, 4 );\n\ttrap_SendConsoleCommand( va( \"gc %i %i\", targetNum, atoi( test ) ) );\n}\n\n\n\n/*\n=================\nCG_SizeUp_f\n\nKeybinding command\n=================\n*/\nstatic void CG_SizeUp_f (void) {\n\ttrap_Cvar_Set(\"cg_viewsize\", va(\"%i\",(int)(cg_viewsize.integer+10)));\n}\n\n\n/*\n=================\nCG_SizeDown_f\n\nKeybinding command\n=================\n*/\nstatic void CG_SizeDown_f (void) {\n\ttrap_Cvar_Set(\"cg_viewsize\", va(\"%i\",(int)(cg_viewsize.integer-10)));\n}\n\n\n/*\n=============\nCG_Viewpos_f\n\nDebugging command to print the current position\n=============\n*/\nstatic void CG_Viewpos_f (void) {\n\tCG_Printf (\"(%i %i %i) : %i\\n\", (int)cg.refdef.vieworg[0],\n\t\t(int)cg.refdef.vieworg[1], (int)cg.refdef.vieworg[2], \n\t\t(int)cg.refdefViewAngles[YAW]);\n}\n\n\nstatic void CG_ScoresDown_f( void ) {\n\n#ifdef MISSIONPACK\n\t\tCG_BuildSpectatorString();\n#endif\n\tif ( cg.scoresRequestTime + 2000 < cg.time ) {\n\t\t// the scores are more than two seconds out of data,\n\t\t// so request new ones\n\t\tcg.scoresRequestTime = cg.time;\n\t\ttrap_SendClientCommand( \"score\" );\n\n\t\t// leave the current scores up if they were already\n\t\t// displayed, but if this is the first hit, clear them out\n\t\tif ( !cg.showScores ) {\n\t\t\tcg.showScores = qtrue;\n\t\t\tcg.numScores = 0;\n\t\t}\n\t} else {\n\t\t// show the cached contents even if they just pressed if it\n\t\t// is within two seconds\n\t\tcg.showScores = qtrue;\n\t}\n}\n\nstatic void CG_ScoresUp_f( void ) {\n\tif ( cg.showScores ) {\n\t\tcg.showScores = qfalse;\n\t\tcg.scoreFadeTime = cg.time;\n\t}\n}\n\n#ifdef MISSIONPACK\nextern menuDef_t *menuScoreboard;\nvoid Menu_Reset();\t\t\t// FIXME: add to right include file\n\nstatic void CG_LoadHud_f( void) {\n  char buff[1024];\n\tconst char *hudSet;\n  memset(buff, 0, sizeof(buff));\n\n\tString_Init();\n\tMenu_Reset();\n\t\n\ttrap_Cvar_VariableStringBuffer(\"cg_hudFiles\", buff, sizeof(buff));\n\thudSet = buff;\n\tif (hudSet[0] == '\\0') {\n\t\thudSet = \"ui/hud.txt\";\n\t}\n\n\tCG_LoadMenus(hudSet);\n  menuScoreboard = NULL;\n}\n\n\nstatic void CG_scrollScoresDown_f( void) {\n\tif (menuScoreboard && cg.scoreBoardShowing) {\n\t\tMenu_ScrollFeeder(menuScoreboard, FEEDER_SCOREBOARD, qtrue);\n\t\tMenu_ScrollFeeder(menuScoreboard, FEEDER_REDTEAM_LIST, qtrue);\n\t\tMenu_ScrollFeeder(menuScoreboard, FEEDER_BLUETEAM_LIST, qtrue);\n\t}\n}\n\n\nstatic void CG_scrollScoresUp_f( void) {\n\tif (menuScoreboard && cg.scoreBoardShowing) {\n\t\tMenu_ScrollFeeder(menuScoreboard, FEEDER_SCOREBOARD, qfalse);\n\t\tMenu_ScrollFeeder(menuScoreboard, FEEDER_REDTEAM_LIST, qfalse);\n\t\tMenu_ScrollFeeder(menuScoreboard, FEEDER_BLUETEAM_LIST, qfalse);\n\t}\n}\n\n\nstatic void CG_spWin_f( void) {\n\ttrap_Cvar_Set(\"cg_cameraOrbit\", \"2\");\n\ttrap_Cvar_Set(\"cg_cameraOrbitDelay\", \"35\");\n\ttrap_Cvar_Set(\"cg_thirdPerson\", \"1\");\n\ttrap_Cvar_Set(\"cg_thirdPersonAngle\", \"0\");\n\ttrap_Cvar_Set(\"cg_thirdPersonRange\", \"100\");\n\tCG_AddBufferedSound(cgs.media.winnerSound);\n\t//trap_S_StartLocalSound(cgs.media.winnerSound, CHAN_ANNOUNCER);\n\tCG_CenterPrint(\"YOU WIN!\", SCREEN_HEIGHT * .30, 0);\n}\n\nstatic void CG_spLose_f( void) {\n\ttrap_Cvar_Set(\"cg_cameraOrbit\", \"2\");\n\ttrap_Cvar_Set(\"cg_cameraOrbitDelay\", \"35\");\n\ttrap_Cvar_Set(\"cg_thirdPerson\", \"1\");\n\ttrap_Cvar_Set(\"cg_thirdPersonAngle\", \"0\");\n\ttrap_Cvar_Set(\"cg_thirdPersonRange\", \"100\");\n\tCG_AddBufferedSound(cgs.media.loserSound);\n\t//trap_S_StartLocalSound(cgs.media.loserSound, CHAN_ANNOUNCER);\n\tCG_CenterPrint(\"YOU LOSE...\", SCREEN_HEIGHT * .30, 0);\n}\n\n#endif\n\nstatic void CG_TellTarget_f( void ) {\n\tint\t\tclientNum;\n\tchar\tcommand[128];\n\tchar\tmessage[128];\n\n\tclientNum = CG_CrosshairPlayer();\n\tif ( clientNum == -1 ) {\n\t\treturn;\n\t}\n\n\ttrap_Args( message, 128 );\n\tCom_sprintf( command, 128, \"tell %i %s\", clientNum, message );\n\ttrap_SendClientCommand( command );\n}\n\nstatic void CG_TellAttacker_f( void ) {\n\tint\t\tclientNum;\n\tchar\tcommand[128];\n\tchar\tmessage[128];\n\n\tclientNum = CG_LastAttacker();\n\tif ( clientNum == -1 ) {\n\t\treturn;\n\t}\n\n\ttrap_Args( message, 128 );\n\tCom_sprintf( command, 128, \"tell %i %s\", clientNum, message );\n\ttrap_SendClientCommand( command );\n}\n\nstatic void CG_VoiceTellTarget_f( void ) {\n\tint\t\tclientNum;\n\tchar\tcommand[128];\n\tchar\tmessage[128];\n\n\tclientNum = CG_CrosshairPlayer();\n\tif ( clientNum == -1 ) {\n\t\treturn;\n\t}\n\n\ttrap_Args( message, 128 );\n\tCom_sprintf( command, 128, \"vtell %i %s\", clientNum, message );\n\ttrap_SendClientCommand( command );\n}\n\nstatic void CG_VoiceTellAttacker_f( void ) {\n\tint\t\tclientNum;\n\tchar\tcommand[128];\n\tchar\tmessage[128];\n\n\tclientNum = CG_LastAttacker();\n\tif ( clientNum == -1 ) {\n\t\treturn;\n\t}\n\n\ttrap_Args( message, 128 );\n\tCom_sprintf( command, 128, \"vtell %i %s\", clientNum, message );\n\ttrap_SendClientCommand( command );\n}\n\n#ifdef MISSIONPACK\nstatic void CG_NextTeamMember_f( void ) {\n  CG_SelectNextPlayer();\n}\n\nstatic void CG_PrevTeamMember_f( void ) {\n  CG_SelectPrevPlayer();\n}\n\n// ASS U ME's enumeration order as far as task specific orders, OFFENSE is zero, CAMP is last\n//\nstatic void CG_NextOrder_f( void ) {\n\tclientInfo_t *ci = cgs.clientinfo + cg.snap->ps.clientNum;\n\tif (ci) {\n\t\tif (!ci->teamLeader && sortedTeamPlayers[cg_currentSelectedPlayer.integer] != cg.snap->ps.clientNum) {\n\t\t\treturn;\n\t\t}\n\t}\n\tif (cgs.currentOrder < TEAMTASK_CAMP) {\n\t\tcgs.currentOrder++;\n\n\t\tif (cgs.currentOrder == TEAMTASK_RETRIEVE) {\n\t\t\tif (!CG_OtherTeamHasFlag()) {\n\t\t\t\tcgs.currentOrder++;\n\t\t\t}\n\t\t}\n\n\t\tif (cgs.currentOrder == TEAMTASK_ESCORT) {\n\t\t\tif (!CG_YourTeamHasFlag()) {\n\t\t\t\tcgs.currentOrder++;\n\t\t\t}\n\t\t}\n\n\t} else {\n\t\tcgs.currentOrder = TEAMTASK_OFFENSE;\n\t}\n\tcgs.orderPending = qtrue;\n\tcgs.orderTime = cg.time + 3000;\n}\n\n\nstatic void CG_ConfirmOrder_f (void ) {\n\ttrap_SendConsoleCommand(va(\"cmd vtell %d %s\\n\", cgs.acceptLeader, VOICECHAT_YES));\n\ttrap_SendConsoleCommand(\"+button5; wait; -button5\");\n\tif (cg.time < cgs.acceptOrderTime) {\n\t\ttrap_SendClientCommand(va(\"teamtask %d\\n\", cgs.acceptTask));\n\t\tcgs.acceptOrderTime = 0;\n\t}\n}\n\nstatic void CG_DenyOrder_f (void ) {\n\ttrap_SendConsoleCommand(va(\"cmd vtell %d %s\\n\", cgs.acceptLeader, VOICECHAT_NO));\n\ttrap_SendConsoleCommand(\"+button6; wait; -button6\");\n\tif (cg.time < cgs.acceptOrderTime) {\n\t\tcgs.acceptOrderTime = 0;\n\t}\n}\n\nstatic void CG_TaskOffense_f (void ) {\n\tif (cgs.gametype == GT_CTF || cgs.gametype == GT_1FCTF) {\n\t\ttrap_SendConsoleCommand(va(\"cmd vsay_team %s\\n\", VOICECHAT_ONGETFLAG));\n\t} else {\n\t\ttrap_SendConsoleCommand(va(\"cmd vsay_team %s\\n\", VOICECHAT_ONOFFENSE));\n\t}\n\ttrap_SendClientCommand(va(\"teamtask %d\\n\", TEAMTASK_OFFENSE));\n}\n\nstatic void CG_TaskDefense_f (void ) {\n\ttrap_SendConsoleCommand(va(\"cmd vsay_team %s\\n\", VOICECHAT_ONDEFENSE));\n\ttrap_SendClientCommand(va(\"teamtask %d\\n\", TEAMTASK_DEFENSE));\n}\n\nstatic void CG_TaskPatrol_f (void ) {\n\ttrap_SendConsoleCommand(va(\"cmd vsay_team %s\\n\", VOICECHAT_ONPATROL));\n\ttrap_SendClientCommand(va(\"teamtask %d\\n\", TEAMTASK_PATROL));\n}\n\nstatic void CG_TaskCamp_f (void ) {\n\ttrap_SendConsoleCommand(va(\"cmd vsay_team %s\\n\", VOICECHAT_ONCAMPING));\n\ttrap_SendClientCommand(va(\"teamtask %d\\n\", TEAMTASK_CAMP));\n}\n\nstatic void CG_TaskFollow_f (void ) {\n\ttrap_SendConsoleCommand(va(\"cmd vsay_team %s\\n\", VOICECHAT_ONFOLLOW));\n\ttrap_SendClientCommand(va(\"teamtask %d\\n\", TEAMTASK_FOLLOW));\n}\n\nstatic void CG_TaskRetrieve_f (void ) {\n\ttrap_SendConsoleCommand(va(\"cmd vsay_team %s\\n\", VOICECHAT_ONRETURNFLAG));\n\ttrap_SendClientCommand(va(\"teamtask %d\\n\", TEAMTASK_RETRIEVE));\n}\n\nstatic void CG_TaskEscort_f (void ) {\n\ttrap_SendConsoleCommand(va(\"cmd vsay_team %s\\n\", VOICECHAT_ONFOLLOWCARRIER));\n\ttrap_SendClientCommand(va(\"teamtask %d\\n\", TEAMTASK_ESCORT));\n}\n\nstatic void CG_TaskOwnFlag_f (void ) {\n\ttrap_SendConsoleCommand(va(\"cmd vsay_team %s\\n\", VOICECHAT_IHAVEFLAG));\n}\n\nstatic void CG_TauntKillInsult_f (void ) {\n\ttrap_SendConsoleCommand(\"cmd vsay kill_insult\\n\");\n}\n\nstatic void CG_TauntPraise_f (void ) {\n\ttrap_SendConsoleCommand(\"cmd vsay praise\\n\");\n}\n\nstatic void CG_TauntTaunt_f (void ) {\n\ttrap_SendConsoleCommand(\"cmd vtaunt\\n\");\n}\n\nstatic void CG_TauntDeathInsult_f (void ) {\n\ttrap_SendConsoleCommand(\"cmd vsay death_insult\\n\");\n}\n\nstatic void CG_TauntGauntlet_f (void ) {\n\ttrap_SendConsoleCommand(\"cmd vsay kill_guantlet\\n\");\n}\n\nstatic void CG_TaskSuicide_f (void ) {\n\tint\t\tclientNum;\n\tchar\tcommand[128];\n\n\tclientNum = CG_CrosshairPlayer();\n\tif ( clientNum == -1 ) {\n\t\treturn;\n\t}\n\n\tCom_sprintf( command, 128, \"tell %i suicide\", clientNum );\n\ttrap_SendClientCommand( command );\n}\n\n\n\n/*\n==================\nCG_TeamMenu_f\n==================\n*/\n/*\nstatic void CG_TeamMenu_f( void ) {\n  if (trap_Key_GetCatcher() & KEYCATCH_CGAME) {\n    CG_EventHandling(CGAME_EVENT_NONE);\n    trap_Key_SetCatcher(0);\n  } else {\n    CG_EventHandling(CGAME_EVENT_TEAMMENU);\n    //trap_Key_SetCatcher(KEYCATCH_CGAME);\n  }\n}\n*/\n\n/*\n==================\nCG_EditHud_f\n==================\n*/\n/*\nstatic void CG_EditHud_f( void ) {\n  //cls.keyCatchers ^= KEYCATCH_CGAME;\n  //VM_Call (cgvm, CG_EVENT_HANDLING, (cls.keyCatchers & KEYCATCH_CGAME) ? CGAME_EVENT_EDITHUD : CGAME_EVENT_NONE);\n}\n*/\n\n#endif\n\n/*\n==================\nCG_StartOrbit_f\n==================\n*/\n\nstatic void CG_StartOrbit_f( void ) {\n\tchar var[MAX_TOKEN_CHARS];\n\n\ttrap_Cvar_VariableStringBuffer( \"developer\", var, sizeof( var ) );\n\tif ( !atoi(var) ) {\n\t\treturn;\n\t}\n\tif (cg_cameraOrbit.value != 0) {\n\t\ttrap_Cvar_Set (\"cg_cameraOrbit\", \"0\");\n\t\ttrap_Cvar_Set(\"cg_thirdPerson\", \"0\");\n\t} else {\n\t\ttrap_Cvar_Set(\"cg_cameraOrbit\", \"5\");\n\t\ttrap_Cvar_Set(\"cg_thirdPerson\", \"1\");\n\t\ttrap_Cvar_Set(\"cg_thirdPersonAngle\", \"0\");\n\t\ttrap_Cvar_Set(\"cg_thirdPersonRange\", \"100\");\n\t}\n}\n\n/*\nstatic void CG_Camera_f( void ) {\n\tchar name[1024];\n\ttrap_Argv( 1, name, sizeof(name));\n\tif (trap_loadCamera(name)) {\n\t\tcg.cameraMode = qtrue;\n\t\ttrap_startCamera(cg.time);\n\t} else {\n\t\tCG_Printf (\"Unable to load camera %s\\n\",name);\n\t}\n}\n*/\n\n\ntypedef struct {\n\tchar\t*cmd;\n\tvoid\t(*function)(void);\n} consoleCommand_t;\n\nstatic consoleCommand_t\tcommands[] = {\n\t{ \"testgun\", CG_TestGun_f },\n\t{ \"testmodel\", CG_TestModel_f },\n\t{ \"nextframe\", CG_TestModelNextFrame_f },\n\t{ \"prevframe\", CG_TestModelPrevFrame_f },\n\t{ \"nextskin\", CG_TestModelNextSkin_f },\n\t{ \"prevskin\", CG_TestModelPrevSkin_f },\n\t{ \"viewpos\", CG_Viewpos_f },\n\t{ \"+scores\", CG_ScoresDown_f },\n\t{ \"-scores\", CG_ScoresUp_f },\n\t{ \"+zoom\", CG_ZoomDown_f },\n\t{ \"-zoom\", CG_ZoomUp_f },\n\t{ \"sizeup\", CG_SizeUp_f },\n\t{ \"sizedown\", CG_SizeDown_f },\n\t{ \"weapnext\", CG_NextWeapon_f },\n\t{ \"weapprev\", CG_PrevWeapon_f },\n\t{ \"weapon\", CG_Weapon_f },\n\t{ \"tell_target\", CG_TellTarget_f },\n\t{ \"tell_attacker\", CG_TellAttacker_f },\n\t{ \"vtell_target\", CG_VoiceTellTarget_f },\n\t{ \"vtell_attacker\", CG_VoiceTellAttacker_f },\n\t{ \"tcmd\", CG_TargetCommand_f },\n#ifdef MISSIONPACK\n\t{ \"loadhud\", CG_LoadHud_f },\n\t{ \"nextTeamMember\", CG_NextTeamMember_f },\n\t{ \"prevTeamMember\", CG_PrevTeamMember_f },\n\t{ \"nextOrder\", CG_NextOrder_f },\n\t{ \"confirmOrder\", CG_ConfirmOrder_f },\n\t{ \"denyOrder\", CG_DenyOrder_f },\n\t{ \"taskOffense\", CG_TaskOffense_f },\n\t{ \"taskDefense\", CG_TaskDefense_f },\n\t{ \"taskPatrol\", CG_TaskPatrol_f },\n\t{ \"taskCamp\", CG_TaskCamp_f },\n\t{ \"taskFollow\", CG_TaskFollow_f },\n\t{ \"taskRetrieve\", CG_TaskRetrieve_f },\n\t{ \"taskEscort\", CG_TaskEscort_f },\n\t{ \"taskSuicide\", CG_TaskSuicide_f },\n\t{ \"taskOwnFlag\", CG_TaskOwnFlag_f },\n\t{ \"tauntKillInsult\", CG_TauntKillInsult_f },\n\t{ \"tauntPraise\", CG_TauntPraise_f },\n\t{ \"tauntTaunt\", CG_TauntTaunt_f },\n\t{ \"tauntDeathInsult\", CG_TauntDeathInsult_f },\n\t{ \"tauntGauntlet\", CG_TauntGauntlet_f },\n\t{ \"spWin\", CG_spWin_f },\n\t{ \"spLose\", CG_spLose_f },\n\t{ \"scoresDown\", CG_scrollScoresDown_f },\n\t{ \"scoresUp\", CG_scrollScoresUp_f },\n#endif\n\t{ \"startOrbit\", CG_StartOrbit_f },\n\t//{ \"camera\", CG_Camera_f },\n\t{ \"loaddeferred\", CG_LoadDeferredPlayers }\t\n};\n\n\n/*\n=================\nCG_ConsoleCommand\n\nThe string has been tokenized and can be retrieved with\nCmd_Argc() / Cmd_Argv()\n=================\n*/\nqboolean CG_ConsoleCommand( void ) {\n\tconst char\t*cmd;\n\tint\t\ti;\n\n\tcmd = CG_Argv(0);\n\n\tfor ( i = 0 ; i < sizeof( commands ) / sizeof( commands[0] ) ; i++ ) {\n\t\tif ( !Q_stricmp( cmd, commands[i].cmd ) ) {\n\t\t\tcommands[i].function();\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\n\treturn qfalse;\n}\n\n\n/*\n=================\nCG_InitConsoleCommands\n\nLet the client system know about all of our commands\nso it can perform tab completion\n=================\n*/\nvoid CG_InitConsoleCommands( void ) {\n\tint\t\ti;\n\n\tfor ( i = 0 ; i < sizeof( commands ) / sizeof( commands[0] ) ; i++ ) {\n\t\ttrap_AddCommand( commands[i].cmd );\n\t}\n\n\t//\n\t// the game server will interpret these commands, which will be automatically\n\t// forwarded to the server after they are not recognized locally\n\t//\n\ttrap_AddCommand (\"kill\");\n\ttrap_AddCommand (\"say\");\n\ttrap_AddCommand (\"say_team\");\n\ttrap_AddCommand (\"tell\");\n\ttrap_AddCommand (\"vsay\");\n\ttrap_AddCommand (\"vsay_team\");\n\ttrap_AddCommand (\"vtell\");\n\ttrap_AddCommand (\"vtaunt\");\n\ttrap_AddCommand (\"vosay\");\n\ttrap_AddCommand (\"vosay_team\");\n\ttrap_AddCommand (\"votell\");\n\ttrap_AddCommand (\"give\");\n\ttrap_AddCommand (\"god\");\n\ttrap_AddCommand (\"notarget\");\n\ttrap_AddCommand (\"noclip\");\n\ttrap_AddCommand (\"team\");\n\ttrap_AddCommand (\"follow\");\n\ttrap_AddCommand (\"levelshot\");\n\ttrap_AddCommand (\"addbot\");\n\ttrap_AddCommand (\"setviewpos\");\n\ttrap_AddCommand (\"callvote\");\n\ttrap_AddCommand (\"vote\");\n\ttrap_AddCommand (\"callteamvote\");\n\ttrap_AddCommand (\"teamvote\");\n\ttrap_AddCommand (\"stats\");\n\ttrap_AddCommand (\"teamtask\");\n\ttrap_AddCommand (\"loaddefered\");\t// spelled wrong, but not changing for demo\n}\n"
  },
  {
    "path": "code/cgame/cg_draw.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// cg_draw.c -- draw all of the graphical elements during\n// active (after loading) gameplay\n\n#include \"cg_local.h\"\n\n#ifdef MISSIONPACK\n#include \"../ui/ui_shared.h\"\n\n// used for scoreboard\nextern displayContextDef_t cgDC;\nmenuDef_t *menuScoreboard = NULL;\n#else\nint drawTeamOverlayModificationCount = -1;\n#endif\n\nint sortedTeamPlayers[TEAM_MAXOVERLAY];\nint\tnumSortedTeamPlayers;\n\nchar systemChat[256];\nchar teamChat1[256];\nchar teamChat2[256];\n\n#ifdef MISSIONPACK\n\nint CG_Text_Width(const char *text, float scale, int limit) {\n  int count,len;\n\tfloat out;\n\tglyphInfo_t *glyph;\n\tfloat useScale;\n// FIXME: see ui_main.c, same problem\n//\tconst unsigned char *s = text;\n\tconst char *s = text;\n\tfontInfo_t *font = &cgDC.Assets.textFont;\n\tif (scale <= cg_smallFont.value) {\n\t\tfont = &cgDC.Assets.smallFont;\n\t} else if (scale > cg_bigFont.value) {\n\t\tfont = &cgDC.Assets.bigFont;\n\t}\n\tuseScale = scale * font->glyphScale;\n  out = 0;\n  if (text) {\n    len = strlen(text);\n\t\tif (limit > 0 && len > limit) {\n\t\t\tlen = limit;\n\t\t}\n\t\tcount = 0;\n\t\twhile (s && *s && count < len) {\n\t\t\tif ( Q_IsColorString(s) ) {\n\t\t\t\ts += 2;\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\tglyph = &font->glyphs[(int)*s]; // TTimo: FIXME: getting nasty warnings without the cast, hopefully this doesn't break the VM build\n\t\t\t\tout += glyph->xSkip;\n\t\t\t\ts++;\n\t\t\t\tcount++;\n\t\t\t}\n    }\n  }\n  return out * useScale;\n}\n\nint CG_Text_Height(const char *text, float scale, int limit) {\n  int len, count;\n\tfloat max;\n\tglyphInfo_t *glyph;\n\tfloat useScale;\n// TTimo: FIXME\n//\tconst unsigned char *s = text;\n\tconst char *s = text;\n\tfontInfo_t *font = &cgDC.Assets.textFont;\n\tif (scale <= cg_smallFont.value) {\n\t\tfont = &cgDC.Assets.smallFont;\n\t} else if (scale > cg_bigFont.value) {\n\t\tfont = &cgDC.Assets.bigFont;\n\t}\n\tuseScale = scale * font->glyphScale;\n  max = 0;\n  if (text) {\n    len = strlen(text);\n\t\tif (limit > 0 && len > limit) {\n\t\t\tlen = limit;\n\t\t}\n\t\tcount = 0;\n\t\twhile (s && *s && count < len) {\n\t\t\tif ( Q_IsColorString(s) ) {\n\t\t\t\ts += 2;\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\tglyph = &font->glyphs[(int)*s]; // TTimo: FIXME: getting nasty warnings without the cast, hopefully this doesn't break the VM build\n\t      if (max < glyph->height) {\n\t\t      max = glyph->height;\n\t\t\t  }\n\t\t\t\ts++;\n\t\t\t\tcount++;\n\t\t\t}\n    }\n  }\n  return max * useScale;\n}\n\nvoid CG_Text_PaintChar(float x, float y, float width, float height, float scale, float s, float t, float s2, float t2, qhandle_t hShader) {\n  float w, h;\n  w = width * scale;\n  h = height * scale;\n  CG_AdjustFrom640( &x, &y, &w, &h );\n  trap_R_DrawStretchPic( x, y, w, h, s, t, s2, t2, hShader );\n}\n\nvoid CG_Text_Paint(float x, float y, float scale, vec4_t color, const char *text, float adjust, int limit, int style) {\n  int len, count;\n\tvec4_t newColor;\n\tglyphInfo_t *glyph;\n\tfloat useScale;\n\tfontInfo_t *font = &cgDC.Assets.textFont;\n\tif (scale <= cg_smallFont.value) {\n\t\tfont = &cgDC.Assets.smallFont;\n\t} else if (scale > cg_bigFont.value) {\n\t\tfont = &cgDC.Assets.bigFont;\n\t}\n\tuseScale = scale * font->glyphScale;\n  if (text) {\n// TTimo: FIXME\n//\t\tconst unsigned char *s = text;\n\t\tconst char *s = text;\n\t\ttrap_R_SetColor( color );\n\t\tmemcpy(&newColor[0], &color[0], sizeof(vec4_t));\n    len = strlen(text);\n\t\tif (limit > 0 && len > limit) {\n\t\t\tlen = limit;\n\t\t}\n\t\tcount = 0;\n\t\twhile (s && *s && count < len) {\n\t\t\tglyph = &font->glyphs[(int)*s]; // TTimo: FIXME: getting nasty warnings without the cast, hopefully this doesn't break the VM build\n      //int yadj = Assets.textFont.glyphs[text[i]].bottom + Assets.textFont.glyphs[text[i]].top;\n      //float yadj = scale * (Assets.textFont.glyphs[text[i]].imageHeight - Assets.textFont.glyphs[text[i]].height);\n\t\t\tif ( Q_IsColorString( s ) ) {\n\t\t\t\tmemcpy( newColor, g_color_table[ColorIndex(*(s+1))], sizeof( newColor ) );\n\t\t\t\tnewColor[3] = color[3];\n\t\t\t\ttrap_R_SetColor( newColor );\n\t\t\t\ts += 2;\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\tfloat yadj = useScale * glyph->top;\n\t\t\t\tif (style == ITEM_TEXTSTYLE_SHADOWED || style == ITEM_TEXTSTYLE_SHADOWEDMORE) {\n\t\t\t\t\tint ofs = style == ITEM_TEXTSTYLE_SHADOWED ? 1 : 2;\n\t\t\t\t\tcolorBlack[3] = newColor[3];\n\t\t\t\t\ttrap_R_SetColor( colorBlack );\n\t\t\t\t\tCG_Text_PaintChar(x + ofs, y - yadj + ofs, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->imageWidth,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->imageHeight,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tuseScale, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->s,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->t,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->s2,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->t2,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->glyph);\n\t\t\t\t\tcolorBlack[3] = 1.0;\n\t\t\t\t\ttrap_R_SetColor( newColor );\n\t\t\t\t}\n\t\t\t\tCG_Text_PaintChar(x, y - yadj, \n\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->imageWidth,\n\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->imageHeight,\n\t\t\t\t\t\t\t\t\t\t\t\t\tuseScale, \n\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->s,\n\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->t,\n\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->s2,\n\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->t2,\n\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->glyph);\n\t\t\t\t// CG_DrawPic(x, y - yadj, scale * cgDC.Assets.textFont.glyphs[text[i]].imageWidth, scale * cgDC.Assets.textFont.glyphs[text[i]].imageHeight, cgDC.Assets.textFont.glyphs[text[i]].glyph);\n\t\t\t\tx += (glyph->xSkip * useScale) + adjust;\n\t\t\t\ts++;\n\t\t\t\tcount++;\n\t\t\t}\n    }\n\t  trap_R_SetColor( NULL );\n  }\n}\n\n\n#endif\n\n/*\n==============\nCG_DrawField\n\nDraws large numbers for status bar and powerups\n==============\n*/\n#ifndef MISSIONPACK\nstatic void CG_DrawField (int x, int y, int width, int value) {\n\tchar\tnum[16], *ptr;\n\tint\t\tl;\n\tint\t\tframe;\n\n\tif ( width < 1 ) {\n\t\treturn;\n\t}\n\n\t// draw number string\n\tif ( width > 5 ) {\n\t\twidth = 5;\n\t}\n\n\tswitch ( width ) {\n\tcase 1:\n\t\tvalue = value > 9 ? 9 : value;\n\t\tvalue = value < 0 ? 0 : value;\n\t\tbreak;\n\tcase 2:\n\t\tvalue = value > 99 ? 99 : value;\n\t\tvalue = value < -9 ? -9 : value;\n\t\tbreak;\n\tcase 3:\n\t\tvalue = value > 999 ? 999 : value;\n\t\tvalue = value < -99 ? -99 : value;\n\t\tbreak;\n\tcase 4:\n\t\tvalue = value > 9999 ? 9999 : value;\n\t\tvalue = value < -999 ? -999 : value;\n\t\tbreak;\n\t}\n\n\tCom_sprintf (num, sizeof(num), \"%i\", value);\n\tl = strlen(num);\n\tif (l > width)\n\t\tl = width;\n\tx += 2 + CHAR_WIDTH*(width - l);\n\n\tptr = num;\n\twhile (*ptr && l)\n\t{\n\t\tif (*ptr == '-')\n\t\t\tframe = STAT_MINUS;\n\t\telse\n\t\t\tframe = *ptr -'0';\n\n\t\tCG_DrawPic( x,y, CHAR_WIDTH, CHAR_HEIGHT, cgs.media.numberShaders[frame] );\n\t\tx += CHAR_WIDTH;\n\t\tptr++;\n\t\tl--;\n\t}\n}\n#endif // MISSIONPACK\n\n/*\n================\nCG_Draw3DModel\n\n================\n*/\nvoid CG_Draw3DModel( float x, float y, float w, float h, qhandle_t model, qhandle_t skin, vec3_t origin, vec3_t angles ) {\n\trefdef_t\t\trefdef;\n\trefEntity_t\t\tent;\n\n\tif ( !cg_draw3dIcons.integer || !cg_drawIcons.integer ) {\n\t\treturn;\n\t}\n\n\tCG_AdjustFrom640( &x, &y, &w, &h );\n\n\tmemset( &refdef, 0, sizeof( refdef ) );\n\n\tmemset( &ent, 0, sizeof( ent ) );\n\tAnglesToAxis( angles, ent.axis );\n\tVectorCopy( origin, ent.origin );\n\tent.hModel = model;\n\tent.customSkin = skin;\n\tent.renderfx = RF_NOSHADOW;\t\t// no stencil shadows\n\n\trefdef.rdflags = RDF_NOWORLDMODEL;\n\n\tAxisClear( refdef.viewaxis );\n\n\trefdef.fov_x = 30;\n\trefdef.fov_y = 30;\n\n\trefdef.x = x;\n\trefdef.y = y;\n\trefdef.width = w;\n\trefdef.height = h;\n\n\trefdef.time = cg.time;\n\n\ttrap_R_ClearScene();\n\ttrap_R_AddRefEntityToScene( &ent );\n\ttrap_R_RenderScene( &refdef );\n}\n\n/*\n================\nCG_DrawHead\n\nUsed for both the status bar and the scoreboard\n================\n*/\nvoid CG_DrawHead( float x, float y, float w, float h, int clientNum, vec3_t headAngles ) {\n\tclipHandle_t\tcm;\n\tclientInfo_t\t*ci;\n\tfloat\t\t\tlen;\n\tvec3_t\t\t\torigin;\n\tvec3_t\t\t\tmins, maxs;\n\n\tci = &cgs.clientinfo[ clientNum ];\n\n\tif ( cg_draw3dIcons.integer ) {\n\t\tcm = ci->headModel;\n\t\tif ( !cm ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// offset the origin y and z to center the head\n\t\ttrap_R_ModelBounds( cm, mins, maxs );\n\n\t\torigin[2] = -0.5 * ( mins[2] + maxs[2] );\n\t\torigin[1] = 0.5 * ( mins[1] + maxs[1] );\n\n\t\t// calculate distance so the head nearly fills the box\n\t\t// assume heads are taller than wide\n\t\tlen = 0.7 * ( maxs[2] - mins[2] );\t\t\n\t\torigin[0] = len / 0.268;\t// len / tan( fov/2 )\n\n\t\t// allow per-model tweaking\n\t\tVectorAdd( origin, ci->headOffset, origin );\n\n\t\tCG_Draw3DModel( x, y, w, h, ci->headModel, ci->headSkin, origin, headAngles );\n\t} else if ( cg_drawIcons.integer ) {\n\t\tCG_DrawPic( x, y, w, h, ci->modelIcon );\n\t}\n\n\t// if they are deferred, draw a cross out\n\tif ( ci->deferred ) {\n\t\tCG_DrawPic( x, y, w, h, cgs.media.deferShader );\n\t}\n}\n\n/*\n================\nCG_DrawFlagModel\n\nUsed for both the status bar and the scoreboard\n================\n*/\nvoid CG_DrawFlagModel( float x, float y, float w, float h, int team, qboolean force2D ) {\n\tqhandle_t\t\tcm;\n\tfloat\t\t\tlen;\n\tvec3_t\t\t\torigin, angles;\n\tvec3_t\t\t\tmins, maxs;\n\tqhandle_t\t\thandle;\n\n\tif ( !force2D && cg_draw3dIcons.integer ) {\n\n\t\tVectorClear( angles );\n\n\t\tcm = cgs.media.redFlagModel;\n\n\t\t// offset the origin y and z to center the flag\n\t\ttrap_R_ModelBounds( cm, mins, maxs );\n\n\t\torigin[2] = -0.5 * ( mins[2] + maxs[2] );\n\t\torigin[1] = 0.5 * ( mins[1] + maxs[1] );\n\n\t\t// calculate distance so the flag nearly fills the box\n\t\t// assume heads are taller than wide\n\t\tlen = 0.5 * ( maxs[2] - mins[2] );\t\t\n\t\torigin[0] = len / 0.268;\t// len / tan( fov/2 )\n\n\t\tangles[YAW] = 60 * sin( cg.time / 2000.0 );;\n\n\t\tif( team == TEAM_RED ) {\n\t\t\thandle = cgs.media.redFlagModel;\n\t\t} else if( team == TEAM_BLUE ) {\n\t\t\thandle = cgs.media.blueFlagModel;\n\t\t} else if( team == TEAM_FREE ) {\n\t\t\thandle = cgs.media.neutralFlagModel;\n\t\t} else {\n\t\t\treturn;\n\t\t}\n\t\tCG_Draw3DModel( x, y, w, h, handle, 0, origin, angles );\n\t} else if ( cg_drawIcons.integer ) {\n\t\tgitem_t *item;\n\n\t\tif( team == TEAM_RED ) {\n\t\t\titem = BG_FindItemForPowerup( PW_REDFLAG );\n\t\t} else if( team == TEAM_BLUE ) {\n\t\t\titem = BG_FindItemForPowerup( PW_BLUEFLAG );\n\t\t} else if( team == TEAM_FREE ) {\n\t\t\titem = BG_FindItemForPowerup( PW_NEUTRALFLAG );\n\t\t} else {\n\t\t\treturn;\n\t\t}\n\t\tif (item) {\n\t\t  CG_DrawPic( x, y, w, h, cg_items[ ITEM_INDEX(item) ].icon );\n\t\t}\n\t}\n}\n\n/*\n================\nCG_DrawStatusBarHead\n\n================\n*/\n#ifndef MISSIONPACK\n\nstatic void CG_DrawStatusBarHead( float x ) {\n\tvec3_t\t\tangles;\n\tfloat\t\tsize, stretch;\n\tfloat\t\tfrac;\n\n\tVectorClear( angles );\n\n\tif ( cg.damageTime && cg.time - cg.damageTime < DAMAGE_TIME ) {\n\t\tfrac = (float)(cg.time - cg.damageTime ) / DAMAGE_TIME;\n\t\tsize = ICON_SIZE * 1.25 * ( 1.5 - frac * 0.5 );\n\n\t\tstretch = size - ICON_SIZE * 1.25;\n\t\t// kick in the direction of damage\n\t\tx -= stretch * 0.5 + cg.damageX * stretch * 0.5;\n\n\t\tcg.headStartYaw = 180 + cg.damageX * 45;\n\n\t\tcg.headEndYaw = 180 + 20 * cos( crandom()*M_PI );\n\t\tcg.headEndPitch = 5 * cos( crandom()*M_PI );\n\n\t\tcg.headStartTime = cg.time;\n\t\tcg.headEndTime = cg.time + 100 + random() * 2000;\n\t} else {\n\t\tif ( cg.time >= cg.headEndTime ) {\n\t\t\t// select a new head angle\n\t\t\tcg.headStartYaw = cg.headEndYaw;\n\t\t\tcg.headStartPitch = cg.headEndPitch;\n\t\t\tcg.headStartTime = cg.headEndTime;\n\t\t\tcg.headEndTime = cg.time + 100 + random() * 2000;\n\n\t\t\tcg.headEndYaw = 180 + 20 * cos( crandom()*M_PI );\n\t\t\tcg.headEndPitch = 5 * cos( crandom()*M_PI );\n\t\t}\n\n\t\tsize = ICON_SIZE * 1.25;\n\t}\n\n\t// if the server was frozen for a while we may have a bad head start time\n\tif ( cg.headStartTime > cg.time ) {\n\t\tcg.headStartTime = cg.time;\n\t}\n\n\tfrac = ( cg.time - cg.headStartTime ) / (float)( cg.headEndTime - cg.headStartTime );\n\tfrac = frac * frac * ( 3 - 2 * frac );\n\tangles[YAW] = cg.headStartYaw + ( cg.headEndYaw - cg.headStartYaw ) * frac;\n\tangles[PITCH] = cg.headStartPitch + ( cg.headEndPitch - cg.headStartPitch ) * frac;\n\n\tCG_DrawHead( x, 480 - size, size, size, \n\t\t\t\tcg.snap->ps.clientNum, angles );\n}\n#endif // MISSIONPACK\n\n/*\n================\nCG_DrawStatusBarFlag\n\n================\n*/\n#ifndef MISSIONPACK\nstatic void CG_DrawStatusBarFlag( float x, int team ) {\n\tCG_DrawFlagModel( x, 480 - ICON_SIZE, ICON_SIZE, ICON_SIZE, team, qfalse );\n}\n#endif // MISSIONPACK\n\n/*\n================\nCG_DrawTeamBackground\n\n================\n*/\nvoid CG_DrawTeamBackground( int x, int y, int w, int h, float alpha, int team )\n{\n\tvec4_t\t\thcolor;\n\n\thcolor[3] = alpha;\n\tif ( team == TEAM_RED ) {\n\t\thcolor[0] = 1;\n\t\thcolor[1] = 0;\n\t\thcolor[2] = 0;\n\t} else if ( team == TEAM_BLUE ) {\n\t\thcolor[0] = 0;\n\t\thcolor[1] = 0;\n\t\thcolor[2] = 1;\n\t} else {\n\t\treturn;\n\t}\n\ttrap_R_SetColor( hcolor );\n\tCG_DrawPic( x, y, w, h, cgs.media.teamStatusBar );\n\ttrap_R_SetColor( NULL );\n}\n\n/*\n================\nCG_DrawStatusBar\n\n================\n*/\n#ifndef MISSIONPACK\nstatic void CG_DrawStatusBar( void ) {\n\tint\t\t\tcolor;\n\tcentity_t\t*cent;\n\tplayerState_t\t*ps;\n\tint\t\t\tvalue;\n\tvec4_t\t\thcolor;\n\tvec3_t\t\tangles;\n\tvec3_t\t\torigin;\n#ifdef MISSIONPACK\n\tqhandle_t\thandle;\n#endif\n\tstatic float colors[4][4] = { \n//\t\t{ 0.2, 1.0, 0.2, 1.0 } , { 1.0, 0.2, 0.2, 1.0 }, {0.5, 0.5, 0.5, 1} };\n\t\t{ 1.0f, 0.69f, 0.0f, 1.0f },    // normal\n\t\t{ 1.0f, 0.2f, 0.2f, 1.0f },     // low health\n\t\t{ 0.5f, 0.5f, 0.5f, 1.0f },     // weapon firing\n\t\t{ 1.0f, 1.0f, 1.0f, 1.0f } };   // health > 100\n\n\tif ( cg_drawStatus.integer == 0 ) {\n\t\treturn;\n\t}\n\n\t// draw the team background\n\tCG_DrawTeamBackground( 0, 420, 640, 60, 0.33f, cg.snap->ps.persistant[PERS_TEAM] );\n\n\tcent = &cg_entities[cg.snap->ps.clientNum];\n\tps = &cg.snap->ps;\n\n\tVectorClear( angles );\n\n\t// draw any 3D icons first, so the changes back to 2D are minimized\n\tif ( cent->currentState.weapon && cg_weapons[ cent->currentState.weapon ].ammoModel ) {\n\t\torigin[0] = 70;\n\t\torigin[1] = 0;\n\t\torigin[2] = 0;\n\t\tangles[YAW] = 90 + 20 * sin( cg.time / 1000.0 );\n\t\tCG_Draw3DModel( CHAR_WIDTH*3 + TEXT_ICON_SPACE, 432, ICON_SIZE, ICON_SIZE,\n\t\t\t\t\t   cg_weapons[ cent->currentState.weapon ].ammoModel, 0, origin, angles );\n\t}\n\n\tCG_DrawStatusBarHead( 185 + CHAR_WIDTH*3 + TEXT_ICON_SPACE );\n\n\tif( cg.predictedPlayerState.powerups[PW_REDFLAG] ) {\n\t\tCG_DrawStatusBarFlag( 185 + CHAR_WIDTH*3 + TEXT_ICON_SPACE + ICON_SIZE, TEAM_RED );\n\t} else if( cg.predictedPlayerState.powerups[PW_BLUEFLAG] ) {\n\t\tCG_DrawStatusBarFlag( 185 + CHAR_WIDTH*3 + TEXT_ICON_SPACE + ICON_SIZE, TEAM_BLUE );\n\t} else if( cg.predictedPlayerState.powerups[PW_NEUTRALFLAG] ) {\n\t\tCG_DrawStatusBarFlag( 185 + CHAR_WIDTH*3 + TEXT_ICON_SPACE + ICON_SIZE, TEAM_FREE );\n\t}\n\n\tif ( ps->stats[ STAT_ARMOR ] ) {\n\t\torigin[0] = 90;\n\t\torigin[1] = 0;\n\t\torigin[2] = -10;\n\t\tangles[YAW] = ( cg.time & 2047 ) * 360 / 2048.0;\n\t\tCG_Draw3DModel( 370 + CHAR_WIDTH*3 + TEXT_ICON_SPACE, 432, ICON_SIZE, ICON_SIZE,\n\t\t\t\t\t   cgs.media.armorModel, 0, origin, angles );\n\t}\n#ifdef MISSIONPACK\n\tif( cgs.gametype == GT_HARVESTER ) {\n\t\torigin[0] = 90;\n\t\torigin[1] = 0;\n\t\torigin[2] = -10;\n\t\tangles[YAW] = ( cg.time & 2047 ) * 360 / 2048.0;\n\t\tif( cg.snap->ps.persistant[PERS_TEAM] == TEAM_BLUE ) {\n\t\t\thandle = cgs.media.redCubeModel;\n\t\t} else {\n\t\t\thandle = cgs.media.blueCubeModel;\n\t\t}\n\t\tCG_Draw3DModel( 640 - (TEXT_ICON_SPACE + ICON_SIZE), 416, ICON_SIZE, ICON_SIZE, handle, 0, origin, angles );\n\t}\n#endif\n\t//\n\t// ammo\n\t//\n\tif ( cent->currentState.weapon ) {\n\t\tvalue = ps->ammo[cent->currentState.weapon];\n\t\tif ( value > -1 ) {\n\t\t\tif ( cg.predictedPlayerState.weaponstate == WEAPON_FIRING\n\t\t\t\t&& cg.predictedPlayerState.weaponTime > 100 ) {\n\t\t\t\t// draw as dark grey when reloading\n\t\t\t\tcolor = 2;\t// dark grey\n\t\t\t} else {\n\t\t\t\tif ( value >= 0 ) {\n\t\t\t\t\tcolor = 0;\t// green\n\t\t\t\t} else {\n\t\t\t\t\tcolor = 1;\t// red\n\t\t\t\t}\n\t\t\t}\n\t\t\ttrap_R_SetColor( colors[color] );\n\t\t\t\n\t\t\tCG_DrawField (0, 432, 3, value);\n\t\t\ttrap_R_SetColor( NULL );\n\n\t\t\t// if we didn't draw a 3D icon, draw a 2D icon for ammo\n\t\t\tif ( !cg_draw3dIcons.integer && cg_drawIcons.integer ) {\n\t\t\t\tqhandle_t\ticon;\n\n\t\t\t\ticon = cg_weapons[ cg.predictedPlayerState.weapon ].ammoIcon;\n\t\t\t\tif ( icon ) {\n\t\t\t\t\tCG_DrawPic( CHAR_WIDTH*3 + TEXT_ICON_SPACE, 432, ICON_SIZE, ICON_SIZE, icon );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t//\n\t// health\n\t//\n\tvalue = ps->stats[STAT_HEALTH];\n\tif ( value > 100 ) {\n\t\ttrap_R_SetColor( colors[3] );\t\t// white\n\t} else if (value > 25) {\n\t\ttrap_R_SetColor( colors[0] );\t// green\n\t} else if (value > 0) {\n\t\tcolor = (cg.time >> 8) & 1;\t// flash\n\t\ttrap_R_SetColor( colors[color] );\n\t} else {\n\t\ttrap_R_SetColor( colors[1] );\t// red\n\t}\n\n\t// stretch the health up when taking damage\n\tCG_DrawField ( 185, 432, 3, value);\n\tCG_ColorForHealth( hcolor );\n\ttrap_R_SetColor( hcolor );\n\n\n\t//\n\t// armor\n\t//\n\tvalue = ps->stats[STAT_ARMOR];\n\tif (value > 0 ) {\n\t\ttrap_R_SetColor( colors[0] );\n\t\tCG_DrawField (370, 432, 3, value);\n\t\ttrap_R_SetColor( NULL );\n\t\t// if we didn't draw a 3D icon, draw a 2D icon for armor\n\t\tif ( !cg_draw3dIcons.integer && cg_drawIcons.integer ) {\n\t\t\tCG_DrawPic( 370 + CHAR_WIDTH*3 + TEXT_ICON_SPACE, 432, ICON_SIZE, ICON_SIZE, cgs.media.armorIcon );\n\t\t}\n\n\t}\n#ifdef MISSIONPACK\n\t//\n\t// cubes\n\t//\n\tif( cgs.gametype == GT_HARVESTER ) {\n\t\tvalue = ps->generic1;\n\t\tif( value > 99 ) {\n\t\t\tvalue = 99;\n\t\t}\n\t\ttrap_R_SetColor( colors[0] );\n\t\tCG_DrawField (640 - (CHAR_WIDTH*2 + TEXT_ICON_SPACE + ICON_SIZE), 432, 2, value);\n\t\ttrap_R_SetColor( NULL );\n\t\t// if we didn't draw a 3D icon, draw a 2D icon for armor\n\t\tif ( !cg_draw3dIcons.integer && cg_drawIcons.integer ) {\n\t\t\tif( cg.snap->ps.persistant[PERS_TEAM] == TEAM_BLUE ) {\n\t\t\t\thandle = cgs.media.redCubeIcon;\n\t\t\t} else {\n\t\t\t\thandle = cgs.media.blueCubeIcon;\n\t\t\t}\n\t\t\tCG_DrawPic( 640 - (TEXT_ICON_SPACE + ICON_SIZE), 432, ICON_SIZE, ICON_SIZE, handle );\n\t\t}\n\t}\n#endif\n}\n#endif\n\n/*\n===========================================================================================\n\n  UPPER RIGHT CORNER\n\n===========================================================================================\n*/\n\n/*\n================\nCG_DrawAttacker\n\n================\n*/\nstatic float CG_DrawAttacker( float y ) {\n\tint\t\t\tt;\n\tfloat\t\tsize;\n\tvec3_t\t\tangles;\n\tconst char\t*info;\n\tconst char\t*name;\n\tint\t\t\tclientNum;\n\n\tif ( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) {\n\t\treturn y;\n\t}\n\n\tif ( !cg.attackerTime ) {\n\t\treturn y;\n\t}\n\n\tclientNum = cg.predictedPlayerState.persistant[PERS_ATTACKER];\n\tif ( clientNum < 0 || clientNum >= MAX_CLIENTS || clientNum == cg.snap->ps.clientNum ) {\n\t\treturn y;\n\t}\n\n\tt = cg.time - cg.attackerTime;\n\tif ( t > ATTACKER_HEAD_TIME ) {\n\t\tcg.attackerTime = 0;\n\t\treturn y;\n\t}\n\n\tsize = ICON_SIZE * 1.25;\n\n\tangles[PITCH] = 0;\n\tangles[YAW] = 180;\n\tangles[ROLL] = 0;\n\tCG_DrawHead( 640 - size, y, size, size, clientNum, angles );\n\n\tinfo = CG_ConfigString( CS_PLAYERS + clientNum );\n\tname = Info_ValueForKey(  info, \"n\" );\n\ty += size;\n\tCG_DrawBigString( 640 - ( Q_PrintStrlen( name ) * BIGCHAR_WIDTH), y, name, 0.5 );\n\n\treturn y + BIGCHAR_HEIGHT + 2;\n}\n\n/*\n==================\nCG_DrawSnapshot\n==================\n*/\nstatic float CG_DrawSnapshot( float y ) {\n\tchar\t\t*s;\n\tint\t\t\tw;\n\n\ts = va( \"time:%i snap:%i cmd:%i\", cg.snap->serverTime, \n\t\tcg.latestSnapshotNum, cgs.serverCommandSequence );\n\tw = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;\n\n\tCG_DrawBigString( 635 - w, y + 2, s, 1.0F);\n\n\treturn y + BIGCHAR_HEIGHT + 4;\n}\n\n/*\n==================\nCG_DrawFPS\n==================\n*/\n#define\tFPS_FRAMES\t4\nstatic float CG_DrawFPS( float y ) {\n\tchar\t\t*s;\n\tint\t\t\tw;\n\tstatic int\tpreviousTimes[FPS_FRAMES];\n\tstatic int\tindex;\n\tint\t\ti, total;\n\tint\t\tfps;\n\tstatic\tint\tprevious;\n\tint\t\tt, frameTime;\n\n\t// don't use serverTime, because that will be drifting to\n\t// correct for internet lag changes, timescales, timedemos, etc\n\tt = trap_Milliseconds();\n\tframeTime = t - previous;\n\tprevious = t;\n\n\tpreviousTimes[index % FPS_FRAMES] = frameTime;\n\tindex++;\n\tif ( index > FPS_FRAMES ) {\n\t\t// average multiple frames together to smooth changes out a bit\n\t\ttotal = 0;\n\t\tfor ( i = 0 ; i < FPS_FRAMES ; i++ ) {\n\t\t\ttotal += previousTimes[i];\n\t\t}\n\t\tif ( !total ) {\n\t\t\ttotal = 1;\n\t\t}\n\t\tfps = 1000 * FPS_FRAMES / total;\n\n\t\ts = va( \"%ifps\", fps );\n\t\tw = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;\n\n\t\tCG_DrawBigString( 635 - w, y + 2, s, 1.0F);\n\t}\n\n\treturn y + BIGCHAR_HEIGHT + 4;\n}\n\n/*\n=================\nCG_DrawTimer\n=================\n*/\nstatic float CG_DrawTimer( float y ) {\n\tchar\t\t*s;\n\tint\t\t\tw;\n\tint\t\t\tmins, seconds, tens;\n\tint\t\t\tmsec;\n\n\tmsec = cg.time - cgs.levelStartTime;\n\n\tseconds = msec / 1000;\n\tmins = seconds / 60;\n\tseconds -= mins * 60;\n\ttens = seconds / 10;\n\tseconds -= tens * 10;\n\n\ts = va( \"%i:%i%i\", mins, tens, seconds );\n\tw = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;\n\n\tCG_DrawBigString( 635 - w, y + 2, s, 1.0F);\n\n\treturn y + BIGCHAR_HEIGHT + 4;\n}\n\n\n/*\n=================\nCG_DrawTeamOverlay\n=================\n*/\n\nstatic float CG_DrawTeamOverlay( float y, qboolean right, qboolean upper ) {\n\tint x, w, h, xx;\n\tint i, j, len;\n\tconst char *p;\n\tvec4_t\t\thcolor;\n\tint pwidth, lwidth;\n\tint plyrs;\n\tchar st[16];\n\tclientInfo_t *ci;\n\tgitem_t\t*item;\n\tint ret_y, count;\n\n\tif ( !cg_drawTeamOverlay.integer ) {\n\t\treturn y;\n\t}\n\n\tif ( cg.snap->ps.persistant[PERS_TEAM] != TEAM_RED && cg.snap->ps.persistant[PERS_TEAM] != TEAM_BLUE ) {\n\t\treturn y; // Not on any team\n\t}\n\n\tplyrs = 0;\n\n\t// max player name width\n\tpwidth = 0;\n\tcount = (numSortedTeamPlayers > 8) ? 8 : numSortedTeamPlayers;\n\tfor (i = 0; i < count; i++) {\n\t\tci = cgs.clientinfo + sortedTeamPlayers[i];\n\t\tif ( ci->infoValid && ci->team == cg.snap->ps.persistant[PERS_TEAM]) {\n\t\t\tplyrs++;\n\t\t\tlen = CG_DrawStrlen(ci->name);\n\t\t\tif (len > pwidth)\n\t\t\t\tpwidth = len;\n\t\t}\n\t}\n\n\tif (!plyrs)\n\t\treturn y;\n\n\tif (pwidth > TEAM_OVERLAY_MAXNAME_WIDTH)\n\t\tpwidth = TEAM_OVERLAY_MAXNAME_WIDTH;\n\n\t// max location name width\n\tlwidth = 0;\n\tfor (i = 1; i < MAX_LOCATIONS; i++) {\n\t\tp = CG_ConfigString(CS_LOCATIONS + i);\n\t\tif (p && *p) {\n\t\t\tlen = CG_DrawStrlen(p);\n\t\t\tif (len > lwidth)\n\t\t\t\tlwidth = len;\n\t\t}\n\t}\n\n\tif (lwidth > TEAM_OVERLAY_MAXLOCATION_WIDTH)\n\t\tlwidth = TEAM_OVERLAY_MAXLOCATION_WIDTH;\n\n\tw = (pwidth + lwidth + 4 + 7) * TINYCHAR_WIDTH;\n\n\tif ( right )\n\t\tx = 640 - w;\n\telse\n\t\tx = 0;\n\n\th = plyrs * TINYCHAR_HEIGHT;\n\n\tif ( upper ) {\n\t\tret_y = y + h;\n\t} else {\n\t\ty -= h;\n\t\tret_y = y;\n\t}\n\n\tif ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_RED ) {\n\t\thcolor[0] = 1.0f;\n\t\thcolor[1] = 0.0f;\n\t\thcolor[2] = 0.0f;\n\t\thcolor[3] = 0.33f;\n\t} else { // if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_BLUE )\n\t\thcolor[0] = 0.0f;\n\t\thcolor[1] = 0.0f;\n\t\thcolor[2] = 1.0f;\n\t\thcolor[3] = 0.33f;\n\t}\n\ttrap_R_SetColor( hcolor );\n\tCG_DrawPic( x, y, w, h, cgs.media.teamStatusBar );\n\ttrap_R_SetColor( NULL );\n\n\tfor (i = 0; i < count; i++) {\n\t\tci = cgs.clientinfo + sortedTeamPlayers[i];\n\t\tif ( ci->infoValid && ci->team == cg.snap->ps.persistant[PERS_TEAM]) {\n\n\t\t\thcolor[0] = hcolor[1] = hcolor[2] = hcolor[3] = 1.0;\n\n\t\t\txx = x + TINYCHAR_WIDTH;\n\n\t\t\tCG_DrawStringExt( xx, y,\n\t\t\t\tci->name, hcolor, qfalse, qfalse,\n\t\t\t\tTINYCHAR_WIDTH, TINYCHAR_HEIGHT, TEAM_OVERLAY_MAXNAME_WIDTH);\n\n\t\t\tif (lwidth) {\n\t\t\t\tp = CG_ConfigString(CS_LOCATIONS + ci->location);\n\t\t\t\tif (!p || !*p)\n\t\t\t\t\tp = \"unknown\";\n\t\t\t\tlen = CG_DrawStrlen(p);\n\t\t\t\tif (len > lwidth)\n\t\t\t\t\tlen = lwidth;\n\n//\t\t\t\txx = x + TINYCHAR_WIDTH * 2 + TINYCHAR_WIDTH * pwidth + \n//\t\t\t\t\t((lwidth/2 - len/2) * TINYCHAR_WIDTH);\n\t\t\t\txx = x + TINYCHAR_WIDTH * 2 + TINYCHAR_WIDTH * pwidth;\n\t\t\t\tCG_DrawStringExt( xx, y,\n\t\t\t\t\tp, hcolor, qfalse, qfalse, TINYCHAR_WIDTH, TINYCHAR_HEIGHT,\n\t\t\t\t\tTEAM_OVERLAY_MAXLOCATION_WIDTH);\n\t\t\t}\n\n\t\t\tCG_GetColorForHealth( ci->health, ci->armor, hcolor );\n\n\t\t\tCom_sprintf (st, sizeof(st), \"%3i %3i\", ci->health,\tci->armor);\n\n\t\t\txx = x + TINYCHAR_WIDTH * 3 + \n\t\t\t\tTINYCHAR_WIDTH * pwidth + TINYCHAR_WIDTH * lwidth;\n\n\t\t\tCG_DrawStringExt( xx, y,\n\t\t\t\tst, hcolor, qfalse, qfalse,\n\t\t\t\tTINYCHAR_WIDTH, TINYCHAR_HEIGHT, 0 );\n\n\t\t\t// draw weapon icon\n\t\t\txx += TINYCHAR_WIDTH * 3;\n\n\t\t\tif ( cg_weapons[ci->curWeapon].weaponIcon ) {\n\t\t\t\tCG_DrawPic( xx, y, TINYCHAR_WIDTH, TINYCHAR_HEIGHT, \n\t\t\t\t\tcg_weapons[ci->curWeapon].weaponIcon );\n\t\t\t} else {\n\t\t\t\tCG_DrawPic( xx, y, TINYCHAR_WIDTH, TINYCHAR_HEIGHT, \n\t\t\t\t\tcgs.media.deferShader );\n\t\t\t}\n\n\t\t\t// Draw powerup icons\n\t\t\tif (right) {\n\t\t\t\txx = x;\n\t\t\t} else {\n\t\t\t\txx = x + w - TINYCHAR_WIDTH;\n\t\t\t}\n\t\t\tfor (j = 0; j <= PW_NUM_POWERUPS; j++) {\n\t\t\t\tif (ci->powerups & (1 << j)) {\n\n\t\t\t\t\titem = BG_FindItemForPowerup( j );\n\n\t\t\t\t\tif (item) {\n\t\t\t\t\t\tCG_DrawPic( xx, y, TINYCHAR_WIDTH, TINYCHAR_HEIGHT, \n\t\t\t\t\t\ttrap_R_RegisterShader( item->icon ) );\n\t\t\t\t\t\tif (right) {\n\t\t\t\t\t\t\txx -= TINYCHAR_WIDTH;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\txx += TINYCHAR_WIDTH;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ty += TINYCHAR_HEIGHT;\n\t\t}\n\t}\n\n\treturn ret_y;\n//#endif\n}\n\n\n/*\n=====================\nCG_DrawUpperRight\n\n=====================\n*/\nstatic void CG_DrawUpperRight( void ) {\n\tfloat\ty;\n\n\ty = 0;\n\n\tif ( cgs.gametype >= GT_TEAM && cg_drawTeamOverlay.integer == 1 ) {\n\t\ty = CG_DrawTeamOverlay( y, qtrue, qtrue );\n\t} \n\tif ( cg_drawSnapshot.integer ) {\n\t\ty = CG_DrawSnapshot( y );\n\t}\n\tif ( cg_drawFPS.integer ) {\n\t\ty = CG_DrawFPS( y );\n\t}\n\tif ( cg_drawTimer.integer ) {\n\t\ty = CG_DrawTimer( y );\n\t}\n\tif ( cg_drawAttacker.integer ) {\n\t\ty = CG_DrawAttacker( y );\n\t}\n\n}\n\n/*\n===========================================================================================\n\n  LOWER RIGHT CORNER\n\n===========================================================================================\n*/\n\n/*\n=================\nCG_DrawScores\n\nDraw the small two score display\n=================\n*/\n#ifndef MISSIONPACK\nstatic float CG_DrawScores( float y ) {\n\tconst char\t*s;\n\tint\t\t\ts1, s2, score;\n\tint\t\t\tx, w;\n\tint\t\t\tv;\n\tvec4_t\t\tcolor;\n\tfloat\t\ty1;\n\tgitem_t\t\t*item;\n\n\ts1 = cgs.scores1;\n\ts2 = cgs.scores2;\n\n\ty -=  BIGCHAR_HEIGHT + 8;\n\n\ty1 = y;\n\n\t// draw from the right side to left\n\tif ( cgs.gametype >= GT_TEAM ) {\n\t\tx = 640;\n\t\tcolor[0] = 0.0f;\n\t\tcolor[1] = 0.0f;\n\t\tcolor[2] = 1.0f;\n\t\tcolor[3] = 0.33f;\n\t\ts = va( \"%2i\", s2 );\n\t\tw = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8;\n\t\tx -= w;\n\t\tCG_FillRect( x, y-4,  w, BIGCHAR_HEIGHT+8, color );\n\t\tif ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_BLUE ) {\n\t\t\tCG_DrawPic( x, y-4, w, BIGCHAR_HEIGHT+8, cgs.media.selectShader );\n\t\t}\n\t\tCG_DrawBigString( x + 4, y, s, 1.0F);\n\n\t\tif ( cgs.gametype == GT_CTF ) {\n\t\t\t// Display flag status\n\t\t\titem = BG_FindItemForPowerup( PW_BLUEFLAG );\n\n\t\t\tif (item) {\n\t\t\t\ty1 = y - BIGCHAR_HEIGHT - 8;\n\t\t\t\tif( cgs.blueflag >= 0 && cgs.blueflag <= 2 ) {\n\t\t\t\t\tCG_DrawPic( x, y1-4, w, BIGCHAR_HEIGHT+8, cgs.media.blueFlagShader[cgs.blueflag] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcolor[0] = 1.0f;\n\t\tcolor[1] = 0.0f;\n\t\tcolor[2] = 0.0f;\n\t\tcolor[3] = 0.33f;\n\t\ts = va( \"%2i\", s1 );\n\t\tw = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8;\n\t\tx -= w;\n\t\tCG_FillRect( x, y-4,  w, BIGCHAR_HEIGHT+8, color );\n\t\tif ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_RED ) {\n\t\t\tCG_DrawPic( x, y-4, w, BIGCHAR_HEIGHT+8, cgs.media.selectShader );\n\t\t}\n\t\tCG_DrawBigString( x + 4, y, s, 1.0F);\n\n\t\tif ( cgs.gametype == GT_CTF ) {\n\t\t\t// Display flag status\n\t\t\titem = BG_FindItemForPowerup( PW_REDFLAG );\n\n\t\t\tif (item) {\n\t\t\t\ty1 = y - BIGCHAR_HEIGHT - 8;\n\t\t\t\tif( cgs.redflag >= 0 && cgs.redflag <= 2 ) {\n\t\t\t\t\tCG_DrawPic( x, y1-4, w, BIGCHAR_HEIGHT+8, cgs.media.redFlagShader[cgs.redflag] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n#ifdef MISSIONPACK\n\t\tif ( cgs.gametype == GT_1FCTF ) {\n\t\t\t// Display flag status\n\t\t\titem = BG_FindItemForPowerup( PW_NEUTRALFLAG );\n\n\t\t\tif (item) {\n\t\t\t\ty1 = y - BIGCHAR_HEIGHT - 8;\n\t\t\t\tif( cgs.flagStatus >= 0 && cgs.flagStatus <= 3 ) {\n\t\t\t\t\tCG_DrawPic( x, y1-4, w, BIGCHAR_HEIGHT+8, cgs.media.flagShader[cgs.flagStatus] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n#endif\n\t\tif ( cgs.gametype >= GT_CTF ) {\n\t\t\tv = cgs.capturelimit;\n\t\t} else {\n\t\t\tv = cgs.fraglimit;\n\t\t}\n\t\tif ( v ) {\n\t\t\ts = va( \"%2i\", v );\n\t\t\tw = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8;\n\t\t\tx -= w;\n\t\t\tCG_DrawBigString( x + 4, y, s, 1.0F);\n\t\t}\n\n\t} else {\n\t\tqboolean\tspectator;\n\n\t\tx = 640;\n\t\tscore = cg.snap->ps.persistant[PERS_SCORE];\n\t\tspectator = ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR );\n\n\t\t// always show your score in the second box if not in first place\n\t\tif ( s1 != score ) {\n\t\t\ts2 = score;\n\t\t}\n\t\tif ( s2 != SCORE_NOT_PRESENT ) {\n\t\t\ts = va( \"%2i\", s2 );\n\t\t\tw = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8;\n\t\t\tx -= w;\n\t\t\tif ( !spectator && score == s2 && score != s1 ) {\n\t\t\t\tcolor[0] = 1.0f;\n\t\t\t\tcolor[1] = 0.0f;\n\t\t\t\tcolor[2] = 0.0f;\n\t\t\t\tcolor[3] = 0.33f;\n\t\t\t\tCG_FillRect( x, y-4,  w, BIGCHAR_HEIGHT+8, color );\n\t\t\t\tCG_DrawPic( x, y-4, w, BIGCHAR_HEIGHT+8, cgs.media.selectShader );\n\t\t\t} else {\n\t\t\t\tcolor[0] = 0.5f;\n\t\t\t\tcolor[1] = 0.5f;\n\t\t\t\tcolor[2] = 0.5f;\n\t\t\t\tcolor[3] = 0.33f;\n\t\t\t\tCG_FillRect( x, y-4,  w, BIGCHAR_HEIGHT+8, color );\n\t\t\t}\t\n\t\t\tCG_DrawBigString( x + 4, y, s, 1.0F);\n\t\t}\n\n\t\t// first place\n\t\tif ( s1 != SCORE_NOT_PRESENT ) {\n\t\t\ts = va( \"%2i\", s1 );\n\t\t\tw = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8;\n\t\t\tx -= w;\n\t\t\tif ( !spectator && score == s1 ) {\n\t\t\t\tcolor[0] = 0.0f;\n\t\t\t\tcolor[1] = 0.0f;\n\t\t\t\tcolor[2] = 1.0f;\n\t\t\t\tcolor[3] = 0.33f;\n\t\t\t\tCG_FillRect( x, y-4,  w, BIGCHAR_HEIGHT+8, color );\n\t\t\t\tCG_DrawPic( x, y-4, w, BIGCHAR_HEIGHT+8, cgs.media.selectShader );\n\t\t\t} else {\n\t\t\t\tcolor[0] = 0.5f;\n\t\t\t\tcolor[1] = 0.5f;\n\t\t\t\tcolor[2] = 0.5f;\n\t\t\t\tcolor[3] = 0.33f;\n\t\t\t\tCG_FillRect( x, y-4,  w, BIGCHAR_HEIGHT+8, color );\n\t\t\t}\t\n\t\t\tCG_DrawBigString( x + 4, y, s, 1.0F);\n\t\t}\n\n\t\tif ( cgs.fraglimit ) {\n\t\t\ts = va( \"%2i\", cgs.fraglimit );\n\t\t\tw = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8;\n\t\t\tx -= w;\n\t\t\tCG_DrawBigString( x + 4, y, s, 1.0F);\n\t\t}\n\n\t}\n\n\treturn y1 - 8;\n}\n#endif // MISSIONPACK\n\n/*\n================\nCG_DrawPowerups\n================\n*/\n#ifndef MISSIONPACK\nstatic float CG_DrawPowerups( float y ) {\n\tint\t\tsorted[MAX_POWERUPS];\n\tint\t\tsortedTime[MAX_POWERUPS];\n\tint\t\ti, j, k;\n\tint\t\tactive;\n\tplayerState_t\t*ps;\n\tint\t\tt;\n\tgitem_t\t*item;\n\tint\t\tx;\n\tint\t\tcolor;\n\tfloat\tsize;\n\tfloat\tf;\n\tstatic float colors[2][4] = { \n    { 0.2f, 1.0f, 0.2f, 1.0f } , \n    { 1.0f, 0.2f, 0.2f, 1.0f } \n  };\n\n\tps = &cg.snap->ps;\n\n\tif ( ps->stats[STAT_HEALTH] <= 0 ) {\n\t\treturn y;\n\t}\n\n\t// sort the list by time remaining\n\tactive = 0;\n\tfor ( i = 0 ; i < MAX_POWERUPS ; i++ ) {\n\t\tif ( !ps->powerups[ i ] ) {\n\t\t\tcontinue;\n\t\t}\n\t\tt = ps->powerups[ i ] - cg.time;\n\t\t// ZOID--don't draw if the power up has unlimited time (999 seconds)\n\t\t// This is true of the CTF flags\n\t\tif ( t < 0 || t > 999000) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// insert into the list\n\t\tfor ( j = 0 ; j < active ; j++ ) {\n\t\t\tif ( sortedTime[j] >= t ) {\n\t\t\t\tfor ( k = active - 1 ; k >= j ; k-- ) {\n\t\t\t\t\tsorted[k+1] = sorted[k];\n\t\t\t\t\tsortedTime[k+1] = sortedTime[k];\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tsorted[j] = i;\n\t\tsortedTime[j] = t;\n\t\tactive++;\n\t}\n\n\t// draw the icons and timers\n\tx = 640 - ICON_SIZE - CHAR_WIDTH * 2;\n\tfor ( i = 0 ; i < active ; i++ ) {\n\t\titem = BG_FindItemForPowerup( sorted[i] );\n\n    if (item) {\n\n\t\t  color = 1;\n\n\t\t  y -= ICON_SIZE;\n\n\t\t  trap_R_SetColor( colors[color] );\n\t\t  CG_DrawField( x, y, 2, sortedTime[ i ] / 1000 );\n\n\t\t  t = ps->powerups[ sorted[i] ];\n\t\t  if ( t - cg.time >= POWERUP_BLINKS * POWERUP_BLINK_TIME ) {\n\t\t\t  trap_R_SetColor( NULL );\n\t\t  } else {\n\t\t\t  vec4_t\tmodulate;\n\n\t\t\t  f = (float)( t - cg.time ) / POWERUP_BLINK_TIME;\n\t\t\t  f -= (int)f;\n\t\t\t  modulate[0] = modulate[1] = modulate[2] = modulate[3] = f;\n\t\t\t  trap_R_SetColor( modulate );\n\t\t  }\n\n\t\t  if ( cg.powerupActive == sorted[i] && \n\t\t\t  cg.time - cg.powerupTime < PULSE_TIME ) {\n\t\t\t  f = 1.0 - ( ( (float)cg.time - cg.powerupTime ) / PULSE_TIME );\n\t\t\t  size = ICON_SIZE * ( 1.0 + ( PULSE_SCALE - 1.0 ) * f );\n\t\t  } else {\n\t\t\t  size = ICON_SIZE;\n\t\t  }\n\n\t\t  CG_DrawPic( 640 - size, y + ICON_SIZE / 2 - size / 2, \n\t\t\t  size, size, trap_R_RegisterShader( item->icon ) );\n    }\n\t}\n\ttrap_R_SetColor( NULL );\n\n\treturn y;\n}\n#endif // MISSIONPACK\n\n/*\n=====================\nCG_DrawLowerRight\n\n=====================\n*/\n#ifndef MISSIONPACK\nstatic void CG_DrawLowerRight( void ) {\n\tfloat\ty;\n\n\ty = 480 - ICON_SIZE;\n\n\tif ( cgs.gametype >= GT_TEAM && cg_drawTeamOverlay.integer == 2 ) {\n\t\ty = CG_DrawTeamOverlay( y, qtrue, qfalse );\n\t} \n\n\ty = CG_DrawScores( y );\n\ty = CG_DrawPowerups( y );\n}\n#endif // MISSIONPACK\n\n/*\n===================\nCG_DrawPickupItem\n===================\n*/\n#ifndef MISSIONPACK\nstatic int CG_DrawPickupItem( int y ) {\n\tint\t\tvalue;\n\tfloat\t*fadeColor;\n\n\tif ( cg.snap->ps.stats[STAT_HEALTH] <= 0 ) {\n\t\treturn y;\n\t}\n\n\ty -= ICON_SIZE;\n\n\tvalue = cg.itemPickup;\n\tif ( value ) {\n\t\tfadeColor = CG_FadeColor( cg.itemPickupTime, 3000 );\n\t\tif ( fadeColor ) {\n\t\t\tCG_RegisterItemVisuals( value );\n\t\t\ttrap_R_SetColor( fadeColor );\n\t\t\tCG_DrawPic( 8, y, ICON_SIZE, ICON_SIZE, cg_items[ value ].icon );\n\t\t\tCG_DrawBigString( ICON_SIZE + 16, y + (ICON_SIZE/2 - BIGCHAR_HEIGHT/2), bg_itemlist[ value ].pickup_name, fadeColor[0] );\n\t\t\ttrap_R_SetColor( NULL );\n\t\t}\n\t}\n\t\n\treturn y;\n}\n#endif // MISSIONPACK\n\n/*\n=====================\nCG_DrawLowerLeft\n\n=====================\n*/\n#ifndef MISSIONPACK\nstatic void CG_DrawLowerLeft( void ) {\n\tfloat\ty;\n\n\ty = 480 - ICON_SIZE;\n\n\tif ( cgs.gametype >= GT_TEAM && cg_drawTeamOverlay.integer == 3 ) {\n\t\ty = CG_DrawTeamOverlay( y, qfalse, qfalse );\n\t} \n\n\n\ty = CG_DrawPickupItem( y );\n}\n#endif // MISSIONPACK\n\n\n//===========================================================================================\n\n/*\n=================\nCG_DrawTeamInfo\n=================\n*/\n#ifndef MISSIONPACK\nstatic void CG_DrawTeamInfo( void ) {\n\tint w, h;\n\tint i, len;\n\tvec4_t\t\thcolor;\n\tint\t\tchatHeight;\n\n#define CHATLOC_Y 420 // bottom end\n#define CHATLOC_X 0\n\n\tif (cg_teamChatHeight.integer < TEAMCHAT_HEIGHT)\n\t\tchatHeight = cg_teamChatHeight.integer;\n\telse\n\t\tchatHeight = TEAMCHAT_HEIGHT;\n\tif (chatHeight <= 0)\n\t\treturn; // disabled\n\n\tif (cgs.teamLastChatPos != cgs.teamChatPos) {\n\t\tif (cg.time - cgs.teamChatMsgTimes[cgs.teamLastChatPos % chatHeight] > cg_teamChatTime.integer) {\n\t\t\tcgs.teamLastChatPos++;\n\t\t}\n\n\t\th = (cgs.teamChatPos - cgs.teamLastChatPos) * TINYCHAR_HEIGHT;\n\n\t\tw = 0;\n\n\t\tfor (i = cgs.teamLastChatPos; i < cgs.teamChatPos; i++) {\n\t\t\tlen = CG_DrawStrlen(cgs.teamChatMsgs[i % chatHeight]);\n\t\t\tif (len > w)\n\t\t\t\tw = len;\n\t\t}\n\t\tw *= TINYCHAR_WIDTH;\n\t\tw += TINYCHAR_WIDTH * 2;\n\n\t\tif ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_RED ) {\n\t\t\thcolor[0] = 1.0f;\n\t\t\thcolor[1] = 0.0f;\n\t\t\thcolor[2] = 0.0f;\n\t\t\thcolor[3] = 0.33f;\n\t\t} else if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_BLUE ) {\n\t\t\thcolor[0] = 0.0f;\n\t\t\thcolor[1] = 0.0f;\n\t\t\thcolor[2] = 1.0f;\n\t\t\thcolor[3] = 0.33f;\n\t\t} else {\n\t\t\thcolor[0] = 0.0f;\n\t\t\thcolor[1] = 1.0f;\n\t\t\thcolor[2] = 0.0f;\n\t\t\thcolor[3] = 0.33f;\n\t\t}\n\n\t\ttrap_R_SetColor( hcolor );\n\t\tCG_DrawPic( CHATLOC_X, CHATLOC_Y - h, 640, h, cgs.media.teamStatusBar );\n\t\ttrap_R_SetColor( NULL );\n\n\t\thcolor[0] = hcolor[1] = hcolor[2] = 1.0f;\n\t\thcolor[3] = 1.0f;\n\n\t\tfor (i = cgs.teamChatPos - 1; i >= cgs.teamLastChatPos; i--) {\n\t\t\tCG_DrawStringExt( CHATLOC_X + TINYCHAR_WIDTH, \n\t\t\t\tCHATLOC_Y - (cgs.teamChatPos - i)*TINYCHAR_HEIGHT, \n\t\t\t\tcgs.teamChatMsgs[i % chatHeight], hcolor, qfalse, qfalse,\n\t\t\t\tTINYCHAR_WIDTH, TINYCHAR_HEIGHT, 0 );\n\t\t}\n\t}\n}\n#endif // MISSIONPACK\n\n/*\n===================\nCG_DrawHoldableItem\n===================\n*/\n#ifndef MISSIONPACK\nstatic void CG_DrawHoldableItem( void ) { \n\tint\t\tvalue;\n\n\tvalue = cg.snap->ps.stats[STAT_HOLDABLE_ITEM];\n\tif ( value ) {\n\t\tCG_RegisterItemVisuals( value );\n\t\tCG_DrawPic( 640-ICON_SIZE, (SCREEN_HEIGHT-ICON_SIZE)/2, ICON_SIZE, ICON_SIZE, cg_items[ value ].icon );\n\t}\n\n}\n#endif // MISSIONPACK\n\n#ifdef MISSIONPACK\n/*\n===================\nCG_DrawPersistantPowerup\n===================\n*/\n#if 0 // sos001208 - DEAD\nstatic void CG_DrawPersistantPowerup( void ) { \n\tint\t\tvalue;\n\n\tvalue = cg.snap->ps.stats[STAT_PERSISTANT_POWERUP];\n\tif ( value ) {\n\t\tCG_RegisterItemVisuals( value );\n\t\tCG_DrawPic( 640-ICON_SIZE, (SCREEN_HEIGHT-ICON_SIZE)/2 - ICON_SIZE, ICON_SIZE, ICON_SIZE, cg_items[ value ].icon );\n\t}\n}\n#endif\n#endif // MISSIONPACK\n\n\n/*\n===================\nCG_DrawReward\n===================\n*/\nstatic void CG_DrawReward( void ) { \n\tfloat\t*color;\n\tint\t\ti, count;\n\tfloat\tx, y;\n\tchar\tbuf[32];\n\n\tif ( !cg_drawRewards.integer ) {\n\t\treturn;\n\t}\n\n\tcolor = CG_FadeColor( cg.rewardTime, REWARD_TIME );\n\tif ( !color ) {\n\t\tif (cg.rewardStack > 0) {\n\t\t\tfor(i = 0; i < cg.rewardStack; i++) {\n\t\t\t\tcg.rewardSound[i] = cg.rewardSound[i+1];\n\t\t\t\tcg.rewardShader[i] = cg.rewardShader[i+1];\n\t\t\t\tcg.rewardCount[i] = cg.rewardCount[i+1];\n\t\t\t}\n\t\t\tcg.rewardTime = cg.time;\n\t\t\tcg.rewardStack--;\n\t\t\tcolor = CG_FadeColor( cg.rewardTime, REWARD_TIME );\n\t\t\ttrap_S_StartLocalSound(cg.rewardSound[0], CHAN_ANNOUNCER);\n\t\t} else {\n\t\t\treturn;\n\t\t}\n\t}\n\n\ttrap_R_SetColor( color );\n\n\t/*\n\tcount = cg.rewardCount[0]/10;\t\t\t\t// number of big rewards to draw\n\n\tif (count) {\n\t\ty = 4;\n\t\tx = 320 - count * ICON_SIZE;\n\t\tfor ( i = 0 ; i < count ; i++ ) {\n\t\t\tCG_DrawPic( x, y, (ICON_SIZE*2)-4, (ICON_SIZE*2)-4, cg.rewardShader[0] );\n\t\t\tx += (ICON_SIZE*2);\n\t\t}\n\t}\n\n\tcount = cg.rewardCount[0] - count*10;\t\t// number of small rewards to draw\n\t*/\n\n\tif ( cg.rewardCount[0] >= 10 ) {\n\t\ty = 56;\n\t\tx = 320 - ICON_SIZE/2;\n\t\tCG_DrawPic( x, y, ICON_SIZE-4, ICON_SIZE-4, cg.rewardShader[0] );\n\t\tCom_sprintf(buf, sizeof(buf), \"%d\", cg.rewardCount[0]);\n\t\tx = ( SCREEN_WIDTH - SMALLCHAR_WIDTH * CG_DrawStrlen( buf ) ) / 2;\n\t\tCG_DrawStringExt( x, y+ICON_SIZE, buf, color, qfalse, qtrue,\n\t\t\t\t\t\t\t\tSMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 0 );\n\t}\n\telse {\n\n\t\tcount = cg.rewardCount[0];\n\n\t\ty = 56;\n\t\tx = 320 - count * ICON_SIZE/2;\n\t\tfor ( i = 0 ; i < count ; i++ ) {\n\t\t\tCG_DrawPic( x, y, ICON_SIZE-4, ICON_SIZE-4, cg.rewardShader[0] );\n\t\t\tx += ICON_SIZE;\n\t\t}\n\t}\n\ttrap_R_SetColor( NULL );\n}\n\n\n/*\n===============================================================================\n\nLAGOMETER\n\n===============================================================================\n*/\n\n#define\tLAG_SAMPLES\t\t128\n\n\ntypedef struct {\n\tint\t\tframeSamples[LAG_SAMPLES];\n\tint\t\tframeCount;\n\tint\t\tsnapshotFlags[LAG_SAMPLES];\n\tint\t\tsnapshotSamples[LAG_SAMPLES];\n\tint\t\tsnapshotCount;\n} lagometer_t;\n\nlagometer_t\t\tlagometer;\n\n/*\n==============\nCG_AddLagometerFrameInfo\n\nAdds the current interpolate / extrapolate bar for this frame\n==============\n*/\nvoid CG_AddLagometerFrameInfo( void ) {\n\tint\t\t\toffset;\n\n\toffset = cg.time - cg.latestSnapshotTime;\n\tlagometer.frameSamples[ lagometer.frameCount & ( LAG_SAMPLES - 1) ] = offset;\n\tlagometer.frameCount++;\n}\n\n/*\n==============\nCG_AddLagometerSnapshotInfo\n\nEach time a snapshot is received, log its ping time and\nthe number of snapshots that were dropped before it.\n\nPass NULL for a dropped packet.\n==============\n*/\nvoid CG_AddLagometerSnapshotInfo( snapshot_t *snap ) {\n\t// dropped packet\n\tif ( !snap ) {\n\t\tlagometer.snapshotSamples[ lagometer.snapshotCount & ( LAG_SAMPLES - 1) ] = -1;\n\t\tlagometer.snapshotCount++;\n\t\treturn;\n\t}\n\n\t// add this snapshot's info\n\tlagometer.snapshotSamples[ lagometer.snapshotCount & ( LAG_SAMPLES - 1) ] = snap->ping;\n\tlagometer.snapshotFlags[ lagometer.snapshotCount & ( LAG_SAMPLES - 1) ] = snap->snapFlags;\n\tlagometer.snapshotCount++;\n}\n\n/*\n==============\nCG_DrawDisconnect\n\nShould we draw something differnet for long lag vs no packets?\n==============\n*/\nstatic void CG_DrawDisconnect( void ) {\n\tfloat\t\tx, y;\n\tint\t\t\tcmdNum;\n\tusercmd_t\tcmd;\n\tconst char\t\t*s;\n\tint\t\t\tw;  // bk010215 - FIXME char message[1024];\n\n\t// draw the phone jack if we are completely past our buffers\n\tcmdNum = trap_GetCurrentCmdNumber() - CMD_BACKUP + 1;\n\ttrap_GetUserCmd( cmdNum, &cmd );\n\tif ( cmd.serverTime <= cg.snap->ps.commandTime\n\t\t|| cmd.serverTime > cg.time ) {\t// special check for map_restart // bk 0102165 - FIXME\n\t\treturn;\n\t}\n\n\t// also add text in center of screen\n\ts = \"Connection Interrupted\"; // bk 010215 - FIXME\n\tw = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;\n\tCG_DrawBigString( 320 - w/2, 100, s, 1.0F);\n\n\t// blink the icon\n\tif ( ( cg.time >> 9 ) & 1 ) {\n\t\treturn;\n\t}\n\n\tx = 640 - 48;\n\ty = 480 - 48;\n\n\tCG_DrawPic( x, y, 48, 48, trap_R_RegisterShader(\"gfx/2d/net.tga\" ) );\n}\n\n\n#define\tMAX_LAGOMETER_PING\t900\n#define\tMAX_LAGOMETER_RANGE\t300\n\n/*\n==============\nCG_DrawLagometer\n==============\n*/\nstatic void CG_DrawLagometer( void ) {\n\tint\t\ta, x, y, i;\n\tfloat\tv;\n\tfloat\tax, ay, aw, ah, mid, range;\n\tint\t\tcolor;\n\tfloat\tvscale;\n\n\tif ( !cg_lagometer.integer || cgs.localServer ) {\n\t\tCG_DrawDisconnect();\n\t\treturn;\n\t}\n\n\t//\n\t// draw the graph\n\t//\n#ifdef MISSIONPACK\n\tx = 640 - 48;\n\ty = 480 - 144;\n#else\n\tx = 640 - 48;\n\ty = 480 - 48;\n#endif\n\n\ttrap_R_SetColor( NULL );\n\tCG_DrawPic( x, y, 48, 48, cgs.media.lagometerShader );\n\n\tax = x;\n\tay = y;\n\taw = 48;\n\tah = 48;\n\tCG_AdjustFrom640( &ax, &ay, &aw, &ah );\n\n\tcolor = -1;\n\trange = ah / 3;\n\tmid = ay + range;\n\n\tvscale = range / MAX_LAGOMETER_RANGE;\n\n\t// draw the frame interpoalte / extrapolate graph\n\tfor ( a = 0 ; a < aw ; a++ ) {\n\t\ti = ( lagometer.frameCount - 1 - a ) & (LAG_SAMPLES - 1);\n\t\tv = lagometer.frameSamples[i];\n\t\tv *= vscale;\n\t\tif ( v > 0 ) {\n\t\t\tif ( color != 1 ) {\n\t\t\t\tcolor = 1;\n\t\t\t\ttrap_R_SetColor( g_color_table[ColorIndex(COLOR_YELLOW)] );\n\t\t\t}\n\t\t\tif ( v > range ) {\n\t\t\t\tv = range;\n\t\t\t}\n\t\t\ttrap_R_DrawStretchPic ( ax + aw - a, mid - v, 1, v, 0, 0, 0, 0, cgs.media.whiteShader );\n\t\t} else if ( v < 0 ) {\n\t\t\tif ( color != 2 ) {\n\t\t\t\tcolor = 2;\n\t\t\t\ttrap_R_SetColor( g_color_table[ColorIndex(COLOR_BLUE)] );\n\t\t\t}\n\t\t\tv = -v;\n\t\t\tif ( v > range ) {\n\t\t\t\tv = range;\n\t\t\t}\n\t\t\ttrap_R_DrawStretchPic( ax + aw - a, mid, 1, v, 0, 0, 0, 0, cgs.media.whiteShader );\n\t\t}\n\t}\n\n\t// draw the snapshot latency / drop graph\n\trange = ah / 2;\n\tvscale = range / MAX_LAGOMETER_PING;\n\n\tfor ( a = 0 ; a < aw ; a++ ) {\n\t\ti = ( lagometer.snapshotCount - 1 - a ) & (LAG_SAMPLES - 1);\n\t\tv = lagometer.snapshotSamples[i];\n\t\tif ( v > 0 ) {\n\t\t\tif ( lagometer.snapshotFlags[i] & SNAPFLAG_RATE_DELAYED ) {\n\t\t\t\tif ( color != 5 ) {\n\t\t\t\t\tcolor = 5;\t// YELLOW for rate delay\n\t\t\t\t\ttrap_R_SetColor( g_color_table[ColorIndex(COLOR_YELLOW)] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( color != 3 ) {\n\t\t\t\t\tcolor = 3;\n\t\t\t\t\ttrap_R_SetColor( g_color_table[ColorIndex(COLOR_GREEN)] );\n\t\t\t\t}\n\t\t\t}\n\t\t\tv = v * vscale;\n\t\t\tif ( v > range ) {\n\t\t\t\tv = range;\n\t\t\t}\n\t\t\ttrap_R_DrawStretchPic( ax + aw - a, ay + ah - v, 1, v, 0, 0, 0, 0, cgs.media.whiteShader );\n\t\t} else if ( v < 0 ) {\n\t\t\tif ( color != 4 ) {\n\t\t\t\tcolor = 4;\t\t// RED for dropped snapshots\n\t\t\t\ttrap_R_SetColor( g_color_table[ColorIndex(COLOR_RED)] );\n\t\t\t}\n\t\t\ttrap_R_DrawStretchPic( ax + aw - a, ay + ah - range, 1, range, 0, 0, 0, 0, cgs.media.whiteShader );\n\t\t}\n\t}\n\n\ttrap_R_SetColor( NULL );\n\n\tif ( cg_nopredict.integer || cg_synchronousClients.integer ) {\n\t\tCG_DrawBigString( ax, ay, \"snc\", 1.0 );\n\t}\n\n\tCG_DrawDisconnect();\n}\n\n\n\n/*\n===============================================================================\n\nCENTER PRINTING\n\n===============================================================================\n*/\n\n\n/*\n==============\nCG_CenterPrint\n\nCalled for important messages that should stay in the center of the screen\nfor a few moments\n==============\n*/\nvoid CG_CenterPrint( const char *str, int y, int charWidth ) {\n\tchar\t*s;\n\n\tQ_strncpyz( cg.centerPrint, str, sizeof(cg.centerPrint) );\n\n\tcg.centerPrintTime = cg.time;\n\tcg.centerPrintY = y;\n\tcg.centerPrintCharWidth = charWidth;\n\n\t// count the number of lines for centering\n\tcg.centerPrintLines = 1;\n\ts = cg.centerPrint;\n\twhile( *s ) {\n\t\tif (*s == '\\n')\n\t\t\tcg.centerPrintLines++;\n\t\ts++;\n\t}\n}\n\n\n/*\n===================\nCG_DrawCenterString\n===================\n*/\nstatic void CG_DrawCenterString( void ) {\n\tchar\t*start;\n\tint\t\tl;\n\tint\t\tx, y, w;\n#ifdef MISSIONPACK // bk010221 - unused else\n  int h;\n#endif\n\tfloat\t*color;\n\n\tif ( !cg.centerPrintTime ) {\n\t\treturn;\n\t}\n\n\tcolor = CG_FadeColor( cg.centerPrintTime, 1000 * cg_centertime.value );\n\tif ( !color ) {\n\t\treturn;\n\t}\n\n\ttrap_R_SetColor( color );\n\n\tstart = cg.centerPrint;\n\n\ty = cg.centerPrintY - cg.centerPrintLines * BIGCHAR_HEIGHT / 2;\n\n\twhile ( 1 ) {\n\t\tchar linebuffer[1024];\n\n\t\tfor ( l = 0; l < 50; l++ ) {\n\t\t\tif ( !start[l] || start[l] == '\\n' ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tlinebuffer[l] = start[l];\n\t\t}\n\t\tlinebuffer[l] = 0;\n\n#ifdef MISSIONPACK\n\t\tw = CG_Text_Width(linebuffer, 0.5, 0);\n\t\th = CG_Text_Height(linebuffer, 0.5, 0);\n\t\tx = (SCREEN_WIDTH - w) / 2;\n\t\tCG_Text_Paint(x, y + h, 0.5, color, linebuffer, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE);\n\t\ty += h + 6;\n#else\n\t\tw = cg.centerPrintCharWidth * CG_DrawStrlen( linebuffer );\n\n\t\tx = ( SCREEN_WIDTH - w ) / 2;\n\n\t\tCG_DrawStringExt( x, y, linebuffer, color, qfalse, qtrue,\n\t\t\tcg.centerPrintCharWidth, (int)(cg.centerPrintCharWidth * 1.5), 0 );\n\n\t\ty += cg.centerPrintCharWidth * 1.5;\n#endif\n\t\twhile ( *start && ( *start != '\\n' ) ) {\n\t\t\tstart++;\n\t\t}\n\t\tif ( !*start ) {\n\t\t\tbreak;\n\t\t}\n\t\tstart++;\n\t}\n\n\ttrap_R_SetColor( NULL );\n}\n\n\n\n/*\n================================================================================\n\nCROSSHAIR\n\n================================================================================\n*/\n\n\n/*\n=================\nCG_DrawCrosshair\n=================\n*/\nstatic void CG_DrawCrosshair(void) {\n\tfloat\t\tw, h;\n\tqhandle_t\thShader;\n\tfloat\t\tf;\n\tfloat\t\tx, y;\n\tint\t\t\tca;\n\n\tif ( !cg_drawCrosshair.integer ) {\n\t\treturn;\n\t}\n\n\tif ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR) {\n\t\treturn;\n\t}\n\n\tif ( cg.renderingThirdPerson ) {\n\t\treturn;\n\t}\n\n\t// set color based on health\n\tif ( cg_crosshairHealth.integer ) {\n\t\tvec4_t\t\thcolor;\n\n\t\tCG_ColorForHealth( hcolor );\n\t\ttrap_R_SetColor( hcolor );\n\t} else {\n\t\ttrap_R_SetColor( NULL );\n\t}\n\n\tw = h = cg_crosshairSize.value;\n\n\t// pulse the size of the crosshair when picking up items\n\tf = cg.time - cg.itemPickupBlendTime;\n\tif ( f > 0 && f < ITEM_BLOB_TIME ) {\n\t\tf /= ITEM_BLOB_TIME;\n\t\tw *= ( 1 + f );\n\t\th *= ( 1 + f );\n\t}\n\n\tx = cg_crosshairX.integer;\n\ty = cg_crosshairY.integer;\n\tCG_AdjustFrom640( &x, &y, &w, &h );\n\n\tca = cg_drawCrosshair.integer;\n\tif (ca < 0) {\n\t\tca = 0;\n\t}\n\thShader = cgs.media.crosshairShader[ ca % NUM_CROSSHAIRS ];\n\n\ttrap_R_DrawStretchPic( x + cg.refdef.x + 0.5 * (cg.refdef.width - w), \n\t\ty + cg.refdef.y + 0.5 * (cg.refdef.height - h), \n\t\tw, h, 0, 0, 1, 1, hShader );\n}\n\n\n\n/*\n=================\nCG_ScanForCrosshairEntity\n=================\n*/\nstatic void CG_ScanForCrosshairEntity( void ) {\n\ttrace_t\t\ttrace;\n\tvec3_t\t\tstart, end;\n\tint\t\t\tcontent;\n\n\tVectorCopy( cg.refdef.vieworg, start );\n\tVectorMA( start, 131072, cg.refdef.viewaxis[0], end );\n\n\tCG_Trace( &trace, start, vec3_origin, vec3_origin, end, \n\t\tcg.snap->ps.clientNum, CONTENTS_SOLID|CONTENTS_BODY );\n\tif ( trace.entityNum >= MAX_CLIENTS ) {\n\t\treturn;\n\t}\n\n\t// if the player is in fog, don't show it\n\tcontent = trap_CM_PointContents( trace.endpos, 0 );\n\tif ( content & CONTENTS_FOG ) {\n\t\treturn;\n\t}\n\n\t// if the player is invisible, don't show it\n\tif ( cg_entities[ trace.entityNum ].currentState.powerups & ( 1 << PW_INVIS ) ) {\n\t\treturn;\n\t}\n\n\t// update the fade timer\n\tcg.crosshairClientNum = trace.entityNum;\n\tcg.crosshairClientTime = cg.time;\n}\n\n\n/*\n=====================\nCG_DrawCrosshairNames\n=====================\n*/\nstatic void CG_DrawCrosshairNames( void ) {\n\tfloat\t\t*color;\n\tchar\t\t*name;\n\tfloat\t\tw;\n\n\tif ( !cg_drawCrosshair.integer ) {\n\t\treturn;\n\t}\n\tif ( !cg_drawCrosshairNames.integer ) {\n\t\treturn;\n\t}\n\tif ( cg.renderingThirdPerson ) {\n\t\treturn;\n\t}\n\n\t// scan the known entities to see if the crosshair is sighted on one\n\tCG_ScanForCrosshairEntity();\n\n\t// draw the name of the player being looked at\n\tcolor = CG_FadeColor( cg.crosshairClientTime, 1000 );\n\tif ( !color ) {\n\t\ttrap_R_SetColor( NULL );\n\t\treturn;\n\t}\n\n\tname = cgs.clientinfo[ cg.crosshairClientNum ].name;\n#ifdef MISSIONPACK\n\tcolor[3] *= 0.5f;\n\tw = CG_Text_Width(name, 0.3f, 0);\n\tCG_Text_Paint( 320 - w / 2, 190, 0.3f, color, name, 0, 0, ITEM_TEXTSTYLE_SHADOWED);\n#else\n\tw = CG_DrawStrlen( name ) * BIGCHAR_WIDTH;\n\tCG_DrawBigString( 320 - w / 2, 170, name, color[3] * 0.5f );\n#endif\n\ttrap_R_SetColor( NULL );\n}\n\n\n//==============================================================================\n\n/*\n=================\nCG_DrawSpectator\n=================\n*/\nstatic void CG_DrawSpectator(void) {\n\tCG_DrawBigString(320 - 9 * 8, 440, \"SPECTATOR\", 1.0F);\n\tif ( cgs.gametype == GT_TOURNAMENT ) {\n\t\tCG_DrawBigString(320 - 15 * 8, 460, \"waiting to play\", 1.0F);\n\t}\n\telse if ( cgs.gametype >= GT_TEAM ) {\n\t\tCG_DrawBigString(320 - 39 * 8, 460, \"press ESC and use the JOIN menu to play\", 1.0F);\n\t}\n}\n\n/*\n=================\nCG_DrawVote\n=================\n*/\nstatic void CG_DrawVote(void) {\n\tchar\t*s;\n\tint\t\tsec;\n\n\tif ( !cgs.voteTime ) {\n\t\treturn;\n\t}\n\n\t// play a talk beep whenever it is modified\n\tif ( cgs.voteModified ) {\n\t\tcgs.voteModified = qfalse;\n\t\ttrap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND );\n\t}\n\n\tsec = ( VOTE_TIME - ( cg.time - cgs.voteTime ) ) / 1000;\n\tif ( sec < 0 ) {\n\t\tsec = 0;\n\t}\n#ifdef MISSIONPACK\n\ts = va(\"VOTE(%i):%s yes:%i no:%i\", sec, cgs.voteString, cgs.voteYes, cgs.voteNo);\n\tCG_DrawSmallString( 0, 58, s, 1.0F );\n\ts = \"or press ESC then click Vote\";\n\tCG_DrawSmallString( 0, 58 + SMALLCHAR_HEIGHT + 2, s, 1.0F );\n#else\n\ts = va(\"VOTE(%i):%s yes:%i no:%i\", sec, cgs.voteString, cgs.voteYes, cgs.voteNo );\n\tCG_DrawSmallString( 0, 58, s, 1.0F );\n#endif\n}\n\n/*\n=================\nCG_DrawTeamVote\n=================\n*/\nstatic void CG_DrawTeamVote(void) {\n\tchar\t*s;\n\tint\t\tsec, cs_offset;\n\n\tif ( cgs.clientinfo->team == TEAM_RED )\n\t\tcs_offset = 0;\n\telse if ( cgs.clientinfo->team == TEAM_BLUE )\n\t\tcs_offset = 1;\n\telse\n\t\treturn;\n\n\tif ( !cgs.teamVoteTime[cs_offset] ) {\n\t\treturn;\n\t}\n\n\t// play a talk beep whenever it is modified\n\tif ( cgs.teamVoteModified[cs_offset] ) {\n\t\tcgs.teamVoteModified[cs_offset] = qfalse;\n\t\ttrap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND );\n\t}\n\n\tsec = ( VOTE_TIME - ( cg.time - cgs.teamVoteTime[cs_offset] ) ) / 1000;\n\tif ( sec < 0 ) {\n\t\tsec = 0;\n\t}\n\ts = va(\"TEAMVOTE(%i):%s yes:%i no:%i\", sec, cgs.teamVoteString[cs_offset],\n\t\t\t\t\t\t\tcgs.teamVoteYes[cs_offset], cgs.teamVoteNo[cs_offset] );\n\tCG_DrawSmallString( 0, 90, s, 1.0F );\n}\n\n\nstatic qboolean CG_DrawScoreboard() {\n#ifdef MISSIONPACK\n\tstatic qboolean firstTime = qtrue;\n\tfloat fade, *fadeColor;\n\n\tif (menuScoreboard) {\n\t\tmenuScoreboard->window.flags &= ~WINDOW_FORCED;\n\t}\n\tif (cg_paused.integer) {\n\t\tcg.deferredPlayerLoading = 0;\n\t\tfirstTime = qtrue;\n\t\treturn qfalse;\n\t}\n\n\t// should never happen in Team Arena\n\tif (cgs.gametype == GT_SINGLE_PLAYER && cg.predictedPlayerState.pm_type == PM_INTERMISSION ) {\n\t\tcg.deferredPlayerLoading = 0;\n\t\tfirstTime = qtrue;\n\t\treturn qfalse;\n\t}\n\n\t// don't draw scoreboard during death while warmup up\n\tif ( cg.warmup && !cg.showScores ) {\n\t\treturn qfalse;\n\t}\n\n\tif ( cg.showScores || cg.predictedPlayerState.pm_type == PM_DEAD || cg.predictedPlayerState.pm_type == PM_INTERMISSION ) {\n\t\tfade = 1.0;\n\t\tfadeColor = colorWhite;\n\t} else {\n\t\tfadeColor = CG_FadeColor( cg.scoreFadeTime, FADE_TIME );\n\t\tif ( !fadeColor ) {\n\t\t\t// next time scoreboard comes up, don't print killer\n\t\t\tcg.deferredPlayerLoading = 0;\n\t\t\tcg.killerName[0] = 0;\n\t\t\tfirstTime = qtrue;\n\t\t\treturn qfalse;\n\t\t}\n\t\tfade = *fadeColor;\n\t}\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  \n\n\n\tif (menuScoreboard == NULL) {\n\t\tif ( cgs.gametype >= GT_TEAM ) {\n\t\t\tmenuScoreboard = Menus_FindByName(\"teamscore_menu\");\n\t\t} else {\n\t\t\tmenuScoreboard = Menus_FindByName(\"score_menu\");\n\t\t}\n\t}\n\n\tif (menuScoreboard) {\n\t\tif (firstTime) {\n\t\t\tCG_SetScoreSelection(menuScoreboard);\n\t\t\tfirstTime = qfalse;\n\t\t}\n\t\tMenu_Paint(menuScoreboard, qtrue);\n\t}\n\n\t// load any models that have been deferred\n\tif ( ++cg.deferredPlayerLoading > 10 ) {\n\t\tCG_LoadDeferredPlayers();\n\t}\n\n\treturn qtrue;\n#else\n\treturn CG_DrawOldScoreboard();\n#endif\n}\n\n/*\n=================\nCG_DrawIntermission\n=================\n*/\nstatic void CG_DrawIntermission( void ) {\n//\tint key;\n#ifdef MISSIONPACK\n\t//if (cg_singlePlayer.integer) {\n\t//\tCG_DrawCenterString();\n\t//\treturn;\n\t//}\n#else\n\tif ( cgs.gametype == GT_SINGLE_PLAYER ) {\n\t\tCG_DrawCenterString();\n\t\treturn;\n\t}\n#endif\n\tcg.scoreFadeTime = cg.time;\n\tcg.scoreBoardShowing = CG_DrawScoreboard();\n}\n\n/*\n=================\nCG_DrawFollow\n=================\n*/\nstatic qboolean CG_DrawFollow( void ) {\n\tfloat\t\tx;\n\tvec4_t\t\tcolor;\n\tconst char\t*name;\n\n\tif ( !(cg.snap->ps.pm_flags & PMF_FOLLOW) ) {\n\t\treturn qfalse;\n\t}\n\tcolor[0] = 1;\n\tcolor[1] = 1;\n\tcolor[2] = 1;\n\tcolor[3] = 1;\n\n\n\tCG_DrawBigString( 320 - 9 * 8, 24, \"following\", 1.0F );\n\n\tname = cgs.clientinfo[ cg.snap->ps.clientNum ].name;\n\n\tx = 0.5 * ( 640 - GIANT_WIDTH * CG_DrawStrlen( name ) );\n\n\tCG_DrawStringExt( x, 40, name, color, qtrue, qtrue, GIANT_WIDTH, GIANT_HEIGHT, 0 );\n\n\treturn qtrue;\n}\n\n\n\n/*\n=================\nCG_DrawAmmoWarning\n=================\n*/\nstatic void CG_DrawAmmoWarning( void ) {\n\tconst char\t*s;\n\tint\t\t\tw;\n\n\tif ( cg_drawAmmoWarning.integer == 0 ) {\n\t\treturn;\n\t}\n\n\tif ( !cg.lowAmmoWarning ) {\n\t\treturn;\n\t}\n\n\tif ( cg.lowAmmoWarning == 2 ) {\n\t\ts = \"OUT OF AMMO\";\n\t} else {\n\t\ts = \"LOW AMMO WARNING\";\n\t}\n\tw = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;\n\tCG_DrawBigString(320 - w / 2, 64, s, 1.0F);\n}\n\n\n#ifdef MISSIONPACK\n/*\n=================\nCG_DrawProxWarning\n=================\n*/\nstatic void CG_DrawProxWarning( void ) {\n\tchar s [32];\n\tint\t\t\tw;\n  static int proxTime;\n  static int proxCounter;\n  static int proxTick;\n\n\tif( !(cg.snap->ps.eFlags & EF_TICKING ) ) {\n    proxTime = 0;\n\t\treturn;\n\t}\n\n  if (proxTime == 0) {\n    proxTime = cg.time + 5000;\n    proxCounter = 5;\n    proxTick = 0;\n  }\n\n  if (cg.time > proxTime) {\n    proxTick = proxCounter--;\n    proxTime = cg.time + 1000;\n  }\n\n  if (proxTick != 0) {\n    Com_sprintf(s, sizeof(s), \"INTERNAL COMBUSTION IN: %i\", proxTick);\n  } else {\n    Com_sprintf(s, sizeof(s), \"YOU HAVE BEEN MINED\");\n  }\n\n\tw = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;\n\tCG_DrawBigStringColor( 320 - w / 2, 64 + BIGCHAR_HEIGHT, s, g_color_table[ColorIndex(COLOR_RED)] );\n}\n#endif\n\n\n/*\n=================\nCG_DrawWarmup\n=================\n*/\nstatic void CG_DrawWarmup( void ) {\n\tint\t\t\tw;\n\tint\t\t\tsec;\n\tint\t\t\ti;\n\tfloat scale;\n\tclientInfo_t\t*ci1, *ci2;\n\tint\t\t\tcw;\n\tconst char\t*s;\n\n\tsec = cg.warmup;\n\tif ( !sec ) {\n\t\treturn;\n\t}\n\n\tif ( sec < 0 ) {\n\t\ts = \"Waiting for players\";\t\t\n\t\tw = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;\n\t\tCG_DrawBigString(320 - w / 2, 24, s, 1.0F);\n\t\tcg.warmupCount = 0;\n\t\treturn;\n\t}\n\n\tif (cgs.gametype == GT_TOURNAMENT) {\n\t\t// find the two active players\n\t\tci1 = NULL;\n\t\tci2 = NULL;\n\t\tfor ( i = 0 ; i < cgs.maxclients ; i++ ) {\n\t\t\tif ( cgs.clientinfo[i].infoValid && cgs.clientinfo[i].team == TEAM_FREE ) {\n\t\t\t\tif ( !ci1 ) {\n\t\t\t\t\tci1 = &cgs.clientinfo[i];\n\t\t\t\t} else {\n\t\t\t\t\tci2 = &cgs.clientinfo[i];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( ci1 && ci2 ) {\n\t\t\ts = va( \"%s vs %s\", ci1->name, ci2->name );\n#ifdef MISSIONPACK\n\t\t\tw = CG_Text_Width(s, 0.6f, 0);\n\t\t\tCG_Text_Paint(320 - w / 2, 60, 0.6f, colorWhite, s, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE);\n#else\n\t\t\tw = CG_DrawStrlen( s );\n\t\t\tif ( w > 640 / GIANT_WIDTH ) {\n\t\t\t\tcw = 640 / w;\n\t\t\t} else {\n\t\t\t\tcw = GIANT_WIDTH;\n\t\t\t}\n\t\t\tCG_DrawStringExt( 320 - w * cw/2, 20,s, colorWhite, \n\t\t\t\t\tqfalse, qtrue, cw, (int)(cw * 1.5f), 0 );\n#endif\n\t\t}\n\t} else {\n\t\tif ( cgs.gametype == GT_FFA ) {\n\t\t\ts = \"Free For All\";\n\t\t} else if ( cgs.gametype == GT_TEAM ) {\n\t\t\ts = \"Team Deathmatch\";\n\t\t} else if ( cgs.gametype == GT_CTF ) {\n\t\t\ts = \"Capture the Flag\";\n#ifdef MISSIONPACK\n\t\t} else if ( cgs.gametype == GT_1FCTF ) {\n\t\t\ts = \"One Flag CTF\";\n\t\t} else if ( cgs.gametype == GT_OBELISK ) {\n\t\t\ts = \"Overload\";\n\t\t} else if ( cgs.gametype == GT_HARVESTER ) {\n\t\t\ts = \"Harvester\";\n#endif\n\t\t} else {\n\t\t\ts = \"\";\n\t\t}\n#ifdef MISSIONPACK\n\t\tw = CG_Text_Width(s, 0.6f, 0);\n\t\tCG_Text_Paint(320 - w / 2, 90, 0.6f, colorWhite, s, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE);\n#else\n\t\tw = CG_DrawStrlen( s );\n\t\tif ( w > 640 / GIANT_WIDTH ) {\n\t\t\tcw = 640 / w;\n\t\t} else {\n\t\t\tcw = GIANT_WIDTH;\n\t\t}\n\t\tCG_DrawStringExt( 320 - w * cw/2, 25,s, colorWhite, \n\t\t\t\tqfalse, qtrue, cw, (int)(cw * 1.1f), 0 );\n#endif\n\t}\n\n\tsec = ( sec - cg.time ) / 1000;\n\tif ( sec < 0 ) {\n\t\tcg.warmup = 0;\n\t\tsec = 0;\n\t}\n\ts = va( \"Starts in: %i\", sec + 1 );\n\tif ( sec != cg.warmupCount ) {\n\t\tcg.warmupCount = sec;\n\t\tswitch ( sec ) {\n\t\tcase 0:\n\t\t\ttrap_S_StartLocalSound( cgs.media.count1Sound, CHAN_ANNOUNCER );\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\ttrap_S_StartLocalSound( cgs.media.count2Sound, CHAN_ANNOUNCER );\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\ttrap_S_StartLocalSound( cgs.media.count3Sound, CHAN_ANNOUNCER );\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}\n\tscale = 0.45f;\n\tswitch ( cg.warmupCount ) {\n\tcase 0:\n\t\tcw = 28;\n\t\tscale = 0.54f;\n\t\tbreak;\n\tcase 1:\n\t\tcw = 24;\n\t\tscale = 0.51f;\n\t\tbreak;\n\tcase 2:\n\t\tcw = 20;\n\t\tscale = 0.48f;\n\t\tbreak;\n\tdefault:\n\t\tcw = 16;\n\t\tscale = 0.45f;\n\t\tbreak;\n\t}\n\n#ifdef MISSIONPACK\n\t\tw = CG_Text_Width(s, scale, 0);\n\t\tCG_Text_Paint(320 - w / 2, 125, scale, colorWhite, s, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE);\n#else\n\tw = CG_DrawStrlen( s );\n\tCG_DrawStringExt( 320 - w * cw/2, 70, s, colorWhite, \n\t\t\tqfalse, qtrue, cw, (int)(cw * 1.5), 0 );\n#endif\n}\n\n//==================================================================================\n#ifdef MISSIONPACK\n/* \n=================\nCG_DrawTimedMenus\n=================\n*/\nvoid CG_DrawTimedMenus() {\n\tif (cg.voiceTime) {\n\t\tint t = cg.time - cg.voiceTime;\n\t\tif ( t > 2500 ) {\n\t\t\tMenus_CloseByName(\"voiceMenu\");\n\t\t\ttrap_Cvar_Set(\"cl_conXOffset\", \"0\");\n\t\t\tcg.voiceTime = 0;\n\t\t}\n\t}\n}\n#endif\n/*\n=================\nCG_Draw2D\n=================\n*/\nstatic void CG_Draw2D( void ) {\n#ifdef MISSIONPACK\n\tif (cgs.orderPending && cg.time > cgs.orderTime) {\n\t\tCG_CheckOrderPending();\n\t}\n#endif\n\t// if we are taking a levelshot for the menu, don't draw anything\n\tif ( cg.levelShot ) {\n\t\treturn;\n\t}\n\n\tif ( cg_draw2D.integer == 0 ) {\n\t\treturn;\n\t}\n\n\tif ( cg.snap->ps.pm_type == PM_INTERMISSION ) {\n\t\tCG_DrawIntermission();\n\t\treturn;\n\t}\n\n/*\n\tif (cg.cameraMode) {\n\t\treturn;\n\t}\n*/\n\tif ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR ) {\n\t\tCG_DrawSpectator();\n\t\tCG_DrawCrosshair();\n\t\tCG_DrawCrosshairNames();\n\t} else {\n\t\t// don't draw any status if dead or the scoreboard is being explicitly shown\n\t\tif ( !cg.showScores && cg.snap->ps.stats[STAT_HEALTH] > 0 ) {\n\n#ifdef MISSIONPACK\n\t\t\tif ( cg_drawStatus.integer ) {\n\t\t\t\tMenu_PaintAll();\n\t\t\t\tCG_DrawTimedMenus();\n\t\t\t}\n#else\n\t\t\tCG_DrawStatusBar();\n#endif\n      \n\t\t\tCG_DrawAmmoWarning();\n\n#ifdef MISSIONPACK\n\t\t\tCG_DrawProxWarning();\n#endif      \n\t\t\tCG_DrawCrosshair();\n\t\t\tCG_DrawCrosshairNames();\n\t\t\tCG_DrawWeaponSelect();\n\n#ifndef MISSIONPACK\n\t\t\tCG_DrawHoldableItem();\n#else\n\t\t\t//CG_DrawPersistantPowerup();\n#endif\n\t\t\tCG_DrawReward();\n\t\t}\n    \n\t\tif ( cgs.gametype >= GT_TEAM ) {\n#ifndef MISSIONPACK\n\t\t\tCG_DrawTeamInfo();\n#endif\n\t\t}\n\t}\n\n\tCG_DrawVote();\n\tCG_DrawTeamVote();\n\n\tCG_DrawLagometer();\n\n#ifdef MISSIONPACK\n\tif (!cg_paused.integer) {\n\t\tCG_DrawUpperRight();\n\t}\n#else\n\tCG_DrawUpperRight();\n#endif\n\n#ifndef MISSIONPACK\n\tCG_DrawLowerRight();\n\tCG_DrawLowerLeft();\n#endif\n\n\tif ( !CG_DrawFollow() ) {\n\t\tCG_DrawWarmup();\n\t}\n\n\t// don't draw center string if scoreboard is up\n\tcg.scoreBoardShowing = CG_DrawScoreboard();\n\tif ( !cg.scoreBoardShowing) {\n\t\tCG_DrawCenterString();\n\t}\n}\n\n\nstatic void CG_DrawTourneyScoreboard() {\n#ifdef MISSIONPACK\n#else\n\tCG_DrawOldTourneyScoreboard();\n#endif\n}\n\n/*\n=====================\nCG_DrawActive\n\nPerform all drawing needed to completely fill the screen\n=====================\n*/\nvoid CG_DrawActive( stereoFrame_t stereoView ) {\n\tfloat\t\tseparation;\n\tvec3_t\t\tbaseOrg;\n\n\t// optionally draw the info screen instead\n\tif ( !cg.snap ) {\n\t\tCG_DrawInformation();\n\t\treturn;\n\t}\n\n\t// optionally draw the tournement scoreboard instead\n\tif ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR &&\n\t\t( cg.snap->ps.pm_flags & PMF_SCOREBOARD ) ) {\n\t\tCG_DrawTourneyScoreboard();\n\t\treturn;\n\t}\n\n\tswitch ( stereoView ) {\n\tcase STEREO_CENTER:\n\t\tseparation = 0;\n\t\tbreak;\n\tcase STEREO_LEFT:\n\t\tseparation = -cg_stereoSeparation.value / 2;\n\t\tbreak;\n\tcase STEREO_RIGHT:\n\t\tseparation = cg_stereoSeparation.value / 2;\n\t\tbreak;\n\tdefault:\n\t\tseparation = 0;\n\t\tCG_Error( \"CG_DrawActive: Undefined stereoView\" );\n\t}\n\n\n\t// clear around the rendered view if sized down\n\tCG_TileClear();\n\n\t// offset vieworg appropriately if we're doing stereo separation\n\tVectorCopy( cg.refdef.vieworg, baseOrg );\n\tif ( separation != 0 ) {\n\t\tVectorMA( cg.refdef.vieworg, -separation, cg.refdef.viewaxis[1], cg.refdef.vieworg );\n\t}\n\n\t// draw 3D view\n\ttrap_R_RenderScene( &cg.refdef );\n\n\t// restore original viewpoint if running stereo\n\tif ( separation != 0 ) {\n\t\tVectorCopy( baseOrg, cg.refdef.vieworg );\n\t}\n\n\t// draw status bar and other floating elements\n \tCG_Draw2D();\n}\n\n\n\n"
  },
  {
    "path": "code/cgame/cg_drawtools.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// cg_drawtools.c -- helper functions called by cg_draw, cg_scoreboard, cg_info, etc\n#include \"cg_local.h\"\n\n/*\n================\nCG_AdjustFrom640\n\nAdjusted for resolution and screen aspect ratio\n================\n*/\nvoid CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {\n#if 0\n\t// adjust for wide screens\n\tif ( cgs.glconfig.vidWidth * 480 > cgs.glconfig.vidHeight * 640 ) {\n\t\t*x += 0.5 * ( cgs.glconfig.vidWidth - ( cgs.glconfig.vidHeight * 640 / 480 ) );\n\t}\n#endif\n\t// scale for screen sizes\n\t*x *= cgs.screenXScale;\n\t*y *= cgs.screenYScale;\n\t*w *= cgs.screenXScale;\n\t*h *= cgs.screenYScale;\n}\n\n/*\n================\nCG_FillRect\n\nCoordinates are 640*480 virtual values\n=================\n*/\nvoid CG_FillRect( float x, float y, float width, float height, const float *color ) {\n\ttrap_R_SetColor( color );\n\n\tCG_AdjustFrom640( &x, &y, &width, &height );\n\ttrap_R_DrawStretchPic( x, y, width, height, 0, 0, 0, 0, cgs.media.whiteShader );\n\n\ttrap_R_SetColor( NULL );\n}\n\n/*\n================\nCG_DrawSides\n\nCoords are virtual 640x480\n================\n*/\nvoid CG_DrawSides(float x, float y, float w, float h, float size) {\n\tCG_AdjustFrom640( &x, &y, &w, &h );\n\tsize *= cgs.screenXScale;\n\ttrap_R_DrawStretchPic( x, y, size, h, 0, 0, 0, 0, cgs.media.whiteShader );\n\ttrap_R_DrawStretchPic( x + w - size, y, size, h, 0, 0, 0, 0, cgs.media.whiteShader );\n}\n\nvoid CG_DrawTopBottom(float x, float y, float w, float h, float size) {\n\tCG_AdjustFrom640( &x, &y, &w, &h );\n\tsize *= cgs.screenYScale;\n\ttrap_R_DrawStretchPic( x, y, w, size, 0, 0, 0, 0, cgs.media.whiteShader );\n\ttrap_R_DrawStretchPic( x, y + h - size, w, size, 0, 0, 0, 0, cgs.media.whiteShader );\n}\n/*\n================\nUI_DrawRect\n\nCoordinates are 640*480 virtual values\n=================\n*/\nvoid CG_DrawRect( float x, float y, float width, float height, float size, const float *color ) {\n\ttrap_R_SetColor( color );\n\n  CG_DrawTopBottom(x, y, width, height, size);\n  CG_DrawSides(x, y, width, height, size);\n\n\ttrap_R_SetColor( NULL );\n}\n\n\n\n/*\n================\nCG_DrawPic\n\nCoordinates are 640*480 virtual values\n=================\n*/\nvoid CG_DrawPic( float x, float y, float width, float height, qhandle_t hShader ) {\n\tCG_AdjustFrom640( &x, &y, &width, &height );\n\ttrap_R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader );\n}\n\n\n\n/*\n===============\nCG_DrawChar\n\nCoordinates and size in 640*480 virtual screen size\n===============\n*/\nvoid CG_DrawChar( int x, int y, int width, int height, int ch ) {\n\tint row, col;\n\tfloat frow, fcol;\n\tfloat size;\n\tfloat\tax, ay, aw, ah;\n\n\tch &= 255;\n\n\tif ( ch == ' ' ) {\n\t\treturn;\n\t}\n\n\tax = x;\n\tay = y;\n\taw = width;\n\tah = height;\n\tCG_AdjustFrom640( &ax, &ay, &aw, &ah );\n\n\trow = ch>>4;\n\tcol = ch&15;\n\n\tfrow = row*0.0625;\n\tfcol = col*0.0625;\n\tsize = 0.0625;\n\n\ttrap_R_DrawStretchPic( ax, ay, aw, ah,\n\t\t\t\t\t   fcol, frow, \n\t\t\t\t\t   fcol + size, frow + size, \n\t\t\t\t\t   cgs.media.charsetShader );\n}\n\n\n/*\n==================\nCG_DrawStringExt\n\nDraws a multi-colored string with a drop shadow, optionally forcing\nto a fixed color.\n\nCoordinates are at 640 by 480 virtual resolution\n==================\n*/\nvoid CG_DrawStringExt( int x, int y, const char *string, const float *setColor, \n\t\tqboolean forceColor, qboolean shadow, int charWidth, int charHeight, int maxChars ) {\n\tvec4_t\t\tcolor;\n\tconst char\t*s;\n\tint\t\t\txx;\n\tint\t\t\tcnt;\n\n\tif (maxChars <= 0)\n\t\tmaxChars = 32767; // do them all!\n\n\t// draw the drop shadow\n\tif (shadow) {\n\t\tcolor[0] = color[1] = color[2] = 0;\n\t\tcolor[3] = setColor[3];\n\t\ttrap_R_SetColor( color );\n\t\ts = string;\n\t\txx = x;\n\t\tcnt = 0;\n\t\twhile ( *s && cnt < maxChars) {\n\t\t\tif ( Q_IsColorString( s ) ) {\n\t\t\t\ts += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tCG_DrawChar( xx + 2, y + 2, charWidth, charHeight, *s );\n\t\t\tcnt++;\n\t\t\txx += charWidth;\n\t\t\ts++;\n\t\t}\n\t}\n\n\t// draw the colored text\n\ts = string;\n\txx = x;\n\tcnt = 0;\n\ttrap_R_SetColor( setColor );\n\twhile ( *s && cnt < maxChars) {\n\t\tif ( Q_IsColorString( s ) ) {\n\t\t\tif ( !forceColor ) {\n\t\t\t\tmemcpy( color, g_color_table[ColorIndex(*(s+1))], sizeof( color ) );\n\t\t\t\tcolor[3] = setColor[3];\n\t\t\t\ttrap_R_SetColor( color );\n\t\t\t}\n\t\t\ts += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tCG_DrawChar( xx, y, charWidth, charHeight, *s );\n\t\txx += charWidth;\n\t\tcnt++;\n\t\ts++;\n\t}\n\ttrap_R_SetColor( NULL );\n}\n\nvoid CG_DrawBigString( int x, int y, const char *s, float alpha ) {\n\tfloat\tcolor[4];\n\n\tcolor[0] = color[1] = color[2] = 1.0;\n\tcolor[3] = alpha;\n\tCG_DrawStringExt( x, y, s, color, qfalse, qtrue, BIGCHAR_WIDTH, BIGCHAR_HEIGHT, 0 );\n}\n\nvoid CG_DrawBigStringColor( int x, int y, const char *s, vec4_t color ) {\n\tCG_DrawStringExt( x, y, s, color, qtrue, qtrue, BIGCHAR_WIDTH, BIGCHAR_HEIGHT, 0 );\n}\n\nvoid CG_DrawSmallString( int x, int y, const char *s, float alpha ) {\n\tfloat\tcolor[4];\n\n\tcolor[0] = color[1] = color[2] = 1.0;\n\tcolor[3] = alpha;\n\tCG_DrawStringExt( x, y, s, color, qfalse, qfalse, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 0 );\n}\n\nvoid CG_DrawSmallStringColor( int x, int y, const char *s, vec4_t color ) {\n\tCG_DrawStringExt( x, y, s, color, qtrue, qfalse, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 0 );\n}\n\n/*\n=================\nCG_DrawStrlen\n\nReturns character count, skiping color escape codes\n=================\n*/\nint CG_DrawStrlen( const char *str ) {\n\tconst char *s = str;\n\tint count = 0;\n\n\twhile ( *s ) {\n\t\tif ( Q_IsColorString( s ) ) {\n\t\t\ts += 2;\n\t\t} else {\n\t\t\tcount++;\n\t\t\ts++;\n\t\t}\n\t}\n\n\treturn count;\n}\n\n/*\n=============\nCG_TileClearBox\n\nThis repeats a 64*64 tile graphic to fill the screen around a sized down\nrefresh window.\n=============\n*/\nstatic void CG_TileClearBox( int x, int y, int w, int h, qhandle_t hShader ) {\n\tfloat\ts1, t1, s2, t2;\n\n\ts1 = x/64.0;\n\tt1 = y/64.0;\n\ts2 = (x+w)/64.0;\n\tt2 = (y+h)/64.0;\n\ttrap_R_DrawStretchPic( x, y, w, h, s1, t1, s2, t2, hShader );\n}\n\n\n\n/*\n==============\nCG_TileClear\n\nClear around a sized down screen\n==============\n*/\nvoid CG_TileClear( void ) {\n\tint\t\ttop, bottom, left, right;\n\tint\t\tw, h;\n\n\tw = cgs.glconfig.vidWidth;\n\th = cgs.glconfig.vidHeight;\n\n\tif ( cg.refdef.x == 0 && cg.refdef.y == 0 && \n\t\tcg.refdef.width == w && cg.refdef.height == h ) {\n\t\treturn;\t\t// full screen rendering\n\t}\n\n\ttop = cg.refdef.y;\n\tbottom = top + cg.refdef.height-1;\n\tleft = cg.refdef.x;\n\tright = left + cg.refdef.width-1;\n\n\t// clear above view screen\n\tCG_TileClearBox( 0, 0, w, top, cgs.media.backTileShader );\n\n\t// clear below view screen\n\tCG_TileClearBox( 0, bottom, w, h - bottom, cgs.media.backTileShader );\n\n\t// clear left of view screen\n\tCG_TileClearBox( 0, top, left, bottom - top + 1, cgs.media.backTileShader );\n\n\t// clear right of view screen\n\tCG_TileClearBox( right, top, w - right, bottom - top + 1, cgs.media.backTileShader );\n}\n\n\n\n/*\n================\nCG_FadeColor\n================\n*/\nfloat *CG_FadeColor( int startMsec, int totalMsec ) {\n\tstatic vec4_t\t\tcolor;\n\tint\t\t\tt;\n\n\tif ( startMsec == 0 ) {\n\t\treturn NULL;\n\t}\n\n\tt = cg.time - startMsec;\n\n\tif ( t >= totalMsec ) {\n\t\treturn NULL;\n\t}\n\n\t// fade out\n\tif ( totalMsec - t < FADE_TIME ) {\n\t\tcolor[3] = ( totalMsec - t ) * 1.0/FADE_TIME;\n\t} else {\n\t\tcolor[3] = 1.0;\n\t}\n\tcolor[0] = color[1] = color[2] = 1;\n\n\treturn color;\n}\n\n\n/*\n================\nCG_TeamColor\n================\n*/\nfloat *CG_TeamColor( int team ) {\n\tstatic vec4_t\tred = {1, 0.2f, 0.2f, 1};\n\tstatic vec4_t\tblue = {0.2f, 0.2f, 1, 1};\n\tstatic vec4_t\tother = {1, 1, 1, 1};\n\tstatic vec4_t\tspectator = {0.7f, 0.7f, 0.7f, 1};\n\n\tswitch ( team ) {\n\tcase TEAM_RED:\n\t\treturn red;\n\tcase TEAM_BLUE:\n\t\treturn blue;\n\tcase TEAM_SPECTATOR:\n\t\treturn spectator;\n\tdefault:\n\t\treturn other;\n\t}\n}\n\n\n\n/*\n=================\nCG_GetColorForHealth\n=================\n*/\nvoid CG_GetColorForHealth( int health, int armor, vec4_t hcolor ) {\n\tint\t\tcount;\n\tint\t\tmax;\n\n\t// calculate the total points of damage that can\n\t// be sustained at the current health / armor level\n\tif ( health <= 0 ) {\n\t\tVectorClear( hcolor );\t// black\n\t\thcolor[3] = 1;\n\t\treturn;\n\t}\n\tcount = armor;\n\tmax = health * ARMOR_PROTECTION / ( 1.0 - ARMOR_PROTECTION );\n\tif ( max < count ) {\n\t\tcount = max;\n\t}\n\thealth += count;\n\n\t// set the color based on health\n\thcolor[0] = 1.0;\n\thcolor[3] = 1.0;\n\tif ( health >= 100 ) {\n\t\thcolor[2] = 1.0;\n\t} else if ( health < 66 ) {\n\t\thcolor[2] = 0;\n\t} else {\n\t\thcolor[2] = ( health - 66 ) / 33.0;\n\t}\n\n\tif ( health > 60 ) {\n\t\thcolor[1] = 1.0;\n\t} else if ( health < 30 ) {\n\t\thcolor[1] = 0;\n\t} else {\n\t\thcolor[1] = ( health - 30 ) / 30.0;\n\t}\n}\n\n/*\n=================\nCG_ColorForHealth\n=================\n*/\nvoid CG_ColorForHealth( vec4_t hcolor ) {\n\n\tCG_GetColorForHealth( cg.snap->ps.stats[STAT_HEALTH], \n\t\tcg.snap->ps.stats[STAT_ARMOR], hcolor );\n}\n\n\n\n\n// bk001205 - code below duplicated in q3_ui/ui-atoms.c\n// bk001205 - FIXME: does this belong in ui_shared.c?\n// bk001205 - FIXME: HARD_LINKED flags not visible here\n#ifndef Q3_STATIC // bk001205 - q_shared defines not visible here \n/*\n=================\nUI_DrawProportionalString2\n=================\n*/\nstatic int\tpropMap[128][3] = {\n{0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1},\n{0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1},\n\n{0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1},\n{0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1},\n\n{0, 0, PROP_SPACE_WIDTH},\t\t// SPACE\n{11, 122, 7},\t// !\n{154, 181, 14},\t// \"\n{55, 122, 17},\t// #\n{79, 122, 18},\t// $\n{101, 122, 23},\t// %\n{153, 122, 18},\t// &\n{9, 93, 7},\t\t// '\n{207, 122, 8},\t// (\n{230, 122, 9},\t// )\n{177, 122, 18},\t// *\n{30, 152, 18},\t// +\n{85, 181, 7},\t// ,\n{34, 93, 11},\t// -\n{110, 181, 6},\t// .\n{130, 152, 14},\t// /\n\n{22, 64, 17},\t// 0\n{41, 64, 12},\t// 1\n{58, 64, 17},\t// 2\n{78, 64, 18},\t// 3\n{98, 64, 19},\t// 4\n{120, 64, 18},\t// 5\n{141, 64, 18},\t// 6\n{204, 64, 16},\t// 7\n{162, 64, 17},\t// 8\n{182, 64, 18},\t// 9\n{59, 181, 7},\t// :\n{35,181, 7},\t// ;\n{203, 152, 14},\t// <\n{56, 93, 14},\t// =\n{228, 152, 14},\t// >\n{177, 181, 18},\t// ?\n\n{28, 122, 22},\t// @\n{5, 4, 18},\t\t// A\n{27, 4, 18},\t// B\n{48, 4, 18},\t// C\n{69, 4, 17},\t// D\n{90, 4, 13},\t// E\n{106, 4, 13},\t// F\n{121, 4, 18},\t// G\n{143, 4, 17},\t// H\n{164, 4, 8},\t// I\n{175, 4, 16},\t// J\n{195, 4, 18},\t// K\n{216, 4, 12},\t// L\n{230, 4, 23},\t// M\n{6, 34, 18},\t// N\n{27, 34, 18},\t// O\n\n{48, 34, 18},\t// P\n{68, 34, 18},\t// Q\n{90, 34, 17},\t// R\n{110, 34, 18},\t// S\n{130, 34, 14},\t// T\n{146, 34, 18},\t// U\n{166, 34, 19},\t// V\n{185, 34, 29},\t// W\n{215, 34, 18},\t// X\n{234, 34, 18},\t// Y\n{5, 64, 14},\t// Z\n{60, 152, 7},\t// [\n{106, 151, 13},\t// '\\'\n{83, 152, 7},\t// ]\n{128, 122, 17},\t// ^\n{4, 152, 21},\t// _\n\n{134, 181, 5},\t// '\n{5, 4, 18},\t\t// A\n{27, 4, 18},\t// B\n{48, 4, 18},\t// C\n{69, 4, 17},\t// D\n{90, 4, 13},\t// E\n{106, 4, 13},\t// F\n{121, 4, 18},\t// G\n{143, 4, 17},\t// H\n{164, 4, 8},\t// I\n{175, 4, 16},\t// J\n{195, 4, 18},\t// K\n{216, 4, 12},\t// L\n{230, 4, 23},\t// M\n{6, 34, 18},\t// N\n{27, 34, 18},\t// O\n\n{48, 34, 18},\t// P\n{68, 34, 18},\t// Q\n{90, 34, 17},\t// R\n{110, 34, 18},\t// S\n{130, 34, 14},\t// T\n{146, 34, 18},\t// U\n{166, 34, 19},\t// V\n{185, 34, 29},\t// W\n{215, 34, 18},\t// X\n{234, 34, 18},\t// Y\n{5, 64, 14},\t// Z\n{153, 152, 13},\t// {\n{11, 181, 5},\t// |\n{180, 152, 13},\t// }\n{79, 93, 17},\t// ~\n{0, 0, -1}\t\t// DEL\n};\n\nstatic int propMapB[26][3] = {\n{11, 12, 33},\n{49, 12, 31},\n{85, 12, 31},\n{120, 12, 30},\n{156, 12, 21},\n{183, 12, 21},\n{207, 12, 32},\n\n{13, 55, 30},\n{49, 55, 13},\n{66, 55, 29},\n{101, 55, 31},\n{135, 55, 21},\n{158, 55, 40},\n{204, 55, 32},\n\n{12, 97, 31},\n{48, 97, 31},\n{82, 97, 30},\n{118, 97, 30},\n{153, 97, 30},\n{185, 97, 25},\n{213, 97, 30},\n\n{11, 139, 32},\n{42, 139, 51},\n{93, 139, 32},\n{126, 139, 31},\n{158, 139, 25},\n};\n\n#define PROPB_GAP_WIDTH\t\t4\n#define PROPB_SPACE_WIDTH\t12\n#define PROPB_HEIGHT\t\t36\n\n/*\n=================\nUI_DrawBannerString\n=================\n*/\nstatic void UI_DrawBannerString2( int x, int y, const char* str, vec4_t color )\n{\n\tconst char* s;\n\tunsigned char\tch; // bk001204 : array subscript\n\tfloat\tax;\n\tfloat\tay;\n\tfloat\taw;\n\tfloat\tah;\n\tfloat\tfrow;\n\tfloat\tfcol;\n\tfloat\tfwidth;\n\tfloat\tfheight;\n\n\t// draw the colored text\n\ttrap_R_SetColor( color );\n\t\n\tax = x * cgs.screenXScale + cgs.screenXBias;\n\tay = y * cgs.screenXScale;\n\n\ts = str;\n\twhile ( *s )\n\t{\n\t\tch = *s & 127;\n\t\tif ( ch == ' ' ) {\n\t\t\tax += ((float)PROPB_SPACE_WIDTH + (float)PROPB_GAP_WIDTH)* cgs.screenXScale;\n\t\t}\n\t\telse if ( ch >= 'A' && ch <= 'Z' ) {\n\t\t\tch -= 'A';\n\t\t\tfcol = (float)propMapB[ch][0] / 256.0f;\n\t\t\tfrow = (float)propMapB[ch][1] / 256.0f;\n\t\t\tfwidth = (float)propMapB[ch][2] / 256.0f;\n\t\t\tfheight = (float)PROPB_HEIGHT / 256.0f;\n\t\t\taw = (float)propMapB[ch][2] * cgs.screenXScale;\n\t\t\tah = (float)PROPB_HEIGHT * cgs.screenXScale;\n\t\t\ttrap_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol+fwidth, frow+fheight, cgs.media.charsetPropB );\n\t\t\tax += (aw + (float)PROPB_GAP_WIDTH * cgs.screenXScale);\n\t\t}\n\t\ts++;\n\t}\n\n\ttrap_R_SetColor( NULL );\n}\n\nvoid UI_DrawBannerString( int x, int y, const char* str, int style, vec4_t color ) {\n\tconst char *\ts;\n\tint\t\t\t\tch;\n\tint\t\t\t\twidth;\n\tvec4_t\t\t\tdrawcolor;\n\n\t// find the width of the drawn text\n\ts = str;\n\twidth = 0;\n\twhile ( *s ) {\n\t\tch = *s;\n\t\tif ( ch == ' ' ) {\n\t\t\twidth += PROPB_SPACE_WIDTH;\n\t\t}\n\t\telse if ( ch >= 'A' && ch <= 'Z' ) {\n\t\t\twidth += propMapB[ch - 'A'][2] + PROPB_GAP_WIDTH;\n\t\t}\n\t\ts++;\n\t}\n\twidth -= PROPB_GAP_WIDTH;\n\n\tswitch( style & UI_FORMATMASK ) {\n\t\tcase UI_CENTER:\n\t\t\tx -= width / 2;\n\t\t\tbreak;\n\n\t\tcase UI_RIGHT:\n\t\t\tx -= width;\n\t\t\tbreak;\n\n\t\tcase UI_LEFT:\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\n\tif ( style & UI_DROPSHADOW ) {\n\t\tdrawcolor[0] = drawcolor[1] = drawcolor[2] = 0;\n\t\tdrawcolor[3] = color[3];\n\t\tUI_DrawBannerString2( x+2, y+2, str, drawcolor );\n\t}\n\n\tUI_DrawBannerString2( x, y, str, color );\n}\n\n\nint UI_ProportionalStringWidth( const char* str ) {\n\tconst char *\ts;\n\tint\t\t\t\tch;\n\tint\t\t\t\tcharWidth;\n\tint\t\t\t\twidth;\n\n\ts = str;\n\twidth = 0;\n\twhile ( *s ) {\n\t\tch = *s & 127;\n\t\tcharWidth = propMap[ch][2];\n\t\tif ( charWidth != -1 ) {\n\t\t\twidth += charWidth;\n\t\t\twidth += PROP_GAP_WIDTH;\n\t\t}\n\t\ts++;\n\t}\n\n\twidth -= PROP_GAP_WIDTH;\n\treturn width;\n}\n\nstatic void UI_DrawProportionalString2( int x, int y, const char* str, vec4_t color, float sizeScale, qhandle_t charset )\n{\n\tconst char* s;\n\tunsigned char\tch; // bk001204 - unsigned\n\tfloat\tax;\n\tfloat\tay;\n\tfloat\taw;\n\tfloat\tah;\n\tfloat\tfrow;\n\tfloat\tfcol;\n\tfloat\tfwidth;\n\tfloat\tfheight;\n\n\t// draw the colored text\n\ttrap_R_SetColor( color );\n\t\n\tax = x * cgs.screenXScale + cgs.screenXBias;\n\tay = y * cgs.screenXScale;\n\n\ts = str;\n\twhile ( *s )\n\t{\n\t\tch = *s & 127;\n\t\tif ( ch == ' ' ) {\n\t\t\taw = (float)PROP_SPACE_WIDTH * cgs.screenXScale * sizeScale;\n\t\t} else if ( propMap[ch][2] != -1 ) {\n\t\t\tfcol = (float)propMap[ch][0] / 256.0f;\n\t\t\tfrow = (float)propMap[ch][1] / 256.0f;\n\t\t\tfwidth = (float)propMap[ch][2] / 256.0f;\n\t\t\tfheight = (float)PROP_HEIGHT / 256.0f;\n\t\t\taw = (float)propMap[ch][2] * cgs.screenXScale * sizeScale;\n\t\t\tah = (float)PROP_HEIGHT * cgs.screenXScale * sizeScale;\n\t\t\ttrap_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol+fwidth, frow+fheight, charset );\n\t\t} else {\n\t\t\taw = 0;\n\t\t}\n\n\t\tax += (aw + (float)PROP_GAP_WIDTH * cgs.screenXScale * sizeScale);\n\t\ts++;\n\t}\n\n\ttrap_R_SetColor( NULL );\n}\n\n/*\n=================\nUI_ProportionalSizeScale\n=================\n*/\nfloat UI_ProportionalSizeScale( int style ) {\n\tif(  style & UI_SMALLFONT ) {\n\t\treturn 0.75;\n\t}\n\n\treturn 1.00;\n}\n\n\n/*\n=================\nUI_DrawProportionalString\n=================\n*/\nvoid UI_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color ) {\n\tvec4_t\tdrawcolor;\n\tint\t\twidth;\n\tfloat\tsizeScale;\n\n\tsizeScale = UI_ProportionalSizeScale( style );\n\n\tswitch( style & UI_FORMATMASK ) {\n\t\tcase UI_CENTER:\n\t\t\twidth = UI_ProportionalStringWidth( str ) * sizeScale;\n\t\t\tx -= width / 2;\n\t\t\tbreak;\n\n\t\tcase UI_RIGHT:\n\t\t\twidth = UI_ProportionalStringWidth( str ) * sizeScale;\n\t\t\tx -= width;\n\t\t\tbreak;\n\n\t\tcase UI_LEFT:\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\n\tif ( style & UI_DROPSHADOW ) {\n\t\tdrawcolor[0] = drawcolor[1] = drawcolor[2] = 0;\n\t\tdrawcolor[3] = color[3];\n\t\tUI_DrawProportionalString2( x+2, y+2, str, drawcolor, sizeScale, cgs.media.charsetProp );\n\t}\n\n\tif ( style & UI_INVERSE ) {\n\t\tdrawcolor[0] = color[0] * 0.8;\n\t\tdrawcolor[1] = color[1] * 0.8;\n\t\tdrawcolor[2] = color[2] * 0.8;\n\t\tdrawcolor[3] = color[3];\n\t\tUI_DrawProportionalString2( x, y, str, drawcolor, sizeScale, cgs.media.charsetProp );\n\t\treturn;\n\t}\n\n\tif ( style & UI_PULSE ) {\n\t\tdrawcolor[0] = color[0] * 0.8;\n\t\tdrawcolor[1] = color[1] * 0.8;\n\t\tdrawcolor[2] = color[2] * 0.8;\n\t\tdrawcolor[3] = color[3];\n\t\tUI_DrawProportionalString2( x, y, str, color, sizeScale, cgs.media.charsetProp );\n\n\t\tdrawcolor[0] = color[0];\n\t\tdrawcolor[1] = color[1];\n\t\tdrawcolor[2] = color[2];\n\t\tdrawcolor[3] = 0.5 + 0.5 * sin( cg.time / PULSE_DIVISOR );\n\t\tUI_DrawProportionalString2( x, y, str, drawcolor, sizeScale, cgs.media.charsetPropGlow );\n\t\treturn;\n\t}\n\n\tUI_DrawProportionalString2( x, y, str, color, sizeScale, cgs.media.charsetProp );\n}\n#endif // Q3STATIC\n"
  },
  {
    "path": "code/cgame/cg_effects.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// cg_effects.c -- these functions generate localentities, usually as a result\n// of event processing\n\n#include \"cg_local.h\"\n\n\n/*\n==================\nCG_BubbleTrail\n\nBullets shot underwater\n==================\n*/\nvoid CG_BubbleTrail( vec3_t start, vec3_t end, float spacing ) {\n\tvec3_t\t\tmove;\n\tvec3_t\t\tvec;\n\tfloat\t\tlen;\n\tint\t\t\ti;\n\n\tif ( cg_noProjectileTrail.integer ) {\n\t\treturn;\n\t}\n\n\tVectorCopy (start, move);\n\tVectorSubtract (end, start, vec);\n\tlen = VectorNormalize (vec);\n\n\t// advance a random amount first\n\ti = rand() % (int)spacing;\n\tVectorMA( move, i, vec, move );\n\n\tVectorScale (vec, spacing, vec);\n\n\tfor ( ; i < len; i += spacing ) {\n\t\tlocalEntity_t\t*le;\n\t\trefEntity_t\t\t*re;\n\n\t\tle = CG_AllocLocalEntity();\n\t\tle->leFlags = LEF_PUFF_DONT_SCALE;\n\t\tle->leType = LE_MOVE_SCALE_FADE;\n\t\tle->startTime = cg.time;\n\t\tle->endTime = cg.time + 1000 + random() * 250;\n\t\tle->lifeRate = 1.0 / ( le->endTime - le->startTime );\n\n\t\tre = &le->refEntity;\n\t\tre->shaderTime = cg.time / 1000.0f;\n\n\t\tre->reType = RT_SPRITE;\n\t\tre->rotation = 0;\n\t\tre->radius = 3;\n\t\tre->customShader = cgs.media.waterBubbleShader;\n\t\tre->shaderRGBA[0] = 0xff;\n\t\tre->shaderRGBA[1] = 0xff;\n\t\tre->shaderRGBA[2] = 0xff;\n\t\tre->shaderRGBA[3] = 0xff;\n\n\t\tle->color[3] = 1.0;\n\n\t\tle->pos.trType = TR_LINEAR;\n\t\tle->pos.trTime = cg.time;\n\t\tVectorCopy( move, le->pos.trBase );\n\t\tle->pos.trDelta[0] = crandom()*5;\n\t\tle->pos.trDelta[1] = crandom()*5;\n\t\tle->pos.trDelta[2] = crandom()*5 + 6;\n\n\t\tVectorAdd (move, vec, move);\n\t}\n}\n\n/*\n=====================\nCG_SmokePuff\n\nAdds a smoke puff or blood trail localEntity.\n=====================\n*/\nlocalEntity_t *CG_SmokePuff( const vec3_t p, const vec3_t vel, \n\t\t\t\t   float radius,\n\t\t\t\t   float r, float g, float b, float a,\n\t\t\t\t   float duration,\n\t\t\t\t   int startTime,\n\t\t\t\t   int fadeInTime,\n\t\t\t\t   int leFlags,\n\t\t\t\t   qhandle_t hShader ) {\n\tstatic int\tseed = 0x92;\n\tlocalEntity_t\t*le;\n\trefEntity_t\t\t*re;\n//\tint fadeInTime = startTime + duration / 2;\n\n\tle = CG_AllocLocalEntity();\n\tle->leFlags = leFlags;\n\tle->radius = radius;\n\n\tre = &le->refEntity;\n\tre->rotation = Q_random( &seed ) * 360;\n\tre->radius = radius;\n\tre->shaderTime = startTime / 1000.0f;\n\n\tle->leType = LE_MOVE_SCALE_FADE;\n\tle->startTime = startTime;\n\tle->fadeInTime = fadeInTime;\n\tle->endTime = startTime + duration;\n\tif ( fadeInTime > startTime ) {\n\t\tle->lifeRate = 1.0 / ( le->endTime - le->fadeInTime );\n\t}\n\telse {\n\t\tle->lifeRate = 1.0 / ( le->endTime - le->startTime );\n\t}\n\tle->color[0] = r;\n\tle->color[1] = g; \n\tle->color[2] = b;\n\tle->color[3] = a;\n\n\n\tle->pos.trType = TR_LINEAR;\n\tle->pos.trTime = startTime;\n\tVectorCopy( vel, le->pos.trDelta );\n\tVectorCopy( p, le->pos.trBase );\n\n\tVectorCopy( p, re->origin );\n\tre->customShader = hShader;\n\n\t// rage pro can't alpha fade, so use a different shader\n\tif ( cgs.glconfig.hardwareType == GLHW_RAGEPRO ) {\n\t\tre->customShader = cgs.media.smokePuffRageProShader;\n\t\tre->shaderRGBA[0] = 0xff;\n\t\tre->shaderRGBA[1] = 0xff;\n\t\tre->shaderRGBA[2] = 0xff;\n\t\tre->shaderRGBA[3] = 0xff;\n\t} else {\n\t\tre->shaderRGBA[0] = le->color[0] * 0xff;\n\t\tre->shaderRGBA[1] = le->color[1] * 0xff;\n\t\tre->shaderRGBA[2] = le->color[2] * 0xff;\n\t\tre->shaderRGBA[3] = 0xff;\n\t}\n\n\tre->reType = RT_SPRITE;\n\tre->radius = le->radius;\n\n\treturn le;\n}\n\n/*\n==================\nCG_SpawnEffect\n\nPlayer teleporting in or out\n==================\n*/\nvoid CG_SpawnEffect( vec3_t org ) {\n\tlocalEntity_t\t*le;\n\trefEntity_t\t\t*re;\n\n\tle = CG_AllocLocalEntity();\n\tle->leFlags = 0;\n\tle->leType = LE_FADE_RGB;\n\tle->startTime = cg.time;\n\tle->endTime = cg.time + 500;\n\tle->lifeRate = 1.0 / ( le->endTime - le->startTime );\n\n\tle->color[0] = le->color[1] = le->color[2] = le->color[3] = 1.0;\n\n\tre = &le->refEntity;\n\n\tre->reType = RT_MODEL;\n\tre->shaderTime = cg.time / 1000.0f;\n\n#ifndef MISSIONPACK\n\tre->customShader = cgs.media.teleportEffectShader;\n#endif\n\tre->hModel = cgs.media.teleportEffectModel;\n\tAxisClear( re->axis );\n\n\tVectorCopy( org, re->origin );\n#ifdef MISSIONPACK\n\tre->origin[2] += 16;\n#else\n\tre->origin[2] -= 24;\n#endif\n}\n\n\n#ifdef MISSIONPACK\n/*\n===============\nCG_LightningBoltBeam\n===============\n*/\nvoid CG_LightningBoltBeam( vec3_t start, vec3_t end ) {\n\tlocalEntity_t\t*le;\n\trefEntity_t\t\t*beam;\n\n\tle = CG_AllocLocalEntity();\n\tle->leFlags = 0;\n\tle->leType = LE_SHOWREFENTITY;\n\tle->startTime = cg.time;\n\tle->endTime = cg.time + 50;\n\n\tbeam = &le->refEntity;\n\n\tVectorCopy( start, beam->origin );\n\t// this is the end point\n\tVectorCopy( end, beam->oldorigin );\n\n\tbeam->reType = RT_LIGHTNING;\n\tbeam->customShader = cgs.media.lightningShader;\n}\n\n/*\n==================\nCG_KamikazeEffect\n==================\n*/\nvoid CG_KamikazeEffect( vec3_t org ) {\n\tlocalEntity_t\t*le;\n\trefEntity_t\t\t*re;\n\n\tle = CG_AllocLocalEntity();\n\tle->leFlags = 0;\n\tle->leType = LE_KAMIKAZE;\n\tle->startTime = cg.time;\n\tle->endTime = cg.time + 3000;//2250;\n\tle->lifeRate = 1.0 / ( le->endTime - le->startTime );\n\n\tle->color[0] = le->color[1] = le->color[2] = le->color[3] = 1.0;\n\n\tVectorClear(le->angles.trBase);\n\n\tre = &le->refEntity;\n\n\tre->reType = RT_MODEL;\n\tre->shaderTime = cg.time / 1000.0f;\n\n\tre->hModel = cgs.media.kamikazeEffectModel;\n\n\tVectorCopy( org, re->origin );\n\n}\n\n/*\n==================\nCG_ObeliskExplode\n==================\n*/\nvoid CG_ObeliskExplode( vec3_t org, int entityNum ) {\n\tlocalEntity_t\t*le;\n\tvec3_t origin;\n\n\t// create an explosion\n\tVectorCopy( org, origin );\n\torigin[2] += 64;\n\tle = CG_MakeExplosion( origin, vec3_origin,\n\t\t\t\t\t\t   cgs.media.dishFlashModel,\n\t\t\t\t\t\t   cgs.media.rocketExplosionShader,\n\t\t\t\t\t\t   600, qtrue );\n\tle->light = 300;\n\tle->lightColor[0] = 1;\n\tle->lightColor[1] = 0.75;\n\tle->lightColor[2] = 0.0;\n}\n\n/*\n==================\nCG_ObeliskPain\n==================\n*/\nvoid CG_ObeliskPain( vec3_t org ) {\n\tfloat r;\n\tsfxHandle_t sfx;\n\n\t// hit sound\n\tr = rand() & 3;\n\tif ( r < 2 ) {\n\t\tsfx = cgs.media.obeliskHitSound1;\n\t} else if ( r == 2 ) {\n\t\tsfx = cgs.media.obeliskHitSound2;\n\t} else {\n\t\tsfx = cgs.media.obeliskHitSound3;\n\t}\n\ttrap_S_StartSound ( org, ENTITYNUM_NONE, CHAN_BODY, sfx );\n}\n\n\n/*\n==================\nCG_InvulnerabilityImpact\n==================\n*/\nvoid CG_InvulnerabilityImpact( vec3_t org, vec3_t angles ) {\n\tlocalEntity_t\t*le;\n\trefEntity_t\t\t*re;\n\tint\t\t\t\tr;\n\tsfxHandle_t\t\tsfx;\n\n\tle = CG_AllocLocalEntity();\n\tle->leFlags = 0;\n\tle->leType = LE_INVULIMPACT;\n\tle->startTime = cg.time;\n\tle->endTime = cg.time + 1000;\n\tle->lifeRate = 1.0 / ( le->endTime - le->startTime );\n\n\tle->color[0] = le->color[1] = le->color[2] = le->color[3] = 1.0;\n\n\tre = &le->refEntity;\n\n\tre->reType = RT_MODEL;\n\tre->shaderTime = cg.time / 1000.0f;\n\n\tre->hModel = cgs.media.invulnerabilityImpactModel;\n\n\tVectorCopy( org, re->origin );\n\tAnglesToAxis( angles, re->axis );\n\n\tr = rand() & 3;\n\tif ( r < 2 ) {\n\t\tsfx = cgs.media.invulnerabilityImpactSound1;\n\t} else if ( r == 2 ) {\n\t\tsfx = cgs.media.invulnerabilityImpactSound2;\n\t} else {\n\t\tsfx = cgs.media.invulnerabilityImpactSound3;\n\t}\n\ttrap_S_StartSound (org, ENTITYNUM_NONE, CHAN_BODY, sfx );\n}\n\n/*\n==================\nCG_InvulnerabilityJuiced\n==================\n*/\nvoid CG_InvulnerabilityJuiced( vec3_t org ) {\n\tlocalEntity_t\t*le;\n\trefEntity_t\t\t*re;\n\tvec3_t\t\t\tangles;\n\n\tle = CG_AllocLocalEntity();\n\tle->leFlags = 0;\n\tle->leType = LE_INVULJUICED;\n\tle->startTime = cg.time;\n\tle->endTime = cg.time + 10000;\n\tle->lifeRate = 1.0 / ( le->endTime - le->startTime );\n\n\tle->color[0] = le->color[1] = le->color[2] = le->color[3] = 1.0;\n\n\tre = &le->refEntity;\n\n\tre->reType = RT_MODEL;\n\tre->shaderTime = cg.time / 1000.0f;\n\n\tre->hModel = cgs.media.invulnerabilityJuicedModel;\n\n\tVectorCopy( org, re->origin );\n\tVectorClear(angles);\n\tAnglesToAxis( angles, re->axis );\n\n\ttrap_S_StartSound (org, ENTITYNUM_NONE, CHAN_BODY, cgs.media.invulnerabilityJuicedSound );\n}\n\n#endif\n\n/*\n==================\nCG_ScorePlum\n==================\n*/\nvoid CG_ScorePlum( int client, vec3_t org, int score ) {\n\tlocalEntity_t\t*le;\n\trefEntity_t\t\t*re;\n\tvec3_t\t\t\tangles;\n\tstatic vec3_t lastPos;\n\n\t// only visualize for the client that scored\n\tif (client != cg.predictedPlayerState.clientNum || cg_scorePlum.integer == 0) {\n\t\treturn;\n\t}\n\n\tle = CG_AllocLocalEntity();\n\tle->leFlags = 0;\n\tle->leType = LE_SCOREPLUM;\n\tle->startTime = cg.time;\n\tle->endTime = cg.time + 4000;\n\tle->lifeRate = 1.0 / ( le->endTime - le->startTime );\n\n\t\n\tle->color[0] = le->color[1] = le->color[2] = le->color[3] = 1.0;\n\tle->radius = score;\n\t\n\tVectorCopy( org, le->pos.trBase );\n\tif (org[2] >= lastPos[2] - 20 && org[2] <= lastPos[2] + 20) {\n\t\tle->pos.trBase[2] -= 20;\n\t}\n\n\t//CG_Printf( \"Plum origin %i %i %i -- %i\\n\", (int)org[0], (int)org[1], (int)org[2], (int)Distance(org, lastPos));\n\tVectorCopy(org, lastPos);\n\n\n\tre = &le->refEntity;\n\n\tre->reType = RT_SPRITE;\n\tre->radius = 16;\n\n\tVectorClear(angles);\n\tAnglesToAxis( angles, re->axis );\n}\n\n\n/*\n====================\nCG_MakeExplosion\n====================\n*/\nlocalEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, \n\t\t\t\t\t\t\t\tqhandle_t hModel, qhandle_t shader,\n\t\t\t\t\t\t\t\tint msec, qboolean isSprite ) {\n\tfloat\t\t\tang;\n\tlocalEntity_t\t*ex;\n\tint\t\t\t\toffset;\n\tvec3_t\t\t\ttmpVec, newOrigin;\n\n\tif ( msec <= 0 ) {\n\t\tCG_Error( \"CG_MakeExplosion: msec = %i\", msec );\n\t}\n\n\t// skew the time a bit so they aren't all in sync\n\toffset = rand() & 63;\n\n\tex = CG_AllocLocalEntity();\n\tif ( isSprite ) {\n\t\tex->leType = LE_SPRITE_EXPLOSION;\n\n\t\t// randomly rotate sprite orientation\n\t\tex->refEntity.rotation = rand() % 360;\n\t\tVectorScale( dir, 16, tmpVec );\n\t\tVectorAdd( tmpVec, origin, newOrigin );\n\t} else {\n\t\tex->leType = LE_EXPLOSION;\n\t\tVectorCopy( origin, newOrigin );\n\n\t\t// set axis with random rotate\n\t\tif ( !dir ) {\n\t\t\tAxisClear( ex->refEntity.axis );\n\t\t} else {\n\t\t\tang = rand() % 360;\n\t\t\tVectorCopy( dir, ex->refEntity.axis[0] );\n\t\t\tRotateAroundDirection( ex->refEntity.axis, ang );\n\t\t}\n\t}\n\n\tex->startTime = cg.time - offset;\n\tex->endTime = ex->startTime + msec;\n\n\t// bias the time so all shader effects start correctly\n\tex->refEntity.shaderTime = ex->startTime / 1000.0f;\n\n\tex->refEntity.hModel = hModel;\n\tex->refEntity.customShader = shader;\n\n\t// set origin\n\tVectorCopy( newOrigin, ex->refEntity.origin );\n\tVectorCopy( newOrigin, ex->refEntity.oldorigin );\n\n\tex->color[0] = ex->color[1] = ex->color[2] = 1.0;\n\n\treturn ex;\n}\n\n\n/*\n=================\nCG_Bleed\n\nThis is the spurt of blood when a character gets hit\n=================\n*/\nvoid CG_Bleed( vec3_t origin, int entityNum ) {\n\tlocalEntity_t\t*ex;\n\n\tif ( !cg_blood.integer ) {\n\t\treturn;\n\t}\n\n\tex = CG_AllocLocalEntity();\n\tex->leType = LE_EXPLOSION;\n\n\tex->startTime = cg.time;\n\tex->endTime = ex->startTime + 500;\n\t\n\tVectorCopy ( origin, ex->refEntity.origin);\n\tex->refEntity.reType = RT_SPRITE;\n\tex->refEntity.rotation = rand() % 360;\n\tex->refEntity.radius = 24;\n\n\tex->refEntity.customShader = cgs.media.bloodExplosionShader;\n\n\t// don't show player's own blood in view\n\tif ( entityNum == cg.snap->ps.clientNum ) {\n\t\tex->refEntity.renderfx |= RF_THIRD_PERSON;\n\t}\n}\n\n\n\n/*\n==================\nCG_LaunchGib\n==================\n*/\nvoid CG_LaunchGib( vec3_t origin, vec3_t velocity, qhandle_t hModel ) {\n\tlocalEntity_t\t*le;\n\trefEntity_t\t\t*re;\n\n\tle = CG_AllocLocalEntity();\n\tre = &le->refEntity;\n\n\tle->leType = LE_FRAGMENT;\n\tle->startTime = cg.time;\n\tle->endTime = le->startTime + 5000 + random() * 3000;\n\n\tVectorCopy( origin, re->origin );\n\tAxisCopy( axisDefault, re->axis );\n\tre->hModel = hModel;\n\n\tle->pos.trType = TR_GRAVITY;\n\tVectorCopy( origin, le->pos.trBase );\n\tVectorCopy( velocity, le->pos.trDelta );\n\tle->pos.trTime = cg.time;\n\n\tle->bounceFactor = 0.6f;\n\n\tle->leBounceSoundType = LEBS_BLOOD;\n\tle->leMarkType = LEMT_BLOOD;\n}\n\n/*\n===================\nCG_GibPlayer\n\nGenerated a bunch of gibs launching out from the bodies location\n===================\n*/\n#define\tGIB_VELOCITY\t250\n#define\tGIB_JUMP\t\t250\nvoid CG_GibPlayer( vec3_t playerOrigin ) {\n\tvec3_t\torigin, velocity;\n\n\tif ( !cg_blood.integer ) {\n\t\treturn;\n\t}\n\n\tVectorCopy( playerOrigin, origin );\n\tvelocity[0] = crandom()*GIB_VELOCITY;\n\tvelocity[1] = crandom()*GIB_VELOCITY;\n\tvelocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY;\n\tif ( rand() & 1 ) {\n\t\tCG_LaunchGib( origin, velocity, cgs.media.gibSkull );\n\t} else {\n\t\tCG_LaunchGib( origin, velocity, cgs.media.gibBrain );\n\t}\n\n\t// allow gibs to be turned off for speed\n\tif ( !cg_gibs.integer ) {\n\t\treturn;\n\t}\n\n\tVectorCopy( playerOrigin, origin );\n\tvelocity[0] = crandom()*GIB_VELOCITY;\n\tvelocity[1] = crandom()*GIB_VELOCITY;\n\tvelocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY;\n\tCG_LaunchGib( origin, velocity, cgs.media.gibAbdomen );\n\n\tVectorCopy( playerOrigin, origin );\n\tvelocity[0] = crandom()*GIB_VELOCITY;\n\tvelocity[1] = crandom()*GIB_VELOCITY;\n\tvelocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY;\n\tCG_LaunchGib( origin, velocity, cgs.media.gibArm );\n\n\tVectorCopy( playerOrigin, origin );\n\tvelocity[0] = crandom()*GIB_VELOCITY;\n\tvelocity[1] = crandom()*GIB_VELOCITY;\n\tvelocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY;\n\tCG_LaunchGib( origin, velocity, cgs.media.gibChest );\n\n\tVectorCopy( playerOrigin, origin );\n\tvelocity[0] = crandom()*GIB_VELOCITY;\n\tvelocity[1] = crandom()*GIB_VELOCITY;\n\tvelocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY;\n\tCG_LaunchGib( origin, velocity, cgs.media.gibFist );\n\n\tVectorCopy( playerOrigin, origin );\n\tvelocity[0] = crandom()*GIB_VELOCITY;\n\tvelocity[1] = crandom()*GIB_VELOCITY;\n\tvelocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY;\n\tCG_LaunchGib( origin, velocity, cgs.media.gibFoot );\n\n\tVectorCopy( playerOrigin, origin );\n\tvelocity[0] = crandom()*GIB_VELOCITY;\n\tvelocity[1] = crandom()*GIB_VELOCITY;\n\tvelocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY;\n\tCG_LaunchGib( origin, velocity, cgs.media.gibForearm );\n\n\tVectorCopy( playerOrigin, origin );\n\tvelocity[0] = crandom()*GIB_VELOCITY;\n\tvelocity[1] = crandom()*GIB_VELOCITY;\n\tvelocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY;\n\tCG_LaunchGib( origin, velocity, cgs.media.gibIntestine );\n\n\tVectorCopy( playerOrigin, origin );\n\tvelocity[0] = crandom()*GIB_VELOCITY;\n\tvelocity[1] = crandom()*GIB_VELOCITY;\n\tvelocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY;\n\tCG_LaunchGib( origin, velocity, cgs.media.gibLeg );\n\n\tVectorCopy( playerOrigin, origin );\n\tvelocity[0] = crandom()*GIB_VELOCITY;\n\tvelocity[1] = crandom()*GIB_VELOCITY;\n\tvelocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY;\n\tCG_LaunchGib( origin, velocity, cgs.media.gibLeg );\n}\n\n/*\n==================\nCG_LaunchGib\n==================\n*/\nvoid CG_LaunchExplode( vec3_t origin, vec3_t velocity, qhandle_t hModel ) {\n\tlocalEntity_t\t*le;\n\trefEntity_t\t\t*re;\n\n\tle = CG_AllocLocalEntity();\n\tre = &le->refEntity;\n\n\tle->leType = LE_FRAGMENT;\n\tle->startTime = cg.time;\n\tle->endTime = le->startTime + 10000 + random() * 6000;\n\n\tVectorCopy( origin, re->origin );\n\tAxisCopy( axisDefault, re->axis );\n\tre->hModel = hModel;\n\n\tle->pos.trType = TR_GRAVITY;\n\tVectorCopy( origin, le->pos.trBase );\n\tVectorCopy( velocity, le->pos.trDelta );\n\tle->pos.trTime = cg.time;\n\n\tle->bounceFactor = 0.1f;\n\n\tle->leBounceSoundType = LEBS_BRASS;\n\tle->leMarkType = LEMT_NONE;\n}\n\n#define\tEXP_VELOCITY\t100\n#define\tEXP_JUMP\t\t150\n/*\n===================\nCG_GibPlayer\n\nGenerated a bunch of gibs launching out from the bodies location\n===================\n*/\nvoid CG_BigExplode( vec3_t playerOrigin ) {\n\tvec3_t\torigin, velocity;\n\n\tif ( !cg_blood.integer ) {\n\t\treturn;\n\t}\n\n\tVectorCopy( playerOrigin, origin );\n\tvelocity[0] = crandom()*EXP_VELOCITY;\n\tvelocity[1] = crandom()*EXP_VELOCITY;\n\tvelocity[2] = EXP_JUMP + crandom()*EXP_VELOCITY;\n\tCG_LaunchExplode( origin, velocity, cgs.media.smoke2 );\n\n\tVectorCopy( playerOrigin, origin );\n\tvelocity[0] = crandom()*EXP_VELOCITY;\n\tvelocity[1] = crandom()*EXP_VELOCITY;\n\tvelocity[2] = EXP_JUMP + crandom()*EXP_VELOCITY;\n\tCG_LaunchExplode( origin, velocity, cgs.media.smoke2 );\n\n\tVectorCopy( playerOrigin, origin );\n\tvelocity[0] = crandom()*EXP_VELOCITY*1.5;\n\tvelocity[1] = crandom()*EXP_VELOCITY*1.5;\n\tvelocity[2] = EXP_JUMP + crandom()*EXP_VELOCITY;\n\tCG_LaunchExplode( origin, velocity, cgs.media.smoke2 );\n\n\tVectorCopy( playerOrigin, origin );\n\tvelocity[0] = crandom()*EXP_VELOCITY*2.0;\n\tvelocity[1] = crandom()*EXP_VELOCITY*2.0;\n\tvelocity[2] = EXP_JUMP + crandom()*EXP_VELOCITY;\n\tCG_LaunchExplode( origin, velocity, cgs.media.smoke2 );\n\n\tVectorCopy( playerOrigin, origin );\n\tvelocity[0] = crandom()*EXP_VELOCITY*2.5;\n\tvelocity[1] = crandom()*EXP_VELOCITY*2.5;\n\tvelocity[2] = EXP_JUMP + crandom()*EXP_VELOCITY;\n\tCG_LaunchExplode( origin, velocity, cgs.media.smoke2 );\n}\n\n"
  },
  {
    "path": "code/cgame/cg_ents.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// cg_ents.c -- present snapshot entities, happens every single frame\n\n#include \"cg_local.h\"\n\n\n/*\n======================\nCG_PositionEntityOnTag\n\nModifies the entities position and axis by the given\ntag location\n======================\n*/\nvoid CG_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent, \n\t\t\t\t\t\t\tqhandle_t parentModel, char *tagName ) {\n\tint\t\t\t\ti;\n\torientation_t\tlerped;\n\t\n\t// lerp the tag\n\ttrap_R_LerpTag( &lerped, parentModel, parent->oldframe, parent->frame,\n\t\t1.0 - parent->backlerp, tagName );\n\n\t// FIXME: allow origin offsets along tag?\n\tVectorCopy( parent->origin, entity->origin );\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tVectorMA( entity->origin, lerped.origin[i], parent->axis[i], entity->origin );\n\t}\n\n\t// had to cast away the const to avoid compiler problems...\n\tMatrixMultiply( lerped.axis, ((refEntity_t *)parent)->axis, entity->axis );\n\tentity->backlerp = parent->backlerp;\n}\n\n\n/*\n======================\nCG_PositionRotatedEntityOnTag\n\nModifies the entities position and axis by the given\ntag location\n======================\n*/\nvoid CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *parent, \n\t\t\t\t\t\t\tqhandle_t parentModel, char *tagName ) {\n\tint\t\t\t\ti;\n\torientation_t\tlerped;\n\tvec3_t\t\t\ttempAxis[3];\n\n//AxisClear( entity->axis );\n\t// lerp the tag\n\ttrap_R_LerpTag( &lerped, parentModel, parent->oldframe, parent->frame,\n\t\t1.0 - parent->backlerp, tagName );\n\n\t// FIXME: allow origin offsets along tag?\n\tVectorCopy( parent->origin, entity->origin );\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tVectorMA( entity->origin, lerped.origin[i], parent->axis[i], entity->origin );\n\t}\n\n\t// had to cast away the const to avoid compiler problems...\n\tMatrixMultiply( entity->axis, lerped.axis, tempAxis );\n\tMatrixMultiply( tempAxis, ((refEntity_t *)parent)->axis, entity->axis );\n}\n\n\n\n/*\n==========================================================================\n\nFUNCTIONS CALLED EACH FRAME\n\n==========================================================================\n*/\n\n/*\n======================\nCG_SetEntitySoundPosition\n\nAlso called by event processing code\n======================\n*/\nvoid CG_SetEntitySoundPosition( centity_t *cent ) {\n\tif ( cent->currentState.solid == SOLID_BMODEL ) {\n\t\tvec3_t\torigin;\n\t\tfloat\t*v;\n\n\t\tv = cgs.inlineModelMidpoints[ cent->currentState.modelindex ];\n\t\tVectorAdd( cent->lerpOrigin, v, origin );\n\t\ttrap_S_UpdateEntityPosition( cent->currentState.number, origin );\n\t} else {\n\t\ttrap_S_UpdateEntityPosition( cent->currentState.number, cent->lerpOrigin );\n\t}\n}\n\n/*\n==================\nCG_EntityEffects\n\nAdd continuous entity effects, like local entity emission and lighting\n==================\n*/\nstatic void CG_EntityEffects( centity_t *cent ) {\n\n\t// update sound origins\n\tCG_SetEntitySoundPosition( cent );\n\n\t// add loop sound\n\tif ( cent->currentState.loopSound ) {\n\t\tif (cent->currentState.eType != ET_SPEAKER) {\n\t\t\ttrap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, \n\t\t\t\tcgs.gameSounds[ cent->currentState.loopSound ] );\n\t\t} else {\n\t\t\ttrap_S_AddRealLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, \n\t\t\t\tcgs.gameSounds[ cent->currentState.loopSound ] );\n\t\t}\n\t}\n\n\n\t// constant light glow\n\tif ( cent->currentState.constantLight ) {\n\t\tint\t\tcl;\n\t\tint\t\ti, r, g, b;\n\n\t\tcl = cent->currentState.constantLight;\n\t\tr = cl & 255;\n\t\tg = ( cl >> 8 ) & 255;\n\t\tb = ( cl >> 16 ) & 255;\n\t\ti = ( ( cl >> 24 ) & 255 ) * 4;\n\t\ttrap_R_AddLightToScene( cent->lerpOrigin, i, r, g, b );\n\t}\n\n}\n\n\n/*\n==================\nCG_General\n==================\n*/\nstatic void CG_General( centity_t *cent ) {\n\trefEntity_t\t\t\tent;\n\tentityState_t\t\t*s1;\n\n\ts1 = &cent->currentState;\n\n\t// if set to invisible, skip\n\tif (!s1->modelindex) {\n\t\treturn;\n\t}\n\n\tmemset (&ent, 0, sizeof(ent));\n\n\t// set frame\n\n\tent.frame = s1->frame;\n\tent.oldframe = ent.frame;\n\tent.backlerp = 0;\n\n\tVectorCopy( cent->lerpOrigin, ent.origin);\n\tVectorCopy( cent->lerpOrigin, ent.oldorigin);\n\n\tent.hModel = cgs.gameModels[s1->modelindex];\n\n\t// player model\n\tif (s1->number == cg.snap->ps.clientNum) {\n\t\tent.renderfx |= RF_THIRD_PERSON;\t// only draw from mirrors\n\t}\n\n\t// convert angles to axis\n\tAnglesToAxis( cent->lerpAngles, ent.axis );\n\n\t// add to refresh list\n\ttrap_R_AddRefEntityToScene (&ent);\n}\n\n/*\n==================\nCG_Speaker\n\nSpeaker entities can automatically play sounds\n==================\n*/\nstatic void CG_Speaker( centity_t *cent ) {\n\tif ( ! cent->currentState.clientNum ) {\t// FIXME: use something other than clientNum...\n\t\treturn;\t\t// not auto triggering\n\t}\n\n\tif ( cg.time < cent->miscTime ) {\n\t\treturn;\n\t}\n\n\ttrap_S_StartSound (NULL, cent->currentState.number, CHAN_ITEM, cgs.gameSounds[cent->currentState.eventParm] );\n\n\t//\tent->s.frame = ent->wait * 10;\n\t//\tent->s.clientNum = ent->random * 10;\n\tcent->miscTime = cg.time + cent->currentState.frame * 100 + cent->currentState.clientNum * 100 * crandom();\n}\n\n/*\n==================\nCG_Item\n==================\n*/\nstatic void CG_Item( centity_t *cent ) {\n\trefEntity_t\t\tent;\n\tentityState_t\t*es;\n\tgitem_t\t\t\t*item;\n\tint\t\t\t\tmsec;\n\tfloat\t\t\tfrac;\n\tfloat\t\t\tscale;\n\tweaponInfo_t\t*wi;\n\n\tes = &cent->currentState;\n\tif ( es->modelindex >= bg_numItems ) {\n\t\tCG_Error( \"Bad item index %i on entity\", es->modelindex );\n\t}\n\n\t// if set to invisible, skip\n\tif ( !es->modelindex || ( es->eFlags & EF_NODRAW ) ) {\n\t\treturn;\n\t}\n\n\titem = &bg_itemlist[ es->modelindex ];\n\tif ( cg_simpleItems.integer && item->giType != IT_TEAM ) {\n\t\tmemset( &ent, 0, sizeof( ent ) );\n\t\tent.reType = RT_SPRITE;\n\t\tVectorCopy( cent->lerpOrigin, ent.origin );\n\t\tent.radius = 14;\n\t\tent.customShader = cg_items[es->modelindex].icon;\n\t\tent.shaderRGBA[0] = 255;\n\t\tent.shaderRGBA[1] = 255;\n\t\tent.shaderRGBA[2] = 255;\n\t\tent.shaderRGBA[3] = 255;\n\t\ttrap_R_AddRefEntityToScene(&ent);\n\t\treturn;\n\t}\n\n\t// items bob up and down continuously\n\tscale = 0.005 + cent->currentState.number * 0.00001;\n\tcent->lerpOrigin[2] += 4 + cos( ( cg.time + 1000 ) *  scale ) * 4;\n\n\tmemset (&ent, 0, sizeof(ent));\n\n\t// autorotate at one of two speeds\n\tif ( item->giType == IT_HEALTH ) {\n\t\tVectorCopy( cg.autoAnglesFast, cent->lerpAngles );\n\t\tAxisCopy( cg.autoAxisFast, ent.axis );\n\t} else {\n\t\tVectorCopy( cg.autoAngles, cent->lerpAngles );\n\t\tAxisCopy( cg.autoAxis, ent.axis );\n\t}\n\n\twi = NULL;\n\t// the weapons have their origin where they attatch to player\n\t// models, so we need to offset them or they will rotate\n\t// eccentricly\n\tif ( item->giType == IT_WEAPON ) {\n\t\twi = &cg_weapons[item->giTag];\n\t\tcent->lerpOrigin[0] -= \n\t\t\twi->weaponMidpoint[0] * ent.axis[0][0] +\n\t\t\twi->weaponMidpoint[1] * ent.axis[1][0] +\n\t\t\twi->weaponMidpoint[2] * ent.axis[2][0];\n\t\tcent->lerpOrigin[1] -= \n\t\t\twi->weaponMidpoint[0] * ent.axis[0][1] +\n\t\t\twi->weaponMidpoint[1] * ent.axis[1][1] +\n\t\t\twi->weaponMidpoint[2] * ent.axis[2][1];\n\t\tcent->lerpOrigin[2] -= \n\t\t\twi->weaponMidpoint[0] * ent.axis[0][2] +\n\t\t\twi->weaponMidpoint[1] * ent.axis[1][2] +\n\t\t\twi->weaponMidpoint[2] * ent.axis[2][2];\n\n\t\tcent->lerpOrigin[2] += 8;\t// an extra height boost\n\t}\n\n\tent.hModel = cg_items[es->modelindex].models[0];\n\n\tVectorCopy( cent->lerpOrigin, ent.origin);\n\tVectorCopy( cent->lerpOrigin, ent.oldorigin);\n\n\tent.nonNormalizedAxes = qfalse;\n\n\t// if just respawned, slowly scale up\n\tmsec = cg.time - cent->miscTime;\n\tif ( msec >= 0 && msec < ITEM_SCALEUP_TIME ) {\n\t\tfrac = (float)msec / ITEM_SCALEUP_TIME;\n\t\tVectorScale( ent.axis[0], frac, ent.axis[0] );\n\t\tVectorScale( ent.axis[1], frac, ent.axis[1] );\n\t\tVectorScale( ent.axis[2], frac, ent.axis[2] );\n\t\tent.nonNormalizedAxes = qtrue;\n\t} else {\n\t\tfrac = 1.0;\n\t}\n\n\t// items without glow textures need to keep a minimum light value\n\t// so they are always visible\n\tif ( ( item->giType == IT_WEAPON ) ||\n\t\t ( item->giType == IT_ARMOR ) ) {\n\t\tent.renderfx |= RF_MINLIGHT;\n\t}\n\n\t// increase the size of the weapons when they are presented as items\n\tif ( item->giType == IT_WEAPON ) {\n\t\tVectorScale( ent.axis[0], 1.5, ent.axis[0] );\n\t\tVectorScale( ent.axis[1], 1.5, ent.axis[1] );\n\t\tVectorScale( ent.axis[2], 1.5, ent.axis[2] );\n\t\tent.nonNormalizedAxes = qtrue;\n#ifdef MISSIONPACK\n\t\ttrap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, cgs.media.weaponHoverSound );\n#endif\n\t}\n\n#ifdef MISSIONPACK\n\tif ( item->giType == IT_HOLDABLE && item->giTag == HI_KAMIKAZE ) {\n\t\tVectorScale( ent.axis[0], 2, ent.axis[0] );\n\t\tVectorScale( ent.axis[1], 2, ent.axis[1] );\n\t\tVectorScale( ent.axis[2], 2, ent.axis[2] );\n\t\tent.nonNormalizedAxes = qtrue;\n\t}\n#endif\n\n\t// add to refresh list\n\ttrap_R_AddRefEntityToScene(&ent);\n\n#ifdef MISSIONPACK\n\tif ( item->giType == IT_WEAPON && wi->barrelModel ) {\n\t\trefEntity_t\tbarrel;\n\n\t\tmemset( &barrel, 0, sizeof( barrel ) );\n\n\t\tbarrel.hModel = wi->barrelModel;\n\n\t\tVectorCopy( ent.lightingOrigin, barrel.lightingOrigin );\n\t\tbarrel.shadowPlane = ent.shadowPlane;\n\t\tbarrel.renderfx = ent.renderfx;\n\n\t\tCG_PositionRotatedEntityOnTag( &barrel, &ent, wi->weaponModel, \"tag_barrel\" );\n\n\t\tAxisCopy( ent.axis, barrel.axis );\n\t\tbarrel.nonNormalizedAxes = ent.nonNormalizedAxes;\n\n\t\ttrap_R_AddRefEntityToScene( &barrel );\n\t}\n#endif\n\n\t// accompanying rings / spheres for powerups\n\tif ( !cg_simpleItems.integer ) \n\t{\n\t\tvec3_t spinAngles;\n\n\t\tVectorClear( spinAngles );\n\n\t\tif ( item->giType == IT_HEALTH || item->giType == IT_POWERUP )\n\t\t{\n\t\t\tif ( ( ent.hModel = cg_items[es->modelindex].models[1] ) != 0 )\n\t\t\t{\n\t\t\t\tif ( item->giType == IT_POWERUP )\n\t\t\t\t{\n\t\t\t\t\tent.origin[2] += 12;\n\t\t\t\t\tspinAngles[1] = ( cg.time & 1023 ) * 360 / -1024.0f;\n\t\t\t\t}\n\t\t\t\tAnglesToAxis( spinAngles, ent.axis );\n\t\t\t\t\n\t\t\t\t// scale up if respawning\n\t\t\t\tif ( frac != 1.0 ) {\n\t\t\t\t\tVectorScale( ent.axis[0], frac, ent.axis[0] );\n\t\t\t\t\tVectorScale( ent.axis[1], frac, ent.axis[1] );\n\t\t\t\t\tVectorScale( ent.axis[2], frac, ent.axis[2] );\n\t\t\t\t\tent.nonNormalizedAxes = qtrue;\n\t\t\t\t}\n\t\t\t\ttrap_R_AddRefEntityToScene( &ent );\n\t\t\t}\n\t\t}\n\t}\n}\n\n//============================================================================\n\n/*\n===============\nCG_Missile\n===============\n*/\nstatic void CG_Missile( centity_t *cent ) {\n\trefEntity_t\t\t\tent;\n\tentityState_t\t\t*s1;\n\tconst weaponInfo_t\t\t*weapon;\n//\tint\tcol;\n\n\ts1 = &cent->currentState;\n\tif ( s1->weapon > WP_NUM_WEAPONS ) {\n\t\ts1->weapon = 0;\n\t}\n\tweapon = &cg_weapons[s1->weapon];\n\n\t// calculate the axis\n\tVectorCopy( s1->angles, cent->lerpAngles);\n\n\t// add trails\n\tif ( weapon->missileTrailFunc ) \n\t{\n\t\tweapon->missileTrailFunc( cent, weapon );\n\t}\n/*\n\tif ( cent->currentState.modelindex == TEAM_RED ) {\n\t\tcol = 1;\n\t}\n\telse if ( cent->currentState.modelindex == TEAM_BLUE ) {\n\t\tcol = 2;\n\t}\n\telse {\n\t\tcol = 0;\n\t}\n\n\t// add dynamic light\n\tif ( weapon->missileDlight ) {\n\t\ttrap_R_AddLightToScene(cent->lerpOrigin, weapon->missileDlight, \n\t\t\tweapon->missileDlightColor[col][0], weapon->missileDlightColor[col][1], weapon->missileDlightColor[col][2] );\n\t}\n*/\n\t// add dynamic light\n\tif ( weapon->missileDlight ) {\n\t\ttrap_R_AddLightToScene(cent->lerpOrigin, weapon->missileDlight, \n\t\t\tweapon->missileDlightColor[0], weapon->missileDlightColor[1], weapon->missileDlightColor[2] );\n\t}\n\n\t// add missile sound\n\tif ( weapon->missileSound ) {\n\t\tvec3_t\tvelocity;\n\n\t\tBG_EvaluateTrajectoryDelta( &cent->currentState.pos, cg.time, velocity );\n\n\t\ttrap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, velocity, weapon->missileSound );\n\t}\n\n\t// create the render entity\n\tmemset (&ent, 0, sizeof(ent));\n\tVectorCopy( cent->lerpOrigin, ent.origin);\n\tVectorCopy( cent->lerpOrigin, ent.oldorigin);\n\n\tif ( cent->currentState.weapon == WP_PLASMAGUN ) {\n\t\tent.reType = RT_SPRITE;\n\t\tent.radius = 16;\n\t\tent.rotation = 0;\n\t\tent.customShader = cgs.media.plasmaBallShader;\n\t\ttrap_R_AddRefEntityToScene( &ent );\n\t\treturn;\n\t}\n\n\t// flicker between two skins\n\tent.skinNum = cg.clientFrame & 1;\n\tent.hModel = weapon->missileModel;\n\tent.renderfx = weapon->missileRenderfx | RF_NOSHADOW;\n\n#ifdef MISSIONPACK\n\tif ( cent->currentState.weapon == WP_PROX_LAUNCHER ) {\n\t\tif (s1->generic1 == TEAM_BLUE) {\n\t\t\tent.hModel = cgs.media.blueProxMine;\n\t\t}\n\t}\n#endif\n\n\t// convert direction of travel into axis\n\tif ( VectorNormalize2( s1->pos.trDelta, ent.axis[0] ) == 0 ) {\n\t\tent.axis[0][2] = 1;\n\t}\n\n\t// spin as it moves\n\tif ( s1->pos.trType != TR_STATIONARY ) {\n\t\tRotateAroundDirection( ent.axis, cg.time / 4 );\n\t} else {\n#ifdef MISSIONPACK\n\t\tif ( s1->weapon == WP_PROX_LAUNCHER ) {\n\t\t\tAnglesToAxis( cent->lerpAngles, ent.axis );\n\t\t}\n\t\telse\n#endif\n\t\t{\n\t\t\tRotateAroundDirection( ent.axis, s1->time );\n\t\t}\n\t}\n\n\t// add to refresh list, possibly with quad glow\n\tCG_AddRefEntityWithPowerups( &ent, s1, TEAM_FREE );\n}\n\n/*\n===============\nCG_Grapple\n\nThis is called when the grapple is sitting up against the wall\n===============\n*/\nstatic void CG_Grapple( centity_t *cent ) {\n\trefEntity_t\t\t\tent;\n\tentityState_t\t\t*s1;\n\tconst weaponInfo_t\t\t*weapon;\n\n\ts1 = &cent->currentState;\n\tif ( s1->weapon > WP_NUM_WEAPONS ) {\n\t\ts1->weapon = 0;\n\t}\n\tweapon = &cg_weapons[s1->weapon];\n\n\t// calculate the axis\n\tVectorCopy( s1->angles, cent->lerpAngles);\n\n#if 0 // FIXME add grapple pull sound here..?\n\t// add missile sound\n\tif ( weapon->missileSound ) {\n\t\ttrap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, weapon->missileSound );\n\t}\n#endif\n\n\t// Will draw cable if needed\n\tCG_GrappleTrail ( cent, weapon );\n\n\t// create the render entity\n\tmemset (&ent, 0, sizeof(ent));\n\tVectorCopy( cent->lerpOrigin, ent.origin);\n\tVectorCopy( cent->lerpOrigin, ent.oldorigin);\n\n\t// flicker between two skins\n\tent.skinNum = cg.clientFrame & 1;\n\tent.hModel = weapon->missileModel;\n\tent.renderfx = weapon->missileRenderfx | RF_NOSHADOW;\n\n\t// convert direction of travel into axis\n\tif ( VectorNormalize2( s1->pos.trDelta, ent.axis[0] ) == 0 ) {\n\t\tent.axis[0][2] = 1;\n\t}\n\n\ttrap_R_AddRefEntityToScene( &ent );\n}\n\n/*\n===============\nCG_Mover\n===============\n*/\nstatic void CG_Mover( centity_t *cent ) {\n\trefEntity_t\t\t\tent;\n\tentityState_t\t\t*s1;\n\n\ts1 = &cent->currentState;\n\n\t// create the render entity\n\tmemset (&ent, 0, sizeof(ent));\n\tVectorCopy( cent->lerpOrigin, ent.origin);\n\tVectorCopy( cent->lerpOrigin, ent.oldorigin);\n\tAnglesToAxis( cent->lerpAngles, ent.axis );\n\n\tent.renderfx = RF_NOSHADOW;\n\n\t// flicker between two skins (FIXME?)\n\tent.skinNum = ( cg.time >> 6 ) & 1;\n\n\t// get the model, either as a bmodel or a modelindex\n\tif ( s1->solid == SOLID_BMODEL ) {\n\t\tent.hModel = cgs.inlineDrawModel[s1->modelindex];\n\t} else {\n\t\tent.hModel = cgs.gameModels[s1->modelindex];\n\t}\n\n\t// add to refresh list\n\ttrap_R_AddRefEntityToScene(&ent);\n\n\t// add the secondary model\n\tif ( s1->modelindex2 ) {\n\t\tent.skinNum = 0;\n\t\tent.hModel = cgs.gameModels[s1->modelindex2];\n\t\ttrap_R_AddRefEntityToScene(&ent);\n\t}\n\n}\n\n/*\n===============\nCG_Beam\n\nAlso called as an event\n===============\n*/\nvoid CG_Beam( centity_t *cent ) {\n\trefEntity_t\t\t\tent;\n\tentityState_t\t\t*s1;\n\n\ts1 = &cent->currentState;\n\n\t// create the render entity\n\tmemset (&ent, 0, sizeof(ent));\n\tVectorCopy( s1->pos.trBase, ent.origin );\n\tVectorCopy( s1->origin2, ent.oldorigin );\n\tAxisClear( ent.axis );\n\tent.reType = RT_BEAM;\n\n\tent.renderfx = RF_NOSHADOW;\n\n\t// add to refresh list\n\ttrap_R_AddRefEntityToScene(&ent);\n}\n\n\n/*\n===============\nCG_Portal\n===============\n*/\nstatic void CG_Portal( centity_t *cent ) {\n\trefEntity_t\t\t\tent;\n\tentityState_t\t\t*s1;\n\n\ts1 = &cent->currentState;\n\n\t// create the render entity\n\tmemset (&ent, 0, sizeof(ent));\n\tVectorCopy( cent->lerpOrigin, ent.origin );\n\tVectorCopy( s1->origin2, ent.oldorigin );\n\tByteToDir( s1->eventParm, ent.axis[0] );\n\tPerpendicularVector( ent.axis[1], ent.axis[0] );\n\n\t// negating this tends to get the directions like they want\n\t// we really should have a camera roll value\n\tVectorSubtract( vec3_origin, ent.axis[1], ent.axis[1] );\n\n\tCrossProduct( ent.axis[0], ent.axis[1], ent.axis[2] );\n\tent.reType = RT_PORTALSURFACE;\n\tent.oldframe = s1->powerups;\n\tent.frame = s1->frame;\t\t// rotation speed\n\tent.skinNum = s1->clientNum/256.0 * 360;\t// roll offset\n\n\t// add to refresh list\n\ttrap_R_AddRefEntityToScene(&ent);\n}\n\n\n/*\n=========================\nCG_AdjustPositionForMover\n\nAlso called by client movement prediction code\n=========================\n*/\nvoid CG_AdjustPositionForMover( const vec3_t in, int moverNum, int fromTime, int toTime, vec3_t out ) {\n\tcentity_t\t*cent;\n\tvec3_t\toldOrigin, origin, deltaOrigin;\n\tvec3_t\toldAngles, angles, deltaAngles;\n\n\tif ( moverNum <= 0 || moverNum >= ENTITYNUM_MAX_NORMAL ) {\n\t\tVectorCopy( in, out );\n\t\treturn;\n\t}\n\n\tcent = &cg_entities[ moverNum ];\n\tif ( cent->currentState.eType != ET_MOVER ) {\n\t\tVectorCopy( in, out );\n\t\treturn;\n\t}\n\n\tBG_EvaluateTrajectory( &cent->currentState.pos, fromTime, oldOrigin );\n\tBG_EvaluateTrajectory( &cent->currentState.apos, fromTime, oldAngles );\n\n\tBG_EvaluateTrajectory( &cent->currentState.pos, toTime, origin );\n\tBG_EvaluateTrajectory( &cent->currentState.apos, toTime, angles );\n\n\tVectorSubtract( origin, oldOrigin, deltaOrigin );\n\tVectorSubtract( angles, oldAngles, deltaAngles );\n\n\tVectorAdd( in, deltaOrigin, out );\n\n\t// FIXME: origin change when on a rotating object\n}\n\n\n/*\n=============================\nCG_InterpolateEntityPosition\n=============================\n*/\nstatic void CG_InterpolateEntityPosition( centity_t *cent ) {\n\tvec3_t\t\tcurrent, next;\n\tfloat\t\tf;\n\n\t// it would be an internal error to find an entity that interpolates without\n\t// a snapshot ahead of the current one\n\tif ( cg.nextSnap == NULL ) {\n\t\tCG_Error( \"CG_InterpoateEntityPosition: cg.nextSnap == NULL\" );\n\t}\n\n\tf = cg.frameInterpolation;\n\n\t// this will linearize a sine or parabolic curve, but it is important\n\t// to not extrapolate player positions if more recent data is available\n\tBG_EvaluateTrajectory( &cent->currentState.pos, cg.snap->serverTime, current );\n\tBG_EvaluateTrajectory( &cent->nextState.pos, cg.nextSnap->serverTime, next );\n\n\tcent->lerpOrigin[0] = current[0] + f * ( next[0] - current[0] );\n\tcent->lerpOrigin[1] = current[1] + f * ( next[1] - current[1] );\n\tcent->lerpOrigin[2] = current[2] + f * ( next[2] - current[2] );\n\n\tBG_EvaluateTrajectory( &cent->currentState.apos, cg.snap->serverTime, current );\n\tBG_EvaluateTrajectory( &cent->nextState.apos, cg.nextSnap->serverTime, next );\n\n\tcent->lerpAngles[0] = LerpAngle( current[0], next[0], f );\n\tcent->lerpAngles[1] = LerpAngle( current[1], next[1], f );\n\tcent->lerpAngles[2] = LerpAngle( current[2], next[2], f );\n\n}\n\n/*\n===============\nCG_CalcEntityLerpPositions\n\n===============\n*/\nstatic void CG_CalcEntityLerpPositions( centity_t *cent ) {\n\n\t// if this player does not want to see extrapolated players\n\tif ( !cg_smoothClients.integer ) {\n\t\t// make sure the clients use TR_INTERPOLATE\n\t\tif ( cent->currentState.number < MAX_CLIENTS ) {\n\t\t\tcent->currentState.pos.trType = TR_INTERPOLATE;\n\t\t\tcent->nextState.pos.trType = TR_INTERPOLATE;\n\t\t}\n\t}\n\n\tif ( cent->interpolate && cent->currentState.pos.trType == TR_INTERPOLATE ) {\n\t\tCG_InterpolateEntityPosition( cent );\n\t\treturn;\n\t}\n\n\t// first see if we can interpolate between two snaps for\n\t// linear extrapolated clients\n\tif ( cent->interpolate && cent->currentState.pos.trType == TR_LINEAR_STOP &&\n\t\t\t\t\t\t\t\t\t\t\tcent->currentState.number < MAX_CLIENTS) {\n\t\tCG_InterpolateEntityPosition( cent );\n\t\treturn;\n\t}\n\n\t// just use the current frame and evaluate as best we can\n\tBG_EvaluateTrajectory( &cent->currentState.pos, cg.time, cent->lerpOrigin );\n\tBG_EvaluateTrajectory( &cent->currentState.apos, cg.time, cent->lerpAngles );\n\n\t// adjust for riding a mover if it wasn't rolled into the predicted\n\t// player state\n\tif ( cent != &cg.predictedPlayerEntity ) {\n\t\tCG_AdjustPositionForMover( cent->lerpOrigin, cent->currentState.groundEntityNum, \n\t\tcg.snap->serverTime, cg.time, cent->lerpOrigin );\n\t}\n}\n\n/*\n===============\nCG_TeamBase\n===============\n*/\nstatic void CG_TeamBase( centity_t *cent ) {\n\trefEntity_t model;\n#ifdef MISSIONPACK\n\tvec3_t angles;\n\tint t, h;\n\tfloat c;\n\n\tif ( cgs.gametype == GT_CTF || cgs.gametype == GT_1FCTF ) {\n#else\n\tif ( cgs.gametype == GT_CTF) {\n#endif\n\t\t// show the flag base\n\t\tmemset(&model, 0, sizeof(model));\n\t\tmodel.reType = RT_MODEL;\n\t\tVectorCopy( cent->lerpOrigin, model.lightingOrigin );\n\t\tVectorCopy( cent->lerpOrigin, model.origin );\n\t\tAnglesToAxis( cent->currentState.angles, model.axis );\n\t\tif ( cent->currentState.modelindex == TEAM_RED ) {\n\t\t\tmodel.hModel = cgs.media.redFlagBaseModel;\n\t\t}\n\t\telse if ( cent->currentState.modelindex == TEAM_BLUE ) {\n\t\t\tmodel.hModel = cgs.media.blueFlagBaseModel;\n\t\t}\n\t\telse {\n\t\t\tmodel.hModel = cgs.media.neutralFlagBaseModel;\n\t\t}\n\t\ttrap_R_AddRefEntityToScene( &model );\n\t}\n#ifdef MISSIONPACK\n\telse if ( cgs.gametype == GT_OBELISK ) {\n\t\t// show the obelisk\n\t\tmemset(&model, 0, sizeof(model));\n\t\tmodel.reType = RT_MODEL;\n\t\tVectorCopy( cent->lerpOrigin, model.lightingOrigin );\n\t\tVectorCopy( cent->lerpOrigin, model.origin );\n\t\tAnglesToAxis( cent->currentState.angles, model.axis );\n\n\t\tmodel.hModel = cgs.media.overloadBaseModel;\n\t\ttrap_R_AddRefEntityToScene( &model );\n\t\t// if hit\n\t\tif ( cent->currentState.frame == 1) {\n\t\t\t// show hit model\n\t\t\t// modelindex2 is the health value of the obelisk\n\t\t\tc = cent->currentState.modelindex2;\n\t\t\tmodel.shaderRGBA[0] = 0xff;\n\t\t\tmodel.shaderRGBA[1] = c;\n\t\t\tmodel.shaderRGBA[2] = c;\n\t\t\tmodel.shaderRGBA[3] = 0xff;\n\t\t\t//\n\t\t\tmodel.hModel = cgs.media.overloadEnergyModel;\n\t\t\ttrap_R_AddRefEntityToScene( &model );\n\t\t}\n\t\t// if respawning\n\t\tif ( cent->currentState.frame == 2) {\n\t\t\tif ( !cent->miscTime ) {\n\t\t\t\tcent->miscTime = cg.time;\n\t\t\t}\n\t\t\tt = cg.time - cent->miscTime;\n\t\t\th = (cg_obeliskRespawnDelay.integer - 5) * 1000;\n\t\t\t//\n\t\t\tif (t > h) {\n\t\t\t\tc = (float) (t - h) / h;\n\t\t\t\tif (c > 1)\n\t\t\t\t\tc = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tc = 0;\n\t\t\t}\n\t\t\t// show the lights\n\t\t\tAnglesToAxis( cent->currentState.angles, model.axis );\n\t\t\t//\n\t\t\tmodel.shaderRGBA[0] = c * 0xff;\n\t\t\tmodel.shaderRGBA[1] = c * 0xff;\n\t\t\tmodel.shaderRGBA[2] = c * 0xff;\n\t\t\tmodel.shaderRGBA[3] = c * 0xff;\n\n\t\t\tmodel.hModel = cgs.media.overloadLightsModel;\n\t\t\ttrap_R_AddRefEntityToScene( &model );\n\t\t\t// show the target\n\t\t\tif (t > h) {\n\t\t\t\tif ( !cent->muzzleFlashTime ) {\n\t\t\t\t\ttrap_S_StartSound (cent->lerpOrigin, ENTITYNUM_NONE, CHAN_BODY,  cgs.media.obeliskRespawnSound);\n\t\t\t\t\tcent->muzzleFlashTime = 1;\n\t\t\t\t}\n\t\t\t\tVectorCopy(cent->currentState.angles, angles);\n\t\t\t\tangles[YAW] += (float) 16 * acos(1-c) * 180 / M_PI;\n\t\t\t\tAnglesToAxis( angles, model.axis );\n\n\t\t\t\tVectorScale( model.axis[0], c, model.axis[0]);\n\t\t\t\tVectorScale( model.axis[1], c, model.axis[1]);\n\t\t\t\tVectorScale( model.axis[2], c, model.axis[2]);\n\n\t\t\t\tmodel.shaderRGBA[0] = 0xff;\n\t\t\t\tmodel.shaderRGBA[1] = 0xff;\n\t\t\t\tmodel.shaderRGBA[2] = 0xff;\n\t\t\t\tmodel.shaderRGBA[3] = 0xff;\n\t\t\t\t//\n\t\t\t\tmodel.origin[2] += 56;\n\t\t\t\tmodel.hModel = cgs.media.overloadTargetModel;\n\t\t\t\ttrap_R_AddRefEntityToScene( &model );\n\t\t\t}\n\t\t\telse {\n\t\t\t\t//FIXME: show animated smoke\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tcent->miscTime = 0;\n\t\t\tcent->muzzleFlashTime = 0;\n\t\t\t// modelindex2 is the health value of the obelisk\n\t\t\tc = cent->currentState.modelindex2;\n\t\t\tmodel.shaderRGBA[0] = 0xff;\n\t\t\tmodel.shaderRGBA[1] = c;\n\t\t\tmodel.shaderRGBA[2] = c;\n\t\t\tmodel.shaderRGBA[3] = 0xff;\n\t\t\t// show the lights\n\t\t\tmodel.hModel = cgs.media.overloadLightsModel;\n\t\t\ttrap_R_AddRefEntityToScene( &model );\n\t\t\t// show the target\n\t\t\tmodel.origin[2] += 56;\n\t\t\tmodel.hModel = cgs.media.overloadTargetModel;\n\t\t\ttrap_R_AddRefEntityToScene( &model );\n\t\t}\n\t}\n\telse if ( cgs.gametype == GT_HARVESTER ) {\n\t\t// show harvester model\n\t\tmemset(&model, 0, sizeof(model));\n\t\tmodel.reType = RT_MODEL;\n\t\tVectorCopy( cent->lerpOrigin, model.lightingOrigin );\n\t\tVectorCopy( cent->lerpOrigin, model.origin );\n\t\tAnglesToAxis( cent->currentState.angles, model.axis );\n\n\t\tif ( cent->currentState.modelindex == TEAM_RED ) {\n\t\t\tmodel.hModel = cgs.media.harvesterModel;\n\t\t\tmodel.customSkin = cgs.media.harvesterRedSkin;\n\t\t}\n\t\telse if ( cent->currentState.modelindex == TEAM_BLUE ) {\n\t\t\tmodel.hModel = cgs.media.harvesterModel;\n\t\t\tmodel.customSkin = cgs.media.harvesterBlueSkin;\n\t\t}\n\t\telse {\n\t\t\tmodel.hModel = cgs.media.harvesterNeutralModel;\n\t\t\tmodel.customSkin = 0;\n\t\t}\n\t\ttrap_R_AddRefEntityToScene( &model );\n\t}\n#endif\n}\n\n/*\n===============\nCG_AddCEntity\n\n===============\n*/\nstatic void CG_AddCEntity( centity_t *cent ) {\n\t// event-only entities will have been dealt with already\n\tif ( cent->currentState.eType >= ET_EVENTS ) {\n\t\treturn;\n\t}\n\n\t// calculate the current origin\n\tCG_CalcEntityLerpPositions( cent );\n\n\t// add automatic effects\n\tCG_EntityEffects( cent );\n\n\tswitch ( cent->currentState.eType ) {\n\tdefault:\n\t\tCG_Error( \"Bad entity type: %i\\n\", cent->currentState.eType );\n\t\tbreak;\n\tcase ET_INVISIBLE:\n\tcase ET_PUSH_TRIGGER:\n\tcase ET_TELEPORT_TRIGGER:\n\t\tbreak;\n\tcase ET_GENERAL:\n\t\tCG_General( cent );\n\t\tbreak;\n\tcase ET_PLAYER:\n\t\tCG_Player( cent );\n\t\tbreak;\n\tcase ET_ITEM:\n\t\tCG_Item( cent );\n\t\tbreak;\n\tcase ET_MISSILE:\n\t\tCG_Missile( cent );\n\t\tbreak;\n\tcase ET_MOVER:\n\t\tCG_Mover( cent );\n\t\tbreak;\n\tcase ET_BEAM:\n\t\tCG_Beam( cent );\n\t\tbreak;\n\tcase ET_PORTAL:\n\t\tCG_Portal( cent );\n\t\tbreak;\n\tcase ET_SPEAKER:\n\t\tCG_Speaker( cent );\n\t\tbreak;\n\tcase ET_GRAPPLE:\n\t\tCG_Grapple( cent );\n\t\tbreak;\n\tcase ET_TEAM:\n\t\tCG_TeamBase( cent );\n\t\tbreak;\n\t}\n}\n\n/*\n===============\nCG_AddPacketEntities\n\n===============\n*/\nvoid CG_AddPacketEntities( void ) {\n\tint\t\t\t\t\tnum;\n\tcentity_t\t\t\t*cent;\n\tplayerState_t\t\t*ps;\n\n\t// set cg.frameInterpolation\n\tif ( cg.nextSnap ) {\n\t\tint\t\tdelta;\n\n\t\tdelta = (cg.nextSnap->serverTime - cg.snap->serverTime);\n\t\tif ( delta == 0 ) {\n\t\t\tcg.frameInterpolation = 0;\n\t\t} else {\n\t\t\tcg.frameInterpolation = (float)( cg.time - cg.snap->serverTime ) / delta;\n\t\t}\n\t} else {\n\t\tcg.frameInterpolation = 0;\t// actually, it should never be used, because \n\t\t\t\t\t\t\t\t\t// no entities should be marked as interpolating\n\t}\n\n\t// the auto-rotating items will all have the same axis\n\tcg.autoAngles[0] = 0;\n\tcg.autoAngles[1] = ( cg.time & 2047 ) * 360 / 2048.0;\n\tcg.autoAngles[2] = 0;\n\n\tcg.autoAnglesFast[0] = 0;\n\tcg.autoAnglesFast[1] = ( cg.time & 1023 ) * 360 / 1024.0f;\n\tcg.autoAnglesFast[2] = 0;\n\n\tAnglesToAxis( cg.autoAngles, cg.autoAxis );\n\tAnglesToAxis( cg.autoAnglesFast, cg.autoAxisFast );\n\n\t// generate and add the entity from the playerstate\n\tps = &cg.predictedPlayerState;\n\tBG_PlayerStateToEntityState( ps, &cg.predictedPlayerEntity.currentState, qfalse );\n\tCG_AddCEntity( &cg.predictedPlayerEntity );\n\n\t// lerp the non-predicted value for lightning gun origins\n\tCG_CalcEntityLerpPositions( &cg_entities[ cg.snap->ps.clientNum ] );\n\n\t// add each entity sent over by the server\n\tfor ( num = 0 ; num < cg.snap->numEntities ; num++ ) {\n\t\tcent = &cg_entities[ cg.snap->entities[ num ].number ];\n\t\tCG_AddCEntity( cent );\n\t}\n}\n\n"
  },
  {
    "path": "code/cgame/cg_event.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// cg_event.c -- handle entity events at snapshot or playerstate transitions\n\n#include \"cg_local.h\"\n\n// for the voice chats\n#ifdef MISSIONPACK // bk001205\n#include \"../../ui/menudef.h\"\n#endif\n//==========================================================================\n\n/*\n===================\nCG_PlaceString\n\nAlso called by scoreboard drawing\n===================\n*/\nconst char\t*CG_PlaceString( int rank ) {\n\tstatic char\tstr[64];\n\tchar\t*s, *t;\n\n\tif ( rank & RANK_TIED_FLAG ) {\n\t\trank &= ~RANK_TIED_FLAG;\n\t\tt = \"Tied for \";\n\t} else {\n\t\tt = \"\";\n\t}\n\n\tif ( rank == 1 ) {\n\t\ts = S_COLOR_BLUE \"1st\" S_COLOR_WHITE;\t\t// draw in blue\n\t} else if ( rank == 2 ) {\n\t\ts = S_COLOR_RED \"2nd\" S_COLOR_WHITE;\t\t// draw in red\n\t} else if ( rank == 3 ) {\n\t\ts = S_COLOR_YELLOW \"3rd\" S_COLOR_WHITE;\t\t// draw in yellow\n\t} else if ( rank == 11 ) {\n\t\ts = \"11th\";\n\t} else if ( rank == 12 ) {\n\t\ts = \"12th\";\n\t} else if ( rank == 13 ) {\n\t\ts = \"13th\";\n\t} else if ( rank % 10 == 1 ) {\n\t\ts = va(\"%ist\", rank);\n\t} else if ( rank % 10 == 2 ) {\n\t\ts = va(\"%ind\", rank);\n\t} else if ( rank % 10 == 3 ) {\n\t\ts = va(\"%ird\", rank);\n\t} else {\n\t\ts = va(\"%ith\", rank);\n\t}\n\n\tCom_sprintf( str, sizeof( str ), \"%s%s\", t, s );\n\treturn str;\n}\n\n/*\n=============\nCG_Obituary\n=============\n*/\nstatic void CG_Obituary( entityState_t *ent ) {\n\tint\t\t\tmod;\n\tint\t\t\ttarget, attacker;\n\tchar\t\t*message;\n\tchar\t\t*message2;\n\tconst char\t*targetInfo;\n\tconst char\t*attackerInfo;\n\tchar\t\ttargetName[32];\n\tchar\t\tattackerName[32];\n\tgender_t\tgender;\n\tclientInfo_t\t*ci;\n\n\ttarget = ent->otherEntityNum;\n\tattacker = ent->otherEntityNum2;\n\tmod = ent->eventParm;\n\n\tif ( target < 0 || target >= MAX_CLIENTS ) {\n\t\tCG_Error( \"CG_Obituary: target out of range\" );\n\t}\n\tci = &cgs.clientinfo[target];\n\n\tif ( attacker < 0 || attacker >= MAX_CLIENTS ) {\n\t\tattacker = ENTITYNUM_WORLD;\n\t\tattackerInfo = NULL;\n\t} else {\n\t\tattackerInfo = CG_ConfigString( CS_PLAYERS + attacker );\n\t}\n\n\ttargetInfo = CG_ConfigString( CS_PLAYERS + target );\n\tif ( !targetInfo ) {\n\t\treturn;\n\t}\n\tQ_strncpyz( targetName, Info_ValueForKey( targetInfo, \"n\" ), sizeof(targetName) - 2);\n\tstrcat( targetName, S_COLOR_WHITE );\n\n\tmessage2 = \"\";\n\n\t// check for single client messages\n\n\tswitch( mod ) {\n\tcase MOD_SUICIDE:\n\t\tmessage = \"suicides\";\n\t\tbreak;\n\tcase MOD_FALLING:\n\t\tmessage = \"cratered\";\n\t\tbreak;\n\tcase MOD_CRUSH:\n\t\tmessage = \"was squished\";\n\t\tbreak;\n\tcase MOD_WATER:\n\t\tmessage = \"sank like a rock\";\n\t\tbreak;\n\tcase MOD_SLIME:\n\t\tmessage = \"melted\";\n\t\tbreak;\n\tcase MOD_LAVA:\n\t\tmessage = \"does a back flip into the lava\";\n\t\tbreak;\n\tcase MOD_TARGET_LASER:\n\t\tmessage = \"saw the light\";\n\t\tbreak;\n\tcase MOD_TRIGGER_HURT:\n\t\tmessage = \"was in the wrong place\";\n\t\tbreak;\n\tdefault:\n\t\tmessage = NULL;\n\t\tbreak;\n\t}\n\n\tif (attacker == target) {\n\t\tgender = ci->gender;\n\t\tswitch (mod) {\n#ifdef MISSIONPACK\n\t\tcase MOD_KAMIKAZE:\n\t\t\tmessage = \"goes out with a bang\";\n\t\t\tbreak;\n#endif\n\t\tcase MOD_GRENADE_SPLASH:\n\t\t\tif ( gender == GENDER_FEMALE )\n\t\t\t\tmessage = \"tripped on her own grenade\";\n\t\t\telse if ( gender == GENDER_NEUTER )\n\t\t\t\tmessage = \"tripped on its own grenade\";\n\t\t\telse\n\t\t\t\tmessage = \"tripped on his own grenade\";\n\t\t\tbreak;\n\t\tcase MOD_ROCKET_SPLASH:\n\t\t\tif ( gender == GENDER_FEMALE )\n\t\t\t\tmessage = \"blew herself up\";\n\t\t\telse if ( gender == GENDER_NEUTER )\n\t\t\t\tmessage = \"blew itself up\";\n\t\t\telse\n\t\t\t\tmessage = \"blew himself up\";\n\t\t\tbreak;\n\t\tcase MOD_PLASMA_SPLASH:\n\t\t\tif ( gender == GENDER_FEMALE )\n\t\t\t\tmessage = \"melted herself\";\n\t\t\telse if ( gender == GENDER_NEUTER )\n\t\t\t\tmessage = \"melted itself\";\n\t\t\telse\n\t\t\t\tmessage = \"melted himself\";\n\t\t\tbreak;\n\t\tcase MOD_BFG_SPLASH:\n\t\t\tmessage = \"should have used a smaller gun\";\n\t\t\tbreak;\n#ifdef MISSIONPACK\n\t\tcase MOD_PROXIMITY_MINE:\n\t\t\tif( gender == GENDER_FEMALE ) {\n\t\t\t\tmessage = \"found her prox mine\";\n\t\t\t} else if ( gender == GENDER_NEUTER ) {\n\t\t\t\tmessage = \"found it's prox mine\";\n\t\t\t} else {\n\t\t\t\tmessage = \"found his prox mine\";\n\t\t\t}\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tif ( gender == GENDER_FEMALE )\n\t\t\t\tmessage = \"killed herself\";\n\t\t\telse if ( gender == GENDER_NEUTER )\n\t\t\t\tmessage = \"killed itself\";\n\t\t\telse\n\t\t\t\tmessage = \"killed himself\";\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (message) {\n\t\tCG_Printf( \"%s %s.\\n\", targetName, message);\n\t\treturn;\n\t}\n\n\t// check for kill messages from the current clientNum\n\tif ( attacker == cg.snap->ps.clientNum ) {\n\t\tchar\t*s;\n\n\t\tif ( cgs.gametype < GT_TEAM ) {\n\t\t\ts = va(\"You fragged %s\\n%s place with %i\", targetName, \n\t\t\t\tCG_PlaceString( cg.snap->ps.persistant[PERS_RANK] + 1 ),\n\t\t\t\tcg.snap->ps.persistant[PERS_SCORE] );\n\t\t} else {\n\t\t\ts = va(\"You fragged %s\", targetName );\n\t\t}\n#ifdef MISSIONPACK\n\t\tif (!(cg_singlePlayerActive.integer && cg_cameraOrbit.integer)) {\n\t\t\tCG_CenterPrint( s, SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH );\n\t\t} \n#else\n\t\tCG_CenterPrint( s, SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH );\n#endif\n\n\t\t// print the text message as well\n\t}\n\n\t// check for double client messages\n\tif ( !attackerInfo ) {\n\t\tattacker = ENTITYNUM_WORLD;\n\t\tstrcpy( attackerName, \"noname\" );\n\t} else {\n\t\tQ_strncpyz( attackerName, Info_ValueForKey( attackerInfo, \"n\" ), sizeof(attackerName) - 2);\n\t\tstrcat( attackerName, S_COLOR_WHITE );\n\t\t// check for kill messages about the current clientNum\n\t\tif ( target == cg.snap->ps.clientNum ) {\n\t\t\tQ_strncpyz( cg.killerName, attackerName, sizeof( cg.killerName ) );\n\t\t}\n\t}\n\n\tif ( attacker != ENTITYNUM_WORLD ) {\n\t\tswitch (mod) {\n\t\tcase MOD_GRAPPLE:\n\t\t\tmessage = \"was caught by\";\n\t\t\tbreak;\n\t\tcase MOD_GAUNTLET:\n\t\t\tmessage = \"was pummeled by\";\n\t\t\tbreak;\n\t\tcase MOD_MACHINEGUN:\n\t\t\tmessage = \"was machinegunned by\";\n\t\t\tbreak;\n\t\tcase MOD_SHOTGUN:\n\t\t\tmessage = \"was gunned down by\";\n\t\t\tbreak;\n\t\tcase MOD_GRENADE:\n\t\t\tmessage = \"ate\";\n\t\t\tmessage2 = \"'s grenade\";\n\t\t\tbreak;\n\t\tcase MOD_GRENADE_SPLASH:\n\t\t\tmessage = \"was shredded by\";\n\t\t\tmessage2 = \"'s shrapnel\";\n\t\t\tbreak;\n\t\tcase MOD_ROCKET:\n\t\t\tmessage = \"ate\";\n\t\t\tmessage2 = \"'s rocket\";\n\t\t\tbreak;\n\t\tcase MOD_ROCKET_SPLASH:\n\t\t\tmessage = \"almost dodged\";\n\t\t\tmessage2 = \"'s rocket\";\n\t\t\tbreak;\n\t\tcase MOD_PLASMA:\n\t\t\tmessage = \"was melted by\";\n\t\t\tmessage2 = \"'s plasmagun\";\n\t\t\tbreak;\n\t\tcase MOD_PLASMA_SPLASH:\n\t\t\tmessage = \"was melted by\";\n\t\t\tmessage2 = \"'s plasmagun\";\n\t\t\tbreak;\n\t\tcase MOD_RAILGUN:\n\t\t\tmessage = \"was railed by\";\n\t\t\tbreak;\n\t\tcase MOD_LIGHTNING:\n\t\t\tmessage = \"was electrocuted by\";\n\t\t\tbreak;\n\t\tcase MOD_BFG:\n\t\tcase MOD_BFG_SPLASH:\n\t\t\tmessage = \"was blasted by\";\n\t\t\tmessage2 = \"'s BFG\";\n\t\t\tbreak;\n#ifdef MISSIONPACK\n\t\tcase MOD_NAIL:\n\t\t\tmessage = \"was nailed by\";\n\t\t\tbreak;\n\t\tcase MOD_CHAINGUN:\n\t\t\tmessage = \"got lead poisoning from\";\n\t\t\tmessage2 = \"'s Chaingun\";\n\t\t\tbreak;\n\t\tcase MOD_PROXIMITY_MINE:\n\t\t\tmessage = \"was too close to\";\n\t\t\tmessage2 = \"'s Prox Mine\";\n\t\t\tbreak;\n\t\tcase MOD_KAMIKAZE:\n\t\t\tmessage = \"falls to\";\n\t\t\tmessage2 = \"'s Kamikaze blast\";\n\t\t\tbreak;\n\t\tcase MOD_JUICED:\n\t\t\tmessage = \"was juiced by\";\n\t\t\tbreak;\n#endif\n\t\tcase MOD_TELEFRAG:\n\t\t\tmessage = \"tried to invade\";\n\t\t\tmessage2 = \"'s personal space\";\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tmessage = \"was killed by\";\n\t\t\tbreak;\n\t\t}\n\n\t\tif (message) {\n\t\t\tCG_Printf( \"%s %s %s%s\\n\", \n\t\t\t\ttargetName, message, attackerName, message2);\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// we don't know what it was\n\tCG_Printf( \"%s died.\\n\", targetName );\n}\n\n//==========================================================================\n\n/*\n===============\nCG_UseItem\n===============\n*/\nstatic void CG_UseItem( centity_t *cent ) {\n\tclientInfo_t *ci;\n\tint\t\t\titemNum, clientNum;\n\tgitem_t\t\t*item;\n\tentityState_t *es;\n\n\tes = &cent->currentState;\n\t\n\titemNum = (es->event & ~EV_EVENT_BITS) - EV_USE_ITEM0;\n\tif ( itemNum < 0 || itemNum > HI_NUM_HOLDABLE ) {\n\t\titemNum = 0;\n\t}\n\n\t// print a message if the local player\n\tif ( es->number == cg.snap->ps.clientNum ) {\n\t\tif ( !itemNum ) {\n\t\t\tCG_CenterPrint( \"No item to use\", SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH );\n\t\t} else {\n\t\t\titem = BG_FindItemForHoldable( itemNum );\n\t\t\tCG_CenterPrint( va(\"Use %s\", item->pickup_name), SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH );\n\t\t}\n\t}\n\n\tswitch ( itemNum ) {\n\tdefault:\n\tcase HI_NONE:\n\t\ttrap_S_StartSound (NULL, es->number, CHAN_BODY, cgs.media.useNothingSound );\n\t\tbreak;\n\n\tcase HI_TELEPORTER:\n\t\tbreak;\n\n\tcase HI_MEDKIT:\n\t\tclientNum = cent->currentState.clientNum;\n\t\tif ( clientNum >= 0 && clientNum < MAX_CLIENTS ) {\n\t\t\tci = &cgs.clientinfo[ clientNum ];\n\t\t\tci->medkitUsageTime = cg.time;\n\t\t}\n\t\ttrap_S_StartSound (NULL, es->number, CHAN_BODY, cgs.media.medkitSound );\n\t\tbreak;\n\n#ifdef MISSIONPACK\n\tcase HI_KAMIKAZE:\n\t\tbreak;\n\n\tcase HI_PORTAL:\n\t\tbreak;\n\tcase HI_INVULNERABILITY:\n\t\ttrap_S_StartSound (NULL, es->number, CHAN_BODY, cgs.media.useInvulnerabilitySound );\n\t\tbreak;\n#endif\n\t}\n\n}\n\n/*\n================\nCG_ItemPickup\n\nA new item was picked up this frame\n================\n*/\nstatic void CG_ItemPickup( int itemNum ) {\n\tcg.itemPickup = itemNum;\n\tcg.itemPickupTime = cg.time;\n\tcg.itemPickupBlendTime = cg.time;\n\t// see if it should be the grabbed weapon\n\tif ( bg_itemlist[itemNum].giType == IT_WEAPON ) {\n\t\t// select it immediately\n\t\tif ( cg_autoswitch.integer && bg_itemlist[itemNum].giTag != WP_MACHINEGUN ) {\n\t\t\tcg.weaponSelectTime = cg.time;\n\t\t\tcg.weaponSelect = bg_itemlist[itemNum].giTag;\n\t\t}\n\t}\n\n}\n\n\n/*\n================\nCG_PainEvent\n\nAlso called by playerstate transition\n================\n*/\nvoid CG_PainEvent( centity_t *cent, int health ) {\n\tchar\t*snd;\n\n\t// don't do more than two pain sounds a second\n\tif ( cg.time - cent->pe.painTime < 500 ) {\n\t\treturn;\n\t}\n\n\tif ( health < 25 ) {\n\t\tsnd = \"*pain25_1.wav\";\n\t} else if ( health < 50 ) {\n\t\tsnd = \"*pain50_1.wav\";\n\t} else if ( health < 75 ) {\n\t\tsnd = \"*pain75_1.wav\";\n\t} else {\n\t\tsnd = \"*pain100_1.wav\";\n\t}\n\ttrap_S_StartSound( NULL, cent->currentState.number, CHAN_VOICE, \n\t\tCG_CustomSound( cent->currentState.number, snd ) );\n\n\t// save pain time for programitic twitch animation\n\tcent->pe.painTime = cg.time;\n\tcent->pe.painDirection ^= 1;\n}\n\n\n\n/*\n==============\nCG_EntityEvent\n\nAn entity has an event value\nalso called by CG_CheckPlayerstateEvents\n==============\n*/\n#define\tDEBUGNAME(x) if(cg_debugEvents.integer){CG_Printf(x\"\\n\");}\nvoid CG_EntityEvent( centity_t *cent, vec3_t position ) {\n\tentityState_t\t*es;\n\tint\t\t\t\tevent;\n\tvec3_t\t\t\tdir;\n\tconst char\t\t*s;\n\tint\t\t\t\tclientNum;\n\tclientInfo_t\t*ci;\n\n\tes = &cent->currentState;\n\tevent = es->event & ~EV_EVENT_BITS;\n\n\tif ( cg_debugEvents.integer ) {\n\t\tCG_Printf( \"ent:%3i  event:%3i \", es->number, event );\n\t}\n\n\tif ( !event ) {\n\t\tDEBUGNAME(\"ZEROEVENT\");\n\t\treturn;\n\t}\n\n\tclientNum = es->clientNum;\n\tif ( clientNum < 0 || clientNum >= MAX_CLIENTS ) {\n\t\tclientNum = 0;\n\t}\n\tci = &cgs.clientinfo[ clientNum ];\n\n\tswitch ( event ) {\n\t//\n\t// movement generated events\n\t//\n\tcase EV_FOOTSTEP:\n\t\tDEBUGNAME(\"EV_FOOTSTEP\");\n\t\tif (cg_footsteps.integer) {\n\t\t\ttrap_S_StartSound (NULL, es->number, CHAN_BODY, \n\t\t\t\tcgs.media.footsteps[ ci->footsteps ][rand()&3] );\n\t\t}\n\t\tbreak;\n\tcase EV_FOOTSTEP_METAL:\n\t\tDEBUGNAME(\"EV_FOOTSTEP_METAL\");\n\t\tif (cg_footsteps.integer) {\n\t\t\ttrap_S_StartSound (NULL, es->number, CHAN_BODY, \n\t\t\t\tcgs.media.footsteps[ FOOTSTEP_METAL ][rand()&3] );\n\t\t}\n\t\tbreak;\n\tcase EV_FOOTSPLASH:\n\t\tDEBUGNAME(\"EV_FOOTSPLASH\");\n\t\tif (cg_footsteps.integer) {\n\t\t\ttrap_S_StartSound (NULL, es->number, CHAN_BODY, \n\t\t\t\tcgs.media.footsteps[ FOOTSTEP_SPLASH ][rand()&3] );\n\t\t}\n\t\tbreak;\n\tcase EV_FOOTWADE:\n\t\tDEBUGNAME(\"EV_FOOTWADE\");\n\t\tif (cg_footsteps.integer) {\n\t\t\ttrap_S_StartSound (NULL, es->number, CHAN_BODY, \n\t\t\t\tcgs.media.footsteps[ FOOTSTEP_SPLASH ][rand()&3] );\n\t\t}\n\t\tbreak;\n\tcase EV_SWIM:\n\t\tDEBUGNAME(\"EV_SWIM\");\n\t\tif (cg_footsteps.integer) {\n\t\t\ttrap_S_StartSound (NULL, es->number, CHAN_BODY, \n\t\t\t\tcgs.media.footsteps[ FOOTSTEP_SPLASH ][rand()&3] );\n\t\t}\n\t\tbreak;\n\n\n\tcase EV_FALL_SHORT:\n\t\tDEBUGNAME(\"EV_FALL_SHORT\");\n\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.landSound );\n\t\tif ( clientNum == cg.predictedPlayerState.clientNum ) {\n\t\t\t// smooth landing z changes\n\t\t\tcg.landChange = -8;\n\t\t\tcg.landTime = cg.time;\n\t\t}\n\t\tbreak;\n\tcase EV_FALL_MEDIUM:\n\t\tDEBUGNAME(\"EV_FALL_MEDIUM\");\n\t\t// use normal pain sound\n\t\ttrap_S_StartSound( NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, \"*pain100_1.wav\" ) );\n\t\tif ( clientNum == cg.predictedPlayerState.clientNum ) {\n\t\t\t// smooth landing z changes\n\t\t\tcg.landChange = -16;\n\t\t\tcg.landTime = cg.time;\n\t\t}\n\t\tbreak;\n\tcase EV_FALL_FAR:\n\t\tDEBUGNAME(\"EV_FALL_FAR\");\n\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO, CG_CustomSound( es->number, \"*fall1.wav\" ) );\n\t\tcent->pe.painTime = cg.time;\t// don't play a pain sound right after this\n\t\tif ( clientNum == cg.predictedPlayerState.clientNum ) {\n\t\t\t// smooth landing z changes\n\t\t\tcg.landChange = -24;\n\t\t\tcg.landTime = cg.time;\n\t\t}\n\t\tbreak;\n\n\tcase EV_STEP_4:\n\tcase EV_STEP_8:\n\tcase EV_STEP_12:\n\tcase EV_STEP_16:\t\t// smooth out step up transitions\n\t\tDEBUGNAME(\"EV_STEP\");\n\t{\n\t\tfloat\toldStep;\n\t\tint\t\tdelta;\n\t\tint\t\tstep;\n\n\t\tif ( clientNum != cg.predictedPlayerState.clientNum ) {\n\t\t\tbreak;\n\t\t}\n\t\t// if we are interpolating, we don't need to smooth steps\n\t\tif ( cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_FOLLOW) ||\n\t\t\tcg_nopredict.integer || cg_synchronousClients.integer ) {\n\t\t\tbreak;\n\t\t}\n\t\t// check for stepping up before a previous step is completed\n\t\tdelta = cg.time - cg.stepTime;\n\t\tif (delta < STEP_TIME) {\n\t\t\toldStep = cg.stepChange * (STEP_TIME - delta) / STEP_TIME;\n\t\t} else {\n\t\t\toldStep = 0;\n\t\t}\n\n\t\t// add this amount\n\t\tstep = 4 * (event - EV_STEP_4 + 1 );\n\t\tcg.stepChange = oldStep + step;\n\t\tif ( cg.stepChange > MAX_STEP_CHANGE ) {\n\t\t\tcg.stepChange = MAX_STEP_CHANGE;\n\t\t}\n\t\tcg.stepTime = cg.time;\n\t\tbreak;\n\t}\n\n\tcase EV_JUMP_PAD:\n\t\tDEBUGNAME(\"EV_JUMP_PAD\");\n//\t\tCG_Printf( \"EV_JUMP_PAD w/effect #%i\\n\", es->eventParm );\n\t\t{\n\t\t\tlocalEntity_t\t*smoke;\n\t\t\tvec3_t\t\t\tup = {0, 0, 1};\n\n\n\t\t\tsmoke = CG_SmokePuff( cent->lerpOrigin, up, \n\t\t\t\t\t\t  32, \n\t\t\t\t\t\t  1, 1, 1, 0.33f,\n\t\t\t\t\t\t  1000, \n\t\t\t\t\t\t  cg.time, 0,\n\t\t\t\t\t\t  LEF_PUFF_DONT_SCALE, \n\t\t\t\t\t\t  cgs.media.smokePuffShader );\n\t\t}\n\n\t\t// boing sound at origin, jump sound on player\n\t\ttrap_S_StartSound ( cent->lerpOrigin, -1, CHAN_VOICE, cgs.media.jumpPadSound );\n\t\ttrap_S_StartSound (NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, \"*jump1.wav\" ) );\n\t\tbreak;\n\n\tcase EV_JUMP:\n\t\tDEBUGNAME(\"EV_JUMP\");\n\t\ttrap_S_StartSound (NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, \"*jump1.wav\" ) );\n\t\tbreak;\n\tcase EV_TAUNT:\n\t\tDEBUGNAME(\"EV_TAUNT\");\n\t\ttrap_S_StartSound (NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, \"*taunt.wav\" ) );\n\t\tbreak;\n#ifdef MISSIONPACK\n\tcase EV_TAUNT_YES:\n\t\tDEBUGNAME(\"EV_TAUNT_YES\");\n\t\tCG_VoiceChatLocal(SAY_TEAM, qfalse, es->number, COLOR_CYAN, VOICECHAT_YES);\n\t\tbreak;\n\tcase EV_TAUNT_NO:\n\t\tDEBUGNAME(\"EV_TAUNT_NO\");\n\t\tCG_VoiceChatLocal(SAY_TEAM, qfalse, es->number, COLOR_CYAN, VOICECHAT_NO);\n\t\tbreak;\n\tcase EV_TAUNT_FOLLOWME:\n\t\tDEBUGNAME(\"EV_TAUNT_FOLLOWME\");\n\t\tCG_VoiceChatLocal(SAY_TEAM, qfalse, es->number, COLOR_CYAN, VOICECHAT_FOLLOWME);\n\t\tbreak;\n\tcase EV_TAUNT_GETFLAG:\n\t\tDEBUGNAME(\"EV_TAUNT_GETFLAG\");\n\t\tCG_VoiceChatLocal(SAY_TEAM, qfalse, es->number, COLOR_CYAN, VOICECHAT_ONGETFLAG);\n\t\tbreak;\n\tcase EV_TAUNT_GUARDBASE:\n\t\tDEBUGNAME(\"EV_TAUNT_GUARDBASE\");\n\t\tCG_VoiceChatLocal(SAY_TEAM, qfalse, es->number, COLOR_CYAN, VOICECHAT_ONDEFENSE);\n\t\tbreak;\n\tcase EV_TAUNT_PATROL:\n\t\tDEBUGNAME(\"EV_TAUNT_PATROL\");\n\t\tCG_VoiceChatLocal(SAY_TEAM, qfalse, es->number, COLOR_CYAN, VOICECHAT_ONPATROL);\n\t\tbreak;\n#endif\n\tcase EV_WATER_TOUCH:\n\t\tDEBUGNAME(\"EV_WATER_TOUCH\");\n\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.watrInSound );\n\t\tbreak;\n\tcase EV_WATER_LEAVE:\n\t\tDEBUGNAME(\"EV_WATER_LEAVE\");\n\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.watrOutSound );\n\t\tbreak;\n\tcase EV_WATER_UNDER:\n\t\tDEBUGNAME(\"EV_WATER_UNDER\");\n\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.watrUnSound );\n\t\tbreak;\n\tcase EV_WATER_CLEAR:\n\t\tDEBUGNAME(\"EV_WATER_CLEAR\");\n\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO, CG_CustomSound( es->number, \"*gasp.wav\" ) );\n\t\tbreak;\n\n\tcase EV_ITEM_PICKUP:\n\t\tDEBUGNAME(\"EV_ITEM_PICKUP\");\n\t\t{\n\t\t\tgitem_t\t*item;\n\t\t\tint\t\tindex;\n\n\t\t\tindex = es->eventParm;\t\t// player predicted\n\n\t\t\tif ( index < 1 || index >= bg_numItems ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\titem = &bg_itemlist[ index ];\n\n\t\t\t// powerups and team items will have a separate global sound, this one\n\t\t\t// will be played at prediction time\n\t\t\tif ( item->giType == IT_POWERUP || item->giType == IT_TEAM) {\n\t\t\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO,\tcgs.media.n_healthSound );\n\t\t\t} else if (item->giType == IT_PERSISTANT_POWERUP) {\n#ifdef MISSIONPACK\n\t\t\t\tswitch (item->giTag ) {\n\t\t\t\t\tcase PW_SCOUT:\n\t\t\t\t\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO,\tcgs.media.scoutSound );\n\t\t\t\t\tbreak;\n\t\t\t\t\tcase PW_GUARD:\n\t\t\t\t\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO,\tcgs.media.guardSound );\n\t\t\t\t\tbreak;\n\t\t\t\t\tcase PW_DOUBLER:\n\t\t\t\t\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO,\tcgs.media.doublerSound );\n\t\t\t\t\tbreak;\n\t\t\t\t\tcase PW_AMMOREGEN:\n\t\t\t\t\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO,\tcgs.media.ammoregenSound );\n\t\t\t\t\tbreak;\n\t\t\t\t}\n#endif\n\t\t\t} else {\n\t\t\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO,\ttrap_S_RegisterSound( item->pickup_sound, qfalse ) );\n\t\t\t}\n\n\t\t\t// show icon and name on status bar\n\t\t\tif ( es->number == cg.snap->ps.clientNum ) {\n\t\t\t\tCG_ItemPickup( index );\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase EV_GLOBAL_ITEM_PICKUP:\n\t\tDEBUGNAME(\"EV_GLOBAL_ITEM_PICKUP\");\n\t\t{\n\t\t\tgitem_t\t*item;\n\t\t\tint\t\tindex;\n\n\t\t\tindex = es->eventParm;\t\t// player predicted\n\n\t\t\tif ( index < 1 || index >= bg_numItems ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\titem = &bg_itemlist[ index ];\n\t\t\t// powerup pickups are global\n\t\t\tif( item->pickup_sound ) {\n\t\t\t\ttrap_S_StartSound (NULL, cg.snap->ps.clientNum, CHAN_AUTO, trap_S_RegisterSound( item->pickup_sound, qfalse ) );\n\t\t\t}\n\n\t\t\t// show icon and name on status bar\n\t\t\tif ( es->number == cg.snap->ps.clientNum ) {\n\t\t\t\tCG_ItemPickup( index );\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\t//\n\t// weapon events\n\t//\n\tcase EV_NOAMMO:\n\t\tDEBUGNAME(\"EV_NOAMMO\");\n//\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.noAmmoSound );\n\t\tif ( es->number == cg.snap->ps.clientNum ) {\n\t\t\tCG_OutOfAmmoChange();\n\t\t}\n\t\tbreak;\n\tcase EV_CHANGE_WEAPON:\n\t\tDEBUGNAME(\"EV_CHANGE_WEAPON\");\n\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.selectSound );\n\t\tbreak;\n\tcase EV_FIRE_WEAPON:\n\t\tDEBUGNAME(\"EV_FIRE_WEAPON\");\n\t\tCG_FireWeapon( cent );\n\t\tbreak;\n\n\tcase EV_USE_ITEM0:\n\t\tDEBUGNAME(\"EV_USE_ITEM0\");\n\t\tCG_UseItem( cent );\n\t\tbreak;\n\tcase EV_USE_ITEM1:\n\t\tDEBUGNAME(\"EV_USE_ITEM1\");\n\t\tCG_UseItem( cent );\n\t\tbreak;\n\tcase EV_USE_ITEM2:\n\t\tDEBUGNAME(\"EV_USE_ITEM2\");\n\t\tCG_UseItem( cent );\n\t\tbreak;\n\tcase EV_USE_ITEM3:\n\t\tDEBUGNAME(\"EV_USE_ITEM3\");\n\t\tCG_UseItem( cent );\n\t\tbreak;\n\tcase EV_USE_ITEM4:\n\t\tDEBUGNAME(\"EV_USE_ITEM4\");\n\t\tCG_UseItem( cent );\n\t\tbreak;\n\tcase EV_USE_ITEM5:\n\t\tDEBUGNAME(\"EV_USE_ITEM5\");\n\t\tCG_UseItem( cent );\n\t\tbreak;\n\tcase EV_USE_ITEM6:\n\t\tDEBUGNAME(\"EV_USE_ITEM6\");\n\t\tCG_UseItem( cent );\n\t\tbreak;\n\tcase EV_USE_ITEM7:\n\t\tDEBUGNAME(\"EV_USE_ITEM7\");\n\t\tCG_UseItem( cent );\n\t\tbreak;\n\tcase EV_USE_ITEM8:\n\t\tDEBUGNAME(\"EV_USE_ITEM8\");\n\t\tCG_UseItem( cent );\n\t\tbreak;\n\tcase EV_USE_ITEM9:\n\t\tDEBUGNAME(\"EV_USE_ITEM9\");\n\t\tCG_UseItem( cent );\n\t\tbreak;\n\tcase EV_USE_ITEM10:\n\t\tDEBUGNAME(\"EV_USE_ITEM10\");\n\t\tCG_UseItem( cent );\n\t\tbreak;\n\tcase EV_USE_ITEM11:\n\t\tDEBUGNAME(\"EV_USE_ITEM11\");\n\t\tCG_UseItem( cent );\n\t\tbreak;\n\tcase EV_USE_ITEM12:\n\t\tDEBUGNAME(\"EV_USE_ITEM12\");\n\t\tCG_UseItem( cent );\n\t\tbreak;\n\tcase EV_USE_ITEM13:\n\t\tDEBUGNAME(\"EV_USE_ITEM13\");\n\t\tCG_UseItem( cent );\n\t\tbreak;\n\tcase EV_USE_ITEM14:\n\t\tDEBUGNAME(\"EV_USE_ITEM14\");\n\t\tCG_UseItem( cent );\n\t\tbreak;\n\n\t//=================================================================\n\n\t//\n\t// other events\n\t//\n\tcase EV_PLAYER_TELEPORT_IN:\n\t\tDEBUGNAME(\"EV_PLAYER_TELEPORT_IN\");\n\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.teleInSound );\n\t\tCG_SpawnEffect( position);\n\t\tbreak;\n\n\tcase EV_PLAYER_TELEPORT_OUT:\n\t\tDEBUGNAME(\"EV_PLAYER_TELEPORT_OUT\");\n\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.teleOutSound );\n\t\tCG_SpawnEffect(  position);\n\t\tbreak;\n\n\tcase EV_ITEM_POP:\n\t\tDEBUGNAME(\"EV_ITEM_POP\");\n\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.respawnSound );\n\t\tbreak;\n\tcase EV_ITEM_RESPAWN:\n\t\tDEBUGNAME(\"EV_ITEM_RESPAWN\");\n\t\tcent->miscTime = cg.time;\t// scale up from this\n\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.respawnSound );\n\t\tbreak;\n\n\tcase EV_GRENADE_BOUNCE:\n\t\tDEBUGNAME(\"EV_GRENADE_BOUNCE\");\n\t\tif ( rand() & 1 ) {\n\t\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.hgrenb1aSound );\n\t\t} else {\n\t\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.hgrenb2aSound );\n\t\t}\n\t\tbreak;\n\n#ifdef MISSIONPACK\n\tcase EV_PROXIMITY_MINE_STICK:\n\t\tDEBUGNAME(\"EV_PROXIMITY_MINE_STICK\");\n\t\tif( es->eventParm & SURF_FLESH ) {\n\t\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.wstbimplSound );\n\t\t} else \tif( es->eventParm & SURF_METALSTEPS ) {\n\t\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.wstbimpmSound );\n\t\t} else {\n\t\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.wstbimpdSound );\n\t\t}\n\t\tbreak;\n\n\tcase EV_PROXIMITY_MINE_TRIGGER:\n\t\tDEBUGNAME(\"EV_PROXIMITY_MINE_TRIGGER\");\n\t\ttrap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.wstbactvSound );\n\t\tbreak;\n\tcase EV_KAMIKAZE:\n\t\tDEBUGNAME(\"EV_KAMIKAZE\");\n\t\tCG_KamikazeEffect( cent->lerpOrigin );\n\t\tbreak;\n\tcase EV_OBELISKEXPLODE:\n\t\tDEBUGNAME(\"EV_OBELISKEXPLODE\");\n\t\tCG_ObeliskExplode( cent->lerpOrigin, es->eventParm );\n\t\tbreak;\n\tcase EV_OBELISKPAIN:\n\t\tDEBUGNAME(\"EV_OBELISKPAIN\");\n\t\tCG_ObeliskPain( cent->lerpOrigin );\n\t\tbreak;\n\tcase EV_INVUL_IMPACT:\n\t\tDEBUGNAME(\"EV_INVUL_IMPACT\");\n\t\tCG_InvulnerabilityImpact( cent->lerpOrigin, cent->currentState.angles );\n\t\tbreak;\n\tcase EV_JUICED:\n\t\tDEBUGNAME(\"EV_JUICED\");\n\t\tCG_InvulnerabilityJuiced( cent->lerpOrigin );\n\t\tbreak;\n\tcase EV_LIGHTNINGBOLT:\n\t\tDEBUGNAME(\"EV_LIGHTNINGBOLT\");\n\t\tCG_LightningBoltBeam(es->origin2, es->pos.trBase);\n\t\tbreak;\n#endif\n\tcase EV_SCOREPLUM:\n\t\tDEBUGNAME(\"EV_SCOREPLUM\");\n\t\tCG_ScorePlum( cent->currentState.otherEntityNum, cent->lerpOrigin, cent->currentState.time );\n\t\tbreak;\n\n\t//\n\t// missile impacts\n\t//\n\tcase EV_MISSILE_HIT:\n\t\tDEBUGNAME(\"EV_MISSILE_HIT\");\n\t\tByteToDir( es->eventParm, dir );\n\t\tCG_MissileHitPlayer( es->weapon, position, dir, es->otherEntityNum );\n\t\tbreak;\n\n\tcase EV_MISSILE_MISS:\n\t\tDEBUGNAME(\"EV_MISSILE_MISS\");\n\t\tByteToDir( es->eventParm, dir );\n\t\tCG_MissileHitWall( es->weapon, 0, position, dir, IMPACTSOUND_DEFAULT );\n\t\tbreak;\n\n\tcase EV_MISSILE_MISS_METAL:\n\t\tDEBUGNAME(\"EV_MISSILE_MISS_METAL\");\n\t\tByteToDir( es->eventParm, dir );\n\t\tCG_MissileHitWall( es->weapon, 0, position, dir, IMPACTSOUND_METAL );\n\t\tbreak;\n\n\tcase EV_RAILTRAIL:\n\t\tDEBUGNAME(\"EV_RAILTRAIL\");\n\t\tcent->currentState.weapon = WP_RAILGUN;\n\t\t// if the end was on a nomark surface, don't make an explosion\n\t\tCG_RailTrail( ci, es->origin2, es->pos.trBase );\n\t\tif ( es->eventParm != 255 ) {\n\t\t\tByteToDir( es->eventParm, dir );\n\t\t\tCG_MissileHitWall( es->weapon, es->clientNum, position, dir, IMPACTSOUND_DEFAULT );\n\t\t}\n\t\tbreak;\n\n\tcase EV_BULLET_HIT_WALL:\n\t\tDEBUGNAME(\"EV_BULLET_HIT_WALL\");\n\t\tByteToDir( es->eventParm, dir );\n\t\tCG_Bullet( es->pos.trBase, es->otherEntityNum, dir, qfalse, ENTITYNUM_WORLD );\n\t\tbreak;\n\n\tcase EV_BULLET_HIT_FLESH:\n\t\tDEBUGNAME(\"EV_BULLET_HIT_FLESH\");\n\t\tCG_Bullet( es->pos.trBase, es->otherEntityNum, dir, qtrue, es->eventParm );\n\t\tbreak;\n\n\tcase EV_SHOTGUN:\n\t\tDEBUGNAME(\"EV_SHOTGUN\");\n\t\tCG_ShotgunFire( es );\n\t\tbreak;\n\n\tcase EV_GENERAL_SOUND:\n\t\tDEBUGNAME(\"EV_GENERAL_SOUND\");\n\t\tif ( cgs.gameSounds[ es->eventParm ] ) {\n\t\t\ttrap_S_StartSound (NULL, es->number, CHAN_VOICE, cgs.gameSounds[ es->eventParm ] );\n\t\t} else {\n\t\t\ts = CG_ConfigString( CS_SOUNDS + es->eventParm );\n\t\t\ttrap_S_StartSound (NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, s ) );\n\t\t}\n\t\tbreak;\n\n\tcase EV_GLOBAL_SOUND:\t// play from the player's head so it never diminishes\n\t\tDEBUGNAME(\"EV_GLOBAL_SOUND\");\n\t\tif ( cgs.gameSounds[ es->eventParm ] ) {\n\t\t\ttrap_S_StartSound (NULL, cg.snap->ps.clientNum, CHAN_AUTO, cgs.gameSounds[ es->eventParm ] );\n\t\t} else {\n\t\t\ts = CG_ConfigString( CS_SOUNDS + es->eventParm );\n\t\t\ttrap_S_StartSound (NULL, cg.snap->ps.clientNum, CHAN_AUTO, CG_CustomSound( es->number, s ) );\n\t\t}\n\t\tbreak;\n\n\tcase EV_GLOBAL_TEAM_SOUND:\t// play from the player's head so it never diminishes\n\t\t{\n\t\t\tDEBUGNAME(\"EV_GLOBAL_TEAM_SOUND\");\n\t\t\tswitch( es->eventParm ) {\n\t\t\t\tcase GTS_RED_CAPTURE: // CTF: red team captured the blue flag, 1FCTF: red team captured the neutral flag\n\t\t\t\t\tif ( cgs.clientinfo[cg.clientNum].team == TEAM_RED )\n\t\t\t\t\t\tCG_AddBufferedSound( cgs.media.captureYourTeamSound );\n\t\t\t\t\telse\n\t\t\t\t\t\tCG_AddBufferedSound( cgs.media.captureOpponentSound );\n\t\t\t\t\tbreak;\n\t\t\t\tcase GTS_BLUE_CAPTURE: // CTF: blue team captured the red flag, 1FCTF: blue team captured the neutral flag\n\t\t\t\t\tif ( cgs.clientinfo[cg.clientNum].team == TEAM_BLUE )\n\t\t\t\t\t\tCG_AddBufferedSound( cgs.media.captureYourTeamSound );\n\t\t\t\t\telse\n\t\t\t\t\t\tCG_AddBufferedSound( cgs.media.captureOpponentSound );\n\t\t\t\t\tbreak;\n\t\t\t\tcase GTS_RED_RETURN: // CTF: blue flag returned, 1FCTF: never used\n\t\t\t\t\tif ( cgs.clientinfo[cg.clientNum].team == TEAM_RED )\n\t\t\t\t\t\tCG_AddBufferedSound( cgs.media.returnYourTeamSound );\n\t\t\t\t\telse\n\t\t\t\t\t\tCG_AddBufferedSound( cgs.media.returnOpponentSound );\n\t\t\t\t\t//\n\t\t\t\t\tCG_AddBufferedSound( cgs.media.blueFlagReturnedSound );\n\t\t\t\t\tbreak;\n\t\t\t\tcase GTS_BLUE_RETURN: // CTF red flag returned, 1FCTF: neutral flag returned\n\t\t\t\t\tif ( cgs.clientinfo[cg.clientNum].team == TEAM_BLUE )\n\t\t\t\t\t\tCG_AddBufferedSound( cgs.media.returnYourTeamSound );\n\t\t\t\t\telse\n\t\t\t\t\t\tCG_AddBufferedSound( cgs.media.returnOpponentSound );\n\t\t\t\t\t//\n\t\t\t\t\tCG_AddBufferedSound( cgs.media.redFlagReturnedSound );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase GTS_RED_TAKEN: // CTF: red team took blue flag, 1FCTF: blue team took the neutral flag\n\t\t\t\t\t// if this player picked up the flag then a sound is played in CG_CheckLocalSounds\n\t\t\t\t\tif (cg.snap->ps.powerups[PW_BLUEFLAG] || cg.snap->ps.powerups[PW_NEUTRALFLAG]) {\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\tif (cgs.clientinfo[cg.clientNum].team == TEAM_BLUE) {\n#ifdef MISSIONPACK\n\t\t\t\t\t\t\tif (cgs.gametype == GT_1FCTF) \n\t\t\t\t\t\t\t\tCG_AddBufferedSound( cgs.media.yourTeamTookTheFlagSound );\n\t\t\t\t\t\t\telse\n#endif\n\t\t\t\t\t\t \tCG_AddBufferedSound( cgs.media.enemyTookYourFlagSound );\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (cgs.clientinfo[cg.clientNum].team == TEAM_RED) {\n#ifdef MISSIONPACK\n\t\t\t\t\t\t\tif (cgs.gametype == GT_1FCTF)\n\t\t\t\t\t\t\t\tCG_AddBufferedSound( cgs.media.enemyTookTheFlagSound );\n\t\t\t\t\t\t\telse\n#endif\n \t\t\t\t\t\t\tCG_AddBufferedSound( cgs.media.yourTeamTookEnemyFlagSound );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase GTS_BLUE_TAKEN: // CTF: blue team took the red flag, 1FCTF red team took the neutral flag\n\t\t\t\t\t// if this player picked up the flag then a sound is played in CG_CheckLocalSounds\n\t\t\t\t\tif (cg.snap->ps.powerups[PW_REDFLAG] || cg.snap->ps.powerups[PW_NEUTRALFLAG]) {\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (cgs.clientinfo[cg.clientNum].team == TEAM_RED) {\n#ifdef MISSIONPACK\n\t\t\t\t\t\t\tif (cgs.gametype == GT_1FCTF)\n\t\t\t\t\t\t\t\tCG_AddBufferedSound( cgs.media.yourTeamTookTheFlagSound );\n\t\t\t\t\t\t\telse\n#endif\n\t\t\t\t\t\t\tCG_AddBufferedSound( cgs.media.enemyTookYourFlagSound );\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (cgs.clientinfo[cg.clientNum].team == TEAM_BLUE) {\n#ifdef MISSIONPACK\n\t\t\t\t\t\t\tif (cgs.gametype == GT_1FCTF)\n\t\t\t\t\t\t\t\tCG_AddBufferedSound( cgs.media.enemyTookTheFlagSound );\n\t\t\t\t\t\t\telse\n#endif\n\t\t\t\t\t\t\tCG_AddBufferedSound( cgs.media.yourTeamTookEnemyFlagSound );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase GTS_REDOBELISK_ATTACKED: // Overload: red obelisk is being attacked\n\t\t\t\t\tif (cgs.clientinfo[cg.clientNum].team == TEAM_RED) {\n\t\t\t\t\t\tCG_AddBufferedSound( cgs.media.yourBaseIsUnderAttackSound );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase GTS_BLUEOBELISK_ATTACKED: // Overload: blue obelisk is being attacked\n\t\t\t\t\tif (cgs.clientinfo[cg.clientNum].team == TEAM_BLUE) {\n\t\t\t\t\t\tCG_AddBufferedSound( cgs.media.yourBaseIsUnderAttackSound );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase GTS_REDTEAM_SCORED:\n\t\t\t\t\tCG_AddBufferedSound(cgs.media.redScoredSound);\n\t\t\t\t\tbreak;\n\t\t\t\tcase GTS_BLUETEAM_SCORED:\n\t\t\t\t\tCG_AddBufferedSound(cgs.media.blueScoredSound);\n\t\t\t\t\tbreak;\n\t\t\t\tcase GTS_REDTEAM_TOOK_LEAD:\n\t\t\t\t\tCG_AddBufferedSound(cgs.media.redLeadsSound);\n\t\t\t\t\tbreak;\n\t\t\t\tcase GTS_BLUETEAM_TOOK_LEAD:\n\t\t\t\t\tCG_AddBufferedSound(cgs.media.blueLeadsSound);\n\t\t\t\t\tbreak;\n\t\t\t\tcase GTS_TEAMS_ARE_TIED:\n\t\t\t\t\tCG_AddBufferedSound( cgs.media.teamsTiedSound );\n\t\t\t\t\tbreak;\n#ifdef MISSIONPACK\n\t\t\t\tcase GTS_KAMIKAZE:\n\t\t\t\t\ttrap_S_StartLocalSound(cgs.media.kamikazeFarSound, CHAN_ANNOUNCER);\n\t\t\t\t\tbreak;\n#endif\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\tcase EV_PAIN:\n\t\t// local player sounds are triggered in CG_CheckLocalSounds,\n\t\t// so ignore events on the player\n\t\tDEBUGNAME(\"EV_PAIN\");\n\t\tif ( cent->currentState.number != cg.snap->ps.clientNum ) {\n\t\t\tCG_PainEvent( cent, es->eventParm );\n\t\t}\n\t\tbreak;\n\n\tcase EV_DEATH1:\n\tcase EV_DEATH2:\n\tcase EV_DEATH3:\n\t\tDEBUGNAME(\"EV_DEATHx\");\n\t\ttrap_S_StartSound( NULL, es->number, CHAN_VOICE, \n\t\t\t\tCG_CustomSound( es->number, va(\"*death%i.wav\", event - EV_DEATH1 + 1) ) );\n\t\tbreak;\n\n\n\tcase EV_OBITUARY:\n\t\tDEBUGNAME(\"EV_OBITUARY\");\n\t\tCG_Obituary( es );\n\t\tbreak;\n\n\t//\n\t// powerup events\n\t//\n\tcase EV_POWERUP_QUAD:\n\t\tDEBUGNAME(\"EV_POWERUP_QUAD\");\n\t\tif ( es->number == cg.snap->ps.clientNum ) {\n\t\t\tcg.powerupActive = PW_QUAD;\n\t\t\tcg.powerupTime = cg.time;\n\t\t}\n\t\ttrap_S_StartSound (NULL, es->number, CHAN_ITEM, cgs.media.quadSound );\n\t\tbreak;\n\tcase EV_POWERUP_BATTLESUIT:\n\t\tDEBUGNAME(\"EV_POWERUP_BATTLESUIT\");\n\t\tif ( es->number == cg.snap->ps.clientNum ) {\n\t\t\tcg.powerupActive = PW_BATTLESUIT;\n\t\t\tcg.powerupTime = cg.time;\n\t\t}\n\t\ttrap_S_StartSound (NULL, es->number, CHAN_ITEM, cgs.media.protectSound );\n\t\tbreak;\n\tcase EV_POWERUP_REGEN:\n\t\tDEBUGNAME(\"EV_POWERUP_REGEN\");\n\t\tif ( es->number == cg.snap->ps.clientNum ) {\n\t\t\tcg.powerupActive = PW_REGEN;\n\t\t\tcg.powerupTime = cg.time;\n\t\t}\n\t\ttrap_S_StartSound (NULL, es->number, CHAN_ITEM, cgs.media.regenSound );\n\t\tbreak;\n\n\tcase EV_GIB_PLAYER:\n\t\tDEBUGNAME(\"EV_GIB_PLAYER\");\n\t\t// don't play gib sound when using the kamikaze because it interferes\n\t\t// with the kamikaze sound, downside is that the gib sound will also\n\t\t// not be played when someone is gibbed while just carrying the kamikaze\n\t\tif ( !(es->eFlags & EF_KAMIKAZE) ) {\n\t\t\ttrap_S_StartSound( NULL, es->number, CHAN_BODY, cgs.media.gibSound );\n\t\t}\n\t\tCG_GibPlayer( cent->lerpOrigin );\n\t\tbreak;\n\n\tcase EV_STOPLOOPINGSOUND:\n\t\tDEBUGNAME(\"EV_STOPLOOPINGSOUND\");\n\t\ttrap_S_StopLoopingSound( es->number );\n\t\tes->loopSound = 0;\n\t\tbreak;\n\n\tcase EV_DEBUG_LINE:\n\t\tDEBUGNAME(\"EV_DEBUG_LINE\");\n\t\tCG_Beam( cent );\n\t\tbreak;\n\n\tdefault:\n\t\tDEBUGNAME(\"UNKNOWN\");\n\t\tCG_Error( \"Unknown event: %i\", event );\n\t\tbreak;\n\t}\n\n}\n\n\n/*\n==============\nCG_CheckEvents\n\n==============\n*/\nvoid CG_CheckEvents( centity_t *cent ) {\n\t// check for event-only entities\n\tif ( cent->currentState.eType > ET_EVENTS ) {\n\t\tif ( cent->previousEvent ) {\n\t\t\treturn;\t// already fired\n\t\t}\n\t\t// if this is a player event set the entity number of the client entity number\n\t\tif ( cent->currentState.eFlags & EF_PLAYER_EVENT ) {\n\t\t\tcent->currentState.number = cent->currentState.otherEntityNum;\n\t\t}\n\n\t\tcent->previousEvent = 1;\n\n\t\tcent->currentState.event = cent->currentState.eType - ET_EVENTS;\n\t} else {\n\t\t// check for events riding with another entity\n\t\tif ( cent->currentState.event == cent->previousEvent ) {\n\t\t\treturn;\n\t\t}\n\t\tcent->previousEvent = cent->currentState.event;\n\t\tif ( ( cent->currentState.event & ~EV_EVENT_BITS ) == 0 ) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// calculate the position at exactly the frame time\n\tBG_EvaluateTrajectory( &cent->currentState.pos, cg.snap->serverTime, cent->lerpOrigin );\n\tCG_SetEntitySoundPosition( cent );\n\n\tCG_EntityEvent( cent, cent->lerpOrigin );\n}\n\n"
  },
  {
    "path": "code/cgame/cg_info.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// cg_info.c -- display information while data is being loading\n\n#include \"cg_local.h\"\n\n#define MAX_LOADING_PLAYER_ICONS\t16\n#define MAX_LOADING_ITEM_ICONS\t\t26\n\nstatic int\t\t\tloadingPlayerIconCount;\nstatic int\t\t\tloadingItemIconCount;\nstatic qhandle_t\tloadingPlayerIcons[MAX_LOADING_PLAYER_ICONS];\nstatic qhandle_t\tloadingItemIcons[MAX_LOADING_ITEM_ICONS];\n\n\n/*\n===================\nCG_DrawLoadingIcons\n===================\n*/\nstatic void CG_DrawLoadingIcons( void ) {\n\tint\t\tn;\n\tint\t\tx, y;\n\n\tfor( n = 0; n < loadingPlayerIconCount; n++ ) {\n\t\tx = 16 + n * 78;\n\t\ty = 324-40;\n\t\tCG_DrawPic( x, y, 64, 64, loadingPlayerIcons[n] );\n\t}\n\n\tfor( n = 0; n < loadingItemIconCount; n++ ) {\n\t\ty = 400-40;\n\t\tif( n >= 13 ) {\n\t\t\ty += 40;\n\t\t}\n\t\tx = 16 + n % 13 * 48;\n\t\tCG_DrawPic( x, y, 32, 32, loadingItemIcons[n] );\n\t}\n}\n\n\n/*\n======================\nCG_LoadingString\n\n======================\n*/\nvoid CG_LoadingString( const char *s ) {\n\tQ_strncpyz( cg.infoScreenText, s, sizeof( cg.infoScreenText ) );\n\n\ttrap_UpdateScreen();\n}\n\n/*\n===================\nCG_LoadingItem\n===================\n*/\nvoid CG_LoadingItem( int itemNum ) {\n\tgitem_t\t\t*item;\n\n\titem = &bg_itemlist[itemNum];\n\t\n\tif ( item->icon && loadingItemIconCount < MAX_LOADING_ITEM_ICONS ) {\n\t\tloadingItemIcons[loadingItemIconCount++] = trap_R_RegisterShaderNoMip( item->icon );\n\t}\n\n\tCG_LoadingString( item->pickup_name );\n}\n\n/*\n===================\nCG_LoadingClient\n===================\n*/\nvoid CG_LoadingClient( int clientNum ) {\n\tconst char\t\t*info;\n\tchar\t\t\t*skin;\n\tchar\t\t\tpersonality[MAX_QPATH];\n\tchar\t\t\tmodel[MAX_QPATH];\n\tchar\t\t\ticonName[MAX_QPATH];\n\n\tinfo = CG_ConfigString( CS_PLAYERS + clientNum );\n\n\tif ( loadingPlayerIconCount < MAX_LOADING_PLAYER_ICONS ) {\n\t\tQ_strncpyz( model, Info_ValueForKey( info, \"model\" ), sizeof( model ) );\n\t\tskin = Q_strrchr( model, '/' );\n\t\tif ( skin ) {\n\t\t\t*skin++ = '\\0';\n\t\t} else {\n\t\t\tskin = \"default\";\n\t\t}\n\n\t\tCom_sprintf( iconName, MAX_QPATH, \"models/players/%s/icon_%s.tga\", model, skin );\n\t\t\n\t\tloadingPlayerIcons[loadingPlayerIconCount] = trap_R_RegisterShaderNoMip( iconName );\n\t\tif ( !loadingPlayerIcons[loadingPlayerIconCount] ) {\n\t\t\tCom_sprintf( iconName, MAX_QPATH, \"models/players/characters/%s/icon_%s.tga\", model, skin );\n\t\t\tloadingPlayerIcons[loadingPlayerIconCount] = trap_R_RegisterShaderNoMip( iconName );\n\t\t}\n\t\tif ( !loadingPlayerIcons[loadingPlayerIconCount] ) {\n\t\t\tCom_sprintf( iconName, MAX_QPATH, \"models/players/%s/icon_%s.tga\", DEFAULT_MODEL, \"default\" );\n\t\t\tloadingPlayerIcons[loadingPlayerIconCount] = trap_R_RegisterShaderNoMip( iconName );\n\t\t}\n\t\tif ( loadingPlayerIcons[loadingPlayerIconCount] ) {\n\t\t\tloadingPlayerIconCount++;\n\t\t}\n\t}\n\n\tQ_strncpyz( personality, Info_ValueForKey( info, \"n\" ), sizeof(personality) );\n\tQ_CleanStr( personality );\n\n\tif( cgs.gametype == GT_SINGLE_PLAYER ) {\n\t\ttrap_S_RegisterSound( va( \"sound/player/announce/%s.wav\", personality ), qtrue );\n\t}\n\n\tCG_LoadingString( personality );\n}\n\n\n/*\n====================\nCG_DrawInformation\n\nDraw all the status / pacifier stuff during level loading\n====================\n*/\nvoid CG_DrawInformation( void ) {\n\tconst char\t*s;\n\tconst char\t*info;\n\tconst char\t*sysInfo;\n\tint\t\t\ty;\n\tint\t\t\tvalue;\n\tqhandle_t\tlevelshot;\n\tqhandle_t\tdetail;\n\tchar\t\tbuf[1024];\n\n\tinfo = CG_ConfigString( CS_SERVERINFO );\n\tsysInfo = CG_ConfigString( CS_SYSTEMINFO );\n\n\ts = Info_ValueForKey( info, \"mapname\" );\n\tlevelshot = trap_R_RegisterShaderNoMip( va( \"levelshots/%s.tga\", s ) );\n\tif ( !levelshot ) {\n\t\tlevelshot = trap_R_RegisterShaderNoMip( \"menu/art/unknownmap\" );\n\t}\n\ttrap_R_SetColor( NULL );\n\tCG_DrawPic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, levelshot );\n\n\t// blend a detail texture over it\n\tdetail = trap_R_RegisterShader( \"levelShotDetail\" );\n\ttrap_R_DrawStretchPic( 0, 0, cgs.glconfig.vidWidth, cgs.glconfig.vidHeight, 0, 0, 2.5, 2, detail );\n\n\t// draw the icons of things as they are loaded\n\tCG_DrawLoadingIcons();\n\n\t// the first 150 rows are reserved for the client connection\n\t// screen to write into\n\tif ( cg.infoScreenText[0] ) {\n\t\tUI_DrawProportionalString( 320, 128-32, va(\"Loading... %s\", cg.infoScreenText),\n\t\t\tUI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );\n\t} else {\n\t\tUI_DrawProportionalString( 320, 128-32, \"Awaiting snapshot...\",\n\t\t\tUI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );\n\t}\n\n\t// draw info string information\n\n\ty = 180-32;\n\n\t// don't print server lines if playing a local game\n\ttrap_Cvar_VariableStringBuffer( \"sv_running\", buf, sizeof( buf ) );\n\tif ( !atoi( buf ) ) {\n\t\t// server hostname\n\t\tQ_strncpyz(buf, Info_ValueForKey( info, \"sv_hostname\" ), 1024);\n\t\tQ_CleanStr(buf);\n\t\tUI_DrawProportionalString( 320, y, buf,\n\t\t\tUI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );\n\t\ty += PROP_HEIGHT;\n\n\t\t// pure server\n\t\ts = Info_ValueForKey( sysInfo, \"sv_pure\" );\n\t\tif ( s[0] == '1' ) {\n\t\t\tUI_DrawProportionalString( 320, y, \"Pure Server\",\n\t\t\t\tUI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );\n\t\t\ty += PROP_HEIGHT;\n\t\t}\n\n\t\t// server-specific message of the day\n\t\ts = CG_ConfigString( CS_MOTD );\n\t\tif ( s[0] ) {\n\t\t\tUI_DrawProportionalString( 320, y, s,\n\t\t\t\tUI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );\n\t\t\ty += PROP_HEIGHT;\n\t\t}\n\n\t\t// some extra space after hostname and motd\n\t\ty += 10;\n\t}\n\n\t// map-specific message (long map name)\n\ts = CG_ConfigString( CS_MESSAGE );\n\tif ( s[0] ) {\n\t\tUI_DrawProportionalString( 320, y, s,\n\t\t\tUI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );\n\t\ty += PROP_HEIGHT;\n\t}\n\n\t// cheats warning\n\ts = Info_ValueForKey( sysInfo, \"sv_cheats\" );\n\tif ( s[0] == '1' ) {\n\t\tUI_DrawProportionalString( 320, y, \"CHEATS ARE ENABLED\",\n\t\t\tUI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );\n\t\ty += PROP_HEIGHT;\n\t}\n\n\t// game type\n\tswitch ( cgs.gametype ) {\n\tcase GT_FFA:\n\t\ts = \"Free For All\";\n\t\tbreak;\n\tcase GT_SINGLE_PLAYER:\n\t\ts = \"Single Player\";\n\t\tbreak;\n\tcase GT_TOURNAMENT:\n\t\ts = \"Tournament\";\n\t\tbreak;\n\tcase GT_TEAM:\n\t\ts = \"Team Deathmatch\";\n\t\tbreak;\n\tcase GT_CTF:\n\t\ts = \"Capture The Flag\";\n\t\tbreak;\n#ifdef MISSIONPACK\n\tcase GT_1FCTF:\n\t\ts = \"One Flag CTF\";\n\t\tbreak;\n\tcase GT_OBELISK:\n\t\ts = \"Overload\";\n\t\tbreak;\n\tcase GT_HARVESTER:\n\t\ts = \"Harvester\";\n\t\tbreak;\n#endif\n\tdefault:\n\t\ts = \"Unknown Gametype\";\n\t\tbreak;\n\t}\n\tUI_DrawProportionalString( 320, y, s,\n\t\tUI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );\n\ty += PROP_HEIGHT;\n\t\t\n\tvalue = atoi( Info_ValueForKey( info, \"timelimit\" ) );\n\tif ( value ) {\n\t\tUI_DrawProportionalString( 320, y, va( \"timelimit %i\", value ),\n\t\t\tUI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );\n\t\ty += PROP_HEIGHT;\n\t}\n\n\tif (cgs.gametype < GT_CTF ) {\n\t\tvalue = atoi( Info_ValueForKey( info, \"fraglimit\" ) );\n\t\tif ( value ) {\n\t\t\tUI_DrawProportionalString( 320, y, va( \"fraglimit %i\", value ),\n\t\t\t\tUI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );\n\t\t\ty += PROP_HEIGHT;\n\t\t}\n\t}\n\n\tif (cgs.gametype >= GT_CTF) {\n\t\tvalue = atoi( Info_ValueForKey( info, \"capturelimit\" ) );\n\t\tif ( value ) {\n\t\t\tUI_DrawProportionalString( 320, y, va( \"capturelimit %i\", value ),\n\t\t\t\tUI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );\n\t\t\ty += PROP_HEIGHT;\n\t\t}\n\t}\n}\n\n"
  },
  {
    "path": "code/cgame/cg_local.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#include \"../game/q_shared.h\"\n#include \"tr_types.h\"\n#include \"../game/bg_public.h\"\n#include \"cg_public.h\"\n\n\n// The entire cgame module is unloaded and reloaded on each level change,\n// so there is NO persistant data between levels on the client side.\n// If you absolutely need something stored, it can either be kept\n// by the server in the server stored userinfos, or stashed in a cvar.\n\n#ifdef MISSIONPACK\n#define CG_FONT_THRESHOLD 0.1\n#endif\n\n#define\tPOWERUP_BLINKS\t\t5\n\n#define\tPOWERUP_BLINK_TIME\t1000\n#define\tFADE_TIME\t\t\t200\n#define\tPULSE_TIME\t\t\t200\n#define\tDAMAGE_DEFLECT_TIME\t100\n#define\tDAMAGE_RETURN_TIME\t400\n#define DAMAGE_TIME\t\t\t500\n#define\tLAND_DEFLECT_TIME\t150\n#define\tLAND_RETURN_TIME\t300\n#define\tSTEP_TIME\t\t\t200\n#define\tDUCK_TIME\t\t\t100\n#define\tPAIN_TWITCH_TIME\t200\n#define\tWEAPON_SELECT_TIME\t1400\n#define\tITEM_SCALEUP_TIME\t1000\n#define\tZOOM_TIME\t\t\t150\n#define\tITEM_BLOB_TIME\t\t200\n#define\tMUZZLE_FLASH_TIME\t20\n#define\tSINK_TIME\t\t\t1000\t\t// time for fragments to sink into ground before going away\n#define\tATTACKER_HEAD_TIME\t10000\n#define\tREWARD_TIME\t\t\t3000\n\n#define\tPULSE_SCALE\t\t\t1.5\t\t\t// amount to scale up the icons when activating\n\n#define\tMAX_STEP_CHANGE\t\t32\n\n#define\tMAX_VERTS_ON_POLY\t10\n#define\tMAX_MARK_POLYS\t\t256\n\n#define STAT_MINUS\t\t\t10\t// num frame for '-' stats digit\n\n#define\tICON_SIZE\t\t\t48\n#define\tCHAR_WIDTH\t\t\t32\n#define\tCHAR_HEIGHT\t\t\t48\n#define\tTEXT_ICON_SPACE\t\t4\n\n#define\tTEAMCHAT_WIDTH\t\t80\n#define TEAMCHAT_HEIGHT\t\t8\n\n// very large characters\n#define\tGIANT_WIDTH\t\t\t32\n#define\tGIANT_HEIGHT\t\t48\n\n#define\tNUM_CROSSHAIRS\t\t10\n\n#define TEAM_OVERLAY_MAXNAME_WIDTH\t12\n#define TEAM_OVERLAY_MAXLOCATION_WIDTH\t16\n\n#define\tDEFAULT_MODEL\t\t\t\"sarge\"\n#ifdef MISSIONPACK\n#define\tDEFAULT_TEAM_MODEL\t\t\"james\"\n#define\tDEFAULT_TEAM_HEAD\t\t\"*james\"\n#else\n#define\tDEFAULT_TEAM_MODEL\t\t\"sarge\"\n#define\tDEFAULT_TEAM_HEAD\t\t\"sarge\"\n#endif\n\n#define DEFAULT_REDTEAM_NAME\t\t\"Stroggs\"\n#define DEFAULT_BLUETEAM_NAME\t\t\"Pagans\"\n\ntypedef enum {\n\tFOOTSTEP_NORMAL,\n\tFOOTSTEP_BOOT,\n\tFOOTSTEP_FLESH,\n\tFOOTSTEP_MECH,\n\tFOOTSTEP_ENERGY,\n\tFOOTSTEP_METAL,\n\tFOOTSTEP_SPLASH,\n\n\tFOOTSTEP_TOTAL\n} footstep_t;\n\ntypedef enum {\n\tIMPACTSOUND_DEFAULT,\n\tIMPACTSOUND_METAL,\n\tIMPACTSOUND_FLESH\n} impactSound_t;\n\n//=================================================\n\n// player entities need to track more information\n// than any other type of entity.\n\n// note that not every player entity is a client entity,\n// because corpses after respawn are outside the normal\n// client numbering range\n\n// when changing animation, set animationTime to frameTime + lerping time\n// The current lerp will finish out, then it will lerp to the new animation\ntypedef struct {\n\tint\t\t\toldFrame;\n\tint\t\t\toldFrameTime;\t\t// time when ->oldFrame was exactly on\n\n\tint\t\t\tframe;\n\tint\t\t\tframeTime;\t\t\t// time when ->frame will be exactly on\n\n\tfloat\t\tbacklerp;\n\n\tfloat\t\tyawAngle;\n\tqboolean\tyawing;\n\tfloat\t\tpitchAngle;\n\tqboolean\tpitching;\n\n\tint\t\t\tanimationNumber;\t// may include ANIM_TOGGLEBIT\n\tanimation_t\t*animation;\n\tint\t\t\tanimationTime;\t\t// time when the first frame of the animation will be exact\n} lerpFrame_t;\n\n\ntypedef struct {\n\tlerpFrame_t\t\tlegs, torso, flag;\n\tint\t\t\t\tpainTime;\n\tint\t\t\t\tpainDirection;\t// flip from 0 to 1\n\tint\t\t\t\tlightningFiring;\n\n\t// railgun trail spawning\n\tvec3_t\t\t\trailgunImpact;\n\tqboolean\t\trailgunFlash;\n\n\t// machinegun spinning\n\tfloat\t\t\tbarrelAngle;\n\tint\t\t\t\tbarrelTime;\n\tqboolean\t\tbarrelSpinning;\n} playerEntity_t;\n\n//=================================================\n\n\n\n// centity_t have a direct corespondence with gentity_t in the game, but\n// only the entityState_t is directly communicated to the cgame\ntypedef struct centity_s {\n\tentityState_t\tcurrentState;\t// from cg.frame\n\tentityState_t\tnextState;\t\t// from cg.nextFrame, if available\n\tqboolean\t\tinterpolate;\t// true if next is valid to interpolate to\n\tqboolean\t\tcurrentValid;\t// true if cg.frame holds this entity\n\n\tint\t\t\t\tmuzzleFlashTime;\t// move to playerEntity?\n\tint\t\t\t\tpreviousEvent;\n\tint\t\t\t\tteleportFlag;\n\n\tint\t\t\t\ttrailTime;\t\t// so missile trails can handle dropped initial packets\n\tint\t\t\t\tdustTrailTime;\n\tint\t\t\t\tmiscTime;\n\n\tint\t\t\t\tsnapShotTime;\t// last time this entity was found in a snapshot\n\n\tplayerEntity_t\tpe;\n\n\tint\t\t\t\terrorTime;\t\t// decay the error from this time\n\tvec3_t\t\t\terrorOrigin;\n\tvec3_t\t\t\terrorAngles;\n\t\n\tqboolean\t\textrapolated;\t// false if origin / angles is an interpolation\n\tvec3_t\t\t\trawOrigin;\n\tvec3_t\t\t\trawAngles;\n\n\tvec3_t\t\t\tbeamEnd;\n\n\t// exact interpolated position of entity on this frame\n\tvec3_t\t\t\tlerpOrigin;\n\tvec3_t\t\t\tlerpAngles;\n} centity_t;\n\n\n//======================================================================\n\n// local entities are created as a result of events or predicted actions,\n// and live independantly from all server transmitted entities\n\ntypedef struct markPoly_s {\n\tstruct markPoly_s\t*prevMark, *nextMark;\n\tint\t\t\ttime;\n\tqhandle_t\tmarkShader;\n\tqboolean\talphaFade;\t\t// fade alpha instead of rgb\n\tfloat\t\tcolor[4];\n\tpoly_t\t\tpoly;\n\tpolyVert_t\tverts[MAX_VERTS_ON_POLY];\n} markPoly_t;\n\n\ntypedef enum {\n\tLE_MARK,\n\tLE_EXPLOSION,\n\tLE_SPRITE_EXPLOSION,\n\tLE_FRAGMENT,\n\tLE_MOVE_SCALE_FADE,\n\tLE_FALL_SCALE_FADE,\n\tLE_FADE_RGB,\n\tLE_SCALE_FADE,\n\tLE_SCOREPLUM,\n#ifdef MISSIONPACK\n\tLE_KAMIKAZE,\n\tLE_INVULIMPACT,\n\tLE_INVULJUICED,\n\tLE_SHOWREFENTITY\n#endif\n} leType_t;\n\ntypedef enum {\n\tLEF_PUFF_DONT_SCALE  = 0x0001,\t\t\t// do not scale size over time\n\tLEF_TUMBLE\t\t\t = 0x0002,\t\t\t// tumble over time, used for ejecting shells\n\tLEF_SOUND1\t\t\t = 0x0004,\t\t\t// sound 1 for kamikaze\n\tLEF_SOUND2\t\t\t = 0x0008\t\t\t// sound 2 for kamikaze\n} leFlag_t;\n\ntypedef enum {\n\tLEMT_NONE,\n\tLEMT_BURN,\n\tLEMT_BLOOD\n} leMarkType_t;\t\t\t// fragment local entities can leave marks on walls\n\ntypedef enum {\n\tLEBS_NONE,\n\tLEBS_BLOOD,\n\tLEBS_BRASS\n} leBounceSoundType_t;\t// fragment local entities can make sounds on impacts\n\ntypedef struct localEntity_s {\n\tstruct localEntity_s\t*prev, *next;\n\tleType_t\t\tleType;\n\tint\t\t\t\tleFlags;\n\n\tint\t\t\t\tstartTime;\n\tint\t\t\t\tendTime;\n\tint\t\t\t\tfadeInTime;\n\n\tfloat\t\t\tlifeRate;\t\t\t// 1.0 / (endTime - startTime)\n\n\ttrajectory_t\tpos;\n\ttrajectory_t\tangles;\n\n\tfloat\t\t\tbounceFactor;\t\t// 0.0 = no bounce, 1.0 = perfect\n\n\tfloat\t\t\tcolor[4];\n\n\tfloat\t\t\tradius;\n\n\tfloat\t\t\tlight;\n\tvec3_t\t\t\tlightColor;\n\n\tleMarkType_t\t\tleMarkType;\t\t// mark to leave on fragment impact\n\tleBounceSoundType_t\tleBounceSoundType;\n\n\trefEntity_t\t\trefEntity;\t\t\n} localEntity_t;\n\n//======================================================================\n\n\ntypedef struct {\n\tint\t\t\t\tclient;\n\tint\t\t\t\tscore;\n\tint\t\t\t\tping;\n\tint\t\t\t\ttime;\n\tint\t\t\t\tscoreFlags;\n\tint\t\t\t\tpowerUps;\n\tint\t\t\t\taccuracy;\n\tint\t\t\t\timpressiveCount;\n\tint\t\t\t\texcellentCount;\n\tint\t\t\t\tguantletCount;\n\tint\t\t\t\tdefendCount;\n\tint\t\t\t\tassistCount;\n\tint\t\t\t\tcaptures;\n\tqboolean\tperfect;\n\tint\t\t\t\tteam;\n} score_t;\n\n// each client has an associated clientInfo_t\n// that contains media references necessary to present the\n// client model and other color coded effects\n// this is regenerated each time a client's configstring changes,\n// usually as a result of a userinfo (name, model, etc) change\n#define\tMAX_CUSTOM_SOUNDS\t32\n\ntypedef struct {\n\tqboolean\t\tinfoValid;\n\n\tchar\t\t\tname[MAX_QPATH];\n\tteam_t\t\t\tteam;\n\n\tint\t\t\t\tbotSkill;\t\t// 0 = not bot, 1-5 = bot\n\n\tvec3_t\t\t\tcolor1;\n\tvec3_t\t\t\tcolor2;\n\n\tint\t\t\t\tscore;\t\t\t// updated by score servercmds\n\tint\t\t\t\tlocation;\t\t// location index for team mode\n\tint\t\t\t\thealth;\t\t\t// you only get this info about your teammates\n\tint\t\t\t\tarmor;\n\tint\t\t\t\tcurWeapon;\n\n\tint\t\t\t\thandicap;\n\tint\t\t\t\twins, losses;\t// in tourney mode\n\n\tint\t\t\t\tteamTask;\t\t// task in teamplay (offence/defence)\n\tqboolean\t\tteamLeader;\t\t// true when this is a team leader\n\n\tint\t\t\t\tpowerups;\t\t// so can display quad/flag status\n\n\tint\t\t\t\tmedkitUsageTime;\n\tint\t\t\t\tinvulnerabilityStartTime;\n\tint\t\t\t\tinvulnerabilityStopTime;\n\n\tint\t\t\t\tbreathPuffTime;\n\n\t// when clientinfo is changed, the loading of models/skins/sounds\n\t// can be deferred until you are dead, to prevent hitches in\n\t// gameplay\n\tchar\t\t\tmodelName[MAX_QPATH];\n\tchar\t\t\tskinName[MAX_QPATH];\n\tchar\t\t\theadModelName[MAX_QPATH];\n\tchar\t\t\theadSkinName[MAX_QPATH];\n\tchar\t\t\tredTeam[MAX_TEAMNAME];\n\tchar\t\t\tblueTeam[MAX_TEAMNAME];\n\tqboolean\t\tdeferred;\n\n\tqboolean\t\tnewAnims;\t\t// true if using the new mission pack animations\n\tqboolean\t\tfixedlegs;\t\t// true if legs yaw is always the same as torso yaw\n\tqboolean\t\tfixedtorso;\t\t// true if torso never changes yaw\n\n\tvec3_t\t\t\theadOffset;\t\t// move head in icon views\n\tfootstep_t\t\tfootsteps;\n\tgender_t\t\tgender;\t\t\t// from model\n\n\tqhandle_t\t\tlegsModel;\n\tqhandle_t\t\tlegsSkin;\n\n\tqhandle_t\t\ttorsoModel;\n\tqhandle_t\t\ttorsoSkin;\n\n\tqhandle_t\t\theadModel;\n\tqhandle_t\t\theadSkin;\n\n\tqhandle_t\t\tmodelIcon;\n\n\tanimation_t\t\tanimations[MAX_TOTALANIMATIONS];\n\n\tsfxHandle_t\t\tsounds[MAX_CUSTOM_SOUNDS];\n} clientInfo_t;\n\n\n// each WP_* weapon enum has an associated weaponInfo_t\n// that contains media references necessary to present the\n// weapon and its effects\ntypedef struct weaponInfo_s {\n\tqboolean\t\tregistered;\n\tgitem_t\t\t\t*item;\n\n\tqhandle_t\t\thandsModel;\t\t\t// the hands don't actually draw, they just position the weapon\n\tqhandle_t\t\tweaponModel;\n\tqhandle_t\t\tbarrelModel;\n\tqhandle_t\t\tflashModel;\n\n\tvec3_t\t\t\tweaponMidpoint;\t\t// so it will rotate centered instead of by tag\n\n\tfloat\t\t\tflashDlight;\n\tvec3_t\t\t\tflashDlightColor;\n\tsfxHandle_t\t\tflashSound[4];\t\t// fast firing weapons randomly choose\n\n\tqhandle_t\t\tweaponIcon;\n\tqhandle_t\t\tammoIcon;\n\n\tqhandle_t\t\tammoModel;\n\n\tqhandle_t\t\tmissileModel;\n\tsfxHandle_t\t\tmissileSound;\n\tvoid\t\t\t(*missileTrailFunc)( centity_t *, const struct weaponInfo_s *wi );\n\tfloat\t\t\tmissileDlight;\n\tvec3_t\t\t\tmissileDlightColor;\n\tint\t\t\t\tmissileRenderfx;\n\n\tvoid\t\t\t(*ejectBrassFunc)( centity_t * );\n\n\tfloat\t\t\ttrailRadius;\n\tfloat\t\t\twiTrailTime;\n\n\tsfxHandle_t\t\treadySound;\n\tsfxHandle_t\t\tfiringSound;\n\tqboolean\t\tloopFireSound;\n} weaponInfo_t;\n\n\n// each IT_* item has an associated itemInfo_t\n// that constains media references necessary to present the\n// item and its effects\ntypedef struct {\n\tqboolean\t\tregistered;\n\tqhandle_t\t\tmodels[MAX_ITEM_MODELS];\n\tqhandle_t\t\ticon;\n} itemInfo_t;\n\n\ntypedef struct {\n\tint\t\t\t\titemNum;\n} powerupInfo_t;\n\n\n#define MAX_SKULLTRAIL\t\t10\n\ntypedef struct {\n\tvec3_t positions[MAX_SKULLTRAIL];\n\tint numpositions;\n} skulltrail_t;\n\n\n#define MAX_REWARDSTACK\t\t10\n#define MAX_SOUNDBUFFER\t\t20\n\n//======================================================================\n\n// all cg.stepTime, cg.duckTime, cg.landTime, etc are set to cg.time when the action\n// occurs, and they will have visible effects for #define STEP_TIME or whatever msec after\n\n#define MAX_PREDICTED_EVENTS\t16\n \ntypedef struct {\n\tint\t\t\tclientFrame;\t\t// incremented each frame\n\n\tint\t\t\tclientNum;\n\t\n\tqboolean\tdemoPlayback;\n\tqboolean\tlevelShot;\t\t\t// taking a level menu screenshot\n\tint\t\t\tdeferredPlayerLoading;\n\tqboolean\tloading;\t\t\t// don't defer players at initial startup\n\tqboolean\tintermissionStarted;\t// don't play voice rewards, because game will end shortly\n\n\t// there are only one or two snapshot_t that are relevent at a time\n\tint\t\t\tlatestSnapshotNum;\t// the number of snapshots the client system has received\n\tint\t\t\tlatestSnapshotTime;\t// the time from latestSnapshotNum, so we don't need to read the snapshot yet\n\n\tsnapshot_t\t*snap;\t\t\t\t// cg.snap->serverTime <= cg.time\n\tsnapshot_t\t*nextSnap;\t\t\t// cg.nextSnap->serverTime > cg.time, or NULL\n\tsnapshot_t\tactiveSnapshots[2];\n\n\tfloat\t\tframeInterpolation;\t// (float)( cg.time - cg.frame->serverTime ) / (cg.nextFrame->serverTime - cg.frame->serverTime)\n\n\tqboolean\tthisFrameTeleport;\n\tqboolean\tnextFrameTeleport;\n\n\tint\t\t\tframetime;\t\t// cg.time - cg.oldTime\n\n\tint\t\t\ttime;\t\t\t// this is the time value that the client\n\t\t\t\t\t\t\t\t// is rendering at.\n\tint\t\t\toldTime;\t\t// time at last frame, used for missile trails and prediction checking\n\n\tint\t\t\tphysicsTime;\t// either cg.snap->time or cg.nextSnap->time\n\n\tint\t\t\ttimelimitWarnings;\t// 5 min, 1 min, overtime\n\tint\t\t\tfraglimitWarnings;\n\n\tqboolean\tmapRestart;\t\t\t// set on a map restart to set back the weapon\n\n\tqboolean\trenderingThirdPerson;\t\t// during deaths, chasecams, etc\n\n\t// prediction state\n\tqboolean\thyperspace;\t\t\t\t// true if prediction has hit a trigger_teleport\n\tplayerState_t\tpredictedPlayerState;\n\tcentity_t\t\tpredictedPlayerEntity;\n\tqboolean\tvalidPPS;\t\t\t\t// clear until the first call to CG_PredictPlayerState\n\tint\t\t\tpredictedErrorTime;\n\tvec3_t\t\tpredictedError;\n\n\tint\t\t\teventSequence;\n\tint\t\t\tpredictableEvents[MAX_PREDICTED_EVENTS];\n\n\tfloat\t\tstepChange;\t\t\t\t// for stair up smoothing\n\tint\t\t\tstepTime;\n\n\tfloat\t\tduckChange;\t\t\t\t// for duck viewheight smoothing\n\tint\t\t\tduckTime;\n\n\tfloat\t\tlandChange;\t\t\t\t// for landing hard\n\tint\t\t\tlandTime;\n\n\t// input state sent to server\n\tint\t\t\tweaponSelect;\n\n\t// auto rotating items\n\tvec3_t\t\tautoAngles;\n\tvec3_t\t\tautoAxis[3];\n\tvec3_t\t\tautoAnglesFast;\n\tvec3_t\t\tautoAxisFast[3];\n\n\t// view rendering\n\trefdef_t\trefdef;\n\tvec3_t\t\trefdefViewAngles;\t\t// will be converted to refdef.viewaxis\n\n\t// zoom key\n\tqboolean\tzoomed;\n\tint\t\t\tzoomTime;\n\tfloat\t\tzoomSensitivity;\n\n\t// information screen text during loading\n\tchar\t\tinfoScreenText[MAX_STRING_CHARS];\n\n\t// scoreboard\n\tint\t\t\tscoresRequestTime;\n\tint\t\t\tnumScores;\n\tint\t\t\tselectedScore;\n\tint\t\t\tteamScores[2];\n\tscore_t\t\tscores[MAX_CLIENTS];\n\tqboolean\tshowScores;\n\tqboolean\tscoreBoardShowing;\n\tint\t\t\tscoreFadeTime;\n\tchar\t\tkillerName[MAX_NAME_LENGTH];\n\tchar\t\t\tspectatorList[MAX_STRING_CHARS];\t\t// list of names\n\tint\t\t\t\tspectatorLen;\t\t\t\t\t\t\t\t\t\t\t\t// length of list\n\tfloat\t\t\tspectatorWidth;\t\t\t\t\t\t\t\t\t\t\t// width in device units\n\tint\t\t\t\tspectatorTime;\t\t\t\t\t\t\t\t\t\t\t// next time to offset\n\tint\t\t\t\tspectatorPaintX;\t\t\t\t\t\t\t\t\t\t// current paint x\n\tint\t\t\t\tspectatorPaintX2;\t\t\t\t\t\t\t\t\t\t// current paint x\n\tint\t\t\t\tspectatorOffset;\t\t\t\t\t\t\t\t\t\t// current offset from start\n\tint\t\t\t\tspectatorPaintLen; \t\t\t\t\t\t\t\t\t// current offset from start\n\n\t// skull trails\n\tskulltrail_t\tskulltrails[MAX_CLIENTS];\n\n\t// centerprinting\n\tint\t\t\tcenterPrintTime;\n\tint\t\t\tcenterPrintCharWidth;\n\tint\t\t\tcenterPrintY;\n\tchar\t\tcenterPrint[1024];\n\tint\t\t\tcenterPrintLines;\n\n\t// low ammo warning state\n\tint\t\t\tlowAmmoWarning;\t\t// 1 = low, 2 = empty\n\n\t// kill timers for carnage reward\n\tint\t\t\tlastKillTime;\n\n\t// crosshair client ID\n\tint\t\t\tcrosshairClientNum;\n\tint\t\t\tcrosshairClientTime;\n\n\t// powerup active flashing\n\tint\t\t\tpowerupActive;\n\tint\t\t\tpowerupTime;\n\n\t// attacking player\n\tint\t\t\tattackerTime;\n\tint\t\t\tvoiceTime;\n\n\t// reward medals\n\tint\t\t\trewardStack;\n\tint\t\t\trewardTime;\n\tint\t\t\trewardCount[MAX_REWARDSTACK];\n\tqhandle_t\trewardShader[MAX_REWARDSTACK];\n\tqhandle_t\trewardSound[MAX_REWARDSTACK];\n\n\t// sound buffer mainly for announcer sounds\n\tint\t\t\tsoundBufferIn;\n\tint\t\t\tsoundBufferOut;\n\tint\t\t\tsoundTime;\n\tqhandle_t\tsoundBuffer[MAX_SOUNDBUFFER];\n\n\t// for voice chat buffer\n\tint\t\t\tvoiceChatTime;\n\tint\t\t\tvoiceChatBufferIn;\n\tint\t\t\tvoiceChatBufferOut;\n\n\t// warmup countdown\n\tint\t\t\twarmup;\n\tint\t\t\twarmupCount;\n\n\t//==========================\n\n\tint\t\t\titemPickup;\n\tint\t\t\titemPickupTime;\n\tint\t\t\titemPickupBlendTime;\t// the pulse around the crosshair is timed seperately\n\n\tint\t\t\tweaponSelectTime;\n\tint\t\t\tweaponAnimation;\n\tint\t\t\tweaponAnimationTime;\n\n\t// blend blobs\n\tfloat\t\tdamageTime;\n\tfloat\t\tdamageX, damageY, damageValue;\n\n\t// status bar head\n\tfloat\t\theadYaw;\n\tfloat\t\theadEndPitch;\n\tfloat\t\theadEndYaw;\n\tint\t\t\theadEndTime;\n\tfloat\t\theadStartPitch;\n\tfloat\t\theadStartYaw;\n\tint\t\t\theadStartTime;\n\n\t// view movement\n\tfloat\t\tv_dmg_time;\n\tfloat\t\tv_dmg_pitch;\n\tfloat\t\tv_dmg_roll;\n\n\tvec3_t\t\tkick_angles;\t// weapon kicks\n\tvec3_t\t\tkick_origin;\n\n\t// temp working variables for player view\n\tfloat\t\tbobfracsin;\n\tint\t\t\tbobcycle;\n\tfloat\t\txyspeed;\n\tint     nextOrbitTime;\n\n\t//qboolean cameraMode;\t\t// if rendering from a loaded camera\n\n\n\t// development tool\n\trefEntity_t\t\ttestModelEntity;\n\tchar\t\t\ttestModelName[MAX_QPATH];\n\tqboolean\t\ttestGun;\n\n} cg_t;\n\n\n// all of the model, shader, and sound references that are\n// loaded at gamestate time are stored in cgMedia_t\n// Other media that can be tied to clients, weapons, or items are\n// stored in the clientInfo_t, itemInfo_t, weaponInfo_t, and powerupInfo_t\ntypedef struct {\n\tqhandle_t\tcharsetShader;\n\tqhandle_t\tcharsetProp;\n\tqhandle_t\tcharsetPropGlow;\n\tqhandle_t\tcharsetPropB;\n\tqhandle_t\twhiteShader;\n\n\tqhandle_t\tredCubeModel;\n\tqhandle_t\tblueCubeModel;\n\tqhandle_t\tredCubeIcon;\n\tqhandle_t\tblueCubeIcon;\n\tqhandle_t\tredFlagModel;\n\tqhandle_t\tblueFlagModel;\n\tqhandle_t\tneutralFlagModel;\n\tqhandle_t\tredFlagShader[3];\n\tqhandle_t\tblueFlagShader[3];\n\tqhandle_t\tflagShader[4];\n\n\tqhandle_t\tflagPoleModel;\n\tqhandle_t\tflagFlapModel;\n\n\tqhandle_t\tredFlagFlapSkin;\n\tqhandle_t\tblueFlagFlapSkin;\n\tqhandle_t\tneutralFlagFlapSkin;\n\n\tqhandle_t\tredFlagBaseModel;\n\tqhandle_t\tblueFlagBaseModel;\n\tqhandle_t\tneutralFlagBaseModel;\n\n#ifdef MISSIONPACK\n\tqhandle_t\toverloadBaseModel;\n\tqhandle_t\toverloadTargetModel;\n\tqhandle_t\toverloadLightsModel;\n\tqhandle_t\toverloadEnergyModel;\n\n\tqhandle_t\tharvesterModel;\n\tqhandle_t\tharvesterRedSkin;\n\tqhandle_t\tharvesterBlueSkin;\n\tqhandle_t\tharvesterNeutralModel;\n#endif\n\n\tqhandle_t\tarmorModel;\n\tqhandle_t\tarmorIcon;\n\n\tqhandle_t\tteamStatusBar;\n\n\tqhandle_t\tdeferShader;\n\n\t// gib explosions\n\tqhandle_t\tgibAbdomen;\n\tqhandle_t\tgibArm;\n\tqhandle_t\tgibChest;\n\tqhandle_t\tgibFist;\n\tqhandle_t\tgibFoot;\n\tqhandle_t\tgibForearm;\n\tqhandle_t\tgibIntestine;\n\tqhandle_t\tgibLeg;\n\tqhandle_t\tgibSkull;\n\tqhandle_t\tgibBrain;\n\n\tqhandle_t\tsmoke2;\n\n\tqhandle_t\tmachinegunBrassModel;\n\tqhandle_t\tshotgunBrassModel;\n\n\tqhandle_t\trailRingsShader;\n\tqhandle_t\trailCoreShader;\n\n\tqhandle_t\tlightningShader;\n\n\tqhandle_t\tfriendShader;\n\n\tqhandle_t\tballoonShader;\n\tqhandle_t\tconnectionShader;\n\n\tqhandle_t\tselectShader;\n\tqhandle_t\tviewBloodShader;\n\tqhandle_t\ttracerShader;\n\tqhandle_t\tcrosshairShader[NUM_CROSSHAIRS];\n\tqhandle_t\tlagometerShader;\n\tqhandle_t\tbackTileShader;\n\tqhandle_t\tnoammoShader;\n\n\tqhandle_t\tsmokePuffShader;\n\tqhandle_t\tsmokePuffRageProShader;\n\tqhandle_t\tshotgunSmokePuffShader;\n\tqhandle_t\tplasmaBallShader;\n\tqhandle_t\twaterBubbleShader;\n\tqhandle_t\tbloodTrailShader;\n#ifdef MISSIONPACK\n\tqhandle_t\tnailPuffShader;\n\tqhandle_t\tblueProxMine;\n#endif\n\n\tqhandle_t\tnumberShaders[11];\n\n\tqhandle_t\tshadowMarkShader;\n\n\tqhandle_t\tbotSkillShaders[5];\n\n\t// wall mark shaders\n\tqhandle_t\twakeMarkShader;\n\tqhandle_t\tbloodMarkShader;\n\tqhandle_t\tbulletMarkShader;\n\tqhandle_t\tburnMarkShader;\n\tqhandle_t\tholeMarkShader;\n\tqhandle_t\tenergyMarkShader;\n\n\t// powerup shaders\n\tqhandle_t\tquadShader;\n\tqhandle_t\tredQuadShader;\n\tqhandle_t\tquadWeaponShader;\n\tqhandle_t\tinvisShader;\n\tqhandle_t\tregenShader;\n\tqhandle_t\tbattleSuitShader;\n\tqhandle_t\tbattleWeaponShader;\n\tqhandle_t\thastePuffShader;\n\tqhandle_t\tredKamikazeShader;\n\tqhandle_t\tblueKamikazeShader;\n\n\t// weapon effect models\n\tqhandle_t\tbulletFlashModel;\n\tqhandle_t\tringFlashModel;\n\tqhandle_t\tdishFlashModel;\n\tqhandle_t\tlightningExplosionModel;\n\n\t// weapon effect shaders\n\tqhandle_t\trailExplosionShader;\n\tqhandle_t\tplasmaExplosionShader;\n\tqhandle_t\tbulletExplosionShader;\n\tqhandle_t\trocketExplosionShader;\n\tqhandle_t\tgrenadeExplosionShader;\n\tqhandle_t\tbfgExplosionShader;\n\tqhandle_t\tbloodExplosionShader;\n\n\t// special effects models\n\tqhandle_t\tteleportEffectModel;\n\tqhandle_t\tteleportEffectShader;\n#ifdef MISSIONPACK\n\tqhandle_t\tkamikazeEffectModel;\n\tqhandle_t\tkamikazeShockWave;\n\tqhandle_t\tkamikazeHeadModel;\n\tqhandle_t\tkamikazeHeadTrail;\n\tqhandle_t\tguardPowerupModel;\n\tqhandle_t\tscoutPowerupModel;\n\tqhandle_t\tdoublerPowerupModel;\n\tqhandle_t\tammoRegenPowerupModel;\n\tqhandle_t\tinvulnerabilityImpactModel;\n\tqhandle_t\tinvulnerabilityJuicedModel;\n\tqhandle_t\tmedkitUsageModel;\n\tqhandle_t\tdustPuffShader;\n\tqhandle_t\theartShader;\n#endif\n\tqhandle_t\tinvulnerabilityPowerupModel;\n\n\t// scoreboard headers\n\tqhandle_t\tscoreboardName;\n\tqhandle_t\tscoreboardPing;\n\tqhandle_t\tscoreboardScore;\n\tqhandle_t\tscoreboardTime;\n\n\t// medals shown during gameplay\n\tqhandle_t\tmedalImpressive;\n\tqhandle_t\tmedalExcellent;\n\tqhandle_t\tmedalGauntlet;\n\tqhandle_t\tmedalDefend;\n\tqhandle_t\tmedalAssist;\n\tqhandle_t\tmedalCapture;\n\n\t// sounds\n\tsfxHandle_t\tquadSound;\n\tsfxHandle_t\ttracerSound;\n\tsfxHandle_t\tselectSound;\n\tsfxHandle_t\tuseNothingSound;\n\tsfxHandle_t\twearOffSound;\n\tsfxHandle_t\tfootsteps[FOOTSTEP_TOTAL][4];\n\tsfxHandle_t\tsfx_lghit1;\n\tsfxHandle_t\tsfx_lghit2;\n\tsfxHandle_t\tsfx_lghit3;\n\tsfxHandle_t\tsfx_ric1;\n\tsfxHandle_t\tsfx_ric2;\n\tsfxHandle_t\tsfx_ric3;\n\tsfxHandle_t\tsfx_railg;\n\tsfxHandle_t\tsfx_rockexp;\n\tsfxHandle_t\tsfx_plasmaexp;\n#ifdef MISSIONPACK\n\tsfxHandle_t\tsfx_proxexp;\n\tsfxHandle_t\tsfx_nghit;\n\tsfxHandle_t\tsfx_nghitflesh;\n\tsfxHandle_t\tsfx_nghitmetal;\n\tsfxHandle_t\tsfx_chghit;\n\tsfxHandle_t\tsfx_chghitflesh;\n\tsfxHandle_t\tsfx_chghitmetal;\n\tsfxHandle_t kamikazeExplodeSound;\n\tsfxHandle_t kamikazeImplodeSound;\n\tsfxHandle_t kamikazeFarSound;\n\tsfxHandle_t useInvulnerabilitySound;\n\tsfxHandle_t invulnerabilityImpactSound1;\n\tsfxHandle_t invulnerabilityImpactSound2;\n\tsfxHandle_t invulnerabilityImpactSound3;\n\tsfxHandle_t invulnerabilityJuicedSound;\n\tsfxHandle_t obeliskHitSound1;\n\tsfxHandle_t obeliskHitSound2;\n\tsfxHandle_t obeliskHitSound3;\n\tsfxHandle_t\tobeliskRespawnSound;\n\tsfxHandle_t\twinnerSound;\n\tsfxHandle_t\tloserSound;\n\tsfxHandle_t\tyouSuckSound;\n#endif\n\tsfxHandle_t\tgibSound;\n\tsfxHandle_t\tgibBounce1Sound;\n\tsfxHandle_t\tgibBounce2Sound;\n\tsfxHandle_t\tgibBounce3Sound;\n\tsfxHandle_t\tteleInSound;\n\tsfxHandle_t\tteleOutSound;\n\tsfxHandle_t\tnoAmmoSound;\n\tsfxHandle_t\trespawnSound;\n\tsfxHandle_t talkSound;\n\tsfxHandle_t landSound;\n\tsfxHandle_t fallSound;\n\tsfxHandle_t jumpPadSound;\n\n\tsfxHandle_t oneMinuteSound;\n\tsfxHandle_t fiveMinuteSound;\n\tsfxHandle_t suddenDeathSound;\n\n\tsfxHandle_t threeFragSound;\n\tsfxHandle_t twoFragSound;\n\tsfxHandle_t oneFragSound;\n\n\tsfxHandle_t hitSound;\n\tsfxHandle_t hitSoundHighArmor;\n\tsfxHandle_t hitSoundLowArmor;\n\tsfxHandle_t hitTeamSound;\n\tsfxHandle_t impressiveSound;\n\tsfxHandle_t excellentSound;\n\tsfxHandle_t deniedSound;\n\tsfxHandle_t humiliationSound;\n\tsfxHandle_t assistSound;\n\tsfxHandle_t defendSound;\n\tsfxHandle_t firstImpressiveSound;\n\tsfxHandle_t firstExcellentSound;\n\tsfxHandle_t firstHumiliationSound;\n\n\tsfxHandle_t takenLeadSound;\n\tsfxHandle_t tiedLeadSound;\n\tsfxHandle_t lostLeadSound;\n\n\tsfxHandle_t voteNow;\n\tsfxHandle_t votePassed;\n\tsfxHandle_t voteFailed;\n\n\tsfxHandle_t watrInSound;\n\tsfxHandle_t watrOutSound;\n\tsfxHandle_t watrUnSound;\n\n\tsfxHandle_t flightSound;\n\tsfxHandle_t medkitSound;\n\n\tsfxHandle_t weaponHoverSound;\n\n\t// teamplay sounds\n\tsfxHandle_t captureAwardSound;\n\tsfxHandle_t redScoredSound;\n\tsfxHandle_t blueScoredSound;\n\tsfxHandle_t redLeadsSound;\n\tsfxHandle_t blueLeadsSound;\n\tsfxHandle_t teamsTiedSound;\n\n\tsfxHandle_t\tcaptureYourTeamSound;\n\tsfxHandle_t\tcaptureOpponentSound;\n\tsfxHandle_t\treturnYourTeamSound;\n\tsfxHandle_t\treturnOpponentSound;\n\tsfxHandle_t\ttakenYourTeamSound;\n\tsfxHandle_t\ttakenOpponentSound;\n\n\tsfxHandle_t redFlagReturnedSound;\n\tsfxHandle_t blueFlagReturnedSound;\n\tsfxHandle_t neutralFlagReturnedSound;\n\tsfxHandle_t\tenemyTookYourFlagSound;\n\tsfxHandle_t\tenemyTookTheFlagSound;\n\tsfxHandle_t yourTeamTookEnemyFlagSound;\n\tsfxHandle_t yourTeamTookTheFlagSound;\n\tsfxHandle_t\tyouHaveFlagSound;\n\tsfxHandle_t yourBaseIsUnderAttackSound;\n\tsfxHandle_t holyShitSound;\n\n\t// tournament sounds\n\tsfxHandle_t\tcount3Sound;\n\tsfxHandle_t\tcount2Sound;\n\tsfxHandle_t\tcount1Sound;\n\tsfxHandle_t\tcountFightSound;\n\tsfxHandle_t\tcountPrepareSound;\n\n#ifdef MISSIONPACK\n\t// new stuff\n\tqhandle_t patrolShader;\n\tqhandle_t assaultShader;\n\tqhandle_t campShader;\n\tqhandle_t followShader;\n\tqhandle_t defendShader;\n\tqhandle_t teamLeaderShader;\n\tqhandle_t retrieveShader;\n\tqhandle_t escortShader;\n\tqhandle_t flagShaders[3];\n\tsfxHandle_t\tcountPrepareTeamSound;\n\n\tsfxHandle_t ammoregenSound;\n\tsfxHandle_t doublerSound;\n\tsfxHandle_t guardSound;\n\tsfxHandle_t scoutSound;\n#endif\n\tqhandle_t cursor;\n\tqhandle_t selectCursor;\n\tqhandle_t sizeCursor;\n\n\tsfxHandle_t\tregenSound;\n\tsfxHandle_t\tprotectSound;\n\tsfxHandle_t\tn_healthSound;\n\tsfxHandle_t\thgrenb1aSound;\n\tsfxHandle_t\thgrenb2aSound;\n\tsfxHandle_t\twstbimplSound;\n\tsfxHandle_t\twstbimpmSound;\n\tsfxHandle_t\twstbimpdSound;\n\tsfxHandle_t\twstbactvSound;\n\n} cgMedia_t;\n\n\n// The client game static (cgs) structure hold everything\n// loaded or calculated from the gamestate.  It will NOT\n// be cleared when a tournement restart is done, allowing\n// all clients to begin playing instantly\ntypedef struct {\n\tgameState_t\t\tgameState;\t\t\t// gamestate from server\n\tglconfig_t\t\tglconfig;\t\t\t// rendering configuration\n\tfloat\t\t\tscreenXScale;\t\t// derived from glconfig\n\tfloat\t\t\tscreenYScale;\n\tfloat\t\t\tscreenXBias;\n\n\tint\t\t\t\tserverCommandSequence;\t// reliable command stream counter\n\tint\t\t\t\tprocessedSnapshotNum;// the number of snapshots cgame has requested\n\n\tqboolean\t\tlocalServer;\t\t// detected on startup by checking sv_running\n\n\t// parsed from serverinfo\n\tgametype_t\t\tgametype;\n\tint\t\t\t\tdmflags;\n\tint\t\t\t\tteamflags;\n\tint\t\t\t\tfraglimit;\n\tint\t\t\t\tcapturelimit;\n\tint\t\t\t\ttimelimit;\n\tint\t\t\t\tmaxclients;\n\tchar\t\t\tmapname[MAX_QPATH];\n\tchar\t\t\tredTeam[MAX_QPATH];\n\tchar\t\t\tblueTeam[MAX_QPATH];\n\n\tint\t\t\t\tvoteTime;\n\tint\t\t\t\tvoteYes;\n\tint\t\t\t\tvoteNo;\n\tqboolean\t\tvoteModified;\t\t\t// beep whenever changed\n\tchar\t\t\tvoteString[MAX_STRING_TOKENS];\n\n\tint\t\t\t\tteamVoteTime[2];\n\tint\t\t\t\tteamVoteYes[2];\n\tint\t\t\t\tteamVoteNo[2];\n\tqboolean\t\tteamVoteModified[2];\t// beep whenever changed\n\tchar\t\t\tteamVoteString[2][MAX_STRING_TOKENS];\n\n\tint\t\t\t\tlevelStartTime;\n\n\tint\t\t\t\tscores1, scores2;\t\t// from configstrings\n\tint\t\t\t\tredflag, blueflag;\t\t// flag status from configstrings\n\tint\t\t\t\tflagStatus;\n\n\tqboolean  newHud;\n\n\t//\n\t// locally derived information from gamestate\n\t//\n\tqhandle_t\t\tgameModels[MAX_MODELS];\n\tsfxHandle_t\t\tgameSounds[MAX_SOUNDS];\n\n\tint\t\t\t\tnumInlineModels;\n\tqhandle_t\t\tinlineDrawModel[MAX_MODELS];\n\tvec3_t\t\t\tinlineModelMidpoints[MAX_MODELS];\n\n\tclientInfo_t\tclientinfo[MAX_CLIENTS];\n\n\t// teamchat width is *3 because of embedded color codes\n\tchar\t\t\tteamChatMsgs[TEAMCHAT_HEIGHT][TEAMCHAT_WIDTH*3+1];\n\tint\t\t\t\tteamChatMsgTimes[TEAMCHAT_HEIGHT];\n\tint\t\t\t\tteamChatPos;\n\tint\t\t\t\tteamLastChatPos;\n\n\tint cursorX;\n\tint cursorY;\n\tqboolean eventHandling;\n\tqboolean mouseCaptured;\n\tqboolean sizingHud;\n\tvoid *capturedItem;\n\tqhandle_t activeCursor;\n\n\t// orders\n\tint currentOrder;\n\tqboolean orderPending;\n\tint orderTime;\n\tint currentVoiceClient;\n\tint acceptOrderTime;\n\tint acceptTask;\n\tint acceptLeader;\n\tchar acceptVoice[MAX_NAME_LENGTH];\n\n\t// media\n\tcgMedia_t\t\tmedia;\n\n} cgs_t;\n\n//==============================================================================\n\nextern\tcgs_t\t\t\tcgs;\nextern\tcg_t\t\t\tcg;\nextern\tcentity_t\t\tcg_entities[MAX_GENTITIES];\nextern\tweaponInfo_t\tcg_weapons[MAX_WEAPONS];\nextern\titemInfo_t\t\tcg_items[MAX_ITEMS];\nextern\tmarkPoly_t\t\tcg_markPolys[MAX_MARK_POLYS];\n\nextern\tvmCvar_t\t\tcg_centertime;\nextern\tvmCvar_t\t\tcg_runpitch;\nextern\tvmCvar_t\t\tcg_runroll;\nextern\tvmCvar_t\t\tcg_bobup;\nextern\tvmCvar_t\t\tcg_bobpitch;\nextern\tvmCvar_t\t\tcg_bobroll;\nextern\tvmCvar_t\t\tcg_swingSpeed;\nextern\tvmCvar_t\t\tcg_shadows;\nextern\tvmCvar_t\t\tcg_gibs;\nextern\tvmCvar_t\t\tcg_drawTimer;\nextern\tvmCvar_t\t\tcg_drawFPS;\nextern\tvmCvar_t\t\tcg_drawSnapshot;\nextern\tvmCvar_t\t\tcg_draw3dIcons;\nextern\tvmCvar_t\t\tcg_drawIcons;\nextern\tvmCvar_t\t\tcg_drawAmmoWarning;\nextern\tvmCvar_t\t\tcg_drawCrosshair;\nextern\tvmCvar_t\t\tcg_drawCrosshairNames;\nextern\tvmCvar_t\t\tcg_drawRewards;\nextern\tvmCvar_t\t\tcg_drawTeamOverlay;\nextern\tvmCvar_t\t\tcg_teamOverlayUserinfo;\nextern\tvmCvar_t\t\tcg_crosshairX;\nextern\tvmCvar_t\t\tcg_crosshairY;\nextern\tvmCvar_t\t\tcg_crosshairSize;\nextern\tvmCvar_t\t\tcg_crosshairHealth;\nextern\tvmCvar_t\t\tcg_drawStatus;\nextern\tvmCvar_t\t\tcg_draw2D;\nextern\tvmCvar_t\t\tcg_animSpeed;\nextern\tvmCvar_t\t\tcg_debugAnim;\nextern\tvmCvar_t\t\tcg_debugPosition;\nextern\tvmCvar_t\t\tcg_debugEvents;\nextern\tvmCvar_t\t\tcg_railTrailTime;\nextern\tvmCvar_t\t\tcg_errorDecay;\nextern\tvmCvar_t\t\tcg_nopredict;\nextern\tvmCvar_t\t\tcg_noPlayerAnims;\nextern\tvmCvar_t\t\tcg_showmiss;\nextern\tvmCvar_t\t\tcg_footsteps;\nextern\tvmCvar_t\t\tcg_addMarks;\nextern\tvmCvar_t\t\tcg_brassTime;\nextern\tvmCvar_t\t\tcg_gun_frame;\nextern\tvmCvar_t\t\tcg_gun_x;\nextern\tvmCvar_t\t\tcg_gun_y;\nextern\tvmCvar_t\t\tcg_gun_z;\nextern\tvmCvar_t\t\tcg_drawGun;\nextern\tvmCvar_t\t\tcg_viewsize;\nextern\tvmCvar_t\t\tcg_tracerChance;\nextern\tvmCvar_t\t\tcg_tracerWidth;\nextern\tvmCvar_t\t\tcg_tracerLength;\nextern\tvmCvar_t\t\tcg_autoswitch;\nextern\tvmCvar_t\t\tcg_ignore;\nextern\tvmCvar_t\t\tcg_simpleItems;\nextern\tvmCvar_t\t\tcg_fov;\nextern\tvmCvar_t\t\tcg_zoomFov;\nextern\tvmCvar_t\t\tcg_thirdPersonRange;\nextern\tvmCvar_t\t\tcg_thirdPersonAngle;\nextern\tvmCvar_t\t\tcg_thirdPerson;\nextern\tvmCvar_t\t\tcg_stereoSeparation;\nextern\tvmCvar_t\t\tcg_lagometer;\nextern\tvmCvar_t\t\tcg_drawAttacker;\nextern\tvmCvar_t\t\tcg_synchronousClients;\nextern\tvmCvar_t\t\tcg_teamChatTime;\nextern\tvmCvar_t\t\tcg_teamChatHeight;\nextern\tvmCvar_t\t\tcg_stats;\nextern\tvmCvar_t \t\tcg_forceModel;\nextern\tvmCvar_t \t\tcg_buildScript;\nextern\tvmCvar_t\t\tcg_paused;\nextern\tvmCvar_t\t\tcg_blood;\nextern\tvmCvar_t\t\tcg_predictItems;\nextern\tvmCvar_t\t\tcg_deferPlayers;\nextern\tvmCvar_t\t\tcg_drawFriend;\nextern\tvmCvar_t\t\tcg_teamChatsOnly;\nextern\tvmCvar_t\t\tcg_noVoiceChats;\nextern\tvmCvar_t\t\tcg_noVoiceText;\nextern  vmCvar_t\t\tcg_scorePlum;\nextern\tvmCvar_t\t\tcg_smoothClients;\nextern\tvmCvar_t\t\tpmove_fixed;\nextern\tvmCvar_t\t\tpmove_msec;\n//extern\tvmCvar_t\t\tcg_pmove_fixed;\nextern\tvmCvar_t\t\tcg_cameraOrbit;\nextern\tvmCvar_t\t\tcg_cameraOrbitDelay;\nextern\tvmCvar_t\t\tcg_timescaleFadeEnd;\nextern\tvmCvar_t\t\tcg_timescaleFadeSpeed;\nextern\tvmCvar_t\t\tcg_timescale;\nextern\tvmCvar_t\t\tcg_cameraMode;\nextern  vmCvar_t\t\tcg_smallFont;\nextern  vmCvar_t\t\tcg_bigFont;\nextern\tvmCvar_t\t\tcg_noTaunt;\nextern\tvmCvar_t\t\tcg_noProjectileTrail;\nextern\tvmCvar_t\t\tcg_oldRail;\nextern\tvmCvar_t\t\tcg_oldRocket;\nextern\tvmCvar_t\t\tcg_oldPlasma;\nextern\tvmCvar_t\t\tcg_trueLightning;\n#ifdef MISSIONPACK\nextern\tvmCvar_t\t\tcg_redTeamName;\nextern\tvmCvar_t\t\tcg_blueTeamName;\nextern\tvmCvar_t\t\tcg_currentSelectedPlayer;\nextern\tvmCvar_t\t\tcg_currentSelectedPlayerName;\nextern\tvmCvar_t\t\tcg_singlePlayer;\nextern\tvmCvar_t\t\tcg_enableDust;\nextern\tvmCvar_t\t\tcg_enableBreath;\nextern\tvmCvar_t\t\tcg_singlePlayerActive;\nextern  vmCvar_t\t\tcg_recordSPDemo;\nextern  vmCvar_t\t\tcg_recordSPDemoName;\nextern\tvmCvar_t\t\tcg_obeliskRespawnDelay;\n#endif\n\n//\n// cg_main.c\n//\nconst char *CG_ConfigString( int index );\nconst char *CG_Argv( int arg );\n\nvoid QDECL CG_Printf( const char *msg, ... );\nvoid QDECL CG_Error( const char *msg, ... );\n\nvoid CG_StartMusic( void );\n\nvoid CG_UpdateCvars( void );\n\nint CG_CrosshairPlayer( void );\nint CG_LastAttacker( void );\nvoid CG_LoadMenus(const char *menuFile);\nvoid CG_KeyEvent(int key, qboolean down);\nvoid CG_MouseEvent(int x, int y);\nvoid CG_EventHandling(int type);\nvoid CG_RankRunFrame( void );\nvoid CG_SetScoreSelection(void *menu);\nscore_t *CG_GetSelectedScore();\nvoid CG_BuildSpectatorString();\n\n\n//\n// cg_view.c\n//\nvoid CG_TestModel_f (void);\nvoid CG_TestGun_f (void);\nvoid CG_TestModelNextFrame_f (void);\nvoid CG_TestModelPrevFrame_f (void);\nvoid CG_TestModelNextSkin_f (void);\nvoid CG_TestModelPrevSkin_f (void);\nvoid CG_ZoomDown_f( void );\nvoid CG_ZoomUp_f( void );\nvoid CG_AddBufferedSound( sfxHandle_t sfx);\n\nvoid CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demoPlayback );\n\n\n//\n// cg_drawtools.c\n//\nvoid CG_AdjustFrom640( float *x, float *y, float *w, float *h );\nvoid CG_FillRect( float x, float y, float width, float height, const float *color );\nvoid CG_DrawPic( float x, float y, float width, float height, qhandle_t hShader );\nvoid CG_DrawString( float x, float y, const char *string, \n\t\t\t\t   float charWidth, float charHeight, const float *modulate );\n\n\nvoid CG_DrawStringExt( int x, int y, const char *string, const float *setColor, \n\t\tqboolean forceColor, qboolean shadow, int charWidth, int charHeight, int maxChars );\nvoid CG_DrawBigString( int x, int y, const char *s, float alpha );\nvoid CG_DrawBigStringColor( int x, int y, const char *s, vec4_t color );\nvoid CG_DrawSmallString( int x, int y, const char *s, float alpha );\nvoid CG_DrawSmallStringColor( int x, int y, const char *s, vec4_t color );\n\nint CG_DrawStrlen( const char *str );\n\nfloat\t*CG_FadeColor( int startMsec, int totalMsec );\nfloat *CG_TeamColor( int team );\nvoid CG_TileClear( void );\nvoid CG_ColorForHealth( vec4_t hcolor );\nvoid CG_GetColorForHealth( int health, int armor, vec4_t hcolor );\n\nvoid UI_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color );\nvoid CG_DrawRect( float x, float y, float width, float height, float size, const float *color );\nvoid CG_DrawSides(float x, float y, float w, float h, float size);\nvoid CG_DrawTopBottom(float x, float y, float w, float h, float size);\n\n\n//\n// cg_draw.c, cg_newDraw.c\n//\nextern\tint sortedTeamPlayers[TEAM_MAXOVERLAY];\nextern\tint\tnumSortedTeamPlayers;\nextern\tint drawTeamOverlayModificationCount;\nextern  char systemChat[256];\nextern  char teamChat1[256];\nextern  char teamChat2[256];\n\nvoid CG_AddLagometerFrameInfo( void );\nvoid CG_AddLagometerSnapshotInfo( snapshot_t *snap );\nvoid CG_CenterPrint( const char *str, int y, int charWidth );\nvoid CG_DrawHead( float x, float y, float w, float h, int clientNum, vec3_t headAngles );\nvoid CG_DrawActive( stereoFrame_t stereoView );\nvoid CG_DrawFlagModel( float x, float y, float w, float h, int team, qboolean force2D );\nvoid CG_DrawTeamBackground( int x, int y, int w, int h, float alpha, int team );\nvoid CG_OwnerDraw(float x, float y, float w, float h, float text_x, float text_y, int ownerDraw, int ownerDrawFlags, int align, float special, float scale, vec4_t color, qhandle_t shader, int textStyle);\nvoid CG_Text_Paint(float x, float y, float scale, vec4_t color, const char *text, float adjust, int limit, int style);\nint CG_Text_Width(const char *text, float scale, int limit);\nint CG_Text_Height(const char *text, float scale, int limit);\nvoid CG_SelectPrevPlayer();\nvoid CG_SelectNextPlayer();\nfloat CG_GetValue(int ownerDraw);\nqboolean CG_OwnerDrawVisible(int flags);\nvoid CG_RunMenuScript(char **args);\nvoid CG_ShowResponseHead();\nvoid CG_SetPrintString(int type, const char *p);\nvoid CG_InitTeamChat();\nvoid CG_GetTeamColor(vec4_t *color);\nconst char *CG_GetGameStatusText();\nconst char *CG_GetKillerText();\nvoid CG_Draw3DModel( float x, float y, float w, float h, qhandle_t model, qhandle_t skin, vec3_t origin, vec3_t angles );\nvoid CG_Text_PaintChar(float x, float y, float width, float height, float scale, float s, float t, float s2, float t2, qhandle_t hShader);\nvoid CG_CheckOrderPending();\nconst char *CG_GameTypeString();\nqboolean CG_YourTeamHasFlag();\nqboolean CG_OtherTeamHasFlag();\nqhandle_t CG_StatusHandle(int task);\n\n\n\n//\n// cg_player.c\n//\nvoid CG_Player( centity_t *cent );\nvoid CG_ResetPlayerEntity( centity_t *cent );\nvoid CG_AddRefEntityWithPowerups( refEntity_t *ent, entityState_t *state, int team );\nvoid CG_NewClientInfo( int clientNum );\nsfxHandle_t\tCG_CustomSound( int clientNum, const char *soundName );\n\n//\n// cg_predict.c\n//\nvoid CG_BuildSolidList( void );\nint\tCG_PointContents( const vec3_t point, int passEntityNum );\nvoid CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, \n\t\t\t\t\t int skipNumber, int mask );\nvoid CG_PredictPlayerState( void );\nvoid CG_LoadDeferredPlayers( void );\n\n\n//\n// cg_events.c\n//\nvoid CG_CheckEvents( centity_t *cent );\nconst char\t*CG_PlaceString( int rank );\nvoid CG_EntityEvent( centity_t *cent, vec3_t position );\nvoid CG_PainEvent( centity_t *cent, int health );\n\n\n//\n// cg_ents.c\n//\nvoid CG_SetEntitySoundPosition( centity_t *cent );\nvoid CG_AddPacketEntities( void );\nvoid CG_Beam( centity_t *cent );\nvoid CG_AdjustPositionForMover( const vec3_t in, int moverNum, int fromTime, int toTime, vec3_t out );\n\nvoid CG_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent, \n\t\t\t\t\t\t\tqhandle_t parentModel, char *tagName );\nvoid CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *parent, \n\t\t\t\t\t\t\tqhandle_t parentModel, char *tagName );\n\n\n\n//\n// cg_weapons.c\n//\nvoid CG_NextWeapon_f( void );\nvoid CG_PrevWeapon_f( void );\nvoid CG_Weapon_f( void );\n\nvoid CG_RegisterWeapon( int weaponNum );\nvoid CG_RegisterItemVisuals( int itemNum );\n\nvoid CG_FireWeapon( centity_t *cent );\nvoid CG_MissileHitWall( int weapon, int clientNum, vec3_t origin, vec3_t dir, impactSound_t soundType );\nvoid CG_MissileHitPlayer( int weapon, vec3_t origin, vec3_t dir, int entityNum );\nvoid CG_ShotgunFire( entityState_t *es );\nvoid CG_Bullet( vec3_t origin, int sourceEntityNum, vec3_t normal, qboolean flesh, int fleshEntityNum );\n\nvoid CG_RailTrail( clientInfo_t *ci, vec3_t start, vec3_t end );\nvoid CG_GrappleTrail( centity_t *ent, const weaponInfo_t *wi );\nvoid CG_AddViewWeapon (playerState_t *ps);\nvoid CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent, int team );\nvoid CG_DrawWeaponSelect( void );\n\nvoid CG_OutOfAmmoChange( void );\t// should this be in pmove?\n\n//\n// cg_marks.c\n//\nvoid\tCG_InitMarkPolys( void );\nvoid\tCG_AddMarks( void );\nvoid\tCG_ImpactMark( qhandle_t markShader, \n\t\t\t\t    const vec3_t origin, const vec3_t dir, \n\t\t\t\t\tfloat orientation, \n\t\t\t\t    float r, float g, float b, float a, \n\t\t\t\t\tqboolean alphaFade, \n\t\t\t\t\tfloat radius, qboolean temporary );\n\n//\n// cg_localents.c\n//\nvoid\tCG_InitLocalEntities( void );\nlocalEntity_t\t*CG_AllocLocalEntity( void );\nvoid\tCG_AddLocalEntities( void );\n\n//\n// cg_effects.c\n//\nlocalEntity_t *CG_SmokePuff( const vec3_t p, \n\t\t\t\t   const vec3_t vel, \n\t\t\t\t   float radius,\n\t\t\t\t   float r, float g, float b, float a,\n\t\t\t\t   float duration,\n\t\t\t\t   int startTime,\n\t\t\t\t   int fadeInTime,\n\t\t\t\t   int leFlags,\n\t\t\t\t   qhandle_t hShader );\nvoid CG_BubbleTrail( vec3_t start, vec3_t end, float spacing );\nvoid CG_SpawnEffect( vec3_t org );\n#ifdef MISSIONPACK\nvoid CG_KamikazeEffect( vec3_t org );\nvoid CG_ObeliskExplode( vec3_t org, int entityNum );\nvoid CG_ObeliskPain( vec3_t org );\nvoid CG_InvulnerabilityImpact( vec3_t org, vec3_t angles );\nvoid CG_InvulnerabilityJuiced( vec3_t org );\nvoid CG_LightningBoltBeam( vec3_t start, vec3_t end );\n#endif\nvoid CG_ScorePlum( int client, vec3_t org, int score );\n\nvoid CG_GibPlayer( vec3_t playerOrigin );\nvoid CG_BigExplode( vec3_t playerOrigin );\n\nvoid CG_Bleed( vec3_t origin, int entityNum );\n\nlocalEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir,\n\t\t\t\t\t\t\t\tqhandle_t hModel, qhandle_t shader, int msec,\n\t\t\t\t\t\t\t\tqboolean isSprite );\n\n//\n// cg_snapshot.c\n//\nvoid CG_ProcessSnapshots( void );\n\n//\n// cg_info.c\n//\nvoid CG_LoadingString( const char *s );\nvoid CG_LoadingItem( int itemNum );\nvoid CG_LoadingClient( int clientNum );\nvoid CG_DrawInformation( void );\n\n//\n// cg_scoreboard.c\n//\nqboolean CG_DrawOldScoreboard( void );\nvoid CG_DrawOldTourneyScoreboard( void );\n\n//\n// cg_consolecmds.c\n//\nqboolean CG_ConsoleCommand( void );\nvoid CG_InitConsoleCommands( void );\n\n//\n// cg_servercmds.c\n//\nvoid CG_ExecuteNewServerCommands( int latestSequence );\nvoid CG_ParseServerinfo( void );\nvoid CG_SetConfigValues( void );\nvoid CG_LoadVoiceChats( void );\nvoid CG_ShaderStateChanged(void);\nvoid CG_VoiceChatLocal( int mode, qboolean voiceOnly, int clientNum, int color, const char *cmd );\nvoid CG_PlayBufferedVoiceChats( void );\n\n//\n// cg_playerstate.c\n//\nvoid CG_Respawn( void );\nvoid CG_TransitionPlayerState( playerState_t *ps, playerState_t *ops );\nvoid CG_CheckChangedPredictableEvents( playerState_t *ps );\n\n\n//===============================================\n\n//\n// system traps\n// These functions are how the cgame communicates with the main game system\n//\n\n// print message on the local console\nvoid\t\ttrap_Print( const char *fmt );\n\n// abort the game\nvoid\t\ttrap_Error( const char *fmt );\n\n// milliseconds should only be used for performance tuning, never\n// for anything game related.  Get time from the CG_DrawActiveFrame parameter\nint\t\t\ttrap_Milliseconds( void );\n\n// console variable interaction\nvoid\t\ttrap_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags );\nvoid\t\ttrap_Cvar_Update( vmCvar_t *vmCvar );\nvoid\t\ttrap_Cvar_Set( const char *var_name, const char *value );\nvoid\t\ttrap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize );\n\n// ServerCommand and ConsoleCommand parameter access\nint\t\t\ttrap_Argc( void );\nvoid\t\ttrap_Argv( int n, char *buffer, int bufferLength );\nvoid\t\ttrap_Args( char *buffer, int bufferLength );\n\n// filesystem access\n// returns length of file\nint\t\t\ttrap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode );\nvoid\t\ttrap_FS_Read( void *buffer, int len, fileHandle_t f );\nvoid\t\ttrap_FS_Write( const void *buffer, int len, fileHandle_t f );\nvoid\t\ttrap_FS_FCloseFile( fileHandle_t f );\nint\t\t\ttrap_FS_Seek( fileHandle_t f, long offset, int origin ); // fsOrigin_t\n\n// add commands to the local console as if they were typed in\n// for map changing, etc.  The command is not executed immediately,\n// but will be executed in order the next time console commands\n// are processed\nvoid\t\ttrap_SendConsoleCommand( const char *text );\n\n// register a command name so the console can perform command completion.\n// FIXME: replace this with a normal console command \"defineCommand\"?\nvoid\t\ttrap_AddCommand( const char *cmdName );\n\n// send a string to the server over the network\nvoid\t\ttrap_SendClientCommand( const char *s );\n\n// force a screen update, only used during gamestate load\nvoid\t\ttrap_UpdateScreen( void );\n\n// model collision\nvoid\t\ttrap_CM_LoadMap( const char *mapname );\nint\t\t\ttrap_CM_NumInlineModels( void );\nclipHandle_t trap_CM_InlineModel( int index );\t\t// 0 = world, 1+ = bmodels\nclipHandle_t trap_CM_TempBoxModel( const vec3_t mins, const vec3_t maxs );\nint\t\t\ttrap_CM_PointContents( const vec3_t p, clipHandle_t model );\nint\t\t\ttrap_CM_TransformedPointContents( const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles );\nvoid\t\ttrap_CM_BoxTrace( trace_t *results, const vec3_t start, const vec3_t end,\n\t\t\t\t\t  const vec3_t mins, const vec3_t maxs,\n\t\t\t\t\t  clipHandle_t model, int brushmask );\nvoid\t\ttrap_CM_TransformedBoxTrace( trace_t *results, const vec3_t start, const vec3_t end,\n\t\t\t\t\t  const vec3_t mins, const vec3_t maxs,\n\t\t\t\t\t  clipHandle_t model, int brushmask,\n\t\t\t\t\t  const vec3_t origin, const vec3_t angles );\n\n// Returns the projection of a polygon onto the solid brushes in the world\nint\t\t\ttrap_CM_MarkFragments( int numPoints, const vec3_t *points, \n\t\t\tconst vec3_t projection,\n\t\t\tint maxPoints, vec3_t pointBuffer,\n\t\t\tint maxFragments, markFragment_t *fragmentBuffer );\n\n// normal sounds will have their volume dynamically changed as their entity\n// moves and the listener moves\nvoid\t\ttrap_S_StartSound( vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx );\nvoid\t\ttrap_S_StopLoopingSound(int entnum);\n\n// a local sound is always played full volume\nvoid\t\ttrap_S_StartLocalSound( sfxHandle_t sfx, int channelNum );\nvoid\t\ttrap_S_ClearLoopingSounds( qboolean killall );\nvoid\t\ttrap_S_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx );\nvoid\t\ttrap_S_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx );\nvoid\t\ttrap_S_UpdateEntityPosition( int entityNum, const vec3_t origin );\n\n// respatialize recalculates the volumes of sound as they should be heard by the\n// given entityNum and position\nvoid\t\ttrap_S_Respatialize( int entityNum, const vec3_t origin, vec3_t axis[3], int inwater );\nsfxHandle_t\ttrap_S_RegisterSound( const char *sample, qboolean compressed );\t\t// returns buzz if not found\nvoid\t\ttrap_S_StartBackgroundTrack( const char *intro, const char *loop );\t// empty name stops music\nvoid\ttrap_S_StopBackgroundTrack( void );\n\n\nvoid\t\ttrap_R_LoadWorldMap( const char *mapname );\n\n// all media should be registered during level startup to prevent\n// hitches during gameplay\nqhandle_t\ttrap_R_RegisterModel( const char *name );\t\t\t// returns rgb axis if not found\nqhandle_t\ttrap_R_RegisterSkin( const char *name );\t\t\t// returns all white if not found\nqhandle_t\ttrap_R_RegisterShader( const char *name );\t\t\t// returns all white if not found\nqhandle_t\ttrap_R_RegisterShaderNoMip( const char *name );\t\t\t// returns all white if not found\n\n// a scene is built up by calls to R_ClearScene and the various R_Add functions.\n// Nothing is drawn until R_RenderScene is called.\nvoid\t\ttrap_R_ClearScene( void );\nvoid\t\ttrap_R_AddRefEntityToScene( const refEntity_t *re );\n\n// polys are intended for simple wall marks, not really for doing\n// significant construction\nvoid\t\ttrap_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts );\nvoid\t\ttrap_R_AddPolysToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts, int numPolys );\nvoid\t\ttrap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b );\nint\t\t\ttrap_R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir );\nvoid\t\ttrap_R_RenderScene( const refdef_t *fd );\nvoid\t\ttrap_R_SetColor( const float *rgba );\t// NULL = 1,1,1,1\nvoid\t\ttrap_R_DrawStretchPic( float x, float y, float w, float h, \n\t\t\tfloat s1, float t1, float s2, float t2, qhandle_t hShader );\nvoid\t\ttrap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs );\nint\t\t\ttrap_R_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame, \n\t\t\t\t\t   float frac, const char *tagName );\nvoid\t\ttrap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset );\n\n// The glconfig_t will not change during the life of a cgame.\n// If it needs to change, the entire cgame will be restarted, because\n// all the qhandle_t are then invalid.\nvoid\t\ttrap_GetGlconfig( glconfig_t *glconfig );\n\n// the gamestate should be grabbed at startup, and whenever a\n// configstring changes\nvoid\t\ttrap_GetGameState( gameState_t *gamestate );\n\n// cgame will poll each frame to see if a newer snapshot has arrived\n// that it is interested in.  The time is returned seperately so that\n// snapshot latency can be calculated.\nvoid\t\ttrap_GetCurrentSnapshotNumber( int *snapshotNumber, int *serverTime );\n\n// a snapshot get can fail if the snapshot (or the entties it holds) is so\n// old that it has fallen out of the client system queue\nqboolean\ttrap_GetSnapshot( int snapshotNumber, snapshot_t *snapshot );\n\n// retrieve a text command from the server stream\n// the current snapshot will hold the number of the most recent command\n// qfalse can be returned if the client system handled the command\n// argc() / argv() can be used to examine the parameters of the command\nqboolean\ttrap_GetServerCommand( int serverCommandNumber );\n\n// returns the most recent command number that can be passed to GetUserCmd\n// this will always be at least one higher than the number in the current\n// snapshot, and it may be quite a few higher if it is a fast computer on\n// a lagged connection\nint\t\t\ttrap_GetCurrentCmdNumber( void );\t\n\nqboolean\ttrap_GetUserCmd( int cmdNumber, usercmd_t *ucmd );\n\n// used for the weapon select and zoom\nvoid\t\ttrap_SetUserCmdValue( int stateValue, float sensitivityScale );\n\n// aids for VM testing\nvoid\t\ttestPrintInt( char *string, int i );\nvoid\t\ttestPrintFloat( char *string, float f );\n\nint\t\t\ttrap_MemoryRemaining( void );\nvoid\t\ttrap_R_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font);\nqboolean\ttrap_Key_IsDown( int keynum );\nint\t\t\ttrap_Key_GetCatcher( void );\nvoid\t\ttrap_Key_SetCatcher( int catcher );\nint\t\t\ttrap_Key_GetKey( const char *binding );\n\n\ntypedef enum {\n  SYSTEM_PRINT,\n  CHAT_PRINT,\n  TEAMCHAT_PRINT\n} q3print_t; // bk001201 - warning: useless keyword or type name in empty declaration\n\n\nint trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits);\ne_status trap_CIN_StopCinematic(int handle);\ne_status trap_CIN_RunCinematic (int handle);\nvoid trap_CIN_DrawCinematic (int handle);\nvoid trap_CIN_SetExtents (int handle, int x, int y, int w, int h);\n\nvoid trap_SnapVector( float *v );\n\nqboolean\ttrap_loadCamera(const char *name);\nvoid\t\ttrap_startCamera(int time);\nqboolean\ttrap_getCameraInfo(int time, vec3_t *origin, vec3_t *angles);\n\nqboolean\ttrap_GetEntityToken( char *buffer, int bufferSize );\n\nvoid\tCG_ClearParticles (void);\nvoid\tCG_AddParticles (void);\nvoid\tCG_ParticleSnow (qhandle_t pshader, vec3_t origin, vec3_t origin2, int turb, float range, int snum);\nvoid\tCG_ParticleSmoke (qhandle_t pshader, centity_t *cent);\nvoid\tCG_AddParticleShrapnel (localEntity_t *le);\nvoid\tCG_ParticleSnowFlurry (qhandle_t pshader, centity_t *cent);\nvoid\tCG_ParticleBulletDebris (vec3_t\torg, vec3_t vel, int duration);\nvoid\tCG_ParticleSparks (vec3_t org, vec3_t vel, int duration, float x, float y, float speed);\nvoid\tCG_ParticleDust (centity_t *cent, vec3_t origin, vec3_t dir);\nvoid\tCG_ParticleMisc (qhandle_t pshader, vec3_t origin, int size, int duration, float alpha);\nvoid\tCG_ParticleExplosion (char *animStr, vec3_t origin, vec3_t vel, int duration, int sizeStart, int sizeEnd);\nextern qboolean\t\tinitparticles;\nint CG_NewParticleArea ( int num );\n\n\n"
  },
  {
    "path": "code/cgame/cg_localents.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n// cg_localents.c -- every frame, generate renderer commands for locally\n// processed entities, like smoke puffs, gibs, shells, etc.\n\n#include \"cg_local.h\"\n\n#define\tMAX_LOCAL_ENTITIES\t512\nlocalEntity_t\tcg_localEntities[MAX_LOCAL_ENTITIES];\nlocalEntity_t\tcg_activeLocalEntities;\t\t// double linked list\nlocalEntity_t\t*cg_freeLocalEntities;\t\t// single linked list\n\n/*\n===================\nCG_InitLocalEntities\n\nThis is called at startup and for tournement restarts\n===================\n*/\nvoid\tCG_InitLocalEntities( void ) {\n\tint\t\ti;\n\n\tmemset( cg_localEntities, 0, sizeof( cg_localEntities ) );\n\tcg_activeLocalEntities.next = &cg_activeLocalEntities;\n\tcg_activeLocalEntities.prev = &cg_activeLocalEntities;\n\tcg_freeLocalEntities = cg_localEntities;\n\tfor ( i = 0 ; i < MAX_LOCAL_ENTITIES - 1 ; i++ ) {\n\t\tcg_localEntities[i].next = &cg_localEntities[i+1];\n\t}\n}\n\n\n/*\n==================\nCG_FreeLocalEntity\n==================\n*/\nvoid CG_FreeLocalEntity( localEntity_t *le ) {\n\tif ( !le->prev ) {\n\t\tCG_Error( \"CG_FreeLocalEntity: not active\" );\n\t}\n\n\t// remove from the doubly linked active list\n\tle->prev->next = le->next;\n\tle->next->prev = le->prev;\n\n\t// the free list is only singly linked\n\tle->next = cg_freeLocalEntities;\n\tcg_freeLocalEntities = le;\n}\n\n/*\n===================\nCG_AllocLocalEntity\n\nWill allways succeed, even if it requires freeing an old active entity\n===================\n*/\nlocalEntity_t\t*CG_AllocLocalEntity( void ) {\n\tlocalEntity_t\t*le;\n\n\tif ( !cg_freeLocalEntities ) {\n\t\t// no free entities, so free the one at the end of the chain\n\t\t// remove the oldest active entity\n\t\tCG_FreeLocalEntity( cg_activeLocalEntities.prev );\n\t}\n\n\tle = cg_freeLocalEntities;\n\tcg_freeLocalEntities = cg_freeLocalEntities->next;\n\n\tmemset( le, 0, sizeof( *le ) );\n\n\t// link into the active list\n\tle->next = cg_activeLocalEntities.next;\n\tle->prev = &cg_activeLocalEntities;\n\tcg_activeLocalEntities.next->prev = le;\n\tcg_activeLocalEntities.next = le;\n\treturn le;\n}\n\n\n/*\n====================================================================================\n\nFRAGMENT PROCESSING\n\nA fragment localentity interacts with the environment in some way (hitting walls),\nor generates more localentities along a trail.\n\n====================================================================================\n*/\n\n/*\n================\nCG_BloodTrail\n\nLeave expanding blood puffs behind gibs\n================\n*/\nvoid CG_BloodTrail( localEntity_t *le ) {\n\tint\t\tt;\n\tint\t\tt2;\n\tint\t\tstep;\n\tvec3_t\tnewOrigin;\n\tlocalEntity_t\t*blood;\n\n\tstep = 150;\n\tt = step * ( (cg.time - cg.frametime + step ) / step );\n\tt2 = step * ( cg.time / step );\n\n\tfor ( ; t <= t2; t += step ) {\n\t\tBG_EvaluateTrajectory( &le->pos, t, newOrigin );\n\n\t\tblood = CG_SmokePuff( newOrigin, vec3_origin, \n\t\t\t\t\t  20,\t\t// radius\n\t\t\t\t\t  1, 1, 1, 1,\t// color\n\t\t\t\t\t  2000,\t\t// trailTime\n\t\t\t\t\t  t,\t\t// startTime\n\t\t\t\t\t  0,\t\t// fadeInTime\n\t\t\t\t\t  0,\t\t// flags\n\t\t\t\t\t  cgs.media.bloodTrailShader );\n\t\t// use the optimized version\n\t\tblood->leType = LE_FALL_SCALE_FADE;\n\t\t// drop a total of 40 units over its lifetime\n\t\tblood->pos.trDelta[2] = 40;\n\t}\n}\n\n\n/*\n================\nCG_FragmentBounceMark\n================\n*/\nvoid CG_FragmentBounceMark( localEntity_t *le, trace_t *trace ) {\n\tint\t\t\tradius;\n\n\tif ( le->leMarkType == LEMT_BLOOD ) {\n\n\t\tradius = 16 + (rand()&31);\n\t\tCG_ImpactMark( cgs.media.bloodMarkShader, trace->endpos, trace->plane.normal, random()*360,\n\t\t\t1,1,1,1, qtrue, radius, qfalse );\n\t} else if ( le->leMarkType == LEMT_BURN ) {\n\n\t\tradius = 8 + (rand()&15);\n\t\tCG_ImpactMark( cgs.media.burnMarkShader, trace->endpos, trace->plane.normal, random()*360,\n\t\t\t1,1,1,1, qtrue, radius, qfalse );\n\t}\n\n\n\t// don't allow a fragment to make multiple marks, or they\n\t// pile up while settling\n\tle->leMarkType = LEMT_NONE;\n}\n\n/*\n================\nCG_FragmentBounceSound\n================\n*/\nvoid CG_FragmentBounceSound( localEntity_t *le, trace_t *trace ) {\n\tif ( le->leBounceSoundType == LEBS_BLOOD ) {\n\t\t// half the gibs will make splat sounds\n\t\tif ( rand() & 1 ) {\n\t\t\tint r = rand()&3;\n\t\t\tsfxHandle_t\ts;\n\n\t\t\tif ( r == 0 ) {\n\t\t\t\ts = cgs.media.gibBounce1Sound;\n\t\t\t} else if ( r == 1 ) {\n\t\t\t\ts = cgs.media.gibBounce2Sound;\n\t\t\t} else {\n\t\t\t\ts = cgs.media.gibBounce3Sound;\n\t\t\t}\n\t\t\ttrap_S_StartSound( trace->endpos, ENTITYNUM_WORLD, CHAN_AUTO, s );\n\t\t}\n\t} else if ( le->leBounceSoundType == LEBS_BRASS ) {\n\n\t}\n\n\t// don't allow a fragment to make multiple bounce sounds,\n\t// or it gets too noisy as they settle\n\tle->leBounceSoundType = LEBS_NONE;\n}\n\n\n/*\n================\nCG_ReflectVelocity\n================\n*/\nvoid CG_ReflectVelocity( localEntity_t *le, trace_t *trace ) {\n\tvec3_t\tvelocity;\n\tfloat\tdot;\n\tint\t\thitTime;\n\n\t// reflect the velocity on the trace plane\n\thitTime = cg.time - cg.frametime + cg.frametime * trace->fraction;\n\tBG_EvaluateTrajectoryDelta( &le->pos, hitTime, velocity );\n\tdot = DotProduct( velocity, trace->plane.normal );\n\tVectorMA( velocity, -2*dot, trace->plane.normal, le->pos.trDelta );\n\n\tVectorScale( le->pos.trDelta, le->bounceFactor, le->pos.trDelta );\n\n\tVectorCopy( trace->endpos, le->pos.trBase );\n\tle->pos.trTime = cg.time;\n\n\n\t// check for stop, making sure that even on low FPS systems it doesn't bobble\n\tif ( trace->allsolid || \n\t\t( trace->plane.normal[2] > 0 && \n\t\t( le->pos.trDelta[2] < 40 || le->pos.trDelta[2] < -cg.frametime * le->pos.trDelta[2] ) ) ) {\n\t\tle->pos.trType = TR_STATIONARY;\n\t} else {\n\n\t}\n}\n\n/*\n================\nCG_AddFragment\n================\n*/\nvoid CG_AddFragment( localEntity_t *le ) {\n\tvec3_t\tnewOrigin;\n\ttrace_t\ttrace;\n\n\tif ( le->pos.trType == TR_STATIONARY ) {\n\t\t// sink into the ground if near the removal time\n\t\tint\t\tt;\n\t\tfloat\toldZ;\n\t\t\n\t\tt = le->endTime - cg.time;\n\t\tif ( t < SINK_TIME ) {\n\t\t\t// we must use an explicit lighting origin, otherwise the\n\t\t\t// lighting would be lost as soon as the origin went\n\t\t\t// into the ground\n\t\t\tVectorCopy( le->refEntity.origin, le->refEntity.lightingOrigin );\n\t\t\tle->refEntity.renderfx |= RF_LIGHTING_ORIGIN;\n\t\t\toldZ = le->refEntity.origin[2];\n\t\t\tle->refEntity.origin[2] -= 16 * ( 1.0 - (float)t / SINK_TIME );\n\t\t\ttrap_R_AddRefEntityToScene( &le->refEntity );\n\t\t\tle->refEntity.origin[2] = oldZ;\n\t\t} else {\n\t\t\ttrap_R_AddRefEntityToScene( &le->refEntity );\n\t\t}\n\n\t\treturn;\n\t}\n\n\t// calculate new position\n\tBG_EvaluateTrajectory( &le->pos, cg.time, newOrigin );\n\n\t// trace a line from previous position to new position\n\tCG_Trace( &trace, le->refEntity.origin, NULL, NULL, newOrigin, -1, CONTENTS_SOLID );\n\tif ( trace.fraction == 1.0 ) {\n\t\t// still in free fall\n\t\tVectorCopy( newOrigin, le->refEntity.origin );\n\n\t\tif ( le->leFlags & LEF_TUMBLE ) {\n\t\t\tvec3_t angles;\n\n\t\t\tBG_EvaluateTrajectory( &le->angles, cg.time, angles );\n\t\t\tAnglesToAxis( angles, le->refEntity.axis );\n\t\t}\n\n\t\ttrap_R_AddRefEntityToScene( &le->refEntity );\n\n\t\t// add a blood trail\n\t\tif ( le->leBounceSoundType == LEBS_BLOOD ) {\n\t\t\tCG_BloodTrail( le );\n\t\t}\n\n\t\treturn;\n\t}\n\n\t// if it is in a nodrop zone, remove it\n\t// this keeps gibs from waiting at the bottom of pits of death\n\t// and floating levels\n\tif ( trap_CM_PointContents( trace.endpos, 0 ) & CONTENTS_NODROP ) {\n\t\tCG_FreeLocalEntity( le );\n\t\treturn;\n\t}\n\n\t// leave a mark\n\tCG_FragmentBounceMark( le, &trace );\n\n\t// do a bouncy sound\n\tCG_FragmentBounceSound( le, &trace );\n\n\t// reflect the velocity on the trace plane\n\tCG_ReflectVelocity( le, &trace );\n\n\ttrap_R_AddRefEntityToScene( &le->refEntity );\n}\n\n/*\n=====================================================================\n\nTRIVIAL LOCAL ENTITIES\n\nThese only do simple scaling or modulation before passing to the renderer\n=====================================================================\n*/\n\n/*\n====================\nCG_AddFadeRGB\n====================\n*/\nvoid CG_AddFadeRGB( localEntity_t *le ) {\n\trefEntity_t *re;\n\tfloat c;\n\n\tre = &le->refEntity;\n\n\tc = ( le->endTime - cg.time ) * le->lifeRate;\n\tc *= 0xff;\n\n\tre->shaderRGBA[0] = le->color[0] * c;\n\tre->shaderRGBA[1] = le->color[1] * c;\n\tre->shaderRGBA[2] = le->color[2] * c;\n\tre->shaderRGBA[3] = le->color[3] * c;\n\n\ttrap_R_AddRefEntityToScene( re );\n}\n\n/*\n==================\nCG_AddMoveScaleFade\n==================\n*/\nstatic void CG_AddMoveScaleFade( localEntity_t *le ) {\n\trefEntity_t\t*re;\n\tfloat\t\tc;\n\tvec3_t\t\tdelta;\n\tfloat\t\tlen;\n\n\tre = &le->refEntity;\n\n\tif ( le->fadeInTime > le->startTime && cg.time < le->fadeInTime ) {\n\t\t// fade / grow time\n\t\tc = 1.0 - (float) ( le->fadeInTime - cg.time ) / ( le->fadeInTime - le->startTime );\n\t}\n\telse {\n\t\t// fade / grow time\n\t\tc = ( le->endTime - cg.time ) * le->lifeRate;\n\t}\n\n\tre->shaderRGBA[3] = 0xff * c * le->color[3];\n\n\tif ( !( le->leFlags & LEF_PUFF_DONT_SCALE ) ) {\n\t\tre->radius = le->radius * ( 1.0 - c ) + 8;\n\t}\n\n\tBG_EvaluateTrajectory( &le->pos, cg.time, re->origin );\n\n\t// if the view would be \"inside\" the sprite, kill the sprite\n\t// so it doesn't add too much overdraw\n\tVectorSubtract( re->origin, cg.refdef.vieworg, delta );\n\tlen = VectorLength( delta );\n\tif ( len < le->radius ) {\n\t\tCG_FreeLocalEntity( le );\n\t\treturn;\n\t}\n\n\ttrap_R_AddRefEntityToScene( re );\n}\n\n\n/*\n===================\nCG_AddScaleFade\n\nFor rocket smokes that hang in place, fade out, and are\nremoved if the view passes through them.\nThere are often many of these, so it needs to be simple.\n===================\n*/\nstatic void CG_AddScaleFade( localEntity_t *le ) {\n\trefEntity_t\t*re;\n\tfloat\t\tc;\n\tvec3_t\t\tdelta;\n\tfloat\t\tlen;\n\n\tre = &le->refEntity;\n\n\t// fade / grow time\n\tc = ( le->endTime - cg.time ) * le->lifeRate;\n\n\tre->shaderRGBA[3] = 0xff * c * le->color[3];\n\tre->radius = le->radius * ( 1.0 - c ) + 8;\n\n\t// if the view would be \"inside\" the sprite, kill the sprite\n\t// so it doesn't add too much overdraw\n\tVectorSubtract( re->origin, cg.refdef.vieworg, delta );\n\tlen = VectorLength( delta );\n\tif ( len < le->radius ) {\n\t\tCG_FreeLocalEntity( le );\n\t\treturn;\n\t}\n\n\ttrap_R_AddRefEntityToScene( re );\n}\n\n\n/*\n=================\nCG_AddFallScaleFade\n\nThis is just an optimized CG_AddMoveScaleFade\nFor blood mists that drift down, fade out, and are\nremoved if the view passes through them.\nThere are often 100+ of these, so it needs to be simple.\n=================\n*/\nstatic void CG_AddFallScaleFade( localEntity_t *le ) {\n\trefEntity_t\t*re;\n\tfloat\t\tc;\n\tvec3_t\t\tdelta;\n\tfloat\t\tlen;\n\n\tre = &le->refEntity;\n\n\t// fade time\n\tc = ( le->endTime - cg.time ) * le->lifeRate;\n\n\tre->shaderRGBA[3] = 0xff * c * le->color[3];\n\n\tre->origin[2] = le->pos.trBase[2] - ( 1.0 - c ) * le->pos.trDelta[2];\n\n\tre->radius = le->radius * ( 1.0 - c ) + 16;\n\n\t// if the view would be \"inside\" the sprite, kill the sprite\n\t// so it doesn't add too much overdraw\n\tVectorSubtract( re->origin, cg.refdef.vieworg, delta );\n\tlen = VectorLength( delta );\n\tif ( len < le->radius ) {\n\t\tCG_FreeLocalEntity( le );\n\t\treturn;\n\t}\n\n\ttrap_R_AddRefEntityToScene( re );\n}\n\n\n\n/*\n================\nCG_AddExplosion\n================\n*/\nstatic void CG_AddExplosion( localEntity_t *ex ) {\n\trefEntity_t\t*ent;\n\n\tent = &ex->refEntity;\n\n\t// add the entity\n\ttrap_R_AddRefEntityToScene(ent);\n\n\t// add the dlight\n\tif ( ex->light ) {\n\t\tfloat\t\tlight;\n\n\t\tlight = (float)( cg.time - ex->startTime ) / ( ex->endTime - ex->startTime );\n\t\tif ( light < 0.5 ) {\n\t\t\tlight = 1.0;\n\t\t} else {\n\t\t\tlight = 1.0 - ( light - 0.5 ) * 2;\n\t\t}\n\t\tlight = ex->light * light;\n\t\ttrap_R_AddLightToScene(ent->origin, light, ex->lightColor[0], ex->lightColor[1], ex->lightColor[2] );\n\t}\n}\n\n/*\n================\nCG_AddSpriteExplosion\n================\n*/\nstatic void CG_AddSpriteExplosion( localEntity_t *le ) {\n\trefEntity_t\tre;\n\tfloat c;\n\n\tre = le->refEntity;\n\n\tc = ( le->endTime - cg.time ) / ( float ) ( le->endTime - le->startTime );\n\tif ( c > 1 ) {\n\t\tc = 1.0;\t// can happen during connection problems\n\t}\n\n\tre.shaderRGBA[0] = 0xff;\n\tre.shaderRGBA[1] = 0xff;\n\tre.shaderRGBA[2] = 0xff;\n\tre.shaderRGBA[3] = 0xff * c * 0.33;\n\n\tre.reType = RT_SPRITE;\n\tre.radius = 42 * ( 1.0 - c ) + 30;\n\n\ttrap_R_AddRefEntityToScene( &re );\n\n\t// add the dlight\n\tif ( le->light ) {\n\t\tfloat\t\tlight;\n\n\t\tlight = (float)( cg.time - le->startTime ) / ( le->endTime - le->startTime );\n\t\tif ( light < 0.5 ) {\n\t\t\tlight = 1.0;\n\t\t} else {\n\t\t\tlight = 1.0 - ( light - 0.5 ) * 2;\n\t\t}\n\t\tlight = le->light * light;\n\t\ttrap_R_AddLightToScene(re.origin, light, le->lightColor[0], le->lightColor[1], le->lightColor[2] );\n\t}\n}\n\n\n#ifdef MISSIONPACK\n/*\n====================\nCG_AddKamikaze\n====================\n*/\nvoid CG_AddKamikaze( localEntity_t *le ) {\n\trefEntity_t\t*re;\n\trefEntity_t shockwave;\n\tfloat\t\tc;\n\tvec3_t\t\ttest, axis[3];\n\tint\t\t\tt;\n\n\tre = &le->refEntity;\n\n\tt = cg.time - le->startTime;\n\tVectorClear( test );\n\tAnglesToAxis( test, axis );\n\n\tif (t > KAMI_SHOCKWAVE_STARTTIME && t < KAMI_SHOCKWAVE_ENDTIME) {\n\n\t\tif (!(le->leFlags & LEF_SOUND1)) {\n//\t\t\ttrap_S_StartSound (re->origin, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.kamikazeExplodeSound );\n\t\t\ttrap_S_StartLocalSound(cgs.media.kamikazeExplodeSound, CHAN_AUTO);\n\t\t\tle->leFlags |= LEF_SOUND1;\n\t\t}\n\t\t// 1st kamikaze shockwave\n\t\tmemset(&shockwave, 0, sizeof(shockwave));\n\t\tshockwave.hModel = cgs.media.kamikazeShockWave;\n\t\tshockwave.reType = RT_MODEL;\n\t\tshockwave.shaderTime = re->shaderTime;\n\t\tVectorCopy(re->origin, shockwave.origin);\n\n\t\tc = (float)(t - KAMI_SHOCKWAVE_STARTTIME) / (float)(KAMI_SHOCKWAVE_ENDTIME - KAMI_SHOCKWAVE_STARTTIME);\n\t\tVectorScale( axis[0], c * KAMI_SHOCKWAVE_MAXRADIUS / KAMI_SHOCKWAVEMODEL_RADIUS, shockwave.axis[0] );\n\t\tVectorScale( axis[1], c * KAMI_SHOCKWAVE_MAXRADIUS / KAMI_SHOCKWAVEMODEL_RADIUS, shockwave.axis[1] );\n\t\tVectorScale( axis[2], c * KAMI_SHOCKWAVE_MAXRADIUS / KAMI_SHOCKWAVEMODEL_RADIUS, shockwave.axis[2] );\n\t\tshockwave.nonNormalizedAxes = qtrue;\n\n\t\tif (t > KAMI_SHOCKWAVEFADE_STARTTIME) {\n\t\t\tc = (float)(t - KAMI_SHOCKWAVEFADE_STARTTIME) / (float)(KAMI_SHOCKWAVE_ENDTIME - KAMI_SHOCKWAVEFADE_STARTTIME);\n\t\t}\n\t\telse {\n\t\t\tc = 0;\n\t\t}\n\t\tc *= 0xff;\n\t\tshockwave.shaderRGBA[0] = 0xff - c;\n\t\tshockwave.shaderRGBA[1] = 0xff - c;\n\t\tshockwave.shaderRGBA[2] = 0xff - c;\n\t\tshockwave.shaderRGBA[3] = 0xff - c;\n\n\t\ttrap_R_AddRefEntityToScene( &shockwave );\n\t}\n\n\tif (t > KAMI_EXPLODE_STARTTIME && t < KAMI_IMPLODE_ENDTIME) {\n\t\t// explosion and implosion\n\t\tc = ( le->endTime - cg.time ) * le->lifeRate;\n\t\tc *= 0xff;\n\t\tre->shaderRGBA[0] = le->color[0] * c;\n\t\tre->shaderRGBA[1] = le->color[1] * c;\n\t\tre->shaderRGBA[2] = le->color[2] * c;\n\t\tre->shaderRGBA[3] = le->color[3] * c;\n\n\t\tif( t < KAMI_IMPLODE_STARTTIME ) {\n\t\t\tc = (float)(t - KAMI_EXPLODE_STARTTIME) / (float)(KAMI_IMPLODE_STARTTIME - KAMI_EXPLODE_STARTTIME);\n\t\t}\n\t\telse {\n\t\t\tif (!(le->leFlags & LEF_SOUND2)) {\n//\t\t\t\ttrap_S_StartSound (re->origin, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.kamikazeImplodeSound );\n\t\t\t\ttrap_S_StartLocalSound(cgs.media.kamikazeImplodeSound, CHAN_AUTO);\n\t\t\t\tle->leFlags |= LEF_SOUND2;\n\t\t\t}\n\t\t\tc = (float)(KAMI_IMPLODE_ENDTIME - t) / (float) (KAMI_IMPLODE_ENDTIME - KAMI_IMPLODE_STARTTIME);\n\t\t}\n\t\tVectorScale( axis[0], c * KAMI_BOOMSPHERE_MAXRADIUS / KAMI_BOOMSPHEREMODEL_RADIUS, re->axis[0] );\n\t\tVectorScale( axis[1], c * KAMI_BOOMSPHERE_MAXRADIUS / KAMI_BOOMSPHEREMODEL_RADIUS, re->axis[1] );\n\t\tVectorScale( axis[2], c * KAMI_BOOMSPHERE_MAXRADIUS / KAMI_BOOMSPHEREMODEL_RADIUS, re->axis[2] );\n\t\tre->nonNormalizedAxes = qtrue;\n\n\t\ttrap_R_AddRefEntityToScene( re );\n\t\t// add the dlight\n\t\ttrap_R_AddLightToScene( re->origin, c * 1000.0, 1.0, 1.0, c );\n\t}\n\n\tif (t > KAMI_SHOCKWAVE2_STARTTIME && t < KAMI_SHOCKWAVE2_ENDTIME) {\n\t\t// 2nd kamikaze shockwave\n\t\tif (le->angles.trBase[0] == 0 &&\n\t\t\tle->angles.trBase[1] == 0 &&\n\t\t\tle->angles.trBase[2] == 0) {\n\t\t\tle->angles.trBase[0] = random() * 360;\n\t\t\tle->angles.trBase[1] = random() * 360;\n\t\t\tle->angles.trBase[2] = random() * 360;\n\t\t}\n\t\telse {\n\t\t\tc = 0;\n\t\t}\n\t\tmemset(&shockwave, 0, sizeof(shockwave));\n\t\tshockwave.hModel = cgs.media.kamikazeShockWave;\n\t\tshockwave.reType = RT_MODEL;\n\t\tshockwave.shaderTime = re->shaderTime;\n\t\tVectorCopy(re->origin, shockwave.origin);\n\n\t\ttest[0] = le->angles.trBase[0];\n\t\ttest[1] = le->angles.trBase[1];\n\t\ttest[2] = le->angles.trBase[2];\n\t\tAnglesToAxis( test, axis );\n\n\t\tc = (float)(t - KAMI_SHOCKWAVE2_STARTTIME) / (float)(KAMI_SHOCKWAVE2_ENDTIME - KAMI_SHOCKWAVE2_STARTTIME);\n\t\tVectorScale( axis[0], c * KAMI_SHOCKWAVE2_MAXRADIUS / KAMI_SHOCKWAVEMODEL_RADIUS, shockwave.axis[0] );\n\t\tVectorScale( axis[1], c * KAMI_SHOCKWAVE2_MAXRADIUS / KAMI_SHOCKWAVEMODEL_RADIUS, shockwave.axis[1] );\n\t\tVectorScale( axis[2], c * KAMI_SHOCKWAVE2_MAXRADIUS / KAMI_SHOCKWAVEMODEL_RADIUS, shockwave.axis[2] );\n\t\tshockwave.nonNormalizedAxes = qtrue;\n\n\t\tif (t > KAMI_SHOCKWAVE2FADE_STARTTIME) {\n\t\t\tc = (float)(t - KAMI_SHOCKWAVE2FADE_STARTTIME) / (float)(KAMI_SHOCKWAVE2_ENDTIME - KAMI_SHOCKWAVE2FADE_STARTTIME);\n\t\t}\n\t\telse {\n\t\t\tc = 0;\n\t\t}\n\t\tc *= 0xff;\n\t\tshockwave.shaderRGBA[0] = 0xff - c;\n\t\tshockwave.shaderRGBA[1] = 0xff - c;\n\t\tshockwave.shaderRGBA[2] = 0xff - c;\n\t\tshockwave.shaderRGBA[3] = 0xff - c;\n\n\t\ttrap_R_AddRefEntityToScene( &shockwave );\n\t}\n}\n\n/*\n===================\nCG_AddInvulnerabilityImpact\n===================\n*/\nvoid CG_AddInvulnerabilityImpact( localEntity_t *le ) {\n\ttrap_R_AddRefEntityToScene( &le->refEntity );\n}\n\n/*\n===================\nCG_AddInvulnerabilityJuiced\n===================\n*/\nvoid CG_AddInvulnerabilityJuiced( localEntity_t *le ) {\n\tint t;\n\n\tt = cg.time - le->startTime;\n\tif ( t > 3000 ) {\n\t\tle->refEntity.axis[0][0] = (float) 1.0 + 0.3 * (t - 3000) / 2000;\n\t\tle->refEntity.axis[1][1] = (float) 1.0 + 0.3 * (t - 3000) / 2000;\n\t\tle->refEntity.axis[2][2] = (float) 0.7 + 0.3 * (2000 - (t - 3000)) / 2000;\n\t}\n\tif ( t > 5000 ) {\n\t\tle->endTime = 0;\n\t\tCG_GibPlayer( le->refEntity.origin );\n\t}\n\telse {\n\t\ttrap_R_AddRefEntityToScene( &le->refEntity );\n\t}\n}\n\n/*\n===================\nCG_AddRefEntity\n===================\n*/\nvoid CG_AddRefEntity( localEntity_t *le ) {\n\tif (le->endTime < cg.time) {\n\t\tCG_FreeLocalEntity( le );\n\t\treturn;\n\t}\n\ttrap_R_AddRefEntityToScene( &le->refEntity );\n}\n\n#endif\n/*\n===================\nCG_AddScorePlum\n===================\n*/\n#define NUMBER_SIZE\t\t8\n\nvoid CG_AddScorePlum( localEntity_t *le ) {\n\trefEntity_t\t*re;\n\tvec3_t\t\torigin, delta, dir, vec, up = {0, 0, 1};\n\tfloat\t\tc, len;\n\tint\t\t\ti, score, digits[10], numdigits, negative;\n\n\tre = &le->refEntity;\n\n\tc = ( le->endTime - cg.time ) * le->lifeRate;\n\n\tscore = le->radius;\n\tif (score < 0) {\n\t\tre->shaderRGBA[0] = 0xff;\n\t\tre->shaderRGBA[1] = 0x11;\n\t\tre->shaderRGBA[2] = 0x11;\n\t}\n\telse {\n\t\tre->shaderRGBA[0] = 0xff;\n\t\tre->shaderRGBA[1] = 0xff;\n\t\tre->shaderRGBA[2] = 0xff;\n\t\tif (score >= 50) {\n\t\t\tre->shaderRGBA[1] = 0;\n\t\t} else if (score >= 20) {\n\t\t\tre->shaderRGBA[0] = re->shaderRGBA[1] = 0;\n\t\t} else if (score >= 10) {\n\t\t\tre->shaderRGBA[2] = 0;\n\t\t} else if (score >= 2) {\n\t\t\tre->shaderRGBA[0] = re->shaderRGBA[2] = 0;\n\t\t}\n\n\t}\n\tif (c < 0.25)\n\t\tre->shaderRGBA[3] = 0xff * 4 * c;\n\telse\n\t\tre->shaderRGBA[3] = 0xff;\n\n\tre->radius = NUMBER_SIZE / 2;\n\n\tVectorCopy(le->pos.trBase, origin);\n\torigin[2] += 110 - c * 100;\n\n\tVectorSubtract(cg.refdef.vieworg, origin, dir);\n\tCrossProduct(dir, up, vec);\n\tVectorNormalize(vec);\n\n\tVectorMA(origin, -10 + 20 * sin(c * 2 * M_PI), vec, origin);\n\n\t// if the view would be \"inside\" the sprite, kill the sprite\n\t// so it doesn't add too much overdraw\n\tVectorSubtract( origin, cg.refdef.vieworg, delta );\n\tlen = VectorLength( delta );\n\tif ( len < 20 ) {\n\t\tCG_FreeLocalEntity( le );\n\t\treturn;\n\t}\n\n\tnegative = qfalse;\n\tif (score < 0) {\n\t\tnegative = qtrue;\n\t\tscore = -score;\n\t}\n\n\tfor (numdigits = 0; !(numdigits && !score); numdigits++) {\n\t\tdigits[numdigits] = score % 10;\n\t\tscore = score / 10;\n\t}\n\n\tif (negative) {\n\t\tdigits[numdigits] = 10;\n\t\tnumdigits++;\n\t}\n\n\tfor (i = 0; i < numdigits; i++) {\n\t\tVectorMA(origin, (float) (((float) numdigits / 2) - i) * NUMBER_SIZE, vec, re->origin);\n\t\tre->customShader = cgs.media.numberShaders[digits[numdigits-1-i]];\n\t\ttrap_R_AddRefEntityToScene( re );\n\t}\n}\n\n\n\n\n//==============================================================================\n\n/*\n===================\nCG_AddLocalEntities\n\n===================\n*/\nvoid CG_AddLocalEntities( void ) {\n\tlocalEntity_t\t*le, *next;\n\n\t// walk the list backwards, so any new local entities generated\n\t// (trails, marks, etc) will be present this frame\n\tle = cg_activeLocalEntities.prev;\n\tfor ( ; le != &cg_activeLocalEntities ; le = next ) {\n\t\t// grab next now, so if the local entity is freed we\n\t\t// still have it\n\t\tnext = le->prev;\n\n\t\tif ( cg.time >= le->endTime ) {\n\t\t\tCG_FreeLocalEntity( le );\n\t\t\tcontinue;\n\t\t}\n\t\tswitch ( le->leType ) {\n\t\tdefault:\n\t\t\tCG_Error( \"Bad leType: %i\", le->leType );\n\t\t\tbreak;\n\n\t\tcase LE_MARK:\n\t\t\tbreak;\n\n\t\tcase LE_SPRITE_EXPLOSION:\n\t\t\tCG_AddSpriteExplosion( le );\n\t\t\tbreak;\n\n\t\tcase LE_EXPLOSION:\n\t\t\tCG_AddExplosion( le );\n\t\t\tbreak;\n\n\t\tcase LE_FRAGMENT:\t\t\t// gibs and brass\n\t\t\tCG_AddFragment( le );\n\t\t\tbreak;\n\n\t\tcase LE_MOVE_SCALE_FADE:\t\t// water bubbles\n\t\t\tCG_AddMoveScaleFade( le );\n\t\t\tbreak;\n\n\t\tcase LE_FADE_RGB:\t\t\t\t// teleporters, railtrails\n\t\t\tCG_AddFadeRGB( le );\n\t\t\tbreak;\n\n\t\tcase LE_FALL_SCALE_FADE: // gib blood trails\n\t\t\tCG_AddFallScaleFade( le );\n\t\t\tbreak;\n\n\t\tcase LE_SCALE_FADE:\t\t// rocket trails\n\t\t\tCG_AddScaleFade( le );\n\t\t\tbreak;\n\n\t\tcase LE_SCOREPLUM:\n\t\t\tCG_AddScorePlum( le );\n\t\t\tbreak;\n\n#ifdef MISSIONPACK\n\t\tcase LE_KAMIKAZE:\n\t\t\tCG_AddKamikaze( le );\n\t\t\tbreak;\n\t\tcase LE_INVULIMPACT:\n\t\t\tCG_AddInvulnerabilityImpact( le );\n\t\t\tbreak;\n\t\tcase LE_INVULJUICED:\n\t\t\tCG_AddInvulnerabilityJuiced( le );\n\t\t\tbreak;\n\t\tcase LE_SHOWREFENTITY:\n\t\t\tCG_AddRefEntity( le );\n\t\t\tbreak;\n#endif\n\t\t}\n\t}\n}\n\n\n\n\n"
  },
  {
    "path": "code/cgame/cg_main.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// cg_main.c -- initialization and primary entry point for cgame\n#include \"cg_local.h\"\n\n#ifdef MISSIONPACK\n#include \"../ui/ui_shared.h\"\n// display context for new ui stuff\ndisplayContextDef_t cgDC;\n#endif\n\nint forceModelModificationCount = -1;\n\nvoid CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum );\nvoid CG_Shutdown( void );\n\n\n/*\n================\nvmMain\n\nThis is the only way control passes into the module.\nThis must be the very first function compiled into the .q3vm file\n================\n*/\nint vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11  ) {\n\n\tswitch ( command ) {\n\tcase CG_INIT:\n\t\tCG_Init( arg0, arg1, arg2 );\n\t\treturn 0;\n\tcase CG_SHUTDOWN:\n\t\tCG_Shutdown();\n\t\treturn 0;\n\tcase CG_CONSOLE_COMMAND:\n\t\treturn CG_ConsoleCommand();\n\tcase CG_DRAW_ACTIVE_FRAME:\n\t\tCG_DrawActiveFrame( arg0, arg1, arg2 );\n\t\treturn 0;\n\tcase CG_CROSSHAIR_PLAYER:\n\t\treturn CG_CrosshairPlayer();\n\tcase CG_LAST_ATTACKER:\n\t\treturn CG_LastAttacker();\n\tcase CG_KEY_EVENT:\n\t\tCG_KeyEvent(arg0, arg1);\n\t\treturn 0;\n\tcase CG_MOUSE_EVENT:\n#ifdef MISSIONPACK\n\t\tcgDC.cursorx = cgs.cursorX;\n\t\tcgDC.cursory = cgs.cursorY;\n#endif\n\t\tCG_MouseEvent(arg0, arg1);\n\t\treturn 0;\n\tcase CG_EVENT_HANDLING:\n\t\tCG_EventHandling(arg0);\n\t\treturn 0;\n\tdefault:\n\t\tCG_Error( \"vmMain: unknown command %i\", command );\n\t\tbreak;\n\t}\n\treturn -1;\n}\n\n\ncg_t\t\t\t\tcg;\ncgs_t\t\t\t\tcgs;\ncentity_t\t\t\tcg_entities[MAX_GENTITIES];\nweaponInfo_t\t\tcg_weapons[MAX_WEAPONS];\nitemInfo_t\t\t\tcg_items[MAX_ITEMS];\n\n\nvmCvar_t\tcg_railTrailTime;\nvmCvar_t\tcg_centertime;\nvmCvar_t\tcg_runpitch;\nvmCvar_t\tcg_runroll;\nvmCvar_t\tcg_bobup;\nvmCvar_t\tcg_bobpitch;\nvmCvar_t\tcg_bobroll;\nvmCvar_t\tcg_swingSpeed;\nvmCvar_t\tcg_shadows;\nvmCvar_t\tcg_gibs;\nvmCvar_t\tcg_drawTimer;\nvmCvar_t\tcg_drawFPS;\nvmCvar_t\tcg_drawSnapshot;\nvmCvar_t\tcg_draw3dIcons;\nvmCvar_t\tcg_drawIcons;\nvmCvar_t\tcg_drawAmmoWarning;\nvmCvar_t\tcg_drawCrosshair;\nvmCvar_t\tcg_drawCrosshairNames;\nvmCvar_t\tcg_drawRewards;\nvmCvar_t\tcg_crosshairSize;\nvmCvar_t\tcg_crosshairX;\nvmCvar_t\tcg_crosshairY;\nvmCvar_t\tcg_crosshairHealth;\nvmCvar_t\tcg_draw2D;\nvmCvar_t\tcg_drawStatus;\nvmCvar_t\tcg_animSpeed;\nvmCvar_t\tcg_debugAnim;\nvmCvar_t\tcg_debugPosition;\nvmCvar_t\tcg_debugEvents;\nvmCvar_t\tcg_errorDecay;\nvmCvar_t\tcg_nopredict;\nvmCvar_t\tcg_noPlayerAnims;\nvmCvar_t\tcg_showmiss;\nvmCvar_t\tcg_footsteps;\nvmCvar_t\tcg_addMarks;\nvmCvar_t\tcg_brassTime;\nvmCvar_t\tcg_viewsize;\nvmCvar_t\tcg_drawGun;\nvmCvar_t\tcg_gun_frame;\nvmCvar_t\tcg_gun_x;\nvmCvar_t\tcg_gun_y;\nvmCvar_t\tcg_gun_z;\nvmCvar_t\tcg_tracerChance;\nvmCvar_t\tcg_tracerWidth;\nvmCvar_t\tcg_tracerLength;\nvmCvar_t\tcg_autoswitch;\nvmCvar_t\tcg_ignore;\nvmCvar_t\tcg_simpleItems;\nvmCvar_t\tcg_fov;\nvmCvar_t\tcg_zoomFov;\nvmCvar_t\tcg_thirdPerson;\nvmCvar_t\tcg_thirdPersonRange;\nvmCvar_t\tcg_thirdPersonAngle;\nvmCvar_t\tcg_stereoSeparation;\nvmCvar_t\tcg_lagometer;\nvmCvar_t\tcg_drawAttacker;\nvmCvar_t\tcg_synchronousClients;\nvmCvar_t \tcg_teamChatTime;\nvmCvar_t \tcg_teamChatHeight;\nvmCvar_t \tcg_stats;\nvmCvar_t \tcg_buildScript;\nvmCvar_t \tcg_forceModel;\nvmCvar_t\tcg_paused;\nvmCvar_t\tcg_blood;\nvmCvar_t\tcg_predictItems;\nvmCvar_t\tcg_deferPlayers;\nvmCvar_t\tcg_drawTeamOverlay;\nvmCvar_t\tcg_teamOverlayUserinfo;\nvmCvar_t\tcg_drawFriend;\nvmCvar_t\tcg_teamChatsOnly;\nvmCvar_t\tcg_noVoiceChats;\nvmCvar_t\tcg_noVoiceText;\nvmCvar_t\tcg_hudFiles;\nvmCvar_t \tcg_scorePlum;\nvmCvar_t \tcg_smoothClients;\nvmCvar_t\tpmove_fixed;\n//vmCvar_t\tcg_pmove_fixed;\nvmCvar_t\tpmove_msec;\nvmCvar_t\tcg_pmove_msec;\nvmCvar_t\tcg_cameraMode;\nvmCvar_t\tcg_cameraOrbit;\nvmCvar_t\tcg_cameraOrbitDelay;\nvmCvar_t\tcg_timescaleFadeEnd;\nvmCvar_t\tcg_timescaleFadeSpeed;\nvmCvar_t\tcg_timescale;\nvmCvar_t\tcg_smallFont;\nvmCvar_t\tcg_bigFont;\nvmCvar_t\tcg_noTaunt;\nvmCvar_t\tcg_noProjectileTrail;\nvmCvar_t\tcg_oldRail;\nvmCvar_t\tcg_oldRocket;\nvmCvar_t\tcg_oldPlasma;\nvmCvar_t\tcg_trueLightning;\n\n#ifdef MISSIONPACK\nvmCvar_t \tcg_redTeamName;\nvmCvar_t \tcg_blueTeamName;\nvmCvar_t\tcg_currentSelectedPlayer;\nvmCvar_t\tcg_currentSelectedPlayerName;\nvmCvar_t\tcg_singlePlayer;\nvmCvar_t\tcg_enableDust;\nvmCvar_t\tcg_enableBreath;\nvmCvar_t\tcg_singlePlayerActive;\nvmCvar_t\tcg_recordSPDemo;\nvmCvar_t\tcg_recordSPDemoName;\nvmCvar_t\tcg_obeliskRespawnDelay;\n#endif\n\ntypedef struct {\n\tvmCvar_t\t*vmCvar;\n\tchar\t\t*cvarName;\n\tchar\t\t*defaultString;\n\tint\t\t\tcvarFlags;\n} cvarTable_t;\n\nstatic cvarTable_t cvarTable[] = { // bk001129\n\t{ &cg_ignore, \"cg_ignore\", \"0\", 0 },\t// used for debugging\n\t{ &cg_autoswitch, \"cg_autoswitch\", \"1\", CVAR_ARCHIVE },\n\t{ &cg_drawGun, \"cg_drawGun\", \"1\", CVAR_ARCHIVE },\n\t{ &cg_zoomFov, \"cg_zoomfov\", \"22.5\", CVAR_ARCHIVE },\n\t{ &cg_fov, \"cg_fov\", \"90\", CVAR_ARCHIVE },\n\t{ &cg_viewsize, \"cg_viewsize\", \"100\", CVAR_ARCHIVE },\n\t{ &cg_stereoSeparation, \"cg_stereoSeparation\", \"0.4\", CVAR_ARCHIVE  },\n\t{ &cg_shadows, \"cg_shadows\", \"1\", CVAR_ARCHIVE  },\n\t{ &cg_gibs, \"cg_gibs\", \"1\", CVAR_ARCHIVE  },\n\t{ &cg_draw2D, \"cg_draw2D\", \"1\", CVAR_ARCHIVE  },\n\t{ &cg_drawStatus, \"cg_drawStatus\", \"1\", CVAR_ARCHIVE  },\n\t{ &cg_drawTimer, \"cg_drawTimer\", \"0\", CVAR_ARCHIVE  },\n\t{ &cg_drawFPS, \"cg_drawFPS\", \"0\", CVAR_ARCHIVE  },\n\t{ &cg_drawSnapshot, \"cg_drawSnapshot\", \"0\", CVAR_ARCHIVE  },\n\t{ &cg_draw3dIcons, \"cg_draw3dIcons\", \"1\", CVAR_ARCHIVE  },\n\t{ &cg_drawIcons, \"cg_drawIcons\", \"1\", CVAR_ARCHIVE  },\n\t{ &cg_drawAmmoWarning, \"cg_drawAmmoWarning\", \"1\", CVAR_ARCHIVE  },\n\t{ &cg_drawAttacker, \"cg_drawAttacker\", \"1\", CVAR_ARCHIVE  },\n\t{ &cg_drawCrosshair, \"cg_drawCrosshair\", \"4\", CVAR_ARCHIVE },\n\t{ &cg_drawCrosshairNames, \"cg_drawCrosshairNames\", \"1\", CVAR_ARCHIVE },\n\t{ &cg_drawRewards, \"cg_drawRewards\", \"1\", CVAR_ARCHIVE },\n\t{ &cg_crosshairSize, \"cg_crosshairSize\", \"24\", CVAR_ARCHIVE },\n\t{ &cg_crosshairHealth, \"cg_crosshairHealth\", \"1\", CVAR_ARCHIVE },\n\t{ &cg_crosshairX, \"cg_crosshairX\", \"0\", CVAR_ARCHIVE },\n\t{ &cg_crosshairY, \"cg_crosshairY\", \"0\", CVAR_ARCHIVE },\n\t{ &cg_brassTime, \"cg_brassTime\", \"2500\", CVAR_ARCHIVE },\n\t{ &cg_simpleItems, \"cg_simpleItems\", \"0\", CVAR_ARCHIVE },\n\t{ &cg_addMarks, \"cg_marks\", \"1\", CVAR_ARCHIVE },\n\t{ &cg_lagometer, \"cg_lagometer\", \"1\", CVAR_ARCHIVE },\n\t{ &cg_railTrailTime, \"cg_railTrailTime\", \"400\", CVAR_ARCHIVE  },\n\t{ &cg_gun_x, \"cg_gunX\", \"0\", CVAR_CHEAT },\n\t{ &cg_gun_y, \"cg_gunY\", \"0\", CVAR_CHEAT },\n\t{ &cg_gun_z, \"cg_gunZ\", \"0\", CVAR_CHEAT },\n\t{ &cg_centertime, \"cg_centertime\", \"3\", CVAR_CHEAT },\n\t{ &cg_runpitch, \"cg_runpitch\", \"0.002\", CVAR_ARCHIVE},\n\t{ &cg_runroll, \"cg_runroll\", \"0.005\", CVAR_ARCHIVE },\n\t{ &cg_bobup , \"cg_bobup\", \"0.005\", CVAR_CHEAT },\n\t{ &cg_bobpitch, \"cg_bobpitch\", \"0.002\", CVAR_ARCHIVE },\n\t{ &cg_bobroll, \"cg_bobroll\", \"0.002\", CVAR_ARCHIVE },\n\t{ &cg_swingSpeed, \"cg_swingSpeed\", \"0.3\", CVAR_CHEAT },\n\t{ &cg_animSpeed, \"cg_animspeed\", \"1\", CVAR_CHEAT },\n\t{ &cg_debugAnim, \"cg_debuganim\", \"0\", CVAR_CHEAT },\n\t{ &cg_debugPosition, \"cg_debugposition\", \"0\", CVAR_CHEAT },\n\t{ &cg_debugEvents, \"cg_debugevents\", \"0\", CVAR_CHEAT },\n\t{ &cg_errorDecay, \"cg_errordecay\", \"100\", 0 },\n\t{ &cg_nopredict, \"cg_nopredict\", \"0\", 0 },\n\t{ &cg_noPlayerAnims, \"cg_noplayeranims\", \"0\", CVAR_CHEAT },\n\t{ &cg_showmiss, \"cg_showmiss\", \"0\", 0 },\n\t{ &cg_footsteps, \"cg_footsteps\", \"1\", CVAR_CHEAT },\n\t{ &cg_tracerChance, \"cg_tracerchance\", \"0.4\", CVAR_CHEAT },\n\t{ &cg_tracerWidth, \"cg_tracerwidth\", \"1\", CVAR_CHEAT },\n\t{ &cg_tracerLength, \"cg_tracerlength\", \"100\", CVAR_CHEAT },\n\t{ &cg_thirdPersonRange, \"cg_thirdPersonRange\", \"40\", CVAR_CHEAT },\n\t{ &cg_thirdPersonAngle, \"cg_thirdPersonAngle\", \"0\", CVAR_CHEAT },\n\t{ &cg_thirdPerson, \"cg_thirdPerson\", \"0\", 0 },\n\t{ &cg_teamChatTime, \"cg_teamChatTime\", \"3000\", CVAR_ARCHIVE  },\n\t{ &cg_teamChatHeight, \"cg_teamChatHeight\", \"0\", CVAR_ARCHIVE  },\n\t{ &cg_forceModel, \"cg_forceModel\", \"0\", CVAR_ARCHIVE  },\n\t{ &cg_predictItems, \"cg_predictItems\", \"1\", CVAR_ARCHIVE },\n#ifdef MISSIONPACK\n\t{ &cg_deferPlayers, \"cg_deferPlayers\", \"0\", CVAR_ARCHIVE },\n#else\n\t{ &cg_deferPlayers, \"cg_deferPlayers\", \"1\", CVAR_ARCHIVE },\n#endif\n\t{ &cg_drawTeamOverlay, \"cg_drawTeamOverlay\", \"0\", CVAR_ARCHIVE },\n\t{ &cg_teamOverlayUserinfo, \"teamoverlay\", \"0\", CVAR_ROM | CVAR_USERINFO },\n\t{ &cg_stats, \"cg_stats\", \"0\", 0 },\n\t{ &cg_drawFriend, \"cg_drawFriend\", \"1\", CVAR_ARCHIVE },\n\t{ &cg_teamChatsOnly, \"cg_teamChatsOnly\", \"0\", CVAR_ARCHIVE },\n\t{ &cg_noVoiceChats, \"cg_noVoiceChats\", \"0\", CVAR_ARCHIVE },\n\t{ &cg_noVoiceText, \"cg_noVoiceText\", \"0\", CVAR_ARCHIVE },\n\t// the following variables are created in other parts of the system,\n\t// but we also reference them here\n\t{ &cg_buildScript, \"com_buildScript\", \"0\", 0 },\t// force loading of all possible data amd error on failures\n\t{ &cg_paused, \"cl_paused\", \"0\", CVAR_ROM },\n\t{ &cg_blood, \"com_blood\", \"1\", CVAR_ARCHIVE },\n\t{ &cg_synchronousClients, \"g_synchronousClients\", \"0\", 0 },\t// communicated by systeminfo\n#ifdef MISSIONPACK\n\t{ &cg_redTeamName, \"g_redteam\", DEFAULT_REDTEAM_NAME, CVAR_ARCHIVE | CVAR_SERVERINFO | CVAR_USERINFO },\n\t{ &cg_blueTeamName, \"g_blueteam\", DEFAULT_BLUETEAM_NAME, CVAR_ARCHIVE | CVAR_SERVERINFO | CVAR_USERINFO },\n\t{ &cg_currentSelectedPlayer, \"cg_currentSelectedPlayer\", \"0\", CVAR_ARCHIVE},\n\t{ &cg_currentSelectedPlayerName, \"cg_currentSelectedPlayerName\", \"\", CVAR_ARCHIVE},\n\t{ &cg_singlePlayer, \"ui_singlePlayerActive\", \"0\", CVAR_USERINFO},\n\t{ &cg_enableDust, \"g_enableDust\", \"0\", CVAR_SERVERINFO},\n\t{ &cg_enableBreath, \"g_enableBreath\", \"0\", CVAR_SERVERINFO},\n\t{ &cg_singlePlayerActive, \"ui_singlePlayerActive\", \"0\", CVAR_USERINFO},\n\t{ &cg_recordSPDemo, \"ui_recordSPDemo\", \"0\", CVAR_ARCHIVE},\n\t{ &cg_recordSPDemoName, \"ui_recordSPDemoName\", \"\", CVAR_ARCHIVE},\n\t{ &cg_obeliskRespawnDelay, \"g_obeliskRespawnDelay\", \"10\", CVAR_SERVERINFO},\n\t{ &cg_hudFiles, \"cg_hudFiles\", \"ui/hud.txt\", CVAR_ARCHIVE},\n#endif\n\t{ &cg_cameraOrbit, \"cg_cameraOrbit\", \"0\", CVAR_CHEAT},\n\t{ &cg_cameraOrbitDelay, \"cg_cameraOrbitDelay\", \"50\", CVAR_ARCHIVE},\n\t{ &cg_timescaleFadeEnd, \"cg_timescaleFadeEnd\", \"1\", 0},\n\t{ &cg_timescaleFadeSpeed, \"cg_timescaleFadeSpeed\", \"0\", 0},\n\t{ &cg_timescale, \"timescale\", \"1\", 0},\n\t{ &cg_scorePlum, \"cg_scorePlums\", \"1\", CVAR_USERINFO | CVAR_ARCHIVE},\n\t{ &cg_smoothClients, \"cg_smoothClients\", \"0\", CVAR_USERINFO | CVAR_ARCHIVE},\n\t{ &cg_cameraMode, \"com_cameraMode\", \"0\", CVAR_CHEAT},\n\n\t{ &pmove_fixed, \"pmove_fixed\", \"0\", 0},\n\t{ &pmove_msec, \"pmove_msec\", \"8\", 0},\n\t{ &cg_noTaunt, \"cg_noTaunt\", \"0\", CVAR_ARCHIVE},\n\t{ &cg_noProjectileTrail, \"cg_noProjectileTrail\", \"0\", CVAR_ARCHIVE},\n\t{ &cg_smallFont, \"ui_smallFont\", \"0.25\", CVAR_ARCHIVE},\n\t{ &cg_bigFont, \"ui_bigFont\", \"0.4\", CVAR_ARCHIVE},\n\t{ &cg_oldRail, \"cg_oldRail\", \"1\", CVAR_ARCHIVE},\n\t{ &cg_oldRocket, \"cg_oldRocket\", \"1\", CVAR_ARCHIVE},\n\t{ &cg_oldPlasma, \"cg_oldPlasma\", \"1\", CVAR_ARCHIVE},\n\t{ &cg_trueLightning, \"cg_trueLightning\", \"0.0\", CVAR_ARCHIVE}\n//\t{ &cg_pmove_fixed, \"cg_pmove_fixed\", \"0\", CVAR_USERINFO | CVAR_ARCHIVE }\n};\n\nstatic int  cvarTableSize = sizeof( cvarTable ) / sizeof( cvarTable[0] );\n\n/*\n=================\nCG_RegisterCvars\n=================\n*/\nvoid CG_RegisterCvars( void ) {\n\tint\t\t\ti;\n\tcvarTable_t\t*cv;\n\tchar\t\tvar[MAX_TOKEN_CHARS];\n\n\tfor ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {\n\t\ttrap_Cvar_Register( cv->vmCvar, cv->cvarName,\n\t\t\tcv->defaultString, cv->cvarFlags );\n\t}\n\n\t// see if we are also running the server on this machine\n\ttrap_Cvar_VariableStringBuffer( \"sv_running\", var, sizeof( var ) );\n\tcgs.localServer = atoi( var );\n\n\tforceModelModificationCount = cg_forceModel.modificationCount;\n\n\ttrap_Cvar_Register(NULL, \"model\", DEFAULT_MODEL, CVAR_USERINFO | CVAR_ARCHIVE );\n\ttrap_Cvar_Register(NULL, \"headmodel\", DEFAULT_MODEL, CVAR_USERINFO | CVAR_ARCHIVE );\n\ttrap_Cvar_Register(NULL, \"team_model\", DEFAULT_TEAM_MODEL, CVAR_USERINFO | CVAR_ARCHIVE );\n\ttrap_Cvar_Register(NULL, \"team_headmodel\", DEFAULT_TEAM_HEAD, CVAR_USERINFO | CVAR_ARCHIVE );\n}\n\n/*\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n===================\nCG_ForceModelChange\n===================\n*/\nstatic void CG_ForceModelChange( void ) {\n\tint\t\ti;\n\n\tfor (i=0 ; i<MAX_CLIENTS ; i++) {\n\t\tconst char\t\t*clientInfo;\n\n\t\tclientInfo = CG_ConfigString( CS_PLAYERS+i );\n\t\tif ( !clientInfo[0] ) {\n\t\t\tcontinue;\n\t\t}\n\t\tCG_NewClientInfo( i );\n\t}\n}\n\n/*\n=================\nCG_UpdateCvars\n=================\n*/\nvoid CG_UpdateCvars( void ) {\n\tint\t\t\ti;\n\tcvarTable_t\t*cv;\n\n\tfor ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {\n\t\ttrap_Cvar_Update( cv->vmCvar );\n\t}\n\n\t// check for modications here\n\n\t// If team overlay is on, ask for updates from the server.  If its off,\n\t// let the server know so we don't receive it\n\tif ( drawTeamOverlayModificationCount != cg_drawTeamOverlay.modificationCount ) {\n\t\tdrawTeamOverlayModificationCount = cg_drawTeamOverlay.modificationCount;\n\n\t\tif ( cg_drawTeamOverlay.integer > 0 ) {\n\t\t\ttrap_Cvar_Set( \"teamoverlay\", \"1\" );\n\t\t} else {\n\t\t\ttrap_Cvar_Set( \"teamoverlay\", \"0\" );\n\t\t}\n\t\t// FIXME E3 HACK\n\t\ttrap_Cvar_Set( \"teamoverlay\", \"1\" );\n\t}\n\n\t// if force model changed\n\tif ( forceModelModificationCount != cg_forceModel.modificationCount ) {\n\t\tforceModelModificationCount = cg_forceModel.modificationCount;\n\t\tCG_ForceModelChange();\n\t}\n}\n\nint CG_CrosshairPlayer( void ) {\n\tif ( cg.time > ( cg.crosshairClientTime + 1000 ) ) {\n\t\treturn -1;\n\t}\n\treturn cg.crosshairClientNum;\n}\n\nint CG_LastAttacker( void ) {\n\tif ( !cg.attackerTime ) {\n\t\treturn -1;\n\t}\n\treturn cg.snap->ps.persistant[PERS_ATTACKER];\n}\n\nvoid QDECL CG_Printf( const char *msg, ... ) {\n\tva_list\t\targptr;\n\tchar\t\ttext[1024];\n\n\tva_start (argptr, msg);\n\tvsprintf (text, msg, argptr);\n\tva_end (argptr);\n\n\ttrap_Print( text );\n}\n\nvoid QDECL CG_Error( const char *msg, ... ) {\n\tva_list\t\targptr;\n\tchar\t\ttext[1024];\n\n\tva_start (argptr, msg);\n\tvsprintf (text, msg, argptr);\n\tva_end (argptr);\n\n\ttrap_Error( text );\n}\n\n#ifndef CGAME_HARD_LINKED\n// this is only here so the functions in q_shared.c and bg_*.c can link (FIXME)\n\nvoid QDECL Com_Error( int level, const char *error, ... ) {\n\tva_list\t\targptr;\n\tchar\t\ttext[1024];\n\n\tva_start (argptr, error);\n\tvsprintf (text, error, argptr);\n\tva_end (argptr);\n\n\tCG_Error( \"%s\", text);\n}\n\nvoid QDECL Com_Printf( const char *msg, ... ) {\n\tva_list\t\targptr;\n\tchar\t\ttext[1024];\n\n\tva_start (argptr, msg);\n\tvsprintf (text, msg, argptr);\n\tva_end (argptr);\n\n\tCG_Printf (\"%s\", text);\n}\n\n#endif\n\n/*\n================\nCG_Argv\n================\n*/\nconst char *CG_Argv( int arg ) {\n\tstatic char\tbuffer[MAX_STRING_CHARS];\n\n\ttrap_Argv( arg, buffer, sizeof( buffer ) );\n\n\treturn buffer;\n}\n\n\n//========================================================================\n\n/*\n=================\nCG_RegisterItemSounds\n\nThe server says this item is used on this level\n=================\n*/\nstatic void CG_RegisterItemSounds( int itemNum ) {\n\tgitem_t\t\t\t*item;\n\tchar\t\t\tdata[MAX_QPATH];\n\tchar\t\t\t*s, *start;\n\tint\t\t\t\tlen;\n\n\titem = &bg_itemlist[ itemNum ];\n\n\tif( item->pickup_sound ) {\n\t\ttrap_S_RegisterSound( item->pickup_sound, qfalse );\n\t}\n\n\t// parse the space seperated precache string for other media\n\ts = item->sounds;\n\tif (!s || !s[0])\n\t\treturn;\n\n\twhile (*s) {\n\t\tstart = s;\n\t\twhile (*s && *s != ' ') {\n\t\t\ts++;\n\t\t}\n\n\t\tlen = s-start;\n\t\tif (len >= MAX_QPATH || len < 5) {\n\t\t\tCG_Error( \"PrecacheItem: %s has bad precache string\", \n\t\t\t\titem->classname);\n\t\t\treturn;\n\t\t}\n\t\tmemcpy (data, start, len);\n\t\tdata[len] = 0;\n\t\tif ( *s ) {\n\t\t\ts++;\n\t\t}\n\n\t\tif ( !strcmp(data+len-3, \"wav\" )) {\n\t\t\ttrap_S_RegisterSound( data, qfalse );\n\t\t}\n\t}\n}\n\n\n/*\n=================\nCG_RegisterSounds\n\ncalled during a precache command\n=================\n*/\nstatic void CG_RegisterSounds( void ) {\n\tint\t\ti;\n\tchar\titems[MAX_ITEMS+1];\n\tchar\tname[MAX_QPATH];\n\tconst char\t*soundName;\n\n\t// voice commands\n#ifdef MISSIONPACK\n\tCG_LoadVoiceChats();\n#endif\n\n\tcgs.media.oneMinuteSound = trap_S_RegisterSound( \"sound/feedback/1_minute.wav\", qtrue );\n\tcgs.media.fiveMinuteSound = trap_S_RegisterSound( \"sound/feedback/5_minute.wav\", qtrue );\n\tcgs.media.suddenDeathSound = trap_S_RegisterSound( \"sound/feedback/sudden_death.wav\", qtrue );\n\tcgs.media.oneFragSound = trap_S_RegisterSound( \"sound/feedback/1_frag.wav\", qtrue );\n\tcgs.media.twoFragSound = trap_S_RegisterSound( \"sound/feedback/2_frags.wav\", qtrue );\n\tcgs.media.threeFragSound = trap_S_RegisterSound( \"sound/feedback/3_frags.wav\", qtrue );\n\tcgs.media.count3Sound = trap_S_RegisterSound( \"sound/feedback/three.wav\", qtrue );\n\tcgs.media.count2Sound = trap_S_RegisterSound( \"sound/feedback/two.wav\", qtrue );\n\tcgs.media.count1Sound = trap_S_RegisterSound( \"sound/feedback/one.wav\", qtrue );\n\tcgs.media.countFightSound = trap_S_RegisterSound( \"sound/feedback/fight.wav\", qtrue );\n\tcgs.media.countPrepareSound = trap_S_RegisterSound( \"sound/feedback/prepare.wav\", qtrue );\n#ifdef MISSIONPACK\n\tcgs.media.countPrepareTeamSound = trap_S_RegisterSound( \"sound/feedback/prepare_team.wav\", qtrue );\n#endif\n\n\tif ( cgs.gametype >= GT_TEAM || cg_buildScript.integer ) {\n\n\t\tcgs.media.captureAwardSound = trap_S_RegisterSound( \"sound/teamplay/flagcapture_yourteam.wav\", qtrue );\n\t\tcgs.media.redLeadsSound = trap_S_RegisterSound( \"sound/feedback/redleads.wav\", qtrue );\n\t\tcgs.media.blueLeadsSound = trap_S_RegisterSound( \"sound/feedback/blueleads.wav\", qtrue );\n\t\tcgs.media.teamsTiedSound = trap_S_RegisterSound( \"sound/feedback/teamstied.wav\", qtrue );\n\t\tcgs.media.hitTeamSound = trap_S_RegisterSound( \"sound/feedback/hit_teammate.wav\", qtrue );\n\n\t\tcgs.media.redScoredSound = trap_S_RegisterSound( \"sound/teamplay/voc_red_scores.wav\", qtrue );\n\t\tcgs.media.blueScoredSound = trap_S_RegisterSound( \"sound/teamplay/voc_blue_scores.wav\", qtrue );\n\n\t\tcgs.media.captureYourTeamSound = trap_S_RegisterSound( \"sound/teamplay/flagcapture_yourteam.wav\", qtrue );\n\t\tcgs.media.captureOpponentSound = trap_S_RegisterSound( \"sound/teamplay/flagcapture_opponent.wav\", qtrue );\n\n\t\tcgs.media.returnYourTeamSound = trap_S_RegisterSound( \"sound/teamplay/flagreturn_yourteam.wav\", qtrue );\n\t\tcgs.media.returnOpponentSound = trap_S_RegisterSound( \"sound/teamplay/flagreturn_opponent.wav\", qtrue );\n\n\t\tcgs.media.takenYourTeamSound = trap_S_RegisterSound( \"sound/teamplay/flagtaken_yourteam.wav\", qtrue );\n\t\tcgs.media.takenOpponentSound = trap_S_RegisterSound( \"sound/teamplay/flagtaken_opponent.wav\", qtrue );\n\n\t\tif ( cgs.gametype == GT_CTF || cg_buildScript.integer ) {\n\t\t\tcgs.media.redFlagReturnedSound = trap_S_RegisterSound( \"sound/teamplay/voc_red_returned.wav\", qtrue );\n\t\t\tcgs.media.blueFlagReturnedSound = trap_S_RegisterSound( \"sound/teamplay/voc_blue_returned.wav\", qtrue );\n\t\t\tcgs.media.enemyTookYourFlagSound = trap_S_RegisterSound( \"sound/teamplay/voc_enemy_flag.wav\", qtrue );\n\t\t\tcgs.media.yourTeamTookEnemyFlagSound = trap_S_RegisterSound( \"sound/teamplay/voc_team_flag.wav\", qtrue );\n\t\t}\n\n#ifdef MISSIONPACK\n\t\tif ( cgs.gametype == GT_1FCTF || cg_buildScript.integer ) {\n\t\t\t// FIXME: get a replacement for this sound ?\n\t\t\tcgs.media.neutralFlagReturnedSound = trap_S_RegisterSound( \"sound/teamplay/flagreturn_opponent.wav\", qtrue );\n\t\t\tcgs.media.yourTeamTookTheFlagSound = trap_S_RegisterSound( \"sound/teamplay/voc_team_1flag.wav\", qtrue );\n\t\t\tcgs.media.enemyTookTheFlagSound = trap_S_RegisterSound( \"sound/teamplay/voc_enemy_1flag.wav\", qtrue );\n\t\t}\n\n\t\tif ( cgs.gametype == GT_1FCTF || cgs.gametype == GT_CTF || cg_buildScript.integer ) {\n\t\t\tcgs.media.youHaveFlagSound = trap_S_RegisterSound( \"sound/teamplay/voc_you_flag.wav\", qtrue );\n\t\t\tcgs.media.holyShitSound = trap_S_RegisterSound(\"sound/feedback/voc_holyshit.wav\", qtrue);\n\t\t}\n\n\t\tif ( cgs.gametype == GT_OBELISK || cg_buildScript.integer ) {\n\t\t\tcgs.media.yourBaseIsUnderAttackSound = trap_S_RegisterSound( \"sound/teamplay/voc_base_attack.wav\", qtrue );\n\t\t}\n#else\n\t\tcgs.media.youHaveFlagSound = trap_S_RegisterSound( \"sound/teamplay/voc_you_flag.wav\", qtrue );\n\t\tcgs.media.holyShitSound = trap_S_RegisterSound(\"sound/feedback/voc_holyshit.wav\", qtrue);\n\t\tcgs.media.neutralFlagReturnedSound = trap_S_RegisterSound( \"sound/teamplay/flagreturn_opponent.wav\", qtrue );\n\t\tcgs.media.yourTeamTookTheFlagSound = trap_S_RegisterSound( \"sound/teamplay/voc_team_1flag.wav\", qtrue );\n\t\tcgs.media.enemyTookTheFlagSound = trap_S_RegisterSound( \"sound/teamplay/voc_enemy_1flag.wav\", qtrue );\n#endif\n\t}\n\n\tcgs.media.tracerSound = trap_S_RegisterSound( \"sound/weapons/machinegun/buletby1.wav\", qfalse );\n\tcgs.media.selectSound = trap_S_RegisterSound( \"sound/weapons/change.wav\", qfalse );\n\tcgs.media.wearOffSound = trap_S_RegisterSound( \"sound/items/wearoff.wav\", qfalse );\n\tcgs.media.useNothingSound = trap_S_RegisterSound( \"sound/items/use_nothing.wav\", qfalse );\n\tcgs.media.gibSound = trap_S_RegisterSound( \"sound/player/gibsplt1.wav\", qfalse );\n\tcgs.media.gibBounce1Sound = trap_S_RegisterSound( \"sound/player/gibimp1.wav\", qfalse );\n\tcgs.media.gibBounce2Sound = trap_S_RegisterSound( \"sound/player/gibimp2.wav\", qfalse );\n\tcgs.media.gibBounce3Sound = trap_S_RegisterSound( \"sound/player/gibimp3.wav\", qfalse );\n\n#ifdef MISSIONPACK\n\tcgs.media.useInvulnerabilitySound = trap_S_RegisterSound( \"sound/items/invul_activate.wav\", qfalse );\n\tcgs.media.invulnerabilityImpactSound1 = trap_S_RegisterSound( \"sound/items/invul_impact_01.wav\", qfalse );\n\tcgs.media.invulnerabilityImpactSound2 = trap_S_RegisterSound( \"sound/items/invul_impact_02.wav\", qfalse );\n\tcgs.media.invulnerabilityImpactSound3 = trap_S_RegisterSound( \"sound/items/invul_impact_03.wav\", qfalse );\n\tcgs.media.invulnerabilityJuicedSound = trap_S_RegisterSound( \"sound/items/invul_juiced.wav\", qfalse );\n\tcgs.media.obeliskHitSound1 = trap_S_RegisterSound( \"sound/items/obelisk_hit_01.wav\", qfalse );\n\tcgs.media.obeliskHitSound2 = trap_S_RegisterSound( \"sound/items/obelisk_hit_02.wav\", qfalse );\n\tcgs.media.obeliskHitSound3 = trap_S_RegisterSound( \"sound/items/obelisk_hit_03.wav\", qfalse );\n\tcgs.media.obeliskRespawnSound = trap_S_RegisterSound( \"sound/items/obelisk_respawn.wav\", qfalse );\n\n\tcgs.media.ammoregenSound = trap_S_RegisterSound(\"sound/items/cl_ammoregen.wav\", qfalse);\n\tcgs.media.doublerSound = trap_S_RegisterSound(\"sound/items/cl_doubler.wav\", qfalse);\n\tcgs.media.guardSound = trap_S_RegisterSound(\"sound/items/cl_guard.wav\", qfalse);\n\tcgs.media.scoutSound = trap_S_RegisterSound(\"sound/items/cl_scout.wav\", qfalse);\n#endif\n\n\tcgs.media.teleInSound = trap_S_RegisterSound( \"sound/world/telein.wav\", qfalse );\n\tcgs.media.teleOutSound = trap_S_RegisterSound( \"sound/world/teleout.wav\", qfalse );\n\tcgs.media.respawnSound = trap_S_RegisterSound( \"sound/items/respawn1.wav\", qfalse );\n\n\tcgs.media.noAmmoSound = trap_S_RegisterSound( \"sound/weapons/noammo.wav\", qfalse );\n\n\tcgs.media.talkSound = trap_S_RegisterSound( \"sound/player/talk.wav\", qfalse );\n\tcgs.media.landSound = trap_S_RegisterSound( \"sound/player/land1.wav\", qfalse);\n\n\tcgs.media.hitSound = trap_S_RegisterSound( \"sound/feedback/hit.wav\", qfalse );\n#ifdef MISSIONPACK\n\tcgs.media.hitSoundHighArmor = trap_S_RegisterSound( \"sound/feedback/hithi.wav\", qfalse );\n\tcgs.media.hitSoundLowArmor = trap_S_RegisterSound( \"sound/feedback/hitlo.wav\", qfalse );\n#endif\n\n\tcgs.media.impressiveSound = trap_S_RegisterSound( \"sound/feedback/impressive.wav\", qtrue );\n\tcgs.media.excellentSound = trap_S_RegisterSound( \"sound/feedback/excellent.wav\", qtrue );\n\tcgs.media.deniedSound = trap_S_RegisterSound( \"sound/feedback/denied.wav\", qtrue );\n\tcgs.media.humiliationSound = trap_S_RegisterSound( \"sound/feedback/humiliation.wav\", qtrue );\n\tcgs.media.assistSound = trap_S_RegisterSound( \"sound/feedback/assist.wav\", qtrue );\n\tcgs.media.defendSound = trap_S_RegisterSound( \"sound/feedback/defense.wav\", qtrue );\n#ifdef MISSIONPACK\n\tcgs.media.firstImpressiveSound = trap_S_RegisterSound( \"sound/feedback/first_impressive.wav\", qtrue );\n\tcgs.media.firstExcellentSound = trap_S_RegisterSound( \"sound/feedback/first_excellent.wav\", qtrue );\n\tcgs.media.firstHumiliationSound = trap_S_RegisterSound( \"sound/feedback/first_gauntlet.wav\", qtrue );\n#endif\n\n\tcgs.media.takenLeadSound = trap_S_RegisterSound( \"sound/feedback/takenlead.wav\", qtrue);\n\tcgs.media.tiedLeadSound = trap_S_RegisterSound( \"sound/feedback/tiedlead.wav\", qtrue);\n\tcgs.media.lostLeadSound = trap_S_RegisterSound( \"sound/feedback/lostlead.wav\", qtrue);\n\n#ifdef MISSIONPACK\n\tcgs.media.voteNow = trap_S_RegisterSound( \"sound/feedback/vote_now.wav\", qtrue);\n\tcgs.media.votePassed = trap_S_RegisterSound( \"sound/feedback/vote_passed.wav\", qtrue);\n\tcgs.media.voteFailed = trap_S_RegisterSound( \"sound/feedback/vote_failed.wav\", qtrue);\n#endif\n\n\tcgs.media.watrInSound = trap_S_RegisterSound( \"sound/player/watr_in.wav\", qfalse);\n\tcgs.media.watrOutSound = trap_S_RegisterSound( \"sound/player/watr_out.wav\", qfalse);\n\tcgs.media.watrUnSound = trap_S_RegisterSound( \"sound/player/watr_un.wav\", qfalse);\n\n\tcgs.media.jumpPadSound = trap_S_RegisterSound (\"sound/world/jumppad.wav\", qfalse );\n\n\tfor (i=0 ; i<4 ; i++) {\n\t\tCom_sprintf (name, sizeof(name), \"sound/player/footsteps/step%i.wav\", i+1);\n\t\tcgs.media.footsteps[FOOTSTEP_NORMAL][i] = trap_S_RegisterSound (name, qfalse);\n\n\t\tCom_sprintf (name, sizeof(name), \"sound/player/footsteps/boot%i.wav\", i+1);\n\t\tcgs.media.footsteps[FOOTSTEP_BOOT][i] = trap_S_RegisterSound (name, qfalse);\n\n\t\tCom_sprintf (name, sizeof(name), \"sound/player/footsteps/flesh%i.wav\", i+1);\n\t\tcgs.media.footsteps[FOOTSTEP_FLESH][i] = trap_S_RegisterSound (name, qfalse);\n\n\t\tCom_sprintf (name, sizeof(name), \"sound/player/footsteps/mech%i.wav\", i+1);\n\t\tcgs.media.footsteps[FOOTSTEP_MECH][i] = trap_S_RegisterSound (name, qfalse);\n\n\t\tCom_sprintf (name, sizeof(name), \"sound/player/footsteps/energy%i.wav\", i+1);\n\t\tcgs.media.footsteps[FOOTSTEP_ENERGY][i] = trap_S_RegisterSound (name, qfalse);\n\n\t\tCom_sprintf (name, sizeof(name), \"sound/player/footsteps/splash%i.wav\", i+1);\n\t\tcgs.media.footsteps[FOOTSTEP_SPLASH][i] = trap_S_RegisterSound (name, qfalse);\n\n\t\tCom_sprintf (name, sizeof(name), \"sound/player/footsteps/clank%i.wav\", i+1);\n\t\tcgs.media.footsteps[FOOTSTEP_METAL][i] = trap_S_RegisterSound (name, qfalse);\n\t}\n\n\t// only register the items that the server says we need\n\tstrcpy( items, CG_ConfigString( CS_ITEMS ) );\n\n\tfor ( i = 1 ; i < bg_numItems ; i++ ) {\n//\t\tif ( items[ i ] == '1' || cg_buildScript.integer ) {\n\t\t\tCG_RegisterItemSounds( i );\n//\t\t}\n\t}\n\n\tfor ( i = 1 ; i < MAX_SOUNDS ; i++ ) {\n\t\tsoundName = CG_ConfigString( CS_SOUNDS+i );\n\t\tif ( !soundName[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( soundName[0] == '*' ) {\n\t\t\tcontinue;\t// custom sound\n\t\t}\n\t\tcgs.gameSounds[i] = trap_S_RegisterSound( soundName, qfalse );\n\t}\n\n\t// FIXME: only needed with item\n\tcgs.media.flightSound = trap_S_RegisterSound( \"sound/items/flight.wav\", qfalse );\n\tcgs.media.medkitSound = trap_S_RegisterSound (\"sound/items/use_medkit.wav\", qfalse);\n\tcgs.media.quadSound = trap_S_RegisterSound(\"sound/items/damage3.wav\", qfalse);\n\tcgs.media.sfx_ric1 = trap_S_RegisterSound (\"sound/weapons/machinegun/ric1.wav\", qfalse);\n\tcgs.media.sfx_ric2 = trap_S_RegisterSound (\"sound/weapons/machinegun/ric2.wav\", qfalse);\n\tcgs.media.sfx_ric3 = trap_S_RegisterSound (\"sound/weapons/machinegun/ric3.wav\", qfalse);\n\tcgs.media.sfx_railg = trap_S_RegisterSound (\"sound/weapons/railgun/railgf1a.wav\", qfalse);\n\tcgs.media.sfx_rockexp = trap_S_RegisterSound (\"sound/weapons/rocket/rocklx1a.wav\", qfalse);\n\tcgs.media.sfx_plasmaexp = trap_S_RegisterSound (\"sound/weapons/plasma/plasmx1a.wav\", qfalse);\n#ifdef MISSIONPACK\n\tcgs.media.sfx_proxexp = trap_S_RegisterSound( \"sound/weapons/proxmine/wstbexpl.wav\" , qfalse);\n\tcgs.media.sfx_nghit = trap_S_RegisterSound( \"sound/weapons/nailgun/wnalimpd.wav\" , qfalse);\n\tcgs.media.sfx_nghitflesh = trap_S_RegisterSound( \"sound/weapons/nailgun/wnalimpl.wav\" , qfalse);\n\tcgs.media.sfx_nghitmetal = trap_S_RegisterSound( \"sound/weapons/nailgun/wnalimpm.wav\", qfalse );\n\tcgs.media.sfx_chghit = trap_S_RegisterSound( \"sound/weapons/vulcan/wvulimpd.wav\", qfalse );\n\tcgs.media.sfx_chghitflesh = trap_S_RegisterSound( \"sound/weapons/vulcan/wvulimpl.wav\", qfalse );\n\tcgs.media.sfx_chghitmetal = trap_S_RegisterSound( \"sound/weapons/vulcan/wvulimpm.wav\", qfalse );\n\tcgs.media.weaponHoverSound = trap_S_RegisterSound( \"sound/weapons/weapon_hover.wav\", qfalse );\n\tcgs.media.kamikazeExplodeSound = trap_S_RegisterSound( \"sound/items/kam_explode.wav\", qfalse );\n\tcgs.media.kamikazeImplodeSound = trap_S_RegisterSound( \"sound/items/kam_implode.wav\", qfalse );\n\tcgs.media.kamikazeFarSound = trap_S_RegisterSound( \"sound/items/kam_explode_far.wav\", qfalse );\n\tcgs.media.winnerSound = trap_S_RegisterSound( \"sound/feedback/voc_youwin.wav\", qfalse );\n\tcgs.media.loserSound = trap_S_RegisterSound( \"sound/feedback/voc_youlose.wav\", qfalse );\n\tcgs.media.youSuckSound = trap_S_RegisterSound( \"sound/misc/yousuck.wav\", qfalse );\n\n\tcgs.media.wstbimplSound = trap_S_RegisterSound(\"sound/weapons/proxmine/wstbimpl.wav\", qfalse);\n\tcgs.media.wstbimpmSound = trap_S_RegisterSound(\"sound/weapons/proxmine/wstbimpm.wav\", qfalse);\n\tcgs.media.wstbimpdSound = trap_S_RegisterSound(\"sound/weapons/proxmine/wstbimpd.wav\", qfalse);\n\tcgs.media.wstbactvSound = trap_S_RegisterSound(\"sound/weapons/proxmine/wstbactv.wav\", qfalse);\n#endif\n\n\tcgs.media.regenSound = trap_S_RegisterSound(\"sound/items/regen.wav\", qfalse);\n\tcgs.media.protectSound = trap_S_RegisterSound(\"sound/items/protect3.wav\", qfalse);\n\tcgs.media.n_healthSound = trap_S_RegisterSound(\"sound/items/n_health.wav\", qfalse );\n\tcgs.media.hgrenb1aSound = trap_S_RegisterSound(\"sound/weapons/grenade/hgrenb1a.wav\", qfalse);\n\tcgs.media.hgrenb2aSound = trap_S_RegisterSound(\"sound/weapons/grenade/hgrenb2a.wav\", qfalse);\n\n#ifdef MISSIONPACK\n\ttrap_S_RegisterSound(\"sound/player/james/death1.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/james/death2.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/james/death3.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/james/jump1.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/james/pain25_1.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/james/pain75_1.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/james/pain100_1.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/james/falling1.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/james/gasp.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/james/drown.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/james/fall1.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/james/taunt.wav\", qfalse );\n\n\ttrap_S_RegisterSound(\"sound/player/janet/death1.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/janet/death2.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/janet/death3.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/janet/jump1.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/janet/pain25_1.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/janet/pain75_1.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/janet/pain100_1.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/janet/falling1.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/janet/gasp.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/janet/drown.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/janet/fall1.wav\", qfalse );\n\ttrap_S_RegisterSound(\"sound/player/janet/taunt.wav\", qfalse );\n#endif\n\n}\n\n\n//===================================================================================\n\n\n/*\n=================\nCG_RegisterGraphics\n\nThis function may execute for a couple of minutes with a slow disk.\n=================\n*/\nstatic void CG_RegisterGraphics( void ) {\n\tint\t\t\ti;\n\tchar\t\titems[MAX_ITEMS+1];\n\tstatic char\t\t*sb_nums[11] = {\n\t\t\"gfx/2d/numbers/zero_32b\",\n\t\t\"gfx/2d/numbers/one_32b\",\n\t\t\"gfx/2d/numbers/two_32b\",\n\t\t\"gfx/2d/numbers/three_32b\",\n\t\t\"gfx/2d/numbers/four_32b\",\n\t\t\"gfx/2d/numbers/five_32b\",\n\t\t\"gfx/2d/numbers/six_32b\",\n\t\t\"gfx/2d/numbers/seven_32b\",\n\t\t\"gfx/2d/numbers/eight_32b\",\n\t\t\"gfx/2d/numbers/nine_32b\",\n\t\t\"gfx/2d/numbers/minus_32b\",\n\t};\n\n\t// clear any references to old media\n\tmemset( &cg.refdef, 0, sizeof( cg.refdef ) );\n\ttrap_R_ClearScene();\n\n\tCG_LoadingString( cgs.mapname );\n\n\ttrap_R_LoadWorldMap( cgs.mapname );\n\n\t// precache status bar pics\n\tCG_LoadingString( \"game media\" );\n\n\tfor ( i=0 ; i<11 ; i++) {\n\t\tcgs.media.numberShaders[i] = trap_R_RegisterShader( sb_nums[i] );\n\t}\n\n\tcgs.media.botSkillShaders[0] = trap_R_RegisterShader( \"menu/art/skill1.tga\" );\n\tcgs.media.botSkillShaders[1] = trap_R_RegisterShader( \"menu/art/skill2.tga\" );\n\tcgs.media.botSkillShaders[2] = trap_R_RegisterShader( \"menu/art/skill3.tga\" );\n\tcgs.media.botSkillShaders[3] = trap_R_RegisterShader( \"menu/art/skill4.tga\" );\n\tcgs.media.botSkillShaders[4] = trap_R_RegisterShader( \"menu/art/skill5.tga\" );\n\n\tcgs.media.viewBloodShader = trap_R_RegisterShader( \"viewBloodBlend\" );\n\n\tcgs.media.deferShader = trap_R_RegisterShaderNoMip( \"gfx/2d/defer.tga\" );\n\n\tcgs.media.scoreboardName = trap_R_RegisterShaderNoMip( \"menu/tab/name.tga\" );\n\tcgs.media.scoreboardPing = trap_R_RegisterShaderNoMip( \"menu/tab/ping.tga\" );\n\tcgs.media.scoreboardScore = trap_R_RegisterShaderNoMip( \"menu/tab/score.tga\" );\n\tcgs.media.scoreboardTime = trap_R_RegisterShaderNoMip( \"menu/tab/time.tga\" );\n\n\tcgs.media.smokePuffShader = trap_R_RegisterShader( \"smokePuff\" );\n\tcgs.media.smokePuffRageProShader = trap_R_RegisterShader( \"smokePuffRagePro\" );\n\tcgs.media.shotgunSmokePuffShader = trap_R_RegisterShader( \"shotgunSmokePuff\" );\n#ifdef MISSIONPACK\n\tcgs.media.nailPuffShader = trap_R_RegisterShader( \"nailtrail\" );\n\tcgs.media.blueProxMine = trap_R_RegisterModel( \"models/weaphits/proxmineb.md3\" );\n#endif\n\tcgs.media.plasmaBallShader = trap_R_RegisterShader( \"sprites/plasma1\" );\n\tcgs.media.bloodTrailShader = trap_R_RegisterShader( \"bloodTrail\" );\n\tcgs.media.lagometerShader = trap_R_RegisterShader(\"lagometer\" );\n\tcgs.media.connectionShader = trap_R_RegisterShader( \"disconnected\" );\n\n\tcgs.media.waterBubbleShader = trap_R_RegisterShader( \"waterBubble\" );\n\n\tcgs.media.tracerShader = trap_R_RegisterShader( \"gfx/misc/tracer\" );\n\tcgs.media.selectShader = trap_R_RegisterShader( \"gfx/2d/select\" );\n\n\tfor ( i = 0 ; i < NUM_CROSSHAIRS ; i++ ) {\n\t\tcgs.media.crosshairShader[i] = trap_R_RegisterShader( va(\"gfx/2d/crosshair%c\", 'a'+i) );\n\t}\n\n\tcgs.media.backTileShader = trap_R_RegisterShader( \"gfx/2d/backtile\" );\n\tcgs.media.noammoShader = trap_R_RegisterShader( \"icons/noammo\" );\n\n\t// powerup shaders\n\tcgs.media.quadShader = trap_R_RegisterShader(\"powerups/quad\" );\n\tcgs.media.quadWeaponShader = trap_R_RegisterShader(\"powerups/quadWeapon\" );\n\tcgs.media.battleSuitShader = trap_R_RegisterShader(\"powerups/battleSuit\" );\n\tcgs.media.battleWeaponShader = trap_R_RegisterShader(\"powerups/battleWeapon\" );\n\tcgs.media.invisShader = trap_R_RegisterShader(\"powerups/invisibility\" );\n\tcgs.media.regenShader = trap_R_RegisterShader(\"powerups/regen\" );\n\tcgs.media.hastePuffShader = trap_R_RegisterShader(\"hasteSmokePuff\" );\n\n#ifdef MISSIONPACK\n\tif ( cgs.gametype == GT_CTF || cgs.gametype == GT_1FCTF || cgs.gametype == GT_HARVESTER || cg_buildScript.integer ) {\n#else\n\tif ( cgs.gametype == GT_CTF || cg_buildScript.integer ) {\n#endif\n\t\tcgs.media.redCubeModel = trap_R_RegisterModel( \"models/powerups/orb/r_orb.md3\" );\n\t\tcgs.media.blueCubeModel = trap_R_RegisterModel( \"models/powerups/orb/b_orb.md3\" );\n\t\tcgs.media.redCubeIcon = trap_R_RegisterShader( \"icons/skull_red\" );\n\t\tcgs.media.blueCubeIcon = trap_R_RegisterShader( \"icons/skull_blue\" );\n\t}\n\n#ifdef MISSIONPACK\n\tif ( cgs.gametype == GT_CTF || cgs.gametype == GT_1FCTF || cgs.gametype == GT_HARVESTER || cg_buildScript.integer ) {\n#else\n\tif ( cgs.gametype == GT_CTF || cg_buildScript.integer ) {\n#endif\n\t\tcgs.media.redFlagModel = trap_R_RegisterModel( \"models/flags/r_flag.md3\" );\n\t\tcgs.media.blueFlagModel = trap_R_RegisterModel( \"models/flags/b_flag.md3\" );\n\t\tcgs.media.redFlagShader[0] = trap_R_RegisterShaderNoMip( \"icons/iconf_red1\" );\n\t\tcgs.media.redFlagShader[1] = trap_R_RegisterShaderNoMip( \"icons/iconf_red2\" );\n\t\tcgs.media.redFlagShader[2] = trap_R_RegisterShaderNoMip( \"icons/iconf_red3\" );\n\t\tcgs.media.blueFlagShader[0] = trap_R_RegisterShaderNoMip( \"icons/iconf_blu1\" );\n\t\tcgs.media.blueFlagShader[1] = trap_R_RegisterShaderNoMip( \"icons/iconf_blu2\" );\n\t\tcgs.media.blueFlagShader[2] = trap_R_RegisterShaderNoMip( \"icons/iconf_blu3\" );\n#ifdef MISSIONPACK\n\t\tcgs.media.flagPoleModel = trap_R_RegisterModel( \"models/flag2/flagpole.md3\" );\n\t\tcgs.media.flagFlapModel = trap_R_RegisterModel( \"models/flag2/flagflap3.md3\" );\n\n\t\tcgs.media.redFlagFlapSkin = trap_R_RegisterSkin( \"models/flag2/red.skin\" );\n\t\tcgs.media.blueFlagFlapSkin = trap_R_RegisterSkin( \"models/flag2/blue.skin\" );\n\t\tcgs.media.neutralFlagFlapSkin = trap_R_RegisterSkin( \"models/flag2/white.skin\" );\n\n\t\tcgs.media.redFlagBaseModel = trap_R_RegisterModel( \"models/mapobjects/flagbase/red_base.md3\" );\n\t\tcgs.media.blueFlagBaseModel = trap_R_RegisterModel( \"models/mapobjects/flagbase/blue_base.md3\" );\n\t\tcgs.media.neutralFlagBaseModel = trap_R_RegisterModel( \"models/mapobjects/flagbase/ntrl_base.md3\" );\n#endif\n\t}\n\n#ifdef MISSIONPACK\n\tif ( cgs.gametype == GT_1FCTF || cg_buildScript.integer ) {\n\t\tcgs.media.neutralFlagModel = trap_R_RegisterModel( \"models/flags/n_flag.md3\" );\n\t\tcgs.media.flagShader[0] = trap_R_RegisterShaderNoMip( \"icons/iconf_neutral1\" );\n\t\tcgs.media.flagShader[1] = trap_R_RegisterShaderNoMip( \"icons/iconf_red2\" );\n\t\tcgs.media.flagShader[2] = trap_R_RegisterShaderNoMip( \"icons/iconf_blu2\" );\n\t\tcgs.media.flagShader[3] = trap_R_RegisterShaderNoMip( \"icons/iconf_neutral3\" );\n\t}\n\n\tif ( cgs.gametype == GT_OBELISK || cg_buildScript.integer ) {\n\t\tcgs.media.overloadBaseModel = trap_R_RegisterModel( \"models/powerups/overload_base.md3\" );\n\t\tcgs.media.overloadTargetModel = trap_R_RegisterModel( \"models/powerups/overload_target.md3\" );\n\t\tcgs.media.overloadLightsModel = trap_R_RegisterModel( \"models/powerups/overload_lights.md3\" );\n\t\tcgs.media.overloadEnergyModel = trap_R_RegisterModel( \"models/powerups/overload_energy.md3\" );\n\t}\n\n\tif ( cgs.gametype == GT_HARVESTER || cg_buildScript.integer ) {\n\t\tcgs.media.harvesterModel = trap_R_RegisterModel( \"models/powerups/harvester/harvester.md3\" );\n\t\tcgs.media.harvesterRedSkin = trap_R_RegisterSkin( \"models/powerups/harvester/red.skin\" );\n\t\tcgs.media.harvesterBlueSkin = trap_R_RegisterSkin( \"models/powerups/harvester/blue.skin\" );\n\t\tcgs.media.harvesterNeutralModel = trap_R_RegisterModel( \"models/powerups/obelisk/obelisk.md3\" );\n\t}\n\n\tcgs.media.redKamikazeShader = trap_R_RegisterShader( \"models/weaphits/kamikred\" );\n\tcgs.media.dustPuffShader = trap_R_RegisterShader(\"hasteSmokePuff\" );\n#endif\n\n\tif ( cgs.gametype >= GT_TEAM || cg_buildScript.integer ) {\n\t\tcgs.media.friendShader = trap_R_RegisterShader( \"sprites/foe\" );\n\t\tcgs.media.redQuadShader = trap_R_RegisterShader(\"powerups/blueflag\" );\n\t\tcgs.media.teamStatusBar = trap_R_RegisterShader( \"gfx/2d/colorbar.tga\" );\n#ifdef MISSIONPACK\n\t\tcgs.media.blueKamikazeShader = trap_R_RegisterShader( \"models/weaphits/kamikblu\" );\n#endif\n\t}\n\n\tcgs.media.armorModel = trap_R_RegisterModel( \"models/powerups/armor/armor_yel.md3\" );\n\tcgs.media.armorIcon  = trap_R_RegisterShaderNoMip( \"icons/iconr_yellow\" );\n\n\tcgs.media.machinegunBrassModel = trap_R_RegisterModel( \"models/weapons2/shells/m_shell.md3\" );\n\tcgs.media.shotgunBrassModel = trap_R_RegisterModel( \"models/weapons2/shells/s_shell.md3\" );\n\n\tcgs.media.gibAbdomen = trap_R_RegisterModel( \"models/gibs/abdomen.md3\" );\n\tcgs.media.gibArm = trap_R_RegisterModel( \"models/gibs/arm.md3\" );\n\tcgs.media.gibChest = trap_R_RegisterModel( \"models/gibs/chest.md3\" );\n\tcgs.media.gibFist = trap_R_RegisterModel( \"models/gibs/fist.md3\" );\n\tcgs.media.gibFoot = trap_R_RegisterModel( \"models/gibs/foot.md3\" );\n\tcgs.media.gibForearm = trap_R_RegisterModel( \"models/gibs/forearm.md3\" );\n\tcgs.media.gibIntestine = trap_R_RegisterModel( \"models/gibs/intestine.md3\" );\n\tcgs.media.gibLeg = trap_R_RegisterModel( \"models/gibs/leg.md3\" );\n\tcgs.media.gibSkull = trap_R_RegisterModel( \"models/gibs/skull.md3\" );\n\tcgs.media.gibBrain = trap_R_RegisterModel( \"models/gibs/brain.md3\" );\n\n\tcgs.media.smoke2 = trap_R_RegisterModel( \"models/weapons2/shells/s_shell.md3\" );\n\n\tcgs.media.balloonShader = trap_R_RegisterShader( \"sprites/balloon3\" );\n\n\tcgs.media.bloodExplosionShader = trap_R_RegisterShader( \"bloodExplosion\" );\n\n\tcgs.media.bulletFlashModel = trap_R_RegisterModel(\"models/weaphits/bullet.md3\");\n\tcgs.media.ringFlashModel = trap_R_RegisterModel(\"models/weaphits/ring02.md3\");\n\tcgs.media.dishFlashModel = trap_R_RegisterModel(\"models/weaphits/boom01.md3\");\n#ifdef MISSIONPACK\n\tcgs.media.teleportEffectModel = trap_R_RegisterModel( \"models/powerups/pop.md3\" );\n#else\n\tcgs.media.teleportEffectModel = trap_R_RegisterModel( \"models/misc/telep.md3\" );\n\tcgs.media.teleportEffectShader = trap_R_RegisterShader( \"teleportEffect\" );\n#endif\n#ifdef MISSIONPACK\n\tcgs.media.kamikazeEffectModel = trap_R_RegisterModel( \"models/weaphits/kamboom2.md3\" );\n\tcgs.media.kamikazeShockWave = trap_R_RegisterModel( \"models/weaphits/kamwave.md3\" );\n\tcgs.media.kamikazeHeadModel = trap_R_RegisterModel( \"models/powerups/kamikazi.md3\" );\n\tcgs.media.kamikazeHeadTrail = trap_R_RegisterModel( \"models/powerups/trailtest.md3\" );\n\tcgs.media.guardPowerupModel = trap_R_RegisterModel( \"models/powerups/guard_player.md3\" );\n\tcgs.media.scoutPowerupModel = trap_R_RegisterModel( \"models/powerups/scout_player.md3\" );\n\tcgs.media.doublerPowerupModel = trap_R_RegisterModel( \"models/powerups/doubler_player.md3\" );\n\tcgs.media.ammoRegenPowerupModel = trap_R_RegisterModel( \"models/powerups/ammo_player.md3\" );\n\tcgs.media.invulnerabilityImpactModel = trap_R_RegisterModel( \"models/powerups/shield/impact.md3\" );\n\tcgs.media.invulnerabilityJuicedModel = trap_R_RegisterModel( \"models/powerups/shield/juicer.md3\" );\n\tcgs.media.medkitUsageModel = trap_R_RegisterModel( \"models/powerups/regen.md3\" );\n\tcgs.media.heartShader = trap_R_RegisterShaderNoMip( \"ui/assets/statusbar/selectedhealth.tga\" );\n\n#endif\n\n\tcgs.media.invulnerabilityPowerupModel = trap_R_RegisterModel( \"models/powerups/shield/shield.md3\" );\n\tcgs.media.medalImpressive = trap_R_RegisterShaderNoMip( \"medal_impressive\" );\n\tcgs.media.medalExcellent = trap_R_RegisterShaderNoMip( \"medal_excellent\" );\n\tcgs.media.medalGauntlet = trap_R_RegisterShaderNoMip( \"medal_gauntlet\" );\n\tcgs.media.medalDefend = trap_R_RegisterShaderNoMip( \"medal_defend\" );\n\tcgs.media.medalAssist = trap_R_RegisterShaderNoMip( \"medal_assist\" );\n\tcgs.media.medalCapture = trap_R_RegisterShaderNoMip( \"medal_capture\" );\n\n\n\tmemset( cg_items, 0, sizeof( cg_items ) );\n\tmemset( cg_weapons, 0, sizeof( cg_weapons ) );\n\n\t// only register the items that the server says we need\n\tstrcpy( items, CG_ConfigString( CS_ITEMS) );\n\n\tfor ( i = 1 ; i < bg_numItems ; i++ ) {\n\t\tif ( items[ i ] == '1' || cg_buildScript.integer ) {\n\t\t\tCG_LoadingItem( i );\n\t\t\tCG_RegisterItemVisuals( i );\n\t\t}\n\t}\n\n\t// wall marks\n\tcgs.media.bulletMarkShader = trap_R_RegisterShader( \"gfx/damage/bullet_mrk\" );\n\tcgs.media.burnMarkShader = trap_R_RegisterShader( \"gfx/damage/burn_med_mrk\" );\n\tcgs.media.holeMarkShader = trap_R_RegisterShader( \"gfx/damage/hole_lg_mrk\" );\n\tcgs.media.energyMarkShader = trap_R_RegisterShader( \"gfx/damage/plasma_mrk\" );\n\tcgs.media.shadowMarkShader = trap_R_RegisterShader( \"markShadow\" );\n\tcgs.media.wakeMarkShader = trap_R_RegisterShader( \"wake\" );\n\tcgs.media.bloodMarkShader = trap_R_RegisterShader( \"bloodMark\" );\n\n\t// register the inline models\n\tcgs.numInlineModels = trap_CM_NumInlineModels();\n\tfor ( i = 1 ; i < cgs.numInlineModels ; i++ ) {\n\t\tchar\tname[10];\n\t\tvec3_t\t\t\tmins, maxs;\n\t\tint\t\t\t\tj;\n\n\t\tCom_sprintf( name, sizeof(name), \"*%i\", i );\n\t\tcgs.inlineDrawModel[i] = trap_R_RegisterModel( name );\n\t\ttrap_R_ModelBounds( cgs.inlineDrawModel[i], mins, maxs );\n\t\tfor ( j = 0 ; j < 3 ; j++ ) {\n\t\t\tcgs.inlineModelMidpoints[i][j] = mins[j] + 0.5 * ( maxs[j] - mins[j] );\n\t\t}\n\t}\n\n\t// register all the server specified models\n\tfor (i=1 ; i<MAX_MODELS ; i++) {\n\t\tconst char\t\t*modelName;\n\n\t\tmodelName = CG_ConfigString( CS_MODELS+i );\n\t\tif ( !modelName[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tcgs.gameModels[i] = trap_R_RegisterModel( modelName );\n\t}\n\n#ifdef MISSIONPACK\n\t// new stuff\n\tcgs.media.patrolShader = trap_R_RegisterShaderNoMip(\"ui/assets/statusbar/patrol.tga\");\n\tcgs.media.assaultShader = trap_R_RegisterShaderNoMip(\"ui/assets/statusbar/assault.tga\");\n\tcgs.media.campShader = trap_R_RegisterShaderNoMip(\"ui/assets/statusbar/camp.tga\");\n\tcgs.media.followShader = trap_R_RegisterShaderNoMip(\"ui/assets/statusbar/follow.tga\");\n\tcgs.media.defendShader = trap_R_RegisterShaderNoMip(\"ui/assets/statusbar/defend.tga\");\n\tcgs.media.teamLeaderShader = trap_R_RegisterShaderNoMip(\"ui/assets/statusbar/team_leader.tga\");\n\tcgs.media.retrieveShader = trap_R_RegisterShaderNoMip(\"ui/assets/statusbar/retrieve.tga\");\n\tcgs.media.escortShader = trap_R_RegisterShaderNoMip(\"ui/assets/statusbar/escort.tga\");\n\tcgs.media.cursor = trap_R_RegisterShaderNoMip( \"menu/art/3_cursor2\" );\n\tcgs.media.sizeCursor = trap_R_RegisterShaderNoMip( \"ui/assets/sizecursor.tga\" );\n\tcgs.media.selectCursor = trap_R_RegisterShaderNoMip( \"ui/assets/selectcursor.tga\" );\n\tcgs.media.flagShaders[0] = trap_R_RegisterShaderNoMip(\"ui/assets/statusbar/flag_in_base.tga\");\n\tcgs.media.flagShaders[1] = trap_R_RegisterShaderNoMip(\"ui/assets/statusbar/flag_capture.tga\");\n\tcgs.media.flagShaders[2] = trap_R_RegisterShaderNoMip(\"ui/assets/statusbar/flag_missing.tga\");\n\n\ttrap_R_RegisterModel( \"models/players/james/lower.md3\" );\n\ttrap_R_RegisterModel( \"models/players/james/upper.md3\" );\n\ttrap_R_RegisterModel( \"models/players/heads/james/james.md3\" );\n\n\ttrap_R_RegisterModel( \"models/players/janet/lower.md3\" );\n\ttrap_R_RegisterModel( \"models/players/janet/upper.md3\" );\n\ttrap_R_RegisterModel( \"models/players/heads/janet/janet.md3\" );\n\n#endif\n\tCG_ClearParticles ();\n/*\n\tfor (i=1; i<MAX_PARTICLES_AREAS; i++)\n\t{\n\t\t{\n\t\t\tint rval;\n\n\t\t\trval = CG_NewParticleArea ( CS_PARTICLES + i);\n\t\t\tif (!rval)\n\t\t\t\tbreak;\n\t\t}\n\t}\n*/\n}\n\n\n\n/*\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n=======================\nCG_BuildSpectatorString\n\n=======================\n*/\nvoid CG_BuildSpectatorString() {\n\tint i;\n\tcg.spectatorList[0] = 0;\n\tfor (i = 0; i < MAX_CLIENTS; i++) {\n\t\tif (cgs.clientinfo[i].infoValid && cgs.clientinfo[i].team == TEAM_SPECTATOR ) {\n\t\t\tQ_strcat(cg.spectatorList, sizeof(cg.spectatorList), va(\"%s     \", cgs.clientinfo[i].name));\n\t\t}\n\t}\n\ti = strlen(cg.spectatorList);\n\tif (i != cg.spectatorLen) {\n\t\tcg.spectatorLen = i;\n\t\tcg.spectatorWidth = -1;\n\t}\n}\n\n\n/*\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n===================\nCG_RegisterClients\n===================\n*/\nstatic void CG_RegisterClients( void ) {\n\tint\t\ti;\n\n\tCG_LoadingClient(cg.clientNum);\n\tCG_NewClientInfo(cg.clientNum);\n\n\tfor (i=0 ; i<MAX_CLIENTS ; i++) {\n\t\tconst char\t\t*clientInfo;\n\n\t\tif (cg.clientNum == i) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tclientInfo = CG_ConfigString( CS_PLAYERS+i );\n\t\tif ( !clientInfo[0]) {\n\t\t\tcontinue;\n\t\t}\n\t\tCG_LoadingClient( i );\n\t\tCG_NewClientInfo( i );\n\t}\n\tCG_BuildSpectatorString();\n}\n\n//===========================================================================\n\n/*\n=================\nCG_ConfigString\n=================\n*/\nconst char *CG_ConfigString( int index ) {\n\tif ( index < 0 || index >= MAX_CONFIGSTRINGS ) {\n\t\tCG_Error( \"CG_ConfigString: bad index: %i\", index );\n\t}\n\treturn cgs.gameState.stringData + cgs.gameState.stringOffsets[ index ];\n}\n\n//==================================================================\n\n/*\n======================\nCG_StartMusic\n\n======================\n*/\nvoid CG_StartMusic( void ) {\n\tchar\t*s;\n\tchar\tparm1[MAX_QPATH], parm2[MAX_QPATH];\n\n\t// start the background music\n\ts = (char *)CG_ConfigString( CS_MUSIC );\n\tQ_strncpyz( parm1, COM_Parse( &s ), sizeof( parm1 ) );\n\tQ_strncpyz( parm2, COM_Parse( &s ), sizeof( parm2 ) );\n\n\ttrap_S_StartBackgroundTrack( parm1, parm2 );\n}\n#ifdef MISSIONPACK\nchar *CG_GetMenuBuffer(const char *filename) {\n\tint\tlen;\n\tfileHandle_t\tf;\n\tstatic char buf[MAX_MENUFILE];\n\n\tlen = trap_FS_FOpenFile( filename, &f, FS_READ );\n\tif ( !f ) {\n\t\ttrap_Print( va( S_COLOR_RED \"menu file not found: %s, using default\\n\", filename ) );\n\t\treturn NULL;\n\t}\n\tif ( len >= MAX_MENUFILE ) {\n\t\ttrap_Print( va( S_COLOR_RED \"menu file too large: %s is %i, max allowed is %i\", filename, len, MAX_MENUFILE ) );\n\t\ttrap_FS_FCloseFile( f );\n\t\treturn NULL;\n\t}\n\n\ttrap_FS_Read( buf, len, f );\n\tbuf[len] = 0;\n\ttrap_FS_FCloseFile( f );\n\n\treturn buf;\n}\n\n//\n// ==============================\n// new hud stuff ( mission pack )\n// ==============================\n//\nqboolean CG_Asset_Parse(int handle) {\n\tpc_token_t token;\n\tconst char *tempStr;\n\n\tif (!trap_PC_ReadToken(handle, &token))\n\t\treturn qfalse;\n\tif (Q_stricmp(token.string, \"{\") != 0) {\n\t\treturn qfalse;\n\t}\n    \n\twhile ( 1 ) {\n\t\tif (!trap_PC_ReadToken(handle, &token))\n\t\t\treturn qfalse;\n\n\t\tif (Q_stricmp(token.string, \"}\") == 0) {\n\t\t\treturn qtrue;\n\t\t}\n\n\t\t// font\n\t\tif (Q_stricmp(token.string, \"font\") == 0) {\n\t\t\tint pointSize;\n\t\t\tif (!PC_String_Parse(handle, &tempStr) || !PC_Int_Parse(handle, &pointSize)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tcgDC.registerFont(tempStr, pointSize, &cgDC.Assets.textFont);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// smallFont\n\t\tif (Q_stricmp(token.string, \"smallFont\") == 0) {\n\t\t\tint pointSize;\n\t\t\tif (!PC_String_Parse(handle, &tempStr) || !PC_Int_Parse(handle, &pointSize)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tcgDC.registerFont(tempStr, pointSize, &cgDC.Assets.smallFont);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// font\n\t\tif (Q_stricmp(token.string, \"bigfont\") == 0) {\n\t\t\tint pointSize;\n\t\t\tif (!PC_String_Parse(handle, &tempStr) || !PC_Int_Parse(handle, &pointSize)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tcgDC.registerFont(tempStr, pointSize, &cgDC.Assets.bigFont);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// gradientbar\n\t\tif (Q_stricmp(token.string, \"gradientbar\") == 0) {\n\t\t\tif (!PC_String_Parse(handle, &tempStr)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tcgDC.Assets.gradientBar = trap_R_RegisterShaderNoMip(tempStr);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// enterMenuSound\n\t\tif (Q_stricmp(token.string, \"menuEnterSound\") == 0) {\n\t\t\tif (!PC_String_Parse(handle, &tempStr)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tcgDC.Assets.menuEnterSound = trap_S_RegisterSound( tempStr, qfalse );\n\t\t\tcontinue;\n\t\t}\n\n\t\t// exitMenuSound\n\t\tif (Q_stricmp(token.string, \"menuExitSound\") == 0) {\n\t\t\tif (!PC_String_Parse(handle, &tempStr)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tcgDC.Assets.menuExitSound = trap_S_RegisterSound( tempStr, qfalse );\n\t\t\tcontinue;\n\t\t}\n\n\t\t// itemFocusSound\n\t\tif (Q_stricmp(token.string, \"itemFocusSound\") == 0) {\n\t\t\tif (!PC_String_Parse(handle, &tempStr)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tcgDC.Assets.itemFocusSound = trap_S_RegisterSound( tempStr, qfalse );\n\t\t\tcontinue;\n\t\t}\n\n\t\t// menuBuzzSound\n\t\tif (Q_stricmp(token.string, \"menuBuzzSound\") == 0) {\n\t\t\tif (!PC_String_Parse(handle, &tempStr)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tcgDC.Assets.menuBuzzSound = trap_S_RegisterSound( tempStr, qfalse );\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (Q_stricmp(token.string, \"cursor\") == 0) {\n\t\t\tif (!PC_String_Parse(handle, &cgDC.Assets.cursorStr)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tcgDC.Assets.cursor = trap_R_RegisterShaderNoMip( cgDC.Assets.cursorStr);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (Q_stricmp(token.string, \"fadeClamp\") == 0) {\n\t\t\tif (!PC_Float_Parse(handle, &cgDC.Assets.fadeClamp)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (Q_stricmp(token.string, \"fadeCycle\") == 0) {\n\t\t\tif (!PC_Int_Parse(handle, &cgDC.Assets.fadeCycle)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (Q_stricmp(token.string, \"fadeAmount\") == 0) {\n\t\t\tif (!PC_Float_Parse(handle, &cgDC.Assets.fadeAmount)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (Q_stricmp(token.string, \"shadowX\") == 0) {\n\t\t\tif (!PC_Float_Parse(handle, &cgDC.Assets.shadowX)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (Q_stricmp(token.string, \"shadowY\") == 0) {\n\t\t\tif (!PC_Float_Parse(handle, &cgDC.Assets.shadowY)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (Q_stricmp(token.string, \"shadowColor\") == 0) {\n\t\t\tif (!PC_Color_Parse(handle, &cgDC.Assets.shadowColor)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tcgDC.Assets.shadowFadeClamp = cgDC.Assets.shadowColor[3];\n\t\t\tcontinue;\n\t\t}\n\t}\n\treturn qfalse; // bk001204 - why not?\n}\n\nvoid CG_ParseMenu(const char *menuFile) {\n\tpc_token_t token;\n\tint handle;\n\n\thandle = trap_PC_LoadSource(menuFile);\n\tif (!handle)\n\t\thandle = trap_PC_LoadSource(\"ui/testhud.menu\");\n\tif (!handle)\n\t\treturn;\n\n\twhile ( 1 ) {\n\t\tif (!trap_PC_ReadToken( handle, &token )) {\n\t\t\tbreak;\n\t\t}\n\n\t\t//if ( Q_stricmp( token, \"{\" ) ) {\n\t\t//\tCom_Printf( \"Missing { in menu file\\n\" );\n\t\t//\tbreak;\n\t\t//}\n\n\t\t//if ( menuCount == MAX_MENUS ) {\n\t\t//\tCom_Printf( \"Too many menus!\\n\" );\n\t\t//\tbreak;\n\t\t//}\n\n\t\tif ( token.string[0] == '}' ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (Q_stricmp(token.string, \"assetGlobalDef\") == 0) {\n\t\t\tif (CG_Asset_Parse(handle)) {\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\n\t\tif (Q_stricmp(token.string, \"menudef\") == 0) {\n\t\t\t// start a new menu\n\t\t\tMenu_New(handle);\n\t\t}\n\t}\n\ttrap_PC_FreeSource(handle);\n}\n\nqboolean CG_Load_Menu(char **p) {\n\tchar *token;\n\n\ttoken = COM_ParseExt(p, qtrue);\n\n\tif (token[0] != '{') {\n\t\treturn qfalse;\n\t}\n\n\twhile ( 1 ) {\n\n\t\ttoken = COM_ParseExt(p, qtrue);\n    \n\t\tif (Q_stricmp(token, \"}\") == 0) {\n\t\t\treturn qtrue;\n\t\t}\n\n\t\tif ( !token || token[0] == 0 ) {\n\t\t\treturn qfalse;\n\t\t}\n\n\t\tCG_ParseMenu(token); \n\t}\n\treturn qfalse;\n}\n\n\n\nvoid CG_LoadMenus(const char *menuFile) {\n\tchar\t*token;\n\tchar *p;\n\tint\tlen, start;\n\tfileHandle_t\tf;\n\tstatic char buf[MAX_MENUDEFFILE];\n\n\tstart = trap_Milliseconds();\n\n\tlen = trap_FS_FOpenFile( menuFile, &f, FS_READ );\n\tif ( !f ) {\n\t\ttrap_Error( va( S_COLOR_YELLOW \"menu file not found: %s, using default\\n\", menuFile ) );\n\t\tlen = trap_FS_FOpenFile( \"ui/hud.txt\", &f, FS_READ );\n\t\tif (!f) {\n\t\t\ttrap_Error( va( S_COLOR_RED \"default menu file not found: ui/hud.txt, unable to continue!\\n\", menuFile ) );\n\t\t}\n\t}\n\n\tif ( len >= MAX_MENUDEFFILE ) {\n\t\ttrap_Error( va( S_COLOR_RED \"menu file too large: %s is %i, max allowed is %i\", menuFile, len, MAX_MENUDEFFILE ) );\n\t\ttrap_FS_FCloseFile( f );\n\t\treturn;\n\t}\n\n\ttrap_FS_Read( buf, len, f );\n\tbuf[len] = 0;\n\ttrap_FS_FCloseFile( f );\n\t\n\tCOM_Compress(buf);\n\n\tMenu_Reset();\n\n\tp = buf;\n\n\twhile ( 1 ) {\n\t\ttoken = COM_ParseExt( &p, qtrue );\n\t\tif( !token || token[0] == 0 || token[0] == '}') {\n\t\t\tbreak;\n\t\t}\n\n\t\t//if ( Q_stricmp( token, \"{\" ) ) {\n\t\t//\tCom_Printf( \"Missing { in menu file\\n\" );\n\t\t//\tbreak;\n\t\t//}\n\n\t\t//if ( menuCount == MAX_MENUS ) {\n\t\t//\tCom_Printf( \"Too many menus!\\n\" );\n\t\t//\tbreak;\n\t\t//}\n\n\t\tif ( Q_stricmp( token, \"}\" ) == 0 ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (Q_stricmp(token, \"loadmenu\") == 0) {\n\t\t\tif (CG_Load_Menu(&p)) {\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tCom_Printf(\"UI menu load time = %d milli seconds\\n\", trap_Milliseconds() - start);\n\n}\n\n\n\nstatic qboolean CG_OwnerDrawHandleKey(int ownerDraw, int flags, float *special, int key) {\n\treturn qfalse;\n}\n\n\nstatic int CG_FeederCount(float feederID) {\n\tint i, count;\n\tcount = 0;\n\tif (feederID == FEEDER_REDTEAM_LIST) {\n\t\tfor (i = 0; i < cg.numScores; i++) {\n\t\t\tif (cg.scores[i].team == TEAM_RED) {\n\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t} else if (feederID == FEEDER_BLUETEAM_LIST) {\n\t\tfor (i = 0; i < cg.numScores; i++) {\n\t\t\tif (cg.scores[i].team == TEAM_BLUE) {\n\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t} else if (feederID == FEEDER_SCOREBOARD) {\n\t\treturn cg.numScores;\n\t}\n\treturn count;\n}\n\n\nvoid CG_SetScoreSelection(void *p) {\n\tmenuDef_t *menu = (menuDef_t*)p;\n\tplayerState_t *ps = &cg.snap->ps;\n\tint i, red, blue;\n\tred = blue = 0;\n\tfor (i = 0; i < cg.numScores; i++) {\n\t\tif (cg.scores[i].team == TEAM_RED) {\n\t\t\tred++;\n\t\t} else if (cg.scores[i].team == TEAM_BLUE) {\n\t\t\tblue++;\n\t\t}\n\t\tif (ps->clientNum == cg.scores[i].client) {\n\t\t\tcg.selectedScore = i;\n\t\t}\n\t}\n\n\tif (menu == NULL) {\n\t\t// just interested in setting the selected score\n\t\treturn;\n\t}\n\n\tif ( cgs.gametype >= GT_TEAM ) {\n\t\tint feeder = FEEDER_REDTEAM_LIST;\n\t\ti = red;\n\t\tif (cg.scores[cg.selectedScore].team == TEAM_BLUE) {\n\t\t\tfeeder = FEEDER_BLUETEAM_LIST;\n\t\t\ti = blue;\n\t\t}\n\t\tMenu_SetFeederSelection(menu, feeder, i, NULL);\n\t} else {\n\t\tMenu_SetFeederSelection(menu, FEEDER_SCOREBOARD, cg.selectedScore, NULL);\n\t}\n}\n\n// FIXME: might need to cache this info\nstatic clientInfo_t * CG_InfoFromScoreIndex(int index, int team, int *scoreIndex) {\n\tint i, count;\n\tif ( cgs.gametype >= GT_TEAM ) {\n\t\tcount = 0;\n\t\tfor (i = 0; i < cg.numScores; i++) {\n\t\t\tif (cg.scores[i].team == team) {\n\t\t\t\tif (count == index) {\n\t\t\t\t\t*scoreIndex = i;\n\t\t\t\t\treturn &cgs.clientinfo[cg.scores[i].client];\n\t\t\t\t}\n\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}\n\t*scoreIndex = index;\n\treturn &cgs.clientinfo[ cg.scores[index].client ];\n}\n\nstatic const char *CG_FeederItemText(float feederID, int index, int column, qhandle_t *handle) {\n\tgitem_t *item;\n\tint scoreIndex = 0;\n\tclientInfo_t *info = NULL;\n\tint team = -1;\n\tscore_t *sp = NULL;\n\n\t*handle = -1;\n\n\tif (feederID == FEEDER_REDTEAM_LIST) {\n\t\tteam = TEAM_RED;\n\t} else if (feederID == FEEDER_BLUETEAM_LIST) {\n\t\tteam = TEAM_BLUE;\n\t}\n\n\tinfo = CG_InfoFromScoreIndex(index, team, &scoreIndex);\n\tsp = &cg.scores[scoreIndex];\n\n\tif (info && info->infoValid) {\n\t\tswitch (column) {\n\t\t\tcase 0:\n\t\t\t\tif ( info->powerups & ( 1 << PW_NEUTRALFLAG ) ) {\n\t\t\t\t\titem = BG_FindItemForPowerup( PW_NEUTRALFLAG );\n\t\t\t\t\t*handle = cg_items[ ITEM_INDEX(item) ].icon;\n\t\t\t\t} else if ( info->powerups & ( 1 << PW_REDFLAG ) ) {\n\t\t\t\t\titem = BG_FindItemForPowerup( PW_REDFLAG );\n\t\t\t\t\t*handle = cg_items[ ITEM_INDEX(item) ].icon;\n\t\t\t\t} else if ( info->powerups & ( 1 << PW_BLUEFLAG ) ) {\n\t\t\t\t\titem = BG_FindItemForPowerup( PW_BLUEFLAG );\n\t\t\t\t\t*handle = cg_items[ ITEM_INDEX(item) ].icon;\n\t\t\t\t} else {\n\t\t\t\t\tif ( info->botSkill > 0 && info->botSkill <= 5 ) {\n\t\t\t\t\t\t*handle = cgs.media.botSkillShaders[ info->botSkill - 1 ];\n\t\t\t\t\t} else if ( info->handicap < 100 ) {\n\t\t\t\t\treturn va(\"%i\", info->handicap );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\tif (team == -1) {\n\t\t\t\t\treturn \"\";\n\t\t\t\t} else {\n\t\t\t\t\t*handle = CG_StatusHandle(info->teamTask);\n\t\t\t\t}\n\t\t  break;\n\t\t\tcase 2:\n\t\t\t\tif ( cg.snap->ps.stats[ STAT_CLIENTS_READY ] & ( 1 << sp->client ) ) {\n\t\t\t\t\treturn \"Ready\";\n\t\t\t\t}\n\t\t\t\tif (team == -1) {\n\t\t\t\t\tif (cgs.gametype == GT_TOURNAMENT) {\n\t\t\t\t\t\treturn va(\"%i/%i\", info->wins, info->losses);\n\t\t\t\t\t} else if (info->infoValid && info->team == TEAM_SPECTATOR ) {\n\t\t\t\t\t\treturn \"Spectator\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn \"\";\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (info->teamLeader) {\n\t\t\t\t\t\treturn \"Leader\";\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tbreak;\n\t\t\tcase 3:\n\t\t\t\treturn info->name;\n\t\t\tbreak;\n\t\t\tcase 4:\n\t\t\t\treturn va(\"%i\", info->score);\n\t\t\tbreak;\n\t\t\tcase 5:\n\t\t\t\treturn va(\"%4i\", sp->time);\n\t\t\tbreak;\n\t\t\tcase 6:\n\t\t\t\tif ( sp->ping == -1 ) {\n\t\t\t\t\treturn \"connecting\";\n\t\t\t\t} \n\t\t\t\treturn va(\"%4i\", sp->ping);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn \"\";\n}\n\nstatic qhandle_t CG_FeederItemImage(float feederID, int index) {\n\treturn 0;\n}\n\nstatic void CG_FeederSelection(float feederID, int index) {\n\tif ( cgs.gametype >= GT_TEAM ) {\n\t\tint i, count;\n\t\tint team = (feederID == FEEDER_REDTEAM_LIST) ? TEAM_RED : TEAM_BLUE;\n\t\tcount = 0;\n\t\tfor (i = 0; i < cg.numScores; i++) {\n\t\t\tif (cg.scores[i].team == team) {\n\t\t\t\tif (index == count) {\n\t\t\t\t\tcg.selectedScore = i;\n\t\t\t\t}\n\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tcg.selectedScore = index;\n\t}\n}\n#endif\n\n#ifdef MISSIONPACK // bk001204 - only needed there\nstatic float CG_Cvar_Get(const char *cvar) {\n\tchar buff[128];\n\tmemset(buff, 0, sizeof(buff));\n\ttrap_Cvar_VariableStringBuffer(cvar, buff, sizeof(buff));\n\treturn atof(buff);\n}\n#endif\n\n#ifdef MISSIONPACK\nvoid CG_Text_PaintWithCursor(float x, float y, float scale, vec4_t color, const char *text, int cursorPos, char cursor, int limit, int style) {\n\tCG_Text_Paint(x, y, scale, color, text, 0, limit, style);\n}\n\nstatic int CG_OwnerDrawWidth(int ownerDraw, float scale) {\n\tswitch (ownerDraw) {\n\t  case CG_GAME_TYPE:\n\t\t\treturn CG_Text_Width(CG_GameTypeString(), scale, 0);\n\t  case CG_GAME_STATUS:\n\t\t\treturn CG_Text_Width(CG_GetGameStatusText(), scale, 0);\n\t\t\tbreak;\n\t  case CG_KILLER:\n\t\t\treturn CG_Text_Width(CG_GetKillerText(), scale, 0);\n\t\t\tbreak;\n\t  case CG_RED_NAME:\n\t\t\treturn CG_Text_Width(cg_redTeamName.string, scale, 0);\n\t\t\tbreak;\n\t  case CG_BLUE_NAME:\n\t\t\treturn CG_Text_Width(cg_blueTeamName.string, scale, 0);\n\t\t\tbreak;\n\n\n\t}\n\treturn 0;\n}\n\nstatic int CG_PlayCinematic(const char *name, float x, float y, float w, float h) {\n  return trap_CIN_PlayCinematic(name, x, y, w, h, CIN_loop);\n}\n\nstatic void CG_StopCinematic(int handle) {\n  trap_CIN_StopCinematic(handle);\n}\n\nstatic void CG_DrawCinematic(int handle, float x, float y, float w, float h) {\n  trap_CIN_SetExtents(handle, x, y, w, h);\n  trap_CIN_DrawCinematic(handle);\n}\n\nstatic void CG_RunCinematicFrame(int handle) {\n  trap_CIN_RunCinematic(handle);\n}\n\n/*\n=================\nCG_LoadHudMenu();\n\n=================\n*/\nvoid CG_LoadHudMenu() {\n\tchar buff[1024];\n\tconst char *hudSet;\n\n\tcgDC.registerShaderNoMip = &trap_R_RegisterShaderNoMip;\n\tcgDC.setColor = &trap_R_SetColor;\n\tcgDC.drawHandlePic = &CG_DrawPic;\n\tcgDC.drawStretchPic = &trap_R_DrawStretchPic;\n\tcgDC.drawText = &CG_Text_Paint;\n\tcgDC.textWidth = &CG_Text_Width;\n\tcgDC.textHeight = &CG_Text_Height;\n\tcgDC.registerModel = &trap_R_RegisterModel;\n\tcgDC.modelBounds = &trap_R_ModelBounds;\n\tcgDC.fillRect = &CG_FillRect;\n\tcgDC.drawRect = &CG_DrawRect;   \n\tcgDC.drawSides = &CG_DrawSides;\n\tcgDC.drawTopBottom = &CG_DrawTopBottom;\n\tcgDC.clearScene = &trap_R_ClearScene;\n\tcgDC.addRefEntityToScene = &trap_R_AddRefEntityToScene;\n\tcgDC.renderScene = &trap_R_RenderScene;\n\tcgDC.registerFont = &trap_R_RegisterFont;\n\tcgDC.ownerDrawItem = &CG_OwnerDraw;\n\tcgDC.getValue = &CG_GetValue;\n\tcgDC.ownerDrawVisible = &CG_OwnerDrawVisible;\n\tcgDC.runScript = &CG_RunMenuScript;\n\tcgDC.getTeamColor = &CG_GetTeamColor;\n\tcgDC.setCVar = trap_Cvar_Set;\n\tcgDC.getCVarString = trap_Cvar_VariableStringBuffer;\n\tcgDC.getCVarValue = CG_Cvar_Get;\n\tcgDC.drawTextWithCursor = &CG_Text_PaintWithCursor;\n\t//cgDC.setOverstrikeMode = &trap_Key_SetOverstrikeMode;\n\t//cgDC.getOverstrikeMode = &trap_Key_GetOverstrikeMode;\n\tcgDC.startLocalSound = &trap_S_StartLocalSound;\n\tcgDC.ownerDrawHandleKey = &CG_OwnerDrawHandleKey;\n\tcgDC.feederCount = &CG_FeederCount;\n\tcgDC.feederItemImage = &CG_FeederItemImage;\n\tcgDC.feederItemText = &CG_FeederItemText;\n\tcgDC.feederSelection = &CG_FeederSelection;\n\t//cgDC.setBinding = &trap_Key_SetBinding;\n\t//cgDC.getBindingBuf = &trap_Key_GetBindingBuf;\n\t//cgDC.keynumToStringBuf = &trap_Key_KeynumToStringBuf;\n\t//cgDC.executeText = &trap_Cmd_ExecuteText;\n\tcgDC.Error = &Com_Error; \n\tcgDC.Print = &Com_Printf; \n\tcgDC.ownerDrawWidth = &CG_OwnerDrawWidth;\n\t//cgDC.Pause = &CG_Pause;\n\tcgDC.registerSound = &trap_S_RegisterSound;\n\tcgDC.startBackgroundTrack = &trap_S_StartBackgroundTrack;\n\tcgDC.stopBackgroundTrack = &trap_S_StopBackgroundTrack;\n\tcgDC.playCinematic = &CG_PlayCinematic;\n\tcgDC.stopCinematic = &CG_StopCinematic;\n\tcgDC.drawCinematic = &CG_DrawCinematic;\n\tcgDC.runCinematicFrame = &CG_RunCinematicFrame;\n\t\n\tInit_Display(&cgDC);\n\n\tMenu_Reset();\n\t\n\ttrap_Cvar_VariableStringBuffer(\"cg_hudFiles\", buff, sizeof(buff));\n\thudSet = buff;\n\tif (hudSet[0] == '\\0') {\n\t\thudSet = \"ui/hud.txt\";\n\t}\n\n\tCG_LoadMenus(hudSet);\n}\n\nvoid CG_AssetCache() {\n\t//if (Assets.textFont == NULL) {\n\t//  trap_R_RegisterFont(\"fonts/arial.ttf\", 72, &Assets.textFont);\n\t//}\n\t//Assets.background = trap_R_RegisterShaderNoMip( ASSET_BACKGROUND );\n\t//Com_Printf(\"Menu Size: %i bytes\\n\", sizeof(Menus));\n\tcgDC.Assets.gradientBar = trap_R_RegisterShaderNoMip( ASSET_GRADIENTBAR );\n\tcgDC.Assets.fxBasePic = trap_R_RegisterShaderNoMip( ART_FX_BASE );\n\tcgDC.Assets.fxPic[0] = trap_R_RegisterShaderNoMip( ART_FX_RED );\n\tcgDC.Assets.fxPic[1] = trap_R_RegisterShaderNoMip( ART_FX_YELLOW );\n\tcgDC.Assets.fxPic[2] = trap_R_RegisterShaderNoMip( ART_FX_GREEN );\n\tcgDC.Assets.fxPic[3] = trap_R_RegisterShaderNoMip( ART_FX_TEAL );\n\tcgDC.Assets.fxPic[4] = trap_R_RegisterShaderNoMip( ART_FX_BLUE );\n\tcgDC.Assets.fxPic[5] = trap_R_RegisterShaderNoMip( ART_FX_CYAN );\n\tcgDC.Assets.fxPic[6] = trap_R_RegisterShaderNoMip( ART_FX_WHITE );\n\tcgDC.Assets.scrollBar = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR );\n\tcgDC.Assets.scrollBarArrowDown = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWDOWN );\n\tcgDC.Assets.scrollBarArrowUp = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWUP );\n\tcgDC.Assets.scrollBarArrowLeft = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWLEFT );\n\tcgDC.Assets.scrollBarArrowRight = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWRIGHT );\n\tcgDC.Assets.scrollBarThumb = trap_R_RegisterShaderNoMip( ASSET_SCROLL_THUMB );\n\tcgDC.Assets.sliderBar = trap_R_RegisterShaderNoMip( ASSET_SLIDER_BAR );\n\tcgDC.Assets.sliderThumb = trap_R_RegisterShaderNoMip( ASSET_SLIDER_THUMB );\n}\n#endif\n/*\n=================\nCG_Init\n\nCalled after every level change or subsystem restart\nWill perform callbacks to make the loading info screen update.\n=================\n*/\nvoid CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) {\n\tconst char\t*s;\n\n\t// clear everything\n\tmemset( &cgs, 0, sizeof( cgs ) );\n\tmemset( &cg, 0, sizeof( cg ) );\n\tmemset( cg_entities, 0, sizeof(cg_entities) );\n\tmemset( cg_weapons, 0, sizeof(cg_weapons) );\n\tmemset( cg_items, 0, sizeof(cg_items) );\n\n\tcg.clientNum = clientNum;\n\n\tcgs.processedSnapshotNum = serverMessageNum;\n\tcgs.serverCommandSequence = serverCommandSequence;\n\n\t// load a few needed things before we do any screen updates\n\tcgs.media.charsetShader\t\t= trap_R_RegisterShader( \"gfx/2d/bigchars\" );\n\tcgs.media.whiteShader\t\t= trap_R_RegisterShader( \"white\" );\n\tcgs.media.charsetProp\t\t= trap_R_RegisterShaderNoMip( \"menu/art/font1_prop.tga\" );\n\tcgs.media.charsetPropGlow\t= trap_R_RegisterShaderNoMip( \"menu/art/font1_prop_glo.tga\" );\n\tcgs.media.charsetPropB\t\t= trap_R_RegisterShaderNoMip( \"menu/art/font2_prop.tga\" );\n\n\tCG_RegisterCvars();\n\n\tCG_InitConsoleCommands();\n\n\tcg.weaponSelect = WP_MACHINEGUN;\n\n\tcgs.redflag = cgs.blueflag = -1; // For compatibily, default to unset for\n\tcgs.flagStatus = -1;\n\t// old servers\n\n\t// get the rendering configuration from the client system\n\ttrap_GetGlconfig( &cgs.glconfig );\n\tcgs.screenXScale = cgs.glconfig.vidWidth / 640.0;\n\tcgs.screenYScale = cgs.glconfig.vidHeight / 480.0;\n\n\t// get the gamestate from the client system\n\ttrap_GetGameState( &cgs.gameState );\n\n\t// check version\n\ts = CG_ConfigString( CS_GAME_VERSION );\n\tif ( strcmp( s, GAME_VERSION ) ) {\n\t\tCG_Error( \"Client/Server game mismatch: %s/%s\", GAME_VERSION, s );\n\t}\n\n\ts = CG_ConfigString( CS_LEVEL_START_TIME );\n\tcgs.levelStartTime = atoi( s );\n\n\tCG_ParseServerinfo();\n\n\t// load the new map\n\tCG_LoadingString( \"collision map\" );\n\n\ttrap_CM_LoadMap( cgs.mapname );\n\n#ifdef MISSIONPACK\n\tString_Init();\n#endif\n\n\tcg.loading = qtrue;\t\t// force players to load instead of defer\n\n\tCG_LoadingString( \"sounds\" );\n\n\tCG_RegisterSounds();\n\n\tCG_LoadingString( \"graphics\" );\n\n\tCG_RegisterGraphics();\n\n\tCG_LoadingString( \"clients\" );\n\n\tCG_RegisterClients();\t\t// if low on memory, some clients will be deferred\n\n#ifdef MISSIONPACK\n\tCG_AssetCache();\n\tCG_LoadHudMenu();      // load new hud stuff\n#endif\n\n\tcg.loading = qfalse;\t// future players will be deferred\n\n\tCG_InitLocalEntities();\n\n\tCG_InitMarkPolys();\n\n\t// remove the last loading update\n\tcg.infoScreenText[0] = 0;\n\n\t// Make sure we have update values (scores)\n\tCG_SetConfigValues();\n\n\tCG_StartMusic();\n\n\tCG_LoadingString( \"\" );\n\n#ifdef MISSIONPACK\n\tCG_InitTeamChat();\n#endif\n\n\tCG_ShaderStateChanged();\n\n\ttrap_S_ClearLoopingSounds( qtrue );\n}\n\n/*\n=================\nCG_Shutdown\n\nCalled before every level change or subsystem restart\n=================\n*/\nvoid CG_Shutdown( void ) {\n\t// some mods may need to do cleanup work here,\n\t// like closing files or archiving session data\n}\n\n\n/*\n==================\nCG_EventHandling\n==================\n type 0 - no event handling\n      1 - team menu\n      2 - hud editor\n\n*/\n#ifndef MISSIONPACK\nvoid CG_EventHandling(int type) {\n}\n\n\n\nvoid CG_KeyEvent(int key, qboolean down) {\n}\n\nvoid CG_MouseEvent(int x, int y) {\n}\n#endif\n\n"
  },
  {
    "path": "code/cgame/cg_marks.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// cg_marks.c -- wall marks\n\n#include \"cg_local.h\"\n\n/*\n===================================================================\n\nMARK POLYS\n\n===================================================================\n*/\n\n\nmarkPoly_t\tcg_activeMarkPolys;\t\t\t// double linked list\nmarkPoly_t\t*cg_freeMarkPolys;\t\t\t// single linked list\nmarkPoly_t\tcg_markPolys[MAX_MARK_POLYS];\nstatic\t\tint\tmarkTotal;\n\n/*\n===================\nCG_InitMarkPolys\n\nThis is called at startup and for tournement restarts\n===================\n*/\nvoid\tCG_InitMarkPolys( void ) {\n\tint\t\ti;\n\n\tmemset( cg_markPolys, 0, sizeof(cg_markPolys) );\n\n\tcg_activeMarkPolys.nextMark = &cg_activeMarkPolys;\n\tcg_activeMarkPolys.prevMark = &cg_activeMarkPolys;\n\tcg_freeMarkPolys = cg_markPolys;\n\tfor ( i = 0 ; i < MAX_MARK_POLYS - 1 ; i++ ) {\n\t\tcg_markPolys[i].nextMark = &cg_markPolys[i+1];\n\t}\n}\n\n\n/*\n==================\nCG_FreeMarkPoly\n==================\n*/\nvoid CG_FreeMarkPoly( markPoly_t *le ) {\n\tif ( !le->prevMark ) {\n\t\tCG_Error( \"CG_FreeLocalEntity: not active\" );\n\t}\n\n\t// remove from the doubly linked active list\n\tle->prevMark->nextMark = le->nextMark;\n\tle->nextMark->prevMark = le->prevMark;\n\n\t// the free list is only singly linked\n\tle->nextMark = cg_freeMarkPolys;\n\tcg_freeMarkPolys = le;\n}\n\n/*\n===================\nCG_AllocMark\n\nWill allways succeed, even if it requires freeing an old active mark\n===================\n*/\nmarkPoly_t\t*CG_AllocMark( void ) {\n\tmarkPoly_t\t*le;\n\tint time;\n\n\tif ( !cg_freeMarkPolys ) {\n\t\t// no free entities, so free the one at the end of the chain\n\t\t// remove the oldest active entity\n\t\ttime = cg_activeMarkPolys.prevMark->time;\n\t\twhile (cg_activeMarkPolys.prevMark && time == cg_activeMarkPolys.prevMark->time) {\n\t\t\tCG_FreeMarkPoly( cg_activeMarkPolys.prevMark );\n\t\t}\n\t}\n\n\tle = cg_freeMarkPolys;\n\tcg_freeMarkPolys = cg_freeMarkPolys->nextMark;\n\n\tmemset( le, 0, sizeof( *le ) );\n\n\t// link into the active list\n\tle->nextMark = cg_activeMarkPolys.nextMark;\n\tle->prevMark = &cg_activeMarkPolys;\n\tcg_activeMarkPolys.nextMark->prevMark = le;\n\tcg_activeMarkPolys.nextMark = le;\n\treturn le;\n}\n\n\n\n/*\n=================\nCG_ImpactMark\n\norigin should be a point within a unit of the plane\ndir should be the plane normal\n\ntemporary marks will not be stored or randomly oriented, but immediately\npassed to the renderer.\n=================\n*/\n#define\tMAX_MARK_FRAGMENTS\t128\n#define\tMAX_MARK_POINTS\t\t384\n\nvoid CG_ImpactMark( qhandle_t markShader, const vec3_t origin, const vec3_t dir, \n\t\t\t\t   float orientation, float red, float green, float blue, float alpha,\n\t\t\t\t   qboolean alphaFade, float radius, qboolean temporary ) {\n\tvec3_t\t\t\taxis[3];\n\tfloat\t\t\ttexCoordScale;\n\tvec3_t\t\t\toriginalPoints[4];\n\tbyte\t\t\tcolors[4];\n\tint\t\t\t\ti, j;\n\tint\t\t\t\tnumFragments;\n\tmarkFragment_t\tmarkFragments[MAX_MARK_FRAGMENTS], *mf;\n\tvec3_t\t\t\tmarkPoints[MAX_MARK_POINTS];\n\tvec3_t\t\t\tprojection;\n\n\tif ( !cg_addMarks.integer ) {\n\t\treturn;\n\t}\n\n\tif ( radius <= 0 ) {\n\t\tCG_Error( \"CG_ImpactMark called with <= 0 radius\" );\n\t}\n\n\t//if ( markTotal >= MAX_MARK_POLYS ) {\n\t//\treturn;\n\t//}\n\n\t// create the texture axis\n\tVectorNormalize2( dir, axis[0] );\n\tPerpendicularVector( axis[1], axis[0] );\n\tRotatePointAroundVector( axis[2], axis[0], axis[1], orientation );\n\tCrossProduct( axis[0], axis[2], axis[1] );\n\n\ttexCoordScale = 0.5 * 1.0 / radius;\n\n\t// create the full polygon\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\toriginalPoints[0][i] = origin[i] - radius * axis[1][i] - radius * axis[2][i];\n\t\toriginalPoints[1][i] = origin[i] + radius * axis[1][i] - radius * axis[2][i];\n\t\toriginalPoints[2][i] = origin[i] + radius * axis[1][i] + radius * axis[2][i];\n\t\toriginalPoints[3][i] = origin[i] - radius * axis[1][i] + radius * axis[2][i];\n\t}\n\n\t// get the fragments\n\tVectorScale( dir, -20, projection );\n\tnumFragments = trap_CM_MarkFragments( 4, (void *)originalPoints,\n\t\t\t\t\tprojection, MAX_MARK_POINTS, markPoints[0],\n\t\t\t\t\tMAX_MARK_FRAGMENTS, markFragments );\n\n\tcolors[0] = red * 255;\n\tcolors[1] = green * 255;\n\tcolors[2] = blue * 255;\n\tcolors[3] = alpha * 255;\n\n\tfor ( i = 0, mf = markFragments ; i < numFragments ; i++, mf++ ) {\n\t\tpolyVert_t\t*v;\n\t\tpolyVert_t\tverts[MAX_VERTS_ON_POLY];\n\t\tmarkPoly_t\t*mark;\n\n\t\t// we have an upper limit on the complexity of polygons\n\t\t// that we store persistantly\n\t\tif ( mf->numPoints > MAX_VERTS_ON_POLY ) {\n\t\t\tmf->numPoints = MAX_VERTS_ON_POLY;\n\t\t}\n\t\tfor ( j = 0, v = verts ; j < mf->numPoints ; j++, v++ ) {\n\t\t\tvec3_t\t\tdelta;\n\n\t\t\tVectorCopy( markPoints[mf->firstPoint + j], v->xyz );\n\n\t\t\tVectorSubtract( v->xyz, origin, delta );\n\t\t\tv->st[0] = 0.5 + DotProduct( delta, axis[1] ) * texCoordScale;\n\t\t\tv->st[1] = 0.5 + DotProduct( delta, axis[2] ) * texCoordScale;\n\t\t\t*(int *)v->modulate = *(int *)colors;\n\t\t}\n\n\t\t// if it is a temporary (shadow) mark, add it immediately and forget about it\n\t\tif ( temporary ) {\n\t\t\ttrap_R_AddPolyToScene( markShader, mf->numPoints, verts );\n\t\t\tcontinue;\n\t\t}\n\n\t\t// otherwise save it persistantly\n\t\tmark = CG_AllocMark();\n\t\tmark->time = cg.time;\n\t\tmark->alphaFade = alphaFade;\n\t\tmark->markShader = markShader;\n\t\tmark->poly.numVerts = mf->numPoints;\n\t\tmark->color[0] = red;\n\t\tmark->color[1] = green;\n\t\tmark->color[2] = blue;\n\t\tmark->color[3] = alpha;\n\t\tmemcpy( mark->verts, verts, mf->numPoints * sizeof( verts[0] ) );\n\t\tmarkTotal++;\n\t}\n}\n\n\n/*\n===============\nCG_AddMarks\n===============\n*/\n#define\tMARK_TOTAL_TIME\t\t10000\n#define\tMARK_FADE_TIME\t\t1000\n\nvoid CG_AddMarks( void ) {\n\tint\t\t\tj;\n\tmarkPoly_t\t*mp, *next;\n\tint\t\t\tt;\n\tint\t\t\tfade;\n\n\tif ( !cg_addMarks.integer ) {\n\t\treturn;\n\t}\n\n\tmp = cg_activeMarkPolys.nextMark;\n\tfor ( ; mp != &cg_activeMarkPolys ; mp = next ) {\n\t\t// grab next now, so if the local entity is freed we\n\t\t// still have it\n\t\tnext = mp->nextMark;\n\n\t\t// see if it is time to completely remove it\n\t\tif ( cg.time > mp->time + MARK_TOTAL_TIME ) {\n\t\t\tCG_FreeMarkPoly( mp );\n\t\t\tcontinue;\n\t\t}\n\n\t\t// fade out the energy bursts\n\t\tif ( mp->markShader == cgs.media.energyMarkShader ) {\n\n\t\t\tfade = 450 - 450 * ( (cg.time - mp->time ) / 3000.0 );\n\t\t\tif ( fade < 255 ) {\n\t\t\t\tif ( fade < 0 ) {\n\t\t\t\t\tfade = 0;\n\t\t\t\t}\n\t\t\t\tif ( mp->verts[0].modulate[0] != 0 ) {\n\t\t\t\t\tfor ( j = 0 ; j < mp->poly.numVerts ; j++ ) {\n\t\t\t\t\t\tmp->verts[j].modulate[0] = mp->color[0] * fade;\n\t\t\t\t\t\tmp->verts[j].modulate[1] = mp->color[1] * fade;\n\t\t\t\t\t\tmp->verts[j].modulate[2] = mp->color[2] * fade;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// fade all marks out with time\n\t\tt = mp->time + MARK_TOTAL_TIME - cg.time;\n\t\tif ( t < MARK_FADE_TIME ) {\n\t\t\tfade = 255 * t / MARK_FADE_TIME;\n\t\t\tif ( mp->alphaFade ) {\n\t\t\t\tfor ( j = 0 ; j < mp->poly.numVerts ; j++ ) {\n\t\t\t\t\tmp->verts[j].modulate[3] = fade;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor ( j = 0 ; j < mp->poly.numVerts ; j++ ) {\n\t\t\t\t\tmp->verts[j].modulate[0] = mp->color[0] * fade;\n\t\t\t\t\tmp->verts[j].modulate[1] = mp->color[1] * fade;\n\t\t\t\t\tmp->verts[j].modulate[2] = mp->color[2] * fade;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\n\t\ttrap_R_AddPolyToScene( mp->markShader, mp->poly.numVerts, mp->verts );\n\t}\n}\n\n// cg_particles.c  \n\n#define BLOODRED\t2\n#define EMISIVEFADE\t3\n#define GREY75\t\t4\n\ntypedef struct particle_s\n{\n\tstruct particle_s\t*next;\n\n\tfloat\t\ttime;\n\tfloat\t\tendtime;\n\n\tvec3_t\t\torg;\n\tvec3_t\t\tvel;\n\tvec3_t\t\taccel;\n\tint\t\t\tcolor;\n\tfloat\t\tcolorvel;\n\tfloat\t\talpha;\n\tfloat\t\talphavel;\n\tint\t\t\ttype;\n\tqhandle_t\tpshader;\n\t\n\tfloat\t\theight;\n\tfloat\t\twidth;\n\t\t\t\t\n\tfloat\t\tendheight;\n\tfloat\t\tendwidth;\n\t\n\tfloat\t\tstart;\n\tfloat\t\tend;\n\n\tfloat\t\tstartfade;\n\tqboolean\trotate;\n\tint\t\t\tsnum;\n\t\n\tqboolean\tlink;\n\n\t// Ridah\n\tint\t\t\tshaderAnim;\n\tint\t\t\troll;\n\n\tint\t\t\taccumroll;\n\n} cparticle_t;\n\ntypedef enum\n{\n\tP_NONE,\n\tP_WEATHER,\n\tP_FLAT,\n\tP_SMOKE,\n\tP_ROTATE,\n\tP_WEATHER_TURBULENT,\n\tP_ANIM,\t// Ridah\n\tP_BAT,\n\tP_BLEED,\n\tP_FLAT_SCALEUP,\n\tP_FLAT_SCALEUP_FADE,\n\tP_WEATHER_FLURRY,\n\tP_SMOKE_IMPACT,\n\tP_BUBBLE,\n\tP_BUBBLE_TURBULENT,\n\tP_SPRITE\n} particle_type_t;\n\n#define\tMAX_SHADER_ANIMS\t\t32\n#define\tMAX_SHADER_ANIM_FRAMES\t64\n\nstatic char *shaderAnimNames[MAX_SHADER_ANIMS] = {\n\t\"explode1\",\n\tNULL\n};\nstatic qhandle_t shaderAnims[MAX_SHADER_ANIMS][MAX_SHADER_ANIM_FRAMES];\nstatic int\tshaderAnimCounts[MAX_SHADER_ANIMS] = {\n\t23\n};\nstatic float\tshaderAnimSTRatio[MAX_SHADER_ANIMS] = {\n\t1.0f\n};\nstatic int\tnumShaderAnims;\n// done.\n\n#define\t\tPARTICLE_GRAVITY\t40\n#define\t\tMAX_PARTICLES\t1024\n\ncparticle_t\t*active_particles, *free_particles;\ncparticle_t\tparticles[MAX_PARTICLES];\nint\t\tcl_numparticles = MAX_PARTICLES;\n\nqboolean\t\tinitparticles = qfalse;\nvec3_t\t\t\tpvforward, pvright, pvup;\nvec3_t\t\t\trforward, rright, rup;\n\nfloat\t\t\toldtime;\n\n/*\n===============\nCL_ClearParticles\n===============\n*/\nvoid CG_ClearParticles (void)\n{\n\tint\t\ti;\n\n\tmemset( particles, 0, sizeof(particles) );\n\n\tfree_particles = &particles[0];\n\tactive_particles = NULL;\n\n\tfor (i=0 ;i<cl_numparticles ; i++)\n\t{\n\t\tparticles[i].next = &particles[i+1];\n\t\tparticles[i].type = 0;\n\t}\n\tparticles[cl_numparticles-1].next = NULL;\n\n\toldtime = cg.time;\n\n\t// Ridah, init the shaderAnims\n\tfor (i=0; shaderAnimNames[i]; i++) {\n\t\tint j;\n\n\t\tfor (j=0; j<shaderAnimCounts[i]; j++) {\n\t\t\tshaderAnims[i][j] = trap_R_RegisterShader( va(\"%s%i\", shaderAnimNames[i], j+1) );\n\t\t}\n\t}\n\tnumShaderAnims = i;\n\t// done.\n\n\tinitparticles = qtrue;\n}\n\n\n/*\n=====================\nCG_AddParticleToScene\n=====================\n*/\nvoid CG_AddParticleToScene (cparticle_t *p, vec3_t org, float alpha)\n{\n\n\tvec3_t\t\tpoint;\n\tpolyVert_t\tverts[4];\n\tfloat\t\twidth;\n\tfloat\t\theight;\n\tfloat\t\ttime, time2;\n\tfloat\t\tratio;\n\tfloat\t\tinvratio;\n\tvec3_t\t\tcolor;\n\tpolyVert_t\tTRIverts[3];\n\tvec3_t\t\trright2, rup2;\n\n\tif (p->type == P_WEATHER || p->type == P_WEATHER_TURBULENT || p->type == P_WEATHER_FLURRY\n\t\t|| p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT)\n\t{// create a front facing polygon\n\t\t\t\n\t\tif (p->type != P_WEATHER_FLURRY)\n\t\t{\n\t\t\tif (p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT)\n\t\t\t{\n\t\t\t\tif (org[2] > p->end)\t\t\t\n\t\t\t\t{\t\n\t\t\t\t\tp->time = cg.time;\t\n\t\t\t\t\tVectorCopy (org, p->org); // Ridah, fixes rare snow flakes that flicker on the ground\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tp->org[2] = ( p->start + crandom () * 4 );\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tif (p->type == P_BUBBLE_TURBULENT)\n\t\t\t\t\t{\n\t\t\t\t\t\tp->vel[0] = crandom() * 4;\n\t\t\t\t\t\tp->vel[1] = crandom() * 4;\n\t\t\t\t\t}\n\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (org[2] < p->end)\t\t\t\n\t\t\t\t{\t\n\t\t\t\t\tp->time = cg.time;\t\n\t\t\t\t\tVectorCopy (org, p->org); // Ridah, fixes rare snow flakes that flicker on the ground\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\twhile (p->org[2] < p->end) \n\t\t\t\t\t{\n\t\t\t\t\t\tp->org[2] += (p->start - p->end); \n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tif (p->type == P_WEATHER_TURBULENT)\n\t\t\t\t\t{\n\t\t\t\t\t\tp->vel[0] = crandom() * 16;\n\t\t\t\t\t\tp->vel[1] = crandom() * 16;\n\t\t\t\t\t}\n\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\n\t\t\t// Rafael snow pvs check\n\t\t\tif (!p->link)\n\t\t\t\treturn;\n\n\t\t\tp->alpha = 1;\n\t\t}\n\t\t\n\t\t// Ridah, had to do this or MAX_POLYS is being exceeded in village1.bsp\n\t\tif (Distance( cg.snap->ps.origin, org ) > 1024) {\n\t\t\treturn;\n\t\t}\n\t\t// done.\n\t\n\t\tif (p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT)\n\t\t{\n\t\t\tVectorMA (org, -p->height, pvup, point);\t\n\t\t\tVectorMA (point, -p->width, pvright, point);\t\n\t\t\tVectorCopy (point, verts[0].xyz);\t\n\t\t\tverts[0].st[0] = 0;\t\n\t\t\tverts[0].st[1] = 0;\t\n\t\t\tverts[0].modulate[0] = 255;\t\n\t\t\tverts[0].modulate[1] = 255;\t\n\t\t\tverts[0].modulate[2] = 255;\t\n\t\t\tverts[0].modulate[3] = 255 * p->alpha;\t\n\n\t\t\tVectorMA (org, -p->height, pvup, point);\t\n\t\t\tVectorMA (point, p->width, pvright, point);\t\n\t\t\tVectorCopy (point, verts[1].xyz);\t\n\t\t\tverts[1].st[0] = 0;\t\n\t\t\tverts[1].st[1] = 1;\t\n\t\t\tverts[1].modulate[0] = 255;\t\n\t\t\tverts[1].modulate[1] = 255;\t\n\t\t\tverts[1].modulate[2] = 255;\t\n\t\t\tverts[1].modulate[3] = 255 * p->alpha;\t\n\n\t\t\tVectorMA (org, p->height, pvup, point);\t\n\t\t\tVectorMA (point, p->width, pvright, point);\t\n\t\t\tVectorCopy (point, verts[2].xyz);\t\n\t\t\tverts[2].st[0] = 1;\t\n\t\t\tverts[2].st[1] = 1;\t\n\t\t\tverts[2].modulate[0] = 255;\t\n\t\t\tverts[2].modulate[1] = 255;\t\n\t\t\tverts[2].modulate[2] = 255;\t\n\t\t\tverts[2].modulate[3] = 255 * p->alpha;\t\n\n\t\t\tVectorMA (org, p->height, pvup, point);\t\n\t\t\tVectorMA (point, -p->width, pvright, point);\t\n\t\t\tVectorCopy (point, verts[3].xyz);\t\n\t\t\tverts[3].st[0] = 1;\t\n\t\t\tverts[3].st[1] = 0;\t\n\t\t\tverts[3].modulate[0] = 255;\t\n\t\t\tverts[3].modulate[1] = 255;\t\n\t\t\tverts[3].modulate[2] = 255;\t\n\t\t\tverts[3].modulate[3] = 255 * p->alpha;\t\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVectorMA (org, -p->height, pvup, point);\t\n\t\t\tVectorMA (point, -p->width, pvright, point);\t\n\t\t\tVectorCopy( point, TRIverts[0].xyz );\n\t\t\tTRIverts[0].st[0] = 1;\n\t\t\tTRIverts[0].st[1] = 0;\n\t\t\tTRIverts[0].modulate[0] = 255;\n\t\t\tTRIverts[0].modulate[1] = 255;\n\t\t\tTRIverts[0].modulate[2] = 255;\n\t\t\tTRIverts[0].modulate[3] = 255 * p->alpha;\t\n\n\t\t\tVectorMA (org, p->height, pvup, point);\t\n\t\t\tVectorMA (point, -p->width, pvright, point);\t\n\t\t\tVectorCopy (point, TRIverts[1].xyz);\t\n\t\t\tTRIverts[1].st[0] = 0;\n\t\t\tTRIverts[1].st[1] = 0;\n\t\t\tTRIverts[1].modulate[0] = 255;\n\t\t\tTRIverts[1].modulate[1] = 255;\n\t\t\tTRIverts[1].modulate[2] = 255;\n\t\t\tTRIverts[1].modulate[3] = 255 * p->alpha;\t\n\n\t\t\tVectorMA (org, p->height, pvup, point);\t\n\t\t\tVectorMA (point, p->width, pvright, point);\t\n\t\t\tVectorCopy (point, TRIverts[2].xyz);\t\n\t\t\tTRIverts[2].st[0] = 0;\n\t\t\tTRIverts[2].st[1] = 1;\n\t\t\tTRIverts[2].modulate[0] = 255;\n\t\t\tTRIverts[2].modulate[1] = 255;\n\t\t\tTRIverts[2].modulate[2] = 255;\n\t\t\tTRIverts[2].modulate[3] = 255 * p->alpha;\t\n\t\t}\n\t\n\t}\n\telse if (p->type == P_SPRITE)\n\t{\n\t\tvec3_t\trr, ru;\n\t\tvec3_t\trotate_ang;\n\n\t\tVectorSet (color, 1.0, 1.0, 0.5);\n\t\ttime = cg.time - p->time;\n\t\ttime2 = p->endtime - p->time;\n\t\tratio = time / time2;\n\n\t\twidth = p->width + ( ratio * ( p->endwidth - p->width) );\n\t\theight = p->height + ( ratio * ( p->endheight - p->height) );\n\n\t\tif (p->roll) {\n\t\t\tvectoangles( cg.refdef.viewaxis[0], rotate_ang );\n\t\t\trotate_ang[ROLL] += p->roll;\n\t\t\tAngleVectors ( rotate_ang, NULL, rr, ru);\n\t\t}\n\n\t\tif (p->roll) {\n\t\t\tVectorMA (org, -height, ru, point);\t\n\t\t\tVectorMA (point, -width, rr, point);\t\n\t\t} else {\n\t\t\tVectorMA (org, -height, pvup, point);\t\n\t\t\tVectorMA (point, -width, pvright, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[0].xyz);\t\n\t\tverts[0].st[0] = 0;\t\n\t\tverts[0].st[1] = 0;\t\n\t\tverts[0].modulate[0] = 255;\t\n\t\tverts[0].modulate[1] = 255;\t\n\t\tverts[0].modulate[2] = 255;\t\n\t\tverts[0].modulate[3] = 255;\n\n\t\tif (p->roll) {\n\t\t\tVectorMA (point, 2*height, ru, point);\t\n\t\t} else {\n\t\t\tVectorMA (point, 2*height, pvup, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[1].xyz);\t\n\t\tverts[1].st[0] = 0;\t\n\t\tverts[1].st[1] = 1;\t\n\t\tverts[1].modulate[0] = 255;\t\n\t\tverts[1].modulate[1] = 255;\t\n\t\tverts[1].modulate[2] = 255;\t\n\t\tverts[1].modulate[3] = 255;\t\n\n\t\tif (p->roll) {\n\t\t\tVectorMA (point, 2*width, rr, point);\t\n\t\t} else {\n\t\t\tVectorMA (point, 2*width, pvright, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[2].xyz);\t\n\t\tverts[2].st[0] = 1;\t\n\t\tverts[2].st[1] = 1;\t\n\t\tverts[2].modulate[0] = 255;\t\n\t\tverts[2].modulate[1] = 255;\t\n\t\tverts[2].modulate[2] = 255;\t\n\t\tverts[2].modulate[3] = 255;\t\n\n\t\tif (p->roll) {\n\t\t\tVectorMA (point, -2*height, ru, point);\t\n\t\t} else {\n\t\t\tVectorMA (point, -2*height, pvup, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[3].xyz);\t\n\t\tverts[3].st[0] = 1;\t\n\t\tverts[3].st[1] = 0;\t\n\t\tverts[3].modulate[0] = 255;\t\n\t\tverts[3].modulate[1] = 255;\t\n\t\tverts[3].modulate[2] = 255;\t\n\t\tverts[3].modulate[3] = 255;\t\n\t}\n\telse if (p->type == P_SMOKE || p->type == P_SMOKE_IMPACT)\n\t{// create a front rotating facing polygon\n\n\t\tif ( p->type == P_SMOKE_IMPACT && Distance( cg.snap->ps.origin, org ) > 1024) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (p->color == BLOODRED)\n\t\t\tVectorSet (color, 0.22f, 0.0f, 0.0f);\n\t\telse if (p->color == GREY75)\n\t\t{\n\t\t\tfloat\tlen;\n\t\t\tfloat\tgreyit;\n\t\t\tfloat\tval;\n\t\t\tlen = Distance (cg.snap->ps.origin, org);\n\t\t\tif (!len)\n\t\t\t\tlen = 1;\n\n\t\t\tval = 4096/len;\n\t\t\tgreyit = 0.25 * val;\n\t\t\tif (greyit > 0.5)\n\t\t\t\tgreyit = 0.5;\n\n\t\t\tVectorSet (color, greyit, greyit, greyit);\n\t\t}\n\t\telse\n\t\t\tVectorSet (color, 1.0, 1.0, 1.0);\n\n\t\ttime = cg.time - p->time;\n\t\ttime2 = p->endtime - p->time;\n\t\tratio = time / time2;\n\t\t\n\t\tif (cg.time > p->startfade)\n\t\t{\n\t\t\tinvratio = 1 - ( (cg.time - p->startfade) / (p->endtime - p->startfade) );\n\n\t\t\tif (p->color == EMISIVEFADE)\n\t\t\t{\n\t\t\t\tfloat fval;\n\t\t\t\tfval = (invratio * invratio);\n\t\t\t\tif (fval < 0)\n\t\t\t\t\tfval = 0;\n\t\t\t\tVectorSet (color, fval , fval , fval );\n\t\t\t}\n\t\t\tinvratio *= p->alpha;\n\t\t}\n\t\telse \n\t\t\tinvratio = 1 * p->alpha;\n\n\t\tif ( cgs.glconfig.hardwareType == GLHW_RAGEPRO )\n\t\t\tinvratio = 1;\n\n\t\tif (invratio > 1)\n\t\t\tinvratio = 1;\n\t\n\t\twidth = p->width + ( ratio * ( p->endwidth - p->width) );\n\t\theight = p->height + ( ratio * ( p->endheight - p->height) );\n\n\t\tif (p->type != P_SMOKE_IMPACT)\n\t\t{\n\t\t\tvec3_t temp;\n\n\t\t\tvectoangles (rforward, temp);\n\t\t\tp->accumroll += p->roll;\n\t\t\ttemp[ROLL] += p->accumroll * 0.1;\n\t\t\tAngleVectors ( temp, NULL, rright2, rup2);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVectorCopy (rright, rright2);\n\t\t\tVectorCopy (rup, rup2);\n\t\t}\n\t\t\n\t\tif (p->rotate)\n\t\t{\n\t\t\tVectorMA (org, -height, rup2, point);\t\n\t\t\tVectorMA (point, -width, rright2, point);\t\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVectorMA (org, -p->height, pvup, point);\t\n\t\t\tVectorMA (point, -p->width, pvright, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[0].xyz);\t\n\t\tverts[0].st[0] = 0;\t\n\t\tverts[0].st[1] = 0;\t\n\t\tverts[0].modulate[0] = 255 * color[0];\t\n\t\tverts[0].modulate[1] = 255 * color[1];\t\n\t\tverts[0].modulate[2] = 255 * color[2];\t\n\t\tverts[0].modulate[3] = 255 * invratio;\t\n\n\t\tif (p->rotate)\n\t\t{\n\t\t\tVectorMA (org, -height, rup2, point);\t\n\t\t\tVectorMA (point, width, rright2, point);\t\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVectorMA (org, -p->height, pvup, point);\t\n\t\t\tVectorMA (point, p->width, pvright, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[1].xyz);\t\n\t\tverts[1].st[0] = 0;\t\n\t\tverts[1].st[1] = 1;\t\n\t\tverts[1].modulate[0] = 255 * color[0];\t\n\t\tverts[1].modulate[1] = 255 * color[1];\t\n\t\tverts[1].modulate[2] = 255 * color[2];\t\n\t\tverts[1].modulate[3] = 255 * invratio;\t\n\n\t\tif (p->rotate)\n\t\t{\n\t\t\tVectorMA (org, height, rup2, point);\t\n\t\t\tVectorMA (point, width, rright2, point);\t\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVectorMA (org, p->height, pvup, point);\t\n\t\t\tVectorMA (point, p->width, pvright, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[2].xyz);\t\n\t\tverts[2].st[0] = 1;\t\n\t\tverts[2].st[1] = 1;\t\n\t\tverts[2].modulate[0] = 255 * color[0];\t\n\t\tverts[2].modulate[1] = 255 * color[1];\t\n\t\tverts[2].modulate[2] = 255 * color[2];\t\n\t\tverts[2].modulate[3] = 255 * invratio;\t\n\n\t\tif (p->rotate)\n\t\t{\n\t\t\tVectorMA (org, height, rup2, point);\t\n\t\t\tVectorMA (point, -width, rright2, point);\t\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVectorMA (org, p->height, pvup, point);\t\n\t\t\tVectorMA (point, -p->width, pvright, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[3].xyz);\t\n\t\tverts[3].st[0] = 1;\t\n\t\tverts[3].st[1] = 0;\t\n\t\tverts[3].modulate[0] = 255 * color[0];\t\n\t\tverts[3].modulate[1] = 255 * color[1];\t\n\t\tverts[3].modulate[2] = 255 * color[2];\t\n\t\tverts[3].modulate[3] = 255  * invratio;\t\n\t\t\n\t}\n\telse if (p->type == P_BLEED)\n\t{\n\t\tvec3_t\trr, ru;\n\t\tvec3_t\trotate_ang;\n\t\tfloat\talpha;\n\n\t\talpha = p->alpha;\n\t\t\n\t\tif ( cgs.glconfig.hardwareType == GLHW_RAGEPRO )\n\t\t\talpha = 1;\n\n\t\tif (p->roll) \n\t\t{\n\t\t\tvectoangles( cg.refdef.viewaxis[0], rotate_ang );\n\t\t\trotate_ang[ROLL] += p->roll;\n\t\t\tAngleVectors ( rotate_ang, NULL, rr, ru);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVectorCopy (pvup, ru);\n\t\t\tVectorCopy (pvright, rr);\n\t\t}\n\n\t\tVectorMA (org, -p->height, ru, point);\t\n\t\tVectorMA (point, -p->width, rr, point);\t\n\t\tVectorCopy (point, verts[0].xyz);\t\n\t\tverts[0].st[0] = 0;\t\n\t\tverts[0].st[1] = 0;\t\n\t\tverts[0].modulate[0] = 111;\t\n\t\tverts[0].modulate[1] = 19;\t\n\t\tverts[0].modulate[2] = 9;\t\n\t\tverts[0].modulate[3] = 255 * alpha;\t\n\n\t\tVectorMA (org, -p->height, ru, point);\t\n\t\tVectorMA (point, p->width, rr, point);\t\n\t\tVectorCopy (point, verts[1].xyz);\t\n\t\tverts[1].st[0] = 0;\t\n\t\tverts[1].st[1] = 1;\t\n\t\tverts[1].modulate[0] = 111;\t\n\t\tverts[1].modulate[1] = 19;\t\n\t\tverts[1].modulate[2] = 9;\t\n\t\tverts[1].modulate[3] = 255 * alpha;\t\n\n\t\tVectorMA (org, p->height, ru, point);\t\n\t\tVectorMA (point, p->width, rr, point);\t\n\t\tVectorCopy (point, verts[2].xyz);\t\n\t\tverts[2].st[0] = 1;\t\n\t\tverts[2].st[1] = 1;\t\n\t\tverts[2].modulate[0] = 111;\t\n\t\tverts[2].modulate[1] = 19;\t\n\t\tverts[2].modulate[2] = 9;\t\n\t\tverts[2].modulate[3] = 255 * alpha;\t\n\n\t\tVectorMA (org, p->height, ru, point);\t\n\t\tVectorMA (point, -p->width, rr, point);\t\n\t\tVectorCopy (point, verts[3].xyz);\t\n\t\tverts[3].st[0] = 1;\t\n\t\tverts[3].st[1] = 0;\t\n\t\tverts[3].modulate[0] = 111;\t\n\t\tverts[3].modulate[1] = 19;\t\n\t\tverts[3].modulate[2] = 9;\t\n\t\tverts[3].modulate[3] = 255 * alpha;\t\n\n\t}\n\telse if (p->type == P_FLAT_SCALEUP)\n\t{\n\t\tfloat width, height;\n\t\tfloat sinR, cosR;\n\n\t\tif (p->color == BLOODRED)\n\t\t\tVectorSet (color, 1, 1, 1);\n\t\telse\n\t\t\tVectorSet (color, 0.5, 0.5, 0.5);\n\t\t\n\t\ttime = cg.time - p->time;\n\t\ttime2 = p->endtime - p->time;\n\t\tratio = time / time2;\n\n\t\twidth = p->width + ( ratio * ( p->endwidth - p->width) );\n\t\theight = p->height + ( ratio * ( p->endheight - p->height) );\n\n\t\tif (width > p->endwidth)\n\t\t\twidth = p->endwidth;\n\n\t\tif (height > p->endheight)\n\t\t\theight = p->endheight;\n\n\t\tsinR = height * sin(DEG2RAD(p->roll)) * sqrt(2);\n\t\tcosR = width * cos(DEG2RAD(p->roll)) * sqrt(2);\n\n\t\tVectorCopy (org, verts[0].xyz);\t\n\t\tverts[0].xyz[0] -= sinR;\n\t\tverts[0].xyz[1] -= cosR;\n\t\tverts[0].st[0] = 0;\t\n\t\tverts[0].st[1] = 0;\t\n\t\tverts[0].modulate[0] = 255 * color[0];\t\n\t\tverts[0].modulate[1] = 255 * color[1];\t\n\t\tverts[0].modulate[2] = 255 * color[2];\t\n\t\tverts[0].modulate[3] = 255;\t\n\n\t\tVectorCopy (org, verts[1].xyz);\t\n\t\tverts[1].xyz[0] -= cosR;\t\n\t\tverts[1].xyz[1] += sinR;\t\n\t\tverts[1].st[0] = 0;\t\n\t\tverts[1].st[1] = 1;\t\n\t\tverts[1].modulate[0] = 255 * color[0];\t\n\t\tverts[1].modulate[1] = 255 * color[1];\t\n\t\tverts[1].modulate[2] = 255 * color[2];\t\n\t\tverts[1].modulate[3] = 255;\t\n\n\t\tVectorCopy (org, verts[2].xyz);\t\n\t\tverts[2].xyz[0] += sinR;\t\n\t\tverts[2].xyz[1] += cosR;\t\n\t\tverts[2].st[0] = 1;\t\n\t\tverts[2].st[1] = 1;\t\n\t\tverts[2].modulate[0] = 255 * color[0];\t\n\t\tverts[2].modulate[1] = 255 * color[1];\t\n\t\tverts[2].modulate[2] = 255 * color[2];\t\n\t\tverts[2].modulate[3] = 255;\t\n\n\t\tVectorCopy (org, verts[3].xyz);\t\n\t\tverts[3].xyz[0] += cosR;\t\n\t\tverts[3].xyz[1] -= sinR;\t\n\t\tverts[3].st[0] = 1;\t\n\t\tverts[3].st[1] = 0;\t\n\t\tverts[3].modulate[0] = 255 * color[0];\t\n\t\tverts[3].modulate[1] = 255 * color[1];\t\n\t\tverts[3].modulate[2] = 255 * color[2];\t\n\t\tverts[3].modulate[3] = 255;\t\t\n\t}\n\telse if (p->type == P_FLAT)\n\t{\n\n\t\tVectorCopy (org, verts[0].xyz);\t\n\t\tverts[0].xyz[0] -= p->height;\t\n\t\tverts[0].xyz[1] -= p->width;\t\n\t\tverts[0].st[0] = 0;\t\n\t\tverts[0].st[1] = 0;\t\n\t\tverts[0].modulate[0] = 255;\t\n\t\tverts[0].modulate[1] = 255;\t\n\t\tverts[0].modulate[2] = 255;\t\n\t\tverts[0].modulate[3] = 255;\t\n\n\t\tVectorCopy (org, verts[1].xyz);\t\n\t\tverts[1].xyz[0] -= p->height;\t\n\t\tverts[1].xyz[1] += p->width;\t\n\t\tverts[1].st[0] = 0;\t\n\t\tverts[1].st[1] = 1;\t\n\t\tverts[1].modulate[0] = 255;\t\n\t\tverts[1].modulate[1] = 255;\t\n\t\tverts[1].modulate[2] = 255;\t\n\t\tverts[1].modulate[3] = 255;\t\n\n\t\tVectorCopy (org, verts[2].xyz);\t\n\t\tverts[2].xyz[0] += p->height;\t\n\t\tverts[2].xyz[1] += p->width;\t\n\t\tverts[2].st[0] = 1;\t\n\t\tverts[2].st[1] = 1;\t\n\t\tverts[2].modulate[0] = 255;\t\n\t\tverts[2].modulate[1] = 255;\t\n\t\tverts[2].modulate[2] = 255;\t\n\t\tverts[2].modulate[3] = 255;\t\n\n\t\tVectorCopy (org, verts[3].xyz);\t\n\t\tverts[3].xyz[0] += p->height;\t\n\t\tverts[3].xyz[1] -= p->width;\t\n\t\tverts[3].st[0] = 1;\t\n\t\tverts[3].st[1] = 0;\t\n\t\tverts[3].modulate[0] = 255;\t\n\t\tverts[3].modulate[1] = 255;\t\n\t\tverts[3].modulate[2] = 255;\t\n\t\tverts[3].modulate[3] = 255;\t\n\n\t}\n\t// Ridah\n\telse if (p->type == P_ANIM) {\n\t\tvec3_t\trr, ru;\n\t\tvec3_t\trotate_ang;\n\t\tint i, j;\n\n\t\ttime = cg.time - p->time;\n\t\ttime2 = p->endtime - p->time;\n\t\tratio = time / time2;\n\t\tif (ratio >= 1.0f) {\n\t\t\tratio = 0.9999f;\n\t\t}\n\n\t\twidth = p->width + ( ratio * ( p->endwidth - p->width) );\n\t\theight = p->height + ( ratio * ( p->endheight - p->height) );\n\n\t\t// if we are \"inside\" this sprite, don't draw\n\t\tif (Distance( cg.snap->ps.origin, org ) < width/1.5) {\n\t\t\treturn;\n\t\t}\n\n\t\ti = p->shaderAnim;\n\t\tj = (int)floor(ratio * shaderAnimCounts[p->shaderAnim]);\n\t\tp->pshader = shaderAnims[i][j];\n\n\t\tif (p->roll) {\n\t\t\tvectoangles( cg.refdef.viewaxis[0], rotate_ang );\n\t\t\trotate_ang[ROLL] += p->roll;\n\t\t\tAngleVectors ( rotate_ang, NULL, rr, ru);\n\t\t}\n\n\t\tif (p->roll) {\n\t\t\tVectorMA (org, -height, ru, point);\t\n\t\t\tVectorMA (point, -width, rr, point);\t\n\t\t} else {\n\t\t\tVectorMA (org, -height, pvup, point);\t\n\t\t\tVectorMA (point, -width, pvright, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[0].xyz);\t\n\t\tverts[0].st[0] = 0;\t\n\t\tverts[0].st[1] = 0;\t\n\t\tverts[0].modulate[0] = 255;\t\n\t\tverts[0].modulate[1] = 255;\t\n\t\tverts[0].modulate[2] = 255;\t\n\t\tverts[0].modulate[3] = 255;\n\n\t\tif (p->roll) {\n\t\t\tVectorMA (point, 2*height, ru, point);\t\n\t\t} else {\n\t\t\tVectorMA (point, 2*height, pvup, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[1].xyz);\t\n\t\tverts[1].st[0] = 0;\t\n\t\tverts[1].st[1] = 1;\t\n\t\tverts[1].modulate[0] = 255;\t\n\t\tverts[1].modulate[1] = 255;\t\n\t\tverts[1].modulate[2] = 255;\t\n\t\tverts[1].modulate[3] = 255;\t\n\n\t\tif (p->roll) {\n\t\t\tVectorMA (point, 2*width, rr, point);\t\n\t\t} else {\n\t\t\tVectorMA (point, 2*width, pvright, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[2].xyz);\t\n\t\tverts[2].st[0] = 1;\t\n\t\tverts[2].st[1] = 1;\t\n\t\tverts[2].modulate[0] = 255;\t\n\t\tverts[2].modulate[1] = 255;\t\n\t\tverts[2].modulate[2] = 255;\t\n\t\tverts[2].modulate[3] = 255;\t\n\n\t\tif (p->roll) {\n\t\t\tVectorMA (point, -2*height, ru, point);\t\n\t\t} else {\n\t\t\tVectorMA (point, -2*height, pvup, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[3].xyz);\t\n\t\tverts[3].st[0] = 1;\t\n\t\tverts[3].st[1] = 0;\t\n\t\tverts[3].modulate[0] = 255;\t\n\t\tverts[3].modulate[1] = 255;\t\n\t\tverts[3].modulate[2] = 255;\t\n\t\tverts[3].modulate[3] = 255;\t\n\t}\n\t// done.\n\t\n\tif (!p->pshader) {\n// (SA) temp commented out for DM\n//\t\tCG_Printf (\"CG_AddParticleToScene type %d p->pshader == ZERO\\n\", p->type);\n\t\treturn;\n\t}\n\n\tif (p->type == P_WEATHER || p->type == P_WEATHER_TURBULENT || p->type == P_WEATHER_FLURRY)\n\t\ttrap_R_AddPolyToScene( p->pshader, 3, TRIverts );\n\telse\n\t\ttrap_R_AddPolyToScene( p->pshader, 4, verts );\n\n}\n\n// Ridah, made this static so it doesn't interfere with other files\nstatic float roll = 0.0;\n\n/*\n===============\nCG_AddParticles\n===============\n*/\nvoid CG_AddParticles (void)\n{\n\tcparticle_t\t\t*p, *next;\n\tfloat\t\t\talpha;\n\tfloat\t\t\ttime, time2;\n\tvec3_t\t\t\torg;\n\tint\t\t\t\tcolor;\n\tcparticle_t\t\t*active, *tail;\n\tint\t\t\t\ttype;\n\tvec3_t\t\t\trotate_ang;\n\n\tif (!initparticles)\n\t\tCG_ClearParticles ();\n\n\tVectorCopy( cg.refdef.viewaxis[0], pvforward );\n\tVectorCopy( cg.refdef.viewaxis[1], pvright );\n\tVectorCopy( cg.refdef.viewaxis[2], pvup );\n\n\tvectoangles( cg.refdef.viewaxis[0], rotate_ang );\n\troll += ((cg.time - oldtime) * 0.1) ;\n\trotate_ang[ROLL] += (roll*0.9);\n\tAngleVectors ( rotate_ang, rforward, rright, rup);\n\t\n\toldtime = cg.time;\n\n\tactive = NULL;\n\ttail = NULL;\n\n\tfor (p=active_particles ; p ; p=next)\n\t{\n\n\t\tnext = p->next;\n\n\t\ttime = (cg.time - p->time)*0.001;\n\n\t\talpha = p->alpha + time*p->alphavel;\n\t\tif (alpha <= 0)\n\t\t{\t// faded out\n\t\t\tp->next = free_particles;\n\t\t\tfree_particles = p;\n\t\t\tp->type = 0;\n\t\t\tp->color = 0;\n\t\t\tp->alpha = 0;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (p->type == P_SMOKE || p->type == P_ANIM || p->type == P_BLEED || p->type == P_SMOKE_IMPACT)\n\t\t{\n\t\t\tif (cg.time > p->endtime)\n\t\t\t{\n\t\t\t\tp->next = free_particles;\n\t\t\t\tfree_particles = p;\n\t\t\t\tp->type = 0;\n\t\t\t\tp->color = 0;\n\t\t\t\tp->alpha = 0;\n\t\t\t\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t}\n\n\t\tif (p->type == P_WEATHER_FLURRY)\n\t\t{\n\t\t\tif (cg.time > p->endtime)\n\t\t\t{\n\t\t\t\tp->next = free_particles;\n\t\t\t\tfree_particles = p;\n\t\t\t\tp->type = 0;\n\t\t\t\tp->color = 0;\n\t\t\t\tp->alpha = 0;\n\t\t\t\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\n\t\tif (p->type == P_FLAT_SCALEUP_FADE)\n\t\t{\n\t\t\tif (cg.time > p->endtime)\n\t\t\t{\n\t\t\t\tp->next = free_particles;\n\t\t\t\tfree_particles = p;\n\t\t\t\tp->type = 0;\n\t\t\t\tp->color = 0;\n\t\t\t\tp->alpha = 0;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t}\n\n\t\tif ((p->type == P_BAT || p->type == P_SPRITE) && p->endtime < 0) {\n\t\t\t// temporary sprite\n\t\t\tCG_AddParticleToScene (p, p->org, alpha);\n\t\t\tp->next = free_particles;\n\t\t\tfree_particles = p;\n\t\t\tp->type = 0;\n\t\t\tp->color = 0;\n\t\t\tp->alpha = 0;\n\t\t\tcontinue;\n\t\t}\n\n\t\tp->next = NULL;\n\t\tif (!tail)\n\t\t\tactive = tail = p;\n\t\telse\n\t\t{\n\t\t\ttail->next = p;\n\t\t\ttail = p;\n\t\t}\n\n\t\tif (alpha > 1.0)\n\t\t\talpha = 1;\n\n\t\tcolor = p->color;\n\n\t\ttime2 = time*time;\n\n\t\torg[0] = p->org[0] + p->vel[0]*time + p->accel[0]*time2;\n\t\torg[1] = p->org[1] + p->vel[1]*time + p->accel[1]*time2;\n\t\torg[2] = p->org[2] + p->vel[2]*time + p->accel[2]*time2;\n\n\t\ttype = p->type;\n\n\t\tCG_AddParticleToScene (p, org, alpha);\n\t}\n\n\tactive_particles = active;\n}\n\n/*\n======================\nCG_AddParticles\n======================\n*/\nvoid CG_ParticleSnowFlurry (qhandle_t pshader, centity_t *cent)\n{\n\tcparticle_t\t*p;\n\tqboolean turb = qtrue;\n\n\tif (!pshader)\n\t\tCG_Printf (\"CG_ParticleSnowFlurry pshader == ZERO!\\n\");\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\tp->color = 0;\n\tp->alpha = 0.90f;\n\tp->alphavel = 0;\n\n\tp->start = cent->currentState.origin2[0];\n\tp->end = cent->currentState.origin2[1];\n\t\n\tp->endtime = cg.time + cent->currentState.time;\n\tp->startfade = cg.time + cent->currentState.time2;\n\t\n\tp->pshader = pshader;\n\t\n\tif (rand()%100 > 90)\n\t{\n\t\tp->height = 32;\n\t\tp->width = 32;\n\t\tp->alpha = 0.10f;\n\t}\n\telse\n\t{\n\t\tp->height = 1;\n\t\tp->width = 1;\n\t}\n\n\tp->vel[2] = -20;\n\n\tp->type = P_WEATHER_FLURRY;\n\t\n\tif (turb)\n\t\tp->vel[2] = -10;\n\t\n\tVectorCopy(cent->currentState.origin, p->org);\n\n\tp->org[0] = p->org[0];\n\tp->org[1] = p->org[1];\n\tp->org[2] = p->org[2];\n\n\tp->vel[0] = p->vel[1] = 0;\n\t\n\tp->accel[0] = p->accel[1] = p->accel[2] = 0;\n\n\tp->vel[0] += cent->currentState.angles[0] * 32 + (crandom() * 16);\n\tp->vel[1] += cent->currentState.angles[1] * 32 + (crandom() * 16);\n\tp->vel[2] += cent->currentState.angles[2];\n\n\tif (turb)\n\t{\n\t\tp->accel[0] = crandom () * 16;\n\t\tp->accel[1] = crandom () * 16;\n\t}\n\n}\n\nvoid CG_ParticleSnow (qhandle_t pshader, vec3_t origin, vec3_t origin2, int turb, float range, int snum)\n{\n\tcparticle_t\t*p;\n\n\tif (!pshader)\n\t\tCG_Printf (\"CG_ParticleSnow pshader == ZERO!\\n\");\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\tp->color = 0;\n\tp->alpha = 0.40f;\n\tp->alphavel = 0;\n\tp->start = origin[2];\n\tp->end = origin2[2];\n\tp->pshader = pshader;\n\tp->height = 1;\n\tp->width = 1;\n\t\n\tp->vel[2] = -50;\n\n\tif (turb)\n\t{\n\t\tp->type = P_WEATHER_TURBULENT;\n\t\tp->vel[2] = -50 * 1.3;\n\t}\n\telse\n\t{\n\t\tp->type = P_WEATHER;\n\t}\n\t\n\tVectorCopy(origin, p->org);\n\n\tp->org[0] = p->org[0] + ( crandom() * range);\n\tp->org[1] = p->org[1] + ( crandom() * range);\n\tp->org[2] = p->org[2] + ( crandom() * (p->start - p->end)); \n\n\tp->vel[0] = p->vel[1] = 0;\n\t\n\tp->accel[0] = p->accel[1] = p->accel[2] = 0;\n\n\tif (turb)\n\t{\n\t\tp->vel[0] = crandom() * 16;\n\t\tp->vel[1] = crandom() * 16;\n\t}\n\n\t// Rafael snow pvs check\n\tp->snum = snum;\n\tp->link = qtrue;\n\n}\n\nvoid CG_ParticleBubble (qhandle_t pshader, vec3_t origin, vec3_t origin2, int turb, float range, int snum)\n{\n\tcparticle_t\t*p;\n\tfloat\t\trandsize;\n\n\tif (!pshader)\n\t\tCG_Printf (\"CG_ParticleSnow pshader == ZERO!\\n\");\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\tp->color = 0;\n\tp->alpha = 0.40f;\n\tp->alphavel = 0;\n\tp->start = origin[2];\n\tp->end = origin2[2];\n\tp->pshader = pshader;\n\t\n\trandsize = 1 + (crandom() * 0.5);\n\t\n\tp->height = randsize;\n\tp->width = randsize;\n\t\n\tp->vel[2] = 50 + ( crandom() * 10 );\n\n\tif (turb)\n\t{\n\t\tp->type = P_BUBBLE_TURBULENT;\n\t\tp->vel[2] = 50 * 1.3;\n\t}\n\telse\n\t{\n\t\tp->type = P_BUBBLE;\n\t}\n\t\n\tVectorCopy(origin, p->org);\n\n\tp->org[0] = p->org[0] + ( crandom() * range);\n\tp->org[1] = p->org[1] + ( crandom() * range);\n\tp->org[2] = p->org[2] + ( crandom() * (p->start - p->end)); \n\n\tp->vel[0] = p->vel[1] = 0;\n\t\n\tp->accel[0] = p->accel[1] = p->accel[2] = 0;\n\n\tif (turb)\n\t{\n\t\tp->vel[0] = crandom() * 4;\n\t\tp->vel[1] = crandom() * 4;\n\t}\n\n\t// Rafael snow pvs check\n\tp->snum = snum;\n\tp->link = qtrue;\n\n}\n\nvoid CG_ParticleSmoke (qhandle_t pshader, centity_t *cent)\n{\n\n\t// using cent->density = enttime\n\t//\t\t cent->frame = startfade\n\tcparticle_t\t*p;\n\n\tif (!pshader)\n\t\tCG_Printf (\"CG_ParticleSmoke == ZERO!\\n\");\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\t\n\tp->endtime = cg.time + cent->currentState.time;\n\tp->startfade = cg.time + cent->currentState.time2;\n\t\n\tp->color = 0;\n\tp->alpha = 1.0;\n\tp->alphavel = 0;\n\tp->start = cent->currentState.origin[2];\n\tp->end = cent->currentState.origin2[2];\n\tp->pshader = pshader;\n\tp->rotate = qfalse;\n\tp->height = 8;\n\tp->width = 8;\n\tp->endheight = 32;\n\tp->endwidth = 32;\n\tp->type = P_SMOKE;\n\t\n\tVectorCopy(cent->currentState.origin, p->org);\n\n\tp->vel[0] = p->vel[1] = 0;\n\tp->accel[0] = p->accel[1] = p->accel[2] = 0;\n\n\tp->vel[2] = 5;\n\n\tif (cent->currentState.frame == 1)// reverse gravity\t\n\t\tp->vel[2] *= -1;\n\n\tp->roll = 8 + (crandom() * 4);\n}\n\n\nvoid CG_ParticleBulletDebris (vec3_t org, vec3_t vel, int duration)\n{\n\n\tcparticle_t\t*p;\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\t\n\tp->endtime = cg.time + duration;\n\tp->startfade = cg.time + duration/2;\n\t\n\tp->color = EMISIVEFADE;\n\tp->alpha = 1.0;\n\tp->alphavel = 0;\n\n\tp->height = 0.5;\n\tp->width = 0.5;\n\tp->endheight = 0.5;\n\tp->endwidth = 0.5;\n\n\tp->pshader = cgs.media.tracerShader;\n\n\tp->type = P_SMOKE;\n\t\n\tVectorCopy(org, p->org);\n\n\tp->vel[0] = vel[0];\n\tp->vel[1] = vel[1];\n\tp->vel[2] = vel[2];\n\tp->accel[0] = p->accel[1] = p->accel[2] = 0;\n\n\tp->accel[2] = -60;\n\tp->vel[2] += -20;\n\t\n}\n\n/*\n======================\nCG_ParticleExplosion\n======================\n*/\n\nvoid CG_ParticleExplosion (char *animStr, vec3_t origin, vec3_t vel, int duration, int sizeStart, int sizeEnd)\n{\n\tcparticle_t\t*p;\n\tint anim;\n\n\tif (animStr < (char *)10)\n\t\tCG_Error( \"CG_ParticleExplosion: animStr is probably an index rather than a string\" );\n\n\t// find the animation string\n\tfor (anim=0; shaderAnimNames[anim]; anim++) {\n\t\tif (!Q_stricmp( animStr, shaderAnimNames[anim] ))\n\t\t\tbreak;\n\t}\n\tif (!shaderAnimNames[anim]) {\n\t\tCG_Error(\"CG_ParticleExplosion: unknown animation string: %s\\n\", animStr);\n\t\treturn;\n\t}\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\tp->alpha = 0.5;\n\tp->alphavel = 0;\n\n\tif (duration < 0) {\n\t\tduration *= -1;\n\t\tp->roll = 0;\n\t} else {\n\t\tp->roll = crandom()*179;\n\t}\n\n\tp->shaderAnim = anim;\n\n\tp->width = sizeStart;\n\tp->height = sizeStart*shaderAnimSTRatio[anim];\t// for sprites that are stretch in either direction\n\n\tp->endheight = sizeEnd;\n\tp->endwidth = sizeEnd*shaderAnimSTRatio[anim];\n\n\tp->endtime = cg.time + duration;\n\n\tp->type = P_ANIM;\n\n\tVectorCopy( origin, p->org );\n\tVectorCopy( vel, p->vel );\n\tVectorClear( p->accel );\n\n}\n\n// Rafael Shrapnel\nvoid CG_AddParticleShrapnel (localEntity_t *le)\n{\n\treturn;\n}\n// done.\n\nint CG_NewParticleArea (int num)\n{\n\t// const char *str;\n\tchar *str;\n\tchar *token;\n\tint type;\n\tvec3_t origin, origin2;\n\tint\t\ti;\n\tfloat range = 0;\n\tint turb;\n\tint\tnumparticles;\n\tint\tsnum;\n\t\n\tstr = (char *) CG_ConfigString (num);\n\tif (!str[0])\n\t\treturn (0);\n\t\n\t// returns type 128 64 or 32\n\ttoken = COM_Parse (&str);\n\ttype = atoi (token);\n\t\n\tif (type == 1)\n\t\trange = 128;\n\telse if (type == 2)\n\t\trange = 64;\n\telse if (type == 3)\n\t\trange = 32;\n\telse if (type == 0)\n\t\trange = 256;\n\telse if (type == 4)\n\t\trange = 8;\n\telse if (type == 5)\n\t\trange = 16;\n\telse if (type == 6)\n\t\trange = 32;\n\telse if (type == 7)\n\t\trange = 64;\n\n\n\tfor (i=0; i<3; i++)\n\t{\n\t\ttoken = COM_Parse (&str);\n\t\torigin[i] = atof (token);\n\t}\n\n\tfor (i=0; i<3; i++)\n\t{\n\t\ttoken = COM_Parse (&str);\n\t\torigin2[i] = atof (token);\n\t}\n\t\t\n\ttoken = COM_Parse (&str);\n\tnumparticles = atoi (token);\n\t\n\ttoken = COM_Parse (&str);\n\tturb = atoi (token);\n\n\ttoken = COM_Parse (&str);\n\tsnum = atoi (token);\n\t\n\tfor (i=0; i<numparticles; i++)\n\t{\n\t\tif (type >= 4)\n\t\t\tCG_ParticleBubble (cgs.media.waterBubbleShader, origin, origin2, turb, range, snum);\n\t\telse\n\t\t\tCG_ParticleSnow (cgs.media.waterBubbleShader, origin, origin2, turb, range, snum);\n\t}\n\n\treturn (1);\n}\n\nvoid\tCG_SnowLink (centity_t *cent, qboolean particleOn)\n{\n\tcparticle_t\t\t*p, *next;\n\tint id;\n\n\tid = cent->currentState.frame;\n\n\tfor (p=active_particles ; p ; p=next)\n\t{\n\t\tnext = p->next;\n\t\t\n\t\tif (p->type == P_WEATHER || p->type == P_WEATHER_TURBULENT)\n\t\t{\n\t\t\tif (p->snum == id)\n\t\t\t{\n\t\t\t\tif (particleOn)\n\t\t\t\t\tp->link = qtrue;\n\t\t\t\telse\n\t\t\t\t\tp->link = qfalse;\n\t\t\t}\n\t\t}\n\n\t}\n}\n\nvoid CG_ParticleImpactSmokePuff (qhandle_t pshader, vec3_t origin)\n{\n\tcparticle_t\t*p;\n\n\tif (!pshader)\n\t\tCG_Printf (\"CG_ParticleImpactSmokePuff pshader == ZERO!\\n\");\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\tp->alpha = 0.25;\n\tp->alphavel = 0;\n\tp->roll = crandom()*179;\n\n\tp->pshader = pshader;\n\n\tp->endtime = cg.time + 1000;\n\tp->startfade = cg.time + 100;\n\n\tp->width = rand()%4 + 8;\n\tp->height = rand()%4 + 8;\n\n\tp->endheight = p->height *2;\n\tp->endwidth = p->width * 2;\n\n\tp->endtime = cg.time + 500;\n\n\tp->type = P_SMOKE_IMPACT;\n\n\tVectorCopy( origin, p->org );\n\tVectorSet(p->vel, 0, 0, 20);\n\tVectorSet(p->accel, 0, 0, 20);\n\n\tp->rotate = qtrue;\n}\n\nvoid CG_Particle_Bleed (qhandle_t pshader, vec3_t start, vec3_t dir, int fleshEntityNum, int duration)\n{\n\tcparticle_t\t*p;\n\n\tif (!pshader)\n\t\tCG_Printf (\"CG_Particle_Bleed pshader == ZERO!\\n\");\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\tp->alpha = 1.0;\n\tp->alphavel = 0;\n\tp->roll = 0;\n\n\tp->pshader = pshader;\n\n\tp->endtime = cg.time + duration;\n\t\n\tif (fleshEntityNum)\n\t\tp->startfade = cg.time;\n\telse\n\t\tp->startfade = cg.time + 100;\n\n\tp->width = 4;\n\tp->height = 4;\n\n\tp->endheight = 4+rand()%3;\n\tp->endwidth = p->endheight;\n\n\tp->type = P_SMOKE;\n\n\tVectorCopy( start, p->org );\n\tp->vel[0] = 0;\n\tp->vel[1] = 0;\n\tp->vel[2] = -20;\n\tVectorClear( p->accel );\n\n\tp->rotate = qfalse;\n\n\tp->roll = rand()%179;\n\t\n\tp->color = BLOODRED;\n\tp->alpha = 0.75;\n\n}\n\nvoid CG_Particle_OilParticle (qhandle_t pshader, centity_t *cent)\n{\n\tcparticle_t\t*p;\n\n\tint\t\t\ttime;\n\tint\t\t\ttime2;\n\tfloat\t\tratio;\n\n\tfloat\tduration = 1500;\n\n\ttime = cg.time;\n\ttime2 = cg.time + cent->currentState.time;\n\n\tratio =(float)1 - ((float)time / (float)time2);\n\n\tif (!pshader)\n\t\tCG_Printf (\"CG_Particle_OilParticle == ZERO!\\n\");\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\tp->alpha = 1.0;\n\tp->alphavel = 0;\n\tp->roll = 0;\n\n\tp->pshader = pshader;\n\n\tp->endtime = cg.time + duration;\n\t\n\tp->startfade = p->endtime;\n\n\tp->width = 1;\n\tp->height = 3;\n\n\tp->endheight = 3;\n\tp->endwidth = 1;\n\n\tp->type = P_SMOKE;\n\n\tVectorCopy(cent->currentState.origin, p->org );\t\n\t\n\tp->vel[0] = (cent->currentState.origin2[0] * (16 * ratio));\n\tp->vel[1] = (cent->currentState.origin2[1] * (16 * ratio));\n\tp->vel[2] = (cent->currentState.origin2[2]);\n\n\tp->snum = 1.0f;\n\n\tVectorClear( p->accel );\n\n\tp->accel[2] = -20;\n\n\tp->rotate = qfalse;\n\n\tp->roll = rand()%179;\n\t\n\tp->alpha = 0.75;\n\n}\n\n\nvoid CG_Particle_OilSlick (qhandle_t pshader, centity_t *cent)\n{\n\tcparticle_t\t*p;\n\t\n  \tif (!pshader)\n\t\tCG_Printf (\"CG_Particle_OilSlick == ZERO!\\n\");\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\t\n\tif (cent->currentState.angles2[2])\n\t\tp->endtime = cg.time + cent->currentState.angles2[2];\n\telse\n\t\tp->endtime = cg.time + 60000;\n\n\tp->startfade = p->endtime;\n\n\tp->alpha = 1.0;\n\tp->alphavel = 0;\n\tp->roll = 0;\n\n\tp->pshader = pshader;\n\n\tif (cent->currentState.angles2[0] || cent->currentState.angles2[1])\n\t{\n\t\tp->width = cent->currentState.angles2[0];\n\t\tp->height = cent->currentState.angles2[0];\n\n\t\tp->endheight = cent->currentState.angles2[1];\n\t\tp->endwidth = cent->currentState.angles2[1];\n\t}\n\telse\n\t{\n\t\tp->width = 8;\n\t\tp->height = 8;\n\n\t\tp->endheight = 16;\n\t\tp->endwidth = 16;\n\t}\n\n\tp->type = P_FLAT_SCALEUP;\n\n\tp->snum = 1.0;\n\n\tVectorCopy(cent->currentState.origin, p->org );\n\t\n\tp->org[2]+= 0.55 + (crandom() * 0.5);\n\n\tp->vel[0] = 0;\n\tp->vel[1] = 0;\n\tp->vel[2] = 0;\n\tVectorClear( p->accel );\n\n\tp->rotate = qfalse;\n\n\tp->roll = rand()%179;\n\t\n\tp->alpha = 0.75;\n\n}\n\nvoid CG_OilSlickRemove (centity_t *cent)\n{\n\tcparticle_t\t\t*p, *next;\n\tint\t\t\t\tid;\n\n\tid = 1.0f;\n\n\tif (!id)\n\t\tCG_Printf (\"CG_OilSlickRevove NULL id\\n\");\n\n\tfor (p=active_particles ; p ; p=next)\n\t{\n\t\tnext = p->next;\n\t\t\n\t\tif (p->type == P_FLAT_SCALEUP)\n\t\t{\n\t\t\tif (p->snum == id)\n\t\t\t{\n\t\t\t\tp->endtime = cg.time + 100;\n\t\t\t\tp->startfade = p->endtime;\n\t\t\t\tp->type = P_FLAT_SCALEUP_FADE;\n\n\t\t\t}\n\t\t}\n\n\t}\n}\n\nqboolean ValidBloodPool (vec3_t start)\n{\n#define EXTRUDE_DIST\t0.5\n\n\tvec3_t\tangles;\n\tvec3_t\tright, up;\n\tvec3_t\tthis_pos, x_pos, center_pos, end_pos;\n\tfloat\tx, y;\n\tfloat\tfwidth, fheight;\n\ttrace_t\ttrace;\n\tvec3_t\tnormal;\n\n\tfwidth = 16;\n\tfheight = 16;\n\n\tVectorSet (normal, 0, 0, 1);\n\n\tvectoangles (normal, angles);\n\tAngleVectors (angles, NULL, right, up);\n\n\tVectorMA (start, EXTRUDE_DIST, normal, center_pos);\n\n\tfor (x= -fwidth/2; x<fwidth; x+= fwidth)\n\t{\n\t\tVectorMA (center_pos, x, right, x_pos);\n\n\t\tfor (y= -fheight/2; y<fheight; y+= fheight)\n\t\t{\n\t\t\tVectorMA (x_pos, y, up, this_pos);\n\t\t\tVectorMA (this_pos, -EXTRUDE_DIST*2, normal, end_pos);\n\t\t\t\n\t\t\tCG_Trace (&trace, this_pos, NULL, NULL, end_pos, -1, CONTENTS_SOLID);\n\n\t\t\t\n\t\t\tif (trace.entityNum < (MAX_ENTITIES - 1)) // may only land on world\n\t\t\t\treturn qfalse;\n\n\t\t\tif (!(!trace.startsolid && trace.fraction < 1))\n\t\t\t\treturn qfalse;\n\t\t\n\t\t}\n\t}\n\n\treturn qtrue;\n}\n\nvoid CG_BloodPool (localEntity_t *le, qhandle_t pshader, trace_t *tr)\n{\t\n\tcparticle_t\t*p;\n\tqboolean\tlegit;\n\tvec3_t\t\tstart;\n\tfloat\t\trndSize;\n\t\n\tif (!pshader)\n\t\tCG_Printf (\"CG_BloodPool pshader == ZERO!\\n\");\n\n\tif (!free_particles)\n\t\treturn;\n\t\n\tVectorCopy (tr->endpos, start);\n\tlegit = ValidBloodPool (start);\n\n\tif (!legit) \n\t\treturn;\n\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\t\n\tp->endtime = cg.time + 3000;\n\tp->startfade = p->endtime;\n\n\tp->alpha = 1.0;\n\tp->alphavel = 0;\n\tp->roll = 0;\n\n\tp->pshader = pshader;\n\n\trndSize = 0.4 + random()*0.6;\n\n\tp->width = 8*rndSize;\n\tp->height = 8*rndSize;\n\n\tp->endheight = 16*rndSize;\n\tp->endwidth = 16*rndSize;\n\t\n\tp->type = P_FLAT_SCALEUP;\n\n\tVectorCopy(start, p->org );\n\t\n\tp->vel[0] = 0;\n\tp->vel[1] = 0;\n\tp->vel[2] = 0;\n\tVectorClear( p->accel );\n\n\tp->rotate = qfalse;\n\n\tp->roll = rand()%179;\n\t\n\tp->alpha = 0.75;\n\t\n\tp->color = BLOODRED;\n}\n\n#define NORMALSIZE\t16\n#define LARGESIZE\t32\n\nvoid CG_ParticleBloodCloud (centity_t *cent, vec3_t origin, vec3_t dir)\n{\n\tfloat\tlength;\n\tfloat\tdist;\n\tfloat\tcrittersize;\n\tvec3_t\tangles, forward;\n\tvec3_t\tpoint;\n\tcparticle_t\t*p;\n\tint\t\ti;\n\t\n\tdist = 0;\n\n\tlength = VectorLength (dir);\n\tvectoangles (dir, angles);\n\tAngleVectors (angles, forward, NULL, NULL);\n\n\tcrittersize = LARGESIZE;\n\n\tif (length)\n\t\tdist = length / crittersize;\n\n\tif (dist < 1)\n\t\tdist = 1;\n\n\tVectorCopy (origin, point);\n\n\tfor (i=0; i<dist; i++)\n\t{\n\t\tVectorMA (point, crittersize, forward, point);\t\n\t\t\n\t\tif (!free_particles)\n\t\t\treturn;\n\n\t\tp = free_particles;\n\t\tfree_particles = p->next;\n\t\tp->next = active_particles;\n\t\tactive_particles = p;\n\n\t\tp->time = cg.time;\n\t\tp->alpha = 1.0;\n\t\tp->alphavel = 0;\n\t\tp->roll = 0;\n\n\t\tp->pshader = cgs.media.smokePuffShader;\n\n\t\tp->endtime = cg.time + 350 + (crandom() * 100);\n\t\t\n\t\tp->startfade = cg.time;\n\t\t\n\t\tp->width = LARGESIZE;\n\t\tp->height = LARGESIZE;\n\t\tp->endheight = LARGESIZE;\n\t\tp->endwidth = LARGESIZE;\n\n\t\tp->type = P_SMOKE;\n\n\t\tVectorCopy( origin, p->org );\n\t\t\n\t\tp->vel[0] = 0;\n\t\tp->vel[1] = 0;\n\t\tp->vel[2] = -1;\n\t\t\n\t\tVectorClear( p->accel );\n\n\t\tp->rotate = qfalse;\n\n\t\tp->roll = rand()%179;\n\t\t\n\t\tp->color = BLOODRED;\n\t\t\n\t\tp->alpha = 0.75;\n\t\t\n\t}\n\n\t\n}\n\nvoid CG_ParticleSparks (vec3_t org, vec3_t vel, int duration, float x, float y, float speed)\n{\n\tcparticle_t\t*p;\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\t\n\tp->endtime = cg.time + duration;\n\tp->startfade = cg.time + duration/2;\n\t\n\tp->color = EMISIVEFADE;\n\tp->alpha = 0.4f;\n\tp->alphavel = 0;\n\n\tp->height = 0.5;\n\tp->width = 0.5;\n\tp->endheight = 0.5;\n\tp->endwidth = 0.5;\n\n\tp->pshader = cgs.media.tracerShader;\n\n\tp->type = P_SMOKE;\n\t\n\tVectorCopy(org, p->org);\n\n\tp->org[0] += (crandom() * x);\n\tp->org[1] += (crandom() * y);\n\n\tp->vel[0] = vel[0];\n\tp->vel[1] = vel[1];\n\tp->vel[2] = vel[2];\n\n\tp->accel[0] = p->accel[1] = p->accel[2] = 0;\n\n\tp->vel[0] += (crandom() * 4);\n\tp->vel[1] += (crandom() * 4);\n\tp->vel[2] += (20 + (crandom() * 10)) * speed;\t\n\n\tp->accel[0] = crandom () * 4;\n\tp->accel[1] = crandom () * 4;\n\t\n}\n\nvoid CG_ParticleDust (centity_t *cent, vec3_t origin, vec3_t dir)\n{\n\tfloat\tlength;\n\tfloat\tdist;\n\tfloat\tcrittersize;\n\tvec3_t\tangles, forward;\n\tvec3_t\tpoint;\n\tcparticle_t\t*p;\n\tint\t\ti;\n\t\n\tdist = 0;\n\n\tVectorNegate (dir, dir);\n\tlength = VectorLength (dir);\n\tvectoangles (dir, angles);\n\tAngleVectors (angles, forward, NULL, NULL);\n\n\tcrittersize = LARGESIZE;\n\n\tif (length)\n\t\tdist = length / crittersize;\n\n\tif (dist < 1)\n\t\tdist = 1;\n\n\tVectorCopy (origin, point);\n\n\tfor (i=0; i<dist; i++)\n\t{\n\t\tVectorMA (point, crittersize, forward, point);\t\n\t\t\t\t\n\t\tif (!free_particles)\n\t\t\treturn;\n\n\t\tp = free_particles;\n\t\tfree_particles = p->next;\n\t\tp->next = active_particles;\n\t\tactive_particles = p;\n\n\t\tp->time = cg.time;\n\t\tp->alpha = 5.0;\n\t\tp->alphavel = 0;\n\t\tp->roll = 0;\n\n\t\tp->pshader = cgs.media.smokePuffShader;\n\n\t\t// RF, stay around for long enough to expand and dissipate naturally\n\t\tif (length)\n\t\t\tp->endtime = cg.time + 4500 + (crandom() * 3500);\n\t\telse\n\t\t\tp->endtime = cg.time + 750 + (crandom() * 500);\n\t\t\n\t\tp->startfade = cg.time;\n\t\t\n\t\tp->width = LARGESIZE;\n\t\tp->height = LARGESIZE;\n\n\t\t// RF, expand while falling\n\t\tp->endheight = LARGESIZE*3.0;\n\t\tp->endwidth = LARGESIZE*3.0;\n\n\t\tif (!length)\n\t\t{\n\t\t\tp->width *= 0.2f;\n\t\t\tp->height *= 0.2f;\n\n\t\t\tp->endheight = NORMALSIZE;\n\t\t\tp->endwidth = NORMALSIZE;\n\t\t}\n\n\t\tp->type = P_SMOKE;\n\n\t\tVectorCopy( point, p->org );\n\t\t\n\t\tp->vel[0] = crandom()*6;\n\t\tp->vel[1] = crandom()*6;\n\t\tp->vel[2] = random()*20;\n\n\t\t// RF, add some gravity/randomness\n\t\tp->accel[0] = crandom()*3;\n\t\tp->accel[1] = crandom()*3;\n\t\tp->accel[2] = -PARTICLE_GRAVITY*0.4;\n\n\t\tVectorClear( p->accel );\n\n\t\tp->rotate = qfalse;\n\n\t\tp->roll = rand()%179;\n\t\t\n\t\tp->alpha = 0.75;\n\t\t\n\t}\n\n\t\n}\n\nvoid CG_ParticleMisc (qhandle_t pshader, vec3_t origin, int size, int duration, float alpha)\n{\n\tcparticle_t\t*p;\n\n\tif (!pshader)\n\t\tCG_Printf (\"CG_ParticleImpactSmokePuff pshader == ZERO!\\n\");\n\n\tif (!free_particles)\n\t\treturn;\n\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\tp->alpha = 1.0;\n\tp->alphavel = 0;\n\tp->roll = rand()%179;\n\n\tp->pshader = pshader;\n\n\tif (duration > 0)\n\t\tp->endtime = cg.time + duration;\n\telse\n\t\tp->endtime = duration;\n\n\tp->startfade = cg.time;\n\n\tp->width = size;\n\tp->height = size;\n\n\tp->endheight = size;\n\tp->endwidth = size;\n\n\tp->type = P_SPRITE;\n\n\tVectorCopy( origin, p->org );\n\n\tp->rotate = qfalse;\n}\n\n"
  },
  {
    "path": "code/cgame/cg_newdraw.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#ifndef MISSIONPACK // bk001204\n#error This file not be used for classic Q3A.\n#endif\n\n#include \"cg_local.h\"\n#include \"../ui/ui_shared.h\"\n\nextern displayContextDef_t cgDC;\n\n\n// set in CG_ParseTeamInfo\n\n//static int sortedTeamPlayers[TEAM_MAXOVERLAY];\n//static int numSortedTeamPlayers;\nint drawTeamOverlayModificationCount = -1;\n\n//static char systemChat[256];\n//static char teamChat1[256];\n//static char teamChat2[256];\n\nvoid CG_InitTeamChat() {\n  memset(teamChat1, 0, sizeof(teamChat1));\n  memset(teamChat2, 0, sizeof(teamChat2));\n  memset(systemChat, 0, sizeof(systemChat));\n}\n\nvoid CG_SetPrintString(int type, const char *p) {\n  if (type == SYSTEM_PRINT) {\n    strcpy(systemChat, p);\n  } else {\n    strcpy(teamChat2, teamChat1);\n    strcpy(teamChat1, p);\n  }\n}\n\nvoid CG_CheckOrderPending() {\n\tif (cgs.gametype < GT_CTF) {\n\t\treturn;\n\t}\n\tif (cgs.orderPending) {\n\t\t//clientInfo_t *ci = cgs.clientinfo + sortedTeamPlayers[cg_currentSelectedPlayer.integer];\n\t\tconst char *p1, *p2, *b;\n\t\tp1 = p2 = b = NULL;\n\t\tswitch (cgs.currentOrder) {\n\t\t\tcase TEAMTASK_OFFENSE:\n\t\t\t\tp1 = VOICECHAT_ONOFFENSE;\n\t\t\t\tp2 = VOICECHAT_OFFENSE;\n\t\t\t\tb = \"+button7; wait; -button7\";\n\t\t\tbreak;\n\t\t\tcase TEAMTASK_DEFENSE:\n\t\t\t\tp1 = VOICECHAT_ONDEFENSE;\n\t\t\t\tp2 = VOICECHAT_DEFEND;\n\t\t\t\tb = \"+button8; wait; -button8\";\n\t\t\tbreak;\t\t\t\t\t\n\t\t\tcase TEAMTASK_PATROL:\n\t\t\t\tp1 = VOICECHAT_ONPATROL;\n\t\t\t\tp2 = VOICECHAT_PATROL;\n\t\t\t\tb = \"+button9; wait; -button9\";\n\t\t\tbreak;\n\t\t\tcase TEAMTASK_FOLLOW: \n\t\t\t\tp1 = VOICECHAT_ONFOLLOW;\n\t\t\t\tp2 = VOICECHAT_FOLLOWME;\n\t\t\t\tb = \"+button10; wait; -button10\";\n\t\t\tbreak;\n\t\t\tcase TEAMTASK_CAMP:\n\t\t\t\tp1 = VOICECHAT_ONCAMPING;\n\t\t\t\tp2 = VOICECHAT_CAMP;\n\t\t\tbreak;\n\t\t\tcase TEAMTASK_RETRIEVE:\n\t\t\t\tp1 = VOICECHAT_ONGETFLAG;\n\t\t\t\tp2 = VOICECHAT_RETURNFLAG;\n\t\t\tbreak;\n\t\t\tcase TEAMTASK_ESCORT:\n\t\t\t\tp1 = VOICECHAT_ONFOLLOWCARRIER;\n\t\t\t\tp2 = VOICECHAT_FOLLOWFLAGCARRIER;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (cg_currentSelectedPlayer.integer == numSortedTeamPlayers) {\n\t\t\t// to everyone\n\t\t\ttrap_SendConsoleCommand(va(\"cmd vsay_team %s\\n\", p2));\n\t\t} else {\n\t\t\t// for the player self\n\t\t\tif (sortedTeamPlayers[cg_currentSelectedPlayer.integer] == cg.snap->ps.clientNum && p1) {\n\t\t\t\ttrap_SendConsoleCommand(va(\"teamtask %i\\n\", cgs.currentOrder));\n\t\t\t\t//trap_SendConsoleCommand(va(\"cmd say_team %s\\n\", p2));\n\t\t\t\ttrap_SendConsoleCommand(va(\"cmd vsay_team %s\\n\", p1));\n\t\t\t} else if (p2) {\n\t\t\t\t//trap_SendConsoleCommand(va(\"cmd say_team %s, %s\\n\", ci->name,p));\n\t\t\t\ttrap_SendConsoleCommand(va(\"cmd vtell %d %s\\n\", sortedTeamPlayers[cg_currentSelectedPlayer.integer], p2));\n\t\t\t}\n\t\t}\n\t\tif (b) {\n\t\t\ttrap_SendConsoleCommand(b);\n\t\t}\n\t\tcgs.orderPending = qfalse;\n\t}\n}\n\nstatic void CG_SetSelectedPlayerName() {\n  if (cg_currentSelectedPlayer.integer >= 0 && cg_currentSelectedPlayer.integer < numSortedTeamPlayers) {\n\t\tclientInfo_t *ci = cgs.clientinfo + sortedTeamPlayers[cg_currentSelectedPlayer.integer];\n\t  if (ci) {\n\t\t\ttrap_Cvar_Set(\"cg_selectedPlayerName\", ci->name);\n\t\t\ttrap_Cvar_Set(\"cg_selectedPlayer\", va(\"%d\", sortedTeamPlayers[cg_currentSelectedPlayer.integer]));\n\t\t\tcgs.currentOrder = ci->teamTask;\n\t  }\n\t} else {\n\t\ttrap_Cvar_Set(\"cg_selectedPlayerName\", \"Everyone\");\n\t}\n}\nint CG_GetSelectedPlayer() {\n\tif (cg_currentSelectedPlayer.integer < 0 || cg_currentSelectedPlayer.integer >= numSortedTeamPlayers) {\n\t\tcg_currentSelectedPlayer.integer = 0;\n\t}\n\treturn cg_currentSelectedPlayer.integer;\n}\n\nvoid CG_SelectNextPlayer() {\n\tCG_CheckOrderPending();\n\tif (cg_currentSelectedPlayer.integer >= 0 && cg_currentSelectedPlayer.integer < numSortedTeamPlayers) {\n\t\tcg_currentSelectedPlayer.integer++;\n\t} else {\n\t\tcg_currentSelectedPlayer.integer = 0;\n\t}\n\tCG_SetSelectedPlayerName();\n}\n\nvoid CG_SelectPrevPlayer() {\n\tCG_CheckOrderPending();\n\tif (cg_currentSelectedPlayer.integer > 0 && cg_currentSelectedPlayer.integer < numSortedTeamPlayers) {\n\t\tcg_currentSelectedPlayer.integer--;\n\t} else {\n\t\tcg_currentSelectedPlayer.integer = numSortedTeamPlayers;\n\t}\n\tCG_SetSelectedPlayerName();\n}\n\n\nstatic void CG_DrawPlayerArmorIcon( rectDef_t *rect, qboolean draw2D ) {\n\tcentity_t\t*cent;\n\tplayerState_t\t*ps;\n\tvec3_t\t\tangles;\n\tvec3_t\t\torigin;\n\n  if ( cg_drawStatus.integer == 0 ) {\n\t\treturn;\n\t}\n\n\tcent = &cg_entities[cg.snap->ps.clientNum];\n\tps = &cg.snap->ps;\n\n\tif ( draw2D || ( !cg_draw3dIcons.integer && cg_drawIcons.integer) ) { // bk001206 - parentheses\n\t\tCG_DrawPic( rect->x, rect->y + rect->h/2 + 1, rect->w, rect->h, cgs.media.armorIcon );\n  } else if (cg_draw3dIcons.integer) {\n\t  VectorClear( angles );\n    origin[0] = 90;\n  \torigin[1] = 0;\n  \torigin[2] = -10;\n  \tangles[YAW] = ( cg.time & 2047 ) * 360 / 2048.0;\n  \n    CG_Draw3DModel( rect->x, rect->y, rect->w, rect->h, cgs.media.armorModel, 0, origin, angles );\n  }\n\n}\n\nstatic void CG_DrawPlayerArmorValue(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle) {\n\tchar\tnum[16];\n  int value;\n\tcentity_t\t*cent;\n\tplayerState_t\t*ps;\n\n  cent = &cg_entities[cg.snap->ps.clientNum];\n\tps = &cg.snap->ps;\n\n\tvalue = ps->stats[STAT_ARMOR];\n  \n\n\tif (shader) {\n    trap_R_SetColor( color );\n\t\tCG_DrawPic(rect->x, rect->y, rect->w, rect->h, shader);\n\t  trap_R_SetColor( NULL );\n\t} else {\n\t\tCom_sprintf (num, sizeof(num), \"%i\", value);\n\t\tvalue = CG_Text_Width(num, scale, 0);\n\t  CG_Text_Paint(rect->x + (rect->w - value) / 2, rect->y + rect->h, scale, color, num, 0, 0, textStyle);\n\t}\n}\n\n#ifndef MISSIONPACK // bk001206 \nstatic float healthColors[4][4] = { \n//\t\t{ 0.2, 1.0, 0.2, 1.0 } , { 1.0, 0.2, 0.2, 1.0 }, {0.5, 0.5, 0.5, 1} };\n  // bk0101016 - float const\n  { 1.0f, 0.69f, 0.0f, 1.0f } ,\t\t// normal\n  { 1.0f, 0.2f, 0.2f, 1.0f },\t\t// low health\n  { 0.5f, 0.5f, 0.5f, 1.0f},\t\t// weapon firing\n  { 1.0f, 1.0f, 1.0f, 1.0f } };\t\t// health > 100\n#endif\n\nstatic void CG_DrawPlayerAmmoIcon( rectDef_t *rect, qboolean draw2D ) {\n\tcentity_t\t*cent;\n\tplayerState_t\t*ps;\n\tvec3_t\t\tangles;\n\tvec3_t\t\torigin;\n\n\tcent = &cg_entities[cg.snap->ps.clientNum];\n\tps = &cg.snap->ps;\n\n\tif ( draw2D || (!cg_draw3dIcons.integer && cg_drawIcons.integer) ) { // bk001206 - parentheses\n\t  qhandle_t\ticon;\n    icon = cg_weapons[ cg.predictedPlayerState.weapon ].ammoIcon;\n\t\tif ( icon ) {\n\t\t  CG_DrawPic( rect->x, rect->y, rect->w, rect->h, icon );\n\t\t}\n  } else if (cg_draw3dIcons.integer) {\n  \tif ( cent->currentState.weapon && cg_weapons[ cent->currentState.weapon ].ammoModel ) {\n\t    VectorClear( angles );\n\t  \torigin[0] = 70;\n  \t\torigin[1] = 0;\n  \t\torigin[2] = 0;\n  \t\tangles[YAW] = 90 + 20 * sin( cg.time / 1000.0 );\n  \t\tCG_Draw3DModel( rect->x, rect->y, rect->w, rect->h, cg_weapons[ cent->currentState.weapon ].ammoModel, 0, origin, angles );\n  \t}\n  }\n}\n\nstatic void CG_DrawPlayerAmmoValue(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle) {\n\tchar\tnum[16];\n\tint value;\n\tcentity_t\t*cent;\n\tplayerState_t\t*ps;\n\n\tcent = &cg_entities[cg.snap->ps.clientNum];\n\tps = &cg.snap->ps;\n\n\tif ( cent->currentState.weapon ) {\n\t\tvalue = ps->ammo[cent->currentState.weapon];\n\t\tif ( value > -1 ) {\n\t\t\tif (shader) {\n\t\t    trap_R_SetColor( color );\n\t\t\t\tCG_DrawPic(rect->x, rect->y, rect->w, rect->h, shader);\n\t\t\t  trap_R_SetColor( NULL );\n\t\t\t} else {\n\t\t\t\tCom_sprintf (num, sizeof(num), \"%i\", value);\n\t\t\t\tvalue = CG_Text_Width(num, scale, 0);\n\t\t\t\tCG_Text_Paint(rect->x + (rect->w - value) / 2, rect->y + rect->h, scale, color, num, 0, 0, textStyle);\n\t\t\t}\n\t\t}\n\t}\n\n}\n\n\n\nstatic void CG_DrawPlayerHead(rectDef_t *rect, qboolean draw2D) {\n\tvec3_t\t\tangles;\n\tfloat\t\tsize, stretch;\n\tfloat\t\tfrac;\n\tfloat\t\tx = rect->x;\n\n\tVectorClear( angles );\n\n\tif ( cg.damageTime && cg.time - cg.damageTime < DAMAGE_TIME ) {\n\t\tfrac = (float)(cg.time - cg.damageTime ) / DAMAGE_TIME;\n\t\tsize = rect->w * 1.25 * ( 1.5 - frac * 0.5 );\n\n\t\tstretch = size - rect->w * 1.25;\n\t\t// kick in the direction of damage\n\t\tx -= stretch * 0.5 + cg.damageX * stretch * 0.5;\n\n\t\tcg.headStartYaw = 180 + cg.damageX * 45;\n\n\t\tcg.headEndYaw = 180 + 20 * cos( crandom()*M_PI );\n\t\tcg.headEndPitch = 5 * cos( crandom()*M_PI );\n\n\t\tcg.headStartTime = cg.time;\n\t\tcg.headEndTime = cg.time + 100 + random() * 2000;\n\t} else {\n\t\tif ( cg.time >= cg.headEndTime ) {\n\t\t\t// select a new head angle\n\t\t\tcg.headStartYaw = cg.headEndYaw;\n\t\t\tcg.headStartPitch = cg.headEndPitch;\n\t\t\tcg.headStartTime = cg.headEndTime;\n\t\t\tcg.headEndTime = cg.time + 100 + random() * 2000;\n\n\t\t\tcg.headEndYaw = 180 + 20 * cos( crandom()*M_PI );\n\t\t\tcg.headEndPitch = 5 * cos( crandom()*M_PI );\n\t\t}\n\n\t\tsize = rect->w * 1.25;\n\t}\n\n\t// if the server was frozen for a while we may have a bad head start time\n\tif ( cg.headStartTime > cg.time ) {\n\t\tcg.headStartTime = cg.time;\n\t}\n\n\tfrac = ( cg.time - cg.headStartTime ) / (float)( cg.headEndTime - cg.headStartTime );\n\tfrac = frac * frac * ( 3 - 2 * frac );\n\tangles[YAW] = cg.headStartYaw + ( cg.headEndYaw - cg.headStartYaw ) * frac;\n\tangles[PITCH] = cg.headStartPitch + ( cg.headEndPitch - cg.headStartPitch ) * frac;\n\n\tCG_DrawHead( x, rect->y, rect->w, rect->h, cg.snap->ps.clientNum, angles );\n}\n\nstatic void CG_DrawSelectedPlayerHealth( rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle ) {\n\tclientInfo_t *ci;\n\tint value;\n\tchar num[16];\n\n  ci = cgs.clientinfo + sortedTeamPlayers[CG_GetSelectedPlayer()];\n  if (ci) {\n\t\tif (shader) {\n\t\t\ttrap_R_SetColor( color );\n\t\t\tCG_DrawPic(rect->x, rect->y, rect->w, rect->h, shader);\n\t\t\ttrap_R_SetColor( NULL );\n\t\t} else {\n\t\t\tCom_sprintf (num, sizeof(num), \"%i\", ci->health);\n\t\t  value = CG_Text_Width(num, scale, 0);\n\t\t  CG_Text_Paint(rect->x + (rect->w - value) / 2, rect->y + rect->h, scale, color, num, 0, 0, textStyle);\n\t\t}\n\t}\n}\n\nstatic void CG_DrawSelectedPlayerArmor( rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle ) {\n\tclientInfo_t *ci;\n\tint value;\n\tchar num[16];\n  ci = cgs.clientinfo + sortedTeamPlayers[CG_GetSelectedPlayer()];\n  if (ci) {\n    if (ci->armor > 0) {\n\t\t\tif (shader) {\n\t\t\t\ttrap_R_SetColor( color );\n\t\t\t\tCG_DrawPic(rect->x, rect->y, rect->w, rect->h, shader);\n\t\t\t\ttrap_R_SetColor( NULL );\n\t\t\t} else {\n\t\t\t\tCom_sprintf (num, sizeof(num), \"%i\", ci->armor);\n\t\t\t\tvalue = CG_Text_Width(num, scale, 0);\n\t\t\t\tCG_Text_Paint(rect->x + (rect->w - value) / 2, rect->y + rect->h, scale, color, num, 0, 0, textStyle);\n\t\t\t}\n\t\t}\n \t}\n}\n\nqhandle_t CG_StatusHandle(int task) {\n\tqhandle_t h = cgs.media.assaultShader;\n\tswitch (task) {\n\t\tcase TEAMTASK_OFFENSE :\n\t\t\th = cgs.media.assaultShader;\n\t\t\tbreak;\n\t\tcase TEAMTASK_DEFENSE :\n\t\t\th = cgs.media.defendShader;\n\t\t\tbreak;\n\t\tcase TEAMTASK_PATROL :\n\t\t\th = cgs.media.patrolShader;\n\t\t\tbreak;\n\t\tcase TEAMTASK_FOLLOW :\n\t\t\th = cgs.media.followShader;\n\t\t\tbreak;\n\t\tcase TEAMTASK_CAMP :\n\t\t\th = cgs.media.campShader;\n\t\t\tbreak;\n\t\tcase TEAMTASK_RETRIEVE :\n\t\t\th = cgs.media.retrieveShader; \n\t\t\tbreak;\n\t\tcase TEAMTASK_ESCORT :\n\t\t\th = cgs.media.escortShader; \n\t\t\tbreak;\n\t\tdefault : \n\t\t\th = cgs.media.assaultShader;\n\t\t\tbreak;\n\t}\n\treturn h;\n}\n\nstatic void CG_DrawSelectedPlayerStatus( rectDef_t *rect ) {\n\tclientInfo_t *ci = cgs.clientinfo + sortedTeamPlayers[CG_GetSelectedPlayer()];\n\tif (ci) {\n\t\tqhandle_t h;\n\t\tif (cgs.orderPending) {\n\t\t\t// blink the icon\n\t\t\tif ( cg.time > cgs.orderTime - 2500 && (cg.time >> 9 ) & 1 ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\th = CG_StatusHandle(cgs.currentOrder);\n\t\t}\telse {\n\t\t\th = CG_StatusHandle(ci->teamTask);\n\t\t}\n\t\tCG_DrawPic( rect->x, rect->y, rect->w, rect->h, h );\n\t}\n}\n\n\nstatic void CG_DrawPlayerStatus( rectDef_t *rect ) {\n\tclientInfo_t *ci = &cgs.clientinfo[cg.snap->ps.clientNum];\n\tif (ci) {\n\t\tqhandle_t h = CG_StatusHandle(ci->teamTask);\n\t\tCG_DrawPic( rect->x, rect->y, rect->w, rect->h, h);\n\t}\n}\n\n\nstatic void CG_DrawSelectedPlayerName( rectDef_t *rect, float scale, vec4_t color, qboolean voice, int textStyle) {\n\tclientInfo_t *ci;\n  ci = cgs.clientinfo + ((voice) ? cgs.currentVoiceClient : sortedTeamPlayers[CG_GetSelectedPlayer()]);\n  if (ci) {\n    CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, ci->name, 0, 0, textStyle);\n  }\n}\n\nstatic void CG_DrawSelectedPlayerLocation( rectDef_t *rect, float scale, vec4_t color, int textStyle ) {\n\tclientInfo_t *ci;\n  ci = cgs.clientinfo + sortedTeamPlayers[CG_GetSelectedPlayer()];\n  if (ci) {\n\t\tconst char *p = CG_ConfigString(CS_LOCATIONS + ci->location);\n\t\tif (!p || !*p) {\n\t\t\tp = \"unknown\";\n\t\t}\n    CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, p, 0, 0, textStyle);\n  }\n}\n\nstatic void CG_DrawPlayerLocation( rectDef_t *rect, float scale, vec4_t color, int textStyle  ) {\n\tclientInfo_t *ci = &cgs.clientinfo[cg.snap->ps.clientNum];\n  if (ci) {\n\t\tconst char *p = CG_ConfigString(CS_LOCATIONS + ci->location);\n\t\tif (!p || !*p) {\n\t\t\tp = \"unknown\";\n\t\t}\n    CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, p, 0, 0, textStyle);\n  }\n}\n\n\n\nstatic void CG_DrawSelectedPlayerWeapon( rectDef_t *rect ) {\n\tclientInfo_t *ci;\n\n  ci = cgs.clientinfo + sortedTeamPlayers[CG_GetSelectedPlayer()];\n  if (ci) {\n\t  if ( cg_weapons[ci->curWeapon].weaponIcon ) {\n\t    CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cg_weapons[ci->curWeapon].weaponIcon );\n\t\t} else {\n  \t  CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.deferShader);\n    }\n  }\n}\n\nstatic void CG_DrawPlayerScore( rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle ) {\n  char num[16];\n  int value = cg.snap->ps.persistant[PERS_SCORE];\n\n\tif (shader) {\n\t\ttrap_R_SetColor( color );\n\t\tCG_DrawPic(rect->x, rect->y, rect->w, rect->h, shader);\n\t\ttrap_R_SetColor( NULL );\n\t} else {\n\t\tCom_sprintf (num, sizeof(num), \"%i\", value);\n\t\tvalue = CG_Text_Width(num, scale, 0);\n\t  CG_Text_Paint(rect->x + (rect->w - value) / 2, rect->y + rect->h, scale, color, num, 0, 0, textStyle);\n\t}\n}\n\nstatic void CG_DrawPlayerItem( rectDef_t *rect, float scale, qboolean draw2D) {\n\tint\t\tvalue;\n  vec3_t origin, angles;\n\n\tvalue = cg.snap->ps.stats[STAT_HOLDABLE_ITEM];\n\tif ( value ) {\n\t\tCG_RegisterItemVisuals( value );\n\n\t\tif (qtrue) {\n\t\t  CG_RegisterItemVisuals( value );\n\t\t  CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cg_items[ value ].icon );\n\t\t} else {\n \t\t\tVectorClear( angles );\n\t\t\torigin[0] = 90;\n  \t\torigin[1] = 0;\n   \t\torigin[2] = -10;\n  \t\tangles[YAW] = ( cg.time & 2047 ) * 360 / 2048.0;\n\t\t\tCG_Draw3DModel(rect->x, rect->y, rect->w, rect->h, cg_items[ value ].models[0], 0, origin, angles );\n\t\t}\n\t}\n\n}\n\n\nstatic void CG_DrawSelectedPlayerPowerup( rectDef_t *rect, qboolean draw2D ) {\n\tclientInfo_t *ci;\n  int j;\n  float x, y;\n\n  ci = cgs.clientinfo + sortedTeamPlayers[CG_GetSelectedPlayer()];\n  if (ci) {\n    x = rect->x;\n    y = rect->y;\n\n\t\tfor (j = 0; j < PW_NUM_POWERUPS; j++) {\n\t\t\tif (ci->powerups & (1 << j)) {\n\t\t\t\tgitem_t\t*item;\n\t\t\t\titem = BG_FindItemForPowerup( j );\n\t\t\t\tif (item) {\n\t\t\t\t  CG_DrawPic( x, y, rect->w, rect->h, trap_R_RegisterShader( item->icon ) );\n\t\t\t\t\tx += 3;\n\t\t\t\t\ty += 3;\n          return;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n  }\n}\n\n\nstatic void CG_DrawSelectedPlayerHead( rectDef_t *rect, qboolean draw2D, qboolean voice ) {\n\tclipHandle_t\tcm;\n\tclientInfo_t\t*ci;\n\tfloat\t\t\tlen;\n\tvec3_t\t\t\torigin;\n\tvec3_t\t\t\tmins, maxs, angles;\n\n\n  ci = cgs.clientinfo + ((voice) ? cgs.currentVoiceClient : sortedTeamPlayers[CG_GetSelectedPlayer()]);\n\n  if (ci) {\n  \tif ( cg_draw3dIcons.integer ) {\n\t  \tcm = ci->headModel;\n  \t\tif ( !cm ) {\n  \t\t\treturn;\n\t  \t}\n\n  \t\t// offset the origin y and z to center the head\n  \t\ttrap_R_ModelBounds( cm, mins, maxs );\n\n\t  \torigin[2] = -0.5 * ( mins[2] + maxs[2] );\n  \t\torigin[1] = 0.5 * ( mins[1] + maxs[1] );\n\n\t  \t// calculate distance so the head nearly fills the box\n  \t\t// assume heads are taller than wide\n  \t\tlen = 0.7 * ( maxs[2] - mins[2] );\t\t\n  \t\torigin[0] = len / 0.268;\t// len / tan( fov/2 )\n\n  \t\t// allow per-model tweaking\n  \t\tVectorAdd( origin, ci->headOffset, origin );\n\n    \tangles[PITCH] = 0;\n    \tangles[YAW] = 180;\n    \tangles[ROLL] = 0;\n  \t\n      CG_Draw3DModel( rect->x, rect->y, rect->w, rect->h, ci->headModel, ci->headSkin, origin, angles );\n  \t} else if ( cg_drawIcons.integer ) {\n\t  \tCG_DrawPic( rect->x, rect->y, rect->w, rect->h, ci->modelIcon );\n  \t}\n\n  \t// if they are deferred, draw a cross out\n  \tif ( ci->deferred ) {\n  \t\tCG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.deferShader );\n  \t}\n  }\n\n}\n\n\nstatic void CG_DrawPlayerHealth(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle ) {\n\tplayerState_t\t*ps;\n  int value;\n\tchar\tnum[16];\n\n\tps = &cg.snap->ps;\n\n\tvalue = ps->stats[STAT_HEALTH];\n\n\tif (shader) {\n\t\ttrap_R_SetColor( color );\n\t\tCG_DrawPic(rect->x, rect->y, rect->w, rect->h, shader);\n\t\ttrap_R_SetColor( NULL );\n\t} else {\n\t\tCom_sprintf (num, sizeof(num), \"%i\", value);\n\t  value = CG_Text_Width(num, scale, 0);\n\t  CG_Text_Paint(rect->x + (rect->w - value) / 2, rect->y + rect->h, scale, color, num, 0, 0, textStyle);\n\t}\n}\n\n\nstatic void CG_DrawRedScore(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle ) {\n\tint value;\n\tchar num[16];\n\tif ( cgs.scores1 == SCORE_NOT_PRESENT ) {\n\t\tCom_sprintf (num, sizeof(num), \"-\");\n\t}\n\telse {\n\t\tCom_sprintf (num, sizeof(num), \"%i\", cgs.scores1);\n\t}\n\tvalue = CG_Text_Width(num, scale, 0);\n\tCG_Text_Paint(rect->x + rect->w - value, rect->y + rect->h, scale, color, num, 0, 0, textStyle);\n}\n\nstatic void CG_DrawBlueScore(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle ) {\n\tint value;\n\tchar num[16];\n\n\tif ( cgs.scores2 == SCORE_NOT_PRESENT ) {\n\t\tCom_sprintf (num, sizeof(num), \"-\");\n\t}\n\telse {\n\t\tCom_sprintf (num, sizeof(num), \"%i\", cgs.scores2);\n\t}\n\tvalue = CG_Text_Width(num, scale, 0);\n\tCG_Text_Paint(rect->x + rect->w - value, rect->y + rect->h, scale, color, num, 0, 0, textStyle);\n}\n\n// FIXME: team name support\nstatic void CG_DrawRedName(rectDef_t *rect, float scale, vec4_t color, int textStyle ) {\n  CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, cg_redTeamName.string , 0, 0, textStyle);\n}\n\nstatic void CG_DrawBlueName(rectDef_t *rect, float scale, vec4_t color, int textStyle ) {\n  CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, cg_blueTeamName.string, 0, 0, textStyle);\n}\n\nstatic void CG_DrawBlueFlagName(rectDef_t *rect, float scale, vec4_t color, int textStyle ) {\n  int i;\n  for ( i = 0 ; i < cgs.maxclients ; i++ ) {\n\t  if ( cgs.clientinfo[i].infoValid && cgs.clientinfo[i].team == TEAM_RED  && cgs.clientinfo[i].powerups & ( 1<< PW_BLUEFLAG )) {\n      CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, cgs.clientinfo[i].name, 0, 0, textStyle);\n      return;\n    }\n  }\n}\n\nstatic void CG_DrawBlueFlagStatus(rectDef_t *rect, qhandle_t shader) {\n\tif (cgs.gametype != GT_CTF && cgs.gametype != GT_1FCTF) {\n\t\tif (cgs.gametype == GT_HARVESTER) {\n\t\t  vec4_t color = {0, 0, 1, 1};\n\t\t  trap_R_SetColor(color);\n\t    CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.blueCubeIcon );\n\t\t  trap_R_SetColor(NULL);\n\t\t}\n\t\treturn;\n\t}\n  if (shader) {\n\t\tCG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader );\n  } else {\n\t  gitem_t *item = BG_FindItemForPowerup( PW_BLUEFLAG );\n    if (item) {\n\t\t  vec4_t color = {0, 0, 1, 1};\n\t\t  trap_R_SetColor(color);\n\t    if( cgs.blueflag >= 0 && cgs.blueflag <= 2 ) {\n\t\t    CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.flagShaders[cgs.blueflag] );\n\t\t\t} else {\n\t\t    CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.flagShaders[0] );\n\t\t\t}\n\t\t  trap_R_SetColor(NULL);\n\t  }\n  }\n}\n\nstatic void CG_DrawBlueFlagHead(rectDef_t *rect) {\n  int i;\n  for ( i = 0 ; i < cgs.maxclients ; i++ ) {\n\t  if ( cgs.clientinfo[i].infoValid && cgs.clientinfo[i].team == TEAM_RED  && cgs.clientinfo[i].powerups & ( 1<< PW_BLUEFLAG )) {\n      vec3_t angles;\n      VectorClear( angles );\n \t\t  angles[YAW] = 180 + 20 * sin( cg.time / 650.0 );;\n      CG_DrawHead( rect->x, rect->y, rect->w, rect->h, 0,angles );\n      return;\n    }\n  }\n}\n\nstatic void CG_DrawRedFlagName(rectDef_t *rect, float scale, vec4_t color, int textStyle ) {\n  int i;\n  for ( i = 0 ; i < cgs.maxclients ; i++ ) {\n\t  if ( cgs.clientinfo[i].infoValid && cgs.clientinfo[i].team == TEAM_BLUE  && cgs.clientinfo[i].powerups & ( 1<< PW_REDFLAG )) {\n      CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, cgs.clientinfo[i].name, 0, 0, textStyle);\n      return;\n    }\n  }\n}\n\nstatic void CG_DrawRedFlagStatus(rectDef_t *rect, qhandle_t shader) {\n\tif (cgs.gametype != GT_CTF && cgs.gametype != GT_1FCTF) {\n\t\tif (cgs.gametype == GT_HARVESTER) {\n\t\t  vec4_t color = {1, 0, 0, 1};\n\t\t  trap_R_SetColor(color);\n\t    CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.redCubeIcon );\n\t\t  trap_R_SetColor(NULL);\n\t\t}\n\t\treturn;\n\t}\n  if (shader) {\n\t\tCG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader );\n  } else {\n\t  gitem_t *item = BG_FindItemForPowerup( PW_REDFLAG );\n    if (item) {\n\t\t  vec4_t color = {1, 0, 0, 1};\n\t\t  trap_R_SetColor(color);\n\t    if( cgs.redflag >= 0 && cgs.redflag <= 2) {\n\t\t    CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.flagShaders[cgs.redflag] );\n\t\t\t} else {\n\t\t    CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.flagShaders[0] );\n\t\t\t}\n\t\t  trap_R_SetColor(NULL);\n\t  }\n  }\n}\n\nstatic void CG_DrawRedFlagHead(rectDef_t *rect) {\n  int i;\n  for ( i = 0 ; i < cgs.maxclients ; i++ ) {\n\t  if ( cgs.clientinfo[i].infoValid && cgs.clientinfo[i].team == TEAM_BLUE  && cgs.clientinfo[i].powerups & ( 1<< PW_REDFLAG )) {\n      vec3_t angles;\n      VectorClear( angles );\n \t\t  angles[YAW] = 180 + 20 * sin( cg.time / 650.0 );;\n      CG_DrawHead( rect->x, rect->y, rect->w, rect->h, 0,angles );\n      return;\n    }\n  }\n}\n\nstatic void CG_HarvesterSkulls(rectDef_t *rect, float scale, vec4_t color, qboolean force2D, int textStyle ) {\n\tchar num[16];\n\tvec3_t origin, angles;\n\tqhandle_t handle;\n\tint value = cg.snap->ps.generic1;\n\n\tif (cgs.gametype != GT_HARVESTER) {\n\t\treturn;\n\t}\n\n\tif( value > 99 ) {\n\t\tvalue = 99;\n\t}\n\n\tCom_sprintf (num, sizeof(num), \"%i\", value);\n\tvalue = CG_Text_Width(num, scale, 0);\n\tCG_Text_Paint(rect->x + (rect->w - value), rect->y + rect->h, scale, color, num, 0, 0, textStyle);\n\n\tif (cg_drawIcons.integer) {\n\t\tif (!force2D && cg_draw3dIcons.integer) {\n\t\t\tVectorClear(angles);\n\t\t\torigin[0] = 90;\n\t\t\torigin[1] = 0;\n\t\t\torigin[2] = -10;\n\t\t\tangles[YAW] = ( cg.time & 2047 ) * 360 / 2048.0;\n\t\t\tif( cg.snap->ps.persistant[PERS_TEAM] == TEAM_BLUE ) {\n\t\t\t\thandle = cgs.media.redCubeModel;\n\t\t\t} else {\n\t\t\t\thandle = cgs.media.blueCubeModel;\n\t\t\t}\n\t\t\tCG_Draw3DModel( rect->x, rect->y, 35, 35, handle, 0, origin, angles );\n\t\t} else {\n\t\t\tif( cg.snap->ps.persistant[PERS_TEAM] == TEAM_BLUE ) {\n\t\t\t\thandle = cgs.media.redCubeIcon;\n\t\t\t} else {\n\t\t\t\thandle = cgs.media.blueCubeIcon;\n\t\t\t}\n\t\t\tCG_DrawPic( rect->x + 3, rect->y + 16, 20, 20, handle );\n\t\t}\n\t}\n}\n\nstatic void CG_OneFlagStatus(rectDef_t *rect) {\n\tif (cgs.gametype != GT_1FCTF) {\n\t\treturn;\n\t} else {\n\t\tgitem_t *item = BG_FindItemForPowerup( PW_NEUTRALFLAG );\n\t\tif (item) {\n\t\t\tif( cgs.flagStatus >= 0 && cgs.flagStatus <= 4 ) {\n\t\t\t\tvec4_t color = {1, 1, 1, 1};\n\t\t\t\tint index = 0;\n\t\t\t\tif (cgs.flagStatus == FLAG_TAKEN_RED) {\n\t\t\t\t\tcolor[1] = color[2] = 0;\n\t\t\t\t\tindex = 1;\n\t\t\t\t} else if (cgs.flagStatus == FLAG_TAKEN_BLUE) {\n\t\t\t\t\tcolor[0] = color[1] = 0;\n\t\t\t\t\tindex = 1;\n\t\t\t\t} else if (cgs.flagStatus == FLAG_DROPPED) {\n\t\t\t\t\tindex = 2;\n\t\t\t\t}\n\t\t\t  trap_R_SetColor(color);\n\t\t\t\tCG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.flagShaders[index] );\n\t\t\t}\n\t\t}\n\t}\n}\n\n\nstatic void CG_DrawCTFPowerUp(rectDef_t *rect) {\n\tint\t\tvalue;\n\n\tif (cgs.gametype < GT_CTF) {\n\t\treturn;\n\t}\n\tvalue = cg.snap->ps.stats[STAT_PERSISTANT_POWERUP];\n\tif ( value ) {\n\t\tCG_RegisterItemVisuals( value );\n\t\tCG_DrawPic( rect->x, rect->y, rect->w, rect->h, cg_items[ value ].icon );\n\t}\n}\n\n\n\nstatic void CG_DrawTeamColor(rectDef_t *rect, vec4_t color) {\n\tCG_DrawTeamBackground(rect->x, rect->y, rect->w, rect->h, color[3], cg.snap->ps.persistant[PERS_TEAM]);\n}\n\nstatic void CG_DrawAreaPowerUp(rectDef_t *rect, int align, float special, float scale, vec4_t color) {\n\tchar num[16];\n\tint\t\tsorted[MAX_POWERUPS];\n\tint\t\tsortedTime[MAX_POWERUPS];\n\tint\t\ti, j, k;\n\tint\t\tactive;\n\tplayerState_t\t*ps;\n\tint\t\tt;\n\tgitem_t\t*item;\n\tfloat\tf;\n\trectDef_t r2;\n\tfloat *inc;\n\tr2.x = rect->x;\n\tr2.y = rect->y;\n\tr2.w = rect->w;\n\tr2.h = rect->h;\n\n\tinc = (align == HUD_VERTICAL) ? &r2.y : &r2.x;\n\n\tps = &cg.snap->ps;\n\n\tif ( ps->stats[STAT_HEALTH] <= 0 ) {\n\t\treturn;\n\t}\n\n\t// sort the list by time remaining\n\tactive = 0;\n\tfor ( i = 0 ; i < MAX_POWERUPS ; i++ ) {\n\t\tif ( !ps->powerups[ i ] ) {\n\t\t\tcontinue;\n\t\t}\n\t\tt = ps->powerups[ i ] - cg.time;\n\t\t// ZOID--don't draw if the power up has unlimited time (999 seconds)\n\t\t// This is true of the CTF flags\n\t\tif ( t <= 0 || t >= 999000) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// insert into the list\n\t\tfor ( j = 0 ; j < active ; j++ ) {\n\t\t\tif ( sortedTime[j] >= t ) {\n\t\t\t\tfor ( k = active - 1 ; k >= j ; k-- ) {\n\t\t\t\t\tsorted[k+1] = sorted[k];\n\t\t\t\t\tsortedTime[k+1] = sortedTime[k];\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tsorted[j] = i;\n\t\tsortedTime[j] = t;\n\t\tactive++;\n\t}\n\n\t// draw the icons and timers\n\tfor ( i = 0 ; i < active ; i++ ) {\n\t\titem = BG_FindItemForPowerup( sorted[i] );\n\n\t\tif (item) {\n\t\t\tt = ps->powerups[ sorted[i] ];\n\t\t\tif ( t - cg.time >= POWERUP_BLINKS * POWERUP_BLINK_TIME ) {\n\t\t\t\ttrap_R_SetColor( NULL );\n\t\t\t} else {\n\t\t\t\tvec4_t\tmodulate;\n\n\t\t\t\tf = (float)( t - cg.time ) / POWERUP_BLINK_TIME;\n\t\t\t\tf -= (int)f;\n\t\t\t\tmodulate[0] = modulate[1] = modulate[2] = modulate[3] = f;\n\t\t\t\ttrap_R_SetColor( modulate );\n\t\t\t}\n\n\t\t\tCG_DrawPic( r2.x, r2.y, r2.w * .75, r2.h, trap_R_RegisterShader( item->icon ) );\n\n\t\t\tCom_sprintf (num, sizeof(num), \"%i\", sortedTime[i] / 1000);\n\t\t\tCG_Text_Paint(r2.x + (r2.w * .75) + 3 , r2.y + r2.h, scale, color, num, 0, 0, 0);\n\t\t\t*inc += r2.w + special;\n\t\t}\n\n\t}\n\ttrap_R_SetColor( NULL );\n\n}\n\nfloat CG_GetValue(int ownerDraw) {\n\tcentity_t\t*cent;\n \tclientInfo_t *ci;\n\tplayerState_t\t*ps;\n\n  cent = &cg_entities[cg.snap->ps.clientNum];\n\tps = &cg.snap->ps;\n\n  switch (ownerDraw) {\n  case CG_SELECTEDPLAYER_ARMOR:\n    ci = cgs.clientinfo + sortedTeamPlayers[CG_GetSelectedPlayer()];\n    return ci->armor;\n    break;\n  case CG_SELECTEDPLAYER_HEALTH:\n    ci = cgs.clientinfo + sortedTeamPlayers[CG_GetSelectedPlayer()];\n    return ci->health;\n    break;\n  case CG_PLAYER_ARMOR_VALUE:\n\t\treturn ps->stats[STAT_ARMOR];\n    break;\n  case CG_PLAYER_AMMO_VALUE:\n\t\tif ( cent->currentState.weapon ) {\n\t\t  return ps->ammo[cent->currentState.weapon];\n\t\t}\n    break;\n  case CG_PLAYER_SCORE:\n\t  return cg.snap->ps.persistant[PERS_SCORE];\n    break;\n  case CG_PLAYER_HEALTH:\n\t\treturn ps->stats[STAT_HEALTH];\n    break;\n  case CG_RED_SCORE:\n\t\treturn cgs.scores1;\n    break;\n  case CG_BLUE_SCORE:\n\t\treturn cgs.scores2;\n    break;\n  default:\n    break;\n  }\n\treturn -1;\n}\n\nqboolean CG_OtherTeamHasFlag() {\n\tif (cgs.gametype == GT_CTF || cgs.gametype == GT_1FCTF) {\n\t\tint team = cg.snap->ps.persistant[PERS_TEAM];\n\t\tif (cgs.gametype == GT_1FCTF) {\n\t\t\tif (team == TEAM_RED && cgs.flagStatus == FLAG_TAKEN_BLUE) {\n\t\t\t\treturn qtrue;\n\t\t\t} else if (team == TEAM_BLUE && cgs.flagStatus == FLAG_TAKEN_RED) {\n\t\t\t\treturn qtrue;\n\t\t\t} else {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t} else {\n\t\t\tif (team == TEAM_RED && cgs.redflag == FLAG_TAKEN) {\n\t\t\t\treturn qtrue;\n\t\t\t} else if (team == TEAM_BLUE && cgs.blueflag == FLAG_TAKEN) {\n\t\t\t\treturn qtrue;\n\t\t\t} else {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t}\n\t}\n\treturn qfalse;\n}\n\nqboolean CG_YourTeamHasFlag() {\n\tif (cgs.gametype == GT_CTF || cgs.gametype == GT_1FCTF) {\n\t\tint team = cg.snap->ps.persistant[PERS_TEAM];\n\t\tif (cgs.gametype == GT_1FCTF) {\n\t\t\tif (team == TEAM_RED && cgs.flagStatus == FLAG_TAKEN_RED) {\n\t\t\t\treturn qtrue;\n\t\t\t} else if (team == TEAM_BLUE && cgs.flagStatus == FLAG_TAKEN_BLUE) {\n\t\t\t\treturn qtrue;\n\t\t\t} else {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t} else {\n\t\t\tif (team == TEAM_RED && cgs.blueflag == FLAG_TAKEN) {\n\t\t\t\treturn qtrue;\n\t\t\t} else if (team == TEAM_BLUE && cgs.redflag == FLAG_TAKEN) {\n\t\t\t\treturn qtrue;\n\t\t\t} else {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n// THINKABOUTME: should these be exclusive or inclusive.. \n// \nqboolean CG_OwnerDrawVisible(int flags) {\n\n\tif (flags & CG_SHOW_TEAMINFO) {\n\t\treturn (cg_currentSelectedPlayer.integer == numSortedTeamPlayers);\n\t}\n\n\tif (flags & CG_SHOW_NOTEAMINFO) {\n\t\treturn !(cg_currentSelectedPlayer.integer == numSortedTeamPlayers);\n\t}\n\n\tif (flags & CG_SHOW_OTHERTEAMHASFLAG) {\n\t\treturn CG_OtherTeamHasFlag();\n\t}\n\n\tif (flags & CG_SHOW_YOURTEAMHASENEMYFLAG) {\n\t\treturn CG_YourTeamHasFlag();\n\t}\n\n\tif (flags & (CG_SHOW_BLUE_TEAM_HAS_REDFLAG | CG_SHOW_RED_TEAM_HAS_BLUEFLAG)) {\n\t\tif (flags & CG_SHOW_BLUE_TEAM_HAS_REDFLAG && (cgs.redflag == FLAG_TAKEN || cgs.flagStatus == FLAG_TAKEN_RED)) {\n\t\t\treturn qtrue;\n\t\t} else if (flags & CG_SHOW_RED_TEAM_HAS_BLUEFLAG && (cgs.blueflag == FLAG_TAKEN || cgs.flagStatus == FLAG_TAKEN_BLUE)) {\n\t\t\treturn qtrue;\n\t\t}\n\t\treturn qfalse;\n\t}\n\n\tif (flags & CG_SHOW_ANYTEAMGAME) {\n\t\tif( cgs.gametype >= GT_TEAM) {\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\n\tif (flags & CG_SHOW_ANYNONTEAMGAME) {\n\t\tif( cgs.gametype < GT_TEAM) {\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\n\tif (flags & CG_SHOW_HARVESTER) {\n\t\tif( cgs.gametype == GT_HARVESTER ) {\n\t\t\treturn qtrue;\n    } else {\n      return qfalse;\n    }\n\t}\n\n\tif (flags & CG_SHOW_ONEFLAG) {\n\t\tif( cgs.gametype == GT_1FCTF ) {\n\t\t\treturn qtrue;\n    } else {\n      return qfalse;\n    }\n\t}\n\n\tif (flags & CG_SHOW_CTF) {\n\t\tif( cgs.gametype == GT_CTF ) {\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\n\tif (flags & CG_SHOW_OBELISK) {\n\t\tif( cgs.gametype == GT_OBELISK ) {\n\t\t\treturn qtrue;\n    } else {\n      return qfalse;\n    }\n\t}\n\n\tif (flags & CG_SHOW_HEALTHCRITICAL) {\n\t\tif (cg.snap->ps.stats[STAT_HEALTH] < 25) {\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\n\tif (flags & CG_SHOW_HEALTHOK) {\n\t\tif (cg.snap->ps.stats[STAT_HEALTH] >= 25) {\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\n\tif (flags & CG_SHOW_SINGLEPLAYER) {\n\t\tif( cgs.gametype == GT_SINGLE_PLAYER ) {\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\n\tif (flags & CG_SHOW_TOURNAMENT) {\n\t\tif( cgs.gametype == GT_TOURNAMENT ) {\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\n\tif (flags & CG_SHOW_DURINGINCOMINGVOICE) {\n\t}\n\n\tif (flags & CG_SHOW_IF_PLAYER_HAS_FLAG) {\n\t\tif (cg.snap->ps.powerups[PW_REDFLAG] || cg.snap->ps.powerups[PW_BLUEFLAG] || cg.snap->ps.powerups[PW_NEUTRALFLAG]) {\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n\n\nstatic void CG_DrawPlayerHasFlag(rectDef_t *rect, qboolean force2D) {\n\tint adj = (force2D) ? 0 : 2;\n\tif( cg.predictedPlayerState.powerups[PW_REDFLAG] ) {\n  \tCG_DrawFlagModel( rect->x + adj, rect->y + adj, rect->w - adj, rect->h - adj, TEAM_RED, force2D);\n\t} else if( cg.predictedPlayerState.powerups[PW_BLUEFLAG] ) {\n  \tCG_DrawFlagModel( rect->x + adj, rect->y + adj, rect->w - adj, rect->h - adj, TEAM_BLUE, force2D);\n\t} else if( cg.predictedPlayerState.powerups[PW_NEUTRALFLAG] ) {\n  \tCG_DrawFlagModel( rect->x + adj, rect->y + adj, rect->w - adj, rect->h - adj, TEAM_FREE, force2D);\n\t}\n}\n\nstatic void CG_DrawAreaSystemChat(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader) {\n  CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, systemChat, 0, 0, 0);\n}\n\nstatic void CG_DrawAreaTeamChat(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader) {\n  CG_Text_Paint(rect->x, rect->y + rect->h, scale, color,teamChat1, 0, 0, 0);\n}\n\nstatic void CG_DrawAreaChat(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader) {\n  CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, teamChat2, 0, 0, 0);\n}\n\nconst char *CG_GetKillerText() {\n\tconst char *s = \"\";\n\tif ( cg.killerName[0] ) {\n\t\ts = va(\"Fragged by %s\", cg.killerName );\n\t}\n\treturn s;\n}\n\n\nstatic void CG_DrawKiller(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle ) {\n\t// fragged by ... line\n\tif ( cg.killerName[0] ) {\n\t\tint x = rect->x + rect->w / 2;\n\t  CG_Text_Paint(x - CG_Text_Width(CG_GetKillerText(), scale, 0) / 2, rect->y + rect->h, scale, color, CG_GetKillerText(), 0, 0, textStyle);\n\t}\n\t\n}\n\n\nstatic void CG_DrawCapFragLimit(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle) {\n\tint limit = (cgs.gametype >= GT_CTF) ? cgs.capturelimit : cgs.fraglimit;\n\tCG_Text_Paint(rect->x, rect->y, scale, color, va(\"%2i\", limit),0, 0, textStyle); \n}\n\nstatic void CG_Draw1stPlace(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle) {\n\tif (cgs.scores1 != SCORE_NOT_PRESENT) {\n\t\tCG_Text_Paint(rect->x, rect->y, scale, color, va(\"%2i\", cgs.scores1),0, 0, textStyle); \n\t}\n}\n\nstatic void CG_Draw2ndPlace(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle) {\n\tif (cgs.scores2 != SCORE_NOT_PRESENT) {\n\t\tCG_Text_Paint(rect->x, rect->y, scale, color, va(\"%2i\", cgs.scores2),0, 0, textStyle); \n\t}\n}\n\nconst char *CG_GetGameStatusText() {\n\tconst char *s = \"\";\n\tif ( cgs.gametype < GT_TEAM) {\n\t\tif (cg.snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR ) {\n\t\t\ts = va(\"%s place with %i\",CG_PlaceString( cg.snap->ps.persistant[PERS_RANK] + 1 ),cg.snap->ps.persistant[PERS_SCORE] );\n\t\t}\n\t} else {\n\t\tif ( cg.teamScores[0] == cg.teamScores[1] ) {\n\t\t\ts = va(\"Teams are tied at %i\", cg.teamScores[0] );\n\t\t} else if ( cg.teamScores[0] >= cg.teamScores[1] ) {\n\t\t\ts = va(\"Red leads Blue, %i to %i\", cg.teamScores[0], cg.teamScores[1] );\n\t\t} else {\n\t\t\ts = va(\"Blue leads Red, %i to %i\", cg.teamScores[1], cg.teamScores[0] );\n\t\t}\n\t}\n\treturn s;\n}\n\t\nstatic void CG_DrawGameStatus(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle ) {\n\tCG_Text_Paint(rect->x, rect->y + rect->h, scale, color, CG_GetGameStatusText(), 0, 0, textStyle);\n}\n\nconst char *CG_GameTypeString() {\n\tif ( cgs.gametype == GT_FFA ) {\n\t\treturn \"Free For All\";\n\t} else if ( cgs.gametype == GT_TEAM ) {\n\t\treturn \"Team Deathmatch\";\n\t} else if ( cgs.gametype == GT_CTF ) {\n\t\treturn \"Capture the Flag\";\n\t} else if ( cgs.gametype == GT_1FCTF ) {\n\t\treturn \"One Flag CTF\";\n\t} else if ( cgs.gametype == GT_OBELISK ) {\n\t\treturn \"Overload\";\n\t} else if ( cgs.gametype == GT_HARVESTER ) {\n\t\treturn \"Harvester\";\n\t}\n\treturn \"\";\n}\nstatic void CG_DrawGameType(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle ) {\n\tCG_Text_Paint(rect->x, rect->y + rect->h, scale, color, CG_GameTypeString(), 0, 0, textStyle);\n}\n\nstatic void CG_Text_Paint_Limit(float *maxX, float x, float y, float scale, vec4_t color, const char* text, float adjust, int limit) {\n  int len, count;\n\tvec4_t newColor;\n\tglyphInfo_t *glyph;\n  if (text) {\n// TTimo: FIXME\n//    const unsigned char *s = text; // bk001206 - unsigned\n    const char *s = text;\n\t\tfloat max = *maxX;\n\t\tfloat useScale;\n\t\tfontInfo_t *font = &cgDC.Assets.textFont;\n\t\tif (scale <= cg_smallFont.value) {\n\t\t\tfont = &cgDC.Assets.smallFont;\n\t\t} else if (scale > cg_bigFont.value) {\n\t\t\tfont = &cgDC.Assets.bigFont;\n\t\t}\n\t\tuseScale = scale * font->glyphScale;\n\t\ttrap_R_SetColor( color );\n    len = strlen(text);\t\t\t\t\t \n\t\tif (limit > 0 && len > limit) {\n\t\t\tlen = limit;\n\t\t}\n\t\tcount = 0;\n\t\twhile (s && *s && count < len) {\n\t\t\tglyph = &font->glyphs[(int)*s]; // TTimo: FIXME: getting nasty warnings without the cast, hopefully this doesn't break the VM build\n\t\t\tif ( Q_IsColorString( s ) ) {\n\t\t\t\tmemcpy( newColor, g_color_table[ColorIndex(*(s+1))], sizeof( newColor ) );\n\t\t\t\tnewColor[3] = color[3];\n\t\t\t\ttrap_R_SetColor( newColor );\n\t\t\t\ts += 2;\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t      float yadj = useScale * glyph->top;\n\t\t\t\tif (CG_Text_Width(s, useScale, 1) + x > max) {\n\t\t\t\t\t*maxX = 0;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t    CG_Text_PaintChar(x, y - yadj, \n\t\t\t                    glyph->imageWidth,\n\t\t\t\t                  glyph->imageHeight,\n\t\t\t\t\t                useScale, \n\t\t\t\t\t\t              glyph->s,\n\t\t\t\t\t\t\t            glyph->t,\n\t\t\t\t\t\t\t\t          glyph->s2,\n\t\t\t\t\t\t\t\t\t        glyph->t2,\n\t\t\t\t\t\t\t\t\t\t      glyph->glyph);\n\t      x += (glyph->xSkip * useScale) + adjust;\n\t\t\t\t*maxX = x;\n\t\t\t\tcount++;\n\t\t\t\ts++;\n\t    }\n\t\t}\n\t  trap_R_SetColor( NULL );\n  }\n\n}\n\n\n\n#define PIC_WIDTH 12\n\nvoid CG_DrawNewTeamInfo(rectDef_t *rect, float text_x, float text_y, float scale, vec4_t color, qhandle_t shader) {\n\tint xx;\n\tfloat y;\n\tint i, j, len, count;\n\tconst char *p;\n\tvec4_t\t\thcolor;\n\tfloat pwidth, lwidth, maxx, leftOver;\n\tclientInfo_t *ci;\n\tgitem_t\t*item;\n\tqhandle_t h;\n\n\t// max player name width\n\tpwidth = 0;\n\tcount = (numSortedTeamPlayers > 8) ? 8 : numSortedTeamPlayers;\n\tfor (i = 0; i < count; i++) {\n\t\tci = cgs.clientinfo + sortedTeamPlayers[i];\n\t\tif ( ci->infoValid && ci->team == cg.snap->ps.persistant[PERS_TEAM]) {\n\t\t\tlen = CG_Text_Width( ci->name, scale, 0);\n\t\t\tif (len > pwidth)\n\t\t\t\tpwidth = len;\n\t\t}\n\t}\n\n\t// max location name width\n\tlwidth = 0;\n\tfor (i = 1; i < MAX_LOCATIONS; i++) {\n\t\tp = CG_ConfigString(CS_LOCATIONS + i);\n\t\tif (p && *p) {\n\t\t\tlen = CG_Text_Width(p, scale, 0);\n\t\t\tif (len > lwidth)\n\t\t\t\tlwidth = len;\n\t\t}\n\t}\n\n\ty = rect->y;\n\n\tfor (i = 0; i < count; i++) {\n\t\tci = cgs.clientinfo + sortedTeamPlayers[i];\n\t\tif ( ci->infoValid && ci->team == cg.snap->ps.persistant[PERS_TEAM]) {\n\n\t\t\txx = rect->x + 1;\n\t\t\tfor (j = 0; j <= PW_NUM_POWERUPS; j++) {\n\t\t\t\tif (ci->powerups & (1 << j)) {\n\n\t\t\t\t\titem = BG_FindItemForPowerup( j );\n\n\t\t\t\t\tif (item) {\n\t\t\t\t\t\tCG_DrawPic( xx, y, PIC_WIDTH, PIC_WIDTH, trap_R_RegisterShader( item->icon ) );\n\t\t\t\t\t\txx += PIC_WIDTH;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// FIXME: max of 3 powerups shown properly\n\t\t\txx = rect->x + (PIC_WIDTH * 3) + 2;\n\n\t\t\tCG_GetColorForHealth( ci->health, ci->armor, hcolor );\n\t\t\ttrap_R_SetColor(hcolor);\n\t\t\tCG_DrawPic( xx, y + 1, PIC_WIDTH - 2, PIC_WIDTH - 2, cgs.media.heartShader );\n\n\t\t\t//Com_sprintf (st, sizeof(st), \"%3i %3i\", ci->health,\tci->armor);\n\t\t\t//CG_Text_Paint(xx, y + text_y, scale, hcolor, st, 0, 0); \n\n\t\t\t// draw weapon icon\n\t\t\txx += PIC_WIDTH + 1;\n\n// weapon used is not that useful, use the space for task\n#if 0\n\t\t\tif ( cg_weapons[ci->curWeapon].weaponIcon ) {\n\t\t\t\tCG_DrawPic( xx, y, PIC_WIDTH, PIC_WIDTH, cg_weapons[ci->curWeapon].weaponIcon );\n\t\t\t} else {\n\t\t\t\tCG_DrawPic( xx, y, PIC_WIDTH, PIC_WIDTH, cgs.media.deferShader );\n\t\t\t}\n#endif\n\n\t\t\ttrap_R_SetColor(NULL);\n\t\t\tif (cgs.orderPending) {\n\t\t\t\t// blink the icon\n\t\t\t\tif ( cg.time > cgs.orderTime - 2500 && (cg.time >> 9 ) & 1 ) {\n\t\t\t\t\th = 0;\n\t\t\t\t} else {\n\t\t\t\t\th = CG_StatusHandle(cgs.currentOrder);\n\t\t\t\t}\n\t\t\t}\telse {\n\t\t\t\th = CG_StatusHandle(ci->teamTask);\n\t\t\t}\n\n\t\t\tif (h) {\n\t\t\t\tCG_DrawPic( xx, y, PIC_WIDTH, PIC_WIDTH, h);\n\t\t\t}\n\n\t\t\txx += PIC_WIDTH + 1;\n\n\t\t\tleftOver = rect->w - xx;\n\t\t\tmaxx = xx + leftOver / 3;\n\n\n\n\t\t\tCG_Text_Paint_Limit(&maxx, xx, y + text_y, scale, color, ci->name, 0, 0); \n\n\t\t\tp = CG_ConfigString(CS_LOCATIONS + ci->location);\n\t\t\tif (!p || !*p) {\n\t\t\t\tp = \"unknown\";\n\t\t\t}\n\n\t\t\txx += leftOver / 3 + 2;\n\t\t\tmaxx = rect->w - 4;\n\n\t\t\tCG_Text_Paint_Limit(&maxx, xx, y + text_y, scale, color, p, 0, 0); \n\t\t\ty += text_y + 2;\n\t\t\tif ( y + text_y + 2 > rect->y + rect->h ) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t}\n\t}\n}\n\n\nvoid CG_DrawTeamSpectators(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader) {\n\tif (cg.spectatorLen) {\n\t\tfloat maxX;\n\n\t\tif (cg.spectatorWidth == -1) {\n\t\t\tcg.spectatorWidth = 0;\n\t\t\tcg.spectatorPaintX = rect->x + 1;\n\t\t\tcg.spectatorPaintX2 = -1;\n\t\t}\n\n\t\tif (cg.spectatorOffset > cg.spectatorLen) {\n\t\t\tcg.spectatorOffset = 0;\n\t\t\tcg.spectatorPaintX = rect->x + 1;\n\t\t\tcg.spectatorPaintX2 = -1;\n\t\t}\n\n\t\tif (cg.time > cg.spectatorTime) {\n\t\t\tcg.spectatorTime = cg.time + 10;\n\t\t\tif (cg.spectatorPaintX <= rect->x + 2) {\n\t\t\t\tif (cg.spectatorOffset < cg.spectatorLen) {\n\t\t\t\t\tcg.spectatorPaintX += CG_Text_Width(&cg.spectatorList[cg.spectatorOffset], scale, 1) - 1;\n\t\t\t\t\tcg.spectatorOffset++;\n\t\t\t\t} else {\n\t\t\t\t\tcg.spectatorOffset = 0;\n\t\t\t\t\tif (cg.spectatorPaintX2 >= 0) {\n\t\t\t\t\t\tcg.spectatorPaintX = cg.spectatorPaintX2;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcg.spectatorPaintX = rect->x + rect->w - 2;\n\t\t\t\t\t}\n\t\t\t\t\tcg.spectatorPaintX2 = -1;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcg.spectatorPaintX--;\n\t\t\t\tif (cg.spectatorPaintX2 >= 0) {\n\t\t\t\t\tcg.spectatorPaintX2--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tmaxX = rect->x + rect->w - 2;\n\t\tCG_Text_Paint_Limit(&maxX, cg.spectatorPaintX, rect->y + rect->h - 3, scale, color, &cg.spectatorList[cg.spectatorOffset], 0, 0); \n\t\tif (cg.spectatorPaintX2 >= 0) {\n\t\t\tfloat maxX2 = rect->x + rect->w - 2;\n\t\t\tCG_Text_Paint_Limit(&maxX2, cg.spectatorPaintX2, rect->y + rect->h - 3, scale, color, cg.spectatorList, 0, cg.spectatorOffset); \n\t\t}\n\t\tif (cg.spectatorOffset && maxX > 0) {\n\t\t\t// if we have an offset ( we are skipping the first part of the string ) and we fit the string\n\t\t\tif (cg.spectatorPaintX2 == -1) {\n\t\t\t\t\t\tcg.spectatorPaintX2 = rect->x + rect->w - 2;\n\t\t\t}\n\t\t} else {\n\t\t\tcg.spectatorPaintX2 = -1;\n\t\t}\n\n\t}\n}\n\n\n\nvoid CG_DrawMedal(int ownerDraw, rectDef_t *rect, float scale, vec4_t color, qhandle_t shader) {\n\tscore_t *score = &cg.scores[cg.selectedScore];\n\tfloat value = 0;\n\tchar *text = NULL;\n\tcolor[3] = 0.25;\n\n\tswitch (ownerDraw) {\n\t\tcase CG_ACCURACY:\n\t\t\tvalue = score->accuracy;\n\t\t\tbreak;\n\t\tcase CG_ASSISTS:\n\t\t\tvalue = score->assistCount;\n\t\t\tbreak;\n\t\tcase CG_DEFEND:\n\t\t\tvalue = score->defendCount;\n\t\t\tbreak;\n\t\tcase CG_EXCELLENT:\n\t\t\tvalue = score->excellentCount;\n\t\t\tbreak;\n\t\tcase CG_IMPRESSIVE:\n\t\t\tvalue = score->impressiveCount;\n\t\t\tbreak;\n\t\tcase CG_PERFECT:\n\t\t\tvalue = score->perfect;\n\t\t\tbreak;\n\t\tcase CG_GAUNTLET:\n\t\t\tvalue = score->guantletCount;\n\t\t\tbreak;\n\t\tcase CG_CAPTURES:\n\t\t\tvalue = score->captures;\n\t\t\tbreak;\n\t}\n\n\tif (value > 0) {\n\t\tif (ownerDraw != CG_PERFECT) {\n\t\t\tif (ownerDraw == CG_ACCURACY) {\n\t\t\t\ttext = va(\"%i%%\", (int)value);\n\t\t\t\tif (value > 50) {\n\t\t\t\t\tcolor[3] = 1.0;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttext = va(\"%i\", (int)value);\n\t\t\t\tcolor[3] = 1.0;\n\t\t\t}\n\t\t} else {\n\t\t\tif (value) {\n\t\t\t\tcolor[3] = 1.0;\n\t\t\t}\n\t\t\ttext = \"Wow\";\n\t\t}\n\t}\n\n\ttrap_R_SetColor(color);\n\tCG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader );\n\n\tif (text) {\n\t\tcolor[3] = 1.0;\n\t\tvalue = CG_Text_Width(text, scale, 0);\n\t\tCG_Text_Paint(rect->x + (rect->w - value) / 2, rect->y + rect->h + 10 , scale, color, text, 0, 0, 0);\n\t}\n\ttrap_R_SetColor(NULL);\n\n}\n\n\t\n//\nvoid CG_OwnerDraw(float x, float y, float w, float h, float text_x, float text_y, int ownerDraw, int ownerDrawFlags, int align, float special, float scale, vec4_t color, qhandle_t shader, int textStyle) {\n\trectDef_t rect;\n\n  if ( cg_drawStatus.integer == 0 ) {\n\t\treturn;\n\t}\n\n\t//if (ownerDrawFlags != 0 && !CG_OwnerDrawVisible(ownerDrawFlags)) {\n\t//\treturn;\n\t//}\n\n  rect.x = x;\n  rect.y = y;\n  rect.w = w;\n  rect.h = h;\n\n  switch (ownerDraw) {\n  case CG_PLAYER_ARMOR_ICON:\n    CG_DrawPlayerArmorIcon(&rect, ownerDrawFlags & CG_SHOW_2DONLY);\n    break;\n  case CG_PLAYER_ARMOR_ICON2D:\n    CG_DrawPlayerArmorIcon(&rect, qtrue);\n    break;\n  case CG_PLAYER_ARMOR_VALUE:\n    CG_DrawPlayerArmorValue(&rect, scale, color, shader, textStyle);\n    break;\n  case CG_PLAYER_AMMO_ICON:\n    CG_DrawPlayerAmmoIcon(&rect, ownerDrawFlags & CG_SHOW_2DONLY);\n    break;\n  case CG_PLAYER_AMMO_ICON2D:\n    CG_DrawPlayerAmmoIcon(&rect, qtrue);\n    break;\n  case CG_PLAYER_AMMO_VALUE:\n    CG_DrawPlayerAmmoValue(&rect, scale, color, shader, textStyle);\n    break;\n  case CG_SELECTEDPLAYER_HEAD:\n    CG_DrawSelectedPlayerHead(&rect, ownerDrawFlags & CG_SHOW_2DONLY, qfalse);\n    break;\n  case CG_VOICE_HEAD:\n    CG_DrawSelectedPlayerHead(&rect, ownerDrawFlags & CG_SHOW_2DONLY, qtrue);\n    break;\n  case CG_VOICE_NAME:\n    CG_DrawSelectedPlayerName(&rect, scale, color, qtrue, textStyle);\n    break;\n  case CG_SELECTEDPLAYER_STATUS:\n    CG_DrawSelectedPlayerStatus(&rect);\n    break;\n  case CG_SELECTEDPLAYER_ARMOR:\n    CG_DrawSelectedPlayerArmor(&rect, scale, color, shader, textStyle);\n    break;\n  case CG_SELECTEDPLAYER_HEALTH:\n    CG_DrawSelectedPlayerHealth(&rect, scale, color, shader, textStyle);\n    break;\n  case CG_SELECTEDPLAYER_NAME:\n    CG_DrawSelectedPlayerName(&rect, scale, color, qfalse, textStyle);\n    break;\n  case CG_SELECTEDPLAYER_LOCATION:\n    CG_DrawSelectedPlayerLocation(&rect, scale, color, textStyle);\n    break;\n  case CG_SELECTEDPLAYER_WEAPON:\n    CG_DrawSelectedPlayerWeapon(&rect);\n    break;\n  case CG_SELECTEDPLAYER_POWERUP:\n    CG_DrawSelectedPlayerPowerup(&rect, ownerDrawFlags & CG_SHOW_2DONLY);\n    break;\n  case CG_PLAYER_HEAD:\n    CG_DrawPlayerHead(&rect, ownerDrawFlags & CG_SHOW_2DONLY);\n    break;\n  case CG_PLAYER_ITEM:\n    CG_DrawPlayerItem(&rect, scale, ownerDrawFlags & CG_SHOW_2DONLY);\n    break;\n  case CG_PLAYER_SCORE:\n    CG_DrawPlayerScore(&rect, scale, color, shader, textStyle);\n    break;\n  case CG_PLAYER_HEALTH:\n    CG_DrawPlayerHealth(&rect, scale, color, shader, textStyle);\n    break;\n  case CG_RED_SCORE:\n    CG_DrawRedScore(&rect, scale, color, shader, textStyle);\n    break;\n  case CG_BLUE_SCORE:\n    CG_DrawBlueScore(&rect, scale, color, shader, textStyle);\n    break;\n  case CG_RED_NAME:\n    CG_DrawRedName(&rect, scale, color, textStyle);\n    break;\n  case CG_BLUE_NAME:\n    CG_DrawBlueName(&rect, scale, color, textStyle);\n    break;\n  case CG_BLUE_FLAGHEAD:\n    CG_DrawBlueFlagHead(&rect);\n    break;\n  case CG_BLUE_FLAGSTATUS:\n    CG_DrawBlueFlagStatus(&rect, shader);\n    break;\n  case CG_BLUE_FLAGNAME:\n    CG_DrawBlueFlagName(&rect, scale, color, textStyle);\n    break;\n  case CG_RED_FLAGHEAD:\n    CG_DrawRedFlagHead(&rect);\n    break;\n  case CG_RED_FLAGSTATUS:\n    CG_DrawRedFlagStatus(&rect, shader);\n    break;\n  case CG_RED_FLAGNAME:\n    CG_DrawRedFlagName(&rect, scale, color, textStyle);\n    break;\n  case CG_HARVESTER_SKULLS:\n    CG_HarvesterSkulls(&rect, scale, color, qfalse, textStyle);\n    break;\n  case CG_HARVESTER_SKULLS2D:\n    CG_HarvesterSkulls(&rect, scale, color, qtrue, textStyle);\n    break;\n  case CG_ONEFLAG_STATUS:\n    CG_OneFlagStatus(&rect);\n    break;\n  case CG_PLAYER_LOCATION:\n    CG_DrawPlayerLocation(&rect, scale, color, textStyle);\n    break;\n  case CG_TEAM_COLOR:\n    CG_DrawTeamColor(&rect, color);\n    break;\n  case CG_CTF_POWERUP:\n    CG_DrawCTFPowerUp(&rect);\n    break;\n  case CG_AREA_POWERUP:\n\t\tCG_DrawAreaPowerUp(&rect, align, special, scale, color);\n    break;\n  case CG_PLAYER_STATUS:\n    CG_DrawPlayerStatus(&rect);\n    break;\n  case CG_PLAYER_HASFLAG:\n    CG_DrawPlayerHasFlag(&rect, qfalse);\n    break;\n  case CG_PLAYER_HASFLAG2D:\n    CG_DrawPlayerHasFlag(&rect, qtrue);\n    break;\n  case CG_AREA_SYSTEMCHAT:\n    CG_DrawAreaSystemChat(&rect, scale, color, shader);\n    break;\n  case CG_AREA_TEAMCHAT:\n    CG_DrawAreaTeamChat(&rect, scale, color, shader);\n    break;\n  case CG_AREA_CHAT:\n    CG_DrawAreaChat(&rect, scale, color, shader);\n    break;\n  case CG_GAME_TYPE:\n    CG_DrawGameType(&rect, scale, color, shader, textStyle);\n    break;\n  case CG_GAME_STATUS:\n    CG_DrawGameStatus(&rect, scale, color, shader, textStyle);\n\t\tbreak;\n  case CG_KILLER:\n    CG_DrawKiller(&rect, scale, color, shader, textStyle);\n\t\tbreak;\n\tcase CG_ACCURACY:\n\tcase CG_ASSISTS:\n\tcase CG_DEFEND:\n\tcase CG_EXCELLENT:\n\tcase CG_IMPRESSIVE:\n\tcase CG_PERFECT:\n\tcase CG_GAUNTLET:\n\tcase CG_CAPTURES:\n\t\tCG_DrawMedal(ownerDraw, &rect, scale, color, shader);\n\t\tbreak;\n  case CG_SPECTATORS:\n\t\tCG_DrawTeamSpectators(&rect, scale, color, shader);\n\t\tbreak;\n  case CG_TEAMINFO:\n\t\tif (cg_currentSelectedPlayer.integer == numSortedTeamPlayers) {\n\t\t\tCG_DrawNewTeamInfo(&rect, text_x, text_y, scale, color, shader);\n\t\t}\n\t\tbreak;\n  case CG_CAPFRAGLIMIT:\n    CG_DrawCapFragLimit(&rect, scale, color, shader, textStyle);\n\t\tbreak;\n  case CG_1STPLACE:\n    CG_Draw1stPlace(&rect, scale, color, shader, textStyle);\n\t\tbreak;\n  case CG_2NDPLACE:\n    CG_Draw2ndPlace(&rect, scale, color, shader, textStyle);\n\t\tbreak;\n  default:\n    break;\n  }\n}\n\nvoid CG_MouseEvent(int x, int y) {\n\tint n;\n\n\tif ( (cg.predictedPlayerState.pm_type == PM_NORMAL || cg.predictedPlayerState.pm_type == PM_SPECTATOR) && cg.showScores == qfalse) {\n    trap_Key_SetCatcher(0);\n\t\treturn;\n\t}\n\n\tcgs.cursorX+= x;\n\tif (cgs.cursorX < 0)\n\t\tcgs.cursorX = 0;\n\telse if (cgs.cursorX > 640)\n\t\tcgs.cursorX = 640;\n\n\tcgs.cursorY += y;\n\tif (cgs.cursorY < 0)\n\t\tcgs.cursorY = 0;\n\telse if (cgs.cursorY > 480)\n\t\tcgs.cursorY = 480;\n\n\tn = Display_CursorType(cgs.cursorX, cgs.cursorY);\n\tcgs.activeCursor = 0;\n\tif (n == CURSOR_ARROW) {\n\t\tcgs.activeCursor = cgs.media.selectCursor;\n\t} else if (n == CURSOR_SIZER) {\n\t\tcgs.activeCursor = cgs.media.sizeCursor;\n\t}\n\n  if (cgs.capturedItem) {\n\t  Display_MouseMove(cgs.capturedItem, x, y);\n  } else {\n\t  Display_MouseMove(NULL, cgs.cursorX, cgs.cursorY);\n  }\n\n}\n\n/*\n==================\nCG_HideTeamMenus\n==================\n\n*/\nvoid CG_HideTeamMenu() {\n  Menus_CloseByName(\"teamMenu\");\n  Menus_CloseByName(\"getMenu\");\n}\n\n/*\n==================\nCG_ShowTeamMenus\n==================\n\n*/\nvoid CG_ShowTeamMenu() {\n  Menus_OpenByName(\"teamMenu\");\n}\n\n\n\n\n/*\n==================\nCG_EventHandling\n==================\n type 0 - no event handling\n      1 - team menu\n      2 - hud editor\n\n*/\nvoid CG_EventHandling(int type) {\n\tcgs.eventHandling = type;\n  if (type == CGAME_EVENT_NONE) {\n    CG_HideTeamMenu();\n  } else if (type == CGAME_EVENT_TEAMMENU) {\n    //CG_ShowTeamMenu();\n  } else if (type == CGAME_EVENT_SCOREBOARD) {\n  }\n\n}\n\n\n\nvoid CG_KeyEvent(int key, qboolean down) {\n\n\tif (!down) {\n\t\treturn;\n\t}\n\n\tif ( cg.predictedPlayerState.pm_type == PM_NORMAL || (cg.predictedPlayerState.pm_type == PM_SPECTATOR && cg.showScores == qfalse)) {\n\t\tCG_EventHandling(CGAME_EVENT_NONE);\n    trap_Key_SetCatcher(0);\n\t\treturn;\n\t}\n\n  //if (key == trap_Key_GetKey(\"teamMenu\") || !Display_CaptureItem(cgs.cursorX, cgs.cursorY)) {\n    // if we see this then we should always be visible\n  //  CG_EventHandling(CGAME_EVENT_NONE);\n  //  trap_Key_SetCatcher(0);\n  //}\n\n\n\n  Display_HandleKey(key, down, cgs.cursorX, cgs.cursorY);\n\n\tif (cgs.capturedItem) {\n\t\tcgs.capturedItem = NULL;\n\t}\telse {\n\t\tif (key == K_MOUSE2 && down) {\n\t\t\tcgs.capturedItem = Display_CaptureItem(cgs.cursorX, cgs.cursorY);\n\t\t}\n\t}\n}\n\nint CG_ClientNumFromName(const char *p) {\n  int i;\n  for (i = 0; i < cgs.maxclients; i++) {\n    if (cgs.clientinfo[i].infoValid && Q_stricmp(cgs.clientinfo[i].name, p) == 0) {\n      return i;\n    }\n  }\n  return -1;\n}\n\nvoid CG_ShowResponseHead() {\n  Menus_OpenByName(\"voiceMenu\");\n\ttrap_Cvar_Set(\"cl_conXOffset\", \"72\");\n\tcg.voiceTime = cg.time;\n}\n\nvoid CG_RunMenuScript(char **args) {\n}\n\n\nvoid CG_GetTeamColor(vec4_t *color) {\n  if (cg.snap->ps.persistant[PERS_TEAM] == TEAM_RED) {\n    (*color)[0] = 1.0f;\n    (*color)[3] = 0.25f;\n    (*color)[1] = (*color)[2] = 0.0f;\n  } else if (cg.snap->ps.persistant[PERS_TEAM] == TEAM_BLUE) {\n    (*color)[0] = (*color)[1] = 0.0f;\n    (*color)[2] = 1.0f;\n    (*color)[3] = 0.25f;\n  } else {\n    (*color)[0] = (*color)[2] = 0.0f;\n    (*color)[1] = 0.17f;\n    (*color)[3] = 0.25f;\n\t}\n}\n\n"
  },
  {
    "path": "code/cgame/cg_particles.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// Rafael particles\n// cg_particles.c  \n\n#include \"cg_local.h\"\n\n#define BLOODRED\t2\n#define EMISIVEFADE\t3\n#define GREY75\t\t4\n\ntypedef struct particle_s\n{\n\tstruct particle_s\t*next;\n\n\tfloat\t\ttime;\n\tfloat\t\tendtime;\n\n\tvec3_t\t\torg;\n\tvec3_t\t\tvel;\n\tvec3_t\t\taccel;\n\tint\t\t\tcolor;\n\tfloat\t\tcolorvel;\n\tfloat\t\talpha;\n\tfloat\t\talphavel;\n\tint\t\t\ttype;\n\tqhandle_t\tpshader;\n\t\n\tfloat\t\theight;\n\tfloat\t\twidth;\n\t\t\t\t\n\tfloat\t\tendheight;\n\tfloat\t\tendwidth;\n\t\n\tfloat\t\tstart;\n\tfloat\t\tend;\n\n\tfloat\t\tstartfade;\n\tqboolean\trotate;\n\tint\t\t\tsnum;\n\t\n\tqboolean\tlink;\n\n\t// Ridah\n\tint\t\t\tshaderAnim;\n\tint\t\t\troll;\n\n\tint\t\t\taccumroll;\n\n} cparticle_t;\n\ntypedef enum\n{\n\tP_NONE,\n\tP_WEATHER,\n\tP_FLAT,\n\tP_SMOKE,\n\tP_ROTATE,\n\tP_WEATHER_TURBULENT,\n\tP_ANIM,\t// Ridah\n\tP_BAT,\n\tP_BLEED,\n\tP_FLAT_SCALEUP,\n\tP_FLAT_SCALEUP_FADE,\n\tP_WEATHER_FLURRY,\n\tP_SMOKE_IMPACT,\n\tP_BUBBLE,\n\tP_BUBBLE_TURBULENT,\n\tP_SPRITE\n} particle_type_t;\n\n#define\tMAX_SHADER_ANIMS\t\t32\n#define\tMAX_SHADER_ANIM_FRAMES\t64\n\nstatic char *shaderAnimNames[MAX_SHADER_ANIMS] = {\n\t\"explode1\",\n\t\"blacksmokeanim\",\n\t\"twiltb2\",\n\t\"expblue\",\n\t\"blacksmokeanimb\",\t// uses 'explode1' sequence\n\t\"blood\",\n\tNULL\n};\nstatic qhandle_t shaderAnims[MAX_SHADER_ANIMS][MAX_SHADER_ANIM_FRAMES];\nstatic int\tshaderAnimCounts[MAX_SHADER_ANIMS] = {\n\t23,\n\t25,\n\t45,\n\t25,\n\t23,\n\t5,\n};\nstatic float\tshaderAnimSTRatio[MAX_SHADER_ANIMS] = {\n\t1.405f,\n\t1.0f,\n\t1.0f,\n\t1.0f,\n\t1.0f,\n\t1.0f,\n};\nstatic int\tnumShaderAnims;\n// done.\n\n#define\t\tPARTICLE_GRAVITY\t40\n#define\t\tMAX_PARTICLES\t1024 * 8\n\ncparticle_t\t*active_particles, *free_particles;\ncparticle_t\tparticles[MAX_PARTICLES];\nint\t\tcl_numparticles = MAX_PARTICLES;\n\nqboolean\t\tinitparticles = qfalse;\nvec3_t\t\t\tvforward, vright, vup;\nvec3_t\t\t\trforward, rright, rup;\n\nfloat\t\t\toldtime;\n\n/*\n===============\nCL_ClearParticles\n===============\n*/\nvoid CG_ClearParticles (void)\n{\n\tint\t\ti;\n\n\tmemset( particles, 0, sizeof(particles) );\n\n\tfree_particles = &particles[0];\n\tactive_particles = NULL;\n\n\tfor (i=0 ;i<cl_numparticles ; i++)\n\t{\n\t\tparticles[i].next = &particles[i+1];\n\t\tparticles[i].type = 0;\n\t}\n\tparticles[cl_numparticles-1].next = NULL;\n\n\toldtime = cg.time;\n\n\t// Ridah, init the shaderAnims\n\tfor (i=0; shaderAnimNames[i]; i++) {\n\t\tint j;\n\n\t\tfor (j=0; j<shaderAnimCounts[i]; j++) {\n\t\t\tshaderAnims[i][j] = trap_R_RegisterShader( va(\"%s%i\", shaderAnimNames[i], j+1) );\n\t\t}\n\t}\n\tnumShaderAnims = i;\n\t// done.\n\n\tinitparticles = qtrue;\n}\n\n\n/*\n=====================\nCG_AddParticleToScene\n=====================\n*/\nvoid CG_AddParticleToScene (cparticle_t *p, vec3_t org, float alpha)\n{\n\n\tvec3_t\t\tpoint;\n\tpolyVert_t\tverts[4];\n\tfloat\t\twidth;\n\tfloat\t\theight;\n\tfloat\t\ttime, time2;\n\tfloat\t\tratio;\n\tfloat\t\tinvratio;\n\tvec3_t\t\tcolor;\n\tpolyVert_t\tTRIverts[3];\n\tvec3_t\t\trright2, rup2;\n\n\tif (p->type == P_WEATHER || p->type == P_WEATHER_TURBULENT || p->type == P_WEATHER_FLURRY\n\t\t|| p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT)\n\t{// create a front facing polygon\n\t\t\t\n\t\tif (p->type != P_WEATHER_FLURRY)\n\t\t{\n\t\t\tif (p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT)\n\t\t\t{\n\t\t\t\tif (org[2] > p->end)\t\t\t\n\t\t\t\t{\t\n\t\t\t\t\tp->time = cg.time;\t\n\t\t\t\t\tVectorCopy (org, p->org); // Ridah, fixes rare snow flakes that flicker on the ground\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tp->org[2] = ( p->start + crandom () * 4 );\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tif (p->type == P_BUBBLE_TURBULENT)\n\t\t\t\t\t{\n\t\t\t\t\t\tp->vel[0] = crandom() * 4;\n\t\t\t\t\t\tp->vel[1] = crandom() * 4;\n\t\t\t\t\t}\n\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (org[2] < p->end)\t\t\t\n\t\t\t\t{\t\n\t\t\t\t\tp->time = cg.time;\t\n\t\t\t\t\tVectorCopy (org, p->org); // Ridah, fixes rare snow flakes that flicker on the ground\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\twhile (p->org[2] < p->end) \n\t\t\t\t\t{\n\t\t\t\t\t\tp->org[2] += (p->start - p->end); \n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tif (p->type == P_WEATHER_TURBULENT)\n\t\t\t\t\t{\n\t\t\t\t\t\tp->vel[0] = crandom() * 16;\n\t\t\t\t\t\tp->vel[1] = crandom() * 16;\n\t\t\t\t\t}\n\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\n\t\t\t// Rafael snow pvs check\n\t\t\tif (!p->link)\n\t\t\t\treturn;\n\n\t\t\tp->alpha = 1;\n\t\t}\n\t\t\n\t\t// Ridah, had to do this or MAX_POLYS is being exceeded in village1.bsp\n\t\tif (Distance( cg.snap->ps.origin, org ) > 1024) {\n\t\t\treturn;\n\t\t}\n\t\t// done.\n\t\n\t\tif (p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT)\n\t\t{\n\t\t\tVectorMA (org, -p->height, vup, point);\t\n\t\t\tVectorMA (point, -p->width, vright, point);\t\n\t\t\tVectorCopy (point, verts[0].xyz);\t\n\t\t\tverts[0].st[0] = 0;\t\n\t\t\tverts[0].st[1] = 0;\t\n\t\t\tverts[0].modulate[0] = 255;\t\n\t\t\tverts[0].modulate[1] = 255;\t\n\t\t\tverts[0].modulate[2] = 255;\t\n\t\t\tverts[0].modulate[3] = 255 * p->alpha;\t\n\n\t\t\tVectorMA (org, -p->height, vup, point);\t\n\t\t\tVectorMA (point, p->width, vright, point);\t\n\t\t\tVectorCopy (point, verts[1].xyz);\t\n\t\t\tverts[1].st[0] = 0;\t\n\t\t\tverts[1].st[1] = 1;\t\n\t\t\tverts[1].modulate[0] = 255;\t\n\t\t\tverts[1].modulate[1] = 255;\t\n\t\t\tverts[1].modulate[2] = 255;\t\n\t\t\tverts[1].modulate[3] = 255 * p->alpha;\t\n\n\t\t\tVectorMA (org, p->height, vup, point);\t\n\t\t\tVectorMA (point, p->width, vright, point);\t\n\t\t\tVectorCopy (point, verts[2].xyz);\t\n\t\t\tverts[2].st[0] = 1;\t\n\t\t\tverts[2].st[1] = 1;\t\n\t\t\tverts[2].modulate[0] = 255;\t\n\t\t\tverts[2].modulate[1] = 255;\t\n\t\t\tverts[2].modulate[2] = 255;\t\n\t\t\tverts[2].modulate[3] = 255 * p->alpha;\t\n\n\t\t\tVectorMA (org, p->height, vup, point);\t\n\t\t\tVectorMA (point, -p->width, vright, point);\t\n\t\t\tVectorCopy (point, verts[3].xyz);\t\n\t\t\tverts[3].st[0] = 1;\t\n\t\t\tverts[3].st[1] = 0;\t\n\t\t\tverts[3].modulate[0] = 255;\t\n\t\t\tverts[3].modulate[1] = 255;\t\n\t\t\tverts[3].modulate[2] = 255;\t\n\t\t\tverts[3].modulate[3] = 255 * p->alpha;\t\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVectorMA (org, -p->height, vup, point);\t\n\t\t\tVectorMA (point, -p->width, vright, point);\t\n\t\t\tVectorCopy( point, TRIverts[0].xyz );\n\t\t\tTRIverts[0].st[0] = 1;\n\t\t\tTRIverts[0].st[1] = 0;\n\t\t\tTRIverts[0].modulate[0] = 255;\n\t\t\tTRIverts[0].modulate[1] = 255;\n\t\t\tTRIverts[0].modulate[2] = 255;\n\t\t\tTRIverts[0].modulate[3] = 255 * p->alpha;\t\n\n\t\t\tVectorMA (org, p->height, vup, point);\t\n\t\t\tVectorMA (point, -p->width, vright, point);\t\n\t\t\tVectorCopy (point, TRIverts[1].xyz);\t\n\t\t\tTRIverts[1].st[0] = 0;\n\t\t\tTRIverts[1].st[1] = 0;\n\t\t\tTRIverts[1].modulate[0] = 255;\n\t\t\tTRIverts[1].modulate[1] = 255;\n\t\t\tTRIverts[1].modulate[2] = 255;\n\t\t\tTRIverts[1].modulate[3] = 255 * p->alpha;\t\n\n\t\t\tVectorMA (org, p->height, vup, point);\t\n\t\t\tVectorMA (point, p->width, vright, point);\t\n\t\t\tVectorCopy (point, TRIverts[2].xyz);\t\n\t\t\tTRIverts[2].st[0] = 0;\n\t\t\tTRIverts[2].st[1] = 1;\n\t\t\tTRIverts[2].modulate[0] = 255;\n\t\t\tTRIverts[2].modulate[1] = 255;\n\t\t\tTRIverts[2].modulate[2] = 255;\n\t\t\tTRIverts[2].modulate[3] = 255 * p->alpha;\t\n\t\t}\n\t\n\t}\n\telse if (p->type == P_SPRITE)\n\t{\n\t\tvec3_t\trr, ru;\n\t\tvec3_t\trotate_ang;\n\n\t\tVectorSet (color, 1.0, 1.0, 1.0);\n\t\ttime = cg.time - p->time;\n\t\ttime2 = p->endtime - p->time;\n\t\tratio = time / time2;\n\n\t\twidth = p->width + ( ratio * ( p->endwidth - p->width) );\n\t\theight = p->height + ( ratio * ( p->endheight - p->height) );\n\n\t\tif (p->roll) {\n\t\t\tvectoangles( cg.refdef.viewaxis[0], rotate_ang );\n\t\t\trotate_ang[ROLL] += p->roll;\n\t\t\tAngleVectors ( rotate_ang, NULL, rr, ru);\n\t\t}\n\n\t\tif (p->roll) {\n\t\t\tVectorMA (org, -height, ru, point);\t\n\t\t\tVectorMA (point, -width, rr, point);\t\n\t\t} else {\n\t\t\tVectorMA (org, -height, vup, point);\t\n\t\t\tVectorMA (point, -width, vright, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[0].xyz);\t\n\t\tverts[0].st[0] = 0;\t\n\t\tverts[0].st[1] = 0;\t\n\t\tverts[0].modulate[0] = 255;\t\n\t\tverts[0].modulate[1] = 255;\t\n\t\tverts[0].modulate[2] = 255;\t\n\t\tverts[0].modulate[3] = 255;\n\n\t\tif (p->roll) {\n\t\t\tVectorMA (point, 2*height, ru, point);\t\n\t\t} else {\n\t\t\tVectorMA (point, 2*height, vup, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[1].xyz);\t\n\t\tverts[1].st[0] = 0;\t\n\t\tverts[1].st[1] = 1;\t\n\t\tverts[1].modulate[0] = 255;\t\n\t\tverts[1].modulate[1] = 255;\t\n\t\tverts[1].modulate[2] = 255;\t\n\t\tverts[1].modulate[3] = 255;\t\n\n\t\tif (p->roll) {\n\t\t\tVectorMA (point, 2*width, rr, point);\t\n\t\t} else {\n\t\t\tVectorMA (point, 2*width, vright, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[2].xyz);\t\n\t\tverts[2].st[0] = 1;\t\n\t\tverts[2].st[1] = 1;\t\n\t\tverts[2].modulate[0] = 255;\t\n\t\tverts[2].modulate[1] = 255;\t\n\t\tverts[2].modulate[2] = 255;\t\n\t\tverts[2].modulate[3] = 255;\t\n\n\t\tif (p->roll) {\n\t\t\tVectorMA (point, -2*height, ru, point);\t\n\t\t} else {\n\t\t\tVectorMA (point, -2*height, vup, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[3].xyz);\t\n\t\tverts[3].st[0] = 1;\t\n\t\tverts[3].st[1] = 0;\t\n\t\tverts[3].modulate[0] = 255;\t\n\t\tverts[3].modulate[1] = 255;\t\n\t\tverts[3].modulate[2] = 255;\t\n\t\tverts[3].modulate[3] = 255;\t\n\t}\n\telse if (p->type == P_SMOKE || p->type == P_SMOKE_IMPACT)\n\t{// create a front rotating facing polygon\n\n\t\tif ( p->type == P_SMOKE_IMPACT && Distance( cg.snap->ps.origin, org ) > 1024) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (p->color == BLOODRED)\n\t\t\tVectorSet (color, 0.22f, 0.0f, 0.0f);\n\t\telse if (p->color == GREY75)\n\t\t{\n\t\t\tfloat\tlen;\n\t\t\tfloat\tgreyit;\n\t\t\tfloat\tval;\n\t\t\tlen = Distance (cg.snap->ps.origin, org);\n\t\t\tif (!len)\n\t\t\t\tlen = 1;\n\n\t\t\tval = 4096/len;\n\t\t\tgreyit = 0.25 * val;\n\t\t\tif (greyit > 0.5)\n\t\t\t\tgreyit = 0.5;\n\n\t\t\tVectorSet (color, greyit, greyit, greyit);\n\t\t}\n\t\telse\n\t\t\tVectorSet (color, 1.0, 1.0, 1.0);\n\n\t\ttime = cg.time - p->time;\n\t\ttime2 = p->endtime - p->time;\n\t\tratio = time / time2;\n\t\t\n\t\tif (cg.time > p->startfade)\n\t\t{\n\t\t\tinvratio = 1 - ( (cg.time - p->startfade) / (p->endtime - p->startfade) );\n\n\t\t\tif (p->color == EMISIVEFADE)\n\t\t\t{\n\t\t\t\tfloat fval;\n\t\t\t\tfval = (invratio * invratio);\n\t\t\t\tif (fval < 0)\n\t\t\t\t\tfval = 0;\n\t\t\t\tVectorSet (color, fval , fval , fval );\n\t\t\t}\n\t\t\tinvratio *= p->alpha;\n\t\t}\n\t\telse \n\t\t\tinvratio = 1 * p->alpha;\n\n\t\tif ( cgs.glconfig.hardwareType == GLHW_RAGEPRO )\n\t\t\tinvratio = 1;\n\n\t\tif (invratio > 1)\n\t\t\tinvratio = 1;\n\t\n\t\twidth = p->width + ( ratio * ( p->endwidth - p->width) );\n\t\theight = p->height + ( ratio * ( p->endheight - p->height) );\n\n\t\tif (p->type != P_SMOKE_IMPACT)\n\t\t{\n\t\t\tvec3_t temp;\n\n\t\t\tvectoangles (rforward, temp);\n\t\t\tp->accumroll += p->roll;\n\t\t\ttemp[ROLL] += p->accumroll * 0.1;\n\t\t\tAngleVectors ( temp, NULL, rright2, rup2);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVectorCopy (rright, rright2);\n\t\t\tVectorCopy (rup, rup2);\n\t\t}\n\t\t\n\t\tif (p->rotate)\n\t\t{\n\t\t\tVectorMA (org, -height, rup2, point);\t\n\t\t\tVectorMA (point, -width, rright2, point);\t\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVectorMA (org, -p->height, vup, point);\t\n\t\t\tVectorMA (point, -p->width, vright, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[0].xyz);\t\n\t\tverts[0].st[0] = 0;\t\n\t\tverts[0].st[1] = 0;\t\n\t\tverts[0].modulate[0] = 255 * color[0];\t\n\t\tverts[0].modulate[1] = 255 * color[1];\t\n\t\tverts[0].modulate[2] = 255 * color[2];\t\n\t\tverts[0].modulate[3] = 255 * invratio;\t\n\n\t\tif (p->rotate)\n\t\t{\n\t\t\tVectorMA (org, -height, rup2, point);\t\n\t\t\tVectorMA (point, width, rright2, point);\t\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVectorMA (org, -p->height, vup, point);\t\n\t\t\tVectorMA (point, p->width, vright, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[1].xyz);\t\n\t\tverts[1].st[0] = 0;\t\n\t\tverts[1].st[1] = 1;\t\n\t\tverts[1].modulate[0] = 255 * color[0];\t\n\t\tverts[1].modulate[1] = 255 * color[1];\t\n\t\tverts[1].modulate[2] = 255 * color[2];\t\n\t\tverts[1].modulate[3] = 255 * invratio;\t\n\n\t\tif (p->rotate)\n\t\t{\n\t\t\tVectorMA (org, height, rup2, point);\t\n\t\t\tVectorMA (point, width, rright2, point);\t\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVectorMA (org, p->height, vup, point);\t\n\t\t\tVectorMA (point, p->width, vright, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[2].xyz);\t\n\t\tverts[2].st[0] = 1;\t\n\t\tverts[2].st[1] = 1;\t\n\t\tverts[2].modulate[0] = 255 * color[0];\t\n\t\tverts[2].modulate[1] = 255 * color[1];\t\n\t\tverts[2].modulate[2] = 255 * color[2];\t\n\t\tverts[2].modulate[3] = 255 * invratio;\t\n\n\t\tif (p->rotate)\n\t\t{\n\t\t\tVectorMA (org, height, rup2, point);\t\n\t\t\tVectorMA (point, -width, rright2, point);\t\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVectorMA (org, p->height, vup, point);\t\n\t\t\tVectorMA (point, -p->width, vright, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[3].xyz);\t\n\t\tverts[3].st[0] = 1;\t\n\t\tverts[3].st[1] = 0;\t\n\t\tverts[3].modulate[0] = 255 * color[0];\t\n\t\tverts[3].modulate[1] = 255 * color[1];\t\n\t\tverts[3].modulate[2] = 255 * color[2];\t\n\t\tverts[3].modulate[3] = 255  * invratio;\t\n\t\t\n\t}\n\telse if (p->type == P_BLEED)\n\t{\n\t\tvec3_t\trr, ru;\n\t\tvec3_t\trotate_ang;\n\t\tfloat\talpha;\n\n\t\talpha = p->alpha;\n\t\t\n\t\tif ( cgs.glconfig.hardwareType == GLHW_RAGEPRO )\n\t\t\talpha = 1;\n\n\t\tif (p->roll) \n\t\t{\n\t\t\tvectoangles( cg.refdef.viewaxis[0], rotate_ang );\n\t\t\trotate_ang[ROLL] += p->roll;\n\t\t\tAngleVectors ( rotate_ang, NULL, rr, ru);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVectorCopy (vup, ru);\n\t\t\tVectorCopy (vright, rr);\n\t\t}\n\n\t\tVectorMA (org, -p->height, ru, point);\t\n\t\tVectorMA (point, -p->width, rr, point);\t\n\t\tVectorCopy (point, verts[0].xyz);\t\n\t\tverts[0].st[0] = 0;\t\n\t\tverts[0].st[1] = 0;\t\n\t\tverts[0].modulate[0] = 111;\t\n\t\tverts[0].modulate[1] = 19;\t\n\t\tverts[0].modulate[2] = 9;\t\n\t\tverts[0].modulate[3] = 255 * alpha;\t\n\n\t\tVectorMA (org, -p->height, ru, point);\t\n\t\tVectorMA (point, p->width, rr, point);\t\n\t\tVectorCopy (point, verts[1].xyz);\t\n\t\tverts[1].st[0] = 0;\t\n\t\tverts[1].st[1] = 1;\t\n\t\tverts[1].modulate[0] = 111;\t\n\t\tverts[1].modulate[1] = 19;\t\n\t\tverts[1].modulate[2] = 9;\t\n\t\tverts[1].modulate[3] = 255 * alpha;\t\n\n\t\tVectorMA (org, p->height, ru, point);\t\n\t\tVectorMA (point, p->width, rr, point);\t\n\t\tVectorCopy (point, verts[2].xyz);\t\n\t\tverts[2].st[0] = 1;\t\n\t\tverts[2].st[1] = 1;\t\n\t\tverts[2].modulate[0] = 111;\t\n\t\tverts[2].modulate[1] = 19;\t\n\t\tverts[2].modulate[2] = 9;\t\n\t\tverts[2].modulate[3] = 255 * alpha;\t\n\n\t\tVectorMA (org, p->height, ru, point);\t\n\t\tVectorMA (point, -p->width, rr, point);\t\n\t\tVectorCopy (point, verts[3].xyz);\t\n\t\tverts[3].st[0] = 1;\t\n\t\tverts[3].st[1] = 0;\t\n\t\tverts[3].modulate[0] = 111;\t\n\t\tverts[3].modulate[1] = 19;\t\n\t\tverts[3].modulate[2] = 9;\t\n\t\tverts[3].modulate[3] = 255 * alpha;\t\n\n\t}\n\telse if (p->type == P_FLAT_SCALEUP)\n\t{\n\t\tfloat width, height;\n\t\tfloat sinR, cosR;\n\n\t\tif (p->color == BLOODRED)\n\t\t\tVectorSet (color, 1, 1, 1);\n\t\telse\n\t\t\tVectorSet (color, 0.5, 0.5, 0.5);\n\t\t\n\t\ttime = cg.time - p->time;\n\t\ttime2 = p->endtime - p->time;\n\t\tratio = time / time2;\n\n\t\twidth = p->width + ( ratio * ( p->endwidth - p->width) );\n\t\theight = p->height + ( ratio * ( p->endheight - p->height) );\n\n\t\tif (width > p->endwidth)\n\t\t\twidth = p->endwidth;\n\n\t\tif (height > p->endheight)\n\t\t\theight = p->endheight;\n\n\t\tsinR = height * sin(DEG2RAD(p->roll)) * sqrt(2);\n\t\tcosR = width * cos(DEG2RAD(p->roll)) * sqrt(2);\n\n\t\tVectorCopy (org, verts[0].xyz);\t\n\t\tverts[0].xyz[0] -= sinR;\n\t\tverts[0].xyz[1] -= cosR;\n\t\tverts[0].st[0] = 0;\t\n\t\tverts[0].st[1] = 0;\t\n\t\tverts[0].modulate[0] = 255 * color[0];\t\n\t\tverts[0].modulate[1] = 255 * color[1];\t\n\t\tverts[0].modulate[2] = 255 * color[2];\t\n\t\tverts[0].modulate[3] = 255;\t\n\n\t\tVectorCopy (org, verts[1].xyz);\t\n\t\tverts[1].xyz[0] -= cosR;\t\n\t\tverts[1].xyz[1] += sinR;\t\n\t\tverts[1].st[0] = 0;\t\n\t\tverts[1].st[1] = 1;\t\n\t\tverts[1].modulate[0] = 255 * color[0];\t\n\t\tverts[1].modulate[1] = 255 * color[1];\t\n\t\tverts[1].modulate[2] = 255 * color[2];\t\n\t\tverts[1].modulate[3] = 255;\t\n\n\t\tVectorCopy (org, verts[2].xyz);\t\n\t\tverts[2].xyz[0] += sinR;\t\n\t\tverts[2].xyz[1] += cosR;\t\n\t\tverts[2].st[0] = 1;\t\n\t\tverts[2].st[1] = 1;\t\n\t\tverts[2].modulate[0] = 255 * color[0];\t\n\t\tverts[2].modulate[1] = 255 * color[1];\t\n\t\tverts[2].modulate[2] = 255 * color[2];\t\n\t\tverts[2].modulate[3] = 255;\t\n\n\t\tVectorCopy (org, verts[3].xyz);\t\n\t\tverts[3].xyz[0] += cosR;\t\n\t\tverts[3].xyz[1] -= sinR;\t\n\t\tverts[3].st[0] = 1;\t\n\t\tverts[3].st[1] = 0;\t\n\t\tverts[3].modulate[0] = 255 * color[0];\t\n\t\tverts[3].modulate[1] = 255 * color[1];\t\n\t\tverts[3].modulate[2] = 255 * color[2];\t\n\t\tverts[3].modulate[3] = 255;\t\t\n\t}\n\telse if (p->type == P_FLAT)\n\t{\n\n\t\tVectorCopy (org, verts[0].xyz);\t\n\t\tverts[0].xyz[0] -= p->height;\t\n\t\tverts[0].xyz[1] -= p->width;\t\n\t\tverts[0].st[0] = 0;\t\n\t\tverts[0].st[1] = 0;\t\n\t\tverts[0].modulate[0] = 255;\t\n\t\tverts[0].modulate[1] = 255;\t\n\t\tverts[0].modulate[2] = 255;\t\n\t\tverts[0].modulate[3] = 255;\t\n\n\t\tVectorCopy (org, verts[1].xyz);\t\n\t\tverts[1].xyz[0] -= p->height;\t\n\t\tverts[1].xyz[1] += p->width;\t\n\t\tverts[1].st[0] = 0;\t\n\t\tverts[1].st[1] = 1;\t\n\t\tverts[1].modulate[0] = 255;\t\n\t\tverts[1].modulate[1] = 255;\t\n\t\tverts[1].modulate[2] = 255;\t\n\t\tverts[1].modulate[3] = 255;\t\n\n\t\tVectorCopy (org, verts[2].xyz);\t\n\t\tverts[2].xyz[0] += p->height;\t\n\t\tverts[2].xyz[1] += p->width;\t\n\t\tverts[2].st[0] = 1;\t\n\t\tverts[2].st[1] = 1;\t\n\t\tverts[2].modulate[0] = 255;\t\n\t\tverts[2].modulate[1] = 255;\t\n\t\tverts[2].modulate[2] = 255;\t\n\t\tverts[2].modulate[3] = 255;\t\n\n\t\tVectorCopy (org, verts[3].xyz);\t\n\t\tverts[3].xyz[0] += p->height;\t\n\t\tverts[3].xyz[1] -= p->width;\t\n\t\tverts[3].st[0] = 1;\t\n\t\tverts[3].st[1] = 0;\t\n\t\tverts[3].modulate[0] = 255;\t\n\t\tverts[3].modulate[1] = 255;\t\n\t\tverts[3].modulate[2] = 255;\t\n\t\tverts[3].modulate[3] = 255;\t\n\n\t}\n\t// Ridah\n\telse if (p->type == P_ANIM) {\n\t\tvec3_t\trr, ru;\n\t\tvec3_t\trotate_ang;\n\t\tint i, j;\n\n\t\ttime = cg.time - p->time;\n\t\ttime2 = p->endtime - p->time;\n\t\tratio = time / time2;\n\t\tif (ratio >= 1.0f) {\n\t\t\tratio = 0.9999f;\n\t\t}\n\n\t\twidth = p->width + ( ratio * ( p->endwidth - p->width) );\n\t\theight = p->height + ( ratio * ( p->endheight - p->height) );\n\n\t\t// if we are \"inside\" this sprite, don't draw\n\t\tif (Distance( cg.snap->ps.origin, org ) < width/1.5) {\n\t\t\treturn;\n\t\t}\n\n\t\ti = p->shaderAnim;\n\t\tj = (int)floor(ratio * shaderAnimCounts[p->shaderAnim]);\n\t\tp->pshader = shaderAnims[i][j];\n\n\t\tif (p->roll) {\n\t\t\tvectoangles( cg.refdef.viewaxis[0], rotate_ang );\n\t\t\trotate_ang[ROLL] += p->roll;\n\t\t\tAngleVectors ( rotate_ang, NULL, rr, ru);\n\t\t}\n\n\t\tif (p->roll) {\n\t\t\tVectorMA (org, -height, ru, point);\t\n\t\t\tVectorMA (point, -width, rr, point);\t\n\t\t} else {\n\t\t\tVectorMA (org, -height, vup, point);\t\n\t\t\tVectorMA (point, -width, vright, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[0].xyz);\t\n\t\tverts[0].st[0] = 0;\t\n\t\tverts[0].st[1] = 0;\t\n\t\tverts[0].modulate[0] = 255;\t\n\t\tverts[0].modulate[1] = 255;\t\n\t\tverts[0].modulate[2] = 255;\t\n\t\tverts[0].modulate[3] = 255;\n\n\t\tif (p->roll) {\n\t\t\tVectorMA (point, 2*height, ru, point);\t\n\t\t} else {\n\t\t\tVectorMA (point, 2*height, vup, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[1].xyz);\t\n\t\tverts[1].st[0] = 0;\t\n\t\tverts[1].st[1] = 1;\t\n\t\tverts[1].modulate[0] = 255;\t\n\t\tverts[1].modulate[1] = 255;\t\n\t\tverts[1].modulate[2] = 255;\t\n\t\tverts[1].modulate[3] = 255;\t\n\n\t\tif (p->roll) {\n\t\t\tVectorMA (point, 2*width, rr, point);\t\n\t\t} else {\n\t\t\tVectorMA (point, 2*width, vright, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[2].xyz);\t\n\t\tverts[2].st[0] = 1;\t\n\t\tverts[2].st[1] = 1;\t\n\t\tverts[2].modulate[0] = 255;\t\n\t\tverts[2].modulate[1] = 255;\t\n\t\tverts[2].modulate[2] = 255;\t\n\t\tverts[2].modulate[3] = 255;\t\n\n\t\tif (p->roll) {\n\t\t\tVectorMA (point, -2*height, ru, point);\t\n\t\t} else {\n\t\t\tVectorMA (point, -2*height, vup, point);\t\n\t\t}\n\t\tVectorCopy (point, verts[3].xyz);\t\n\t\tverts[3].st[0] = 1;\t\n\t\tverts[3].st[1] = 0;\t\n\t\tverts[3].modulate[0] = 255;\t\n\t\tverts[3].modulate[1] = 255;\t\n\t\tverts[3].modulate[2] = 255;\t\n\t\tverts[3].modulate[3] = 255;\t\n\t}\n\t// done.\n\t\n\tif (!p->pshader) {\n// (SA) temp commented out for DM\n//\t\tCG_Printf (\"CG_AddParticleToScene type %d p->pshader == ZERO\\n\", p->type);\n\t\treturn;\n\t}\n\n\tif (p->type == P_WEATHER || p->type == P_WEATHER_TURBULENT || p->type == P_WEATHER_FLURRY)\n\t\ttrap_R_AddPolyToScene( p->pshader, 3, TRIverts );\n\telse\n\t\ttrap_R_AddPolyToScene( p->pshader, 4, verts );\n\n}\n\n// Ridah, made this static so it doesn't interfere with other files\nstatic float roll = 0.0;\n\n/*\n===============\nCG_AddParticles\n===============\n*/\nvoid CG_AddParticles (void)\n{\n\tcparticle_t\t\t*p, *next;\n\tfloat\t\t\talpha;\n\tfloat\t\t\ttime, time2;\n\tvec3_t\t\t\torg;\n\tint\t\t\t\tcolor;\n\tcparticle_t\t\t*active, *tail;\n\tint\t\t\t\ttype;\n\tvec3_t\t\t\trotate_ang;\n\n\tif (!initparticles)\n\t\tCG_ClearParticles ();\n\n\tVectorCopy( cg.refdef.viewaxis[0], vforward );\n\tVectorCopy( cg.refdef.viewaxis[1], vright );\n\tVectorCopy( cg.refdef.viewaxis[2], vup );\n\n\tvectoangles( cg.refdef.viewaxis[0], rotate_ang );\n\troll += ((cg.time - oldtime) * 0.1) ;\n\trotate_ang[ROLL] += (roll*0.9);\n\tAngleVectors ( rotate_ang, rforward, rright, rup);\n\t\n\toldtime = cg.time;\n\n\tactive = NULL;\n\ttail = NULL;\n\n\tfor (p=active_particles ; p ; p=next)\n\t{\n\n\t\tnext = p->next;\n\n\t\ttime = (cg.time - p->time)*0.001;\n\n\t\talpha = p->alpha + time*p->alphavel;\n\t\tif (alpha <= 0)\n\t\t{\t// faded out\n\t\t\tp->next = free_particles;\n\t\t\tfree_particles = p;\n\t\t\tp->type = 0;\n\t\t\tp->color = 0;\n\t\t\tp->alpha = 0;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (p->type == P_SMOKE || p->type == P_ANIM || p->type == P_BLEED || p->type == P_SMOKE_IMPACT)\n\t\t{\n\t\t\tif (cg.time > p->endtime)\n\t\t\t{\n\t\t\t\tp->next = free_particles;\n\t\t\t\tfree_particles = p;\n\t\t\t\tp->type = 0;\n\t\t\t\tp->color = 0;\n\t\t\t\tp->alpha = 0;\n\t\t\t\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t}\n\n\t\tif (p->type == P_WEATHER_FLURRY)\n\t\t{\n\t\t\tif (cg.time > p->endtime)\n\t\t\t{\n\t\t\t\tp->next = free_particles;\n\t\t\t\tfree_particles = p;\n\t\t\t\tp->type = 0;\n\t\t\t\tp->color = 0;\n\t\t\t\tp->alpha = 0;\n\t\t\t\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\n\t\tif (p->type == P_FLAT_SCALEUP_FADE)\n\t\t{\n\t\t\tif (cg.time > p->endtime)\n\t\t\t{\n\t\t\t\tp->next = free_particles;\n\t\t\t\tfree_particles = p;\n\t\t\t\tp->type = 0;\n\t\t\t\tp->color = 0;\n\t\t\t\tp->alpha = 0;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t}\n\n\t\tif ((p->type == P_BAT || p->type == P_SPRITE) && p->endtime < 0) {\n\t\t\t// temporary sprite\n\t\t\tCG_AddParticleToScene (p, p->org, alpha);\n\t\t\tp->next = free_particles;\n\t\t\tfree_particles = p;\n\t\t\tp->type = 0;\n\t\t\tp->color = 0;\n\t\t\tp->alpha = 0;\n\t\t\tcontinue;\n\t\t}\n\n\t\tp->next = NULL;\n\t\tif (!tail)\n\t\t\tactive = tail = p;\n\t\telse\n\t\t{\n\t\t\ttail->next = p;\n\t\t\ttail = p;\n\t\t}\n\n\t\tif (alpha > 1.0)\n\t\t\talpha = 1;\n\n\t\tcolor = p->color;\n\n\t\ttime2 = time*time;\n\n\t\torg[0] = p->org[0] + p->vel[0]*time + p->accel[0]*time2;\n\t\torg[1] = p->org[1] + p->vel[1]*time + p->accel[1]*time2;\n\t\torg[2] = p->org[2] + p->vel[2]*time + p->accel[2]*time2;\n\n\t\ttype = p->type;\n\n\t\tCG_AddParticleToScene (p, org, alpha);\n\t}\n\n\tactive_particles = active;\n}\n\n/*\n======================\nCG_AddParticles\n======================\n*/\nvoid CG_ParticleSnowFlurry (qhandle_t pshader, centity_t *cent)\n{\n\tcparticle_t\t*p;\n\tqboolean turb = qtrue;\n\n\tif (!pshader)\n\t\tCG_Printf (\"CG_ParticleSnowFlurry pshader == ZERO!\\n\");\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\tp->color = 0;\n\tp->alpha = 0.90f;\n\tp->alphavel = 0;\n\n\tp->start = cent->currentState.origin2[0];\n\tp->end = cent->currentState.origin2[1];\n\t\n\tp->endtime = cg.time + cent->currentState.time;\n\tp->startfade = cg.time + cent->currentState.time2;\n\t\n\tp->pshader = pshader;\n\t\n\tif (rand()%100 > 90)\n\t{\n\t\tp->height = 32;\n\t\tp->width = 32;\n\t\tp->alpha = 0.10f;\n\t}\n\telse\n\t{\n\t\tp->height = 1;\n\t\tp->width = 1;\n\t}\n\n\tp->vel[2] = -20;\n\n\tp->type = P_WEATHER_FLURRY;\n\t\n\tif (turb)\n\t\tp->vel[2] = -10;\n\t\n\tVectorCopy(cent->currentState.origin, p->org);\n\n\tp->org[0] = p->org[0];\n\tp->org[1] = p->org[1];\n\tp->org[2] = p->org[2];\n\n\tp->vel[0] = p->vel[1] = 0;\n\t\n\tp->accel[0] = p->accel[1] = p->accel[2] = 0;\n\n\tp->vel[0] += cent->currentState.angles[0] * 32 + (crandom() * 16);\n\tp->vel[1] += cent->currentState.angles[1] * 32 + (crandom() * 16);\n\tp->vel[2] += cent->currentState.angles[2];\n\n\tif (turb)\n\t{\n\t\tp->accel[0] = crandom () * 16;\n\t\tp->accel[1] = crandom () * 16;\n\t}\n\n}\n\nvoid CG_ParticleSnow (qhandle_t pshader, vec3_t origin, vec3_t origin2, int turb, float range, int snum)\n{\n\tcparticle_t\t*p;\n\n\tif (!pshader)\n\t\tCG_Printf (\"CG_ParticleSnow pshader == ZERO!\\n\");\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\tp->color = 0;\n\tp->alpha = 0.40f;\n\tp->alphavel = 0;\n\tp->start = origin[2];\n\tp->end = origin2[2];\n\tp->pshader = pshader;\n\tp->height = 1;\n\tp->width = 1;\n\t\n\tp->vel[2] = -50;\n\n\tif (turb)\n\t{\n\t\tp->type = P_WEATHER_TURBULENT;\n\t\tp->vel[2] = -50 * 1.3;\n\t}\n\telse\n\t{\n\t\tp->type = P_WEATHER;\n\t}\n\t\n\tVectorCopy(origin, p->org);\n\n\tp->org[0] = p->org[0] + ( crandom() * range);\n\tp->org[1] = p->org[1] + ( crandom() * range);\n\tp->org[2] = p->org[2] + ( crandom() * (p->start - p->end)); \n\n\tp->vel[0] = p->vel[1] = 0;\n\t\n\tp->accel[0] = p->accel[1] = p->accel[2] = 0;\n\n\tif (turb)\n\t{\n\t\tp->vel[0] = crandom() * 16;\n\t\tp->vel[1] = crandom() * 16;\n\t}\n\n\t// Rafael snow pvs check\n\tp->snum = snum;\n\tp->link = qtrue;\n\n}\n\nvoid CG_ParticleBubble (qhandle_t pshader, vec3_t origin, vec3_t origin2, int turb, float range, int snum)\n{\n\tcparticle_t\t*p;\n\tfloat\t\trandsize;\n\n\tif (!pshader)\n\t\tCG_Printf (\"CG_ParticleSnow pshader == ZERO!\\n\");\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\tp->color = 0;\n\tp->alpha = 0.40f;\n\tp->alphavel = 0;\n\tp->start = origin[2];\n\tp->end = origin2[2];\n\tp->pshader = pshader;\n\t\n\trandsize = 1 + (crandom() * 0.5);\n\t\n\tp->height = randsize;\n\tp->width = randsize;\n\t\n\tp->vel[2] = 50 + ( crandom() * 10 );\n\n\tif (turb)\n\t{\n\t\tp->type = P_BUBBLE_TURBULENT;\n\t\tp->vel[2] = 50 * 1.3;\n\t}\n\telse\n\t{\n\t\tp->type = P_BUBBLE;\n\t}\n\t\n\tVectorCopy(origin, p->org);\n\n\tp->org[0] = p->org[0] + ( crandom() * range);\n\tp->org[1] = p->org[1] + ( crandom() * range);\n\tp->org[2] = p->org[2] + ( crandom() * (p->start - p->end)); \n\n\tp->vel[0] = p->vel[1] = 0;\n\t\n\tp->accel[0] = p->accel[1] = p->accel[2] = 0;\n\n\tif (turb)\n\t{\n\t\tp->vel[0] = crandom() * 4;\n\t\tp->vel[1] = crandom() * 4;\n\t}\n\n\t// Rafael snow pvs check\n\tp->snum = snum;\n\tp->link = qtrue;\n\n}\n\nvoid CG_ParticleSmoke (qhandle_t pshader, centity_t *cent)\n{\n\n\t// using cent->density = enttime\n\t//\t\t cent->frame = startfade\n\tcparticle_t\t*p;\n\n\tif (!pshader)\n\t\tCG_Printf (\"CG_ParticleSmoke == ZERO!\\n\");\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\t\n\tp->endtime = cg.time + cent->currentState.time;\n\tp->startfade = cg.time + cent->currentState.time2;\n\t\n\tp->color = 0;\n\tp->alpha = 1.0;\n\tp->alphavel = 0;\n\tp->start = cent->currentState.origin[2];\n\tp->end = cent->currentState.origin2[2];\n\tp->pshader = pshader;\n\tp->rotate = qfalse;\n\tp->height = 8;\n\tp->width = 8;\n\tp->endheight = 32;\n\tp->endwidth = 32;\n\tp->type = P_SMOKE;\n\t\n\tVectorCopy(cent->currentState.origin, p->org);\n\n\tp->vel[0] = p->vel[1] = 0;\n\tp->accel[0] = p->accel[1] = p->accel[2] = 0;\n\n\tp->vel[2] = 5;\n\n\tif (cent->currentState.frame == 1)// reverse gravity\t\n\t\tp->vel[2] *= -1;\n\n\tp->roll = 8 + (crandom() * 4);\n}\n\n\nvoid CG_ParticleBulletDebris (vec3_t org, vec3_t vel, int duration)\n{\n\n\tcparticle_t\t*p;\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\t\n\tp->endtime = cg.time + duration;\n\tp->startfade = cg.time + duration/2;\n\t\n\tp->color = EMISIVEFADE;\n\tp->alpha = 1.0;\n\tp->alphavel = 0;\n\n\tp->height = 0.5;\n\tp->width = 0.5;\n\tp->endheight = 0.5;\n\tp->endwidth = 0.5;\n\n\tp->pshader = cgs.media.tracerShader;\n\n\tp->type = P_SMOKE;\n\t\n\tVectorCopy(org, p->org);\n\n\tp->vel[0] = vel[0];\n\tp->vel[1] = vel[1];\n\tp->vel[2] = vel[2];\n\tp->accel[0] = p->accel[1] = p->accel[2] = 0;\n\n\tp->accel[2] = -60;\n\tp->vel[2] += -20;\n\t\n}\n\n/*\n======================\nCG_ParticleExplosion\n======================\n*/\n\nvoid CG_ParticleExplosion (char *animStr, vec3_t origin, vec3_t vel, int duration, int sizeStart, int sizeEnd)\n{\n\tcparticle_t\t*p;\n\tint anim;\n\n\tif (animStr < (char *)10)\n\t\tCG_Error( \"CG_ParticleExplosion: animStr is probably an index rather than a string\" );\n\n\t// find the animation string\n\tfor (anim=0; shaderAnimNames[anim]; anim++) {\n\t\tif (!stricmp( animStr, shaderAnimNames[anim] ))\n\t\t\tbreak;\n\t}\n\tif (!shaderAnimNames[anim]) {\n\t\tCG_Error(\"CG_ParticleExplosion: unknown animation string: %s\\n\", animStr);\n\t\treturn;\n\t}\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\tp->alpha = 1.0;\n\tp->alphavel = 0;\n\n\tif (duration < 0) {\n\t\tduration *= -1;\n\t\tp->roll = 0;\n\t} else {\n\t\tp->roll = crandom()*179;\n\t}\n\n\tp->shaderAnim = anim;\n\n\tp->width = sizeStart;\n\tp->height = sizeStart*shaderAnimSTRatio[anim];\t// for sprites that are stretch in either direction\n\n\tp->endheight = sizeEnd;\n\tp->endwidth = sizeEnd*shaderAnimSTRatio[anim];\n\n\tp->endtime = cg.time + duration;\n\n\tp->type = P_ANIM;\n\n\tVectorCopy( origin, p->org );\n\tVectorCopy( vel, p->vel );\n\tVectorClear( p->accel );\n\n}\n\n// Rafael Shrapnel\nvoid CG_AddParticleShrapnel (localEntity_t *le)\n{\n\treturn;\n}\n// done.\n\nint CG_NewParticleArea (int num)\n{\n\t// const char *str;\n\tchar *str;\n\tchar *token;\n\tint type;\n\tvec3_t origin, origin2;\n\tint\t\ti;\n\tfloat range = 0;\n\tint turb;\n\tint\tnumparticles;\n\tint\tsnum;\n\t\n\tstr = (char *) CG_ConfigString (num);\n\tif (!str[0])\n\t\treturn (0);\n\t\n\t// returns type 128 64 or 32\n\ttoken = COM_Parse (&str);\n\ttype = atoi (token);\n\t\n\tif (type == 1)\n\t\trange = 128;\n\telse if (type == 2)\n\t\trange = 64;\n\telse if (type == 3)\n\t\trange = 32;\n\telse if (type == 0)\n\t\trange = 256;\n\telse if (type == 4)\n\t\trange = 8;\n\telse if (type == 5)\n\t\trange = 16;\n\telse if (type == 6)\n\t\trange = 32;\n\telse if (type == 7)\n\t\trange = 64;\n\n\n\tfor (i=0; i<3; i++)\n\t{\n\t\ttoken = COM_Parse (&str);\n\t\torigin[i] = atof (token);\n\t}\n\n\tfor (i=0; i<3; i++)\n\t{\n\t\ttoken = COM_Parse (&str);\n\t\torigin2[i] = atof (token);\n\t}\n\t\t\n\ttoken = COM_Parse (&str);\n\tnumparticles = atoi (token);\n\t\n\ttoken = COM_Parse (&str);\n\tturb = atoi (token);\n\n\ttoken = COM_Parse (&str);\n\tsnum = atoi (token);\n\t\n\tfor (i=0; i<numparticles; i++)\n\t{\n\t\tif (type >= 4)\n\t\t\tCG_ParticleBubble (cgs.media.waterBubbleShader, origin, origin2, turb, range, snum);\n\t\telse\n\t\t\tCG_ParticleSnow (cgs.media.waterBubbleShader, origin, origin2, turb, range, snum);\n\t}\n\n\treturn (1);\n}\n\nvoid\tCG_SnowLink (centity_t *cent, qboolean particleOn)\n{\n\tcparticle_t\t\t*p, *next;\n\tint id;\n\n\tid = cent->currentState.frame;\n\n\tfor (p=active_particles ; p ; p=next)\n\t{\n\t\tnext = p->next;\n\t\t\n\t\tif (p->type == P_WEATHER || p->type == P_WEATHER_TURBULENT)\n\t\t{\n\t\t\tif (p->snum == id)\n\t\t\t{\n\t\t\t\tif (particleOn)\n\t\t\t\t\tp->link = qtrue;\n\t\t\t\telse\n\t\t\t\t\tp->link = qfalse;\n\t\t\t}\n\t\t}\n\n\t}\n}\n\nvoid CG_ParticleImpactSmokePuff (qhandle_t pshader, vec3_t origin)\n{\n\tcparticle_t\t*p;\n\n\tif (!pshader)\n\t\tCG_Printf (\"CG_ParticleImpactSmokePuff pshader == ZERO!\\n\");\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\tp->alpha = 0.25;\n\tp->alphavel = 0;\n\tp->roll = crandom()*179;\n\n\tp->pshader = pshader;\n\n\tp->endtime = cg.time + 1000;\n\tp->startfade = cg.time + 100;\n\n\tp->width = rand()%4 + 8;\n\tp->height = rand()%4 + 8;\n\n\tp->endheight = p->height *2;\n\tp->endwidth = p->width * 2;\n\n\tp->endtime = cg.time + 500;\n\n\tp->type = P_SMOKE_IMPACT;\n\n\tVectorCopy( origin, p->org );\n\tVectorSet(p->vel, 0, 0, 20);\n\tVectorSet(p->accel, 0, 0, 20);\n\n\tp->rotate = qtrue;\n}\n\nvoid CG_Particle_Bleed (qhandle_t pshader, vec3_t start, vec3_t dir, int fleshEntityNum, int duration)\n{\n\tcparticle_t\t*p;\n\n\tif (!pshader)\n\t\tCG_Printf (\"CG_Particle_Bleed pshader == ZERO!\\n\");\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\tp->alpha = 1.0;\n\tp->alphavel = 0;\n\tp->roll = 0;\n\n\tp->pshader = pshader;\n\n\tp->endtime = cg.time + duration;\n\t\n\tif (fleshEntityNum)\n\t\tp->startfade = cg.time;\n\telse\n\t\tp->startfade = cg.time + 100;\n\n\tp->width = 4;\n\tp->height = 4;\n\n\tp->endheight = 4+rand()%3;\n\tp->endwidth = p->endheight;\n\n\tp->type = P_SMOKE;\n\n\tVectorCopy( start, p->org );\n\tp->vel[0] = 0;\n\tp->vel[1] = 0;\n\tp->vel[2] = -20;\n\tVectorClear( p->accel );\n\n\tp->rotate = qfalse;\n\n\tp->roll = rand()%179;\n\t\n\tp->color = BLOODRED;\n\tp->alpha = 0.75;\n\n}\n\nvoid CG_Particle_OilParticle (qhandle_t pshader, centity_t *cent)\n{\n\tcparticle_t\t*p;\n\n\tint\t\t\ttime;\n\tint\t\t\ttime2;\n\tfloat\t\tratio;\n\n\tfloat\tduration = 1500;\n\n\ttime = cg.time;\n\ttime2 = cg.time + cent->currentState.time;\n\n\tratio =(float)1 - ((float)time / (float)time2);\n\n\tif (!pshader)\n\t\tCG_Printf (\"CG_Particle_OilParticle == ZERO!\\n\");\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\tp->alpha = 1.0;\n\tp->alphavel = 0;\n\tp->roll = 0;\n\n\tp->pshader = pshader;\n\n\tp->endtime = cg.time + duration;\n\t\n\tp->startfade = p->endtime;\n\n\tp->width = 1;\n\tp->height = 3;\n\n\tp->endheight = 3;\n\tp->endwidth = 1;\n\n\tp->type = P_SMOKE;\n\n\tVectorCopy(cent->currentState.origin, p->org );\t\n\t\n\tp->vel[0] = (cent->currentState.origin2[0] * (16 * ratio));\n\tp->vel[1] = (cent->currentState.origin2[1] * (16 * ratio));\n\tp->vel[2] = (cent->currentState.origin2[2]);\n\n\tp->snum = 1.0f;\n\n\tVectorClear( p->accel );\n\n\tp->accel[2] = -20;\n\n\tp->rotate = qfalse;\n\n\tp->roll = rand()%179;\n\t\n\tp->alpha = 0.75;\n\n}\n\n\nvoid CG_Particle_OilSlick (qhandle_t pshader, centity_t *cent)\n{\n\tcparticle_t\t*p;\n\t\n  \tif (!pshader)\n\t\tCG_Printf (\"CG_Particle_OilSlick == ZERO!\\n\");\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\t\n\tif (cent->currentState.angles2[2])\n\t\tp->endtime = cg.time + cent->currentState.angles2[2];\n\telse\n\t\tp->endtime = cg.time + 60000;\n\n\tp->startfade = p->endtime;\n\n\tp->alpha = 1.0;\n\tp->alphavel = 0;\n\tp->roll = 0;\n\n\tp->pshader = pshader;\n\n\tif (cent->currentState.angles2[0] || cent->currentState.angles2[1])\n\t{\n\t\tp->width = cent->currentState.angles2[0];\n\t\tp->height = cent->currentState.angles2[0];\n\n\t\tp->endheight = cent->currentState.angles2[1];\n\t\tp->endwidth = cent->currentState.angles2[1];\n\t}\n\telse\n\t{\n\t\tp->width = 8;\n\t\tp->height = 8;\n\n\t\tp->endheight = 16;\n\t\tp->endwidth = 16;\n\t}\n\n\tp->type = P_FLAT_SCALEUP;\n\n\tp->snum = 1.0;\n\n\tVectorCopy(cent->currentState.origin, p->org );\n\t\n\tp->org[2]+= 0.55 + (crandom() * 0.5);\n\n\tp->vel[0] = 0;\n\tp->vel[1] = 0;\n\tp->vel[2] = 0;\n\tVectorClear( p->accel );\n\n\tp->rotate = qfalse;\n\n\tp->roll = rand()%179;\n\t\n\tp->alpha = 0.75;\n\n}\n\nvoid CG_OilSlickRemove (centity_t *cent)\n{\n\tcparticle_t\t\t*p, *next;\n\tint\t\t\t\tid;\n\n\tid = 1.0f;\n\n\tif (!id)\n\t\tCG_Printf (\"CG_OilSlickRevove NULL id\\n\");\n\n\tfor (p=active_particles ; p ; p=next)\n\t{\n\t\tnext = p->next;\n\t\t\n\t\tif (p->type == P_FLAT_SCALEUP)\n\t\t{\n\t\t\tif (p->snum == id)\n\t\t\t{\n\t\t\t\tp->endtime = cg.time + 100;\n\t\t\t\tp->startfade = p->endtime;\n\t\t\t\tp->type = P_FLAT_SCALEUP_FADE;\n\n\t\t\t}\n\t\t}\n\n\t}\n}\n\nqboolean ValidBloodPool (vec3_t start)\n{\n#define EXTRUDE_DIST\t0.5\n\n\tvec3_t\tangles;\n\tvec3_t\tright, up;\n\tvec3_t\tthis_pos, x_pos, center_pos, end_pos;\n\tfloat\tx, y;\n\tfloat\tfwidth, fheight;\n\ttrace_t\ttrace;\n\tvec3_t\tnormal;\n\n\tfwidth = 16;\n\tfheight = 16;\n\n\tVectorSet (normal, 0, 0, 1);\n\n\tvectoangles (normal, angles);\n\tAngleVectors (angles, NULL, right, up);\n\n\tVectorMA (start, EXTRUDE_DIST, normal, center_pos);\n\n\tfor (x= -fwidth/2; x<fwidth; x+= fwidth)\n\t{\n\t\tVectorMA (center_pos, x, right, x_pos);\n\n\t\tfor (y= -fheight/2; y<fheight; y+= fheight)\n\t\t{\n\t\t\tVectorMA (x_pos, y, up, this_pos);\n\t\t\tVectorMA (this_pos, -EXTRUDE_DIST*2, normal, end_pos);\n\t\t\t\n\t\t\tCG_Trace (&trace, this_pos, NULL, NULL, end_pos, -1, CONTENTS_SOLID);\n\n\t\t\t\n\t\t\tif (trace.entityNum < (MAX_ENTITIES - 1)) // may only land on world\n\t\t\t\treturn qfalse;\n\n\t\t\tif (!(!trace.startsolid && trace.fraction < 1))\n\t\t\t\treturn qfalse;\n\t\t\n\t\t}\n\t}\n\n\treturn qtrue;\n}\n\nvoid CG_BloodPool (localEntity_t *le, qhandle_t pshader, trace_t *tr)\n{\t\n\tcparticle_t\t*p;\n\tqboolean\tlegit;\n\tvec3_t\t\tstart;\n\tfloat\t\trndSize;\n\t\n\tif (!pshader)\n\t\tCG_Printf (\"CG_BloodPool pshader == ZERO!\\n\");\n\n\tif (!free_particles)\n\t\treturn;\n\t\n\tVectorCopy (tr->endpos, start);\n\tlegit = ValidBloodPool (start);\n\n\tif (!legit) \n\t\treturn;\n\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\t\n\tp->endtime = cg.time + 3000;\n\tp->startfade = p->endtime;\n\n\tp->alpha = 1.0;\n\tp->alphavel = 0;\n\tp->roll = 0;\n\n\tp->pshader = pshader;\n\n\trndSize = 0.4 + random()*0.6;\n\n\tp->width = 8*rndSize;\n\tp->height = 8*rndSize;\n\n\tp->endheight = 16*rndSize;\n\tp->endwidth = 16*rndSize;\n\t\n\tp->type = P_FLAT_SCALEUP;\n\n\tVectorCopy(start, p->org );\n\t\n\tp->vel[0] = 0;\n\tp->vel[1] = 0;\n\tp->vel[2] = 0;\n\tVectorClear( p->accel );\n\n\tp->rotate = qfalse;\n\n\tp->roll = rand()%179;\n\t\n\tp->alpha = 0.75;\n\t\n\tp->color = BLOODRED;\n}\n\n#define NORMALSIZE\t16\n#define LARGESIZE\t32\n\nvoid CG_ParticleBloodCloud (centity_t *cent, vec3_t origin, vec3_t dir)\n{\n\tfloat\tlength;\n\tfloat\tdist;\n\tfloat\tcrittersize;\n\tvec3_t\tangles, forward;\n\tvec3_t\tpoint;\n\tcparticle_t\t*p;\n\tint\t\ti;\n\t\n\tdist = 0;\n\n\tlength = VectorLength (dir);\n\tvectoangles (dir, angles);\n\tAngleVectors (angles, forward, NULL, NULL);\n\n\tcrittersize = LARGESIZE;\n\n\tif (length)\n\t\tdist = length / crittersize;\n\n\tif (dist < 1)\n\t\tdist = 1;\n\n\tVectorCopy (origin, point);\n\n\tfor (i=0; i<dist; i++)\n\t{\n\t\tVectorMA (point, crittersize, forward, point);\t\n\t\t\n\t\tif (!free_particles)\n\t\t\treturn;\n\n\t\tp = free_particles;\n\t\tfree_particles = p->next;\n\t\tp->next = active_particles;\n\t\tactive_particles = p;\n\n\t\tp->time = cg.time;\n\t\tp->alpha = 1.0;\n\t\tp->alphavel = 0;\n\t\tp->roll = 0;\n\n\t\tp->pshader = cgs.media.smokePuffShader;\n\n\t\tp->endtime = cg.time + 350 + (crandom() * 100);\n\t\t\n\t\tp->startfade = cg.time;\n\t\t\n\t\tp->width = LARGESIZE;\n\t\tp->height = LARGESIZE;\n\t\tp->endheight = LARGESIZE;\n\t\tp->endwidth = LARGESIZE;\n\n\t\tp->type = P_SMOKE;\n\n\t\tVectorCopy( origin, p->org );\n\t\t\n\t\tp->vel[0] = 0;\n\t\tp->vel[1] = 0;\n\t\tp->vel[2] = -1;\n\t\t\n\t\tVectorClear( p->accel );\n\n\t\tp->rotate = qfalse;\n\n\t\tp->roll = rand()%179;\n\t\t\n\t\tp->color = BLOODRED;\n\t\t\n\t\tp->alpha = 0.75;\n\t\t\n\t}\n\n\t\n}\n\nvoid CG_ParticleSparks (vec3_t org, vec3_t vel, int duration, float x, float y, float speed)\n{\n\tcparticle_t\t*p;\n\n\tif (!free_particles)\n\t\treturn;\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\t\n\tp->endtime = cg.time + duration;\n\tp->startfade = cg.time + duration/2;\n\t\n\tp->color = EMISIVEFADE;\n\tp->alpha = 0.4f;\n\tp->alphavel = 0;\n\n\tp->height = 0.5;\n\tp->width = 0.5;\n\tp->endheight = 0.5;\n\tp->endwidth = 0.5;\n\n\tp->pshader = cgs.media.tracerShader;\n\n\tp->type = P_SMOKE;\n\t\n\tVectorCopy(org, p->org);\n\n\tp->org[0] += (crandom() * x);\n\tp->org[1] += (crandom() * y);\n\n\tp->vel[0] = vel[0];\n\tp->vel[1] = vel[1];\n\tp->vel[2] = vel[2];\n\n\tp->accel[0] = p->accel[1] = p->accel[2] = 0;\n\n\tp->vel[0] += (crandom() * 4);\n\tp->vel[1] += (crandom() * 4);\n\tp->vel[2] += (20 + (crandom() * 10)) * speed;\t\n\n\tp->accel[0] = crandom () * 4;\n\tp->accel[1] = crandom () * 4;\n\t\n}\n\nvoid CG_ParticleDust (centity_t *cent, vec3_t origin, vec3_t dir)\n{\n\tfloat\tlength;\n\tfloat\tdist;\n\tfloat\tcrittersize;\n\tvec3_t\tangles, forward;\n\tvec3_t\tpoint;\n\tcparticle_t\t*p;\n\tint\t\ti;\n\t\n\tdist = 0;\n\n\tVectorNegate (dir, dir);\n\tlength = VectorLength (dir);\n\tvectoangles (dir, angles);\n\tAngleVectors (angles, forward, NULL, NULL);\n\n\tcrittersize = LARGESIZE;\n\n\tif (length)\n\t\tdist = length / crittersize;\n\n\tif (dist < 1)\n\t\tdist = 1;\n\n\tVectorCopy (origin, point);\n\n\tfor (i=0; i<dist; i++)\n\t{\n\t\tVectorMA (point, crittersize, forward, point);\t\n\t\t\t\t\n\t\tif (!free_particles)\n\t\t\treturn;\n\n\t\tp = free_particles;\n\t\tfree_particles = p->next;\n\t\tp->next = active_particles;\n\t\tactive_particles = p;\n\n\t\tp->time = cg.time;\n\t\tp->alpha = 5.0;\n\t\tp->alphavel = 0;\n\t\tp->roll = 0;\n\n\t\tp->pshader = cgs.media.smokePuffShader;\n\n\t\t// RF, stay around for long enough to expand and dissipate naturally\n\t\tif (length)\n\t\t\tp->endtime = cg.time + 4500 + (crandom() * 3500);\n\t\telse\n\t\t\tp->endtime = cg.time + 750 + (crandom() * 500);\n\t\t\n\t\tp->startfade = cg.time;\n\t\t\n\t\tp->width = LARGESIZE;\n\t\tp->height = LARGESIZE;\n\n\t\t// RF, expand while falling\n\t\tp->endheight = LARGESIZE*3.0;\n\t\tp->endwidth = LARGESIZE*3.0;\n\n\t\tif (!length)\n\t\t{\n\t\t\tp->width *= 0.2f;\n\t\t\tp->height *= 0.2f;\n\n\t\t\tp->endheight = NORMALSIZE;\n\t\t\tp->endwidth = NORMALSIZE;\n\t\t}\n\n\t\tp->type = P_SMOKE;\n\n\t\tVectorCopy( point, p->org );\n\t\t\n\t\tp->vel[0] = crandom()*6;\n\t\tp->vel[1] = crandom()*6;\n\t\tp->vel[2] = random()*20;\n\n\t\t// RF, add some gravity/randomness\n\t\tp->accel[0] = crandom()*3;\n\t\tp->accel[1] = crandom()*3;\n\t\tp->accel[2] = -PARTICLE_GRAVITY*0.4;\n\n\t\tVectorClear( p->accel );\n\n\t\tp->rotate = qfalse;\n\n\t\tp->roll = rand()%179;\n\t\t\n\t\tp->alpha = 0.75;\n\t\t\n\t}\n\n\t\n}\n\nvoid CG_ParticleMisc (qhandle_t pshader, vec3_t origin, int size, int duration, float alpha)\n{\n\tcparticle_t\t*p;\n\n\tif (!pshader)\n\t\tCG_Printf (\"CG_ParticleImpactSmokePuff pshader == ZERO!\\n\");\n\n\tif (!free_particles)\n\t\treturn;\n\n\tp = free_particles;\n\tfree_particles = p->next;\n\tp->next = active_particles;\n\tactive_particles = p;\n\tp->time = cg.time;\n\tp->alpha = 1.0;\n\tp->alphavel = 0;\n\tp->roll = rand()%179;\n\n\tp->pshader = pshader;\n\n\tif (duration > 0)\n\t\tp->endtime = cg.time + duration;\n\telse\n\t\tp->endtime = duration;\n\n\tp->startfade = cg.time;\n\n\tp->width = size;\n\tp->height = size;\n\n\tp->endheight = size;\n\tp->endwidth = size;\n\n\tp->type = P_SPRITE;\n\n\tVectorCopy( origin, p->org );\n\n\tp->rotate = qfalse;\n}\n"
  },
  {
    "path": "code/cgame/cg_players.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// cg_players.c -- handle the media and animation for player entities\n#include \"cg_local.h\"\n\nchar\t*cg_customSoundNames[MAX_CUSTOM_SOUNDS] = {\n\t\"*death1.wav\",\n\t\"*death2.wav\",\n\t\"*death3.wav\",\n\t\"*jump1.wav\",\n\t\"*pain25_1.wav\",\n\t\"*pain50_1.wav\",\n\t\"*pain75_1.wav\",\n\t\"*pain100_1.wav\",\n\t\"*falling1.wav\",\n\t\"*gasp.wav\",\n\t\"*drown.wav\",\n\t\"*fall1.wav\",\n\t\"*taunt.wav\"\n};\n\n\n/*\n================\nCG_CustomSound\n\n================\n*/\nsfxHandle_t\tCG_CustomSound( int clientNum, const char *soundName ) {\n\tclientInfo_t *ci;\n\tint\t\t\ti;\n\n\tif ( soundName[0] != '*' ) {\n\t\treturn trap_S_RegisterSound( soundName, qfalse );\n\t}\n\n\tif ( clientNum < 0 || clientNum >= MAX_CLIENTS ) {\n\t\tclientNum = 0;\n\t}\n\tci = &cgs.clientinfo[ clientNum ];\n\n\tfor ( i = 0 ; i < MAX_CUSTOM_SOUNDS && cg_customSoundNames[i] ; i++ ) {\n\t\tif ( !strcmp( soundName, cg_customSoundNames[i] ) ) {\n\t\t\treturn ci->sounds[i];\n\t\t}\n\t}\n\n\tCG_Error( \"Unknown custom sound: %s\", soundName );\n\treturn 0;\n}\n\n\n\n/*\n=============================================================================\n\nCLIENT INFO\n\n=============================================================================\n*/\n\n/*\n======================\nCG_ParseAnimationFile\n\nRead a configuration file containing animation coutns and rates\nmodels/players/visor/animation.cfg, etc\n======================\n*/\nstatic qboolean\tCG_ParseAnimationFile( const char *filename, clientInfo_t *ci ) {\n\tchar\t\t*text_p, *prev;\n\tint\t\t\tlen;\n\tint\t\t\ti;\n\tchar\t\t*token;\n\tfloat\t\tfps;\n\tint\t\t\tskip;\n\tchar\t\ttext[20000];\n\tfileHandle_t\tf;\n\tanimation_t *animations;\n\n\tanimations = ci->animations;\n\n\t// load the file\n\tlen = trap_FS_FOpenFile( filename, &f, FS_READ );\n\tif ( len <= 0 ) {\n\t\treturn qfalse;\n\t}\n\tif ( len >= sizeof( text ) - 1 ) {\n\t\tCG_Printf( \"File %s too long\\n\", filename );\n\t\treturn qfalse;\n\t}\n\ttrap_FS_Read( text, len, f );\n\ttext[len] = 0;\n\ttrap_FS_FCloseFile( f );\n\n\t// parse the text\n\ttext_p = text;\n\tskip = 0;\t// quite the compiler warning\n\n\tci->footsteps = FOOTSTEP_NORMAL;\n\tVectorClear( ci->headOffset );\n\tci->gender = GENDER_MALE;\n\tci->fixedlegs = qfalse;\n\tci->fixedtorso = qfalse;\n\n\t// read optional parameters\n\twhile ( 1 ) {\n\t\tprev = text_p;\t// so we can unget\n\t\ttoken = COM_Parse( &text_p );\n\t\tif ( !token ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( !Q_stricmp( token, \"footsteps\" ) ) {\n\t\t\ttoken = COM_Parse( &text_p );\n\t\t\tif ( !token ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( !Q_stricmp( token, \"default\" ) || !Q_stricmp( token, \"normal\" ) ) {\n\t\t\t\tci->footsteps = FOOTSTEP_NORMAL;\n\t\t\t} else if ( !Q_stricmp( token, \"boot\" ) ) {\n\t\t\t\tci->footsteps = FOOTSTEP_BOOT;\n\t\t\t} else if ( !Q_stricmp( token, \"flesh\" ) ) {\n\t\t\t\tci->footsteps = FOOTSTEP_FLESH;\n\t\t\t} else if ( !Q_stricmp( token, \"mech\" ) ) {\n\t\t\t\tci->footsteps = FOOTSTEP_MECH;\n\t\t\t} else if ( !Q_stricmp( token, \"energy\" ) ) {\n\t\t\t\tci->footsteps = FOOTSTEP_ENERGY;\n\t\t\t} else {\n\t\t\t\tCG_Printf( \"Bad footsteps parm in %s: %s\\n\", filename, token );\n\t\t\t}\n\t\t\tcontinue;\n\t\t} else if ( !Q_stricmp( token, \"headoffset\" ) ) {\n\t\t\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\t\t\ttoken = COM_Parse( &text_p );\n\t\t\t\tif ( !token ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tci->headOffset[i] = atof( token );\n\t\t\t}\n\t\t\tcontinue;\n\t\t} else if ( !Q_stricmp( token, \"sex\" ) ) {\n\t\t\ttoken = COM_Parse( &text_p );\n\t\t\tif ( !token ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( token[0] == 'f' || token[0] == 'F' ) {\n\t\t\t\tci->gender = GENDER_FEMALE;\n\t\t\t} else if ( token[0] == 'n' || token[0] == 'N' ) {\n\t\t\t\tci->gender = GENDER_NEUTER;\n\t\t\t} else {\n\t\t\t\tci->gender = GENDER_MALE;\n\t\t\t}\n\t\t\tcontinue;\n\t\t} else if ( !Q_stricmp( token, \"fixedlegs\" ) ) {\n\t\t\tci->fixedlegs = qtrue;\n\t\t\tcontinue;\n\t\t} else if ( !Q_stricmp( token, \"fixedtorso\" ) ) {\n\t\t\tci->fixedtorso = qtrue;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// if it is a number, start parsing animations\n\t\tif ( token[0] >= '0' && token[0] <= '9' ) {\n\t\t\ttext_p = prev;\t// unget the token\n\t\t\tbreak;\n\t\t}\n\t\tCom_Printf( \"unknown token '%s' is %s\\n\", token, filename );\n\t}\n\n\t// read information for each frame\n\tfor ( i = 0 ; i < MAX_ANIMATIONS ; i++ ) {\n\n\t\ttoken = COM_Parse( &text_p );\n\t\tif ( !*token ) {\n\t\t\tif( i >= TORSO_GETFLAG && i <= TORSO_NEGATIVE ) {\n\t\t\t\tanimations[i].firstFrame = animations[TORSO_GESTURE].firstFrame;\n\t\t\t\tanimations[i].frameLerp = animations[TORSO_GESTURE].frameLerp;\n\t\t\t\tanimations[i].initialLerp = animations[TORSO_GESTURE].initialLerp;\n\t\t\t\tanimations[i].loopFrames = animations[TORSO_GESTURE].loopFrames;\n\t\t\t\tanimations[i].numFrames = animations[TORSO_GESTURE].numFrames;\n\t\t\t\tanimations[i].reversed = qfalse;\n\t\t\t\tanimations[i].flipflop = qfalse;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tanimations[i].firstFrame = atoi( token );\n\t\t// leg only frames are adjusted to not count the upper body only frames\n\t\tif ( i == LEGS_WALKCR ) {\n\t\t\tskip = animations[LEGS_WALKCR].firstFrame - animations[TORSO_GESTURE].firstFrame;\n\t\t}\n\t\tif ( i >= LEGS_WALKCR && i<TORSO_GETFLAG) {\n\t\t\tanimations[i].firstFrame -= skip;\n\t\t}\n\n\t\ttoken = COM_Parse( &text_p );\n\t\tif ( !*token ) {\n\t\t\tbreak;\n\t\t}\n\t\tanimations[i].numFrames = atoi( token );\n\n\t\tanimations[i].reversed = qfalse;\n\t\tanimations[i].flipflop = qfalse;\n\t\t// if numFrames is negative the animation is reversed\n\t\tif (animations[i].numFrames < 0) {\n\t\t\tanimations[i].numFrames = -animations[i].numFrames;\n\t\t\tanimations[i].reversed = qtrue;\n\t\t}\n\n\t\ttoken = COM_Parse( &text_p );\n\t\tif ( !*token ) {\n\t\t\tbreak;\n\t\t}\n\t\tanimations[i].loopFrames = atoi( token );\n\n\t\ttoken = COM_Parse( &text_p );\n\t\tif ( !*token ) {\n\t\t\tbreak;\n\t\t}\n\t\tfps = atof( token );\n\t\tif ( fps == 0 ) {\n\t\t\tfps = 1;\n\t\t}\n\t\tanimations[i].frameLerp = 1000 / fps;\n\t\tanimations[i].initialLerp = 1000 / fps;\n\t}\n\n\tif ( i != MAX_ANIMATIONS ) {\n\t\tCG_Printf( \"Error parsing animation file: %s\", filename );\n\t\treturn qfalse;\n\t}\n\n\t// crouch backward animation\n\tmemcpy(&animations[LEGS_BACKCR], &animations[LEGS_WALKCR], sizeof(animation_t));\n\tanimations[LEGS_BACKCR].reversed = qtrue;\n\t// walk backward animation\n\tmemcpy(&animations[LEGS_BACKWALK], &animations[LEGS_WALK], sizeof(animation_t));\n\tanimations[LEGS_BACKWALK].reversed = qtrue;\n\t// flag moving fast\n\tanimations[FLAG_RUN].firstFrame = 0;\n\tanimations[FLAG_RUN].numFrames = 16;\n\tanimations[FLAG_RUN].loopFrames = 16;\n\tanimations[FLAG_RUN].frameLerp = 1000 / 15;\n\tanimations[FLAG_RUN].initialLerp = 1000 / 15;\n\tanimations[FLAG_RUN].reversed = qfalse;\n\t// flag not moving or moving slowly\n\tanimations[FLAG_STAND].firstFrame = 16;\n\tanimations[FLAG_STAND].numFrames = 5;\n\tanimations[FLAG_STAND].loopFrames = 0;\n\tanimations[FLAG_STAND].frameLerp = 1000 / 20;\n\tanimations[FLAG_STAND].initialLerp = 1000 / 20;\n\tanimations[FLAG_STAND].reversed = qfalse;\n\t// flag speeding up\n\tanimations[FLAG_STAND2RUN].firstFrame = 16;\n\tanimations[FLAG_STAND2RUN].numFrames = 5;\n\tanimations[FLAG_STAND2RUN].loopFrames = 1;\n\tanimations[FLAG_STAND2RUN].frameLerp = 1000 / 15;\n\tanimations[FLAG_STAND2RUN].initialLerp = 1000 / 15;\n\tanimations[FLAG_STAND2RUN].reversed = qtrue;\n\t//\n\t// new anims changes\n\t//\n//\tanimations[TORSO_GETFLAG].flipflop = qtrue;\n//\tanimations[TORSO_GUARDBASE].flipflop = qtrue;\n//\tanimations[TORSO_PATROL].flipflop = qtrue;\n//\tanimations[TORSO_AFFIRMATIVE].flipflop = qtrue;\n//\tanimations[TORSO_NEGATIVE].flipflop = qtrue;\n\t//\n\treturn qtrue;\n}\n\n/*\n==========================\nCG_FileExists\n==========================\n*/\nstatic qboolean\tCG_FileExists(const char *filename) {\n\tint len;\n\n\tlen = trap_FS_FOpenFile( filename, 0, FS_READ );\n\tif (len>0) {\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n==========================\nCG_FindClientModelFile\n==========================\n*/\nstatic qboolean\tCG_FindClientModelFile( char *filename, int length, clientInfo_t *ci, const char *teamName, const char *modelName, const char *skinName, const char *base, const char *ext ) {\n\tchar *team, *charactersFolder;\n\tint i;\n\n\tif ( cgs.gametype >= GT_TEAM ) {\n\t\tswitch ( ci->team ) {\n\t\t\tcase TEAM_BLUE: {\n\t\t\t\tteam = \"blue\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tteam = \"red\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\tteam = \"default\";\n\t}\n\tcharactersFolder = \"\";\n\twhile(1) {\n\t\tfor ( i = 0; i < 2; i++ ) {\n\t\t\tif ( i == 0 && teamName && *teamName ) {\n\t\t\t\t//\t\t\t\t\t\t\t\t\"models/players/characters/james/stroggs/lower_lily_red.skin\"\n\t\t\t\tCom_sprintf( filename, length, \"models/players/%s%s/%s%s_%s_%s.%s\", charactersFolder, modelName, teamName, base, skinName, team, ext );\n\t\t\t}\n\t\t\telse {\n\t\t\t\t//\t\t\t\t\t\t\t\t\"models/players/characters/james/lower_lily_red.skin\"\n\t\t\t\tCom_sprintf( filename, length, \"models/players/%s%s/%s_%s_%s.%s\", charactersFolder, modelName, base, skinName, team, ext );\n\t\t\t}\n\t\t\tif ( CG_FileExists( filename ) ) {\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t\tif ( cgs.gametype >= GT_TEAM ) {\n\t\t\t\tif ( i == 0 && teamName && *teamName ) {\n\t\t\t\t\t//\t\t\t\t\t\t\t\t\"models/players/characters/james/stroggs/lower_red.skin\"\n\t\t\t\t\tCom_sprintf( filename, length, \"models/players/%s%s/%s%s_%s.%s\", charactersFolder, modelName, teamName, base, team, ext );\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t//\t\t\t\t\t\t\t\t\"models/players/characters/james/lower_red.skin\"\n\t\t\t\t\tCom_sprintf( filename, length, \"models/players/%s%s/%s_%s.%s\", charactersFolder, modelName, base, team, ext );\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif ( i == 0 && teamName && *teamName ) {\n\t\t\t\t\t//\t\t\t\t\t\t\t\t\"models/players/characters/james/stroggs/lower_lily.skin\"\n\t\t\t\t\tCom_sprintf( filename, length, \"models/players/%s%s/%s%s_%s.%s\", charactersFolder, modelName, teamName, base, skinName, ext );\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t//\t\t\t\t\t\t\t\t\"models/players/characters/james/lower_lily.skin\"\n\t\t\t\t\tCom_sprintf( filename, length, \"models/players/%s%s/%s_%s.%s\", charactersFolder, modelName, base, skinName, ext );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( CG_FileExists( filename ) ) {\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t\tif ( !teamName || !*teamName ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t// if tried the heads folder first\n\t\tif ( charactersFolder[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tcharactersFolder = \"characters/\";\n\t}\n\n\treturn qfalse;\n}\n\n/*\n==========================\nCG_FindClientHeadFile\n==========================\n*/\nstatic qboolean\tCG_FindClientHeadFile( char *filename, int length, clientInfo_t *ci, const char *teamName, const char *headModelName, const char *headSkinName, const char *base, const char *ext ) {\n\tchar *team, *headsFolder;\n\tint i;\n\n\tif ( cgs.gametype >= GT_TEAM ) {\n\t\tswitch ( ci->team ) {\n\t\t\tcase TEAM_BLUE: {\n\t\t\t\tteam = \"blue\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tteam = \"red\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\tteam = \"default\";\n\t}\n\n\tif ( headModelName[0] == '*' ) {\n\t\theadsFolder = \"heads/\";\n\t\theadModelName++;\n\t}\n\telse {\n\t\theadsFolder = \"\";\n\t}\n\twhile(1) {\n\t\tfor ( i = 0; i < 2; i++ ) {\n\t\t\tif ( i == 0 && teamName && *teamName ) {\n\t\t\t\tCom_sprintf( filename, length, \"models/players/%s%s/%s/%s%s_%s.%s\", headsFolder, headModelName, headSkinName, teamName, base, team, ext );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tCom_sprintf( filename, length, \"models/players/%s%s/%s/%s_%s.%s\", headsFolder, headModelName, headSkinName, base, team, ext );\n\t\t\t}\n\t\t\tif ( CG_FileExists( filename ) ) {\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t\tif ( cgs.gametype >= GT_TEAM ) {\n\t\t\t\tif ( i == 0 &&  teamName && *teamName ) {\n\t\t\t\t\tCom_sprintf( filename, length, \"models/players/%s%s/%s%s_%s.%s\", headsFolder, headModelName, teamName, base, team, ext );\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tCom_sprintf( filename, length, \"models/players/%s%s/%s_%s.%s\", headsFolder, headModelName, base, team, ext );\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif ( i == 0 && teamName && *teamName ) {\n\t\t\t\t\tCom_sprintf( filename, length, \"models/players/%s%s/%s%s_%s.%s\", headsFolder, headModelName, teamName, base, headSkinName, ext );\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tCom_sprintf( filename, length, \"models/players/%s%s/%s_%s.%s\", headsFolder, headModelName, base, headSkinName, ext );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( CG_FileExists( filename ) ) {\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t\tif ( !teamName || !*teamName ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t// if tried the heads folder first\n\t\tif ( headsFolder[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\theadsFolder = \"heads/\";\n\t}\n\n\treturn qfalse;\n}\n\n/*\n==========================\nCG_RegisterClientSkin\n==========================\n*/\nstatic qboolean\tCG_RegisterClientSkin( clientInfo_t *ci, const char *teamName, const char *modelName, const char *skinName, const char *headModelName, const char *headSkinName ) {\n\tchar filename[MAX_QPATH];\n\n\t/*\n\tCom_sprintf( filename, sizeof( filename ), \"models/players/%s/%slower_%s.skin\", modelName, teamName, skinName );\n\tci->legsSkin = trap_R_RegisterSkin( filename );\n\tif (!ci->legsSkin) {\n\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/characters/%s/%slower_%s.skin\", modelName, teamName, skinName );\n\t\tci->legsSkin = trap_R_RegisterSkin( filename );\n\t\tif (!ci->legsSkin) {\n\t\t\tCom_Printf( \"Leg skin load failure: %s\\n\", filename );\n\t\t}\n\t}\n\n\n\tCom_sprintf( filename, sizeof( filename ), \"models/players/%s/%supper_%s.skin\", modelName, teamName, skinName );\n\tci->torsoSkin = trap_R_RegisterSkin( filename );\n\tif (!ci->torsoSkin) {\n\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/characters/%s/%supper_%s.skin\", modelName, teamName, skinName );\n\t\tci->torsoSkin = trap_R_RegisterSkin( filename );\n\t\tif (!ci->torsoSkin) {\n\t\t\tCom_Printf( \"Torso skin load failure: %s\\n\", filename );\n\t\t}\n\t}\n\t*/\n\tif ( CG_FindClientModelFile( filename, sizeof(filename), ci, teamName, modelName, skinName, \"lower\", \"skin\" ) ) {\n\t\tci->legsSkin = trap_R_RegisterSkin( filename );\n\t}\n\tif (!ci->legsSkin) {\n\t\tCom_Printf( \"Leg skin load failure: %s\\n\", filename );\n\t}\n\n\tif ( CG_FindClientModelFile( filename, sizeof(filename), ci, teamName, modelName, skinName, \"upper\", \"skin\" ) ) {\n\t\tci->torsoSkin = trap_R_RegisterSkin( filename );\n\t}\n\tif (!ci->torsoSkin) {\n\t\tCom_Printf( \"Torso skin load failure: %s\\n\", filename );\n\t}\n\n\tif ( CG_FindClientHeadFile( filename, sizeof(filename), ci, teamName, headModelName, headSkinName, \"head\", \"skin\" ) ) {\n\t\tci->headSkin = trap_R_RegisterSkin( filename );\n\t}\n\tif (!ci->headSkin) {\n\t\tCom_Printf( \"Head skin load failure: %s\\n\", filename );\n\t}\n\n\t// if any skins failed to load\n\tif ( !ci->legsSkin || !ci->torsoSkin || !ci->headSkin ) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n/*\n==========================\nCG_RegisterClientModelname\n==========================\n*/\nstatic qboolean CG_RegisterClientModelname( clientInfo_t *ci, const char *modelName, const char *skinName, const char *headModelName, const char *headSkinName, const char *teamName ) {\n\tchar\tfilename[MAX_QPATH*2];\n\tconst char\t\t*headName;\n\tchar newTeamName[MAX_QPATH*2];\n\n\tif ( headModelName[0] == '\\0' ) {\n\t\theadName = modelName;\n\t}\n\telse {\n\t\theadName = headModelName;\n\t}\n\tCom_sprintf( filename, sizeof( filename ), \"models/players/%s/lower.md3\", modelName );\n\tci->legsModel = trap_R_RegisterModel( filename );\n\tif ( !ci->legsModel ) {\n\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/characters/%s/lower.md3\", modelName );\n\t\tci->legsModel = trap_R_RegisterModel( filename );\n\t\tif ( !ci->legsModel ) {\n\t\t\tCom_Printf( \"Failed to load model file %s\\n\", filename );\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\tCom_sprintf( filename, sizeof( filename ), \"models/players/%s/upper.md3\", modelName );\n\tci->torsoModel = trap_R_RegisterModel( filename );\n\tif ( !ci->torsoModel ) {\n\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/characters/%s/upper.md3\", modelName );\n\t\tci->torsoModel = trap_R_RegisterModel( filename );\n\t\tif ( !ci->torsoModel ) {\n\t\t\tCom_Printf( \"Failed to load model file %s\\n\", filename );\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\tif( headName[0] == '*' ) {\n\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/heads/%s/%s.md3\", &headModelName[1], &headModelName[1] );\n\t}\n\telse {\n\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/%s/head.md3\", headName );\n\t}\n\tci->headModel = trap_R_RegisterModel( filename );\n\t// if the head model could not be found and we didn't load from the heads folder try to load from there\n\tif ( !ci->headModel && headName[0] != '*' ) {\n\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/heads/%s/%s.md3\", headModelName, headModelName );\n\t\tci->headModel = trap_R_RegisterModel( filename );\n\t}\n\tif ( !ci->headModel ) {\n\t\tCom_Printf( \"Failed to load model file %s\\n\", filename );\n\t\treturn qfalse;\n\t}\n\n\t// if any skins failed to load, return failure\n\tif ( !CG_RegisterClientSkin( ci, teamName, modelName, skinName, headName, headSkinName ) ) {\n\t\tif ( teamName && *teamName) {\n\t\t\tCom_Printf( \"Failed to load skin file: %s : %s : %s, %s : %s\\n\", teamName, modelName, skinName, headName, headSkinName );\n\t\t\tif( ci->team == TEAM_BLUE ) {\n\t\t\t\tCom_sprintf(newTeamName, sizeof(newTeamName), \"%s/\", DEFAULT_BLUETEAM_NAME);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tCom_sprintf(newTeamName, sizeof(newTeamName), \"%s/\", DEFAULT_REDTEAM_NAME);\n\t\t\t}\n\t\t\tif ( !CG_RegisterClientSkin( ci, newTeamName, modelName, skinName, headName, headSkinName ) ) {\n\t\t\t\tCom_Printf( \"Failed to load skin file: %s : %s : %s, %s : %s\\n\", newTeamName, modelName, skinName, headName, headSkinName );\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t} else {\n\t\t\tCom_Printf( \"Failed to load skin file: %s : %s, %s : %s\\n\", modelName, skinName, headName, headSkinName );\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\t// load the animations\n\tCom_sprintf( filename, sizeof( filename ), \"models/players/%s/animation.cfg\", modelName );\n\tif ( !CG_ParseAnimationFile( filename, ci ) ) {\n\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/characters/%s/animation.cfg\", modelName );\n\t\tif ( !CG_ParseAnimationFile( filename, ci ) ) {\n\t\t\tCom_Printf( \"Failed to load animation file %s\\n\", filename );\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\tif ( CG_FindClientHeadFile( filename, sizeof(filename), ci, teamName, headName, headSkinName, \"icon\", \"skin\" ) ) {\n\t\tci->modelIcon = trap_R_RegisterShaderNoMip( filename );\n\t}\n\telse if ( CG_FindClientHeadFile( filename, sizeof(filename), ci, teamName, headName, headSkinName, \"icon\", \"tga\" ) ) {\n\t\tci->modelIcon = trap_R_RegisterShaderNoMip( filename );\n\t}\n\n\tif ( !ci->modelIcon ) {\n\t\treturn qfalse;\n\t}\n\n\treturn qtrue;\n}\n\n/*\n====================\nCG_ColorFromString\n====================\n*/\nstatic void CG_ColorFromString( const char *v, vec3_t color ) {\n\tint val;\n\n\tVectorClear( color );\n\n\tval = atoi( v );\n\n\tif ( val < 1 || val > 7 ) {\n\t\tVectorSet( color, 1, 1, 1 );\n\t\treturn;\n\t}\n\n\tif ( val & 1 ) {\n\t\tcolor[2] = 1.0f;\n\t}\n\tif ( val & 2 ) {\n\t\tcolor[1] = 1.0f;\n\t}\n\tif ( val & 4 ) {\n\t\tcolor[0] = 1.0f;\n\t}\n}\n\n/*\n===================\nCG_LoadClientInfo\n\nLoad it now, taking the disk hits.\nThis will usually be deferred to a safe time\n===================\n*/\nstatic void CG_LoadClientInfo( clientInfo_t *ci ) {\n\tconst char\t*dir, *fallback;\n\tint\t\t\ti, modelloaded;\n\tconst char\t*s;\n\tint\t\t\tclientNum;\n\tchar\t\tteamname[MAX_QPATH];\n\n\tteamname[0] = 0;\n#ifdef MISSIONPACK\n\tif( cgs.gametype >= GT_TEAM) {\n\t\tif( ci->team == TEAM_BLUE ) {\n\t\t\tQ_strncpyz(teamname, cg_blueTeamName.string, sizeof(teamname) );\n\t\t} else {\n\t\t\tQ_strncpyz(teamname, cg_redTeamName.string, sizeof(teamname) );\n\t\t}\n\t}\n\tif( teamname[0] ) {\n\t\tstrcat( teamname, \"/\" );\n\t}\n#endif\n\tmodelloaded = qtrue;\n\tif ( !CG_RegisterClientModelname( ci, ci->modelName, ci->skinName, ci->headModelName, ci->headSkinName, teamname ) ) {\n\t\tif ( cg_buildScript.integer ) {\n\t\t\tCG_Error( \"CG_RegisterClientModelname( %s, %s, %s, %s %s ) failed\", ci->modelName, ci->skinName, ci->headModelName, ci->headSkinName, teamname );\n\t\t}\n\n\t\t// fall back to default team name\n\t\tif( cgs.gametype >= GT_TEAM) {\n\t\t\t// keep skin name\n\t\t\tif( ci->team == TEAM_BLUE ) {\n\t\t\t\tQ_strncpyz(teamname, DEFAULT_BLUETEAM_NAME, sizeof(teamname) );\n\t\t\t} else {\n\t\t\t\tQ_strncpyz(teamname, DEFAULT_REDTEAM_NAME, sizeof(teamname) );\n\t\t\t}\n\t\t\tif ( !CG_RegisterClientModelname( ci, DEFAULT_TEAM_MODEL, ci->skinName, DEFAULT_TEAM_HEAD, ci->skinName, teamname ) ) {\n\t\t\t\tCG_Error( \"DEFAULT_TEAM_MODEL / skin (%s/%s) failed to register\", DEFAULT_TEAM_MODEL, ci->skinName );\n\t\t\t}\n\t\t} else {\n\t\t\tif ( !CG_RegisterClientModelname( ci, DEFAULT_MODEL, \"default\", DEFAULT_MODEL, \"default\", teamname ) ) {\n\t\t\t\tCG_Error( \"DEFAULT_MODEL (%s) failed to register\", DEFAULT_MODEL );\n\t\t\t}\n\t\t}\n\t\tmodelloaded = qfalse;\n\t}\n\n\tci->newAnims = qfalse;\n\tif ( ci->torsoModel ) {\n\t\torientation_t tag;\n\t\t// if the torso model has the \"tag_flag\"\n\t\tif ( trap_R_LerpTag( &tag, ci->torsoModel, 0, 0, 1, \"tag_flag\" ) ) {\n\t\t\tci->newAnims = qtrue;\n\t\t}\n\t}\n\n\t// sounds\n\tdir = ci->modelName;\n\tfallback = (cgs.gametype >= GT_TEAM) ? DEFAULT_TEAM_MODEL : DEFAULT_MODEL;\n\n\tfor ( i = 0 ; i < MAX_CUSTOM_SOUNDS ; i++ ) {\n\t\ts = cg_customSoundNames[i];\n\t\tif ( !s ) {\n\t\t\tbreak;\n\t\t}\n\t\tci->sounds[i] = 0;\n\t\t// if the model didn't load use the sounds of the default model\n\t\tif (modelloaded) {\n\t\t\tci->sounds[i] = trap_S_RegisterSound( va(\"sound/player/%s/%s\", dir, s + 1), qfalse );\n\t\t}\n\t\tif ( !ci->sounds[i] ) {\n\t\t\tci->sounds[i] = trap_S_RegisterSound( va(\"sound/player/%s/%s\", fallback, s + 1), qfalse );\n\t\t}\n\t}\n\n\tci->deferred = qfalse;\n\n\t// reset any existing players and bodies, because they might be in bad\n\t// frames for this new model\n\tclientNum = ci - cgs.clientinfo;\n\tfor ( i = 0 ; i < MAX_GENTITIES ; i++ ) {\n\t\tif ( cg_entities[i].currentState.clientNum == clientNum\n\t\t\t&& cg_entities[i].currentState.eType == ET_PLAYER ) {\n\t\t\tCG_ResetPlayerEntity( &cg_entities[i] );\n\t\t}\n\t}\n}\n\n/*\n======================\nCG_CopyClientInfoModel\n======================\n*/\nstatic void CG_CopyClientInfoModel( clientInfo_t *from, clientInfo_t *to ) {\n\tVectorCopy( from->headOffset, to->headOffset );\n\tto->footsteps = from->footsteps;\n\tto->gender = from->gender;\n\n\tto->legsModel = from->legsModel;\n\tto->legsSkin = from->legsSkin;\n\tto->torsoModel = from->torsoModel;\n\tto->torsoSkin = from->torsoSkin;\n\tto->headModel = from->headModel;\n\tto->headSkin = from->headSkin;\n\tto->modelIcon = from->modelIcon;\n\n\tto->newAnims = from->newAnims;\n\n\tmemcpy( to->animations, from->animations, sizeof( to->animations ) );\n\tmemcpy( to->sounds, from->sounds, sizeof( to->sounds ) );\n}\n\n/*\n======================\nCG_ScanForExistingClientInfo\n======================\n*/\nstatic qboolean CG_ScanForExistingClientInfo( clientInfo_t *ci ) {\n\tint\t\ti;\n\tclientInfo_t\t*match;\n\n\tfor ( i = 0 ; i < cgs.maxclients ; i++ ) {\n\t\tmatch = &cgs.clientinfo[ i ];\n\t\tif ( !match->infoValid ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( match->deferred ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( !Q_stricmp( ci->modelName, match->modelName )\n\t\t\t&& !Q_stricmp( ci->skinName, match->skinName )\n\t\t\t&& !Q_stricmp( ci->headModelName, match->headModelName )\n\t\t\t&& !Q_stricmp( ci->headSkinName, match->headSkinName ) \n\t\t\t&& !Q_stricmp( ci->blueTeam, match->blueTeam ) \n\t\t\t&& !Q_stricmp( ci->redTeam, match->redTeam )\n\t\t\t&& (cgs.gametype < GT_TEAM || ci->team == match->team) ) {\n\t\t\t// this clientinfo is identical, so use it's handles\n\n\t\t\tci->deferred = qfalse;\n\n\t\t\tCG_CopyClientInfoModel( match, ci );\n\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\n\t// nothing matches, so defer the load\n\treturn qfalse;\n}\n\n/*\n======================\nCG_SetDeferredClientInfo\n\nWe aren't going to load it now, so grab some other\nclient's info to use until we have some spare time.\n======================\n*/\nstatic void CG_SetDeferredClientInfo( clientInfo_t *ci ) {\n\tint\t\ti;\n\tclientInfo_t\t*match;\n\n\t// if someone else is already the same models and skins we\n\t// can just load the client info\n\tfor ( i = 0 ; i < cgs.maxclients ; i++ ) {\n\t\tmatch = &cgs.clientinfo[ i ];\n\t\tif ( !match->infoValid || match->deferred ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( Q_stricmp( ci->skinName, match->skinName ) ||\n\t\t\t Q_stricmp( ci->modelName, match->modelName ) ||\n//\t\t\t Q_stricmp( ci->headModelName, match->headModelName ) ||\n//\t\t\t Q_stricmp( ci->headSkinName, match->headSkinName ) ||\n\t\t\t (cgs.gametype >= GT_TEAM && ci->team != match->team) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// just load the real info cause it uses the same models and skins\n\t\tCG_LoadClientInfo( ci );\n\t\treturn;\n\t}\n\n\t// if we are in teamplay, only grab a model if the skin is correct\n\tif ( cgs.gametype >= GT_TEAM ) {\n\t\tfor ( i = 0 ; i < cgs.maxclients ; i++ ) {\n\t\t\tmatch = &cgs.clientinfo[ i ];\n\t\t\tif ( !match->infoValid || match->deferred ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( Q_stricmp( ci->skinName, match->skinName ) ||\n\t\t\t\t(cgs.gametype >= GT_TEAM && ci->team != match->team) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tci->deferred = qtrue;\n\t\t\tCG_CopyClientInfoModel( match, ci );\n\t\t\treturn;\n\t\t}\n\t\t// load the full model, because we don't ever want to show\n\t\t// an improper team skin.  This will cause a hitch for the first\n\t\t// player, when the second enters.  Combat shouldn't be going on\n\t\t// yet, so it shouldn't matter\n\t\tCG_LoadClientInfo( ci );\n\t\treturn;\n\t}\n\n\t// find the first valid clientinfo and grab its stuff\n\tfor ( i = 0 ; i < cgs.maxclients ; i++ ) {\n\t\tmatch = &cgs.clientinfo[ i ];\n\t\tif ( !match->infoValid ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tci->deferred = qtrue;\n\t\tCG_CopyClientInfoModel( match, ci );\n\t\treturn;\n\t}\n\n\t// we should never get here...\n\tCG_Printf( \"CG_SetDeferredClientInfo: no valid clients!\\n\" );\n\n\tCG_LoadClientInfo( ci );\n}\n\n\n/*\n======================\nCG_NewClientInfo\n======================\n*/\nvoid CG_NewClientInfo( int clientNum ) {\n\tclientInfo_t *ci;\n\tclientInfo_t newInfo;\n\tconst char\t*configstring;\n\tconst char\t*v;\n\tchar\t\t*slash;\n\n\tci = &cgs.clientinfo[clientNum];\n\n\tconfigstring = CG_ConfigString( clientNum + CS_PLAYERS );\n\tif ( !configstring[0] ) {\n\t\tmemset( ci, 0, sizeof( *ci ) );\n\t\treturn;\t\t// player just left\n\t}\n\n\t// build into a temp buffer so the defer checks can use\n\t// the old value\n\tmemset( &newInfo, 0, sizeof( newInfo ) );\n\n\t// isolate the player's name\n\tv = Info_ValueForKey(configstring, \"n\");\n\tQ_strncpyz( newInfo.name, v, sizeof( newInfo.name ) );\n\n\t// colors\n\tv = Info_ValueForKey( configstring, \"c1\" );\n\tCG_ColorFromString( v, newInfo.color1 );\n\n\tv = Info_ValueForKey( configstring, \"c2\" );\n\tCG_ColorFromString( v, newInfo.color2 );\n\n\t// bot skill\n\tv = Info_ValueForKey( configstring, \"skill\" );\n\tnewInfo.botSkill = atoi( v );\n\n\t// handicap\n\tv = Info_ValueForKey( configstring, \"hc\" );\n\tnewInfo.handicap = atoi( v );\n\n\t// wins\n\tv = Info_ValueForKey( configstring, \"w\" );\n\tnewInfo.wins = atoi( v );\n\n\t// losses\n\tv = Info_ValueForKey( configstring, \"l\" );\n\tnewInfo.losses = atoi( v );\n\n\t// team\n\tv = Info_ValueForKey( configstring, \"t\" );\n\tnewInfo.team = atoi( v );\n\n\t// team task\n\tv = Info_ValueForKey( configstring, \"tt\" );\n\tnewInfo.teamTask = atoi(v);\n\n\t// team leader\n\tv = Info_ValueForKey( configstring, \"tl\" );\n\tnewInfo.teamLeader = atoi(v);\n\n\tv = Info_ValueForKey( configstring, \"g_redteam\" );\n\tQ_strncpyz(newInfo.redTeam, v, MAX_TEAMNAME);\n\n\tv = Info_ValueForKey( configstring, \"g_blueteam\" );\n\tQ_strncpyz(newInfo.blueTeam, v, MAX_TEAMNAME);\n\n\t// model\n\tv = Info_ValueForKey( configstring, \"model\" );\n\tif ( cg_forceModel.integer ) {\n\t\t// forcemodel makes everyone use a single model\n\t\t// to prevent load hitches\n\t\tchar modelStr[MAX_QPATH];\n\t\tchar *skin;\n\n\t\tif( cgs.gametype >= GT_TEAM ) {\n\t\t\tQ_strncpyz( newInfo.modelName, DEFAULT_TEAM_MODEL, sizeof( newInfo.modelName ) );\n\t\t\tQ_strncpyz( newInfo.skinName, \"default\", sizeof( newInfo.skinName ) );\n\t\t} else {\n\t\t\ttrap_Cvar_VariableStringBuffer( \"model\", modelStr, sizeof( modelStr ) );\n\t\t\tif ( ( skin = strchr( modelStr, '/' ) ) == NULL) {\n\t\t\t\tskin = \"default\";\n\t\t\t} else {\n\t\t\t\t*skin++ = 0;\n\t\t\t}\n\n\t\t\tQ_strncpyz( newInfo.skinName, skin, sizeof( newInfo.skinName ) );\n\t\t\tQ_strncpyz( newInfo.modelName, modelStr, sizeof( newInfo.modelName ) );\n\t\t}\n\n\t\tif ( cgs.gametype >= GT_TEAM ) {\n\t\t\t// keep skin name\n\t\t\tslash = strchr( v, '/' );\n\t\t\tif ( slash ) {\n\t\t\t\tQ_strncpyz( newInfo.skinName, slash + 1, sizeof( newInfo.skinName ) );\n\t\t\t}\n\t\t}\n\t} else {\n\t\tQ_strncpyz( newInfo.modelName, v, sizeof( newInfo.modelName ) );\n\n\t\tslash = strchr( newInfo.modelName, '/' );\n\t\tif ( !slash ) {\n\t\t\t// modelName didn not include a skin name\n\t\t\tQ_strncpyz( newInfo.skinName, \"default\", sizeof( newInfo.skinName ) );\n\t\t} else {\n\t\t\tQ_strncpyz( newInfo.skinName, slash + 1, sizeof( newInfo.skinName ) );\n\t\t\t// truncate modelName\n\t\t\t*slash = 0;\n\t\t}\n\t}\n\n\t// head model\n\tv = Info_ValueForKey( configstring, \"hmodel\" );\n\tif ( cg_forceModel.integer ) {\n\t\t// forcemodel makes everyone use a single model\n\t\t// to prevent load hitches\n\t\tchar modelStr[MAX_QPATH];\n\t\tchar *skin;\n\n\t\tif( cgs.gametype >= GT_TEAM ) {\n\t\t\tQ_strncpyz( newInfo.headModelName, DEFAULT_TEAM_MODEL, sizeof( newInfo.headModelName ) );\n\t\t\tQ_strncpyz( newInfo.headSkinName, \"default\", sizeof( newInfo.headSkinName ) );\n\t\t} else {\n\t\t\ttrap_Cvar_VariableStringBuffer( \"headmodel\", modelStr, sizeof( modelStr ) );\n\t\t\tif ( ( skin = strchr( modelStr, '/' ) ) == NULL) {\n\t\t\t\tskin = \"default\";\n\t\t\t} else {\n\t\t\t\t*skin++ = 0;\n\t\t\t}\n\n\t\t\tQ_strncpyz( newInfo.headSkinName, skin, sizeof( newInfo.headSkinName ) );\n\t\t\tQ_strncpyz( newInfo.headModelName, modelStr, sizeof( newInfo.headModelName ) );\n\t\t}\n\n\t\tif ( cgs.gametype >= GT_TEAM ) {\n\t\t\t// keep skin name\n\t\t\tslash = strchr( v, '/' );\n\t\t\tif ( slash ) {\n\t\t\t\tQ_strncpyz( newInfo.headSkinName, slash + 1, sizeof( newInfo.headSkinName ) );\n\t\t\t}\n\t\t}\n\t} else {\n\t\tQ_strncpyz( newInfo.headModelName, v, sizeof( newInfo.headModelName ) );\n\n\t\tslash = strchr( newInfo.headModelName, '/' );\n\t\tif ( !slash ) {\n\t\t\t// modelName didn not include a skin name\n\t\t\tQ_strncpyz( newInfo.headSkinName, \"default\", sizeof( newInfo.headSkinName ) );\n\t\t} else {\n\t\t\tQ_strncpyz( newInfo.headSkinName, slash + 1, sizeof( newInfo.headSkinName ) );\n\t\t\t// truncate modelName\n\t\t\t*slash = 0;\n\t\t}\n\t}\n\n\t// scan for an existing clientinfo that matches this modelname\n\t// so we can avoid loading checks if possible\n\tif ( !CG_ScanForExistingClientInfo( &newInfo ) ) {\n\t\tqboolean\tforceDefer;\n\n\t\tforceDefer = trap_MemoryRemaining() < 4000000;\n\n\t\t// if we are defering loads, just have it pick the first valid\n\t\tif ( forceDefer || (cg_deferPlayers.integer && !cg_buildScript.integer && !cg.loading ) ) {\n\t\t\t// keep whatever they had if it won't violate team skins\n\t\t\tCG_SetDeferredClientInfo( &newInfo );\n\t\t\t// if we are low on memory, leave them with this model\n\t\t\tif ( forceDefer ) {\n\t\t\t\tCG_Printf( \"Memory is low.  Using deferred model.\\n\" );\n\t\t\t\tnewInfo.deferred = qfalse;\n\t\t\t}\n\t\t} else {\n\t\t\tCG_LoadClientInfo( &newInfo );\n\t\t}\n\t}\n\n\t// replace whatever was there with the new one\n\tnewInfo.infoValid = qtrue;\n\t*ci = newInfo;\n}\n\n\n\n/*\n======================\nCG_LoadDeferredPlayers\n\nCalled each frame when a player is dead\nand the scoreboard is up\nso deferred players can be loaded\n======================\n*/\nvoid CG_LoadDeferredPlayers( void ) {\n\tint\t\ti;\n\tclientInfo_t\t*ci;\n\n\t// scan for a deferred player to load\n\tfor ( i = 0, ci = cgs.clientinfo ; i < cgs.maxclients ; i++, ci++ ) {\n\t\tif ( ci->infoValid && ci->deferred ) {\n\t\t\t// if we are low on memory, leave it deferred\n\t\t\tif ( trap_MemoryRemaining() < 4000000 ) {\n\t\t\t\tCG_Printf( \"Memory is low.  Using deferred model.\\n\" );\n\t\t\t\tci->deferred = qfalse;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tCG_LoadClientInfo( ci );\n//\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/*\n=============================================================================\n\nPLAYER ANIMATION\n\n=============================================================================\n*/\n\n\n/*\n===============\nCG_SetLerpFrameAnimation\n\nmay include ANIM_TOGGLEBIT\n===============\n*/\nstatic void CG_SetLerpFrameAnimation( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation ) {\n\tanimation_t\t*anim;\n\n\tlf->animationNumber = newAnimation;\n\tnewAnimation &= ~ANIM_TOGGLEBIT;\n\n\tif ( newAnimation < 0 || newAnimation >= MAX_TOTALANIMATIONS ) {\n\t\tCG_Error( \"Bad animation number: %i\", newAnimation );\n\t}\n\n\tanim = &ci->animations[ newAnimation ];\n\n\tlf->animation = anim;\n\tlf->animationTime = lf->frameTime + anim->initialLerp;\n\n\tif ( cg_debugAnim.integer ) {\n\t\tCG_Printf( \"Anim: %i\\n\", newAnimation );\n\t}\n}\n\n/*\n===============\nCG_RunLerpFrame\n\nSets cg.snap, cg.oldFrame, and cg.backlerp\ncg.time should be between oldFrameTime and frameTime after exit\n===============\n*/\nstatic void CG_RunLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation, float speedScale ) {\n\tint\t\t\tf, numFrames;\n\tanimation_t\t*anim;\n\n\t// debugging tool to get no animations\n\tif ( cg_animSpeed.integer == 0 ) {\n\t\tlf->oldFrame = lf->frame = lf->backlerp = 0;\n\t\treturn;\n\t}\n\n\t// see if the animation sequence is switching\n\tif ( newAnimation != lf->animationNumber || !lf->animation ) {\n\t\tCG_SetLerpFrameAnimation( ci, lf, newAnimation );\n\t}\n\n\t// if we have passed the current frame, move it to\n\t// oldFrame and calculate a new frame\n\tif ( cg.time >= lf->frameTime ) {\n\t\tlf->oldFrame = lf->frame;\n\t\tlf->oldFrameTime = lf->frameTime;\n\n\t\t// get the next frame based on the animation\n\t\tanim = lf->animation;\n\t\tif ( !anim->frameLerp ) {\n\t\t\treturn;\t\t// shouldn't happen\n\t\t}\n\t\tif ( cg.time < lf->animationTime ) {\n\t\t\tlf->frameTime = lf->animationTime;\t\t// initial lerp\n\t\t} else {\n\t\t\tlf->frameTime = lf->oldFrameTime + anim->frameLerp;\n\t\t}\n\t\tf = ( lf->frameTime - lf->animationTime ) / anim->frameLerp;\n\t\tf *= speedScale;\t\t// adjust for haste, etc\n\n\t\tnumFrames = anim->numFrames;\n\t\tif (anim->flipflop) {\n\t\t\tnumFrames *= 2;\n\t\t}\n\t\tif ( f >= numFrames ) {\n\t\t\tf -= numFrames;\n\t\t\tif ( anim->loopFrames ) {\n\t\t\t\tf %= anim->loopFrames;\n\t\t\t\tf += anim->numFrames - anim->loopFrames;\n\t\t\t} else {\n\t\t\t\tf = numFrames - 1;\n\t\t\t\t// the animation is stuck at the end, so it\n\t\t\t\t// can immediately transition to another sequence\n\t\t\t\tlf->frameTime = cg.time;\n\t\t\t}\n\t\t}\n\t\tif ( anim->reversed ) {\n\t\t\tlf->frame = anim->firstFrame + anim->numFrames - 1 - f;\n\t\t}\n\t\telse if (anim->flipflop && f>=anim->numFrames) {\n\t\t\tlf->frame = anim->firstFrame + anim->numFrames - 1 - (f%anim->numFrames);\n\t\t}\n\t\telse {\n\t\t\tlf->frame = anim->firstFrame + f;\n\t\t}\n\t\tif ( cg.time > lf->frameTime ) {\n\t\t\tlf->frameTime = cg.time;\n\t\t\tif ( cg_debugAnim.integer ) {\n\t\t\t\tCG_Printf( \"Clamp lf->frameTime\\n\");\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( lf->frameTime > cg.time + 200 ) {\n\t\tlf->frameTime = cg.time;\n\t}\n\n\tif ( lf->oldFrameTime > cg.time ) {\n\t\tlf->oldFrameTime = cg.time;\n\t}\n\t// calculate current lerp value\n\tif ( lf->frameTime == lf->oldFrameTime ) {\n\t\tlf->backlerp = 0;\n\t} else {\n\t\tlf->backlerp = 1.0 - (float)( cg.time - lf->oldFrameTime ) / ( lf->frameTime - lf->oldFrameTime );\n\t}\n}\n\n\n/*\n===============\nCG_ClearLerpFrame\n===============\n*/\nstatic void CG_ClearLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int animationNumber ) {\n\tlf->frameTime = lf->oldFrameTime = cg.time;\n\tCG_SetLerpFrameAnimation( ci, lf, animationNumber );\n\tlf->oldFrame = lf->frame = lf->animation->firstFrame;\n}\n\n\n/*\n===============\nCG_PlayerAnimation\n===============\n*/\nstatic void CG_PlayerAnimation( centity_t *cent, int *legsOld, int *legs, float *legsBackLerp,\n\t\t\t\t\t\tint *torsoOld, int *torso, float *torsoBackLerp ) {\n\tclientInfo_t\t*ci;\n\tint\t\t\t\tclientNum;\n\tfloat\t\t\tspeedScale;\n\n\tclientNum = cent->currentState.clientNum;\n\n\tif ( cg_noPlayerAnims.integer ) {\n\t\t*legsOld = *legs = *torsoOld = *torso = 0;\n\t\treturn;\n\t}\n\n\tif ( cent->currentState.powerups & ( 1 << PW_HASTE ) ) {\n\t\tspeedScale = 1.5;\n\t} else {\n\t\tspeedScale = 1;\n\t}\n\n\tci = &cgs.clientinfo[ clientNum ];\n\n\t// do the shuffle turn frames locally\n\tif ( cent->pe.legs.yawing && ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_IDLE ) {\n\t\tCG_RunLerpFrame( ci, &cent->pe.legs, LEGS_TURN, speedScale );\n\t} else {\n\t\tCG_RunLerpFrame( ci, &cent->pe.legs, cent->currentState.legsAnim, speedScale );\n\t}\n\n\t*legsOld = cent->pe.legs.oldFrame;\n\t*legs = cent->pe.legs.frame;\n\t*legsBackLerp = cent->pe.legs.backlerp;\n\n\tCG_RunLerpFrame( ci, &cent->pe.torso, cent->currentState.torsoAnim, speedScale );\n\n\t*torsoOld = cent->pe.torso.oldFrame;\n\t*torso = cent->pe.torso.frame;\n\t*torsoBackLerp = cent->pe.torso.backlerp;\n}\n\n/*\n=============================================================================\n\nPLAYER ANGLES\n\n=============================================================================\n*/\n\n/*\n==================\nCG_SwingAngles\n==================\n*/\nstatic void CG_SwingAngles( float destination, float swingTolerance, float clampTolerance,\n\t\t\t\t\tfloat speed, float *angle, qboolean *swinging ) {\n\tfloat\tswing;\n\tfloat\tmove;\n\tfloat\tscale;\n\n\tif ( !*swinging ) {\n\t\t// see if a swing should be started\n\t\tswing = AngleSubtract( *angle, destination );\n\t\tif ( swing > swingTolerance || swing < -swingTolerance ) {\n\t\t\t*swinging = qtrue;\n\t\t}\n\t}\n\n\tif ( !*swinging ) {\n\t\treturn;\n\t}\n\t\n\t// modify the speed depending on the delta\n\t// so it doesn't seem so linear\n\tswing = AngleSubtract( destination, *angle );\n\tscale = fabs( swing );\n\tif ( scale < swingTolerance * 0.5 ) {\n\t\tscale = 0.5;\n\t} else if ( scale < swingTolerance ) {\n\t\tscale = 1.0;\n\t} else {\n\t\tscale = 2.0;\n\t}\n\n\t// swing towards the destination angle\n\tif ( swing >= 0 ) {\n\t\tmove = cg.frametime * scale * speed;\n\t\tif ( move >= swing ) {\n\t\t\tmove = swing;\n\t\t\t*swinging = qfalse;\n\t\t}\n\t\t*angle = AngleMod( *angle + move );\n\t} else if ( swing < 0 ) {\n\t\tmove = cg.frametime * scale * -speed;\n\t\tif ( move <= swing ) {\n\t\t\tmove = swing;\n\t\t\t*swinging = qfalse;\n\t\t}\n\t\t*angle = AngleMod( *angle + move );\n\t}\n\n\t// clamp to no more than tolerance\n\tswing = AngleSubtract( destination, *angle );\n\tif ( swing > clampTolerance ) {\n\t\t*angle = AngleMod( destination - (clampTolerance - 1) );\n\t} else if ( swing < -clampTolerance ) {\n\t\t*angle = AngleMod( destination + (clampTolerance - 1) );\n\t}\n}\n\n/*\n=================\nCG_AddPainTwitch\n=================\n*/\nstatic void CG_AddPainTwitch( centity_t *cent, vec3_t torsoAngles ) {\n\tint\t\tt;\n\tfloat\tf;\n\n\tt = cg.time - cent->pe.painTime;\n\tif ( t >= PAIN_TWITCH_TIME ) {\n\t\treturn;\n\t}\n\n\tf = 1.0 - (float)t / PAIN_TWITCH_TIME;\n\n\tif ( cent->pe.painDirection ) {\n\t\ttorsoAngles[ROLL] += 20 * f;\n\t} else {\n\t\ttorsoAngles[ROLL] -= 20 * f;\n\t}\n}\n\n\n/*\n===============\nCG_PlayerAngles\n\nHandles seperate torso motion\n\n  legs pivot based on direction of movement\n\n  head always looks exactly at cent->lerpAngles\n\n  if motion < 20 degrees, show in head only\n  if < 45 degrees, also show in torso\n===============\n*/\nstatic void CG_PlayerAngles( centity_t *cent, vec3_t legs[3], vec3_t torso[3], vec3_t head[3] ) {\n\tvec3_t\t\tlegsAngles, torsoAngles, headAngles;\n\tfloat\t\tdest;\n\tstatic\tint\tmovementOffsets[8] = { 0, 22, 45, -22, 0, 22, -45, -22 };\n\tvec3_t\t\tvelocity;\n\tfloat\t\tspeed;\n\tint\t\t\tdir, clientNum;\n\tclientInfo_t\t*ci;\n\n\tVectorCopy( cent->lerpAngles, headAngles );\n\theadAngles[YAW] = AngleMod( headAngles[YAW] );\n\tVectorClear( legsAngles );\n\tVectorClear( torsoAngles );\n\n\t// --------- yaw -------------\n\n\t// allow yaw to drift a bit\n\tif ( ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) != LEGS_IDLE \n\t\t|| ( cent->currentState.torsoAnim & ~ANIM_TOGGLEBIT ) != TORSO_STAND  ) {\n\t\t// if not standing still, always point all in the same direction\n\t\tcent->pe.torso.yawing = qtrue;\t// always center\n\t\tcent->pe.torso.pitching = qtrue;\t// always center\n\t\tcent->pe.legs.yawing = qtrue;\t// always center\n\t}\n\n\t// adjust legs for movement dir\n\tif ( cent->currentState.eFlags & EF_DEAD ) {\n\t\t// don't let dead bodies twitch\n\t\tdir = 0;\n\t} else {\n\t\tdir = cent->currentState.angles2[YAW];\n\t\tif ( dir < 0 || dir > 7 ) {\n\t\t\tCG_Error( \"Bad player movement angle\" );\n\t\t}\n\t}\n\tlegsAngles[YAW] = headAngles[YAW] + movementOffsets[ dir ];\n\ttorsoAngles[YAW] = headAngles[YAW] + 0.25 * movementOffsets[ dir ];\n\n\t// torso\n\tCG_SwingAngles( torsoAngles[YAW], 25, 90, cg_swingSpeed.value, &cent->pe.torso.yawAngle, &cent->pe.torso.yawing );\n\tCG_SwingAngles( legsAngles[YAW], 40, 90, cg_swingSpeed.value, &cent->pe.legs.yawAngle, &cent->pe.legs.yawing );\n\n\ttorsoAngles[YAW] = cent->pe.torso.yawAngle;\n\tlegsAngles[YAW] = cent->pe.legs.yawAngle;\n\n\n\t// --------- pitch -------------\n\n\t// only show a fraction of the pitch angle in the torso\n\tif ( headAngles[PITCH] > 180 ) {\n\t\tdest = (-360 + headAngles[PITCH]) * 0.75f;\n\t} else {\n\t\tdest = headAngles[PITCH] * 0.75f;\n\t}\n\tCG_SwingAngles( dest, 15, 30, 0.1f, &cent->pe.torso.pitchAngle, &cent->pe.torso.pitching );\n\ttorsoAngles[PITCH] = cent->pe.torso.pitchAngle;\n\n\t//\n\tclientNum = cent->currentState.clientNum;\n\tif ( clientNum >= 0 && clientNum < MAX_CLIENTS ) {\n\t\tci = &cgs.clientinfo[ clientNum ];\n\t\tif ( ci->fixedtorso ) {\n\t\t\ttorsoAngles[PITCH] = 0.0f;\n\t\t}\n\t}\n\n\t// --------- roll -------------\n\n\n\t// lean towards the direction of travel\n\tVectorCopy( cent->currentState.pos.trDelta, velocity );\n\tspeed = VectorNormalize( velocity );\n\tif ( speed ) {\n\t\tvec3_t\taxis[3];\n\t\tfloat\tside;\n\n\t\tspeed *= 0.05f;\n\n\t\tAnglesToAxis( legsAngles, axis );\n\t\tside = speed * DotProduct( velocity, axis[1] );\n\t\tlegsAngles[ROLL] -= side;\n\n\t\tside = speed * DotProduct( velocity, axis[0] );\n\t\tlegsAngles[PITCH] += side;\n\t}\n\n\t//\n\tclientNum = cent->currentState.clientNum;\n\tif ( clientNum >= 0 && clientNum < MAX_CLIENTS ) {\n\t\tci = &cgs.clientinfo[ clientNum ];\n\t\tif ( ci->fixedlegs ) {\n\t\t\tlegsAngles[YAW] = torsoAngles[YAW];\n\t\t\tlegsAngles[PITCH] = 0.0f;\n\t\t\tlegsAngles[ROLL] = 0.0f;\n\t\t}\n\t}\n\n\t// pain twitch\n\tCG_AddPainTwitch( cent, torsoAngles );\n\n\t// pull the angles back out of the hierarchial chain\n\tAnglesSubtract( headAngles, torsoAngles, headAngles );\n\tAnglesSubtract( torsoAngles, legsAngles, torsoAngles );\n\tAnglesToAxis( legsAngles, legs );\n\tAnglesToAxis( torsoAngles, torso );\n\tAnglesToAxis( headAngles, head );\n}\n\n\n//==========================================================================\n\n/*\n===============\nCG_HasteTrail\n===============\n*/\nstatic void CG_HasteTrail( centity_t *cent ) {\n\tlocalEntity_t\t*smoke;\n\tvec3_t\t\t\torigin;\n\tint\t\t\t\tanim;\n\n\tif ( cent->trailTime > cg.time ) {\n\t\treturn;\n\t}\n\tanim = cent->pe.legs.animationNumber & ~ANIM_TOGGLEBIT;\n\tif ( anim != LEGS_RUN && anim != LEGS_BACK ) {\n\t\treturn;\n\t}\n\n\tcent->trailTime += 100;\n\tif ( cent->trailTime < cg.time ) {\n\t\tcent->trailTime = cg.time;\n\t}\n\n\tVectorCopy( cent->lerpOrigin, origin );\n\torigin[2] -= 16;\n\n\tsmoke = CG_SmokePuff( origin, vec3_origin, \n\t\t\t\t  8, \n\t\t\t\t  1, 1, 1, 1,\n\t\t\t\t  500, \n\t\t\t\t  cg.time,\n\t\t\t\t  0,\n\t\t\t\t  0,\n\t\t\t\t  cgs.media.hastePuffShader );\n\n\t// use the optimized local entity add\n\tsmoke->leType = LE_SCALE_FADE;\n}\n\n#ifdef MISSIONPACK\n/*\n===============\nCG_BreathPuffs\n===============\n*/\nstatic void CG_BreathPuffs( centity_t *cent, refEntity_t *head) {\n\tclientInfo_t *ci;\n\tvec3_t up, origin;\n\tint contents;\n\n\tci = &cgs.clientinfo[ cent->currentState.number ];\n\n\tif (!cg_enableBreath.integer) {\n\t\treturn;\n\t}\n\tif ( cent->currentState.number == cg.snap->ps.clientNum && !cg.renderingThirdPerson) {\n\t\treturn;\n\t}\n\tif ( cent->currentState.eFlags & EF_DEAD ) {\n\t\treturn;\n\t}\n\tcontents = trap_CM_PointContents( head->origin, 0 );\n\tif ( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ) {\n\t\treturn;\n\t}\n\tif ( ci->breathPuffTime > cg.time ) {\n\t\treturn;\n\t}\n\n\tVectorSet( up, 0, 0, 8 );\n\tVectorMA(head->origin, 8, head->axis[0], origin);\n\tVectorMA(origin, -4, head->axis[2], origin);\n\tCG_SmokePuff( origin, up, 16, 1, 1, 1, 0.66f, 1500, cg.time, cg.time + 400, LEF_PUFF_DONT_SCALE, cgs.media.shotgunSmokePuffShader );\n\tci->breathPuffTime = cg.time + 2000;\n}\n\n/*\n===============\nCG_DustTrail\n===============\n*/\nstatic void CG_DustTrail( centity_t *cent ) {\n\tint\t\t\t\tanim;\n\tlocalEntity_t\t*dust;\n\tvec3_t end, vel;\n\ttrace_t tr;\n\n\tif (!cg_enableDust.integer)\n\t\treturn;\n\n\tif ( cent->dustTrailTime > cg.time ) {\n\t\treturn;\n\t}\n\n\tanim = cent->pe.legs.animationNumber & ~ANIM_TOGGLEBIT;\n\tif ( anim != LEGS_LANDB && anim != LEGS_LAND ) {\n\t\treturn;\n\t}\n\n\tcent->dustTrailTime += 40;\n\tif ( cent->dustTrailTime < cg.time ) {\n\t\tcent->dustTrailTime = cg.time;\n\t}\n\n\tVectorCopy(cent->currentState.pos.trBase, end);\n\tend[2] -= 64;\n\tCG_Trace( &tr, cent->currentState.pos.trBase, NULL, NULL, end, cent->currentState.number, MASK_PLAYERSOLID );\n\n\tif ( !(tr.surfaceFlags & SURF_DUST) )\n\t\treturn;\n\n\tVectorCopy( cent->currentState.pos.trBase, end );\n\tend[2] -= 16;\n\n\tVectorSet(vel, 0, 0, -30);\n\tdust = CG_SmokePuff( end, vel,\n\t\t\t\t  24,\n\t\t\t\t  .8f, .8f, 0.7f, 0.33f,\n\t\t\t\t  500,\n\t\t\t\t  cg.time,\n\t\t\t\t  0,\n\t\t\t\t  0,\n\t\t\t\t  cgs.media.dustPuffShader );\n}\n\n#endif\n\n/*\n===============\nCG_TrailItem\n===============\n*/\nstatic void CG_TrailItem( centity_t *cent, qhandle_t hModel ) {\n\trefEntity_t\t\tent;\n\tvec3_t\t\t\tangles;\n\tvec3_t\t\t\taxis[3];\n\n\tVectorCopy( cent->lerpAngles, angles );\n\tangles[PITCH] = 0;\n\tangles[ROLL] = 0;\n\tAnglesToAxis( angles, axis );\n\n\tmemset( &ent, 0, sizeof( ent ) );\n\tVectorMA( cent->lerpOrigin, -16, axis[0], ent.origin );\n\tent.origin[2] += 16;\n\tangles[YAW] += 90;\n\tAnglesToAxis( angles, ent.axis );\n\n\tent.hModel = hModel;\n\ttrap_R_AddRefEntityToScene( &ent );\n}\n\n\n/*\n===============\nCG_PlayerFlag\n===============\n*/\nstatic void CG_PlayerFlag( centity_t *cent, qhandle_t hSkin, refEntity_t *torso ) {\n\tclientInfo_t\t*ci;\n\trefEntity_t\tpole;\n\trefEntity_t\tflag;\n\tvec3_t\t\tangles, dir;\n\tint\t\t\tlegsAnim, flagAnim, updateangles;\n\tfloat\t\tangle, d;\n\n\t// show the flag pole model\n\tmemset( &pole, 0, sizeof(pole) );\n\tpole.hModel = cgs.media.flagPoleModel;\n\tVectorCopy( torso->lightingOrigin, pole.lightingOrigin );\n\tpole.shadowPlane = torso->shadowPlane;\n\tpole.renderfx = torso->renderfx;\n\tCG_PositionEntityOnTag( &pole, torso, torso->hModel, \"tag_flag\" );\n\ttrap_R_AddRefEntityToScene( &pole );\n\n\t// show the flag model\n\tmemset( &flag, 0, sizeof(flag) );\n\tflag.hModel = cgs.media.flagFlapModel;\n\tflag.customSkin = hSkin;\n\tVectorCopy( torso->lightingOrigin, flag.lightingOrigin );\n\tflag.shadowPlane = torso->shadowPlane;\n\tflag.renderfx = torso->renderfx;\n\n\tVectorClear(angles);\n\n\tupdateangles = qfalse;\n\tlegsAnim = cent->currentState.legsAnim & ~ANIM_TOGGLEBIT;\n\tif( legsAnim == LEGS_IDLE || legsAnim == LEGS_IDLECR ) {\n\t\tflagAnim = FLAG_STAND;\n\t} else if ( legsAnim == LEGS_WALK || legsAnim == LEGS_WALKCR ) {\n\t\tflagAnim = FLAG_STAND;\n\t\tupdateangles = qtrue;\n\t} else {\n\t\tflagAnim = FLAG_RUN;\n\t\tupdateangles = qtrue;\n\t}\n\n\tif ( updateangles ) {\n\n\t\tVectorCopy( cent->currentState.pos.trDelta, dir );\n\t\t// add gravity\n\t\tdir[2] += 100;\n\t\tVectorNormalize( dir );\n\t\td = DotProduct(pole.axis[2], dir);\n\t\t// if there is anough movement orthogonal to the flag pole\n\t\tif (fabs(d) < 0.9) {\n\t\t\t//\n\t\t\td = DotProduct(pole.axis[0], dir);\n\t\t\tif (d > 1.0f) {\n\t\t\t\td = 1.0f;\n\t\t\t}\n\t\t\telse if (d < -1.0f) {\n\t\t\t\td = -1.0f;\n\t\t\t}\n\t\t\tangle = acos(d);\n\n\t\t\td = DotProduct(pole.axis[1], dir);\n\t\t\tif (d < 0) {\n\t\t\t\tangles[YAW] = 360 - angle * 180 / M_PI;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tangles[YAW] = angle * 180 / M_PI;\n\t\t\t}\n\t\t\tif (angles[YAW] < 0)\n\t\t\t\tangles[YAW] += 360;\n\t\t\tif (angles[YAW] > 360)\n\t\t\t\tangles[YAW] -= 360;\n\n\t\t\t//vectoangles( cent->currentState.pos.trDelta, tmpangles );\n\t\t\t//angles[YAW] = tmpangles[YAW] + 45 - cent->pe.torso.yawAngle;\n\t\t\t// change the yaw angle\n\t\t\tCG_SwingAngles( angles[YAW], 25, 90, 0.15f, &cent->pe.flag.yawAngle, &cent->pe.flag.yawing );\n\t\t}\n\n\t\t/*\n\t\td = DotProduct(pole.axis[2], dir);\n\t\tangle = Q_acos(d);\n\n\t\td = DotProduct(pole.axis[1], dir);\n\t\tif (d < 0) {\n\t\t\tangle = 360 - angle * 180 / M_PI;\n\t\t}\n\t\telse {\n\t\t\tangle = angle * 180 / M_PI;\n\t\t}\n\t\tif (angle > 340 && angle < 20) {\n\t\t\tflagAnim = FLAG_RUNUP;\n\t\t}\n\t\tif (angle > 160 && angle < 200) {\n\t\t\tflagAnim = FLAG_RUNDOWN;\n\t\t}\n\t\t*/\n\t}\n\n\t// set the yaw angle\n\tangles[YAW] = cent->pe.flag.yawAngle;\n\t// lerp the flag animation frames\n\tci = &cgs.clientinfo[ cent->currentState.clientNum ];\n\tCG_RunLerpFrame( ci, &cent->pe.flag, flagAnim, 1 );\n\tflag.oldframe = cent->pe.flag.oldFrame;\n\tflag.frame = cent->pe.flag.frame;\n\tflag.backlerp = cent->pe.flag.backlerp;\n\n\tAnglesToAxis( angles, flag.axis );\n\tCG_PositionRotatedEntityOnTag( &flag, &pole, pole.hModel, \"tag_flag\" );\n\n\ttrap_R_AddRefEntityToScene( &flag );\n}\n\n\n#ifdef MISSIONPACK // bk001204\n/*\n===============\nCG_PlayerTokens\n===============\n*/\nstatic void CG_PlayerTokens( centity_t *cent, int renderfx ) {\n\tint\t\t\ttokens, i, j;\n\tfloat\t\tangle;\n\trefEntity_t\tent;\n\tvec3_t\t\tdir, origin;\n\tskulltrail_t *trail;\n\ttrail = &cg.skulltrails[cent->currentState.number];\n\ttokens = cent->currentState.generic1;\n\tif ( !tokens ) {\n\t\ttrail->numpositions = 0;\n\t\treturn;\n\t}\n\n\tif ( tokens > MAX_SKULLTRAIL ) {\n\t\ttokens = MAX_SKULLTRAIL;\n\t}\n\n\t// add skulls if there are more than last time\n\tfor (i = 0; i < tokens - trail->numpositions; i++) {\n\t\tfor (j = trail->numpositions; j > 0; j--) {\n\t\t\tVectorCopy(trail->positions[j-1], trail->positions[j]);\n\t\t}\n\t\tVectorCopy(cent->lerpOrigin, trail->positions[0]);\n\t}\n\ttrail->numpositions = tokens;\n\n\t// move all the skulls along the trail\n\tVectorCopy(cent->lerpOrigin, origin);\n\tfor (i = 0; i < trail->numpositions; i++) {\n\t\tVectorSubtract(trail->positions[i], origin, dir);\n\t\tif (VectorNormalize(dir) > 30) {\n\t\t\tVectorMA(origin, 30, dir, trail->positions[i]);\n\t\t}\n\t\tVectorCopy(trail->positions[i], origin);\n\t}\n\n\tmemset( &ent, 0, sizeof( ent ) );\n\tif( cgs.clientinfo[ cent->currentState.clientNum ].team == TEAM_BLUE ) {\n\t\tent.hModel = cgs.media.redCubeModel;\n\t} else {\n\t\tent.hModel = cgs.media.blueCubeModel;\n\t}\n\tent.renderfx = renderfx;\n\n\tVectorCopy(cent->lerpOrigin, origin);\n\tfor (i = 0; i < trail->numpositions; i++) {\n\t\tVectorSubtract(origin, trail->positions[i], ent.axis[0]);\n\t\tent.axis[0][2] = 0;\n\t\tVectorNormalize(ent.axis[0]);\n\t\tVectorSet(ent.axis[2], 0, 0, 1);\n\t\tCrossProduct(ent.axis[0], ent.axis[2], ent.axis[1]);\n\n\t\tVectorCopy(trail->positions[i], ent.origin);\n\t\tangle = (((cg.time + 500 * MAX_SKULLTRAIL - 500 * i) / 16) & 255) * (M_PI * 2) / 255;\n\t\tent.origin[2] += sin(angle) * 10;\n\t\ttrap_R_AddRefEntityToScene( &ent );\n\t\tVectorCopy(trail->positions[i], origin);\n\t}\n}\n#endif\n\n\n/*\n===============\nCG_PlayerPowerups\n===============\n*/\nstatic void CG_PlayerPowerups( centity_t *cent, refEntity_t *torso ) {\n\tint\t\tpowerups;\n\tclientInfo_t\t*ci;\n\n\tpowerups = cent->currentState.powerups;\n\tif ( !powerups ) {\n\t\treturn;\n\t}\n\n\t// quad gives a dlight\n\tif ( powerups & ( 1 << PW_QUAD ) ) {\n\t\ttrap_R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 0.2f, 0.2f, 1 );\n\t}\n\n\t// flight plays a looped sound\n\tif ( powerups & ( 1 << PW_FLIGHT ) ) {\n\t\ttrap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, cgs.media.flightSound );\n\t}\n\n\tci = &cgs.clientinfo[ cent->currentState.clientNum ];\n\t// redflag\n\tif ( powerups & ( 1 << PW_REDFLAG ) ) {\n\t\tif (ci->newAnims) {\n\t\t\tCG_PlayerFlag( cent, cgs.media.redFlagFlapSkin, torso );\n\t\t}\n\t\telse {\n\t\t\tCG_TrailItem( cent, cgs.media.redFlagModel );\n\t\t}\n\t\ttrap_R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 1.0, 0.2f, 0.2f );\n\t}\n\n\t// blueflag\n\tif ( powerups & ( 1 << PW_BLUEFLAG ) ) {\n\t\tif (ci->newAnims){\n\t\t\tCG_PlayerFlag( cent, cgs.media.blueFlagFlapSkin, torso );\n\t\t}\n\t\telse {\n\t\t\tCG_TrailItem( cent, cgs.media.blueFlagModel );\n\t\t}\n\t\ttrap_R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 0.2f, 0.2f, 1.0 );\n\t}\n\n\t// neutralflag\n\tif ( powerups & ( 1 << PW_NEUTRALFLAG ) ) {\n\t\tif (ci->newAnims) {\n\t\t\tCG_PlayerFlag( cent, cgs.media.neutralFlagFlapSkin, torso );\n\t\t}\n\t\telse {\n\t\t\tCG_TrailItem( cent, cgs.media.neutralFlagModel );\n\t\t}\n\t\ttrap_R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 1.0, 1.0, 1.0 );\n\t}\n\n\t// haste leaves smoke trails\n\tif ( powerups & ( 1 << PW_HASTE ) ) {\n\t\tCG_HasteTrail( cent );\n\t}\n}\n\n\n/*\n===============\nCG_PlayerFloatSprite\n\nFloat a sprite over the player's head\n===============\n*/\nstatic void CG_PlayerFloatSprite( centity_t *cent, qhandle_t shader ) {\n\tint\t\t\t\trf;\n\trefEntity_t\t\tent;\n\n\tif ( cent->currentState.number == cg.snap->ps.clientNum && !cg.renderingThirdPerson ) {\n\t\trf = RF_THIRD_PERSON;\t\t// only show in mirrors\n\t} else {\n\t\trf = 0;\n\t}\n\n\tmemset( &ent, 0, sizeof( ent ) );\n\tVectorCopy( cent->lerpOrigin, ent.origin );\n\tent.origin[2] += 48;\n\tent.reType = RT_SPRITE;\n\tent.customShader = shader;\n\tent.radius = 10;\n\tent.renderfx = rf;\n\tent.shaderRGBA[0] = 255;\n\tent.shaderRGBA[1] = 255;\n\tent.shaderRGBA[2] = 255;\n\tent.shaderRGBA[3] = 255;\n\ttrap_R_AddRefEntityToScene( &ent );\n}\n\n\n\n/*\n===============\nCG_PlayerSprites\n\nFloat sprites over the player's head\n===============\n*/\nstatic void CG_PlayerSprites( centity_t *cent ) {\n\tint\t\tteam;\n\n\tif ( cent->currentState.eFlags & EF_CONNECTION ) {\n\t\tCG_PlayerFloatSprite( cent, cgs.media.connectionShader );\n\t\treturn;\n\t}\n\n\tif ( cent->currentState.eFlags & EF_TALK ) {\n\t\tCG_PlayerFloatSprite( cent, cgs.media.balloonShader );\n\t\treturn;\n\t}\n\n\tif ( cent->currentState.eFlags & EF_AWARD_IMPRESSIVE ) {\n\t\tCG_PlayerFloatSprite( cent, cgs.media.medalImpressive );\n\t\treturn;\n\t}\n\n\tif ( cent->currentState.eFlags & EF_AWARD_EXCELLENT ) {\n\t\tCG_PlayerFloatSprite( cent, cgs.media.medalExcellent );\n\t\treturn;\n\t}\n\n\tif ( cent->currentState.eFlags & EF_AWARD_GAUNTLET ) {\n\t\tCG_PlayerFloatSprite( cent, cgs.media.medalGauntlet );\n\t\treturn;\n\t}\n\n\tif ( cent->currentState.eFlags & EF_AWARD_DEFEND ) {\n\t\tCG_PlayerFloatSprite( cent, cgs.media.medalDefend );\n\t\treturn;\n\t}\n\n\tif ( cent->currentState.eFlags & EF_AWARD_ASSIST ) {\n\t\tCG_PlayerFloatSprite( cent, cgs.media.medalAssist );\n\t\treturn;\n\t}\n\n\tif ( cent->currentState.eFlags & EF_AWARD_CAP ) {\n\t\tCG_PlayerFloatSprite( cent, cgs.media.medalCapture );\n\t\treturn;\n\t}\n\n\tteam = cgs.clientinfo[ cent->currentState.clientNum ].team;\n\tif ( !(cent->currentState.eFlags & EF_DEAD) && \n\t\tcg.snap->ps.persistant[PERS_TEAM] == team &&\n\t\tcgs.gametype >= GT_TEAM) {\n\t\tif (cg_drawFriend.integer) {\n\t\t\tCG_PlayerFloatSprite( cent, cgs.media.friendShader );\n\t\t}\n\t\treturn;\n\t}\n}\n\n/*\n===============\nCG_PlayerShadow\n\nReturns the Z component of the surface being shadowed\n\n  should it return a full plane instead of a Z?\n===============\n*/\n#define\tSHADOW_DISTANCE\t\t128\nstatic qboolean CG_PlayerShadow( centity_t *cent, float *shadowPlane ) {\n\tvec3_t\t\tend, mins = {-15, -15, 0}, maxs = {15, 15, 2};\n\ttrace_t\t\ttrace;\n\tfloat\t\talpha;\n\n\t*shadowPlane = 0;\n\n\tif ( cg_shadows.integer == 0 ) {\n\t\treturn qfalse;\n\t}\n\n\t// no shadows when invisible\n\tif ( cent->currentState.powerups & ( 1 << PW_INVIS ) ) {\n\t\treturn qfalse;\n\t}\n\n\t// send a trace down from the player to the ground\n\tVectorCopy( cent->lerpOrigin, end );\n\tend[2] -= SHADOW_DISTANCE;\n\n\ttrap_CM_BoxTrace( &trace, cent->lerpOrigin, end, mins, maxs, 0, MASK_PLAYERSOLID );\n\n\t// no shadow if too high\n\tif ( trace.fraction == 1.0 || trace.startsolid || trace.allsolid ) {\n\t\treturn qfalse;\n\t}\n\n\t*shadowPlane = trace.endpos[2] + 1;\n\n\tif ( cg_shadows.integer != 1 ) {\t// no mark for stencil or projection shadows\n\t\treturn qtrue;\n\t}\n\n\t// fade the shadow out with height\n\talpha = 1.0 - trace.fraction;\n\n\t// bk0101022 - hack / FPE - bogus planes?\n\t//assert( DotProduct( trace.plane.normal, trace.plane.normal ) != 0.0f ) \n\n\t// add the mark as a temporary, so it goes directly to the renderer\n\t// without taking a spot in the cg_marks array\n\tCG_ImpactMark( cgs.media.shadowMarkShader, trace.endpos, trace.plane.normal, \n\t\tcent->pe.legs.yawAngle, alpha,alpha,alpha,1, qfalse, 24, qtrue );\n\n\treturn qtrue;\n}\n\n\n/*\n===============\nCG_PlayerSplash\n\nDraw a mark at the water surface\n===============\n*/\nstatic void CG_PlayerSplash( centity_t *cent ) {\n\tvec3_t\t\tstart, end;\n\ttrace_t\t\ttrace;\n\tint\t\t\tcontents;\n\tpolyVert_t\tverts[4];\n\n\tif ( !cg_shadows.integer ) {\n\t\treturn;\n\t}\n\n\tVectorCopy( cent->lerpOrigin, end );\n\tend[2] -= 24;\n\n\t// if the feet aren't in liquid, don't make a mark\n\t// this won't handle moving water brushes, but they wouldn't draw right anyway...\n\tcontents = trap_CM_PointContents( end, 0 );\n\tif ( !( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ) ) {\n\t\treturn;\n\t}\n\n\tVectorCopy( cent->lerpOrigin, start );\n\tstart[2] += 32;\n\n\t// if the head isn't out of liquid, don't make a mark\n\tcontents = trap_CM_PointContents( start, 0 );\n\tif ( contents & ( CONTENTS_SOLID | CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ) {\n\t\treturn;\n\t}\n\n\t// trace down to find the surface\n\ttrap_CM_BoxTrace( &trace, start, end, NULL, NULL, 0, ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) );\n\n\tif ( trace.fraction == 1.0 ) {\n\t\treturn;\n\t}\n\n\t// create a mark polygon\n\tVectorCopy( trace.endpos, verts[0].xyz );\n\tverts[0].xyz[0] -= 32;\n\tverts[0].xyz[1] -= 32;\n\tverts[0].st[0] = 0;\n\tverts[0].st[1] = 0;\n\tverts[0].modulate[0] = 255;\n\tverts[0].modulate[1] = 255;\n\tverts[0].modulate[2] = 255;\n\tverts[0].modulate[3] = 255;\n\n\tVectorCopy( trace.endpos, verts[1].xyz );\n\tverts[1].xyz[0] -= 32;\n\tverts[1].xyz[1] += 32;\n\tverts[1].st[0] = 0;\n\tverts[1].st[1] = 1;\n\tverts[1].modulate[0] = 255;\n\tverts[1].modulate[1] = 255;\n\tverts[1].modulate[2] = 255;\n\tverts[1].modulate[3] = 255;\n\n\tVectorCopy( trace.endpos, verts[2].xyz );\n\tverts[2].xyz[0] += 32;\n\tverts[2].xyz[1] += 32;\n\tverts[2].st[0] = 1;\n\tverts[2].st[1] = 1;\n\tverts[2].modulate[0] = 255;\n\tverts[2].modulate[1] = 255;\n\tverts[2].modulate[2] = 255;\n\tverts[2].modulate[3] = 255;\n\n\tVectorCopy( trace.endpos, verts[3].xyz );\n\tverts[3].xyz[0] += 32;\n\tverts[3].xyz[1] -= 32;\n\tverts[3].st[0] = 1;\n\tverts[3].st[1] = 0;\n\tverts[3].modulate[0] = 255;\n\tverts[3].modulate[1] = 255;\n\tverts[3].modulate[2] = 255;\n\tverts[3].modulate[3] = 255;\n\n\ttrap_R_AddPolyToScene( cgs.media.wakeMarkShader, 4, verts );\n}\n\n\n\n/*\n===============\nCG_AddRefEntityWithPowerups\n\nAdds a piece with modifications or duplications for powerups\nAlso called by CG_Missile for quad rockets, but nobody can tell...\n===============\n*/\nvoid CG_AddRefEntityWithPowerups( refEntity_t *ent, entityState_t *state, int team ) {\n\n\tif ( state->powerups & ( 1 << PW_INVIS ) ) {\n\t\tent->customShader = cgs.media.invisShader;\n\t\ttrap_R_AddRefEntityToScene( ent );\n\t} else {\n\t\t/*\n\t\tif ( state->eFlags & EF_KAMIKAZE ) {\n\t\t\tif (team == TEAM_BLUE)\n\t\t\t\tent->customShader = cgs.media.blueKamikazeShader;\n\t\t\telse\n\t\t\t\tent->customShader = cgs.media.redKamikazeShader;\n\t\t\ttrap_R_AddRefEntityToScene( ent );\n\t\t}\n\t\telse {*/\n\t\t\ttrap_R_AddRefEntityToScene( ent );\n\t\t//}\n\n\t\tif ( state->powerups & ( 1 << PW_QUAD ) )\n\t\t{\n\t\t\tif (team == TEAM_RED)\n\t\t\t\tent->customShader = cgs.media.redQuadShader;\n\t\t\telse\n\t\t\t\tent->customShader = cgs.media.quadShader;\n\t\t\ttrap_R_AddRefEntityToScene( ent );\n\t\t}\n\t\tif ( state->powerups & ( 1 << PW_REGEN ) ) {\n\t\t\tif ( ( ( cg.time / 100 ) % 10 ) == 1 ) {\n\t\t\t\tent->customShader = cgs.media.regenShader;\n\t\t\t\ttrap_R_AddRefEntityToScene( ent );\n\t\t\t}\n\t\t}\n\t\tif ( state->powerups & ( 1 << PW_BATTLESUIT ) ) {\n\t\t\tent->customShader = cgs.media.battleSuitShader;\n\t\t\ttrap_R_AddRefEntityToScene( ent );\n\t\t}\n\t}\n}\n\n/*\n=================\nCG_LightVerts\n=================\n*/\nint CG_LightVerts( vec3_t normal, int numVerts, polyVert_t *verts )\n{\n\tint\t\t\t\ti, j;\n\tfloat\t\t\tincoming;\n\tvec3_t\t\t\tambientLight;\n\tvec3_t\t\t\tlightDir;\n\tvec3_t\t\t\tdirectedLight;\n\n\ttrap_R_LightForPoint( verts[0].xyz, ambientLight, directedLight, lightDir );\n\n\tfor (i = 0; i < numVerts; i++) {\n\t\tincoming = DotProduct (normal, lightDir);\n\t\tif ( incoming <= 0 ) {\n\t\t\tverts[i].modulate[0] = ambientLight[0];\n\t\t\tverts[i].modulate[1] = ambientLight[1];\n\t\t\tverts[i].modulate[2] = ambientLight[2];\n\t\t\tverts[i].modulate[3] = 255;\n\t\t\tcontinue;\n\t\t} \n\t\tj = ( ambientLight[0] + incoming * directedLight[0] );\n\t\tif ( j > 255 ) {\n\t\t\tj = 255;\n\t\t}\n\t\tverts[i].modulate[0] = j;\n\n\t\tj = ( ambientLight[1] + incoming * directedLight[1] );\n\t\tif ( j > 255 ) {\n\t\t\tj = 255;\n\t\t}\n\t\tverts[i].modulate[1] = j;\n\n\t\tj = ( ambientLight[2] + incoming * directedLight[2] );\n\t\tif ( j > 255 ) {\n\t\t\tj = 255;\n\t\t}\n\t\tverts[i].modulate[2] = j;\n\n\t\tverts[i].modulate[3] = 255;\n\t}\n\treturn qtrue;\n}\n\n/*\n===============\nCG_Player\n===============\n*/\nvoid CG_Player( centity_t *cent ) {\n\tclientInfo_t\t*ci;\n\trefEntity_t\t\tlegs;\n\trefEntity_t\t\ttorso;\n\trefEntity_t\t\thead;\n\tint\t\t\t\tclientNum;\n\tint\t\t\t\trenderfx;\n\tqboolean\t\tshadow;\n\tfloat\t\t\tshadowPlane;\n#ifdef MISSIONPACK\n\trefEntity_t\t\tskull;\n\trefEntity_t\t\tpowerup;\n\tint\t\t\t\tt;\n\tfloat\t\t\tc;\n\tfloat\t\t\tangle;\n\tvec3_t\t\t\tdir, angles;\n#endif\n\n\t// the client number is stored in clientNum.  It can't be derived\n\t// from the entity number, because a single client may have\n\t// multiple corpses on the level using the same clientinfo\n\tclientNum = cent->currentState.clientNum;\n\tif ( clientNum < 0 || clientNum >= MAX_CLIENTS ) {\n\t\tCG_Error( \"Bad clientNum on player entity\");\n\t}\n\tci = &cgs.clientinfo[ clientNum ];\n\n\t// it is possible to see corpses from disconnected players that may\n\t// not have valid clientinfo\n\tif ( !ci->infoValid ) {\n\t\treturn;\n\t}\n\n\t// get the player model information\n\trenderfx = 0;\n\tif ( cent->currentState.number == cg.snap->ps.clientNum) {\n\t\tif (!cg.renderingThirdPerson) {\n\t\t\trenderfx = RF_THIRD_PERSON;\t\t\t// only draw in mirrors\n\t\t} else {\n\t\t\tif (cg_cameraMode.integer) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\n\tmemset( &legs, 0, sizeof(legs) );\n\tmemset( &torso, 0, sizeof(torso) );\n\tmemset( &head, 0, sizeof(head) );\n\n\t// get the rotation information\n\tCG_PlayerAngles( cent, legs.axis, torso.axis, head.axis );\n\t\n\t// get the animation state (after rotation, to allow feet shuffle)\n\tCG_PlayerAnimation( cent, &legs.oldframe, &legs.frame, &legs.backlerp,\n\t\t &torso.oldframe, &torso.frame, &torso.backlerp );\n\n\t// add the talk baloon or disconnect icon\n\tCG_PlayerSprites( cent );\n\n\t// add the shadow\n\tshadow = CG_PlayerShadow( cent, &shadowPlane );\n\n\t// add a water splash if partially in and out of water\n\tCG_PlayerSplash( cent );\n\n\tif ( cg_shadows.integer == 3 && shadow ) {\n\t\trenderfx |= RF_SHADOW_PLANE;\n\t}\n\trenderfx |= RF_LIGHTING_ORIGIN;\t\t\t// use the same origin for all\n#ifdef MISSIONPACK\n\tif( cgs.gametype == GT_HARVESTER ) {\n\t\tCG_PlayerTokens( cent, renderfx );\n\t}\n#endif\n\t//\n\t// add the legs\n\t//\n\tlegs.hModel = ci->legsModel;\n\tlegs.customSkin = ci->legsSkin;\n\n\tVectorCopy( cent->lerpOrigin, legs.origin );\n\n\tVectorCopy( cent->lerpOrigin, legs.lightingOrigin );\n\tlegs.shadowPlane = shadowPlane;\n\tlegs.renderfx = renderfx;\n\tVectorCopy (legs.origin, legs.oldorigin);\t// don't positionally lerp at all\n\n\tCG_AddRefEntityWithPowerups( &legs, &cent->currentState, ci->team );\n\n\t// if the model failed, allow the default nullmodel to be displayed\n\tif (!legs.hModel) {\n\t\treturn;\n\t}\n\n\t//\n\t// add the torso\n\t//\n\ttorso.hModel = ci->torsoModel;\n\tif (!torso.hModel) {\n\t\treturn;\n\t}\n\n\ttorso.customSkin = ci->torsoSkin;\n\n\tVectorCopy( cent->lerpOrigin, torso.lightingOrigin );\n\n\tCG_PositionRotatedEntityOnTag( &torso, &legs, ci->legsModel, \"tag_torso\");\n\n\ttorso.shadowPlane = shadowPlane;\n\ttorso.renderfx = renderfx;\n\n\tCG_AddRefEntityWithPowerups( &torso, &cent->currentState, ci->team );\n\n#ifdef MISSIONPACK\n\tif ( cent->currentState.eFlags & EF_KAMIKAZE ) {\n\n\t\tmemset( &skull, 0, sizeof(skull) );\n\n\t\tVectorCopy( cent->lerpOrigin, skull.lightingOrigin );\n\t\tskull.shadowPlane = shadowPlane;\n\t\tskull.renderfx = renderfx;\n\n\t\tif ( cent->currentState.eFlags & EF_DEAD ) {\n\t\t\t// one skull bobbing above the dead body\n\t\t\tangle = ((cg.time / 7) & 255) * (M_PI * 2) / 255;\n\t\t\tif (angle > M_PI * 2)\n\t\t\t\tangle -= (float)M_PI * 2;\n\t\t\tdir[0] = sin(angle) * 20;\n\t\t\tdir[1] = cos(angle) * 20;\n\t\t\tangle = ((cg.time / 4) & 255) * (M_PI * 2) / 255;\n\t\t\tdir[2] = 15 + sin(angle) * 8;\n\t\t\tVectorAdd(torso.origin, dir, skull.origin);\n\t\t\t\n\t\t\tdir[2] = 0;\n\t\t\tVectorCopy(dir, skull.axis[1]);\n\t\t\tVectorNormalize(skull.axis[1]);\n\t\t\tVectorSet(skull.axis[2], 0, 0, 1);\n\t\t\tCrossProduct(skull.axis[1], skull.axis[2], skull.axis[0]);\n\n\t\t\tskull.hModel = cgs.media.kamikazeHeadModel;\n\t\t\ttrap_R_AddRefEntityToScene( &skull );\n\t\t\tskull.hModel = cgs.media.kamikazeHeadTrail;\n\t\t\ttrap_R_AddRefEntityToScene( &skull );\n\t\t}\n\t\telse {\n\t\t\t// three skulls spinning around the player\n\t\t\tangle = ((cg.time / 4) & 255) * (M_PI * 2) / 255;\n\t\t\tdir[0] = cos(angle) * 20;\n\t\t\tdir[1] = sin(angle) * 20;\n\t\t\tdir[2] = cos(angle) * 20;\n\t\t\tVectorAdd(torso.origin, dir, skull.origin);\n\n\t\t\tangles[0] = sin(angle) * 30;\n\t\t\tangles[1] = (angle * 180 / M_PI) + 90;\n\t\t\tif (angles[1] > 360)\n\t\t\t\tangles[1] -= 360;\n\t\t\tangles[2] = 0;\n\t\t\tAnglesToAxis( angles, skull.axis );\n\n\t\t\t/*\n\t\t\tdir[2] = 0;\n\t\t\tVectorInverse(dir);\n\t\t\tVectorCopy(dir, skull.axis[1]);\n\t\t\tVectorNormalize(skull.axis[1]);\n\t\t\tVectorSet(skull.axis[2], 0, 0, 1);\n\t\t\tCrossProduct(skull.axis[1], skull.axis[2], skull.axis[0]);\n\t\t\t*/\n\n\t\t\tskull.hModel = cgs.media.kamikazeHeadModel;\n\t\t\ttrap_R_AddRefEntityToScene( &skull );\n\t\t\t// flip the trail because this skull is spinning in the other direction\n\t\t\tVectorInverse(skull.axis[1]);\n\t\t\tskull.hModel = cgs.media.kamikazeHeadTrail;\n\t\t\ttrap_R_AddRefEntityToScene( &skull );\n\n\t\t\tangle = ((cg.time / 4) & 255) * (M_PI * 2) / 255 + M_PI;\n\t\t\tif (angle > M_PI * 2)\n\t\t\t\tangle -= (float)M_PI * 2;\n\t\t\tdir[0] = sin(angle) * 20;\n\t\t\tdir[1] = cos(angle) * 20;\n\t\t\tdir[2] = cos(angle) * 20;\n\t\t\tVectorAdd(torso.origin, dir, skull.origin);\n\n\t\t\tangles[0] = cos(angle - 0.5 * M_PI) * 30;\n\t\t\tangles[1] = 360 - (angle * 180 / M_PI);\n\t\t\tif (angles[1] > 360)\n\t\t\t\tangles[1] -= 360;\n\t\t\tangles[2] = 0;\n\t\t\tAnglesToAxis( angles, skull.axis );\n\n\t\t\t/*\n\t\t\tdir[2] = 0;\n\t\t\tVectorCopy(dir, skull.axis[1]);\n\t\t\tVectorNormalize(skull.axis[1]);\n\t\t\tVectorSet(skull.axis[2], 0, 0, 1);\n\t\t\tCrossProduct(skull.axis[1], skull.axis[2], skull.axis[0]);\n\t\t\t*/\n\n\t\t\tskull.hModel = cgs.media.kamikazeHeadModel;\n\t\t\ttrap_R_AddRefEntityToScene( &skull );\n\t\t\tskull.hModel = cgs.media.kamikazeHeadTrail;\n\t\t\ttrap_R_AddRefEntityToScene( &skull );\n\n\t\t\tangle = ((cg.time / 3) & 255) * (M_PI * 2) / 255 + 0.5 * M_PI;\n\t\t\tif (angle > M_PI * 2)\n\t\t\t\tangle -= (float)M_PI * 2;\n\t\t\tdir[0] = sin(angle) * 20;\n\t\t\tdir[1] = cos(angle) * 20;\n\t\t\tdir[2] = 0;\n\t\t\tVectorAdd(torso.origin, dir, skull.origin);\n\t\t\t\n\t\t\tVectorCopy(dir, skull.axis[1]);\n\t\t\tVectorNormalize(skull.axis[1]);\n\t\t\tVectorSet(skull.axis[2], 0, 0, 1);\n\t\t\tCrossProduct(skull.axis[1], skull.axis[2], skull.axis[0]);\n\n\t\t\tskull.hModel = cgs.media.kamikazeHeadModel;\n\t\t\ttrap_R_AddRefEntityToScene( &skull );\n\t\t\tskull.hModel = cgs.media.kamikazeHeadTrail;\n\t\t\ttrap_R_AddRefEntityToScene( &skull );\n\t\t}\n\t}\n\n\tif ( cent->currentState.powerups & ( 1 << PW_GUARD ) ) {\n\t\tmemcpy(&powerup, &torso, sizeof(torso));\n\t\tpowerup.hModel = cgs.media.guardPowerupModel;\n\t\tpowerup.frame = 0;\n\t\tpowerup.oldframe = 0;\n\t\tpowerup.customSkin = 0;\n\t\ttrap_R_AddRefEntityToScene( &powerup );\n\t}\n\tif ( cent->currentState.powerups & ( 1 << PW_SCOUT ) ) {\n\t\tmemcpy(&powerup, &torso, sizeof(torso));\n\t\tpowerup.hModel = cgs.media.scoutPowerupModel;\n\t\tpowerup.frame = 0;\n\t\tpowerup.oldframe = 0;\n\t\tpowerup.customSkin = 0;\n\t\ttrap_R_AddRefEntityToScene( &powerup );\n\t}\n\tif ( cent->currentState.powerups & ( 1 << PW_DOUBLER ) ) {\n\t\tmemcpy(&powerup, &torso, sizeof(torso));\n\t\tpowerup.hModel = cgs.media.doublerPowerupModel;\n\t\tpowerup.frame = 0;\n\t\tpowerup.oldframe = 0;\n\t\tpowerup.customSkin = 0;\n\t\ttrap_R_AddRefEntityToScene( &powerup );\n\t}\n\tif ( cent->currentState.powerups & ( 1 << PW_AMMOREGEN ) ) {\n\t\tmemcpy(&powerup, &torso, sizeof(torso));\n\t\tpowerup.hModel = cgs.media.ammoRegenPowerupModel;\n\t\tpowerup.frame = 0;\n\t\tpowerup.oldframe = 0;\n\t\tpowerup.customSkin = 0;\n\t\ttrap_R_AddRefEntityToScene( &powerup );\n\t}\n\tif ( cent->currentState.powerups & ( 1 << PW_INVULNERABILITY ) ) {\n\t\tif ( !ci->invulnerabilityStartTime ) {\n\t\t\tci->invulnerabilityStartTime = cg.time;\n\t\t}\n\t\tci->invulnerabilityStopTime = cg.time;\n\t}\n\telse {\n\t\tci->invulnerabilityStartTime = 0;\n\t}\n\tif ( (cent->currentState.powerups & ( 1 << PW_INVULNERABILITY ) ) ||\n\t\tcg.time - ci->invulnerabilityStopTime < 250 ) {\n\n\t\tmemcpy(&powerup, &torso, sizeof(torso));\n\t\tpowerup.hModel = cgs.media.invulnerabilityPowerupModel;\n\t\tpowerup.customSkin = 0;\n\t\t// always draw\n\t\tpowerup.renderfx &= ~RF_THIRD_PERSON;\n\t\tVectorCopy(cent->lerpOrigin, powerup.origin);\n\n\t\tif ( cg.time - ci->invulnerabilityStartTime < 250 ) {\n\t\t\tc = (float) (cg.time - ci->invulnerabilityStartTime) / 250;\n\t\t}\n\t\telse if (cg.time - ci->invulnerabilityStopTime < 250 ) {\n\t\t\tc = (float) (250 - (cg.time - ci->invulnerabilityStopTime)) / 250;\n\t\t}\n\t\telse {\n\t\t\tc = 1;\n\t\t}\n\t\tVectorSet( powerup.axis[0], c, 0, 0 );\n\t\tVectorSet( powerup.axis[1], 0, c, 0 );\n\t\tVectorSet( powerup.axis[2], 0, 0, c );\n\t\ttrap_R_AddRefEntityToScene( &powerup );\n\t}\n\n\tt = cg.time - ci->medkitUsageTime;\n\tif ( ci->medkitUsageTime && t < 500 ) {\n\t\tmemcpy(&powerup, &torso, sizeof(torso));\n\t\tpowerup.hModel = cgs.media.medkitUsageModel;\n\t\tpowerup.customSkin = 0;\n\t\t// always draw\n\t\tpowerup.renderfx &= ~RF_THIRD_PERSON;\n\t\tVectorClear(angles);\n\t\tAnglesToAxis(angles, powerup.axis);\n\t\tVectorCopy(cent->lerpOrigin, powerup.origin);\n\t\tpowerup.origin[2] += -24 + (float) t * 80 / 500;\n\t\tif ( t > 400 ) {\n\t\t\tc = (float) (t - 1000) * 0xff / 100;\n\t\t\tpowerup.shaderRGBA[0] = 0xff - c;\n\t\t\tpowerup.shaderRGBA[1] = 0xff - c;\n\t\t\tpowerup.shaderRGBA[2] = 0xff - c;\n\t\t\tpowerup.shaderRGBA[3] = 0xff - c;\n\t\t}\n\t\telse {\n\t\t\tpowerup.shaderRGBA[0] = 0xff;\n\t\t\tpowerup.shaderRGBA[1] = 0xff;\n\t\t\tpowerup.shaderRGBA[2] = 0xff;\n\t\t\tpowerup.shaderRGBA[3] = 0xff;\n\t\t}\n\t\ttrap_R_AddRefEntityToScene( &powerup );\n\t}\n#endif // MISSIONPACK\n\n\t//\n\t// add the head\n\t//\n\thead.hModel = ci->headModel;\n\tif (!head.hModel) {\n\t\treturn;\n\t}\n\thead.customSkin = ci->headSkin;\n\n\tVectorCopy( cent->lerpOrigin, head.lightingOrigin );\n\n\tCG_PositionRotatedEntityOnTag( &head, &torso, ci->torsoModel, \"tag_head\");\n\n\thead.shadowPlane = shadowPlane;\n\thead.renderfx = renderfx;\n\n\tCG_AddRefEntityWithPowerups( &head, &cent->currentState, ci->team );\n\n#ifdef MISSIONPACK\n\tCG_BreathPuffs(cent, &head);\n\n\tCG_DustTrail(cent);\n#endif\n\n\t//\n\t// add the gun / barrel / flash\n\t//\n\tCG_AddPlayerWeapon( &torso, NULL, cent, ci->team );\n\n\t// add powerups floating behind the player\n\tCG_PlayerPowerups( cent, &torso );\n}\n\n\n//=====================================================================\n\n/*\n===============\nCG_ResetPlayerEntity\n\nA player just came into view or teleported, so reset all animation info\n===============\n*/\nvoid CG_ResetPlayerEntity( centity_t *cent ) {\n\tcent->errorTime = -99999;\t\t// guarantee no error decay added\n\tcent->extrapolated = qfalse;\t\n\n\tCG_ClearLerpFrame( &cgs.clientinfo[ cent->currentState.clientNum ], &cent->pe.legs, cent->currentState.legsAnim );\n\tCG_ClearLerpFrame( &cgs.clientinfo[ cent->currentState.clientNum ], &cent->pe.torso, cent->currentState.torsoAnim );\n\n\tBG_EvaluateTrajectory( &cent->currentState.pos, cg.time, cent->lerpOrigin );\n\tBG_EvaluateTrajectory( &cent->currentState.apos, cg.time, cent->lerpAngles );\n\n\tVectorCopy( cent->lerpOrigin, cent->rawOrigin );\n\tVectorCopy( cent->lerpAngles, cent->rawAngles );\n\n\tmemset( &cent->pe.legs, 0, sizeof( cent->pe.legs ) );\n\tcent->pe.legs.yawAngle = cent->rawAngles[YAW];\n\tcent->pe.legs.yawing = qfalse;\n\tcent->pe.legs.pitchAngle = 0;\n\tcent->pe.legs.pitching = qfalse;\n\n\tmemset( &cent->pe.torso, 0, sizeof( cent->pe.legs ) );\n\tcent->pe.torso.yawAngle = cent->rawAngles[YAW];\n\tcent->pe.torso.yawing = qfalse;\n\tcent->pe.torso.pitchAngle = cent->rawAngles[PITCH];\n\tcent->pe.torso.pitching = qfalse;\n\n\tif ( cg_debugPosition.integer ) {\n\t\tCG_Printf(\"%i ResetPlayerEntity yaw=%i\\n\", cent->currentState.number, cent->pe.torso.yawAngle );\n\t}\n}\n\n"
  },
  {
    "path": "code/cgame/cg_playerstate.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// cg_playerstate.c -- this file acts on changes in a new playerState_t\n// With normal play, this will be done after local prediction, but when\n// following another player or playing back a demo, it will be checked\n// when the snapshot transitions like all the other entities\n\n#include \"cg_local.h\"\n\n/*\n==============\nCG_CheckAmmo\n\nIf the ammo has gone low enough to generate the warning, play a sound\n==============\n*/\nvoid CG_CheckAmmo( void ) {\n\tint\t\ti;\n\tint\t\ttotal;\n\tint\t\tprevious;\n\tint\t\tweapons;\n\n\t// see about how many seconds of ammo we have remaining\n\tweapons = cg.snap->ps.stats[ STAT_WEAPONS ];\n\ttotal = 0;\n\tfor ( i = WP_MACHINEGUN ; i < WP_NUM_WEAPONS ; i++ ) {\n\t\tif ( ! ( weapons & ( 1 << i ) ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\tswitch ( i ) {\n\t\tcase WP_ROCKET_LAUNCHER:\n\t\tcase WP_GRENADE_LAUNCHER:\n\t\tcase WP_RAILGUN:\n\t\tcase WP_SHOTGUN:\n#ifdef MISSIONPACK\n\t\tcase WP_PROX_LAUNCHER:\n#endif\n\t\t\ttotal += cg.snap->ps.ammo[i] * 1000;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\ttotal += cg.snap->ps.ammo[i] * 200;\n\t\t\tbreak;\n\t\t}\n\t\tif ( total >= 5000 ) {\n\t\t\tcg.lowAmmoWarning = 0;\n\t\t\treturn;\n\t\t}\n\t}\n\n\tprevious = cg.lowAmmoWarning;\n\n\tif ( total == 0 ) {\n\t\tcg.lowAmmoWarning = 2;\n\t} else {\n\t\tcg.lowAmmoWarning = 1;\n\t}\n\n\t// play a sound on transitions\n\tif ( cg.lowAmmoWarning != previous ) {\n\t\ttrap_S_StartLocalSound( cgs.media.noAmmoSound, CHAN_LOCAL_SOUND );\n\t}\n}\n\n/*\n==============\nCG_DamageFeedback\n==============\n*/\nvoid CG_DamageFeedback( int yawByte, int pitchByte, int damage ) {\n\tfloat\t\tleft, front, up;\n\tfloat\t\tkick;\n\tint\t\t\thealth;\n\tfloat\t\tscale;\n\tvec3_t\t\tdir;\n\tvec3_t\t\tangles;\n\tfloat\t\tdist;\n\tfloat\t\tyaw, pitch;\n\n\t// show the attacking player's head and name in corner\n\tcg.attackerTime = cg.time;\n\n\t// the lower on health you are, the greater the view kick will be\n\thealth = cg.snap->ps.stats[STAT_HEALTH];\n\tif ( health < 40 ) {\n\t\tscale = 1;\n\t} else {\n\t\tscale = 40.0 / health;\n\t}\n\tkick = damage * scale;\n\n\tif (kick < 5)\n\t\tkick = 5;\n\tif (kick > 10)\n\t\tkick = 10;\n\n\t// if yaw and pitch are both 255, make the damage always centered (falling, etc)\n\tif ( yawByte == 255 && pitchByte == 255 ) {\n\t\tcg.damageX = 0;\n\t\tcg.damageY = 0;\n\t\tcg.v_dmg_roll = 0;\n\t\tcg.v_dmg_pitch = -kick;\n\t} else {\n\t\t// positional\n\t\tpitch = pitchByte / 255.0 * 360;\n\t\tyaw = yawByte / 255.0 * 360;\n\n\t\tangles[PITCH] = pitch;\n\t\tangles[YAW] = yaw;\n\t\tangles[ROLL] = 0;\n\n\t\tAngleVectors( angles, dir, NULL, NULL );\n\t\tVectorSubtract( vec3_origin, dir, dir );\n\n\t\tfront = DotProduct (dir, cg.refdef.viewaxis[0] );\n\t\tleft = DotProduct (dir, cg.refdef.viewaxis[1] );\n\t\tup = DotProduct (dir, cg.refdef.viewaxis[2] );\n\n\t\tdir[0] = front;\n\t\tdir[1] = left;\n\t\tdir[2] = 0;\n\t\tdist = VectorLength( dir );\n\t\tif ( dist < 0.1 ) {\n\t\t\tdist = 0.1f;\n\t\t}\n\n\t\tcg.v_dmg_roll = kick * left;\n\t\t\n\t\tcg.v_dmg_pitch = -kick * front;\n\n\t\tif ( front <= 0.1 ) {\n\t\t\tfront = 0.1f;\n\t\t}\n\t\tcg.damageX = -left / front;\n\t\tcg.damageY = up / dist;\n\t}\n\n\t// clamp the position\n\tif ( cg.damageX > 1.0 ) {\n\t\tcg.damageX = 1.0;\n\t}\n\tif ( cg.damageX < - 1.0 ) {\n\t\tcg.damageX = -1.0;\n\t}\n\n\tif ( cg.damageY > 1.0 ) {\n\t\tcg.damageY = 1.0;\n\t}\n\tif ( cg.damageY < - 1.0 ) {\n\t\tcg.damageY = -1.0;\n\t}\n\n\t// don't let the screen flashes vary as much\n\tif ( kick > 10 ) {\n\t\tkick = 10;\n\t}\n\tcg.damageValue = kick;\n\tcg.v_dmg_time = cg.time + DAMAGE_TIME;\n\tcg.damageTime = cg.snap->serverTime;\n}\n\n\n\n\n/*\n================\nCG_Respawn\n\nA respawn happened this snapshot\n================\n*/\nvoid CG_Respawn( void ) {\n\t// no error decay on player movement\n\tcg.thisFrameTeleport = qtrue;\n\n\t// display weapons available\n\tcg.weaponSelectTime = cg.time;\n\n\t// select the weapon the server says we are using\n\tcg.weaponSelect = cg.snap->ps.weapon;\n}\n\nextern char *eventnames[];\n\n/*\n==============\nCG_CheckPlayerstateEvents\n==============\n*/\nvoid CG_CheckPlayerstateEvents( playerState_t *ps, playerState_t *ops ) {\n\tint\t\t\ti;\n\tint\t\t\tevent;\n\tcentity_t\t*cent;\n\n\tif ( ps->externalEvent && ps->externalEvent != ops->externalEvent ) {\n\t\tcent = &cg_entities[ ps->clientNum ];\n\t\tcent->currentState.event = ps->externalEvent;\n\t\tcent->currentState.eventParm = ps->externalEventParm;\n\t\tCG_EntityEvent( cent, cent->lerpOrigin );\n\t}\n\n\tcent = &cg.predictedPlayerEntity; // cg_entities[ ps->clientNum ];\n\t// go through the predictable events buffer\n\tfor ( i = ps->eventSequence - MAX_PS_EVENTS ; i < ps->eventSequence ; i++ ) {\n\t\t// if we have a new predictable event\n\t\tif ( i >= ops->eventSequence\n\t\t\t// or the server told us to play another event instead of a predicted event we already issued\n\t\t\t// or something the server told us changed our prediction causing a different event\n\t\t\t|| (i > ops->eventSequence - MAX_PS_EVENTS && ps->events[i & (MAX_PS_EVENTS-1)] != ops->events[i & (MAX_PS_EVENTS-1)]) ) {\n\n\t\t\tevent = ps->events[ i & (MAX_PS_EVENTS-1) ];\n\t\t\tcent->currentState.event = event;\n\t\t\tcent->currentState.eventParm = ps->eventParms[ i & (MAX_PS_EVENTS-1) ];\n\t\t\tCG_EntityEvent( cent, cent->lerpOrigin );\n\n\t\t\tcg.predictableEvents[ i & (MAX_PREDICTED_EVENTS-1) ] = event;\n\n\t\t\tcg.eventSequence++;\n\t\t}\n\t}\n}\n\n/*\n==================\nCG_CheckChangedPredictableEvents\n==================\n*/\nvoid CG_CheckChangedPredictableEvents( playerState_t *ps ) {\n\tint i;\n\tint event;\n\tcentity_t\t*cent;\n\n\tcent = &cg.predictedPlayerEntity;\n\tfor ( i = ps->eventSequence - MAX_PS_EVENTS ; i < ps->eventSequence ; i++ ) {\n\t\t//\n\t\tif (i >= cg.eventSequence) {\n\t\t\tcontinue;\n\t\t}\n\t\t// if this event is not further back in than the maximum predictable events we remember\n\t\tif (i > cg.eventSequence - MAX_PREDICTED_EVENTS) {\n\t\t\t// if the new playerstate event is different from a previously predicted one\n\t\t\tif ( ps->events[i & (MAX_PS_EVENTS-1)] != cg.predictableEvents[i & (MAX_PREDICTED_EVENTS-1) ] ) {\n\n\t\t\t\tevent = ps->events[ i & (MAX_PS_EVENTS-1) ];\n\t\t\t\tcent->currentState.event = event;\n\t\t\t\tcent->currentState.eventParm = ps->eventParms[ i & (MAX_PS_EVENTS-1) ];\n\t\t\t\tCG_EntityEvent( cent, cent->lerpOrigin );\n\n\t\t\t\tcg.predictableEvents[ i & (MAX_PREDICTED_EVENTS-1) ] = event;\n\n\t\t\t\tif ( cg_showmiss.integer ) {\n\t\t\t\t\tCG_Printf(\"WARNING: changed predicted event\\n\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n==================\npushReward\n==================\n*/\nstatic void pushReward(sfxHandle_t sfx, qhandle_t shader, int rewardCount) {\n\tif (cg.rewardStack < (MAX_REWARDSTACK-1)) {\n\t\tcg.rewardStack++;\n\t\tcg.rewardSound[cg.rewardStack] = sfx;\n\t\tcg.rewardShader[cg.rewardStack] = shader;\n\t\tcg.rewardCount[cg.rewardStack] = rewardCount;\n\t}\n}\n\n/*\n==================\nCG_CheckLocalSounds\n==================\n*/\nvoid CG_CheckLocalSounds( playerState_t *ps, playerState_t *ops ) {\n\tint\t\t\thighScore, health, armor, reward;\n\tsfxHandle_t sfx;\n\n\t// don't play the sounds if the player just changed teams\n\tif ( ps->persistant[PERS_TEAM] != ops->persistant[PERS_TEAM] ) {\n\t\treturn;\n\t}\n\n\t// hit changes\n\tif ( ps->persistant[PERS_HITS] > ops->persistant[PERS_HITS] ) {\n\t\tarmor  = ps->persistant[PERS_ATTACKEE_ARMOR] & 0xff;\n\t\thealth = ps->persistant[PERS_ATTACKEE_ARMOR] >> 8;\n#ifdef MISSIONPACK\n\t\tif (armor > 50 ) {\n\t\t\ttrap_S_StartLocalSound( cgs.media.hitSoundHighArmor, CHAN_LOCAL_SOUND );\n\t\t} else if (armor || health > 100) {\n\t\t\ttrap_S_StartLocalSound( cgs.media.hitSoundLowArmor, CHAN_LOCAL_SOUND );\n\t\t} else {\n\t\t\ttrap_S_StartLocalSound( cgs.media.hitSound, CHAN_LOCAL_SOUND );\n\t\t}\n#else\n\t\ttrap_S_StartLocalSound( cgs.media.hitSound, CHAN_LOCAL_SOUND );\n#endif\n\t} else if ( ps->persistant[PERS_HITS] < ops->persistant[PERS_HITS] ) {\n\t\ttrap_S_StartLocalSound( cgs.media.hitTeamSound, CHAN_LOCAL_SOUND );\n\t}\n\n\t// health changes of more than -1 should make pain sounds\n\tif ( ps->stats[STAT_HEALTH] < ops->stats[STAT_HEALTH] - 1 ) {\n\t\tif ( ps->stats[STAT_HEALTH] > 0 ) {\n\t\t\tCG_PainEvent( &cg.predictedPlayerEntity, ps->stats[STAT_HEALTH] );\n\t\t}\n\t}\n\n\n\t// if we are going into the intermission, don't start any voices\n\tif ( cg.intermissionStarted ) {\n\t\treturn;\n\t}\n\n\t// reward sounds\n\treward = qfalse;\n\tif (ps->persistant[PERS_CAPTURES] != ops->persistant[PERS_CAPTURES]) {\n\t\tpushReward(cgs.media.captureAwardSound, cgs.media.medalCapture, ps->persistant[PERS_CAPTURES]);\n\t\treward = qtrue;\n\t\t//Com_Printf(\"capture\\n\");\n\t}\n\tif (ps->persistant[PERS_IMPRESSIVE_COUNT] != ops->persistant[PERS_IMPRESSIVE_COUNT]) {\n#ifdef MISSIONPACK\n\t\tif (ps->persistant[PERS_IMPRESSIVE_COUNT] == 1) {\n\t\t\tsfx = cgs.media.firstImpressiveSound;\n\t\t} else {\n\t\t\tsfx = cgs.media.impressiveSound;\n\t\t}\n#else\n\t\tsfx = cgs.media.impressiveSound;\n#endif\n\t\tpushReward(sfx, cgs.media.medalImpressive, ps->persistant[PERS_IMPRESSIVE_COUNT]);\n\t\treward = qtrue;\n\t\t//Com_Printf(\"impressive\\n\");\n\t}\n\tif (ps->persistant[PERS_EXCELLENT_COUNT] != ops->persistant[PERS_EXCELLENT_COUNT]) {\n#ifdef MISSIONPACK\n\t\tif (ps->persistant[PERS_EXCELLENT_COUNT] == 1) {\n\t\t\tsfx = cgs.media.firstExcellentSound;\n\t\t} else {\n\t\t\tsfx = cgs.media.excellentSound;\n\t\t}\n#else\n\t\tsfx = cgs.media.excellentSound;\n#endif\n\t\tpushReward(sfx, cgs.media.medalExcellent, ps->persistant[PERS_EXCELLENT_COUNT]);\n\t\treward = qtrue;\n\t\t//Com_Printf(\"excellent\\n\");\n\t}\n\tif (ps->persistant[PERS_GAUNTLET_FRAG_COUNT] != ops->persistant[PERS_GAUNTLET_FRAG_COUNT]) {\n#ifdef MISSIONPACK\n\t\tif (ops->persistant[PERS_GAUNTLET_FRAG_COUNT] == 1) {\n\t\t\tsfx = cgs.media.firstHumiliationSound;\n\t\t} else {\n\t\t\tsfx = cgs.media.humiliationSound;\n\t\t}\n#else\n\t\tsfx = cgs.media.humiliationSound;\n#endif\n\t\tpushReward(sfx, cgs.media.medalGauntlet, ps->persistant[PERS_GAUNTLET_FRAG_COUNT]);\n\t\treward = qtrue;\n\t\t//Com_Printf(\"guantlet frag\\n\");\n\t}\n\tif (ps->persistant[PERS_DEFEND_COUNT] != ops->persistant[PERS_DEFEND_COUNT]) {\n\t\tpushReward(cgs.media.defendSound, cgs.media.medalDefend, ps->persistant[PERS_DEFEND_COUNT]);\n\t\treward = qtrue;\n\t\t//Com_Printf(\"defend\\n\");\n\t}\n\tif (ps->persistant[PERS_ASSIST_COUNT] != ops->persistant[PERS_ASSIST_COUNT]) {\n\t\tpushReward(cgs.media.assistSound, cgs.media.medalAssist, ps->persistant[PERS_ASSIST_COUNT]);\n\t\treward = qtrue;\n\t\t//Com_Printf(\"assist\\n\");\n\t}\n\t// if any of the player event bits changed\n\tif (ps->persistant[PERS_PLAYEREVENTS] != ops->persistant[PERS_PLAYEREVENTS]) {\n\t\tif ((ps->persistant[PERS_PLAYEREVENTS] & PLAYEREVENT_DENIEDREWARD) !=\n\t\t\t\t(ops->persistant[PERS_PLAYEREVENTS] & PLAYEREVENT_DENIEDREWARD)) {\n\t\t\ttrap_S_StartLocalSound( cgs.media.deniedSound, CHAN_ANNOUNCER );\n\t\t}\n\t\telse if ((ps->persistant[PERS_PLAYEREVENTS] & PLAYEREVENT_GAUNTLETREWARD) !=\n\t\t\t\t(ops->persistant[PERS_PLAYEREVENTS] & PLAYEREVENT_GAUNTLETREWARD)) {\n\t\t\ttrap_S_StartLocalSound( cgs.media.humiliationSound, CHAN_ANNOUNCER );\n\t\t}\n\t\telse if ((ps->persistant[PERS_PLAYEREVENTS] & PLAYEREVENT_HOLYSHIT) !=\n\t\t\t\t(ops->persistant[PERS_PLAYEREVENTS] & PLAYEREVENT_HOLYSHIT)) {\n\t\t\ttrap_S_StartLocalSound( cgs.media.holyShitSound, CHAN_ANNOUNCER );\n\t\t}\n\t\treward = qtrue;\n\t}\n\n\t// check for flag pickup\n\tif ( cgs.gametype >= GT_TEAM ) {\n\t\tif ((ps->powerups[PW_REDFLAG] != ops->powerups[PW_REDFLAG] && ps->powerups[PW_REDFLAG]) ||\n\t\t\t(ps->powerups[PW_BLUEFLAG] != ops->powerups[PW_BLUEFLAG] && ps->powerups[PW_BLUEFLAG]) ||\n\t\t\t(ps->powerups[PW_NEUTRALFLAG] != ops->powerups[PW_NEUTRALFLAG] && ps->powerups[PW_NEUTRALFLAG]) )\n\t\t{\n\t\t\ttrap_S_StartLocalSound( cgs.media.youHaveFlagSound, CHAN_ANNOUNCER );\n\t\t}\n\t}\n\n\t// lead changes\n\tif (!reward) {\n\t\t//\n\t\tif ( !cg.warmup ) {\n\t\t\t// never play lead changes during warmup\n\t\t\tif ( ps->persistant[PERS_RANK] != ops->persistant[PERS_RANK] ) {\n\t\t\t\tif ( cgs.gametype < GT_TEAM) {\n\t\t\t\t\tif (  ps->persistant[PERS_RANK] == 0 ) {\n\t\t\t\t\t\tCG_AddBufferedSound(cgs.media.takenLeadSound);\n\t\t\t\t\t} else if ( ps->persistant[PERS_RANK] == RANK_TIED_FLAG ) {\n\t\t\t\t\t\tCG_AddBufferedSound(cgs.media.tiedLeadSound);\n\t\t\t\t\t} else if ( ( ops->persistant[PERS_RANK] & ~RANK_TIED_FLAG ) == 0 ) {\n\t\t\t\t\t\tCG_AddBufferedSound(cgs.media.lostLeadSound);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// timelimit warnings\n\tif ( cgs.timelimit > 0 ) {\n\t\tint\t\tmsec;\n\n\t\tmsec = cg.time - cgs.levelStartTime;\n\t\tif ( !( cg.timelimitWarnings & 4 ) && msec > ( cgs.timelimit * 60 + 2 ) * 1000 ) {\n\t\t\tcg.timelimitWarnings |= 1 | 2 | 4;\n\t\t\ttrap_S_StartLocalSound( cgs.media.suddenDeathSound, CHAN_ANNOUNCER );\n\t\t}\n\t\telse if ( !( cg.timelimitWarnings & 2 ) && msec > (cgs.timelimit - 1) * 60 * 1000 ) {\n\t\t\tcg.timelimitWarnings |= 1 | 2;\n\t\t\ttrap_S_StartLocalSound( cgs.media.oneMinuteSound, CHAN_ANNOUNCER );\n\t\t}\n\t\telse if ( cgs.timelimit > 5 && !( cg.timelimitWarnings & 1 ) && msec > (cgs.timelimit - 5) * 60 * 1000 ) {\n\t\t\tcg.timelimitWarnings |= 1;\n\t\t\ttrap_S_StartLocalSound( cgs.media.fiveMinuteSound, CHAN_ANNOUNCER );\n\t\t}\n\t}\n\n\t// fraglimit warnings\n\tif ( cgs.fraglimit > 0 && cgs.gametype < GT_CTF) {\n\t\thighScore = cgs.scores1;\n\t\tif ( !( cg.fraglimitWarnings & 4 ) && highScore == (cgs.fraglimit - 1) ) {\n\t\t\tcg.fraglimitWarnings |= 1 | 2 | 4;\n\t\t\tCG_AddBufferedSound(cgs.media.oneFragSound);\n\t\t}\n\t\telse if ( cgs.fraglimit > 2 && !( cg.fraglimitWarnings & 2 ) && highScore == (cgs.fraglimit - 2) ) {\n\t\t\tcg.fraglimitWarnings |= 1 | 2;\n\t\t\tCG_AddBufferedSound(cgs.media.twoFragSound);\n\t\t}\n\t\telse if ( cgs.fraglimit > 3 && !( cg.fraglimitWarnings & 1 ) && highScore == (cgs.fraglimit - 3) ) {\n\t\t\tcg.fraglimitWarnings |= 1;\n\t\t\tCG_AddBufferedSound(cgs.media.threeFragSound);\n\t\t}\n\t}\n}\n\n/*\n===============\nCG_TransitionPlayerState\n\n===============\n*/\nvoid CG_TransitionPlayerState( playerState_t *ps, playerState_t *ops ) {\n\t// check for changing follow mode\n\tif ( ps->clientNum != ops->clientNum ) {\n\t\tcg.thisFrameTeleport = qtrue;\n\t\t// make sure we don't get any unwanted transition effects\n\t\t*ops = *ps;\n\t}\n\n\t// damage events (player is getting wounded)\n\tif ( ps->damageEvent != ops->damageEvent && ps->damageCount ) {\n\t\tCG_DamageFeedback( ps->damageYaw, ps->damagePitch, ps->damageCount );\n\t}\n\n\t// respawning\n\tif ( ps->persistant[PERS_SPAWN_COUNT] != ops->persistant[PERS_SPAWN_COUNT] ) {\n\t\tCG_Respawn();\n\t}\n\n\tif ( cg.mapRestart ) {\n\t\tCG_Respawn();\n\t\tcg.mapRestart = qfalse;\n\t}\n\n\tif ( cg.snap->ps.pm_type != PM_INTERMISSION \n\t\t&& ps->persistant[PERS_TEAM] != TEAM_SPECTATOR ) {\n\t\tCG_CheckLocalSounds( ps, ops );\n\t}\n\n\t// check for going low on ammo\n\tCG_CheckAmmo();\n\n\t// run events\n\tCG_CheckPlayerstateEvents( ps, ops );\n\n\t// smooth the ducking viewheight change\n\tif ( ps->viewheight != ops->viewheight ) {\n\t\tcg.duckChange = ps->viewheight - ops->viewheight;\n\t\tcg.duckTime = cg.time;\n\t}\n}\n\n"
  },
  {
    "path": "code/cgame/cg_predict.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// cg_predict.c -- this file generates cg.predictedPlayerState by either\n// interpolating between snapshots from the server or locally predicting\n// ahead the client's movement.\n// It also handles local physics interaction, like fragments bouncing off walls\n\n#include \"cg_local.h\"\n\nstatic\tpmove_t\t\tcg_pmove;\n\nstatic\tint\t\t\tcg_numSolidEntities;\nstatic\tcentity_t\t*cg_solidEntities[MAX_ENTITIES_IN_SNAPSHOT];\nstatic\tint\t\t\tcg_numTriggerEntities;\nstatic\tcentity_t\t*cg_triggerEntities[MAX_ENTITIES_IN_SNAPSHOT];\n\n/*\n====================\nCG_BuildSolidList\n\nWhen a new cg.snap has been set, this function builds a sublist\nof the entities that are actually solid, to make for more\nefficient collision detection\n====================\n*/\nvoid CG_BuildSolidList( void ) {\n\tint\t\t\ti;\n\tcentity_t\t*cent;\n\tsnapshot_t\t*snap;\n\tentityState_t\t*ent;\n\n\tcg_numSolidEntities = 0;\n\tcg_numTriggerEntities = 0;\n\n\tif ( cg.nextSnap && !cg.nextFrameTeleport && !cg.thisFrameTeleport ) {\n\t\tsnap = cg.nextSnap;\n\t} else {\n\t\tsnap = cg.snap;\n\t}\n\n\tfor ( i = 0 ; i < snap->numEntities ; i++ ) {\n\t\tcent = &cg_entities[ snap->entities[ i ].number ];\n\t\tent = &cent->currentState;\n\n\t\tif ( ent->eType == ET_ITEM || ent->eType == ET_PUSH_TRIGGER || ent->eType == ET_TELEPORT_TRIGGER ) {\n\t\t\tcg_triggerEntities[cg_numTriggerEntities] = cent;\n\t\t\tcg_numTriggerEntities++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( cent->nextState.solid ) {\n\t\t\tcg_solidEntities[cg_numSolidEntities] = cent;\n\t\t\tcg_numSolidEntities++;\n\t\t\tcontinue;\n\t\t}\n\t}\n}\n\n/*\n====================\nCG_ClipMoveToEntities\n\n====================\n*/\nstatic void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end,\n\t\t\t\t\t\t\tint skipNumber, int mask, trace_t *tr ) {\n\tint\t\t\ti, x, zd, zu;\n\ttrace_t\t\ttrace;\n\tentityState_t\t*ent;\n\tclipHandle_t \tcmodel;\n\tvec3_t\t\tbmins, bmaxs;\n\tvec3_t\t\torigin, angles;\n\tcentity_t\t*cent;\n\n\tfor ( i = 0 ; i < cg_numSolidEntities ; i++ ) {\n\t\tcent = cg_solidEntities[ i ];\n\t\tent = &cent->currentState;\n\n\t\tif ( ent->number == skipNumber ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( ent->solid == SOLID_BMODEL ) {\n\t\t\t// special value for bmodel\n\t\t\tcmodel = trap_CM_InlineModel( ent->modelindex );\n\t\t\tVectorCopy( cent->lerpAngles, angles );\n\t\t\tBG_EvaluateTrajectory( &cent->currentState.pos, cg.physicsTime, origin );\n\t\t} else {\n\t\t\t// encoded bbox\n\t\t\tx = (ent->solid & 255);\n\t\t\tzd = ((ent->solid>>8) & 255);\n\t\t\tzu = ((ent->solid>>16) & 255) - 32;\n\n\t\t\tbmins[0] = bmins[1] = -x;\n\t\t\tbmaxs[0] = bmaxs[1] = x;\n\t\t\tbmins[2] = -zd;\n\t\t\tbmaxs[2] = zu;\n\n\t\t\tcmodel = trap_CM_TempBoxModel( bmins, bmaxs );\n\t\t\tVectorCopy( vec3_origin, angles );\n\t\t\tVectorCopy( cent->lerpOrigin, origin );\n\t\t}\n\n\n\t\ttrap_CM_TransformedBoxTrace ( &trace, start, end,\n\t\t\tmins, maxs, cmodel,  mask, origin, angles);\n\n\t\tif (trace.allsolid || trace.fraction < tr->fraction) {\n\t\t\ttrace.entityNum = ent->number;\n\t\t\t*tr = trace;\n\t\t} else if (trace.startsolid) {\n\t\t\ttr->startsolid = qtrue;\n\t\t}\n\t\tif ( tr->allsolid ) {\n\t\t\treturn;\n\t\t}\n\t}\n}\n\n/*\n================\nCG_Trace\n================\n*/\nvoid\tCG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, \n\t\t\t\t\t int skipNumber, int mask ) {\n\ttrace_t\tt;\n\n\ttrap_CM_BoxTrace ( &t, start, end, mins, maxs, 0, mask);\n\tt.entityNum = t.fraction != 1.0 ? ENTITYNUM_WORLD : ENTITYNUM_NONE;\n\t// check all other solid models\n\tCG_ClipMoveToEntities (start, mins, maxs, end, skipNumber, mask, &t);\n\n\t*result = t;\n}\n\n/*\n================\nCG_PointContents\n================\n*/\nint\t\tCG_PointContents( const vec3_t point, int passEntityNum ) {\n\tint\t\t\ti;\n\tentityState_t\t*ent;\n\tcentity_t\t*cent;\n\tclipHandle_t cmodel;\n\tint\t\t\tcontents;\n\n\tcontents = trap_CM_PointContents (point, 0);\n\n\tfor ( i = 0 ; i < cg_numSolidEntities ; i++ ) {\n\t\tcent = cg_solidEntities[ i ];\n\n\t\tent = &cent->currentState;\n\n\t\tif ( ent->number == passEntityNum ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (ent->solid != SOLID_BMODEL) { // special value for bmodel\n\t\t\tcontinue;\n\t\t}\n\n\t\tcmodel = trap_CM_InlineModel( ent->modelindex );\n\t\tif ( !cmodel ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tcontents |= trap_CM_TransformedPointContents( point, cmodel, ent->origin, ent->angles );\n\t}\n\n\treturn contents;\n}\n\n\n/*\n========================\nCG_InterpolatePlayerState\n\nGenerates cg.predictedPlayerState by interpolating between\ncg.snap->player_state and cg.nextFrame->player_state\n========================\n*/\nstatic void CG_InterpolatePlayerState( qboolean grabAngles ) {\n\tfloat\t\t\tf;\n\tint\t\t\t\ti;\n\tplayerState_t\t*out;\n\tsnapshot_t\t\t*prev, *next;\n\n\tout = &cg.predictedPlayerState;\n\tprev = cg.snap;\n\tnext = cg.nextSnap;\n\n\t*out = cg.snap->ps;\n\n\t// if we are still allowing local input, short circuit the view angles\n\tif ( grabAngles ) {\n\t\tusercmd_t\tcmd;\n\t\tint\t\t\tcmdNum;\n\n\t\tcmdNum = trap_GetCurrentCmdNumber();\n\t\ttrap_GetUserCmd( cmdNum, &cmd );\n\n\t\tPM_UpdateViewAngles( out, &cmd );\n\t}\n\n\t// if the next frame is a teleport, we can't lerp to it\n\tif ( cg.nextFrameTeleport ) {\n\t\treturn;\n\t}\n\n\tif ( !next || next->serverTime <= prev->serverTime ) {\n\t\treturn;\n\t}\n\n\tf = (float)( cg.time - prev->serverTime ) / ( next->serverTime - prev->serverTime );\n\n\ti = next->ps.bobCycle;\n\tif ( i < prev->ps.bobCycle ) {\n\t\ti += 256;\t\t// handle wraparound\n\t}\n\tout->bobCycle = prev->ps.bobCycle + f * ( i - prev->ps.bobCycle );\n\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tout->origin[i] = prev->ps.origin[i] + f * (next->ps.origin[i] - prev->ps.origin[i] );\n\t\tif ( !grabAngles ) {\n\t\t\tout->viewangles[i] = LerpAngle( \n\t\t\t\tprev->ps.viewangles[i], next->ps.viewangles[i], f );\n\t\t}\n\t\tout->velocity[i] = prev->ps.velocity[i] + \n\t\t\tf * (next->ps.velocity[i] - prev->ps.velocity[i] );\n\t}\n\n}\n\n/*\n===================\nCG_TouchItem\n===================\n*/\nstatic void CG_TouchItem( centity_t *cent ) {\n\tgitem_t\t\t*item;\n\n\tif ( !cg_predictItems.integer ) {\n\t\treturn;\n\t}\n\tif ( !BG_PlayerTouchesItem( &cg.predictedPlayerState, &cent->currentState, cg.time ) ) {\n\t\treturn;\n\t}\n\n\t// never pick an item up twice in a prediction\n\tif ( cent->miscTime == cg.time ) {\n\t\treturn;\n\t}\n\n\tif ( !BG_CanItemBeGrabbed( cgs.gametype, &cent->currentState, &cg.predictedPlayerState ) ) {\n\t\treturn;\t\t// can't hold it\n\t}\n\n\titem = &bg_itemlist[ cent->currentState.modelindex ];\n\n\t// Special case for flags.  \n\t// We don't predict touching our own flag\n#ifdef MISSIONPACK\n\tif( cgs.gametype == GT_1FCTF ) {\n\t\tif( item->giTag != PW_NEUTRALFLAG ) {\n\t\t\treturn;\n\t\t}\n\t}\n\tif( cgs.gametype == GT_CTF || cgs.gametype == GT_HARVESTER ) {\n#else\n\tif( cgs.gametype == GT_CTF ) {\n#endif\n\t\tif (cg.predictedPlayerState.persistant[PERS_TEAM] == TEAM_RED &&\n\t\t\titem->giTag == PW_REDFLAG)\n\t\t\treturn;\n\t\tif (cg.predictedPlayerState.persistant[PERS_TEAM] == TEAM_BLUE &&\n\t\t\titem->giTag == PW_BLUEFLAG)\n\t\t\treturn;\n\t}\n\n\t// grab it\n\tBG_AddPredictableEventToPlayerstate( EV_ITEM_PICKUP, cent->currentState.modelindex , &cg.predictedPlayerState);\n\n\t// remove it from the frame so it won't be drawn\n\tcent->currentState.eFlags |= EF_NODRAW;\n\n\t// don't touch it again this prediction\n\tcent->miscTime = cg.time;\n\n\t// if its a weapon, give them some predicted ammo so the autoswitch will work\n\tif ( item->giType == IT_WEAPON ) {\n\t\tcg.predictedPlayerState.stats[ STAT_WEAPONS ] |= 1 << item->giTag;\n\t\tif ( !cg.predictedPlayerState.ammo[ item->giTag ] ) {\n\t\t\tcg.predictedPlayerState.ammo[ item->giTag ] = 1;\n\t\t}\n\t}\n}\n\n\n/*\n=========================\nCG_TouchTriggerPrediction\n\nPredict push triggers and items\n=========================\n*/\nstatic void CG_TouchTriggerPrediction( void ) {\n\tint\t\t\ti;\n\ttrace_t\t\ttrace;\n\tentityState_t\t*ent;\n\tclipHandle_t cmodel;\n\tcentity_t\t*cent;\n\tqboolean\tspectator;\n\n\t// dead clients don't activate triggers\n\tif ( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) {\n\t\treturn;\n\t}\n\n\tspectator = ( cg.predictedPlayerState.pm_type == PM_SPECTATOR );\n\n\tif ( cg.predictedPlayerState.pm_type != PM_NORMAL && !spectator ) {\n\t\treturn;\n\t}\n\n\tfor ( i = 0 ; i < cg_numTriggerEntities ; i++ ) {\n\t\tcent = cg_triggerEntities[ i ];\n\t\tent = &cent->currentState;\n\n\t\tif ( ent->eType == ET_ITEM && !spectator ) {\n\t\t\tCG_TouchItem( cent );\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( ent->solid != SOLID_BMODEL ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tcmodel = trap_CM_InlineModel( ent->modelindex );\n\t\tif ( !cmodel ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\ttrap_CM_BoxTrace( &trace, cg.predictedPlayerState.origin, cg.predictedPlayerState.origin, \n\t\t\tcg_pmove.mins, cg_pmove.maxs, cmodel, -1 );\n\n\t\tif ( !trace.startsolid ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( ent->eType == ET_TELEPORT_TRIGGER ) {\n\t\t\tcg.hyperspace = qtrue;\n\t\t} else if ( ent->eType == ET_PUSH_TRIGGER ) {\n\t\t\tBG_TouchJumpPad( &cg.predictedPlayerState, ent );\n\t\t}\n\t}\n\n\t// if we didn't touch a jump pad this pmove frame\n\tif ( cg.predictedPlayerState.jumppad_frame != cg.predictedPlayerState.pmove_framecount ) {\n\t\tcg.predictedPlayerState.jumppad_frame = 0;\n\t\tcg.predictedPlayerState.jumppad_ent = 0;\n\t}\n}\n\n\n\n/*\n=================\nCG_PredictPlayerState\n\nGenerates cg.predictedPlayerState for the current cg.time\ncg.predictedPlayerState is guaranteed to be valid after exiting.\n\nFor demo playback, this will be an interpolation between two valid\nplayerState_t.\n\nFor normal gameplay, it will be the result of predicted usercmd_t on\ntop of the most recent playerState_t received from the server.\n\nEach new snapshot will usually have one or more new usercmd over the last,\nbut we simulate all unacknowledged commands each time, not just the new ones.\nThis means that on an internet connection, quite a few pmoves may be issued\neach frame.\n\nOPTIMIZE: don't re-simulate unless the newly arrived snapshot playerState_t\ndiffers from the predicted one.  Would require saving all intermediate\nplayerState_t during prediction.\n\nWe detect prediction errors and allow them to be decayed off over several frames\nto ease the jerk.\n=================\n*/\nvoid CG_PredictPlayerState( void ) {\n\tint\t\t\tcmdNum, current;\n\tplayerState_t\toldPlayerState;\n\tqboolean\tmoved;\n\tusercmd_t\toldestCmd;\n\tusercmd_t\tlatestCmd;\n\n\tcg.hyperspace = qfalse;\t// will be set if touching a trigger_teleport\n\n\t// if this is the first frame we must guarantee\n\t// predictedPlayerState is valid even if there is some\n\t// other error condition\n\tif ( !cg.validPPS ) {\n\t\tcg.validPPS = qtrue;\n\t\tcg.predictedPlayerState = cg.snap->ps;\n\t}\n\n\n\t// demo playback just copies the moves\n\tif ( cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_FOLLOW) ) {\n\t\tCG_InterpolatePlayerState( qfalse );\n\t\treturn;\n\t}\n\n\t// non-predicting local movement will grab the latest angles\n\tif ( cg_nopredict.integer || cg_synchronousClients.integer ) {\n\t\tCG_InterpolatePlayerState( qtrue );\n\t\treturn;\n\t}\n\n\t// prepare for pmove\n\tcg_pmove.ps = &cg.predictedPlayerState;\n\tcg_pmove.trace = CG_Trace;\n\tcg_pmove.pointcontents = CG_PointContents;\n\tif ( cg_pmove.ps->pm_type == PM_DEAD ) {\n\t\tcg_pmove.tracemask = MASK_PLAYERSOLID & ~CONTENTS_BODY;\n\t}\n\telse {\n\t\tcg_pmove.tracemask = MASK_PLAYERSOLID;\n\t}\n\tif ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR ) {\n\t\tcg_pmove.tracemask &= ~CONTENTS_BODY;\t// spectators can fly through bodies\n\t}\n\tcg_pmove.noFootsteps = ( cgs.dmflags & DF_NO_FOOTSTEPS ) > 0;\n\n\t// save the state before the pmove so we can detect transitions\n\toldPlayerState = cg.predictedPlayerState;\n\n\tcurrent = trap_GetCurrentCmdNumber();\n\n\t// if we don't have the commands right after the snapshot, we\n\t// can't accurately predict a current position, so just freeze at\n\t// the last good position we had\n\tcmdNum = current - CMD_BACKUP + 1;\n\ttrap_GetUserCmd( cmdNum, &oldestCmd );\n\tif ( oldestCmd.serverTime > cg.snap->ps.commandTime \n\t\t&& oldestCmd.serverTime < cg.time ) {\t// special check for map_restart\n\t\tif ( cg_showmiss.integer ) {\n\t\t\tCG_Printf (\"exceeded PACKET_BACKUP on commands\\n\");\n\t\t}\n\t\treturn;\n\t}\n\n\t// get the latest command so we can know which commands are from previous map_restarts\n\ttrap_GetUserCmd( current, &latestCmd );\n\n\t// get the most recent information we have, even if\n\t// the server time is beyond our current cg.time,\n\t// because predicted player positions are going to \n\t// be ahead of everything else anyway\n\tif ( cg.nextSnap && !cg.nextFrameTeleport && !cg.thisFrameTeleport ) {\n\t\tcg.predictedPlayerState = cg.nextSnap->ps;\n\t\tcg.physicsTime = cg.nextSnap->serverTime;\n\t} else {\n\t\tcg.predictedPlayerState = cg.snap->ps;\n\t\tcg.physicsTime = cg.snap->serverTime;\n\t}\n\n\tif ( pmove_msec.integer < 8 ) {\n\t\ttrap_Cvar_Set(\"pmove_msec\", \"8\");\n\t}\n\telse if (pmove_msec.integer > 33) {\n\t\ttrap_Cvar_Set(\"pmove_msec\", \"33\");\n\t}\n\n\tcg_pmove.pmove_fixed = pmove_fixed.integer;// | cg_pmove_fixed.integer;\n\tcg_pmove.pmove_msec = pmove_msec.integer;\n\n\t// run cmds\n\tmoved = qfalse;\n\tfor ( cmdNum = current - CMD_BACKUP + 1 ; cmdNum <= current ; cmdNum++ ) {\n\t\t// get the command\n\t\ttrap_GetUserCmd( cmdNum, &cg_pmove.cmd );\n\n\t\tif ( cg_pmove.pmove_fixed ) {\n\t\t\tPM_UpdateViewAngles( cg_pmove.ps, &cg_pmove.cmd );\n\t\t}\n\n\t\t// don't do anything if the time is before the snapshot player time\n\t\tif ( cg_pmove.cmd.serverTime <= cg.predictedPlayerState.commandTime ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// don't do anything if the command was from a previous map_restart\n\t\tif ( cg_pmove.cmd.serverTime > latestCmd.serverTime ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// check for a prediction error from last frame\n\t\t// on a lan, this will often be the exact value\n\t\t// from the snapshot, but on a wan we will have\n\t\t// to predict several commands to get to the point\n\t\t// we want to compare\n\t\tif ( cg.predictedPlayerState.commandTime == oldPlayerState.commandTime ) {\n\t\t\tvec3_t\tdelta;\n\t\t\tfloat\tlen;\n\n\t\t\tif ( cg.thisFrameTeleport ) {\n\t\t\t\t// a teleport will not cause an error decay\n\t\t\t\tVectorClear( cg.predictedError );\n\t\t\t\tif ( cg_showmiss.integer ) {\n\t\t\t\t\tCG_Printf( \"PredictionTeleport\\n\" );\n\t\t\t\t}\n\t\t\t\tcg.thisFrameTeleport = qfalse;\n\t\t\t} else {\n\t\t\t\tvec3_t\tadjusted;\n\t\t\t\tCG_AdjustPositionForMover( cg.predictedPlayerState.origin, \n\t\t\t\t\tcg.predictedPlayerState.groundEntityNum, cg.physicsTime, cg.oldTime, adjusted );\n\n\t\t\t\tif ( cg_showmiss.integer ) {\n\t\t\t\t\tif (!VectorCompare( oldPlayerState.origin, adjusted )) {\n\t\t\t\t\t\tCG_Printf(\"prediction error\\n\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tVectorSubtract( oldPlayerState.origin, adjusted, delta );\n\t\t\t\tlen = VectorLength( delta );\n\t\t\t\tif ( len > 0.1 ) {\n\t\t\t\t\tif ( cg_showmiss.integer ) {\n\t\t\t\t\t\tCG_Printf(\"Prediction miss: %f\\n\", len);\n\t\t\t\t\t}\n\t\t\t\t\tif ( cg_errorDecay.integer ) {\n\t\t\t\t\t\tint\t\tt;\n\t\t\t\t\t\tfloat\tf;\n\n\t\t\t\t\t\tt = cg.time - cg.predictedErrorTime;\n\t\t\t\t\t\tf = ( cg_errorDecay.value - t ) / cg_errorDecay.value;\n\t\t\t\t\t\tif ( f < 0 ) {\n\t\t\t\t\t\t\tf = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( f > 0 && cg_showmiss.integer ) {\n\t\t\t\t\t\t\tCG_Printf(\"Double prediction decay: %f\\n\", f);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tVectorScale( cg.predictedError, f, cg.predictedError );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tVectorClear( cg.predictedError );\n\t\t\t\t\t}\n\t\t\t\t\tVectorAdd( delta, cg.predictedError, cg.predictedError );\n\t\t\t\t\tcg.predictedErrorTime = cg.oldTime;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// don't predict gauntlet firing, which is only supposed to happen\n\t\t// when it actually inflicts damage\n\t\tcg_pmove.gauntletHit = qfalse;\n\n\t\tif ( cg_pmove.pmove_fixed ) {\n\t\t\tcg_pmove.cmd.serverTime = ((cg_pmove.cmd.serverTime + pmove_msec.integer-1) / pmove_msec.integer) * pmove_msec.integer;\n\t\t}\n\n\t\tPmove (&cg_pmove);\n\n\t\tmoved = qtrue;\n\n\t\t// add push trigger movement effects\n\t\tCG_TouchTriggerPrediction();\n\n\t\t// check for predictable events that changed from previous predictions\n\t\t//CG_CheckChangedPredictableEvents(&cg.predictedPlayerState);\n\t}\n\n\tif ( cg_showmiss.integer > 1 ) {\n\t\tCG_Printf( \"[%i : %i] \", cg_pmove.cmd.serverTime, cg.time );\n\t}\n\n\tif ( !moved ) {\n\t\tif ( cg_showmiss.integer ) {\n\t\t\tCG_Printf( \"not moved\\n\" );\n\t\t}\n\t\treturn;\n\t}\n\n\t// adjust for the movement of the groundentity\n\tCG_AdjustPositionForMover( cg.predictedPlayerState.origin, \n\t\tcg.predictedPlayerState.groundEntityNum, \n\t\tcg.physicsTime, cg.time, cg.predictedPlayerState.origin );\n\n\tif ( cg_showmiss.integer ) {\n\t\tif (cg.predictedPlayerState.eventSequence > oldPlayerState.eventSequence + MAX_PS_EVENTS) {\n\t\t\tCG_Printf(\"WARNING: dropped event\\n\");\n\t\t}\n\t}\n\n\t// fire events and other transition triggered things\n\tCG_TransitionPlayerState( &cg.predictedPlayerState, &oldPlayerState );\n\n\tif ( cg_showmiss.integer ) {\n\t\tif (cg.eventSequence > cg.predictedPlayerState.eventSequence) {\n\t\t\tCG_Printf(\"WARNING: double event\\n\");\n\t\t\tcg.eventSequence = cg.predictedPlayerState.eventSequence;\n\t\t}\n\t}\n}\n\n\n"
  },
  {
    "path": "code/cgame/cg_public.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n\n#define\tCMD_BACKUP\t\t\t64\t\n#define\tCMD_MASK\t\t\t(CMD_BACKUP - 1)\n// allow a lot of command backups for very fast systems\n// multiple commands may be combined into a single packet, so this\n// needs to be larger than PACKET_BACKUP\n\n\n#define\tMAX_ENTITIES_IN_SNAPSHOT\t256\n\n// snapshots are a view of the server at a given time\n\n// Snapshots are generated at regular time intervals by the server,\n// but they may not be sent if a client's rate level is exceeded, or\n// they may be dropped by the network.\ntypedef struct {\n\tint\t\t\t\tsnapFlags;\t\t\t// SNAPFLAG_RATE_DELAYED, etc\n\tint\t\t\t\tping;\n\n\tint\t\t\t\tserverTime;\t\t// server time the message is valid for (in msec)\n\n\tbyte\t\t\tareamask[MAX_MAP_AREA_BYTES];\t\t// portalarea visibility bits\n\n\tplayerState_t\tps;\t\t\t\t\t\t// complete information about the current player at this time\n\n\tint\t\t\t\tnumEntities;\t\t\t// all of the entities that need to be presented\n\tentityState_t\tentities[MAX_ENTITIES_IN_SNAPSHOT];\t// at the time of this snapshot\n\n\tint\t\t\t\tnumServerCommands;\t\t// text based server commands to execute when this\n\tint\t\t\t\tserverCommandSequence;\t// snapshot becomes current\n} snapshot_t;\n\nenum {\n  CGAME_EVENT_NONE,\n  CGAME_EVENT_TEAMMENU,\n  CGAME_EVENT_SCOREBOARD,\n  CGAME_EVENT_EDITHUD\n};\n\n\n/*\n==================================================================\n\nfunctions imported from the main executable\n\n==================================================================\n*/\n\n#define\tCGAME_IMPORT_API_VERSION\t4\n\ntypedef enum {\n\tCG_PRINT,\n\tCG_ERROR,\n\tCG_MILLISECONDS,\n\tCG_CVAR_REGISTER,\n\tCG_CVAR_UPDATE,\n\tCG_CVAR_SET,\n\tCG_CVAR_VARIABLESTRINGBUFFER,\n\tCG_ARGC,\n\tCG_ARGV,\n\tCG_ARGS,\n\tCG_FS_FOPENFILE,\n\tCG_FS_READ,\n\tCG_FS_WRITE,\n\tCG_FS_FCLOSEFILE,\n\tCG_SENDCONSOLECOMMAND,\n\tCG_ADDCOMMAND,\n\tCG_SENDCLIENTCOMMAND,\n\tCG_UPDATESCREEN,\n\tCG_CM_LOADMAP,\n\tCG_CM_NUMINLINEMODELS,\n\tCG_CM_INLINEMODEL,\n\tCG_CM_LOADMODEL,\n\tCG_CM_TEMPBOXMODEL,\n\tCG_CM_POINTCONTENTS,\n\tCG_CM_TRANSFORMEDPOINTCONTENTS,\n\tCG_CM_BOXTRACE,\n\tCG_CM_TRANSFORMEDBOXTRACE,\n\tCG_CM_MARKFRAGMENTS,\n\tCG_S_STARTSOUND,\n\tCG_S_STARTLOCALSOUND,\n\tCG_S_CLEARLOOPINGSOUNDS,\n\tCG_S_ADDLOOPINGSOUND,\n\tCG_S_UPDATEENTITYPOSITION,\n\tCG_S_RESPATIALIZE,\n\tCG_S_REGISTERSOUND,\n\tCG_S_STARTBACKGROUNDTRACK,\n\tCG_R_LOADWORLDMAP,\n\tCG_R_REGISTERMODEL,\n\tCG_R_REGISTERSKIN,\n\tCG_R_REGISTERSHADER,\n\tCG_R_CLEARSCENE,\n\tCG_R_ADDREFENTITYTOSCENE,\n\tCG_R_ADDPOLYTOSCENE,\n\tCG_R_ADDLIGHTTOSCENE,\n\tCG_R_RENDERSCENE,\n\tCG_R_SETCOLOR,\n\tCG_R_DRAWSTRETCHPIC,\n\tCG_R_MODELBOUNDS,\n\tCG_R_LERPTAG,\n\tCG_GETGLCONFIG,\n\tCG_GETGAMESTATE,\n\tCG_GETCURRENTSNAPSHOTNUMBER,\n\tCG_GETSNAPSHOT,\n\tCG_GETSERVERCOMMAND,\n\tCG_GETCURRENTCMDNUMBER,\n\tCG_GETUSERCMD,\n\tCG_SETUSERCMDVALUE,\n\tCG_R_REGISTERSHADERNOMIP,\n\tCG_MEMORY_REMAINING,\n\tCG_R_REGISTERFONT,\n\tCG_KEY_ISDOWN,\n\tCG_KEY_GETCATCHER,\n\tCG_KEY_SETCATCHER,\n\tCG_KEY_GETKEY,\n \tCG_PC_ADD_GLOBAL_DEFINE,\n\tCG_PC_LOAD_SOURCE,\n\tCG_PC_FREE_SOURCE,\n\tCG_PC_READ_TOKEN,\n\tCG_PC_SOURCE_FILE_AND_LINE,\n\tCG_S_STOPBACKGROUNDTRACK,\n\tCG_REAL_TIME,\n\tCG_SNAPVECTOR,\n\tCG_REMOVECOMMAND,\n\tCG_R_LIGHTFORPOINT,\n\tCG_CIN_PLAYCINEMATIC,\n\tCG_CIN_STOPCINEMATIC,\n\tCG_CIN_RUNCINEMATIC,\n\tCG_CIN_DRAWCINEMATIC,\n\tCG_CIN_SETEXTENTS,\n\tCG_R_REMAP_SHADER,\n\tCG_S_ADDREALLOOPINGSOUND,\n\tCG_S_STOPLOOPINGSOUND,\n\n\tCG_CM_TEMPCAPSULEMODEL,\n\tCG_CM_CAPSULETRACE,\n\tCG_CM_TRANSFORMEDCAPSULETRACE,\n\tCG_R_ADDADDITIVELIGHTTOSCENE,\n\tCG_GET_ENTITY_TOKEN,\n\tCG_R_ADDPOLYSTOSCENE,\n\tCG_R_INPVS,\n\t// 1.32\n\tCG_FS_SEEK,\n\n/*\n\tCG_LOADCAMERA,\n\tCG_STARTCAMERA,\n\tCG_GETCAMERAINFO,\n*/\n\n\tCG_MEMSET = 100,\n\tCG_MEMCPY,\n\tCG_STRNCPY,\n\tCG_SIN,\n\tCG_COS,\n\tCG_ATAN2,\n\tCG_SQRT,\n\tCG_FLOOR,\n\tCG_CEIL,\n\tCG_TESTPRINTINT,\n\tCG_TESTPRINTFLOAT,\n\tCG_ACOS\n} cgameImport_t;\n\n\n/*\n==================================================================\n\nfunctions exported to the main executable\n\n==================================================================\n*/\n\ntypedef enum {\n\tCG_INIT,\n//\tvoid CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum )\n\t// called when the level loads or when the renderer is restarted\n\t// all media should be registered at this time\n\t// cgame will display loading status by calling SCR_Update, which\n\t// will call CG_DrawInformation during the loading process\n\t// reliableCommandSequence will be 0 on fresh loads, but higher for\n\t// demos, tourney restarts, or vid_restarts\n\n\tCG_SHUTDOWN,\n//\tvoid (*CG_Shutdown)( void );\n\t// oportunity to flush and close any open files\n\n\tCG_CONSOLE_COMMAND,\n//\tqboolean (*CG_ConsoleCommand)( void );\n\t// a console command has been issued locally that is not recognized by the\n\t// main game system.\n\t// use Cmd_Argc() / Cmd_Argv() to read the command, return qfalse if the\n\t// command is not known to the game\n\n\tCG_DRAW_ACTIVE_FRAME,\n//\tvoid (*CG_DrawActiveFrame)( int serverTime, stereoFrame_t stereoView, qboolean demoPlayback );\n\t// Generates and draws a game scene and status information at the given time.\n\t// If demoPlayback is set, local movement prediction will not be enabled\n\n\tCG_CROSSHAIR_PLAYER,\n//\tint (*CG_CrosshairPlayer)( void );\n\n\tCG_LAST_ATTACKER,\n//\tint (*CG_LastAttacker)( void );\n\n\tCG_KEY_EVENT, \n//\tvoid\t(*CG_KeyEvent)( int key, qboolean down );\n\n\tCG_MOUSE_EVENT,\n//\tvoid\t(*CG_MouseEvent)( int dx, int dy );\n\tCG_EVENT_HANDLING\n//\tvoid (*CG_EventHandling)(int type);\n} cgameExport_t;\n\n//----------------------------------------------\n"
  },
  {
    "path": "code/cgame/cg_scoreboard.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// cg_scoreboard -- draw the scoreboard on top of the game screen\n#include \"cg_local.h\"\n\n\n#define\tSCOREBOARD_X\t\t(0)\n\n#define SB_HEADER\t\t\t86\n#define SB_TOP\t\t\t\t(SB_HEADER+32)\n\n// Where the status bar starts, so we don't overwrite it\n#define SB_STATUSBAR\t\t420\n\n#define SB_NORMAL_HEIGHT\t40\n#define SB_INTER_HEIGHT\t\t16 // interleaved height\n\n#define SB_MAXCLIENTS_NORMAL  ((SB_STATUSBAR - SB_TOP) / SB_NORMAL_HEIGHT)\n#define SB_MAXCLIENTS_INTER   ((SB_STATUSBAR - SB_TOP) / SB_INTER_HEIGHT - 1)\n\n// Used when interleaved\n\n\n\n#define SB_LEFT_BOTICON_X\t(SCOREBOARD_X+0)\n#define SB_LEFT_HEAD_X\t\t(SCOREBOARD_X+32)\n#define SB_RIGHT_BOTICON_X\t(SCOREBOARD_X+64)\n#define SB_RIGHT_HEAD_X\t\t(SCOREBOARD_X+96)\n// Normal\n#define SB_BOTICON_X\t\t(SCOREBOARD_X+32)\n#define SB_HEAD_X\t\t\t(SCOREBOARD_X+64)\n\n#define SB_SCORELINE_X\t\t112\n\n#define SB_RATING_WIDTH\t    (6 * BIGCHAR_WIDTH) // width 6\n#define SB_SCORE_X\t\t\t(SB_SCORELINE_X + BIGCHAR_WIDTH) // width 6\n#define SB_RATING_X\t\t\t(SB_SCORELINE_X + 6 * BIGCHAR_WIDTH) // width 6\n#define SB_PING_X\t\t\t(SB_SCORELINE_X + 12 * BIGCHAR_WIDTH + 8) // width 5\n#define SB_TIME_X\t\t\t(SB_SCORELINE_X + 17 * BIGCHAR_WIDTH + 8) // width 5\n#define SB_NAME_X\t\t\t(SB_SCORELINE_X + 22 * BIGCHAR_WIDTH) // width 15\n\n// The new and improved score board\n//\n// In cases where the number of clients is high, the score board heads are interleaved\n// here's the layout\n\n//\n//\t0   32   80  112  144   240  320  400   <-- pixel position\n//  bot head bot head score ping time name\n//  \n//  wins/losses are drawn on bot icon now\n\nstatic qboolean localClient; // true if local client has been displayed\n\n\n\t\t\t\t\t\t\t /*\n=================\nCG_DrawScoreboard\n=================\n*/\nstatic void CG_DrawClientScore( int y, score_t *score, float *color, float fade, qboolean largeFormat ) {\n\tchar\tstring[1024];\n\tvec3_t\theadAngles;\n\tclientInfo_t\t*ci;\n\tint iconx, headx;\n\n\tif ( score->client < 0 || score->client >= cgs.maxclients ) {\n\t\tCom_Printf( \"Bad score->client: %i\\n\", score->client );\n\t\treturn;\n\t}\n\t\n\tci = &cgs.clientinfo[score->client];\n\n\ticonx = SB_BOTICON_X + (SB_RATING_WIDTH / 2);\n\theadx = SB_HEAD_X + (SB_RATING_WIDTH / 2);\n\n\t// draw the handicap or bot skill marker (unless player has flag)\n\tif ( ci->powerups & ( 1 << PW_NEUTRALFLAG ) ) {\n\t\tif( largeFormat ) {\n\t\t\tCG_DrawFlagModel( iconx, y - ( 32 - BIGCHAR_HEIGHT ) / 2, 32, 32, TEAM_FREE, qfalse );\n\t\t}\n\t\telse {\n\t\t\tCG_DrawFlagModel( iconx, y, 16, 16, TEAM_FREE, qfalse );\n\t\t}\n\t} else if ( ci->powerups & ( 1 << PW_REDFLAG ) ) {\n\t\tif( largeFormat ) {\n\t\t\tCG_DrawFlagModel( iconx, y - ( 32 - BIGCHAR_HEIGHT ) / 2, 32, 32, TEAM_RED, qfalse );\n\t\t}\n\t\telse {\n\t\t\tCG_DrawFlagModel( iconx, y, 16, 16, TEAM_RED, qfalse );\n\t\t}\n\t} else if ( ci->powerups & ( 1 << PW_BLUEFLAG ) ) {\n\t\tif( largeFormat ) {\n\t\t\tCG_DrawFlagModel( iconx, y - ( 32 - BIGCHAR_HEIGHT ) / 2, 32, 32, TEAM_BLUE, qfalse );\n\t\t}\n\t\telse {\n\t\t\tCG_DrawFlagModel( iconx, y, 16, 16, TEAM_BLUE, qfalse );\n\t\t}\n\t} else {\n\t\tif ( ci->botSkill > 0 && ci->botSkill <= 5 ) {\n\t\t\tif ( cg_drawIcons.integer ) {\n\t\t\t\tif( largeFormat ) {\n\t\t\t\t\tCG_DrawPic( iconx, y - ( 32 - BIGCHAR_HEIGHT ) / 2, 32, 32, cgs.media.botSkillShaders[ ci->botSkill - 1 ] );\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tCG_DrawPic( iconx, y, 16, 16, cgs.media.botSkillShaders[ ci->botSkill - 1 ] );\n\t\t\t\t}\n\t\t\t}\n\t\t} else if ( ci->handicap < 100 ) {\n\t\t\tCom_sprintf( string, sizeof( string ), \"%i\", ci->handicap );\n\t\t\tif ( cgs.gametype == GT_TOURNAMENT )\n\t\t\t\tCG_DrawSmallStringColor( iconx, y - SMALLCHAR_HEIGHT/2, string, color );\n\t\t\telse\n\t\t\t\tCG_DrawSmallStringColor( iconx, y, string, color );\n\t\t}\n\n\t\t// draw the wins / losses\n\t\tif ( cgs.gametype == GT_TOURNAMENT ) {\n\t\t\tCom_sprintf( string, sizeof( string ), \"%i/%i\", ci->wins, ci->losses );\n\t\t\tif( ci->handicap < 100 && !ci->botSkill ) {\n\t\t\t\tCG_DrawSmallStringColor( iconx, y + SMALLCHAR_HEIGHT/2, string, color );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tCG_DrawSmallStringColor( iconx, y, string, color );\n\t\t\t}\n\t\t}\n\t}\n\n\t// draw the face\n\tVectorClear( headAngles );\n\theadAngles[YAW] = 180;\n\tif( largeFormat ) {\n\t\tCG_DrawHead( headx, y - ( ICON_SIZE - BIGCHAR_HEIGHT ) / 2, ICON_SIZE, ICON_SIZE, \n\t\t\tscore->client, headAngles );\n\t}\n\telse {\n\t\tCG_DrawHead( headx, y, 16, 16, score->client, headAngles );\n\t}\n\n#ifdef MISSIONPACK\n\t// draw the team task\n\tif ( ci->teamTask != TEAMTASK_NONE ) {\n\t\tif ( ci->teamTask == TEAMTASK_OFFENSE ) {\n\t\t\tCG_DrawPic( headx + 48, y, 16, 16, cgs.media.assaultShader );\n\t\t}\n\t\telse if ( ci->teamTask == TEAMTASK_DEFENSE ) {\n\t\t\tCG_DrawPic( headx + 48, y, 16, 16, cgs.media.defendShader );\n\t\t}\n\t}\n#endif\n\t// draw the score line\n\tif ( score->ping == -1 ) {\n\t\tCom_sprintf(string, sizeof(string),\n\t\t\t\" connecting    %s\", ci->name);\n\t} else if ( ci->team == TEAM_SPECTATOR ) {\n\t\tCom_sprintf(string, sizeof(string),\n\t\t\t\" SPECT %3i %4i %s\", score->ping, score->time, ci->name);\n\t} else {\n\t\tCom_sprintf(string, sizeof(string),\n\t\t\t\"%5i %4i %4i %s\", score->score, score->ping, score->time, ci->name);\n\t}\n\n\t// highlight your position\n\tif ( score->client == cg.snap->ps.clientNum ) {\n\t\tfloat\thcolor[4];\n\t\tint\t\trank;\n\n\t\tlocalClient = qtrue;\n\n\t\tif ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR \n\t\t\t|| cgs.gametype >= GT_TEAM ) {\n\t\t\trank = -1;\n\t\t} else {\n\t\t\trank = cg.snap->ps.persistant[PERS_RANK] & ~RANK_TIED_FLAG;\n\t\t}\n\t\tif ( rank == 0 ) {\n\t\t\thcolor[0] = 0;\n\t\t\thcolor[1] = 0;\n\t\t\thcolor[2] = 0.7f;\n\t\t} else if ( rank == 1 ) {\n\t\t\thcolor[0] = 0.7f;\n\t\t\thcolor[1] = 0;\n\t\t\thcolor[2] = 0;\n\t\t} else if ( rank == 2 ) {\n\t\t\thcolor[0] = 0.7f;\n\t\t\thcolor[1] = 0.7f;\n\t\t\thcolor[2] = 0;\n\t\t} else {\n\t\t\thcolor[0] = 0.7f;\n\t\t\thcolor[1] = 0.7f;\n\t\t\thcolor[2] = 0.7f;\n\t\t}\n\n\t\thcolor[3] = fade * 0.7;\n\t\tCG_FillRect( SB_SCORELINE_X + BIGCHAR_WIDTH + (SB_RATING_WIDTH / 2), y, \n\t\t\t640 - SB_SCORELINE_X - BIGCHAR_WIDTH, BIGCHAR_HEIGHT+1, hcolor );\n\t}\n\n\tCG_DrawBigString( SB_SCORELINE_X + (SB_RATING_WIDTH / 2), y, string, fade );\n\n\t// add the \"ready\" marker for intermission exiting\n\tif ( cg.snap->ps.stats[ STAT_CLIENTS_READY ] & ( 1 << score->client ) ) {\n\t\tCG_DrawBigStringColor( iconx, y, \"READY\", color );\n\t}\n}\n\n/*\n=================\nCG_TeamScoreboard\n=================\n*/\nstatic int CG_TeamScoreboard( int y, team_t team, float fade, int maxClients, int lineHeight ) {\n\tint\t\ti;\n\tscore_t\t*score;\n\tfloat\tcolor[4];\n\tint\t\tcount;\n\tclientInfo_t\t*ci;\n\n\tcolor[0] = color[1] = color[2] = 1.0;\n\tcolor[3] = fade;\n\n\tcount = 0;\n\tfor ( i = 0 ; i < cg.numScores && count < maxClients ; i++ ) {\n\t\tscore = &cg.scores[i];\n\t\tci = &cgs.clientinfo[ score->client ];\n\n\t\tif ( team != ci->team ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tCG_DrawClientScore( y + lineHeight * count, score, color, fade, lineHeight == SB_NORMAL_HEIGHT );\n\n\t\tcount++;\n\t}\n\n\treturn count;\n}\n\n/*\n=================\nCG_DrawScoreboard\n\nDraw the normal in-game scoreboard\n=================\n*/\nqboolean CG_DrawOldScoreboard( void ) {\n\tint\t\tx, y, w, i, n1, n2;\n\tfloat\tfade;\n\tfloat\t*fadeColor;\n\tchar\t*s;\n\tint maxClients;\n\tint lineHeight;\n\tint topBorderSize, bottomBorderSize;\n\n\t// don't draw amuthing if the menu or console is up\n\tif ( cg_paused.integer ) {\n\t\tcg.deferredPlayerLoading = 0;\n\t\treturn qfalse;\n\t}\n\n\tif ( cgs.gametype == GT_SINGLE_PLAYER && cg.predictedPlayerState.pm_type == PM_INTERMISSION ) {\n\t\tcg.deferredPlayerLoading = 0;\n\t\treturn qfalse;\n\t}\n\n\t// don't draw scoreboard during death while warmup up\n\tif ( cg.warmup && !cg.showScores ) {\n\t\treturn qfalse;\n\t}\n\n\tif ( cg.showScores || cg.predictedPlayerState.pm_type == PM_DEAD ||\n\t\t cg.predictedPlayerState.pm_type == PM_INTERMISSION ) {\n\t\tfade = 1.0;\n\t\tfadeColor = colorWhite;\n\t} else {\n\t\tfadeColor = CG_FadeColor( cg.scoreFadeTime, FADE_TIME );\n\t\t\n\t\tif ( !fadeColor ) {\n\t\t\t// next time scoreboard comes up, don't print killer\n\t\t\tcg.deferredPlayerLoading = 0;\n\t\t\tcg.killerName[0] = 0;\n\t\t\treturn qfalse;\n\t\t}\n\t\tfade = *fadeColor;\n\t}\n\n\n\t// fragged by ... line\n\tif ( cg.killerName[0] ) {\n\t\ts = va(\"Fragged by %s\", cg.killerName );\n\t\tw = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;\n\t\tx = ( SCREEN_WIDTH - w ) / 2;\n\t\ty = 40;\n\t\tCG_DrawBigString( x, y, s, fade );\n\t}\n\n\t// current rank\n\tif ( cgs.gametype < GT_TEAM) {\n\t\tif (cg.snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR ) {\n\t\t\ts = va(\"%s place with %i\",\n\t\t\t\tCG_PlaceString( cg.snap->ps.persistant[PERS_RANK] + 1 ),\n\t\t\t\tcg.snap->ps.persistant[PERS_SCORE] );\n\t\t\tw = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;\n\t\t\tx = ( SCREEN_WIDTH - w ) / 2;\n\t\t\ty = 60;\n\t\t\tCG_DrawBigString( x, y, s, fade );\n\t\t}\n\t} else {\n\t\tif ( cg.teamScores[0] == cg.teamScores[1] ) {\n\t\t\ts = va(\"Teams are tied at %i\", cg.teamScores[0] );\n\t\t} else if ( cg.teamScores[0] >= cg.teamScores[1] ) {\n\t\t\ts = va(\"Red leads %i to %i\",cg.teamScores[0], cg.teamScores[1] );\n\t\t} else {\n\t\t\ts = va(\"Blue leads %i to %i\",cg.teamScores[1], cg.teamScores[0] );\n\t\t}\n\n\t\tw = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;\n\t\tx = ( SCREEN_WIDTH - w ) / 2;\n\t\ty = 60;\n\t\tCG_DrawBigString( x, y, s, fade );\n\t}\n\n\t// scoreboard\n\ty = SB_HEADER;\n\n\tCG_DrawPic( SB_SCORE_X + (SB_RATING_WIDTH / 2), y, 64, 32, cgs.media.scoreboardScore );\n\tCG_DrawPic( SB_PING_X - (SB_RATING_WIDTH / 2), y, 64, 32, cgs.media.scoreboardPing );\n\tCG_DrawPic( SB_TIME_X - (SB_RATING_WIDTH / 2), y, 64, 32, cgs.media.scoreboardTime );\n\tCG_DrawPic( SB_NAME_X - (SB_RATING_WIDTH / 2), y, 64, 32, cgs.media.scoreboardName );\n\n\ty = SB_TOP;\n\n\t// If there are more than SB_MAXCLIENTS_NORMAL, use the interleaved scores\n\tif ( cg.numScores > SB_MAXCLIENTS_NORMAL ) {\n\t\tmaxClients = SB_MAXCLIENTS_INTER;\n\t\tlineHeight = SB_INTER_HEIGHT;\n\t\ttopBorderSize = 8;\n\t\tbottomBorderSize = 16;\n\t} else {\n\t\tmaxClients = SB_MAXCLIENTS_NORMAL;\n\t\tlineHeight = SB_NORMAL_HEIGHT;\n\t\ttopBorderSize = 16;\n\t\tbottomBorderSize = 16;\n\t}\n\n\tlocalClient = qfalse;\n\n\tif ( cgs.gametype >= GT_TEAM ) {\n\t\t//\n\t\t// teamplay scoreboard\n\t\t//\n\t\ty += lineHeight/2;\n\n\t\tif ( cg.teamScores[0] >= cg.teamScores[1] ) {\n\t\t\tn1 = CG_TeamScoreboard( y, TEAM_RED, fade, maxClients, lineHeight );\n\t\t\tCG_DrawTeamBackground( 0, y - topBorderSize, 640, n1 * lineHeight + bottomBorderSize, 0.33f, TEAM_RED );\n\t\t\ty += (n1 * lineHeight) + BIGCHAR_HEIGHT;\n\t\t\tmaxClients -= n1;\n\t\t\tn2 = CG_TeamScoreboard( y, TEAM_BLUE, fade, maxClients, lineHeight );\n\t\t\tCG_DrawTeamBackground( 0, y - topBorderSize, 640, n2 * lineHeight + bottomBorderSize, 0.33f, TEAM_BLUE );\n\t\t\ty += (n2 * lineHeight) + BIGCHAR_HEIGHT;\n\t\t\tmaxClients -= n2;\n\t\t} else {\n\t\t\tn1 = CG_TeamScoreboard( y, TEAM_BLUE, fade, maxClients, lineHeight );\n\t\t\tCG_DrawTeamBackground( 0, y - topBorderSize, 640, n1 * lineHeight + bottomBorderSize, 0.33f, TEAM_BLUE );\n\t\t\ty += (n1 * lineHeight) + BIGCHAR_HEIGHT;\n\t\t\tmaxClients -= n1;\n\t\t\tn2 = CG_TeamScoreboard( y, TEAM_RED, fade, maxClients, lineHeight );\n\t\t\tCG_DrawTeamBackground( 0, y - topBorderSize, 640, n2 * lineHeight + bottomBorderSize, 0.33f, TEAM_RED );\n\t\t\ty += (n2 * lineHeight) + BIGCHAR_HEIGHT;\n\t\t\tmaxClients -= n2;\n\t\t}\n\t\tn1 = CG_TeamScoreboard( y, TEAM_SPECTATOR, fade, maxClients, lineHeight );\n\t\ty += (n1 * lineHeight) + BIGCHAR_HEIGHT;\n\n\t} else {\n\t\t//\n\t\t// free for all scoreboard\n\t\t//\n\t\tn1 = CG_TeamScoreboard( y, TEAM_FREE, fade, maxClients, lineHeight );\n\t\ty += (n1 * lineHeight) + BIGCHAR_HEIGHT;\n\t\tn2 = CG_TeamScoreboard( y, TEAM_SPECTATOR, fade, maxClients - n1, lineHeight );\n\t\ty += (n2 * lineHeight) + BIGCHAR_HEIGHT;\n\t}\n\n\tif (!localClient) {\n\t\t// draw local client at the bottom\n\t\tfor ( i = 0 ; i < cg.numScores ; i++ ) {\n\t\t\tif ( cg.scores[i].client == cg.snap->ps.clientNum ) {\n\t\t\t\tCG_DrawClientScore( y, &cg.scores[i], fadeColor, fade, lineHeight == SB_NORMAL_HEIGHT );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t// load any models that have been deferred\n\tif ( ++cg.deferredPlayerLoading > 10 ) {\n\t\tCG_LoadDeferredPlayers();\n\t}\n\n\treturn qtrue;\n}\n\n//================================================================================\n\n/*\n================\nCG_CenterGiantLine\n================\n*/\nstatic void CG_CenterGiantLine( float y, const char *string ) {\n\tfloat\t\tx;\n\tvec4_t\t\tcolor;\n\n\tcolor[0] = 1;\n\tcolor[1] = 1;\n\tcolor[2] = 1;\n\tcolor[3] = 1;\n\n\tx = 0.5 * ( 640 - GIANT_WIDTH * CG_DrawStrlen( string ) );\n\n\tCG_DrawStringExt( x, y, string, color, qtrue, qtrue, GIANT_WIDTH, GIANT_HEIGHT, 0 );\n}\n\n/*\n=================\nCG_DrawTourneyScoreboard\n\nDraw the oversize scoreboard for tournements\n=================\n*/\nvoid CG_DrawOldTourneyScoreboard( void ) {\n\tconst char\t\t*s;\n\tvec4_t\t\t\tcolor;\n\tint\t\t\t\tmin, tens, ones;\n\tclientInfo_t\t*ci;\n\tint\t\t\t\ty;\n\tint\t\t\t\ti;\n\n\t// request more scores regularly\n\tif ( cg.scoresRequestTime + 2000 < cg.time ) {\n\t\tcg.scoresRequestTime = cg.time;\n\t\ttrap_SendClientCommand( \"score\" );\n\t}\n\n\tcolor[0] = 1;\n\tcolor[1] = 1;\n\tcolor[2] = 1;\n\tcolor[3] = 1;\n\n\t// draw the dialog background\n\tcolor[0] = color[1] = color[2] = 0;\n\tcolor[3] = 1;\n\tCG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, color );\n\n\t// print the mesage of the day\n\ts = CG_ConfigString( CS_MOTD );\n\tif ( !s[0] ) {\n\t\ts = \"Scoreboard\";\n\t}\n\n\t// print optional title\n\tCG_CenterGiantLine( 8, s );\n\n\t// print server time\n\tones = cg.time / 1000;\n\tmin = ones / 60;\n\tones %= 60;\n\ttens = ones / 10;\n\tones %= 10;\n\ts = va(\"%i:%i%i\", min, tens, ones );\n\n\tCG_CenterGiantLine( 64, s );\n\n\n\t// print the two scores\n\n\ty = 160;\n\tif ( cgs.gametype >= GT_TEAM ) {\n\t\t//\n\t\t// teamplay scoreboard\n\t\t//\n\t\tCG_DrawStringExt( 8, y, \"Red Team\", color, qtrue, qtrue, GIANT_WIDTH, GIANT_HEIGHT, 0 );\n\t\ts = va(\"%i\", cg.teamScores[0] );\n\t\tCG_DrawStringExt( 632 - GIANT_WIDTH * strlen(s), y, s, color, qtrue, qtrue, GIANT_WIDTH, GIANT_HEIGHT, 0 );\n\t\t\n\t\ty += 64;\n\n\t\tCG_DrawStringExt( 8, y, \"Blue Team\", color, qtrue, qtrue, GIANT_WIDTH, GIANT_HEIGHT, 0 );\n\t\ts = va(\"%i\", cg.teamScores[1] );\n\t\tCG_DrawStringExt( 632 - GIANT_WIDTH * strlen(s), y, s, color, qtrue, qtrue, GIANT_WIDTH, GIANT_HEIGHT, 0 );\n\t} else {\n\t\t//\n\t\t// free for all scoreboard\n\t\t//\n\t\tfor ( i = 0 ; i < MAX_CLIENTS ; i++ ) {\n\t\t\tci = &cgs.clientinfo[i];\n\t\t\tif ( !ci->infoValid ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( ci->team != TEAM_FREE ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tCG_DrawStringExt( 8, y, ci->name, color, qtrue, qtrue, GIANT_WIDTH, GIANT_HEIGHT, 0 );\n\t\t\ts = va(\"%i\", ci->score );\n\t\t\tCG_DrawStringExt( 632 - GIANT_WIDTH * strlen(s), y, s, color, qtrue, qtrue, GIANT_WIDTH, GIANT_HEIGHT, 0 );\n\t\t\ty += 64;\n\t\t}\n\t}\n\n\n}\n\n"
  },
  {
    "path": "code/cgame/cg_servercmds.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// cg_servercmds.c -- reliably sequenced text commands sent by the server\n// these are processed at snapshot transition time, so there will definately\n// be a valid snapshot this frame\n\n#include \"cg_local.h\"\n#include \"../../ui/menudef.h\" // bk001205 - for Q3_ui as well\n\ntypedef struct {\n\tconst char *order;\n\tint taskNum;\n} orderTask_t;\n\nstatic const orderTask_t validOrders[] = {\n\t{ VOICECHAT_GETFLAG,\t\t\t\t\t\tTEAMTASK_OFFENSE },\n\t{ VOICECHAT_OFFENSE,\t\t\t\t\t\tTEAMTASK_OFFENSE },\n\t{ VOICECHAT_DEFEND,\t\t\t\t\t\t\tTEAMTASK_DEFENSE },\n\t{ VOICECHAT_DEFENDFLAG,\t\t\t\t\tTEAMTASK_DEFENSE },\n\t{ VOICECHAT_PATROL,\t\t\t\t\t\t\tTEAMTASK_PATROL },\n\t{ VOICECHAT_CAMP,\t\t\t\t\t\t\t\tTEAMTASK_CAMP },\n\t{ VOICECHAT_FOLLOWME,\t\t\t\t\t\tTEAMTASK_FOLLOW },\n\t{ VOICECHAT_RETURNFLAG,\t\t\t\t\tTEAMTASK_RETRIEVE },\n\t{ VOICECHAT_FOLLOWFLAGCARRIER,\tTEAMTASK_ESCORT }\n};\n\nstatic const int numValidOrders = sizeof(validOrders) / sizeof(orderTask_t);\n\n#ifdef MISSIONPACK // bk001204\nstatic int CG_ValidOrder(const char *p) {\n\tint i;\n\tfor (i = 0; i < numValidOrders; i++) {\n\t\tif (Q_stricmp(p, validOrders[i].order) == 0) {\n\t\t\treturn validOrders[i].taskNum;\n\t\t}\n\t}\n\treturn -1;\n}\n#endif\n\n/*\n=================\nCG_ParseScores\n\n=================\n*/\nstatic void CG_ParseScores( void ) {\n\tint\t\ti, powerups;\n\n\tcg.numScores = atoi( CG_Argv( 1 ) );\n\tif ( cg.numScores > MAX_CLIENTS ) {\n\t\tcg.numScores = MAX_CLIENTS;\n\t}\n\n\tcg.teamScores[0] = atoi( CG_Argv( 2 ) );\n\tcg.teamScores[1] = atoi( CG_Argv( 3 ) );\n\n\tmemset( cg.scores, 0, sizeof( cg.scores ) );\n\tfor ( i = 0 ; i < cg.numScores ; i++ ) {\n\t\t//\n\t\tcg.scores[i].client = atoi( CG_Argv( i * 14 + 4 ) );\n\t\tcg.scores[i].score = atoi( CG_Argv( i * 14 + 5 ) );\n\t\tcg.scores[i].ping = atoi( CG_Argv( i * 14 + 6 ) );\n\t\tcg.scores[i].time = atoi( CG_Argv( i * 14 + 7 ) );\n\t\tcg.scores[i].scoreFlags = atoi( CG_Argv( i * 14 + 8 ) );\n\t\tpowerups = atoi( CG_Argv( i * 14 + 9 ) );\n\t\tcg.scores[i].accuracy = atoi(CG_Argv(i * 14 + 10));\n\t\tcg.scores[i].impressiveCount = atoi(CG_Argv(i * 14 + 11));\n\t\tcg.scores[i].excellentCount = atoi(CG_Argv(i * 14 + 12));\n\t\tcg.scores[i].guantletCount = atoi(CG_Argv(i * 14 + 13));\n\t\tcg.scores[i].defendCount = atoi(CG_Argv(i * 14 + 14));\n\t\tcg.scores[i].assistCount = atoi(CG_Argv(i * 14 + 15));\n\t\tcg.scores[i].perfect = atoi(CG_Argv(i * 14 + 16));\n\t\tcg.scores[i].captures = atoi(CG_Argv(i * 14 + 17));\n\n\t\tif ( cg.scores[i].client < 0 || cg.scores[i].client >= MAX_CLIENTS ) {\n\t\t\tcg.scores[i].client = 0;\n\t\t}\n\t\tcgs.clientinfo[ cg.scores[i].client ].score = cg.scores[i].score;\n\t\tcgs.clientinfo[ cg.scores[i].client ].powerups = powerups;\n\n\t\tcg.scores[i].team = cgs.clientinfo[cg.scores[i].client].team;\n\t}\n#ifdef MISSIONPACK\n\tCG_SetScoreSelection(NULL);\n#endif\n\n}\n\n/*\n=================\nCG_ParseTeamInfo\n\n=================\n*/\nstatic void CG_ParseTeamInfo( void ) {\n\tint\t\ti;\n\tint\t\tclient;\n\n\tnumSortedTeamPlayers = atoi( CG_Argv( 1 ) );\n\n\tfor ( i = 0 ; i < numSortedTeamPlayers ; i++ ) {\n\t\tclient = atoi( CG_Argv( i * 6 + 2 ) );\n\n\t\tsortedTeamPlayers[i] = client;\n\n\t\tcgs.clientinfo[ client ].location = atoi( CG_Argv( i * 6 + 3 ) );\n\t\tcgs.clientinfo[ client ].health = atoi( CG_Argv( i * 6 + 4 ) );\n\t\tcgs.clientinfo[ client ].armor = atoi( CG_Argv( i * 6 + 5 ) );\n\t\tcgs.clientinfo[ client ].curWeapon = atoi( CG_Argv( i * 6 + 6 ) );\n\t\tcgs.clientinfo[ client ].powerups = atoi( CG_Argv( i * 6 + 7 ) );\n\t}\n}\n\n\n/*\n================\nCG_ParseServerinfo\n\nThis is called explicitly when the gamestate is first received,\nand whenever the server updates any serverinfo flagged cvars\n================\n*/\nvoid CG_ParseServerinfo( void ) {\n\tconst char\t*info;\n\tchar\t*mapname;\n\n\tinfo = CG_ConfigString( CS_SERVERINFO );\n\tcgs.gametype = atoi( Info_ValueForKey( info, \"g_gametype\" ) );\n\ttrap_Cvar_Set(\"g_gametype\", va(\"%i\", cgs.gametype));\n\tcgs.dmflags = atoi( Info_ValueForKey( info, \"dmflags\" ) );\n\tcgs.teamflags = atoi( Info_ValueForKey( info, \"teamflags\" ) );\n\tcgs.fraglimit = atoi( Info_ValueForKey( info, \"fraglimit\" ) );\n\tcgs.capturelimit = atoi( Info_ValueForKey( info, \"capturelimit\" ) );\n\tcgs.timelimit = atoi( Info_ValueForKey( info, \"timelimit\" ) );\n\tcgs.maxclients = atoi( Info_ValueForKey( info, \"sv_maxclients\" ) );\n\tmapname = Info_ValueForKey( info, \"mapname\" );\n\tCom_sprintf( cgs.mapname, sizeof( cgs.mapname ), \"maps/%s.bsp\", mapname );\n\tQ_strncpyz( cgs.redTeam, Info_ValueForKey( info, \"g_redTeam\" ), sizeof(cgs.redTeam) );\n\ttrap_Cvar_Set(\"g_redTeam\", cgs.redTeam);\n\tQ_strncpyz( cgs.blueTeam, Info_ValueForKey( info, \"g_blueTeam\" ), sizeof(cgs.blueTeam) );\n\ttrap_Cvar_Set(\"g_blueTeam\", cgs.blueTeam);\n}\n\n/*\n==================\nCG_ParseWarmup\n==================\n*/\nstatic void CG_ParseWarmup( void ) {\n\tconst char\t*info;\n\tint\t\t\twarmup;\n\n\tinfo = CG_ConfigString( CS_WARMUP );\n\n\twarmup = atoi( info );\n\tcg.warmupCount = -1;\n\n\tif ( warmup == 0 && cg.warmup ) {\n\n\t} else if ( warmup > 0 && cg.warmup <= 0 ) {\n#ifdef MISSIONPACK\n\t\tif (cgs.gametype >= GT_CTF && cgs.gametype <= GT_HARVESTER) {\n\t\t\ttrap_S_StartLocalSound( cgs.media.countPrepareTeamSound, CHAN_ANNOUNCER );\n\t\t} else\n#endif\n\t\t{\n\t\t\ttrap_S_StartLocalSound( cgs.media.countPrepareSound, CHAN_ANNOUNCER );\n\t\t}\n\t}\n\n\tcg.warmup = warmup;\n}\n\n/*\n================\nCG_SetConfigValues\n\nCalled on load to set the initial values from configure strings\n================\n*/\nvoid CG_SetConfigValues( void ) {\n\tconst char *s;\n\n\tcgs.scores1 = atoi( CG_ConfigString( CS_SCORES1 ) );\n\tcgs.scores2 = atoi( CG_ConfigString( CS_SCORES2 ) );\n\tcgs.levelStartTime = atoi( CG_ConfigString( CS_LEVEL_START_TIME ) );\n\tif( cgs.gametype == GT_CTF ) {\n\t\ts = CG_ConfigString( CS_FLAGSTATUS );\n\t\tcgs.redflag = s[0] - '0';\n\t\tcgs.blueflag = s[1] - '0';\n\t}\n#ifdef MISSIONPACK\n\telse if( cgs.gametype == GT_1FCTF ) {\n\t\ts = CG_ConfigString( CS_FLAGSTATUS );\n\t\tcgs.flagStatus = s[0] - '0';\n\t}\n#endif\n\tcg.warmup = atoi( CG_ConfigString( CS_WARMUP ) );\n}\n\n/*\n=====================\nCG_ShaderStateChanged\n=====================\n*/\nvoid CG_ShaderStateChanged(void) {\n\tchar originalShader[MAX_QPATH];\n\tchar newShader[MAX_QPATH];\n\tchar timeOffset[16];\n\tconst char *o;\n\tchar *n,*t;\n\n\to = CG_ConfigString( CS_SHADERSTATE );\n\twhile (o && *o) {\n\t\tn = strstr(o, \"=\");\n\t\tif (n && *n) {\n\t\t\tstrncpy(originalShader, o, n-o);\n\t\t\toriginalShader[n-o] = 0;\n\t\t\tn++;\n\t\t\tt = strstr(n, \":\");\n\t\t\tif (t && *t) {\n\t\t\t\tstrncpy(newShader, n, t-n);\n\t\t\t\tnewShader[t-n] = 0;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tt++;\n\t\t\to = strstr(t, \"@\");\n\t\t\tif (o) {\n\t\t\t\tstrncpy(timeOffset, t, o-t);\n\t\t\t\ttimeOffset[o-t] = 0;\n\t\t\t\to++;\n\t\t\t\ttrap_R_RemapShader( originalShader, newShader, timeOffset );\n\t\t\t}\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/*\n================\nCG_ConfigStringModified\n\n================\n*/\nstatic void CG_ConfigStringModified( void ) {\n\tconst char\t*str;\n\tint\t\tnum;\n\n\tnum = atoi( CG_Argv( 1 ) );\n\n\t// get the gamestate from the client system, which will have the\n\t// new configstring already integrated\n\ttrap_GetGameState( &cgs.gameState );\n\n\t// look up the individual string that was modified\n\tstr = CG_ConfigString( num );\n\n\t// do something with it if necessary\n\tif ( num == CS_MUSIC ) {\n\t\tCG_StartMusic();\n\t} else if ( num == CS_SERVERINFO ) {\n\t\tCG_ParseServerinfo();\n\t} else if ( num == CS_WARMUP ) {\n\t\tCG_ParseWarmup();\n\t} else if ( num == CS_SCORES1 ) {\n\t\tcgs.scores1 = atoi( str );\n\t} else if ( num == CS_SCORES2 ) {\n\t\tcgs.scores2 = atoi( str );\n\t} else if ( num == CS_LEVEL_START_TIME ) {\n\t\tcgs.levelStartTime = atoi( str );\n\t} else if ( num == CS_VOTE_TIME ) {\n\t\tcgs.voteTime = atoi( str );\n\t\tcgs.voteModified = qtrue;\n\t} else if ( num == CS_VOTE_YES ) {\n\t\tcgs.voteYes = atoi( str );\n\t\tcgs.voteModified = qtrue;\n\t} else if ( num == CS_VOTE_NO ) {\n\t\tcgs.voteNo = atoi( str );\n\t\tcgs.voteModified = qtrue;\n\t} else if ( num == CS_VOTE_STRING ) {\n\t\tQ_strncpyz( cgs.voteString, str, sizeof( cgs.voteString ) );\n#ifdef MISSIONPACK\n\t\ttrap_S_StartLocalSound( cgs.media.voteNow, CHAN_ANNOUNCER );\n#endif //MISSIONPACK\n\t} else if ( num >= CS_TEAMVOTE_TIME && num <= CS_TEAMVOTE_TIME + 1) {\n\t\tcgs.teamVoteTime[num-CS_TEAMVOTE_TIME] = atoi( str );\n\t\tcgs.teamVoteModified[num-CS_TEAMVOTE_TIME] = qtrue;\n\t} else if ( num >= CS_TEAMVOTE_YES && num <= CS_TEAMVOTE_YES + 1) {\n\t\tcgs.teamVoteYes[num-CS_TEAMVOTE_YES] = atoi( str );\n\t\tcgs.teamVoteModified[num-CS_TEAMVOTE_YES] = qtrue;\n\t} else if ( num >= CS_TEAMVOTE_NO && num <= CS_TEAMVOTE_NO + 1) {\n\t\tcgs.teamVoteNo[num-CS_TEAMVOTE_NO] = atoi( str );\n\t\tcgs.teamVoteModified[num-CS_TEAMVOTE_NO] = qtrue;\n\t} else if ( num >= CS_TEAMVOTE_STRING && num <= CS_TEAMVOTE_STRING + 1) {\n\t\tQ_strncpyz( cgs.teamVoteString[num-CS_TEAMVOTE_STRING], str, sizeof( cgs.teamVoteString ) );\n#ifdef MISSIONPACK\n\t\ttrap_S_StartLocalSound( cgs.media.voteNow, CHAN_ANNOUNCER );\n#endif\n\t} else if ( num == CS_INTERMISSION ) {\n\t\tcg.intermissionStarted = atoi( str );\n\t} else if ( num >= CS_MODELS && num < CS_MODELS+MAX_MODELS ) {\n\t\tcgs.gameModels[ num-CS_MODELS ] = trap_R_RegisterModel( str );\n\t} else if ( num >= CS_SOUNDS && num < CS_SOUNDS+MAX_MODELS ) {\n\t\tif ( str[0] != '*' ) {\t// player specific sounds don't register here\n\t\t\tcgs.gameSounds[ num-CS_SOUNDS] = trap_S_RegisterSound( str, qfalse );\n\t\t}\n\t} else if ( num >= CS_PLAYERS && num < CS_PLAYERS+MAX_CLIENTS ) {\n\t\tCG_NewClientInfo( num - CS_PLAYERS );\n\t\tCG_BuildSpectatorString();\n\t} else if ( num == CS_FLAGSTATUS ) {\n\t\tif( cgs.gametype == GT_CTF ) {\n\t\t\t// format is rb where its red/blue, 0 is at base, 1 is taken, 2 is dropped\n\t\t\tcgs.redflag = str[0] - '0';\n\t\t\tcgs.blueflag = str[1] - '0';\n\t\t}\n#ifdef MISSIONPACK\n\t\telse if( cgs.gametype == GT_1FCTF ) {\n\t\t\tcgs.flagStatus = str[0] - '0';\n\t\t}\n#endif\n\t}\n\telse if ( num == CS_SHADERSTATE ) {\n\t\tCG_ShaderStateChanged();\n\t}\n\t\t\n}\n\n\n/*\n=======================\nCG_AddToTeamChat\n\n=======================\n*/\nstatic void CG_AddToTeamChat( const char *str ) {\n\tint len;\n\tchar *p, *ls;\n\tint lastcolor;\n\tint chatHeight;\n\n\tif (cg_teamChatHeight.integer < TEAMCHAT_HEIGHT) {\n\t\tchatHeight = cg_teamChatHeight.integer;\n\t} else {\n\t\tchatHeight = TEAMCHAT_HEIGHT;\n\t}\n\n\tif (chatHeight <= 0 || cg_teamChatTime.integer <= 0) {\n\t\t// team chat disabled, dump into normal chat\n\t\tcgs.teamChatPos = cgs.teamLastChatPos = 0;\n\t\treturn;\n\t}\n\n\tlen = 0;\n\n\tp = cgs.teamChatMsgs[cgs.teamChatPos % chatHeight];\n\t*p = 0;\n\n\tlastcolor = '7';\n\n\tls = NULL;\n\twhile (*str) {\n\t\tif (len > TEAMCHAT_WIDTH - 1) {\n\t\t\tif (ls) {\n\t\t\t\tstr -= (p - ls);\n\t\t\t\tstr++;\n\t\t\t\tp -= (p - ls);\n\t\t\t}\n\t\t\t*p = 0;\n\n\t\t\tcgs.teamChatMsgTimes[cgs.teamChatPos % chatHeight] = cg.time;\n\n\t\t\tcgs.teamChatPos++;\n\t\t\tp = cgs.teamChatMsgs[cgs.teamChatPos % chatHeight];\n\t\t\t*p = 0;\n\t\t\t*p++ = Q_COLOR_ESCAPE;\n\t\t\t*p++ = lastcolor;\n\t\t\tlen = 0;\n\t\t\tls = NULL;\n\t\t}\n\n\t\tif ( Q_IsColorString( str ) ) {\n\t\t\t*p++ = *str++;\n\t\t\tlastcolor = *str;\n\t\t\t*p++ = *str++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (*str == ' ') {\n\t\t\tls = p;\n\t\t}\n\t\t*p++ = *str++;\n\t\tlen++;\n\t}\n\t*p = 0;\n\n\tcgs.teamChatMsgTimes[cgs.teamChatPos % chatHeight] = cg.time;\n\tcgs.teamChatPos++;\n\n\tif (cgs.teamChatPos - cgs.teamLastChatPos > chatHeight)\n\t\tcgs.teamLastChatPos = cgs.teamChatPos - chatHeight;\n}\n\n/*\n===============\nCG_MapRestart\n\nThe server has issued a map_restart, so the next snapshot\nis completely new and should not be interpolated to.\n\nA tournement restart will clear everything, but doesn't\nrequire a reload of all the media\n===============\n*/\nstatic void CG_MapRestart( void ) {\n\tif ( cg_showmiss.integer ) {\n\t\tCG_Printf( \"CG_MapRestart\\n\" );\n\t}\n\n\tCG_InitLocalEntities();\n\tCG_InitMarkPolys();\n\tCG_ClearParticles ();\n\n\t// make sure the \"3 frags left\" warnings play again\n\tcg.fraglimitWarnings = 0;\n\n\tcg.timelimitWarnings = 0;\n\n\tcg.intermissionStarted = qfalse;\n\n\tcgs.voteTime = 0;\n\n\tcg.mapRestart = qtrue;\n\n\tCG_StartMusic();\n\n\ttrap_S_ClearLoopingSounds(qtrue);\n\n\t// we really should clear more parts of cg here and stop sounds\n\n\t// play the \"fight\" sound if this is a restart without warmup\n\tif ( cg.warmup == 0 /* && cgs.gametype == GT_TOURNAMENT */) {\n\t\ttrap_S_StartLocalSound( cgs.media.countFightSound, CHAN_ANNOUNCER );\n\t\tCG_CenterPrint( \"FIGHT!\", 120, GIANTCHAR_WIDTH*2 );\n\t}\n#ifdef MISSIONPACK\n\tif (cg_singlePlayerActive.integer) {\n\t\ttrap_Cvar_Set(\"ui_matchStartTime\", va(\"%i\", cg.time));\n\t\tif (cg_recordSPDemo.integer && cg_recordSPDemoName.string && *cg_recordSPDemoName.string) {\n\t\t\ttrap_SendConsoleCommand(va(\"set g_synchronousclients 1 ; record %s \\n\", cg_recordSPDemoName.string));\n\t\t}\n\t}\n#endif\n\ttrap_Cvar_Set(\"cg_thirdPerson\", \"0\");\n}\n\n#define MAX_VOICEFILESIZE\t16384\n#define MAX_VOICEFILES\t\t8\n#define MAX_VOICECHATS\t\t64\n#define MAX_VOICESOUNDS\t\t64\n#define MAX_CHATSIZE\t\t64\n#define MAX_HEADMODELS\t\t64\n\ntypedef struct voiceChat_s\n{\n\tchar id[64];\n\tint numSounds;\n\tsfxHandle_t sounds[MAX_VOICESOUNDS];\n\tchar chats[MAX_VOICESOUNDS][MAX_CHATSIZE];\n} voiceChat_t;\n\ntypedef struct voiceChatList_s\n{\n\tchar name[64];\n\tint gender;\n\tint numVoiceChats;\n\tvoiceChat_t voiceChats[MAX_VOICECHATS];\n} voiceChatList_t;\n\ntypedef struct headModelVoiceChat_s\n{\n\tchar headmodel[64];\n\tint voiceChatNum;\n} headModelVoiceChat_t;\n\nvoiceChatList_t voiceChatLists[MAX_VOICEFILES];\nheadModelVoiceChat_t headModelVoiceChat[MAX_HEADMODELS];\n\n/*\n=================\nCG_ParseVoiceChats\n=================\n*/\nint CG_ParseVoiceChats( const char *filename, voiceChatList_t *voiceChatList, int maxVoiceChats ) {\n\tint\tlen, i;\n\tfileHandle_t f;\n\tchar buf[MAX_VOICEFILESIZE];\n\tchar **p, *ptr;\n\tchar *token;\n\tvoiceChat_t *voiceChats;\n\tqboolean compress;\n\tsfxHandle_t sound;\n\n\tcompress = qtrue;\n\tif (cg_buildScript.integer) {\n\t\tcompress = qfalse;\n\t}\n\n\tlen = trap_FS_FOpenFile( filename, &f, FS_READ );\n\tif ( !f ) {\n\t\ttrap_Print( va( S_COLOR_RED \"voice chat file not found: %s\\n\", filename ) );\n\t\treturn qfalse;\n\t}\n\tif ( len >= MAX_VOICEFILESIZE ) {\n\t\ttrap_Print( va( S_COLOR_RED \"voice chat file too large: %s is %i, max allowed is %i\", filename, len, MAX_VOICEFILESIZE ) );\n\t\ttrap_FS_FCloseFile( f );\n\t\treturn qfalse;\n\t}\n\n\ttrap_FS_Read( buf, len, f );\n\tbuf[len] = 0;\n\ttrap_FS_FCloseFile( f );\n\n\tptr = buf;\n\tp = &ptr;\n\n\tCom_sprintf(voiceChatList->name, sizeof(voiceChatList->name), \"%s\", filename);\n\tvoiceChats = voiceChatList->voiceChats;\n\tfor ( i = 0; i < maxVoiceChats; i++ ) {\n\t\tvoiceChats[i].id[0] = 0;\n\t}\n\ttoken = COM_ParseExt(p, qtrue);\n\tif (!token || token[0] == 0) {\n\t\treturn qtrue;\n\t}\n\tif (!Q_stricmp(token, \"female\")) {\n\t\tvoiceChatList->gender = GENDER_FEMALE;\n\t}\n\telse if (!Q_stricmp(token, \"male\")) {\n\t\tvoiceChatList->gender = GENDER_MALE;\n\t}\n\telse if (!Q_stricmp(token, \"neuter\")) {\n\t\tvoiceChatList->gender = GENDER_NEUTER;\n\t}\n\telse {\n\t\ttrap_Print( va( S_COLOR_RED \"expected gender not found in voice chat file: %s\\n\", filename ) );\n\t\treturn qfalse;\n\t}\n\n\tvoiceChatList->numVoiceChats = 0;\n\twhile ( 1 ) {\n\t\ttoken = COM_ParseExt(p, qtrue);\n\t\tif (!token || token[0] == 0) {\n\t\t\treturn qtrue;\n\t\t}\n\t\tCom_sprintf(voiceChats[voiceChatList->numVoiceChats].id, sizeof( voiceChats[voiceChatList->numVoiceChats].id ), \"%s\", token);\n\t\ttoken = COM_ParseExt(p, qtrue);\n\t\tif (Q_stricmp(token, \"{\")) {\n\t\t\ttrap_Print( va( S_COLOR_RED \"expected { found %s in voice chat file: %s\\n\", token, filename ) );\n\t\t\treturn qfalse;\n\t\t}\n\t\tvoiceChats[voiceChatList->numVoiceChats].numSounds = 0;\n\t\twhile(1) {\n\t\t\ttoken = COM_ParseExt(p, qtrue);\n\t\t\tif (!token || token[0] == 0) {\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t\tif (!Q_stricmp(token, \"}\"))\n\t\t\t\tbreak;\n\t\t\tsound = trap_S_RegisterSound( token, compress );\n\t\t\tvoiceChats[voiceChatList->numVoiceChats].sounds[voiceChats[voiceChatList->numVoiceChats].numSounds] = sound;\n\t\t\ttoken = COM_ParseExt(p, qtrue);\n\t\t\tif (!token || token[0] == 0) {\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t\tCom_sprintf(voiceChats[voiceChatList->numVoiceChats].chats[\n\t\t\t\t\t\t\tvoiceChats[voiceChatList->numVoiceChats].numSounds], MAX_CHATSIZE, \"%s\", token);\n\t\t\tif (sound)\n\t\t\t\tvoiceChats[voiceChatList->numVoiceChats].numSounds++;\n\t\t\tif (voiceChats[voiceChatList->numVoiceChats].numSounds >= MAX_VOICESOUNDS)\n\t\t\t\tbreak;\n\t\t}\n\t\tvoiceChatList->numVoiceChats++;\n\t\tif (voiceChatList->numVoiceChats >= maxVoiceChats)\n\t\t\treturn qtrue;\n\t}\n\treturn qtrue;\n}\n\n/*\n=================\nCG_LoadVoiceChats\n=================\n*/\nvoid CG_LoadVoiceChats( void ) {\n\tint size;\n\n\tsize = trap_MemoryRemaining();\n\tCG_ParseVoiceChats( \"scripts/female1.voice\", &voiceChatLists[0], MAX_VOICECHATS );\n\tCG_ParseVoiceChats( \"scripts/female2.voice\", &voiceChatLists[1], MAX_VOICECHATS );\n\tCG_ParseVoiceChats( \"scripts/female3.voice\", &voiceChatLists[2], MAX_VOICECHATS );\n\tCG_ParseVoiceChats( \"scripts/male1.voice\", &voiceChatLists[3], MAX_VOICECHATS );\n\tCG_ParseVoiceChats( \"scripts/male2.voice\", &voiceChatLists[4], MAX_VOICECHATS );\n\tCG_ParseVoiceChats( \"scripts/male3.voice\", &voiceChatLists[5], MAX_VOICECHATS );\n\tCG_ParseVoiceChats( \"scripts/male4.voice\", &voiceChatLists[6], MAX_VOICECHATS );\n\tCG_ParseVoiceChats( \"scripts/male5.voice\", &voiceChatLists[7], MAX_VOICECHATS );\n\tCG_Printf(\"voice chat memory size = %d\\n\", size - trap_MemoryRemaining());\n}\n\n/*\n=================\nCG_HeadModelVoiceChats\n=================\n*/\nint CG_HeadModelVoiceChats( char *filename ) {\n\tint\tlen, i;\n\tfileHandle_t f;\n\tchar buf[MAX_VOICEFILESIZE];\n\tchar **p, *ptr;\n\tchar *token;\n\n\tlen = trap_FS_FOpenFile( filename, &f, FS_READ );\n\tif ( !f ) {\n\t\t//trap_Print( va( \"voice chat file not found: %s\\n\", filename ) );\n\t\treturn -1;\n\t}\n\tif ( len >= MAX_VOICEFILESIZE ) {\n\t\ttrap_Print( va( S_COLOR_RED \"voice chat file too large: %s is %i, max allowed is %i\", filename, len, MAX_VOICEFILESIZE ) );\n\t\ttrap_FS_FCloseFile( f );\n\t\treturn -1;\n\t}\n\n\ttrap_FS_Read( buf, len, f );\n\tbuf[len] = 0;\n\ttrap_FS_FCloseFile( f );\n\n\tptr = buf;\n\tp = &ptr;\n\n\ttoken = COM_ParseExt(p, qtrue);\n\tif (!token || token[0] == 0) {\n\t\treturn -1;\n\t}\n\n\tfor ( i = 0; i < MAX_VOICEFILES; i++ ) {\n\t\tif ( !Q_stricmp(token, voiceChatLists[i].name) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\n\t//FIXME: maybe try to load the .voice file which name is stored in token?\n\n\treturn -1;\n}\n\n\n/*\n=================\nCG_GetVoiceChat\n=================\n*/\nint CG_GetVoiceChat( voiceChatList_t *voiceChatList, const char *id, sfxHandle_t *snd, char **chat) {\n\tint i, rnd;\n\n\tfor ( i = 0; i < voiceChatList->numVoiceChats; i++ ) {\n\t\tif ( !Q_stricmp( id, voiceChatList->voiceChats[i].id ) ) {\n\t\t\trnd = random() * voiceChatList->voiceChats[i].numSounds;\n\t\t\t*snd = voiceChatList->voiceChats[i].sounds[rnd];\n\t\t\t*chat = voiceChatList->voiceChats[i].chats[rnd];\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n/*\n=================\nCG_VoiceChatListForClient\n=================\n*/\nvoiceChatList_t *CG_VoiceChatListForClient( int clientNum ) {\n\tclientInfo_t *ci;\n\tint voiceChatNum, i, j, k, gender;\n\tchar filename[MAX_QPATH], headModelName[MAX_QPATH];\n\n\tif ( clientNum < 0 || clientNum >= MAX_CLIENTS ) {\n\t\tclientNum = 0;\n\t}\n\tci = &cgs.clientinfo[ clientNum ];\n\n\tfor ( k = 0; k < 2; k++ ) {\n\t\tif ( k == 0 ) {\n\t\t\tif (ci->headModelName[0] == '*') {\n\t\t\t\tCom_sprintf( headModelName, sizeof(headModelName), \"%s/%s\", ci->headModelName+1, ci->headSkinName );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tCom_sprintf( headModelName, sizeof(headModelName), \"%s/%s\", ci->headModelName, ci->headSkinName );\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif (ci->headModelName[0] == '*') {\n\t\t\t\tCom_sprintf( headModelName, sizeof(headModelName), \"%s\", ci->headModelName+1 );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tCom_sprintf( headModelName, sizeof(headModelName), \"%s\", ci->headModelName );\n\t\t\t}\n\t\t}\n\t\t// find the voice file for the head model the client uses\n\t\tfor ( i = 0; i < MAX_HEADMODELS; i++ ) {\n\t\t\tif (!Q_stricmp(headModelVoiceChat[i].headmodel, headModelName)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (i < MAX_HEADMODELS) {\n\t\t\treturn &voiceChatLists[headModelVoiceChat[i].voiceChatNum];\n\t\t}\n\t\t// find a <headmodelname>.vc file\n\t\tfor ( i = 0; i < MAX_HEADMODELS; i++ ) {\n\t\t\tif (!strlen(headModelVoiceChat[i].headmodel)) {\n\t\t\t\tCom_sprintf(filename, sizeof(filename), \"scripts/%s.vc\", headModelName);\n\t\t\t\tvoiceChatNum = CG_HeadModelVoiceChats(filename);\n\t\t\t\tif (voiceChatNum == -1)\n\t\t\t\t\tbreak;\n\t\t\t\tCom_sprintf(headModelVoiceChat[i].headmodel, sizeof ( headModelVoiceChat[i].headmodel ),\n\t\t\t\t\t\t\t\"%s\", headModelName);\n\t\t\t\theadModelVoiceChat[i].voiceChatNum = voiceChatNum;\n\t\t\t\treturn &voiceChatLists[headModelVoiceChat[i].voiceChatNum];\n\t\t\t}\n\t\t}\n\t}\n\tgender = ci->gender;\n\tfor (k = 0; k < 2; k++) {\n\t\t// just pick the first with the right gender\n\t\tfor ( i = 0; i < MAX_VOICEFILES; i++ ) {\n\t\t\tif (strlen(voiceChatLists[i].name)) {\n\t\t\t\tif (voiceChatLists[i].gender == gender) {\n\t\t\t\t\t// store this head model with voice chat for future reference\n\t\t\t\t\tfor ( j = 0; j < MAX_HEADMODELS; j++ ) {\n\t\t\t\t\t\tif (!strlen(headModelVoiceChat[j].headmodel)) {\n\t\t\t\t\t\t\tCom_sprintf(headModelVoiceChat[j].headmodel, sizeof ( headModelVoiceChat[j].headmodel ),\n\t\t\t\t\t\t\t\t\t\"%s\", headModelName);\n\t\t\t\t\t\t\theadModelVoiceChat[j].voiceChatNum = i;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn &voiceChatLists[i];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// fall back to male gender because we don't have neuter in the mission pack\n\t\tif (gender == GENDER_MALE)\n\t\t\tbreak;\n\t\tgender = GENDER_MALE;\n\t}\n\t// store this head model with voice chat for future reference\n\tfor ( j = 0; j < MAX_HEADMODELS; j++ ) {\n\t\tif (!strlen(headModelVoiceChat[j].headmodel)) {\n\t\t\tCom_sprintf(headModelVoiceChat[j].headmodel, sizeof ( headModelVoiceChat[j].headmodel ),\n\t\t\t\t\t\"%s\", headModelName);\n\t\t\theadModelVoiceChat[j].voiceChatNum = 0;\n\t\t\tbreak;\n\t\t}\n\t}\n\t// just return the first voice chat list\n\treturn &voiceChatLists[0];\n}\n\n#define MAX_VOICECHATBUFFER\t\t32\n\ntypedef struct bufferedVoiceChat_s\n{\n\tint clientNum;\n\tsfxHandle_t snd;\n\tint voiceOnly;\n\tchar cmd[MAX_SAY_TEXT];\n\tchar message[MAX_SAY_TEXT];\n} bufferedVoiceChat_t;\n\nbufferedVoiceChat_t voiceChatBuffer[MAX_VOICECHATBUFFER];\n\n/*\n=================\nCG_PlayVoiceChat\n=================\n*/\nvoid CG_PlayVoiceChat( bufferedVoiceChat_t *vchat ) {\n#ifdef MISSIONPACK\n\t// if we are going into the intermission, don't start any voices\n\tif ( cg.intermissionStarted ) {\n\t\treturn;\n\t}\n\n\tif ( !cg_noVoiceChats.integer ) {\n\t\ttrap_S_StartLocalSound( vchat->snd, CHAN_VOICE);\n\t\tif (vchat->clientNum != cg.snap->ps.clientNum) {\n\t\t\tint orderTask = CG_ValidOrder(vchat->cmd);\n\t\t\tif (orderTask > 0) {\n\t\t\t\tcgs.acceptOrderTime = cg.time + 5000;\n\t\t\t\tQ_strncpyz(cgs.acceptVoice, vchat->cmd, sizeof(cgs.acceptVoice));\n\t\t\t\tcgs.acceptTask = orderTask;\n\t\t\t\tcgs.acceptLeader = vchat->clientNum;\n\t\t\t}\n\t\t\t// see if this was an order\n\t\t\tCG_ShowResponseHead();\n\t\t}\n\t}\n\tif (!vchat->voiceOnly && !cg_noVoiceText.integer) {\n\t\tCG_AddToTeamChat( vchat->message );\n\t\tCG_Printf( \"%s\\n\", vchat->message );\n\t}\n\tvoiceChatBuffer[cg.voiceChatBufferOut].snd = 0;\n#endif\n}\n\n/*\n=====================\nCG_PlayBufferedVoieChats\n=====================\n*/\nvoid CG_PlayBufferedVoiceChats( void ) {\n#ifdef MISSIONPACK\n\tif ( cg.voiceChatTime < cg.time ) {\n\t\tif (cg.voiceChatBufferOut != cg.voiceChatBufferIn && voiceChatBuffer[cg.voiceChatBufferOut].snd) {\n\t\t\t//\n\t\t\tCG_PlayVoiceChat(&voiceChatBuffer[cg.voiceChatBufferOut]);\n\t\t\t//\n\t\t\tcg.voiceChatBufferOut = (cg.voiceChatBufferOut + 1) % MAX_VOICECHATBUFFER;\n\t\t\tcg.voiceChatTime = cg.time + 1000;\n\t\t}\n\t}\n#endif\n}\n\n/*\n=====================\nCG_AddBufferedVoiceChat\n=====================\n*/\nvoid CG_AddBufferedVoiceChat( bufferedVoiceChat_t *vchat ) {\n#ifdef MISSIONPACK\n\t// if we are going into the intermission, don't start any voices\n\tif ( cg.intermissionStarted ) {\n\t\treturn;\n\t}\n\n\tmemcpy(&voiceChatBuffer[cg.voiceChatBufferIn], vchat, sizeof(bufferedVoiceChat_t));\n\tcg.voiceChatBufferIn = (cg.voiceChatBufferIn + 1) % MAX_VOICECHATBUFFER;\n\tif (cg.voiceChatBufferIn == cg.voiceChatBufferOut) {\n\t\tCG_PlayVoiceChat( &voiceChatBuffer[cg.voiceChatBufferOut] );\n\t\tcg.voiceChatBufferOut++;\n\t}\n#endif\n}\n\n/*\n=================\nCG_VoiceChatLocal\n=================\n*/\nvoid CG_VoiceChatLocal( int mode, qboolean voiceOnly, int clientNum, int color, const char *cmd ) {\n#ifdef MISSIONPACK\n\tchar *chat;\n\tvoiceChatList_t *voiceChatList;\n\tclientInfo_t *ci;\n\tsfxHandle_t snd;\n\tbufferedVoiceChat_t vchat;\n\n\t// if we are going into the intermission, don't start any voices\n\tif ( cg.intermissionStarted ) {\n\t\treturn;\n\t}\n\n\tif ( clientNum < 0 || clientNum >= MAX_CLIENTS ) {\n\t\tclientNum = 0;\n\t}\n\tci = &cgs.clientinfo[ clientNum ];\n\n\tcgs.currentVoiceClient = clientNum;\n\n\tvoiceChatList = CG_VoiceChatListForClient( clientNum );\n\n\tif ( CG_GetVoiceChat( voiceChatList, cmd, &snd, &chat ) ) {\n\t\t//\n\t\tif ( mode == SAY_TEAM || !cg_teamChatsOnly.integer ) {\n\t\t\tvchat.clientNum = clientNum;\n\t\t\tvchat.snd = snd;\n\t\t\tvchat.voiceOnly = voiceOnly;\n\t\t\tQ_strncpyz(vchat.cmd, cmd, sizeof(vchat.cmd));\n\t\t\tif ( mode == SAY_TELL ) {\n\t\t\t\tCom_sprintf(vchat.message, sizeof(vchat.message), \"[%s]: %c%c%s\", ci->name, Q_COLOR_ESCAPE, color, chat);\n\t\t\t}\n\t\t\telse if ( mode == SAY_TEAM ) {\n\t\t\t\tCom_sprintf(vchat.message, sizeof(vchat.message), \"(%s): %c%c%s\", ci->name, Q_COLOR_ESCAPE, color, chat);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tCom_sprintf(vchat.message, sizeof(vchat.message), \"%s: %c%c%s\", ci->name, Q_COLOR_ESCAPE, color, chat);\n\t\t\t}\n\t\t\tCG_AddBufferedVoiceChat(&vchat);\n\t\t}\n\t}\n#endif\n}\n\n/*\n=================\nCG_VoiceChat\n=================\n*/\nvoid CG_VoiceChat( int mode ) {\n#ifdef MISSIONPACK\n\tconst char *cmd;\n\tint clientNum, color;\n\tqboolean voiceOnly;\n\n\tvoiceOnly = atoi(CG_Argv(1));\n\tclientNum = atoi(CG_Argv(2));\n\tcolor = atoi(CG_Argv(3));\n\tcmd = CG_Argv(4);\n\n\tif (cg_noTaunt.integer != 0) {\n\t\tif (!strcmp(cmd, VOICECHAT_KILLINSULT)  || !strcmp(cmd, VOICECHAT_TAUNT) || \\\n\t\t\t!strcmp(cmd, VOICECHAT_DEATHINSULT) || !strcmp(cmd, VOICECHAT_KILLGAUNTLET) || \\\n\t\t\t!strcmp(cmd, VOICECHAT_PRAISE)) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\tCG_VoiceChatLocal( mode, voiceOnly, clientNum, color, cmd );\n#endif\n}\n\n/*\n=================\nCG_RemoveChatEscapeChar\n=================\n*/\nstatic void CG_RemoveChatEscapeChar( char *text ) {\n\tint i, l;\n\n\tl = 0;\n\tfor ( i = 0; text[i]; i++ ) {\n\t\tif (text[i] == '\\x19')\n\t\t\tcontinue;\n\t\ttext[l++] = text[i];\n\t}\n\ttext[l] = '\\0';\n}\n\n/*\n=================\nCG_ServerCommand\n\nThe string has been tokenized and can be retrieved with\nCmd_Argc() / Cmd_Argv()\n=================\n*/\nstatic void CG_ServerCommand( void ) {\n\tconst char\t*cmd;\n\tchar\t\ttext[MAX_SAY_TEXT];\n\n\tcmd = CG_Argv(0);\n\n\tif ( !cmd[0] ) {\n\t\t// server claimed the command\n\t\treturn;\n\t}\n\n\tif ( !strcmp( cmd, \"cp\" ) ) {\n\t\tCG_CenterPrint( CG_Argv(1), SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH );\n\t\treturn;\n\t}\n\n\tif ( !strcmp( cmd, \"cs\" ) ) {\n\t\tCG_ConfigStringModified();\n\t\treturn;\n\t}\n\n\tif ( !strcmp( cmd, \"print\" ) ) {\n\t\tCG_Printf( \"%s\", CG_Argv(1) );\n#ifdef MISSIONPACK\n\t\tcmd = CG_Argv(1);\t\t\t// yes, this is obviously a hack, but so is the way we hear about\n\t\t\t\t\t\t\t\t\t// votes passing or failing\n\t\tif ( !Q_stricmpn( cmd, \"vote failed\", 11 ) || !Q_stricmpn( cmd, \"team vote failed\", 16 )) {\n\t\t\ttrap_S_StartLocalSound( cgs.media.voteFailed, CHAN_ANNOUNCER );\n\t\t} else if ( !Q_stricmpn( cmd, \"vote passed\", 11 ) || !Q_stricmpn( cmd, \"team vote passed\", 16 ) ) {\n\t\t\ttrap_S_StartLocalSound( cgs.media.votePassed, CHAN_ANNOUNCER );\n\t\t}\n#endif\n\t\treturn;\n\t}\n\n\tif ( !strcmp( cmd, \"chat\" ) ) {\n\t\tif ( !cg_teamChatsOnly.integer ) {\n\t\t\ttrap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND );\n\t\t\tQ_strncpyz( text, CG_Argv(1), MAX_SAY_TEXT );\n\t\t\tCG_RemoveChatEscapeChar( text );\n\t\t\tCG_Printf( \"%s\\n\", text );\n\t\t}\n\t\treturn;\n\t}\n\n\tif ( !strcmp( cmd, \"tchat\" ) ) {\n\t\ttrap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND );\n\t\tQ_strncpyz( text, CG_Argv(1), MAX_SAY_TEXT );\n\t\tCG_RemoveChatEscapeChar( text );\n\t\tCG_AddToTeamChat( text );\n\t\tCG_Printf( \"%s\\n\", text );\n\t\treturn;\n\t}\n\tif ( !strcmp( cmd, \"vchat\" ) ) {\n\t\tCG_VoiceChat( SAY_ALL );\n\t\treturn;\n\t}\n\n\tif ( !strcmp( cmd, \"vtchat\" ) ) {\n\t\tCG_VoiceChat( SAY_TEAM );\n\t\treturn;\n\t}\n\n\tif ( !strcmp( cmd, \"vtell\" ) ) {\n\t\tCG_VoiceChat( SAY_TELL );\n\t\treturn;\n\t}\n\n\tif ( !strcmp( cmd, \"scores\" ) ) {\n\t\tCG_ParseScores();\n\t\treturn;\n\t}\n\n\tif ( !strcmp( cmd, \"tinfo\" ) ) {\n\t\tCG_ParseTeamInfo();\n\t\treturn;\n\t}\n\n\tif ( !strcmp( cmd, \"map_restart\" ) ) {\n\t\tCG_MapRestart();\n\t\treturn;\n\t}\n\n  if ( Q_stricmp (cmd, \"remapShader\") == 0 ) {\n\t\tif (trap_Argc() == 4) {\n\t\t\ttrap_R_RemapShader(CG_Argv(1), CG_Argv(2), CG_Argv(3));\n\t\t}\n\t}\n\n\t// loaddeferred can be both a servercmd and a consolecmd\n\tif ( !strcmp( cmd, \"loaddefered\" ) ) {\t// FIXME: spelled wrong, but not changing for demo\n\t\tCG_LoadDeferredPlayers();\n\t\treturn;\n\t}\n\n\t// clientLevelShot is sent before taking a special screenshot for\n\t// the menu system during development\n\tif ( !strcmp( cmd, \"clientLevelShot\" ) ) {\n\t\tcg.levelShot = qtrue;\n\t\treturn;\n\t}\n\n\tCG_Printf( \"Unknown client game command: %s\\n\", cmd );\n}\n\n\n/*\n====================\nCG_ExecuteNewServerCommands\n\nExecute all of the server commands that were received along\nwith this this snapshot.\n====================\n*/\nvoid CG_ExecuteNewServerCommands( int latestSequence ) {\n\twhile ( cgs.serverCommandSequence < latestSequence ) {\n\t\tif ( trap_GetServerCommand( ++cgs.serverCommandSequence ) ) {\n\t\t\tCG_ServerCommand();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "code/cgame/cg_snapshot.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// cg_snapshot.c -- things that happen on snapshot transition,\n// not necessarily every single rendered frame\n\n#include \"cg_local.h\"\n\n\n\n/*\n==================\nCG_ResetEntity\n==================\n*/\nstatic void CG_ResetEntity( centity_t *cent ) {\n\t// if the previous snapshot this entity was updated in is at least\n\t// an event window back in time then we can reset the previous event\n\tif ( cent->snapShotTime < cg.time - EVENT_VALID_MSEC ) {\n\t\tcent->previousEvent = 0;\n\t}\n\n\tcent->trailTime = cg.snap->serverTime;\n\n\tVectorCopy (cent->currentState.origin, cent->lerpOrigin);\n\tVectorCopy (cent->currentState.angles, cent->lerpAngles);\n\tif ( cent->currentState.eType == ET_PLAYER ) {\n\t\tCG_ResetPlayerEntity( cent );\n\t}\n}\n\n/*\n===============\nCG_TransitionEntity\n\ncent->nextState is moved to cent->currentState and events are fired\n===============\n*/\nstatic void CG_TransitionEntity( centity_t *cent ) {\n\tcent->currentState = cent->nextState;\n\tcent->currentValid = qtrue;\n\n\t// reset if the entity wasn't in the last frame or was teleported\n\tif ( !cent->interpolate ) {\n\t\tCG_ResetEntity( cent );\n\t}\n\n\t// clear the next state.  if will be set by the next CG_SetNextSnap\n\tcent->interpolate = qfalse;\n\n\t// check for events\n\tCG_CheckEvents( cent );\n}\n\n\n/*\n==================\nCG_SetInitialSnapshot\n\nThis will only happen on the very first snapshot, or\non tourney restarts.  All other times will use \nCG_TransitionSnapshot instead.\n\nFIXME: Also called by map_restart?\n==================\n*/\nvoid CG_SetInitialSnapshot( snapshot_t *snap ) {\n\tint\t\t\t\ti;\n\tcentity_t\t\t*cent;\n\tentityState_t\t*state;\n\n\tcg.snap = snap;\n\n\tBG_PlayerStateToEntityState( &snap->ps, &cg_entities[ snap->ps.clientNum ].currentState, qfalse );\n\n\t// sort out solid entities\n\tCG_BuildSolidList();\n\n\tCG_ExecuteNewServerCommands( snap->serverCommandSequence );\n\n\t// set our local weapon selection pointer to\n\t// what the server has indicated the current weapon is\n\tCG_Respawn();\n\n\tfor ( i = 0 ; i < cg.snap->numEntities ; i++ ) {\n\t\tstate = &cg.snap->entities[ i ];\n\t\tcent = &cg_entities[ state->number ];\n\n\t\tmemcpy(&cent->currentState, state, sizeof(entityState_t));\n\t\t//cent->currentState = *state;\n\t\tcent->interpolate = qfalse;\n\t\tcent->currentValid = qtrue;\n\n\t\tCG_ResetEntity( cent );\n\n\t\t// check for events\n\t\tCG_CheckEvents( cent );\n\t}\n}\n\n\n/*\n===================\nCG_TransitionSnapshot\n\nThe transition point from snap to nextSnap has passed\n===================\n*/\nstatic void CG_TransitionSnapshot( void ) {\n\tcentity_t\t\t\t*cent;\n\tsnapshot_t\t\t\t*oldFrame;\n\tint\t\t\t\t\ti;\n\n\tif ( !cg.snap ) {\n\t\tCG_Error( \"CG_TransitionSnapshot: NULL cg.snap\" );\n\t}\n\tif ( !cg.nextSnap ) {\n\t\tCG_Error( \"CG_TransitionSnapshot: NULL cg.nextSnap\" );\n\t}\n\n\t// execute any server string commands before transitioning entities\n\tCG_ExecuteNewServerCommands( cg.nextSnap->serverCommandSequence );\n\n\t// if we had a map_restart, set everthing with initial\n\tif ( !cg.snap ) {\n\t}\n\n\t// clear the currentValid flag for all entities in the existing snapshot\n\tfor ( i = 0 ; i < cg.snap->numEntities ; i++ ) {\n\t\tcent = &cg_entities[ cg.snap->entities[ i ].number ];\n\t\tcent->currentValid = qfalse;\n\t}\n\n\t// move nextSnap to snap and do the transitions\n\toldFrame = cg.snap;\n\tcg.snap = cg.nextSnap;\n\n\tBG_PlayerStateToEntityState( &cg.snap->ps, &cg_entities[ cg.snap->ps.clientNum ].currentState, qfalse );\n\tcg_entities[ cg.snap->ps.clientNum ].interpolate = qfalse;\n\n\tfor ( i = 0 ; i < cg.snap->numEntities ; i++ ) {\n\t\tcent = &cg_entities[ cg.snap->entities[ i ].number ];\n\t\tCG_TransitionEntity( cent );\n\n\t\t// remember time of snapshot this entity was last updated in\n\t\tcent->snapShotTime = cg.snap->serverTime;\n\t}\n\n\tcg.nextSnap = NULL;\n\n\t// check for playerstate transition events\n\tif ( oldFrame ) {\n\t\tplayerState_t\t*ops, *ps;\n\n\t\tops = &oldFrame->ps;\n\t\tps = &cg.snap->ps;\n\t\t// teleporting checks are irrespective of prediction\n\t\tif ( ( ps->eFlags ^ ops->eFlags ) & EF_TELEPORT_BIT ) {\n\t\t\tcg.thisFrameTeleport = qtrue;\t// will be cleared by prediction code\n\t\t}\n\n\t\t// if we are not doing client side movement prediction for any\n\t\t// reason, then the client events and view changes will be issued now\n\t\tif ( cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_FOLLOW)\n\t\t\t|| cg_nopredict.integer || cg_synchronousClients.integer ) {\n\t\t\tCG_TransitionPlayerState( ps, ops );\n\t\t}\n\t}\n\n}\n\n\n/*\n===================\nCG_SetNextSnap\n\nA new snapshot has just been read in from the client system.\n===================\n*/\nstatic void CG_SetNextSnap( snapshot_t *snap ) {\n\tint\t\t\t\t\tnum;\n\tentityState_t\t\t*es;\n\tcentity_t\t\t\t*cent;\n\n\tcg.nextSnap = snap;\n\n\tBG_PlayerStateToEntityState( &snap->ps, &cg_entities[ snap->ps.clientNum ].nextState, qfalse );\n\tcg_entities[ cg.snap->ps.clientNum ].interpolate = qtrue;\n\n\t// check for extrapolation errors\n\tfor ( num = 0 ; num < snap->numEntities ; num++ ) {\n\t\tes = &snap->entities[num];\n\t\tcent = &cg_entities[ es->number ];\n\n\t\tmemcpy(&cent->nextState, es, sizeof(entityState_t));\n\t\t//cent->nextState = *es;\n\n\t\t// if this frame is a teleport, or the entity wasn't in the\n\t\t// previous frame, don't interpolate\n\t\tif ( !cent->currentValid || ( ( cent->currentState.eFlags ^ es->eFlags ) & EF_TELEPORT_BIT )  ) {\n\t\t\tcent->interpolate = qfalse;\n\t\t} else {\n\t\t\tcent->interpolate = qtrue;\n\t\t}\n\t}\n\n\t// if the next frame is a teleport for the playerstate, we\n\t// can't interpolate during demos\n\tif ( cg.snap && ( ( snap->ps.eFlags ^ cg.snap->ps.eFlags ) & EF_TELEPORT_BIT ) ) {\n\t\tcg.nextFrameTeleport = qtrue;\n\t} else {\n\t\tcg.nextFrameTeleport = qfalse;\n\t}\n\n\t// if changing follow mode, don't interpolate\n\tif ( cg.nextSnap->ps.clientNum != cg.snap->ps.clientNum ) {\n\t\tcg.nextFrameTeleport = qtrue;\n\t}\n\n\t// if changing server restarts, don't interpolate\n\tif ( ( cg.nextSnap->snapFlags ^ cg.snap->snapFlags ) & SNAPFLAG_SERVERCOUNT ) {\n\t\tcg.nextFrameTeleport = qtrue;\n\t}\n\n\t// sort out solid entities\n\tCG_BuildSolidList();\n}\n\n\n/*\n========================\nCG_ReadNextSnapshot\n\nThis is the only place new snapshots are requested\nThis may increment cgs.processedSnapshotNum multiple\ntimes if the client system fails to return a\nvalid snapshot.\n========================\n*/\nstatic snapshot_t *CG_ReadNextSnapshot( void ) {\n\tqboolean\tr;\n\tsnapshot_t\t*dest;\n\n\tif ( cg.latestSnapshotNum > cgs.processedSnapshotNum + 1000 ) {\n\t\tCG_Printf( \"WARNING: CG_ReadNextSnapshot: way out of range, %i > %i\", \n\t\t\tcg.latestSnapshotNum, cgs.processedSnapshotNum );\n\t}\n\n\twhile ( cgs.processedSnapshotNum < cg.latestSnapshotNum ) {\n\t\t// decide which of the two slots to load it into\n\t\tif ( cg.snap == &cg.activeSnapshots[0] ) {\n\t\t\tdest = &cg.activeSnapshots[1];\n\t\t} else {\n\t\t\tdest = &cg.activeSnapshots[0];\n\t\t}\n\n\t\t// try to read the snapshot from the client system\n\t\tcgs.processedSnapshotNum++;\n\t\tr = trap_GetSnapshot( cgs.processedSnapshotNum, dest );\n\n\t\t// FIXME: why would trap_GetSnapshot return a snapshot with the same server time\n\t\tif ( cg.snap && r && dest->serverTime == cg.snap->serverTime ) {\n\t\t\t//continue;\n\t\t}\n\n\t\t// if it succeeded, return\n\t\tif ( r ) {\n\t\t\tCG_AddLagometerSnapshotInfo( dest );\n\t\t\treturn dest;\n\t\t}\n\n\t\t// a GetSnapshot will return failure if the snapshot\n\t\t// never arrived, or  is so old that its entities\n\t\t// have been shoved off the end of the circular\n\t\t// buffer in the client system.\n\n\t\t// record as a dropped packet\n\t\tCG_AddLagometerSnapshotInfo( NULL );\n\n\t\t// If there are additional snapshots, continue trying to\n\t\t// read them.\n\t}\n\n\t// nothing left to read\n\treturn NULL;\n}\n\n\n/*\n============\nCG_ProcessSnapshots\n\nWe are trying to set up a renderable view, so determine\nwhat the simulated time is, and try to get snapshots\nboth before and after that time if available.\n\nIf we don't have a valid cg.snap after exiting this function,\nthen a 3D game view cannot be rendered.  This should only happen\nright after the initial connection.  After cg.snap has been valid\nonce, it will never turn invalid.\n\nEven if cg.snap is valid, cg.nextSnap may not be, if the snapshot\nhasn't arrived yet (it becomes an extrapolating situation instead\nof an interpolating one)\n\n============\n*/\nvoid CG_ProcessSnapshots( void ) {\n\tsnapshot_t\t\t*snap;\n\tint\t\t\t\tn;\n\n\t// see what the latest snapshot the client system has is\n\ttrap_GetCurrentSnapshotNumber( &n, &cg.latestSnapshotTime );\n\tif ( n != cg.latestSnapshotNum ) {\n\t\tif ( n < cg.latestSnapshotNum ) {\n\t\t\t// this should never happen\n\t\t\tCG_Error( \"CG_ProcessSnapshots: n < cg.latestSnapshotNum\" );\n\t\t}\n\t\tcg.latestSnapshotNum = n;\n\t}\n\n\t// If we have yet to receive a snapshot, check for it.\n\t// Once we have gotten the first snapshot, cg.snap will\n\t// always have valid data for the rest of the game\n\twhile ( !cg.snap ) {\n\t\tsnap = CG_ReadNextSnapshot();\n\t\tif ( !snap ) {\n\t\t\t// we can't continue until we get a snapshot\n\t\t\treturn;\n\t\t}\n\n\t\t// set our weapon selection to what\n\t\t// the playerstate is currently using\n\t\tif ( !( snap->snapFlags & SNAPFLAG_NOT_ACTIVE ) ) {\n\t\t\tCG_SetInitialSnapshot( snap );\n\t\t}\n\t}\n\n\t// loop until we either have a valid nextSnap with a serverTime\n\t// greater than cg.time to interpolate towards, or we run\n\t// out of available snapshots\n\tdo {\n\t\t// if we don't have a nextframe, try and read a new one in\n\t\tif ( !cg.nextSnap ) {\n\t\t\tsnap = CG_ReadNextSnapshot();\n\n\t\t\t// if we still don't have a nextframe, we will just have to\n\t\t\t// extrapolate\n\t\t\tif ( !snap ) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tCG_SetNextSnap( snap );\n\n\n\t\t\t// if time went backwards, we have a level restart\n\t\t\tif ( cg.nextSnap->serverTime < cg.snap->serverTime ) {\n\t\t\t\tCG_Error( \"CG_ProcessSnapshots: Server time went backwards\" );\n\t\t\t}\n\t\t}\n\n\t\t// if our time is < nextFrame's, we have a nice interpolating state\n\t\tif ( cg.time >= cg.snap->serverTime && cg.time < cg.nextSnap->serverTime ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// we have passed the transition from nextFrame to frame\n\t\tCG_TransitionSnapshot();\n\t} while ( 1 );\n\n\t// assert our valid conditions upon exiting\n\tif ( cg.snap == NULL ) {\n\t\tCG_Error( \"CG_ProcessSnapshots: cg.snap == NULL\" );\n\t}\n\tif ( cg.time < cg.snap->serverTime ) {\n\t\t// this can happen right after a vid_restart\n\t\tcg.time = cg.snap->serverTime;\n\t}\n\tif ( cg.nextSnap != NULL && cg.nextSnap->serverTime <= cg.time ) {\n\t\tCG_Error( \"CG_ProcessSnapshots: cg.nextSnap->serverTime <= cg.time\" );\n\t}\n\n}\n\n"
  },
  {
    "path": "code/cgame/cg_syscalls.asm",
    "content": "code\n\nequ\ttrap_Print\t\t\t\t\t\t\t-1\nequ\ttrap_Error\t\t\t\t\t\t\t-2\nequ\ttrap_Milliseconds\t\t\t\t\t-3\nequ\ttrap_Cvar_Register\t\t\t\t\t-4\nequ\ttrap_Cvar_Update\t\t\t\t\t-5\nequ\ttrap_Cvar_Set\t\t\t\t\t\t-6\nequ trap_Cvar_VariableStringBuffer\t\t-7\nequ\ttrap_Argc\t\t\t\t\t\t\t-8\nequ\ttrap_Argv\t\t\t\t\t\t\t-9\nequ\ttrap_Args\t\t\t\t\t\t\t-10\nequ\ttrap_FS_FOpenFile\t\t\t\t\t-11\nequ\ttrap_FS_Read\t\t\t\t\t\t-12\nequ\ttrap_FS_Write\t\t\t\t\t\t-13 \nequ\ttrap_FS_FCloseFile\t\t\t\t\t-14\nequ\ttrap_SendConsoleCommand\t\t\t\t-15\nequ\ttrap_AddCommand\t\t\t\t\t\t-16\nequ\ttrap_SendClientCommand\t\t\t\t-17\nequ\ttrap_UpdateScreen\t\t\t\t\t-18\nequ\ttrap_CM_LoadMap\t\t\t\t\t\t-19\nequ\ttrap_CM_NumInlineModels\t\t\t\t-20\nequ\ttrap_CM_InlineModel\t\t\t\t\t-21\nequ\ttrap_CM_LoadModel\t\t\t\t\t-22\nequ\ttrap_CM_TempBoxModel\t\t\t\t-23\nequ\ttrap_CM_PointContents\t\t\t\t-24\nequ\ttrap_CM_TransformedPointContents\t-25\nequ\ttrap_CM_BoxTrace\t\t\t\t\t-26\nequ\ttrap_CM_TransformedBoxTrace\t\t\t-27\nequ\ttrap_CM_MarkFragments\t\t\t\t-28\nequ\ttrap_S_StartSound\t\t\t\t\t-29\nequ\ttrap_S_StartLocalSound\t\t\t\t-30\nequ\ttrap_S_ClearLoopingSounds\t\t\t-31\nequ\ttrap_S_AddLoopingSound\t\t\t\t-32\nequ\ttrap_S_UpdateEntityPosition\t\t\t-33\nequ\ttrap_S_Respatialize\t\t\t\t\t-34\nequ\ttrap_S_RegisterSound\t\t\t\t-35\nequ\ttrap_S_StartBackgroundTrack\t\t\t-36\nequ\ttrap_R_LoadWorldMap\t\t\t\t\t-37\nequ\ttrap_R_RegisterModel\t\t\t\t-38\nequ\ttrap_R_RegisterSkin\t\t\t\t\t-39\nequ\ttrap_R_RegisterShader\t\t\t\t-40\nequ\ttrap_R_ClearScene\t\t\t\t\t-41\nequ\ttrap_R_AddRefEntityToScene\t\t\t-42\nequ\ttrap_R_AddPolyToScene\t\t\t\t-43\nequ\ttrap_R_AddLightToScene\t\t\t\t-44\nequ\ttrap_R_RenderScene\t\t\t\t\t-45\nequ\ttrap_R_SetColor\t\t\t\t\t\t-46\nequ\ttrap_R_DrawStretchPic\t\t\t\t-47\nequ\ttrap_R_ModelBounds\t\t\t\t\t-48\nequ\ttrap_R_LerpTag\t\t\t\t\t\t-49\nequ\ttrap_GetGlconfig\t\t\t\t\t-50\nequ\ttrap_GetGameState\t\t\t\t\t-51\nequ\ttrap_GetCurrentSnapshotNumber\t\t-52\nequ\ttrap_GetSnapshot\t\t\t\t\t-53\nequ\ttrap_GetServerCommand\t\t\t\t-54\nequ\ttrap_GetCurrentCmdNumber\t\t\t-55\nequ\ttrap_GetUserCmd\t\t\t\t\t\t-56\nequ\ttrap_SetUserCmdValue\t\t\t\t-57\nequ\ttrap_R_RegisterShaderNoMip\t\t\t-58\nequ\ttrap_MemoryRemaining\t\t\t\t-59\nequ trap_R_RegisterFont\t\t\t\t\t-60\nequ trap_Key_IsDown\t\t\t\t\t\t-61\nequ trap_Key_GetCatcher\t\t\t\t\t-62\nequ trap_Key_SetCatcher\t\t\t\t\t-63\nequ trap_Key_GetKey\t\t\t\t\t\t-64\nequ trap_PC_AddGlobalDefine\t\t\t\t-65\nequ\ttrap_PC_LoadSource\t\t\t\t\t-66\nequ trap_PC_FreeSource\t\t\t\t\t-67\nequ trap_PC_ReadToken\t\t\t\t\t-68\nequ trap_PC_SourceFileAndLine\t\t\t-69\nequ trap_S_StopBackgroundTrack\t\t\t-70\nequ trap_RealTime\t\t\t\t\t\t-71\nequ trap_SnapVector\t\t\t\t\t\t-72\nequ trap_RemoveCommand\t\t\t\t\t-73\nequ trap_R_LightForPoint\t\t\t\t-74\nequ trap_CIN_PlayCinematic\t\t\t\t-75\nequ trap_CIN_StopCinematic\t\t\t\t-76\nequ trap_CIN_RunCinematic \t\t\t\t-77\nequ trap_CIN_DrawCinematic\t\t\t\t-78\nequ trap_CIN_SetExtents\t\t\t\t\t-79\nequ trap_R_RemapShader\t\t\t\t\t-80\nequ\ttrap_S_AddRealLoopingSound\t\t\t-81\nequ trap_S_StopLoopingSound\t\t\t\t-82\nequ trap_CM_TempCapsuleModel\t\t\t-83\nequ trap_CM_CapsuleTrace\t\t\t\t-84\nequ trap_CM_TransformedCapsuleTrace\t\t-85\nequ trap_R_AddAdditiveLightToScene\t\t-86\nequ trap_GetEntityToken\t\t\t\t\t-87\nequ\ttrap_R_AddPolysToScene\t\t\t\t-88\nequ trap_R_inPVS\t\t\t\t\t\t-89\nequ trap_FS_Seek\t\t\t-90\n\nequ\tmemset\t\t\t\t\t\t-101\nequ\tmemcpy\t\t\t\t\t\t-102\nequ\tstrncpy\t\t\t\t\t\t-103\nequ\tsin\t\t\t\t\t\t\t-104\nequ\tcos\t\t\t\t\t\t\t-105\nequ\tatan2\t\t\t\t\t\t-106\nequ\tsqrt\t\t\t\t\t\t-107\nequ floor\t\t\t\t\t\t-108\nequ\tceil\t\t\t\t\t\t-109\nequ\ttestPrintInt\t\t\t\t-110\nequ\ttestPrintFloat\t\t\t\t-111\nequ acos\t\t\t\t\t\t-112\n\n"
  },
  {
    "path": "code/cgame/cg_syscalls.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// cg_syscalls.c -- this file is only included when building a dll\n// cg_syscalls.asm is included instead when building a qvm\n#ifdef Q3_VM\n#error \"Do not use in VM build\"\n#endif\n\n#include \"cg_local.h\"\n\nstatic int (QDECL *syscall)( int arg, ... ) = (int (QDECL *)( int, ...))-1;\n\n\nvoid dllEntry( int (QDECL  *syscallptr)( int arg,... ) ) {\n\tsyscall = syscallptr;\n}\n\n\nint PASSFLOAT( float x ) {\n\tfloat\tfloatTemp;\n\tfloatTemp = x;\n\treturn *(int *)&floatTemp;\n}\n\nvoid\ttrap_Print( const char *fmt ) {\n\tsyscall( CG_PRINT, fmt );\n}\n\nvoid\ttrap_Error( const char *fmt ) {\n\tsyscall( CG_ERROR, fmt );\n}\n\nint\t\ttrap_Milliseconds( void ) {\n\treturn syscall( CG_MILLISECONDS ); \n}\n\nvoid\ttrap_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags ) {\n\tsyscall( CG_CVAR_REGISTER, vmCvar, varName, defaultValue, flags );\n}\n\nvoid\ttrap_Cvar_Update( vmCvar_t *vmCvar ) {\n\tsyscall( CG_CVAR_UPDATE, vmCvar );\n}\n\nvoid\ttrap_Cvar_Set( const char *var_name, const char *value ) {\n\tsyscall( CG_CVAR_SET, var_name, value );\n}\n\nvoid trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize ) {\n\tsyscall( CG_CVAR_VARIABLESTRINGBUFFER, var_name, buffer, bufsize );\n}\n\nint\t\ttrap_Argc( void ) {\n\treturn syscall( CG_ARGC );\n}\n\nvoid\ttrap_Argv( int n, char *buffer, int bufferLength ) {\n\tsyscall( CG_ARGV, n, buffer, bufferLength );\n}\n\nvoid\ttrap_Args( char *buffer, int bufferLength ) {\n\tsyscall( CG_ARGS, buffer, bufferLength );\n}\n\nint\t\ttrap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode ) {\n\treturn syscall( CG_FS_FOPENFILE, qpath, f, mode );\n}\n\nvoid\ttrap_FS_Read( void *buffer, int len, fileHandle_t f ) {\n\tsyscall( CG_FS_READ, buffer, len, f );\n}\n\nvoid\ttrap_FS_Write( const void *buffer, int len, fileHandle_t f ) {\n\tsyscall( CG_FS_WRITE, buffer, len, f );\n}\n\nvoid\ttrap_FS_FCloseFile( fileHandle_t f ) {\n\tsyscall( CG_FS_FCLOSEFILE, f );\n}\n\nint trap_FS_Seek( fileHandle_t f, long offset, int origin ) {\n\treturn syscall( CG_FS_SEEK, f, offset, origin );\n}\n\nvoid\ttrap_SendConsoleCommand( const char *text ) {\n\tsyscall( CG_SENDCONSOLECOMMAND, text );\n}\n\nvoid\ttrap_AddCommand( const char *cmdName ) {\n\tsyscall( CG_ADDCOMMAND, cmdName );\n}\n\nvoid\ttrap_RemoveCommand( const char *cmdName ) {\n\tsyscall( CG_REMOVECOMMAND, cmdName );\n}\n\nvoid\ttrap_SendClientCommand( const char *s ) {\n\tsyscall( CG_SENDCLIENTCOMMAND, s );\n}\n\nvoid\ttrap_UpdateScreen( void ) {\n\tsyscall( CG_UPDATESCREEN );\n}\n\nvoid\ttrap_CM_LoadMap( const char *mapname ) {\n\tsyscall( CG_CM_LOADMAP, mapname );\n}\n\nint\t\ttrap_CM_NumInlineModels( void ) {\n\treturn syscall( CG_CM_NUMINLINEMODELS );\n}\n\nclipHandle_t trap_CM_InlineModel( int index ) {\n\treturn syscall( CG_CM_INLINEMODEL, index );\n}\n\nclipHandle_t trap_CM_TempBoxModel( const vec3_t mins, const vec3_t maxs ) {\n\treturn syscall( CG_CM_TEMPBOXMODEL, mins, maxs );\n}\n\nclipHandle_t trap_CM_TempCapsuleModel( const vec3_t mins, const vec3_t maxs ) {\n\treturn syscall( CG_CM_TEMPCAPSULEMODEL, mins, maxs );\n}\n\nint\t\ttrap_CM_PointContents( const vec3_t p, clipHandle_t model ) {\n\treturn syscall( CG_CM_POINTCONTENTS, p, model );\n}\n\nint\t\ttrap_CM_TransformedPointContents( const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles ) {\n\treturn syscall( CG_CM_TRANSFORMEDPOINTCONTENTS, p, model, origin, angles );\n}\n\nvoid\ttrap_CM_BoxTrace( trace_t *results, const vec3_t start, const vec3_t end,\n\t\t\t\t\t\t  const vec3_t mins, const vec3_t maxs,\n\t\t\t\t\t\t  clipHandle_t model, int brushmask ) {\n\tsyscall( CG_CM_BOXTRACE, results, start, end, mins, maxs, model, brushmask );\n}\n\nvoid\ttrap_CM_CapsuleTrace( trace_t *results, const vec3_t start, const vec3_t end,\n\t\t\t\t\t\t  const vec3_t mins, const vec3_t maxs,\n\t\t\t\t\t\t  clipHandle_t model, int brushmask ) {\n\tsyscall( CG_CM_CAPSULETRACE, results, start, end, mins, maxs, model, brushmask );\n}\n\nvoid\ttrap_CM_TransformedBoxTrace( trace_t *results, const vec3_t start, const vec3_t end,\n\t\t\t\t\t\t  const vec3_t mins, const vec3_t maxs,\n\t\t\t\t\t\t  clipHandle_t model, int brushmask,\n\t\t\t\t\t\t  const vec3_t origin, const vec3_t angles ) {\n\tsyscall( CG_CM_TRANSFORMEDBOXTRACE, results, start, end, mins, maxs, model, brushmask, origin, angles );\n}\n\nvoid\ttrap_CM_TransformedCapsuleTrace( trace_t *results, const vec3_t start, const vec3_t end,\n\t\t\t\t\t\t  const vec3_t mins, const vec3_t maxs,\n\t\t\t\t\t\t  clipHandle_t model, int brushmask,\n\t\t\t\t\t\t  const vec3_t origin, const vec3_t angles ) {\n\tsyscall( CG_CM_TRANSFORMEDCAPSULETRACE, results, start, end, mins, maxs, model, brushmask, origin, angles );\n}\n\nint\t\ttrap_CM_MarkFragments( int numPoints, const vec3_t *points, \n\t\t\t\tconst vec3_t projection,\n\t\t\t\tint maxPoints, vec3_t pointBuffer,\n\t\t\t\tint maxFragments, markFragment_t *fragmentBuffer ) {\n\treturn syscall( CG_CM_MARKFRAGMENTS, numPoints, points, projection, maxPoints, pointBuffer, maxFragments, fragmentBuffer );\n}\n\nvoid\ttrap_S_StartSound( vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx ) {\n\tsyscall( CG_S_STARTSOUND, origin, entityNum, entchannel, sfx );\n}\n\nvoid\ttrap_S_StartLocalSound( sfxHandle_t sfx, int channelNum ) {\n\tsyscall( CG_S_STARTLOCALSOUND, sfx, channelNum );\n}\n\nvoid\ttrap_S_ClearLoopingSounds( qboolean killall ) {\n\tsyscall( CG_S_CLEARLOOPINGSOUNDS, killall );\n}\n\nvoid\ttrap_S_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx ) {\n\tsyscall( CG_S_ADDLOOPINGSOUND, entityNum, origin, velocity, sfx );\n}\n\nvoid\ttrap_S_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx ) {\n\tsyscall( CG_S_ADDREALLOOPINGSOUND, entityNum, origin, velocity, sfx );\n}\n\nvoid\ttrap_S_StopLoopingSound( int entityNum ) {\n\tsyscall( CG_S_STOPLOOPINGSOUND, entityNum );\n}\n\nvoid\ttrap_S_UpdateEntityPosition( int entityNum, const vec3_t origin ) {\n\tsyscall( CG_S_UPDATEENTITYPOSITION, entityNum, origin );\n}\n\nvoid\ttrap_S_Respatialize( int entityNum, const vec3_t origin, vec3_t axis[3], int inwater ) {\n\tsyscall( CG_S_RESPATIALIZE, entityNum, origin, axis, inwater );\n}\n\nsfxHandle_t\ttrap_S_RegisterSound( const char *sample, qboolean compressed ) {\n\treturn syscall( CG_S_REGISTERSOUND, sample, compressed );\n}\n\nvoid\ttrap_S_StartBackgroundTrack( const char *intro, const char *loop ) {\n\tsyscall( CG_S_STARTBACKGROUNDTRACK, intro, loop );\n}\n\nvoid\ttrap_R_LoadWorldMap( const char *mapname ) {\n\tsyscall( CG_R_LOADWORLDMAP, mapname );\n}\n\nqhandle_t trap_R_RegisterModel( const char *name ) {\n\treturn syscall( CG_R_REGISTERMODEL, name );\n}\n\nqhandle_t trap_R_RegisterSkin( const char *name ) {\n\treturn syscall( CG_R_REGISTERSKIN, name );\n}\n\nqhandle_t trap_R_RegisterShader( const char *name ) {\n\treturn syscall( CG_R_REGISTERSHADER, name );\n}\n\nqhandle_t trap_R_RegisterShaderNoMip( const char *name ) {\n\treturn syscall( CG_R_REGISTERSHADERNOMIP, name );\n}\n\nvoid trap_R_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {\n\tsyscall(CG_R_REGISTERFONT, fontName, pointSize, font );\n}\n\nvoid\ttrap_R_ClearScene( void ) {\n\tsyscall( CG_R_CLEARSCENE );\n}\n\nvoid\ttrap_R_AddRefEntityToScene( const refEntity_t *re ) {\n\tsyscall( CG_R_ADDREFENTITYTOSCENE, re );\n}\n\nvoid\ttrap_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts ) {\n\tsyscall( CG_R_ADDPOLYTOSCENE, hShader, numVerts, verts );\n}\n\nvoid\ttrap_R_AddPolysToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts, int num ) {\n\tsyscall( CG_R_ADDPOLYSTOSCENE, hShader, numVerts, verts, num );\n}\n\nint\t\ttrap_R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir ) {\n\treturn syscall( CG_R_LIGHTFORPOINT, point, ambientLight, directedLight, lightDir );\n}\n\nvoid\ttrap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ) {\n\tsyscall( CG_R_ADDLIGHTTOSCENE, org, PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b) );\n}\n\nvoid\ttrap_R_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b ) {\n\tsyscall( CG_R_ADDADDITIVELIGHTTOSCENE, org, PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b) );\n}\n\nvoid\ttrap_R_RenderScene( const refdef_t *fd ) {\n\tsyscall( CG_R_RENDERSCENE, fd );\n}\n\nvoid\ttrap_R_SetColor( const float *rgba ) {\n\tsyscall( CG_R_SETCOLOR, rgba );\n}\n\nvoid\ttrap_R_DrawStretchPic( float x, float y, float w, float h, \n\t\t\t\t\t\t\t   float s1, float t1, float s2, float t2, qhandle_t hShader ) {\n\tsyscall( CG_R_DRAWSTRETCHPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), hShader );\n}\n\nvoid\ttrap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs ) {\n\tsyscall( CG_R_MODELBOUNDS, model, mins, maxs );\n}\n\nint\t\ttrap_R_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame, \n\t\t\t\t\t   float frac, const char *tagName ) {\n\treturn syscall( CG_R_LERPTAG, tag, mod, startFrame, endFrame, PASSFLOAT(frac), tagName );\n}\n\nvoid\ttrap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset ) {\n\tsyscall( CG_R_REMAP_SHADER, oldShader, newShader, timeOffset );\n}\n\nvoid\t\ttrap_GetGlconfig( glconfig_t *glconfig ) {\n\tsyscall( CG_GETGLCONFIG, glconfig );\n}\n\nvoid\t\ttrap_GetGameState( gameState_t *gamestate ) {\n\tsyscall( CG_GETGAMESTATE, gamestate );\n}\n\nvoid\t\ttrap_GetCurrentSnapshotNumber( int *snapshotNumber, int *serverTime ) {\n\tsyscall( CG_GETCURRENTSNAPSHOTNUMBER, snapshotNumber, serverTime );\n}\n\nqboolean\ttrap_GetSnapshot( int snapshotNumber, snapshot_t *snapshot ) {\n\treturn syscall( CG_GETSNAPSHOT, snapshotNumber, snapshot );\n}\n\nqboolean\ttrap_GetServerCommand( int serverCommandNumber ) {\n\treturn syscall( CG_GETSERVERCOMMAND, serverCommandNumber );\n}\n\nint\t\t\ttrap_GetCurrentCmdNumber( void ) {\n\treturn syscall( CG_GETCURRENTCMDNUMBER );\n}\n\nqboolean\ttrap_GetUserCmd( int cmdNumber, usercmd_t *ucmd ) {\n\treturn syscall( CG_GETUSERCMD, cmdNumber, ucmd );\n}\n\nvoid\t\ttrap_SetUserCmdValue( int stateValue, float sensitivityScale ) {\n\tsyscall( CG_SETUSERCMDVALUE, stateValue, PASSFLOAT(sensitivityScale) );\n}\n\nvoid\t\ttestPrintInt( char *string, int i ) {\n\tsyscall( CG_TESTPRINTINT, string, i );\n}\n\nvoid\t\ttestPrintFloat( char *string, float f ) {\n\tsyscall( CG_TESTPRINTFLOAT, string, PASSFLOAT(f) );\n}\n\nint trap_MemoryRemaining( void ) {\n\treturn syscall( CG_MEMORY_REMAINING );\n}\n\nqboolean trap_Key_IsDown( int keynum ) {\n\treturn syscall( CG_KEY_ISDOWN, keynum );\n}\n\nint trap_Key_GetCatcher( void ) {\n\treturn syscall( CG_KEY_GETCATCHER );\n}\n\nvoid trap_Key_SetCatcher( int catcher ) {\n\tsyscall( CG_KEY_SETCATCHER, catcher );\n}\n\nint trap_Key_GetKey( const char *binding ) {\n\treturn syscall( CG_KEY_GETKEY, binding );\n}\n\nint trap_PC_AddGlobalDefine( char *define ) {\n\treturn syscall( CG_PC_ADD_GLOBAL_DEFINE, define );\n}\n\nint trap_PC_LoadSource( const char *filename ) {\n\treturn syscall( CG_PC_LOAD_SOURCE, filename );\n}\n\nint trap_PC_FreeSource( int handle ) {\n\treturn syscall( CG_PC_FREE_SOURCE, handle );\n}\n\nint trap_PC_ReadToken( int handle, pc_token_t *pc_token ) {\n\treturn syscall( CG_PC_READ_TOKEN, handle, pc_token );\n}\n\nint trap_PC_SourceFileAndLine( int handle, char *filename, int *line ) {\n\treturn syscall( CG_PC_SOURCE_FILE_AND_LINE, handle, filename, line );\n}\n\nvoid\ttrap_S_StopBackgroundTrack( void ) {\n\tsyscall( CG_S_STOPBACKGROUNDTRACK );\n}\n\nint trap_RealTime(qtime_t *qtime) {\n\treturn syscall( CG_REAL_TIME, qtime );\n}\n\nvoid trap_SnapVector( float *v ) {\n\tsyscall( CG_SNAPVECTOR, v );\n}\n\n// this returns a handle.  arg0 is the name in the format \"idlogo.roq\", set arg1 to NULL, alteredstates to qfalse (do not alter gamestate)\nint trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits) {\n  return syscall(CG_CIN_PLAYCINEMATIC, arg0, xpos, ypos, width, height, bits);\n}\n \n// stops playing the cinematic and ends it.  should always return FMV_EOF\n// cinematics must be stopped in reverse order of when they are started\ne_status trap_CIN_StopCinematic(int handle) {\n  return syscall(CG_CIN_STOPCINEMATIC, handle);\n}\n\n\n// will run a frame of the cinematic but will not draw it.  Will return FMV_EOF if the end of the cinematic has been reached.\ne_status trap_CIN_RunCinematic (int handle) {\n  return syscall(CG_CIN_RUNCINEMATIC, handle);\n}\n \n\n// draws the current frame\nvoid trap_CIN_DrawCinematic (int handle) {\n  syscall(CG_CIN_DRAWCINEMATIC, handle);\n}\n \n\n// allows you to resize the animation dynamically\nvoid trap_CIN_SetExtents (int handle, int x, int y, int w, int h) {\n  syscall(CG_CIN_SETEXTENTS, handle, x, y, w, h);\n}\n\n/*\nqboolean trap_loadCamera( const char *name ) {\n\treturn syscall( CG_LOADCAMERA, name );\n}\n\nvoid trap_startCamera(int time) {\n\tsyscall(CG_STARTCAMERA, time);\n}\n\nqboolean trap_getCameraInfo( int time, vec3_t *origin, vec3_t *angles) {\n\treturn syscall( CG_GETCAMERAINFO, time, origin, angles );\n}\n*/\n\nqboolean trap_GetEntityToken( char *buffer, int bufferSize ) {\n\treturn syscall( CG_GET_ENTITY_TOKEN, buffer, bufferSize );\n}\n\nqboolean trap_R_inPVS( const vec3_t p1, const vec3_t p2 ) {\n\treturn syscall( CG_R_INPVS, p1, p2 );\n}\n"
  },
  {
    "path": "code/cgame/cg_view.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// cg_view.c -- setup all the parameters (position, angle, etc)\n// for a 3D rendering\n#include \"cg_local.h\"\n\n\n/*\n=============================================================================\n\n  MODEL TESTING\n\nThe viewthing and gun positioning tools from Q2 have been integrated and\nenhanced into a single model testing facility.\n\nModel viewing can begin with either \"testmodel <modelname>\" or \"testgun <modelname>\".\n\nThe names must be the full pathname after the basedir, like \n\"models/weapons/v_launch/tris.md3\" or \"players/male/tris.md3\"\n\nTestmodel will create a fake entity 100 units in front of the current view\nposition, directly facing the viewer.  It will remain immobile, so you can\nmove around it to view it from different angles.\n\nTestgun will cause the model to follow the player around and supress the real\nview weapon model.  The default frame 0 of most guns is completely off screen,\nso you will probably have to cycle a couple frames to see it.\n\n\"nextframe\", \"prevframe\", \"nextskin\", and \"prevskin\" commands will change the\nframe or skin of the testmodel.  These are bound to F5, F6, F7, and F8 in\nq3default.cfg.\n\nIf a gun is being tested, the \"gun_x\", \"gun_y\", and \"gun_z\" variables will let\nyou adjust the positioning.\n\nNote that none of the model testing features update while the game is paused, so\nit may be convenient to test with deathmatch set to 1 so that bringing down the\nconsole doesn't pause the game.\n\n=============================================================================\n*/\n\n/*\n=================\nCG_TestModel_f\n\nCreates an entity in front of the current position, which\ncan then be moved around\n=================\n*/\nvoid CG_TestModel_f (void) {\n\tvec3_t\t\tangles;\n\n\tmemset( &cg.testModelEntity, 0, sizeof(cg.testModelEntity) );\n\tif ( trap_Argc() < 2 ) {\n\t\treturn;\n\t}\n\n\tQ_strncpyz (cg.testModelName, CG_Argv( 1 ), MAX_QPATH );\n\tcg.testModelEntity.hModel = trap_R_RegisterModel( cg.testModelName );\n\n\tif ( trap_Argc() == 3 ) {\n\t\tcg.testModelEntity.backlerp = atof( CG_Argv( 2 ) );\n\t\tcg.testModelEntity.frame = 1;\n\t\tcg.testModelEntity.oldframe = 0;\n\t}\n\tif (! cg.testModelEntity.hModel ) {\n\t\tCG_Printf( \"Can't register model\\n\" );\n\t\treturn;\n\t}\n\n\tVectorMA( cg.refdef.vieworg, 100, cg.refdef.viewaxis[0], cg.testModelEntity.origin );\n\n\tangles[PITCH] = 0;\n\tangles[YAW] = 180 + cg.refdefViewAngles[1];\n\tangles[ROLL] = 0;\n\n\tAnglesToAxis( angles, cg.testModelEntity.axis );\n\tcg.testGun = qfalse;\n}\n\n/*\n=================\nCG_TestGun_f\n\nReplaces the current view weapon with the given model\n=================\n*/\nvoid CG_TestGun_f (void) {\n\tCG_TestModel_f();\n\tcg.testGun = qtrue;\n\tcg.testModelEntity.renderfx = RF_MINLIGHT | RF_DEPTHHACK | RF_FIRST_PERSON;\n}\n\n\nvoid CG_TestModelNextFrame_f (void) {\n\tcg.testModelEntity.frame++;\n\tCG_Printf( \"frame %i\\n\", cg.testModelEntity.frame );\n}\n\nvoid CG_TestModelPrevFrame_f (void) {\n\tcg.testModelEntity.frame--;\n\tif ( cg.testModelEntity.frame < 0 ) {\n\t\tcg.testModelEntity.frame = 0;\n\t}\n\tCG_Printf( \"frame %i\\n\", cg.testModelEntity.frame );\n}\n\nvoid CG_TestModelNextSkin_f (void) {\n\tcg.testModelEntity.skinNum++;\n\tCG_Printf( \"skin %i\\n\", cg.testModelEntity.skinNum );\n}\n\nvoid CG_TestModelPrevSkin_f (void) {\n\tcg.testModelEntity.skinNum--;\n\tif ( cg.testModelEntity.skinNum < 0 ) {\n\t\tcg.testModelEntity.skinNum = 0;\n\t}\n\tCG_Printf( \"skin %i\\n\", cg.testModelEntity.skinNum );\n}\n\nstatic void CG_AddTestModel (void) {\n\tint\t\ti;\n\n\t// re-register the model, because the level may have changed\n\tcg.testModelEntity.hModel = trap_R_RegisterModel( cg.testModelName );\n\tif (! cg.testModelEntity.hModel ) {\n\t\tCG_Printf (\"Can't register model\\n\");\n\t\treturn;\n\t}\n\n\t// if testing a gun, set the origin reletive to the view origin\n\tif ( cg.testGun ) {\n\t\tVectorCopy( cg.refdef.vieworg, cg.testModelEntity.origin );\n\t\tVectorCopy( cg.refdef.viewaxis[0], cg.testModelEntity.axis[0] );\n\t\tVectorCopy( cg.refdef.viewaxis[1], cg.testModelEntity.axis[1] );\n\t\tVectorCopy( cg.refdef.viewaxis[2], cg.testModelEntity.axis[2] );\n\n\t\t// allow the position to be adjusted\n\t\tfor (i=0 ; i<3 ; i++) {\n\t\t\tcg.testModelEntity.origin[i] += cg.refdef.viewaxis[0][i] * cg_gun_x.value;\n\t\t\tcg.testModelEntity.origin[i] += cg.refdef.viewaxis[1][i] * cg_gun_y.value;\n\t\t\tcg.testModelEntity.origin[i] += cg.refdef.viewaxis[2][i] * cg_gun_z.value;\n\t\t}\n\t}\n\n\ttrap_R_AddRefEntityToScene( &cg.testModelEntity );\n}\n\n\n\n//============================================================================\n\n\n/*\n=================\nCG_CalcVrect\n\nSets the coordinates of the rendered window\n=================\n*/\nstatic void CG_CalcVrect (void) {\n\tint\t\tsize;\n\n\t// the intermission should allways be full screen\n\tif ( cg.snap->ps.pm_type == PM_INTERMISSION ) {\n\t\tsize = 100;\n\t} else {\n\t\t// bound normal viewsize\n\t\tif (cg_viewsize.integer < 30) {\n\t\t\ttrap_Cvar_Set (\"cg_viewsize\",\"30\");\n\t\t\tsize = 30;\n\t\t} else if (cg_viewsize.integer > 100) {\n\t\t\ttrap_Cvar_Set (\"cg_viewsize\",\"100\");\n\t\t\tsize = 100;\n\t\t} else {\n\t\t\tsize = cg_viewsize.integer;\n\t\t}\n\n\t}\n\tcg.refdef.width = cgs.glconfig.vidWidth*size/100;\n\tcg.refdef.width &= ~1;\n\n\tcg.refdef.height = cgs.glconfig.vidHeight*size/100;\n\tcg.refdef.height &= ~1;\n\n\tcg.refdef.x = (cgs.glconfig.vidWidth - cg.refdef.width)/2;\n\tcg.refdef.y = (cgs.glconfig.vidHeight - cg.refdef.height)/2;\n}\n\n//==============================================================================\n\n\n/*\n===============\nCG_OffsetThirdPersonView\n\n===============\n*/\n#define\tFOCUS_DISTANCE\t512\nstatic void CG_OffsetThirdPersonView( void ) {\n\tvec3_t\t\tforward, right, up;\n\tvec3_t\t\tview;\n\tvec3_t\t\tfocusAngles;\n\ttrace_t\t\ttrace;\n\tstatic vec3_t\tmins = { -4, -4, -4 };\n\tstatic vec3_t\tmaxs = { 4, 4, 4 };\n\tvec3_t\t\tfocusPoint;\n\tfloat\t\tfocusDist;\n\tfloat\t\tforwardScale, sideScale;\n\n\tcg.refdef.vieworg[2] += cg.predictedPlayerState.viewheight;\n\n\tVectorCopy( cg.refdefViewAngles, focusAngles );\n\n\t// if dead, look at killer\n\tif ( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) {\n\t\tfocusAngles[YAW] = cg.predictedPlayerState.stats[STAT_DEAD_YAW];\n\t\tcg.refdefViewAngles[YAW] = cg.predictedPlayerState.stats[STAT_DEAD_YAW];\n\t}\n\n\tif ( focusAngles[PITCH] > 45 ) {\n\t\tfocusAngles[PITCH] = 45;\t\t// don't go too far overhead\n\t}\n\tAngleVectors( focusAngles, forward, NULL, NULL );\n\n\tVectorMA( cg.refdef.vieworg, FOCUS_DISTANCE, forward, focusPoint );\n\n\tVectorCopy( cg.refdef.vieworg, view );\n\n\tview[2] += 8;\n\n\tcg.refdefViewAngles[PITCH] *= 0.5;\n\n\tAngleVectors( cg.refdefViewAngles, forward, right, up );\n\n\tforwardScale = cos( cg_thirdPersonAngle.value / 180 * M_PI );\n\tsideScale = sin( cg_thirdPersonAngle.value / 180 * M_PI );\n\tVectorMA( view, -cg_thirdPersonRange.value * forwardScale, forward, view );\n\tVectorMA( view, -cg_thirdPersonRange.value * sideScale, right, view );\n\n\t// trace a ray from the origin to the viewpoint to make sure the view isn't\n\t// in a solid block.  Use an 8 by 8 block to prevent the view from near clipping anything\n\n\tif (!cg_cameraMode.integer) {\n\t\tCG_Trace( &trace, cg.refdef.vieworg, mins, maxs, view, cg.predictedPlayerState.clientNum, MASK_SOLID );\n\n\t\tif ( trace.fraction != 1.0 ) {\n\t\t\tVectorCopy( trace.endpos, view );\n\t\t\tview[2] += (1.0 - trace.fraction) * 32;\n\t\t\t// try another trace to this position, because a tunnel may have the ceiling\n\t\t\t// close enogh that this is poking out\n\n\t\t\tCG_Trace( &trace, cg.refdef.vieworg, mins, maxs, view, cg.predictedPlayerState.clientNum, MASK_SOLID );\n\t\t\tVectorCopy( trace.endpos, view );\n\t\t}\n\t}\n\n\n\tVectorCopy( view, cg.refdef.vieworg );\n\n\t// select pitch to look at focus point from vieword\n\tVectorSubtract( focusPoint, cg.refdef.vieworg, focusPoint );\n\tfocusDist = sqrt( focusPoint[0] * focusPoint[0] + focusPoint[1] * focusPoint[1] );\n\tif ( focusDist < 1 ) {\n\t\tfocusDist = 1;\t// should never happen\n\t}\n\tcg.refdefViewAngles[PITCH] = -180 / M_PI * atan2( focusPoint[2], focusDist );\n\tcg.refdefViewAngles[YAW] -= cg_thirdPersonAngle.value;\n}\n\n\n// this causes a compiler bug on mac MrC compiler\nstatic void CG_StepOffset( void ) {\n\tint\t\ttimeDelta;\n\t\n\t// smooth out stair climbing\n\ttimeDelta = cg.time - cg.stepTime;\n\tif ( timeDelta < STEP_TIME ) {\n\t\tcg.refdef.vieworg[2] -= cg.stepChange \n\t\t\t* (STEP_TIME - timeDelta) / STEP_TIME;\n\t}\n}\n\n/*\n===============\nCG_OffsetFirstPersonView\n\n===============\n*/\nstatic void CG_OffsetFirstPersonView( void ) {\n\tfloat\t\t\t*origin;\n\tfloat\t\t\t*angles;\n\tfloat\t\t\tbob;\n\tfloat\t\t\tratio;\n\tfloat\t\t\tdelta;\n\tfloat\t\t\tspeed;\n\tfloat\t\t\tf;\n\tvec3_t\t\t\tpredictedVelocity;\n\tint\t\t\t\ttimeDelta;\n\t\n\tif ( cg.snap->ps.pm_type == PM_INTERMISSION ) {\n\t\treturn;\n\t}\n\n\torigin = cg.refdef.vieworg;\n\tangles = cg.refdefViewAngles;\n\n\t// if dead, fix the angle and don't add any kick\n\tif ( cg.snap->ps.stats[STAT_HEALTH] <= 0 ) {\n\t\tangles[ROLL] = 40;\n\t\tangles[PITCH] = -15;\n\t\tangles[YAW] = cg.snap->ps.stats[STAT_DEAD_YAW];\n\t\torigin[2] += cg.predictedPlayerState.viewheight;\n\t\treturn;\n\t}\n\n\t// add angles based on weapon kick\n\tVectorAdd (angles, cg.kick_angles, angles);\n\n\t// add angles based on damage kick\n\tif ( cg.damageTime ) {\n\t\tratio = cg.time - cg.damageTime;\n\t\tif ( ratio < DAMAGE_DEFLECT_TIME ) {\n\t\t\tratio /= DAMAGE_DEFLECT_TIME;\n\t\t\tangles[PITCH] += ratio * cg.v_dmg_pitch;\n\t\t\tangles[ROLL] += ratio * cg.v_dmg_roll;\n\t\t} else {\n\t\t\tratio = 1.0 - ( ratio - DAMAGE_DEFLECT_TIME ) / DAMAGE_RETURN_TIME;\n\t\t\tif ( ratio > 0 ) {\n\t\t\t\tangles[PITCH] += ratio * cg.v_dmg_pitch;\n\t\t\t\tangles[ROLL] += ratio * cg.v_dmg_roll;\n\t\t\t}\n\t\t}\n\t}\n\n\t// add pitch based on fall kick\n#if 0\n\tratio = ( cg.time - cg.landTime) / FALL_TIME;\n\tif (ratio < 0)\n\t\tratio = 0;\n\tangles[PITCH] += ratio * cg.fall_value;\n#endif\n\n\t// add angles based on velocity\n\tVectorCopy( cg.predictedPlayerState.velocity, predictedVelocity );\n\n\tdelta = DotProduct ( predictedVelocity, cg.refdef.viewaxis[0]);\n\tangles[PITCH] += delta * cg_runpitch.value;\n\t\n\tdelta = DotProduct ( predictedVelocity, cg.refdef.viewaxis[1]);\n\tangles[ROLL] -= delta * cg_runroll.value;\n\n\t// add angles based on bob\n\n\t// make sure the bob is visible even at low speeds\n\tspeed = cg.xyspeed > 200 ? cg.xyspeed : 200;\n\n\tdelta = cg.bobfracsin * cg_bobpitch.value * speed;\n\tif (cg.predictedPlayerState.pm_flags & PMF_DUCKED)\n\t\tdelta *= 3;\t\t// crouching\n\tangles[PITCH] += delta;\n\tdelta = cg.bobfracsin * cg_bobroll.value * speed;\n\tif (cg.predictedPlayerState.pm_flags & PMF_DUCKED)\n\t\tdelta *= 3;\t\t// crouching accentuates roll\n\tif (cg.bobcycle & 1)\n\t\tdelta = -delta;\n\tangles[ROLL] += delta;\n\n//===================================\n\n\t// add view height\n\torigin[2] += cg.predictedPlayerState.viewheight;\n\n\t// smooth out duck height changes\n\ttimeDelta = cg.time - cg.duckTime;\n\tif ( timeDelta < DUCK_TIME) {\n\t\tcg.refdef.vieworg[2] -= cg.duckChange \n\t\t\t* (DUCK_TIME - timeDelta) / DUCK_TIME;\n\t}\n\n\t// add bob height\n\tbob = cg.bobfracsin * cg.xyspeed * cg_bobup.value;\n\tif (bob > 6) {\n\t\tbob = 6;\n\t}\n\n\torigin[2] += bob;\n\n\n\t// add fall height\n\tdelta = cg.time - cg.landTime;\n\tif ( delta < LAND_DEFLECT_TIME ) {\n\t\tf = delta / LAND_DEFLECT_TIME;\n\t\tcg.refdef.vieworg[2] += cg.landChange * f;\n\t} else if ( delta < LAND_DEFLECT_TIME + LAND_RETURN_TIME ) {\n\t\tdelta -= LAND_DEFLECT_TIME;\n\t\tf = 1.0 - ( delta / LAND_RETURN_TIME );\n\t\tcg.refdef.vieworg[2] += cg.landChange * f;\n\t}\n\n\t// add step offset\n\tCG_StepOffset();\n\n\t// add kick offset\n\n\tVectorAdd (origin, cg.kick_origin, origin);\n\n\t// pivot the eye based on a neck length\n#if 0\n\t{\n#define\tNECK_LENGTH\t\t8\n\tvec3_t\t\t\tforward, up;\n \n\tcg.refdef.vieworg[2] -= NECK_LENGTH;\n\tAngleVectors( cg.refdefViewAngles, forward, NULL, up );\n\tVectorMA( cg.refdef.vieworg, 3, forward, cg.refdef.vieworg );\n\tVectorMA( cg.refdef.vieworg, NECK_LENGTH, up, cg.refdef.vieworg );\n\t}\n#endif\n}\n\n//======================================================================\n\nvoid CG_ZoomDown_f( void ) { \n\tif ( cg.zoomed ) {\n\t\treturn;\n\t}\n\tcg.zoomed = qtrue;\n\tcg.zoomTime = cg.time;\n}\n\nvoid CG_ZoomUp_f( void ) { \n\tif ( !cg.zoomed ) {\n\t\treturn;\n\t}\n\tcg.zoomed = qfalse;\n\tcg.zoomTime = cg.time;\n}\n\n\n/*\n====================\nCG_CalcFov\n\nFixed fov at intermissions, otherwise account for fov variable and zooms.\n====================\n*/\n#define\tWAVE_AMPLITUDE\t1\n#define\tWAVE_FREQUENCY\t0.4\n\nstatic int CG_CalcFov( void ) {\n\tfloat\tx;\n\tfloat\tphase;\n\tfloat\tv;\n\tint\t\tcontents;\n\tfloat\tfov_x, fov_y;\n\tfloat\tzoomFov;\n\tfloat\tf;\n\tint\t\tinwater;\n\n\tif ( cg.predictedPlayerState.pm_type == PM_INTERMISSION ) {\n\t\t// if in intermission, use a fixed value\n\t\tfov_x = 90;\n\t} else {\n\t\t// user selectable\n\t\tif ( cgs.dmflags & DF_FIXED_FOV ) {\n\t\t\t// dmflag to prevent wide fov for all clients\n\t\t\tfov_x = 90;\n\t\t} else {\n\t\t\tfov_x = cg_fov.value;\n\t\t\tif ( fov_x < 1 ) {\n\t\t\t\tfov_x = 1;\n\t\t\t} else if ( fov_x > 160 ) {\n\t\t\t\tfov_x = 160;\n\t\t\t}\n\t\t}\n\n\t\t// account for zooms\n\t\tzoomFov = cg_zoomFov.value;\n\t\tif ( zoomFov < 1 ) {\n\t\t\tzoomFov = 1;\n\t\t} else if ( zoomFov > 160 ) {\n\t\t\tzoomFov = 160;\n\t\t}\n\n\t\tif ( cg.zoomed ) {\n\t\t\tf = ( cg.time - cg.zoomTime ) / (float)ZOOM_TIME;\n\t\t\tif ( f > 1.0 ) {\n\t\t\t\tfov_x = zoomFov;\n\t\t\t} else {\n\t\t\t\tfov_x = fov_x + f * ( zoomFov - fov_x );\n\t\t\t}\n\t\t} else {\n\t\t\tf = ( cg.time - cg.zoomTime ) / (float)ZOOM_TIME;\n\t\t\tif ( f > 1.0 ) {\n\t\t\t\tfov_x = fov_x;\n\t\t\t} else {\n\t\t\t\tfov_x = zoomFov + f * ( fov_x - zoomFov );\n\t\t\t}\n\t\t}\n\t}\n\n\tx = cg.refdef.width / tan( fov_x / 360 * M_PI );\n\tfov_y = atan2( cg.refdef.height, x );\n\tfov_y = fov_y * 360 / M_PI;\n\n\t// warp if underwater\n\tcontents = CG_PointContents( cg.refdef.vieworg, -1 );\n\tif ( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ){\n\t\tphase = cg.time / 1000.0 * WAVE_FREQUENCY * M_PI * 2;\n\t\tv = WAVE_AMPLITUDE * sin( phase );\n\t\tfov_x += v;\n\t\tfov_y -= v;\n\t\tinwater = qtrue;\n\t}\n\telse {\n\t\tinwater = qfalse;\n\t}\n\n\n\t// set it\n\tcg.refdef.fov_x = fov_x;\n\tcg.refdef.fov_y = fov_y;\n\n\tif ( !cg.zoomed ) {\n\t\tcg.zoomSensitivity = 1;\n\t} else {\n\t\tcg.zoomSensitivity = cg.refdef.fov_y / 75.0;\n\t}\n\n\treturn inwater;\n}\n\n\n\n/*\n===============\nCG_DamageBlendBlob\n\n===============\n*/\nstatic void CG_DamageBlendBlob( void ) {\n\tint\t\t\tt;\n\tint\t\t\tmaxTime;\n\trefEntity_t\t\tent;\n\n\tif ( !cg.damageValue ) {\n\t\treturn;\n\t}\n\n\t//if (cg.cameraMode) {\n\t//\treturn;\n\t//}\n\n\t// ragePro systems can't fade blends, so don't obscure the screen\n\tif ( cgs.glconfig.hardwareType == GLHW_RAGEPRO ) {\n\t\treturn;\n\t}\n\n\tmaxTime = DAMAGE_TIME;\n\tt = cg.time - cg.damageTime;\n\tif ( t <= 0 || t >= maxTime ) {\n\t\treturn;\n\t}\n\n\n\tmemset( &ent, 0, sizeof( ent ) );\n\tent.reType = RT_SPRITE;\n\tent.renderfx = RF_FIRST_PERSON;\n\n\tVectorMA( cg.refdef.vieworg, 8, cg.refdef.viewaxis[0], ent.origin );\n\tVectorMA( ent.origin, cg.damageX * -8, cg.refdef.viewaxis[1], ent.origin );\n\tVectorMA( ent.origin, cg.damageY * 8, cg.refdef.viewaxis[2], ent.origin );\n\n\tent.radius = cg.damageValue * 3;\n\tent.customShader = cgs.media.viewBloodShader;\n\tent.shaderRGBA[0] = 255;\n\tent.shaderRGBA[1] = 255;\n\tent.shaderRGBA[2] = 255;\n\tent.shaderRGBA[3] = 200 * ( 1.0 - ((float)t / maxTime) );\n\ttrap_R_AddRefEntityToScene( &ent );\n}\n\n\n/*\n===============\nCG_CalcViewValues\n\nSets cg.refdef view values\n===============\n*/\nstatic int CG_CalcViewValues( void ) {\n\tplayerState_t\t*ps;\n\n\tmemset( &cg.refdef, 0, sizeof( cg.refdef ) );\n\n\t// strings for in game rendering\n\t// Q_strncpyz( cg.refdef.text[0], \"Park Ranger\", sizeof(cg.refdef.text[0]) );\n\t// Q_strncpyz( cg.refdef.text[1], \"19\", sizeof(cg.refdef.text[1]) );\n\n\t// calculate size of 3D view\n\tCG_CalcVrect();\n\n\tps = &cg.predictedPlayerState;\n/*\n\tif (cg.cameraMode) {\n\t\tvec3_t origin, angles;\n\t\tif (trap_getCameraInfo(cg.time, &origin, &angles)) {\n\t\t\tVectorCopy(origin, cg.refdef.vieworg);\n\t\t\tangles[ROLL] = 0;\n\t\t\tVectorCopy(angles, cg.refdefViewAngles);\n\t\t\tAnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis );\n\t\t\treturn CG_CalcFov();\n\t\t} else {\n\t\t\tcg.cameraMode = qfalse;\n\t\t}\n\t}\n*/\n\t// intermission view\n\tif ( ps->pm_type == PM_INTERMISSION ) {\n\t\tVectorCopy( ps->origin, cg.refdef.vieworg );\n\t\tVectorCopy( ps->viewangles, cg.refdefViewAngles );\n\t\tAnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis );\n\t\treturn CG_CalcFov();\n\t}\n\n\tcg.bobcycle = ( ps->bobCycle & 128 ) >> 7;\n\tcg.bobfracsin = fabs( sin( ( ps->bobCycle & 127 ) / 127.0 * M_PI ) );\n\tcg.xyspeed = sqrt( ps->velocity[0] * ps->velocity[0] +\n\t\tps->velocity[1] * ps->velocity[1] );\n\n\n\tVectorCopy( ps->origin, cg.refdef.vieworg );\n\tVectorCopy( ps->viewangles, cg.refdefViewAngles );\n\n\tif (cg_cameraOrbit.integer) {\n\t\tif (cg.time > cg.nextOrbitTime) {\n\t\t\tcg.nextOrbitTime = cg.time + cg_cameraOrbitDelay.integer;\n\t\t\tcg_thirdPersonAngle.value += cg_cameraOrbit.value;\n\t\t}\n\t}\n\t// add error decay\n\tif ( cg_errorDecay.value > 0 ) {\n\t\tint\t\tt;\n\t\tfloat\tf;\n\n\t\tt = cg.time - cg.predictedErrorTime;\n\t\tf = ( cg_errorDecay.value - t ) / cg_errorDecay.value;\n\t\tif ( f > 0 && f < 1 ) {\n\t\t\tVectorMA( cg.refdef.vieworg, f, cg.predictedError, cg.refdef.vieworg );\n\t\t} else {\n\t\t\tcg.predictedErrorTime = 0;\n\t\t}\n\t}\n\n\tif ( cg.renderingThirdPerson ) {\n\t\t// back away from character\n\t\tCG_OffsetThirdPersonView();\n\t} else {\n\t\t// offset for local bobbing and kicks\n\t\tCG_OffsetFirstPersonView();\n\t}\n\n\t// position eye reletive to origin\n\tAnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis );\n\n\tif ( cg.hyperspace ) {\n\t\tcg.refdef.rdflags |= RDF_NOWORLDMODEL | RDF_HYPERSPACE;\n\t}\n\n\t// field of view\n\treturn CG_CalcFov();\n}\n\n\n/*\n=====================\nCG_PowerupTimerSounds\n=====================\n*/\nstatic void CG_PowerupTimerSounds( void ) {\n\tint\t\ti;\n\tint\t\tt;\n\n\t// powerup timers going away\n\tfor ( i = 0 ; i < MAX_POWERUPS ; i++ ) {\n\t\tt = cg.snap->ps.powerups[i];\n\t\tif ( t <= cg.time ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( t - cg.time >= POWERUP_BLINKS * POWERUP_BLINK_TIME ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( ( t - cg.time ) / POWERUP_BLINK_TIME != ( t - cg.oldTime ) / POWERUP_BLINK_TIME ) {\n\t\t\ttrap_S_StartSound( NULL, cg.snap->ps.clientNum, CHAN_ITEM, cgs.media.wearOffSound );\n\t\t}\n\t}\n}\n\n/*\n=====================\nCG_AddBufferedSound\n=====================\n*/\nvoid CG_AddBufferedSound( sfxHandle_t sfx ) {\n\tif ( !sfx )\n\t\treturn;\n\tcg.soundBuffer[cg.soundBufferIn] = sfx;\n\tcg.soundBufferIn = (cg.soundBufferIn + 1) % MAX_SOUNDBUFFER;\n\tif (cg.soundBufferIn == cg.soundBufferOut) {\n\t\tcg.soundBufferOut++;\n\t}\n}\n\n/*\n=====================\nCG_PlayBufferedSounds\n=====================\n*/\nstatic void CG_PlayBufferedSounds( void ) {\n\tif ( cg.soundTime < cg.time ) {\n\t\tif (cg.soundBufferOut != cg.soundBufferIn && cg.soundBuffer[cg.soundBufferOut]) {\n\t\t\ttrap_S_StartLocalSound(cg.soundBuffer[cg.soundBufferOut], CHAN_ANNOUNCER);\n\t\t\tcg.soundBuffer[cg.soundBufferOut] = 0;\n\t\t\tcg.soundBufferOut = (cg.soundBufferOut + 1) % MAX_SOUNDBUFFER;\n\t\t\tcg.soundTime = cg.time + 750;\n\t\t}\n\t}\n}\n\n//=========================================================================\n\n/*\n=================\nCG_DrawActiveFrame\n\nGenerates and draws a game scene and status information at the given time.\n=================\n*/\nvoid CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demoPlayback ) {\n\tint\t\tinwater;\n\n\tcg.time = serverTime;\n\tcg.demoPlayback = demoPlayback;\n\n\t// update cvars\n\tCG_UpdateCvars();\n\n\t// if we are only updating the screen as a loading\n\t// pacifier, don't even try to read snapshots\n\tif ( cg.infoScreenText[0] != 0 ) {\n\t\tCG_DrawInformation();\n\t\treturn;\n\t}\n\n\t// any looped sounds will be respecified as entities\n\t// are added to the render list\n\ttrap_S_ClearLoopingSounds(qfalse);\n\n\t// clear all the render lists\n\ttrap_R_ClearScene();\n\n\t// set up cg.snap and possibly cg.nextSnap\n\tCG_ProcessSnapshots();\n\n\t// if we haven't received any snapshots yet, all\n\t// we can draw is the information screen\n\tif ( !cg.snap || ( cg.snap->snapFlags & SNAPFLAG_NOT_ACTIVE ) ) {\n\t\tCG_DrawInformation();\n\t\treturn;\n\t}\n\n\t// let the client system know what our weapon and zoom settings are\n\ttrap_SetUserCmdValue( cg.weaponSelect, cg.zoomSensitivity );\n\n\t// this counter will be bumped for every valid scene we generate\n\tcg.clientFrame++;\n\n\t// update cg.predictedPlayerState\n\tCG_PredictPlayerState();\n\n\t// decide on third person view\n\tcg.renderingThirdPerson = cg_thirdPerson.integer || (cg.snap->ps.stats[STAT_HEALTH] <= 0);\n\n\t// build cg.refdef\n\tinwater = CG_CalcViewValues();\n\n\t// first person blend blobs, done after AnglesToAxis\n\tif ( !cg.renderingThirdPerson ) {\n\t\tCG_DamageBlendBlob();\n\t}\n\n\t// build the render lists\n\tif ( !cg.hyperspace ) {\n\t\tCG_AddPacketEntities();\t\t\t// adter calcViewValues, so predicted player state is correct\n\t\tCG_AddMarks();\n\t\tCG_AddParticles ();\n\t\tCG_AddLocalEntities();\n\t}\n\tCG_AddViewWeapon( &cg.predictedPlayerState );\n\n\t// add buffered sounds\n\tCG_PlayBufferedSounds();\n\n\t// play buffered voice chats\n\tCG_PlayBufferedVoiceChats();\n\n\t// finish up the rest of the refdef\n\tif ( cg.testModelEntity.hModel ) {\n\t\tCG_AddTestModel();\n\t}\n\tcg.refdef.time = cg.time;\n\tmemcpy( cg.refdef.areamask, cg.snap->areamask, sizeof( cg.refdef.areamask ) );\n\n\t// warning sounds when powerup is wearing off\n\tCG_PowerupTimerSounds();\n\n\t// update audio positions\n\ttrap_S_Respatialize( cg.snap->ps.clientNum, cg.refdef.vieworg, cg.refdef.viewaxis, inwater );\n\n\t// make sure the lagometerSample and frame timing isn't done twice when in stereo\n\tif ( stereoView != STEREO_RIGHT ) {\n\t\tcg.frametime = cg.time - cg.oldTime;\n\t\tif ( cg.frametime < 0 ) {\n\t\t\tcg.frametime = 0;\n\t\t}\n\t\tcg.oldTime = cg.time;\n\t\tCG_AddLagometerFrameInfo();\n\t}\n\tif (cg_timescale.value != cg_timescaleFadeEnd.value) {\n\t\tif (cg_timescale.value < cg_timescaleFadeEnd.value) {\n\t\t\tcg_timescale.value += cg_timescaleFadeSpeed.value * ((float)cg.frametime) / 1000;\n\t\t\tif (cg_timescale.value > cg_timescaleFadeEnd.value)\n\t\t\t\tcg_timescale.value = cg_timescaleFadeEnd.value;\n\t\t}\n\t\telse {\n\t\t\tcg_timescale.value -= cg_timescaleFadeSpeed.value * ((float)cg.frametime) / 1000;\n\t\t\tif (cg_timescale.value < cg_timescaleFadeEnd.value)\n\t\t\t\tcg_timescale.value = cg_timescaleFadeEnd.value;\n\t\t}\n\t\tif (cg_timescaleFadeSpeed.value) {\n\t\t\ttrap_Cvar_Set(\"timescale\", va(\"%f\", cg_timescale.value));\n\t\t}\n\t}\n\n\t// actually issue the rendering calls\n\tCG_DrawActive( stereoView );\n\n\tif ( cg_stats.integer ) {\n\t\tCG_Printf( \"cg.clientFrame:%i\\n\", cg.clientFrame );\n\t}\n\n\n}\n\n"
  },
  {
    "path": "code/cgame/cg_weapons.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// cg_weapons.c -- events and effects dealing with weapons\n#include \"cg_local.h\"\n\n/*\n==========================\nCG_MachineGunEjectBrass\n==========================\n*/\nstatic void CG_MachineGunEjectBrass( centity_t *cent ) {\n\tlocalEntity_t\t*le;\n\trefEntity_t\t\t*re;\n\tvec3_t\t\t\tvelocity, xvelocity;\n\tvec3_t\t\t\toffset, xoffset;\n\tfloat\t\t\twaterScale = 1.0f;\n\tvec3_t\t\t\tv[3];\n\n\tif ( cg_brassTime.integer <= 0 ) {\n\t\treturn;\n\t}\n\n\tle = CG_AllocLocalEntity();\n\tre = &le->refEntity;\n\n\tvelocity[0] = 0;\n\tvelocity[1] = -50 + 40 * crandom();\n\tvelocity[2] = 100 + 50 * crandom();\n\n\tle->leType = LE_FRAGMENT;\n\tle->startTime = cg.time;\n\tle->endTime = le->startTime + cg_brassTime.integer + ( cg_brassTime.integer / 4 ) * random();\n\n\tle->pos.trType = TR_GRAVITY;\n\tle->pos.trTime = cg.time - (rand()&15);\n\n\tAnglesToAxis( cent->lerpAngles, v );\n\n\toffset[0] = 8;\n\toffset[1] = -4;\n\toffset[2] = 24;\n\n\txoffset[0] = offset[0] * v[0][0] + offset[1] * v[1][0] + offset[2] * v[2][0];\n\txoffset[1] = offset[0] * v[0][1] + offset[1] * v[1][1] + offset[2] * v[2][1];\n\txoffset[2] = offset[0] * v[0][2] + offset[1] * v[1][2] + offset[2] * v[2][2];\n\tVectorAdd( cent->lerpOrigin, xoffset, re->origin );\n\n\tVectorCopy( re->origin, le->pos.trBase );\n\n\tif ( CG_PointContents( re->origin, -1 ) & CONTENTS_WATER ) {\n\t\twaterScale = 0.10f;\n\t}\n\n\txvelocity[0] = velocity[0] * v[0][0] + velocity[1] * v[1][0] + velocity[2] * v[2][0];\n\txvelocity[1] = velocity[0] * v[0][1] + velocity[1] * v[1][1] + velocity[2] * v[2][1];\n\txvelocity[2] = velocity[0] * v[0][2] + velocity[1] * v[1][2] + velocity[2] * v[2][2];\n\tVectorScale( xvelocity, waterScale, le->pos.trDelta );\n\n\tAxisCopy( axisDefault, re->axis );\n\tre->hModel = cgs.media.machinegunBrassModel;\n\n\tle->bounceFactor = 0.4 * waterScale;\n\n\tle->angles.trType = TR_LINEAR;\n\tle->angles.trTime = cg.time;\n\tle->angles.trBase[0] = rand()&31;\n\tle->angles.trBase[1] = rand()&31;\n\tle->angles.trBase[2] = rand()&31;\n\tle->angles.trDelta[0] = 2;\n\tle->angles.trDelta[1] = 1;\n\tle->angles.trDelta[2] = 0;\n\n\tle->leFlags = LEF_TUMBLE;\n\tle->leBounceSoundType = LEBS_BRASS;\n\tle->leMarkType = LEMT_NONE;\n}\n\n/*\n==========================\nCG_ShotgunEjectBrass\n==========================\n*/\nstatic void CG_ShotgunEjectBrass( centity_t *cent ) {\n\tlocalEntity_t\t*le;\n\trefEntity_t\t\t*re;\n\tvec3_t\t\t\tvelocity, xvelocity;\n\tvec3_t\t\t\toffset, xoffset;\n\tvec3_t\t\t\tv[3];\n\tint\t\t\t\ti;\n\n\tif ( cg_brassTime.integer <= 0 ) {\n\t\treturn;\n\t}\n\n\tfor ( i = 0; i < 2; i++ ) {\n\t\tfloat\twaterScale = 1.0f;\n\n\t\tle = CG_AllocLocalEntity();\n\t\tre = &le->refEntity;\n\n\t\tvelocity[0] = 60 + 60 * crandom();\n\t\tif ( i == 0 ) {\n\t\t\tvelocity[1] = 40 + 10 * crandom();\n\t\t} else {\n\t\t\tvelocity[1] = -40 + 10 * crandom();\n\t\t}\n\t\tvelocity[2] = 100 + 50 * crandom();\n\n\t\tle->leType = LE_FRAGMENT;\n\t\tle->startTime = cg.time;\n\t\tle->endTime = le->startTime + cg_brassTime.integer*3 + cg_brassTime.integer * random();\n\n\t\tle->pos.trType = TR_GRAVITY;\n\t\tle->pos.trTime = cg.time;\n\n\t\tAnglesToAxis( cent->lerpAngles, v );\n\n\t\toffset[0] = 8;\n\t\toffset[1] = 0;\n\t\toffset[2] = 24;\n\n\t\txoffset[0] = offset[0] * v[0][0] + offset[1] * v[1][0] + offset[2] * v[2][0];\n\t\txoffset[1] = offset[0] * v[0][1] + offset[1] * v[1][1] + offset[2] * v[2][1];\n\t\txoffset[2] = offset[0] * v[0][2] + offset[1] * v[1][2] + offset[2] * v[2][2];\n\t\tVectorAdd( cent->lerpOrigin, xoffset, re->origin );\n\t\tVectorCopy( re->origin, le->pos.trBase );\n\t\tif ( CG_PointContents( re->origin, -1 ) & CONTENTS_WATER ) {\n\t\t\twaterScale = 0.10f;\n\t\t}\n\n\t\txvelocity[0] = velocity[0] * v[0][0] + velocity[1] * v[1][0] + velocity[2] * v[2][0];\n\t\txvelocity[1] = velocity[0] * v[0][1] + velocity[1] * v[1][1] + velocity[2] * v[2][1];\n\t\txvelocity[2] = velocity[0] * v[0][2] + velocity[1] * v[1][2] + velocity[2] * v[2][2];\n\t\tVectorScale( xvelocity, waterScale, le->pos.trDelta );\n\n\t\tAxisCopy( axisDefault, re->axis );\n\t\tre->hModel = cgs.media.shotgunBrassModel;\n\t\tle->bounceFactor = 0.3f;\n\n\t\tle->angles.trType = TR_LINEAR;\n\t\tle->angles.trTime = cg.time;\n\t\tle->angles.trBase[0] = rand()&31;\n\t\tle->angles.trBase[1] = rand()&31;\n\t\tle->angles.trBase[2] = rand()&31;\n\t\tle->angles.trDelta[0] = 1;\n\t\tle->angles.trDelta[1] = 0.5;\n\t\tle->angles.trDelta[2] = 0;\n\n\t\tle->leFlags = LEF_TUMBLE;\n\t\tle->leBounceSoundType = LEBS_BRASS;\n\t\tle->leMarkType = LEMT_NONE;\n\t}\n}\n\n\n#ifdef MISSIONPACK\n/*\n==========================\nCG_NailgunEjectBrass\n==========================\n*/\nstatic void CG_NailgunEjectBrass( centity_t *cent ) {\n\tlocalEntity_t\t*smoke;\n\tvec3_t\t\t\torigin;\n\tvec3_t\t\t\tv[3];\n\tvec3_t\t\t\toffset;\n\tvec3_t\t\t\txoffset;\n\tvec3_t\t\t\tup;\n\n\tAnglesToAxis( cent->lerpAngles, v );\n\n\toffset[0] = 0;\n\toffset[1] = -12;\n\toffset[2] = 24;\n\n\txoffset[0] = offset[0] * v[0][0] + offset[1] * v[1][0] + offset[2] * v[2][0];\n\txoffset[1] = offset[0] * v[0][1] + offset[1] * v[1][1] + offset[2] * v[2][1];\n\txoffset[2] = offset[0] * v[0][2] + offset[1] * v[1][2] + offset[2] * v[2][2];\n\tVectorAdd( cent->lerpOrigin, xoffset, origin );\n\n\tVectorSet( up, 0, 0, 64 );\n\n\tsmoke = CG_SmokePuff( origin, up, 32, 1, 1, 1, 0.33f, 700, cg.time, 0, 0, cgs.media.smokePuffShader );\n\t// use the optimized local entity add\n\tsmoke->leType = LE_SCALE_FADE;\n}\n#endif\n\n\n/*\n==========================\nCG_RailTrail\n==========================\n*/\nvoid CG_RailTrail (clientInfo_t *ci, vec3_t start, vec3_t end) {\n\tvec3_t axis[36], move, move2, next_move, vec, temp;\n\tfloat  len;\n\tint    i, j, skip;\n \n\tlocalEntity_t *le;\n\trefEntity_t   *re;\n \n#define RADIUS   4\n#define ROTATION 1\n#define SPACING  5\n \n\tstart[2] -= 4;\n\tVectorCopy (start, move);\n\tVectorSubtract (end, start, vec);\n\tlen = VectorNormalize (vec);\n\tPerpendicularVector(temp, vec);\n\tfor (i = 0 ; i < 36; i++) {\n\t\tRotatePointAroundVector(axis[i], vec, temp, i * 10);//banshee 2.4 was 10\n\t}\n \n\tle = CG_AllocLocalEntity();\n\tre = &le->refEntity;\n \n\tle->leType = LE_FADE_RGB;\n\tle->startTime = cg.time;\n\tle->endTime = cg.time + cg_railTrailTime.value;\n\tle->lifeRate = 1.0 / (le->endTime - le->startTime);\n \n\tre->shaderTime = cg.time / 1000.0f;\n\tre->reType = RT_RAIL_CORE;\n\tre->customShader = cgs.media.railCoreShader;\n \n\tVectorCopy(start, re->origin);\n\tVectorCopy(end, re->oldorigin);\n \n\tre->shaderRGBA[0] = ci->color1[0] * 255;\n    re->shaderRGBA[1] = ci->color1[1] * 255;\n    re->shaderRGBA[2] = ci->color1[2] * 255;\n    re->shaderRGBA[3] = 255;\n\n\tle->color[0] = ci->color1[0] * 0.75;\n\tle->color[1] = ci->color1[1] * 0.75;\n\tle->color[2] = ci->color1[2] * 0.75;\n\tle->color[3] = 1.0f;\n\n\tAxisClear( re->axis );\n \n\tVectorMA(move, 20, vec, move);\n\tVectorCopy(move, next_move);\n\tVectorScale (vec, SPACING, vec);\n\n\tif (cg_oldRail.integer != 0) {\n\t\t// nudge down a bit so it isn't exactly in center\n\t\tre->origin[2] -= 8;\n\t\tre->oldorigin[2] -= 8;\n\t\treturn;\n\t}\n\tskip = -1;\n \n\tj = 18;\n    for (i = 0; i < len; i += SPACING) {\n\t\tif (i != skip) {\n\t\t\tskip = i + SPACING;\n\t\t\tle = CG_AllocLocalEntity();\n            re = &le->refEntity;\n            le->leFlags = LEF_PUFF_DONT_SCALE;\n\t\t\tle->leType = LE_MOVE_SCALE_FADE;\n            le->startTime = cg.time;\n            le->endTime = cg.time + (i>>1) + 600;\n            le->lifeRate = 1.0 / (le->endTime - le->startTime);\n\n            re->shaderTime = cg.time / 1000.0f;\n            re->reType = RT_SPRITE;\n            re->radius = 1.1f;\n\t\t\tre->customShader = cgs.media.railRingsShader;\n\n            re->shaderRGBA[0] = ci->color2[0] * 255;\n            re->shaderRGBA[1] = ci->color2[1] * 255;\n            re->shaderRGBA[2] = ci->color2[2] * 255;\n            re->shaderRGBA[3] = 255;\n\n            le->color[0] = ci->color2[0] * 0.75;\n            le->color[1] = ci->color2[1] * 0.75;\n            le->color[2] = ci->color2[2] * 0.75;\n            le->color[3] = 1.0f;\n\n            le->pos.trType = TR_LINEAR;\n            le->pos.trTime = cg.time;\n\n\t\t\tVectorCopy( move, move2);\n            VectorMA(move2, RADIUS , axis[j], move2);\n            VectorCopy(move2, le->pos.trBase);\n\n            le->pos.trDelta[0] = axis[j][0]*6;\n            le->pos.trDelta[1] = axis[j][1]*6;\n            le->pos.trDelta[2] = axis[j][2]*6;\n\t\t}\n\n        VectorAdd (move, vec, move);\n\n        j = j + ROTATION < 36 ? j + ROTATION : (j + ROTATION) % 36;\n\t}\n}\n\n/*\n==========================\nCG_RocketTrail\n==========================\n*/\nstatic void CG_RocketTrail( centity_t *ent, const weaponInfo_t *wi ) {\n\tint\t\tstep;\n\tvec3_t\torigin, lastPos;\n\tint\t\tt;\n\tint\t\tstartTime, contents;\n\tint\t\tlastContents;\n\tentityState_t\t*es;\n\tvec3_t\tup;\n\tlocalEntity_t\t*smoke;\n\n\tif ( cg_noProjectileTrail.integer ) {\n\t\treturn;\n\t}\n\n\tup[0] = 0;\n\tup[1] = 0;\n\tup[2] = 0;\n\n\tstep = 50;\n\n\tes = &ent->currentState;\n\tstartTime = ent->trailTime;\n\tt = step * ( (startTime + step) / step );\n\n\tBG_EvaluateTrajectory( &es->pos, cg.time, origin );\n\tcontents = CG_PointContents( origin, -1 );\n\n\t// if object (e.g. grenade) is stationary, don't toss up smoke\n\tif ( es->pos.trType == TR_STATIONARY ) {\n\t\tent->trailTime = cg.time;\n\t\treturn;\n\t}\n\n\tBG_EvaluateTrajectory( &es->pos, ent->trailTime, lastPos );\n\tlastContents = CG_PointContents( lastPos, -1 );\n\n\tent->trailTime = cg.time;\n\n\tif ( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ) {\n\t\tif ( contents & lastContents & CONTENTS_WATER ) {\n\t\t\tCG_BubbleTrail( lastPos, origin, 8 );\n\t\t}\n\t\treturn;\n\t}\n\n\tfor ( ; t <= ent->trailTime ; t += step ) {\n\t\tBG_EvaluateTrajectory( &es->pos, t, lastPos );\n\n\t\tsmoke = CG_SmokePuff( lastPos, up, \n\t\t\t\t\t  wi->trailRadius, \n\t\t\t\t\t  1, 1, 1, 0.33f,\n\t\t\t\t\t  wi->wiTrailTime, \n\t\t\t\t\t  t,\n\t\t\t\t\t  0,\n\t\t\t\t\t  0, \n\t\t\t\t\t  cgs.media.smokePuffShader );\n\t\t// use the optimized local entity add\n\t\tsmoke->leType = LE_SCALE_FADE;\n\t}\n\n}\n\n#ifdef MISSIONPACK\n/*\n==========================\nCG_NailTrail\n==========================\n*/\nstatic void CG_NailTrail( centity_t *ent, const weaponInfo_t *wi ) {\n\tint\t\tstep;\n\tvec3_t\torigin, lastPos;\n\tint\t\tt;\n\tint\t\tstartTime, contents;\n\tint\t\tlastContents;\n\tentityState_t\t*es;\n\tvec3_t\tup;\n\tlocalEntity_t\t*smoke;\n\n\tif ( cg_noProjectileTrail.integer ) {\n\t\treturn;\n\t}\n\n\tup[0] = 0;\n\tup[1] = 0;\n\tup[2] = 0;\n\n\tstep = 50;\n\n\tes = &ent->currentState;\n\tstartTime = ent->trailTime;\n\tt = step * ( (startTime + step) / step );\n\n\tBG_EvaluateTrajectory( &es->pos, cg.time, origin );\n\tcontents = CG_PointContents( origin, -1 );\n\n\t// if object (e.g. grenade) is stationary, don't toss up smoke\n\tif ( es->pos.trType == TR_STATIONARY ) {\n\t\tent->trailTime = cg.time;\n\t\treturn;\n\t}\n\n\tBG_EvaluateTrajectory( &es->pos, ent->trailTime, lastPos );\n\tlastContents = CG_PointContents( lastPos, -1 );\n\n\tent->trailTime = cg.time;\n\n\tif ( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ) {\n\t\tif ( contents & lastContents & CONTENTS_WATER ) {\n\t\t\tCG_BubbleTrail( lastPos, origin, 8 );\n\t\t}\n\t\treturn;\n\t}\n\n\tfor ( ; t <= ent->trailTime ; t += step ) {\n\t\tBG_EvaluateTrajectory( &es->pos, t, lastPos );\n\n\t\tsmoke = CG_SmokePuff( lastPos, up, \n\t\t\t\t\t  wi->trailRadius, \n\t\t\t\t\t  1, 1, 1, 0.33f,\n\t\t\t\t\t  wi->wiTrailTime, \n\t\t\t\t\t  t,\n\t\t\t\t\t  0,\n\t\t\t\t\t  0, \n\t\t\t\t\t  cgs.media.nailPuffShader );\n\t\t// use the optimized local entity add\n\t\tsmoke->leType = LE_SCALE_FADE;\n\t}\n\n}\n#endif\n\n/*\n==========================\nCG_NailTrail\n==========================\n*/\nstatic void CG_PlasmaTrail( centity_t *cent, const weaponInfo_t *wi ) {\n\tlocalEntity_t\t*le;\n\trefEntity_t\t\t*re;\n\tentityState_t\t*es;\n\tvec3_t\t\t\tvelocity, xvelocity, origin;\n\tvec3_t\t\t\toffset, xoffset;\n\tvec3_t\t\t\tv[3];\n\tint\t\t\t\tt, startTime, step;\n\n\tfloat\twaterScale = 1.0f;\n\n\tif ( cg_noProjectileTrail.integer || cg_oldPlasma.integer ) {\n\t\treturn;\n\t}\n\n\tstep = 50;\n\n\tes = &cent->currentState;\n\tstartTime = cent->trailTime;\n\tt = step * ( (startTime + step) / step );\n\n\tBG_EvaluateTrajectory( &es->pos, cg.time, origin );\n\n\tle = CG_AllocLocalEntity();\n\tre = &le->refEntity;\n\n\tvelocity[0] = 60 - 120 * crandom();\n\tvelocity[1] = 40 - 80 * crandom();\n\tvelocity[2] = 100 - 200 * crandom();\n\n\tle->leType = LE_MOVE_SCALE_FADE;\n\tle->leFlags = LEF_TUMBLE;\n\tle->leBounceSoundType = LEBS_NONE;\n\tle->leMarkType = LEMT_NONE;\n\n\tle->startTime = cg.time;\n\tle->endTime = le->startTime + 600;\n\n\tle->pos.trType = TR_GRAVITY;\n\tle->pos.trTime = cg.time;\n\n\tAnglesToAxis( cent->lerpAngles, v );\n\n\toffset[0] = 2;\n\toffset[1] = 2;\n\toffset[2] = 2;\n\n\txoffset[0] = offset[0] * v[0][0] + offset[1] * v[1][0] + offset[2] * v[2][0];\n\txoffset[1] = offset[0] * v[0][1] + offset[1] * v[1][1] + offset[2] * v[2][1];\n\txoffset[2] = offset[0] * v[0][2] + offset[1] * v[1][2] + offset[2] * v[2][2];\n\n\tVectorAdd( origin, xoffset, re->origin );\n\tVectorCopy( re->origin, le->pos.trBase );\n\n\tif ( CG_PointContents( re->origin, -1 ) & CONTENTS_WATER ) {\n\t\twaterScale = 0.10f;\n\t}\n\n\txvelocity[0] = velocity[0] * v[0][0] + velocity[1] * v[1][0] + velocity[2] * v[2][0];\n\txvelocity[1] = velocity[0] * v[0][1] + velocity[1] * v[1][1] + velocity[2] * v[2][1];\n\txvelocity[2] = velocity[0] * v[0][2] + velocity[1] * v[1][2] + velocity[2] * v[2][2];\n\tVectorScale( xvelocity, waterScale, le->pos.trDelta );\n\n\tAxisCopy( axisDefault, re->axis );\n    re->shaderTime = cg.time / 1000.0f;\n    re->reType = RT_SPRITE;\n    re->radius = 0.25f;\n\tre->customShader = cgs.media.railRingsShader;\n\tle->bounceFactor = 0.3f;\n\n    re->shaderRGBA[0] = wi->flashDlightColor[0] * 63;\n    re->shaderRGBA[1] = wi->flashDlightColor[1] * 63;\n    re->shaderRGBA[2] = wi->flashDlightColor[2] * 63;\n    re->shaderRGBA[3] = 63;\n\n    le->color[0] = wi->flashDlightColor[0] * 0.2;\n    le->color[1] = wi->flashDlightColor[1] * 0.2;\n    le->color[2] = wi->flashDlightColor[2] * 0.2;\n    le->color[3] = 0.25f;\n\n\tle->angles.trType = TR_LINEAR;\n\tle->angles.trTime = cg.time;\n\tle->angles.trBase[0] = rand()&31;\n\tle->angles.trBase[1] = rand()&31;\n\tle->angles.trBase[2] = rand()&31;\n\tle->angles.trDelta[0] = 1;\n\tle->angles.trDelta[1] = 0.5;\n\tle->angles.trDelta[2] = 0;\n\n}\n/*\n==========================\nCG_GrappleTrail\n==========================\n*/\nvoid CG_GrappleTrail( centity_t *ent, const weaponInfo_t *wi ) {\n\tvec3_t\torigin;\n\tentityState_t\t*es;\n\tvec3_t\t\t\tforward, up;\n\trefEntity_t\t\tbeam;\n\n\tes = &ent->currentState;\n\n\tBG_EvaluateTrajectory( &es->pos, cg.time, origin );\n\tent->trailTime = cg.time;\n\n\tmemset( &beam, 0, sizeof( beam ) );\n\t//FIXME adjust for muzzle position\n\tVectorCopy ( cg_entities[ ent->currentState.otherEntityNum ].lerpOrigin, beam.origin );\n\tbeam.origin[2] += 26;\n\tAngleVectors( cg_entities[ ent->currentState.otherEntityNum ].lerpAngles, forward, NULL, up );\n\tVectorMA( beam.origin, -6, up, beam.origin );\n\tVectorCopy( origin, beam.oldorigin );\n\n\tif (Distance( beam.origin, beam.oldorigin ) < 64 )\n\t\treturn; // Don't draw if close\n\n\tbeam.reType = RT_LIGHTNING;\n\tbeam.customShader = cgs.media.lightningShader;\n\n\tAxisClear( beam.axis );\n\tbeam.shaderRGBA[0] = 0xff;\n\tbeam.shaderRGBA[1] = 0xff;\n\tbeam.shaderRGBA[2] = 0xff;\n\tbeam.shaderRGBA[3] = 0xff;\n\ttrap_R_AddRefEntityToScene( &beam );\n}\n\n/*\n==========================\nCG_GrenadeTrail\n==========================\n*/\nstatic void CG_GrenadeTrail( centity_t *ent, const weaponInfo_t *wi ) {\n\tCG_RocketTrail( ent, wi );\n}\n\n\n/*\n=================\nCG_RegisterWeapon\n\nThe server says this item is used on this level\n=================\n*/\nvoid CG_RegisterWeapon( int weaponNum ) {\n\tweaponInfo_t\t*weaponInfo;\n\tgitem_t\t\t\t*item, *ammo;\n\tchar\t\t\tpath[MAX_QPATH];\n\tvec3_t\t\t\tmins, maxs;\n\tint\t\t\t\ti;\n\n\tweaponInfo = &cg_weapons[weaponNum];\n\n\tif ( weaponNum == 0 ) {\n\t\treturn;\n\t}\n\n\tif ( weaponInfo->registered ) {\n\t\treturn;\n\t}\n\n\tmemset( weaponInfo, 0, sizeof( *weaponInfo ) );\n\tweaponInfo->registered = qtrue;\n\n\tfor ( item = bg_itemlist + 1 ; item->classname ; item++ ) {\n\t\tif ( item->giType == IT_WEAPON && item->giTag == weaponNum ) {\n\t\t\tweaponInfo->item = item;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif ( !item->classname ) {\n\t\tCG_Error( \"Couldn't find weapon %i\", weaponNum );\n\t}\n\tCG_RegisterItemVisuals( item - bg_itemlist );\n\n\t// load cmodel before model so filecache works\n\tweaponInfo->weaponModel = trap_R_RegisterModel( item->world_model[0] );\n\n\t// calc midpoint for rotation\n\ttrap_R_ModelBounds( weaponInfo->weaponModel, mins, maxs );\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tweaponInfo->weaponMidpoint[i] = mins[i] + 0.5 * ( maxs[i] - mins[i] );\n\t}\n\n\tweaponInfo->weaponIcon = trap_R_RegisterShader( item->icon );\n\tweaponInfo->ammoIcon = trap_R_RegisterShader( item->icon );\n\n\tfor ( ammo = bg_itemlist + 1 ; ammo->classname ; ammo++ ) {\n\t\tif ( ammo->giType == IT_AMMO && ammo->giTag == weaponNum ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif ( ammo->classname && ammo->world_model[0] ) {\n\t\tweaponInfo->ammoModel = trap_R_RegisterModel( ammo->world_model[0] );\n\t}\n\n\tstrcpy( path, item->world_model[0] );\n\tCOM_StripExtension( path, path );\n\tstrcat( path, \"_flash.md3\" );\n\tweaponInfo->flashModel = trap_R_RegisterModel( path );\n\n\tstrcpy( path, item->world_model[0] );\n\tCOM_StripExtension( path, path );\n\tstrcat( path, \"_barrel.md3\" );\n\tweaponInfo->barrelModel = trap_R_RegisterModel( path );\n\n\tstrcpy( path, item->world_model[0] );\n\tCOM_StripExtension( path, path );\n\tstrcat( path, \"_hand.md3\" );\n\tweaponInfo->handsModel = trap_R_RegisterModel( path );\n\n\tif ( !weaponInfo->handsModel ) {\n\t\tweaponInfo->handsModel = trap_R_RegisterModel( \"models/weapons2/shotgun/shotgun_hand.md3\" );\n\t}\n\n\tweaponInfo->loopFireSound = qfalse;\n\n\tswitch ( weaponNum ) {\n\tcase WP_GAUNTLET:\n\t\tMAKERGB( weaponInfo->flashDlightColor, 0.6f, 0.6f, 1.0f );\n\t\tweaponInfo->firingSound = trap_S_RegisterSound( \"sound/weapons/melee/fstrun.wav\", qfalse );\n\t\tweaponInfo->flashSound[0] = trap_S_RegisterSound( \"sound/weapons/melee/fstatck.wav\", qfalse );\n\t\tbreak;\n\n\tcase WP_LIGHTNING:\n\t\tMAKERGB( weaponInfo->flashDlightColor, 0.6f, 0.6f, 1.0f );\n\t\tweaponInfo->readySound = trap_S_RegisterSound( \"sound/weapons/melee/fsthum.wav\", qfalse );\n\t\tweaponInfo->firingSound = trap_S_RegisterSound( \"sound/weapons/lightning/lg_hum.wav\", qfalse );\n\n\t\tweaponInfo->flashSound[0] = trap_S_RegisterSound( \"sound/weapons/lightning/lg_fire.wav\", qfalse );\n\t\tcgs.media.lightningShader = trap_R_RegisterShader( \"lightningBoltNew\");\n\t\tcgs.media.lightningExplosionModel = trap_R_RegisterModel( \"models/weaphits/crackle.md3\" );\n\t\tcgs.media.sfx_lghit1 = trap_S_RegisterSound( \"sound/weapons/lightning/lg_hit.wav\", qfalse );\n\t\tcgs.media.sfx_lghit2 = trap_S_RegisterSound( \"sound/weapons/lightning/lg_hit2.wav\", qfalse );\n\t\tcgs.media.sfx_lghit3 = trap_S_RegisterSound( \"sound/weapons/lightning/lg_hit3.wav\", qfalse );\n\n\t\tbreak;\n\n\tcase WP_GRAPPLING_HOOK:\n\t\tMAKERGB( weaponInfo->flashDlightColor, 0.6f, 0.6f, 1.0f );\n\t\tweaponInfo->missileModel = trap_R_RegisterModel( \"models/ammo/rocket/rocket.md3\" );\n\t\tweaponInfo->missileTrailFunc = CG_GrappleTrail;\n\t\tweaponInfo->missileDlight = 200;\n\t\tweaponInfo->wiTrailTime = 2000;\n\t\tweaponInfo->trailRadius = 64;\n\t\tMAKERGB( weaponInfo->missileDlightColor, 1, 0.75f, 0 );\n\t\tweaponInfo->readySound = trap_S_RegisterSound( \"sound/weapons/melee/fsthum.wav\", qfalse );\n\t\tweaponInfo->firingSound = trap_S_RegisterSound( \"sound/weapons/melee/fstrun.wav\", qfalse );\n\t\tbreak;\n\n#ifdef MISSIONPACK\n\tcase WP_CHAINGUN:\n\t\tweaponInfo->firingSound = trap_S_RegisterSound( \"sound/weapons/vulcan/wvulfire.wav\", qfalse );\n\t\tweaponInfo->loopFireSound = qtrue;\n\t\tMAKERGB( weaponInfo->flashDlightColor, 1, 1, 0 );\n\t\tweaponInfo->flashSound[0] = trap_S_RegisterSound( \"sound/weapons/vulcan/vulcanf1b.wav\", qfalse );\n\t\tweaponInfo->flashSound[1] = trap_S_RegisterSound( \"sound/weapons/vulcan/vulcanf2b.wav\", qfalse );\n\t\tweaponInfo->flashSound[2] = trap_S_RegisterSound( \"sound/weapons/vulcan/vulcanf3b.wav\", qfalse );\n\t\tweaponInfo->flashSound[3] = trap_S_RegisterSound( \"sound/weapons/vulcan/vulcanf4b.wav\", qfalse );\n\t\tweaponInfo->ejectBrassFunc = CG_MachineGunEjectBrass;\n\t\tcgs.media.bulletExplosionShader = trap_R_RegisterShader( \"bulletExplosion\" );\n\t\tbreak;\n#endif\n\n\tcase WP_MACHINEGUN:\n\t\tMAKERGB( weaponInfo->flashDlightColor, 1, 1, 0 );\n\t\tweaponInfo->flashSound[0] = trap_S_RegisterSound( \"sound/weapons/machinegun/machgf1b.wav\", qfalse );\n\t\tweaponInfo->flashSound[1] = trap_S_RegisterSound( \"sound/weapons/machinegun/machgf2b.wav\", qfalse );\n\t\tweaponInfo->flashSound[2] = trap_S_RegisterSound( \"sound/weapons/machinegun/machgf3b.wav\", qfalse );\n\t\tweaponInfo->flashSound[3] = trap_S_RegisterSound( \"sound/weapons/machinegun/machgf4b.wav\", qfalse );\n\t\tweaponInfo->ejectBrassFunc = CG_MachineGunEjectBrass;\n\t\tcgs.media.bulletExplosionShader = trap_R_RegisterShader( \"bulletExplosion\" );\n\t\tbreak;\n\n\tcase WP_SHOTGUN:\n\t\tMAKERGB( weaponInfo->flashDlightColor, 1, 1, 0 );\n\t\tweaponInfo->flashSound[0] = trap_S_RegisterSound( \"sound/weapons/shotgun/sshotf1b.wav\", qfalse );\n\t\tweaponInfo->ejectBrassFunc = CG_ShotgunEjectBrass;\n\t\tbreak;\n\n\tcase WP_ROCKET_LAUNCHER:\n\t\tweaponInfo->missileModel = trap_R_RegisterModel( \"models/ammo/rocket/rocket.md3\" );\n\t\tweaponInfo->missileSound = trap_S_RegisterSound( \"sound/weapons/rocket/rockfly.wav\", qfalse );\n\t\tweaponInfo->missileTrailFunc = CG_RocketTrail;\n\t\tweaponInfo->missileDlight = 200;\n\t\tweaponInfo->wiTrailTime = 2000;\n\t\tweaponInfo->trailRadius = 64;\n\t\t\n\t\tMAKERGB( weaponInfo->missileDlightColor, 1, 0.75f, 0 );\n\t\tMAKERGB( weaponInfo->flashDlightColor, 1, 0.75f, 0 );\n\n\t\tweaponInfo->flashSound[0] = trap_S_RegisterSound( \"sound/weapons/rocket/rocklf1a.wav\", qfalse );\n\t\tcgs.media.rocketExplosionShader = trap_R_RegisterShader( \"rocketExplosion\" );\n\t\tbreak;\n\n#ifdef MISSIONPACK\n\tcase WP_PROX_LAUNCHER:\n\t\tweaponInfo->missileModel = trap_R_RegisterModel( \"models/weaphits/proxmine.md3\" );\n\t\tweaponInfo->missileTrailFunc = CG_GrenadeTrail;\n\t\tweaponInfo->wiTrailTime = 700;\n\t\tweaponInfo->trailRadius = 32;\n\t\tMAKERGB( weaponInfo->flashDlightColor, 1, 0.70f, 0 );\n\t\tweaponInfo->flashSound[0] = trap_S_RegisterSound( \"sound/weapons/proxmine/wstbfire.wav\", qfalse );\n\t\tcgs.media.grenadeExplosionShader = trap_R_RegisterShader( \"grenadeExplosion\" );\n\t\tbreak;\n#endif\n\n\tcase WP_GRENADE_LAUNCHER:\n\t\tweaponInfo->missileModel = trap_R_RegisterModel( \"models/ammo/grenade1.md3\" );\n\t\tweaponInfo->missileTrailFunc = CG_GrenadeTrail;\n\t\tweaponInfo->wiTrailTime = 700;\n\t\tweaponInfo->trailRadius = 32;\n\t\tMAKERGB( weaponInfo->flashDlightColor, 1, 0.70f, 0 );\n\t\tweaponInfo->flashSound[0] = trap_S_RegisterSound( \"sound/weapons/grenade/grenlf1a.wav\", qfalse );\n\t\tcgs.media.grenadeExplosionShader = trap_R_RegisterShader( \"grenadeExplosion\" );\n\t\tbreak;\n\n#ifdef MISSIONPACK\n\tcase WP_NAILGUN:\n\t\tweaponInfo->ejectBrassFunc = CG_NailgunEjectBrass;\n\t\tweaponInfo->missileTrailFunc = CG_NailTrail;\n//\t\tweaponInfo->missileSound = trap_S_RegisterSound( \"sound/weapons/nailgun/wnalflit.wav\", qfalse );\n\t\tweaponInfo->trailRadius = 16;\n\t\tweaponInfo->wiTrailTime = 250;\n\t\tweaponInfo->missileModel = trap_R_RegisterModel( \"models/weaphits/nail.md3\" );\n\t\tMAKERGB( weaponInfo->flashDlightColor, 1, 0.75f, 0 );\n\t\tweaponInfo->flashSound[0] = trap_S_RegisterSound( \"sound/weapons/nailgun/wnalfire.wav\", qfalse );\n\t\tbreak;\n#endif\n\n\tcase WP_PLASMAGUN:\n//\t\tweaponInfo->missileModel = cgs.media.invulnerabilityPowerupModel;\n\t\tweaponInfo->missileTrailFunc = CG_PlasmaTrail;\n\t\tweaponInfo->missileSound = trap_S_RegisterSound( \"sound/weapons/plasma/lasfly.wav\", qfalse );\n\t\tMAKERGB( weaponInfo->flashDlightColor, 0.6f, 0.6f, 1.0f );\n\t\tweaponInfo->flashSound[0] = trap_S_RegisterSound( \"sound/weapons/plasma/hyprbf1a.wav\", qfalse );\n\t\tcgs.media.plasmaExplosionShader = trap_R_RegisterShader( \"plasmaExplosion\" );\n\t\tcgs.media.railRingsShader = trap_R_RegisterShader( \"railDisc\" );\n\t\tbreak;\n\n\tcase WP_RAILGUN:\n\t\tweaponInfo->readySound = trap_S_RegisterSound( \"sound/weapons/railgun/rg_hum.wav\", qfalse );\n\t\tMAKERGB( weaponInfo->flashDlightColor, 1, 0.5f, 0 );\n\t\tweaponInfo->flashSound[0] = trap_S_RegisterSound( \"sound/weapons/railgun/railgf1a.wav\", qfalse );\n\t\tcgs.media.railExplosionShader = trap_R_RegisterShader( \"railExplosion\" );\n\t\tcgs.media.railRingsShader = trap_R_RegisterShader( \"railDisc\" );\n\t\tcgs.media.railCoreShader = trap_R_RegisterShader( \"railCore\" );\n\t\tbreak;\n\n\tcase WP_BFG:\n\t\tweaponInfo->readySound = trap_S_RegisterSound( \"sound/weapons/bfg/bfg_hum.wav\", qfalse );\n\t\tMAKERGB( weaponInfo->flashDlightColor, 1, 0.7f, 1 );\n\t\tweaponInfo->flashSound[0] = trap_S_RegisterSound( \"sound/weapons/bfg/bfg_fire.wav\", qfalse );\n\t\tcgs.media.bfgExplosionShader = trap_R_RegisterShader( \"bfgExplosion\" );\n\t\tweaponInfo->missileModel = trap_R_RegisterModel( \"models/weaphits/bfg.md3\" );\n\t\tweaponInfo->missileSound = trap_S_RegisterSound( \"sound/weapons/rocket/rockfly.wav\", qfalse );\n\t\tbreak;\n\n\t default:\n\t\tMAKERGB( weaponInfo->flashDlightColor, 1, 1, 1 );\n\t\tweaponInfo->flashSound[0] = trap_S_RegisterSound( \"sound/weapons/rocket/rocklf1a.wav\", qfalse );\n\t\tbreak;\n\t}\n}\n\n/*\n=================\nCG_RegisterItemVisuals\n\nThe server says this item is used on this level\n=================\n*/\nvoid CG_RegisterItemVisuals( int itemNum ) {\n\titemInfo_t\t\t*itemInfo;\n\tgitem_t\t\t\t*item;\n\n\tif ( itemNum < 0 || itemNum >= bg_numItems ) {\n\t\tCG_Error( \"CG_RegisterItemVisuals: itemNum %d out of range [0-%d]\", itemNum, bg_numItems-1 );\n\t}\n\n\titemInfo = &cg_items[ itemNum ];\n\tif ( itemInfo->registered ) {\n\t\treturn;\n\t}\n\n\titem = &bg_itemlist[ itemNum ];\n\n\tmemset( itemInfo, 0, sizeof( &itemInfo ) );\n\titemInfo->registered = qtrue;\n\n\titemInfo->models[0] = trap_R_RegisterModel( item->world_model[0] );\n\n\titemInfo->icon = trap_R_RegisterShader( item->icon );\n\n\tif ( item->giType == IT_WEAPON ) {\n\t\tCG_RegisterWeapon( item->giTag );\n\t}\n\n\t//\n\t// powerups have an accompanying ring or sphere\n\t//\n\tif ( item->giType == IT_POWERUP || item->giType == IT_HEALTH || \n\t\titem->giType == IT_ARMOR || item->giType == IT_HOLDABLE ) {\n\t\tif ( item->world_model[1] ) {\n\t\t\titemInfo->models[1] = trap_R_RegisterModel( item->world_model[1] );\n\t\t}\n\t}\n}\n\n\n/*\n========================================================================================\n\nVIEW WEAPON\n\n========================================================================================\n*/\n\n/*\n=================\nCG_MapTorsoToWeaponFrame\n\n=================\n*/\nstatic int CG_MapTorsoToWeaponFrame( clientInfo_t *ci, int frame ) {\n\n\t// change weapon\n\tif ( frame >= ci->animations[TORSO_DROP].firstFrame \n\t\t&& frame < ci->animations[TORSO_DROP].firstFrame + 9 ) {\n\t\treturn frame - ci->animations[TORSO_DROP].firstFrame + 6;\n\t}\n\n\t// stand attack\n\tif ( frame >= ci->animations[TORSO_ATTACK].firstFrame \n\t\t&& frame < ci->animations[TORSO_ATTACK].firstFrame + 6 ) {\n\t\treturn 1 + frame - ci->animations[TORSO_ATTACK].firstFrame;\n\t}\n\n\t// stand attack 2\n\tif ( frame >= ci->animations[TORSO_ATTACK2].firstFrame \n\t\t&& frame < ci->animations[TORSO_ATTACK2].firstFrame + 6 ) {\n\t\treturn 1 + frame - ci->animations[TORSO_ATTACK2].firstFrame;\n\t}\n\t\n\treturn 0;\n}\n\n\n/*\n==============\nCG_CalculateWeaponPosition\n==============\n*/\nstatic void CG_CalculateWeaponPosition( vec3_t origin, vec3_t angles ) {\n\tfloat\tscale;\n\tint\t\tdelta;\n\tfloat\tfracsin;\n\n\tVectorCopy( cg.refdef.vieworg, origin );\n\tVectorCopy( cg.refdefViewAngles, angles );\n\n\t// on odd legs, invert some angles\n\tif ( cg.bobcycle & 1 ) {\n\t\tscale = -cg.xyspeed;\n\t} else {\n\t\tscale = cg.xyspeed;\n\t}\n\n\t// gun angles from bobbing\n\tangles[ROLL] += scale * cg.bobfracsin * 0.005;\n\tangles[YAW] += scale * cg.bobfracsin * 0.01;\n\tangles[PITCH] += cg.xyspeed * cg.bobfracsin * 0.005;\n\n\t// drop the weapon when landing\n\tdelta = cg.time - cg.landTime;\n\tif ( delta < LAND_DEFLECT_TIME ) {\n\t\torigin[2] += cg.landChange*0.25 * delta / LAND_DEFLECT_TIME;\n\t} else if ( delta < LAND_DEFLECT_TIME + LAND_RETURN_TIME ) {\n\t\torigin[2] += cg.landChange*0.25 * \n\t\t\t(LAND_DEFLECT_TIME + LAND_RETURN_TIME - delta) / LAND_RETURN_TIME;\n\t}\n\n#if 0\n\t// drop the weapon when stair climbing\n\tdelta = cg.time - cg.stepTime;\n\tif ( delta < STEP_TIME/2 ) {\n\t\torigin[2] -= cg.stepChange*0.25 * delta / (STEP_TIME/2);\n\t} else if ( delta < STEP_TIME ) {\n\t\torigin[2] -= cg.stepChange*0.25 * (STEP_TIME - delta) / (STEP_TIME/2);\n\t}\n#endif\n\n\t// idle drift\n\tscale = cg.xyspeed + 40;\n\tfracsin = sin( cg.time * 0.001 );\n\tangles[ROLL] += scale * fracsin * 0.01;\n\tangles[YAW] += scale * fracsin * 0.01;\n\tangles[PITCH] += scale * fracsin * 0.01;\n}\n\n\n/*\n===============\nCG_LightningBolt\n\nOrigin will be the exact tag point, which is slightly\ndifferent than the muzzle point used for determining hits.\nThe cent should be the non-predicted cent if it is from the player,\nso the endpoint will reflect the simulated strike (lagging the predicted\nangle)\n===============\n*/\nstatic void CG_LightningBolt( centity_t *cent, vec3_t origin ) {\n\ttrace_t  trace;\n\trefEntity_t  beam;\n\tvec3_t   forward;\n\tvec3_t   muzzlePoint, endPoint;\n\n\tif (cent->currentState.weapon != WP_LIGHTNING) {\n\t\treturn;\n\t}\n\n\tmemset( &beam, 0, sizeof( beam ) );\n\n\t// CPMA  \"true\" lightning\n\tif ((cent->currentState.number == cg.predictedPlayerState.clientNum) && (cg_trueLightning.value != 0)) {\n\t\tvec3_t angle;\n\t\tint i;\n\n\t\tfor (i = 0; i < 3; i++) {\n\t\t\tfloat a = cent->lerpAngles[i] - cg.refdefViewAngles[i];\n\t\t\tif (a > 180) {\n\t\t\t\ta -= 360;\n\t\t\t}\n\t\t\tif (a < -180) {\n\t\t\t\ta += 360;\n\t\t\t}\n\n\t\t\tangle[i] = cg.refdefViewAngles[i] + a * (1.0 - cg_trueLightning.value);\n\t\t\tif (angle[i] < 0) {\n\t\t\t\tangle[i] += 360;\n\t\t\t}\n\t\t\tif (angle[i] > 360) {\n\t\t\t\tangle[i] -= 360;\n\t\t\t}\n\t\t}\n\n\t\tAngleVectors(angle, forward, NULL, NULL );\n\t\tVectorCopy(cent->lerpOrigin, muzzlePoint );\n//\t\tVectorCopy(cg.refdef.vieworg, muzzlePoint );\n\t} else {\n\t\t// !CPMA\n\t\tAngleVectors( cent->lerpAngles, forward, NULL, NULL );\n\t\tVectorCopy(cent->lerpOrigin, muzzlePoint );\n\t}\n\n\t// FIXME: crouch\n\tmuzzlePoint[2] += DEFAULT_VIEWHEIGHT;\n\n\tVectorMA( muzzlePoint, 14, forward, muzzlePoint );\n\n\t// project forward by the lightning range\n\tVectorMA( muzzlePoint, LIGHTNING_RANGE, forward, endPoint );\n\n\t// see if it hit a wall\n\tCG_Trace( &trace, muzzlePoint, vec3_origin, vec3_origin, endPoint, \n\t\tcent->currentState.number, MASK_SHOT );\n\n\t// this is the endpoint\n\tVectorCopy( trace.endpos, beam.oldorigin );\n\n\t// use the provided origin, even though it may be slightly\n\t// different than the muzzle origin\n\tVectorCopy( origin, beam.origin );\n\n\tbeam.reType = RT_LIGHTNING;\n\tbeam.customShader = cgs.media.lightningShader;\n\ttrap_R_AddRefEntityToScene( &beam );\n\n\t// add the impact flare if it hit something\n\tif ( trace.fraction < 1.0 ) {\n\t\tvec3_t\tangles;\n\t\tvec3_t\tdir;\n\n\t\tVectorSubtract( beam.oldorigin, beam.origin, dir );\n\t\tVectorNormalize( dir );\n\n\t\tmemset( &beam, 0, sizeof( beam ) );\n\t\tbeam.hModel = cgs.media.lightningExplosionModel;\n\n\t\tVectorMA( trace.endpos, -16, dir, beam.origin );\n\n\t\t// make a random orientation\n\t\tangles[0] = rand() % 360;\n\t\tangles[1] = rand() % 360;\n\t\tangles[2] = rand() % 360;\n\t\tAnglesToAxis( angles, beam.axis );\n\t\ttrap_R_AddRefEntityToScene( &beam );\n\t}\n}\n/*\n\nstatic void CG_LightningBolt( centity_t *cent, vec3_t origin ) {\n\ttrace_t\t\ttrace;\n\trefEntity_t\t\tbeam;\n\tvec3_t\t\t\tforward;\n\tvec3_t\t\t\tmuzzlePoint, endPoint;\n\n\tif ( cent->currentState.weapon != WP_LIGHTNING ) {\n\t\treturn;\n\t}\n\n\tmemset( &beam, 0, sizeof( beam ) );\n\n\t// find muzzle point for this frame\n\tVectorCopy( cent->lerpOrigin, muzzlePoint );\n\tAngleVectors( cent->lerpAngles, forward, NULL, NULL );\n\n\t// FIXME: crouch\n\tmuzzlePoint[2] += DEFAULT_VIEWHEIGHT;\n\n\tVectorMA( muzzlePoint, 14, forward, muzzlePoint );\n\n\t// project forward by the lightning range\n\tVectorMA( muzzlePoint, LIGHTNING_RANGE, forward, endPoint );\n\n\t// see if it hit a wall\n\tCG_Trace( &trace, muzzlePoint, vec3_origin, vec3_origin, endPoint, \n\t\tcent->currentState.number, MASK_SHOT );\n\n\t// this is the endpoint\n\tVectorCopy( trace.endpos, beam.oldorigin );\n\n\t// use the provided origin, even though it may be slightly\n\t// different than the muzzle origin\n\tVectorCopy( origin, beam.origin );\n\n\tbeam.reType = RT_LIGHTNING;\n\tbeam.customShader = cgs.media.lightningShader;\n\ttrap_R_AddRefEntityToScene( &beam );\n\n\t// add the impact flare if it hit something\n\tif ( trace.fraction < 1.0 ) {\n\t\tvec3_t\tangles;\n\t\tvec3_t\tdir;\n\n\t\tVectorSubtract( beam.oldorigin, beam.origin, dir );\n\t\tVectorNormalize( dir );\n\n\t\tmemset( &beam, 0, sizeof( beam ) );\n\t\tbeam.hModel = cgs.media.lightningExplosionModel;\n\n\t\tVectorMA( trace.endpos, -16, dir, beam.origin );\n\n\t\t// make a random orientation\n\t\tangles[0] = rand() % 360;\n\t\tangles[1] = rand() % 360;\n\t\tangles[2] = rand() % 360;\n\t\tAnglesToAxis( angles, beam.axis );\n\t\ttrap_R_AddRefEntityToScene( &beam );\n\t}\n}\n*/\n\n/*\n===============\nCG_SpawnRailTrail\n\nOrigin will be the exact tag point, which is slightly\ndifferent than the muzzle point used for determining hits.\n===============\n*/\nstatic void CG_SpawnRailTrail( centity_t *cent, vec3_t origin ) {\n\tclientInfo_t\t*ci;\n\n\tif ( cent->currentState.weapon != WP_RAILGUN ) {\n\t\treturn;\n\t}\n\tif ( !cent->pe.railgunFlash ) {\n\t\treturn;\n\t}\n\tcent->pe.railgunFlash = qtrue;\n\tci = &cgs.clientinfo[ cent->currentState.clientNum ];\n\tCG_RailTrail( ci, origin, cent->pe.railgunImpact );\n}\n\n\n/*\n======================\nCG_MachinegunSpinAngle\n======================\n*/\n#define\t\tSPIN_SPEED\t0.9\n#define\t\tCOAST_TIME\t1000\nstatic float\tCG_MachinegunSpinAngle( centity_t *cent ) {\n\tint\t\tdelta;\n\tfloat\tangle;\n\tfloat\tspeed;\n\n\tdelta = cg.time - cent->pe.barrelTime;\n\tif ( cent->pe.barrelSpinning ) {\n\t\tangle = cent->pe.barrelAngle + delta * SPIN_SPEED;\n\t} else {\n\t\tif ( delta > COAST_TIME ) {\n\t\t\tdelta = COAST_TIME;\n\t\t}\n\n\t\tspeed = 0.5 * ( SPIN_SPEED + (float)( COAST_TIME - delta ) / COAST_TIME );\n\t\tangle = cent->pe.barrelAngle + delta * speed;\n\t}\n\n\tif ( cent->pe.barrelSpinning == !(cent->currentState.eFlags & EF_FIRING) ) {\n\t\tcent->pe.barrelTime = cg.time;\n\t\tcent->pe.barrelAngle = AngleMod( angle );\n\t\tcent->pe.barrelSpinning = !!(cent->currentState.eFlags & EF_FIRING);\n#ifdef MISSIONPACK\n\t\tif ( cent->currentState.weapon == WP_CHAINGUN && !cent->pe.barrelSpinning ) {\n\t\t\ttrap_S_StartSound( NULL, cent->currentState.number, CHAN_WEAPON, trap_S_RegisterSound( \"sound/weapons/vulcan/wvulwind.wav\", qfalse ) );\n\t\t}\n#endif\n\t}\n\n\treturn angle;\n}\n\n\n/*\n========================\nCG_AddWeaponWithPowerups\n========================\n*/\nstatic void CG_AddWeaponWithPowerups( refEntity_t *gun, int powerups ) {\n\t// add powerup effects\n\tif ( powerups & ( 1 << PW_INVIS ) ) {\n\t\tgun->customShader = cgs.media.invisShader;\n\t\ttrap_R_AddRefEntityToScene( gun );\n\t} else {\n\t\ttrap_R_AddRefEntityToScene( gun );\n\n\t\tif ( powerups & ( 1 << PW_BATTLESUIT ) ) {\n\t\t\tgun->customShader = cgs.media.battleWeaponShader;\n\t\t\ttrap_R_AddRefEntityToScene( gun );\n\t\t}\n\t\tif ( powerups & ( 1 << PW_QUAD ) ) {\n\t\t\tgun->customShader = cgs.media.quadWeaponShader;\n\t\t\ttrap_R_AddRefEntityToScene( gun );\n\t\t}\n\t}\n}\n\n\n/*\n=============\nCG_AddPlayerWeapon\n\nUsed for both the view weapon (ps is valid) and the world modelother character models (ps is NULL)\nThe main player will have this called for BOTH cases, so effects like light and\nsound should only be done on the world model case.\n=============\n*/\nvoid CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent, int team ) {\n\trefEntity_t\tgun;\n\trefEntity_t\tbarrel;\n\trefEntity_t\tflash;\n\tvec3_t\t\tangles;\n\tweapon_t\tweaponNum;\n\tweaponInfo_t\t*weapon;\n\tcentity_t\t*nonPredictedCent;\n//\tint\tcol;\n\n\tweaponNum = cent->currentState.weapon;\n\n\tCG_RegisterWeapon( weaponNum );\n\tweapon = &cg_weapons[weaponNum];\n\n\t// add the weapon\n\tmemset( &gun, 0, sizeof( gun ) );\n\tVectorCopy( parent->lightingOrigin, gun.lightingOrigin );\n\tgun.shadowPlane = parent->shadowPlane;\n\tgun.renderfx = parent->renderfx;\n\n\t// set custom shading for railgun refire rate\n\tif ( ps ) {\n\t\tif ( cg.predictedPlayerState.weapon == WP_RAILGUN \n\t\t\t&& cg.predictedPlayerState.weaponstate == WEAPON_FIRING ) {\n\t\t\tfloat\tf;\n\n\t\t\tf = (float)cg.predictedPlayerState.weaponTime / 1500;\n\t\t\tgun.shaderRGBA[1] = 0;\n\t\t\tgun.shaderRGBA[0] = \n\t\t\tgun.shaderRGBA[2] = 255 * ( 1.0 - f );\n\t\t} else {\n\t\t\tgun.shaderRGBA[0] = 255;\n\t\t\tgun.shaderRGBA[1] = 255;\n\t\t\tgun.shaderRGBA[2] = 255;\n\t\t\tgun.shaderRGBA[3] = 255;\n\t\t}\n\t}\n\n\tgun.hModel = weapon->weaponModel;\n\tif (!gun.hModel) {\n\t\treturn;\n\t}\n\n\tif ( !ps ) {\n\t\t// add weapon ready sound\n\t\tcent->pe.lightningFiring = qfalse;\n\t\tif ( ( cent->currentState.eFlags & EF_FIRING ) && weapon->firingSound ) {\n\t\t\t// lightning gun and guantlet make a different sound when fire is held down\n\t\t\ttrap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, weapon->firingSound );\n\t\t\tcent->pe.lightningFiring = qtrue;\n\t\t} else if ( weapon->readySound ) {\n\t\t\ttrap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, weapon->readySound );\n\t\t}\n\t}\n\n\tCG_PositionEntityOnTag( &gun, parent, parent->hModel, \"tag_weapon\");\n\n\tCG_AddWeaponWithPowerups( &gun, cent->currentState.powerups );\n\n\t// add the spinning barrel\n\tif ( weapon->barrelModel ) {\n\t\tmemset( &barrel, 0, sizeof( barrel ) );\n\t\tVectorCopy( parent->lightingOrigin, barrel.lightingOrigin );\n\t\tbarrel.shadowPlane = parent->shadowPlane;\n\t\tbarrel.renderfx = parent->renderfx;\n\n\t\tbarrel.hModel = weapon->barrelModel;\n\t\tangles[YAW] = 0;\n\t\tangles[PITCH] = 0;\n\t\tangles[ROLL] = CG_MachinegunSpinAngle( cent );\n\t\tAnglesToAxis( angles, barrel.axis );\n\n\t\tCG_PositionRotatedEntityOnTag( &barrel, &gun, weapon->weaponModel, \"tag_barrel\" );\n\n\t\tCG_AddWeaponWithPowerups( &barrel, cent->currentState.powerups );\n\t}\n\n\t// make sure we aren't looking at cg.predictedPlayerEntity for LG\n\tnonPredictedCent = &cg_entities[cent->currentState.clientNum];\n\n\t// if the index of the nonPredictedCent is not the same as the clientNum\n\t// then this is a fake player (like on teh single player podiums), so\n\t// go ahead and use the cent\n\tif( ( nonPredictedCent - cg_entities ) != cent->currentState.clientNum ) {\n\t\tnonPredictedCent = cent;\n\t}\n\n\t// add the flash\n\tif ( ( weaponNum == WP_LIGHTNING || weaponNum == WP_GAUNTLET || weaponNum == WP_GRAPPLING_HOOK )\n\t\t&& ( nonPredictedCent->currentState.eFlags & EF_FIRING ) ) \n\t{\n\t\t// continuous flash\n\t} else {\n\t\t// impulse flash\n\t\tif ( cg.time - cent->muzzleFlashTime > MUZZLE_FLASH_TIME && !cent->pe.railgunFlash ) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\tmemset( &flash, 0, sizeof( flash ) );\n\tVectorCopy( parent->lightingOrigin, flash.lightingOrigin );\n\tflash.shadowPlane = parent->shadowPlane;\n\tflash.renderfx = parent->renderfx;\n\n\tflash.hModel = weapon->flashModel;\n\tif (!flash.hModel) {\n\t\treturn;\n\t}\n\tangles[YAW] = 0;\n\tangles[PITCH] = 0;\n\tangles[ROLL] = crandom() * 10;\n\tAnglesToAxis( angles, flash.axis );\n\n\t// colorize the railgun blast\n\tif ( weaponNum == WP_RAILGUN ) {\n\t\tclientInfo_t\t*ci;\n\n\t\tci = &cgs.clientinfo[ cent->currentState.clientNum ];\n\t\tflash.shaderRGBA[0] = 255 * ci->color1[0];\n\t\tflash.shaderRGBA[1] = 255 * ci->color1[1];\n\t\tflash.shaderRGBA[2] = 255 * ci->color1[2];\n\t}\n\n\tCG_PositionRotatedEntityOnTag( &flash, &gun, weapon->weaponModel, \"tag_flash\");\n\ttrap_R_AddRefEntityToScene( &flash );\n\n\tif ( ps || cg.renderingThirdPerson ||\n\t\tcent->currentState.number != cg.predictedPlayerState.clientNum ) {\n\t\t// add lightning bolt\n\t\tCG_LightningBolt( nonPredictedCent, flash.origin );\n\n\t\t// add rail trail\n\t\tCG_SpawnRailTrail( cent, flash.origin );\n\n\t\tif ( weapon->flashDlightColor[0] || weapon->flashDlightColor[1] || weapon->flashDlightColor[2] ) {\n\t\t\ttrap_R_AddLightToScene( flash.origin, 300 + (rand()&31), weapon->flashDlightColor[0],\n\t\t\t\tweapon->flashDlightColor[1], weapon->flashDlightColor[2] );\n\t\t}\n\t}\n}\n\n/*\n==============\nCG_AddViewWeapon\n\nAdd the weapon, and flash for the player's view\n==============\n*/\nvoid CG_AddViewWeapon( playerState_t *ps ) {\n\trefEntity_t\thand;\n\tcentity_t\t*cent;\n\tclientInfo_t\t*ci;\n\tfloat\t\tfovOffset;\n\tvec3_t\t\tangles;\n\tweaponInfo_t\t*weapon;\n\n\tif ( ps->persistant[PERS_TEAM] == TEAM_SPECTATOR ) {\n\t\treturn;\n\t}\n\n\tif ( ps->pm_type == PM_INTERMISSION ) {\n\t\treturn;\n\t}\n\n\t// no gun if in third person view or a camera is active\n\t//if ( cg.renderingThirdPerson || cg.cameraMode) {\n\tif ( cg.renderingThirdPerson ) {\n\t\treturn;\n\t}\n\n\n\t// allow the gun to be completely removed\n\tif ( !cg_drawGun.integer ) {\n\t\tvec3_t\t\torigin;\n\n\t\tif ( cg.predictedPlayerState.eFlags & EF_FIRING ) {\n\t\t\t// special hack for lightning gun...\n\t\t\tVectorCopy( cg.refdef.vieworg, origin );\n\t\t\tVectorMA( origin, -8, cg.refdef.viewaxis[2], origin );\n\t\t\tCG_LightningBolt( &cg_entities[ps->clientNum], origin );\n\t\t}\n\t\treturn;\n\t}\n\n\t// don't draw if testing a gun model\n\tif ( cg.testGun ) {\n\t\treturn;\n\t}\n\n\t// drop gun lower at higher fov\n\tif ( cg_fov.integer > 90 ) {\n\t\tfovOffset = -0.2 * ( cg_fov.integer - 90 );\n\t} else {\n\t\tfovOffset = 0;\n\t}\n\n\tcent = &cg.predictedPlayerEntity;\t// &cg_entities[cg.snap->ps.clientNum];\n\tCG_RegisterWeapon( ps->weapon );\n\tweapon = &cg_weapons[ ps->weapon ];\n\n\tmemset (&hand, 0, sizeof(hand));\n\n\t// set up gun position\n\tCG_CalculateWeaponPosition( hand.origin, angles );\n\n\tVectorMA( hand.origin, cg_gun_x.value, cg.refdef.viewaxis[0], hand.origin );\n\tVectorMA( hand.origin, cg_gun_y.value, cg.refdef.viewaxis[1], hand.origin );\n\tVectorMA( hand.origin, (cg_gun_z.value+fovOffset), cg.refdef.viewaxis[2], hand.origin );\n\n\tAnglesToAxis( angles, hand.axis );\n\n\t// map torso animations to weapon animations\n\tif ( cg_gun_frame.integer ) {\n\t\t// development tool\n\t\thand.frame = hand.oldframe = cg_gun_frame.integer;\n\t\thand.backlerp = 0;\n\t} else {\n\t\t// get clientinfo for animation map\n\t\tci = &cgs.clientinfo[ cent->currentState.clientNum ];\n\t\thand.frame = CG_MapTorsoToWeaponFrame( ci, cent->pe.torso.frame );\n\t\thand.oldframe = CG_MapTorsoToWeaponFrame( ci, cent->pe.torso.oldFrame );\n\t\thand.backlerp = cent->pe.torso.backlerp;\n\t}\n\n\thand.hModel = weapon->handsModel;\n\thand.renderfx = RF_DEPTHHACK | RF_FIRST_PERSON | RF_MINLIGHT;\n\n\t// add everything onto the hand\n\tCG_AddPlayerWeapon( &hand, ps, &cg.predictedPlayerEntity, ps->persistant[PERS_TEAM] );\n}\n\n/*\n==============================================================================\n\nWEAPON SELECTION\n\n==============================================================================\n*/\n\n/*\n===================\nCG_DrawWeaponSelect\n===================\n*/\nvoid CG_DrawWeaponSelect( void ) {\n\tint\t\ti;\n\tint\t\tbits;\n\tint\t\tcount;\n\tint\t\tx, y, w;\n\tchar\t*name;\n\tfloat\t*color;\n\n\t// don't display if dead\n\tif ( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) {\n\t\treturn;\n\t}\n\n\tcolor = CG_FadeColor( cg.weaponSelectTime, WEAPON_SELECT_TIME );\n\tif ( !color ) {\n\t\treturn;\n\t}\n\ttrap_R_SetColor( color );\n\n\t// showing weapon select clears pickup item display, but not the blend blob\n\tcg.itemPickupTime = 0;\n\n\t// count the number of weapons owned\n\tbits = cg.snap->ps.stats[ STAT_WEAPONS ];\n\tcount = 0;\n\tfor ( i = 1 ; i < 16 ; i++ ) {\n\t\tif ( bits & ( 1 << i ) ) {\n\t\t\tcount++;\n\t\t}\n\t}\n\n\tx = 320 - count * 20;\n\ty = 380;\n\n\tfor ( i = 1 ; i < 16 ; i++ ) {\n\t\tif ( !( bits & ( 1 << i ) ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tCG_RegisterWeapon( i );\n\n\t\t// draw weapon icon\n\t\tCG_DrawPic( x, y, 32, 32, cg_weapons[i].weaponIcon );\n\n\t\t// draw selection marker\n\t\tif ( i == cg.weaponSelect ) {\n\t\t\tCG_DrawPic( x-4, y-4, 40, 40, cgs.media.selectShader );\n\t\t}\n\n\t\t// no ammo cross on top\n\t\tif ( !cg.snap->ps.ammo[ i ] ) {\n\t\t\tCG_DrawPic( x, y, 32, 32, cgs.media.noammoShader );\n\t\t}\n\n\t\tx += 40;\n\t}\n\n\t// draw the selected name\n\tif ( cg_weapons[ cg.weaponSelect ].item ) {\n\t\tname = cg_weapons[ cg.weaponSelect ].item->pickup_name;\n\t\tif ( name ) {\n\t\t\tw = CG_DrawStrlen( name ) * BIGCHAR_WIDTH;\n\t\t\tx = ( SCREEN_WIDTH - w ) / 2;\n\t\t\tCG_DrawBigStringColor(x, y - 22, name, color);\n\t\t}\n\t}\n\n\ttrap_R_SetColor( NULL );\n}\n\n\n/*\n===============\nCG_WeaponSelectable\n===============\n*/\nstatic qboolean CG_WeaponSelectable( int i ) {\n\tif ( !cg.snap->ps.ammo[i] ) {\n\t\treturn qfalse;\n\t}\n\tif ( ! (cg.snap->ps.stats[ STAT_WEAPONS ] & ( 1 << i ) ) ) {\n\t\treturn qfalse;\n\t}\n\n\treturn qtrue;\n}\n\n/*\n===============\nCG_NextWeapon_f\n===============\n*/\nvoid CG_NextWeapon_f( void ) {\n\tint\t\ti;\n\tint\t\toriginal;\n\n\tif ( !cg.snap ) {\n\t\treturn;\n\t}\n\tif ( cg.snap->ps.pm_flags & PMF_FOLLOW ) {\n\t\treturn;\n\t}\n\n\tcg.weaponSelectTime = cg.time;\n\toriginal = cg.weaponSelect;\n\n\tfor ( i = 0 ; i < 16 ; i++ ) {\n\t\tcg.weaponSelect++;\n\t\tif ( cg.weaponSelect == 16 ) {\n\t\t\tcg.weaponSelect = 0;\n\t\t}\n\t\tif ( cg.weaponSelect == WP_GAUNTLET ) {\n\t\t\tcontinue;\t\t// never cycle to gauntlet\n\t\t}\n\t\tif ( CG_WeaponSelectable( cg.weaponSelect ) ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif ( i == 16 ) {\n\t\tcg.weaponSelect = original;\n\t}\n}\n\n/*\n===============\nCG_PrevWeapon_f\n===============\n*/\nvoid CG_PrevWeapon_f( void ) {\n\tint\t\ti;\n\tint\t\toriginal;\n\n\tif ( !cg.snap ) {\n\t\treturn;\n\t}\n\tif ( cg.snap->ps.pm_flags & PMF_FOLLOW ) {\n\t\treturn;\n\t}\n\n\tcg.weaponSelectTime = cg.time;\n\toriginal = cg.weaponSelect;\n\n\tfor ( i = 0 ; i < 16 ; i++ ) {\n\t\tcg.weaponSelect--;\n\t\tif ( cg.weaponSelect == -1 ) {\n\t\t\tcg.weaponSelect = 15;\n\t\t}\n\t\tif ( cg.weaponSelect == WP_GAUNTLET ) {\n\t\t\tcontinue;\t\t// never cycle to gauntlet\n\t\t}\n\t\tif ( CG_WeaponSelectable( cg.weaponSelect ) ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif ( i == 16 ) {\n\t\tcg.weaponSelect = original;\n\t}\n}\n\n/*\n===============\nCG_Weapon_f\n===============\n*/\nvoid CG_Weapon_f( void ) {\n\tint\t\tnum;\n\n\tif ( !cg.snap ) {\n\t\treturn;\n\t}\n\tif ( cg.snap->ps.pm_flags & PMF_FOLLOW ) {\n\t\treturn;\n\t}\n\n\tnum = atoi( CG_Argv( 1 ) );\n\n\tif ( num < 1 || num > 15 ) {\n\t\treturn;\n\t}\n\n\tcg.weaponSelectTime = cg.time;\n\n\tif ( ! ( cg.snap->ps.stats[STAT_WEAPONS] & ( 1 << num ) ) ) {\n\t\treturn;\t\t// don't have the weapon\n\t}\n\n\tcg.weaponSelect = num;\n}\n\n/*\n===================\nCG_OutOfAmmoChange\n\nThe current weapon has just run out of ammo\n===================\n*/\nvoid CG_OutOfAmmoChange( void ) {\n\tint\t\ti;\n\n\tcg.weaponSelectTime = cg.time;\n\n\tfor ( i = 15 ; i > 0 ; i-- ) {\n\t\tif ( CG_WeaponSelectable( i ) ) {\n\t\t\tcg.weaponSelect = i;\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n\n\n/*\n===================================================================================================\n\nWEAPON EVENTS\n\n===================================================================================================\n*/\n\n/*\n================\nCG_FireWeapon\n\nCaused by an EV_FIRE_WEAPON event\n================\n*/\nvoid CG_FireWeapon( centity_t *cent ) {\n\tentityState_t *ent;\n\tint\t\t\t\tc;\n\tweaponInfo_t\t*weap;\n\n\tent = &cent->currentState;\n\tif ( ent->weapon == WP_NONE ) {\n\t\treturn;\n\t}\n\tif ( ent->weapon >= WP_NUM_WEAPONS ) {\n\t\tCG_Error( \"CG_FireWeapon: ent->weapon >= WP_NUM_WEAPONS\" );\n\t\treturn;\n\t}\n\tweap = &cg_weapons[ ent->weapon ];\n\n\t// mark the entity as muzzle flashing, so when it is added it will\n\t// append the flash to the weapon model\n\tcent->muzzleFlashTime = cg.time;\n\n\t// lightning gun only does this this on initial press\n\tif ( ent->weapon == WP_LIGHTNING ) {\n\t\tif ( cent->pe.lightningFiring ) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// play quad sound if needed\n\tif ( cent->currentState.powerups & ( 1 << PW_QUAD ) ) {\n\t\ttrap_S_StartSound (NULL, cent->currentState.number, CHAN_ITEM, cgs.media.quadSound );\n\t}\n\n\t// play a sound\n\tfor ( c = 0 ; c < 4 ; c++ ) {\n\t\tif ( !weap->flashSound[c] ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif ( c > 0 ) {\n\t\tc = rand() % c;\n\t\tif ( weap->flashSound[c] )\n\t\t{\n\t\t\ttrap_S_StartSound( NULL, ent->number, CHAN_WEAPON, weap->flashSound[c] );\n\t\t}\n\t}\n\n\t// do brass ejection\n\tif ( weap->ejectBrassFunc && cg_brassTime.integer > 0 ) {\n\t\tweap->ejectBrassFunc( cent );\n\t}\n}\n\n\n/*\n=================\nCG_MissileHitWall\n\nCaused by an EV_MISSILE_MISS event, or directly by local bullet tracing\n=================\n*/\nvoid CG_MissileHitWall( int weapon, int clientNum, vec3_t origin, vec3_t dir, impactSound_t soundType ) {\n\tqhandle_t\t\tmod;\n\tqhandle_t\t\tmark;\n\tqhandle_t\t\tshader;\n\tsfxHandle_t\t\tsfx;\n\tfloat\t\t\tradius;\n\tfloat\t\t\tlight;\n\tvec3_t\t\t\tlightColor;\n\tlocalEntity_t\t*le;\n\tint\t\t\t\tr;\n\tqboolean\t\talphaFade;\n\tqboolean\t\tisSprite;\n\tint\t\t\t\tduration;\n\tvec3_t\t\t\tsprOrg;\n\tvec3_t\t\t\tsprVel;\n\n\tmark = 0;\n\tradius = 32;\n\tsfx = 0;\n\tmod = 0;\n\tshader = 0;\n\tlight = 0;\n\tlightColor[0] = 1;\n\tlightColor[1] = 1;\n\tlightColor[2] = 0;\n\n\t// set defaults\n\tisSprite = qfalse;\n\tduration = 600;\n\n\tswitch ( weapon ) {\n\tdefault:\n#ifdef MISSIONPACK\n\tcase WP_NAILGUN:\n\t\tif( soundType == IMPACTSOUND_FLESH ) {\n\t\t\tsfx = cgs.media.sfx_nghitflesh;\n\t\t} else if( soundType == IMPACTSOUND_METAL ) {\n\t\t\tsfx = cgs.media.sfx_nghitmetal;\n\t\t} else {\n\t\t\tsfx = cgs.media.sfx_nghit;\n\t\t}\n\t\tmark = cgs.media.holeMarkShader;\n\t\tradius = 12;\n\t\tbreak;\n#endif\n\tcase WP_LIGHTNING:\n\t\t// no explosion at LG impact, it is added with the beam\n\t\tr = rand() & 3;\n\t\tif ( r < 2 ) {\n\t\t\tsfx = cgs.media.sfx_lghit2;\n\t\t} else if ( r == 2 ) {\n\t\t\tsfx = cgs.media.sfx_lghit1;\n\t\t} else {\n\t\t\tsfx = cgs.media.sfx_lghit3;\n\t\t}\n\t\tmark = cgs.media.holeMarkShader;\n\t\tradius = 12;\n\t\tbreak;\n#ifdef MISSIONPACK\n\tcase WP_PROX_LAUNCHER:\n\t\tmod = cgs.media.dishFlashModel;\n\t\tshader = cgs.media.grenadeExplosionShader;\n\t\tsfx = cgs.media.sfx_proxexp;\n\t\tmark = cgs.media.burnMarkShader;\n\t\tradius = 64;\n\t\tlight = 300;\n\t\tisSprite = qtrue;\n\t\tbreak;\n#endif\n\tcase WP_GRENADE_LAUNCHER:\n\t\tmod = cgs.media.dishFlashModel;\n\t\tshader = cgs.media.grenadeExplosionShader;\n\t\tsfx = cgs.media.sfx_rockexp;\n\t\tmark = cgs.media.burnMarkShader;\n\t\tradius = 64;\n\t\tlight = 300;\n\t\tisSprite = qtrue;\n\t\tbreak;\n\tcase WP_ROCKET_LAUNCHER:\n\t\tmod = cgs.media.dishFlashModel;\n\t\tshader = cgs.media.rocketExplosionShader;\n\t\tsfx = cgs.media.sfx_rockexp;\n\t\tmark = cgs.media.burnMarkShader;\n\t\tradius = 64;\n\t\tlight = 300;\n\t\tisSprite = qtrue;\n\t\tduration = 1000;\n\t\tlightColor[0] = 1;\n\t\tlightColor[1] = 0.75;\n\t\tlightColor[2] = 0.0;\n\t\tif (cg_oldRocket.integer == 0) {\n\t\t\t// explosion sprite animation\n\t\t\tVectorMA( origin, 24, dir, sprOrg );\n\t\t\tVectorScale( dir, 64, sprVel );\n\n\t\t\tCG_ParticleExplosion( \"explode1\", sprOrg, sprVel, 1400, 20, 30 );\n\t\t}\n\t\tbreak;\n\tcase WP_RAILGUN:\n\t\tmod = cgs.media.ringFlashModel;\n\t\tshader = cgs.media.railExplosionShader;\n\t\tsfx = cgs.media.sfx_plasmaexp;\n\t\tmark = cgs.media.energyMarkShader;\n\t\tradius = 24;\n\t\tbreak;\n\tcase WP_PLASMAGUN:\n\t\tmod = cgs.media.ringFlashModel;\n\t\tshader = cgs.media.plasmaExplosionShader;\n\t\tsfx = cgs.media.sfx_plasmaexp;\n\t\tmark = cgs.media.energyMarkShader;\n\t\tradius = 16;\n\t\tbreak;\n\tcase WP_BFG:\n\t\tmod = cgs.media.dishFlashModel;\n\t\tshader = cgs.media.bfgExplosionShader;\n\t\tsfx = cgs.media.sfx_rockexp;\n\t\tmark = cgs.media.burnMarkShader;\n\t\tradius = 32;\n\t\tisSprite = qtrue;\n\t\tbreak;\n\tcase WP_SHOTGUN:\n\t\tmod = cgs.media.bulletFlashModel;\n\t\tshader = cgs.media.bulletExplosionShader;\n\t\tmark = cgs.media.bulletMarkShader;\n\t\tsfx = 0;\n\t\tradius = 4;\n\t\tbreak;\n\n#ifdef MISSIONPACK\n\tcase WP_CHAINGUN:\n\t\tmod = cgs.media.bulletFlashModel;\n\t\tif( soundType == IMPACTSOUND_FLESH ) {\n\t\t\tsfx = cgs.media.sfx_chghitflesh;\n\t\t} else if( soundType == IMPACTSOUND_METAL ) {\n\t\t\tsfx = cgs.media.sfx_chghitmetal;\n\t\t} else {\n\t\t\tsfx = cgs.media.sfx_chghit;\n\t\t}\n\t\tmark = cgs.media.bulletMarkShader;\n\n\t\tr = rand() & 3;\n\t\tif ( r < 2 ) {\n\t\t\tsfx = cgs.media.sfx_ric1;\n\t\t} else if ( r == 2 ) {\n\t\t\tsfx = cgs.media.sfx_ric2;\n\t\t} else {\n\t\t\tsfx = cgs.media.sfx_ric3;\n\t\t}\n\n\t\tradius = 8;\n\t\tbreak;\n#endif\n\n\tcase WP_MACHINEGUN:\n\t\tmod = cgs.media.bulletFlashModel;\n\t\tshader = cgs.media.bulletExplosionShader;\n\t\tmark = cgs.media.bulletMarkShader;\n\n\t\tr = rand() & 3;\n\t\tif ( r == 0 ) {\n\t\t\tsfx = cgs.media.sfx_ric1;\n\t\t} else if ( r == 1 ) {\n\t\t\tsfx = cgs.media.sfx_ric2;\n\t\t} else {\n\t\t\tsfx = cgs.media.sfx_ric3;\n\t\t}\n\n\t\tradius = 8;\n\t\tbreak;\n\t}\n\n\tif ( sfx ) {\n\t\ttrap_S_StartSound( origin, ENTITYNUM_WORLD, CHAN_AUTO, sfx );\n\t}\n\n\t//\n\t// create the explosion\n\t//\n\tif ( mod ) {\n\t\tle = CG_MakeExplosion( origin, dir, \n\t\t\t\t\t\t\t   mod,\tshader,\n\t\t\t\t\t\t\t   duration, isSprite );\n\t\tle->light = light;\n\t\tVectorCopy( lightColor, le->lightColor );\n\t\tif ( weapon == WP_RAILGUN ) {\n\t\t\t// colorize with client color\n\t\t\tVectorCopy( cgs.clientinfo[clientNum].color1, le->color );\n\t\t}\n\t}\n\n\t//\n\t// impact mark\n\t//\n\talphaFade = (mark == cgs.media.energyMarkShader);\t// plasma fades alpha, all others fade color\n\tif ( weapon == WP_RAILGUN ) {\n\t\tfloat\t*color;\n\n\t\t// colorize with client color\n\t\tcolor = cgs.clientinfo[clientNum].color2;\n\t\tCG_ImpactMark( mark, origin, dir, random()*360, color[0],color[1], color[2],1, alphaFade, radius, qfalse );\n\t} else {\n\t\tCG_ImpactMark( mark, origin, dir, random()*360, 1,1,1,1, alphaFade, radius, qfalse );\n\t}\n}\n\n\n/*\n=================\nCG_MissileHitPlayer\n=================\n*/\nvoid CG_MissileHitPlayer( int weapon, vec3_t origin, vec3_t dir, int entityNum ) {\n\tCG_Bleed( origin, entityNum );\n\n\t// some weapons will make an explosion with the blood, while\n\t// others will just make the blood\n\tswitch ( weapon ) {\n\tcase WP_GRENADE_LAUNCHER:\n\tcase WP_ROCKET_LAUNCHER:\n#ifdef MISSIONPACK\n\tcase WP_NAILGUN:\n\tcase WP_CHAINGUN:\n\tcase WP_PROX_LAUNCHER:\n#endif\n\t\tCG_MissileHitWall( weapon, 0, origin, dir, IMPACTSOUND_FLESH );\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n}\n\n\n\n/*\n============================================================================\n\nSHOTGUN TRACING\n\n============================================================================\n*/\n\n/*\n================\nCG_ShotgunPellet\n================\n*/\nstatic void CG_ShotgunPellet( vec3_t start, vec3_t end, int skipNum ) {\n\ttrace_t\t\ttr;\n\tint sourceContentType, destContentType;\n\n\tCG_Trace( &tr, start, NULL, NULL, end, skipNum, MASK_SHOT );\n\n\tsourceContentType = trap_CM_PointContents( start, 0 );\n\tdestContentType = trap_CM_PointContents( tr.endpos, 0 );\n\n\t// FIXME: should probably move this cruft into CG_BubbleTrail\n\tif ( sourceContentType == destContentType ) {\n\t\tif ( sourceContentType & CONTENTS_WATER ) {\n\t\t\tCG_BubbleTrail( start, tr.endpos, 32 );\n\t\t}\n\t} else if ( sourceContentType & CONTENTS_WATER ) {\n\t\ttrace_t trace;\n\n\t\ttrap_CM_BoxTrace( &trace, end, start, NULL, NULL, 0, CONTENTS_WATER );\n\t\tCG_BubbleTrail( start, trace.endpos, 32 );\n\t} else if ( destContentType & CONTENTS_WATER ) {\n\t\ttrace_t trace;\n\n\t\ttrap_CM_BoxTrace( &trace, start, end, NULL, NULL, 0, CONTENTS_WATER );\n\t\tCG_BubbleTrail( tr.endpos, trace.endpos, 32 );\n\t}\n\n\tif (  tr.surfaceFlags & SURF_NOIMPACT ) {\n\t\treturn;\n\t}\n\n\tif ( cg_entities[tr.entityNum].currentState.eType == ET_PLAYER ) {\n\t\tCG_MissileHitPlayer( WP_SHOTGUN, tr.endpos, tr.plane.normal, tr.entityNum );\n\t} else {\n\t\tif ( tr.surfaceFlags & SURF_NOIMPACT ) {\n\t\t\t// SURF_NOIMPACT will not make a flame puff or a mark\n\t\t\treturn;\n\t\t}\n\t\tif ( tr.surfaceFlags & SURF_METALSTEPS ) {\n\t\t\tCG_MissileHitWall( WP_SHOTGUN, 0, tr.endpos, tr.plane.normal, IMPACTSOUND_METAL );\n\t\t} else {\n\t\t\tCG_MissileHitWall( WP_SHOTGUN, 0, tr.endpos, tr.plane.normal, IMPACTSOUND_DEFAULT );\n\t\t}\n\t}\n}\n\n/*\n================\nCG_ShotgunPattern\n\nPerform the same traces the server did to locate the\nhit splashes\n================\n*/\nstatic void CG_ShotgunPattern( vec3_t origin, vec3_t origin2, int seed, int otherEntNum ) {\n\tint\t\t\ti;\n\tfloat\t\tr, u;\n\tvec3_t\t\tend;\n\tvec3_t\t\tforward, right, up;\n\n\t// derive the right and up vectors from the forward vector, because\n\t// the client won't have any other information\n\tVectorNormalize2( origin2, forward );\n\tPerpendicularVector( right, forward );\n\tCrossProduct( forward, right, up );\n\n\t// generate the \"random\" spread pattern\n\tfor ( i = 0 ; i < DEFAULT_SHOTGUN_COUNT ; i++ ) {\n\t\tr = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * 16;\n\t\tu = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * 16;\n\t\tVectorMA( origin, 8192 * 16, forward, end);\n\t\tVectorMA (end, r, right, end);\n\t\tVectorMA (end, u, up, end);\n\n\t\tCG_ShotgunPellet( origin, end, otherEntNum );\n\t}\n}\n\n/*\n==============\nCG_ShotgunFire\n==============\n*/\nvoid CG_ShotgunFire( entityState_t *es ) {\n\tvec3_t\tv;\n\tint\t\tcontents;\n\n\tVectorSubtract( es->origin2, es->pos.trBase, v );\n\tVectorNormalize( v );\n\tVectorScale( v, 32, v );\n\tVectorAdd( es->pos.trBase, v, v );\n\tif ( cgs.glconfig.hardwareType != GLHW_RAGEPRO ) {\n\t\t// ragepro can't alpha fade, so don't even bother with smoke\n\t\tvec3_t\t\t\tup;\n\n\t\tcontents = trap_CM_PointContents( es->pos.trBase, 0 );\n\t\tif ( !( contents & CONTENTS_WATER ) ) {\n\t\t\tVectorSet( up, 0, 0, 8 );\n\t\t\tCG_SmokePuff( v, up, 32, 1, 1, 1, 0.33f, 900, cg.time, 0, LEF_PUFF_DONT_SCALE, cgs.media.shotgunSmokePuffShader );\n\t\t}\n\t}\n\tCG_ShotgunPattern( es->pos.trBase, es->origin2, es->eventParm, es->otherEntityNum );\n}\n\n/*\n============================================================================\n\nBULLETS\n\n============================================================================\n*/\n\n\n/*\n===============\nCG_Tracer\n===============\n*/\nvoid CG_Tracer( vec3_t source, vec3_t dest ) {\n\tvec3_t\t\tforward, right;\n\tpolyVert_t\tverts[4];\n\tvec3_t\t\tline;\n\tfloat\t\tlen, begin, end;\n\tvec3_t\t\tstart, finish;\n\tvec3_t\t\tmidpoint;\n\n\t// tracer\n\tVectorSubtract( dest, source, forward );\n\tlen = VectorNormalize( forward );\n\n\t// start at least a little ways from the muzzle\n\tif ( len < 100 ) {\n\t\treturn;\n\t}\n\tbegin = 50 + random() * (len - 60);\n\tend = begin + cg_tracerLength.value;\n\tif ( end > len ) {\n\t\tend = len;\n\t}\n\tVectorMA( source, begin, forward, start );\n\tVectorMA( source, end, forward, finish );\n\n\tline[0] = DotProduct( forward, cg.refdef.viewaxis[1] );\n\tline[1] = DotProduct( forward, cg.refdef.viewaxis[2] );\n\n\tVectorScale( cg.refdef.viewaxis[1], line[1], right );\n\tVectorMA( right, -line[0], cg.refdef.viewaxis[2], right );\n\tVectorNormalize( right );\n\n\tVectorMA( finish, cg_tracerWidth.value, right, verts[0].xyz );\n\tverts[0].st[0] = 0;\n\tverts[0].st[1] = 1;\n\tverts[0].modulate[0] = 255;\n\tverts[0].modulate[1] = 255;\n\tverts[0].modulate[2] = 255;\n\tverts[0].modulate[3] = 255;\n\n\tVectorMA( finish, -cg_tracerWidth.value, right, verts[1].xyz );\n\tverts[1].st[0] = 1;\n\tverts[1].st[1] = 0;\n\tverts[1].modulate[0] = 255;\n\tverts[1].modulate[1] = 255;\n\tverts[1].modulate[2] = 255;\n\tverts[1].modulate[3] = 255;\n\n\tVectorMA( start, -cg_tracerWidth.value, right, verts[2].xyz );\n\tverts[2].st[0] = 1;\n\tverts[2].st[1] = 1;\n\tverts[2].modulate[0] = 255;\n\tverts[2].modulate[1] = 255;\n\tverts[2].modulate[2] = 255;\n\tverts[2].modulate[3] = 255;\n\n\tVectorMA( start, cg_tracerWidth.value, right, verts[3].xyz );\n\tverts[3].st[0] = 0;\n\tverts[3].st[1] = 0;\n\tverts[3].modulate[0] = 255;\n\tverts[3].modulate[1] = 255;\n\tverts[3].modulate[2] = 255;\n\tverts[3].modulate[3] = 255;\n\n\ttrap_R_AddPolyToScene( cgs.media.tracerShader, 4, verts );\n\n\tmidpoint[0] = ( start[0] + finish[0] ) * 0.5;\n\tmidpoint[1] = ( start[1] + finish[1] ) * 0.5;\n\tmidpoint[2] = ( start[2] + finish[2] ) * 0.5;\n\n\t// add the tracer sound\n\ttrap_S_StartSound( midpoint, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.tracerSound );\n\n}\n\n\n/*\n======================\nCG_CalcMuzzlePoint\n======================\n*/\nstatic qboolean\tCG_CalcMuzzlePoint( int entityNum, vec3_t muzzle ) {\n\tvec3_t\t\tforward;\n\tcentity_t\t*cent;\n\tint\t\t\tanim;\n\n\tif ( entityNum == cg.snap->ps.clientNum ) {\n\t\tVectorCopy( cg.snap->ps.origin, muzzle );\n\t\tmuzzle[2] += cg.snap->ps.viewheight;\n\t\tAngleVectors( cg.snap->ps.viewangles, forward, NULL, NULL );\n\t\tVectorMA( muzzle, 14, forward, muzzle );\n\t\treturn qtrue;\n\t}\n\n\tcent = &cg_entities[entityNum];\n\tif ( !cent->currentValid ) {\n\t\treturn qfalse;\n\t}\n\n\tVectorCopy( cent->currentState.pos.trBase, muzzle );\n\n\tAngleVectors( cent->currentState.apos.trBase, forward, NULL, NULL );\n\tanim = cent->currentState.legsAnim & ~ANIM_TOGGLEBIT;\n\tif ( anim == LEGS_WALKCR || anim == LEGS_IDLECR ) {\n\t\tmuzzle[2] += CROUCH_VIEWHEIGHT;\n\t} else {\n\t\tmuzzle[2] += DEFAULT_VIEWHEIGHT;\n\t}\n\n\tVectorMA( muzzle, 14, forward, muzzle );\n\n\treturn qtrue;\n\n}\n\n/*\n======================\nCG_Bullet\n\nRenders bullet effects.\n======================\n*/\nvoid CG_Bullet( vec3_t end, int sourceEntityNum, vec3_t normal, qboolean flesh, int fleshEntityNum ) {\n\ttrace_t trace;\n\tint sourceContentType, destContentType;\n\tvec3_t\t\tstart;\n\n\t// if the shooter is currently valid, calc a source point and possibly\n\t// do trail effects\n\tif ( sourceEntityNum >= 0 && cg_tracerChance.value > 0 ) {\n\t\tif ( CG_CalcMuzzlePoint( sourceEntityNum, start ) ) {\n\t\t\tsourceContentType = trap_CM_PointContents( start, 0 );\n\t\t\tdestContentType = trap_CM_PointContents( end, 0 );\n\n\t\t\t// do a complete bubble trail if necessary\n\t\t\tif ( ( sourceContentType == destContentType ) && ( sourceContentType & CONTENTS_WATER ) ) {\n\t\t\t\tCG_BubbleTrail( start, end, 32 );\n\t\t\t}\n\t\t\t// bubble trail from water into air\n\t\t\telse if ( ( sourceContentType & CONTENTS_WATER ) ) {\n\t\t\t\ttrap_CM_BoxTrace( &trace, end, start, NULL, NULL, 0, CONTENTS_WATER );\n\t\t\t\tCG_BubbleTrail( start, trace.endpos, 32 );\n\t\t\t}\n\t\t\t// bubble trail from air into water\n\t\t\telse if ( ( destContentType & CONTENTS_WATER ) ) {\n\t\t\t\ttrap_CM_BoxTrace( &trace, start, end, NULL, NULL, 0, CONTENTS_WATER );\n\t\t\t\tCG_BubbleTrail( trace.endpos, end, 32 );\n\t\t\t}\n\n\t\t\t// draw a tracer\n\t\t\tif ( random() < cg_tracerChance.value ) {\n\t\t\t\tCG_Tracer( start, end );\n\t\t\t}\n\t\t}\n\t}\n\n\t// impact splash and mark\n\tif ( flesh ) {\n\t\tCG_Bleed( end, fleshEntityNum );\n\t} else {\n\t\tCG_MissileHitWall( WP_MACHINEGUN, 0, end, normal, IMPACTSOUND_DEFAULT );\n\t}\n\n}\n"
  },
  {
    "path": "code/cgame/cgame.bat",
    "content": "rem make sure we have a safe environement\nset LIBRARY=\nset INCLUDE=\n\nmkdir vm\ncd vm\nset cc=lcc -DQ3_VM -DCGAME -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\ui %1\n\n%cc% ../../game/bg_misc.c\n@if errorlevel 1 goto quit\n%cc% ../../game/bg_pmove.c\n@if errorlevel 1 goto quit\n%cc% ../../game/bg_slidemove.c\n@if errorlevel 1 goto quit\n%cc% ../../game/bg_lib.c\n@if errorlevel 1 goto quit\n%cc% ../../game/q_math.c\n@if errorlevel 1 goto quit\n%cc% ../../game/q_shared.c\n@if errorlevel 1 goto quit\n%cc% ../cg_consolecmds.c\n@if errorlevel 1 goto quit\n%cc% ../cg_draw.c\n@if errorlevel 1 goto quit\n%cc% ../cg_drawtools.c\n@if errorlevel 1 goto quit\n%cc% ../cg_effects.c\n@if errorlevel 1 goto quit\n%cc% ../cg_ents.c\n@if errorlevel 1 goto quit\n%cc% ../cg_event.c\n@if errorlevel 1 goto quit\n%cc% ../cg_info.c\n@if errorlevel 1 goto quit\n%cc% ../cg_localents.c\n@if errorlevel 1 goto quit\n%cc% ../cg_main.c\n@if errorlevel 1 goto quit\n%cc% ../cg_marks.c\n@if errorlevel 1 goto quit\n%cc% ../cg_players.c\n@if errorlevel 1 goto quit\n%cc% ../cg_playerstate.c\n@if errorlevel 1 goto quit\n%cc% ../cg_predict.c\n@if errorlevel 1 goto quit\n%cc% ../cg_scoreboard.c\n@if errorlevel 1 goto quit\n%cc% ../cg_servercmds.c\n@if errorlevel 1 goto quit\n%cc% ../cg_snapshot.c\n@if errorlevel 1 goto quit\n%cc% ../cg_view.c\n@if errorlevel 1 goto quit\n%cc% ../cg_weapons.c\n@if errorlevel 1 goto quit\n\n\n\n\nq3asm -f ../cgame\n:quit\ncd ..\n"
  },
  {
    "path": "code/cgame/cgame.def",
    "content": "EXPORTS\n\tvmMain\n\tdllEntry\n"
  },
  {
    "path": "code/cgame/cgame.plg",
    "content": "<html>\n<body>\n<pre>\n<h1>Build Log</h1>\n<h3>\n--------------------Configuration: cgame - Win32 Release--------------------\n</h3>\n<h3>Command Lines</h3>\nCreating temporary file \"C:\\WINNT\\Profiles\\ADMINI~1\\LOCALS~1\\Temp\\RSP4BE.tmp\" with contents\n[\n/nologo /G6 /ML /W4 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /Fp\"Release/cgame.pch\" /YX /Fo\"Release/\" /Fd\"Release/\" /FD /c \n\"D:\\quake3\\MissionPack\\code\\game\\bg_misc.c\"\n\"D:\\quake3\\MissionPack\\code\\game\\bg_pmove.c\"\n\"D:\\quake3\\MissionPack\\code\\game\\bg_slidemove.c\"\n\"D:\\quake3\\MissionPack\\code\\cgame\\cg_consolecmds.c\"\n\"D:\\quake3\\MissionPack\\code\\cgame\\cg_draw.c\"\n\"D:\\quake3\\MissionPack\\code\\cgame\\cg_drawtools.c\"\n\"D:\\quake3\\MissionPack\\code\\cgame\\cg_effects.c\"\n\"D:\\quake3\\MissionPack\\code\\cgame\\cg_ents.c\"\n\"D:\\quake3\\MissionPack\\code\\cgame\\cg_event.c\"\n\"D:\\quake3\\MissionPack\\code\\cgame\\cg_info.c\"\n\"D:\\quake3\\MissionPack\\code\\cgame\\cg_localents.c\"\n\"D:\\quake3\\MissionPack\\code\\cgame\\cg_main.c\"\n\"D:\\quake3\\MissionPack\\code\\cgame\\cg_marks.c\"\n\"D:\\quake3\\MissionPack\\code\\cgame\\cg_players.c\"\n\"D:\\quake3\\MissionPack\\code\\cgame\\cg_playerstate.c\"\n\"D:\\quake3\\MissionPack\\code\\cgame\\cg_predict.c\"\n\"D:\\quake3\\MissionPack\\code\\cgame\\cg_rankings.c\"\n\"D:\\quake3\\MissionPack\\code\\cgame\\cg_scoreboard.c\"\n\"D:\\quake3\\MissionPack\\code\\cgame\\cg_servercmds.c\"\n\"D:\\quake3\\MissionPack\\code\\cgame\\cg_snapshot.c\"\n\"D:\\quake3\\MissionPack\\code\\cgame\\cg_syscalls.c\"\n\"D:\\quake3\\MissionPack\\code\\cgame\\cg_view.c\"\n\"D:\\quake3\\MissionPack\\code\\cgame\\cg_weapons.c\"\n\"D:\\quake3\\MissionPack\\code\\game\\q_math.c\"\n\"D:\\quake3\\MissionPack\\code\\game\\q_shared.c\"\n\"D:\\quake3\\MissionPack\\code\\ui\\ui_shared.c\"\n]\nCreating command line \"cl.exe @C:\\WINNT\\Profiles\\ADMINI~1\\LOCALS~1\\Temp\\RSP4BE.tmp\" \nCreating temporary file \"C:\\WINNT\\Profiles\\ADMINI~1\\LOCALS~1\\Temp\\RSP4BF.tmp\" with contents\n[\n/nologo /base:\"0x30000000\" /subsystem:windows /dll /incremental:no /pdb:\"Release/cgamex86.pdb\" /map:\"Release/cgamex86.map\" /machine:I386 /def:\".\\cgame.def\" /out:\"../Release/cgamex86.dll\" /implib:\"Release/cgamex86.lib\" \n.\\Release\\bg_misc.obj\n.\\Release\\bg_pmove.obj\n.\\Release\\bg_slidemove.obj\n.\\Release\\cg_consolecmds.obj\n.\\Release\\cg_draw.obj\n.\\Release\\cg_drawtools.obj\n.\\Release\\cg_effects.obj\n.\\Release\\cg_ents.obj\n.\\Release\\cg_event.obj\n.\\Release\\cg_info.obj\n.\\Release\\cg_localents.obj\n.\\Release\\cg_main.obj\n.\\Release\\cg_marks.obj\n.\\Release\\cg_players.obj\n.\\Release\\cg_playerstate.obj\n.\\Release\\cg_predict.obj\n.\\Release\\cg_rankings.obj\n.\\Release\\cg_scoreboard.obj\n.\\Release\\cg_servercmds.obj\n.\\Release\\cg_snapshot.obj\n.\\Release\\cg_syscalls.obj\n.\\Release\\cg_view.obj\n.\\Release\\cg_weapons.obj\n.\\Release\\q_math.obj\n.\\Release\\q_shared.obj\n.\\Release\\ui_shared.obj\n]\nCreating command line \"link.exe @C:\\WINNT\\Profiles\\ADMINI~1\\LOCALS~1\\Temp\\RSP4BF.tmp\"\n<h3>Output Window</h3>\nCompiling...\nbg_misc.c\nbg_pmove.c\nD:\\quake3\\MissionPack\\code\\game\\bg_pmove.c(987) : warning C4189: 'shit' : local variable is initialized but not referenced\nD:\\quake3\\MissionPack\\code\\game\\bg_pmove.c(2001) : warning C4505: 'PM_InvulnerabilityMove' : unreferenced local function has been removed\n        D:\\quake3\\MissionPack\\code\\game\\bg_pmove.c(519) : see declaration of 'PM_InvulnerabilityMove'\nbg_slidemove.c\ncg_consolecmds.c\ncg_draw.c\ncg_drawtools.c\ncg_effects.c\ncg_ents.c\ncg_event.c\ncg_info.c\ncg_localents.c\ncg_main.c\nD:\\quake3\\MissionPack\\code\\cgame\\cg_main.c(1819) : warning C4505: 'CG_Cvar_Get' : unreferenced local function has been removed\n        D:\\quake3\\MissionPack\\code\\cgame\\cg_main.c(1513) : see declaration of 'CG_Cvar_Get'\ncg_marks.c\ncg_players.c\nD:\\quake3\\MissionPack\\code\\cgame\\cg_players.c(2209) : warning C4505: 'CG_PlayerTokens' : unreferenced local function has been removed\n        D:\\quake3\\MissionPack\\code\\cgame\\cg_players.c(1371) : see declaration of 'CG_PlayerTokens'\ncg_playerstate.c\ncg_predict.c\ncg_rankings.c\ncg_scoreboard.c\ncg_servercmds.c\ncg_snapshot.c\ncg_syscalls.c\ncg_view.c\ncg_weapons.c\nq_math.c\nq_shared.c\nui_shared.c\nD:\\quake3\\MissionPack\\code\\ui\\ui_shared.c(2223) : warning C4189: 'parent' : local variable is initialized but not referenced\nD:\\quake3\\MissionPack\\code\\ui\\ui_shared.c(3501) : warning C4189: 'collision' : local variable is initialized but not referenced\nD:\\quake3\\MissionPack\\code\\ui\\ui_shared.c(4622) : warning C4505: 'Controls_SetDefaults' : unreferenced local function has been removed\n        D:\\quake3\\MissionPack\\code\\ui\\ui_shared.c(2595) : see declaration of 'Controls_SetDefaults'\nD:\\quake3\\MissionPack\\code\\ui\\ui_shared.c(1540) : warning C4701: local variable 'value' may be used without having been initialized\nD:\\quake3\\MissionPack\\code\\ui\\ui_shared.c(1566) : warning C4701: local variable 'value' may be used without having been initialized\nD:\\quake3\\MissionPack\\code\\ui\\ui_shared.c(1912) : warning C4702: unreachable code\nD:\\quake3\\MissionPack\\code\\ui\\ui_shared.c(4013) : warning C4702: unreachable code\nD:\\quake3\\MissionPack\\code\\ui\\ui_shared.c(4056) : warning C4702: unreachable code\nLinking...\n   Creating library Release/cgamex86.lib and object Release/cgamex86.exp\n\n\n\n<h3>Results</h3>\ncgamex86.dll - 0 error(s), 12 warning(s)\n</pre>\n</body>\n</html>\n"
  },
  {
    "path": "code/cgame/cgame.q3asm",
    "content": "-o \"\\quake3\\baseq3\\vm\\cgame\"\ncg_main\n..\\cg_syscalls\ncg_consolecmds\ncg_draw\ncg_drawtools\ncg_effects\ncg_ents\ncg_event\ncg_info\ncg_localents\ncg_marks\ncg_players\ncg_playerstate\ncg_predict\ncg_scoreboard\ncg_servercmds\ncg_snapshot\ncg_view\ncg_weapons\nbg_slidemove\nbg_pmove\nbg_lib\nbg_misc\nq_math\nq_shared\n"
  },
  {
    "path": "code/cgame/cgame.sh",
    "content": "#!/bin/sh\n\nmkdir -p vm\ncd vm\n\nCC=\"q3lcc -DQ3_VM -DCGAME -S -Wf-target=bytecode -Wf-g -I../../cgame -I../../game -I../../q3_ui\"\n\n$CC ../cg_syscalls.c\n$CC ../../game/bg_misc.c\n$CC ../../game/bg_pmove.c\n$CC ../../game/bg_slidemove.c\n$CC ../../game/bg_lib.c\n$CC ../../game/q_math.c\n$CC ../../game/q_shared.c\n$CC ../cg_consolecmds.c\n$CC ../cg_draw.c\n$CC ../cg_drawtools.c\n$CC ../cg_effects.c\n$CC ../cg_ents.c\n$CC ../cg_event.c\n$CC ../cg_info.c\n$CC ../cg_localents.c\n$CC ../cg_main.c\n$CC ../cg_marks.c\n$CC ../cg_players.c\n$CC ../cg_playerstate.c\n$CC ../cg_predict.c\n$CC ../cg_scoreboard.c\n$CC ../cg_servercmds.c\n$CC ../cg_snapshot.c\n$CC ../cg_view.c\n$CC ../cg_weapons.c\n\nq3asm -f ../cgame\n\ncd ..\n"
  },
  {
    "path": "code/cgame/cgame.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<VisualStudioProject\n\tProjectType=\"Visual C++\"\n\tVersion=\"7.10\"\n\tName=\"cgame\"\n\tSccProjectName=\"&quot;$/MissionPack/code/cgame&quot;, NPAAAAAA\"\n\tSccLocalPath=\".\">\n\t<Platforms>\n\t\t<Platform\n\t\t\tName=\"Win32\"/>\n\t</Platforms>\n\t<Configurations>\n\t\t<Configuration\n\t\t\tName=\"Release TA|Win32\"\n\t\t\tOutputDirectory=\".\\Release_TA\"\n\t\t\tIntermediateDirectory=\".\\Release_TA\"\n\t\t\tConfigurationType=\"2\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tOptimizeForProcessor=\"2\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"4\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release_TA/cgame.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release_TA/\"\n\t\t\t\tObjectFile=\".\\Release_TA/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release_TA/\"\n\t\t\t\tWarningLevel=\"4\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"odbc32.lib odbccp32.lib\"\n\t\t\t\tOutputFile=\"../Release_TA/cgamex86.dll\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tModuleDefinitionFile=\".\\cgame.def\"\n\t\t\t\tProgramDatabaseFile=\".\\Release_TA/cgamex86.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\".\\Release_TA/cgamex86.map\"\n\t\t\t\tSubSystem=\"2\"\n\t\t\t\tBaseAddress=\"0x30000000\"\n\t\t\t\tImportLibrary=\".\\Release_TA/cgamex86.lib\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Release_TA/cgame.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Debug|Win32\"\n\t\t\tOutputDirectory=\".\\Debug\"\n\t\t\tIntermediateDirectory=\".\\Debug\"\n\t\t\tConfigurationType=\"2\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tOptimizeForProcessor=\"1\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Debug/cgame.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug/\"\n\t\t\t\tObjectFile=\".\\Debug/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Debug/\"\n\t\t\t\tBrowseInformation=\"1\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"odbc32.lib odbccp32.lib\"\n\t\t\t\tOutputFile=\"../Debug/cgamex86.dll\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tModuleDefinitionFile=\".\\cgame.def\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\Debug/cgamex86.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\".\\Debug/cgamex86.map\"\n\t\t\t\tSubSystem=\"2\"\n\t\t\t\tBaseAddress=\"0x30000000\"\n\t\t\t\tImportLibrary=\".\\Debug/cgamex86.lib\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Debug/cgame.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Release|Win32\"\n\t\t\tOutputDirectory=\".\\Release\"\n\t\t\tIntermediateDirectory=\".\\Release\"\n\t\t\tConfigurationType=\"2\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tOptimizeForProcessor=\"2\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"4\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release/cgame.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release/\"\n\t\t\t\tObjectFile=\".\\Release/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release/\"\n\t\t\t\tWarningLevel=\"4\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"odbc32.lib odbccp32.lib\"\n\t\t\t\tOutputFile=\"../Release/cgamex86.dll\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tModuleDefinitionFile=\".\\cgame.def\"\n\t\t\t\tProgramDatabaseFile=\".\\Release/cgamex86.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\".\\Release/cgamex86.map\"\n\t\t\t\tSubSystem=\"2\"\n\t\t\t\tBaseAddress=\"0x30000000\"\n\t\t\t\tImportLibrary=\".\\Release/cgamex86.lib\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Release/cgame.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Debug TA|Win32\"\n\t\t\tOutputDirectory=\".\\Debug_TA\"\n\t\t\tIntermediateDirectory=\".\\Debug_TA\"\n\t\t\tConfigurationType=\"2\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tOptimizeForProcessor=\"1\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Debug_TA/cgame.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug_TA/\"\n\t\t\t\tObjectFile=\".\\Debug_TA/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Debug_TA/\"\n\t\t\t\tBrowseInformation=\"1\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"odbc32.lib odbccp32.lib\"\n\t\t\t\tOutputFile=\"..\\Debug_TA\\cgamex86.dll\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tModuleDefinitionFile=\".\\cgame.def\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\Debug_TA/cgamex86.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\".\\Debug_TA/cgamex86.map\"\n\t\t\t\tSubSystem=\"2\"\n\t\t\t\tBaseAddress=\"0x30000000\"\n\t\t\t\tImportLibrary=\".\\Debug_TA/cgamex86.lib\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Debug_TA/cgame.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t</Configurations>\n\t<References>\n\t</References>\n\t<Files>\n\t\t<Filter\n\t\t\tName=\"Source Files\"\n\t\t\tFilter=\"c\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\bg_lib.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\bg_misc.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\bg_pmove.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\bg_slidemove.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_consolecmds.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_draw.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_drawtools.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_effects.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_ents.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_event.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_info.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_localents.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_main.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_marks.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_newDraw.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_players.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_playerstate.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_predict.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_scoreboard.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_servercmds.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_snapshot.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_syscalls.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_view.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_weapons.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\q_math.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\q_shared.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ui\\ui_shared.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Header Files\"\n\t\t\tFilter=\"h\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\bg_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_local.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cg_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\q_shared.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\surfaceflags.h\">\n\t\t\t</File>\n\t\t</Filter>\n\t\t<File\n\t\t\tRelativePath=\"cgame.def\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t</Files>\n\t<Globals>\n\t</Globals>\n</VisualStudioProject>\n"
  },
  {
    "path": "code/cgame/cgame_ta.bat",
    "content": "rem make sure we have a safe environement\nset LIBRARY=\nset INCLUDE=\n\nmkdir vm\ncd vm\nset cc=lcc -DQ3_VM -DMISSIONPACK -DCGAME -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\ui %1\n\n%cc% ../../game/bg_misc.c\n@if errorlevel 1 goto quit\n%cc% ../../game/bg_pmove.c\n@if errorlevel 1 goto quit\n%cc% ../../game/bg_slidemove.c\n@if errorlevel 1 goto quit\n%cc% ../../game/bg_lib.c\n@if errorlevel 1 goto quit\n%cc% ../../game/q_math.c\n@if errorlevel 1 goto quit\n%cc% ../../game/q_shared.c\n@if errorlevel 1 goto quit\n%cc% ../cg_consolecmds.c\n@if errorlevel 1 goto quit\n%cc% ../cg_draw.c\n@if errorlevel 1 goto quit\n%cc% ../cg_drawtools.c\n@if errorlevel 1 goto quit\n%cc% ../cg_effects.c\n@if errorlevel 1 goto quit\n%cc% ../cg_ents.c\n@if errorlevel 1 goto quit\n%cc% ../cg_event.c\n@if errorlevel 1 goto quit\n%cc% ../cg_info.c\n@if errorlevel 1 goto quit\n%cc% ../cg_localents.c\n@if errorlevel 1 goto quit\n%cc% ../cg_main.c\n@if errorlevel 1 goto quit\n%cc% ../cg_marks.c\n@if errorlevel 1 goto quit\n%cc% ../cg_players.c\n@if errorlevel 1 goto quit\n%cc% ../cg_playerstate.c\n@if errorlevel 1 goto quit\n%cc% ../cg_predict.c\n@if errorlevel 1 goto quit\n%cc% ../cg_scoreboard.c\n@if errorlevel 1 goto quit\n%cc% ../cg_servercmds.c\n@if errorlevel 1 goto quit\n%cc% ../cg_snapshot.c\n@if errorlevel 1 goto quit\n%cc% ../cg_view.c\n@if errorlevel 1 goto quit\n%cc% ../cg_weapons.c\n@if errorlevel 1 goto quit\n%cc% ../../ui/ui_shared.c\n@if errorlevel 1 goto quit\n%cc% ../cg_newdraw.c\n@if errorlevel 1 goto quit\n\n\nq3asm -f ../cgame_ta\n:quit\ncd ..\n"
  },
  {
    "path": "code/cgame/cgame_ta.q3asm",
    "content": "-o \"\\quake3\\missionpack\\vm\\cgame\"\ncg_main\n..\\cg_syscalls\ncg_consolecmds\ncg_draw\ncg_drawtools\ncg_effects\ncg_ents\ncg_event\ncg_info\ncg_localents\ncg_marks\ncg_players\ncg_playerstate\ncg_predict\ncg_scoreboard\ncg_servercmds\ncg_snapshot\ncg_view\ncg_weapons\nbg_slidemove\nbg_pmove\nbg_lib\nbg_misc\nq_math\nq_shared\nui_shared\ncg_newdraw\n"
  },
  {
    "path": "code/cgame/cgame_ta.sh",
    "content": "#!/bin/sh\n\nmkdir -p vm\ncd vm\n\nCC=\"q3lcc -DQ3_VM  -DCGAME -DMISSIONPACK -S -Wf-target=bytecode -Wf-g -I../../cgame -I../../game -I../../ui\"\n\n$CC  ../cg_syscalls.c\n$CC ../../game/bg_misc.c\n$CC ../../game/bg_pmove.c\n$CC ../../game/bg_slidemove.c\n$CC ../../game/bg_lib.c\n$CC ../../game/q_math.c\n$CC ../../game/q_shared.c\n$CC ../cg_consolecmds.c\n$CC ../cg_draw.c\n$CC ../cg_drawtools.c\n$CC ../cg_effects.c\n$CC ../cg_ents.c\n$CC ../cg_event.c\n$CC ../cg_info.c\n$CC ../cg_localents.c\n$CC ../cg_main.c\n$CC ../cg_marks.c\n$CC ../cg_players.c\n$CC ../cg_playerstate.c\n$CC ../cg_predict.c\n$CC ../cg_scoreboard.c\n$CC ../cg_servercmds.c\n$CC ../cg_snapshot.c\n$CC ../cg_view.c\n$CC ../cg_weapons.c\n$CC ../../ui/ui_shared.c\n$CC ../cg_newdraw.c\n\nq3asm -f ../cgame_ta\n\ncd ..\n"
  },
  {
    "path": "code/cgame/tr_types.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#ifndef __TR_TYPES_H\n#define __TR_TYPES_H\n\n\n#define\tMAX_DLIGHTS\t\t32\t\t\t// can't be increased, because bit flags are used on surfaces\n#define\tMAX_ENTITIES\t1023\t\t// can't be increased without changing drawsurf bit packing\n\n// renderfx flags\n#define\tRF_MINLIGHT\t\t\t1\t\t// allways have some light (viewmodel, some items)\n#define\tRF_THIRD_PERSON\t\t2\t\t// don't draw through eyes, only mirrors (player bodies, chat sprites)\n#define\tRF_FIRST_PERSON\t\t4\t\t// only draw through eyes (view weapon, damage blood blob)\n#define\tRF_DEPTHHACK\t\t8\t\t// for view weapon Z crunching\n#define\tRF_NOSHADOW\t\t\t64\t\t// don't add stencil shadows\n\n#define RF_LIGHTING_ORIGIN\t128\t\t// use refEntity->lightingOrigin instead of refEntity->origin\n\t\t\t\t\t\t\t\t\t// for lighting.  This allows entities to sink into the floor\n\t\t\t\t\t\t\t\t\t// with their origin going solid, and allows all parts of a\n\t\t\t\t\t\t\t\t\t// player to get the same lighting\n#define\tRF_SHADOW_PLANE\t\t256\t\t// use refEntity->shadowPlane\n#define\tRF_WRAP_FRAMES\t\t512\t\t// mod the model frames by the maxframes to allow continuous\n\t\t\t\t\t\t\t\t\t// animation without needing to know the frame count\n\n// refdef flags\n#define RDF_NOWORLDMODEL\t1\t\t// used for player configuration screen\n#define RDF_HYPERSPACE\t\t4\t\t// teleportation effect\n\ntypedef struct {\n\tvec3_t\t\txyz;\n\tfloat\t\tst[2];\n\tbyte\t\tmodulate[4];\n} polyVert_t;\n\ntypedef struct poly_s {\n\tqhandle_t\t\t\thShader;\n\tint\t\t\t\t\tnumVerts;\n\tpolyVert_t\t\t\t*verts;\n} poly_t;\n\ntypedef enum {\n\tRT_MODEL,\n\tRT_POLY,\n\tRT_SPRITE,\n\tRT_BEAM,\n\tRT_RAIL_CORE,\n\tRT_RAIL_RINGS,\n\tRT_LIGHTNING,\n\tRT_PORTALSURFACE,\t\t// doesn't draw anything, just info for portals\n\n\tRT_MAX_REF_ENTITY_TYPE\n} refEntityType_t;\n\ntypedef struct {\n\trefEntityType_t\treType;\n\tint\t\t\trenderfx;\n\n\tqhandle_t\thModel;\t\t\t\t// opaque type outside refresh\n\n\t// most recent data\n\tvec3_t\t\tlightingOrigin;\t\t// so multi-part models can be lit identically (RF_LIGHTING_ORIGIN)\n\tfloat\t\tshadowPlane;\t\t// projection shadows go here, stencils go slightly lower\n\n\tvec3_t\t\taxis[3];\t\t\t// rotation vectors\n\tqboolean\tnonNormalizedAxes;\t// axis are not normalized, i.e. they have scale\n\tfloat\t\torigin[3];\t\t\t// also used as MODEL_BEAM's \"from\"\n\tint\t\t\tframe;\t\t\t\t// also used as MODEL_BEAM's diameter\n\n\t// previous data for frame interpolation\n\tfloat\t\toldorigin[3];\t\t// also used as MODEL_BEAM's \"to\"\n\tint\t\t\toldframe;\n\tfloat\t\tbacklerp;\t\t\t// 0.0 = current, 1.0 = old\n\n\t// texturing\n\tint\t\t\tskinNum;\t\t\t// inline skin index\n\tqhandle_t\tcustomSkin;\t\t\t// NULL for default skin\n\tqhandle_t\tcustomShader;\t\t// use one image for the entire thing\n\n\t// misc\n\tbyte\t\tshaderRGBA[4];\t\t// colors used by rgbgen entity shaders\n\tfloat\t\tshaderTexCoord[2];\t// texture coordinates used by tcMod entity modifiers\n\tfloat\t\tshaderTime;\t\t\t// subtracted from refdef time to control effect start times\n\n\t// extra sprite information\n\tfloat\t\tradius;\n\tfloat\t\trotation;\n} refEntity_t;\n\n\n#define\tMAX_RENDER_STRINGS\t\t\t8\n#define\tMAX_RENDER_STRING_LENGTH\t32\n\ntypedef struct {\n\tint\t\t\tx, y, width, height;\n\tfloat\t\tfov_x, fov_y;\n\tvec3_t\t\tvieworg;\n\tvec3_t\t\tviewaxis[3];\t\t// transformation matrix\n\n\t// time in milliseconds for shader effects and other time dependent rendering issues\n\tint\t\t\ttime;\n\n\tint\t\t\trdflags;\t\t\t// RDF_NOWORLDMODEL, etc\n\n\t// 1 bits will prevent the associated area from rendering at all\n\tbyte\t\tareamask[MAX_MAP_AREA_BYTES];\n\n\t// text messages for deform text shaders\n\tchar\t\ttext[MAX_RENDER_STRINGS][MAX_RENDER_STRING_LENGTH];\n} refdef_t;\n\n\ntypedef enum {\n\tSTEREO_CENTER,\n\tSTEREO_LEFT,\n\tSTEREO_RIGHT\n} stereoFrame_t;\n\n\n/*\n** glconfig_t\n**\n** Contains variables specific to the OpenGL configuration\n** being run right now.  These are constant once the OpenGL\n** subsystem is initialized.\n*/\ntypedef enum {\n\tTC_NONE,\n\tTC_S3TC\n} textureCompression_t;\n\ntypedef enum {\n\tGLDRV_ICD,\t\t\t\t\t// driver is integrated with window system\n\t\t\t\t\t\t\t\t// WARNING: there are tests that check for\n\t\t\t\t\t\t\t\t// > GLDRV_ICD for minidriverness, so this\n\t\t\t\t\t\t\t\t// should always be the lowest value in this\n\t\t\t\t\t\t\t\t// enum set\n\tGLDRV_STANDALONE,\t\t\t// driver is a non-3Dfx standalone driver\n\tGLDRV_VOODOO\t\t\t\t// driver is a 3Dfx standalone driver\n} glDriverType_t;\n\ntypedef enum {\n\tGLHW_GENERIC,\t\t\t// where everthing works the way it should\n\tGLHW_3DFX_2D3D,\t\t\t// Voodoo Banshee or Voodoo3, relevant since if this is\n\t\t\t\t\t\t\t// the hardware type then there can NOT exist a secondary\n\t\t\t\t\t\t\t// display adapter\n\tGLHW_RIVA128,\t\t\t// where you can't interpolate alpha\n\tGLHW_RAGEPRO,\t\t\t// where you can't modulate alpha on alpha textures\n\tGLHW_PERMEDIA2\t\t\t// where you don't have src*dst\n} glHardwareType_t;\n\ntypedef struct {\n\tchar\t\t\t\t\trenderer_string[MAX_STRING_CHARS];\n\tchar\t\t\t\t\tvendor_string[MAX_STRING_CHARS];\n\tchar\t\t\t\t\tversion_string[MAX_STRING_CHARS];\n\tchar\t\t\t\t\textensions_string[BIG_INFO_STRING];\n\n\tint\t\t\t\t\t\tmaxTextureSize;\t\t\t// queried from GL\n\tint\t\t\t\t\t\tmaxActiveTextures;\t\t// multitexture ability\n\n\tint\t\t\t\t\t\tcolorBits, depthBits, stencilBits;\n\n\tglDriverType_t\t\t\tdriverType;\n\tglHardwareType_t\t\thardwareType;\n\n\tqboolean\t\t\t\tdeviceSupportsGamma;\n\ttextureCompression_t\ttextureCompression;\n\tqboolean\t\t\t\ttextureEnvAddAvailable;\n\n\tint\t\t\t\t\t\tvidWidth, vidHeight;\n\t// aspect is the screen's physical width / height, which may be different\n\t// than scrWidth / scrHeight if the pixels are non-square\n\t// normal screens should be 4/3, but wide aspect monitors may be 16/9\n\tfloat\t\t\t\t\twindowAspect;\n\n\tint\t\t\t\t\t\tdisplayFrequency;\n\n\t// synonymous with \"does rendering consume the entire screen?\", therefore\n\t// a Voodoo or Voodoo2 will have this set to TRUE, as will a Win32 ICD that\n\t// used CDS.\n\tqboolean\t\t\t\tisFullscreen;\n\tqboolean\t\t\t\tstereoEnabled;\n\tqboolean\t\t\t\tsmpActive;\t\t// dual processor\n} glconfig_t;\n\n// FIXME: VM should be OS agnostic .. in theory\n\n/*\n#ifdef Q3_VM\n\n#define _3DFX_DRIVER_NAME\t\"Voodoo\"\n#define OPENGL_DRIVER_NAME\t\"Default\"\n\n#elif defined(_WIN32)\n*/\n\n#if defined(Q3_VM) || defined(_WIN32)\n\n#define _3DFX_DRIVER_NAME\t\"3dfxvgl\"\n#define OPENGL_DRIVER_NAME\t\"opengl32\"\n\n#else\n\n#define _3DFX_DRIVER_NAME\t\"libMesaVoodooGL.so\"\n// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=524\n#define OPENGL_DRIVER_NAME\t\"libGL.so.1\"\n\n#endif\t// !defined _WIN32\n\n#endif\t// __TR_TYPES_H\n"
  },
  {
    "path": "code/cgame.lnt",
    "content": "opts.lnt\n\ngame\\bg_misc.c\ngame\\bg_pmove.c\ngame\\q_math.c\ngame\\q_shared.c\ncgame\\cg_consolecmds.c\ncgame\\cg_draw.c\ncgame\\cg_drawtools.c\ncgame\\cg_effects.c\ncgame\\cg_ents.c\ncgame\\cg_event.c\ncgame\\cg_info.c\ncgame\\cg_localents.c\ncgame\\cg_main.c\ncgame\\cg_marks.c\ncgame\\cg_players.c\ncgame\\cg_playerstate.c\ncgame\\cg_predict.c\ncgame\\cg_scoreboard.c\ncgame\\cg_servercmds.c\ncgame\\cg_snapshot.c\ncgame\\cg_syscalls.c\ncgame\\cg_view.c\ncgame\\cg_weapons.c\n"
  },
  {
    "path": "code/clean.bat",
    "content": "rmdir debug /s /q\nrmdir release /s /q\ndel quake3.ncb\ndel quake3.opt\ndel quake3.plg\ndel quake3.stt\nrmdir cgame\\debug /s /q\nrmdir cgame\\release /s /q\ndel cgame\\cgame.ncb\ndel cgame\\cgame.opt\ndel cgame\\cgame.plg\ndel cgame\\cgame.stt\nrmdir game\\debug /s /q\nrmdir game\\release /s /q\ndel game\\game.ncb\ndel game\\game.opt\ndel game\\game.plg\ndel game\\game.stt\nrmdir ui\\debug /s /q\nrmdir ui\\release /s /q\ndel ui\\ui.ncb\ndel ui\\ui.opt\ndel ui\\ui.plg\ndel ui\\ui.stt\nrmdir renderer\\debug /s /q\nrmdir renderer\\release /s /q\ndel renderer\\renderer.ncb\ndel renderer\\renderer.opt\ndel renderer\\renderer.plg\ndel renderer\\renderer.stt\nrmdir botlib\\debug /s /q\nrmdir botlib\\release /s /q\ndel botlib\\botlib.ncb\ndel botlib\\botlib.opt\ndel botlib\\botlib.plg\ndel botlib\\botlib.stt\nrmdir botlai\\debug /s /q\nrmdir botlai\\release /s /q\ndel botai\\botai.dsp\ndel botai\\botai.plg\nrmdir bspc\\debug /s /q\nrmdir bspc\\release /s /q\ndel bspc\\bspc.exe\ndel bspc\\bspc.log\ndel bspc\\bspc.ncb\ndel bspc\\bspc.opt\ndel bspc\\bspc.pdb\ndel bspc\\bspc.plg\nrmdir unix\\debugi386-glibc /s /q\nrmdir unix\\releasei386-glibc /s /q\nrmdir \"mac\\MacQuake3 Data\" /s /q\nrmdir macosx\\Client\\Q3Test.app /s /q\nrmdir macosx\\Client\\Q3Test.build /s /q\ndel *.o /s\ndel *.obj /s\ndel *.lib /s\ndel *.dll /s\ndel *.ncb /s\ndel *.plg /s\ndel *.map /s\ndel *.opt /s\n"
  },
  {
    "path": "code/client/cl_cgame.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// cl_cgame.c  -- client system interaction with client game\n\n#include \"client.h\"\n\n#include \"../game/botlib.h\"\n\nextern\tbotlib_export_t\t*botlib_export;\n\nextern qboolean loadCamera(const char *name);\nextern void startCamera(int time);\nextern qboolean getCameraInfo(int time, vec3_t *origin, vec3_t *angles);\n\n/*\n====================\nCL_GetGameState\n====================\n*/\nvoid CL_GetGameState( gameState_t *gs ) {\n\t*gs = cl.gameState;\n}\n\n/*\n====================\nCL_GetGlconfig\n====================\n*/\nvoid CL_GetGlconfig( glconfig_t *glconfig ) {\n\t*glconfig = cls.glconfig;\n}\n\n\n/*\n====================\nCL_GetUserCmd\n====================\n*/\nqboolean CL_GetUserCmd( int cmdNumber, usercmd_t *ucmd ) {\n\t// cmds[cmdNumber] is the last properly generated command\n\n\t// can't return anything that we haven't created yet\n\tif ( cmdNumber > cl.cmdNumber ) {\n\t\tCom_Error( ERR_DROP, \"CL_GetUserCmd: %i >= %i\", cmdNumber, cl.cmdNumber );\n\t}\n\n\t// the usercmd has been overwritten in the wrapping\n\t// buffer because it is too far out of date\n\tif ( cmdNumber <= cl.cmdNumber - CMD_BACKUP ) {\n\t\treturn qfalse;\n\t}\n\n\t*ucmd = cl.cmds[ cmdNumber & CMD_MASK ];\n\n\treturn qtrue;\n}\n\nint CL_GetCurrentCmdNumber( void ) {\n\treturn cl.cmdNumber;\n}\n\n\n/*\n====================\nCL_GetParseEntityState\n====================\n*/\nqboolean\tCL_GetParseEntityState( int parseEntityNumber, entityState_t *state ) {\n\t// can't return anything that hasn't been parsed yet\n\tif ( parseEntityNumber >= cl.parseEntitiesNum ) {\n\t\tCom_Error( ERR_DROP, \"CL_GetParseEntityState: %i >= %i\",\n\t\t\tparseEntityNumber, cl.parseEntitiesNum );\n\t}\n\n\t// can't return anything that has been overwritten in the circular buffer\n\tif ( parseEntityNumber <= cl.parseEntitiesNum - MAX_PARSE_ENTITIES ) {\n\t\treturn qfalse;\n\t}\n\n\t*state = cl.parseEntities[ parseEntityNumber & ( MAX_PARSE_ENTITIES - 1 ) ];\n\treturn qtrue;\n}\n\n/*\n====================\nCL_GetCurrentSnapshotNumber\n====================\n*/\nvoid\tCL_GetCurrentSnapshotNumber( int *snapshotNumber, int *serverTime ) {\n\t*snapshotNumber = cl.snap.messageNum;\n\t*serverTime = cl.snap.serverTime;\n}\n\n/*\n====================\nCL_GetSnapshot\n====================\n*/\nqboolean\tCL_GetSnapshot( int snapshotNumber, snapshot_t *snapshot ) {\n\tclSnapshot_t\t*clSnap;\n\tint\t\t\t\ti, count;\n\n\tif ( snapshotNumber > cl.snap.messageNum ) {\n\t\tCom_Error( ERR_DROP, \"CL_GetSnapshot: snapshotNumber > cl.snapshot.messageNum\" );\n\t}\n\n\t// if the frame has fallen out of the circular buffer, we can't return it\n\tif ( cl.snap.messageNum - snapshotNumber >= PACKET_BACKUP ) {\n\t\treturn qfalse;\n\t}\n\n\t// if the frame is not valid, we can't return it\n\tclSnap = &cl.snapshots[snapshotNumber & PACKET_MASK];\n\tif ( !clSnap->valid ) {\n\t\treturn qfalse;\n\t}\n\n\t// if the entities in the frame have fallen out of their\n\t// circular buffer, we can't return it\n\tif ( cl.parseEntitiesNum - clSnap->parseEntitiesNum >= MAX_PARSE_ENTITIES ) {\n\t\treturn qfalse;\n\t}\n\n\t// write the snapshot\n\tsnapshot->snapFlags = clSnap->snapFlags;\n\tsnapshot->serverCommandSequence = clSnap->serverCommandNum;\n\tsnapshot->ping = clSnap->ping;\n\tsnapshot->serverTime = clSnap->serverTime;\n\tCom_Memcpy( snapshot->areamask, clSnap->areamask, sizeof( snapshot->areamask ) );\n\tsnapshot->ps = clSnap->ps;\n\tcount = clSnap->numEntities;\n\tif ( count > MAX_ENTITIES_IN_SNAPSHOT ) {\n\t\tCom_DPrintf( \"CL_GetSnapshot: truncated %i entities to %i\\n\", count, MAX_ENTITIES_IN_SNAPSHOT );\n\t\tcount = MAX_ENTITIES_IN_SNAPSHOT;\n\t}\n\tsnapshot->numEntities = count;\n\tfor ( i = 0 ; i < count ; i++ ) {\n\t\tsnapshot->entities[i] = \n\t\t\tcl.parseEntities[ ( clSnap->parseEntitiesNum + i ) & (MAX_PARSE_ENTITIES-1) ];\n\t}\n\n\t// FIXME: configstring changes and server commands!!!\n\n\treturn qtrue;\n}\n\n/*\n=====================\nCL_SetUserCmdValue\n=====================\n*/\nvoid CL_SetUserCmdValue( int userCmdValue, float sensitivityScale ) {\n\tcl.cgameUserCmdValue = userCmdValue;\n\tcl.cgameSensitivity = sensitivityScale;\n}\n\n/*\n=====================\nCL_AddCgameCommand\n=====================\n*/\nvoid CL_AddCgameCommand( const char *cmdName ) {\n\tCmd_AddCommand( cmdName, NULL );\n}\n\n/*\n=====================\nCL_CgameError\n=====================\n*/\nvoid CL_CgameError( const char *string ) {\n\tCom_Error( ERR_DROP, \"%s\", string );\n}\n\n\n/*\n=====================\nCL_ConfigstringModified\n=====================\n*/\nvoid CL_ConfigstringModified( void ) {\n\tchar\t\t*old, *s;\n\tint\t\t\ti, index;\n\tchar\t\t*dup;\n\tgameState_t\toldGs;\n\tint\t\t\tlen;\n\n\tindex = atoi( Cmd_Argv(1) );\n\tif ( index < 0 || index >= MAX_CONFIGSTRINGS ) {\n\t\tCom_Error( ERR_DROP, \"configstring > MAX_CONFIGSTRINGS\" );\n\t}\n\t// get everything after \"cs <num>\"\n\ts = Cmd_ArgsFrom(2);\n\n\told = cl.gameState.stringData + cl.gameState.stringOffsets[ index ];\n\tif ( !strcmp( old, s ) ) {\n\t\treturn;\t\t// unchanged\n\t}\n\n\t// build the new gameState_t\n\toldGs = cl.gameState;\n\n\tCom_Memset( &cl.gameState, 0, sizeof( cl.gameState ) );\n\n\t// leave the first 0 for uninitialized strings\n\tcl.gameState.dataCount = 1;\n\t\t\n\tfor ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) {\n\t\tif ( i == index ) {\n\t\t\tdup = s;\n\t\t} else {\n\t\t\tdup = oldGs.stringData + oldGs.stringOffsets[ i ];\n\t\t}\n\t\tif ( !dup[0] ) {\n\t\t\tcontinue;\t\t// leave with the default empty string\n\t\t}\n\n\t\tlen = strlen( dup );\n\n\t\tif ( len + 1 + cl.gameState.dataCount > MAX_GAMESTATE_CHARS ) {\n\t\t\tCom_Error( ERR_DROP, \"MAX_GAMESTATE_CHARS exceeded\" );\n\t\t}\n\n\t\t// append it to the gameState string buffer\n\t\tcl.gameState.stringOffsets[ i ] = cl.gameState.dataCount;\n\t\tCom_Memcpy( cl.gameState.stringData + cl.gameState.dataCount, dup, len + 1 );\n\t\tcl.gameState.dataCount += len + 1;\n\t}\n\n\tif ( index == CS_SYSTEMINFO ) {\n\t\t// parse serverId and other cvars\n\t\tCL_SystemInfoChanged();\n\t}\n\n}\n\n\n/*\n===================\nCL_GetServerCommand\n\nSet up argc/argv for the given command\n===================\n*/\nqboolean CL_GetServerCommand( int serverCommandNumber ) {\n\tchar\t*s;\n\tchar\t*cmd;\n\tstatic char bigConfigString[BIG_INFO_STRING];\n\tint argc;\n\n\t// if we have irretrievably lost a reliable command, drop the connection\n\tif ( serverCommandNumber <= clc.serverCommandSequence - MAX_RELIABLE_COMMANDS ) {\n\t\t// when a demo record was started after the client got a whole bunch of\n\t\t// reliable commands then the client never got those first reliable commands\n\t\tif ( clc.demoplaying )\n\t\t\treturn qfalse;\n\t\tCom_Error( ERR_DROP, \"CL_GetServerCommand: a reliable command was cycled out\" );\n\t\treturn qfalse;\n\t}\n\n\tif ( serverCommandNumber > clc.serverCommandSequence ) {\n\t\tCom_Error( ERR_DROP, \"CL_GetServerCommand: requested a command not received\" );\n\t\treturn qfalse;\n\t}\n\n\ts = clc.serverCommands[ serverCommandNumber & ( MAX_RELIABLE_COMMANDS - 1 ) ];\n\tclc.lastExecutedServerCommand = serverCommandNumber;\n\n\tCom_DPrintf( \"serverCommand: %i : %s\\n\", serverCommandNumber, s );\n\nrescan:\n\tCmd_TokenizeString( s );\n\tcmd = Cmd_Argv(0);\n\targc = Cmd_Argc();\n\n\tif ( !strcmp( cmd, \"disconnect\" ) ) {\n\t\t// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=552\n\t\t// allow server to indicate why they were disconnected\n\t\tif ( argc >= 2 )\n\t\t\tCom_Error (ERR_SERVERDISCONNECT, va( \"Server Disconnected - %s\", Cmd_Argv( 1 ) ) );\n\t\telse\n\t\t\tCom_Error (ERR_SERVERDISCONNECT,\"Server disconnected\\n\");\n\t}\n\n\tif ( !strcmp( cmd, \"bcs0\" ) ) {\n\t\tCom_sprintf( bigConfigString, BIG_INFO_STRING, \"cs %s \\\"%s\", Cmd_Argv(1), Cmd_Argv(2) );\n\t\treturn qfalse;\n\t}\n\n\tif ( !strcmp( cmd, \"bcs1\" ) ) {\n\t\ts = Cmd_Argv(2);\n\t\tif( strlen(bigConfigString) + strlen(s) >= BIG_INFO_STRING ) {\n\t\t\tCom_Error( ERR_DROP, \"bcs exceeded BIG_INFO_STRING\" );\n\t\t}\n\t\tstrcat( bigConfigString, s );\n\t\treturn qfalse;\n\t}\n\n\tif ( !strcmp( cmd, \"bcs2\" ) ) {\n\t\ts = Cmd_Argv(2);\n\t\tif( strlen(bigConfigString) + strlen(s) + 1 >= BIG_INFO_STRING ) {\n\t\t\tCom_Error( ERR_DROP, \"bcs exceeded BIG_INFO_STRING\" );\n\t\t}\n\t\tstrcat( bigConfigString, s );\n\t\tstrcat( bigConfigString, \"\\\"\" );\n\t\ts = bigConfigString;\n\t\tgoto rescan;\n\t}\n\n\tif ( !strcmp( cmd, \"cs\" ) ) {\n\t\tCL_ConfigstringModified();\n\t\t// reparse the string, because CL_ConfigstringModified may have done another Cmd_TokenizeString()\n\t\tCmd_TokenizeString( s );\n\t\treturn qtrue;\n\t}\n\n\tif ( !strcmp( cmd, \"map_restart\" ) ) {\n\t\t// clear notify lines and outgoing commands before passing\n\t\t// the restart to the cgame\n\t\tCon_ClearNotify();\n\t\tCom_Memset( cl.cmds, 0, sizeof( cl.cmds ) );\n\t\treturn qtrue;\n\t}\n\n\t// the clientLevelShot command is used during development\n\t// to generate 128*128 screenshots from the intermission\n\t// point of levels for the menu system to use\n\t// we pass it along to the cgame to make apropriate adjustments,\n\t// but we also clear the console and notify lines here\n\tif ( !strcmp( cmd, \"clientLevelShot\" ) ) {\n\t\t// don't do it if we aren't running the server locally,\n\t\t// otherwise malicious remote servers could overwrite\n\t\t// the existing thumbnails\n\t\tif ( !com_sv_running->integer ) {\n\t\t\treturn qfalse;\n\t\t}\n\t\t// close the console\n\t\tCon_Close();\n\t\t// take a special screenshot next frame\n\t\tCbuf_AddText( \"wait ; wait ; wait ; wait ; screenshot levelshot\\n\" );\n\t\treturn qtrue;\n\t}\n\n\t// we may want to put a \"connect to other server\" command here\n\n\t// cgame can now act on the command\n\treturn qtrue;\n}\n\n\n/*\n====================\nCL_CM_LoadMap\n\nJust adds default parameters that cgame doesn't need to know about\n====================\n*/\nvoid CL_CM_LoadMap( const char *mapname ) {\n\tint\t\tchecksum;\n\n\tCM_LoadMap( mapname, qtrue, &checksum );\n}\n\n/*\n====================\nCL_ShutdonwCGame\n\n====================\n*/\nvoid CL_ShutdownCGame( void ) {\n\tcls.keyCatchers &= ~KEYCATCH_CGAME;\n\tcls.cgameStarted = qfalse;\n\tif ( !cgvm ) {\n\t\treturn;\n\t}\n\tVM_Call( cgvm, CG_SHUTDOWN );\n\tVM_Free( cgvm );\n\tcgvm = NULL;\n}\n\nstatic int\tFloatAsInt( float f ) {\n\tint\t\ttemp;\n\n\t*(float *)&temp = f;\n\n\treturn temp;\n}\n\n/*\n====================\nCL_CgameSystemCalls\n\nThe cgame module is making a system call\n====================\n*/\n#define\tVMA(x) VM_ArgPtr(args[x])\n#define\tVMF(x)\t((float *)args)[x]\nint CL_CgameSystemCalls( int *args ) {\n\tswitch( args[0] ) {\n\tcase CG_PRINT:\n\t\tCom_Printf( \"%s\", VMA(1) );\n\t\treturn 0;\n\tcase CG_ERROR:\n\t\tCom_Error( ERR_DROP, \"%s\", VMA(1) );\n\t\treturn 0;\n\tcase CG_MILLISECONDS:\n\t\treturn Sys_Milliseconds();\n\tcase CG_CVAR_REGISTER:\n\t\tCvar_Register( VMA(1), VMA(2), VMA(3), args[4] ); \n\t\treturn 0;\n\tcase CG_CVAR_UPDATE:\n\t\tCvar_Update( VMA(1) );\n\t\treturn 0;\n\tcase CG_CVAR_SET:\n\t\tCvar_Set( VMA(1), VMA(2) );\n\t\treturn 0;\n\tcase CG_CVAR_VARIABLESTRINGBUFFER:\n\t\tCvar_VariableStringBuffer( VMA(1), VMA(2), args[3] );\n\t\treturn 0;\n\tcase CG_ARGC:\n\t\treturn Cmd_Argc();\n\tcase CG_ARGV:\n\t\tCmd_ArgvBuffer( args[1], VMA(2), args[3] );\n\t\treturn 0;\n\tcase CG_ARGS:\n\t\tCmd_ArgsBuffer( VMA(1), args[2] );\n\t\treturn 0;\n\tcase CG_FS_FOPENFILE:\n\t\treturn FS_FOpenFileByMode( VMA(1), VMA(2), args[3] );\n\tcase CG_FS_READ:\n\t\tFS_Read2( VMA(1), args[2], args[3] );\n\t\treturn 0;\n\tcase CG_FS_WRITE:\n\t\tFS_Write( VMA(1), args[2], args[3] );\n\t\treturn 0;\n\tcase CG_FS_FCLOSEFILE:\n\t\tFS_FCloseFile( args[1] );\n\t\treturn 0;\n\tcase CG_FS_SEEK:\n\t\treturn FS_Seek( args[1], args[2], args[3] );\n\tcase CG_SENDCONSOLECOMMAND:\n\t\tCbuf_AddText( VMA(1) );\n\t\treturn 0;\n\tcase CG_ADDCOMMAND:\n\t\tCL_AddCgameCommand( VMA(1) );\n\t\treturn 0;\n\tcase CG_REMOVECOMMAND:\n\t\tCmd_RemoveCommand( VMA(1) );\n\t\treturn 0;\n\tcase CG_SENDCLIENTCOMMAND:\n\t\tCL_AddReliableCommand( VMA(1) );\n\t\treturn 0;\n\tcase CG_UPDATESCREEN:\n\t\t// this is used during lengthy level loading, so pump message loop\n//\t\tCom_EventLoop();\t// FIXME: if a server restarts here, BAD THINGS HAPPEN!\n// We can't call Com_EventLoop here, a restart will crash and this _does_ happen\n// if there is a map change while we are downloading at pk3.\n// ZOID\n\t\tSCR_UpdateScreen();\n\t\treturn 0;\n\tcase CG_CM_LOADMAP:\n\t\tCL_CM_LoadMap( VMA(1) );\n\t\treturn 0;\n\tcase CG_CM_NUMINLINEMODELS:\n\t\treturn CM_NumInlineModels();\n\tcase CG_CM_INLINEMODEL:\n\t\treturn CM_InlineModel( args[1] );\n\tcase CG_CM_TEMPBOXMODEL:\n\t\treturn CM_TempBoxModel( VMA(1), VMA(2), /*int capsule*/ qfalse );\n\tcase CG_CM_TEMPCAPSULEMODEL:\n\t\treturn CM_TempBoxModel( VMA(1), VMA(2), /*int capsule*/ qtrue );\n\tcase CG_CM_POINTCONTENTS:\n\t\treturn CM_PointContents( VMA(1), args[2] );\n\tcase CG_CM_TRANSFORMEDPOINTCONTENTS:\n\t\treturn CM_TransformedPointContents( VMA(1), args[2], VMA(3), VMA(4) );\n\tcase CG_CM_BOXTRACE:\n\t\tCM_BoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule*/ qfalse );\n\t\treturn 0;\n\tcase CG_CM_CAPSULETRACE:\n\t\tCM_BoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule*/ qtrue );\n\t\treturn 0;\n\tcase CG_CM_TRANSFORMEDBOXTRACE:\n\t\tCM_TransformedBoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], VMA(8), VMA(9), /*int capsule*/ qfalse );\n\t\treturn 0;\n\tcase CG_CM_TRANSFORMEDCAPSULETRACE:\n\t\tCM_TransformedBoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], VMA(8), VMA(9), /*int capsule*/ qtrue );\n\t\treturn 0;\n\tcase CG_CM_MARKFRAGMENTS:\n\t\treturn re.MarkFragments( args[1], VMA(2), VMA(3), args[4], VMA(5), args[6], VMA(7) );\n\tcase CG_S_STARTSOUND:\n\t\tS_StartSound( VMA(1), args[2], args[3], args[4] );\n\t\treturn 0;\n\tcase CG_S_STARTLOCALSOUND:\n\t\tS_StartLocalSound( args[1], args[2] );\n\t\treturn 0;\n\tcase CG_S_CLEARLOOPINGSOUNDS:\n\t\tS_ClearLoopingSounds(args[1]);\n\t\treturn 0;\n\tcase CG_S_ADDLOOPINGSOUND:\n\t\tS_AddLoopingSound( args[1], VMA(2), VMA(3), args[4] );\n\t\treturn 0;\n\tcase CG_S_ADDREALLOOPINGSOUND:\n\t\tS_AddRealLoopingSound( args[1], VMA(2), VMA(3), args[4] );\n\t\treturn 0;\n\tcase CG_S_STOPLOOPINGSOUND:\n\t\tS_StopLoopingSound( args[1] );\n\t\treturn 0;\n\tcase CG_S_UPDATEENTITYPOSITION:\n\t\tS_UpdateEntityPosition( args[1], VMA(2) );\n\t\treturn 0;\n\tcase CG_S_RESPATIALIZE:\n\t\tS_Respatialize( args[1], VMA(2), VMA(3), args[4] );\n\t\treturn 0;\n\tcase CG_S_REGISTERSOUND:\n\t\treturn S_RegisterSound( VMA(1), args[2] );\n\tcase CG_S_STARTBACKGROUNDTRACK:\n\t\tS_StartBackgroundTrack( VMA(1), VMA(2) );\n\t\treturn 0;\n\tcase CG_R_LOADWORLDMAP:\n\t\tre.LoadWorld( VMA(1) );\n\t\treturn 0; \n\tcase CG_R_REGISTERMODEL:\n\t\treturn re.RegisterModel( VMA(1) );\n\tcase CG_R_REGISTERSKIN:\n\t\treturn re.RegisterSkin( VMA(1) );\n\tcase CG_R_REGISTERSHADER:\n\t\treturn re.RegisterShader( VMA(1) );\n\tcase CG_R_REGISTERSHADERNOMIP:\n\t\treturn re.RegisterShaderNoMip( VMA(1) );\n\tcase CG_R_REGISTERFONT:\n\t\tre.RegisterFont( VMA(1), args[2], VMA(3));\n\tcase CG_R_CLEARSCENE:\n\t\tre.ClearScene();\n\t\treturn 0;\n\tcase CG_R_ADDREFENTITYTOSCENE:\n\t\tre.AddRefEntityToScene( VMA(1) );\n\t\treturn 0;\n\tcase CG_R_ADDPOLYTOSCENE:\n\t\tre.AddPolyToScene( args[1], args[2], VMA(3), 1 );\n\t\treturn 0;\n\tcase CG_R_ADDPOLYSTOSCENE:\n\t\tre.AddPolyToScene( args[1], args[2], VMA(3), args[4] );\n\t\treturn 0;\n\tcase CG_R_LIGHTFORPOINT:\n\t\treturn re.LightForPoint( VMA(1), VMA(2), VMA(3), VMA(4) );\n\tcase CG_R_ADDLIGHTTOSCENE:\n\t\tre.AddLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) );\n\t\treturn 0;\n\tcase CG_R_ADDADDITIVELIGHTTOSCENE:\n\t\tre.AddAdditiveLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) );\n\t\treturn 0;\n\tcase CG_R_RENDERSCENE:\n\t\tre.RenderScene( VMA(1) );\n\t\treturn 0;\n\tcase CG_R_SETCOLOR:\n\t\tre.SetColor( VMA(1) );\n\t\treturn 0;\n\tcase CG_R_DRAWSTRETCHPIC:\n\t\tre.DrawStretchPic( VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9] );\n\t\treturn 0;\n\tcase CG_R_MODELBOUNDS:\n\t\tre.ModelBounds( args[1], VMA(2), VMA(3) );\n\t\treturn 0;\n\tcase CG_R_LERPTAG:\n\t\treturn re.LerpTag( VMA(1), args[2], args[3], args[4], VMF(5), VMA(6) );\n\tcase CG_GETGLCONFIG:\n\t\tCL_GetGlconfig( VMA(1) );\n\t\treturn 0;\n\tcase CG_GETGAMESTATE:\n\t\tCL_GetGameState( VMA(1) );\n\t\treturn 0;\n\tcase CG_GETCURRENTSNAPSHOTNUMBER:\n\t\tCL_GetCurrentSnapshotNumber( VMA(1), VMA(2) );\n\t\treturn 0;\n\tcase CG_GETSNAPSHOT:\n\t\treturn CL_GetSnapshot( args[1], VMA(2) );\n\tcase CG_GETSERVERCOMMAND:\n\t\treturn CL_GetServerCommand( args[1] );\n\tcase CG_GETCURRENTCMDNUMBER:\n\t\treturn CL_GetCurrentCmdNumber();\n\tcase CG_GETUSERCMD:\n\t\treturn CL_GetUserCmd( args[1], VMA(2) );\n\tcase CG_SETUSERCMDVALUE:\n\t\tCL_SetUserCmdValue( args[1], VMF(2) );\n\t\treturn 0;\n\tcase CG_MEMORY_REMAINING:\n\t\treturn Hunk_MemoryRemaining();\n  case CG_KEY_ISDOWN:\n\t\treturn Key_IsDown( args[1] );\n  case CG_KEY_GETCATCHER:\n\t\treturn Key_GetCatcher();\n  case CG_KEY_SETCATCHER:\n\t\tKey_SetCatcher( args[1] );\n    return 0;\n  case CG_KEY_GETKEY:\n\t\treturn Key_GetKey( VMA(1) );\n\n\n\n\tcase CG_MEMSET:\n\t\tCom_Memset( VMA(1), args[2], args[3] );\n\t\treturn 0;\n\tcase CG_MEMCPY:\n\t\tCom_Memcpy( VMA(1), VMA(2), args[3] );\n\t\treturn 0;\n\tcase CG_STRNCPY:\n\t\treturn (int)strncpy( VMA(1), VMA(2), args[3] );\n\tcase CG_SIN:\n\t\treturn FloatAsInt( sin( VMF(1) ) );\n\tcase CG_COS:\n\t\treturn FloatAsInt( cos( VMF(1) ) );\n\tcase CG_ATAN2:\n\t\treturn FloatAsInt( atan2( VMF(1), VMF(2) ) );\n\tcase CG_SQRT:\n\t\treturn FloatAsInt( sqrt( VMF(1) ) );\n\tcase CG_FLOOR:\n\t\treturn FloatAsInt( floor( VMF(1) ) );\n\tcase CG_CEIL:\n\t\treturn FloatAsInt( ceil( VMF(1) ) );\n\tcase CG_ACOS:\n\t\treturn FloatAsInt( Q_acos( VMF(1) ) );\n\n\tcase CG_PC_ADD_GLOBAL_DEFINE:\n\t\treturn botlib_export->PC_AddGlobalDefine( VMA(1) );\n\tcase CG_PC_LOAD_SOURCE:\n\t\treturn botlib_export->PC_LoadSourceHandle( VMA(1) );\n\tcase CG_PC_FREE_SOURCE:\n\t\treturn botlib_export->PC_FreeSourceHandle( args[1] );\n\tcase CG_PC_READ_TOKEN:\n\t\treturn botlib_export->PC_ReadTokenHandle( args[1], VMA(2) );\n\tcase CG_PC_SOURCE_FILE_AND_LINE:\n\t\treturn botlib_export->PC_SourceFileAndLine( args[1], VMA(2), VMA(3) );\n\n\tcase CG_S_STOPBACKGROUNDTRACK:\n\t\tS_StopBackgroundTrack();\n\t\treturn 0;\n\n\tcase CG_REAL_TIME:\n\t\treturn Com_RealTime( VMA(1) );\n\tcase CG_SNAPVECTOR:\n\t\tSys_SnapVector( VMA(1) );\n\t\treturn 0;\n\n\tcase CG_CIN_PLAYCINEMATIC:\n\t  return CIN_PlayCinematic(VMA(1), args[2], args[3], args[4], args[5], args[6]);\n\n\tcase CG_CIN_STOPCINEMATIC:\n\t  return CIN_StopCinematic(args[1]);\n\n\tcase CG_CIN_RUNCINEMATIC:\n\t  return CIN_RunCinematic(args[1]);\n\n\tcase CG_CIN_DRAWCINEMATIC:\n\t  CIN_DrawCinematic(args[1]);\n\t  return 0;\n\n\tcase CG_CIN_SETEXTENTS:\n\t  CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]);\n\t  return 0;\n\n\tcase CG_R_REMAP_SHADER:\n\t\tre.RemapShader( VMA(1), VMA(2), VMA(3) );\n\t\treturn 0;\n\n/*\n\tcase CG_LOADCAMERA:\n\t\treturn loadCamera(VMA(1));\n\n\tcase CG_STARTCAMERA:\n\t\tstartCamera(args[1]);\n\t\treturn 0;\n\n\tcase CG_GETCAMERAINFO:\n\t\treturn getCameraInfo(args[1], VMA(2), VMA(3));\n*/\n\tcase CG_GET_ENTITY_TOKEN:\n\t\treturn re.GetEntityToken( VMA(1), args[2] );\n\tcase CG_R_INPVS:\n\t\treturn re.inPVS( VMA(1), VMA(2) );\n\n\tdefault:\n\t        assert(0); // bk010102\n\t\tCom_Error( ERR_DROP, \"Bad cgame system trap: %i\", args[0] );\n\t}\n\treturn 0;\n}\n\n\n/*\n====================\nCL_InitCGame\n\nShould only be called by CL_StartHunkUsers\n====================\n*/\nvoid CL_InitCGame( void ) {\n\tconst char\t\t\t*info;\n\tconst char\t\t\t*mapname;\n\tint\t\t\t\t\tt1, t2;\n\tvmInterpret_t\t\tinterpret;\n\n\tt1 = Sys_Milliseconds();\n\n\t// put away the console\n\tCon_Close();\n\n\t// find the current mapname\n\tinfo = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SERVERINFO ];\n\tmapname = Info_ValueForKey( info, \"mapname\" );\n\tCom_sprintf( cl.mapname, sizeof( cl.mapname ), \"maps/%s.bsp\", mapname );\n\n\t// load the dll or bytecode\n\tif ( cl_connectedToPureServer != 0 ) {\n\t\t// if sv_pure is set we only allow qvms to be loaded\n\t\tinterpret = VMI_COMPILED;\n\t}\n\telse {\n\t\tinterpret = Cvar_VariableValue( \"vm_cgame\" );\n\t}\n\tcgvm = VM_Create( \"cgame\", CL_CgameSystemCalls, interpret );\n\tif ( !cgvm ) {\n\t\tCom_Error( ERR_DROP, \"VM_Create on cgame failed\" );\n\t}\n\tcls.state = CA_LOADING;\n\n\t// init for this gamestate\n\t// use the lastExecutedServerCommand instead of the serverCommandSequence\n\t// otherwise server commands sent just before a gamestate are dropped\n\tVM_Call( cgvm, CG_INIT, clc.serverMessageSequence, clc.lastExecutedServerCommand, clc.clientNum );\n\n\t// we will send a usercmd this frame, which\n\t// will cause the server to send us the first snapshot\n\tcls.state = CA_PRIMED;\n\n\tt2 = Sys_Milliseconds();\n\n\tCom_Printf( \"CL_InitCGame: %5.2f seconds\\n\", (t2-t1)/1000.0 );\n\n\t// have the renderer touch all its images, so they are present\n\t// on the card even if the driver does deferred loading\n\tre.EndRegistration();\n\n\t// make sure everything is paged in\n\tif (!Sys_LowPhysicalMemory()) {\n\t\tCom_TouchMemory();\n\t}\n\n\t// clear anything that got printed\n\tCon_ClearNotify ();\n}\n\n\n/*\n====================\nCL_GameCommand\n\nSee if the current console command is claimed by the cgame\n====================\n*/\nqboolean CL_GameCommand( void ) {\n\tif ( !cgvm ) {\n\t\treturn qfalse;\n\t}\n\n\treturn VM_Call( cgvm, CG_CONSOLE_COMMAND );\n}\n\n\n\n/*\n=====================\nCL_CGameRendering\n=====================\n*/\nvoid CL_CGameRendering( stereoFrame_t stereo ) {\n\tVM_Call( cgvm, CG_DRAW_ACTIVE_FRAME, cl.serverTime, stereo, clc.demoplaying );\n\tVM_Debug( 0 );\n}\n\n\n/*\n=================\nCL_AdjustTimeDelta\n\nAdjust the clients view of server time.\n\nWe attempt to have cl.serverTime exactly equal the server's view\nof time plus the timeNudge, but with variable latencies over\nthe internet it will often need to drift a bit to match conditions.\n\nOur ideal time would be to have the adjusted time approach, but not pass,\nthe very latest snapshot.\n\nAdjustments are only made when a new snapshot arrives with a rational\nlatency, which keeps the adjustment process framerate independent and\nprevents massive overadjustment during times of significant packet loss\nor bursted delayed packets.\n=================\n*/\n\n#define\tRESET_TIME\t500\n\nvoid CL_AdjustTimeDelta( void ) {\n\tint\t\tresetTime;\n\tint\t\tnewDelta;\n\tint\t\tdeltaDelta;\n\n\tcl.newSnapshots = qfalse;\n\n\t// the delta never drifts when replaying a demo\n\tif ( clc.demoplaying ) {\n\t\treturn;\n\t}\n\n\t// if the current time is WAY off, just correct to the current value\n\tif ( com_sv_running->integer ) {\n\t\tresetTime = 100;\n\t} else {\n\t\tresetTime = RESET_TIME;\n\t}\n\n\tnewDelta = cl.snap.serverTime - cls.realtime;\n\tdeltaDelta = abs( newDelta - cl.serverTimeDelta );\n\n\tif ( deltaDelta > RESET_TIME ) {\n\t\tcl.serverTimeDelta = newDelta;\n\t\tcl.oldServerTime = cl.snap.serverTime;\t// FIXME: is this a problem for cgame?\n\t\tcl.serverTime = cl.snap.serverTime;\n\t\tif ( cl_showTimeDelta->integer ) {\n\t\t\tCom_Printf( \"<RESET> \" );\n\t\t}\n\t} else if ( deltaDelta > 100 ) {\n\t\t// fast adjust, cut the difference in half\n\t\tif ( cl_showTimeDelta->integer ) {\n\t\t\tCom_Printf( \"<FAST> \" );\n\t\t}\n\t\tcl.serverTimeDelta = ( cl.serverTimeDelta + newDelta ) >> 1;\n\t} else {\n\t\t// slow drift adjust, only move 1 or 2 msec\n\n\t\t// if any of the frames between this and the previous snapshot\n\t\t// had to be extrapolated, nudge our sense of time back a little\n\t\t// the granularity of +1 / -2 is too high for timescale modified frametimes\n\t\tif ( com_timescale->value == 0 || com_timescale->value == 1 ) {\n\t\t\tif ( cl.extrapolatedSnapshot ) {\n\t\t\t\tcl.extrapolatedSnapshot = qfalse;\n\t\t\t\tcl.serverTimeDelta -= 2;\n\t\t\t} else {\n\t\t\t\t// otherwise, move our sense of time forward to minimize total latency\n\t\t\t\tcl.serverTimeDelta++;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( cl_showTimeDelta->integer ) {\n\t\tCom_Printf( \"%i \", cl.serverTimeDelta );\n\t}\n}\n\n\n/*\n==================\nCL_FirstSnapshot\n==================\n*/\nvoid CL_FirstSnapshot( void ) {\n\t// ignore snapshots that don't have entities\n\tif ( cl.snap.snapFlags & SNAPFLAG_NOT_ACTIVE ) {\n\t\treturn;\n\t}\n\tcls.state = CA_ACTIVE;\n\n\t// set the timedelta so we are exactly on this first frame\n\tcl.serverTimeDelta = cl.snap.serverTime - cls.realtime;\n\tcl.oldServerTime = cl.snap.serverTime;\n\n\tclc.timeDemoBaseTime = cl.snap.serverTime;\n\n\t// if this is the first frame of active play,\n\t// execute the contents of activeAction now\n\t// this is to allow scripting a timedemo to start right\n\t// after loading\n\tif ( cl_activeAction->string[0] ) {\n\t\tCbuf_AddText( cl_activeAction->string );\n\t\tCvar_Set( \"activeAction\", \"\" );\n\t}\n\t\n\tSys_BeginProfiling();\n}\n\n/*\n==================\nCL_SetCGameTime\n==================\n*/\nvoid CL_SetCGameTime( void ) {\n\t// getting a valid frame message ends the connection process\n\tif ( cls.state != CA_ACTIVE ) {\n\t\tif ( cls.state != CA_PRIMED ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( clc.demoplaying ) {\n\t\t\t// we shouldn't get the first snapshot on the same frame\n\t\t\t// as the gamestate, because it causes a bad time skip\n\t\t\tif ( !clc.firstDemoFrameSkipped ) {\n\t\t\t\tclc.firstDemoFrameSkipped = qtrue;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tCL_ReadDemoMessage();\n\t\t}\n\t\tif ( cl.newSnapshots ) {\n\t\t\tcl.newSnapshots = qfalse;\n\t\t\tCL_FirstSnapshot();\n\t\t}\n\t\tif ( cls.state != CA_ACTIVE ) {\n\t\t\treturn;\n\t\t}\n\t}\t\n\n\t// if we have gotten to this point, cl.snap is guaranteed to be valid\n\tif ( !cl.snap.valid ) {\n\t\tCom_Error( ERR_DROP, \"CL_SetCGameTime: !cl.snap.valid\" );\n\t}\n\n\t// allow pause in single player\n\tif ( sv_paused->integer && cl_paused->integer && com_sv_running->integer ) {\n\t\t// paused\n\t\treturn;\n\t}\n\n\tif ( cl.snap.serverTime < cl.oldFrameServerTime ) {\n\t\tCom_Error( ERR_DROP, \"cl.snap.serverTime < cl.oldFrameServerTime\" );\n\t}\n\tcl.oldFrameServerTime = cl.snap.serverTime;\n\n\n\t// get our current view of time\n\n\tif ( clc.demoplaying && cl_freezeDemo->integer ) {\n\t\t// cl_freezeDemo is used to lock a demo in place for single frame advances\n\n\t} else {\n\t\t// cl_timeNudge is a user adjustable cvar that allows more\n\t\t// or less latency to be added in the interest of better \n\t\t// smoothness or better responsiveness.\n\t\tint tn;\n\t\t\n\t\ttn = cl_timeNudge->integer;\n\t\tif (tn<-30) {\n\t\t\ttn = -30;\n\t\t} else if (tn>30) {\n\t\t\ttn = 30;\n\t\t}\n\n\t\tcl.serverTime = cls.realtime + cl.serverTimeDelta - tn;\n\n\t\t// guarantee that time will never flow backwards, even if\n\t\t// serverTimeDelta made an adjustment or cl_timeNudge was changed\n\t\tif ( cl.serverTime < cl.oldServerTime ) {\n\t\t\tcl.serverTime = cl.oldServerTime;\n\t\t}\n\t\tcl.oldServerTime = cl.serverTime;\n\n\t\t// note if we are almost past the latest frame (without timeNudge),\n\t\t// so we will try and adjust back a bit when the next snapshot arrives\n\t\tif ( cls.realtime + cl.serverTimeDelta >= cl.snap.serverTime - 5 ) {\n\t\t\tcl.extrapolatedSnapshot = qtrue;\n\t\t}\n\t}\n\n\t// if we have gotten new snapshots, drift serverTimeDelta\n\t// don't do this every frame, or a period of packet loss would\n\t// make a huge adjustment\n\tif ( cl.newSnapshots ) {\n\t\tCL_AdjustTimeDelta();\n\t}\n\n\tif ( !clc.demoplaying ) {\n\t\treturn;\n\t}\n\n\t// if we are playing a demo back, we can just keep reading\n\t// messages from the demo file until the cgame definately\n\t// has valid snapshots to interpolate between\n\n\t// a timedemo will always use a deterministic set of time samples\n\t// no matter what speed machine it is run on,\n\t// while a normal demo may have different time samples\n\t// each time it is played back\n\tif ( cl_timedemo->integer ) {\n\t\tif (!clc.timeDemoStart) {\n\t\t\tclc.timeDemoStart = Sys_Milliseconds();\n\t\t}\n\t\tclc.timeDemoFrames++;\n\t\tcl.serverTime = clc.timeDemoBaseTime + clc.timeDemoFrames * 50;\n\t}\n\n\twhile ( cl.serverTime >= cl.snap.serverTime ) {\n\t\t// feed another messag, which should change\n\t\t// the contents of cl.snap\n\t\tCL_ReadDemoMessage();\n\t\tif ( cls.state != CA_ACTIVE ) {\n\t\t\treturn;\t\t// end of demo\n\t\t}\n\t}\n\n}\n\n\n\n"
  },
  {
    "path": "code/client/cl_cin.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tcl_cin.c\n *\n * desc:\t\tvideo and cinematic playback\n *\n * $Archive: /MissionPack/code/client/cl_cin.c $\n *\n * cl_glconfig.hwtype trtypes 3dfx/ragepro need 256x256\n *\n *****************************************************************************/\n\n#include \"client.h\"\n#include \"snd_local.h\"\n\n#define MAXSIZE\t\t\t\t8\n#define MINSIZE\t\t\t\t4\n\n#define DEFAULT_CIN_WIDTH\t512\n#define DEFAULT_CIN_HEIGHT\t512\n\n#define ROQ_QUAD\t\t\t0x1000\n#define ROQ_QUAD_INFO\t\t0x1001\n#define ROQ_CODEBOOK\t\t0x1002\n#define ROQ_QUAD_VQ\t\t\t0x1011\n#define ROQ_QUAD_JPEG\t\t0x1012\n#define ROQ_QUAD_HANG\t\t0x1013\n#define ROQ_PACKET\t\t\t0x1030\n#define ZA_SOUND_MONO\t\t0x1020\n#define ZA_SOUND_STEREO\t\t0x1021\n\n#define MAX_VIDEO_HANDLES\t16\n\nextern glconfig_t glConfig;\nextern\tint\t\ts_paintedtime;\nextern\tint\t\ts_rawend;\n\n\nstatic void RoQ_init( void );\n\n/******************************************************************************\n*\n* Class:\t\ttrFMV\n*\n* Description:\tRoQ/RnR manipulation routines\n*\t\t\t\tnot entirely complete for first run\n*\n******************************************************************************/\n\nstatic\tlong\t\t\t\tROQ_YY_tab[256];\nstatic\tlong\t\t\t\tROQ_UB_tab[256];\nstatic\tlong\t\t\t\tROQ_UG_tab[256];\nstatic\tlong\t\t\t\tROQ_VG_tab[256];\nstatic\tlong\t\t\t\tROQ_VR_tab[256];\nstatic\tunsigned short\t\tvq2[256*16*4];\nstatic\tunsigned short\t\tvq4[256*64*4];\nstatic\tunsigned short\t\tvq8[256*256*4];\n\n\ntypedef struct {\n\tbyte\t\t\t\tlinbuf[DEFAULT_CIN_WIDTH*DEFAULT_CIN_HEIGHT*4*2];\n\tbyte\t\t\t\tfile[65536];\n\tshort\t\t\t\tsqrTable[256];\n\n\tunsigned int\t\tmcomp[256];\n\tbyte\t\t\t\t*qStatus[2][32768];\n\n\tlong\t\t\t\toldXOff, oldYOff, oldysize, oldxsize;\n\n\tint\t\t\t\t\tcurrentHandle;\n} cinematics_t;\n\ntypedef struct {\n\tchar\t\t\t\tfileName[MAX_OSPATH];\n\tint\t\t\t\t\tCIN_WIDTH, CIN_HEIGHT;\n\tint\t\t\t\t\txpos, ypos, width, height;\n\tqboolean\t\t\tlooping, holdAtEnd, dirty, alterGameState, silent, shader;\n\tfileHandle_t\t\tiFile;\n\te_status\t\t\tstatus;\n\tunsigned int\t\tstartTime;\n\tunsigned int\t\tlastTime;\n\tlong\t\t\t\ttfps;\n\tlong\t\t\t\tRoQPlayed;\n\tlong\t\t\t\tROQSize;\n\tunsigned int\t\tRoQFrameSize;\n\tlong\t\t\t\tonQuad;\n\tlong\t\t\t\tnumQuads;\n\tlong\t\t\t\tsamplesPerLine;\n\tunsigned int\t\troq_id;\n\tlong\t\t\t\tscreenDelta;\n\n\tvoid ( *VQ0)(byte *status, void *qdata );\n\tvoid ( *VQ1)(byte *status, void *qdata );\n\tvoid ( *VQNormal)(byte *status, void *qdata );\n\tvoid ( *VQBuffer)(byte *status, void *qdata );\n\n\tlong\t\t\t\tsamplesPerPixel;\t\t\t\t// defaults to 2\n\tbyte*\t\t\t\tgray;\n\tunsigned int\t\txsize, ysize, maxsize, minsize;\n\n\tqboolean\t\t\thalf, smootheddouble, inMemory;\n\tlong\t\t\t\tnormalBuffer0;\n\tlong\t\t\t\troq_flags;\n\tlong\t\t\t\troqF0;\n\tlong\t\t\t\troqF1;\n\tlong\t\t\t\tt[2];\n\tlong\t\t\t\troqFPS;\n\tint\t\t\t\t\tplayonwalls;\n\tbyte*\t\t\t\tbuf;\n\tlong\t\t\t\tdrawX, drawY;\n} cin_cache;\n\nstatic cinematics_t\t\tcin;\nstatic cin_cache\t\tcinTable[MAX_VIDEO_HANDLES];\nstatic int\t\t\t\tcurrentHandle = -1;\nstatic int\t\t\t\tCL_handle = -1;\n\nextern int\t\t\t\ts_soundtime;\t\t// sample PAIRS\nextern int   \t\t\ts_paintedtime; \t\t// sample PAIRS\n\n\nvoid CIN_CloseAllVideos(void) {\n\tint\t\ti;\n\n\tfor ( i = 0 ; i < MAX_VIDEO_HANDLES ; i++ ) {\n\t\tif (cinTable[i].fileName[0] != 0 ) {\n\t\t\tCIN_StopCinematic(i);\n\t\t}\n\t}\n}\n\n\nstatic int CIN_HandleForVideo(void) {\n\tint\t\ti;\n\n\tfor ( i = 0 ; i < MAX_VIDEO_HANDLES ; i++ ) {\n\t\tif ( cinTable[i].fileName[0] == 0 ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\tCom_Error( ERR_DROP, \"CIN_HandleForVideo: none free\" );\n\treturn -1;\n}\n\n\nextern int CL_ScaledMilliseconds(void);\n\n//-----------------------------------------------------------------------------\n// RllSetupTable\n//\n// Allocates and initializes the square table.\n//\n// Parameters:\tNone\n//\n// Returns:\t\tNothing\n//-----------------------------------------------------------------------------\nstatic void RllSetupTable()\n{\n\tint z;\n\n\tfor (z=0;z<128;z++) {\n\t\tcin.sqrTable[z] = (short)(z*z);\n\t\tcin.sqrTable[z+128] = (short)(-cin.sqrTable[z]);\n\t}\n}\n\n\n\n//-----------------------------------------------------------------------------\n// RllDecodeMonoToMono\n//\n// Decode mono source data into a mono buffer.\n//\n// Parameters:\tfrom -> buffer holding encoded data\n//\t\t\t\tto ->\tbuffer to hold decoded data\n//\t\t\t\tsize =\tnumber of bytes of input (= # of shorts of output)\n//\t\t\t\tsignedOutput = 0 for unsigned output, non-zero for signed output\n//\t\t\t\tflag = flags from asset header\n//\n// Returns:\t\tNumber of samples placed in output buffer\n//-----------------------------------------------------------------------------\nlong RllDecodeMonoToMono(unsigned char *from,short *to,unsigned int size,char signedOutput ,unsigned short flag)\n{\n\tunsigned int z;\n\tint prev;\n\t\n\tif (signedOutput)\t\n\t\tprev =  flag - 0x8000;\n\telse \n\t\tprev = flag;\n\n\tfor (z=0;z<size;z++) {\n\t\tprev = to[z] = (short)(prev + cin.sqrTable[from[z]]); \n\t}\n\treturn size;\t//*sizeof(short));\n}\n\n\n//-----------------------------------------------------------------------------\n// RllDecodeMonoToStereo\n//\n// Decode mono source data into a stereo buffer. Output is 4 times the number\n// of bytes in the input.\n//\n// Parameters:\tfrom -> buffer holding encoded data\n//\t\t\t\tto ->\tbuffer to hold decoded data\n//\t\t\t\tsize =\tnumber of bytes of input (= 1/4 # of bytes of output)\n//\t\t\t\tsignedOutput = 0 for unsigned output, non-zero for signed output\n//\t\t\t\tflag = flags from asset header\n//\n// Returns:\t\tNumber of samples placed in output buffer\n//-----------------------------------------------------------------------------\nlong RllDecodeMonoToStereo(unsigned char *from,short *to,unsigned int size,char signedOutput,unsigned short flag)\n{\n\tunsigned int z;\n\tint prev;\n\t\n\tif (signedOutput)\t\n\t\tprev =  flag - 0x8000;\n\telse \n\t\tprev = flag;\n\n\tfor (z = 0; z < size; z++) {\n\t\tprev = (short)(prev + cin.sqrTable[from[z]]);\n\t\tto[z*2+0] = to[z*2+1] = (short)(prev);\n\t}\n\t\n\treturn size;\t// * 2 * sizeof(short));\n}\n\n\n//-----------------------------------------------------------------------------\n// RllDecodeStereoToStereo\n//\n// Decode stereo source data into a stereo buffer.\n//\n// Parameters:\tfrom -> buffer holding encoded data\n//\t\t\t\tto ->\tbuffer to hold decoded data\n//\t\t\t\tsize =\tnumber of bytes of input (= 1/2 # of bytes of output)\n//\t\t\t\tsignedOutput = 0 for unsigned output, non-zero for signed output\n//\t\t\t\tflag = flags from asset header\n//\n// Returns:\t\tNumber of samples placed in output buffer\n//-----------------------------------------------------------------------------\nlong RllDecodeStereoToStereo(unsigned char *from,short *to,unsigned int size,char signedOutput, unsigned short flag)\n{\n\tunsigned int z;\n\tunsigned char *zz = from;\n\tint\tprevL, prevR;\n\n\tif (signedOutput) {\n\t\tprevL = (flag & 0xff00) - 0x8000;\n\t\tprevR = ((flag & 0x00ff) << 8) - 0x8000;\n\t} else {\n\t\tprevL = flag & 0xff00;\n\t\tprevR = (flag & 0x00ff) << 8;\n\t}\n\n\tfor (z=0;z<size;z+=2) {\n                prevL = (short)(prevL + cin.sqrTable[*zz++]); \n                prevR = (short)(prevR + cin.sqrTable[*zz++]);\n                to[z+0] = (short)(prevL);\n                to[z+1] = (short)(prevR);\n\t}\n\t\n\treturn (size>>1);\t//*sizeof(short));\n}\n\n\n//-----------------------------------------------------------------------------\n// RllDecodeStereoToMono\n//\n// Decode stereo source data into a mono buffer.\n//\n// Parameters:\tfrom -> buffer holding encoded data\n//\t\t\t\tto ->\tbuffer to hold decoded data\n//\t\t\t\tsize =\tnumber of bytes of input (= # of bytes of output)\n//\t\t\t\tsignedOutput = 0 for unsigned output, non-zero for signed output\n//\t\t\t\tflag = flags from asset header\n//\n// Returns:\t\tNumber of samples placed in output buffer\n//-----------------------------------------------------------------------------\nlong RllDecodeStereoToMono(unsigned char *from,short *to,unsigned int size,char signedOutput, unsigned short flag)\n{\n\tunsigned int z;\n\tint prevL,prevR;\n\t\n\tif (signedOutput) {\n\t\tprevL = (flag & 0xff00) - 0x8000;\n\t\tprevR = ((flag & 0x00ff) << 8) -0x8000;\n\t} else {\n\t\tprevL = flag & 0xff00;\n\t\tprevR = (flag & 0x00ff) << 8;\n\t}\n\n\tfor (z=0;z<size;z+=1) {\n\t\tprevL= prevL + cin.sqrTable[from[z*2]];\n\t\tprevR = prevR + cin.sqrTable[from[z*2+1]];\n\t\tto[z] = (short)((prevL + prevR)/2);\n\t}\n\n\treturn size;\n}\n\n/******************************************************************************\n*\n* Function:\t\t\n*\n* Description:\t\n*\n******************************************************************************/\n\nstatic void move8_32( byte *src, byte *dst, int spl )\n{\n\tdouble *dsrc, *ddst;\n\tint dspl;\n\n\tdsrc = (double *)src;\n\tddst = (double *)dst;\n\tdspl = spl>>3;\n\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3];\n\tdsrc += dspl; ddst += dspl;\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3];\n\tdsrc += dspl; ddst += dspl;\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3];\n\tdsrc += dspl; ddst += dspl;\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3];\n\tdsrc += dspl; ddst += dspl;\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3];\n\tdsrc += dspl; ddst += dspl;\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3];\n\tdsrc += dspl; ddst += dspl;\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3];\n\tdsrc += dspl; ddst += dspl;\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3];\n}\n\n/******************************************************************************\n*\n* Function:\t\t\n*\n* Description:\t\n*\n******************************************************************************/\n\nstatic void move4_32( byte *src, byte *dst, int spl  )\n{\n\tdouble *dsrc, *ddst;\n\tint dspl;\n\n\tdsrc = (double *)src;\n\tddst = (double *)dst;\n\tdspl = spl>>3;\n\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1];\n\tdsrc += dspl; ddst += dspl;\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1];\n\tdsrc += dspl; ddst += dspl;\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1];\n\tdsrc += dspl; ddst += dspl;\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1];\n}\n\n/******************************************************************************\n*\n* Function:\t\t\n*\n* Description:\t\n*\n******************************************************************************/\n\nstatic void blit8_32( byte *src, byte *dst, int spl  )\n{\n\tdouble *dsrc, *ddst;\n\tint dspl;\n\n\tdsrc = (double *)src;\n\tddst = (double *)dst;\n\tdspl = spl>>3;\n\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3];\n\tdsrc += 4; ddst += dspl;\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3];\n\tdsrc += 4; ddst += dspl;\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3];\n\tdsrc += 4; ddst += dspl;\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3];\n\tdsrc += 4; ddst += dspl;\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3];\n\tdsrc += 4; ddst += dspl;\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3];\n\tdsrc += 4; ddst += dspl;\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3];\n\tdsrc += 4; ddst += dspl;\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3];\n}\n\n/******************************************************************************\n*\n* Function:\t\t\n*\n* Description:\t\n*\n******************************************************************************/\n#define movs double\nstatic void blit4_32( byte *src, byte *dst, int spl  )\n{\n\tmovs *dsrc, *ddst;\n\tint dspl;\n\n\tdsrc = (movs *)src;\n\tddst = (movs *)dst;\n\tdspl = spl>>3;\n\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1];\n\tdsrc += 2; ddst += dspl;\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1];\n\tdsrc += 2; ddst += dspl;\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1];\n\tdsrc += 2; ddst += dspl;\n\tddst[0] = dsrc[0]; ddst[1] = dsrc[1];\n}\n\n/******************************************************************************\n*\n* Function:\t\t\n*\n* Description:\t\n*\n******************************************************************************/\n\nstatic void blit2_32( byte *src, byte *dst, int spl  )\n{\n\tdouble *dsrc, *ddst;\n\tint dspl;\n\n\tdsrc = (double *)src;\n\tddst = (double *)dst;\n\tdspl = spl>>3;\n\n\tddst[0] = dsrc[0];\n\tddst[dspl] = dsrc[1];\n}\n\n/******************************************************************************\n*\n* Function:\t\t\n*\n* Description:\t\n*\n******************************************************************************/\n\nstatic void blitVQQuad32fs( byte **status, unsigned char *data )\n{\nunsigned short\tnewd, celdata, code;\nunsigned int\tindex, i;\nint\t\tspl;\n\n\tnewd\t= 0;\n\tceldata = 0;\n\tindex\t= 0;\n\t\n        spl = cinTable[currentHandle].samplesPerLine;\n        \n\tdo {\n\t\tif (!newd) { \n\t\t\tnewd = 7;\n\t\t\tceldata = data[0] + data[1]*256;\n\t\t\tdata += 2;\n\t\t} else {\n\t\t\tnewd--;\n\t\t}\n\n\t\tcode = (unsigned short)(celdata&0xc000); \n\t\tceldata <<= 2;\n\t\t\n\t\tswitch (code) {\n\t\t\tcase\t0x8000:\t\t\t\t\t\t\t\t\t\t\t\t\t// vq code\n\t\t\t\tblit8_32( (byte *)&vq8[(*data)*128], status[index], spl );\n\t\t\t\tdata++;\n\t\t\t\tindex += 5;\n\t\t\t\tbreak;\n\t\t\tcase\t0xc000:\t\t\t\t\t\t\t\t\t\t\t\t\t// drop\n\t\t\t\tindex++;\t\t\t\t\t\t\t\t\t\t\t\t\t// skip 8x8\n\t\t\t\tfor(i=0;i<4;i++) {\n\t\t\t\t\tif (!newd) { \n\t\t\t\t\t\tnewd = 7;\n\t\t\t\t\t\tceldata = data[0] + data[1]*256;\n\t\t\t\t\t\tdata += 2;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnewd--;\n\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\tcode = (unsigned short)(celdata&0xc000); celdata <<= 2; \n\n\t\t\t\t\tswitch (code) {\t\t\t\t\t\t\t\t\t\t\t// code in top two bits of code\n\t\t\t\t\t\tcase\t0x8000:\t\t\t\t\t\t\t\t\t\t// 4x4 vq code\n\t\t\t\t\t\t\tblit4_32( (byte *)&vq4[(*data)*32], status[index], spl );\n\t\t\t\t\t\t\tdata++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase\t0xc000:\t\t\t\t\t\t\t\t\t\t// 2x2 vq code\n\t\t\t\t\t\t\tblit2_32( (byte *)&vq2[(*data)*8], status[index], spl );\n\t\t\t\t\t\t\tdata++;\n\t\t\t\t\t\t\tblit2_32( (byte *)&vq2[(*data)*8], status[index]+8, spl );\n\t\t\t\t\t\t\tdata++;\n\t\t\t\t\t\t\tblit2_32( (byte *)&vq2[(*data)*8], status[index]+spl*2, spl );\n\t\t\t\t\t\t\tdata++;\n\t\t\t\t\t\t\tblit2_32( (byte *)&vq2[(*data)*8], status[index]+spl*2+8, spl );\n\t\t\t\t\t\t\tdata++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase\t0x4000:\t\t\t\t\t\t\t\t\t\t// motion compensation\n\t\t\t\t\t\t\tmove4_32( status[index] + cin.mcomp[(*data)], status[index], spl );\n\t\t\t\t\t\t\tdata++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tindex++;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase\t0x4000:\t\t\t\t\t\t\t\t\t\t\t\t\t// motion compensation\n\t\t\t\tmove8_32( status[index] + cin.mcomp[(*data)], status[index], spl );\n\t\t\t\tdata++;\n\t\t\t\tindex += 5;\n\t\t\t\tbreak;\n\t\t\tcase\t0x0000:\n\t\t\t\tindex += 5;\n\t\t\t\tbreak;\n\t\t}\n\t} while ( status[index] != NULL );\n}\n\n/******************************************************************************\n*\n* Function:\t\t\n*\n* Description:\t\n*\n******************************************************************************/\n\nstatic void ROQ_GenYUVTables( void )\n{\n\tfloat t_ub,t_vr,t_ug,t_vg;\n\tlong i;\n\n\tt_ub = (1.77200f/2.0f) * (float)(1<<6) + 0.5f;\n\tt_vr = (1.40200f/2.0f) * (float)(1<<6) + 0.5f;\n\tt_ug = (0.34414f/2.0f) * (float)(1<<6) + 0.5f;\n\tt_vg = (0.71414f/2.0f) * (float)(1<<6) + 0.5f;\n\tfor(i=0;i<256;i++) {\n\t\tfloat x = (float)(2 * i - 255);\n\t\n\t\tROQ_UB_tab[i] = (long)( ( t_ub * x) + (1<<5));\n\t\tROQ_VR_tab[i] = (long)( ( t_vr * x) + (1<<5));\n\t\tROQ_UG_tab[i] = (long)( (-t_ug * x)\t\t );\n\t\tROQ_VG_tab[i] = (long)( (-t_vg * x) + (1<<5));\n\t\tROQ_YY_tab[i] = (long)( (i << 6) | (i >> 2) );\n\t}\n}\n\n#define VQ2TO4(a,b,c,d) { \\\n    \t*c++ = a[0];\t\\\n\t*d++ = a[0];\t\\\n\t*d++ = a[0];\t\\\n\t*c++ = a[1];\t\\\n\t*d++ = a[1];\t\\\n\t*d++ = a[1];\t\\\n\t*c++ = b[0];\t\\\n\t*d++ = b[0];\t\\\n\t*d++ = b[0];\t\\\n\t*c++ = b[1];\t\\\n\t*d++ = b[1];\t\\\n\t*d++ = b[1];\t\\\n\t*d++ = a[0];\t\\\n\t*d++ = a[0];\t\\\n\t*d++ = a[1];\t\\\n\t*d++ = a[1];\t\\\n\t*d++ = b[0];\t\\\n\t*d++ = b[0];\t\\\n\t*d++ = b[1];\t\\\n\t*d++ = b[1];\t\\\n\ta += 2; b += 2; }\n \n#define VQ2TO2(a,b,c,d) { \\\n\t*c++ = *a;\t\\\n\t*d++ = *a;\t\\\n\t*d++ = *a;\t\\\n\t*c++ = *b;\t\\\n\t*d++ = *b;\t\\\n\t*d++ = *b;\t\\\n\t*d++ = *a;\t\\\n\t*d++ = *a;\t\\\n\t*d++ = *b;\t\\\n\t*d++ = *b;\t\\\n\ta++; b++; }\n\n/******************************************************************************\n*\n* Function:\t\t\n*\n* Description:\t\n*\n******************************************************************************/\n\nstatic unsigned short yuv_to_rgb( long y, long u, long v )\n{ \n\tlong r,g,b,YY = (long)(ROQ_YY_tab[(y)]);\n\n\tr = (YY + ROQ_VR_tab[v]) >> 9;\n\tg = (YY + ROQ_UG_tab[u] + ROQ_VG_tab[v]) >> 8;\n\tb = (YY + ROQ_UB_tab[u]) >> 9;\n\t\n\tif (r<0) r = 0; if (g<0) g = 0; if (b<0) b = 0;\n\tif (r > 31) r = 31; if (g > 63) g = 63; if (b > 31) b = 31;\n\n\treturn (unsigned short)((r<<11)+(g<<5)+(b));\n}\n\n/******************************************************************************\n*\n* Function:\t\t\n*\n* Description:\t\n*\n******************************************************************************/\n#if defined(MACOS_X)\n\nstatic inline unsigned int yuv_to_rgb24( long y, long u, long v )\n{ \n\tlong r,g,b,YY;\n        \n        YY = (long)(ROQ_YY_tab[(y)]);\n\n\tr = (YY + ROQ_VR_tab[v]) >> 6;\n\tg = (YY + ROQ_UG_tab[u] + ROQ_VG_tab[v]) >> 6;\n\tb = (YY + ROQ_UB_tab[u]) >> 6;\n\t\n\tif (r<0) r = 0; if (g<0) g = 0; if (b<0) b = 0;\n\tif (r > 255) r = 255; if (g > 255) g = 255; if (b > 255) b = 255;\n\t\n\treturn ((r<<24)|(g<<16)|(b<<8))|(255);\t//+(255<<24));\n}\n\n#else\nstatic unsigned int yuv_to_rgb24( long y, long u, long v )\n{ \n\tlong r,g,b,YY = (long)(ROQ_YY_tab[(y)]);\n\n\tr = (YY + ROQ_VR_tab[v]) >> 6;\n\tg = (YY + ROQ_UG_tab[u] + ROQ_VG_tab[v]) >> 6;\n\tb = (YY + ROQ_UB_tab[u]) >> 6;\n\t\n\tif (r<0) r = 0; if (g<0) g = 0; if (b<0) b = 0;\n\tif (r > 255) r = 255; if (g > 255) g = 255; if (b > 255) b = 255;\n\t\n\treturn LittleLong ((r)|(g<<8)|(b<<16)|(255<<24));\n}\n#endif\n\n/******************************************************************************\n*\n* Function:\t\t\n*\n* Description:\t\n*\n******************************************************************************/\n\nstatic void decodeCodeBook( byte *input, unsigned short roq_flags )\n{\n\tlong\ti, j, two, four;\n\tunsigned short\t*aptr, *bptr, *cptr, *dptr;\n\tlong\ty0,y1,y2,y3,cr,cb;\n\tbyte\t*bbptr, *baptr, *bcptr, *bdptr;\n\tunsigned int *iaptr, *ibptr, *icptr, *idptr;\n\n\tif (!roq_flags) {\n\t\ttwo = four = 256;\n\t} else {\n\t\ttwo  = roq_flags>>8;\n\t\tif (!two) two = 256;\n\t\tfour = roq_flags&0xff;\n\t}\n\n\tfour *= 2;\n\n\tbptr = (unsigned short *)vq2;\n\n\tif (!cinTable[currentHandle].half) {\n\t\tif (!cinTable[currentHandle].smootheddouble) {\n//\n// normal height\n//\n\t\t\tif (cinTable[currentHandle].samplesPerPixel==2) {\n\t\t\t\tfor(i=0;i<two;i++) {\n\t\t\t\t\ty0 = (long)*input++;\n\t\t\t\t\ty1 = (long)*input++;\n\t\t\t\t\ty2 = (long)*input++;\n\t\t\t\t\ty3 = (long)*input++;\n\t\t\t\t\tcr = (long)*input++;\n\t\t\t\t\tcb = (long)*input++;\n\t\t\t\t\t*bptr++ = yuv_to_rgb( y0, cr, cb );\n\t\t\t\t\t*bptr++ = yuv_to_rgb( y1, cr, cb );\n\t\t\t\t\t*bptr++ = yuv_to_rgb( y2, cr, cb );\n\t\t\t\t\t*bptr++ = yuv_to_rgb( y3, cr, cb );\n\t\t\t\t}\n\n\t\t\t\tcptr = (unsigned short *)vq4;\n\t\t\t\tdptr = (unsigned short *)vq8;\n\t\t\n\t\t\t\tfor(i=0;i<four;i++) {\n\t\t\t\t\taptr = (unsigned short *)vq2 + (*input++)*4;\n\t\t\t\t\tbptr = (unsigned short *)vq2 + (*input++)*4;\n\t\t\t\t\tfor(j=0;j<2;j++)\n\t\t\t\t\t\tVQ2TO4(aptr,bptr,cptr,dptr);\n\t\t\t\t}\n\t\t\t} else if (cinTable[currentHandle].samplesPerPixel==4) {\n\t\t\t\tibptr = (unsigned int *)bptr;\n\t\t\t\tfor(i=0;i<two;i++) {\n\t\t\t\t\ty0 = (long)*input++;\n\t\t\t\t\ty1 = (long)*input++;\n\t\t\t\t\ty2 = (long)*input++;\n\t\t\t\t\ty3 = (long)*input++;\n\t\t\t\t\tcr = (long)*input++;\n\t\t\t\t\tcb = (long)*input++;\n\t\t\t\t\t*ibptr++ = yuv_to_rgb24( y0, cr, cb );\n\t\t\t\t\t*ibptr++ = yuv_to_rgb24( y1, cr, cb );\n\t\t\t\t\t*ibptr++ = yuv_to_rgb24( y2, cr, cb );\n\t\t\t\t\t*ibptr++ = yuv_to_rgb24( y3, cr, cb );\n\t\t\t\t}\n\n\t\t\t\ticptr = (unsigned int *)vq4;\n\t\t\t\tidptr = (unsigned int *)vq8;\n\t\n\t\t\t\tfor(i=0;i<four;i++) {\n\t\t\t\t\tiaptr = (unsigned int *)vq2 + (*input++)*4;\n\t\t\t\t\tibptr = (unsigned int *)vq2 + (*input++)*4;\n\t\t\t\t\tfor(j=0;j<2;j++) \n\t\t\t\t\t\tVQ2TO4(iaptr, ibptr, icptr, idptr);\n\t\t\t\t}\n\t\t\t} else if (cinTable[currentHandle].samplesPerPixel==1) {\n\t\t\t\tbbptr = (byte *)bptr;\n\t\t\t\tfor(i=0;i<two;i++) {\n\t\t\t\t\t*bbptr++ = cinTable[currentHandle].gray[*input++];\n\t\t\t\t\t*bbptr++ = cinTable[currentHandle].gray[*input++];\n\t\t\t\t\t*bbptr++ = cinTable[currentHandle].gray[*input++];\n\t\t\t\t\t*bbptr++ = cinTable[currentHandle].gray[*input]; input +=3;\n\t\t\t\t}\n\n\t\t\t\tbcptr = (byte *)vq4;\n\t\t\t\tbdptr = (byte *)vq8;\n\t\n\t\t\t\tfor(i=0;i<four;i++) {\n\t\t\t\t\tbaptr = (byte *)vq2 + (*input++)*4;\n\t\t\t\t\tbbptr = (byte *)vq2 + (*input++)*4;\n\t\t\t\t\tfor(j=0;j<2;j++) \n\t\t\t\t\t\tVQ2TO4(baptr,bbptr,bcptr,bdptr);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n//\n// double height, smoothed\n//\n\t\t\tif (cinTable[currentHandle].samplesPerPixel==2) {\n\t\t\t\tfor(i=0;i<two;i++) {\n\t\t\t\t\ty0 = (long)*input++;\n\t\t\t\t\ty1 = (long)*input++;\n\t\t\t\t\ty2 = (long)*input++;\n\t\t\t\t\ty3 = (long)*input++;\n\t\t\t\t\tcr = (long)*input++;\n\t\t\t\t\tcb = (long)*input++;\n\t\t\t\t\t*bptr++ = yuv_to_rgb( y0, cr, cb );\n\t\t\t\t\t*bptr++ = yuv_to_rgb( y1, cr, cb );\n\t\t\t\t\t*bptr++ = yuv_to_rgb( ((y0*3)+y2)/4, cr, cb );\n\t\t\t\t\t*bptr++ = yuv_to_rgb( ((y1*3)+y3)/4, cr, cb );\n\t\t\t\t\t*bptr++ = yuv_to_rgb( (y0+(y2*3))/4, cr, cb );\n\t\t\t\t\t*bptr++ = yuv_to_rgb( (y1+(y3*3))/4, cr, cb );\n\t\t\t\t\t*bptr++ = yuv_to_rgb( y2, cr, cb );\n\t\t\t\t\t*bptr++ = yuv_to_rgb( y3, cr, cb );\n\t\t\t\t}\n\n\t\t\t\tcptr = (unsigned short *)vq4;\n\t\t\t\tdptr = (unsigned short *)vq8;\n\t\t\n\t\t\t\tfor(i=0;i<four;i++) {\n\t\t\t\t\taptr = (unsigned short *)vq2 + (*input++)*8;\n\t\t\t\t\tbptr = (unsigned short *)vq2 + (*input++)*8;\n\t\t\t\t\tfor(j=0;j<2;j++) {\n\t\t\t\t\t\tVQ2TO4(aptr,bptr,cptr,dptr);\n\t\t\t\t\t\tVQ2TO4(aptr,bptr,cptr,dptr);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (cinTable[currentHandle].samplesPerPixel==4) {\n\t\t\t\tibptr = (unsigned int *)bptr;\n\t\t\t\tfor(i=0;i<two;i++) {\n\t\t\t\t\ty0 = (long)*input++;\n\t\t\t\t\ty1 = (long)*input++;\n\t\t\t\t\ty2 = (long)*input++;\n\t\t\t\t\ty3 = (long)*input++;\n\t\t\t\t\tcr = (long)*input++;\n\t\t\t\t\tcb = (long)*input++;\n\t\t\t\t\t*ibptr++ = yuv_to_rgb24( y0, cr, cb );\n\t\t\t\t\t*ibptr++ = yuv_to_rgb24( y1, cr, cb );\n\t\t\t\t\t*ibptr++ = yuv_to_rgb24( ((y0*3)+y2)/4, cr, cb );\n\t\t\t\t\t*ibptr++ = yuv_to_rgb24( ((y1*3)+y3)/4, cr, cb );\n\t\t\t\t\t*ibptr++ = yuv_to_rgb24( (y0+(y2*3))/4, cr, cb );\n\t\t\t\t\t*ibptr++ = yuv_to_rgb24( (y1+(y3*3))/4, cr, cb );\n\t\t\t\t\t*ibptr++ = yuv_to_rgb24( y2, cr, cb );\n\t\t\t\t\t*ibptr++ = yuv_to_rgb24( y3, cr, cb );\n\t\t\t\t}\n\n\t\t\t\ticptr = (unsigned int *)vq4;\n\t\t\t\tidptr = (unsigned int *)vq8;\n\t\n\t\t\t\tfor(i=0;i<four;i++) {\n\t\t\t\t\tiaptr = (unsigned int *)vq2 + (*input++)*8;\n\t\t\t\t\tibptr = (unsigned int *)vq2 + (*input++)*8;\n\t\t\t\t\tfor(j=0;j<2;j++) {\n\t\t\t\t\t\tVQ2TO4(iaptr, ibptr, icptr, idptr);\n\t\t\t\t\t\tVQ2TO4(iaptr, ibptr, icptr, idptr);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (cinTable[currentHandle].samplesPerPixel==1) {\n\t\t\t\tbbptr = (byte *)bptr;\n\t\t\t\tfor(i=0;i<two;i++) {\n\t\t\t\t\ty0 = (long)*input++;\n\t\t\t\t\ty1 = (long)*input++;\n\t\t\t\t\ty2 = (long)*input++;\n\t\t\t\t\ty3 = (long)*input; input+= 3;\n\t\t\t\t\t*bbptr++ = cinTable[currentHandle].gray[y0];\n\t\t\t\t\t*bbptr++ = cinTable[currentHandle].gray[y1];\n\t\t\t\t\t*bbptr++ = cinTable[currentHandle].gray[((y0*3)+y2)/4];\n\t\t\t\t\t*bbptr++ = cinTable[currentHandle].gray[((y1*3)+y3)/4];\n\t\t\t\t\t*bbptr++ = cinTable[currentHandle].gray[(y0+(y2*3))/4];\n\t\t\t\t\t*bbptr++ = cinTable[currentHandle].gray[(y1+(y3*3))/4];\t\t\t\t\t\t\n\t\t\t\t\t*bbptr++ = cinTable[currentHandle].gray[y2];\n\t\t\t\t\t*bbptr++ = cinTable[currentHandle].gray[y3];\n\t\t\t\t}\n\n\t\t\t\tbcptr = (byte *)vq4;\n\t\t\t\tbdptr = (byte *)vq8;\n\t\n\t\t\t\tfor(i=0;i<four;i++) {\n\t\t\t\t\tbaptr = (byte *)vq2 + (*input++)*8;\n\t\t\t\t\tbbptr = (byte *)vq2 + (*input++)*8;\n\t\t\t\t\tfor(j=0;j<2;j++) {\n\t\t\t\t\t\tVQ2TO4(baptr,bbptr,bcptr,bdptr);\n\t\t\t\t\t\tVQ2TO4(baptr,bbptr,bcptr,bdptr);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t}\n\t} else {\n//\n// 1/4 screen\n//\n\t\tif (cinTable[currentHandle].samplesPerPixel==2) {\n\t\t\tfor(i=0;i<two;i++) {\n\t\t\t\ty0 = (long)*input; input+=2;\n\t\t\t\ty2 = (long)*input; input+=2;\n\t\t\t\tcr = (long)*input++;\n\t\t\t\tcb = (long)*input++;\n\t\t\t\t*bptr++ = yuv_to_rgb( y0, cr, cb );\n\t\t\t\t*bptr++ = yuv_to_rgb( y2, cr, cb );\n\t\t\t}\n\n\t\t\tcptr = (unsigned short *)vq4;\n\t\t\tdptr = (unsigned short *)vq8;\n\t\n\t\t\tfor(i=0;i<four;i++) {\n\t\t\t\taptr = (unsigned short *)vq2 + (*input++)*2;\n\t\t\t\tbptr = (unsigned short *)vq2 + (*input++)*2;\n\t\t\t\tfor(j=0;j<2;j++) { \n\t\t\t\t\tVQ2TO2(aptr,bptr,cptr,dptr);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (cinTable[currentHandle].samplesPerPixel == 1) {\n\t\t\tbbptr = (byte *)bptr;\n\t\t\t\t\n\t\t\tfor(i=0;i<two;i++) {\n\t\t\t\t*bbptr++ = cinTable[currentHandle].gray[*input]; input+=2;\n\t\t\t\t*bbptr++ = cinTable[currentHandle].gray[*input]; input+=4;\n\t\t\t}\n\n\t\t\tbcptr = (byte *)vq4;\n\t\t\tbdptr = (byte *)vq8;\n\t\n\t\t\tfor(i=0;i<four;i++) {\n\t\t\t\tbaptr = (byte *)vq2 + (*input++)*2;\n\t\t\t\tbbptr = (byte *)vq2 + (*input++)*2;\n\t\t\t\tfor(j=0;j<2;j++) { \n\t\t\t\t\tVQ2TO2(baptr,bbptr,bcptr,bdptr);\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t} else if (cinTable[currentHandle].samplesPerPixel == 4) {\n\t\t\tibptr = (unsigned int *) bptr;\n\t\t\tfor(i=0;i<two;i++) {\n\t\t\t\ty0 = (long)*input; input+=2;\n\t\t\t\ty2 = (long)*input; input+=2;\n\t\t\t\tcr = (long)*input++;\n\t\t\t\tcb = (long)*input++;\n\t\t\t\t*ibptr++ = yuv_to_rgb24( y0, cr, cb );\n\t\t\t\t*ibptr++ = yuv_to_rgb24( y2, cr, cb );\n\t\t\t}\n\n\t\t\ticptr = (unsigned int *)vq4;\n\t\t\tidptr = (unsigned int *)vq8;\n\t\n\t\t\tfor(i=0;i<four;i++) {\n\t\t\t\tiaptr = (unsigned int *)vq2 + (*input++)*2;\n\t\t\t\tibptr = (unsigned int *)vq2 + (*input++)*2;\n\t\t\t\tfor(j=0;j<2;j++) { \n\t\t\t\t\tVQ2TO2(iaptr,ibptr,icptr,idptr);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n/******************************************************************************\n*\n* Function:\t\t\n*\n* Description:\t\n*\n******************************************************************************/\n\nstatic void recurseQuad( long startX, long startY, long quadSize, long xOff, long yOff )\n{\n\tbyte *scroff;\n\tlong bigx, bigy, lowx, lowy, useY;\n\tlong offset;\n\n\toffset = cinTable[currentHandle].screenDelta;\n\t\n\tlowx = lowy = 0;\n\tbigx = cinTable[currentHandle].xsize;\n\tbigy = cinTable[currentHandle].ysize;\n\n\tif (bigx > cinTable[currentHandle].CIN_WIDTH) bigx = cinTable[currentHandle].CIN_WIDTH;\n\tif (bigy > cinTable[currentHandle].CIN_HEIGHT) bigy = cinTable[currentHandle].CIN_HEIGHT;\n\n\tif ( (startX >= lowx) && (startX+quadSize) <= (bigx) && (startY+quadSize) <= (bigy) && (startY >= lowy) && quadSize <= MAXSIZE) {\n\t\tuseY = startY;\n\t\tscroff = cin.linbuf + (useY+((cinTable[currentHandle].CIN_HEIGHT-bigy)>>1)+yOff)*(cinTable[currentHandle].samplesPerLine) + (((startX+xOff))*cinTable[currentHandle].samplesPerPixel);\n\n\t\tcin.qStatus[0][cinTable[currentHandle].onQuad  ] = scroff;\n\t\tcin.qStatus[1][cinTable[currentHandle].onQuad++] = scroff+offset;\n\t}\n\n\tif ( quadSize != MINSIZE ) {\n\t\tquadSize >>= 1;\n\t\trecurseQuad( startX,\t\t  startY\t\t  , quadSize, xOff, yOff );\n\t\trecurseQuad( startX+quadSize, startY\t\t  , quadSize, xOff, yOff );\n\t\trecurseQuad( startX,\t\t  startY+quadSize , quadSize, xOff, yOff );\n\t\trecurseQuad( startX+quadSize, startY+quadSize , quadSize, xOff, yOff );\n\t}\n}\n\n\n/******************************************************************************\n*\n* Function:\t\t\n*\n* Description:\t\n*\n******************************************************************************/\n\nstatic void setupQuad( long xOff, long yOff )\n{\n\tlong numQuadCels, i,x,y;\n\tbyte *temp;\n\n\tif (xOff == cin.oldXOff && yOff == cin.oldYOff && cinTable[currentHandle].ysize == cin.oldysize && cinTable[currentHandle].xsize == cin.oldxsize) {\n\t\treturn;\n\t}\n\n\tcin.oldXOff = xOff;\n\tcin.oldYOff = yOff;\n\tcin.oldysize = cinTable[currentHandle].ysize;\n\tcin.oldxsize = cinTable[currentHandle].xsize;\n\n\tnumQuadCels  = (cinTable[currentHandle].CIN_WIDTH*cinTable[currentHandle].CIN_HEIGHT) / (16);\n\tnumQuadCels += numQuadCels/4 + numQuadCels/16;\n\tnumQuadCels += 64;\t\t\t\t\t\t\t  // for overflow\n\n\tnumQuadCels  = (cinTable[currentHandle].xsize*cinTable[currentHandle].ysize) / (16);\n\tnumQuadCels += numQuadCels/4;\n\tnumQuadCels += 64;\t\t\t\t\t\t\t  // for overflow\n\n\tcinTable[currentHandle].onQuad = 0;\n\n\tfor(y=0;y<(long)cinTable[currentHandle].ysize;y+=16) \n\t\tfor(x=0;x<(long)cinTable[currentHandle].xsize;x+=16) \n\t\t\trecurseQuad( x, y, 16, xOff, yOff );\n\n\ttemp = NULL;\n\n\tfor(i=(numQuadCels-64);i<numQuadCels;i++) {\n\t\tcin.qStatus[0][i] = temp;\t\t\t  // eoq\n\t\tcin.qStatus[1][i] = temp;\t\t\t  // eoq\n\t}\n}\n\n/******************************************************************************\n*\n* Function:\t\t\n*\n* Description:\t\n*\n******************************************************************************/\n\nstatic void readQuadInfo( byte *qData )\n{\n\tif (currentHandle < 0) return;\n\n\tcinTable[currentHandle].xsize    = qData[0]+qData[1]*256;\n\tcinTable[currentHandle].ysize    = qData[2]+qData[3]*256;\n\tcinTable[currentHandle].maxsize  = qData[4]+qData[5]*256;\n\tcinTable[currentHandle].minsize  = qData[6]+qData[7]*256;\n\t\n\tcinTable[currentHandle].CIN_HEIGHT = cinTable[currentHandle].ysize;\n\tcinTable[currentHandle].CIN_WIDTH  = cinTable[currentHandle].xsize;\n\n\tcinTable[currentHandle].samplesPerLine = cinTable[currentHandle].CIN_WIDTH*cinTable[currentHandle].samplesPerPixel;\n\tcinTable[currentHandle].screenDelta = cinTable[currentHandle].CIN_HEIGHT*cinTable[currentHandle].samplesPerLine;\n\n\tcinTable[currentHandle].half = qfalse;\n\tcinTable[currentHandle].smootheddouble = qfalse;\n\t\n\tcinTable[currentHandle].VQ0 = cinTable[currentHandle].VQNormal;\n\tcinTable[currentHandle].VQ1 = cinTable[currentHandle].VQBuffer;\n\n\tcinTable[currentHandle].t[0] = (0 - (unsigned int)cin.linbuf)+(unsigned int)cin.linbuf+cinTable[currentHandle].screenDelta;\n\tcinTable[currentHandle].t[1] = (0 - ((unsigned int)cin.linbuf + cinTable[currentHandle].screenDelta))+(unsigned int)cin.linbuf;\n\n        cinTable[currentHandle].drawX = cinTable[currentHandle].CIN_WIDTH;\n        cinTable[currentHandle].drawY = cinTable[currentHandle].CIN_HEIGHT;\n        \n\t// rage pro is very slow at 512 wide textures, voodoo can't do it at all\n\tif ( glConfig.hardwareType == GLHW_RAGEPRO || glConfig.maxTextureSize <= 256) {\n                if (cinTable[currentHandle].drawX>256) {\n                        cinTable[currentHandle].drawX = 256;\n                }\n                if (cinTable[currentHandle].drawY>256) {\n                        cinTable[currentHandle].drawY = 256;\n                }\n\t\tif (cinTable[currentHandle].CIN_WIDTH != 256 || cinTable[currentHandle].CIN_HEIGHT != 256) {\n\t\t\tCom_Printf(\"HACK: approxmimating cinematic for Rage Pro or Voodoo\\n\");\n\t\t}\n\t}\n#if defined(MACOS_X)\n\tcinTable[currentHandle].drawX = 256;\n\tcinTable[currentHandle].drawX = 256;\n#endif\n}\n\n/******************************************************************************\n*\n* Function:\t\t\n*\n* Description:\t\n*\n******************************************************************************/\n\nstatic void RoQPrepMcomp( long xoff, long yoff ) \n{\n\tlong i, j, x, y, temp, temp2;\n\n\ti=cinTable[currentHandle].samplesPerLine; j=cinTable[currentHandle].samplesPerPixel;\n\tif ( cinTable[currentHandle].xsize == (cinTable[currentHandle].ysize*4) && !cinTable[currentHandle].half ) { j = j+j; i = i+i; }\n\t\n\tfor(y=0;y<16;y++) {\n\t\ttemp2 = (y+yoff-8)*i;\n\t\tfor(x=0;x<16;x++) {\n\t\t\ttemp = (x+xoff-8)*j;\n\t\t\tcin.mcomp[(x*16)+y] = cinTable[currentHandle].normalBuffer0-(temp2+temp);\n\t\t}\n\t}\n}\n\n/******************************************************************************\n*\n* Function:\t\t\n*\n* Description:\t\n*\n******************************************************************************/\n\nstatic void initRoQ() \n{\n\tif (currentHandle < 0) return;\n\n\tcinTable[currentHandle].VQNormal = (void (*)(byte *, void *))blitVQQuad32fs;\n\tcinTable[currentHandle].VQBuffer = (void (*)(byte *, void *))blitVQQuad32fs;\n\tcinTable[currentHandle].samplesPerPixel = 4;\n\tROQ_GenYUVTables();\n\tRllSetupTable();\n}\n\n/******************************************************************************\n*\n* Function:\t\t\n*\n* Description:\t\n*\n******************************************************************************/\n/*\nstatic byte* RoQFetchInterlaced( byte *source ) {\n\tint x, *src, *dst;\n\n\tif (currentHandle < 0) return NULL;\n\n\tsrc = (int *)source;\n\tdst = (int *)cinTable[currentHandle].buf2;\n\n\tfor(x=0;x<256*256;x++) {\n\t\t*dst = *src;\n\t\tdst++; src += 2;\n\t}\n\treturn cinTable[currentHandle].buf2;\n}\n*/\nstatic void RoQReset() {\n\t\n\tif (currentHandle < 0) return;\n\n\tSys_EndStreamedFile(cinTable[currentHandle].iFile);\n\tFS_FCloseFile( cinTable[currentHandle].iFile );\n\tFS_FOpenFileRead (cinTable[currentHandle].fileName, &cinTable[currentHandle].iFile, qtrue);\n\t// let the background thread start reading ahead\n\tSys_BeginStreamedFile( cinTable[currentHandle].iFile, 0x10000 );\n\tSys_StreamedRead (cin.file, 16, 1, cinTable[currentHandle].iFile);\n\tRoQ_init();\n\tcinTable[currentHandle].status = FMV_LOOPED;\n}\n\n/******************************************************************************\n*\n* Function:\t\t\n*\n* Description:\t\n*\n******************************************************************************/\n\nstatic void RoQInterrupt(void)\n{\n\tbyte\t\t\t\t*framedata;\n        short\t\tsbuf[32768];\n        int\t\tssize;\n        \n\tif (currentHandle < 0) return;\n\n\tSys_StreamedRead( cin.file, cinTable[currentHandle].RoQFrameSize+8, 1, cinTable[currentHandle].iFile );\n\tif ( cinTable[currentHandle].RoQPlayed >= cinTable[currentHandle].ROQSize ) { \n\t\tif (cinTable[currentHandle].holdAtEnd==qfalse) {\n\t\t\tif (cinTable[currentHandle].looping) {\n\t\t\t\tRoQReset();\n\t\t\t} else {\n\t\t\t\tcinTable[currentHandle].status = FMV_EOF;\n\t\t\t}\n\t\t} else {\n\t\t\tcinTable[currentHandle].status = FMV_IDLE;\n\t\t}\n\t\treturn; \n\t}\n\n\tframedata = cin.file;\n//\n// new frame is ready\n//\nredump:\n\tswitch(cinTable[currentHandle].roq_id) \n\t{\n\t\tcase\tROQ_QUAD_VQ:\n\t\t\tif ((cinTable[currentHandle].numQuads&1)) {\n\t\t\t\tcinTable[currentHandle].normalBuffer0 = cinTable[currentHandle].t[1];\n\t\t\t\tRoQPrepMcomp( cinTable[currentHandle].roqF0, cinTable[currentHandle].roqF1 );\n\t\t\t\tcinTable[currentHandle].VQ1( (byte *)cin.qStatus[1], framedata);\n\t\t\t\tcinTable[currentHandle].buf = \tcin.linbuf + cinTable[currentHandle].screenDelta;\n\t\t\t} else {\n\t\t\t\tcinTable[currentHandle].normalBuffer0 = cinTable[currentHandle].t[0];\n\t\t\t\tRoQPrepMcomp( cinTable[currentHandle].roqF0, cinTable[currentHandle].roqF1 );\n\t\t\t\tcinTable[currentHandle].VQ0( (byte *)cin.qStatus[0], framedata );\n\t\t\t\tcinTable[currentHandle].buf = \tcin.linbuf;\n\t\t\t}\n\t\t\tif (cinTable[currentHandle].numQuads == 0) {\t\t// first frame\n\t\t\t\tCom_Memcpy(cin.linbuf+cinTable[currentHandle].screenDelta, cin.linbuf, cinTable[currentHandle].samplesPerLine*cinTable[currentHandle].ysize);\n\t\t\t}\n\t\t\tcinTable[currentHandle].numQuads++;\n\t\t\tcinTable[currentHandle].dirty = qtrue;\n\t\t\tbreak;\n\t\tcase\tROQ_CODEBOOK:\n\t\t\tdecodeCodeBook( framedata, (unsigned short)cinTable[currentHandle].roq_flags );\n\t\t\tbreak;\n\t\tcase\tZA_SOUND_MONO:\n\t\t\tif (!cinTable[currentHandle].silent) {\n\t\t\t\tssize = RllDecodeMonoToStereo( framedata, sbuf, cinTable[currentHandle].RoQFrameSize, 0, (unsigned short)cinTable[currentHandle].roq_flags);\n                                S_RawSamples( ssize, 22050, 2, 1, (byte *)sbuf, 1.0f );\n\t\t\t}\n\t\t\tbreak;\n\t\tcase\tZA_SOUND_STEREO:\n\t\t\tif (!cinTable[currentHandle].silent) {\n\t\t\t\tif (cinTable[currentHandle].numQuads == -1) {\n\t\t\t\t\tS_Update();\n\t\t\t\t\ts_rawend = s_soundtime;\n\t\t\t\t}\n\t\t\t\tssize = RllDecodeStereoToStereo( framedata, sbuf, cinTable[currentHandle].RoQFrameSize, 0, (unsigned short)cinTable[currentHandle].roq_flags);\n                                S_RawSamples( ssize, 22050, 2, 2, (byte *)sbuf, 1.0f );\n\t\t\t}\n\t\t\tbreak;\n\t\tcase\tROQ_QUAD_INFO:\n\t\t\tif (cinTable[currentHandle].numQuads == -1) {\n\t\t\t\treadQuadInfo( framedata );\n\t\t\t\tsetupQuad( 0, 0 );\n\t\t\t\t// we need to use CL_ScaledMilliseconds because of the smp mode calls from the renderer\n\t\t\t\tcinTable[currentHandle].startTime = cinTable[currentHandle].lastTime = CL_ScaledMilliseconds()*com_timescale->value;\n\t\t\t}\n\t\t\tif (cinTable[currentHandle].numQuads != 1) cinTable[currentHandle].numQuads = 0;\n\t\t\tbreak;\n\t\tcase\tROQ_PACKET:\n\t\t\tcinTable[currentHandle].inMemory = cinTable[currentHandle].roq_flags;\n\t\t\tcinTable[currentHandle].RoQFrameSize = 0;           // for header\n\t\t\tbreak;\n\t\tcase\tROQ_QUAD_HANG:\n\t\t\tcinTable[currentHandle].RoQFrameSize = 0;\n\t\t\tbreak;\n\t\tcase\tROQ_QUAD_JPEG:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tcinTable[currentHandle].status = FMV_EOF;\n\t\t\tbreak;\n\t}\t\n//\n// read in next frame data\n//\n\tif ( cinTable[currentHandle].RoQPlayed >= cinTable[currentHandle].ROQSize ) { \n\t\tif (cinTable[currentHandle].holdAtEnd==qfalse) {\n\t\t\tif (cinTable[currentHandle].looping) {\n\t\t\t\tRoQReset();\n\t\t\t} else {\n\t\t\t\tcinTable[currentHandle].status = FMV_EOF;\n\t\t\t}\n\t\t} else {\n\t\t\tcinTable[currentHandle].status = FMV_IDLE;\n\t\t}\n\t\treturn; \n\t}\n\t\n\tframedata\t\t += cinTable[currentHandle].RoQFrameSize;\n\tcinTable[currentHandle].roq_id\t\t = framedata[0] + framedata[1]*256;\n\tcinTable[currentHandle].RoQFrameSize = framedata[2] + framedata[3]*256 + framedata[4]*65536;\n\tcinTable[currentHandle].roq_flags\t = framedata[6] + framedata[7]*256;\n\tcinTable[currentHandle].roqF0\t\t = (char)framedata[7];\n\tcinTable[currentHandle].roqF1\t\t = (char)framedata[6];\n\n\tif (cinTable[currentHandle].RoQFrameSize>65536||cinTable[currentHandle].roq_id==0x1084) {\n\t\tCom_DPrintf(\"roq_size>65536||roq_id==0x1084\\n\");\n\t\tcinTable[currentHandle].status = FMV_EOF;\n\t\tif (cinTable[currentHandle].looping) {\n\t\t\tRoQReset();\n\t\t}\n\t\treturn;\n\t}\n\tif (cinTable[currentHandle].inMemory && (cinTable[currentHandle].status != FMV_EOF)) { cinTable[currentHandle].inMemory--; framedata += 8; goto redump; }\n//\n// one more frame hits the dust\n//\n//\tassert(cinTable[currentHandle].RoQFrameSize <= 65536);\n//\tr = Sys_StreamedRead( cin.file, cinTable[currentHandle].RoQFrameSize+8, 1, cinTable[currentHandle].iFile );\n\tcinTable[currentHandle].RoQPlayed\t+= cinTable[currentHandle].RoQFrameSize+8;\n}\n\n/******************************************************************************\n*\n* Function:\t\t\n*\n* Description:\t\n*\n******************************************************************************/\n\nstatic void RoQ_init( void )\n{\n\t// we need to use CL_ScaledMilliseconds because of the smp mode calls from the renderer\n\tcinTable[currentHandle].startTime = cinTable[currentHandle].lastTime = CL_ScaledMilliseconds()*com_timescale->value;\n\n\tcinTable[currentHandle].RoQPlayed = 24;\n\n/*\tget frame rate */\t\n\tcinTable[currentHandle].roqFPS\t = cin.file[ 6] + cin.file[ 7]*256;\n\t\n\tif (!cinTable[currentHandle].roqFPS) cinTable[currentHandle].roqFPS = 30;\n\n\tcinTable[currentHandle].numQuads = -1;\n\n\tcinTable[currentHandle].roq_id\t\t= cin.file[ 8] + cin.file[ 9]*256;\n\tcinTable[currentHandle].RoQFrameSize\t= cin.file[10] + cin.file[11]*256 + cin.file[12]*65536;\n\tcinTable[currentHandle].roq_flags\t= cin.file[14] + cin.file[15]*256;\n\n\tif (cinTable[currentHandle].RoQFrameSize > 65536 || !cinTable[currentHandle].RoQFrameSize) { \n\t\treturn;\n\t}\n\n}\n\n/******************************************************************************\n*\n* Function:\t\t\n*\n* Description:\t\n*\n******************************************************************************/\n\nstatic void RoQShutdown( void ) {\n\tconst char *s;\n\n\tif (!cinTable[currentHandle].buf) {\n\t\treturn;\n\t}\n\n\tif ( cinTable[currentHandle].status == FMV_IDLE ) {\n\t\treturn;\n\t}\n\tCom_DPrintf(\"finished cinematic\\n\");\n\tcinTable[currentHandle].status = FMV_IDLE;\n\n\tif (cinTable[currentHandle].iFile) {\n\t\tSys_EndStreamedFile( cinTable[currentHandle].iFile );\n\t\tFS_FCloseFile( cinTable[currentHandle].iFile );\n\t\tcinTable[currentHandle].iFile = 0;\n\t}\n\n\tif (cinTable[currentHandle].alterGameState) {\n\t\tcls.state = CA_DISCONNECTED;\n\t\t// we can't just do a vstr nextmap, because\n\t\t// if we are aborting the intro cinematic with\n\t\t// a devmap command, nextmap would be valid by\n\t\t// the time it was referenced\n\t\ts = Cvar_VariableString( \"nextmap\" );\n\t\tif ( s[0] ) {\n\t\t\tCbuf_ExecuteText( EXEC_APPEND, va(\"%s\\n\", s) );\n\t\t\tCvar_Set( \"nextmap\", \"\" );\n\t\t}\n\t\tCL_handle = -1;\n\t}\n\tcinTable[currentHandle].fileName[0] = 0;\n\tcurrentHandle = -1;\n}\n\n/*\n==================\nSCR_StopCinematic\n==================\n*/\ne_status CIN_StopCinematic(int handle) {\n\t\n\tif (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return FMV_EOF;\n\tcurrentHandle = handle;\n\n\tCom_DPrintf(\"trFMV::stop(), closing %s\\n\", cinTable[currentHandle].fileName);\n\n\tif (!cinTable[currentHandle].buf) {\n\t\treturn FMV_EOF;\n\t}\n\n\tif (cinTable[currentHandle].alterGameState) {\n\t\tif ( cls.state != CA_CINEMATIC ) {\n\t\t\treturn cinTable[currentHandle].status;\n\t\t}\n\t}\n\tcinTable[currentHandle].status = FMV_EOF;\n\tRoQShutdown();\n\n\treturn FMV_EOF;\n}\n\n/*\n==================\nSCR_RunCinematic\n\nFetch and decompress the pending frame\n==================\n*/\n\n\ne_status CIN_RunCinematic (int handle)\n{\n        // bk001204 - init\n\tint\tstart = 0;\n\tint     thisTime = 0;\n\n\tif (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return FMV_EOF;\n\n\tif (cin.currentHandle != handle) {\n\t\tcurrentHandle = handle;\n\t\tcin.currentHandle = currentHandle;\n\t\tcinTable[currentHandle].status = FMV_EOF;\n\t\tRoQReset();\n\t}\n\n\tif (cinTable[handle].playonwalls < -1)\n\t{\n\t\treturn cinTable[handle].status;\n\t}\n\n\tcurrentHandle = handle;\n\n\tif (cinTable[currentHandle].alterGameState) {\n\t\tif ( cls.state != CA_CINEMATIC ) {\n\t\t\treturn cinTable[currentHandle].status;\n\t\t}\n\t}\n\n\tif (cinTable[currentHandle].status == FMV_IDLE) {\n\t\treturn cinTable[currentHandle].status;\n\t}\n\n\t// we need to use CL_ScaledMilliseconds because of the smp mode calls from the renderer\n\tthisTime = CL_ScaledMilliseconds()*com_timescale->value;\n\tif (cinTable[currentHandle].shader && (abs(thisTime - cinTable[currentHandle].lastTime))>100) {\n\t\tcinTable[currentHandle].startTime += thisTime - cinTable[currentHandle].lastTime;\n\t}\n\t// we need to use CL_ScaledMilliseconds because of the smp mode calls from the renderer\n\tcinTable[currentHandle].tfps = ((((CL_ScaledMilliseconds()*com_timescale->value) - cinTable[currentHandle].startTime)*3)/100);\n\n\tstart = cinTable[currentHandle].startTime;\n\twhile(  (cinTable[currentHandle].tfps != cinTable[currentHandle].numQuads)\n\t\t&& (cinTable[currentHandle].status == FMV_PLAY) ) \n\t{\n\t\tRoQInterrupt();\n\t\tif (start != cinTable[currentHandle].startTime) {\n\t\t\t// we need to use CL_ScaledMilliseconds because of the smp mode calls from the renderer\n\t\t  cinTable[currentHandle].tfps = ((((CL_ScaledMilliseconds()*com_timescale->value)\n\t\t\t\t\t\t\t  - cinTable[currentHandle].startTime)*3)/100);\n\t\t\tstart = cinTable[currentHandle].startTime;\n\t\t}\n\t}\n\n\tcinTable[currentHandle].lastTime = thisTime;\n\n\tif (cinTable[currentHandle].status == FMV_LOOPED) {\n\t\tcinTable[currentHandle].status = FMV_PLAY;\n\t}\n\n\tif (cinTable[currentHandle].status == FMV_EOF) {\n\t  if (cinTable[currentHandle].looping) {\n\t\tRoQReset();\n\t  } else {\n\t\tRoQShutdown();\n\t  }\n\t}\n\n\treturn cinTable[currentHandle].status;\n}\n\n/*\n==================\nCL_PlayCinematic\n\n==================\n*/\nint CIN_PlayCinematic( const char *arg, int x, int y, int w, int h, int systemBits ) {\n\tunsigned short RoQID;\n\tchar\tname[MAX_OSPATH];\n\tint\t\ti;\n\n\tif (strstr(arg, \"/\") == NULL && strstr(arg, \"\\\\\") == NULL) {\n\t\tCom_sprintf (name, sizeof(name), \"video/%s\", arg);\n\t} else {\n\t\tCom_sprintf (name, sizeof(name), \"%s\", arg);\n\t}\n\n\tif (!(systemBits & CIN_system)) {\n\t\tfor ( i = 0 ; i < MAX_VIDEO_HANDLES ; i++ ) {\n\t\t\tif (!strcmp(cinTable[i].fileName, name) ) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t}\n\n\tCom_DPrintf(\"SCR_PlayCinematic( %s )\\n\", arg);\n\n\tCom_Memset(&cin, 0, sizeof(cinematics_t) );\n\tcurrentHandle = CIN_HandleForVideo();\n\n\tcin.currentHandle = currentHandle;\n\n\tstrcpy(cinTable[currentHandle].fileName, name);\n\n\tcinTable[currentHandle].ROQSize = 0;\n\tcinTable[currentHandle].ROQSize = FS_FOpenFileRead (cinTable[currentHandle].fileName, &cinTable[currentHandle].iFile, qtrue);\n\n\tif (cinTable[currentHandle].ROQSize<=0) {\n\t\tCom_DPrintf(\"play(%s), ROQSize<=0\\n\", arg);\n\t\tcinTable[currentHandle].fileName[0] = 0;\n\t\treturn -1;\n\t}\n\n\tCIN_SetExtents(currentHandle, x, y, w, h);\n\tCIN_SetLooping(currentHandle, (systemBits & CIN_loop)!=0);\n\n\tcinTable[currentHandle].CIN_HEIGHT = DEFAULT_CIN_HEIGHT;\n\tcinTable[currentHandle].CIN_WIDTH  =  DEFAULT_CIN_WIDTH;\n\tcinTable[currentHandle].holdAtEnd = (systemBits & CIN_hold) != 0;\n\tcinTable[currentHandle].alterGameState = (systemBits & CIN_system) != 0;\n\tcinTable[currentHandle].playonwalls = 1;\n\tcinTable[currentHandle].silent = (systemBits & CIN_silent) != 0;\n\tcinTable[currentHandle].shader = (systemBits & CIN_shader) != 0;\n\n\tif (cinTable[currentHandle].alterGameState) {\n\t\t// close the menu\n\t\tif ( uivm ) {\n\t\t\tVM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_NONE );\n\t\t}\n\t} else {\n\t\tcinTable[currentHandle].playonwalls = cl_inGameVideo->integer;\n\t}\n\n\tinitRoQ();\n\t\t\t\t\t\n\tFS_Read (cin.file, 16, cinTable[currentHandle].iFile);\n\n\tRoQID = (unsigned short)(cin.file[0]) + (unsigned short)(cin.file[1])*256;\n\tif (RoQID == 0x1084)\n\t{\n\t\tRoQ_init();\n//\t\tFS_Read (cin.file, cinTable[currentHandle].RoQFrameSize+8, cinTable[currentHandle].iFile);\n\t\t// let the background thread start reading ahead\n\t\tSys_BeginStreamedFile( cinTable[currentHandle].iFile, 0x10000 );\n\n\t\tcinTable[currentHandle].status = FMV_PLAY;\n\t\tCom_DPrintf(\"trFMV::play(), playing %s\\n\", arg);\n\n\t\tif (cinTable[currentHandle].alterGameState) {\n\t\t\tcls.state = CA_CINEMATIC;\n\t\t}\n\t\t\n\t\tCon_Close();\n\n\t\ts_rawend = s_soundtime;\n\n\t\treturn currentHandle;\n\t}\n\tCom_DPrintf(\"trFMV::play(), invalid RoQ ID\\n\");\n\n\tRoQShutdown();\n\treturn -1;\n}\n\nvoid CIN_SetExtents (int handle, int x, int y, int w, int h) {\n\tif (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return;\n\tcinTable[handle].xpos = x;\n\tcinTable[handle].ypos = y;\n\tcinTable[handle].width = w;\n\tcinTable[handle].height = h;\n\tcinTable[handle].dirty = qtrue;\n}\n\nvoid CIN_SetLooping(int handle, qboolean loop) {\n\tif (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return;\n\tcinTable[handle].looping = loop;\n}\n\n/*\n==================\nSCR_DrawCinematic\n\n==================\n*/\nvoid CIN_DrawCinematic (int handle) {\n\tfloat\tx, y, w, h;\n\tbyte\t*buf;\n\n\tif (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return;\n\n\tif (!cinTable[handle].buf) {\n\t\treturn;\n\t}\n\n\tx = cinTable[handle].xpos;\n\ty = cinTable[handle].ypos;\n\tw = cinTable[handle].width;\n\th = cinTable[handle].height;\n\tbuf = cinTable[handle].buf;\n\tSCR_AdjustFrom640( &x, &y, &w, &h );\n\n\tif (cinTable[handle].dirty && (cinTable[handle].CIN_WIDTH != cinTable[handle].drawX || cinTable[handle].CIN_HEIGHT != cinTable[handle].drawY)) {\n\t\tint ix, iy, *buf2, *buf3, xm, ym, ll;\n                \n\t\txm = cinTable[handle].CIN_WIDTH/256;\n\t\tym = cinTable[handle].CIN_HEIGHT/256;\n                ll = 8;\n                if (cinTable[handle].CIN_WIDTH==512) {\n                    ll = 9;\n                }\n                \n\t\tbuf3 = (int*)buf;\n\t\tbuf2 = Hunk_AllocateTempMemory( 256*256*4 );\n                if (xm==2 && ym==2) {\n                    byte *bc2, *bc3;\n                    int\tic, iiy;\n                    \n                    bc2 = (byte *)buf2;\n                    bc3 = (byte *)buf3;\n                    for (iy = 0; iy<256; iy++) {\n                            iiy = iy<<12;\n                            for (ix = 0; ix<2048; ix+=8) {\n                                for(ic = ix;ic<(ix+4);ic++) {\n                                    *bc2=(bc3[iiy+ic]+bc3[iiy+4+ic]+bc3[iiy+2048+ic]+bc3[iiy+2048+4+ic])>>2;\n                                    bc2++;\n                                }\n                            }\n                    }\n                } else if (xm==2 && ym==1) {\n                    byte *bc2, *bc3;\n                    int\tic, iiy;\n                    \n                    bc2 = (byte *)buf2;\n                    bc3 = (byte *)buf3;\n                    for (iy = 0; iy<256; iy++) {\n                            iiy = iy<<11;\n                            for (ix = 0; ix<2048; ix+=8) {\n                                for(ic = ix;ic<(ix+4);ic++) {\n                                    *bc2=(bc3[iiy+ic]+bc3[iiy+4+ic])>>1;\n                                    bc2++;\n                                }\n                            }\n                    }\n                } else {\n                    for (iy = 0; iy<256; iy++) {\n                            for (ix = 0; ix<256; ix++) {\n                                    buf2[(iy<<8)+ix] = buf3[((iy*ym)<<ll) + (ix*xm)];\n                            }\n                    }\n                }\n\t\tre.DrawStretchRaw( x, y, w, h, 256, 256, (byte *)buf2, handle, qtrue);\n\t\tcinTable[handle].dirty = qfalse;\n\t\tHunk_FreeTempMemory(buf2);\n\t\treturn;\n\t}\n\n\tre.DrawStretchRaw( x, y, w, h, cinTable[handle].drawX, cinTable[handle].drawY, buf, handle, cinTable[handle].dirty);\n\tcinTable[handle].dirty = qfalse;\n}\n\nvoid CL_PlayCinematic_f(void) {\n\tchar\t*arg, *s;\n\tqboolean\tholdatend;\n\tint bits = CIN_system;\n\n\tCom_DPrintf(\"CL_PlayCinematic_f\\n\");\n\tif (cls.state == CA_CINEMATIC) {\n\t\tSCR_StopCinematic();\n\t}\n\n\targ = Cmd_Argv( 1 );\n\ts = Cmd_Argv(2);\n\n\tholdatend = qfalse;\n\tif ((s && s[0] == '1') || Q_stricmp(arg,\"demoend.roq\")==0 || Q_stricmp(arg,\"end.roq\")==0) {\n\t\tbits |= CIN_hold;\n\t}\n\tif (s && s[0] == '2') {\n\t\tbits |= CIN_loop;\n\t}\n\n\tS_StopAllSounds ();\n\n\tCL_handle = CIN_PlayCinematic( arg, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, bits );\n\tif (CL_handle >= 0) {\n\t\tdo {\n\t\t\tSCR_RunCinematic();\n\t\t} while (cinTable[currentHandle].buf == NULL && cinTable[currentHandle].status == FMV_PLAY);\t\t// wait for first frame (load codebook and sound)\n\t}\n}\n\n\nvoid SCR_DrawCinematic (void) {\n\tif (CL_handle >= 0 && CL_handle < MAX_VIDEO_HANDLES) {\n\t\tCIN_DrawCinematic(CL_handle);\n\t}\n}\n\nvoid SCR_RunCinematic (void)\n{\n\tif (CL_handle >= 0 && CL_handle < MAX_VIDEO_HANDLES) {\n\t\tCIN_RunCinematic(CL_handle);\n\t}\n}\n\nvoid SCR_StopCinematic(void) {\n\tif (CL_handle >= 0 && CL_handle < MAX_VIDEO_HANDLES) {\n\t\tCIN_StopCinematic(CL_handle);\n\t\tS_StopAllSounds ();\n\t\tCL_handle = -1;\n\t}\n}\n\nvoid CIN_UploadCinematic(int handle) {\n\tif (handle >= 0 && handle < MAX_VIDEO_HANDLES) {\n\t\tif (!cinTable[handle].buf) {\n\t\t\treturn;\n\t\t}\n\t\tif (cinTable[handle].playonwalls <= 0 && cinTable[handle].dirty) {\n\t\t\tif (cinTable[handle].playonwalls == 0) {\n\t\t\t\tcinTable[handle].playonwalls = -1;\n\t\t\t} else {\n\t\t\t\tif (cinTable[handle].playonwalls == -1) {\n\t\t\t\t\tcinTable[handle].playonwalls = -2;\n\t\t\t\t} else {\n\t\t\t\t\tcinTable[handle].dirty = qfalse;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tre.UploadCinematic( 256, 256, 256, 256, cinTable[handle].buf, handle, cinTable[handle].dirty);\n\t\tif (cl_inGameVideo->integer == 0 && cinTable[handle].playonwalls == 1) {\n\t\t\tcinTable[handle].playonwalls--;\n\t\t}\n\t}\n}\n\n"
  },
  {
    "path": "code/client/cl_console.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// console.c\n\n#include \"client.h\"\n\n\nint g_console_field_width = 78;\n\n\n#define\tNUM_CON_TIMES 4\n\n#define\t\tCON_TEXTSIZE\t32768\ntypedef struct {\n\tqboolean\tinitialized;\n\n\tshort\ttext[CON_TEXTSIZE];\n\tint\t\tcurrent;\t\t// line where next message will be printed\n\tint\t\tx;\t\t\t\t// offset in current line for next print\n\tint\t\tdisplay;\t\t// bottom of console displays this line\n\n\tint \tlinewidth;\t\t// characters across screen\n\tint\t\ttotallines;\t\t// total lines in console scrollback\n\n\tfloat\txadjust;\t\t// for wide aspect screens\n\n\tfloat\tdisplayFrac;\t// aproaches finalFrac at scr_conspeed\n\tfloat\tfinalFrac;\t\t// 0.0 to 1.0 lines of console to display\n\n\tint\t\tvislines;\t\t// in scanlines\n\n\tint\t\ttimes[NUM_CON_TIMES];\t// cls.realtime time the line was generated\n\t\t\t\t\t\t\t\t// for transparent notify lines\n\tvec4_t\tcolor;\n} console_t;\n\nextern\tconsole_t\tcon;\n\nconsole_t\tcon;\n\ncvar_t\t\t*con_conspeed;\ncvar_t\t\t*con_notifytime;\n\n#define\tDEFAULT_CONSOLE_WIDTH\t78\n\nvec4_t\tconsole_color = {1.0, 1.0, 1.0, 1.0};\n\n\n/*\n================\nCon_ToggleConsole_f\n================\n*/\nvoid Con_ToggleConsole_f (void) {\n\t// closing a full screen console restarts the demo loop\n\tif ( cls.state == CA_DISCONNECTED && cls.keyCatchers == KEYCATCH_CONSOLE ) {\n\t\tCL_StartDemoLoop();\n\t\treturn;\n\t}\n\n\tField_Clear( &g_consoleField );\n\tg_consoleField.widthInChars = g_console_field_width;\n\n\tCon_ClearNotify ();\n\tcls.keyCatchers ^= KEYCATCH_CONSOLE;\n}\n\n/*\n================\nCon_MessageMode_f\n================\n*/\nvoid Con_MessageMode_f (void) {\n\tchat_playerNum = -1;\n\tchat_team = qfalse;\n\tField_Clear( &chatField );\n\tchatField.widthInChars = 30;\n\n\tcls.keyCatchers ^= KEYCATCH_MESSAGE;\n}\n\n/*\n================\nCon_MessageMode2_f\n================\n*/\nvoid Con_MessageMode2_f (void) {\n\tchat_playerNum = -1;\n\tchat_team = qtrue;\n\tField_Clear( &chatField );\n\tchatField.widthInChars = 25;\n\tcls.keyCatchers ^= KEYCATCH_MESSAGE;\n}\n\n/*\n================\nCon_MessageMode3_f\n================\n*/\nvoid Con_MessageMode3_f (void) {\n\tchat_playerNum = VM_Call( cgvm, CG_CROSSHAIR_PLAYER );\n\tif ( chat_playerNum < 0 || chat_playerNum >= MAX_CLIENTS ) {\n\t\tchat_playerNum = -1;\n\t\treturn;\n\t}\n\tchat_team = qfalse;\n\tField_Clear( &chatField );\n\tchatField.widthInChars = 30;\n\tcls.keyCatchers ^= KEYCATCH_MESSAGE;\n}\n\n/*\n================\nCon_MessageMode4_f\n================\n*/\nvoid Con_MessageMode4_f (void) {\n\tchat_playerNum = VM_Call( cgvm, CG_LAST_ATTACKER );\n\tif ( chat_playerNum < 0 || chat_playerNum >= MAX_CLIENTS ) {\n\t\tchat_playerNum = -1;\n\t\treturn;\n\t}\n\tchat_team = qfalse;\n\tField_Clear( &chatField );\n\tchatField.widthInChars = 30;\n\tcls.keyCatchers ^= KEYCATCH_MESSAGE;\n}\n\n/*\n================\nCon_Clear_f\n================\n*/\nvoid Con_Clear_f (void) {\n\tint\t\ti;\n\n\tfor ( i = 0 ; i < CON_TEXTSIZE ; i++ ) {\n\t\tcon.text[i] = (ColorIndex(COLOR_WHITE)<<8) | ' ';\n\t}\n\n\tCon_Bottom();\t\t// go to end\n}\n\n\t\t\t\t\t\t\n/*\n================\nCon_Dump_f\n\nSave the console contents out to a file\n================\n*/\nvoid Con_Dump_f (void)\n{\n\tint\t\tl, x, i;\n\tshort\t*line;\n\tfileHandle_t\tf;\n\tchar\tbuffer[1024];\n\n\tif (Cmd_Argc() != 2)\n\t{\n\t\tCom_Printf (\"usage: condump <filename>\\n\");\n\t\treturn;\n\t}\n\n\tCom_Printf (\"Dumped console text to %s.\\n\", Cmd_Argv(1) );\n\n\tf = FS_FOpenFileWrite( Cmd_Argv( 1 ) );\n\tif (!f)\n\t{\n\t\tCom_Printf (\"ERROR: couldn't open.\\n\");\n\t\treturn;\n\t}\n\n\t// skip empty lines\n\tfor (l = con.current - con.totallines + 1 ; l <= con.current ; l++)\n\t{\n\t\tline = con.text + (l%con.totallines)*con.linewidth;\n\t\tfor (x=0 ; x<con.linewidth ; x++)\n\t\t\tif ((line[x] & 0xff) != ' ')\n\t\t\t\tbreak;\n\t\tif (x != con.linewidth)\n\t\t\tbreak;\n\t}\n\n\t// write the remaining lines\n\tbuffer[con.linewidth] = 0;\n\tfor ( ; l <= con.current ; l++)\n\t{\n\t\tline = con.text + (l%con.totallines)*con.linewidth;\n\t\tfor(i=0; i<con.linewidth; i++)\n\t\t\tbuffer[i] = line[i] & 0xff;\n\t\tfor (x=con.linewidth-1 ; x>=0 ; x--)\n\t\t{\n\t\t\tif (buffer[x] == ' ')\n\t\t\t\tbuffer[x] = 0;\n\t\t\telse\n\t\t\t\tbreak;\n\t\t}\n\t\tstrcat( buffer, \"\\n\" );\n\t\tFS_Write(buffer, strlen(buffer), f);\n\t}\n\n\tFS_FCloseFile( f );\n}\n\n\t\t\t\t\t\t\n/*\n================\nCon_ClearNotify\n================\n*/\nvoid Con_ClearNotify( void ) {\n\tint\t\ti;\n\t\n\tfor ( i = 0 ; i < NUM_CON_TIMES ; i++ ) {\n\t\tcon.times[i] = 0;\n\t}\n}\n\n\t\t\t\t\t\t\n\n/*\n================\nCon_CheckResize\n\nIf the line width has changed, reformat the buffer.\n================\n*/\nvoid Con_CheckResize (void)\n{\n\tint\t\ti, j, width, oldwidth, oldtotallines, numlines, numchars;\n\tMAC_STATIC short\ttbuf[CON_TEXTSIZE];\n\n\twidth = (SCREEN_WIDTH / SMALLCHAR_WIDTH) - 2;\n\n\tif (width == con.linewidth)\n\t\treturn;\n\n\tif (width < 1)\t\t\t// video hasn't been initialized yet\n\t{\n\t\twidth = DEFAULT_CONSOLE_WIDTH;\n\t\tcon.linewidth = width;\n\t\tcon.totallines = CON_TEXTSIZE / con.linewidth;\n\t\tfor(i=0; i<CON_TEXTSIZE; i++)\n\n\t\t\tcon.text[i] = (ColorIndex(COLOR_WHITE)<<8) | ' ';\n\t}\n\telse\n\t{\n\t\toldwidth = con.linewidth;\n\t\tcon.linewidth = width;\n\t\toldtotallines = con.totallines;\n\t\tcon.totallines = CON_TEXTSIZE / con.linewidth;\n\t\tnumlines = oldtotallines;\n\n\t\tif (con.totallines < numlines)\n\t\t\tnumlines = con.totallines;\n\n\t\tnumchars = oldwidth;\n\t\n\t\tif (con.linewidth < numchars)\n\t\t\tnumchars = con.linewidth;\n\n\t\tCom_Memcpy (tbuf, con.text, CON_TEXTSIZE * sizeof(short));\n\t\tfor(i=0; i<CON_TEXTSIZE; i++)\n\n\t\t\tcon.text[i] = (ColorIndex(COLOR_WHITE)<<8) | ' ';\n\n\n\t\tfor (i=0 ; i<numlines ; i++)\n\t\t{\n\t\t\tfor (j=0 ; j<numchars ; j++)\n\t\t\t{\n\t\t\t\tcon.text[(con.totallines - 1 - i) * con.linewidth + j] =\n\t\t\t\t\t\ttbuf[((con.current - i + oldtotallines) %\n\t\t\t\t\t\t\t  oldtotallines) * oldwidth + j];\n\t\t\t}\n\t\t}\n\n\t\tCon_ClearNotify ();\n\t}\n\n\tcon.current = con.totallines - 1;\n\tcon.display = con.current;\n}\n\n\n/*\n================\nCon_Init\n================\n*/\nvoid Con_Init (void) {\n\tint\t\ti;\n\n\tcon_notifytime = Cvar_Get (\"con_notifytime\", \"3\", 0);\n\tcon_conspeed = Cvar_Get (\"scr_conspeed\", \"3\", 0);\n\n\tField_Clear( &g_consoleField );\n\tg_consoleField.widthInChars = g_console_field_width;\n\tfor ( i = 0 ; i < COMMAND_HISTORY ; i++ ) {\n\t\tField_Clear( &historyEditLines[i] );\n\t\thistoryEditLines[i].widthInChars = g_console_field_width;\n\t}\n\n\tCmd_AddCommand (\"toggleconsole\", Con_ToggleConsole_f);\n\tCmd_AddCommand (\"messagemode\", Con_MessageMode_f);\n\tCmd_AddCommand (\"messagemode2\", Con_MessageMode2_f);\n\tCmd_AddCommand (\"messagemode3\", Con_MessageMode3_f);\n\tCmd_AddCommand (\"messagemode4\", Con_MessageMode4_f);\n\tCmd_AddCommand (\"clear\", Con_Clear_f);\n\tCmd_AddCommand (\"condump\", Con_Dump_f);\n}\n\n\n/*\n===============\nCon_Linefeed\n===============\n*/\nvoid Con_Linefeed (qboolean skipnotify)\n{\n\tint\t\ti;\n\n\t// mark time for transparent overlay\n\tif (con.current >= 0)\n\t{\n    if (skipnotify)\n\t\t  con.times[con.current % NUM_CON_TIMES] = 0;\n    else\n\t\t  con.times[con.current % NUM_CON_TIMES] = cls.realtime;\n\t}\n\n\tcon.x = 0;\n\tif (con.display == con.current)\n\t\tcon.display++;\n\tcon.current++;\n\tfor(i=0; i<con.linewidth; i++)\n\t\tcon.text[(con.current%con.totallines)*con.linewidth+i] = (ColorIndex(COLOR_WHITE)<<8) | ' ';\n}\n\n/*\n================\nCL_ConsolePrint\n\nHandles cursor positioning, line wrapping, etc\nAll console printing must go through this in order to be logged to disk\nIf no console is visible, the text will appear at the top of the game window\n================\n*/\nvoid CL_ConsolePrint( char *txt ) {\n\tint\t\ty;\n\tint\t\tc, l;\n\tint\t\tcolor;\n\tqboolean skipnotify = qfalse;\t\t// NERVE - SMF\n\tint prev;\t\t\t\t\t\t\t// NERVE - SMF\n\n\t// TTimo - prefix for text that shows up in console but not in notify\n\t// backported from RTCW\n\tif ( !Q_strncmp( txt, \"[skipnotify]\", 12 ) ) {\n\t\tskipnotify = qtrue;\n\t\ttxt += 12;\n\t}\n\t\n\t// for some demos we don't want to ever show anything on the console\n\tif ( cl_noprint && cl_noprint->integer ) {\n\t\treturn;\n\t}\n\t\n\tif (!con.initialized) {\n\t\tcon.color[0] = \n\t\tcon.color[1] = \n\t\tcon.color[2] =\n\t\tcon.color[3] = 1.0f;\n\t\tcon.linewidth = -1;\n\t\tCon_CheckResize ();\n\t\tcon.initialized = qtrue;\n\t}\n\n\tcolor = ColorIndex(COLOR_WHITE);\n\n\twhile ( (c = *txt) != 0 ) {\n\t\tif ( Q_IsColorString( txt ) ) {\n\t\t\tcolor = ColorIndex( *(txt+1) );\n\t\t\ttxt += 2;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// count word length\n\t\tfor (l=0 ; l< con.linewidth ; l++) {\n\t\t\tif ( txt[l] <= ' ') {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t}\n\n\t\t// word wrap\n\t\tif (l != con.linewidth && (con.x + l >= con.linewidth) ) {\n\t\t\tCon_Linefeed(skipnotify);\n\n\t\t}\n\n\t\ttxt++;\n\n\t\tswitch (c)\n\t\t{\n\t\tcase '\\n':\n\t\t\tCon_Linefeed (skipnotify);\n\t\t\tbreak;\n\t\tcase '\\r':\n\t\t\tcon.x = 0;\n\t\t\tbreak;\n\t\tdefault:\t// display character and advance\n\t\t\ty = con.current % con.totallines;\n\t\t\tcon.text[y*con.linewidth+con.x] = (color << 8) | c;\n\t\t\tcon.x++;\n\t\t\tif (con.x >= con.linewidth) {\n\t\t\t\tCon_Linefeed(skipnotify);\n\t\t\t\tcon.x = 0;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\n\t// mark time for transparent overlay\n\tif (con.current >= 0) {\n\t\t// NERVE - SMF\n\t\tif ( skipnotify ) {\n\t\t\tprev = con.current % NUM_CON_TIMES - 1;\n\t\t\tif ( prev < 0 )\n\t\t\t\tprev = NUM_CON_TIMES - 1;\n\t\t\tcon.times[prev] = 0;\n\t\t}\n\t\telse\n\t\t// -NERVE - SMF\n\t\t\tcon.times[con.current % NUM_CON_TIMES] = cls.realtime;\n\t}\n}\n\n\n/*\n==============================================================================\n\nDRAWING\n\n==============================================================================\n*/\n\n\n/*\n================\nCon_DrawInput\n\nDraw the editline after a ] prompt\n================\n*/\nvoid Con_DrawInput (void) {\n\tint\t\ty;\n\n\tif ( cls.state != CA_DISCONNECTED && !(cls.keyCatchers & KEYCATCH_CONSOLE ) ) {\n\t\treturn;\n\t}\n\n\ty = con.vislines - ( SMALLCHAR_HEIGHT * 2 );\n\n\tre.SetColor( con.color );\n\n\tSCR_DrawSmallChar( con.xadjust + 1 * SMALLCHAR_WIDTH, y, ']' );\n\n\tField_Draw( &g_consoleField, con.xadjust + 2 * SMALLCHAR_WIDTH, y,\n\t\tSCREEN_WIDTH - 3 * SMALLCHAR_WIDTH, qtrue );\n}\n\n\n/*\n================\nCon_DrawNotify\n\nDraws the last few lines of output transparently over the game top\n================\n*/\nvoid Con_DrawNotify (void)\n{\n\tint\t\tx, v;\n\tshort\t*text;\n\tint\t\ti;\n\tint\t\ttime;\n\tint\t\tskip;\n\tint\t\tcurrentColor;\n\n\tcurrentColor = 7;\n\tre.SetColor( g_color_table[currentColor] );\n\n\tv = 0;\n\tfor (i= con.current-NUM_CON_TIMES+1 ; i<=con.current ; i++)\n\t{\n\t\tif (i < 0)\n\t\t\tcontinue;\n\t\ttime = con.times[i % NUM_CON_TIMES];\n\t\tif (time == 0)\n\t\t\tcontinue;\n\t\ttime = cls.realtime - time;\n\t\tif (time > con_notifytime->value*1000)\n\t\t\tcontinue;\n\t\ttext = con.text + (i % con.totallines)*con.linewidth;\n\n\t\tif (cl.snap.ps.pm_type != PM_INTERMISSION && cls.keyCatchers & (KEYCATCH_UI | KEYCATCH_CGAME) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (x = 0 ; x < con.linewidth ; x++) {\n\t\t\tif ( ( text[x] & 0xff ) == ' ' ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( ( (text[x]>>8)&7 ) != currentColor ) {\n\t\t\t\tcurrentColor = (text[x]>>8)&7;\n\t\t\t\tre.SetColor( g_color_table[currentColor] );\n\t\t\t}\n\t\t\tSCR_DrawSmallChar( cl_conXOffset->integer + con.xadjust + (x+1)*SMALLCHAR_WIDTH, v, text[x] & 0xff );\n\t\t}\n\n\t\tv += SMALLCHAR_HEIGHT;\n\t}\n\n\tre.SetColor( NULL );\n\n\tif (cls.keyCatchers & (KEYCATCH_UI | KEYCATCH_CGAME) ) {\n\t\treturn;\n\t}\n\n\t// draw the chat line\n\tif ( cls.keyCatchers & KEYCATCH_MESSAGE )\n\t{\n\t\tif (chat_team)\n\t\t{\n\t\t\tSCR_DrawBigString (8, v, \"say_team:\", 1.0f );\n\t\t\tskip = 11;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tSCR_DrawBigString (8, v, \"say:\", 1.0f );\n\t\t\tskip = 5;\n\t\t}\n\n\t\tField_BigDraw( &chatField, skip * BIGCHAR_WIDTH, v,\n\t\t\tSCREEN_WIDTH - ( skip + 1 ) * BIGCHAR_WIDTH, qtrue );\n\n\t\tv += BIGCHAR_HEIGHT;\n\t}\n\n}\n\n/*\n================\nCon_DrawSolidConsole\n\nDraws the console with the solid background\n================\n*/\nvoid Con_DrawSolidConsole( float frac ) {\n\tint\t\t\t\ti, x, y;\n\tint\t\t\t\trows;\n\tshort\t\t\t*text;\n\tint\t\t\t\trow;\n\tint\t\t\t\tlines;\n//\tqhandle_t\t\tconShader;\n\tint\t\t\t\tcurrentColor;\n\tvec4_t\t\t\tcolor;\n\n\tlines = cls.glconfig.vidHeight * frac;\n\tif (lines <= 0)\n\t\treturn;\n\n\tif (lines > cls.glconfig.vidHeight )\n\t\tlines = cls.glconfig.vidHeight;\n\n\t// on wide screens, we will center the text\n\tcon.xadjust = 0;\n\tSCR_AdjustFrom640( &con.xadjust, NULL, NULL, NULL );\n\n\t// draw the background\n\ty = frac * SCREEN_HEIGHT - 2;\n\tif ( y < 1 ) {\n\t\ty = 0;\n\t}\n\telse {\n\t\tSCR_DrawPic( 0, 0, SCREEN_WIDTH, y, cls.consoleShader );\n\t}\n\n\tcolor[0] = 1;\n\tcolor[1] = 0;\n\tcolor[2] = 0;\n\tcolor[3] = 1;\n\tSCR_FillRect( 0, y, SCREEN_WIDTH, 2, color );\n\n\n\t// draw the version number\n\n\tre.SetColor( g_color_table[ColorIndex(COLOR_RED)] );\n\n\ti = strlen( Q3_VERSION );\n\n\tfor (x=0 ; x<i ; x++) {\n\n\t\tSCR_DrawSmallChar( cls.glconfig.vidWidth - ( i - x ) * SMALLCHAR_WIDTH, \n\n\t\t\t(lines-(SMALLCHAR_HEIGHT+SMALLCHAR_HEIGHT/2)), Q3_VERSION[x] );\n\n\t}\n\n\n\t// draw the text\n\tcon.vislines = lines;\n\trows = (lines-SMALLCHAR_WIDTH)/SMALLCHAR_WIDTH;\t\t// rows of text to draw\n\n\ty = lines - (SMALLCHAR_HEIGHT*3);\n\n\t// draw from the bottom up\n\tif (con.display != con.current)\n\t{\n\t// draw arrows to show the buffer is backscrolled\n\t\tre.SetColor( g_color_table[ColorIndex(COLOR_RED)] );\n\t\tfor (x=0 ; x<con.linewidth ; x+=4)\n\t\t\tSCR_DrawSmallChar( con.xadjust + (x+1)*SMALLCHAR_WIDTH, y, '^' );\n\t\ty -= SMALLCHAR_HEIGHT;\n\t\trows--;\n\t}\n\t\n\trow = con.display;\n\n\tif ( con.x == 0 ) {\n\t\trow--;\n\t}\n\n\tcurrentColor = 7;\n\tre.SetColor( g_color_table[currentColor] );\n\n\tfor (i=0 ; i<rows ; i++, y -= SMALLCHAR_HEIGHT, row--)\n\t{\n\t\tif (row < 0)\n\t\t\tbreak;\n\t\tif (con.current - row >= con.totallines) {\n\t\t\t// past scrollback wrap point\n\t\t\tcontinue;\t\n\t\t}\n\n\t\ttext = con.text + (row % con.totallines)*con.linewidth;\n\n\t\tfor (x=0 ; x<con.linewidth ; x++) {\n\t\t\tif ( ( text[x] & 0xff ) == ' ' ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif ( ( (text[x]>>8)&7 ) != currentColor ) {\n\t\t\t\tcurrentColor = (text[x]>>8)&7;\n\t\t\t\tre.SetColor( g_color_table[currentColor] );\n\t\t\t}\n\t\t\tSCR_DrawSmallChar(  con.xadjust + (x+1)*SMALLCHAR_WIDTH, y, text[x] & 0xff );\n\t\t}\n\t}\n\n\t// draw the input prompt, user text, and cursor if desired\n\tCon_DrawInput ();\n\n\tre.SetColor( NULL );\n}\n\n\n\n/*\n==================\nCon_DrawConsole\n==================\n*/\nvoid Con_DrawConsole( void ) {\n\t// check for console width changes from a vid mode change\n\tCon_CheckResize ();\n\n\t// if disconnected, render console full screen\n\tif ( cls.state == CA_DISCONNECTED ) {\n\t\tif ( !( cls.keyCatchers & (KEYCATCH_UI | KEYCATCH_CGAME)) ) {\n\t\t\tCon_DrawSolidConsole( 1.0 );\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif ( con.displayFrac ) {\n\t\tCon_DrawSolidConsole( con.displayFrac );\n\t} else {\n\t\t// draw notify lines\n\t\tif ( cls.state == CA_ACTIVE ) {\n\t\t\tCon_DrawNotify ();\n\t\t}\n\t}\n}\n\n//================================================================\n\n/*\n==================\nCon_RunConsole\n\nScroll it up or down\n==================\n*/\nvoid Con_RunConsole (void) {\n\t// decide on the destination height of the console\n\tif ( cls.keyCatchers & KEYCATCH_CONSOLE )\n\t\tcon.finalFrac = 0.5;\t\t// half screen\n\telse\n\t\tcon.finalFrac = 0;\t\t\t\t// none visible\n\t\n\t// scroll towards the destination height\n\tif (con.finalFrac < con.displayFrac)\n\t{\n\t\tcon.displayFrac -= con_conspeed->value*cls.realFrametime*0.001;\n\t\tif (con.finalFrac > con.displayFrac)\n\t\t\tcon.displayFrac = con.finalFrac;\n\n\t}\n\telse if (con.finalFrac > con.displayFrac)\n\t{\n\t\tcon.displayFrac += con_conspeed->value*cls.realFrametime*0.001;\n\t\tif (con.finalFrac < con.displayFrac)\n\t\t\tcon.displayFrac = con.finalFrac;\n\t}\n\n}\n\n\nvoid Con_PageUp( void ) {\n\tcon.display -= 2;\n\tif ( con.current - con.display >= con.totallines ) {\n\t\tcon.display = con.current - con.totallines + 1;\n\t}\n}\n\nvoid Con_PageDown( void ) {\n\tcon.display += 2;\n\tif (con.display > con.current) {\n\t\tcon.display = con.current;\n\t}\n}\n\nvoid Con_Top( void ) {\n\tcon.display = con.totallines;\n\tif ( con.current - con.display >= con.totallines ) {\n\t\tcon.display = con.current - con.totallines + 1;\n\t}\n}\n\nvoid Con_Bottom( void ) {\n\tcon.display = con.current;\n}\n\n\nvoid Con_Close( void ) {\n\tif ( !com_cl_running->integer ) {\n\t\treturn;\n\t}\n\tField_Clear( &g_consoleField );\n\tCon_ClearNotify ();\n\tcls.keyCatchers &= ~KEYCATCH_CONSOLE;\n\tcon.finalFrac = 0;\t\t\t\t// none visible\n\tcon.displayFrac = 0;\n}\n"
  },
  {
    "path": "code/client/cl_input.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// cl.input.c  -- builds an intended movement command to send to the server\n\n#include \"client.h\"\n\nunsigned\tframe_msec;\nint\t\t\told_com_frameTime;\n\n/*\n===============================================================================\n\nKEY BUTTONS\n\nContinuous button event tracking is complicated by the fact that two different\ninput sources (say, mouse button 1 and the control key) can both press the\nsame button, but the button should only be released when both of the\npressing key have been released.\n\nWhen a key event issues a button command (+forward, +attack, etc), it appends\nits key number as argv(1) so it can be matched up with the release.\n\nargv(2) will be set to the time the event happened, which allows exact\ncontrol even at low framerates when the down and up events may both get qued\nat the same time.\n\n===============================================================================\n*/\n\n\nkbutton_t\tin_left, in_right, in_forward, in_back;\nkbutton_t\tin_lookup, in_lookdown, in_moveleft, in_moveright;\nkbutton_t\tin_strafe, in_speed;\nkbutton_t\tin_up, in_down;\n\nkbutton_t\tin_buttons[16];\n\n\nqboolean\tin_mlooking;\n\n\nvoid IN_MLookDown( void ) {\n\tin_mlooking = qtrue;\n}\n\nvoid IN_MLookUp( void ) {\n\tin_mlooking = qfalse;\n\tif ( !cl_freelook->integer ) {\n\t\tIN_CenterView ();\n\t}\n}\n\nvoid IN_KeyDown( kbutton_t *b ) {\n\tint\t\tk;\n\tchar\t*c;\n\t\n\tc = Cmd_Argv(1);\n\tif ( c[0] ) {\n\t\tk = atoi(c);\n\t} else {\n\t\tk = -1;\t\t// typed manually at the console for continuous down\n\t}\n\n\tif ( k == b->down[0] || k == b->down[1] ) {\n\t\treturn;\t\t// repeating key\n\t}\n\t\n\tif ( !b->down[0] ) {\n\t\tb->down[0] = k;\n\t} else if ( !b->down[1] ) {\n\t\tb->down[1] = k;\n\t} else {\n\t\tCom_Printf (\"Three keys down for a button!\\n\");\n\t\treturn;\n\t}\n\t\n\tif ( b->active ) {\n\t\treturn;\t\t// still down\n\t}\n\n\t// save timestamp for partial frame summing\n\tc = Cmd_Argv(2);\n\tb->downtime = atoi(c);\n\n\tb->active = qtrue;\n\tb->wasPressed = qtrue;\n}\n\nvoid IN_KeyUp( kbutton_t *b ) {\n\tint\t\tk;\n\tchar\t*c;\n\tunsigned\tuptime;\n\n\tc = Cmd_Argv(1);\n\tif ( c[0] ) {\n\t\tk = atoi(c);\n\t} else {\n\t\t// typed manually at the console, assume for unsticking, so clear all\n\t\tb->down[0] = b->down[1] = 0;\n\t\tb->active = qfalse;\n\t\treturn;\n\t}\n\n\tif ( b->down[0] == k ) {\n\t\tb->down[0] = 0;\n\t} else if ( b->down[1] == k ) {\n\t\tb->down[1] = 0;\n\t} else {\n\t\treturn;\t\t// key up without coresponding down (menu pass through)\n\t}\n\tif ( b->down[0] || b->down[1] ) {\n\t\treturn;\t\t// some other key is still holding it down\n\t}\n\n\tb->active = qfalse;\n\n\t// save timestamp for partial frame summing\n\tc = Cmd_Argv(2);\n\tuptime = atoi(c);\n\tif ( uptime ) {\n\t\tb->msec += uptime - b->downtime;\n\t} else {\n\t\tb->msec += frame_msec / 2;\n\t}\n\n\tb->active = qfalse;\n}\n\n\n\n/*\n===============\nCL_KeyState\n\nReturns the fraction of the frame that the key was down\n===============\n*/\nfloat CL_KeyState( kbutton_t *key ) {\n\tfloat\t\tval;\n\tint\t\t\tmsec;\n\n\tmsec = key->msec;\n\tkey->msec = 0;\n\n\tif ( key->active ) {\n\t\t// still down\n\t\tif ( !key->downtime ) {\n\t\t\tmsec = com_frameTime;\n\t\t} else {\n\t\t\tmsec += com_frameTime - key->downtime;\n\t\t}\n\t\tkey->downtime = com_frameTime;\n\t}\n\n#if 0\n\tif (msec) {\n\t\tCom_Printf (\"%i \", msec);\n\t}\n#endif\n\n\tval = (float)msec / frame_msec;\n\tif ( val < 0 ) {\n\t\tval = 0;\n\t}\n\tif ( val > 1 ) {\n\t\tval = 1;\n\t}\n\n\treturn val;\n}\n\n\n\nvoid IN_UpDown(void) {IN_KeyDown(&in_up);}\nvoid IN_UpUp(void) {IN_KeyUp(&in_up);}\nvoid IN_DownDown(void) {IN_KeyDown(&in_down);}\nvoid IN_DownUp(void) {IN_KeyUp(&in_down);}\nvoid IN_LeftDown(void) {IN_KeyDown(&in_left);}\nvoid IN_LeftUp(void) {IN_KeyUp(&in_left);}\nvoid IN_RightDown(void) {IN_KeyDown(&in_right);}\nvoid IN_RightUp(void) {IN_KeyUp(&in_right);}\nvoid IN_ForwardDown(void) {IN_KeyDown(&in_forward);}\nvoid IN_ForwardUp(void) {IN_KeyUp(&in_forward);}\nvoid IN_BackDown(void) {IN_KeyDown(&in_back);}\nvoid IN_BackUp(void) {IN_KeyUp(&in_back);}\nvoid IN_LookupDown(void) {IN_KeyDown(&in_lookup);}\nvoid IN_LookupUp(void) {IN_KeyUp(&in_lookup);}\nvoid IN_LookdownDown(void) {IN_KeyDown(&in_lookdown);}\nvoid IN_LookdownUp(void) {IN_KeyUp(&in_lookdown);}\nvoid IN_MoveleftDown(void) {IN_KeyDown(&in_moveleft);}\nvoid IN_MoveleftUp(void) {IN_KeyUp(&in_moveleft);}\nvoid IN_MoverightDown(void) {IN_KeyDown(&in_moveright);}\nvoid IN_MoverightUp(void) {IN_KeyUp(&in_moveright);}\n\nvoid IN_SpeedDown(void) {IN_KeyDown(&in_speed);}\nvoid IN_SpeedUp(void) {IN_KeyUp(&in_speed);}\nvoid IN_StrafeDown(void) {IN_KeyDown(&in_strafe);}\nvoid IN_StrafeUp(void) {IN_KeyUp(&in_strafe);}\n\nvoid IN_Button0Down(void) {IN_KeyDown(&in_buttons[0]);}\nvoid IN_Button0Up(void) {IN_KeyUp(&in_buttons[0]);}\nvoid IN_Button1Down(void) {IN_KeyDown(&in_buttons[1]);}\nvoid IN_Button1Up(void) {IN_KeyUp(&in_buttons[1]);}\nvoid IN_Button2Down(void) {IN_KeyDown(&in_buttons[2]);}\nvoid IN_Button2Up(void) {IN_KeyUp(&in_buttons[2]);}\nvoid IN_Button3Down(void) {IN_KeyDown(&in_buttons[3]);}\nvoid IN_Button3Up(void) {IN_KeyUp(&in_buttons[3]);}\nvoid IN_Button4Down(void) {IN_KeyDown(&in_buttons[4]);}\nvoid IN_Button4Up(void) {IN_KeyUp(&in_buttons[4]);}\nvoid IN_Button5Down(void) {IN_KeyDown(&in_buttons[5]);}\nvoid IN_Button5Up(void) {IN_KeyUp(&in_buttons[5]);}\nvoid IN_Button6Down(void) {IN_KeyDown(&in_buttons[6]);}\nvoid IN_Button6Up(void) {IN_KeyUp(&in_buttons[6]);}\nvoid IN_Button7Down(void) {IN_KeyDown(&in_buttons[7]);}\nvoid IN_Button7Up(void) {IN_KeyUp(&in_buttons[7]);}\nvoid IN_Button8Down(void) {IN_KeyDown(&in_buttons[8]);}\nvoid IN_Button8Up(void) {IN_KeyUp(&in_buttons[8]);}\nvoid IN_Button9Down(void) {IN_KeyDown(&in_buttons[9]);}\nvoid IN_Button9Up(void) {IN_KeyUp(&in_buttons[9]);}\nvoid IN_Button10Down(void) {IN_KeyDown(&in_buttons[10]);}\nvoid IN_Button10Up(void) {IN_KeyUp(&in_buttons[10]);}\nvoid IN_Button11Down(void) {IN_KeyDown(&in_buttons[11]);}\nvoid IN_Button11Up(void) {IN_KeyUp(&in_buttons[11]);}\nvoid IN_Button12Down(void) {IN_KeyDown(&in_buttons[12]);}\nvoid IN_Button12Up(void) {IN_KeyUp(&in_buttons[12]);}\nvoid IN_Button13Down(void) {IN_KeyDown(&in_buttons[13]);}\nvoid IN_Button13Up(void) {IN_KeyUp(&in_buttons[13]);}\nvoid IN_Button14Down(void) {IN_KeyDown(&in_buttons[14]);}\nvoid IN_Button14Up(void) {IN_KeyUp(&in_buttons[14]);}\nvoid IN_Button15Down(void) {IN_KeyDown(&in_buttons[15]);}\nvoid IN_Button15Up(void) {IN_KeyUp(&in_buttons[15]);}\n\nvoid IN_ButtonDown (void) {\n\tIN_KeyDown(&in_buttons[1]);}\nvoid IN_ButtonUp (void) {\n\tIN_KeyUp(&in_buttons[1]);}\n\nvoid IN_CenterView (void) {\n\tcl.viewangles[PITCH] = -SHORT2ANGLE(cl.snap.ps.delta_angles[PITCH]);\n}\n\n\n//==========================================================================\n\ncvar_t\t*cl_upspeed;\ncvar_t\t*cl_forwardspeed;\ncvar_t\t*cl_sidespeed;\n\ncvar_t\t*cl_yawspeed;\ncvar_t\t*cl_pitchspeed;\n\ncvar_t\t*cl_run;\n\ncvar_t\t*cl_anglespeedkey;\n\n\n/*\n================\nCL_AdjustAngles\n\nMoves the local angle positions\n================\n*/\nvoid CL_AdjustAngles( void ) {\n\tfloat\tspeed;\n\t\n\tif ( in_speed.active ) {\n\t\tspeed = 0.001 * cls.frametime * cl_anglespeedkey->value;\n\t} else {\n\t\tspeed = 0.001 * cls.frametime;\n\t}\n\n\tif ( !in_strafe.active ) {\n\t\tcl.viewangles[YAW] -= speed*cl_yawspeed->value*CL_KeyState (&in_right);\n\t\tcl.viewangles[YAW] += speed*cl_yawspeed->value*CL_KeyState (&in_left);\n\t}\n\n\tcl.viewangles[PITCH] -= speed*cl_pitchspeed->value * CL_KeyState (&in_lookup);\n\tcl.viewangles[PITCH] += speed*cl_pitchspeed->value * CL_KeyState (&in_lookdown);\n}\n\n/*\n================\nCL_KeyMove\n\nSets the usercmd_t based on key states\n================\n*/\nvoid CL_KeyMove( usercmd_t *cmd ) {\n\tint\t\tmovespeed;\n\tint\t\tforward, side, up;\n\n\t//\n\t// adjust for speed key / running\n\t// the walking flag is to keep animations consistant\n\t// even during acceleration and develeration\n\t//\n\tif ( in_speed.active ^ cl_run->integer ) {\n\t\tmovespeed = 127;\n\t\tcmd->buttons &= ~BUTTON_WALKING;\n\t} else {\n\t\tcmd->buttons |= BUTTON_WALKING;\n\t\tmovespeed = 64;\n\t}\n\n\tforward = 0;\n\tside = 0;\n\tup = 0;\n\tif ( in_strafe.active ) {\n\t\tside += movespeed * CL_KeyState (&in_right);\n\t\tside -= movespeed * CL_KeyState (&in_left);\n\t}\n\n\tside += movespeed * CL_KeyState (&in_moveright);\n\tside -= movespeed * CL_KeyState (&in_moveleft);\n\n\n\tup += movespeed * CL_KeyState (&in_up);\n\tup -= movespeed * CL_KeyState (&in_down);\n\n\tforward += movespeed * CL_KeyState (&in_forward);\n\tforward -= movespeed * CL_KeyState (&in_back);\n\n\tcmd->forwardmove = ClampChar( forward );\n\tcmd->rightmove = ClampChar( side );\n\tcmd->upmove = ClampChar( up );\n}\n\n/*\n=================\nCL_MouseEvent\n=================\n*/\nvoid CL_MouseEvent( int dx, int dy, int time ) {\n\tif ( cls.keyCatchers & KEYCATCH_UI ) {\n\t\tVM_Call( uivm, UI_MOUSE_EVENT, dx, dy );\n\t} else if (cls.keyCatchers & KEYCATCH_CGAME) {\n\t\tVM_Call (cgvm, CG_MOUSE_EVENT, dx, dy);\n\t} else {\n\t\tcl.mouseDx[cl.mouseIndex] += dx;\n\t\tcl.mouseDy[cl.mouseIndex] += dy;\n\t}\n}\n\n/*\n=================\nCL_JoystickEvent\n\nJoystick values stay set until changed\n=================\n*/\nvoid CL_JoystickEvent( int axis, int value, int time ) {\n\tif ( axis < 0 || axis >= MAX_JOYSTICK_AXIS ) {\n\t\tCom_Error( ERR_DROP, \"CL_JoystickEvent: bad axis %i\", axis );\n\t}\n\tcl.joystickAxis[axis] = value;\n}\n\n/*\n=================\nCL_JoystickMove\n=================\n*/\nvoid CL_JoystickMove( usercmd_t *cmd ) {\n\tint\t\tmovespeed;\n\tfloat\tanglespeed;\n\n\tif ( in_speed.active ^ cl_run->integer ) {\n\t\tmovespeed = 2;\n\t} else {\n\t\tmovespeed = 1;\n\t\tcmd->buttons |= BUTTON_WALKING;\n\t}\n\n\tif ( in_speed.active ) {\n\t\tanglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value;\n\t} else {\n\t\tanglespeed = 0.001 * cls.frametime;\n\t}\n\n\tif ( !in_strafe.active ) {\n\t\tcl.viewangles[YAW] += anglespeed * cl_yawspeed->value * cl.joystickAxis[AXIS_SIDE];\n\t} else {\n\t\tcmd->rightmove = ClampChar( cmd->rightmove + cl.joystickAxis[AXIS_SIDE] );\n\t}\n\n\tif ( in_mlooking ) {\n\t\tcl.viewangles[PITCH] += anglespeed * cl_pitchspeed->value * cl.joystickAxis[AXIS_FORWARD];\n\t} else {\n\t\tcmd->forwardmove = ClampChar( cmd->forwardmove + cl.joystickAxis[AXIS_FORWARD] );\n\t}\n\n\tcmd->upmove = ClampChar( cmd->upmove + cl.joystickAxis[AXIS_UP] );\n}\n\n/*\n=================\nCL_MouseMove\n=================\n*/\nvoid CL_MouseMove( usercmd_t *cmd ) {\n\tfloat\tmx, my;\n\tfloat\taccelSensitivity;\n\tfloat\trate;\n\n\t// allow mouse smoothing\n\tif ( m_filter->integer ) {\n\t\tmx = ( cl.mouseDx[0] + cl.mouseDx[1] ) * 0.5;\n\t\tmy = ( cl.mouseDy[0] + cl.mouseDy[1] ) * 0.5;\n\t} else {\n\t\tmx = cl.mouseDx[cl.mouseIndex];\n\t\tmy = cl.mouseDy[cl.mouseIndex];\n\t}\n\tcl.mouseIndex ^= 1;\n\tcl.mouseDx[cl.mouseIndex] = 0;\n\tcl.mouseDy[cl.mouseIndex] = 0;\n\n\trate = sqrt( mx * mx + my * my ) / (float)frame_msec;\n\taccelSensitivity = cl_sensitivity->value + rate * cl_mouseAccel->value;\n\n\t// scale by FOV\n\taccelSensitivity *= cl.cgameSensitivity;\n\n\tif ( rate && cl_showMouseRate->integer ) {\n\t\tCom_Printf( \"%f : %f\\n\", rate, accelSensitivity );\n\t}\n\n\tmx *= accelSensitivity;\n\tmy *= accelSensitivity;\n\n\tif (!mx && !my) {\n\t\treturn;\n\t}\n\n\t// add mouse X/Y movement to cmd\n\tif ( in_strafe.active ) {\n\t\tcmd->rightmove = ClampChar( cmd->rightmove + m_side->value * mx );\n\t} else {\n\t\tcl.viewangles[YAW] -= m_yaw->value * mx;\n\t}\n\n\tif ( (in_mlooking || cl_freelook->integer) && !in_strafe.active ) {\n\t\tcl.viewangles[PITCH] += m_pitch->value * my;\n\t} else {\n\t\tcmd->forwardmove = ClampChar( cmd->forwardmove - m_forward->value * my );\n\t}\n}\n\n\n/*\n==============\nCL_CmdButtons\n==============\n*/\nvoid CL_CmdButtons( usercmd_t *cmd ) {\n\tint\t\ti;\n\n\t//\n\t// figure button bits\n\t// send a button bit even if the key was pressed and released in\n\t// less than a frame\n\t//\t\n\tfor (i = 0 ; i < 15 ; i++) {\n\t\tif ( in_buttons[i].active || in_buttons[i].wasPressed ) {\n\t\t\tcmd->buttons |= 1 << i;\n\t\t}\n\t\tin_buttons[i].wasPressed = qfalse;\n\t}\n\n\tif ( cls.keyCatchers ) {\n\t\tcmd->buttons |= BUTTON_TALK;\n\t}\n\n\t// allow the game to know if any key at all is\n\t// currently pressed, even if it isn't bound to anything\n\tif ( anykeydown && !cls.keyCatchers ) {\n\t\tcmd->buttons |= BUTTON_ANY;\n\t}\n}\n\n\n/*\n==============\nCL_FinishMove\n==============\n*/\nvoid CL_FinishMove( usercmd_t *cmd ) {\n\tint\t\ti;\n\n\t// copy the state that the cgame is currently sending\n\tcmd->weapon = cl.cgameUserCmdValue;\n\n\t// send the current server time so the amount of movement\n\t// can be determined without allowing cheating\n\tcmd->serverTime = cl.serverTime;\n\n\tfor (i=0 ; i<3 ; i++) {\n\t\tcmd->angles[i] = ANGLE2SHORT(cl.viewangles[i]);\n\t}\n}\n\n\n/*\n=================\nCL_CreateCmd\n=================\n*/\nusercmd_t CL_CreateCmd( void ) {\n\tusercmd_t\tcmd;\n\tvec3_t\t\toldAngles;\n\n\tVectorCopy( cl.viewangles, oldAngles );\n\n\t// keyboard angle adjustment\n\tCL_AdjustAngles ();\n\t\n\tCom_Memset( &cmd, 0, sizeof( cmd ) );\n\n\tCL_CmdButtons( &cmd );\n\n\t// get basic movement from keyboard\n\tCL_KeyMove( &cmd );\n\n\t// get basic movement from mouse\n\tCL_MouseMove( &cmd );\n\n\t// get basic movement from joystick\n\tCL_JoystickMove( &cmd );\n\n\t// check to make sure the angles haven't wrapped\n\tif ( cl.viewangles[PITCH] - oldAngles[PITCH] > 90 ) {\n\t\tcl.viewangles[PITCH] = oldAngles[PITCH] + 90;\n\t} else if ( oldAngles[PITCH] - cl.viewangles[PITCH] > 90 ) {\n\t\tcl.viewangles[PITCH] = oldAngles[PITCH] - 90;\n\t} \n\n\t// store out the final values\n\tCL_FinishMove( &cmd );\n\n\t// draw debug graphs of turning for mouse testing\n\tif ( cl_debugMove->integer ) {\n\t\tif ( cl_debugMove->integer == 1 ) {\n\t\t\tSCR_DebugGraph( abs(cl.viewangles[YAW] - oldAngles[YAW]), 0 );\n\t\t}\n\t\tif ( cl_debugMove->integer == 2 ) {\n\t\t\tSCR_DebugGraph( abs(cl.viewangles[PITCH] - oldAngles[PITCH]), 0 );\n\t\t}\n\t}\n\n\treturn cmd;\n}\n\n\n/*\n=================\nCL_CreateNewCommands\n\nCreate a new usercmd_t structure for this frame\n=================\n*/\nvoid CL_CreateNewCommands( void ) {\n\tusercmd_t\t*cmd;\n\tint\t\t\tcmdNum;\n\n\t// no need to create usercmds until we have a gamestate\n\tif ( cls.state < CA_PRIMED ) {\n\t\treturn;\n\t}\n\n\tframe_msec = com_frameTime - old_com_frameTime;\n\n\t// if running less than 5fps, truncate the extra time to prevent\n\t// unexpected moves after a hitch\n\tif ( frame_msec > 200 ) {\n\t\tframe_msec = 200;\n\t}\n\told_com_frameTime = com_frameTime;\n\n\n\t// generate a command for this frame\n\tcl.cmdNumber++;\n\tcmdNum = cl.cmdNumber & CMD_MASK;\n\tcl.cmds[cmdNum] = CL_CreateCmd ();\n\tcmd = &cl.cmds[cmdNum];\n}\n\n/*\n=================\nCL_ReadyToSendPacket\n\nReturns qfalse if we are over the maxpackets limit\nand should choke back the bandwidth a bit by not sending\na packet this frame.  All the commands will still get\ndelivered in the next packet, but saving a header and\ngetting more delta compression will reduce total bandwidth.\n=================\n*/\nqboolean CL_ReadyToSendPacket( void ) {\n\tint\t\toldPacketNum;\n\tint\t\tdelta;\n\n\t// don't send anything if playing back a demo\n\tif ( clc.demoplaying || cls.state == CA_CINEMATIC ) {\n\t\treturn qfalse;\n\t}\n\n\t// If we are downloading, we send no less than 50ms between packets\n\tif ( *clc.downloadTempName &&\n\t\tcls.realtime - clc.lastPacketSentTime < 50 ) {\n\t\treturn qfalse;\n\t}\n\n\t// if we don't have a valid gamestate yet, only send\n\t// one packet a second\n\tif ( cls.state != CA_ACTIVE && \n\t\tcls.state != CA_PRIMED && \n\t\t!*clc.downloadTempName &&\n\t\tcls.realtime - clc.lastPacketSentTime < 1000 ) {\n\t\treturn qfalse;\n\t}\n\n\t// send every frame for loopbacks\n\tif ( clc.netchan.remoteAddress.type == NA_LOOPBACK ) {\n\t\treturn qtrue;\n\t}\n\n\t// send every frame for LAN\n\tif ( Sys_IsLANAddress( clc.netchan.remoteAddress ) ) {\n\t\treturn qtrue;\n\t}\n\n\t// check for exceeding cl_maxpackets\n\tif ( cl_maxpackets->integer < 15 ) {\n\t\tCvar_Set( \"cl_maxpackets\", \"15\" );\n\t} else if ( cl_maxpackets->integer > 125 ) {\n\t\tCvar_Set( \"cl_maxpackets\", \"125\" );\n\t}\n\toldPacketNum = (clc.netchan.outgoingSequence - 1) & PACKET_MASK;\n\tdelta = cls.realtime -  cl.outPackets[ oldPacketNum ].p_realtime;\n\tif ( delta < 1000 / cl_maxpackets->integer ) {\n\t\t// the accumulated commands will go out in the next packet\n\t\treturn qfalse;\n\t}\n\n\treturn qtrue;\n}\n\n/*\n===================\nCL_WritePacket\n\nCreate and send the command packet to the server\nIncluding both the reliable commands and the usercmds\n\nDuring normal gameplay, a client packet will contain something like:\n\n4\tsequence number\n2\tqport\n4\tserverid\n4\tacknowledged sequence number\n4\tclc.serverCommandSequence\n<optional reliable commands>\n1\tclc_move or clc_moveNoDelta\n1\tcommand count\n<count * usercmds>\n\n===================\n*/\nvoid CL_WritePacket( void ) {\n\tmsg_t\t\tbuf;\n\tbyte\t\tdata[MAX_MSGLEN];\n\tint\t\t\ti, j;\n\tusercmd_t\t*cmd, *oldcmd;\n\tusercmd_t\tnullcmd;\n\tint\t\t\tpacketNum;\n\tint\t\t\toldPacketNum;\n\tint\t\t\tcount, key;\n\n\t// don't send anything if playing back a demo\n\tif ( clc.demoplaying || cls.state == CA_CINEMATIC ) {\n\t\treturn;\n\t}\n\n\tCom_Memset( &nullcmd, 0, sizeof(nullcmd) );\n\toldcmd = &nullcmd;\n\n\tMSG_Init( &buf, data, sizeof(data) );\n\n\tMSG_Bitstream( &buf );\n\t// write the current serverId so the server\n\t// can tell if this is from the current gameState\n\tMSG_WriteLong( &buf, cl.serverId );\n\n\t// write the last message we received, which can\n\t// be used for delta compression, and is also used\n\t// to tell if we dropped a gamestate\n\tMSG_WriteLong( &buf, clc.serverMessageSequence );\n\n\t// write the last reliable message we received\n\tMSG_WriteLong( &buf, clc.serverCommandSequence );\n\n\t// write any unacknowledged clientCommands\n\tfor ( i = clc.reliableAcknowledge + 1 ; i <= clc.reliableSequence ; i++ ) {\n\t\tMSG_WriteByte( &buf, clc_clientCommand );\n\t\tMSG_WriteLong( &buf, i );\n\t\tMSG_WriteString( &buf, clc.reliableCommands[ i & (MAX_RELIABLE_COMMANDS-1) ] );\n\t}\n\n\t// we want to send all the usercmds that were generated in the last\n\t// few packet, so even if a couple packets are dropped in a row,\n\t// all the cmds will make it to the server\n\tif ( cl_packetdup->integer < 0 ) {\n\t\tCvar_Set( \"cl_packetdup\", \"0\" );\n\t} else if ( cl_packetdup->integer > 5 ) {\n\t\tCvar_Set( \"cl_packetdup\", \"5\" );\n\t}\n\toldPacketNum = (clc.netchan.outgoingSequence - 1 - cl_packetdup->integer) & PACKET_MASK;\n\tcount = cl.cmdNumber - cl.outPackets[ oldPacketNum ].p_cmdNumber;\n\tif ( count > MAX_PACKET_USERCMDS ) {\n\t\tcount = MAX_PACKET_USERCMDS;\n\t\tCom_Printf(\"MAX_PACKET_USERCMDS\\n\");\n\t}\n\tif ( count >= 1 ) {\n\t\tif ( cl_showSend->integer ) {\n\t\t\tCom_Printf( \"(%i)\", count );\n\t\t}\n\n\t\t// begin a client move command\n\t\tif ( cl_nodelta->integer || !cl.snap.valid || clc.demowaiting\n\t\t\t|| clc.serverMessageSequence != cl.snap.messageNum ) {\n\t\t\tMSG_WriteByte (&buf, clc_moveNoDelta);\n\t\t} else {\n\t\t\tMSG_WriteByte (&buf, clc_move);\n\t\t}\n\n\t\t// write the command count\n\t\tMSG_WriteByte( &buf, count );\n\n\t\t// use the checksum feed in the key\n\t\tkey = clc.checksumFeed;\n\t\t// also use the message acknowledge\n\t\tkey ^= clc.serverMessageSequence;\n\t\t// also use the last acknowledged server command in the key\n\t\tkey ^= Com_HashKey(clc.serverCommands[ clc.serverCommandSequence & (MAX_RELIABLE_COMMANDS-1) ], 32);\n\n\t\t// write all the commands, including the predicted command\n\t\tfor ( i = 0 ; i < count ; i++ ) {\n\t\t\tj = (cl.cmdNumber - count + i + 1) & CMD_MASK;\n\t\t\tcmd = &cl.cmds[j];\n\t\t\tMSG_WriteDeltaUsercmdKey (&buf, key, oldcmd, cmd);\n\t\t\toldcmd = cmd;\n\t\t}\n\t}\n\n\t//\n\t// deliver the message\n\t//\n\tpacketNum = clc.netchan.outgoingSequence & PACKET_MASK;\n\tcl.outPackets[ packetNum ].p_realtime = cls.realtime;\n\tcl.outPackets[ packetNum ].p_serverTime = oldcmd->serverTime;\n\tcl.outPackets[ packetNum ].p_cmdNumber = cl.cmdNumber;\n\tclc.lastPacketSentTime = cls.realtime;\n\n\tif ( cl_showSend->integer ) {\n\t\tCom_Printf( \"%i \", buf.cursize );\n\t}\n\n\tCL_Netchan_Transmit (&clc.netchan, &buf);\t\n\n\t// clients never really should have messages large enough\n\t// to fragment, but in case they do, fire them all off\n\t// at once\n\t// TTimo: this causes a packet burst, which is bad karma for winsock\n\t// added a WARNING message, we'll see if there are legit situations where this happens\n\twhile ( clc.netchan.unsentFragments ) {\n\t\tCom_DPrintf( \"WARNING: #462 unsent fragments (not supposed to happen!)\\n\" );\n\t\tCL_Netchan_TransmitNextFragment( &clc.netchan );\n\t}\n}\n\n/*\n=================\nCL_SendCmd\n\nCalled every frame to builds and sends a command packet to the server.\n=================\n*/\nvoid CL_SendCmd( void ) {\n\t// don't send any message if not connected\n\tif ( cls.state < CA_CONNECTED ) {\n\t\treturn;\n\t}\n\n\t// don't send commands if paused\n\tif ( com_sv_running->integer && sv_paused->integer && cl_paused->integer ) {\n\t\treturn;\n\t}\n\n\t// we create commands even if a demo is playing,\n\tCL_CreateNewCommands();\n\n\t// don't send a packet if the last packet was sent too recently\n\tif ( !CL_ReadyToSendPacket() ) {\n\t\tif ( cl_showSend->integer ) {\n\t\t\tCom_Printf( \". \" );\n\t\t}\n\t\treturn;\n\t}\n\n\tCL_WritePacket();\n}\n\n/*\n============\nCL_InitInput\n============\n*/\nvoid CL_InitInput( void ) {\n\tCmd_AddCommand (\"centerview\",IN_CenterView);\n\n\tCmd_AddCommand (\"+moveup\",IN_UpDown);\n\tCmd_AddCommand (\"-moveup\",IN_UpUp);\n\tCmd_AddCommand (\"+movedown\",IN_DownDown);\n\tCmd_AddCommand (\"-movedown\",IN_DownUp);\n\tCmd_AddCommand (\"+left\",IN_LeftDown);\n\tCmd_AddCommand (\"-left\",IN_LeftUp);\n\tCmd_AddCommand (\"+right\",IN_RightDown);\n\tCmd_AddCommand (\"-right\",IN_RightUp);\n\tCmd_AddCommand (\"+forward\",IN_ForwardDown);\n\tCmd_AddCommand (\"-forward\",IN_ForwardUp);\n\tCmd_AddCommand (\"+back\",IN_BackDown);\n\tCmd_AddCommand (\"-back\",IN_BackUp);\n\tCmd_AddCommand (\"+lookup\", IN_LookupDown);\n\tCmd_AddCommand (\"-lookup\", IN_LookupUp);\n\tCmd_AddCommand (\"+lookdown\", IN_LookdownDown);\n\tCmd_AddCommand (\"-lookdown\", IN_LookdownUp);\n\tCmd_AddCommand (\"+strafe\", IN_StrafeDown);\n\tCmd_AddCommand (\"-strafe\", IN_StrafeUp);\n\tCmd_AddCommand (\"+moveleft\", IN_MoveleftDown);\n\tCmd_AddCommand (\"-moveleft\", IN_MoveleftUp);\n\tCmd_AddCommand (\"+moveright\", IN_MoverightDown);\n\tCmd_AddCommand (\"-moveright\", IN_MoverightUp);\n\tCmd_AddCommand (\"+speed\", IN_SpeedDown);\n\tCmd_AddCommand (\"-speed\", IN_SpeedUp);\n\tCmd_AddCommand (\"+attack\", IN_Button0Down);\n\tCmd_AddCommand (\"-attack\", IN_Button0Up);\n\tCmd_AddCommand (\"+button0\", IN_Button0Down);\n\tCmd_AddCommand (\"-button0\", IN_Button0Up);\n\tCmd_AddCommand (\"+button1\", IN_Button1Down);\n\tCmd_AddCommand (\"-button1\", IN_Button1Up);\n\tCmd_AddCommand (\"+button2\", IN_Button2Down);\n\tCmd_AddCommand (\"-button2\", IN_Button2Up);\n\tCmd_AddCommand (\"+button3\", IN_Button3Down);\n\tCmd_AddCommand (\"-button3\", IN_Button3Up);\n\tCmd_AddCommand (\"+button4\", IN_Button4Down);\n\tCmd_AddCommand (\"-button4\", IN_Button4Up);\n\tCmd_AddCommand (\"+button5\", IN_Button5Down);\n\tCmd_AddCommand (\"-button5\", IN_Button5Up);\n\tCmd_AddCommand (\"+button6\", IN_Button6Down);\n\tCmd_AddCommand (\"-button6\", IN_Button6Up);\n\tCmd_AddCommand (\"+button7\", IN_Button7Down);\n\tCmd_AddCommand (\"-button7\", IN_Button7Up);\n\tCmd_AddCommand (\"+button8\", IN_Button8Down);\n\tCmd_AddCommand (\"-button8\", IN_Button8Up);\n\tCmd_AddCommand (\"+button9\", IN_Button9Down);\n\tCmd_AddCommand (\"-button9\", IN_Button9Up);\n\tCmd_AddCommand (\"+button10\", IN_Button10Down);\n\tCmd_AddCommand (\"-button10\", IN_Button10Up);\n\tCmd_AddCommand (\"+button11\", IN_Button11Down);\n\tCmd_AddCommand (\"-button11\", IN_Button11Up);\n\tCmd_AddCommand (\"+button12\", IN_Button12Down);\n\tCmd_AddCommand (\"-button12\", IN_Button12Up);\n\tCmd_AddCommand (\"+button13\", IN_Button13Down);\n\tCmd_AddCommand (\"-button13\", IN_Button13Up);\n\tCmd_AddCommand (\"+button14\", IN_Button14Down);\n\tCmd_AddCommand (\"-button14\", IN_Button14Up);\n\tCmd_AddCommand (\"+mlook\", IN_MLookDown);\n\tCmd_AddCommand (\"-mlook\", IN_MLookUp);\n\n\tcl_nodelta = Cvar_Get (\"cl_nodelta\", \"0\", 0);\n\tcl_debugMove = Cvar_Get (\"cl_debugMove\", \"0\", 0);\n}\n"
  },
  {
    "path": "code/client/cl_keys.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"client.h\"\n\n/*\n\nkey up events are sent even if in console mode\n\n*/\n\nfield_t\thistoryEditLines[COMMAND_HISTORY];\n\nint\t\t\tnextHistoryLine;\t\t// the last line in the history buffer, not masked\nint\t\t\thistoryLine;\t// the line being displayed from history buffer\n\t\t\t\t\t\t\t// will be <= nextHistoryLine\n\nfield_t\t\tg_consoleField;\nfield_t\t\tchatField;\nqboolean\tchat_team;\n\nint\t\t\tchat_playerNum;\n\n\nqboolean\tkey_overstrikeMode;\n\nqboolean\tanykeydown;\nqkey_t\t\tkeys[MAX_KEYS];\n\n\ntypedef struct {\n\tchar\t*name;\n\tint\t\tkeynum;\n} keyname_t;\n\n\n// names not in this list can either be lowercase ascii, or '0xnn' hex sequences\nkeyname_t keynames[] =\n{\n\t{\"TAB\", K_TAB},\n\t{\"ENTER\", K_ENTER},\n\t{\"ESCAPE\", K_ESCAPE},\n\t{\"SPACE\", K_SPACE},\n\t{\"BACKSPACE\", K_BACKSPACE},\n\t{\"UPARROW\", K_UPARROW},\n\t{\"DOWNARROW\", K_DOWNARROW},\n\t{\"LEFTARROW\", K_LEFTARROW},\n\t{\"RIGHTARROW\", K_RIGHTARROW},\n\n\t{\"ALT\", K_ALT},\n\t{\"CTRL\", K_CTRL},\n\t{\"SHIFT\", K_SHIFT},\n\n\t{\"COMMAND\", K_COMMAND},\n\n\t{\"CAPSLOCK\", K_CAPSLOCK},\n\n\t\n\t{\"F1\", K_F1},\n\t{\"F2\", K_F2},\n\t{\"F3\", K_F3},\n\t{\"F4\", K_F4},\n\t{\"F5\", K_F5},\n\t{\"F6\", K_F6},\n\t{\"F7\", K_F7},\n\t{\"F8\", K_F8},\n\t{\"F9\", K_F9},\n\t{\"F10\", K_F10},\n\t{\"F11\", K_F11},\n\t{\"F12\", K_F12},\n\n\t{\"INS\", K_INS},\n\t{\"DEL\", K_DEL},\n\t{\"PGDN\", K_PGDN},\n\t{\"PGUP\", K_PGUP},\n\t{\"HOME\", K_HOME},\n\t{\"END\", K_END},\n\n\t{\"MOUSE1\", K_MOUSE1},\n\t{\"MOUSE2\", K_MOUSE2},\n\t{\"MOUSE3\", K_MOUSE3},\n\t{\"MOUSE4\", K_MOUSE4},\n\t{\"MOUSE5\", K_MOUSE5},\n\n\t{\"MWHEELUP\",\tK_MWHEELUP },\n\t{\"MWHEELDOWN\",\tK_MWHEELDOWN },\n\n\t{\"JOY1\", K_JOY1},\n\t{\"JOY2\", K_JOY2},\n\t{\"JOY3\", K_JOY3},\n\t{\"JOY4\", K_JOY4},\n\t{\"JOY5\", K_JOY5},\n\t{\"JOY6\", K_JOY6},\n\t{\"JOY7\", K_JOY7},\n\t{\"JOY8\", K_JOY8},\n\t{\"JOY9\", K_JOY9},\n\t{\"JOY10\", K_JOY10},\n\t{\"JOY11\", K_JOY11},\n\t{\"JOY12\", K_JOY12},\n\t{\"JOY13\", K_JOY13},\n\t{\"JOY14\", K_JOY14},\n\t{\"JOY15\", K_JOY15},\n\t{\"JOY16\", K_JOY16},\n\t{\"JOY17\", K_JOY17},\n\t{\"JOY18\", K_JOY18},\n\t{\"JOY19\", K_JOY19},\n\t{\"JOY20\", K_JOY20},\n\t{\"JOY21\", K_JOY21},\n\t{\"JOY22\", K_JOY22},\n\t{\"JOY23\", K_JOY23},\n\t{\"JOY24\", K_JOY24},\n\t{\"JOY25\", K_JOY25},\n\t{\"JOY26\", K_JOY26},\n\t{\"JOY27\", K_JOY27},\n\t{\"JOY28\", K_JOY28},\n\t{\"JOY29\", K_JOY29},\n\t{\"JOY30\", K_JOY30},\n\t{\"JOY31\", K_JOY31},\n\t{\"JOY32\", K_JOY32},\n\n\t{\"AUX1\", K_AUX1},\n\t{\"AUX2\", K_AUX2},\n\t{\"AUX3\", K_AUX3},\n\t{\"AUX4\", K_AUX4},\n\t{\"AUX5\", K_AUX5},\n\t{\"AUX6\", K_AUX6},\n\t{\"AUX7\", K_AUX7},\n\t{\"AUX8\", K_AUX8},\n\t{\"AUX9\", K_AUX9},\n\t{\"AUX10\", K_AUX10},\n\t{\"AUX11\", K_AUX11},\n\t{\"AUX12\", K_AUX12},\n\t{\"AUX13\", K_AUX13},\n\t{\"AUX14\", K_AUX14},\n\t{\"AUX15\", K_AUX15},\n\t{\"AUX16\", K_AUX16},\n\n\t{\"KP_HOME\",\t\t\tK_KP_HOME },\n\t{\"KP_UPARROW\",\t\tK_KP_UPARROW },\n\t{\"KP_PGUP\",\t\t\tK_KP_PGUP },\n\t{\"KP_LEFTARROW\",\tK_KP_LEFTARROW },\n\t{\"KP_5\",\t\t\tK_KP_5 },\n\t{\"KP_RIGHTARROW\",\tK_KP_RIGHTARROW },\n\t{\"KP_END\",\t\t\tK_KP_END },\n\t{\"KP_DOWNARROW\",\tK_KP_DOWNARROW },\n\t{\"KP_PGDN\",\t\t\tK_KP_PGDN },\n\t{\"KP_ENTER\",\t\tK_KP_ENTER },\n\t{\"KP_INS\",\t\t\tK_KP_INS },\n\t{\"KP_DEL\",\t\t\tK_KP_DEL },\n\t{\"KP_SLASH\",\t\tK_KP_SLASH },\n\t{\"KP_MINUS\",\t\tK_KP_MINUS },\n\t{\"KP_PLUS\",\t\t\tK_KP_PLUS },\n\t{\"KP_NUMLOCK\",\t\tK_KP_NUMLOCK },\n\t{\"KP_STAR\",\t\t\tK_KP_STAR },\n\t{\"KP_EQUALS\",\t\tK_KP_EQUALS },\n\n\t{\"PAUSE\", K_PAUSE},\n\t\n\t{\"SEMICOLON\", ';'},\t// because a raw semicolon seperates commands\n\n\t{NULL,0}\n};\n\n/*\n=============================================================================\n\nEDIT FIELDS\n\n=============================================================================\n*/\n\n\n/*\n===================\nField_Draw\n\nHandles horizontal scrolling and cursor blinking\nx, y, amd width are in pixels\n===================\n*/\nvoid Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, qboolean showCursor ) {\n\tint\t\tlen;\n\tint\t\tdrawLen;\n\tint\t\tprestep;\n\tint\t\tcursorChar;\n\tchar\tstr[MAX_STRING_CHARS];\n\tint\t\ti;\n\n\tdrawLen = edit->widthInChars;\n\tlen = strlen( edit->buffer ) + 1;\n\n\t// guarantee that cursor will be visible\n\tif ( len <= drawLen ) {\n\t\tprestep = 0;\n\t} else {\n\t\tif ( edit->scroll + drawLen > len ) {\n\t\t\tedit->scroll = len - drawLen;\n\t\t\tif ( edit->scroll < 0 ) {\n\t\t\t\tedit->scroll = 0;\n\t\t\t}\n\t\t}\n\t\tprestep = edit->scroll;\n\n/*\n\t\tif ( edit->cursor < len - drawLen ) {\n\t\t\tprestep = edit->cursor;\t// cursor at start\n\t\t} else {\n\t\t\tprestep = len - drawLen;\n\t\t}\n*/\n\t}\n\n\tif ( prestep + drawLen > len ) {\n\t\tdrawLen = len - prestep;\n\t}\n\n\t// extract <drawLen> characters from the field at <prestep>\n\tif ( drawLen >= MAX_STRING_CHARS ) {\n\t\tCom_Error( ERR_DROP, \"drawLen >= MAX_STRING_CHARS\" );\n\t}\n\n\tCom_Memcpy( str, edit->buffer + prestep, drawLen );\n\tstr[ drawLen ] = 0;\n\n\t// draw it\n\tif ( size == SMALLCHAR_WIDTH ) {\n\t\tfloat\tcolor[4];\n\n\t\tcolor[0] = color[1] = color[2] = color[3] = 1.0;\n\t\tSCR_DrawSmallStringExt( x, y, str, color, qfalse );\n\t} else {\n\t\t// draw big string with drop shadow\n\t\tSCR_DrawBigString( x, y, str, 1.0 );\n\t}\n\n\t// draw the cursor\n\tif ( !showCursor ) {\n\t\treturn;\n\t}\n\n\tif ( (int)( cls.realtime >> 8 ) & 1 ) {\n\t\treturn;\t\t// off blink\n\t}\n\n\tif ( key_overstrikeMode ) {\n\t\tcursorChar = 11;\n\t} else {\n\t\tcursorChar = 10;\n\t}\n\n\ti = drawLen - ( Q_PrintStrlen( str ) + 1 );\n\n\tif ( size == SMALLCHAR_WIDTH ) {\n\t\tSCR_DrawSmallChar( x + ( edit->cursor - prestep - i ) * size, y, cursorChar );\n\t} else {\n\t\tstr[0] = cursorChar;\n\t\tstr[1] = 0;\n\t\tSCR_DrawBigString( x + ( edit->cursor - prestep - i ) * size, y, str, 1.0 );\n\n\t}\n}\n\nvoid Field_Draw( field_t *edit, int x, int y, int width, qboolean showCursor ) \n{\n\tField_VariableSizeDraw( edit, x, y, width, SMALLCHAR_WIDTH, showCursor );\n}\n\nvoid Field_BigDraw( field_t *edit, int x, int y, int width, qboolean showCursor ) \n{\n\tField_VariableSizeDraw( edit, x, y, width, BIGCHAR_WIDTH, showCursor );\n}\n\n/*\n================\nField_Paste\n================\n*/\nvoid Field_Paste( field_t *edit ) {\n\tchar\t*cbd;\n\tint\t\tpasteLen, i;\n\n\tcbd = Sys_GetClipboardData();\n\n\tif ( !cbd ) {\n\t\treturn;\n\t}\n\n\t// send as if typed, so insert / overstrike works properly\n\tpasteLen = strlen( cbd );\n\tfor ( i = 0 ; i < pasteLen ; i++ ) {\n\t\tField_CharEvent( edit, cbd[i] );\n\t}\n\n\tZ_Free( cbd );\n}\n\n/*\n=================\nField_KeyDownEvent\n\nPerforms the basic line editing functions for the console,\nin-game talk, and menu fields\n\nKey events are used for non-printable characters, others are gotten from char events.\n=================\n*/\nvoid Field_KeyDownEvent( field_t *edit, int key ) {\n\tint\t\tlen;\n\n\t// shift-insert is paste\n\tif ( ( ( key == K_INS ) || ( key == K_KP_INS ) ) && keys[K_SHIFT].down ) {\n\t\tField_Paste( edit );\n\t\treturn;\n\t}\n\n\tlen = strlen( edit->buffer );\n\n\tif ( key == K_DEL ) {\n\t\tif ( edit->cursor < len ) {\n\t\t\tmemmove( edit->buffer + edit->cursor, \n\t\t\t\tedit->buffer + edit->cursor + 1, len - edit->cursor );\n\t\t}\n\t\treturn;\n\t}\n\n\tif ( key == K_RIGHTARROW ) \n\t{\n\t\tif ( edit->cursor < len ) {\n\t\t\tedit->cursor++;\n\t\t}\n\n\t\tif ( edit->cursor >= edit->scroll + edit->widthInChars && edit->cursor <= len )\n\t\t{\n\t\t\tedit->scroll++;\n\t\t}\n\t\treturn;\n\t}\n\n\tif ( key == K_LEFTARROW ) \n\t{\n\t\tif ( edit->cursor > 0 ) {\n\t\t\tedit->cursor--;\n\t\t}\n\t\tif ( edit->cursor < edit->scroll )\n\t\t{\n\t\t\tedit->scroll--;\n\t\t}\n\t\treturn;\n\t}\n\n\tif ( key == K_HOME || ( tolower(key) == 'a' && keys[K_CTRL].down ) ) {\n\t\tedit->cursor = 0;\n\t\treturn;\n\t}\n\n\tif ( key == K_END || ( tolower(key) == 'e' && keys[K_CTRL].down ) ) {\n\t\tedit->cursor = len;\n\t\treturn;\n\t}\n\n\tif ( key == K_INS ) {\n\t\tkey_overstrikeMode = !key_overstrikeMode;\n\t\treturn;\n\t}\n}\n\n/*\n==================\nField_CharEvent\n==================\n*/\nvoid Field_CharEvent( field_t *edit, int ch ) {\n\tint\t\tlen;\n\n\tif ( ch == 'v' - 'a' + 1 ) {\t// ctrl-v is paste\n\t\tField_Paste( edit );\n\t\treturn;\n\t}\n\n\tif ( ch == 'c' - 'a' + 1 ) {\t// ctrl-c clears the field\n\t\tField_Clear( edit );\n\t\treturn;\n\t}\n\n\tlen = strlen( edit->buffer );\n\n\tif ( ch == 'h' - 'a' + 1 )\t{\t// ctrl-h is backspace\n\t\tif ( edit->cursor > 0 ) {\n\t\t\tmemmove( edit->buffer + edit->cursor - 1, \n\t\t\t\tedit->buffer + edit->cursor, len + 1 - edit->cursor );\n\t\t\tedit->cursor--;\n\t\t\tif ( edit->cursor < edit->scroll )\n\t\t\t{\n\t\t\t\tedit->scroll--;\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\n\tif ( ch == 'a' - 'a' + 1 ) {\t// ctrl-a is home\n\t\tedit->cursor = 0;\n\t\tedit->scroll = 0;\n\t\treturn;\n\t}\n\n\tif ( ch == 'e' - 'a' + 1 ) {\t// ctrl-e is end\n\t\tedit->cursor = len;\n\t\tedit->scroll = edit->cursor - edit->widthInChars;\n\t\treturn;\n\t}\n\n\t//\n\t// ignore any other non printable chars\n\t//\n\tif ( ch < 32 ) {\n\t\treturn;\n\t}\n\n\tif ( key_overstrikeMode ) {\t\n\t\tif ( edit->cursor == MAX_EDIT_LINE - 1 )\n\t\t\treturn;\n\t\tedit->buffer[edit->cursor] = ch;\n\t\tedit->cursor++;\n\t} else {\t// insert mode\n\t\tif ( len == MAX_EDIT_LINE - 1 ) {\n\t\t\treturn; // all full\n\t\t}\n\t\tmemmove( edit->buffer + edit->cursor + 1, \n\t\t\tedit->buffer + edit->cursor, len + 1 - edit->cursor );\n\t\tedit->buffer[edit->cursor] = ch;\n\t\tedit->cursor++;\n\t}\n\n\n\tif ( edit->cursor >= edit->widthInChars ) {\n\t\tedit->scroll++;\n\t}\n\n\tif ( edit->cursor == len + 1) {\n\t\tedit->buffer[edit->cursor] = 0;\n\t}\n}\n\n/*\n=============================================================================\n\nCONSOLE LINE EDITING\n\n==============================================================================\n*/\n\n/*\n====================\nConsole_Key\n\nHandles history and console scrollback\n====================\n*/\nvoid Console_Key (int key) {\n\t// ctrl-L clears screen\n\tif ( key == 'l' && keys[K_CTRL].down ) {\n\t\tCbuf_AddText (\"clear\\n\");\n\t\treturn;\n\t}\n\n\t// enter finishes the line\n\tif ( key == K_ENTER || key == K_KP_ENTER ) {\n\t\t// if not in the game explicitly prepent a slash if needed\n\t\tif ( cls.state != CA_ACTIVE && g_consoleField.buffer[0] != '\\\\' \n\t\t\t&& g_consoleField.buffer[0] != '/' ) {\n\t\t\tchar\ttemp[MAX_STRING_CHARS];\n\n\t\t\tQ_strncpyz( temp, g_consoleField.buffer, sizeof( temp ) );\n\t\t\tCom_sprintf( g_consoleField.buffer, sizeof( g_consoleField.buffer ), \"\\\\%s\", temp );\n\t\t\tg_consoleField.cursor++;\n\t\t}\n\n\t\tCom_Printf ( \"]%s\\n\", g_consoleField.buffer );\n\n\t\t// leading slash is an explicit command\n\t\tif ( g_consoleField.buffer[0] == '\\\\' || g_consoleField.buffer[0] == '/' ) {\n\t\t\tCbuf_AddText( g_consoleField.buffer+1 );\t// valid command\n\t\t\tCbuf_AddText (\"\\n\");\n\t\t} else {\n\t\t\t// other text will be chat messages\n\t\t\tif ( !g_consoleField.buffer[0] ) {\n\t\t\t\treturn;\t// empty lines just scroll the console without adding to history\n\t\t\t} else {\n\t\t\t\tCbuf_AddText (\"cmd say \");\n\t\t\t\tCbuf_AddText( g_consoleField.buffer );\n\t\t\t\tCbuf_AddText (\"\\n\");\n\t\t\t}\n\t\t}\n\n\t\t// copy line to history buffer\n\t\thistoryEditLines[nextHistoryLine % COMMAND_HISTORY] = g_consoleField;\n\t\tnextHistoryLine++;\n\t\thistoryLine = nextHistoryLine;\n\n\t\tField_Clear( &g_consoleField );\n\n\t\tg_consoleField.widthInChars = g_console_field_width;\n\n\t\tif ( cls.state == CA_DISCONNECTED ) {\n\t\t\tSCR_UpdateScreen ();\t// force an update, because the command\n\t\t}\t\t\t\t\t\t\t// may take some time\n\t\treturn;\n\t}\n\n\t// command completion\n\n\tif (key == K_TAB) {\n\t\tField_CompleteCommand(&g_consoleField);\n\t\treturn;\n\t}\n\n\t// command history (ctrl-p ctrl-n for unix style)\n\n\tif ( (key == K_MWHEELUP && keys[K_SHIFT].down) || ( key == K_UPARROW ) || ( key == K_KP_UPARROW ) ||\n\t\t ( ( tolower(key) == 'p' ) && keys[K_CTRL].down ) ) {\n\t\tif ( nextHistoryLine - historyLine < COMMAND_HISTORY \n\t\t\t&& historyLine > 0 ) {\n\t\t\thistoryLine--;\n\t\t}\n\t\tg_consoleField = historyEditLines[ historyLine % COMMAND_HISTORY ];\n\t\treturn;\n\t}\n\n\tif ( (key == K_MWHEELDOWN && keys[K_SHIFT].down) || ( key == K_DOWNARROW ) || ( key == K_KP_DOWNARROW ) ||\n\t\t ( ( tolower(key) == 'n' ) && keys[K_CTRL].down ) ) {\n\t\tif (historyLine == nextHistoryLine)\n\t\t\treturn;\n\t\thistoryLine++;\n\t\tg_consoleField = historyEditLines[ historyLine % COMMAND_HISTORY ];\n\t\treturn;\n\t}\n\n\t// console scrolling\n\tif ( key == K_PGUP ) {\n\t\tCon_PageUp();\n\t\treturn;\n\t}\n\n\tif ( key == K_PGDN) {\n\t\tCon_PageDown();\n\t\treturn;\n\t}\n\n\tif ( key == K_MWHEELUP) {\t//----(SA)\tadded some mousewheel functionality to the console\n\t\tCon_PageUp();\n\t\tif(keys[K_CTRL].down) {\t// hold <ctrl> to accelerate scrolling\n\t\t\tCon_PageUp();\n\t\t\tCon_PageUp();\n\t\t}\n\t\treturn;\n\t}\n\n\tif ( key == K_MWHEELDOWN) {\t//----(SA)\tadded some mousewheel functionality to the console\n\t\tCon_PageDown();\n\t\tif(keys[K_CTRL].down) {\t// hold <ctrl> to accelerate scrolling\n\t\t\tCon_PageDown();\n\t\t\tCon_PageDown();\n\t\t}\n\t\treturn;\n\t}\n\n\t// ctrl-home = top of console\n\tif ( key == K_HOME && keys[K_CTRL].down ) {\n\t\tCon_Top();\n\t\treturn;\n\t}\n\n\t// ctrl-end = bottom of console\n\tif ( key == K_END && keys[K_CTRL].down ) {\n\t\tCon_Bottom();\n\t\treturn;\n\t}\n\n\t// pass to the normal editline routine\n\tField_KeyDownEvent( &g_consoleField, key );\n}\n\n//============================================================================\n\n\n/*\n================\nMessage_Key\n\nIn game talk message\n================\n*/\nvoid Message_Key( int key ) {\n\n\tchar\tbuffer[MAX_STRING_CHARS];\n\n\n\tif (key == K_ESCAPE) {\n\t\tcls.keyCatchers &= ~KEYCATCH_MESSAGE;\n\t\tField_Clear( &chatField );\n\t\treturn;\n\t}\n\n\tif ( key == K_ENTER || key == K_KP_ENTER )\n\t{\n\t\tif ( chatField.buffer[0] && cls.state == CA_ACTIVE ) {\n\t\t\tif (chat_playerNum != -1 )\n\n\t\t\t\tCom_sprintf( buffer, sizeof( buffer ), \"tell %i \\\"%s\\\"\\n\", chat_playerNum, chatField.buffer );\n\n\t\t\telse if (chat_team)\n\n\t\t\t\tCom_sprintf( buffer, sizeof( buffer ), \"say_team \\\"%s\\\"\\n\", chatField.buffer );\n\t\t\telse\n\t\t\t\tCom_sprintf( buffer, sizeof( buffer ), \"say \\\"%s\\\"\\n\", chatField.buffer );\n\n\n\n\t\t\tCL_AddReliableCommand( buffer );\n\t\t}\n\t\tcls.keyCatchers &= ~KEYCATCH_MESSAGE;\n\t\tField_Clear( &chatField );\n\t\treturn;\n\t}\n\n\tField_KeyDownEvent( &chatField, key );\n}\n\n//============================================================================\n\n\nqboolean Key_GetOverstrikeMode( void ) {\n\treturn key_overstrikeMode;\n}\n\n\nvoid Key_SetOverstrikeMode( qboolean state ) {\n\tkey_overstrikeMode = state;\n}\n\n\n/*\n===================\nKey_IsDown\n===================\n*/\nqboolean Key_IsDown( int keynum ) {\n\tif ( keynum == -1 ) {\n\t\treturn qfalse;\n\t}\n\n\treturn keys[keynum].down;\n}\n\n\n/*\n===================\nKey_StringToKeynum\n\nReturns a key number to be used to index keys[] by looking at\nthe given string.  Single ascii characters return themselves, while\nthe K_* names are matched up.\n\n0x11 will be interpreted as raw hex, which will allow new controlers\n\nto be configured even if they don't have defined names.\n===================\n*/\nint Key_StringToKeynum( char *str ) {\n\tkeyname_t\t*kn;\n\t\n\tif ( !str || !str[0] ) {\n\t\treturn -1;\n\t}\n\tif ( !str[1] ) {\n\t\treturn str[0];\n\t}\n\n\t// check for hex code\n\tif ( str[0] == '0' && str[1] == 'x' && strlen( str ) == 4) {\n\t\tint\t\tn1, n2;\n\t\t\n\t\tn1 = str[2];\n\t\tif ( n1 >= '0' && n1 <= '9' ) {\n\t\t\tn1 -= '0';\n\t\t} else if ( n1 >= 'a' && n1 <= 'f' ) {\n\t\t\tn1 = n1 - 'a' + 10;\n\t\t} else {\n\t\t\tn1 = 0;\n\t\t}\n\n\t\tn2 = str[3];\n\t\tif ( n2 >= '0' && n2 <= '9' ) {\n\t\t\tn2 -= '0';\n\t\t} else if ( n2 >= 'a' && n2 <= 'f' ) {\n\t\t\tn2 = n2 - 'a' + 10;\n\t\t} else {\n\t\t\tn2 = 0;\n\t\t}\n\n\t\treturn n1 * 16 + n2;\n\t}\n\n\t// scan for a text match\n\tfor ( kn=keynames ; kn->name ; kn++ ) {\n\t\tif ( !Q_stricmp( str,kn->name ) )\n\t\t\treturn kn->keynum;\n\t}\n\n\treturn -1;\n}\n\n/*\n===================\nKey_KeynumToString\n\nReturns a string (either a single ascii char, a K_* name, or a 0x11 hex string) for the\ngiven keynum.\n===================\n*/\nchar *Key_KeynumToString( int keynum ) {\n\tkeyname_t\t*kn;\t\n\tstatic\tchar\ttinystr[5];\n\tint\t\t\ti, j;\n\n\tif ( keynum == -1 ) {\n\t\treturn \"<KEY NOT FOUND>\";\n\t}\n\n\tif ( keynum < 0 || keynum > 255 ) {\n\t\treturn \"<OUT OF RANGE>\";\n\t}\n\n\t// check for printable ascii (don't use quote)\n\tif ( keynum > 32 && keynum < 127 && keynum != '\"' && keynum != ';' ) {\n\t\ttinystr[0] = keynum;\n\t\ttinystr[1] = 0;\n\t\treturn tinystr;\n\t}\n\n\t// check for a key string\n\tfor ( kn=keynames ; kn->name ; kn++ ) {\n\t\tif (keynum == kn->keynum) {\n\t\t\treturn kn->name;\n\t\t}\n\t}\n\n\t// make a hex string\n\ti = keynum >> 4;\n\tj = keynum & 15;\n\n\ttinystr[0] = '0';\n\ttinystr[1] = 'x';\n\ttinystr[2] = i > 9 ? i - 10 + 'a' : i + '0';\n\ttinystr[3] = j > 9 ? j - 10 + 'a' : j + '0';\n\ttinystr[4] = 0;\n\n\treturn tinystr;\n}\n\n\n/*\n===================\nKey_SetBinding\n===================\n*/\nvoid Key_SetBinding( int keynum, const char *binding ) {\n\tif ( keynum == -1 ) {\n\t\treturn;\n\t}\n\n\t// free old bindings\n\tif ( keys[ keynum ].binding ) {\n\t\tZ_Free( keys[ keynum ].binding );\n\t}\n\t\t\n\t// allocate memory for new binding\n\tkeys[keynum].binding = CopyString( binding );\n\n\t// consider this like modifying an archived cvar, so the\n\t// file write will be triggered at the next oportunity\n\tcvar_modifiedFlags |= CVAR_ARCHIVE;\n}\n\n\n/*\n===================\nKey_GetBinding\n===================\n*/\nchar *Key_GetBinding( int keynum ) {\n\tif ( keynum == -1 ) {\n\t\treturn \"\";\n\t}\n\n\treturn keys[ keynum ].binding;\n}\n\n/* \n===================\nKey_GetKey\n===================\n*/\n\nint Key_GetKey(const char *binding) {\n  int i;\n\n  if (binding) {\n  \tfor (i=0 ; i<256 ; i++) {\n      if (keys[i].binding && Q_stricmp(binding, keys[i].binding) == 0) {\n        return i;\n      }\n    }\n  }\n  return -1;\n}\n\n/*\n===================\nKey_Unbind_f\n===================\n*/\nvoid Key_Unbind_f (void)\n{\n\tint\t\tb;\n\n\tif (Cmd_Argc() != 2)\n\t{\n\t\tCom_Printf (\"unbind <key> : remove commands from a key\\n\");\n\t\treturn;\n\t}\n\t\n\tb = Key_StringToKeynum (Cmd_Argv(1));\n\tif (b==-1)\n\t{\n\t\tCom_Printf (\"\\\"%s\\\" isn't a valid key\\n\", Cmd_Argv(1));\n\t\treturn;\n\t}\n\n\tKey_SetBinding (b, \"\");\n}\n\n/*\n===================\nKey_Unbindall_f\n===================\n*/\nvoid Key_Unbindall_f (void)\n{\n\tint\t\ti;\n\t\n\tfor (i=0 ; i<256 ; i++)\n\t\tif (keys[i].binding)\n\t\t\tKey_SetBinding (i, \"\");\n}\n\n\n/*\n===================\nKey_Bind_f\n===================\n*/\nvoid Key_Bind_f (void)\n{\n\tint\t\t\ti, c, b;\n\tchar\t\tcmd[1024];\n\t\n\tc = Cmd_Argc();\n\n\tif (c < 2)\n\t{\n\t\tCom_Printf (\"bind <key> [command] : attach a command to a key\\n\");\n\t\treturn;\n\t}\n\tb = Key_StringToKeynum (Cmd_Argv(1));\n\tif (b==-1)\n\t{\n\t\tCom_Printf (\"\\\"%s\\\" isn't a valid key\\n\", Cmd_Argv(1));\n\t\treturn;\n\t}\n\n\tif (c == 2)\n\t{\n\t\tif (keys[b].binding)\n\t\t\tCom_Printf (\"\\\"%s\\\" = \\\"%s\\\"\\n\", Cmd_Argv(1), keys[b].binding );\n\t\telse\n\t\t\tCom_Printf (\"\\\"%s\\\" is not bound\\n\", Cmd_Argv(1) );\n\t\treturn;\n\t}\n\t\n// copy the rest of the command line\n\tcmd[0] = 0;\t\t// start out with a null string\n\tfor (i=2 ; i< c ; i++)\n\t{\n\t\tstrcat (cmd, Cmd_Argv(i));\n\t\tif (i != (c-1))\n\t\t\tstrcat (cmd, \" \");\n\t}\n\n\tKey_SetBinding (b, cmd);\n}\n\n/*\n============\nKey_WriteBindings\n\nWrites lines containing \"bind key value\"\n============\n*/\nvoid Key_WriteBindings( fileHandle_t f ) {\n\tint\t\ti;\n\n\tFS_Printf (f, \"unbindall\\n\" );\n\n\tfor (i=0 ; i<256 ; i++) {\n\t\tif (keys[i].binding && keys[i].binding[0] ) {\n\t\t\tFS_Printf (f, \"bind %s \\\"%s\\\"\\n\", Key_KeynumToString(i), keys[i].binding);\n\n\t\t}\n\n\t}\n}\n\n\n/*\n============\nKey_Bindlist_f\n\n============\n*/\nvoid Key_Bindlist_f( void ) {\n\tint\t\ti;\n\n\tfor ( i = 0 ; i < 256 ; i++ ) {\n\t\tif ( keys[i].binding && keys[i].binding[0] ) {\n\t\t\tCom_Printf( \"%s \\\"%s\\\"\\n\", Key_KeynumToString(i), keys[i].binding );\n\t\t}\n\t}\n}\n\n/*\n===================\nCL_InitKeyCommands\n===================\n*/\nvoid CL_InitKeyCommands( void ) {\n\t// register our functions\n\tCmd_AddCommand (\"bind\",Key_Bind_f);\n\tCmd_AddCommand (\"unbind\",Key_Unbind_f);\n\tCmd_AddCommand (\"unbindall\",Key_Unbindall_f);\n\tCmd_AddCommand (\"bindlist\",Key_Bindlist_f);\n}\n\n/*\n===================\nCL_AddKeyUpCommands\n===================\n*/\nvoid CL_AddKeyUpCommands( int key, char *kb ) {\n\tint i;\n\tchar button[1024], *buttonPtr;\n\tchar\tcmd[1024];\n\tqboolean keyevent;\n\n\tif ( !kb ) {\n\t\treturn;\n\t}\n\tkeyevent = qfalse;\n\tbuttonPtr = button;\n\tfor ( i = 0; ; i++ ) {\n\t\tif ( kb[i] == ';' || !kb[i] ) {\n\t\t\t*buttonPtr = '\\0';\n\t\t\tif ( button[0] == '+') {\n\t\t\t\t// button commands add keynum and time as parms so that multiple\n\t\t\t\t// sources can be discriminated and subframe corrected\n\t\t\t\tCom_sprintf (cmd, sizeof(cmd), \"-%s %i %i\\n\", button+1, key, time);\n\t\t\t\tCbuf_AddText (cmd);\n\t\t\t\tkeyevent = qtrue;\n\t\t\t} else {\n\t\t\t\tif (keyevent) {\n\t\t\t\t\t// down-only command\n\t\t\t\t\tCbuf_AddText (button);\n\t\t\t\t\tCbuf_AddText (\"\\n\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tbuttonPtr = button;\n\t\t\twhile ( (kb[i] <= ' ' || kb[i] == ';') && kb[i] != 0 ) {\n\t\t\t\ti++;\n\t\t\t}\n\t\t}\n\t\t*buttonPtr++ = kb[i];\n\t\tif ( !kb[i] ) {\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/*\n===================\nCL_KeyEvent\n\nCalled by the system for both key up and key down events\n===================\n*/\nvoid CL_KeyEvent (int key, qboolean down, unsigned time) {\n\tchar\t*kb;\n\tchar\tcmd[1024];\n\n\t// update auto-repeat status and BUTTON_ANY status\n\tkeys[key].down = down;\n\n\tif (down) {\n\t\tkeys[key].repeats++;\n\t\tif ( keys[key].repeats == 1) {\n\t\t\tanykeydown++;\n\t\t}\n\t} else {\n\t\tkeys[key].repeats = 0;\n\t\tanykeydown--;\n\t\tif (anykeydown < 0) {\n\t\t\tanykeydown = 0;\n\t\t}\n\t}\n\n#ifdef __linux__\n  if (key == K_ENTER)\n  {\n    if (down)\n    {\n      if (keys[K_ALT].down)\n      {\n        Key_ClearStates();\n        if (Cvar_VariableValue(\"r_fullscreen\") == 0)\n        {\n          Com_Printf(\"Switching to fullscreen rendering\\n\");\n          Cvar_Set(\"r_fullscreen\", \"1\");\n        }\n        else\n        {\n          Com_Printf(\"Switching to windowed rendering\\n\");\n          Cvar_Set(\"r_fullscreen\", \"0\");\n        }\n        Cbuf_ExecuteText( EXEC_APPEND, \"vid_restart\\n\");\n        return;\n      }\n    }\n  }\n#endif\n\n\t// console key is hardcoded, so the user can never unbind it\n\tif (key == '`' || key == '~') {\n\t\tif (!down) {\n\t\t\treturn;\n\t\t}\n    Con_ToggleConsole_f ();\n\t\treturn;\n\t}\n\n\n\t// keys can still be used for bound actions\n\tif ( down && ( key < 128 || key == K_MOUSE1 ) && ( clc.demoplaying || cls.state == CA_CINEMATIC ) && !cls.keyCatchers) {\n\n\t\tif (Cvar_VariableValue (\"com_cameraMode\") == 0) {\n\t\t\tCvar_Set (\"nextdemo\",\"\");\n\t\t\tkey = K_ESCAPE;\n\t\t}\n\t}\n\n\n\t// escape is always handled special\n\tif ( key == K_ESCAPE && down ) {\n\t\tif ( cls.keyCatchers & KEYCATCH_MESSAGE ) {\n\t\t\t// clear message mode\n\t\t\tMessage_Key( key );\n\t\t\treturn;\n\t\t}\n\n\t\t// escape always gets out of CGAME stuff\n\t\tif (cls.keyCatchers & KEYCATCH_CGAME) {\n\t\t\tcls.keyCatchers &= ~KEYCATCH_CGAME;\n\t\t\tVM_Call (cgvm, CG_EVENT_HANDLING, CGAME_EVENT_NONE);\n\t\t\treturn;\n\t\t}\n\n\t\tif ( !( cls.keyCatchers & KEYCATCH_UI ) ) {\n\t\t\tif ( cls.state == CA_ACTIVE && !clc.demoplaying ) {\n\t\t\t\tVM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_INGAME );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tCL_Disconnect_f();\n\t\t\t\tS_StopAllSounds();\n\t\t\t\tVM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_MAIN );\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tVM_Call( uivm, UI_KEY_EVENT, key, down );\n\t\treturn;\n\t}\n\n\t//\n\t// key up events only perform actions if the game key binding is\n\t// a button command (leading + sign).  These will be processed even in\n\t// console mode and menu mode, to keep the character from continuing \n\t// an action started before a mode switch.\n\t//\n\tif (!down) {\n\t\tkb = keys[key].binding;\n\n\t\tCL_AddKeyUpCommands( key, kb );\n\n\t\tif ( cls.keyCatchers & KEYCATCH_UI && uivm ) {\n\t\t\tVM_Call( uivm, UI_KEY_EVENT, key, down );\n\t\t} else if ( cls.keyCatchers & KEYCATCH_CGAME && cgvm ) {\n\t\t\tVM_Call( cgvm, CG_KEY_EVENT, key, down );\n\t\t} \n\n\t\treturn;\n\t}\n\n\n\t// distribute the key down event to the apropriate handler\n\tif ( cls.keyCatchers & KEYCATCH_CONSOLE ) {\n\t\tConsole_Key( key );\n\t} else if ( cls.keyCatchers & KEYCATCH_UI ) {\n\t\tif ( uivm ) {\n\t\t\tVM_Call( uivm, UI_KEY_EVENT, key, down );\n\t\t} \n\t} else if ( cls.keyCatchers & KEYCATCH_CGAME ) {\n\t\tif ( cgvm ) {\n\t\t\tVM_Call( cgvm, CG_KEY_EVENT, key, down );\n\t\t} \n\t} else if ( cls.keyCatchers & KEYCATCH_MESSAGE ) {\n\t\tMessage_Key( key );\n\t} else if ( cls.state == CA_DISCONNECTED ) {\n\t\tConsole_Key( key );\n\t} else {\n\t\t// send the bound action\n\t\tkb = keys[key].binding;\n\t\tif ( !kb ) {\n\t\t\tif (key >= 200) {\n\t\t\t\tCom_Printf (\"%s is unbound, use controls menu to set.\\n\"\n\t\t\t\t\t, Key_KeynumToString( key ) );\n\t\t\t}\n\t\t} else if (kb[0] == '+') {\t\n\t\t\tint i;\n\t\t\tchar button[1024], *buttonPtr;\n\t\t\tbuttonPtr = button;\n\t\t\tfor ( i = 0; ; i++ ) {\n\t\t\t\tif ( kb[i] == ';' || !kb[i] ) {\n\t\t\t\t\t*buttonPtr = '\\0';\n\t\t\t\t\tif ( button[0] == '+') {\n\t\t\t\t\t\t// button commands add keynum and time as parms so that multiple\n\t\t\t\t\t\t// sources can be discriminated and subframe corrected\n\t\t\t\t\t\tCom_sprintf (cmd, sizeof(cmd), \"%s %i %i\\n\", button, key, time);\n\t\t\t\t\t\tCbuf_AddText (cmd);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// down-only command\n\t\t\t\t\t\tCbuf_AddText (button);\n\t\t\t\t\t\tCbuf_AddText (\"\\n\");\n\t\t\t\t\t}\n\t\t\t\t\tbuttonPtr = button;\n\t\t\t\t\twhile ( (kb[i] <= ' ' || kb[i] == ';') && kb[i] != 0 ) {\n\t\t\t\t\t\ti++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t*buttonPtr++ = kb[i];\n\t\t\t\tif ( !kb[i] ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// down-only command\n\t\t\tCbuf_AddText (kb);\n\t\t\tCbuf_AddText (\"\\n\");\n\t\t}\n\t}\n}\n\n\n/*\n===================\nCL_CharEvent\n\nNormal keyboard characters, already shifted / capslocked / etc\n===================\n*/\nvoid CL_CharEvent( int key ) {\n\t// the console key should never be used as a char\n\tif ( key == '`' || key == '~' ) {\n\t\treturn;\n\t}\n\n\t// distribute the key down event to the apropriate handler\n\tif ( cls.keyCatchers & KEYCATCH_CONSOLE )\n\t{\n\t\tField_CharEvent( &g_consoleField, key );\n\t}\n\telse if ( cls.keyCatchers & KEYCATCH_UI )\n\t{\n\t\tVM_Call( uivm, UI_KEY_EVENT, key | K_CHAR_FLAG, qtrue );\n\t}\n\telse if ( cls.keyCatchers & KEYCATCH_MESSAGE ) \n\t{\n\t\tField_CharEvent( &chatField, key );\n\t}\n\telse if ( cls.state == CA_DISCONNECTED )\n\t{\n\t\tField_CharEvent( &g_consoleField, key );\n\t}\n}\n\n\n/*\n===================\nKey_ClearStates\n===================\n*/\nvoid Key_ClearStates (void)\n{\n\tint\t\ti;\n\n\tanykeydown = qfalse;\n\n\tfor ( i=0 ; i < MAX_KEYS ; i++ ) {\n\t\tif ( keys[i].down ) {\n\t\t\tCL_KeyEvent( i, qfalse, 0 );\n\n\t\t}\n\t\tkeys[i].down = 0;\n\t\tkeys[i].repeats = 0;\n\t}\n}\n\n"
  },
  {
    "path": "code/client/cl_main.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// cl_main.c  -- client main loop\n\n#include \"client.h\"\n#include <limits.h>\n\ncvar_t\t*cl_nodelta;\ncvar_t\t*cl_debugMove;\n\ncvar_t\t*cl_noprint;\ncvar_t\t*cl_motd;\n\ncvar_t\t*rcon_client_password;\ncvar_t\t*rconAddress;\n\ncvar_t\t*cl_timeout;\ncvar_t\t*cl_maxpackets;\ncvar_t\t*cl_packetdup;\ncvar_t\t*cl_timeNudge;\ncvar_t\t*cl_showTimeDelta;\ncvar_t\t*cl_freezeDemo;\n\ncvar_t\t*cl_shownet;\ncvar_t\t*cl_showSend;\ncvar_t\t*cl_timedemo;\ncvar_t\t*cl_avidemo;\ncvar_t\t*cl_forceavidemo;\n\ncvar_t\t*cl_freelook;\ncvar_t\t*cl_sensitivity;\n\ncvar_t\t*cl_mouseAccel;\ncvar_t\t*cl_showMouseRate;\n\ncvar_t\t*m_pitch;\ncvar_t\t*m_yaw;\ncvar_t\t*m_forward;\ncvar_t\t*m_side;\ncvar_t\t*m_filter;\n\ncvar_t\t*cl_activeAction;\n\ncvar_t\t*cl_motdString;\n\ncvar_t\t*cl_allowDownload;\ncvar_t\t*cl_conXOffset;\ncvar_t\t*cl_inGameVideo;\n\ncvar_t\t*cl_serverStatusResendTime;\ncvar_t\t*cl_trn;\n\nclientActive_t\t\tcl;\nclientConnection_t\tclc;\nclientStatic_t\t\tcls;\nvm_t\t\t\t\t*cgvm;\n\n// Structure containing functions exported from refresh DLL\nrefexport_t\tre;\n\nping_t\tcl_pinglist[MAX_PINGREQUESTS];\n\ntypedef struct serverStatus_s\n{\n\tchar string[BIG_INFO_STRING];\n\tnetadr_t address;\n\tint time, startTime;\n\tqboolean pending;\n\tqboolean print;\n\tqboolean retrieved;\n} serverStatus_t;\n\nserverStatus_t cl_serverStatusList[MAX_SERVERSTATUSREQUESTS];\nint serverStatusCount;\n\n#if defined __USEA3D && defined __A3D_GEOM\n\tvoid hA3Dg_ExportRenderGeom (refexport_t *incoming_re);\n#endif\n\nextern void SV_BotFrame( int time );\nvoid CL_CheckForResend( void );\nvoid CL_ShowIP_f(void);\nvoid CL_ServerStatus_f(void);\nvoid CL_ServerStatusResponse( netadr_t from, msg_t *msg );\n\n/*\n===============\nCL_CDDialog\n\nCalled by Com_Error when a cd is needed\n===============\n*/\nvoid CL_CDDialog( void ) {\n\tcls.cddialog = qtrue;\t// start it next frame\n}\n\n\n/*\n=======================================================================\n\nCLIENT RELIABLE COMMAND COMMUNICATION\n\n=======================================================================\n*/\n\n/*\n======================\nCL_AddReliableCommand\n\nThe given command will be transmitted to the server, and is gauranteed to\nnot have future usercmd_t executed before it is executed\n======================\n*/\nvoid CL_AddReliableCommand( const char *cmd ) {\n\tint\t\tindex;\n\n\t// if we would be losing an old command that hasn't been acknowledged,\n\t// we must drop the connection\n\tif ( clc.reliableSequence - clc.reliableAcknowledge > MAX_RELIABLE_COMMANDS ) {\n\t\tCom_Error( ERR_DROP, \"Client command overflow\" );\n\t}\n\tclc.reliableSequence++;\n\tindex = clc.reliableSequence & ( MAX_RELIABLE_COMMANDS - 1 );\n\tQ_strncpyz( clc.reliableCommands[ index ], cmd, sizeof( clc.reliableCommands[ index ] ) );\n}\n\n/*\n======================\nCL_ChangeReliableCommand\n======================\n*/\nvoid CL_ChangeReliableCommand( void ) {\n\tint r, index, l;\n\n\tr = clc.reliableSequence - (random() * 5);\n\tindex = clc.reliableSequence & ( MAX_RELIABLE_COMMANDS - 1 );\n\tl = strlen(clc.reliableCommands[ index ]);\n\tif ( l >= MAX_STRING_CHARS - 1 ) {\n\t\tl = MAX_STRING_CHARS - 2;\n\t}\n\tclc.reliableCommands[ index ][ l ] = '\\n';\n\tclc.reliableCommands[ index ][ l+1 ] = '\\0';\n}\n\n/*\n=======================================================================\n\nCLIENT SIDE DEMO RECORDING\n\n=======================================================================\n*/\n\n/*\n====================\nCL_WriteDemoMessage\n\nDumps the current net message, prefixed by the length\n====================\n*/\nvoid CL_WriteDemoMessage ( msg_t *msg, int headerBytes ) {\n\tint\t\tlen, swlen;\n\n\t// write the packet sequence\n\tlen = clc.serverMessageSequence;\n\tswlen = LittleLong( len );\n\tFS_Write (&swlen, 4, clc.demofile);\n\n\t// skip the packet sequencing information\n\tlen = msg->cursize - headerBytes;\n\tswlen = LittleLong(len);\n\tFS_Write (&swlen, 4, clc.demofile);\n\tFS_Write ( msg->data + headerBytes, len, clc.demofile );\n}\n\n\n/*\n====================\nCL_StopRecording_f\n\nstop recording a demo\n====================\n*/\nvoid CL_StopRecord_f( void ) {\n\tint\t\tlen;\n\n\tif ( !clc.demorecording ) {\n\t\tCom_Printf (\"Not recording a demo.\\n\");\n\t\treturn;\n\t}\n\n\t// finish up\n\tlen = -1;\n\tFS_Write (&len, 4, clc.demofile);\n\tFS_Write (&len, 4, clc.demofile);\n\tFS_FCloseFile (clc.demofile);\n\tclc.demofile = 0;\n\tclc.demorecording = qfalse;\n\tclc.spDemoRecording = qfalse;\n\tCom_Printf (\"Stopped demo.\\n\");\n}\n\n/* \n================== \nCL_DemoFilename\n================== \n*/  \nvoid CL_DemoFilename( int number, char *fileName ) {\n\tint\t\ta,b,c,d;\n\n\tif ( number < 0 || number > 9999 ) {\n\t\tCom_sprintf( fileName, MAX_OSPATH, \"demo9999.tga\" );\n\t\treturn;\n\t}\n\n\ta = number / 1000;\n\tnumber -= a*1000;\n\tb = number / 100;\n\tnumber -= b*100;\n\tc = number / 10;\n\tnumber -= c*10;\n\td = number;\n\n\tCom_sprintf( fileName, MAX_OSPATH, \"demo%i%i%i%i\"\n\t\t, a, b, c, d );\n}\n\n/*\n====================\nCL_Record_f\n\nrecord <demoname>\n\nBegins recording a demo from the current position\n====================\n*/\nstatic char\t\tdemoName[MAX_QPATH];\t// compiler bug workaround\nvoid CL_Record_f( void ) {\n\tchar\t\tname[MAX_OSPATH];\n\tbyte\t\tbufData[MAX_MSGLEN];\n\tmsg_t\tbuf;\n\tint\t\t\ti;\n\tint\t\t\tlen;\n\tentityState_t\t*ent;\n\tentityState_t\tnullstate;\n\tchar\t\t*s;\n\n\tif ( Cmd_Argc() > 2 ) {\n\t\tCom_Printf (\"record <demoname>\\n\");\n\t\treturn;\n\t}\n\n\tif ( clc.demorecording ) {\n\t\tif (!clc.spDemoRecording) {\n\t\t\tCom_Printf (\"Already recording.\\n\");\n\t\t}\n\t\treturn;\n\t}\n\n\tif ( cls.state != CA_ACTIVE ) {\n\t\tCom_Printf (\"You must be in a level to record.\\n\");\n\t\treturn;\n\t}\n\n  // sync 0 doesn't prevent recording, so not forcing it off .. everyone does g_sync 1 ; record ; g_sync 0 ..\n\tif ( !Cvar_VariableValue( \"g_synchronousClients\" ) ) {\n\t\tCom_Printf (S_COLOR_YELLOW \"WARNING: You should set 'g_synchronousClients 1' for smoother demo recording\\n\");\n\t}\n\n\tif ( Cmd_Argc() == 2 ) {\n\t\ts = Cmd_Argv(1);\n\t\tQ_strncpyz( demoName, s, sizeof( demoName ) );\n\t\tCom_sprintf (name, sizeof(name), \"demos/%s.dm_%d\", demoName, PROTOCOL_VERSION );\n\t} else {\n\t\tint\t\tnumber;\n\n\t\t// scan for a free demo name\n\t\tfor ( number = 0 ; number <= 9999 ; number++ ) {\n\t\t\tCL_DemoFilename( number, demoName );\n\t\t\tCom_sprintf (name, sizeof(name), \"demos/%s.dm_%d\", demoName, PROTOCOL_VERSION );\n\n\t\t\tlen = FS_ReadFile( name, NULL );\n\t\t\tif ( len <= 0 ) {\n\t\t\t\tbreak;\t// file doesn't exist\n\t\t\t}\n\t\t}\n\t}\n\n\t// open the demo file\n\n\tCom_Printf (\"recording to %s.\\n\", name);\n\tclc.demofile = FS_FOpenFileWrite( name );\n\tif ( !clc.demofile ) {\n\t\tCom_Printf (\"ERROR: couldn't open.\\n\");\n\t\treturn;\n\t}\n\tclc.demorecording = qtrue;\n\tif (Cvar_VariableValue(\"ui_recordSPDemo\")) {\n\t  clc.spDemoRecording = qtrue;\n\t} else {\n\t  clc.spDemoRecording = qfalse;\n\t}\n\n\n\tQ_strncpyz( clc.demoName, demoName, sizeof( clc.demoName ) );\n\n\t// don't start saving messages until a non-delta compressed message is received\n\tclc.demowaiting = qtrue;\n\n\t// write out the gamestate message\n\tMSG_Init (&buf, bufData, sizeof(bufData));\n\tMSG_Bitstream(&buf);\n\n\t// NOTE, MRE: all server->client messages now acknowledge\n\tMSG_WriteLong( &buf, clc.reliableSequence );\n\n\tMSG_WriteByte (&buf, svc_gamestate);\n\tMSG_WriteLong (&buf, clc.serverCommandSequence );\n\n\t// configstrings\n\tfor ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) {\n\t\tif ( !cl.gameState.stringOffsets[i] ) {\n\t\t\tcontinue;\n\t\t}\n\t\ts = cl.gameState.stringData + cl.gameState.stringOffsets[i];\n\t\tMSG_WriteByte (&buf, svc_configstring);\n\t\tMSG_WriteShort (&buf, i);\n\t\tMSG_WriteBigString (&buf, s);\n\t}\n\n\t// baselines\n\tCom_Memset (&nullstate, 0, sizeof(nullstate));\n\tfor ( i = 0; i < MAX_GENTITIES ; i++ ) {\n\t\tent = &cl.entityBaselines[i];\n\t\tif ( !ent->number ) {\n\t\t\tcontinue;\n\t\t}\n\t\tMSG_WriteByte (&buf, svc_baseline);\t\t\n\t\tMSG_WriteDeltaEntity (&buf, &nullstate, ent, qtrue );\n\t}\n\n\tMSG_WriteByte( &buf, svc_EOF );\n\t\n\t// finished writing the gamestate stuff\n\n\t// write the client num\n\tMSG_WriteLong(&buf, clc.clientNum);\n\t// write the checksum feed\n\tMSG_WriteLong(&buf, clc.checksumFeed);\n\n\t// finished writing the client packet\n\tMSG_WriteByte( &buf, svc_EOF );\n\n\t// write it to the demo file\n\tlen = LittleLong( clc.serverMessageSequence - 1 );\n\tFS_Write (&len, 4, clc.demofile);\n\n\tlen = LittleLong (buf.cursize);\n\tFS_Write (&len, 4, clc.demofile);\n\tFS_Write (buf.data, buf.cursize, clc.demofile);\n\n\t// the rest of the demo file will be copied from net messages\n}\n\n/*\n=======================================================================\n\nCLIENT SIDE DEMO PLAYBACK\n\n=======================================================================\n*/\n\n/*\n=================\nCL_DemoCompleted\n=================\n*/\nvoid CL_DemoCompleted( void ) {\n\tif (cl_timedemo && cl_timedemo->integer) {\n\t\tint\ttime;\n\t\t\n\t\ttime = Sys_Milliseconds() - clc.timeDemoStart;\n\t\tif ( time > 0 ) {\n\t\t\tCom_Printf (\"%i frames, %3.1f seconds: %3.1f fps\\n\", clc.timeDemoFrames,\n\t\t\ttime/1000.0, clc.timeDemoFrames*1000.0 / time);\n\t\t}\n\t}\n\n\tCL_Disconnect( qtrue );\n\tCL_NextDemo();\n}\n\n/*\n=================\nCL_ReadDemoMessage\n=================\n*/\nvoid CL_ReadDemoMessage( void ) {\n\tint\t\t\tr;\n\tmsg_t\t\tbuf;\n\tbyte\t\tbufData[ MAX_MSGLEN ];\n\tint\t\t\ts;\n\n\tif ( !clc.demofile ) {\n\t\tCL_DemoCompleted ();\n\t\treturn;\n\t}\n\n\t// get the sequence number\n\tr = FS_Read( &s, 4, clc.demofile);\n\tif ( r != 4 ) {\n\t\tCL_DemoCompleted ();\n\t\treturn;\n\t}\n\tclc.serverMessageSequence = LittleLong( s );\n\n\t// init the message\n\tMSG_Init( &buf, bufData, sizeof( bufData ) );\n\n\t// get the length\n\tr = FS_Read (&buf.cursize, 4, clc.demofile);\n\tif ( r != 4 ) {\n\t\tCL_DemoCompleted ();\n\t\treturn;\n\t}\n\tbuf.cursize = LittleLong( buf.cursize );\n\tif ( buf.cursize == -1 ) {\n\t\tCL_DemoCompleted ();\n\t\treturn;\n\t}\n\tif ( buf.cursize > buf.maxsize ) {\n\t\tCom_Error (ERR_DROP, \"CL_ReadDemoMessage: demoMsglen > MAX_MSGLEN\");\n\t}\n\tr = FS_Read( buf.data, buf.cursize, clc.demofile );\n\tif ( r != buf.cursize ) {\n\t\tCom_Printf( \"Demo file was truncated.\\n\");\n\t\tCL_DemoCompleted ();\n\t\treturn;\n\t}\n\n\tclc.lastPacketTime = cls.realtime;\n\tbuf.readcount = 0;\n\tCL_ParseServerMessage( &buf );\n}\n\n/*\n====================\nCL_WalkDemoExt\n====================\n*/\nstatic void CL_WalkDemoExt(char *arg, char *name, int *demofile)\n{\n\tint i = 0;\n\t*demofile = 0;\n\twhile(demo_protocols[i])\n\t{\n\t\tCom_sprintf (name, MAX_OSPATH, \"demos/%s.dm_%d\", arg, demo_protocols[i]);\n\t\tFS_FOpenFileRead( name, demofile, qtrue );\n\t\tif (*demofile)\n\t\t{\n\t\t\tCom_Printf(\"Demo file: %s\\n\", name);\n\t\t\tbreak;\n\t\t}\n\t\telse\n\t\t\tCom_Printf(\"Not found: %s\\n\", name);\n\t\ti++;\n\t}\n}\n\n/*\n====================\nCL_PlayDemo_f\n\ndemo <demoname>\n\n====================\n*/\nvoid CL_PlayDemo_f( void ) {\n\tchar\t\tname[MAX_OSPATH];\n\tchar\t\t*arg, *ext_test;\n\tint\t\t\tprotocol, i;\n\tchar\t\tretry[MAX_OSPATH];\n\n\tif (Cmd_Argc() != 2) {\n\t\tCom_Printf (\"playdemo <demoname>\\n\");\n\t\treturn;\n\t}\n\n\t// make sure a local server is killed\n\tCvar_Set( \"sv_killserver\", \"1\" );\n\n\tCL_Disconnect( qtrue );\n\n\t// open the demo file\n\targ = Cmd_Argv(1);\n\t\n\t// check for an extension .dm_?? (?? is protocol)\n\text_test = arg + strlen(arg) - 6;\n\tif ((strlen(arg) > 6) && (ext_test[0] == '.') && ((ext_test[1] == 'd') || (ext_test[1] == 'D')) && ((ext_test[2] == 'm') || (ext_test[2] == 'M')) && (ext_test[3] == '_'))\n\t{\n\t\tprotocol = atoi(ext_test+4);\n\t\ti=0;\n\t\twhile(demo_protocols[i])\n\t\t{\n\t\t\tif (demo_protocols[i] == protocol)\n\t\t\t\tbreak;\n\t\t\ti++;\n\t\t}\n\t\tif (demo_protocols[i])\n\t\t{\n\t\t\tCom_sprintf (name, sizeof(name), \"demos/%s\", arg);\n\t\t\tFS_FOpenFileRead( name, &clc.demofile, qtrue );\n\t\t} else {\n\t\t\tCom_Printf(\"Protocol %d not supported for demos\\n\", protocol);\n\t\t\tQ_strncpyz(retry, arg, sizeof(retry));\n\t\t\tretry[strlen(retry)-6] = 0;\n\t\t\tCL_WalkDemoExt( retry, name, &clc.demofile );\n\t\t}\n\t} else {\n\t\tCL_WalkDemoExt( arg, name, &clc.demofile );\n\t}\n\t\n\tif (!clc.demofile) {\n\t\tCom_Error( ERR_DROP, \"couldn't open %s\", name);\n\t\treturn;\n\t}\n\tQ_strncpyz( clc.demoName, Cmd_Argv(1), sizeof( clc.demoName ) );\n\n\tCon_Close();\n\n\tcls.state = CA_CONNECTED;\n\tclc.demoplaying = qtrue;\n\tQ_strncpyz( cls.servername, Cmd_Argv(1), sizeof( cls.servername ) );\n\n\t// read demo messages until connected\n\twhile ( cls.state >= CA_CONNECTED && cls.state < CA_PRIMED ) {\n\t\tCL_ReadDemoMessage();\n\t}\n\t// don't get the first snapshot this frame, to prevent the long\n\t// time from the gamestate load from messing causing a time skip\n\tclc.firstDemoFrameSkipped = qfalse;\n}\n\n\n/*\n====================\nCL_StartDemoLoop\n\nClosing the main menu will restart the demo loop\n====================\n*/\nvoid CL_StartDemoLoop( void ) {\n\t// start the demo loop again\n\tCbuf_AddText (\"d1\\n\");\n\tcls.keyCatchers = 0;\n}\n\n/*\n==================\nCL_NextDemo\n\nCalled when a demo or cinematic finishes\nIf the \"nextdemo\" cvar is set, that command will be issued\n==================\n*/\nvoid CL_NextDemo( void ) {\n\tchar\tv[MAX_STRING_CHARS];\n\n\tQ_strncpyz( v, Cvar_VariableString (\"nextdemo\"), sizeof(v) );\n\tv[MAX_STRING_CHARS-1] = 0;\n\tCom_DPrintf(\"CL_NextDemo: %s\\n\", v );\n\tif (!v[0]) {\n\t\treturn;\n\t}\n\n\tCvar_Set (\"nextdemo\",\"\");\n\tCbuf_AddText (v);\n\tCbuf_AddText (\"\\n\");\n\tCbuf_Execute();\n}\n\n\n//======================================================================\n\n/*\n=====================\nCL_ShutdownAll\n=====================\n*/\nvoid CL_ShutdownAll(void) {\n\n\t// clear sounds\n\tS_DisableSounds();\n\t// shutdown CGame\n\tCL_ShutdownCGame();\n\t// shutdown UI\n\tCL_ShutdownUI();\n\n\t// shutdown the renderer\n\tif ( re.Shutdown ) {\n\t\tre.Shutdown( qfalse );\t\t// don't destroy window or context\n\t}\n\n\tcls.uiStarted = qfalse;\n\tcls.cgameStarted = qfalse;\n\tcls.rendererStarted = qfalse;\n\tcls.soundRegistered = qfalse;\n}\n\n/*\n=================\nCL_FlushMemory\n\nCalled by CL_MapLoading, CL_Connect_f, CL_PlayDemo_f, and CL_ParseGamestate the only\nways a client gets into a game\nAlso called by Com_Error\n=================\n*/\nvoid CL_FlushMemory( void ) {\n\n\t// shutdown all the client stuff\n\tCL_ShutdownAll();\n\n\t// if not running a server clear the whole hunk\n\tif ( !com_sv_running->integer ) {\n\t\t// clear the whole hunk\n\t\tHunk_Clear();\n\t\t// clear collision map data\n\t\tCM_ClearMap();\n\t}\n\telse {\n\t\t// clear all the client data on the hunk\n\t\tHunk_ClearToMark();\n\t}\n\n\tCL_StartHunkUsers();\n}\n\n/*\n=====================\nCL_MapLoading\n\nA local server is starting to load a map, so update the\nscreen to let the user know about it, then dump all client\nmemory on the hunk from cgame, ui, and renderer\n=====================\n*/\nvoid CL_MapLoading( void ) {\n\tif ( !com_cl_running->integer ) {\n\t\treturn;\n\t}\n\n\tCon_Close();\n\tcls.keyCatchers = 0;\n\n\t// if we are already connected to the local host, stay connected\n\tif ( cls.state >= CA_CONNECTED && !Q_stricmp( cls.servername, \"localhost\" ) ) {\n\t\tcls.state = CA_CONNECTED;\t\t// so the connect screen is drawn\n\t\tCom_Memset( cls.updateInfoString, 0, sizeof( cls.updateInfoString ) );\n\t\tCom_Memset( clc.serverMessage, 0, sizeof( clc.serverMessage ) );\n\t\tCom_Memset( &cl.gameState, 0, sizeof( cl.gameState ) );\n\t\tclc.lastPacketSentTime = -9999;\n\t\tSCR_UpdateScreen();\n\t} else {\n\t\t// clear nextmap so the cinematic shutdown doesn't execute it\n\t\tCvar_Set( \"nextmap\", \"\" );\n\t\tCL_Disconnect( qtrue );\n\t\tQ_strncpyz( cls.servername, \"localhost\", sizeof(cls.servername) );\n\t\tcls.state = CA_CHALLENGING;\t\t// so the connect screen is drawn\n\t\tcls.keyCatchers = 0;\n\t\tSCR_UpdateScreen();\n\t\tclc.connectTime = -RETRANSMIT_TIMEOUT;\n\t\tNET_StringToAdr( cls.servername, &clc.serverAddress);\n\t\t// we don't need a challenge on the localhost\n\n\t\tCL_CheckForResend();\n\t}\n}\n\n/*\n=====================\nCL_ClearState\n\nCalled before parsing a gamestate\n=====================\n*/\nvoid CL_ClearState (void) {\n\n//\tS_StopAllSounds();\n\n\tCom_Memset( &cl, 0, sizeof( cl ) );\n}\n\n\n/*\n=====================\nCL_Disconnect\n\nCalled when a connection, demo, or cinematic is being terminated.\nGoes from a connected state to either a menu state or a console state\nSends a disconnect message to the server\nThis is also called on Com_Error and Com_Quit, so it shouldn't cause any errors\n=====================\n*/\nvoid CL_Disconnect( qboolean showMainMenu ) {\n\tif ( !com_cl_running || !com_cl_running->integer ) {\n\t\treturn;\n\t}\n\n\t// shutting down the client so enter full screen ui mode\n\tCvar_Set(\"r_uiFullScreen\", \"1\");\n\n\tif ( clc.demorecording ) {\n\t\tCL_StopRecord_f ();\n\t}\n\n\tif (clc.download) {\n\t\tFS_FCloseFile( clc.download );\n\t\tclc.download = 0;\n\t}\n\t*clc.downloadTempName = *clc.downloadName = 0;\n\tCvar_Set( \"cl_downloadName\", \"\" );\n\n\tif ( clc.demofile ) {\n\t\tFS_FCloseFile( clc.demofile );\n\t\tclc.demofile = 0;\n\t}\n\n\tif ( uivm && showMainMenu ) {\n\t\tVM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_NONE );\n\t}\n\n\tSCR_StopCinematic ();\n\tS_ClearSoundBuffer();\n\n\t// send a disconnect message to the server\n\t// send it a few times in case one is dropped\n\tif ( cls.state >= CA_CONNECTED ) {\n\t\tCL_AddReliableCommand( \"disconnect\" );\n\t\tCL_WritePacket();\n\t\tCL_WritePacket();\n\t\tCL_WritePacket();\n\t}\n\t\n\tCL_ClearState ();\n\n\t// wipe the client connection\n\tCom_Memset( &clc, 0, sizeof( clc ) );\n\n\tcls.state = CA_DISCONNECTED;\n\n\t// allow cheats locally\n\tCvar_Set( \"sv_cheats\", \"1\" );\n\n\t// not connected to a pure server anymore\n\tcl_connectedToPureServer = qfalse;\n}\n\n\n/*\n===================\nCL_ForwardCommandToServer\n\nadds the current command line as a clientCommand\nthings like godmode, noclip, etc, are commands directed to the server,\nso when they are typed in at the console, they will need to be forwarded.\n===================\n*/\nvoid CL_ForwardCommandToServer( const char *string ) {\n\tchar\t*cmd;\n\n\tcmd = Cmd_Argv(0);\n\n\t// ignore key up commands\n\tif ( cmd[0] == '-' ) {\n\t\treturn;\n\t}\n\n\tif ( clc.demoplaying || cls.state < CA_CONNECTED || cmd[0] == '+' ) {\n\t\tCom_Printf (\"Unknown command \\\"%s\\\"\\n\", cmd);\n\t\treturn;\n\t}\n\n\tif ( Cmd_Argc() > 1 ) {\n\t\tCL_AddReliableCommand( string );\n\t} else {\n\t\tCL_AddReliableCommand( cmd );\n\t}\n}\n\n/*\n===================\nCL_RequestMotd\n\n===================\n*/\nvoid CL_RequestMotd( void ) {\n\tchar\t\tinfo[MAX_INFO_STRING];\n\n\tif ( !cl_motd->integer ) {\n\t\treturn;\n\t}\n\tCom_Printf( \"Resolving %s\\n\", UPDATE_SERVER_NAME );\n\tif ( !NET_StringToAdr( UPDATE_SERVER_NAME, &cls.updateServer  ) ) {\n\t\tCom_Printf( \"Couldn't resolve address\\n\" );\n\t\treturn;\n\t}\n\tcls.updateServer.port = BigShort( PORT_UPDATE );\n\tCom_Printf( \"%s resolved to %i.%i.%i.%i:%i\\n\", UPDATE_SERVER_NAME,\n\t\tcls.updateServer.ip[0], cls.updateServer.ip[1],\n\t\tcls.updateServer.ip[2], cls.updateServer.ip[3],\n\t\tBigShort( cls.updateServer.port ) );\n\t\n\tinfo[0] = 0;\n  // NOTE TTimo xoring against Com_Milliseconds, otherwise we may not have a true randomization\n  // only srand I could catch before here is tr_noise.c l:26 srand(1001)\n  // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=382\n  // NOTE: the Com_Milliseconds xoring only affects the lower 16-bit word,\n  //   but I decided it was enough randomization\n\tCom_sprintf( cls.updateChallenge, sizeof( cls.updateChallenge ), \"%i\", ((rand() << 16) ^ rand()) ^ Com_Milliseconds());\n\n\tInfo_SetValueForKey( info, \"challenge\", cls.updateChallenge );\n\tInfo_SetValueForKey( info, \"renderer\", cls.glconfig.renderer_string );\n\tInfo_SetValueForKey( info, \"version\", com_version->string );\n\n\tNET_OutOfBandPrint( NS_CLIENT, cls.updateServer, \"getmotd \\\"%s\\\"\\n\", info );\n}\n\n/*\n===================\nCL_RequestAuthorization\n\nAuthorization server protocol\n-----------------------------\n\nAll commands are text in Q3 out of band packets (leading 0xff 0xff 0xff 0xff).\n\nWhenever the client tries to get a challenge from the server it wants to\nconnect to, it also blindly fires off a packet to the authorize server:\n\ngetKeyAuthorize <challenge> <cdkey>\n\ncdkey may be \"demo\"\n\n\n#OLD The authorize server returns a:\n#OLD \n#OLD keyAthorize <challenge> <accept | deny>\n#OLD \n#OLD A client will be accepted if the cdkey is valid and it has not been used by any other IP\n#OLD address in the last 15 minutes.\n\n\nThe server sends a:\n\ngetIpAuthorize <challenge> <ip>\n\nThe authorize server returns a:\n\nipAuthorize <challenge> <accept | deny | demo | unknown >\n\nA client will be accepted if a valid cdkey was sent by that ip (only) in the last 15 minutes.\nIf no response is received from the authorize server after two tries, the client will be let\nin anyway.\n===================\n*/\nvoid CL_RequestAuthorization( void ) {\n\tchar\tnums[64];\n\tint\t\ti, j, l;\n\tcvar_t\t*fs;\n\n\tif ( !cls.authorizeServer.port ) {\n\t\tCom_Printf( \"Resolving %s\\n\", AUTHORIZE_SERVER_NAME );\n\t\tif ( !NET_StringToAdr( AUTHORIZE_SERVER_NAME, &cls.authorizeServer  ) ) {\n\t\t\tCom_Printf( \"Couldn't resolve address\\n\" );\n\t\t\treturn;\n\t\t}\n\n\t\tcls.authorizeServer.port = BigShort( PORT_AUTHORIZE );\n\t\tCom_Printf( \"%s resolved to %i.%i.%i.%i:%i\\n\", AUTHORIZE_SERVER_NAME,\n\t\t\tcls.authorizeServer.ip[0], cls.authorizeServer.ip[1],\n\t\t\tcls.authorizeServer.ip[2], cls.authorizeServer.ip[3],\n\t\t\tBigShort( cls.authorizeServer.port ) );\n\t}\n\tif ( cls.authorizeServer.type == NA_BAD ) {\n\t\treturn;\n\t}\n\n\tif ( Cvar_VariableValue( \"fs_restrict\" ) ) {\n\t\tQ_strncpyz( nums, \"demota\", sizeof( nums ) );\n\t} else {\n\t\t// only grab the alphanumeric values from the cdkey, to avoid any dashes or spaces\n\t\tj = 0;\n\t\tl = strlen( cl_cdkey );\n\t\tif ( l > 32 ) {\n\t\t\tl = 32;\n\t\t}\n\t\tfor ( i = 0 ; i < l ; i++ ) {\n\t\t\tif ( ( cl_cdkey[i] >= '0' && cl_cdkey[i] <= '9' )\n\t\t\t\t|| ( cl_cdkey[i] >= 'a' && cl_cdkey[i] <= 'z' )\n\t\t\t\t|| ( cl_cdkey[i] >= 'A' && cl_cdkey[i] <= 'Z' )\n\t\t\t\t) {\n\t\t\t\tnums[j] = cl_cdkey[i];\n\t\t\t\tj++;\n\t\t\t}\n\t\t}\n\t\tnums[j] = 0;\n\t}\n\n\tfs = Cvar_Get (\"cl_anonymous\", \"0\", CVAR_INIT|CVAR_SYSTEMINFO );\n\n\tNET_OutOfBandPrint(NS_CLIENT, cls.authorizeServer, va(\"getKeyAuthorize %i %s\", fs->integer, nums) );\n}\n\n/*\n======================================================================\n\nCONSOLE COMMANDS\n\n======================================================================\n*/\n\n/*\n==================\nCL_ForwardToServer_f\n==================\n*/\nvoid CL_ForwardToServer_f( void ) {\n\tif ( cls.state != CA_ACTIVE || clc.demoplaying ) {\n\t\tCom_Printf (\"Not connected to a server.\\n\");\n\t\treturn;\n\t}\n\t\n\t// don't forward the first argument\n\tif ( Cmd_Argc() > 1 ) {\n\t\tCL_AddReliableCommand( Cmd_Args() );\n\t}\n}\n\n/*\n==================\nCL_Setenv_f\n\nMostly for controlling voodoo environment variables\n==================\n*/\nvoid CL_Setenv_f( void ) {\n\tint argc = Cmd_Argc();\n\n\tif ( argc > 2 ) {\n\t\tchar buffer[1024];\n\t\tint i;\n\n\t\tstrcpy( buffer, Cmd_Argv(1) );\n\t\tstrcat( buffer, \"=\" );\n\n\t\tfor ( i = 2; i < argc; i++ ) {\n\t\t\tstrcat( buffer, Cmd_Argv( i ) );\n\t\t\tstrcat( buffer, \" \" );\n\t\t}\n\n\t\tputenv( buffer );\n\t} else if ( argc == 2 ) {\n\t\tchar *env = getenv( Cmd_Argv(1) );\n\n\t\tif ( env ) {\n\t\t\tCom_Printf( \"%s=%s\\n\", Cmd_Argv(1), env );\n\t\t} else {\n\t\t\tCom_Printf( \"%s undefined\\n\", Cmd_Argv(1), env );\n\t\t}\n\t}\n}\n\n\n/*\n==================\nCL_Disconnect_f\n==================\n*/\nvoid CL_Disconnect_f( void ) {\n\tSCR_StopCinematic();\n\tCvar_Set(\"ui_singlePlayerActive\", \"0\");\n\tif ( cls.state != CA_DISCONNECTED && cls.state != CA_CINEMATIC ) {\n\t\tCom_Error (ERR_DISCONNECT, \"Disconnected from server\");\n\t}\n}\n\n\n/*\n================\nCL_Reconnect_f\n\n================\n*/\nvoid CL_Reconnect_f( void ) {\n\tif ( !strlen( cls.servername ) || !strcmp( cls.servername, \"localhost\" ) ) {\n\t\tCom_Printf( \"Can't reconnect to localhost.\\n\" );\n\t\treturn;\n\t}\n\tCvar_Set(\"ui_singlePlayerActive\", \"0\");\n\tCbuf_AddText( va(\"connect %s\\n\", cls.servername ) );\n}\n\n/*\n================\nCL_Connect_f\n\n================\n*/\nvoid CL_Connect_f( void ) {\n\tchar\t*server;\n\n\tif ( Cmd_Argc() != 2 ) {\n\t\tCom_Printf( \"usage: connect [server]\\n\");\n\t\treturn;\t\n\t}\n\n\tCvar_Set(\"ui_singlePlayerActive\", \"0\");\n\n\t// fire a message off to the motd server\n\tCL_RequestMotd();\n\n\t// clear any previous \"server full\" type messages\n\tclc.serverMessage[0] = 0;\n\n\tserver = Cmd_Argv (1);\n\n\tif ( com_sv_running->integer && !strcmp( server, \"localhost\" ) ) {\n\t\t// if running a local server, kill it\n\t\tSV_Shutdown( \"Server quit\\n\" );\n\t}\n\n\t// make sure a local server is killed\n\tCvar_Set( \"sv_killserver\", \"1\" );\n\tSV_Frame( 0 );\n\n\tCL_Disconnect( qtrue );\n\tCon_Close();\n\n\t/* MrE: 2000-09-13: now called in CL_DownloadsComplete\n\tCL_FlushMemory( );\n\t*/\n\n\tQ_strncpyz( cls.servername, server, sizeof(cls.servername) );\n\n\tif (!NET_StringToAdr( cls.servername, &clc.serverAddress) ) {\n\t\tCom_Printf (\"Bad server address\\n\");\n\t\tcls.state = CA_DISCONNECTED;\n\t\treturn;\n\t}\n\tif (clc.serverAddress.port == 0) {\n\t\tclc.serverAddress.port = BigShort( PORT_SERVER );\n\t}\n\tCom_Printf( \"%s resolved to %i.%i.%i.%i:%i\\n\", cls.servername,\n\t\tclc.serverAddress.ip[0], clc.serverAddress.ip[1],\n\t\tclc.serverAddress.ip[2], clc.serverAddress.ip[3],\n\t\tBigShort( clc.serverAddress.port ) );\n\n\t// if we aren't playing on a lan, we need to authenticate\n\t// with the cd key\n\tif ( NET_IsLocalAddress( clc.serverAddress ) ) {\n\t\tcls.state = CA_CHALLENGING;\n\t} else {\n\t\tcls.state = CA_CONNECTING;\n\t}\n\n\tcls.keyCatchers = 0;\n\tclc.connectTime = -99999;\t// CL_CheckForResend() will fire immediately\n\tclc.connectPacketCount = 0;\n\n\t// server connection string\n\tCvar_Set( \"cl_currentServerAddress\", server );\n}\n\n\n/*\n=====================\nCL_Rcon_f\n\n  Send the rest of the command line over as\n  an unconnected command.\n=====================\n*/\nvoid CL_Rcon_f( void ) {\n\tchar\tmessage[1024];\n\tnetadr_t\tto;\n\n\tif ( !rcon_client_password->string ) {\n\t\tCom_Printf (\"You must set 'rconpassword' before\\n\"\n\t\t\t\t\t\"issuing an rcon command.\\n\");\n\t\treturn;\n\t}\n\n\tmessage[0] = -1;\n\tmessage[1] = -1;\n\tmessage[2] = -1;\n\tmessage[3] = -1;\n\tmessage[4] = 0;\n\n\tstrcat (message, \"rcon \");\n\n\tstrcat (message, rcon_client_password->string);\n\tstrcat (message, \" \");\n\n\t// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=543\n\tstrcat (message, Cmd_Cmd()+5);\n\n\tif ( cls.state >= CA_CONNECTED ) {\n\t\tto = clc.netchan.remoteAddress;\n\t} else {\n\t\tif (!strlen(rconAddress->string)) {\n\t\t\tCom_Printf (\"You must either be connected,\\n\"\n\t\t\t\t\t\t\"or set the 'rconAddress' cvar\\n\"\n\t\t\t\t\t\t\"to issue rcon commands\\n\");\n\n\t\t\treturn;\n\t\t}\n\t\tNET_StringToAdr (rconAddress->string, &to);\n\t\tif (to.port == 0) {\n\t\t\tto.port = BigShort (PORT_SERVER);\n\t\t}\n\t}\n\t\n\tNET_SendPacket (NS_CLIENT, strlen(message)+1, message, to);\n}\n\n/*\n=================\nCL_SendPureChecksums\n=================\n*/\nvoid CL_SendPureChecksums( void ) {\n\tconst char *pChecksums;\n\tchar cMsg[MAX_INFO_VALUE];\n\tint i;\n\n\t// if we are pure we need to send back a command with our referenced pk3 checksums\n\tpChecksums = FS_ReferencedPakPureChecksums();\n\n\t// \"cp\"\n\t// \"Yf\"\n\tCom_sprintf(cMsg, sizeof(cMsg), \"Yf \");\n\tQ_strcat(cMsg, sizeof(cMsg), va(\"%d \", cl.serverId) );\n\tQ_strcat(cMsg, sizeof(cMsg), pChecksums);\n\tfor (i = 0; i < 2; i++) {\n\t\tcMsg[i] += 10;\n\t}\n\tCL_AddReliableCommand( cMsg );\n}\n\n/*\n=================\nCL_ResetPureClientAtServer\n=================\n*/\nvoid CL_ResetPureClientAtServer( void ) {\n\tCL_AddReliableCommand( va(\"vdr\") );\n}\n\n/*\n=================\nCL_Vid_Restart_f\n\nRestart the video subsystem\n\nwe also have to reload the UI and CGame because the renderer\ndoesn't know what graphics to reload\n=================\n*/\nvoid CL_Vid_Restart_f( void ) {\n\n\t// don't let them loop during the restart\n\tS_StopAllSounds();\n\t// shutdown the UI\n\tCL_ShutdownUI();\n\t// shutdown the CGame\n\tCL_ShutdownCGame();\n\t// shutdown the renderer and clear the renderer interface\n\tCL_ShutdownRef();\n\t// client is no longer pure untill new checksums are sent\n\tCL_ResetPureClientAtServer();\n\t// clear pak references\n\tFS_ClearPakReferences( FS_UI_REF | FS_CGAME_REF );\n\t// reinitialize the filesystem if the game directory or checksum has changed\n\tFS_ConditionalRestart( clc.checksumFeed );\n\n\tcls.rendererStarted = qfalse;\n\tcls.uiStarted = qfalse;\n\tcls.cgameStarted = qfalse;\n\tcls.soundRegistered = qfalse;\n\n\t// unpause so the cgame definately gets a snapshot and renders a frame\n\tCvar_Set( \"cl_paused\", \"0\" );\n\n\t// if not running a server clear the whole hunk\n\tif ( !com_sv_running->integer ) {\n\t\t// clear the whole hunk\n\t\tHunk_Clear();\n\t}\n\telse {\n\t\t// clear all the client data on the hunk\n\t\tHunk_ClearToMark();\n\t}\n\n\t// initialize the renderer interface\n\tCL_InitRef();\n\n\t// startup all the client stuff\n\tCL_StartHunkUsers();\n\n\t// start the cgame if connected\n\tif ( cls.state > CA_CONNECTED && cls.state != CA_CINEMATIC ) {\n\t\tcls.cgameStarted = qtrue;\n\t\tCL_InitCGame();\n\t\t// send pure checksums\n\t\tCL_SendPureChecksums();\n\t}\n}\n\n/*\n=================\nCL_Snd_Restart_f\n\nRestart the sound subsystem\nThe cgame and game must also be forced to restart because\nhandles will be invalid\n=================\n*/\nvoid CL_Snd_Restart_f( void ) {\n\tS_Shutdown();\n\tS_Init();\n\n\tCL_Vid_Restart_f();\n}\n\n\n/*\n==================\nCL_PK3List_f\n==================\n*/\nvoid CL_OpenedPK3List_f( void ) {\n\tCom_Printf(\"Opened PK3 Names: %s\\n\", FS_LoadedPakNames());\n}\n\n/*\n==================\nCL_PureList_f\n==================\n*/\nvoid CL_ReferencedPK3List_f( void ) {\n\tCom_Printf(\"Referenced PK3 Names: %s\\n\", FS_ReferencedPakNames());\n}\n\n/*\n==================\nCL_Configstrings_f\n==================\n*/\nvoid CL_Configstrings_f( void ) {\n\tint\t\ti;\n\tint\t\tofs;\n\n\tif ( cls.state != CA_ACTIVE ) {\n\t\tCom_Printf( \"Not connected to a server.\\n\");\n\t\treturn;\n\t}\n\n\tfor ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) {\n\t\tofs = cl.gameState.stringOffsets[ i ];\n\t\tif ( !ofs ) {\n\t\t\tcontinue;\n\t\t}\n\t\tCom_Printf( \"%4i: %s\\n\", i, cl.gameState.stringData + ofs );\n\t}\n}\n\n/*\n==============\nCL_Clientinfo_f\n==============\n*/\nvoid CL_Clientinfo_f( void ) {\n\tCom_Printf( \"--------- Client Information ---------\\n\" );\n\tCom_Printf( \"state: %i\\n\", cls.state );\n\tCom_Printf( \"Server: %s\\n\", cls.servername );\n\tCom_Printf (\"User info settings:\\n\");\n\tInfo_Print( Cvar_InfoString( CVAR_USERINFO ) );\n\tCom_Printf( \"--------------------------------------\\n\" );\n}\n\n\n//====================================================================\n\n/*\n=================\nCL_DownloadsComplete\n\nCalled when all downloading has been completed\n=================\n*/\nvoid CL_DownloadsComplete( void ) {\n\n\t// if we downloaded files we need to restart the file system\n\tif (clc.downloadRestart) {\n\t\tclc.downloadRestart = qfalse;\n\n\t\tFS_Restart(clc.checksumFeed); // We possibly downloaded a pak, restart the file system to load it\n\n\t\t// inform the server so we get new gamestate info\n\t\tCL_AddReliableCommand( \"donedl\" );\n\n\t\t// by sending the donedl command we request a new gamestate\n\t\t// so we don't want to load stuff yet\n\t\treturn;\n\t}\n\n\t// let the client game init and load data\n\tcls.state = CA_LOADING;\n\n\t// Pump the loop, this may change gamestate!\n\tCom_EventLoop();\n\n\t// if the gamestate was changed by calling Com_EventLoop\n\t// then we loaded everything already and we don't want to do it again.\n\tif ( cls.state != CA_LOADING ) {\n\t\treturn;\n\t}\n\n\t// starting to load a map so we get out of full screen ui mode\n\tCvar_Set(\"r_uiFullScreen\", \"0\");\n\n\t// flush client memory and start loading stuff\n\t// this will also (re)load the UI\n\t// if this is a local client then only the client part of the hunk\n\t// will be cleared, note that this is done after the hunk mark has been set\n\tCL_FlushMemory();\n\n\t// initialize the CGame\n\tcls.cgameStarted = qtrue;\n\tCL_InitCGame();\n\n\t// set pure checksums\n\tCL_SendPureChecksums();\n\n\tCL_WritePacket();\n\tCL_WritePacket();\n\tCL_WritePacket();\n}\n\n/*\n=================\nCL_BeginDownload\n\nRequests a file to download from the server.  Stores it in the current\ngame directory.\n=================\n*/\nvoid CL_BeginDownload( const char *localName, const char *remoteName ) {\n\n\tCom_DPrintf(\"***** CL_BeginDownload *****\\n\"\n\t\t\t\t\"Localname: %s\\n\"\n\t\t\t\t\"Remotename: %s\\n\"\n\t\t\t\t\"****************************\\n\", localName, remoteName);\n\n\tQ_strncpyz ( clc.downloadName, localName, sizeof(clc.downloadName) );\n\tCom_sprintf( clc.downloadTempName, sizeof(clc.downloadTempName), \"%s.tmp\", localName );\n\n\t// Set so UI gets access to it\n\tCvar_Set( \"cl_downloadName\", remoteName );\n\tCvar_Set( \"cl_downloadSize\", \"0\" );\n\tCvar_Set( \"cl_downloadCount\", \"0\" );\n\tCvar_SetValue( \"cl_downloadTime\", cls.realtime );\n\n\tclc.downloadBlock = 0; // Starting new file\n\tclc.downloadCount = 0;\n\n\tCL_AddReliableCommand( va(\"download %s\", remoteName) );\n}\n\n/*\n=================\nCL_NextDownload\n\nA download completed or failed\n=================\n*/\nvoid CL_NextDownload(void) {\n\tchar *s;\n\tchar *remoteName, *localName;\n\n\t// We are looking to start a download here\n\tif (*clc.downloadList) {\n\t\ts = clc.downloadList;\n\n\t\t// format is:\n\t\t//  @remotename@localname@remotename@localname, etc.\n\n\t\tif (*s == '@')\n\t\t\ts++;\n\t\tremoteName = s;\n\t\t\n\t\tif ( (s = strchr(s, '@')) == NULL ) {\n\t\t\tCL_DownloadsComplete();\n\t\t\treturn;\n\t\t}\n\n\t\t*s++ = 0;\n\t\tlocalName = s;\n\t\tif ( (s = strchr(s, '@')) != NULL )\n\t\t\t*s++ = 0;\n\t\telse\n\t\t\ts = localName + strlen(localName); // point at the nul byte\n\n\t\tCL_BeginDownload( localName, remoteName );\n\n\t\tclc.downloadRestart = qtrue;\n\n\t\t// move over the rest\n\t\tmemmove( clc.downloadList, s, strlen(s) + 1);\n\n\t\treturn;\n\t}\n\n\tCL_DownloadsComplete();\n}\n\n/*\n=================\nCL_InitDownloads\n\nAfter receiving a valid game state, we valid the cgame and local zip files here\nand determine if we need to download them\n=================\n*/\nvoid CL_InitDownloads(void) {\n  char missingfiles[1024];\n\n  if ( !cl_allowDownload->integer )\n  {\n    // autodownload is disabled on the client\n    // but it's possible that some referenced files on the server are missing\n    if (FS_ComparePaks( missingfiles, sizeof( missingfiles ), qfalse ) )\n    {      \n      // NOTE TTimo I would rather have that printed as a modal message box\n      //   but at this point while joining the game we don't know wether we will successfully join or not\n      Com_Printf( \"\\nWARNING: You are missing some files referenced by the server:\\n%s\"\n                  \"You might not be able to join the game\\n\"\n                  \"Go to the setting menu to turn on autodownload, or get the file elsewhere\\n\\n\", missingfiles );\n    }\n  }\n  else if ( FS_ComparePaks( clc.downloadList, sizeof( clc.downloadList ) , qtrue ) ) {\n\n    Com_Printf(\"Need paks: %s\\n\", clc.downloadList );\n\n\t\tif ( *clc.downloadList ) {\n\t\t\t// if autodownloading is not enabled on the server\n\t\t\tcls.state = CA_CONNECTED;\n\t\t\tCL_NextDownload();\n\t\t\treturn;\n\t\t}\n\n\t}\n\t\t\n\tCL_DownloadsComplete();\n}\n\n/*\n=================\nCL_CheckForResend\n\nResend a connect message if the last one has timed out\n=================\n*/\nvoid CL_CheckForResend( void ) {\n\tint\t\tport, i;\n\tchar\tinfo[MAX_INFO_STRING];\n\tchar\tdata[MAX_INFO_STRING];\n\n\t// don't send anything if playing back a demo\n\tif ( clc.demoplaying ) {\n\t\treturn;\n\t}\n\n\t// resend if we haven't gotten a reply yet\n\tif ( cls.state != CA_CONNECTING && cls.state != CA_CHALLENGING ) {\n\t\treturn;\n\t}\n\n\tif ( cls.realtime - clc.connectTime < RETRANSMIT_TIMEOUT ) {\n\t\treturn;\n\t}\n\n\tclc.connectTime = cls.realtime;\t// for retransmit requests\n\tclc.connectPacketCount++;\n\n\n\tswitch ( cls.state ) {\n\tcase CA_CONNECTING:\n\t\t// requesting a challenge\n\t\tif ( !Sys_IsLANAddress( clc.serverAddress ) ) {\n\t\t\tCL_RequestAuthorization();\n\t\t}\n\t\tNET_OutOfBandPrint(NS_CLIENT, clc.serverAddress, \"getchallenge\");\n\t\tbreak;\n\t\t\n\tcase CA_CHALLENGING:\n\t\t// sending back the challenge\n\t\tport = Cvar_VariableValue (\"net_qport\");\n\n\t\tQ_strncpyz( info, Cvar_InfoString( CVAR_USERINFO ), sizeof( info ) );\n\t\tInfo_SetValueForKey( info, \"protocol\", va(\"%i\", PROTOCOL_VERSION ) );\n\t\tInfo_SetValueForKey( info, \"qport\", va(\"%i\", port ) );\n\t\tInfo_SetValueForKey( info, \"challenge\", va(\"%i\", clc.challenge ) );\n\t\t\n\t\tstrcpy(data, \"connect \");\n    // TTimo adding \" \" around the userinfo string to avoid truncated userinfo on the server\n    //   (Com_TokenizeString tokenizes around spaces)\n    data[8] = '\"';\n\n\t\tfor(i=0;i<strlen(info);i++) {\n\t\t\tdata[9+i] = info[i];\t// + (clc.challenge)&0x3;\n\t\t}\n    data[9+i] = '\"';\n\t\tdata[10+i] = 0;\n\n    // NOTE TTimo don't forget to set the right data length!\n\t\tNET_OutOfBandData( NS_CLIENT, clc.serverAddress, &data[0], i+10 );\n\t\t// the most current userinfo has been sent, so watch for any\n\t\t// newer changes to userinfo variables\n\t\tcvar_modifiedFlags &= ~CVAR_USERINFO;\n\t\tbreak;\n\n\tdefault:\n\t\tCom_Error( ERR_FATAL, \"CL_CheckForResend: bad cls.state\" );\n\t}\n}\n\n/*\n===================\nCL_DisconnectPacket\n\nSometimes the server can drop the client and the netchan based\ndisconnect can be lost.  If the client continues to send packets\nto the server, the server will send out of band disconnect packets\nto the client so it doesn't have to wait for the full timeout period.\n===================\n*/\nvoid CL_DisconnectPacket( netadr_t from ) {\n\tif ( cls.state < CA_AUTHORIZING ) {\n\t\treturn;\n\t}\n\n\t// if not from our server, ignore it\n\tif ( !NET_CompareAdr( from, clc.netchan.remoteAddress ) ) {\n\t\treturn;\n\t}\n\n\t// if we have received packets within three seconds, ignore it\n\t// (it might be a malicious spoof)\n\tif ( cls.realtime - clc.lastPacketTime < 3000 ) {\n\t\treturn;\n\t}\n\n\t// drop the connection\n\tCom_Printf( \"Server disconnected for unknown reason\\n\" );\n\tCvar_Set(\"com_errorMessage\", \"Server disconnected for unknown reason\\n\" );\n\tCL_Disconnect( qtrue );\n}\n\n\n/*\n===================\nCL_MotdPacket\n\n===================\n*/\nvoid CL_MotdPacket( netadr_t from ) {\n\tchar\t*challenge;\n\tchar\t*info;\n\n\t// if not from our server, ignore it\n\tif ( !NET_CompareAdr( from, cls.updateServer ) ) {\n\t\treturn;\n\t}\n\n\tinfo = Cmd_Argv(1);\n\n\t// check challenge\n\tchallenge = Info_ValueForKey( info, \"challenge\" );\n\tif ( strcmp( challenge, cls.updateChallenge ) ) {\n\t\treturn;\n\t}\n\n\tchallenge = Info_ValueForKey( info, \"motd\" );\n\n\tQ_strncpyz( cls.updateInfoString, info, sizeof( cls.updateInfoString ) );\n\tCvar_Set( \"cl_motdString\", challenge );\n}\n\n/*\n===================\nCL_InitServerInfo\n===================\n*/\nvoid CL_InitServerInfo( serverInfo_t *server, serverAddress_t *address ) {\n\tserver->adr.type  = NA_IP;\n\tserver->adr.ip[0] = address->ip[0];\n\tserver->adr.ip[1] = address->ip[1];\n\tserver->adr.ip[2] = address->ip[2];\n\tserver->adr.ip[3] = address->ip[3];\n\tserver->adr.port  = address->port;\n\tserver->clients = 0;\n\tserver->hostName[0] = '\\0';\n\tserver->mapName[0] = '\\0';\n\tserver->maxClients = 0;\n\tserver->maxPing = 0;\n\tserver->minPing = 0;\n\tserver->ping = -1;\n\tserver->game[0] = '\\0';\n\tserver->gameType = 0;\n\tserver->netType = 0;\n}\n\n#define MAX_SERVERSPERPACKET\t256\n\n/*\n===================\nCL_ServersResponsePacket\n===================\n*/\nvoid CL_ServersResponsePacket( netadr_t from, msg_t *msg ) {\n\tint\t\t\t\ti, count, max, total;\n\tserverAddress_t addresses[MAX_SERVERSPERPACKET];\n\tint\t\t\t\tnumservers;\n\tbyte*\t\t\tbuffptr;\n\tbyte*\t\t\tbuffend;\n\t\n\tCom_Printf(\"CL_ServersResponsePacket\\n\");\n\n\tif (cls.numglobalservers == -1) {\n\t\t// state to detect lack of servers or lack of response\n\t\tcls.numglobalservers = 0;\n\t\tcls.numGlobalServerAddresses = 0;\n\t}\n\n\tif (cls.nummplayerservers == -1) {\n\t\tcls.nummplayerservers = 0;\n\t}\n\n\t// parse through server response string\n\tnumservers = 0;\n\tbuffptr    = msg->data;\n\tbuffend    = buffptr + msg->cursize;\n\twhile (buffptr+1 < buffend) {\n\t\t// advance to initial token\n\t\tdo {\n\t\t\tif (*buffptr++ == '\\\\')\n\t\t\t\tbreak;\t\t\n\t\t}\n\t\twhile (buffptr < buffend);\n\n\t\tif ( buffptr >= buffend - 6 ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// parse out ip\n\t\taddresses[numservers].ip[0] = *buffptr++;\n\t\taddresses[numservers].ip[1] = *buffptr++;\n\t\taddresses[numservers].ip[2] = *buffptr++;\n\t\taddresses[numservers].ip[3] = *buffptr++;\n\n\t\t// parse out port\n\t\taddresses[numservers].port = (*buffptr++)<<8;\n\t\taddresses[numservers].port += *buffptr++;\n\t\taddresses[numservers].port = BigShort( addresses[numservers].port );\n\n\t\t// syntax check\n\t\tif (*buffptr != '\\\\') {\n\t\t\tbreak;\n\t\t}\n\n\t\tCom_DPrintf( \"server: %d ip: %d.%d.%d.%d:%d\\n\",numservers,\n\t\t\t\taddresses[numservers].ip[0],\n\t\t\t\taddresses[numservers].ip[1],\n\t\t\t\taddresses[numservers].ip[2],\n\t\t\t\taddresses[numservers].ip[3],\n\t\t\t\taddresses[numservers].port );\n\n\t\tnumservers++;\n\t\tif (numservers >= MAX_SERVERSPERPACKET) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// parse out EOT\n\t\tif (buffptr[1] == 'E' && buffptr[2] == 'O' && buffptr[3] == 'T') {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (cls.masterNum == 0) {\n\t\tcount = cls.numglobalservers;\n\t\tmax = MAX_GLOBAL_SERVERS;\n\t} else {\n\t\tcount = cls.nummplayerservers;\n\t\tmax = MAX_OTHER_SERVERS;\n\t}\n\n\tfor (i = 0; i < numservers && count < max; i++) {\n\t\t// build net address\n\t\tserverInfo_t *server = (cls.masterNum == 0) ? &cls.globalServers[count] : &cls.mplayerServers[count];\n\n\t\tCL_InitServerInfo( server, &addresses[i] );\n\t\t// advance to next slot\n\t\tcount++;\n\t}\n\n\t// if getting the global list\n\tif (cls.masterNum == 0) {\n\t\tif ( cls.numGlobalServerAddresses < MAX_GLOBAL_SERVERS ) {\n\t\t\t// if we couldn't store the servers in the main list anymore\n\t\t\tfor (; i < numservers && count >= max; i++) {\n\t\t\t\tserverAddress_t *addr;\n\t\t\t\t// just store the addresses in an additional list\n\t\t\t\taddr = &cls.globalServerAddresses[cls.numGlobalServerAddresses++];\n\t\t\t\taddr->ip[0] = addresses[i].ip[0];\n\t\t\t\taddr->ip[1] = addresses[i].ip[1];\n\t\t\t\taddr->ip[2] = addresses[i].ip[2];\n\t\t\t\taddr->ip[3] = addresses[i].ip[3];\n\t\t\t\taddr->port  = addresses[i].port;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (cls.masterNum == 0) {\n\t\tcls.numglobalservers = count;\n\t\ttotal = count + cls.numGlobalServerAddresses;\n\t} else {\n\t\tcls.nummplayerservers = count;\n\t\ttotal = count;\n\t}\n\n\tCom_Printf(\"%d servers parsed (total %d)\\n\", numservers, total);\n}\n\n/*\n=================\nCL_ConnectionlessPacket\n\nResponses to broadcasts, etc\n=================\n*/\nvoid CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) {\n\tchar\t*s;\n\tchar\t*c;\n\n\tMSG_BeginReadingOOB( msg );\n\tMSG_ReadLong( msg );\t// skip the -1\n\n\ts = MSG_ReadStringLine( msg );\n\n\tCmd_TokenizeString( s );\n\n\tc = Cmd_Argv(0);\n\n\tCom_DPrintf (\"CL packet %s: %s\\n\", NET_AdrToString(from), c);\n\n\t// challenge from the server we are connecting to\n\tif ( !Q_stricmp(c, \"challengeResponse\") ) {\n\t\tif ( cls.state != CA_CONNECTING ) {\n\t\t\tCom_Printf( \"Unwanted challenge response received.  Ignored.\\n\" );\n\t\t} else {\n\t\t\t// start sending challenge repsonse instead of challenge request packets\n\t\t\tclc.challenge = atoi(Cmd_Argv(1));\n\t\t\tcls.state = CA_CHALLENGING;\n\t\t\tclc.connectPacketCount = 0;\n\t\t\tclc.connectTime = -99999;\n\n\t\t\t// take this address as the new server address.  This allows\n\t\t\t// a server proxy to hand off connections to multiple servers\n\t\t\tclc.serverAddress = from;\n\t\t\tCom_DPrintf (\"challengeResponse: %d\\n\", clc.challenge);\n\t\t}\n\t\treturn;\n\t}\n\n\t// server connection\n\tif ( !Q_stricmp(c, \"connectResponse\") ) {\n\t\tif ( cls.state >= CA_CONNECTED ) {\n\t\t\tCom_Printf (\"Dup connect received.  Ignored.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tif ( cls.state != CA_CHALLENGING ) {\n\t\t\tCom_Printf (\"connectResponse packet while not connecting.  Ignored.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tif ( !NET_CompareBaseAdr( from, clc.serverAddress ) ) {\n\t\t\tCom_Printf( \"connectResponse from a different address.  Ignored.\\n\" );\n\t\t\tCom_Printf( \"%s should have been %s\\n\", NET_AdrToString( from ), \n\t\t\t\tNET_AdrToString( clc.serverAddress ) );\n\t\t\treturn;\n\t\t}\n\t\tNetchan_Setup (NS_CLIENT, &clc.netchan, from, Cvar_VariableValue( \"net_qport\" ) );\n\t\tcls.state = CA_CONNECTED;\n\t\tclc.lastPacketSentTime = -9999;\t\t// send first packet immediately\n\t\treturn;\n\t}\n\n\t// server responding to an info broadcast\n\tif ( !Q_stricmp(c, \"infoResponse\") ) {\n\t\tCL_ServerInfoPacket( from, msg );\n\t\treturn;\n\t}\n\n\t// server responding to a get playerlist\n\tif ( !Q_stricmp(c, \"statusResponse\") ) {\n\t\tCL_ServerStatusResponse( from, msg );\n\t\treturn;\n\t}\n\n\t// a disconnect message from the server, which will happen if the server\n\t// dropped the connection but it is still getting packets from us\n\tif (!Q_stricmp(c, \"disconnect\")) {\n\t\tCL_DisconnectPacket( from );\n\t\treturn;\n\t}\n\n\t// echo request from server\n\tif ( !Q_stricmp(c, \"echo\") ) {\n\t\tNET_OutOfBandPrint( NS_CLIENT, from, \"%s\", Cmd_Argv(1) );\n\t\treturn;\n\t}\n\n\t// cd check\n\tif ( !Q_stricmp(c, \"keyAuthorize\") ) {\n\t\t// we don't use these now, so dump them on the floor\n\t\treturn;\n\t}\n\n\t// global MOTD from id\n\tif ( !Q_stricmp(c, \"motd\") ) {\n\t\tCL_MotdPacket( from );\n\t\treturn;\n\t}\n\n\t// echo request from server\n\tif ( !Q_stricmp(c, \"print\") ) {\n\t\ts = MSG_ReadString( msg );\n\t\tQ_strncpyz( clc.serverMessage, s, sizeof( clc.serverMessage ) );\n\t\tCom_Printf( \"%s\", s );\n\t\treturn;\n\t}\n\n\t// echo request from server\n\tif ( !Q_strncmp(c, \"getserversResponse\", 18) ) {\n\t\tCL_ServersResponsePacket( from, msg );\n\t\treturn;\n\t}\n\n\tCom_DPrintf (\"Unknown connectionless packet command.\\n\");\n}\n\n\n/*\n=================\nCL_PacketEvent\n\nA packet has arrived from the main event loop\n=================\n*/\nvoid CL_PacketEvent( netadr_t from, msg_t *msg ) {\n\tint\t\theaderBytes;\n\n\tclc.lastPacketTime = cls.realtime;\n\n\tif ( msg->cursize >= 4 && *(int *)msg->data == -1 ) {\n\t\tCL_ConnectionlessPacket( from, msg );\n\t\treturn;\n\t}\n\n\tif ( cls.state < CA_CONNECTED ) {\n\t\treturn;\t\t// can't be a valid sequenced packet\n\t}\n\n\tif ( msg->cursize < 4 ) {\n\t\tCom_Printf (\"%s: Runt packet\\n\",NET_AdrToString( from ));\n\t\treturn;\n\t}\n\n\t//\n\t// packet from server\n\t//\n\tif ( !NET_CompareAdr( from, clc.netchan.remoteAddress ) ) {\n\t\tCom_DPrintf (\"%s:sequenced packet without connection\\n\"\n\t\t\t,NET_AdrToString( from ) );\n\t\t// FIXME: send a client disconnect?\n\t\treturn;\n\t}\n\n\tif (!CL_Netchan_Process( &clc.netchan, msg) ) {\n\t\treturn;\t\t// out of order, duplicated, etc\n\t}\n\n\t// the header is different lengths for reliable and unreliable messages\n\theaderBytes = msg->readcount;\n\n\t// track the last message received so it can be returned in \n\t// client messages, allowing the server to detect a dropped\n\t// gamestate\n\tclc.serverMessageSequence = LittleLong( *(int *)msg->data );\n\n\tclc.lastPacketTime = cls.realtime;\n\tCL_ParseServerMessage( msg );\n\n\t//\n\t// we don't know if it is ok to save a demo message until\n\t// after we have parsed the frame\n\t//\n\tif ( clc.demorecording && !clc.demowaiting ) {\n\t\tCL_WriteDemoMessage( msg, headerBytes );\n\t}\n}\n\n/*\n==================\nCL_CheckTimeout\n\n==================\n*/\nvoid CL_CheckTimeout( void ) {\n\t//\n\t// check timeout\n\t//\n\tif ( ( !cl_paused->integer || !sv_paused->integer ) \n\t\t&& cls.state >= CA_CONNECTED && cls.state != CA_CINEMATIC\n\t    && cls.realtime - clc.lastPacketTime > cl_timeout->value*1000) {\n\t\tif (++cl.timeoutcount > 5) {\t// timeoutcount saves debugger\n\t\t\tCom_Printf (\"\\nServer connection timed out.\\n\");\n\t\t\tCL_Disconnect( qtrue );\n\t\t\treturn;\n\t\t}\n\t} else {\n\t\tcl.timeoutcount = 0;\n\t}\n}\n\n\n//============================================================================\n\n/*\n==================\nCL_CheckUserinfo\n\n==================\n*/\nvoid CL_CheckUserinfo( void ) {\n\t// don't add reliable commands when not yet connected\n\tif ( cls.state < CA_CHALLENGING ) {\n\t\treturn;\n\t}\n\t// don't overflow the reliable command buffer when paused\n\tif ( cl_paused->integer ) {\n\t\treturn;\n\t}\n\t// send a reliable userinfo update if needed\n\tif ( cvar_modifiedFlags & CVAR_USERINFO ) {\n\t\tcvar_modifiedFlags &= ~CVAR_USERINFO;\n\t\tCL_AddReliableCommand( va(\"userinfo \\\"%s\\\"\", Cvar_InfoString( CVAR_USERINFO ) ) );\n\t}\n\n}\n\n/*\n==================\nCL_Frame\n\n==================\n*/\nvoid CL_Frame ( int msec ) {\n\n\tif ( !com_cl_running->integer ) {\n\t\treturn;\n\t}\n\n\tif ( cls.cddialog ) {\n\t\t// bring up the cd error dialog if needed\n\t\tcls.cddialog = qfalse;\n\t\tVM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_NEED_CD );\n\t} else\tif ( cls.state == CA_DISCONNECTED && !( cls.keyCatchers & KEYCATCH_UI )\n\t\t&& !com_sv_running->integer ) {\n\t\t// if disconnected, bring up the menu\n\t\tS_StopAllSounds();\n\t\tVM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_MAIN );\n\t}\n\n\t// if recording an avi, lock to a fixed fps\n\tif ( cl_avidemo->integer && msec) {\n\t\t// save the current screen\n\t\tif ( cls.state == CA_ACTIVE || cl_forceavidemo->integer) {\n\t\t\tCbuf_ExecuteText( EXEC_NOW, \"screenshot silent\\n\" );\n\t\t}\n\t\t// fixed time for next frame'\n\t\tmsec = (1000 / cl_avidemo->integer) * com_timescale->value;\n\t\tif (msec == 0) {\n\t\t\tmsec = 1;\n\t\t}\n\t}\n\t\n\t// save the msec before checking pause\n\tcls.realFrametime = msec;\n\n\t// decide the simulation time\n\tcls.frametime = msec;\n\n\tcls.realtime += cls.frametime;\n\n\tif ( cl_timegraph->integer ) {\n\t\tSCR_DebugGraph ( cls.realFrametime * 0.25, 0 );\n\t}\n\n\t// see if we need to update any userinfo\n\tCL_CheckUserinfo();\n\n\t// if we haven't gotten a packet in a long time,\n\t// drop the connection\n\tCL_CheckTimeout();\n\n\t// send intentions now\n\tCL_SendCmd();\n\n\t// resend a connection request if necessary\n\tCL_CheckForResend();\n\n\t// decide on the serverTime to render\n\tCL_SetCGameTime();\n\n\t// update the screen\n\tSCR_UpdateScreen();\n\n\t// update audio\n\tS_Update();\n\n\t// advance local effects for next frame\n\tSCR_RunCinematic();\n\n\tCon_RunConsole();\n\n\tcls.framecount++;\n}\n\n\n//============================================================================\n\n/*\n================\nCL_RefPrintf\n\nDLL glue\n================\n*/\nvoid QDECL CL_RefPrintf( int print_level, const char *fmt, ...) {\n\tva_list\t\targptr;\n\tchar\t\tmsg[MAXPRINTMSG];\n\t\n\tva_start (argptr,fmt);\n\tQ_vsnprintf (msg, sizeof(msg), fmt, argptr);\n\tva_end (argptr);\n\n\tif ( print_level == PRINT_ALL ) {\n\t\tCom_Printf (\"%s\", msg);\n\t} else if ( print_level == PRINT_WARNING ) {\n\t\tCom_Printf (S_COLOR_YELLOW \"%s\", msg);\t\t// yellow\n\t} else if ( print_level == PRINT_DEVELOPER ) {\n\t\tCom_DPrintf (S_COLOR_RED \"%s\", msg);\t\t// red\n\t}\n}\n\n\n\n/*\n============\nCL_ShutdownRef\n============\n*/\nvoid CL_ShutdownRef( void ) {\n\tif ( !re.Shutdown ) {\n\t\treturn;\n\t}\n\tre.Shutdown( qtrue );\n\tCom_Memset( &re, 0, sizeof( re ) );\n}\n\n/*\n============\nCL_InitRenderer\n============\n*/\nvoid CL_InitRenderer( void ) {\n\t// this sets up the renderer and calls R_Init\n\tre.BeginRegistration( &cls.glconfig );\n\n\t// load character sets\n\tcls.charSetShader = re.RegisterShader( \"gfx/2d/bigchars\" );\n\tcls.whiteShader = re.RegisterShader( \"white\" );\n\tcls.consoleShader = re.RegisterShader( \"console\" );\n\tg_console_field_width = cls.glconfig.vidWidth / SMALLCHAR_WIDTH - 2;\n\tg_consoleField.widthInChars = g_console_field_width;\n}\n\n/*\n============================\nCL_StartHunkUsers\n\nAfter the server has cleared the hunk, these will need to be restarted\nThis is the only place that any of these functions are called from\n============================\n*/\nvoid CL_StartHunkUsers( void ) {\n\tif (!com_cl_running) {\n\t\treturn;\n\t}\n\n\tif ( !com_cl_running->integer ) {\n\t\treturn;\n\t}\n\n\tif ( !cls.rendererStarted ) {\n\t\tcls.rendererStarted = qtrue;\n\t\tCL_InitRenderer();\n\t}\n\n\tif ( !cls.soundStarted ) {\n\t\tcls.soundStarted = qtrue;\n\t\tS_Init();\n\t}\n\n\tif ( !cls.soundRegistered ) {\n\t\tcls.soundRegistered = qtrue;\n\t\tS_BeginRegistration();\n\t}\n\n\tif ( !cls.uiStarted ) {\n\t\tcls.uiStarted = qtrue;\n\t\tCL_InitUI();\n\t}\n}\n\n/*\n============\nCL_RefMalloc\n============\n*/\nvoid *CL_RefMalloc( int size ) {\n\treturn Z_TagMalloc( size, TAG_RENDERER );\n}\n\nint CL_ScaledMilliseconds(void) {\n\treturn Sys_Milliseconds()*com_timescale->value;\n}\n\n/*\n============\nCL_InitRef\n============\n*/\nvoid CL_InitRef( void ) {\n\trefimport_t\tri;\n\trefexport_t\t*ret;\n\n\tCom_Printf( \"----- Initializing Renderer ----\\n\" );\n\n\tri.Cmd_AddCommand = Cmd_AddCommand;\n\tri.Cmd_RemoveCommand = Cmd_RemoveCommand;\n\tri.Cmd_Argc = Cmd_Argc;\n\tri.Cmd_Argv = Cmd_Argv;\n\tri.Cmd_ExecuteText = Cbuf_ExecuteText;\n\tri.Printf = CL_RefPrintf;\n\tri.Error = Com_Error;\n\tri.Milliseconds = CL_ScaledMilliseconds;\n\tri.Malloc = CL_RefMalloc;\n\tri.Free = Z_Free;\n#ifdef HUNK_DEBUG\n\tri.Hunk_AllocDebug = Hunk_AllocDebug;\n#else\n\tri.Hunk_Alloc = Hunk_Alloc;\n#endif\n\tri.Hunk_AllocateTempMemory = Hunk_AllocateTempMemory;\n\tri.Hunk_FreeTempMemory = Hunk_FreeTempMemory;\n\tri.CM_DrawDebugSurface = CM_DrawDebugSurface;\n\tri.FS_ReadFile = FS_ReadFile;\n\tri.FS_FreeFile = FS_FreeFile;\n\tri.FS_WriteFile = FS_WriteFile;\n\tri.FS_FreeFileList = FS_FreeFileList;\n\tri.FS_ListFiles = FS_ListFiles;\n\tri.FS_FileIsInPAK = FS_FileIsInPAK;\n\tri.FS_FileExists = FS_FileExists;\n\tri.Cvar_Get = Cvar_Get;\n\tri.Cvar_Set = Cvar_Set;\n\n\t// cinematic stuff\n\n\tri.CIN_UploadCinematic = CIN_UploadCinematic;\n\tri.CIN_PlayCinematic = CIN_PlayCinematic;\n\tri.CIN_RunCinematic = CIN_RunCinematic;\n\n\tret = GetRefAPI( REF_API_VERSION, &ri );\n\n#if defined __USEA3D && defined __A3D_GEOM\n\thA3Dg_ExportRenderGeom (ret);\n#endif\n\n\tCom_Printf( \"-------------------------------\\n\");\n\n\tif ( !ret ) {\n\t\tCom_Error (ERR_FATAL, \"Couldn't initialize refresh\" );\n\t}\n\n\tre = *ret;\n\n\t// unpause so the cgame definately gets a snapshot and renders a frame\n\tCvar_Set( \"cl_paused\", \"0\" );\n}\n\n\n//===========================================================================================\n\n\nvoid CL_SetModel_f( void ) {\n\tchar\t*arg;\n\tchar\tname[256];\n\n\targ = Cmd_Argv( 1 );\n\tif (arg[0]) {\n\t\tCvar_Set( \"model\", arg );\n\t\tCvar_Set( \"headmodel\", arg );\n\t} else {\n\t\tCvar_VariableStringBuffer( \"model\", name, sizeof(name) );\n\t\tCom_Printf(\"model is set to %s\\n\", name);\n\t}\n}\n\n/*\n====================\nCL_Init\n====================\n*/\nvoid CL_Init( void ) {\n\tCom_Printf( \"----- Client Initialization -----\\n\" );\n\n\tCon_Init ();\t\n\n\tCL_ClearState ();\n\n\tcls.state = CA_DISCONNECTED;\t// no longer CA_UNINITIALIZED\n\n\tcls.realtime = 0;\n\n\tCL_InitInput ();\n\n\t//\n\t// register our variables\n\t//\n\tcl_noprint = Cvar_Get( \"cl_noprint\", \"0\", 0 );\n\tcl_motd = Cvar_Get (\"cl_motd\", \"1\", 0);\n\n\tcl_timeout = Cvar_Get (\"cl_timeout\", \"200\", 0);\n\n\tcl_timeNudge = Cvar_Get (\"cl_timeNudge\", \"0\", CVAR_TEMP );\n\tcl_shownet = Cvar_Get (\"cl_shownet\", \"0\", CVAR_TEMP );\n\tcl_showSend = Cvar_Get (\"cl_showSend\", \"0\", CVAR_TEMP );\n\tcl_showTimeDelta = Cvar_Get (\"cl_showTimeDelta\", \"0\", CVAR_TEMP );\n\tcl_freezeDemo = Cvar_Get (\"cl_freezeDemo\", \"0\", CVAR_TEMP );\n\trcon_client_password = Cvar_Get (\"rconPassword\", \"\", CVAR_TEMP );\n\tcl_activeAction = Cvar_Get( \"activeAction\", \"\", CVAR_TEMP );\n\n\tcl_timedemo = Cvar_Get (\"timedemo\", \"0\", 0);\n\tcl_avidemo = Cvar_Get (\"cl_avidemo\", \"0\", 0);\n\tcl_forceavidemo = Cvar_Get (\"cl_forceavidemo\", \"0\", 0);\n\n\trconAddress = Cvar_Get (\"rconAddress\", \"\", 0);\n\n\tcl_yawspeed = Cvar_Get (\"cl_yawspeed\", \"140\", CVAR_ARCHIVE);\n\tcl_pitchspeed = Cvar_Get (\"cl_pitchspeed\", \"140\", CVAR_ARCHIVE);\n\tcl_anglespeedkey = Cvar_Get (\"cl_anglespeedkey\", \"1.5\", 0);\n\n\tcl_maxpackets = Cvar_Get (\"cl_maxpackets\", \"30\", CVAR_ARCHIVE );\n\tcl_packetdup = Cvar_Get (\"cl_packetdup\", \"1\", CVAR_ARCHIVE );\n\n\tcl_run = Cvar_Get (\"cl_run\", \"1\", CVAR_ARCHIVE);\n\tcl_sensitivity = Cvar_Get (\"sensitivity\", \"5\", CVAR_ARCHIVE);\n\tcl_mouseAccel = Cvar_Get (\"cl_mouseAccel\", \"0\", CVAR_ARCHIVE);\n\tcl_freelook = Cvar_Get( \"cl_freelook\", \"1\", CVAR_ARCHIVE );\n\n\tcl_showMouseRate = Cvar_Get (\"cl_showmouserate\", \"0\", 0);\n\n\tcl_allowDownload = Cvar_Get (\"cl_allowDownload\", \"0\", CVAR_ARCHIVE);\n\n\tcl_conXOffset = Cvar_Get (\"cl_conXOffset\", \"0\", 0);\n#ifdef MACOS_X\n        // In game video is REALLY slow in Mac OS X right now due to driver slowness\n\tcl_inGameVideo = Cvar_Get (\"r_inGameVideo\", \"0\", CVAR_ARCHIVE);\n#else\n\tcl_inGameVideo = Cvar_Get (\"r_inGameVideo\", \"1\", CVAR_ARCHIVE);\n#endif\n\n\tcl_serverStatusResendTime = Cvar_Get (\"cl_serverStatusResendTime\", \"750\", 0);\n\n\t// init autoswitch so the ui will have it correctly even\n\t// if the cgame hasn't been started\n\tCvar_Get (\"cg_autoswitch\", \"1\", CVAR_ARCHIVE);\n\n\tm_pitch = Cvar_Get (\"m_pitch\", \"0.022\", CVAR_ARCHIVE);\n\tm_yaw = Cvar_Get (\"m_yaw\", \"0.022\", CVAR_ARCHIVE);\n\tm_forward = Cvar_Get (\"m_forward\", \"0.25\", CVAR_ARCHIVE);\n\tm_side = Cvar_Get (\"m_side\", \"0.25\", CVAR_ARCHIVE);\n#ifdef MACOS_X\n        // Input is jittery on OS X w/o this\n\tm_filter = Cvar_Get (\"m_filter\", \"1\", CVAR_ARCHIVE);\n#else\n\tm_filter = Cvar_Get (\"m_filter\", \"0\", CVAR_ARCHIVE);\n#endif\n\n\tcl_motdString = Cvar_Get( \"cl_motdString\", \"\", CVAR_ROM );\n\n\tCvar_Get( \"cl_maxPing\", \"800\", CVAR_ARCHIVE );\n\n\n\t// userinfo\n\tCvar_Get (\"name\", \"UnnamedPlayer\", CVAR_USERINFO | CVAR_ARCHIVE );\n\tCvar_Get (\"rate\", \"3000\", CVAR_USERINFO | CVAR_ARCHIVE );\n\tCvar_Get (\"snaps\", \"20\", CVAR_USERINFO | CVAR_ARCHIVE );\n\tCvar_Get (\"model\", \"sarge\", CVAR_USERINFO | CVAR_ARCHIVE );\n\tCvar_Get (\"headmodel\", \"sarge\", CVAR_USERINFO | CVAR_ARCHIVE );\n\tCvar_Get (\"team_model\", \"james\", CVAR_USERINFO | CVAR_ARCHIVE );\n\tCvar_Get (\"team_headmodel\", \"*james\", CVAR_USERINFO | CVAR_ARCHIVE );\n\tCvar_Get (\"g_redTeam\", \"Stroggs\", CVAR_SERVERINFO | CVAR_ARCHIVE);\n\tCvar_Get (\"g_blueTeam\", \"Pagans\", CVAR_SERVERINFO | CVAR_ARCHIVE);\n\tCvar_Get (\"color1\",  \"4\", CVAR_USERINFO | CVAR_ARCHIVE );\n\tCvar_Get (\"color2\", \"5\", CVAR_USERINFO | CVAR_ARCHIVE );\n\tCvar_Get (\"handicap\", \"100\", CVAR_USERINFO | CVAR_ARCHIVE );\n\tCvar_Get (\"teamtask\", \"0\", CVAR_USERINFO );\n\tCvar_Get (\"sex\", \"male\", CVAR_USERINFO | CVAR_ARCHIVE );\n\tCvar_Get (\"cl_anonymous\", \"0\", CVAR_USERINFO | CVAR_ARCHIVE );\n\n\tCvar_Get (\"password\", \"\", CVAR_USERINFO);\n\tCvar_Get (\"cg_predictItems\", \"1\", CVAR_USERINFO | CVAR_ARCHIVE );\n\n\n\t// cgame might not be initialized before menu is used\n\tCvar_Get (\"cg_viewsize\", \"100\", CVAR_ARCHIVE );\n\n\t//\n\t// register our commands\n\t//\n\tCmd_AddCommand (\"cmd\", CL_ForwardToServer_f);\n\tCmd_AddCommand (\"configstrings\", CL_Configstrings_f);\n\tCmd_AddCommand (\"clientinfo\", CL_Clientinfo_f);\n\tCmd_AddCommand (\"snd_restart\", CL_Snd_Restart_f);\n\tCmd_AddCommand (\"vid_restart\", CL_Vid_Restart_f);\n\tCmd_AddCommand (\"disconnect\", CL_Disconnect_f);\n\tCmd_AddCommand (\"record\", CL_Record_f);\n\tCmd_AddCommand (\"demo\", CL_PlayDemo_f);\n\tCmd_AddCommand (\"cinematic\", CL_PlayCinematic_f);\n\tCmd_AddCommand (\"stoprecord\", CL_StopRecord_f);\n\tCmd_AddCommand (\"connect\", CL_Connect_f);\n\tCmd_AddCommand (\"reconnect\", CL_Reconnect_f);\n\tCmd_AddCommand (\"localservers\", CL_LocalServers_f);\n\tCmd_AddCommand (\"globalservers\", CL_GlobalServers_f);\n\tCmd_AddCommand (\"rcon\", CL_Rcon_f);\n\tCmd_AddCommand (\"setenv\", CL_Setenv_f );\n\tCmd_AddCommand (\"ping\", CL_Ping_f );\n\tCmd_AddCommand (\"serverstatus\", CL_ServerStatus_f );\n\tCmd_AddCommand (\"showip\", CL_ShowIP_f );\n\tCmd_AddCommand (\"fs_openedList\", CL_OpenedPK3List_f );\n\tCmd_AddCommand (\"fs_referencedList\", CL_ReferencedPK3List_f );\n\tCmd_AddCommand (\"model\", CL_SetModel_f );\n\tCL_InitRef();\n\n\tSCR_Init ();\n\n\tCbuf_Execute ();\n\n\tCvar_Set( \"cl_running\", \"1\" );\n\n\tCom_Printf( \"----- Client Initialization Complete -----\\n\" );\n}\n\n\n/*\n===============\nCL_Shutdown\n\n===============\n*/\nvoid CL_Shutdown( void ) {\n\tstatic qboolean recursive = qfalse;\n\t\n\tCom_Printf( \"----- CL_Shutdown -----\\n\" );\n\n\tif ( recursive ) {\n\t\tprintf (\"recursive shutdown\\n\");\n\t\treturn;\n\t}\n\trecursive = qtrue;\n\n\tCL_Disconnect( qtrue );\n\n\tS_Shutdown();\n\tCL_ShutdownRef();\n\t\n\tCL_ShutdownUI();\n\n\tCmd_RemoveCommand (\"cmd\");\n\tCmd_RemoveCommand (\"configstrings\");\n\tCmd_RemoveCommand (\"userinfo\");\n\tCmd_RemoveCommand (\"snd_restart\");\n\tCmd_RemoveCommand (\"vid_restart\");\n\tCmd_RemoveCommand (\"disconnect\");\n\tCmd_RemoveCommand (\"record\");\n\tCmd_RemoveCommand (\"demo\");\n\tCmd_RemoveCommand (\"cinematic\");\n\tCmd_RemoveCommand (\"stoprecord\");\n\tCmd_RemoveCommand (\"connect\");\n\tCmd_RemoveCommand (\"localservers\");\n\tCmd_RemoveCommand (\"globalservers\");\n\tCmd_RemoveCommand (\"rcon\");\n\tCmd_RemoveCommand (\"setenv\");\n\tCmd_RemoveCommand (\"ping\");\n\tCmd_RemoveCommand (\"serverstatus\");\n\tCmd_RemoveCommand (\"showip\");\n\tCmd_RemoveCommand (\"model\");\n\n\tCvar_Set( \"cl_running\", \"0\" );\n\n\trecursive = qfalse;\n\n\tCom_Memset( &cls, 0, sizeof( cls ) );\n\n\tCom_Printf( \"-----------------------\\n\" );\n\n}\n\nstatic void CL_SetServerInfo(serverInfo_t *server, const char *info, int ping) {\n\tif (server) {\n\t\tif (info) {\n\t\t\tserver->clients = atoi(Info_ValueForKey(info, \"clients\"));\n\t\t\tQ_strncpyz(server->hostName,Info_ValueForKey(info, \"hostname\"), MAX_NAME_LENGTH);\n\t\t\tQ_strncpyz(server->mapName, Info_ValueForKey(info, \"mapname\"), MAX_NAME_LENGTH);\n\t\t\tserver->maxClients = atoi(Info_ValueForKey(info, \"sv_maxclients\"));\n\t\t\tQ_strncpyz(server->game,Info_ValueForKey(info, \"game\"), MAX_NAME_LENGTH);\n\t\t\tserver->gameType = atoi(Info_ValueForKey(info, \"gametype\"));\n\t\t\tserver->netType = atoi(Info_ValueForKey(info, \"nettype\"));\n\t\t\tserver->minPing = atoi(Info_ValueForKey(info, \"minping\"));\n\t\t\tserver->maxPing = atoi(Info_ValueForKey(info, \"maxping\"));\n\t\t\tserver->punkbuster = atoi(Info_ValueForKey(info, \"punkbuster\"));\n\t\t}\n\t\tserver->ping = ping;\n\t}\n}\n\nstatic void CL_SetServerInfoByAddress(netadr_t from, const char *info, int ping) {\n\tint i;\n\n\tfor (i = 0; i < MAX_OTHER_SERVERS; i++) {\n\t\tif (NET_CompareAdr(from, cls.localServers[i].adr)) {\n\t\t\tCL_SetServerInfo(&cls.localServers[i], info, ping);\n\t\t}\n\t}\n\n\tfor (i = 0; i < MAX_OTHER_SERVERS; i++) {\n\t\tif (NET_CompareAdr(from, cls.mplayerServers[i].adr)) {\n\t\t\tCL_SetServerInfo(&cls.mplayerServers[i], info, ping);\n\t\t}\n\t}\n\n\tfor (i = 0; i < MAX_GLOBAL_SERVERS; i++) {\n\t\tif (NET_CompareAdr(from, cls.globalServers[i].adr)) {\n\t\t\tCL_SetServerInfo(&cls.globalServers[i], info, ping);\n\t\t}\n\t}\n\n\tfor (i = 0; i < MAX_OTHER_SERVERS; i++) {\n\t\tif (NET_CompareAdr(from, cls.favoriteServers[i].adr)) {\n\t\t\tCL_SetServerInfo(&cls.favoriteServers[i], info, ping);\n\t\t}\n\t}\n\n}\n\n/*\n===================\nCL_ServerInfoPacket\n===================\n*/\nvoid CL_ServerInfoPacket( netadr_t from, msg_t *msg ) {\n\tint\t\ti, type;\n\tchar\tinfo[MAX_INFO_STRING];\n\tchar*\tstr;\n\tchar\t*infoString;\n\tint\t\tprot;\n\n\tinfoString = MSG_ReadString( msg );\n\n\t// if this isn't the correct protocol version, ignore it\n\tprot = atoi( Info_ValueForKey( infoString, \"protocol\" ) );\n\tif ( prot != PROTOCOL_VERSION ) {\n\t\tCom_DPrintf( \"Different protocol info packet: %s\\n\", infoString );\n\t\treturn;\n\t}\n\n\t// iterate servers waiting for ping response\n\tfor (i=0; i<MAX_PINGREQUESTS; i++)\n\t{\n\t\tif ( cl_pinglist[i].adr.port && !cl_pinglist[i].time && NET_CompareAdr( from, cl_pinglist[i].adr ) )\n\t\t{\n\t\t\t// calc ping time\n\t\t\tcl_pinglist[i].time = cls.realtime - cl_pinglist[i].start + 1;\n\t\t\tCom_DPrintf( \"ping time %dms from %s\\n\", cl_pinglist[i].time, NET_AdrToString( from ) );\n\n\t\t\t// save of info\n\t\t\tQ_strncpyz( cl_pinglist[i].info, infoString, sizeof( cl_pinglist[i].info ) );\n\n\t\t\t// tack on the net type\n\t\t\t// NOTE: make sure these types are in sync with the netnames strings in the UI\n\t\t\tswitch (from.type)\n\t\t\t{\n\t\t\t\tcase NA_BROADCAST:\n\t\t\t\tcase NA_IP:\n\t\t\t\t\tstr = \"udp\";\n\t\t\t\t\ttype = 1;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase NA_IPX:\n\t\t\t\tcase NA_BROADCAST_IPX:\n\t\t\t\t\tstr = \"ipx\";\n\t\t\t\t\ttype = 2;\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tstr = \"???\";\n\t\t\t\t\ttype = 0;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tInfo_SetValueForKey( cl_pinglist[i].info, \"nettype\", va(\"%d\", type) );\n\t\t\tCL_SetServerInfoByAddress(from, infoString, cl_pinglist[i].time);\n\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// if not just sent a local broadcast or pinging local servers\n\tif (cls.pingUpdateSource != AS_LOCAL) {\n\t\treturn;\n\t}\n\n\tfor ( i = 0 ; i < MAX_OTHER_SERVERS ; i++ ) {\n\t\t// empty slot\n\t\tif ( cls.localServers[i].adr.port == 0 ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// avoid duplicate\n\t\tif ( NET_CompareAdr( from, cls.localServers[i].adr ) ) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif ( i == MAX_OTHER_SERVERS ) {\n\t\tCom_DPrintf( \"MAX_OTHER_SERVERS hit, dropping infoResponse\\n\" );\n\t\treturn;\n\t}\n\n\t// add this to the list\n\tcls.numlocalservers = i+1;\n\tcls.localServers[i].adr = from;\n\tcls.localServers[i].clients = 0;\n\tcls.localServers[i].hostName[0] = '\\0';\n\tcls.localServers[i].mapName[0] = '\\0';\n\tcls.localServers[i].maxClients = 0;\n\tcls.localServers[i].maxPing = 0;\n\tcls.localServers[i].minPing = 0;\n\tcls.localServers[i].ping = -1;\n\tcls.localServers[i].game[0] = '\\0';\n\tcls.localServers[i].gameType = 0;\n\tcls.localServers[i].netType = from.type;\n\tcls.localServers[i].punkbuster = 0;\n\t\t\t\t\t\t\t\t\t \n\tQ_strncpyz( info, MSG_ReadString( msg ), MAX_INFO_STRING );\n\tif (strlen(info)) {\n\t\tif (info[strlen(info)-1] != '\\n') {\n\t\t\tstrncat(info, \"\\n\", sizeof(info));\n\t\t}\n\t\tCom_Printf( \"%s: %s\", NET_AdrToString( from ), info );\n\t}\n}\n\n/*\n===================\nCL_GetServerStatus\n===================\n*/\nserverStatus_t *CL_GetServerStatus( netadr_t from ) {\n\tserverStatus_t *serverStatus;\n\tint i, oldest, oldestTime;\n\n\tserverStatus = NULL;\n\tfor (i = 0; i < MAX_SERVERSTATUSREQUESTS; i++) {\n\t\tif ( NET_CompareAdr( from, cl_serverStatusList[i].address ) ) {\n\t\t\treturn &cl_serverStatusList[i];\n\t\t}\n\t}\n\tfor (i = 0; i < MAX_SERVERSTATUSREQUESTS; i++) {\n\t\tif ( cl_serverStatusList[i].retrieved ) {\n\t\t\treturn &cl_serverStatusList[i];\n\t\t}\n\t}\n\toldest = -1;\n\toldestTime = 0;\n\tfor (i = 0; i < MAX_SERVERSTATUSREQUESTS; i++) {\n\t\tif (oldest == -1 || cl_serverStatusList[i].startTime < oldestTime) {\n\t\t\toldest = i;\n\t\t\toldestTime = cl_serverStatusList[i].startTime;\n\t\t}\n\t}\n\tif (oldest != -1) {\n\t\treturn &cl_serverStatusList[oldest];\n\t}\n\tserverStatusCount++;\n\treturn &cl_serverStatusList[serverStatusCount & (MAX_SERVERSTATUSREQUESTS-1)];\n}\n\n/*\n===================\nCL_ServerStatus\n===================\n*/\nint CL_ServerStatus( char *serverAddress, char *serverStatusString, int maxLen ) {\n\tint i;\n\tnetadr_t\tto;\n\tserverStatus_t *serverStatus;\n\n\t// if no server address then reset all server status requests\n\tif ( !serverAddress ) {\n\t\tfor (i = 0; i < MAX_SERVERSTATUSREQUESTS; i++) {\n\t\t\tcl_serverStatusList[i].address.port = 0;\n\t\t\tcl_serverStatusList[i].retrieved = qtrue;\n\t\t}\n\t\treturn qfalse;\n\t}\n\t// get the address\n\tif ( !NET_StringToAdr( serverAddress, &to ) ) {\n\t\treturn qfalse;\n\t}\n\tserverStatus = CL_GetServerStatus( to );\n\t// if no server status string then reset the server status request for this address\n\tif ( !serverStatusString ) {\n\t\tserverStatus->retrieved = qtrue;\n\t\treturn qfalse;\n\t}\n\n\t// if this server status request has the same address\n\tif ( NET_CompareAdr( to, serverStatus->address) ) {\n\t\t// if we recieved an response for this server status request\n\t\tif (!serverStatus->pending) {\n\t\t\tQ_strncpyz(serverStatusString, serverStatus->string, maxLen);\n\t\t\tserverStatus->retrieved = qtrue;\n\t\t\tserverStatus->startTime = 0;\n\t\t\treturn qtrue;\n\t\t}\n\t\t// resend the request regularly\n\t\telse if ( serverStatus->startTime < Com_Milliseconds() - cl_serverStatusResendTime->integer ) {\n\t\t\tserverStatus->print = qfalse;\n\t\t\tserverStatus->pending = qtrue;\n\t\t\tserverStatus->retrieved = qfalse;\n\t\t\tserverStatus->time = 0;\n\t\t\tserverStatus->startTime = Com_Milliseconds();\n\t\t\tNET_OutOfBandPrint( NS_CLIENT, to, \"getstatus\" );\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\t// if retrieved\n\telse if ( serverStatus->retrieved ) {\n\t\tserverStatus->address = to;\n\t\tserverStatus->print = qfalse;\n\t\tserverStatus->pending = qtrue;\n\t\tserverStatus->retrieved = qfalse;\n\t\tserverStatus->startTime = Com_Milliseconds();\n\t\tserverStatus->time = 0;\n\t\tNET_OutOfBandPrint( NS_CLIENT, to, \"getstatus\" );\n\t\treturn qfalse;\n\t}\n\treturn qfalse;\n}\n\n/*\n===================\nCL_ServerStatusResponse\n===================\n*/\nvoid CL_ServerStatusResponse( netadr_t from, msg_t *msg ) {\n\tchar\t*s;\n\tchar\tinfo[MAX_INFO_STRING];\n\tint\t\ti, l, score, ping;\n\tint\t\tlen;\n\tserverStatus_t *serverStatus;\n\n\tserverStatus = NULL;\n\tfor (i = 0; i < MAX_SERVERSTATUSREQUESTS; i++) {\n\t\tif ( NET_CompareAdr( from, cl_serverStatusList[i].address ) ) {\n\t\t\tserverStatus = &cl_serverStatusList[i];\n\t\t\tbreak;\n\t\t}\n\t}\n\t// if we didn't request this server status\n\tif (!serverStatus) {\n\t\treturn;\n\t}\n\n\ts = MSG_ReadStringLine( msg );\n\n\tlen = 0;\n\tCom_sprintf(&serverStatus->string[len], sizeof(serverStatus->string)-len, \"%s\", s);\n\n\tif (serverStatus->print) {\n\t\tCom_Printf(\"Server settings:\\n\");\n\t\t// print cvars\n\t\twhile (*s) {\n\t\t\tfor (i = 0; i < 2 && *s; i++) {\n\t\t\t\tif (*s == '\\\\')\n\t\t\t\t\ts++;\n\t\t\t\tl = 0;\n\t\t\t\twhile (*s) {\n\t\t\t\t\tinfo[l++] = *s;\n\t\t\t\t\tif (l >= MAX_INFO_STRING-1)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\ts++;\n\t\t\t\t\tif (*s == '\\\\') {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tinfo[l] = '\\0';\n\t\t\t\tif (i) {\n\t\t\t\t\tCom_Printf(\"%s\\n\", info);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tCom_Printf(\"%-24s\", info);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tlen = strlen(serverStatus->string);\n\tCom_sprintf(&serverStatus->string[len], sizeof(serverStatus->string)-len, \"\\\\\");\n\n\tif (serverStatus->print) {\n\t\tCom_Printf(\"\\nPlayers:\\n\");\n\t\tCom_Printf(\"num: score: ping: name:\\n\");\n\t}\n\tfor (i = 0, s = MSG_ReadStringLine( msg ); *s; s = MSG_ReadStringLine( msg ), i++) {\n\n\t\tlen = strlen(serverStatus->string);\n\t\tCom_sprintf(&serverStatus->string[len], sizeof(serverStatus->string)-len, \"\\\\%s\", s);\n\n\t\tif (serverStatus->print) {\n\t\t\tscore = ping = 0;\n\t\t\tsscanf(s, \"%d %d\", &score, &ping);\n\t\t\ts = strchr(s, ' ');\n\t\t\tif (s)\n\t\t\t\ts = strchr(s+1, ' ');\n\t\t\tif (s)\n\t\t\t\ts++;\n\t\t\telse\n\t\t\t\ts = \"unknown\";\n\t\t\tCom_Printf(\"%-2d   %-3d    %-3d   %s\\n\", i, score, ping, s );\n\t\t}\n\t}\n\tlen = strlen(serverStatus->string);\n\tCom_sprintf(&serverStatus->string[len], sizeof(serverStatus->string)-len, \"\\\\\");\n\n\tserverStatus->time = Com_Milliseconds();\n\tserverStatus->address = from;\n\tserverStatus->pending = qfalse;\n\tif (serverStatus->print) {\n\t\tserverStatus->retrieved = qtrue;\n\t}\n}\n\n/*\n==================\nCL_LocalServers_f\n==================\n*/\nvoid CL_LocalServers_f( void ) {\n\tchar\t\t*message;\n\tint\t\t\ti, j;\n\tnetadr_t\tto;\n\n\tCom_Printf( \"Scanning for servers on the local network...\\n\");\n\n\t// reset the list, waiting for response\n\tcls.numlocalservers = 0;\n\tcls.pingUpdateSource = AS_LOCAL;\n\n\tfor (i = 0; i < MAX_OTHER_SERVERS; i++) {\n\t\tqboolean b = cls.localServers[i].visible;\n\t\tCom_Memset(&cls.localServers[i], 0, sizeof(cls.localServers[i]));\n\t\tcls.localServers[i].visible = b;\n\t}\n\tCom_Memset( &to, 0, sizeof( to ) );\n\n\t// The 'xxx' in the message is a challenge that will be echoed back\n\t// by the server.  We don't care about that here, but master servers\n\t// can use that to prevent spoofed server responses from invalid ip\n\tmessage = \"\\377\\377\\377\\377getinfo xxx\";\n\n\t// send each message twice in case one is dropped\n\tfor ( i = 0 ; i < 2 ; i++ ) {\n\t\t// send a broadcast packet on each server port\n\t\t// we support multiple server ports so a single machine\n\t\t// can nicely run multiple servers\n\t\tfor ( j = 0 ; j < NUM_SERVER_PORTS ; j++ ) {\n\t\t\tto.port = BigShort( (short)(PORT_SERVER + j) );\n\n\t\t\tto.type = NA_BROADCAST;\n\t\t\tNET_SendPacket( NS_CLIENT, strlen( message ), message, to );\n\n\t\t\tto.type = NA_BROADCAST_IPX;\n\t\t\tNET_SendPacket( NS_CLIENT, strlen( message ), message, to );\n\t\t}\n\t}\n}\n\n/*\n==================\nCL_GlobalServers_f\n==================\n*/\nvoid CL_GlobalServers_f( void ) {\n\tnetadr_t\tto;\n\tint\t\t\ti;\n\tint\t\t\tcount;\n\tchar\t\t*buffptr;\n\tchar\t\tcommand[1024];\n\t\n\tif ( Cmd_Argc() < 3) {\n\t\tCom_Printf( \"usage: globalservers <master# 0-1> <protocol> [keywords]\\n\");\n\t\treturn;\t\n\t}\n\n\tcls.masterNum = atoi( Cmd_Argv(1) );\n\n\tCom_Printf( \"Requesting servers from the master...\\n\");\n\n\t// reset the list, waiting for response\n\t// -1 is used to distinguish a \"no response\"\n\n\tif( cls.masterNum == 1 ) {\n\t\tNET_StringToAdr( MASTER_SERVER_NAME, &to );\n\t\tcls.nummplayerservers = -1;\n\t\tcls.pingUpdateSource = AS_MPLAYER;\n\t}\n\telse {\n\t\tNET_StringToAdr( MASTER_SERVER_NAME, &to );\n\t\tcls.numglobalservers = -1;\n\t\tcls.pingUpdateSource = AS_GLOBAL;\n\t}\n\tto.type = NA_IP;\n\tto.port = BigShort(PORT_MASTER);\n\n\tsprintf( command, \"getservers %s\", Cmd_Argv(2) );\n\n\t// tack on keywords\n\tbuffptr = command + strlen( command );\n\tcount   = Cmd_Argc();\n\tfor (i=3; i<count; i++)\n\t\tbuffptr += sprintf( buffptr, \" %s\", Cmd_Argv(i) );\n\n\t// if we are a demo, automatically add a \"demo\" keyword\n\tif ( Cvar_VariableValue( \"fs_restrict\" ) ) {\n\t\tbuffptr += sprintf( buffptr, \" demo\" );\n\t}\n\n\tNET_OutOfBandPrint( NS_SERVER, to, command );\n}\n\n\n/*\n==================\nCL_GetPing\n==================\n*/\nvoid CL_GetPing( int n, char *buf, int buflen, int *pingtime )\n{\n\tconst char\t*str;\n\tint\t\ttime;\n\tint\t\tmaxPing;\n\n\tif (!cl_pinglist[n].adr.port)\n\t{\n\t\t// empty slot\n\t\tbuf[0]    = '\\0';\n\t\t*pingtime = 0;\n\t\treturn;\n\t}\n\n\tstr = NET_AdrToString( cl_pinglist[n].adr );\n\tQ_strncpyz( buf, str, buflen );\n\n\ttime = cl_pinglist[n].time;\n\tif (!time)\n\t{\n\t\t// check for timeout\n\t\ttime = cls.realtime - cl_pinglist[n].start;\n\t\tmaxPing = Cvar_VariableIntegerValue( \"cl_maxPing\" );\n\t\tif( maxPing < 100 ) {\n\t\t\tmaxPing = 100;\n\t\t}\n\t\tif (time < maxPing)\n\t\t{\n\t\t\t// not timed out yet\n\t\t\ttime = 0;\n\t\t}\n\t}\n\n\tCL_SetServerInfoByAddress(cl_pinglist[n].adr, cl_pinglist[n].info, cl_pinglist[n].time);\n\n\t*pingtime = time;\n}\n\n/*\n==================\nCL_UpdateServerInfo\n==================\n*/\nvoid CL_UpdateServerInfo( int n )\n{\n\tif (!cl_pinglist[n].adr.port)\n\t{\n\t\treturn;\n\t}\n\n\tCL_SetServerInfoByAddress(cl_pinglist[n].adr, cl_pinglist[n].info, cl_pinglist[n].time );\n}\n\n/*\n==================\nCL_GetPingInfo\n==================\n*/\nvoid CL_GetPingInfo( int n, char *buf, int buflen )\n{\n\tif (!cl_pinglist[n].adr.port)\n\t{\n\t\t// empty slot\n\t\tif (buflen)\n\t\t\tbuf[0] = '\\0';\n\t\treturn;\n\t}\n\n\tQ_strncpyz( buf, cl_pinglist[n].info, buflen );\n}\n\n/*\n==================\nCL_ClearPing\n==================\n*/\nvoid CL_ClearPing( int n )\n{\n\tif (n < 0 || n >= MAX_PINGREQUESTS)\n\t\treturn;\n\n\tcl_pinglist[n].adr.port = 0;\n}\n\n/*\n==================\nCL_GetPingQueueCount\n==================\n*/\nint CL_GetPingQueueCount( void )\n{\n\tint\t\ti;\n\tint\t\tcount;\n\tping_t*\tpingptr;\n\n\tcount   = 0;\n\tpingptr = cl_pinglist;\n\n\tfor (i=0; i<MAX_PINGREQUESTS; i++, pingptr++ ) {\n\t\tif (pingptr->adr.port) {\n\t\t\tcount++;\n\t\t}\n\t}\n\n\treturn (count);\n}\n\n/*\n==================\nCL_GetFreePing\n==================\n*/\nping_t* CL_GetFreePing( void )\n{\n\tping_t*\tpingptr;\n\tping_t*\tbest;\t\n\tint\t\toldest;\n\tint\t\ti;\n\tint\t\ttime;\n\n\tpingptr = cl_pinglist;\n\tfor (i=0; i<MAX_PINGREQUESTS; i++, pingptr++ )\n\t{\n\t\t// find free ping slot\n\t\tif (pingptr->adr.port)\n\t\t{\n\t\t\tif (!pingptr->time)\n\t\t\t{\n\t\t\t\tif (cls.realtime - pingptr->start < 500)\n\t\t\t\t{\n\t\t\t\t\t// still waiting for response\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (pingptr->time < 500)\n\t\t\t{\n\t\t\t\t// results have not been queried\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\t// clear it\n\t\tpingptr->adr.port = 0;\n\t\treturn (pingptr);\n\t}\n\n\t// use oldest entry\n\tpingptr = cl_pinglist;\n\tbest    = cl_pinglist;\n\toldest  = INT_MIN;\n\tfor (i=0; i<MAX_PINGREQUESTS; i++, pingptr++ )\n\t{\n\t\t// scan for oldest\n\t\ttime = cls.realtime - pingptr->start;\n\t\tif (time > oldest)\n\t\t{\n\t\t\toldest = time;\n\t\t\tbest   = pingptr;\n\t\t}\n\t}\n\n\treturn (best);\n}\n\n/*\n==================\nCL_Ping_f\n==================\n*/\nvoid CL_Ping_f( void ) {\n\tnetadr_t\tto;\n\tping_t*\t\tpingptr;\n\tchar*\t\tserver;\n\n\tif ( Cmd_Argc() != 2 ) {\n\t\tCom_Printf( \"usage: ping [server]\\n\");\n\t\treturn;\t\n\t}\n\n\tCom_Memset( &to, 0, sizeof(netadr_t) );\n\n\tserver = Cmd_Argv(1);\n\n\tif ( !NET_StringToAdr( server, &to ) ) {\n\t\treturn;\n\t}\n\n\tpingptr = CL_GetFreePing();\n\n\tmemcpy( &pingptr->adr, &to, sizeof (netadr_t) );\n\tpingptr->start = cls.realtime;\n\tpingptr->time  = 0;\n\n\tCL_SetServerInfoByAddress(pingptr->adr, NULL, 0);\n\t\t\n\tNET_OutOfBandPrint( NS_CLIENT, to, \"getinfo xxx\" );\n}\n\n/*\n==================\nCL_UpdateVisiblePings_f\n==================\n*/\nqboolean CL_UpdateVisiblePings_f(int source) {\n\tint\t\t\tslots, i;\n\tchar\t\tbuff[MAX_STRING_CHARS];\n\tint\t\t\tpingTime;\n\tint\t\t\tmax;\n\tqboolean status = qfalse;\n\n\tif (source < 0 || source > AS_FAVORITES) {\n\t\treturn qfalse;\n\t}\n\n\tcls.pingUpdateSource = source;\n\n\tslots = CL_GetPingQueueCount();\n\tif (slots < MAX_PINGREQUESTS) {\n\t\tserverInfo_t *server = NULL;\n\n\t\tmax = (source == AS_GLOBAL) ? MAX_GLOBAL_SERVERS : MAX_OTHER_SERVERS;\n\t\tswitch (source) {\n\t\t\tcase AS_LOCAL :\n\t\t\t\tserver = &cls.localServers[0];\n\t\t\t\tmax = cls.numlocalservers;\n\t\t\tbreak;\n\t\t\tcase AS_MPLAYER :\n\t\t\t\tserver = &cls.mplayerServers[0];\n\t\t\t\tmax = cls.nummplayerservers;\n\t\t\tbreak;\n\t\t\tcase AS_GLOBAL :\n\t\t\t\tserver = &cls.globalServers[0];\n\t\t\t\tmax = cls.numglobalservers;\n\t\t\tbreak;\n\t\t\tcase AS_FAVORITES :\n\t\t\t\tserver = &cls.favoriteServers[0];\n\t\t\t\tmax = cls.numfavoriteservers;\n\t\t\tbreak;\n\t\t}\n\t\tfor (i = 0; i < max; i++) {\n\t\t\tif (server[i].visible) {\n\t\t\t\tif (server[i].ping == -1) {\n\t\t\t\t\tint j;\n\n\t\t\t\t\tif (slots >= MAX_PINGREQUESTS) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tfor (j = 0; j < MAX_PINGREQUESTS; j++) {\n\t\t\t\t\t\tif (!cl_pinglist[j].adr.port) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (NET_CompareAdr( cl_pinglist[j].adr, server[i].adr)) {\n\t\t\t\t\t\t\t// already on the list\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (j >= MAX_PINGREQUESTS) {\n\t\t\t\t\t\tstatus = qtrue;\n\t\t\t\t\t\tfor (j = 0; j < MAX_PINGREQUESTS; j++) {\n\t\t\t\t\t\t\tif (!cl_pinglist[j].adr.port) {\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmemcpy(&cl_pinglist[j].adr, &server[i].adr, sizeof(netadr_t));\n\t\t\t\t\t\tcl_pinglist[j].start = cls.realtime;\n\t\t\t\t\t\tcl_pinglist[j].time = 0;\n\t\t\t\t\t\tNET_OutOfBandPrint( NS_CLIENT, cl_pinglist[j].adr, \"getinfo xxx\" );\n\t\t\t\t\t\tslots++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// if the server has a ping higher than cl_maxPing or\n\t\t\t\t// the ping packet got lost\n\t\t\t\telse if (server[i].ping == 0) {\n\t\t\t\t\t// if we are updating global servers\n\t\t\t\t\tif (source == AS_GLOBAL) {\n\t\t\t\t\t\t//\n\t\t\t\t\t\tif ( cls.numGlobalServerAddresses > 0 ) {\n\t\t\t\t\t\t\t// overwrite this server with one from the additional global servers\n\t\t\t\t\t\t\tcls.numGlobalServerAddresses--;\n\t\t\t\t\t\t\tCL_InitServerInfo(&server[i], &cls.globalServerAddresses[cls.numGlobalServerAddresses]);\n\t\t\t\t\t\t\t// NOTE: the server[i].visible flag stays untouched\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} \n\n\tif (slots) {\n\t\tstatus = qtrue;\n\t}\n\tfor (i = 0; i < MAX_PINGREQUESTS; i++) {\n\t\tif (!cl_pinglist[i].adr.port) {\n\t\t\tcontinue;\n\t\t}\n\t\tCL_GetPing( i, buff, MAX_STRING_CHARS, &pingTime );\n\t\tif (pingTime != 0) {\n\t\t\tCL_ClearPing(i);\n\t\t\tstatus = qtrue;\n\t\t}\n\t}\n\n\treturn status;\n}\n\n/*\n==================\nCL_ServerStatus_f\n==================\n*/\nvoid CL_ServerStatus_f(void) {\n\tnetadr_t\tto;\n\tchar\t\t*server;\n\tserverStatus_t *serverStatus;\n\n\tCom_Memset( &to, 0, sizeof(netadr_t) );\n\n\tif ( Cmd_Argc() != 2 ) {\n\t\tif ( cls.state != CA_ACTIVE || clc.demoplaying ) {\n\t\t\tCom_Printf (\"Not connected to a server.\\n\");\n\t\t\tCom_Printf( \"Usage: serverstatus [server]\\n\");\n\t\t\treturn;\t\n\t\t}\n\t\tserver = cls.servername;\n\t}\n\telse {\n\t\tserver = Cmd_Argv(1);\n\t}\n\n\tif ( !NET_StringToAdr( server, &to ) ) {\n\t\treturn;\n\t}\n\n\tNET_OutOfBandPrint( NS_CLIENT, to, \"getstatus\" );\n\n\tserverStatus = CL_GetServerStatus( to );\n\tserverStatus->address = to;\n\tserverStatus->print = qtrue;\n\tserverStatus->pending = qtrue;\n}\n\n/*\n==================\nCL_ShowIP_f\n==================\n*/\nvoid CL_ShowIP_f(void) {\n\tSys_ShowIP();\n}\n\n/*\n=================\nbool CL_CDKeyValidate\n=================\n*/\nqboolean CL_CDKeyValidate( const char *key, const char *checksum ) {\n\tchar\tch;\n\tbyte\tsum;\n\tchar\tchs[3];\n\tint i, len;\n\n\tlen = strlen(key);\n\tif( len != CDKEY_LEN ) {\n\t\treturn qfalse;\n\t}\n\n\tif( checksum && strlen( checksum ) != CDCHKSUM_LEN ) {\n\t\treturn qfalse;\n\t}\n\n\tsum = 0;\n\t// for loop gets rid of conditional assignment warning\n\tfor (i = 0; i < len; i++) {\n\t\tch = *key++;\n\t\tif (ch>='a' && ch<='z') {\n\t\t\tch -= 32;\n\t\t}\n\t\tswitch( ch ) {\n\t\tcase '2':\n\t\tcase '3':\n\t\tcase '7':\n\t\tcase 'A':\n\t\tcase 'B':\n\t\tcase 'C':\n\t\tcase 'D':\n\t\tcase 'G':\n\t\tcase 'H':\n\t\tcase 'J':\n\t\tcase 'L':\n\t\tcase 'P':\n\t\tcase 'R':\n\t\tcase 'S':\n\t\tcase 'T':\n\t\tcase 'W':\n\t\t\tsum += ch;\n\t\t\tcontinue;\n\t\tdefault:\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\tsprintf(chs, \"%02x\", sum);\n\t\n\tif (checksum && !Q_stricmp(chs, checksum)) {\n\t\treturn qtrue;\n\t}\n\n\tif (!checksum) {\n\t\treturn qtrue;\n\t}\n\n\treturn qfalse;\n}\n\n\n"
  },
  {
    "path": "code/client/cl_net_chan.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"../game/q_shared.h\"\n#include \"../qcommon/qcommon.h\"\n#include \"client.h\"\n\n/*\n==============\nCL_Netchan_Encode\n\n\t// first 12 bytes of the data are always:\n\tlong serverId;\n\tlong messageAcknowledge;\n\tlong reliableAcknowledge;\n\n==============\n*/\nstatic void CL_Netchan_Encode( msg_t *msg ) {\n\tint serverId, messageAcknowledge, reliableAcknowledge;\n\tint i, index, srdc, sbit, soob;\n\tbyte key, *string;\n\n\tif ( msg->cursize <= CL_ENCODE_START ) {\n\t\treturn;\n\t}\n\n        srdc = msg->readcount;\n        sbit = msg->bit;\n        soob = msg->oob;\n        \n        msg->bit = 0;\n        msg->readcount = 0;\n        msg->oob = 0;\n        \n        serverId = MSG_ReadLong(msg);\n\tmessageAcknowledge = MSG_ReadLong(msg);\n\treliableAcknowledge = MSG_ReadLong(msg);\n\n        msg->oob = soob;\n        msg->bit = sbit;\n        msg->readcount = srdc;\n        \n\tstring = (byte *)clc.serverCommands[ reliableAcknowledge & (MAX_RELIABLE_COMMANDS-1) ];\n\tindex = 0;\n\t//\n\tkey = clc.challenge ^ serverId ^ messageAcknowledge;\n\tfor (i = CL_ENCODE_START; i < msg->cursize; i++) {\n\t\t// modify the key with the last received now acknowledged server command\n\t\tif (!string[index])\n\t\t\tindex = 0;\n\t\tif (string[index] > 127 || string[index] == '%') {\n\t\t\tkey ^= '.' << (i & 1);\n\t\t}\n\t\telse {\n\t\t\tkey ^= string[index] << (i & 1);\n\t\t}\n\t\tindex++;\n\t\t// encode the data with this key\n\t\t*(msg->data + i) = (*(msg->data + i)) ^ key;\n\t}\n}\n\n/*\n==============\nCL_Netchan_Decode\n\n\t// first four bytes of the data are always:\n\tlong reliableAcknowledge;\n\n==============\n*/\nstatic void CL_Netchan_Decode( msg_t *msg ) {\n\tlong reliableAcknowledge, i, index;\n\tbyte key, *string;\n        int\tsrdc, sbit, soob;\n\n        srdc = msg->readcount;\n        sbit = msg->bit;\n        soob = msg->oob;\n        \n        msg->oob = 0;\n        \n\treliableAcknowledge = MSG_ReadLong(msg);\n\n        msg->oob = soob;\n        msg->bit = sbit;\n        msg->readcount = srdc;\n\n\tstring = clc.reliableCommands[ reliableAcknowledge & (MAX_RELIABLE_COMMANDS-1) ];\n\tindex = 0;\n\t// xor the client challenge with the netchan sequence number (need something that changes every message)\n\tkey = clc.challenge ^ LittleLong( *(unsigned *)msg->data );\n\tfor (i = msg->readcount + CL_DECODE_START; i < msg->cursize; i++) {\n\t\t// modify the key with the last sent and with this message acknowledged client command\n\t\tif (!string[index])\n\t\t\tindex = 0;\n\t\tif (string[index] > 127 || string[index] == '%') {\n\t\t\tkey ^= '.' << (i & 1);\n\t\t}\n\t\telse {\n\t\t\tkey ^= string[index] << (i & 1);\n\t\t}\n\t\tindex++;\n\t\t// decode the data with this key\n\t\t*(msg->data + i) = *(msg->data + i) ^ key;\n\t}\n}\n\n/*\n=================\nCL_Netchan_TransmitNextFragment\n=================\n*/\nvoid CL_Netchan_TransmitNextFragment( netchan_t *chan ) {\n\tNetchan_TransmitNextFragment( chan );\n}\n\n/*\n===============\nCL_Netchan_Transmit\n================\n*/\nvoid CL_Netchan_Transmit( netchan_t *chan, msg_t* msg ) {\n\tMSG_WriteByte( msg, clc_EOF );\n\n\tCL_Netchan_Encode( msg );\n\tNetchan_Transmit( chan, msg->cursize, msg->data );\n}\n\nextern \tint oldsize;\nint newsize = 0;\n\n/*\n=================\nCL_Netchan_Process\n=================\n*/\nqboolean CL_Netchan_Process( netchan_t *chan, msg_t *msg ) {\n\tint ret;\n\n\tret = Netchan_Process( chan, msg );\n\tif (!ret)\n\t\treturn qfalse;\n\tCL_Netchan_Decode( msg );\n\tnewsize += msg->cursize;\n\treturn qtrue;\n}\n"
  },
  {
    "path": "code/client/cl_parse.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// cl_parse.c  -- parse a message received from the server\n\n#include \"client.h\"\n\nchar *svc_strings[256] = {\n\t\"svc_bad\",\n\n\t\"svc_nop\",\n\t\"svc_gamestate\",\n\t\"svc_configstring\",\n\t\"svc_baseline\",\t\n\t\"svc_serverCommand\",\n\t\"svc_download\",\n\t\"svc_snapshot\"\n};\n\nvoid SHOWNET( msg_t *msg, char *s) {\n\tif ( cl_shownet->integer >= 2) {\n\t\tCom_Printf (\"%3i:%s\\n\", msg->readcount-1, s);\n\t}\n}\n\n\n/*\n=========================================================================\n\nMESSAGE PARSING\n\n=========================================================================\n*/\n\n/*\n==================\nCL_DeltaEntity\n\nParses deltas from the given base and adds the resulting entity\nto the current frame\n==================\n*/\nvoid CL_DeltaEntity (msg_t *msg, clSnapshot_t *frame, int newnum, entityState_t *old, \n\t\t\t\t\t qboolean unchanged) {\n\tentityState_t\t*state;\n\n\t// save the parsed entity state into the big circular buffer so\n\t// it can be used as the source for a later delta\n\tstate = &cl.parseEntities[cl.parseEntitiesNum & (MAX_PARSE_ENTITIES-1)];\n\n\tif ( unchanged ) {\n\t\t*state = *old;\n\t} else {\n\t\tMSG_ReadDeltaEntity( msg, old, state, newnum );\n\t}\n\n\tif ( state->number == (MAX_GENTITIES-1) ) {\n\t\treturn;\t\t// entity was delta removed\n\t}\n\tcl.parseEntitiesNum++;\n\tframe->numEntities++;\n}\n\n/*\n==================\nCL_ParsePacketEntities\n\n==================\n*/\nvoid CL_ParsePacketEntities( msg_t *msg, clSnapshot_t *oldframe, clSnapshot_t *newframe) {\n\tint\t\t\tnewnum;\n\tentityState_t\t*oldstate;\n\tint\t\t\toldindex, oldnum;\n\n\tnewframe->parseEntitiesNum = cl.parseEntitiesNum;\n\tnewframe->numEntities = 0;\n\n\t// delta from the entities present in oldframe\n\toldindex = 0;\n\toldstate = NULL;\n\tif (!oldframe) {\n\t\toldnum = 99999;\n\t} else {\n\t\tif ( oldindex >= oldframe->numEntities ) {\n\t\t\toldnum = 99999;\n\t\t} else {\n\t\t\toldstate = &cl.parseEntities[\n\t\t\t\t(oldframe->parseEntitiesNum + oldindex) & (MAX_PARSE_ENTITIES-1)];\n\t\t\toldnum = oldstate->number;\n\t\t}\n\t}\n\n\twhile ( 1 ) {\n\t\t// read the entity index number\n\t\tnewnum = MSG_ReadBits( msg, GENTITYNUM_BITS );\n\n\t\tif ( newnum == (MAX_GENTITIES-1) ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif ( msg->readcount > msg->cursize ) {\n\t\t\tCom_Error (ERR_DROP,\"CL_ParsePacketEntities: end of message\");\n\t\t}\n\n\t\twhile ( oldnum < newnum ) {\n\t\t\t// one or more entities from the old packet are unchanged\n\t\t\tif ( cl_shownet->integer == 3 ) {\n\t\t\t\tCom_Printf (\"%3i:  unchanged: %i\\n\", msg->readcount, oldnum);\n\t\t\t}\n\t\t\tCL_DeltaEntity( msg, newframe, oldnum, oldstate, qtrue );\n\t\t\t\n\t\t\toldindex++;\n\n\t\t\tif ( oldindex >= oldframe->numEntities ) {\n\t\t\t\toldnum = 99999;\n\t\t\t} else {\n\t\t\t\toldstate = &cl.parseEntities[\n\t\t\t\t\t(oldframe->parseEntitiesNum + oldindex) & (MAX_PARSE_ENTITIES-1)];\n\t\t\t\toldnum = oldstate->number;\n\t\t\t}\n\t\t}\n\t\tif (oldnum == newnum) {\n\t\t\t// delta from previous state\n\t\t\tif ( cl_shownet->integer == 3 ) {\n\t\t\t\tCom_Printf (\"%3i:  delta: %i\\n\", msg->readcount, newnum);\n\t\t\t}\n\t\t\tCL_DeltaEntity( msg, newframe, newnum, oldstate, qfalse );\n\n\t\t\toldindex++;\n\n\t\t\tif ( oldindex >= oldframe->numEntities ) {\n\t\t\t\toldnum = 99999;\n\t\t\t} else {\n\t\t\t\toldstate = &cl.parseEntities[\n\t\t\t\t\t(oldframe->parseEntitiesNum + oldindex) & (MAX_PARSE_ENTITIES-1)];\n\t\t\t\toldnum = oldstate->number;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( oldnum > newnum ) {\n\t\t\t// delta from baseline\n\t\t\tif ( cl_shownet->integer == 3 ) {\n\t\t\t\tCom_Printf (\"%3i:  baseline: %i\\n\", msg->readcount, newnum);\n\t\t\t}\n\t\t\tCL_DeltaEntity( msg, newframe, newnum, &cl.entityBaselines[newnum], qfalse );\n\t\t\tcontinue;\n\t\t}\n\n\t}\n\n\t// any remaining entities in the old frame are copied over\n\twhile ( oldnum != 99999 ) {\n\t\t// one or more entities from the old packet are unchanged\n\t\tif ( cl_shownet->integer == 3 ) {\n\t\t\tCom_Printf (\"%3i:  unchanged: %i\\n\", msg->readcount, oldnum);\n\t\t}\n\t\tCL_DeltaEntity( msg, newframe, oldnum, oldstate, qtrue );\n\t\t\n\t\toldindex++;\n\n\t\tif ( oldindex >= oldframe->numEntities ) {\n\t\t\toldnum = 99999;\n\t\t} else {\n\t\t\toldstate = &cl.parseEntities[\n\t\t\t\t(oldframe->parseEntitiesNum + oldindex) & (MAX_PARSE_ENTITIES-1)];\n\t\t\toldnum = oldstate->number;\n\t\t}\n\t}\n}\n\n\n/*\n================\nCL_ParseSnapshot\n\nIf the snapshot is parsed properly, it will be copied to\ncl.snap and saved in cl.snapshots[].  If the snapshot is invalid\nfor any reason, no changes to the state will be made at all.\n================\n*/\nvoid CL_ParseSnapshot( msg_t *msg ) {\n\tint\t\t\tlen;\n\tclSnapshot_t\t*old;\n\tclSnapshot_t\tnewSnap;\n\tint\t\t\tdeltaNum;\n\tint\t\t\toldMessageNum;\n\tint\t\t\ti, packetNum;\n\n\t// get the reliable sequence acknowledge number\n\t// NOTE: now sent with all server to client messages\n\t//clc.reliableAcknowledge = MSG_ReadLong( msg );\n\n\t// read in the new snapshot to a temporary buffer\n\t// we will only copy to cl.snap if it is valid\n\tCom_Memset (&newSnap, 0, sizeof(newSnap));\n\n\t// we will have read any new server commands in this\n\t// message before we got to svc_snapshot\n\tnewSnap.serverCommandNum = clc.serverCommandSequence;\n\n\tnewSnap.serverTime = MSG_ReadLong( msg );\n\n\tnewSnap.messageNum = clc.serverMessageSequence;\n\n\tdeltaNum = MSG_ReadByte( msg );\n\tif ( !deltaNum ) {\n\t\tnewSnap.deltaNum = -1;\n\t} else {\n\t\tnewSnap.deltaNum = newSnap.messageNum - deltaNum;\n\t}\n\tnewSnap.snapFlags = MSG_ReadByte( msg );\n\n\t// If the frame is delta compressed from data that we\n\t// no longer have available, we must suck up the rest of\n\t// the frame, but not use it, then ask for a non-compressed\n\t// message \n\tif ( newSnap.deltaNum <= 0 ) {\n\t\tnewSnap.valid = qtrue;\t\t// uncompressed frame\n\t\told = NULL;\n\t\tclc.demowaiting = qfalse;\t// we can start recording now\n\t} else {\n\t\told = &cl.snapshots[newSnap.deltaNum & PACKET_MASK];\n\t\tif ( !old->valid ) {\n\t\t\t// should never happen\n\t\t\tCom_Printf (\"Delta from invalid frame (not supposed to happen!).\\n\");\n\t\t} else if ( old->messageNum != newSnap.deltaNum ) {\n\t\t\t// The frame that the server did the delta from\n\t\t\t// is too old, so we can't reconstruct it properly.\n\t\t\tCom_Printf (\"Delta frame too old.\\n\");\n\t\t} else if ( cl.parseEntitiesNum - old->parseEntitiesNum > MAX_PARSE_ENTITIES-128 ) {\n\t\t\tCom_Printf (\"Delta parseEntitiesNum too old.\\n\");\n\t\t} else {\n\t\t\tnewSnap.valid = qtrue;\t// valid delta parse\n\t\t}\n\t}\n\n\t// read areamask\n\tlen = MSG_ReadByte( msg );\n\tMSG_ReadData( msg, &newSnap.areamask, len);\n\n\t// read playerinfo\n\tSHOWNET( msg, \"playerstate\" );\n\tif ( old ) {\n\t\tMSG_ReadDeltaPlayerstate( msg, &old->ps, &newSnap.ps );\n\t} else {\n\t\tMSG_ReadDeltaPlayerstate( msg, NULL, &newSnap.ps );\n\t}\n\n\t// read packet entities\n\tSHOWNET( msg, \"packet entities\" );\n\tCL_ParsePacketEntities( msg, old, &newSnap );\n\n\t// if not valid, dump the entire thing now that it has\n\t// been properly read\n\tif ( !newSnap.valid ) {\n\t\treturn;\n\t}\n\n\t// clear the valid flags of any snapshots between the last\n\t// received and this one, so if there was a dropped packet\n\t// it won't look like something valid to delta from next\n\t// time we wrap around in the buffer\n\toldMessageNum = cl.snap.messageNum + 1;\n\n\tif ( newSnap.messageNum - oldMessageNum >= PACKET_BACKUP ) {\n\t\toldMessageNum = newSnap.messageNum - ( PACKET_BACKUP - 1 );\n\t}\n\tfor ( ; oldMessageNum < newSnap.messageNum ; oldMessageNum++ ) {\n\t\tcl.snapshots[oldMessageNum & PACKET_MASK].valid = qfalse;\n\t}\n\n\t// copy to the current good spot\n\tcl.snap = newSnap;\n\tcl.snap.ping = 999;\n\t// calculate ping time\n\tfor ( i = 0 ; i < PACKET_BACKUP ; i++ ) {\n\t\tpacketNum = ( clc.netchan.outgoingSequence - 1 - i ) & PACKET_MASK;\n\t\tif ( cl.snap.ps.commandTime >= cl.outPackets[ packetNum ].p_serverTime ) {\n\t\t\tcl.snap.ping = cls.realtime - cl.outPackets[ packetNum ].p_realtime;\n\t\t\tbreak;\n\t\t}\n\t}\n\t// save the frame off in the backup array for later delta comparisons\n\tcl.snapshots[cl.snap.messageNum & PACKET_MASK] = cl.snap;\n\n\tif (cl_shownet->integer == 3) {\n\t\tCom_Printf( \"   snapshot:%i  delta:%i  ping:%i\\n\", cl.snap.messageNum,\n\t\tcl.snap.deltaNum, cl.snap.ping );\n\t}\n\n\tcl.newSnapshots = qtrue;\n}\n\n\n//=====================================================================\n\nint cl_connectedToPureServer;\n\n/*\n==================\nCL_SystemInfoChanged\n\nThe systeminfo configstring has been changed, so parse\nnew information out of it.  This will happen at every\ngamestate, and possibly during gameplay.\n==================\n*/\nvoid CL_SystemInfoChanged( void ) {\n\tchar\t\t\t*systemInfo;\n\tconst char\t\t*s, *t;\n\tchar\t\t\tkey[BIG_INFO_KEY];\n\tchar\t\t\tvalue[BIG_INFO_VALUE];\n\tqboolean\t\tgameSet;\n\n\tsystemInfo = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SYSTEMINFO ];\n\t// NOTE TTimo:\n\t// when the serverId changes, any further messages we send to the server will use this new serverId\n\t// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=475\n\t// in some cases, outdated cp commands might get sent with this news serverId\n\tcl.serverId = atoi( Info_ValueForKey( systemInfo, \"sv_serverid\" ) );\n\n\t// don't set any vars when playing a demo\n\tif ( clc.demoplaying ) {\n\t\treturn;\n\t}\n\n\ts = Info_ValueForKey( systemInfo, \"sv_cheats\" );\n\tif ( atoi(s) == 0 ) {\n\t\tCvar_SetCheatState();\n\t}\n\n\t// check pure server string\n\ts = Info_ValueForKey( systemInfo, \"sv_paks\" );\n\tt = Info_ValueForKey( systemInfo, \"sv_pakNames\" );\n\tFS_PureServerSetLoadedPaks( s, t );\n\n\ts = Info_ValueForKey( systemInfo, \"sv_referencedPaks\" );\n\tt = Info_ValueForKey( systemInfo, \"sv_referencedPakNames\" );\n\tFS_PureServerSetReferencedPaks( s, t );\n\n\tgameSet = qfalse;\n\t// scan through all the variables in the systeminfo and locally set cvars to match\n\ts = systemInfo;\n\twhile ( s ) {\n\t\tInfo_NextPair( &s, key, value );\n\t\tif ( !key[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\t// ehw!\n\t\tif ( !Q_stricmp( key, \"fs_game\" ) ) {\n\t\t\tgameSet = qtrue;\n\t\t}\n\n\t\tCvar_Set( key, value );\n\t}\n\t// if game folder should not be set and it is set at the client side\n\tif ( !gameSet && *Cvar_VariableString(\"fs_game\") ) {\n\t\tCvar_Set( \"fs_game\", \"\" );\n\t}\n\tcl_connectedToPureServer = Cvar_VariableValue( \"sv_pure\" );\n}\n\n/*\n==================\nCL_ParseGamestate\n==================\n*/\nvoid CL_ParseGamestate( msg_t *msg ) {\n\tint\t\t\t\ti;\n\tentityState_t\t*es;\n\tint\t\t\t\tnewnum;\n\tentityState_t\tnullstate;\n\tint\t\t\t\tcmd;\n\tchar\t\t\t*s;\n\n\tCon_Close();\n\n\tclc.connectPacketCount = 0;\n\n\t// wipe local client state\n\tCL_ClearState();\n\n\t// a gamestate always marks a server command sequence\n\tclc.serverCommandSequence = MSG_ReadLong( msg );\n\n\t// parse all the configstrings and baselines\n\tcl.gameState.dataCount = 1;\t// leave a 0 at the beginning for uninitialized configstrings\n\twhile ( 1 ) {\n\t\tcmd = MSG_ReadByte( msg );\n\n\t\tif ( cmd == svc_EOF ) {\n\t\t\tbreak;\n\t\t}\n\t\t\n\t\tif ( cmd == svc_configstring ) {\n\t\t\tint\t\tlen;\n\n\t\t\ti = MSG_ReadShort( msg );\n\t\t\tif ( i < 0 || i >= MAX_CONFIGSTRINGS ) {\n\t\t\t\tCom_Error( ERR_DROP, \"configstring > MAX_CONFIGSTRINGS\" );\n\t\t\t}\n\t\t\ts = MSG_ReadBigString( msg );\n\t\t\tlen = strlen( s );\n\n\t\t\tif ( len + 1 + cl.gameState.dataCount > MAX_GAMESTATE_CHARS ) {\n\t\t\t\tCom_Error( ERR_DROP, \"MAX_GAMESTATE_CHARS exceeded\" );\n\t\t\t}\n\n\t\t\t// append it to the gameState string buffer\n\t\t\tcl.gameState.stringOffsets[ i ] = cl.gameState.dataCount;\n\t\t\tCom_Memcpy( cl.gameState.stringData + cl.gameState.dataCount, s, len + 1 );\n\t\t\tcl.gameState.dataCount += len + 1;\n\t\t} else if ( cmd == svc_baseline ) {\n\t\t\tnewnum = MSG_ReadBits( msg, GENTITYNUM_BITS );\n\t\t\tif ( newnum < 0 || newnum >= MAX_GENTITIES ) {\n\t\t\t\tCom_Error( ERR_DROP, \"Baseline number out of range: %i\", newnum );\n\t\t\t}\n\t\t\tCom_Memset (&nullstate, 0, sizeof(nullstate));\n\t\t\tes = &cl.entityBaselines[ newnum ];\n\t\t\tMSG_ReadDeltaEntity( msg, &nullstate, es, newnum );\n\t\t} else {\n\t\t\tCom_Error( ERR_DROP, \"CL_ParseGamestate: bad command byte\" );\n\t\t}\n\t}\n\n\tclc.clientNum = MSG_ReadLong(msg);\n\t// read the checksum feed\n\tclc.checksumFeed = MSG_ReadLong( msg );\n\n\t// parse serverId and other cvars\n\tCL_SystemInfoChanged();\n\n\t// reinitialize the filesystem if the game directory has changed\n  FS_ConditionalRestart( clc.checksumFeed );\n\n\t// This used to call CL_StartHunkUsers, but now we enter the download state before loading the\n\t// cgame\n\tCL_InitDownloads();\n\n\t// make sure the game starts\n\tCvar_Set( \"cl_paused\", \"0\" );\n}\n\n\n//=====================================================================\n\n/*\n=====================\nCL_ParseDownload\n\nA download message has been received from the server\n=====================\n*/\nvoid CL_ParseDownload ( msg_t *msg ) {\n\tint\t\tsize;\n\tunsigned char data[MAX_MSGLEN];\n\tint block;\n\n\t// read the data\n\tblock = MSG_ReadShort ( msg );\n\n\tif ( !block )\n\t{\n\t\t// block zero is special, contains file size\n\t\tclc.downloadSize = MSG_ReadLong ( msg );\n\n\t\tCvar_SetValue( \"cl_downloadSize\", clc.downloadSize );\n\n\t\tif (clc.downloadSize < 0)\n\t\t{\n\t\t\tCom_Error(ERR_DROP, MSG_ReadString( msg ) );\n\t\t\treturn;\n\t\t}\n\t}\n\n\tsize = MSG_ReadShort ( msg );\n\tif (size > 0)\n\t\tMSG_ReadData( msg, data, size );\n\n\tif (clc.downloadBlock != block) {\n\t\tCom_DPrintf( \"CL_ParseDownload: Expected block %d, got %d\\n\", clc.downloadBlock, block);\n\t\treturn;\n\t}\n\n\t// open the file if not opened yet\n\tif (!clc.download)\n\t{\n\t\tif (!*clc.downloadTempName) {\n\t\t\tCom_Printf(\"Server sending download, but no download was requested\\n\");\n\t\t\tCL_AddReliableCommand( \"stopdl\" );\n\t\t\treturn;\n\t\t}\n\n\t\tclc.download = FS_SV_FOpenFileWrite( clc.downloadTempName );\n\n\t\tif (!clc.download) {\n\t\t\tCom_Printf( \"Could not create %s\\n\", clc.downloadTempName );\n\t\t\tCL_AddReliableCommand( \"stopdl\" );\n\t\t\tCL_NextDownload();\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif (size)\n\t\tFS_Write( data, size, clc.download );\n\n\tCL_AddReliableCommand( va(\"nextdl %d\", clc.downloadBlock) );\n\tclc.downloadBlock++;\n\n\tclc.downloadCount += size;\n\n\t// So UI gets access to it\n\tCvar_SetValue( \"cl_downloadCount\", clc.downloadCount );\n\n\tif (!size) { // A zero length block means EOF\n\t\tif (clc.download) {\n\t\t\tFS_FCloseFile( clc.download );\n\t\t\tclc.download = 0;\n\n\t\t\t// rename the file\n\t\t\tFS_SV_Rename ( clc.downloadTempName, clc.downloadName );\n\t\t}\n\t\t*clc.downloadTempName = *clc.downloadName = 0;\n\t\tCvar_Set( \"cl_downloadName\", \"\" );\n\n\t\t// send intentions now\n\t\t// We need this because without it, we would hold the last nextdl and then start\n\t\t// loading right away.  If we take a while to load, the server is happily trying\n\t\t// to send us that last block over and over.\n\t\t// Write it twice to help make sure we acknowledge the download\n\t\tCL_WritePacket();\n\t\tCL_WritePacket();\n\n\t\t// get another file if needed\n\t\tCL_NextDownload ();\n\t}\n}\n\n/*\n=====================\nCL_ParseCommandString\n\nCommand strings are just saved off until cgame asks for them\nwhen it transitions a snapshot\n=====================\n*/\nvoid CL_ParseCommandString( msg_t *msg ) {\n\tchar\t*s;\n\tint\t\tseq;\n\tint\t\tindex;\n\n\tseq = MSG_ReadLong( msg );\n\ts = MSG_ReadString( msg );\n\n\t// see if we have already executed stored it off\n\tif ( clc.serverCommandSequence >= seq ) {\n\t\treturn;\n\t}\n\tclc.serverCommandSequence = seq;\n\n\tindex = seq & (MAX_RELIABLE_COMMANDS-1);\n\tQ_strncpyz( clc.serverCommands[ index ], s, sizeof( clc.serverCommands[ index ] ) );\n}\n\n\n/*\n=====================\nCL_ParseServerMessage\n=====================\n*/\nvoid CL_ParseServerMessage( msg_t *msg ) {\n\tint\t\t\tcmd;\n\n\tif ( cl_shownet->integer == 1 ) {\n\t\tCom_Printf (\"%i \",msg->cursize);\n\t} else if ( cl_shownet->integer >= 2 ) {\n\t\tCom_Printf (\"------------------\\n\");\n\t}\n\n\tMSG_Bitstream(msg);\n\n\t// get the reliable sequence acknowledge number\n\tclc.reliableAcknowledge = MSG_ReadLong( msg );\n\t// \n\tif ( clc.reliableAcknowledge < clc.reliableSequence - MAX_RELIABLE_COMMANDS ) {\n\t\tclc.reliableAcknowledge = clc.reliableSequence;\n\t}\n\n\t//\n\t// parse the message\n\t//\n\twhile ( 1 ) {\n\t\tif ( msg->readcount > msg->cursize ) {\n\t\t\tCom_Error (ERR_DROP,\"CL_ParseServerMessage: read past end of server message\");\n\t\t\tbreak;\n\t\t}\n\n\t\tcmd = MSG_ReadByte( msg );\n\n\t\tif ( cmd == svc_EOF) {\n\t\t\tSHOWNET( msg, \"END OF MESSAGE\" );\n\t\t\tbreak;\n\t\t}\n\n\t\tif ( cl_shownet->integer >= 2 ) {\n\t\t\tif ( !svc_strings[cmd] ) {\n\t\t\t\tCom_Printf( \"%3i:BAD CMD %i\\n\", msg->readcount-1, cmd );\n\t\t\t} else {\n\t\t\t\tSHOWNET( msg, svc_strings[cmd] );\n\t\t\t}\n\t\t}\n\t\n\t// other commands\n\t\tswitch ( cmd ) {\n\t\tdefault:\n\t\t\tCom_Error (ERR_DROP,\"CL_ParseServerMessage: Illegible server message\\n\");\n\t\t\tbreak;\t\t\t\n\t\tcase svc_nop:\n\t\t\tbreak;\n\t\tcase svc_serverCommand:\n\t\t\tCL_ParseCommandString( msg );\n\t\t\tbreak;\n\t\tcase svc_gamestate:\n\t\t\tCL_ParseGamestate( msg );\n\t\t\tbreak;\n\t\tcase svc_snapshot:\n\t\t\tCL_ParseSnapshot( msg );\n\t\t\tbreak;\n\t\tcase svc_download:\n\t\t\tCL_ParseDownload( msg );\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n\n"
  },
  {
    "path": "code/client/cl_scrn.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// cl_scrn.c -- master for refresh, status bar, console, chat, notify, etc\n\n#include \"client.h\"\n\nqboolean\tscr_initialized;\t\t// ready to draw\n\ncvar_t\t\t*cl_timegraph;\ncvar_t\t\t*cl_debuggraph;\ncvar_t\t\t*cl_graphheight;\ncvar_t\t\t*cl_graphscale;\ncvar_t\t\t*cl_graphshift;\n\n/*\n================\nSCR_DrawNamedPic\n\nCoordinates are 640*480 virtual values\n=================\n*/\nvoid SCR_DrawNamedPic( float x, float y, float width, float height, const char *picname ) {\n\tqhandle_t\thShader;\n\n\tassert( width != 0 );\n\n\thShader = re.RegisterShader( picname );\n\tSCR_AdjustFrom640( &x, &y, &width, &height );\n\tre.DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader );\n}\n\n\n/*\n================\nSCR_AdjustFrom640\n\nAdjusted for resolution and screen aspect ratio\n================\n*/\nvoid SCR_AdjustFrom640( float *x, float *y, float *w, float *h ) {\n\tfloat\txscale;\n\tfloat\tyscale;\n\n#if 0\n\t\t// adjust for wide screens\n\t\tif ( cls.glconfig.vidWidth * 480 > cls.glconfig.vidHeight * 640 ) {\n\t\t\t*x += 0.5 * ( cls.glconfig.vidWidth - ( cls.glconfig.vidHeight * 640 / 480 ) );\n\t\t}\n#endif\n\n\t// scale for screen sizes\n\txscale = cls.glconfig.vidWidth / 640.0;\n\tyscale = cls.glconfig.vidHeight / 480.0;\n\tif ( x ) {\n\t\t*x *= xscale;\n\t}\n\tif ( y ) {\n\t\t*y *= yscale;\n\t}\n\tif ( w ) {\n\t\t*w *= xscale;\n\t}\n\tif ( h ) {\n\t\t*h *= yscale;\n\t}\n}\n\n/*\n================\nSCR_FillRect\n\nCoordinates are 640*480 virtual values\n=================\n*/\nvoid SCR_FillRect( float x, float y, float width, float height, const float *color ) {\n\tre.SetColor( color );\n\n\tSCR_AdjustFrom640( &x, &y, &width, &height );\n\tre.DrawStretchPic( x, y, width, height, 0, 0, 0, 0, cls.whiteShader );\n\n\tre.SetColor( NULL );\n}\n\n\n/*\n================\nSCR_DrawPic\n\nCoordinates are 640*480 virtual values\n=================\n*/\nvoid SCR_DrawPic( float x, float y, float width, float height, qhandle_t hShader ) {\n\tSCR_AdjustFrom640( &x, &y, &width, &height );\n\tre.DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader );\n}\n\n\n\n/*\n** SCR_DrawChar\n** chars are drawn at 640*480 virtual screen size\n*/\nstatic void SCR_DrawChar( int x, int y, float size, int ch ) {\n\tint row, col;\n\tfloat frow, fcol;\n\tfloat\tax, ay, aw, ah;\n\n\tch &= 255;\n\n\tif ( ch == ' ' ) {\n\t\treturn;\n\t}\n\n\tif ( y < -size ) {\n\t\treturn;\n\t}\n\n\tax = x;\n\tay = y;\n\taw = size;\n\tah = size;\n\tSCR_AdjustFrom640( &ax, &ay, &aw, &ah );\n\n\trow = ch>>4;\n\tcol = ch&15;\n\n\tfrow = row*0.0625;\n\tfcol = col*0.0625;\n\tsize = 0.0625;\n\n\tre.DrawStretchPic( ax, ay, aw, ah,\n\t\t\t\t\t   fcol, frow, \n\t\t\t\t\t   fcol + size, frow + size, \n\t\t\t\t\t   cls.charSetShader );\n}\n\n/*\n** SCR_DrawSmallChar\n** small chars are drawn at native screen resolution\n*/\nvoid SCR_DrawSmallChar( int x, int y, int ch ) {\n\tint row, col;\n\tfloat frow, fcol;\n\tfloat size;\n\n\tch &= 255;\n\n\tif ( ch == ' ' ) {\n\t\treturn;\n\t}\n\n\tif ( y < -SMALLCHAR_HEIGHT ) {\n\t\treturn;\n\t}\n\n\trow = ch>>4;\n\tcol = ch&15;\n\n\tfrow = row*0.0625;\n\tfcol = col*0.0625;\n\tsize = 0.0625;\n\n\tre.DrawStretchPic( x, y, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT,\n\t\t\t\t\t   fcol, frow, \n\t\t\t\t\t   fcol + size, frow + size, \n\t\t\t\t\t   cls.charSetShader );\n}\n\n\n/*\n==================\nSCR_DrawBigString[Color]\n\nDraws a multi-colored string with a drop shadow, optionally forcing\nto a fixed color.\n\nCoordinates are at 640 by 480 virtual resolution\n==================\n*/\nvoid SCR_DrawStringExt( int x, int y, float size, const char *string, float *setColor, qboolean forceColor ) {\n\tvec4_t\t\tcolor;\n\tconst char\t*s;\n\tint\t\t\txx;\n\n\t// draw the drop shadow\n\tcolor[0] = color[1] = color[2] = 0;\n\tcolor[3] = setColor[3];\n\tre.SetColor( color );\n\ts = string;\n\txx = x;\n\twhile ( *s ) {\n\t\tif ( Q_IsColorString( s ) ) {\n\t\t\ts += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tSCR_DrawChar( xx+2, y+2, size, *s );\n\t\txx += size;\n\t\ts++;\n\t}\n\n\n\t// draw the colored text\n\ts = string;\n\txx = x;\n\tre.SetColor( setColor );\n\twhile ( *s ) {\n\t\tif ( Q_IsColorString( s ) ) {\n\t\t\tif ( !forceColor ) {\n\t\t\t\tCom_Memcpy( color, g_color_table[ColorIndex(*(s+1))], sizeof( color ) );\n\t\t\t\tcolor[3] = setColor[3];\n\t\t\t\tre.SetColor( color );\n\t\t\t}\n\t\t\ts += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tSCR_DrawChar( xx, y, size, *s );\n\t\txx += size;\n\t\ts++;\n\t}\n\tre.SetColor( NULL );\n}\n\n\nvoid SCR_DrawBigString( int x, int y, const char *s, float alpha ) {\n\tfloat\tcolor[4];\n\n\tcolor[0] = color[1] = color[2] = 1.0;\n\tcolor[3] = alpha;\n\tSCR_DrawStringExt( x, y, BIGCHAR_WIDTH, s, color, qfalse );\n}\n\nvoid SCR_DrawBigStringColor( int x, int y, const char *s, vec4_t color ) {\n\tSCR_DrawStringExt( x, y, BIGCHAR_WIDTH, s, color, qtrue );\n}\n\n\n/*\n==================\nSCR_DrawSmallString[Color]\n\nDraws a multi-colored string with a drop shadow, optionally forcing\nto a fixed color.\n\nCoordinates are at 640 by 480 virtual resolution\n==================\n*/\nvoid SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor, qboolean forceColor ) {\n\tvec4_t\t\tcolor;\n\tconst char\t*s;\n\tint\t\t\txx;\n\n\t// draw the colored text\n\ts = string;\n\txx = x;\n\tre.SetColor( setColor );\n\twhile ( *s ) {\n\t\tif ( Q_IsColorString( s ) ) {\n\t\t\tif ( !forceColor ) {\n\t\t\t\tCom_Memcpy( color, g_color_table[ColorIndex(*(s+1))], sizeof( color ) );\n\t\t\t\tcolor[3] = setColor[3];\n\t\t\t\tre.SetColor( color );\n\t\t\t}\n\t\t\ts += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tSCR_DrawSmallChar( xx, y, *s );\n\t\txx += SMALLCHAR_WIDTH;\n\t\ts++;\n\t}\n\tre.SetColor( NULL );\n}\n\n\n\n/*\n** SCR_Strlen -- skips color escape codes\n*/\nstatic int SCR_Strlen( const char *str ) {\n\tconst char *s = str;\n\tint count = 0;\n\n\twhile ( *s ) {\n\t\tif ( Q_IsColorString( s ) ) {\n\t\t\ts += 2;\n\t\t} else {\n\t\t\tcount++;\n\t\t\ts++;\n\t\t}\n\t}\n\n\treturn count;\n}\n\n/*\n** SCR_GetBigStringWidth\n*/ \nint\tSCR_GetBigStringWidth( const char *str ) {\n\treturn SCR_Strlen( str ) * 16;\n}\n\n\n//===============================================================================\n\n/*\n=================\nSCR_DrawDemoRecording\n=================\n*/\nvoid SCR_DrawDemoRecording( void ) {\n\tchar\tstring[1024];\n\tint\t\tpos;\n\n\tif ( !clc.demorecording ) {\n\t\treturn;\n\t}\n\tif ( clc.spDemoRecording ) {\n\t\treturn;\n\t}\n\n\tpos = FS_FTell( clc.demofile );\n\tsprintf( string, \"RECORDING %s: %ik\", clc.demoName, pos / 1024 );\n\n\tSCR_DrawStringExt( 320 - strlen( string ) * 4, 20, 8, string, g_color_table[7], qtrue );\n}\n\n\n/*\n===============================================================================\n\nDEBUG GRAPH\n\n===============================================================================\n*/\n\ntypedef struct\n{\n\tfloat\tvalue;\n\tint\t\tcolor;\n} graphsamp_t;\n\nstatic\tint\t\t\tcurrent;\nstatic\tgraphsamp_t\tvalues[1024];\n\n/*\n==============\nSCR_DebugGraph\n==============\n*/\nvoid SCR_DebugGraph (float value, int color)\n{\n\tvalues[current&1023].value = value;\n\tvalues[current&1023].color = color;\n\tcurrent++;\n}\n\n/*\n==============\nSCR_DrawDebugGraph\n==============\n*/\nvoid SCR_DrawDebugGraph (void)\n{\n\tint\t\ta, x, y, w, i, h;\n\tfloat\tv;\n\tint\t\tcolor;\n\n\t//\n\t// draw the graph\n\t//\n\tw = cls.glconfig.vidWidth;\n\tx = 0;\n\ty = cls.glconfig.vidHeight;\n\tre.SetColor( g_color_table[0] );\n\tre.DrawStretchPic(x, y - cl_graphheight->integer, \n\t\tw, cl_graphheight->integer, 0, 0, 0, 0, cls.whiteShader );\n\tre.SetColor( NULL );\n\n\tfor (a=0 ; a<w ; a++)\n\t{\n\t\ti = (current-1-a+1024) & 1023;\n\t\tv = values[i].value;\n\t\tcolor = values[i].color;\n\t\tv = v * cl_graphscale->integer + cl_graphshift->integer;\n\t\t\n\t\tif (v < 0)\n\t\t\tv += cl_graphheight->integer * (1+(int)(-v / cl_graphheight->integer));\n\t\th = (int)v % cl_graphheight->integer;\n\t\tre.DrawStretchPic( x+w-1-a, y - h, 1, h, 0, 0, 0, 0, cls.whiteShader );\n\t}\n}\n\n//=============================================================================\n\n/*\n==================\nSCR_Init\n==================\n*/\nvoid SCR_Init( void ) {\n\tcl_timegraph = Cvar_Get (\"timegraph\", \"0\", CVAR_CHEAT);\n\tcl_debuggraph = Cvar_Get (\"debuggraph\", \"0\", CVAR_CHEAT);\n\tcl_graphheight = Cvar_Get (\"graphheight\", \"32\", CVAR_CHEAT);\n\tcl_graphscale = Cvar_Get (\"graphscale\", \"1\", CVAR_CHEAT);\n\tcl_graphshift = Cvar_Get (\"graphshift\", \"0\", CVAR_CHEAT);\n\n\tscr_initialized = qtrue;\n}\n\n\n//=======================================================\n\n/*\n==================\nSCR_DrawScreenField\n\nThis will be called twice if rendering in stereo mode\n==================\n*/\nvoid SCR_DrawScreenField( stereoFrame_t stereoFrame ) {\n\tre.BeginFrame( stereoFrame );\n\n\t// wide aspect ratio screens need to have the sides cleared\n\t// unless they are displaying game renderings\n\tif ( cls.state != CA_ACTIVE ) {\n\t\tif ( cls.glconfig.vidWidth * 480 > cls.glconfig.vidHeight * 640 ) {\n\t\t\tre.SetColor( g_color_table[0] );\n\t\t\tre.DrawStretchPic( 0, 0, cls.glconfig.vidWidth, cls.glconfig.vidHeight, 0, 0, 0, 0, cls.whiteShader );\n\t\t\tre.SetColor( NULL );\n\t\t}\n\t}\n\n\tif ( !uivm ) {\n\t\tCom_DPrintf(\"draw screen without UI loaded\\n\");\n\t\treturn;\n\t}\n\n\t// if the menu is going to cover the entire screen, we\n\t// don't need to render anything under it\n\tif ( !VM_Call( uivm, UI_IS_FULLSCREEN )) {\n\t\tswitch( cls.state ) {\n\t\tdefault:\n\t\t\tCom_Error( ERR_FATAL, \"SCR_DrawScreenField: bad cls.state\" );\n\t\t\tbreak;\n\t\tcase CA_CINEMATIC:\n\t\t\tSCR_DrawCinematic();\n\t\t\tbreak;\n\t\tcase CA_DISCONNECTED:\n\t\t\t// force menu up\n\t\t\tS_StopAllSounds();\n\t\t\tVM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_MAIN );\n\t\t\tbreak;\n\t\tcase CA_CONNECTING:\n\t\tcase CA_CHALLENGING:\n\t\tcase CA_CONNECTED:\n\t\t\t// connecting clients will only show the connection dialog\n\t\t\t// refresh to update the time\n\t\t\tVM_Call( uivm, UI_REFRESH, cls.realtime );\n\t\t\tVM_Call( uivm, UI_DRAW_CONNECT_SCREEN, qfalse );\n\t\t\tbreak;\n\t\tcase CA_LOADING:\n\t\tcase CA_PRIMED:\n\t\t\t// draw the game information screen and loading progress\n\t\t\tCL_CGameRendering( stereoFrame );\n\n\t\t\t// also draw the connection information, so it doesn't\n\t\t\t// flash away too briefly on local or lan games\n\t\t\t// refresh to update the time\n\t\t\tVM_Call( uivm, UI_REFRESH, cls.realtime );\n\t\t\tVM_Call( uivm, UI_DRAW_CONNECT_SCREEN, qtrue );\n\t\t\tbreak;\n\t\tcase CA_ACTIVE:\n\t\t\tCL_CGameRendering( stereoFrame );\n\t\t\tSCR_DrawDemoRecording();\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// the menu draws next\n\tif ( cls.keyCatchers & KEYCATCH_UI && uivm ) {\n\t\tVM_Call( uivm, UI_REFRESH, cls.realtime );\n\t}\n\n\t// console draws next\n\tCon_DrawConsole ();\n\n\t// debug graph can be drawn on top of anything\n\tif ( cl_debuggraph->integer || cl_timegraph->integer || cl_debugMove->integer ) {\n\t\tSCR_DrawDebugGraph ();\n\t}\n}\n\n/*\n==================\nSCR_UpdateScreen\n\nThis is called every frame, and can also be called explicitly to flush\ntext to the screen.\n==================\n*/\nvoid SCR_UpdateScreen( void ) {\n\tstatic int\trecursive;\n\n\tif ( !scr_initialized ) {\n\t\treturn;\t\t\t\t// not initialized yet\n\t}\n\n\tif ( ++recursive > 2 ) {\n\t\tCom_Error( ERR_FATAL, \"SCR_UpdateScreen: recursively called\" );\n\t}\n\trecursive = 1;\n\n\t// if running in stereo, we need to draw the frame twice\n\tif ( cls.glconfig.stereoEnabled ) {\n\t\tSCR_DrawScreenField( STEREO_LEFT );\n\t\tSCR_DrawScreenField( STEREO_RIGHT );\n\t} else {\n\t\tSCR_DrawScreenField( STEREO_CENTER );\n\t}\n\n\tif ( com_speeds->integer ) {\n\t\tre.EndFrame( &time_frontend, &time_backend );\n\t} else {\n\t\tre.EndFrame( NULL, NULL );\n\t}\n\n\trecursive = 0;\n}\n\n"
  },
  {
    "path": "code/client/cl_ui.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"client.h\"\n\n#include \"../game/botlib.h\"\n\nextern\tbotlib_export_t\t*botlib_export;\n\nvm_t *uivm;\n\n/*\n====================\nGetClientState\n====================\n*/\nstatic void GetClientState( uiClientState_t *state ) {\n\tstate->connectPacketCount = clc.connectPacketCount;\n\tstate->connState = cls.state;\n\tQ_strncpyz( state->servername, cls.servername, sizeof( state->servername ) );\n\tQ_strncpyz( state->updateInfoString, cls.updateInfoString, sizeof( state->updateInfoString ) );\n\tQ_strncpyz( state->messageString, clc.serverMessage, sizeof( state->messageString ) );\n\tstate->clientNum = cl.snap.ps.clientNum;\n}\n\n/*\n====================\nLAN_LoadCachedServers\n====================\n*/\nvoid LAN_LoadCachedServers( ) {\n\tint size;\n\tfileHandle_t fileIn;\n\tcls.numglobalservers = cls.nummplayerservers = cls.numfavoriteservers = 0;\n\tcls.numGlobalServerAddresses = 0;\n\tif (FS_SV_FOpenFileRead(\"servercache.dat\", &fileIn)) {\n\t\tFS_Read(&cls.numglobalservers, sizeof(int), fileIn);\n\t\tFS_Read(&cls.nummplayerservers, sizeof(int), fileIn);\n\t\tFS_Read(&cls.numfavoriteservers, sizeof(int), fileIn);\n\t\tFS_Read(&size, sizeof(int), fileIn);\n\t\tif (size == sizeof(cls.globalServers) + sizeof(cls.favoriteServers) + sizeof(cls.mplayerServers)) {\n\t\t\tFS_Read(&cls.globalServers, sizeof(cls.globalServers), fileIn);\n\t\t\tFS_Read(&cls.mplayerServers, sizeof(cls.mplayerServers), fileIn);\n\t\t\tFS_Read(&cls.favoriteServers, sizeof(cls.favoriteServers), fileIn);\n\t\t} else {\n\t\t\tcls.numglobalservers = cls.nummplayerservers = cls.numfavoriteservers = 0;\n\t\t\tcls.numGlobalServerAddresses = 0;\n\t\t}\n\t\tFS_FCloseFile(fileIn);\n\t}\n}\n\n/*\n====================\nLAN_SaveServersToCache\n====================\n*/\nvoid LAN_SaveServersToCache( ) {\n\tint size;\n\tfileHandle_t fileOut = FS_SV_FOpenFileWrite(\"servercache.dat\");\n\tFS_Write(&cls.numglobalservers, sizeof(int), fileOut);\n\tFS_Write(&cls.nummplayerservers, sizeof(int), fileOut);\n\tFS_Write(&cls.numfavoriteservers, sizeof(int), fileOut);\n\tsize = sizeof(cls.globalServers) + sizeof(cls.favoriteServers) + sizeof(cls.mplayerServers);\n\tFS_Write(&size, sizeof(int), fileOut);\n\tFS_Write(&cls.globalServers, sizeof(cls.globalServers), fileOut);\n\tFS_Write(&cls.mplayerServers, sizeof(cls.mplayerServers), fileOut);\n\tFS_Write(&cls.favoriteServers, sizeof(cls.favoriteServers), fileOut);\n\tFS_FCloseFile(fileOut);\n}\n\n\n/*\n====================\nLAN_ResetPings\n====================\n*/\nstatic void LAN_ResetPings(int source) {\n\tint count,i;\n\tserverInfo_t *servers = NULL;\n\tcount = 0;\n\n\tswitch (source) {\n\t\tcase AS_LOCAL :\n\t\t\tservers = &cls.localServers[0];\n\t\t\tcount = MAX_OTHER_SERVERS;\n\t\t\tbreak;\n\t\tcase AS_MPLAYER :\n\t\t\tservers = &cls.mplayerServers[0];\n\t\t\tcount = MAX_OTHER_SERVERS;\n\t\t\tbreak;\n\t\tcase AS_GLOBAL :\n\t\t\tservers = &cls.globalServers[0];\n\t\t\tcount = MAX_GLOBAL_SERVERS;\n\t\t\tbreak;\n\t\tcase AS_FAVORITES :\n\t\t\tservers = &cls.favoriteServers[0];\n\t\t\tcount = MAX_OTHER_SERVERS;\n\t\t\tbreak;\n\t}\n\tif (servers) {\n\t\tfor (i = 0; i < count; i++) {\n\t\t\tservers[i].ping = -1;\n\t\t}\n\t}\n}\n\n/*\n====================\nLAN_AddServer\n====================\n*/\nstatic int LAN_AddServer(int source, const char *name, const char *address) {\n\tint max, *count, i;\n\tnetadr_t adr;\n\tserverInfo_t *servers = NULL;\n\tmax = MAX_OTHER_SERVERS;\n\tcount = 0;\n\n\tswitch (source) {\n\t\tcase AS_LOCAL :\n\t\t\tcount = &cls.numlocalservers;\n\t\t\tservers = &cls.localServers[0];\n\t\t\tbreak;\n\t\tcase AS_MPLAYER :\n\t\t\tcount = &cls.nummplayerservers;\n\t\t\tservers = &cls.mplayerServers[0];\n\t\t\tbreak;\n\t\tcase AS_GLOBAL :\n\t\t\tmax = MAX_GLOBAL_SERVERS;\n\t\t\tcount = &cls.numglobalservers;\n\t\t\tservers = &cls.globalServers[0];\n\t\t\tbreak;\n\t\tcase AS_FAVORITES :\n\t\t\tcount = &cls.numfavoriteservers;\n\t\t\tservers = &cls.favoriteServers[0];\n\t\t\tbreak;\n\t}\n\tif (servers && *count < max) {\n\t\tNET_StringToAdr( address, &adr );\n\t\tfor ( i = 0; i < *count; i++ ) {\n\t\t\tif (NET_CompareAdr(servers[i].adr, adr)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (i >= *count) {\n\t\t\tservers[*count].adr = adr;\n\t\t\tQ_strncpyz(servers[*count].hostName, name, sizeof(servers[*count].hostName));\n\t\t\tservers[*count].visible = qtrue;\n\t\t\t(*count)++;\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t}\n\treturn -1;\n}\n\n/*\n====================\nLAN_RemoveServer\n====================\n*/\nstatic void LAN_RemoveServer(int source, const char *addr) {\n\tint *count, i;\n\tserverInfo_t *servers = NULL;\n\tcount = 0;\n\tswitch (source) {\n\t\tcase AS_LOCAL :\n\t\t\tcount = &cls.numlocalservers;\n\t\t\tservers = &cls.localServers[0];\n\t\t\tbreak;\n\t\tcase AS_MPLAYER :\n\t\t\tcount = &cls.nummplayerservers;\n\t\t\tservers = &cls.mplayerServers[0];\n\t\t\tbreak;\n\t\tcase AS_GLOBAL :\n\t\t\tcount = &cls.numglobalservers;\n\t\t\tservers = &cls.globalServers[0];\n\t\t\tbreak;\n\t\tcase AS_FAVORITES :\n\t\t\tcount = &cls.numfavoriteservers;\n\t\t\tservers = &cls.favoriteServers[0];\n\t\t\tbreak;\n\t}\n\tif (servers) {\n\t\tnetadr_t comp;\n\t\tNET_StringToAdr( addr, &comp );\n\t\tfor (i = 0; i < *count; i++) {\n\t\t\tif (NET_CompareAdr( comp, servers[i].adr)) {\n\t\t\t\tint j = i;\n\t\t\t\twhile (j < *count - 1) {\n\t\t\t\t\tCom_Memcpy(&servers[j], &servers[j+1], sizeof(servers[j]));\n\t\t\t\t\tj++;\n\t\t\t\t}\n\t\t\t\t(*count)--;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n/*\n====================\nLAN_GetServerCount\n====================\n*/\nstatic int LAN_GetServerCount( int source ) {\n\tswitch (source) {\n\t\tcase AS_LOCAL :\n\t\t\treturn cls.numlocalservers;\n\t\t\tbreak;\n\t\tcase AS_MPLAYER :\n\t\t\treturn cls.nummplayerservers;\n\t\t\tbreak;\n\t\tcase AS_GLOBAL :\n\t\t\treturn cls.numglobalservers;\n\t\t\tbreak;\n\t\tcase AS_FAVORITES :\n\t\t\treturn cls.numfavoriteservers;\n\t\t\tbreak;\n\t}\n\treturn 0;\n}\n\n/*\n====================\nLAN_GetLocalServerAddressString\n====================\n*/\nstatic void LAN_GetServerAddressString( int source, int n, char *buf, int buflen ) {\n\tswitch (source) {\n\t\tcase AS_LOCAL :\n\t\t\tif (n >= 0 && n < MAX_OTHER_SERVERS) {\n\t\t\t\tQ_strncpyz(buf, NET_AdrToString( cls.localServers[n].adr) , buflen );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase AS_MPLAYER :\n\t\t\tif (n >= 0 && n < MAX_OTHER_SERVERS) {\n\t\t\t\tQ_strncpyz(buf, NET_AdrToString( cls.mplayerServers[n].adr) , buflen );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase AS_GLOBAL :\n\t\t\tif (n >= 0 && n < MAX_GLOBAL_SERVERS) {\n\t\t\t\tQ_strncpyz(buf, NET_AdrToString( cls.globalServers[n].adr) , buflen );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase AS_FAVORITES :\n\t\t\tif (n >= 0 && n < MAX_OTHER_SERVERS) {\n\t\t\t\tQ_strncpyz(buf, NET_AdrToString( cls.favoriteServers[n].adr) , buflen );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbreak;\n\t}\n\tbuf[0] = '\\0';\n}\n\n/*\n====================\nLAN_GetServerInfo\n====================\n*/\nstatic void LAN_GetServerInfo( int source, int n, char *buf, int buflen ) {\n\tchar info[MAX_STRING_CHARS];\n\tserverInfo_t *server = NULL;\n\tinfo[0] = '\\0';\n\tswitch (source) {\n\t\tcase AS_LOCAL :\n\t\t\tif (n >= 0 && n < MAX_OTHER_SERVERS) {\n\t\t\t\tserver = &cls.localServers[n];\n\t\t\t}\n\t\t\tbreak;\n\t\tcase AS_MPLAYER :\n\t\t\tif (n >= 0 && n < MAX_OTHER_SERVERS) {\n\t\t\t\tserver = &cls.mplayerServers[n];\n\t\t\t}\n\t\t\tbreak;\n\t\tcase AS_GLOBAL :\n\t\t\tif (n >= 0 && n < MAX_GLOBAL_SERVERS) {\n\t\t\t\tserver = &cls.globalServers[n];\n\t\t\t}\n\t\t\tbreak;\n\t\tcase AS_FAVORITES :\n\t\t\tif (n >= 0 && n < MAX_OTHER_SERVERS) {\n\t\t\t\tserver = &cls.favoriteServers[n];\n\t\t\t}\n\t\t\tbreak;\n\t}\n\tif (server && buf) {\n\t\tbuf[0] = '\\0';\n\t\tInfo_SetValueForKey( info, \"hostname\", server->hostName);\n\t\tInfo_SetValueForKey( info, \"mapname\", server->mapName);\n\t\tInfo_SetValueForKey( info, \"clients\", va(\"%i\",server->clients));\n\t\tInfo_SetValueForKey( info, \"sv_maxclients\", va(\"%i\",server->maxClients));\n\t\tInfo_SetValueForKey( info, \"ping\", va(\"%i\",server->ping));\n\t\tInfo_SetValueForKey( info, \"minping\", va(\"%i\",server->minPing));\n\t\tInfo_SetValueForKey( info, \"maxping\", va(\"%i\",server->maxPing));\n\t\tInfo_SetValueForKey( info, \"game\", server->game);\n\t\tInfo_SetValueForKey( info, \"gametype\", va(\"%i\",server->gameType));\n\t\tInfo_SetValueForKey( info, \"nettype\", va(\"%i\",server->netType));\n\t\tInfo_SetValueForKey( info, \"addr\", NET_AdrToString(server->adr));\n\t\tInfo_SetValueForKey( info, \"punkbuster\", va(\"%i\", server->punkbuster));\n\t\tQ_strncpyz(buf, info, buflen);\n\t} else {\n\t\tif (buf) {\n\t\t\tbuf[0] = '\\0';\n\t\t}\n\t}\n}\n\n/*\n====================\nLAN_GetServerPing\n====================\n*/\nstatic int LAN_GetServerPing( int source, int n ) {\n\tserverInfo_t *server = NULL;\n\tswitch (source) {\n\t\tcase AS_LOCAL :\n\t\t\tif (n >= 0 && n < MAX_OTHER_SERVERS) {\n\t\t\t\tserver = &cls.localServers[n];\n\t\t\t}\n\t\t\tbreak;\n\t\tcase AS_MPLAYER :\n\t\t\tif (n >= 0 && n < MAX_OTHER_SERVERS) {\n\t\t\t\tserver = &cls.mplayerServers[n];\n\t\t\t}\n\t\t\tbreak;\n\t\tcase AS_GLOBAL :\n\t\t\tif (n >= 0 && n < MAX_GLOBAL_SERVERS) {\n\t\t\t\tserver = &cls.globalServers[n];\n\t\t\t}\n\t\t\tbreak;\n\t\tcase AS_FAVORITES :\n\t\t\tif (n >= 0 && n < MAX_OTHER_SERVERS) {\n\t\t\t\tserver = &cls.favoriteServers[n];\n\t\t\t}\n\t\t\tbreak;\n\t}\n\tif (server) {\n\t\treturn server->ping;\n\t}\n\treturn -1;\n}\n\n/*\n====================\nLAN_GetServerPtr\n====================\n*/\nstatic serverInfo_t *LAN_GetServerPtr( int source, int n ) {\n\tswitch (source) {\n\t\tcase AS_LOCAL :\n\t\t\tif (n >= 0 && n < MAX_OTHER_SERVERS) {\n\t\t\t\treturn &cls.localServers[n];\n\t\t\t}\n\t\t\tbreak;\n\t\tcase AS_MPLAYER :\n\t\t\tif (n >= 0 && n < MAX_OTHER_SERVERS) {\n\t\t\t\treturn &cls.mplayerServers[n];\n\t\t\t}\n\t\t\tbreak;\n\t\tcase AS_GLOBAL :\n\t\t\tif (n >= 0 && n < MAX_GLOBAL_SERVERS) {\n\t\t\t\treturn &cls.globalServers[n];\n\t\t\t}\n\t\t\tbreak;\n\t\tcase AS_FAVORITES :\n\t\t\tif (n >= 0 && n < MAX_OTHER_SERVERS) {\n\t\t\t\treturn &cls.favoriteServers[n];\n\t\t\t}\n\t\t\tbreak;\n\t}\n\treturn NULL;\n}\n\n/*\n====================\nLAN_CompareServers\n====================\n*/\nstatic int LAN_CompareServers( int source, int sortKey, int sortDir, int s1, int s2 ) {\n\tint res;\n\tserverInfo_t *server1, *server2;\n\n\tserver1 = LAN_GetServerPtr(source, s1);\n\tserver2 = LAN_GetServerPtr(source, s2);\n\tif (!server1 || !server2) {\n\t\treturn 0;\n\t}\n\n\tres = 0;\n\tswitch( sortKey ) {\n\t\tcase SORT_HOST:\n\t\t\tres = Q_stricmp( server1->hostName, server2->hostName );\n\t\t\tbreak;\n\n\t\tcase SORT_MAP:\n\t\t\tres = Q_stricmp( server1->mapName, server2->mapName );\n\t\t\tbreak;\n\t\tcase SORT_CLIENTS:\n\t\t\tif (server1->clients < server2->clients) {\n\t\t\t\tres = -1;\n\t\t\t}\n\t\t\telse if (server1->clients > server2->clients) {\n\t\t\t\tres = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tres = 0;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase SORT_GAME:\n\t\t\tif (server1->gameType < server2->gameType) {\n\t\t\t\tres = -1;\n\t\t\t}\n\t\t\telse if (server1->gameType > server2->gameType) {\n\t\t\t\tres = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tres = 0;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase SORT_PING:\n\t\t\tif (server1->ping < server2->ping) {\n\t\t\t\tres = -1;\n\t\t\t}\n\t\t\telse if (server1->ping > server2->ping) {\n\t\t\t\tres = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tres = 0;\n\t\t\t}\n\t\t\tbreak;\n\t}\n\n\tif (sortDir) {\n\t\tif (res < 0)\n\t\t\treturn 1;\n\t\tif (res > 0)\n\t\t\treturn -1;\n\t\treturn 0;\n\t}\n\treturn res;\n}\n\n/*\n====================\nLAN_GetPingQueueCount\n====================\n*/\nstatic int LAN_GetPingQueueCount( void ) {\n\treturn (CL_GetPingQueueCount());\n}\n\n/*\n====================\nLAN_ClearPing\n====================\n*/\nstatic void LAN_ClearPing( int n ) {\n\tCL_ClearPing( n );\n}\n\n/*\n====================\nLAN_GetPing\n====================\n*/\nstatic void LAN_GetPing( int n, char *buf, int buflen, int *pingtime ) {\n\tCL_GetPing( n, buf, buflen, pingtime );\n}\n\n/*\n====================\nLAN_GetPingInfo\n====================\n*/\nstatic void LAN_GetPingInfo( int n, char *buf, int buflen ) {\n\tCL_GetPingInfo( n, buf, buflen );\n}\n\n/*\n====================\nLAN_MarkServerVisible\n====================\n*/\nstatic void LAN_MarkServerVisible(int source, int n, qboolean visible ) {\n\tif (n == -1) {\n\t\tint count = MAX_OTHER_SERVERS;\n\t\tserverInfo_t *server = NULL;\n\t\tswitch (source) {\n\t\t\tcase AS_LOCAL :\n\t\t\t\tserver = &cls.localServers[0];\n\t\t\t\tbreak;\n\t\t\tcase AS_MPLAYER :\n\t\t\t\tserver = &cls.mplayerServers[0];\n\t\t\t\tbreak;\n\t\t\tcase AS_GLOBAL :\n\t\t\t\tserver = &cls.globalServers[0];\n\t\t\t\tcount = MAX_GLOBAL_SERVERS;\n\t\t\t\tbreak;\n\t\t\tcase AS_FAVORITES :\n\t\t\t\tserver = &cls.favoriteServers[0];\n\t\t\t\tbreak;\n\t\t}\n\t\tif (server) {\n\t\t\tfor (n = 0; n < count; n++) {\n\t\t\t\tserver[n].visible = visible;\n\t\t\t}\n\t\t}\n\n\t} else {\n\t\tswitch (source) {\n\t\t\tcase AS_LOCAL :\n\t\t\t\tif (n >= 0 && n < MAX_OTHER_SERVERS) {\n\t\t\t\t\tcls.localServers[n].visible = visible;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase AS_MPLAYER :\n\t\t\t\tif (n >= 0 && n < MAX_OTHER_SERVERS) {\n\t\t\t\t\tcls.mplayerServers[n].visible = visible;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase AS_GLOBAL :\n\t\t\t\tif (n >= 0 && n < MAX_GLOBAL_SERVERS) {\n\t\t\t\t\tcls.globalServers[n].visible = visible;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase AS_FAVORITES :\n\t\t\t\tif (n >= 0 && n < MAX_OTHER_SERVERS) {\n\t\t\t\t\tcls.favoriteServers[n].visible = visible;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\n\n/*\n=======================\nLAN_ServerIsVisible\n=======================\n*/\nstatic int LAN_ServerIsVisible(int source, int n ) {\n\tswitch (source) {\n\t\tcase AS_LOCAL :\n\t\t\tif (n >= 0 && n < MAX_OTHER_SERVERS) {\n\t\t\t\treturn cls.localServers[n].visible;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase AS_MPLAYER :\n\t\t\tif (n >= 0 && n < MAX_OTHER_SERVERS) {\n\t\t\t\treturn cls.mplayerServers[n].visible;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase AS_GLOBAL :\n\t\t\tif (n >= 0 && n < MAX_GLOBAL_SERVERS) {\n\t\t\t\treturn cls.globalServers[n].visible;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase AS_FAVORITES :\n\t\t\tif (n >= 0 && n < MAX_OTHER_SERVERS) {\n\t\t\t\treturn cls.favoriteServers[n].visible;\n\t\t\t}\n\t\t\tbreak;\n\t}\n\treturn qfalse;\n}\n\n/*\n=======================\nLAN_UpdateVisiblePings\n=======================\n*/\nqboolean LAN_UpdateVisiblePings(int source ) {\n\treturn CL_UpdateVisiblePings_f(source);\n}\n\n/*\n====================\nLAN_GetServerStatus\n====================\n*/\nint LAN_GetServerStatus( char *serverAddress, char *serverStatus, int maxLen ) {\n\treturn CL_ServerStatus( serverAddress, serverStatus, maxLen );\n}\n\n/*\n====================\nCL_GetGlConfig\n====================\n*/\nstatic void CL_GetGlconfig( glconfig_t *config ) {\n\t*config = cls.glconfig;\n}\n\n/*\n====================\nGetClipboardData\n====================\n*/\nstatic void GetClipboardData( char *buf, int buflen ) {\n\tchar\t*cbd;\n\n\tcbd = Sys_GetClipboardData();\n\n\tif ( !cbd ) {\n\t\t*buf = 0;\n\t\treturn;\n\t}\n\n\tQ_strncpyz( buf, cbd, buflen );\n\n\tZ_Free( cbd );\n}\n\n/*\n====================\nKey_KeynumToStringBuf\n====================\n*/\nstatic void Key_KeynumToStringBuf( int keynum, char *buf, int buflen ) {\n\tQ_strncpyz( buf, Key_KeynumToString( keynum ), buflen );\n}\n\n/*\n====================\nKey_GetBindingBuf\n====================\n*/\nstatic void Key_GetBindingBuf( int keynum, char *buf, int buflen ) {\n\tchar\t*value;\n\n\tvalue = Key_GetBinding( keynum );\n\tif ( value ) {\n\t\tQ_strncpyz( buf, value, buflen );\n\t}\n\telse {\n\t\t*buf = 0;\n\t}\n}\n\n/*\n====================\nKey_GetCatcher\n====================\n*/\nint Key_GetCatcher( void ) {\n\treturn cls.keyCatchers;\n}\n\n/*\n====================\nKet_SetCatcher\n====================\n*/\nvoid Key_SetCatcher( int catcher ) {\n\tcls.keyCatchers = catcher;\n}\n\n\n/*\n====================\nCLUI_GetCDKey\n====================\n*/\nstatic void CLUI_GetCDKey( char *buf, int buflen ) {\n\tcvar_t\t*fs;\n\tfs = Cvar_Get (\"fs_game\", \"\", CVAR_INIT|CVAR_SYSTEMINFO );\n\tif (UI_usesUniqueCDKey() && fs && fs->string[0] != 0) {\n\t\tCom_Memcpy( buf, &cl_cdkey[16], 16);\n\t\tbuf[16] = 0;\n\t} else {\n\t\tCom_Memcpy( buf, cl_cdkey, 16);\n\t\tbuf[16] = 0;\n\t}\n}\n\n\n/*\n====================\nCLUI_SetCDKey\n====================\n*/\nstatic void CLUI_SetCDKey( char *buf ) {\n\tcvar_t\t*fs;\n\tfs = Cvar_Get (\"fs_game\", \"\", CVAR_INIT|CVAR_SYSTEMINFO );\n\tif (UI_usesUniqueCDKey() && fs && fs->string[0] != 0) {\n\t\tCom_Memcpy( &cl_cdkey[16], buf, 16 );\n\t\tcl_cdkey[32] = 0;\n\t\t// set the flag so the fle will be written at the next opportunity\n\t\tcvar_modifiedFlags |= CVAR_ARCHIVE;\n\t} else {\n\t\tCom_Memcpy( cl_cdkey, buf, 16 );\n\t\t// set the flag so the fle will be written at the next opportunity\n\t\tcvar_modifiedFlags |= CVAR_ARCHIVE;\n\t}\n}\n\n/*\n====================\nGetConfigString\n====================\n*/\nstatic int GetConfigString(int index, char *buf, int size)\n{\n\tint\t\toffset;\n\n\tif (index < 0 || index >= MAX_CONFIGSTRINGS)\n\t\treturn qfalse;\n\n\toffset = cl.gameState.stringOffsets[index];\n\tif (!offset) {\n\t\tif( size ) {\n\t\t\tbuf[0] = 0;\n\t\t}\n\t\treturn qfalse;\n\t}\n\n\tQ_strncpyz( buf, cl.gameState.stringData+offset, size);\n \n\treturn qtrue;\n}\n\n/*\n====================\nFloatAsInt\n====================\n*/\nstatic int FloatAsInt( float f ) {\n\tint\t\ttemp;\n\n\t*(float *)&temp = f;\n\n\treturn temp;\n}\n\nvoid *VM_ArgPtr( int intValue );\n#define\tVMA(x) VM_ArgPtr(args[x])\n#define\tVMF(x)\t((float *)args)[x]\n\n/*\n====================\nCL_UISystemCalls\n\nThe ui module is making a system call\n====================\n*/\nint CL_UISystemCalls( int *args ) {\n\tswitch( args[0] ) {\n\tcase UI_ERROR:\n\t\tCom_Error( ERR_DROP, \"%s\", VMA(1) );\n\t\treturn 0;\n\n\tcase UI_PRINT:\n\t\tCom_Printf( \"%s\", VMA(1) );\n\t\treturn 0;\n\n\tcase UI_MILLISECONDS:\n\t\treturn Sys_Milliseconds();\n\n\tcase UI_CVAR_REGISTER:\n\t\tCvar_Register( VMA(1), VMA(2), VMA(3), args[4] ); \n\t\treturn 0;\n\n\tcase UI_CVAR_UPDATE:\n\t\tCvar_Update( VMA(1) );\n\t\treturn 0;\n\n\tcase UI_CVAR_SET:\n\t\tCvar_Set( VMA(1), VMA(2) );\n\t\treturn 0;\n\n\tcase UI_CVAR_VARIABLEVALUE:\n\t\treturn FloatAsInt( Cvar_VariableValue( VMA(1) ) );\n\n\tcase UI_CVAR_VARIABLESTRINGBUFFER:\n\t\tCvar_VariableStringBuffer( VMA(1), VMA(2), args[3] );\n\t\treturn 0;\n\n\tcase UI_CVAR_SETVALUE:\n\t\tCvar_SetValue( VMA(1), VMF(2) );\n\t\treturn 0;\n\n\tcase UI_CVAR_RESET:\n\t\tCvar_Reset( VMA(1) );\n\t\treturn 0;\n\n\tcase UI_CVAR_CREATE:\n\t\tCvar_Get( VMA(1), VMA(2), args[3] );\n\t\treturn 0;\n\n\tcase UI_CVAR_INFOSTRINGBUFFER:\n\t\tCvar_InfoStringBuffer( args[1], VMA(2), args[3] );\n\t\treturn 0;\n\n\tcase UI_ARGC:\n\t\treturn Cmd_Argc();\n\n\tcase UI_ARGV:\n\t\tCmd_ArgvBuffer( args[1], VMA(2), args[3] );\n\t\treturn 0;\n\n\tcase UI_CMD_EXECUTETEXT:\n\t\tCbuf_ExecuteText( args[1], VMA(2) );\n\t\treturn 0;\n\n\tcase UI_FS_FOPENFILE:\n\t\treturn FS_FOpenFileByMode( VMA(1), VMA(2), args[3] );\n\n\tcase UI_FS_READ:\n\t\tFS_Read2( VMA(1), args[2], args[3] );\n\t\treturn 0;\n\n\tcase UI_FS_WRITE:\n\t\tFS_Write( VMA(1), args[2], args[3] );\n\t\treturn 0;\n\n\tcase UI_FS_FCLOSEFILE:\n\t\tFS_FCloseFile( args[1] );\n\t\treturn 0;\n\n\tcase UI_FS_GETFILELIST:\n\t\treturn FS_GetFileList( VMA(1), VMA(2), VMA(3), args[4] );\n\n\tcase UI_FS_SEEK:\n\t\treturn FS_Seek( args[1], args[2], args[3] );\n\t\n\tcase UI_R_REGISTERMODEL:\n\t\treturn re.RegisterModel( VMA(1) );\n\n\tcase UI_R_REGISTERSKIN:\n\t\treturn re.RegisterSkin( VMA(1) );\n\n\tcase UI_R_REGISTERSHADERNOMIP:\n\t\treturn re.RegisterShaderNoMip( VMA(1) );\n\n\tcase UI_R_CLEARSCENE:\n\t\tre.ClearScene();\n\t\treturn 0;\n\n\tcase UI_R_ADDREFENTITYTOSCENE:\n\t\tre.AddRefEntityToScene( VMA(1) );\n\t\treturn 0;\n\n\tcase UI_R_ADDPOLYTOSCENE:\n\t\tre.AddPolyToScene( args[1], args[2], VMA(3), 1 );\n\t\treturn 0;\n\n\tcase UI_R_ADDLIGHTTOSCENE:\n\t\tre.AddLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) );\n\t\treturn 0;\n\n\tcase UI_R_RENDERSCENE:\n\t\tre.RenderScene( VMA(1) );\n\t\treturn 0;\n\n\tcase UI_R_SETCOLOR:\n\t\tre.SetColor( VMA(1) );\n\t\treturn 0;\n\n\tcase UI_R_DRAWSTRETCHPIC:\n\t\tre.DrawStretchPic( VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9] );\n\t\treturn 0;\n\n  case UI_R_MODELBOUNDS:\n\t\tre.ModelBounds( args[1], VMA(2), VMA(3) );\n\t\treturn 0;\n\n\tcase UI_UPDATESCREEN:\n\t\tSCR_UpdateScreen();\n\t\treturn 0;\n\n\tcase UI_CM_LERPTAG:\n\t\tre.LerpTag( VMA(1), args[2], args[3], args[4], VMF(5), VMA(6) );\n\t\treturn 0;\n\n\tcase UI_S_REGISTERSOUND:\n\t\treturn S_RegisterSound( VMA(1), args[2] );\n\n\tcase UI_S_STARTLOCALSOUND:\n\t\tS_StartLocalSound( args[1], args[2] );\n\t\treturn 0;\n\n\tcase UI_KEY_KEYNUMTOSTRINGBUF:\n\t\tKey_KeynumToStringBuf( args[1], VMA(2), args[3] );\n\t\treturn 0;\n\n\tcase UI_KEY_GETBINDINGBUF:\n\t\tKey_GetBindingBuf( args[1], VMA(2), args[3] );\n\t\treturn 0;\n\n\tcase UI_KEY_SETBINDING:\n\t\tKey_SetBinding( args[1], VMA(2) );\n\t\treturn 0;\n\n\tcase UI_KEY_ISDOWN:\n\t\treturn Key_IsDown( args[1] );\n\n\tcase UI_KEY_GETOVERSTRIKEMODE:\n\t\treturn Key_GetOverstrikeMode();\n\n\tcase UI_KEY_SETOVERSTRIKEMODE:\n\t\tKey_SetOverstrikeMode( args[1] );\n\t\treturn 0;\n\n\tcase UI_KEY_CLEARSTATES:\n\t\tKey_ClearStates();\n\t\treturn 0;\n\n\tcase UI_KEY_GETCATCHER:\n\t\treturn Key_GetCatcher();\n\n\tcase UI_KEY_SETCATCHER:\n\t\tKey_SetCatcher( args[1] );\n\t\treturn 0;\n\n\tcase UI_GETCLIPBOARDDATA:\n\t\tGetClipboardData( VMA(1), args[2] );\n\t\treturn 0;\n\n\tcase UI_GETCLIENTSTATE:\n\t\tGetClientState( VMA(1) );\n\t\treturn 0;\t\t\n\n\tcase UI_GETGLCONFIG:\n\t\tCL_GetGlconfig( VMA(1) );\n\t\treturn 0;\n\n\tcase UI_GETCONFIGSTRING:\n\t\treturn GetConfigString( args[1], VMA(2), args[3] );\n\n\tcase UI_LAN_LOADCACHEDSERVERS:\n\t\tLAN_LoadCachedServers();\n\t\treturn 0;\n\n\tcase UI_LAN_SAVECACHEDSERVERS:\n\t\tLAN_SaveServersToCache();\n\t\treturn 0;\n\n\tcase UI_LAN_ADDSERVER:\n\t\treturn LAN_AddServer(args[1], VMA(2), VMA(3));\n\n\tcase UI_LAN_REMOVESERVER:\n\t\tLAN_RemoveServer(args[1], VMA(2));\n\t\treturn 0;\n\n\tcase UI_LAN_GETPINGQUEUECOUNT:\n\t\treturn LAN_GetPingQueueCount();\n\n\tcase UI_LAN_CLEARPING:\n\t\tLAN_ClearPing( args[1] );\n\t\treturn 0;\n\n\tcase UI_LAN_GETPING:\n\t\tLAN_GetPing( args[1], VMA(2), args[3], VMA(4) );\n\t\treturn 0;\n\n\tcase UI_LAN_GETPINGINFO:\n\t\tLAN_GetPingInfo( args[1], VMA(2), args[3] );\n\t\treturn 0;\n\n\tcase UI_LAN_GETSERVERCOUNT:\n\t\treturn LAN_GetServerCount(args[1]);\n\n\tcase UI_LAN_GETSERVERADDRESSSTRING:\n\t\tLAN_GetServerAddressString( args[1], args[2], VMA(3), args[4] );\n\t\treturn 0;\n\n\tcase UI_LAN_GETSERVERINFO:\n\t\tLAN_GetServerInfo( args[1], args[2], VMA(3), args[4] );\n\t\treturn 0;\n\n\tcase UI_LAN_GETSERVERPING:\n\t\treturn LAN_GetServerPing( args[1], args[2] );\n\n\tcase UI_LAN_MARKSERVERVISIBLE:\n\t\tLAN_MarkServerVisible( args[1], args[2], args[3] );\n\t\treturn 0;\n\n\tcase UI_LAN_SERVERISVISIBLE:\n\t\treturn LAN_ServerIsVisible( args[1], args[2] );\n\n\tcase UI_LAN_UPDATEVISIBLEPINGS:\n\t\treturn LAN_UpdateVisiblePings( args[1] );\n\n\tcase UI_LAN_RESETPINGS:\n\t\tLAN_ResetPings( args[1] );\n\t\treturn 0;\n\n\tcase UI_LAN_SERVERSTATUS:\n\t\treturn LAN_GetServerStatus( VMA(1), VMA(2), args[3] );\n\n\tcase UI_LAN_COMPARESERVERS:\n\t\treturn LAN_CompareServers( args[1], args[2], args[3], args[4], args[5] );\n\n\tcase UI_MEMORY_REMAINING:\n\t\treturn Hunk_MemoryRemaining();\n\n\tcase UI_GET_CDKEY:\n\t\tCLUI_GetCDKey( VMA(1), args[2] );\n\t\treturn 0;\n\n\tcase UI_SET_CDKEY:\n\t\tCLUI_SetCDKey( VMA(1) );\n\t\treturn 0;\n\t\n\tcase UI_SET_PBCLSTATUS:\n\t\treturn 0;\t\n\n\tcase UI_R_REGISTERFONT:\n\t\tre.RegisterFont( VMA(1), args[2], VMA(3));\n\t\treturn 0;\n\n\tcase UI_MEMSET:\n\t\tCom_Memset( VMA(1), args[2], args[3] );\n\t\treturn 0;\n\n\tcase UI_MEMCPY:\n\t\tCom_Memcpy( VMA(1), VMA(2), args[3] );\n\t\treturn 0;\n\n\tcase UI_STRNCPY:\n\t\treturn (int)strncpy( VMA(1), VMA(2), args[3] );\n\n\tcase UI_SIN:\n\t\treturn FloatAsInt( sin( VMF(1) ) );\n\n\tcase UI_COS:\n\t\treturn FloatAsInt( cos( VMF(1) ) );\n\n\tcase UI_ATAN2:\n\t\treturn FloatAsInt( atan2( VMF(1), VMF(2) ) );\n\n\tcase UI_SQRT:\n\t\treturn FloatAsInt( sqrt( VMF(1) ) );\n\n\tcase UI_FLOOR:\n\t\treturn FloatAsInt( floor( VMF(1) ) );\n\n\tcase UI_CEIL:\n\t\treturn FloatAsInt( ceil( VMF(1) ) );\n\n\tcase UI_PC_ADD_GLOBAL_DEFINE:\n\t\treturn botlib_export->PC_AddGlobalDefine( VMA(1) );\n\tcase UI_PC_LOAD_SOURCE:\n\t\treturn botlib_export->PC_LoadSourceHandle( VMA(1) );\n\tcase UI_PC_FREE_SOURCE:\n\t\treturn botlib_export->PC_FreeSourceHandle( args[1] );\n\tcase UI_PC_READ_TOKEN:\n\t\treturn botlib_export->PC_ReadTokenHandle( args[1], VMA(2) );\n\tcase UI_PC_SOURCE_FILE_AND_LINE:\n\t\treturn botlib_export->PC_SourceFileAndLine( args[1], VMA(2), VMA(3) );\n\n\tcase UI_S_STOPBACKGROUNDTRACK:\n\t\tS_StopBackgroundTrack();\n\t\treturn 0;\n\tcase UI_S_STARTBACKGROUNDTRACK:\n\t\tS_StartBackgroundTrack( VMA(1), VMA(2));\n\t\treturn 0;\n\n\tcase UI_REAL_TIME:\n\t\treturn Com_RealTime( VMA(1) );\n\n\tcase UI_CIN_PLAYCINEMATIC:\n\t  Com_DPrintf(\"UI_CIN_PlayCinematic\\n\");\n\t  return CIN_PlayCinematic(VMA(1), args[2], args[3], args[4], args[5], args[6]);\n\n\tcase UI_CIN_STOPCINEMATIC:\n\t  return CIN_StopCinematic(args[1]);\n\n\tcase UI_CIN_RUNCINEMATIC:\n\t  return CIN_RunCinematic(args[1]);\n\n\tcase UI_CIN_DRAWCINEMATIC:\n\t  CIN_DrawCinematic(args[1]);\n\t  return 0;\n\n\tcase UI_CIN_SETEXTENTS:\n\t  CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]);\n\t  return 0;\n\n\tcase UI_R_REMAP_SHADER:\n\t\tre.RemapShader( VMA(1), VMA(2), VMA(3) );\n\t\treturn 0;\n\n\tcase UI_VERIFY_CDKEY:\n\t\treturn CL_CDKeyValidate(VMA(1), VMA(2));\n\n\n\t\t\n\tdefault:\n\t\tCom_Error( ERR_DROP, \"Bad UI system trap: %i\", args[0] );\n\n\t}\n\n\treturn 0;\n}\n\n/*\n====================\nCL_ShutdownUI\n====================\n*/\nvoid CL_ShutdownUI( void ) {\n\tcls.keyCatchers &= ~KEYCATCH_UI;\n\tcls.uiStarted = qfalse;\n\tif ( !uivm ) {\n\t\treturn;\n\t}\n\tVM_Call( uivm, UI_SHUTDOWN );\n\tVM_Free( uivm );\n\tuivm = NULL;\n}\n\n/*\n====================\nCL_InitUI\n====================\n*/\n#define UI_OLD_API_VERSION\t4\n\nvoid CL_InitUI( void ) {\n\tint\t\tv;\n\tvmInterpret_t\t\tinterpret;\n\n\t// load the dll or bytecode\n\tif ( cl_connectedToPureServer != 0 ) {\n\t\t// if sv_pure is set we only allow qvms to be loaded\n\t\tinterpret = VMI_COMPILED;\n\t}\n\telse {\n\t\tinterpret = Cvar_VariableValue( \"vm_ui\" );\n\t}\n\tuivm = VM_Create( \"ui\", CL_UISystemCalls, interpret );\n\tif ( !uivm ) {\n\t\tCom_Error( ERR_FATAL, \"VM_Create on UI failed\" );\n\t}\n\n\t// sanity check\n\tv = VM_Call( uivm, UI_GETAPIVERSION );\n\tif (v == UI_OLD_API_VERSION) {\n//\t\tCom_Printf(S_COLOR_YELLOW \"WARNING: loading old Quake III Arena User Interface version %d\\n\", v );\n\t\t// init for this gamestate\n\t\tVM_Call( uivm, UI_INIT, (cls.state >= CA_AUTHORIZING && cls.state < CA_ACTIVE));\n\t}\n\telse if (v != UI_API_VERSION) {\n\t\tCom_Error( ERR_DROP, \"User Interface is version %d, expected %d\", v, UI_API_VERSION );\n\t\tcls.uiStarted = qfalse;\n\t}\n\telse {\n\t\t// init for this gamestate\n\t\tVM_Call( uivm, UI_INIT, (cls.state >= CA_AUTHORIZING && cls.state < CA_ACTIVE) );\n\t}\n}\n\nqboolean UI_usesUniqueCDKey() {\n\tif (uivm) {\n\t\treturn (VM_Call( uivm, UI_HASUNIQUECDKEY) == qtrue);\n\t} else {\n\t\treturn qfalse;\n\t}\n}\n\n/*\n====================\nUI_GameCommand\n\nSee if the current console command is claimed by the ui\n====================\n*/\nqboolean UI_GameCommand( void ) {\n\tif ( !uivm ) {\n\t\treturn qfalse;\n\t}\n\n\treturn VM_Call( uivm, UI_CONSOLE_COMMAND, cls.realtime );\n}\n"
  },
  {
    "path": "code/client/client.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// client.h -- primary header for client\n\n#include \"../game/q_shared.h\"\n#include \"../qcommon/qcommon.h\"\n#include \"../renderer/tr_public.h\"\n#include \"../ui/ui_public.h\"\n#include \"keys.h\"\n#include \"snd_public.h\"\n#include \"../cgame/cg_public.h\"\n#include \"../game/bg_public.h\"\n\n#define\tRETRANSMIT_TIMEOUT\t3000\t// time between connection packet retransmits\n\n\n// snapshots are a view of the server at a given time\ntypedef struct {\n\tqboolean\t\tvalid;\t\t\t// cleared if delta parsing was invalid\n\tint\t\t\t\tsnapFlags;\t\t// rate delayed and dropped commands\n\n\tint\t\t\t\tserverTime;\t\t// server time the message is valid for (in msec)\n\n\tint\t\t\t\tmessageNum;\t\t// copied from netchan->incoming_sequence\n\tint\t\t\t\tdeltaNum;\t\t// messageNum the delta is from\n\tint\t\t\t\tping;\t\t\t// time from when cmdNum-1 was sent to time packet was reeceived\n\tbyte\t\t\tareamask[MAX_MAP_AREA_BYTES];\t\t// portalarea visibility bits\n\n\tint\t\t\t\tcmdNum;\t\t\t// the next cmdNum the server is expecting\n\tplayerState_t\tps;\t\t\t\t\t\t// complete information about the current player at this time\n\n\tint\t\t\t\tnumEntities;\t\t\t// all of the entities that need to be presented\n\tint\t\t\t\tparseEntitiesNum;\t\t// at the time of this snapshot\n\n\tint\t\t\t\tserverCommandNum;\t\t// execute all commands up to this before\n\t\t\t\t\t\t\t\t\t\t\t// making the snapshot current\n} clSnapshot_t;\n\n\n\n/*\n=============================================================================\n\nthe clientActive_t structure is wiped completely at every\nnew gamestate_t, potentially several times during an established connection\n\n=============================================================================\n*/\n\ntypedef struct {\n\tint\t\tp_cmdNumber;\t\t// cl.cmdNumber when packet was sent\n\tint\t\tp_serverTime;\t\t// usercmd->serverTime when packet was sent\n\tint\t\tp_realtime;\t\t\t// cls.realtime when packet was sent\n} outPacket_t;\n\n// the parseEntities array must be large enough to hold PACKET_BACKUP frames of\n// entities, so that when a delta compressed message arives from the server\n// it can be un-deltad from the original \n#define\tMAX_PARSE_ENTITIES\t2048\n\nextern int g_console_field_width;\n\ntypedef struct {\n\tint\t\t\ttimeoutcount;\t\t// it requres several frames in a timeout condition\n\t\t\t\t\t\t\t\t\t// to disconnect, preventing debugging breaks from\n\t\t\t\t\t\t\t\t\t// causing immediate disconnects on continue\n\tclSnapshot_t\tsnap;\t\t\t// latest received from server\n\n\tint\t\t\tserverTime;\t\t\t// may be paused during play\n\tint\t\t\toldServerTime;\t\t// to prevent time from flowing bakcwards\n\tint\t\t\toldFrameServerTime;\t// to check tournament restarts\n\tint\t\t\tserverTimeDelta;\t// cl.serverTime = cls.realtime + cl.serverTimeDelta\n\t\t\t\t\t\t\t\t\t// this value changes as net lag varies\n\tqboolean\textrapolatedSnapshot;\t// set if any cgame frame has been forced to extrapolate\n\t\t\t\t\t\t\t\t\t// cleared when CL_AdjustTimeDelta looks at it\n\tqboolean\tnewSnapshots;\t\t// set on parse of any valid packet\n\n\tgameState_t\tgameState;\t\t\t// configstrings\n\tchar\t\tmapname[MAX_QPATH];\t// extracted from CS_SERVERINFO\n\n\tint\t\t\tparseEntitiesNum;\t// index (not anded off) into cl_parse_entities[]\n\n\tint\t\t\tmouseDx[2], mouseDy[2];\t// added to by mouse events\n\tint\t\t\tmouseIndex;\n\tint\t\t\tjoystickAxis[MAX_JOYSTICK_AXIS];\t// set by joystick events\n\n\t// cgame communicates a few values to the client system\n\tint\t\t\tcgameUserCmdValue;\t// current weapon to add to usercmd_t\n\tfloat\t\tcgameSensitivity;\n\n\t// cmds[cmdNumber] is the predicted command, [cmdNumber-1] is the last\n\t// properly generated command\n\tusercmd_t\tcmds[CMD_BACKUP];\t// each mesage will send several old cmds\n\tint\t\t\tcmdNumber;\t\t\t// incremented each frame, because multiple\n\t\t\t\t\t\t\t\t\t// frames may need to be packed into a single packet\n\n\toutPacket_t\toutPackets[PACKET_BACKUP];\t// information about each packet we have sent out\n\n\t// the client maintains its own idea of view angles, which are\n\t// sent to the server each frame.  It is cleared to 0 upon entering each level.\n\t// the server sends a delta each frame which is added to the locally\n\t// tracked view angles to account for standing on rotating objects,\n\t// and teleport direction changes\n\tvec3_t\t\tviewangles;\n\n\tint\t\t\tserverId;\t\t\t// included in each client message so the server\n\t\t\t\t\t\t\t\t\t\t\t\t// can tell if it is for a prior map_restart\n\t// big stuff at end of structure so most offsets are 15 bits or less\n\tclSnapshot_t\tsnapshots[PACKET_BACKUP];\n\n\tentityState_t\tentityBaselines[MAX_GENTITIES];\t// for delta compression when not in previous frame\n\n\tentityState_t\tparseEntities[MAX_PARSE_ENTITIES];\n} clientActive_t;\n\nextern\tclientActive_t\t\tcl;\n\n/*\n=============================================================================\n\nthe clientConnection_t structure is wiped when disconnecting from a server,\neither to go to a full screen console, play a demo, or connect to a different server\n\nA connection can be to either a server through the network layer or a\ndemo through a file.\n\n=============================================================================\n*/\n\n\ntypedef struct {\n\n\tint\t\t\tclientNum;\n\tint\t\t\tlastPacketSentTime;\t\t\t// for retransmits during connection\n\tint\t\t\tlastPacketTime;\t\t\t\t// for timeouts\n\n\tnetadr_t\tserverAddress;\n\tint\t\t\tconnectTime;\t\t\t\t// for connection retransmits\n\tint\t\t\tconnectPacketCount;\t\t\t// for display on connection dialog\n\tchar\t\tserverMessage[MAX_STRING_TOKENS];\t// for display on connection dialog\n\n\tint\t\t\tchallenge;\t\t\t\t\t// from the server to use for connecting\n\tint\t\t\tchecksumFeed;\t\t\t\t// from the server for checksum calculations\n\n\t// these are our reliable messages that go to the server\n\tint\t\t\treliableSequence;\n\tint\t\t\treliableAcknowledge;\t\t// the last one the server has executed\n\tchar\t\treliableCommands[MAX_RELIABLE_COMMANDS][MAX_STRING_CHARS];\n\n\t// server message (unreliable) and command (reliable) sequence\n\t// numbers are NOT cleared at level changes, but continue to\n\t// increase as long as the connection is valid\n\n\t// message sequence is used by both the network layer and the\n\t// delta compression layer\n\tint\t\t\tserverMessageSequence;\n\n\t// reliable messages received from server\n\tint\t\t\tserverCommandSequence;\n\tint\t\t\tlastExecutedServerCommand;\t\t// last server command grabbed or executed with CL_GetServerCommand\n\tchar\t\tserverCommands[MAX_RELIABLE_COMMANDS][MAX_STRING_CHARS];\n\n\t// file transfer from server\n\tfileHandle_t download;\n\tchar\t\tdownloadTempName[MAX_OSPATH];\n\tchar\t\tdownloadName[MAX_OSPATH];\n\tint\t\t\tdownloadNumber;\n\tint\t\t\tdownloadBlock;\t// block we are waiting for\n\tint\t\t\tdownloadCount;\t// how many bytes we got\n\tint\t\t\tdownloadSize;\t// how many bytes we got\n\tchar\t\tdownloadList[MAX_INFO_STRING]; // list of paks we need to download\n\tqboolean\tdownloadRestart;\t// if true, we need to do another FS_Restart because we downloaded a pak\n\n\t// demo information\n\tchar\t\tdemoName[MAX_QPATH];\n\tqboolean\tspDemoRecording;\n\tqboolean\tdemorecording;\n\tqboolean\tdemoplaying;\n\tqboolean\tdemowaiting;\t// don't record until a non-delta message is received\n\tqboolean\tfirstDemoFrameSkipped;\n\tfileHandle_t\tdemofile;\n\n\tint\t\t\ttimeDemoFrames;\t\t// counter of rendered frames\n\tint\t\t\ttimeDemoStart;\t\t// cls.realtime before first frame\n\tint\t\t\ttimeDemoBaseTime;\t// each frame will be at this time + frameNum * 50\n\n\t// big stuff at end of structure so most offsets are 15 bits or less\n\tnetchan_t\tnetchan;\n} clientConnection_t;\n\nextern\tclientConnection_t clc;\n\n/*\n==================================================================\n\nthe clientStatic_t structure is never wiped, and is used even when\nno client connection is active at all\n\n==================================================================\n*/\n\ntypedef struct {\n\tnetadr_t\tadr;\n\tint\t\t\tstart;\n\tint\t\t\ttime;\n\tchar\t\tinfo[MAX_INFO_STRING];\n} ping_t;\n\ntypedef struct {\n\tnetadr_t\tadr;\n\tchar\t  \thostName[MAX_NAME_LENGTH];\n\tchar\t  \tmapName[MAX_NAME_LENGTH];\n\tchar\t  \tgame[MAX_NAME_LENGTH];\n\tint\t\t\tnetType;\n\tint\t\t\tgameType;\n\tint\t\t  \tclients;\n\tint\t\t  \tmaxClients;\n\tint\t\t\tminPing;\n\tint\t\t\tmaxPing;\n\tint\t\t\tping;\n\tqboolean\tvisible;\n\tint\t\t\tpunkbuster;\n} serverInfo_t;\n\ntypedef struct {\n\tbyte\tip[4];\n\tunsigned short\tport;\n} serverAddress_t;\n\ntypedef struct {\n\tconnstate_t\tstate;\t\t\t\t// connection status\n\tint\t\t\tkeyCatchers;\t\t// bit flags\n\n\tqboolean\tcddialog;\t\t\t// bring up the cd needed dialog next frame\n\n\tchar\t\tservername[MAX_OSPATH];\t\t// name of server from original connect (used by reconnect)\n\n\t// when the server clears the hunk, all of these must be restarted\n\tqboolean\trendererStarted;\n\tqboolean\tsoundStarted;\n\tqboolean\tsoundRegistered;\n\tqboolean\tuiStarted;\n\tqboolean\tcgameStarted;\n\n\tint\t\t\tframecount;\n\tint\t\t\tframetime;\t\t\t// msec since last frame\n\n\tint\t\t\trealtime;\t\t\t// ignores pause\n\tint\t\t\trealFrametime;\t\t// ignoring pause, so console always works\n\n\tint\t\t\tnumlocalservers;\n\tserverInfo_t\tlocalServers[MAX_OTHER_SERVERS];\n\n\tint\t\t\tnumglobalservers;\n\tserverInfo_t  globalServers[MAX_GLOBAL_SERVERS];\n\t// additional global servers\n\tint\t\t\tnumGlobalServerAddresses;\n\tserverAddress_t\t\tglobalServerAddresses[MAX_GLOBAL_SERVERS];\n\n\tint\t\t\tnumfavoriteservers;\n\tserverInfo_t\tfavoriteServers[MAX_OTHER_SERVERS];\n\n\tint\t\t\tnummplayerservers;\n\tserverInfo_t\tmplayerServers[MAX_OTHER_SERVERS];\n\n\tint pingUpdateSource;\t\t// source currently pinging or updating\n\n\tint masterNum;\n\n\t// update server info\n\tnetadr_t\tupdateServer;\n\tchar\t\tupdateChallenge[MAX_TOKEN_CHARS];\n\tchar\t\tupdateInfoString[MAX_INFO_STRING];\n\n\tnetadr_t\tauthorizeServer;\n\n\t// rendering info\n\tglconfig_t\tglconfig;\n\tqhandle_t\tcharSetShader;\n\tqhandle_t\twhiteShader;\n\tqhandle_t\tconsoleShader;\n} clientStatic_t;\n\nextern\tclientStatic_t\t\tcls;\n\n//=============================================================================\n\nextern\tvm_t\t\t\t*cgvm;\t// interface to cgame dll or vm\nextern\tvm_t\t\t\t*uivm;\t// interface to ui dll or vm\nextern\trefexport_t\t\tre;\t\t// interface to refresh .dll\n\n\n//\n// cvars\n//\nextern\tcvar_t\t*cl_nodelta;\nextern\tcvar_t\t*cl_debugMove;\nextern\tcvar_t\t*cl_noprint;\nextern\tcvar_t\t*cl_timegraph;\nextern\tcvar_t\t*cl_maxpackets;\nextern\tcvar_t\t*cl_packetdup;\nextern\tcvar_t\t*cl_shownet;\nextern\tcvar_t\t*cl_showSend;\nextern\tcvar_t\t*cl_timeNudge;\nextern\tcvar_t\t*cl_showTimeDelta;\nextern\tcvar_t\t*cl_freezeDemo;\n\nextern\tcvar_t\t*cl_yawspeed;\nextern\tcvar_t\t*cl_pitchspeed;\nextern\tcvar_t\t*cl_run;\nextern\tcvar_t\t*cl_anglespeedkey;\n\nextern\tcvar_t\t*cl_sensitivity;\nextern\tcvar_t\t*cl_freelook;\n\nextern\tcvar_t\t*cl_mouseAccel;\nextern\tcvar_t\t*cl_showMouseRate;\n\nextern\tcvar_t\t*m_pitch;\nextern\tcvar_t\t*m_yaw;\nextern\tcvar_t\t*m_forward;\nextern\tcvar_t\t*m_side;\nextern\tcvar_t\t*m_filter;\n\nextern\tcvar_t\t*cl_timedemo;\n\nextern\tcvar_t\t*cl_activeAction;\n\nextern\tcvar_t\t*cl_allowDownload;\nextern\tcvar_t\t*cl_conXOffset;\nextern\tcvar_t\t*cl_inGameVideo;\n\n//=================================================\n\n//\n// cl_main\n//\n\nvoid CL_Init (void);\nvoid CL_FlushMemory(void);\nvoid CL_ShutdownAll(void);\nvoid CL_AddReliableCommand( const char *cmd );\n\nvoid CL_StartHunkUsers( void );\n\nvoid CL_Disconnect_f (void);\nvoid CL_GetChallengePacket (void);\nvoid CL_Vid_Restart_f( void );\nvoid CL_Snd_Restart_f (void);\nvoid CL_StartDemoLoop( void );\nvoid CL_NextDemo( void );\nvoid CL_ReadDemoMessage( void );\n\nvoid CL_InitDownloads(void);\nvoid CL_NextDownload(void);\n\nvoid CL_GetPing( int n, char *buf, int buflen, int *pingtime );\nvoid CL_GetPingInfo( int n, char *buf, int buflen );\nvoid CL_ClearPing( int n );\nint CL_GetPingQueueCount( void );\n\nvoid CL_ShutdownRef( void );\nvoid CL_InitRef( void );\nqboolean CL_CDKeyValidate( const char *key, const char *checksum );\nint CL_ServerStatus( char *serverAddress, char *serverStatusString, int maxLen );\n\n\n//\n// cl_input\n//\ntypedef struct {\n\tint\t\t\tdown[2];\t\t// key nums holding it down\n\tunsigned\tdowntime;\t\t// msec timestamp\n\tunsigned\tmsec;\t\t\t// msec down this frame if both a down and up happened\n\tqboolean\tactive;\t\t\t// current state\n\tqboolean\twasPressed;\t\t// set when down, not cleared when up\n} kbutton_t;\n\nextern\tkbutton_t\tin_mlook, in_klook;\nextern \tkbutton_t \tin_strafe;\nextern \tkbutton_t \tin_speed;\n\nvoid CL_InitInput (void);\nvoid CL_SendCmd (void);\nvoid CL_ClearState (void);\nvoid CL_ReadPackets (void);\n\nvoid CL_WritePacket( void );\nvoid IN_CenterView (void);\n\nvoid CL_VerifyCode( void );\n\nfloat CL_KeyState (kbutton_t *key);\nchar *Key_KeynumToString (int keynum);\n\n//\n// cl_parse.c\n//\nextern int cl_connectedToPureServer;\n\nvoid CL_SystemInfoChanged( void );\nvoid CL_ParseServerMessage( msg_t *msg );\n\n//====================================================================\n\nvoid\tCL_ServerInfoPacket( netadr_t from, msg_t *msg );\nvoid\tCL_LocalServers_f( void );\nvoid\tCL_GlobalServers_f( void );\nvoid\tCL_FavoriteServers_f( void );\nvoid\tCL_Ping_f( void );\nqboolean CL_UpdateVisiblePings_f( int source );\n\n\n//\n// console\n//\nvoid Con_DrawCharacter (int cx, int line, int num);\n\nvoid Con_CheckResize (void);\nvoid Con_Init (void);\nvoid Con_Clear_f (void);\nvoid Con_ToggleConsole_f (void);\nvoid Con_DrawNotify (void);\nvoid Con_ClearNotify (void);\nvoid Con_RunConsole (void);\nvoid Con_DrawConsole (void);\nvoid Con_PageUp( void );\nvoid Con_PageDown( void );\nvoid Con_Top( void );\nvoid Con_Bottom( void );\nvoid Con_Close( void );\n\n\n//\n// cl_scrn.c\n//\nvoid\tSCR_Init (void);\nvoid\tSCR_UpdateScreen (void);\n\nvoid\tSCR_DebugGraph (float value, int color);\n\nint\t\tSCR_GetBigStringWidth( const char *str );\t// returns in virtual 640x480 coordinates\n\nvoid\tSCR_AdjustFrom640( float *x, float *y, float *w, float *h );\nvoid\tSCR_FillRect( float x, float y, float width, float height, \n\t\t\t\t\t const float *color );\nvoid\tSCR_DrawPic( float x, float y, float width, float height, qhandle_t hShader );\nvoid\tSCR_DrawNamedPic( float x, float y, float width, float height, const char *picname );\n\nvoid\tSCR_DrawBigString( int x, int y, const char *s, float alpha );\t\t\t// draws a string with embedded color control characters with fade\nvoid\tSCR_DrawBigStringColor( int x, int y, const char *s, vec4_t color );\t// ignores embedded color control characters\nvoid\tSCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor, qboolean forceColor );\nvoid\tSCR_DrawSmallChar( int x, int y, int ch );\n\n\n//\n// cl_cin.c\n//\n\nvoid CL_PlayCinematic_f( void );\nvoid SCR_DrawCinematic (void);\nvoid SCR_RunCinematic (void);\nvoid SCR_StopCinematic (void);\nint CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits);\ne_status CIN_StopCinematic(int handle);\ne_status CIN_RunCinematic (int handle);\nvoid CIN_DrawCinematic (int handle);\nvoid CIN_SetExtents (int handle, int x, int y, int w, int h);\nvoid CIN_SetLooping (int handle, qboolean loop);\nvoid CIN_UploadCinematic(int handle);\nvoid CIN_CloseAllVideos(void);\n\n//\n// cl_cgame.c\n//\nvoid CL_InitCGame( void );\nvoid CL_ShutdownCGame( void );\nqboolean CL_GameCommand( void );\nvoid CL_CGameRendering( stereoFrame_t stereo );\nvoid CL_SetCGameTime( void );\nvoid CL_FirstSnapshot( void );\nvoid CL_ShaderStateChanged(void);\n\n//\n// cl_ui.c\n//\nvoid CL_InitUI( void );\nvoid CL_ShutdownUI( void );\nint Key_GetCatcher( void );\nvoid Key_SetCatcher( int catcher );\nvoid LAN_LoadCachedServers();\nvoid LAN_SaveServersToCache();\n\n\n//\n// cl_net_chan.c\n//\nvoid CL_Netchan_Transmit( netchan_t *chan, msg_t* msg);\t//int length, const byte *data );\nvoid CL_Netchan_TransmitNextFragment( netchan_t *chan );\nqboolean CL_Netchan_Process( netchan_t *chan, msg_t *msg );\n"
  },
  {
    "path": "code/client/keys.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"../ui/keycodes.h\"\n\n#define\tMAX_KEYS\t\t256\n\ntypedef struct {\n\tqboolean\tdown;\n\tint\t\t\trepeats;\t\t// if > 1, it is autorepeating\n\tchar\t\t*binding;\n} qkey_t;\n\nextern\tqboolean\tkey_overstrikeMode;\nextern\tqkey_t\t\tkeys[MAX_KEYS];\n\n// NOTE TTimo the declaration of field_t and Field_Clear is now in qcommon/qcommon.h\nvoid Field_KeyDownEvent( field_t *edit, int key );\nvoid Field_CharEvent( field_t *edit, int ch );\nvoid Field_Draw( field_t *edit, int x, int y, int width, qboolean showCursor );\nvoid Field_BigDraw( field_t *edit, int x, int y, int width, qboolean showCursor );\n\n#define\t\tCOMMAND_HISTORY\t\t32\nextern\tfield_t\thistoryEditLines[COMMAND_HISTORY];\n\nextern\tfield_t\tg_consoleField;\nextern\tfield_t\tchatField;\nextern\tqboolean\tanykeydown;\nextern\tqboolean\tchat_team;\nextern\tint\t\t\tchat_playerNum;\n\nvoid Key_WriteBindings( fileHandle_t f );\nvoid Key_SetBinding( int keynum, const char *binding );\nchar *Key_GetBinding( int keynum );\nqboolean Key_IsDown( int keynum );\nqboolean Key_GetOverstrikeMode( void );\nvoid Key_SetOverstrikeMode( qboolean state );\nvoid Key_ClearStates( void );\nint Key_GetKey(const char *binding);\n"
  },
  {
    "path": "code/client/snd_adpcm.c",
    "content": "/***********************************************************\nCopyright 1992 by Stichting Mathematisch Centrum, Amsterdam, The\nNetherlands.\n\n                        All Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its \ndocumentation for any purpose and without fee is hereby granted, \nprovided that the above copyright notice appear in all copies and that\nboth that copyright notice and this permission notice appear in \nsupporting documentation, and that the names of Stichting Mathematisch\nCentrum or CWI not be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior permission.\n\nSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO\nTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE\nFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\nACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT\nOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n\n******************************************************************/\n\n/*\n** Intel/DVI ADPCM coder/decoder.\n**\n** The algorithm for this coder was taken from the IMA Compatability Project\n** proceedings, Vol 2, Number 2; May 1992.\n**\n** Version 1.2, 18-Dec-92.\n*/\n\n#include \"snd_local.h\"\n\n\n/* Intel ADPCM step variation table */\nstatic int indexTable[16] = {\n    -1, -1, -1, -1, 2, 4, 6, 8,\n    -1, -1, -1, -1, 2, 4, 6, 8,\n};\n\nstatic int stepsizeTable[89] = {\n    7, 8, 9, 10, 11, 12, 13, 14, 16, 17,\n    19, 21, 23, 25, 28, 31, 34, 37, 41, 45,\n    50, 55, 60, 66, 73, 80, 88, 97, 107, 118,\n    130, 143, 157, 173, 190, 209, 230, 253, 279, 307,\n    337, 371, 408, 449, 494, 544, 598, 658, 724, 796,\n    876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,\n    2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,\n    5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,\n    15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767\n};\n\n   \nvoid S_AdpcmEncode( short indata[], char outdata[], int len, struct adpcm_state *state ) {\n    short *inp;\t\t\t/* Input buffer pointer */\n    signed char *outp;\t\t/* output buffer pointer */\n    int val;\t\t\t/* Current input sample value */\n    int sign;\t\t\t/* Current adpcm sign bit */\n    int delta;\t\t\t/* Current adpcm output value */\n    int diff;\t\t\t/* Difference between val and sample */\n    int step;\t\t\t/* Stepsize */\n    int valpred;\t\t/* Predicted output value */\n    int vpdiff;\t\t\t/* Current change to valpred */\n    int index;\t\t\t/* Current step change index */\n    int outputbuffer;\t\t/* place to keep previous 4-bit value */\n    int bufferstep;\t\t/* toggle between outputbuffer/output */\n\n    outp = (signed char *)outdata;\n    inp = indata;\n\n    valpred = state->sample;\n    index = state->index;\n    step = stepsizeTable[index];\n    \n\toutputbuffer = 0;\t// quiet a compiler warning\n    bufferstep = 1;\n\n    for ( ; len > 0 ; len-- ) {\n\t\tval = *inp++;\n\n\t\t/* Step 1 - compute difference with previous value */\n\t\tdiff = val - valpred;\n\t\tsign = (diff < 0) ? 8 : 0;\n\t\tif ( sign ) diff = (-diff);\n\n\t\t/* Step 2 - Divide and clamp */\n\t\t/* Note:\n\t\t** This code *approximately* computes:\n\t\t**    delta = diff*4/step;\n\t\t**    vpdiff = (delta+0.5)*step/4;\n\t\t** but in shift step bits are dropped. The net result of this is\n\t\t** that even if you have fast mul/div hardware you cannot put it to\n\t\t** good use since the fixup would be too expensive.\n\t\t*/\n\t\tdelta = 0;\n\t\tvpdiff = (step >> 3);\n\t\t\n\t\tif ( diff >= step ) {\n\t\t\tdelta = 4;\n\t\t\tdiff -= step;\n\t\t\tvpdiff += step;\n\t\t}\n\t\tstep >>= 1;\n\t\tif ( diff >= step  ) {\n\t\t\tdelta |= 2;\n\t\t\tdiff -= step;\n\t\t\tvpdiff += step;\n\t\t}\n\t\tstep >>= 1;\n\t\tif ( diff >= step ) {\n\t\t\tdelta |= 1;\n\t\t\tvpdiff += step;\n\t\t}\n\n\t\t/* Step 3 - Update previous value */\n\t\tif ( sign )\n\t\t  valpred -= vpdiff;\n\t\telse\n\t\t  valpred += vpdiff;\n\n\t\t/* Step 4 - Clamp previous value to 16 bits */\n\t\tif ( valpred > 32767 )\n\t\t  valpred = 32767;\n\t\telse if ( valpred < -32768 )\n\t\t  valpred = -32768;\n\n\t\t/* Step 5 - Assemble value, update index and step values */\n\t\tdelta |= sign;\n\t\t\n\t\tindex += indexTable[delta];\n\t\tif ( index < 0 ) index = 0;\n\t\tif ( index > 88 ) index = 88;\n\t\tstep = stepsizeTable[index];\n\n\t\t/* Step 6 - Output value */\n\t\tif ( bufferstep ) {\n\t\t\toutputbuffer = (delta << 4) & 0xf0;\n\t\t} else {\n\t\t\t*outp++ = (delta & 0x0f) | outputbuffer;\n\t\t}\n\t\tbufferstep = !bufferstep;\n    }\n\n    /* Output last step, if needed */\n    if ( !bufferstep )\n      *outp++ = outputbuffer;\n    \n    state->sample = valpred;\n    state->index = index;\n}\n\n\n/* static */ void S_AdpcmDecode( const char indata[], short *outdata, int len, struct adpcm_state *state ) {\n    signed char *inp;\t\t/* Input buffer pointer */\n    int outp;\t\t\t/* output buffer pointer */\n    int sign;\t\t\t/* Current adpcm sign bit */\n    int delta;\t\t\t/* Current adpcm output value */\n    int step;\t\t\t/* Stepsize */\n    int valpred;\t\t/* Predicted value */\n    int vpdiff;\t\t\t/* Current change to valpred */\n    int index;\t\t\t/* Current step change index */\n    int inputbuffer;\t\t/* place to keep next 4-bit value */\n    int bufferstep;\t\t/* toggle between inputbuffer/input */\n\n    outp = 0;\n    inp = (signed char *)indata;\n\n    valpred = state->sample;\n    index = state->index;\n    step = stepsizeTable[index];\n\n    bufferstep = 0;\n    inputbuffer = 0;\t// quiet a compiler warning\n    for ( ; len > 0 ; len-- ) {\n\t\t\n\t\t/* Step 1 - get the delta value */\n\t\tif ( bufferstep ) {\n\t\t\tdelta = inputbuffer & 0xf;\n\t\t} else {\n\t\t\tinputbuffer = *inp++;\n\t\t\tdelta = (inputbuffer >> 4) & 0xf;\n\t\t}\n\t\tbufferstep = !bufferstep;\n\n\t\t/* Step 2 - Find new index value (for later) */\n\t\tindex += indexTable[delta];\n\t\tif ( index < 0 ) index = 0;\n\t\tif ( index > 88 ) index = 88;\n\n\t\t/* Step 3 - Separate sign and magnitude */\n\t\tsign = delta & 8;\n\t\tdelta = delta & 7;\n\n\t\t/* Step 4 - Compute difference and new predicted value */\n\t\t/*\n\t\t** Computes 'vpdiff = (delta+0.5)*step/4', but see comment\n\t\t** in adpcm_coder.\n\t\t*/\n\t\tvpdiff = step >> 3;\n\t\tif ( delta & 4 ) vpdiff += step;\n\t\tif ( delta & 2 ) vpdiff += step>>1;\n\t\tif ( delta & 1 ) vpdiff += step>>2;\n\n\t\tif ( sign )\n\t\t  valpred -= vpdiff;\n\t\telse\n\t\t  valpred += vpdiff;\n\n\t\t/* Step 5 - clamp output value */\n\t\tif ( valpred > 32767 )\n\t\t  valpred = 32767;\n\t\telse if ( valpred < -32768 )\n\t\t  valpred = -32768;\n\n\t\t/* Step 6 - Update step value */\n\t\tstep = stepsizeTable[index];\n\n\t\t/* Step 7 - Output value */\n\t\toutdata[outp] = valpred;\n\t\toutp++;\n    }\n\n    state->sample = valpred;\n    state->index = index;\n}\n\n\n/*\n====================\nS_AdpcmMemoryNeeded\n\nReturns the amount of memory (in bytes) needed to store the samples in out internal adpcm format\n====================\n*/\nint S_AdpcmMemoryNeeded( const wavinfo_t *info ) {\n\tfloat\tscale;\n\tint\t\tscaledSampleCount;\n\tint\t\tsampleMemory;\n\tint\t\tblockCount;\n\tint\t\theaderMemory;\n\n\t// determine scale to convert from input sampling rate to desired sampling rate\n\tscale = (float)info->rate / dma.speed;\n\n\t// calc number of samples at playback sampling rate\n\tscaledSampleCount = info->samples / scale;\n\n\t// calc memory need to store those samples using ADPCM at 4 bits per sample\n\tsampleMemory = scaledSampleCount / 2;\n\n\t// calc number of sample blocks needed of PAINTBUFFER_SIZE\n\tblockCount = scaledSampleCount / PAINTBUFFER_SIZE;\n\tif( scaledSampleCount % PAINTBUFFER_SIZE ) {\n\t\tblockCount++;\n\t}\n\n\t// calc memory needed to store the block headers\n\theaderMemory = blockCount * sizeof(adpcm_state_t);\n\n\treturn sampleMemory + headerMemory;\n}\n\n\n/*\n====================\nS_AdpcmGetSamples\n====================\n*/\nvoid S_AdpcmGetSamples(sndBuffer *chunk, short *to) {\n\tadpcm_state_t\tstate;\n\tbyte\t\t\t*out;\n\n\t// get the starting state from the block header\n\tstate.index = chunk->adpcm.index;\n\tstate.sample = chunk->adpcm.sample;\n\n\tout = (byte *)chunk->sndChunk;\n\t// get samples\n\tS_AdpcmDecode( out, to, SND_CHUNK_SIZE_BYTE*2, &state );\n}\n\n\n/*\n====================\nS_AdpcmEncodeSound\n====================\n*/\nvoid S_AdpcmEncodeSound( sfx_t *sfx, short *samples ) {\n\tadpcm_state_t\tstate;\n\tint\t\t\t\tinOffset;\n\tint\t\t\t\tcount;\n\tint\t\t\t\tn;\n\tsndBuffer\t\t*newchunk, *chunk;\n\tbyte\t\t\t*out;\n\n\tinOffset = 0;\n\tcount = sfx->soundLength;\n\tstate.index = 0;\n\tstate.sample = samples[0];\n\n\tchunk = NULL;\n\twhile( count ) {\n\t\tn = count;\n\t\tif( n > SND_CHUNK_SIZE_BYTE*2 ) {\n\t\t\tn = SND_CHUNK_SIZE_BYTE*2;\n\t\t}\n\n\t\tnewchunk = SND_malloc();\n\t\tif (sfx->soundData == NULL) {\n\t\t\tsfx->soundData = newchunk;\n\t\t} else {\n\t\t\tchunk->next = newchunk;\n\t\t}\n\t\tchunk = newchunk;\n\n\t\t// output the header\n\t\tchunk->adpcm.index  = state.index;\n\t\tchunk->adpcm.sample = state.sample;\n\n\t\tout = (byte *)chunk->sndChunk;\n\n\t\t// encode the samples\n\t\tS_AdpcmEncode( samples + inOffset, out, n, &state );\n\n\t\tinOffset += n;\n\t\tcount -= n;\n\t}\n}\n"
  },
  {
    "path": "code/client/snd_dma.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tsnd_dma.c\n *\n * desc:\t\tmain control for any streaming sound output device\n *\n * $Archive: /MissionPack/code/client/snd_dma.c $\n *\n *****************************************************************************/\n\n#include \"snd_local.h\"\n#include \"client.h\"\n\nvoid S_Play_f(void);\nvoid S_SoundList_f(void);\nvoid S_Music_f(void);\n\nvoid S_Update_();\nvoid S_StopAllSounds(void);\nvoid S_UpdateBackgroundTrack( void );\n\nstatic fileHandle_t s_backgroundFile;\nstatic wavinfo_t\ts_backgroundInfo;\n//int\t\t\ts_nextWavChunk;\nstatic int\t\t\ts_backgroundSamples;\nstatic char\t\ts_backgroundLoop[MAX_QPATH];\n//static char\t\ts_backgroundMusic[MAX_QPATH]; //TTimo: unused\n\n\n// =======================================================================\n// Internal sound data & structures\n// =======================================================================\n\n// only begin attenuating sound volumes when outside the FULLVOLUME range\n#define\t\tSOUND_FULLVOLUME\t80\n\n#define\t\tSOUND_ATTENUATE\t\t0.0008f\n\nchannel_t   s_channels[MAX_CHANNELS];\nchannel_t   loop_channels[MAX_CHANNELS];\nint\t\t\tnumLoopChannels;\n\nstatic int\ts_soundStarted;\nstatic\t\tqboolean\ts_soundMuted;\n\ndma_t\t\tdma;\n\nstatic int\t\t\tlistener_number;\nstatic vec3_t\t\tlistener_origin;\nstatic vec3_t\t\tlistener_axis[3];\n\nint\t\t\ts_soundtime;\t\t// sample PAIRS\nint   \t\ts_paintedtime; \t\t// sample PAIRS\n\n// MAX_SFX may be larger than MAX_SOUNDS because\n// of custom player sounds\n#define\t\tMAX_SFX\t\t\t4096\nsfx_t\t\ts_knownSfx[MAX_SFX];\nint\t\t\ts_numSfx = 0;\n\n#define\t\tLOOP_HASH\t\t128\nstatic\tsfx_t\t\t*sfxHash[LOOP_HASH];\n\ncvar_t\t\t*s_volume;\ncvar_t\t\t*s_testsound;\ncvar_t\t\t*s_khz;\ncvar_t\t\t*s_show;\ncvar_t\t\t*s_mixahead;\ncvar_t\t\t*s_mixPreStep;\ncvar_t\t\t*s_musicVolume;\ncvar_t\t\t*s_separation;\ncvar_t\t\t*s_doppler;\n\nstatic loopSound_t\t\tloopSounds[MAX_GENTITIES];\nstatic\tchannel_t\t\t*freelist = NULL;\n\nint\t\t\t\t\t\ts_rawend;\nportable_samplepair_t\ts_rawsamples[MAX_RAW_SAMPLES];\n\n\n// ====================================================================\n// User-setable variables\n// ====================================================================\n\n\nvoid S_SoundInfo_f(void) {\t\n\tCom_Printf(\"----- Sound Info -----\\n\" );\n\tif (!s_soundStarted) {\n\t\tCom_Printf (\"sound system not started\\n\");\n\t} else {\n\t\tif ( s_soundMuted ) {\n\t\t\tCom_Printf (\"sound system is muted\\n\");\n\t\t}\n\n\t\tCom_Printf(\"%5d stereo\\n\", dma.channels - 1);\n\t\tCom_Printf(\"%5d samples\\n\", dma.samples);\n\t\tCom_Printf(\"%5d samplebits\\n\", dma.samplebits);\n\t\tCom_Printf(\"%5d submission_chunk\\n\", dma.submission_chunk);\n\t\tCom_Printf(\"%5d speed\\n\", dma.speed);\n\t\tCom_Printf(\"0x%x dma buffer\\n\", dma.buffer);\n\t\tif ( s_backgroundFile ) {\n\t\t\tCom_Printf(\"Background file: %s\\n\", s_backgroundLoop );\n\t\t} else {\n\t\t\tCom_Printf(\"No background file.\\n\" );\n\t\t}\n\n\t}\n\tCom_Printf(\"----------------------\\n\" );\n}\n\n\n\n/*\n================\nS_Init\n================\n*/\nvoid S_Init( void ) {\n\tcvar_t\t*cv;\n\tqboolean\tr;\n\n\tCom_Printf(\"\\n------- sound initialization -------\\n\");\n\n\ts_volume = Cvar_Get (\"s_volume\", \"0.8\", CVAR_ARCHIVE);\n\ts_musicVolume = Cvar_Get (\"s_musicvolume\", \"0.25\", CVAR_ARCHIVE);\n\ts_separation = Cvar_Get (\"s_separation\", \"0.5\", CVAR_ARCHIVE);\n\ts_doppler = Cvar_Get (\"s_doppler\", \"1\", CVAR_ARCHIVE);\n\ts_khz = Cvar_Get (\"s_khz\", \"22\", CVAR_ARCHIVE);\n\ts_mixahead = Cvar_Get (\"s_mixahead\", \"0.2\", CVAR_ARCHIVE);\n\n\ts_mixPreStep = Cvar_Get (\"s_mixPreStep\", \"0.05\", CVAR_ARCHIVE);\n\ts_show = Cvar_Get (\"s_show\", \"0\", CVAR_CHEAT);\n\ts_testsound = Cvar_Get (\"s_testsound\", \"0\", CVAR_CHEAT);\n\n\tcv = Cvar_Get (\"s_initsound\", \"1\", 0);\n\tif ( !cv->integer ) {\n\t\tCom_Printf (\"not initializing.\\n\");\n\t\tCom_Printf(\"------------------------------------\\n\");\n\t\treturn;\n\t}\n\n\tCmd_AddCommand(\"play\", S_Play_f);\n\tCmd_AddCommand(\"music\", S_Music_f);\n\tCmd_AddCommand(\"s_list\", S_SoundList_f);\n\tCmd_AddCommand(\"s_info\", S_SoundInfo_f);\n\tCmd_AddCommand(\"s_stop\", S_StopAllSounds);\n\n\tr = SNDDMA_Init();\n\tCom_Printf(\"------------------------------------\\n\");\n\n\tif ( r ) {\n\t\ts_soundStarted = 1;\n\t\ts_soundMuted = 1;\n//\t\ts_numSfx = 0;\n\n\t\tCom_Memset(sfxHash, 0, sizeof(sfx_t *)*LOOP_HASH);\n\n\t\ts_soundtime = 0;\n\t\ts_paintedtime = 0;\n\n\t\tS_StopAllSounds ();\n\n\t\tS_SoundInfo_f();\n\t}\n\n}\n\n\nvoid S_ChannelFree(channel_t *v) {\n\tv->thesfx = NULL;\n\t*(channel_t **)v = freelist;\n\tfreelist = (channel_t*)v;\n}\n\nchannel_t*\tS_ChannelMalloc() {\n\tchannel_t *v;\n\tif (freelist == NULL) {\n\t\treturn NULL;\n\t}\n\tv = freelist;\n\tfreelist = *(channel_t **)freelist;\n\tv->allocTime = Com_Milliseconds();\n\treturn v;\n}\n\nvoid S_ChannelSetup() {\n\tchannel_t *p, *q;\n\n\t// clear all the sounds so they don't\n\tCom_Memset( s_channels, 0, sizeof( s_channels ) );\n\n\tp = s_channels;;\n\tq = p + MAX_CHANNELS;\n\twhile (--q > p) {\n\t\t*(channel_t **)q = q-1;\n\t}\n\t\n\t*(channel_t **)q = NULL;\n\tfreelist = p + MAX_CHANNELS - 1;\n\tCom_DPrintf(\"Channel memory manager started\\n\");\n}\n\n// =======================================================================\n// Shutdown sound engine\n// =======================================================================\n\nvoid S_Shutdown( void ) {\n\tif ( !s_soundStarted ) {\n\t\treturn;\n\t}\n\n\tSNDDMA_Shutdown();\n\n\ts_soundStarted = 0;\n\n    Cmd_RemoveCommand(\"play\");\n\tCmd_RemoveCommand(\"music\");\n\tCmd_RemoveCommand(\"stopsound\");\n\tCmd_RemoveCommand(\"soundlist\");\n\tCmd_RemoveCommand(\"soundinfo\");\n}\n\n\n// =======================================================================\n// Load a sound\n// =======================================================================\n\n/*\n================\nreturn a hash value for the sfx name\n================\n*/\nstatic long S_HashSFXName(const char *name) {\n\tint\t\ti;\n\tlong\thash;\n\tchar\tletter;\n\n\thash = 0;\n\ti = 0;\n\twhile (name[i] != '\\0') {\n\t\tletter = tolower(name[i]);\n\t\tif (letter =='.') break;\t\t\t\t// don't include extension\n\t\tif (letter =='\\\\') letter = '/';\t\t// damn path names\n\t\thash+=(long)(letter)*(i+119);\n\t\ti++;\n\t}\n\thash &= (LOOP_HASH-1);\n\treturn hash;\n}\n\n/*\n==================\nS_FindName\n\nWill allocate a new sfx if it isn't found\n==================\n*/\nstatic sfx_t *S_FindName( const char *name ) {\n\tint\t\ti;\n\tint\t\thash;\n\n\tsfx_t\t*sfx;\n\n\tif (!name) {\n\t\tCom_Error (ERR_FATAL, \"S_FindName: NULL\\n\");\n\t}\n\tif (!name[0]) {\n\t\tCom_Error (ERR_FATAL, \"S_FindName: empty name\\n\");\n\t}\n\n\tif (strlen(name) >= MAX_QPATH) {\n\t\tCom_Error (ERR_FATAL, \"Sound name too long: %s\", name);\n\t}\n\n\thash = S_HashSFXName(name);\n\n\tsfx = sfxHash[hash];\n\t// see if already loaded\n\twhile (sfx) {\n\t\tif (!Q_stricmp(sfx->soundName, name) ) {\n\t\t\treturn sfx;\n\t\t}\n\t\tsfx = sfx->next;\n\t}\n\n\t// find a free sfx\n\tfor (i=0 ; i < s_numSfx ; i++) {\n\t\tif (!s_knownSfx[i].soundName[0]) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (i == s_numSfx) {\n\t\tif (s_numSfx == MAX_SFX) {\n\t\t\tCom_Error (ERR_FATAL, \"S_FindName: out of sfx_t\");\n\t\t}\n\t\ts_numSfx++;\n\t}\n\t\n\tsfx = &s_knownSfx[i];\n\tCom_Memset (sfx, 0, sizeof(*sfx));\n\tstrcpy (sfx->soundName, name);\n\n\tsfx->next = sfxHash[hash];\n\tsfxHash[hash] = sfx;\n\n\treturn sfx;\n}\n\n/*\n=================\nS_DefaultSound\n=================\n*/\nvoid S_DefaultSound( sfx_t *sfx ) {\n\t\n\tint\t\ti;\n\n\tsfx->soundLength = 512;\n\tsfx->soundData = SND_malloc();\n\tsfx->soundData->next = NULL;\n\n\n\tfor ( i = 0 ; i < sfx->soundLength ; i++ ) {\n\t\tsfx->soundData->sndChunk[i] = i;\n\t}\n}\n\n/*\n===================\nS_DisableSounds\n\nDisables sounds until the next S_BeginRegistration.\nThis is called when the hunk is cleared and the sounds\nare no longer valid.\n===================\n*/\nvoid S_DisableSounds( void ) {\n\tS_StopAllSounds();\n\ts_soundMuted = qtrue;\n}\n\n/*\n=====================\nS_BeginRegistration\n\n=====================\n*/\nvoid S_BeginRegistration( void ) {\n\ts_soundMuted = qfalse;\t\t// we can play again\n\n\tif (s_numSfx == 0) {\n\t\tSND_setup();\n\n\t\ts_numSfx = 0;\n\t\tCom_Memset( s_knownSfx, 0, sizeof( s_knownSfx ) );\n\t\tCom_Memset(sfxHash, 0, sizeof(sfx_t *)*LOOP_HASH);\n\n\t\tS_RegisterSound(\"sound/feedback/hit.wav\", qfalse);\t\t// changed to a sound in baseq3\n\t}\n}\n\n\n/*\n==================\nS_RegisterSound\n\nCreates a default buzz sound if the file can't be loaded\n==================\n*/\nsfxHandle_t\tS_RegisterSound( const char *name, qboolean compressed ) {\n\tsfx_t\t*sfx;\n\n\tcompressed = qfalse;\n\tif (!s_soundStarted) {\n\t\treturn 0;\n\t}\n\n\tif ( strlen( name ) >= MAX_QPATH ) {\n\t\tCom_Printf( \"Sound name exceeds MAX_QPATH\\n\" );\n\t\treturn 0;\n\t}\n\n\tsfx = S_FindName( name );\n\tif ( sfx->soundData ) {\n\t\tif ( sfx->defaultSound ) {\n\t\t\tCom_Printf( S_COLOR_YELLOW \"WARNING: could not find %s - using default\\n\", sfx->soundName );\n\t\t\treturn 0;\n\t\t}\n\t\treturn sfx - s_knownSfx;\n\t}\n\n\tsfx->inMemory = qfalse;\n\tsfx->soundCompressed = compressed;\n\n  S_memoryLoad(sfx);\n\n\tif ( sfx->defaultSound ) {\n\t\tCom_Printf( S_COLOR_YELLOW \"WARNING: could not find %s - using default\\n\", sfx->soundName );\n\t\treturn 0;\n\t}\n\n\treturn sfx - s_knownSfx;\n}\n\nvoid S_memoryLoad(sfx_t\t*sfx) {\n\t// load the sound file\n\tif ( !S_LoadSound ( sfx ) ) {\n//\t\tCom_Printf( S_COLOR_YELLOW \"WARNING: couldn't load sound: %s\\n\", sfx->soundName );\n\t\tsfx->defaultSound = qtrue;\n\t}\n\tsfx->inMemory = qtrue;\n}\n\n//=============================================================================\n\n/*\n=================\nS_SpatializeOrigin\n\nUsed for spatializing s_channels\n=================\n*/\nvoid S_SpatializeOrigin (vec3_t origin, int master_vol, int *left_vol, int *right_vol)\n{\n    vec_t\t\tdot;\n    vec_t\t\tdist;\n    vec_t\t\tlscale, rscale, scale;\n    vec3_t\t\tsource_vec;\n    vec3_t\t\tvec;\n\n\tconst float dist_mult = SOUND_ATTENUATE;\n\t\n\t// calculate stereo seperation and distance attenuation\n\tVectorSubtract(origin, listener_origin, source_vec);\n\n\tdist = VectorNormalize(source_vec);\n\tdist -= SOUND_FULLVOLUME;\n\tif (dist < 0)\n\t\tdist = 0;\t\t\t// close enough to be at full volume\n\tdist *= dist_mult;\t\t// different attenuation levels\n\t\n\tVectorRotate( source_vec, listener_axis, vec );\n\n\tdot = -vec[1];\n\n\tif (dma.channels == 1)\n\t{ // no attenuation = no spatialization\n\t\trscale = 1.0;\n\t\tlscale = 1.0;\n\t}\n\telse\n\t{\n\t\trscale = 0.5 * (1.0 + dot);\n\t\tlscale = 0.5 * (1.0 - dot);\n\t\t//rscale = s_separation->value + ( 1.0 - s_separation->value ) * dot;\n\t\t//lscale = s_separation->value - ( 1.0 - s_separation->value ) * dot;\n\t\tif ( rscale < 0 ) {\n\t\t\trscale = 0;\n\t\t}\n\t\tif ( lscale < 0 ) {\n\t\t\tlscale = 0;\n\t\t}\n\t}\n\n\t// add in distance effect\n\tscale = (1.0 - dist) * rscale;\n\t*right_vol = (master_vol * scale);\n\tif (*right_vol < 0)\n\t\t*right_vol = 0;\n\n\tscale = (1.0 - dist) * lscale;\n\t*left_vol = (master_vol * scale);\n\tif (*left_vol < 0)\n\t\t*left_vol = 0;\n}\n\n// =======================================================================\n// Start a sound effect\n// =======================================================================\n\n/*\n====================\nS_StartSound\n\nValidates the parms and ques the sound up\nif pos is NULL, the sound will be dynamically sourced from the entity\nEntchannel 0 will never override a playing sound\n====================\n*/\nvoid S_StartSound(vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfxHandle ) {\n\tchannel_t\t*ch;\n\tsfx_t\t\t*sfx;\n  int i, oldest, chosen, time;\n  int\tinplay, allowed;\n\n\tif ( !s_soundStarted || s_soundMuted ) {\n\t\treturn;\n\t}\n\n\tif ( !origin && ( entityNum < 0 || entityNum > MAX_GENTITIES ) ) {\n\t\tCom_Error( ERR_DROP, \"S_StartSound: bad entitynum %i\", entityNum );\n\t}\n\n\tif ( sfxHandle < 0 || sfxHandle >= s_numSfx ) {\n\t\tCom_Printf( S_COLOR_YELLOW, \"S_StartSound: handle %i out of range\\n\", sfxHandle );\n\t\treturn;\n\t}\n\n\tsfx = &s_knownSfx[ sfxHandle ];\n\n\tif (sfx->inMemory == qfalse) {\n\t\tS_memoryLoad(sfx);\n\t}\n\n\tif ( s_show->integer == 1 ) {\n\t\tCom_Printf( \"%i : %s\\n\", s_paintedtime, sfx->soundName );\n\t}\n\n\ttime = Com_Milliseconds();\n\n//\tCom_Printf(\"playing %s\\n\", sfx->soundName);\n\t// pick a channel to play on\n\n\tallowed = 4;\n\tif (entityNum == listener_number) {\n\t\tallowed = 8;\n\t}\n\n\tch = s_channels;\n\tinplay = 0;\n\tfor ( i = 0; i < MAX_CHANNELS ; i++, ch++ ) {\t\t\n\t\tif (ch[i].entnum == entityNum && ch[i].thesfx == sfx) {\n\t\t\tif (time - ch[i].allocTime < 50) {\n//\t\t\t\tif (Cvar_VariableValue( \"cg_showmiss\" )) {\n//\t\t\t\t\tCom_Printf(\"double sound start\\n\");\n//\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tinplay++;\n\t\t}\n\t}\n\n\tif (inplay>allowed) {\n\t\treturn;\n\t}\n\n\tsfx->lastTimeUsed = time;\n\n\tch = S_ChannelMalloc();\t// entityNum, entchannel);\n\tif (!ch) {\n\t\tch = s_channels;\n\n\t\toldest = sfx->lastTimeUsed;\n\t\tchosen = -1;\n\t\tfor ( i = 0 ; i < MAX_CHANNELS ; i++, ch++ ) {\n\t\t\tif (ch->entnum != listener_number && ch->entnum == entityNum && ch->allocTime<oldest && ch->entchannel != CHAN_ANNOUNCER) {\n\t\t\t\toldest = ch->allocTime;\n\t\t\t\tchosen = i;\n\t\t\t}\n\t\t}\n\t\tif (chosen == -1) {\n\t\t\tch = s_channels;\n\t\t\tfor ( i = 0 ; i < MAX_CHANNELS ; i++, ch++ ) {\n\t\t\t\tif (ch->entnum != listener_number && ch->allocTime<oldest && ch->entchannel != CHAN_ANNOUNCER) {\n\t\t\t\t\toldest = ch->allocTime;\n\t\t\t\t\tchosen = i;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (chosen == -1) {\n\t\t\t\tif (ch->entnum == listener_number) {\n\t\t\t\t\tfor ( i = 0 ; i < MAX_CHANNELS ; i++, ch++ ) {\n\t\t\t\t\t\tif (ch->allocTime<oldest) {\n\t\t\t\t\t\t\toldest = ch->allocTime;\n\t\t\t\t\t\t\tchosen = i;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (chosen == -1) {\n\t\t\t\t\tCom_Printf(\"dropping sound\\n\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tch = &s_channels[chosen];\n\t\tch->allocTime = sfx->lastTimeUsed;\n\t}\n\n\tif (origin) {\n\t\tVectorCopy (origin, ch->origin);\n\t\tch->fixed_origin = qtrue;\n\t} else {\n\t\tch->fixed_origin = qfalse;\n\t}\n\n\tch->master_vol = 127;\n\tch->entnum = entityNum;\n\tch->thesfx = sfx;\n\tch->startSample = START_SAMPLE_IMMEDIATE;\n\tch->entchannel = entchannel;\n\tch->leftvol = ch->master_vol;\t\t// these will get calced at next spatialize\n\tch->rightvol = ch->master_vol;\t\t// unless the game isn't running\n\tch->doppler = qfalse;\n}\n\n\n/*\n==================\nS_StartLocalSound\n==================\n*/\nvoid S_StartLocalSound( sfxHandle_t sfxHandle, int channelNum ) {\n\tif ( !s_soundStarted || s_soundMuted ) {\n\t\treturn;\n\t}\n\n\tif ( sfxHandle < 0 || sfxHandle >= s_numSfx ) {\n\t\tCom_Printf( S_COLOR_YELLOW, \"S_StartLocalSound: handle %i out of range\\n\", sfxHandle );\n\t\treturn;\n\t}\n\n\tS_StartSound (NULL, listener_number, channelNum, sfxHandle );\n}\n\n\n/*\n==================\nS_ClearSoundBuffer\n\nIf we are about to perform file access, clear the buffer\nso sound doesn't stutter.\n==================\n*/\nvoid S_ClearSoundBuffer( void ) {\n\tint\t\tclear;\n\t\t\n\tif (!s_soundStarted)\n\t\treturn;\n\n\t// stop looping sounds\n\tCom_Memset(loopSounds, 0, MAX_GENTITIES*sizeof(loopSound_t));\n\tCom_Memset(loop_channels, 0, MAX_CHANNELS*sizeof(channel_t));\n\tnumLoopChannels = 0;\n\n\tS_ChannelSetup();\n\n\ts_rawend = 0;\n\n\tif (dma.samplebits == 8)\n\t\tclear = 0x80;\n\telse\n\t\tclear = 0;\n\n\tSNDDMA_BeginPainting ();\n\tif (dma.buffer)\n    // TTimo: due to a particular bug workaround in linux sound code,\n    //   have to optionally use a custom C implementation of Com_Memset\n    //   not affecting win32, we have #define Snd_Memset Com_Memset\n    // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=371\n\t\tSnd_Memset(dma.buffer, clear, dma.samples * dma.samplebits/8);\n\tSNDDMA_Submit ();\n}\n\n/*\n==================\nS_StopAllSounds\n==================\n*/\nvoid S_StopAllSounds(void) {\n\tif ( !s_soundStarted ) {\n\t\treturn;\n\t}\n\n\t// stop the background music\n\tS_StopBackgroundTrack();\n\n\tS_ClearSoundBuffer ();\n}\n\n/*\n==============================================================\n\ncontinuous looping sounds are added each frame\n\n==============================================================\n*/\n\nvoid S_StopLoopingSound(int entityNum) {\n\tloopSounds[entityNum].active = qfalse;\n//\tloopSounds[entityNum].sfx = 0;\n\tloopSounds[entityNum].kill = qfalse;\n}\n\n/*\n==================\nS_ClearLoopingSounds\n\n==================\n*/\nvoid S_ClearLoopingSounds( qboolean killall ) {\n\tint i;\n\tfor ( i = 0 ; i < MAX_GENTITIES ; i++) {\n\t\tif (killall || loopSounds[i].kill == qtrue || (loopSounds[i].sfx && loopSounds[i].sfx->soundLength == 0)) {\n\t\t\tloopSounds[i].kill = qfalse;\n\t\t\tS_StopLoopingSound(i);\n\t\t}\n\t}\n\tnumLoopChannels = 0;\n}\n\n/*\n==================\nS_AddLoopingSound\n\nCalled during entity generation for a frame\nInclude velocity in case I get around to doing doppler...\n==================\n*/\nvoid S_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfxHandle ) {\n\tsfx_t *sfx;\n\n\tif ( !s_soundStarted || s_soundMuted ) {\n\t\treturn;\n\t}\n\n\tif ( sfxHandle < 0 || sfxHandle >= s_numSfx ) {\n\t\tCom_Printf( S_COLOR_YELLOW, \"S_AddLoopingSound: handle %i out of range\\n\", sfxHandle );\n\t\treturn;\n\t}\n\n\tsfx = &s_knownSfx[ sfxHandle ];\n\n\tif (sfx->inMemory == qfalse) {\n\t\tS_memoryLoad(sfx);\n\t}\n\n\tif ( !sfx->soundLength ) {\n\t\tCom_Error( ERR_DROP, \"%s has length 0\", sfx->soundName );\n\t}\n\n\tVectorCopy( origin, loopSounds[entityNum].origin );\n\tVectorCopy( velocity, loopSounds[entityNum].velocity );\n\tloopSounds[entityNum].active = qtrue;\n\tloopSounds[entityNum].kill = qtrue;\n\tloopSounds[entityNum].doppler = qfalse;\n\tloopSounds[entityNum].oldDopplerScale = 1.0;\n\tloopSounds[entityNum].dopplerScale = 1.0;\n\tloopSounds[entityNum].sfx = sfx;\n\n\tif (s_doppler->integer && VectorLengthSquared(velocity)>0.0) {\n\t\tvec3_t\tout;\n\t\tfloat\tlena, lenb;\n\n\t\tloopSounds[entityNum].doppler = qtrue;\n\t\tlena = DistanceSquared(loopSounds[listener_number].origin, loopSounds[entityNum].origin);\n\t\tVectorAdd(loopSounds[entityNum].origin, loopSounds[entityNum].velocity, out);\n\t\tlenb = DistanceSquared(loopSounds[listener_number].origin, out);\n\t\tif ((loopSounds[entityNum].framenum+1) != cls.framecount) {\n\t\t\tloopSounds[entityNum].oldDopplerScale = 1.0;\n\t\t} else {\n\t\t\tloopSounds[entityNum].oldDopplerScale = loopSounds[entityNum].dopplerScale;\n\t\t}\n\t\tloopSounds[entityNum].dopplerScale = lenb/(lena*100);\n\t\tif (loopSounds[entityNum].dopplerScale<=1.0) {\n\t\t\tloopSounds[entityNum].doppler = qfalse;\t\t\t// don't bother doing the math\n\t\t}\n\t}\n\n\tloopSounds[entityNum].framenum = cls.framecount;\n}\n\n/*\n==================\nS_AddLoopingSound\n\nCalled during entity generation for a frame\nInclude velocity in case I get around to doing doppler...\n==================\n*/\nvoid S_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfxHandle ) {\n\tsfx_t *sfx;\n\n\tif ( !s_soundStarted || s_soundMuted ) {\n\t\treturn;\n\t}\n\n\tif ( sfxHandle < 0 || sfxHandle >= s_numSfx ) {\n\t\tCom_Printf( S_COLOR_YELLOW, \"S_AddRealLoopingSound: handle %i out of range\\n\", sfxHandle );\n\t\treturn;\n\t}\n\n\tsfx = &s_knownSfx[ sfxHandle ];\n\n\tif (sfx->inMemory == qfalse) {\n\t\tS_memoryLoad(sfx);\n\t}\n\n\tif ( !sfx->soundLength ) {\n\t\tCom_Error( ERR_DROP, \"%s has length 0\", sfx->soundName );\n\t}\n\tVectorCopy( origin, loopSounds[entityNum].origin );\n\tVectorCopy( velocity, loopSounds[entityNum].velocity );\n\tloopSounds[entityNum].sfx = sfx;\n\tloopSounds[entityNum].active = qtrue;\n\tloopSounds[entityNum].kill = qfalse;\n\tloopSounds[entityNum].doppler = qfalse;\n}\n\n\n\n/*\n==================\nS_AddLoopSounds\n\nSpatialize all of the looping sounds.\nAll sounds are on the same cycle, so any duplicates can just\nsum up the channel multipliers.\n==================\n*/\nvoid S_AddLoopSounds (void) {\n\tint\t\t\ti, j, time;\n\tint\t\t\tleft_total, right_total, left, right;\n\tchannel_t\t*ch;\n\tloopSound_t\t*loop, *loop2;\n\tstatic int\tloopFrame;\n\n\n\tnumLoopChannels = 0;\n\n\ttime = Com_Milliseconds();\n\n\tloopFrame++;\n\tfor ( i = 0 ; i < MAX_GENTITIES ; i++) {\n\t\tloop = &loopSounds[i];\n\t\tif ( !loop->active || loop->mergeFrame == loopFrame ) {\n\t\t\tcontinue;\t// already merged into an earlier sound\n\t\t}\n\n\t\tif (loop->kill) {\n\t\t\tS_SpatializeOrigin( loop->origin, 127, &left_total, &right_total);\t\t\t// 3d\n\t\t} else {\n\t\t\tS_SpatializeOrigin( loop->origin, 90,  &left_total, &right_total);\t\t\t// sphere\n\t\t}\n\n\t\tloop->sfx->lastTimeUsed = time;\n\n\t\tfor (j=(i+1); j< MAX_GENTITIES ; j++) {\n\t\t\tloop2 = &loopSounds[j];\n\t\t\tif ( !loop2->active || loop2->doppler || loop2->sfx != loop->sfx) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tloop2->mergeFrame = loopFrame;\n\n\t\t\tif (loop2->kill) {\n\t\t\t\tS_SpatializeOrigin( loop2->origin, 127, &left, &right);\t\t\t\t// 3d\n\t\t\t} else {\n\t\t\t\tS_SpatializeOrigin( loop2->origin, 90,  &left, &right);\t\t\t\t// sphere\n\t\t\t}\n\n\t\t\tloop2->sfx->lastTimeUsed = time;\n\t\t\tleft_total += left;\n\t\t\tright_total += right;\n\t\t}\n\t\tif (left_total == 0 && right_total == 0) {\n\t\t\tcontinue;\t\t// not audible\n\t\t}\n\n\t\t// allocate a channel\n\t\tch = &loop_channels[numLoopChannels];\n\t\t\n\t\tif (left_total > 255) {\n\t\t\tleft_total = 255;\n\t\t}\n\t\tif (right_total > 255) {\n\t\t\tright_total = 255;\n\t\t}\n\t\t\n\t\tch->master_vol = 127;\n\t\tch->leftvol = left_total;\n\t\tch->rightvol = right_total;\n\t\tch->thesfx = loop->sfx;\n\t\tch->doppler = loop->doppler;\n\t\tch->dopplerScale = loop->dopplerScale;\n\t\tch->oldDopplerScale = loop->oldDopplerScale;\n\t\tnumLoopChannels++;\n\t\tif (numLoopChannels == MAX_CHANNELS) {\n\t\t\treturn;\n\t\t}\n\t}\n}\n\n//=============================================================================\n\n/*\n=================\nS_ByteSwapRawSamples\n\nIf raw data has been loaded in little endien binary form, this must be done.\nIf raw data was calculated, as with ADPCM, this should not be called.\n=================\n*/\nvoid S_ByteSwapRawSamples( int samples, int width, int s_channels, const byte *data ) {\n\tint\t\ti;\n\n\tif ( width != 2 ) {\n\t\treturn;\n\t}\n\tif ( LittleShort( 256 ) == 256 ) {\n\t\treturn;\n\t}\n\n\tif ( s_channels == 2 ) {\n\t\tsamples <<= 1;\n\t}\n\tfor ( i = 0 ; i < samples ; i++ ) {\n\t\t((short *)data)[i] = LittleShort( ((short *)data)[i] );\n\t}\n}\n\nportable_samplepair_t *S_GetRawSamplePointer() {\n\treturn s_rawsamples;\n}\n\n/*\n============\nS_RawSamples\n\nMusic streaming\n============\n*/\nvoid S_RawSamples( int samples, int rate, int width, int s_channels, const byte *data, float volume ) {\n\tint\t\ti;\n\tint\t\tsrc, dst;\n\tfloat\tscale;\n\tint\t\tintVolume;\n\n\tif ( !s_soundStarted || s_soundMuted ) {\n\t\treturn;\n\t}\n\n\tintVolume = 256 * volume;\n\n\tif ( s_rawend < s_soundtime ) {\n\t\tCom_DPrintf( \"S_RawSamples: resetting minimum: %i < %i\\n\", s_rawend, s_soundtime );\n\t\ts_rawend = s_soundtime;\n\t}\n\n\tscale = (float)rate / dma.speed;\n\n//Com_Printf (\"%i < %i < %i\\n\", s_soundtime, s_paintedtime, s_rawend);\n\tif (s_channels == 2 && width == 2)\n\t{\n\t\tif (scale == 1.0)\n\t\t{\t// optimized case\n\t\t\tfor (i=0 ; i<samples ; i++)\n\t\t\t{\n\t\t\t\tdst = s_rawend&(MAX_RAW_SAMPLES-1);\n\t\t\t\ts_rawend++;\n\t\t\t\ts_rawsamples[dst].left = ((short *)data)[i*2] * intVolume;\n\t\t\t\ts_rawsamples[dst].right = ((short *)data)[i*2+1] * intVolume;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfor (i=0 ; ; i++)\n\t\t\t{\n\t\t\t\tsrc = i*scale;\n\t\t\t\tif (src >= samples)\n\t\t\t\t\tbreak;\n\t\t\t\tdst = s_rawend&(MAX_RAW_SAMPLES-1);\n\t\t\t\ts_rawend++;\n\t\t\t\ts_rawsamples[dst].left = ((short *)data)[src*2] * intVolume;\n\t\t\t\ts_rawsamples[dst].right = ((short *)data)[src*2+1] * intVolume;\n\t\t\t}\n\t\t}\n\t}\n\telse if (s_channels == 1 && width == 2)\n\t{\n\t\tfor (i=0 ; ; i++)\n\t\t{\n\t\t\tsrc = i*scale;\n\t\t\tif (src >= samples)\n\t\t\t\tbreak;\n\t\t\tdst = s_rawend&(MAX_RAW_SAMPLES-1);\n\t\t\ts_rawend++;\n\t\t\ts_rawsamples[dst].left = ((short *)data)[src] * intVolume;\n\t\t\ts_rawsamples[dst].right = ((short *)data)[src] * intVolume;\n\t\t}\n\t}\n\telse if (s_channels == 2 && width == 1)\n\t{\n\t\tintVolume *= 256;\n\n\t\tfor (i=0 ; ; i++)\n\t\t{\n\t\t\tsrc = i*scale;\n\t\t\tif (src >= samples)\n\t\t\t\tbreak;\n\t\t\tdst = s_rawend&(MAX_RAW_SAMPLES-1);\n\t\t\ts_rawend++;\n\t\t\ts_rawsamples[dst].left = ((char *)data)[src*2] * intVolume;\n\t\t\ts_rawsamples[dst].right = ((char *)data)[src*2+1] * intVolume;\n\t\t}\n\t}\n\telse if (s_channels == 1 && width == 1)\n\t{\n\t\tintVolume *= 256;\n\n\t\tfor (i=0 ; ; i++)\n\t\t{\n\t\t\tsrc = i*scale;\n\t\t\tif (src >= samples)\n\t\t\t\tbreak;\n\t\t\tdst = s_rawend&(MAX_RAW_SAMPLES-1);\n\t\t\ts_rawend++;\n\t\t\ts_rawsamples[dst].left = (((byte *)data)[src]-128) * intVolume;\n\t\t\ts_rawsamples[dst].right = (((byte *)data)[src]-128) * intVolume;\n\t\t}\n\t}\n\n\tif ( s_rawend > s_soundtime + MAX_RAW_SAMPLES ) {\n\t\tCom_DPrintf( \"S_RawSamples: overflowed %i > %i\\n\", s_rawend, s_soundtime );\n\t}\n}\n\n//=============================================================================\n\n/*\n=====================\nS_UpdateEntityPosition\n\nlet the sound system know where an entity currently is\n======================\n*/\nvoid S_UpdateEntityPosition( int entityNum, const vec3_t origin ) {\n\tif ( entityNum < 0 || entityNum > MAX_GENTITIES ) {\n\t\tCom_Error( ERR_DROP, \"S_UpdateEntityPosition: bad entitynum %i\", entityNum );\n\t}\n\tVectorCopy( origin, loopSounds[entityNum].origin );\n}\n\n\n/*\n============\nS_Respatialize\n\nChange the volumes of all the playing sounds for changes in their positions\n============\n*/\nvoid S_Respatialize( int entityNum, const vec3_t head, vec3_t axis[3], int inwater ) {\n\tint\t\t\ti;\n\tchannel_t\t*ch;\n\tvec3_t\t\torigin;\n\n\tif ( !s_soundStarted || s_soundMuted ) {\n\t\treturn;\n\t}\n\n\tlistener_number = entityNum;\n\tVectorCopy(head, listener_origin);\n\tVectorCopy(axis[0], listener_axis[0]);\n\tVectorCopy(axis[1], listener_axis[1]);\n\tVectorCopy(axis[2], listener_axis[2]);\n\n\t// update spatialization for dynamic sounds\t\n\tch = s_channels;\n\tfor ( i = 0 ; i < MAX_CHANNELS ; i++, ch++ ) {\n\t\tif ( !ch->thesfx ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// anything coming from the view entity will always be full volume\n\t\tif (ch->entnum == listener_number) {\n\t\t\tch->leftvol = ch->master_vol;\n\t\t\tch->rightvol = ch->master_vol;\n\t\t} else {\n\t\t\tif (ch->fixed_origin) {\n\t\t\t\tVectorCopy( ch->origin, origin );\n\t\t\t} else {\n\t\t\t\tVectorCopy( loopSounds[ ch->entnum ].origin, origin );\n\t\t\t}\n\n\t\t\tS_SpatializeOrigin (origin, ch->master_vol, &ch->leftvol, &ch->rightvol);\n\t\t}\n\t}\n\n\t// add loopsounds\n\tS_AddLoopSounds ();\n}\n\n\n/*\n========================\nS_ScanChannelStarts\n\nReturns qtrue if any new sounds were started since the last mix\n========================\n*/\nqboolean S_ScanChannelStarts( void ) {\n\tchannel_t\t\t*ch;\n\tint\t\t\t\ti;\n\tqboolean\t\tnewSamples;\n\n\tnewSamples = qfalse;\n\tch = s_channels;\n\n\tfor (i=0; i<MAX_CHANNELS ; i++, ch++) {\n\t\tif ( !ch->thesfx ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// if this channel was just started this frame,\n\t\t// set the sample count to it begins mixing\n\t\t// into the very first sample\n\t\tif ( ch->startSample == START_SAMPLE_IMMEDIATE ) {\n\t\t\tch->startSample = s_paintedtime;\n\t\t\tnewSamples = qtrue;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// if it is completely finished by now, clear it\n\t\tif ( ch->startSample + (ch->thesfx->soundLength) <= s_paintedtime ) {\n\t\t\tS_ChannelFree(ch);\n\t\t}\n\t}\n\n\treturn newSamples;\n}\n\n/*\n============\nS_Update\n\nCalled once each time through the main loop\n============\n*/\nvoid S_Update( void ) {\n\tint\t\t\ti;\n\tint\t\t\ttotal;\n\tchannel_t\t*ch;\n\n\tif ( !s_soundStarted || s_soundMuted ) {\n\t\tCom_DPrintf (\"not started or muted\\n\");\n\t\treturn;\n\t}\n\n\t//\n\t// debugging output\n\t//\n\tif ( s_show->integer == 2 ) {\n\t\ttotal = 0;\n\t\tch = s_channels;\n\t\tfor (i=0 ; i<MAX_CHANNELS; i++, ch++) {\n\t\t\tif (ch->thesfx && (ch->leftvol || ch->rightvol) ) {\n\t\t\t\tCom_Printf (\"%f %f %s\\n\", ch->leftvol, ch->rightvol, ch->thesfx->soundName);\n\t\t\t\ttotal++;\n\t\t\t}\n\t\t}\n\t\t\n\t\tCom_Printf (\"----(%i)---- painted: %i\\n\", total, s_paintedtime);\n\t}\n\n\t// add raw data from streamed samples\n\tS_UpdateBackgroundTrack();\n\n\t// mix some sound\n\tS_Update_();\n}\n\nvoid S_GetSoundtime(void)\n{\n\tint\t\tsamplepos;\n\tstatic\tint\t\tbuffers;\n\tstatic\tint\t\toldsamplepos;\n\tint\t\tfullsamples;\n\t\n\tfullsamples = dma.samples / dma.channels;\n\n\t// it is possible to miscount buffers if it has wrapped twice between\n\t// calls to S_Update.  Oh well.\n\tsamplepos = SNDDMA_GetDMAPos();\n\tif (samplepos < oldsamplepos)\n\t{\n\t\tbuffers++;\t\t\t\t\t// buffer wrapped\n\t\t\n\t\tif (s_paintedtime > 0x40000000)\n\t\t{\t// time to chop things off to avoid 32 bit limits\n\t\t\tbuffers = 0;\n\t\t\ts_paintedtime = fullsamples;\n\t\t\tS_StopAllSounds ();\n\t\t}\n\t}\n\toldsamplepos = samplepos;\n\n\ts_soundtime = buffers*fullsamples + samplepos/dma.channels;\n\n#if 0\n// check to make sure that we haven't overshot\n\tif (s_paintedtime < s_soundtime)\n\t{\n\t\tCom_DPrintf (\"S_Update_ : overflow\\n\");\n\t\ts_paintedtime = s_soundtime;\n\t}\n#endif\n\n\tif ( dma.submission_chunk < 256 ) {\n\t\ts_paintedtime = s_soundtime + s_mixPreStep->value * dma.speed;\n\t} else {\n\t\ts_paintedtime = s_soundtime + dma.submission_chunk;\n\t}\n}\n\n\nvoid S_Update_(void) {\n\tunsigned        endtime;\n\tint\t\t\t\tsamps;\n\tstatic\t\t\tfloat\tlastTime = 0.0f;\n\tfloat\t\t\tma, op;\n\tfloat\t\t\tthisTime, sane;\n\tstatic\t\t\tint ot = -1;\n\n\tif ( !s_soundStarted || s_soundMuted ) {\n\t\treturn;\n\t}\n\n\tthisTime = Com_Milliseconds();\n\n\t// Updates s_soundtime\n\tS_GetSoundtime();\n\n\tif (s_soundtime == ot) {\n\t\treturn;\n\t}\n\tot = s_soundtime;\n\n\t// clear any sound effects that end before the current time,\n\t// and start any new sounds\n\tS_ScanChannelStarts();\n\n\tsane = thisTime - lastTime;\n\tif (sane<11) {\n\t\tsane = 11;\t\t\t// 85hz\n\t}\n\n\tma = s_mixahead->value * dma.speed;\n\top = s_mixPreStep->value + sane*dma.speed*0.01;\n\n\tif (op < ma) {\n\t\tma = op;\n\t}\n\n\t// mix ahead of current position\n\tendtime = s_soundtime + ma;\n\n\t// mix to an even submission block size\n\tendtime = (endtime + dma.submission_chunk-1)\n\t\t& ~(dma.submission_chunk-1);\n\n\t// never mix more than the complete buffer\n\tsamps = dma.samples >> (dma.channels-1);\n\tif (endtime - s_soundtime > samps)\n\t\tendtime = s_soundtime + samps;\n\n\n\n\tSNDDMA_BeginPainting ();\n\n\tS_PaintChannels (endtime);\n\n\tSNDDMA_Submit ();\n\n\tlastTime = thisTime;\n}\n\n/*\n===============================================================================\n\nconsole functions\n\n===============================================================================\n*/\n\nvoid S_Play_f( void ) {\n\tint \t\ti;\n\tsfxHandle_t\th;\n\tchar\t\tname[256];\n\t\n\ti = 1;\n\twhile ( i<Cmd_Argc() ) {\n\t\tif ( !Q_strrchr(Cmd_Argv(i), '.') ) {\n\t\t\tCom_sprintf( name, sizeof(name), \"%s.wav\", Cmd_Argv(1) );\n\t\t} else {\n\t\t\tQ_strncpyz( name, Cmd_Argv(i), sizeof(name) );\n\t\t}\n\t\th = S_RegisterSound( name, qfalse );\n\t\tif( h ) {\n\t\t\tS_StartLocalSound( h, CHAN_LOCAL_SOUND );\n\t\t}\n\t\ti++;\n\t}\n}\n\nvoid S_Music_f( void ) {\n\tint\t\tc;\n\n\tc = Cmd_Argc();\n\n\tif ( c == 2 ) {\n\t\tS_StartBackgroundTrack( Cmd_Argv(1), Cmd_Argv(1) );\n\t\ts_backgroundLoop[0] = 0;\n\t} else if ( c == 3 ) {\n\t\tS_StartBackgroundTrack( Cmd_Argv(1), Cmd_Argv(2) );\n\t} else {\n\t\tCom_Printf (\"music <musicfile> [loopfile]\\n\");\n\t\treturn;\n\t}\n\n}\n\nvoid S_SoundList_f( void ) {\n\tint\t\ti;\n\tsfx_t\t*sfx;\n\tint\t\tsize, total;\n\tchar\ttype[4][16];\n\tchar\tmem[2][16];\n\n\tstrcpy(type[0], \"16bit\");\n\tstrcpy(type[1], \"adpcm\");\n\tstrcpy(type[2], \"daub4\");\n\tstrcpy(type[3], \"mulaw\");\n\tstrcpy(mem[0], \"paged out\");\n\tstrcpy(mem[1], \"resident \");\n\ttotal = 0;\n\tfor (sfx=s_knownSfx, i=0 ; i<s_numSfx ; i++, sfx++) {\n\t\tsize = sfx->soundLength;\n\t\ttotal += size;\n\t\tCom_Printf(\"%6i[%s] : %s[%s]\\n\", size, type[sfx->soundCompressionMethod], sfx->soundName, mem[sfx->inMemory] );\n\t}\n\tCom_Printf (\"Total resident: %i\\n\", total);\n\tS_DisplayFreeMemory();\n}\n\n\n/*\n===============================================================================\n\nbackground music functions\n\n===============================================================================\n*/\n\nint\tFGetLittleLong( fileHandle_t f ) {\n\tint\t\tv;\n\n\tFS_Read( &v, sizeof(v), f );\n\n\treturn LittleLong( v);\n}\n\nint\tFGetLittleShort( fileHandle_t f ) {\n\tshort\tv;\n\n\tFS_Read( &v, sizeof(v), f );\n\n\treturn LittleShort( v);\n}\n\n// returns the length of the data in the chunk, or 0 if not found\nint S_FindWavChunk( fileHandle_t f, char *chunk ) {\n\tchar\tname[5];\n\tint\t\tlen;\n\tint\t\tr;\n\n\tname[4] = 0;\n\tlen = 0;\n\tr = FS_Read( name, 4, f );\n\tif ( r != 4 ) {\n\t\treturn 0;\n\t}\n\tlen = FGetLittleLong( f );\n\tif ( len < 0 || len > 0xfffffff ) {\n\t\tlen = 0;\n\t\treturn 0;\n\t}\n\tlen = (len + 1 ) & ~1;\t\t// pad to word boundary\n//\ts_nextWavChunk += len + 8;\n\n\tif ( strcmp( name, chunk ) ) {\n\t\treturn 0;\n\t}\n\n\treturn len;\n}\n\n/*\n======================\nS_StopBackgroundTrack\n======================\n*/\nvoid S_StopBackgroundTrack( void ) {\n\tif ( !s_backgroundFile ) {\n\t\treturn;\n\t}\n\tSys_EndStreamedFile( s_backgroundFile );\n\tFS_FCloseFile( s_backgroundFile );\n\ts_backgroundFile = 0;\n\ts_rawend = 0;\n}\n\n/*\n======================\nS_StartBackgroundTrack\n======================\n*/\nvoid S_StartBackgroundTrack( const char *intro, const char *loop ){\n\tint\t\tlen;\n\tchar\tdump[16];\n\tchar\tname[MAX_QPATH];\n\n\tif ( !intro ) {\n\t\tintro = \"\";\n\t}\n\tif ( !loop || !loop[0] ) {\n\t\tloop = intro;\n\t}\n\tCom_DPrintf( \"S_StartBackgroundTrack( %s, %s )\\n\", intro, loop );\n\n\tQ_strncpyz( name, intro, sizeof( name ) - 4 );\n\tCOM_DefaultExtension( name, sizeof( name ), \".wav\" );\n\n\tif ( !intro[0] ) {\n\t\treturn;\n\t}\n\n\tQ_strncpyz( s_backgroundLoop, loop, sizeof( s_backgroundLoop ) );\n\n\t// close the background track, but DON'T reset s_rawend\n\t// if restarting the same back ground track\n\tif ( s_backgroundFile ) {\n\t\tSys_EndStreamedFile( s_backgroundFile );\n\t\tFS_FCloseFile( s_backgroundFile );\n\t\ts_backgroundFile = 0;\n\t}\n\n\t//\n\t// open up a wav file and get all the info\n\t//\n\tFS_FOpenFileRead( name, &s_backgroundFile, qtrue );\n\tif ( !s_backgroundFile ) {\n\t\tCom_Printf( S_COLOR_YELLOW \"WARNING: couldn't open music file %s\\n\", name );\n\t\treturn;\n\t}\n\n\t// skip the riff wav header\n\n\tFS_Read(dump, 12, s_backgroundFile);\n\n\tif ( !S_FindWavChunk( s_backgroundFile, \"fmt \" ) ) {\n\t\tCom_Printf( \"No fmt chunk in %s\\n\", name );\n\t\tFS_FCloseFile( s_backgroundFile );\n\t\ts_backgroundFile = 0;\n\t\treturn;\n\t}\n\n\t// save name for soundinfo\n\ts_backgroundInfo.format = FGetLittleShort( s_backgroundFile );\n\ts_backgroundInfo.channels = FGetLittleShort( s_backgroundFile );\n\ts_backgroundInfo.rate = FGetLittleLong( s_backgroundFile );\n\tFGetLittleLong(  s_backgroundFile );\n\tFGetLittleShort(  s_backgroundFile );\n\ts_backgroundInfo.width = FGetLittleShort( s_backgroundFile ) / 8;\n\n\tif ( s_backgroundInfo.format != WAV_FORMAT_PCM ) {\n\t\tFS_FCloseFile( s_backgroundFile );\n\t\ts_backgroundFile = 0;\n\t\tCom_Printf(\"Not a microsoft PCM format wav: %s\\n\", name);\n\t\treturn;\n\t}\n\n\tif ( s_backgroundInfo.channels != 2 || s_backgroundInfo.rate != 22050 ) {\n\t\tCom_Printf(S_COLOR_YELLOW \"WARNING: music file %s is not 22k stereo\\n\", name );\n\t}\n\n\tif ( ( len = S_FindWavChunk( s_backgroundFile, \"data\" ) ) == 0 ) {\n\t\tFS_FCloseFile( s_backgroundFile );\n\t\ts_backgroundFile = 0;\n\t\tCom_Printf(\"No data chunk in %s\\n\", name);\n\t\treturn;\n\t}\n\n\ts_backgroundInfo.samples = len / (s_backgroundInfo.width * s_backgroundInfo.channels);\n\n\ts_backgroundSamples = s_backgroundInfo.samples;\n\n\t//\n\t// start the background streaming\n\t//\n\tSys_BeginStreamedFile( s_backgroundFile, 0x10000 );\n}\n\n/*\n======================\nS_UpdateBackgroundTrack\n======================\n*/\nvoid S_UpdateBackgroundTrack( void ) {\n\tint\t\tbufferSamples;\n\tint\t\tfileSamples;\n\tbyte\traw[30000];\t\t// just enough to fit in a mac stack frame\n\tint\t\tfileBytes;\n\tint\t\tr;\n\tstatic\tfloat\tmusicVolume = 0.5f;\n\n\tif ( !s_backgroundFile ) {\n\t\treturn;\n\t}\n\n\t// graeme see if this is OK\n\tmusicVolume = (musicVolume + (s_musicVolume->value * 2))/4.0f;\n\n\t// don't bother playing anything if musicvolume is 0\n\tif ( musicVolume <= 0 ) {\n\t\treturn;\n\t}\n\n\t// see how many samples should be copied into the raw buffer\n\tif ( s_rawend < s_soundtime ) {\n\t\ts_rawend = s_soundtime;\n\t}\n\n\twhile ( s_rawend < s_soundtime + MAX_RAW_SAMPLES ) {\n\t\tbufferSamples = MAX_RAW_SAMPLES - (s_rawend - s_soundtime);\n\n\t\t// decide how much data needs to be read from the file\n\t\tfileSamples = bufferSamples * s_backgroundInfo.rate / dma.speed;\n\n\t\t// don't try and read past the end of the file\n\t\tif ( fileSamples > s_backgroundSamples ) {\n\t\t\tfileSamples = s_backgroundSamples;\n\t\t}\n\n\t\t// our max buffer size\n\t\tfileBytes = fileSamples * (s_backgroundInfo.width * s_backgroundInfo.channels);\n\t\tif ( fileBytes > sizeof(raw) ) {\n\t\t\tfileBytes = sizeof(raw);\n\t\t\tfileSamples = fileBytes / (s_backgroundInfo.width * s_backgroundInfo.channels);\n\t\t}\n\n\t\tr = Sys_StreamedRead( raw, 1, fileBytes, s_backgroundFile );\n\t\tif ( r != fileBytes ) {\n\t\t\tCom_Printf(\"StreamedRead failure on music track\\n\");\n\t\t\tS_StopBackgroundTrack();\n\t\t\treturn;\n\t\t}\n\n\t\t// byte swap if needed\n\t\tS_ByteSwapRawSamples( fileSamples, s_backgroundInfo.width, s_backgroundInfo.channels, raw );\n\n\t\t// add to raw buffer\n\t\tS_RawSamples( fileSamples, s_backgroundInfo.rate, \n\t\t\ts_backgroundInfo.width, s_backgroundInfo.channels, raw, musicVolume );\n\n\t\ts_backgroundSamples -= fileSamples;\n\t\tif ( !s_backgroundSamples ) {\n\t\t\t// loop\n\t\t\tif (s_backgroundLoop[0]) {\n\t\t\t\tSys_EndStreamedFile( s_backgroundFile );\n\t\t\t\tFS_FCloseFile( s_backgroundFile );\n\t\t\t\ts_backgroundFile = 0;\n\t\t\t\tS_StartBackgroundTrack( s_backgroundLoop, s_backgroundLoop );\n\t\t\t\tif ( !s_backgroundFile ) {\n\t\t\t\t\treturn;\t\t// loop failed to restart\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ts_backgroundFile = 0;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n/*\n======================\nS_FreeOldestSound\n======================\n*/\n\nvoid S_FreeOldestSound() {\n\tint\ti, oldest, used;\n\tsfx_t\t*sfx;\n\tsndBuffer\t*buffer, *nbuffer;\n\n\toldest = Com_Milliseconds();\n\tused = 0;\n\n\tfor (i=1 ; i < s_numSfx ; i++) {\n\t\tsfx = &s_knownSfx[i];\n\t\tif (sfx->inMemory && sfx->lastTimeUsed<oldest) {\n\t\t\tused = i;\n\t\t\toldest = sfx->lastTimeUsed;\n\t\t}\n\t}\n\n\tsfx = &s_knownSfx[used];\n\n\tCom_DPrintf(\"S_FreeOldestSound: freeing sound %s\\n\", sfx->soundName);\n\n\tbuffer = sfx->soundData;\n\twhile(buffer != NULL) {\n\t\tnbuffer = buffer->next;\n\t\tSND_free(buffer);\n\t\tbuffer = nbuffer;\n\t}\n\tsfx->inMemory = qfalse;\n\tsfx->soundData = NULL;\n}\n"
  },
  {
    "path": "code/client/snd_local.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// snd_local.h -- private sound definations\n\n\n#include \"../game/q_shared.h\"\n#include \"../qcommon/qcommon.h\"\n#include \"snd_public.h\"\n\n#define\tPAINTBUFFER_SIZE\t\t4096\t\t\t\t\t// this is in samples\n\n#define SND_CHUNK_SIZE\t\t\t1024\t\t\t\t\t// samples\n#define SND_CHUNK_SIZE_FLOAT\t(SND_CHUNK_SIZE/2)\t\t// floats\n#define SND_CHUNK_SIZE_BYTE\t\t(SND_CHUNK_SIZE*2)\t\t// floats\n\ntypedef struct {\n\tint\t\t\tleft;\t// the final values will be clamped to +/- 0x00ffff00 and shifted down\n\tint\t\t\tright;\n} portable_samplepair_t;\n\ntypedef struct adpcm_state {\n    short\tsample;\t\t/* Previous output value */\n    char\tindex;\t\t/* Index into stepsize table */\n} adpcm_state_t;\n\ntypedef\tstruct sndBuffer_s {\n\tshort\t\t\t\t\tsndChunk[SND_CHUNK_SIZE];\n\tstruct sndBuffer_s\t\t*next;\n    int\t\t\t\t\t\tsize;\n\tadpcm_state_t\t\t\tadpcm;\n} sndBuffer;\n\ntypedef struct sfx_s {\n\tsndBuffer\t\t*soundData;\n\tqboolean\t\tdefaultSound;\t\t\t// couldn't be loaded, so use buzz\n\tqboolean\t\tinMemory;\t\t\t\t// not in Memory\n\tqboolean\t\tsoundCompressed;\t\t// not in Memory\n\tint\t\t\t\tsoundCompressionMethod;\t\n\tint \t\t\tsoundLength;\n\tchar \t\t\tsoundName[MAX_QPATH];\n\tint\t\t\t\tlastTimeUsed;\n\tstruct sfx_s\t*next;\n} sfx_t;\n\ntypedef struct {\n\tint\t\t\tchannels;\n\tint\t\t\tsamples;\t\t\t\t// mono samples in buffer\n\tint\t\t\tsubmission_chunk;\t\t// don't mix less than this #\n\tint\t\t\tsamplebits;\n\tint\t\t\tspeed;\n\tbyte\t\t*buffer;\n} dma_t;\n\n#define START_SAMPLE_IMMEDIATE\t0x7fffffff\n\ntypedef struct loopSound_s {\n\tvec3_t\t\torigin;\n\tvec3_t\t\tvelocity;\n\tsfx_t\t\t*sfx;\n\tint\t\t\tmergeFrame;\n\tqboolean\tactive;\n\tqboolean\tkill;\n\tqboolean\tdoppler;\n\tfloat\t\tdopplerScale;\n\tfloat\t\toldDopplerScale;\n\tint\t\t\tframenum;\n} loopSound_t;\n\ntypedef struct\n{\n\tint\t\t\tallocTime;\n\tint\t\t\tstartSample;\t// START_SAMPLE_IMMEDIATE = set immediately on next mix\n\tint\t\t\tentnum;\t\t\t// to allow overriding a specific sound\n\tint\t\t\tentchannel;\t\t// to allow overriding a specific sound\n\tint\t\t\tleftvol;\t\t// 0-255 volume after spatialization\n\tint\t\t\trightvol;\t\t// 0-255 volume after spatialization\n\tint\t\t\tmaster_vol;\t\t// 0-255 volume before spatialization\n\tfloat\t\tdopplerScale;\n\tfloat\t\toldDopplerScale;\n\tvec3_t\t\torigin;\t\t\t// only use if fixed_origin is set\n\tqboolean\tfixed_origin;\t// use origin instead of fetching entnum's origin\n\tsfx_t\t\t*thesfx;\t\t// sfx structure\n\tqboolean\tdoppler;\n} channel_t;\n\n\n#define\tWAV_FORMAT_PCM\t\t1\n\n\ntypedef struct {\n\tint\t\t\tformat;\n\tint\t\t\trate;\n\tint\t\t\twidth;\n\tint\t\t\tchannels;\n\tint\t\t\tsamples;\n\tint\t\t\tdataofs;\t\t// chunk starts this many bytes from file start\n} wavinfo_t;\n\n\n/*\n====================================================================\n\n  SYSTEM SPECIFIC FUNCTIONS\n\n====================================================================\n*/\n\n// initializes cycling through a DMA buffer and returns information on it\nqboolean SNDDMA_Init(void);\n\n// gets the current DMA position\nint\t\tSNDDMA_GetDMAPos(void);\n\n// shutdown the DMA xfer.\nvoid\tSNDDMA_Shutdown(void);\n\nvoid\tSNDDMA_BeginPainting (void);\n\nvoid\tSNDDMA_Submit(void);\n\n//====================================================================\n\n#define\tMAX_CHANNELS\t\t\t96\n\nextern\tchannel_t   s_channels[MAX_CHANNELS];\nextern\tchannel_t   loop_channels[MAX_CHANNELS];\nextern\tint\t\tnumLoopChannels;\n\nextern\tint\t\ts_paintedtime;\nextern\tint\t\ts_rawend;\nextern\tvec3_t\tlistener_forward;\nextern\tvec3_t\tlistener_right;\nextern\tvec3_t\tlistener_up;\nextern\tdma_t\tdma;\n\n#define\tMAX_RAW_SAMPLES\t16384\nextern\tportable_samplepair_t\ts_rawsamples[MAX_RAW_SAMPLES];\n\nextern cvar_t\t*s_volume;\nextern cvar_t\t*s_nosound;\nextern cvar_t\t*s_khz;\nextern cvar_t\t*s_show;\nextern cvar_t\t*s_mixahead;\n\nextern cvar_t\t*s_testsound;\nextern cvar_t\t*s_separation;\n\nqboolean S_LoadSound( sfx_t *sfx );\n\nvoid\t\tSND_free(sndBuffer *v);\nsndBuffer*\tSND_malloc();\nvoid\t\tSND_setup();\n\nvoid S_PaintChannels(int endtime);\n\nvoid S_memoryLoad(sfx_t *sfx);\nportable_samplepair_t *S_GetRawSamplePointer();\n\n// spatializes a channel\nvoid S_Spatialize(channel_t *ch);\n\n// adpcm functions\nint  S_AdpcmMemoryNeeded( const wavinfo_t *info );\nvoid S_AdpcmEncodeSound( sfx_t *sfx, short *samples );\nvoid S_AdpcmGetSamples(sndBuffer *chunk, short *to);\n\n// wavelet function\n\n#define SENTINEL_MULAW_ZERO_RUN 127\n#define SENTINEL_MULAW_FOUR_BIT_RUN 126\n\nvoid S_FreeOldestSound();\n\n#define\tNXStream byte\n\nvoid encodeWavelet(sfx_t *sfx, short *packets);\nvoid decodeWavelet( sndBuffer *stream, short *packets);\n\nvoid encodeMuLaw( sfx_t *sfx, short *packets);\nextern short mulawToShort[256];\n\nextern short *sfxScratchBuffer;\nextern sfx_t *sfxScratchPointer;\nextern int\t   sfxScratchIndex;\n\n"
  },
  {
    "path": "code/client/snd_mem.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*****************************************************************************\n * name:\t\tsnd_mem.c\n *\n * desc:\t\tsound caching\n *\n * $Archive: /MissionPack/code/client/snd_mem.c $\n *\n *****************************************************************************/\n\n#include \"snd_local.h\"\n\n#define DEF_COMSOUNDMEGS \"8\"\n\n/*\n===============================================================================\n\nmemory management\n\n===============================================================================\n*/\n\nstatic\tsndBuffer\t*buffer = NULL;\nstatic\tsndBuffer\t*freelist = NULL;\nstatic\tint inUse = 0;\nstatic\tint totalInUse = 0;\n\nshort *sfxScratchBuffer = NULL;\nsfx_t *sfxScratchPointer = NULL;\nint\t   sfxScratchIndex = 0;\n\nvoid\tSND_free(sndBuffer *v) {\n\t*(sndBuffer **)v = freelist;\n\tfreelist = (sndBuffer*)v;\n\tinUse += sizeof(sndBuffer);\n}\n\nsndBuffer*\tSND_malloc() {\n\tsndBuffer *v;\nredo:\n\tif (freelist == NULL) {\n\t\tS_FreeOldestSound();\n\t\tgoto redo;\n\t}\n\n\tinUse -= sizeof(sndBuffer);\n\ttotalInUse += sizeof(sndBuffer);\n\n\tv = freelist;\n\tfreelist = *(sndBuffer **)freelist;\n\tv->next = NULL;\n\treturn v;\n}\n\nvoid SND_setup() {\n\tsndBuffer *p, *q;\n\tcvar_t\t*cv;\n\tint scs;\n\n\tcv = Cvar_Get( \"com_soundMegs\", DEF_COMSOUNDMEGS, CVAR_LATCH | CVAR_ARCHIVE );\n\n\tscs = (cv->integer*1536);\n\n\tbuffer = malloc(scs*sizeof(sndBuffer) );\n\t// allocate the stack based hunk allocator\n\tsfxScratchBuffer = malloc(SND_CHUNK_SIZE * sizeof(short) * 4);\t//Hunk_Alloc(SND_CHUNK_SIZE * sizeof(short) * 4);\n\tsfxScratchPointer = NULL;\n\n\tinUse = scs*sizeof(sndBuffer);\n\tp = buffer;;\n\tq = p + scs;\n\twhile (--q > p)\n\t\t*(sndBuffer **)q = q-1;\n\t\n\t*(sndBuffer **)q = NULL;\n\tfreelist = p + scs - 1;\n\n\tCom_Printf(\"Sound memory manager started\\n\");\n}\n\n/*\n===============================================================================\n\nWAV loading\n\n===============================================================================\n*/\n\nstatic\tbyte\t*data_p;\nstatic\tbyte \t*iff_end;\nstatic\tbyte \t*last_chunk;\nstatic\tbyte \t*iff_data;\nstatic\tint \tiff_chunk_len;\n\nstatic short GetLittleShort(void)\n{\n\tshort val = 0;\n\tval = *data_p;\n\tval = val + (*(data_p+1)<<8);\n\tdata_p += 2;\n\treturn val;\n}\n\nstatic int GetLittleLong(void)\n{\n\tint val = 0;\n\tval = *data_p;\n\tval = val + (*(data_p+1)<<8);\n\tval = val + (*(data_p+2)<<16);\n\tval = val + (*(data_p+3)<<24);\n\tdata_p += 4;\n\treturn val;\n}\n\nstatic void FindNextChunk(char *name)\n{\n\twhile (1)\n\t{\n\t\tdata_p=last_chunk;\n\n\t\tif (data_p >= iff_end)\n\t\t{\t// didn't find the chunk\n\t\t\tdata_p = NULL;\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tdata_p += 4;\n\t\tiff_chunk_len = GetLittleLong();\n\t\tif (iff_chunk_len < 0)\n\t\t{\n\t\t\tdata_p = NULL;\n\t\t\treturn;\n\t\t}\n\t\tdata_p -= 8;\n\t\tlast_chunk = data_p + 8 + ( (iff_chunk_len + 1) & ~1 );\n\t\tif (!strncmp((char *)data_p, name, 4))\n\t\t\treturn;\n\t}\n}\n\nstatic void FindChunk(char *name)\n{\n\tlast_chunk = iff_data;\n\tFindNextChunk (name);\n}\n\n/*\n============\nGetWavinfo\n============\n*/\nstatic wavinfo_t GetWavinfo (char *name, byte *wav, int wavlength)\n{\n\twavinfo_t\tinfo;\n\n\tCom_Memset (&info, 0, sizeof(info));\n\n\tif (!wav)\n\t\treturn info;\n\t\t\n\tiff_data = wav;\n\tiff_end = wav + wavlength;\n\n// find \"RIFF\" chunk\n\tFindChunk(\"RIFF\");\n\tif (!(data_p && !strncmp((char *)data_p+8, \"WAVE\", 4)))\n\t{\n\t\tCom_Printf(\"Missing RIFF/WAVE chunks\\n\");\n\t\treturn info;\n\t}\n\n// get \"fmt \" chunk\n\tiff_data = data_p + 12;\n// DumpChunks ();\n\n\tFindChunk(\"fmt \");\n\tif (!data_p)\n\t{\n\t\tCom_Printf(\"Missing fmt chunk\\n\");\n\t\treturn info;\n\t}\n\tdata_p += 8;\n\tinfo.format = GetLittleShort();\n\tinfo.channels = GetLittleShort();\n\tinfo.rate = GetLittleLong();\n\tdata_p += 4+2;\n\tinfo.width = GetLittleShort() / 8;\n\n\tif (info.format != 1)\n\t{\n\t\tCom_Printf(\"Microsoft PCM format only\\n\");\n\t\treturn info;\n\t}\n\n\n// find data chunk\n\tFindChunk(\"data\");\n\tif (!data_p)\n\t{\n\t\tCom_Printf(\"Missing data chunk\\n\");\n\t\treturn info;\n\t}\n\n\tdata_p += 4;\n\tinfo.samples = GetLittleLong () / info.width;\n\tinfo.dataofs = data_p - wav;\n\n\treturn info;\n}\n\n\n/*\n================\nResampleSfx\n\nresample / decimate to the current source rate\n================\n*/\nstatic void ResampleSfx( sfx_t *sfx, int inrate, int inwidth, byte *data, qboolean compressed ) {\n\tint\t\toutcount;\n\tint\t\tsrcsample;\n\tfloat\tstepscale;\n\tint\t\ti;\n\tint\t\tsample, samplefrac, fracstep;\n\tint\t\t\tpart;\n\tsndBuffer\t*chunk;\n\t\n\tstepscale = (float)inrate / dma.speed;\t// this is usually 0.5, 1, or 2\n\n\toutcount = sfx->soundLength / stepscale;\n\tsfx->soundLength = outcount;\n\n\tsamplefrac = 0;\n\tfracstep = stepscale * 256;\n\tchunk = sfx->soundData;\n\n\tfor (i=0 ; i<outcount ; i++)\n\t{\n\t\tsrcsample = samplefrac >> 8;\n\t\tsamplefrac += fracstep;\n\t\tif( inwidth == 2 ) {\n\t\t\tsample = LittleShort ( ((short *)data)[srcsample] );\n\t\t} else {\n\t\t\tsample = (int)( (unsigned char)(data[srcsample]) - 128) << 8;\n\t\t}\n\t\tpart  = (i&(SND_CHUNK_SIZE-1));\n\t\tif (part == 0) {\n\t\t\tsndBuffer\t*newchunk;\n\t\t\tnewchunk = SND_malloc();\n\t\t\tif (chunk == NULL) {\n\t\t\t\tsfx->soundData = newchunk;\n\t\t\t} else {\n\t\t\t\tchunk->next = newchunk;\n\t\t\t}\n\t\t\tchunk = newchunk;\n\t\t}\n\n\t\tchunk->sndChunk[part] = sample;\n\t}\n}\n\n/*\n================\nResampleSfx\n\nresample / decimate to the current source rate\n================\n*/\nstatic int ResampleSfxRaw( short *sfx, int inrate, int inwidth, int samples, byte *data ) {\n\tint\t\t\toutcount;\n\tint\t\t\tsrcsample;\n\tfloat\t\tstepscale;\n\tint\t\t\ti;\n\tint\t\t\tsample, samplefrac, fracstep;\n\t\n\tstepscale = (float)inrate / dma.speed;\t// this is usually 0.5, 1, or 2\n\n\toutcount = samples / stepscale;\n\n\tsamplefrac = 0;\n\tfracstep = stepscale * 256;\n\n\tfor (i=0 ; i<outcount ; i++)\n\t{\n\t\tsrcsample = samplefrac >> 8;\n\t\tsamplefrac += fracstep;\n\t\tif( inwidth == 2 ) {\n\t\t\tsample = LittleShort ( ((short *)data)[srcsample] );\n\t\t} else {\n\t\t\tsample = (int)( (unsigned char)(data[srcsample]) - 128) << 8;\n\t\t}\n\t\tsfx[i] = sample;\n\t}\n\treturn outcount;\n}\n\n\n//=============================================================================\n\n/*\n==============\nS_LoadSound\n\nThe filename may be different than sfx->name in the case\nof a forced fallback of a player specific sound\n==============\n*/\nqboolean S_LoadSound( sfx_t *sfx )\n{\n\tbyte\t*data;\n\tshort\t*samples;\n\twavinfo_t\tinfo;\n\tint\t\tsize;\n\n\t// player specific sounds are never directly loaded\n\tif ( sfx->soundName[0] == '*') {\n\t\treturn qfalse;\n\t}\n\n\t// load it in\n\tsize = FS_ReadFile( sfx->soundName, (void **)&data );\n\tif ( !data ) {\n\t\treturn qfalse;\n\t}\n\n\tinfo = GetWavinfo( sfx->soundName, data, size );\n\tif ( info.channels != 1 ) {\n\t\tCom_Printf (\"%s is a stereo wav file\\n\", sfx->soundName);\n\t\tFS_FreeFile (data);\n\t\treturn qfalse;\n\t}\n\n\tif ( info.width == 1 ) {\n\t\tCom_DPrintf(S_COLOR_YELLOW \"WARNING: %s is a 8 bit wav file\\n\", sfx->soundName);\n\t}\n\n\tif ( info.rate != 22050 ) {\n\t\tCom_DPrintf(S_COLOR_YELLOW \"WARNING: %s is not a 22kHz wav file\\n\", sfx->soundName);\n\t}\n\n\tsamples = Hunk_AllocateTempMemory(info.samples * sizeof(short) * 2);\n\n\tsfx->lastTimeUsed = Com_Milliseconds()+1;\n\n\t// each of these compression schemes works just fine\n\t// but the 16bit quality is much nicer and with a local\n\t// install assured we can rely upon the sound memory\n\t// manager to do the right thing for us and page\n\t// sound in as needed\n\n\tif( sfx->soundCompressed == qtrue) {\n\t\tsfx->soundCompressionMethod = 1;\n\t\tsfx->soundData = NULL;\n\t\tsfx->soundLength = ResampleSfxRaw( samples, info.rate, info.width, info.samples, (data + info.dataofs) );\n\t\tS_AdpcmEncodeSound(sfx, samples);\n#if 0\n\t} else if (info.samples>(SND_CHUNK_SIZE*16) && info.width >1) {\n\t\tsfx->soundCompressionMethod = 3;\n\t\tsfx->soundData = NULL;\n\t\tsfx->soundLength = ResampleSfxRaw( samples, info.rate, info.width, info.samples, (data + info.dataofs) );\n\t\tencodeMuLaw( sfx, samples);\n\t} else if (info.samples>(SND_CHUNK_SIZE*6400) && info.width >1) {\n\t\tsfx->soundCompressionMethod = 2;\n\t\tsfx->soundData = NULL;\n\t\tsfx->soundLength = ResampleSfxRaw( samples, info.rate, info.width, info.samples, (data + info.dataofs) );\n\t\tencodeWavelet( sfx, samples);\n#endif\n\t} else {\n\t\tsfx->soundCompressionMethod = 0;\n\t\tsfx->soundLength = info.samples;\n\t\tsfx->soundData = NULL;\n\t\tResampleSfx( sfx, info.rate, info.width, data + info.dataofs, qfalse );\n\t}\n\t\n\tHunk_FreeTempMemory(samples);\n\tFS_FreeFile( data );\n\n\treturn qtrue;\n}\n\nvoid S_DisplayFreeMemory() {\n\tCom_Printf(\"%d bytes free sound buffer memory, %d total used\\n\", inUse, totalInUse);\n}\n"
  },
  {
    "path": "code/client/snd_mix.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// snd_mix.c -- portable code to mix sounds for snd_dma.c\n\n#include \"snd_local.h\"\n\nstatic portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE];\nstatic int snd_vol;\n\n// bk001119 - these not static, required by unix/snd_mixa.s\nint*     snd_p;  \nint      snd_linear_count;\nshort*   snd_out;\n\n#if !( (defined __linux__ || defined __FreeBSD__ ) && (defined __i386__) ) // rb010123\n#if\t!id386\n\nvoid S_WriteLinearBlastStereo16 (void)\n{\n\tint\t\ti;\n\tint\t\tval;\n\n\tfor (i=0 ; i<snd_linear_count ; i+=2)\n\t{\n\t\tval = snd_p[i]>>8;\n\t\tif (val > 0x7fff)\n\t\t\tsnd_out[i] = 0x7fff;\n\t\telse if (val < -32768)\n\t\t\tsnd_out[i] = -32768;\n\t\telse\n\t\t\tsnd_out[i] = val;\n\n\t\tval = snd_p[i+1]>>8;\n\t\tif (val > 0x7fff)\n\t\t\tsnd_out[i+1] = 0x7fff;\n\t\telse if (val < -32768)\n\t\t\tsnd_out[i+1] = -32768;\n\t\telse\n\t\t\tsnd_out[i+1] = val;\n\t}\n}\n#else\n\n__declspec( naked ) void S_WriteLinearBlastStereo16 (void)\n{\n\t__asm {\n\n push edi\n push ebx\n mov ecx,ds:dword ptr[snd_linear_count]\n mov ebx,ds:dword ptr[snd_p]\n mov edi,ds:dword ptr[snd_out]\nLWLBLoopTop:\n mov eax,ds:dword ptr[-8+ebx+ecx*4]\n sar eax,8\n cmp eax,07FFFh\n jg LClampHigh\n cmp eax,0FFFF8000h\n jnl LClampDone\n mov eax,0FFFF8000h\n jmp LClampDone\nLClampHigh:\n mov eax,07FFFh\nLClampDone:\n mov edx,ds:dword ptr[-4+ebx+ecx*4]\n sar edx,8\n cmp edx,07FFFh\n jg LClampHigh2\n cmp edx,0FFFF8000h\n jnl LClampDone2\n mov edx,0FFFF8000h\n jmp LClampDone2\nLClampHigh2:\n mov edx,07FFFh\nLClampDone2:\n shl edx,16\n and eax,0FFFFh\n or edx,eax\n mov ds:dword ptr[-4+edi+ecx*2],edx\n sub ecx,2\n jnz LWLBLoopTop\n pop ebx\n pop edi\n ret\n\t}\n}\n\n#endif\n#else\n// forward declare, implementation somewhere else\nvoid S_WriteLinearBlastStereo16 (void);\n#endif\n\nvoid S_TransferStereo16 (unsigned long *pbuf, int endtime)\n{\n\tint\t\tlpos;\n\tint\t\tls_paintedtime;\n\t\n\tsnd_p = (int *) paintbuffer;\n\tls_paintedtime = s_paintedtime;\n\n\twhile (ls_paintedtime < endtime)\n\t{\n\t// handle recirculating buffer issues\n\t\tlpos = ls_paintedtime & ((dma.samples>>1)-1);\n\n\t\tsnd_out = (short *) pbuf + (lpos<<1);\n\n\t\tsnd_linear_count = (dma.samples>>1) - lpos;\n\t\tif (ls_paintedtime + snd_linear_count > endtime)\n\t\t\tsnd_linear_count = endtime - ls_paintedtime;\n\n\t\tsnd_linear_count <<= 1;\n\n\t// write a linear blast of samples\n\t\tS_WriteLinearBlastStereo16 ();\n\n\t\tsnd_p += snd_linear_count;\n\t\tls_paintedtime += (snd_linear_count>>1);\n\t}\n}\n\n/*\n===================\nS_TransferPaintBuffer\n\n===================\n*/\nvoid S_TransferPaintBuffer(int endtime)\n{\n\tint \tout_idx;\n\tint \tcount;\n\tint \tout_mask;\n\tint \t*p;\n\tint \tstep;\n\tint\t\tval;\n\tunsigned long *pbuf;\n\n\tpbuf = (unsigned long *)dma.buffer;\n\n\n\tif ( s_testsound->integer ) {\n\t\tint\t\ti;\n\t\tint\t\tcount;\n\n\t\t// write a fixed sine wave\n\t\tcount = (endtime - s_paintedtime);\n\t\tfor (i=0 ; i<count ; i++)\n\t\t\tpaintbuffer[i].left = paintbuffer[i].right = sin((s_paintedtime+i)*0.1)*20000*256;\n\t}\n\n\n\tif (dma.samplebits == 16 && dma.channels == 2)\n\t{\t// optimized case\n\t\tS_TransferStereo16 (pbuf, endtime);\n\t}\n\telse\n\t{\t// general case\n\t\tp = (int *) paintbuffer;\n\t\tcount = (endtime - s_paintedtime) * dma.channels;\n\t\tout_mask = dma.samples - 1; \n\t\tout_idx = s_paintedtime * dma.channels & out_mask;\n\t\tstep = 3 - dma.channels;\n\n\t\tif (dma.samplebits == 16)\n\t\t{\n\t\t\tshort *out = (short *) pbuf;\n\t\t\twhile (count--)\n\t\t\t{\n\t\t\t\tval = *p >> 8;\n\t\t\t\tp+= step;\n\t\t\t\tif (val > 0x7fff)\n\t\t\t\t\tval = 0x7fff;\n\t\t\t\telse if (val < -32768)\n\t\t\t\t\tval = -32768;\n\t\t\t\tout[out_idx] = val;\n\t\t\t\tout_idx = (out_idx + 1) & out_mask;\n\t\t\t}\n\t\t}\n\t\telse if (dma.samplebits == 8)\n\t\t{\n\t\t\tunsigned char *out = (unsigned char *) pbuf;\n\t\t\twhile (count--)\n\t\t\t{\n\t\t\t\tval = *p >> 8;\n\t\t\t\tp+= step;\n\t\t\t\tif (val > 0x7fff)\n\t\t\t\t\tval = 0x7fff;\n\t\t\t\telse if (val < -32768)\n\t\t\t\t\tval = -32768;\n\t\t\t\tout[out_idx] = (val>>8) + 128;\n\t\t\t\tout_idx = (out_idx + 1) & out_mask;\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n/*\n===============================================================================\n\nCHANNEL MIXING\n\n===============================================================================\n*/\n\nstatic void S_PaintChannelFrom16( channel_t *ch, const sfx_t *sc, int count, int sampleOffset, int bufferOffset ) {\n\tint\t\t\t\t\t\tdata, aoff, boff;\n\tint\t\t\t\t\t\tleftvol, rightvol;\n\tint\t\t\t\t\t\ti, j;\n\tportable_samplepair_t\t*samp;\n\tsndBuffer\t\t\t\t*chunk;\n\tshort\t\t\t\t\t*samples;\n\tfloat\t\t\t\t\tooff, fdata, fdiv, fleftvol, frightvol;\n\n\tsamp = &paintbuffer[ bufferOffset ];\n\n\tif (ch->doppler) {\n\t\tsampleOffset = sampleOffset*ch->oldDopplerScale;\n\t}\n\n\tchunk = sc->soundData;\n\twhile (sampleOffset>=SND_CHUNK_SIZE) {\n\t\tchunk = chunk->next;\n\t\tsampleOffset -= SND_CHUNK_SIZE;\n\t\tif (!chunk) {\n\t\t\tchunk = sc->soundData;\n\t\t}\n\t}\n\n\tif (!ch->doppler || ch->dopplerScale==1.0f) {\n#if idppc_altivec\n\t\tvector signed short volume_vec;\n\t\tvector unsigned int volume_shift;\n\t\tint vectorCount, samplesLeft, chunkSamplesLeft;\n#endif\n\t\tleftvol = ch->leftvol*snd_vol;\n\t\trightvol = ch->rightvol*snd_vol;\n\t\tsamples = chunk->sndChunk;\n#if idppc_altivec\n\t\t((short *)&volume_vec)[0] = leftvol;\n\t\t((short *)&volume_vec)[1] = leftvol;\n\t\t((short *)&volume_vec)[4] = leftvol;\n\t\t((short *)&volume_vec)[5] = leftvol;\n\t\t((short *)&volume_vec)[2] = rightvol;\n\t\t((short *)&volume_vec)[3] = rightvol;\n\t\t((short *)&volume_vec)[6] = rightvol;\n\t\t((short *)&volume_vec)[7] = rightvol;\n\t\tvolume_shift = vec_splat_u32(8);\n\t\ti = 0;\n\n\t\twhile(i < count) {\n\t\t\t/* Try to align destination to 16-byte boundary */\n\t\t\twhile(i < count && (((unsigned long)&samp[i] & 0x1f) || ((count-i) < 8) || ((SND_CHUNK_SIZE - sampleOffset) < 8))) {\n\t\t\t\tdata  = samples[sampleOffset++];\n\t\t\t\tsamp[i].left += (data * leftvol)>>8;\n\t\t\t\tsamp[i].right += (data * rightvol)>>8;\n\t\n\t\t\t\tif (sampleOffset == SND_CHUNK_SIZE) {\n\t\t\t\t\tchunk = chunk->next;\n\t\t\t\t\tsamples = chunk->sndChunk;\n\t\t\t\t\tsampleOffset = 0;\n\t\t\t\t}\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t/* Destination is now aligned.  Process as many 8-sample \n\t\t\t   chunks as we can before we run out of room from the current\n\t\t\t   sound chunk.  We do 8 per loop to avoid extra source data reads. */\n\t\t\tsamplesLeft = count - i;\n\t\t\tchunkSamplesLeft = SND_CHUNK_SIZE - sampleOffset;\n\t\t\tif(samplesLeft > chunkSamplesLeft)\n\t\t\t\tsamplesLeft = chunkSamplesLeft;\n\t\t\t\n\t\t\tvectorCount = samplesLeft / 8;\n\t\t\t\n\t\t\tif(vectorCount)\n\t\t\t{\n\t\t\t\tvector unsigned char tmp;\n\t\t\t\tvector short s0, s1, sampleData0, sampleData1;\n\t\t\t\tvector short samples0, samples1;\n\t\t\t\tvector signed int left0, right0;\n\t\t\t\tvector signed int merge0, merge1;\n\t\t\t\tvector signed int d0, d1, d2, d3;\t\t\t\t\n\t\t\t\tvector unsigned char samplePermute0 = \n\t\t\t\t\t(vector unsigned char)(0, 1, 4, 5, 0, 1, 4, 5, 2, 3, 6, 7, 2, 3, 6, 7);\n\t\t\t\tvector unsigned char samplePermute1 = \n\t\t\t\t\t(vector unsigned char)(8, 9, 12, 13, 8, 9, 12, 13, 10, 11, 14, 15, 10, 11, 14, 15);\n\t\t\t\tvector unsigned char loadPermute0, loadPermute1;\n\t\t\t\t\n\t\t\t\t// Rather than permute the vectors after we load them to do the sample\n\t\t\t\t// replication and rearrangement, we permute the alignment vector so\n\t\t\t\t// we do everything in one step below and avoid data shuffling.\n\t\t\t\ttmp = vec_lvsl(0,&samples[sampleOffset]);\t\t\t\t\t\t\t\t\n\t\t\t\tloadPermute0 = vec_perm(tmp,tmp,samplePermute0);\n\t\t\t\tloadPermute1 = vec_perm(tmp,tmp,samplePermute1);\n\t\t\t\t\n\t\t\t\ts0 = *(vector short *)&samples[sampleOffset];\n\t\t\t\twhile(vectorCount)\n\t\t\t\t{\n\t\t\t\t\t/* Load up source (16-bit) sample data */\n\t\t\t\t\ts1 = *(vector short *)&samples[sampleOffset+7];\n\t\t\t\t\t\n\t\t\t\t\t/* Load up destination sample data */\n\t\t\t\t\td0 = *(vector signed int *)&samp[i];\n\t\t\t\t\td1 = *(vector signed int *)&samp[i+2];\n\t\t\t\t\td2 = *(vector signed int *)&samp[i+4];\n\t\t\t\t\td3 = *(vector signed int *)&samp[i+6];\n\n\t\t\t\t\tsampleData0 = vec_perm(s0,s1,loadPermute0);\n\t\t\t\t\tsampleData1 = vec_perm(s0,s1,loadPermute1);\n\t\t\t\t\t\n\t\t\t\t\tmerge0 = vec_mule(sampleData0,volume_vec);\n\t\t\t\t\tmerge0 = vec_sra(merge0,volume_shift);\t/* Shift down to proper range */\n\t\t\t\t\t\n\t\t\t\t\tmerge1 = vec_mulo(sampleData0,volume_vec);\n\t\t\t\t\tmerge1 = vec_sra(merge1,volume_shift);\n\t\t\t\t\t\n\t\t\t\t\td0 = vec_add(merge0,d0);\n\t\t\t\t\td1 = vec_add(merge1,d1);\n\t\t\t\t\t\n\t\t\t\t\tmerge0 = vec_mule(sampleData1,volume_vec);\n\t\t\t\t\tmerge0 = vec_sra(merge0,volume_shift);\t/* Shift down to proper range */\n\t\t\t\t\t\n\t\t\t\t\tmerge1 = vec_mulo(sampleData1,volume_vec);\n\t\t\t\t\tmerge1 = vec_sra(merge1,volume_shift);\t\t\t\t\t\n\n\t\t\t\t\td2 = vec_add(merge0,d2);\n\t\t\t\t\td3 = vec_add(merge1,d3);\n\n\t\t\t\t\t/* Store destination sample data */\n\t\t\t\t\t*(vector signed int *)&samp[i] = d0;\n\t\t\t\t\t*(vector signed int *)&samp[i+2] = d1;\n\t\t\t\t\t*(vector signed int *)&samp[i+4] = d2;\n\t\t\t\t\t*(vector signed int *)&samp[i+6] = d3;\n\n\t\t\t\t\ti += 8;\n\t\t\t\t\tvectorCount--;\n\t\t\t\t\ts0 = s1;\n\t\t\t\t\tsampleOffset += 8;\n\t\t\t\t}\n\t\t\t\tif (sampleOffset == SND_CHUNK_SIZE) {\n\t\t\t\t\tchunk = chunk->next;\n\t\t\t\t\tsamples = chunk->sndChunk;\n\t\t\t\t\tsampleOffset = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n#else\t\t\t\n\t\tfor ( i=0 ; i<count ; i++ ) {\n\t\t\tdata  = samples[sampleOffset++];\n\t\t\tsamp[i].left += (data * leftvol)>>8;\n\t\t\tsamp[i].right += (data * rightvol)>>8;\n\n\t\t\tif (sampleOffset == SND_CHUNK_SIZE) {\n\t\t\t\tchunk = chunk->next;\n\t\t\t\tsamples = chunk->sndChunk;\n\t\t\t\tsampleOffset = 0;\n\t\t\t}\n\t\t}\n#endif\n\t} else {\n\t\tfleftvol = ch->leftvol*snd_vol;\n\t\tfrightvol = ch->rightvol*snd_vol;\n\n\t\tooff = sampleOffset;\n\t\tsamples = chunk->sndChunk;\n\t\t\n\n\n\n\t\tfor ( i=0 ; i<count ; i++ ) {\n\n\t\t\taoff = ooff;\n\t\t\tooff = ooff + ch->dopplerScale;\n\t\t\tboff = ooff;\n\t\t\tfdata = 0;\n\t\t\tfor (j=aoff; j<boff; j++) {\n\t\t\t\tif (j == SND_CHUNK_SIZE) {\n\t\t\t\t\tchunk = chunk->next;\n\t\t\t\t\tif (!chunk) {\n\t\t\t\t\t\tchunk = sc->soundData;\n\t\t\t\t\t}\n\t\t\t\t\tsamples = chunk->sndChunk;\n\t\t\t\t\tooff -= SND_CHUNK_SIZE;\n\t\t\t\t}\n\t\t\t\tfdata  += samples[j&(SND_CHUNK_SIZE-1)];\n\t\t\t}\n\t\t\tfdiv = 256 * (boff-aoff);\n\t\t\tsamp[i].left += (fdata * fleftvol)/fdiv;\n\t\t\tsamp[i].right += (fdata * frightvol)/fdiv;\n\t\t}\n\t}\n}\n\nvoid S_PaintChannelFromWavelet( channel_t *ch, sfx_t *sc, int count, int sampleOffset, int bufferOffset ) {\n\tint\t\t\t\t\t\tdata;\n\tint\t\t\t\t\t\tleftvol, rightvol;\n\tint\t\t\t\t\t\ti;\n\tportable_samplepair_t\t*samp;\n\tsndBuffer\t\t\t\t*chunk;\n\tshort\t\t\t\t\t*samples;\n\n\tleftvol = ch->leftvol*snd_vol;\n\trightvol = ch->rightvol*snd_vol;\n\n\ti = 0;\n\tsamp = &paintbuffer[ bufferOffset ];\n\tchunk = sc->soundData;\n\twhile (sampleOffset>=(SND_CHUNK_SIZE_FLOAT*4)) {\n\t\tchunk = chunk->next;\n\t\tsampleOffset -= (SND_CHUNK_SIZE_FLOAT*4);\n\t\ti++;\n\t}\n\n\tif (i!=sfxScratchIndex || sfxScratchPointer != sc) {\n\t\tS_AdpcmGetSamples( chunk, sfxScratchBuffer );\n\t\tsfxScratchIndex = i;\n\t\tsfxScratchPointer = sc;\n\t}\n\n\tsamples = sfxScratchBuffer;\n\n\tfor ( i=0 ; i<count ; i++ ) {\n\t\tdata  = samples[sampleOffset++];\n\t\tsamp[i].left += (data * leftvol)>>8;\n\t\tsamp[i].right += (data * rightvol)>>8;\n\n\t\tif (sampleOffset == SND_CHUNK_SIZE*2) {\n\t\t\tchunk = chunk->next;\n\t\t\tdecodeWavelet(chunk, sfxScratchBuffer);\n\t\t\tsfxScratchIndex++;\n\t\t\tsampleOffset = 0;\n\t\t}\n\t}\n}\n\nvoid S_PaintChannelFromADPCM( channel_t *ch, sfx_t *sc, int count, int sampleOffset, int bufferOffset ) {\n\tint\t\t\t\t\t\tdata;\n\tint\t\t\t\t\t\tleftvol, rightvol;\n\tint\t\t\t\t\t\ti;\n\tportable_samplepair_t\t*samp;\n\tsndBuffer\t\t\t\t*chunk;\n\tshort\t\t\t\t\t*samples;\n\n\tleftvol = ch->leftvol*snd_vol;\n\trightvol = ch->rightvol*snd_vol;\n\n\ti = 0;\n\tsamp = &paintbuffer[ bufferOffset ];\n\tchunk = sc->soundData;\n\n\tif (ch->doppler) {\n\t\tsampleOffset = sampleOffset*ch->oldDopplerScale;\n\t}\n\n\twhile (sampleOffset>=(SND_CHUNK_SIZE*4)) {\n\t\tchunk = chunk->next;\n\t\tsampleOffset -= (SND_CHUNK_SIZE*4);\n\t\ti++;\n\t}\n\n\tif (i!=sfxScratchIndex || sfxScratchPointer != sc) {\n\t\tS_AdpcmGetSamples( chunk, sfxScratchBuffer );\n\t\tsfxScratchIndex = i;\n\t\tsfxScratchPointer = sc;\n\t}\n\n\tsamples = sfxScratchBuffer;\n\n\tfor ( i=0 ; i<count ; i++ ) {\n\t\tdata  = samples[sampleOffset++];\n\t\tsamp[i].left += (data * leftvol)>>8;\n\t\tsamp[i].right += (data * rightvol)>>8;\n\n\t\tif (sampleOffset == SND_CHUNK_SIZE*4) {\n\t\t\tchunk = chunk->next;\n\t\t\tS_AdpcmGetSamples( chunk, sfxScratchBuffer);\n\t\t\tsampleOffset = 0;\n\t\t\tsfxScratchIndex++;\n\t\t}\n\t}\n}\n\nvoid S_PaintChannelFromMuLaw( channel_t *ch, sfx_t *sc, int count, int sampleOffset, int bufferOffset ) {\n\tint\t\t\t\t\t\tdata;\n\tint\t\t\t\t\t\tleftvol, rightvol;\n\tint\t\t\t\t\t\ti;\n\tportable_samplepair_t\t*samp;\n\tsndBuffer\t\t\t\t*chunk;\n\tbyte\t\t\t\t\t*samples;\n\tfloat\t\t\t\t\tooff;\n\n\tleftvol = ch->leftvol*snd_vol;\n\trightvol = ch->rightvol*snd_vol;\n\n\tsamp = &paintbuffer[ bufferOffset ];\n\tchunk = sc->soundData;\n\twhile (sampleOffset>=(SND_CHUNK_SIZE*2)) {\n\t\tchunk = chunk->next;\n\t\tsampleOffset -= (SND_CHUNK_SIZE*2);\n\t\tif (!chunk) {\n\t\t\tchunk = sc->soundData;\n\t\t}\n\t}\n\n\tif (!ch->doppler) {\n\t\tsamples = (byte *)chunk->sndChunk + sampleOffset;\n\t\tfor ( i=0 ; i<count ; i++ ) {\n\t\t\tdata  = mulawToShort[*samples];\n\t\t\tsamp[i].left += (data * leftvol)>>8;\n\t\t\tsamp[i].right += (data * rightvol)>>8;\n\t\t\tsamples++;\n\t\t\tif (samples == (byte *)chunk->sndChunk+(SND_CHUNK_SIZE*2)) {\n\t\t\t\tchunk = chunk->next;\n\t\t\t\tsamples = (byte *)chunk->sndChunk;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tooff = sampleOffset;\n\t\tsamples = (byte *)chunk->sndChunk;\n\t\tfor ( i=0 ; i<count ; i++ ) {\n\t\t\tdata  = mulawToShort[samples[(int)(ooff)]];\n\t\t\tooff = ooff + ch->dopplerScale;\n\t\t\tsamp[i].left += (data * leftvol)>>8;\n\t\t\tsamp[i].right += (data * rightvol)>>8;\n\t\t\tif (ooff >= SND_CHUNK_SIZE*2) {\n\t\t\t\tchunk = chunk->next;\n\t\t\t\tif (!chunk) {\n\t\t\t\t\tchunk = sc->soundData;\n\t\t\t\t}\n\t\t\t\tsamples = (byte *)chunk->sndChunk;\n\t\t\t\tooff = 0.0;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n===================\nS_PaintChannels\n===================\n*/\nvoid S_PaintChannels( int endtime ) {\n\tint \ti;\n\tint \tend;\n\tchannel_t *ch;\n\tsfx_t\t*sc;\n\tint\t\tltime, count;\n\tint\t\tsampleOffset;\n\n\n\tsnd_vol = s_volume->value*255;\n\n//Com_Printf (\"%i to %i\\n\", s_paintedtime, endtime);\n\twhile ( s_paintedtime < endtime ) {\n\t\t// if paintbuffer is smaller than DMA buffer\n\t\t// we may need to fill it multiple times\n\t\tend = endtime;\n\t\tif ( endtime - s_paintedtime > PAINTBUFFER_SIZE ) {\n\t\t\tend = s_paintedtime + PAINTBUFFER_SIZE;\n\t\t}\n\n\t\t// clear the paint buffer to either music or zeros\n\t\tif ( s_rawend < s_paintedtime ) {\n\t\t\tif ( s_rawend ) {\n\t\t\t\t//Com_DPrintf (\"background sound underrun\\n\");\n\t\t\t}\n\t\t\tCom_Memset(paintbuffer, 0, (end - s_paintedtime) * sizeof(portable_samplepair_t));\n\t\t} else {\n\t\t\t// copy from the streaming sound source\n\t\t\tint\t\ts;\n\t\t\tint\t\tstop;\n\n\t\t\tstop = (end < s_rawend) ? end : s_rawend;\n\n\t\t\tfor ( i = s_paintedtime ; i < stop ; i++ ) {\n\t\t\t\ts = i&(MAX_RAW_SAMPLES-1);\n\t\t\t\tpaintbuffer[i-s_paintedtime] = s_rawsamples[s];\n\t\t\t}\n//\t\tif (i != end)\n//\t\t\tCom_Printf (\"partial stream\\n\");\n//\t\telse\n//\t\t\tCom_Printf (\"full stream\\n\");\n\t\t\tfor ( ; i < end ; i++ ) {\n\t\t\t\tpaintbuffer[i-s_paintedtime].left =\n\t\t\t\tpaintbuffer[i-s_paintedtime].right = 0;\n\t\t\t}\n\t\t}\n\n\t\t// paint in the channels.\n\t\tch = s_channels;\n\t\tfor ( i = 0; i < MAX_CHANNELS ; i++, ch++ ) {\t\t\n\t\t\tif ( !ch->thesfx || (ch->leftvol<0.25 && ch->rightvol<0.25 )) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tltime = s_paintedtime;\n\t\t\tsc = ch->thesfx;\n\n\t\t\tsampleOffset = ltime - ch->startSample;\n\t\t\tcount = end - ltime;\n\t\t\tif ( sampleOffset + count > sc->soundLength ) {\n\t\t\t\tcount = sc->soundLength - sampleOffset;\n\t\t\t}\n\n\t\t\tif ( count > 0 ) {\t\n\t\t\t\tif( sc->soundCompressionMethod == 1) {\n\t\t\t\t\tS_PaintChannelFromADPCM\t\t(ch, sc, count, sampleOffset, ltime - s_paintedtime);\n\t\t\t\t} else if( sc->soundCompressionMethod == 2) {\n\t\t\t\t\tS_PaintChannelFromWavelet\t(ch, sc, count, sampleOffset, ltime - s_paintedtime);\n\t\t\t\t} else if( sc->soundCompressionMethod == 3) {\n\t\t\t\t\tS_PaintChannelFromMuLaw\t(ch, sc, count, sampleOffset, ltime - s_paintedtime);\n\t\t\t\t} else {\n\t\t\t\t\tS_PaintChannelFrom16\t\t(ch, sc, count, sampleOffset, ltime - s_paintedtime);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// paint in the looped channels.\n\t\tch = loop_channels;\n\t\tfor ( i = 0; i < numLoopChannels ; i++, ch++ ) {\t\t\n\t\t\tif ( !ch->thesfx || (!ch->leftvol && !ch->rightvol )) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tltime = s_paintedtime;\n\t\t\tsc = ch->thesfx;\n\n\t\t\tif (sc->soundData==NULL || sc->soundLength==0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// we might have to make two passes if it\n\t\t\t// is a looping sound effect and the end of\n\t\t\t// the sample is hit\n\t\t\tdo {\n\t\t\t\tsampleOffset = (ltime % sc->soundLength);\n\n\t\t\t\tcount = end - ltime;\n\t\t\t\tif ( sampleOffset + count > sc->soundLength ) {\n\t\t\t\t\tcount = sc->soundLength - sampleOffset;\n\t\t\t\t}\n\n\t\t\t\tif ( count > 0 ) {\t\n\t\t\t\t\tif( sc->soundCompressionMethod == 1) {\n\t\t\t\t\t\tS_PaintChannelFromADPCM\t\t(ch, sc, count, sampleOffset, ltime - s_paintedtime);\n\t\t\t\t\t} else if( sc->soundCompressionMethod == 2) {\n\t\t\t\t\t\tS_PaintChannelFromWavelet\t(ch, sc, count, sampleOffset, ltime - s_paintedtime);\n\t\t\t\t\t} else if( sc->soundCompressionMethod == 3) {\n\t\t\t\t\t\tS_PaintChannelFromMuLaw\t\t(ch, sc, count, sampleOffset, ltime - s_paintedtime);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tS_PaintChannelFrom16\t\t(ch, sc, count, sampleOffset, ltime - s_paintedtime);\n\t\t\t\t\t}\n\t\t\t\t\tltime += count;\n\t\t\t\t}\n\t\t\t} while ( ltime < end);\n\t\t}\n\n\t\t// transfer out according to DMA format\n\t\tS_TransferPaintBuffer( end );\n\t\ts_paintedtime = end;\n\t}\n}\n"
  },
  {
    "path": "code/client/snd_public.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n\nvoid S_Init( void );\nvoid S_Shutdown( void );\n\n// if origin is NULL, the sound will be dynamically sourced from the entity\nvoid S_StartSound( vec3_t origin, int entnum, int entchannel, sfxHandle_t sfx );\nvoid S_StartLocalSound( sfxHandle_t sfx, int channelNum );\n\nvoid S_StartBackgroundTrack( const char *intro, const char *loop );\nvoid S_StopBackgroundTrack( void );\n\n// cinematics and voice-over-network will send raw samples\n// 1.0 volume will be direct output of source samples\nvoid S_RawSamples (int samples, int rate, int width, int channels, \n\t\t\t\t   const byte *data, float volume);\n\n// stop all sounds and the background track\nvoid S_StopAllSounds( void );\n\n// all continuous looping sounds must be added before calling S_Update\nvoid S_ClearLoopingSounds( qboolean killall );\nvoid S_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx );\nvoid S_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx );\nvoid S_StopLoopingSound(int entityNum );\n\n// recompute the reletive volumes for all running sounds\n// reletive to the given entityNum / orientation\nvoid S_Respatialize( int entityNum, const vec3_t origin, vec3_t axis[3], int inwater );\n\n// let the sound system know where an entity currently is\nvoid S_UpdateEntityPosition( int entityNum, const vec3_t origin );\n\nvoid S_Update( void );\n\nvoid S_DisableSounds( void );\n\nvoid S_BeginRegistration( void );\n\n// RegisterSound will allways return a valid sample, even if it\n// has to create a placeholder.  This prevents continuous filesystem\n// checks for missing files\nsfxHandle_t\tS_RegisterSound( const char *sample, qboolean compressed );\n\nvoid S_DisplayFreeMemory(void);\n\nvoid S_ClearSoundBuffer( void );\n\nvoid SNDDMA_Activate( void );\n\nvoid S_UpdateBackgroundTrack( void );\n"
  },
  {
    "path": "code/client/snd_wavelet.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"snd_local.h\"\n\nlong myftol( float f );\n\n#define C0 0.4829629131445341\n#define C1 0.8365163037378079\n#define C2 0.2241438680420134\n#define C3 -0.1294095225512604\n\nvoid daub4(float b[], unsigned long n, int isign)\n{\n\tfloat wksp[4097];\n\tfloat\t*a=b-1;\t\t\t\t\t\t// numerical recipies so a[1] = b[0]\n\n\tunsigned long nh,nh1,i,j;\n\n\tif (n < 4) return;\n\n\tnh1=(nh=n >> 1)+1;\n\tif (isign >= 0) {\n\t\tfor (i=1,j=1;j<=n-3;j+=2,i++) {\n\t\t\twksp[i]\t   = C0*a[j]+C1*a[j+1]+C2*a[j+2]+C3*a[j+3];\n\t\t\twksp[i+nh] = C3*a[j]-C2*a[j+1]+C1*a[j+2]-C0*a[j+3];\n\t\t}\n\t\twksp[i   ] = C0*a[n-1]+C1*a[n]+C2*a[1]+C3*a[2];\n\t\twksp[i+nh] = C3*a[n-1]-C2*a[n]+C1*a[1]-C0*a[2];\n\t} else {\n\t\twksp[1] = C2*a[nh]+C1*a[n]+C0*a[1]+C3*a[nh1];\n\t\twksp[2] = C3*a[nh]-C0*a[n]+C1*a[1]-C2*a[nh1];\n\t\tfor (i=1,j=3;i<nh;i++) {\n\t\t\twksp[j++] = C2*a[i]+C1*a[i+nh]+C0*a[i+1]+C3*a[i+nh1];\n\t\t\twksp[j++] = C3*a[i]-C0*a[i+nh]+C1*a[i+1]-C2*a[i+nh1];\n\t\t}\n\t}\n\tfor (i=1;i<=n;i++) {\n\t\ta[i]=wksp[i];\n\t}\n}\n\nvoid wt1(float a[], unsigned long n, int isign)\n{\n\tunsigned long nn;\n\tint inverseStartLength = n/4;\n\tif (n < inverseStartLength) return;\n\tif (isign >= 0) {\n\t\tfor (nn=n;nn>=inverseStartLength;nn>>=1) daub4(a,nn,isign);\n\t} else {\n\t\tfor (nn=inverseStartLength;nn<=n;nn<<=1) daub4(a,nn,isign);\n\t}\n}\n\n/* The number of bits required by each value */\nstatic unsigned char numBits[] = {\n   0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,\n   6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,\n   7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,\n   7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,\n   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,\n   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,\n   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,\n   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,\n};\n\nbyte MuLawEncode(short s) {\n\tunsigned long adjusted;\n\tbyte sign, exponent, mantissa;\n\n\tsign = (s<0)?0:0x80;\n\n\tif (s<0) s=-s;\n\tadjusted = (long)s << (16-sizeof(short)*8);\n\tadjusted += 128L + 4L;\n\tif (adjusted > 32767) adjusted = 32767;\n\texponent = numBits[(adjusted>>7)&0xff] - 1;\n\tmantissa = (adjusted>>(exponent+3))&0xf;\n\treturn ~(sign | (exponent<<4) | mantissa);\n}\n\nshort MuLawDecode(byte uLaw) {\n\tsigned long adjusted;\n\tbyte exponent, mantissa;\n\n\tuLaw = ~uLaw;\n\texponent = (uLaw>>4) & 0x7;\n\tmantissa = (uLaw&0xf) + 16;\n\tadjusted = (mantissa << (exponent +3)) - 128 - 4;\n\n\treturn (uLaw & 0x80)? adjusted : -adjusted;\n}\n\nshort mulawToShort[256];\nstatic qboolean madeTable = qfalse;\n\nstatic\tint\tNXStreamCount;\n\nvoid NXPutc(NXStream *stream, char out) {\n\tstream[NXStreamCount++] = out;\n}\n\n\nvoid encodeWavelet( sfx_t *sfx, short *packets) {\n\tfloat\twksp[4097], temp;\n\tint\t\ti, samples, size;\n\tsndBuffer\t\t*newchunk, *chunk;\n\tbyte\t\t\t*out;\n\n\tif (!madeTable) {\n\t\tfor (i=0;i<256;i++) {\n\t\t\tmulawToShort[i] = (float)MuLawDecode((byte)i);\n\t\t}\n\t\tmadeTable = qtrue;\n\t}\n\tchunk = NULL;\n\n\tsamples = sfx->soundLength;\n\twhile(samples>0) {\n\t\tsize = samples;\n\t\tif (size>(SND_CHUNK_SIZE*2)) {\n\t\t\tsize = (SND_CHUNK_SIZE*2);\n\t\t}\n\n\t\tif (size<4) {\n\t\t\tsize = 4;\n\t\t}\n\n\t\tnewchunk = SND_malloc();\n\t\tif (sfx->soundData == NULL) {\n\t\t\tsfx->soundData = newchunk;\n\t\t} else {\n\t\t\tchunk->next = newchunk;\n\t\t}\n\t\tchunk = newchunk;\n\t\tfor(i=0; i<size; i++) {\n\t\t\twksp[i] = *packets;\n\t\t\tpackets++;\n\t\t}\n\t\twt1(wksp, size, 1);\n\t\tout = (byte *)chunk->sndChunk;\n\n\t\tfor(i=0;i<size;i++) {\n\t\t\ttemp = wksp[i];\n\t\t\tif (temp > 32767) temp = 32767; else if (temp<-32768) temp = -32768;\n\t\t\tout[i] = MuLawEncode((short)temp);\n\t\t}\n\n\t\tchunk->size = size;\n\t\tsamples -= size;\n\t}\n}\n\nvoid decodeWavelet(sndBuffer *chunk, short *to) {\n\tfloat\t\t\twksp[4097];\n\tint\t\t\t\ti;\n\tbyte\t\t\t*out;\n\n\tint size = chunk->size;\n\t\n\tout = (byte *)chunk->sndChunk;\n\tfor(i=0;i<size;i++) {\n\t\twksp[i] = mulawToShort[out[i]];\n\t}\n\n\twt1(wksp, size, -1);\n\t\n\tif (!to) return;\n\n\tfor(i=0; i<size; i++) {\n\t\tto[i] = wksp[i];\n\t}\n}\n\n\nvoid encodeMuLaw( sfx_t *sfx, short *packets) {\n\tint\t\ti, samples, size, grade, poop;\n\tsndBuffer\t\t*newchunk, *chunk;\n\tbyte\t\t\t*out;\n\n\tif (!madeTable) {\n\t\tfor (i=0;i<256;i++) {\n\t\t\tmulawToShort[i] = (float)MuLawDecode((byte)i);\n\t\t}\n\t\tmadeTable = qtrue;\n\t}\n\n\tchunk = NULL;\n\tsamples = sfx->soundLength;\n\tgrade = 0;\n\n\twhile(samples>0) {\n\t\tsize = samples;\n\t\tif (size>(SND_CHUNK_SIZE*2)) {\n\t\t\tsize = (SND_CHUNK_SIZE*2);\n\t\t}\n\n\t\tnewchunk = SND_malloc();\n\t\tif (sfx->soundData == NULL) {\n\t\t\tsfx->soundData = newchunk;\n\t\t} else {\n\t\t\tchunk->next = newchunk;\n\t\t}\n\t\tchunk = newchunk;\n\t\tout = (byte *)chunk->sndChunk;\n\t\tfor(i=0; i<size; i++) {\n\t\t\tpoop = packets[0]+grade;\n\t\t\tif (poop>32767) {\n\t\t\t\tpoop = 32767;\n\t\t\t} else if (poop<-32768) {\n\t\t\t\tpoop = -32768;\n\t\t\t}\n\t\t\tout[i] = MuLawEncode((short)poop);\n\t\t\tgrade = poop - mulawToShort[out[i]];\n\t\t\tpackets++;\n\t\t}\n\t\tchunk->size = size;\n\t\tsamples -= size;\n\t}\n}\n\nvoid decodeMuLaw(sndBuffer *chunk, short *to) {\n\tint\t\t\t\ti;\n\tbyte\t\t\t*out;\n\n\tint size = chunk->size;\n\t\n\tout = (byte *)chunk->sndChunk;\n\tfor(i=0;i<size;i++) {\n\t\tto[i] = mulawToShort[out[i]];\n\t}\n}\n\n\n"
  },
  {
    "path": "code/game/Conscript",
    "content": "# game building\n# builds the game for vanilla Q3 and TA\n\n# there are slight differences between Q3 and TA build:\n#   -DMISSIONPACK\n# the config is passed in the imported variable TARGET_DIR\n\n# qvm building against native:\n# only native has g_syscalls.c\n# only qvm has ../game/bg_lib.c\n# qvm uses a custom g_syscalls.asm with equ stubs\n\nImport qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );\n\n$env = new cons(\n  # the code has the very bad habit of doing things like #include \"../ui/ui_shared.h\"\n  # this seems to confuse the dependency analysis, explicit toplevel includes seem to fix\n  CPPPATH => '#cgame:#game:#q3_ui',\n  CC => $CC,\n  CXX => $CXX,\n  LINK => $LINK,\n\tENV => { PATH => $ENV{PATH}, HOME => $ENV{HOME} },\n  CFLAGS => $BASE_CFLAGS . '-fPIC',\n  LDFLAGS => '-shared -ldl -lm'\n);\n\n# for TA, use -DMISSIONPACK\n%ta_env_hash = $env->copy(\n  CPPPATH => '#cgame:#game:#ui'\n  );\n$ta_env_hash{CFLAGS} = '-DMISSIONPACK ' . $ta_env_hash{CFLAGS};\n$ta_env = new cons(%ta_env_hash);\n\n# qvm building\n# we heavily customize the cons environment\n$vm_env = new cons(\n  # the code has the very bad habit of doing things like #include \"../ui/ui_shared.h\"\n  # this seems to confuse the dependency analysis, explicit toplevel includes seem to fix\n  CPPPATH => '#cgame:#game:#q3_ui',\n  CC => 'q3lcc',\n  CCCOM => '%CC %CFLAGS %_IFLAGS -c %< -o %>',\n  SUFOBJ => '.asm',\n  LINK => 'q3asm',\n  CFLAGS => '-DQ3_VM -S -Wf-target=bytecode -Wf-g',\n  # need to know where to find the compiler tools\n  ENV => { PATH => $ENV{PATH} . \":./qvmtools\", },\n);\n\n# TA qvm building\n%vm_ta_env_hash = $vm_env->copy(\n  CPPPATH => '#cgame:#game:#ui'\n  );\n$vm_ta_env_hash{CFLAGS} = '-DMISSIONPACK ' . $vm_ta_env_hash{CFLAGS};\n$vm_ta_env = new cons(%vm_ta_env_hash);\n\n# the file with vmMain function MUST be the first one of the list\n@FILES = qw(\n  g_main.c\n  ai_chat.c\n  ai_cmd.c\n  ai_dmnet.c\n  ai_dmq3.c\n  ai_main.c\n  ai_team.c\n  ai_vcmd.c\n  bg_misc.c\n  bg_pmove.c\n  bg_slidemove.c\n  g_active.c\n  g_arenas.c\n  g_bot.c\n  g_client.c\n  g_cmds.c\n  g_combat.c\n  g_items.c\n  g_mem.c\n  g_misc.c\n  g_missile.c\n  g_mover.c\n  g_session.c\n  g_spawn.c\n  g_svcmds.c\n  g_target.c\n  g_team.c\n  g_trigger.c\n  g_utils.c\n  g_weapon.c\n  q_math.c\n  q_shared.c\n  );\n$FILESREF = \\@FILES;\n\n# only in .so\n# (VM uses a custom .asm with equ stubs)\n@SO_FILES = qw(\n  g_syscalls.c\n  );\n$SO_FILESREF = \\@SO_FILES;\n  \n# only for VM\n@VM_FILES = qw(\n  bg_lib.c\n  g_syscalls.asm\n  );\n$VM_FILESREF = \\@VM_FILES;  \n\n# FIXME CPU string?\n# NOTE: $env $ta_env and $vm_env $vm_ta_env may not be necessary\n#   we could alter the $env and $ta_env based on $TARGET_DIR\n#   doing it this way to ensure homogeneity with cgame building\nif ($TARGET_DIR eq 'Q3')\n{\n\tif ($NO_SO eq 0)\n\t{\n\t\tProgram $env 'qagamei386.so', @$FILESREF, @$SO_FILESREF;\n\t\tInstall $env $INSTALL_DIR, 'qagamei386.so';\n\t}\n\tif ($NO_VM eq 0)\n\t{\n    Depends $vm_env 'qagame.qvm', '#qvmtools/q3lcc';\n    Depends $vm_env 'qagame.qvm', '#qvmtools/q3asm';\n\t\tProgram $vm_env 'qagame.qvm', @$FILESREF, @$VM_FILESREF;\n\t\tInstall $vm_env $INSTALL_DIR . '/vm', 'qagame.qvm';\n\t}\n}\nelse\n{\n\tif ($NO_SO eq 0)\n\t{\n\t\tProgram $ta_env 'qagamei386.so', @$FILESREF, @$SO_FILESREF;\n\t\tInstall $ta_env $INSTALL_DIR, 'qagamei386.so';\n\t}\n\tif ($NO_VM eq 0)\n\t{\n    Depends $vm_env 'qagame.qvm', '#qvmtools/q3lcc';\n    Depends $vm_env 'qagame.qvm', '#qvmtools/q3asm';\n\t\tProgram $vm_ta_env 'qagame.qvm', @$FILESREF, @$VM_FILESREF;    \n\t\tInstall $vm_ta_env $INSTALL_DIR . '/vm', 'qagame.qvm';\n\t}\n}\n"
  },
  {
    "path": "code/game/ai_chat.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n/*****************************************************************************\n * name:\t\tai_chat.c\n *\n * desc:\t\tQuake3 bot AI\n *\n * $Archive: /MissionPack/code/game/ai_chat.c $\n *\n *****************************************************************************/\n\n#include \"g_local.h\"\n#include \"botlib.h\"\n#include \"be_aas.h\"\n#include \"be_ea.h\"\n#include \"be_ai_char.h\"\n#include \"be_ai_chat.h\"\n#include \"be_ai_gen.h\"\n#include \"be_ai_goal.h\"\n#include \"be_ai_move.h\"\n#include \"be_ai_weap.h\"\n//\n#include \"ai_main.h\"\n#include \"ai_dmq3.h\"\n#include \"ai_chat.h\"\n#include \"ai_cmd.h\"\n#include \"ai_dmnet.h\"\n//\n#include \"chars.h\"\t\t\t\t//characteristics\n#include \"inv.h\"\t\t\t\t//indexes into the inventory\n#include \"syn.h\"\t\t\t\t//synonyms\n#include \"match.h\"\t\t\t\t//string matching types and vars\n\n// for the voice chats\n#ifdef MISSIONPACK // bk001205\n#include \"../../ui/menudef.h\"\n#endif\n\n#define TIME_BETWEENCHATTING\t25\n\n\n/*\n==================\nBotNumActivePlayers\n==================\n*/\nint BotNumActivePlayers(void) {\n\tint i, num;\n\tchar buf[MAX_INFO_STRING];\n\tstatic int maxclients;\n\n\tif (!maxclients)\n\t\tmaxclients = trap_Cvar_VariableIntegerValue(\"sv_maxclients\");\n\n\tnum = 0;\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\ttrap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));\n\t\t//if no config string or no name\n\t\tif (!strlen(buf) || !strlen(Info_ValueForKey(buf, \"n\"))) continue;\n\t\t//skip spectators\n\t\tif (atoi(Info_ValueForKey(buf, \"t\")) == TEAM_SPECTATOR) continue;\n\t\t//\n\t\tnum++;\n\t}\n\treturn num;\n}\n\n/*\n==================\nBotIsFirstInRankings\n==================\n*/\nint BotIsFirstInRankings(bot_state_t *bs) {\n\tint i, score;\n\tchar buf[MAX_INFO_STRING];\n\tstatic int maxclients;\n\tplayerState_t ps;\n\n\tif (!maxclients)\n\t\tmaxclients = trap_Cvar_VariableIntegerValue(\"sv_maxclients\");\n\n\tscore = bs->cur_ps.persistant[PERS_SCORE];\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\ttrap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));\n\t\t//if no config string or no name\n\t\tif (!strlen(buf) || !strlen(Info_ValueForKey(buf, \"n\"))) continue;\n\t\t//skip spectators\n\t\tif (atoi(Info_ValueForKey(buf, \"t\")) == TEAM_SPECTATOR) continue;\n\t\t//\n\t\tBotAI_GetClientState(i, &ps);\n\t\tif (score < ps.persistant[PERS_SCORE]) return qfalse;\n\t}\n\treturn qtrue;\n}\n\n/*\n==================\nBotIsLastInRankings\n==================\n*/\nint BotIsLastInRankings(bot_state_t *bs) {\n\tint i, score;\n\tchar buf[MAX_INFO_STRING];\n\tstatic int maxclients;\n\tplayerState_t ps;\n\n\tif (!maxclients)\n\t\tmaxclients = trap_Cvar_VariableIntegerValue(\"sv_maxclients\");\n\n\tscore = bs->cur_ps.persistant[PERS_SCORE];\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\ttrap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));\n\t\t//if no config string or no name\n\t\tif (!strlen(buf) || !strlen(Info_ValueForKey(buf, \"n\"))) continue;\n\t\t//skip spectators\n\t\tif (atoi(Info_ValueForKey(buf, \"t\")) == TEAM_SPECTATOR) continue;\n\t\t//\n\t\tBotAI_GetClientState(i, &ps);\n\t\tif (score > ps.persistant[PERS_SCORE]) return qfalse;\n\t}\n\treturn qtrue;\n}\n\n/*\n==================\nBotFirstClientInRankings\n==================\n*/\nchar *BotFirstClientInRankings(void) {\n\tint i, bestscore, bestclient;\n\tchar buf[MAX_INFO_STRING];\n\tstatic char name[32];\n\tstatic int maxclients;\n\tplayerState_t ps;\n\n\tif (!maxclients)\n\t\tmaxclients = trap_Cvar_VariableIntegerValue(\"sv_maxclients\");\n\n\tbestscore = -999999;\n\tbestclient = 0;\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\ttrap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));\n\t\t//if no config string or no name\n\t\tif (!strlen(buf) || !strlen(Info_ValueForKey(buf, \"n\"))) continue;\n\t\t//skip spectators\n\t\tif (atoi(Info_ValueForKey(buf, \"t\")) == TEAM_SPECTATOR) continue;\n\t\t//\n\t\tBotAI_GetClientState(i, &ps);\n\t\tif (ps.persistant[PERS_SCORE] > bestscore) {\n\t\t\tbestscore = ps.persistant[PERS_SCORE];\n\t\t\tbestclient = i;\n\t\t}\n\t}\n\tEasyClientName(bestclient, name, 32);\n\treturn name;\n}\n\n/*\n==================\nBotLastClientInRankings\n==================\n*/\nchar *BotLastClientInRankings(void) {\n\tint i, worstscore, bestclient;\n\tchar buf[MAX_INFO_STRING];\n\tstatic char name[32];\n\tstatic int maxclients;\n\tplayerState_t ps;\n\n\tif (!maxclients)\n\t\tmaxclients = trap_Cvar_VariableIntegerValue(\"sv_maxclients\");\n\n\tworstscore = 999999;\n\tbestclient = 0;\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\ttrap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));\n\t\t//if no config string or no name\n\t\tif (!strlen(buf) || !strlen(Info_ValueForKey(buf, \"n\"))) continue;\n\t\t//skip spectators\n\t\tif (atoi(Info_ValueForKey(buf, \"t\")) == TEAM_SPECTATOR) continue;\n\t\t//\n\t\tBotAI_GetClientState(i, &ps);\n\t\tif (ps.persistant[PERS_SCORE] < worstscore) {\n\t\t\tworstscore = ps.persistant[PERS_SCORE];\n\t\t\tbestclient = i;\n\t\t}\n\t}\n\tEasyClientName(bestclient, name, 32);\n\treturn name;\n}\n\n/*\n==================\nBotRandomOpponentName\n==================\n*/\nchar *BotRandomOpponentName(bot_state_t *bs) {\n\tint i, count;\n\tchar buf[MAX_INFO_STRING];\n\tint opponents[MAX_CLIENTS], numopponents;\n\tstatic int maxclients;\n\tstatic char name[32];\n\n\tif (!maxclients)\n\t\tmaxclients = trap_Cvar_VariableIntegerValue(\"sv_maxclients\");\n\n\tnumopponents = 0;\n\topponents[0] = 0;\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\tif (i == bs->client) continue;\n\t\t//\n\t\ttrap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));\n\t\t//if no config string or no name\n\t\tif (!strlen(buf) || !strlen(Info_ValueForKey(buf, \"n\"))) continue;\n\t\t//skip spectators\n\t\tif (atoi(Info_ValueForKey(buf, \"t\")) == TEAM_SPECTATOR) continue;\n\t\t//skip team mates\n\t\tif (BotSameTeam(bs, i)) continue;\n\t\t//\n\t\topponents[numopponents] = i;\n\t\tnumopponents++;\n\t}\n\tcount = random() * numopponents;\n\tfor (i = 0; i < numopponents; i++) {\n\t\tcount--;\n\t\tif (count <= 0) {\n\t\t\tEasyClientName(opponents[i], name, sizeof(name));\n\t\t\treturn name;\n\t\t}\n\t}\n\tEasyClientName(opponents[0], name, sizeof(name));\n\treturn name;\n}\n\n/*\n==================\nBotMapTitle\n==================\n*/\n\nchar *BotMapTitle(void) {\n\tchar info[1024];\n\tstatic char mapname[128];\n\n\ttrap_GetServerinfo(info, sizeof(info));\n\n\tstrncpy(mapname, Info_ValueForKey( info, \"mapname\" ), sizeof(mapname)-1);\n\tmapname[sizeof(mapname)-1] = '\\0';\n\n\treturn mapname;\n}\n\n\n/*\n==================\nBotWeaponNameForMeansOfDeath\n==================\n*/\n\nchar *BotWeaponNameForMeansOfDeath(int mod) {\n\tswitch(mod) {\n\t\tcase MOD_SHOTGUN: return \"Shotgun\";\n\t\tcase MOD_GAUNTLET: return \"Gauntlet\";\n\t\tcase MOD_MACHINEGUN: return \"Machinegun\";\n\t\tcase MOD_GRENADE:\n\t\tcase MOD_GRENADE_SPLASH: return \"Grenade Launcher\";\n\t\tcase MOD_ROCKET:\n\t\tcase MOD_ROCKET_SPLASH: return \"Rocket Launcher\";\n\t\tcase MOD_PLASMA:\n\t\tcase MOD_PLASMA_SPLASH: return \"Plasmagun\";\n\t\tcase MOD_RAILGUN: return \"Railgun\";\n\t\tcase MOD_LIGHTNING: return \"Lightning Gun\";\n\t\tcase MOD_BFG:\n\t\tcase MOD_BFG_SPLASH: return \"BFG10K\";\n#ifdef MISSIONPACK\n\t\tcase MOD_NAIL: return \"Nailgun\";\n\t\tcase MOD_CHAINGUN: return \"Chaingun\";\n\t\tcase MOD_PROXIMITY_MINE: return \"Proximity Launcher\";\n\t\tcase MOD_KAMIKAZE: return \"Kamikaze\";\n\t\tcase MOD_JUICED: return \"Prox mine\";\n#endif\n\t\tcase MOD_GRAPPLE: return \"Grapple\";\n\t\tdefault: return \"[unknown weapon]\";\n\t}\n}\n\n/*\n==================\nBotRandomWeaponName\n==================\n*/\nchar *BotRandomWeaponName(void) {\n\tint rnd;\n\n#ifdef MISSIONPACK\n\trnd = random() * 11.9;\n#else\n\trnd = random() * 8.9;\n#endif\n\tswitch(rnd) {\n\t\tcase 0: return \"Gauntlet\";\n\t\tcase 1: return \"Shotgun\";\n\t\tcase 2: return \"Machinegun\";\n\t\tcase 3: return \"Grenade Launcher\";\n\t\tcase 4: return \"Rocket Launcher\";\n\t\tcase 5: return \"Plasmagun\";\n\t\tcase 6: return \"Railgun\";\n\t\tcase 7: return \"Lightning Gun\";\n#ifdef MISSIONPACK\n\t\tcase 8: return \"Nailgun\";\n\t\tcase 9: return \"Chaingun\";\n\t\tcase 10: return \"Proximity Launcher\";\n#endif\n\t\tdefault: return \"BFG10K\";\n\t}\n}\n\n/*\n==================\nBotVisibleEnemies\n==================\n*/\nint BotVisibleEnemies(bot_state_t *bs) {\n\tfloat vis;\n\tint i;\n\taas_entityinfo_t entinfo;\n\n\tfor (i = 0; i < MAX_CLIENTS; i++) {\n\n\t\tif (i == bs->client) continue;\n\t\t//\n\t\tBotEntityInfo(i, &entinfo);\n\t\t//\n\t\tif (!entinfo.valid) continue;\n\t\t//if the enemy isn't dead and the enemy isn't the bot self\n\t\tif (EntityIsDead(&entinfo) || entinfo.number == bs->entitynum) continue;\n\t\t//if the enemy is invisible and not shooting\n\t\tif (EntityIsInvisible(&entinfo) && !EntityIsShooting(&entinfo)) {\n\t\t\tcontinue;\n\t\t}\n\t\t//if on the same team\n\t\tif (BotSameTeam(bs, i)) continue;\n\t\t//check if the enemy is visible\n\t\tvis = BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, i);\n\t\tif (vis > 0) return qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nBotValidChatPosition\n==================\n*/\nint BotValidChatPosition(bot_state_t *bs) {\n\tvec3_t point, start, end, mins, maxs;\n\tbsp_trace_t trace;\n\n\t//if the bot is dead all positions are valid\n\tif (BotIsDead(bs)) return qtrue;\n\t//never start chatting with a powerup\n\tif (bs->inventory[INVENTORY_QUAD] ||\n\t\tbs->inventory[INVENTORY_HASTE] ||\n\t\tbs->inventory[INVENTORY_INVISIBILITY] ||\n\t\tbs->inventory[INVENTORY_REGEN] ||\n\t\tbs->inventory[INVENTORY_FLIGHT]) return qfalse;\n\t//must be on the ground\n\t//if (bs->cur_ps.groundEntityNum != ENTITYNUM_NONE) return qfalse;\n\t//do not chat if in lava or slime\n\tVectorCopy(bs->origin, point);\n\tpoint[2] -= 24;\n\tif (trap_PointContents(point,bs->entitynum) & (CONTENTS_LAVA|CONTENTS_SLIME)) return qfalse;\n\t//do not chat if under water\n\tVectorCopy(bs->origin, point);\n\tpoint[2] += 32;\n\tif (trap_PointContents(point,bs->entitynum) & MASK_WATER) return qfalse;\n\t//must be standing on the world entity\n\tVectorCopy(bs->origin, start);\n\tVectorCopy(bs->origin, end);\n\tstart[2] += 1;\n\tend[2] -= 10;\n\ttrap_AAS_PresenceTypeBoundingBox(PRESENCE_CROUCH, mins, maxs);\n\tBotAI_Trace(&trace, start, mins, maxs, end, bs->client, MASK_SOLID);\n\tif (trace.ent != ENTITYNUM_WORLD) return qfalse;\n\t//the bot is in a position where it can chat\n\treturn qtrue;\n}\n\n/*\n==================\nBotChat_EnterGame\n==================\n*/\nint BotChat_EnterGame(bot_state_t *bs) {\n\tchar name[32];\n\tfloat rnd;\n\n\tif (bot_nochat.integer) return qfalse;\n\tif (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;\n\t//don't chat in teamplay\n\tif (TeamPlayIsOn()) return qfalse;\n\t// don't chat in tournament mode\n\tif (gametype == GT_TOURNAMENT) return qfalse;\n\trnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_ENTEREXITGAME, 0, 1);\n\tif (!bot_fastchat.integer) {\n\t\tif (random() > rnd) return qfalse;\n\t}\n\tif (BotNumActivePlayers() <= 1) return qfalse;\n\tif (!BotValidChatPosition(bs)) return qfalse;\n\tBotAI_BotInitialChat(bs, \"game_enter\",\n\t\t\t\tEasyClientName(bs->client, name, 32),\t// 0\n\t\t\t\tBotRandomOpponentName(bs),\t\t\t\t// 1\n\t\t\t\t\"[invalid var]\",\t\t\t\t\t\t// 2\n\t\t\t\t\"[invalid var]\",\t\t\t\t\t\t// 3\n\t\t\t\tBotMapTitle(),\t\t\t\t\t\t\t// 4\n\t\t\t\tNULL);\n\tbs->lastchat_time = FloatTime();\n\tbs->chatto = CHAT_ALL;\n\treturn qtrue;\n}\n\n/*\n==================\nBotChat_ExitGame\n==================\n*/\nint BotChat_ExitGame(bot_state_t *bs) {\n\tchar name[32];\n\tfloat rnd;\n\n\tif (bot_nochat.integer) return qfalse;\n\tif (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;\n\t//don't chat in teamplay\n\tif (TeamPlayIsOn()) return qfalse;\n\t// don't chat in tournament mode\n\tif (gametype == GT_TOURNAMENT) return qfalse;\n\trnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_ENTEREXITGAME, 0, 1);\n\tif (!bot_fastchat.integer) {\n\t\tif (random() > rnd) return qfalse;\n\t}\n\tif (BotNumActivePlayers() <= 1) return qfalse;\n\t//\n\tBotAI_BotInitialChat(bs, \"game_exit\",\n\t\t\t\tEasyClientName(bs->client, name, 32),\t// 0\n\t\t\t\tBotRandomOpponentName(bs),\t\t\t\t// 1\n\t\t\t\t\"[invalid var]\",\t\t\t\t\t\t// 2\n\t\t\t\t\"[invalid var]\",\t\t\t\t\t\t// 3\n\t\t\t\tBotMapTitle(),\t\t\t\t\t\t\t// 4\n\t\t\t\tNULL);\n\tbs->lastchat_time = FloatTime();\n\tbs->chatto = CHAT_ALL;\n\treturn qtrue;\n}\n\n/*\n==================\nBotChat_StartLevel\n==================\n*/\nint BotChat_StartLevel(bot_state_t *bs) {\n\tchar name[32];\n\tfloat rnd;\n\n\tif (bot_nochat.integer) return qfalse;\n\tif (BotIsObserver(bs)) return qfalse;\n\tif (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;\n\t//don't chat in teamplay\n\tif (TeamPlayIsOn()) {\n\t    trap_EA_Command(bs->client, \"vtaunt\");\n\t    return qfalse;\n\t}\n\t// don't chat in tournament mode\n\tif (gametype == GT_TOURNAMENT) return qfalse;\n\trnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_STARTENDLEVEL, 0, 1);\n\tif (!bot_fastchat.integer) {\n\t\tif (random() > rnd) return qfalse;\n\t}\n\tif (BotNumActivePlayers() <= 1) return qfalse;\n\tBotAI_BotInitialChat(bs, \"level_start\",\n\t\t\t\tEasyClientName(bs->client, name, 32),\t// 0\n\t\t\t\tNULL);\n\tbs->lastchat_time = FloatTime();\n\tbs->chatto = CHAT_ALL;\n\treturn qtrue;\n}\n\n/*\n==================\nBotChat_EndLevel\n==================\n*/\nint BotChat_EndLevel(bot_state_t *bs) {\n\tchar name[32];\n\tfloat rnd;\n\n\tif (bot_nochat.integer) return qfalse;\n\tif (BotIsObserver(bs)) return qfalse;\n\tif (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;\n\t// teamplay\n\tif (TeamPlayIsOn()) \n\t{\n\t\tif (BotIsFirstInRankings(bs)) {\n\t\t\ttrap_EA_Command(bs->client, \"vtaunt\");\n\t\t}\n\t\treturn qtrue;\n\t}\n\t// don't chat in tournament mode\n\tif (gametype == GT_TOURNAMENT) return qfalse;\n\trnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_STARTENDLEVEL, 0, 1);\n\tif (!bot_fastchat.integer) {\n\t\tif (random() > rnd) return qfalse;\n\t}\n\tif (BotNumActivePlayers() <= 1) return qfalse;\n\t//\n\tif (BotIsFirstInRankings(bs)) {\n\t\tBotAI_BotInitialChat(bs, \"level_end_victory\",\n\t\t\t\tEasyClientName(bs->client, name, 32),\t// 0\n\t\t\t\tBotRandomOpponentName(bs),\t\t\t\t// 1\n\t\t\t\t\"[invalid var]\",\t\t\t\t\t\t// 2\n\t\t\t\tBotLastClientInRankings(),\t\t\t\t// 3\n\t\t\t\tBotMapTitle(),\t\t\t\t\t\t\t// 4\n\t\t\t\tNULL);\n\t}\n\telse if (BotIsLastInRankings(bs)) {\n\t\tBotAI_BotInitialChat(bs, \"level_end_lose\",\n\t\t\t\tEasyClientName(bs->client, name, 32),\t// 0\n\t\t\t\tBotRandomOpponentName(bs),\t\t\t\t// 1\n\t\t\t\tBotFirstClientInRankings(),\t\t\t\t// 2\n\t\t\t\t\"[invalid var]\",\t\t\t\t\t\t// 3\n\t\t\t\tBotMapTitle(),\t\t\t\t\t\t\t// 4\n\t\t\t\tNULL);\n\t}\n\telse {\n\t\tBotAI_BotInitialChat(bs, \"level_end\",\n\t\t\t\tEasyClientName(bs->client, name, 32),\t// 0\n\t\t\t\tBotRandomOpponentName(bs),\t\t\t\t// 1\n\t\t\t\tBotFirstClientInRankings(),\t\t\t\t// 2\n\t\t\t\tBotLastClientInRankings(),\t\t\t\t// 3\n\t\t\t\tBotMapTitle(),\t\t\t\t\t\t\t// 4\n\t\t\t\tNULL);\n\t}\n\tbs->lastchat_time = FloatTime();\n\tbs->chatto = CHAT_ALL;\n\treturn qtrue;\n}\n\n/*\n==================\nBotChat_Death\n==================\n*/\nint BotChat_Death(bot_state_t *bs) {\n\tchar name[32];\n\tfloat rnd;\n\n\tif (bot_nochat.integer) return qfalse;\n\tif (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;\n\trnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_DEATH, 0, 1);\n\t// don't chat in tournament mode\n\tif (gametype == GT_TOURNAMENT) return qfalse;\n\t//if fast chatting is off\n\tif (!bot_fastchat.integer) {\n\t\tif (random() > rnd) return qfalse;\n\t}\n\tif (BotNumActivePlayers() <= 1) return qfalse;\n\t//\n\tif (bs->lastkilledby >= 0 && bs->lastkilledby < MAX_CLIENTS)\n\t\tEasyClientName(bs->lastkilledby, name, 32);\n\telse\n\t\tstrcpy(name, \"[world]\");\n\t//\n\tif (TeamPlayIsOn() && BotSameTeam(bs, bs->lastkilledby)) {\n\t\tif (bs->lastkilledby == bs->client) return qfalse;\n\t\tBotAI_BotInitialChat(bs, \"death_teammate\", name, NULL);\n\t\tbs->chatto = CHAT_TEAM;\n\t}\n\telse\n\t{\n\t\t//teamplay\n\t\tif (TeamPlayIsOn()) {\n\t\t\ttrap_EA_Command(bs->client, \"vtaunt\");\n\t\t\treturn qtrue;\n\t\t}\n\t\t//\n\t\tif (bs->botdeathtype == MOD_WATER)\n\t\t\tBotAI_BotInitialChat(bs, \"death_drown\", BotRandomOpponentName(bs), NULL);\n\t\telse if (bs->botdeathtype == MOD_SLIME)\n\t\t\tBotAI_BotInitialChat(bs, \"death_slime\", BotRandomOpponentName(bs), NULL);\n\t\telse if (bs->botdeathtype == MOD_LAVA)\n\t\t\tBotAI_BotInitialChat(bs, \"death_lava\", BotRandomOpponentName(bs), NULL);\n\t\telse if (bs->botdeathtype == MOD_FALLING)\n\t\t\tBotAI_BotInitialChat(bs, \"death_cratered\", BotRandomOpponentName(bs), NULL);\n\t\telse if (bs->botsuicide || //all other suicides by own weapon\n\t\t\t\tbs->botdeathtype == MOD_CRUSH ||\n\t\t\t\tbs->botdeathtype == MOD_SUICIDE ||\n\t\t\t\tbs->botdeathtype == MOD_TARGET_LASER ||\n\t\t\t\tbs->botdeathtype == MOD_TRIGGER_HURT ||\n\t\t\t\tbs->botdeathtype == MOD_UNKNOWN)\n\t\t\tBotAI_BotInitialChat(bs, \"death_suicide\", BotRandomOpponentName(bs), NULL);\n\t\telse if (bs->botdeathtype == MOD_TELEFRAG)\n\t\t\tBotAI_BotInitialChat(bs, \"death_telefrag\", name, NULL);\n#ifdef MISSIONPACK\n\t\telse if (bs->botdeathtype == MOD_KAMIKAZE && trap_BotNumInitialChats(bs->cs, \"death_kamikaze\"))\n\t\t\tBotAI_BotInitialChat(bs, \"death_kamikaze\", name, NULL);\n#endif\n\t\telse {\n\t\t\tif ((bs->botdeathtype == MOD_GAUNTLET ||\n\t\t\t\tbs->botdeathtype == MOD_RAILGUN ||\n\t\t\t\tbs->botdeathtype == MOD_BFG ||\n\t\t\t\tbs->botdeathtype == MOD_BFG_SPLASH) && random() < 0.5) {\n\n\t\t\t\tif (bs->botdeathtype == MOD_GAUNTLET)\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"death_gauntlet\",\n\t\t\t\t\t\t\tname,\t\t\t\t\t\t\t\t\t\t\t\t// 0\n\t\t\t\t\t\t\tBotWeaponNameForMeansOfDeath(bs->botdeathtype),\t\t// 1\n\t\t\t\t\t\t\tNULL);\n\t\t\t\telse if (bs->botdeathtype == MOD_RAILGUN)\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"death_rail\",\n\t\t\t\t\t\t\tname,\t\t\t\t\t\t\t\t\t\t\t\t// 0\n\t\t\t\t\t\t\tBotWeaponNameForMeansOfDeath(bs->botdeathtype),\t\t// 1\n\t\t\t\t\t\t\tNULL);\n\t\t\t\telse\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"death_bfg\",\n\t\t\t\t\t\t\tname,\t\t\t\t\t\t\t\t\t\t\t\t// 0\n\t\t\t\t\t\t\tBotWeaponNameForMeansOfDeath(bs->botdeathtype),\t\t// 1\n\t\t\t\t\t\t\tNULL);\n\t\t\t}\n\t\t\t//choose between insult and praise\n\t\t\telse if (random() < trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_INSULT, 0, 1)) {\n\t\t\t\tBotAI_BotInitialChat(bs, \"death_insult\",\n\t\t\t\t\t\t\tname,\t\t\t\t\t\t\t\t\t\t\t\t// 0\n\t\t\t\t\t\t\tBotWeaponNameForMeansOfDeath(bs->botdeathtype),\t\t// 1\n\t\t\t\t\t\t\tNULL);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tBotAI_BotInitialChat(bs, \"death_praise\",\n\t\t\t\t\t\t\tname,\t\t\t\t\t\t\t\t\t\t\t\t// 0\n\t\t\t\t\t\t\tBotWeaponNameForMeansOfDeath(bs->botdeathtype),\t\t// 1\n\t\t\t\t\t\t\tNULL);\n\t\t\t}\n\t\t}\n\t\tbs->chatto = CHAT_ALL;\n\t}\n\tbs->lastchat_time = FloatTime();\n\treturn qtrue;\n}\n\n/*\n==================\nBotChat_Kill\n==================\n*/\nint BotChat_Kill(bot_state_t *bs) {\n\tchar name[32];\n\tfloat rnd;\n\n\tif (bot_nochat.integer) return qfalse;\n\tif (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;\n\trnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_KILL, 0, 1);\n\t// don't chat in tournament mode\n\tif (gametype == GT_TOURNAMENT) return qfalse;\n\t//if fast chat is off\n\tif (!bot_fastchat.integer) {\n\t\tif (random() > rnd) return qfalse;\n\t}\n\tif (bs->lastkilledplayer == bs->client) return qfalse;\n\tif (BotNumActivePlayers() <= 1) return qfalse;\n\tif (!BotValidChatPosition(bs)) return qfalse;\n\t//\n\tif (BotVisibleEnemies(bs)) return qfalse;\n\t//\n\tEasyClientName(bs->lastkilledplayer, name, 32);\n\t//\n\tbs->chatto = CHAT_ALL;\n\tif (TeamPlayIsOn() && BotSameTeam(bs, bs->lastkilledplayer)) {\n\t\tBotAI_BotInitialChat(bs, \"kill_teammate\", name, NULL);\n\t\tbs->chatto = CHAT_TEAM;\n\t}\n\telse\n\t{\n\t\t//don't chat in teamplay\n\t\tif (TeamPlayIsOn()) {\n\t\t\ttrap_EA_Command(bs->client, \"vtaunt\");\n\t\t\treturn qfalse;\t\t\t// don't wait\n\t\t}\n\t\t//\n\t\tif (bs->enemydeathtype == MOD_GAUNTLET) {\n\t\t\tBotAI_BotInitialChat(bs, \"kill_gauntlet\", name, NULL);\n\t\t}\n\t\telse if (bs->enemydeathtype == MOD_RAILGUN) {\n\t\t\tBotAI_BotInitialChat(bs, \"kill_rail\", name, NULL);\n\t\t}\n\t\telse if (bs->enemydeathtype == MOD_TELEFRAG) {\n\t\t\tBotAI_BotInitialChat(bs, \"kill_telefrag\", name, NULL);\n\t\t}\n#ifdef MISSIONPACK\n\t\telse if (bs->botdeathtype == MOD_KAMIKAZE && trap_BotNumInitialChats(bs->cs, \"kill_kamikaze\"))\n\t\t\tBotAI_BotInitialChat(bs, \"kill_kamikaze\", name, NULL);\n#endif\n\t\t//choose between insult and praise\n\t\telse if (random() < trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_INSULT, 0, 1)) {\n\t\t\tBotAI_BotInitialChat(bs, \"kill_insult\", name, NULL);\n\t\t}\n\t\telse {\n\t\t\tBotAI_BotInitialChat(bs, \"kill_praise\", name, NULL);\n\t\t}\n\t}\n\tbs->lastchat_time = FloatTime();\n\treturn qtrue;\n}\n\n/*\n==================\nBotChat_EnemySuicide\n==================\n*/\nint BotChat_EnemySuicide(bot_state_t *bs) {\n\tchar name[32];\n\tfloat rnd;\n\n\tif (bot_nochat.integer) return qfalse;\n\tif (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;\n\tif (BotNumActivePlayers() <= 1) return qfalse;\n\t//\n\trnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_KILL, 0, 1);\n\t//don't chat in teamplay\n\tif (TeamPlayIsOn()) return qfalse;\n\t// don't chat in tournament mode\n\tif (gametype == GT_TOURNAMENT) return qfalse;\n\t//if fast chat is off\n\tif (!bot_fastchat.integer) {\n\t\tif (random() > rnd) return qfalse;\n\t}\n\tif (!BotValidChatPosition(bs)) return qfalse;\n\t//\n\tif (BotVisibleEnemies(bs)) return qfalse;\n\t//\n\tif (bs->enemy >= 0) EasyClientName(bs->enemy, name, 32);\n\telse strcpy(name, \"\");\n\tBotAI_BotInitialChat(bs, \"enemy_suicide\", name, NULL);\n\tbs->lastchat_time = FloatTime();\n\tbs->chatto = CHAT_ALL;\n\treturn qtrue;\n}\n\n/*\n==================\nBotChat_HitTalking\n==================\n*/\nint BotChat_HitTalking(bot_state_t *bs) {\n\tchar name[32], *weap;\n\tint lasthurt_client;\n\tfloat rnd;\n\n\tif (bot_nochat.integer) return qfalse;\n\tif (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;\n\tif (BotNumActivePlayers() <= 1) return qfalse;\n\tlasthurt_client = g_entities[bs->client].client->lasthurt_client;\n\tif (!lasthurt_client) return qfalse;\n\tif (lasthurt_client == bs->client) return qfalse;\n\t//\n\tif (lasthurt_client < 0 || lasthurt_client >= MAX_CLIENTS) return qfalse;\n\t//\n\trnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_HITTALKING, 0, 1);\n\t//don't chat in teamplay\n\tif (TeamPlayIsOn()) return qfalse;\n\t// don't chat in tournament mode\n\tif (gametype == GT_TOURNAMENT) return qfalse;\n\t//if fast chat is off\n\tif (!bot_fastchat.integer) {\n\t\tif (random() > rnd * 0.5) return qfalse;\n\t}\n\tif (!BotValidChatPosition(bs)) return qfalse;\n\t//\n\tClientName(g_entities[bs->client].client->lasthurt_client, name, sizeof(name));\n\tweap = BotWeaponNameForMeansOfDeath(g_entities[bs->client].client->lasthurt_client);\n\t//\n\tBotAI_BotInitialChat(bs, \"hit_talking\", name, weap, NULL);\n\tbs->lastchat_time = FloatTime();\n\tbs->chatto = CHAT_ALL;\n\treturn qtrue;\n}\n\n/*\n==================\nBotChat_HitNoDeath\n==================\n*/\nint BotChat_HitNoDeath(bot_state_t *bs) {\n\tchar name[32], *weap;\n\tfloat rnd;\n\tint lasthurt_client;\n\taas_entityinfo_t entinfo;\n\n\tlasthurt_client = g_entities[bs->client].client->lasthurt_client;\n\tif (!lasthurt_client) return qfalse;\n\tif (lasthurt_client == bs->client) return qfalse;\n\t//\n\tif (lasthurt_client < 0 || lasthurt_client >= MAX_CLIENTS) return qfalse;\n\t//\n\tif (bot_nochat.integer) return qfalse;\n\tif (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;\n\tif (BotNumActivePlayers() <= 1) return qfalse;\n\trnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_HITNODEATH, 0, 1);\n\t//don't chat in teamplay\n\tif (TeamPlayIsOn()) return qfalse;\n\t// don't chat in tournament mode\n\tif (gametype == GT_TOURNAMENT) return qfalse;\n\t//if fast chat is off\n\tif (!bot_fastchat.integer) {\n\t\tif (random() > rnd * 0.5) return qfalse;\n\t}\n\tif (!BotValidChatPosition(bs)) return qfalse;\n\t//\n\tif (BotVisibleEnemies(bs)) return qfalse;\n\t//\n\tBotEntityInfo(bs->enemy, &entinfo);\n\tif (EntityIsShooting(&entinfo)) return qfalse;\n\t//\n\tClientName(lasthurt_client, name, sizeof(name));\n\tweap = BotWeaponNameForMeansOfDeath(g_entities[bs->client].client->lasthurt_mod);\n\t//\n\tBotAI_BotInitialChat(bs, \"hit_nodeath\", name, weap, NULL);\n\tbs->lastchat_time = FloatTime();\n\tbs->chatto = CHAT_ALL;\n\treturn qtrue;\n}\n\n/*\n==================\nBotChat_HitNoKill\n==================\n*/\nint BotChat_HitNoKill(bot_state_t *bs) {\n\tchar name[32], *weap;\n\tfloat rnd;\n\taas_entityinfo_t entinfo;\n\n\tif (bot_nochat.integer) return qfalse;\n\tif (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;\n\tif (BotNumActivePlayers() <= 1) return qfalse;\n\trnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_HITNOKILL, 0, 1);\n\t//don't chat in teamplay\n\tif (TeamPlayIsOn()) return qfalse;\n\t// don't chat in tournament mode\n\tif (gametype == GT_TOURNAMENT) return qfalse;\n\t//if fast chat is off\n\tif (!bot_fastchat.integer) {\n\t\tif (random() > rnd * 0.5) return qfalse;\n\t}\n\tif (!BotValidChatPosition(bs)) return qfalse;\n\t//\n\tif (BotVisibleEnemies(bs)) return qfalse;\n\t//\n\tBotEntityInfo(bs->enemy, &entinfo);\n\tif (EntityIsShooting(&entinfo)) return qfalse;\n\t//\n\tClientName(bs->enemy, name, sizeof(name));\n\tweap = BotWeaponNameForMeansOfDeath(g_entities[bs->enemy].client->lasthurt_mod);\n\t//\n\tBotAI_BotInitialChat(bs, \"hit_nokill\", name, weap, NULL);\n\tbs->lastchat_time = FloatTime();\n\tbs->chatto = CHAT_ALL;\n\treturn qtrue;\n}\n\n/*\n==================\nBotChat_Random\n==================\n*/\nint BotChat_Random(bot_state_t *bs) {\n\tfloat rnd;\n\tchar name[32];\n\n\tif (bot_nochat.integer) return qfalse;\n\tif (BotIsObserver(bs)) return qfalse;\n\tif (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;\n\t// don't chat in tournament mode\n\tif (gametype == GT_TOURNAMENT) return qfalse;\n\t//don't chat when doing something important :)\n\tif (bs->ltgtype == LTG_TEAMHELP ||\n\t\tbs->ltgtype == LTG_TEAMACCOMPANY ||\n\t\tbs->ltgtype == LTG_RUSHBASE) return qfalse;\n\t//\n\trnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_RANDOM, 0, 1);\n\tif (random() > bs->thinktime * 0.1) return qfalse;\n\tif (!bot_fastchat.integer) {\n\t\tif (random() > rnd) return qfalse;\n\t\tif (random() > 0.25) return qfalse;\n\t}\n\tif (BotNumActivePlayers() <= 1) return qfalse;\n\t//\n\tif (!BotValidChatPosition(bs)) return qfalse;\n\t//\n\tif (BotVisibleEnemies(bs)) return qfalse;\n\t//\n\tif (bs->lastkilledplayer == bs->client) {\n\t\tstrcpy(name, BotRandomOpponentName(bs));\n\t}\n\telse {\n\t\tEasyClientName(bs->lastkilledplayer, name, sizeof(name));\n\t}\n\tif (TeamPlayIsOn()) {\n\t\ttrap_EA_Command(bs->client, \"vtaunt\");\n\t\treturn qfalse;\t\t\t// don't wait\n\t}\n\t//\n\tif (random() < trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_MISC, 0, 1)) {\n\t\tBotAI_BotInitialChat(bs, \"random_misc\",\n\t\t\t\t\tBotRandomOpponentName(bs),\t// 0\n\t\t\t\t\tname,\t\t\t\t\t\t// 1\n\t\t\t\t\t\"[invalid var]\",\t\t\t// 2\n\t\t\t\t\t\"[invalid var]\",\t\t\t// 3\n\t\t\t\t\tBotMapTitle(),\t\t\t\t// 4\n\t\t\t\t\tBotRandomWeaponName(),\t\t// 5\n\t\t\t\t\tNULL);\n\t}\n\telse {\n\t\tBotAI_BotInitialChat(bs, \"random_insult\",\n\t\t\t\t\tBotRandomOpponentName(bs),\t// 0\n\t\t\t\t\tname,\t\t\t\t\t\t// 1\n\t\t\t\t\t\"[invalid var]\",\t\t\t// 2\n\t\t\t\t\t\"[invalid var]\",\t\t\t// 3\n\t\t\t\t\tBotMapTitle(),\t\t\t\t// 4\n\t\t\t\t\tBotRandomWeaponName(),\t\t// 5\n\t\t\t\t\tNULL);\n\t}\n\tbs->lastchat_time = FloatTime();\n\tbs->chatto = CHAT_ALL;\n\treturn qtrue;\n}\n\n/*\n==================\nBotChatTime\n==================\n*/\nfloat BotChatTime(bot_state_t *bs) {\n\tint cpm;\n\n\tcpm = trap_Characteristic_BInteger(bs->character, CHARACTERISTIC_CHAT_CPM, 1, 4000);\n\n\treturn 2.0;\t//(float) trap_BotChatLength(bs->cs) * 30 / cpm;\n}\n\n/*\n==================\nBotChatTest\n==================\n*/\nvoid BotChatTest(bot_state_t *bs) {\n\n\tchar name[32];\n\tchar *weap;\n\tint num, i;\n\n\tnum = trap_BotNumInitialChats(bs->cs, \"game_enter\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"game_enter\",\n\t\t\t\t\tEasyClientName(bs->client, name, 32),\t// 0\n\t\t\t\t\tBotRandomOpponentName(bs),\t\t\t\t// 1\n\t\t\t\t\t\"[invalid var]\",\t\t\t\t\t\t// 2\n\t\t\t\t\t\"[invalid var]\",\t\t\t\t\t\t// 3\n\t\t\t\t\tBotMapTitle(),\t\t\t\t\t\t\t// 4\n\t\t\t\t\tNULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"game_exit\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"game_exit\",\n\t\t\t\t\tEasyClientName(bs->client, name, 32),\t// 0\n\t\t\t\t\tBotRandomOpponentName(bs),\t\t\t\t// 1\n\t\t\t\t\t\"[invalid var]\",\t\t\t\t\t\t// 2\n\t\t\t\t\t\"[invalid var]\",\t\t\t\t\t\t// 3\n\t\t\t\t\tBotMapTitle(),\t\t\t\t\t\t\t// 4\n\t\t\t\t\tNULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"level_start\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"level_start\",\n\t\t\t\t\tEasyClientName(bs->client, name, 32),\t// 0\n\t\t\t\t\tNULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"level_end_victory\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"level_end_victory\",\n\t\t\t\tEasyClientName(bs->client, name, 32),\t// 0\n\t\t\t\tBotRandomOpponentName(bs),\t\t\t\t// 1\n\t\t\t\tBotFirstClientInRankings(),\t\t\t\t// 2\n\t\t\t\tBotLastClientInRankings(),\t\t\t\t// 3\n\t\t\t\tBotMapTitle(),\t\t\t\t\t\t\t// 4\n\t\t\t\tNULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"level_end_lose\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"level_end_lose\",\n\t\t\t\tEasyClientName(bs->client, name, 32),\t// 0\n\t\t\t\tBotRandomOpponentName(bs),\t\t\t\t// 1\n\t\t\t\tBotFirstClientInRankings(),\t\t\t\t// 2\n\t\t\t\tBotLastClientInRankings(),\t\t\t\t// 3\n\t\t\t\tBotMapTitle(),\t\t\t\t\t\t\t// 4\n\t\t\t\tNULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"level_end\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"level_end\",\n\t\t\t\tEasyClientName(bs->client, name, 32),\t// 0\n\t\t\t\tBotRandomOpponentName(bs),\t\t\t\t// 1\n\t\t\t\tBotFirstClientInRankings(),\t\t\t\t// 2\n\t\t\t\tBotLastClientInRankings(),\t\t\t\t// 3\n\t\t\t\tBotMapTitle(),\t\t\t\t\t\t\t// 4\n\t\t\t\tNULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tEasyClientName(bs->lastkilledby, name, sizeof(name));\n\tnum = trap_BotNumInitialChats(bs->cs, \"death_drown\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\t//\n\t\tBotAI_BotInitialChat(bs, \"death_drown\", name, NULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"death_slime\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"death_slime\", name, NULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"death_lava\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"death_lava\", name, NULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"death_cratered\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"death_cratered\", name, NULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"death_suicide\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"death_suicide\", name, NULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"death_telefrag\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"death_telefrag\", name, NULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"death_gauntlet\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"death_gauntlet\",\n\t\t\t\tname,\t\t\t\t\t\t\t\t\t\t\t\t// 0\n\t\t\t\tBotWeaponNameForMeansOfDeath(bs->botdeathtype),\t\t// 1\n\t\t\t\tNULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"death_rail\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"death_rail\",\n\t\t\t\tname,\t\t\t\t\t\t\t\t\t\t\t\t// 0\n\t\t\t\tBotWeaponNameForMeansOfDeath(bs->botdeathtype),\t\t// 1\n\t\t\t\tNULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"death_bfg\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"death_bfg\",\n\t\t\t\tname,\t\t\t\t\t\t\t\t\t\t\t\t// 0\n\t\t\t\tBotWeaponNameForMeansOfDeath(bs->botdeathtype),\t\t// 1\n\t\t\t\tNULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"death_insult\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"death_insult\",\n\t\t\t\t\tname,\t\t\t\t\t\t\t\t\t\t\t\t// 0\n\t\t\t\t\tBotWeaponNameForMeansOfDeath(bs->botdeathtype),\t\t// 1\n\t\t\t\t\tNULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"death_praise\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"death_praise\",\n\t\t\t\t\tname,\t\t\t\t\t\t\t\t\t\t\t\t// 0\n\t\t\t\t\tBotWeaponNameForMeansOfDeath(bs->botdeathtype),\t\t// 1\n\t\t\t\t\tNULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\t//\n\tEasyClientName(bs->lastkilledplayer, name, 32);\n\t//\n\tnum = trap_BotNumInitialChats(bs->cs, \"kill_gauntlet\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\t//\n\t\tBotAI_BotInitialChat(bs, \"kill_gauntlet\", name, NULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"kill_rail\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"kill_rail\", name, NULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"kill_telefrag\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"kill_telefrag\", name, NULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"kill_insult\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"kill_insult\", name, NULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"kill_praise\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"kill_praise\", name, NULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"enemy_suicide\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"enemy_suicide\", name, NULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tClientName(g_entities[bs->client].client->lasthurt_client, name, sizeof(name));\n\tweap = BotWeaponNameForMeansOfDeath(g_entities[bs->client].client->lasthurt_client);\n\tnum = trap_BotNumInitialChats(bs->cs, \"hit_talking\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"hit_talking\", name, weap, NULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"hit_nodeath\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"hit_nodeath\", name, weap, NULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"hit_nokill\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"hit_nokill\", name, weap, NULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\t//\n\tif (bs->lastkilledplayer == bs->client) {\n\t\tstrcpy(name, BotRandomOpponentName(bs));\n\t}\n\telse {\n\t\tEasyClientName(bs->lastkilledplayer, name, sizeof(name));\n\t}\n\t//\n\tnum = trap_BotNumInitialChats(bs->cs, \"random_misc\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\t//\n\t\tBotAI_BotInitialChat(bs, \"random_misc\",\n\t\t\t\t\tBotRandomOpponentName(bs),\t// 0\n\t\t\t\t\tname,\t\t\t\t\t\t// 1\n\t\t\t\t\t\"[invalid var]\",\t\t\t// 2\n\t\t\t\t\t\"[invalid var]\",\t\t\t// 3\n\t\t\t\t\tBotMapTitle(),\t\t\t\t// 4\n\t\t\t\t\tBotRandomWeaponName(),\t\t// 5\n\t\t\t\t\tNULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n\tnum = trap_BotNumInitialChats(bs->cs, \"random_insult\");\n\tfor (i = 0; i < num; i++)\n\t{\n\t\tBotAI_BotInitialChat(bs, \"random_insult\",\n\t\t\t\t\tBotRandomOpponentName(bs),\t// 0\n\t\t\t\t\tname,\t\t\t\t\t\t// 1\n\t\t\t\t\t\"[invalid var]\",\t\t\t// 2\n\t\t\t\t\t\"[invalid var]\",\t\t\t// 3\n\t\t\t\t\tBotMapTitle(),\t\t\t\t// 4\n\t\t\t\t\tBotRandomWeaponName(),\t\t// 5\n\t\t\t\t\tNULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_ALL);\n\t}\n}\n"
  },
  {
    "path": "code/game/ai_chat.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n/*****************************************************************************\n * name:\t\tai_chat.h\n *\n * desc:\t\tQuake3 bot AI\n *\n * $Archive: /source/code/botai/ai_chat.c $\n *\n *****************************************************************************/\n\n//\nint BotChat_EnterGame(bot_state_t *bs);\n//\nint BotChat_ExitGame(bot_state_t *bs);\n//\nint BotChat_StartLevel(bot_state_t *bs);\n//\nint BotChat_EndLevel(bot_state_t *bs);\n//\nint BotChat_HitTalking(bot_state_t *bs);\n//\nint BotChat_HitNoDeath(bot_state_t *bs);\n//\nint BotChat_HitNoKill(bot_state_t *bs);\n//\nint BotChat_Death(bot_state_t *bs);\n//\nint BotChat_Kill(bot_state_t *bs);\n//\nint BotChat_EnemySuicide(bot_state_t *bs);\n//\nint BotChat_Random(bot_state_t *bs);\n// time the selected chat takes to type in\nfloat BotChatTime(bot_state_t *bs);\n// returns true if the bot can chat at the current position\nint BotValidChatPosition(bot_state_t *bs);\n// test the initial bot chats\nvoid BotChatTest(bot_state_t *bs);\n\n"
  },
  {
    "path": "code/game/ai_cmd.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n/*****************************************************************************\n * name:\t\tai_cmd.c\n *\n * desc:\t\tQuake3 bot AI\n *\n * $Archive: /MissionPack/code/game/ai_cmd.c $\n *\n *****************************************************************************/\n\n#include \"g_local.h\"\n#include \"botlib.h\"\n#include \"be_aas.h\"\n#include \"be_ea.h\"\n#include \"be_ai_char.h\"\n#include \"be_ai_chat.h\"\n#include \"be_ai_gen.h\"\n#include \"be_ai_goal.h\"\n#include \"be_ai_move.h\"\n#include \"be_ai_weap.h\"\n//\n#include \"ai_main.h\"\n#include \"ai_dmq3.h\"\n#include \"ai_chat.h\"\n#include \"ai_cmd.h\"\n#include \"ai_dmnet.h\"\n#include \"ai_team.h\"\n//\n#include \"chars.h\"\t\t\t\t//characteristics\n#include \"inv.h\"\t\t\t\t//indexes into the inventory\n#include \"syn.h\"\t\t\t\t//synonyms\n#include \"match.h\"\t\t\t\t//string matching types and vars\n\n// for the voice chats\n#include \"../../ui/menudef.h\"\n\nint notleader[MAX_CLIENTS];\n\n#ifdef DEBUG\n/*\n==================\nBotPrintTeamGoal\n==================\n*/\nvoid BotPrintTeamGoal(bot_state_t *bs) {\n\tchar netname[MAX_NETNAME];\n\tfloat t;\n\n\tClientName(bs->client, netname, sizeof(netname));\n\tt = bs->teamgoal_time - FloatTime();\n\tswitch(bs->ltgtype) {\n\t\tcase LTG_TEAMHELP:\n\t\t{\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%s: I'm gonna help a team mate for %1.0f secs\\n\", netname, t);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_TEAMACCOMPANY:\n\t\t{\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%s: I'm gonna accompany a team mate for %1.0f secs\\n\", netname, t);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_GETFLAG:\n\t\t{\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%s: I'm gonna get the flag for %1.0f secs\\n\", netname, t);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_RUSHBASE:\n\t\t{\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%s: I'm gonna rush to the base for %1.0f secs\\n\", netname, t);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_RETURNFLAG:\n\t\t{\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%s: I'm gonna try to return the flag for %1.0f secs\\n\", netname, t);\n\t\t\tbreak;\n\t\t}\n#ifdef MISSIONPACK\n\t\tcase LTG_ATTACKENEMYBASE:\n\t\t{\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%s: I'm gonna attack the enemy base for %1.0f secs\\n\", netname, t);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_HARVEST:\n\t\t{\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%s: I'm gonna harvest for %1.0f secs\\n\", netname, t);\n\t\t\tbreak;\n\t\t}\n#endif\n\t\tcase LTG_DEFENDKEYAREA:\n\t\t{\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%s: I'm gonna defend a key area for %1.0f secs\\n\", netname, t);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_GETITEM:\n\t\t{\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%s: I'm gonna get an item for %1.0f secs\\n\", netname, t);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_KILL:\n\t\t{\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%s: I'm gonna kill someone for %1.0f secs\\n\", netname, t);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_CAMP:\n\t\tcase LTG_CAMPORDER:\n\t\t{\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%s: I'm gonna camp for %1.0f secs\\n\", netname, t);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_PATROL:\n\t\t{\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%s: I'm gonna patrol for %1.0f secs\\n\", netname, t);\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t{\n\t\t\tif (bs->ctfroam_time > FloatTime()) {\n\t\t\t\tt = bs->ctfroam_time - FloatTime();\n\t\t\t\tBotAI_Print(PRT_MESSAGE, \"%s: I'm gonna roam for %1.0f secs\\n\", netname, t);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tBotAI_Print(PRT_MESSAGE, \"%s: I've got a regular goal\\n\", netname);\n\t\t\t}\n\t\t}\n\t}\n}\n#endif //DEBUG\n\n/*\n==================\nBotGetItemTeamGoal\n\nFIXME: add stuff like \"upper rocket launcher\"\n\"the rl near the railgun\", \"lower grenade launcher\" etc.\n==================\n*/\nint BotGetItemTeamGoal(char *goalname, bot_goal_t *goal) {\n\tint i;\n\n\tif (!strlen(goalname)) return qfalse;\n\ti = -1;\n\tdo {\n\t\ti = trap_BotGetLevelItemGoal(i, goalname, goal);\n\t\tif (i > 0) {\n\t\t\t//do NOT defend dropped items\n\t\t\tif (goal->flags & GFL_DROPPED)\n\t\t\t\tcontinue;\n\t\t\treturn qtrue;\n\t\t}\n\t} while(i > 0);\n\treturn qfalse;\n}\n\n/*\n==================\nBotGetMessageTeamGoal\n==================\n*/\nint BotGetMessageTeamGoal(bot_state_t *bs, char *goalname, bot_goal_t *goal) {\n\tbot_waypoint_t *cp;\n\n\tif (BotGetItemTeamGoal(goalname, goal)) return qtrue;\n\n\tcp = BotFindWayPoint(bs->checkpoints, goalname);\n\tif (cp) {\n\t\tmemcpy(goal, &cp->goal, sizeof(bot_goal_t));\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nBotGetTime\n==================\n*/\nfloat BotGetTime(bot_match_t *match) {\n\tbot_match_t timematch;\n\tchar timestring[MAX_MESSAGE_SIZE];\n\tfloat t;\n\n\t//if the matched string has a time\n\tif (match->subtype & ST_TIME) {\n\t\t//get the time string\n\t\ttrap_BotMatchVariable(match, TIME, timestring, MAX_MESSAGE_SIZE);\n\t\t//match it to find out if the time is in seconds or minutes\n\t\tif (trap_BotFindMatch(timestring, &timematch, MTCONTEXT_TIME)) {\n\t\t\tif (timematch.type == MSG_FOREVER) {\n\t\t\t\tt = 99999999.0f;\n\t\t\t}\n\t\t\telse if (timematch.type == MSG_FORAWHILE) {\n\t\t\t\tt = 10 * 60; // 10 minutes\n\t\t\t}\n\t\t\telse if (timematch.type == MSG_FORALONGTIME) {\n\t\t\t\tt = 30 * 60; // 30 minutes\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttrap_BotMatchVariable(&timematch, TIME, timestring, MAX_MESSAGE_SIZE);\n\t\t\t\tif (timematch.type == MSG_MINUTES) t = atof(timestring) * 60;\n\t\t\t\telse if (timematch.type == MSG_SECONDS) t = atof(timestring);\n\t\t\t\telse t = 0;\n\t\t\t}\n\t\t\t//if there's a valid time\n\t\t\tif (t > 0) return FloatTime() + t;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/*\n==================\nFindClientByName\n==================\n*/\nint FindClientByName(char *name) {\n\tint i;\n\tchar buf[MAX_INFO_STRING];\n\tstatic int maxclients;\n\n\tif (!maxclients)\n\t\tmaxclients = trap_Cvar_VariableIntegerValue(\"sv_maxclients\");\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\tClientName(i, buf, sizeof(buf));\n\t\tif (!Q_stricmp(buf, name)) return i;\n\t}\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\tClientName(i, buf, sizeof(buf));\n\t\tif (stristr(buf, name)) return i;\n\t}\n\treturn -1;\n}\n\n/*\n==================\nFindEnemyByName\n==================\n*/\nint FindEnemyByName(bot_state_t *bs, char *name) {\n\tint i;\n\tchar buf[MAX_INFO_STRING];\n\tstatic int maxclients;\n\n\tif (!maxclients)\n\t\tmaxclients = trap_Cvar_VariableIntegerValue(\"sv_maxclients\");\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\tif (BotSameTeam(bs, i)) continue;\n\t\tClientName(i, buf, sizeof(buf));\n\t\tif (!Q_stricmp(buf, name)) return i;\n\t}\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\tif (BotSameTeam(bs, i)) continue;\n\t\tClientName(i, buf, sizeof(buf));\n\t\tif (stristr(buf, name)) return i;\n\t}\n\treturn -1;\n}\n\n/*\n==================\nNumPlayersOnSameTeam\n==================\n*/\nint NumPlayersOnSameTeam(bot_state_t *bs) {\n\tint i, num;\n\tchar buf[MAX_INFO_STRING];\n\tstatic int maxclients;\n\n\tif (!maxclients)\n\t\tmaxclients = trap_Cvar_VariableIntegerValue(\"sv_maxclients\");\n\n\tnum = 0;\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\ttrap_GetConfigstring(CS_PLAYERS+i, buf, MAX_INFO_STRING);\n\t\tif (strlen(buf)) {\n\t\t\tif (BotSameTeam(bs, i+1)) num++;\n\t\t}\n\t}\n\treturn num;\n}\n\n/*\n==================\nTeamPlayIsOn\n==================\n*/\nint BotGetPatrolWaypoints(bot_state_t *bs, bot_match_t *match) {\n\tchar keyarea[MAX_MESSAGE_SIZE];\n\tint patrolflags;\n\tbot_waypoint_t *wp, *newwp, *newpatrolpoints;\n\tbot_match_t keyareamatch;\n\tbot_goal_t goal;\n\n\tnewpatrolpoints = NULL;\n\tpatrolflags = 0;\n\t//\n\ttrap_BotMatchVariable(match, KEYAREA, keyarea, MAX_MESSAGE_SIZE);\n\t//\n\twhile(1) {\n\t\tif (!trap_BotFindMatch(keyarea, &keyareamatch, MTCONTEXT_PATROLKEYAREA)) {\n\t\t\ttrap_EA_SayTeam(bs->client, \"what do you say?\");\n\t\t\tBotFreeWaypoints(newpatrolpoints);\n\t\t\tbs->patrolpoints = NULL;\n\t\t\treturn qfalse;\n\t\t}\n\t\ttrap_BotMatchVariable(&keyareamatch, KEYAREA, keyarea, MAX_MESSAGE_SIZE);\n\t\tif (!BotGetMessageTeamGoal(bs, keyarea, &goal)) {\n\t\t\t//BotAI_BotInitialChat(bs, \"cannotfind\", keyarea, NULL);\n\t\t\t//trap_BotEnterChat(bs->cs, 0, CHAT_TEAM);\n\t\t\tBotFreeWaypoints(newpatrolpoints);\n\t\t\tbs->patrolpoints = NULL;\n\t\t\treturn qfalse;\n\t\t}\n\t\t//create a new waypoint\n\t\tnewwp = BotCreateWayPoint(keyarea, goal.origin, goal.areanum);\n\t\tif (!newwp)\n\t\t\tbreak;\n\t\t//add the waypoint to the patrol points\n\t\tnewwp->next = NULL;\n\t\tfor (wp = newpatrolpoints; wp && wp->next; wp = wp->next);\n\t\tif (!wp) {\n\t\t\tnewpatrolpoints = newwp;\n\t\t\tnewwp->prev = NULL;\n\t\t}\n\t\telse {\n\t\t\twp->next = newwp;\n\t\t\tnewwp->prev = wp;\n\t\t}\n\t\t//\n\t\tif (keyareamatch.subtype & ST_BACK) {\n\t\t\tpatrolflags = PATROL_LOOP;\n\t\t\tbreak;\n\t\t}\n\t\telse if (keyareamatch.subtype & ST_REVERSE) {\n\t\t\tpatrolflags = PATROL_REVERSE;\n\t\t\tbreak;\n\t\t}\n\t\telse if (keyareamatch.subtype & ST_MORE) {\n\t\t\ttrap_BotMatchVariable(&keyareamatch, MORE, keyarea, MAX_MESSAGE_SIZE);\n\t\t}\n\t\telse {\n\t\t\tbreak;\n\t\t}\n\t}\n\t//\n\tif (!newpatrolpoints || !newpatrolpoints->next) {\n\t\ttrap_EA_SayTeam(bs->client, \"I need more key points to patrol\\n\");\n\t\tBotFreeWaypoints(newpatrolpoints);\n\t\tnewpatrolpoints = NULL;\n\t\treturn qfalse;\n\t}\n\t//\n\tBotFreeWaypoints(bs->patrolpoints);\n\tbs->patrolpoints = newpatrolpoints;\n\t//\n\tbs->curpatrolpoint = bs->patrolpoints;\n\tbs->patrolflags = patrolflags;\n\t//\n\treturn qtrue;\n}\n\n/*\n==================\nBotAddressedToBot\n==================\n*/\nint BotAddressedToBot(bot_state_t *bs, bot_match_t *match) {\n\tchar addressedto[MAX_MESSAGE_SIZE];\n\tchar netname[MAX_MESSAGE_SIZE];\n\tchar name[MAX_MESSAGE_SIZE];\n\tchar botname[128];\n\tint client;\n\tbot_match_t addresseematch;\n\n\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\tclient = ClientOnSameTeamFromName(bs, netname);\n\tif (client < 0) return qfalse;\n\t//if the message is addressed to someone\n\tif (match->subtype & ST_ADDRESSED) {\n\t\ttrap_BotMatchVariable(match, ADDRESSEE, addressedto, sizeof(addressedto));\n\t\t//the name of this bot\n\t\tClientName(bs->client, botname, 128);\n\t\t//\n\t\twhile(trap_BotFindMatch(addressedto, &addresseematch, MTCONTEXT_ADDRESSEE)) {\n\t\t\tif (addresseematch.type == MSG_EVERYONE) {\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t\telse if (addresseematch.type == MSG_MULTIPLENAMES) {\n\t\t\t\ttrap_BotMatchVariable(&addresseematch, TEAMMATE, name, sizeof(name));\n\t\t\t\tif (strlen(name)) {\n\t\t\t\t\tif (stristr(botname, name)) return qtrue;\n\t\t\t\t\tif (stristr(bs->subteam, name)) return qtrue;\n\t\t\t\t}\n\t\t\t\ttrap_BotMatchVariable(&addresseematch, MORE, addressedto, MAX_MESSAGE_SIZE);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttrap_BotMatchVariable(&addresseematch, TEAMMATE, name, MAX_MESSAGE_SIZE);\n\t\t\t\tif (strlen(name)) {\n\t\t\t\t\tif (stristr(botname, name)) return qtrue;\n\t\t\t\t\tif (stristr(bs->subteam, name)) return qtrue;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t//Com_sprintf(buf, sizeof(buf), \"not addressed to me but %s\", addressedto);\n\t\t//trap_EA_Say(bs->client, buf);\n\t\treturn qfalse;\n\t}\n\telse {\n\t\tbot_match_t tellmatch;\n\n\t\ttellmatch.type = 0;\n\t\t//if this message wasn't directed solely to this bot\n\t\tif (!trap_BotFindMatch(match->string, &tellmatch, MTCONTEXT_REPLYCHAT) ||\n\t\t\t\ttellmatch.type != MSG_CHATTELL) {\n\t\t\t//make sure not everyone reacts to this message\n\t\t\tif (random() > (float ) 1.0 / (NumPlayersOnSameTeam(bs)-1)) return qfalse;\n\t\t}\n\t}\n\treturn qtrue;\n}\n\n/*\n==================\nBotGPSToPosition\n==================\n*/\nint BotGPSToPosition(char *buf, vec3_t position) {\n\tint i, j = 0;\n\tint num, sign;\n\n\tfor (i = 0; i < 3; i++) {\n\t\tnum = 0;\n\t\twhile(buf[j] == ' ') j++;\n\t\tif (buf[j] == '-') {\n\t\t\tj++;\n\t\t\tsign = -1;\n\t\t}\n\t\telse {\n\t\t\tsign = 1;\n\t\t}\n\t\twhile (buf[j]) {\n\t\t\tif (buf[j] >= '0' && buf[j] <= '9') {\n\t\t\t\tnum = num * 10 + buf[j] - '0';\n\t\t\t\tj++;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tj++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tBotAI_Print(PRT_MESSAGE, \"%d\\n\", sign * num);\n\t\tposition[i] = (float) sign * num;\n\t}\n\treturn qtrue;\n}\n\n/*\n==================\nBotMatch_HelpAccompany\n==================\n*/\nvoid BotMatch_HelpAccompany(bot_state_t *bs, bot_match_t *match) {\n\tint client, other, areanum;\n\tchar teammate[MAX_MESSAGE_SIZE];\n\tchar netname[MAX_MESSAGE_SIZE];\n\tchar itemname[MAX_MESSAGE_SIZE];\n\tbot_match_t teammatematch;\n\taas_entityinfo_t entinfo;\n\n\tif (!TeamPlayIsOn()) return;\n\t//if not addressed to this bot\n\tif (!BotAddressedToBot(bs, match)) return;\n\t//get the team mate name\n\ttrap_BotMatchVariable(match, TEAMMATE, teammate, sizeof(teammate));\n\t//get the client to help\n\tif (trap_BotFindMatch(teammate, &teammatematch, MTCONTEXT_TEAMMATE) &&\n\t\t\t//if someone asks for him or herself\n\t\t\tteammatematch.type == MSG_ME) {\n\t\t//get the netname\n\t\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\t\tclient = ClientFromName(netname);\n\t\tother = qfalse;\n\t}\n\telse {\n\t\t//asked for someone else\n\t\tclient = FindClientByName(teammate);\n\t\t//if this is the bot self\n\t\tif (client == bs->client) {\n\t\t\tother = qfalse;\n\t\t}\n\t\telse if (!BotSameTeam(bs, client)) {\n\t\t\t//FIXME: say \"I don't help the enemy\"\n\t\t\treturn;\n\t\t}\n\t\telse {\n\t\t\tother = qtrue;\n\t\t}\n\t}\n\t//if the bot doesn't know who to help (FindClientByName returned -1)\n\tif (client < 0) {\n\t\tif (other) BotAI_BotInitialChat(bs, \"whois\", teammate, NULL);\n\t\telse BotAI_BotInitialChat(bs, \"whois\", netname, NULL);\n\t\tclient = ClientFromName(netname);\n\t\ttrap_BotEnterChat(bs->cs, client, CHAT_TELL);\n\t\treturn;\n\t}\n\t//don't help or accompany yourself\n\tif (client == bs->client) {\n\t\treturn;\n\t}\n\t//\n\tbs->teamgoal.entitynum = -1;\n\tBotEntityInfo(client, &entinfo);\n\t//if info is valid (in PVS)\n\tif (entinfo.valid) {\n\t\tareanum = BotPointAreaNum(entinfo.origin);\n\t\tif (areanum) {// && trap_AAS_AreaReachability(areanum)) {\n\t\t\tbs->teamgoal.entitynum = client;\n\t\t\tbs->teamgoal.areanum = areanum;\n\t\t\tVectorCopy(entinfo.origin, bs->teamgoal.origin);\n\t\t\tVectorSet(bs->teamgoal.mins, -8, -8, -8);\n\t\t\tVectorSet(bs->teamgoal.maxs, 8, 8, 8);\n\t\t}\n\t}\n\t//if no teamgoal yet\n\tif (bs->teamgoal.entitynum < 0) {\n\t\t//if near an item\n\t\tif (match->subtype & ST_NEARITEM) {\n\t\t\t//get the match variable\n\t\t\ttrap_BotMatchVariable(match, ITEM, itemname, sizeof(itemname));\n\t\t\t//\n\t\t\tif (!BotGetMessageTeamGoal(bs, itemname, &bs->teamgoal)) {\n\t\t\t\t//BotAI_BotInitialChat(bs, \"cannotfind\", itemname, NULL);\n\t\t\t\t//trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\t//\n\tif (bs->teamgoal.entitynum < 0) {\n\t\tif (other) BotAI_BotInitialChat(bs, \"whereis\", teammate, NULL);\n\t\telse BotAI_BotInitialChat(bs, \"whereareyou\", netname, NULL);\n\t\tclient = ClientFromName(netname);\n\t\ttrap_BotEnterChat(bs->cs, client, CHAT_TEAM);\n\t\treturn;\n\t}\n\t//the team mate\n\tbs->teammate = client;\n\t//\n\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\t//\n\tclient = ClientFromName(netname);\n\t//the team mate who ordered\n\tbs->decisionmaker = client;\n\tbs->ordered = qtrue;\n\tbs->order_time = FloatTime();\n\t//last time the team mate was assumed visible\n\tbs->teammatevisible_time = FloatTime();\n\t//set the time to send a message to the team mates\n\tbs->teammessage_time = FloatTime() + 2 * random();\n\t//get the team goal time\n\tbs->teamgoal_time = BotGetTime(match);\n\t//set the ltg type\n\tif (match->type == MSG_HELP) {\n\t\tbs->ltgtype = LTG_TEAMHELP;\n\t\tif (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + TEAM_HELP_TIME;\n\t}\n\telse {\n\t\tbs->ltgtype = LTG_TEAMACCOMPANY;\n\t\tif (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + TEAM_ACCOMPANY_TIME;\n\t\tbs->formation_dist = 3.5 * 32;\t\t//3.5 meter\n\t\tbs->arrive_time = 0;\n\t\t//\n\t\tBotSetTeamStatus(bs);\n\t\t// remember last ordered task\n\t\tBotRememberLastOrderedTask(bs);\n\t}\n#ifdef DEBUG\n\tBotPrintTeamGoal(bs);\n#endif //DEBUG\n}\n\n/*\n==================\nBotMatch_DefendKeyArea\n==================\n*/\nvoid BotMatch_DefendKeyArea(bot_state_t *bs, bot_match_t *match) {\n\tchar itemname[MAX_MESSAGE_SIZE];\n\tchar netname[MAX_MESSAGE_SIZE];\n\tint client;\n\n\tif (!TeamPlayIsOn()) return;\n\t//if not addressed to this bot\n\tif (!BotAddressedToBot(bs, match)) return;\n\t//get the match variable\n\ttrap_BotMatchVariable(match, KEYAREA, itemname, sizeof(itemname));\n\t//\n\tif (!BotGetMessageTeamGoal(bs, itemname, &bs->teamgoal)) {\n\t\t//BotAI_BotInitialChat(bs, \"cannotfind\", itemname, NULL);\n\t\t//trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);\n\t\treturn;\n\t}\n\t//\n\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\t//\n\tclient = ClientFromName(netname);\n\t//the team mate who ordered\n\tbs->decisionmaker = client;\n\tbs->ordered = qtrue;\n\tbs->order_time = FloatTime();\n\t//set the time to send a message to the team mates\n\tbs->teammessage_time = FloatTime() + 2 * random();\n\t//set the ltg type\n\tbs->ltgtype = LTG_DEFENDKEYAREA;\n\t//get the team goal time\n\tbs->teamgoal_time = BotGetTime(match);\n\t//set the team goal time\n\tif (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + TEAM_DEFENDKEYAREA_TIME;\n\t//away from defending\n\tbs->defendaway_time = 0;\n\t//\n\tBotSetTeamStatus(bs);\n\t// remember last ordered task\n\tBotRememberLastOrderedTask(bs);\n#ifdef DEBUG\n\tBotPrintTeamGoal(bs);\n#endif //DEBUG\n}\n\n/*\n==================\nBotMatch_GetItem\n==================\n*/\nvoid BotMatch_GetItem(bot_state_t *bs, bot_match_t *match) {\n\tchar itemname[MAX_MESSAGE_SIZE];\n\tchar netname[MAX_MESSAGE_SIZE];\n\tint client;\n\n\tif (!TeamPlayIsOn()) return;\n\t//if not addressed to this bot\n\tif (!BotAddressedToBot(bs, match)) return;\n\t//get the match variable\n\ttrap_BotMatchVariable(match, ITEM, itemname, sizeof(itemname));\n\t//\n\tif (!BotGetMessageTeamGoal(bs, itemname, &bs->teamgoal)) {\n\t\t//BotAI_BotInitialChat(bs, \"cannotfind\", itemname, NULL);\n\t\t//trap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);\n\t\treturn;\n\t}\n\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\tclient = ClientOnSameTeamFromName(bs, netname);\n\t//\n\tbs->decisionmaker = client;\n\tbs->ordered = qtrue;\n\tbs->order_time = FloatTime();\n\t//set the time to send a message to the team mates\n\tbs->teammessage_time = FloatTime() + 2 * random();\n\t//set the ltg type\n\tbs->ltgtype = LTG_GETITEM;\n\t//set the team goal time\n\tbs->teamgoal_time = FloatTime() + TEAM_GETITEM_TIME;\n\t//\n\tBotSetTeamStatus(bs);\n#ifdef DEBUG\n\tBotPrintTeamGoal(bs);\n#endif //DEBUG\n}\n\n/*\n==================\nBotMatch_Camp\n==================\n*/\nvoid BotMatch_Camp(bot_state_t *bs, bot_match_t *match) {\n\tint client, areanum;\n\tchar netname[MAX_MESSAGE_SIZE];\n\tchar itemname[MAX_MESSAGE_SIZE];\n\taas_entityinfo_t entinfo;\n\n\tif (!TeamPlayIsOn()) return;\n\t//if not addressed to this bot\n\tif (!BotAddressedToBot(bs, match)) return;\n\t//\n\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\t//asked for someone else\n\tclient = FindClientByName(netname);\n\t//if there's no valid client with this name\n\tif (client < 0) {\n\t\tBotAI_BotInitialChat(bs, \"whois\", netname, NULL);\n\t\ttrap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);\n\t\treturn;\n\t}\n\t//get the match variable\n\ttrap_BotMatchVariable(match, KEYAREA, itemname, sizeof(itemname));\n\t//in CTF it could be the base\n\tif (match->subtype & ST_THERE) {\n\t\t//camp at the spot the bot is currently standing\n\t\tbs->teamgoal.entitynum = bs->entitynum;\n\t\tbs->teamgoal.areanum = bs->areanum;\n\t\tVectorCopy(bs->origin, bs->teamgoal.origin);\n\t\tVectorSet(bs->teamgoal.mins, -8, -8, -8);\n\t\tVectorSet(bs->teamgoal.maxs, 8, 8, 8);\n\t}\n\telse if (match->subtype & ST_HERE) {\n\t\t//if this is the bot self\n\t\tif (client == bs->client) return;\n\t\t//\n\t\tbs->teamgoal.entitynum = -1;\n\t\tBotEntityInfo(client, &entinfo);\n\t\t//if info is valid (in PVS)\n\t\tif (entinfo.valid) {\n\t\t\tareanum = BotPointAreaNum(entinfo.origin);\n\t\t\tif (areanum) {// && trap_AAS_AreaReachability(areanum)) {\n\t\t\t\t//NOTE: just assume the bot knows where the person is\n\t\t\t\t//if (BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, client)) {\n\t\t\t\t\tbs->teamgoal.entitynum = client;\n\t\t\t\t\tbs->teamgoal.areanum = areanum;\n\t\t\t\t\tVectorCopy(entinfo.origin, bs->teamgoal.origin);\n\t\t\t\t\tVectorSet(bs->teamgoal.mins, -8, -8, -8);\n\t\t\t\t\tVectorSet(bs->teamgoal.maxs, 8, 8, 8);\n\t\t\t\t//}\n\t\t\t}\n\t\t}\n\t\t//if the other is not visible\n\t\tif (bs->teamgoal.entitynum < 0) {\n\t\t\tBotAI_BotInitialChat(bs, \"whereareyou\", netname, NULL);\n\t\t\tclient = ClientFromName(netname);\n\t\t\ttrap_BotEnterChat(bs->cs, client, CHAT_TELL);\n\t\t\treturn;\n\t\t}\n\t}\n\telse if (!BotGetMessageTeamGoal(bs, itemname, &bs->teamgoal)) {\n\t\t//BotAI_BotInitialChat(bs, \"cannotfind\", itemname, NULL);\n\t\t//client = ClientFromName(netname);\n\t\t//trap_BotEnterChat(bs->cs, client, CHAT_TELL);\n\t\treturn;\n\t}\n\t//\n\tbs->decisionmaker = client;\n\tbs->ordered = qtrue;\n\tbs->order_time = FloatTime();\n\t//set the time to send a message to the team mates\n\tbs->teammessage_time = FloatTime() + 2 * random();\n\t//set the ltg type\n\tbs->ltgtype = LTG_CAMPORDER;\n\t//get the team goal time\n\tbs->teamgoal_time = BotGetTime(match);\n\t//set the team goal time\n\tif (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + TEAM_CAMP_TIME;\n\t//not arrived yet\n\tbs->arrive_time = 0;\n\t//\n\tBotSetTeamStatus(bs);\n\t// remember last ordered task\n\tBotRememberLastOrderedTask(bs);\n#ifdef DEBUG\n\tBotPrintTeamGoal(bs);\n#endif //DEBUG\n}\n\n/*\n==================\nBotMatch_Patrol\n==================\n*/\nvoid BotMatch_Patrol(bot_state_t *bs, bot_match_t *match) {\n\tchar netname[MAX_MESSAGE_SIZE];\n\tint client;\n\n\tif (!TeamPlayIsOn()) return;\n\t//if not addressed to this bot\n\tif (!BotAddressedToBot(bs, match)) return;\n\t//get the patrol waypoints\n\tif (!BotGetPatrolWaypoints(bs, match)) return;\n\t//\n\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\t//\n\tclient = FindClientByName(netname);\n\t//\n\tbs->decisionmaker = client;\n\tbs->ordered = qtrue;\n\tbs->order_time = FloatTime();\n\t//set the time to send a message to the team mates\n\tbs->teammessage_time = FloatTime() + 2 * random();\n\t//set the ltg type\n\tbs->ltgtype = LTG_PATROL;\n\t//get the team goal time\n\tbs->teamgoal_time = BotGetTime(match);\n\t//set the team goal time if not set already\n\tif (!bs->teamgoal_time) bs->teamgoal_time = FloatTime() + TEAM_PATROL_TIME;\n\t//\n\tBotSetTeamStatus(bs);\n\t// remember last ordered task\n\tBotRememberLastOrderedTask(bs);\n#ifdef DEBUG\n\tBotPrintTeamGoal(bs);\n#endif //DEBUG\n}\n\n/*\n==================\nBotMatch_GetFlag\n==================\n*/\nvoid BotMatch_GetFlag(bot_state_t *bs, bot_match_t *match) {\n\tchar netname[MAX_MESSAGE_SIZE];\n\tint client;\n\n\tif (gametype == GT_CTF) {\n\t\tif (!ctf_redflag.areanum || !ctf_blueflag.areanum)\n\t\t\treturn;\n\t}\n#ifdef MISSIONPACK\n\telse if (gametype == GT_1FCTF) {\n\t\tif (!ctf_neutralflag.areanum || !ctf_redflag.areanum || !ctf_blueflag.areanum)\n\t\t\treturn;\n\t}\n#endif\n\telse {\n\t\treturn;\n\t}\n\t//if not addressed to this bot\n\tif (!BotAddressedToBot(bs, match)) return;\n\t//\n\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\t//\n\tclient = FindClientByName(netname);\n\t//\n\tbs->decisionmaker = client;\n\tbs->ordered = qtrue;\n\tbs->order_time = FloatTime();\n\t//set the time to send a message to the team mates\n\tbs->teammessage_time = FloatTime() + 2 * random();\n\t//set the ltg type\n\tbs->ltgtype = LTG_GETFLAG;\n\t//set the team goal time\n\tbs->teamgoal_time = FloatTime() + CTF_GETFLAG_TIME;\n\t// get an alternate route in ctf\n\tif (gametype == GT_CTF) {\n\t\t//get an alternative route goal towards the enemy base\n\t\tBotGetAlternateRouteGoal(bs, BotOppositeTeam(bs));\n\t}\n\t//\n\tBotSetTeamStatus(bs);\n\t// remember last ordered task\n\tBotRememberLastOrderedTask(bs);\n#ifdef DEBUG\n\tBotPrintTeamGoal(bs);\n#endif //DEBUG\n}\n\n/*\n==================\nBotMatch_AttackEnemyBase\n==================\n*/\nvoid BotMatch_AttackEnemyBase(bot_state_t *bs, bot_match_t *match) {\n\tchar netname[MAX_MESSAGE_SIZE];\n\tint client;\n\n\tif (gametype == GT_CTF) {\n\t\tBotMatch_GetFlag(bs, match);\n\t}\n#ifdef MISSIONPACK\n\telse if (gametype == GT_1FCTF || gametype == GT_OBELISK || gametype == GT_HARVESTER) {\n\t\tif (!redobelisk.areanum || !blueobelisk.areanum)\n\t\t\treturn;\n\t}\n#endif\n\telse {\n\t\treturn;\n\t}\n\t//if not addressed to this bot\n\tif (!BotAddressedToBot(bs, match)) return;\n\t//\n\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\t//\n\tclient = FindClientByName(netname);\n\t//\n\tbs->decisionmaker = client;\n\tbs->ordered = qtrue;\n\tbs->order_time = FloatTime();\n\t//set the time to send a message to the team mates\n\tbs->teammessage_time = FloatTime() + 2 * random();\n\t//set the ltg type\n\tbs->ltgtype = LTG_ATTACKENEMYBASE;\n\t//set the team goal time\n\tbs->teamgoal_time = FloatTime() + TEAM_ATTACKENEMYBASE_TIME;\n\tbs->attackaway_time = 0;\n\t//\n\tBotSetTeamStatus(bs);\n\t// remember last ordered task\n\tBotRememberLastOrderedTask(bs);\n#ifdef DEBUG\n\tBotPrintTeamGoal(bs);\n#endif //DEBUG\n}\n\n#ifdef MISSIONPACK\n/*\n==================\nBotMatch_Harvest\n==================\n*/\nvoid BotMatch_Harvest(bot_state_t *bs, bot_match_t *match) {\n\tchar netname[MAX_MESSAGE_SIZE];\n\tint client;\n\n\tif (gametype == GT_HARVESTER) {\n\t\tif (!neutralobelisk.areanum || !redobelisk.areanum || !blueobelisk.areanum)\n\t\t\treturn;\n\t}\n\telse {\n\t\treturn;\n\t}\n\t//if not addressed to this bot\n\tif (!BotAddressedToBot(bs, match)) return;\n\t//\n\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\t//\n\tclient = FindClientByName(netname);\n\t//\n\tbs->decisionmaker = client;\n\tbs->ordered = qtrue;\n\tbs->order_time = FloatTime();\n\t//set the time to send a message to the team mates\n\tbs->teammessage_time = FloatTime() + 2 * random();\n\t//set the ltg type\n\tbs->ltgtype = LTG_HARVEST;\n\t//set the team goal time\n\tbs->teamgoal_time = FloatTime() + TEAM_HARVEST_TIME;\n\tbs->harvestaway_time = 0;\n\t//\n\tBotSetTeamStatus(bs);\n\t// remember last ordered task\n\tBotRememberLastOrderedTask(bs);\n#ifdef DEBUG\n\tBotPrintTeamGoal(bs);\n#endif //DEBUG\n}\n#endif\n\n/*\n==================\nBotMatch_RushBase\n==================\n*/\nvoid BotMatch_RushBase(bot_state_t *bs, bot_match_t *match) {\n\tchar netname[MAX_MESSAGE_SIZE];\n\tint client;\n\n\tif (gametype == GT_CTF) {\n\t\tif (!ctf_redflag.areanum || !ctf_blueflag.areanum)\n\t\t\treturn;\n\t}\n#ifdef MISSIONPACK\n\telse if (gametype == GT_1FCTF || gametype == GT_HARVESTER) {\n\t\tif (!redobelisk.areanum || !blueobelisk.areanum)\n\t\t\treturn;\n\t}\n#endif\n\telse {\n\t\treturn;\n\t}\n\t//if not addressed to this bot\n\tif (!BotAddressedToBot(bs, match)) return;\n\t//\n\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\t//\n\tclient = FindClientByName(netname);\n\t//\n\tbs->decisionmaker = client;\n\tbs->ordered = qtrue;\n\tbs->order_time = FloatTime();\n\t//set the time to send a message to the team mates\n\tbs->teammessage_time = FloatTime() + 2 * random();\n\t//set the ltg type\n\tbs->ltgtype = LTG_RUSHBASE;\n\t//set the team goal time\n\tbs->teamgoal_time = FloatTime() + CTF_RUSHBASE_TIME;\n\tbs->rushbaseaway_time = 0;\n\t//\n\tBotSetTeamStatus(bs);\n#ifdef DEBUG\n\tBotPrintTeamGoal(bs);\n#endif //DEBUG\n}\n\n/*\n==================\nBotMatch_TaskPreference\n==================\n*/\nvoid BotMatch_TaskPreference(bot_state_t *bs, bot_match_t *match) {\n\tchar netname[MAX_NETNAME];\n\tchar teammatename[MAX_MESSAGE_SIZE];\n\tint teammate, preference;\n\n\tClientName(bs->client, netname, sizeof(netname));\n\tif (Q_stricmp(netname, bs->teamleader) != 0) return;\n\n\ttrap_BotMatchVariable(match, NETNAME, teammatename, sizeof(teammatename));\n\tteammate = ClientFromName(teammatename);\n\tif (teammate < 0) return;\n\n\tpreference = BotGetTeamMateTaskPreference(bs, teammate);\n\tswitch(match->subtype)\n\t{\n\t\tcase ST_DEFENDER:\n\t\t{\n\t\t\tpreference &= ~TEAMTP_ATTACKER;\n\t\t\tpreference |= TEAMTP_DEFENDER;\n\t\t\tbreak;\n\t\t}\n\t\tcase ST_ATTACKER:\n\t\t{\n\t\t\tpreference &= ~TEAMTP_DEFENDER;\n\t\t\tpreference |= TEAMTP_ATTACKER;\n\t\t\tbreak;\n\t\t}\n\t\tcase ST_ROAMER:\n\t\t{\n\t\t\tpreference &= ~(TEAMTP_ATTACKER|TEAMTP_DEFENDER);\n\t\t\tbreak;\n\t\t}\n\t}\n\tBotSetTeamMateTaskPreference(bs, teammate, preference);\n\t//\n\tEasyClientName(teammate, teammatename, sizeof(teammatename));\n\tBotAI_BotInitialChat(bs, \"keepinmind\", teammatename, NULL);\n\ttrap_BotEnterChat(bs->cs, teammate, CHAT_TELL);\n\tBotVoiceChatOnly(bs, teammate, VOICECHAT_YES);\n\ttrap_EA_Action(bs->client, ACTION_AFFIRMATIVE);\n}\n\n/*\n==================\nBotMatch_ReturnFlag\n==================\n*/\nvoid BotMatch_ReturnFlag(bot_state_t *bs, bot_match_t *match) {\n\tchar netname[MAX_MESSAGE_SIZE];\n\tint client;\n\n\t//if not in CTF mode\n\tif (\n\t\tgametype != GT_CTF\n#ifdef MISSIONPACK\n\t\t&& gametype != GT_1FCTF\n#endif\n\t\t)\n\t\treturn;\n\t//if not addressed to this bot\n\tif (!BotAddressedToBot(bs, match))\n\t\treturn;\n\t//\n\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\t//\n\tclient = FindClientByName(netname);\n\t//\n\tbs->decisionmaker = client;\n\tbs->ordered = qtrue;\n\tbs->order_time = FloatTime();\n\t//set the time to send a message to the team mates\n\tbs->teammessage_time = FloatTime() + 2 * random();\n\t//set the ltg type\n\tbs->ltgtype = LTG_RETURNFLAG;\n\t//set the team goal time\n\tbs->teamgoal_time = FloatTime() + CTF_RETURNFLAG_TIME;\n\tbs->rushbaseaway_time = 0;\n\t//\n\tBotSetTeamStatus(bs);\n#ifdef DEBUG\n\tBotPrintTeamGoal(bs);\n#endif //DEBUG\n}\n\n/*\n==================\nBotMatch_JoinSubteam\n==================\n*/\nvoid BotMatch_JoinSubteam(bot_state_t *bs, bot_match_t *match) {\n\tchar teammate[MAX_MESSAGE_SIZE];\n\tchar netname[MAX_MESSAGE_SIZE];\n\tint client;\n\n\tif (!TeamPlayIsOn()) return;\n\t//if not addressed to this bot\n\tif (!BotAddressedToBot(bs, match)) return;\n\t//get the sub team name\n\ttrap_BotMatchVariable(match, TEAMNAME, teammate, sizeof(teammate));\n\t//set the sub team name\n\tstrncpy(bs->subteam, teammate, 32);\n\tbs->subteam[31] = '\\0';\n\t//\n\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\tBotAI_BotInitialChat(bs, \"joinedteam\", teammate, NULL);\n\tclient = ClientFromName(netname);\n\ttrap_BotEnterChat(bs->cs, client, CHAT_TELL);\n}\n\n/*\n==================\nBotMatch_LeaveSubteam\n==================\n*/\nvoid BotMatch_LeaveSubteam(bot_state_t *bs, bot_match_t *match) {\n\tchar netname[MAX_MESSAGE_SIZE];\n\tint client;\n\n\tif (!TeamPlayIsOn()) return;\n\t//if not addressed to this bot\n\tif (!BotAddressedToBot(bs, match)) return;\n\t//\n\tif (strlen(bs->subteam))\n\t{\n\t\tBotAI_BotInitialChat(bs, \"leftteam\", bs->subteam, NULL);\n\t\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\t\tclient = ClientFromName(netname);\n\t\ttrap_BotEnterChat(bs->cs, client, CHAT_TELL);\n\t} //end if\n\tstrcpy(bs->subteam, \"\");\n}\n\n/*\n==================\nBotMatch_LeaveSubteam\n==================\n*/\nvoid BotMatch_WhichTeam(bot_state_t *bs, bot_match_t *match) {\n\tif (!TeamPlayIsOn()) return;\n\t//if not addressed to this bot\n\tif (!BotAddressedToBot(bs, match)) return;\n\t//\n\tif (strlen(bs->subteam)) {\n\t\tBotAI_BotInitialChat(bs, \"inteam\", bs->subteam, NULL);\n\t}\n\telse {\n\t\tBotAI_BotInitialChat(bs, \"noteam\", NULL);\n\t}\n\ttrap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);\n}\n\n/*\n==================\nBotMatch_CheckPoint\n==================\n*/\nvoid BotMatch_CheckPoint(bot_state_t *bs, bot_match_t *match) {\n\tint areanum, client;\n\tchar buf[MAX_MESSAGE_SIZE];\n\tchar netname[MAX_MESSAGE_SIZE];\n\tvec3_t position;\n\tbot_waypoint_t *cp;\n\n\tif (!TeamPlayIsOn()) return;\n\t//\n\ttrap_BotMatchVariable(match, POSITION, buf, MAX_MESSAGE_SIZE);\n\tVectorClear(position);\n\t//\n\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\tclient = ClientFromName(netname);\n\t//BotGPSToPosition(buf, position);\n\tsscanf(buf, \"%f %f %f\", &position[0], &position[1], &position[2]);\n\tposition[2] += 0.5;\n\tareanum = BotPointAreaNum(position);\n\tif (!areanum) {\n\t\tif (BotAddressedToBot(bs, match)) {\n\t\t\tBotAI_BotInitialChat(bs, \"checkpoint_invalid\", NULL);\n\t\t\ttrap_BotEnterChat(bs->cs, client, CHAT_TELL);\n\t\t}\n\t\treturn;\n\t}\n\t//\n\ttrap_BotMatchVariable(match, NAME, buf, MAX_MESSAGE_SIZE);\n\t//check if there already exists a checkpoint with this name\n\tcp = BotFindWayPoint(bs->checkpoints, buf);\n\tif (cp) {\n\t\tif (cp->next) cp->next->prev = cp->prev;\n\t\tif (cp->prev) cp->prev->next = cp->next;\n\t\telse bs->checkpoints = cp->next;\n\t\tcp->inuse = qfalse;\n\t}\n\t//create a new check point\n\tcp = BotCreateWayPoint(buf, position, areanum);\n\t//add the check point to the bot's known chech points\n\tcp->next = bs->checkpoints;\n\tif (bs->checkpoints) bs->checkpoints->prev = cp;\n\tbs->checkpoints = cp;\n\t//\n\tif (BotAddressedToBot(bs, match)) {\n\t\tCom_sprintf(buf, sizeof(buf), \"%1.0f %1.0f %1.0f\", cp->goal.origin[0],\n\t\t\t\t\t\t\t\t\t\t\t\t\tcp->goal.origin[1],\n\t\t\t\t\t\t\t\t\t\t\t\t\tcp->goal.origin[2]);\n\n\t\tBotAI_BotInitialChat(bs, \"checkpoint_confirm\", cp->name, buf, NULL);\n\t\ttrap_BotEnterChat(bs->cs, client, CHAT_TELL);\n\t}\n}\n\n/*\n==================\nBotMatch_FormationSpace\n==================\n*/\nvoid BotMatch_FormationSpace(bot_state_t *bs, bot_match_t *match) {\n\tchar buf[MAX_MESSAGE_SIZE];\n\tfloat space;\n\n\tif (!TeamPlayIsOn()) return;\n\t//if not addressed to this bot\n\tif (!BotAddressedToBot(bs, match)) return;\n\t//\n\ttrap_BotMatchVariable(match, NUMBER, buf, MAX_MESSAGE_SIZE);\n\t//if it's the distance in feet\n\tif (match->subtype & ST_FEET) space = 0.3048 * 32 * atof(buf);\n\t//else it's in meters\n\telse space = 32 * atof(buf);\n\t//check if the formation intervening space is valid\n\tif (space < 48 || space > 500) space = 100;\n\tbs->formation_dist = space;\n}\n\n/*\n==================\nBotMatch_Dismiss\n==================\n*/\nvoid BotMatch_Dismiss(bot_state_t *bs, bot_match_t *match) {\n\tchar netname[MAX_MESSAGE_SIZE];\n\tint client;\n\n\tif (!TeamPlayIsOn()) return;\n\t//if not addressed to this bot\n\tif (!BotAddressedToBot(bs, match)) return;\n\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\tclient = ClientFromName(netname);\n\t//\n\tbs->decisionmaker = client;\n\t//\n\tbs->ltgtype = 0;\n\tbs->lead_time = 0;\n\tbs->lastgoal_ltgtype = 0;\n\t//\n\tBotAI_BotInitialChat(bs, \"dismissed\", NULL);\n\ttrap_BotEnterChat(bs->cs, client, CHAT_TELL);\n}\n\n/*\n==================\nBotMatch_Suicide\n==================\n*/\nvoid BotMatch_Suicide(bot_state_t *bs, bot_match_t *match) {\n\tchar netname[MAX_MESSAGE_SIZE];\n\tint client;\n\n\tif (!TeamPlayIsOn()) return;\n\t//if not addressed to this bot\n\tif (!BotAddressedToBot(bs, match)) return;\n\t//\n\ttrap_EA_Command(bs->client, \"kill\");\n\t//\n\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\tclient = ClientFromName(netname);\n\t//\n\tBotVoiceChat(bs, client, VOICECHAT_TAUNT);\n\ttrap_EA_Action(bs->client, ACTION_AFFIRMATIVE);\n}\n\n/*\n==================\nBotMatch_StartTeamLeaderShip\n==================\n*/\nvoid BotMatch_StartTeamLeaderShip(bot_state_t *bs, bot_match_t *match) {\n\tint client;\n\tchar teammate[MAX_MESSAGE_SIZE];\n\n\tif (!TeamPlayIsOn()) return;\n\t//if chats for him or herself\n\tif (match->subtype & ST_I) {\n\t\t//get the team mate that will be the team leader\n\t\ttrap_BotMatchVariable(match, NETNAME, teammate, sizeof(teammate));\n\t\tstrncpy(bs->teamleader, teammate, sizeof(bs->teamleader));\n\t\tbs->teamleader[sizeof(bs->teamleader)] = '\\0';\n\t}\n\t//chats for someone else\n\telse {\n\t\t//get the team mate that will be the team leader\n\t\ttrap_BotMatchVariable(match, TEAMMATE, teammate, sizeof(teammate));\n\t\tclient = FindClientByName(teammate);\n\t\tif (client >= 0) ClientName(client, bs->teamleader, sizeof(bs->teamleader));\n\t}\n}\n\n/*\n==================\nBotMatch_StopTeamLeaderShip\n==================\n*/\nvoid BotMatch_StopTeamLeaderShip(bot_state_t *bs, bot_match_t *match) {\n\tint client;\n\tchar teammate[MAX_MESSAGE_SIZE];\n\tchar netname[MAX_MESSAGE_SIZE];\n\n\tif (!TeamPlayIsOn()) return;\n\t//get the team mate that stops being the team leader\n\ttrap_BotMatchVariable(match, TEAMMATE, teammate, sizeof(teammate));\n\t//if chats for him or herself\n\tif (match->subtype & ST_I) {\n\t\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\t\tclient = FindClientByName(netname);\n\t}\n\t//chats for someone else\n\telse {\n\t\tclient = FindClientByName(teammate);\n\t} //end else\n\tif (client >= 0) {\n\t\tif (!Q_stricmp(bs->teamleader, ClientName(client, netname, sizeof(netname)))) {\n\t\t\tbs->teamleader[0] = '\\0';\n\t\t\tnotleader[client] = qtrue;\n\t\t}\n\t}\n}\n\n/*\n==================\nBotMatch_WhoIsTeamLeader\n==================\n*/\nvoid BotMatch_WhoIsTeamLeader(bot_state_t *bs, bot_match_t *match) {\n\tchar netname[MAX_MESSAGE_SIZE];\n\n\tif (!TeamPlayIsOn()) return;\n\n\tClientName(bs->client, netname, sizeof(netname));\n\t//if this bot IS the team leader\n\tif (!Q_stricmp(netname, bs->teamleader)) {\n\t\ttrap_EA_SayTeam(bs->client, \"I'm the team leader\\n\");\n\t}\n}\n\n/*\n==================\nBotMatch_WhatAreYouDoing\n==================\n*/\nvoid BotMatch_WhatAreYouDoing(bot_state_t *bs, bot_match_t *match) {\n\tchar netname[MAX_MESSAGE_SIZE];\n\tchar goalname[MAX_MESSAGE_SIZE];\n\tint client;\n\n\t//if not addressed to this bot\n\tif (!BotAddressedToBot(bs, match)) return;\n\t//\n\tswitch(bs->ltgtype) {\n\t\tcase LTG_TEAMHELP:\n\t\t{\n\t\t\tEasyClientName(bs->teammate, netname, sizeof(netname));\n\t\t\tBotAI_BotInitialChat(bs, \"helping\", netname, NULL);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_TEAMACCOMPANY:\n\t\t{\n\t\t\tEasyClientName(bs->teammate, netname, sizeof(netname));\n\t\t\tBotAI_BotInitialChat(bs, \"accompanying\", netname, NULL);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_DEFENDKEYAREA:\n\t\t{\n\t\t\ttrap_BotGoalName(bs->teamgoal.number, goalname, sizeof(goalname));\n\t\t\tBotAI_BotInitialChat(bs, \"defending\", goalname, NULL);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_GETITEM:\n\t\t{\n\t\t\ttrap_BotGoalName(bs->teamgoal.number, goalname, sizeof(goalname));\n\t\t\tBotAI_BotInitialChat(bs, \"gettingitem\", goalname, NULL);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_KILL:\n\t\t{\n\t\t\tClientName(bs->teamgoal.entitynum, netname, sizeof(netname));\n\t\t\tBotAI_BotInitialChat(bs, \"killing\", netname, NULL);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_CAMP:\n\t\tcase LTG_CAMPORDER:\n\t\t{\n\t\t\tBotAI_BotInitialChat(bs, \"camping\", NULL);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_PATROL:\n\t\t{\n\t\t\tBotAI_BotInitialChat(bs, \"patrolling\", NULL);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_GETFLAG:\n\t\t{\n\t\t\tBotAI_BotInitialChat(bs, \"capturingflag\", NULL);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_RUSHBASE:\n\t\t{\n\t\t\tBotAI_BotInitialChat(bs, \"rushingbase\", NULL);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_RETURNFLAG:\n\t\t{\n\t\t\tBotAI_BotInitialChat(bs, \"returningflag\", NULL);\n\t\t\tbreak;\n\t\t}\n#ifdef MISSIONPACK\n\t\tcase LTG_ATTACKENEMYBASE:\n\t\t{\n\t\t\tBotAI_BotInitialChat(bs, \"attackingenemybase\", NULL);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_HARVEST:\n\t\t{\n\t\t\tBotAI_BotInitialChat(bs, \"harvesting\", NULL);\n\t\t\tbreak;\n\t\t}\n#endif\n\t\tdefault:\n\t\t{\n\t\t\tBotAI_BotInitialChat(bs, \"roaming\", NULL);\n\t\t\tbreak;\n\t\t}\n\t}\n\t//chat what the bot is doing\n\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\tclient = ClientFromName(netname);\n\ttrap_BotEnterChat(bs->cs, client, CHAT_TELL);\n}\n\n/*\n==================\nBotMatch_WhatIsMyCommand\n==================\n*/\nvoid BotMatch_WhatIsMyCommand(bot_state_t *bs, bot_match_t *match) {\n\tchar netname[MAX_NETNAME];\n\n\tClientName(bs->client, netname, sizeof(netname));\n\tif (Q_stricmp(netname, bs->teamleader) != 0) return;\n\tbs->forceorders = qtrue;\n}\n\n/*\n==================\nBotNearestVisibleItem\n==================\n*/\nfloat BotNearestVisibleItem(bot_state_t *bs, char *itemname, bot_goal_t *goal) {\n\tint i;\n\tchar name[64];\n\tbot_goal_t tmpgoal;\n\tfloat dist, bestdist;\n\tvec3_t dir;\n\tbsp_trace_t trace;\n\n\tbestdist = 999999;\n\ti = -1;\n\tdo {\n\t\ti = trap_BotGetLevelItemGoal(i, itemname, &tmpgoal);\n\t\ttrap_BotGoalName(tmpgoal.number, name, sizeof(name));\n\t\tif (Q_stricmp(itemname, name) != 0)\n\t\t\tcontinue;\n\t\tVectorSubtract(tmpgoal.origin, bs->origin, dir);\n\t\tdist = VectorLength(dir);\n\t\tif (dist < bestdist) {\n\t\t\t//trace from start to end\n\t\t\tBotAI_Trace(&trace, bs->eye, NULL, NULL, tmpgoal.origin, bs->client, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);\n\t\t\tif (trace.fraction >= 1.0) {\n\t\t\t\tbestdist = dist;\n\t\t\t\tmemcpy(goal, &tmpgoal, sizeof(bot_goal_t));\n\t\t\t}\n\t\t}\n\t} while(i > 0);\n\treturn bestdist;\n}\n\n/*\n==================\nBotMatch_WhereAreYou\n==================\n*/\nvoid BotMatch_WhereAreYou(bot_state_t *bs, bot_match_t *match) {\n\tfloat dist, bestdist;\n\tint i, bestitem, redtt, bluett, client;\n\tbot_goal_t goal;\n\tchar netname[MAX_MESSAGE_SIZE];\n\tchar *nearbyitems[] = {\n\t\t\"Shotgun\",\n\t\t\"Grenade Launcher\",\n\t\t\"Rocket Launcher\",\n\t\t\"Plasmagun\",\n\t\t\"Railgun\",\n\t\t\"Lightning Gun\",\n\t\t\"BFG10K\",\n\t\t\"Quad Damage\",\n\t\t\"Regeneration\",\n\t\t\"Battle Suit\",\n\t\t\"Speed\",\n\t\t\"Invisibility\",\n\t\t\"Flight\",\n\t\t\"Armor\",\n\t\t\"Heavy Armor\",\n\t\t\"Red Flag\",\n\t\t\"Blue Flag\",\n#ifdef MISSIONPACK\n\t\t\"Nailgun\",\n\t\t\"Prox Launcher\",\n\t\t\"Chaingun\",\n\t\t\"Scout\",\n\t\t\"Guard\",\n\t\t\"Doubler\",\n\t\t\"Ammo Regen\",\n\t\t\"Neutral Flag\",\n\t\t\"Red Obelisk\",\n\t\t\"Blue Obelisk\",\n\t\t\"Neutral Obelisk\",\n#endif\n\t\tNULL\n\t};\n\t//\n\tif (!TeamPlayIsOn())\n\t\treturn;\n\t//if not addressed to this bot\n\tif (!BotAddressedToBot(bs, match))\n\t\treturn;\n\n\tbestitem = -1;\n\tbestdist = 999999;\n\tfor (i = 0; nearbyitems[i]; i++) {\n\t\tdist = BotNearestVisibleItem(bs, nearbyitems[i], &goal);\n\t\tif (dist < bestdist) {\n\t\t\tbestdist = dist;\n\t\t\tbestitem = i;\n\t\t}\n\t}\n\tif (bestitem != -1) {\n\t\tif (gametype == GT_CTF\n#ifdef MISSIONPACK\n\t\t\t|| gametype == GT_1FCTF\n#endif\n\t\t\t) {\n\t\t\tredtt = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, ctf_redflag.areanum, TFL_DEFAULT);\n\t\t\tbluett = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, ctf_blueflag.areanum, TFL_DEFAULT);\n\t\t\tif (redtt < (redtt + bluett) * 0.4) {\n\t\t\t\tBotAI_BotInitialChat(bs, \"teamlocation\", nearbyitems[bestitem], \"red\", NULL);\n\t\t\t}\n\t\t\telse if (bluett < (redtt + bluett) * 0.4) {\n\t\t\t\tBotAI_BotInitialChat(bs, \"teamlocation\", nearbyitems[bestitem], \"blue\", NULL);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tBotAI_BotInitialChat(bs, \"location\", nearbyitems[bestitem], NULL);\n\t\t\t}\n\t\t}\n#ifdef MISSIONPACK\n\t\telse if (gametype == GT_OBELISK || gametype == GT_HARVESTER) {\n\t\t\tredtt = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, redobelisk.areanum, TFL_DEFAULT);\n\t\t\tbluett = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, blueobelisk.areanum, TFL_DEFAULT);\n\t\t\tif (redtt < (redtt + bluett) * 0.4) {\n\t\t\t\tBotAI_BotInitialChat(bs, \"teamlocation\", nearbyitems[bestitem], \"red\", NULL);\n\t\t\t}\n\t\t\telse if (bluett < (redtt + bluett) * 0.4) {\n\t\t\t\tBotAI_BotInitialChat(bs, \"teamlocation\", nearbyitems[bestitem], \"blue\", NULL);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tBotAI_BotInitialChat(bs, \"location\", nearbyitems[bestitem], NULL);\n\t\t\t}\n\t\t}\n#endif\n\t\telse {\n\t\t\tBotAI_BotInitialChat(bs, \"location\", nearbyitems[bestitem], NULL);\n\t\t}\n\t\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\t\tclient = ClientFromName(netname);\n\t\ttrap_BotEnterChat(bs->cs, client, CHAT_TELL);\n\t}\n}\n\n/*\n==================\nBotMatch_LeadTheWay\n==================\n*/\nvoid BotMatch_LeadTheWay(bot_state_t *bs, bot_match_t *match) {\n\taas_entityinfo_t entinfo;\n\tchar netname[MAX_MESSAGE_SIZE], teammate[MAX_MESSAGE_SIZE];\n\tint client, areanum, other;\n\n\tif (!TeamPlayIsOn()) return;\n\t//if not addressed to this bot\n\tif (!BotAddressedToBot(bs, match)) return;\n\t//if someone asks for someone else\n\tif (match->subtype & ST_SOMEONE) {\n\t\t//get the team mate name\n\t\ttrap_BotMatchVariable(match, TEAMMATE, teammate, sizeof(teammate));\n\t\tclient = FindClientByName(teammate);\n\t\t//if this is the bot self\n\t\tif (client == bs->client) {\n\t\t\tother = qfalse;\n\t\t}\n\t\telse if (!BotSameTeam(bs, client)) {\n\t\t\t//FIXME: say \"I don't help the enemy\"\n\t\t\treturn;\n\t\t}\n\t\telse {\n\t\t\tother = qtrue;\n\t\t}\n\t}\n\telse {\n\t\t//get the netname\n\t\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\t\tclient = ClientFromName(netname);\n\t\tother = qfalse;\n\t}\n\t//if the bot doesn't know who to help (FindClientByName returned -1)\n\tif (client < 0) {\n\t\tBotAI_BotInitialChat(bs, \"whois\", netname, NULL);\n\t\ttrap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);\n\t\treturn;\n\t}\n\t//\n\tbs->lead_teamgoal.entitynum = -1;\n\tBotEntityInfo(client, &entinfo);\n\t//if info is valid (in PVS)\n\tif (entinfo.valid) {\n\t\tareanum = BotPointAreaNum(entinfo.origin);\n\t\tif (areanum) { // && trap_AAS_AreaReachability(areanum)) {\n\t\t\tbs->lead_teamgoal.entitynum = client;\n\t\t\tbs->lead_teamgoal.areanum = areanum;\n\t\t\tVectorCopy(entinfo.origin, bs->lead_teamgoal.origin);\n\t\t\tVectorSet(bs->lead_teamgoal.mins, -8, -8, -8);\n\t\t\tVectorSet(bs->lead_teamgoal.maxs, 8, 8, 8);\n\t\t}\n\t}\n\n\tif (bs->teamgoal.entitynum < 0) {\n\t\tif (other) BotAI_BotInitialChat(bs, \"whereis\", teammate, NULL);\n\t\telse BotAI_BotInitialChat(bs, \"whereareyou\", netname, NULL);\n\t\ttrap_BotEnterChat(bs->cs, bs->client, CHAT_TEAM);\n\t\treturn;\n\t}\n\tbs->lead_teammate = client;\n\tbs->lead_time = FloatTime() + TEAM_LEAD_TIME;\n\tbs->leadvisible_time = 0;\n\tbs->leadmessage_time = -(FloatTime() + 2 * random());\n}\n\n/*\n==================\nBotMatch_Kill\n==================\n*/\nvoid BotMatch_Kill(bot_state_t *bs, bot_match_t *match) {\n\tchar enemy[MAX_MESSAGE_SIZE];\n\tchar netname[MAX_MESSAGE_SIZE];\n\tint client;\n\n\tif (!TeamPlayIsOn()) return;\n\t//if not addressed to this bot\n\tif (!BotAddressedToBot(bs, match)) return;\n\n\ttrap_BotMatchVariable(match, ENEMY, enemy, sizeof(enemy));\n\t//\n\tclient = FindEnemyByName(bs, enemy);\n\tif (client < 0) {\n\t\tBotAI_BotInitialChat(bs, \"whois\", enemy, NULL);\n\t\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\t\tclient = ClientFromName(netname);\n\t\ttrap_BotEnterChat(bs->cs, client, CHAT_TELL);\n\t\treturn;\n\t}\n\tbs->teamgoal.entitynum = client;\n\t//set the time to send a message to the team mates\n\tbs->teammessage_time = FloatTime() + 2 * random();\n\t//set the ltg type\n\tbs->ltgtype = LTG_KILL;\n\t//set the team goal time\n\tbs->teamgoal_time = FloatTime() + TEAM_KILL_SOMEONE;\n\t//\n\tBotSetTeamStatus(bs);\n#ifdef DEBUG\n\tBotPrintTeamGoal(bs);\n#endif //DEBUG\n}\n\n/*\n==================\nBotMatch_CTF\n==================\n*/\nvoid BotMatch_CTF(bot_state_t *bs, bot_match_t *match) {\n\n\tchar flag[128], netname[MAX_NETNAME];\n\n\tif (gametype == GT_CTF) {\n\t\ttrap_BotMatchVariable(match, FLAG, flag, sizeof(flag));\n\t\tif (match->subtype & ST_GOTFLAG) {\n\t\t\tif (!Q_stricmp(flag, \"red\")) {\n\t\t\t\tbs->redflagstatus = 1;\n\t\t\t\tif (BotTeam(bs) == TEAM_BLUE) {\n\t\t\t\t\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\t\t\t\t\tbs->flagcarrier = ClientFromName(netname);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tbs->blueflagstatus = 1;\n\t\t\t\tif (BotTeam(bs) == TEAM_RED) {\n\t\t\t\t\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\t\t\t\t\tbs->flagcarrier = ClientFromName(netname);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbs->flagstatuschanged = 1;\n\t\t\tbs->lastflagcapture_time = FloatTime();\n\t\t}\n\t\telse if (match->subtype & ST_CAPTUREDFLAG) {\n\t\t\tbs->redflagstatus = 0;\n\t\t\tbs->blueflagstatus = 0;\n\t\t\tbs->flagcarrier = 0;\n\t\t\tbs->flagstatuschanged = 1;\n\t\t}\n\t\telse if (match->subtype & ST_RETURNEDFLAG) {\n\t\t\tif (!Q_stricmp(flag, \"red\")) bs->redflagstatus = 0;\n\t\t\telse bs->blueflagstatus = 0;\n\t\t\tbs->flagstatuschanged = 1;\n\t\t}\n\t}\n#ifdef MISSIONPACK\n\telse if (gametype == GT_1FCTF) {\n\t\tif (match->subtype & ST_1FCTFGOTFLAG) {\n\t\t\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\t\t\tbs->flagcarrier = ClientFromName(netname);\n\t\t}\n\t}\n#endif\n}\n\nvoid BotMatch_EnterGame(bot_state_t *bs, bot_match_t *match) {\n\tint client;\n\tchar netname[MAX_NETNAME];\n\n\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\tclient = FindClientByName(netname);\n\tif (client >= 0) {\n\t\tnotleader[client] = qfalse;\n\t}\n\t//NOTE: eliza chats will catch this\n\t//Com_sprintf(buf, sizeof(buf), \"heya %s\", netname);\n\t//EA_Say(bs->client, buf);\n}\n\nvoid BotMatch_NewLeader(bot_state_t *bs, bot_match_t *match) {\n\tint client;\n\tchar netname[MAX_NETNAME];\n\n\ttrap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));\n\tclient = FindClientByName(netname);\n\tif (!BotSameTeam(bs, client))\n\t\treturn;\n\tQ_strncpyz(bs->teamleader, netname, sizeof(bs->teamleader));\n}\n\n/*\n==================\nBotMatchMessage\n==================\n*/\nint BotMatchMessage(bot_state_t *bs, char *message) {\n\tbot_match_t match;\n\n\tmatch.type = 0;\n\t//if it is an unknown message\n\tif (!trap_BotFindMatch(message, &match, MTCONTEXT_MISC\n\t\t\t\t\t\t\t\t\t\t\t|MTCONTEXT_INITIALTEAMCHAT\n\t\t\t\t\t\t\t\t\t\t\t|MTCONTEXT_CTF)) {\n\t\treturn qfalse;\n\t}\n\t//react to the found message\n\tswitch(match.type)\n\t{\n\t\tcase MSG_HELP:\t\t\t\t\t//someone calling for help\n\t\tcase MSG_ACCOMPANY:\t\t\t\t//someone calling for company\n\t\t{\n\t\t\tBotMatch_HelpAccompany(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_DEFENDKEYAREA:\t\t\t//teamplay defend a key area\n\t\t{\n\t\t\tBotMatch_DefendKeyArea(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_CAMP:\t\t\t\t\t//camp somewhere\n\t\t{\n\t\t\tBotMatch_Camp(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_PATROL:\t\t\t\t//patrol between several key areas\n\t\t{\n\t\t\tBotMatch_Patrol(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\t//CTF & 1FCTF\n\t\tcase MSG_GETFLAG:\t\t\t\t//ctf get the enemy flag\n\t\t{\n\t\t\tBotMatch_GetFlag(bs, &match);\n\t\t\tbreak;\n\t\t}\n#ifdef MISSIONPACK\n\t\t//CTF & 1FCTF & Obelisk & Harvester\n\t\tcase MSG_ATTACKENEMYBASE:\n\t\t{\n\t\t\tBotMatch_AttackEnemyBase(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\t//Harvester\n\t\tcase MSG_HARVEST:\n\t\t{\n\t\t\tBotMatch_Harvest(bs, &match);\n\t\t\tbreak;\n\t\t}\n#endif\n\t\t//CTF & 1FCTF & Harvester\n\t\tcase MSG_RUSHBASE:\t\t\t\t//ctf rush to the base\n\t\t{\n\t\t\tBotMatch_RushBase(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\t//CTF & 1FCTF\n\t\tcase MSG_RETURNFLAG:\n\t\t{\n\t\t\tBotMatch_ReturnFlag(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\t//CTF & 1FCTF & Obelisk & Harvester\n\t\tcase MSG_TASKPREFERENCE:\n\t\t{\n\t\t\tBotMatch_TaskPreference(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\t//CTF & 1FCTF\n\t\tcase MSG_CTF:\n\t\t{\n\t\t\tBotMatch_CTF(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_GETITEM:\n\t\t{\n\t\t\tBotMatch_GetItem(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_JOINSUBTEAM:\t\t\t//join a sub team\n\t\t{\n\t\t\tBotMatch_JoinSubteam(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_LEAVESUBTEAM:\t\t\t//leave a sub team\n\t\t{\n\t\t\tBotMatch_LeaveSubteam(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_WHICHTEAM:\n\t\t{\n\t\t\tBotMatch_WhichTeam(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_CHECKPOINT:\t\t\t//remember a check point\n\t\t{\n\t\t\tBotMatch_CheckPoint(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_CREATENEWFORMATION:\t//start the creation of a new formation\n\t\t{\n\t\t\ttrap_EA_SayTeam(bs->client, \"the part of my brain to create formations has been damaged\");\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_FORMATIONPOSITION:\t\t//tell someone his/her position in the formation\n\t\t{\n\t\t\ttrap_EA_SayTeam(bs->client, \"the part of my brain to create formations has been damaged\");\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_FORMATIONSPACE:\t\t//set the formation space\n\t\t{\n\t\t\tBotMatch_FormationSpace(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_DOFORMATION:\t\t\t//form a certain formation\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_DISMISS:\t\t\t\t//dismiss someone\n\t\t{\n\t\t\tBotMatch_Dismiss(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_STARTTEAMLEADERSHIP:\t//someone will become the team leader\n\t\t{\n\t\t\tBotMatch_StartTeamLeaderShip(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_STOPTEAMLEADERSHIP:\t//someone will stop being the team leader\n\t\t{\n\t\t\tBotMatch_StopTeamLeaderShip(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_WHOISTEAMLAEDER:\n\t\t{\n\t\t\tBotMatch_WhoIsTeamLeader(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_WHATAREYOUDOING:\t\t//ask a bot what he/she is doing\n\t\t{\n\t\t\tBotMatch_WhatAreYouDoing(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_WHATISMYCOMMAND:\n\t\t{\n\t\t\tBotMatch_WhatIsMyCommand(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_WHEREAREYOU:\n\t\t{\n\t\t\tBotMatch_WhereAreYou(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_LEADTHEWAY:\n\t\t{\n\t\t\tBotMatch_LeadTheWay(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_KILL:\n\t\t{\n\t\t\tBotMatch_Kill(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_ENTERGAME:\t\t\t\t//someone entered the game\n\t\t{\n\t\t\tBotMatch_EnterGame(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_NEWLEADER:\n\t\t{\n\t\t\tBotMatch_NewLeader(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_WAIT:\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t\tcase MSG_SUICIDE:\n\t\t{\n\t\t\tBotMatch_Suicide(bs, &match);\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t{\n\t\t\tBotAI_Print(PRT_MESSAGE, \"unknown match type\\n\");\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn qtrue;\n}\n"
  },
  {
    "path": "code/game/ai_cmd.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n/*****************************************************************************\n * name:\t\tai_cmd.h\n *\n * desc:\t\tQuake3 bot AI\n *\n * $Archive: /source/code/botai/ai_chat.c $\n *\n *****************************************************************************/\n\nextern int notleader[MAX_CLIENTS];\n\nint BotMatchMessage(bot_state_t *bs, char *message);\nvoid BotPrintTeamGoal(bot_state_t *bs);\n\n"
  },
  {
    "path": "code/game/ai_dmnet.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n/*****************************************************************************\n * name:\t\tai_dmnet.c\n *\n * desc:\t\tQuake3 bot AI\n *\n * $Archive: /MissionPack/code/game/ai_dmnet.c $\n *\n *****************************************************************************/\n\n#include \"g_local.h\"\n#include \"botlib.h\"\n#include \"be_aas.h\"\n#include \"be_ea.h\"\n#include \"be_ai_char.h\"\n#include \"be_ai_chat.h\"\n#include \"be_ai_gen.h\"\n#include \"be_ai_goal.h\"\n#include \"be_ai_move.h\"\n#include \"be_ai_weap.h\"\n//\n#include \"ai_main.h\"\n#include \"ai_dmq3.h\"\n#include \"ai_chat.h\"\n#include \"ai_cmd.h\"\n#include \"ai_dmnet.h\"\n#include \"ai_team.h\"\n//data file headers\n#include \"chars.h\"\t\t\t//characteristics\n#include \"inv.h\"\t\t\t//indexes into the inventory\n#include \"syn.h\"\t\t\t//synonyms\n#include \"match.h\"\t\t\t//string matching types and vars\n\n// for the voice chats\n#include \"../../ui/menudef.h\"\n\n//goal flag, see be_ai_goal.h for the other GFL_*\n#define GFL_AIR\t\t\t128\n\nint numnodeswitches;\nchar nodeswitch[MAX_NODESWITCHES+1][144];\n\n#define LOOKAHEAD_DISTANCE\t\t\t300\n\n/*\n==================\nBotResetNodeSwitches\n==================\n*/\nvoid BotResetNodeSwitches(void) {\n\tnumnodeswitches = 0;\n}\n\n/*\n==================\nBotDumpNodeSwitches\n==================\n*/\nvoid BotDumpNodeSwitches(bot_state_t *bs) {\n\tint i;\n\tchar netname[MAX_NETNAME];\n\n\tClientName(bs->client, netname, sizeof(netname));\n\tBotAI_Print(PRT_MESSAGE, \"%s at %1.1f switched more than %d AI nodes\\n\", netname, FloatTime(), MAX_NODESWITCHES);\n\tfor (i = 0; i < numnodeswitches; i++) {\n\t\tBotAI_Print(PRT_MESSAGE, nodeswitch[i]);\n\t}\n\tBotAI_Print(PRT_FATAL, \"\");\n}\n\n/*\n==================\nBotRecordNodeSwitch\n==================\n*/\nvoid BotRecordNodeSwitch(bot_state_t *bs, char *node, char *str, char *s) {\n\tchar netname[MAX_NETNAME];\n\n\tClientName(bs->client, netname, sizeof(netname));\n\tCom_sprintf(nodeswitch[numnodeswitches], 144, \"%s at %2.1f entered %s: %s from %s\\n\", netname, FloatTime(), node, str, s);\n#ifdef DEBUG\n\tif (0) {\n\t\tBotAI_Print(PRT_MESSAGE, nodeswitch[numnodeswitches]);\n\t}\n#endif //DEBUG\n\tnumnodeswitches++;\n}\n\n/*\n==================\nBotGetAirGoal\n==================\n*/\nint BotGetAirGoal(bot_state_t *bs, bot_goal_t *goal) {\n\tbsp_trace_t bsptrace;\n\tvec3_t end, mins = {-15, -15, -2}, maxs = {15, 15, 2};\n\tint areanum;\n\n\t//trace up until we hit solid\n\tVectorCopy(bs->origin, end);\n\tend[2] += 1000;\n\tBotAI_Trace(&bsptrace, bs->origin, mins, maxs, end, bs->entitynum, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);\n\t//trace down until we hit water\n\tVectorCopy(bsptrace.endpos, end);\n\tBotAI_Trace(&bsptrace, end, mins, maxs, bs->origin, bs->entitynum, CONTENTS_WATER|CONTENTS_SLIME|CONTENTS_LAVA);\n\t//if we found the water surface\n\tif (bsptrace.fraction > 0) {\n\t\tareanum = BotPointAreaNum(bsptrace.endpos);\n\t\tif (areanum) {\n\t\t\tVectorCopy(bsptrace.endpos, goal->origin);\n\t\t\tgoal->origin[2] -= 2;\n\t\t\tgoal->areanum = areanum;\n\t\t\tgoal->mins[0] = -15;\n\t\t\tgoal->mins[1] = -15;\n\t\t\tgoal->mins[2] = -1;\n\t\t\tgoal->maxs[0] = 15;\n\t\t\tgoal->maxs[1] = 15;\n\t\t\tgoal->maxs[2] = 1;\n\t\t\tgoal->flags = GFL_AIR;\n\t\t\tgoal->number = 0;\n\t\t\tgoal->iteminfo = 0;\n\t\t\tgoal->entitynum = 0;\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nBotGoForAir\n==================\n*/\nint BotGoForAir(bot_state_t *bs, int tfl, bot_goal_t *ltg, float range) {\n\tbot_goal_t goal;\n\n\t//if the bot needs air\n\tif (bs->lastair_time < FloatTime() - 6) {\n\t\t//\n#ifdef DEBUG\n\t\t//BotAI_Print(PRT_MESSAGE, \"going for air\\n\");\n#endif //DEBUG\n\t\t//if we can find an air goal\n\t\tif (BotGetAirGoal(bs, &goal)) {\n\t\t\ttrap_BotPushGoal(bs->gs, &goal);\n\t\t\treturn qtrue;\n\t\t}\n\t\telse {\n\t\t\t//get a nearby goal outside the water\n\t\t\twhile(trap_BotChooseNBGItem(bs->gs, bs->origin, bs->inventory, tfl, ltg, range)) {\n\t\t\t\ttrap_BotGetTopGoal(bs->gs, &goal);\n\t\t\t\t//if the goal is not in water\n\t\t\t\tif (!(trap_AAS_PointContents(goal.origin) & (CONTENTS_WATER|CONTENTS_SLIME|CONTENTS_LAVA))) {\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n\t\t\t\ttrap_BotPopGoal(bs->gs);\n\t\t\t}\n\t\t\ttrap_BotResetAvoidGoals(bs->gs);\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nBotNearbyGoal\n==================\n*/\nint BotNearbyGoal(bot_state_t *bs, int tfl, bot_goal_t *ltg, float range) {\n\tint ret;\n\n\t//check if the bot should go for air\n\tif (BotGoForAir(bs, tfl, ltg, range)) return qtrue;\n\t//if the bot is carrying the enemy flag\n\tif (BotCTFCarryingFlag(bs)) {\n\t\t//if the bot is just a few secs away from the base \n\t\tif (trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin,\n\t\t\t\tbs->teamgoal.areanum, TFL_DEFAULT) < 300) {\n\t\t\t//make the range really small\n\t\t\trange = 50;\n\t\t}\n\t}\n\t//\n\tret = trap_BotChooseNBGItem(bs->gs, bs->origin, bs->inventory, tfl, ltg, range);\n\t/*\n\tif (ret)\n\t{\n\t\tchar buf[128];\n\t\t//get the goal at the top of the stack\n\t\ttrap_BotGetTopGoal(bs->gs, &goal);\n\t\ttrap_BotGoalName(goal.number, buf, sizeof(buf));\n\t\tBotAI_Print(PRT_MESSAGE, \"%1.1f: new nearby goal %s\\n\", FloatTime(), buf);\n\t}\n    */\n\treturn ret;\n}\n\n/*\n==================\nBotReachedGoal\n==================\n*/\nint BotReachedGoal(bot_state_t *bs, bot_goal_t *goal) {\n\tif (goal->flags & GFL_ITEM) {\n\t\t//if touching the goal\n\t\tif (trap_BotTouchingGoal(bs->origin, goal)) {\n\t\t\tif (!(goal->flags & GFL_DROPPED)) {\n\t\t\t\ttrap_BotSetAvoidGoalTime(bs->gs, goal->number, -1);\n\t\t\t}\n\t\t\treturn qtrue;\n\t\t}\n\t\t//if the goal isn't there\n\t\tif (trap_BotItemGoalInVisButNotVisible(bs->entitynum, bs->eye, bs->viewangles, goal)) {\n\t\t\t/*\n\t\t\tfloat avoidtime;\n\t\t\tint t;\n\n\t\t\tavoidtime = trap_BotAvoidGoalTime(bs->gs, goal->number);\n\t\t\tif (avoidtime > 0) {\n\t\t\t\tt = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, goal->areanum, bs->tfl);\n\t\t\t\tif ((float) t * 0.009 < avoidtime)\n\t\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t\t*/\n\t\t\treturn qtrue;\n\t\t}\n\t\t//if in the goal area and below or above the goal and not swimming\n\t\tif (bs->areanum == goal->areanum) {\n\t\t\tif (bs->origin[0] > goal->origin[0] + goal->mins[0] && bs->origin[0] < goal->origin[0] + goal->maxs[0]) {\n\t\t\t\tif (bs->origin[1] > goal->origin[1] + goal->mins[1] && bs->origin[1] < goal->origin[1] + goal->maxs[1]) {\n\t\t\t\t\tif (!trap_AAS_Swimming(bs->origin)) {\n\t\t\t\t\t\treturn qtrue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\telse if (goal->flags & GFL_AIR) {\n\t\t//if touching the goal\n\t\tif (trap_BotTouchingGoal(bs->origin, goal)) return qtrue;\n\t\t//if the bot got air\n\t\tif (bs->lastair_time > FloatTime() - 1) return qtrue;\n\t}\n\telse {\n\t\t//if touching the goal\n\t\tif (trap_BotTouchingGoal(bs->origin, goal)) return qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nBotGetItemLongTermGoal\n==================\n*/\nint BotGetItemLongTermGoal(bot_state_t *bs, int tfl, bot_goal_t *goal) {\n\t//if the bot has no goal\n\tif (!trap_BotGetTopGoal(bs->gs, goal)) {\n\t\t//BotAI_Print(PRT_MESSAGE, \"no ltg on stack\\n\");\n\t\tbs->ltg_time = 0;\n\t}\n\t//if the bot touches the current goal\n\telse if (BotReachedGoal(bs, goal)) {\n\t\tBotChooseWeapon(bs);\n\t\tbs->ltg_time = 0;\n\t}\n\t//if it is time to find a new long term goal\n\tif (bs->ltg_time < FloatTime()) {\n\t\t//pop the current goal from the stack\n\t\ttrap_BotPopGoal(bs->gs);\n\t\t//BotAI_Print(PRT_MESSAGE, \"%s: choosing new ltg\\n\", ClientName(bs->client, netname, sizeof(netname)));\n\t\t//choose a new goal\n\t\t//BotAI_Print(PRT_MESSAGE, \"%6.1f client %d: BotChooseLTGItem\\n\", FloatTime(), bs->client);\n\t\tif (trap_BotChooseLTGItem(bs->gs, bs->origin, bs->inventory, tfl)) {\n\t\t\t/*\n\t\t\tchar buf[128];\n\t\t\t//get the goal at the top of the stack\n\t\t\ttrap_BotGetTopGoal(bs->gs, goal);\n\t\t\ttrap_BotGoalName(goal->number, buf, sizeof(buf));\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%1.1f: new long term goal %s\\n\", FloatTime(), buf);\n            */\n\t\t\tbs->ltg_time = FloatTime() + 20;\n\t\t}\n\t\telse {//the bot gets sorta stuck with all the avoid timings, shouldn't happen though\n\t\t\t//\n#ifdef DEBUG\n\t\t\tchar netname[128];\n\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%s: no valid ltg (probably stuck)\\n\", ClientName(bs->client, netname, sizeof(netname)));\n#endif\n\t\t\t//trap_BotDumpAvoidGoals(bs->gs);\n\t\t\t//reset the avoid goals and the avoid reach\n\t\t\ttrap_BotResetAvoidGoals(bs->gs);\n\t\t\ttrap_BotResetAvoidReach(bs->ms);\n\t\t}\n\t\t//get the goal at the top of the stack\n\t\treturn trap_BotGetTopGoal(bs->gs, goal);\n\t}\n\treturn qtrue;\n}\n\n/*\n==================\nBotGetLongTermGoal\n\nwe could also create a seperate AI node for every long term goal type\nhowever this saves us a lot of code\n==================\n*/\nint BotGetLongTermGoal(bot_state_t *bs, int tfl, int retreat, bot_goal_t *goal) {\n\tvec3_t target, dir, dir2;\n\tchar netname[MAX_NETNAME];\n\tchar buf[MAX_MESSAGE_SIZE];\n\tint areanum;\n\tfloat croucher;\n\taas_entityinfo_t entinfo, botinfo;\n\tbot_waypoint_t *wp;\n\n\tif (bs->ltgtype == LTG_TEAMHELP && !retreat) {\n\t\t//check for bot typing status message\n\t\tif (bs->teammessage_time && bs->teammessage_time < FloatTime()) {\n\t\t\tBotAI_BotInitialChat(bs, \"help_start\", EasyClientName(bs->teammate, netname, sizeof(netname)), NULL);\n\t\t\ttrap_BotEnterChat(bs->cs, bs->decisionmaker, CHAT_TELL);\n\t\t\tBotVoiceChatOnly(bs, bs->decisionmaker, VOICECHAT_YES);\n\t\t\ttrap_EA_Action(bs->client, ACTION_AFFIRMATIVE);\n\t\t\tbs->teammessage_time = 0;\n\t\t}\n\t\t//if trying to help the team mate for more than a minute\n\t\tif (bs->teamgoal_time < FloatTime())\n\t\t\tbs->ltgtype = 0;\n\t\t//if the team mate IS visible for quite some time\n\t\tif (bs->teammatevisible_time < FloatTime() - 10) bs->ltgtype = 0;\n\t\t//get entity information of the companion\n\t\tBotEntityInfo(bs->teammate, &entinfo);\n\t\t//if the team mate is visible\n\t\tif (BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, bs->teammate)) {\n\t\t\t//if close just stand still there\n\t\t\tVectorSubtract(entinfo.origin, bs->origin, dir);\n\t\t\tif (VectorLengthSquared(dir) < Square(100)) {\n\t\t\t\ttrap_BotResetAvoidReach(bs->ms);\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\t//last time the bot was NOT visible\n\t\t\tbs->teammatevisible_time = FloatTime();\n\t\t}\n\t\t//if the entity information is valid (entity in PVS)\n\t\tif (entinfo.valid) {\n\t\t\tareanum = BotPointAreaNum(entinfo.origin);\n\t\t\tif (areanum && trap_AAS_AreaReachability(areanum)) {\n\t\t\t\t//update team goal\n\t\t\t\tbs->teamgoal.entitynum = bs->teammate;\n\t\t\t\tbs->teamgoal.areanum = areanum;\n\t\t\t\tVectorCopy(entinfo.origin, bs->teamgoal.origin);\n\t\t\t\tVectorSet(bs->teamgoal.mins, -8, -8, -8);\n\t\t\t\tVectorSet(bs->teamgoal.maxs, 8, 8, 8);\n\t\t\t}\n\t\t}\n\t\tmemcpy(goal, &bs->teamgoal, sizeof(bot_goal_t));\n\t\treturn qtrue;\n\t}\n\t//if the bot accompanies someone\n\tif (bs->ltgtype == LTG_TEAMACCOMPANY && !retreat) {\n\t\t//check for bot typing status message\n\t\tif (bs->teammessage_time && bs->teammessage_time < FloatTime()) {\n\t\t\tBotAI_BotInitialChat(bs, \"accompany_start\", EasyClientName(bs->teammate, netname, sizeof(netname)), NULL);\n\t\t\ttrap_BotEnterChat(bs->cs, bs->decisionmaker, CHAT_TELL);\n\t\t\tBotVoiceChatOnly(bs, bs->decisionmaker, VOICECHAT_YES);\n\t\t\ttrap_EA_Action(bs->client, ACTION_AFFIRMATIVE);\n\t\t\tbs->teammessage_time = 0;\n\t\t}\n\t\t//if accompanying the companion for 3 minutes\n\t\tif (bs->teamgoal_time < FloatTime()) {\n\t\t\tBotAI_BotInitialChat(bs, \"accompany_stop\", EasyClientName(bs->teammate, netname, sizeof(netname)), NULL);\n\t\t\ttrap_BotEnterChat(bs->cs, bs->teammate, CHAT_TELL);\n\t\t\tbs->ltgtype = 0;\n\t\t}\n\t\t//get entity information of the companion\n\t\tBotEntityInfo(bs->teammate, &entinfo);\n\t\t//if the companion is visible\n\t\tif (BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, bs->teammate)) {\n\t\t\t//update visible time\n\t\t\tbs->teammatevisible_time = FloatTime();\n\t\t\tVectorSubtract(entinfo.origin, bs->origin, dir);\n\t\t\tif (VectorLengthSquared(dir) < Square(bs->formation_dist)) {\n\t\t\t\t//\n\t\t\t\t// if the client being followed bumps into this bot then\n\t\t\t\t// the bot should back up\n\t\t\t\tBotEntityInfo(bs->entitynum, &botinfo);\n\t\t\t\t// if the followed client is not standing ontop of the bot\n\t\t\t\tif (botinfo.origin[2] + botinfo.maxs[2] > entinfo.origin[2] + entinfo.mins[2]) {\n\t\t\t\t\t// if the bounding boxes touch each other\n\t\t\t\t\tif (botinfo.origin[0] + botinfo.maxs[0] > entinfo.origin[0] + entinfo.mins[0] - 4&&\n\t\t\t\t\t\tbotinfo.origin[0] + botinfo.mins[0] < entinfo.origin[0] + entinfo.maxs[0] + 4) {\n\t\t\t\t\t\tif (botinfo.origin[1] + botinfo.maxs[1] > entinfo.origin[1] + entinfo.mins[1] - 4 &&\n\t\t\t\t\t\t\tbotinfo.origin[1] + botinfo.mins[1] < entinfo.origin[1] + entinfo.maxs[1] + 4) {\n\t\t\t\t\t\t\tif (botinfo.origin[2] + botinfo.maxs[2] > entinfo.origin[2] + entinfo.mins[2] - 4 &&\n\t\t\t\t\t\t\t\tbotinfo.origin[2] + botinfo.mins[2] < entinfo.origin[2] + entinfo.maxs[2] + 4) {\n\t\t\t\t\t\t\t\t// if the followed client looks in the direction of this bot\n\t\t\t\t\t\t\t\tAngleVectors(entinfo.angles, dir, NULL, NULL);\n\t\t\t\t\t\t\t\tdir[2] = 0;\n\t\t\t\t\t\t\t\tVectorNormalize(dir);\n\t\t\t\t\t\t\t\t//VectorSubtract(entinfo.origin, entinfo.lastvisorigin, dir);\n\t\t\t\t\t\t\t\tVectorSubtract(bs->origin, entinfo.origin, dir2);\n\t\t\t\t\t\t\t\tVectorNormalize(dir2);\n\t\t\t\t\t\t\t\tif (DotProduct(dir, dir2) > 0.7) {\n\t\t\t\t\t\t\t\t\t// back up\n\t\t\t\t\t\t\t\t\tBotSetupForMovement(bs);\n\t\t\t\t\t\t\t\t\ttrap_BotMoveInDirection(bs->ms, dir2, 400, MOVE_WALK);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t//check if the bot wants to crouch\n\t\t\t\t//don't crouch if crouched less than 5 seconds ago\n\t\t\t\tif (bs->attackcrouch_time < FloatTime() - 5) {\n\t\t\t\t\tcroucher = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CROUCHER, 0, 1);\n\t\t\t\t\tif (random() < bs->thinktime * croucher) {\n\t\t\t\t\t\tbs->attackcrouch_time = FloatTime() + 5 + croucher * 15;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t//don't crouch when swimming\n\t\t\t\tif (trap_AAS_Swimming(bs->origin)) bs->attackcrouch_time = FloatTime() - 1;\n\t\t\t\t//if not arrived yet or arived some time ago\n\t\t\t\tif (bs->arrive_time < FloatTime() - 2) {\n\t\t\t\t\t//if not arrived yet\n\t\t\t\t\tif (!bs->arrive_time) {\n\t\t\t\t\t\ttrap_EA_Gesture(bs->client);\n\t\t\t\t\t\tBotAI_BotInitialChat(bs, \"accompany_arrive\", EasyClientName(bs->teammate, netname, sizeof(netname)), NULL);\n\t\t\t\t\t\ttrap_BotEnterChat(bs->cs, bs->teammate, CHAT_TELL);\n\t\t\t\t\t\tbs->arrive_time = FloatTime();\n\t\t\t\t\t}\n\t\t\t\t\t//if the bot wants to crouch\n\t\t\t\t\telse if (bs->attackcrouch_time > FloatTime()) {\n\t\t\t\t\t\ttrap_EA_Crouch(bs->client);\n\t\t\t\t\t}\n\t\t\t\t\t//else do some model taunts\n\t\t\t\t\telse if (random() < bs->thinktime * 0.05) {\n\t\t\t\t\t\t//do a gesture :)\n\t\t\t\t\t\ttrap_EA_Gesture(bs->client);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t//if just arrived look at the companion\n\t\t\t\tif (bs->arrive_time > FloatTime() - 2) {\n\t\t\t\t\tVectorSubtract(entinfo.origin, bs->origin, dir);\n\t\t\t\t\tvectoangles(dir, bs->ideal_viewangles);\n\t\t\t\t\tbs->ideal_viewangles[2] *= 0.5;\n\t\t\t\t}\n\t\t\t\t//else look strategically around for enemies\n\t\t\t\telse if (random() < bs->thinktime * 0.8) {\n\t\t\t\t\tBotRoamGoal(bs, target);\n\t\t\t\t\tVectorSubtract(target, bs->origin, dir);\n\t\t\t\t\tvectoangles(dir, bs->ideal_viewangles);\n\t\t\t\t\tbs->ideal_viewangles[2] *= 0.5;\n\t\t\t\t}\n\t\t\t\t//check if the bot wants to go for air\n\t\t\t\tif (BotGoForAir(bs, bs->tfl, &bs->teamgoal, 400)) {\n\t\t\t\t\ttrap_BotResetLastAvoidReach(bs->ms);\n\t\t\t\t\t//get the goal at the top of the stack\n\t\t\t\t\t//trap_BotGetTopGoal(bs->gs, &tmpgoal);\n\t\t\t\t\t//trap_BotGoalName(tmpgoal.number, buf, 144);\n\t\t\t\t\t//BotAI_Print(PRT_MESSAGE, \"new nearby goal %s\\n\", buf);\n\t\t\t\t\t//time the bot gets to pick up the nearby goal item\n\t\t\t\t\tbs->nbg_time = FloatTime() + 8;\n\t\t\t\t\tAIEnter_Seek_NBG(bs, \"BotLongTermGoal: go for air\");\n\t\t\t\t\treturn qfalse;\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\ttrap_BotResetAvoidReach(bs->ms);\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t}\n\t\t//if the entity information is valid (entity in PVS)\n\t\tif (entinfo.valid) {\n\t\t\tareanum = BotPointAreaNum(entinfo.origin);\n\t\t\tif (areanum && trap_AAS_AreaReachability(areanum)) {\n\t\t\t\t//update team goal\n\t\t\t\tbs->teamgoal.entitynum = bs->teammate;\n\t\t\t\tbs->teamgoal.areanum = areanum;\n\t\t\t\tVectorCopy(entinfo.origin, bs->teamgoal.origin);\n\t\t\t\tVectorSet(bs->teamgoal.mins, -8, -8, -8);\n\t\t\t\tVectorSet(bs->teamgoal.maxs, 8, 8, 8);\n\t\t\t}\n\t\t}\n\t\t//the goal the bot should go for\n\t\tmemcpy(goal, &bs->teamgoal, sizeof(bot_goal_t));\n\t\t//if the companion is NOT visible for too long\n\t\tif (bs->teammatevisible_time < FloatTime() - 60) {\n\t\t\tBotAI_BotInitialChat(bs, \"accompany_cannotfind\", EasyClientName(bs->teammate, netname, sizeof(netname)), NULL);\n\t\t\ttrap_BotEnterChat(bs->cs, bs->teammate, CHAT_TELL);\n\t\t\tbs->ltgtype = 0;\n\t\t\t// just to make sure the bot won't spam this message\n\t\t\tbs->teammatevisible_time = FloatTime();\n\t\t}\n\t\treturn qtrue;\n\t}\n\t//\n\tif (bs->ltgtype == LTG_DEFENDKEYAREA) {\n\t\tif (trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin,\n\t\t\t\tbs->teamgoal.areanum, TFL_DEFAULT) > bs->defendaway_range) {\n\t\t\tbs->defendaway_time = 0;\n\t\t}\n\t}\n\t//if defending a key area\n\tif (bs->ltgtype == LTG_DEFENDKEYAREA && !retreat &&\n\t\t\t\tbs->defendaway_time < FloatTime()) {\n\t\t//check for bot typing status message\n\t\tif (bs->teammessage_time && bs->teammessage_time < FloatTime()) {\n\t\t\ttrap_BotGoalName(bs->teamgoal.number, buf, sizeof(buf));\n\t\t\tBotAI_BotInitialChat(bs, \"defend_start\", buf, NULL);\n\t\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_TEAM);\n\t\t\tBotVoiceChatOnly(bs, -1, VOICECHAT_ONDEFENSE);\n\t\t\tbs->teammessage_time = 0;\n\t\t}\n\t\t//set the bot goal\n\t\tmemcpy(goal, &bs->teamgoal, sizeof(bot_goal_t));\n\t\t//stop after 2 minutes\n\t\tif (bs->teamgoal_time < FloatTime()) {\n\t\t\ttrap_BotGoalName(bs->teamgoal.number, buf, sizeof(buf));\n\t\t\tBotAI_BotInitialChat(bs, \"defend_stop\", buf, NULL);\n\t\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_TEAM);\n\t\t\tbs->ltgtype = 0;\n\t\t}\n\t\t//if very close... go away for some time\n\t\tVectorSubtract(goal->origin, bs->origin, dir);\n\t\tif (VectorLengthSquared(dir) < Square(70)) {\n\t\t\ttrap_BotResetAvoidReach(bs->ms);\n\t\t\tbs->defendaway_time = FloatTime() + 3 + 3 * random();\n\t\t\tif (BotHasPersistantPowerupAndWeapon(bs)) {\n\t\t\t\tbs->defendaway_range = 100;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tbs->defendaway_range = 350;\n\t\t\t}\n\t\t}\n\t\treturn qtrue;\n\t}\n\t//going to kill someone\n\tif (bs->ltgtype == LTG_KILL && !retreat) {\n\t\t//check for bot typing status message\n\t\tif (bs->teammessage_time && bs->teammessage_time < FloatTime()) {\n\t\t\tEasyClientName(bs->teamgoal.entitynum, buf, sizeof(buf));\n\t\t\tBotAI_BotInitialChat(bs, \"kill_start\", buf, NULL);\n\t\t\ttrap_BotEnterChat(bs->cs, bs->decisionmaker, CHAT_TELL);\n\t\t\tbs->teammessage_time = 0;\n\t\t}\n\t\t//\n\t\tif (bs->lastkilledplayer == bs->teamgoal.entitynum) {\n\t\t\tEasyClientName(bs->teamgoal.entitynum, buf, sizeof(buf));\n\t\t\tBotAI_BotInitialChat(bs, \"kill_done\", buf, NULL);\n\t\t\ttrap_BotEnterChat(bs->cs, bs->decisionmaker, CHAT_TELL);\n\t\t\tbs->lastkilledplayer = -1;\n\t\t\tbs->ltgtype = 0;\n\t\t}\n\t\t//\n\t\tif (bs->teamgoal_time < FloatTime()) {\n\t\t\tbs->ltgtype = 0;\n\t\t}\n\t\t//just roam around\n\t\treturn BotGetItemLongTermGoal(bs, tfl, goal);\n\t}\n\t//get an item\n\tif (bs->ltgtype == LTG_GETITEM && !retreat) {\n\t\t//check for bot typing status message\n\t\tif (bs->teammessage_time && bs->teammessage_time < FloatTime()) {\n\t\t\ttrap_BotGoalName(bs->teamgoal.number, buf, sizeof(buf));\n\t\t\tBotAI_BotInitialChat(bs, \"getitem_start\", buf, NULL);\n\t\t\ttrap_BotEnterChat(bs->cs, bs->decisionmaker, CHAT_TELL);\n\t\t\tBotVoiceChatOnly(bs, bs->decisionmaker, VOICECHAT_YES);\n\t\t\ttrap_EA_Action(bs->client, ACTION_AFFIRMATIVE);\n\t\t\tbs->teammessage_time = 0;\n\t\t}\n\t\t//set the bot goal\n\t\tmemcpy(goal, &bs->teamgoal, sizeof(bot_goal_t));\n\t\t//stop after some time\n\t\tif (bs->teamgoal_time < FloatTime()) {\n\t\t\tbs->ltgtype = 0;\n\t\t}\n\t\t//\n\t\tif (trap_BotItemGoalInVisButNotVisible(bs->entitynum, bs->eye, bs->viewangles, goal)) {\n\t\t\ttrap_BotGoalName(bs->teamgoal.number, buf, sizeof(buf));\n\t\t\tBotAI_BotInitialChat(bs, \"getitem_notthere\", buf, NULL);\n\t\t\ttrap_BotEnterChat(bs->cs, bs->decisionmaker, CHAT_TELL);\n\t\t\tbs->ltgtype = 0;\n\t\t}\n\t\telse if (BotReachedGoal(bs, goal)) {\n\t\t\ttrap_BotGoalName(bs->teamgoal.number, buf, sizeof(buf));\n\t\t\tBotAI_BotInitialChat(bs, \"getitem_gotit\", buf, NULL);\n\t\t\ttrap_BotEnterChat(bs->cs, bs->decisionmaker, CHAT_TELL);\n\t\t\tbs->ltgtype = 0;\n\t\t}\n\t\treturn qtrue;\n\t}\n\t//if camping somewhere\n\tif ((bs->ltgtype == LTG_CAMP || bs->ltgtype == LTG_CAMPORDER) && !retreat) {\n\t\t//check for bot typing status message\n\t\tif (bs->teammessage_time && bs->teammessage_time < FloatTime()) {\n\t\t\tif (bs->ltgtype == LTG_CAMPORDER) {\n\t\t\t\tBotAI_BotInitialChat(bs, \"camp_start\", EasyClientName(bs->teammate, netname, sizeof(netname)), NULL);\n\t\t\t\ttrap_BotEnterChat(bs->cs, bs->decisionmaker, CHAT_TELL);\n\t\t\t\tBotVoiceChatOnly(bs, bs->decisionmaker, VOICECHAT_YES);\n\t\t\t\ttrap_EA_Action(bs->client, ACTION_AFFIRMATIVE);\n\t\t\t}\n\t\t\tbs->teammessage_time = 0;\n\t\t}\n\t\t//set the bot goal\n\t\tmemcpy(goal, &bs->teamgoal, sizeof(bot_goal_t));\n\t\t//\n\t\tif (bs->teamgoal_time < FloatTime()) {\n\t\t\tif (bs->ltgtype == LTG_CAMPORDER) {\n\t\t\t\tBotAI_BotInitialChat(bs, \"camp_stop\", NULL);\n\t\t\t\ttrap_BotEnterChat(bs->cs, bs->decisionmaker, CHAT_TELL);\n\t\t\t}\n\t\t\tbs->ltgtype = 0;\n\t\t}\n\t\t//if really near the camp spot\n\t\tVectorSubtract(goal->origin, bs->origin, dir);\n\t\tif (VectorLengthSquared(dir) < Square(60))\n\t\t{\n\t\t\t//if not arrived yet\n\t\t\tif (!bs->arrive_time) {\n\t\t\t\tif (bs->ltgtype == LTG_CAMPORDER) {\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"camp_arrive\", EasyClientName(bs->teammate, netname, sizeof(netname)), NULL);\n\t\t\t\t\ttrap_BotEnterChat(bs->cs, bs->decisionmaker, CHAT_TELL);\n\t\t\t\t\tBotVoiceChatOnly(bs, bs->decisionmaker, VOICECHAT_INPOSITION);\n\t\t\t\t}\n\t\t\t\tbs->arrive_time = FloatTime();\n\t\t\t}\n\t\t\t//look strategically around for enemies\n\t\t\tif (random() < bs->thinktime * 0.8) {\n\t\t\t\tBotRoamGoal(bs, target);\n\t\t\t\tVectorSubtract(target, bs->origin, dir);\n\t\t\t\tvectoangles(dir, bs->ideal_viewangles);\n\t\t\t\tbs->ideal_viewangles[2] *= 0.5;\n\t\t\t}\n\t\t\t//check if the bot wants to crouch\n\t\t\t//don't crouch if crouched less than 5 seconds ago\n\t\t\tif (bs->attackcrouch_time < FloatTime() - 5) {\n\t\t\t\tcroucher = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CROUCHER, 0, 1);\n\t\t\t\tif (random() < bs->thinktime * croucher) {\n\t\t\t\t\tbs->attackcrouch_time = FloatTime() + 5 + croucher * 15;\n\t\t\t\t}\n\t\t\t}\n\t\t\t//if the bot wants to crouch\n\t\t\tif (bs->attackcrouch_time > FloatTime()) {\n\t\t\t\ttrap_EA_Crouch(bs->client);\n\t\t\t}\n\t\t\t//don't crouch when swimming\n\t\t\tif (trap_AAS_Swimming(bs->origin)) bs->attackcrouch_time = FloatTime() - 1;\n\t\t\t//make sure the bot is not gonna drown\n\t\t\tif (trap_PointContents(bs->eye,bs->entitynum) & (CONTENTS_WATER|CONTENTS_SLIME|CONTENTS_LAVA)) {\n\t\t\t\tif (bs->ltgtype == LTG_CAMPORDER) {\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"camp_stop\", NULL);\n\t\t\t\t\ttrap_BotEnterChat(bs->cs, bs->decisionmaker, CHAT_TELL);\n\t\t\t\t\t//\n\t\t\t\t\tif (bs->lastgoal_ltgtype == LTG_CAMPORDER) {\n\t\t\t\t\t\tbs->lastgoal_ltgtype = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbs->ltgtype = 0;\n\t\t\t}\n\t\t\t//\n\t\t\tif (bs->camp_range > 0) {\n\t\t\t\t//FIXME: move around a bit\n\t\t\t}\n\t\t\t//\n\t\t\ttrap_BotResetAvoidReach(bs->ms);\n\t\t\treturn qfalse;\n\t\t}\n\t\treturn qtrue;\n\t}\n\t//patrolling along several waypoints\n\tif (bs->ltgtype == LTG_PATROL && !retreat) {\n\t\t//check for bot typing status message\n\t\tif (bs->teammessage_time && bs->teammessage_time < FloatTime()) {\n\t\t\tstrcpy(buf, \"\");\n\t\t\tfor (wp = bs->patrolpoints; wp; wp = wp->next) {\n\t\t\t\tstrcat(buf, wp->name);\n\t\t\t\tif (wp->next) strcat(buf, \" to \");\n\t\t\t}\n\t\t\tBotAI_BotInitialChat(bs, \"patrol_start\", buf, NULL);\n\t\t\ttrap_BotEnterChat(bs->cs, bs->decisionmaker, CHAT_TELL);\n\t\t\tBotVoiceChatOnly(bs, bs->decisionmaker, VOICECHAT_YES);\n\t\t\ttrap_EA_Action(bs->client, ACTION_AFFIRMATIVE);\n\t\t\tbs->teammessage_time = 0;\n\t\t}\n\t\t//\n\t\tif (!bs->curpatrolpoint) {\n\t\t\tbs->ltgtype = 0;\n\t\t\treturn qfalse;\n\t\t}\n\t\t//if the bot touches the current goal\n\t\tif (trap_BotTouchingGoal(bs->origin, &bs->curpatrolpoint->goal)) {\n\t\t\tif (bs->patrolflags & PATROL_BACK) {\n\t\t\t\tif (bs->curpatrolpoint->prev) {\n\t\t\t\t\tbs->curpatrolpoint = bs->curpatrolpoint->prev;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tbs->curpatrolpoint = bs->curpatrolpoint->next;\n\t\t\t\t\tbs->patrolflags &= ~PATROL_BACK;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (bs->curpatrolpoint->next) {\n\t\t\t\t\tbs->curpatrolpoint = bs->curpatrolpoint->next;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tbs->curpatrolpoint = bs->curpatrolpoint->prev;\n\t\t\t\t\tbs->patrolflags |= PATROL_BACK;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t//stop after 5 minutes\n\t\tif (bs->teamgoal_time < FloatTime()) {\n\t\t\tBotAI_BotInitialChat(bs, \"patrol_stop\", NULL);\n\t\t\ttrap_BotEnterChat(bs->cs, bs->decisionmaker, CHAT_TELL);\n\t\t\tbs->ltgtype = 0;\n\t\t}\n\t\tif (!bs->curpatrolpoint) {\n\t\t\tbs->ltgtype = 0;\n\t\t\treturn qfalse;\n\t\t}\n\t\tmemcpy(goal, &bs->curpatrolpoint->goal, sizeof(bot_goal_t));\n\t\treturn qtrue;\n\t}\n#ifdef CTF\n\tif (gametype == GT_CTF) {\n\t\t//if going for enemy flag\n\t\tif (bs->ltgtype == LTG_GETFLAG) {\n\t\t\t//check for bot typing status message\n\t\t\tif (bs->teammessage_time && bs->teammessage_time < FloatTime()) {\n\t\t\t\tBotAI_BotInitialChat(bs, \"captureflag_start\", NULL);\n\t\t\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_TEAM);\n\t\t\t\tBotVoiceChatOnly(bs, -1, VOICECHAT_ONGETFLAG);\n\t\t\t\tbs->teammessage_time = 0;\n\t\t\t}\n\t\t\t//\n\t\t\tswitch(BotTeam(bs)) {\n\t\t\t\tcase TEAM_RED: memcpy(goal, &ctf_blueflag, sizeof(bot_goal_t)); break;\n\t\t\t\tcase TEAM_BLUE: memcpy(goal, &ctf_redflag, sizeof(bot_goal_t)); break;\n\t\t\t\tdefault: bs->ltgtype = 0; return qfalse;\n\t\t\t}\n\t\t\t//if touching the flag\n\t\t\tif (trap_BotTouchingGoal(bs->origin, goal)) {\n\t\t\t\t// make sure the bot knows the flag isn't there anymore\n\t\t\t\tswitch(BotTeam(bs)) {\n\t\t\t\t\tcase TEAM_RED: bs->blueflagstatus = 1; break;\n\t\t\t\t\tcase TEAM_BLUE: bs->redflagstatus = 1; break;\n\t\t\t\t}\n\t\t\t\tbs->ltgtype = 0;\n\t\t\t}\n\t\t\t//stop after 3 minutes\n\t\t\tif (bs->teamgoal_time < FloatTime()) {\n\t\t\t\tbs->ltgtype = 0;\n\t\t\t}\n\t\t\tBotAlternateRoute(bs, goal);\n\t\t\treturn qtrue;\n\t\t}\n\t\t//if rushing to the base\n\t\tif (bs->ltgtype == LTG_RUSHBASE && bs->rushbaseaway_time < FloatTime()) {\n\t\t\tswitch(BotTeam(bs)) {\n\t\t\t\tcase TEAM_RED: memcpy(goal, &ctf_redflag, sizeof(bot_goal_t)); break;\n\t\t\t\tcase TEAM_BLUE: memcpy(goal, &ctf_blueflag, sizeof(bot_goal_t)); break;\n\t\t\t\tdefault: bs->ltgtype = 0; return qfalse;\n\t\t\t}\n\t\t\t//if not carrying the flag anymore\n\t\t\tif (!BotCTFCarryingFlag(bs)) bs->ltgtype = 0;\n\t\t\t//quit rushing after 2 minutes\n\t\t\tif (bs->teamgoal_time < FloatTime()) bs->ltgtype = 0;\n\t\t\t//if touching the base flag the bot should loose the enemy flag\n\t\t\tif (trap_BotTouchingGoal(bs->origin, goal)) {\n\t\t\t\t//if the bot is still carrying the enemy flag then the\n\t\t\t\t//base flag is gone, now just walk near the base a bit\n\t\t\t\tif (BotCTFCarryingFlag(bs)) {\n\t\t\t\t\ttrap_BotResetAvoidReach(bs->ms);\n\t\t\t\t\tbs->rushbaseaway_time = FloatTime() + 5 + 10 * random();\n\t\t\t\t\t//FIXME: add chat to tell the others to get back the flag\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tbs->ltgtype = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tBotAlternateRoute(bs, goal);\n\t\t\treturn qtrue;\n\t\t}\n\t\t//returning flag\n\t\tif (bs->ltgtype == LTG_RETURNFLAG) {\n\t\t\t//check for bot typing status message\n\t\t\tif (bs->teammessage_time && bs->teammessage_time < FloatTime()) {\n\t\t\t\tBotAI_BotInitialChat(bs, \"returnflag_start\", NULL);\n\t\t\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_TEAM);\n\t\t\t\tBotVoiceChatOnly(bs, -1, VOICECHAT_ONRETURNFLAG);\n\t\t\t\tbs->teammessage_time = 0;\n\t\t\t}\n\t\t\t//\n\t\t\tswitch(BotTeam(bs)) {\n\t\t\t\tcase TEAM_RED: memcpy(goal, &ctf_blueflag, sizeof(bot_goal_t)); break;\n\t\t\t\tcase TEAM_BLUE: memcpy(goal, &ctf_redflag, sizeof(bot_goal_t)); break;\n\t\t\t\tdefault: bs->ltgtype = 0; return qfalse;\n\t\t\t}\n\t\t\t//if touching the flag\n\t\t\tif (trap_BotTouchingGoal(bs->origin, goal)) bs->ltgtype = 0;\n\t\t\t//stop after 3 minutes\n\t\t\tif (bs->teamgoal_time < FloatTime()) {\n\t\t\t\tbs->ltgtype = 0;\n\t\t\t}\n\t\t\tBotAlternateRoute(bs, goal);\n\t\t\treturn qtrue;\n\t\t}\n\t}\n#endif //CTF\n#ifdef MISSIONPACK\n\telse if (gametype == GT_1FCTF) {\n\t\tif (bs->ltgtype == LTG_GETFLAG) {\n\t\t\t//check for bot typing status message\n\t\t\tif (bs->teammessage_time && bs->teammessage_time < FloatTime()) {\n\t\t\t\tBotAI_BotInitialChat(bs, \"captureflag_start\", NULL);\n\t\t\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_TEAM);\n\t\t\t\tBotVoiceChatOnly(bs, -1, VOICECHAT_ONGETFLAG);\n\t\t\t\tbs->teammessage_time = 0;\n\t\t\t}\n\t\t\tmemcpy(goal, &ctf_neutralflag, sizeof(bot_goal_t));\n\t\t\t//if touching the flag\n\t\t\tif (trap_BotTouchingGoal(bs->origin, goal)) {\n\t\t\t\tbs->ltgtype = 0;\n\t\t\t}\n\t\t\t//stop after 3 minutes\n\t\t\tif (bs->teamgoal_time < FloatTime()) {\n\t\t\t\tbs->ltgtype = 0;\n\t\t\t}\n\t\t\treturn qtrue;\n\t\t}\n\t\t//if rushing to the base\n\t\tif (bs->ltgtype == LTG_RUSHBASE) {\n\t\t\tswitch(BotTeam(bs)) {\n\t\t\t\tcase TEAM_RED: memcpy(goal, &ctf_blueflag, sizeof(bot_goal_t)); break;\n\t\t\t\tcase TEAM_BLUE: memcpy(goal, &ctf_redflag, sizeof(bot_goal_t)); break;\n\t\t\t\tdefault: bs->ltgtype = 0; return qfalse;\n\t\t\t}\n\t\t\t//if not carrying the flag anymore\n\t\t\tif (!Bot1FCTFCarryingFlag(bs)) {\n\t\t\t\tbs->ltgtype = 0;\n\t\t\t}\n\t\t\t//quit rushing after 2 minutes\n\t\t\tif (bs->teamgoal_time < FloatTime()) {\n\t\t\t\tbs->ltgtype = 0;\n\t\t\t}\n\t\t\t//if touching the base flag the bot should loose the enemy flag\n\t\t\tif (trap_BotTouchingGoal(bs->origin, goal)) {\n\t\t\t\tbs->ltgtype = 0;\n\t\t\t}\n\t\t\tBotAlternateRoute(bs, goal);\n\t\t\treturn qtrue;\n\t\t}\n\t\t//attack the enemy base\n\t\tif (bs->ltgtype == LTG_ATTACKENEMYBASE &&\n\t\t\t\tbs->attackaway_time < FloatTime()) {\n\t\t\t//check for bot typing status message\n\t\t\tif (bs->teammessage_time && bs->teammessage_time < FloatTime()) {\n\t\t\t\tBotAI_BotInitialChat(bs, \"attackenemybase_start\", NULL);\n\t\t\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_TEAM);\n\t\t\t\tBotVoiceChatOnly(bs, -1, VOICECHAT_ONOFFENSE);\n\t\t\t\tbs->teammessage_time = 0;\n\t\t\t}\n\t\t\tswitch(BotTeam(bs)) {\n\t\t\t\tcase TEAM_RED: memcpy(goal, &ctf_blueflag, sizeof(bot_goal_t)); break;\n\t\t\t\tcase TEAM_BLUE: memcpy(goal, &ctf_redflag, sizeof(bot_goal_t)); break;\n\t\t\t\tdefault: bs->ltgtype = 0; return qfalse;\n\t\t\t}\n\t\t\t//quit rushing after 2 minutes\n\t\t\tif (bs->teamgoal_time < FloatTime()) {\n\t\t\t\tbs->ltgtype = 0;\n\t\t\t}\n\t\t\t//if touching the base flag the bot should loose the enemy flag\n\t\t\tif (trap_BotTouchingGoal(bs->origin, goal)) {\n\t\t\t\tbs->attackaway_time = FloatTime() + 2 + 5 * random();\n\t\t\t}\n\t\t\treturn qtrue;\n\t\t}\n\t\t//returning flag\n\t\tif (bs->ltgtype == LTG_RETURNFLAG) {\n\t\t\t//check for bot typing status message\n\t\t\tif (bs->teammessage_time && bs->teammessage_time < FloatTime()) {\n\t\t\t\tBotAI_BotInitialChat(bs, \"returnflag_start\", NULL);\n\t\t\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_TEAM);\n\t\t\t\tBotVoiceChatOnly(bs, -1, VOICECHAT_ONRETURNFLAG);\n\t\t\t\tbs->teammessage_time = 0;\n\t\t\t}\n\t\t\t//\n\t\t\tif (bs->teamgoal_time < FloatTime()) {\n\t\t\t\tbs->ltgtype = 0;\n\t\t\t}\n\t\t\t//just roam around\n\t\t\treturn BotGetItemLongTermGoal(bs, tfl, goal);\n\t\t}\n\t}\n\telse if (gametype == GT_OBELISK) {\n\t\tif (bs->ltgtype == LTG_ATTACKENEMYBASE &&\n\t\t\t\tbs->attackaway_time < FloatTime()) {\n\n\t\t\t//check for bot typing status message\n\t\t\tif (bs->teammessage_time && bs->teammessage_time < FloatTime()) {\n\t\t\t\tBotAI_BotInitialChat(bs, \"attackenemybase_start\", NULL);\n\t\t\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_TEAM);\n\t\t\t\tBotVoiceChatOnly(bs, -1, VOICECHAT_ONOFFENSE);\n\t\t\t\tbs->teammessage_time = 0;\n\t\t\t}\n\t\t\tswitch(BotTeam(bs)) {\n\t\t\t\tcase TEAM_RED: memcpy(goal, &blueobelisk, sizeof(bot_goal_t)); break;\n\t\t\t\tcase TEAM_BLUE: memcpy(goal, &redobelisk, sizeof(bot_goal_t)); break;\n\t\t\t\tdefault: bs->ltgtype = 0; return qfalse;\n\t\t\t}\n\t\t\t//if the bot no longer wants to attack the obelisk\n\t\t\tif (BotFeelingBad(bs) > 50) {\n\t\t\t\treturn BotGetItemLongTermGoal(bs, tfl, goal);\n\t\t\t}\n\t\t\t//if touching the obelisk\n\t\t\tif (trap_BotTouchingGoal(bs->origin, goal)) {\n\t\t\t\tbs->attackaway_time = FloatTime() + 3 + 5 * random();\n\t\t\t}\n\t\t\t// or very close to the obelisk\n\t\t\tVectorSubtract(bs->origin, goal->origin, dir);\n\t\t\tif (VectorLengthSquared(dir) < Square(60)) {\n\t\t\t\tbs->attackaway_time = FloatTime() + 3 + 5 * random();\n\t\t\t}\n\t\t\t//quit rushing after 2 minutes\n\t\t\tif (bs->teamgoal_time < FloatTime()) {\n\t\t\t\tbs->ltgtype = 0;\n\t\t\t}\n\t\t\tBotAlternateRoute(bs, goal);\n\t\t\t//just move towards the obelisk\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\telse if (gametype == GT_HARVESTER) {\n\t\t//if rushing to the base\n\t\tif (bs->ltgtype == LTG_RUSHBASE) {\n\t\t\tswitch(BotTeam(bs)) {\n\t\t\t\tcase TEAM_RED: memcpy(goal, &blueobelisk, sizeof(bot_goal_t)); break;\n\t\t\t\tcase TEAM_BLUE: memcpy(goal, &redobelisk, sizeof(bot_goal_t)); break;\n\t\t\t\tdefault: BotGoHarvest(bs); return qfalse;\n\t\t\t}\n\t\t\t//if not carrying any cubes\n\t\t\tif (!BotHarvesterCarryingCubes(bs)) {\n\t\t\t\tBotGoHarvest(bs);\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\t//quit rushing after 2 minutes\n\t\t\tif (bs->teamgoal_time < FloatTime()) {\n\t\t\t\tBotGoHarvest(bs);\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\t//if touching the base flag the bot should loose the enemy flag\n\t\t\tif (trap_BotTouchingGoal(bs->origin, goal)) {\n\t\t\t\tBotGoHarvest(bs);\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tBotAlternateRoute(bs, goal);\n\t\t\treturn qtrue;\n\t\t}\n\t\t//attack the enemy base\n\t\tif (bs->ltgtype == LTG_ATTACKENEMYBASE &&\n\t\t\t\tbs->attackaway_time < FloatTime()) {\n\t\t\t//check for bot typing status message\n\t\t\tif (bs->teammessage_time && bs->teammessage_time < FloatTime()) {\n\t\t\t\tBotAI_BotInitialChat(bs, \"attackenemybase_start\", NULL);\n\t\t\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_TEAM);\n\t\t\t\tBotVoiceChatOnly(bs, -1, VOICECHAT_ONOFFENSE);\n\t\t\t\tbs->teammessage_time = 0;\n\t\t\t}\n\t\t\tswitch(BotTeam(bs)) {\n\t\t\t\tcase TEAM_RED: memcpy(goal, &blueobelisk, sizeof(bot_goal_t)); break;\n\t\t\t\tcase TEAM_BLUE: memcpy(goal, &redobelisk, sizeof(bot_goal_t)); break;\n\t\t\t\tdefault: bs->ltgtype = 0; return qfalse;\n\t\t\t}\n\t\t\t//quit rushing after 2 minutes\n\t\t\tif (bs->teamgoal_time < FloatTime()) {\n\t\t\t\tbs->ltgtype = 0;\n\t\t\t}\n\t\t\t//if touching the base flag the bot should loose the enemy flag\n\t\t\tif (trap_BotTouchingGoal(bs->origin, goal)) {\n\t\t\t\tbs->attackaway_time = FloatTime() + 2 + 5 * random();\n\t\t\t}\n\t\t\treturn qtrue;\n\t\t}\n\t\t//harvest cubes\n\t\tif (bs->ltgtype == LTG_HARVEST &&\n\t\t\tbs->harvestaway_time < FloatTime()) {\n\t\t\t//check for bot typing status message\n\t\t\tif (bs->teammessage_time && bs->teammessage_time < FloatTime()) {\n\t\t\t\tBotAI_BotInitialChat(bs, \"harvest_start\", NULL);\n\t\t\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_TEAM);\n\t\t\t\tBotVoiceChatOnly(bs, -1, VOICECHAT_ONOFFENSE);\n\t\t\t\tbs->teammessage_time = 0;\n\t\t\t}\n\t\t\tmemcpy(goal, &neutralobelisk, sizeof(bot_goal_t));\n\t\t\t//\n\t\t\tif (bs->teamgoal_time < FloatTime()) {\n\t\t\t\tbs->ltgtype = 0;\n\t\t\t}\n\t\t\t//\n\t\t\tif (trap_BotTouchingGoal(bs->origin, goal)) {\n\t\t\t\tbs->harvestaway_time = FloatTime() + 4 + 3 * random();\n\t\t\t}\n\t\t\treturn qtrue;\n\t\t}\n\t}\n#endif\n\t//normal goal stuff\n\treturn BotGetItemLongTermGoal(bs, tfl, goal);\n}\n\n/*\n==================\nBotLongTermGoal\n==================\n*/\nint BotLongTermGoal(bot_state_t *bs, int tfl, int retreat, bot_goal_t *goal) {\n\taas_entityinfo_t entinfo;\n\tchar teammate[MAX_MESSAGE_SIZE];\n\tfloat squaredist;\n\tint areanum;\n\tvec3_t dir;\n\n\t//FIXME: also have air long term goals?\n\t//\n\t//if the bot is leading someone and not retreating\n\tif (bs->lead_time > 0 && !retreat) {\n\t\tif (bs->lead_time < FloatTime()) {\n\t\t\tBotAI_BotInitialChat(bs, \"lead_stop\", EasyClientName(bs->lead_teammate, teammate, sizeof(teammate)), NULL);\n\t\t\ttrap_BotEnterChat(bs->cs, bs->teammate, CHAT_TELL);\n\t\t\tbs->lead_time = 0;\n\t\t\treturn BotGetLongTermGoal(bs, tfl, retreat, goal);\n\t\t}\n\t\t//\n\t\tif (bs->leadmessage_time < 0 && -bs->leadmessage_time < FloatTime()) {\n\t\t\tBotAI_BotInitialChat(bs, \"followme\", EasyClientName(bs->lead_teammate, teammate, sizeof(teammate)), NULL);\n\t\t\ttrap_BotEnterChat(bs->cs, bs->teammate, CHAT_TELL);\n\t\t\tbs->leadmessage_time = FloatTime();\n\t\t}\n\t\t//get entity information of the companion\n\t\tBotEntityInfo(bs->lead_teammate, &entinfo);\n\t\t//\n\t\tif (entinfo.valid) {\n\t\t\tareanum = BotPointAreaNum(entinfo.origin);\n\t\t\tif (areanum && trap_AAS_AreaReachability(areanum)) {\n\t\t\t\t//update team goal\n\t\t\t\tbs->lead_teamgoal.entitynum = bs->lead_teammate;\n\t\t\t\tbs->lead_teamgoal.areanum = areanum;\n\t\t\t\tVectorCopy(entinfo.origin, bs->lead_teamgoal.origin);\n\t\t\t\tVectorSet(bs->lead_teamgoal.mins, -8, -8, -8);\n\t\t\t\tVectorSet(bs->lead_teamgoal.maxs, 8, 8, 8);\n\t\t\t}\n\t\t}\n\t\t//if the team mate is visible\n\t\tif (BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, bs->lead_teammate)) {\n\t\t\tbs->leadvisible_time = FloatTime();\n\t\t}\n\t\t//if the team mate is not visible for 1 seconds\n\t\tif (bs->leadvisible_time < FloatTime() - 1) {\n\t\t\tbs->leadbackup_time = FloatTime() + 2;\n\t\t}\n\t\t//distance towards the team mate\n\t\tVectorSubtract(bs->origin, bs->lead_teamgoal.origin, dir);\n\t\tsquaredist = VectorLengthSquared(dir);\n\t\t//if backing up towards the team mate\n\t\tif (bs->leadbackup_time > FloatTime()) {\n\t\t\tif (bs->leadmessage_time < FloatTime() - 20) {\n\t\t\t\tBotAI_BotInitialChat(bs, \"followme\", EasyClientName(bs->lead_teammate, teammate, sizeof(teammate)), NULL);\n\t\t\t\ttrap_BotEnterChat(bs->cs, bs->teammate, CHAT_TELL);\n\t\t\t\tbs->leadmessage_time = FloatTime();\n\t\t\t}\n\t\t\t//if very close to the team mate\n\t\t\tif (squaredist < Square(100)) {\n\t\t\t\tbs->leadbackup_time = 0;\n\t\t\t}\n\t\t\t//the bot should go back to the team mate\n\t\t\tmemcpy(goal, &bs->lead_teamgoal, sizeof(bot_goal_t));\n\t\t\treturn qtrue;\n\t\t}\n\t\telse {\n\t\t\t//if quite distant from the team mate\n\t\t\tif (squaredist > Square(500)) {\n\t\t\t\tif (bs->leadmessage_time < FloatTime() - 20) {\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"followme\", EasyClientName(bs->lead_teammate, teammate, sizeof(teammate)), NULL);\n\t\t\t\t\ttrap_BotEnterChat(bs->cs, bs->teammate, CHAT_TELL);\n\t\t\t\t\tbs->leadmessage_time = FloatTime();\n\t\t\t\t}\n\t\t\t\t//look at the team mate\n\t\t\t\tVectorSubtract(entinfo.origin, bs->origin, dir);\n\t\t\t\tvectoangles(dir, bs->ideal_viewangles);\n\t\t\t\tbs->ideal_viewangles[2] *= 0.5;\n\t\t\t\t//just wait for the team mate\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t}\n\t}\n\treturn BotGetLongTermGoal(bs, tfl, retreat, goal);\n}\n\n/*\n==================\nAIEnter_Intermission\n==================\n*/\nvoid AIEnter_Intermission(bot_state_t *bs, char *s) {\n\tBotRecordNodeSwitch(bs, \"intermission\", \"\", s);\n\t//reset the bot state\n\tBotResetState(bs);\n\t//check for end level chat\n\tif (BotChat_EndLevel(bs)) {\n\t\ttrap_BotEnterChat(bs->cs, 0, bs->chatto);\n\t}\n\tbs->ainode = AINode_Intermission;\n}\n\n/*\n==================\nAINode_Intermission\n==================\n*/\nint AINode_Intermission(bot_state_t *bs) {\n\t//if the intermission ended\n\tif (!BotIntermission(bs)) {\n\t\tif (BotChat_StartLevel(bs)) {\n\t\t\tbs->stand_time = FloatTime() + BotChatTime(bs);\n\t\t}\n\t\telse {\n\t\t\tbs->stand_time = FloatTime() + 2;\n\t\t}\n\t\tAIEnter_Stand(bs, \"intermission: chat\");\n\t}\n\treturn qtrue;\n}\n\n/*\n==================\nAIEnter_Observer\n==================\n*/\nvoid AIEnter_Observer(bot_state_t *bs, char *s) {\n\tBotRecordNodeSwitch(bs, \"observer\", \"\", s);\n\t//reset the bot state\n\tBotResetState(bs);\n\tbs->ainode = AINode_Observer;\n}\n\n/*\n==================\nAINode_Observer\n==================\n*/\nint AINode_Observer(bot_state_t *bs) {\n\t//if the bot left observer mode\n\tif (!BotIsObserver(bs)) {\n\t\tAIEnter_Stand(bs, \"observer: left observer\");\n\t}\n\treturn qtrue;\n}\n\n/*\n==================\nAIEnter_Stand\n==================\n*/\nvoid AIEnter_Stand(bot_state_t *bs, char *s) {\n\tBotRecordNodeSwitch(bs, \"stand\", \"\", s);\n\tbs->standfindenemy_time = FloatTime() + 1;\n\tbs->ainode = AINode_Stand;\n}\n\n/*\n==================\nAINode_Stand\n==================\n*/\nint AINode_Stand(bot_state_t *bs) {\n\n\t//if the bot's health decreased\n\tif (bs->lastframe_health > bs->inventory[INVENTORY_HEALTH]) {\n\t\tif (BotChat_HitTalking(bs)) {\n\t\t\tbs->standfindenemy_time = FloatTime() + BotChatTime(bs) + 0.1;\n\t\t\tbs->stand_time = FloatTime() + BotChatTime(bs) + 0.1;\n\t\t}\n\t}\n\tif (bs->standfindenemy_time < FloatTime()) {\n\t\tif (BotFindEnemy(bs, -1)) {\n\t\t\tAIEnter_Battle_Fight(bs, \"stand: found enemy\");\n\t\t\treturn qfalse;\n\t\t}\n\t\tbs->standfindenemy_time = FloatTime() + 1;\n\t}\n\t// put up chat icon\n\ttrap_EA_Talk(bs->client);\n\t// when done standing\n\tif (bs->stand_time < FloatTime()) {\n\t\ttrap_BotEnterChat(bs->cs, 0, bs->chatto);\n\t\tAIEnter_Seek_LTG(bs, \"stand: time out\");\n\t\treturn qfalse;\n\t}\n\t//\n\treturn qtrue;\n}\n\n/*\n==================\nAIEnter_Respawn\n==================\n*/\nvoid AIEnter_Respawn(bot_state_t *bs, char *s) {\n\tBotRecordNodeSwitch(bs, \"respawn\", \"\", s);\n\t//reset some states\n\ttrap_BotResetMoveState(bs->ms);\n\ttrap_BotResetGoalState(bs->gs);\n\ttrap_BotResetAvoidGoals(bs->gs);\n\ttrap_BotResetAvoidReach(bs->ms);\n\t//if the bot wants to chat\n\tif (BotChat_Death(bs)) {\n\t\tbs->respawn_time = FloatTime() + BotChatTime(bs);\n\t\tbs->respawnchat_time = FloatTime();\n\t}\n\telse {\n\t\tbs->respawn_time = FloatTime() + 1 + random();\n\t\tbs->respawnchat_time = 0;\n\t}\n\t//set respawn state\n\tbs->respawn_wait = qfalse;\n\tbs->ainode = AINode_Respawn;\n}\n\n/*\n==================\nAINode_Respawn\n==================\n*/\nint AINode_Respawn(bot_state_t *bs) {\n\t// if waiting for the actual respawn\n\tif (bs->respawn_wait) {\n\t\tif (!BotIsDead(bs)) {\n\t\t\tAIEnter_Seek_LTG(bs, \"respawn: respawned\");\n\t\t}\n\t\telse {\n\t\t\ttrap_EA_Respawn(bs->client);\n\t\t}\n\t}\n\telse if (bs->respawn_time < FloatTime()) {\n\t\t// wait until respawned\n\t\tbs->respawn_wait = qtrue;\n\t\t// elementary action respawn\n\t\ttrap_EA_Respawn(bs->client);\n\t\t//\n\t\tif (bs->respawnchat_time) {\n\t\t\ttrap_BotEnterChat(bs->cs, 0, bs->chatto);\n\t\t\tbs->enemy = -1;\n\t\t}\n\t}\n\tif (bs->respawnchat_time && bs->respawnchat_time < FloatTime() - 0.5) {\n\t\ttrap_EA_Talk(bs->client);\n\t}\n\t//\n\treturn qtrue;\n}\n\n/*\n==================\nBotSelectActivateWeapon\n==================\n*/\nint BotSelectActivateWeapon(bot_state_t *bs) {\n\t//\n\tif (bs->inventory[INVENTORY_MACHINEGUN] > 0 && bs->inventory[INVENTORY_BULLETS] > 0)\n\t\treturn WEAPONINDEX_MACHINEGUN;\n\telse if (bs->inventory[INVENTORY_SHOTGUN] > 0 && bs->inventory[INVENTORY_SHELLS] > 0)\n\t\treturn WEAPONINDEX_SHOTGUN;\n\telse if (bs->inventory[INVENTORY_PLASMAGUN] > 0 && bs->inventory[INVENTORY_CELLS] > 0)\n\t\treturn WEAPONINDEX_PLASMAGUN;\n\telse if (bs->inventory[INVENTORY_LIGHTNING] > 0 && bs->inventory[INVENTORY_LIGHTNINGAMMO] > 0)\n\t\treturn WEAPONINDEX_LIGHTNING;\n#ifdef MISSIONPACK\n\telse if (bs->inventory[INVENTORY_CHAINGUN] > 0 && bs->inventory[INVENTORY_BELT] > 0)\n\t\treturn WEAPONINDEX_CHAINGUN;\n\telse if (bs->inventory[INVENTORY_NAILGUN] > 0 && bs->inventory[INVENTORY_NAILS] > 0)\n\t\treturn WEAPONINDEX_NAILGUN;\n#endif\n\telse if (bs->inventory[INVENTORY_RAILGUN] > 0 && bs->inventory[INVENTORY_SLUGS] > 0)\n\t\treturn WEAPONINDEX_RAILGUN;\n\telse if (bs->inventory[INVENTORY_ROCKETLAUNCHER] > 0 && bs->inventory[INVENTORY_ROCKETS] > 0)\n\t\treturn WEAPONINDEX_ROCKET_LAUNCHER;\n\telse if (bs->inventory[INVENTORY_BFG10K] > 0 && bs->inventory[INVENTORY_BFGAMMO] > 0)\n\t\treturn WEAPONINDEX_BFG;\n\telse {\n\t\treturn -1;\n\t}\n}\n\n/*\n==================\nBotClearPath\n\n try to deactivate obstacles like proximity mines on the bot's path\n==================\n*/\nvoid BotClearPath(bot_state_t *bs, bot_moveresult_t *moveresult) {\n\tint i, bestmine;\n\tfloat dist, bestdist;\n\tvec3_t target, dir;\n\tbsp_trace_t bsptrace;\n\tentityState_t state;\n\n\t// if there is a dead body wearing kamikze nearby\n\tif (bs->kamikazebody) {\n\t\t// if the bot's view angles and weapon are not used for movement\n\t\tif ( !(moveresult->flags & (MOVERESULT_MOVEMENTVIEW | MOVERESULT_MOVEMENTWEAPON)) ) {\n\t\t\t//\n\t\t\tBotAI_GetEntityState(bs->kamikazebody, &state);\n\t\t\tVectorCopy(state.pos.trBase, target);\n\t\t\ttarget[2] += 8;\n\t\t\tVectorSubtract(target, bs->eye, dir);\n\t\t\tvectoangles(dir, moveresult->ideal_viewangles);\n\t\t\t//\n\t\t\tmoveresult->weapon = BotSelectActivateWeapon(bs);\n\t\t\tif (moveresult->weapon == -1) {\n\t\t\t\t// FIXME: run away!\n\t\t\t\tmoveresult->weapon = 0;\n\t\t\t}\n\t\t\tif (moveresult->weapon) {\n\t\t\t\t//\n\t\t\t\tmoveresult->flags |= MOVERESULT_MOVEMENTWEAPON | MOVERESULT_MOVEMENTVIEW;\n\t\t\t\t// if holding the right weapon\n\t\t\t\tif (bs->cur_ps.weapon == moveresult->weapon) {\n\t\t\t\t\t// if the bot is pretty close with it's aim\n\t\t\t\t\tif (InFieldOfVision(bs->viewangles, 20, moveresult->ideal_viewangles)) {\n\t\t\t\t\t\t//\n\t\t\t\t\t\tBotAI_Trace(&bsptrace, bs->eye, NULL, NULL, target, bs->entitynum, MASK_SHOT);\n\t\t\t\t\t\t// if the mine is visible from the current position\n\t\t\t\t\t\tif (bsptrace.fraction >= 1.0 || bsptrace.ent == state.number) {\n\t\t\t\t\t\t\t// shoot at the mine\n\t\t\t\t\t\t\ttrap_EA_Attack(bs->client);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif (moveresult->flags & MOVERESULT_BLOCKEDBYAVOIDSPOT) {\n\t\tbs->blockedbyavoidspot_time = FloatTime() + 5;\n\t}\n\t// if blocked by an avoid spot and the view angles and weapon are used for movement\n\tif (bs->blockedbyavoidspot_time > FloatTime() &&\n\t\t!(moveresult->flags & (MOVERESULT_MOVEMENTVIEW | MOVERESULT_MOVEMENTWEAPON)) ) {\n\t\tbestdist = 300;\n\t\tbestmine = -1;\n\t\tfor (i = 0; i < bs->numproxmines; i++) {\n\t\t\tBotAI_GetEntityState(bs->proxmines[i], &state);\n\t\t\tVectorSubtract(state.pos.trBase, bs->origin, dir);\n\t\t\tdist = VectorLength(dir);\n\t\t\tif (dist < bestdist) {\n\t\t\t\tbestdist = dist;\n\t\t\t\tbestmine = i;\n\t\t\t}\n\t\t}\n\t\tif (bestmine != -1) {\n\t\t\t//\n\t\t\t// state->generic1 == TEAM_RED || state->generic1 == TEAM_BLUE\n\t\t\t//\n\t\t\t// deactivate prox mines in the bot's path by shooting\n\t\t\t// rockets or plasma cells etc. at them\n\t\t\tBotAI_GetEntityState(bs->proxmines[bestmine], &state);\n\t\t\tVectorCopy(state.pos.trBase, target);\n\t\t\ttarget[2] += 2;\n\t\t\tVectorSubtract(target, bs->eye, dir);\n\t\t\tvectoangles(dir, moveresult->ideal_viewangles);\n\t\t\t// if the bot has a weapon that does splash damage\n\t\t\tif (bs->inventory[INVENTORY_PLASMAGUN] > 0 && bs->inventory[INVENTORY_CELLS] > 0)\n\t\t\t\tmoveresult->weapon = WEAPONINDEX_PLASMAGUN;\n\t\t\telse if (bs->inventory[INVENTORY_ROCKETLAUNCHER] > 0 && bs->inventory[INVENTORY_ROCKETS] > 0)\n\t\t\t\tmoveresult->weapon = WEAPONINDEX_ROCKET_LAUNCHER;\n\t\t\telse if (bs->inventory[INVENTORY_BFG10K] > 0 && bs->inventory[INVENTORY_BFGAMMO] > 0)\n\t\t\t\tmoveresult->weapon = WEAPONINDEX_BFG;\n\t\t\telse {\n\t\t\t\tmoveresult->weapon = 0;\n\t\t\t}\n\t\t\tif (moveresult->weapon) {\n\t\t\t\t//\n\t\t\t\tmoveresult->flags |= MOVERESULT_MOVEMENTWEAPON | MOVERESULT_MOVEMENTVIEW;\n\t\t\t\t// if holding the right weapon\n\t\t\t\tif (bs->cur_ps.weapon == moveresult->weapon) {\n\t\t\t\t\t// if the bot is pretty close with it's aim\n\t\t\t\t\tif (InFieldOfVision(bs->viewangles, 20, moveresult->ideal_viewangles)) {\n\t\t\t\t\t\t//\n\t\t\t\t\t\tBotAI_Trace(&bsptrace, bs->eye, NULL, NULL, target, bs->entitynum, MASK_SHOT);\n\t\t\t\t\t\t// if the mine is visible from the current position\n\t\t\t\t\t\tif (bsptrace.fraction >= 1.0 || bsptrace.ent == state.number) {\n\t\t\t\t\t\t\t// shoot at the mine\n\t\t\t\t\t\t\ttrap_EA_Attack(bs->client);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n==================\nAIEnter_Seek_ActivateEntity\n==================\n*/\nvoid AIEnter_Seek_ActivateEntity(bot_state_t *bs, char *s) {\n\tBotRecordNodeSwitch(bs, \"activate entity\", \"\", s);\n\tbs->ainode = AINode_Seek_ActivateEntity;\n}\n\n/*\n==================\nAINode_Seek_Activate_Entity\n==================\n*/\nint AINode_Seek_ActivateEntity(bot_state_t *bs) {\n\tbot_goal_t *goal;\n\tvec3_t target, dir, ideal_viewangles;\n\tbot_moveresult_t moveresult;\n\tint targetvisible;\n\tbsp_trace_t bsptrace;\n\taas_entityinfo_t entinfo;\n\n\tif (BotIsObserver(bs)) {\n\t\tBotClearActivateGoalStack(bs);\n\t\tAIEnter_Observer(bs, \"active entity: observer\");\n\t\treturn qfalse;\n\t}\n\t//if in the intermission\n\tif (BotIntermission(bs)) {\n\t\tBotClearActivateGoalStack(bs);\n\t\tAIEnter_Intermission(bs, \"activate entity: intermission\");\n\t\treturn qfalse;\n\t}\n\t//respawn if dead\n\tif (BotIsDead(bs)) {\n\t\tBotClearActivateGoalStack(bs);\n\t\tAIEnter_Respawn(bs, \"activate entity: bot dead\");\n\t\treturn qfalse;\n\t}\n\t//\n\tbs->tfl = TFL_DEFAULT;\n\tif (bot_grapple.integer) bs->tfl |= TFL_GRAPPLEHOOK;\n\t// if in lava or slime the bot should be able to get out\n\tif (BotInLavaOrSlime(bs)) bs->tfl |= TFL_LAVA|TFL_SLIME;\n\t// map specific code\n\tBotMapScripts(bs);\n\t// no enemy\n\tbs->enemy = -1;\n\t// if the bot has no activate goal\n\tif (!bs->activatestack) {\n\t\tBotClearActivateGoalStack(bs);\n\t\tAIEnter_Seek_NBG(bs, \"activate entity: no goal\");\n\t\treturn qfalse;\n\t}\n\t//\n\tgoal = &bs->activatestack->goal;\n\t// initialize target being visible to false\n\ttargetvisible = qfalse;\n\t// if the bot has to shoot at a target to activate something\n\tif (bs->activatestack->shoot) {\n\t\t//\n\t\tBotAI_Trace(&bsptrace, bs->eye, NULL, NULL, bs->activatestack->target, bs->entitynum, MASK_SHOT);\n\t\t// if the shootable entity is visible from the current position\n\t\tif (bsptrace.fraction >= 1.0 || bsptrace.ent == goal->entitynum) {\n\t\t\ttargetvisible = qtrue;\n\t\t\t// if holding the right weapon\n\t\t\tif (bs->cur_ps.weapon == bs->activatestack->weapon) {\n\t\t\t\tVectorSubtract(bs->activatestack->target, bs->eye, dir);\n\t\t\t\tvectoangles(dir, ideal_viewangles);\n\t\t\t\t// if the bot is pretty close with it's aim\n\t\t\t\tif (InFieldOfVision(bs->viewangles, 20, ideal_viewangles)) {\n\t\t\t\t\ttrap_EA_Attack(bs->client);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t// if the shoot target is visible\n\tif (targetvisible) {\n\t\t// get the entity info of the entity the bot is shooting at\n\t\tBotEntityInfo(goal->entitynum, &entinfo);\n\t\t// if the entity the bot shoots at moved\n\t\tif (!VectorCompare(bs->activatestack->origin, entinfo.origin)) {\n#ifdef DEBUG\n\t\t\tBotAI_Print(PRT_MESSAGE, \"hit shootable button or trigger\\n\");\n#endif //DEBUG\n\t\t\tbs->activatestack->time = 0;\n\t\t}\n\t\t// if the activate goal has been activated or the bot takes too long\n\t\tif (bs->activatestack->time < FloatTime()) {\n\t\t\tBotPopFromActivateGoalStack(bs);\n\t\t\t// if there are more activate goals on the stack\n\t\t\tif (bs->activatestack) {\n\t\t\t\tbs->activatestack->time = FloatTime() + 10;\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tAIEnter_Seek_NBG(bs, \"activate entity: time out\");\n\t\t\treturn qfalse;\n\t\t}\n\t\tmemset(&moveresult, 0, sizeof(bot_moveresult_t));\n\t}\n\telse {\n\t\t// if the bot has no goal\n\t\tif (!goal) {\n\t\t\tbs->activatestack->time = 0;\n\t\t}\n\t\t// if the bot does not have a shoot goal\n\t\telse if (!bs->activatestack->shoot) {\n\t\t\t//if the bot touches the current goal\n\t\t\tif (trap_BotTouchingGoal(bs->origin, goal)) {\n#ifdef DEBUG\n\t\t\t\tBotAI_Print(PRT_MESSAGE, \"touched button or trigger\\n\");\n#endif //DEBUG\n\t\t\t\tbs->activatestack->time = 0;\n\t\t\t}\n\t\t}\n\t\t// if the activate goal has been activated or the bot takes too long\n\t\tif (bs->activatestack->time < FloatTime()) {\n\t\t\tBotPopFromActivateGoalStack(bs);\n\t\t\t// if there are more activate goals on the stack\n\t\t\tif (bs->activatestack) {\n\t\t\t\tbs->activatestack->time = FloatTime() + 10;\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tAIEnter_Seek_NBG(bs, \"activate entity: activated\");\n\t\t\treturn qfalse;\n\t\t}\n\t\t//predict obstacles\n\t\tif (BotAIPredictObstacles(bs, goal))\n\t\t\treturn qfalse;\n\t\t//initialize the movement state\n\t\tBotSetupForMovement(bs);\n\t\t//move towards the goal\n\t\ttrap_BotMoveToGoal(&moveresult, bs->ms, goal, bs->tfl);\n\t\t//if the movement failed\n\t\tif (moveresult.failure) {\n\t\t\t//reset the avoid reach, otherwise bot is stuck in current area\n\t\t\ttrap_BotResetAvoidReach(bs->ms);\n\t\t\t//\n\t\t\tbs->activatestack->time = 0;\n\t\t}\n\t\t//check if the bot is blocked\n\t\tBotAIBlocked(bs, &moveresult, qtrue);\n\t}\n\t//\n\tBotClearPath(bs, &moveresult);\n\t// if the bot has to shoot to activate\n\tif (bs->activatestack->shoot) {\n\t\t// if the view angles aren't yet used for the movement\n\t\tif (!(moveresult.flags & MOVERESULT_MOVEMENTVIEW)) {\n\t\t\tVectorSubtract(bs->activatestack->target, bs->eye, dir);\n\t\t\tvectoangles(dir, moveresult.ideal_viewangles);\n\t\t\tmoveresult.flags |= MOVERESULT_MOVEMENTVIEW;\n\t\t}\n\t\t// if there's no weapon yet used for the movement\n\t\tif (!(moveresult.flags & MOVERESULT_MOVEMENTWEAPON)) {\n\t\t\tmoveresult.flags |= MOVERESULT_MOVEMENTWEAPON;\n\t\t\t//\n\t\t\tbs->activatestack->weapon = BotSelectActivateWeapon(bs);\n\t\t\tif (bs->activatestack->weapon == -1) {\n\t\t\t\t//FIXME: find a decent weapon first\n\t\t\t\tbs->activatestack->weapon = 0;\n\t\t\t}\n\t\t\tmoveresult.weapon = bs->activatestack->weapon;\n\t\t}\n\t}\n\t// if the ideal view angles are set for movement\n\tif (moveresult.flags & (MOVERESULT_MOVEMENTVIEWSET|MOVERESULT_MOVEMENTVIEW|MOVERESULT_SWIMVIEW)) {\n\t\tVectorCopy(moveresult.ideal_viewangles, bs->ideal_viewangles);\n\t}\n\t// if waiting for something\n\telse if (moveresult.flags & MOVERESULT_WAITING) {\n\t\tif (random() < bs->thinktime * 0.8) {\n\t\t\tBotRoamGoal(bs, target);\n\t\t\tVectorSubtract(target, bs->origin, dir);\n\t\t\tvectoangles(dir, bs->ideal_viewangles);\n\t\t\tbs->ideal_viewangles[2] *= 0.5;\n\t\t}\n\t}\n\telse if (!(bs->flags & BFL_IDEALVIEWSET)) {\n\t\tif (trap_BotMovementViewTarget(bs->ms, goal, bs->tfl, 300, target)) {\n\t\t\tVectorSubtract(target, bs->origin, dir);\n\t\t\tvectoangles(dir, bs->ideal_viewangles);\n\t\t}\n\t\telse {\n\t\t\tvectoangles(moveresult.movedir, bs->ideal_viewangles);\n\t\t}\n\t\tbs->ideal_viewangles[2] *= 0.5;\n\t}\n\t// if the weapon is used for the bot movement\n\tif (moveresult.flags & MOVERESULT_MOVEMENTWEAPON)\n\t\tbs->weaponnum = moveresult.weapon;\n\t// if there is an enemy\n\tif (BotFindEnemy(bs, -1)) {\n\t\tif (BotWantsToRetreat(bs)) {\n\t\t\t//keep the current long term goal and retreat\n\t\t\tAIEnter_Battle_NBG(bs, \"activate entity: found enemy\");\n\t\t}\n\t\telse {\n\t\t\ttrap_BotResetLastAvoidReach(bs->ms);\n\t\t\t//empty the goal stack\n\t\t\ttrap_BotEmptyGoalStack(bs->gs);\n\t\t\t//go fight\n\t\t\tAIEnter_Battle_Fight(bs, \"activate entity: found enemy\");\n\t\t}\n\t\tBotClearActivateGoalStack(bs);\n\t}\n\treturn qtrue;\n}\n\n/*\n==================\nAIEnter_Seek_NBG\n==================\n*/\nvoid AIEnter_Seek_NBG(bot_state_t *bs, char *s) {\n\tbot_goal_t goal;\n\tchar buf[144];\n\n\tif (trap_BotGetTopGoal(bs->gs, &goal)) {\n\t\ttrap_BotGoalName(goal.number, buf, 144);\n\t\tBotRecordNodeSwitch(bs, \"seek NBG\", buf, s);\n\t}\n\telse {\n\t\tBotRecordNodeSwitch(bs, \"seek NBG\", \"no goal\", s);\n\t}\n\tbs->ainode = AINode_Seek_NBG;\n}\n\n/*\n==================\nAINode_Seek_NBG\n==================\n*/\nint AINode_Seek_NBG(bot_state_t *bs) {\n\tbot_goal_t goal;\n\tvec3_t target, dir;\n\tbot_moveresult_t moveresult;\n\n\tif (BotIsObserver(bs)) {\n\t\tAIEnter_Observer(bs, \"seek nbg: observer\");\n\t\treturn qfalse;\n\t}\n\t//if in the intermission\n\tif (BotIntermission(bs)) {\n\t\tAIEnter_Intermission(bs, \"seek nbg: intermision\");\n\t\treturn qfalse;\n\t}\n\t//respawn if dead\n\tif (BotIsDead(bs)) {\n\t\tAIEnter_Respawn(bs, \"seek nbg: bot dead\");\n\t\treturn qfalse;\n\t}\n\t//\n\tbs->tfl = TFL_DEFAULT;\n\tif (bot_grapple.integer) bs->tfl |= TFL_GRAPPLEHOOK;\n\t//if in lava or slime the bot should be able to get out\n\tif (BotInLavaOrSlime(bs)) bs->tfl |= TFL_LAVA|TFL_SLIME;\n\t//\n\tif (BotCanAndWantsToRocketJump(bs)) {\n\t\tbs->tfl |= TFL_ROCKETJUMP;\n\t}\n\t//map specific code\n\tBotMapScripts(bs);\n\t//no enemy\n\tbs->enemy = -1;\n\t//if the bot has no goal\n\tif (!trap_BotGetTopGoal(bs->gs, &goal)) bs->nbg_time = 0;\n\t//if the bot touches the current goal\n\telse if (BotReachedGoal(bs, &goal)) {\n\t\tBotChooseWeapon(bs);\n\t\tbs->nbg_time = 0;\n\t}\n\t//\n\tif (bs->nbg_time < FloatTime()) {\n\t\t//pop the current goal from the stack\n\t\ttrap_BotPopGoal(bs->gs);\n\t\t//check for new nearby items right away\n\t\t//NOTE: we canNOT reset the check_time to zero because it would create an endless loop of node switches\n\t\tbs->check_time = FloatTime() + 0.05;\n\t\t//go back to seek ltg\n\t\tAIEnter_Seek_LTG(bs, \"seek nbg: time out\");\n\t\treturn qfalse;\n\t}\n\t//predict obstacles\n\tif (BotAIPredictObstacles(bs, &goal))\n\t\treturn qfalse;\n\t//initialize the movement state\n\tBotSetupForMovement(bs);\n\t//move towards the goal\n\ttrap_BotMoveToGoal(&moveresult, bs->ms, &goal, bs->tfl);\n\t//if the movement failed\n\tif (moveresult.failure) {\n\t\t//reset the avoid reach, otherwise bot is stuck in current area\n\t\ttrap_BotResetAvoidReach(bs->ms);\n\t\tbs->nbg_time = 0;\n\t}\n\t//check if the bot is blocked\n\tBotAIBlocked(bs, &moveresult, qtrue);\n\t//\n\tBotClearPath(bs, &moveresult);\n\t//if the viewangles are used for the movement\n\tif (moveresult.flags & (MOVERESULT_MOVEMENTVIEWSET|MOVERESULT_MOVEMENTVIEW|MOVERESULT_SWIMVIEW)) {\n\t\tVectorCopy(moveresult.ideal_viewangles, bs->ideal_viewangles);\n\t}\n\t//if waiting for something\n\telse if (moveresult.flags & MOVERESULT_WAITING) {\n\t\tif (random() < bs->thinktime * 0.8) {\n\t\t\tBotRoamGoal(bs, target);\n\t\t\tVectorSubtract(target, bs->origin, dir);\n\t\t\tvectoangles(dir, bs->ideal_viewangles);\n\t\t\tbs->ideal_viewangles[2] *= 0.5;\n\t\t}\n\t}\n\telse if (!(bs->flags & BFL_IDEALVIEWSET)) {\n\t\tif (!trap_BotGetSecondGoal(bs->gs, &goal)) trap_BotGetTopGoal(bs->gs, &goal);\n\t\tif (trap_BotMovementViewTarget(bs->ms, &goal, bs->tfl, 300, target)) {\n\t\t\tVectorSubtract(target, bs->origin, dir);\n\t\t\tvectoangles(dir, bs->ideal_viewangles);\n\t\t}\n\t\t//FIXME: look at cluster portals?\n\t\telse vectoangles(moveresult.movedir, bs->ideal_viewangles);\n\t\tbs->ideal_viewangles[2] *= 0.5;\n\t}\n\t//if the weapon is used for the bot movement\n\tif (moveresult.flags & MOVERESULT_MOVEMENTWEAPON) bs->weaponnum = moveresult.weapon;\n\t//if there is an enemy\n\tif (BotFindEnemy(bs, -1)) {\n\t\tif (BotWantsToRetreat(bs)) {\n\t\t\t//keep the current long term goal and retreat\n\t\t\tAIEnter_Battle_NBG(bs, \"seek nbg: found enemy\");\n\t\t}\n\t\telse {\n\t\t\ttrap_BotResetLastAvoidReach(bs->ms);\n\t\t\t//empty the goal stack\n\t\t\ttrap_BotEmptyGoalStack(bs->gs);\n\t\t\t//go fight\n\t\t\tAIEnter_Battle_Fight(bs, \"seek nbg: found enemy\");\n\t\t}\n\t}\n\treturn qtrue;\n}\n\n/*\n==================\nAIEnter_Seek_LTG\n==================\n*/\nvoid AIEnter_Seek_LTG(bot_state_t *bs, char *s) {\n\tbot_goal_t goal;\n\tchar buf[144];\n\n\tif (trap_BotGetTopGoal(bs->gs, &goal)) {\n\t\ttrap_BotGoalName(goal.number, buf, 144);\n\t\tBotRecordNodeSwitch(bs, \"seek LTG\", buf, s);\n\t}\n\telse {\n\t\tBotRecordNodeSwitch(bs, \"seek LTG\", \"no goal\", s);\n\t}\n\tbs->ainode = AINode_Seek_LTG;\n}\n\n/*\n==================\nAINode_Seek_LTG\n==================\n*/\nint AINode_Seek_LTG(bot_state_t *bs)\n{\n\tbot_goal_t goal;\n\tvec3_t target, dir;\n\tbot_moveresult_t moveresult;\n\tint range;\n\t//char buf[128];\n\t//bot_goal_t tmpgoal;\n\n\tif (BotIsObserver(bs)) {\n\t\tAIEnter_Observer(bs, \"seek ltg: observer\");\n\t\treturn qfalse;\n\t}\n\t//if in the intermission\n\tif (BotIntermission(bs)) {\n\t\tAIEnter_Intermission(bs, \"seek ltg: intermission\");\n\t\treturn qfalse;\n\t}\n\t//respawn if dead\n\tif (BotIsDead(bs)) {\n\t\tAIEnter_Respawn(bs, \"seek ltg: bot dead\");\n\t\treturn qfalse;\n\t}\n\t//\n\tif (BotChat_Random(bs)) {\n\t\tbs->stand_time = FloatTime() + BotChatTime(bs);\n\t\tAIEnter_Stand(bs, \"seek ltg: random chat\");\n\t\treturn qfalse;\n\t}\n\t//\n\tbs->tfl = TFL_DEFAULT;\n\tif (bot_grapple.integer) bs->tfl |= TFL_GRAPPLEHOOK;\n\t//if in lava or slime the bot should be able to get out\n\tif (BotInLavaOrSlime(bs)) bs->tfl |= TFL_LAVA|TFL_SLIME;\n\t//\n\tif (BotCanAndWantsToRocketJump(bs)) {\n\t\tbs->tfl |= TFL_ROCKETJUMP;\n\t}\n\t//map specific code\n\tBotMapScripts(bs);\n\t//no enemy\n\tbs->enemy = -1;\n\t//\n\tif (bs->killedenemy_time > FloatTime() - 2) {\n\t\tif (random() < bs->thinktime * 1) {\n\t\t\ttrap_EA_Gesture(bs->client);\n\t\t}\n\t}\n\t//if there is an enemy\n\tif (BotFindEnemy(bs, -1)) {\n\t\tif (BotWantsToRetreat(bs)) {\n\t\t\t//keep the current long term goal and retreat\n\t\t\tAIEnter_Battle_Retreat(bs, \"seek ltg: found enemy\");\n\t\t\treturn qfalse;\n\t\t}\n\t\telse {\n\t\t\ttrap_BotResetLastAvoidReach(bs->ms);\n\t\t\t//empty the goal stack\n\t\t\ttrap_BotEmptyGoalStack(bs->gs);\n\t\t\t//go fight\n\t\t\tAIEnter_Battle_Fight(bs, \"seek ltg: found enemy\");\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\t//\n\tBotTeamGoals(bs, qfalse);\n\t//get the current long term goal\n\tif (!BotLongTermGoal(bs, bs->tfl, qfalse, &goal)) {\n\t\treturn qtrue;\n\t}\n\t//check for nearby goals periodicly\n\tif (bs->check_time < FloatTime()) {\n\t\tbs->check_time = FloatTime() + 0.5;\n\t\t//check if the bot wants to camp\n\t\tBotWantsToCamp(bs);\n\t\t//\n\t\tif (bs->ltgtype == LTG_DEFENDKEYAREA) range = 400;\n\t\telse range = 150;\n\t\t//\n#ifdef CTF\n\t\tif (gametype == GT_CTF) {\n\t\t\t//if carrying a flag the bot shouldn't be distracted too much\n\t\t\tif (BotCTFCarryingFlag(bs))\n\t\t\t\trange = 50;\n\t\t}\n#endif //CTF\n#ifdef MISSIONPACK\n\t\telse if (gametype == GT_1FCTF) {\n\t\t\tif (Bot1FCTFCarryingFlag(bs))\n\t\t\t\trange = 50;\n\t\t}\n\t\telse if (gametype == GT_HARVESTER) {\n\t\t\tif (BotHarvesterCarryingCubes(bs))\n\t\t\t\trange = 80;\n\t\t}\n#endif\n\t\t//\n\t\tif (BotNearbyGoal(bs, bs->tfl, &goal, range)) {\n\t\t\ttrap_BotResetLastAvoidReach(bs->ms);\n\t\t\t//get the goal at the top of the stack\n\t\t\t//trap_BotGetTopGoal(bs->gs, &tmpgoal);\n\t\t\t//trap_BotGoalName(tmpgoal.number, buf, 144);\n\t\t\t//BotAI_Print(PRT_MESSAGE, \"new nearby goal %s\\n\", buf);\n\t\t\t//time the bot gets to pick up the nearby goal item\n\t\t\tbs->nbg_time = FloatTime() + 4 + range * 0.01;\n\t\t\tAIEnter_Seek_NBG(bs, \"ltg seek: nbg\");\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\t//predict obstacles\n\tif (BotAIPredictObstacles(bs, &goal))\n\t\treturn qfalse;\n\t//initialize the movement state\n\tBotSetupForMovement(bs);\n\t//move towards the goal\n\ttrap_BotMoveToGoal(&moveresult, bs->ms, &goal, bs->tfl);\n\t//if the movement failed\n\tif (moveresult.failure) {\n\t\t//reset the avoid reach, otherwise bot is stuck in current area\n\t\ttrap_BotResetAvoidReach(bs->ms);\n\t\t//BotAI_Print(PRT_MESSAGE, \"movement failure %d\\n\", moveresult.traveltype);\n\t\tbs->ltg_time = 0;\n\t}\n\t//\n\tBotAIBlocked(bs, &moveresult, qtrue);\n\t//\n\tBotClearPath(bs, &moveresult);\n\t//if the viewangles are used for the movement\n\tif (moveresult.flags & (MOVERESULT_MOVEMENTVIEWSET|MOVERESULT_MOVEMENTVIEW|MOVERESULT_SWIMVIEW)) {\n\t\tVectorCopy(moveresult.ideal_viewangles, bs->ideal_viewangles);\n\t}\n\t//if waiting for something\n\telse if (moveresult.flags & MOVERESULT_WAITING) {\n\t\tif (random() < bs->thinktime * 0.8) {\n\t\t\tBotRoamGoal(bs, target);\n\t\t\tVectorSubtract(target, bs->origin, dir);\n\t\t\tvectoangles(dir, bs->ideal_viewangles);\n\t\t\tbs->ideal_viewangles[2] *= 0.5;\n\t\t}\n\t}\n\telse if (!(bs->flags & BFL_IDEALVIEWSET)) {\n\t\tif (trap_BotMovementViewTarget(bs->ms, &goal, bs->tfl, 300, target)) {\n\t\t\tVectorSubtract(target, bs->origin, dir);\n\t\t\tvectoangles(dir, bs->ideal_viewangles);\n\t\t}\n\t\t//FIXME: look at cluster portals?\n\t\telse if (VectorLengthSquared(moveresult.movedir)) {\n\t\t\tvectoangles(moveresult.movedir, bs->ideal_viewangles);\n\t\t}\n\t\telse if (random() < bs->thinktime * 0.8) {\n\t\t\tBotRoamGoal(bs, target);\n\t\t\tVectorSubtract(target, bs->origin, dir);\n\t\t\tvectoangles(dir, bs->ideal_viewangles);\n\t\t\tbs->ideal_viewangles[2] *= 0.5;\n\t\t}\n\t\tbs->ideal_viewangles[2] *= 0.5;\n\t}\n\t//if the weapon is used for the bot movement\n\tif (moveresult.flags & MOVERESULT_MOVEMENTWEAPON) bs->weaponnum = moveresult.weapon;\n\t//\n\treturn qtrue;\n}\n\n/*\n==================\nAIEnter_Battle_Fight\n==================\n*/\nvoid AIEnter_Battle_Fight(bot_state_t *bs, char *s) {\n\tBotRecordNodeSwitch(bs, \"battle fight\", \"\", s);\n\ttrap_BotResetLastAvoidReach(bs->ms);\n\tbs->ainode = AINode_Battle_Fight;\n}\n\n/*\n==================\nAIEnter_Battle_Fight\n==================\n*/\nvoid AIEnter_Battle_SuicidalFight(bot_state_t *bs, char *s) {\n\tBotRecordNodeSwitch(bs, \"battle fight\", \"\", s);\n\ttrap_BotResetLastAvoidReach(bs->ms);\n\tbs->ainode = AINode_Battle_Fight;\n\tbs->flags |= BFL_FIGHTSUICIDAL;\n}\n\n/*\n==================\nAINode_Battle_Fight\n==================\n*/\nint AINode_Battle_Fight(bot_state_t *bs) {\n\tint areanum;\n\tvec3_t target;\n\taas_entityinfo_t entinfo;\n\tbot_moveresult_t moveresult;\n\n\tif (BotIsObserver(bs)) {\n\t\tAIEnter_Observer(bs, \"battle fight: observer\");\n\t\treturn qfalse;\n\t}\n\n\t//if in the intermission\n\tif (BotIntermission(bs)) {\n\t\tAIEnter_Intermission(bs, \"battle fight: intermission\");\n\t\treturn qfalse;\n\t}\n\t//respawn if dead\n\tif (BotIsDead(bs)) {\n\t\tAIEnter_Respawn(bs, \"battle fight: bot dead\");\n\t\treturn qfalse;\n\t}\n\t//if there is another better enemy\n\tif (BotFindEnemy(bs, bs->enemy)) {\n#ifdef DEBUG\n\t\tBotAI_Print(PRT_MESSAGE, \"found new better enemy\\n\");\n#endif\n\t}\n\t//if no enemy\n\tif (bs->enemy < 0) {\n\t\tAIEnter_Seek_LTG(bs, \"battle fight: no enemy\");\n\t\treturn qfalse;\n\t}\n\t//\n\tBotEntityInfo(bs->enemy, &entinfo);\n\t//if the enemy is dead\n\tif (bs->enemydeath_time) {\n\t\tif (bs->enemydeath_time < FloatTime() - 1.0) {\n\t\t\tbs->enemydeath_time = 0;\n\t\t\tif (bs->enemysuicide) {\n\t\t\t\tBotChat_EnemySuicide(bs);\n\t\t\t}\n\t\t\tif (bs->lastkilledplayer == bs->enemy && BotChat_Kill(bs)) {\n\t\t\t\tbs->stand_time = FloatTime() + BotChatTime(bs);\n\t\t\t\tAIEnter_Stand(bs, \"battle fight: enemy dead\");\n\t\t\t}\n\t\t\telse {\n\t\t\t\tbs->ltg_time = 0;\n\t\t\t\tAIEnter_Seek_LTG(bs, \"battle fight: enemy dead\");\n\t\t\t}\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\telse {\n\t\tif (EntityIsDead(&entinfo)) {\n\t\t\tbs->enemydeath_time = FloatTime();\n\t\t}\n\t}\n\t//if the enemy is invisible and not shooting the bot looses track easily\n\tif (EntityIsInvisible(&entinfo) && !EntityIsShooting(&entinfo)) {\n\t\tif (random() < 0.2) {\n\t\t\tAIEnter_Seek_LTG(bs, \"battle fight: invisible\");\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\t//\n\tVectorCopy(entinfo.origin, target);\n\t// if not a player enemy\n\tif (bs->enemy >= MAX_CLIENTS) {\n#ifdef MISSIONPACK\n\t\t// if attacking an obelisk\n\t\tif ( bs->enemy == redobelisk.entitynum ||\n\t\t\tbs->enemy == blueobelisk.entitynum ) {\n\t\t\ttarget[2] += 16;\n\t\t}\n#endif\n\t}\n\t//update the reachability area and origin if possible\n\tareanum = BotPointAreaNum(target);\n\tif (areanum && trap_AAS_AreaReachability(areanum)) {\n\t\tVectorCopy(target, bs->lastenemyorigin);\n\t\tbs->lastenemyareanum = areanum;\n\t}\n\t//update the attack inventory values\n\tBotUpdateBattleInventory(bs, bs->enemy);\n\t//if the bot's health decreased\n\tif (bs->lastframe_health > bs->inventory[INVENTORY_HEALTH]) {\n\t\tif (BotChat_HitNoDeath(bs)) {\n\t\t\tbs->stand_time = FloatTime() + BotChatTime(bs);\n\t\t\tAIEnter_Stand(bs, \"battle fight: chat health decreased\");\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\t//if the bot hit someone\n\tif (bs->cur_ps.persistant[PERS_HITS] > bs->lasthitcount) {\n\t\tif (BotChat_HitNoKill(bs)) {\n\t\t\tbs->stand_time = FloatTime() + BotChatTime(bs);\n\t\t\tAIEnter_Stand(bs, \"battle fight: chat hit someone\");\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\t//if the enemy is not visible\n\tif (!BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, bs->enemy)) {\n\t\tif (BotWantsToChase(bs)) {\n\t\t\tAIEnter_Battle_Chase(bs, \"battle fight: enemy out of sight\");\n\t\t\treturn qfalse;\n\t\t}\n\t\telse {\n\t\t\tAIEnter_Seek_LTG(bs, \"battle fight: enemy out of sight\");\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\t//use holdable items\n\tBotBattleUseItems(bs);\n\t//\n\tbs->tfl = TFL_DEFAULT;\n\tif (bot_grapple.integer) bs->tfl |= TFL_GRAPPLEHOOK;\n\t//if in lava or slime the bot should be able to get out\n\tif (BotInLavaOrSlime(bs)) bs->tfl |= TFL_LAVA|TFL_SLIME;\n\t//\n\tif (BotCanAndWantsToRocketJump(bs)) {\n\t\tbs->tfl |= TFL_ROCKETJUMP;\n\t}\n\t//choose the best weapon to fight with\n\tBotChooseWeapon(bs);\n\t//do attack movements\n\tmoveresult = BotAttackMove(bs, bs->tfl);\n\t//if the movement failed\n\tif (moveresult.failure) {\n\t\t//reset the avoid reach, otherwise bot is stuck in current area\n\t\ttrap_BotResetAvoidReach(bs->ms);\n\t\t//BotAI_Print(PRT_MESSAGE, \"movement failure %d\\n\", moveresult.traveltype);\n\t\tbs->ltg_time = 0;\n\t}\n\t//\n\tBotAIBlocked(bs, &moveresult, qfalse);\n\t//aim at the enemy\n\tBotAimAtEnemy(bs);\n\t//attack the enemy if possible\n\tBotCheckAttack(bs);\n\t//if the bot wants to retreat\n\tif (!(bs->flags & BFL_FIGHTSUICIDAL)) {\n\t\tif (BotWantsToRetreat(bs)) {\n\t\t\tAIEnter_Battle_Retreat(bs, \"battle fight: wants to retreat\");\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\treturn qtrue;\n}\n\n/*\n==================\nAIEnter_Battle_Chase\n==================\n*/\nvoid AIEnter_Battle_Chase(bot_state_t *bs, char *s) {\n\tBotRecordNodeSwitch(bs, \"battle chase\", \"\", s);\n\tbs->chase_time = FloatTime();\n\tbs->ainode = AINode_Battle_Chase;\n}\n\n/*\n==================\nAINode_Battle_Chase\n==================\n*/\nint AINode_Battle_Chase(bot_state_t *bs)\n{\n\tbot_goal_t goal;\n\tvec3_t target, dir;\n\tbot_moveresult_t moveresult;\n\tfloat range;\n\n\tif (BotIsObserver(bs)) {\n\t\tAIEnter_Observer(bs, \"battle chase: observer\");\n\t\treturn qfalse;\n\t}\n\t//if in the intermission\n\tif (BotIntermission(bs)) {\n\t\tAIEnter_Intermission(bs, \"battle chase: intermission\");\n\t\treturn qfalse;\n\t}\n\t//respawn if dead\n\tif (BotIsDead(bs)) {\n\t\tAIEnter_Respawn(bs, \"battle chase: bot dead\");\n\t\treturn qfalse;\n\t}\n\t//if no enemy\n\tif (bs->enemy < 0) {\n\t\tAIEnter_Seek_LTG(bs, \"battle chase: no enemy\");\n\t\treturn qfalse;\n\t}\n\t//if the enemy is visible\n\tif (BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, bs->enemy)) {\n\t\tAIEnter_Battle_Fight(bs, \"battle chase\");\n\t\treturn qfalse;\n\t}\n\t//if there is another enemy\n\tif (BotFindEnemy(bs, -1)) {\n\t\tAIEnter_Battle_Fight(bs, \"battle chase: better enemy\");\n\t\treturn qfalse;\n\t}\n\t//there is no last enemy area\n\tif (!bs->lastenemyareanum) {\n\t\tAIEnter_Seek_LTG(bs, \"battle chase: no enemy area\");\n\t\treturn qfalse;\n\t}\n\t//\n\tbs->tfl = TFL_DEFAULT;\n\tif (bot_grapple.integer) bs->tfl |= TFL_GRAPPLEHOOK;\n\t//if in lava or slime the bot should be able to get out\n\tif (BotInLavaOrSlime(bs)) bs->tfl |= TFL_LAVA|TFL_SLIME;\n\t//\n\tif (BotCanAndWantsToRocketJump(bs)) {\n\t\tbs->tfl |= TFL_ROCKETJUMP;\n\t}\n\t//map specific code\n\tBotMapScripts(bs);\n\t//create the chase goal\n\tgoal.entitynum = bs->enemy;\n\tgoal.areanum = bs->lastenemyareanum;\n\tVectorCopy(bs->lastenemyorigin, goal.origin);\n\tVectorSet(goal.mins, -8, -8, -8);\n\tVectorSet(goal.maxs, 8, 8, 8);\n\t//if the last seen enemy spot is reached the enemy could not be found\n\tif (trap_BotTouchingGoal(bs->origin, &goal)) bs->chase_time = 0;\n\t//if there's no chase time left\n\tif (!bs->chase_time || bs->chase_time < FloatTime() - 10) {\n\t\tAIEnter_Seek_LTG(bs, \"battle chase: time out\");\n\t\treturn qfalse;\n\t}\n\t//check for nearby goals periodicly\n\tif (bs->check_time < FloatTime()) {\n\t\tbs->check_time = FloatTime() + 1;\n\t\trange = 150;\n\t\t//\n\t\tif (BotNearbyGoal(bs, bs->tfl, &goal, range)) {\n\t\t\t//the bot gets 5 seconds to pick up the nearby goal item\n\t\t\tbs->nbg_time = FloatTime() + 0.1 * range + 1;\n\t\t\ttrap_BotResetLastAvoidReach(bs->ms);\n\t\t\tAIEnter_Battle_NBG(bs, \"battle chase: nbg\");\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\t//\n\tBotUpdateBattleInventory(bs, bs->enemy);\n\t//initialize the movement state\n\tBotSetupForMovement(bs);\n\t//move towards the goal\n\ttrap_BotMoveToGoal(&moveresult, bs->ms, &goal, bs->tfl);\n\t//if the movement failed\n\tif (moveresult.failure) {\n\t\t//reset the avoid reach, otherwise bot is stuck in current area\n\t\ttrap_BotResetAvoidReach(bs->ms);\n\t\t//BotAI_Print(PRT_MESSAGE, \"movement failure %d\\n\", moveresult.traveltype);\n\t\tbs->ltg_time = 0;\n\t}\n\t//\n\tBotAIBlocked(bs, &moveresult, qfalse);\n\t//\n\tif (moveresult.flags & (MOVERESULT_MOVEMENTVIEWSET|MOVERESULT_MOVEMENTVIEW|MOVERESULT_SWIMVIEW)) {\n\t\tVectorCopy(moveresult.ideal_viewangles, bs->ideal_viewangles);\n\t}\n\telse if (!(bs->flags & BFL_IDEALVIEWSET)) {\n\t\tif (bs->chase_time > FloatTime() - 2) {\n\t\t\tBotAimAtEnemy(bs);\n\t\t}\n\t\telse {\n\t\t\tif (trap_BotMovementViewTarget(bs->ms, &goal, bs->tfl, 300, target)) {\n\t\t\t\tVectorSubtract(target, bs->origin, dir);\n\t\t\t\tvectoangles(dir, bs->ideal_viewangles);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvectoangles(moveresult.movedir, bs->ideal_viewangles);\n\t\t\t}\n\t\t}\n\t\tbs->ideal_viewangles[2] *= 0.5;\n\t}\n\t//if the weapon is used for the bot movement\n\tif (moveresult.flags & MOVERESULT_MOVEMENTWEAPON) bs->weaponnum = moveresult.weapon;\n\t//if the bot is in the area the enemy was last seen in\n\tif (bs->areanum == bs->lastenemyareanum) bs->chase_time = 0;\n\t//if the bot wants to retreat (the bot could have been damage during the chase)\n\tif (BotWantsToRetreat(bs)) {\n\t\tAIEnter_Battle_Retreat(bs, \"battle chase: wants to retreat\");\n\t\treturn qtrue;\n\t}\n\treturn qtrue;\n}\n\n/*\n==================\nAIEnter_Battle_Retreat\n==================\n*/\nvoid AIEnter_Battle_Retreat(bot_state_t *bs, char *s) {\n\tBotRecordNodeSwitch(bs, \"battle retreat\", \"\", s);\n\tbs->ainode = AINode_Battle_Retreat;\n}\n\n/*\n==================\nAINode_Battle_Retreat\n==================\n*/\nint AINode_Battle_Retreat(bot_state_t *bs) {\n\tbot_goal_t goal;\n\taas_entityinfo_t entinfo;\n\tbot_moveresult_t moveresult;\n\tvec3_t target, dir;\n\tfloat attack_skill, range;\n\tint areanum;\n\n\tif (BotIsObserver(bs)) {\n\t\tAIEnter_Observer(bs, \"battle retreat: observer\");\n\t\treturn qfalse;\n\t}\n\t//if in the intermission\n\tif (BotIntermission(bs)) {\n\t\tAIEnter_Intermission(bs, \"battle retreat: intermission\");\n\t\treturn qfalse;\n\t}\n\t//respawn if dead\n\tif (BotIsDead(bs)) {\n\t\tAIEnter_Respawn(bs, \"battle retreat: bot dead\");\n\t\treturn qfalse;\n\t}\n\t//if no enemy\n\tif (bs->enemy < 0) {\n\t\tAIEnter_Seek_LTG(bs, \"battle retreat: no enemy\");\n\t\treturn qfalse;\n\t}\n\t//\n\tBotEntityInfo(bs->enemy, &entinfo);\n\tif (EntityIsDead(&entinfo)) {\n\t\tAIEnter_Seek_LTG(bs, \"battle retreat: enemy dead\");\n\t\treturn qfalse;\n\t}\n\t//if there is another better enemy\n\tif (BotFindEnemy(bs, bs->enemy)) {\n#ifdef DEBUG\n\t\tBotAI_Print(PRT_MESSAGE, \"found new better enemy\\n\");\n#endif\n\t}\n\t//\n\tbs->tfl = TFL_DEFAULT;\n\tif (bot_grapple.integer) bs->tfl |= TFL_GRAPPLEHOOK;\n\t//if in lava or slime the bot should be able to get out\n\tif (BotInLavaOrSlime(bs)) bs->tfl |= TFL_LAVA|TFL_SLIME;\n\t//map specific code\n\tBotMapScripts(bs);\n\t//update the attack inventory values\n\tBotUpdateBattleInventory(bs, bs->enemy);\n\t//if the bot doesn't want to retreat anymore... probably picked up some nice items\n\tif (BotWantsToChase(bs)) {\n\t\t//empty the goal stack, when chasing, only the enemy is the goal\n\t\ttrap_BotEmptyGoalStack(bs->gs);\n\t\t//go chase the enemy\n\t\tAIEnter_Battle_Chase(bs, \"battle retreat: wants to chase\");\n\t\treturn qfalse;\n\t}\n\t//update the last time the enemy was visible\n\tif (BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, bs->enemy)) {\n\t\tbs->enemyvisible_time = FloatTime();\n\t\tVectorCopy(entinfo.origin, target);\n\t\t// if not a player enemy\n\t\tif (bs->enemy >= MAX_CLIENTS) {\n#ifdef MISSIONPACK\n\t\t\t// if attacking an obelisk\n\t\t\tif ( bs->enemy == redobelisk.entitynum ||\n\t\t\t\tbs->enemy == blueobelisk.entitynum ) {\n\t\t\t\ttarget[2] += 16;\n\t\t\t}\n#endif\n\t\t}\n\t\t//update the reachability area and origin if possible\n\t\tareanum = BotPointAreaNum(target);\n\t\tif (areanum && trap_AAS_AreaReachability(areanum)) {\n\t\t\tVectorCopy(target, bs->lastenemyorigin);\n\t\t\tbs->lastenemyareanum = areanum;\n\t\t}\n\t}\n\t//if the enemy is NOT visible for 4 seconds\n\tif (bs->enemyvisible_time < FloatTime() - 4) {\n\t\tAIEnter_Seek_LTG(bs, \"battle retreat: lost enemy\");\n\t\treturn qfalse;\n\t}\n\t//else if the enemy is NOT visible\n\telse if (bs->enemyvisible_time < FloatTime()) {\n\t\t//if there is another enemy\n\t\tif (BotFindEnemy(bs, -1)) {\n\t\t\tAIEnter_Battle_Fight(bs, \"battle retreat: another enemy\");\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\t//\n\tBotTeamGoals(bs, qtrue);\n\t//use holdable items\n\tBotBattleUseItems(bs);\n\t//get the current long term goal while retreating\n\tif (!BotLongTermGoal(bs, bs->tfl, qtrue, &goal)) {\n\t\tAIEnter_Battle_SuicidalFight(bs, \"battle retreat: no way out\");\n\t\treturn qfalse;\n\t}\n\t//check for nearby goals periodicly\n\tif (bs->check_time < FloatTime()) {\n\t\tbs->check_time = FloatTime() + 1;\n\t\trange = 150;\n#ifdef CTF\n\t\tif (gametype == GT_CTF) {\n\t\t\t//if carrying a flag the bot shouldn't be distracted too much\n\t\t\tif (BotCTFCarryingFlag(bs))\n\t\t\t\trange = 50;\n\t\t}\n#endif //CTF\n#ifdef MISSIONPACK\n\t\telse if (gametype == GT_1FCTF) {\n\t\t\tif (Bot1FCTFCarryingFlag(bs))\n\t\t\t\trange = 50;\n\t\t}\n\t\telse if (gametype == GT_HARVESTER) {\n\t\t\tif (BotHarvesterCarryingCubes(bs))\n\t\t\t\trange = 80;\n\t\t}\n#endif\n\t\t//\n\t\tif (BotNearbyGoal(bs, bs->tfl, &goal, range)) {\n\t\t\ttrap_BotResetLastAvoidReach(bs->ms);\n\t\t\t//time the bot gets to pick up the nearby goal item\n\t\t\tbs->nbg_time = FloatTime() + range / 100 + 1;\n\t\t\tAIEnter_Battle_NBG(bs, \"battle retreat: nbg\");\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\t//initialize the movement state\n\tBotSetupForMovement(bs);\n\t//move towards the goal\n\ttrap_BotMoveToGoal(&moveresult, bs->ms, &goal, bs->tfl);\n\t//if the movement failed\n\tif (moveresult.failure) {\n\t\t//reset the avoid reach, otherwise bot is stuck in current area\n\t\ttrap_BotResetAvoidReach(bs->ms);\n\t\t//BotAI_Print(PRT_MESSAGE, \"movement failure %d\\n\", moveresult.traveltype);\n\t\tbs->ltg_time = 0;\n\t}\n\t//\n\tBotAIBlocked(bs, &moveresult, qfalse);\n\t//choose the best weapon to fight with\n\tBotChooseWeapon(bs);\n\t//if the view is fixed for the movement\n\tif (moveresult.flags & (MOVERESULT_MOVEMENTVIEW|MOVERESULT_SWIMVIEW)) {\n\t\tVectorCopy(moveresult.ideal_viewangles, bs->ideal_viewangles);\n\t}\n\telse if (!(moveresult.flags & MOVERESULT_MOVEMENTVIEWSET)\n\t\t\t\t&& !(bs->flags & BFL_IDEALVIEWSET) ) {\n\t\tattack_skill = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_ATTACK_SKILL, 0, 1);\n\t\t//if the bot is skilled anough\n\t\tif (attack_skill > 0.3) {\n\t\t\tBotAimAtEnemy(bs);\n\t\t}\n\t\telse {\n\t\t\tif (trap_BotMovementViewTarget(bs->ms, &goal, bs->tfl, 300, target)) {\n\t\t\t\tVectorSubtract(target, bs->origin, dir);\n\t\t\t\tvectoangles(dir, bs->ideal_viewangles);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvectoangles(moveresult.movedir, bs->ideal_viewangles);\n\t\t\t}\n\t\t\tbs->ideal_viewangles[2] *= 0.5;\n\t\t}\n\t}\n\t//if the weapon is used for the bot movement\n\tif (moveresult.flags & MOVERESULT_MOVEMENTWEAPON) bs->weaponnum = moveresult.weapon;\n\t//attack the enemy if possible\n\tBotCheckAttack(bs);\n\t//\n\treturn qtrue;\n}\n\n/*\n==================\nAIEnter_Battle_NBG\n==================\n*/\nvoid AIEnter_Battle_NBG(bot_state_t *bs, char *s) {\n\tBotRecordNodeSwitch(bs, \"battle NBG\", \"\", s);\n\tbs->ainode = AINode_Battle_NBG;\n}\n\n/*\n==================\nAINode_Battle_NBG\n==================\n*/\nint AINode_Battle_NBG(bot_state_t *bs) {\n\tint areanum;\n\tbot_goal_t goal;\n\taas_entityinfo_t entinfo;\n\tbot_moveresult_t moveresult;\n\tfloat attack_skill;\n\tvec3_t target, dir;\n\n\tif (BotIsObserver(bs)) {\n\t\tAIEnter_Observer(bs, \"battle nbg: observer\");\n\t\treturn qfalse;\n\t}\n\t//if in the intermission\n\tif (BotIntermission(bs)) {\n\t\tAIEnter_Intermission(bs, \"battle nbg: intermission\");\n\t\treturn qfalse;\n\t}\n\t//respawn if dead\n\tif (BotIsDead(bs)) {\n\t\tAIEnter_Respawn(bs, \"battle nbg: bot dead\");\n\t\treturn qfalse;\n\t}\n\t//if no enemy\n\tif (bs->enemy < 0) {\n\t\tAIEnter_Seek_NBG(bs, \"battle nbg: no enemy\");\n\t\treturn qfalse;\n\t}\n\t//\n\tBotEntityInfo(bs->enemy, &entinfo);\n\tif (EntityIsDead(&entinfo)) {\n\t\tAIEnter_Seek_NBG(bs, \"battle nbg: enemy dead\");\n\t\treturn qfalse;\n\t}\n\t//\n\tbs->tfl = TFL_DEFAULT;\n\tif (bot_grapple.integer) bs->tfl |= TFL_GRAPPLEHOOK;\n\t//if in lava or slime the bot should be able to get out\n\tif (BotInLavaOrSlime(bs)) bs->tfl |= TFL_LAVA|TFL_SLIME;\n\t//\n\tif (BotCanAndWantsToRocketJump(bs)) {\n\t\tbs->tfl |= TFL_ROCKETJUMP;\n\t}\n\t//map specific code\n\tBotMapScripts(bs);\n\t//update the last time the enemy was visible\n\tif (BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, bs->enemy)) {\n\t\tbs->enemyvisible_time = FloatTime();\n\t\tVectorCopy(entinfo.origin, target);\n\t\t// if not a player enemy\n\t\tif (bs->enemy >= MAX_CLIENTS) {\n#ifdef MISSIONPACK\n\t\t\t// if attacking an obelisk\n\t\t\tif ( bs->enemy == redobelisk.entitynum ||\n\t\t\t\tbs->enemy == blueobelisk.entitynum ) {\n\t\t\t\ttarget[2] += 16;\n\t\t\t}\n#endif\n\t\t}\n\t\t//update the reachability area and origin if possible\n\t\tareanum = BotPointAreaNum(target);\n\t\tif (areanum && trap_AAS_AreaReachability(areanum)) {\n\t\t\tVectorCopy(target, bs->lastenemyorigin);\n\t\t\tbs->lastenemyareanum = areanum;\n\t\t}\n\t}\n\t//if the bot has no goal or touches the current goal\n\tif (!trap_BotGetTopGoal(bs->gs, &goal)) {\n\t\tbs->nbg_time = 0;\n\t}\n\telse if (BotReachedGoal(bs, &goal)) {\n\t\tbs->nbg_time = 0;\n\t}\n\t//\n\tif (bs->nbg_time < FloatTime()) {\n\t\t//pop the current goal from the stack\n\t\ttrap_BotPopGoal(bs->gs);\n\t\t//if the bot still has a goal\n\t\tif (trap_BotGetTopGoal(bs->gs, &goal))\n\t\t\tAIEnter_Battle_Retreat(bs, \"battle nbg: time out\");\n\t\telse\n\t\t\tAIEnter_Battle_Fight(bs, \"battle nbg: time out\");\n\t\t//\n\t\treturn qfalse;\n\t}\n\t//initialize the movement state\n\tBotSetupForMovement(bs);\n\t//move towards the goal\n\ttrap_BotMoveToGoal(&moveresult, bs->ms, &goal, bs->tfl);\n\t//if the movement failed\n\tif (moveresult.failure) {\n\t\t//reset the avoid reach, otherwise bot is stuck in current area\n\t\ttrap_BotResetAvoidReach(bs->ms);\n\t\t//BotAI_Print(PRT_MESSAGE, \"movement failure %d\\n\", moveresult.traveltype);\n\t\tbs->nbg_time = 0;\n\t}\n\t//\n\tBotAIBlocked(bs, &moveresult, qfalse);\n\t//update the attack inventory values\n\tBotUpdateBattleInventory(bs, bs->enemy);\n\t//choose the best weapon to fight with\n\tBotChooseWeapon(bs);\n\t//if the view is fixed for the movement\n\tif (moveresult.flags & (MOVERESULT_MOVEMENTVIEW|MOVERESULT_SWIMVIEW)) {\n\t\tVectorCopy(moveresult.ideal_viewangles, bs->ideal_viewangles);\n\t}\n\telse if (!(moveresult.flags & MOVERESULT_MOVEMENTVIEWSET)\n\t\t\t\t&& !(bs->flags & BFL_IDEALVIEWSET)) {\n\t\tattack_skill = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_ATTACK_SKILL, 0, 1);\n\t\t//if the bot is skilled anough and the enemy is visible\n\t\tif (attack_skill > 0.3) {\n\t\t\t//&& BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, bs->enemy)\n\t\t\tBotAimAtEnemy(bs);\n\t\t}\n\t\telse {\n\t\t\tif (trap_BotMovementViewTarget(bs->ms, &goal, bs->tfl, 300, target)) {\n\t\t\t\tVectorSubtract(target, bs->origin, dir);\n\t\t\t\tvectoangles(dir, bs->ideal_viewangles);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvectoangles(moveresult.movedir, bs->ideal_viewangles);\n\t\t\t}\n\t\t\tbs->ideal_viewangles[2] *= 0.5;\n\t\t}\n\t}\n\t//if the weapon is used for the bot movement\n\tif (moveresult.flags & MOVERESULT_MOVEMENTWEAPON) bs->weaponnum = moveresult.weapon;\n\t//attack the enemy if possible\n\tBotCheckAttack(bs);\n\t//\n\treturn qtrue;\n}\n\n"
  },
  {
    "path": "code/game/ai_dmnet.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n/*****************************************************************************\n * name:\t\tai_dmnet.h\n *\n * desc:\t\tQuake3 bot AI\n *\n * $Archive: /source/code/botai/ai_chat.c $\n *\n *****************************************************************************/\n\n#define MAX_NODESWITCHES\t50\n\nvoid AIEnter_Intermission(bot_state_t *bs, char *s);\nvoid AIEnter_Observer(bot_state_t *bs, char *s);\nvoid AIEnter_Respawn(bot_state_t *bs, char *s);\nvoid AIEnter_Stand(bot_state_t *bs, char *s);\nvoid AIEnter_Seek_ActivateEntity(bot_state_t *bs, char *s);\nvoid AIEnter_Seek_NBG(bot_state_t *bs, char *s);\nvoid AIEnter_Seek_LTG(bot_state_t *bs, char *s);\nvoid AIEnter_Seek_Camp(bot_state_t *bs, char *s);\nvoid AIEnter_Battle_Fight(bot_state_t *bs, char *s);\nvoid AIEnter_Battle_Chase(bot_state_t *bs, char *s);\nvoid AIEnter_Battle_Retreat(bot_state_t *bs, char *s);\nvoid AIEnter_Battle_NBG(bot_state_t *bs, char *s);\nint AINode_Intermission(bot_state_t *bs);\nint AINode_Observer(bot_state_t *bs);\nint AINode_Respawn(bot_state_t *bs);\nint AINode_Stand(bot_state_t *bs);\nint AINode_Seek_ActivateEntity(bot_state_t *bs);\nint AINode_Seek_NBG(bot_state_t *bs);\nint AINode_Seek_LTG(bot_state_t *bs);\nint AINode_Battle_Fight(bot_state_t *bs);\nint AINode_Battle_Chase(bot_state_t *bs);\nint AINode_Battle_Retreat(bot_state_t *bs);\nint AINode_Battle_NBG(bot_state_t *bs);\n\nvoid BotResetNodeSwitches(void);\nvoid BotDumpNodeSwitches(bot_state_t *bs);\n\n"
  },
  {
    "path": "code/game/ai_dmq3.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n/*****************************************************************************\n * name:\t\tai_dmq3.c\n *\n * desc:\t\tQuake3 bot AI\n *\n * $Archive: /MissionPack/code/game/ai_dmq3.c $\n *\n *****************************************************************************/\n\n\n#include \"g_local.h\"\n#include \"botlib.h\"\n#include \"be_aas.h\"\n#include \"be_ea.h\"\n#include \"be_ai_char.h\"\n#include \"be_ai_chat.h\"\n#include \"be_ai_gen.h\"\n#include \"be_ai_goal.h\"\n#include \"be_ai_move.h\"\n#include \"be_ai_weap.h\"\n//\n#include \"ai_main.h\"\n#include \"ai_dmq3.h\"\n#include \"ai_chat.h\"\n#include \"ai_cmd.h\"\n#include \"ai_dmnet.h\"\n#include \"ai_team.h\"\n//\n#include \"chars.h\"\t\t\t\t//characteristics\n#include \"inv.h\"\t\t\t\t//indexes into the inventory\n#include \"syn.h\"\t\t\t\t//synonyms\n#include \"match.h\"\t\t\t\t//string matching types and vars\n\n// for the voice chats\n#include \"../../ui/menudef.h\" // sos001205 - for q3_ui also\n\n// from aasfile.h\n#define AREACONTENTS_MOVER\t\t\t\t1024\n#define AREACONTENTS_MODELNUMSHIFT\t\t24\n#define AREACONTENTS_MAXMODELNUM\t\t0xFF\n#define AREACONTENTS_MODELNUM\t\t\t(AREACONTENTS_MAXMODELNUM << AREACONTENTS_MODELNUMSHIFT)\n\n#define IDEAL_ATTACKDIST\t\t\t140\n\n#define MAX_WAYPOINTS\t\t128\n//\nbot_waypoint_t botai_waypoints[MAX_WAYPOINTS];\nbot_waypoint_t *botai_freewaypoints;\n\n//NOTE: not using a cvars which can be updated because the game should be reloaded anyway\nint gametype;\t\t//game type\nint maxclients;\t\t//maximum number of clients\n\nvmCvar_t bot_grapple;\nvmCvar_t bot_rocketjump;\nvmCvar_t bot_fastchat;\nvmCvar_t bot_nochat;\nvmCvar_t bot_testrchat;\nvmCvar_t bot_challenge;\nvmCvar_t bot_predictobstacles;\nvmCvar_t g_spSkill;\n\nextern vmCvar_t bot_developer;\n\nvec3_t lastteleport_origin;\t\t//last teleport event origin\nfloat lastteleport_time;\t\t//last teleport event time\nint max_bspmodelindex;\t\t\t//maximum BSP model index\n\n//CTF flag goals\nbot_goal_t ctf_redflag;\nbot_goal_t ctf_blueflag;\n#ifdef MISSIONPACK\nbot_goal_t ctf_neutralflag;\nbot_goal_t redobelisk;\nbot_goal_t blueobelisk;\nbot_goal_t neutralobelisk;\n#endif\n\n#define MAX_ALTROUTEGOALS\t\t32\n\nint altroutegoals_setup;\naas_altroutegoal_t red_altroutegoals[MAX_ALTROUTEGOALS];\nint red_numaltroutegoals;\naas_altroutegoal_t blue_altroutegoals[MAX_ALTROUTEGOALS];\nint blue_numaltroutegoals;\n\n\n/*\n==================\nBotSetUserInfo\n==================\n*/\nvoid BotSetUserInfo(bot_state_t *bs, char *key, char *value) {\n\tchar userinfo[MAX_INFO_STRING];\n\n\ttrap_GetUserinfo(bs->client, userinfo, sizeof(userinfo));\n\tInfo_SetValueForKey(userinfo, key, value);\n\ttrap_SetUserinfo(bs->client, userinfo);\n\tClientUserinfoChanged( bs->client );\n}\n\n/*\n==================\nBotCTFCarryingFlag\n==================\n*/\nint BotCTFCarryingFlag(bot_state_t *bs) {\n\tif (gametype != GT_CTF) return CTF_FLAG_NONE;\n\n\tif (bs->inventory[INVENTORY_REDFLAG] > 0) return CTF_FLAG_RED;\n\telse if (bs->inventory[INVENTORY_BLUEFLAG] > 0) return CTF_FLAG_BLUE;\n\treturn CTF_FLAG_NONE;\n}\n\n/*\n==================\nBotTeam\n==================\n*/\nint BotTeam(bot_state_t *bs) {\n\tchar info[1024];\n\n\tif (bs->client < 0 || bs->client >= MAX_CLIENTS) {\n\t\t//BotAI_Print(PRT_ERROR, \"BotCTFTeam: client out of range\\n\");\n\t\treturn qfalse;\n\t}\n\ttrap_GetConfigstring(CS_PLAYERS+bs->client, info, sizeof(info));\n\t//\n\tif (atoi(Info_ValueForKey(info, \"t\")) == TEAM_RED) return TEAM_RED;\n\telse if (atoi(Info_ValueForKey(info, \"t\")) == TEAM_BLUE) return TEAM_BLUE;\n\treturn TEAM_FREE;\n}\n\n/*\n==================\nBotOppositeTeam\n==================\n*/\nint BotOppositeTeam(bot_state_t *bs) {\n\tswitch(BotTeam(bs)) {\n\t\tcase TEAM_RED: return TEAM_BLUE;\n\t\tcase TEAM_BLUE: return TEAM_RED;\n\t\tdefault: return TEAM_FREE;\n\t}\n}\n\n/*\n==================\nBotEnemyFlag\n==================\n*/\nbot_goal_t *BotEnemyFlag(bot_state_t *bs) {\n\tif (BotTeam(bs) == TEAM_RED) {\n\t\treturn &ctf_blueflag;\n\t}\n\telse {\n\t\treturn &ctf_redflag;\n\t}\n}\n\n/*\n==================\nBotTeamFlag\n==================\n*/\nbot_goal_t *BotTeamFlag(bot_state_t *bs) {\n\tif (BotTeam(bs) == TEAM_RED) {\n\t\treturn &ctf_redflag;\n\t}\n\telse {\n\t\treturn &ctf_blueflag;\n\t}\n}\n\n\n/*\n==================\nEntityIsDead\n==================\n*/\nqboolean EntityIsDead(aas_entityinfo_t *entinfo) {\n\tplayerState_t ps;\n\n\tif (entinfo->number >= 0 && entinfo->number < MAX_CLIENTS) {\n\t\t//retrieve the current client state\n\t\tBotAI_GetClientState( entinfo->number, &ps );\n\t\tif (ps.pm_type != PM_NORMAL) return qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nEntityCarriesFlag\n==================\n*/\nqboolean EntityCarriesFlag(aas_entityinfo_t *entinfo) {\n\tif ( entinfo->powerups & ( 1 << PW_REDFLAG ) )\n\t\treturn qtrue;\n\tif ( entinfo->powerups & ( 1 << PW_BLUEFLAG ) )\n\t\treturn qtrue;\n#ifdef MISSIONPACK\n\tif ( entinfo->powerups & ( 1 << PW_NEUTRALFLAG ) )\n\t\treturn qtrue;\n#endif\n\treturn qfalse;\n}\n\n/*\n==================\nEntityIsInvisible\n==================\n*/\nqboolean EntityIsInvisible(aas_entityinfo_t *entinfo) {\n\t// the flag is always visible\n\tif (EntityCarriesFlag(entinfo)) {\n\t\treturn qfalse;\n\t}\n\tif (entinfo->powerups & (1 << PW_INVIS)) {\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nEntityIsShooting\n==================\n*/\nqboolean EntityIsShooting(aas_entityinfo_t *entinfo) {\n\tif (entinfo->flags & EF_FIRING) {\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nEntityIsChatting\n==================\n*/\nqboolean EntityIsChatting(aas_entityinfo_t *entinfo) {\n\tif (entinfo->flags & EF_TALK) {\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nEntityHasQuad\n==================\n*/\nqboolean EntityHasQuad(aas_entityinfo_t *entinfo) {\n\tif (entinfo->powerups & (1 << PW_QUAD)) {\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n#ifdef MISSIONPACK\n/*\n==================\nEntityHasKamikze\n==================\n*/\nqboolean EntityHasKamikaze(aas_entityinfo_t *entinfo) {\n\tif (entinfo->flags & EF_KAMIKAZE) {\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nEntityCarriesCubes\n==================\n*/\nqboolean EntityCarriesCubes(aas_entityinfo_t *entinfo) {\n\tentityState_t state;\n\n\tif (gametype != GT_HARVESTER)\n\t\treturn qfalse;\n\t//FIXME: get this info from the aas_entityinfo_t ?\n\tBotAI_GetEntityState(entinfo->number, &state);\n\tif (state.generic1 > 0)\n\t\treturn qtrue;\n\treturn qfalse;\n}\n\n/*\n==================\nBot1FCTFCarryingFlag\n==================\n*/\nint Bot1FCTFCarryingFlag(bot_state_t *bs) {\n\tif (gametype != GT_1FCTF) return qfalse;\n\n\tif (bs->inventory[INVENTORY_NEUTRALFLAG] > 0) return qtrue;\n\treturn qfalse;\n}\n\n/*\n==================\nBotHarvesterCarryingCubes\n==================\n*/\nint BotHarvesterCarryingCubes(bot_state_t *bs) {\n\tif (gametype != GT_HARVESTER) return qfalse;\n\n\tif (bs->inventory[INVENTORY_REDCUBE] > 0) return qtrue;\n\tif (bs->inventory[INVENTORY_BLUECUBE] > 0) return qtrue;\n\treturn qfalse;\n}\n#endif\n\n/*\n==================\nBotRememberLastOrderedTask\n==================\n*/\nvoid BotRememberLastOrderedTask(bot_state_t *bs) {\n\tif (!bs->ordered) {\n\t\treturn;\n\t}\n\tbs->lastgoal_decisionmaker = bs->decisionmaker;\n\tbs->lastgoal_ltgtype = bs->ltgtype;\n\tmemcpy(&bs->lastgoal_teamgoal, &bs->teamgoal, sizeof(bot_goal_t));\n\tbs->lastgoal_teammate = bs->teammate;\n}\n\n/*\n==================\nBotSetTeamStatus\n==================\n*/\nvoid BotSetTeamStatus(bot_state_t *bs) {\n#ifdef MISSIONPACK\n\tint teamtask;\n\taas_entityinfo_t entinfo;\n\n\tteamtask = TEAMTASK_PATROL;\n\n\tswitch(bs->ltgtype) {\n\t\tcase LTG_TEAMHELP:\n\t\t\tbreak;\n\t\tcase LTG_TEAMACCOMPANY:\n\t\t\tBotEntityInfo(bs->teammate, &entinfo);\n\t\t\tif ( ( (gametype == GT_CTF || gametype == GT_1FCTF) && EntityCarriesFlag(&entinfo))\n\t\t\t\t|| ( gametype == GT_HARVESTER && EntityCarriesCubes(&entinfo)) ) {\n\t\t\t\tteamtask = TEAMTASK_ESCORT;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tteamtask = TEAMTASK_FOLLOW;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase LTG_DEFENDKEYAREA:\n\t\t\tteamtask = TEAMTASK_DEFENSE;\n\t\t\tbreak;\n\t\tcase LTG_GETFLAG:\n\t\t\tteamtask = TEAMTASK_OFFENSE;\n\t\t\tbreak;\n\t\tcase LTG_RUSHBASE:\n\t\t\tteamtask = TEAMTASK_DEFENSE;\n\t\t\tbreak;\n\t\tcase LTG_RETURNFLAG:\n\t\t\tteamtask = TEAMTASK_RETRIEVE;\n\t\t\tbreak;\n\t\tcase LTG_CAMP:\n\t\tcase LTG_CAMPORDER:\n\t\t\tteamtask = TEAMTASK_CAMP;\n\t\t\tbreak;\n\t\tcase LTG_PATROL:\n\t\t\tteamtask = TEAMTASK_PATROL;\n\t\t\tbreak;\n\t\tcase LTG_GETITEM:\n\t\t\tteamtask = TEAMTASK_PATROL;\n\t\t\tbreak;\n\t\tcase LTG_KILL:\n\t\t\tteamtask = TEAMTASK_PATROL;\n\t\t\tbreak;\n\t\tcase LTG_HARVEST:\n\t\t\tteamtask = TEAMTASK_OFFENSE;\n\t\t\tbreak;\n\t\tcase LTG_ATTACKENEMYBASE:\n\t\t\tteamtask = TEAMTASK_OFFENSE;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tteamtask = TEAMTASK_PATROL;\n\t\t\tbreak;\n\t}\n\tBotSetUserInfo(bs, \"teamtask\", va(\"%d\", teamtask));\n#endif\n}\n\n/*\n==================\nBotSetLastOrderedTask\n==================\n*/\nint BotSetLastOrderedTask(bot_state_t *bs) {\n\n\tif (gametype == GT_CTF) {\n\t\t// don't go back to returning the flag if it's at the base\n\t\tif ( bs->lastgoal_ltgtype == LTG_RETURNFLAG ) {\n\t\t\tif ( BotTeam(bs) == TEAM_RED ) {\n\t\t\t\tif ( bs->redflagstatus == 0 ) {\n\t\t\t\t\tbs->lastgoal_ltgtype = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif ( bs->blueflagstatus == 0 ) {\n\t\t\t\t\tbs->lastgoal_ltgtype = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( bs->lastgoal_ltgtype ) {\n\t\tbs->decisionmaker = bs->lastgoal_decisionmaker;\n\t\tbs->ordered = qtrue;\n\t\tbs->ltgtype = bs->lastgoal_ltgtype;\n\t\tmemcpy(&bs->teamgoal, &bs->lastgoal_teamgoal, sizeof(bot_goal_t));\n\t\tbs->teammate = bs->lastgoal_teammate;\n\t\tbs->teamgoal_time = FloatTime() + 300;\n\t\tBotSetTeamStatus(bs);\n\t\t//\n\t\tif ( gametype == GT_CTF ) {\n\t\t\tif ( bs->ltgtype == LTG_GETFLAG ) {\n\t\t\t\tbot_goal_t *tb, *eb;\n\t\t\t\tint tt, et;\n\n\t\t\t\ttb = BotTeamFlag(bs);\n\t\t\t\teb = BotEnemyFlag(bs);\n\t\t\t\ttt = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, tb->areanum, TFL_DEFAULT);\n\t\t\t\tet = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, eb->areanum, TFL_DEFAULT);\n\t\t\t\t// if the travel time towards the enemy base is larger than towards our base\n\t\t\t\tif (et > tt) {\n\t\t\t\t\t//get an alternative route goal towards the enemy base\n\t\t\t\t\tBotGetAlternateRouteGoal(bs, BotOppositeTeam(bs));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nBotRefuseOrder\n==================\n*/\nvoid BotRefuseOrder(bot_state_t *bs) {\n\tif (!bs->ordered)\n\t\treturn;\n\t// if the bot was ordered to do something\n\tif ( bs->order_time && bs->order_time > FloatTime() - 10 ) {\n\t\ttrap_EA_Action(bs->client, ACTION_NEGATIVE);\n\t\tBotVoiceChat(bs, bs->decisionmaker, VOICECHAT_NO);\n\t\tbs->order_time = 0;\n\t}\n}\n\n/*\n==================\nBotCTFSeekGoals\n==================\n*/\nvoid BotCTFSeekGoals(bot_state_t *bs) {\n\tfloat rnd, l1, l2;\n\tint flagstatus, c;\n\tvec3_t dir;\n\taas_entityinfo_t entinfo;\n\n\t//when carrying a flag in ctf the bot should rush to the base\n\tif (BotCTFCarryingFlag(bs)) {\n\t\t//if not already rushing to the base\n\t\tif (bs->ltgtype != LTG_RUSHBASE) {\n\t\t\tBotRefuseOrder(bs);\n\t\t\tbs->ltgtype = LTG_RUSHBASE;\n\t\t\tbs->teamgoal_time = FloatTime() + CTF_RUSHBASE_TIME;\n\t\t\tbs->rushbaseaway_time = 0;\n\t\t\tbs->decisionmaker = bs->client;\n\t\t\tbs->ordered = qfalse;\n\t\t\t//\n\t\t\tswitch(BotTeam(bs)) {\n\t\t\t\tcase TEAM_RED: VectorSubtract(bs->origin, ctf_blueflag.origin, dir); break;\n\t\t\t\tcase TEAM_BLUE: VectorSubtract(bs->origin, ctf_redflag.origin, dir); break;\n\t\t\t\tdefault: VectorSet(dir, 999, 999, 999); break;\n\t\t\t}\n\t\t\t// if the bot picked up the flag very close to the enemy base\n\t\t\tif ( VectorLength(dir) < 128 ) {\n\t\t\t\t// get an alternative route goal through the enemy base\n\t\t\t\tBotGetAlternateRouteGoal(bs, BotOppositeTeam(bs));\n\t\t\t} else {\n\t\t\t\t// don't use any alt route goal, just get the hell out of the base\n\t\t\t\tbs->altroutegoal.areanum = 0;\n\t\t\t}\n\t\t\tBotSetUserInfo(bs, \"teamtask\", va(\"%d\", TEAMTASK_OFFENSE));\n\t\t\tBotVoiceChat(bs, -1, VOICECHAT_IHAVEFLAG);\n\t\t}\n\t\telse if (bs->rushbaseaway_time > FloatTime()) {\n\t\t\tif (BotTeam(bs) == TEAM_RED) flagstatus = bs->redflagstatus;\n\t\t\telse flagstatus = bs->blueflagstatus;\n\t\t\t//if the flag is back\n\t\t\tif (flagstatus == 0) {\n\t\t\t\tbs->rushbaseaway_time = 0;\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\t// if the bot decided to follow someone\n\tif ( bs->ltgtype == LTG_TEAMACCOMPANY && !bs->ordered ) {\n\t\t// if the team mate being accompanied no longer carries the flag\n\t\tBotEntityInfo(bs->teammate, &entinfo);\n\t\tif (!EntityCarriesFlag(&entinfo)) {\n\t\t\tbs->ltgtype = 0;\n\t\t}\n\t}\n\t//\n\tif (BotTeam(bs) == TEAM_RED) flagstatus = bs->redflagstatus * 2 + bs->blueflagstatus;\n\telse flagstatus = bs->blueflagstatus * 2 + bs->redflagstatus;\n\t//if our team has the enemy flag and our flag is at the base\n\tif (flagstatus == 1) {\n\t\t//\n\t\tif (bs->owndecision_time < FloatTime()) {\n\t\t\t//if Not defending the base already\n\t\t\tif (!(bs->ltgtype == LTG_DEFENDKEYAREA &&\n\t\t\t\t\t(bs->teamgoal.number == ctf_redflag.number ||\n\t\t\t\t\tbs->teamgoal.number == ctf_blueflag.number))) {\n\t\t\t\t//if there is a visible team mate flag carrier\n\t\t\t\tc = BotTeamFlagCarrierVisible(bs);\n\t\t\t\tif (c >= 0 &&\n\t\t\t\t\t\t// and not already following the team mate flag carrier\n\t\t\t\t\t\t(bs->ltgtype != LTG_TEAMACCOMPANY || bs->teammate != c)) {\n\t\t\t\t\t//\n\t\t\t\t\tBotRefuseOrder(bs);\n\t\t\t\t\t//follow the flag carrier\n\t\t\t\t\tbs->decisionmaker = bs->client;\n\t\t\t\t\tbs->ordered = qfalse;\n\t\t\t\t\t//the team mate\n\t\t\t\t\tbs->teammate = c;\n\t\t\t\t\t//last time the team mate was visible\n\t\t\t\t\tbs->teammatevisible_time = FloatTime();\n\t\t\t\t\t//no message\n\t\t\t\t\tbs->teammessage_time = 0;\n\t\t\t\t\t//no arrive message\n\t\t\t\t\tbs->arrive_time = 1;\n\t\t\t\t\t//\n\t\t\t\t\tBotVoiceChat(bs, bs->teammate, VOICECHAT_ONFOLLOW);\n\t\t\t\t\t//get the team goal time\n\t\t\t\t\tbs->teamgoal_time = FloatTime() + TEAM_ACCOMPANY_TIME;\n\t\t\t\t\tbs->ltgtype = LTG_TEAMACCOMPANY;\n\t\t\t\t\tbs->formation_dist = 3.5 * 32;\t\t//3.5 meter\n\t\t\t\t\tBotSetTeamStatus(bs);\n\t\t\t\t\tbs->owndecision_time = FloatTime() + 5;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\t//if the enemy has our flag\n\telse if (flagstatus == 2) {\n\t\t//\n\t\tif (bs->owndecision_time < FloatTime()) {\n\t\t\t//if enemy flag carrier is visible\n\t\t\tc = BotEnemyFlagCarrierVisible(bs);\n\t\t\tif (c >= 0) {\n\t\t\t\t//FIXME: fight enemy flag carrier\n\t\t\t}\n\t\t\t//if not already doing something important\n\t\t\tif (bs->ltgtype != LTG_GETFLAG &&\n\t\t\t\tbs->ltgtype != LTG_RETURNFLAG &&\n\t\t\t\tbs->ltgtype != LTG_TEAMHELP &&\n\t\t\t\tbs->ltgtype != LTG_TEAMACCOMPANY &&\n\t\t\t\tbs->ltgtype != LTG_CAMPORDER &&\n\t\t\t\tbs->ltgtype != LTG_PATROL &&\n\t\t\t\tbs->ltgtype != LTG_GETITEM) {\n\n\t\t\t\tBotRefuseOrder(bs);\n\t\t\t\tbs->decisionmaker = bs->client;\n\t\t\t\tbs->ordered = qfalse;\n\t\t\t\t//\n\t\t\t\tif (random() < 0.5) {\n\t\t\t\t\t//go for the enemy flag\n\t\t\t\t\tbs->ltgtype = LTG_GETFLAG;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tbs->ltgtype = LTG_RETURNFLAG;\n\t\t\t\t}\n\t\t\t\t//no team message\n\t\t\t\tbs->teammessage_time = 0;\n\t\t\t\t//set the time the bot will stop getting the flag\n\t\t\t\tbs->teamgoal_time = FloatTime() + CTF_GETFLAG_TIME;\n\t\t\t\t//get an alternative route goal towards the enemy base\n\t\t\t\tBotGetAlternateRouteGoal(bs, BotOppositeTeam(bs));\n\t\t\t\t//\n\t\t\t\tBotSetTeamStatus(bs);\n\t\t\t\tbs->owndecision_time = FloatTime() + 5;\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\t//if both flags Not at their bases\n\telse if (flagstatus == 3) {\n\t\t//\n\t\tif (bs->owndecision_time < FloatTime()) {\n\t\t\t// if not trying to return the flag and not following the team flag carrier\n\t\t\tif ( bs->ltgtype != LTG_RETURNFLAG && bs->ltgtype != LTG_TEAMACCOMPANY ) {\n\t\t\t\t//\n\t\t\t\tc = BotTeamFlagCarrierVisible(bs);\n\t\t\t\t// if there is a visible team mate flag carrier\n\t\t\t\tif (c >= 0) {\n\t\t\t\t\tBotRefuseOrder(bs);\n\t\t\t\t\t//follow the flag carrier\n\t\t\t\t\tbs->decisionmaker = bs->client;\n\t\t\t\t\tbs->ordered = qfalse;\n\t\t\t\t\t//the team mate\n\t\t\t\t\tbs->teammate = c;\n\t\t\t\t\t//last time the team mate was visible\n\t\t\t\t\tbs->teammatevisible_time = FloatTime();\n\t\t\t\t\t//no message\n\t\t\t\t\tbs->teammessage_time = 0;\n\t\t\t\t\t//no arrive message\n\t\t\t\t\tbs->arrive_time = 1;\n\t\t\t\t\t//\n\t\t\t\t\tBotVoiceChat(bs, bs->teammate, VOICECHAT_ONFOLLOW);\n\t\t\t\t\t//get the team goal time\n\t\t\t\t\tbs->teamgoal_time = FloatTime() + TEAM_ACCOMPANY_TIME;\n\t\t\t\t\tbs->ltgtype = LTG_TEAMACCOMPANY;\n\t\t\t\t\tbs->formation_dist = 3.5 * 32;\t\t//3.5 meter\n\t\t\t\t\t//\n\t\t\t\t\tBotSetTeamStatus(bs);\n\t\t\t\t\tbs->owndecision_time = FloatTime() + 5;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tBotRefuseOrder(bs);\n\t\t\t\t\tbs->decisionmaker = bs->client;\n\t\t\t\t\tbs->ordered = qfalse;\n\t\t\t\t\t//get the enemy flag\n\t\t\t\t\tbs->teammessage_time = FloatTime() + 2 * random();\n\t\t\t\t\t//get the flag\n\t\t\t\t\tbs->ltgtype = LTG_RETURNFLAG;\n\t\t\t\t\t//set the time the bot will stop getting the flag\n\t\t\t\t\tbs->teamgoal_time = FloatTime() + CTF_RETURNFLAG_TIME;\n\t\t\t\t\t//get an alternative route goal towards the enemy base\n\t\t\t\t\tBotGetAlternateRouteGoal(bs, BotOppositeTeam(bs));\n\t\t\t\t\t//\n\t\t\t\t\tBotSetTeamStatus(bs);\n\t\t\t\t\tbs->owndecision_time = FloatTime() + 5;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\t// don't just do something wait for the bot team leader to give orders\n\tif (BotTeamLeader(bs)) {\n\t\treturn;\n\t}\n\t// if the bot is ordered to do something\n\tif ( bs->lastgoal_ltgtype ) {\n\t\tbs->teamgoal_time += 60;\n\t}\n\t// if the bot decided to do something on it's own and has a last ordered goal\n\tif ( !bs->ordered && bs->lastgoal_ltgtype ) {\n\t\tbs->ltgtype = 0;\n\t}\n\t//if already a CTF or team goal\n\tif (bs->ltgtype == LTG_TEAMHELP ||\n\t\t\tbs->ltgtype == LTG_TEAMACCOMPANY ||\n\t\t\tbs->ltgtype == LTG_DEFENDKEYAREA ||\n\t\t\tbs->ltgtype == LTG_GETFLAG ||\n\t\t\tbs->ltgtype == LTG_RUSHBASE ||\n\t\t\tbs->ltgtype == LTG_RETURNFLAG ||\n\t\t\tbs->ltgtype == LTG_CAMPORDER ||\n\t\t\tbs->ltgtype == LTG_PATROL ||\n\t\t\tbs->ltgtype == LTG_GETITEM ||\n\t\t\tbs->ltgtype == LTG_MAKELOVE_UNDER ||\n\t\t\tbs->ltgtype == LTG_MAKELOVE_ONTOP) {\n\t\treturn;\n\t}\n\t//\n\tif (BotSetLastOrderedTask(bs))\n\t\treturn;\n\t//\n\tif (bs->owndecision_time > FloatTime())\n\t\treturn;;\n\t//if the bot is roaming\n\tif (bs->ctfroam_time > FloatTime())\n\t\treturn;\n\t//if the bot has anough aggression to decide what to do\n\tif (BotAggression(bs) < 50)\n\t\treturn;\n\t//set the time to send a message to the team mates\n\tbs->teammessage_time = FloatTime() + 2 * random();\n\t//\n\tif (bs->teamtaskpreference & (TEAMTP_ATTACKER|TEAMTP_DEFENDER)) {\n\t\tif (bs->teamtaskpreference & TEAMTP_ATTACKER) {\n\t\t\tl1 = 0.7f;\n\t\t}\n\t\telse {\n\t\t\tl1 = 0.2f;\n\t\t}\n\t\tl2 = 0.9f;\n\t}\n\telse {\n\t\tl1 = 0.4f;\n\t\tl2 = 0.7f;\n\t}\n\t//get the flag or defend the base\n\trnd = random();\n\tif (rnd < l1 && ctf_redflag.areanum && ctf_blueflag.areanum) {\n\t\tbs->decisionmaker = bs->client;\n\t\tbs->ordered = qfalse;\n\t\tbs->ltgtype = LTG_GETFLAG;\n\t\t//set the time the bot will stop getting the flag\n\t\tbs->teamgoal_time = FloatTime() + CTF_GETFLAG_TIME;\n\t\t//get an alternative route goal towards the enemy base\n\t\tBotGetAlternateRouteGoal(bs, BotOppositeTeam(bs));\n\t\tBotSetTeamStatus(bs);\n\t}\n\telse if (rnd < l2 && ctf_redflag.areanum && ctf_blueflag.areanum) {\n\t\tbs->decisionmaker = bs->client;\n\t\tbs->ordered = qfalse;\n\t\t//\n\t\tif (BotTeam(bs) == TEAM_RED) memcpy(&bs->teamgoal, &ctf_redflag, sizeof(bot_goal_t));\n\t\telse memcpy(&bs->teamgoal, &ctf_blueflag, sizeof(bot_goal_t));\n\t\t//set the ltg type\n\t\tbs->ltgtype = LTG_DEFENDKEYAREA;\n\t\t//set the time the bot stops defending the base\n\t\tbs->teamgoal_time = FloatTime() + TEAM_DEFENDKEYAREA_TIME;\n\t\tbs->defendaway_time = 0;\n\t\tBotSetTeamStatus(bs);\n\t}\n\telse {\n\t\tbs->ltgtype = 0;\n\t\t//set the time the bot will stop roaming\n\t\tbs->ctfroam_time = FloatTime() + CTF_ROAM_TIME;\n\t\tBotSetTeamStatus(bs);\n\t}\n\tbs->owndecision_time = FloatTime() + 5;\n#ifdef DEBUG\n\tBotPrintTeamGoal(bs);\n#endif //DEBUG\n}\n\n/*\n==================\nBotCTFRetreatGoals\n==================\n*/\nvoid BotCTFRetreatGoals(bot_state_t *bs) {\n\t//when carrying a flag in ctf the bot should rush to the base\n\tif (BotCTFCarryingFlag(bs)) {\n\t\t//if not already rushing to the base\n\t\tif (bs->ltgtype != LTG_RUSHBASE) {\n\t\t\tBotRefuseOrder(bs);\n\t\t\tbs->ltgtype = LTG_RUSHBASE;\n\t\t\tbs->teamgoal_time = FloatTime() + CTF_RUSHBASE_TIME;\n\t\t\tbs->rushbaseaway_time = 0;\n\t\t\tbs->decisionmaker = bs->client;\n\t\t\tbs->ordered = qfalse;\n\t\t\tBotSetTeamStatus(bs);\n\t\t}\n\t}\n}\n\n#ifdef MISSIONPACK\n/*\n==================\nBot1FCTFSeekGoals\n==================\n*/\nvoid Bot1FCTFSeekGoals(bot_state_t *bs) {\n\taas_entityinfo_t entinfo;\n\tfloat rnd, l1, l2;\n\tint c;\n\n\t//when carrying a flag in ctf the bot should rush to the base\n\tif (Bot1FCTFCarryingFlag(bs)) {\n\t\t//if not already rushing to the base\n\t\tif (bs->ltgtype != LTG_RUSHBASE) {\n\t\t\tBotRefuseOrder(bs);\n\t\t\tbs->ltgtype = LTG_RUSHBASE;\n\t\t\tbs->teamgoal_time = FloatTime() + CTF_RUSHBASE_TIME;\n\t\t\tbs->rushbaseaway_time = 0;\n\t\t\tbs->decisionmaker = bs->client;\n\t\t\tbs->ordered = qfalse;\n\t\t\t//get an alternative route goal towards the enemy base\n\t\t\tBotGetAlternateRouteGoal(bs, BotOppositeTeam(bs));\n\t\t\t//\n\t\t\tBotSetTeamStatus(bs);\n\t\t\tBotVoiceChat(bs, -1, VOICECHAT_IHAVEFLAG);\n\t\t}\n\t\treturn;\n\t}\n\t// if the bot decided to follow someone\n\tif ( bs->ltgtype == LTG_TEAMACCOMPANY && !bs->ordered ) {\n\t\t// if the team mate being accompanied no longer carries the flag\n\t\tBotEntityInfo(bs->teammate, &entinfo);\n\t\tif (!EntityCarriesFlag(&entinfo)) {\n\t\t\tbs->ltgtype = 0;\n\t\t}\n\t}\n\t//our team has the flag\n\tif (bs->neutralflagstatus == 1) {\n\t\tif (bs->owndecision_time < FloatTime()) {\n\t\t\t// if not already following someone\n\t\t\tif (bs->ltgtype != LTG_TEAMACCOMPANY) {\n\t\t\t\t//if there is a visible team mate flag carrier\n\t\t\t\tc = BotTeamFlagCarrierVisible(bs);\n\t\t\t\tif (c >= 0) {\n\t\t\t\t\tBotRefuseOrder(bs);\n\t\t\t\t\t//follow the flag carrier\n\t\t\t\t\tbs->decisionmaker = bs->client;\n\t\t\t\t\tbs->ordered = qfalse;\n\t\t\t\t\t//the team mate\n\t\t\t\t\tbs->teammate = c;\n\t\t\t\t\t//last time the team mate was visible\n\t\t\t\t\tbs->teammatevisible_time = FloatTime();\n\t\t\t\t\t//no message\n\t\t\t\t\tbs->teammessage_time = 0;\n\t\t\t\t\t//no arrive message\n\t\t\t\t\tbs->arrive_time = 1;\n\t\t\t\t\t//\n\t\t\t\t\tBotVoiceChat(bs, bs->teammate, VOICECHAT_ONFOLLOW);\n\t\t\t\t\t//get the team goal time\n\t\t\t\t\tbs->teamgoal_time = FloatTime() + TEAM_ACCOMPANY_TIME;\n\t\t\t\t\tbs->ltgtype = LTG_TEAMACCOMPANY;\n\t\t\t\t\tbs->formation_dist = 3.5 * 32;\t\t//3.5 meter\n\t\t\t\t\tBotSetTeamStatus(bs);\n\t\t\t\t\tbs->owndecision_time = FloatTime() + 5;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\t//if already a CTF or team goal\n\t\t\tif (bs->ltgtype == LTG_TEAMHELP ||\n\t\t\t\t\tbs->ltgtype == LTG_TEAMACCOMPANY ||\n\t\t\t\t\tbs->ltgtype == LTG_DEFENDKEYAREA ||\n\t\t\t\t\tbs->ltgtype == LTG_GETFLAG ||\n\t\t\t\t\tbs->ltgtype == LTG_RUSHBASE ||\n\t\t\t\t\tbs->ltgtype == LTG_CAMPORDER ||\n\t\t\t\t\tbs->ltgtype == LTG_PATROL ||\n\t\t\t\t\tbs->ltgtype == LTG_ATTACKENEMYBASE ||\n\t\t\t\t\tbs->ltgtype == LTG_GETITEM ||\n\t\t\t\t\tbs->ltgtype == LTG_MAKELOVE_UNDER ||\n\t\t\t\t\tbs->ltgtype == LTG_MAKELOVE_ONTOP) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t//if not already attacking the enemy base\n\t\t\tif (bs->ltgtype != LTG_ATTACKENEMYBASE) {\n\t\t\t\tBotRefuseOrder(bs);\n\t\t\t\tbs->decisionmaker = bs->client;\n\t\t\t\tbs->ordered = qfalse;\n\t\t\t\t//\n\t\t\t\tif (BotTeam(bs) == TEAM_RED) memcpy(&bs->teamgoal, &ctf_blueflag, sizeof(bot_goal_t));\n\t\t\t\telse memcpy(&bs->teamgoal, &ctf_redflag, sizeof(bot_goal_t));\n\t\t\t\t//set the ltg type\n\t\t\t\tbs->ltgtype = LTG_ATTACKENEMYBASE;\n\t\t\t\t//set the time the bot will stop getting the flag\n\t\t\t\tbs->teamgoal_time = FloatTime() + TEAM_ATTACKENEMYBASE_TIME;\n\t\t\t\tBotSetTeamStatus(bs);\n\t\t\t\tbs->owndecision_time = FloatTime() + 5;\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\t//enemy team has the flag\n\telse if (bs->neutralflagstatus == 2) {\n\t\tif (bs->owndecision_time < FloatTime()) {\n\t\t\tc = BotEnemyFlagCarrierVisible(bs);\n\t\t\tif (c >= 0) {\n\t\t\t\t//FIXME: attack enemy flag carrier\n\t\t\t}\n\t\t\t//if already a CTF or team goal\n\t\t\tif (bs->ltgtype == LTG_TEAMHELP ||\n\t\t\t\t\tbs->ltgtype == LTG_TEAMACCOMPANY ||\n\t\t\t\t\tbs->ltgtype == LTG_CAMPORDER ||\n\t\t\t\t\tbs->ltgtype == LTG_PATROL ||\n\t\t\t\t\tbs->ltgtype == LTG_GETITEM) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// if not already defending the base\n\t\t\tif (bs->ltgtype != LTG_DEFENDKEYAREA) {\n\t\t\t\tBotRefuseOrder(bs);\n\t\t\t\tbs->decisionmaker = bs->client;\n\t\t\t\tbs->ordered = qfalse;\n\t\t\t\t//\n\t\t\t\tif (BotTeam(bs) == TEAM_RED) memcpy(&bs->teamgoal, &ctf_redflag, sizeof(bot_goal_t));\n\t\t\t\telse memcpy(&bs->teamgoal, &ctf_blueflag, sizeof(bot_goal_t));\n\t\t\t\t//set the ltg type\n\t\t\t\tbs->ltgtype = LTG_DEFENDKEYAREA;\n\t\t\t\t//set the time the bot stops defending the base\n\t\t\t\tbs->teamgoal_time = FloatTime() + TEAM_DEFENDKEYAREA_TIME;\n\t\t\t\tbs->defendaway_time = 0;\n\t\t\t\tBotSetTeamStatus(bs);\n\t\t\t\tbs->owndecision_time = FloatTime() + 5;\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\t// don't just do something wait for the bot team leader to give orders\n\tif (BotTeamLeader(bs)) {\n\t\treturn;\n\t}\n\t// if the bot is ordered to do something\n\tif ( bs->lastgoal_ltgtype ) {\n\t\tbs->teamgoal_time += 60;\n\t}\n\t// if the bot decided to do something on it's own and has a last ordered goal\n\tif ( !bs->ordered && bs->lastgoal_ltgtype ) {\n\t\tbs->ltgtype = 0;\n\t}\n\t//if already a CTF or team goal\n\tif (bs->ltgtype == LTG_TEAMHELP ||\n\t\t\tbs->ltgtype == LTG_TEAMACCOMPANY ||\n\t\t\tbs->ltgtype == LTG_DEFENDKEYAREA ||\n\t\t\tbs->ltgtype == LTG_GETFLAG ||\n\t\t\tbs->ltgtype == LTG_RUSHBASE ||\n\t\t\tbs->ltgtype == LTG_RETURNFLAG ||\n\t\t\tbs->ltgtype == LTG_CAMPORDER ||\n\t\t\tbs->ltgtype == LTG_PATROL ||\n\t\t\tbs->ltgtype == LTG_ATTACKENEMYBASE ||\n\t\t\tbs->ltgtype == LTG_GETITEM ||\n\t\t\tbs->ltgtype == LTG_MAKELOVE_UNDER ||\n\t\t\tbs->ltgtype == LTG_MAKELOVE_ONTOP) {\n\t\treturn;\n\t}\n\t//\n\tif (BotSetLastOrderedTask(bs))\n\t\treturn;\n\t//\n\tif (bs->owndecision_time > FloatTime())\n\t\treturn;;\n\t//if the bot is roaming\n\tif (bs->ctfroam_time > FloatTime())\n\t\treturn;\n\t//if the bot has anough aggression to decide what to do\n\tif (BotAggression(bs) < 50)\n\t\treturn;\n\t//set the time to send a message to the team mates\n\tbs->teammessage_time = FloatTime() + 2 * random();\n\t//\n\tif (bs->teamtaskpreference & (TEAMTP_ATTACKER|TEAMTP_DEFENDER)) {\n\t\tif (bs->teamtaskpreference & TEAMTP_ATTACKER) {\n\t\t\tl1 = 0.7f;\n\t\t}\n\t\telse {\n\t\t\tl1 = 0.2f;\n\t\t}\n\t\tl2 = 0.9f;\n\t}\n\telse {\n\t\tl1 = 0.4f;\n\t\tl2 = 0.7f;\n\t}\n\t//get the flag or defend the base\n\trnd = random();\n\tif (rnd < l1 && ctf_neutralflag.areanum) {\n\t\tbs->decisionmaker = bs->client;\n\t\tbs->ordered = qfalse;\n\t\tbs->ltgtype = LTG_GETFLAG;\n\t\t//set the time the bot will stop getting the flag\n\t\tbs->teamgoal_time = FloatTime() + CTF_GETFLAG_TIME;\n\t\tBotSetTeamStatus(bs);\n\t}\n\telse if (rnd < l2 && ctf_redflag.areanum && ctf_blueflag.areanum) {\n\t\tbs->decisionmaker = bs->client;\n\t\tbs->ordered = qfalse;\n\t\t//\n\t\tif (BotTeam(bs) == TEAM_RED) memcpy(&bs->teamgoal, &ctf_redflag, sizeof(bot_goal_t));\n\t\telse memcpy(&bs->teamgoal, &ctf_blueflag, sizeof(bot_goal_t));\n\t\t//set the ltg type\n\t\tbs->ltgtype = LTG_DEFENDKEYAREA;\n\t\t//set the time the bot stops defending the base\n\t\tbs->teamgoal_time = FloatTime() + TEAM_DEFENDKEYAREA_TIME;\n\t\tbs->defendaway_time = 0;\n\t\tBotSetTeamStatus(bs);\n\t}\n\telse {\n\t\tbs->ltgtype = 0;\n\t\t//set the time the bot will stop roaming\n\t\tbs->ctfroam_time = FloatTime() + CTF_ROAM_TIME;\n\t\tBotSetTeamStatus(bs);\n\t}\n\tbs->owndecision_time = FloatTime() + 5;\n#ifdef DEBUG\n\tBotPrintTeamGoal(bs);\n#endif //DEBUG\n}\n\n/*\n==================\nBot1FCTFRetreatGoals\n==================\n*/\nvoid Bot1FCTFRetreatGoals(bot_state_t *bs) {\n\t//when carrying a flag in ctf the bot should rush to the enemy base\n\tif (Bot1FCTFCarryingFlag(bs)) {\n\t\t//if not already rushing to the base\n\t\tif (bs->ltgtype != LTG_RUSHBASE) {\n\t\t\tBotRefuseOrder(bs);\n\t\t\tbs->ltgtype = LTG_RUSHBASE;\n\t\t\tbs->teamgoal_time = FloatTime() + CTF_RUSHBASE_TIME;\n\t\t\tbs->rushbaseaway_time = 0;\n\t\t\tbs->decisionmaker = bs->client;\n\t\t\tbs->ordered = qfalse;\n\t\t\t//get an alternative route goal towards the enemy base\n\t\t\tBotGetAlternateRouteGoal(bs, BotOppositeTeam(bs));\n\t\t\tBotSetTeamStatus(bs);\n\t\t}\n\t}\n}\n\n/*\n==================\nBotObeliskSeekGoals\n==================\n*/\nvoid BotObeliskSeekGoals(bot_state_t *bs) {\n\tfloat rnd, l1, l2;\n\n\t// don't just do something wait for the bot team leader to give orders\n\tif (BotTeamLeader(bs)) {\n\t\treturn;\n\t}\n\t// if the bot is ordered to do something\n\tif ( bs->lastgoal_ltgtype ) {\n\t\tbs->teamgoal_time += 60;\n\t}\n\t//if already a team goal\n\tif (bs->ltgtype == LTG_TEAMHELP ||\n\t\t\tbs->ltgtype == LTG_TEAMACCOMPANY ||\n\t\t\tbs->ltgtype == LTG_DEFENDKEYAREA ||\n\t\t\tbs->ltgtype == LTG_GETFLAG ||\n\t\t\tbs->ltgtype == LTG_RUSHBASE ||\n\t\t\tbs->ltgtype == LTG_RETURNFLAG ||\n\t\t\tbs->ltgtype == LTG_CAMPORDER ||\n\t\t\tbs->ltgtype == LTG_PATROL ||\n\t\t\tbs->ltgtype == LTG_ATTACKENEMYBASE ||\n\t\t\tbs->ltgtype == LTG_GETITEM ||\n\t\t\tbs->ltgtype == LTG_MAKELOVE_UNDER ||\n\t\t\tbs->ltgtype == LTG_MAKELOVE_ONTOP) {\n\t\treturn;\n\t}\n\t//\n\tif (BotSetLastOrderedTask(bs))\n\t\treturn;\n\t//if the bot is roaming\n\tif (bs->ctfroam_time > FloatTime())\n\t\treturn;\n\t//if the bot has anough aggression to decide what to do\n\tif (BotAggression(bs) < 50)\n\t\treturn;\n\t//set the time to send a message to the team mates\n\tbs->teammessage_time = FloatTime() + 2 * random();\n\t//\n\tif (bs->teamtaskpreference & (TEAMTP_ATTACKER|TEAMTP_DEFENDER)) {\n\t\tif (bs->teamtaskpreference & TEAMTP_ATTACKER) {\n\t\t\tl1 = 0.7f;\n\t\t}\n\t\telse {\n\t\t\tl1 = 0.2f;\n\t\t}\n\t\tl2 = 0.9f;\n\t}\n\telse {\n\t\tl1 = 0.4f;\n\t\tl2 = 0.7f;\n\t}\n\t//get the flag or defend the base\n\trnd = random();\n\tif (rnd < l1 && redobelisk.areanum && blueobelisk.areanum) {\n\t\tbs->decisionmaker = bs->client;\n\t\tbs->ordered = qfalse;\n\t\t//\n\t\tif (BotTeam(bs) == TEAM_RED) memcpy(&bs->teamgoal, &blueobelisk, sizeof(bot_goal_t));\n\t\telse memcpy(&bs->teamgoal, &redobelisk, sizeof(bot_goal_t));\n\t\t//set the ltg type\n\t\tbs->ltgtype = LTG_ATTACKENEMYBASE;\n\t\t//set the time the bot will stop attacking the enemy base\n\t\tbs->teamgoal_time = FloatTime() + TEAM_ATTACKENEMYBASE_TIME;\n\t\t//get an alternate route goal towards the enemy base\n\t\tBotGetAlternateRouteGoal(bs, BotOppositeTeam(bs));\n\t\tBotSetTeamStatus(bs);\n\t}\n\telse if (rnd < l2 && redobelisk.areanum && blueobelisk.areanum) {\n\t\tbs->decisionmaker = bs->client;\n\t\tbs->ordered = qfalse;\n\t\t//\n\t\tif (BotTeam(bs) == TEAM_RED) memcpy(&bs->teamgoal, &redobelisk, sizeof(bot_goal_t));\n\t\telse memcpy(&bs->teamgoal, &blueobelisk, sizeof(bot_goal_t));\n\t\t//set the ltg type\n\t\tbs->ltgtype = LTG_DEFENDKEYAREA;\n\t\t//set the time the bot stops defending the base\n\t\tbs->teamgoal_time = FloatTime() + TEAM_DEFENDKEYAREA_TIME;\n\t\tbs->defendaway_time = 0;\n\t\tBotSetTeamStatus(bs);\n\t}\n\telse {\n\t\tbs->ltgtype = 0;\n\t\t//set the time the bot will stop roaming\n\t\tbs->ctfroam_time = FloatTime() + CTF_ROAM_TIME;\n\t\tBotSetTeamStatus(bs);\n\t}\n}\n\n/*\n==================\nBotGoHarvest\n==================\n*/\nvoid BotGoHarvest(bot_state_t *bs) {\n\t//\n\tif (BotTeam(bs) == TEAM_RED) memcpy(&bs->teamgoal, &blueobelisk, sizeof(bot_goal_t));\n\telse memcpy(&bs->teamgoal, &redobelisk, sizeof(bot_goal_t));\n\t//set the ltg type\n\tbs->ltgtype = LTG_HARVEST;\n\t//set the time the bot will stop harvesting\n\tbs->teamgoal_time = FloatTime() + TEAM_HARVEST_TIME;\n\tbs->harvestaway_time = 0;\n\tBotSetTeamStatus(bs);\n}\n\n/*\n==================\nBotObeliskRetreatGoals\n==================\n*/\nvoid BotObeliskRetreatGoals(bot_state_t *bs) {\n\t//nothing special\n}\n\n/*\n==================\nBotHarvesterSeekGoals\n==================\n*/\nvoid BotHarvesterSeekGoals(bot_state_t *bs) {\n\taas_entityinfo_t entinfo;\n\tfloat rnd, l1, l2;\n\tint c;\n\n\t//when carrying cubes in harvester the bot should rush to the base\n\tif (BotHarvesterCarryingCubes(bs)) {\n\t\t//if not already rushing to the base\n\t\tif (bs->ltgtype != LTG_RUSHBASE) {\n\t\t\tBotRefuseOrder(bs);\n\t\t\tbs->ltgtype = LTG_RUSHBASE;\n\t\t\tbs->teamgoal_time = FloatTime() + CTF_RUSHBASE_TIME;\n\t\t\tbs->rushbaseaway_time = 0;\n\t\t\tbs->decisionmaker = bs->client;\n\t\t\tbs->ordered = qfalse;\n\t\t\t//get an alternative route goal towards the enemy base\n\t\t\tBotGetAlternateRouteGoal(bs, BotOppositeTeam(bs));\n\t\t\t//\n\t\t\tBotSetTeamStatus(bs);\n\t\t}\n\t\treturn;\n\t}\n\t// don't just do something wait for the bot team leader to give orders\n\tif (BotTeamLeader(bs)) {\n\t\treturn;\n\t}\n\t// if the bot decided to follow someone\n\tif ( bs->ltgtype == LTG_TEAMACCOMPANY && !bs->ordered ) {\n\t\t// if the team mate being accompanied no longer carries the flag\n\t\tBotEntityInfo(bs->teammate, &entinfo);\n\t\tif (!EntityCarriesCubes(&entinfo)) {\n\t\t\tbs->ltgtype = 0;\n\t\t}\n\t}\n\t// if the bot is ordered to do something\n\tif ( bs->lastgoal_ltgtype ) {\n\t\tbs->teamgoal_time += 60;\n\t}\n\t//if not yet doing something\n\tif (bs->ltgtype == LTG_TEAMHELP ||\n\t\t\tbs->ltgtype == LTG_TEAMACCOMPANY ||\n\t\t\tbs->ltgtype == LTG_DEFENDKEYAREA ||\n\t\t\tbs->ltgtype == LTG_GETFLAG ||\n\t\t\tbs->ltgtype == LTG_CAMPORDER ||\n\t\t\tbs->ltgtype == LTG_PATROL ||\n\t\t\tbs->ltgtype == LTG_ATTACKENEMYBASE ||\n\t\t\tbs->ltgtype == LTG_HARVEST ||\n\t\t\tbs->ltgtype == LTG_GETITEM ||\n\t\t\tbs->ltgtype == LTG_MAKELOVE_UNDER ||\n\t\t\tbs->ltgtype == LTG_MAKELOVE_ONTOP) {\n\t\treturn;\n\t}\n\t//\n\tif (BotSetLastOrderedTask(bs))\n\t\treturn;\n\t//if the bot is roaming\n\tif (bs->ctfroam_time > FloatTime())\n\t\treturn;\n\t//if the bot has anough aggression to decide what to do\n\tif (BotAggression(bs) < 50)\n\t\treturn;\n\t//set the time to send a message to the team mates\n\tbs->teammessage_time = FloatTime() + 2 * random();\n\t//\n\tc = BotEnemyCubeCarrierVisible(bs);\n\tif (c >= 0) {\n\t\t//FIXME: attack enemy cube carrier\n\t}\n\tif (bs->ltgtype != LTG_TEAMACCOMPANY) {\n\t\t//if there is a visible team mate carrying cubes\n\t\tc = BotTeamCubeCarrierVisible(bs);\n\t\tif (c >= 0) {\n\t\t\t//follow the team mate carrying cubes\n\t\t\tbs->decisionmaker = bs->client;\n\t\t\tbs->ordered = qfalse;\n\t\t\t//the team mate\n\t\t\tbs->teammate = c;\n\t\t\t//last time the team mate was visible\n\t\t\tbs->teammatevisible_time = FloatTime();\n\t\t\t//no message\n\t\t\tbs->teammessage_time = 0;\n\t\t\t//no arrive message\n\t\t\tbs->arrive_time = 1;\n\t\t\t//\n\t\t\tBotVoiceChat(bs, bs->teammate, VOICECHAT_ONFOLLOW);\n\t\t\t//get the team goal time\n\t\t\tbs->teamgoal_time = FloatTime() + TEAM_ACCOMPANY_TIME;\n\t\t\tbs->ltgtype = LTG_TEAMACCOMPANY;\n\t\t\tbs->formation_dist = 3.5 * 32;\t\t//3.5 meter\n\t\t\tBotSetTeamStatus(bs);\n\t\t\treturn;\n\t\t}\n\t}\n\t//\n\tif (bs->teamtaskpreference & (TEAMTP_ATTACKER|TEAMTP_DEFENDER)) {\n\t\tif (bs->teamtaskpreference & TEAMTP_ATTACKER) {\n\t\t\tl1 = 0.7f;\n\t\t}\n\t\telse {\n\t\t\tl1 = 0.2f;\n\t\t}\n\t\tl2 = 0.9f;\n\t}\n\telse {\n\t\tl1 = 0.4f;\n\t\tl2 = 0.7f;\n\t}\n\t//\n\trnd = random();\n\tif (rnd < l1 && redobelisk.areanum && blueobelisk.areanum) {\n\t\tbs->decisionmaker = bs->client;\n\t\tbs->ordered = qfalse;\n\t\tBotGoHarvest(bs);\n\t}\n\telse if (rnd < l2 && redobelisk.areanum && blueobelisk.areanum) {\n\t\tbs->decisionmaker = bs->client;\n\t\tbs->ordered = qfalse;\n\t\t//\n\t\tif (BotTeam(bs) == TEAM_RED) memcpy(&bs->teamgoal, &redobelisk, sizeof(bot_goal_t));\n\t\telse memcpy(&bs->teamgoal, &blueobelisk, sizeof(bot_goal_t));\n\t\t//set the ltg type\n\t\tbs->ltgtype = LTG_DEFENDKEYAREA;\n\t\t//set the time the bot stops defending the base\n\t\tbs->teamgoal_time = FloatTime() + TEAM_DEFENDKEYAREA_TIME;\n\t\tbs->defendaway_time = 0;\n\t\tBotSetTeamStatus(bs);\n\t}\n\telse {\n\t\tbs->ltgtype = 0;\n\t\t//set the time the bot will stop roaming\n\t\tbs->ctfroam_time = FloatTime() + CTF_ROAM_TIME;\n\t\tBotSetTeamStatus(bs);\n\t}\n}\n\n/*\n==================\nBotHarvesterRetreatGoals\n==================\n*/\nvoid BotHarvesterRetreatGoals(bot_state_t *bs) {\n\t//when carrying cubes in harvester the bot should rush to the base\n\tif (BotHarvesterCarryingCubes(bs)) {\n\t\t//if not already rushing to the base\n\t\tif (bs->ltgtype != LTG_RUSHBASE) {\n\t\t\tBotRefuseOrder(bs);\n\t\t\tbs->ltgtype = LTG_RUSHBASE;\n\t\t\tbs->teamgoal_time = FloatTime() + CTF_RUSHBASE_TIME;\n\t\t\tbs->rushbaseaway_time = 0;\n\t\t\tbs->decisionmaker = bs->client;\n\t\t\tbs->ordered = qfalse;\n\t\t\tBotSetTeamStatus(bs);\n\t\t}\n\t\treturn;\n\t}\n}\n#endif\n\n/*\n==================\nBotTeamGoals\n==================\n*/\nvoid BotTeamGoals(bot_state_t *bs, int retreat) {\n\n\tif ( retreat ) {\n\t\tif (gametype == GT_CTF) {\n\t\t\tBotCTFRetreatGoals(bs);\n\t\t}\n#ifdef MISSIONPACK\n\t\telse if (gametype == GT_1FCTF) {\n\t\t\tBot1FCTFRetreatGoals(bs);\n\t\t}\n\t\telse if (gametype == GT_OBELISK) {\n\t\t\tBotObeliskRetreatGoals(bs);\n\t\t}\n\t\telse if (gametype == GT_HARVESTER) {\n\t\t\tBotHarvesterRetreatGoals(bs);\n\t\t}\n#endif\n\t}\n\telse {\n\t\tif (gametype == GT_CTF) {\n\t\t\t//decide what to do in CTF mode\n\t\t\tBotCTFSeekGoals(bs);\n\t\t}\n#ifdef MISSIONPACK\n\t\telse if (gametype == GT_1FCTF) {\n\t\t\tBot1FCTFSeekGoals(bs);\n\t\t}\n\t\telse if (gametype == GT_OBELISK) {\n\t\t\tBotObeliskSeekGoals(bs);\n\t\t}\n\t\telse if (gametype == GT_HARVESTER) {\n\t\t\tBotHarvesterSeekGoals(bs);\n\t\t}\n#endif\n\t}\n\t// reset the order time which is used to see if\n\t// we decided to refuse an order\n\tbs->order_time = 0;\n}\n\n/*\n==================\nBotPointAreaNum\n==================\n*/\nint BotPointAreaNum(vec3_t origin) {\n\tint areanum, numareas, areas[10];\n\tvec3_t end;\n\n\tareanum = trap_AAS_PointAreaNum(origin);\n\tif (areanum) return areanum;\n\tVectorCopy(origin, end);\n\tend[2] += 10;\n\tnumareas = trap_AAS_TraceAreas(origin, end, areas, NULL, 10);\n\tif (numareas > 0) return areas[0];\n\treturn 0;\n}\n\n/*\n==================\nClientName\n==================\n*/\nchar *ClientName(int client, char *name, int size) {\n\tchar buf[MAX_INFO_STRING];\n\n\tif (client < 0 || client >= MAX_CLIENTS) {\n\t\tBotAI_Print(PRT_ERROR, \"ClientName: client out of range\\n\");\n\t\treturn \"[client out of range]\";\n\t}\n\ttrap_GetConfigstring(CS_PLAYERS+client, buf, sizeof(buf));\n\tstrncpy(name, Info_ValueForKey(buf, \"n\"), size-1);\n\tname[size-1] = '\\0';\n\tQ_CleanStr( name );\n\treturn name;\n}\n\n/*\n==================\nClientSkin\n==================\n*/\nchar *ClientSkin(int client, char *skin, int size) {\n\tchar buf[MAX_INFO_STRING];\n\n\tif (client < 0 || client >= MAX_CLIENTS) {\n\t\tBotAI_Print(PRT_ERROR, \"ClientSkin: client out of range\\n\");\n\t\treturn \"[client out of range]\";\n\t}\n\ttrap_GetConfigstring(CS_PLAYERS+client, buf, sizeof(buf));\n\tstrncpy(skin, Info_ValueForKey(buf, \"model\"), size-1);\n\tskin[size-1] = '\\0';\n\treturn skin;\n}\n\n/*\n==================\nClientFromName\n==================\n*/\nint ClientFromName(char *name) {\n\tint i;\n\tchar buf[MAX_INFO_STRING];\n\tstatic int maxclients;\n\n\tif (!maxclients)\n\t\tmaxclients = trap_Cvar_VariableIntegerValue(\"sv_maxclients\");\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\ttrap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));\n\t\tQ_CleanStr( buf );\n\t\tif (!Q_stricmp(Info_ValueForKey(buf, \"n\"), name)) return i;\n\t}\n\treturn -1;\n}\n\n/*\n==================\nClientOnSameTeamFromName\n==================\n*/\nint ClientOnSameTeamFromName(bot_state_t *bs, char *name) {\n\tint i;\n\tchar buf[MAX_INFO_STRING];\n\tstatic int maxclients;\n\n\tif (!maxclients)\n\t\tmaxclients = trap_Cvar_VariableIntegerValue(\"sv_maxclients\");\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\tif (!BotSameTeam(bs, i))\n\t\t\tcontinue;\n\t\ttrap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));\n\t\tQ_CleanStr( buf );\n\t\tif (!Q_stricmp(Info_ValueForKey(buf, \"n\"), name)) return i;\n\t}\n\treturn -1;\n}\n\n/*\n==================\nstristr\n==================\n*/\nchar *stristr(char *str, char *charset) {\n\tint i;\n\n\twhile(*str) {\n\t\tfor (i = 0; charset[i] && str[i]; i++) {\n\t\t\tif (toupper(charset[i]) != toupper(str[i])) break;\n\t\t}\n\t\tif (!charset[i]) return str;\n\t\tstr++;\n\t}\n\treturn NULL;\n}\n\n/*\n==================\nEasyClientName\n==================\n*/\nchar *EasyClientName(int client, char *buf, int size) {\n\tint i;\n\tchar *str1, *str2, *ptr, c;\n\tchar name[128];\n\n\tstrcpy(name, ClientName(client, name, sizeof(name)));\n\tfor (i = 0; name[i]; i++) name[i] &= 127;\n\t//remove all spaces\n\tfor (ptr = strstr(name, \" \"); ptr; ptr = strstr(name, \" \")) {\n\t\tmemmove(ptr, ptr+1, strlen(ptr+1)+1);\n\t}\n\t//check for [x] and ]x[ clan names\n\tstr1 = strstr(name, \"[\");\n\tstr2 = strstr(name, \"]\");\n\tif (str1 && str2) {\n\t\tif (str2 > str1) memmove(str1, str2+1, strlen(str2+1)+1);\n\t\telse memmove(str2, str1+1, strlen(str1+1)+1);\n\t}\n\t//remove Mr prefix\n\tif ((name[0] == 'm' || name[0] == 'M') &&\n\t\t\t(name[1] == 'r' || name[1] == 'R')) {\n\t\tmemmove(name, name+2, strlen(name+2)+1);\n\t}\n\t//only allow lower case alphabet characters\n\tptr = name;\n\twhile(*ptr) {\n\t\tc = *ptr;\n\t\tif ((c >= 'a' && c <= 'z') ||\n\t\t\t\t(c >= '0' && c <= '9') || c == '_') {\n\t\t\tptr++;\n\t\t}\n\t\telse if (c >= 'A' && c <= 'Z') {\n\t\t\t*ptr += 'a' - 'A';\n\t\t\tptr++;\n\t\t}\n\t\telse {\n\t\t\tmemmove(ptr, ptr+1, strlen(ptr + 1)+1);\n\t\t}\n\t}\n\tstrncpy(buf, name, size-1);\n\tbuf[size-1] = '\\0';\n\treturn buf;\n}\n\n/*\n==================\nBotSynonymContext\n==================\n*/\nint BotSynonymContext(bot_state_t *bs) {\n\tint context;\n\n\tcontext = CONTEXT_NORMAL|CONTEXT_NEARBYITEM|CONTEXT_NAMES;\n\t//\n\tif (gametype == GT_CTF\n#ifdef MISSIONPACK\n\t\t|| gametype == GT_1FCTF\n#endif\n\t\t) {\n\t\tif (BotTeam(bs) == TEAM_RED) context |= CONTEXT_CTFREDTEAM;\n\t\telse context |= CONTEXT_CTFBLUETEAM;\n\t}\n#ifdef MISSIONPACK\n\telse if (gametype == GT_OBELISK) {\n\t\tif (BotTeam(bs) == TEAM_RED) context |= CONTEXT_OBELISKREDTEAM;\n\t\telse context |= CONTEXT_OBELISKBLUETEAM;\n\t}\n\telse if (gametype == GT_HARVESTER) {\n\t\tif (BotTeam(bs) == TEAM_RED) context |= CONTEXT_HARVESTERREDTEAM;\n\t\telse context |= CONTEXT_HARVESTERBLUETEAM;\n\t}\n#endif\n\treturn context;\n}\n\n/*\n==================\nBotChooseWeapon\n==================\n*/\nvoid BotChooseWeapon(bot_state_t *bs) {\n\tint newweaponnum;\n\n\tif (bs->cur_ps.weaponstate == WEAPON_RAISING ||\n\t\t\tbs->cur_ps.weaponstate == WEAPON_DROPPING) {\n\t\ttrap_EA_SelectWeapon(bs->client, bs->weaponnum);\n\t}\n\telse {\n\t\tnewweaponnum = trap_BotChooseBestFightWeapon(bs->ws, bs->inventory);\n\t\tif (bs->weaponnum != newweaponnum) bs->weaponchange_time = FloatTime();\n\t\tbs->weaponnum = newweaponnum;\n\t\t//BotAI_Print(PRT_MESSAGE, \"bs->weaponnum = %d\\n\", bs->weaponnum);\n\t\ttrap_EA_SelectWeapon(bs->client, bs->weaponnum);\n\t}\n}\n\n/*\n==================\nBotSetupForMovement\n==================\n*/\nvoid BotSetupForMovement(bot_state_t *bs) {\n\tbot_initmove_t initmove;\n\n\tmemset(&initmove, 0, sizeof(bot_initmove_t));\n\tVectorCopy(bs->cur_ps.origin, initmove.origin);\n\tVectorCopy(bs->cur_ps.velocity, initmove.velocity);\n\tVectorClear(initmove.viewoffset);\n\tinitmove.viewoffset[2] += bs->cur_ps.viewheight;\n\tinitmove.entitynum = bs->entitynum;\n\tinitmove.client = bs->client;\n\tinitmove.thinktime = bs->thinktime;\n\t//set the onground flag\n\tif (bs->cur_ps.groundEntityNum != ENTITYNUM_NONE) initmove.or_moveflags |= MFL_ONGROUND;\n\t//set the teleported flag\n\tif ((bs->cur_ps.pm_flags & PMF_TIME_KNOCKBACK) && (bs->cur_ps.pm_time > 0)) {\n\t\tinitmove.or_moveflags |= MFL_TELEPORTED;\n\t}\n\t//set the waterjump flag\n\tif ((bs->cur_ps.pm_flags & PMF_TIME_WATERJUMP) && (bs->cur_ps.pm_time > 0)) {\n\t\tinitmove.or_moveflags |= MFL_WATERJUMP;\n\t}\n\t//set presence type\n\tif (bs->cur_ps.pm_flags & PMF_DUCKED) initmove.presencetype = PRESENCE_CROUCH;\n\telse initmove.presencetype = PRESENCE_NORMAL;\n\t//\n\tif (bs->walker > 0.5) initmove.or_moveflags |= MFL_WALK;\n\t//\n\tVectorCopy(bs->viewangles, initmove.viewangles);\n\t//\n\ttrap_BotInitMoveState(bs->ms, &initmove);\n}\n\n/*\n==================\nBotCheckItemPickup\n==================\n*/\nvoid BotCheckItemPickup(bot_state_t *bs, int *oldinventory) {\n#ifdef MISSIONPACK\n\tint offence, leader;\n\n\tif (gametype <= GT_TEAM)\n\t\treturn;\n\n\toffence = -1;\n\t// go into offence if picked up the kamikaze or invulnerability\n\tif (!oldinventory[INVENTORY_KAMIKAZE] && bs->inventory[INVENTORY_KAMIKAZE] >= 1) {\n\t\toffence = qtrue;\n\t}\n\tif (!oldinventory[INVENTORY_INVULNERABILITY] && bs->inventory[INVENTORY_INVULNERABILITY] >= 1) {\n\t\toffence = qtrue;\n\t}\n\t// if not already wearing the kamikaze or invulnerability\n\tif (!bs->inventory[INVENTORY_KAMIKAZE] && !bs->inventory[INVENTORY_INVULNERABILITY]) {\n\t\tif (!oldinventory[INVENTORY_SCOUT] && bs->inventory[INVENTORY_SCOUT] >= 1) {\n\t\t\toffence = qtrue;\n\t\t}\n\t\tif (!oldinventory[INVENTORY_GUARD] && bs->inventory[INVENTORY_GUARD] >= 1) {\n\t\t\toffence = qtrue;\n\t\t}\n\t\tif (!oldinventory[INVENTORY_DOUBLER] && bs->inventory[INVENTORY_DOUBLER] >= 1) {\n\t\t\toffence = qfalse;\n\t\t}\n\t\tif (!oldinventory[INVENTORY_AMMOREGEN] && bs->inventory[INVENTORY_AMMOREGEN] >= 1) {\n\t\t\toffence = qfalse;\n\t\t}\n\t}\n\n\tif (offence >= 0) {\n\t\tleader = ClientFromName(bs->teamleader);\n\t\tif (offence) {\n\t\t\tif (!(bs->teamtaskpreference & TEAMTP_ATTACKER)) {\n\t\t\t\t// if we have a bot team leader\n\t\t\t\tif (BotTeamLeader(bs)) {\n\t\t\t\t\t// tell the leader we want to be on offence\n\t\t\t\t\tBotVoiceChat(bs, leader, VOICECHAT_WANTONOFFENSE);\n\t\t\t\t\t//BotAI_BotInitialChat(bs, \"wantoffence\", NULL);\n\t\t\t\t\t//trap_BotEnterChat(bs->cs, leader, CHAT_TELL);\n\t\t\t\t}\n\t\t\t\telse if (g_spSkill.integer <= 3) {\n\t\t\t\t\tif ( bs->ltgtype != LTG_GETFLAG &&\n\t\t\t\t\t\t bs->ltgtype != LTG_ATTACKENEMYBASE &&\n\t\t\t\t\t\t bs->ltgtype != LTG_HARVEST ) {\n\t\t\t\t\t\t//\n\t\t\t\t\t\tif ((gametype != GT_CTF || (bs->redflagstatus == 0 && bs->blueflagstatus == 0)) &&\n\t\t\t\t\t\t\t(gametype != GT_1FCTF || bs->neutralflagstatus == 0) ) {\n\t\t\t\t\t\t\t// tell the leader we want to be on offence\n\t\t\t\t\t\t\tBotVoiceChat(bs, leader, VOICECHAT_WANTONOFFENSE);\n\t\t\t\t\t\t\t//BotAI_BotInitialChat(bs, \"wantoffence\", NULL);\n\t\t\t\t\t\t\t//trap_BotEnterChat(bs->cs, leader, CHAT_TELL);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbs->teamtaskpreference |= TEAMTP_ATTACKER;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbs->teamtaskpreference &= ~TEAMTP_DEFENDER;\n\t\t}\n\t\telse {\n\t\t\tif (!(bs->teamtaskpreference & TEAMTP_DEFENDER)) {\n\t\t\t\t// if we have a bot team leader\n\t\t\t\tif (BotTeamLeader(bs)) {\n\t\t\t\t\t// tell the leader we want to be on defense\n\t\t\t\t\tBotVoiceChat(bs, -1, VOICECHAT_WANTONDEFENSE);\n\t\t\t\t\t//BotAI_BotInitialChat(bs, \"wantdefence\", NULL);\n\t\t\t\t\t//trap_BotEnterChat(bs->cs, leader, CHAT_TELL);\n\t\t\t\t}\n\t\t\t\telse if (g_spSkill.integer <= 3) {\n\t\t\t\t\tif ( bs->ltgtype != LTG_DEFENDKEYAREA ) {\n\t\t\t\t\t\t//\n\t\t\t\t\t\tif ((gametype != GT_CTF || (bs->redflagstatus == 0 && bs->blueflagstatus == 0)) &&\n\t\t\t\t\t\t\t(gametype != GT_1FCTF || bs->neutralflagstatus == 0) ) {\n\t\t\t\t\t\t\t// tell the leader we want to be on defense\n\t\t\t\t\t\t\tBotVoiceChat(bs, -1, VOICECHAT_WANTONDEFENSE);\n\t\t\t\t\t\t\t//BotAI_BotInitialChat(bs, \"wantdefence\", NULL);\n\t\t\t\t\t\t\t//trap_BotEnterChat(bs->cs, leader, CHAT_TELL);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbs->teamtaskpreference |= TEAMTP_DEFENDER;\n\t\t\t}\n\t\t\tbs->teamtaskpreference &= ~TEAMTP_ATTACKER;\n\t\t}\n\t}\n#endif\n}\n\n/*\n==================\nBotUpdateInventory\n==================\n*/\nvoid BotUpdateInventory(bot_state_t *bs) {\n\tint oldinventory[MAX_ITEMS];\n\n\tmemcpy(oldinventory, bs->inventory, sizeof(oldinventory));\n\t//armor\n\tbs->inventory[INVENTORY_ARMOR] = bs->cur_ps.stats[STAT_ARMOR];\n\t//weapons\n\tbs->inventory[INVENTORY_GAUNTLET] = (bs->cur_ps.stats[STAT_WEAPONS] & (1 << WP_GAUNTLET)) != 0;\n\tbs->inventory[INVENTORY_SHOTGUN] = (bs->cur_ps.stats[STAT_WEAPONS] & (1 << WP_SHOTGUN)) != 0;\n\tbs->inventory[INVENTORY_MACHINEGUN] = (bs->cur_ps.stats[STAT_WEAPONS] & (1 << WP_MACHINEGUN)) != 0;\n\tbs->inventory[INVENTORY_GRENADELAUNCHER] = (bs->cur_ps.stats[STAT_WEAPONS] & (1 << WP_GRENADE_LAUNCHER)) != 0;\n\tbs->inventory[INVENTORY_ROCKETLAUNCHER] = (bs->cur_ps.stats[STAT_WEAPONS] & (1 << WP_ROCKET_LAUNCHER)) != 0;\n\tbs->inventory[INVENTORY_LIGHTNING] = (bs->cur_ps.stats[STAT_WEAPONS] & (1 << WP_LIGHTNING)) != 0;\n\tbs->inventory[INVENTORY_RAILGUN] = (bs->cur_ps.stats[STAT_WEAPONS] & (1 << WP_RAILGUN)) != 0;\n\tbs->inventory[INVENTORY_PLASMAGUN] = (bs->cur_ps.stats[STAT_WEAPONS] & (1 << WP_PLASMAGUN)) != 0;\n\tbs->inventory[INVENTORY_BFG10K] = (bs->cur_ps.stats[STAT_WEAPONS] & (1 << WP_BFG)) != 0;\n\tbs->inventory[INVENTORY_GRAPPLINGHOOK] = (bs->cur_ps.stats[STAT_WEAPONS] & (1 << WP_GRAPPLING_HOOK)) != 0;\n#ifdef MISSIONPACK\n\tbs->inventory[INVENTORY_NAILGUN] = (bs->cur_ps.stats[STAT_WEAPONS] & (1 << WP_NAILGUN)) != 0;;\n\tbs->inventory[INVENTORY_PROXLAUNCHER] = (bs->cur_ps.stats[STAT_WEAPONS] & (1 << WP_PROX_LAUNCHER)) != 0;;\n\tbs->inventory[INVENTORY_CHAINGUN] = (bs->cur_ps.stats[STAT_WEAPONS] & (1 << WP_CHAINGUN)) != 0;;\n#endif\n\t//ammo\n\tbs->inventory[INVENTORY_SHELLS] = bs->cur_ps.ammo[WP_SHOTGUN];\n\tbs->inventory[INVENTORY_BULLETS] = bs->cur_ps.ammo[WP_MACHINEGUN];\n\tbs->inventory[INVENTORY_GRENADES] = bs->cur_ps.ammo[WP_GRENADE_LAUNCHER];\n\tbs->inventory[INVENTORY_CELLS] = bs->cur_ps.ammo[WP_PLASMAGUN];\n\tbs->inventory[INVENTORY_LIGHTNINGAMMO] = bs->cur_ps.ammo[WP_LIGHTNING];\n\tbs->inventory[INVENTORY_ROCKETS] = bs->cur_ps.ammo[WP_ROCKET_LAUNCHER];\n\tbs->inventory[INVENTORY_SLUGS] = bs->cur_ps.ammo[WP_RAILGUN];\n\tbs->inventory[INVENTORY_BFGAMMO] = bs->cur_ps.ammo[WP_BFG];\n#ifdef MISSIONPACK\n\tbs->inventory[INVENTORY_NAILS] = bs->cur_ps.ammo[WP_NAILGUN];\n\tbs->inventory[INVENTORY_MINES] = bs->cur_ps.ammo[WP_PROX_LAUNCHER];\n\tbs->inventory[INVENTORY_BELT] = bs->cur_ps.ammo[WP_CHAINGUN];\n#endif\n\t//powerups\n\tbs->inventory[INVENTORY_HEALTH] = bs->cur_ps.stats[STAT_HEALTH];\n\tbs->inventory[INVENTORY_TELEPORTER] = bs->cur_ps.stats[STAT_HOLDABLE_ITEM] == MODELINDEX_TELEPORTER;\n\tbs->inventory[INVENTORY_MEDKIT] = bs->cur_ps.stats[STAT_HOLDABLE_ITEM] == MODELINDEX_MEDKIT;\n#ifdef MISSIONPACK\n\tbs->inventory[INVENTORY_KAMIKAZE] = bs->cur_ps.stats[STAT_HOLDABLE_ITEM] == MODELINDEX_KAMIKAZE;\n\tbs->inventory[INVENTORY_PORTAL] = bs->cur_ps.stats[STAT_HOLDABLE_ITEM] == MODELINDEX_PORTAL;\n\tbs->inventory[INVENTORY_INVULNERABILITY] = bs->cur_ps.stats[STAT_HOLDABLE_ITEM] == MODELINDEX_INVULNERABILITY;\n#endif\n\tbs->inventory[INVENTORY_QUAD] = bs->cur_ps.powerups[PW_QUAD] != 0;\n\tbs->inventory[INVENTORY_ENVIRONMENTSUIT] = bs->cur_ps.powerups[PW_BATTLESUIT] != 0;\n\tbs->inventory[INVENTORY_HASTE] = bs->cur_ps.powerups[PW_HASTE] != 0;\n\tbs->inventory[INVENTORY_INVISIBILITY] = bs->cur_ps.powerups[PW_INVIS] != 0;\n\tbs->inventory[INVENTORY_REGEN] = bs->cur_ps.powerups[PW_REGEN] != 0;\n\tbs->inventory[INVENTORY_FLIGHT] = bs->cur_ps.powerups[PW_FLIGHT] != 0;\n#ifdef MISSIONPACK\n\tbs->inventory[INVENTORY_SCOUT] = bs->cur_ps.stats[STAT_PERSISTANT_POWERUP] == MODELINDEX_SCOUT;\n\tbs->inventory[INVENTORY_GUARD] = bs->cur_ps.stats[STAT_PERSISTANT_POWERUP] == MODELINDEX_GUARD;\n\tbs->inventory[INVENTORY_DOUBLER] = bs->cur_ps.stats[STAT_PERSISTANT_POWERUP] == MODELINDEX_DOUBLER;\n\tbs->inventory[INVENTORY_AMMOREGEN] = bs->cur_ps.stats[STAT_PERSISTANT_POWERUP] == MODELINDEX_AMMOREGEN;\n#endif\n\tbs->inventory[INVENTORY_REDFLAG] = bs->cur_ps.powerups[PW_REDFLAG] != 0;\n\tbs->inventory[INVENTORY_BLUEFLAG] = bs->cur_ps.powerups[PW_BLUEFLAG] != 0;\n#ifdef MISSIONPACK\n\tbs->inventory[INVENTORY_NEUTRALFLAG] = bs->cur_ps.powerups[PW_NEUTRALFLAG] != 0;\n\tif (BotTeam(bs) == TEAM_RED) {\n\t\tbs->inventory[INVENTORY_REDCUBE] = bs->cur_ps.generic1;\n\t\tbs->inventory[INVENTORY_BLUECUBE] = 0;\n\t}\n\telse {\n\t\tbs->inventory[INVENTORY_REDCUBE] = 0;\n\t\tbs->inventory[INVENTORY_BLUECUBE] = bs->cur_ps.generic1;\n\t}\n#endif\n\tBotCheckItemPickup(bs, oldinventory);\n}\n\n/*\n==================\nBotUpdateBattleInventory\n==================\n*/\nvoid BotUpdateBattleInventory(bot_state_t *bs, int enemy) {\n\tvec3_t dir;\n\taas_entityinfo_t entinfo;\n\n\tBotEntityInfo(enemy, &entinfo);\n\tVectorSubtract(entinfo.origin, bs->origin, dir);\n\tbs->inventory[ENEMY_HEIGHT] = (int) dir[2];\n\tdir[2] = 0;\n\tbs->inventory[ENEMY_HORIZONTAL_DIST] = (int) VectorLength(dir);\n\t//FIXME: add num visible enemies and num visible team mates to the inventory\n}\n\n#ifdef MISSIONPACK\n/*\n==================\nBotUseKamikaze\n==================\n*/\n#define KAMIKAZE_DIST\t\t1024\n\nvoid BotUseKamikaze(bot_state_t *bs) {\n\tint c, teammates, enemies;\n\taas_entityinfo_t entinfo;\n\tvec3_t dir, target;\n\tbot_goal_t *goal;\n\tbsp_trace_t trace;\n\n\t//if the bot has no kamikaze\n\tif (bs->inventory[INVENTORY_KAMIKAZE] <= 0)\n\t\treturn;\n\tif (bs->kamikaze_time > FloatTime())\n\t\treturn;\n\tbs->kamikaze_time = FloatTime() + 0.2;\n\tif (gametype == GT_CTF) {\n\t\t//never use kamikaze if the team flag carrier is visible\n\t\tif (BotCTFCarryingFlag(bs))\n\t\t\treturn;\n\t\tc = BotTeamFlagCarrierVisible(bs);\n\t\tif (c >= 0) {\n\t\t\tBotEntityInfo(c, &entinfo);\n\t\t\tVectorSubtract(entinfo.origin, bs->origin, dir);\n\t\t\tif (VectorLengthSquared(dir) < Square(KAMIKAZE_DIST))\n\t\t\t\treturn;\n\t\t}\n\t\tc = BotEnemyFlagCarrierVisible(bs);\n\t\tif (c >= 0) {\n\t\t\tBotEntityInfo(c, &entinfo);\n\t\t\tVectorSubtract(entinfo.origin, bs->origin, dir);\n\t\t\tif (VectorLengthSquared(dir) < Square(KAMIKAZE_DIST)) {\n\t\t\t\ttrap_EA_Use(bs->client);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\telse if (gametype == GT_1FCTF) {\n\t\t//never use kamikaze if the team flag carrier is visible\n\t\tif (Bot1FCTFCarryingFlag(bs))\n\t\t\treturn;\n\t\tc = BotTeamFlagCarrierVisible(bs);\n\t\tif (c >= 0) {\n\t\t\tBotEntityInfo(c, &entinfo);\n\t\t\tVectorSubtract(entinfo.origin, bs->origin, dir);\n\t\t\tif (VectorLengthSquared(dir) < Square(KAMIKAZE_DIST))\n\t\t\t\treturn;\n\t\t}\n\t\tc = BotEnemyFlagCarrierVisible(bs);\n\t\tif (c >= 0) {\n\t\t\tBotEntityInfo(c, &entinfo);\n\t\t\tVectorSubtract(entinfo.origin, bs->origin, dir);\n\t\t\tif (VectorLengthSquared(dir) < Square(KAMIKAZE_DIST)) {\n\t\t\t\ttrap_EA_Use(bs->client);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\telse if (gametype == GT_OBELISK) {\n\t\tswitch(BotTeam(bs)) {\n\t\t\tcase TEAM_RED: goal = &blueobelisk; break;\n\t\t\tdefault: goal = &redobelisk; break;\n\t\t}\n\t\t//if the obelisk is visible\n\t\tVectorCopy(goal->origin, target);\n\t\ttarget[2] += 1;\n\t\tVectorSubtract(bs->origin, target, dir);\n\t\tif (VectorLengthSquared(dir) < Square(KAMIKAZE_DIST * 0.9)) {\n\t\t\tBotAI_Trace(&trace, bs->eye, NULL, NULL, target, bs->client, CONTENTS_SOLID);\n\t\t\tif (trace.fraction >= 1 || trace.ent == goal->entitynum) {\n\t\t\t\ttrap_EA_Use(bs->client);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\telse if (gametype == GT_HARVESTER) {\n\t\t//\n\t\tif (BotHarvesterCarryingCubes(bs))\n\t\t\treturn;\n\t\t//never use kamikaze if a team mate carrying cubes is visible\n\t\tc = BotTeamCubeCarrierVisible(bs);\n\t\tif (c >= 0) {\n\t\t\tBotEntityInfo(c, &entinfo);\n\t\t\tVectorSubtract(entinfo.origin, bs->origin, dir);\n\t\t\tif (VectorLengthSquared(dir) < Square(KAMIKAZE_DIST))\n\t\t\t\treturn;\n\t\t}\n\t\tc = BotEnemyCubeCarrierVisible(bs);\n\t\tif (c >= 0) {\n\t\t\tBotEntityInfo(c, &entinfo);\n\t\t\tVectorSubtract(entinfo.origin, bs->origin, dir);\n\t\t\tif (VectorLengthSquared(dir) < Square(KAMIKAZE_DIST)) {\n\t\t\t\ttrap_EA_Use(bs->client);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\t//\n\tBotVisibleTeamMatesAndEnemies(bs, &teammates, &enemies, KAMIKAZE_DIST);\n\t//\n\tif (enemies > 2 && enemies > teammates+1) {\n\t\ttrap_EA_Use(bs->client);\n\t\treturn;\n\t}\n}\n\n/*\n==================\nBotUseInvulnerability\n==================\n*/\nvoid BotUseInvulnerability(bot_state_t *bs) {\n\tint c;\n\tvec3_t dir, target;\n\tbot_goal_t *goal;\n\tbsp_trace_t trace;\n\n\t//if the bot has no invulnerability\n\tif (bs->inventory[INVENTORY_INVULNERABILITY] <= 0)\n\t\treturn;\n\tif (bs->invulnerability_time > FloatTime())\n\t\treturn;\n\tbs->invulnerability_time = FloatTime() + 0.2;\n\tif (gametype == GT_CTF) {\n\t\t//never use kamikaze if the team flag carrier is visible\n\t\tif (BotCTFCarryingFlag(bs))\n\t\t\treturn;\n\t\tc = BotEnemyFlagCarrierVisible(bs);\n\t\tif (c >= 0)\n\t\t\treturn;\n\t\t//if near enemy flag and the flag is visible\n\t\tswitch(BotTeam(bs)) {\n\t\t\tcase TEAM_RED: goal = &ctf_blueflag; break;\n\t\t\tdefault: goal = &ctf_redflag; break;\n\t\t}\n\t\t//if the obelisk is visible\n\t\tVectorCopy(goal->origin, target);\n\t\ttarget[2] += 1;\n\t\tVectorSubtract(bs->origin, target, dir);\n\t\tif (VectorLengthSquared(dir) < Square(200)) {\n\t\t\tBotAI_Trace(&trace, bs->eye, NULL, NULL, target, bs->client, CONTENTS_SOLID);\n\t\t\tif (trace.fraction >= 1 || trace.ent == goal->entitynum) {\n\t\t\t\ttrap_EA_Use(bs->client);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\telse if (gametype == GT_1FCTF) {\n\t\t//never use kamikaze if the team flag carrier is visible\n\t\tif (Bot1FCTFCarryingFlag(bs))\n\t\t\treturn;\n\t\tc = BotEnemyFlagCarrierVisible(bs);\n\t\tif (c >= 0)\n\t\t\treturn;\n\t\t//if near enemy flag and the flag is visible\n\t\tswitch(BotTeam(bs)) {\n\t\t\tcase TEAM_RED: goal = &ctf_blueflag; break;\n\t\t\tdefault: goal = &ctf_redflag; break;\n\t\t}\n\t\t//if the obelisk is visible\n\t\tVectorCopy(goal->origin, target);\n\t\ttarget[2] += 1;\n\t\tVectorSubtract(bs->origin, target, dir);\n\t\tif (VectorLengthSquared(dir) < Square(200)) {\n\t\t\tBotAI_Trace(&trace, bs->eye, NULL, NULL, target, bs->client, CONTENTS_SOLID);\n\t\t\tif (trace.fraction >= 1 || trace.ent == goal->entitynum) {\n\t\t\t\ttrap_EA_Use(bs->client);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\telse if (gametype == GT_OBELISK) {\n\t\tswitch(BotTeam(bs)) {\n\t\t\tcase TEAM_RED: goal = &blueobelisk; break;\n\t\t\tdefault: goal = &redobelisk; break;\n\t\t}\n\t\t//if the obelisk is visible\n\t\tVectorCopy(goal->origin, target);\n\t\ttarget[2] += 1;\n\t\tVectorSubtract(bs->origin, target, dir);\n\t\tif (VectorLengthSquared(dir) < Square(300)) {\n\t\t\tBotAI_Trace(&trace, bs->eye, NULL, NULL, target, bs->client, CONTENTS_SOLID);\n\t\t\tif (trace.fraction >= 1 || trace.ent == goal->entitynum) {\n\t\t\t\ttrap_EA_Use(bs->client);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\telse if (gametype == GT_HARVESTER) {\n\t\t//\n\t\tif (BotHarvesterCarryingCubes(bs))\n\t\t\treturn;\n\t\tc = BotEnemyCubeCarrierVisible(bs);\n\t\tif (c >= 0)\n\t\t\treturn;\n\t\t//if near enemy base and enemy base is visible\n\t\tswitch(BotTeam(bs)) {\n\t\t\tcase TEAM_RED: goal = &blueobelisk; break;\n\t\t\tdefault: goal = &redobelisk; break;\n\t\t}\n\t\t//if the obelisk is visible\n\t\tVectorCopy(goal->origin, target);\n\t\ttarget[2] += 1;\n\t\tVectorSubtract(bs->origin, target, dir);\n\t\tif (VectorLengthSquared(dir) < Square(200)) {\n\t\t\tBotAI_Trace(&trace, bs->eye, NULL, NULL, target, bs->client, CONTENTS_SOLID);\n\t\t\tif (trace.fraction >= 1 || trace.ent == goal->entitynum) {\n\t\t\t\ttrap_EA_Use(bs->client);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n}\n#endif\n\n/*\n==================\nBotBattleUseItems\n==================\n*/\nvoid BotBattleUseItems(bot_state_t *bs) {\n\tif (bs->inventory[INVENTORY_HEALTH] < 40) {\n\t\tif (bs->inventory[INVENTORY_TELEPORTER] > 0) {\n\t\t\tif (!BotCTFCarryingFlag(bs)\n#ifdef MISSIONPACK\n\t\t\t\t&& !Bot1FCTFCarryingFlag(bs)\n\t\t\t\t&& !BotHarvesterCarryingCubes(bs)\n#endif\n\t\t\t\t) {\n\t\t\t\ttrap_EA_Use(bs->client);\n\t\t\t}\n\t\t}\n\t}\n\tif (bs->inventory[INVENTORY_HEALTH] < 60) {\n\t\tif (bs->inventory[INVENTORY_MEDKIT] > 0) {\n\t\t\ttrap_EA_Use(bs->client);\n\t\t}\n\t}\n#ifdef MISSIONPACK\n\tBotUseKamikaze(bs);\n\tBotUseInvulnerability(bs);\n#endif\n}\n\n/*\n==================\nBotSetTeleportTime\n==================\n*/\nvoid BotSetTeleportTime(bot_state_t *bs) {\n\tif ((bs->cur_ps.eFlags ^ bs->last_eFlags) & EF_TELEPORT_BIT) {\n\t\tbs->teleport_time = FloatTime();\n\t}\n\tbs->last_eFlags = bs->cur_ps.eFlags;\n}\n\n/*\n==================\nBotIsDead\n==================\n*/\nqboolean BotIsDead(bot_state_t *bs) {\n\treturn (bs->cur_ps.pm_type == PM_DEAD);\n}\n\n/*\n==================\nBotIsObserver\n==================\n*/\nqboolean BotIsObserver(bot_state_t *bs) {\n\tchar buf[MAX_INFO_STRING];\n\tif (bs->cur_ps.pm_type == PM_SPECTATOR) return qtrue;\n\ttrap_GetConfigstring(CS_PLAYERS+bs->client, buf, sizeof(buf));\n\tif (atoi(Info_ValueForKey(buf, \"t\")) == TEAM_SPECTATOR) return qtrue;\n\treturn qfalse;\n}\n\n/*\n==================\nBotIntermission\n==================\n*/\nqboolean BotIntermission(bot_state_t *bs) {\n\t//NOTE: we shouldn't be looking at the game code...\n\tif (level.intermissiontime) return qtrue;\n\treturn (bs->cur_ps.pm_type == PM_FREEZE || bs->cur_ps.pm_type == PM_INTERMISSION);\n}\n\n/*\n==================\nBotInLavaOrSlime\n==================\n*/\nqboolean BotInLavaOrSlime(bot_state_t *bs) {\n\tvec3_t feet;\n\n\tVectorCopy(bs->origin, feet);\n\tfeet[2] -= 23;\n\treturn (trap_AAS_PointContents(feet) & (CONTENTS_LAVA|CONTENTS_SLIME));\n}\n\n/*\n==================\nBotCreateWayPoint\n==================\n*/\nbot_waypoint_t *BotCreateWayPoint(char *name, vec3_t origin, int areanum) {\n\tbot_waypoint_t *wp;\n\tvec3_t waypointmins = {-8, -8, -8}, waypointmaxs = {8, 8, 8};\n\n\twp = botai_freewaypoints;\n\tif ( !wp ) {\n\t\tBotAI_Print( PRT_WARNING, \"BotCreateWayPoint: Out of waypoints\\n\" );\n\t\treturn NULL;\n\t}\n\tbotai_freewaypoints = botai_freewaypoints->next;\n\n\tQ_strncpyz( wp->name, name, sizeof(wp->name) );\n\tVectorCopy(origin, wp->goal.origin);\n\tVectorCopy(waypointmins, wp->goal.mins);\n\tVectorCopy(waypointmaxs, wp->goal.maxs);\n\twp->goal.areanum = areanum;\n\twp->next = NULL;\n\twp->prev = NULL;\n\treturn wp;\n}\n\n/*\n==================\nBotFindWayPoint\n==================\n*/\nbot_waypoint_t *BotFindWayPoint(bot_waypoint_t *waypoints, char *name) {\n\tbot_waypoint_t *wp;\n\n\tfor (wp = waypoints; wp; wp = wp->next) {\n\t\tif (!Q_stricmp(wp->name, name)) return wp;\n\t}\n\treturn NULL;\n}\n\n/*\n==================\nBotFreeWaypoints\n==================\n*/\nvoid BotFreeWaypoints(bot_waypoint_t *wp) {\n\tbot_waypoint_t *nextwp;\n\n\tfor (; wp; wp = nextwp) {\n\t\tnextwp = wp->next;\n\t\twp->next = botai_freewaypoints;\n\t\tbotai_freewaypoints = wp;\n\t}\n}\n\n/*\n==================\nBotInitWaypoints\n==================\n*/\nvoid BotInitWaypoints(void) {\n\tint i;\n\n\tbotai_freewaypoints = NULL;\n\tfor (i = 0; i < MAX_WAYPOINTS; i++) {\n\t\tbotai_waypoints[i].next = botai_freewaypoints;\n\t\tbotai_freewaypoints = &botai_waypoints[i];\n\t}\n}\n\n/*\n==================\nTeamPlayIsOn\n==================\n*/\nint TeamPlayIsOn(void) {\n\treturn ( gametype >= GT_TEAM );\n}\n\n/*\n==================\nBotAggression\n==================\n*/\nfloat BotAggression(bot_state_t *bs) {\n\t//if the bot has quad\n\tif (bs->inventory[INVENTORY_QUAD]) {\n\t\t//if the bot is not holding the gauntlet or the enemy is really nearby\n\t\tif (bs->weaponnum != WP_GAUNTLET ||\n\t\t\tbs->inventory[ENEMY_HORIZONTAL_DIST] < 80) {\n\t\t\treturn 70;\n\t\t}\n\t}\n\t//if the enemy is located way higher than the bot\n\tif (bs->inventory[ENEMY_HEIGHT] > 200) return 0;\n\t//if the bot is very low on health\n\tif (bs->inventory[INVENTORY_HEALTH] < 60) return 0;\n\t//if the bot is low on health\n\tif (bs->inventory[INVENTORY_HEALTH] < 80) {\n\t\t//if the bot has insufficient armor\n\t\tif (bs->inventory[INVENTORY_ARMOR] < 40) return 0;\n\t}\n\t//if the bot can use the bfg\n\tif (bs->inventory[INVENTORY_BFG10K] > 0 &&\n\t\t\tbs->inventory[INVENTORY_BFGAMMO] > 7) return 100;\n\t//if the bot can use the railgun\n\tif (bs->inventory[INVENTORY_RAILGUN] > 0 &&\n\t\t\tbs->inventory[INVENTORY_SLUGS] > 5) return 95;\n\t//if the bot can use the lightning gun\n\tif (bs->inventory[INVENTORY_LIGHTNING] > 0 &&\n\t\t\tbs->inventory[INVENTORY_LIGHTNINGAMMO] > 50) return 90;\n\t//if the bot can use the rocketlauncher\n\tif (bs->inventory[INVENTORY_ROCKETLAUNCHER] > 0 &&\n\t\t\tbs->inventory[INVENTORY_ROCKETS] > 5) return 90;\n\t//if the bot can use the plasmagun\n\tif (bs->inventory[INVENTORY_PLASMAGUN] > 0 &&\n\t\t\tbs->inventory[INVENTORY_CELLS] > 40) return 85;\n\t//if the bot can use the grenade launcher\n\tif (bs->inventory[INVENTORY_GRENADELAUNCHER] > 0 &&\n\t\t\tbs->inventory[INVENTORY_GRENADES] > 10) return 80;\n\t//if the bot can use the shotgun\n\tif (bs->inventory[INVENTORY_SHOTGUN] > 0 &&\n\t\t\tbs->inventory[INVENTORY_SHELLS] > 10) return 50;\n\t//otherwise the bot is not feeling too good\n\treturn 0;\n}\n\n/*\n==================\nBotFeelingBad\n==================\n*/\nfloat BotFeelingBad(bot_state_t *bs) {\n\tif (bs->weaponnum == WP_GAUNTLET) {\n\t\treturn 100;\n\t}\n\tif (bs->inventory[INVENTORY_HEALTH] < 40) {\n\t\treturn 100;\n\t}\n\tif (bs->weaponnum == WP_MACHINEGUN) {\n\t\treturn 90;\n\t}\n\tif (bs->inventory[INVENTORY_HEALTH] < 60) {\n\t\treturn 80;\n\t}\n\treturn 0;\n}\n\n/*\n==================\nBotWantsToRetreat\n==================\n*/\nint BotWantsToRetreat(bot_state_t *bs) {\n\taas_entityinfo_t entinfo;\n\n\tif (gametype == GT_CTF) {\n\t\t//always retreat when carrying a CTF flag\n\t\tif (BotCTFCarryingFlag(bs))\n\t\t\treturn qtrue;\n\t}\n#ifdef MISSIONPACK\n\telse if (gametype == GT_1FCTF) {\n\t\t//if carrying the flag then always retreat\n\t\tif (Bot1FCTFCarryingFlag(bs))\n\t\t\treturn qtrue;\n\t}\n\telse if (gametype == GT_OBELISK) {\n\t\t//the bots should be dedicated to attacking the enemy obelisk\n\t\tif (bs->ltgtype == LTG_ATTACKENEMYBASE) {\n\t\t\tif (bs->enemy != redobelisk.entitynum ||\n\t\t\t\t\t\tbs->enemy != blueobelisk.entitynum) {\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t}\n\t\tif (BotFeelingBad(bs) > 50) {\n\t\t\treturn qtrue;\n\t\t}\n\t\treturn qfalse;\n\t}\n\telse if (gametype == GT_HARVESTER) {\n\t\t//if carrying cubes then always retreat\n\t\tif (BotHarvesterCarryingCubes(bs)) return qtrue;\n\t}\n#endif\n\t//\n\tif (bs->enemy >= 0) {\n\t\t//if the enemy is carrying a flag\n\t\tBotEntityInfo(bs->enemy, &entinfo);\n\t\tif (EntityCarriesFlag(&entinfo))\n\t\t\treturn qfalse;\n\t}\n\t//if the bot is getting the flag\n\tif (bs->ltgtype == LTG_GETFLAG)\n\t\treturn qtrue;\n\t//\n\tif (BotAggression(bs) < 50)\n\t\treturn qtrue;\n\treturn qfalse;\n}\n\n/*\n==================\nBotWantsToChase\n==================\n*/\nint BotWantsToChase(bot_state_t *bs) {\n\taas_entityinfo_t entinfo;\n\n\tif (gametype == GT_CTF) {\n\t\t//never chase when carrying a CTF flag\n\t\tif (BotCTFCarryingFlag(bs))\n\t\t\treturn qfalse;\n\t\t//always chase if the enemy is carrying a flag\n\t\tBotEntityInfo(bs->enemy, &entinfo);\n\t\tif (EntityCarriesFlag(&entinfo))\n\t\t\treturn qtrue;\n\t}\n#ifdef MISSIONPACK\n\telse if (gametype == GT_1FCTF) {\n\t\t//never chase if carrying the flag\n\t\tif (Bot1FCTFCarryingFlag(bs))\n\t\t\treturn qfalse;\n\t\t//always chase if the enemy is carrying a flag\n\t\tBotEntityInfo(bs->enemy, &entinfo);\n\t\tif (EntityCarriesFlag(&entinfo))\n\t\t\treturn qtrue;\n\t}\n\telse if (gametype == GT_OBELISK) {\n\t\t//the bots should be dedicated to attacking the enemy obelisk\n\t\tif (bs->ltgtype == LTG_ATTACKENEMYBASE) {\n\t\t\tif (bs->enemy != redobelisk.entitynum ||\n\t\t\t\t\t\tbs->enemy != blueobelisk.entitynum) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t}\n\t}\n\telse if (gametype == GT_HARVESTER) {\n\t\t//never chase if carrying cubes\n\t\tif (BotHarvesterCarryingCubes(bs))\n\t\t\treturn qfalse;\n\t}\n#endif\n\t//if the bot is getting the flag\n\tif (bs->ltgtype == LTG_GETFLAG)\n\t\treturn qfalse;\n\t//\n\tif (BotAggression(bs) > 50)\n\t\treturn qtrue;\n\treturn qfalse;\n}\n\n/*\n==================\nBotWantsToHelp\n==================\n*/\nint BotWantsToHelp(bot_state_t *bs) {\n\treturn qtrue;\n}\n\n/*\n==================\nBotCanAndWantsToRocketJump\n==================\n*/\nint BotCanAndWantsToRocketJump(bot_state_t *bs) {\n\tfloat rocketjumper;\n\n\t//if rocket jumping is disabled\n\tif (!bot_rocketjump.integer) return qfalse;\n\t//if no rocket launcher\n\tif (bs->inventory[INVENTORY_ROCKETLAUNCHER] <= 0) return qfalse;\n\t//if low on rockets\n\tif (bs->inventory[INVENTORY_ROCKETS] < 3) return qfalse;\n\t//never rocket jump with the Quad\n\tif (bs->inventory[INVENTORY_QUAD]) return qfalse;\n\t//if low on health\n\tif (bs->inventory[INVENTORY_HEALTH] < 60) return qfalse;\n\t//if not full health\n\tif (bs->inventory[INVENTORY_HEALTH] < 90) {\n\t\t//if the bot has insufficient armor\n\t\tif (bs->inventory[INVENTORY_ARMOR] < 40) return qfalse;\n\t}\n\trocketjumper = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_WEAPONJUMPING, 0, 1);\n\tif (rocketjumper < 0.5) return qfalse;\n\treturn qtrue;\n}\n\n/*\n==================\nBotHasPersistantPowerupAndWeapon\n==================\n*/\nint BotHasPersistantPowerupAndWeapon(bot_state_t *bs) {\n#ifdef MISSIONPACK\n\t// if the bot does not have a persistant powerup\n\tif (!bs->inventory[INVENTORY_SCOUT] &&\n\t\t!bs->inventory[INVENTORY_GUARD] &&\n\t\t!bs->inventory[INVENTORY_DOUBLER] &&\n\t\t!bs->inventory[INVENTORY_AMMOREGEN] ) {\n\t\treturn qfalse;\n\t}\n#endif\n\t//if the bot is very low on health\n\tif (bs->inventory[INVENTORY_HEALTH] < 60) return qfalse;\n\t//if the bot is low on health\n\tif (bs->inventory[INVENTORY_HEALTH] < 80) {\n\t\t//if the bot has insufficient armor\n\t\tif (bs->inventory[INVENTORY_ARMOR] < 40) return qfalse;\n\t}\n\t//if the bot can use the bfg\n\tif (bs->inventory[INVENTORY_BFG10K] > 0 &&\n\t\t\tbs->inventory[INVENTORY_BFGAMMO] > 7) return qtrue;\n\t//if the bot can use the railgun\n\tif (bs->inventory[INVENTORY_RAILGUN] > 0 &&\n\t\t\tbs->inventory[INVENTORY_SLUGS] > 5) return qtrue;\n\t//if the bot can use the lightning gun\n\tif (bs->inventory[INVENTORY_LIGHTNING] > 0 &&\n\t\t\tbs->inventory[INVENTORY_LIGHTNINGAMMO] > 50) return qtrue;\n\t//if the bot can use the rocketlauncher\n\tif (bs->inventory[INVENTORY_ROCKETLAUNCHER] > 0 &&\n\t\t\tbs->inventory[INVENTORY_ROCKETS] > 5) return qtrue;\n\t//\n\tif (bs->inventory[INVENTORY_NAILGUN] > 0 &&\n\t\t\tbs->inventory[INVENTORY_NAILS] > 5) return qtrue;\n\t//\n\tif (bs->inventory[INVENTORY_PROXLAUNCHER] > 0 &&\n\t\t\tbs->inventory[INVENTORY_MINES] > 5) return qtrue;\n\t//\n\tif (bs->inventory[INVENTORY_CHAINGUN] > 0 &&\n\t\t\tbs->inventory[INVENTORY_BELT] > 40) return qtrue;\n\t//if the bot can use the plasmagun\n\tif (bs->inventory[INVENTORY_PLASMAGUN] > 0 &&\n\t\t\tbs->inventory[INVENTORY_CELLS] > 20) return qtrue;\n\treturn qfalse;\n}\n\n/*\n==================\nBotGoCamp\n==================\n*/\nvoid BotGoCamp(bot_state_t *bs, bot_goal_t *goal) {\n\tfloat camper;\n\n\tbs->decisionmaker = bs->client;\n\t//set message time to zero so bot will NOT show any message\n\tbs->teammessage_time = 0;\n\t//set the ltg type\n\tbs->ltgtype = LTG_CAMP;\n\t//set the team goal\n\tmemcpy(&bs->teamgoal, goal, sizeof(bot_goal_t));\n\t//get the team goal time\n\tcamper = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CAMPER, 0, 1);\n\tif (camper > 0.99) bs->teamgoal_time = FloatTime() + 99999;\n\telse bs->teamgoal_time = FloatTime() + 120 + 180 * camper + random() * 15;\n\t//set the last time the bot started camping\n\tbs->camp_time = FloatTime();\n\t//the teammate that requested the camping\n\tbs->teammate = 0;\n\t//do NOT type arrive message\n\tbs->arrive_time = 1;\n}\n\n/*\n==================\nBotWantsToCamp\n==================\n*/\nint BotWantsToCamp(bot_state_t *bs) {\n\tfloat camper;\n\tint cs, traveltime, besttraveltime;\n\tbot_goal_t goal, bestgoal;\n\n\tcamper = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CAMPER, 0, 1);\n\tif (camper < 0.1) return qfalse;\n\t//if the bot has a team goal\n\tif (bs->ltgtype == LTG_TEAMHELP ||\n\t\t\tbs->ltgtype == LTG_TEAMACCOMPANY ||\n\t\t\tbs->ltgtype == LTG_DEFENDKEYAREA ||\n\t\t\tbs->ltgtype == LTG_GETFLAG ||\n\t\t\tbs->ltgtype == LTG_RUSHBASE ||\n\t\t\tbs->ltgtype == LTG_CAMP ||\n\t\t\tbs->ltgtype == LTG_CAMPORDER ||\n\t\t\tbs->ltgtype == LTG_PATROL) {\n\t\treturn qfalse;\n\t}\n\t//if camped recently\n\tif (bs->camp_time > FloatTime() - 60 + 300 * (1-camper)) return qfalse;\n\t//\n\tif (random() > camper) {\n\t\tbs->camp_time = FloatTime();\n\t\treturn qfalse;\n\t}\n\t//if the bot isn't healthy anough\n\tif (BotAggression(bs) < 50) return qfalse;\n\t//the bot should have at least have the rocket launcher, the railgun or the bfg10k with some ammo\n\tif ((bs->inventory[INVENTORY_ROCKETLAUNCHER] <= 0 || bs->inventory[INVENTORY_ROCKETS < 10]) &&\n\t\t(bs->inventory[INVENTORY_RAILGUN] <= 0 || bs->inventory[INVENTORY_SLUGS] < 10) &&\n\t\t(bs->inventory[INVENTORY_BFG10K] <= 0 || bs->inventory[INVENTORY_BFGAMMO] < 10)) {\n\t\treturn qfalse;\n\t}\n\t//find the closest camp spot\n\tbesttraveltime = 99999;\n\tfor (cs = trap_BotGetNextCampSpotGoal(0, &goal); cs; cs = trap_BotGetNextCampSpotGoal(cs, &goal)) {\n\t\ttraveltime = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, goal.areanum, TFL_DEFAULT);\n\t\tif (traveltime && traveltime < besttraveltime) {\n\t\t\tbesttraveltime = traveltime;\n\t\t\tmemcpy(&bestgoal, &goal, sizeof(bot_goal_t));\n\t\t}\n\t}\n\tif (besttraveltime > 150) return qfalse;\n\t//ok found a camp spot, go camp there\n\tBotGoCamp(bs, &bestgoal);\n\tbs->ordered = qfalse;\n\t//\n\treturn qtrue;\n}\n\n/*\n==================\nBotDontAvoid\n==================\n*/\nvoid BotDontAvoid(bot_state_t *bs, char *itemname) {\n\tbot_goal_t goal;\n\tint num;\n\n\tnum = trap_BotGetLevelItemGoal(-1, itemname, &goal);\n\twhile(num >= 0) {\n\t\ttrap_BotRemoveFromAvoidGoals(bs->gs, goal.number);\n\t\tnum = trap_BotGetLevelItemGoal(num, itemname, &goal);\n\t}\n}\n\n/*\n==================\nBotGoForPowerups\n==================\n*/\nvoid BotGoForPowerups(bot_state_t *bs) {\n\n\t//don't avoid any of the powerups anymore\n\tBotDontAvoid(bs, \"Quad Damage\");\n\tBotDontAvoid(bs, \"Regeneration\");\n\tBotDontAvoid(bs, \"Battle Suit\");\n\tBotDontAvoid(bs, \"Speed\");\n\tBotDontAvoid(bs, \"Invisibility\");\n\t//BotDontAvoid(bs, \"Flight\");\n\t//reset the long term goal time so the bot will go for the powerup\n\t//NOTE: the long term goal type doesn't change\n\tbs->ltg_time = 0;\n}\n\n/*\n==================\nBotRoamGoal\n==================\n*/\nvoid BotRoamGoal(bot_state_t *bs, vec3_t goal) {\n\tint pc, i;\n\tfloat len, rnd;\n\tvec3_t dir, bestorg, belowbestorg;\n\tbsp_trace_t trace;\n\n\tfor (i = 0; i < 10; i++) {\n\t\t//start at the bot origin\n\t\tVectorCopy(bs->origin, bestorg);\n\t\trnd = random();\n\t\tif (rnd > 0.25) {\n\t\t\t//add a random value to the x-coordinate\n\t\t\tif (random() < 0.5) bestorg[0] -= 800 * random() + 100;\n\t\t\telse bestorg[0] += 800 * random() + 100;\n\t\t}\n\t\tif (rnd < 0.75) {\n\t\t\t//add a random value to the y-coordinate\n\t\t\tif (random() < 0.5) bestorg[1] -= 800 * random() + 100;\n\t\t\telse bestorg[1] += 800 * random() + 100;\n\t\t}\n\t\t//add a random value to the z-coordinate (NOTE: 48 = maxjump?)\n\t\tbestorg[2] += 2 * 48 * crandom();\n\t\t//trace a line from the origin to the roam target\n\t\tBotAI_Trace(&trace, bs->origin, NULL, NULL, bestorg, bs->entitynum, MASK_SOLID);\n\t\t//direction and length towards the roam target\n\t\tVectorSubtract(trace.endpos, bs->origin, dir);\n\t\tlen = VectorNormalize(dir);\n\t\t//if the roam target is far away anough\n\t\tif (len > 200) {\n\t\t\t//the roam target is in the given direction before walls\n\t\t\tVectorScale(dir, len * trace.fraction - 40, dir);\n\t\t\tVectorAdd(bs->origin, dir, bestorg);\n\t\t\t//get the coordinates of the floor below the roam target\n\t\t\tbelowbestorg[0] = bestorg[0];\n\t\t\tbelowbestorg[1] = bestorg[1];\n\t\t\tbelowbestorg[2] = bestorg[2] - 800;\n\t\t\tBotAI_Trace(&trace, bestorg, NULL, NULL, belowbestorg, bs->entitynum, MASK_SOLID);\n\t\t\t//\n\t\t\tif (!trace.startsolid) {\n\t\t\t\ttrace.endpos[2]++;\n\t\t\t\tpc = trap_PointContents(trace.endpos, bs->entitynum);\n\t\t\t\tif (!(pc & (CONTENTS_LAVA | CONTENTS_SLIME))) {\n\t\t\t\t\tVectorCopy(bestorg, goal);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tVectorCopy(bestorg, goal);\n}\n\n/*\n==================\nBotAttackMove\n==================\n*/\nbot_moveresult_t BotAttackMove(bot_state_t *bs, int tfl) {\n\tint movetype, i, attackentity;\n\tfloat attack_skill, jumper, croucher, dist, strafechange_time;\n\tfloat attack_dist, attack_range;\n\tvec3_t forward, backward, sideward, hordir, up = {0, 0, 1};\n\taas_entityinfo_t entinfo;\n\tbot_moveresult_t moveresult;\n\tbot_goal_t goal;\n\n\tattackentity = bs->enemy;\n\t//\n\tif (bs->attackchase_time > FloatTime()) {\n\t\t//create the chase goal\n\t\tgoal.entitynum = attackentity;\n\t\tgoal.areanum = bs->lastenemyareanum;\n\t\tVectorCopy(bs->lastenemyorigin, goal.origin);\n\t\tVectorSet(goal.mins, -8, -8, -8);\n\t\tVectorSet(goal.maxs, 8, 8, 8);\n\t\t//initialize the movement state\n\t\tBotSetupForMovement(bs);\n\t\t//move towards the goal\n\t\ttrap_BotMoveToGoal(&moveresult, bs->ms, &goal, tfl);\n\t\treturn moveresult;\n\t}\n\t//\n\tmemset(&moveresult, 0, sizeof(bot_moveresult_t));\n\t//\n\tattack_skill = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_ATTACK_SKILL, 0, 1);\n\tjumper = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_JUMPER, 0, 1);\n\tcroucher = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CROUCHER, 0, 1);\n\t//if the bot is really stupid\n\tif (attack_skill < 0.2) return moveresult;\n\t//initialize the movement state\n\tBotSetupForMovement(bs);\n\t//get the enemy entity info\n\tBotEntityInfo(attackentity, &entinfo);\n\t//direction towards the enemy\n\tVectorSubtract(entinfo.origin, bs->origin, forward);\n\t//the distance towards the enemy\n\tdist = VectorNormalize(forward);\n\tVectorNegate(forward, backward);\n\t//walk, crouch or jump\n\tmovetype = MOVE_WALK;\n\t//\n\tif (bs->attackcrouch_time < FloatTime() - 1) {\n\t\tif (random() < jumper) {\n\t\t\tmovetype = MOVE_JUMP;\n\t\t}\n\t\t//wait at least one second before crouching again\n\t\telse if (bs->attackcrouch_time < FloatTime() - 1 && random() < croucher) {\n\t\t\tbs->attackcrouch_time = FloatTime() + croucher * 5;\n\t\t}\n\t}\n\tif (bs->attackcrouch_time > FloatTime()) movetype = MOVE_CROUCH;\n\t//if the bot should jump\n\tif (movetype == MOVE_JUMP) {\n\t\t//if jumped last frame\n\t\tif (bs->attackjump_time > FloatTime()) {\n\t\t\tmovetype = MOVE_WALK;\n\t\t}\n\t\telse {\n\t\t\tbs->attackjump_time = FloatTime() + 1;\n\t\t}\n\t}\n\tif (bs->cur_ps.weapon == WP_GAUNTLET) {\n\t\tattack_dist = 0;\n\t\tattack_range = 0;\n\t}\n\telse {\n\t\tattack_dist = IDEAL_ATTACKDIST;\n\t\tattack_range = 40;\n\t}\n\t//if the bot is stupid\n\tif (attack_skill <= 0.4) {\n\t\t//just walk to or away from the enemy\n\t\tif (dist > attack_dist + attack_range) {\n\t\t\tif (trap_BotMoveInDirection(bs->ms, forward, 400, movetype)) return moveresult;\n\t\t}\n\t\tif (dist < attack_dist - attack_range) {\n\t\t\tif (trap_BotMoveInDirection(bs->ms, backward, 400, movetype)) return moveresult;\n\t\t}\n\t\treturn moveresult;\n\t}\n\t//increase the strafe time\n\tbs->attackstrafe_time += bs->thinktime;\n\t//get the strafe change time\n\tstrafechange_time = 0.4 + (1 - attack_skill) * 0.2;\n\tif (attack_skill > 0.7) strafechange_time += crandom() * 0.2;\n\t//if the strafe direction should be changed\n\tif (bs->attackstrafe_time > strafechange_time) {\n\t\t//some magic number :)\n\t\tif (random() > 0.935) {\n\t\t\t//flip the strafe direction\n\t\t\tbs->flags ^= BFL_STRAFERIGHT;\n\t\t\tbs->attackstrafe_time = 0;\n\t\t}\n\t}\n\t//\n\tfor (i = 0; i < 2; i++) {\n\t\thordir[0] = forward[0];\n\t\thordir[1] = forward[1];\n\t\thordir[2] = 0;\n\t\tVectorNormalize(hordir);\n\t\t//get the sideward vector\n\t\tCrossProduct(hordir, up, sideward);\n\t\t//reverse the vector depending on the strafe direction\n\t\tif (bs->flags & BFL_STRAFERIGHT) VectorNegate(sideward, sideward);\n\t\t//randomly go back a little\n\t\tif (random() > 0.9) {\n\t\t\tVectorAdd(sideward, backward, sideward);\n\t\t}\n\t\telse {\n\t\t\t//walk forward or backward to get at the ideal attack distance\n\t\t\tif (dist > attack_dist + attack_range) {\n\t\t\t\tVectorAdd(sideward, forward, sideward);\n\t\t\t}\n\t\t\telse if (dist < attack_dist - attack_range) {\n\t\t\t\tVectorAdd(sideward, backward, sideward);\n\t\t\t}\n\t\t}\n\t\t//perform the movement\n\t\tif (trap_BotMoveInDirection(bs->ms, sideward, 400, movetype))\n\t\t\treturn moveresult;\n\t\t//movement failed, flip the strafe direction\n\t\tbs->flags ^= BFL_STRAFERIGHT;\n\t\tbs->attackstrafe_time = 0;\n\t}\n\t//bot couldn't do any usefull movement\n//\tbs->attackchase_time = AAS_Time() + 6;\n\treturn moveresult;\n}\n\n/*\n==================\nBotSameTeam\n==================\n*/\nint BotSameTeam(bot_state_t *bs, int entnum) {\n\tchar info1[1024], info2[1024];\n\n\tif (bs->client < 0 || bs->client >= MAX_CLIENTS) {\n\t\t//BotAI_Print(PRT_ERROR, \"BotSameTeam: client out of range\\n\");\n\t\treturn qfalse;\n\t}\n\tif (entnum < 0 || entnum >= MAX_CLIENTS) {\n\t\t//BotAI_Print(PRT_ERROR, \"BotSameTeam: client out of range\\n\");\n\t\treturn qfalse;\n\t}\n\tif ( gametype >= GT_TEAM ) {\n\t\ttrap_GetConfigstring(CS_PLAYERS+bs->client, info1, sizeof(info1));\n\t\ttrap_GetConfigstring(CS_PLAYERS+entnum, info2, sizeof(info2));\n\t\t//\n\t\tif (atoi(Info_ValueForKey(info1, \"t\")) == atoi(Info_ValueForKey(info2, \"t\"))) return qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nInFieldOfVision\n==================\n*/\nqboolean InFieldOfVision(vec3_t viewangles, float fov, vec3_t angles)\n{\n\tint i;\n\tfloat diff, angle;\n\n\tfor (i = 0; i < 2; i++) {\n\t\tangle = AngleMod(viewangles[i]);\n\t\tangles[i] = AngleMod(angles[i]);\n\t\tdiff = angles[i] - angle;\n\t\tif (angles[i] > angle) {\n\t\t\tif (diff > 180.0) diff -= 360.0;\n\t\t}\n\t\telse {\n\t\t\tif (diff < -180.0) diff += 360.0;\n\t\t}\n\t\tif (diff > 0) {\n\t\t\tif (diff > fov * 0.5) return qfalse;\n\t\t}\n\t\telse {\n\t\t\tif (diff < -fov * 0.5) return qfalse;\n\t\t}\n\t}\n\treturn qtrue;\n}\n\n/*\n==================\nBotEntityVisible\n\nreturns visibility in the range [0, 1] taking fog and water surfaces into account\n==================\n*/\nfloat BotEntityVisible(int viewer, vec3_t eye, vec3_t viewangles, float fov, int ent) {\n\tint i, contents_mask, passent, hitent, infog, inwater, otherinfog, pc;\n\tfloat squaredfogdist, waterfactor, vis, bestvis;\n\tbsp_trace_t trace;\n\taas_entityinfo_t entinfo;\n\tvec3_t dir, entangles, start, end, middle;\n\n\t//calculate middle of bounding box\n\tBotEntityInfo(ent, &entinfo);\n\tVectorAdd(entinfo.mins, entinfo.maxs, middle);\n\tVectorScale(middle, 0.5, middle);\n\tVectorAdd(entinfo.origin, middle, middle);\n\t//check if entity is within field of vision\n\tVectorSubtract(middle, eye, dir);\n\tvectoangles(dir, entangles);\n\tif (!InFieldOfVision(viewangles, fov, entangles)) return 0;\n\t//\n\tpc = trap_AAS_PointContents(eye);\n\tinfog = (pc & CONTENTS_FOG);\n\tinwater = (pc & (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER));\n\t//\n\tbestvis = 0;\n\tfor (i = 0; i < 3; i++) {\n\t\t//if the point is not in potential visible sight\n\t\t//if (!AAS_inPVS(eye, middle)) continue;\n\t\t//\n\t\tcontents_mask = CONTENTS_SOLID|CONTENTS_PLAYERCLIP;\n\t\tpassent = viewer;\n\t\thitent = ent;\n\t\tVectorCopy(eye, start);\n\t\tVectorCopy(middle, end);\n\t\t//if the entity is in water, lava or slime\n\t\tif (trap_AAS_PointContents(middle) & (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER)) {\n\t\t\tcontents_mask |= (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER);\n\t\t}\n\t\t//if eye is in water, lava or slime\n\t\tif (inwater) {\n\t\t\tif (!(contents_mask & (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER))) {\n\t\t\t\tpassent = ent;\n\t\t\t\thitent = viewer;\n\t\t\t\tVectorCopy(middle, start);\n\t\t\t\tVectorCopy(eye, end);\n\t\t\t}\n\t\t\tcontents_mask ^= (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER);\n\t\t}\n\t\t//trace from start to end\n\t\tBotAI_Trace(&trace, start, NULL, NULL, end, passent, contents_mask);\n\t\t//if water was hit\n\t\twaterfactor = 1.0;\n\t\tif (trace.contents & (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER)) {\n\t\t\t//if the water surface is translucent\n\t\t\tif (1) {\n\t\t\t\t//trace through the water\n\t\t\t\tcontents_mask &= ~(CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER);\n\t\t\t\tBotAI_Trace(&trace, trace.endpos, NULL, NULL, end, passent, contents_mask);\n\t\t\t\twaterfactor = 0.5;\n\t\t\t}\n\t\t}\n\t\t//if a full trace or the hitent was hit\n\t\tif (trace.fraction >= 1 || trace.ent == hitent) {\n\t\t\t//check for fog, assuming there's only one fog brush where\n\t\t\t//either the viewer or the entity is in or both are in\n\t\t\totherinfog = (trap_AAS_PointContents(middle) & CONTENTS_FOG);\n\t\t\tif (infog && otherinfog) {\n\t\t\t\tVectorSubtract(trace.endpos, eye, dir);\n\t\t\t\tsquaredfogdist = VectorLengthSquared(dir);\n\t\t\t}\n\t\t\telse if (infog) {\n\t\t\t\tVectorCopy(trace.endpos, start);\n\t\t\t\tBotAI_Trace(&trace, start, NULL, NULL, eye, viewer, CONTENTS_FOG);\n\t\t\t\tVectorSubtract(eye, trace.endpos, dir);\n\t\t\t\tsquaredfogdist = VectorLengthSquared(dir);\n\t\t\t}\n\t\t\telse if (otherinfog) {\n\t\t\t\tVectorCopy(trace.endpos, end);\n\t\t\t\tBotAI_Trace(&trace, eye, NULL, NULL, end, viewer, CONTENTS_FOG);\n\t\t\t\tVectorSubtract(end, trace.endpos, dir);\n\t\t\t\tsquaredfogdist = VectorLengthSquared(dir);\n\t\t\t}\n\t\t\telse {\n\t\t\t\t//if the entity and the viewer are not in fog assume there's no fog in between\n\t\t\t\tsquaredfogdist = 0;\n\t\t\t}\n\t\t\t//decrease visibility with the view distance through fog\n\t\t\tvis = 1 / ((squaredfogdist * 0.001) < 1 ? 1 : (squaredfogdist * 0.001));\n\t\t\t//if entering water visibility is reduced\n\t\t\tvis *= waterfactor;\n\t\t\t//\n\t\t\tif (vis > bestvis) bestvis = vis;\n\t\t\t//if pretty much no fog\n\t\t\tif (bestvis >= 0.95) return bestvis;\n\t\t}\n\t\t//check bottom and top of bounding box as well\n\t\tif (i == 0) middle[2] += entinfo.mins[2];\n\t\telse if (i == 1) middle[2] += entinfo.maxs[2] - entinfo.mins[2];\n\t}\n\treturn bestvis;\n}\n\n/*\n==================\nBotFindEnemy\n==================\n*/\nint BotFindEnemy(bot_state_t *bs, int curenemy) {\n\tint i, healthdecrease;\n\tfloat f, alertness, easyfragger, vis;\n\tfloat squaredist, cursquaredist;\n\taas_entityinfo_t entinfo, curenemyinfo;\n\tvec3_t dir, angles;\n\n\talertness = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_ALERTNESS, 0, 1);\n\teasyfragger = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_EASY_FRAGGER, 0, 1);\n\t//check if the health decreased\n\thealthdecrease = bs->lasthealth > bs->inventory[INVENTORY_HEALTH];\n\t//remember the current health value\n\tbs->lasthealth = bs->inventory[INVENTORY_HEALTH];\n\t//\n\tif (curenemy >= 0) {\n\t\tBotEntityInfo(curenemy, &curenemyinfo);\n\t\tif (EntityCarriesFlag(&curenemyinfo)) return qfalse;\n\t\tVectorSubtract(curenemyinfo.origin, bs->origin, dir);\n\t\tcursquaredist = VectorLengthSquared(dir);\n\t}\n\telse {\n\t\tcursquaredist = 0;\n\t}\n#ifdef MISSIONPACK\n\tif (gametype == GT_OBELISK) {\n\t\tvec3_t target;\n\t\tbot_goal_t *goal;\n\t\tbsp_trace_t trace;\n\n\t\tif (BotTeam(bs) == TEAM_RED)\n\t\t\tgoal = &blueobelisk;\n\t\telse\n\t\t\tgoal = &redobelisk;\n\t\t//if the obelisk is visible\n\t\tVectorCopy(goal->origin, target);\n\t\ttarget[2] += 1;\n\t\tBotAI_Trace(&trace, bs->eye, NULL, NULL, target, bs->client, CONTENTS_SOLID);\n\t\tif (trace.fraction >= 1 || trace.ent == goal->entitynum) {\n\t\t\tif (goal->entitynum == bs->enemy) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tbs->enemy = goal->entitynum;\n\t\t\tbs->enemysight_time = FloatTime();\n\t\t\tbs->enemysuicide = qfalse;\n\t\t\tbs->enemydeath_time = 0;\n\t\t\tbs->enemyvisible_time = FloatTime();\n\t\t\treturn qtrue;\n\t\t}\n\t}\n#endif\n\t//\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\n\t\tif (i == bs->client) continue;\n\t\t//if it's the current enemy\n\t\tif (i == curenemy) continue;\n\t\t//\n\t\tBotEntityInfo(i, &entinfo);\n\t\t//\n\t\tif (!entinfo.valid) continue;\n\t\t//if the enemy isn't dead and the enemy isn't the bot self\n\t\tif (EntityIsDead(&entinfo) || entinfo.number == bs->entitynum) continue;\n\t\t//if the enemy is invisible and not shooting\n\t\tif (EntityIsInvisible(&entinfo) && !EntityIsShooting(&entinfo)) {\n\t\t\tcontinue;\n\t\t}\n\t\t//if not an easy fragger don't shoot at chatting players\n\t\tif (easyfragger < 0.5 && EntityIsChatting(&entinfo)) continue;\n\t\t//\n\t\tif (lastteleport_time > FloatTime() - 3) {\n\t\t\tVectorSubtract(entinfo.origin, lastteleport_origin, dir);\n\t\t\tif (VectorLengthSquared(dir) < Square(70)) continue;\n\t\t}\n\t\t//calculate the distance towards the enemy\n\t\tVectorSubtract(entinfo.origin, bs->origin, dir);\n\t\tsquaredist = VectorLengthSquared(dir);\n\t\t//if this entity is not carrying a flag\n\t\tif (!EntityCarriesFlag(&entinfo))\n\t\t{\n\t\t\t//if this enemy is further away than the current one\n\t\t\tif (curenemy >= 0 && squaredist > cursquaredist) continue;\n\t\t} //end if\n\t\t//if the bot has no\n\t\tif (squaredist > Square(900.0 + alertness * 4000.0)) continue;\n\t\t//if on the same team\n\t\tif (BotSameTeam(bs, i)) continue;\n\t\t//if the bot's health decreased or the enemy is shooting\n\t\tif (curenemy < 0 && (healthdecrease || EntityIsShooting(&entinfo)))\n\t\t\tf = 360;\n\t\telse\n\t\t\tf = 90 + 90 - (90 - (squaredist > Square(810) ? Square(810) : squaredist) / (810 * 9));\n\t\t//check if the enemy is visible\n\t\tvis = BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, f, i);\n\t\tif (vis <= 0) continue;\n\t\t//if the enemy is quite far away, not shooting and the bot is not damaged\n\t\tif (curenemy < 0 && squaredist > Square(100) && !healthdecrease && !EntityIsShooting(&entinfo))\n\t\t{\n\t\t\t//check if we can avoid this enemy\n\t\t\tVectorSubtract(bs->origin, entinfo.origin, dir);\n\t\t\tvectoangles(dir, angles);\n\t\t\t//if the bot isn't in the fov of the enemy\n\t\t\tif (!InFieldOfVision(entinfo.angles, 90, angles)) {\n\t\t\t\t//update some stuff for this enemy\n\t\t\t\tBotUpdateBattleInventory(bs, i);\n\t\t\t\t//if the bot doesn't really want to fight\n\t\t\t\tif (BotWantsToRetreat(bs)) continue;\n\t\t\t}\n\t\t}\n\t\t//found an enemy\n\t\tbs->enemy = entinfo.number;\n\t\tif (curenemy >= 0) bs->enemysight_time = FloatTime() - 2;\n\t\telse bs->enemysight_time = FloatTime();\n\t\tbs->enemysuicide = qfalse;\n\t\tbs->enemydeath_time = 0;\n\t\tbs->enemyvisible_time = FloatTime();\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nBotTeamFlagCarrierVisible\n==================\n*/\nint BotTeamFlagCarrierVisible(bot_state_t *bs) {\n\tint i;\n\tfloat vis;\n\taas_entityinfo_t entinfo;\n\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\tif (i == bs->client)\n\t\t\tcontinue;\n\t\t//\n\t\tBotEntityInfo(i, &entinfo);\n\t\t//if this player is active\n\t\tif (!entinfo.valid)\n\t\t\tcontinue;\n\t\t//if this player is carrying a flag\n\t\tif (!EntityCarriesFlag(&entinfo))\n\t\t\tcontinue;\n\t\t//if the flag carrier is not on the same team\n\t\tif (!BotSameTeam(bs, i))\n\t\t\tcontinue;\n\t\t//if the flag carrier is not visible\n\t\tvis = BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, i);\n\t\tif (vis <= 0)\n\t\t\tcontinue;\n\t\t//\n\t\treturn i;\n\t}\n\treturn -1;\n}\n\n/*\n==================\nBotTeamFlagCarrier\n==================\n*/\nint BotTeamFlagCarrier(bot_state_t *bs) {\n\tint i;\n\taas_entityinfo_t entinfo;\n\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\tif (i == bs->client)\n\t\t\tcontinue;\n\t\t//\n\t\tBotEntityInfo(i, &entinfo);\n\t\t//if this player is active\n\t\tif (!entinfo.valid)\n\t\t\tcontinue;\n\t\t//if this player is carrying a flag\n\t\tif (!EntityCarriesFlag(&entinfo))\n\t\t\tcontinue;\n\t\t//if the flag carrier is not on the same team\n\t\tif (!BotSameTeam(bs, i))\n\t\t\tcontinue;\n\t\t//\n\t\treturn i;\n\t}\n\treturn -1;\n}\n\n/*\n==================\nBotEnemyFlagCarrierVisible\n==================\n*/\nint BotEnemyFlagCarrierVisible(bot_state_t *bs) {\n\tint i;\n\tfloat vis;\n\taas_entityinfo_t entinfo;\n\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\tif (i == bs->client)\n\t\t\tcontinue;\n\t\t//\n\t\tBotEntityInfo(i, &entinfo);\n\t\t//if this player is active\n\t\tif (!entinfo.valid)\n\t\t\tcontinue;\n\t\t//if this player is carrying a flag\n\t\tif (!EntityCarriesFlag(&entinfo))\n\t\t\tcontinue;\n\t\t//if the flag carrier is on the same team\n\t\tif (BotSameTeam(bs, i))\n\t\t\tcontinue;\n\t\t//if the flag carrier is not visible\n\t\tvis = BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, i);\n\t\tif (vis <= 0)\n\t\t\tcontinue;\n\t\t//\n\t\treturn i;\n\t}\n\treturn -1;\n}\n\n/*\n==================\nBotVisibleTeamMatesAndEnemies\n==================\n*/\nvoid BotVisibleTeamMatesAndEnemies(bot_state_t *bs, int *teammates, int *enemies, float range) {\n\tint i;\n\tfloat vis;\n\taas_entityinfo_t entinfo;\n\tvec3_t dir;\n\n\tif (teammates)\n\t\t*teammates = 0;\n\tif (enemies)\n\t\t*enemies = 0;\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\tif (i == bs->client)\n\t\t\tcontinue;\n\t\t//\n\t\tBotEntityInfo(i, &entinfo);\n\t\t//if this player is active\n\t\tif (!entinfo.valid)\n\t\t\tcontinue;\n\t\t//if this player is carrying a flag\n\t\tif (!EntityCarriesFlag(&entinfo))\n\t\t\tcontinue;\n\t\t//if not within range\n\t\tVectorSubtract(entinfo.origin, bs->origin, dir);\n\t\tif (VectorLengthSquared(dir) > Square(range))\n\t\t\tcontinue;\n\t\t//if the flag carrier is not visible\n\t\tvis = BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, i);\n\t\tif (vis <= 0)\n\t\t\tcontinue;\n\t\t//if the flag carrier is on the same team\n\t\tif (BotSameTeam(bs, i)) {\n\t\t\tif (teammates)\n\t\t\t\t(*teammates)++;\n\t\t}\n\t\telse {\n\t\t\tif (enemies)\n\t\t\t\t(*enemies)++;\n\t\t}\n\t}\n}\n\n#ifdef MISSIONPACK\n/*\n==================\nBotTeamCubeCarrierVisible\n==================\n*/\nint BotTeamCubeCarrierVisible(bot_state_t *bs) {\n\tint i;\n\tfloat vis;\n\taas_entityinfo_t entinfo;\n\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\tif (i == bs->client) continue;\n\t\t//\n\t\tBotEntityInfo(i, &entinfo);\n\t\t//if this player is active\n\t\tif (!entinfo.valid) continue;\n\t\t//if this player is carrying a flag\n\t\tif (!EntityCarriesCubes(&entinfo)) continue;\n\t\t//if the flag carrier is not on the same team\n\t\tif (!BotSameTeam(bs, i)) continue;\n\t\t//if the flag carrier is not visible\n\t\tvis = BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, i);\n\t\tif (vis <= 0) continue;\n\t\t//\n\t\treturn i;\n\t}\n\treturn -1;\n}\n\n/*\n==================\nBotEnemyCubeCarrierVisible\n==================\n*/\nint BotEnemyCubeCarrierVisible(bot_state_t *bs) {\n\tint i;\n\tfloat vis;\n\taas_entityinfo_t entinfo;\n\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\tif (i == bs->client)\n\t\t\tcontinue;\n\t\t//\n\t\tBotEntityInfo(i, &entinfo);\n\t\t//if this player is active\n\t\tif (!entinfo.valid)\n\t\t\tcontinue;\n\t\t//if this player is carrying a flag\n\t\tif (!EntityCarriesCubes(&entinfo)) continue;\n\t\t//if the flag carrier is on the same team\n\t\tif (BotSameTeam(bs, i))\n\t\t\tcontinue;\n\t\t//if the flag carrier is not visible\n\t\tvis = BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, i);\n\t\tif (vis <= 0)\n\t\t\tcontinue;\n\t\t//\n\t\treturn i;\n\t}\n\treturn -1;\n}\n#endif\n\n/*\n==================\nBotAimAtEnemy\n==================\n*/\nvoid BotAimAtEnemy(bot_state_t *bs) {\n\tint i, enemyvisible;\n\tfloat dist, f, aim_skill, aim_accuracy, speed, reactiontime;\n\tvec3_t dir, bestorigin, end, start, groundtarget, cmdmove, enemyvelocity;\n\tvec3_t mins = {-4,-4,-4}, maxs = {4, 4, 4};\n\tweaponinfo_t wi;\n\taas_entityinfo_t entinfo;\n\tbot_goal_t goal;\n\tbsp_trace_t trace;\n\tvec3_t target;\n\n\t//if the bot has no enemy\n\tif (bs->enemy < 0) {\n\t\treturn;\n\t}\n\t//get the enemy entity information\n\tBotEntityInfo(bs->enemy, &entinfo);\n\t//if this is not a player (should be an obelisk)\n\tif (bs->enemy >= MAX_CLIENTS) {\n\t\t//if the obelisk is visible\n\t\tVectorCopy(entinfo.origin, target);\n#ifdef MISSIONPACK\n\t\t// if attacking an obelisk\n\t\tif ( bs->enemy == redobelisk.entitynum ||\n\t\t\tbs->enemy == blueobelisk.entitynum ) {\n\t\t\ttarget[2] += 32;\n\t\t}\n#endif\n\t\t//aim at the obelisk\n\t\tVectorSubtract(target, bs->eye, dir);\n\t\tvectoangles(dir, bs->ideal_viewangles);\n\t\t//set the aim target before trying to attack\n\t\tVectorCopy(target, bs->aimtarget);\n\t\treturn;\n\t}\n\t//\n\t//BotAI_Print(PRT_MESSAGE, \"client %d: aiming at client %d\\n\", bs->entitynum, bs->enemy);\n\t//\n\taim_skill = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_AIM_SKILL, 0, 1);\n\taim_accuracy = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_AIM_ACCURACY, 0, 1);\n\t//\n\tif (aim_skill > 0.95) {\n\t\t//don't aim too early\n\t\treactiontime = 0.5 * trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_REACTIONTIME, 0, 1);\n\t\tif (bs->enemysight_time > FloatTime() - reactiontime) return;\n\t\tif (bs->teleport_time > FloatTime() - reactiontime) return;\n\t}\n\n\t//get the weapon information\n\ttrap_BotGetWeaponInfo(bs->ws, bs->weaponnum, &wi);\n\t//get the weapon specific aim accuracy and or aim skill\n\tif (wi.number == WP_MACHINEGUN) {\n\t\taim_accuracy = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_AIM_ACCURACY_MACHINEGUN, 0, 1);\n\t}\n\telse if (wi.number == WP_SHOTGUN) {\n\t\taim_accuracy = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_AIM_ACCURACY_SHOTGUN, 0, 1);\n\t}\n\telse if (wi.number == WP_GRENADE_LAUNCHER) {\n\t\taim_accuracy = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_AIM_ACCURACY_GRENADELAUNCHER, 0, 1);\n\t\taim_skill = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_AIM_SKILL_GRENADELAUNCHER, 0, 1);\n\t}\n\telse if (wi.number == WP_ROCKET_LAUNCHER) {\n\t\taim_accuracy = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_AIM_ACCURACY_ROCKETLAUNCHER, 0, 1);\n\t\taim_skill = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_AIM_SKILL_ROCKETLAUNCHER, 0, 1);\n\t}\n\telse if (wi.number == WP_LIGHTNING) {\n\t\taim_accuracy = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_AIM_ACCURACY_LIGHTNING, 0, 1);\n\t}\n\telse if (wi.number == WP_RAILGUN) {\n\t\taim_accuracy = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_AIM_ACCURACY_RAILGUN, 0, 1);\n\t}\n\telse if (wi.number == WP_PLASMAGUN) {\n\t\taim_accuracy = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_AIM_ACCURACY_PLASMAGUN, 0, 1);\n\t\taim_skill = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_AIM_SKILL_PLASMAGUN, 0, 1);\n\t}\n\telse if (wi.number == WP_BFG) {\n\t\taim_accuracy = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_AIM_ACCURACY_BFG10K, 0, 1);\n\t\taim_skill = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_AIM_SKILL_BFG10K, 0, 1);\n\t}\n\t//\n\tif (aim_accuracy <= 0) aim_accuracy = 0.0001f;\n\t//get the enemy entity information\n\tBotEntityInfo(bs->enemy, &entinfo);\n\t//if the enemy is invisible then shoot crappy most of the time\n\tif (EntityIsInvisible(&entinfo)) {\n\t\tif (random() > 0.1) aim_accuracy *= 0.4f;\n\t}\n\t//\n\tVectorSubtract(entinfo.origin, entinfo.lastvisorigin, enemyvelocity);\n\tVectorScale(enemyvelocity, 1 / entinfo.update_time, enemyvelocity);\n\t//enemy origin and velocity is remembered every 0.5 seconds\n\tif (bs->enemyposition_time < FloatTime()) {\n\t\t//\n\t\tbs->enemyposition_time = FloatTime() + 0.5;\n\t\tVectorCopy(enemyvelocity, bs->enemyvelocity);\n\t\tVectorCopy(entinfo.origin, bs->enemyorigin);\n\t}\n\t//if not extremely skilled\n\tif (aim_skill < 0.9) {\n\t\tVectorSubtract(entinfo.origin, bs->enemyorigin, dir);\n\t\t//if the enemy moved a bit\n\t\tif (VectorLengthSquared(dir) > Square(48)) {\n\t\t\t//if the enemy changed direction\n\t\t\tif (DotProduct(bs->enemyvelocity, enemyvelocity) < 0) {\n\t\t\t\t//aim accuracy should be worse now\n\t\t\t\taim_accuracy *= 0.7f;\n\t\t\t}\n\t\t}\n\t}\n\t//check visibility of enemy\n\tenemyvisible = BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, bs->enemy);\n\t//if the enemy is visible\n\tif (enemyvisible) {\n\t\t//\n\t\tVectorCopy(entinfo.origin, bestorigin);\n\t\tbestorigin[2] += 8;\n\t\t//get the start point shooting from\n\t\t//NOTE: the x and y projectile start offsets are ignored\n\t\tVectorCopy(bs->origin, start);\n\t\tstart[2] += bs->cur_ps.viewheight;\n\t\tstart[2] += wi.offset[2];\n\t\t//\n\t\tBotAI_Trace(&trace, start, mins, maxs, bestorigin, bs->entitynum, MASK_SHOT);\n\t\t//if the enemy is NOT hit\n\t\tif (trace.fraction <= 1 && trace.ent != entinfo.number) {\n\t\t\tbestorigin[2] += 16;\n\t\t}\n\t\t//if it is not an instant hit weapon the bot might want to predict the enemy\n\t\tif (wi.speed) {\n\t\t\t//\n\t\t\tVectorSubtract(bestorigin, bs->origin, dir);\n\t\t\tdist = VectorLength(dir);\n\t\t\tVectorSubtract(entinfo.origin, bs->enemyorigin, dir);\n\t\t\t//if the enemy is NOT pretty far away and strafing just small steps left and right\n\t\t\tif (!(dist > 100 && VectorLengthSquared(dir) < Square(32))) {\n\t\t\t\t//if skilled anough do exact prediction\n\t\t\t\tif (aim_skill > 0.8 &&\n\t\t\t\t\t\t//if the weapon is ready to fire\n\t\t\t\t\t\tbs->cur_ps.weaponstate == WEAPON_READY) {\n\t\t\t\t\taas_clientmove_t move;\n\t\t\t\t\tvec3_t origin;\n\n\t\t\t\t\tVectorSubtract(entinfo.origin, bs->origin, dir);\n\t\t\t\t\t//distance towards the enemy\n\t\t\t\t\tdist = VectorLength(dir);\n\t\t\t\t\t//direction the enemy is moving in\n\t\t\t\t\tVectorSubtract(entinfo.origin, entinfo.lastvisorigin, dir);\n\t\t\t\t\t//\n\t\t\t\t\tVectorScale(dir, 1 / entinfo.update_time, dir);\n\t\t\t\t\t//\n\t\t\t\t\tVectorCopy(entinfo.origin, origin);\n\t\t\t\t\torigin[2] += 1;\n\t\t\t\t\t//\n\t\t\t\t\tVectorClear(cmdmove);\n\t\t\t\t\t//AAS_ClearShownDebugLines();\n\t\t\t\t\ttrap_AAS_PredictClientMovement(&move, bs->enemy, origin,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tPRESENCE_CROUCH, qfalse,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdir, cmdmove, 0,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdist * 10 / wi.speed, 0.1f, 0, 0, qfalse);\n\t\t\t\t\tVectorCopy(move.endpos, bestorigin);\n\t\t\t\t\t//BotAI_Print(PRT_MESSAGE, \"%1.1f predicted speed = %f, frames = %f\\n\", FloatTime(), VectorLength(dir), dist * 10 / wi.speed);\n\t\t\t\t}\n\t\t\t\t//if not that skilled do linear prediction\n\t\t\t\telse if (aim_skill > 0.4) {\n\t\t\t\t\tVectorSubtract(entinfo.origin, bs->origin, dir);\n\t\t\t\t\t//distance towards the enemy\n\t\t\t\t\tdist = VectorLength(dir);\n\t\t\t\t\t//direction the enemy is moving in\n\t\t\t\t\tVectorSubtract(entinfo.origin, entinfo.lastvisorigin, dir);\n\t\t\t\t\tdir[2] = 0;\n\t\t\t\t\t//\n\t\t\t\t\tspeed = VectorNormalize(dir) / entinfo.update_time;\n\t\t\t\t\t//botimport.Print(PRT_MESSAGE, \"speed = %f, wi->speed = %f\\n\", speed, wi->speed);\n\t\t\t\t\t//best spot to aim at\n\t\t\t\t\tVectorMA(entinfo.origin, (dist / wi.speed) * speed, dir, bestorigin);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t//if the projectile does radial damage\n\t\tif (aim_skill > 0.6 && wi.proj.damagetype & DAMAGETYPE_RADIAL) {\n\t\t\t//if the enemy isn't standing significantly higher than the bot\n\t\t\tif (entinfo.origin[2] < bs->origin[2] + 16) {\n\t\t\t\t//try to aim at the ground in front of the enemy\n\t\t\t\tVectorCopy(entinfo.origin, end);\n\t\t\t\tend[2] -= 64;\n\t\t\t\tBotAI_Trace(&trace, entinfo.origin, NULL, NULL, end, entinfo.number, MASK_SHOT);\n\t\t\t\t//\n\t\t\t\tVectorCopy(bestorigin, groundtarget);\n\t\t\t\tif (trace.startsolid) groundtarget[2] = entinfo.origin[2] - 16;\n\t\t\t\telse groundtarget[2] = trace.endpos[2] - 8;\n\t\t\t\t//trace a line from projectile start to ground target\n\t\t\t\tBotAI_Trace(&trace, start, NULL, NULL, groundtarget, bs->entitynum, MASK_SHOT);\n\t\t\t\t//if hitpoint is not vertically too far from the ground target\n\t\t\t\tif (fabs(trace.endpos[2] - groundtarget[2]) < 50) {\n\t\t\t\t\tVectorSubtract(trace.endpos, groundtarget, dir);\n\t\t\t\t\t//if the hitpoint is near anough the ground target\n\t\t\t\t\tif (VectorLengthSquared(dir) < Square(60)) {\n\t\t\t\t\t\tVectorSubtract(trace.endpos, start, dir);\n\t\t\t\t\t\t//if the hitpoint is far anough from the bot\n\t\t\t\t\t\tif (VectorLengthSquared(dir) > Square(100)) {\n\t\t\t\t\t\t\t//check if the bot is visible from the ground target\n\t\t\t\t\t\t\ttrace.endpos[2] += 1;\n\t\t\t\t\t\t\tBotAI_Trace(&trace, trace.endpos, NULL, NULL, entinfo.origin, entinfo.number, MASK_SHOT);\n\t\t\t\t\t\t\tif (trace.fraction >= 1) {\n\t\t\t\t\t\t\t\t//botimport.Print(PRT_MESSAGE, \"%1.1f aiming at ground\\n\", AAS_Time());\n\t\t\t\t\t\t\t\tVectorCopy(groundtarget, bestorigin);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbestorigin[0] += 20 * crandom() * (1 - aim_accuracy);\n\t\tbestorigin[1] += 20 * crandom() * (1 - aim_accuracy);\n\t\tbestorigin[2] += 10 * crandom() * (1 - aim_accuracy);\n\t}\n\telse {\n\t\t//\n\t\tVectorCopy(bs->lastenemyorigin, bestorigin);\n\t\tbestorigin[2] += 8;\n\t\t//if the bot is skilled anough\n\t\tif (aim_skill > 0.5) {\n\t\t\t//do prediction shots around corners\n\t\t\tif (wi.number == WP_BFG ||\n\t\t\t\twi.number == WP_ROCKET_LAUNCHER ||\n\t\t\t\twi.number == WP_GRENADE_LAUNCHER) {\n\t\t\t\t//create the chase goal\n\t\t\t\tgoal.entitynum = bs->client;\n\t\t\t\tgoal.areanum = bs->areanum;\n\t\t\t\tVectorCopy(bs->eye, goal.origin);\n\t\t\t\tVectorSet(goal.mins, -8, -8, -8);\n\t\t\t\tVectorSet(goal.maxs, 8, 8, 8);\n\t\t\t\t//\n\t\t\t\tif (trap_BotPredictVisiblePosition(bs->lastenemyorigin, bs->lastenemyareanum, &goal, TFL_DEFAULT, target)) {\n\t\t\t\t\tVectorSubtract(target, bs->eye, dir);\n\t\t\t\t\tif (VectorLengthSquared(dir) > Square(80)) {\n\t\t\t\t\t\tVectorCopy(target, bestorigin);\n\t\t\t\t\t\tbestorigin[2] -= 20;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\taim_accuracy = 1;\n\t\t\t}\n\t\t}\n\t}\n\t//\n\tif (enemyvisible) {\n\t\tBotAI_Trace(&trace, bs->eye, NULL, NULL, bestorigin, bs->entitynum, MASK_SHOT);\n\t\tVectorCopy(trace.endpos, bs->aimtarget);\n\t}\n\telse {\n\t\tVectorCopy(bestorigin, bs->aimtarget);\n\t}\n\t//get aim direction\n\tVectorSubtract(bestorigin, bs->eye, dir);\n\t//\n\tif (wi.number == WP_MACHINEGUN ||\n\t\twi.number == WP_SHOTGUN ||\n\t\twi.number == WP_LIGHTNING ||\n\t\twi.number == WP_RAILGUN) {\n\t\t//distance towards the enemy\n\t\tdist = VectorLength(dir);\n\t\tif (dist > 150) dist = 150;\n\t\tf = 0.6 + dist / 150 * 0.4;\n\t\taim_accuracy *= f;\n\t}\n\t//add some random stuff to the aim direction depending on the aim accuracy\n\tif (aim_accuracy < 0.8) {\n\t\tVectorNormalize(dir);\n\t\tfor (i = 0; i < 3; i++) dir[i] += 0.3 * crandom() * (1 - aim_accuracy);\n\t}\n\t//set the ideal view angles\n\tvectoangles(dir, bs->ideal_viewangles);\n\t//take the weapon spread into account for lower skilled bots\n\tbs->ideal_viewangles[PITCH] += 6 * wi.vspread * crandom() * (1 - aim_accuracy);\n\tbs->ideal_viewangles[PITCH] = AngleMod(bs->ideal_viewangles[PITCH]);\n\tbs->ideal_viewangles[YAW] += 6 * wi.hspread * crandom() * (1 - aim_accuracy);\n\tbs->ideal_viewangles[YAW] = AngleMod(bs->ideal_viewangles[YAW]);\n\t//if the bots should be really challenging\n\tif (bot_challenge.integer) {\n\t\t//if the bot is really accurate and has the enemy in view for some time\n\t\tif (aim_accuracy > 0.9 && bs->enemysight_time < FloatTime() - 1) {\n\t\t\t//set the view angles directly\n\t\t\tif (bs->ideal_viewangles[PITCH] > 180) bs->ideal_viewangles[PITCH] -= 360;\n\t\t\tVectorCopy(bs->ideal_viewangles, bs->viewangles);\n\t\t\ttrap_EA_View(bs->client, bs->viewangles);\n\t\t}\n\t}\n}\n\n/*\n==================\nBotCheckAttack\n==================\n*/\nvoid BotCheckAttack(bot_state_t *bs) {\n\tfloat points, reactiontime, fov, firethrottle;\n\tint attackentity;\n\tbsp_trace_t bsptrace;\n\t//float selfpreservation;\n\tvec3_t forward, right, start, end, dir, angles;\n\tweaponinfo_t wi;\n\tbsp_trace_t trace;\n\taas_entityinfo_t entinfo;\n\tvec3_t mins = {-8, -8, -8}, maxs = {8, 8, 8};\n\n\tattackentity = bs->enemy;\n\t//\n\tBotEntityInfo(attackentity, &entinfo);\n\t// if not attacking a player\n\tif (attackentity >= MAX_CLIENTS) {\n#ifdef MISSIONPACK\n\t\t// if attacking an obelisk\n\t\tif ( entinfo.number == redobelisk.entitynum ||\n\t\t\tentinfo.number == blueobelisk.entitynum ) {\n\t\t\t// if obelisk is respawning return\n\t\t\tif ( g_entities[entinfo.number].activator &&\n\t\t\t\tg_entities[entinfo.number].activator->s.frame == 2 ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n#endif\n\t}\n\t//\n\treactiontime = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_REACTIONTIME, 0, 1);\n\tif (bs->enemysight_time > FloatTime() - reactiontime) return;\n\tif (bs->teleport_time > FloatTime() - reactiontime) return;\n\t//if changing weapons\n\tif (bs->weaponchange_time > FloatTime() - 0.1) return;\n\t//check fire throttle characteristic\n\tif (bs->firethrottlewait_time > FloatTime()) return;\n\tfirethrottle = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_FIRETHROTTLE, 0, 1);\n\tif (bs->firethrottleshoot_time < FloatTime()) {\n\t\tif (random() > firethrottle) {\n\t\t\tbs->firethrottlewait_time = FloatTime() + firethrottle;\n\t\t\tbs->firethrottleshoot_time = 0;\n\t\t}\n\t\telse {\n\t\t\tbs->firethrottleshoot_time = FloatTime() + 1 - firethrottle;\n\t\t\tbs->firethrottlewait_time = 0;\n\t\t}\n\t}\n\t//\n\t//\n\tVectorSubtract(bs->aimtarget, bs->eye, dir);\n\t//\n\tif (bs->weaponnum == WP_GAUNTLET) {\n\t\tif (VectorLengthSquared(dir) > Square(60)) {\n\t\t\treturn;\n\t\t}\n\t}\n\tif (VectorLengthSquared(dir) < Square(100))\n\t\tfov = 120;\n\telse\n\t\tfov = 50;\n\t//\n\tvectoangles(dir, angles);\n\tif (!InFieldOfVision(bs->viewangles, fov, angles))\n\t\treturn;\n\tBotAI_Trace(&bsptrace, bs->eye, NULL, NULL, bs->aimtarget, bs->client, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);\n\tif (bsptrace.fraction < 1 && bsptrace.ent != attackentity)\n\t\treturn;\n\n\t//get the weapon info\n\ttrap_BotGetWeaponInfo(bs->ws, bs->weaponnum, &wi);\n\t//get the start point shooting from\n\tVectorCopy(bs->origin, start);\n\tstart[2] += bs->cur_ps.viewheight;\n\tAngleVectors(bs->viewangles, forward, right, NULL);\n\tstart[0] += forward[0] * wi.offset[0] + right[0] * wi.offset[1];\n\tstart[1] += forward[1] * wi.offset[0] + right[1] * wi.offset[1];\n\tstart[2] += forward[2] * wi.offset[0] + right[2] * wi.offset[1] + wi.offset[2];\n\t//end point aiming at\n\tVectorMA(start, 1000, forward, end);\n\t//a little back to make sure not inside a very close enemy\n\tVectorMA(start, -12, forward, start);\n\tBotAI_Trace(&trace, start, mins, maxs, end, bs->entitynum, MASK_SHOT);\n\t//if the entity is a client\n\tif (trace.ent > 0 && trace.ent <= MAX_CLIENTS) {\n\t\tif (trace.ent != attackentity) {\n\t\t\t//if a teammate is hit\n\t\t\tif (BotSameTeam(bs, trace.ent))\n\t\t\t\treturn;\n\t\t}\n\t}\n\t//if won't hit the enemy or not attacking a player (obelisk)\n\tif (trace.ent != attackentity || attackentity >= MAX_CLIENTS) {\n\t\t//if the projectile does radial damage\n\t\tif (wi.proj.damagetype & DAMAGETYPE_RADIAL) {\n\t\t\tif (trace.fraction * 1000 < wi.proj.radius) {\n\t\t\t\tpoints = (wi.proj.damage - 0.5 * trace.fraction * 1000) * 0.5;\n\t\t\t\tif (points > 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\t//FIXME: check if a teammate gets radial damage\n\t\t}\n\t}\n\t//if fire has to be release to activate weapon\n\tif (wi.flags & WFL_FIRERELEASED) {\n\t\tif (bs->flags & BFL_ATTACKED) {\n\t\t\ttrap_EA_Attack(bs->client);\n\t\t}\n\t}\n\telse {\n\t\ttrap_EA_Attack(bs->client);\n\t}\n\tbs->flags ^= BFL_ATTACKED;\n}\n\n/*\n==================\nBotMapScripts\n==================\n*/\nvoid BotMapScripts(bot_state_t *bs) {\n\tchar info[1024];\n\tchar mapname[128];\n\tint i, shootbutton;\n\tfloat aim_accuracy;\n\taas_entityinfo_t entinfo;\n\tvec3_t dir;\n\n\ttrap_GetServerinfo(info, sizeof(info));\n\n\tstrncpy(mapname, Info_ValueForKey( info, \"mapname\" ), sizeof(mapname)-1);\n\tmapname[sizeof(mapname)-1] = '\\0';\n\n\tif (!Q_stricmp(mapname, \"q3tourney6\")) {\n\t\tvec3_t mins = {700, 204, 672}, maxs = {964, 468, 680};\n\t\tvec3_t buttonorg = {304, 352, 920};\n\t\t//NOTE: NEVER use the func_bobbing in q3tourney6\n\t\tbs->tfl &= ~TFL_FUNCBOB;\n\t\t//if the bot is below the bounding box\n\t\tif (bs->origin[0] > mins[0] && bs->origin[0] < maxs[0]) {\n\t\t\tif (bs->origin[1] > mins[1] && bs->origin[1] < maxs[1]) {\n\t\t\t\tif (bs->origin[2] < mins[2]) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tshootbutton = qfalse;\n\t\t//if an enemy is below this bounding box then shoot the button\n\t\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\n\t\t\tif (i == bs->client) continue;\n\t\t\t//\n\t\t\tBotEntityInfo(i, &entinfo);\n\t\t\t//\n\t\t\tif (!entinfo.valid) continue;\n\t\t\t//if the enemy isn't dead and the enemy isn't the bot self\n\t\t\tif (EntityIsDead(&entinfo) || entinfo.number == bs->entitynum) continue;\n\t\t\t//\n\t\t\tif (entinfo.origin[0] > mins[0] && entinfo.origin[0] < maxs[0]) {\n\t\t\t\tif (entinfo.origin[1] > mins[1] && entinfo.origin[1] < maxs[1]) {\n\t\t\t\t\tif (entinfo.origin[2] < mins[2]) {\n\t\t\t\t\t\t//if there's a team mate below the crusher\n\t\t\t\t\t\tif (BotSameTeam(bs, i)) {\n\t\t\t\t\t\t\tshootbutton = qfalse;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tshootbutton = qtrue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (shootbutton) {\n\t\t\tbs->flags |= BFL_IDEALVIEWSET;\n\t\t\tVectorSubtract(buttonorg, bs->eye, dir);\n\t\t\tvectoangles(dir, bs->ideal_viewangles);\n\t\t\taim_accuracy = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_AIM_ACCURACY, 0, 1);\n\t\t\tbs->ideal_viewangles[PITCH] += 8 * crandom() * (1 - aim_accuracy);\n\t\t\tbs->ideal_viewangles[PITCH] = AngleMod(bs->ideal_viewangles[PITCH]);\n\t\t\tbs->ideal_viewangles[YAW] += 8 * crandom() * (1 - aim_accuracy);\n\t\t\tbs->ideal_viewangles[YAW] = AngleMod(bs->ideal_viewangles[YAW]);\n\t\t\t//\n\t\t\tif (InFieldOfVision(bs->viewangles, 20, bs->ideal_viewangles)) {\n\t\t\t\ttrap_EA_Attack(bs->client);\n\t\t\t}\n\t\t}\n\t}\n\telse if (!Q_stricmp(mapname, \"mpq3tourney6\")) {\n\t\t//NOTE: NEVER use the func_bobbing in mpq3tourney6\n\t\tbs->tfl &= ~TFL_FUNCBOB;\n\t}\n}\n\n/*\n==================\nBotSetMovedir\n==================\n*/\n// bk001205 - made these static\nstatic vec3_t VEC_UP\t\t= {0, -1,  0};\nstatic vec3_t MOVEDIR_UP\t= {0,  0,  1};\nstatic vec3_t VEC_DOWN\t\t= {0, -2,  0};\nstatic vec3_t MOVEDIR_DOWN\t= {0,  0, -1};\n\nvoid BotSetMovedir(vec3_t angles, vec3_t movedir) {\n\tif (VectorCompare(angles, VEC_UP)) {\n\t\tVectorCopy(MOVEDIR_UP, movedir);\n\t}\n\telse if (VectorCompare(angles, VEC_DOWN)) {\n\t\tVectorCopy(MOVEDIR_DOWN, movedir);\n\t}\n\telse {\n\t\tAngleVectors(angles, movedir, NULL, NULL);\n\t}\n}\n\n/*\n==================\nBotModelMinsMaxs\n\nthis is ugly\n==================\n*/\nint BotModelMinsMaxs(int modelindex, int eType, int contents, vec3_t mins, vec3_t maxs) {\n\tgentity_t *ent;\n\tint i;\n\n\tent = &g_entities[0];\n\tfor (i = 0; i < level.num_entities; i++, ent++) {\n\t\tif ( !ent->inuse ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( eType && ent->s.eType != eType) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( contents && ent->r.contents != contents) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (ent->s.modelindex == modelindex) {\n\t\t\tif (mins)\n\t\t\t\tVectorAdd(ent->r.currentOrigin, ent->r.mins, mins);\n\t\t\tif (maxs)\n\t\t\t\tVectorAdd(ent->r.currentOrigin, ent->r.maxs, maxs);\n\t\t\treturn i;\n\t\t}\n\t}\n\tif (mins)\n\t\tVectorClear(mins);\n\tif (maxs)\n\t\tVectorClear(maxs);\n\treturn 0;\n}\n\n/*\n==================\nBotFuncButtonGoal\n==================\n*/\nint BotFuncButtonActivateGoal(bot_state_t *bs, int bspent, bot_activategoal_t *activategoal) {\n\tint i, areas[10], numareas, modelindex, entitynum;\n\tchar model[128];\n\tfloat lip, dist, health, angle;\n\tvec3_t size, start, end, mins, maxs, angles, points[10];\n\tvec3_t movedir, origin, goalorigin, bboxmins, bboxmaxs;\n\tvec3_t extramins = {1, 1, 1}, extramaxs = {-1, -1, -1};\n\tbsp_trace_t bsptrace;\n\n\tactivategoal->shoot = qfalse;\n\tVectorClear(activategoal->target);\n\t//create a bot goal towards the button\n\ttrap_AAS_ValueForBSPEpairKey(bspent, \"model\", model, sizeof(model));\n\tif (!*model)\n\t\treturn qfalse;\n\tmodelindex = atoi(model+1);\n\tif (!modelindex)\n\t\treturn qfalse;\n\tVectorClear(angles);\n\tentitynum = BotModelMinsMaxs(modelindex, ET_MOVER, 0, mins, maxs);\n\t//get the lip of the button\n\ttrap_AAS_FloatForBSPEpairKey(bspent, \"lip\", &lip);\n\tif (!lip) lip = 4;\n\t//get the move direction from the angle\n\ttrap_AAS_FloatForBSPEpairKey(bspent, \"angle\", &angle);\n\tVectorSet(angles, 0, angle, 0);\n\tBotSetMovedir(angles, movedir);\n\t//button size\n\tVectorSubtract(maxs, mins, size);\n\t//button origin\n\tVectorAdd(mins, maxs, origin);\n\tVectorScale(origin, 0.5, origin);\n\t//touch distance of the button\n\tdist = fabs(movedir[0]) * size[0] + fabs(movedir[1]) * size[1] + fabs(movedir[2]) * size[2];\n\tdist *= 0.5;\n\t//\n\ttrap_AAS_FloatForBSPEpairKey(bspent, \"health\", &health);\n\t//if the button is shootable\n\tif (health) {\n\t\t//calculate the shoot target\n\t\tVectorMA(origin, -dist, movedir, goalorigin);\n\t\t//\n\t\tVectorCopy(goalorigin, activategoal->target);\n\t\tactivategoal->shoot = qtrue;\n\t\t//\n\t\tBotAI_Trace(&bsptrace, bs->eye, NULL, NULL, goalorigin, bs->entitynum, MASK_SHOT);\n\t\t// if the button is visible from the current position\n\t\tif (bsptrace.fraction >= 1.0 || bsptrace.ent == entitynum) {\n\t\t\t//\n\t\t\tactivategoal->goal.entitynum = entitynum; //NOTE: this is the entity number of the shootable button\n\t\t\tactivategoal->goal.number = 0;\n\t\t\tactivategoal->goal.flags = 0;\n\t\t\tVectorCopy(bs->origin, activategoal->goal.origin);\n\t\t\tactivategoal->goal.areanum = bs->areanum;\n\t\t\tVectorSet(activategoal->goal.mins, -8, -8, -8);\n\t\t\tVectorSet(activategoal->goal.maxs, 8, 8, 8);\n\t\t\t//\n\t\t\treturn qtrue;\n\t\t}\n\t\telse {\n\t\t\t//create a goal from where the button is visible and shoot at the button from there\n\t\t\t//add bounding box size to the dist\n\t\t\ttrap_AAS_PresenceTypeBoundingBox(PRESENCE_CROUCH, bboxmins, bboxmaxs);\n\t\t\tfor (i = 0; i < 3; i++) {\n\t\t\t\tif (movedir[i] < 0) dist += fabs(movedir[i]) * fabs(bboxmaxs[i]);\n\t\t\t\telse dist += fabs(movedir[i]) * fabs(bboxmins[i]);\n\t\t\t}\n\t\t\t//calculate the goal origin\n\t\t\tVectorMA(origin, -dist, movedir, goalorigin);\n\t\t\t//\n\t\t\tVectorCopy(goalorigin, start);\n\t\t\tstart[2] += 24;\n\t\t\tVectorCopy(start, end);\n\t\t\tend[2] -= 512;\n\t\t\tnumareas = trap_AAS_TraceAreas(start, end, areas, points, 10);\n\t\t\t//\n\t\t\tfor (i = numareas-1; i >= 0; i--) {\n\t\t\t\tif (trap_AAS_AreaReachability(areas[i])) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (i < 0) {\n\t\t\t\t// FIXME: trace forward and maybe in other directions to find a valid area\n\t\t\t}\n\t\t\tif (i >= 0) {\n\t\t\t\t//\n\t\t\t\tVectorCopy(points[i], activategoal->goal.origin);\n\t\t\t\tactivategoal->goal.areanum = areas[i];\n\t\t\t\tVectorSet(activategoal->goal.mins, 8, 8, 8);\n\t\t\t\tVectorSet(activategoal->goal.maxs, -8, -8, -8);\n\t\t\t\t//\n\t\t\t\tfor (i = 0; i < 3; i++)\n\t\t\t\t{\n\t\t\t\t\tif (movedir[i] < 0) activategoal->goal.maxs[i] += fabs(movedir[i]) * fabs(extramaxs[i]);\n\t\t\t\t\telse activategoal->goal.mins[i] += fabs(movedir[i]) * fabs(extramins[i]);\n\t\t\t\t} //end for\n\t\t\t\t//\n\t\t\t\tactivategoal->goal.entitynum = entitynum;\n\t\t\t\tactivategoal->goal.number = 0;\n\t\t\t\tactivategoal->goal.flags = 0;\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t}\n\t\treturn qfalse;\n\t}\n\telse {\n\t\t//add bounding box size to the dist\n\t\ttrap_AAS_PresenceTypeBoundingBox(PRESENCE_CROUCH, bboxmins, bboxmaxs);\n\t\tfor (i = 0; i < 3; i++) {\n\t\t\tif (movedir[i] < 0) dist += fabs(movedir[i]) * fabs(bboxmaxs[i]);\n\t\t\telse dist += fabs(movedir[i]) * fabs(bboxmins[i]);\n\t\t}\n\t\t//calculate the goal origin\n\t\tVectorMA(origin, -dist, movedir, goalorigin);\n\t\t//\n\t\tVectorCopy(goalorigin, start);\n\t\tstart[2] += 24;\n\t\tVectorCopy(start, end);\n\t\tend[2] -= 100;\n\t\tnumareas = trap_AAS_TraceAreas(start, end, areas, NULL, 10);\n\t\t//\n\t\tfor (i = 0; i < numareas; i++) {\n\t\t\tif (trap_AAS_AreaReachability(areas[i])) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (i < numareas) {\n\t\t\t//\n\t\t\tVectorCopy(origin, activategoal->goal.origin);\n\t\t\tactivategoal->goal.areanum = areas[i];\n\t\t\tVectorSubtract(mins, origin, activategoal->goal.mins);\n\t\t\tVectorSubtract(maxs, origin, activategoal->goal.maxs);\n\t\t\t//\n\t\t\tfor (i = 0; i < 3; i++)\n\t\t\t{\n\t\t\t\tif (movedir[i] < 0) activategoal->goal.maxs[i] += fabs(movedir[i]) * fabs(extramaxs[i]);\n\t\t\t\telse activategoal->goal.mins[i] += fabs(movedir[i]) * fabs(extramins[i]);\n\t\t\t} //end for\n\t\t\t//\n\t\t\tactivategoal->goal.entitynum = entitynum;\n\t\t\tactivategoal->goal.number = 0;\n\t\t\tactivategoal->goal.flags = 0;\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nBotFuncDoorGoal\n==================\n*/\nint BotFuncDoorActivateGoal(bot_state_t *bs, int bspent, bot_activategoal_t *activategoal) {\n\tint modelindex, entitynum;\n\tchar model[MAX_INFO_STRING];\n\tvec3_t mins, maxs, origin, angles;\n\n\t//shoot at the shootable door\n\ttrap_AAS_ValueForBSPEpairKey(bspent, \"model\", model, sizeof(model));\n\tif (!*model)\n\t\treturn qfalse;\n\tmodelindex = atoi(model+1);\n\tif (!modelindex)\n\t\treturn qfalse;\n\tVectorClear(angles);\n\tentitynum = BotModelMinsMaxs(modelindex, ET_MOVER, 0, mins, maxs);\n\t//door origin\n\tVectorAdd(mins, maxs, origin);\n\tVectorScale(origin, 0.5, origin);\n\tVectorCopy(origin, activategoal->target);\n\tactivategoal->shoot = qtrue;\n\t//\n\tactivategoal->goal.entitynum = entitynum; //NOTE: this is the entity number of the shootable door\n\tactivategoal->goal.number = 0;\n\tactivategoal->goal.flags = 0;\n\tVectorCopy(bs->origin, activategoal->goal.origin);\n\tactivategoal->goal.areanum = bs->areanum;\n\tVectorSet(activategoal->goal.mins, -8, -8, -8);\n\tVectorSet(activategoal->goal.maxs, 8, 8, 8);\n\treturn qtrue;\n}\n\n/*\n==================\nBotTriggerMultipleGoal\n==================\n*/\nint BotTriggerMultipleActivateGoal(bot_state_t *bs, int bspent, bot_activategoal_t *activategoal) {\n\tint i, areas[10], numareas, modelindex, entitynum;\n\tchar model[128];\n\tvec3_t start, end, mins, maxs, angles;\n\tvec3_t origin, goalorigin;\n\n\tactivategoal->shoot = qfalse;\n\tVectorClear(activategoal->target);\n\t//create a bot goal towards the trigger\n\ttrap_AAS_ValueForBSPEpairKey(bspent, \"model\", model, sizeof(model));\n\tif (!*model)\n\t\treturn qfalse;\n\tmodelindex = atoi(model+1);\n\tif (!modelindex)\n\t\treturn qfalse;\n\tVectorClear(angles);\n\tentitynum = BotModelMinsMaxs(modelindex, 0, CONTENTS_TRIGGER, mins, maxs);\n\t//trigger origin\n\tVectorAdd(mins, maxs, origin);\n\tVectorScale(origin, 0.5, origin);\n\tVectorCopy(origin, goalorigin);\n\t//\n\tVectorCopy(goalorigin, start);\n\tstart[2] += 24;\n\tVectorCopy(start, end);\n\tend[2] -= 100;\n\tnumareas = trap_AAS_TraceAreas(start, end, areas, NULL, 10);\n\t//\n\tfor (i = 0; i < numareas; i++) {\n\t\tif (trap_AAS_AreaReachability(areas[i])) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (i < numareas) {\n\t\tVectorCopy(origin, activategoal->goal.origin);\n\t\tactivategoal->goal.areanum = areas[i];\n\t\tVectorSubtract(mins, origin, activategoal->goal.mins);\n\t\tVectorSubtract(maxs, origin, activategoal->goal.maxs);\n\t\t//\n\t\tactivategoal->goal.entitynum = entitynum;\n\t\tactivategoal->goal.number = 0;\n\t\tactivategoal->goal.flags = 0;\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nBotPopFromActivateGoalStack\n==================\n*/\nint BotPopFromActivateGoalStack(bot_state_t *bs) {\n\tif (!bs->activatestack)\n\t\treturn qfalse;\n\tBotEnableActivateGoalAreas(bs->activatestack, qtrue);\n\tbs->activatestack->inuse = qfalse;\n\tbs->activatestack->justused_time = FloatTime();\n\tbs->activatestack = bs->activatestack->next;\n\treturn qtrue;\n}\n\n/*\n==================\nBotPushOntoActivateGoalStack\n==================\n*/\nint BotPushOntoActivateGoalStack(bot_state_t *bs, bot_activategoal_t *activategoal) {\n\tint i, best;\n\tfloat besttime;\n\n\tbest = -1;\n\tbesttime = FloatTime() + 9999;\n\t//\n\tfor (i = 0; i < MAX_ACTIVATESTACK; i++) {\n\t\tif (!bs->activategoalheap[i].inuse) {\n\t\t\tif (bs->activategoalheap[i].justused_time < besttime) {\n\t\t\t\tbesttime = bs->activategoalheap[i].justused_time;\n\t\t\t\tbest = i;\n\t\t\t}\n\t\t}\n\t}\n\tif (best != -1) {\n\t\tmemcpy(&bs->activategoalheap[best], activategoal, sizeof(bot_activategoal_t));\n\t\tbs->activategoalheap[best].inuse = qtrue;\n\t\tbs->activategoalheap[best].next = bs->activatestack;\n\t\tbs->activatestack = &bs->activategoalheap[best];\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nBotClearActivateGoalStack\n==================\n*/\nvoid BotClearActivateGoalStack(bot_state_t *bs) {\n\twhile(bs->activatestack)\n\t\tBotPopFromActivateGoalStack(bs);\n}\n\n/*\n==================\nBotEnableActivateGoalAreas\n==================\n*/\nvoid BotEnableActivateGoalAreas(bot_activategoal_t *activategoal, int enable) {\n\tint i;\n\n\tif (activategoal->areasdisabled == !enable)\n\t\treturn;\n\tfor (i = 0; i < activategoal->numareas; i++)\n\t\ttrap_AAS_EnableRoutingArea( activategoal->areas[i], enable );\n\tactivategoal->areasdisabled = !enable;\n}\n\n/*\n==================\nBotIsGoingToActivateEntity\n==================\n*/\nint BotIsGoingToActivateEntity(bot_state_t *bs, int entitynum) {\n\tbot_activategoal_t *a;\n\tint i;\n\n\tfor (a = bs->activatestack; a; a = a->next) {\n\t\tif (a->time < FloatTime())\n\t\t\tcontinue;\n\t\tif (a->goal.entitynum == entitynum)\n\t\t\treturn qtrue;\n\t}\n\tfor (i = 0; i < MAX_ACTIVATESTACK; i++) {\n\t\tif (bs->activategoalheap[i].inuse)\n\t\t\tcontinue;\n\t\t//\n\t\tif (bs->activategoalheap[i].goal.entitynum == entitynum) {\n\t\t\t// if the bot went for this goal less than 2 seconds ago\n\t\t\tif (bs->activategoalheap[i].justused_time > FloatTime() - 2)\n\t\t\t\treturn qtrue;\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nBotGetActivateGoal\n\n  returns the number of the bsp entity to activate\n  goal->entitynum will be set to the game entity to activate\n==================\n*/\n//#define OBSTACLEDEBUG\n\nint BotGetActivateGoal(bot_state_t *bs, int entitynum, bot_activategoal_t *activategoal) {\n\tint i, ent, cur_entities[10], spawnflags, modelindex, areas[MAX_ACTIVATEAREAS*2], numareas, t;\n\tchar model[MAX_INFO_STRING], tmpmodel[128];\n\tchar target[128], classname[128];\n\tfloat health;\n\tchar targetname[10][128];\n\taas_entityinfo_t entinfo;\n\taas_areainfo_t areainfo;\n\tvec3_t origin, angles, absmins, absmaxs;\n\n\tmemset(activategoal, 0, sizeof(bot_activategoal_t));\n\tBotEntityInfo(entitynum, &entinfo);\n\tCom_sprintf(model, sizeof( model ), \"*%d\", entinfo.modelindex);\n\tfor (ent = trap_AAS_NextBSPEntity(0); ent; ent = trap_AAS_NextBSPEntity(ent)) {\n\t\tif (!trap_AAS_ValueForBSPEpairKey(ent, \"model\", tmpmodel, sizeof(tmpmodel))) continue;\n\t\tif (!strcmp(model, tmpmodel)) break;\n\t}\n\tif (!ent) {\n\t\tBotAI_Print(PRT_ERROR, \"BotGetActivateGoal: no entity found with model %s\\n\", model);\n\t\treturn 0;\n\t}\n\ttrap_AAS_ValueForBSPEpairKey(ent, \"classname\", classname, sizeof(classname));\n\tif (!classname) {\n\t\tBotAI_Print(PRT_ERROR, \"BotGetActivateGoal: entity with model %s has no classname\\n\", model);\n\t\treturn 0;\n\t}\n\t//if it is a door\n\tif (!strcmp(classname, \"func_door\")) {\n\t\tif (trap_AAS_FloatForBSPEpairKey(ent, \"health\", &health)) {\n\t\t\t//if the door has health then the door must be shot to open\n\t\t\tif (health) {\n\t\t\t\tBotFuncDoorActivateGoal(bs, ent, activategoal);\n\t\t\t\treturn ent;\n\t\t\t}\n\t\t}\n\t\t//\n\t\ttrap_AAS_IntForBSPEpairKey(ent, \"spawnflags\", &spawnflags);\n\t\t// if the door starts open then just wait for the door to return\n\t\tif ( spawnflags & 1 )\n\t\t\treturn 0;\n\t\t//get the door origin\n\t\tif (!trap_AAS_VectorForBSPEpairKey(ent, \"origin\", origin)) {\n\t\t\tVectorClear(origin);\n\t\t}\n\t\t//if the door is open or opening already\n\t\tif (!VectorCompare(origin, entinfo.origin))\n\t\t\treturn 0;\n\t\t// store all the areas the door is in\n\t\ttrap_AAS_ValueForBSPEpairKey(ent, \"model\", model, sizeof(model));\n\t\tif (*model) {\n\t\t\tmodelindex = atoi(model+1);\n\t\t\tif (modelindex) {\n\t\t\t\tVectorClear(angles);\n\t\t\t\tBotModelMinsMaxs(modelindex, ET_MOVER, 0, absmins, absmaxs);\n\t\t\t\t//\n\t\t\t\tnumareas = trap_AAS_BBoxAreas(absmins, absmaxs, areas, MAX_ACTIVATEAREAS*2);\n\t\t\t\t// store the areas with reachabilities first\n\t\t\t\tfor (i = 0; i < numareas; i++) {\n\t\t\t\t\tif (activategoal->numareas >= MAX_ACTIVATEAREAS)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tif ( !trap_AAS_AreaReachability(areas[i]) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\ttrap_AAS_AreaInfo(areas[i], &areainfo);\n\t\t\t\t\tif (areainfo.contents & AREACONTENTS_MOVER) {\n\t\t\t\t\t\tactivategoal->areas[activategoal->numareas++] = areas[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// store any remaining areas\n\t\t\t\tfor (i = 0; i < numareas; i++) {\n\t\t\t\t\tif (activategoal->numareas >= MAX_ACTIVATEAREAS)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tif ( trap_AAS_AreaReachability(areas[i]) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\ttrap_AAS_AreaInfo(areas[i], &areainfo);\n\t\t\t\t\tif (areainfo.contents & AREACONTENTS_MOVER) {\n\t\t\t\t\t\tactivategoal->areas[activategoal->numareas++] = areas[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t// if the bot is blocked by or standing on top of a button\n\tif (!strcmp(classname, \"func_button\")) {\n\t\treturn 0;\n\t}\n\t// get the targetname so we can find an entity with a matching target\n\tif (!trap_AAS_ValueForBSPEpairKey(ent, \"targetname\", targetname[0], sizeof(targetname[0]))) {\n\t\tif (bot_developer.integer) {\n\t\t\tBotAI_Print(PRT_ERROR, \"BotGetActivateGoal: entity with model \\\"%s\\\" has no targetname\\n\", model);\n\t\t}\n\t\treturn 0;\n\t}\n\t// allow tree-like activation\n\tcur_entities[0] = trap_AAS_NextBSPEntity(0);\n\tfor (i = 0; i >= 0 && i < 10;) {\n\t\tfor (ent = cur_entities[i]; ent; ent = trap_AAS_NextBSPEntity(ent)) {\n\t\t\tif (!trap_AAS_ValueForBSPEpairKey(ent, \"target\", target, sizeof(target))) continue;\n\t\t\tif (!strcmp(targetname[i], target)) {\n\t\t\t\tcur_entities[i] = trap_AAS_NextBSPEntity(ent);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!ent) {\n\t\t\tif (bot_developer.integer) {\n\t\t\t\tBotAI_Print(PRT_ERROR, \"BotGetActivateGoal: no entity with target \\\"%s\\\"\\n\", targetname[i]);\n\t\t\t}\n\t\t\ti--;\n\t\t\tcontinue;\n\t\t}\n\t\tif (!trap_AAS_ValueForBSPEpairKey(ent, \"classname\", classname, sizeof(classname))) {\n\t\t\tif (bot_developer.integer) {\n\t\t\t\tBotAI_Print(PRT_ERROR, \"BotGetActivateGoal: entity with target \\\"%s\\\" has no classname\\n\", targetname[i]);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\t// BSP button model\n\t\tif (!strcmp(classname, \"func_button\")) {\n\t\t\t//\n\t\t\tif (!BotFuncButtonActivateGoal(bs, ent, activategoal))\n\t\t\t\tcontinue;\n\t\t\t// if the bot tries to activate this button already\n\t\t\tif ( bs->activatestack && bs->activatestack->inuse &&\n\t\t\t\t bs->activatestack->goal.entitynum == activategoal->goal.entitynum &&\n\t\t\t\t bs->activatestack->time > FloatTime() &&\n\t\t\t\t bs->activatestack->start_time < FloatTime() - 2)\n\t\t\t\tcontinue;\n\t\t\t// if the bot is in a reachability area\n\t\t\tif ( trap_AAS_AreaReachability(bs->areanum) ) {\n\t\t\t\t// disable all areas the blocking entity is in\n\t\t\t\tBotEnableActivateGoalAreas( activategoal, qfalse );\n\t\t\t\t//\n\t\t\t\tt = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, activategoal->goal.areanum, bs->tfl);\n\t\t\t\t// if the button is not reachable\n\t\t\t\tif (!t) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tactivategoal->time = FloatTime() + t * 0.01 + 5;\n\t\t\t}\n\t\t\treturn ent;\n\t\t}\n\t\t// invisible trigger multiple box\n\t\telse if (!strcmp(classname, \"trigger_multiple\")) {\n\t\t\t//\n\t\t\tif (!BotTriggerMultipleActivateGoal(bs, ent, activategoal))\n\t\t\t\tcontinue;\n\t\t\t// if the bot tries to activate this trigger already\n\t\t\tif ( bs->activatestack && bs->activatestack->inuse &&\n\t\t\t\t bs->activatestack->goal.entitynum == activategoal->goal.entitynum &&\n\t\t\t\t bs->activatestack->time > FloatTime() &&\n\t\t\t\t bs->activatestack->start_time < FloatTime() - 2)\n\t\t\t\tcontinue;\n\t\t\t// if the bot is in a reachability area\n\t\t\tif ( trap_AAS_AreaReachability(bs->areanum) ) {\n\t\t\t\t// disable all areas the blocking entity is in\n\t\t\t\tBotEnableActivateGoalAreas( activategoal, qfalse );\n\t\t\t\t//\n\t\t\t\tt = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, activategoal->goal.areanum, bs->tfl);\n\t\t\t\t// if the trigger is not reachable\n\t\t\t\tif (!t) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tactivategoal->time = FloatTime() + t * 0.01 + 5;\n\t\t\t}\n\t\t\treturn ent;\n\t\t}\n\t\telse if (!strcmp(classname, \"func_timer\")) {\n\t\t\t// just skip the func_timer\n\t\t\tcontinue;\n\t\t}\n\t\t// the actual button or trigger might be linked through a target_relay or target_delay\n\t\telse if (!strcmp(classname, \"target_relay\") || !strcmp(classname, \"target_delay\")) {\n\t\t\tif (trap_AAS_ValueForBSPEpairKey(ent, \"targetname\", targetname[i+1], sizeof(targetname[0]))) {\n\t\t\t\ti++;\n\t\t\t\tcur_entities[i] = trap_AAS_NextBSPEntity(0);\n\t\t\t}\n\t\t}\n\t}\n#ifdef OBSTACLEDEBUG\n\tBotAI_Print(PRT_ERROR, \"BotGetActivateGoal: no valid activator for entity with target \\\"%s\\\"\\n\", targetname[0]);\n#endif\n\treturn 0;\n}\n\n/*\n==================\nBotGoForActivateGoal\n==================\n*/\nint BotGoForActivateGoal(bot_state_t *bs, bot_activategoal_t *activategoal) {\n\taas_entityinfo_t activateinfo;\n\n\tactivategoal->inuse = qtrue;\n\tif (!activategoal->time)\n\t\tactivategoal->time = FloatTime() + 10;\n\tactivategoal->start_time = FloatTime();\n\tBotEntityInfo(activategoal->goal.entitynum, &activateinfo);\n\tVectorCopy(activateinfo.origin, activategoal->origin);\n\t//\n\tif (BotPushOntoActivateGoalStack(bs, activategoal)) {\n\t\t// enter the activate entity AI node\n\t\tAIEnter_Seek_ActivateEntity(bs, \"BotGoForActivateGoal\");\n\t\treturn qtrue;\n\t}\n\telse {\n\t\t// enable any routing areas that were disabled\n\t\tBotEnableActivateGoalAreas(activategoal, qtrue);\n\t\treturn qfalse;\n\t}\n}\n\n/*\n==================\nBotPrintActivateGoalInfo\n==================\n*/\nvoid BotPrintActivateGoalInfo(bot_state_t *bs, bot_activategoal_t *activategoal, int bspent) {\n\tchar netname[MAX_NETNAME];\n\tchar classname[128];\n\tchar buf[128];\n\n\tClientName(bs->client, netname, sizeof(netname));\n\ttrap_AAS_ValueForBSPEpairKey(bspent, \"classname\", classname, sizeof(classname));\n\tif (activategoal->shoot) {\n\t\tCom_sprintf(buf, sizeof(buf), \"%s: I have to shoot at a %s from %1.1f %1.1f %1.1f in area %d\\n\",\n\t\t\t\t\t\tnetname, classname,\n\t\t\t\t\t\tactivategoal->goal.origin[0],\n\t\t\t\t\t\tactivategoal->goal.origin[1],\n\t\t\t\t\t\tactivategoal->goal.origin[2],\n\t\t\t\t\t\tactivategoal->goal.areanum);\n\t}\n\telse {\n\t\tCom_sprintf(buf, sizeof(buf), \"%s: I have to activate a %s at %1.1f %1.1f %1.1f in area %d\\n\",\n\t\t\t\t\t\tnetname, classname,\n\t\t\t\t\t\tactivategoal->goal.origin[0],\n\t\t\t\t\t\tactivategoal->goal.origin[1],\n\t\t\t\t\t\tactivategoal->goal.origin[2],\n\t\t\t\t\t\tactivategoal->goal.areanum);\n\t}\n\ttrap_EA_Say(bs->client, buf);\n}\n\n/*\n==================\nBotRandomMove\n==================\n*/\nvoid BotRandomMove(bot_state_t *bs, bot_moveresult_t *moveresult) {\n\tvec3_t dir, angles;\n\n\tangles[0] = 0;\n\tangles[1] = random() * 360;\n\tangles[2] = 0;\n\tAngleVectors(angles, dir, NULL, NULL);\n\n\ttrap_BotMoveInDirection(bs->ms, dir, 400, MOVE_WALK);\n\n\tmoveresult->failure = qfalse;\n\tVectorCopy(dir, moveresult->movedir);\n}\n\n/*\n==================\nBotAIBlocked\n\nVery basic handling of bots being blocked by other entities.\nCheck what kind of entity is blocking the bot and try to activate\nit. If that's not an option then try to walk around or over the entity.\nBefore the bot ends in this part of the AI it should predict which doors to\nopen, which buttons to activate etc.\n==================\n*/\nvoid BotAIBlocked(bot_state_t *bs, bot_moveresult_t *moveresult, int activate) {\n\tint movetype, bspent;\n\tvec3_t hordir, start, end, mins, maxs, sideward, angles, up = {0, 0, 1};\n\taas_entityinfo_t entinfo;\n\tbot_activategoal_t activategoal;\n\n\t// if the bot is not blocked by anything\n\tif (!moveresult->blocked) {\n\t\tbs->notblocked_time = FloatTime();\n\t\treturn;\n\t}\n\t// if stuck in a solid area\n\tif ( moveresult->type == RESULTTYPE_INSOLIDAREA ) {\n\t\t// move in a random direction in the hope to get out\n\t\tBotRandomMove(bs, moveresult);\n\t\t//\n\t\treturn;\n\t}\n\t// get info for the entity that is blocking the bot\n\tBotEntityInfo(moveresult->blockentity, &entinfo);\n#ifdef OBSTACLEDEBUG\n\tClientName(bs->client, netname, sizeof(netname));\n\tBotAI_Print(PRT_MESSAGE, \"%s: I'm blocked by model %d\\n\", netname, entinfo.modelindex);\n#endif // OBSTACLEDEBUG\n\t// if blocked by a bsp model and the bot wants to activate it\n\tif (activate && entinfo.modelindex > 0 && entinfo.modelindex <= max_bspmodelindex) {\n\t\t// find the bsp entity which should be activated in order to get the blocking entity out of the way\n\t\tbspent = BotGetActivateGoal(bs, entinfo.number, &activategoal);\n\t\tif (bspent) {\n\t\t\t//\n\t\t\tif (bs->activatestack && !bs->activatestack->inuse)\n\t\t\t\tbs->activatestack = NULL;\n\t\t\t// if not already trying to activate this entity\n\t\t\tif (!BotIsGoingToActivateEntity(bs, activategoal.goal.entitynum)) {\n\t\t\t\t//\n\t\t\t\tBotGoForActivateGoal(bs, &activategoal);\n\t\t\t}\n\t\t\t// if ontop of an obstacle or\n\t\t\t// if the bot is not in a reachability area it'll still\n\t\t\t// need some dynamic obstacle avoidance, otherwise return\n\t\t\tif (!(moveresult->flags & MOVERESULT_ONTOPOFOBSTACLE) &&\n\t\t\t\ttrap_AAS_AreaReachability(bs->areanum))\n\t\t\t\treturn;\n\t\t}\n\t\telse {\n\t\t\t// enable any routing areas that were disabled\n\t\t\tBotEnableActivateGoalAreas(&activategoal, qtrue);\n\t\t}\n\t}\n\t// just some basic dynamic obstacle avoidance code\n\thordir[0] = moveresult->movedir[0];\n\thordir[1] = moveresult->movedir[1];\n\thordir[2] = 0;\n\t// if no direction just take a random direction\n\tif (VectorNormalize(hordir) < 0.1) {\n\t\tVectorSet(angles, 0, 360 * random(), 0);\n\t\tAngleVectors(angles, hordir, NULL, NULL);\n\t}\n\t//\n\t//if (moveresult->flags & MOVERESULT_ONTOPOFOBSTACLE) movetype = MOVE_JUMP;\n\t//else\n\tmovetype = MOVE_WALK;\n\t// if there's an obstacle at the bot's feet and head then\n\t// the bot might be able to crouch through\n\tVectorCopy(bs->origin, start);\n\tstart[2] += 18;\n\tVectorMA(start, 5, hordir, end);\n\tVectorSet(mins, -16, -16, -24);\n\tVectorSet(maxs, 16, 16, 4);\n\t//\n\t//bsptrace = AAS_Trace(start, mins, maxs, end, bs->entitynum, MASK_PLAYERSOLID);\n\t//if (bsptrace.fraction >= 1) movetype = MOVE_CROUCH;\n\t// get the sideward vector\n\tCrossProduct(hordir, up, sideward);\n\t//\n\tif (bs->flags & BFL_AVOIDRIGHT) VectorNegate(sideward, sideward);\n\t// try to crouch straight forward?\n\tif (movetype != MOVE_CROUCH || !trap_BotMoveInDirection(bs->ms, hordir, 400, movetype)) {\n\t\t// perform the movement\n\t\tif (!trap_BotMoveInDirection(bs->ms, sideward, 400, movetype)) {\n\t\t\t// flip the avoid direction flag\n\t\t\tbs->flags ^= BFL_AVOIDRIGHT;\n\t\t\t// flip the direction\n\t\t\t// VectorNegate(sideward, sideward);\n\t\t\tVectorMA(sideward, -1, hordir, sideward);\n\t\t\t// move in the other direction\n\t\t\ttrap_BotMoveInDirection(bs->ms, sideward, 400, movetype);\n\t\t}\n\t}\n\t//\n\tif (bs->notblocked_time < FloatTime() - 0.4) {\n\t\t// just reset goals and hope the bot will go into another direction?\n\t\t// is this still needed??\n\t\tif (bs->ainode == AINode_Seek_NBG) bs->nbg_time = 0;\n\t\telse if (bs->ainode == AINode_Seek_LTG) bs->ltg_time = 0;\n\t}\n}\n\n/*\n==================\nBotAIPredictObstacles\n\nPredict the route towards the goal and check if the bot\nwill be blocked by certain obstacles. When the bot has obstacles\non it's path the bot should figure out if they can be removed\nby activating certain entities.\n==================\n*/\nint BotAIPredictObstacles(bot_state_t *bs, bot_goal_t *goal) {\n\tint modelnum, entitynum, bspent;\n\tbot_activategoal_t activategoal;\n\taas_predictroute_t route;\n\n\tif (!bot_predictobstacles.integer)\n\t\treturn qfalse;\n\n\t// always predict when the goal change or at regular intervals\n\tif (bs->predictobstacles_goalareanum == goal->areanum &&\n\t\tbs->predictobstacles_time > FloatTime() - 6) {\n\t\treturn qfalse;\n\t}\n\tbs->predictobstacles_goalareanum = goal->areanum;\n\tbs->predictobstacles_time = FloatTime();\n\n\t// predict at most 100 areas or 10 seconds ahead\n\ttrap_AAS_PredictRoute(&route, bs->areanum, bs->origin,\n\t\t\t\t\t\t\tgoal->areanum, bs->tfl, 100, 1000,\n\t\t\t\t\t\t\tRSE_USETRAVELTYPE|RSE_ENTERCONTENTS,\n\t\t\t\t\t\t\tAREACONTENTS_MOVER, TFL_BRIDGE, 0);\n\t// if bot has to travel through an area with a mover\n\tif (route.stopevent & RSE_ENTERCONTENTS) {\n\t\t// if the bot will run into a mover\n\t\tif (route.endcontents & AREACONTENTS_MOVER) {\n\t\t\t//NOTE: this only works with bspc 2.1 or higher\n\t\t\tmodelnum = (route.endcontents & AREACONTENTS_MODELNUM) >> AREACONTENTS_MODELNUMSHIFT;\n\t\t\tif (modelnum) {\n\t\t\t\t//\n\t\t\t\tentitynum = BotModelMinsMaxs(modelnum, ET_MOVER, 0, NULL, NULL);\n\t\t\t\tif (entitynum) {\n\t\t\t\t\t//NOTE: BotGetActivateGoal already checks if the door is open or not\n\t\t\t\t\tbspent = BotGetActivateGoal(bs, entitynum, &activategoal);\n\t\t\t\t\tif (bspent) {\n\t\t\t\t\t\t//\n\t\t\t\t\t\tif (bs->activatestack && !bs->activatestack->inuse)\n\t\t\t\t\t\t\tbs->activatestack = NULL;\n\t\t\t\t\t\t// if not already trying to activate this entity\n\t\t\t\t\t\tif (!BotIsGoingToActivateEntity(bs, activategoal.goal.entitynum)) {\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t//BotAI_Print(PRT_MESSAGE, \"blocked by mover model %d, entity %d ?\\n\", modelnum, entitynum);\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\tBotGoForActivateGoal(bs, &activategoal);\n\t\t\t\t\t\t\treturn qtrue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t// enable any routing areas that were disabled\n\t\t\t\t\t\t\tBotEnableActivateGoalAreas(&activategoal, qtrue);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\telse if (route.stopevent & RSE_USETRAVELTYPE) {\n\t\tif (route.endtravelflags & TFL_BRIDGE) {\n\t\t\t//FIXME: check if the bridge is available to travel over\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nBotCheckConsoleMessages\n==================\n*/\nvoid BotCheckConsoleMessages(bot_state_t *bs) {\n\tchar botname[MAX_NETNAME], message[MAX_MESSAGE_SIZE], netname[MAX_NETNAME], *ptr;\n\tfloat chat_reply;\n\tint context, handle;\n\tbot_consolemessage_t m;\n\tbot_match_t match;\n\n\t//the name of this bot\n\tClientName(bs->client, botname, sizeof(botname));\n\t//\n\twhile((handle = trap_BotNextConsoleMessage(bs->cs, &m)) != 0) {\n\t\t//if the chat state is flooded with messages the bot will read them quickly\n\t\tif (trap_BotNumConsoleMessages(bs->cs) < 10) {\n\t\t\t//if it is a chat message the bot needs some time to read it\n\t\t\tif (m.type == CMS_CHAT && m.time > FloatTime() - (1 + random())) break;\n\t\t}\n\t\t//\n\t\tptr = m.message;\n\t\t//if it is a chat message then don't unify white spaces and don't\n\t\t//replace synonyms in the netname\n\t\tif (m.type == CMS_CHAT) {\n\t\t\t//\n\t\t\tif (trap_BotFindMatch(m.message, &match, MTCONTEXT_REPLYCHAT)) {\n\t\t\t\tptr = m.message + match.variables[MESSAGE].offset;\n\t\t\t}\n\t\t}\n\t\t//unify the white spaces in the message\n\t\ttrap_UnifyWhiteSpaces(ptr);\n\t\t//replace synonyms in the right context\n\t\tcontext = BotSynonymContext(bs);\n\t\ttrap_BotReplaceSynonyms(ptr, context);\n\t\t//if there's no match\n\t\tif (!BotMatchMessage(bs, m.message)) {\n\t\t\t//if it is a chat message\n\t\t\tif (m.type == CMS_CHAT && !bot_nochat.integer) {\n\t\t\t\t//\n\t\t\t\tif (!trap_BotFindMatch(m.message, &match, MTCONTEXT_REPLYCHAT)) {\n\t\t\t\t\ttrap_BotRemoveConsoleMessage(bs->cs, handle);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t//don't use eliza chats with team messages\n\t\t\t\tif (match.subtype & ST_TEAM) {\n\t\t\t\t\ttrap_BotRemoveConsoleMessage(bs->cs, handle);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\ttrap_BotMatchVariable(&match, NETNAME, netname, sizeof(netname));\n\t\t\t\ttrap_BotMatchVariable(&match, MESSAGE, message, sizeof(message));\n\t\t\t\t//if this is a message from the bot self\n\t\t\t\tif (bs->client == ClientFromName(netname)) {\n\t\t\t\t\ttrap_BotRemoveConsoleMessage(bs->cs, handle);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t//unify the message\n\t\t\t\ttrap_UnifyWhiteSpaces(message);\n\t\t\t\t//\n\t\t\t\ttrap_Cvar_Update(&bot_testrchat);\n\t\t\t\tif (bot_testrchat.integer) {\n\t\t\t\t\t//\n\t\t\t\t\ttrap_BotLibVarSet(\"bot_testrchat\", \"1\");\n\t\t\t\t\t//if bot replies with a chat message\n\t\t\t\t\tif (trap_BotReplyChat(bs->cs, message, context, CONTEXT_REPLY,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNULL, NULL,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNULL, NULL,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNULL, NULL,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbotname, netname)) {\n\t\t\t\t\t\tBotAI_Print(PRT_MESSAGE, \"------------------------\\n\");\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tBotAI_Print(PRT_MESSAGE, \"**** no valid reply ****\\n\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t//if at a valid chat position and not chatting already and not in teamplay\n\t\t\t\telse if (bs->ainode != AINode_Stand && BotValidChatPosition(bs) && !TeamPlayIsOn()) {\n\t\t\t\t\tchat_reply = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_REPLY, 0, 1);\n\t\t\t\t\tif (random() < 1.5 / (NumBots()+1) && random() < chat_reply) {\n\t\t\t\t\t\t//if bot replies with a chat message\n\t\t\t\t\t\tif (trap_BotReplyChat(bs->cs, message, context, CONTEXT_REPLY,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNULL, NULL,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNULL, NULL,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNULL, NULL,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbotname, netname)) {\n\t\t\t\t\t\t\t//remove the console message\n\t\t\t\t\t\t\ttrap_BotRemoveConsoleMessage(bs->cs, handle);\n\t\t\t\t\t\t\tbs->stand_time = FloatTime() + BotChatTime(bs);\n\t\t\t\t\t\t\tAIEnter_Stand(bs, \"BotCheckConsoleMessages: reply chat\");\n\t\t\t\t\t\t\t//EA_Say(bs->client, bs->cs.chatmessage);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t//remove the console message\n\t\ttrap_BotRemoveConsoleMessage(bs->cs, handle);\n\t}\n}\n\n/*\n==================\nBotCheckEvents\n==================\n*/\nvoid BotCheckForGrenades(bot_state_t *bs, entityState_t *state) {\n\t// if this is not a grenade\n\tif (state->eType != ET_MISSILE || state->weapon != WP_GRENADE_LAUNCHER)\n\t\treturn;\n\t// try to avoid the grenade\n\ttrap_BotAddAvoidSpot(bs->ms, state->pos.trBase, 160, AVOID_ALWAYS);\n}\n\n#ifdef MISSIONPACK\n/*\n==================\nBotCheckForProxMines\n==================\n*/\nvoid BotCheckForProxMines(bot_state_t *bs, entityState_t *state) {\n\t// if this is not a prox mine\n\tif (state->eType != ET_MISSILE || state->weapon != WP_PROX_LAUNCHER)\n\t\treturn;\n\t// if this prox mine is from someone on our own team\n\tif (state->generic1 == BotTeam(bs))\n\t\treturn;\n\t// if the bot doesn't have a weapon to deactivate the mine\n\tif (!(bs->inventory[INVENTORY_PLASMAGUN] > 0 && bs->inventory[INVENTORY_CELLS] > 0) &&\n\t\t!(bs->inventory[INVENTORY_ROCKETLAUNCHER] > 0 && bs->inventory[INVENTORY_ROCKETS] > 0) &&\n\t\t!(bs->inventory[INVENTORY_BFG10K] > 0 && bs->inventory[INVENTORY_BFGAMMO] > 0) ) {\n\t\treturn;\n\t}\n\t// try to avoid the prox mine\n\ttrap_BotAddAvoidSpot(bs->ms, state->pos.trBase, 160, AVOID_ALWAYS);\n\t//\n\tif (bs->numproxmines >= MAX_PROXMINES)\n\t\treturn;\n\tbs->proxmines[bs->numproxmines] = state->number;\n\tbs->numproxmines++;\n}\n\n/*\n==================\nBotCheckForKamikazeBody\n==================\n*/\nvoid BotCheckForKamikazeBody(bot_state_t *bs, entityState_t *state) {\n\t// if this entity is not wearing the kamikaze\n\tif (!(state->eFlags & EF_KAMIKAZE))\n\t\treturn;\n\t// if this entity isn't dead\n\tif (!(state->eFlags & EF_DEAD))\n\t\treturn;\n\t//remember this kamikaze body\n\tbs->kamikazebody = state->number;\n}\n#endif\n\n/*\n==================\nBotCheckEvents\n==================\n*/\nvoid BotCheckEvents(bot_state_t *bs, entityState_t *state) {\n\tint event;\n\tchar buf[128];\n#ifdef MISSIONPACK\n\taas_entityinfo_t entinfo;\n#endif\n\n\t//NOTE: this sucks, we're accessing the gentity_t directly\n\t//but there's no other fast way to do it right now\n\tif (bs->entityeventTime[state->number] == g_entities[state->number].eventTime) {\n\t\treturn;\n\t}\n\tbs->entityeventTime[state->number] = g_entities[state->number].eventTime;\n\t//if it's an event only entity\n\tif (state->eType > ET_EVENTS) {\n\t\tevent = (state->eType - ET_EVENTS) & ~EV_EVENT_BITS;\n\t}\n\telse {\n\t\tevent = state->event & ~EV_EVENT_BITS;\n\t}\n\t//\n\tswitch(event) {\n\t\t//client obituary event\n\t\tcase EV_OBITUARY:\n\t\t{\n\t\t\tint target, attacker, mod;\n\n\t\t\ttarget = state->otherEntityNum;\n\t\t\tattacker = state->otherEntityNum2;\n\t\t\tmod = state->eventParm;\n\t\t\t//\n\t\t\tif (target == bs->client) {\n\t\t\t\tbs->botdeathtype = mod;\n\t\t\t\tbs->lastkilledby = attacker;\n\t\t\t\t//\n\t\t\t\tif (target == attacker ||\n\t\t\t\t\ttarget == ENTITYNUM_NONE ||\n\t\t\t\t\ttarget == ENTITYNUM_WORLD) bs->botsuicide = qtrue;\n\t\t\t\telse bs->botsuicide = qfalse;\n\t\t\t\t//\n\t\t\t\tbs->num_deaths++;\n\t\t\t}\n\t\t\t//else if this client was killed by the bot\n\t\t\telse if (attacker == bs->client) {\n\t\t\t\tbs->enemydeathtype = mod;\n\t\t\t\tbs->lastkilledplayer = target;\n\t\t\t\tbs->killedenemy_time = FloatTime();\n\t\t\t\t//\n\t\t\t\tbs->num_kills++;\n\t\t\t}\n\t\t\telse if (attacker == bs->enemy && target == attacker) {\n\t\t\t\tbs->enemysuicide = qtrue;\n\t\t\t}\n\t\t\t//\n#ifdef MISSIONPACK\t\t\t\n\t\t\tif (gametype == GT_1FCTF) {\n\t\t\t\t//\n\t\t\t\tBotEntityInfo(target, &entinfo);\n\t\t\t\tif ( entinfo.powerups & ( 1 << PW_NEUTRALFLAG ) ) {\n\t\t\t\t\tif (!BotSameTeam(bs, target)) {\n\t\t\t\t\t\tbs->neutralflagstatus = 3;\t//enemy dropped the flag\n\t\t\t\t\t\tbs->flagstatuschanged = qtrue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n#endif\n\t\t\tbreak;\n\t\t}\n\t\tcase EV_GLOBAL_SOUND:\n\t\t{\n\t\t\tif (state->eventParm < 0 || state->eventParm > MAX_SOUNDS) {\n\t\t\t\tBotAI_Print(PRT_ERROR, \"EV_GLOBAL_SOUND: eventParm (%d) out of range\\n\", state->eventParm);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\ttrap_GetConfigstring(CS_SOUNDS + state->eventParm, buf, sizeof(buf));\n\t\t\t/*\n\t\t\tif (!strcmp(buf, \"sound/teamplay/flagret_red.wav\")) {\n\t\t\t\t//red flag is returned\n\t\t\t\tbs->redflagstatus = 0;\n\t\t\t\tbs->flagstatuschanged = qtrue;\n\t\t\t}\n\t\t\telse if (!strcmp(buf, \"sound/teamplay/flagret_blu.wav\")) {\n\t\t\t\t//blue flag is returned\n\t\t\t\tbs->blueflagstatus = 0;\n\t\t\t\tbs->flagstatuschanged = qtrue;\n\t\t\t}\n\t\t\telse*/\n#ifdef MISSIONPACK\n\t\t\tif (!strcmp(buf, \"sound/items/kamikazerespawn.wav\" )) {\n\t\t\t\t//the kamikaze respawned so dont avoid it\n\t\t\t\tBotDontAvoid(bs, \"Kamikaze\");\n\t\t\t}\n\t\t\telse\n#endif\n\t\t\t\tif (!strcmp(buf, \"sound/items/poweruprespawn.wav\")) {\n\t\t\t\t//powerup respawned... go get it\n\t\t\t\tBotGoForPowerups(bs);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase EV_GLOBAL_TEAM_SOUND:\n\t\t{\n\t\t\tif (gametype == GT_CTF) {\n\t\t\t\tswitch(state->eventParm) {\n\t\t\t\t\tcase GTS_RED_CAPTURE:\n\t\t\t\t\t\tbs->blueflagstatus = 0;\n\t\t\t\t\t\tbs->redflagstatus = 0;\n\t\t\t\t\t\tbs->flagstatuschanged = qtrue;\n\t\t\t\t\t\tbreak; //see BotMatch_CTF\n\t\t\t\t\tcase GTS_BLUE_CAPTURE:\n\t\t\t\t\t\tbs->blueflagstatus = 0;\n\t\t\t\t\t\tbs->redflagstatus = 0;\n\t\t\t\t\t\tbs->flagstatuschanged = qtrue;\n\t\t\t\t\t\tbreak; //see BotMatch_CTF\n\t\t\t\t\tcase GTS_RED_RETURN:\n\t\t\t\t\t\t//blue flag is returned\n\t\t\t\t\t\tbs->blueflagstatus = 0;\n\t\t\t\t\t\tbs->flagstatuschanged = qtrue;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase GTS_BLUE_RETURN:\n\t\t\t\t\t\t//red flag is returned\n\t\t\t\t\t\tbs->redflagstatus = 0;\n\t\t\t\t\t\tbs->flagstatuschanged = qtrue;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase GTS_RED_TAKEN:\n\t\t\t\t\t\t//blue flag is taken\n\t\t\t\t\t\tbs->blueflagstatus = 1;\n\t\t\t\t\t\tbs->flagstatuschanged = qtrue;\n\t\t\t\t\t\tbreak; //see BotMatch_CTF\n\t\t\t\t\tcase GTS_BLUE_TAKEN:\n\t\t\t\t\t\t//red flag is taken\n\t\t\t\t\t\tbs->redflagstatus = 1;\n\t\t\t\t\t\tbs->flagstatuschanged = qtrue;\n\t\t\t\t\t\tbreak; //see BotMatch_CTF\n\t\t\t\t}\n\t\t\t}\n#ifdef MISSIONPACK\n\t\t\telse if (gametype == GT_1FCTF) {\n\t\t\t\tswitch(state->eventParm) {\n\t\t\t\t\tcase GTS_RED_CAPTURE:\n\t\t\t\t\t\tbs->neutralflagstatus = 0;\n\t\t\t\t\t\tbs->flagstatuschanged = qtrue;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase GTS_BLUE_CAPTURE:\n\t\t\t\t\t\tbs->neutralflagstatus = 0;\n\t\t\t\t\t\tbs->flagstatuschanged = qtrue;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase GTS_RED_RETURN:\n\t\t\t\t\t\t//flag has returned\n\t\t\t\t\t\tbs->neutralflagstatus = 0;\n\t\t\t\t\t\tbs->flagstatuschanged = qtrue;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase GTS_BLUE_RETURN:\n\t\t\t\t\t\t//flag has returned\n\t\t\t\t\t\tbs->neutralflagstatus = 0;\n\t\t\t\t\t\tbs->flagstatuschanged = qtrue;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase GTS_RED_TAKEN:\n\t\t\t\t\t\tbs->neutralflagstatus = BotTeam(bs) == TEAM_RED ? 2 : 1; //FIXME: check Team_TakeFlagSound in g_team.c\n\t\t\t\t\t\tbs->flagstatuschanged = qtrue;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase GTS_BLUE_TAKEN:\n\t\t\t\t\t\tbs->neutralflagstatus = BotTeam(bs) == TEAM_BLUE ? 2 : 1; //FIXME: check Team_TakeFlagSound in g_team.c\n\t\t\t\t\t\tbs->flagstatuschanged = qtrue;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n#endif\n\t\t\tbreak;\n\t\t}\n\t\tcase EV_PLAYER_TELEPORT_IN:\n\t\t{\n\t\t\tVectorCopy(state->origin, lastteleport_origin);\n\t\t\tlastteleport_time = FloatTime();\n\t\t\tbreak;\n\t\t}\n\t\tcase EV_GENERAL_SOUND:\n\t\t{\n\t\t\t//if this sound is played on the bot\n\t\t\tif (state->number == bs->client) {\n\t\t\t\tif (state->eventParm < 0 || state->eventParm > MAX_SOUNDS) {\n\t\t\t\t\tBotAI_Print(PRT_ERROR, \"EV_GENERAL_SOUND: eventParm (%d) out of range\\n\", state->eventParm);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t//check out the sound\n\t\t\t\ttrap_GetConfigstring(CS_SOUNDS + state->eventParm, buf, sizeof(buf));\n\t\t\t\t//if falling into a death pit\n\t\t\t\tif (!strcmp(buf, \"*falling1.wav\")) {\n\t\t\t\t\t//if the bot has a personal teleporter\n\t\t\t\t\tif (bs->inventory[INVENTORY_TELEPORTER] > 0) {\n\t\t\t\t\t\t//use the holdable item\n\t\t\t\t\t\ttrap_EA_Use(bs->client);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase EV_FOOTSTEP:\n\t\tcase EV_FOOTSTEP_METAL:\n\t\tcase EV_FOOTSPLASH:\n\t\tcase EV_FOOTWADE:\n\t\tcase EV_SWIM:\n\t\tcase EV_FALL_SHORT:\n\t\tcase EV_FALL_MEDIUM:\n\t\tcase EV_FALL_FAR:\n\t\tcase EV_STEP_4:\n\t\tcase EV_STEP_8:\n\t\tcase EV_STEP_12:\n\t\tcase EV_STEP_16:\n\t\tcase EV_JUMP_PAD:\n\t\tcase EV_JUMP:\n\t\tcase EV_TAUNT:\n\t\tcase EV_WATER_TOUCH:\n\t\tcase EV_WATER_LEAVE:\n\t\tcase EV_WATER_UNDER:\n\t\tcase EV_WATER_CLEAR:\n\t\tcase EV_ITEM_PICKUP:\n\t\tcase EV_GLOBAL_ITEM_PICKUP:\n\t\tcase EV_NOAMMO:\n\t\tcase EV_CHANGE_WEAPON:\n\t\tcase EV_FIRE_WEAPON:\n\t\t\t//FIXME: either add to sound queue or mark player as someone making noise\n\t\t\tbreak;\n\t\tcase EV_USE_ITEM0:\n\t\tcase EV_USE_ITEM1:\n\t\tcase EV_USE_ITEM2:\n\t\tcase EV_USE_ITEM3:\n\t\tcase EV_USE_ITEM4:\n\t\tcase EV_USE_ITEM5:\n\t\tcase EV_USE_ITEM6:\n\t\tcase EV_USE_ITEM7:\n\t\tcase EV_USE_ITEM8:\n\t\tcase EV_USE_ITEM9:\n\t\tcase EV_USE_ITEM10:\n\t\tcase EV_USE_ITEM11:\n\t\tcase EV_USE_ITEM12:\n\t\tcase EV_USE_ITEM13:\n\t\tcase EV_USE_ITEM14:\n\t\t\tbreak;\n\t}\n}\n\n/*\n==================\nBotCheckSnapshot\n==================\n*/\nvoid BotCheckSnapshot(bot_state_t *bs) {\n\tint ent;\n\tentityState_t state;\n\n\t//remove all avoid spots\n\ttrap_BotAddAvoidSpot(bs->ms, vec3_origin, 0, AVOID_CLEAR);\n\t//reset kamikaze body\n\tbs->kamikazebody = 0;\n\t//reset number of proxmines\n\tbs->numproxmines = 0;\n\t//\n\tent = 0;\n\twhile( ( ent = BotAI_GetSnapshotEntity( bs->client, ent, &state ) ) != -1 ) {\n\t\t//check the entity state for events\n\t\tBotCheckEvents(bs, &state);\n\t\t//check for grenades the bot should avoid\n\t\tBotCheckForGrenades(bs, &state);\n\t\t//\n#ifdef MISSIONPACK\n\t\t//check for proximity mines which the bot should deactivate\n\t\tBotCheckForProxMines(bs, &state);\n\t\t//check for dead bodies with the kamikaze effect which should be gibbed\n\t\tBotCheckForKamikazeBody(bs, &state);\n#endif\n\t}\n\t//check the player state for events\n\tBotAI_GetEntityState(bs->client, &state);\n\t//copy the player state events to the entity state\n\tstate.event = bs->cur_ps.externalEvent;\n\tstate.eventParm = bs->cur_ps.externalEventParm;\n\t//\n\tBotCheckEvents(bs, &state);\n}\n\n/*\n==================\nBotCheckAir\n==================\n*/\nvoid BotCheckAir(bot_state_t *bs) {\n\tif (bs->inventory[INVENTORY_ENVIRONMENTSUIT] <= 0) {\n\t\tif (trap_AAS_PointContents(bs->eye) & (CONTENTS_WATER|CONTENTS_SLIME|CONTENTS_LAVA)) {\n\t\t\treturn;\n\t\t}\n\t}\n\tbs->lastair_time = FloatTime();\n}\n\n/*\n==================\nBotAlternateRoute\n==================\n*/\nbot_goal_t *BotAlternateRoute(bot_state_t *bs, bot_goal_t *goal) {\n\tint t;\n\n\t// if the bot has an alternative route goal\n\tif (bs->altroutegoal.areanum) {\n\t\t//\n\t\tif (bs->reachedaltroutegoal_time)\n\t\t\treturn goal;\n\t\t// travel time towards alternative route goal\n\t\tt = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, bs->altroutegoal.areanum, bs->tfl);\n\t\tif (t && t < 20) {\n\t\t\t//BotAI_Print(PRT_MESSAGE, \"reached alternate route goal\\n\");\n\t\t\tbs->reachedaltroutegoal_time = FloatTime();\n\t\t}\n\t\tmemcpy(goal, &bs->altroutegoal, sizeof(bot_goal_t));\n\t\treturn &bs->altroutegoal;\n\t}\n\treturn goal;\n}\n\n/*\n==================\nBotGetAlternateRouteGoal\n==================\n*/\nint BotGetAlternateRouteGoal(bot_state_t *bs, int base) {\n\taas_altroutegoal_t *altroutegoals;\n\tbot_goal_t *goal;\n\tint numaltroutegoals, rnd;\n\n\tif (base == TEAM_RED) {\n\t\taltroutegoals = red_altroutegoals;\n\t\tnumaltroutegoals = red_numaltroutegoals;\n\t}\n\telse {\n\t\taltroutegoals = blue_altroutegoals;\n\t\tnumaltroutegoals = blue_numaltroutegoals;\n\t}\n\tif (!numaltroutegoals)\n\t\treturn qfalse;\n\trnd = (float) random() * numaltroutegoals;\n\tif (rnd >= numaltroutegoals)\n\t\trnd = numaltroutegoals-1;\n\tgoal = &bs->altroutegoal;\n\tgoal->areanum = altroutegoals[rnd].areanum;\n\tVectorCopy(altroutegoals[rnd].origin, goal->origin);\n\tVectorSet(goal->mins, -8, -8, -8);\n\tVectorSet(goal->maxs, 8, 8, 8);\n\tgoal->entitynum = 0;\n\tgoal->iteminfo = 0;\n\tgoal->number = 0;\n\tgoal->flags = 0;\n\t//\n\tbs->reachedaltroutegoal_time = 0;\n\treturn qtrue;\n}\n\n/*\n==================\nBotSetupAlternateRouteGoals\n==================\n*/\nvoid BotSetupAlternativeRouteGoals(void) {\n\n\tif (altroutegoals_setup)\n\t\treturn;\n#ifdef MISSIONPACK\n\tif (gametype == GT_CTF) {\n\t\tif (trap_BotGetLevelItemGoal(-1, \"Neutral Flag\", &ctf_neutralflag) < 0)\n\t\t\tBotAI_Print(PRT_WARNING, \"no alt routes without Neutral Flag\\n\");\n\t\tif (ctf_neutralflag.areanum) {\n\t\t\t//\n\t\t\tred_numaltroutegoals = trap_AAS_AlternativeRouteGoals(\n\t\t\t\t\t\t\t\t\t\tctf_neutralflag.origin, ctf_neutralflag.areanum,\n\t\t\t\t\t\t\t\t\t\tctf_redflag.origin, ctf_redflag.areanum, TFL_DEFAULT,\n\t\t\t\t\t\t\t\t\t\tred_altroutegoals, MAX_ALTROUTEGOALS,\n\t\t\t\t\t\t\t\t\t\tALTROUTEGOAL_CLUSTERPORTALS|\n\t\t\t\t\t\t\t\t\t\tALTROUTEGOAL_VIEWPORTALS);\n\t\t\tblue_numaltroutegoals = trap_AAS_AlternativeRouteGoals(\n\t\t\t\t\t\t\t\t\t\tctf_neutralflag.origin, ctf_neutralflag.areanum,\n\t\t\t\t\t\t\t\t\t\tctf_blueflag.origin, ctf_blueflag.areanum, TFL_DEFAULT,\n\t\t\t\t\t\t\t\t\t\tblue_altroutegoals, MAX_ALTROUTEGOALS,\n\t\t\t\t\t\t\t\t\t\tALTROUTEGOAL_CLUSTERPORTALS|\n\t\t\t\t\t\t\t\t\t\tALTROUTEGOAL_VIEWPORTALS);\n\t\t}\n\t}\n\telse if (gametype == GT_1FCTF) {\n\t\t//\n\t\tred_numaltroutegoals = trap_AAS_AlternativeRouteGoals(\n\t\t\t\t\t\t\t\t\tctf_neutralflag.origin, ctf_neutralflag.areanum,\n\t\t\t\t\t\t\t\t\tctf_redflag.origin, ctf_redflag.areanum, TFL_DEFAULT,\n\t\t\t\t\t\t\t\t\tred_altroutegoals, MAX_ALTROUTEGOALS,\n\t\t\t\t\t\t\t\t\tALTROUTEGOAL_CLUSTERPORTALS|\n\t\t\t\t\t\t\t\t\tALTROUTEGOAL_VIEWPORTALS);\n\t\tblue_numaltroutegoals = trap_AAS_AlternativeRouteGoals(\n\t\t\t\t\t\t\t\t\tctf_neutralflag.origin, ctf_neutralflag.areanum,\n\t\t\t\t\t\t\t\t\tctf_blueflag.origin, ctf_blueflag.areanum, TFL_DEFAULT,\n\t\t\t\t\t\t\t\t\tblue_altroutegoals, MAX_ALTROUTEGOALS,\n\t\t\t\t\t\t\t\t\tALTROUTEGOAL_CLUSTERPORTALS|\n\t\t\t\t\t\t\t\t\tALTROUTEGOAL_VIEWPORTALS);\n\t}\n\telse if (gametype == GT_OBELISK) {\n\t\tif (trap_BotGetLevelItemGoal(-1, \"Neutral Obelisk\", &neutralobelisk) < 0)\n\t\t\tBotAI_Print(PRT_WARNING, \"Harvester without neutral obelisk\\n\");\n\t\t//\n\t\tred_numaltroutegoals = trap_AAS_AlternativeRouteGoals(\n\t\t\t\t\t\t\t\t\tneutralobelisk.origin, neutralobelisk.areanum,\n\t\t\t\t\t\t\t\t\tredobelisk.origin, redobelisk.areanum, TFL_DEFAULT,\n\t\t\t\t\t\t\t\t\tred_altroutegoals, MAX_ALTROUTEGOALS,\n\t\t\t\t\t\t\t\t\tALTROUTEGOAL_CLUSTERPORTALS|\n\t\t\t\t\t\t\t\t\tALTROUTEGOAL_VIEWPORTALS);\n\t\tblue_numaltroutegoals = trap_AAS_AlternativeRouteGoals(\n\t\t\t\t\t\t\t\t\tneutralobelisk.origin, neutralobelisk.areanum,\n\t\t\t\t\t\t\t\t\tblueobelisk.origin, blueobelisk.areanum, TFL_DEFAULT,\n\t\t\t\t\t\t\t\t\tblue_altroutegoals, MAX_ALTROUTEGOALS,\n\t\t\t\t\t\t\t\t\tALTROUTEGOAL_CLUSTERPORTALS|\n\t\t\t\t\t\t\t\t\tALTROUTEGOAL_VIEWPORTALS);\n\t}\n\telse if (gametype == GT_HARVESTER) {\n\t\t//\n\t\tred_numaltroutegoals = trap_AAS_AlternativeRouteGoals(\n\t\t\t\t\t\t\t\t\tneutralobelisk.origin, neutralobelisk.areanum,\n\t\t\t\t\t\t\t\t\tredobelisk.origin, redobelisk.areanum, TFL_DEFAULT,\n\t\t\t\t\t\t\t\t\tred_altroutegoals, MAX_ALTROUTEGOALS,\n\t\t\t\t\t\t\t\t\tALTROUTEGOAL_CLUSTERPORTALS|\n\t\t\t\t\t\t\t\t\tALTROUTEGOAL_VIEWPORTALS);\n\t\tblue_numaltroutegoals = trap_AAS_AlternativeRouteGoals(\n\t\t\t\t\t\t\t\t\tneutralobelisk.origin, neutralobelisk.areanum,\n\t\t\t\t\t\t\t\t\tblueobelisk.origin, blueobelisk.areanum, TFL_DEFAULT,\n\t\t\t\t\t\t\t\t\tblue_altroutegoals, MAX_ALTROUTEGOALS,\n\t\t\t\t\t\t\t\t\tALTROUTEGOAL_CLUSTERPORTALS|\n\t\t\t\t\t\t\t\t\tALTROUTEGOAL_VIEWPORTALS);\n\t}\n#endif\n\taltroutegoals_setup = qtrue;\n}\n\n/*\n==================\nBotDeathmatchAI\n==================\n*/\nvoid BotDeathmatchAI(bot_state_t *bs, float thinktime) {\n\tchar gender[144], name[144], buf[144];\n\tchar userinfo[MAX_INFO_STRING];\n\tint i;\n\n\t//if the bot has just been setup\n\tif (bs->setupcount > 0) {\n\t\tbs->setupcount--;\n\t\tif (bs->setupcount > 0) return;\n\t\t//get the gender characteristic\n\t\ttrap_Characteristic_String(bs->character, CHARACTERISTIC_GENDER, gender, sizeof(gender));\n\t\t//set the bot gender\n\t\ttrap_GetUserinfo(bs->client, userinfo, sizeof(userinfo));\n\t\tInfo_SetValueForKey(userinfo, \"sex\", gender);\n\t\ttrap_SetUserinfo(bs->client, userinfo);\n\t\t//set the team\n\t\tif ( !bs->map_restart && g_gametype.integer != GT_TOURNAMENT ) {\n\t\t\tCom_sprintf(buf, sizeof(buf), \"team %s\", bs->settings.team);\n\t\t\ttrap_EA_Command(bs->client, buf);\n\t\t}\n\t\t//set the chat gender\n\t\tif (gender[0] == 'm') trap_BotSetChatGender(bs->cs, CHAT_GENDERMALE);\n\t\telse if (gender[0] == 'f')  trap_BotSetChatGender(bs->cs, CHAT_GENDERFEMALE);\n\t\telse  trap_BotSetChatGender(bs->cs, CHAT_GENDERLESS);\n\t\t//set the chat name\n\t\tClientName(bs->client, name, sizeof(name));\n\t\ttrap_BotSetChatName(bs->cs, name, bs->client);\n\t\t//\n\t\tbs->lastframe_health = bs->inventory[INVENTORY_HEALTH];\n\t\tbs->lasthitcount = bs->cur_ps.persistant[PERS_HITS];\n\t\t//\n\t\tbs->setupcount = 0;\n\t\t//\n\t\tBotSetupAlternativeRouteGoals();\n\t}\n\t//no ideal view set\n\tbs->flags &= ~BFL_IDEALVIEWSET;\n\t//\n\tif (!BotIntermission(bs)) {\n\t\t//set the teleport time\n\t\tBotSetTeleportTime(bs);\n\t\t//update some inventory values\n\t\tBotUpdateInventory(bs);\n\t\t//check out the snapshot\n\t\tBotCheckSnapshot(bs);\n\t\t//check for air\n\t\tBotCheckAir(bs);\n\t}\n\t//check the console messages\n\tBotCheckConsoleMessages(bs);\n\t//if not in the intermission and not in observer mode\n\tif (!BotIntermission(bs) && !BotIsObserver(bs)) {\n\t\t//do team AI\n\t\tBotTeamAI(bs);\n\t}\n\t//if the bot has no ai node\n\tif (!bs->ainode) {\n\t\tAIEnter_Seek_LTG(bs, \"BotDeathmatchAI: no ai node\");\n\t}\n\t//if the bot entered the game less than 8 seconds ago\n\tif (!bs->entergamechat && bs->entergame_time > FloatTime() - 8) {\n\t\tif (BotChat_EnterGame(bs)) {\n\t\t\tbs->stand_time = FloatTime() + BotChatTime(bs);\n\t\t\tAIEnter_Stand(bs, \"BotDeathmatchAI: chat enter game\");\n\t\t}\n\t\tbs->entergamechat = qtrue;\n\t}\n\t//reset the node switches from the previous frame\n\tBotResetNodeSwitches();\n\t//execute AI nodes\n\tfor (i = 0; i < MAX_NODESWITCHES; i++) {\n\t\tif (bs->ainode(bs)) break;\n\t}\n\t//if the bot removed itself :)\n\tif (!bs->inuse) return;\n\t//if the bot executed too many AI nodes\n\tif (i >= MAX_NODESWITCHES) {\n\t\ttrap_BotDumpGoalStack(bs->gs);\n\t\ttrap_BotDumpAvoidGoals(bs->gs);\n\t\tBotDumpNodeSwitches(bs);\n\t\tClientName(bs->client, name, sizeof(name));\n\t\tBotAI_Print(PRT_ERROR, \"%s at %1.1f switched more than %d AI nodes\\n\", name, FloatTime(), MAX_NODESWITCHES);\n\t}\n\t//\n\tbs->lastframe_health = bs->inventory[INVENTORY_HEALTH];\n\tbs->lasthitcount = bs->cur_ps.persistant[PERS_HITS];\n}\n\n/*\n==================\nBotSetEntityNumForGoalWithModel\n==================\n*/\nvoid BotSetEntityNumForGoalWithModel(bot_goal_t *goal, int eType, char *modelname) {\n\tgentity_t *ent;\n\tint i, modelindex;\n\tvec3_t dir;\n\n\tmodelindex = G_ModelIndex( modelname );\n\tent = &g_entities[0];\n\tfor (i = 0; i < level.num_entities; i++, ent++) {\n\t\tif ( !ent->inuse ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( eType && ent->s.eType != eType) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (ent->s.modelindex != modelindex) {\n\t\t\tcontinue;\n\t\t}\n\t\tVectorSubtract(goal->origin, ent->s.origin, dir);\n\t\tif (VectorLengthSquared(dir) < Square(10)) {\n\t\t\tgoal->entitynum = i;\n\t\t\treturn;\n\t\t}\n\t}\n}\n\n/*\n==================\nBotSetEntityNumForGoal\n==================\n*/\nvoid BotSetEntityNumForGoal(bot_goal_t *goal, char *classname) {\n\tgentity_t *ent;\n\tint i;\n\tvec3_t dir;\n\n\tent = &g_entities[0];\n\tfor (i = 0; i < level.num_entities; i++, ent++) {\n\t\tif ( !ent->inuse ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( !Q_stricmp(ent->classname, classname) ) {\n\t\t\tcontinue;\n\t\t}\n\t\tVectorSubtract(goal->origin, ent->s.origin, dir);\n\t\tif (VectorLengthSquared(dir) < Square(10)) {\n\t\t\tgoal->entitynum = i;\n\t\t\treturn;\n\t\t}\n\t}\n}\n\n/*\n==================\nBotGoalForBSPEntity\n==================\n*/\nint BotGoalForBSPEntity( char *classname, bot_goal_t *goal ) {\n\tchar value[MAX_INFO_STRING];\n\tvec3_t origin, start, end;\n\tint ent, numareas, areas[10];\n\n\tmemset(goal, 0, sizeof(bot_goal_t));\n\tfor (ent = trap_AAS_NextBSPEntity(0); ent; ent = trap_AAS_NextBSPEntity(ent)) {\n\t\tif (!trap_AAS_ValueForBSPEpairKey(ent, \"classname\", value, sizeof(value)))\n\t\t\tcontinue;\n\t\tif (!strcmp(value, classname)) {\n\t\t\tif (!trap_AAS_VectorForBSPEpairKey(ent, \"origin\", origin))\n\t\t\t\treturn qfalse;\n\t\t\tVectorCopy(origin, goal->origin);\n\t\t\tVectorCopy(origin, start);\n\t\t\tstart[2] -= 32;\n\t\t\tVectorCopy(origin, end);\n\t\t\tend[2] += 32;\n\t\t\tnumareas = trap_AAS_TraceAreas(start, end, areas, NULL, 10);\n\t\t\tif (!numareas)\n\t\t\t\treturn qfalse;\n\t\t\tgoal->areanum = areas[0];\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nBotSetupDeathmatchAI\n==================\n*/\nvoid BotSetupDeathmatchAI(void) {\n\tint ent, modelnum;\n\tchar model[128];\n\n\tgametype = trap_Cvar_VariableIntegerValue(\"g_gametype\");\n\tmaxclients = trap_Cvar_VariableIntegerValue(\"sv_maxclients\");\n\n\ttrap_Cvar_Register(&bot_rocketjump, \"bot_rocketjump\", \"1\", 0);\n\ttrap_Cvar_Register(&bot_grapple, \"bot_grapple\", \"0\", 0);\n\ttrap_Cvar_Register(&bot_fastchat, \"bot_fastchat\", \"0\", 0);\n\ttrap_Cvar_Register(&bot_nochat, \"bot_nochat\", \"0\", 0);\n\ttrap_Cvar_Register(&bot_testrchat, \"bot_testrchat\", \"0\", 0);\n\ttrap_Cvar_Register(&bot_challenge, \"bot_challenge\", \"0\", 0);\n\ttrap_Cvar_Register(&bot_predictobstacles, \"bot_predictobstacles\", \"1\", 0);\n\ttrap_Cvar_Register(&g_spSkill, \"g_spSkill\", \"2\", 0);\n\t//\n\tif (gametype == GT_CTF) {\n\t\tif (trap_BotGetLevelItemGoal(-1, \"Red Flag\", &ctf_redflag) < 0)\n\t\t\tBotAI_Print(PRT_WARNING, \"CTF without Red Flag\\n\");\n\t\tif (trap_BotGetLevelItemGoal(-1, \"Blue Flag\", &ctf_blueflag) < 0)\n\t\t\tBotAI_Print(PRT_WARNING, \"CTF without Blue Flag\\n\");\n\t}\n#ifdef MISSIONPACK\n\telse if (gametype == GT_1FCTF) {\n\t\tif (trap_BotGetLevelItemGoal(-1, \"Neutral Flag\", &ctf_neutralflag) < 0)\n\t\t\tBotAI_Print(PRT_WARNING, \"One Flag CTF without Neutral Flag\\n\");\n\t\tif (trap_BotGetLevelItemGoal(-1, \"Red Flag\", &ctf_redflag) < 0)\n\t\t\tBotAI_Print(PRT_WARNING, \"CTF without Red Flag\\n\");\n\t\tif (trap_BotGetLevelItemGoal(-1, \"Blue Flag\", &ctf_blueflag) < 0)\n\t\t\tBotAI_Print(PRT_WARNING, \"CTF without Blue Flag\\n\");\n\t}\n\telse if (gametype == GT_OBELISK) {\n\t\tif (trap_BotGetLevelItemGoal(-1, \"Red Obelisk\", &redobelisk) < 0)\n\t\t\tBotAI_Print(PRT_WARNING, \"Obelisk without red obelisk\\n\");\n\t\tBotSetEntityNumForGoal(&redobelisk, \"team_redobelisk\");\n\t\tif (trap_BotGetLevelItemGoal(-1, \"Blue Obelisk\", &blueobelisk) < 0)\n\t\t\tBotAI_Print(PRT_WARNING, \"Obelisk without blue obelisk\\n\");\n\t\tBotSetEntityNumForGoal(&blueobelisk, \"team_blueobelisk\");\n\t}\n\telse if (gametype == GT_HARVESTER) {\n\t\tif (trap_BotGetLevelItemGoal(-1, \"Red Obelisk\", &redobelisk) < 0)\n\t\t\tBotAI_Print(PRT_WARNING, \"Harvester without red obelisk\\n\");\n\t\tBotSetEntityNumForGoal(&redobelisk, \"team_redobelisk\");\n\t\tif (trap_BotGetLevelItemGoal(-1, \"Blue Obelisk\", &blueobelisk) < 0)\n\t\t\tBotAI_Print(PRT_WARNING, \"Harvester without blue obelisk\\n\");\n\t\tBotSetEntityNumForGoal(&blueobelisk, \"team_blueobelisk\");\n\t\tif (trap_BotGetLevelItemGoal(-1, \"Neutral Obelisk\", &neutralobelisk) < 0)\n\t\t\tBotAI_Print(PRT_WARNING, \"Harvester without neutral obelisk\\n\");\n\t\tBotSetEntityNumForGoal(&neutralobelisk, \"team_neutralobelisk\");\n\t}\n#endif\n\n\tmax_bspmodelindex = 0;\n\tfor (ent = trap_AAS_NextBSPEntity(0); ent; ent = trap_AAS_NextBSPEntity(ent)) {\n\t\tif (!trap_AAS_ValueForBSPEpairKey(ent, \"model\", model, sizeof(model))) continue;\n\t\tif (model[0] == '*') {\n\t\t\tmodelnum = atoi(model+1);\n\t\t\tif (modelnum > max_bspmodelindex)\n\t\t\t\tmax_bspmodelindex = modelnum;\n\t\t}\n\t}\n\t//initialize the waypoint heap\n\tBotInitWaypoints();\n}\n\n/*\n==================\nBotShutdownDeathmatchAI\n==================\n*/\nvoid BotShutdownDeathmatchAI(void) {\n\taltroutegoals_setup = qfalse;\n}\n"
  },
  {
    "path": "code/game/ai_dmq3.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n/*****************************************************************************\n * name:\t\tai_dmq3.h\n *\n * desc:\t\tQuake3 bot AI\n *\n * $Archive: /source/code/botai/ai_chat.c $\n *\n *****************************************************************************/\n\n//setup the deathmatch AI\nvoid BotSetupDeathmatchAI(void);\n//shutdown the deathmatch AI\nvoid BotShutdownDeathmatchAI(void);\n//let the bot live within it's deathmatch AI net\nvoid BotDeathmatchAI(bot_state_t *bs, float thinktime);\n//free waypoints\nvoid BotFreeWaypoints(bot_waypoint_t *wp);\n//choose a weapon\nvoid BotChooseWeapon(bot_state_t *bs);\n//setup movement stuff\nvoid BotSetupForMovement(bot_state_t *bs);\n//update the inventory\nvoid BotUpdateInventory(bot_state_t *bs);\n//update the inventory during battle\nvoid BotUpdateBattleInventory(bot_state_t *bs, int enemy);\n//use holdable items during battle\nvoid BotBattleUseItems(bot_state_t *bs);\n//return true if the bot is dead\nqboolean BotIsDead(bot_state_t *bs);\n//returns true if the bot is in observer mode\nqboolean BotIsObserver(bot_state_t *bs);\n//returns true if the bot is in the intermission\nqboolean BotIntermission(bot_state_t *bs);\n//returns true if the bot is in lava or slime\nqboolean BotInLavaOrSlime(bot_state_t *bs);\n//returns true if the entity is dead\nqboolean EntityIsDead(aas_entityinfo_t *entinfo);\n//returns true if the entity is invisible\nqboolean EntityIsInvisible(aas_entityinfo_t *entinfo);\n//returns true if the entity is shooting\nqboolean EntityIsShooting(aas_entityinfo_t *entinfo);\n#ifdef MISSIONPACK\n//returns true if this entity has the kamikaze\nqboolean EntityHasKamikaze(aas_entityinfo_t *entinfo);\n#endif\n// set a user info key/value pair\nvoid BotSetUserInfo(bot_state_t *bs, char *key, char *value);\n// set the team status (offense, defense etc.)\nvoid BotSetTeamStatus(bot_state_t *bs);\n//returns the name of the client\nchar *ClientName(int client, char *name, int size);\n//returns an simplyfied client name\nchar *EasyClientName(int client, char *name, int size);\n//returns the skin used by the client\nchar *ClientSkin(int client, char *skin, int size);\n// returns the appropriate synonym context for the current game type and situation\nint BotSynonymContext(bot_state_t *bs);\n// set last ordered task\nint BotSetLastOrderedTask(bot_state_t *bs);\n// selection of goals for teamplay\nvoid BotTeamGoals(bot_state_t *bs, int retreat);\n//returns the aggression of the bot in the range [0, 100]\nfloat BotAggression(bot_state_t *bs);\n//returns how bad the bot feels\nfloat BotFeelingBad(bot_state_t *bs);\n//returns true if the bot wants to retreat\nint BotWantsToRetreat(bot_state_t *bs);\n//returns true if the bot wants to chase\nint BotWantsToChase(bot_state_t *bs);\n//returns true if the bot wants to help\nint BotWantsToHelp(bot_state_t *bs);\n//returns true if the bot can and wants to rocketjump\nint BotCanAndWantsToRocketJump(bot_state_t *bs);\n// returns true if the bot has a persistant powerup and a weapon\nint BotHasPersistantPowerupAndWeapon(bot_state_t *bs);\n//returns true if the bot wants to and goes camping\nint BotWantsToCamp(bot_state_t *bs);\n//the bot will perform attack movements\nbot_moveresult_t BotAttackMove(bot_state_t *bs, int tfl);\n//returns true if the bot and the entity are in the same team\nint BotSameTeam(bot_state_t *bs, int entnum);\n//returns true if teamplay is on\nint TeamPlayIsOn(void);\n// returns the client number of the team mate flag carrier (-1 if none)\nint BotTeamFlagCarrier(bot_state_t *bs);\n//returns visible team mate flag carrier if available\nint BotTeamFlagCarrierVisible(bot_state_t *bs);\n//returns visible enemy flag carrier if available\nint BotEnemyFlagCarrierVisible(bot_state_t *bs);\n//get the number of visible teammates and enemies\nvoid BotVisibleTeamMatesAndEnemies(bot_state_t *bs, int *teammates, int *enemies, float range);\n//returns true if within the field of vision for the given angles\nqboolean InFieldOfVision(vec3_t viewangles, float fov, vec3_t angles);\n//returns true and sets the .enemy field when an enemy is found\nint BotFindEnemy(bot_state_t *bs, int curenemy);\n//returns a roam goal\nvoid BotRoamGoal(bot_state_t *bs, vec3_t goal);\n//returns entity visibility in the range [0, 1]\nfloat BotEntityVisible(int viewer, vec3_t eye, vec3_t viewangles, float fov, int ent);\n//the bot will aim at the current enemy\nvoid BotAimAtEnemy(bot_state_t *bs);\n//check if the bot should attack\nvoid BotCheckAttack(bot_state_t *bs);\n//AI when the bot is blocked\nvoid BotAIBlocked(bot_state_t *bs, bot_moveresult_t *moveresult, int activate);\n//AI to predict obstacles\nint BotAIPredictObstacles(bot_state_t *bs, bot_goal_t *goal);\n//enable or disable the areas the blocking entity is in\nvoid BotEnableActivateGoalAreas(bot_activategoal_t *activategoal, int enable);\n//pop an activate goal from the stack\nint BotPopFromActivateGoalStack(bot_state_t *bs);\n//clear the activate goal stack\nvoid BotClearActivateGoalStack(bot_state_t *bs);\n//returns the team the bot is in\nint BotTeam(bot_state_t *bs);\n//retuns the opposite team of the bot\nint BotOppositeTeam(bot_state_t *bs);\n//returns the flag the bot is carrying (CTFFLAG_?)\nint BotCTFCarryingFlag(bot_state_t *bs);\n//remember the last ordered task\nvoid BotRememberLastOrderedTask(bot_state_t *bs);\n//set ctf goals (defend base, get enemy flag) during seek\nvoid BotCTFSeekGoals(bot_state_t *bs);\n//set ctf goals (defend base, get enemy flag) during retreat\nvoid BotCTFRetreatGoals(bot_state_t *bs);\n//\n#ifdef MISSIONPACK\nint Bot1FCTFCarryingFlag(bot_state_t *bs);\nint BotHarvesterCarryingCubes(bot_state_t *bs);\nvoid Bot1FCTFSeekGoals(bot_state_t *bs);\nvoid Bot1FCTFRetreatGoals(bot_state_t *bs);\nvoid BotObeliskSeekGoals(bot_state_t *bs);\nvoid BotObeliskRetreatGoals(bot_state_t *bs);\nvoid BotGoHarvest(bot_state_t *bs);\nvoid BotHarvesterSeekGoals(bot_state_t *bs);\nvoid BotHarvesterRetreatGoals(bot_state_t *bs);\nint BotTeamCubeCarrierVisible(bot_state_t *bs);\nint BotEnemyCubeCarrierVisible(bot_state_t *bs);\n#endif\n//get a random alternate route goal towards the given base\nint BotGetAlternateRouteGoal(bot_state_t *bs, int base);\n//returns either the alternate route goal or the given goal\nbot_goal_t *BotAlternateRoute(bot_state_t *bs, bot_goal_t *goal);\n//create a new waypoint\nbot_waypoint_t *BotCreateWayPoint(char *name, vec3_t origin, int areanum);\n//find a waypoint with the given name\nbot_waypoint_t *BotFindWayPoint(bot_waypoint_t *waypoints, char *name);\n//strstr but case insensitive\nchar *stristr(char *str, char *charset);\n//returns the number of the client with the given name\nint ClientFromName(char *name);\nint ClientOnSameTeamFromName(bot_state_t *bs, char *name);\n//\nint BotPointAreaNum(vec3_t origin);\n//\nvoid BotMapScripts(bot_state_t *bs);\n\n//ctf flags\n#define CTF_FLAG_NONE\t\t0\n#define CTF_FLAG_RED\t\t1\n#define CTF_FLAG_BLUE\t\t2\n//CTF skins\n#define CTF_SKIN_REDTEAM\t\"red\"\n#define CTF_SKIN_BLUETEAM\t\"blue\"\n\nextern int gametype;\t\t//game type\nextern int maxclients;\t\t//maximum number of clients\n\nextern vmCvar_t bot_grapple;\nextern vmCvar_t bot_rocketjump;\nextern vmCvar_t bot_fastchat;\nextern vmCvar_t bot_nochat;\nextern vmCvar_t bot_testrchat;\nextern vmCvar_t bot_challenge;\n\nextern bot_goal_t ctf_redflag;\nextern bot_goal_t ctf_blueflag;\n#ifdef MISSIONPACK\nextern bot_goal_t ctf_neutralflag;\nextern bot_goal_t redobelisk;\nextern bot_goal_t blueobelisk;\nextern bot_goal_t neutralobelisk;\n#endif\n"
  },
  {
    "path": "code/game/ai_main.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n/*****************************************************************************\n * name:\t\tai_main.c\n *\n * desc:\t\tQuake3 bot AI\n *\n * $Archive: /MissionPack/code/game/ai_main.c $\n *\n *****************************************************************************/\n\n\n#include \"g_local.h\"\n#include \"q_shared.h\"\n#include \"botlib.h\"\t\t//bot lib interface\n#include \"be_aas.h\"\n#include \"be_ea.h\"\n#include \"be_ai_char.h\"\n#include \"be_ai_chat.h\"\n#include \"be_ai_gen.h\"\n#include \"be_ai_goal.h\"\n#include \"be_ai_move.h\"\n#include \"be_ai_weap.h\"\n//\n#include \"ai_main.h\"\n#include \"ai_dmq3.h\"\n#include \"ai_chat.h\"\n#include \"ai_cmd.h\"\n#include \"ai_dmnet.h\"\n#include \"ai_vcmd.h\"\n\n//\n#include \"chars.h\"\n#include \"inv.h\"\n#include \"syn.h\"\n\n#define MAX_PATH\t\t144\n\n\n//bot states\nbot_state_t\t*botstates[MAX_CLIENTS];\n//number of bots\nint numbots;\n//floating point time\nfloat floattime;\n//time to do a regular update\nfloat regularupdate_time;\n//\nint bot_interbreed;\nint bot_interbreedmatchcount;\n//\nvmCvar_t bot_thinktime;\nvmCvar_t bot_memorydump;\nvmCvar_t bot_saveroutingcache;\nvmCvar_t bot_pause;\nvmCvar_t bot_report;\nvmCvar_t bot_testsolid;\nvmCvar_t bot_testclusters;\nvmCvar_t bot_developer;\nvmCvar_t bot_interbreedchar;\nvmCvar_t bot_interbreedbots;\nvmCvar_t bot_interbreedcycle;\nvmCvar_t bot_interbreedwrite;\n\n\nvoid ExitLevel( void );\n\n\n/*\n==================\nBotAI_Print\n==================\n*/\nvoid QDECL BotAI_Print(int type, char *fmt, ...) {\n\tchar str[2048];\n\tva_list ap;\n\n\tva_start(ap, fmt);\n\tvsprintf(str, fmt, ap);\n\tva_end(ap);\n\n\tswitch(type) {\n\t\tcase PRT_MESSAGE: {\n\t\t\tG_Printf(\"%s\", str);\n\t\t\tbreak;\n\t\t}\n\t\tcase PRT_WARNING: {\n\t\t\tG_Printf( S_COLOR_YELLOW \"Warning: %s\", str );\n\t\t\tbreak;\n\t\t}\n\t\tcase PRT_ERROR: {\n\t\t\tG_Printf( S_COLOR_RED \"Error: %s\", str );\n\t\t\tbreak;\n\t\t}\n\t\tcase PRT_FATAL: {\n\t\t\tG_Printf( S_COLOR_RED \"Fatal: %s\", str );\n\t\t\tbreak;\n\t\t}\n\t\tcase PRT_EXIT: {\n\t\t\tG_Error( S_COLOR_RED \"Exit: %s\", str );\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tG_Printf( \"unknown print type\\n\" );\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n\n/*\n==================\nBotAI_Trace\n==================\n*/\nvoid BotAI_Trace(bsp_trace_t *bsptrace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask) {\n\ttrace_t trace;\n\n\ttrap_Trace(&trace, start, mins, maxs, end, passent, contentmask);\n\t//copy the trace information\n\tbsptrace->allsolid = trace.allsolid;\n\tbsptrace->startsolid = trace.startsolid;\n\tbsptrace->fraction = trace.fraction;\n\tVectorCopy(trace.endpos, bsptrace->endpos);\n\tbsptrace->plane.dist = trace.plane.dist;\n\tVectorCopy(trace.plane.normal, bsptrace->plane.normal);\n\tbsptrace->plane.signbits = trace.plane.signbits;\n\tbsptrace->plane.type = trace.plane.type;\n\tbsptrace->surface.value = trace.surfaceFlags;\n\tbsptrace->ent = trace.entityNum;\n\tbsptrace->exp_dist = 0;\n\tbsptrace->sidenum = 0;\n\tbsptrace->contents = 0;\n}\n\n/*\n==================\nBotAI_GetClientState\n==================\n*/\nint BotAI_GetClientState( int clientNum, playerState_t *state ) {\n\tgentity_t\t*ent;\n\n\tent = &g_entities[clientNum];\n\tif ( !ent->inuse ) {\n\t\treturn qfalse;\n\t}\n\tif ( !ent->client ) {\n\t\treturn qfalse;\n\t}\n\n\tmemcpy( state, &ent->client->ps, sizeof(playerState_t) );\n\treturn qtrue;\n}\n\n/*\n==================\nBotAI_GetEntityState\n==================\n*/\nint BotAI_GetEntityState( int entityNum, entityState_t *state ) {\n\tgentity_t\t*ent;\n\n\tent = &g_entities[entityNum];\n\tmemset( state, 0, sizeof(entityState_t) );\n\tif (!ent->inuse) return qfalse;\n\tif (!ent->r.linked) return qfalse;\n\tif (ent->r.svFlags & SVF_NOCLIENT) return qfalse;\n\tmemcpy( state, &ent->s, sizeof(entityState_t) );\n\treturn qtrue;\n}\n\n/*\n==================\nBotAI_GetSnapshotEntity\n==================\n*/\nint BotAI_GetSnapshotEntity( int clientNum, int sequence, entityState_t *state ) {\n\tint\t\tentNum;\n\n\tentNum = trap_BotGetSnapshotEntity( clientNum, sequence );\n\tif ( entNum == -1 ) {\n\t\tmemset(state, 0, sizeof(entityState_t));\n\t\treturn -1;\n\t}\n\n\tBotAI_GetEntityState( entNum, state );\n\n\treturn sequence + 1;\n}\n\n/*\n==================\nBotAI_BotInitialChat\n==================\n*/\nvoid QDECL BotAI_BotInitialChat( bot_state_t *bs, char *type, ... ) {\n\tint\t\ti, mcontext;\n\tva_list\tap;\n\tchar\t*p;\n\tchar\t*vars[MAX_MATCHVARIABLES];\n\n\tmemset(vars, 0, sizeof(vars));\n\tva_start(ap, type);\n\tp = va_arg(ap, char *);\n\tfor (i = 0; i < MAX_MATCHVARIABLES; i++) {\n\t\tif( !p ) {\n\t\t\tbreak;\n\t\t}\n\t\tvars[i] = p;\n\t\tp = va_arg(ap, char *);\n\t}\n\tva_end(ap);\n\n\tmcontext = BotSynonymContext(bs);\n\n\ttrap_BotInitialChat( bs->cs, type, mcontext, vars[0], vars[1], vars[2], vars[3], vars[4], vars[5], vars[6], vars[7] );\n}\n\n\n/*\n==================\nBotTestAAS\n==================\n*/\nvoid BotTestAAS(vec3_t origin) {\n\tint areanum;\n\taas_areainfo_t info;\n\n\ttrap_Cvar_Update(&bot_testsolid);\n\ttrap_Cvar_Update(&bot_testclusters);\n\tif (bot_testsolid.integer) {\n\t\tif (!trap_AAS_Initialized()) return;\n\t\tareanum = BotPointAreaNum(origin);\n\t\tif (areanum) BotAI_Print(PRT_MESSAGE, \"\\remtpy area\");\n\t\telse BotAI_Print(PRT_MESSAGE, \"\\r^1SOLID area\");\n\t}\n\telse if (bot_testclusters.integer) {\n\t\tif (!trap_AAS_Initialized()) return;\n\t\tareanum = BotPointAreaNum(origin);\n\t\tif (!areanum)\n\t\t\tBotAI_Print(PRT_MESSAGE, \"\\r^1Solid!                              \");\n\t\telse {\n\t\t\ttrap_AAS_AreaInfo(areanum, &info);\n\t\t\tBotAI_Print(PRT_MESSAGE, \"\\rarea %d, cluster %d       \", areanum, info.cluster);\n\t\t}\n\t}\n}\n\n/*\n==================\nBotReportStatus\n==================\n*/\nvoid BotReportStatus(bot_state_t *bs) {\n\tchar goalname[MAX_MESSAGE_SIZE];\n\tchar netname[MAX_MESSAGE_SIZE];\n\tchar *leader, flagstatus[32];\n\t//\n\tClientName(bs->client, netname, sizeof(netname));\n\tif (Q_stricmp(netname, bs->teamleader) == 0) leader = \"L\";\n\telse leader = \" \";\n\n\tstrcpy(flagstatus, \"  \");\n\tif (gametype == GT_CTF) {\n\t\tif (BotCTFCarryingFlag(bs)) {\n\t\t\tif (BotTeam(bs) == TEAM_RED) strcpy(flagstatus, S_COLOR_RED\"F \");\n\t\t\telse strcpy(flagstatus, S_COLOR_BLUE\"F \");\n\t\t}\n\t}\n#ifdef MISSIONPACK\n\telse if (gametype == GT_1FCTF) {\n\t\tif (Bot1FCTFCarryingFlag(bs)) {\n\t\t\tif (BotTeam(bs) == TEAM_RED) strcpy(flagstatus, S_COLOR_RED\"F \");\n\t\t\telse strcpy(flagstatus, S_COLOR_BLUE\"F \");\n\t\t}\n\t}\n\telse if (gametype == GT_HARVESTER) {\n\t\tif (BotHarvesterCarryingCubes(bs)) {\n\t\t\tif (BotTeam(bs) == TEAM_RED) Com_sprintf(flagstatus, sizeof(flagstatus), S_COLOR_RED\"%2d\", bs->inventory[INVENTORY_REDCUBE]);\n\t\t\telse Com_sprintf(flagstatus, sizeof(flagstatus), S_COLOR_BLUE\"%2d\", bs->inventory[INVENTORY_BLUECUBE]);\n\t\t}\n\t}\n#endif\n\n\tswitch(bs->ltgtype) {\n\t\tcase LTG_TEAMHELP:\n\t\t{\n\t\t\tEasyClientName(bs->teammate, goalname, sizeof(goalname));\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%-20s%s%s: helping %s\\n\", netname, leader, flagstatus, goalname);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_TEAMACCOMPANY:\n\t\t{\n\t\t\tEasyClientName(bs->teammate, goalname, sizeof(goalname));\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%-20s%s%s: accompanying %s\\n\", netname, leader, flagstatus, goalname);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_DEFENDKEYAREA:\n\t\t{\n\t\t\ttrap_BotGoalName(bs->teamgoal.number, goalname, sizeof(goalname));\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%-20s%s%s: defending %s\\n\", netname, leader, flagstatus, goalname);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_GETITEM:\n\t\t{\n\t\t\ttrap_BotGoalName(bs->teamgoal.number, goalname, sizeof(goalname));\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%-20s%s%s: getting item %s\\n\", netname, leader, flagstatus, goalname);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_KILL:\n\t\t{\n\t\t\tClientName(bs->teamgoal.entitynum, goalname, sizeof(goalname));\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%-20s%s%s: killing %s\\n\", netname, leader, flagstatus, goalname);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_CAMP:\n\t\tcase LTG_CAMPORDER:\n\t\t{\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%-20s%s%s: camping\\n\", netname, leader, flagstatus);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_PATROL:\n\t\t{\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%-20s%s%s: patrolling\\n\", netname, leader, flagstatus);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_GETFLAG:\n\t\t{\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%-20s%s%s: capturing flag\\n\", netname, leader, flagstatus);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_RUSHBASE:\n\t\t{\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%-20s%s%s: rushing base\\n\", netname, leader, flagstatus);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_RETURNFLAG:\n\t\t{\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%-20s%s%s: returning flag\\n\", netname, leader, flagstatus);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_ATTACKENEMYBASE:\n\t\t{\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%-20s%s%s: attacking the enemy base\\n\", netname, leader, flagstatus);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_HARVEST:\n\t\t{\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%-20s%s%s: harvesting\\n\", netname, leader, flagstatus);\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t{\n\t\t\tBotAI_Print(PRT_MESSAGE, \"%-20s%s%s: roaming\\n\", netname, leader, flagstatus);\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/*\n==================\nBotTeamplayReport\n==================\n*/\nvoid BotTeamplayReport(void) {\n\tint i;\n\tchar buf[MAX_INFO_STRING];\n\n\tBotAI_Print(PRT_MESSAGE, S_COLOR_RED\"RED\\n\");\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\t//\n\t\tif ( !botstates[i] || !botstates[i]->inuse ) continue;\n\t\t//\n\t\ttrap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));\n\t\t//if no config string or no name\n\t\tif (!strlen(buf) || !strlen(Info_ValueForKey(buf, \"n\"))) continue;\n\t\t//skip spectators\n\t\tif (atoi(Info_ValueForKey(buf, \"t\")) == TEAM_RED) {\n\t\t\tBotReportStatus(botstates[i]);\n\t\t}\n\t}\n\tBotAI_Print(PRT_MESSAGE, S_COLOR_BLUE\"BLUE\\n\");\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\t//\n\t\tif ( !botstates[i] || !botstates[i]->inuse ) continue;\n\t\t//\n\t\ttrap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));\n\t\t//if no config string or no name\n\t\tif (!strlen(buf) || !strlen(Info_ValueForKey(buf, \"n\"))) continue;\n\t\t//skip spectators\n\t\tif (atoi(Info_ValueForKey(buf, \"t\")) == TEAM_BLUE) {\n\t\t\tBotReportStatus(botstates[i]);\n\t\t}\n\t}\n}\n\n/*\n==================\nBotSetInfoConfigString\n==================\n*/\nvoid BotSetInfoConfigString(bot_state_t *bs) {\n\tchar goalname[MAX_MESSAGE_SIZE];\n\tchar netname[MAX_MESSAGE_SIZE];\n\tchar action[MAX_MESSAGE_SIZE];\n\tchar *leader, carrying[32], *cs;\n\tbot_goal_t goal;\n\t//\n\tClientName(bs->client, netname, sizeof(netname));\n\tif (Q_stricmp(netname, bs->teamleader) == 0) leader = \"L\";\n\telse leader = \" \";\n\n\tstrcpy(carrying, \"  \");\n\tif (gametype == GT_CTF) {\n\t\tif (BotCTFCarryingFlag(bs)) {\n\t\t\tstrcpy(carrying, \"F \");\n\t\t}\n\t}\n#ifdef MISSIONPACK\n\telse if (gametype == GT_1FCTF) {\n\t\tif (Bot1FCTFCarryingFlag(bs)) {\n\t\t\tstrcpy(carrying, \"F \");\n\t\t}\n\t}\n\telse if (gametype == GT_HARVESTER) {\n\t\tif (BotHarvesterCarryingCubes(bs)) {\n\t\t\tif (BotTeam(bs) == TEAM_RED) Com_sprintf(carrying, sizeof(carrying), \"%2d\", bs->inventory[INVENTORY_REDCUBE]);\n\t\t\telse Com_sprintf(carrying, sizeof(carrying), \"%2d\", bs->inventory[INVENTORY_BLUECUBE]);\n\t\t}\n\t}\n#endif\n\n\tswitch(bs->ltgtype) {\n\t\tcase LTG_TEAMHELP:\n\t\t{\n\t\t\tEasyClientName(bs->teammate, goalname, sizeof(goalname));\n\t\t\tCom_sprintf(action, sizeof(action), \"helping %s\", goalname);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_TEAMACCOMPANY:\n\t\t{\n\t\t\tEasyClientName(bs->teammate, goalname, sizeof(goalname));\n\t\t\tCom_sprintf(action, sizeof(action), \"accompanying %s\", goalname);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_DEFENDKEYAREA:\n\t\t{\n\t\t\ttrap_BotGoalName(bs->teamgoal.number, goalname, sizeof(goalname));\n\t\t\tCom_sprintf(action, sizeof(action), \"defending %s\", goalname);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_GETITEM:\n\t\t{\n\t\t\ttrap_BotGoalName(bs->teamgoal.number, goalname, sizeof(goalname));\n\t\t\tCom_sprintf(action, sizeof(action), \"getting item %s\", goalname);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_KILL:\n\t\t{\n\t\t\tClientName(bs->teamgoal.entitynum, goalname, sizeof(goalname));\n\t\t\tCom_sprintf(action, sizeof(action), \"killing %s\", goalname);\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_CAMP:\n\t\tcase LTG_CAMPORDER:\n\t\t{\n\t\t\tCom_sprintf(action, sizeof(action), \"camping\");\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_PATROL:\n\t\t{\n\t\t\tCom_sprintf(action, sizeof(action), \"patrolling\");\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_GETFLAG:\n\t\t{\n\t\t\tCom_sprintf(action, sizeof(action), \"capturing flag\");\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_RUSHBASE:\n\t\t{\n\t\t\tCom_sprintf(action, sizeof(action), \"rushing base\");\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_RETURNFLAG:\n\t\t{\n\t\t\tCom_sprintf(action, sizeof(action), \"returning flag\");\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_ATTACKENEMYBASE:\n\t\t{\n\t\t\tCom_sprintf(action, sizeof(action), \"attacking the enemy base\");\n\t\t\tbreak;\n\t\t}\n\t\tcase LTG_HARVEST:\n\t\t{\n\t\t\tCom_sprintf(action, sizeof(action), \"harvesting\");\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t{\n\t\t\ttrap_BotGetTopGoal(bs->gs, &goal);\n\t\t\ttrap_BotGoalName(goal.number, goalname, sizeof(goalname));\n\t\t\tCom_sprintf(action, sizeof(action), \"roaming %s\", goalname);\n\t\t\tbreak;\n\t\t}\n\t}\n  \tcs = va(\"l\\\\%s\\\\c\\\\%s\\\\a\\\\%s\",\n\t\t\t\tleader,\n\t\t\t\tcarrying,\n\t\t\t\taction);\n  \ttrap_SetConfigstring (CS_BOTINFO + bs->client, cs);\n}\n\n/*\n==============\nBotUpdateInfoConfigStrings\n==============\n*/\nvoid BotUpdateInfoConfigStrings(void) {\n\tint i;\n\tchar buf[MAX_INFO_STRING];\n\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\t//\n\t\tif ( !botstates[i] || !botstates[i]->inuse )\n\t\t\tcontinue;\n\t\t//\n\t\ttrap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));\n\t\t//if no config string or no name\n\t\tif (!strlen(buf) || !strlen(Info_ValueForKey(buf, \"n\")))\n\t\t\tcontinue;\n\t\tBotSetInfoConfigString(botstates[i]);\n\t}\n}\n\n/*\n==============\nBotInterbreedBots\n==============\n*/\nvoid BotInterbreedBots(void) {\n\tfloat ranks[MAX_CLIENTS];\n\tint parent1, parent2, child;\n\tint i;\n\n\t// get rankings for all the bots\n\tfor (i = 0; i < MAX_CLIENTS; i++) {\n\t\tif ( botstates[i] && botstates[i]->inuse ) {\n\t\t\tranks[i] = botstates[i]->num_kills * 2 - botstates[i]->num_deaths;\n\t\t}\n\t\telse {\n\t\t\tranks[i] = -1;\n\t\t}\n\t}\n\n\tif (trap_GeneticParentsAndChildSelection(MAX_CLIENTS, ranks, &parent1, &parent2, &child)) {\n\t\ttrap_BotInterbreedGoalFuzzyLogic(botstates[parent1]->gs, botstates[parent2]->gs, botstates[child]->gs);\n\t\ttrap_BotMutateGoalFuzzyLogic(botstates[child]->gs, 1);\n\t}\n\t// reset the kills and deaths\n\tfor (i = 0; i < MAX_CLIENTS; i++) {\n\t\tif (botstates[i] && botstates[i]->inuse) {\n\t\t\tbotstates[i]->num_kills = 0;\n\t\t\tbotstates[i]->num_deaths = 0;\n\t\t}\n\t}\n}\n\n/*\n==============\nBotWriteInterbreeded\n==============\n*/\nvoid BotWriteInterbreeded(char *filename) {\n\tfloat rank, bestrank;\n\tint i, bestbot;\n\n\tbestrank = 0;\n\tbestbot = -1;\n\t// get the best bot\n\tfor (i = 0; i < MAX_CLIENTS; i++) {\n\t\tif ( botstates[i] && botstates[i]->inuse ) {\n\t\t\trank = botstates[i]->num_kills * 2 - botstates[i]->num_deaths;\n\t\t}\n\t\telse {\n\t\t\trank = -1;\n\t\t}\n\t\tif (rank > bestrank) {\n\t\t\tbestrank = rank;\n\t\t\tbestbot = i;\n\t\t}\n\t}\n\tif (bestbot >= 0) {\n\t\t//write out the new goal fuzzy logic\n\t\ttrap_BotSaveGoalFuzzyLogic(botstates[bestbot]->gs, filename);\n\t}\n}\n\n/*\n==============\nBotInterbreedEndMatch\n\nadd link back into ExitLevel?\n==============\n*/\nvoid BotInterbreedEndMatch(void) {\n\n\tif (!bot_interbreed) return;\n\tbot_interbreedmatchcount++;\n\tif (bot_interbreedmatchcount >= bot_interbreedcycle.integer) {\n\t\tbot_interbreedmatchcount = 0;\n\t\t//\n\t\ttrap_Cvar_Update(&bot_interbreedwrite);\n\t\tif (strlen(bot_interbreedwrite.string)) {\n\t\t\tBotWriteInterbreeded(bot_interbreedwrite.string);\n\t\t\ttrap_Cvar_Set(\"bot_interbreedwrite\", \"\");\n\t\t}\n\t\tBotInterbreedBots();\n\t}\n}\n\n/*\n==============\nBotInterbreeding\n==============\n*/\nvoid BotInterbreeding(void) {\n\tint i;\n\n\ttrap_Cvar_Update(&bot_interbreedchar);\n\tif (!strlen(bot_interbreedchar.string)) return;\n\t//make sure we are in tournament mode\n\tif (gametype != GT_TOURNAMENT) {\n\t\ttrap_Cvar_Set(\"g_gametype\", va(\"%d\", GT_TOURNAMENT));\n\t\tExitLevel();\n\t\treturn;\n\t}\n\t//shutdown all the bots\n\tfor (i = 0; i < MAX_CLIENTS; i++) {\n\t\tif (botstates[i] && botstates[i]->inuse) {\n\t\t\tBotAIShutdownClient(botstates[i]->client, qfalse);\n\t\t}\n\t}\n\t//make sure all item weight configs are reloaded and Not shared\n\ttrap_BotLibVarSet(\"bot_reloadcharacters\", \"1\");\n\t//add a number of bots using the desired bot character\n\tfor (i = 0; i < bot_interbreedbots.integer; i++) {\n\t\ttrap_SendConsoleCommand( EXEC_INSERT, va(\"addbot %s 4 free %i %s%d\\n\",\n\t\t\t\t\t\tbot_interbreedchar.string, i * 50, bot_interbreedchar.string, i) );\n\t}\n\t//\n\ttrap_Cvar_Set(\"bot_interbreedchar\", \"\");\n\tbot_interbreed = qtrue;\n}\n\n/*\n==============\nBotEntityInfo\n==============\n*/\nvoid BotEntityInfo(int entnum, aas_entityinfo_t *info) {\n\ttrap_AAS_EntityInfo(entnum, info);\n}\n\n/*\n==============\nNumBots\n==============\n*/\nint NumBots(void) {\n\treturn numbots;\n}\n\n/*\n==============\nBotTeamLeader\n==============\n*/\nint BotTeamLeader(bot_state_t *bs) {\n\tint leader;\n\n\tleader = ClientFromName(bs->teamleader);\n\tif (leader < 0) return qfalse;\n\tif (!botstates[leader] || !botstates[leader]->inuse) return qfalse;\n\treturn qtrue;\n}\n\n/*\n==============\nAngleDifference\n==============\n*/\nfloat AngleDifference(float ang1, float ang2) {\n\tfloat diff;\n\n\tdiff = ang1 - ang2;\n\tif (ang1 > ang2) {\n\t\tif (diff > 180.0) diff -= 360.0;\n\t}\n\telse {\n\t\tif (diff < -180.0) diff += 360.0;\n\t}\n\treturn diff;\n}\n\n/*\n==============\nBotChangeViewAngle\n==============\n*/\nfloat BotChangeViewAngle(float angle, float ideal_angle, float speed) {\n\tfloat move;\n\n\tangle = AngleMod(angle);\n\tideal_angle = AngleMod(ideal_angle);\n\tif (angle == ideal_angle) return angle;\n\tmove = ideal_angle - angle;\n\tif (ideal_angle > angle) {\n\t\tif (move > 180.0) move -= 360.0;\n\t}\n\telse {\n\t\tif (move < -180.0) move += 360.0;\n\t}\n\tif (move > 0) {\n\t\tif (move > speed) move = speed;\n\t}\n\telse {\n\t\tif (move < -speed) move = -speed;\n\t}\n\treturn AngleMod(angle + move);\n}\n\n/*\n==============\nBotChangeViewAngles\n==============\n*/\nvoid BotChangeViewAngles(bot_state_t *bs, float thinktime) {\n\tfloat diff, factor, maxchange, anglespeed, disired_speed;\n\tint i;\n\n\tif (bs->ideal_viewangles[PITCH] > 180) bs->ideal_viewangles[PITCH] -= 360;\n\t//\n\tif (bs->enemy >= 0) {\n\t\tfactor = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_VIEW_FACTOR, 0.01f, 1);\n\t\tmaxchange = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_VIEW_MAXCHANGE, 1, 1800);\n\t}\n\telse {\n\t\tfactor = 0.05f;\n\t\tmaxchange = 360;\n\t}\n\tif (maxchange < 240) maxchange = 240;\n\tmaxchange *= thinktime;\n\tfor (i = 0; i < 2; i++) {\n\t\t//\n\t\tif (bot_challenge.integer) {\n\t\t\t//smooth slowdown view model\n\t\t\tdiff = abs(AngleDifference(bs->viewangles[i], bs->ideal_viewangles[i]));\n\t\t\tanglespeed = diff * factor;\n\t\t\tif (anglespeed > maxchange) anglespeed = maxchange;\n\t\t\tbs->viewangles[i] = BotChangeViewAngle(bs->viewangles[i],\n\t\t\t\t\t\t\t\t\t\t\tbs->ideal_viewangles[i], anglespeed);\n\t\t}\n\t\telse {\n\t\t\t//over reaction view model\n\t\t\tbs->viewangles[i] = AngleMod(bs->viewangles[i]);\n\t\t\tbs->ideal_viewangles[i] = AngleMod(bs->ideal_viewangles[i]);\n\t\t\tdiff = AngleDifference(bs->viewangles[i], bs->ideal_viewangles[i]);\n\t\t\tdisired_speed = diff * factor;\n\t\t\tbs->viewanglespeed[i] += (bs->viewanglespeed[i] - disired_speed);\n\t\t\tif (bs->viewanglespeed[i] > 180) bs->viewanglespeed[i] = maxchange;\n\t\t\tif (bs->viewanglespeed[i] < -180) bs->viewanglespeed[i] = -maxchange;\n\t\t\tanglespeed = bs->viewanglespeed[i];\n\t\t\tif (anglespeed > maxchange) anglespeed = maxchange;\n\t\t\tif (anglespeed < -maxchange) anglespeed = -maxchange;\n\t\t\tbs->viewangles[i] += anglespeed;\n\t\t\tbs->viewangles[i] = AngleMod(bs->viewangles[i]);\n\t\t\t//demping\n\t\t\tbs->viewanglespeed[i] *= 0.45 * (1 - factor);\n\t\t}\n\t\t//BotAI_Print(PRT_MESSAGE, \"ideal_angles %f %f\\n\", bs->ideal_viewangles[0], bs->ideal_viewangles[1], bs->ideal_viewangles[2]);`\n\t\t//bs->viewangles[i] = bs->ideal_viewangles[i];\n\t}\n\t//bs->viewangles[PITCH] = 0;\n\tif (bs->viewangles[PITCH] > 180) bs->viewangles[PITCH] -= 360;\n\t//elementary action: view\n\ttrap_EA_View(bs->client, bs->viewangles);\n}\n\n/*\n==============\nBotInputToUserCommand\n==============\n*/\nvoid BotInputToUserCommand(bot_input_t *bi, usercmd_t *ucmd, int delta_angles[3], int time) {\n\tvec3_t angles, forward, right;\n\tshort temp;\n\tint j;\n\n\t//clear the whole structure\n\tmemset(ucmd, 0, sizeof(usercmd_t));\n\t//\n\t//Com_Printf(\"dir = %f %f %f speed = %f\\n\", bi->dir[0], bi->dir[1], bi->dir[2], bi->speed);\n\t//the duration for the user command in milli seconds\n\tucmd->serverTime = time;\n\t//\n\tif (bi->actionflags & ACTION_DELAYEDJUMP) {\n\t\tbi->actionflags |= ACTION_JUMP;\n\t\tbi->actionflags &= ~ACTION_DELAYEDJUMP;\n\t}\n\t//set the buttons\n\tif (bi->actionflags & ACTION_RESPAWN) ucmd->buttons = BUTTON_ATTACK;\n\tif (bi->actionflags & ACTION_ATTACK) ucmd->buttons |= BUTTON_ATTACK;\n\tif (bi->actionflags & ACTION_TALK) ucmd->buttons |= BUTTON_TALK;\n\tif (bi->actionflags & ACTION_GESTURE) ucmd->buttons |= BUTTON_GESTURE;\n\tif (bi->actionflags & ACTION_USE) ucmd->buttons |= BUTTON_USE_HOLDABLE;\n\tif (bi->actionflags & ACTION_WALK) ucmd->buttons |= BUTTON_WALKING;\n\tif (bi->actionflags & ACTION_AFFIRMATIVE) ucmd->buttons |= BUTTON_AFFIRMATIVE;\n\tif (bi->actionflags & ACTION_NEGATIVE) ucmd->buttons |= BUTTON_NEGATIVE;\n\tif (bi->actionflags & ACTION_GETFLAG) ucmd->buttons |= BUTTON_GETFLAG;\n\tif (bi->actionflags & ACTION_GUARDBASE) ucmd->buttons |= BUTTON_GUARDBASE;\n\tif (bi->actionflags & ACTION_PATROL) ucmd->buttons |= BUTTON_PATROL;\n\tif (bi->actionflags & ACTION_FOLLOWME) ucmd->buttons |= BUTTON_FOLLOWME;\n\t//\n\tucmd->weapon = bi->weapon;\n\t//set the view angles\n\t//NOTE: the ucmd->angles are the angles WITHOUT the delta angles\n\tucmd->angles[PITCH] = ANGLE2SHORT(bi->viewangles[PITCH]);\n\tucmd->angles[YAW] = ANGLE2SHORT(bi->viewangles[YAW]);\n\tucmd->angles[ROLL] = ANGLE2SHORT(bi->viewangles[ROLL]);\n\t//subtract the delta angles\n\tfor (j = 0; j < 3; j++) {\n\t\ttemp = ucmd->angles[j] - delta_angles[j];\n\t\t/*NOTE: disabled because temp should be mod first\n\t\tif ( j == PITCH ) {\n\t\t\t// don't let the player look up or down more than 90 degrees\n\t\t\tif ( temp > 16000 ) temp = 16000;\n\t\t\telse if ( temp < -16000 ) temp = -16000;\n\t\t}\n\t\t*/\n\t\tucmd->angles[j] = temp;\n\t}\n\t//NOTE: movement is relative to the REAL view angles\n\t//get the horizontal forward and right vector\n\t//get the pitch in the range [-180, 180]\n\tif (bi->dir[2]) angles[PITCH] = bi->viewangles[PITCH];\n\telse angles[PITCH] = 0;\n\tangles[YAW] = bi->viewangles[YAW];\n\tangles[ROLL] = 0;\n\tAngleVectors(angles, forward, right, NULL);\n\t//bot input speed is in the range [0, 400]\n\tbi->speed = bi->speed * 127 / 400;\n\t//set the view independent movement\n\tucmd->forwardmove = DotProduct(forward, bi->dir) * bi->speed;\n\tucmd->rightmove = DotProduct(right, bi->dir) * bi->speed;\n\tucmd->upmove = abs(forward[2]) * bi->dir[2] * bi->speed;\n\t//normal keyboard movement\n\tif (bi->actionflags & ACTION_MOVEFORWARD) ucmd->forwardmove += 127;\n\tif (bi->actionflags & ACTION_MOVEBACK) ucmd->forwardmove -= 127;\n\tif (bi->actionflags & ACTION_MOVELEFT) ucmd->rightmove -= 127;\n\tif (bi->actionflags & ACTION_MOVERIGHT) ucmd->rightmove += 127;\n\t//jump/moveup\n\tif (bi->actionflags & ACTION_JUMP) ucmd->upmove += 127;\n\t//crouch/movedown\n\tif (bi->actionflags & ACTION_CROUCH) ucmd->upmove -= 127;\n\t//\n\t//Com_Printf(\"forward = %d right = %d up = %d\\n\", ucmd.forwardmove, ucmd.rightmove, ucmd.upmove);\n\t//Com_Printf(\"ucmd->serverTime = %d\\n\", ucmd->serverTime);\n}\n\n/*\n==============\nBotUpdateInput\n==============\n*/\nvoid BotUpdateInput(bot_state_t *bs, int time, int elapsed_time) {\n\tbot_input_t bi;\n\tint j;\n\n\t//add the delta angles to the bot's current view angles\n\tfor (j = 0; j < 3; j++) {\n\t\tbs->viewangles[j] = AngleMod(bs->viewangles[j] + SHORT2ANGLE(bs->cur_ps.delta_angles[j]));\n\t}\n\t//change the bot view angles\n\tBotChangeViewAngles(bs, (float) elapsed_time / 1000);\n\t//retrieve the bot input\n\ttrap_EA_GetInput(bs->client, (float) time / 1000, &bi);\n\t//respawn hack\n\tif (bi.actionflags & ACTION_RESPAWN) {\n\t\tif (bs->lastucmd.buttons & BUTTON_ATTACK) bi.actionflags &= ~(ACTION_RESPAWN|ACTION_ATTACK);\n\t}\n\t//convert the bot input to a usercmd\n\tBotInputToUserCommand(&bi, &bs->lastucmd, bs->cur_ps.delta_angles, time);\n\t//subtract the delta angles\n\tfor (j = 0; j < 3; j++) {\n\t\tbs->viewangles[j] = AngleMod(bs->viewangles[j] - SHORT2ANGLE(bs->cur_ps.delta_angles[j]));\n\t}\n}\n\n/*\n==============\nBotAIRegularUpdate\n==============\n*/\nvoid BotAIRegularUpdate(void) {\n\tif (regularupdate_time < FloatTime()) {\n\t\ttrap_BotUpdateEntityItems();\n\t\tregularupdate_time = FloatTime() + 0.3;\n\t}\n}\n\n/*\n==============\nRemoveColorEscapeSequences\n==============\n*/\nvoid RemoveColorEscapeSequences( char *text ) {\n\tint i, l;\n\n\tl = 0;\n\tfor ( i = 0; text[i]; i++ ) {\n\t\tif (Q_IsColorString(&text[i])) {\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (text[i] > 0x7E)\n\t\t\tcontinue;\n\t\ttext[l++] = text[i];\n\t}\n\ttext[l] = '\\0';\n}\n\n/*\n==============\nBotAI\n==============\n*/\nint BotAI(int client, float thinktime) {\n\tbot_state_t *bs;\n\tchar buf[1024], *args;\n\tint j;\n\n\ttrap_EA_ResetInput(client);\n\t//\n\tbs = botstates[client];\n\tif (!bs || !bs->inuse) {\n\t\tBotAI_Print(PRT_FATAL, \"BotAI: client %d is not setup\\n\", client);\n\t\treturn qfalse;\n\t}\n\n\t//retrieve the current client state\n\tBotAI_GetClientState( client, &bs->cur_ps );\n\n\t//retrieve any waiting server commands\n\twhile( trap_BotGetServerCommand(client, buf, sizeof(buf)) ) {\n\t\t//have buf point to the command and args to the command arguments\n\t\targs = strchr( buf, ' ');\n\t\tif (!args) continue;\n\t\t*args++ = '\\0';\n\n\t\t//remove color espace sequences from the arguments\n\t\tRemoveColorEscapeSequences( args );\n\n\t\tif (!Q_stricmp(buf, \"cp \"))\n\t\t\t{ /*CenterPrintf*/ }\n\t\telse if (!Q_stricmp(buf, \"cs\"))\n\t\t\t{ /*ConfigStringModified*/ }\n\t\telse if (!Q_stricmp(buf, \"print\")) {\n\t\t\t//remove first and last quote from the chat message\n\t\t\tmemmove(args, args+1, strlen(args));\n\t\t\targs[strlen(args)-1] = '\\0';\n\t\t\ttrap_BotQueueConsoleMessage(bs->cs, CMS_NORMAL, args);\n\t\t}\n\t\telse if (!Q_stricmp(buf, \"chat\")) {\n\t\t\t//remove first and last quote from the chat message\n\t\t\tmemmove(args, args+1, strlen(args));\n\t\t\targs[strlen(args)-1] = '\\0';\n\t\t\ttrap_BotQueueConsoleMessage(bs->cs, CMS_CHAT, args);\n\t\t}\n\t\telse if (!Q_stricmp(buf, \"tchat\")) {\n\t\t\t//remove first and last quote from the chat message\n\t\t\tmemmove(args, args+1, strlen(args));\n\t\t\targs[strlen(args)-1] = '\\0';\n\t\t\ttrap_BotQueueConsoleMessage(bs->cs, CMS_CHAT, args);\n\t\t}\n#ifdef MISSIONPACK\n\t\telse if (!Q_stricmp(buf, \"vchat\")) {\n\t\t\tBotVoiceChatCommand(bs, SAY_ALL, args);\n\t\t}\n\t\telse if (!Q_stricmp(buf, \"vtchat\")) {\n\t\t\tBotVoiceChatCommand(bs, SAY_TEAM, args);\n\t\t}\n\t\telse if (!Q_stricmp(buf, \"vtell\")) {\n\t\t\tBotVoiceChatCommand(bs, SAY_TELL, args);\n\t\t}\n#endif\n\t\telse if (!Q_stricmp(buf, \"scores\"))\n\t\t\t{ /*FIXME: parse scores?*/ }\n\t\telse if (!Q_stricmp(buf, \"clientLevelShot\"))\n\t\t\t{ /*ignore*/ }\n\t}\n\t//add the delta angles to the bot's current view angles\n\tfor (j = 0; j < 3; j++) {\n\t\tbs->viewangles[j] = AngleMod(bs->viewangles[j] + SHORT2ANGLE(bs->cur_ps.delta_angles[j]));\n\t}\n\t//increase the local time of the bot\n\tbs->ltime += thinktime;\n\t//\n\tbs->thinktime = thinktime;\n\t//origin of the bot\n\tVectorCopy(bs->cur_ps.origin, bs->origin);\n\t//eye coordinates of the bot\n\tVectorCopy(bs->cur_ps.origin, bs->eye);\n\tbs->eye[2] += bs->cur_ps.viewheight;\n\t//get the area the bot is in\n\tbs->areanum = BotPointAreaNum(bs->origin);\n\t//the real AI\n\tBotDeathmatchAI(bs, thinktime);\n\t//set the weapon selection every AI frame\n\ttrap_EA_SelectWeapon(bs->client, bs->weaponnum);\n\t//subtract the delta angles\n\tfor (j = 0; j < 3; j++) {\n\t\tbs->viewangles[j] = AngleMod(bs->viewangles[j] - SHORT2ANGLE(bs->cur_ps.delta_angles[j]));\n\t}\n\t//everything was ok\n\treturn qtrue;\n}\n\n/*\n==================\nBotScheduleBotThink\n==================\n*/\nvoid BotScheduleBotThink(void) {\n\tint i, botnum;\n\n\tbotnum = 0;\n\n\tfor( i = 0; i < MAX_CLIENTS; i++ ) {\n\t\tif( !botstates[i] || !botstates[i]->inuse ) {\n\t\t\tcontinue;\n\t\t}\n\t\t//initialize the bot think residual time\n\t\tbotstates[i]->botthink_residual = bot_thinktime.integer * botnum / numbots;\n\t\tbotnum++;\n\t}\n}\n\n/*\n==============\nBotWriteSessionData\n==============\n*/\nvoid BotWriteSessionData(bot_state_t *bs) {\n\tconst char\t*s;\n\tconst char\t*var;\n\n\ts = va(\n\t\t\t\"%i %i %i %i %i %i %i %i\"\n\t\t\t\" %f %f %f\"\n\t\t\t\" %f %f %f\"\n\t\t\t\" %f %f %f\",\n\t\tbs->lastgoal_decisionmaker,\n\t\tbs->lastgoal_ltgtype,\n\t\tbs->lastgoal_teammate,\n\t\tbs->lastgoal_teamgoal.areanum,\n\t\tbs->lastgoal_teamgoal.entitynum,\n\t\tbs->lastgoal_teamgoal.flags,\n\t\tbs->lastgoal_teamgoal.iteminfo,\n\t\tbs->lastgoal_teamgoal.number,\n\t\tbs->lastgoal_teamgoal.origin[0],\n\t\tbs->lastgoal_teamgoal.origin[1],\n\t\tbs->lastgoal_teamgoal.origin[2],\n\t\tbs->lastgoal_teamgoal.mins[0],\n\t\tbs->lastgoal_teamgoal.mins[1],\n\t\tbs->lastgoal_teamgoal.mins[2],\n\t\tbs->lastgoal_teamgoal.maxs[0],\n\t\tbs->lastgoal_teamgoal.maxs[1],\n\t\tbs->lastgoal_teamgoal.maxs[2]\n\t\t);\n\n\tvar = va( \"botsession%i\", bs->client );\n\n\ttrap_Cvar_Set( var, s );\n}\n\n/*\n==============\nBotReadSessionData\n==============\n*/\nvoid BotReadSessionData(bot_state_t *bs) {\n\tchar\ts[MAX_STRING_CHARS];\n\tconst char\t*var;\n\n\tvar = va( \"botsession%i\", bs->client );\n\ttrap_Cvar_VariableStringBuffer( var, s, sizeof(s) );\n\n\tsscanf(s,\n\t\t\t\"%i %i %i %i %i %i %i %i\"\n\t\t\t\" %f %f %f\"\n\t\t\t\" %f %f %f\"\n\t\t\t\" %f %f %f\",\n\t\t&bs->lastgoal_decisionmaker,\n\t\t&bs->lastgoal_ltgtype,\n\t\t&bs->lastgoal_teammate,\n\t\t&bs->lastgoal_teamgoal.areanum,\n\t\t&bs->lastgoal_teamgoal.entitynum,\n\t\t&bs->lastgoal_teamgoal.flags,\n\t\t&bs->lastgoal_teamgoal.iteminfo,\n\t\t&bs->lastgoal_teamgoal.number,\n\t\t&bs->lastgoal_teamgoal.origin[0],\n\t\t&bs->lastgoal_teamgoal.origin[1],\n\t\t&bs->lastgoal_teamgoal.origin[2],\n\t\t&bs->lastgoal_teamgoal.mins[0],\n\t\t&bs->lastgoal_teamgoal.mins[1],\n\t\t&bs->lastgoal_teamgoal.mins[2],\n\t\t&bs->lastgoal_teamgoal.maxs[0],\n\t\t&bs->lastgoal_teamgoal.maxs[1],\n\t\t&bs->lastgoal_teamgoal.maxs[2]\n\t\t);\n}\n\n/*\n==============\nBotAISetupClient\n==============\n*/\nint BotAISetupClient(int client, struct bot_settings_s *settings, qboolean restart) {\n\tchar filename[MAX_PATH], name[MAX_PATH], gender[MAX_PATH];\n\tbot_state_t *bs;\n\tint errnum;\n\n\tif (!botstates[client]) botstates[client] = G_Alloc(sizeof(bot_state_t));\n\tbs = botstates[client];\n\n\tif (bs && bs->inuse) {\n\t\tBotAI_Print(PRT_FATAL, \"BotAISetupClient: client %d already setup\\n\", client);\n\t\treturn qfalse;\n\t}\n\n\tif (!trap_AAS_Initialized()) {\n\t\tBotAI_Print(PRT_FATAL, \"AAS not initialized\\n\");\n\t\treturn qfalse;\n\t}\n\n\t//load the bot character\n\tbs->character = trap_BotLoadCharacter(settings->characterfile, settings->skill);\n\tif (!bs->character) {\n\t\tBotAI_Print(PRT_FATAL, \"couldn't load skill %f from %s\\n\", settings->skill, settings->characterfile);\n\t\treturn qfalse;\n\t}\n\t//copy the settings\n\tmemcpy(&bs->settings, settings, sizeof(bot_settings_t));\n\t//allocate a goal state\n\tbs->gs = trap_BotAllocGoalState(client);\n\t//load the item weights\n\ttrap_Characteristic_String(bs->character, CHARACTERISTIC_ITEMWEIGHTS, filename, MAX_PATH);\n\terrnum = trap_BotLoadItemWeights(bs->gs, filename);\n\tif (errnum != BLERR_NOERROR) {\n\t\ttrap_BotFreeGoalState(bs->gs);\n\t\treturn qfalse;\n\t}\n\t//allocate a weapon state\n\tbs->ws = trap_BotAllocWeaponState();\n\t//load the weapon weights\n\ttrap_Characteristic_String(bs->character, CHARACTERISTIC_WEAPONWEIGHTS, filename, MAX_PATH);\n\terrnum = trap_BotLoadWeaponWeights(bs->ws, filename);\n\tif (errnum != BLERR_NOERROR) {\n\t\ttrap_BotFreeGoalState(bs->gs);\n\t\ttrap_BotFreeWeaponState(bs->ws);\n\t\treturn qfalse;\n\t}\n\t//allocate a chat state\n\tbs->cs = trap_BotAllocChatState();\n\t//load the chat file\n\ttrap_Characteristic_String(bs->character, CHARACTERISTIC_CHAT_FILE, filename, MAX_PATH);\n\ttrap_Characteristic_String(bs->character, CHARACTERISTIC_CHAT_NAME, name, MAX_PATH);\n\terrnum = trap_BotLoadChatFile(bs->cs, filename, name);\n\tif (errnum != BLERR_NOERROR) {\n\t\ttrap_BotFreeChatState(bs->cs);\n\t\ttrap_BotFreeGoalState(bs->gs);\n\t\ttrap_BotFreeWeaponState(bs->ws);\n\t\treturn qfalse;\n\t}\n\t//get the gender characteristic\n\ttrap_Characteristic_String(bs->character, CHARACTERISTIC_GENDER, gender, MAX_PATH);\n\t//set the chat gender\n\tif (*gender == 'f' || *gender == 'F') trap_BotSetChatGender(bs->cs, CHAT_GENDERFEMALE);\n\telse if (*gender == 'm' || *gender == 'M') trap_BotSetChatGender(bs->cs, CHAT_GENDERMALE);\n\telse trap_BotSetChatGender(bs->cs, CHAT_GENDERLESS);\n\n\tbs->inuse = qtrue;\n\tbs->client = client;\n\tbs->entitynum = client;\n\tbs->setupcount = 4;\n\tbs->entergame_time = FloatTime();\n\tbs->ms = trap_BotAllocMoveState();\n\tbs->walker = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_WALKER, 0, 1);\n\tnumbots++;\n\n\tif (trap_Cvar_VariableIntegerValue(\"bot_testichat\")) {\n\t\ttrap_BotLibVarSet(\"bot_testichat\", \"1\");\n\t\tBotChatTest(bs);\n\t}\n\t//NOTE: reschedule the bot thinking\n\tBotScheduleBotThink();\n\t//if interbreeding start with a mutation\n\tif (bot_interbreed) {\n\t\ttrap_BotMutateGoalFuzzyLogic(bs->gs, 1);\n\t}\n\t// if we kept the bot client\n\tif (restart) {\n\t\tBotReadSessionData(bs);\n\t}\n\t//bot has been setup succesfully\n\treturn qtrue;\n}\n\n/*\n==============\nBotAIShutdownClient\n==============\n*/\nint BotAIShutdownClient(int client, qboolean restart) {\n\tbot_state_t *bs;\n\n\tbs = botstates[client];\n\tif (!bs || !bs->inuse) {\n\t\t//BotAI_Print(PRT_ERROR, \"BotAIShutdownClient: client %d already shutdown\\n\", client);\n\t\treturn qfalse;\n\t}\n\n\tif (restart) {\n\t\tBotWriteSessionData(bs);\n\t}\n\n\tif (BotChat_ExitGame(bs)) {\n\t\ttrap_BotEnterChat(bs->cs, bs->client, CHAT_ALL);\n\t}\n\n\ttrap_BotFreeMoveState(bs->ms);\n\t//free the goal state`\t\t\t\n\ttrap_BotFreeGoalState(bs->gs);\n\t//free the chat file\n\ttrap_BotFreeChatState(bs->cs);\n\t//free the weapon weights\n\ttrap_BotFreeWeaponState(bs->ws);\n\t//free the bot character\n\ttrap_BotFreeCharacter(bs->character);\n\t//\n\tBotFreeWaypoints(bs->checkpoints);\n\tBotFreeWaypoints(bs->patrolpoints);\n\t//clear activate goal stack\n\tBotClearActivateGoalStack(bs);\n\t//clear the bot state\n\tmemset(bs, 0, sizeof(bot_state_t));\n\t//set the inuse flag to qfalse\n\tbs->inuse = qfalse;\n\t//there's one bot less\n\tnumbots--;\n\t//everything went ok\n\treturn qtrue;\n}\n\n/*\n==============\nBotResetState\n\ncalled when a bot enters the intermission or observer mode and\nwhen the level is changed\n==============\n*/\nvoid BotResetState(bot_state_t *bs) {\n\tint client, entitynum, inuse;\n\tint movestate, goalstate, chatstate, weaponstate;\n\tbot_settings_t settings;\n\tint character;\n\tplayerState_t ps;\t\t\t\t\t\t\t//current player state\n\tfloat entergame_time;\n\n\t//save some things that should not be reset here\n\tmemcpy(&settings, &bs->settings, sizeof(bot_settings_t));\n\tmemcpy(&ps, &bs->cur_ps, sizeof(playerState_t));\n\tinuse = bs->inuse;\n\tclient = bs->client;\n\tentitynum = bs->entitynum;\n\tcharacter = bs->character;\n\tmovestate = bs->ms;\n\tgoalstate = bs->gs;\n\tchatstate = bs->cs;\n\tweaponstate = bs->ws;\n\tentergame_time = bs->entergame_time;\n\t//free checkpoints and patrol points\n\tBotFreeWaypoints(bs->checkpoints);\n\tBotFreeWaypoints(bs->patrolpoints);\n\t//reset the whole state\n\tmemset(bs, 0, sizeof(bot_state_t));\n\t//copy back some state stuff that should not be reset\n\tbs->ms = movestate;\n\tbs->gs = goalstate;\n\tbs->cs = chatstate;\n\tbs->ws = weaponstate;\n\tmemcpy(&bs->cur_ps, &ps, sizeof(playerState_t));\n\tmemcpy(&bs->settings, &settings, sizeof(bot_settings_t));\n\tbs->inuse = inuse;\n\tbs->client = client;\n\tbs->entitynum = entitynum;\n\tbs->character = character;\n\tbs->entergame_time = entergame_time;\n\t//reset several states\n\tif (bs->ms) trap_BotResetMoveState(bs->ms);\n\tif (bs->gs) trap_BotResetGoalState(bs->gs);\n\tif (bs->ws) trap_BotResetWeaponState(bs->ws);\n\tif (bs->gs) trap_BotResetAvoidGoals(bs->gs);\n\tif (bs->ms) trap_BotResetAvoidReach(bs->ms);\n}\n\n/*\n==============\nBotAILoadMap\n==============\n*/\nint BotAILoadMap( int restart ) {\n\tint\t\t\ti;\n\tvmCvar_t\tmapname;\n\n\tif (!restart) {\n\t\ttrap_Cvar_Register( &mapname, \"mapname\", \"\", CVAR_SERVERINFO | CVAR_ROM );\n\t\ttrap_BotLibLoadMap( mapname.string );\n\t}\n\n\tfor (i = 0; i < MAX_CLIENTS; i++) {\n\t\tif (botstates[i] && botstates[i]->inuse) {\n\t\t\tBotResetState( botstates[i] );\n\t\t\tbotstates[i]->setupcount = 4;\n\t\t}\n\t}\n\n\tBotSetupDeathmatchAI();\n\n\treturn qtrue;\n}\n\n#ifdef MISSIONPACK\nvoid ProximityMine_Trigger( gentity_t *trigger, gentity_t *other, trace_t *trace );\n#endif\n\n/*\n==================\nBotAIStartFrame\n==================\n*/\nint BotAIStartFrame(int time) {\n\tint i;\n\tgentity_t\t*ent;\n\tbot_entitystate_t state;\n\tint elapsed_time, thinktime;\n\tstatic int local_time;\n\tstatic int botlib_residual;\n\tstatic int lastbotthink_time;\n\n\tG_CheckBotSpawn();\n\n\ttrap_Cvar_Update(&bot_rocketjump);\n\ttrap_Cvar_Update(&bot_grapple);\n\ttrap_Cvar_Update(&bot_fastchat);\n\ttrap_Cvar_Update(&bot_nochat);\n\ttrap_Cvar_Update(&bot_testrchat);\n\ttrap_Cvar_Update(&bot_thinktime);\n\ttrap_Cvar_Update(&bot_memorydump);\n\ttrap_Cvar_Update(&bot_saveroutingcache);\n\ttrap_Cvar_Update(&bot_pause);\n\ttrap_Cvar_Update(&bot_report);\n\n\tif (bot_report.integer) {\n//\t\tBotTeamplayReport();\n//\t\ttrap_Cvar_Set(\"bot_report\", \"0\");\n\t\tBotUpdateInfoConfigStrings();\n\t}\n\n\tif (bot_pause.integer) {\n\t\t// execute bot user commands every frame\n\t\tfor( i = 0; i < MAX_CLIENTS; i++ ) {\n\t\t\tif( !botstates[i] || !botstates[i]->inuse ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif( g_entities[i].client->pers.connected != CON_CONNECTED ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tbotstates[i]->lastucmd.forwardmove = 0;\n\t\t\tbotstates[i]->lastucmd.rightmove = 0;\n\t\t\tbotstates[i]->lastucmd.upmove = 0;\n\t\t\tbotstates[i]->lastucmd.buttons = 0;\n\t\t\tbotstates[i]->lastucmd.serverTime = time;\n\t\t\ttrap_BotUserCommand(botstates[i]->client, &botstates[i]->lastucmd);\n\t\t}\n\t\treturn qtrue;\n\t}\n\n\tif (bot_memorydump.integer) {\n\t\ttrap_BotLibVarSet(\"memorydump\", \"1\");\n\t\ttrap_Cvar_Set(\"bot_memorydump\", \"0\");\n\t}\n\tif (bot_saveroutingcache.integer) {\n\t\ttrap_BotLibVarSet(\"saveroutingcache\", \"1\");\n\t\ttrap_Cvar_Set(\"bot_saveroutingcache\", \"0\");\n\t}\n\t//check if bot interbreeding is activated\n\tBotInterbreeding();\n\t//cap the bot think time\n\tif (bot_thinktime.integer > 200) {\n\t\ttrap_Cvar_Set(\"bot_thinktime\", \"200\");\n\t}\n\t//if the bot think time changed we should reschedule the bots\n\tif (bot_thinktime.integer != lastbotthink_time) {\n\t\tlastbotthink_time = bot_thinktime.integer;\n\t\tBotScheduleBotThink();\n\t}\n\n\telapsed_time = time - local_time;\n\tlocal_time = time;\n\n\tbotlib_residual += elapsed_time;\n\n\tif (elapsed_time > bot_thinktime.integer) thinktime = elapsed_time;\n\telse thinktime = bot_thinktime.integer;\n\n\t// update the bot library\n\tif ( botlib_residual >= thinktime ) {\n\t\tbotlib_residual -= thinktime;\n\n\t\ttrap_BotLibStartFrame((float) time / 1000);\n\n\t\tif (!trap_AAS_Initialized()) return qfalse;\n\n\t\t//update entities in the botlib\n\t\tfor (i = 0; i < MAX_GENTITIES; i++) {\n\t\t\tent = &g_entities[i];\n\t\t\tif (!ent->inuse) {\n\t\t\t\ttrap_BotLibUpdateEntity(i, NULL);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!ent->r.linked) {\n\t\t\t\ttrap_BotLibUpdateEntity(i, NULL);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (ent->r.svFlags & SVF_NOCLIENT) {\n\t\t\t\ttrap_BotLibUpdateEntity(i, NULL);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// do not update missiles\n\t\t\tif (ent->s.eType == ET_MISSILE && ent->s.weapon != WP_GRAPPLING_HOOK) {\n\t\t\t\ttrap_BotLibUpdateEntity(i, NULL);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// do not update event only entities\n\t\t\tif (ent->s.eType > ET_EVENTS) {\n\t\t\t\ttrap_BotLibUpdateEntity(i, NULL);\n\t\t\t\tcontinue;\n\t\t\t}\n#ifdef MISSIONPACK\n\t\t\t// never link prox mine triggers\n\t\t\tif (ent->r.contents == CONTENTS_TRIGGER) {\n\t\t\t\tif (ent->touch == ProximityMine_Trigger) {\n\t\t\t\t\ttrap_BotLibUpdateEntity(i, NULL);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n#endif\n\t\t\t//\n\t\t\tmemset(&state, 0, sizeof(bot_entitystate_t));\n\t\t\t//\n\t\t\tVectorCopy(ent->r.currentOrigin, state.origin);\n\t\t\tif (i < MAX_CLIENTS) {\n\t\t\t\tVectorCopy(ent->s.apos.trBase, state.angles);\n\t\t\t} else {\n\t\t\t\tVectorCopy(ent->r.currentAngles, state.angles);\n\t\t\t}\n\t\t\tVectorCopy(ent->s.origin2, state.old_origin);\n\t\t\tVectorCopy(ent->r.mins, state.mins);\n\t\t\tVectorCopy(ent->r.maxs, state.maxs);\n\t\t\tstate.type = ent->s.eType;\n\t\t\tstate.flags = ent->s.eFlags;\n\t\t\tif (ent->r.bmodel) state.solid = SOLID_BSP;\n\t\t\telse state.solid = SOLID_BBOX;\n\t\t\tstate.groundent = ent->s.groundEntityNum;\n\t\t\tstate.modelindex = ent->s.modelindex;\n\t\t\tstate.modelindex2 = ent->s.modelindex2;\n\t\t\tstate.frame = ent->s.frame;\n\t\t\tstate.event = ent->s.event;\n\t\t\tstate.eventParm = ent->s.eventParm;\n\t\t\tstate.powerups = ent->s.powerups;\n\t\t\tstate.legsAnim = ent->s.legsAnim;\n\t\t\tstate.torsoAnim = ent->s.torsoAnim;\n\t\t\tstate.weapon = ent->s.weapon;\n\t\t\t//\n\t\t\ttrap_BotLibUpdateEntity(i, &state);\n\t\t}\n\n\t\tBotAIRegularUpdate();\n\t}\n\n\tfloattime = trap_AAS_Time();\n\n\t// execute scheduled bot AI\n\tfor( i = 0; i < MAX_CLIENTS; i++ ) {\n\t\tif( !botstates[i] || !botstates[i]->inuse ) {\n\t\t\tcontinue;\n\t\t}\n\t\t//\n\t\tbotstates[i]->botthink_residual += elapsed_time;\n\t\t//\n\t\tif ( botstates[i]->botthink_residual >= thinktime ) {\n\t\t\tbotstates[i]->botthink_residual -= thinktime;\n\n\t\t\tif (!trap_AAS_Initialized()) return qfalse;\n\n\t\t\tif (g_entities[i].client->pers.connected == CON_CONNECTED) {\n\t\t\t\tBotAI(i, (float) thinktime / 1000);\n\t\t\t}\n\t\t}\n\t}\n\n\n\t// execute bot user commands every frame\n\tfor( i = 0; i < MAX_CLIENTS; i++ ) {\n\t\tif( !botstates[i] || !botstates[i]->inuse ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif( g_entities[i].client->pers.connected != CON_CONNECTED ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tBotUpdateInput(botstates[i], time, elapsed_time);\n\t\ttrap_BotUserCommand(botstates[i]->client, &botstates[i]->lastucmd);\n\t}\n\n\treturn qtrue;\n}\n\n/*\n==============\nBotInitLibrary\n==============\n*/\nint BotInitLibrary(void) {\n\tchar buf[144];\n\n\t//set the maxclients and maxentities library variables before calling BotSetupLibrary\n\ttrap_Cvar_VariableStringBuffer(\"sv_maxclients\", buf, sizeof(buf));\n\tif (!strlen(buf)) strcpy(buf, \"8\");\n\ttrap_BotLibVarSet(\"maxclients\", buf);\n\tCom_sprintf(buf, sizeof(buf), \"%d\", MAX_GENTITIES);\n\ttrap_BotLibVarSet(\"maxentities\", buf);\n\t//bsp checksum\n\ttrap_Cvar_VariableStringBuffer(\"sv_mapChecksum\", buf, sizeof(buf));\n\tif (strlen(buf)) trap_BotLibVarSet(\"sv_mapChecksum\", buf);\n\t//maximum number of aas links\n\ttrap_Cvar_VariableStringBuffer(\"max_aaslinks\", buf, sizeof(buf));\n\tif (strlen(buf)) trap_BotLibVarSet(\"max_aaslinks\", buf);\n\t//maximum number of items in a level\n\ttrap_Cvar_VariableStringBuffer(\"max_levelitems\", buf, sizeof(buf));\n\tif (strlen(buf)) trap_BotLibVarSet(\"max_levelitems\", buf);\n\t//game type\n\ttrap_Cvar_VariableStringBuffer(\"g_gametype\", buf, sizeof(buf));\n\tif (!strlen(buf)) strcpy(buf, \"0\");\n\ttrap_BotLibVarSet(\"g_gametype\", buf);\n\t//bot developer mode and log file\n\ttrap_BotLibVarSet(\"bot_developer\", bot_developer.string);\n\ttrap_BotLibVarSet(\"log\", buf);\n\t//no chatting\n\ttrap_Cvar_VariableStringBuffer(\"bot_nochat\", buf, sizeof(buf));\n\tif (strlen(buf)) trap_BotLibVarSet(\"nochat\", \"0\");\n\t//visualize jump pads\n\ttrap_Cvar_VariableStringBuffer(\"bot_visualizejumppads\", buf, sizeof(buf));\n\tif (strlen(buf)) trap_BotLibVarSet(\"bot_visualizejumppads\", buf);\n\t//forced clustering calculations\n\ttrap_Cvar_VariableStringBuffer(\"bot_forceclustering\", buf, sizeof(buf));\n\tif (strlen(buf)) trap_BotLibVarSet(\"forceclustering\", buf);\n\t//forced reachability calculations\n\ttrap_Cvar_VariableStringBuffer(\"bot_forcereachability\", buf, sizeof(buf));\n\tif (strlen(buf)) trap_BotLibVarSet(\"forcereachability\", buf);\n\t//force writing of AAS to file\n\ttrap_Cvar_VariableStringBuffer(\"bot_forcewrite\", buf, sizeof(buf));\n\tif (strlen(buf)) trap_BotLibVarSet(\"forcewrite\", buf);\n\t//no AAS optimization\n\ttrap_Cvar_VariableStringBuffer(\"bot_aasoptimize\", buf, sizeof(buf));\n\tif (strlen(buf)) trap_BotLibVarSet(\"aasoptimize\", buf);\n\t//\n\ttrap_Cvar_VariableStringBuffer(\"bot_saveroutingcache\", buf, sizeof(buf));\n\tif (strlen(buf)) trap_BotLibVarSet(\"saveroutingcache\", buf);\n\t//reload instead of cache bot character files\n\ttrap_Cvar_VariableStringBuffer(\"bot_reloadcharacters\", buf, sizeof(buf));\n\tif (!strlen(buf)) strcpy(buf, \"0\");\n\ttrap_BotLibVarSet(\"bot_reloadcharacters\", buf);\n\t//base directory\n\ttrap_Cvar_VariableStringBuffer(\"fs_basepath\", buf, sizeof(buf));\n\tif (strlen(buf)) trap_BotLibVarSet(\"basedir\", buf);\n\t//game directory\n\ttrap_Cvar_VariableStringBuffer(\"fs_game\", buf, sizeof(buf));\n\tif (strlen(buf)) trap_BotLibVarSet(\"gamedir\", buf);\n\t//cd directory\n\ttrap_Cvar_VariableStringBuffer(\"fs_cdpath\", buf, sizeof(buf));\n\tif (strlen(buf)) trap_BotLibVarSet(\"cddir\", buf);\n\t//\n#ifdef MISSIONPACK\n\ttrap_BotLibDefine(\"MISSIONPACK\");\n#endif\n\t//setup the bot library\n\treturn trap_BotLibSetup();\n}\n\n/*\n==============\nBotAISetup\n==============\n*/\nint BotAISetup( int restart ) {\n\tint\t\t\terrnum;\n\n\ttrap_Cvar_Register(&bot_thinktime, \"bot_thinktime\", \"100\", CVAR_CHEAT);\n\ttrap_Cvar_Register(&bot_memorydump, \"bot_memorydump\", \"0\", CVAR_CHEAT);\n\ttrap_Cvar_Register(&bot_saveroutingcache, \"bot_saveroutingcache\", \"0\", CVAR_CHEAT);\n\ttrap_Cvar_Register(&bot_pause, \"bot_pause\", \"0\", CVAR_CHEAT);\n\ttrap_Cvar_Register(&bot_report, \"bot_report\", \"0\", CVAR_CHEAT);\n\ttrap_Cvar_Register(&bot_testsolid, \"bot_testsolid\", \"0\", CVAR_CHEAT);\n\ttrap_Cvar_Register(&bot_testclusters, \"bot_testclusters\", \"0\", CVAR_CHEAT);\n\ttrap_Cvar_Register(&bot_developer, \"bot_developer\", \"0\", CVAR_CHEAT);\n\ttrap_Cvar_Register(&bot_interbreedchar, \"bot_interbreedchar\", \"\", 0);\n\ttrap_Cvar_Register(&bot_interbreedbots, \"bot_interbreedbots\", \"10\", 0);\n\ttrap_Cvar_Register(&bot_interbreedcycle, \"bot_interbreedcycle\", \"20\", 0);\n\ttrap_Cvar_Register(&bot_interbreedwrite, \"bot_interbreedwrite\", \"\", 0);\n\n\t//if the game is restarted for a tournament\n\tif (restart) {\n\t\treturn qtrue;\n\t}\n\n\t//initialize the bot states\n\tmemset( botstates, 0, sizeof(botstates) );\n\n\terrnum = BotInitLibrary();\n\tif (errnum != BLERR_NOERROR) return qfalse;\n\treturn qtrue;\n}\n\n/*\n==============\nBotAIShutdown\n==============\n*/\nint BotAIShutdown( int restart ) {\n\n\tint i;\n\n\t//if the game is restarted for a tournament\n\tif ( restart ) {\n\t\t//shutdown all the bots in the botlib\n\t\tfor (i = 0; i < MAX_CLIENTS; i++) {\n\t\t\tif (botstates[i] && botstates[i]->inuse) {\n\t\t\t\tBotAIShutdownClient(botstates[i]->client, restart);\n\t\t\t}\n\t\t}\n\t\t//don't shutdown the bot library\n\t}\n\telse {\n\t\ttrap_BotLibShutdown();\n\t}\n\treturn qtrue;\n}\n\n"
  },
  {
    "path": "code/game/ai_main.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n/*****************************************************************************\n * name:\t\tai_main.h\n *\n * desc:\t\tQuake3 bot AI\n *\n * $Archive: /source/code/botai/ai_chat.c $\n *\n *****************************************************************************/\n\n//#define DEBUG\n#define CTF\n\n#define MAX_ITEMS\t\t\t\t\t256\n//bot flags\n#define BFL_STRAFERIGHT\t\t\t\t1\t//strafe to the right\n#define BFL_ATTACKED\t\t\t\t2\t//bot has attacked last ai frame\n#define BFL_ATTACKJUMPED\t\t\t4\t//bot jumped during attack last frame\n#define BFL_AIMATENEMY\t\t\t\t8\t//bot aimed at the enemy this frame\n#define BFL_AVOIDRIGHT\t\t\t\t16\t//avoid obstacles by going to the right\n#define BFL_IDEALVIEWSET\t\t\t32\t//bot has ideal view angles set\n#define BFL_FIGHTSUICIDAL\t\t\t64\t//bot is in a suicidal fight\n//long term goal types\n#define LTG_TEAMHELP\t\t\t\t1\t//help a team mate\n#define LTG_TEAMACCOMPANY\t\t\t2\t//accompany a team mate\n#define LTG_DEFENDKEYAREA\t\t\t3\t//defend a key area\n#define LTG_GETFLAG\t\t\t\t\t4\t//get the enemy flag\n#define LTG_RUSHBASE\t\t\t\t5\t//rush to the base\n#define LTG_RETURNFLAG\t\t\t\t6\t//return the flag\n#define LTG_CAMP\t\t\t\t\t7\t//camp somewhere\n#define LTG_CAMPORDER\t\t\t\t8\t//ordered to camp somewhere\n#define LTG_PATROL\t\t\t\t\t9\t//patrol\n#define LTG_GETITEM\t\t\t\t\t10\t//get an item\n#define LTG_KILL\t\t\t\t\t11\t//kill someone\n#define LTG_HARVEST\t\t\t\t\t12\t//harvest skulls\n#define LTG_ATTACKENEMYBASE\t\t\t13\t//attack the enemy base\n#define LTG_MAKELOVE_UNDER\t\t\t14\n#define LTG_MAKELOVE_ONTOP\t\t\t15\n//some goal dedication times\n#define TEAM_HELP_TIME\t\t\t\t60\t//1 minute teamplay help time\n#define TEAM_ACCOMPANY_TIME\t\t\t600\t//10 minutes teamplay accompany time\n#define TEAM_DEFENDKEYAREA_TIME\t\t600\t//10 minutes ctf defend base time\n#define TEAM_CAMP_TIME\t\t\t\t600\t//10 minutes camping time\n#define TEAM_PATROL_TIME\t\t\t600\t//10 minutes patrolling time\n#define TEAM_LEAD_TIME\t\t\t\t600\t//10 minutes taking the lead\n#define TEAM_GETITEM_TIME\t\t\t60\t//1 minute\n#define\tTEAM_KILL_SOMEONE\t\t\t180\t//3 minute to kill someone\n#define TEAM_ATTACKENEMYBASE_TIME\t600\t//10 minutes\n#define TEAM_HARVEST_TIME\t\t\t120\t//2 minutes\n#define CTF_GETFLAG_TIME\t\t\t600\t//10 minutes ctf get flag time\n#define CTF_RUSHBASE_TIME\t\t\t120\t//2 minutes ctf rush base time\n#define CTF_RETURNFLAG_TIME\t\t\t180\t//3 minutes to return the flag\n#define CTF_ROAM_TIME\t\t\t\t60\t//1 minute ctf roam time\n//patrol flags\n#define PATROL_LOOP\t\t\t\t\t1\n#define PATROL_REVERSE\t\t\t\t2\n#define PATROL_BACK\t\t\t\t\t4\n//teamplay task preference\n#define TEAMTP_DEFENDER\t\t\t\t1\n#define TEAMTP_ATTACKER\t\t\t\t2\n//CTF strategy\n#define CTFS_AGRESSIVE\t\t\t\t1\n//copied from the aas file header\n#define PRESENCE_NONE\t\t\t\t1\n#define PRESENCE_NORMAL\t\t\t\t2\n#define PRESENCE_CROUCH\t\t\t\t4\n//\n#define MAX_PROXMINES\t\t\t\t64\n\n//check points\ntypedef struct bot_waypoint_s\n{\n\tint\t\t\tinuse;\n\tchar\t\tname[32];\n\tbot_goal_t\tgoal;\n\tstruct\t\tbot_waypoint_s *next, *prev;\n} bot_waypoint_t;\n\n#define MAX_ACTIVATESTACK\t\t8\n#define MAX_ACTIVATEAREAS\t\t32\n\ntypedef struct bot_activategoal_s\n{\n\tint inuse;\n\tbot_goal_t goal;\t\t\t\t\t\t//goal to activate (buttons etc.)\n\tfloat time;\t\t\t\t\t\t\t\t//time to activate something\n\tfloat start_time;\t\t\t\t\t\t//time starting to activate something\n\tfloat justused_time;\t\t\t\t\t//time the goal was used\n\tint shoot;\t\t\t\t\t\t\t\t//true if bot has to shoot to activate\n\tint weapon;\t\t\t\t\t\t\t\t//weapon to be used for activation\n\tvec3_t target;\t\t\t\t\t\t\t//target to shoot at to activate something\n\tvec3_t origin;\t\t\t\t\t\t\t//origin of the blocking entity to activate\n\tint areas[MAX_ACTIVATEAREAS];\t\t\t//routing areas disabled by blocking entity\n\tint numareas;\t\t\t\t\t\t\t//number of disabled routing areas\n\tint areasdisabled;\t\t\t\t\t\t//true if the areas are disabled for the routing\n\tstruct bot_activategoal_s *next;\t\t//next activate goal on stack\n} bot_activategoal_t;\n\n//bot state\ntypedef struct bot_state_s\n{\n\tint inuse;\t\t\t\t\t\t\t\t\t\t//true if this state is used by a bot client\n\tint botthink_residual;\t\t\t\t\t\t\t//residual for the bot thinks\n\tint client;\t\t\t\t\t\t\t\t\t\t//client number of the bot\n\tint entitynum;\t\t\t\t\t\t\t\t\t//entity number of the bot\n\tplayerState_t cur_ps;\t\t\t\t\t\t\t//current player state\n\tint last_eFlags;\t\t\t\t\t\t\t\t//last ps flags\n\tusercmd_t lastucmd;\t\t\t\t\t\t\t\t//usercmd from last frame\n\tint entityeventTime[1024];\t\t\t\t\t\t//last entity event time\n\t//\n\tbot_settings_t settings;\t\t\t\t\t\t//several bot settings\n\tint (*ainode)(struct bot_state_s *bs);\t\t\t//current AI node\n\tfloat thinktime;\t\t\t\t\t\t\t\t//time the bot thinks this frame\n\tvec3_t origin;\t\t\t\t\t\t\t\t\t//origin of the bot\n\tvec3_t velocity;\t\t\t\t\t\t\t\t//velocity of the bot\n\tint presencetype;\t\t\t\t\t\t\t\t//presence type of the bot\n\tvec3_t eye;\t\t\t\t\t\t\t\t\t\t//eye coordinates of the bot\n\tint areanum;\t\t\t\t\t\t\t\t\t//the number of the area the bot is in\n\tint inventory[MAX_ITEMS];\t\t\t\t\t\t//string with items amounts the bot has\n\tint tfl;\t\t\t\t\t\t\t\t\t\t//the travel flags the bot uses\n\tint flags;\t\t\t\t\t\t\t\t\t\t//several flags\n\tint respawn_wait;\t\t\t\t\t\t\t\t//wait until respawned\n\tint lasthealth;\t\t\t\t\t\t\t\t\t//health value previous frame\n\tint lastkilledplayer;\t\t\t\t\t\t\t//last killed player\n\tint lastkilledby;\t\t\t\t\t\t\t\t//player that last killed this bot\n\tint botdeathtype;\t\t\t\t\t\t\t\t//the death type of the bot\n\tint enemydeathtype;\t\t\t\t\t\t\t\t//the death type of the enemy\n\tint botsuicide;\t\t\t\t\t\t\t\t\t//true when the bot suicides\n\tint enemysuicide;\t\t\t\t\t\t\t\t//true when the enemy of the bot suicides\n\tint setupcount;\t\t\t\t\t\t\t\t\t//true when the bot has just been setup\n\tint map_restart;\t\t\t\t\t\t\t\t\t//true when the map is being restarted\n\tint entergamechat;\t\t\t\t\t\t\t\t//true when the bot used an enter game chat\n\tint num_deaths;\t\t\t\t\t\t\t\t\t//number of time this bot died\n\tint num_kills;\t\t\t\t\t\t\t\t\t//number of kills of this bot\n\tint revenge_enemy;\t\t\t\t\t\t\t\t//the revenge enemy\n\tint revenge_kills;\t\t\t\t\t\t\t\t//number of kills the enemy made\n\tint lastframe_health;\t\t\t\t\t\t\t//health value the last frame\n\tint lasthitcount;\t\t\t\t\t\t\t\t//number of hits last frame\n\tint chatto;\t\t\t\t\t\t\t\t\t\t//chat to all or team\n\tfloat walker;\t\t\t\t\t\t\t\t\t//walker charactertic\n\tfloat ltime;\t\t\t\t\t\t\t\t\t//local bot time\n\tfloat entergame_time;\t\t\t\t\t\t\t//time the bot entered the game\n\tfloat ltg_time;\t\t\t\t\t\t\t\t\t//long term goal time\n\tfloat nbg_time;\t\t\t\t\t\t\t\t\t//nearby goal time\n\tfloat respawn_time;\t\t\t\t\t\t\t\t//time the bot takes to respawn\n\tfloat respawnchat_time;\t\t\t\t\t\t\t//time the bot started a chat during respawn\n\tfloat chase_time;\t\t\t\t\t\t\t\t//time the bot will chase the enemy\n\tfloat enemyvisible_time;\t\t\t\t\t\t//time the enemy was last visible\n\tfloat check_time;\t\t\t\t\t\t\t\t//time to check for nearby items\n\tfloat stand_time;\t\t\t\t\t\t\t\t//time the bot is standing still\n\tfloat lastchat_time;\t\t\t\t\t\t\t//time the bot last selected a chat\n\tfloat kamikaze_time;\t\t\t\t\t\t\t//time to check for kamikaze usage\n\tfloat invulnerability_time;\t\t\t\t\t\t//time to check for invulnerability usage\n\tfloat standfindenemy_time;\t\t\t\t\t\t//time to find enemy while standing\n\tfloat attackstrafe_time;\t\t\t\t\t\t//time the bot is strafing in one dir\n\tfloat attackcrouch_time;\t\t\t\t\t\t//time the bot will stop crouching\n\tfloat attackchase_time;\t\t\t\t\t\t\t//time the bot chases during actual attack\n\tfloat attackjump_time;\t\t\t\t\t\t\t//time the bot jumped during attack\n\tfloat enemysight_time;\t\t\t\t\t\t\t//time before reacting to enemy\n\tfloat enemydeath_time;\t\t\t\t\t\t\t//time the enemy died\n\tfloat enemyposition_time;\t\t\t\t\t\t//time the position and velocity of the enemy were stored\n\tfloat defendaway_time;\t\t\t\t\t\t\t//time away while defending\n\tfloat defendaway_range;\t\t\t\t\t\t\t//max travel time away from defend area\n\tfloat rushbaseaway_time;\t\t\t\t\t\t//time away from rushing to the base\n\tfloat attackaway_time;\t\t\t\t\t\t\t//time away from attacking the enemy base\n\tfloat harvestaway_time;\t\t\t\t\t\t\t//time away from harvesting\n\tfloat ctfroam_time;\t\t\t\t\t\t\t\t//time the bot is roaming in ctf\n\tfloat killedenemy_time;\t\t\t\t\t\t\t//time the bot killed the enemy\n\tfloat arrive_time;\t\t\t\t\t\t\t\t//time arrived (at companion)\n\tfloat lastair_time;\t\t\t\t\t\t\t\t//last time the bot had air\n\tfloat teleport_time;\t\t\t\t\t\t\t//last time the bot teleported\n\tfloat camp_time;\t\t\t\t\t\t\t\t//last time camped\n\tfloat camp_range;\t\t\t\t\t\t\t\t//camp range\n\tfloat weaponchange_time;\t\t\t\t\t\t//time the bot started changing weapons\n\tfloat firethrottlewait_time;\t\t\t\t\t//amount of time to wait\n\tfloat firethrottleshoot_time;\t\t\t\t\t//amount of time to shoot\n\tfloat notblocked_time;\t\t\t\t\t\t\t//last time the bot was not blocked\n\tfloat blockedbyavoidspot_time;\t\t\t\t\t//time blocked by an avoid spot\n\tfloat predictobstacles_time;\t\t\t\t\t//last time the bot predicted obstacles\n\tint predictobstacles_goalareanum;\t\t\t\t//last goal areanum the bot predicted obstacles for\n\tvec3_t aimtarget;\n\tvec3_t enemyvelocity;\t\t\t\t\t\t\t//enemy velocity 0.5 secs ago during battle\n\tvec3_t enemyorigin;\t\t\t\t\t\t\t\t//enemy origin 0.5 secs ago during battle\n\t//\n\tint kamikazebody;\t\t\t\t\t\t\t\t//kamikaze body\n\tint proxmines[MAX_PROXMINES];\n\tint numproxmines;\n\t//\n\tint character;\t\t\t\t\t\t\t\t\t//the bot character\n\tint ms;\t\t\t\t\t\t\t\t\t\t\t//move state of the bot\n\tint gs;\t\t\t\t\t\t\t\t\t\t\t//goal state of the bot\n\tint cs;\t\t\t\t\t\t\t\t\t\t\t//chat state of the bot\n\tint ws;\t\t\t\t\t\t\t\t\t\t\t//weapon state of the bot\n\t//\n\tint enemy;\t\t\t\t\t\t\t\t\t\t//enemy entity number\n\tint lastenemyareanum;\t\t\t\t\t\t\t//last reachability area the enemy was in\n\tvec3_t lastenemyorigin;\t\t\t\t\t\t\t//last origin of the enemy in the reachability area\n\tint weaponnum;\t\t\t\t\t\t\t\t\t//current weapon number\n\tvec3_t viewangles;\t\t\t\t\t\t\t\t//current view angles\n\tvec3_t ideal_viewangles;\t\t\t\t\t\t//ideal view angles\n\tvec3_t viewanglespeed;\n\t//\n\tint ltgtype;\t\t\t\t\t\t\t\t\t//long term goal type\n\t// team goals\n\tint teammate;\t\t\t\t\t\t\t\t\t//team mate involved in this team goal\n\tint decisionmaker;\t\t\t\t\t\t\t\t//player who decided to go for this goal\n\tint ordered;\t\t\t\t\t\t\t\t\t//true if ordered to do something\n\tfloat order_time;\t\t\t\t\t\t\t\t//time ordered to do something\n\tint owndecision_time;\t\t\t\t\t\t\t//time the bot made it's own decision\n\tbot_goal_t teamgoal;\t\t\t\t\t\t\t//the team goal\n\tbot_goal_t altroutegoal;\t\t\t\t\t\t//alternative route goal\n\tfloat reachedaltroutegoal_time;\t\t\t\t\t//time the bot reached the alt route goal\n\tfloat teammessage_time;\t\t\t\t\t\t\t//time to message team mates what the bot is doing\n\tfloat teamgoal_time;\t\t\t\t\t\t\t//time to stop helping team mate\n\tfloat teammatevisible_time;\t\t\t\t\t\t//last time the team mate was NOT visible\n\tint teamtaskpreference;\t\t\t\t\t\t\t//team task preference\n\t// last ordered team goal\n\tint lastgoal_decisionmaker;\n\tint lastgoal_ltgtype;\n\tint lastgoal_teammate;\n\tbot_goal_t lastgoal_teamgoal;\n\t// for leading team mates\n\tint lead_teammate;\t\t\t\t\t\t\t\t//team mate the bot is leading\n\tbot_goal_t lead_teamgoal;\t\t\t\t\t\t//team goal while leading\n\tfloat lead_time;\t\t\t\t\t\t\t\t//time leading someone\n\tfloat leadvisible_time;\t\t\t\t\t\t\t//last time the team mate was visible\n\tfloat leadmessage_time;\t\t\t\t\t\t\t//last time a messaged was sent to the team mate\n\tfloat leadbackup_time;\t\t\t\t\t\t\t//time backing up towards team mate\n\t//\n\tchar teamleader[32];\t\t\t\t\t\t\t//netname of the team leader\n\tfloat askteamleader_time;\t\t\t\t\t\t//time asked for team leader\n\tfloat becometeamleader_time;\t\t\t\t\t//time the bot will become the team leader\n\tfloat teamgiveorders_time;\t\t\t\t\t\t//time to give team orders\n\tfloat lastflagcapture_time;\t\t\t\t\t\t//last time a flag was captured\n\tint numteammates;\t\t\t\t\t\t\t\t//number of team mates\n\tint redflagstatus;\t\t\t\t\t\t\t\t//0 = at base, 1 = not at base\n\tint blueflagstatus;\t\t\t\t\t\t\t\t//0 = at base, 1 = not at base\n\tint neutralflagstatus;\t\t\t\t\t\t\t//0 = at base, 1 = our team has flag, 2 = enemy team has flag, 3 = enemy team dropped the flag\n\tint flagstatuschanged;\t\t\t\t\t\t\t//flag status changed\n\tint forceorders;\t\t\t\t\t\t\t\t//true if forced to give orders\n\tint flagcarrier;\t\t\t\t\t\t\t\t//team mate carrying the enemy flag\n\tint ctfstrategy;\t\t\t\t\t\t\t\t//ctf strategy\n\tchar subteam[32];\t\t\t\t\t\t\t\t//sub team name\n\tfloat formation_dist;\t\t\t\t\t\t\t//formation team mate intervening space\n\tchar formation_teammate[16];\t\t\t\t\t//netname of the team mate the bot uses for relative positioning\n\tfloat formation_angle;\t\t\t\t\t\t\t//angle relative to the formation team mate\n\tvec3_t formation_dir;\t\t\t\t\t\t\t//the direction the formation is moving in\n\tvec3_t formation_origin;\t\t\t\t\t\t//origin the bot uses for relative positioning\n\tbot_goal_t formation_goal;\t\t\t\t\t\t//formation goal\n\n\tbot_activategoal_t *activatestack;\t\t\t\t//first activate goal on the stack\n\tbot_activategoal_t activategoalheap[MAX_ACTIVATESTACK];\t//activate goal heap\n\n\tbot_waypoint_t *checkpoints;\t\t\t\t\t//check points\n\tbot_waypoint_t *patrolpoints;\t\t\t\t\t//patrol points\n\tbot_waypoint_t *curpatrolpoint;\t\t\t\t\t//current patrol point the bot is going for\n\tint patrolflags;\t\t\t\t\t\t\t\t//patrol flags\n} bot_state_t;\n\n//resets the whole bot state\nvoid BotResetState(bot_state_t *bs);\n//returns the number of bots in the game\nint NumBots(void);\n//returns info about the entity\nvoid BotEntityInfo(int entnum, aas_entityinfo_t *info);\n\nextern float floattime;\n#define FloatTime() floattime\n\n// from the game source\nvoid\tQDECL BotAI_Print(int type, char *fmt, ...);\nvoid\tQDECL QDECL BotAI_BotInitialChat( bot_state_t *bs, char *type, ... );\nvoid\tBotAI_Trace(bsp_trace_t *bsptrace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask);\nint\t\tBotAI_GetClientState( int clientNum, playerState_t *state );\nint\t\tBotAI_GetEntityState( int entityNum, entityState_t *state );\nint\t\tBotAI_GetSnapshotEntity( int clientNum, int sequence, entityState_t *state );\nint\t\tBotTeamLeader(bot_state_t *bs);\n"
  },
  {
    "path": "code/game/ai_team.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n/*****************************************************************************\n * name:\t\tai_team.c\n *\n * desc:\t\tQuake3 bot AI\n *\n * $Archive: /MissionPack/code/game/ai_team.c $\n *\n *****************************************************************************/\n\n#include \"g_local.h\"\n#include \"botlib.h\"\n#include \"be_aas.h\"\n#include \"be_ea.h\"\n#include \"be_ai_char.h\"\n#include \"be_ai_chat.h\"\n#include \"be_ai_gen.h\"\n#include \"be_ai_goal.h\"\n#include \"be_ai_move.h\"\n#include \"be_ai_weap.h\"\n//\n#include \"ai_main.h\"\n#include \"ai_dmq3.h\"\n#include \"ai_chat.h\"\n#include \"ai_cmd.h\"\n#include \"ai_dmnet.h\"\n#include \"ai_team.h\"\n#include \"ai_vcmd.h\"\n\n#include \"match.h\"\n\n// for the voice chats\n#include \"../../ui/menudef.h\"\n\n//ctf task preferences for a client\ntypedef struct bot_ctftaskpreference_s\n{\n\tchar\t\tname[36];\n\tint\t\t\tpreference;\n} bot_ctftaskpreference_t;\n\nbot_ctftaskpreference_t ctftaskpreferences[MAX_CLIENTS];\n\n\n/*\n==================\nBotValidTeamLeader\n==================\n*/\nint BotValidTeamLeader(bot_state_t *bs) {\n\tif (!strlen(bs->teamleader)) return qfalse;\n\tif (ClientFromName(bs->teamleader) == -1) return qfalse;\n\treturn qtrue;\n}\n\n/*\n==================\nBotNumTeamMates\n==================\n*/\nint BotNumTeamMates(bot_state_t *bs) {\n\tint i, numplayers;\n\tchar buf[MAX_INFO_STRING];\n\tstatic int maxclients;\n\n\tif (!maxclients)\n\t\tmaxclients = trap_Cvar_VariableIntegerValue(\"sv_maxclients\");\n\n\tnumplayers = 0;\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\ttrap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));\n\t\t//if no config string or no name\n\t\tif (!strlen(buf) || !strlen(Info_ValueForKey(buf, \"n\"))) continue;\n\t\t//skip spectators\n\t\tif (atoi(Info_ValueForKey(buf, \"t\")) == TEAM_SPECTATOR) continue;\n\t\t//\n\t\tif (BotSameTeam(bs, i)) {\n\t\t\tnumplayers++;\n\t\t}\n\t}\n\treturn numplayers;\n}\n\n/*\n==================\nBotClientTravelTimeToGoal\n==================\n*/\nint BotClientTravelTimeToGoal(int client, bot_goal_t *goal) {\n\tplayerState_t ps;\n\tint areanum;\n\n\tBotAI_GetClientState(client, &ps);\n\tareanum = BotPointAreaNum(ps.origin);\n\tif (!areanum) return 1;\n\treturn trap_AAS_AreaTravelTimeToGoalArea(areanum, ps.origin, goal->areanum, TFL_DEFAULT);\n}\n\n/*\n==================\nBotSortTeamMatesByBaseTravelTime\n==================\n*/\nint BotSortTeamMatesByBaseTravelTime(bot_state_t *bs, int *teammates, int maxteammates) {\n\n\tint i, j, k, numteammates, traveltime;\n\tchar buf[MAX_INFO_STRING];\n\tstatic int maxclients;\n\tint traveltimes[MAX_CLIENTS];\n\tbot_goal_t *goal = NULL;\n\n\tif (gametype == GT_CTF || gametype == GT_1FCTF) {\n\t\tif (BotTeam(bs) == TEAM_RED)\n\t\t\tgoal = &ctf_redflag;\n\t\telse\n\t\t\tgoal = &ctf_blueflag;\n\t}\n#ifdef MISSIONPACK\n\telse {\n\t\tif (BotTeam(bs) == TEAM_RED)\n\t\t\tgoal = &redobelisk;\n\t\telse\n\t\t\tgoal = &blueobelisk;\n\t}\n#endif\n\tif (!maxclients)\n\t\tmaxclients = trap_Cvar_VariableIntegerValue(\"sv_maxclients\");\n\n\tnumteammates = 0;\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\ttrap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));\n\t\t//if no config string or no name\n\t\tif (!strlen(buf) || !strlen(Info_ValueForKey(buf, \"n\"))) continue;\n\t\t//skip spectators\n\t\tif (atoi(Info_ValueForKey(buf, \"t\")) == TEAM_SPECTATOR) continue;\n\t\t//\n\t\tif (BotSameTeam(bs, i)) {\n\t\t\t//\n\t\t\ttraveltime = BotClientTravelTimeToGoal(i, goal);\n\t\t\t//\n\t\t\tfor (j = 0; j < numteammates; j++) {\n\t\t\t\tif (traveltime < traveltimes[j]) {\n\t\t\t\t\tfor (k = numteammates; k > j; k--) {\n\t\t\t\t\t\ttraveltimes[k] = traveltimes[k-1];\n\t\t\t\t\t\tteammates[k] = teammates[k-1];\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\ttraveltimes[j] = traveltime;\n\t\t\tteammates[j] = i;\n\t\t\tnumteammates++;\n\t\t\tif (numteammates >= maxteammates) break;\n\t\t}\n\t}\n\treturn numteammates;\n}\n\n/*\n==================\nBotSetTeamMateTaskPreference\n==================\n*/\nvoid BotSetTeamMateTaskPreference(bot_state_t *bs, int teammate, int preference) {\n\tchar teammatename[MAX_NETNAME];\n\n\tctftaskpreferences[teammate].preference = preference;\n\tClientName(teammate, teammatename, sizeof(teammatename));\n\tstrcpy(ctftaskpreferences[teammate].name, teammatename);\n}\n\n/*\n==================\nBotGetTeamMateTaskPreference\n==================\n*/\nint BotGetTeamMateTaskPreference(bot_state_t *bs, int teammate) {\n\tchar teammatename[MAX_NETNAME];\n\n\tif (!ctftaskpreferences[teammate].preference) return 0;\n\tClientName(teammate, teammatename, sizeof(teammatename));\n\tif (Q_stricmp(teammatename, ctftaskpreferences[teammate].name)) return 0;\n\treturn ctftaskpreferences[teammate].preference;\n}\n\n/*\n==================\nBotSortTeamMatesByTaskPreference\n==================\n*/\nint BotSortTeamMatesByTaskPreference(bot_state_t *bs, int *teammates, int numteammates) {\n\tint defenders[MAX_CLIENTS], numdefenders;\n\tint attackers[MAX_CLIENTS], numattackers;\n\tint roamers[MAX_CLIENTS], numroamers;\n\tint i, preference;\n\n\tnumdefenders = numattackers = numroamers = 0;\n\tfor (i = 0; i < numteammates; i++) {\n\t\tpreference = BotGetTeamMateTaskPreference(bs, teammates[i]);\n\t\tif (preference & TEAMTP_DEFENDER) {\n\t\t\tdefenders[numdefenders++] = teammates[i];\n\t\t}\n\t\telse if (preference & TEAMTP_ATTACKER) {\n\t\t\tattackers[numattackers++] = teammates[i];\n\t\t}\n\t\telse {\n\t\t\troamers[numroamers++] = teammates[i];\n\t\t}\n\t}\n\tnumteammates = 0;\n\t//defenders at the front of the list\n\tmemcpy(&teammates[numteammates], defenders, numdefenders * sizeof(int));\n\tnumteammates += numdefenders;\n\t//roamers in the middle\n\tmemcpy(&teammates[numteammates], roamers, numroamers * sizeof(int));\n\tnumteammates += numroamers;\n\t//attacker in the back of the list\n\tmemcpy(&teammates[numteammates], attackers, numattackers * sizeof(int));\n\tnumteammates += numattackers;\n\n\treturn numteammates;\n}\n\n/*\n==================\nBotSayTeamOrders\n==================\n*/\nvoid BotSayTeamOrderAlways(bot_state_t *bs, int toclient) {\n\tchar teamchat[MAX_MESSAGE_SIZE];\n\tchar buf[MAX_MESSAGE_SIZE];\n\tchar name[MAX_NETNAME];\n\n\t//if the bot is talking to itself\n\tif (bs->client == toclient) {\n\t\t//don't show the message just put it in the console message queue\n\t\ttrap_BotGetChatMessage(bs->cs, buf, sizeof(buf));\n\t\tClientName(bs->client, name, sizeof(name));\n\t\tCom_sprintf(teamchat, sizeof(teamchat), EC\"(%s\"EC\")\"EC\": %s\", name, buf);\n\t\ttrap_BotQueueConsoleMessage(bs->cs, CMS_CHAT, teamchat);\n\t}\n\telse {\n\t\ttrap_BotEnterChat(bs->cs, toclient, CHAT_TELL);\n\t}\n}\n\n/*\n==================\nBotSayTeamOrders\n==================\n*/\nvoid BotSayTeamOrder(bot_state_t *bs, int toclient) {\n#ifdef MISSIONPACK\n\t// voice chats only\n\tchar buf[MAX_MESSAGE_SIZE];\n\n\ttrap_BotGetChatMessage(bs->cs, buf, sizeof(buf));\n#else\n\tBotSayTeamOrderAlways(bs, toclient);\n#endif\n}\n\n/*\n==================\nBotVoiceChat\n==================\n*/\nvoid BotVoiceChat(bot_state_t *bs, int toclient, char *voicechat) {\n#ifdef MISSIONPACK\n\tif (toclient == -1)\n\t\t// voice only say team\n\t\ttrap_EA_Command(bs->client, va(\"vsay_team %s\", voicechat));\n\telse\n\t\t// voice only tell single player\n\t\ttrap_EA_Command(bs->client, va(\"vtell %d %s\", toclient, voicechat));\n#endif\n}\n\n/*\n==================\nBotVoiceChatOnly\n==================\n*/\nvoid BotVoiceChatOnly(bot_state_t *bs, int toclient, char *voicechat) {\n#ifdef MISSIONPACK\n\tif (toclient == -1)\n\t\t// voice only say team\n\t\ttrap_EA_Command(bs->client, va(\"vosay_team %s\", voicechat));\n\telse\n\t\t// voice only tell single player\n\t\ttrap_EA_Command(bs->client, va(\"votell %d %s\", toclient, voicechat));\n#endif\n}\n\n/*\n==================\nBotSayVoiceTeamOrder\n==================\n*/\nvoid BotSayVoiceTeamOrder(bot_state_t *bs, int toclient, char *voicechat) {\n#ifdef MISSIONPACK\n\tBotVoiceChat(bs, toclient, voicechat);\n#endif\n}\n\n/*\n==================\nBotCTFOrders\n==================\n*/\nvoid BotCTFOrders_BothFlagsNotAtBase(bot_state_t *bs) {\n\tint numteammates, defenders, attackers, i, other;\n\tint teammates[MAX_CLIENTS];\n\tchar name[MAX_NETNAME], carriername[MAX_NETNAME];\n\n\tnumteammates = BotSortTeamMatesByBaseTravelTime(bs, teammates, sizeof(teammates));\n\tBotSortTeamMatesByTaskPreference(bs, teammates, numteammates);\n\t//different orders based on the number of team mates\n\tswitch(bs->numteammates) {\n\t\tcase 1: break;\n\t\tcase 2:\n\t\t{\n\t\t\t//tell the one not carrying the flag to attack the enemy base\n\t\t\tif (teammates[0] != bs->flagcarrier) other = teammates[0];\n\t\t\telse other = teammates[1];\n\t\t\tClientName(other, name, sizeof(name));\n\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\tBotSayTeamOrder(bs, other);\n\t\t\tBotSayVoiceTeamOrder(bs, other, VOICECHAT_GETFLAG);\n\t\t\tbreak;\n\t\t}\n\t\tcase 3:\n\t\t{\n\t\t\t//tell the one closest to the base not carrying the flag to accompany the flag carrier\n\t\t\tif (teammates[0] != bs->flagcarrier) other = teammates[0];\n\t\t\telse other = teammates[1];\n\t\t\tClientName(other, name, sizeof(name));\n\t\t\tif ( bs->flagcarrier != -1 ) {\n\t\t\t\tClientName(bs->flagcarrier, carriername, sizeof(carriername));\n\t\t\t\tif (bs->flagcarrier == bs->client) {\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_accompanyme\", name, NULL);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, other, VOICECHAT_FOLLOWME);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_accompany\", name, carriername, NULL);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, other, VOICECHAT_FOLLOWFLAGCARRIER);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\t//\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayVoiceTeamOrder(bs, other, VOICECHAT_GETFLAG);\n\t\t\t}\n\t\t\tBotSayTeamOrder(bs, other);\n\t\t\t//tell the one furthest from the the base not carrying the flag to get the enemy flag\n\t\t\tif (teammates[2] != bs->flagcarrier) other = teammates[2];\n\t\t\telse other = teammates[1];\n\t\t\tClientName(other, name, sizeof(name));\n\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\tBotSayTeamOrder(bs, other);\n\t\t\tBotSayVoiceTeamOrder(bs, other, VOICECHAT_RETURNFLAG);\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t{\n\t\t\tdefenders = (int) (float) numteammates * 0.4 + 0.5;\n\t\t\tif (defenders > 4) defenders = 4;\n\t\t\tattackers = (int) (float) numteammates * 0.5 + 0.5;\n\t\t\tif (attackers > 5) attackers = 5;\n\t\t\tif (bs->flagcarrier != -1) {\n\t\t\t\tClientName(bs->flagcarrier, carriername, sizeof(carriername));\n\t\t\t\tfor (i = 0; i < defenders; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tif (teammates[i] == bs->flagcarrier) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[i], name, sizeof(name));\n\t\t\t\t\tif (bs->flagcarrier == bs->client) {\n\t\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_accompanyme\", name, NULL);\n\t\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_FOLLOWME);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_accompany\", name, carriername, NULL);\n\t\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_FOLLOWFLAGCARRIER);\n\t\t\t\t\t}\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tfor (i = 0; i < defenders; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tif (teammates[i] == bs->flagcarrier) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[i], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_GETFLAG);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (i = 0; i < attackers; i++) {\n\t\t\t\t//\n\t\t\t\tif (teammates[numteammates - i - 1] == bs->flagcarrier) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tClientName(teammates[numteammates - i - 1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[numteammates - i - 1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_RETURNFLAG);\n\t\t\t}\n\t\t\t//\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/*\n==================\nBotCTFOrders\n==================\n*/\nvoid BotCTFOrders_FlagNotAtBase(bot_state_t *bs) {\n\tint numteammates, defenders, attackers, i;\n\tint teammates[MAX_CLIENTS];\n\tchar name[MAX_NETNAME];\n\n\tnumteammates = BotSortTeamMatesByBaseTravelTime(bs, teammates, sizeof(teammates));\n\tBotSortTeamMatesByTaskPreference(bs, teammates, numteammates);\n\t//passive strategy\n\tif (!(bs->ctfstrategy & CTFS_AGRESSIVE)) {\n\t\t//different orders based on the number of team mates\n\t\tswitch(bs->numteammates) {\n\t\t\tcase 1: break;\n\t\t\tcase 2:\n\t\t\t{\n\t\t\t\t//both will go for the enemy flag\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_GETFLAG);\n\t\t\t\t//\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_GETFLAG);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 3:\n\t\t\t{\n\t\t\t\t//keep one near the base for when the flag is returned\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the other two get the flag\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_GETFLAG);\n\t\t\t\t//\n\t\t\t\tClientName(teammates[2], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[2]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[2], VOICECHAT_GETFLAG);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\t//keep some people near the base for when the flag is returned\n\t\t\t\tdefenders = (int) (float) numteammates * 0.3 + 0.5;\n\t\t\t\tif (defenders > 3) defenders = 3;\n\t\t\t\tattackers = (int) (float) numteammates * 0.7 + 0.5;\n\t\t\t\tif (attackers > 6) attackers = 6;\n\t\t\t\tfor (i = 0; i < defenders; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[i], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[i]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);\n\t\t\t\t}\n\t\t\t\tfor (i = 0; i < attackers; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[numteammates - i - 1], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[numteammates - i - 1]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_GETFLAG);\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\t//different orders based on the number of team mates\n\t\tswitch(bs->numteammates) {\n\t\t\tcase 1: break;\n\t\t\tcase 2:\n\t\t\t{\n\t\t\t\t//both will go for the enemy flag\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_GETFLAG);\n\t\t\t\t//\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_GETFLAG);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 3:\n\t\t\t{\n\t\t\t\t//everyone go for the flag\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_GETFLAG);\n\t\t\t\t//\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_GETFLAG);\n\t\t\t\t//\n\t\t\t\tClientName(teammates[2], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[2]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[2], VOICECHAT_GETFLAG);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\t//keep some people near the base for when the flag is returned\n\t\t\t\tdefenders = (int) (float) numteammates * 0.2 + 0.5;\n\t\t\t\tif (defenders > 2) defenders = 2;\n\t\t\t\tattackers = (int) (float) numteammates * 0.7 + 0.5;\n\t\t\t\tif (attackers > 7) attackers = 7;\n\t\t\t\tfor (i = 0; i < defenders; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[i], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[i]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);\n\t\t\t\t}\n\t\t\t\tfor (i = 0; i < attackers; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[numteammates - i - 1], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[numteammates - i - 1]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_GETFLAG);\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n==================\nBotCTFOrders\n==================\n*/\nvoid BotCTFOrders_EnemyFlagNotAtBase(bot_state_t *bs) {\n\tint numteammates, defenders, attackers, i, other;\n\tint teammates[MAX_CLIENTS];\n\tchar name[MAX_NETNAME], carriername[MAX_NETNAME];\n\n\tnumteammates = BotSortTeamMatesByBaseTravelTime(bs, teammates, sizeof(teammates));\n\tBotSortTeamMatesByTaskPreference(bs, teammates, numteammates);\n\t//different orders based on the number of team mates\n\tswitch(numteammates) {\n\t\tcase 1: break;\n\t\tcase 2:\n\t\t{\n\t\t\t//tell the one not carrying the flag to defend the base\n\t\t\tif (teammates[0] == bs->flagcarrier) other = teammates[1];\n\t\t\telse other = teammates[0];\n\t\t\tClientName(other, name, sizeof(name));\n\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\tBotSayTeamOrder(bs, other);\n\t\t\tBotSayVoiceTeamOrder(bs, other, VOICECHAT_DEFEND);\n\t\t\tbreak;\n\t\t}\n\t\tcase 3:\n\t\t{\n\t\t\t//tell the one closest to the base not carrying the flag to defend the base\n\t\t\tif (teammates[0] != bs->flagcarrier) other = teammates[0];\n\t\t\telse other = teammates[1];\n\t\t\tClientName(other, name, sizeof(name));\n\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\tBotSayTeamOrder(bs, other);\n\t\t\tBotSayVoiceTeamOrder(bs, other, VOICECHAT_DEFEND);\n\t\t\t//tell the other also to defend the base\n\t\t\tif (teammates[2] != bs->flagcarrier) other = teammates[2];\n\t\t\telse other = teammates[1];\n\t\t\tClientName(other, name, sizeof(name));\n\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\tBotSayTeamOrder(bs, other);\n\t\t\tBotSayVoiceTeamOrder(bs, other, VOICECHAT_DEFEND);\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t{\n\t\t\t//60% will defend the base\n\t\t\tdefenders = (int) (float) numteammates * 0.6 + 0.5;\n\t\t\tif (defenders > 6) defenders = 6;\n\t\t\t//30% accompanies the flag carrier\n\t\t\tattackers = (int) (float) numteammates * 0.3 + 0.5;\n\t\t\tif (attackers > 3) attackers = 3;\n\t\t\tfor (i = 0; i < defenders; i++) {\n\t\t\t\t//\n\t\t\t\tif (teammates[i] == bs->flagcarrier) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tClientName(teammates[i], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[i]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);\n\t\t\t}\n\t\t\t// if we have a flag carrier\n\t\t\tif ( bs->flagcarrier != -1 ) {\n\t\t\t\tClientName(bs->flagcarrier, carriername, sizeof(carriername));\n\t\t\t\tfor (i = 0; i < attackers; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tif (teammates[numteammates - i - 1] == bs->flagcarrier) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[numteammates - i - 1], name, sizeof(name));\n\t\t\t\t\tif (bs->flagcarrier == bs->client) {\n\t\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_accompanyme\", name, NULL);\n\t\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_FOLLOWME);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_accompany\", name, carriername, NULL);\n\t\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_FOLLOWFLAGCARRIER);\n\t\t\t\t\t}\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[numteammates - i - 1]);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tfor (i = 0; i < attackers; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tif (teammates[numteammates - i - 1] == bs->flagcarrier) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[numteammates - i - 1], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_GETFLAG);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[numteammates - i - 1]);\n\t\t\t\t}\n\t\t\t}\n\t\t\t//\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n\n/*\n==================\nBotCTFOrders\n==================\n*/\nvoid BotCTFOrders_BothFlagsAtBase(bot_state_t *bs) {\n\tint numteammates, defenders, attackers, i;\n\tint teammates[MAX_CLIENTS];\n\tchar name[MAX_NETNAME];\n\n\t//sort team mates by travel time to base\n\tnumteammates = BotSortTeamMatesByBaseTravelTime(bs, teammates, sizeof(teammates));\n\t//sort team mates by CTF preference\n\tBotSortTeamMatesByTaskPreference(bs, teammates, numteammates);\n\t//passive strategy\n\tif (!(bs->ctfstrategy & CTFS_AGRESSIVE)) {\n\t\t//different orders based on the number of team mates\n\t\tswitch(numteammates) {\n\t\t\tcase 1: break;\n\t\t\tcase 2:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the other will get the flag\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_GETFLAG);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 3:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the second one closest to the base will defend the base\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_DEFEND);\n\t\t\t\t//the other will get the flag\n\t\t\t\tClientName(teammates[2], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[2]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[2], VOICECHAT_GETFLAG);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\tdefenders = (int) (float) numteammates * 0.5 + 0.5;\n\t\t\t\tif (defenders > 5) defenders = 5;\n\t\t\t\tattackers = (int) (float) numteammates * 0.4 + 0.5;\n\t\t\t\tif (attackers > 4) attackers = 4;\n\t\t\t\tfor (i = 0; i < defenders; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[i], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[i]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);\n\t\t\t\t}\n\t\t\t\tfor (i = 0; i < attackers; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[numteammates - i - 1], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[numteammates - i - 1]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_GETFLAG);\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\t//different orders based on the number of team mates\n\t\tswitch(numteammates) {\n\t\t\tcase 1: break;\n\t\t\tcase 2:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the other will get the flag\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_GETFLAG);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 3:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the others should go for the enemy flag\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_GETFLAG);\n\t\t\t\t//\n\t\t\t\tClientName(teammates[2], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[2]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[2], VOICECHAT_GETFLAG);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\tdefenders = (int) (float) numteammates * 0.4 + 0.5;\n\t\t\t\tif (defenders > 4) defenders = 4;\n\t\t\t\tattackers = (int) (float) numteammates * 0.5 + 0.5;\n\t\t\t\tif (attackers > 5) attackers = 5;\n\t\t\t\tfor (i = 0; i < defenders; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[i], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[i]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);\n\t\t\t\t}\n\t\t\t\tfor (i = 0; i < attackers; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[numteammates - i - 1], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[numteammates - i - 1]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_GETFLAG);\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n==================\nBotCTFOrders\n==================\n*/\nvoid BotCTFOrders(bot_state_t *bs) {\n\tint flagstatus;\n\n\t//\n\tif (BotTeam(bs) == TEAM_RED) flagstatus = bs->redflagstatus * 2 + bs->blueflagstatus;\n\telse flagstatus = bs->blueflagstatus * 2 + bs->redflagstatus;\n\t//\n\tswitch(flagstatus) {\n\t\tcase 0: BotCTFOrders_BothFlagsAtBase(bs); break;\n\t\tcase 1: BotCTFOrders_EnemyFlagNotAtBase(bs); break;\n\t\tcase 2: BotCTFOrders_FlagNotAtBase(bs); break;\n\t\tcase 3: BotCTFOrders_BothFlagsNotAtBase(bs); break;\n\t}\n}\n\n\n/*\n==================\nBotCreateGroup\n==================\n*/\nvoid BotCreateGroup(bot_state_t *bs, int *teammates, int groupsize) {\n\tchar name[MAX_NETNAME], leadername[MAX_NETNAME];\n\tint i;\n\n\t// the others in the group will follow the teammates[0]\n\tClientName(teammates[0], leadername, sizeof(leadername));\n\tfor (i = 1; i < groupsize; i++)\n\t{\n\t\tClientName(teammates[i], name, sizeof(name));\n\t\tif (teammates[0] == bs->client) {\n\t\t\tBotAI_BotInitialChat(bs, \"cmd_accompanyme\", name, NULL);\n\t\t}\n\t\telse {\n\t\t\tBotAI_BotInitialChat(bs, \"cmd_accompany\", name, leadername, NULL);\n\t\t}\n\t\tBotSayTeamOrderAlways(bs, teammates[i]);\n\t}\n}\n\n/*\n==================\nBotTeamOrders\n\n  FIXME: defend key areas?\n==================\n*/\nvoid BotTeamOrders(bot_state_t *bs) {\n\tint teammates[MAX_CLIENTS];\n\tint numteammates, i;\n\tchar buf[MAX_INFO_STRING];\n\tstatic int maxclients;\n\n\tif (!maxclients)\n\t\tmaxclients = trap_Cvar_VariableIntegerValue(\"sv_maxclients\");\n\n\tnumteammates = 0;\n\tfor (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {\n\t\ttrap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));\n\t\t//if no config string or no name\n\t\tif (!strlen(buf) || !strlen(Info_ValueForKey(buf, \"n\"))) continue;\n\t\t//skip spectators\n\t\tif (atoi(Info_ValueForKey(buf, \"t\")) == TEAM_SPECTATOR) continue;\n\t\t//\n\t\tif (BotSameTeam(bs, i)) {\n\t\t\tteammates[numteammates] = i;\n\t\t\tnumteammates++;\n\t\t}\n\t}\n\t//\n\tswitch(numteammates) {\n\t\tcase 1: break;\n\t\tcase 2:\n\t\t{\n\t\t\t//nothing special\n\t\t\tbreak;\n\t\t}\n\t\tcase 3:\n\t\t{\n\t\t\t//have one follow another and one free roaming\n\t\t\tBotCreateGroup(bs, teammates, 2);\n\t\t\tbreak;\n\t\t}\n\t\tcase 4:\n\t\t{\n\t\t\tBotCreateGroup(bs, teammates, 2);\t\t//a group of 2\n\t\t\tBotCreateGroup(bs, &teammates[2], 2);\t//a group of 2\n\t\t\tbreak;\n\t\t}\n\t\tcase 5:\n\t\t{\n\t\t\tBotCreateGroup(bs, teammates, 2);\t\t//a group of 2\n\t\t\tBotCreateGroup(bs, &teammates[2], 3);\t//a group of 3\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t{\n\t\t\tif (numteammates <= 10) {\n\t\t\t\tfor (i = 0; i < numteammates / 2; i++) {\n\t\t\t\t\tBotCreateGroup(bs, &teammates[i*2], 2);\t//groups of 2\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n#ifdef MISSIONPACK\n\n/*\n==================\nBot1FCTFOrders_FlagAtCenter\n\n  X% defend the base, Y% get the flag\n==================\n*/\nvoid Bot1FCTFOrders_FlagAtCenter(bot_state_t *bs) {\n\tint numteammates, defenders, attackers, i;\n\tint teammates[MAX_CLIENTS];\n\tchar name[MAX_NETNAME];\n\n\t//sort team mates by travel time to base\n\tnumteammates = BotSortTeamMatesByBaseTravelTime(bs, teammates, sizeof(teammates));\n\t//sort team mates by CTF preference\n\tBotSortTeamMatesByTaskPreference(bs, teammates, numteammates);\n\t//passive strategy\n\tif (!(bs->ctfstrategy & CTFS_AGRESSIVE)) {\n\t\t//different orders based on the number of team mates\n\t\tswitch(numteammates) {\n\t\t\tcase 1: break;\n\t\t\tcase 2:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the other will get the flag\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_GETFLAG);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 3:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the second one closest to the base will defend the base\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the other will get the flag\n\t\t\t\tClientName(teammates[2], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[2]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[2], VOICECHAT_GETFLAG);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\t//50% defend the base\n\t\t\t\tdefenders = (int) (float) numteammates * 0.5 + 0.5;\n\t\t\t\tif (defenders > 5) defenders = 5;\n\t\t\t\t//40% get the flag\n\t\t\t\tattackers = (int) (float) numteammates * 0.4 + 0.5;\n\t\t\t\tif (attackers > 4) attackers = 4;\n\t\t\t\tfor (i = 0; i < defenders; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[i], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[i]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);\n\t\t\t\t}\n\t\t\t\tfor (i = 0; i < attackers; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[numteammates - i - 1], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[numteammates - i - 1]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_GETFLAG);\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\telse { //agressive\n\t\t//different orders based on the number of team mates\n\t\tswitch(numteammates) {\n\t\t\tcase 1: break;\n\t\t\tcase 2:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the other will get the flag\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_GETFLAG);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 3:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the others should go for the enemy flag\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_GETFLAG);\n\t\t\t\t//\n\t\t\t\tClientName(teammates[2], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[2]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[2], VOICECHAT_GETFLAG);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\t//30% defend the base\n\t\t\t\tdefenders = (int) (float) numteammates * 0.3 + 0.5;\n\t\t\t\tif (defenders > 3) defenders = 3;\n\t\t\t\t//60% get the flag\n\t\t\t\tattackers = (int) (float) numteammates * 0.6 + 0.5;\n\t\t\t\tif (attackers > 6) attackers = 6;\n\t\t\t\tfor (i = 0; i < defenders; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[i], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[i]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);\n\t\t\t\t}\n\t\t\t\tfor (i = 0; i < attackers; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[numteammates - i - 1], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[numteammates - i - 1]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_GETFLAG);\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n==================\nBot1FCTFOrders_TeamHasFlag\n\n  X% towards neutral flag, Y% go towards enemy base and accompany flag carrier if visible\n==================\n*/\nvoid Bot1FCTFOrders_TeamHasFlag(bot_state_t *bs) {\n\tint numteammates, defenders, attackers, i, other;\n\tint teammates[MAX_CLIENTS];\n\tchar name[MAX_NETNAME], carriername[MAX_NETNAME];\n\n\t//sort team mates by travel time to base\n\tnumteammates = BotSortTeamMatesByBaseTravelTime(bs, teammates, sizeof(teammates));\n\t//sort team mates by CTF preference\n\tBotSortTeamMatesByTaskPreference(bs, teammates, numteammates);\n\t//passive strategy\n\tif (!(bs->ctfstrategy & CTFS_AGRESSIVE)) {\n\t\t//different orders based on the number of team mates\n\t\tswitch(numteammates) {\n\t\t\tcase 1: break;\n\t\t\tcase 2:\n\t\t\t{\n\t\t\t\t//tell the one not carrying the flag to attack the enemy base\n\t\t\t\tif (teammates[0] == bs->flagcarrier) other = teammates[1];\n\t\t\t\telse other = teammates[0];\n\t\t\t\tClientName(other, name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_attackenemybase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, other);\n\t\t\t\tBotSayVoiceTeamOrder(bs, other, VOICECHAT_OFFENSE);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 3:\n\t\t\t{\n\t\t\t\t//tell the one closest to the base not carrying the flag to defend the base\n\t\t\t\tif (teammates[0] != bs->flagcarrier) other = teammates[0];\n\t\t\t\telse other = teammates[1];\n\t\t\t\tClientName(other, name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, other);\n\t\t\t\tBotSayVoiceTeamOrder(bs, other, VOICECHAT_DEFEND);\n\t\t\t\t//tell the one furthest from the base not carrying the flag to accompany the flag carrier\n\t\t\t\tif (teammates[2] != bs->flagcarrier) other = teammates[2];\n\t\t\t\telse other = teammates[1];\n\t\t\t\tClientName(other, name, sizeof(name));\n\t\t\t\tif ( bs->flagcarrier != -1 ) {\n\t\t\t\t\tClientName(bs->flagcarrier, carriername, sizeof(carriername));\n\t\t\t\t\tif (bs->flagcarrier == bs->client) {\n\t\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_accompanyme\", name, NULL);\n\t\t\t\t\t\tBotSayVoiceTeamOrder(bs, other, VOICECHAT_FOLLOWME);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_accompany\", name, carriername, NULL);\n\t\t\t\t\t\tBotSayVoiceTeamOrder(bs, other, VOICECHAT_FOLLOWFLAGCARRIER);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t//\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, other, VOICECHAT_GETFLAG);\n\t\t\t\t}\n\t\t\t\tBotSayTeamOrder(bs, other);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\t//30% will defend the base\n\t\t\t\tdefenders = (int) (float) numteammates * 0.3 + 0.5;\n\t\t\t\tif (defenders > 3) defenders = 3;\n\t\t\t\t//70% accompanies the flag carrier\n\t\t\t\tattackers = (int) (float) numteammates * 0.7 + 0.5;\n\t\t\t\tif (attackers > 7) attackers = 7;\n\t\t\t\tfor (i = 0; i < defenders; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tif (teammates[i] == bs->flagcarrier) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tClientName(teammates[i], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[i]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);\n\t\t\t\t}\n\t\t\t\tif (bs->flagcarrier != -1) {\n\t\t\t\t\tClientName(bs->flagcarrier, carriername, sizeof(carriername));\n\t\t\t\t\tfor (i = 0; i < attackers; i++) {\n\t\t\t\t\t\t//\n\t\t\t\t\t\tif (teammates[numteammates - i - 1] == bs->flagcarrier) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t//\n\t\t\t\t\t\tClientName(teammates[numteammates - i - 1], name, sizeof(name));\n\t\t\t\t\t\tif (bs->flagcarrier == bs->client) {\n\t\t\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_accompanyme\", name, NULL);\n\t\t\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_FOLLOWME);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_accompany\", name, carriername, NULL);\n\t\t\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_FOLLOWFLAGCARRIER);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tBotSayTeamOrder(bs, teammates[numteammates - i - 1]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tfor (i = 0; i < attackers; i++) {\n\t\t\t\t\t\t//\n\t\t\t\t\t\tif (teammates[numteammates - i - 1] == bs->flagcarrier) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t//\n\t\t\t\t\t\tClientName(teammates[numteammates - i - 1], name, sizeof(name));\n\t\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\t\t\tBotSayTeamOrder(bs, teammates[numteammates - i - 1]);\n\t\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_GETFLAG);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\telse { //agressive\n\t\t//different orders based on the number of team mates\n\t\tswitch(numteammates) {\n\t\t\tcase 1: break;\n\t\t\tcase 2:\n\t\t\t{\n\t\t\t\t//tell the one not carrying the flag to defend the base\n\t\t\t\tif (teammates[0] == bs->flagcarrier) other = teammates[1];\n\t\t\t\telse other = teammates[0];\n\t\t\t\tClientName(other, name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, other);\n\t\t\t\tBotSayVoiceTeamOrder(bs, other, VOICECHAT_DEFEND);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 3:\n\t\t\t{\n\t\t\t\t//tell the one closest to the base not carrying the flag to defend the base\n\t\t\t\tif (teammates[0] != bs->flagcarrier) other = teammates[0];\n\t\t\t\telse other = teammates[1];\n\t\t\t\tClientName(other, name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, other);\n\t\t\t\tBotSayVoiceTeamOrder(bs, other, VOICECHAT_DEFEND);\n\t\t\t\t//tell the one furthest from the base not carrying the flag to accompany the flag carrier\n\t\t\t\tif (teammates[2] != bs->flagcarrier) other = teammates[2];\n\t\t\t\telse other = teammates[1];\n\t\t\t\tClientName(other, name, sizeof(name));\n\t\t\t\tClientName(bs->flagcarrier, carriername, sizeof(carriername));\n\t\t\t\tif (bs->flagcarrier == bs->client) {\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_accompanyme\", name, NULL);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, other, VOICECHAT_FOLLOWME);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_accompany\", name, carriername, NULL);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, other, VOICECHAT_FOLLOWFLAGCARRIER);\n\t\t\t\t}\n\t\t\t\tBotSayTeamOrder(bs, other);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\t//20% will defend the base\n\t\t\t\tdefenders = (int) (float) numteammates * 0.2 + 0.5;\n\t\t\t\tif (defenders > 2) defenders = 2;\n\t\t\t\t//80% accompanies the flag carrier\n\t\t\t\tattackers = (int) (float) numteammates * 0.8 + 0.5;\n\t\t\t\tif (attackers > 8) attackers = 8;\n\t\t\t\tfor (i = 0; i < defenders; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tif (teammates[i] == bs->flagcarrier) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tClientName(teammates[i], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[i]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);\n\t\t\t\t}\n\t\t\t\tClientName(bs->flagcarrier, carriername, sizeof(carriername));\n\t\t\t\tfor (i = 0; i < attackers; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tif (teammates[numteammates - i - 1] == bs->flagcarrier) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[numteammates - i - 1], name, sizeof(name));\n\t\t\t\t\tif (bs->flagcarrier == bs->client) {\n\t\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_accompanyme\", name, NULL);\n\t\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_FOLLOWME);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_accompany\", name, carriername, NULL);\n\t\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_FOLLOWFLAGCARRIER);\n\t\t\t\t\t}\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[numteammates - i - 1]);\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n==================\nBot1FCTFOrders_EnemyHasFlag\n\n  X% defend the base, Y% towards neutral flag\n==================\n*/\nvoid Bot1FCTFOrders_EnemyHasFlag(bot_state_t *bs) {\n\tint numteammates, defenders, attackers, i;\n\tint teammates[MAX_CLIENTS];\n\tchar name[MAX_NETNAME];\n\n\t//sort team mates by travel time to base\n\tnumteammates = BotSortTeamMatesByBaseTravelTime(bs, teammates, sizeof(teammates));\n\t//sort team mates by CTF preference\n\tBotSortTeamMatesByTaskPreference(bs, teammates, numteammates);\n\t//passive strategy\n\tif (!(bs->ctfstrategy & CTFS_AGRESSIVE)) {\n\t\t//different orders based on the number of team mates\n\t\tswitch(numteammates) {\n\t\t\tcase 1: break;\n\t\t\tcase 2:\n\t\t\t{\n\t\t\t\t//both defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_DEFEND);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 3:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the second one closest to the base will defend the base\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_DEFEND);\n\t\t\t\t//the other will also defend the base\n\t\t\t\tClientName(teammates[2], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[2]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[2], VOICECHAT_DEFEND);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\t//80% will defend the base\n\t\t\t\tdefenders = (int) (float) numteammates * 0.8 + 0.5;\n\t\t\t\tif (defenders > 8) defenders = 8;\n\t\t\t\t//10% will try to return the flag\n\t\t\t\tattackers = (int) (float) numteammates * 0.1 + 0.5;\n\t\t\t\tif (attackers > 2) attackers = 2;\n\t\t\t\tfor (i = 0; i < defenders; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[i], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[i]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);\n\t\t\t\t}\n\t\t\t\tfor (i = 0; i < attackers; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[numteammates - i - 1], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_returnflag\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[numteammates - i - 1]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_GETFLAG);\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\telse { //agressive\n\t\t//different orders based on the number of team mates\n\t\tswitch(numteammates) {\n\t\t\tcase 1: break;\n\t\t\tcase 2:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the other will get the flag\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_DEFEND);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 3:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the others should go for the enemy flag\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_DEFEND);\n\t\t\t\t//\n\t\t\t\tClientName(teammates[2], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_returnflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[2]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[2], VOICECHAT_GETFLAG);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\t//70% defend the base\n\t\t\t\tdefenders = (int) (float) numteammates * 0.7 + 0.5;\n\t\t\t\tif (defenders > 8) defenders = 8;\n\t\t\t\t//20% try to return the flag\n\t\t\t\tattackers = (int) (float) numteammates * 0.2 + 0.5;\n\t\t\t\tif (attackers > 2) attackers = 2;\n\t\t\t\tfor (i = 0; i < defenders; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[i], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[i]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);\n\t\t\t\t}\n\t\t\t\tfor (i = 0; i < attackers; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[numteammates - i - 1], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_returnflag\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[numteammates - i - 1]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_GETFLAG);\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n==================\nBot1FCTFOrders_EnemyDroppedFlag\n\n  X% defend the base, Y% get the flag\n==================\n*/\nvoid Bot1FCTFOrders_EnemyDroppedFlag(bot_state_t *bs) {\n\tint numteammates, defenders, attackers, i;\n\tint teammates[MAX_CLIENTS];\n\tchar name[MAX_NETNAME];\n\n\t//sort team mates by travel time to base\n\tnumteammates = BotSortTeamMatesByBaseTravelTime(bs, teammates, sizeof(teammates));\n\t//sort team mates by CTF preference\n\tBotSortTeamMatesByTaskPreference(bs, teammates, numteammates);\n\t//passive strategy\n\tif (!(bs->ctfstrategy & CTFS_AGRESSIVE)) {\n\t\t//different orders based on the number of team mates\n\t\tswitch(numteammates) {\n\t\t\tcase 1: break;\n\t\t\tcase 2:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the other will get the flag\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_GETFLAG);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 3:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the second one closest to the base will defend the base\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_DEFEND);\n\t\t\t\t//the other will get the flag\n\t\t\t\tClientName(teammates[2], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[2]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[2], VOICECHAT_GETFLAG);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\t//50% defend the base\n\t\t\t\tdefenders = (int) (float) numteammates * 0.5 + 0.5;\n\t\t\t\tif (defenders > 5) defenders = 5;\n\t\t\t\t//40% get the flag\n\t\t\t\tattackers = (int) (float) numteammates * 0.4 + 0.5;\n\t\t\t\tif (attackers > 4) attackers = 4;\n\t\t\t\tfor (i = 0; i < defenders; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[i], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[i]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);\n\t\t\t\t}\n\t\t\t\tfor (i = 0; i < attackers; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[numteammates - i - 1], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[numteammates - i - 1]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_GETFLAG);\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\telse { //agressive\n\t\t//different orders based on the number of team mates\n\t\tswitch(numteammates) {\n\t\t\tcase 1: break;\n\t\t\tcase 2:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the other will get the flag\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_GETFLAG);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 3:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the others should go for the enemy flag\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_GETFLAG);\n\t\t\t\t//\n\t\t\t\tClientName(teammates[2], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[2]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[2], VOICECHAT_GETFLAG);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\t//30% defend the base\n\t\t\t\tdefenders = (int) (float) numteammates * 0.3 + 0.5;\n\t\t\t\tif (defenders > 3) defenders = 3;\n\t\t\t\t//60% get the flag\n\t\t\t\tattackers = (int) (float) numteammates * 0.6 + 0.5;\n\t\t\t\tif (attackers > 6) attackers = 6;\n\t\t\t\tfor (i = 0; i < defenders; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[i], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[i]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);\n\t\t\t\t}\n\t\t\t\tfor (i = 0; i < attackers; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[numteammates - i - 1], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_getflag\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[numteammates - i - 1]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_DEFEND);\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n==================\nBot1FCTFOrders\n==================\n*/\nvoid Bot1FCTFOrders(bot_state_t *bs) {\n\tswitch(bs->neutralflagstatus) {\n\t\tcase 0: Bot1FCTFOrders_FlagAtCenter(bs); break;\n\t\tcase 1: Bot1FCTFOrders_TeamHasFlag(bs); break;\n\t\tcase 2: Bot1FCTFOrders_EnemyHasFlag(bs); break;\n\t\tcase 3: Bot1FCTFOrders_EnemyDroppedFlag(bs); break;\n\t}\n}\n\n/*\n==================\nBotObeliskOrders\n\n  X% in defence Y% in offence\n==================\n*/\nvoid BotObeliskOrders(bot_state_t *bs) {\n\tint numteammates, defenders, attackers, i;\n\tint teammates[MAX_CLIENTS];\n\tchar name[MAX_NETNAME];\n\n\t//sort team mates by travel time to base\n\tnumteammates = BotSortTeamMatesByBaseTravelTime(bs, teammates, sizeof(teammates));\n\t//sort team mates by CTF preference\n\tBotSortTeamMatesByTaskPreference(bs, teammates, numteammates);\n\t//passive strategy\n\tif (!(bs->ctfstrategy & CTFS_AGRESSIVE)) {\n\t\t//different orders based on the number of team mates\n\t\tswitch(numteammates) {\n\t\t\tcase 1: break;\n\t\t\tcase 2:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the other will attack the enemy base\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_attackenemybase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_OFFENSE);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 3:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the one second closest to the base also defends the base\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_DEFEND);\n\t\t\t\t//the other one attacks the enemy base\n\t\t\t\tClientName(teammates[2], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_attackenemybase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[2]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[2], VOICECHAT_OFFENSE);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\t//50% defend the base\n\t\t\t\tdefenders = (int) (float) numteammates * 0.5 + 0.5;\n\t\t\t\tif (defenders > 5) defenders = 5;\n\t\t\t\t//40% attack the enemy base\n\t\t\t\tattackers = (int) (float) numteammates * 0.4 + 0.5;\n\t\t\t\tif (attackers > 4) attackers = 4;\n\t\t\t\tfor (i = 0; i < defenders; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[i], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[i]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);\n\t\t\t\t}\n\t\t\t\tfor (i = 0; i < attackers; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[numteammates - i - 1], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_attackenemybase\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[numteammates - i - 1]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_OFFENSE);\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\t//different orders based on the number of team mates\n\t\tswitch(numteammates) {\n\t\t\tcase 1: break;\n\t\t\tcase 2:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the other will attack the enemy base\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_attackenemybase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_OFFENSE);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 3:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the others attack the enemy base\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_attackenemybase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_OFFENSE);\n\t\t\t\t//\n\t\t\t\tClientName(teammates[2], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_attackenemybase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[2]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[2], VOICECHAT_OFFENSE);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\t//30% defend the base\n\t\t\t\tdefenders = (int) (float) numteammates * 0.3 + 0.5;\n\t\t\t\tif (defenders > 3) defenders = 3;\n\t\t\t\t//70% attack the enemy base\n\t\t\t\tattackers = (int) (float) numteammates * 0.7 + 0.5;\n\t\t\t\tif (attackers > 7) attackers = 7;\n\t\t\t\tfor (i = 0; i < defenders; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[i], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[i]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);\n\t\t\t\t}\n\t\t\t\tfor (i = 0; i < attackers; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[numteammates - i - 1], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_attackenemybase\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[numteammates - i - 1]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_OFFENSE);\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n==================\nBotHarvesterOrders\n\n  X% defend the base, Y% harvest\n==================\n*/\nvoid BotHarvesterOrders(bot_state_t *bs) {\n\tint numteammates, defenders, attackers, i;\n\tint teammates[MAX_CLIENTS];\n\tchar name[MAX_NETNAME];\n\n\t//sort team mates by travel time to base\n\tnumteammates = BotSortTeamMatesByBaseTravelTime(bs, teammates, sizeof(teammates));\n\t//sort team mates by CTF preference\n\tBotSortTeamMatesByTaskPreference(bs, teammates, numteammates);\n\t//passive strategy\n\tif (!(bs->ctfstrategy & CTFS_AGRESSIVE)) {\n\t\t//different orders based on the number of team mates\n\t\tswitch(numteammates) {\n\t\t\tcase 1: break;\n\t\t\tcase 2:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the other will harvest\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_harvest\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_OFFENSE);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 3:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the one second closest to the base also defends the base\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_DEFEND);\n\t\t\t\t//the other one goes harvesting\n\t\t\t\tClientName(teammates[2], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_harvest\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[2]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[2], VOICECHAT_OFFENSE);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\t//50% defend the base\n\t\t\t\tdefenders = (int) (float) numteammates * 0.5 + 0.5;\n\t\t\t\tif (defenders > 5) defenders = 5;\n\t\t\t\t//40% goes harvesting\n\t\t\t\tattackers = (int) (float) numteammates * 0.4 + 0.5;\n\t\t\t\tif (attackers > 4) attackers = 4;\n\t\t\t\tfor (i = 0; i < defenders; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[i], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[i]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);\n\t\t\t\t}\n\t\t\t\tfor (i = 0; i < attackers; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[numteammates - i - 1], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_harvest\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[numteammates - i - 1]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_OFFENSE);\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\t//different orders based on the number of team mates\n\t\tswitch(numteammates) {\n\t\t\tcase 1: break;\n\t\t\tcase 2:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the other will harvest\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_harvest\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_OFFENSE);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 3:\n\t\t\t{\n\t\t\t\t//the one closest to the base will defend the base\n\t\t\t\tClientName(teammates[0], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[0]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[0], VOICECHAT_DEFEND);\n\t\t\t\t//the others go harvesting\n\t\t\t\tClientName(teammates[1], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_harvest\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[1]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[1], VOICECHAT_OFFENSE);\n\t\t\t\t//\n\t\t\t\tClientName(teammates[2], name, sizeof(name));\n\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_harvest\", name, NULL);\n\t\t\t\tBotSayTeamOrder(bs, teammates[2]);\n\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[2], VOICECHAT_OFFENSE);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\t//30% defend the base\n\t\t\t\tdefenders = (int) (float) numteammates * 0.3 + 0.5;\n\t\t\t\tif (defenders > 3) defenders = 3;\n\t\t\t\t//70% go harvesting\n\t\t\t\tattackers = (int) (float) numteammates * 0.7 + 0.5;\n\t\t\t\tif (attackers > 7) attackers = 7;\n\t\t\t\tfor (i = 0; i < defenders; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[i], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_defendbase\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[i]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[i], VOICECHAT_DEFEND);\n\t\t\t\t}\n\t\t\t\tfor (i = 0; i < attackers; i++) {\n\t\t\t\t\t//\n\t\t\t\t\tClientName(teammates[numteammates - i - 1], name, sizeof(name));\n\t\t\t\t\tBotAI_BotInitialChat(bs, \"cmd_harvest\", name, NULL);\n\t\t\t\t\tBotSayTeamOrder(bs, teammates[numteammates - i - 1]);\n\t\t\t\t\tBotSayVoiceTeamOrder(bs, teammates[numteammates - i - 1], VOICECHAT_OFFENSE);\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n#endif\n\n/*\n==================\nFindHumanTeamLeader\n==================\n*/\nint FindHumanTeamLeader(bot_state_t *bs) {\n\tint i;\n\n\tfor (i = 0; i < MAX_CLIENTS; i++) {\n\t\tif ( g_entities[i].inuse ) {\n\t\t\t// if this player is not a bot\n\t\t\tif ( !(g_entities[i].r.svFlags & SVF_BOT) ) {\n\t\t\t\t// if this player is ok with being the leader\n\t\t\t\tif (!notleader[i]) {\n\t\t\t\t\t// if this player is on the same team\n\t\t\t\t\tif ( BotSameTeam(bs, i) ) {\n\t\t\t\t\t\tClientName(i, bs->teamleader, sizeof(bs->teamleader));\n\t\t\t\t\t\t// if not yet ordered to do anything\n\t\t\t\t\t\tif ( !BotSetLastOrderedTask(bs) ) {\n\t\t\t\t\t\t\t// go on defense by default\n\t\t\t\t\t\t\tBotVoiceChat_Defend(bs, i, SAY_TELL);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn qtrue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nBotTeamAI\n==================\n*/\nvoid BotTeamAI(bot_state_t *bs) {\n\tint numteammates;\n\tchar netname[MAX_NETNAME];\n\n\t//\n\tif ( gametype < GT_TEAM  )\n\t\treturn;\n\t// make sure we've got a valid team leader\n\tif (!BotValidTeamLeader(bs)) {\n\t\t//\n\t\tif (!FindHumanTeamLeader(bs)) {\n\t\t\t//\n\t\t\tif (!bs->askteamleader_time && !bs->becometeamleader_time) {\n\t\t\t\tif (bs->entergame_time + 10 > FloatTime()) {\n\t\t\t\t\tbs->askteamleader_time = FloatTime() + 5 + random() * 10;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tbs->becometeamleader_time = FloatTime() + 5 + random() * 10;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (bs->askteamleader_time && bs->askteamleader_time < FloatTime()) {\n\t\t\t\t// if asked for a team leader and no response\n\t\t\t\tBotAI_BotInitialChat(bs, \"whoisteamleader\", NULL);\n\t\t\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_TEAM);\n\t\t\t\tbs->askteamleader_time = 0;\n\t\t\t\tbs->becometeamleader_time = FloatTime() + 8 + random() * 10;\n\t\t\t}\n\t\t\tif (bs->becometeamleader_time && bs->becometeamleader_time < FloatTime()) {\n\t\t\t\tBotAI_BotInitialChat(bs, \"iamteamleader\", NULL);\n\t\t\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_TEAM);\n\t\t\t\tBotSayVoiceTeamOrder(bs, -1, VOICECHAT_STARTLEADER);\n\t\t\t\tClientName(bs->client, netname, sizeof(netname));\n\t\t\t\tstrncpy(bs->teamleader, netname, sizeof(bs->teamleader));\n\t\t\t\tbs->teamleader[sizeof(bs->teamleader)] = '\\0';\n\t\t\t\tbs->becometeamleader_time = 0;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t}\n\tbs->askteamleader_time = 0;\n\tbs->becometeamleader_time = 0;\n\n\t//return if this bot is NOT the team leader\n\tClientName(bs->client, netname, sizeof(netname));\n\tif (Q_stricmp(netname, bs->teamleader) != 0) return;\n\t//\n\tnumteammates = BotNumTeamMates(bs);\n\t//give orders\n\tswitch(gametype) {\n\t\tcase GT_TEAM:\n\t\t{\n\t\t\tif (bs->numteammates != numteammates || bs->forceorders) {\n\t\t\t\tbs->teamgiveorders_time = FloatTime();\n\t\t\t\tbs->numteammates = numteammates;\n\t\t\t\tbs->forceorders = qfalse;\n\t\t\t}\n\t\t\t//if it's time to give orders\n\t\t\tif (bs->teamgiveorders_time && bs->teamgiveorders_time < FloatTime() - 5) {\n\t\t\t\tBotTeamOrders(bs);\n\t\t\t\t//give orders again after 120 seconds\n\t\t\t\tbs->teamgiveorders_time = FloatTime() + 120;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase GT_CTF:\n\t\t{\n\t\t\t//if the number of team mates changed or the flag status changed\n\t\t\t//or someone wants to know what to do\n\t\t\tif (bs->numteammates != numteammates || bs->flagstatuschanged || bs->forceorders) {\n\t\t\t\tbs->teamgiveorders_time = FloatTime();\n\t\t\t\tbs->numteammates = numteammates;\n\t\t\t\tbs->flagstatuschanged = qfalse;\n\t\t\t\tbs->forceorders = qfalse;\n\t\t\t}\n\t\t\t//if there were no flag captures the last 3 minutes\n\t\t\tif (bs->lastflagcapture_time < FloatTime() - 240) {\n\t\t\t\tbs->lastflagcapture_time = FloatTime();\n\t\t\t\t//randomly change the CTF strategy\n\t\t\t\tif (random() < 0.4) {\n\t\t\t\t\tbs->ctfstrategy ^= CTFS_AGRESSIVE;\n\t\t\t\t\tbs->teamgiveorders_time = FloatTime();\n\t\t\t\t}\n\t\t\t}\n\t\t\t//if it's time to give orders\n\t\t\tif (bs->teamgiveorders_time && bs->teamgiveorders_time < FloatTime() - 3) {\n\t\t\t\tBotCTFOrders(bs);\n\t\t\t\t//\n\t\t\t\tbs->teamgiveorders_time = 0;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n#ifdef MISSIONPACK\n\t\tcase GT_1FCTF:\n\t\t{\n\t\t\tif (bs->numteammates != numteammates || bs->flagstatuschanged || bs->forceorders) {\n\t\t\t\tbs->teamgiveorders_time = FloatTime();\n\t\t\t\tbs->numteammates = numteammates;\n\t\t\t\tbs->flagstatuschanged = qfalse;\n\t\t\t\tbs->forceorders = qfalse;\n\t\t\t}\n\t\t\t//if there were no flag captures the last 4 minutes\n\t\t\tif (bs->lastflagcapture_time < FloatTime() - 240) {\n\t\t\t\tbs->lastflagcapture_time = FloatTime();\n\t\t\t\t//randomly change the CTF strategy\n\t\t\t\tif (random() < 0.4) {\n\t\t\t\t\tbs->ctfstrategy ^= CTFS_AGRESSIVE;\n\t\t\t\t\tbs->teamgiveorders_time = FloatTime();\n\t\t\t\t}\n\t\t\t}\n\t\t\t//if it's time to give orders\n\t\t\tif (bs->teamgiveorders_time && bs->teamgiveorders_time < FloatTime() - 2) {\n\t\t\t\tBot1FCTFOrders(bs);\n\t\t\t\t//\n\t\t\t\tbs->teamgiveorders_time = 0;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase GT_OBELISK:\n\t\t{\n\t\t\tif (bs->numteammates != numteammates || bs->forceorders) {\n\t\t\t\tbs->teamgiveorders_time = FloatTime();\n\t\t\t\tbs->numteammates = numteammates;\n\t\t\t\tbs->forceorders = qfalse;\n\t\t\t}\n\t\t\t//if it's time to give orders\n\t\t\tif (bs->teamgiveorders_time && bs->teamgiveorders_time < FloatTime() - 5) {\n\t\t\t\tBotObeliskOrders(bs);\n\t\t\t\t//give orders again after 30 seconds\n\t\t\t\tbs->teamgiveorders_time = FloatTime() + 30;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase GT_HARVESTER:\n\t\t{\n\t\t\tif (bs->numteammates != numteammates || bs->forceorders) {\n\t\t\t\tbs->teamgiveorders_time = FloatTime();\n\t\t\t\tbs->numteammates = numteammates;\n\t\t\t\tbs->forceorders = qfalse;\n\t\t\t}\n\t\t\t//if it's time to give orders\n\t\t\tif (bs->teamgiveorders_time && bs->teamgiveorders_time < FloatTime() - 5) {\n\t\t\t\tBotHarvesterOrders(bs);\n\t\t\t\t//give orders again after 30 seconds\n\t\t\t\tbs->teamgiveorders_time = FloatTime() + 30;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n#endif\n\t}\n}\n\n"
  },
  {
    "path": "code/game/ai_team.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n/*****************************************************************************\n * name:\t\tai_team.h\n *\n * desc:\t\tQuake3 bot AI\n *\n * $Archive: /source/code/botai/ai_chat.c $\n *\n *****************************************************************************/\n\nvoid BotTeamAI(bot_state_t *bs);\nint BotGetTeamMateTaskPreference(bot_state_t *bs, int teammate);\nvoid BotSetTeamMateTaskPreference(bot_state_t *bs, int teammate, int preference);\nvoid BotVoiceChat(bot_state_t *bs, int toclient, char *voicechat);\nvoid BotVoiceChatOnly(bot_state_t *bs, int toclient, char *voicechat);\n\n\n"
  },
  {
    "path": "code/game/ai_vcmd.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n/*****************************************************************************\n * name:\t\tai_vcmd.c\n *\n * desc:\t\tQuake3 bot AI\n *\n * $Archive: /MissionPack/code/game/ai_vcmd.c $\n *\n *****************************************************************************/\n\n#include \"g_local.h\"\n#include \"botlib.h\"\n#include \"be_aas.h\"\n#include \"be_ea.h\"\n#include \"be_ai_char.h\"\n#include \"be_ai_chat.h\"\n#include \"be_ai_gen.h\"\n#include \"be_ai_goal.h\"\n#include \"be_ai_move.h\"\n#include \"be_ai_weap.h\"\n//\n#include \"ai_main.h\"\n#include \"ai_dmq3.h\"\n#include \"ai_chat.h\"\n#include \"ai_cmd.h\"\n#include \"ai_dmnet.h\"\n#include \"ai_team.h\"\n#include \"ai_vcmd.h\"\n//\n#include \"chars.h\"\t\t\t\t//characteristics\n#include \"inv.h\"\t\t\t\t//indexes into the inventory\n#include \"syn.h\"\t\t\t\t//synonyms\n#include \"match.h\"\t\t\t\t//string matching types and vars\n\n// for the voice chats\n#include \"../../ui/menudef.h\"\n\n\ntypedef struct voiceCommand_s\n{\n\tchar *cmd;\n\tvoid (*func)(bot_state_t *bs, int client, int mode);\n} voiceCommand_t;\n\n/*\n==================\nBotVoiceChat_GetFlag\n==================\n*/\nvoid BotVoiceChat_GetFlag(bot_state_t *bs, int client, int mode) {\n\t//\n\tif (gametype == GT_CTF) {\n\t\tif (!ctf_redflag.areanum || !ctf_blueflag.areanum)\n\t\t\treturn;\n\t}\n#ifdef MISSIONPACK\n\telse if (gametype == GT_1FCTF) {\n\t\tif (!ctf_neutralflag.areanum || !ctf_redflag.areanum || !ctf_blueflag.areanum)\n\t\t\treturn;\n\t}\n#endif\n\telse {\n\t\treturn;\n\t}\n\t//\n\tbs->decisionmaker = client;\n\tbs->ordered = qtrue;\n\tbs->order_time = FloatTime();\n\t//set the time to send a message to the team mates\n\tbs->teammessage_time = FloatTime() + 2 * random();\n\t//set the ltg type\n\tbs->ltgtype = LTG_GETFLAG;\n\t//set the team goal time\n\tbs->teamgoal_time = FloatTime() + CTF_GETFLAG_TIME;\n\t// get an alternate route in ctf\n\tif (gametype == GT_CTF) {\n\t\t//get an alternative route goal towards the enemy base\n\t\tBotGetAlternateRouteGoal(bs, BotOppositeTeam(bs));\n\t}\n\t//\n\tBotSetTeamStatus(bs);\n\t// remember last ordered task\n\tBotRememberLastOrderedTask(bs);\n#ifdef DEBUG\n\tBotPrintTeamGoal(bs);\n#endif //DEBUG\n}\n\n/*\n==================\nBotVoiceChat_Offense\n==================\n*/\nvoid BotVoiceChat_Offense(bot_state_t *bs, int client, int mode) {\n\tif ( gametype == GT_CTF\n#ifdef MISSIONPACK\n\t\t|| gametype == GT_1FCTF\n#endif\n\t\t) {\n\t\tBotVoiceChat_GetFlag(bs, client, mode);\n\t\treturn;\n\t}\n#ifdef MISSIONPACK\n\tif (gametype == GT_HARVESTER) {\n\t\t//\n\t\tbs->decisionmaker = client;\n\t\tbs->ordered = qtrue;\n\t\tbs->order_time = FloatTime();\n\t\t//set the time to send a message to the team mates\n\t\tbs->teammessage_time = FloatTime() + 2 * random();\n\t\t//set the ltg type\n\t\tbs->ltgtype = LTG_HARVEST;\n\t\t//set the team goal time\n\t\tbs->teamgoal_time = FloatTime() + TEAM_HARVEST_TIME;\n\t\tbs->harvestaway_time = 0;\n\t\t//\n\t\tBotSetTeamStatus(bs);\n\t\t// remember last ordered task\n\t\tBotRememberLastOrderedTask(bs);\n\t}\n\telse\n#endif\n\t{\n\t\t//\n\t\tbs->decisionmaker = client;\n\t\tbs->ordered = qtrue;\n\t\tbs->order_time = FloatTime();\n\t\t//set the time to send a message to the team mates\n\t\tbs->teammessage_time = FloatTime() + 2 * random();\n\t\t//set the ltg type\n\t\tbs->ltgtype = LTG_ATTACKENEMYBASE;\n\t\t//set the team goal time\n\t\tbs->teamgoal_time = FloatTime() + TEAM_ATTACKENEMYBASE_TIME;\n\t\tbs->attackaway_time = 0;\n\t\t//\n\t\tBotSetTeamStatus(bs);\n\t\t// remember last ordered task\n\t\tBotRememberLastOrderedTask(bs);\n\t}\n#ifdef DEBUG\n\tBotPrintTeamGoal(bs);\n#endif //DEBUG\n}\n\n/*\n==================\nBotVoiceChat_Defend\n==================\n*/\nvoid BotVoiceChat_Defend(bot_state_t *bs, int client, int mode) {\n#ifdef MISSIONPACK\n\tif ( gametype == GT_OBELISK || gametype == GT_HARVESTER) {\n\t\t//\n\t\tswitch(BotTeam(bs)) {\n\t\t\tcase TEAM_RED: memcpy(&bs->teamgoal, &redobelisk, sizeof(bot_goal_t)); break;\n\t\t\tcase TEAM_BLUE: memcpy(&bs->teamgoal, &blueobelisk, sizeof(bot_goal_t)); break;\n\t\t\tdefault: return;\n\t\t}\n\t}\n\telse\n#endif\n\t\tif (gametype == GT_CTF\n#ifdef MISSIONPACK\n\t\t\t|| gametype == GT_1FCTF\n#endif\n\t\t\t) {\n\t\t//\n\t\tswitch(BotTeam(bs)) {\n\t\t\tcase TEAM_RED: memcpy(&bs->teamgoal, &ctf_redflag, sizeof(bot_goal_t)); break;\n\t\t\tcase TEAM_BLUE: memcpy(&bs->teamgoal, &ctf_blueflag, sizeof(bot_goal_t)); break;\n\t\t\tdefault: return;\n\t\t}\n\t}\n\telse {\n\t\treturn;\n\t}\n\t//\n\tbs->decisionmaker = client;\n\tbs->ordered = qtrue;\n\tbs->order_time = FloatTime();\n\t//set the time to send a message to the team mates\n\tbs->teammessage_time = FloatTime() + 2 * random();\n\t//set the ltg type\n\tbs->ltgtype = LTG_DEFENDKEYAREA;\n\t//get the team goal time\n\tbs->teamgoal_time = FloatTime() + TEAM_DEFENDKEYAREA_TIME;\n\t//away from defending\n\tbs->defendaway_time = 0;\n\t//\n\tBotSetTeamStatus(bs);\n\t// remember last ordered task\n\tBotRememberLastOrderedTask(bs);\n#ifdef DEBUG\n\tBotPrintTeamGoal(bs);\n#endif //DEBUG\n}\n\n/*\n==================\nBotVoiceChat_DefendFlag\n==================\n*/\nvoid BotVoiceChat_DefendFlag(bot_state_t *bs, int client, int mode) {\n\tBotVoiceChat_Defend(bs, client, mode);\n}\n\n/*\n==================\nBotVoiceChat_Patrol\n==================\n*/\nvoid BotVoiceChat_Patrol(bot_state_t *bs, int client, int mode) {\n\t//\n\tbs->decisionmaker = client;\n\t//\n\tbs->ltgtype = 0;\n\tbs->lead_time = 0;\n\tbs->lastgoal_ltgtype = 0;\n\t//\n\tBotAI_BotInitialChat(bs, \"dismissed\", NULL);\n\ttrap_BotEnterChat(bs->cs, client, CHAT_TELL);\n\tBotVoiceChatOnly(bs, -1, VOICECHAT_ONPATROL);\n\t//\n\tBotSetTeamStatus(bs);\n#ifdef DEBUG\n\tBotPrintTeamGoal(bs);\n#endif //DEBUG\n}\n\n/*\n==================\nBotVoiceChat_Camp\n==================\n*/\nvoid BotVoiceChat_Camp(bot_state_t *bs, int client, int mode) {\n\tint areanum;\n\taas_entityinfo_t entinfo;\n\tchar netname[MAX_NETNAME];\n\n\t//\n\tbs->teamgoal.entitynum = -1;\n\tBotEntityInfo(client, &entinfo);\n\t//if info is valid (in PVS)\n\tif (entinfo.valid) {\n\t\tareanum = BotPointAreaNum(entinfo.origin);\n\t\tif (areanum) { // && trap_AAS_AreaReachability(areanum)) {\n\t\t\t//NOTE: just assume the bot knows where the person is\n\t\t\t//if (BotEntityVisible(bs->entitynum, bs->eye, bs->viewangles, 360, client)) {\n\t\t\t\tbs->teamgoal.entitynum = client;\n\t\t\t\tbs->teamgoal.areanum = areanum;\n\t\t\t\tVectorCopy(entinfo.origin, bs->teamgoal.origin);\n\t\t\t\tVectorSet(bs->teamgoal.mins, -8, -8, -8);\n\t\t\t\tVectorSet(bs->teamgoal.maxs, 8, 8, 8);\n\t\t\t//}\n\t\t}\n\t}\n\t//if the other is not visible\n\tif (bs->teamgoal.entitynum < 0) {\n\t\tBotAI_BotInitialChat(bs, \"whereareyou\", EasyClientName(client, netname, sizeof(netname)), NULL);\n\t\ttrap_BotEnterChat(bs->cs, client, CHAT_TELL);\n\t\treturn;\n\t}\n\t//\n\tbs->decisionmaker = client;\n\tbs->ordered = qtrue;\n\tbs->order_time = FloatTime();\n\t//set the time to send a message to the team mates\n\tbs->teammessage_time = FloatTime() + 2 * random();\n\t//set the ltg type\n\tbs->ltgtype = LTG_CAMPORDER;\n\t//get the team goal time\n\tbs->teamgoal_time = FloatTime() + TEAM_CAMP_TIME;\n\t//the teammate that requested the camping\n\tbs->teammate = client;\n\t//not arrived yet\n\tbs->arrive_time = 0;\n\t//\n\tBotSetTeamStatus(bs);\n\t// remember last ordered task\n\tBotRememberLastOrderedTask(bs);\n#ifdef DEBUG\n\tBotPrintTeamGoal(bs);\n#endif //DEBUG\n}\n\n/*\n==================\nBotVoiceChat_FollowMe\n==================\n*/\nvoid BotVoiceChat_FollowMe(bot_state_t *bs, int client, int mode) {\n\tint areanum;\n\taas_entityinfo_t entinfo;\n\tchar netname[MAX_NETNAME];\n\n\tbs->teamgoal.entitynum = -1;\n\tBotEntityInfo(client, &entinfo);\n\t//if info is valid (in PVS)\n\tif (entinfo.valid) {\n\t\tareanum = BotPointAreaNum(entinfo.origin);\n\t\tif (areanum) { // && trap_AAS_AreaReachability(areanum)) {\n\t\t\tbs->teamgoal.entitynum = client;\n\t\t\tbs->teamgoal.areanum = areanum;\n\t\t\tVectorCopy(entinfo.origin, bs->teamgoal.origin);\n\t\t\tVectorSet(bs->teamgoal.mins, -8, -8, -8);\n\t\t\tVectorSet(bs->teamgoal.maxs, 8, 8, 8);\n\t\t}\n\t}\n\t//if the other is not visible\n\tif (bs->teamgoal.entitynum < 0) {\n\t\tBotAI_BotInitialChat(bs, \"whereareyou\", EasyClientName(client, netname, sizeof(netname)), NULL);\n\t\ttrap_BotEnterChat(bs->cs, client, CHAT_TELL);\n\t\treturn;\n\t}\n\t//\n\tbs->decisionmaker = client;\n\tbs->ordered = qtrue;\n\tbs->order_time = FloatTime();\n\t//the team mate\n\tbs->teammate = client;\n\t//last time the team mate was assumed visible\n\tbs->teammatevisible_time = FloatTime();\n\t//set the time to send a message to the team mates\n\tbs->teammessage_time = FloatTime() + 2 * random();\n\t//get the team goal time\n\tbs->teamgoal_time = FloatTime() + TEAM_ACCOMPANY_TIME;\n\t//set the ltg type\n\tbs->ltgtype = LTG_TEAMACCOMPANY;\n\tbs->formation_dist = 3.5 * 32;\t\t//3.5 meter\n\tbs->arrive_time = 0;\n\t//\n\tBotSetTeamStatus(bs);\n\t// remember last ordered task\n\tBotRememberLastOrderedTask(bs);\n#ifdef DEBUG\n\tBotPrintTeamGoal(bs);\n#endif //DEBUG\n}\n\n/*\n==================\nBotVoiceChat_FollowFlagCarrier\n==================\n*/\nvoid BotVoiceChat_FollowFlagCarrier(bot_state_t *bs, int client, int mode) {\n\tint carrier;\n\n\tcarrier = BotTeamFlagCarrier(bs);\n\tif (carrier >= 0)\n\t\tBotVoiceChat_FollowMe(bs, carrier, mode);\n#ifdef DEBUG\n\tBotPrintTeamGoal(bs);\n#endif //DEBUG\n}\n\n/*\n==================\nBotVoiceChat_ReturnFlag\n==================\n*/\nvoid BotVoiceChat_ReturnFlag(bot_state_t *bs, int client, int mode) {\n\t//if not in CTF mode\n\tif (\n\t\tgametype != GT_CTF\n#ifdef MISSIONPACK\n\t\t&& gametype != GT_1FCTF\n#endif\n\t\t) {\n\t\treturn;\n\t}\n\t//\n\tbs->decisionmaker = client;\n\tbs->ordered = qtrue;\n\tbs->order_time = FloatTime();\n\t//set the time to send a message to the team mates\n\tbs->teammessage_time = FloatTime() + 2 * random();\n\t//set the ltg type\n\tbs->ltgtype = LTG_RETURNFLAG;\n\t//set the team goal time\n\tbs->teamgoal_time = FloatTime() + CTF_RETURNFLAG_TIME;\n\tbs->rushbaseaway_time = 0;\n\tBotSetTeamStatus(bs);\n#ifdef DEBUG\n\tBotPrintTeamGoal(bs);\n#endif //DEBUG\n}\n\n/*\n==================\nBotVoiceChat_StartLeader\n==================\n*/\nvoid BotVoiceChat_StartLeader(bot_state_t *bs, int client, int mode) {\n\tClientName(client, bs->teamleader, sizeof(bs->teamleader));\n}\n\n/*\n==================\nBotVoiceChat_StopLeader\n==================\n*/\nvoid BotVoiceChat_StopLeader(bot_state_t *bs, int client, int mode) {\n\tchar netname[MAX_MESSAGE_SIZE];\n\n\tif (!Q_stricmp(bs->teamleader, ClientName(client, netname, sizeof(netname)))) {\n\t\tbs->teamleader[0] = '\\0';\n\t\tnotleader[client] = qtrue;\n\t}\n}\n\n/*\n==================\nBotVoiceChat_WhoIsLeader\n==================\n*/\nvoid BotVoiceChat_WhoIsLeader(bot_state_t *bs, int client, int mode) {\n\tchar netname[MAX_MESSAGE_SIZE];\n\n\tif (!TeamPlayIsOn()) return;\n\n\tClientName(bs->client, netname, sizeof(netname));\n\t//if this bot IS the team leader\n\tif (!Q_stricmp(netname, bs->teamleader)) {\n\t\tBotAI_BotInitialChat(bs, \"iamteamleader\", NULL);\n\t\ttrap_BotEnterChat(bs->cs, 0, CHAT_TEAM);\n\t\tBotVoiceChatOnly(bs, -1, VOICECHAT_STARTLEADER);\n\t}\n}\n\n/*\n==================\nBotVoiceChat_WantOnDefense\n==================\n*/\nvoid BotVoiceChat_WantOnDefense(bot_state_t *bs, int client, int mode) {\n\tchar netname[MAX_NETNAME];\n\tint preference;\n\n\tpreference = BotGetTeamMateTaskPreference(bs, client);\n\tpreference &= ~TEAMTP_ATTACKER;\n\tpreference |= TEAMTP_DEFENDER;\n\tBotSetTeamMateTaskPreference(bs, client, preference);\n\t//\n\tEasyClientName(client, netname, sizeof(netname));\n\tBotAI_BotInitialChat(bs, \"keepinmind\", netname, NULL);\n\ttrap_BotEnterChat(bs->cs, client, CHAT_TELL);\n\tBotVoiceChatOnly(bs, client, VOICECHAT_YES);\n\ttrap_EA_Action(bs->client, ACTION_AFFIRMATIVE);\n}\n\n/*\n==================\nBotVoiceChat_WantOnOffense\n==================\n*/\nvoid BotVoiceChat_WantOnOffense(bot_state_t *bs, int client, int mode) {\n\tchar netname[MAX_NETNAME];\n\tint preference;\n\n\tpreference = BotGetTeamMateTaskPreference(bs, client);\n\tpreference &= ~TEAMTP_DEFENDER;\n\tpreference |= TEAMTP_ATTACKER;\n\tBotSetTeamMateTaskPreference(bs, client, preference);\n\t//\n\tEasyClientName(client, netname, sizeof(netname));\n\tBotAI_BotInitialChat(bs, \"keepinmind\", netname, NULL);\n\ttrap_BotEnterChat(bs->cs, client, CHAT_TELL);\n\tBotVoiceChatOnly(bs, client, VOICECHAT_YES);\n\ttrap_EA_Action(bs->client, ACTION_AFFIRMATIVE);\n}\n\nvoid BotVoiceChat_Dummy(bot_state_t *bs, int client, int mode) {\n}\n\nvoiceCommand_t voiceCommands[] = {\n\t{VOICECHAT_GETFLAG, BotVoiceChat_GetFlag},\n\t{VOICECHAT_OFFENSE, BotVoiceChat_Offense },\n\t{VOICECHAT_DEFEND, BotVoiceChat_Defend },\n\t{VOICECHAT_DEFENDFLAG, BotVoiceChat_DefendFlag },\n\t{VOICECHAT_PATROL, BotVoiceChat_Patrol },\n\t{VOICECHAT_CAMP, BotVoiceChat_Camp },\n\t{VOICECHAT_FOLLOWME, BotVoiceChat_FollowMe },\n\t{VOICECHAT_FOLLOWFLAGCARRIER, BotVoiceChat_FollowFlagCarrier },\n\t{VOICECHAT_RETURNFLAG, BotVoiceChat_ReturnFlag },\n\t{VOICECHAT_STARTLEADER, BotVoiceChat_StartLeader },\n\t{VOICECHAT_STOPLEADER, BotVoiceChat_StopLeader },\n\t{VOICECHAT_WHOISLEADER, BotVoiceChat_WhoIsLeader },\n\t{VOICECHAT_WANTONDEFENSE, BotVoiceChat_WantOnDefense },\n\t{VOICECHAT_WANTONOFFENSE, BotVoiceChat_WantOnOffense },\n\t{NULL, BotVoiceChat_Dummy}\n};\n\nint BotVoiceChatCommand(bot_state_t *bs, int mode, char *voiceChat) {\n\tint i, voiceOnly, clientNum, color;\n\tchar *ptr, buf[MAX_MESSAGE_SIZE], *cmd;\n\n\tif (!TeamPlayIsOn()) {\n\t\treturn qfalse;\n\t}\n\n\tif ( mode == SAY_ALL ) {\n\t\treturn qfalse;\t// don't do anything with voice chats to everyone\n\t}\n\n\tQ_strncpyz(buf, voiceChat, sizeof(buf));\n\tcmd = buf;\n\tfor (ptr = cmd; *cmd && *cmd > ' '; cmd++);\n\twhile (*cmd && *cmd <= ' ') *cmd++ = '\\0';\n\tvoiceOnly = atoi(ptr);\n\tfor (ptr = cmd; *cmd && *cmd > ' '; cmd++);\n\twhile (*cmd && *cmd <= ' ') *cmd++ = '\\0';\n\tclientNum = atoi(ptr);\n\tfor (ptr = cmd; *cmd && *cmd > ' '; cmd++);\n\twhile (*cmd && *cmd <= ' ') *cmd++ = '\\0';\n\tcolor = atoi(ptr);\n\n\tif (!BotSameTeam(bs, clientNum)) {\n\t\treturn qfalse;\n\t}\n\n\tfor (i = 0; voiceCommands[i].cmd; i++) {\n\t\tif (!Q_stricmp(cmd, voiceCommands[i].cmd)) {\n\t\t\tvoiceCommands[i].func(bs, clientNum, mode);\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\treturn qfalse;\n}\n"
  },
  {
    "path": "code/game/ai_vcmd.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n/*****************************************************************************\n * name:\t\tai_vcmd.h\n *\n * desc:\t\tQuake3 bot AI\n *\n * $Archive: /source/code/botai/ai_vcmd.c $\n *\n *****************************************************************************/\n\nint BotVoiceChatCommand(bot_state_t *bs, int mode, char *voicechat);\nvoid BotVoiceChat_Defend(bot_state_t *bs, int client, int mode);\n\n\n"
  },
  {
    "path": "code/game/be_aas.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n/*****************************************************************************\n * name:\t\tbe_aas.h\n *\n * desc:\t\tArea Awareness System, stuff exported to the AI\n *\n * $Archive: /source/code/botlib/be_aas.h $\n *\n *****************************************************************************/\n\n#ifndef MAX_STRINGFIELD\n#define MAX_STRINGFIELD\t\t\t\t80\n#endif\n\n//travel flags\n#define TFL_INVALID\t\t\t\t0x00000001\t//traveling temporary not possible\n#define TFL_WALK\t\t\t\t0x00000002\t//walking\n#define TFL_CROUCH\t\t\t\t0x00000004\t//crouching\n#define TFL_BARRIERJUMP\t\t\t0x00000008\t//jumping onto a barrier\n#define TFL_JUMP\t\t\t\t0x00000010\t//jumping\n#define TFL_LADDER\t\t\t\t0x00000020\t//climbing a ladder\n#define TFL_WALKOFFLEDGE\t\t0x00000080\t//walking of a ledge\n#define TFL_SWIM\t\t\t\t0x00000100\t//swimming\n#define TFL_WATERJUMP\t\t\t0x00000200\t//jumping out of the water\n#define TFL_TELEPORT\t\t\t0x00000400\t//teleporting\n#define TFL_ELEVATOR\t\t\t0x00000800\t//elevator\n#define TFL_ROCKETJUMP\t\t\t0x00001000\t//rocket jumping\n#define TFL_BFGJUMP\t\t\t\t0x00002000\t//bfg jumping\n#define TFL_GRAPPLEHOOK\t\t\t0x00004000\t//grappling hook\n#define TFL_DOUBLEJUMP\t\t\t0x00008000\t//double jump\n#define TFL_RAMPJUMP\t\t\t0x00010000\t//ramp jump\n#define TFL_STRAFEJUMP\t\t\t0x00020000\t//strafe jump\n#define TFL_JUMPPAD\t\t\t\t0x00040000\t//jump pad\n#define TFL_AIR\t\t\t\t\t0x00080000\t//travel through air\n#define TFL_WATER\t\t\t\t0x00100000\t//travel through water\n#define TFL_SLIME\t\t\t\t0x00200000\t//travel through slime\n#define TFL_LAVA\t\t\t\t0x00400000\t//travel through lava\n#define TFL_DONOTENTER\t\t\t0x00800000\t//travel through donotenter area\n#define TFL_FUNCBOB\t\t\t\t0x01000000\t//func bobbing\n#define TFL_FLIGHT\t\t\t\t0x02000000\t//flight\n#define TFL_BRIDGE\t\t\t\t0x04000000\t//move over a bridge\n//\n#define TFL_NOTTEAM1\t\t\t0x08000000\t//not team 1\n#define TFL_NOTTEAM2\t\t\t0x10000000\t//not team 2\n\n//default travel flags\n#define TFL_DEFAULT\tTFL_WALK|TFL_CROUCH|TFL_BARRIERJUMP|\\\n\tTFL_JUMP|TFL_LADDER|\\\n\tTFL_WALKOFFLEDGE|TFL_SWIM|TFL_WATERJUMP|\\\n\tTFL_TELEPORT|TFL_ELEVATOR|\\\n\tTFL_AIR|TFL_WATER|TFL_JUMPPAD|TFL_FUNCBOB\n\ntypedef enum\n{\n\tSOLID_NOT,\t\t\t// no interaction with other objects\n\tSOLID_TRIGGER,\t\t// only touch when inside, after moving\n\tSOLID_BBOX,\t\t\t// touch on edge\n\tSOLID_BSP\t\t\t// bsp clip, touch on edge\n} solid_t;\n\n//a trace is returned when a box is swept through the AAS world\ntypedef struct aas_trace_s\n{\n\tqboolean\tstartsolid;\t// if true, the initial point was in a solid area\n\tfloat\t\tfraction;\t// time completed, 1.0 = didn't hit anything\n\tvec3_t\t\tendpos;\t\t// final position\n\tint\t\t\tent;\t\t// entity blocking the trace\n\tint\t\t\tlastarea;\t// last area the trace was in (zero if none)\n\tint\t\t\tarea;\t\t// area blocking the trace (zero if none)\n\tint\t\t\tplanenum;\t// number of the plane that was hit\n} aas_trace_t;\n\n/* Defined in botlib.h\n\n//bsp_trace_t hit surface\ntypedef struct bsp_surface_s\n{\n\tchar name[16];\n\tint flags;\n\tint value;\n} bsp_surface_t;\n\n//a trace is returned when a box is swept through the BSP world\ntypedef struct bsp_trace_s\n{\n\tqboolean\t\tallsolid;\t// if true, plane is not valid\n\tqboolean\t\tstartsolid;\t// if true, the initial point was in a solid area\n\tfloat\t\t\tfraction;\t// time completed, 1.0 = didn't hit anything\n\tvec3_t\t\t\tendpos;\t\t// final position\n\tcplane_t\t\tplane;\t\t// surface normal at impact\n\tfloat\t\t\texp_dist;\t// expanded plane distance\n\tint\t\t\t\tsidenum;\t// number of the brush side hit\n\tbsp_surface_t\tsurface;\t// hit surface\n\tint\t\t\t\tcontents;\t// contents on other side of surface hit\n\tint\t\t\t\tent;\t\t// number of entity hit\n} bsp_trace_t;\n//\n*/\n\n//entity info\ntypedef struct aas_entityinfo_s\n{\n\tint\t\tvalid;\t\t\t// true if updated this frame\n\tint\t\ttype;\t\t\t// entity type\n\tint\t\tflags;\t\t\t// entity flags\n\tfloat\tltime;\t\t\t// local time\n\tfloat\tupdate_time;\t// time between last and current update\n\tint\t\tnumber;\t\t\t// number of the entity\n\tvec3_t\torigin;\t\t\t// origin of the entity\n\tvec3_t\tangles;\t\t\t// angles of the model\n\tvec3_t\told_origin;\t\t// for lerping\n\tvec3_t\tlastvisorigin;\t// last visible origin\n\tvec3_t\tmins;\t\t\t// bounding box minimums\n\tvec3_t\tmaxs;\t\t\t// bounding box maximums\n\tint\t\tgroundent;\t\t// ground entity\n\tint\t\tsolid;\t\t\t// solid type\n\tint\t\tmodelindex;\t\t// model used\n\tint\t\tmodelindex2;\t// weapons, CTF flags, etc\n\tint\t\tframe;\t\t\t// model frame number\n\tint\t\tevent;\t\t\t// impulse events -- muzzle flashes, footsteps, etc\n\tint\t\teventParm;\t\t// even parameter\n\tint\t\tpowerups;\t\t// bit flags\n\tint\t\tweapon;\t\t\t// determines weapon and flash model, etc\n\tint\t\tlegsAnim;\t\t// mask off ANIM_TOGGLEBIT\n\tint\t\ttorsoAnim;\t\t// mask off ANIM_TOGGLEBIT\n} aas_entityinfo_t;\n\n// area info\ntypedef struct aas_areainfo_s\n{\n\tint contents;\n\tint flags;\n\tint presencetype;\n\tint cluster;\n\tvec3_t mins;\n\tvec3_t maxs;\n\tvec3_t center;\n} aas_areainfo_t;\n\n// client movement prediction stop events, stop as soon as:\n#define SE_NONE\t\t\t\t\t0\n#define SE_HITGROUND\t\t\t1\t\t// the ground is hit\n#define SE_LEAVEGROUND\t\t\t2\t\t// there's no ground\n#define SE_ENTERWATER\t\t\t4\t\t// water is entered\n#define SE_ENTERSLIME\t\t\t8\t\t// slime is entered\n#define SE_ENTERLAVA\t\t\t16\t\t// lava is entered\n#define SE_HITGROUNDDAMAGE\t\t32\t\t// the ground is hit with damage\n#define SE_GAP\t\t\t\t\t64\t\t// there's a gap\n#define SE_TOUCHJUMPPAD\t\t\t128\t\t// touching a jump pad area\n#define SE_TOUCHTELEPORTER\t\t256\t\t// touching teleporter\n#define SE_ENTERAREA\t\t\t512\t\t// the given stoparea is entered\n#define SE_HITGROUNDAREA\t\t1024\t// a ground face in the area is hit\n#define SE_HITBOUNDINGBOX\t\t2048\t// hit the specified bounding box\n#define SE_TOUCHCLUSTERPORTAL\t4096\t// touching a cluster portal\n\ntypedef struct aas_clientmove_s\n{\n\tvec3_t endpos;\t\t\t//position at the end of movement prediction\n\tint endarea;\t\t\t//area at end of movement prediction\n\tvec3_t velocity;\t\t//velocity at the end of movement prediction\n\taas_trace_t trace;\t\t//last trace\n\tint presencetype;\t\t//presence type at end of movement prediction\n\tint stopevent;\t\t\t//event that made the prediction stop\n\tint endcontents;\t\t//contents at the end of movement prediction\n\tfloat time;\t\t\t\t//time predicted ahead\n\tint frames;\t\t\t\t//number of frames predicted ahead\n} aas_clientmove_t;\n\n// alternate route goals\n#define ALTROUTEGOAL_ALL\t\t\t\t1\n#define ALTROUTEGOAL_CLUSTERPORTALS\t\t2\n#define ALTROUTEGOAL_VIEWPORTALS\t\t4\n\ntypedef struct aas_altroutegoal_s\n{\n\tvec3_t origin;\n\tint areanum;\n\tunsigned short starttraveltime;\n\tunsigned short goaltraveltime;\n\tunsigned short extratraveltime;\n} aas_altroutegoal_t;\n\n// route prediction stop events\n#define RSE_NONE\t\t\t\t0\n#define RSE_NOROUTE\t\t\t\t1\t//no route to goal\n#define RSE_USETRAVELTYPE\t\t2\t//stop as soon as on of the given travel types is used\n#define RSE_ENTERCONTENTS\t\t4\t//stop when entering the given contents\n#define RSE_ENTERAREA\t\t\t8\t//stop when entering the given area\n\ntypedef struct aas_predictroute_s\n{\n\tvec3_t endpos;\t\t\t//position at the end of movement prediction\n\tint endarea;\t\t\t//area at end of movement prediction\n\tint stopevent;\t\t\t//event that made the prediction stop\n\tint endcontents;\t\t//contents at the end of movement prediction\n\tint endtravelflags;\t\t//end travel flags\n\tint numareas;\t\t\t//number of areas predicted ahead\n\tint time;\t\t\t\t//time predicted ahead (in hundreth of a sec)\n} aas_predictroute_t;\n"
  },
  {
    "path": "code/game/be_ai_char.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n/*****************************************************************************\n * name:\t\tbe_ai_char.h\n *\n * desc:\t\tbot characters\n *\n * $Archive: /source/code/botlib/be_ai_char.h $\n *\n *****************************************************************************/\n\n//loads a bot character from a file\nint BotLoadCharacter(char *charfile, float skill);\n//frees a bot character\nvoid BotFreeCharacter(int character);\n//returns a float characteristic\nfloat Characteristic_Float(int character, int index);\n//returns a bounded float characteristic\nfloat Characteristic_BFloat(int character, int index, float min, float max);\n//returns an integer characteristic\nint Characteristic_Integer(int character, int index);\n//returns a bounded integer characteristic\nint Characteristic_BInteger(int character, int index, int min, int max);\n//returns a string characteristic\nvoid Characteristic_String(int character, int index, char *buf, int size);\n//free cached bot characters\nvoid BotShutdownCharacters(void);\n"
  },
  {
    "path": "code/game/be_ai_chat.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*****************************************************************************\n * name:\t\tbe_ai_chat.h\n *\n * desc:\t\tchar AI\n *\n * $Archive: /source/code/botlib/be_ai_chat.h $\n *\n *****************************************************************************/\n\n#define MAX_MESSAGE_SIZE\t\t256\n#define MAX_CHATTYPE_NAME\t\t32\n#define MAX_MATCHVARIABLES\t\t8\n\n#define CHAT_GENDERLESS\t\t\t0\n#define CHAT_GENDERFEMALE\t\t1\n#define CHAT_GENDERMALE\t\t\t2\n\n#define CHAT_ALL\t\t\t\t\t0\n#define CHAT_TEAM\t\t\t\t\t1\n#define CHAT_TELL\t\t\t\t\t2\n\n//a console message\ntypedef struct bot_consolemessage_s\n{\n\tint handle;\n\tfloat time;\t\t\t\t\t\t\t\t\t//message time\n\tint type;\t\t\t\t\t\t\t\t\t//message type\n\tchar message[MAX_MESSAGE_SIZE];\t\t\t\t//message\n\tstruct bot_consolemessage_s *prev, *next;\t//prev and next in list\n} bot_consolemessage_t;\n\n//match variable\ntypedef struct bot_matchvariable_s\n{\n\tchar offset;\n\tint length;\n} bot_matchvariable_t;\n//returned to AI when a match is found\ntypedef struct bot_match_s\n{\n\tchar string[MAX_MESSAGE_SIZE];\n\tint type;\n\tint subtype;\n\tbot_matchvariable_t variables[MAX_MATCHVARIABLES];\n} bot_match_t;\n\n//setup the chat AI\nint BotSetupChatAI(void);\n//shutdown the chat AI\nvoid BotShutdownChatAI(void);\n//returns the handle to a newly allocated chat state\nint BotAllocChatState(void);\n//frees the chatstate\nvoid BotFreeChatState(int handle);\n//adds a console message to the chat state\nvoid BotQueueConsoleMessage(int chatstate, int type, char *message);\n//removes the console message from the chat state\nvoid BotRemoveConsoleMessage(int chatstate, int handle);\n//returns the next console message from the state\nint BotNextConsoleMessage(int chatstate, bot_consolemessage_t *cm);\n//returns the number of console messages currently stored in the state\nint BotNumConsoleMessages(int chatstate);\n//selects a chat message of the given type\nvoid BotInitialChat(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7);\n//returns the number of initial chat messages of the given type\nint BotNumInitialChats(int chatstate, char *type);\n//find and select a reply for the given message\nint BotReplyChat(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7);\n//returns the length of the currently selected chat message\nint BotChatLength(int chatstate);\n//enters the selected chat message\nvoid BotEnterChat(int chatstate, int clientto, int sendto);\n//get the chat message ready to be output\nvoid BotGetChatMessage(int chatstate, char *buf, int size);\n//checks if the first string contains the second one, returns index into first string or -1 if not found\nint StringContains(char *str1, char *str2, int casesensitive);\n//finds a match for the given string using the match templates\nint BotFindMatch(char *str, bot_match_t *match, unsigned long int context);\n//returns a variable from a match\nvoid BotMatchVariable(bot_match_t *match, int variable, char *buf, int size);\n//unify all the white spaces in the string\nvoid UnifyWhiteSpaces(char *string);\n//replace all the context related synonyms in the string\nvoid BotReplaceSynonyms(char *string, unsigned long int context);\n//loads a chat file for the chat state\nint BotLoadChatFile(int chatstate, char *chatfile, char *chatname);\n//store the gender of the bot in the chat state\nvoid BotSetChatGender(int chatstate, int gender);\n//store the bot name in the chat state\nvoid BotSetChatName(int chatstate, char *name, int client);\n\n"
  },
  {
    "path": "code/game/be_ai_gen.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n/*****************************************************************************\n * name:\t\tbe_ai_gen.h\n *\n * desc:\t\tgenetic selection\n *\n * $Archive: /source/code/botlib/be_ai_gen.h $\n *\n *****************************************************************************/\n\nint GeneticParentsAndChildSelection(int numranks, float *ranks, int *parent1, int *parent2, int *child);\n"
  },
  {
    "path": "code/game/be_ai_goal.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*****************************************************************************\n * name:\t\tbe_ai_goal.h\n *\n * desc:\t\tgoal AI\n *\n * $Archive: /source/code/botlib/be_ai_goal.h $\n *\n *****************************************************************************/\n\n#define MAX_AVOIDGOALS\t\t\t256\n#define MAX_GOALSTACK\t\t\t8\n\n#define GFL_NONE\t\t\t\t0\n#define GFL_ITEM\t\t\t\t1\n#define GFL_ROAM\t\t\t\t2\n#define GFL_DROPPED\t\t\t\t4\n\n//a bot goal\ntypedef struct bot_goal_s\n{\n\tvec3_t origin;\t\t\t\t//origin of the goal\n\tint areanum;\t\t\t\t//area number of the goal\n\tvec3_t mins, maxs;\t\t\t//mins and maxs of the goal\n\tint entitynum;\t\t\t\t//number of the goal entity\n\tint number;\t\t\t\t\t//goal number\n\tint flags;\t\t\t\t\t//goal flags\n\tint iteminfo;\t\t\t\t//item information\n} bot_goal_t;\n\n//reset the whole goal state, but keep the item weights\nvoid BotResetGoalState(int goalstate);\n//reset avoid goals\nvoid BotResetAvoidGoals(int goalstate);\n//remove the goal with the given number from the avoid goals\nvoid BotRemoveFromAvoidGoals(int goalstate, int number);\n//push a goal onto the goal stack\nvoid BotPushGoal(int goalstate, bot_goal_t *goal);\n//pop a goal from the goal stack\nvoid BotPopGoal(int goalstate);\n//empty the bot's goal stack\nvoid BotEmptyGoalStack(int goalstate);\n//dump the avoid goals\nvoid BotDumpAvoidGoals(int goalstate);\n//dump the goal stack\nvoid BotDumpGoalStack(int goalstate);\n//get the name name of the goal with the given number\nvoid BotGoalName(int number, char *name, int size);\n//get the top goal from the stack\nint BotGetTopGoal(int goalstate, bot_goal_t *goal);\n//get the second goal on the stack\nint BotGetSecondGoal(int goalstate, bot_goal_t *goal);\n//choose the best long term goal item for the bot\nint BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelflags);\n//choose the best nearby goal item for the bot\n//the item may not be further away from the current bot position than maxtime\n//also the travel time from the nearby goal towards the long term goal may not\n//be larger than the travel time towards the long term goal from the current bot position\nint BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelflags,\n\t\t\t\t\t\t\tbot_goal_t *ltg, float maxtime);\n//returns true if the bot touches the goal\nint BotTouchingGoal(vec3_t origin, bot_goal_t *goal);\n//returns true if the goal should be visible but isn't\nint BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, bot_goal_t *goal);\n//search for a goal for the given classname, the index can be used\n//as a start point for the search when multiple goals are available with that same classname\nint BotGetLevelItemGoal(int index, char *classname, bot_goal_t *goal);\n//get the next camp spot in the map\nint BotGetNextCampSpotGoal(int num, bot_goal_t *goal);\n//get the map location with the given name\nint BotGetMapLocationGoal(char *name, bot_goal_t *goal);\n//returns the avoid goal time\nfloat BotAvoidGoalTime(int goalstate, int number);\n//set the avoid goal time\nvoid BotSetAvoidGoalTime(int goalstate, int number, float avoidtime);\n//initializes the items in the level\nvoid BotInitLevelItems(void);\n//regularly update dynamic entity items (dropped weapons, flags etc.)\nvoid BotUpdateEntityItems(void);\n//interbreed the goal fuzzy logic\nvoid BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child);\n//save the goal fuzzy logic to disk\nvoid BotSaveGoalFuzzyLogic(int goalstate, char *filename);\n//mutate the goal fuzzy logic\nvoid BotMutateGoalFuzzyLogic(int goalstate, float range);\n//loads item weights for the bot\nint BotLoadItemWeights(int goalstate, char *filename);\n//frees the item weights of the bot\nvoid BotFreeItemWeights(int goalstate);\n//returns the handle of a newly allocated goal state\nint BotAllocGoalState(int client);\n//free the given goal state\nvoid BotFreeGoalState(int handle);\n//setup the goal AI\nint BotSetupGoalAI(void);\n//shut down the goal AI\nvoid BotShutdownGoalAI(void);\n"
  },
  {
    "path": "code/game/be_ai_move.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n/*****************************************************************************\n * name:\t\tbe_ai_move.h\n *\n * desc:\t\tmovement AI\n *\n * $Archive: /source/code/botlib/be_ai_move.h $\n *\n *****************************************************************************/\n\n//movement types\n#define MOVE_WALK\t\t\t\t\t\t1\n#define MOVE_CROUCH\t\t\t\t\t\t2\n#define MOVE_JUMP\t\t\t\t\t\t4\n#define MOVE_GRAPPLE\t\t\t\t\t8\n#define MOVE_ROCKETJUMP\t\t\t\t\t16\n#define MOVE_BFGJUMP\t\t\t\t\t32\n//move flags\n#define MFL_BARRIERJUMP\t\t\t\t\t1\t\t//bot is performing a barrier jump\n#define MFL_ONGROUND\t\t\t\t\t2\t\t//bot is in the ground\n#define MFL_SWIMMING\t\t\t\t\t4\t\t//bot is swimming\n#define MFL_AGAINSTLADDER\t\t\t\t8\t\t//bot is against a ladder\n#define MFL_WATERJUMP\t\t\t\t\t16\t\t//bot is waterjumping\n#define MFL_TELEPORTED\t\t\t\t\t32\t\t//bot is being teleported\n#define MFL_GRAPPLEPULL\t\t\t\t\t64\t\t//bot is being pulled by the grapple\n#define MFL_ACTIVEGRAPPLE\t\t\t\t128\t\t//bot is using the grapple hook\n#define MFL_GRAPPLERESET\t\t\t\t256\t\t//bot has reset the grapple\n#define MFL_WALK\t\t\t\t\t\t512\t\t//bot should walk slowly\n// move result flags\n#define MOVERESULT_MOVEMENTVIEW\t\t\t1\t\t//bot uses view for movement\n#define MOVERESULT_SWIMVIEW\t\t\t\t2\t\t//bot uses view for swimming\n#define MOVERESULT_WAITING\t\t\t\t4\t\t//bot is waiting for something\n#define MOVERESULT_MOVEMENTVIEWSET\t\t8\t\t//bot has set the view in movement code\n#define MOVERESULT_MOVEMENTWEAPON\t\t16\t\t//bot uses weapon for movement\n#define MOVERESULT_ONTOPOFOBSTACLE\t\t32\t\t//bot is ontop of obstacle\n#define MOVERESULT_ONTOPOF_FUNCBOB\t\t64\t\t//bot is ontop of a func_bobbing\n#define MOVERESULT_ONTOPOF_ELEVATOR\t\t128\t\t//bot is ontop of an elevator (func_plat)\n#define MOVERESULT_BLOCKEDBYAVOIDSPOT\t256\t\t//bot is blocked by an avoid spot\n//\n#define MAX_AVOIDREACH\t\t\t\t\t1\n#define MAX_AVOIDSPOTS\t\t\t\t\t32\n// avoid spot types\n#define AVOID_CLEAR\t\t\t\t\t\t0\t\t//clear all avoid spots\n#define AVOID_ALWAYS\t\t\t\t\t1\t\t//avoid always\n#define AVOID_DONTBLOCK\t\t\t\t\t2\t\t//never totally block\n// restult types\n#define RESULTTYPE_ELEVATORUP\t\t\t1\t\t//elevator is up\n#define RESULTTYPE_WAITFORFUNCBOBBING\t2\t\t//waiting for func bobbing to arrive\n#define RESULTTYPE_BADGRAPPLEPATH\t\t4\t\t//grapple path is obstructed\n#define RESULTTYPE_INSOLIDAREA\t\t\t8\t\t//stuck in solid area, this is bad\n\n//structure used to initialize the movement state\n//the or_moveflags MFL_ONGROUND, MFL_TELEPORTED and MFL_WATERJUMP come from the playerstate\ntypedef struct bot_initmove_s\n{\n\tvec3_t origin;\t\t\t\t//origin of the bot\n\tvec3_t velocity;\t\t\t//velocity of the bot\n\tvec3_t viewoffset;\t\t\t//view offset\n\tint entitynum;\t\t\t\t//entity number of the bot\n\tint client;\t\t\t\t\t//client number of the bot\n\tfloat thinktime;\t\t\t//time the bot thinks\n\tint presencetype;\t\t\t//presencetype of the bot\n\tvec3_t viewangles;\t\t\t//view angles of the bot\n\tint or_moveflags;\t\t\t//values ored to the movement flags\n} bot_initmove_t;\n\n//NOTE: the ideal_viewangles are only valid if MFL_MOVEMENTVIEW is set\ntypedef struct bot_moveresult_s\n{\n\tint failure;\t\t\t\t//true if movement failed all together\n\tint type;\t\t\t\t\t//failure or blocked type\n\tint blocked;\t\t\t\t//true if blocked by an entity\n\tint blockentity;\t\t\t//entity blocking the bot\n\tint traveltype;\t\t\t\t//last executed travel type\n\tint flags;\t\t\t\t\t//result flags\n\tint weapon;\t\t\t\t\t//weapon used for movement\n\tvec3_t movedir;\t\t\t\t//movement direction\n\tvec3_t ideal_viewangles;\t//ideal viewangles for the movement\n} bot_moveresult_t;\n\n// bk001204: from code/botlib/be_ai_move.c\n// TTimo 04/12/2001 was moved here to avoid dup defines\ntypedef struct bot_avoidspot_s\n{\n\tvec3_t origin;\n\tfloat radius;\n\tint type;\n} bot_avoidspot_t;\n\n//resets the whole move state\nvoid BotResetMoveState(int movestate);\n//moves the bot to the given goal\nvoid BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, int travelflags);\n//moves the bot in the specified direction using the specified type of movement\nint BotMoveInDirection(int movestate, vec3_t dir, float speed, int type);\n//reset avoid reachability\nvoid BotResetAvoidReach(int movestate);\n//resets the last avoid reachability\nvoid BotResetLastAvoidReach(int movestate);\n//returns a reachability area if the origin is in one\nint BotReachabilityArea(vec3_t origin, int client);\n//view target based on movement\nint BotMovementViewTarget(int movestate, bot_goal_t *goal, int travelflags, float lookahead, vec3_t target);\n//predict the position of a player based on movement towards a goal\nint BotPredictVisiblePosition(vec3_t origin, int areanum, bot_goal_t *goal, int travelflags, vec3_t target);\n//returns the handle of a newly allocated movestate\nint BotAllocMoveState(void);\n//frees the movestate with the given handle\nvoid BotFreeMoveState(int handle);\n//initialize movement state before performing any movement\nvoid BotInitMoveState(int handle, bot_initmove_t *initmove);\n//add a spot to avoid (if type == AVOID_CLEAR all spots are removed)\nvoid BotAddAvoidSpot(int movestate, vec3_t origin, float radius, int type);\n//must be called every map change\nvoid BotSetBrushModelTypes(void);\n//setup movement AI\nint BotSetupMoveAI(void);\n//shutdown movement AI\nvoid BotShutdownMoveAI(void);\n\n"
  },
  {
    "path": "code/game/be_ai_weap.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n/*****************************************************************************\n * name:\t\tbe_ai_weap.h\n *\n * desc:\t\tweapon AI\n *\n * $Archive: /source/code/botlib/be_ai_weap.h $\n *\n *****************************************************************************/\n\n//projectile flags\n#define PFL_WINDOWDAMAGE\t\t\t1\t\t//projectile damages through window\n#define PFL_RETURN\t\t\t\t\t2\t\t//set when projectile returns to owner\n//weapon flags\n#define WFL_FIRERELEASED\t\t\t1\t\t//set when projectile is fired with key-up event\n//damage types\n#define DAMAGETYPE_IMPACT\t\t\t1\t\t//damage on impact\n#define DAMAGETYPE_RADIAL\t\t\t2\t\t//radial damage\n#define DAMAGETYPE_VISIBLE\t\t\t4\t\t//damage to all entities visible to the projectile\n\ntypedef struct projectileinfo_s\n{\n\tchar name[MAX_STRINGFIELD];\n\tchar model[MAX_STRINGFIELD];\n\tint flags;\n\tfloat gravity;\n\tint damage;\n\tfloat radius;\n\tint visdamage;\n\tint damagetype;\n\tint healthinc;\n\tfloat push;\n\tfloat detonation;\n\tfloat bounce;\n\tfloat bouncefric;\n\tfloat bouncestop;\n} projectileinfo_t;\n\ntypedef struct weaponinfo_s\n{\n\tint valid;\t\t\t\t\t//true if the weapon info is valid\n\tint number;\t\t\t\t\t\t\t\t\t//number of the weapon\n\tchar name[MAX_STRINGFIELD];\n\tchar model[MAX_STRINGFIELD];\n\tint level;\n\tint weaponindex;\n\tint flags;\n\tchar projectile[MAX_STRINGFIELD];\n\tint numprojectiles;\n\tfloat hspread;\n\tfloat vspread;\n\tfloat speed;\n\tfloat acceleration;\n\tvec3_t recoil;\n\tvec3_t offset;\n\tvec3_t angleoffset;\n\tfloat extrazvelocity;\n\tint ammoamount;\n\tint ammoindex;\n\tfloat activate;\n\tfloat reload;\n\tfloat spinup;\n\tfloat spindown;\n\tprojectileinfo_t proj;\t\t\t\t\t\t//pointer to the used projectile\n} weaponinfo_t;\n\n//setup the weapon AI\nint BotSetupWeaponAI(void);\n//shut down the weapon AI\nvoid BotShutdownWeaponAI(void);\n//returns the best weapon to fight with\nint BotChooseBestFightWeapon(int weaponstate, int *inventory);\n//returns the information of the current weapon\nvoid BotGetWeaponInfo(int weaponstate, int weapon, weaponinfo_t *weaponinfo);\n//loads the weapon weights\nint BotLoadWeaponWeights(int weaponstate, char *filename);\n//returns a handle to a newly allocated weapon state\nint BotAllocWeaponState(void);\n//frees the weapon state\nvoid BotFreeWeaponState(int weaponstate);\n//resets the whole weapon state\nvoid BotResetWeaponState(int weaponstate);\n"
  },
  {
    "path": "code/game/be_ea.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n/*****************************************************************************\n * name:\t\tbe_ea.h\n *\n * desc:\t\telementary actions\n *\n * $Archive: /source/code/botlib/be_ea.h $\n *\n *****************************************************************************/\n\n//ClientCommand elementary actions\nvoid EA_Say(int client, char *str);\nvoid EA_SayTeam(int client, char *str);\nvoid EA_Command(int client, char *command );\n\nvoid EA_Action(int client, int action);\nvoid EA_Crouch(int client);\nvoid EA_Walk(int client);\nvoid EA_MoveUp(int client);\nvoid EA_MoveDown(int client);\nvoid EA_MoveForward(int client);\nvoid EA_MoveBack(int client);\nvoid EA_MoveLeft(int client);\nvoid EA_MoveRight(int client);\nvoid EA_Attack(int client);\nvoid EA_Respawn(int client);\nvoid EA_Talk(int client);\nvoid EA_Gesture(int client);\nvoid EA_Use(int client);\n\n//regular elementary actions\nvoid EA_SelectWeapon(int client, int weapon);\nvoid EA_Jump(int client);\nvoid EA_DelayedJump(int client);\nvoid EA_Move(int client, vec3_t dir, float speed);\nvoid EA_View(int client, vec3_t viewangles);\n\n//send regular input to the server\nvoid EA_EndRegular(int client, float thinktime);\nvoid EA_GetInput(int client, float thinktime, bot_input_t *input);\nvoid EA_ResetInput(int client);\n//setup and shutdown routines\nint EA_Setup(void);\nvoid EA_Shutdown(void);\n"
  },
  {
    "path": "code/game/bg_lib.c",
    "content": "//\n//\n// bg_lib,c -- standard C library replacement routines used by code\n// compiled for the virtual machine\n\n#include \"q_shared.h\"\n\n/*-\n * Copyright (c) 1992, 1993\n *\tThe Regents of the University of California.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *\tThis product includes software developed by the University of\n *\tCalifornia, Berkeley and its contributors.\n * 4. Neither the name of the University nor the names of its contributors\n *    may be used to endorse or promote products derived from this software\n *    without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n */\n\n#if defined(LIBC_SCCS) && !defined(lint)\n#if 0\nstatic char sccsid[] = \"@(#)qsort.c\t8.1 (Berkeley) 6/4/93\";\n#endif\nstatic const char rcsid[] =\n#endif /* LIBC_SCCS and not lint */\n\n// bk001127 - needed for DLL's\n#if !defined( Q3_VM )\ntypedef int\t\t cmp_t(const void *, const void *);\n#endif\n\nstatic char* med3(char *, char *, char *, cmp_t *);\nstatic void\t swapfunc(char *, char *, int, int);\n\n#ifndef min\n#define min(a, b)\t(a) < (b) ? a : b\n#endif\n\n/*\n * Qsort routine from Bentley & McIlroy's \"Engineering a Sort Function\".\n */\n#define swapcode(TYPE, parmi, parmj, n) { \t\t\\\n\tlong i = (n) / sizeof (TYPE); \t\t\t\\\n\tregister TYPE *pi = (TYPE *) (parmi); \t\t\\\n\tregister TYPE *pj = (TYPE *) (parmj); \t\t\\\n\tdo { \t\t\t\t\t\t\\\n\t\tregister TYPE\tt = *pi;\t\t\\\n\t\t*pi++ = *pj;\t\t\t\t\\\n\t\t*pj++ = t;\t\t\t\t\\\n        } while (--i > 0);\t\t\t\t\\\n}\n\n#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \\\n\tes % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;\n\nstatic void\nswapfunc(a, b, n, swaptype)\n\tchar *a, *b;\n\tint n, swaptype;\n{\n\tif(swaptype <= 1)\n\t\tswapcode(long, a, b, n)\n\telse\n\t\tswapcode(char, a, b, n)\n}\n\n#define swap(a, b)\t\t\t\t\t\\\n\tif (swaptype == 0) {\t\t\t\t\\\n\t\tlong t = *(long *)(a);\t\t\t\\\n\t\t*(long *)(a) = *(long *)(b);\t\t\\\n\t\t*(long *)(b) = t;\t\t\t\\\n\t} else\t\t\t\t\t\t\\\n\t\tswapfunc(a, b, es, swaptype)\n\n#define vecswap(a, b, n) \tif ((n) > 0) swapfunc(a, b, n, swaptype)\n\nstatic char *\nmed3(a, b, c, cmp)\n\tchar *a, *b, *c;\n\tcmp_t *cmp;\n{\n\treturn cmp(a, b) < 0 ?\n\t       (cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a ))\n              :(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c ));\n}\n\nvoid\nqsort(a, n, es, cmp)\n\tvoid *a;\n\tsize_t n, es;\n\tcmp_t *cmp;\n{\n\tchar *pa, *pb, *pc, *pd, *pl, *pm, *pn;\n\tint d, r, swaptype, swap_cnt;\n\nloop:\tSWAPINIT(a, es);\n\tswap_cnt = 0;\n\tif (n < 7) {\n\t\tfor (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)\n\t\t\tfor (pl = pm; pl > (char *)a && cmp(pl - es, pl) > 0;\n\t\t\t     pl -= es)\n\t\t\t\tswap(pl, pl - es);\n\t\treturn;\n\t}\n\tpm = (char *)a + (n / 2) * es;\n\tif (n > 7) {\n\t\tpl = a;\n\t\tpn = (char *)a + (n - 1) * es;\n\t\tif (n > 40) {\n\t\t\td = (n / 8) * es;\n\t\t\tpl = med3(pl, pl + d, pl + 2 * d, cmp);\n\t\t\tpm = med3(pm - d, pm, pm + d, cmp);\n\t\t\tpn = med3(pn - 2 * d, pn - d, pn, cmp);\n\t\t}\n\t\tpm = med3(pl, pm, pn, cmp);\n\t}\n\tswap(a, pm);\n\tpa = pb = (char *)a + es;\n\n\tpc = pd = (char *)a + (n - 1) * es;\n\tfor (;;) {\n\t\twhile (pb <= pc && (r = cmp(pb, a)) <= 0) {\n\t\t\tif (r == 0) {\n\t\t\t\tswap_cnt = 1;\n\t\t\t\tswap(pa, pb);\n\t\t\t\tpa += es;\n\t\t\t}\n\t\t\tpb += es;\n\t\t}\n\t\twhile (pb <= pc && (r = cmp(pc, a)) >= 0) {\n\t\t\tif (r == 0) {\n\t\t\t\tswap_cnt = 1;\n\t\t\t\tswap(pc, pd);\n\t\t\t\tpd -= es;\n\t\t\t}\n\t\t\tpc -= es;\n\t\t}\n\t\tif (pb > pc)\n\t\t\tbreak;\n\t\tswap(pb, pc);\n\t\tswap_cnt = 1;\n\t\tpb += es;\n\t\tpc -= es;\n\t}\n\tif (swap_cnt == 0) {  /* Switch to insertion sort */\n\t\tfor (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)\n\t\t\tfor (pl = pm; pl > (char *)a && cmp(pl - es, pl) > 0;\n\t\t\t     pl -= es)\n\t\t\t\tswap(pl, pl - es);\n\t\treturn;\n\t}\n\n\tpn = (char *)a + n * es;\n\tr = min(pa - (char *)a, pb - pa);\n\tvecswap(a, pb - r, r);\n\tr = min(pd - pc, pn - pd - es);\n\tvecswap(pb, pn - r, r);\n\tif ((r = pb - pa) > es)\n\t\tqsort(a, r / es, es, cmp);\n\tif ((r = pd - pc) > es) {\n\t\t/* Iterate rather than recurse to save stack space */\n\t\ta = pn - r;\n\t\tn = r / es;\n\t\tgoto loop;\n\t}\n/*\t\tqsort(pn - r, r / es, es, cmp);*/\n}\n\n//==================================================================================\n\n\n// this file is excluded from release builds because of intrinsics\n\n// bk001211 - gcc errors on compiling strcpy:  parse error before `__extension__'\n#if defined ( Q3_VM )\n\nsize_t strlen( const char *string ) {\n\tconst char\t*s;\n\n\ts = string;\n\twhile ( *s ) {\n\t\ts++;\n\t}\n\treturn s - string;\n}\n\n\nchar *strcat( char *strDestination, const char *strSource ) {\n\tchar\t*s;\n\n\ts = strDestination;\n\twhile ( *s ) {\n\t\ts++;\n\t}\n\twhile ( *strSource ) {\n\t\t*s++ = *strSource++;\n\t}\n\t*s = 0;\n\treturn strDestination;\n}\n\nchar *strcpy( char *strDestination, const char *strSource ) {\n\tchar *s;\n\n\ts = strDestination;\n\twhile ( *strSource ) {\n\t\t*s++ = *strSource++;\n\t}\n\t*s = 0;\n\treturn strDestination;\n}\n\n\nint strcmp( const char *string1, const char *string2 ) {\n\twhile ( *string1 == *string2 && *string1 && *string2 ) {\n\t\tstring1++;\n\t\tstring2++;\n\t}\n\treturn *string1 - *string2;\n}\n\n\nchar *strchr( const char *string, int c ) {\n\twhile ( *string ) {\n\t\tif ( *string == c ) {\n\t\t\treturn ( char * )string;\n\t\t}\n\t\tstring++;\n\t}\n\treturn (char *)0;\n}\n\nchar *strstr( const char *string, const char *strCharSet ) {\n\twhile ( *string ) {\n\t\tint\t\ti;\n\n\t\tfor ( i = 0 ; strCharSet[i] ; i++ ) {\n\t\t\tif ( string[i] != strCharSet[i] ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif ( !strCharSet[i] ) {\n\t\t\treturn (char *)string;\n\t\t}\n\t\tstring++;\n\t}\n\treturn (char *)0;\n}\n#endif // bk001211\n\n// bk001120 - presumably needed for Mac\n//#if !defined(_MSC_VER) && !defined(__linux__)\n// bk001127 - undid undo\n#if defined ( Q3_VM )\nint tolower( int c ) {\n\tif ( c >= 'A' && c <= 'Z' ) {\n\t\tc += 'a' - 'A';\n\t}\n\treturn c;\n}\n\n\nint toupper( int c ) {\n\tif ( c >= 'a' && c <= 'z' ) {\n\t\tc += 'A' - 'a';\n\t}\n\treturn c;\n}\n\n#endif\n//#ifndef _MSC_VER\n\nvoid *memmove( void *dest, const void *src, size_t count ) {\n\tint\t\ti;\n\n\tif ( dest > src ) {\n\t\tfor ( i = count-1 ; i >= 0 ; i-- ) {\n\t\t\t((char *)dest)[i] = ((char *)src)[i];\n\t\t}\n\t} else {\n\t\tfor ( i = 0 ; i < count ; i++ ) {\n\t\t\t((char *)dest)[i] = ((char *)src)[i];\n\t\t}\n\t}\n\treturn dest;\n}\n\n\n#if 0\n\ndouble floor( double x ) {\n\treturn (int)(x + 0x40000000) - 0x40000000;\n}\n\nvoid *memset( void *dest, int c, size_t count ) {\n\twhile ( count-- ) {\n\t\t((char *)dest)[count] = c;\n\t}\n\treturn dest;\n}\n\nvoid *memcpy( void *dest, const void *src, size_t count ) {\n\twhile ( count-- ) {\n\t\t((char *)dest)[count] = ((char *)src)[count];\n\t}\n\treturn dest;\n}\n\nchar *strncpy( char *strDest, const char *strSource, size_t count ) {\n\tchar\t*s;\n\n\ts = strDest;\n\twhile ( *strSource && count ) {\n\t\t*s++ = *strSource++;\n\t\tcount--;\n\t}\n\twhile ( count-- ) {\n\t\t*s++ = 0;\n\t}\n\treturn strDest;\n}\n\ndouble sqrt( double x ) {\n\tfloat\ty;\n\tfloat\tdelta;\n\tfloat\tmaxError;\n\n\tif ( x <= 0 ) {\n\t\treturn 0;\n\t}\n\n\t// initial guess\n\ty = x / 2;\n\n\t// refine\n\tmaxError = x * 0.001;\n\n\tdo {\n\t\tdelta = ( y * y ) - x;\n\t\ty -= delta / ( 2 * y );\n\t} while ( delta > maxError || delta < -maxError );\n\n\treturn y;\n}\n\n\nfloat sintable[1024] = {\n0.000000,0.001534,0.003068,0.004602,0.006136,0.007670,0.009204,0.010738,\n0.012272,0.013805,0.015339,0.016873,0.018407,0.019940,0.021474,0.023008,\n0.024541,0.026075,0.027608,0.029142,0.030675,0.032208,0.033741,0.035274,\n0.036807,0.038340,0.039873,0.041406,0.042938,0.044471,0.046003,0.047535,\n0.049068,0.050600,0.052132,0.053664,0.055195,0.056727,0.058258,0.059790,\n0.061321,0.062852,0.064383,0.065913,0.067444,0.068974,0.070505,0.072035,\n0.073565,0.075094,0.076624,0.078153,0.079682,0.081211,0.082740,0.084269,\n0.085797,0.087326,0.088854,0.090381,0.091909,0.093436,0.094963,0.096490,\n0.098017,0.099544,0.101070,0.102596,0.104122,0.105647,0.107172,0.108697,\n0.110222,0.111747,0.113271,0.114795,0.116319,0.117842,0.119365,0.120888,\n0.122411,0.123933,0.125455,0.126977,0.128498,0.130019,0.131540,0.133061,\n0.134581,0.136101,0.137620,0.139139,0.140658,0.142177,0.143695,0.145213,\n0.146730,0.148248,0.149765,0.151281,0.152797,0.154313,0.155828,0.157343,\n0.158858,0.160372,0.161886,0.163400,0.164913,0.166426,0.167938,0.169450,\n0.170962,0.172473,0.173984,0.175494,0.177004,0.178514,0.180023,0.181532,\n0.183040,0.184548,0.186055,0.187562,0.189069,0.190575,0.192080,0.193586,\n0.195090,0.196595,0.198098,0.199602,0.201105,0.202607,0.204109,0.205610,\n0.207111,0.208612,0.210112,0.211611,0.213110,0.214609,0.216107,0.217604,\n0.219101,0.220598,0.222094,0.223589,0.225084,0.226578,0.228072,0.229565,\n0.231058,0.232550,0.234042,0.235533,0.237024,0.238514,0.240003,0.241492,\n0.242980,0.244468,0.245955,0.247442,0.248928,0.250413,0.251898,0.253382,\n0.254866,0.256349,0.257831,0.259313,0.260794,0.262275,0.263755,0.265234,\n0.266713,0.268191,0.269668,0.271145,0.272621,0.274097,0.275572,0.277046,\n0.278520,0.279993,0.281465,0.282937,0.284408,0.285878,0.287347,0.288816,\n0.290285,0.291752,0.293219,0.294685,0.296151,0.297616,0.299080,0.300543,\n0.302006,0.303468,0.304929,0.306390,0.307850,0.309309,0.310767,0.312225,\n0.313682,0.315138,0.316593,0.318048,0.319502,0.320955,0.322408,0.323859,\n0.325310,0.326760,0.328210,0.329658,0.331106,0.332553,0.334000,0.335445,\n0.336890,0.338334,0.339777,0.341219,0.342661,0.344101,0.345541,0.346980,\n0.348419,0.349856,0.351293,0.352729,0.354164,0.355598,0.357031,0.358463,\n0.359895,0.361326,0.362756,0.364185,0.365613,0.367040,0.368467,0.369892,\n0.371317,0.372741,0.374164,0.375586,0.377007,0.378428,0.379847,0.381266,\n0.382683,0.384100,0.385516,0.386931,0.388345,0.389758,0.391170,0.392582,\n0.393992,0.395401,0.396810,0.398218,0.399624,0.401030,0.402435,0.403838,\n0.405241,0.406643,0.408044,0.409444,0.410843,0.412241,0.413638,0.415034,\n0.416430,0.417824,0.419217,0.420609,0.422000,0.423390,0.424780,0.426168,\n0.427555,0.428941,0.430326,0.431711,0.433094,0.434476,0.435857,0.437237,\n0.438616,0.439994,0.441371,0.442747,0.444122,0.445496,0.446869,0.448241,\n0.449611,0.450981,0.452350,0.453717,0.455084,0.456449,0.457813,0.459177,\n0.460539,0.461900,0.463260,0.464619,0.465976,0.467333,0.468689,0.470043,\n0.471397,0.472749,0.474100,0.475450,0.476799,0.478147,0.479494,0.480839,\n0.482184,0.483527,0.484869,0.486210,0.487550,0.488889,0.490226,0.491563,\n0.492898,0.494232,0.495565,0.496897,0.498228,0.499557,0.500885,0.502212,\n0.503538,0.504863,0.506187,0.507509,0.508830,0.510150,0.511469,0.512786,\n0.514103,0.515418,0.516732,0.518045,0.519356,0.520666,0.521975,0.523283,\n0.524590,0.525895,0.527199,0.528502,0.529804,0.531104,0.532403,0.533701,\n0.534998,0.536293,0.537587,0.538880,0.540171,0.541462,0.542751,0.544039,\n0.545325,0.546610,0.547894,0.549177,0.550458,0.551738,0.553017,0.554294,\n0.555570,0.556845,0.558119,0.559391,0.560662,0.561931,0.563199,0.564466,\n0.565732,0.566996,0.568259,0.569521,0.570781,0.572040,0.573297,0.574553,\n0.575808,0.577062,0.578314,0.579565,0.580814,0.582062,0.583309,0.584554,\n0.585798,0.587040,0.588282,0.589521,0.590760,0.591997,0.593232,0.594466,\n0.595699,0.596931,0.598161,0.599389,0.600616,0.601842,0.603067,0.604290,\n0.605511,0.606731,0.607950,0.609167,0.610383,0.611597,0.612810,0.614022,\n0.615232,0.616440,0.617647,0.618853,0.620057,0.621260,0.622461,0.623661,\n0.624859,0.626056,0.627252,0.628446,0.629638,0.630829,0.632019,0.633207,\n0.634393,0.635578,0.636762,0.637944,0.639124,0.640303,0.641481,0.642657,\n0.643832,0.645005,0.646176,0.647346,0.648514,0.649681,0.650847,0.652011,\n0.653173,0.654334,0.655493,0.656651,0.657807,0.658961,0.660114,0.661266,\n0.662416,0.663564,0.664711,0.665856,0.667000,0.668142,0.669283,0.670422,\n0.671559,0.672695,0.673829,0.674962,0.676093,0.677222,0.678350,0.679476,\n0.680601,0.681724,0.682846,0.683965,0.685084,0.686200,0.687315,0.688429,\n0.689541,0.690651,0.691759,0.692866,0.693971,0.695075,0.696177,0.697278,\n0.698376,0.699473,0.700569,0.701663,0.702755,0.703845,0.704934,0.706021,\n0.707107,0.708191,0.709273,0.710353,0.711432,0.712509,0.713585,0.714659,\n0.715731,0.716801,0.717870,0.718937,0.720003,0.721066,0.722128,0.723188,\n0.724247,0.725304,0.726359,0.727413,0.728464,0.729514,0.730563,0.731609,\n0.732654,0.733697,0.734739,0.735779,0.736817,0.737853,0.738887,0.739920,\n0.740951,0.741980,0.743008,0.744034,0.745058,0.746080,0.747101,0.748119,\n0.749136,0.750152,0.751165,0.752177,0.753187,0.754195,0.755201,0.756206,\n0.757209,0.758210,0.759209,0.760207,0.761202,0.762196,0.763188,0.764179,\n0.765167,0.766154,0.767139,0.768122,0.769103,0.770083,0.771061,0.772036,\n0.773010,0.773983,0.774953,0.775922,0.776888,0.777853,0.778817,0.779778,\n0.780737,0.781695,0.782651,0.783605,0.784557,0.785507,0.786455,0.787402,\n0.788346,0.789289,0.790230,0.791169,0.792107,0.793042,0.793975,0.794907,\n0.795837,0.796765,0.797691,0.798615,0.799537,0.800458,0.801376,0.802293,\n0.803208,0.804120,0.805031,0.805940,0.806848,0.807753,0.808656,0.809558,\n0.810457,0.811355,0.812251,0.813144,0.814036,0.814926,0.815814,0.816701,\n0.817585,0.818467,0.819348,0.820226,0.821103,0.821977,0.822850,0.823721,\n0.824589,0.825456,0.826321,0.827184,0.828045,0.828904,0.829761,0.830616,\n0.831470,0.832321,0.833170,0.834018,0.834863,0.835706,0.836548,0.837387,\n0.838225,0.839060,0.839894,0.840725,0.841555,0.842383,0.843208,0.844032,\n0.844854,0.845673,0.846491,0.847307,0.848120,0.848932,0.849742,0.850549,\n0.851355,0.852159,0.852961,0.853760,0.854558,0.855354,0.856147,0.856939,\n0.857729,0.858516,0.859302,0.860085,0.860867,0.861646,0.862424,0.863199,\n0.863973,0.864744,0.865514,0.866281,0.867046,0.867809,0.868571,0.869330,\n0.870087,0.870842,0.871595,0.872346,0.873095,0.873842,0.874587,0.875329,\n0.876070,0.876809,0.877545,0.878280,0.879012,0.879743,0.880471,0.881197,\n0.881921,0.882643,0.883363,0.884081,0.884797,0.885511,0.886223,0.886932,\n0.887640,0.888345,0.889048,0.889750,0.890449,0.891146,0.891841,0.892534,\n0.893224,0.893913,0.894599,0.895284,0.895966,0.896646,0.897325,0.898001,\n0.898674,0.899346,0.900016,0.900683,0.901349,0.902012,0.902673,0.903332,\n0.903989,0.904644,0.905297,0.905947,0.906596,0.907242,0.907886,0.908528,\n0.909168,0.909806,0.910441,0.911075,0.911706,0.912335,0.912962,0.913587,\n0.914210,0.914830,0.915449,0.916065,0.916679,0.917291,0.917901,0.918508,\n0.919114,0.919717,0.920318,0.920917,0.921514,0.922109,0.922701,0.923291,\n0.923880,0.924465,0.925049,0.925631,0.926210,0.926787,0.927363,0.927935,\n0.928506,0.929075,0.929641,0.930205,0.930767,0.931327,0.931884,0.932440,\n0.932993,0.933544,0.934093,0.934639,0.935184,0.935726,0.936266,0.936803,\n0.937339,0.937872,0.938404,0.938932,0.939459,0.939984,0.940506,0.941026,\n0.941544,0.942060,0.942573,0.943084,0.943593,0.944100,0.944605,0.945107,\n0.945607,0.946105,0.946601,0.947094,0.947586,0.948075,0.948561,0.949046,\n0.949528,0.950008,0.950486,0.950962,0.951435,0.951906,0.952375,0.952842,\n0.953306,0.953768,0.954228,0.954686,0.955141,0.955594,0.956045,0.956494,\n0.956940,0.957385,0.957826,0.958266,0.958703,0.959139,0.959572,0.960002,\n0.960431,0.960857,0.961280,0.961702,0.962121,0.962538,0.962953,0.963366,\n0.963776,0.964184,0.964590,0.964993,0.965394,0.965793,0.966190,0.966584,\n0.966976,0.967366,0.967754,0.968139,0.968522,0.968903,0.969281,0.969657,\n0.970031,0.970403,0.970772,0.971139,0.971504,0.971866,0.972226,0.972584,\n0.972940,0.973293,0.973644,0.973993,0.974339,0.974684,0.975025,0.975365,\n0.975702,0.976037,0.976370,0.976700,0.977028,0.977354,0.977677,0.977999,\n0.978317,0.978634,0.978948,0.979260,0.979570,0.979877,0.980182,0.980485,\n0.980785,0.981083,0.981379,0.981673,0.981964,0.982253,0.982539,0.982824,\n0.983105,0.983385,0.983662,0.983937,0.984210,0.984480,0.984749,0.985014,\n0.985278,0.985539,0.985798,0.986054,0.986308,0.986560,0.986809,0.987057,\n0.987301,0.987544,0.987784,0.988022,0.988258,0.988491,0.988722,0.988950,\n0.989177,0.989400,0.989622,0.989841,0.990058,0.990273,0.990485,0.990695,\n0.990903,0.991108,0.991311,0.991511,0.991710,0.991906,0.992099,0.992291,\n0.992480,0.992666,0.992850,0.993032,0.993212,0.993389,0.993564,0.993737,\n0.993907,0.994075,0.994240,0.994404,0.994565,0.994723,0.994879,0.995033,\n0.995185,0.995334,0.995481,0.995625,0.995767,0.995907,0.996045,0.996180,\n0.996313,0.996443,0.996571,0.996697,0.996820,0.996941,0.997060,0.997176,\n0.997290,0.997402,0.997511,0.997618,0.997723,0.997825,0.997925,0.998023,\n0.998118,0.998211,0.998302,0.998390,0.998476,0.998559,0.998640,0.998719,\n0.998795,0.998870,0.998941,0.999011,0.999078,0.999142,0.999205,0.999265,\n0.999322,0.999378,0.999431,0.999481,0.999529,0.999575,0.999619,0.999660,\n0.999699,0.999735,0.999769,0.999801,0.999831,0.999858,0.999882,0.999905,\n0.999925,0.999942,0.999958,0.999971,0.999981,0.999989,0.999995,0.999999\n};\n\ndouble sin( double x ) {\n\tint\tindex;\n\tint\tquad;\n\n\tindex = 1024 * x / (M_PI * 0.5);\n\tquad = ( index >> 10 ) & 3;\n\tindex &= 1023;\n\tswitch ( quad ) {\n\tcase 0:\n\t\treturn sintable[index];\n\tcase 1:\n\t\treturn sintable[1023-index];\n\tcase 2:\n\t\treturn -sintable[index];\n\tcase 3:\n\t\treturn -sintable[1023-index];\n\t}\n\treturn 0;\n}\n\n\ndouble cos( double x ) {\n\tint\tindex;\n\tint\tquad;\n\n\tindex = 1024 * x / (M_PI * 0.5);\n\tquad = ( index >> 10 ) & 3;\n\tindex &= 1023;\n\tswitch ( quad ) {\n\tcase 3:\n\t\treturn sintable[index];\n\tcase 0:\n\t\treturn sintable[1023-index];\n\tcase 1:\n\t\treturn -sintable[index];\n\tcase 2:\n\t\treturn -sintable[1023-index];\n\t}\n\treturn 0;\n}\n\n\n/*\nvoid create_acostable( void ) {\n\tint i;\n\tFILE *fp;\n\tfloat a;\n\n\tfp = fopen(\"c:\\\\acostable.txt\", \"w\");\n\tfprintf(fp, \"float acostable[] = {\");\n\tfor (i = 0; i < 1024; i++) {\n\t\tif (!(i & 7))\n\t\t\tfprintf(fp, \"\\n\");\n\t\ta = acos( (float) -1 + i / 512 );\n\t\tfprintf(fp, \"%1.8f,\", a);\n\t}\n\tfprintf(fp, \"\\n}\\n\");\n\tfclose(fp);\n}\n*/\n\nfloat acostable[] = {\n3.14159265,3.07908248,3.05317551,3.03328655,3.01651113,3.00172442,2.98834964,2.97604422,\n2.96458497,2.95381690,2.94362719,2.93393068,2.92466119,2.91576615,2.90720289,2.89893629,\n2.89093699,2.88318015,2.87564455,2.86831188,2.86116621,2.85419358,2.84738169,2.84071962,\n2.83419760,2.82780691,2.82153967,2.81538876,2.80934770,2.80341062,2.79757211,2.79182724,\n2.78617145,2.78060056,2.77511069,2.76969824,2.76435988,2.75909250,2.75389319,2.74875926,\n2.74368816,2.73867752,2.73372510,2.72882880,2.72398665,2.71919677,2.71445741,2.70976688,\n2.70512362,2.70052613,2.69597298,2.69146283,2.68699438,2.68256642,2.67817778,2.67382735,\n2.66951407,2.66523692,2.66099493,2.65678719,2.65261279,2.64847088,2.64436066,2.64028133,\n2.63623214,2.63221238,2.62822133,2.62425835,2.62032277,2.61641398,2.61253138,2.60867440,\n2.60484248,2.60103507,2.59725167,2.59349176,2.58975488,2.58604053,2.58234828,2.57867769,\n2.57502832,2.57139977,2.56779164,2.56420354,2.56063509,2.55708594,2.55355572,2.55004409,\n2.54655073,2.54307530,2.53961750,2.53617701,2.53275354,2.52934680,2.52595650,2.52258238,\n2.51922417,2.51588159,2.51255441,2.50924238,2.50594525,2.50266278,2.49939476,2.49614096,\n2.49290115,2.48967513,2.48646269,2.48326362,2.48007773,2.47690482,2.47374472,2.47059722,\n2.46746215,2.46433933,2.46122860,2.45812977,2.45504269,2.45196720,2.44890314,2.44585034,\n2.44280867,2.43977797,2.43675809,2.43374890,2.43075025,2.42776201,2.42478404,2.42181622,\n2.41885841,2.41591048,2.41297232,2.41004380,2.40712480,2.40421521,2.40131491,2.39842379,\n2.39554173,2.39266863,2.38980439,2.38694889,2.38410204,2.38126374,2.37843388,2.37561237,\n2.37279910,2.36999400,2.36719697,2.36440790,2.36162673,2.35885335,2.35608768,2.35332964,\n2.35057914,2.34783610,2.34510044,2.34237208,2.33965094,2.33693695,2.33423003,2.33153010,\n2.32883709,2.32615093,2.32347155,2.32079888,2.31813284,2.31547337,2.31282041,2.31017388,\n2.30753373,2.30489988,2.30227228,2.29965086,2.29703556,2.29442632,2.29182309,2.28922580,\n2.28663439,2.28404881,2.28146900,2.27889490,2.27632647,2.27376364,2.27120637,2.26865460,\n2.26610827,2.26356735,2.26103177,2.25850149,2.25597646,2.25345663,2.25094195,2.24843238,\n2.24592786,2.24342836,2.24093382,2.23844420,2.23595946,2.23347956,2.23100444,2.22853408,\n2.22606842,2.22360742,2.22115104,2.21869925,2.21625199,2.21380924,2.21137096,2.20893709,\n2.20650761,2.20408248,2.20166166,2.19924511,2.19683280,2.19442469,2.19202074,2.18962092,\n2.18722520,2.18483354,2.18244590,2.18006225,2.17768257,2.17530680,2.17293493,2.17056692,\n2.16820274,2.16584236,2.16348574,2.16113285,2.15878367,2.15643816,2.15409630,2.15175805,\n2.14942338,2.14709226,2.14476468,2.14244059,2.14011997,2.13780279,2.13548903,2.13317865,\n2.13087163,2.12856795,2.12626757,2.12397047,2.12167662,2.11938600,2.11709859,2.11481435,\n2.11253326,2.11025530,2.10798044,2.10570867,2.10343994,2.10117424,2.09891156,2.09665185,\n2.09439510,2.09214129,2.08989040,2.08764239,2.08539725,2.08315496,2.08091550,2.07867884,\n2.07644495,2.07421383,2.07198545,2.06975978,2.06753681,2.06531651,2.06309887,2.06088387,\n2.05867147,2.05646168,2.05425445,2.05204979,2.04984765,2.04764804,2.04545092,2.04325628,\n2.04106409,2.03887435,2.03668703,2.03450211,2.03231957,2.03013941,2.02796159,2.02578610,\n2.02361292,2.02144204,2.01927344,2.01710710,2.01494300,2.01278113,2.01062146,2.00846399,\n2.00630870,2.00415556,2.00200457,1.99985570,1.99770895,1.99556429,1.99342171,1.99128119,\n1.98914271,1.98700627,1.98487185,1.98273942,1.98060898,1.97848051,1.97635399,1.97422942,\n1.97210676,1.96998602,1.96786718,1.96575021,1.96363511,1.96152187,1.95941046,1.95730088,\n1.95519310,1.95308712,1.95098292,1.94888050,1.94677982,1.94468089,1.94258368,1.94048818,\n1.93839439,1.93630228,1.93421185,1.93212308,1.93003595,1.92795046,1.92586659,1.92378433,\n1.92170367,1.91962459,1.91754708,1.91547113,1.91339673,1.91132385,1.90925250,1.90718266,\n1.90511432,1.90304746,1.90098208,1.89891815,1.89685568,1.89479464,1.89273503,1.89067683,\n1.88862003,1.88656463,1.88451060,1.88245794,1.88040664,1.87835668,1.87630806,1.87426076,\n1.87221477,1.87017008,1.86812668,1.86608457,1.86404371,1.86200412,1.85996577,1.85792866,\n1.85589277,1.85385809,1.85182462,1.84979234,1.84776125,1.84573132,1.84370256,1.84167495,\n1.83964848,1.83762314,1.83559892,1.83357582,1.83155381,1.82953289,1.82751305,1.82549429,\n1.82347658,1.82145993,1.81944431,1.81742973,1.81541617,1.81340362,1.81139207,1.80938151,\n1.80737194,1.80536334,1.80335570,1.80134902,1.79934328,1.79733848,1.79533460,1.79333164,\n1.79132959,1.78932843,1.78732817,1.78532878,1.78333027,1.78133261,1.77933581,1.77733985,\n1.77534473,1.77335043,1.77135695,1.76936428,1.76737240,1.76538132,1.76339101,1.76140148,\n1.75941271,1.75742470,1.75543743,1.75345090,1.75146510,1.74948002,1.74749565,1.74551198,\n1.74352900,1.74154672,1.73956511,1.73758417,1.73560389,1.73362426,1.73164527,1.72966692,\n1.72768920,1.72571209,1.72373560,1.72175971,1.71978441,1.71780969,1.71583556,1.71386199,\n1.71188899,1.70991653,1.70794462,1.70597325,1.70400241,1.70203209,1.70006228,1.69809297,\n1.69612416,1.69415584,1.69218799,1.69022062,1.68825372,1.68628727,1.68432127,1.68235571,\n1.68039058,1.67842588,1.67646160,1.67449772,1.67253424,1.67057116,1.66860847,1.66664615,\n1.66468420,1.66272262,1.66076139,1.65880050,1.65683996,1.65487975,1.65291986,1.65096028,\n1.64900102,1.64704205,1.64508338,1.64312500,1.64116689,1.63920905,1.63725148,1.63529416,\n1.63333709,1.63138026,1.62942366,1.62746728,1.62551112,1.62355517,1.62159943,1.61964388,\n1.61768851,1.61573332,1.61377831,1.61182346,1.60986877,1.60791422,1.60595982,1.60400556,\n1.60205142,1.60009739,1.59814349,1.59618968,1.59423597,1.59228235,1.59032882,1.58837536,\n1.58642196,1.58446863,1.58251535,1.58056211,1.57860891,1.57665574,1.57470259,1.57274945,\n1.57079633,1.56884320,1.56689007,1.56493692,1.56298375,1.56103055,1.55907731,1.55712403,\n1.55517069,1.55321730,1.55126383,1.54931030,1.54735668,1.54540297,1.54344917,1.54149526,\n1.53954124,1.53758710,1.53563283,1.53367843,1.53172389,1.52976919,1.52781434,1.52585933,\n1.52390414,1.52194878,1.51999323,1.51803748,1.51608153,1.51412537,1.51216900,1.51021240,\n1.50825556,1.50629849,1.50434117,1.50238360,1.50042576,1.49846765,1.49650927,1.49455060,\n1.49259163,1.49063237,1.48867280,1.48671291,1.48475270,1.48279215,1.48083127,1.47887004,\n1.47690845,1.47494650,1.47298419,1.47102149,1.46905841,1.46709493,1.46513106,1.46316677,\n1.46120207,1.45923694,1.45727138,1.45530538,1.45333893,1.45137203,1.44940466,1.44743682,\n1.44546850,1.44349969,1.44153038,1.43956057,1.43759024,1.43561940,1.43364803,1.43167612,\n1.42970367,1.42773066,1.42575709,1.42378296,1.42180825,1.41983295,1.41785705,1.41588056,\n1.41390346,1.41192573,1.40994738,1.40796840,1.40598877,1.40400849,1.40202755,1.40004594,\n1.39806365,1.39608068,1.39409701,1.39211264,1.39012756,1.38814175,1.38615522,1.38416795,\n1.38217994,1.38019117,1.37820164,1.37621134,1.37422025,1.37222837,1.37023570,1.36824222,\n1.36624792,1.36425280,1.36225684,1.36026004,1.35826239,1.35626387,1.35426449,1.35226422,\n1.35026307,1.34826101,1.34625805,1.34425418,1.34224937,1.34024364,1.33823695,1.33622932,\n1.33422072,1.33221114,1.33020059,1.32818904,1.32617649,1.32416292,1.32214834,1.32013273,\n1.31811607,1.31609837,1.31407960,1.31205976,1.31003885,1.30801684,1.30599373,1.30396951,\n1.30194417,1.29991770,1.29789009,1.29586133,1.29383141,1.29180031,1.28976803,1.28773456,\n1.28569989,1.28366400,1.28162688,1.27958854,1.27754894,1.27550809,1.27346597,1.27142257,\n1.26937788,1.26733189,1.26528459,1.26323597,1.26118602,1.25913471,1.25708205,1.25502803,\n1.25297262,1.25091583,1.24885763,1.24679802,1.24473698,1.24267450,1.24061058,1.23854519,\n1.23647833,1.23440999,1.23234015,1.23026880,1.22819593,1.22612152,1.22404557,1.22196806,\n1.21988898,1.21780832,1.21572606,1.21364219,1.21155670,1.20946958,1.20738080,1.20529037,\n1.20319826,1.20110447,1.19900898,1.19691177,1.19481283,1.19271216,1.19060973,1.18850553,\n1.18639955,1.18429178,1.18218219,1.18007079,1.17795754,1.17584244,1.17372548,1.17160663,\n1.16948589,1.16736324,1.16523866,1.16311215,1.16098368,1.15885323,1.15672081,1.15458638,\n1.15244994,1.15031147,1.14817095,1.14602836,1.14388370,1.14173695,1.13958808,1.13743709,\n1.13528396,1.13312866,1.13097119,1.12881153,1.12664966,1.12448556,1.12231921,1.12015061,\n1.11797973,1.11580656,1.11363107,1.11145325,1.10927308,1.10709055,1.10490563,1.10271831,\n1.10052856,1.09833638,1.09614174,1.09394462,1.09174500,1.08954287,1.08733820,1.08513098,\n1.08292118,1.08070879,1.07849378,1.07627614,1.07405585,1.07183287,1.06960721,1.06737882,\n1.06514770,1.06291382,1.06067715,1.05843769,1.05619540,1.05395026,1.05170226,1.04945136,\n1.04719755,1.04494080,1.04268110,1.04041841,1.03815271,1.03588399,1.03361221,1.03133735,\n1.02905939,1.02677830,1.02449407,1.02220665,1.01991603,1.01762219,1.01532509,1.01302471,\n1.01072102,1.00841400,1.00610363,1.00378986,1.00147268,0.99915206,0.99682798,0.99450039,\n0.99216928,0.98983461,0.98749636,0.98515449,0.98280898,0.98045980,0.97810691,0.97575030,\n0.97338991,0.97102573,0.96865772,0.96628585,0.96391009,0.96153040,0.95914675,0.95675912,\n0.95436745,0.95197173,0.94957191,0.94716796,0.94475985,0.94234754,0.93993099,0.93751017,\n0.93508504,0.93265556,0.93022170,0.92778341,0.92534066,0.92289341,0.92044161,0.91798524,\n0.91552424,0.91305858,0.91058821,0.90811309,0.90563319,0.90314845,0.90065884,0.89816430,\n0.89566479,0.89316028,0.89065070,0.88813602,0.88561619,0.88309116,0.88056088,0.87802531,\n0.87548438,0.87293806,0.87038629,0.86782901,0.86526619,0.86269775,0.86012366,0.85754385,\n0.85495827,0.85236686,0.84976956,0.84716633,0.84455709,0.84194179,0.83932037,0.83669277,\n0.83405893,0.83141877,0.82877225,0.82611928,0.82345981,0.82079378,0.81812110,0.81544172,\n0.81275556,0.81006255,0.80736262,0.80465570,0.80194171,0.79922057,0.79649221,0.79375655,\n0.79101352,0.78826302,0.78550497,0.78273931,0.77996593,0.77718475,0.77439569,0.77159865,\n0.76879355,0.76598029,0.76315878,0.76032891,0.75749061,0.75464376,0.75178826,0.74892402,\n0.74605092,0.74316887,0.74027775,0.73737744,0.73446785,0.73154885,0.72862033,0.72568217,\n0.72273425,0.71977644,0.71680861,0.71383064,0.71084240,0.70784376,0.70483456,0.70181469,\n0.69878398,0.69574231,0.69268952,0.68962545,0.68654996,0.68346288,0.68036406,0.67725332,\n0.67413051,0.67099544,0.66784794,0.66468783,0.66151492,0.65832903,0.65512997,0.65191753,\n0.64869151,0.64545170,0.64219789,0.63892987,0.63564741,0.63235028,0.62903824,0.62571106,\n0.62236849,0.61901027,0.61563615,0.61224585,0.60883911,0.60541564,0.60197515,0.59851735,\n0.59504192,0.59154856,0.58803694,0.58450672,0.58095756,0.57738911,0.57380101,0.57019288,\n0.56656433,0.56291496,0.55924437,0.55555212,0.55183778,0.54810089,0.54434099,0.54055758,\n0.53675018,0.53291825,0.52906127,0.52517867,0.52126988,0.51733431,0.51337132,0.50938028,\n0.50536051,0.50131132,0.49723200,0.49312177,0.48897987,0.48480547,0.48059772,0.47635573,\n0.47207859,0.46776530,0.46341487,0.45902623,0.45459827,0.45012983,0.44561967,0.44106652,\n0.43646903,0.43182577,0.42713525,0.42239588,0.41760600,0.41276385,0.40786755,0.40291513,\n0.39790449,0.39283339,0.38769946,0.38250016,0.37723277,0.37189441,0.36648196,0.36099209,\n0.35542120,0.34976542,0.34402054,0.33818204,0.33224495,0.32620390,0.32005298,0.31378574,\n0.30739505,0.30087304,0.29421096,0.28739907,0.28042645,0.27328078,0.26594810,0.25841250,\n0.25065566,0.24265636,0.23438976,0.22582651,0.21693146,0.20766198,0.19796546,0.18777575,\n0.17700769,0.16554844,0.15324301,0.13986823,0.12508152,0.10830610,0.08841715,0.06251018,\n}\n\ndouble acos( double x ) {\n\tint index;\n\n\tif (x < -1)\n\t\tx = -1;\n\tif (x > 1)\n\t\tx = 1;\n\tindex = (float) (1.0 + x) * 511.9;\n\treturn acostable[index];\n}\n\ndouble atan2( double y, double x ) {\n\tfloat\tbase;\n\tfloat\ttemp;\n\tfloat\tdir;\n\tfloat\ttest;\n\tint\t\ti;\n\n\tif ( x < 0 ) {\n\t\tif ( y >= 0 ) {\n\t\t\t// quad 1\n\t\t\tbase = M_PI / 2;\n\t\t\ttemp = x;\n\t\t\tx = y;\n\t\t\ty = -temp;\n\t\t} else {\n\t\t\t// quad 2\n\t\t\tbase = M_PI;\n\t\t\tx = -x;\n\t\t\ty = -y;\n\t\t}\n\t} else {\n\t\tif ( y < 0 ) {\n\t\t\t// quad 3\n\t\t\tbase = 3 * M_PI / 2;\n\t\t\ttemp = x;\n\t\t\tx = -y;\n\t\t\ty = temp;\n\t\t}\n\t}\n\n\tif ( y > x ) {\n\t\tbase += M_PI/2;\n\t\ttemp = x;\n\t\tx = y;\n\t\ty = temp;\n\t\tdir = -1;\n\t} else {\n\t\tdir = 1;\n\t}\n\n\t// calcualte angle in octant 0\n\tif ( x == 0 ) {\n\t\treturn base;\n\t}\n\ty /= x;\n\n\tfor ( i = 0 ; i < 512 ; i++ ) {\n\t\ttest = sintable[i] / sintable[1023-i];\n\t\tif ( test > y ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn base + dir * i * ( M_PI/2048); \n}\n\n\n#endif\n\n#ifdef Q3_VM\n// bk001127 - guarded this tan replacement \n// ld: undefined versioned symbol name tan@@GLIBC_2.0\ndouble tan( double x ) {\n\treturn sin(x) / cos(x);\n}\n#endif\n\n\nstatic int randSeed = 0;\n\nvoid\tsrand( unsigned seed ) {\n\trandSeed = seed;\n}\n\nint\t\trand( void ) {\n\trandSeed = (69069 * randSeed + 1);\n\treturn randSeed & 0x7fff;\n}\n\ndouble atof( const char *string ) {\n\tfloat sign;\n\tfloat value;\n\tint\t\tc;\n\n\n\t// skip whitespace\n\twhile ( *string <= ' ' ) {\n\t\tif ( !*string ) {\n\t\t\treturn 0;\n\t\t}\n\t\tstring++;\n\t}\n\n\t// check sign\n\tswitch ( *string ) {\n\tcase '+':\n\t\tstring++;\n\t\tsign = 1;\n\t\tbreak;\n\tcase '-':\n\t\tstring++;\n\t\tsign = -1;\n\t\tbreak;\n\tdefault:\n\t\tsign = 1;\n\t\tbreak;\n\t}\n\n\t// read digits\n\tvalue = 0;\n\tc = string[0];\n\tif ( c != '.' ) {\n\t\tdo {\n\t\t\tc = *string++;\n\t\t\tif ( c < '0' || c > '9' ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tc -= '0';\n\t\t\tvalue = value * 10 + c;\n\t\t} while ( 1 );\n\t} else {\n\t\tstring++;\n\t}\n\n\t// check for decimal point\n\tif ( c == '.' ) {\n\t\tdouble fraction;\n\n\t\tfraction = 0.1;\n\t\tdo {\n\t\t\tc = *string++;\n\t\t\tif ( c < '0' || c > '9' ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tc -= '0';\n\t\t\tvalue += c * fraction;\n\t\t\tfraction *= 0.1;\n\t\t} while ( 1 );\n\n\t}\n\n\t// not handling 10e10 notation...\n\n\treturn value * sign;\n}\n\ndouble _atof( const char **stringPtr ) {\n\tconst char\t*string;\n\tfloat sign;\n\tfloat value;\n\tint\t\tc = '0'; // bk001211 - uninitialized use possible\n\n\tstring = *stringPtr;\n\n\t// skip whitespace\n\twhile ( *string <= ' ' ) {\n\t\tif ( !*string ) {\n\t\t\t*stringPtr = string;\n\t\t\treturn 0;\n\t\t}\n\t\tstring++;\n\t}\n\n\t// check sign\n\tswitch ( *string ) {\n\tcase '+':\n\t\tstring++;\n\t\tsign = 1;\n\t\tbreak;\n\tcase '-':\n\t\tstring++;\n\t\tsign = -1;\n\t\tbreak;\n\tdefault:\n\t\tsign = 1;\n\t\tbreak;\n\t}\n\n\t// read digits\n\tvalue = 0;\n\tif ( string[0] != '.' ) {\n\t\tdo {\n\t\t\tc = *string++;\n\t\t\tif ( c < '0' || c > '9' ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tc -= '0';\n\t\t\tvalue = value * 10 + c;\n\t\t} while ( 1 );\n\t}\n\n\t// check for decimal point\n\tif ( c == '.' ) {\n\t\tdouble fraction;\n\n\t\tfraction = 0.1;\n\t\tdo {\n\t\t\tc = *string++;\n\t\t\tif ( c < '0' || c > '9' ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tc -= '0';\n\t\t\tvalue += c * fraction;\n\t\t\tfraction *= 0.1;\n\t\t} while ( 1 );\n\n\t}\n\n\t// not handling 10e10 notation...\n\t*stringPtr = string;\n\n\treturn value * sign;\n}\n\n\n// bk001120 - presumably needed for Mac\n//#if !defined ( _MSC_VER ) && ! defined ( __linux__ )\n\n// bk001127 - undid undo\n#if defined ( Q3_VM )\nint atoi( const char *string ) {\n\tint\t\tsign;\n\tint\t\tvalue;\n\tint\t\tc;\n\n\n\t// skip whitespace\n\twhile ( *string <= ' ' ) {\n\t\tif ( !*string ) {\n\t\t\treturn 0;\n\t\t}\n\t\tstring++;\n\t}\n\n\t// check sign\n\tswitch ( *string ) {\n\tcase '+':\n\t\tstring++;\n\t\tsign = 1;\n\t\tbreak;\n\tcase '-':\n\t\tstring++;\n\t\tsign = -1;\n\t\tbreak;\n\tdefault:\n\t\tsign = 1;\n\t\tbreak;\n\t}\n\n\t// read digits\n\tvalue = 0;\n\tdo {\n\t\tc = *string++;\n\t\tif ( c < '0' || c > '9' ) {\n\t\t\tbreak;\n\t\t}\n\t\tc -= '0';\n\t\tvalue = value * 10 + c;\n\t} while ( 1 );\n\n\t// not handling 10e10 notation...\n\n\treturn value * sign;\n}\n\n\nint _atoi( const char **stringPtr ) {\n\tint\t\tsign;\n\tint\t\tvalue;\n\tint\t\tc;\n\tconst char\t*string;\n\n\tstring = *stringPtr;\n\n\t// skip whitespace\n\twhile ( *string <= ' ' ) {\n\t\tif ( !*string ) {\n\t\t\treturn 0;\n\t\t}\n\t\tstring++;\n\t}\n\n\t// check sign\n\tswitch ( *string ) {\n\tcase '+':\n\t\tstring++;\n\t\tsign = 1;\n\t\tbreak;\n\tcase '-':\n\t\tstring++;\n\t\tsign = -1;\n\t\tbreak;\n\tdefault:\n\t\tsign = 1;\n\t\tbreak;\n\t}\n\n\t// read digits\n\tvalue = 0;\n\tdo {\n\t\tc = *string++;\n\t\tif ( c < '0' || c > '9' ) {\n\t\t\tbreak;\n\t\t}\n\t\tc -= '0';\n\t\tvalue = value * 10 + c;\n\t} while ( 1 );\n\n\t// not handling 10e10 notation...\n\n\t*stringPtr = string;\n\n\treturn value * sign;\n}\n\nint abs( int n ) {\n\treturn n < 0 ? -n : n;\n}\n\ndouble fabs( double x ) {\n\treturn x < 0 ? -x : x;\n}\n\n\n\n//=========================================================\n\n\n#define ALT\t\t\t0x00000001\t\t/* alternate form */\n#define HEXPREFIX\t0x00000002\t\t/* add 0x or 0X prefix */\n#define LADJUST\t\t0x00000004\t\t/* left adjustment */\n#define LONGDBL\t\t0x00000008\t\t/* long double */\n#define LONGINT\t\t0x00000010\t\t/* long integer */\n#define QUADINT\t\t0x00000020\t\t/* quad integer */\n#define SHORTINT\t0x00000040\t\t/* short integer */\n#define ZEROPAD\t\t0x00000080\t\t/* zero (as opposed to blank) pad */\n#define FPT\t\t\t0x00000100\t\t/* floating point number */\n\n#define to_digit(c)\t\t((c) - '0')\n#define is_digit(c)\t\t((unsigned)to_digit(c) <= 9)\n#define to_char(n)\t\t((n) + '0')\n\nvoid AddInt( char **buf_p, int val, int width, int flags ) {\n\tchar\ttext[32];\n\tint\t\tdigits;\n\tint\t\tsignedVal;\n\tchar\t*buf;\n\n\tdigits = 0;\n\tsignedVal = val;\n\tif ( val < 0 ) {\n\t\tval = -val;\n\t}\n\tdo {\n\t\ttext[digits++] = '0' + val % 10;\n\t\tval /= 10;\n\t} while ( val );\n\n\tif ( signedVal < 0 ) {\n\t\ttext[digits++] = '-';\n\t}\n\n\tbuf = *buf_p;\n\n\tif( !( flags & LADJUST ) ) {\n\t\twhile ( digits < width ) {\n\t\t\t*buf++ = ( flags & ZEROPAD ) ? '0' : ' ';\n\t\t\twidth--;\n\t\t}\n\t}\n\n\twhile ( digits-- ) {\n\t\t*buf++ = text[digits];\n\t\twidth--;\n\t}\n\n\tif( flags & LADJUST ) {\n\t\twhile ( width-- ) {\n\t\t\t*buf++ = ( flags & ZEROPAD ) ? '0' : ' ';\n\t\t}\n\t}\n\n\t*buf_p = buf;\n}\n\nvoid AddFloat( char **buf_p, float fval, int width, int prec ) {\n\tchar\ttext[32];\n\tint\t\tdigits;\n\tfloat\tsignedVal;\n\tchar\t*buf;\n\tint\t\tval;\n\n\t// get the sign\n\tsignedVal = fval;\n\tif ( fval < 0 ) {\n\t\tfval = -fval;\n\t}\n\n\t// write the float number\n\tdigits = 0;\n\tval = (int)fval;\n\tdo {\n\t\ttext[digits++] = '0' + val % 10;\n\t\tval /= 10;\n\t} while ( val );\n\n\tif ( signedVal < 0 ) {\n\t\ttext[digits++] = '-';\n\t}\n\n\tbuf = *buf_p;\n\n\twhile ( digits < width ) {\n\t\t*buf++ = ' ';\n\t\twidth--;\n\t}\n\n\twhile ( digits-- ) {\n\t\t*buf++ = text[digits];\n\t}\n\n\t*buf_p = buf;\n\n\tif (prec < 0)\n\t\tprec = 6;\n\t// write the fraction\n\tdigits = 0;\n\twhile (digits < prec) {\n\t\tfval -= (int) fval;\n\t\tfval *= 10.0;\n\t\tval = (int) fval;\n\t\ttext[digits++] = '0' + val % 10;\n\t}\n\n\tif (digits > 0) {\n\t\tbuf = *buf_p;\n\t\t*buf++ = '.';\n\t\tfor (prec = 0; prec < digits; prec++) {\n\t\t\t*buf++ = text[prec];\n\t\t}\n\t\t*buf_p = buf;\n\t}\n}\n\n\nvoid AddString( char **buf_p, char *string, int width, int prec ) {\n\tint\t\tsize;\n\tchar\t*buf;\n\n\tbuf = *buf_p;\n\n\tif ( string == NULL ) {\n\t\tstring = \"(null)\";\n\t\tprec = -1;\n\t}\n\n\tif ( prec >= 0 ) {\n\t\tfor( size = 0; size < prec; size++ ) {\n\t\t\tif( string[size] == '\\0' ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\tsize = strlen( string );\n\t}\n\n\twidth -= size;\n\n\twhile( size-- ) {\n\t\t*buf++ = *string++;\n\t}\n\n\twhile( width-- > 0 ) {\n\t\t*buf++ = ' ';\n\t}\n\n\t*buf_p = buf;\n}\n\n/*\nvsprintf\n\nI'm not going to support a bunch of the more arcane stuff in here\njust to keep it simpler.  For example, the '*' and '$' are not\ncurrently supported.  I've tried to make it so that it will just\nparse and ignore formats we don't support.\n*/\nint vsprintf( char *buffer, const char *fmt, va_list argptr ) {\n\tint\t\t*arg;\n\tchar\t*buf_p;\n\tchar\tch;\n\tint\t\tflags;\n\tint\t\twidth;\n\tint\t\tprec;\n\tint\t\tn;\n\tchar\tsign;\n\n\tbuf_p = buffer;\n\targ = (int *)argptr;\n\n\twhile( qtrue ) {\n\t\t// run through the format string until we hit a '%' or '\\0'\n\t\tfor ( ch = *fmt; (ch = *fmt) != '\\0' && ch != '%'; fmt++ ) {\n\t\t\t*buf_p++ = ch;\n\t\t}\n\t\tif ( ch == '\\0' ) {\n\t\t\tgoto done;\n\t\t}\n\n\t\t// skip over the '%'\n\t\tfmt++;\n\n\t\t// reset formatting state\n\t\tflags = 0;\n\t\twidth = 0;\n\t\tprec = -1;\n\t\tsign = '\\0';\n\nrflag:\n\t\tch = *fmt++;\nreswitch:\n\t\tswitch( ch ) {\n\t\tcase '-':\n\t\t\tflags |= LADJUST;\n\t\t\tgoto rflag;\n\t\tcase '.':\n\t\t\tn = 0;\n\t\t\twhile( is_digit( ( ch = *fmt++ ) ) ) {\n\t\t\t\tn = 10 * n + ( ch - '0' );\n\t\t\t}\n\t\t\tprec = n < 0 ? -1 : n;\n\t\t\tgoto reswitch;\n\t\tcase '0':\n\t\t\tflags |= ZEROPAD;\n\t\t\tgoto rflag;\n\t\tcase '1':\n\t\tcase '2':\n\t\tcase '3':\n\t\tcase '4':\n\t\tcase '5':\n\t\tcase '6':\n\t\tcase '7':\n\t\tcase '8':\n\t\tcase '9':\n\t\t\tn = 0;\n\t\t\tdo {\n\t\t\t\tn = 10 * n + ( ch - '0' );\n\t\t\t\tch = *fmt++;\n\t\t\t} while( is_digit( ch ) );\n\t\t\twidth = n;\n\t\t\tgoto reswitch;\n\t\tcase 'c':\n\t\t\t*buf_p++ = (char)*arg;\n\t\t\targ++;\n\t\t\tbreak;\n\t\tcase 'd':\n\t\tcase 'i':\n\t\t\tAddInt( &buf_p, *arg, width, flags );\n\t\t\targ++;\n\t\t\tbreak;\n\t\tcase 'f':\n\t\t\tAddFloat( &buf_p, *(double *)arg, width, prec );\n#ifdef __LCC__\n\t\t\targ += 1;\t// everything is 32 bit in my compiler\n#else\n\t\t\targ += 2;\n#endif\n\t\t\tbreak;\n\t\tcase 's':\n\t\t\tAddString( &buf_p, (char *)*arg, width, prec );\n\t\t\targ++;\n\t\t\tbreak;\n\t\tcase '%':\n\t\t\t*buf_p++ = ch;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t*buf_p++ = (char)*arg;\n\t\t\targ++;\n\t\t\tbreak;\n\t\t}\n\t}\n\ndone:\n\t*buf_p = 0;\n\treturn buf_p - buffer;\n}\n\n/* this is really crappy */\nint sscanf( const char *buffer, const char *fmt, ... ) {\n\tint\t\tcmd;\n\tint\t\t**arg;\n\tint\t\tcount;\n\n\targ = (int **)&fmt + 1;\n\tcount = 0;\n\n\twhile ( *fmt ) {\n\t\tif ( fmt[0] != '%' ) {\n\t\t\tfmt++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tcmd = fmt[1];\n\t\tfmt += 2;\n\n\t\tswitch ( cmd ) {\n\t\tcase 'i':\n\t\tcase 'd':\n\t\tcase 'u':\n\t\t\t**arg = _atoi( &buffer );\n\t\t\tbreak;\n\t\tcase 'f':\n\t\t\t*(float *)*arg = _atof( &buffer );\n\t\t\tbreak;\n\t\t}\n\t\targ++;\n\t}\n\n\treturn count;\n}\n\n#endif\n"
  },
  {
    "path": "code/game/bg_lib.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// bg_lib.h -- standard C library replacement routines used by code\n// compiled for the virtual machine\n\n// This file is NOT included on native builds\n\ntypedef int size_t;\n\ntypedef char *  va_list;\n#define _INTSIZEOF(n)   ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )\n#define va_start(ap,v)  ( ap = (va_list)&v + _INTSIZEOF(v) )\n#define va_arg(ap,t)    ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )\n#define va_end(ap)      ( ap = (va_list)0 )\n\n#define CHAR_BIT      8         /* number of bits in a char */\n#define SCHAR_MIN   (-128)      /* minimum signed char value */\n#define SCHAR_MAX     127       /* maximum signed char value */\n#define UCHAR_MAX     0xff      /* maximum unsigned char value */\n\n#define SHRT_MIN    (-32768)        /* minimum (signed) short value */\n#define SHRT_MAX      32767         /* maximum (signed) short value */\n#define USHRT_MAX     0xffff        /* maximum unsigned short value */\n#define INT_MIN     (-2147483647 - 1) /* minimum (signed) int value */\n#define INT_MAX       2147483647    /* maximum (signed) int value */\n#define UINT_MAX      0xffffffff    /* maximum unsigned int value */\n#define LONG_MIN    (-2147483647L - 1) /* minimum (signed) long value */\n#define LONG_MAX      2147483647L   /* maximum (signed) long value */\n#define ULONG_MAX     0xffffffffUL  /* maximum unsigned long value */\n\n// Misc functions\ntypedef int cmp_t(const void *, const void *);\nvoid qsort(void *a, size_t n, size_t es, cmp_t *cmp);\nvoid\tsrand( unsigned seed );\nint\t\trand( void );\n\n// String functions\nsize_t strlen( const char *string );\nchar *strcat( char *strDestination, const char *strSource );\nchar *strcpy( char *strDestination, const char *strSource );\nint strcmp( const char *string1, const char *string2 );\nchar *strchr( const char *string, int c );\nchar *strstr( const char *string, const char *strCharSet );\nchar *strncpy( char *strDest, const char *strSource, size_t count );\nint tolower( int c );\nint toupper( int c );\n\ndouble atof( const char *string );\ndouble _atof( const char **stringPtr );\nint atoi( const char *string );\nint _atoi( const char **stringPtr );\n\nint vsprintf( char *buffer, const char *fmt, va_list argptr );\nint sscanf( const char *buffer, const char *fmt, ... );\n\n// Memory functions\nvoid *memmove( void *dest, const void *src, size_t count );\nvoid *memset( void *dest, int c, size_t count );\nvoid *memcpy( void *dest, const void *src, size_t count );\n\n// Math functions\ndouble ceil( double x );\ndouble floor( double x );\ndouble sqrt( double x );\ndouble sin( double x );\ndouble cos( double x );\ndouble atan2( double y, double x );\ndouble tan( double x );\nint abs( int n );\ndouble fabs( double x );\ndouble acos( double x );\n\n"
  },
  {
    "path": "code/game/bg_local.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// bg_local.h -- local definitions for the bg (both games) files\n\n#define\tMIN_WALK_NORMAL\t0.7f\t\t// can't walk on very steep slopes\n\n#define\tSTEPSIZE\t\t18\n\n#define\tJUMP_VELOCITY\t270\n\n#define\tTIMER_LAND\t\t130\n#define\tTIMER_GESTURE\t(34*66+50)\n\n#define\tOVERCLIP\t\t1.001f\n\n// all of the locals will be zeroed before each\n// pmove, just to make damn sure we don't have\n// any differences when running on client or server\ntypedef struct {\n\tvec3_t\t\tforward, right, up;\n\tfloat\t\tframetime;\n\n\tint\t\t\tmsec;\n\n\tqboolean\twalking;\n\tqboolean\tgroundPlane;\n\ttrace_t\t\tgroundTrace;\n\n\tfloat\t\timpactSpeed;\n\n\tvec3_t\t\tprevious_origin;\n\tvec3_t\t\tprevious_velocity;\n\tint\t\t\tprevious_waterlevel;\n} pml_t;\n\nextern\tpmove_t\t\t*pm;\nextern\tpml_t\t\tpml;\n\n// movement parameters\nextern\tfloat\tpm_stopspeed;\nextern\tfloat\tpm_duckScale;\nextern\tfloat\tpm_swimScale;\nextern\tfloat\tpm_wadeScale;\n\nextern\tfloat\tpm_accelerate;\nextern\tfloat\tpm_airaccelerate;\nextern\tfloat\tpm_wateraccelerate;\nextern\tfloat\tpm_flyaccelerate;\n\nextern\tfloat\tpm_friction;\nextern\tfloat\tpm_waterfriction;\nextern\tfloat\tpm_flightfriction;\n\nextern\tint\t\tc_pmove;\n\nvoid PM_ClipVelocity( vec3_t in, vec3_t normal, vec3_t out, float overbounce );\nvoid PM_AddTouchEnt( int entityNum );\nvoid PM_AddEvent( int newEvent );\n\nqboolean\tPM_SlideMove( qboolean gravity );\nvoid\t\tPM_StepSlideMove( qboolean gravity );\n\n\n"
  },
  {
    "path": "code/game/bg_misc.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// bg_misc.c -- both games misc functions, all completely stateless\n\n#include \"q_shared.h\"\n#include \"bg_public.h\"\n\n/*QUAKED item_***** ( 0 0 0 ) (-16 -16 -16) (16 16 16) suspended\nDO NOT USE THIS CLASS, IT JUST HOLDS GENERAL INFORMATION.\nThe suspended flag will allow items to hang in the air, otherwise they are dropped to the next surface.\n\nIf an item is the target of another entity, it will not spawn in until fired.\n\nAn item fires all of its targets when it is picked up.  If the toucher can't carry it, the targets won't be fired.\n\n\"notfree\" if set to 1, don't spawn in free for all games\n\"notteam\" if set to 1, don't spawn in team games\n\"notsingle\" if set to 1, don't spawn in single player games\n\"wait\"\toverride the default wait before respawning.  -1 = never respawn automatically, which can be used with targeted spawning.\n\"random\" random number of plus or minus seconds varied from the respawn time\n\"count\" override quantity or duration on most items.\n*/\n\ngitem_t\tbg_itemlist[] = \n{\n\t{\n\t\tNULL,\n\t\tNULL,\n\t\t{ NULL,\n\t\tNULL,\n\t\t0, 0} ,\n/* icon */\t\tNULL,\n/* pickup */\tNULL,\n\t\t0,\n\t\t0,\n\t\t0,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\t// leave index 0 alone\n\n\t//\n\t// ARMOR\n\t//\n\n/*QUAKED item_armor_shard (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"item_armor_shard\", \n\t\t\"sound/misc/ar1_pkup.wav\",\n\t\t{ \"models/powerups/armor/shard.md3\", \n\t\t\"models/powerups/armor/shard_sphere.md3\",\n\t\t0, 0} ,\n/* icon */\t\t\"icons/iconr_shard\",\n/* pickup */\t\"Armor Shard\",\n\t\t5,\n\t\tIT_ARMOR,\n\t\t0,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED item_armor_combat (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"item_armor_combat\", \n\t\t\"sound/misc/ar2_pkup.wav\",\n        { \"models/powerups/armor/armor_yel.md3\",\n\t\t0, 0, 0},\n/* icon */\t\t\"icons/iconr_yellow\",\n/* pickup */\t\"Armor\",\n\t\t50,\n\t\tIT_ARMOR,\n\t\t0,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED item_armor_body (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"item_armor_body\", \n\t\t\"sound/misc/ar2_pkup.wav\",\n        { \"models/powerups/armor/armor_red.md3\",\n\t\t0, 0, 0},\n/* icon */\t\t\"icons/iconr_red\",\n/* pickup */\t\"Heavy Armor\",\n\t\t100,\n\t\tIT_ARMOR,\n\t\t0,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n\t//\n\t// health\n\t//\n/*QUAKED item_health_small (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"item_health_small\",\n\t\t\"sound/items/s_health.wav\",\n        { \"models/powerups/health/small_cross.md3\", \n\t\t\"models/powerups/health/small_sphere.md3\", \n\t\t0, 0 },\n/* icon */\t\t\"icons/iconh_green\",\n/* pickup */\t\"5 Health\",\n\t\t5,\n\t\tIT_HEALTH,\n\t\t0,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED item_health (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"item_health\",\n\t\t\"sound/items/n_health.wav\",\n        { \"models/powerups/health/medium_cross.md3\", \n\t\t\"models/powerups/health/medium_sphere.md3\", \n\t\t0, 0 },\n/* icon */\t\t\"icons/iconh_yellow\",\n/* pickup */\t\"25 Health\",\n\t\t25,\n\t\tIT_HEALTH,\n\t\t0,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED item_health_large (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"item_health_large\",\n\t\t\"sound/items/l_health.wav\",\n        { \"models/powerups/health/large_cross.md3\", \n\t\t\"models/powerups/health/large_sphere.md3\", \n\t\t0, 0 },\n/* icon */\t\t\"icons/iconh_red\",\n/* pickup */\t\"50 Health\",\n\t\t50,\n\t\tIT_HEALTH,\n\t\t0,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED item_health_mega (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"item_health_mega\",\n\t\t\"sound/items/m_health.wav\",\n        { \"models/powerups/health/mega_cross.md3\", \n\t\t\"models/powerups/health/mega_sphere.md3\", \n\t\t0, 0 },\n/* icon */\t\t\"icons/iconh_mega\",\n/* pickup */\t\"Mega Health\",\n\t\t100,\n\t\tIT_HEALTH,\n\t\t0,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n\n\t//\n\t// WEAPONS \n\t//\n\n/*QUAKED weapon_gauntlet (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"weapon_gauntlet\", \n\t\t\"sound/misc/w_pkup.wav\",\n        { \"models/weapons2/gauntlet/gauntlet.md3\",\n\t\t0, 0, 0},\n/* icon */\t\t\"icons/iconw_gauntlet\",\n/* pickup */\t\"Gauntlet\",\n\t\t0,\n\t\tIT_WEAPON,\n\t\tWP_GAUNTLET,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED weapon_shotgun (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"weapon_shotgun\", \n\t\t\"sound/misc/w_pkup.wav\",\n        { \"models/weapons2/shotgun/shotgun.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/iconw_shotgun\",\n/* pickup */\t\"Shotgun\",\n\t\t10,\n\t\tIT_WEAPON,\n\t\tWP_SHOTGUN,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED weapon_machinegun (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"weapon_machinegun\", \n\t\t\"sound/misc/w_pkup.wav\",\n        { \"models/weapons2/machinegun/machinegun.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/iconw_machinegun\",\n/* pickup */\t\"Machinegun\",\n\t\t40,\n\t\tIT_WEAPON,\n\t\tWP_MACHINEGUN,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED weapon_grenadelauncher (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"weapon_grenadelauncher\",\n\t\t\"sound/misc/w_pkup.wav\",\n        { \"models/weapons2/grenadel/grenadel.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/iconw_grenade\",\n/* pickup */\t\"Grenade Launcher\",\n\t\t10,\n\t\tIT_WEAPON,\n\t\tWP_GRENADE_LAUNCHER,\n/* precache */ \"\",\n/* sounds */ \"sound/weapons/grenade/hgrenb1a.wav sound/weapons/grenade/hgrenb2a.wav\"\n\t},\n\n/*QUAKED weapon_rocketlauncher (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"weapon_rocketlauncher\",\n\t\t\"sound/misc/w_pkup.wav\",\n        { \"models/weapons2/rocketl/rocketl.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/iconw_rocket\",\n/* pickup */\t\"Rocket Launcher\",\n\t\t10,\n\t\tIT_WEAPON,\n\t\tWP_ROCKET_LAUNCHER,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED weapon_lightning (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"weapon_lightning\", \n\t\t\"sound/misc/w_pkup.wav\",\n        { \"models/weapons2/lightning/lightning.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/iconw_lightning\",\n/* pickup */\t\"Lightning Gun\",\n\t\t100,\n\t\tIT_WEAPON,\n\t\tWP_LIGHTNING,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED weapon_railgun (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"weapon_railgun\", \n\t\t\"sound/misc/w_pkup.wav\",\n        { \"models/weapons2/railgun/railgun.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/iconw_railgun\",\n/* pickup */\t\"Railgun\",\n\t\t10,\n\t\tIT_WEAPON,\n\t\tWP_RAILGUN,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED weapon_plasmagun (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"weapon_plasmagun\", \n\t\t\"sound/misc/w_pkup.wav\",\n        { \"models/weapons2/plasma/plasma.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/iconw_plasma\",\n/* pickup */\t\"Plasma Gun\",\n\t\t50,\n\t\tIT_WEAPON,\n\t\tWP_PLASMAGUN,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED weapon_bfg (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"weapon_bfg\",\n\t\t\"sound/misc/w_pkup.wav\",\n        { \"models/weapons2/bfg/bfg.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/iconw_bfg\",\n/* pickup */\t\"BFG10K\",\n\t\t20,\n\t\tIT_WEAPON,\n\t\tWP_BFG,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED weapon_grapplinghook (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"weapon_grapplinghook\",\n\t\t\"sound/misc/w_pkup.wav\",\n        { \"models/weapons2/grapple/grapple.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/iconw_grapple\",\n/* pickup */\t\"Grappling Hook\",\n\t\t0,\n\t\tIT_WEAPON,\n\t\tWP_GRAPPLING_HOOK,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n\t//\n\t// AMMO ITEMS\n\t//\n\n/*QUAKED ammo_shells (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"ammo_shells\",\n\t\t\"sound/misc/am_pkup.wav\",\n        { \"models/powerups/ammo/shotgunam.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/icona_shotgun\",\n/* pickup */\t\"Shells\",\n\t\t10,\n\t\tIT_AMMO,\n\t\tWP_SHOTGUN,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED ammo_bullets (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"ammo_bullets\",\n\t\t\"sound/misc/am_pkup.wav\",\n        { \"models/powerups/ammo/machinegunam.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/icona_machinegun\",\n/* pickup */\t\"Bullets\",\n\t\t50,\n\t\tIT_AMMO,\n\t\tWP_MACHINEGUN,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED ammo_grenades (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"ammo_grenades\",\n\t\t\"sound/misc/am_pkup.wav\",\n        { \"models/powerups/ammo/grenadeam.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/icona_grenade\",\n/* pickup */\t\"Grenades\",\n\t\t5,\n\t\tIT_AMMO,\n\t\tWP_GRENADE_LAUNCHER,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED ammo_cells (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"ammo_cells\",\n\t\t\"sound/misc/am_pkup.wav\",\n        { \"models/powerups/ammo/plasmaam.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/icona_plasma\",\n/* pickup */\t\"Cells\",\n\t\t30,\n\t\tIT_AMMO,\n\t\tWP_PLASMAGUN,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED ammo_lightning (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"ammo_lightning\",\n\t\t\"sound/misc/am_pkup.wav\",\n        { \"models/powerups/ammo/lightningam.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/icona_lightning\",\n/* pickup */\t\"Lightning\",\n\t\t60,\n\t\tIT_AMMO,\n\t\tWP_LIGHTNING,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED ammo_rockets (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"ammo_rockets\",\n\t\t\"sound/misc/am_pkup.wav\",\n        { \"models/powerups/ammo/rocketam.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/icona_rocket\",\n/* pickup */\t\"Rockets\",\n\t\t5,\n\t\tIT_AMMO,\n\t\tWP_ROCKET_LAUNCHER,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED ammo_slugs (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"ammo_slugs\",\n\t\t\"sound/misc/am_pkup.wav\",\n        { \"models/powerups/ammo/railgunam.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/icona_railgun\",\n/* pickup */\t\"Slugs\",\n\t\t10,\n\t\tIT_AMMO,\n\t\tWP_RAILGUN,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED ammo_bfg (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"ammo_bfg\",\n\t\t\"sound/misc/am_pkup.wav\",\n        { \"models/powerups/ammo/bfgam.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/icona_bfg\",\n/* pickup */\t\"Bfg Ammo\",\n\t\t15,\n\t\tIT_AMMO,\n\t\tWP_BFG,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n\t//\n\t// HOLDABLE ITEMS\n\t//\n/*QUAKED holdable_teleporter (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"holdable_teleporter\", \n\t\t\"sound/items/holdable.wav\",\n        { \"models/powerups/holdable/teleporter.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/teleporter\",\n/* pickup */\t\"Personal Teleporter\",\n\t\t60,\n\t\tIT_HOLDABLE,\n\t\tHI_TELEPORTER,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n/*QUAKED holdable_medkit (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"holdable_medkit\", \n\t\t\"sound/items/holdable.wav\",\n        { \n\t\t\"models/powerups/holdable/medkit.md3\", \n\t\t\"models/powerups/holdable/medkit_sphere.md3\",\n\t\t0, 0},\n/* icon */\t\t\"icons/medkit\",\n/* pickup */\t\"Medkit\",\n\t\t60,\n\t\tIT_HOLDABLE,\n\t\tHI_MEDKIT,\n/* precache */ \"\",\n/* sounds */ \"sound/items/use_medkit.wav\"\n\t},\n\n\t//\n\t// POWERUP ITEMS\n\t//\n/*QUAKED item_quad (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"item_quad\", \n\t\t\"sound/items/quaddamage.wav\",\n        { \"models/powerups/instant/quad.md3\", \n        \"models/powerups/instant/quad_ring.md3\",\n\t\t0, 0 },\n/* icon */\t\t\"icons/quad\",\n/* pickup */\t\"Quad Damage\",\n\t\t30,\n\t\tIT_POWERUP,\n\t\tPW_QUAD,\n/* precache */ \"\",\n/* sounds */ \"sound/items/damage2.wav sound/items/damage3.wav\"\n\t},\n\n/*QUAKED item_enviro (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"item_enviro\",\n\t\t\"sound/items/protect.wav\",\n        { \"models/powerups/instant/enviro.md3\", \n\t\t\"models/powerups/instant/enviro_ring.md3\", \n\t\t0, 0 },\n/* icon */\t\t\"icons/envirosuit\",\n/* pickup */\t\"Battle Suit\",\n\t\t30,\n\t\tIT_POWERUP,\n\t\tPW_BATTLESUIT,\n/* precache */ \"\",\n/* sounds */ \"sound/items/airout.wav sound/items/protect3.wav\"\n\t},\n\n/*QUAKED item_haste (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"item_haste\",\n\t\t\"sound/items/haste.wav\",\n        { \"models/powerups/instant/haste.md3\", \n\t\t\"models/powerups/instant/haste_ring.md3\", \n\t\t0, 0 },\n/* icon */\t\t\"icons/haste\",\n/* pickup */\t\"Speed\",\n\t\t30,\n\t\tIT_POWERUP,\n\t\tPW_HASTE,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED item_invis (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"item_invis\",\n\t\t\"sound/items/invisibility.wav\",\n        { \"models/powerups/instant/invis.md3\", \n\t\t\"models/powerups/instant/invis_ring.md3\", \n\t\t0, 0 },\n/* icon */\t\t\"icons/invis\",\n/* pickup */\t\"Invisibility\",\n\t\t30,\n\t\tIT_POWERUP,\n\t\tPW_INVIS,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED item_regen (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"item_regen\",\n\t\t\"sound/items/regeneration.wav\",\n        { \"models/powerups/instant/regen.md3\", \n\t\t\"models/powerups/instant/regen_ring.md3\", \n\t\t0, 0 },\n/* icon */\t\t\"icons/regen\",\n/* pickup */\t\"Regeneration\",\n\t\t30,\n\t\tIT_POWERUP,\n\t\tPW_REGEN,\n/* precache */ \"\",\n/* sounds */ \"sound/items/regen.wav\"\n\t},\n\n/*QUAKED item_flight (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"item_flight\",\n\t\t\"sound/items/flight.wav\",\n        { \"models/powerups/instant/flight.md3\", \n\t\t\"models/powerups/instant/flight_ring.md3\", \n\t\t0, 0 },\n/* icon */\t\t\"icons/flight\",\n/* pickup */\t\"Flight\",\n\t\t60,\n\t\tIT_POWERUP,\n\t\tPW_FLIGHT,\n/* precache */ \"\",\n/* sounds */ \"sound/items/flight.wav\"\n\t},\n\n/*QUAKED team_CTF_redflag (1 0 0) (-16 -16 -16) (16 16 16)\nOnly in CTF games\n*/\n\t{\n\t\t\"team_CTF_redflag\",\n\t\tNULL,\n        { \"models/flags/r_flag.md3\",\n\t\t0, 0, 0 },\n/* icon */\t\t\"icons/iconf_red1\",\n/* pickup */\t\"Red Flag\",\n\t\t0,\n\t\tIT_TEAM,\n\t\tPW_REDFLAG,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED team_CTF_blueflag (0 0 1) (-16 -16 -16) (16 16 16)\nOnly in CTF games\n*/\n\t{\n\t\t\"team_CTF_blueflag\",\n\t\tNULL,\n        { \"models/flags/b_flag.md3\",\n\t\t0, 0, 0 },\n/* icon */\t\t\"icons/iconf_blu1\",\n/* pickup */\t\"Blue Flag\",\n\t\t0,\n\t\tIT_TEAM,\n\t\tPW_BLUEFLAG,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n#ifdef MISSIONPACK\n/*QUAKED holdable_kamikaze (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"holdable_kamikaze\", \n\t\t\"sound/items/holdable.wav\",\n        { \"models/powerups/kamikazi.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/kamikaze\",\n/* pickup */\t\"Kamikaze\",\n\t\t60,\n\t\tIT_HOLDABLE,\n\t\tHI_KAMIKAZE,\n/* precache */ \"\",\n/* sounds */ \"sound/items/kamikazerespawn.wav\"\n\t},\n\n/*QUAKED holdable_portal (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"holdable_portal\", \n\t\t\"sound/items/holdable.wav\",\n        { \"models/powerups/holdable/porter.md3\",\n\t\t0, 0, 0},\n/* icon */\t\t\"icons/portal\",\n/* pickup */\t\"Portal\",\n\t\t60,\n\t\tIT_HOLDABLE,\n\t\tHI_PORTAL,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED holdable_invulnerability (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"holdable_invulnerability\", \n\t\t\"sound/items/holdable.wav\",\n        { \"models/powerups/holdable/invulnerability.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/invulnerability\",\n/* pickup */\t\"Invulnerability\",\n\t\t60,\n\t\tIT_HOLDABLE,\n\t\tHI_INVULNERABILITY,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED ammo_nails (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"ammo_nails\",\n\t\t\"sound/misc/am_pkup.wav\",\n        { \"models/powerups/ammo/nailgunam.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/icona_nailgun\",\n/* pickup */\t\"Nails\",\n\t\t20,\n\t\tIT_AMMO,\n\t\tWP_NAILGUN,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED ammo_mines (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"ammo_mines\",\n\t\t\"sound/misc/am_pkup.wav\",\n        { \"models/powerups/ammo/proxmineam.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/icona_proxlauncher\",\n/* pickup */\t\"Proximity Mines\",\n\t\t10,\n\t\tIT_AMMO,\n\t\tWP_PROX_LAUNCHER,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED ammo_belt (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"ammo_belt\",\n\t\t\"sound/misc/am_pkup.wav\",\n        { \"models/powerups/ammo/chaingunam.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/icona_chaingun\",\n/* pickup */\t\"Chaingun Belt\",\n\t\t100,\n\t\tIT_AMMO,\n\t\tWP_CHAINGUN,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n\t//\n\t// PERSISTANT POWERUP ITEMS\n\t//\n/*QUAKED item_scout (.3 .3 1) (-16 -16 -16) (16 16 16) suspended redTeam blueTeam\n*/\n\t{\n\t\t\"item_scout\",\n\t\t\"sound/items/scout.wav\",\n        { \"models/powerups/scout.md3\", \n\t\t0, 0, 0 },\n/* icon */\t\t\"icons/scout\",\n/* pickup */\t\"Scout\",\n\t\t30,\n\t\tIT_PERSISTANT_POWERUP,\n\t\tPW_SCOUT,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED item_guard (.3 .3 1) (-16 -16 -16) (16 16 16) suspended redTeam blueTeam\n*/\n\t{\n\t\t\"item_guard\",\n\t\t\"sound/items/guard.wav\",\n        { \"models/powerups/guard.md3\", \n\t\t0, 0, 0 },\n/* icon */\t\t\"icons/guard\",\n/* pickup */\t\"Guard\",\n\t\t30,\n\t\tIT_PERSISTANT_POWERUP,\n\t\tPW_GUARD,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED item_doubler (.3 .3 1) (-16 -16 -16) (16 16 16) suspended redTeam blueTeam\n*/\n\t{\n\t\t\"item_doubler\",\n\t\t\"sound/items/doubler.wav\",\n        { \"models/powerups/doubler.md3\", \n\t\t0, 0, 0 },\n/* icon */\t\t\"icons/doubler\",\n/* pickup */\t\"Doubler\",\n\t\t30,\n\t\tIT_PERSISTANT_POWERUP,\n\t\tPW_DOUBLER,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED item_doubler (.3 .3 1) (-16 -16 -16) (16 16 16) suspended redTeam blueTeam\n*/\n\t{\n\t\t\"item_ammoregen\",\n\t\t\"sound/items/ammoregen.wav\",\n        { \"models/powerups/ammo.md3\",\n\t\t0, 0, 0 },\n/* icon */\t\t\"icons/ammo_regen\",\n/* pickup */\t\"Ammo Regen\",\n\t\t30,\n\t\tIT_PERSISTANT_POWERUP,\n\t\tPW_AMMOREGEN,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n\t/*QUAKED team_CTF_neutralflag (0 0 1) (-16 -16 -16) (16 16 16)\nOnly in One Flag CTF games\n*/\n\t{\n\t\t\"team_CTF_neutralflag\",\n\t\tNULL,\n        { \"models/flags/n_flag.md3\",\n\t\t0, 0, 0 },\n/* icon */\t\t\"icons/iconf_neutral1\",\n/* pickup */\t\"Neutral Flag\",\n\t\t0,\n\t\tIT_TEAM,\n\t\tPW_NEUTRALFLAG,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n\t{\n\t\t\"item_redcube\",\n\t\t\"sound/misc/am_pkup.wav\",\n        { \"models/powerups/orb/r_orb.md3\",\n\t\t0, 0, 0 },\n/* icon */\t\t\"icons/iconh_rorb\",\n/* pickup */\t\"Red Cube\",\n\t\t0,\n\t\tIT_TEAM,\n\t\t0,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n\t{\n\t\t\"item_bluecube\",\n\t\t\"sound/misc/am_pkup.wav\",\n        { \"models/powerups/orb/b_orb.md3\",\n\t\t0, 0, 0 },\n/* icon */\t\t\"icons/iconh_borb\",\n/* pickup */\t\"Blue Cube\",\n\t\t0,\n\t\tIT_TEAM,\n\t\t0,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n/*QUAKED weapon_nailgun (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"weapon_nailgun\", \n\t\t\"sound/misc/w_pkup.wav\",\n        { \"models/weapons/nailgun/nailgun.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/iconw_nailgun\",\n/* pickup */\t\"Nailgun\",\n\t\t10,\n\t\tIT_WEAPON,\n\t\tWP_NAILGUN,\n/* precache */ \"\",\n/* sounds */ \"\"\n\t},\n\n/*QUAKED weapon_prox_launcher (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"weapon_prox_launcher\", \n\t\t\"sound/misc/w_pkup.wav\",\n        { \"models/weapons/proxmine/proxmine.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/iconw_proxlauncher\",\n/* pickup */\t\"Prox Launcher\",\n\t\t5,\n\t\tIT_WEAPON,\n\t\tWP_PROX_LAUNCHER,\n/* precache */ \"\",\n/* sounds */ \"sound/weapons/proxmine/wstbtick.wav \"\n\t\t\t\"sound/weapons/proxmine/wstbactv.wav \"\n\t\t\t\"sound/weapons/proxmine/wstbimpl.wav \"\n\t\t\t\"sound/weapons/proxmine/wstbimpm.wav \"\n\t\t\t\"sound/weapons/proxmine/wstbimpd.wav \"\n\t\t\t\"sound/weapons/proxmine/wstbactv.wav\"\n\t},\n\n/*QUAKED weapon_chaingun (.3 .3 1) (-16 -16 -16) (16 16 16) suspended\n*/\n\t{\n\t\t\"weapon_chaingun\", \n\t\t\"sound/misc/w_pkup.wav\",\n        { \"models/weapons/vulcan/vulcan.md3\", \n\t\t0, 0, 0},\n/* icon */\t\t\"icons/iconw_chaingun\",\n/* pickup */\t\"Chaingun\",\n\t\t80,\n\t\tIT_WEAPON,\n\t\tWP_CHAINGUN,\n/* precache */ \"\",\n/* sounds */ \"sound/weapons/vulcan/wvulwind.wav\"\n\t},\n#endif\n\n\t// end of list marker\n\t{NULL}\n};\n\nint\t\tbg_numItems = sizeof(bg_itemlist) / sizeof(bg_itemlist[0]) - 1;\n\n\n/*\n==============\nBG_FindItemForPowerup\n==============\n*/\ngitem_t\t*BG_FindItemForPowerup( powerup_t pw ) {\n\tint\t\ti;\n\n\tfor ( i = 0 ; i < bg_numItems ; i++ ) {\n\t\tif ( (bg_itemlist[i].giType == IT_POWERUP || \n\t\t\t\t\tbg_itemlist[i].giType == IT_TEAM ||\n\t\t\t\t\tbg_itemlist[i].giType == IT_PERSISTANT_POWERUP) && \n\t\t\tbg_itemlist[i].giTag == pw ) {\n\t\t\treturn &bg_itemlist[i];\n\t\t}\n\t}\n\n\treturn NULL;\n}\n\n\n/*\n==============\nBG_FindItemForHoldable\n==============\n*/\ngitem_t\t*BG_FindItemForHoldable( holdable_t pw ) {\n\tint\t\ti;\n\n\tfor ( i = 0 ; i < bg_numItems ; i++ ) {\n\t\tif ( bg_itemlist[i].giType == IT_HOLDABLE && bg_itemlist[i].giTag == pw ) {\n\t\t\treturn &bg_itemlist[i];\n\t\t}\n\t}\n\n\tCom_Error( ERR_DROP, \"HoldableItem not found\" );\n\n\treturn NULL;\n}\n\n\n/*\n===============\nBG_FindItemForWeapon\n\n===============\n*/\ngitem_t\t*BG_FindItemForWeapon( weapon_t weapon ) {\n\tgitem_t\t*it;\n\t\n\tfor ( it = bg_itemlist + 1 ; it->classname ; it++) {\n\t\tif ( it->giType == IT_WEAPON && it->giTag == weapon ) {\n\t\t\treturn it;\n\t\t}\n\t}\n\n\tCom_Error( ERR_DROP, \"Couldn't find item for weapon %i\", weapon);\n\treturn NULL;\n}\n\n/*\n===============\nBG_FindItem\n\n===============\n*/\ngitem_t\t*BG_FindItem( const char *pickupName ) {\n\tgitem_t\t*it;\n\t\n\tfor ( it = bg_itemlist + 1 ; it->classname ; it++ ) {\n\t\tif ( !Q_stricmp( it->pickup_name, pickupName ) )\n\t\t\treturn it;\n\t}\n\n\treturn NULL;\n}\n\n/*\n============\nBG_PlayerTouchesItem\n\nItems can be picked up without actually touching their physical bounds to make\ngrabbing them easier\n============\n*/\nqboolean\tBG_PlayerTouchesItem( playerState_t *ps, entityState_t *item, int atTime ) {\n\tvec3_t\t\torigin;\n\n\tBG_EvaluateTrajectory( &item->pos, atTime, origin );\n\n\t// we are ignoring ducked differences here\n\tif ( ps->origin[0] - origin[0] > 44\n\t\t|| ps->origin[0] - origin[0] < -50\n\t\t|| ps->origin[1] - origin[1] > 36\n\t\t|| ps->origin[1] - origin[1] < -36\n\t\t|| ps->origin[2] - origin[2] > 36\n\t\t|| ps->origin[2] - origin[2] < -36 ) {\n\t\treturn qfalse;\n\t}\n\n\treturn qtrue;\n}\n\n\n\n/*\n================\nBG_CanItemBeGrabbed\n\nReturns false if the item should not be picked up.\nThis needs to be the same for client side prediction and server use.\n================\n*/\nqboolean BG_CanItemBeGrabbed( int gametype, const entityState_t *ent, const playerState_t *ps ) {\n\tgitem_t\t*item;\n#ifdef MISSIONPACK\n\tint\t\tupperBound;\n#endif\n\n\tif ( ent->modelindex < 1 || ent->modelindex >= bg_numItems ) {\n\t\tCom_Error( ERR_DROP, \"BG_CanItemBeGrabbed: index out of range\" );\n\t}\n\n\titem = &bg_itemlist[ent->modelindex];\n\n\tswitch( item->giType ) {\n\tcase IT_WEAPON:\n\t\treturn qtrue;\t// weapons are always picked up\n\n\tcase IT_AMMO:\n\t\tif ( ps->ammo[ item->giTag ] >= 200 ) {\n\t\t\treturn qfalse;\t\t// can't hold any more\n\t\t}\n\t\treturn qtrue;\n\n\tcase IT_ARMOR:\n#ifdef MISSIONPACK\n\t\tif( bg_itemlist[ps->stats[STAT_PERSISTANT_POWERUP]].giTag == PW_SCOUT ) {\n\t\t\treturn qfalse;\n\t\t}\n\n\t\t// we also clamp armor to the maxhealth for handicapping\n\t\tif( bg_itemlist[ps->stats[STAT_PERSISTANT_POWERUP]].giTag == PW_GUARD ) {\n\t\t\tupperBound = ps->stats[STAT_MAX_HEALTH];\n\t\t}\n\t\telse {\n\t\t\tupperBound = ps->stats[STAT_MAX_HEALTH] * 2;\n\t\t}\n\n\t\tif ( ps->stats[STAT_ARMOR] >= upperBound ) {\n\t\t\treturn qfalse;\n\t\t}\n#else\n\t\tif ( ps->stats[STAT_ARMOR] >= ps->stats[STAT_MAX_HEALTH] * 2 ) {\n\t\t\treturn qfalse;\n\t\t}\n#endif\n\t\treturn qtrue;\n\n\tcase IT_HEALTH:\n\t\t// small and mega healths will go over the max, otherwise\n\t\t// don't pick up if already at max\n#ifdef MISSIONPACK\n\t\tif( bg_itemlist[ps->stats[STAT_PERSISTANT_POWERUP]].giTag == PW_GUARD ) {\n\t\t\tupperBound = ps->stats[STAT_MAX_HEALTH];\n\t\t}\n\t\telse\n#endif\n\t\tif ( item->quantity == 5 || item->quantity == 100 ) {\n\t\t\tif ( ps->stats[STAT_HEALTH] >= ps->stats[STAT_MAX_HEALTH] * 2 ) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\treturn qtrue;\n\t\t}\n\n\t\tif ( ps->stats[STAT_HEALTH] >= ps->stats[STAT_MAX_HEALTH] ) {\n\t\t\treturn qfalse;\n\t\t}\n\t\treturn qtrue;\n\n\tcase IT_POWERUP:\n\t\treturn qtrue;\t// powerups are always picked up\n\n#ifdef MISSIONPACK\n\tcase IT_PERSISTANT_POWERUP:\n\t\t// can only hold one item at a time\n\t\tif ( ps->stats[STAT_PERSISTANT_POWERUP] ) {\n\t\t\treturn qfalse;\n\t\t}\n\n\t\t// check team only\n\t\tif( ( ent->generic1 & 2 ) && ( ps->persistant[PERS_TEAM] != TEAM_RED ) ) {\n\t\t\treturn qfalse;\n\t\t}\n\t\tif( ( ent->generic1 & 4 ) && ( ps->persistant[PERS_TEAM] != TEAM_BLUE ) ) {\n\t\t\treturn qfalse;\n\t\t}\n\n\t\treturn qtrue;\n#endif\n\n\tcase IT_TEAM: // team items, such as flags\n#ifdef MISSIONPACK\t\t\n\t\tif( gametype == GT_1FCTF ) {\n\t\t\t// neutral flag can always be picked up\n\t\t\tif( item->giTag == PW_NEUTRALFLAG ) {\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t\tif (ps->persistant[PERS_TEAM] == TEAM_RED) {\n\t\t\t\tif (item->giTag == PW_BLUEFLAG  && ps->powerups[PW_NEUTRALFLAG] ) {\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n\t\t\t} else if (ps->persistant[PERS_TEAM] == TEAM_BLUE) {\n\t\t\t\tif (item->giTag == PW_REDFLAG  && ps->powerups[PW_NEUTRALFLAG] ) {\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n#endif\n\t\tif( gametype == GT_CTF ) {\n\t\t\t// ent->modelindex2 is non-zero on items if they are dropped\n\t\t\t// we need to know this because we can pick up our dropped flag (and return it)\n\t\t\t// but we can't pick up our flag at base\n\t\t\tif (ps->persistant[PERS_TEAM] == TEAM_RED) {\n\t\t\t\tif (item->giTag == PW_BLUEFLAG ||\n\t\t\t\t\t(item->giTag == PW_REDFLAG && ent->modelindex2) ||\n\t\t\t\t\t(item->giTag == PW_REDFLAG && ps->powerups[PW_BLUEFLAG]) )\n\t\t\t\t\treturn qtrue;\n\t\t\t} else if (ps->persistant[PERS_TEAM] == TEAM_BLUE) {\n\t\t\t\tif (item->giTag == PW_REDFLAG ||\n\t\t\t\t\t(item->giTag == PW_BLUEFLAG && ent->modelindex2) ||\n\t\t\t\t\t(item->giTag == PW_BLUEFLAG && ps->powerups[PW_REDFLAG]) )\n\t\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t}\n\n#ifdef MISSIONPACK\n\t\tif( gametype == GT_HARVESTER ) {\n\t\t\treturn qtrue;\n\t\t}\n#endif\n\t\treturn qfalse;\n\n\tcase IT_HOLDABLE:\n\t\t// can only hold one item at a time\n\t\tif ( ps->stats[STAT_HOLDABLE_ITEM] ) {\n\t\t\treturn qfalse;\n\t\t}\n\t\treturn qtrue;\n\n        case IT_BAD:\n            Com_Error( ERR_DROP, \"BG_CanItemBeGrabbed: IT_BAD\" );\n        default:\n#ifndef Q3_VM\n#ifndef NDEBUG // bk0001204\n          Com_Printf(\"BG_CanItemBeGrabbed: unknown enum %d\\n\", item->giType );\n#endif\n#endif\n         break;\n\t}\n\n\treturn qfalse;\n}\n\n//======================================================================\n\n/*\n================\nBG_EvaluateTrajectory\n\n================\n*/\nvoid BG_EvaluateTrajectory( const trajectory_t *tr, int atTime, vec3_t result ) {\n\tfloat\t\tdeltaTime;\n\tfloat\t\tphase;\n\n\tswitch( tr->trType ) {\n\tcase TR_STATIONARY:\n\tcase TR_INTERPOLATE:\n\t\tVectorCopy( tr->trBase, result );\n\t\tbreak;\n\tcase TR_LINEAR:\n\t\tdeltaTime = ( atTime - tr->trTime ) * 0.001;\t// milliseconds to seconds\n\t\tVectorMA( tr->trBase, deltaTime, tr->trDelta, result );\n\t\tbreak;\n\tcase TR_SINE:\n\t\tdeltaTime = ( atTime - tr->trTime ) / (float) tr->trDuration;\n\t\tphase = sin( deltaTime * M_PI * 2 );\n\t\tVectorMA( tr->trBase, phase, tr->trDelta, result );\n\t\tbreak;\n\tcase TR_LINEAR_STOP:\n\t\tif ( atTime > tr->trTime + tr->trDuration ) {\n\t\t\tatTime = tr->trTime + tr->trDuration;\n\t\t}\n\t\tdeltaTime = ( atTime - tr->trTime ) * 0.001;\t// milliseconds to seconds\n\t\tif ( deltaTime < 0 ) {\n\t\t\tdeltaTime = 0;\n\t\t}\n\t\tVectorMA( tr->trBase, deltaTime, tr->trDelta, result );\n\t\tbreak;\n\tcase TR_GRAVITY:\n\t\tdeltaTime = ( atTime - tr->trTime ) * 0.001;\t// milliseconds to seconds\n\t\tVectorMA( tr->trBase, deltaTime, tr->trDelta, result );\n\t\tresult[2] -= 0.5 * DEFAULT_GRAVITY * deltaTime * deltaTime;\t\t// FIXME: local gravity...\n\t\tbreak;\n\tdefault:\n\t\tCom_Error( ERR_DROP, \"BG_EvaluateTrajectory: unknown trType: %i\", tr->trTime );\n\t\tbreak;\n\t}\n}\n\n/*\n================\nBG_EvaluateTrajectoryDelta\n\nFor determining velocity at a given time\n================\n*/\nvoid BG_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t result ) {\n\tfloat\tdeltaTime;\n\tfloat\tphase;\n\n\tswitch( tr->trType ) {\n\tcase TR_STATIONARY:\n\tcase TR_INTERPOLATE:\n\t\tVectorClear( result );\n\t\tbreak;\n\tcase TR_LINEAR:\n\t\tVectorCopy( tr->trDelta, result );\n\t\tbreak;\n\tcase TR_SINE:\n\t\tdeltaTime = ( atTime - tr->trTime ) / (float) tr->trDuration;\n\t\tphase = cos( deltaTime * M_PI * 2 );\t// derivative of sin = cos\n\t\tphase *= 0.5;\n\t\tVectorScale( tr->trDelta, phase, result );\n\t\tbreak;\n\tcase TR_LINEAR_STOP:\n\t\tif ( atTime > tr->trTime + tr->trDuration ) {\n\t\t\tVectorClear( result );\n\t\t\treturn;\n\t\t}\n\t\tVectorCopy( tr->trDelta, result );\n\t\tbreak;\n\tcase TR_GRAVITY:\n\t\tdeltaTime = ( atTime - tr->trTime ) * 0.001;\t// milliseconds to seconds\n\t\tVectorCopy( tr->trDelta, result );\n\t\tresult[2] -= DEFAULT_GRAVITY * deltaTime;\t\t// FIXME: local gravity...\n\t\tbreak;\n\tdefault:\n\t\tCom_Error( ERR_DROP, \"BG_EvaluateTrajectoryDelta: unknown trType: %i\", tr->trTime );\n\t\tbreak;\n\t}\n}\n\nchar *eventnames[] = {\n\t\"EV_NONE\",\n\n\t\"EV_FOOTSTEP\",\n\t\"EV_FOOTSTEP_METAL\",\n\t\"EV_FOOTSPLASH\",\n\t\"EV_FOOTWADE\",\n\t\"EV_SWIM\",\n\n\t\"EV_STEP_4\",\n\t\"EV_STEP_8\",\n\t\"EV_STEP_12\",\n\t\"EV_STEP_16\",\n\n\t\"EV_FALL_SHORT\",\n\t\"EV_FALL_MEDIUM\",\n\t\"EV_FALL_FAR\",\n\n\t\"EV_JUMP_PAD\",\t\t\t// boing sound at origin\", jump sound on player\n\n\t\"EV_JUMP\",\n\t\"EV_WATER_TOUCH\",\t// foot touches\n\t\"EV_WATER_LEAVE\",\t// foot leaves\n\t\"EV_WATER_UNDER\",\t// head touches\n\t\"EV_WATER_CLEAR\",\t// head leaves\n\n\t\"EV_ITEM_PICKUP\",\t\t\t// normal item pickups are predictable\n\t\"EV_GLOBAL_ITEM_PICKUP\",\t// powerup / team sounds are broadcast to everyone\n\n\t\"EV_NOAMMO\",\n\t\"EV_CHANGE_WEAPON\",\n\t\"EV_FIRE_WEAPON\",\n\n\t\"EV_USE_ITEM0\",\n\t\"EV_USE_ITEM1\",\n\t\"EV_USE_ITEM2\",\n\t\"EV_USE_ITEM3\",\n\t\"EV_USE_ITEM4\",\n\t\"EV_USE_ITEM5\",\n\t\"EV_USE_ITEM6\",\n\t\"EV_USE_ITEM7\",\n\t\"EV_USE_ITEM8\",\n\t\"EV_USE_ITEM9\",\n\t\"EV_USE_ITEM10\",\n\t\"EV_USE_ITEM11\",\n\t\"EV_USE_ITEM12\",\n\t\"EV_USE_ITEM13\",\n\t\"EV_USE_ITEM14\",\n\t\"EV_USE_ITEM15\",\n\n\t\"EV_ITEM_RESPAWN\",\n\t\"EV_ITEM_POP\",\n\t\"EV_PLAYER_TELEPORT_IN\",\n\t\"EV_PLAYER_TELEPORT_OUT\",\n\n\t\"EV_GRENADE_BOUNCE\",\t\t// eventParm will be the soundindex\n\n\t\"EV_GENERAL_SOUND\",\n\t\"EV_GLOBAL_SOUND\",\t\t// no attenuation\n\t\"EV_GLOBAL_TEAM_SOUND\",\n\n\t\"EV_BULLET_HIT_FLESH\",\n\t\"EV_BULLET_HIT_WALL\",\n\n\t\"EV_MISSILE_HIT\",\n\t\"EV_MISSILE_MISS\",\n\t\"EV_MISSILE_MISS_METAL\",\n\t\"EV_RAILTRAIL\",\n\t\"EV_SHOTGUN\",\n\t\"EV_BULLET\",\t\t\t\t// otherEntity is the shooter\n\n\t\"EV_PAIN\",\n\t\"EV_DEATH1\",\n\t\"EV_DEATH2\",\n\t\"EV_DEATH3\",\n\t\"EV_OBITUARY\",\n\n\t\"EV_POWERUP_QUAD\",\n\t\"EV_POWERUP_BATTLESUIT\",\n\t\"EV_POWERUP_REGEN\",\n\n\t\"EV_GIB_PLAYER\",\t\t\t// gib a previously living player\n\t\"EV_SCOREPLUM\",\t\t\t// score plum\n\n//#ifdef MISSIONPACK\n\t\"EV_PROXIMITY_MINE_STICK\",\n\t\"EV_PROXIMITY_MINE_TRIGGER\",\n\t\"EV_KAMIKAZE\",\t\t\t// kamikaze explodes\n\t\"EV_OBELISKEXPLODE\",\t\t// obelisk explodes\n\t\"EV_INVUL_IMPACT\",\t\t// invulnerability sphere impact\n\t\"EV_JUICED\",\t\t\t\t// invulnerability juiced effect\n\t\"EV_LIGHTNINGBOLT\",\t\t// lightning bolt bounced of invulnerability sphere\n//#endif\n\n\t\"EV_DEBUG_LINE\",\n\t\"EV_STOPLOOPINGSOUND\",\n\t\"EV_TAUNT\"\n\n};\n\n/*\n===============\nBG_AddPredictableEventToPlayerstate\n\nHandles the sequence numbers\n===============\n*/\n\nvoid\ttrap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize );\n\nvoid BG_AddPredictableEventToPlayerstate( int newEvent, int eventParm, playerState_t *ps ) {\n\n#ifdef _DEBUG\n\t{\n\t\tchar buf[256];\n\t\ttrap_Cvar_VariableStringBuffer(\"showevents\", buf, sizeof(buf));\n\t\tif ( atof(buf) != 0 ) {\n#ifdef QAGAME\n\t\t\tCom_Printf(\" game event svt %5d -> %5d: num = %20s parm %d\\n\", ps->pmove_framecount/*ps->commandTime*/, ps->eventSequence, eventnames[newEvent], eventParm);\n#else\n\t\t\tCom_Printf(\"Cgame event svt %5d -> %5d: num = %20s parm %d\\n\", ps->pmove_framecount/*ps->commandTime*/, ps->eventSequence, eventnames[newEvent], eventParm);\n#endif\n\t\t}\n\t}\n#endif\n\tps->events[ps->eventSequence & (MAX_PS_EVENTS-1)] = newEvent;\n\tps->eventParms[ps->eventSequence & (MAX_PS_EVENTS-1)] = eventParm;\n\tps->eventSequence++;\n}\n\n/*\n========================\nBG_TouchJumpPad\n========================\n*/\nvoid BG_TouchJumpPad( playerState_t *ps, entityState_t *jumppad ) {\n\tvec3_t\tangles;\n\tfloat p;\n\tint effectNum;\n\n\t// spectators don't use jump pads\n\tif ( ps->pm_type != PM_NORMAL ) {\n\t\treturn;\n\t}\n\n\t// flying characters don't hit bounce pads\n\tif ( ps->powerups[PW_FLIGHT] ) {\n\t\treturn;\n\t}\n\n\t// if we didn't hit this same jumppad the previous frame\n\t// then don't play the event sound again if we are in a fat trigger\n\tif ( ps->jumppad_ent != jumppad->number ) {\n\n\t\tvectoangles( jumppad->origin2, angles);\n\t\tp = fabs( AngleNormalize180( angles[PITCH] ) );\n\t\tif( p < 45 ) {\n\t\t\teffectNum = 0;\n\t\t} else {\n\t\t\teffectNum = 1;\n\t\t}\n\t\tBG_AddPredictableEventToPlayerstate( EV_JUMP_PAD, effectNum, ps );\n\t}\n\t// remember hitting this jumppad this frame\n\tps->jumppad_ent = jumppad->number;\n\tps->jumppad_frame = ps->pmove_framecount;\n\t// give the player the velocity from the jumppad\n\tVectorCopy( jumppad->origin2, ps->velocity );\n}\n\n/*\n========================\nBG_PlayerStateToEntityState\n\nThis is done after each set of usercmd_t on the server,\nand after local prediction on the client\n========================\n*/\nvoid BG_PlayerStateToEntityState( playerState_t *ps, entityState_t *s, qboolean snap ) {\n\tint\t\ti;\n\n\tif ( ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPECTATOR ) {\n\t\ts->eType = ET_INVISIBLE;\n\t} else if ( ps->stats[STAT_HEALTH] <= GIB_HEALTH ) {\n\t\ts->eType = ET_INVISIBLE;\n\t} else {\n\t\ts->eType = ET_PLAYER;\n\t}\n\n\ts->number = ps->clientNum;\n\n\ts->pos.trType = TR_INTERPOLATE;\n\tVectorCopy( ps->origin, s->pos.trBase );\n\tif ( snap ) {\n\t\tSnapVector( s->pos.trBase );\n\t}\n\t// set the trDelta for flag direction\n\tVectorCopy( ps->velocity, s->pos.trDelta );\n\n\ts->apos.trType = TR_INTERPOLATE;\n\tVectorCopy( ps->viewangles, s->apos.trBase );\n\tif ( snap ) {\n\t\tSnapVector( s->apos.trBase );\n\t}\n\n\ts->angles2[YAW] = ps->movementDir;\n\ts->legsAnim = ps->legsAnim;\n\ts->torsoAnim = ps->torsoAnim;\n\ts->clientNum = ps->clientNum;\t\t// ET_PLAYER looks here instead of at number\n\t\t\t\t\t\t\t\t\t\t// so corpses can also reference the proper config\n\ts->eFlags = ps->eFlags;\n\tif ( ps->stats[STAT_HEALTH] <= 0 ) {\n\t\ts->eFlags |= EF_DEAD;\n\t} else {\n\t\ts->eFlags &= ~EF_DEAD;\n\t}\n\n\tif ( ps->externalEvent ) {\n\t\ts->event = ps->externalEvent;\n\t\ts->eventParm = ps->externalEventParm;\n\t} else if ( ps->entityEventSequence < ps->eventSequence ) {\n\t\tint\t\tseq;\n\n\t\tif ( ps->entityEventSequence < ps->eventSequence - MAX_PS_EVENTS) {\n\t\t\tps->entityEventSequence = ps->eventSequence - MAX_PS_EVENTS;\n\t\t}\n\t\tseq = ps->entityEventSequence & (MAX_PS_EVENTS-1);\n\t\ts->event = ps->events[ seq ] | ( ( ps->entityEventSequence & 3 ) << 8 );\n\t\ts->eventParm = ps->eventParms[ seq ];\n\t\tps->entityEventSequence++;\n\t}\n\n\ts->weapon = ps->weapon;\n\ts->groundEntityNum = ps->groundEntityNum;\n\n\ts->powerups = 0;\n\tfor ( i = 0 ; i < MAX_POWERUPS ; i++ ) {\n\t\tif ( ps->powerups[ i ] ) {\n\t\t\ts->powerups |= 1 << i;\n\t\t}\n\t}\n\n\ts->loopSound = ps->loopSound;\n\ts->generic1 = ps->generic1;\n}\n\n/*\n========================\nBG_PlayerStateToEntityStateExtraPolate\n\nThis is done after each set of usercmd_t on the server,\nand after local prediction on the client\n========================\n*/\nvoid BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s, int time, qboolean snap ) {\n\tint\t\ti;\n\n\tif ( ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPECTATOR ) {\n\t\ts->eType = ET_INVISIBLE;\n\t} else if ( ps->stats[STAT_HEALTH] <= GIB_HEALTH ) {\n\t\ts->eType = ET_INVISIBLE;\n\t} else {\n\t\ts->eType = ET_PLAYER;\n\t}\n\n\ts->number = ps->clientNum;\n\n\ts->pos.trType = TR_LINEAR_STOP;\n\tVectorCopy( ps->origin, s->pos.trBase );\n\tif ( snap ) {\n\t\tSnapVector( s->pos.trBase );\n\t}\n\t// set the trDelta for flag direction and linear prediction\n\tVectorCopy( ps->velocity, s->pos.trDelta );\n\t// set the time for linear prediction\n\ts->pos.trTime = time;\n\t// set maximum extra polation time\n\ts->pos.trDuration = 50; // 1000 / sv_fps (default = 20)\n\n\ts->apos.trType = TR_INTERPOLATE;\n\tVectorCopy( ps->viewangles, s->apos.trBase );\n\tif ( snap ) {\n\t\tSnapVector( s->apos.trBase );\n\t}\n\n\ts->angles2[YAW] = ps->movementDir;\n\ts->legsAnim = ps->legsAnim;\n\ts->torsoAnim = ps->torsoAnim;\n\ts->clientNum = ps->clientNum;\t\t// ET_PLAYER looks here instead of at number\n\t\t\t\t\t\t\t\t\t\t// so corpses can also reference the proper config\n\ts->eFlags = ps->eFlags;\n\tif ( ps->stats[STAT_HEALTH] <= 0 ) {\n\t\ts->eFlags |= EF_DEAD;\n\t} else {\n\t\ts->eFlags &= ~EF_DEAD;\n\t}\n\n\tif ( ps->externalEvent ) {\n\t\ts->event = ps->externalEvent;\n\t\ts->eventParm = ps->externalEventParm;\n\t} else if ( ps->entityEventSequence < ps->eventSequence ) {\n\t\tint\t\tseq;\n\n\t\tif ( ps->entityEventSequence < ps->eventSequence - MAX_PS_EVENTS) {\n\t\t\tps->entityEventSequence = ps->eventSequence - MAX_PS_EVENTS;\n\t\t}\n\t\tseq = ps->entityEventSequence & (MAX_PS_EVENTS-1);\n\t\ts->event = ps->events[ seq ] | ( ( ps->entityEventSequence & 3 ) << 8 );\n\t\ts->eventParm = ps->eventParms[ seq ];\n\t\tps->entityEventSequence++;\n\t}\n\n\ts->weapon = ps->weapon;\n\ts->groundEntityNum = ps->groundEntityNum;\n\n\ts->powerups = 0;\n\tfor ( i = 0 ; i < MAX_POWERUPS ; i++ ) {\n\t\tif ( ps->powerups[ i ] ) {\n\t\t\ts->powerups |= 1 << i;\n\t\t}\n\t}\n\n\ts->loopSound = ps->loopSound;\n\ts->generic1 = ps->generic1;\n}\n"
  },
  {
    "path": "code/game/bg_pmove.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// bg_pmove.c -- both games player movement code\n// takes a playerstate and a usercmd as input and returns a modifed playerstate\n\n#include \"q_shared.h\"\n#include \"bg_public.h\"\n#include \"bg_local.h\"\n\npmove_t\t\t*pm;\npml_t\t\tpml;\n\n// movement parameters\nfloat\tpm_stopspeed = 100.0f;\nfloat\tpm_duckScale = 0.25f;\nfloat\tpm_swimScale = 0.50f;\nfloat\tpm_wadeScale = 0.70f;\n\nfloat\tpm_accelerate = 10.0f;\nfloat\tpm_airaccelerate = 1.0f;\nfloat\tpm_wateraccelerate = 4.0f;\nfloat\tpm_flyaccelerate = 8.0f;\n\nfloat\tpm_friction = 6.0f;\nfloat\tpm_waterfriction = 1.0f;\nfloat\tpm_flightfriction = 3.0f;\nfloat\tpm_spectatorfriction = 5.0f;\n\nint\t\tc_pmove = 0;\n\n\n/*\n===============\nPM_AddEvent\n\n===============\n*/\nvoid PM_AddEvent( int newEvent ) {\n\tBG_AddPredictableEventToPlayerstate( newEvent, 0, pm->ps );\n}\n\n/*\n===============\nPM_AddTouchEnt\n===============\n*/\nvoid PM_AddTouchEnt( int entityNum ) {\n\tint\t\ti;\n\n\tif ( entityNum == ENTITYNUM_WORLD ) {\n\t\treturn;\n\t}\n\tif ( pm->numtouch == MAXTOUCH ) {\n\t\treturn;\n\t}\n\n\t// see if it is already added\n\tfor ( i = 0 ; i < pm->numtouch ; i++ ) {\n\t\tif ( pm->touchents[ i ] == entityNum ) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// add it\n\tpm->touchents[pm->numtouch] = entityNum;\n\tpm->numtouch++;\n}\n\n/*\n===================\nPM_StartTorsoAnim\n===================\n*/\nstatic void PM_StartTorsoAnim( int anim ) {\n\tif ( pm->ps->pm_type >= PM_DEAD ) {\n\t\treturn;\n\t}\n\tpm->ps->torsoAnim = ( ( pm->ps->torsoAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT )\n\t\t| anim;\n}\nstatic void PM_StartLegsAnim( int anim ) {\n\tif ( pm->ps->pm_type >= PM_DEAD ) {\n\t\treturn;\n\t}\n\tif ( pm->ps->legsTimer > 0 ) {\n\t\treturn;\t\t// a high priority animation is running\n\t}\n\tpm->ps->legsAnim = ( ( pm->ps->legsAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT )\n\t\t| anim;\n}\n\nstatic void PM_ContinueLegsAnim( int anim ) {\n\tif ( ( pm->ps->legsAnim & ~ANIM_TOGGLEBIT ) == anim ) {\n\t\treturn;\n\t}\n\tif ( pm->ps->legsTimer > 0 ) {\n\t\treturn;\t\t// a high priority animation is running\n\t}\n\tPM_StartLegsAnim( anim );\n}\n\nstatic void PM_ContinueTorsoAnim( int anim ) {\n\tif ( ( pm->ps->torsoAnim & ~ANIM_TOGGLEBIT ) == anim ) {\n\t\treturn;\n\t}\n\tif ( pm->ps->torsoTimer > 0 ) {\n\t\treturn;\t\t// a high priority animation is running\n\t}\n\tPM_StartTorsoAnim( anim );\n}\n\nstatic void PM_ForceLegsAnim( int anim ) {\n\tpm->ps->legsTimer = 0;\n\tPM_StartLegsAnim( anim );\n}\n\n\n/*\n==================\nPM_ClipVelocity\n\nSlide off of the impacting surface\n==================\n*/\nvoid PM_ClipVelocity( vec3_t in, vec3_t normal, vec3_t out, float overbounce ) {\n\tfloat\tbackoff;\n\tfloat\tchange;\n\tint\t\ti;\n\t\n\tbackoff = DotProduct (in, normal);\n\t\n\tif ( backoff < 0 ) {\n\t\tbackoff *= overbounce;\n\t} else {\n\t\tbackoff /= overbounce;\n\t}\n\n\tfor ( i=0 ; i<3 ; i++ ) {\n\t\tchange = normal[i]*backoff;\n\t\tout[i] = in[i] - change;\n\t}\n}\n\n\n/*\n==================\nPM_Friction\n\nHandles both ground friction and water friction\n==================\n*/\nstatic void PM_Friction( void ) {\n\tvec3_t\tvec;\n\tfloat\t*vel;\n\tfloat\tspeed, newspeed, control;\n\tfloat\tdrop;\n\t\n\tvel = pm->ps->velocity;\n\t\n\tVectorCopy( vel, vec );\n\tif ( pml.walking ) {\n\t\tvec[2] = 0;\t// ignore slope movement\n\t}\n\n\tspeed = VectorLength(vec);\n\tif (speed < 1) {\n\t\tvel[0] = 0;\n\t\tvel[1] = 0;\t\t// allow sinking underwater\n\t\t// FIXME: still have z friction underwater?\n\t\treturn;\n\t}\n\n\tdrop = 0;\n\n\t// apply ground friction\n\tif ( pm->waterlevel <= 1 ) {\n\t\tif ( pml.walking && !(pml.groundTrace.surfaceFlags & SURF_SLICK) ) {\n\t\t\t// if getting knocked back, no friction\n\t\t\tif ( ! (pm->ps->pm_flags & PMF_TIME_KNOCKBACK) ) {\n\t\t\t\tcontrol = speed < pm_stopspeed ? pm_stopspeed : speed;\n\t\t\t\tdrop += control*pm_friction*pml.frametime;\n\t\t\t}\n\t\t}\n\t}\n\n\t// apply water friction even if just wading\n\tif ( pm->waterlevel ) {\n\t\tdrop += speed*pm_waterfriction*pm->waterlevel*pml.frametime;\n\t}\n\n\t// apply flying friction\n\tif ( pm->ps->powerups[PW_FLIGHT]) {\n\t\tdrop += speed*pm_flightfriction*pml.frametime;\n\t}\n\n\tif ( pm->ps->pm_type == PM_SPECTATOR) {\n\t\tdrop += speed*pm_spectatorfriction*pml.frametime;\n\t}\n\n\t// scale the velocity\n\tnewspeed = speed - drop;\n\tif (newspeed < 0) {\n\t\tnewspeed = 0;\n\t}\n\tnewspeed /= speed;\n\n\tvel[0] = vel[0] * newspeed;\n\tvel[1] = vel[1] * newspeed;\n\tvel[2] = vel[2] * newspeed;\n}\n\n\n/*\n==============\nPM_Accelerate\n\nHandles user intended acceleration\n==============\n*/\nstatic void PM_Accelerate( vec3_t wishdir, float wishspeed, float accel ) {\n#if 1\n\t// q2 style\n\tint\t\t\ti;\n\tfloat\t\taddspeed, accelspeed, currentspeed;\n\n\tcurrentspeed = DotProduct (pm->ps->velocity, wishdir);\n\taddspeed = wishspeed - currentspeed;\n\tif (addspeed <= 0) {\n\t\treturn;\n\t}\n\taccelspeed = accel*pml.frametime*wishspeed;\n\tif (accelspeed > addspeed) {\n\t\taccelspeed = addspeed;\n\t}\n\t\n\tfor (i=0 ; i<3 ; i++) {\n\t\tpm->ps->velocity[i] += accelspeed*wishdir[i];\t\n\t}\n#else\n\t// proper way (avoids strafe jump maxspeed bug), but feels bad\n\tvec3_t\t\twishVelocity;\n\tvec3_t\t\tpushDir;\n\tfloat\t\tpushLen;\n\tfloat\t\tcanPush;\n\n\tVectorScale( wishdir, wishspeed, wishVelocity );\n\tVectorSubtract( wishVelocity, pm->ps->velocity, pushDir );\n\tpushLen = VectorNormalize( pushDir );\n\n\tcanPush = accel*pml.frametime*wishspeed;\n\tif (canPush > pushLen) {\n\t\tcanPush = pushLen;\n\t}\n\n\tVectorMA( pm->ps->velocity, canPush, pushDir, pm->ps->velocity );\n#endif\n}\n\n\n\n/*\n============\nPM_CmdScale\n\nReturns the scale factor to apply to cmd movements\nThis allows the clients to use axial -127 to 127 values for all directions\nwithout getting a sqrt(2) distortion in speed.\n============\n*/\nstatic float PM_CmdScale( usercmd_t *cmd ) {\n\tint\t\tmax;\n\tfloat\ttotal;\n\tfloat\tscale;\n\n\tmax = abs( cmd->forwardmove );\n\tif ( abs( cmd->rightmove ) > max ) {\n\t\tmax = abs( cmd->rightmove );\n\t}\n\tif ( abs( cmd->upmove ) > max ) {\n\t\tmax = abs( cmd->upmove );\n\t}\n\tif ( !max ) {\n\t\treturn 0;\n\t}\n\n\ttotal = sqrt( cmd->forwardmove * cmd->forwardmove\n\t\t+ cmd->rightmove * cmd->rightmove + cmd->upmove * cmd->upmove );\n\tscale = (float)pm->ps->speed * max / ( 127.0 * total );\n\n\treturn scale;\n}\n\n\n/*\n================\nPM_SetMovementDir\n\nDetermine the rotation of the legs reletive\nto the facing dir\n================\n*/\nstatic void PM_SetMovementDir( void ) {\n\tif ( pm->cmd.forwardmove || pm->cmd.rightmove ) {\n\t\tif ( pm->cmd.rightmove == 0 && pm->cmd.forwardmove > 0 ) {\n\t\t\tpm->ps->movementDir = 0;\n\t\t} else if ( pm->cmd.rightmove < 0 && pm->cmd.forwardmove > 0 ) {\n\t\t\tpm->ps->movementDir = 1;\n\t\t} else if ( pm->cmd.rightmove < 0 && pm->cmd.forwardmove == 0 ) {\n\t\t\tpm->ps->movementDir = 2;\n\t\t} else if ( pm->cmd.rightmove < 0 && pm->cmd.forwardmove < 0 ) {\n\t\t\tpm->ps->movementDir = 3;\n\t\t} else if ( pm->cmd.rightmove == 0 && pm->cmd.forwardmove < 0 ) {\n\t\t\tpm->ps->movementDir = 4;\n\t\t} else if ( pm->cmd.rightmove > 0 && pm->cmd.forwardmove < 0 ) {\n\t\t\tpm->ps->movementDir = 5;\n\t\t} else if ( pm->cmd.rightmove > 0 && pm->cmd.forwardmove == 0 ) {\n\t\t\tpm->ps->movementDir = 6;\n\t\t} else if ( pm->cmd.rightmove > 0 && pm->cmd.forwardmove > 0 ) {\n\t\t\tpm->ps->movementDir = 7;\n\t\t}\n\t} else {\n\t\t// if they aren't actively going directly sideways,\n\t\t// change the animation to the diagonal so they\n\t\t// don't stop too crooked\n\t\tif ( pm->ps->movementDir == 2 ) {\n\t\t\tpm->ps->movementDir = 1;\n\t\t} else if ( pm->ps->movementDir == 6 ) {\n\t\t\tpm->ps->movementDir = 7;\n\t\t} \n\t}\n}\n\n\n/*\n=============\nPM_CheckJump\n=============\n*/\nstatic qboolean PM_CheckJump( void ) {\n\tif ( pm->ps->pm_flags & PMF_RESPAWNED ) {\n\t\treturn qfalse;\t\t// don't allow jump until all buttons are up\n\t}\n\n\tif ( pm->cmd.upmove < 10 ) {\n\t\t// not holding jump\n\t\treturn qfalse;\n\t}\n\n\t// must wait for jump to be released\n\tif ( pm->ps->pm_flags & PMF_JUMP_HELD ) {\n\t\t// clear upmove so cmdscale doesn't lower running speed\n\t\tpm->cmd.upmove = 0;\n\t\treturn qfalse;\n\t}\n\n\tpml.groundPlane = qfalse;\t\t// jumping away\n\tpml.walking = qfalse;\n\tpm->ps->pm_flags |= PMF_JUMP_HELD;\n\n\tpm->ps->groundEntityNum = ENTITYNUM_NONE;\n\tpm->ps->velocity[2] = JUMP_VELOCITY;\n\tPM_AddEvent( EV_JUMP );\n\n\tif ( pm->cmd.forwardmove >= 0 ) {\n\t\tPM_ForceLegsAnim( LEGS_JUMP );\n\t\tpm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP;\n\t} else {\n\t\tPM_ForceLegsAnim( LEGS_JUMPB );\n\t\tpm->ps->pm_flags |= PMF_BACKWARDS_JUMP;\n\t}\n\n\treturn qtrue;\n}\n\n/*\n=============\nPM_CheckWaterJump\n=============\n*/\nstatic qboolean\tPM_CheckWaterJump( void ) {\n\tvec3_t\tspot;\n\tint\t\tcont;\n\tvec3_t\tflatforward;\n\n\tif (pm->ps->pm_time) {\n\t\treturn qfalse;\n\t}\n\n\t// check for water jump\n\tif ( pm->waterlevel != 2 ) {\n\t\treturn qfalse;\n\t}\n\n\tflatforward[0] = pml.forward[0];\n\tflatforward[1] = pml.forward[1];\n\tflatforward[2] = 0;\n\tVectorNormalize (flatforward);\n\n\tVectorMA (pm->ps->origin, 30, flatforward, spot);\n\tspot[2] += 4;\n\tcont = pm->pointcontents (spot, pm->ps->clientNum );\n\tif ( !(cont & CONTENTS_SOLID) ) {\n\t\treturn qfalse;\n\t}\n\n\tspot[2] += 16;\n\tcont = pm->pointcontents (spot, pm->ps->clientNum );\n\tif ( cont ) {\n\t\treturn qfalse;\n\t}\n\n\t// jump out of water\n\tVectorScale (pml.forward, 200, pm->ps->velocity);\n\tpm->ps->velocity[2] = 350;\n\n\tpm->ps->pm_flags |= PMF_TIME_WATERJUMP;\n\tpm->ps->pm_time = 2000;\n\n\treturn qtrue;\n}\n\n//============================================================================\n\n\n/*\n===================\nPM_WaterJumpMove\n\nFlying out of the water\n===================\n*/\nstatic void PM_WaterJumpMove( void ) {\n\t// waterjump has no control, but falls\n\n\tPM_StepSlideMove( qtrue );\n\n\tpm->ps->velocity[2] -= pm->ps->gravity * pml.frametime;\n\tif (pm->ps->velocity[2] < 0) {\n\t\t// cancel as soon as we are falling down again\n\t\tpm->ps->pm_flags &= ~PMF_ALL_TIMES;\n\t\tpm->ps->pm_time = 0;\n\t}\n}\n\n/*\n===================\nPM_WaterMove\n\n===================\n*/\nstatic void PM_WaterMove( void ) {\n\tint\t\ti;\n\tvec3_t\twishvel;\n\tfloat\twishspeed;\n\tvec3_t\twishdir;\n\tfloat\tscale;\n\tfloat\tvel;\n\n\tif ( PM_CheckWaterJump() ) {\n\t\tPM_WaterJumpMove();\n\t\treturn;\n\t}\n#if 0\n\t// jump = head for surface\n\tif ( pm->cmd.upmove >= 10 ) {\n\t\tif (pm->ps->velocity[2] > -300) {\n\t\t\tif ( pm->watertype == CONTENTS_WATER ) {\n\t\t\t\tpm->ps->velocity[2] = 100;\n\t\t\t} else if (pm->watertype == CONTENTS_SLIME) {\n\t\t\t\tpm->ps->velocity[2] = 80;\n\t\t\t} else {\n\t\t\t\tpm->ps->velocity[2] = 50;\n\t\t\t}\n\t\t}\n\t}\n#endif\n\tPM_Friction ();\n\n\tscale = PM_CmdScale( &pm->cmd );\n\t//\n\t// user intentions\n\t//\n\tif ( !scale ) {\n\t\twishvel[0] = 0;\n\t\twishvel[1] = 0;\n\t\twishvel[2] = -60;\t\t// sink towards bottom\n\t} else {\n\t\tfor (i=0 ; i<3 ; i++)\n\t\t\twishvel[i] = scale * pml.forward[i]*pm->cmd.forwardmove + scale * pml.right[i]*pm->cmd.rightmove;\n\n\t\twishvel[2] += scale * pm->cmd.upmove;\n\t}\n\n\tVectorCopy (wishvel, wishdir);\n\twishspeed = VectorNormalize(wishdir);\n\n\tif ( wishspeed > pm->ps->speed * pm_swimScale ) {\n\t\twishspeed = pm->ps->speed * pm_swimScale;\n\t}\n\n\tPM_Accelerate (wishdir, wishspeed, pm_wateraccelerate);\n\n\t// make sure we can go up slopes easily under water\n\tif ( pml.groundPlane && DotProduct( pm->ps->velocity, pml.groundTrace.plane.normal ) < 0 ) {\n\t\tvel = VectorLength(pm->ps->velocity);\n\t\t// slide along the ground plane\n\t\tPM_ClipVelocity (pm->ps->velocity, pml.groundTrace.plane.normal, \n\t\t\tpm->ps->velocity, OVERCLIP );\n\n\t\tVectorNormalize(pm->ps->velocity);\n\t\tVectorScale(pm->ps->velocity, vel, pm->ps->velocity);\n\t}\n\n\tPM_SlideMove( qfalse );\n}\n\n#ifdef MISSIONPACK\n/*\n===================\nPM_InvulnerabilityMove\n\nOnly with the invulnerability powerup\n===================\n*/\nstatic void PM_InvulnerabilityMove( void ) {\n\tpm->cmd.forwardmove = 0;\n\tpm->cmd.rightmove = 0;\n\tpm->cmd.upmove = 0;\n\tVectorClear(pm->ps->velocity);\n}\n#endif\n\n/*\n===================\nPM_FlyMove\n\nOnly with the flight powerup\n===================\n*/\nstatic void PM_FlyMove( void ) {\n\tint\t\ti;\n\tvec3_t\twishvel;\n\tfloat\twishspeed;\n\tvec3_t\twishdir;\n\tfloat\tscale;\n\n\t// normal slowdown\n\tPM_Friction ();\n\n\tscale = PM_CmdScale( &pm->cmd );\n\t//\n\t// user intentions\n\t//\n\tif ( !scale ) {\n\t\twishvel[0] = 0;\n\t\twishvel[1] = 0;\n\t\twishvel[2] = 0;\n\t} else {\n\t\tfor (i=0 ; i<3 ; i++) {\n\t\t\twishvel[i] = scale * pml.forward[i]*pm->cmd.forwardmove + scale * pml.right[i]*pm->cmd.rightmove;\n\t\t}\n\n\t\twishvel[2] += scale * pm->cmd.upmove;\n\t}\n\n\tVectorCopy (wishvel, wishdir);\n\twishspeed = VectorNormalize(wishdir);\n\n\tPM_Accelerate (wishdir, wishspeed, pm_flyaccelerate);\n\n\tPM_StepSlideMove( qfalse );\n}\n\n\n/*\n===================\nPM_AirMove\n\n===================\n*/\nstatic void PM_AirMove( void ) {\n\tint\t\t\ti;\n\tvec3_t\t\twishvel;\n\tfloat\t\tfmove, smove;\n\tvec3_t\t\twishdir;\n\tfloat\t\twishspeed;\n\tfloat\t\tscale;\n\tusercmd_t\tcmd;\n\n\tPM_Friction();\n\n\tfmove = pm->cmd.forwardmove;\n\tsmove = pm->cmd.rightmove;\n\n\tcmd = pm->cmd;\n\tscale = PM_CmdScale( &cmd );\n\n\t// set the movementDir so clients can rotate the legs for strafing\n\tPM_SetMovementDir();\n\n\t// project moves down to flat plane\n\tpml.forward[2] = 0;\n\tpml.right[2] = 0;\n\tVectorNormalize (pml.forward);\n\tVectorNormalize (pml.right);\n\n\tfor ( i = 0 ; i < 2 ; i++ ) {\n\t\twishvel[i] = pml.forward[i]*fmove + pml.right[i]*smove;\n\t}\n\twishvel[2] = 0;\n\n\tVectorCopy (wishvel, wishdir);\n\twishspeed = VectorNormalize(wishdir);\n\twishspeed *= scale;\n\n\t// not on ground, so little effect on velocity\n\tPM_Accelerate (wishdir, wishspeed, pm_airaccelerate);\n\n\t// we may have a ground plane that is very steep, even\n\t// though we don't have a groundentity\n\t// slide along the steep plane\n\tif ( pml.groundPlane ) {\n\t\tPM_ClipVelocity (pm->ps->velocity, pml.groundTrace.plane.normal, \n\t\t\tpm->ps->velocity, OVERCLIP );\n\t}\n\n#if 0\n\t//ZOID:  If we are on the grapple, try stair-stepping\n\t//this allows a player to use the grapple to pull himself\n\t//over a ledge\n\tif (pm->ps->pm_flags & PMF_GRAPPLE_PULL)\n\t\tPM_StepSlideMove ( qtrue );\n\telse\n\t\tPM_SlideMove ( qtrue );\n#endif\n\n\tPM_StepSlideMove ( qtrue );\n}\n\n/*\n===================\nPM_GrappleMove\n\n===================\n*/\nstatic void PM_GrappleMove( void ) {\n\tvec3_t vel, v;\n\tfloat vlen;\n\n\tVectorScale(pml.forward, -16, v);\n\tVectorAdd(pm->ps->grapplePoint, v, v);\n\tVectorSubtract(v, pm->ps->origin, vel);\n\tvlen = VectorLength(vel);\n\tVectorNormalize( vel );\n\n\tif (vlen <= 100)\n\t\tVectorScale(vel, 10 * vlen, vel);\n\telse\n\t\tVectorScale(vel, 800, vel);\n\n\tVectorCopy(vel, pm->ps->velocity);\n\n\tpml.groundPlane = qfalse;\n}\n\n/*\n===================\nPM_WalkMove\n\n===================\n*/\nstatic void PM_WalkMove( void ) {\n\tint\t\t\ti;\n\tvec3_t\t\twishvel;\n\tfloat\t\tfmove, smove;\n\tvec3_t\t\twishdir;\n\tfloat\t\twishspeed;\n\tfloat\t\tscale;\n\tusercmd_t\tcmd;\n\tfloat\t\taccelerate;\n\tfloat\t\tvel;\n\n\tif ( pm->waterlevel > 2 && DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 ) {\n\t\t// begin swimming\n\t\tPM_WaterMove();\n\t\treturn;\n\t}\n\n\n\tif ( PM_CheckJump () ) {\n\t\t// jumped away\n\t\tif ( pm->waterlevel > 1 ) {\n\t\t\tPM_WaterMove();\n\t\t} else {\n\t\t\tPM_AirMove();\n\t\t}\n\t\treturn;\n\t}\n\n\tPM_Friction ();\n\n\tfmove = pm->cmd.forwardmove;\n\tsmove = pm->cmd.rightmove;\n\n\tcmd = pm->cmd;\n\tscale = PM_CmdScale( &cmd );\n\n\t// set the movementDir so clients can rotate the legs for strafing\n\tPM_SetMovementDir();\n\n\t// project moves down to flat plane\n\tpml.forward[2] = 0;\n\tpml.right[2] = 0;\n\n\t// project the forward and right directions onto the ground plane\n\tPM_ClipVelocity (pml.forward, pml.groundTrace.plane.normal, pml.forward, OVERCLIP );\n\tPM_ClipVelocity (pml.right, pml.groundTrace.plane.normal, pml.right, OVERCLIP );\n\t//\n\tVectorNormalize (pml.forward);\n\tVectorNormalize (pml.right);\n\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\twishvel[i] = pml.forward[i]*fmove + pml.right[i]*smove;\n\t}\n\t// when going up or down slopes the wish velocity should Not be zero\n//\twishvel[2] = 0;\n\n\tVectorCopy (wishvel, wishdir);\n\twishspeed = VectorNormalize(wishdir);\n\twishspeed *= scale;\n\n\t// clamp the speed lower if ducking\n\tif ( pm->ps->pm_flags & PMF_DUCKED ) {\n\t\tif ( wishspeed > pm->ps->speed * pm_duckScale ) {\n\t\t\twishspeed = pm->ps->speed * pm_duckScale;\n\t\t}\n\t}\n\n\t// clamp the speed lower if wading or walking on the bottom\n\tif ( pm->waterlevel ) {\n\t\tfloat\twaterScale;\n\n\t\twaterScale = pm->waterlevel / 3.0;\n\t\twaterScale = 1.0 - ( 1.0 - pm_swimScale ) * waterScale;\n\t\tif ( wishspeed > pm->ps->speed * waterScale ) {\n\t\t\twishspeed = pm->ps->speed * waterScale;\n\t\t}\n\t}\n\n\t// when a player gets hit, they temporarily lose\n\t// full control, which allows them to be moved a bit\n\tif ( ( pml.groundTrace.surfaceFlags & SURF_SLICK ) || pm->ps->pm_flags & PMF_TIME_KNOCKBACK ) {\n\t\taccelerate = pm_airaccelerate;\n\t} else {\n\t\taccelerate = pm_accelerate;\n\t}\n\n\tPM_Accelerate (wishdir, wishspeed, accelerate);\n\n\t//Com_Printf(\"velocity = %1.1f %1.1f %1.1f\\n\", pm->ps->velocity[0], pm->ps->velocity[1], pm->ps->velocity[2]);\n\t//Com_Printf(\"velocity1 = %1.1f\\n\", VectorLength(pm->ps->velocity));\n\n\tif ( ( pml.groundTrace.surfaceFlags & SURF_SLICK ) || pm->ps->pm_flags & PMF_TIME_KNOCKBACK ) {\n\t\tpm->ps->velocity[2] -= pm->ps->gravity * pml.frametime;\n\t} else {\n\t\t// don't reset the z velocity for slopes\n//\t\tpm->ps->velocity[2] = 0;\n\t}\n\n\tvel = VectorLength(pm->ps->velocity);\n\n\t// slide along the ground plane\n\tPM_ClipVelocity (pm->ps->velocity, pml.groundTrace.plane.normal, \n\t\tpm->ps->velocity, OVERCLIP );\n\n\t// don't decrease velocity when going up or down a slope\n\tVectorNormalize(pm->ps->velocity);\n\tVectorScale(pm->ps->velocity, vel, pm->ps->velocity);\n\n\t// don't do anything if standing still\n\tif (!pm->ps->velocity[0] && !pm->ps->velocity[1]) {\n\t\treturn;\n\t}\n\n\tPM_StepSlideMove( qfalse );\n\n\t//Com_Printf(\"velocity2 = %1.1f\\n\", VectorLength(pm->ps->velocity));\n\n}\n\n\n/*\n==============\nPM_DeadMove\n==============\n*/\nstatic void PM_DeadMove( void ) {\n\tfloat\tforward;\n\n\tif ( !pml.walking ) {\n\t\treturn;\n\t}\n\n\t// extra friction\n\n\tforward = VectorLength (pm->ps->velocity);\n\tforward -= 20;\n\tif ( forward <= 0 ) {\n\t\tVectorClear (pm->ps->velocity);\n\t} else {\n\t\tVectorNormalize (pm->ps->velocity);\n\t\tVectorScale (pm->ps->velocity, forward, pm->ps->velocity);\n\t}\n}\n\n\n/*\n===============\nPM_NoclipMove\n===============\n*/\nstatic void PM_NoclipMove( void ) {\n\tfloat\tspeed, drop, friction, control, newspeed;\n\tint\t\t\ti;\n\tvec3_t\t\twishvel;\n\tfloat\t\tfmove, smove;\n\tvec3_t\t\twishdir;\n\tfloat\t\twishspeed;\n\tfloat\t\tscale;\n\n\tpm->ps->viewheight = DEFAULT_VIEWHEIGHT;\n\n\t// friction\n\n\tspeed = VectorLength (pm->ps->velocity);\n\tif (speed < 1)\n\t{\n\t\tVectorCopy (vec3_origin, pm->ps->velocity);\n\t}\n\telse\n\t{\n\t\tdrop = 0;\n\n\t\tfriction = pm_friction*1.5;\t// extra friction\n\t\tcontrol = speed < pm_stopspeed ? pm_stopspeed : speed;\n\t\tdrop += control*friction*pml.frametime;\n\n\t\t// scale the velocity\n\t\tnewspeed = speed - drop;\n\t\tif (newspeed < 0)\n\t\t\tnewspeed = 0;\n\t\tnewspeed /= speed;\n\n\t\tVectorScale (pm->ps->velocity, newspeed, pm->ps->velocity);\n\t}\n\n\t// accelerate\n\tscale = PM_CmdScale( &pm->cmd );\n\n\tfmove = pm->cmd.forwardmove;\n\tsmove = pm->cmd.rightmove;\n\t\n\tfor (i=0 ; i<3 ; i++)\n\t\twishvel[i] = pml.forward[i]*fmove + pml.right[i]*smove;\n\twishvel[2] += pm->cmd.upmove;\n\n\tVectorCopy (wishvel, wishdir);\n\twishspeed = VectorNormalize(wishdir);\n\twishspeed *= scale;\n\n\tPM_Accelerate( wishdir, wishspeed, pm_accelerate );\n\n\t// move\n\tVectorMA (pm->ps->origin, pml.frametime, pm->ps->velocity, pm->ps->origin);\n}\n\n//============================================================================\n\n/*\n================\nPM_FootstepForSurface\n\nReturns an event number apropriate for the groundsurface\n================\n*/\nstatic int PM_FootstepForSurface( void ) {\n\tif ( pml.groundTrace.surfaceFlags & SURF_NOSTEPS ) {\n\t\treturn 0;\n\t}\n\tif ( pml.groundTrace.surfaceFlags & SURF_METALSTEPS ) {\n\t\treturn EV_FOOTSTEP_METAL;\n\t}\n\treturn EV_FOOTSTEP;\n}\n\n\n/*\n=================\nPM_CrashLand\n\nCheck for hard landings that generate sound events\n=================\n*/\nstatic void PM_CrashLand( void ) {\n\tfloat\t\tdelta;\n\tfloat\t\tdist;\n\tfloat\t\tvel, acc;\n\tfloat\t\tt;\n\tfloat\t\ta, b, c, den;\n\n\t// decide which landing animation to use\n\tif ( pm->ps->pm_flags & PMF_BACKWARDS_JUMP ) {\n\t\tPM_ForceLegsAnim( LEGS_LANDB );\n\t} else {\n\t\tPM_ForceLegsAnim( LEGS_LAND );\n\t}\n\n\tpm->ps->legsTimer = TIMER_LAND;\n\n\t// calculate the exact velocity on landing\n\tdist = pm->ps->origin[2] - pml.previous_origin[2];\n\tvel = pml.previous_velocity[2];\n\tacc = -pm->ps->gravity;\n\n\ta = acc / 2;\n\tb = vel;\n\tc = -dist;\n\n\tden =  b * b - 4 * a * c;\n\tif ( den < 0 ) {\n\t\treturn;\n\t}\n\tt = (-b - sqrt( den ) ) / ( 2 * a );\n\n\tdelta = vel + t * acc;\n\tdelta = delta*delta * 0.0001;\n\n\t// ducking while falling doubles damage\n\tif ( pm->ps->pm_flags & PMF_DUCKED ) {\n\t\tdelta *= 2;\n\t}\n\n\t// never take falling damage if completely underwater\n\tif ( pm->waterlevel == 3 ) {\n\t\treturn;\n\t}\n\n\t// reduce falling damage if there is standing water\n\tif ( pm->waterlevel == 2 ) {\n\t\tdelta *= 0.25;\n\t}\n\tif ( pm->waterlevel == 1 ) {\n\t\tdelta *= 0.5;\n\t}\n\n\tif ( delta < 1 ) {\n\t\treturn;\n\t}\n\n\t// create a local entity event to play the sound\n\n\t// SURF_NODAMAGE is used for bounce pads where you don't ever\n\t// want to take damage or play a crunch sound\n\tif ( !(pml.groundTrace.surfaceFlags & SURF_NODAMAGE) )  {\n\t\tif ( delta > 60 ) {\n\t\t\tPM_AddEvent( EV_FALL_FAR );\n\t\t} else if ( delta > 40 ) {\n\t\t\t// this is a pain grunt, so don't play it if dead\n\t\t\tif ( pm->ps->stats[STAT_HEALTH] > 0 ) {\n\t\t\t\tPM_AddEvent( EV_FALL_MEDIUM );\n\t\t\t}\n\t\t} else if ( delta > 7 ) {\n\t\t\tPM_AddEvent( EV_FALL_SHORT );\n\t\t} else {\n\t\t\tPM_AddEvent( PM_FootstepForSurface() );\n\t\t}\n\t}\n\n\t// start footstep cycle over\n\tpm->ps->bobCycle = 0;\n}\n\n/*\n=============\nPM_CheckStuck\n=============\n*/\n/*\nvoid PM_CheckStuck(void) {\n\ttrace_t trace;\n\n\tpm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, pm->ps->origin, pm->ps->clientNum, pm->tracemask);\n\tif (trace.allsolid) {\n\t\t//int shit = qtrue;\n\t}\n}\n*/\n\n/*\n=============\nPM_CorrectAllSolid\n=============\n*/\nstatic int PM_CorrectAllSolid( trace_t *trace ) {\n\tint\t\t\ti, j, k;\n\tvec3_t\t\tpoint;\n\n\tif ( pm->debugLevel ) {\n\t\tCom_Printf(\"%i:allsolid\\n\", c_pmove);\n\t}\n\n\t// jitter around\n\tfor (i = -1; i <= 1; i++) {\n\t\tfor (j = -1; j <= 1; j++) {\n\t\t\tfor (k = -1; k <= 1; k++) {\n\t\t\t\tVectorCopy(pm->ps->origin, point);\n\t\t\t\tpoint[0] += (float) i;\n\t\t\t\tpoint[1] += (float) j;\n\t\t\t\tpoint[2] += (float) k;\n\t\t\t\tpm->trace (trace, point, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask);\n\t\t\t\tif ( !trace->allsolid ) {\n\t\t\t\t\tpoint[0] = pm->ps->origin[0];\n\t\t\t\t\tpoint[1] = pm->ps->origin[1];\n\t\t\t\t\tpoint[2] = pm->ps->origin[2] - 0.25;\n\n\t\t\t\t\tpm->trace (trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask);\n\t\t\t\t\tpml.groundTrace = *trace;\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpm->ps->groundEntityNum = ENTITYNUM_NONE;\n\tpml.groundPlane = qfalse;\n\tpml.walking = qfalse;\n\n\treturn qfalse;\n}\n\n\n/*\n=============\nPM_GroundTraceMissed\n\nThe ground trace didn't hit a surface, so we are in freefall\n=============\n*/\nstatic void PM_GroundTraceMissed( void ) {\n\ttrace_t\t\ttrace;\n\tvec3_t\t\tpoint;\n\n\tif ( pm->ps->groundEntityNum != ENTITYNUM_NONE ) {\n\t\t// we just transitioned into freefall\n\t\tif ( pm->debugLevel ) {\n\t\t\tCom_Printf(\"%i:lift\\n\", c_pmove);\n\t\t}\n\n\t\t// if they aren't in a jumping animation and the ground is a ways away, force into it\n\t\t// if we didn't do the trace, the player would be backflipping down staircases\n\t\tVectorCopy( pm->ps->origin, point );\n\t\tpoint[2] -= 64;\n\n\t\tpm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask);\n\t\tif ( trace.fraction == 1.0 ) {\n\t\t\tif ( pm->cmd.forwardmove >= 0 ) {\n\t\t\t\tPM_ForceLegsAnim( LEGS_JUMP );\n\t\t\t\tpm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP;\n\t\t\t} else {\n\t\t\t\tPM_ForceLegsAnim( LEGS_JUMPB );\n\t\t\t\tpm->ps->pm_flags |= PMF_BACKWARDS_JUMP;\n\t\t\t}\n\t\t}\n\t}\n\n\tpm->ps->groundEntityNum = ENTITYNUM_NONE;\n\tpml.groundPlane = qfalse;\n\tpml.walking = qfalse;\n}\n\n\n/*\n=============\nPM_GroundTrace\n=============\n*/\nstatic void PM_GroundTrace( void ) {\n\tvec3_t\t\tpoint;\n\ttrace_t\t\ttrace;\n\n\tpoint[0] = pm->ps->origin[0];\n\tpoint[1] = pm->ps->origin[1];\n\tpoint[2] = pm->ps->origin[2] - 0.25;\n\n\tpm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask);\n\tpml.groundTrace = trace;\n\n\t// do something corrective if the trace starts in a solid...\n\tif ( trace.allsolid ) {\n\t\tif ( !PM_CorrectAllSolid(&trace) )\n\t\t\treturn;\n\t}\n\n\t// if the trace didn't hit anything, we are in free fall\n\tif ( trace.fraction == 1.0 ) {\n\t\tPM_GroundTraceMissed();\n\t\tpml.groundPlane = qfalse;\n\t\tpml.walking = qfalse;\n\t\treturn;\n\t}\n\n\t// check if getting thrown off the ground\n\tif ( pm->ps->velocity[2] > 0 && DotProduct( pm->ps->velocity, trace.plane.normal ) > 10 ) {\n\t\tif ( pm->debugLevel ) {\n\t\t\tCom_Printf(\"%i:kickoff\\n\", c_pmove);\n\t\t}\n\t\t// go into jump animation\n\t\tif ( pm->cmd.forwardmove >= 0 ) {\n\t\t\tPM_ForceLegsAnim( LEGS_JUMP );\n\t\t\tpm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP;\n\t\t} else {\n\t\t\tPM_ForceLegsAnim( LEGS_JUMPB );\n\t\t\tpm->ps->pm_flags |= PMF_BACKWARDS_JUMP;\n\t\t}\n\n\t\tpm->ps->groundEntityNum = ENTITYNUM_NONE;\n\t\tpml.groundPlane = qfalse;\n\t\tpml.walking = qfalse;\n\t\treturn;\n\t}\n\t\n\t// slopes that are too steep will not be considered onground\n\tif ( trace.plane.normal[2] < MIN_WALK_NORMAL ) {\n\t\tif ( pm->debugLevel ) {\n\t\t\tCom_Printf(\"%i:steep\\n\", c_pmove);\n\t\t}\n\t\t// FIXME: if they can't slide down the slope, let them\n\t\t// walk (sharp crevices)\n\t\tpm->ps->groundEntityNum = ENTITYNUM_NONE;\n\t\tpml.groundPlane = qtrue;\n\t\tpml.walking = qfalse;\n\t\treturn;\n\t}\n\n\tpml.groundPlane = qtrue;\n\tpml.walking = qtrue;\n\n\t// hitting solid ground will end a waterjump\n\tif (pm->ps->pm_flags & PMF_TIME_WATERJUMP)\n\t{\n\t\tpm->ps->pm_flags &= ~(PMF_TIME_WATERJUMP | PMF_TIME_LAND);\n\t\tpm->ps->pm_time = 0;\n\t}\n\n\tif ( pm->ps->groundEntityNum == ENTITYNUM_NONE ) {\n\t\t// just hit the ground\n\t\tif ( pm->debugLevel ) {\n\t\t\tCom_Printf(\"%i:Land\\n\", c_pmove);\n\t\t}\n\t\t\n\t\tPM_CrashLand();\n\n\t\t// don't do landing time if we were just going down a slope\n\t\tif ( pml.previous_velocity[2] < -200 ) {\n\t\t\t// don't allow another jump for a little while\n\t\t\tpm->ps->pm_flags |= PMF_TIME_LAND;\n\t\t\tpm->ps->pm_time = 250;\n\t\t}\n\t}\n\n\tpm->ps->groundEntityNum = trace.entityNum;\n\n\t// don't reset the z velocity for slopes\n//\tpm->ps->velocity[2] = 0;\n\n\tPM_AddTouchEnt( trace.entityNum );\n}\n\n\n/*\n=============\nPM_SetWaterLevel\tFIXME: avoid this twice?  certainly if not moving\n=============\n*/\nstatic void PM_SetWaterLevel( void ) {\n\tvec3_t\t\tpoint;\n\tint\t\t\tcont;\n\tint\t\t\tsample1;\n\tint\t\t\tsample2;\n\n\t//\n\t// get waterlevel, accounting for ducking\n\t//\n\tpm->waterlevel = 0;\n\tpm->watertype = 0;\n\n\tpoint[0] = pm->ps->origin[0];\n\tpoint[1] = pm->ps->origin[1];\n\tpoint[2] = pm->ps->origin[2] + MINS_Z + 1;\t\n\tcont = pm->pointcontents( point, pm->ps->clientNum );\n\n\tif ( cont & MASK_WATER ) {\n\t\tsample2 = pm->ps->viewheight - MINS_Z;\n\t\tsample1 = sample2 / 2;\n\n\t\tpm->watertype = cont;\n\t\tpm->waterlevel = 1;\n\t\tpoint[2] = pm->ps->origin[2] + MINS_Z + sample1;\n\t\tcont = pm->pointcontents (point, pm->ps->clientNum );\n\t\tif ( cont & MASK_WATER ) {\n\t\t\tpm->waterlevel = 2;\n\t\t\tpoint[2] = pm->ps->origin[2] + MINS_Z + sample2;\n\t\t\tcont = pm->pointcontents (point, pm->ps->clientNum );\n\t\t\tif ( cont & MASK_WATER ){\n\t\t\t\tpm->waterlevel = 3;\n\t\t\t}\n\t\t}\n\t}\n\n}\n\n/*\n==============\nPM_CheckDuck\n\nSets mins, maxs, and pm->ps->viewheight\n==============\n*/\nstatic void PM_CheckDuck (void)\n{\n\ttrace_t\ttrace;\n\n\tif ( pm->ps->powerups[PW_INVULNERABILITY] ) {\n\t\tif ( pm->ps->pm_flags & PMF_INVULEXPAND ) {\n\t\t\t// invulnerability sphere has a 42 units radius\n\t\t\tVectorSet( pm->mins, -42, -42, -42 );\n\t\t\tVectorSet( pm->maxs, 42, 42, 42 );\n\t\t}\n\t\telse {\n\t\t\tVectorSet( pm->mins, -15, -15, MINS_Z );\n\t\t\tVectorSet( pm->maxs, 15, 15, 16 );\n\t\t}\n\t\tpm->ps->pm_flags |= PMF_DUCKED;\n\t\tpm->ps->viewheight = CROUCH_VIEWHEIGHT;\n\t\treturn;\n\t}\n\tpm->ps->pm_flags &= ~PMF_INVULEXPAND;\n\n\tpm->mins[0] = -15;\n\tpm->mins[1] = -15;\n\n\tpm->maxs[0] = 15;\n\tpm->maxs[1] = 15;\n\n\tpm->mins[2] = MINS_Z;\n\n\tif (pm->ps->pm_type == PM_DEAD)\n\t{\n\t\tpm->maxs[2] = -8;\n\t\tpm->ps->viewheight = DEAD_VIEWHEIGHT;\n\t\treturn;\n\t}\n\n\tif (pm->cmd.upmove < 0)\n\t{\t// duck\n\t\tpm->ps->pm_flags |= PMF_DUCKED;\n\t}\n\telse\n\t{\t// stand up if possible\n\t\tif (pm->ps->pm_flags & PMF_DUCKED)\n\t\t{\n\t\t\t// try to stand up\n\t\t\tpm->maxs[2] = 32;\n\t\t\tpm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, pm->ps->origin, pm->ps->clientNum, pm->tracemask );\n\t\t\tif (!trace.allsolid)\n\t\t\t\tpm->ps->pm_flags &= ~PMF_DUCKED;\n\t\t}\n\t}\n\n\tif (pm->ps->pm_flags & PMF_DUCKED)\n\t{\n\t\tpm->maxs[2] = 16;\n\t\tpm->ps->viewheight = CROUCH_VIEWHEIGHT;\n\t}\n\telse\n\t{\n\t\tpm->maxs[2] = 32;\n\t\tpm->ps->viewheight = DEFAULT_VIEWHEIGHT;\n\t}\n}\n\n\n\n//===================================================================\n\n\n/*\n===============\nPM_Footsteps\n===============\n*/\nstatic void PM_Footsteps( void ) {\n\tfloat\t\tbobmove;\n\tint\t\t\told;\n\tqboolean\tfootstep;\n\n\t//\n\t// calculate speed and cycle to be used for\n\t// all cyclic walking effects\n\t//\n\tpm->xyspeed = sqrt( pm->ps->velocity[0] * pm->ps->velocity[0]\n\t\t+  pm->ps->velocity[1] * pm->ps->velocity[1] );\n\n\tif ( pm->ps->groundEntityNum == ENTITYNUM_NONE ) {\n\n\t\tif ( pm->ps->powerups[PW_INVULNERABILITY] ) {\n\t\t\tPM_ContinueLegsAnim( LEGS_IDLECR );\n\t\t}\n\t\t// airborne leaves position in cycle intact, but doesn't advance\n\t\tif ( pm->waterlevel > 1 ) {\n\t\t\tPM_ContinueLegsAnim( LEGS_SWIM );\n\t\t}\n\t\treturn;\n\t}\n\n\t// if not trying to move\n\tif ( !pm->cmd.forwardmove && !pm->cmd.rightmove ) {\n\t\tif (  pm->xyspeed < 5 ) {\n\t\t\tpm->ps->bobCycle = 0;\t// start at beginning of cycle again\n\t\t\tif ( pm->ps->pm_flags & PMF_DUCKED ) {\n\t\t\t\tPM_ContinueLegsAnim( LEGS_IDLECR );\n\t\t\t} else {\n\t\t\t\tPM_ContinueLegsAnim( LEGS_IDLE );\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\t\n\n\tfootstep = qfalse;\n\n\tif ( pm->ps->pm_flags & PMF_DUCKED ) {\n\t\tbobmove = 0.5;\t// ducked characters bob much faster\n\t\tif ( pm->ps->pm_flags & PMF_BACKWARDS_RUN ) {\n\t\t\tPM_ContinueLegsAnim( LEGS_BACKCR );\n\t\t}\n\t\telse {\n\t\t\tPM_ContinueLegsAnim( LEGS_WALKCR );\n\t\t}\n\t\t// ducked characters never play footsteps\n\t/*\n\t} else \tif ( pm->ps->pm_flags & PMF_BACKWARDS_RUN ) {\n\t\tif ( !( pm->cmd.buttons & BUTTON_WALKING ) ) {\n\t\t\tbobmove = 0.4;\t// faster speeds bob faster\n\t\t\tfootstep = qtrue;\n\t\t} else {\n\t\t\tbobmove = 0.3;\n\t\t}\n\t\tPM_ContinueLegsAnim( LEGS_BACK );\n\t*/\n\t} else {\n\t\tif ( !( pm->cmd.buttons & BUTTON_WALKING ) ) {\n\t\t\tbobmove = 0.4f;\t// faster speeds bob faster\n\t\t\tif ( pm->ps->pm_flags & PMF_BACKWARDS_RUN ) {\n\t\t\t\tPM_ContinueLegsAnim( LEGS_BACK );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tPM_ContinueLegsAnim( LEGS_RUN );\n\t\t\t}\n\t\t\tfootstep = qtrue;\n\t\t} else {\n\t\t\tbobmove = 0.3f;\t// walking bobs slow\n\t\t\tif ( pm->ps->pm_flags & PMF_BACKWARDS_RUN ) {\n\t\t\t\tPM_ContinueLegsAnim( LEGS_BACKWALK );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tPM_ContinueLegsAnim( LEGS_WALK );\n\t\t\t}\n\t\t}\n\t}\n\n\t// check for footstep / splash sounds\n\told = pm->ps->bobCycle;\n\tpm->ps->bobCycle = (int)( old + bobmove * pml.msec ) & 255;\n\n\t// if we just crossed a cycle boundary, play an apropriate footstep event\n\tif ( ( ( old + 64 ) ^ ( pm->ps->bobCycle + 64 ) ) & 128 ) {\n\t\tif ( pm->waterlevel == 0 ) {\n\t\t\t// on ground will only play sounds if running\n\t\t\tif ( footstep && !pm->noFootsteps ) {\n\t\t\t\tPM_AddEvent( PM_FootstepForSurface() );\n\t\t\t}\n\t\t} else if ( pm->waterlevel == 1 ) {\n\t\t\t// splashing\n\t\t\tPM_AddEvent( EV_FOOTSPLASH );\n\t\t} else if ( pm->waterlevel == 2 ) {\n\t\t\t// wading / swimming at surface\n\t\t\tPM_AddEvent( EV_SWIM );\n\t\t} else if ( pm->waterlevel == 3 ) {\n\t\t\t// no sound when completely underwater\n\n\t\t}\n\t}\n}\n\n/*\n==============\nPM_WaterEvents\n\nGenerate sound events for entering and leaving water\n==============\n*/\nstatic void PM_WaterEvents( void ) {\t\t// FIXME?\n\t//\n\t// if just entered a water volume, play a sound\n\t//\n\tif (!pml.previous_waterlevel && pm->waterlevel) {\n\t\tPM_AddEvent( EV_WATER_TOUCH );\n\t}\n\n\t//\n\t// if just completely exited a water volume, play a sound\n\t//\n\tif (pml.previous_waterlevel && !pm->waterlevel) {\n\t\tPM_AddEvent( EV_WATER_LEAVE );\n\t}\n\n\t//\n\t// check for head just going under water\n\t//\n\tif (pml.previous_waterlevel != 3 && pm->waterlevel == 3) {\n\t\tPM_AddEvent( EV_WATER_UNDER );\n\t}\n\n\t//\n\t// check for head just coming out of water\n\t//\n\tif (pml.previous_waterlevel == 3 && pm->waterlevel != 3) {\n\t\tPM_AddEvent( EV_WATER_CLEAR );\n\t}\n}\n\n\n/*\n===============\nPM_BeginWeaponChange\n===============\n*/\nstatic void PM_BeginWeaponChange( int weapon ) {\n\tif ( weapon <= WP_NONE || weapon >= WP_NUM_WEAPONS ) {\n\t\treturn;\n\t}\n\n\tif ( !( pm->ps->stats[STAT_WEAPONS] & ( 1 << weapon ) ) ) {\n\t\treturn;\n\t}\n\t\n\tif ( pm->ps->weaponstate == WEAPON_DROPPING ) {\n\t\treturn;\n\t}\n\n\tPM_AddEvent( EV_CHANGE_WEAPON );\n\tpm->ps->weaponstate = WEAPON_DROPPING;\n\tpm->ps->weaponTime += 200;\n\tPM_StartTorsoAnim( TORSO_DROP );\n}\n\n\n/*\n===============\nPM_FinishWeaponChange\n===============\n*/\nstatic void PM_FinishWeaponChange( void ) {\n\tint\t\tweapon;\n\n\tweapon = pm->cmd.weapon;\n\tif ( weapon < WP_NONE || weapon >= WP_NUM_WEAPONS ) {\n\t\tweapon = WP_NONE;\n\t}\n\n\tif ( !( pm->ps->stats[STAT_WEAPONS] & ( 1 << weapon ) ) ) {\n\t\tweapon = WP_NONE;\n\t}\n\n\tpm->ps->weapon = weapon;\n\tpm->ps->weaponstate = WEAPON_RAISING;\n\tpm->ps->weaponTime += 250;\n\tPM_StartTorsoAnim( TORSO_RAISE );\n}\n\n\n/*\n==============\nPM_TorsoAnimation\n\n==============\n*/\nstatic void PM_TorsoAnimation( void ) {\n\tif ( pm->ps->weaponstate == WEAPON_READY ) {\n\t\tif ( pm->ps->weapon == WP_GAUNTLET ) {\n\t\t\tPM_ContinueTorsoAnim( TORSO_STAND2 );\n\t\t} else {\n\t\t\tPM_ContinueTorsoAnim( TORSO_STAND );\n\t\t}\n\t\treturn;\n\t}\n}\n\n\n/*\n==============\nPM_Weapon\n\nGenerates weapon events and modifes the weapon counter\n==============\n*/\nstatic void PM_Weapon( void ) {\n\tint\t\taddTime;\n\n\t// don't allow attack until all buttons are up\n\tif ( pm->ps->pm_flags & PMF_RESPAWNED ) {\n\t\treturn;\n\t}\n\n\t// ignore if spectator\n\tif ( pm->ps->persistant[PERS_TEAM] == TEAM_SPECTATOR ) {\n\t\treturn;\n\t}\n\n\t// check for dead player\n\tif ( pm->ps->stats[STAT_HEALTH] <= 0 ) {\n\t\tpm->ps->weapon = WP_NONE;\n\t\treturn;\n\t}\n\n\t// check for item using\n\tif ( pm->cmd.buttons & BUTTON_USE_HOLDABLE ) {\n\t\tif ( ! ( pm->ps->pm_flags & PMF_USE_ITEM_HELD ) ) {\n\t\t\tif ( bg_itemlist[pm->ps->stats[STAT_HOLDABLE_ITEM]].giTag == HI_MEDKIT\n\t\t\t\t&& pm->ps->stats[STAT_HEALTH] >= (pm->ps->stats[STAT_MAX_HEALTH] + 25) ) {\n\t\t\t\t// don't use medkit if at max health\n\t\t\t} else {\n\t\t\t\tpm->ps->pm_flags |= PMF_USE_ITEM_HELD;\n\t\t\t\tPM_AddEvent( EV_USE_ITEM0 + bg_itemlist[pm->ps->stats[STAT_HOLDABLE_ITEM]].giTag );\n\t\t\t\tpm->ps->stats[STAT_HOLDABLE_ITEM] = 0;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t} else {\n\t\tpm->ps->pm_flags &= ~PMF_USE_ITEM_HELD;\n\t}\n\n\n\t// make weapon function\n\tif ( pm->ps->weaponTime > 0 ) {\n\t\tpm->ps->weaponTime -= pml.msec;\n\t}\n\n\t// check for weapon change\n\t// can't change if weapon is firing, but can change\n\t// again if lowering or raising\n\tif ( pm->ps->weaponTime <= 0 || pm->ps->weaponstate != WEAPON_FIRING ) {\n\t\tif ( pm->ps->weapon != pm->cmd.weapon ) {\n\t\t\tPM_BeginWeaponChange( pm->cmd.weapon );\n\t\t}\n\t}\n\n\tif ( pm->ps->weaponTime > 0 ) {\n\t\treturn;\n\t}\n\n\t// change weapon if time\n\tif ( pm->ps->weaponstate == WEAPON_DROPPING ) {\n\t\tPM_FinishWeaponChange();\n\t\treturn;\n\t}\n\n\tif ( pm->ps->weaponstate == WEAPON_RAISING ) {\n\t\tpm->ps->weaponstate = WEAPON_READY;\n\t\tif ( pm->ps->weapon == WP_GAUNTLET ) {\n\t\t\tPM_StartTorsoAnim( TORSO_STAND2 );\n\t\t} else {\n\t\t\tPM_StartTorsoAnim( TORSO_STAND );\n\t\t}\n\t\treturn;\n\t}\n\n\t// check for fire\n\tif ( ! (pm->cmd.buttons & BUTTON_ATTACK) ) {\n\t\tpm->ps->weaponTime = 0;\n\t\tpm->ps->weaponstate = WEAPON_READY;\n\t\treturn;\n\t}\n\n\t// start the animation even if out of ammo\n\tif ( pm->ps->weapon == WP_GAUNTLET ) {\n\t\t// the guantlet only \"fires\" when it actually hits something\n\t\tif ( !pm->gauntletHit ) {\n\t\t\tpm->ps->weaponTime = 0;\n\t\t\tpm->ps->weaponstate = WEAPON_READY;\n\t\t\treturn;\n\t\t}\n\t\tPM_StartTorsoAnim( TORSO_ATTACK2 );\n\t} else {\n\t\tPM_StartTorsoAnim( TORSO_ATTACK );\n\t}\n\n\tpm->ps->weaponstate = WEAPON_FIRING;\n\n\t// check for out of ammo\n\tif ( ! pm->ps->ammo[ pm->ps->weapon ] ) {\n\t\tPM_AddEvent( EV_NOAMMO );\n\t\tpm->ps->weaponTime += 500;\n\t\treturn;\n\t}\n\n\t// take an ammo away if not infinite\n\tif ( pm->ps->ammo[ pm->ps->weapon ] != -1 ) {\n\t\tpm->ps->ammo[ pm->ps->weapon ]--;\n\t}\n\n\t// fire weapon\n\tPM_AddEvent( EV_FIRE_WEAPON );\n\n\tswitch( pm->ps->weapon ) {\n\tdefault:\n\tcase WP_GAUNTLET:\n\t\taddTime = 400;\n\t\tbreak;\n\tcase WP_LIGHTNING:\n\t\taddTime = 50;\n\t\tbreak;\n\tcase WP_SHOTGUN:\n\t\taddTime = 1000;\n\t\tbreak;\n\tcase WP_MACHINEGUN:\n\t\taddTime = 100;\n\t\tbreak;\n\tcase WP_GRENADE_LAUNCHER:\n\t\taddTime = 800;\n\t\tbreak;\n\tcase WP_ROCKET_LAUNCHER:\n\t\taddTime = 800;\n\t\tbreak;\n\tcase WP_PLASMAGUN:\n\t\taddTime = 100;\n\t\tbreak;\n\tcase WP_RAILGUN:\n\t\taddTime = 1500;\n\t\tbreak;\n\tcase WP_BFG:\n\t\taddTime = 200;\n\t\tbreak;\n\tcase WP_GRAPPLING_HOOK:\n\t\taddTime = 400;\n\t\tbreak;\n#ifdef MISSIONPACK\n\tcase WP_NAILGUN:\n\t\taddTime = 1000;\n\t\tbreak;\n\tcase WP_PROX_LAUNCHER:\n\t\taddTime = 800;\n\t\tbreak;\n\tcase WP_CHAINGUN:\n\t\taddTime = 30;\n\t\tbreak;\n#endif\n\t}\n\n#ifdef MISSIONPACK\n\tif( bg_itemlist[pm->ps->stats[STAT_PERSISTANT_POWERUP]].giTag == PW_SCOUT ) {\n\t\taddTime /= 1.5;\n\t}\n\telse\n\tif( bg_itemlist[pm->ps->stats[STAT_PERSISTANT_POWERUP]].giTag == PW_AMMOREGEN ) {\n\t\taddTime /= 1.3;\n  }\n  else\n#endif\n\tif ( pm->ps->powerups[PW_HASTE] ) {\n\t\taddTime /= 1.3;\n\t}\n\n\tpm->ps->weaponTime += addTime;\n}\n\n/*\n================\nPM_Animate\n================\n*/\n\nstatic void PM_Animate( void ) {\n\tif ( pm->cmd.buttons & BUTTON_GESTURE ) {\n\t\tif ( pm->ps->torsoTimer == 0 ) {\n\t\t\tPM_StartTorsoAnim( TORSO_GESTURE );\n\t\t\tpm->ps->torsoTimer = TIMER_GESTURE;\n\t\t\tPM_AddEvent( EV_TAUNT );\n\t\t}\n#ifdef MISSIONPACK\n\t} else if ( pm->cmd.buttons & BUTTON_GETFLAG ) {\n\t\tif ( pm->ps->torsoTimer == 0 ) {\n\t\t\tPM_StartTorsoAnim( TORSO_GETFLAG );\n\t\t\tpm->ps->torsoTimer = 600;\t//TIMER_GESTURE;\n\t\t}\n\t} else if ( pm->cmd.buttons & BUTTON_GUARDBASE ) {\n\t\tif ( pm->ps->torsoTimer == 0 ) {\n\t\t\tPM_StartTorsoAnim( TORSO_GUARDBASE );\n\t\t\tpm->ps->torsoTimer = 600;\t//TIMER_GESTURE;\n\t\t}\n\t} else if ( pm->cmd.buttons & BUTTON_PATROL ) {\n\t\tif ( pm->ps->torsoTimer == 0 ) {\n\t\t\tPM_StartTorsoAnim( TORSO_PATROL );\n\t\t\tpm->ps->torsoTimer = 600;\t//TIMER_GESTURE;\n\t\t}\n\t} else if ( pm->cmd.buttons & BUTTON_FOLLOWME ) {\n\t\tif ( pm->ps->torsoTimer == 0 ) {\n\t\t\tPM_StartTorsoAnim( TORSO_FOLLOWME );\n\t\t\tpm->ps->torsoTimer = 600;\t//TIMER_GESTURE;\n\t\t}\n\t} else if ( pm->cmd.buttons & BUTTON_AFFIRMATIVE ) {\n\t\tif ( pm->ps->torsoTimer == 0 ) {\n\t\t\tPM_StartTorsoAnim( TORSO_AFFIRMATIVE);\n\t\t\tpm->ps->torsoTimer = 600;\t//TIMER_GESTURE;\n\t\t}\n\t} else if ( pm->cmd.buttons & BUTTON_NEGATIVE ) {\n\t\tif ( pm->ps->torsoTimer == 0 ) {\n\t\t\tPM_StartTorsoAnim( TORSO_NEGATIVE );\n\t\t\tpm->ps->torsoTimer = 600;\t//TIMER_GESTURE;\n\t\t}\n#endif\n\t}\n}\n\n\n/*\n================\nPM_DropTimers\n================\n*/\nstatic void PM_DropTimers( void ) {\n\t// drop misc timing counter\n\tif ( pm->ps->pm_time ) {\n\t\tif ( pml.msec >= pm->ps->pm_time ) {\n\t\t\tpm->ps->pm_flags &= ~PMF_ALL_TIMES;\n\t\t\tpm->ps->pm_time = 0;\n\t\t} else {\n\t\t\tpm->ps->pm_time -= pml.msec;\n\t\t}\n\t}\n\n\t// drop animation counter\n\tif ( pm->ps->legsTimer > 0 ) {\n\t\tpm->ps->legsTimer -= pml.msec;\n\t\tif ( pm->ps->legsTimer < 0 ) {\n\t\t\tpm->ps->legsTimer = 0;\n\t\t}\n\t}\n\n\tif ( pm->ps->torsoTimer > 0 ) {\n\t\tpm->ps->torsoTimer -= pml.msec;\n\t\tif ( pm->ps->torsoTimer < 0 ) {\n\t\t\tpm->ps->torsoTimer = 0;\n\t\t}\n\t}\n}\n\n/*\n================\nPM_UpdateViewAngles\n\nThis can be used as another entry point when only the viewangles\nare being updated isntead of a full move\n================\n*/\nvoid PM_UpdateViewAngles( playerState_t *ps, const usercmd_t *cmd ) {\n\tshort\t\ttemp;\n\tint\t\ti;\n\n\tif ( ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPINTERMISSION) {\n\t\treturn;\t\t// no view changes at all\n\t}\n\n\tif ( ps->pm_type != PM_SPECTATOR && ps->stats[STAT_HEALTH] <= 0 ) {\n\t\treturn;\t\t// no view changes at all\n\t}\n\n\t// circularly clamp the angles with deltas\n\tfor (i=0 ; i<3 ; i++) {\n\t\ttemp = cmd->angles[i] + ps->delta_angles[i];\n\t\tif ( i == PITCH ) {\n\t\t\t// don't let the player look up or down more than 90 degrees\n\t\t\tif ( temp > 16000 ) {\n\t\t\t\tps->delta_angles[i] = 16000 - cmd->angles[i];\n\t\t\t\ttemp = 16000;\n\t\t\t} else if ( temp < -16000 ) {\n\t\t\t\tps->delta_angles[i] = -16000 - cmd->angles[i];\n\t\t\t\ttemp = -16000;\n\t\t\t}\n\t\t}\n\t\tps->viewangles[i] = SHORT2ANGLE(temp);\n\t}\n\n}\n\n\n/*\n================\nPmoveSingle\n\n================\n*/\nvoid trap_SnapVector( float *v );\n\nvoid PmoveSingle (pmove_t *pmove) {\n\tpm = pmove;\n\n\t// this counter lets us debug movement problems with a journal\n\t// by setting a conditional breakpoint fot the previous frame\n\tc_pmove++;\n\n\t// clear results\n\tpm->numtouch = 0;\n\tpm->watertype = 0;\n\tpm->waterlevel = 0;\n\n\tif ( pm->ps->stats[STAT_HEALTH] <= 0 ) {\n\t\tpm->tracemask &= ~CONTENTS_BODY;\t// corpses can fly through bodies\n\t}\n\n\t// make sure walking button is clear if they are running, to avoid\n\t// proxy no-footsteps cheats\n\tif ( abs( pm->cmd.forwardmove ) > 64 || abs( pm->cmd.rightmove ) > 64 ) {\n\t\tpm->cmd.buttons &= ~BUTTON_WALKING;\n\t}\n\n\t// set the talk balloon flag\n\tif ( pm->cmd.buttons & BUTTON_TALK ) {\n\t\tpm->ps->eFlags |= EF_TALK;\n\t} else {\n\t\tpm->ps->eFlags &= ~EF_TALK;\n\t}\n\n\t// set the firing flag for continuous beam weapons\n\tif ( !(pm->ps->pm_flags & PMF_RESPAWNED) && pm->ps->pm_type != PM_INTERMISSION\n\t\t&& ( pm->cmd.buttons & BUTTON_ATTACK ) && pm->ps->ammo[ pm->ps->weapon ] ) {\n\t\tpm->ps->eFlags |= EF_FIRING;\n\t} else {\n\t\tpm->ps->eFlags &= ~EF_FIRING;\n\t}\n\n\t// clear the respawned flag if attack and use are cleared\n\tif ( pm->ps->stats[STAT_HEALTH] > 0 && \n\t\t!( pm->cmd.buttons & (BUTTON_ATTACK | BUTTON_USE_HOLDABLE) ) ) {\n\t\tpm->ps->pm_flags &= ~PMF_RESPAWNED;\n\t}\n\n\t// if talk button is down, dissallow all other input\n\t// this is to prevent any possible intercept proxy from\n\t// adding fake talk balloons\n\tif ( pmove->cmd.buttons & BUTTON_TALK ) {\n\t\t// keep the talk button set tho for when the cmd.serverTime > 66 msec\n\t\t// and the same cmd is used multiple times in Pmove\n\t\tpmove->cmd.buttons = BUTTON_TALK;\n\t\tpmove->cmd.forwardmove = 0;\n\t\tpmove->cmd.rightmove = 0;\n\t\tpmove->cmd.upmove = 0;\n\t}\n\n\t// clear all pmove local vars\n\tmemset (&pml, 0, sizeof(pml));\n\n\t// determine the time\n\tpml.msec = pmove->cmd.serverTime - pm->ps->commandTime;\n\tif ( pml.msec < 1 ) {\n\t\tpml.msec = 1;\n\t} else if ( pml.msec > 200 ) {\n\t\tpml.msec = 200;\n\t}\n\tpm->ps->commandTime = pmove->cmd.serverTime;\n\n\t// save old org in case we get stuck\n\tVectorCopy (pm->ps->origin, pml.previous_origin);\n\n\t// save old velocity for crashlanding\n\tVectorCopy (pm->ps->velocity, pml.previous_velocity);\n\n\tpml.frametime = pml.msec * 0.001;\n\n\t// update the viewangles\n\tPM_UpdateViewAngles( pm->ps, &pm->cmd );\n\n\tAngleVectors (pm->ps->viewangles, pml.forward, pml.right, pml.up);\n\n\tif ( pm->cmd.upmove < 10 ) {\n\t\t// not holding jump\n\t\tpm->ps->pm_flags &= ~PMF_JUMP_HELD;\n\t}\n\n\t// decide if backpedaling animations should be used\n\tif ( pm->cmd.forwardmove < 0 ) {\n\t\tpm->ps->pm_flags |= PMF_BACKWARDS_RUN;\n\t} else if ( pm->cmd.forwardmove > 0 || ( pm->cmd.forwardmove == 0 && pm->cmd.rightmove ) ) {\n\t\tpm->ps->pm_flags &= ~PMF_BACKWARDS_RUN;\n\t}\n\n\tif ( pm->ps->pm_type >= PM_DEAD ) {\n\t\tpm->cmd.forwardmove = 0;\n\t\tpm->cmd.rightmove = 0;\n\t\tpm->cmd.upmove = 0;\n\t}\n\n\tif ( pm->ps->pm_type == PM_SPECTATOR ) {\n\t\tPM_CheckDuck ();\n\t\tPM_FlyMove ();\n\t\tPM_DropTimers ();\n\t\treturn;\n\t}\n\n\tif ( pm->ps->pm_type == PM_NOCLIP ) {\n\t\tPM_NoclipMove ();\n\t\tPM_DropTimers ();\n\t\treturn;\n\t}\n\n\tif (pm->ps->pm_type == PM_FREEZE) {\n\t\treturn;\t\t// no movement at all\n\t}\n\n\tif ( pm->ps->pm_type == PM_INTERMISSION || pm->ps->pm_type == PM_SPINTERMISSION) {\n\t\treturn;\t\t// no movement at all\n\t}\n\n\t// set watertype, and waterlevel\n\tPM_SetWaterLevel();\n\tpml.previous_waterlevel = pmove->waterlevel;\n\n\t// set mins, maxs, and viewheight\n\tPM_CheckDuck ();\n\n\t// set groundentity\n\tPM_GroundTrace();\n\n\tif ( pm->ps->pm_type == PM_DEAD ) {\n\t\tPM_DeadMove ();\n\t}\n\n\tPM_DropTimers();\n\n#ifdef MISSIONPACK\n\tif ( pm->ps->powerups[PW_INVULNERABILITY] ) {\n\t\tPM_InvulnerabilityMove();\n\t} else\n#endif\n\tif ( pm->ps->powerups[PW_FLIGHT] ) {\n\t\t// flight powerup doesn't allow jump and has different friction\n\t\tPM_FlyMove();\n\t} else if (pm->ps->pm_flags & PMF_GRAPPLE_PULL) {\n\t\tPM_GrappleMove();\n\t\t// We can wiggle a bit\n\t\tPM_AirMove();\n\t} else if (pm->ps->pm_flags & PMF_TIME_WATERJUMP) {\n\t\tPM_WaterJumpMove();\n\t} else if ( pm->waterlevel > 1 ) {\n\t\t// swimming\n\t\tPM_WaterMove();\n\t} else if ( pml.walking ) {\n\t\t// walking on ground\n\t\tPM_WalkMove();\n\t} else {\n\t\t// airborne\n\t\tPM_AirMove();\n\t}\n\n\tPM_Animate();\n\n\t// set groundentity, watertype, and waterlevel\n\tPM_GroundTrace();\n\tPM_SetWaterLevel();\n\n\t// weapons\n\tPM_Weapon();\n\n\t// torso animation\n\tPM_TorsoAnimation();\n\n\t// footstep events / legs animations\n\tPM_Footsteps();\n\n\t// entering / leaving water splashes\n\tPM_WaterEvents();\n\n\t// snap some parts of playerstate to save network bandwidth\n\ttrap_SnapVector( pm->ps->velocity );\n}\n\n\n/*\n================\nPmove\n\nCan be called by either the server or the client\n================\n*/\nvoid Pmove (pmove_t *pmove) {\n\tint\t\t\tfinalTime;\n\n\tfinalTime = pmove->cmd.serverTime;\n\n\tif ( finalTime < pmove->ps->commandTime ) {\n\t\treturn;\t// should not happen\n\t}\n\n\tif ( finalTime > pmove->ps->commandTime + 1000 ) {\n\t\tpmove->ps->commandTime = finalTime - 1000;\n\t}\n\n\tpmove->ps->pmove_framecount = (pmove->ps->pmove_framecount+1) & ((1<<PS_PMOVEFRAMECOUNTBITS)-1);\n\n\t// chop the move up if it is too long, to prevent framerate\n\t// dependent behavior\n\twhile ( pmove->ps->commandTime != finalTime ) {\n\t\tint\t\tmsec;\n\n\t\tmsec = finalTime - pmove->ps->commandTime;\n\n\t\tif ( pmove->pmove_fixed ) {\n\t\t\tif ( msec > pmove->pmove_msec ) {\n\t\t\t\tmsec = pmove->pmove_msec;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif ( msec > 66 ) {\n\t\t\t\tmsec = 66;\n\t\t\t}\n\t\t}\n\t\tpmove->cmd.serverTime = pmove->ps->commandTime + msec;\n\t\tPmoveSingle( pmove );\n\n\t\tif ( pmove->ps->pm_flags & PMF_JUMP_HELD ) {\n\t\t\tpmove->cmd.upmove = 20;\n\t\t}\n\t}\n\n\t//PM_CheckStuck();\n\n}\n\n"
  },
  {
    "path": "code/game/bg_public.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// bg_public.h -- definitions shared by both the server game and client game modules\n\n// because games can change separately from the main system version, we need a\n// second version that must match between game and cgame\n\n#define\tGAME_VERSION\t\t\"baseq3-1\"\n\n#define\tDEFAULT_GRAVITY\t\t800\n#define\tGIB_HEALTH\t\t\t-40\n#define\tARMOR_PROTECTION\t0.66\n\n#define\tMAX_ITEMS\t\t\t256\n\n#define\tRANK_TIED_FLAG\t\t0x4000\n\n#define DEFAULT_SHOTGUN_SPREAD\t700\n#define DEFAULT_SHOTGUN_COUNT\t11\n\n#define\tITEM_RADIUS\t\t\t15\t\t// item sizes are needed for client side pickup detection\n\n#define\tLIGHTNING_RANGE\t\t768\n\n#define\tSCORE_NOT_PRESENT\t-9999\t// for the CS_SCORES[12] when only one player is present\n\n#define\tVOTE_TIME\t\t\t30000\t// 30 seconds before vote times out\n\n#define\tMINS_Z\t\t\t\t-24\n#define\tDEFAULT_VIEWHEIGHT\t26\n#define CROUCH_VIEWHEIGHT\t12\n#define\tDEAD_VIEWHEIGHT\t\t-16\n\n//\n// config strings are a general means of communicating variable length strings\n// from the server to all connected clients.\n//\n\n// CS_SERVERINFO and CS_SYSTEMINFO are defined in q_shared.h\n#define\tCS_MUSIC\t\t\t\t2\n#define\tCS_MESSAGE\t\t\t\t3\t\t// from the map worldspawn's message field\n#define\tCS_MOTD\t\t\t\t\t4\t\t// g_motd string for server message of the day\n#define\tCS_WARMUP\t\t\t\t5\t\t// server time when the match will be restarted\n#define\tCS_SCORES1\t\t\t\t6\n#define\tCS_SCORES2\t\t\t\t7\n#define CS_VOTE_TIME\t\t\t8\n#define CS_VOTE_STRING\t\t\t9\n#define\tCS_VOTE_YES\t\t\t\t10\n#define\tCS_VOTE_NO\t\t\t\t11\n\n#define CS_TEAMVOTE_TIME\t\t12\n#define CS_TEAMVOTE_STRING\t\t14\n#define\tCS_TEAMVOTE_YES\t\t\t16\n#define\tCS_TEAMVOTE_NO\t\t\t18\n\n#define\tCS_GAME_VERSION\t\t\t20\n#define\tCS_LEVEL_START_TIME\t\t21\t\t// so the timer only shows the current level\n#define\tCS_INTERMISSION\t\t\t22\t\t// when 1, fraglimit/timelimit has been hit and intermission will start in a second or two\n#define CS_FLAGSTATUS\t\t\t23\t\t// string indicating flag status in CTF\n#define CS_SHADERSTATE\t\t\t24\n#define CS_BOTINFO\t\t\t\t25\n\n#define\tCS_ITEMS\t\t\t\t27\t\t// string of 0's and 1's that tell which items are present\n\n#define\tCS_MODELS\t\t\t\t32\n#define\tCS_SOUNDS\t\t\t\t(CS_MODELS+MAX_MODELS)\n#define\tCS_PLAYERS\t\t\t\t(CS_SOUNDS+MAX_SOUNDS)\n#define CS_LOCATIONS\t\t\t(CS_PLAYERS+MAX_CLIENTS)\n#define CS_PARTICLES\t\t\t(CS_LOCATIONS+MAX_LOCATIONS) \n\n#define CS_MAX\t\t\t\t\t(CS_PARTICLES+MAX_LOCATIONS)\n\n#if (CS_MAX) > MAX_CONFIGSTRINGS\n#error overflow: (CS_MAX) > MAX_CONFIGSTRINGS\n#endif\n\ntypedef enum {\n\tGT_FFA,\t\t\t\t// free for all\n\tGT_TOURNAMENT,\t\t// one on one tournament\n\tGT_SINGLE_PLAYER,\t// single player ffa\n\n\t//-- team games go after this --\n\n\tGT_TEAM,\t\t\t// team deathmatch\n\tGT_CTF,\t\t\t\t// capture the flag\n\tGT_1FCTF,\n\tGT_OBELISK,\n\tGT_HARVESTER,\n\tGT_MAX_GAME_TYPE\n} gametype_t;\n\ntypedef enum { GENDER_MALE, GENDER_FEMALE, GENDER_NEUTER } gender_t;\n\n/*\n===================================================================================\n\nPMOVE MODULE\n\nThe pmove code takes a player_state_t and a usercmd_t and generates a new player_state_t\nand some other output data.  Used for local prediction on the client game and true\nmovement on the server game.\n===================================================================================\n*/\n\ntypedef enum {\n\tPM_NORMAL,\t\t// can accelerate and turn\n\tPM_NOCLIP,\t\t// noclip movement\n\tPM_SPECTATOR,\t// still run into walls\n\tPM_DEAD,\t\t// no acceleration or turning, but free falling\n\tPM_FREEZE,\t\t// stuck in place with no control\n\tPM_INTERMISSION,\t// no movement or status bar\n\tPM_SPINTERMISSION\t// no movement or status bar\n} pmtype_t;\n\ntypedef enum {\n\tWEAPON_READY, \n\tWEAPON_RAISING,\n\tWEAPON_DROPPING,\n\tWEAPON_FIRING\n} weaponstate_t;\n\n// pmove->pm_flags\n#define\tPMF_DUCKED\t\t\t1\n#define\tPMF_JUMP_HELD\t\t2\n#define\tPMF_BACKWARDS_JUMP\t8\t\t// go into backwards land\n#define\tPMF_BACKWARDS_RUN\t16\t\t// coast down to backwards run\n#define\tPMF_TIME_LAND\t\t32\t\t// pm_time is time before rejump\n#define\tPMF_TIME_KNOCKBACK\t64\t\t// pm_time is an air-accelerate only time\n#define\tPMF_TIME_WATERJUMP\t256\t\t// pm_time is waterjump\n#define\tPMF_RESPAWNED\t\t512\t\t// clear after attack and jump buttons come up\n#define\tPMF_USE_ITEM_HELD\t1024\n#define PMF_GRAPPLE_PULL\t2048\t// pull towards grapple location\n#define PMF_FOLLOW\t\t\t4096\t// spectate following another player\n#define PMF_SCOREBOARD\t\t8192\t// spectate as a scoreboard\n#define PMF_INVULEXPAND\t\t16384\t// invulnerability sphere set to full size\n\n#define\tPMF_ALL_TIMES\t(PMF_TIME_WATERJUMP|PMF_TIME_LAND|PMF_TIME_KNOCKBACK)\n\n#define\tMAXTOUCH\t32\ntypedef struct {\n\t// state (in / out)\n\tplayerState_t\t*ps;\n\n\t// command (in)\n\tusercmd_t\tcmd;\n\tint\t\t\ttracemask;\t\t\t// collide against these types of surfaces\n\tint\t\t\tdebugLevel;\t\t\t// if set, diagnostic output will be printed\n\tqboolean\tnoFootsteps;\t\t// if the game is setup for no footsteps by the server\n\tqboolean\tgauntletHit;\t\t// true if a gauntlet attack would actually hit something\n\n\tint\t\t\tframecount;\n\n\t// results (out)\n\tint\t\t\tnumtouch;\n\tint\t\t\ttouchents[MAXTOUCH];\n\n\tvec3_t\t\tmins, maxs;\t\t\t// bounding box size\n\n\tint\t\t\twatertype;\n\tint\t\t\twaterlevel;\n\n\tfloat\t\txyspeed;\n\n\t// for fixed msec Pmove\n\tint\t\t\tpmove_fixed;\n\tint\t\t\tpmove_msec;\n\n\t// callbacks to test the world\n\t// these will be different functions during game and cgame\n\tvoid\t\t(*trace)( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask );\n\tint\t\t\t(*pointcontents)( const vec3_t point, int passEntityNum );\n} pmove_t;\n\n// if a full pmove isn't done on the client, you can just update the angles\nvoid PM_UpdateViewAngles( playerState_t *ps, const usercmd_t *cmd );\nvoid Pmove (pmove_t *pmove);\n\n//===================================================================================\n\n\n// player_state->stats[] indexes\n// NOTE: may not have more than 16\ntypedef enum {\n\tSTAT_HEALTH,\n\tSTAT_HOLDABLE_ITEM,\n#ifdef MISSIONPACK\n\tSTAT_PERSISTANT_POWERUP,\n#endif\n\tSTAT_WEAPONS,\t\t\t\t\t// 16 bit fields\n\tSTAT_ARMOR,\t\t\t\t\n\tSTAT_DEAD_YAW,\t\t\t\t\t// look this direction when dead (FIXME: get rid of?)\n\tSTAT_CLIENTS_READY,\t\t\t\t// bit mask of clients wishing to exit the intermission (FIXME: configstring?)\n\tSTAT_MAX_HEALTH\t\t\t\t\t// health / armor limit, changable by handicap\n} statIndex_t;\n\n\n// player_state->persistant[] indexes\n// these fields are the only part of player_state that isn't\n// cleared on respawn\n// NOTE: may not have more than 16\ntypedef enum {\n\tPERS_SCORE,\t\t\t\t\t\t// !!! MUST NOT CHANGE, SERVER AND GAME BOTH REFERENCE !!!\n\tPERS_HITS,\t\t\t\t\t\t// total points damage inflicted so damage beeps can sound on change\n\tPERS_RANK,\t\t\t\t\t\t// player rank or team rank\n\tPERS_TEAM,\t\t\t\t\t\t// player team\n\tPERS_SPAWN_COUNT,\t\t\t\t// incremented every respawn\n\tPERS_PLAYEREVENTS,\t\t\t\t// 16 bits that can be flipped for events\n\tPERS_ATTACKER,\t\t\t\t\t// clientnum of last damage inflicter\n\tPERS_ATTACKEE_ARMOR,\t\t\t// health/armor of last person we attacked\n\tPERS_KILLED,\t\t\t\t\t// count of the number of times you died\n\t// player awards tracking\n\tPERS_IMPRESSIVE_COUNT,\t\t\t// two railgun hits in a row\n\tPERS_EXCELLENT_COUNT,\t\t\t// two successive kills in a short amount of time\n\tPERS_DEFEND_COUNT,\t\t\t\t// defend awards\n\tPERS_ASSIST_COUNT,\t\t\t\t// assist awards\n\tPERS_GAUNTLET_FRAG_COUNT,\t\t// kills with the guantlet\n\tPERS_CAPTURES\t\t\t\t\t// captures\n} persEnum_t;\n\n\n// entityState_t->eFlags\n#define\tEF_DEAD\t\t\t\t0x00000001\t\t// don't draw a foe marker over players with EF_DEAD\n#ifdef MISSIONPACK\n#define EF_TICKING\t\t\t0x00000002\t\t// used to make players play the prox mine ticking sound\n#endif\n#define\tEF_TELEPORT_BIT\t\t0x00000004\t\t// toggled every time the origin abruptly changes\n#define\tEF_AWARD_EXCELLENT\t0x00000008\t\t// draw an excellent sprite\n#define EF_PLAYER_EVENT\t\t0x00000010\n#define\tEF_BOUNCE\t\t\t0x00000010\t\t// for missiles\n#define\tEF_BOUNCE_HALF\t\t0x00000020\t\t// for missiles\n#define\tEF_AWARD_GAUNTLET\t0x00000040\t\t// draw a gauntlet sprite\n#define\tEF_NODRAW\t\t\t0x00000080\t\t// may have an event, but no model (unspawned items)\n#define\tEF_FIRING\t\t\t0x00000100\t\t// for lightning gun\n#define\tEF_KAMIKAZE\t\t\t0x00000200\n#define\tEF_MOVER_STOP\t\t0x00000400\t\t// will push otherwise\n#define EF_AWARD_CAP\t\t0x00000800\t\t// draw the capture sprite\n#define\tEF_TALK\t\t\t\t0x00001000\t\t// draw a talk balloon\n#define\tEF_CONNECTION\t\t0x00002000\t\t// draw a connection trouble sprite\n#define\tEF_VOTED\t\t\t0x00004000\t\t// already cast a vote\n#define\tEF_AWARD_IMPRESSIVE\t0x00008000\t\t// draw an impressive sprite\n#define\tEF_AWARD_DEFEND\t\t0x00010000\t\t// draw a defend sprite\n#define\tEF_AWARD_ASSIST\t\t0x00020000\t\t// draw a assist sprite\n#define EF_AWARD_DENIED\t\t0x00040000\t\t// denied\n#define EF_TEAMVOTED\t\t0x00080000\t\t// already cast a team vote\n\n// NOTE: may not have more than 16\ntypedef enum {\n\tPW_NONE,\n\n\tPW_QUAD,\n\tPW_BATTLESUIT,\n\tPW_HASTE,\n\tPW_INVIS,\n\tPW_REGEN,\n\tPW_FLIGHT,\n\n\tPW_REDFLAG,\n\tPW_BLUEFLAG,\n\tPW_NEUTRALFLAG,\n\n\tPW_SCOUT,\n\tPW_GUARD,\n\tPW_DOUBLER,\n\tPW_AMMOREGEN,\n\tPW_INVULNERABILITY,\n\n\tPW_NUM_POWERUPS\n\n} powerup_t;\n\ntypedef enum {\n\tHI_NONE,\n\n\tHI_TELEPORTER,\n\tHI_MEDKIT,\n\tHI_KAMIKAZE,\n\tHI_PORTAL,\n\tHI_INVULNERABILITY,\n\n\tHI_NUM_HOLDABLE\n} holdable_t;\n\n\ntypedef enum {\n\tWP_NONE,\n\n\tWP_GAUNTLET,\n\tWP_MACHINEGUN,\n\tWP_SHOTGUN,\n\tWP_GRENADE_LAUNCHER,\n\tWP_ROCKET_LAUNCHER,\n\tWP_LIGHTNING,\n\tWP_RAILGUN,\n\tWP_PLASMAGUN,\n\tWP_BFG,\n\tWP_GRAPPLING_HOOK,\n#ifdef MISSIONPACK\n\tWP_NAILGUN,\n\tWP_PROX_LAUNCHER,\n\tWP_CHAINGUN,\n#endif\n\n\tWP_NUM_WEAPONS\n} weapon_t;\n\n\n// reward sounds (stored in ps->persistant[PERS_PLAYEREVENTS])\n#define\tPLAYEREVENT_DENIEDREWARD\t\t0x0001\n#define\tPLAYEREVENT_GAUNTLETREWARD\t\t0x0002\n#define PLAYEREVENT_HOLYSHIT\t\t\t0x0004\n\n// entityState_t->event values\n// entity events are for effects that take place reletive\n// to an existing entities origin.  Very network efficient.\n\n// two bits at the top of the entityState->event field\n// will be incremented with each change in the event so\n// that an identical event started twice in a row can\n// be distinguished.  And off the value with ~EV_EVENT_BITS\n// to retrieve the actual event number\n#define\tEV_EVENT_BIT1\t\t0x00000100\n#define\tEV_EVENT_BIT2\t\t0x00000200\n#define\tEV_EVENT_BITS\t\t(EV_EVENT_BIT1|EV_EVENT_BIT2)\n\n#define\tEVENT_VALID_MSEC\t300\n\ntypedef enum {\n\tEV_NONE,\n\n\tEV_FOOTSTEP,\n\tEV_FOOTSTEP_METAL,\n\tEV_FOOTSPLASH,\n\tEV_FOOTWADE,\n\tEV_SWIM,\n\n\tEV_STEP_4,\n\tEV_STEP_8,\n\tEV_STEP_12,\n\tEV_STEP_16,\n\n\tEV_FALL_SHORT,\n\tEV_FALL_MEDIUM,\n\tEV_FALL_FAR,\n\n\tEV_JUMP_PAD,\t\t\t// boing sound at origin, jump sound on player\n\n\tEV_JUMP,\n\tEV_WATER_TOUCH,\t// foot touches\n\tEV_WATER_LEAVE,\t// foot leaves\n\tEV_WATER_UNDER,\t// head touches\n\tEV_WATER_CLEAR,\t// head leaves\n\n\tEV_ITEM_PICKUP,\t\t\t// normal item pickups are predictable\n\tEV_GLOBAL_ITEM_PICKUP,\t// powerup / team sounds are broadcast to everyone\n\n\tEV_NOAMMO,\n\tEV_CHANGE_WEAPON,\n\tEV_FIRE_WEAPON,\n\n\tEV_USE_ITEM0,\n\tEV_USE_ITEM1,\n\tEV_USE_ITEM2,\n\tEV_USE_ITEM3,\n\tEV_USE_ITEM4,\n\tEV_USE_ITEM5,\n\tEV_USE_ITEM6,\n\tEV_USE_ITEM7,\n\tEV_USE_ITEM8,\n\tEV_USE_ITEM9,\n\tEV_USE_ITEM10,\n\tEV_USE_ITEM11,\n\tEV_USE_ITEM12,\n\tEV_USE_ITEM13,\n\tEV_USE_ITEM14,\n\tEV_USE_ITEM15,\n\n\tEV_ITEM_RESPAWN,\n\tEV_ITEM_POP,\n\tEV_PLAYER_TELEPORT_IN,\n\tEV_PLAYER_TELEPORT_OUT,\n\n\tEV_GRENADE_BOUNCE,\t\t// eventParm will be the soundindex\n\n\tEV_GENERAL_SOUND,\n\tEV_GLOBAL_SOUND,\t\t// no attenuation\n\tEV_GLOBAL_TEAM_SOUND,\n\n\tEV_BULLET_HIT_FLESH,\n\tEV_BULLET_HIT_WALL,\n\n\tEV_MISSILE_HIT,\n\tEV_MISSILE_MISS,\n\tEV_MISSILE_MISS_METAL,\n\tEV_RAILTRAIL,\n\tEV_SHOTGUN,\n\tEV_BULLET,\t\t\t\t// otherEntity is the shooter\n\n\tEV_PAIN,\n\tEV_DEATH1,\n\tEV_DEATH2,\n\tEV_DEATH3,\n\tEV_OBITUARY,\n\n\tEV_POWERUP_QUAD,\n\tEV_POWERUP_BATTLESUIT,\n\tEV_POWERUP_REGEN,\n\n\tEV_GIB_PLAYER,\t\t\t// gib a previously living player\n\tEV_SCOREPLUM,\t\t\t// score plum\n\n//#ifdef MISSIONPACK\n\tEV_PROXIMITY_MINE_STICK,\n\tEV_PROXIMITY_MINE_TRIGGER,\n\tEV_KAMIKAZE,\t\t\t// kamikaze explodes\n\tEV_OBELISKEXPLODE,\t\t// obelisk explodes\n\tEV_OBELISKPAIN,\t\t\t// obelisk is in pain\n\tEV_INVUL_IMPACT,\t\t// invulnerability sphere impact\n\tEV_JUICED,\t\t\t\t// invulnerability juiced effect\n\tEV_LIGHTNINGBOLT,\t\t// lightning bolt bounced of invulnerability sphere\n//#endif\n\n\tEV_DEBUG_LINE,\n\tEV_STOPLOOPINGSOUND,\n\tEV_TAUNT,\n\tEV_TAUNT_YES,\n\tEV_TAUNT_NO,\n\tEV_TAUNT_FOLLOWME,\n\tEV_TAUNT_GETFLAG,\n\tEV_TAUNT_GUARDBASE,\n\tEV_TAUNT_PATROL\n\n} entity_event_t;\n\n\ntypedef enum {\n\tGTS_RED_CAPTURE,\n\tGTS_BLUE_CAPTURE,\n\tGTS_RED_RETURN,\n\tGTS_BLUE_RETURN,\n\tGTS_RED_TAKEN,\n\tGTS_BLUE_TAKEN,\n\tGTS_REDOBELISK_ATTACKED,\n\tGTS_BLUEOBELISK_ATTACKED,\n\tGTS_REDTEAM_SCORED,\n\tGTS_BLUETEAM_SCORED,\n\tGTS_REDTEAM_TOOK_LEAD,\n\tGTS_BLUETEAM_TOOK_LEAD,\n\tGTS_TEAMS_ARE_TIED,\n\tGTS_KAMIKAZE\n} global_team_sound_t;\n\n// animations\ntypedef enum {\n\tBOTH_DEATH1,\n\tBOTH_DEAD1,\n\tBOTH_DEATH2,\n\tBOTH_DEAD2,\n\tBOTH_DEATH3,\n\tBOTH_DEAD3,\n\n\tTORSO_GESTURE,\n\n\tTORSO_ATTACK,\n\tTORSO_ATTACK2,\n\n\tTORSO_DROP,\n\tTORSO_RAISE,\n\n\tTORSO_STAND,\n\tTORSO_STAND2,\n\n\tLEGS_WALKCR,\n\tLEGS_WALK,\n\tLEGS_RUN,\n\tLEGS_BACK,\n\tLEGS_SWIM,\n\n\tLEGS_JUMP,\n\tLEGS_LAND,\n\n\tLEGS_JUMPB,\n\tLEGS_LANDB,\n\n\tLEGS_IDLE,\n\tLEGS_IDLECR,\n\n\tLEGS_TURN,\n\n\tTORSO_GETFLAG,\n\tTORSO_GUARDBASE,\n\tTORSO_PATROL,\n\tTORSO_FOLLOWME,\n\tTORSO_AFFIRMATIVE,\n\tTORSO_NEGATIVE,\n\n\tMAX_ANIMATIONS,\n\n\tLEGS_BACKCR,\n\tLEGS_BACKWALK,\n\tFLAG_RUN,\n\tFLAG_STAND,\n\tFLAG_STAND2RUN,\n\n\tMAX_TOTALANIMATIONS\n} animNumber_t;\n\n\ntypedef struct animation_s {\n\tint\t\tfirstFrame;\n\tint\t\tnumFrames;\n\tint\t\tloopFrames;\t\t\t// 0 to numFrames\n\tint\t\tframeLerp;\t\t\t// msec between frames\n\tint\t\tinitialLerp;\t\t// msec to get to first frame\n\tint\t\treversed;\t\t\t// true if animation is reversed\n\tint\t\tflipflop;\t\t\t// true if animation should flipflop back to base\n} animation_t;\n\n\n// flip the togglebit every time an animation\n// changes so a restart of the same anim can be detected\n#define\tANIM_TOGGLEBIT\t\t128\n\n\ntypedef enum {\n\tTEAM_FREE,\n\tTEAM_RED,\n\tTEAM_BLUE,\n\tTEAM_SPECTATOR,\n\n\tTEAM_NUM_TEAMS\n} team_t;\n\n// Time between location updates\n#define TEAM_LOCATION_UPDATE_TIME\t\t1000\n\n// How many players on the overlay\n#define TEAM_MAXOVERLAY\t\t32\n\n//team task\ntypedef enum {\n\tTEAMTASK_NONE,\n\tTEAMTASK_OFFENSE, \n\tTEAMTASK_DEFENSE,\n\tTEAMTASK_PATROL,\n\tTEAMTASK_FOLLOW,\n\tTEAMTASK_RETRIEVE,\n\tTEAMTASK_ESCORT,\n\tTEAMTASK_CAMP\n} teamtask_t;\n\n// means of death\ntypedef enum {\n\tMOD_UNKNOWN,\n\tMOD_SHOTGUN,\n\tMOD_GAUNTLET,\n\tMOD_MACHINEGUN,\n\tMOD_GRENADE,\n\tMOD_GRENADE_SPLASH,\n\tMOD_ROCKET,\n\tMOD_ROCKET_SPLASH,\n\tMOD_PLASMA,\n\tMOD_PLASMA_SPLASH,\n\tMOD_RAILGUN,\n\tMOD_LIGHTNING,\n\tMOD_BFG,\n\tMOD_BFG_SPLASH,\n\tMOD_WATER,\n\tMOD_SLIME,\n\tMOD_LAVA,\n\tMOD_CRUSH,\n\tMOD_TELEFRAG,\n\tMOD_FALLING,\n\tMOD_SUICIDE,\n\tMOD_TARGET_LASER,\n\tMOD_TRIGGER_HURT,\n#ifdef MISSIONPACK\n\tMOD_NAIL,\n\tMOD_CHAINGUN,\n\tMOD_PROXIMITY_MINE,\n\tMOD_KAMIKAZE,\n\tMOD_JUICED,\n#endif\n\tMOD_GRAPPLE\n} meansOfDeath_t;\n\n\n//---------------------------------------------------------\n\n// gitem_t->type\ntypedef enum {\n\tIT_BAD,\n\tIT_WEAPON,\t\t\t\t// EFX: rotate + upscale + minlight\n\tIT_AMMO,\t\t\t\t// EFX: rotate\n\tIT_ARMOR,\t\t\t\t// EFX: rotate + minlight\n\tIT_HEALTH,\t\t\t\t// EFX: static external sphere + rotating internal\n\tIT_POWERUP,\t\t\t\t// instant on, timer based\n\t\t\t\t\t\t\t// EFX: rotate + external ring that rotates\n\tIT_HOLDABLE,\t\t\t// single use, holdable item\n\t\t\t\t\t\t\t// EFX: rotate + bob\n\tIT_PERSISTANT_POWERUP,\n\tIT_TEAM\n} itemType_t;\n\n#define MAX_ITEM_MODELS 4\n\ntypedef struct gitem_s {\n\tchar\t\t*classname;\t// spawning name\n\tchar\t\t*pickup_sound;\n\tchar\t\t*world_model[MAX_ITEM_MODELS];\n\n\tchar\t\t*icon;\n\tchar\t\t*pickup_name;\t// for printing on pickup\n\n\tint\t\t\tquantity;\t\t// for ammo how much, or duration of powerup\n\titemType_t  giType;\t\t\t// IT_* flags\n\n\tint\t\t\tgiTag;\n\n\tchar\t\t*precaches;\t\t// string of all models and images this item will use\n\tchar\t\t*sounds;\t\t// string of all sounds this item will use\n} gitem_t;\n\n// included in both the game dll and the client\nextern\tgitem_t\tbg_itemlist[];\nextern\tint\t\tbg_numItems;\n\ngitem_t\t*BG_FindItem( const char *pickupName );\ngitem_t\t*BG_FindItemForWeapon( weapon_t weapon );\ngitem_t\t*BG_FindItemForPowerup( powerup_t pw );\ngitem_t\t*BG_FindItemForHoldable( holdable_t pw );\n#define\tITEM_INDEX(x) ((x)-bg_itemlist)\n\nqboolean\tBG_CanItemBeGrabbed( int gametype, const entityState_t *ent, const playerState_t *ps );\n\n\n// g_dmflags->integer flags\n#define\tDF_NO_FALLING\t\t\t8\n#define DF_FIXED_FOV\t\t\t16\n#define\tDF_NO_FOOTSTEPS\t\t\t32\n\n// content masks\n#define\tMASK_ALL\t\t\t\t(-1)\n#define\tMASK_SOLID\t\t\t\t(CONTENTS_SOLID)\n#define\tMASK_PLAYERSOLID\t\t(CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_BODY)\n#define\tMASK_DEADSOLID\t\t\t(CONTENTS_SOLID|CONTENTS_PLAYERCLIP)\n#define\tMASK_WATER\t\t\t\t(CONTENTS_WATER|CONTENTS_LAVA|CONTENTS_SLIME)\n#define\tMASK_OPAQUE\t\t\t\t(CONTENTS_SOLID|CONTENTS_SLIME|CONTENTS_LAVA)\n#define\tMASK_SHOT\t\t\t\t(CONTENTS_SOLID|CONTENTS_BODY|CONTENTS_CORPSE)\n\n\n//\n// entityState_t->eType\n//\ntypedef enum {\n\tET_GENERAL,\n\tET_PLAYER,\n\tET_ITEM,\n\tET_MISSILE,\n\tET_MOVER,\n\tET_BEAM,\n\tET_PORTAL,\n\tET_SPEAKER,\n\tET_PUSH_TRIGGER,\n\tET_TELEPORT_TRIGGER,\n\tET_INVISIBLE,\n\tET_GRAPPLE,\t\t\t\t// grapple hooked on wall\n\tET_TEAM,\n\n\tET_EVENTS\t\t\t\t// any of the EV_* events can be added freestanding\n\t\t\t\t\t\t\t// by setting eType to ET_EVENTS + eventNum\n\t\t\t\t\t\t\t// this avoids having to set eFlags and eventNum\n} entityType_t;\n\n\n\nvoid\tBG_EvaluateTrajectory( const trajectory_t *tr, int atTime, vec3_t result );\nvoid\tBG_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t result );\n\nvoid\tBG_AddPredictableEventToPlayerstate( int newEvent, int eventParm, playerState_t *ps );\n\nvoid\tBG_TouchJumpPad( playerState_t *ps, entityState_t *jumppad );\n\nvoid\tBG_PlayerStateToEntityState( playerState_t *ps, entityState_t *s, qboolean snap );\nvoid\tBG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s, int time, qboolean snap );\n\nqboolean\tBG_PlayerTouchesItem( playerState_t *ps, entityState_t *item, int atTime );\n\n\n#define ARENAS_PER_TIER\t\t4\n#define MAX_ARENAS\t\t\t1024\n#define\tMAX_ARENAS_TEXT\t\t8192\n\n#define MAX_BOTS\t\t\t1024\n#define MAX_BOTS_TEXT\t\t8192\n\n\n// Kamikaze\n\n// 1st shockwave times\n#define KAMI_SHOCKWAVE_STARTTIME\t\t0\n#define KAMI_SHOCKWAVEFADE_STARTTIME\t1500\n#define KAMI_SHOCKWAVE_ENDTIME\t\t\t2000\n// explosion/implosion times\n#define KAMI_EXPLODE_STARTTIME\t\t\t250\n#define KAMI_IMPLODE_STARTTIME\t\t\t2000\n#define KAMI_IMPLODE_ENDTIME\t\t\t2250\n// 2nd shockwave times\n#define KAMI_SHOCKWAVE2_STARTTIME\t\t2000\n#define KAMI_SHOCKWAVE2FADE_STARTTIME\t2500\n#define KAMI_SHOCKWAVE2_ENDTIME\t\t\t3000\n// radius of the models without scaling\n#define KAMI_SHOCKWAVEMODEL_RADIUS\t\t88\n#define KAMI_BOOMSPHEREMODEL_RADIUS\t\t72\n// maximum radius of the models during the effect\n#define KAMI_SHOCKWAVE_MAXRADIUS\t\t1320\n#define KAMI_BOOMSPHERE_MAXRADIUS\t\t720\n#define KAMI_SHOCKWAVE2_MAXRADIUS\t\t704\n\n"
  },
  {
    "path": "code/game/bg_slidemove.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// bg_slidemove.c -- part of bg_pmove functionality\n\n#include \"q_shared.h\"\n#include \"bg_public.h\"\n#include \"bg_local.h\"\n\n/*\n\ninput: origin, velocity, bounds, groundPlane, trace function\n\noutput: origin, velocity, impacts, stairup boolean\n\n*/\n\n/*\n==================\nPM_SlideMove\n\nReturns qtrue if the velocity was clipped in some way\n==================\n*/\n#define\tMAX_CLIP_PLANES\t5\nqboolean\tPM_SlideMove( qboolean gravity ) {\n\tint\t\t\tbumpcount, numbumps;\n\tvec3_t\t\tdir;\n\tfloat\t\td;\n\tint\t\t\tnumplanes;\n\tvec3_t\t\tplanes[MAX_CLIP_PLANES];\n\tvec3_t\t\tprimal_velocity;\n\tvec3_t\t\tclipVelocity;\n\tint\t\t\ti, j, k;\n\ttrace_t\ttrace;\n\tvec3_t\t\tend;\n\tfloat\t\ttime_left;\n\tfloat\t\tinto;\n\tvec3_t\t\tendVelocity;\n\tvec3_t\t\tendClipVelocity;\n\t\n\tnumbumps = 4;\n\n\tVectorCopy (pm->ps->velocity, primal_velocity);\n\n\tif ( gravity ) {\n\t\tVectorCopy( pm->ps->velocity, endVelocity );\n\t\tendVelocity[2] -= pm->ps->gravity * pml.frametime;\n\t\tpm->ps->velocity[2] = ( pm->ps->velocity[2] + endVelocity[2] ) * 0.5;\n\t\tprimal_velocity[2] = endVelocity[2];\n\t\tif ( pml.groundPlane ) {\n\t\t\t// slide along the ground plane\n\t\t\tPM_ClipVelocity (pm->ps->velocity, pml.groundTrace.plane.normal, \n\t\t\t\tpm->ps->velocity, OVERCLIP );\n\t\t}\n\t}\n\n\ttime_left = pml.frametime;\n\n\t// never turn against the ground plane\n\tif ( pml.groundPlane ) {\n\t\tnumplanes = 1;\n\t\tVectorCopy( pml.groundTrace.plane.normal, planes[0] );\n\t} else {\n\t\tnumplanes = 0;\n\t}\n\n\t// never turn against original velocity\n\tVectorNormalize2( pm->ps->velocity, planes[numplanes] );\n\tnumplanes++;\n\n\tfor ( bumpcount=0 ; bumpcount < numbumps ; bumpcount++ ) {\n\n\t\t// calculate position we are trying to move to\n\t\tVectorMA( pm->ps->origin, time_left, pm->ps->velocity, end );\n\n\t\t// see if we can make it there\n\t\tpm->trace ( &trace, pm->ps->origin, pm->mins, pm->maxs, end, pm->ps->clientNum, pm->tracemask);\n\n\t\tif (trace.allsolid) {\n\t\t\t// entity is completely trapped in another solid\n\t\t\tpm->ps->velocity[2] = 0;\t// don't build up falling damage, but allow sideways acceleration\n\t\t\treturn qtrue;\n\t\t}\n\n\t\tif (trace.fraction > 0) {\n\t\t\t// actually covered some distance\n\t\t\tVectorCopy (trace.endpos, pm->ps->origin);\n\t\t}\n\n\t\tif (trace.fraction == 1) {\n\t\t\t break;\t\t// moved the entire distance\n\t\t}\n\n\t\t// save entity for contact\n\t\tPM_AddTouchEnt( trace.entityNum );\n\n\t\ttime_left -= time_left * trace.fraction;\n\n\t\tif (numplanes >= MAX_CLIP_PLANES) {\n\t\t\t// this shouldn't really happen\n\t\t\tVectorClear( pm->ps->velocity );\n\t\t\treturn qtrue;\n\t\t}\n\n\t\t//\n\t\t// if this is the same plane we hit before, nudge velocity\n\t\t// out along it, which fixes some epsilon issues with\n\t\t// non-axial planes\n\t\t//\n\t\tfor ( i = 0 ; i < numplanes ; i++ ) {\n\t\t\tif ( DotProduct( trace.plane.normal, planes[i] ) > 0.99 ) {\n\t\t\t\tVectorAdd( trace.plane.normal, pm->ps->velocity, pm->ps->velocity );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif ( i < numplanes ) {\n\t\t\tcontinue;\n\t\t}\n\t\tVectorCopy (trace.plane.normal, planes[numplanes]);\n\t\tnumplanes++;\n\n\t\t//\n\t\t// modify velocity so it parallels all of the clip planes\n\t\t//\n\n\t\t// find a plane that it enters\n\t\tfor ( i = 0 ; i < numplanes ; i++ ) {\n\t\t\tinto = DotProduct( pm->ps->velocity, planes[i] );\n\t\t\tif ( into >= 0.1 ) {\n\t\t\t\tcontinue;\t\t// move doesn't interact with the plane\n\t\t\t}\n\n\t\t\t// see how hard we are hitting things\n\t\t\tif ( -into > pml.impactSpeed ) {\n\t\t\t\tpml.impactSpeed = -into;\n\t\t\t}\n\n\t\t\t// slide along the plane\n\t\t\tPM_ClipVelocity (pm->ps->velocity, planes[i], clipVelocity, OVERCLIP );\n\n\t\t\t// slide along the plane\n\t\t\tPM_ClipVelocity (endVelocity, planes[i], endClipVelocity, OVERCLIP );\n\n\t\t\t// see if there is a second plane that the new move enters\n\t\t\tfor ( j = 0 ; j < numplanes ; j++ ) {\n\t\t\t\tif ( j == i ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif ( DotProduct( clipVelocity, planes[j] ) >= 0.1 ) {\n\t\t\t\t\tcontinue;\t\t// move doesn't interact with the plane\n\t\t\t\t}\n\n\t\t\t\t// try clipping the move to the plane\n\t\t\t\tPM_ClipVelocity( clipVelocity, planes[j], clipVelocity, OVERCLIP );\n\t\t\t\tPM_ClipVelocity( endClipVelocity, planes[j], endClipVelocity, OVERCLIP );\n\n\t\t\t\t// see if it goes back into the first clip plane\n\t\t\t\tif ( DotProduct( clipVelocity, planes[i] ) >= 0 ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// slide the original velocity along the crease\n\t\t\t\tCrossProduct (planes[i], planes[j], dir);\n\t\t\t\tVectorNormalize( dir );\n\t\t\t\td = DotProduct( dir, pm->ps->velocity );\n\t\t\t\tVectorScale( dir, d, clipVelocity );\n\n\t\t\t\tCrossProduct (planes[i], planes[j], dir);\n\t\t\t\tVectorNormalize( dir );\n\t\t\t\td = DotProduct( dir, endVelocity );\n\t\t\t\tVectorScale( dir, d, endClipVelocity );\n\n\t\t\t\t// see if there is a third plane the the new move enters\n\t\t\t\tfor ( k = 0 ; k < numplanes ; k++ ) {\n\t\t\t\t\tif ( k == i || k == j ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif ( DotProduct( clipVelocity, planes[k] ) >= 0.1 ) {\n\t\t\t\t\t\tcontinue;\t\t// move doesn't interact with the plane\n\t\t\t\t\t}\n\n\t\t\t\t\t// stop dead at a tripple plane interaction\n\t\t\t\t\tVectorClear( pm->ps->velocity );\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// if we have fixed all interactions, try another move\n\t\t\tVectorCopy( clipVelocity, pm->ps->velocity );\n\t\t\tVectorCopy( endClipVelocity, endVelocity );\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif ( gravity ) {\n\t\tVectorCopy( endVelocity, pm->ps->velocity );\n\t}\n\n\t// don't change velocity if in a timer (FIXME: is this correct?)\n\tif ( pm->ps->pm_time ) {\n\t\tVectorCopy( primal_velocity, pm->ps->velocity );\n\t}\n\n\treturn ( bumpcount != 0 );\n}\n\n/*\n==================\nPM_StepSlideMove\n\n==================\n*/\nvoid PM_StepSlideMove( qboolean gravity ) {\n\tvec3_t\t\tstart_o, start_v;\n\tvec3_t\t\tdown_o, down_v;\n\ttrace_t\t\ttrace;\n//\tfloat\t\tdown_dist, up_dist;\n//\tvec3_t\t\tdelta, delta2;\n\tvec3_t\t\tup, down;\n\tfloat\t\tstepSize;\n\n\tVectorCopy (pm->ps->origin, start_o);\n\tVectorCopy (pm->ps->velocity, start_v);\n\n\tif ( PM_SlideMove( gravity ) == 0 ) {\n\t\treturn;\t\t// we got exactly where we wanted to go first try\t\n\t}\n\n\tVectorCopy(start_o, down);\n\tdown[2] -= STEPSIZE;\n\tpm->trace (&trace, start_o, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask);\n\tVectorSet(up, 0, 0, 1);\n\t// never step up when you still have up velocity\n\tif ( pm->ps->velocity[2] > 0 && (trace.fraction == 1.0 ||\n\t\t\t\t\t\t\t\t\t\tDotProduct(trace.plane.normal, up) < 0.7)) {\n\t\treturn;\n\t}\n\n\tVectorCopy (pm->ps->origin, down_o);\n\tVectorCopy (pm->ps->velocity, down_v);\n\n\tVectorCopy (start_o, up);\n\tup[2] += STEPSIZE;\n\n\t// test the player position if they were a stepheight higher\n\tpm->trace (&trace, start_o, pm->mins, pm->maxs, up, pm->ps->clientNum, pm->tracemask);\n\tif ( trace.allsolid ) {\n\t\tif ( pm->debugLevel ) {\n\t\t\tCom_Printf(\"%i:bend can't step\\n\", c_pmove);\n\t\t}\n\t\treturn;\t\t// can't step up\n\t}\n\n\tstepSize = trace.endpos[2] - start_o[2];\n\t// try slidemove from this position\n\tVectorCopy (trace.endpos, pm->ps->origin);\n\tVectorCopy (start_v, pm->ps->velocity);\n\n\tPM_SlideMove( gravity );\n\n\t// push down the final amount\n\tVectorCopy (pm->ps->origin, down);\n\tdown[2] -= stepSize;\n\tpm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask);\n\tif ( !trace.allsolid ) {\n\t\tVectorCopy (trace.endpos, pm->ps->origin);\n\t}\n\tif ( trace.fraction < 1.0 ) {\n\t\tPM_ClipVelocity( pm->ps->velocity, trace.plane.normal, pm->ps->velocity, OVERCLIP );\n\t}\n\n#if 0\n\t// if the down trace can trace back to the original position directly, don't step\n\tpm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, start_o, pm->ps->clientNum, pm->tracemask);\n\tif ( trace.fraction == 1.0 ) {\n\t\t// use the original move\n\t\tVectorCopy (down_o, pm->ps->origin);\n\t\tVectorCopy (down_v, pm->ps->velocity);\n\t\tif ( pm->debugLevel ) {\n\t\t\tCom_Printf(\"%i:bend\\n\", c_pmove);\n\t\t}\n\t} else \n#endif\n\t{\n\t\t// use the step move\n\t\tfloat\tdelta;\n\n\t\tdelta = pm->ps->origin[2] - start_o[2];\n\t\tif ( delta > 2 ) {\n\t\t\tif ( delta < 7 ) {\n\t\t\t\tPM_AddEvent( EV_STEP_4 );\n\t\t\t} else if ( delta < 11 ) {\n\t\t\t\tPM_AddEvent( EV_STEP_8 );\n\t\t\t} else if ( delta < 15 ) {\n\t\t\t\tPM_AddEvent( EV_STEP_12 );\n\t\t\t} else {\n\t\t\t\tPM_AddEvent( EV_STEP_16 );\n\t\t\t}\n\t\t}\n\t\tif ( pm->debugLevel ) {\n\t\t\tCom_Printf(\"%i:stepped\\n\", c_pmove);\n\t\t}\n\t}\n}\n\n"
  },
  {
    "path": "code/game/botlib.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*****************************************************************************\n * name:\t\tbotlib.h\n *\n * desc:\t\tbot AI library\n *\n * $Archive: /source/code/game/botai.h $\n *\n *****************************************************************************/\n\n#define\tBOTLIB_API_VERSION\t\t2\n\nstruct aas_clientmove_s;\nstruct aas_entityinfo_s;\nstruct aas_areainfo_s;\nstruct aas_altroutegoal_s;\nstruct aas_predictroute_s;\nstruct bot_consolemessage_s;\nstruct bot_match_s;\nstruct bot_goal_s;\nstruct bot_moveresult_s;\nstruct bot_initmove_s;\nstruct weaponinfo_s;\n\n#define BOTFILESBASEFOLDER\t\t\"botfiles\"\n//debug line colors\n#define LINECOLOR_NONE\t\t\t-1\n#define LINECOLOR_RED\t\t\t1//0xf2f2f0f0L\n#define LINECOLOR_GREEN\t\t\t2//0xd0d1d2d3L\n#define LINECOLOR_BLUE\t\t\t3//0xf3f3f1f1L\n#define LINECOLOR_YELLOW\t\t4//0xdcdddedfL\n#define LINECOLOR_ORANGE\t\t5//0xe0e1e2e3L\n\n//Print types\n#define PRT_MESSAGE\t\t\t\t1\n#define PRT_WARNING\t\t\t\t2\n#define PRT_ERROR\t\t\t\t3\n#define PRT_FATAL\t\t\t\t4\n#define PRT_EXIT\t\t\t\t5\n\n//console message types\n#define CMS_NORMAL\t\t\t\t0\n#define CMS_CHAT\t\t\t\t1\n\n//botlib error codes\n#define BLERR_NOERROR\t\t\t\t\t0\t//no error\n#define BLERR_LIBRARYNOTSETUP\t\t\t1\t//library not setup\n#define BLERR_INVALIDENTITYNUMBER\t\t2\t//invalid entity number\n#define BLERR_NOAASFILE\t\t\t\t\t3\t//no AAS file available\n#define BLERR_CANNOTOPENAASFILE\t\t\t4\t//cannot open AAS file\n#define BLERR_WRONGAASFILEID\t\t\t5\t//incorrect AAS file id\n#define BLERR_WRONGAASFILEVERSION\t\t6\t//incorrect AAS file version\n#define BLERR_CANNOTREADAASLUMP\t\t\t7\t//cannot read AAS file lump\n#define BLERR_CANNOTLOADICHAT\t\t\t8\t//cannot load initial chats\n#define BLERR_CANNOTLOADITEMWEIGHTS\t\t9\t//cannot load item weights\n#define BLERR_CANNOTLOADITEMCONFIG\t\t10\t//cannot load item config\n#define BLERR_CANNOTLOADWEAPONWEIGHTS\t11\t//cannot load weapon weights\n#define BLERR_CANNOTLOADWEAPONCONFIG\t12\t//cannot load weapon config\n\n//action flags\n#define ACTION_ATTACK\t\t\t0x0000001\n#define ACTION_USE\t\t\t\t0x0000002\n#define ACTION_RESPAWN\t\t\t0x0000008\n#define ACTION_JUMP\t\t\t\t0x0000010\n#define ACTION_MOVEUP\t\t\t0x0000020\n#define ACTION_CROUCH\t\t\t0x0000080\n#define ACTION_MOVEDOWN\t\t\t0x0000100\n#define ACTION_MOVEFORWARD\t\t0x0000200\n#define ACTION_MOVEBACK\t\t\t0x0000800\n#define ACTION_MOVELEFT\t\t\t0x0001000\n#define ACTION_MOVERIGHT\t\t0x0002000\n#define ACTION_DELAYEDJUMP\t\t0x0008000\n#define ACTION_TALK\t\t\t\t0x0010000\n#define ACTION_GESTURE\t\t\t0x0020000\n#define ACTION_WALK\t\t\t\t0x0080000\n#define ACTION_AFFIRMATIVE\t\t0x0100000\n#define ACTION_NEGATIVE\t\t\t0x0200000\n#define ACTION_GETFLAG\t\t\t0x0800000\n#define ACTION_GUARDBASE\t\t0x1000000\n#define ACTION_PATROL\t\t\t0x2000000\n#define ACTION_FOLLOWME\t\t\t0x8000000\n\n//the bot input, will be converted to an usercmd_t\ntypedef struct bot_input_s\n{\n\tfloat thinktime;\t\t//time since last output (in seconds)\n\tvec3_t dir;\t\t\t\t//movement direction\n\tfloat speed;\t\t\t//speed in the range [0, 400]\n\tvec3_t viewangles;\t\t//the view angles\n\tint actionflags;\t\t//one of the ACTION_? flags\n\tint weapon;\t\t\t\t//weapon to use\n} bot_input_t;\n\n#ifndef BSPTRACE\n\n#define BSPTRACE\n\n//bsp_trace_t hit surface\ntypedef struct bsp_surface_s\n{\n\tchar name[16];\n\tint flags;\n\tint value;\n} bsp_surface_t;\n\n//remove the bsp_trace_s structure definition l8r on\n//a trace is returned when a box is swept through the world\ntypedef struct bsp_trace_s\n{\n\tqboolean\t\tallsolid;\t// if true, plane is not valid\n\tqboolean\t\tstartsolid;\t// if true, the initial point was in a solid area\n\tfloat\t\t\tfraction;\t// time completed, 1.0 = didn't hit anything\n\tvec3_t\t\t\tendpos;\t\t// final position\n\tcplane_t\t\tplane;\t\t// surface normal at impact\n\tfloat\t\t\texp_dist;\t// expanded plane distance\n\tint\t\t\t\tsidenum;\t// number of the brush side hit\n\tbsp_surface_t\tsurface;\t// the hit point surface\n\tint\t\t\t\tcontents;\t// contents on other side of surface hit\n\tint\t\t\t\tent;\t\t// number of entity hit\n} bsp_trace_t;\n\n#endif\t// BSPTRACE\n\n//entity state\ntypedef struct bot_entitystate_s\n{\n\tint\t\ttype;\t\t\t// entity type\n\tint\t\tflags;\t\t\t// entity flags\n\tvec3_t\torigin;\t\t\t// origin of the entity\n\tvec3_t\tangles;\t\t\t// angles of the model\n\tvec3_t\told_origin;\t\t// for lerping\n\tvec3_t\tmins;\t\t\t// bounding box minimums\n\tvec3_t\tmaxs;\t\t\t// bounding box maximums\n\tint\t\tgroundent;\t\t// ground entity\n\tint\t\tsolid;\t\t\t// solid type\n\tint\t\tmodelindex;\t\t// model used\n\tint\t\tmodelindex2;\t// weapons, CTF flags, etc\n\tint\t\tframe;\t\t\t// model frame number\n\tint\t\tevent;\t\t\t// impulse events -- muzzle flashes, footsteps, etc\n\tint\t\teventParm;\t\t// even parameter\n\tint\t\tpowerups;\t\t// bit flags\n\tint\t\tweapon;\t\t\t// determines weapon and flash model, etc\n\tint\t\tlegsAnim;\t\t// mask off ANIM_TOGGLEBIT\n\tint\t\ttorsoAnim;\t\t// mask off ANIM_TOGGLEBIT\n} bot_entitystate_t;\n\n//bot AI library exported functions\ntypedef struct botlib_import_s\n{\n\t//print messages from the bot library\n\tvoid\t\t(QDECL *Print)(int type, char *fmt, ...);\n\t//trace a bbox through the world\n\tvoid\t\t(*Trace)(bsp_trace_t *trace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask);\n\t//trace a bbox against a specific entity\n\tvoid\t\t(*EntityTrace)(bsp_trace_t *trace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int entnum, int contentmask);\n\t//retrieve the contents at the given point\n\tint\t\t\t(*PointContents)(vec3_t point);\n\t//check if the point is in potential visible sight\n\tint\t\t\t(*inPVS)(vec3_t p1, vec3_t p2);\n\t//retrieve the BSP entity data lump\n\tchar\t\t*(*BSPEntityData)(void);\n\t//\n\tvoid\t\t(*BSPModelMinsMaxsOrigin)(int modelnum, vec3_t angles, vec3_t mins, vec3_t maxs, vec3_t origin);\n\t//send a bot client command\n\tvoid\t\t(*BotClientCommand)(int client, char *command);\n\t//memory allocation\n\tvoid\t\t*(*GetMemory)(int size);\t\t// allocate from Zone\n\tvoid\t\t(*FreeMemory)(void *ptr);\t\t// free memory from Zone\n\tint\t\t\t(*AvailableMemory)(void);\t\t// available Zone memory\n\tvoid\t\t*(*HunkAlloc)(int size);\t\t// allocate from hunk\n\t//file system access\n\tint\t\t\t(*FS_FOpenFile)( const char *qpath, fileHandle_t *file, fsMode_t mode );\n\tint\t\t\t(*FS_Read)( void *buffer, int len, fileHandle_t f );\n\tint\t\t\t(*FS_Write)( const void *buffer, int len, fileHandle_t f );\n\tvoid\t\t(*FS_FCloseFile)( fileHandle_t f );\n\tint\t\t\t(*FS_Seek)( fileHandle_t f, long offset, int origin );\n\t//debug visualisation stuff\n\tint\t\t\t(*DebugLineCreate)(void);\n\tvoid\t\t(*DebugLineDelete)(int line);\n\tvoid\t\t(*DebugLineShow)(int line, vec3_t start, vec3_t end, int color);\n\t//\n\tint\t\t\t(*DebugPolygonCreate)(int color, int numPoints, vec3_t *points);\n\tvoid\t\t(*DebugPolygonDelete)(int id);\n} botlib_import_t;\n\ntypedef struct aas_export_s\n{\n\t//-----------------------------------\n\t// be_aas_entity.h\n\t//-----------------------------------\n\tvoid\t\t(*AAS_EntityInfo)(int entnum, struct aas_entityinfo_s *info);\n\t//-----------------------------------\n\t// be_aas_main.h\n\t//-----------------------------------\n\tint\t\t\t(*AAS_Initialized)(void);\n\tvoid\t\t(*AAS_PresenceTypeBoundingBox)(int presencetype, vec3_t mins, vec3_t maxs);\n\tfloat\t\t(*AAS_Time)(void);\n\t//--------------------------------------------\n\t// be_aas_sample.c\n\t//--------------------------------------------\n\tint\t\t\t(*AAS_PointAreaNum)(vec3_t point);\n\tint\t\t\t(*AAS_PointReachabilityAreaIndex)( vec3_t point );\n\tint\t\t\t(*AAS_TraceAreas)(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas);\n\tint\t\t\t(*AAS_BBoxAreas)(vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas);\n\tint\t\t\t(*AAS_AreaInfo)( int areanum, struct aas_areainfo_s *info );\n\t//--------------------------------------------\n\t// be_aas_bspq3.c\n\t//--------------------------------------------\n\tint\t\t\t(*AAS_PointContents)(vec3_t point);\n\tint\t\t\t(*AAS_NextBSPEntity)(int ent);\n\tint\t\t\t(*AAS_ValueForBSPEpairKey)(int ent, char *key, char *value, int size);\n\tint\t\t\t(*AAS_VectorForBSPEpairKey)(int ent, char *key, vec3_t v);\n\tint\t\t\t(*AAS_FloatForBSPEpairKey)(int ent, char *key, float *value);\n\tint\t\t\t(*AAS_IntForBSPEpairKey)(int ent, char *key, int *value);\n\t//--------------------------------------------\n\t// be_aas_reach.c\n\t//--------------------------------------------\n\tint\t\t\t(*AAS_AreaReachability)(int areanum);\n\t//--------------------------------------------\n\t// be_aas_route.c\n\t//--------------------------------------------\n\tint\t\t\t(*AAS_AreaTravelTimeToGoalArea)(int areanum, vec3_t origin, int goalareanum, int travelflags);\n\tint\t\t\t(*AAS_EnableRoutingArea)(int areanum, int enable);\n\tint\t\t\t(*AAS_PredictRoute)(struct aas_predictroute_s *route, int areanum, vec3_t origin,\n\t\t\t\t\t\t\tint goalareanum, int travelflags, int maxareas, int maxtime,\n\t\t\t\t\t\t\tint stopevent, int stopcontents, int stoptfl, int stopareanum);\n\t//--------------------------------------------\n\t// be_aas_altroute.c\n\t//--------------------------------------------\n\tint\t\t\t(*AAS_AlternativeRouteGoals)(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags,\n\t\t\t\t\t\t\t\t\t\tstruct aas_altroutegoal_s *altroutegoals, int maxaltroutegoals,\n\t\t\t\t\t\t\t\t\t\tint type);\n\t//--------------------------------------------\n\t// be_aas_move.c\n\t//--------------------------------------------\n\tint\t\t\t(*AAS_Swimming)(vec3_t origin);\n\tint\t\t\t(*AAS_PredictClientMovement)(struct aas_clientmove_s *move,\n\t\t\t\t\t\t\t\t\t\t\tint entnum, vec3_t origin,\n\t\t\t\t\t\t\t\t\t\t\tint presencetype, int onground,\n\t\t\t\t\t\t\t\t\t\t\tvec3_t velocity, vec3_t cmdmove,\n\t\t\t\t\t\t\t\t\t\t\tint cmdframes,\n\t\t\t\t\t\t\t\t\t\t\tint maxframes, float frametime,\n\t\t\t\t\t\t\t\t\t\t\tint stopevent, int stopareanum, int visualize);\n} aas_export_t;\n\ntypedef struct ea_export_s\n{\n\t//ClientCommand elementary actions\n\tvoid\t(*EA_Command)(int client, char *command );\n\tvoid\t(*EA_Say)(int client, char *str);\n\tvoid\t(*EA_SayTeam)(int client, char *str);\n\t//\n\tvoid\t(*EA_Action)(int client, int action);\n\tvoid\t(*EA_Gesture)(int client);\n\tvoid\t(*EA_Talk)(int client);\n\tvoid\t(*EA_Attack)(int client);\n\tvoid\t(*EA_Use)(int client);\n\tvoid\t(*EA_Respawn)(int client);\n\tvoid\t(*EA_MoveUp)(int client);\n\tvoid\t(*EA_MoveDown)(int client);\n\tvoid\t(*EA_MoveForward)(int client);\n\tvoid\t(*EA_MoveBack)(int client);\n\tvoid\t(*EA_MoveLeft)(int client);\n\tvoid\t(*EA_MoveRight)(int client);\n\tvoid\t(*EA_Crouch)(int client);\n\n\tvoid\t(*EA_SelectWeapon)(int client, int weapon);\n\tvoid\t(*EA_Jump)(int client);\n\tvoid\t(*EA_DelayedJump)(int client);\n\tvoid\t(*EA_Move)(int client, vec3_t dir, float speed);\n\tvoid\t(*EA_View)(int client, vec3_t viewangles);\n\t//send regular input to the server\n\tvoid\t(*EA_EndRegular)(int client, float thinktime);\n\tvoid\t(*EA_GetInput)(int client, float thinktime, bot_input_t *input);\n\tvoid\t(*EA_ResetInput)(int client);\n} ea_export_t;\n\ntypedef struct ai_export_s\n{\n\t//-----------------------------------\n\t// be_ai_char.h\n\t//-----------------------------------\n\tint\t\t(*BotLoadCharacter)(char *charfile, float skill);\n\tvoid\t(*BotFreeCharacter)(int character);\n\tfloat\t(*Characteristic_Float)(int character, int index);\n\tfloat\t(*Characteristic_BFloat)(int character, int index, float min, float max);\n\tint\t\t(*Characteristic_Integer)(int character, int index);\n\tint\t\t(*Characteristic_BInteger)(int character, int index, int min, int max);\n\tvoid\t(*Characteristic_String)(int character, int index, char *buf, int size);\n\t//-----------------------------------\n\t// be_ai_chat.h\n\t//-----------------------------------\n\tint\t\t(*BotAllocChatState)(void);\n\tvoid\t(*BotFreeChatState)(int handle);\n\tvoid\t(*BotQueueConsoleMessage)(int chatstate, int type, char *message);\n\tvoid\t(*BotRemoveConsoleMessage)(int chatstate, int handle);\n\tint\t\t(*BotNextConsoleMessage)(int chatstate, struct bot_consolemessage_s *cm);\n\tint\t\t(*BotNumConsoleMessages)(int chatstate);\n\tvoid\t(*BotInitialChat)(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7);\n\tint\t\t(*BotNumInitialChats)(int chatstate, char *type);\n\tint\t\t(*BotReplyChat)(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7);\n\tint\t\t(*BotChatLength)(int chatstate);\n\tvoid\t(*BotEnterChat)(int chatstate, int client, int sendto);\n\tvoid\t(*BotGetChatMessage)(int chatstate, char *buf, int size);\n\tint\t\t(*StringContains)(char *str1, char *str2, int casesensitive);\n\tint\t\t(*BotFindMatch)(char *str, struct bot_match_s *match, unsigned long int context);\n\tvoid\t(*BotMatchVariable)(struct bot_match_s *match, int variable, char *buf, int size);\n\tvoid\t(*UnifyWhiteSpaces)(char *string);\n\tvoid\t(*BotReplaceSynonyms)(char *string, unsigned long int context);\n\tint\t\t(*BotLoadChatFile)(int chatstate, char *chatfile, char *chatname);\n\tvoid\t(*BotSetChatGender)(int chatstate, int gender);\n\tvoid\t(*BotSetChatName)(int chatstate, char *name, int client);\n\t//-----------------------------------\n\t// be_ai_goal.h\n\t//-----------------------------------\n\tvoid\t(*BotResetGoalState)(int goalstate);\n\tvoid\t(*BotResetAvoidGoals)(int goalstate);\n\tvoid\t(*BotRemoveFromAvoidGoals)(int goalstate, int number);\n\tvoid\t(*BotPushGoal)(int goalstate, struct bot_goal_s *goal);\n\tvoid\t(*BotPopGoal)(int goalstate);\n\tvoid\t(*BotEmptyGoalStack)(int goalstate);\n\tvoid\t(*BotDumpAvoidGoals)(int goalstate);\n\tvoid\t(*BotDumpGoalStack)(int goalstate);\n\tvoid\t(*BotGoalName)(int number, char *name, int size);\n\tint\t\t(*BotGetTopGoal)(int goalstate, struct bot_goal_s *goal);\n\tint\t\t(*BotGetSecondGoal)(int goalstate, struct bot_goal_s *goal);\n\tint\t\t(*BotChooseLTGItem)(int goalstate, vec3_t origin, int *inventory, int travelflags);\n\tint\t\t(*BotChooseNBGItem)(int goalstate, vec3_t origin, int *inventory, int travelflags,\n\t\t\t\t\t\t\t\tstruct bot_goal_s *ltg, float maxtime);\n\tint\t\t(*BotTouchingGoal)(vec3_t origin, struct bot_goal_s *goal);\n\tint\t\t(*BotItemGoalInVisButNotVisible)(int viewer, vec3_t eye, vec3_t viewangles, struct bot_goal_s *goal);\n\tint\t\t(*BotGetLevelItemGoal)(int index, char *classname, struct bot_goal_s *goal);\n\tint\t\t(*BotGetNextCampSpotGoal)(int num, struct bot_goal_s *goal);\n\tint\t\t(*BotGetMapLocationGoal)(char *name, struct bot_goal_s *goal);\n\tfloat\t(*BotAvoidGoalTime)(int goalstate, int number);\n\tvoid\t(*BotSetAvoidGoalTime)(int goalstate, int number, float avoidtime);\n\tvoid\t(*BotInitLevelItems)(void);\n\tvoid\t(*BotUpdateEntityItems)(void);\n\tint\t\t(*BotLoadItemWeights)(int goalstate, char *filename);\n\tvoid\t(*BotFreeItemWeights)(int goalstate);\n\tvoid\t(*BotInterbreedGoalFuzzyLogic)(int parent1, int parent2, int child);\n\tvoid\t(*BotSaveGoalFuzzyLogic)(int goalstate, char *filename);\n\tvoid\t(*BotMutateGoalFuzzyLogic)(int goalstate, float range);\n\tint\t\t(*BotAllocGoalState)(int client);\n\tvoid\t(*BotFreeGoalState)(int handle);\n\t//-----------------------------------\n\t// be_ai_move.h\n\t//-----------------------------------\n\tvoid\t(*BotResetMoveState)(int movestate);\n\tvoid\t(*BotMoveToGoal)(struct bot_moveresult_s *result, int movestate, struct bot_goal_s *goal, int travelflags);\n\tint\t\t(*BotMoveInDirection)(int movestate, vec3_t dir, float speed, int type);\n\tvoid\t(*BotResetAvoidReach)(int movestate);\n\tvoid\t(*BotResetLastAvoidReach)(int movestate);\n\tint\t\t(*BotReachabilityArea)(vec3_t origin, int testground);\n\tint\t\t(*BotMovementViewTarget)(int movestate, struct bot_goal_s *goal, int travelflags, float lookahead, vec3_t target);\n\tint\t\t(*BotPredictVisiblePosition)(vec3_t origin, int areanum, struct bot_goal_s *goal, int travelflags, vec3_t target);\n\tint\t\t(*BotAllocMoveState)(void);\n\tvoid\t(*BotFreeMoveState)(int handle);\n\tvoid\t(*BotInitMoveState)(int handle, struct bot_initmove_s *initmove);\n\tvoid\t(*BotAddAvoidSpot)(int movestate, vec3_t origin, float radius, int type);\n\t//-----------------------------------\n\t// be_ai_weap.h\n\t//-----------------------------------\n\tint\t\t(*BotChooseBestFightWeapon)(int weaponstate, int *inventory);\n\tvoid\t(*BotGetWeaponInfo)(int weaponstate, int weapon, struct weaponinfo_s *weaponinfo);\n\tint\t\t(*BotLoadWeaponWeights)(int weaponstate, char *filename);\n\tint\t\t(*BotAllocWeaponState)(void);\n\tvoid\t(*BotFreeWeaponState)(int weaponstate);\n\tvoid\t(*BotResetWeaponState)(int weaponstate);\n\t//-----------------------------------\n\t// be_ai_gen.h\n\t//-----------------------------------\n\tint\t\t(*GeneticParentsAndChildSelection)(int numranks, float *ranks, int *parent1, int *parent2, int *child);\n} ai_export_t;\n\n//bot AI library imported functions\ntypedef struct botlib_export_s\n{\n\t//Area Awareness System functions\n\taas_export_t aas;\n\t//Elementary Action functions\n\tea_export_t ea;\n\t//AI functions\n\tai_export_t ai;\n\t//setup the bot library, returns BLERR_\n\tint (*BotLibSetup)(void);\n\t//shutdown the bot library, returns BLERR_\n\tint (*BotLibShutdown)(void);\n\t//sets a library variable returns BLERR_\n\tint (*BotLibVarSet)(char *var_name, char *value);\n\t//gets a library variable returns BLERR_\n\tint (*BotLibVarGet)(char *var_name, char *value, int size);\n\n\t//sets a C-like define returns BLERR_\n\tint (*PC_AddGlobalDefine)(char *string);\n\tint (*PC_LoadSourceHandle)(const char *filename);\n\tint (*PC_FreeSourceHandle)(int handle);\n\tint (*PC_ReadTokenHandle)(int handle, pc_token_t *pc_token);\n\tint (*PC_SourceFileAndLine)(int handle, char *filename, int *line);\n\n\t//start a frame in the bot library\n\tint (*BotLibStartFrame)(float time);\n\t//load a new map in the bot library\n\tint (*BotLibLoadMap)(const char *mapname);\n\t//entity updates\n\tint (*BotLibUpdateEntity)(int ent, bot_entitystate_t *state);\n\t//just for testing\n\tint (*Test)(int parm0, char *parm1, vec3_t parm2, vec3_t parm3);\n} botlib_export_t;\n\n//linking of bot library\nbotlib_export_t *GetBotLibAPI( int apiVersion, botlib_import_t *import );\n\n/* Library variables:\n\nname:\t\t\t\t\t\tdefault:\t\t\tmodule(s):\t\t\tdescription:\n\n\"basedir\"\t\t\t\t\t\"\"\t\t\t\t\tl_utils.c\t\t\tbase directory\n\"gamedir\"\t\t\t\t\t\"\"\t\t\t\t\tl_utils.c\t\t\tgame directory\n\"cddir\"\t\t\t\t\t\t\"\"\t\t\t\t\tl_utils.c\t\t\tCD directory\n\n\"log\"\t\t\t\t\t\t\"0\"\t\t\t\t\tl_log.c\t\t\t\tenable/disable creating a log file\n\"maxclients\"\t\t\t\t\"4\"\t\t\t\t\tbe_interface.c\t\tmaximum number of clients\n\"maxentities\"\t\t\t\t\"1024\"\t\t\t\tbe_interface.c\t\tmaximum number of entities\n\"bot_developer\"\t\t\t\t\"0\"\t\t\t\t\tbe_interface.c\t\tbot developer mode\n\n\"phys_friction\"\t\t\t\t\"6\"\t\t\t\t\tbe_aas_move.c\t\tground friction\n\"phys_stopspeed\"\t\t\t\"100\"\t\t\t\tbe_aas_move.c\t\tstop speed\n\"phys_gravity\"\t\t\t\t\"800\"\t\t\t\tbe_aas_move.c\t\tgravity value\n\"phys_waterfriction\"\t\t\"1\"\t\t\t\t\tbe_aas_move.c\t\twater friction\n\"phys_watergravity\"\t\t\t\"400\"\t\t\t\tbe_aas_move.c\t\tgravity in water\n\"phys_maxvelocity\"\t\t\t\"320\"\t\t\t\tbe_aas_move.c\t\tmaximum velocity\n\"phys_maxwalkvelocity\"\t\t\"320\"\t\t\t\tbe_aas_move.c\t\tmaximum walk velocity\n\"phys_maxcrouchvelocity\"\t\"100\"\t\t\t\tbe_aas_move.c\t\tmaximum crouch velocity\n\"phys_maxswimvelocity\"\t\t\"150\"\t\t\t\tbe_aas_move.c\t\tmaximum swim velocity\n\"phys_walkaccelerate\"\t\t\"10\"\t\t\t\tbe_aas_move.c\t\twalk acceleration\n\"phys_airaccelerate\"\t\t\"1\"\t\t\t\t\tbe_aas_move.c\t\tair acceleration\n\"phys_swimaccelerate\"\t\t\"4\"\t\t\t\t\tbe_aas_move.c\t\tswim acceleration\n\"phys_maxstep\"\t\t\t\t\"18\"\t\t\t\tbe_aas_move.c\t\tmaximum step height\n\"phys_maxsteepness\"\t\t\t\"0.7\"\t\t\t\tbe_aas_move.c\t\tmaximum floor steepness\n\"phys_maxbarrier\"\t\t\t\"32\"\t\t\t\tbe_aas_move.c\t\tmaximum barrier height\n\"phys_maxwaterjump\"\t\t\t\"19\"\t\t\t\tbe_aas_move.c\t\tmaximum waterjump height\n\"phys_jumpvel\"\t\t\t\t\"270\"\t\t\t\tbe_aas_move.c\t\tjump z velocity\n\"phys_falldelta5\"\t\t\t\"40\"\t\t\t\tbe_aas_move.c\n\"phys_falldelta10\"\t\t\t\"60\"\t\t\t\tbe_aas_move.c\n\"rs_waterjump\"\t\t\t\t\"400\"\t\t\t\tbe_aas_move.c\n\"rs_teleport\"\t\t\t\t\"50\"\t\t\t\tbe_aas_move.c\n\"rs_barrierjump\"\t\t\t\"100\"\t\t\t\tbe_aas_move.c\n\"rs_startcrouch\"\t\t\t\"300\"\t\t\t\tbe_aas_move.c\n\"rs_startgrapple\"\t\t\t\"500\"\t\t\t\tbe_aas_move.c\n\"rs_startwalkoffledge\"\t\t\"70\"\t\t\t\tbe_aas_move.c\n\"rs_startjump\"\t\t\t\t\"300\"\t\t\t\tbe_aas_move.c\n\"rs_rocketjump\"\t\t\t\t\"500\"\t\t\t\tbe_aas_move.c\n\"rs_bfgjump\"\t\t\t\t\"500\"\t\t\t\tbe_aas_move.c\n\"rs_jumppad\"\t\t\t\t\"250\"\t\t\t\tbe_aas_move.c\n\"rs_aircontrolledjumppad\"\t\"300\"\t\t\t\tbe_aas_move.c\n\"rs_funcbob\"\t\t\t\t\"300\"\t\t\t\tbe_aas_move.c\n\"rs_startelevator\"\t\t\t\"50\"\t\t\t\tbe_aas_move.c\n\"rs_falldamage5\"\t\t\t\"300\"\t\t\t\tbe_aas_move.c\n\"rs_falldamage10\"\t\t\t\"500\"\t\t\t\tbe_aas_move.c\n\"rs_maxjumpfallheight\"\t\t\"450\"\t\t\t\tbe_aas_move.c\n\n\"max_aaslinks\"\t\t\t\t\"4096\"\t\t\t\tbe_aas_sample.c\t\tmaximum links in the AAS\n\"max_routingcache\"\t\t\t\"4096\"\t\t\t\tbe_aas_route.c\t\tmaximum routing cache size in KB\n\"forceclustering\"\t\t\t\"0\"\t\t\t\t\tbe_aas_main.c\t\tforce recalculation of clusters\n\"forcereachability\"\t\t\t\"0\"\t\t\t\t\tbe_aas_main.c\t\tforce recalculation of reachabilities\n\"forcewrite\"\t\t\t\t\"0\"\t\t\t\t\tbe_aas_main.c\t\tforce writing of aas file\n\"aasoptimize\"\t\t\t\t\"0\"\t\t\t\t\tbe_aas_main.c\t\tenable aas optimization\n\"sv_mapChecksum\"\t\t\t\"0\"\t\t\t\t\tbe_aas_main.c\t\tBSP file checksum\n\"bot_visualizejumppads\"\t\t\"0\"\t\t\t\t\tbe_aas_reach.c\t\tvisualize jump pads\n\n\"bot_reloadcharacters\"\t\t\"0\"\t\t\t\t\t-\t\t\t\t\treload bot character files\n\"ai_gametype\"\t\t\t\t\"0\"\t\t\t\t\tbe_ai_goal.c\t\tgame type\n\"droppedweight\"\t\t\t\t\"1000\"\t\t\t\tbe_ai_goal.c\t\tadditional dropped item weight\n\"weapindex_rocketlauncher\"\t\"5\"\t\t\t\t\tbe_ai_move.c\t\trl weapon index for rocket jumping\n\"weapindex_bfg10k\"\t\t\t\"9\"\t\t\t\t\tbe_ai_move.c\t\tbfg weapon index for bfg jumping\n\"weapindex_grapple\"\t\t\t\"10\"\t\t\t\tbe_ai_move.c\t\tgrapple weapon index for grappling\n\"entitytypemissile\"\t\t\t\"3\"\t\t\t\t\tbe_ai_move.c\t\tET_MISSILE\n\"offhandgrapple\"\t\t\t\"0\"\t\t\t\t\tbe_ai_move.c\t\tenable off hand grapple hook\n\"cmd_grappleon\"\t\t\t\t\"grappleon\"\t\t\tbe_ai_move.c\t\tcommand to activate off hand grapple\n\"cmd_grappleoff\"\t\t\t\"grappleoff\"\t\tbe_ai_move.c\t\tcommand to deactivate off hand grapple\n\"itemconfig\"\t\t\t\t\"items.c\"\t\t\tbe_ai_goal.c\t\titem configuration file\n\"weaponconfig\"\t\t\t\t\"weapons.c\"\t\t\tbe_ai_weap.c\t\tweapon configuration file\n\"synfile\"\t\t\t\t\t\"syn.c\"\t\t\t\tbe_ai_chat.c\t\tfile with synonyms\n\"rndfile\"\t\t\t\t\t\"rnd.c\"\t\t\t\tbe_ai_chat.c\t\tfile with random strings\n\"matchfile\"\t\t\t\t\t\"match.c\"\t\t\tbe_ai_chat.c\t\tfile with match strings\n\"nochat\"\t\t\t\t\t\"0\"\t\t\t\t\tbe_ai_chat.c\t\tdisable chats\n\"max_messages\"\t\t\t\t\"1024\"\t\t\t\tbe_ai_chat.c\t\tconsole message heap size\n\"max_weaponinfo\"\t\t\t\"32\"\t\t\t\tbe_ai_weap.c\t\tmaximum number of weapon info\n\"max_projectileinfo\"\t\t\"32\"\t\t\t\tbe_ai_weap.c\t\tmaximum number of projectile info\n\"max_iteminfo\"\t\t\t\t\"256\"\t\t\t\tbe_ai_goal.c\t\tmaximum number of item info\n\"max_levelitems\"\t\t\t\"256\"\t\t\t\tbe_ai_goal.c\t\tmaximum number of level items\n\n*/\n\n"
  },
  {
    "path": "code/game/chars.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n//========================================================\n//========================================================\n//name\n#define CHARACTERISTIC_NAME\t\t\t\t\t\t\t0\t//string\n//gender of the bot\n#define CHARACTERISTIC_GENDER\t\t\t\t\t\t1\t//string (\"male\", \"female\", \"it\")\n//attack skill\n// >  0.0 && <  0.2 = don't move\n// >  0.3 && <  1.0 = aim at enemy during retreat\n// >  0.0 && <  0.4 = only move forward/backward\n// >= 0.4 && <  1.0 = circle strafing\n// >  0.7 && <  1.0 = random strafe direction change\n#define CHARACTERISTIC_ATTACK_SKILL\t\t\t\t\t2\t//float [0, 1]\n//weapon weight file\n#define CHARACTERISTIC_WEAPONWEIGHTS\t\t\t\t3\t//string\n//view angle difference to angle change factor\n#define CHARACTERISTIC_VIEW_FACTOR\t\t\t\t\t4\t//float <0, 1]\n//maximum view angle change\n#define CHARACTERISTIC_VIEW_MAXCHANGE\t\t\t\t5\t//float [1, 360]\n//reaction time in seconds\n#define CHARACTERISTIC_REACTIONTIME\t\t\t\t\t6\t//float [0, 5]\n//accuracy when aiming\n#define CHARACTERISTIC_AIM_ACCURACY\t\t\t\t\t7\t//float [0, 1]\n//weapon specific aim accuracy\n#define CHARACTERISTIC_AIM_ACCURACY_MACHINEGUN\t\t8\t//float [0, 1]\n#define CHARACTERISTIC_AIM_ACCURACY_SHOTGUN\t\t\t9\t//float [0, 1]\n#define CHARACTERISTIC_AIM_ACCURACY_ROCKETLAUNCHER\t10\t//float [0, 1]\n#define CHARACTERISTIC_AIM_ACCURACY_GRENADELAUNCHER\t11\t//float [0, 1]\n#define CHARACTERISTIC_AIM_ACCURACY_LIGHTNING\t\t12\n#define CHARACTERISTIC_AIM_ACCURACY_PLASMAGUN\t\t13\t//float [0, 1]\n#define CHARACTERISTIC_AIM_ACCURACY_RAILGUN\t\t\t14\n#define CHARACTERISTIC_AIM_ACCURACY_BFG10K\t\t\t15\t//float [0, 1]\n//skill when aiming\n// >  0.0 && <  0.9 = aim is affected by enemy movement\n// >  0.4 && <= 0.8 = enemy linear leading\n// >  0.8 && <= 1.0 = enemy exact movement leading\n// >  0.5 && <= 1.0 = prediction shots when enemy is not visible\n// >  0.6 && <= 1.0 = splash damage by shooting nearby geometry\n#define CHARACTERISTIC_AIM_SKILL\t\t\t\t\t16\t//float [0, 1]\n//weapon specific aim skill\n#define CHARACTERISTIC_AIM_SKILL_ROCKETLAUNCHER\t\t17\t//float [0, 1]\n#define CHARACTERISTIC_AIM_SKILL_GRENADELAUNCHER\t18\t//float [0, 1]\n#define CHARACTERISTIC_AIM_SKILL_PLASMAGUN\t\t\t19\t//float [0, 1]\n#define CHARACTERISTIC_AIM_SKILL_BFG10K\t\t\t\t20\t//float [0, 1]\n//========================================================\n//chat\n//========================================================\n//file with chats\n#define CHARACTERISTIC_CHAT_FILE\t\t\t\t\t21\t//string\n//name of the chat character\n#define CHARACTERISTIC_CHAT_NAME\t\t\t\t\t22\t//string\n//characters per minute type speed\n#define CHARACTERISTIC_CHAT_CPM\t\t\t\t\t\t23\t//integer [1, 4000]\n//tendency to insult/praise\n#define CHARACTERISTIC_CHAT_INSULT\t\t\t\t\t24\t//float [0, 1]\n//tendency to chat misc\n#define CHARACTERISTIC_CHAT_MISC\t\t\t\t\t25\t//float [0, 1]\n//tendency to chat at start or end of level\n#define CHARACTERISTIC_CHAT_STARTENDLEVEL\t\t\t26\t//float [0, 1]\n//tendency to chat entering or exiting the game\n#define CHARACTERISTIC_CHAT_ENTEREXITGAME\t\t\t27\t//float [0, 1]\n//tendency to chat when killed someone\n#define CHARACTERISTIC_CHAT_KILL\t\t\t\t\t28\t//float [0, 1]\n//tendency to chat when died\n#define CHARACTERISTIC_CHAT_DEATH\t\t\t\t\t29\t//float [0, 1]\n//tendency to chat when enemy suicides\n#define CHARACTERISTIC_CHAT_ENEMYSUICIDE\t\t\t30\t//float [0, 1]\n//tendency to chat when hit while talking\n#define CHARACTERISTIC_CHAT_HITTALKING\t\t\t\t31\t//float [0, 1]\n//tendency to chat when bot was hit but didn't dye\n#define CHARACTERISTIC_CHAT_HITNODEATH\t\t\t\t32\t//float [0, 1]\n//tendency to chat when bot hit the enemy but enemy didn't dye\n#define CHARACTERISTIC_CHAT_HITNOKILL\t\t\t\t33\t//float [0, 1]\n//tendency to randomly chat\n#define CHARACTERISTIC_CHAT_RANDOM\t\t\t\t\t34\t//float [0, 1]\n//tendency to reply\n#define CHARACTERISTIC_CHAT_REPLY\t\t\t\t\t35\t//float [0, 1]\n//========================================================\n//movement\n//========================================================\n//tendency to crouch\n#define CHARACTERISTIC_CROUCHER\t\t\t\t\t\t36\t//float [0, 1]\n//tendency to jump\n#define CHARACTERISTIC_JUMPER\t\t\t\t\t\t37\t//float [0, 1]\n//tendency to walk\n#define CHARACTERISTIC_WALKER\t\t\t\t\t\t48\t//float [0, 1]\n//tendency to jump using a weapon\n#define CHARACTERISTIC_WEAPONJUMPING\t\t\t\t38\t//float [0, 1]\n//tendency to use the grapple hook when available\n#define CHARACTERISTIC_GRAPPLE_USER\t\t\t\t\t39\t//float [0, 1]\t//use this!!\n//========================================================\n//goal\n//========================================================\n//item weight file\n#define CHARACTERISTIC_ITEMWEIGHTS\t\t\t\t\t40\t//string\n//the aggression of the bot\n#define CHARACTERISTIC_AGGRESSION\t\t\t\t\t41\t//float [0, 1]\n//the self preservation of the bot (rockets near walls etc.)\n#define CHARACTERISTIC_SELFPRESERVATION\t\t\t\t42\t//float [0, 1]\n//how likely the bot is to take revenge\n#define CHARACTERISTIC_VENGEFULNESS\t\t\t\t\t43\t//float [0, 1]\t//use this!!\n//tendency to camp\n#define CHARACTERISTIC_CAMPER\t\t\t\t\t\t44\t//float [0, 1]\n//========================================================\n//========================================================\n//tendency to get easy frags\n#define CHARACTERISTIC_EASY_FRAGGER\t\t\t\t\t45\t//float [0, 1]\n//how alert the bot is (view distance)\n#define CHARACTERISTIC_ALERTNESS\t\t\t\t\t46\t//float [0, 1]\n//how much the bot fires it's weapon\n#define CHARACTERISTIC_FIRETHROTTLE\t\t\t\t\t47\t//float [0, 1]\n\n"
  },
  {
    "path": "code/game/g_active.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n#include \"g_local.h\"\n\n\n/*\n===============\nG_DamageFeedback\n\nCalled just before a snapshot is sent to the given player.\nTotals up all damage and generates both the player_state_t\ndamage values to that client for pain blends and kicks, and\nglobal pain sound events for all clients.\n===============\n*/\nvoid P_DamageFeedback( gentity_t *player ) {\n\tgclient_t\t*client;\n\tfloat\tcount;\n\tvec3_t\tangles;\n\n\tclient = player->client;\n\tif ( client->ps.pm_type == PM_DEAD ) {\n\t\treturn;\n\t}\n\n\t// total points of damage shot at the player this frame\n\tcount = client->damage_blood + client->damage_armor;\n\tif ( count == 0 ) {\n\t\treturn;\t\t// didn't take any damage\n\t}\n\n\tif ( count > 255 ) {\n\t\tcount = 255;\n\t}\n\n\t// send the information to the client\n\n\t// world damage (falling, slime, etc) uses a special code\n\t// to make the blend blob centered instead of positional\n\tif ( client->damage_fromWorld ) {\n\t\tclient->ps.damagePitch = 255;\n\t\tclient->ps.damageYaw = 255;\n\n\t\tclient->damage_fromWorld = qfalse;\n\t} else {\n\t\tvectoangles( client->damage_from, angles );\n\t\tclient->ps.damagePitch = angles[PITCH]/360.0 * 256;\n\t\tclient->ps.damageYaw = angles[YAW]/360.0 * 256;\n\t}\n\n\t// play an apropriate pain sound\n\tif ( (level.time > player->pain_debounce_time) && !(player->flags & FL_GODMODE) ) {\n\t\tplayer->pain_debounce_time = level.time + 700;\n\t\tG_AddEvent( player, EV_PAIN, player->health );\n\t\tclient->ps.damageEvent++;\n\t}\n\n\n\tclient->ps.damageCount = count;\n\n\t//\n\t// clear totals\n\t//\n\tclient->damage_blood = 0;\n\tclient->damage_armor = 0;\n\tclient->damage_knockback = 0;\n}\n\n\n\n/*\n=============\nP_WorldEffects\n\nCheck for lava / slime contents and drowning\n=============\n*/\nvoid P_WorldEffects( gentity_t *ent ) {\n\tqboolean\tenvirosuit;\n\tint\t\t\twaterlevel;\n\n\tif ( ent->client->noclip ) {\n\t\tent->client->airOutTime = level.time + 12000;\t// don't need air\n\t\treturn;\n\t}\n\n\twaterlevel = ent->waterlevel;\n\n\tenvirosuit = ent->client->ps.powerups[PW_BATTLESUIT] > level.time;\n\n\t//\n\t// check for drowning\n\t//\n\tif ( waterlevel == 3 ) {\n\t\t// envirosuit give air\n\t\tif ( envirosuit ) {\n\t\t\tent->client->airOutTime = level.time + 10000;\n\t\t}\n\n\t\t// if out of air, start drowning\n\t\tif ( ent->client->airOutTime < level.time) {\n\t\t\t// drown!\n\t\t\tent->client->airOutTime += 1000;\n\t\t\tif ( ent->health > 0 ) {\n\t\t\t\t// take more damage the longer underwater\n\t\t\t\tent->damage += 2;\n\t\t\t\tif (ent->damage > 15)\n\t\t\t\t\tent->damage = 15;\n\n\t\t\t\t// play a gurp sound instead of a normal pain sound\n\t\t\t\tif (ent->health <= ent->damage) {\n\t\t\t\t\tG_Sound(ent, CHAN_VOICE, G_SoundIndex(\"*drown.wav\"));\n\t\t\t\t} else if (rand()&1) {\n\t\t\t\t\tG_Sound(ent, CHAN_VOICE, G_SoundIndex(\"sound/player/gurp1.wav\"));\n\t\t\t\t} else {\n\t\t\t\t\tG_Sound(ent, CHAN_VOICE, G_SoundIndex(\"sound/player/gurp2.wav\"));\n\t\t\t\t}\n\n\t\t\t\t// don't play a normal pain sound\n\t\t\t\tent->pain_debounce_time = level.time + 200;\n\n\t\t\t\tG_Damage (ent, NULL, NULL, NULL, NULL, \n\t\t\t\t\tent->damage, DAMAGE_NO_ARMOR, MOD_WATER);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tent->client->airOutTime = level.time + 12000;\n\t\tent->damage = 2;\n\t}\n\n\t//\n\t// check for sizzle damage (move to pmove?)\n\t//\n\tif (waterlevel && \n\t\t(ent->watertype&(CONTENTS_LAVA|CONTENTS_SLIME)) ) {\n\t\tif (ent->health > 0\n\t\t\t&& ent->pain_debounce_time <= level.time\t) {\n\n\t\t\tif ( envirosuit ) {\n\t\t\t\tG_AddEvent( ent, EV_POWERUP_BATTLESUIT, 0 );\n\t\t\t} else {\n\t\t\t\tif (ent->watertype & CONTENTS_LAVA) {\n\t\t\t\t\tG_Damage (ent, NULL, NULL, NULL, NULL, \n\t\t\t\t\t\t30*waterlevel, 0, MOD_LAVA);\n\t\t\t\t}\n\n\t\t\t\tif (ent->watertype & CONTENTS_SLIME) {\n\t\t\t\t\tG_Damage (ent, NULL, NULL, NULL, NULL, \n\t\t\t\t\t\t10*waterlevel, 0, MOD_SLIME);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n\n/*\n===============\nG_SetClientSound\n===============\n*/\nvoid G_SetClientSound( gentity_t *ent ) {\n#ifdef MISSIONPACK\n\tif( ent->s.eFlags & EF_TICKING ) {\n\t\tent->client->ps.loopSound = G_SoundIndex( \"sound/weapons/proxmine/wstbtick.wav\");\n\t}\n\telse\n#endif\n\tif (ent->waterlevel && (ent->watertype&(CONTENTS_LAVA|CONTENTS_SLIME)) ) {\n\t\tent->client->ps.loopSound = level.snd_fry;\n\t} else {\n\t\tent->client->ps.loopSound = 0;\n\t}\n}\n\n\n\n//==============================================================\n\n/*\n==============\nClientImpacts\n==============\n*/\nvoid ClientImpacts( gentity_t *ent, pmove_t *pm ) {\n\tint\t\ti, j;\n\ttrace_t\ttrace;\n\tgentity_t\t*other;\n\n\tmemset( &trace, 0, sizeof( trace ) );\n\tfor (i=0 ; i<pm->numtouch ; i++) {\n\t\tfor (j=0 ; j<i ; j++) {\n\t\t\tif (pm->touchents[j] == pm->touchents[i] ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (j != i) {\n\t\t\tcontinue;\t// duplicated\n\t\t}\n\t\tother = &g_entities[ pm->touchents[i] ];\n\n\t\tif ( ( ent->r.svFlags & SVF_BOT ) && ( ent->touch ) ) {\n\t\t\tent->touch( ent, other, &trace );\n\t\t}\n\n\t\tif ( !other->touch ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tother->touch( other, ent, &trace );\n\t}\n\n}\n\n/*\n============\nG_TouchTriggers\n\nFind all trigger entities that ent's current position touches.\nSpectators will only interact with teleporters.\n============\n*/\nvoid\tG_TouchTriggers( gentity_t *ent ) {\n\tint\t\t\ti, num;\n\tint\t\t\ttouch[MAX_GENTITIES];\n\tgentity_t\t*hit;\n\ttrace_t\t\ttrace;\n\tvec3_t\t\tmins, maxs;\n\tstatic vec3_t\trange = { 40, 40, 52 };\n\n\tif ( !ent->client ) {\n\t\treturn;\n\t}\n\n\t// dead clients don't activate triggers!\n\tif ( ent->client->ps.stats[STAT_HEALTH] <= 0 ) {\n\t\treturn;\n\t}\n\n\tVectorSubtract( ent->client->ps.origin, range, mins );\n\tVectorAdd( ent->client->ps.origin, range, maxs );\n\n\tnum = trap_EntitiesInBox( mins, maxs, touch, MAX_GENTITIES );\n\n\t// can't use ent->absmin, because that has a one unit pad\n\tVectorAdd( ent->client->ps.origin, ent->r.mins, mins );\n\tVectorAdd( ent->client->ps.origin, ent->r.maxs, maxs );\n\n\tfor ( i=0 ; i<num ; i++ ) {\n\t\thit = &g_entities[touch[i]];\n\n\t\tif ( !hit->touch && !ent->touch ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( !( hit->r.contents & CONTENTS_TRIGGER ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// ignore most entities if a spectator\n\t\tif ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {\n\t\t\tif ( hit->s.eType != ET_TELEPORT_TRIGGER &&\n\t\t\t\t// this is ugly but adding a new ET_? type will\n\t\t\t\t// most likely cause network incompatibilities\n\t\t\t\thit->touch != Touch_DoorTrigger) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\t// use seperate code for determining if an item is picked up\n\t\t// so you don't have to actually contact its bounding box\n\t\tif ( hit->s.eType == ET_ITEM ) {\n\t\t\tif ( !BG_PlayerTouchesItem( &ent->client->ps, &hit->s, level.time ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else {\n\t\t\tif ( !trap_EntityContact( mins, maxs, hit ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tmemset( &trace, 0, sizeof(trace) );\n\n\t\tif ( hit->touch ) {\n\t\t\thit->touch (hit, ent, &trace);\n\t\t}\n\n\t\tif ( ( ent->r.svFlags & SVF_BOT ) && ( ent->touch ) ) {\n\t\t\tent->touch( ent, hit, &trace );\n\t\t}\n\t}\n\n\t// if we didn't touch a jump pad this pmove frame\n\tif ( ent->client->ps.jumppad_frame != ent->client->ps.pmove_framecount ) {\n\t\tent->client->ps.jumppad_frame = 0;\n\t\tent->client->ps.jumppad_ent = 0;\n\t}\n}\n\n/*\n=================\nSpectatorThink\n=================\n*/\nvoid SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) {\n\tpmove_t\tpm;\n\tgclient_t\t*client;\n\n\tclient = ent->client;\n\n\tif ( client->sess.spectatorState != SPECTATOR_FOLLOW ) {\n\t\tclient->ps.pm_type = PM_SPECTATOR;\n\t\tclient->ps.speed = 400;\t// faster than normal\n\n\t\t// set up for pmove\n\t\tmemset (&pm, 0, sizeof(pm));\n\t\tpm.ps = &client->ps;\n\t\tpm.cmd = *ucmd;\n\t\tpm.tracemask = MASK_PLAYERSOLID & ~CONTENTS_BODY;\t// spectators can fly through bodies\n\t\tpm.trace = trap_Trace;\n\t\tpm.pointcontents = trap_PointContents;\n\n\t\t// perform a pmove\n\t\tPmove (&pm);\n\t\t// save results of pmove\n\t\tVectorCopy( client->ps.origin, ent->s.origin );\n\n\t\tG_TouchTriggers( ent );\n\t\ttrap_UnlinkEntity( ent );\n\t}\n\n\tclient->oldbuttons = client->buttons;\n\tclient->buttons = ucmd->buttons;\n\n\t// attack button cycles through spectators\n\tif ( ( client->buttons & BUTTON_ATTACK ) && ! ( client->oldbuttons & BUTTON_ATTACK ) ) {\n\t\tCmd_FollowCycle_f( ent, 1 );\n\t}\n}\n\n\n\n/*\n=================\nClientInactivityTimer\n\nReturns qfalse if the client is dropped\n=================\n*/\nqboolean ClientInactivityTimer( gclient_t *client ) {\n\tif ( ! g_inactivity.integer ) {\n\t\t// give everyone some time, so if the operator sets g_inactivity during\n\t\t// gameplay, everyone isn't kicked\n\t\tclient->inactivityTime = level.time + 60 * 1000;\n\t\tclient->inactivityWarning = qfalse;\n\t} else if ( client->pers.cmd.forwardmove || \n\t\tclient->pers.cmd.rightmove || \n\t\tclient->pers.cmd.upmove ||\n\t\t(client->pers.cmd.buttons & BUTTON_ATTACK) ) {\n\t\tclient->inactivityTime = level.time + g_inactivity.integer * 1000;\n\t\tclient->inactivityWarning = qfalse;\n\t} else if ( !client->pers.localClient ) {\n\t\tif ( level.time > client->inactivityTime ) {\n\t\t\ttrap_DropClient( client - level.clients, \"Dropped due to inactivity\" );\n\t\t\treturn qfalse;\n\t\t}\n\t\tif ( level.time > client->inactivityTime - 10000 && !client->inactivityWarning ) {\n\t\t\tclient->inactivityWarning = qtrue;\n\t\t\ttrap_SendServerCommand( client - level.clients, \"cp \\\"Ten seconds until inactivity drop!\\n\\\"\" );\n\t\t}\n\t}\n\treturn qtrue;\n}\n\n/*\n==================\nClientTimerActions\n\nActions that happen once a second\n==================\n*/\nvoid ClientTimerActions( gentity_t *ent, int msec ) {\n\tgclient_t\t*client;\n#ifdef MISSIONPACK\n\tint\t\t\tmaxHealth;\n#endif\n\n\tclient = ent->client;\n\tclient->timeResidual += msec;\n\n\twhile ( client->timeResidual >= 1000 ) {\n\t\tclient->timeResidual -= 1000;\n\n\t\t// regenerate\n#ifdef MISSIONPACK\n\t\tif( bg_itemlist[client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_GUARD ) {\n\t\t\tmaxHealth = client->ps.stats[STAT_MAX_HEALTH] / 2;\n\t\t}\n\t\telse if ( client->ps.powerups[PW_REGEN] ) {\n\t\t\tmaxHealth = client->ps.stats[STAT_MAX_HEALTH];\n\t\t}\n\t\telse {\n\t\t\tmaxHealth = 0;\n\t\t}\n\t\tif( maxHealth ) {\n\t\t\tif ( ent->health < maxHealth ) {\n\t\t\t\tent->health += 15;\n\t\t\t\tif ( ent->health > maxHealth * 1.1 ) {\n\t\t\t\t\tent->health = maxHealth * 1.1;\n\t\t\t\t}\n\t\t\t\tG_AddEvent( ent, EV_POWERUP_REGEN, 0 );\n\t\t\t} else if ( ent->health < maxHealth * 2) {\n\t\t\t\tent->health += 5;\n\t\t\t\tif ( ent->health > maxHealth * 2 ) {\n\t\t\t\t\tent->health = maxHealth * 2;\n\t\t\t\t}\n\t\t\t\tG_AddEvent( ent, EV_POWERUP_REGEN, 0 );\n\t\t\t}\n#else\n\t\tif ( client->ps.powerups[PW_REGEN] ) {\n\t\t\tif ( ent->health < client->ps.stats[STAT_MAX_HEALTH]) {\n\t\t\t\tent->health += 15;\n\t\t\t\tif ( ent->health > client->ps.stats[STAT_MAX_HEALTH] * 1.1 ) {\n\t\t\t\t\tent->health = client->ps.stats[STAT_MAX_HEALTH] * 1.1;\n\t\t\t\t}\n\t\t\t\tG_AddEvent( ent, EV_POWERUP_REGEN, 0 );\n\t\t\t} else if ( ent->health < client->ps.stats[STAT_MAX_HEALTH] * 2) {\n\t\t\t\tent->health += 5;\n\t\t\t\tif ( ent->health > client->ps.stats[STAT_MAX_HEALTH] * 2 ) {\n\t\t\t\t\tent->health = client->ps.stats[STAT_MAX_HEALTH] * 2;\n\t\t\t\t}\n\t\t\t\tG_AddEvent( ent, EV_POWERUP_REGEN, 0 );\n\t\t\t}\n#endif\n\t\t} else {\n\t\t\t// count down health when over max\n\t\t\tif ( ent->health > client->ps.stats[STAT_MAX_HEALTH] ) {\n\t\t\t\tent->health--;\n\t\t\t}\n\t\t}\n\n\t\t// count down armor when over max\n\t\tif ( client->ps.stats[STAT_ARMOR] > client->ps.stats[STAT_MAX_HEALTH] ) {\n\t\t\tclient->ps.stats[STAT_ARMOR]--;\n\t\t}\n\t}\n#ifdef MISSIONPACK\n\tif( bg_itemlist[client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_AMMOREGEN ) {\n\t\tint w, max, inc, t, i;\n    int weapList[]={WP_MACHINEGUN,WP_SHOTGUN,WP_GRENADE_LAUNCHER,WP_ROCKET_LAUNCHER,WP_LIGHTNING,WP_RAILGUN,WP_PLASMAGUN,WP_BFG,WP_NAILGUN,WP_PROX_LAUNCHER,WP_CHAINGUN};\n    int weapCount = sizeof(weapList) / sizeof(int);\n\t\t//\n    for (i = 0; i < weapCount; i++) {\n\t\t  w = weapList[i];\n\n\t\t  switch(w) {\n\t\t\t  case WP_MACHINEGUN: max = 50; inc = 4; t = 1000; break;\n\t\t\t  case WP_SHOTGUN: max = 10; inc = 1; t = 1500; break;\n\t\t\t  case WP_GRENADE_LAUNCHER: max = 10; inc = 1; t = 2000; break;\n\t\t\t  case WP_ROCKET_LAUNCHER: max = 10; inc = 1; t = 1750; break;\n\t\t\t  case WP_LIGHTNING: max = 50; inc = 5; t = 1500; break;\n\t\t\t  case WP_RAILGUN: max = 10; inc = 1; t = 1750; break;\n\t\t\t  case WP_PLASMAGUN: max = 50; inc = 5; t = 1500; break;\n\t\t\t  case WP_BFG: max = 10; inc = 1; t = 4000; break;\n\t\t\t  case WP_NAILGUN: max = 10; inc = 1; t = 1250; break;\n\t\t\t  case WP_PROX_LAUNCHER: max = 5; inc = 1; t = 2000; break;\n\t\t\t  case WP_CHAINGUN: max = 100; inc = 5; t = 1000; break;\n\t\t\t  default: max = 0; inc = 0; t = 1000; break;\n\t\t  }\n\t\t  client->ammoTimes[w] += msec;\n\t\t  if ( client->ps.ammo[w] >= max ) {\n\t\t\t  client->ammoTimes[w] = 0;\n\t\t  }\n\t\t  if ( client->ammoTimes[w] >= t ) {\n\t\t\t  while ( client->ammoTimes[w] >= t )\n\t\t\t\t  client->ammoTimes[w] -= t;\n\t\t\t  client->ps.ammo[w] += inc;\n\t\t\t  if ( client->ps.ammo[w] > max ) {\n\t\t\t\t  client->ps.ammo[w] = max;\n\t\t\t  }\n\t\t  }\n    }\n\t}\n#endif\n}\n\n/*\n====================\nClientIntermissionThink\n====================\n*/\nvoid ClientIntermissionThink( gclient_t *client ) {\n\tclient->ps.eFlags &= ~EF_TALK;\n\tclient->ps.eFlags &= ~EF_FIRING;\n\n\t// the level will exit when everyone wants to or after timeouts\n\n\t// swap and latch button actions\n\tclient->oldbuttons = client->buttons;\n\tclient->buttons = client->pers.cmd.buttons;\n\tif ( client->buttons & ( BUTTON_ATTACK | BUTTON_USE_HOLDABLE ) & ( client->oldbuttons ^ client->buttons ) ) {\n\t\t// this used to be an ^1 but once a player says ready, it should stick\n\t\tclient->readyToExit = 1;\n\t}\n}\n\n\n/*\n================\nClientEvents\n\nEvents will be passed on to the clients for presentation,\nbut any server game effects are handled here\n================\n*/\nvoid ClientEvents( gentity_t *ent, int oldEventSequence ) {\n\tint\t\ti, j;\n\tint\t\tevent;\n\tgclient_t *client;\n\tint\t\tdamage;\n\tvec3_t\tdir;\n\tvec3_t\torigin, angles;\n//\tqboolean\tfired;\n\tgitem_t *item;\n\tgentity_t *drop;\n\n\tclient = ent->client;\n\n\tif ( oldEventSequence < client->ps.eventSequence - MAX_PS_EVENTS ) {\n\t\toldEventSequence = client->ps.eventSequence - MAX_PS_EVENTS;\n\t}\n\tfor ( i = oldEventSequence ; i < client->ps.eventSequence ; i++ ) {\n\t\tevent = client->ps.events[ i & (MAX_PS_EVENTS-1) ];\n\n\t\tswitch ( event ) {\n\t\tcase EV_FALL_MEDIUM:\n\t\tcase EV_FALL_FAR:\n\t\t\tif ( ent->s.eType != ET_PLAYER ) {\n\t\t\t\tbreak;\t\t// not in the player model\n\t\t\t}\n\t\t\tif ( g_dmflags.integer & DF_NO_FALLING ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( event == EV_FALL_FAR ) {\n\t\t\t\tdamage = 10;\n\t\t\t} else {\n\t\t\t\tdamage = 5;\n\t\t\t}\n\t\t\tVectorSet (dir, 0, 0, 1);\n\t\t\tent->pain_debounce_time = level.time + 200;\t// no normal pain sound\n\t\t\tG_Damage (ent, NULL, NULL, NULL, NULL, damage, 0, MOD_FALLING);\n\t\t\tbreak;\n\n\t\tcase EV_FIRE_WEAPON:\n\t\t\tFireWeapon( ent );\n\t\t\tbreak;\n\n\t\tcase EV_USE_ITEM1:\t\t// teleporter\n\t\t\t// drop flags in CTF\n\t\t\titem = NULL;\n\t\t\tj = 0;\n\n\t\t\tif ( ent->client->ps.powerups[ PW_REDFLAG ] ) {\n\t\t\t\titem = BG_FindItemForPowerup( PW_REDFLAG );\n\t\t\t\tj = PW_REDFLAG;\n\t\t\t} else if ( ent->client->ps.powerups[ PW_BLUEFLAG ] ) {\n\t\t\t\titem = BG_FindItemForPowerup( PW_BLUEFLAG );\n\t\t\t\tj = PW_BLUEFLAG;\n\t\t\t} else if ( ent->client->ps.powerups[ PW_NEUTRALFLAG ] ) {\n\t\t\t\titem = BG_FindItemForPowerup( PW_NEUTRALFLAG );\n\t\t\t\tj = PW_NEUTRALFLAG;\n\t\t\t}\n\n\t\t\tif ( item ) {\n\t\t\t\tdrop = Drop_Item( ent, item, 0 );\n\t\t\t\t// decide how many seconds it has left\n\t\t\t\tdrop->count = ( ent->client->ps.powerups[ j ] - level.time ) / 1000;\n\t\t\t\tif ( drop->count < 1 ) {\n\t\t\t\t\tdrop->count = 1;\n\t\t\t\t}\n\n\t\t\t\tent->client->ps.powerups[ j ] = 0;\n\t\t\t}\n\n#ifdef MISSIONPACK\n\t\t\tif ( g_gametype.integer == GT_HARVESTER ) {\n\t\t\t\tif ( ent->client->ps.generic1 > 0 ) {\n\t\t\t\t\tif ( ent->client->sess.sessionTeam == TEAM_RED ) {\n\t\t\t\t\t\titem = BG_FindItem( \"Blue Cube\" );\n\t\t\t\t\t} else {\n\t\t\t\t\t\titem = BG_FindItem( \"Red Cube\" );\n\t\t\t\t\t}\n\t\t\t\t\tif ( item ) {\n\t\t\t\t\t\tfor ( j = 0; j < ent->client->ps.generic1; j++ ) {\n\t\t\t\t\t\t\tdrop = Drop_Item( ent, item, 0 );\n\t\t\t\t\t\t\tif ( ent->client->sess.sessionTeam == TEAM_RED ) {\n\t\t\t\t\t\t\t\tdrop->spawnflags = TEAM_BLUE;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdrop->spawnflags = TEAM_RED;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tent->client->ps.generic1 = 0;\n\t\t\t\t}\n\t\t\t}\n#endif\n\t\t\tSelectSpawnPoint( ent->client->ps.origin, origin, angles );\n\t\t\tTeleportPlayer( ent, origin, angles );\n\t\t\tbreak;\n\n\t\tcase EV_USE_ITEM2:\t\t// medkit\n\t\t\tent->health = ent->client->ps.stats[STAT_MAX_HEALTH] + 25;\n\n\t\t\tbreak;\n\n#ifdef MISSIONPACK\n\t\tcase EV_USE_ITEM3:\t\t// kamikaze\n\t\t\t// make sure the invulnerability is off\n\t\t\tent->client->invulnerabilityTime = 0;\n\t\t\t// start the kamikze\n\t\t\tG_StartKamikaze( ent );\n\t\t\tbreak;\n\n\t\tcase EV_USE_ITEM4:\t\t// portal\n\t\t\tif( ent->client->portalID ) {\n\t\t\t\tDropPortalSource( ent );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tDropPortalDestination( ent );\n\t\t\t}\n\t\t\tbreak;\n\t\tcase EV_USE_ITEM5:\t\t// invulnerability\n\t\t\tent->client->invulnerabilityTime = level.time + 10000;\n\t\t\tbreak;\n#endif\n\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}\n\n}\n\n#ifdef MISSIONPACK\n/*\n==============\nStuckInOtherClient\n==============\n*/\nstatic int StuckInOtherClient(gentity_t *ent) {\n\tint i;\n\tgentity_t\t*ent2;\n\n\tent2 = &g_entities[0];\n\tfor ( i = 0; i < MAX_CLIENTS; i++, ent2++ ) {\n\t\tif ( ent2 == ent ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( !ent2->inuse ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( !ent2->client ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( ent2->health <= 0 ) {\n\t\t\tcontinue;\n\t\t}\n\t\t//\n\t\tif (ent2->r.absmin[0] > ent->r.absmax[0])\n\t\t\tcontinue;\n\t\tif (ent2->r.absmin[1] > ent->r.absmax[1])\n\t\t\tcontinue;\n\t\tif (ent2->r.absmin[2] > ent->r.absmax[2])\n\t\t\tcontinue;\n\t\tif (ent2->r.absmax[0] < ent->r.absmin[0])\n\t\t\tcontinue;\n\t\tif (ent2->r.absmax[1] < ent->r.absmin[1])\n\t\t\tcontinue;\n\t\tif (ent2->r.absmax[2] < ent->r.absmin[2])\n\t\t\tcontinue;\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n#endif\n\nvoid BotTestSolid(vec3_t origin);\n\n/*\n==============\nSendPendingPredictableEvents\n==============\n*/\nvoid SendPendingPredictableEvents( playerState_t *ps ) {\n\tgentity_t *t;\n\tint event, seq;\n\tint extEvent, number;\n\n\t// if there are still events pending\n\tif ( ps->entityEventSequence < ps->eventSequence ) {\n\t\t// create a temporary entity for this event which is sent to everyone\n\t\t// except the client who generated the event\n\t\tseq = ps->entityEventSequence & (MAX_PS_EVENTS-1);\n\t\tevent = ps->events[ seq ] | ( ( ps->entityEventSequence & 3 ) << 8 );\n\t\t// set external event to zero before calling BG_PlayerStateToEntityState\n\t\textEvent = ps->externalEvent;\n\t\tps->externalEvent = 0;\n\t\t// create temporary entity for event\n\t\tt = G_TempEntity( ps->origin, event );\n\t\tnumber = t->s.number;\n\t\tBG_PlayerStateToEntityState( ps, &t->s, qtrue );\n\t\tt->s.number = number;\n\t\tt->s.eType = ET_EVENTS + event;\n\t\tt->s.eFlags |= EF_PLAYER_EVENT;\n\t\tt->s.otherEntityNum = ps->clientNum;\n\t\t// send to everyone except the client who generated the event\n\t\tt->r.svFlags |= SVF_NOTSINGLECLIENT;\n\t\tt->r.singleClient = ps->clientNum;\n\t\t// set back external event\n\t\tps->externalEvent = extEvent;\n\t}\n}\n\n/*\n==============\nClientThink\n\nThis will be called once for each client frame, which will\nusually be a couple times for each server frame on fast clients.\n\nIf \"g_synchronousClients 1\" is set, this will be called exactly\nonce for each server frame, which makes for smooth demo recording.\n==============\n*/\nvoid ClientThink_real( gentity_t *ent ) {\n\tgclient_t\t*client;\n\tpmove_t\t\tpm;\n\tint\t\t\toldEventSequence;\n\tint\t\t\tmsec;\n\tusercmd_t\t*ucmd;\n\n\tclient = ent->client;\n\n\t// don't think if the client is not yet connected (and thus not yet spawned in)\n\tif (client->pers.connected != CON_CONNECTED) {\n\t\treturn;\n\t}\n\t// mark the time, so the connection sprite can be removed\n\tucmd = &ent->client->pers.cmd;\n\n\t// sanity check the command time to prevent speedup cheating\n\tif ( ucmd->serverTime > level.time + 200 ) {\n\t\tucmd->serverTime = level.time + 200;\n//\t\tG_Printf(\"serverTime <<<<<\\n\" );\n\t}\n\tif ( ucmd->serverTime < level.time - 1000 ) {\n\t\tucmd->serverTime = level.time - 1000;\n//\t\tG_Printf(\"serverTime >>>>>\\n\" );\n\t} \n\n\tmsec = ucmd->serverTime - client->ps.commandTime;\n\t// following others may result in bad times, but we still want\n\t// to check for follow toggles\n\tif ( msec < 1 && client->sess.spectatorState != SPECTATOR_FOLLOW ) {\n\t\treturn;\n\t}\n\tif ( msec > 200 ) {\n\t\tmsec = 200;\n\t}\n\n\tif ( pmove_msec.integer < 8 ) {\n\t\ttrap_Cvar_Set(\"pmove_msec\", \"8\");\n\t}\n\telse if (pmove_msec.integer > 33) {\n\t\ttrap_Cvar_Set(\"pmove_msec\", \"33\");\n\t}\n\n\tif ( pmove_fixed.integer || client->pers.pmoveFixed ) {\n\t\tucmd->serverTime = ((ucmd->serverTime + pmove_msec.integer-1) / pmove_msec.integer) * pmove_msec.integer;\n\t\t//if (ucmd->serverTime - client->ps.commandTime <= 0)\n\t\t//\treturn;\n\t}\n\n\t//\n\t// check for exiting intermission\n\t//\n\tif ( level.intermissiontime ) {\n\t\tClientIntermissionThink( client );\n\t\treturn;\n\t}\n\n\t// spectators don't do much\n\tif ( client->sess.sessionTeam == TEAM_SPECTATOR ) {\n\t\tif ( client->sess.spectatorState == SPECTATOR_SCOREBOARD ) {\n\t\t\treturn;\n\t\t}\n\t\tSpectatorThink( ent, ucmd );\n\t\treturn;\n\t}\n\n\t// check for inactivity timer, but never drop the local client of a non-dedicated server\n\tif ( !ClientInactivityTimer( client ) ) {\n\t\treturn;\n\t}\n\n\t// clear the rewards if time\n\tif ( level.time > client->rewardTime ) {\n\t\tclient->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );\n\t}\n\n\tif ( client->noclip ) {\n\t\tclient->ps.pm_type = PM_NOCLIP;\n\t} else if ( client->ps.stats[STAT_HEALTH] <= 0 ) {\n\t\tclient->ps.pm_type = PM_DEAD;\n\t} else {\n\t\tclient->ps.pm_type = PM_NORMAL;\n\t}\n\n\tclient->ps.gravity = g_gravity.value;\n\n\t// set speed\n\tclient->ps.speed = g_speed.value;\n\n#ifdef MISSIONPACK\n\tif( bg_itemlist[client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_SCOUT ) {\n\t\tclient->ps.speed *= 1.5;\n\t}\n\telse\n#endif\n\tif ( client->ps.powerups[PW_HASTE] ) {\n\t\tclient->ps.speed *= 1.3;\n\t}\n\n\t// Let go of the hook if we aren't firing\n\tif ( client->ps.weapon == WP_GRAPPLING_HOOK &&\n\t\tclient->hook && !( ucmd->buttons & BUTTON_ATTACK ) ) {\n\t\tWeapon_HookFree(client->hook);\n\t}\n\n\t// set up for pmove\n\toldEventSequence = client->ps.eventSequence;\n\n\tmemset (&pm, 0, sizeof(pm));\n\n\t// check for the hit-scan gauntlet, don't let the action\n\t// go through as an attack unless it actually hits something\n\tif ( client->ps.weapon == WP_GAUNTLET && !( ucmd->buttons & BUTTON_TALK ) &&\n\t\t( ucmd->buttons & BUTTON_ATTACK ) && client->ps.weaponTime <= 0 ) {\n\t\tpm.gauntletHit = CheckGauntletAttack( ent );\n\t}\n\n\tif ( ent->flags & FL_FORCE_GESTURE ) {\n\t\tent->flags &= ~FL_FORCE_GESTURE;\n\t\tent->client->pers.cmd.buttons |= BUTTON_GESTURE;\n\t}\n\n#ifdef MISSIONPACK\n\t// check for invulnerability expansion before doing the Pmove\n\tif (client->ps.powerups[PW_INVULNERABILITY] ) {\n\t\tif ( !(client->ps.pm_flags & PMF_INVULEXPAND) ) {\n\t\t\tvec3_t mins = { -42, -42, -42 };\n\t\t\tvec3_t maxs = { 42, 42, 42 };\n\t\t\tvec3_t oldmins, oldmaxs;\n\n\t\t\tVectorCopy (ent->r.mins, oldmins);\n\t\t\tVectorCopy (ent->r.maxs, oldmaxs);\n\t\t\t// expand\n\t\t\tVectorCopy (mins, ent->r.mins);\n\t\t\tVectorCopy (maxs, ent->r.maxs);\n\t\t\ttrap_LinkEntity(ent);\n\t\t\t// check if this would get anyone stuck in this player\n\t\t\tif ( !StuckInOtherClient(ent) ) {\n\t\t\t\t// set flag so the expanded size will be set in PM_CheckDuck\n\t\t\t\tclient->ps.pm_flags |= PMF_INVULEXPAND;\n\t\t\t}\n\t\t\t// set back\n\t\t\tVectorCopy (oldmins, ent->r.mins);\n\t\t\tVectorCopy (oldmaxs, ent->r.maxs);\n\t\t\ttrap_LinkEntity(ent);\n\t\t}\n\t}\n#endif\n\n\tpm.ps = &client->ps;\n\tpm.cmd = *ucmd;\n\tif ( pm.ps->pm_type == PM_DEAD ) {\n\t\tpm.tracemask = MASK_PLAYERSOLID & ~CONTENTS_BODY;\n\t}\n\telse if ( ent->r.svFlags & SVF_BOT ) {\n\t\tpm.tracemask = MASK_PLAYERSOLID | CONTENTS_BOTCLIP;\n\t}\n\telse {\n\t\tpm.tracemask = MASK_PLAYERSOLID;\n\t}\n\tpm.trace = trap_Trace;\n\tpm.pointcontents = trap_PointContents;\n\tpm.debugLevel = g_debugMove.integer;\n\tpm.noFootsteps = ( g_dmflags.integer & DF_NO_FOOTSTEPS ) > 0;\n\n\tpm.pmove_fixed = pmove_fixed.integer | client->pers.pmoveFixed;\n\tpm.pmove_msec = pmove_msec.integer;\n\n\tVectorCopy( client->ps.origin, client->oldOrigin );\n\n#ifdef MISSIONPACK\n\t\tif (level.intermissionQueued != 0 && g_singlePlayer.integer) {\n\t\t\tif ( level.time - level.intermissionQueued >= 1000  ) {\n\t\t\t\tpm.cmd.buttons = 0;\n\t\t\t\tpm.cmd.forwardmove = 0;\n\t\t\t\tpm.cmd.rightmove = 0;\n\t\t\t\tpm.cmd.upmove = 0;\n\t\t\t\tif ( level.time - level.intermissionQueued >= 2000 && level.time - level.intermissionQueued <= 2500 ) {\n\t\t\t\t\ttrap_SendConsoleCommand( EXEC_APPEND, \"centerview\\n\");\n\t\t\t\t}\n\t\t\t\tent->client->ps.pm_type = PM_SPINTERMISSION;\n\t\t\t}\n\t\t}\n\t\tPmove (&pm);\n#else\n\t\tPmove (&pm);\n#endif\n\n\t// save results of pmove\n\tif ( ent->client->ps.eventSequence != oldEventSequence ) {\n\t\tent->eventTime = level.time;\n\t}\n\tif (g_smoothClients.integer) {\n\t\tBG_PlayerStateToEntityStateExtraPolate( &ent->client->ps, &ent->s, ent->client->ps.commandTime, qtrue );\n\t}\n\telse {\n\t\tBG_PlayerStateToEntityState( &ent->client->ps, &ent->s, qtrue );\n\t}\n\tSendPendingPredictableEvents( &ent->client->ps );\n\n\tif ( !( ent->client->ps.eFlags & EF_FIRING ) ) {\n\t\tclient->fireHeld = qfalse;\t\t// for grapple\n\t}\n\n\t// use the snapped origin for linking so it matches client predicted versions\n\tVectorCopy( ent->s.pos.trBase, ent->r.currentOrigin );\n\n\tVectorCopy (pm.mins, ent->r.mins);\n\tVectorCopy (pm.maxs, ent->r.maxs);\n\n\tent->waterlevel = pm.waterlevel;\n\tent->watertype = pm.watertype;\n\n\t// execute client events\n\tClientEvents( ent, oldEventSequence );\n\n\t// link entity now, after any personal teleporters have been used\n\ttrap_LinkEntity (ent);\n\tif ( !ent->client->noclip ) {\n\t\tG_TouchTriggers( ent );\n\t}\n\n\t// NOTE: now copy the exact origin over otherwise clients can be snapped into solid\n\tVectorCopy( ent->client->ps.origin, ent->r.currentOrigin );\n\n\t//test for solid areas in the AAS file\n\tBotTestAAS(ent->r.currentOrigin);\n\n\t// touch other objects\n\tClientImpacts( ent, &pm );\n\n\t// save results of triggers and client events\n\tif (ent->client->ps.eventSequence != oldEventSequence) {\n\t\tent->eventTime = level.time;\n\t}\n\n\t// swap and latch button actions\n\tclient->oldbuttons = client->buttons;\n\tclient->buttons = ucmd->buttons;\n\tclient->latched_buttons |= client->buttons & ~client->oldbuttons;\n\n\t// check for respawning\n\tif ( client->ps.stats[STAT_HEALTH] <= 0 ) {\n\t\t// wait for the attack button to be pressed\n\t\tif ( level.time > client->respawnTime ) {\n\t\t\t// forcerespawn is to prevent users from waiting out powerups\n\t\t\tif ( g_forcerespawn.integer > 0 && \n\t\t\t\t( level.time - client->respawnTime ) > g_forcerespawn.integer * 1000 ) {\n\t\t\t\trespawn( ent );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\n\t\t\t// pressing attack or use is the normal respawn method\n\t\t\tif ( ucmd->buttons & ( BUTTON_ATTACK | BUTTON_USE_HOLDABLE ) ) {\n\t\t\t\trespawn( ent );\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\n\t// perform once-a-second actions\n\tClientTimerActions( ent, msec );\n}\n\n/*\n==================\nClientThink\n\nA new command has arrived from the client\n==================\n*/\nvoid ClientThink( int clientNum ) {\n\tgentity_t *ent;\n\n\tent = g_entities + clientNum;\n\ttrap_GetUsercmd( clientNum, &ent->client->pers.cmd );\n\n\t// mark the time we got info, so we can display the\n\t// phone jack if they don't get any for a while\n\tent->client->lastCmdTime = level.time;\n\n\tif ( !(ent->r.svFlags & SVF_BOT) && !g_synchronousClients.integer ) {\n\t\tClientThink_real( ent );\n\t}\n}\n\n\nvoid G_RunClient( gentity_t *ent ) {\n\tif ( !(ent->r.svFlags & SVF_BOT) && !g_synchronousClients.integer ) {\n\t\treturn;\n\t}\n\tent->client->pers.cmd.serverTime = level.time;\n\tClientThink_real( ent );\n}\n\n\n/*\n==================\nSpectatorClientEndFrame\n\n==================\n*/\nvoid SpectatorClientEndFrame( gentity_t *ent ) {\n\tgclient_t\t*cl;\n\n\t// if we are doing a chase cam or a remote view, grab the latest info\n\tif ( ent->client->sess.spectatorState == SPECTATOR_FOLLOW ) {\n\t\tint\t\tclientNum, flags;\n\n\t\tclientNum = ent->client->sess.spectatorClient;\n\n\t\t// team follow1 and team follow2 go to whatever clients are playing\n\t\tif ( clientNum == -1 ) {\n\t\t\tclientNum = level.follow1;\n\t\t} else if ( clientNum == -2 ) {\n\t\t\tclientNum = level.follow2;\n\t\t}\n\t\tif ( clientNum >= 0 ) {\n\t\t\tcl = &level.clients[ clientNum ];\n\t\t\tif ( cl->pers.connected == CON_CONNECTED && cl->sess.sessionTeam != TEAM_SPECTATOR ) {\n\t\t\t\tflags = (cl->ps.eFlags & ~(EF_VOTED | EF_TEAMVOTED)) | (ent->client->ps.eFlags & (EF_VOTED | EF_TEAMVOTED));\n\t\t\t\tent->client->ps = cl->ps;\n\t\t\t\tent->client->ps.pm_flags |= PMF_FOLLOW;\n\t\t\t\tent->client->ps.eFlags = flags;\n\t\t\t\treturn;\n\t\t\t} else {\n\t\t\t\t// drop them to free spectators unless they are dedicated camera followers\n\t\t\t\tif ( ent->client->sess.spectatorClient >= 0 ) {\n\t\t\t\t\tent->client->sess.spectatorState = SPECTATOR_FREE;\n\t\t\t\t\tClientBegin( ent->client - level.clients );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( ent->client->sess.spectatorState == SPECTATOR_SCOREBOARD ) {\n\t\tent->client->ps.pm_flags |= PMF_SCOREBOARD;\n\t} else {\n\t\tent->client->ps.pm_flags &= ~PMF_SCOREBOARD;\n\t}\n}\n\n/*\n==============\nClientEndFrame\n\nCalled at the end of each server frame for each connected client\nA fast client will have multiple ClientThink for each ClientEdFrame,\nwhile a slow client may have multiple ClientEndFrame between ClientThink.\n==============\n*/\nvoid ClientEndFrame( gentity_t *ent ) {\n\tint\t\t\ti;\n\tclientPersistant_t\t*pers;\n\n\tif ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {\n\t\tSpectatorClientEndFrame( ent );\n\t\treturn;\n\t}\n\n\tpers = &ent->client->pers;\n\n\t// turn off any expired powerups\n\tfor ( i = 0 ; i < MAX_POWERUPS ; i++ ) {\n\t\tif ( ent->client->ps.powerups[ i ] < level.time ) {\n\t\t\tent->client->ps.powerups[ i ] = 0;\n\t\t}\n\t}\n\n#ifdef MISSIONPACK\n\t// set powerup for player animation\n\tif( bg_itemlist[ent->client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_GUARD ) {\n\t\tent->client->ps.powerups[PW_GUARD] = level.time;\n\t}\n\tif( bg_itemlist[ent->client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_SCOUT ) {\n\t\tent->client->ps.powerups[PW_SCOUT] = level.time;\n\t}\n\tif( bg_itemlist[ent->client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_DOUBLER ) {\n\t\tent->client->ps.powerups[PW_DOUBLER] = level.time;\n\t}\n\tif( bg_itemlist[ent->client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_AMMOREGEN ) {\n\t\tent->client->ps.powerups[PW_AMMOREGEN] = level.time;\n\t}\n\tif ( ent->client->invulnerabilityTime > level.time ) {\n\t\tent->client->ps.powerups[PW_INVULNERABILITY] = level.time;\n\t}\n#endif\n\n\t// save network bandwidth\n#if 0\n\tif ( !g_synchronousClients->integer && ent->client->ps.pm_type == PM_NORMAL ) {\n\t\t// FIXME: this must change eventually for non-sync demo recording\n\t\tVectorClear( ent->client->ps.viewangles );\n\t}\n#endif\n\n\t//\n\t// If the end of unit layout is displayed, don't give\n\t// the player any normal movement attributes\n\t//\n\tif ( level.intermissiontime ) {\n\t\treturn;\n\t}\n\n\t// burn from lava, etc\n\tP_WorldEffects (ent);\n\n\t// apply all the damage taken this frame\n\tP_DamageFeedback (ent);\n\n\t// add the EF_CONNECTION flag if we haven't gotten commands recently\n\tif ( level.time - ent->client->lastCmdTime > 1000 ) {\n\t\tent->s.eFlags |= EF_CONNECTION;\n\t} else {\n\t\tent->s.eFlags &= ~EF_CONNECTION;\n\t}\n\n\tent->client->ps.stats[STAT_HEALTH] = ent->health;\t// FIXME: get rid of ent->health...\n\n\tG_SetClientSound (ent);\n\n\t// set the latest infor\n\tif (g_smoothClients.integer) {\n\t\tBG_PlayerStateToEntityStateExtraPolate( &ent->client->ps, &ent->s, ent->client->ps.commandTime, qtrue );\n\t}\n\telse {\n\t\tBG_PlayerStateToEntityState( &ent->client->ps, &ent->s, qtrue );\n\t}\n\tSendPendingPredictableEvents( &ent->client->ps );\n\n\t// set the bit for the reachability area the client is currently in\n//\ti = trap_AAS_PointReachabilityAreaIndex( ent->client->ps.origin );\n//\tent->client->areabits[i >> 3] |= 1 << (i & 7);\n}\n\n\n"
  },
  {
    "path": "code/game/g_arenas.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n//\n// g_arenas.c\n//\n\n#include \"g_local.h\"\n\n\ngentity_t\t*podium1;\ngentity_t\t*podium2;\ngentity_t\t*podium3;\n\n\n/*\n==================\nUpdateTournamentInfo\n==================\n*/\nvoid UpdateTournamentInfo( void ) {\n\tint\t\t\ti;\n\tgentity_t\t*player;\n\tint\t\t\tplayerClientNum;\n\tint\t\t\tn, accuracy, perfect,\tmsglen;\n\tint\t\t\tbuflen;\n#ifdef MISSIONPACK // bk001205\n  int score1, score2;\n\tqboolean won;\n#endif\n\tchar\t\tbuf[32];\n\tchar\t\tmsg[MAX_STRING_CHARS];\n\n\t// find the real player\n\tplayer = NULL;\n\tfor (i = 0; i < level.maxclients; i++ ) {\n\t\tplayer = &g_entities[i];\n\t\tif ( !player->inuse ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( !( player->r.svFlags & SVF_BOT ) ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\t// this should never happen!\n\tif ( !player || i == level.maxclients ) {\n\t\treturn;\n\t}\n\tplayerClientNum = i;\n\n\tCalculateRanks();\n\n\tif ( level.clients[playerClientNum].sess.sessionTeam == TEAM_SPECTATOR ) {\n#ifdef MISSIONPACK\n\t\tCom_sprintf( msg, sizeof(msg), \"postgame %i %i 0 0 0 0 0 0 0 0 0 0 0\", level.numNonSpectatorClients, playerClientNum );\n#else\n\t\tCom_sprintf( msg, sizeof(msg), \"postgame %i %i 0 0 0 0 0 0\", level.numNonSpectatorClients, playerClientNum );\n#endif\n\t}\n\telse {\n\t\tif( player->client->accuracy_shots ) {\n\t\t\taccuracy = player->client->accuracy_hits * 100 / player->client->accuracy_shots;\n\t\t}\n\t\telse {\n\t\t\taccuracy = 0;\n\t\t}\n#ifdef MISSIONPACK\n\t\twon = qfalse;\n\t\tif (g_gametype.integer >= GT_CTF) {\n\t\t\tscore1 = level.teamScores[TEAM_RED];\n\t\t\tscore2 = level.teamScores[TEAM_BLUE];\n\t\t\tif (level.clients[playerClientNum].sess.sessionTeam\t== TEAM_RED) {\n\t\t\t\twon = (level.teamScores[TEAM_RED] > level.teamScores[TEAM_BLUE]);\n\t\t\t} else {\n\t\t\t\twon = (level.teamScores[TEAM_BLUE] > level.teamScores[TEAM_RED]);\n\t\t\t}\n\t\t} else {\n\t\t\tif (&level.clients[playerClientNum] == &level.clients[ level.sortedClients[0] ]) {\n\t\t\t\twon = qtrue;\n\t\t\t\tscore1 = level.clients[ level.sortedClients[0] ].ps.persistant[PERS_SCORE];\n\t\t\t\tscore2 = level.clients[ level.sortedClients[1] ].ps.persistant[PERS_SCORE];\n\t\t\t} else {\n\t\t\t\tscore2 = level.clients[ level.sortedClients[0] ].ps.persistant[PERS_SCORE];\n\t\t\t\tscore1 = level.clients[ level.sortedClients[1] ].ps.persistant[PERS_SCORE];\n\t\t\t}\n\t\t}\n\t\tif (won && player->client->ps.persistant[PERS_KILLED] == 0) {\n\t\t\tperfect = 1;\n\t\t} else {\n\t\t\tperfect = 0;\n\t\t}\n\t\tCom_sprintf( msg, sizeof(msg), \"postgame %i %i %i %i %i %i %i %i %i %i %i %i %i %i\", level.numNonSpectatorClients, playerClientNum, accuracy,\n\t\t\tplayer->client->ps.persistant[PERS_IMPRESSIVE_COUNT], player->client->ps.persistant[PERS_EXCELLENT_COUNT],player->client->ps.persistant[PERS_DEFEND_COUNT],\n\t\t\tplayer->client->ps.persistant[PERS_ASSIST_COUNT], player->client->ps.persistant[PERS_GAUNTLET_FRAG_COUNT], player->client->ps.persistant[PERS_SCORE],\n\t\t\tperfect, score1, score2, level.time, player->client->ps.persistant[PERS_CAPTURES] );\n\n#else\n\t\tperfect = ( level.clients[playerClientNum].ps.persistant[PERS_RANK] == 0 && player->client->ps.persistant[PERS_KILLED] == 0 ) ? 1 : 0;\n\t\tCom_sprintf( msg, sizeof(msg), \"postgame %i %i %i %i %i %i %i %i\", level.numNonSpectatorClients, playerClientNum, accuracy,\n\t\t\tplayer->client->ps.persistant[PERS_IMPRESSIVE_COUNT], player->client->ps.persistant[PERS_EXCELLENT_COUNT],\n\t\t\tplayer->client->ps.persistant[PERS_GAUNTLET_FRAG_COUNT], player->client->ps.persistant[PERS_SCORE],\n\t\t\tperfect );\n#endif\n\t}\n\n\tmsglen = strlen( msg );\n\tfor( i = 0; i < level.numNonSpectatorClients; i++ ) {\n\t\tn = level.sortedClients[i];\n\t\tCom_sprintf( buf, sizeof(buf), \" %i %i %i\", n, level.clients[n].ps.persistant[PERS_RANK], level.clients[n].ps.persistant[PERS_SCORE] );\n\t\tbuflen = strlen( buf );\n\t\tif( msglen + buflen + 1 >= sizeof(msg) ) {\n\t\t\tbreak;\n\t\t}\n\t\tstrcat( msg, buf );\n\t}\n\ttrap_SendConsoleCommand( EXEC_APPEND, msg );\n}\n\n\nstatic gentity_t *SpawnModelOnVictoryPad( gentity_t *pad, vec3_t offset, gentity_t *ent, int place ) {\n\tgentity_t\t*body;\n\tvec3_t\t\tvec;\n\tvec3_t\t\tf, r, u;\n\n\tbody = G_Spawn();\n\tif ( !body ) {\n\t\tG_Printf( S_COLOR_RED \"ERROR: out of gentities\\n\" );\n\t\treturn NULL;\n\t}\n\n\tbody->classname = ent->client->pers.netname;\n\tbody->client = ent->client;\n\tbody->s = ent->s;\n\tbody->s.eType = ET_PLAYER;\t\t// could be ET_INVISIBLE\n\tbody->s.eFlags = 0;\t\t\t\t// clear EF_TALK, etc\n\tbody->s.powerups = 0;\t\t\t// clear powerups\n\tbody->s.loopSound = 0;\t\t\t// clear lava burning\n\tbody->s.number = body - g_entities;\n\tbody->timestamp = level.time;\n\tbody->physicsObject = qtrue;\n\tbody->physicsBounce = 0;\t\t// don't bounce\n\tbody->s.event = 0;\n\tbody->s.pos.trType = TR_STATIONARY;\n\tbody->s.groundEntityNum = ENTITYNUM_WORLD;\n\tbody->s.legsAnim = LEGS_IDLE;\n\tbody->s.torsoAnim = TORSO_STAND;\n\tif( body->s.weapon == WP_NONE ) {\n\t\tbody->s.weapon = WP_MACHINEGUN;\n\t}\n\tif( body->s.weapon == WP_GAUNTLET) {\n\t\tbody->s.torsoAnim = TORSO_STAND2;\n\t}\n\tbody->s.event = 0;\n\tbody->r.svFlags = ent->r.svFlags;\n\tVectorCopy (ent->r.mins, body->r.mins);\n\tVectorCopy (ent->r.maxs, body->r.maxs);\n\tVectorCopy (ent->r.absmin, body->r.absmin);\n\tVectorCopy (ent->r.absmax, body->r.absmax);\n\tbody->clipmask = CONTENTS_SOLID | CONTENTS_PLAYERCLIP;\n\tbody->r.contents = CONTENTS_BODY;\n\tbody->r.ownerNum = ent->r.ownerNum;\n\tbody->takedamage = qfalse;\n\n\tVectorSubtract( level.intermission_origin, pad->r.currentOrigin, vec );\n\tvectoangles( vec, body->s.apos.trBase );\n\tbody->s.apos.trBase[PITCH] = 0;\n\tbody->s.apos.trBase[ROLL] = 0;\n\n\tAngleVectors( body->s.apos.trBase, f, r, u );\n\tVectorMA( pad->r.currentOrigin, offset[0], f, vec );\n\tVectorMA( vec, offset[1], r, vec );\n\tVectorMA( vec, offset[2], u, vec );\n\n\tG_SetOrigin( body, vec );\n\n\ttrap_LinkEntity (body);\n\n\tbody->count = place;\n\n\treturn body;\n}\n\n\nstatic void CelebrateStop( gentity_t *player ) {\n\tint\t\tanim;\n\n\tif( player->s.weapon == WP_GAUNTLET) {\n\t\tanim = TORSO_STAND2;\n\t}\n\telse {\n\t\tanim = TORSO_STAND;\n\t}\n\tplayer->s.torsoAnim = ( ( player->s.torsoAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim;\n}\n\n\n#define\tTIMER_GESTURE\t(34*66+50)\nstatic void CelebrateStart( gentity_t *player ) {\n\tplayer->s.torsoAnim = ( ( player->s.torsoAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | TORSO_GESTURE;\n\tplayer->nextthink = level.time + TIMER_GESTURE;\n\tplayer->think = CelebrateStop;\n\n\t/*\n\tplayer->client->ps.events[player->client->ps.eventSequence & (MAX_PS_EVENTS-1)] = EV_TAUNT;\n\tplayer->client->ps.eventParms[player->client->ps.eventSequence & (MAX_PS_EVENTS-1)] = 0;\n\tplayer->client->ps.eventSequence++;\n\t*/\n\tG_AddEvent(player, EV_TAUNT, 0);\n}\n\n\nstatic vec3_t\toffsetFirst  = {0, 0, 74};\nstatic vec3_t\toffsetSecond = {-10, 60, 54};\nstatic vec3_t\toffsetThird  = {-19, -60, 45};\n\nstatic void PodiumPlacementThink( gentity_t *podium ) {\n\tvec3_t\t\tvec;\n\tvec3_t\t\torigin;\n\tvec3_t\t\tf, r, u;\n\n\tpodium->nextthink = level.time + 100;\n\n\tAngleVectors( level.intermission_angle, vec, NULL, NULL );\n\tVectorMA( level.intermission_origin, trap_Cvar_VariableIntegerValue( \"g_podiumDist\" ), vec, origin );\n\torigin[2] -= trap_Cvar_VariableIntegerValue( \"g_podiumDrop\" );\n\tG_SetOrigin( podium, origin );\n\n\tif( podium1 ) {\n\t\tVectorSubtract( level.intermission_origin, podium->r.currentOrigin, vec );\n\t\tvectoangles( vec, podium1->s.apos.trBase );\n\t\tpodium1->s.apos.trBase[PITCH] = 0;\n\t\tpodium1->s.apos.trBase[ROLL] = 0;\n\n\t\tAngleVectors( podium1->s.apos.trBase, f, r, u );\n\t\tVectorMA( podium->r.currentOrigin, offsetFirst[0], f, vec );\n\t\tVectorMA( vec, offsetFirst[1], r, vec );\n\t\tVectorMA( vec, offsetFirst[2], u, vec );\n\n\t\tG_SetOrigin( podium1, vec );\n\t}\n\n\tif( podium2 ) {\n\t\tVectorSubtract( level.intermission_origin, podium->r.currentOrigin, vec );\n\t\tvectoangles( vec, podium2->s.apos.trBase );\n\t\tpodium2->s.apos.trBase[PITCH] = 0;\n\t\tpodium2->s.apos.trBase[ROLL] = 0;\n\n\t\tAngleVectors( podium2->s.apos.trBase, f, r, u );\n\t\tVectorMA( podium->r.currentOrigin, offsetSecond[0], f, vec );\n\t\tVectorMA( vec, offsetSecond[1], r, vec );\n\t\tVectorMA( vec, offsetSecond[2], u, vec );\n\n\t\tG_SetOrigin( podium2, vec );\n\t}\n\n\tif( podium3 ) {\n\t\tVectorSubtract( level.intermission_origin, podium->r.currentOrigin, vec );\n\t\tvectoangles( vec, podium3->s.apos.trBase );\n\t\tpodium3->s.apos.trBase[PITCH] = 0;\n\t\tpodium3->s.apos.trBase[ROLL] = 0;\n\n\t\tAngleVectors( podium3->s.apos.trBase, f, r, u );\n\t\tVectorMA( podium->r.currentOrigin, offsetThird[0], f, vec );\n\t\tVectorMA( vec, offsetThird[1], r, vec );\n\t\tVectorMA( vec, offsetThird[2], u, vec );\n\n\t\tG_SetOrigin( podium3, vec );\n\t}\n}\n\n\nstatic gentity_t *SpawnPodium( void ) {\n\tgentity_t\t*podium;\n\tvec3_t\t\tvec;\n\tvec3_t\t\torigin;\n\n\tpodium = G_Spawn();\n\tif ( !podium ) {\n\t\treturn NULL;\n\t}\n\n\tpodium->classname = \"podium\";\n\tpodium->s.eType = ET_GENERAL;\n\tpodium->s.number = podium - g_entities;\n\tpodium->clipmask = CONTENTS_SOLID;\n\tpodium->r.contents = CONTENTS_SOLID;\n\tpodium->s.modelindex = G_ModelIndex( SP_PODIUM_MODEL );\n\n\tAngleVectors( level.intermission_angle, vec, NULL, NULL );\n\tVectorMA( level.intermission_origin, trap_Cvar_VariableIntegerValue( \"g_podiumDist\" ), vec, origin );\n\torigin[2] -= trap_Cvar_VariableIntegerValue( \"g_podiumDrop\" );\n\tG_SetOrigin( podium, origin );\n\n\tVectorSubtract( level.intermission_origin, podium->r.currentOrigin, vec );\n\tpodium->s.apos.trBase[YAW] = vectoyaw( vec );\n\ttrap_LinkEntity (podium);\n\n\tpodium->think = PodiumPlacementThink;\n\tpodium->nextthink = level.time + 100;\n\treturn podium;\n}\n\n\n/*\n==================\nSpawnModelsOnVictoryPads\n==================\n*/\nvoid SpawnModelsOnVictoryPads( void ) {\n\tgentity_t\t*player;\n\tgentity_t\t*podium;\n\n\tpodium1 = NULL;\n\tpodium2 = NULL;\n\tpodium3 = NULL;\n\n\tpodium = SpawnPodium();\n\n\tplayer = SpawnModelOnVictoryPad( podium, offsetFirst, &g_entities[level.sortedClients[0]],\n\t\t\t\tlevel.clients[ level.sortedClients[0] ].ps.persistant[PERS_RANK] &~ RANK_TIED_FLAG );\n\tif ( player ) {\n\t\tplayer->nextthink = level.time + 2000;\n\t\tplayer->think = CelebrateStart;\n\t\tpodium1 = player;\n\t}\n\n\tplayer = SpawnModelOnVictoryPad( podium, offsetSecond, &g_entities[level.sortedClients[1]],\n\t\t\t\tlevel.clients[ level.sortedClients[1] ].ps.persistant[PERS_RANK] &~ RANK_TIED_FLAG );\n\tif ( player ) {\n\t\tpodium2 = player;\n\t}\n\n\tif ( level.numNonSpectatorClients > 2 ) {\n\t\tplayer = SpawnModelOnVictoryPad( podium, offsetThird, &g_entities[level.sortedClients[2]],\n\t\t\t\tlevel.clients[ level.sortedClients[2] ].ps.persistant[PERS_RANK] &~ RANK_TIED_FLAG );\n\t\tif ( player ) {\n\t\t\tpodium3 = player;\n\t\t}\n\t}\n}\n\n\n/*\n===============\nSvcmd_AbortPodium_f\n===============\n*/\nvoid Svcmd_AbortPodium_f( void ) {\n\tif( g_gametype.integer != GT_SINGLE_PLAYER ) {\n\t\treturn;\n\t}\n\n\tif( podium1 ) {\n\t\tpodium1->nextthink = level.time;\n\t\tpodium1->think = CelebrateStop;\n\t}\n}\n"
  },
  {
    "path": "code/game/g_bot.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// g_bot.c\n\n#include \"g_local.h\"\n\n\nstatic int\t\tg_numBots;\nstatic char\t\t*g_botInfos[MAX_BOTS];\n\n\nint\t\t\t\tg_numArenas;\nstatic char\t\t*g_arenaInfos[MAX_ARENAS];\n\n\n#define BOT_BEGIN_DELAY_BASE\t\t2000\n#define BOT_BEGIN_DELAY_INCREMENT\t1500\n\n#define BOT_SPAWN_QUEUE_DEPTH\t16\n\ntypedef struct {\n\tint\t\tclientNum;\n\tint\t\tspawnTime;\n} botSpawnQueue_t;\n\n//static int\t\t\tbotBeginDelay = 0;  // bk001206 - unused, init\nstatic botSpawnQueue_t\tbotSpawnQueue[BOT_SPAWN_QUEUE_DEPTH];\n\nvmCvar_t bot_minplayers;\n\nextern gentity_t\t*podium1;\nextern gentity_t\t*podium2;\nextern gentity_t\t*podium3;\n\nfloat trap_Cvar_VariableValue( const char *var_name ) {\n\tchar buf[128];\n\n\ttrap_Cvar_VariableStringBuffer(var_name, buf, sizeof(buf));\n\treturn atof(buf);\n}\n\n\n\n/*\n===============\nG_ParseInfos\n===============\n*/\nint G_ParseInfos( char *buf, int max, char *infos[] ) {\n\tchar\t*token;\n\tint\t\tcount;\n\tchar\tkey[MAX_TOKEN_CHARS];\n\tchar\tinfo[MAX_INFO_STRING];\n\n\tcount = 0;\n\n\twhile ( 1 ) {\n\t\ttoken = COM_Parse( &buf );\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( strcmp( token, \"{\" ) ) {\n\t\t\tCom_Printf( \"Missing { in info file\\n\" );\n\t\t\tbreak;\n\t\t}\n\n\t\tif ( count == max ) {\n\t\t\tCom_Printf( \"Max infos exceeded\\n\" );\n\t\t\tbreak;\n\t\t}\n\n\t\tinfo[0] = '\\0';\n\t\twhile ( 1 ) {\n\t\t\ttoken = COM_ParseExt( &buf, qtrue );\n\t\t\tif ( !token[0] ) {\n\t\t\t\tCom_Printf( \"Unexpected end of info file\\n\" );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( !strcmp( token, \"}\" ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tQ_strncpyz( key, token, sizeof( key ) );\n\n\t\t\ttoken = COM_ParseExt( &buf, qfalse );\n\t\t\tif ( !token[0] ) {\n\t\t\t\tstrcpy( token, \"<NULL>\" );\n\t\t\t}\n\t\t\tInfo_SetValueForKey( info, key, token );\n\t\t}\n\t\t//NOTE: extra space for arena number\n\t\tinfos[count] = G_Alloc(strlen(info) + strlen(\"\\\\num\\\\\") + strlen(va(\"%d\", MAX_ARENAS)) + 1);\n\t\tif (infos[count]) {\n\t\t\tstrcpy(infos[count], info);\n\t\t\tcount++;\n\t\t}\n\t}\n\treturn count;\n}\n\n/*\n===============\nG_LoadArenasFromFile\n===============\n*/\nstatic void G_LoadArenasFromFile( char *filename ) {\n\tint\t\t\t\tlen;\n\tfileHandle_t\tf;\n\tchar\t\t\tbuf[MAX_ARENAS_TEXT];\n\n\tlen = trap_FS_FOpenFile( filename, &f, FS_READ );\n\tif ( !f ) {\n\t\ttrap_Printf( va( S_COLOR_RED \"file not found: %s\\n\", filename ) );\n\t\treturn;\n\t}\n\tif ( len >= MAX_ARENAS_TEXT ) {\n\t\ttrap_Printf( va( S_COLOR_RED \"file too large: %s is %i, max allowed is %i\", filename, len, MAX_ARENAS_TEXT ) );\n\t\ttrap_FS_FCloseFile( f );\n\t\treturn;\n\t}\n\n\ttrap_FS_Read( buf, len, f );\n\tbuf[len] = 0;\n\ttrap_FS_FCloseFile( f );\n\n\tg_numArenas += G_ParseInfos( buf, MAX_ARENAS - g_numArenas, &g_arenaInfos[g_numArenas] );\n}\n\n/*\n===============\nG_LoadArenas\n===============\n*/\nstatic void G_LoadArenas( void ) {\n\tint\t\t\tnumdirs;\n\tvmCvar_t\tarenasFile;\n\tchar\t\tfilename[128];\n\tchar\t\tdirlist[1024];\n\tchar*\t\tdirptr;\n\tint\t\t\ti, n;\n\tint\t\t\tdirlen;\n\n\tg_numArenas = 0;\n\n\ttrap_Cvar_Register( &arenasFile, \"g_arenasFile\", \"\", CVAR_INIT|CVAR_ROM );\n\tif( *arenasFile.string ) {\n\t\tG_LoadArenasFromFile(arenasFile.string);\n\t}\n\telse {\n\t\tG_LoadArenasFromFile(\"scripts/arenas.txt\");\n\t}\n\n\t// get all arenas from .arena files\n\tnumdirs = trap_FS_GetFileList(\"scripts\", \".arena\", dirlist, 1024 );\n\tdirptr  = dirlist;\n\tfor (i = 0; i < numdirs; i++, dirptr += dirlen+1) {\n\t\tdirlen = strlen(dirptr);\n\t\tstrcpy(filename, \"scripts/\");\n\t\tstrcat(filename, dirptr);\n\t\tG_LoadArenasFromFile(filename);\n\t}\n\ttrap_Printf( va( \"%i arenas parsed\\n\", g_numArenas ) );\n\t\n\tfor( n = 0; n < g_numArenas; n++ ) {\n\t\tInfo_SetValueForKey( g_arenaInfos[n], \"num\", va( \"%i\", n ) );\n\t}\n}\n\n\n/*\n===============\nG_GetArenaInfoByNumber\n===============\n*/\nconst char *G_GetArenaInfoByMap( const char *map ) {\n\tint\t\t\tn;\n\n\tfor( n = 0; n < g_numArenas; n++ ) {\n\t\tif( Q_stricmp( Info_ValueForKey( g_arenaInfos[n], \"map\" ), map ) == 0 ) {\n\t\t\treturn g_arenaInfos[n];\n\t\t}\n\t}\n\n\treturn NULL;\n}\n\n\n/*\n=================\nPlayerIntroSound\n=================\n*/\nstatic void PlayerIntroSound( const char *modelAndSkin ) {\n\tchar\tmodel[MAX_QPATH];\n\tchar\t*skin;\n\n\tQ_strncpyz( model, modelAndSkin, sizeof(model) );\n\tskin = Q_strrchr( model, '/' );\n\tif ( skin ) {\n\t\t*skin++ = '\\0';\n\t}\n\telse {\n\t\tskin = model;\n\t}\n\n\tif( Q_stricmp( skin, \"default\" ) == 0 ) {\n\t\tskin = model;\n\t}\n\n\ttrap_SendConsoleCommand( EXEC_APPEND, va( \"play sound/player/announce/%s.wav\\n\", skin ) );\n}\n\n/*\n===============\nG_AddRandomBot\n===============\n*/\nvoid G_AddRandomBot( int team ) {\n\tint\t\ti, n, num;\n\tfloat\tskill;\n\tchar\t*value, netname[36], *teamstr;\n\tgclient_t\t*cl;\n\n\tnum = 0;\n\tfor ( n = 0; n < g_numBots ; n++ ) {\n\t\tvalue = Info_ValueForKey( g_botInfos[n], \"name\" );\n\t\t//\n\t\tfor ( i=0 ; i< g_maxclients.integer ; i++ ) {\n\t\t\tcl = level.clients + i;\n\t\t\tif ( cl->pers.connected != CON_CONNECTED ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( !(g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( team >= 0 && cl->sess.sessionTeam != team ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( !Q_stricmp( value, cl->pers.netname ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (i >= g_maxclients.integer) {\n\t\t\tnum++;\n\t\t}\n\t}\n\tnum = random() * num;\n\tfor ( n = 0; n < g_numBots ; n++ ) {\n\t\tvalue = Info_ValueForKey( g_botInfos[n], \"name\" );\n\t\t//\n\t\tfor ( i=0 ; i< g_maxclients.integer ; i++ ) {\n\t\t\tcl = level.clients + i;\n\t\t\tif ( cl->pers.connected != CON_CONNECTED ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( !(g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( team >= 0 && cl->sess.sessionTeam != team ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( !Q_stricmp( value, cl->pers.netname ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (i >= g_maxclients.integer) {\n\t\t\tnum--;\n\t\t\tif (num <= 0) {\n\t\t\t\tskill = trap_Cvar_VariableValue( \"g_spSkill\" );\n\t\t\t\tif (team == TEAM_RED) teamstr = \"red\";\n\t\t\t\telse if (team == TEAM_BLUE) teamstr = \"blue\";\n\t\t\t\telse teamstr = \"\";\n\t\t\t\tstrncpy(netname, value, sizeof(netname)-1);\n\t\t\t\tnetname[sizeof(netname)-1] = '\\0';\n\t\t\t\tQ_CleanStr(netname);\n\t\t\t\ttrap_SendConsoleCommand( EXEC_INSERT, va(\"addbot %s %f %s %i\\n\", netname, skill, teamstr, 0) );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n===============\nG_RemoveRandomBot\n===============\n*/\nint G_RemoveRandomBot( int team ) {\n\tint i;\n\tchar netname[36];\n\tgclient_t\t*cl;\n\n\tfor ( i=0 ; i< g_maxclients.integer ; i++ ) {\n\t\tcl = level.clients + i;\n\t\tif ( cl->pers.connected != CON_CONNECTED ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( !(g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( team >= 0 && cl->sess.sessionTeam != team ) {\n\t\t\tcontinue;\n\t\t}\n\t\tstrcpy(netname, cl->pers.netname);\n\t\tQ_CleanStr(netname);\n\t\ttrap_SendConsoleCommand( EXEC_INSERT, va(\"kick %s\\n\", netname) );\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n===============\nG_CountHumanPlayers\n===============\n*/\nint G_CountHumanPlayers( int team ) {\n\tint i, num;\n\tgclient_t\t*cl;\n\n\tnum = 0;\n\tfor ( i=0 ; i< g_maxclients.integer ; i++ ) {\n\t\tcl = level.clients + i;\n\t\tif ( cl->pers.connected != CON_CONNECTED ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( team >= 0 && cl->sess.sessionTeam != team ) {\n\t\t\tcontinue;\n\t\t}\n\t\tnum++;\n\t}\n\treturn num;\n}\n\n/*\n===============\nG_CountBotPlayers\n===============\n*/\nint G_CountBotPlayers( int team ) {\n\tint i, n, num;\n\tgclient_t\t*cl;\n\n\tnum = 0;\n\tfor ( i=0 ; i< g_maxclients.integer ; i++ ) {\n\t\tcl = level.clients + i;\n\t\tif ( cl->pers.connected != CON_CONNECTED ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( !(g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( team >= 0 && cl->sess.sessionTeam != team ) {\n\t\t\tcontinue;\n\t\t}\n\t\tnum++;\n\t}\n\tfor( n = 0; n < BOT_SPAWN_QUEUE_DEPTH; n++ ) {\n\t\tif( !botSpawnQueue[n].spawnTime ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( botSpawnQueue[n].spawnTime > level.time ) {\n\t\t\tcontinue;\n\t\t}\n\t\tnum++;\n\t}\n\treturn num;\n}\n\n/*\n===============\nG_CheckMinimumPlayers\n===============\n*/\nvoid G_CheckMinimumPlayers( void ) {\n\tint minplayers;\n\tint humanplayers, botplayers;\n\tstatic int checkminimumplayers_time;\n\n\tif (level.intermissiontime) return;\n\t//only check once each 10 seconds\n\tif (checkminimumplayers_time > level.time - 10000) {\n\t\treturn;\n\t}\n\tcheckminimumplayers_time = level.time;\n\ttrap_Cvar_Update(&bot_minplayers);\n\tminplayers = bot_minplayers.integer;\n\tif (minplayers <= 0) return;\n\n\tif (g_gametype.integer >= GT_TEAM) {\n\t\tif (minplayers >= g_maxclients.integer / 2) {\n\t\t\tminplayers = (g_maxclients.integer / 2) -1;\n\t\t}\n\n\t\thumanplayers = G_CountHumanPlayers( TEAM_RED );\n\t\tbotplayers = G_CountBotPlayers(\tTEAM_RED );\n\t\t//\n\t\tif (humanplayers + botplayers < minplayers) {\n\t\t\tG_AddRandomBot( TEAM_RED );\n\t\t} else if (humanplayers + botplayers > minplayers && botplayers) {\n\t\t\tG_RemoveRandomBot( TEAM_RED );\n\t\t}\n\t\t//\n\t\thumanplayers = G_CountHumanPlayers( TEAM_BLUE );\n\t\tbotplayers = G_CountBotPlayers( TEAM_BLUE );\n\t\t//\n\t\tif (humanplayers + botplayers < minplayers) {\n\t\t\tG_AddRandomBot( TEAM_BLUE );\n\t\t} else if (humanplayers + botplayers > minplayers && botplayers) {\n\t\t\tG_RemoveRandomBot( TEAM_BLUE );\n\t\t}\n\t}\n\telse if (g_gametype.integer == GT_TOURNAMENT ) {\n\t\tif (minplayers >= g_maxclients.integer) {\n\t\t\tminplayers = g_maxclients.integer-1;\n\t\t}\n\t\thumanplayers = G_CountHumanPlayers( -1 );\n\t\tbotplayers = G_CountBotPlayers( -1 );\n\t\t//\n\t\tif (humanplayers + botplayers < minplayers) {\n\t\t\tG_AddRandomBot( TEAM_FREE );\n\t\t} else if (humanplayers + botplayers > minplayers && botplayers) {\n\t\t\t// try to remove spectators first\n\t\t\tif (!G_RemoveRandomBot( TEAM_SPECTATOR )) {\n\t\t\t\t// just remove the bot that is playing\n\t\t\t\tG_RemoveRandomBot( -1 );\n\t\t\t}\n\t\t}\n\t}\n\telse if (g_gametype.integer == GT_FFA) {\n\t\tif (minplayers >= g_maxclients.integer) {\n\t\t\tminplayers = g_maxclients.integer-1;\n\t\t}\n\t\thumanplayers = G_CountHumanPlayers( TEAM_FREE );\n\t\tbotplayers = G_CountBotPlayers( TEAM_FREE );\n\t\t//\n\t\tif (humanplayers + botplayers < minplayers) {\n\t\t\tG_AddRandomBot( TEAM_FREE );\n\t\t} else if (humanplayers + botplayers > minplayers && botplayers) {\n\t\t\tG_RemoveRandomBot( TEAM_FREE );\n\t\t}\n\t}\n}\n\n/*\n===============\nG_CheckBotSpawn\n===============\n*/\nvoid G_CheckBotSpawn( void ) {\n\tint\t\tn;\n\tchar\tuserinfo[MAX_INFO_VALUE];\n\n\tG_CheckMinimumPlayers();\n\n\tfor( n = 0; n < BOT_SPAWN_QUEUE_DEPTH; n++ ) {\n\t\tif( !botSpawnQueue[n].spawnTime ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( botSpawnQueue[n].spawnTime > level.time ) {\n\t\t\tcontinue;\n\t\t}\n\t\tClientBegin( botSpawnQueue[n].clientNum );\n\t\tbotSpawnQueue[n].spawnTime = 0;\n\n\t\tif( g_gametype.integer == GT_SINGLE_PLAYER ) {\n\t\t\ttrap_GetUserinfo( botSpawnQueue[n].clientNum, userinfo, sizeof(userinfo) );\n\t\t\tPlayerIntroSound( Info_ValueForKey (userinfo, \"model\") );\n\t\t}\n\t}\n}\n\n\n/*\n===============\nAddBotToSpawnQueue\n===============\n*/\nstatic void AddBotToSpawnQueue( int clientNum, int delay ) {\n\tint\t\tn;\n\n\tfor( n = 0; n < BOT_SPAWN_QUEUE_DEPTH; n++ ) {\n\t\tif( !botSpawnQueue[n].spawnTime ) {\n\t\t\tbotSpawnQueue[n].spawnTime = level.time + delay;\n\t\t\tbotSpawnQueue[n].clientNum = clientNum;\n\t\t\treturn;\n\t\t}\n\t}\n\n\tG_Printf( S_COLOR_YELLOW \"Unable to delay spawn\\n\" );\n\tClientBegin( clientNum );\n}\n\n\n/*\n===============\nG_RemoveQueuedBotBegin\n\nCalled on client disconnect to make sure the delayed spawn\ndoesn't happen on a freed index\n===============\n*/\nvoid G_RemoveQueuedBotBegin( int clientNum ) {\n\tint\t\tn;\n\n\tfor( n = 0; n < BOT_SPAWN_QUEUE_DEPTH; n++ ) {\n\t\tif( botSpawnQueue[n].clientNum == clientNum ) {\n\t\t\tbotSpawnQueue[n].spawnTime = 0;\n\t\t\treturn;\n\t\t}\n\t}\n}\n\n\n/*\n===============\nG_BotConnect\n===============\n*/\nqboolean G_BotConnect( int clientNum, qboolean restart ) {\n\tbot_settings_t\tsettings;\n\tchar\t\t\tuserinfo[MAX_INFO_STRING];\n\n\ttrap_GetUserinfo( clientNum, userinfo, sizeof(userinfo) );\n\n\tQ_strncpyz( settings.characterfile, Info_ValueForKey( userinfo, \"characterfile\" ), sizeof(settings.characterfile) );\n\tsettings.skill = atof( Info_ValueForKey( userinfo, \"skill\" ) );\n\tQ_strncpyz( settings.team, Info_ValueForKey( userinfo, \"team\" ), sizeof(settings.team) );\n\n\tif (!BotAISetupClient( clientNum, &settings, restart )) {\n\t\ttrap_DropClient( clientNum, \"BotAISetupClient failed\" );\n\t\treturn qfalse;\n\t}\n\n\treturn qtrue;\n}\n\n\n/*\n===============\nG_AddBot\n===============\n*/\nstatic void G_AddBot( const char *name, float skill, const char *team, int delay, char *altname) {\n\tint\t\t\t\tclientNum;\n\tchar\t\t\t*botinfo;\n\tgentity_t\t\t*bot;\n\tchar\t\t\t*key;\n\tchar\t\t\t*s;\n\tchar\t\t\t*botname;\n\tchar\t\t\t*model;\n\tchar\t\t\t*headmodel;\n\tchar\t\t\tuserinfo[MAX_INFO_STRING];\n\n\t// get the botinfo from bots.txt\n\tbotinfo = G_GetBotInfoByName( name );\n\tif ( !botinfo ) {\n\t\tG_Printf( S_COLOR_RED \"Error: Bot '%s' not defined\\n\", name );\n\t\treturn;\n\t}\n\n\t// create the bot's userinfo\n\tuserinfo[0] = '\\0';\n\n\tbotname = Info_ValueForKey( botinfo, \"funname\" );\n\tif( !botname[0] ) {\n\t\tbotname = Info_ValueForKey( botinfo, \"name\" );\n\t}\n\t// check for an alternative name\n\tif (altname && altname[0]) {\n\t\tbotname = altname;\n\t}\n\tInfo_SetValueForKey( userinfo, \"name\", botname );\n\tInfo_SetValueForKey( userinfo, \"rate\", \"25000\" );\n\tInfo_SetValueForKey( userinfo, \"snaps\", \"20\" );\n\tInfo_SetValueForKey( userinfo, \"skill\", va(\"%1.2f\", skill) );\n\n\tif ( skill >= 1 && skill < 2 ) {\n\t\tInfo_SetValueForKey( userinfo, \"handicap\", \"50\" );\n\t}\n\telse if ( skill >= 2 && skill < 3 ) {\n\t\tInfo_SetValueForKey( userinfo, \"handicap\", \"70\" );\n\t}\n\telse if ( skill >= 3 && skill < 4 ) {\n\t\tInfo_SetValueForKey( userinfo, \"handicap\", \"90\" );\n\t}\n\n\tkey = \"model\";\n\tmodel = Info_ValueForKey( botinfo, key );\n\tif ( !*model ) {\n\t\tmodel = \"visor/default\";\n\t}\n\tInfo_SetValueForKey( userinfo, key, model );\n\tkey = \"team_model\";\n\tInfo_SetValueForKey( userinfo, key, model );\n\n\tkey = \"headmodel\";\n\theadmodel = Info_ValueForKey( botinfo, key );\n\tif ( !*headmodel ) {\n\t\theadmodel = model;\n\t}\n\tInfo_SetValueForKey( userinfo, key, headmodel );\n\tkey = \"team_headmodel\";\n\tInfo_SetValueForKey( userinfo, key, headmodel );\n\n\tkey = \"gender\";\n\ts = Info_ValueForKey( botinfo, key );\n\tif ( !*s ) {\n\t\ts = \"male\";\n\t}\n\tInfo_SetValueForKey( userinfo, \"sex\", s );\n\n\tkey = \"color1\";\n\ts = Info_ValueForKey( botinfo, key );\n\tif ( !*s ) {\n\t\ts = \"4\";\n\t}\n\tInfo_SetValueForKey( userinfo, key, s );\n\n\tkey = \"color2\";\n\ts = Info_ValueForKey( botinfo, key );\n\tif ( !*s ) {\n\t\ts = \"5\";\n\t}\n\tInfo_SetValueForKey( userinfo, key, s );\n\n\ts = Info_ValueForKey(botinfo, \"aifile\");\n\tif (!*s ) {\n\t\ttrap_Printf( S_COLOR_RED \"Error: bot has no aifile specified\\n\" );\n\t\treturn;\n\t}\n\n\t// have the server allocate a client slot\n\tclientNum = trap_BotAllocateClient();\n\tif ( clientNum == -1 ) {\n\t\tG_Printf( S_COLOR_RED \"Unable to add bot.  All player slots are in use.\\n\" );\n\t\tG_Printf( S_COLOR_RED \"Start server with more 'open' slots (or check setting of sv_maxclients cvar).\\n\" );\n\t\treturn;\n\t}\n\n\t// initialize the bot settings\n\tif( !team || !*team ) {\n\t\tif( g_gametype.integer >= GT_TEAM ) {\n\t\t\tif( PickTeam(clientNum) == TEAM_RED) {\n\t\t\t\tteam = \"red\";\n\t\t\t}\n\t\t\telse {\n\t\t\t\tteam = \"blue\";\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tteam = \"red\";\n\t\t}\n\t}\n\tInfo_SetValueForKey( userinfo, \"characterfile\", Info_ValueForKey( botinfo, \"aifile\" ) );\n\tInfo_SetValueForKey( userinfo, \"skill\", va( \"%5.2f\", skill ) );\n\tInfo_SetValueForKey( userinfo, \"team\", team );\n\n\tbot = &g_entities[ clientNum ];\n\tbot->r.svFlags |= SVF_BOT;\n\tbot->inuse = qtrue;\n\n\t// register the userinfo\n\ttrap_SetUserinfo( clientNum, userinfo );\n\n\t// have it connect to the game as a normal client\n\tif ( ClientConnect( clientNum, qtrue, qtrue ) ) {\n\t\treturn;\n\t}\n\n\tif( delay == 0 ) {\n\t\tClientBegin( clientNum );\n\t\treturn;\n\t}\n\n\tAddBotToSpawnQueue( clientNum, delay );\n}\n\n\n/*\n===============\nSvcmd_AddBot_f\n===============\n*/\nvoid Svcmd_AddBot_f( void ) {\n\tfloat\t\t\tskill;\n\tint\t\t\t\tdelay;\n\tchar\t\t\tname[MAX_TOKEN_CHARS];\n\tchar\t\t\taltname[MAX_TOKEN_CHARS];\n\tchar\t\t\tstring[MAX_TOKEN_CHARS];\n\tchar\t\t\tteam[MAX_TOKEN_CHARS];\n\n\t// are bots enabled?\n\tif ( !trap_Cvar_VariableIntegerValue( \"bot_enable\" ) ) {\n\t\treturn;\n\t}\n\n\t// name\n\ttrap_Argv( 1, name, sizeof( name ) );\n\tif ( !name[0] ) {\n\t\ttrap_Printf( \"Usage: Addbot <botname> [skill 1-5] [team] [msec delay] [altname]\\n\" );\n\t\treturn;\n\t}\n\n\t// skill\n\ttrap_Argv( 2, string, sizeof( string ) );\n\tif ( !string[0] ) {\n\t\tskill = 4;\n\t}\n\telse {\n\t\tskill = atof( string );\n\t}\n\n\t// team\n\ttrap_Argv( 3, team, sizeof( team ) );\n\n\t// delay\n\ttrap_Argv( 4, string, sizeof( string ) );\n\tif ( !string[0] ) {\n\t\tdelay = 0;\n\t}\n\telse {\n\t\tdelay = atoi( string );\n\t}\n\n\t// alternative name\n\ttrap_Argv( 5, altname, sizeof( altname ) );\n\n\tG_AddBot( name, skill, team, delay, altname );\n\n\t// if this was issued during gameplay and we are playing locally,\n\t// go ahead and load the bot's media immediately\n\tif ( level.time - level.startTime > 1000 &&\n\t\ttrap_Cvar_VariableIntegerValue( \"cl_running\" ) ) {\n\t\ttrap_SendServerCommand( -1, \"loaddefered\\n\" );\t// FIXME: spelled wrong, but not changing for demo\n\t}\n}\n\n/*\n===============\nSvcmd_BotList_f\n===============\n*/\nvoid Svcmd_BotList_f( void ) {\n\tint i;\n\tchar name[MAX_TOKEN_CHARS];\n\tchar funname[MAX_TOKEN_CHARS];\n\tchar model[MAX_TOKEN_CHARS];\n\tchar aifile[MAX_TOKEN_CHARS];\n\n\ttrap_Printf(\"^1name             model            aifile              funname\\n\");\n\tfor (i = 0; i < g_numBots; i++) {\n\t\tstrcpy(name, Info_ValueForKey( g_botInfos[i], \"name\" ));\n\t\tif ( !*name ) {\n\t\t\tstrcpy(name, \"UnnamedPlayer\");\n\t\t}\n\t\tstrcpy(funname, Info_ValueForKey( g_botInfos[i], \"funname\" ));\n\t\tif ( !*funname ) {\n\t\t\tstrcpy(funname, \"\");\n\t\t}\n\t\tstrcpy(model, Info_ValueForKey( g_botInfos[i], \"model\" ));\n\t\tif ( !*model ) {\n\t\t\tstrcpy(model, \"visor/default\");\n\t\t}\n\t\tstrcpy(aifile, Info_ValueForKey( g_botInfos[i], \"aifile\"));\n\t\tif (!*aifile ) {\n\t\t\tstrcpy(aifile, \"bots/default_c.c\");\n\t\t}\n\t\ttrap_Printf(va(\"%-16s %-16s %-20s %-20s\\n\", name, model, aifile, funname));\n\t}\n}\n\n\n/*\n===============\nG_SpawnBots\n===============\n*/\nstatic void G_SpawnBots( char *botList, int baseDelay ) {\n\tchar\t\t*bot;\n\tchar\t\t*p;\n\tfloat\t\tskill;\n\tint\t\t\tdelay;\n\tchar\t\tbots[MAX_INFO_VALUE];\n\n\tpodium1 = NULL;\n\tpodium2 = NULL;\n\tpodium3 = NULL;\n\n\tskill = trap_Cvar_VariableValue( \"g_spSkill\" );\n\tif( skill < 1 ) {\n\t\ttrap_Cvar_Set( \"g_spSkill\", \"1\" );\n\t\tskill = 1;\n\t}\n\telse if ( skill > 5 ) {\n\t\ttrap_Cvar_Set( \"g_spSkill\", \"5\" );\n\t\tskill = 5;\n\t}\n\n\tQ_strncpyz( bots, botList, sizeof(bots) );\n\tp = &bots[0];\n\tdelay = baseDelay;\n\twhile( *p ) {\n\t\t//skip spaces\n\t\twhile( *p && *p == ' ' ) {\n\t\t\tp++;\n\t\t}\n\t\tif( !p ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// mark start of bot name\n\t\tbot = p;\n\n\t\t// skip until space of null\n\t\twhile( *p && *p != ' ' ) {\n\t\t\tp++;\n\t\t}\n\t\tif( *p ) {\n\t\t\t*p++ = 0;\n\t\t}\n\n\t\t// we must add the bot this way, calling G_AddBot directly at this stage\n\t\t// does \"Bad Things\"\n\t\ttrap_SendConsoleCommand( EXEC_INSERT, va(\"addbot %s %f free %i\\n\", bot, skill, delay) );\n\n\t\tdelay += BOT_BEGIN_DELAY_INCREMENT;\n\t}\n}\n\n\n/*\n===============\nG_LoadBotsFromFile\n===============\n*/\nstatic void G_LoadBotsFromFile( char *filename ) {\n\tint\t\t\t\tlen;\n\tfileHandle_t\tf;\n\tchar\t\t\tbuf[MAX_BOTS_TEXT];\n\n\tlen = trap_FS_FOpenFile( filename, &f, FS_READ );\n\tif ( !f ) {\n\t\ttrap_Printf( va( S_COLOR_RED \"file not found: %s\\n\", filename ) );\n\t\treturn;\n\t}\n\tif ( len >= MAX_BOTS_TEXT ) {\n\t\ttrap_Printf( va( S_COLOR_RED \"file too large: %s is %i, max allowed is %i\", filename, len, MAX_BOTS_TEXT ) );\n\t\ttrap_FS_FCloseFile( f );\n\t\treturn;\n\t}\n\n\ttrap_FS_Read( buf, len, f );\n\tbuf[len] = 0;\n\ttrap_FS_FCloseFile( f );\n\n\tg_numBots += G_ParseInfos( buf, MAX_BOTS - g_numBots, &g_botInfos[g_numBots] );\n}\n\n/*\n===============\nG_LoadBots\n===============\n*/\nstatic void G_LoadBots( void ) {\n\tvmCvar_t\tbotsFile;\n\tint\t\t\tnumdirs;\n\tchar\t\tfilename[128];\n\tchar\t\tdirlist[1024];\n\tchar*\t\tdirptr;\n\tint\t\t\ti;\n\tint\t\t\tdirlen;\n\n\tif ( !trap_Cvar_VariableIntegerValue( \"bot_enable\" ) ) {\n\t\treturn;\n\t}\n\n\tg_numBots = 0;\n\n\ttrap_Cvar_Register( &botsFile, \"g_botsFile\", \"\", CVAR_INIT|CVAR_ROM );\n\tif( *botsFile.string ) {\n\t\tG_LoadBotsFromFile(botsFile.string);\n\t}\n\telse {\n\t\tG_LoadBotsFromFile(\"scripts/bots.txt\");\n\t}\n\n\t// get all bots from .bot files\n\tnumdirs = trap_FS_GetFileList(\"scripts\", \".bot\", dirlist, 1024 );\n\tdirptr  = dirlist;\n\tfor (i = 0; i < numdirs; i++, dirptr += dirlen+1) {\n\t\tdirlen = strlen(dirptr);\n\t\tstrcpy(filename, \"scripts/\");\n\t\tstrcat(filename, dirptr);\n\t\tG_LoadBotsFromFile(filename);\n\t}\n\ttrap_Printf( va( \"%i bots parsed\\n\", g_numBots ) );\n}\n\n\n\n/*\n===============\nG_GetBotInfoByNumber\n===============\n*/\nchar *G_GetBotInfoByNumber( int num ) {\n\tif( num < 0 || num >= g_numBots ) {\n\t\ttrap_Printf( va( S_COLOR_RED \"Invalid bot number: %i\\n\", num ) );\n\t\treturn NULL;\n\t}\n\treturn g_botInfos[num];\n}\n\n\n/*\n===============\nG_GetBotInfoByName\n===============\n*/\nchar *G_GetBotInfoByName( const char *name ) {\n\tint\t\tn;\n\tchar\t*value;\n\n\tfor ( n = 0; n < g_numBots ; n++ ) {\n\t\tvalue = Info_ValueForKey( g_botInfos[n], \"name\" );\n\t\tif ( !Q_stricmp( value, name ) ) {\n\t\t\treturn g_botInfos[n];\n\t\t}\n\t}\n\n\treturn NULL;\n}\n\n/*\n===============\nG_InitBots\n===============\n*/\nvoid G_InitBots( qboolean restart ) {\n\tint\t\t\tfragLimit;\n\tint\t\t\ttimeLimit;\n\tconst char\t*arenainfo;\n\tchar\t\t*strValue;\n\tint\t\t\tbasedelay;\n\tchar\t\tmap[MAX_QPATH];\n\tchar\t\tserverinfo[MAX_INFO_STRING];\n\n\tG_LoadBots();\n\tG_LoadArenas();\n\n\ttrap_Cvar_Register( &bot_minplayers, \"bot_minplayers\", \"0\", CVAR_SERVERINFO );\n\n\tif( g_gametype.integer == GT_SINGLE_PLAYER ) {\n\t\ttrap_GetServerinfo( serverinfo, sizeof(serverinfo) );\n\t\tQ_strncpyz( map, Info_ValueForKey( serverinfo, \"mapname\" ), sizeof(map) );\n\t\tarenainfo = G_GetArenaInfoByMap( map );\n\t\tif ( !arenainfo ) {\n\t\t\treturn;\n\t\t}\n\n\t\tstrValue = Info_ValueForKey( arenainfo, \"fraglimit\" );\n\t\tfragLimit = atoi( strValue );\n\t\tif ( fragLimit ) {\n\t\t\ttrap_Cvar_Set( \"fraglimit\", strValue );\n\t\t}\n\t\telse {\n\t\t\ttrap_Cvar_Set( \"fraglimit\", \"0\" );\n\t\t}\n\n\t\tstrValue = Info_ValueForKey( arenainfo, \"timelimit\" );\n\t\ttimeLimit = atoi( strValue );\n\t\tif ( timeLimit ) {\n\t\t\ttrap_Cvar_Set( \"timelimit\", strValue );\n\t\t}\n\t\telse {\n\t\t\ttrap_Cvar_Set( \"timelimit\", \"0\" );\n\t\t}\n\n\t\tif ( !fragLimit && !timeLimit ) {\n\t\t\ttrap_Cvar_Set( \"fraglimit\", \"10\" );\n\t\t\ttrap_Cvar_Set( \"timelimit\", \"0\" );\n\t\t}\n\n\t\tbasedelay = BOT_BEGIN_DELAY_BASE;\n\t\tstrValue = Info_ValueForKey( arenainfo, \"special\" );\n\t\tif( Q_stricmp( strValue, \"training\" ) == 0 ) {\n\t\t\tbasedelay += 10000;\n\t\t}\n\n\t\tif( !restart ) {\n\t\t\tG_SpawnBots( Info_ValueForKey( arenainfo, \"bots\" ), basedelay );\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "code/game/g_client.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#include \"g_local.h\"\n\n// g_client.c -- client functions that don't happen every frame\n\nstatic vec3_t\tplayerMins = {-15, -15, -24};\nstatic vec3_t\tplayerMaxs = {15, 15, 32};\n\n/*QUAKED info_player_deathmatch (1 0 1) (-16 -16 -24) (16 16 32) initial\npotential spawning position for deathmatch games.\nThe first time a player enters the game, they will be at an 'initial' spot.\nTargets will be fired when someone spawns in on them.\n\"nobots\" will prevent bots from using this spot.\n\"nohumans\" will prevent non-bots from using this spot.\n*/\nvoid SP_info_player_deathmatch( gentity_t *ent ) {\n\tint\t\ti;\n\n\tG_SpawnInt( \"nobots\", \"0\", &i);\n\tif ( i ) {\n\t\tent->flags |= FL_NO_BOTS;\n\t}\n\tG_SpawnInt( \"nohumans\", \"0\", &i );\n\tif ( i ) {\n\t\tent->flags |= FL_NO_HUMANS;\n\t}\n}\n\n/*QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 32)\nequivelant to info_player_deathmatch\n*/\nvoid SP_info_player_start(gentity_t *ent) {\n\tent->classname = \"info_player_deathmatch\";\n\tSP_info_player_deathmatch( ent );\n}\n\n/*QUAKED info_player_intermission (1 0 1) (-16 -16 -24) (16 16 32)\nThe intermission will be viewed from this point.  Target an info_notnull for the view direction.\n*/\nvoid SP_info_player_intermission( gentity_t *ent ) {\n\n}\n\n\n\n/*\n=======================================================================\n\n  SelectSpawnPoint\n\n=======================================================================\n*/\n\n/*\n================\nSpotWouldTelefrag\n\n================\n*/\nqboolean SpotWouldTelefrag( gentity_t *spot ) {\n\tint\t\t\ti, num;\n\tint\t\t\ttouch[MAX_GENTITIES];\n\tgentity_t\t*hit;\n\tvec3_t\t\tmins, maxs;\n\n\tVectorAdd( spot->s.origin, playerMins, mins );\n\tVectorAdd( spot->s.origin, playerMaxs, maxs );\n\tnum = trap_EntitiesInBox( mins, maxs, touch, MAX_GENTITIES );\n\n\tfor (i=0 ; i<num ; i++) {\n\t\thit = &g_entities[touch[i]];\n\t\t//if ( hit->client && hit->client->ps.stats[STAT_HEALTH] > 0 ) {\n\t\tif ( hit->client) {\n\t\t\treturn qtrue;\n\t\t}\n\n\t}\n\n\treturn qfalse;\n}\n\n/*\n================\nSelectNearestDeathmatchSpawnPoint\n\nFind the spot that we DON'T want to use\n================\n*/\n#define\tMAX_SPAWN_POINTS\t128\ngentity_t *SelectNearestDeathmatchSpawnPoint( vec3_t from ) {\n\tgentity_t\t*spot;\n\tvec3_t\t\tdelta;\n\tfloat\t\tdist, nearestDist;\n\tgentity_t\t*nearestSpot;\n\n\tnearestDist = 999999;\n\tnearestSpot = NULL;\n\tspot = NULL;\n\n\twhile ((spot = G_Find (spot, FOFS(classname), \"info_player_deathmatch\")) != NULL) {\n\n\t\tVectorSubtract( spot->s.origin, from, delta );\n\t\tdist = VectorLength( delta );\n\t\tif ( dist < nearestDist ) {\n\t\t\tnearestDist = dist;\n\t\t\tnearestSpot = spot;\n\t\t}\n\t}\n\n\treturn nearestSpot;\n}\n\n\n/*\n================\nSelectRandomDeathmatchSpawnPoint\n\ngo to a random point that doesn't telefrag\n================\n*/\n#define\tMAX_SPAWN_POINTS\t128\ngentity_t *SelectRandomDeathmatchSpawnPoint( void ) {\n\tgentity_t\t*spot;\n\tint\t\t\tcount;\n\tint\t\t\tselection;\n\tgentity_t\t*spots[MAX_SPAWN_POINTS];\n\n\tcount = 0;\n\tspot = NULL;\n\n\twhile ((spot = G_Find (spot, FOFS(classname), \"info_player_deathmatch\")) != NULL) {\n\t\tif ( SpotWouldTelefrag( spot ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\tspots[ count ] = spot;\n\t\tcount++;\n\t}\n\n\tif ( !count ) {\t// no spots that won't telefrag\n\t\treturn G_Find( NULL, FOFS(classname), \"info_player_deathmatch\");\n\t}\n\n\tselection = rand() % count;\n\treturn spots[ selection ];\n}\n\n/*\n===========\nSelectRandomFurthestSpawnPoint\n\nChooses a player start, deathmatch start, etc\n============\n*/\ngentity_t *SelectRandomFurthestSpawnPoint ( vec3_t avoidPoint, vec3_t origin, vec3_t angles ) {\n\tgentity_t\t*spot;\n\tvec3_t\t\tdelta;\n\tfloat\t\tdist;\n\tfloat\t\tlist_dist[64];\n\tgentity_t\t*list_spot[64];\n\tint\t\t\tnumSpots, rnd, i, j;\n\n\tnumSpots = 0;\n\tspot = NULL;\n\n\twhile ((spot = G_Find (spot, FOFS(classname), \"info_player_deathmatch\")) != NULL) {\n\t\tif ( SpotWouldTelefrag( spot ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\tVectorSubtract( spot->s.origin, avoidPoint, delta );\n\t\tdist = VectorLength( delta );\n\t\tfor (i = 0; i < numSpots; i++) {\n\t\t\tif ( dist > list_dist[i] ) {\n\t\t\t\tif ( numSpots >= 64 )\n\t\t\t\t\tnumSpots = 64-1;\n\t\t\t\tfor (j = numSpots; j > i; j--) {\n\t\t\t\t\tlist_dist[j] = list_dist[j-1];\n\t\t\t\t\tlist_spot[j] = list_spot[j-1];\n\t\t\t\t}\n\t\t\t\tlist_dist[i] = dist;\n\t\t\t\tlist_spot[i] = spot;\n\t\t\t\tnumSpots++;\n\t\t\t\tif (numSpots > 64)\n\t\t\t\t\tnumSpots = 64;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (i >= numSpots && numSpots < 64) {\n\t\t\tlist_dist[numSpots] = dist;\n\t\t\tlist_spot[numSpots] = spot;\n\t\t\tnumSpots++;\n\t\t}\n\t}\n\tif (!numSpots) {\n\t\tspot = G_Find( NULL, FOFS(classname), \"info_player_deathmatch\");\n\t\tif (!spot)\n\t\t\tG_Error( \"Couldn't find a spawn point\" );\n\t\tVectorCopy (spot->s.origin, origin);\n\t\torigin[2] += 9;\n\t\tVectorCopy (spot->s.angles, angles);\n\t\treturn spot;\n\t}\n\n\t// select a random spot from the spawn points furthest away\n\trnd = random() * (numSpots / 2);\n\n\tVectorCopy (list_spot[rnd]->s.origin, origin);\n\torigin[2] += 9;\n\tVectorCopy (list_spot[rnd]->s.angles, angles);\n\n\treturn list_spot[rnd];\n}\n\n/*\n===========\nSelectSpawnPoint\n\nChooses a player start, deathmatch start, etc\n============\n*/\ngentity_t *SelectSpawnPoint ( vec3_t avoidPoint, vec3_t origin, vec3_t angles ) {\n\treturn SelectRandomFurthestSpawnPoint( avoidPoint, origin, angles );\n\n\t/*\n\tgentity_t\t*spot;\n\tgentity_t\t*nearestSpot;\n\n\tnearestSpot = SelectNearestDeathmatchSpawnPoint( avoidPoint );\n\n\tspot = SelectRandomDeathmatchSpawnPoint ( );\n\tif ( spot == nearestSpot ) {\n\t\t// roll again if it would be real close to point of death\n\t\tspot = SelectRandomDeathmatchSpawnPoint ( );\n\t\tif ( spot == nearestSpot ) {\n\t\t\t// last try\n\t\t\tspot = SelectRandomDeathmatchSpawnPoint ( );\n\t\t}\t\t\n\t}\n\n\t// find a single player start spot\n\tif (!spot) {\n\t\tG_Error( \"Couldn't find a spawn point\" );\n\t}\n\n\tVectorCopy (spot->s.origin, origin);\n\torigin[2] += 9;\n\tVectorCopy (spot->s.angles, angles);\n\n\treturn spot;\n\t*/\n}\n\n/*\n===========\nSelectInitialSpawnPoint\n\nTry to find a spawn point marked 'initial', otherwise\nuse normal spawn selection.\n============\n*/\ngentity_t *SelectInitialSpawnPoint( vec3_t origin, vec3_t angles ) {\n\tgentity_t\t*spot;\n\n\tspot = NULL;\n\twhile ((spot = G_Find (spot, FOFS(classname), \"info_player_deathmatch\")) != NULL) {\n\t\tif ( spot->spawnflags & 1 ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif ( !spot || SpotWouldTelefrag( spot ) ) {\n\t\treturn SelectSpawnPoint( vec3_origin, origin, angles );\n\t}\n\n\tVectorCopy (spot->s.origin, origin);\n\torigin[2] += 9;\n\tVectorCopy (spot->s.angles, angles);\n\n\treturn spot;\n}\n\n/*\n===========\nSelectSpectatorSpawnPoint\n\n============\n*/\ngentity_t *SelectSpectatorSpawnPoint( vec3_t origin, vec3_t angles ) {\n\tFindIntermissionPoint();\n\n\tVectorCopy( level.intermission_origin, origin );\n\tVectorCopy( level.intermission_angle, angles );\n\n\treturn NULL;\n}\n\n/*\n=======================================================================\n\nBODYQUE\n\n=======================================================================\n*/\n\n/*\n===============\nInitBodyQue\n===============\n*/\nvoid InitBodyQue (void) {\n\tint\t\ti;\n\tgentity_t\t*ent;\n\n\tlevel.bodyQueIndex = 0;\n\tfor (i=0; i<BODY_QUEUE_SIZE ; i++) {\n\t\tent = G_Spawn();\n\t\tent->classname = \"bodyque\";\n\t\tent->neverFree = qtrue;\n\t\tlevel.bodyQue[i] = ent;\n\t}\n}\n\n/*\n=============\nBodySink\n\nAfter sitting around for five seconds, fall into the ground and dissapear\n=============\n*/\nvoid BodySink( gentity_t *ent ) {\n\tif ( level.time - ent->timestamp > 6500 ) {\n\t\t// the body ques are never actually freed, they are just unlinked\n\t\ttrap_UnlinkEntity( ent );\n\t\tent->physicsObject = qfalse;\n\t\treturn;\t\n\t}\n\tent->nextthink = level.time + 100;\n\tent->s.pos.trBase[2] -= 1;\n}\n\n/*\n=============\nCopyToBodyQue\n\nA player is respawning, so make an entity that looks\njust like the existing corpse to leave behind.\n=============\n*/\nvoid CopyToBodyQue( gentity_t *ent ) {\n#ifdef MISSIONPACK\n\tgentity_t\t*e;\n\tint i;\n#endif\n\tgentity_t\t\t*body;\n\tint\t\t\tcontents;\n\n\ttrap_UnlinkEntity (ent);\n\n\t// if client is in a nodrop area, don't leave the body\n\tcontents = trap_PointContents( ent->s.origin, -1 );\n\tif ( contents & CONTENTS_NODROP ) {\n\t\treturn;\n\t}\n\n\t// grab a body que and cycle to the next one\n\tbody = level.bodyQue[ level.bodyQueIndex ];\n\tlevel.bodyQueIndex = (level.bodyQueIndex + 1) % BODY_QUEUE_SIZE;\n\n\ttrap_UnlinkEntity (body);\n\n\tbody->s = ent->s;\n\tbody->s.eFlags = EF_DEAD;\t\t// clear EF_TALK, etc\n#ifdef MISSIONPACK\n\tif ( ent->s.eFlags & EF_KAMIKAZE ) {\n\t\tbody->s.eFlags |= EF_KAMIKAZE;\n\n\t\t// check if there is a kamikaze timer around for this owner\n\t\tfor (i = 0; i < MAX_GENTITIES; i++) {\n\t\t\te = &g_entities[i];\n\t\t\tif (!e->inuse)\n\t\t\t\tcontinue;\n\t\t\tif (e->activator != ent)\n\t\t\t\tcontinue;\n\t\t\tif (strcmp(e->classname, \"kamikaze timer\"))\n\t\t\t\tcontinue;\n\t\t\te->activator = body;\n\t\t\tbreak;\n\t\t}\n\t}\n#endif\n\tbody->s.powerups = 0;\t// clear powerups\n\tbody->s.loopSound = 0;\t// clear lava burning\n\tbody->s.number = body - g_entities;\n\tbody->timestamp = level.time;\n\tbody->physicsObject = qtrue;\n\tbody->physicsBounce = 0;\t\t// don't bounce\n\tif ( body->s.groundEntityNum == ENTITYNUM_NONE ) {\n\t\tbody->s.pos.trType = TR_GRAVITY;\n\t\tbody->s.pos.trTime = level.time;\n\t\tVectorCopy( ent->client->ps.velocity, body->s.pos.trDelta );\n\t} else {\n\t\tbody->s.pos.trType = TR_STATIONARY;\n\t}\n\tbody->s.event = 0;\n\n\t// change the animation to the last-frame only, so the sequence\n\t// doesn't repeat anew for the body\n\tswitch ( body->s.legsAnim & ~ANIM_TOGGLEBIT ) {\n\tcase BOTH_DEATH1:\n\tcase BOTH_DEAD1:\n\t\tbody->s.torsoAnim = body->s.legsAnim = BOTH_DEAD1;\n\t\tbreak;\n\tcase BOTH_DEATH2:\n\tcase BOTH_DEAD2:\n\t\tbody->s.torsoAnim = body->s.legsAnim = BOTH_DEAD2;\n\t\tbreak;\n\tcase BOTH_DEATH3:\n\tcase BOTH_DEAD3:\n\tdefault:\n\t\tbody->s.torsoAnim = body->s.legsAnim = BOTH_DEAD3;\n\t\tbreak;\n\t}\n\n\tbody->r.svFlags = ent->r.svFlags;\n\tVectorCopy (ent->r.mins, body->r.mins);\n\tVectorCopy (ent->r.maxs, body->r.maxs);\n\tVectorCopy (ent->r.absmin, body->r.absmin);\n\tVectorCopy (ent->r.absmax, body->r.absmax);\n\n\tbody->clipmask = CONTENTS_SOLID | CONTENTS_PLAYERCLIP;\n\tbody->r.contents = CONTENTS_CORPSE;\n\tbody->r.ownerNum = ent->s.number;\n\n\tbody->nextthink = level.time + 5000;\n\tbody->think = BodySink;\n\n\tbody->die = body_die;\n\n\t// don't take more damage if already gibbed\n\tif ( ent->health <= GIB_HEALTH ) {\n\t\tbody->takedamage = qfalse;\n\t} else {\n\t\tbody->takedamage = qtrue;\n\t}\n\n\n\tVectorCopy ( body->s.pos.trBase, body->r.currentOrigin );\n\ttrap_LinkEntity (body);\n}\n\n//======================================================================\n\n\n/*\n==================\nSetClientViewAngle\n\n==================\n*/\nvoid SetClientViewAngle( gentity_t *ent, vec3_t angle ) {\n\tint\t\t\ti;\n\n\t// set the delta angle\n\tfor (i=0 ; i<3 ; i++) {\n\t\tint\t\tcmdAngle;\n\n\t\tcmdAngle = ANGLE2SHORT(angle[i]);\n\t\tent->client->ps.delta_angles[i] = cmdAngle - ent->client->pers.cmd.angles[i];\n\t}\n\tVectorCopy( angle, ent->s.angles );\n\tVectorCopy (ent->s.angles, ent->client->ps.viewangles);\n}\n\n/*\n================\nrespawn\n================\n*/\nvoid respawn( gentity_t *ent ) {\n\tgentity_t\t*tent;\n\n\tCopyToBodyQue (ent);\n\tClientSpawn(ent);\n\n\t// add a teleportation effect\n\ttent = G_TempEntity( ent->client->ps.origin, EV_PLAYER_TELEPORT_IN );\n\ttent->s.clientNum = ent->s.clientNum;\n}\n\n/*\n================\nTeamCount\n\nReturns number of players on a team\n================\n*/\nteam_t TeamCount( int ignoreClientNum, int team ) {\n\tint\t\ti;\n\tint\t\tcount = 0;\n\n\tfor ( i = 0 ; i < level.maxclients ; i++ ) {\n\t\tif ( i == ignoreClientNum ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( level.clients[i].pers.connected == CON_DISCONNECTED ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( level.clients[i].sess.sessionTeam == team ) {\n\t\t\tcount++;\n\t\t}\n\t}\n\n\treturn count;\n}\n\n/*\n================\nTeamLeader\n\nReturns the client number of the team leader\n================\n*/\nint TeamLeader( int team ) {\n\tint\t\ti;\n\n\tfor ( i = 0 ; i < level.maxclients ; i++ ) {\n\t\tif ( level.clients[i].pers.connected == CON_DISCONNECTED ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( level.clients[i].sess.sessionTeam == team ) {\n\t\t\tif ( level.clients[i].sess.teamLeader )\n\t\t\t\treturn i;\n\t\t}\n\t}\n\n\treturn -1;\n}\n\n\n/*\n================\nPickTeam\n\n================\n*/\nteam_t PickTeam( int ignoreClientNum ) {\n\tint\t\tcounts[TEAM_NUM_TEAMS];\n\n\tcounts[TEAM_BLUE] = TeamCount( ignoreClientNum, TEAM_BLUE );\n\tcounts[TEAM_RED] = TeamCount( ignoreClientNum, TEAM_RED );\n\n\tif ( counts[TEAM_BLUE] > counts[TEAM_RED] ) {\n\t\treturn TEAM_RED;\n\t}\n\tif ( counts[TEAM_RED] > counts[TEAM_BLUE] ) {\n\t\treturn TEAM_BLUE;\n\t}\n\t// equal team count, so join the team with the lowest score\n\tif ( level.teamScores[TEAM_BLUE] > level.teamScores[TEAM_RED] ) {\n\t\treturn TEAM_RED;\n\t}\n\treturn TEAM_BLUE;\n}\n\n/*\n===========\nForceClientSkin\n\nForces a client's skin (for teamplay)\n===========\n*/\n/*\nstatic void ForceClientSkin( gclient_t *client, char *model, const char *skin ) {\n\tchar *p;\n\n\tif ((p = Q_strrchr(model, '/')) != 0) {\n\t\t*p = 0;\n\t}\n\n\tQ_strcat(model, MAX_QPATH, \"/\");\n\tQ_strcat(model, MAX_QPATH, skin);\n}\n*/\n\n/*\n===========\nClientCheckName\n============\n*/\nstatic void ClientCleanName( const char *in, char *out, int outSize ) {\n\tint\t\tlen, colorlessLen;\n\tchar\tch;\n\tchar\t*p;\n\tint\t\tspaces;\n\n\t//save room for trailing null byte\n\toutSize--;\n\n\tlen = 0;\n\tcolorlessLen = 0;\n\tp = out;\n\t*p = 0;\n\tspaces = 0;\n\n\twhile( 1 ) {\n\t\tch = *in++;\n\t\tif( !ch ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// don't allow leading spaces\n\t\tif( !*p && ch == ' ' ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// check colors\n\t\tif( ch == Q_COLOR_ESCAPE ) {\n\t\t\t// solo trailing carat is not a color prefix\n\t\t\tif( !*in ) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// don't allow black in a name, period\n\t\t\tif( ColorIndex(*in) == 0 ) {\n\t\t\t\tin++;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// make sure room in dest for both chars\n\t\t\tif( len > outSize - 2 ) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t*out++ = ch;\n\t\t\t*out++ = *in++;\n\t\t\tlen += 2;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// don't allow too many consecutive spaces\n\t\tif( ch == ' ' ) {\n\t\t\tspaces++;\n\t\t\tif( spaces > 3 ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tspaces = 0;\n\t\t}\n\n\t\tif( len > outSize - 1 ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t*out++ = ch;\n\t\tcolorlessLen++;\n\t\tlen++;\n\t}\n\t*out = 0;\n\n\t// don't allow empty names\n\tif( *p == 0 || colorlessLen == 0 ) {\n\t\tQ_strncpyz( p, \"UnnamedPlayer\", outSize );\n\t}\n}\n\n\n/*\n===========\nClientUserInfoChanged\n\nCalled from ClientConnect when the player first connects and\ndirectly by the server system when the player updates a userinfo variable.\n\nThe game can override any of the settings and call trap_SetUserinfo\nif desired.\n============\n*/\nvoid ClientUserinfoChanged( int clientNum ) {\n\tgentity_t *ent;\n\tint\t\tteamTask, teamLeader, team, health;\n\tchar\t*s;\n\tchar\tmodel[MAX_QPATH];\n\tchar\theadModel[MAX_QPATH];\n\tchar\toldname[MAX_STRING_CHARS];\n\tgclient_t\t*client;\n\tchar\tc1[MAX_INFO_STRING];\n\tchar\tc2[MAX_INFO_STRING];\n\tchar\tredTeam[MAX_INFO_STRING];\n\tchar\tblueTeam[MAX_INFO_STRING];\n\tchar\tuserinfo[MAX_INFO_STRING];\n\n\tent = g_entities + clientNum;\n\tclient = ent->client;\n\n\ttrap_GetUserinfo( clientNum, userinfo, sizeof( userinfo ) );\n\n\t// check for malformed or illegal info strings\n\tif ( !Info_Validate(userinfo) ) {\n\t\tstrcpy (userinfo, \"\\\\name\\\\badinfo\");\n\t}\n\n\t// check for local client\n\ts = Info_ValueForKey( userinfo, \"ip\" );\n\tif ( !strcmp( s, \"localhost\" ) ) {\n\t\tclient->pers.localClient = qtrue;\n\t}\n\n\t// check the item prediction\n\ts = Info_ValueForKey( userinfo, \"cg_predictItems\" );\n\tif ( !atoi( s ) ) {\n\t\tclient->pers.predictItemPickup = qfalse;\n\t} else {\n\t\tclient->pers.predictItemPickup = qtrue;\n\t}\n\n\t// set name\n\tQ_strncpyz ( oldname, client->pers.netname, sizeof( oldname ) );\n\ts = Info_ValueForKey (userinfo, \"name\");\n\tClientCleanName( s, client->pers.netname, sizeof(client->pers.netname) );\n\n\tif ( client->sess.sessionTeam == TEAM_SPECTATOR ) {\n\t\tif ( client->sess.spectatorState == SPECTATOR_SCOREBOARD ) {\n\t\t\tQ_strncpyz( client->pers.netname, \"scoreboard\", sizeof(client->pers.netname) );\n\t\t}\n\t}\n\n\tif ( client->pers.connected == CON_CONNECTED ) {\n\t\tif ( strcmp( oldname, client->pers.netname ) ) {\n\t\t\ttrap_SendServerCommand( -1, va(\"print \\\"%s\" S_COLOR_WHITE \" renamed to %s\\n\\\"\", oldname, \n\t\t\t\tclient->pers.netname) );\n\t\t}\n\t}\n\n\t// set max health\n#ifdef MISSIONPACK\n\tif (client->ps.powerups[PW_GUARD]) {\n\t\tclient->pers.maxHealth = 200;\n\t} else {\n\t\thealth = atoi( Info_ValueForKey( userinfo, \"handicap\" ) );\n\t\tclient->pers.maxHealth = health;\n\t\tif ( client->pers.maxHealth < 1 || client->pers.maxHealth > 100 ) {\n\t\t\tclient->pers.maxHealth = 100;\n\t\t}\n\t}\n#else\n\thealth = atoi( Info_ValueForKey( userinfo, \"handicap\" ) );\n\tclient->pers.maxHealth = health;\n\tif ( client->pers.maxHealth < 1 || client->pers.maxHealth > 100 ) {\n\t\tclient->pers.maxHealth = 100;\n\t}\n#endif\n\tclient->ps.stats[STAT_MAX_HEALTH] = client->pers.maxHealth;\n\n\t// set model\n\tif( g_gametype.integer >= GT_TEAM ) {\n\t\tQ_strncpyz( model, Info_ValueForKey (userinfo, \"team_model\"), sizeof( model ) );\n\t\tQ_strncpyz( headModel, Info_ValueForKey (userinfo, \"team_headmodel\"), sizeof( headModel ) );\n\t} else {\n\t\tQ_strncpyz( model, Info_ValueForKey (userinfo, \"model\"), sizeof( model ) );\n\t\tQ_strncpyz( headModel, Info_ValueForKey (userinfo, \"headmodel\"), sizeof( headModel ) );\n\t}\n\n\t// bots set their team a few frames later\n\tif (g_gametype.integer >= GT_TEAM && g_entities[clientNum].r.svFlags & SVF_BOT) {\n\t\ts = Info_ValueForKey( userinfo, \"team\" );\n\t\tif ( !Q_stricmp( s, \"red\" ) || !Q_stricmp( s, \"r\" ) ) {\n\t\t\tteam = TEAM_RED;\n\t\t} else if ( !Q_stricmp( s, \"blue\" ) || !Q_stricmp( s, \"b\" ) ) {\n\t\t\tteam = TEAM_BLUE;\n\t\t} else {\n\t\t\t// pick the team with the least number of players\n\t\t\tteam = PickTeam( clientNum );\n\t\t}\n\t}\n\telse {\n\t\tteam = client->sess.sessionTeam;\n\t}\n\n/*\tNOTE: all client side now\n\n\t// team\n\tswitch( team ) {\n\tcase TEAM_RED:\n\t\tForceClientSkin(client, model, \"red\");\n//\t\tForceClientSkin(client, headModel, \"red\");\n\t\tbreak;\n\tcase TEAM_BLUE:\n\t\tForceClientSkin(client, model, \"blue\");\n//\t\tForceClientSkin(client, headModel, \"blue\");\n\t\tbreak;\n\t}\n\t// don't ever use a default skin in teamplay, it would just waste memory\n\t// however bots will always join a team but they spawn in as spectator\n\tif ( g_gametype.integer >= GT_TEAM && team == TEAM_SPECTATOR) {\n\t\tForceClientSkin(client, model, \"red\");\n//\t\tForceClientSkin(client, headModel, \"red\");\n\t}\n*/\n\n#ifdef MISSIONPACK\n\tif (g_gametype.integer >= GT_TEAM) {\n\t\tclient->pers.teamInfo = qtrue;\n\t} else {\n\t\ts = Info_ValueForKey( userinfo, \"teamoverlay\" );\n\t\tif ( ! *s || atoi( s ) != 0 ) {\n\t\t\tclient->pers.teamInfo = qtrue;\n\t\t} else {\n\t\t\tclient->pers.teamInfo = qfalse;\n\t\t}\n\t}\n#else\n\t// teamInfo\n\ts = Info_ValueForKey( userinfo, \"teamoverlay\" );\n\tif ( ! *s || atoi( s ) != 0 ) {\n\t\tclient->pers.teamInfo = qtrue;\n\t} else {\n\t\tclient->pers.teamInfo = qfalse;\n\t}\n#endif\n\t/*\n\ts = Info_ValueForKey( userinfo, \"cg_pmove_fixed\" );\n\tif ( !*s || atoi( s ) == 0 ) {\n\t\tclient->pers.pmoveFixed = qfalse;\n\t}\n\telse {\n\t\tclient->pers.pmoveFixed = qtrue;\n\t}\n\t*/\n\n\t// team task (0 = none, 1 = offence, 2 = defence)\n\tteamTask = atoi(Info_ValueForKey(userinfo, \"teamtask\"));\n\t// team Leader (1 = leader, 0 is normal player)\n\tteamLeader = client->sess.teamLeader;\n\n\t// colors\n\tstrcpy(c1, Info_ValueForKey( userinfo, \"color1\" ));\n\tstrcpy(c2, Info_ValueForKey( userinfo, \"color2\" ));\n\n\tstrcpy(redTeam, Info_ValueForKey( userinfo, \"g_redteam\" ));\n\tstrcpy(blueTeam, Info_ValueForKey( userinfo, \"g_blueteam\" ));\n\n\t// send over a subset of the userinfo keys so other clients can\n\t// print scoreboards, display models, and play custom sounds\n\tif ( ent->r.svFlags & SVF_BOT ) {\n\t\ts = va(\"n\\\\%s\\\\t\\\\%i\\\\model\\\\%s\\\\hmodel\\\\%s\\\\c1\\\\%s\\\\c2\\\\%s\\\\hc\\\\%i\\\\w\\\\%i\\\\l\\\\%i\\\\skill\\\\%s\\\\tt\\\\%d\\\\tl\\\\%d\",\n\t\t\tclient->pers.netname, team, model, headModel, c1, c2, \n\t\t\tclient->pers.maxHealth, client->sess.wins, client->sess.losses,\n\t\t\tInfo_ValueForKey( userinfo, \"skill\" ), teamTask, teamLeader );\n\t} else {\n\t\ts = va(\"n\\\\%s\\\\t\\\\%i\\\\model\\\\%s\\\\hmodel\\\\%s\\\\g_redteam\\\\%s\\\\g_blueteam\\\\%s\\\\c1\\\\%s\\\\c2\\\\%s\\\\hc\\\\%i\\\\w\\\\%i\\\\l\\\\%i\\\\tt\\\\%d\\\\tl\\\\%d\",\n\t\t\tclient->pers.netname, client->sess.sessionTeam, model, headModel, redTeam, blueTeam, c1, c2, \n\t\t\tclient->pers.maxHealth, client->sess.wins, client->sess.losses, teamTask, teamLeader);\n\t}\n\n\ttrap_SetConfigstring( CS_PLAYERS+clientNum, s );\n\n\t// this is not the userinfo, more like the configstring actually\n\tG_LogPrintf( \"ClientUserinfoChanged: %i %s\\n\", clientNum, s );\n}\n\n\n/*\n===========\nClientConnect\n\nCalled when a player begins connecting to the server.\nCalled again for every map change or tournement restart.\n\nThe session information will be valid after exit.\n\nReturn NULL if the client should be allowed, otherwise return\na string with the reason for denial.\n\nOtherwise, the client will be sent the current gamestate\nand will eventually get to ClientBegin.\n\nfirstTime will be qtrue the very first time a client connects\nto the server machine, but qfalse on map changes and tournement\nrestarts.\n============\n*/\nchar *ClientConnect( int clientNum, qboolean firstTime, qboolean isBot ) {\n\tchar\t\t*value;\n//\tchar\t\t*areabits;\n\tgclient_t\t*client;\n\tchar\t\tuserinfo[MAX_INFO_STRING];\n\tgentity_t\t*ent;\n\n\tent = &g_entities[ clientNum ];\n\n\ttrap_GetUserinfo( clientNum, userinfo, sizeof( userinfo ) );\n\n \t// IP filtering\n \t// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=500\n \t// recommanding PB based IP / GUID banning, the builtin system is pretty limited\n \t// check to see if they are on the banned IP list\n\tvalue = Info_ValueForKey (userinfo, \"ip\");\n\tif ( G_FilterPacket( value ) ) {\n\t\treturn \"You are banned from this server.\";\n\t}\n\n  // we don't check password for bots and local client\n  // NOTE: local client <-> \"ip\" \"localhost\"\n  //   this means this client is not running in our current process\n\tif ( !( ent->r.svFlags & SVF_BOT ) && (strcmp(value, \"localhost\") != 0)) {\n\t\t// check for a password\n\t\tvalue = Info_ValueForKey (userinfo, \"password\");\n\t\tif ( g_password.string[0] && Q_stricmp( g_password.string, \"none\" ) &&\n\t\t\tstrcmp( g_password.string, value) != 0) {\n\t\t\treturn \"Invalid password\";\n\t\t}\n\t}\n\n\t// they can connect\n\tent->client = level.clients + clientNum;\n\tclient = ent->client;\n\n//\tareabits = client->areabits;\n\n\tmemset( client, 0, sizeof(*client) );\n\n\tclient->pers.connected = CON_CONNECTING;\n\n\t// read or initialize the session data\n\tif ( firstTime || level.newSession ) {\n\t\tG_InitSessionData( client, userinfo );\n\t}\n\tG_ReadSessionData( client );\n\n\tif( isBot ) {\n\t\tent->r.svFlags |= SVF_BOT;\n\t\tent->inuse = qtrue;\n\t\tif( !G_BotConnect( clientNum, !firstTime ) ) {\n\t\t\treturn \"BotConnectfailed\";\n\t\t}\n\t}\n\n\t// get and distribute relevent paramters\n\tG_LogPrintf( \"ClientConnect: %i\\n\", clientNum );\n\tClientUserinfoChanged( clientNum );\n\n\t// don't do the \"xxx connected\" messages if they were caried over from previous level\n\tif ( firstTime ) {\n\t\ttrap_SendServerCommand( -1, va(\"print \\\"%s\" S_COLOR_WHITE \" connected\\n\\\"\", client->pers.netname) );\n\t}\n\n\tif ( g_gametype.integer >= GT_TEAM &&\n\t\tclient->sess.sessionTeam != TEAM_SPECTATOR ) {\n\t\tBroadcastTeamChange( client, -1 );\n\t}\n\n\t// count current clients and rank for scoreboard\n\tCalculateRanks();\n\n\t// for statistics\n//\tclient->areabits = areabits;\n//\tif ( !client->areabits )\n//\t\tclient->areabits = G_Alloc( (trap_AAS_PointReachabilityAreaIndex( NULL ) + 7) / 8 );\n\n\treturn NULL;\n}\n\n/*\n===========\nClientBegin\n\ncalled when a client has finished connecting, and is ready\nto be placed into the level.  This will happen every level load,\nand on transition between teams, but doesn't happen on respawns\n============\n*/\nvoid ClientBegin( int clientNum ) {\n\tgentity_t\t*ent;\n\tgclient_t\t*client;\n\tgentity_t\t*tent;\n\tint\t\t\tflags;\n\n\tent = g_entities + clientNum;\n\n\tclient = level.clients + clientNum;\n\n\tif ( ent->r.linked ) {\n\t\ttrap_UnlinkEntity( ent );\n\t}\n\tG_InitGentity( ent );\n\tent->touch = 0;\n\tent->pain = 0;\n\tent->client = client;\n\n\tclient->pers.connected = CON_CONNECTED;\n\tclient->pers.enterTime = level.time;\n\tclient->pers.teamState.state = TEAM_BEGIN;\n\n\t// save eflags around this, because changing teams will\n\t// cause this to happen with a valid entity, and we\n\t// want to make sure the teleport bit is set right\n\t// so the viewpoint doesn't interpolate through the\n\t// world to the new position\n\tflags = client->ps.eFlags;\n\tmemset( &client->ps, 0, sizeof( client->ps ) );\n\tclient->ps.eFlags = flags;\n\n\t// locate ent at a spawn point\n\tClientSpawn( ent );\n\n\tif ( client->sess.sessionTeam != TEAM_SPECTATOR ) {\n\t\t// send event\n\t\ttent = G_TempEntity( ent->client->ps.origin, EV_PLAYER_TELEPORT_IN );\n\t\ttent->s.clientNum = ent->s.clientNum;\n\n\t\tif ( g_gametype.integer != GT_TOURNAMENT  ) {\n\t\t\ttrap_SendServerCommand( -1, va(\"print \\\"%s\" S_COLOR_WHITE \" entered the game\\n\\\"\", client->pers.netname) );\n\t\t}\n\t}\n\tG_LogPrintf( \"ClientBegin: %i\\n\", clientNum );\n\n\t// count current clients and rank for scoreboard\n\tCalculateRanks();\n}\n\n/*\n===========\nClientSpawn\n\nCalled every time a client is placed fresh in the world:\nafter the first ClientBegin, and after each respawn\nInitializes all non-persistant parts of playerState\n============\n*/\nvoid ClientSpawn(gentity_t *ent) {\n\tint\t\tindex;\n\tvec3_t\tspawn_origin, spawn_angles;\n\tgclient_t\t*client;\n\tint\t\ti;\n\tclientPersistant_t\tsaved;\n\tclientSession_t\t\tsavedSess;\n\tint\t\tpersistant[MAX_PERSISTANT];\n\tgentity_t\t*spawnPoint;\n\tint\t\tflags;\n\tint\t\tsavedPing;\n//\tchar\t*savedAreaBits;\n\tint\t\taccuracy_hits, accuracy_shots;\n\tint\t\teventSequence;\n\tchar\tuserinfo[MAX_INFO_STRING];\n\n\tindex = ent - g_entities;\n\tclient = ent->client;\n\n\t// find a spawn point\n\t// do it before setting health back up, so farthest\n\t// ranging doesn't count this client\n\tif ( client->sess.sessionTeam == TEAM_SPECTATOR ) {\n\t\tspawnPoint = SelectSpectatorSpawnPoint ( \n\t\t\t\t\t\tspawn_origin, spawn_angles);\n\t} else if (g_gametype.integer >= GT_CTF ) {\n\t\t// all base oriented team games use the CTF spawn points\n\t\tspawnPoint = SelectCTFSpawnPoint ( \n\t\t\t\t\t\tclient->sess.sessionTeam, \n\t\t\t\t\t\tclient->pers.teamState.state, \n\t\t\t\t\t\tspawn_origin, spawn_angles);\n\t} else {\n\t\tdo {\n\t\t\t// the first spawn should be at a good looking spot\n\t\t\tif ( !client->pers.initialSpawn && client->pers.localClient ) {\n\t\t\t\tclient->pers.initialSpawn = qtrue;\n\t\t\t\tspawnPoint = SelectInitialSpawnPoint( spawn_origin, spawn_angles );\n\t\t\t} else {\n\t\t\t\t// don't spawn near existing origin if possible\n\t\t\t\tspawnPoint = SelectSpawnPoint ( \n\t\t\t\t\tclient->ps.origin, \n\t\t\t\t\tspawn_origin, spawn_angles);\n\t\t\t}\n\n\t\t\t// Tim needs to prevent bots from spawning at the initial point\n\t\t\t// on q3dm0...\n\t\t\tif ( ( spawnPoint->flags & FL_NO_BOTS ) && ( ent->r.svFlags & SVF_BOT ) ) {\n\t\t\t\tcontinue;\t// try again\n\t\t\t}\n\t\t\t// just to be symetric, we have a nohumans option...\n\t\t\tif ( ( spawnPoint->flags & FL_NO_HUMANS ) && !( ent->r.svFlags & SVF_BOT ) ) {\n\t\t\t\tcontinue;\t// try again\n\t\t\t}\n\n\t\t\tbreak;\n\n\t\t} while ( 1 );\n\t}\n\tclient->pers.teamState.state = TEAM_ACTIVE;\n\n\t// always clear the kamikaze flag\n\tent->s.eFlags &= ~EF_KAMIKAZE;\n\n\t// toggle the teleport bit so the client knows to not lerp\n\t// and never clear the voted flag\n\tflags = ent->client->ps.eFlags & (EF_TELEPORT_BIT | EF_VOTED | EF_TEAMVOTED);\n\tflags ^= EF_TELEPORT_BIT;\n\n\t// clear everything but the persistant data\n\n\tsaved = client->pers;\n\tsavedSess = client->sess;\n\tsavedPing = client->ps.ping;\n//\tsavedAreaBits = client->areabits;\n\taccuracy_hits = client->accuracy_hits;\n\taccuracy_shots = client->accuracy_shots;\n\tfor ( i = 0 ; i < MAX_PERSISTANT ; i++ ) {\n\t\tpersistant[i] = client->ps.persistant[i];\n\t}\n\teventSequence = client->ps.eventSequence;\n\n\tmemset (client, 0, sizeof(*client)); // bk FIXME: Com_Memset?\n\n\tclient->pers = saved;\n\tclient->sess = savedSess;\n\tclient->ps.ping = savedPing;\n//\tclient->areabits = savedAreaBits;\n\tclient->accuracy_hits = accuracy_hits;\n\tclient->accuracy_shots = accuracy_shots;\n\tclient->lastkilled_client = -1;\n\n\tfor ( i = 0 ; i < MAX_PERSISTANT ; i++ ) {\n\t\tclient->ps.persistant[i] = persistant[i];\n\t}\n\tclient->ps.eventSequence = eventSequence;\n\t// increment the spawncount so the client will detect the respawn\n\tclient->ps.persistant[PERS_SPAWN_COUNT]++;\n\tclient->ps.persistant[PERS_TEAM] = client->sess.sessionTeam;\n\n\tclient->airOutTime = level.time + 12000;\n\n\ttrap_GetUserinfo( index, userinfo, sizeof(userinfo) );\n\t// set max health\n\tclient->pers.maxHealth = atoi( Info_ValueForKey( userinfo, \"handicap\" ) );\n\tif ( client->pers.maxHealth < 1 || client->pers.maxHealth > 100 ) {\n\t\tclient->pers.maxHealth = 100;\n\t}\n\t// clear entity values\n\tclient->ps.stats[STAT_MAX_HEALTH] = client->pers.maxHealth;\n\tclient->ps.eFlags = flags;\n\n\tent->s.groundEntityNum = ENTITYNUM_NONE;\n\tent->client = &level.clients[index];\n\tent->takedamage = qtrue;\n\tent->inuse = qtrue;\n\tent->classname = \"player\";\n\tent->r.contents = CONTENTS_BODY;\n\tent->clipmask = MASK_PLAYERSOLID;\n\tent->die = player_die;\n\tent->waterlevel = 0;\n\tent->watertype = 0;\n\tent->flags = 0;\n\t\n\tVectorCopy (playerMins, ent->r.mins);\n\tVectorCopy (playerMaxs, ent->r.maxs);\n\n\tclient->ps.clientNum = index;\n\n\tclient->ps.stats[STAT_WEAPONS] = ( 1 << WP_MACHINEGUN );\n\tif ( g_gametype.integer == GT_TEAM ) {\n\t\tclient->ps.ammo[WP_MACHINEGUN] = 50;\n\t} else {\n\t\tclient->ps.ammo[WP_MACHINEGUN] = 100;\n\t}\n\n\tclient->ps.stats[STAT_WEAPONS] |= ( 1 << WP_GAUNTLET );\n\tclient->ps.ammo[WP_GAUNTLET] = -1;\n\tclient->ps.ammo[WP_GRAPPLING_HOOK] = -1;\n\n\t// health will count down towards max_health\n\tent->health = client->ps.stats[STAT_HEALTH] = client->ps.stats[STAT_MAX_HEALTH] + 25;\n\n\tG_SetOrigin( ent, spawn_origin );\n\tVectorCopy( spawn_origin, client->ps.origin );\n\n\t// the respawned flag will be cleared after the attack and jump keys come up\n\tclient->ps.pm_flags |= PMF_RESPAWNED;\n\n\ttrap_GetUsercmd( client - level.clients, &ent->client->pers.cmd );\n\tSetClientViewAngle( ent, spawn_angles );\n\n\tif ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {\n\n\t} else {\n\t\tG_KillBox( ent );\n\t\ttrap_LinkEntity (ent);\n\n\t\t// force the base weapon up\n\t\tclient->ps.weapon = WP_MACHINEGUN;\n\t\tclient->ps.weaponstate = WEAPON_READY;\n\n\t}\n\n\t// don't allow full run speed for a bit\n\tclient->ps.pm_flags |= PMF_TIME_KNOCKBACK;\n\tclient->ps.pm_time = 100;\n\n\tclient->respawnTime = level.time;\n\tclient->inactivityTime = level.time + g_inactivity.integer * 1000;\n\tclient->latched_buttons = 0;\n\n\t// set default animations\n\tclient->ps.torsoAnim = TORSO_STAND;\n\tclient->ps.legsAnim = LEGS_IDLE;\n\n\tif ( level.intermissiontime ) {\n\t\tMoveClientToIntermission( ent );\n\t} else {\n\t\t// fire the targets of the spawn point\n\t\tG_UseTargets( spawnPoint, ent );\n\n\t\t// select the highest weapon number available, after any\n\t\t// spawn given items have fired\n\t\tclient->ps.weapon = 1;\n\t\tfor ( i = WP_NUM_WEAPONS - 1 ; i > 0 ; i-- ) {\n\t\t\tif ( client->ps.stats[STAT_WEAPONS] & ( 1 << i ) ) {\n\t\t\t\tclient->ps.weapon = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t// run a client frame to drop exactly to the floor,\n\t// initialize animations and other things\n\tclient->ps.commandTime = level.time - 100;\n\tent->client->pers.cmd.serverTime = level.time;\n\tClientThink( ent-g_entities );\n\n\t// positively link the client, even if the command times are weird\n\tif ( ent->client->sess.sessionTeam != TEAM_SPECTATOR ) {\n\t\tBG_PlayerStateToEntityState( &client->ps, &ent->s, qtrue );\n\t\tVectorCopy( ent->client->ps.origin, ent->r.currentOrigin );\n\t\ttrap_LinkEntity( ent );\n\t}\n\n\t// run the presend to set anything else\n\tClientEndFrame( ent );\n\n\t// clear entity state values\n\tBG_PlayerStateToEntityState( &client->ps, &ent->s, qtrue );\n}\n\n\n/*\n===========\nClientDisconnect\n\nCalled when a player drops from the server.\nWill not be called between levels.\n\nThis should NOT be called directly by any game logic,\ncall trap_DropClient(), which will call this and do\nserver system housekeeping.\n============\n*/\nvoid ClientDisconnect( int clientNum ) {\n\tgentity_t\t*ent;\n\tgentity_t\t*tent;\n\tint\t\t\ti;\n\n\t// cleanup if we are kicking a bot that\n\t// hasn't spawned yet\n\tG_RemoveQueuedBotBegin( clientNum );\n\n\tent = g_entities + clientNum;\n\tif ( !ent->client ) {\n\t\treturn;\n\t}\n\n\t// stop any following clients\n\tfor ( i = 0 ; i < level.maxclients ; i++ ) {\n\t\tif ( level.clients[i].sess.sessionTeam == TEAM_SPECTATOR\n\t\t\t&& level.clients[i].sess.spectatorState == SPECTATOR_FOLLOW\n\t\t\t&& level.clients[i].sess.spectatorClient == clientNum ) {\n\t\t\tStopFollowing( &g_entities[i] );\n\t\t}\n\t}\n\n\t// send effect if they were completely connected\n\tif ( ent->client->pers.connected == CON_CONNECTED \n\t\t&& ent->client->sess.sessionTeam != TEAM_SPECTATOR ) {\n\t\ttent = G_TempEntity( ent->client->ps.origin, EV_PLAYER_TELEPORT_OUT );\n\t\ttent->s.clientNum = ent->s.clientNum;\n\n\t\t// They don't get to take powerups with them!\n\t\t// Especially important for stuff like CTF flags\n\t\tTossClientItems( ent );\n#ifdef MISSIONPACK\n\t\tTossClientPersistantPowerups( ent );\n\t\tif( g_gametype.integer == GT_HARVESTER ) {\n\t\t\tTossClientCubes( ent );\n\t\t}\n#endif\n\n\t}\n\n\tG_LogPrintf( \"ClientDisconnect: %i\\n\", clientNum );\n\n\t// if we are playing in tourney mode and losing, give a win to the other player\n\tif ( (g_gametype.integer == GT_TOURNAMENT )\n\t\t&& !level.intermissiontime\n\t\t&& !level.warmupTime && level.sortedClients[1] == clientNum ) {\n\t\tlevel.clients[ level.sortedClients[0] ].sess.wins++;\n\t\tClientUserinfoChanged( level.sortedClients[0] );\n\t}\n\n\ttrap_UnlinkEntity (ent);\n\tent->s.modelindex = 0;\n\tent->inuse = qfalse;\n\tent->classname = \"disconnected\";\n\tent->client->pers.connected = CON_DISCONNECTED;\n\tent->client->ps.persistant[PERS_TEAM] = TEAM_FREE;\n\tent->client->sess.sessionTeam = TEAM_FREE;\n\n\ttrap_SetConfigstring( CS_PLAYERS + clientNum, \"\");\n\n\tCalculateRanks();\n\n\tif ( ent->r.svFlags & SVF_BOT ) {\n\t\tBotAIShutdownClient( clientNum, qfalse );\n\t}\n}\n\n\n"
  },
  {
    "path": "code/game/g_cmds.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#include \"g_local.h\"\n\n#include \"../../ui/menudef.h\"\t\t\t// for the voice chats\n\n/*\n==================\nDeathmatchScoreboardMessage\n\n==================\n*/\nvoid DeathmatchScoreboardMessage( gentity_t *ent ) {\n\tchar\t\tentry[1024];\n\tchar\t\tstring[1400];\n\tint\t\t\tstringlength;\n\tint\t\t\ti, j;\n\tgclient_t\t*cl;\n\tint\t\t\tnumSorted, scoreFlags, accuracy, perfect;\n\n\t// send the latest information on all clients\n\tstring[0] = 0;\n\tstringlength = 0;\n\tscoreFlags = 0;\n\n\tnumSorted = level.numConnectedClients;\n\t\n\tfor (i=0 ; i < numSorted ; i++) {\n\t\tint\t\tping;\n\n\t\tcl = &level.clients[level.sortedClients[i]];\n\n\t\tif ( cl->pers.connected == CON_CONNECTING ) {\n\t\t\tping = -1;\n\t\t} else {\n\t\t\tping = cl->ps.ping < 999 ? cl->ps.ping : 999;\n\t\t}\n\n\t\tif( cl->accuracy_shots ) {\n\t\t\taccuracy = cl->accuracy_hits * 100 / cl->accuracy_shots;\n\t\t}\n\t\telse {\n\t\t\taccuracy = 0;\n\t\t}\n\t\tperfect = ( cl->ps.persistant[PERS_RANK] == 0 && cl->ps.persistant[PERS_KILLED] == 0 ) ? 1 : 0;\n\n\t\tCom_sprintf (entry, sizeof(entry),\n\t\t\t\" %i %i %i %i %i %i %i %i %i %i %i %i %i %i\", level.sortedClients[i],\n\t\t\tcl->ps.persistant[PERS_SCORE], ping, (level.time - cl->pers.enterTime)/60000,\n\t\t\tscoreFlags, g_entities[level.sortedClients[i]].s.powerups, accuracy, \n\t\t\tcl->ps.persistant[PERS_IMPRESSIVE_COUNT],\n\t\t\tcl->ps.persistant[PERS_EXCELLENT_COUNT],\n\t\t\tcl->ps.persistant[PERS_GAUNTLET_FRAG_COUNT], \n\t\t\tcl->ps.persistant[PERS_DEFEND_COUNT], \n\t\t\tcl->ps.persistant[PERS_ASSIST_COUNT], \n\t\t\tperfect,\n\t\t\tcl->ps.persistant[PERS_CAPTURES]);\n\t\tj = strlen(entry);\n\t\tif (stringlength + j > 1024)\n\t\t\tbreak;\n\t\tstrcpy (string + stringlength, entry);\n\t\tstringlength += j;\n\t}\n\n\ttrap_SendServerCommand( ent-g_entities, va(\"scores %i %i %i%s\", i, \n\t\tlevel.teamScores[TEAM_RED], level.teamScores[TEAM_BLUE],\n\t\tstring ) );\n}\n\n\n/*\n==================\nCmd_Score_f\n\nRequest current scoreboard information\n==================\n*/\nvoid Cmd_Score_f( gentity_t *ent ) {\n\tDeathmatchScoreboardMessage( ent );\n}\n\n\n\n/*\n==================\nCheatsOk\n==================\n*/\nqboolean\tCheatsOk( gentity_t *ent ) {\n\tif ( !g_cheats.integer ) {\n\t\ttrap_SendServerCommand( ent-g_entities, va(\"print \\\"Cheats are not enabled on this server.\\n\\\"\"));\n\t\treturn qfalse;\n\t}\n\tif ( ent->health <= 0 ) {\n\t\ttrap_SendServerCommand( ent-g_entities, va(\"print \\\"You must be alive to use this command.\\n\\\"\"));\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n\n/*\n==================\nConcatArgs\n==================\n*/\nchar\t*ConcatArgs( int start ) {\n\tint\t\ti, c, tlen;\n\tstatic char\tline[MAX_STRING_CHARS];\n\tint\t\tlen;\n\tchar\targ[MAX_STRING_CHARS];\n\n\tlen = 0;\n\tc = trap_Argc();\n\tfor ( i = start ; i < c ; i++ ) {\n\t\ttrap_Argv( i, arg, sizeof( arg ) );\n\t\ttlen = strlen( arg );\n\t\tif ( len + tlen >= MAX_STRING_CHARS - 1 ) {\n\t\t\tbreak;\n\t\t}\n\t\tmemcpy( line + len, arg, tlen );\n\t\tlen += tlen;\n\t\tif ( i != c - 1 ) {\n\t\t\tline[len] = ' ';\n\t\t\tlen++;\n\t\t}\n\t}\n\n\tline[len] = 0;\n\n\treturn line;\n}\n\n/*\n==================\nSanitizeString\n\nRemove case and control characters\n==================\n*/\nvoid SanitizeString( char *in, char *out ) {\n\twhile ( *in ) {\n\t\tif ( *in == 27 ) {\n\t\t\tin += 2;\t\t// skip color code\n\t\t\tcontinue;\n\t\t}\n\t\tif ( *in < 32 ) {\n\t\t\tin++;\n\t\t\tcontinue;\n\t\t}\n\t\t*out++ = tolower( *in++ );\n\t}\n\n\t*out = 0;\n}\n\n/*\n==================\nClientNumberFromString\n\nReturns a player number for either a number or name string\nReturns -1 if invalid\n==================\n*/\nint ClientNumberFromString( gentity_t *to, char *s ) {\n\tgclient_t\t*cl;\n\tint\t\t\tidnum;\n\tchar\t\ts2[MAX_STRING_CHARS];\n\tchar\t\tn2[MAX_STRING_CHARS];\n\n\t// numeric values are just slot numbers\n\tif (s[0] >= '0' && s[0] <= '9') {\n\t\tidnum = atoi( s );\n\t\tif ( idnum < 0 || idnum >= level.maxclients ) {\n\t\t\ttrap_SendServerCommand( to-g_entities, va(\"print \\\"Bad client slot: %i\\n\\\"\", idnum));\n\t\t\treturn -1;\n\t\t}\n\n\t\tcl = &level.clients[idnum];\n\t\tif ( cl->pers.connected != CON_CONNECTED ) {\n\t\t\ttrap_SendServerCommand( to-g_entities, va(\"print \\\"Client %i is not active\\n\\\"\", idnum));\n\t\t\treturn -1;\n\t\t}\n\t\treturn idnum;\n\t}\n\n\t// check for a name match\n\tSanitizeString( s, s2 );\n\tfor ( idnum=0,cl=level.clients ; idnum < level.maxclients ; idnum++,cl++ ) {\n\t\tif ( cl->pers.connected != CON_CONNECTED ) {\n\t\t\tcontinue;\n\t\t}\n\t\tSanitizeString( cl->pers.netname, n2 );\n\t\tif ( !strcmp( n2, s2 ) ) {\n\t\t\treturn idnum;\n\t\t}\n\t}\n\n\ttrap_SendServerCommand( to-g_entities, va(\"print \\\"User %s is not on the server\\n\\\"\", s));\n\treturn -1;\n}\n\n/*\n==================\nCmd_Give_f\n\nGive items to a client\n==================\n*/\nvoid Cmd_Give_f (gentity_t *ent)\n{\n\tchar\t\t*name;\n\tgitem_t\t\t*it;\n\tint\t\t\ti;\n\tqboolean\tgive_all;\n\tgentity_t\t\t*it_ent;\n\ttrace_t\t\ttrace;\n\n\tif ( !CheatsOk( ent ) ) {\n\t\treturn;\n\t}\n\n\tname = ConcatArgs( 1 );\n\n\tif (Q_stricmp(name, \"all\") == 0)\n\t\tgive_all = qtrue;\n\telse\n\t\tgive_all = qfalse;\n\n\tif (give_all || Q_stricmp( name, \"health\") == 0)\n\t{\n\t\tent->health = ent->client->ps.stats[STAT_MAX_HEALTH];\n\t\tif (!give_all)\n\t\t\treturn;\n\t}\n\n\tif (give_all || Q_stricmp(name, \"weapons\") == 0)\n\t{\n\t\tent->client->ps.stats[STAT_WEAPONS] = (1 << WP_NUM_WEAPONS) - 1 - \n\t\t\t( 1 << WP_GRAPPLING_HOOK ) - ( 1 << WP_NONE );\n\t\tif (!give_all)\n\t\t\treturn;\n\t}\n\n\tif (give_all || Q_stricmp(name, \"ammo\") == 0)\n\t{\n\t\tfor ( i = 0 ; i < MAX_WEAPONS ; i++ ) {\n\t\t\tent->client->ps.ammo[i] = 999;\n\t\t}\n\t\tif (!give_all)\n\t\t\treturn;\n\t}\n\n\tif (give_all || Q_stricmp(name, \"armor\") == 0)\n\t{\n\t\tent->client->ps.stats[STAT_ARMOR] = 200;\n\n\t\tif (!give_all)\n\t\t\treturn;\n\t}\n\n\tif (Q_stricmp(name, \"excellent\") == 0) {\n\t\tent->client->ps.persistant[PERS_EXCELLENT_COUNT]++;\n\t\treturn;\n\t}\n\tif (Q_stricmp(name, \"impressive\") == 0) {\n\t\tent->client->ps.persistant[PERS_IMPRESSIVE_COUNT]++;\n\t\treturn;\n\t}\n\tif (Q_stricmp(name, \"gauntletaward\") == 0) {\n\t\tent->client->ps.persistant[PERS_GAUNTLET_FRAG_COUNT]++;\n\t\treturn;\n\t}\n\tif (Q_stricmp(name, \"defend\") == 0) {\n\t\tent->client->ps.persistant[PERS_DEFEND_COUNT]++;\n\t\treturn;\n\t}\n\tif (Q_stricmp(name, \"assist\") == 0) {\n\t\tent->client->ps.persistant[PERS_ASSIST_COUNT]++;\n\t\treturn;\n\t}\n\n\t// spawn a specific item right on the player\n\tif ( !give_all ) {\n\t\tit = BG_FindItem (name);\n\t\tif (!it) {\n\t\t\treturn;\n\t\t}\n\n\t\tit_ent = G_Spawn();\n\t\tVectorCopy( ent->r.currentOrigin, it_ent->s.origin );\n\t\tit_ent->classname = it->classname;\n\t\tG_SpawnItem (it_ent, it);\n\t\tFinishSpawningItem(it_ent );\n\t\tmemset( &trace, 0, sizeof( trace ) );\n\t\tTouch_Item (it_ent, ent, &trace);\n\t\tif (it_ent->inuse) {\n\t\t\tG_FreeEntity( it_ent );\n\t\t}\n\t}\n}\n\n\n/*\n==================\nCmd_God_f\n\nSets client to godmode\n\nargv(0) god\n==================\n*/\nvoid Cmd_God_f (gentity_t *ent)\n{\n\tchar\t*msg;\n\n\tif ( !CheatsOk( ent ) ) {\n\t\treturn;\n\t}\n\n\tent->flags ^= FL_GODMODE;\n\tif (!(ent->flags & FL_GODMODE) )\n\t\tmsg = \"godmode OFF\\n\";\n\telse\n\t\tmsg = \"godmode ON\\n\";\n\n\ttrap_SendServerCommand( ent-g_entities, va(\"print \\\"%s\\\"\", msg));\n}\n\n\n/*\n==================\nCmd_Notarget_f\n\nSets client to notarget\n\nargv(0) notarget\n==================\n*/\nvoid Cmd_Notarget_f( gentity_t *ent ) {\n\tchar\t*msg;\n\n\tif ( !CheatsOk( ent ) ) {\n\t\treturn;\n\t}\n\n\tent->flags ^= FL_NOTARGET;\n\tif (!(ent->flags & FL_NOTARGET) )\n\t\tmsg = \"notarget OFF\\n\";\n\telse\n\t\tmsg = \"notarget ON\\n\";\n\n\ttrap_SendServerCommand( ent-g_entities, va(\"print \\\"%s\\\"\", msg));\n}\n\n\n/*\n==================\nCmd_Noclip_f\n\nargv(0) noclip\n==================\n*/\nvoid Cmd_Noclip_f( gentity_t *ent ) {\n\tchar\t*msg;\n\n\tif ( !CheatsOk( ent ) ) {\n\t\treturn;\n\t}\n\n\tif ( ent->client->noclip ) {\n\t\tmsg = \"noclip OFF\\n\";\n\t} else {\n\t\tmsg = \"noclip ON\\n\";\n\t}\n\tent->client->noclip = !ent->client->noclip;\n\n\ttrap_SendServerCommand( ent-g_entities, va(\"print \\\"%s\\\"\", msg));\n}\n\n\n/*\n==================\nCmd_LevelShot_f\n\nThis is just to help generate the level pictures\nfor the menus.  It goes to the intermission immediately\nand sends over a command to the client to resize the view,\nhide the scoreboard, and take a special screenshot\n==================\n*/\nvoid Cmd_LevelShot_f( gentity_t *ent ) {\n\tif ( !CheatsOk( ent ) ) {\n\t\treturn;\n\t}\n\n\t// doesn't work in single player\n\tif ( g_gametype.integer != 0 ) {\n\t\ttrap_SendServerCommand( ent-g_entities, \n\t\t\t\"print \\\"Must be in g_gametype 0 for levelshot\\n\\\"\" );\n\t\treturn;\n\t}\n\n\tBeginIntermission();\n\ttrap_SendServerCommand( ent-g_entities, \"clientLevelShot\" );\n}\n\n\n/*\n==================\nCmd_LevelShot_f\n\nThis is just to help generate the level pictures\nfor the menus.  It goes to the intermission immediately\nand sends over a command to the client to resize the view,\nhide the scoreboard, and take a special screenshot\n==================\n*/\nvoid Cmd_TeamTask_f( gentity_t *ent ) {\n\tchar userinfo[MAX_INFO_STRING];\n\tchar\t\targ[MAX_TOKEN_CHARS];\n\tint task;\n\tint client = ent->client - level.clients;\n\n\tif ( trap_Argc() != 2 ) {\n\t\treturn;\n\t}\n\ttrap_Argv( 1, arg, sizeof( arg ) );\n\ttask = atoi( arg );\n\n\ttrap_GetUserinfo(client, userinfo, sizeof(userinfo));\n\tInfo_SetValueForKey(userinfo, \"teamtask\", va(\"%d\", task));\n\ttrap_SetUserinfo(client, userinfo);\n\tClientUserinfoChanged(client);\n}\n\n\n\n/*\n=================\nCmd_Kill_f\n=================\n*/\nvoid Cmd_Kill_f( gentity_t *ent ) {\n\tif ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {\n\t\treturn;\n\t}\n\tif (ent->health <= 0) {\n\t\treturn;\n\t}\n\tent->flags &= ~FL_GODMODE;\n\tent->client->ps.stats[STAT_HEALTH] = ent->health = -999;\n\tplayer_die (ent, ent, ent, 100000, MOD_SUICIDE);\n}\n\n/*\n=================\nBroadCastTeamChange\n\nLet everyone know about a team change\n=================\n*/\nvoid BroadcastTeamChange( gclient_t *client, int oldTeam )\n{\n\tif ( client->sess.sessionTeam == TEAM_RED ) {\n\t\ttrap_SendServerCommand( -1, va(\"cp \\\"%s\" S_COLOR_WHITE \" joined the red team.\\n\\\"\",\n\t\t\tclient->pers.netname) );\n\t} else if ( client->sess.sessionTeam == TEAM_BLUE ) {\n\t\ttrap_SendServerCommand( -1, va(\"cp \\\"%s\" S_COLOR_WHITE \" joined the blue team.\\n\\\"\",\n\t\tclient->pers.netname));\n\t} else if ( client->sess.sessionTeam == TEAM_SPECTATOR && oldTeam != TEAM_SPECTATOR ) {\n\t\ttrap_SendServerCommand( -1, va(\"cp \\\"%s\" S_COLOR_WHITE \" joined the spectators.\\n\\\"\",\n\t\tclient->pers.netname));\n\t} else if ( client->sess.sessionTeam == TEAM_FREE ) {\n\t\ttrap_SendServerCommand( -1, va(\"cp \\\"%s\" S_COLOR_WHITE \" joined the battle.\\n\\\"\",\n\t\tclient->pers.netname));\n\t}\n}\n\n/*\n=================\nSetTeam\n=================\n*/\nvoid SetTeam( gentity_t *ent, char *s ) {\n\tint\t\t\t\t\tteam, oldTeam;\n\tgclient_t\t\t\t*client;\n\tint\t\t\t\t\tclientNum;\n\tspectatorState_t\tspecState;\n\tint\t\t\t\t\tspecClient;\n\tint\t\t\t\t\tteamLeader;\n\n\t//\n\t// see what change is requested\n\t//\n\tclient = ent->client;\n\n\tclientNum = client - level.clients;\n\tspecClient = 0;\n\tspecState = SPECTATOR_NOT;\n\tif ( !Q_stricmp( s, \"scoreboard\" ) || !Q_stricmp( s, \"score\" )  ) {\n\t\tteam = TEAM_SPECTATOR;\n\t\tspecState = SPECTATOR_SCOREBOARD;\n\t} else if ( !Q_stricmp( s, \"follow1\" ) ) {\n\t\tteam = TEAM_SPECTATOR;\n\t\tspecState = SPECTATOR_FOLLOW;\n\t\tspecClient = -1;\n\t} else if ( !Q_stricmp( s, \"follow2\" ) ) {\n\t\tteam = TEAM_SPECTATOR;\n\t\tspecState = SPECTATOR_FOLLOW;\n\t\tspecClient = -2;\n\t} else if ( !Q_stricmp( s, \"spectator\" ) || !Q_stricmp( s, \"s\" ) ) {\n\t\tteam = TEAM_SPECTATOR;\n\t\tspecState = SPECTATOR_FREE;\n\t} else if ( g_gametype.integer >= GT_TEAM ) {\n\t\t// if running a team game, assign player to one of the teams\n\t\tspecState = SPECTATOR_NOT;\n\t\tif ( !Q_stricmp( s, \"red\" ) || !Q_stricmp( s, \"r\" ) ) {\n\t\t\tteam = TEAM_RED;\n\t\t} else if ( !Q_stricmp( s, \"blue\" ) || !Q_stricmp( s, \"b\" ) ) {\n\t\t\tteam = TEAM_BLUE;\n\t\t} else {\n\t\t\t// pick the team with the least number of players\n\t\t\tteam = PickTeam( clientNum );\n\t\t}\n\n\t\tif ( g_teamForceBalance.integer  ) {\n\t\t\tint\t\tcounts[TEAM_NUM_TEAMS];\n\n\t\t\tcounts[TEAM_BLUE] = TeamCount( ent->client->ps.clientNum, TEAM_BLUE );\n\t\t\tcounts[TEAM_RED] = TeamCount( ent->client->ps.clientNum, TEAM_RED );\n\n\t\t\t// We allow a spread of two\n\t\t\tif ( team == TEAM_RED && counts[TEAM_RED] - counts[TEAM_BLUE] > 1 ) {\n\t\t\t\ttrap_SendServerCommand( ent->client->ps.clientNum, \n\t\t\t\t\t\"cp \\\"Red team has too many players.\\n\\\"\" );\n\t\t\t\treturn; // ignore the request\n\t\t\t}\n\t\t\tif ( team == TEAM_BLUE && counts[TEAM_BLUE] - counts[TEAM_RED] > 1 ) {\n\t\t\t\ttrap_SendServerCommand( ent->client->ps.clientNum, \n\t\t\t\t\t\"cp \\\"Blue team has too many players.\\n\\\"\" );\n\t\t\t\treturn; // ignore the request\n\t\t\t}\n\n\t\t\t// It's ok, the team we are switching to has less or same number of players\n\t\t}\n\n\t} else {\n\t\t// force them to spectators if there aren't any spots free\n\t\tteam = TEAM_FREE;\n\t}\n\n\t// override decision if limiting the players\n\tif ( (g_gametype.integer == GT_TOURNAMENT)\n\t\t&& level.numNonSpectatorClients >= 2 ) {\n\t\tteam = TEAM_SPECTATOR;\n\t} else if ( g_maxGameClients.integer > 0 && \n\t\tlevel.numNonSpectatorClients >= g_maxGameClients.integer ) {\n\t\tteam = TEAM_SPECTATOR;\n\t}\n\n\t//\n\t// decide if we will allow the change\n\t//\n\toldTeam = client->sess.sessionTeam;\n\tif ( team == oldTeam && team != TEAM_SPECTATOR ) {\n\t\treturn;\n\t}\n\n\t//\n\t// execute the team change\n\t//\n\n\t// if the player was dead leave the body\n\tif ( client->ps.stats[STAT_HEALTH] <= 0 ) {\n\t\tCopyToBodyQue(ent);\n\t}\n\n\t// he starts at 'base'\n\tclient->pers.teamState.state = TEAM_BEGIN;\n\tif ( oldTeam != TEAM_SPECTATOR ) {\n\t\t// Kill him (makes sure he loses flags, etc)\n\t\tent->flags &= ~FL_GODMODE;\n\t\tent->client->ps.stats[STAT_HEALTH] = ent->health = 0;\n\t\tplayer_die (ent, ent, ent, 100000, MOD_SUICIDE);\n\n\t}\n\t// they go to the end of the line for tournements\n\tif ( team == TEAM_SPECTATOR ) {\n\t\tclient->sess.spectatorTime = level.time;\n\t}\n\n\tclient->sess.sessionTeam = team;\n\tclient->sess.spectatorState = specState;\n\tclient->sess.spectatorClient = specClient;\n\n\tclient->sess.teamLeader = qfalse;\n\tif ( team == TEAM_RED || team == TEAM_BLUE ) {\n\t\tteamLeader = TeamLeader( team );\n\t\t// if there is no team leader or the team leader is a bot and this client is not a bot\n\t\tif ( teamLeader == -1 || ( !(g_entities[clientNum].r.svFlags & SVF_BOT) && (g_entities[teamLeader].r.svFlags & SVF_BOT) ) ) {\n\t\t\tSetLeader( team, clientNum );\n\t\t}\n\t}\n\t// make sure there is a team leader on the team the player came from\n\tif ( oldTeam == TEAM_RED || oldTeam == TEAM_BLUE ) {\n\t\tCheckTeamLeader( oldTeam );\n\t}\n\n\tBroadcastTeamChange( client, oldTeam );\n\n\t// get and distribute relevent paramters\n\tClientUserinfoChanged( clientNum );\n\n\tClientBegin( clientNum );\n}\n\n/*\n=================\nStopFollowing\n\nIf the client being followed leaves the game, or you just want to drop\nto free floating spectator mode\n=================\n*/\nvoid StopFollowing( gentity_t *ent ) {\n\tent->client->ps.persistant[ PERS_TEAM ] = TEAM_SPECTATOR;\t\n\tent->client->sess.sessionTeam = TEAM_SPECTATOR;\t\n\tent->client->sess.spectatorState = SPECTATOR_FREE;\n\tent->client->ps.pm_flags &= ~PMF_FOLLOW;\n\tent->r.svFlags &= ~SVF_BOT;\n\tent->client->ps.clientNum = ent - g_entities;\n}\n\n/*\n=================\nCmd_Team_f\n=================\n*/\nvoid Cmd_Team_f( gentity_t *ent ) {\n\tint\t\t\toldTeam;\n\tchar\t\ts[MAX_TOKEN_CHARS];\n\n\tif ( trap_Argc() != 2 ) {\n\t\toldTeam = ent->client->sess.sessionTeam;\n\t\tswitch ( oldTeam ) {\n\t\tcase TEAM_BLUE:\n\t\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"Blue team\\n\\\"\" );\n\t\t\tbreak;\n\t\tcase TEAM_RED:\n\t\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"Red team\\n\\\"\" );\n\t\t\tbreak;\n\t\tcase TEAM_FREE:\n\t\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"Free team\\n\\\"\" );\n\t\t\tbreak;\n\t\tcase TEAM_SPECTATOR:\n\t\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"Spectator team\\n\\\"\" );\n\t\t\tbreak;\n\t\t}\n\t\treturn;\n\t}\n\n\tif ( ent->client->switchTeamTime > level.time ) {\n\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"May not switch teams more than once per 5 seconds.\\n\\\"\" );\n\t\treturn;\n\t}\n\n\t// if they are playing a tournement game, count as a loss\n\tif ( (g_gametype.integer == GT_TOURNAMENT )\n\t\t&& ent->client->sess.sessionTeam == TEAM_FREE ) {\n\t\tent->client->sess.losses++;\n\t}\n\n\ttrap_Argv( 1, s, sizeof( s ) );\n\n\tSetTeam( ent, s );\n\n\tent->client->switchTeamTime = level.time + 5000;\n}\n\n\n/*\n=================\nCmd_Follow_f\n=================\n*/\nvoid Cmd_Follow_f( gentity_t *ent ) {\n\tint\t\ti;\n\tchar\targ[MAX_TOKEN_CHARS];\n\n\tif ( trap_Argc() != 2 ) {\n\t\tif ( ent->client->sess.spectatorState == SPECTATOR_FOLLOW ) {\n\t\t\tStopFollowing( ent );\n\t\t}\n\t\treturn;\n\t}\n\n\ttrap_Argv( 1, arg, sizeof( arg ) );\n\ti = ClientNumberFromString( ent, arg );\n\tif ( i == -1 ) {\n\t\treturn;\n\t}\n\n\t// can't follow self\n\tif ( &level.clients[ i ] == ent->client ) {\n\t\treturn;\n\t}\n\n\t// can't follow another spectator\n\tif ( level.clients[ i ].sess.sessionTeam == TEAM_SPECTATOR ) {\n\t\treturn;\n\t}\n\n\t// if they are playing a tournement game, count as a loss\n\tif ( (g_gametype.integer == GT_TOURNAMENT )\n\t\t&& ent->client->sess.sessionTeam == TEAM_FREE ) {\n\t\tent->client->sess.losses++;\n\t}\n\n\t// first set them to spectator\n\tif ( ent->client->sess.sessionTeam != TEAM_SPECTATOR ) {\n\t\tSetTeam( ent, \"spectator\" );\n\t}\n\n\tent->client->sess.spectatorState = SPECTATOR_FOLLOW;\n\tent->client->sess.spectatorClient = i;\n}\n\n/*\n=================\nCmd_FollowCycle_f\n=================\n*/\nvoid Cmd_FollowCycle_f( gentity_t *ent, int dir ) {\n\tint\t\tclientnum;\n\tint\t\toriginal;\n\n\t// if they are playing a tournement game, count as a loss\n\tif ( (g_gametype.integer == GT_TOURNAMENT )\n\t\t&& ent->client->sess.sessionTeam == TEAM_FREE ) {\n\t\tent->client->sess.losses++;\n\t}\n\t// first set them to spectator\n\tif ( ent->client->sess.spectatorState == SPECTATOR_NOT ) {\n\t\tSetTeam( ent, \"spectator\" );\n\t}\n\n\tif ( dir != 1 && dir != -1 ) {\n\t\tG_Error( \"Cmd_FollowCycle_f: bad dir %i\", dir );\n\t}\n\n\tclientnum = ent->client->sess.spectatorClient;\n\toriginal = clientnum;\n\tdo {\n\t\tclientnum += dir;\n\t\tif ( clientnum >= level.maxclients ) {\n\t\t\tclientnum = 0;\n\t\t}\n\t\tif ( clientnum < 0 ) {\n\t\t\tclientnum = level.maxclients - 1;\n\t\t}\n\n\t\t// can only follow connected clients\n\t\tif ( level.clients[ clientnum ].pers.connected != CON_CONNECTED ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// can't follow another spectator\n\t\tif ( level.clients[ clientnum ].sess.sessionTeam == TEAM_SPECTATOR ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// this is good, we can use it\n\t\tent->client->sess.spectatorClient = clientnum;\n\t\tent->client->sess.spectatorState = SPECTATOR_FOLLOW;\n\t\treturn;\n\t} while ( clientnum != original );\n\n\t// leave it where it was\n}\n\n\n/*\n==================\nG_Say\n==================\n*/\n\nstatic void G_SayTo( gentity_t *ent, gentity_t *other, int mode, int color, const char *name, const char *message ) {\n\tif (!other) {\n\t\treturn;\n\t}\n\tif (!other->inuse) {\n\t\treturn;\n\t}\n\tif (!other->client) {\n\t\treturn;\n\t}\n\tif ( other->client->pers.connected != CON_CONNECTED ) {\n\t\treturn;\n\t}\n\tif ( mode == SAY_TEAM  && !OnSameTeam(ent, other) ) {\n\t\treturn;\n\t}\n\t// no chatting to players in tournements\n\tif ( (g_gametype.integer == GT_TOURNAMENT )\n\t\t&& other->client->sess.sessionTeam == TEAM_FREE\n\t\t&& ent->client->sess.sessionTeam != TEAM_FREE ) {\n\t\treturn;\n\t}\n\n\ttrap_SendServerCommand( other-g_entities, va(\"%s \\\"%s%c%c%s\\\"\", \n\t\tmode == SAY_TEAM ? \"tchat\" : \"chat\",\n\t\tname, Q_COLOR_ESCAPE, color, message));\n}\n\n#define EC\t\t\"\\x19\"\n\nvoid G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) {\n\tint\t\t\tj;\n\tgentity_t\t*other;\n\tint\t\t\tcolor;\n\tchar\t\tname[64];\n\t// don't let text be too long for malicious reasons\n\tchar\t\ttext[MAX_SAY_TEXT];\n\tchar\t\tlocation[64];\n\n\tif ( g_gametype.integer < GT_TEAM && mode == SAY_TEAM ) {\n\t\tmode = SAY_ALL;\n\t}\n\n\tswitch ( mode ) {\n\tdefault:\n\tcase SAY_ALL:\n\t\tG_LogPrintf( \"say: %s: %s\\n\", ent->client->pers.netname, chatText );\n\t\tCom_sprintf (name, sizeof(name), \"%s%c%c\"EC\": \", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE );\n\t\tcolor = COLOR_GREEN;\n\t\tbreak;\n\tcase SAY_TEAM:\n\t\tG_LogPrintf( \"sayteam: %s: %s\\n\", ent->client->pers.netname, chatText );\n\t\tif (Team_GetLocationMsg(ent, location, sizeof(location)))\n\t\t\tCom_sprintf (name, sizeof(name), EC\"(%s%c%c\"EC\") (%s)\"EC\": \", \n\t\t\t\tent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE, location);\n\t\telse\n\t\t\tCom_sprintf (name, sizeof(name), EC\"(%s%c%c\"EC\")\"EC\": \", \n\t\t\t\tent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE );\n\t\tcolor = COLOR_CYAN;\n\t\tbreak;\n\tcase SAY_TELL:\n\t\tif (target && g_gametype.integer >= GT_TEAM &&\n\t\t\ttarget->client->sess.sessionTeam == ent->client->sess.sessionTeam &&\n\t\t\tTeam_GetLocationMsg(ent, location, sizeof(location)))\n\t\t\tCom_sprintf (name, sizeof(name), EC\"[%s%c%c\"EC\"] (%s)\"EC\": \", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE, location );\n\t\telse\n\t\t\tCom_sprintf (name, sizeof(name), EC\"[%s%c%c\"EC\"]\"EC\": \", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE );\n\t\tcolor = COLOR_MAGENTA;\n\t\tbreak;\n\t}\n\n\tQ_strncpyz( text, chatText, sizeof(text) );\n\n\tif ( target ) {\n\t\tG_SayTo( ent, target, mode, color, name, text );\n\t\treturn;\n\t}\n\n\t// echo the text to the console\n\tif ( g_dedicated.integer ) {\n\t\tG_Printf( \"%s%s\\n\", name, text);\n\t}\n\n\t// send it to all the apropriate clients\n\tfor (j = 0; j < level.maxclients; j++) {\n\t\tother = &g_entities[j];\n\t\tG_SayTo( ent, other, mode, color, name, text );\n\t}\n}\n\n\n/*\n==================\nCmd_Say_f\n==================\n*/\nstatic void Cmd_Say_f( gentity_t *ent, int mode, qboolean arg0 ) {\n\tchar\t\t*p;\n\n\tif ( trap_Argc () < 2 && !arg0 ) {\n\t\treturn;\n\t}\n\n\tif (arg0)\n\t{\n\t\tp = ConcatArgs( 0 );\n\t}\n\telse\n\t{\n\t\tp = ConcatArgs( 1 );\n\t}\n\n\tG_Say( ent, NULL, mode, p );\n}\n\n/*\n==================\nCmd_Tell_f\n==================\n*/\nstatic void Cmd_Tell_f( gentity_t *ent ) {\n\tint\t\t\ttargetNum;\n\tgentity_t\t*target;\n\tchar\t\t*p;\n\tchar\t\targ[MAX_TOKEN_CHARS];\n\n\tif ( trap_Argc () < 2 ) {\n\t\treturn;\n\t}\n\n\ttrap_Argv( 1, arg, sizeof( arg ) );\n\ttargetNum = atoi( arg );\n\tif ( targetNum < 0 || targetNum >= level.maxclients ) {\n\t\treturn;\n\t}\n\n\ttarget = &g_entities[targetNum];\n\tif ( !target || !target->inuse || !target->client ) {\n\t\treturn;\n\t}\n\n\tp = ConcatArgs( 2 );\n\n\tG_LogPrintf( \"tell: %s to %s: %s\\n\", ent->client->pers.netname, target->client->pers.netname, p );\n\tG_Say( ent, target, SAY_TELL, p );\n\t// don't tell to the player self if it was already directed to this player\n\t// also don't send the chat back to a bot\n\tif ( ent != target && !(ent->r.svFlags & SVF_BOT)) {\n\t\tG_Say( ent, ent, SAY_TELL, p );\n\t}\n}\n\n\nstatic void G_VoiceTo( gentity_t *ent, gentity_t *other, int mode, const char *id, qboolean voiceonly ) {\n\tint color;\n\tchar *cmd;\n\n\tif (!other) {\n\t\treturn;\n\t}\n\tif (!other->inuse) {\n\t\treturn;\n\t}\n\tif (!other->client) {\n\t\treturn;\n\t}\n\tif ( mode == SAY_TEAM && !OnSameTeam(ent, other) ) {\n\t\treturn;\n\t}\n\t// no chatting to players in tournements\n\tif ( (g_gametype.integer == GT_TOURNAMENT )) {\n\t\treturn;\n\t}\n\n\tif (mode == SAY_TEAM) {\n\t\tcolor = COLOR_CYAN;\n\t\tcmd = \"vtchat\";\n\t}\n\telse if (mode == SAY_TELL) {\n\t\tcolor = COLOR_MAGENTA;\n\t\tcmd = \"vtell\";\n\t}\n\telse {\n\t\tcolor = COLOR_GREEN;\n\t\tcmd = \"vchat\";\n\t}\n\n\ttrap_SendServerCommand( other-g_entities, va(\"%s %d %d %d %s\", cmd, voiceonly, ent->s.number, color, id));\n}\n\nvoid G_Voice( gentity_t *ent, gentity_t *target, int mode, const char *id, qboolean voiceonly ) {\n\tint\t\t\tj;\n\tgentity_t\t*other;\n\n\tif ( g_gametype.integer < GT_TEAM && mode == SAY_TEAM ) {\n\t\tmode = SAY_ALL;\n\t}\n\n\tif ( target ) {\n\t\tG_VoiceTo( ent, target, mode, id, voiceonly );\n\t\treturn;\n\t}\n\n\t// echo the text to the console\n\tif ( g_dedicated.integer ) {\n\t\tG_Printf( \"voice: %s %s\\n\", ent->client->pers.netname, id);\n\t}\n\n\t// send it to all the apropriate clients\n\tfor (j = 0; j < level.maxclients; j++) {\n\t\tother = &g_entities[j];\n\t\tG_VoiceTo( ent, other, mode, id, voiceonly );\n\t}\n}\n\n/*\n==================\nCmd_Voice_f\n==================\n*/\nstatic void Cmd_Voice_f( gentity_t *ent, int mode, qboolean arg0, qboolean voiceonly ) {\n\tchar\t\t*p;\n\n\tif ( trap_Argc () < 2 && !arg0 ) {\n\t\treturn;\n\t}\n\n\tif (arg0)\n\t{\n\t\tp = ConcatArgs( 0 );\n\t}\n\telse\n\t{\n\t\tp = ConcatArgs( 1 );\n\t}\n\n\tG_Voice( ent, NULL, mode, p, voiceonly );\n}\n\n/*\n==================\nCmd_VoiceTell_f\n==================\n*/\nstatic void Cmd_VoiceTell_f( gentity_t *ent, qboolean voiceonly ) {\n\tint\t\t\ttargetNum;\n\tgentity_t\t*target;\n\tchar\t\t*id;\n\tchar\t\targ[MAX_TOKEN_CHARS];\n\n\tif ( trap_Argc () < 2 ) {\n\t\treturn;\n\t}\n\n\ttrap_Argv( 1, arg, sizeof( arg ) );\n\ttargetNum = atoi( arg );\n\tif ( targetNum < 0 || targetNum >= level.maxclients ) {\n\t\treturn;\n\t}\n\n\ttarget = &g_entities[targetNum];\n\tif ( !target || !target->inuse || !target->client ) {\n\t\treturn;\n\t}\n\n\tid = ConcatArgs( 2 );\n\n\tG_LogPrintf( \"vtell: %s to %s: %s\\n\", ent->client->pers.netname, target->client->pers.netname, id );\n\tG_Voice( ent, target, SAY_TELL, id, voiceonly );\n\t// don't tell to the player self if it was already directed to this player\n\t// also don't send the chat back to a bot\n\tif ( ent != target && !(ent->r.svFlags & SVF_BOT)) {\n\t\tG_Voice( ent, ent, SAY_TELL, id, voiceonly );\n\t}\n}\n\n\n/*\n==================\nCmd_VoiceTaunt_f\n==================\n*/\nstatic void Cmd_VoiceTaunt_f( gentity_t *ent ) {\n\tgentity_t *who;\n\tint i;\n\n\tif (!ent->client) {\n\t\treturn;\n\t}\n\n\t// insult someone who just killed you\n\tif (ent->enemy && ent->enemy->client && ent->enemy->client->lastkilled_client == ent->s.number) {\n\t\t// i am a dead corpse\n\t\tif (!(ent->enemy->r.svFlags & SVF_BOT)) {\n\t\t\tG_Voice( ent, ent->enemy, SAY_TELL, VOICECHAT_DEATHINSULT, qfalse );\n\t\t}\n\t\tif (!(ent->r.svFlags & SVF_BOT)) {\n\t\t\tG_Voice( ent, ent,        SAY_TELL, VOICECHAT_DEATHINSULT, qfalse );\n\t\t}\n\t\tent->enemy = NULL;\n\t\treturn;\n\t}\n\t// insult someone you just killed\n\tif (ent->client->lastkilled_client >= 0 && ent->client->lastkilled_client != ent->s.number) {\n\t\twho = g_entities + ent->client->lastkilled_client;\n\t\tif (who->client) {\n\t\t\t// who is the person I just killed\n\t\t\tif (who->client->lasthurt_mod == MOD_GAUNTLET) {\n\t\t\t\tif (!(who->r.svFlags & SVF_BOT)) {\n\t\t\t\t\tG_Voice( ent, who, SAY_TELL, VOICECHAT_KILLGAUNTLET, qfalse );\t// and I killed them with a gauntlet\n\t\t\t\t}\n\t\t\t\tif (!(ent->r.svFlags & SVF_BOT)) {\n\t\t\t\t\tG_Voice( ent, ent, SAY_TELL, VOICECHAT_KILLGAUNTLET, qfalse );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (!(who->r.svFlags & SVF_BOT)) {\n\t\t\t\t\tG_Voice( ent, who, SAY_TELL, VOICECHAT_KILLINSULT, qfalse );\t// and I killed them with something else\n\t\t\t\t}\n\t\t\t\tif (!(ent->r.svFlags & SVF_BOT)) {\n\t\t\t\t\tG_Voice( ent, ent, SAY_TELL, VOICECHAT_KILLINSULT, qfalse );\n\t\t\t\t}\n\t\t\t}\n\t\t\tent->client->lastkilled_client = -1;\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif (g_gametype.integer >= GT_TEAM) {\n\t\t// praise a team mate who just got a reward\n\t\tfor(i = 0; i < MAX_CLIENTS; i++) {\n\t\t\twho = g_entities + i;\n\t\t\tif (who->client && who != ent && who->client->sess.sessionTeam == ent->client->sess.sessionTeam) {\n\t\t\t\tif (who->client->rewardTime > level.time) {\n\t\t\t\t\tif (!(who->r.svFlags & SVF_BOT)) {\n\t\t\t\t\t\tG_Voice( ent, who, SAY_TELL, VOICECHAT_PRAISE, qfalse );\n\t\t\t\t\t}\n\t\t\t\t\tif (!(ent->r.svFlags & SVF_BOT)) {\n\t\t\t\t\t\tG_Voice( ent, ent, SAY_TELL, VOICECHAT_PRAISE, qfalse );\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// just say something\n\tG_Voice( ent, NULL, SAY_ALL, VOICECHAT_TAUNT, qfalse );\n}\n\n\n\nstatic char\t*gc_orders[] = {\n\t\"hold your position\",\n\t\"hold this position\",\n\t\"come here\",\n\t\"cover me\",\n\t\"guard location\",\n\t\"search and destroy\",\n\t\"report\"\n};\n\nvoid Cmd_GameCommand_f( gentity_t *ent ) {\n\tint\t\tplayer;\n\tint\t\torder;\n\tchar\tstr[MAX_TOKEN_CHARS];\n\n\ttrap_Argv( 1, str, sizeof( str ) );\n\tplayer = atoi( str );\n\ttrap_Argv( 2, str, sizeof( str ) );\n\torder = atoi( str );\n\n\tif ( player < 0 || player >= MAX_CLIENTS ) {\n\t\treturn;\n\t}\n\tif ( order < 0 || order > sizeof(gc_orders)/sizeof(char *) ) {\n\t\treturn;\n\t}\n\tG_Say( ent, &g_entities[player], SAY_TELL, gc_orders[order] );\n\tG_Say( ent, ent, SAY_TELL, gc_orders[order] );\n}\n\n/*\n==================\nCmd_Where_f\n==================\n*/\nvoid Cmd_Where_f( gentity_t *ent ) {\n\ttrap_SendServerCommand( ent-g_entities, va(\"print \\\"%s\\n\\\"\", vtos( ent->s.origin ) ) );\n}\n\nstatic const char *gameNames[] = {\n\t\"Free For All\",\n\t\"Tournament\",\n\t\"Single Player\",\n\t\"Team Deathmatch\",\n\t\"Capture the Flag\",\n\t\"One Flag CTF\",\n\t\"Overload\",\n\t\"Harvester\"\n};\n\n/*\n==================\nCmd_CallVote_f\n==================\n*/\nvoid Cmd_CallVote_f( gentity_t *ent ) {\n\tint\t\ti;\n\tchar\targ1[MAX_STRING_TOKENS];\n\tchar\targ2[MAX_STRING_TOKENS];\n\n\tif ( !g_allowVote.integer ) {\n\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"Voting not allowed here.\\n\\\"\" );\n\t\treturn;\n\t}\n\n\tif ( level.voteTime ) {\n\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"A vote is already in progress.\\n\\\"\" );\n\t\treturn;\n\t}\n\tif ( ent->client->pers.voteCount >= MAX_VOTE_COUNT ) {\n\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"You have called the maximum number of votes.\\n\\\"\" );\n\t\treturn;\n\t}\n\tif ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {\n\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"Not allowed to call a vote as spectator.\\n\\\"\" );\n\t\treturn;\n\t}\n\n\t// make sure it is a valid command to vote on\n\ttrap_Argv( 1, arg1, sizeof( arg1 ) );\n\ttrap_Argv( 2, arg2, sizeof( arg2 ) );\n\n\tif( strchr( arg1, ';' ) || strchr( arg2, ';' ) ) {\n\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"Invalid vote string.\\n\\\"\" );\n\t\treturn;\n\t}\n\n\tif ( !Q_stricmp( arg1, \"map_restart\" ) ) {\n\t} else if ( !Q_stricmp( arg1, \"nextmap\" ) ) {\n\t} else if ( !Q_stricmp( arg1, \"map\" ) ) {\n\t} else if ( !Q_stricmp( arg1, \"g_gametype\" ) ) {\n\t} else if ( !Q_stricmp( arg1, \"kick\" ) ) {\n\t} else if ( !Q_stricmp( arg1, \"clientkick\" ) ) {\n\t} else if ( !Q_stricmp( arg1, \"g_doWarmup\" ) ) {\n\t} else if ( !Q_stricmp( arg1, \"timelimit\" ) ) {\n\t} else if ( !Q_stricmp( arg1, \"fraglimit\" ) ) {\n\t} else {\n\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"Invalid vote string.\\n\\\"\" );\n\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"Vote commands are: map_restart, nextmap, map <mapname>, g_gametype <n>, kick <player>, clientkick <clientnum>, g_doWarmup, timelimit <time>, fraglimit <frags>.\\n\\\"\" );\n\t\treturn;\n\t}\n\n\t// if there is still a vote to be executed\n\tif ( level.voteExecuteTime ) {\n\t\tlevel.voteExecuteTime = 0;\n\t\ttrap_SendConsoleCommand( EXEC_APPEND, va(\"%s\\n\", level.voteString ) );\n\t}\n\n\t// special case for g_gametype, check for bad values\n\tif ( !Q_stricmp( arg1, \"g_gametype\" ) ) {\n\t\ti = atoi( arg2 );\n\t\tif( i == GT_SINGLE_PLAYER || i < GT_FFA || i >= GT_MAX_GAME_TYPE) {\n\t\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"Invalid gametype.\\n\\\"\" );\n\t\t\treturn;\n\t\t}\n\n\t\tCom_sprintf( level.voteString, sizeof( level.voteString ), \"%s %d\", arg1, i );\n\t\tCom_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), \"%s %s\", arg1, gameNames[i] );\n\t} else if ( !Q_stricmp( arg1, \"map\" ) ) {\n\t\t// special case for map changes, we want to reset the nextmap setting\n\t\t// this allows a player to change maps, but not upset the map rotation\n\t\tchar\ts[MAX_STRING_CHARS];\n\n\t\ttrap_Cvar_VariableStringBuffer( \"nextmap\", s, sizeof(s) );\n\t\tif (*s) {\n\t\t\tCom_sprintf( level.voteString, sizeof( level.voteString ), \"%s %s; set nextmap \\\"%s\\\"\", arg1, arg2, s );\n\t\t} else {\n\t\t\tCom_sprintf( level.voteString, sizeof( level.voteString ), \"%s %s\", arg1, arg2 );\n\t\t}\n\t\tCom_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), \"%s\", level.voteString );\n\t} else if ( !Q_stricmp( arg1, \"nextmap\" ) ) {\n\t\tchar\ts[MAX_STRING_CHARS];\n\n\t\ttrap_Cvar_VariableStringBuffer( \"nextmap\", s, sizeof(s) );\n\t\tif (!*s) {\n\t\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"nextmap not set.\\n\\\"\" );\n\t\t\treturn;\n\t\t}\n\t\tCom_sprintf( level.voteString, sizeof( level.voteString ), \"vstr nextmap\");\n\t\tCom_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), \"%s\", level.voteString );\n\t} else {\n\t\tCom_sprintf( level.voteString, sizeof( level.voteString ), \"%s \\\"%s\\\"\", arg1, arg2 );\n\t\tCom_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), \"%s\", level.voteString );\n\t}\n\n\ttrap_SendServerCommand( -1, va(\"print \\\"%s called a vote.\\n\\\"\", ent->client->pers.netname ) );\n\n\t// start the voting, the caller autoamtically votes yes\n\tlevel.voteTime = level.time;\n\tlevel.voteYes = 1;\n\tlevel.voteNo = 0;\n\n\tfor ( i = 0 ; i < level.maxclients ; i++ ) {\n\t\tlevel.clients[i].ps.eFlags &= ~EF_VOTED;\n\t}\n\tent->client->ps.eFlags |= EF_VOTED;\n\n\ttrap_SetConfigstring( CS_VOTE_TIME, va(\"%i\", level.voteTime ) );\n\ttrap_SetConfigstring( CS_VOTE_STRING, level.voteDisplayString );\t\n\ttrap_SetConfigstring( CS_VOTE_YES, va(\"%i\", level.voteYes ) );\n\ttrap_SetConfigstring( CS_VOTE_NO, va(\"%i\", level.voteNo ) );\t\n}\n\n/*\n==================\nCmd_Vote_f\n==================\n*/\nvoid Cmd_Vote_f( gentity_t *ent ) {\n\tchar\t\tmsg[64];\n\n\tif ( !level.voteTime ) {\n\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"No vote in progress.\\n\\\"\" );\n\t\treturn;\n\t}\n\tif ( ent->client->ps.eFlags & EF_VOTED ) {\n\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"Vote already cast.\\n\\\"\" );\n\t\treturn;\n\t}\n\tif ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {\n\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"Not allowed to vote as spectator.\\n\\\"\" );\n\t\treturn;\n\t}\n\n\ttrap_SendServerCommand( ent-g_entities, \"print \\\"Vote cast.\\n\\\"\" );\n\n\tent->client->ps.eFlags |= EF_VOTED;\n\n\ttrap_Argv( 1, msg, sizeof( msg ) );\n\n\tif ( msg[0] == 'y' || msg[1] == 'Y' || msg[1] == '1' ) {\n\t\tlevel.voteYes++;\n\t\ttrap_SetConfigstring( CS_VOTE_YES, va(\"%i\", level.voteYes ) );\n\t} else {\n\t\tlevel.voteNo++;\n\t\ttrap_SetConfigstring( CS_VOTE_NO, va(\"%i\", level.voteNo ) );\t\n\t}\n\n\t// a majority will be determined in CheckVote, which will also account\n\t// for players entering or leaving\n}\n\n/*\n==================\nCmd_CallTeamVote_f\n==================\n*/\nvoid Cmd_CallTeamVote_f( gentity_t *ent ) {\n\tint\t\ti, team, cs_offset;\n\tchar\targ1[MAX_STRING_TOKENS];\n\tchar\targ2[MAX_STRING_TOKENS];\n\n\tteam = ent->client->sess.sessionTeam;\n\tif ( team == TEAM_RED )\n\t\tcs_offset = 0;\n\telse if ( team == TEAM_BLUE )\n\t\tcs_offset = 1;\n\telse\n\t\treturn;\n\n\tif ( !g_allowVote.integer ) {\n\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"Voting not allowed here.\\n\\\"\" );\n\t\treturn;\n\t}\n\n\tif ( level.teamVoteTime[cs_offset] ) {\n\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"A team vote is already in progress.\\n\\\"\" );\n\t\treturn;\n\t}\n\tif ( ent->client->pers.teamVoteCount >= MAX_VOTE_COUNT ) {\n\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"You have called the maximum number of team votes.\\n\\\"\" );\n\t\treturn;\n\t}\n\tif ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {\n\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"Not allowed to call a vote as spectator.\\n\\\"\" );\n\t\treturn;\n\t}\n\n\t// make sure it is a valid command to vote on\n\ttrap_Argv( 1, arg1, sizeof( arg1 ) );\n\targ2[0] = '\\0';\n\tfor ( i = 2; i < trap_Argc(); i++ ) {\n\t\tif (i > 2)\n\t\t\tstrcat(arg2, \" \");\n\t\ttrap_Argv( i, &arg2[strlen(arg2)], sizeof( arg2 ) - strlen(arg2) );\n\t}\n\n\tif( strchr( arg1, ';' ) || strchr( arg2, ';' ) ) {\n\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"Invalid vote string.\\n\\\"\" );\n\t\treturn;\n\t}\n\n\tif ( !Q_stricmp( arg1, \"leader\" ) ) {\n\t\tchar netname[MAX_NETNAME], leader[MAX_NETNAME];\n\n\t\tif ( !arg2[0] ) {\n\t\t\ti = ent->client->ps.clientNum;\n\t\t}\n\t\telse {\n\t\t\t// numeric values are just slot numbers\n\t\t\tfor (i = 0; i < 3; i++) {\n\t\t\t\tif ( !arg2[i] || arg2[i] < '0' || arg2[i] > '9' )\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( i >= 3 || !arg2[i]) {\n\t\t\t\ti = atoi( arg2 );\n\t\t\t\tif ( i < 0 || i >= level.maxclients ) {\n\t\t\t\t\ttrap_SendServerCommand( ent-g_entities, va(\"print \\\"Bad client slot: %i\\n\\\"\", i) );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( !g_entities[i].inuse ) {\n\t\t\t\t\ttrap_SendServerCommand( ent-g_entities, va(\"print \\\"Client %i is not active\\n\\\"\", i) );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tQ_strncpyz(leader, arg2, sizeof(leader));\n\t\t\t\tQ_CleanStr(leader);\n\t\t\t\tfor ( i = 0 ; i < level.maxclients ; i++ ) {\n\t\t\t\t\tif ( level.clients[i].pers.connected == CON_DISCONNECTED )\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif (level.clients[i].sess.sessionTeam != team)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tQ_strncpyz(netname, level.clients[i].pers.netname, sizeof(netname));\n\t\t\t\t\tQ_CleanStr(netname);\n\t\t\t\t\tif ( !Q_stricmp(netname, leader) ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( i >= level.maxclients ) {\n\t\t\t\t\ttrap_SendServerCommand( ent-g_entities, va(\"print \\\"%s is not a valid player on your team.\\n\\\"\", arg2) );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tCom_sprintf(arg2, sizeof(arg2), \"%d\", i);\n\t} else {\n\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"Invalid vote string.\\n\\\"\" );\n\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"Team vote commands are: leader <player>.\\n\\\"\" );\n\t\treturn;\n\t}\n\n\tCom_sprintf( level.teamVoteString[cs_offset], sizeof( level.teamVoteString[cs_offset] ), \"%s %s\", arg1, arg2 );\n\n\tfor ( i = 0 ; i < level.maxclients ; i++ ) {\n\t\tif ( level.clients[i].pers.connected == CON_DISCONNECTED )\n\t\t\tcontinue;\n\t\tif (level.clients[i].sess.sessionTeam == team)\n\t\t\ttrap_SendServerCommand( i, va(\"print \\\"%s called a team vote.\\n\\\"\", ent->client->pers.netname ) );\n\t}\n\n\t// start the voting, the caller autoamtically votes yes\n\tlevel.teamVoteTime[cs_offset] = level.time;\n\tlevel.teamVoteYes[cs_offset] = 1;\n\tlevel.teamVoteNo[cs_offset] = 0;\n\n\tfor ( i = 0 ; i < level.maxclients ; i++ ) {\n\t\tif (level.clients[i].sess.sessionTeam == team)\n\t\t\tlevel.clients[i].ps.eFlags &= ~EF_TEAMVOTED;\n\t}\n\tent->client->ps.eFlags |= EF_TEAMVOTED;\n\n\ttrap_SetConfigstring( CS_TEAMVOTE_TIME + cs_offset, va(\"%i\", level.teamVoteTime[cs_offset] ) );\n\ttrap_SetConfigstring( CS_TEAMVOTE_STRING + cs_offset, level.teamVoteString[cs_offset] );\n\ttrap_SetConfigstring( CS_TEAMVOTE_YES + cs_offset, va(\"%i\", level.teamVoteYes[cs_offset] ) );\n\ttrap_SetConfigstring( CS_TEAMVOTE_NO + cs_offset, va(\"%i\", level.teamVoteNo[cs_offset] ) );\n}\n\n/*\n==================\nCmd_TeamVote_f\n==================\n*/\nvoid Cmd_TeamVote_f( gentity_t *ent ) {\n\tint\t\t\tteam, cs_offset;\n\tchar\t\tmsg[64];\n\n\tteam = ent->client->sess.sessionTeam;\n\tif ( team == TEAM_RED )\n\t\tcs_offset = 0;\n\telse if ( team == TEAM_BLUE )\n\t\tcs_offset = 1;\n\telse\n\t\treturn;\n\n\tif ( !level.teamVoteTime[cs_offset] ) {\n\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"No team vote in progress.\\n\\\"\" );\n\t\treturn;\n\t}\n\tif ( ent->client->ps.eFlags & EF_TEAMVOTED ) {\n\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"Team vote already cast.\\n\\\"\" );\n\t\treturn;\n\t}\n\tif ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {\n\t\ttrap_SendServerCommand( ent-g_entities, \"print \\\"Not allowed to vote as spectator.\\n\\\"\" );\n\t\treturn;\n\t}\n\n\ttrap_SendServerCommand( ent-g_entities, \"print \\\"Team vote cast.\\n\\\"\" );\n\n\tent->client->ps.eFlags |= EF_TEAMVOTED;\n\n\ttrap_Argv( 1, msg, sizeof( msg ) );\n\n\tif ( msg[0] == 'y' || msg[1] == 'Y' || msg[1] == '1' ) {\n\t\tlevel.teamVoteYes[cs_offset]++;\n\t\ttrap_SetConfigstring( CS_TEAMVOTE_YES + cs_offset, va(\"%i\", level.teamVoteYes[cs_offset] ) );\n\t} else {\n\t\tlevel.teamVoteNo[cs_offset]++;\n\t\ttrap_SetConfigstring( CS_TEAMVOTE_NO + cs_offset, va(\"%i\", level.teamVoteNo[cs_offset] ) );\t\n\t}\n\n\t// a majority will be determined in TeamCheckVote, which will also account\n\t// for players entering or leaving\n}\n\n\n/*\n=================\nCmd_SetViewpos_f\n=================\n*/\nvoid Cmd_SetViewpos_f( gentity_t *ent ) {\n\tvec3_t\t\torigin, angles;\n\tchar\t\tbuffer[MAX_TOKEN_CHARS];\n\tint\t\t\ti;\n\n\tif ( !g_cheats.integer ) {\n\t\ttrap_SendServerCommand( ent-g_entities, va(\"print \\\"Cheats are not enabled on this server.\\n\\\"\"));\n\t\treturn;\n\t}\n\tif ( trap_Argc() != 5 ) {\n\t\ttrap_SendServerCommand( ent-g_entities, va(\"print \\\"usage: setviewpos x y z yaw\\n\\\"\"));\n\t\treturn;\n\t}\n\n\tVectorClear( angles );\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\ttrap_Argv( i + 1, buffer, sizeof( buffer ) );\n\t\torigin[i] = atof( buffer );\n\t}\n\n\ttrap_Argv( 4, buffer, sizeof( buffer ) );\n\tangles[YAW] = atof( buffer );\n\n\tTeleportPlayer( ent, origin, angles );\n}\n\n\n\n/*\n=================\nCmd_Stats_f\n=================\n*/\nvoid Cmd_Stats_f( gentity_t *ent ) {\n/*\n\tint max, n, i;\n\n\tmax = trap_AAS_PointReachabilityAreaIndex( NULL );\n\n\tn = 0;\n\tfor ( i = 0; i < max; i++ ) {\n\t\tif ( ent->client->areabits[i >> 3] & (1 << (i & 7)) )\n\t\t\tn++;\n\t}\n\n\t//trap_SendServerCommand( ent-g_entities, va(\"print \\\"visited %d of %d areas\\n\\\"\", n, max));\n\ttrap_SendServerCommand( ent-g_entities, va(\"print \\\"%d%% level coverage\\n\\\"\", n * 100 / max));\n*/\n}\n\n/*\n=================\nClientCommand\n=================\n*/\nvoid ClientCommand( int clientNum ) {\n\tgentity_t *ent;\n\tchar\tcmd[MAX_TOKEN_CHARS];\n\n\tent = g_entities + clientNum;\n\tif ( !ent->client ) {\n\t\treturn;\t\t// not fully in game yet\n\t}\n\n\n\ttrap_Argv( 0, cmd, sizeof( cmd ) );\n\n\tif (Q_stricmp (cmd, \"say\") == 0) {\n\t\tCmd_Say_f (ent, SAY_ALL, qfalse);\n\t\treturn;\n\t}\n\tif (Q_stricmp (cmd, \"say_team\") == 0) {\n\t\tCmd_Say_f (ent, SAY_TEAM, qfalse);\n\t\treturn;\n\t}\n\tif (Q_stricmp (cmd, \"tell\") == 0) {\n\t\tCmd_Tell_f ( ent );\n\t\treturn;\n\t}\n\tif (Q_stricmp (cmd, \"vsay\") == 0) {\n\t\tCmd_Voice_f (ent, SAY_ALL, qfalse, qfalse);\n\t\treturn;\n\t}\n\tif (Q_stricmp (cmd, \"vsay_team\") == 0) {\n\t\tCmd_Voice_f (ent, SAY_TEAM, qfalse, qfalse);\n\t\treturn;\n\t}\n\tif (Q_stricmp (cmd, \"vtell\") == 0) {\n\t\tCmd_VoiceTell_f ( ent, qfalse );\n\t\treturn;\n\t}\n\tif (Q_stricmp (cmd, \"vosay\") == 0) {\n\t\tCmd_Voice_f (ent, SAY_ALL, qfalse, qtrue);\n\t\treturn;\n\t}\n\tif (Q_stricmp (cmd, \"vosay_team\") == 0) {\n\t\tCmd_Voice_f (ent, SAY_TEAM, qfalse, qtrue);\n\t\treturn;\n\t}\n\tif (Q_stricmp (cmd, \"votell\") == 0) {\n\t\tCmd_VoiceTell_f ( ent, qtrue );\n\t\treturn;\n\t}\n\tif (Q_stricmp (cmd, \"vtaunt\") == 0) {\n\t\tCmd_VoiceTaunt_f ( ent );\n\t\treturn;\n\t}\n\tif (Q_stricmp (cmd, \"score\") == 0) {\n\t\tCmd_Score_f (ent);\n\t\treturn;\n\t}\n\n\t// ignore all other commands when at intermission\n\tif (level.intermissiontime) {\n\t\tCmd_Say_f (ent, qfalse, qtrue);\n\t\treturn;\n\t}\n\n\tif (Q_stricmp (cmd, \"give\") == 0)\n\t\tCmd_Give_f (ent);\n\telse if (Q_stricmp (cmd, \"god\") == 0)\n\t\tCmd_God_f (ent);\n\telse if (Q_stricmp (cmd, \"notarget\") == 0)\n\t\tCmd_Notarget_f (ent);\n\telse if (Q_stricmp (cmd, \"noclip\") == 0)\n\t\tCmd_Noclip_f (ent);\n\telse if (Q_stricmp (cmd, \"kill\") == 0)\n\t\tCmd_Kill_f (ent);\n\telse if (Q_stricmp (cmd, \"teamtask\") == 0)\n\t\tCmd_TeamTask_f (ent);\n\telse if (Q_stricmp (cmd, \"levelshot\") == 0)\n\t\tCmd_LevelShot_f (ent);\n\telse if (Q_stricmp (cmd, \"follow\") == 0)\n\t\tCmd_Follow_f (ent);\n\telse if (Q_stricmp (cmd, \"follownext\") == 0)\n\t\tCmd_FollowCycle_f (ent, 1);\n\telse if (Q_stricmp (cmd, \"followprev\") == 0)\n\t\tCmd_FollowCycle_f (ent, -1);\n\telse if (Q_stricmp (cmd, \"team\") == 0)\n\t\tCmd_Team_f (ent);\n\telse if (Q_stricmp (cmd, \"where\") == 0)\n\t\tCmd_Where_f (ent);\n\telse if (Q_stricmp (cmd, \"callvote\") == 0)\n\t\tCmd_CallVote_f (ent);\n\telse if (Q_stricmp (cmd, \"vote\") == 0)\n\t\tCmd_Vote_f (ent);\n\telse if (Q_stricmp (cmd, \"callteamvote\") == 0)\n\t\tCmd_CallTeamVote_f (ent);\n\telse if (Q_stricmp (cmd, \"teamvote\") == 0)\n\t\tCmd_TeamVote_f (ent);\n\telse if (Q_stricmp (cmd, \"gc\") == 0)\n\t\tCmd_GameCommand_f( ent );\n\telse if (Q_stricmp (cmd, \"setviewpos\") == 0)\n\t\tCmd_SetViewpos_f( ent );\n\telse if (Q_stricmp (cmd, \"stats\") == 0)\n\t\tCmd_Stats_f( ent );\n\telse\n\t\ttrap_SendServerCommand( clientNum, va(\"print \\\"unknown cmd %s\\n\\\"\", cmd ) );\n}\n"
  },
  {
    "path": "code/game/g_combat.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// g_combat.c\n\n#include \"g_local.h\"\n\n\n/*\n============\nScorePlum\n============\n*/\nvoid ScorePlum( gentity_t *ent, vec3_t origin, int score ) {\n\tgentity_t *plum;\n\n\tplum = G_TempEntity( origin, EV_SCOREPLUM );\n\t// only send this temp entity to a single client\n\tplum->r.svFlags |= SVF_SINGLECLIENT;\n\tplum->r.singleClient = ent->s.number;\n\t//\n\tplum->s.otherEntityNum = ent->s.number;\n\tplum->s.time = score;\n}\n\n/*\n============\nAddScore\n\nAdds score to both the client and his team\n============\n*/\nvoid AddScore( gentity_t *ent, vec3_t origin, int score ) {\n\tif ( !ent->client ) {\n\t\treturn;\n\t}\n\t// no scoring during pre-match warmup\n\tif ( level.warmupTime ) {\n\t\treturn;\n\t}\n\t// show score plum\n\tScorePlum(ent, origin, score);\n\t//\n\tent->client->ps.persistant[PERS_SCORE] += score;\n\tif ( g_gametype.integer == GT_TEAM )\n\t\tlevel.teamScores[ ent->client->ps.persistant[PERS_TEAM] ] += score;\n\tCalculateRanks();\n}\n\n/*\n=================\nTossClientItems\n\nToss the weapon and powerups for the killed player\n=================\n*/\nvoid TossClientItems( gentity_t *self ) {\n\tgitem_t\t\t*item;\n\tint\t\t\tweapon;\n\tfloat\t\tangle;\n\tint\t\t\ti;\n\tgentity_t\t*drop;\n\n\t// drop the weapon if not a gauntlet or machinegun\n\tweapon = self->s.weapon;\n\n\t// make a special check to see if they are changing to a new\n\t// weapon that isn't the mg or gauntlet.  Without this, a client\n\t// can pick up a weapon, be killed, and not drop the weapon because\n\t// their weapon change hasn't completed yet and they are still holding the MG.\n\tif ( weapon == WP_MACHINEGUN || weapon == WP_GRAPPLING_HOOK ) {\n\t\tif ( self->client->ps.weaponstate == WEAPON_DROPPING ) {\n\t\t\tweapon = self->client->pers.cmd.weapon;\n\t\t}\n\t\tif ( !( self->client->ps.stats[STAT_WEAPONS] & ( 1 << weapon ) ) ) {\n\t\t\tweapon = WP_NONE;\n\t\t}\n\t}\n\n\tif ( weapon > WP_MACHINEGUN && weapon != WP_GRAPPLING_HOOK && \n\t\tself->client->ps.ammo[ weapon ] ) {\n\t\t// find the item type for this weapon\n\t\titem = BG_FindItemForWeapon( weapon );\n\n\t\t// spawn the item\n\t\tDrop_Item( self, item, 0 );\n\t}\n\n\t// drop all the powerups if not in teamplay\n\tif ( g_gametype.integer != GT_TEAM ) {\n\t\tangle = 45;\n\t\tfor ( i = 1 ; i < PW_NUM_POWERUPS ; i++ ) {\n\t\t\tif ( self->client->ps.powerups[ i ] > level.time ) {\n\t\t\t\titem = BG_FindItemForPowerup( i );\n\t\t\t\tif ( !item ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tdrop = Drop_Item( self, item, angle );\n\t\t\t\t// decide how many seconds it has left\n\t\t\t\tdrop->count = ( self->client->ps.powerups[ i ] - level.time ) / 1000;\n\t\t\t\tif ( drop->count < 1 ) {\n\t\t\t\t\tdrop->count = 1;\n\t\t\t\t}\n\t\t\t\tangle += 45;\n\t\t\t}\n\t\t}\n\t}\n}\n\n#ifdef MISSIONPACK\n\n/*\n=================\nTossClientCubes\n=================\n*/\nextern gentity_t\t*neutralObelisk;\n\nvoid TossClientCubes( gentity_t *self ) {\n\tgitem_t\t\t*item;\n\tgentity_t\t*drop;\n\tvec3_t\t\tvelocity;\n\tvec3_t\t\tangles;\n\tvec3_t\t\torigin;\n\n\tself->client->ps.generic1 = 0;\n\n\t// this should never happen but we should never\n\t// get the server to crash due to skull being spawned in\n\tif (!G_EntitiesFree()) {\n\t\treturn;\n\t}\n\n\tif( self->client->sess.sessionTeam == TEAM_RED ) {\n\t\titem = BG_FindItem( \"Red Cube\" );\n\t}\n\telse {\n\t\titem = BG_FindItem( \"Blue Cube\" );\n\t}\n\n\tangles[YAW] = (float)(level.time % 360);\n\tangles[PITCH] = 0;\t// always forward\n\tangles[ROLL] = 0;\n\n\tAngleVectors( angles, velocity, NULL, NULL );\n\tVectorScale( velocity, 150, velocity );\n\tvelocity[2] += 200 + crandom() * 50;\n\n\tif( neutralObelisk ) {\n\t\tVectorCopy( neutralObelisk->s.pos.trBase, origin );\n\t\torigin[2] += 44;\n\t} else {\n\t\tVectorClear( origin ) ;\n\t}\n\n\tdrop = LaunchItem( item, origin, velocity );\n\n\tdrop->nextthink = level.time + g_cubeTimeout.integer * 1000;\n\tdrop->think = G_FreeEntity;\n\tdrop->spawnflags = self->client->sess.sessionTeam;\n}\n\n\n/*\n=================\nTossClientPersistantPowerups\n=================\n*/\nvoid TossClientPersistantPowerups( gentity_t *ent ) {\n\tgentity_t\t*powerup;\n\n\tif( !ent->client ) {\n\t\treturn;\n\t}\n\n\tif( !ent->client->persistantPowerup ) {\n\t\treturn;\n\t}\n\n\tpowerup = ent->client->persistantPowerup;\n\n\tpowerup->r.svFlags &= ~SVF_NOCLIENT;\n\tpowerup->s.eFlags &= ~EF_NODRAW;\n\tpowerup->r.contents = CONTENTS_TRIGGER;\n\ttrap_LinkEntity( powerup );\n\n\tent->client->ps.stats[STAT_PERSISTANT_POWERUP] = 0;\n\tent->client->persistantPowerup = NULL;\n}\n#endif\n\n\n/*\n==================\nLookAtKiller\n==================\n*/\nvoid LookAtKiller( gentity_t *self, gentity_t *inflictor, gentity_t *attacker ) {\n\tvec3_t\t\tdir;\n\tvec3_t\t\tangles;\n\n\tif ( attacker && attacker != self ) {\n\t\tVectorSubtract (attacker->s.pos.trBase, self->s.pos.trBase, dir);\n\t} else if ( inflictor && inflictor != self ) {\n\t\tVectorSubtract (inflictor->s.pos.trBase, self->s.pos.trBase, dir);\n\t} else {\n\t\tself->client->ps.stats[STAT_DEAD_YAW] = self->s.angles[YAW];\n\t\treturn;\n\t}\n\n\tself->client->ps.stats[STAT_DEAD_YAW] = vectoyaw ( dir );\n\n\tangles[YAW] = vectoyaw ( dir );\n\tangles[PITCH] = 0; \n\tangles[ROLL] = 0;\n}\n\n/*\n==================\nGibEntity\n==================\n*/\nvoid GibEntity( gentity_t *self, int killer ) {\n\tgentity_t *ent;\n\tint i;\n\n\t//if this entity still has kamikaze\n\tif (self->s.eFlags & EF_KAMIKAZE) {\n\t\t// check if there is a kamikaze timer around for this owner\n\t\tfor (i = 0; i < MAX_GENTITIES; i++) {\n\t\t\tent = &g_entities[i];\n\t\t\tif (!ent->inuse)\n\t\t\t\tcontinue;\n\t\t\tif (ent->activator != self)\n\t\t\t\tcontinue;\n\t\t\tif (strcmp(ent->classname, \"kamikaze timer\"))\n\t\t\t\tcontinue;\n\t\t\tG_FreeEntity(ent);\n\t\t\tbreak;\n\t\t}\n\t}\n\tG_AddEvent( self, EV_GIB_PLAYER, killer );\n\tself->takedamage = qfalse;\n\tself->s.eType = ET_INVISIBLE;\n\tself->r.contents = 0;\n}\n\n/*\n==================\nbody_die\n==================\n*/\nvoid body_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath ) {\n\tif ( self->health > GIB_HEALTH ) {\n\t\treturn;\n\t}\n\tif ( !g_blood.integer ) {\n\t\tself->health = GIB_HEALTH+1;\n\t\treturn;\n\t}\n\n\tGibEntity( self, 0 );\n}\n\n\n// these are just for logging, the client prints its own messages\nchar\t*modNames[] = {\n\t\"MOD_UNKNOWN\",\n\t\"MOD_SHOTGUN\",\n\t\"MOD_GAUNTLET\",\n\t\"MOD_MACHINEGUN\",\n\t\"MOD_GRENADE\",\n\t\"MOD_GRENADE_SPLASH\",\n\t\"MOD_ROCKET\",\n\t\"MOD_ROCKET_SPLASH\",\n\t\"MOD_PLASMA\",\n\t\"MOD_PLASMA_SPLASH\",\n\t\"MOD_RAILGUN\",\n\t\"MOD_LIGHTNING\",\n\t\"MOD_BFG\",\n\t\"MOD_BFG_SPLASH\",\n\t\"MOD_WATER\",\n\t\"MOD_SLIME\",\n\t\"MOD_LAVA\",\n\t\"MOD_CRUSH\",\n\t\"MOD_TELEFRAG\",\n\t\"MOD_FALLING\",\n\t\"MOD_SUICIDE\",\n\t\"MOD_TARGET_LASER\",\n\t\"MOD_TRIGGER_HURT\",\n#ifdef MISSIONPACK\n\t\"MOD_NAIL\",\n\t\"MOD_CHAINGUN\",\n\t\"MOD_PROXIMITY_MINE\",\n\t\"MOD_KAMIKAZE\",\n\t\"MOD_JUICED\",\n#endif\n\t\"MOD_GRAPPLE\"\n};\n\n#ifdef MISSIONPACK\n/*\n==================\nKamikaze_DeathActivate\n==================\n*/\nvoid Kamikaze_DeathActivate( gentity_t *ent ) {\n\tG_StartKamikaze(ent);\n\tG_FreeEntity(ent);\n}\n\n/*\n==================\nKamikaze_DeathTimer\n==================\n*/\nvoid Kamikaze_DeathTimer( gentity_t *self ) {\n\tgentity_t *ent;\n\n\tent = G_Spawn();\n\tent->classname = \"kamikaze timer\";\n\tVectorCopy(self->s.pos.trBase, ent->s.pos.trBase);\n\tent->r.svFlags |= SVF_NOCLIENT;\n\tent->think = Kamikaze_DeathActivate;\n\tent->nextthink = level.time + 5 * 1000;\n\n\tent->activator = self;\n}\n\n#endif\n\n/*\n==================\nCheckAlmostCapture\n==================\n*/\nvoid CheckAlmostCapture( gentity_t *self, gentity_t *attacker ) {\n\tgentity_t\t*ent;\n\tvec3_t\t\tdir;\n\tchar\t\t*classname;\n\n\t// if this player was carrying a flag\n\tif ( self->client->ps.powerups[PW_REDFLAG] ||\n\t\tself->client->ps.powerups[PW_BLUEFLAG] ||\n\t\tself->client->ps.powerups[PW_NEUTRALFLAG] ) {\n\t\t// get the goal flag this player should have been going for\n\t\tif ( g_gametype.integer == GT_CTF ) {\n\t\t\tif ( self->client->sess.sessionTeam == TEAM_BLUE ) {\n\t\t\t\tclassname = \"team_CTF_blueflag\";\n\t\t\t}\n\t\t\telse {\n\t\t\t\tclassname = \"team_CTF_redflag\";\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif ( self->client->sess.sessionTeam == TEAM_BLUE ) {\n\t\t\t\tclassname = \"team_CTF_redflag\";\n\t\t\t}\n\t\t\telse {\n\t\t\t\tclassname = \"team_CTF_blueflag\";\n\t\t\t}\n\t\t}\n\t\tent = NULL;\n\t\tdo\n\t\t{\n\t\t\tent = G_Find(ent, FOFS(classname), classname);\n\t\t} while (ent && (ent->flags & FL_DROPPED_ITEM));\n\t\t// if we found the destination flag and it's not picked up\n\t\tif (ent && !(ent->r.svFlags & SVF_NOCLIENT) ) {\n\t\t\t// if the player was *very* close\n\t\t\tVectorSubtract( self->client->ps.origin, ent->s.origin, dir );\n\t\t\tif ( VectorLength(dir) < 200 ) {\n\t\t\t\tself->client->ps.persistant[PERS_PLAYEREVENTS] ^= PLAYEREVENT_HOLYSHIT;\n\t\t\t\tif ( attacker->client ) {\n\t\t\t\t\tattacker->client->ps.persistant[PERS_PLAYEREVENTS] ^= PLAYEREVENT_HOLYSHIT;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n==================\nCheckAlmostScored\n==================\n*/\nvoid CheckAlmostScored( gentity_t *self, gentity_t *attacker ) {\n\tgentity_t\t*ent;\n\tvec3_t\t\tdir;\n\tchar\t\t*classname;\n\n\t// if the player was carrying cubes\n\tif ( self->client->ps.generic1 ) {\n\t\tif ( self->client->sess.sessionTeam == TEAM_BLUE ) {\n\t\t\tclassname = \"team_redobelisk\";\n\t\t}\n\t\telse {\n\t\t\tclassname = \"team_blueobelisk\";\n\t\t}\n\t\tent = G_Find(NULL, FOFS(classname), classname);\n\t\t// if we found the destination obelisk\n\t\tif ( ent ) {\n\t\t\t// if the player was *very* close\n\t\t\tVectorSubtract( self->client->ps.origin, ent->s.origin, dir );\n\t\t\tif ( VectorLength(dir) < 200 ) {\n\t\t\t\tself->client->ps.persistant[PERS_PLAYEREVENTS] ^= PLAYEREVENT_HOLYSHIT;\n\t\t\t\tif ( attacker->client ) {\n\t\t\t\t\tattacker->client->ps.persistant[PERS_PLAYEREVENTS] ^= PLAYEREVENT_HOLYSHIT;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n==================\nplayer_die\n==================\n*/\nvoid player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath ) {\n\tgentity_t\t*ent;\n\tint\t\t\tanim;\n\tint\t\t\tcontents;\n\tint\t\t\tkiller;\n\tint\t\t\ti;\n\tchar\t\t*killerName, *obit;\n\n\tif ( self->client->ps.pm_type == PM_DEAD ) {\n\t\treturn;\n\t}\n\n\tif ( level.intermissiontime ) {\n\t\treturn;\n\t}\n\n\t// check for an almost capture\n\tCheckAlmostCapture( self, attacker );\n\t// check for a player that almost brought in cubes\n\tCheckAlmostScored( self, attacker );\n\n\tif (self->client && self->client->hook) {\n\t\tWeapon_HookFree(self->client->hook);\n\t}\n#ifdef MISSIONPACK\n\tif ((self->client->ps.eFlags & EF_TICKING) && self->activator) {\n\t\tself->client->ps.eFlags &= ~EF_TICKING;\n\t\tself->activator->think = G_FreeEntity;\n\t\tself->activator->nextthink = level.time;\n\t}\n#endif\n\tself->client->ps.pm_type = PM_DEAD;\n\n\tif ( attacker ) {\n\t\tkiller = attacker->s.number;\n\t\tif ( attacker->client ) {\n\t\t\tkillerName = attacker->client->pers.netname;\n\t\t} else {\n\t\t\tkillerName = \"<non-client>\";\n\t\t}\n\t} else {\n\t\tkiller = ENTITYNUM_WORLD;\n\t\tkillerName = \"<world>\";\n\t}\n\n\tif ( killer < 0 || killer >= MAX_CLIENTS ) {\n\t\tkiller = ENTITYNUM_WORLD;\n\t\tkillerName = \"<world>\";\n\t}\n\n\tif ( meansOfDeath < 0 || meansOfDeath >= sizeof( modNames ) / sizeof( modNames[0] ) ) {\n\t\tobit = \"<bad obituary>\";\n\t} else {\n\t\tobit = modNames[ meansOfDeath ];\n\t}\n\n\tG_LogPrintf(\"Kill: %i %i %i: %s killed %s by %s\\n\", \n\t\tkiller, self->s.number, meansOfDeath, killerName, \n\t\tself->client->pers.netname, obit );\n\n\t// broadcast the death event to everyone\n\tent = G_TempEntity( self->r.currentOrigin, EV_OBITUARY );\n\tent->s.eventParm = meansOfDeath;\n\tent->s.otherEntityNum = self->s.number;\n\tent->s.otherEntityNum2 = killer;\n\tent->r.svFlags = SVF_BROADCAST;\t// send to everyone\n\n\tself->enemy = attacker;\n\n\tself->client->ps.persistant[PERS_KILLED]++;\n\n\tif (attacker && attacker->client) {\n\t\tattacker->client->lastkilled_client = self->s.number;\n\n\t\tif ( attacker == self || OnSameTeam (self, attacker ) ) {\n\t\t\tAddScore( attacker, self->r.currentOrigin, -1 );\n\t\t} else {\n\t\t\tAddScore( attacker, self->r.currentOrigin, 1 );\n\n\t\t\tif( meansOfDeath == MOD_GAUNTLET ) {\n\t\t\t\t\n\t\t\t\t// play humiliation on player\n\t\t\t\tattacker->client->ps.persistant[PERS_GAUNTLET_FRAG_COUNT]++;\n\n\t\t\t\t// add the sprite over the player's head\n\t\t\t\tattacker->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );\n\t\t\t\tattacker->client->ps.eFlags |= EF_AWARD_GAUNTLET;\n\t\t\t\tattacker->client->rewardTime = level.time + REWARD_SPRITE_TIME;\n\n\t\t\t\t// also play humiliation on target\n\t\t\t\tself->client->ps.persistant[PERS_PLAYEREVENTS] ^= PLAYEREVENT_GAUNTLETREWARD;\n\t\t\t}\n\n\t\t\t// check for two kills in a short amount of time\n\t\t\t// if this is close enough to the last kill, give a reward sound\n\t\t\tif ( level.time - attacker->client->lastKillTime < CARNAGE_REWARD_TIME ) {\n\t\t\t\t// play excellent on player\n\t\t\t\tattacker->client->ps.persistant[PERS_EXCELLENT_COUNT]++;\n\n\t\t\t\t// add the sprite over the player's head\n\t\t\t\tattacker->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );\n\t\t\t\tattacker->client->ps.eFlags |= EF_AWARD_EXCELLENT;\n\t\t\t\tattacker->client->rewardTime = level.time + REWARD_SPRITE_TIME;\n\t\t\t}\n\t\t\tattacker->client->lastKillTime = level.time;\n\n\t\t}\n\t} else {\n\t\tAddScore( self, self->r.currentOrigin, -1 );\n\t}\n\n\t// Add team bonuses\n\tTeam_FragBonuses(self, inflictor, attacker);\n\n\t// if I committed suicide, the flag does not fall, it returns.\n\tif (meansOfDeath == MOD_SUICIDE) {\n\t\tif ( self->client->ps.powerups[PW_NEUTRALFLAG] ) {\t\t// only happens in One Flag CTF\n\t\t\tTeam_ReturnFlag( TEAM_FREE );\n\t\t\tself->client->ps.powerups[PW_NEUTRALFLAG] = 0;\n\t\t}\n\t\telse if ( self->client->ps.powerups[PW_REDFLAG] ) {\t\t// only happens in standard CTF\n\t\t\tTeam_ReturnFlag( TEAM_RED );\n\t\t\tself->client->ps.powerups[PW_REDFLAG] = 0;\n\t\t}\n\t\telse if ( self->client->ps.powerups[PW_BLUEFLAG] ) {\t// only happens in standard CTF\n\t\t\tTeam_ReturnFlag( TEAM_BLUE );\n\t\t\tself->client->ps.powerups[PW_BLUEFLAG] = 0;\n\t\t}\n\t}\n\n\t// if client is in a nodrop area, don't drop anything (but return CTF flags!)\n\tcontents = trap_PointContents( self->r.currentOrigin, -1 );\n\tif ( !( contents & CONTENTS_NODROP )) {\n\t\tTossClientItems( self );\n\t}\n\telse {\n\t\tif ( self->client->ps.powerups[PW_NEUTRALFLAG] ) {\t\t// only happens in One Flag CTF\n\t\t\tTeam_ReturnFlag( TEAM_FREE );\n\t\t}\n\t\telse if ( self->client->ps.powerups[PW_REDFLAG] ) {\t\t// only happens in standard CTF\n\t\t\tTeam_ReturnFlag( TEAM_RED );\n\t\t}\n\t\telse if ( self->client->ps.powerups[PW_BLUEFLAG] ) {\t// only happens in standard CTF\n\t\t\tTeam_ReturnFlag( TEAM_BLUE );\n\t\t}\n\t}\n#ifdef MISSIONPACK\n\tTossClientPersistantPowerups( self );\n\tif( g_gametype.integer == GT_HARVESTER ) {\n\t\tTossClientCubes( self );\n\t}\n#endif\n\n\tCmd_Score_f( self );\t\t// show scores\n\t// send updated scores to any clients that are following this one,\n\t// or they would get stale scoreboards\n\tfor ( i = 0 ; i < level.maxclients ; i++ ) {\n\t\tgclient_t\t*client;\n\n\t\tclient = &level.clients[i];\n\t\tif ( client->pers.connected != CON_CONNECTED ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( client->sess.sessionTeam != TEAM_SPECTATOR ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( client->sess.spectatorClient == self->s.number ) {\n\t\t\tCmd_Score_f( g_entities + i );\n\t\t}\n\t}\n\n\tself->takedamage = qtrue;\t// can still be gibbed\n\n\tself->s.weapon = WP_NONE;\n\tself->s.powerups = 0;\n\tself->r.contents = CONTENTS_CORPSE;\n\n\tself->s.angles[0] = 0;\n\tself->s.angles[2] = 0;\n\tLookAtKiller (self, inflictor, attacker);\n\n\tVectorCopy( self->s.angles, self->client->ps.viewangles );\n\n\tself->s.loopSound = 0;\n\n\tself->r.maxs[2] = -8;\n\n\t// don't allow respawn until the death anim is done\n\t// g_forcerespawn may force spawning at some later time\n\tself->client->respawnTime = level.time + 1700;\n\n\t// remove powerups\n\tmemset( self->client->ps.powerups, 0, sizeof(self->client->ps.powerups) );\n\n\t// never gib in a nodrop\n\tif ( (self->health <= GIB_HEALTH && !(contents & CONTENTS_NODROP) && g_blood.integer) || meansOfDeath == MOD_SUICIDE) {\n\t\t// gib death\n\t\tGibEntity( self, killer );\n\t} else {\n\t\t// normal death\n\t\tstatic int i;\n\n\t\tswitch ( i ) {\n\t\tcase 0:\n\t\t\tanim = BOTH_DEATH1;\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\tanim = BOTH_DEATH2;\n\t\t\tbreak;\n\t\tcase 2:\n\t\tdefault:\n\t\t\tanim = BOTH_DEATH3;\n\t\t\tbreak;\n\t\t}\n\n\t\t// for the no-blood option, we need to prevent the health\n\t\t// from going to gib level\n\t\tif ( self->health <= GIB_HEALTH ) {\n\t\t\tself->health = GIB_HEALTH+1;\n\t\t}\n\n\t\tself->client->ps.legsAnim = \n\t\t\t( ( self->client->ps.legsAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim;\n\t\tself->client->ps.torsoAnim = \n\t\t\t( ( self->client->ps.torsoAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim;\n\n\t\tG_AddEvent( self, EV_DEATH1 + i, killer );\n\n\t\t// the body can still be gibbed\n\t\tself->die = body_die;\n\n\t\t// globally cycle through the different death animations\n\t\ti = ( i + 1 ) % 3;\n\n#ifdef MISSIONPACK\n\t\tif (self->s.eFlags & EF_KAMIKAZE) {\n\t\t\tKamikaze_DeathTimer( self );\n\t\t}\n#endif\n\t}\n\n\ttrap_LinkEntity (self);\n\n}\n\n\n/*\n================\nCheckArmor\n================\n*/\nint CheckArmor (gentity_t *ent, int damage, int dflags)\n{\n\tgclient_t\t*client;\n\tint\t\t\tsave;\n\tint\t\t\tcount;\n\n\tif (!damage)\n\t\treturn 0;\n\n\tclient = ent->client;\n\n\tif (!client)\n\t\treturn 0;\n\n\tif (dflags & DAMAGE_NO_ARMOR)\n\t\treturn 0;\n\n\t// armor\n\tcount = client->ps.stats[STAT_ARMOR];\n\tsave = ceil( damage * ARMOR_PROTECTION );\n\tif (save >= count)\n\t\tsave = count;\n\n\tif (!save)\n\t\treturn 0;\n\n\tclient->ps.stats[STAT_ARMOR] -= save;\n\n\treturn save;\n}\n\n/*\n================\nRaySphereIntersections\n================\n*/\nint RaySphereIntersections( vec3_t origin, float radius, vec3_t point, vec3_t dir, vec3_t intersections[2] ) {\n\tfloat b, c, d, t;\n\n\t//\t| origin - (point + t * dir) | = radius\n\t//\ta = dir[0]^2 + dir[1]^2 + dir[2]^2;\n\t//\tb = 2 * (dir[0] * (point[0] - origin[0]) + dir[1] * (point[1] - origin[1]) + dir[2] * (point[2] - origin[2]));\n\t//\tc = (point[0] - origin[0])^2 + (point[1] - origin[1])^2 + (point[2] - origin[2])^2 - radius^2;\n\n\t// normalize dir so a = 1\n\tVectorNormalize(dir);\n\tb = 2 * (dir[0] * (point[0] - origin[0]) + dir[1] * (point[1] - origin[1]) + dir[2] * (point[2] - origin[2]));\n\tc = (point[0] - origin[0]) * (point[0] - origin[0]) +\n\t\t(point[1] - origin[1]) * (point[1] - origin[1]) +\n\t\t(point[2] - origin[2]) * (point[2] - origin[2]) -\n\t\tradius * radius;\n\n\td = b * b - 4 * c;\n\tif (d > 0) {\n\t\tt = (- b + sqrt(d)) / 2;\n\t\tVectorMA(point, t, dir, intersections[0]);\n\t\tt = (- b - sqrt(d)) / 2;\n\t\tVectorMA(point, t, dir, intersections[1]);\n\t\treturn 2;\n\t}\n\telse if (d == 0) {\n\t\tt = (- b ) / 2;\n\t\tVectorMA(point, t, dir, intersections[0]);\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\n#ifdef MISSIONPACK\n/*\n================\nG_InvulnerabilityEffect\n================\n*/\nint G_InvulnerabilityEffect( gentity_t *targ, vec3_t dir, vec3_t point, vec3_t impactpoint, vec3_t bouncedir ) {\n\tgentity_t\t*impact;\n\tvec3_t\t\tintersections[2], vec;\n\tint\t\t\tn;\n\n\tif ( !targ->client ) {\n\t\treturn qfalse;\n\t}\n\tVectorCopy(dir, vec);\n\tVectorInverse(vec);\n\t// sphere model radius = 42 units\n\tn = RaySphereIntersections( targ->client->ps.origin, 42, point, vec, intersections);\n\tif (n > 0) {\n\t\timpact = G_TempEntity( targ->client->ps.origin, EV_INVUL_IMPACT );\n\t\tVectorSubtract(intersections[0], targ->client->ps.origin, vec);\n\t\tvectoangles(vec, impact->s.angles);\n\t\timpact->s.angles[0] += 90;\n\t\tif (impact->s.angles[0] > 360)\n\t\t\timpact->s.angles[0] -= 360;\n\t\tif ( impactpoint ) {\n\t\t\tVectorCopy( intersections[0], impactpoint );\n\t\t}\n\t\tif ( bouncedir ) {\n\t\t\tVectorCopy( vec, bouncedir );\n\t\t\tVectorNormalize( bouncedir );\n\t\t}\n\t\treturn qtrue;\n\t}\n\telse {\n\t\treturn qfalse;\n\t}\n}\n#endif\n/*\n============\nT_Damage\n\ntarg\t\tentity that is being damaged\ninflictor\tentity that is causing the damage\nattacker\tentity that caused the inflictor to damage targ\n\texample: targ=monster, inflictor=rocket, attacker=player\n\ndir\t\t\tdirection of the attack for knockback\npoint\t\tpoint at which the damage is being inflicted, used for headshots\ndamage\t\tamount of damage being inflicted\nknockback\tforce to be applied against targ as a result of the damage\n\ninflictor, attacker, dir, and point can be NULL for environmental effects\n\ndflags\t\tthese flags are used to control how T_Damage works\n\tDAMAGE_RADIUS\t\t\tdamage was indirect (from a nearby explosion)\n\tDAMAGE_NO_ARMOR\t\t\tarmor does not protect from this damage\n\tDAMAGE_NO_KNOCKBACK\t\tdo not affect velocity, just view angles\n\tDAMAGE_NO_PROTECTION\tkills godmode, armor, everything\n============\n*/\n\nvoid G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,\n\t\t\t   vec3_t dir, vec3_t point, int damage, int dflags, int mod ) {\n\tgclient_t\t*client;\n\tint\t\t\ttake;\n\tint\t\t\tsave;\n\tint\t\t\tasave;\n\tint\t\t\tknockback;\n\tint\t\t\tmax;\n#ifdef MISSIONPACK\n\tvec3_t\t\tbouncedir, impactpoint;\n#endif\n\n\tif (!targ->takedamage) {\n\t\treturn;\n\t}\n\n\t// the intermission has allready been qualified for, so don't\n\t// allow any extra scoring\n\tif ( level.intermissionQueued ) {\n\t\treturn;\n\t}\n#ifdef MISSIONPACK\n\tif ( targ->client && mod != MOD_JUICED) {\n\t\tif ( targ->client->invulnerabilityTime > level.time) {\n\t\t\tif ( dir && point ) {\n\t\t\t\tG_InvulnerabilityEffect( targ, dir, point, impactpoint, bouncedir );\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t}\n#endif\n\tif ( !inflictor ) {\n\t\tinflictor = &g_entities[ENTITYNUM_WORLD];\n\t}\n\tif ( !attacker ) {\n\t\tattacker = &g_entities[ENTITYNUM_WORLD];\n\t}\n\n\t// shootable doors / buttons don't actually have any health\n\tif ( targ->s.eType == ET_MOVER ) {\n\t\tif ( targ->use && targ->moverState == MOVER_POS1 ) {\n\t\t\ttarg->use( targ, inflictor, attacker );\n\t\t}\n\t\treturn;\n\t}\n#ifdef MISSIONPACK\n\tif( g_gametype.integer == GT_OBELISK && CheckObeliskAttack( targ, attacker ) ) {\n\t\treturn;\n\t}\n#endif\n\t// reduce damage by the attacker's handicap value\n\t// unless they are rocket jumping\n\tif ( attacker->client && attacker != targ ) {\n\t\tmax = attacker->client->ps.stats[STAT_MAX_HEALTH];\n#ifdef MISSIONPACK\n\t\tif( bg_itemlist[attacker->client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_GUARD ) {\n\t\t\tmax /= 2;\n\t\t}\n#endif\n\t\tdamage = damage * max / 100;\n\t}\n\n\tclient = targ->client;\n\n\tif ( client ) {\n\t\tif ( client->noclip ) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif ( !dir ) {\n\t\tdflags |= DAMAGE_NO_KNOCKBACK;\n\t} else {\n\t\tVectorNormalize(dir);\n\t}\n\n\tknockback = damage;\n\tif ( knockback > 200 ) {\n\t\tknockback = 200;\n\t}\n\tif ( targ->flags & FL_NO_KNOCKBACK ) {\n\t\tknockback = 0;\n\t}\n\tif ( dflags & DAMAGE_NO_KNOCKBACK ) {\n\t\tknockback = 0;\n\t}\n\n\t// figure momentum add, even if the damage won't be taken\n\tif ( knockback && targ->client ) {\n\t\tvec3_t\tkvel;\n\t\tfloat\tmass;\n\n\t\tmass = 200;\n\n\t\tVectorScale (dir, g_knockback.value * (float)knockback / mass, kvel);\n\t\tVectorAdd (targ->client->ps.velocity, kvel, targ->client->ps.velocity);\n\n\t\t// set the timer so that the other client can't cancel\n\t\t// out the movement immediately\n\t\tif ( !targ->client->ps.pm_time ) {\n\t\t\tint\t\tt;\n\n\t\t\tt = knockback * 2;\n\t\t\tif ( t < 50 ) {\n\t\t\t\tt = 50;\n\t\t\t}\n\t\t\tif ( t > 200 ) {\n\t\t\t\tt = 200;\n\t\t\t}\n\t\t\ttarg->client->ps.pm_time = t;\n\t\t\ttarg->client->ps.pm_flags |= PMF_TIME_KNOCKBACK;\n\t\t}\n\t}\n\n\t// check for completely getting out of the damage\n\tif ( !(dflags & DAMAGE_NO_PROTECTION) ) {\n\n\t\t// if TF_NO_FRIENDLY_FIRE is set, don't do damage to the target\n\t\t// if the attacker was on the same team\n#ifdef MISSIONPACK\n\t\tif ( mod != MOD_JUICED && targ != attacker && !(dflags & DAMAGE_NO_TEAM_PROTECTION) && OnSameTeam (targ, attacker)  ) {\n#else\t\n\t\tif ( targ != attacker && OnSameTeam (targ, attacker)  ) {\n#endif\n\t\t\tif ( !g_friendlyFire.integer ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n#ifdef MISSIONPACK\n\t\tif (mod == MOD_PROXIMITY_MINE) {\n\t\t\tif (inflictor && inflictor->parent && OnSameTeam(targ, inflictor->parent)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (targ == attacker) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n#endif\n\n\t\t// check for godmode\n\t\tif ( targ->flags & FL_GODMODE ) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// battlesuit protects from all radius damage (but takes knockback)\n\t// and protects 50% against all damage\n\tif ( client && client->ps.powerups[PW_BATTLESUIT] ) {\n\t\tG_AddEvent( targ, EV_POWERUP_BATTLESUIT, 0 );\n\t\tif ( ( dflags & DAMAGE_RADIUS ) || ( mod == MOD_FALLING ) ) {\n\t\t\treturn;\n\t\t}\n\t\tdamage *= 0.5;\n\t}\n\n\t// add to the attacker's hit counter (if the target isn't a general entity like a prox mine)\n\tif ( attacker->client && targ != attacker && targ->health > 0\n\t\t\t&& targ->s.eType != ET_MISSILE\n\t\t\t&& targ->s.eType != ET_GENERAL) {\n\t\tif ( OnSameTeam( targ, attacker ) ) {\n\t\t\tattacker->client->ps.persistant[PERS_HITS]--;\n\t\t} else {\n\t\t\tattacker->client->ps.persistant[PERS_HITS]++;\n\t\t}\n\t\tattacker->client->ps.persistant[PERS_ATTACKEE_ARMOR] = (targ->health<<8)|(client->ps.stats[STAT_ARMOR]);\n\t}\n\n\t// always give half damage if hurting self\n\t// calculated after knockback, so rocket jumping works\n\tif ( targ == attacker) {\n\t\tdamage *= 0.5;\n\t}\n\n\tif ( damage < 1 ) {\n\t\tdamage = 1;\n\t}\n\ttake = damage;\n\tsave = 0;\n\n\t// save some from armor\n\tasave = CheckArmor (targ, take, dflags);\n\ttake -= asave;\n\n\tif ( g_debugDamage.integer ) {\n\t\tG_Printf( \"%i: client:%i health:%i damage:%i armor:%i\\n\", level.time, targ->s.number,\n\t\t\ttarg->health, take, asave );\n\t}\n\n\t// add to the damage inflicted on a player this frame\n\t// the total will be turned into screen blends and view angle kicks\n\t// at the end of the frame\n\tif ( client ) {\n\t\tif ( attacker ) {\n\t\t\tclient->ps.persistant[PERS_ATTACKER] = attacker->s.number;\n\t\t} else {\n\t\t\tclient->ps.persistant[PERS_ATTACKER] = ENTITYNUM_WORLD;\n\t\t}\n\t\tclient->damage_armor += asave;\n\t\tclient->damage_blood += take;\n\t\tclient->damage_knockback += knockback;\n\t\tif ( dir ) {\n\t\t\tVectorCopy ( dir, client->damage_from );\n\t\t\tclient->damage_fromWorld = qfalse;\n\t\t} else {\n\t\t\tVectorCopy ( targ->r.currentOrigin, client->damage_from );\n\t\t\tclient->damage_fromWorld = qtrue;\n\t\t}\n\t}\n\n\t// See if it's the player hurting the emeny flag carrier\n#ifdef MISSIONPACK\n\tif( g_gametype.integer == GT_CTF || g_gametype.integer == GT_1FCTF ) {\n#else\t\n\tif( g_gametype.integer == GT_CTF) {\n#endif\n\t\tTeam_CheckHurtCarrier(targ, attacker);\n\t}\n\n\tif (targ->client) {\n\t\t// set the last client who damaged the target\n\t\ttarg->client->lasthurt_client = attacker->s.number;\n\t\ttarg->client->lasthurt_mod = mod;\n\t}\n\n\t// do the damage\n\tif (take) {\n\t\ttarg->health = targ->health - take;\n\t\tif ( targ->client ) {\n\t\t\ttarg->client->ps.stats[STAT_HEALTH] = targ->health;\n\t\t}\n\t\t\t\n\t\tif ( targ->health <= 0 ) {\n\t\t\tif ( client )\n\t\t\t\ttarg->flags |= FL_NO_KNOCKBACK;\n\n\t\t\tif (targ->health < -999)\n\t\t\t\ttarg->health = -999;\n\n\t\t\ttarg->enemy = attacker;\n\t\t\ttarg->die (targ, inflictor, attacker, take, mod);\n\t\t\treturn;\n\t\t} else if ( targ->pain ) {\n\t\t\ttarg->pain (targ, attacker, take);\n\t\t}\n\t}\n\n}\n\n\n/*\n============\nCanDamage\n\nReturns qtrue if the inflictor can directly damage the target.  Used for\nexplosions and melee attacks.\n============\n*/\nqboolean CanDamage (gentity_t *targ, vec3_t origin) {\n\tvec3_t\tdest;\n\ttrace_t\ttr;\n\tvec3_t\tmidpoint;\n\n\t// use the midpoint of the bounds instead of the origin, because\n\t// bmodels may have their origin is 0,0,0\n\tVectorAdd (targ->r.absmin, targ->r.absmax, midpoint);\n\tVectorScale (midpoint, 0.5, midpoint);\n\n\tVectorCopy (midpoint, dest);\n\ttrap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);\n\tif (tr.fraction == 1.0 || tr.entityNum == targ->s.number)\n\t\treturn qtrue;\n\n\t// this should probably check in the plane of projection, \n\t// rather than in world coordinate, and also include Z\n\tVectorCopy (midpoint, dest);\n\tdest[0] += 15.0;\n\tdest[1] += 15.0;\n\ttrap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);\n\tif (tr.fraction == 1.0)\n\t\treturn qtrue;\n\n\tVectorCopy (midpoint, dest);\n\tdest[0] += 15.0;\n\tdest[1] -= 15.0;\n\ttrap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);\n\tif (tr.fraction == 1.0)\n\t\treturn qtrue;\n\n\tVectorCopy (midpoint, dest);\n\tdest[0] -= 15.0;\n\tdest[1] += 15.0;\n\ttrap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);\n\tif (tr.fraction == 1.0)\n\t\treturn qtrue;\n\n\tVectorCopy (midpoint, dest);\n\tdest[0] -= 15.0;\n\tdest[1] -= 15.0;\n\ttrap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);\n\tif (tr.fraction == 1.0)\n\t\treturn qtrue;\n\n\n\treturn qfalse;\n}\n\n\n/*\n============\nG_RadiusDamage\n============\n*/\nqboolean G_RadiusDamage ( vec3_t origin, gentity_t *attacker, float damage, float radius,\n\t\t\t\t\t gentity_t *ignore, int mod) {\n\tfloat\t\tpoints, dist;\n\tgentity_t\t*ent;\n\tint\t\t\tentityList[MAX_GENTITIES];\n\tint\t\t\tnumListedEntities;\n\tvec3_t\t\tmins, maxs;\n\tvec3_t\t\tv;\n\tvec3_t\t\tdir;\n\tint\t\t\ti, e;\n\tqboolean\thitClient = qfalse;\n\n\tif ( radius < 1 ) {\n\t\tradius = 1;\n\t}\n\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tmins[i] = origin[i] - radius;\n\t\tmaxs[i] = origin[i] + radius;\n\t}\n\n\tnumListedEntities = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES );\n\n\tfor ( e = 0 ; e < numListedEntities ; e++ ) {\n\t\tent = &g_entities[entityList[ e ]];\n\n\t\tif (ent == ignore)\n\t\t\tcontinue;\n\t\tif (!ent->takedamage)\n\t\t\tcontinue;\n\n\t\t// find the distance from the edge of the bounding box\n\t\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\t\tif ( origin[i] < ent->r.absmin[i] ) {\n\t\t\t\tv[i] = ent->r.absmin[i] - origin[i];\n\t\t\t} else if ( origin[i] > ent->r.absmax[i] ) {\n\t\t\t\tv[i] = origin[i] - ent->r.absmax[i];\n\t\t\t} else {\n\t\t\t\tv[i] = 0;\n\t\t\t}\n\t\t}\n\n\t\tdist = VectorLength( v );\n\t\tif ( dist >= radius ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tpoints = damage * ( 1.0 - dist / radius );\n\n\t\tif( CanDamage (ent, origin) ) {\n\t\t\tif( LogAccuracyHit( ent, attacker ) ) {\n\t\t\t\thitClient = qtrue;\n\t\t\t}\n\t\t\tVectorSubtract (ent->r.currentOrigin, origin, dir);\n\t\t\t// push the center of mass higher than the origin so players\n\t\t\t// get knocked into the air more\n\t\t\tdir[2] += 24;\n\t\t\tG_Damage (ent, NULL, attacker, dir, origin, (int)points, DAMAGE_RADIUS, mod);\n\t\t}\n\t}\n\n\treturn hitClient;\n}\n"
  },
  {
    "path": "code/game/g_items.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#include \"g_local.h\"\n\n/*\n\n  Items are any object that a player can touch to gain some effect.\n\n  Pickup will return the number of seconds until they should respawn.\n\n  all items should pop when dropped in lava or slime\n\n  Respawnable items don't actually go away when picked up, they are\n  just made invisible and untouchable.  This allows them to ride\n  movers and respawn apropriately.\n*/\n\n\n#define\tRESPAWN_ARMOR\t\t25\n#define\tRESPAWN_HEALTH\t\t35\n#define\tRESPAWN_AMMO\t\t40\n#define\tRESPAWN_HOLDABLE\t60\n#define\tRESPAWN_MEGAHEALTH\t35//120\n#define\tRESPAWN_POWERUP\t\t120\n\n\n//======================================================================\n\nint Pickup_Powerup( gentity_t *ent, gentity_t *other ) {\n\tint\t\t\tquantity;\n\tint\t\t\ti;\n\tgclient_t\t*client;\n\n\tif ( !other->client->ps.powerups[ent->item->giTag] ) {\n\t\t// round timing to seconds to make multiple powerup timers\n\t\t// count in sync\n\t\tother->client->ps.powerups[ent->item->giTag] = \n\t\t\tlevel.time - ( level.time % 1000 );\n\t}\n\n\tif ( ent->count ) {\n\t\tquantity = ent->count;\n\t} else {\n\t\tquantity = ent->item->quantity;\n\t}\n\n\tother->client->ps.powerups[ent->item->giTag] += quantity * 1000;\n\n\t// give any nearby players a \"denied\" anti-reward\n\tfor ( i = 0 ; i < level.maxclients ; i++ ) {\n\t\tvec3_t\t\tdelta;\n\t\tfloat\t\tlen;\n\t\tvec3_t\t\tforward;\n\t\ttrace_t\t\ttr;\n\n\t\tclient = &level.clients[i];\n\t\tif ( client == other->client ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( client->pers.connected == CON_DISCONNECTED ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( client->ps.stats[STAT_HEALTH] <= 0 ) {\n\t\t\tcontinue;\n\t\t}\n\n    // if same team in team game, no sound\n    // cannot use OnSameTeam as it expects to g_entities, not clients\n  \tif ( g_gametype.integer >= GT_TEAM && other->client->sess.sessionTeam == client->sess.sessionTeam  ) {\n      continue;\n    }\n\n\t\t// if too far away, no sound\n\t\tVectorSubtract( ent->s.pos.trBase, client->ps.origin, delta );\n\t\tlen = VectorNormalize( delta );\n\t\tif ( len > 192 ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// if not facing, no sound\n\t\tAngleVectors( client->ps.viewangles, forward, NULL, NULL );\n\t\tif ( DotProduct( delta, forward ) < 0.4 ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// if not line of sight, no sound\n\t\ttrap_Trace( &tr, client->ps.origin, NULL, NULL, ent->s.pos.trBase, ENTITYNUM_NONE, CONTENTS_SOLID );\n\t\tif ( tr.fraction != 1.0 ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// anti-reward\n\t\tclient->ps.persistant[PERS_PLAYEREVENTS] ^= PLAYEREVENT_DENIEDREWARD;\n\t}\n\treturn RESPAWN_POWERUP;\n}\n\n//======================================================================\n\n#ifdef MISSIONPACK\nint Pickup_PersistantPowerup( gentity_t *ent, gentity_t *other ) {\n\tint\t\tclientNum;\n\tchar\tuserinfo[MAX_INFO_STRING];\n\tfloat\thandicap;\n\tint\t\tmax;\n\n\tother->client->ps.stats[STAT_PERSISTANT_POWERUP] = ent->item - bg_itemlist;\n\tother->client->persistantPowerup = ent;\n\n\tswitch( ent->item->giTag ) {\n\tcase PW_GUARD:\n\t\tclientNum = other->client->ps.clientNum;\n\t\ttrap_GetUserinfo( clientNum, userinfo, sizeof(userinfo) );\n\t\thandicap = atof( Info_ValueForKey( userinfo, \"handicap\" ) );\n\t\tif( handicap<=0.0f || handicap>100.0f) {\n\t\t\thandicap = 100.0f;\n\t\t}\n\t\tmax = (int)(2 *  handicap);\n\n\t\tother->health = max;\n\t\tother->client->ps.stats[STAT_HEALTH] = max;\n\t\tother->client->ps.stats[STAT_MAX_HEALTH] = max;\n\t\tother->client->ps.stats[STAT_ARMOR] = max;\n\t\tother->client->pers.maxHealth = max;\n\n\t\tbreak;\n\n\tcase PW_SCOUT:\n\t\tclientNum = other->client->ps.clientNum;\n\t\ttrap_GetUserinfo( clientNum, userinfo, sizeof(userinfo) );\n\t\thandicap = atof( Info_ValueForKey( userinfo, \"handicap\" ) );\n\t\tif( handicap<=0.0f || handicap>100.0f) {\n\t\t\thandicap = 100.0f;\n\t\t}\n\t\tother->client->pers.maxHealth = handicap;\n\t\tother->client->ps.stats[STAT_ARMOR] = 0;\n\t\tbreak;\n\n\tcase PW_DOUBLER:\n\t\tclientNum = other->client->ps.clientNum;\n\t\ttrap_GetUserinfo( clientNum, userinfo, sizeof(userinfo) );\n\t\thandicap = atof( Info_ValueForKey( userinfo, \"handicap\" ) );\n\t\tif( handicap<=0.0f || handicap>100.0f) {\n\t\t\thandicap = 100.0f;\n\t\t}\n\t\tother->client->pers.maxHealth = handicap;\n\t\tbreak;\n\tcase PW_AMMOREGEN:\n\t\tclientNum = other->client->ps.clientNum;\n\t\ttrap_GetUserinfo( clientNum, userinfo, sizeof(userinfo) );\n\t\thandicap = atof( Info_ValueForKey( userinfo, \"handicap\" ) );\n\t\tif( handicap<=0.0f || handicap>100.0f) {\n\t\t\thandicap = 100.0f;\n\t\t}\n\t\tother->client->pers.maxHealth = handicap;\n\t\tmemset(other->client->ammoTimes, 0, sizeof(other->client->ammoTimes));\n\t\tbreak;\n\tdefault:\n\t\tclientNum = other->client->ps.clientNum;\n\t\ttrap_GetUserinfo( clientNum, userinfo, sizeof(userinfo) );\n\t\thandicap = atof( Info_ValueForKey( userinfo, \"handicap\" ) );\n\t\tif( handicap<=0.0f || handicap>100.0f) {\n\t\t\thandicap = 100.0f;\n\t\t}\n\t\tother->client->pers.maxHealth = handicap;\n\t\tbreak;\n\t}\n\n\treturn -1;\n}\n\n//======================================================================\n#endif\n\nint Pickup_Holdable( gentity_t *ent, gentity_t *other ) {\n\n\tother->client->ps.stats[STAT_HOLDABLE_ITEM] = ent->item - bg_itemlist;\n\n\tif( ent->item->giTag == HI_KAMIKAZE ) {\n\t\tother->client->ps.eFlags |= EF_KAMIKAZE;\n\t}\n\n\treturn RESPAWN_HOLDABLE;\n}\n\n\n//======================================================================\n\nvoid Add_Ammo (gentity_t *ent, int weapon, int count)\n{\n\tent->client->ps.ammo[weapon] += count;\n\tif ( ent->client->ps.ammo[weapon] > 200 ) {\n\t\tent->client->ps.ammo[weapon] = 200;\n\t}\n}\n\nint Pickup_Ammo (gentity_t *ent, gentity_t *other)\n{\n\tint\t\tquantity;\n\n\tif ( ent->count ) {\n\t\tquantity = ent->count;\n\t} else {\n\t\tquantity = ent->item->quantity;\n\t}\n\n\tAdd_Ammo (other, ent->item->giTag, quantity);\n\n\treturn RESPAWN_AMMO;\n}\n\n//======================================================================\n\n\nint Pickup_Weapon (gentity_t *ent, gentity_t *other) {\n\tint\t\tquantity;\n\n\tif ( ent->count < 0 ) {\n\t\tquantity = 0; // None for you, sir!\n\t} else {\n\t\tif ( ent->count ) {\n\t\t\tquantity = ent->count;\n\t\t} else {\n\t\t\tquantity = ent->item->quantity;\n\t\t}\n\n\t\t// dropped items and teamplay weapons always have full ammo\n\t\tif ( ! (ent->flags & FL_DROPPED_ITEM) && g_gametype.integer != GT_TEAM ) {\n\t\t\t// respawning rules\n\t\t\t// drop the quantity if the already have over the minimum\n\t\t\tif ( other->client->ps.ammo[ ent->item->giTag ] < quantity ) {\n\t\t\t\tquantity = quantity - other->client->ps.ammo[ ent->item->giTag ];\n\t\t\t} else {\n\t\t\t\tquantity = 1;\t\t// only add a single shot\n\t\t\t}\n\t\t}\n\t}\n\n\t// add the weapon\n\tother->client->ps.stats[STAT_WEAPONS] |= ( 1 << ent->item->giTag );\n\n\tAdd_Ammo( other, ent->item->giTag, quantity );\n\n\tif (ent->item->giTag == WP_GRAPPLING_HOOK)\n\t\tother->client->ps.ammo[ent->item->giTag] = -1; // unlimited ammo\n\n\t// team deathmatch has slow weapon respawns\n\tif ( g_gametype.integer == GT_TEAM ) {\n\t\treturn g_weaponTeamRespawn.integer;\n\t}\n\n\treturn g_weaponRespawn.integer;\n}\n\n\n//======================================================================\n\nint Pickup_Health (gentity_t *ent, gentity_t *other) {\n\tint\t\t\tmax;\n\tint\t\t\tquantity;\n\n\t// small and mega healths will go over the max\n#ifdef MISSIONPACK\n\tif( other->client && bg_itemlist[other->client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_GUARD ) {\n\t\tmax = other->client->ps.stats[STAT_MAX_HEALTH];\n\t}\n\telse\n#endif\n\tif ( ent->item->quantity != 5 && ent->item->quantity != 100 ) {\n\t\tmax = other->client->ps.stats[STAT_MAX_HEALTH];\n\t} else {\n\t\tmax = other->client->ps.stats[STAT_MAX_HEALTH] * 2;\n\t}\n\n\tif ( ent->count ) {\n\t\tquantity = ent->count;\n\t} else {\n\t\tquantity = ent->item->quantity;\n\t}\n\n\tother->health += quantity;\n\n\tif (other->health > max ) {\n\t\tother->health = max;\n\t}\n\tother->client->ps.stats[STAT_HEALTH] = other->health;\n\n\tif ( ent->item->quantity == 100 ) {\t\t// mega health respawns slow\n\t\treturn RESPAWN_MEGAHEALTH;\n\t}\n\n\treturn RESPAWN_HEALTH;\n}\n\n//======================================================================\n\nint Pickup_Armor( gentity_t *ent, gentity_t *other ) {\n#ifdef MISSIONPACK\n\tint\t\tupperBound;\n\n\tother->client->ps.stats[STAT_ARMOR] += ent->item->quantity;\n\n\tif( other->client && bg_itemlist[other->client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_GUARD ) {\n\t\tupperBound = other->client->ps.stats[STAT_MAX_HEALTH];\n\t}\n\telse {\n\t\tupperBound = other->client->ps.stats[STAT_MAX_HEALTH] * 2;\n\t}\n\n\tif ( other->client->ps.stats[STAT_ARMOR] > upperBound ) {\n\t\tother->client->ps.stats[STAT_ARMOR] = upperBound;\n\t}\n#else\n\tother->client->ps.stats[STAT_ARMOR] += ent->item->quantity;\n\tif ( other->client->ps.stats[STAT_ARMOR] > other->client->ps.stats[STAT_MAX_HEALTH] * 2 ) {\n\t\tother->client->ps.stats[STAT_ARMOR] = other->client->ps.stats[STAT_MAX_HEALTH] * 2;\n\t}\n#endif\n\n\treturn RESPAWN_ARMOR;\n}\n\n//======================================================================\n\n/*\n===============\nRespawnItem\n===============\n*/\nvoid RespawnItem( gentity_t *ent ) {\n\t// randomly select from teamed entities\n\tif (ent->team) {\n\t\tgentity_t\t*master;\n\t\tint\tcount;\n\t\tint choice;\n\n\t\tif ( !ent->teammaster ) {\n\t\t\tG_Error( \"RespawnItem: bad teammaster\");\n\t\t}\n\t\tmaster = ent->teammaster;\n\n\t\tfor (count = 0, ent = master; ent; ent = ent->teamchain, count++)\n\t\t\t;\n\n\t\tchoice = rand() % count;\n\n\t\tfor (count = 0, ent = master; count < choice; ent = ent->teamchain, count++)\n\t\t\t;\n\t}\n\n\tent->r.contents = CONTENTS_TRIGGER;\n\tent->s.eFlags &= ~EF_NODRAW;\n\tent->r.svFlags &= ~SVF_NOCLIENT;\n\ttrap_LinkEntity (ent);\n\n\tif ( ent->item->giType == IT_POWERUP ) {\n\t\t// play powerup spawn sound to all clients\n\t\tgentity_t\t*te;\n\n\t\t// if the powerup respawn sound should Not be global\n\t\tif (ent->speed) {\n\t\t\tte = G_TempEntity( ent->s.pos.trBase, EV_GENERAL_SOUND );\n\t\t}\n\t\telse {\n\t\t\tte = G_TempEntity( ent->s.pos.trBase, EV_GLOBAL_SOUND );\n\t\t}\n\t\tte->s.eventParm = G_SoundIndex( \"sound/items/poweruprespawn.wav\" );\n\t\tte->r.svFlags |= SVF_BROADCAST;\n\t}\n\n\tif ( ent->item->giType == IT_HOLDABLE && ent->item->giTag == HI_KAMIKAZE ) {\n\t\t// play powerup spawn sound to all clients\n\t\tgentity_t\t*te;\n\n\t\t// if the powerup respawn sound should Not be global\n\t\tif (ent->speed) {\n\t\t\tte = G_TempEntity( ent->s.pos.trBase, EV_GENERAL_SOUND );\n\t\t}\n\t\telse {\n\t\t\tte = G_TempEntity( ent->s.pos.trBase, EV_GLOBAL_SOUND );\n\t\t}\n\t\tte->s.eventParm = G_SoundIndex( \"sound/items/kamikazerespawn.wav\" );\n\t\tte->r.svFlags |= SVF_BROADCAST;\n\t}\n\n\t// play the normal respawn sound only to nearby clients\n\tG_AddEvent( ent, EV_ITEM_RESPAWN, 0 );\n\n\tent->nextthink = 0;\n}\n\n\n/*\n===============\nTouch_Item\n===============\n*/\nvoid Touch_Item (gentity_t *ent, gentity_t *other, trace_t *trace) {\n\tint\t\t\trespawn;\n\tqboolean\tpredict;\n\n\tif (!other->client)\n\t\treturn;\n\tif (other->health < 1)\n\t\treturn;\t\t// dead people can't pickup\n\n\t// the same pickup rules are used for client side and server side\n\tif ( !BG_CanItemBeGrabbed( g_gametype.integer, &ent->s, &other->client->ps ) ) {\n\t\treturn;\n\t}\n\n\tG_LogPrintf( \"Item: %i %s\\n\", other->s.number, ent->item->classname );\n\n\tpredict = other->client->pers.predictItemPickup;\n\n\t// call the item-specific pickup function\n\tswitch( ent->item->giType ) {\n\tcase IT_WEAPON:\n\t\trespawn = Pickup_Weapon(ent, other);\n//\t\tpredict = qfalse;\n\t\tbreak;\n\tcase IT_AMMO:\n\t\trespawn = Pickup_Ammo(ent, other);\n//\t\tpredict = qfalse;\n\t\tbreak;\n\tcase IT_ARMOR:\n\t\trespawn = Pickup_Armor(ent, other);\n\t\tbreak;\n\tcase IT_HEALTH:\n\t\trespawn = Pickup_Health(ent, other);\n\t\tbreak;\n\tcase IT_POWERUP:\n\t\trespawn = Pickup_Powerup(ent, other);\n\t\tpredict = qfalse;\n\t\tbreak;\n#ifdef MISSIONPACK\n\tcase IT_PERSISTANT_POWERUP:\n\t\trespawn = Pickup_PersistantPowerup(ent, other);\n\t\tbreak;\n#endif\n\tcase IT_TEAM:\n\t\trespawn = Pickup_Team(ent, other);\n\t\tbreak;\n\tcase IT_HOLDABLE:\n\t\trespawn = Pickup_Holdable(ent, other);\n\t\tbreak;\n\tdefault:\n\t\treturn;\n\t}\n\n\tif ( !respawn ) {\n\t\treturn;\n\t}\n\n\t// play the normal pickup sound\n\tif (predict) {\n\t\tG_AddPredictableEvent( other, EV_ITEM_PICKUP, ent->s.modelindex );\n\t} else {\n\t\tG_AddEvent( other, EV_ITEM_PICKUP, ent->s.modelindex );\n\t}\n\n\t// powerup pickups are global broadcasts\n\tif ( ent->item->giType == IT_POWERUP || ent->item->giType == IT_TEAM) {\n\t\t// if we want the global sound to play\n\t\tif (!ent->speed) {\n\t\t\tgentity_t\t*te;\n\n\t\t\tte = G_TempEntity( ent->s.pos.trBase, EV_GLOBAL_ITEM_PICKUP );\n\t\t\tte->s.eventParm = ent->s.modelindex;\n\t\t\tte->r.svFlags |= SVF_BROADCAST;\n\t\t} else {\n\t\t\tgentity_t\t*te;\n\n\t\t\tte = G_TempEntity( ent->s.pos.trBase, EV_GLOBAL_ITEM_PICKUP );\n\t\t\tte->s.eventParm = ent->s.modelindex;\n\t\t\t// only send this temp entity to a single client\n\t\t\tte->r.svFlags |= SVF_SINGLECLIENT;\n\t\t\tte->r.singleClient = other->s.number;\n\t\t}\n\t}\n\n\t// fire item targets\n\tG_UseTargets (ent, other);\n\n\t// wait of -1 will not respawn\n\tif ( ent->wait == -1 ) {\n\t\tent->r.svFlags |= SVF_NOCLIENT;\n\t\tent->s.eFlags |= EF_NODRAW;\n\t\tent->r.contents = 0;\n\t\tent->unlinkAfterEvent = qtrue;\n\t\treturn;\n\t}\n\n\t// non zero wait overrides respawn time\n\tif ( ent->wait ) {\n\t\trespawn = ent->wait;\n\t}\n\n\t// random can be used to vary the respawn time\n\tif ( ent->random ) {\n\t\trespawn += crandom() * ent->random;\n\t\tif ( respawn < 1 ) {\n\t\t\trespawn = 1;\n\t\t}\n\t}\n\n\t// dropped items will not respawn\n\tif ( ent->flags & FL_DROPPED_ITEM ) {\n\t\tent->freeAfterEvent = qtrue;\n\t}\n\n\t// picked up items still stay around, they just don't\n\t// draw anything.  This allows respawnable items\n\t// to be placed on movers.\n\tent->r.svFlags |= SVF_NOCLIENT;\n\tent->s.eFlags |= EF_NODRAW;\n\tent->r.contents = 0;\n\n\t// ZOID\n\t// A negative respawn times means to never respawn this item (but don't \n\t// delete it).  This is used by items that are respawned by third party \n\t// events such as ctf flags\n\tif ( respawn <= 0 ) {\n\t\tent->nextthink = 0;\n\t\tent->think = 0;\n\t} else {\n\t\tent->nextthink = level.time + respawn * 1000;\n\t\tent->think = RespawnItem;\n\t}\n\ttrap_LinkEntity( ent );\n}\n\n\n//======================================================================\n\n/*\n================\nLaunchItem\n\nSpawns an item and tosses it forward\n================\n*/\ngentity_t *LaunchItem( gitem_t *item, vec3_t origin, vec3_t velocity ) {\n\tgentity_t\t*dropped;\n\n\tdropped = G_Spawn();\n\n\tdropped->s.eType = ET_ITEM;\n\tdropped->s.modelindex = item - bg_itemlist;\t// store item number in modelindex\n\tdropped->s.modelindex2 = 1; // This is non-zero is it's a dropped item\n\n\tdropped->classname = item->classname;\n\tdropped->item = item;\n\tVectorSet (dropped->r.mins, -ITEM_RADIUS, -ITEM_RADIUS, -ITEM_RADIUS);\n\tVectorSet (dropped->r.maxs, ITEM_RADIUS, ITEM_RADIUS, ITEM_RADIUS);\n\tdropped->r.contents = CONTENTS_TRIGGER;\n\n\tdropped->touch = Touch_Item;\n\n\tG_SetOrigin( dropped, origin );\n\tdropped->s.pos.trType = TR_GRAVITY;\n\tdropped->s.pos.trTime = level.time;\n\tVectorCopy( velocity, dropped->s.pos.trDelta );\n\n\tdropped->s.eFlags |= EF_BOUNCE_HALF;\n#ifdef MISSIONPACK\n\tif ((g_gametype.integer == GT_CTF || g_gametype.integer == GT_1FCTF)\t\t\t&& item->giType == IT_TEAM) { // Special case for CTF flags\n#else\n\tif (g_gametype.integer == GT_CTF && item->giType == IT_TEAM) { // Special case for CTF flags\n#endif\n\t\tdropped->think = Team_DroppedFlagThink;\n\t\tdropped->nextthink = level.time + 30000;\n\t\tTeam_CheckDroppedItem( dropped );\n\t} else { // auto-remove after 30 seconds\n\t\tdropped->think = G_FreeEntity;\n\t\tdropped->nextthink = level.time + 30000;\n\t}\n\n\tdropped->flags = FL_DROPPED_ITEM;\n\n\ttrap_LinkEntity (dropped);\n\n\treturn dropped;\n}\n\n/*\n================\nDrop_Item\n\nSpawns an item and tosses it forward\n================\n*/\ngentity_t *Drop_Item( gentity_t *ent, gitem_t *item, float angle ) {\n\tvec3_t\tvelocity;\n\tvec3_t\tangles;\n\n\tVectorCopy( ent->s.apos.trBase, angles );\n\tangles[YAW] += angle;\n\tangles[PITCH] = 0;\t// always forward\n\n\tAngleVectors( angles, velocity, NULL, NULL );\n\tVectorScale( velocity, 150, velocity );\n\tvelocity[2] += 200 + crandom() * 50;\n\t\n\treturn LaunchItem( item, ent->s.pos.trBase, velocity );\n}\n\n\n/*\n================\nUse_Item\n\nRespawn the item\n================\n*/\nvoid Use_Item( gentity_t *ent, gentity_t *other, gentity_t *activator ) {\n\tRespawnItem( ent );\n}\n\n//======================================================================\n\n/*\n================\nFinishSpawningItem\n\nTraces down to find where an item should rest, instead of letting them\nfree fall from their spawn points\n================\n*/\nvoid FinishSpawningItem( gentity_t *ent ) {\n\ttrace_t\t\ttr;\n\tvec3_t\t\tdest;\n\n\tVectorSet( ent->r.mins, -ITEM_RADIUS, -ITEM_RADIUS, -ITEM_RADIUS );\n\tVectorSet( ent->r.maxs, ITEM_RADIUS, ITEM_RADIUS, ITEM_RADIUS );\n\n\tent->s.eType = ET_ITEM;\n\tent->s.modelindex = ent->item - bg_itemlist;\t\t// store item number in modelindex\n\tent->s.modelindex2 = 0; // zero indicates this isn't a dropped item\n\n\tent->r.contents = CONTENTS_TRIGGER;\n\tent->touch = Touch_Item;\n\t// useing an item causes it to respawn\n\tent->use = Use_Item;\n\n\tif ( ent->spawnflags & 1 ) {\n\t\t// suspended\n\t\tG_SetOrigin( ent, ent->s.origin );\n\t} else {\n\t\t// drop to floor\n\t\tVectorSet( dest, ent->s.origin[0], ent->s.origin[1], ent->s.origin[2] - 4096 );\n\t\ttrap_Trace( &tr, ent->s.origin, ent->r.mins, ent->r.maxs, dest, ent->s.number, MASK_SOLID );\n\t\tif ( tr.startsolid ) {\n\t\t\tG_Printf (\"FinishSpawningItem: %s startsolid at %s\\n\", ent->classname, vtos(ent->s.origin));\n\t\t\tG_FreeEntity( ent );\n\t\t\treturn;\n\t\t}\n\n\t\t// allow to ride movers\n\t\tent->s.groundEntityNum = tr.entityNum;\n\n\t\tG_SetOrigin( ent, tr.endpos );\n\t}\n\n\t// team slaves and targeted items aren't present at start\n\tif ( ( ent->flags & FL_TEAMSLAVE ) || ent->targetname ) {\n\t\tent->s.eFlags |= EF_NODRAW;\n\t\tent->r.contents = 0;\n\t\treturn;\n\t}\n\n\t// powerups don't spawn in for a while\n\tif ( ent->item->giType == IT_POWERUP ) {\n\t\tfloat\trespawn;\n\n\t\trespawn = 45 + crandom() * 15;\n\t\tent->s.eFlags |= EF_NODRAW;\n\t\tent->r.contents = 0;\n\t\tent->nextthink = level.time + respawn * 1000;\n\t\tent->think = RespawnItem;\n\t\treturn;\n\t}\n\n\n\ttrap_LinkEntity (ent);\n}\n\n\nqboolean\titemRegistered[MAX_ITEMS];\n\n/*\n==================\nG_CheckTeamItems\n==================\n*/\nvoid G_CheckTeamItems( void ) {\n\n\t// Set up team stuff\n\tTeam_InitGame();\n\n\tif( g_gametype.integer == GT_CTF ) {\n\t\tgitem_t\t*item;\n\n\t\t// check for the two flags\n\t\titem = BG_FindItem( \"Red Flag\" );\n\t\tif ( !item || !itemRegistered[ item - bg_itemlist ] ) {\n\t\t\tG_Printf( S_COLOR_YELLOW \"WARNING: No team_CTF_redflag in map\" );\n\t\t}\n\t\titem = BG_FindItem( \"Blue Flag\" );\n\t\tif ( !item || !itemRegistered[ item - bg_itemlist ] ) {\n\t\t\tG_Printf( S_COLOR_YELLOW \"WARNING: No team_CTF_blueflag in map\" );\n\t\t}\n\t}\n#ifdef MISSIONPACK\n\tif( g_gametype.integer == GT_1FCTF ) {\n\t\tgitem_t\t*item;\n\n\t\t// check for all three flags\n\t\titem = BG_FindItem( \"Red Flag\" );\n\t\tif ( !item || !itemRegistered[ item - bg_itemlist ] ) {\n\t\t\tG_Printf( S_COLOR_YELLOW \"WARNING: No team_CTF_redflag in map\" );\n\t\t}\n\t\titem = BG_FindItem( \"Blue Flag\" );\n\t\tif ( !item || !itemRegistered[ item - bg_itemlist ] ) {\n\t\t\tG_Printf( S_COLOR_YELLOW \"WARNING: No team_CTF_blueflag in map\" );\n\t\t}\n\t\titem = BG_FindItem( \"Neutral Flag\" );\n\t\tif ( !item || !itemRegistered[ item - bg_itemlist ] ) {\n\t\t\tG_Printf( S_COLOR_YELLOW \"WARNING: No team_CTF_neutralflag in map\" );\n\t\t}\n\t}\n\n\tif( g_gametype.integer == GT_OBELISK ) {\n\t\tgentity_t\t*ent;\n\n\t\t// check for the two obelisks\n\t\tent = NULL;\n\t\tent = G_Find( ent, FOFS(classname), \"team_redobelisk\" );\n\t\tif( !ent ) {\n\t\t\tG_Printf( S_COLOR_YELLOW \"WARNING: No team_redobelisk in map\" );\n\t\t}\n\n\t\tent = NULL;\n\t\tent = G_Find( ent, FOFS(classname), \"team_blueobelisk\" );\n\t\tif( !ent ) {\n\t\t\tG_Printf( S_COLOR_YELLOW \"WARNING: No team_blueobelisk in map\" );\n\t\t}\n\t}\n\n\tif( g_gametype.integer == GT_HARVESTER ) {\n\t\tgentity_t\t*ent;\n\n\t\t// check for all three obelisks\n\t\tent = NULL;\n\t\tent = G_Find( ent, FOFS(classname), \"team_redobelisk\" );\n\t\tif( !ent ) {\n\t\t\tG_Printf( S_COLOR_YELLOW \"WARNING: No team_redobelisk in map\" );\n\t\t}\n\n\t\tent = NULL;\n\t\tent = G_Find( ent, FOFS(classname), \"team_blueobelisk\" );\n\t\tif( !ent ) {\n\t\t\tG_Printf( S_COLOR_YELLOW \"WARNING: No team_blueobelisk in map\" );\n\t\t}\n\n\t\tent = NULL;\n\t\tent = G_Find( ent, FOFS(classname), \"team_neutralobelisk\" );\n\t\tif( !ent ) {\n\t\t\tG_Printf( S_COLOR_YELLOW \"WARNING: No team_neutralobelisk in map\" );\n\t\t}\n\t}\n#endif\n}\n\n/*\n==============\nClearRegisteredItems\n==============\n*/\nvoid ClearRegisteredItems( void ) {\n\tmemset( itemRegistered, 0, sizeof( itemRegistered ) );\n\n\t// players always start with the base weapon\n\tRegisterItem( BG_FindItemForWeapon( WP_MACHINEGUN ) );\n\tRegisterItem( BG_FindItemForWeapon( WP_GAUNTLET ) );\n#ifdef MISSIONPACK\n\tif( g_gametype.integer == GT_HARVESTER ) {\n\t\tRegisterItem( BG_FindItem( \"Red Cube\" ) );\n\t\tRegisterItem( BG_FindItem( \"Blue Cube\" ) );\n\t}\n#endif\n}\n\n/*\n===============\nRegisterItem\n\nThe item will be added to the precache list\n===============\n*/\nvoid RegisterItem( gitem_t *item ) {\n\tif ( !item ) {\n\t\tG_Error( \"RegisterItem: NULL\" );\n\t}\n\titemRegistered[ item - bg_itemlist ] = qtrue;\n}\n\n\n/*\n===============\nSaveRegisteredItems\n\nWrite the needed items to a config string\nso the client will know which ones to precache\n===============\n*/\nvoid SaveRegisteredItems( void ) {\n\tchar\tstring[MAX_ITEMS+1];\n\tint\t\ti;\n\tint\t\tcount;\n\n\tcount = 0;\n\tfor ( i = 0 ; i < bg_numItems ; i++ ) {\n\t\tif ( itemRegistered[i] ) {\n\t\t\tcount++;\n\t\t\tstring[i] = '1';\n\t\t} else {\n\t\t\tstring[i] = '0';\n\t\t}\n\t}\n\tstring[ bg_numItems ] = 0;\n\n\tG_Printf( \"%i items registered\\n\", count );\n\ttrap_SetConfigstring(CS_ITEMS, string);\n}\n\n/*\n============\nG_ItemDisabled\n============\n*/\nint G_ItemDisabled( gitem_t *item ) {\n\n\tchar name[128];\n\n\tCom_sprintf(name, sizeof(name), \"disable_%s\", item->classname);\n\treturn trap_Cvar_VariableIntegerValue( name );\n}\n\n/*\n============\nG_SpawnItem\n\nSets the clipping size and plants the object on the floor.\n\nItems can't be immediately dropped to floor, because they might\nbe on an entity that hasn't spawned yet.\n============\n*/\nvoid G_SpawnItem (gentity_t *ent, gitem_t *item) {\n\tG_SpawnFloat( \"random\", \"0\", &ent->random );\n\tG_SpawnFloat( \"wait\", \"0\", &ent->wait );\n\n\tRegisterItem( item );\n\tif ( G_ItemDisabled(item) )\n\t\treturn;\n\n\tent->item = item;\n\t// some movers spawn on the second frame, so delay item\n\t// spawns until the third frame so they can ride trains\n\tent->nextthink = level.time + FRAMETIME * 2;\n\tent->think = FinishSpawningItem;\n\n\tent->physicsBounce = 0.50;\t\t// items are bouncy\n\n\tif ( item->giType == IT_POWERUP ) {\n\t\tG_SoundIndex( \"sound/items/poweruprespawn.wav\" );\n\t\tG_SpawnFloat( \"noglobalsound\", \"0\", &ent->speed);\n\t}\n\n#ifdef MISSIONPACK\n\tif ( item->giType == IT_PERSISTANT_POWERUP ) {\n\t\tent->s.generic1 = ent->spawnflags;\n\t}\n#endif\n}\n\n\n/*\n================\nG_BounceItem\n\n================\n*/\nvoid G_BounceItem( gentity_t *ent, trace_t *trace ) {\n\tvec3_t\tvelocity;\n\tfloat\tdot;\n\tint\t\thitTime;\n\n\t// reflect the velocity on the trace plane\n\thitTime = level.previousTime + ( level.time - level.previousTime ) * trace->fraction;\n\tBG_EvaluateTrajectoryDelta( &ent->s.pos, hitTime, velocity );\n\tdot = DotProduct( velocity, trace->plane.normal );\n\tVectorMA( velocity, -2*dot, trace->plane.normal, ent->s.pos.trDelta );\n\n\t// cut the velocity to keep from bouncing forever\n\tVectorScale( ent->s.pos.trDelta, ent->physicsBounce, ent->s.pos.trDelta );\n\n\t// check for stop\n\tif ( trace->plane.normal[2] > 0 && ent->s.pos.trDelta[2] < 40 ) {\n\t\ttrace->endpos[2] += 1.0;\t// make sure it is off ground\n\t\tSnapVector( trace->endpos );\n\t\tG_SetOrigin( ent, trace->endpos );\n\t\tent->s.groundEntityNum = trace->entityNum;\n\t\treturn;\n\t}\n\n\tVectorAdd( ent->r.currentOrigin, trace->plane.normal, ent->r.currentOrigin);\n\tVectorCopy( ent->r.currentOrigin, ent->s.pos.trBase );\n\tent->s.pos.trTime = level.time;\n}\n\n\n/*\n================\nG_RunItem\n\n================\n*/\nvoid G_RunItem( gentity_t *ent ) {\n\tvec3_t\t\torigin;\n\ttrace_t\t\ttr;\n\tint\t\t\tcontents;\n\tint\t\t\tmask;\n\n\t// if groundentity has been set to -1, it may have been pushed off an edge\n\tif ( ent->s.groundEntityNum == -1 ) {\n\t\tif ( ent->s.pos.trType != TR_GRAVITY ) {\n\t\t\tent->s.pos.trType = TR_GRAVITY;\n\t\t\tent->s.pos.trTime = level.time;\n\t\t}\n\t}\n\n\tif ( ent->s.pos.trType == TR_STATIONARY ) {\n\t\t// check think function\n\t\tG_RunThink( ent );\n\t\treturn;\n\t}\n\n\t// get current position\n\tBG_EvaluateTrajectory( &ent->s.pos, level.time, origin );\n\n\t// trace a line from the previous position to the current position\n\tif ( ent->clipmask ) {\n\t\tmask = ent->clipmask;\n\t} else {\n\t\tmask = MASK_PLAYERSOLID & ~CONTENTS_BODY;//MASK_SOLID;\n\t}\n\ttrap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, origin, \n\t\tent->r.ownerNum, mask );\n\n\tVectorCopy( tr.endpos, ent->r.currentOrigin );\n\n\tif ( tr.startsolid ) {\n\t\ttr.fraction = 0;\n\t}\n\n\ttrap_LinkEntity( ent );\t// FIXME: avoid this for stationary?\n\n\t// check think function\n\tG_RunThink( ent );\n\n\tif ( tr.fraction == 1 ) {\n\t\treturn;\n\t}\n\n\t// if it is in a nodrop volume, remove it\n\tcontents = trap_PointContents( ent->r.currentOrigin, -1 );\n\tif ( contents & CONTENTS_NODROP ) {\n\t\tif (ent->item && ent->item->giType == IT_TEAM) {\n\t\t\tTeam_FreeEntity(ent);\n\t\t} else {\n\t\t\tG_FreeEntity( ent );\n\t\t}\n\t\treturn;\n\t}\n\n\tG_BounceItem( ent, &tr );\n}\n\n"
  },
  {
    "path": "code/game/g_local.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// g_local.h -- local definitions for game module\n\n#include \"q_shared.h\"\n#include \"bg_public.h\"\n#include \"g_public.h\"\n\n//==================================================================\n\n// the \"gameversion\" client command will print this plus compile date\n#define\tGAMEVERSION\t\"baseq3\"\n\n#define BODY_QUEUE_SIZE\t\t8\n\n#define INFINITE\t\t\t1000000\n\n#define\tFRAMETIME\t\t\t100\t\t\t\t\t// msec\n#define\tCARNAGE_REWARD_TIME\t3000\n#define REWARD_SPRITE_TIME\t2000\n\n#define\tINTERMISSION_DELAY_TIME\t1000\n#define\tSP_INTERMISSION_DELAY_TIME\t5000\n\n// gentity->flags\n#define\tFL_GODMODE\t\t\t\t0x00000010\n#define\tFL_NOTARGET\t\t\t\t0x00000020\n#define\tFL_TEAMSLAVE\t\t\t0x00000400\t// not the first on the team\n#define FL_NO_KNOCKBACK\t\t\t0x00000800\n#define FL_DROPPED_ITEM\t\t\t0x00001000\n#define FL_NO_BOTS\t\t\t\t0x00002000\t// spawn point not for bot use\n#define FL_NO_HUMANS\t\t\t0x00004000\t// spawn point just for bots\n#define FL_FORCE_GESTURE\t\t0x00008000\t// force gesture on client\n\n// movers are things like doors, plats, buttons, etc\ntypedef enum {\n\tMOVER_POS1,\n\tMOVER_POS2,\n\tMOVER_1TO2,\n\tMOVER_2TO1\n} moverState_t;\n\n#define SP_PODIUM_MODEL\t\t\"models/mapobjects/podium/podium4.md3\"\n\n//============================================================================\n\ntypedef struct gentity_s gentity_t;\ntypedef struct gclient_s gclient_t;\n\nstruct gentity_s {\n\tentityState_t\ts;\t\t\t\t// communicated by server to clients\n\tentityShared_t\tr;\t\t\t\t// shared by both the server system and game\n\n\t// DO NOT MODIFY ANYTHING ABOVE THIS, THE SERVER\n\t// EXPECTS THE FIELDS IN THAT ORDER!\n\t//================================\n\n\tstruct gclient_s\t*client;\t\t\t// NULL if not a client\n\n\tqboolean\tinuse;\n\n\tchar\t\t*classname;\t\t\t// set in QuakeEd\n\tint\t\t\tspawnflags;\t\t\t// set in QuakeEd\n\n\tqboolean\tneverFree;\t\t\t// if true, FreeEntity will only unlink\n\t\t\t\t\t\t\t\t\t// bodyque uses this\n\n\tint\t\t\tflags;\t\t\t\t// FL_* variables\n\n\tchar\t\t*model;\n\tchar\t\t*model2;\n\tint\t\t\tfreetime;\t\t\t// level.time when the object was freed\n\t\n\tint\t\t\teventTime;\t\t\t// events will be cleared EVENT_VALID_MSEC after set\n\tqboolean\tfreeAfterEvent;\n\tqboolean\tunlinkAfterEvent;\n\n\tqboolean\tphysicsObject;\t\t// if true, it can be pushed by movers and fall off edges\n\t\t\t\t\t\t\t\t\t// all game items are physicsObjects, \n\tfloat\t\tphysicsBounce;\t\t// 1.0 = continuous bounce, 0.0 = no bounce\n\tint\t\t\tclipmask;\t\t\t// brushes with this content value will be collided against\n\t\t\t\t\t\t\t\t\t// when moving.  items and corpses do not collide against\n\t\t\t\t\t\t\t\t\t// players, for instance\n\n\t// movers\n\tmoverState_t moverState;\n\tint\t\t\tsoundPos1;\n\tint\t\t\tsound1to2;\n\tint\t\t\tsound2to1;\n\tint\t\t\tsoundPos2;\n\tint\t\t\tsoundLoop;\n\tgentity_t\t*parent;\n\tgentity_t\t*nextTrain;\n\tgentity_t\t*prevTrain;\n\tvec3_t\t\tpos1, pos2;\n\n\tchar\t\t*message;\n\n\tint\t\t\ttimestamp;\t\t// body queue sinking, etc\n\n\tfloat\t\tangle;\t\t\t// set in editor, -1 = up, -2 = down\n\tchar\t\t*target;\n\tchar\t\t*targetname;\n\tchar\t\t*team;\n\tchar\t\t*targetShaderName;\n\tchar\t\t*targetShaderNewName;\n\tgentity_t\t*target_ent;\n\n\tfloat\t\tspeed;\n\tvec3_t\t\tmovedir;\n\n\tint\t\t\tnextthink;\n\tvoid\t\t(*think)(gentity_t *self);\n\tvoid\t\t(*reached)(gentity_t *self);\t// movers call this when hitting endpoint\n\tvoid\t\t(*blocked)(gentity_t *self, gentity_t *other);\n\tvoid\t\t(*touch)(gentity_t *self, gentity_t *other, trace_t *trace);\n\tvoid\t\t(*use)(gentity_t *self, gentity_t *other, gentity_t *activator);\n\tvoid\t\t(*pain)(gentity_t *self, gentity_t *attacker, int damage);\n\tvoid\t\t(*die)(gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod);\n\n\tint\t\t\tpain_debounce_time;\n\tint\t\t\tfly_sound_debounce_time;\t// wind tunnel\n\tint\t\t\tlast_move_time;\n\n\tint\t\t\thealth;\n\n\tqboolean\ttakedamage;\n\n\tint\t\t\tdamage;\n\tint\t\t\tsplashDamage;\t// quad will increase this without increasing radius\n\tint\t\t\tsplashRadius;\n\tint\t\t\tmethodOfDeath;\n\tint\t\t\tsplashMethodOfDeath;\n\n\tint\t\t\tcount;\n\n\tgentity_t\t*chain;\n\tgentity_t\t*enemy;\n\tgentity_t\t*activator;\n\tgentity_t\t*teamchain;\t\t// next entity in team\n\tgentity_t\t*teammaster;\t// master of the team\n\n#ifdef MISSIONPACK\n\tint\t\t\tkamikazeTime;\n\tint\t\t\tkamikazeShockTime;\n#endif\n\n\tint\t\t\twatertype;\n\tint\t\t\twaterlevel;\n\n\tint\t\t\tnoise_index;\n\n\t// timing variables\n\tfloat\t\twait;\n\tfloat\t\trandom;\n\n\tgitem_t\t\t*item;\t\t\t// for bonus items\n};\n\n\ntypedef enum {\n\tCON_DISCONNECTED,\n\tCON_CONNECTING,\n\tCON_CONNECTED\n} clientConnected_t;\n\ntypedef enum {\n\tSPECTATOR_NOT,\n\tSPECTATOR_FREE,\n\tSPECTATOR_FOLLOW,\n\tSPECTATOR_SCOREBOARD\n} spectatorState_t;\n\ntypedef enum {\n\tTEAM_BEGIN,\t\t// Beginning a team game, spawn at base\n\tTEAM_ACTIVE\t\t// Now actively playing\n} playerTeamStateState_t;\n\ntypedef struct {\n\tplayerTeamStateState_t\tstate;\n\n\tint\t\t\tlocation;\n\n\tint\t\t\tcaptures;\n\tint\t\t\tbasedefense;\n\tint\t\t\tcarrierdefense;\n\tint\t\t\tflagrecovery;\n\tint\t\t\tfragcarrier;\n\tint\t\t\tassists;\n\n\tfloat\t\tlasthurtcarrier;\n\tfloat\t\tlastreturnedflag;\n\tfloat\t\tflagsince;\n\tfloat\t\tlastfraggedcarrier;\n} playerTeamState_t;\n\n// the auto following clients don't follow a specific client\n// number, but instead follow the first two active players\n#define\tFOLLOW_ACTIVE1\t-1\n#define\tFOLLOW_ACTIVE2\t-2\n\n// client data that stays across multiple levels or tournament restarts\n// this is achieved by writing all the data to cvar strings at game shutdown\n// time and reading them back at connection time.  Anything added here\n// MUST be dealt with in G_InitSessionData() / G_ReadSessionData() / G_WriteSessionData()\ntypedef struct {\n\tteam_t\t\tsessionTeam;\n\tint\t\t\tspectatorTime;\t\t// for determining next-in-line to play\n\tspectatorState_t\tspectatorState;\n\tint\t\t\tspectatorClient;\t// for chasecam and follow mode\n\tint\t\t\twins, losses;\t\t// tournament stats\n\tqboolean\tteamLeader;\t\t\t// true when this client is a team leader\n} clientSession_t;\n\n//\n#define MAX_NETNAME\t\t\t36\n#define\tMAX_VOTE_COUNT\t\t3\n\n// client data that stays across multiple respawns, but is cleared\n// on each level change or team change at ClientBegin()\ntypedef struct {\n\tclientConnected_t\tconnected;\t\n\tusercmd_t\tcmd;\t\t\t\t// we would lose angles if not persistant\n\tqboolean\tlocalClient;\t\t// true if \"ip\" info key is \"localhost\"\n\tqboolean\tinitialSpawn;\t\t// the first spawn should be at a cool location\n\tqboolean\tpredictItemPickup;\t// based on cg_predictItems userinfo\n\tqboolean\tpmoveFixed;\t\t\t//\n\tchar\t\tnetname[MAX_NETNAME];\n\tint\t\t\tmaxHealth;\t\t\t// for handicapping\n\tint\t\t\tenterTime;\t\t\t// level.time the client entered the game\n\tplayerTeamState_t teamState;\t// status in teamplay games\n\tint\t\t\tvoteCount;\t\t\t// to prevent people from constantly calling votes\n\tint\t\t\tteamVoteCount;\t\t// to prevent people from constantly calling votes\n\tqboolean\tteamInfo;\t\t\t// send team overlay updates?\n} clientPersistant_t;\n\n\n// this structure is cleared on each ClientSpawn(),\n// except for 'client->pers' and 'client->sess'\nstruct gclient_s {\n\t// ps MUST be the first element, because the server expects it\n\tplayerState_t\tps;\t\t\t\t// communicated by server to clients\n\n\t// the rest of the structure is private to game\n\tclientPersistant_t\tpers;\n\tclientSession_t\t\tsess;\n\n\tqboolean\treadyToExit;\t\t// wishes to leave the intermission\n\n\tqboolean\tnoclip;\n\n\tint\t\t\tlastCmdTime;\t\t// level.time of last usercmd_t, for EF_CONNECTION\n\t\t\t\t\t\t\t\t\t// we can't just use pers.lastCommand.time, because\n\t\t\t\t\t\t\t\t\t// of the g_sycronousclients case\n\tint\t\t\tbuttons;\n\tint\t\t\toldbuttons;\n\tint\t\t\tlatched_buttons;\n\n\tvec3_t\t\toldOrigin;\n\n\t// sum up damage over an entire frame, so\n\t// shotgun blasts give a single big kick\n\tint\t\t\tdamage_armor;\t\t// damage absorbed by armor\n\tint\t\t\tdamage_blood;\t\t// damage taken out of health\n\tint\t\t\tdamage_knockback;\t// impact damage\n\tvec3_t\t\tdamage_from;\t\t// origin for vector calculation\n\tqboolean\tdamage_fromWorld;\t// if true, don't use the damage_from vector\n\n\tint\t\t\taccurateCount;\t\t// for \"impressive\" reward sound\n\n\tint\t\t\taccuracy_shots;\t\t// total number of shots\n\tint\t\t\taccuracy_hits;\t\t// total number of hits\n\n\t//\n\tint\t\t\tlastkilled_client;\t// last client that this client killed\n\tint\t\t\tlasthurt_client;\t// last client that damaged this client\n\tint\t\t\tlasthurt_mod;\t\t// type of damage the client did\n\n\t// timers\n\tint\t\t\trespawnTime;\t\t// can respawn when time > this, force after g_forcerespwan\n\tint\t\t\tinactivityTime;\t\t// kick players when time > this\n\tqboolean\tinactivityWarning;\t// qtrue if the five seoond warning has been given\n\tint\t\t\trewardTime;\t\t\t// clear the EF_AWARD_IMPRESSIVE, etc when time > this\n\n\tint\t\t\tairOutTime;\n\n\tint\t\t\tlastKillTime;\t\t// for multiple kill rewards\n\n\tqboolean\tfireHeld;\t\t\t// used for hook\n\tgentity_t\t*hook;\t\t\t\t// grapple hook if out\n\n\tint\t\t\tswitchTeamTime;\t\t// time the player switched teams\n\n\t// timeResidual is used to handle events that happen every second\n\t// like health / armor countdowns and regeneration\n\tint\t\t\ttimeResidual;\n\n#ifdef MISSIONPACK\n\tgentity_t\t*persistantPowerup;\n\tint\t\t\tportalID;\n\tint\t\t\tammoTimes[WP_NUM_WEAPONS];\n\tint\t\t\tinvulnerabilityTime;\n#endif\n\n\tchar\t\t*areabits;\n};\n\n\n//\n// this structure is cleared as each map is entered\n//\n#define\tMAX_SPAWN_VARS\t\t\t64\n#define\tMAX_SPAWN_VARS_CHARS\t4096\n\ntypedef struct {\n\tstruct gclient_s\t*clients;\t\t// [maxclients]\n\n\tstruct gentity_s\t*gentities;\n\tint\t\t\tgentitySize;\n\tint\t\t\tnum_entities;\t\t// current number, <= MAX_GENTITIES\n\n\tint\t\t\twarmupTime;\t\t\t// restart match at this time\n\n\tfileHandle_t\tlogFile;\n\n\t// store latched cvars here that we want to get at often\n\tint\t\t\tmaxclients;\n\n\tint\t\t\tframenum;\n\tint\t\t\ttime;\t\t\t\t\t// in msec\n\tint\t\t\tpreviousTime;\t\t\t// so movers can back up when blocked\n\n\tint\t\t\tstartTime;\t\t\t\t// level.time the map was started\n\n\tint\t\t\tteamScores[TEAM_NUM_TEAMS];\n\tint\t\t\tlastTeamLocationTime;\t\t// last time of client team location update\n\n\tqboolean\tnewSession;\t\t\t\t// don't use any old session data, because\n\t\t\t\t\t\t\t\t\t\t// we changed gametype\n\n\tqboolean\trestarted;\t\t\t\t// waiting for a map_restart to fire\n\n\tint\t\t\tnumConnectedClients;\n\tint\t\t\tnumNonSpectatorClients;\t// includes connecting clients\n\tint\t\t\tnumPlayingClients;\t\t// connected, non-spectators\n\tint\t\t\tsortedClients[MAX_CLIENTS];\t\t// sorted by score\n\tint\t\t\tfollow1, follow2;\t\t// clientNums for auto-follow spectators\n\n\tint\t\t\tsnd_fry;\t\t\t\t// sound index for standing in lava\n\n\tint\t\t\twarmupModificationCount;\t// for detecting if g_warmup is changed\n\n\t// voting state\n\tchar\t\tvoteString[MAX_STRING_CHARS];\n\tchar\t\tvoteDisplayString[MAX_STRING_CHARS];\n\tint\t\t\tvoteTime;\t\t\t\t// level.time vote was called\n\tint\t\t\tvoteExecuteTime;\t\t// time the vote is executed\n\tint\t\t\tvoteYes;\n\tint\t\t\tvoteNo;\n\tint\t\t\tnumVotingClients;\t\t// set by CalculateRanks\n\n\t// team voting state\n\tchar\t\tteamVoteString[2][MAX_STRING_CHARS];\n\tint\t\t\tteamVoteTime[2];\t\t// level.time vote was called\n\tint\t\t\tteamVoteYes[2];\n\tint\t\t\tteamVoteNo[2];\n\tint\t\t\tnumteamVotingClients[2];// set by CalculateRanks\n\n\t// spawn variables\n\tqboolean\tspawning;\t\t\t\t// the G_Spawn*() functions are valid\n\tint\t\t\tnumSpawnVars;\n\tchar\t\t*spawnVars[MAX_SPAWN_VARS][2];\t// key / value pairs\n\tint\t\t\tnumSpawnVarChars;\n\tchar\t\tspawnVarChars[MAX_SPAWN_VARS_CHARS];\n\n\t// intermission state\n\tint\t\t\tintermissionQueued;\t\t// intermission was qualified, but\n\t\t\t\t\t\t\t\t\t\t// wait INTERMISSION_DELAY_TIME before\n\t\t\t\t\t\t\t\t\t\t// actually going there so the last\n\t\t\t\t\t\t\t\t\t\t// frag can be watched.  Disable future\n\t\t\t\t\t\t\t\t\t\t// kills during this delay\n\tint\t\t\tintermissiontime;\t\t// time the intermission was started\n\tchar\t\t*changemap;\n\tqboolean\treadyToExit;\t\t\t// at least one client wants to exit\n\tint\t\t\texitTime;\n\tvec3_t\t\tintermission_origin;\t// also used for spectator spawns\n\tvec3_t\t\tintermission_angle;\n\n\tqboolean\tlocationLinked;\t\t\t// target_locations get linked\n\tgentity_t\t*locationHead;\t\t\t// head of the location list\n\tint\t\t\tbodyQueIndex;\t\t\t// dead bodies\n\tgentity_t\t*bodyQue[BODY_QUEUE_SIZE];\n#ifdef MISSIONPACK\n\tint\t\t\tportalSequence;\n#endif\n} level_locals_t;\n\n\n//\n// g_spawn.c\n//\nqboolean\tG_SpawnString( const char *key, const char *defaultString, char **out );\n// spawn string returns a temporary reference, you must CopyString() if you want to keep it\nqboolean\tG_SpawnFloat( const char *key, const char *defaultString, float *out );\nqboolean\tG_SpawnInt( const char *key, const char *defaultString, int *out );\nqboolean\tG_SpawnVector( const char *key, const char *defaultString, float *out );\nvoid\t\tG_SpawnEntitiesFromString( void );\nchar *G_NewString( const char *string );\n\n//\n// g_cmds.c\n//\nvoid Cmd_Score_f (gentity_t *ent);\nvoid StopFollowing( gentity_t *ent );\nvoid BroadcastTeamChange( gclient_t *client, int oldTeam );\nvoid SetTeam( gentity_t *ent, char *s );\nvoid Cmd_FollowCycle_f( gentity_t *ent, int dir );\n\n//\n// g_items.c\n//\nvoid G_CheckTeamItems( void );\nvoid G_RunItem( gentity_t *ent );\nvoid RespawnItem( gentity_t *ent );\n\nvoid UseHoldableItem( gentity_t *ent );\nvoid PrecacheItem (gitem_t *it);\ngentity_t *Drop_Item( gentity_t *ent, gitem_t *item, float angle );\ngentity_t *LaunchItem( gitem_t *item, vec3_t origin, vec3_t velocity );\nvoid SetRespawn (gentity_t *ent, float delay);\nvoid G_SpawnItem (gentity_t *ent, gitem_t *item);\nvoid FinishSpawningItem( gentity_t *ent );\nvoid Think_Weapon (gentity_t *ent);\nint ArmorIndex (gentity_t *ent);\nvoid\tAdd_Ammo (gentity_t *ent, int weapon, int count);\nvoid Touch_Item (gentity_t *ent, gentity_t *other, trace_t *trace);\n\nvoid ClearRegisteredItems( void );\nvoid RegisterItem( gitem_t *item );\nvoid SaveRegisteredItems( void );\n\n//\n// g_utils.c\n//\nint G_ModelIndex( char *name );\nint\t\tG_SoundIndex( char *name );\nvoid\tG_TeamCommand( team_t team, char *cmd );\nvoid\tG_KillBox (gentity_t *ent);\ngentity_t *G_Find (gentity_t *from, int fieldofs, const char *match);\ngentity_t *G_PickTarget (char *targetname);\nvoid\tG_UseTargets (gentity_t *ent, gentity_t *activator);\nvoid\tG_SetMovedir ( vec3_t angles, vec3_t movedir);\n\nvoid\tG_InitGentity( gentity_t *e );\ngentity_t\t*G_Spawn (void);\ngentity_t *G_TempEntity( vec3_t origin, int event );\nvoid\tG_Sound( gentity_t *ent, int channel, int soundIndex );\nvoid\tG_FreeEntity( gentity_t *e );\nqboolean\tG_EntitiesFree( void );\n\nvoid\tG_TouchTriggers (gentity_t *ent);\nvoid\tG_TouchSolids (gentity_t *ent);\n\nfloat\t*tv (float x, float y, float z);\nchar\t*vtos( const vec3_t v );\n\nfloat vectoyaw( const vec3_t vec );\n\nvoid G_AddPredictableEvent( gentity_t *ent, int event, int eventParm );\nvoid G_AddEvent( gentity_t *ent, int event, int eventParm );\nvoid G_SetOrigin( gentity_t *ent, vec3_t origin );\nvoid AddRemap(const char *oldShader, const char *newShader, float timeOffset);\nconst char *BuildShaderStateConfig();\n\n//\n// g_combat.c\n//\nqboolean CanDamage (gentity_t *targ, vec3_t origin);\nvoid G_Damage (gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, vec3_t dir, vec3_t point, int damage, int dflags, int mod);\nqboolean G_RadiusDamage (vec3_t origin, gentity_t *attacker, float damage, float radius, gentity_t *ignore, int mod);\nint G_InvulnerabilityEffect( gentity_t *targ, vec3_t dir, vec3_t point, vec3_t impactpoint, vec3_t bouncedir );\nvoid body_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath );\nvoid TossClientItems( gentity_t *self );\n#ifdef MISSIONPACK\nvoid TossClientPersistantPowerups( gentity_t *self );\n#endif\nvoid TossClientCubes( gentity_t *self );\n\n// damage flags\n#define DAMAGE_RADIUS\t\t\t\t0x00000001\t// damage was indirect\n#define DAMAGE_NO_ARMOR\t\t\t\t0x00000002\t// armour does not protect from this damage\n#define DAMAGE_NO_KNOCKBACK\t\t\t0x00000004\t// do not affect velocity, just view angles\n#define DAMAGE_NO_PROTECTION\t\t0x00000008  // armor, shields, invulnerability, and godmode have no effect\n#ifdef MISSIONPACK\n#define DAMAGE_NO_TEAM_PROTECTION\t0x00000010  // armor, shields, invulnerability, and godmode have no effect\n#endif\n\n//\n// g_missile.c\n//\nvoid G_RunMissile( gentity_t *ent );\n\ngentity_t *fire_blaster (gentity_t *self, vec3_t start, vec3_t aimdir);\ngentity_t *fire_plasma (gentity_t *self, vec3_t start, vec3_t aimdir);\ngentity_t *fire_grenade (gentity_t *self, vec3_t start, vec3_t aimdir);\ngentity_t *fire_rocket (gentity_t *self, vec3_t start, vec3_t dir);\ngentity_t *fire_bfg (gentity_t *self, vec3_t start, vec3_t dir);\ngentity_t *fire_grapple (gentity_t *self, vec3_t start, vec3_t dir);\n#ifdef MISSIONPACK\ngentity_t *fire_nail( gentity_t *self, vec3_t start, vec3_t forward, vec3_t right, vec3_t up );\ngentity_t *fire_prox( gentity_t *self, vec3_t start, vec3_t aimdir );\n#endif\n\n\n//\n// g_mover.c\n//\nvoid G_RunMover( gentity_t *ent );\nvoid Touch_DoorTrigger( gentity_t *ent, gentity_t *other, trace_t *trace );\n\n//\n// g_trigger.c\n//\nvoid trigger_teleporter_touch (gentity_t *self, gentity_t *other, trace_t *trace );\n\n\n//\n// g_misc.c\n//\nvoid TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles );\n#ifdef MISSIONPACK\nvoid DropPortalSource( gentity_t *ent );\nvoid DropPortalDestination( gentity_t *ent );\n#endif\n\n\n//\n// g_weapon.c\n//\nqboolean LogAccuracyHit( gentity_t *target, gentity_t *attacker );\nvoid CalcMuzzlePoint ( gentity_t *ent, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint );\nvoid SnapVectorTowards( vec3_t v, vec3_t to );\nqboolean CheckGauntletAttack( gentity_t *ent );\nvoid Weapon_HookFree (gentity_t *ent);\nvoid Weapon_HookThink (gentity_t *ent);\n\n\n//\n// g_client.c\n//\nteam_t TeamCount( int ignoreClientNum, int team );\nint TeamLeader( int team );\nteam_t PickTeam( int ignoreClientNum );\nvoid SetClientViewAngle( gentity_t *ent, vec3_t angle );\ngentity_t *SelectSpawnPoint ( vec3_t avoidPoint, vec3_t origin, vec3_t angles );\nvoid CopyToBodyQue( gentity_t *ent );\nvoid respawn (gentity_t *ent);\nvoid BeginIntermission (void);\nvoid InitClientPersistant (gclient_t *client);\nvoid InitClientResp (gclient_t *client);\nvoid InitBodyQue (void);\nvoid ClientSpawn( gentity_t *ent );\nvoid player_die (gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod);\nvoid AddScore( gentity_t *ent, vec3_t origin, int score );\nvoid CalculateRanks( void );\nqboolean SpotWouldTelefrag( gentity_t *spot );\n\n//\n// g_svcmds.c\n//\nqboolean\tConsoleCommand( void );\nvoid G_ProcessIPBans(void);\nqboolean G_FilterPacket (char *from);\n\n//\n// g_weapon.c\n//\nvoid FireWeapon( gentity_t *ent );\n#ifdef MISSIONPACK\nvoid G_StartKamikaze( gentity_t *ent );\n#endif\n\n//\n// p_hud.c\n//\nvoid MoveClientToIntermission (gentity_t *client);\nvoid G_SetStats (gentity_t *ent);\nvoid DeathmatchScoreboardMessage (gentity_t *client);\n\n//\n// g_cmds.c\n//\n\n//\n// g_pweapon.c\n//\n\n\n//\n// g_main.c\n//\nvoid FindIntermissionPoint( void );\nvoid SetLeader(int team, int client);\nvoid CheckTeamLeader( int team );\nvoid G_RunThink (gentity_t *ent);\nvoid QDECL G_LogPrintf( const char *fmt, ... );\nvoid SendScoreboardMessageToAllClients( void );\nvoid QDECL G_Printf( const char *fmt, ... );\nvoid QDECL G_Error( const char *fmt, ... );\n\n//\n// g_client.c\n//\nchar *ClientConnect( int clientNum, qboolean firstTime, qboolean isBot );\nvoid ClientUserinfoChanged( int clientNum );\nvoid ClientDisconnect( int clientNum );\nvoid ClientBegin( int clientNum );\nvoid ClientCommand( int clientNum );\n\n//\n// g_active.c\n//\nvoid ClientThink( int clientNum );\nvoid ClientEndFrame( gentity_t *ent );\nvoid G_RunClient( gentity_t *ent );\n\n//\n// g_team.c\n//\nqboolean OnSameTeam( gentity_t *ent1, gentity_t *ent2 );\nvoid Team_CheckDroppedItem( gentity_t *dropped );\nqboolean CheckObeliskAttack( gentity_t *obelisk, gentity_t *attacker );\n\n//\n// g_mem.c\n//\nvoid *G_Alloc( int size );\nvoid G_InitMemory( void );\nvoid Svcmd_GameMem_f( void );\n\n//\n// g_session.c\n//\nvoid G_ReadSessionData( gclient_t *client );\nvoid G_InitSessionData( gclient_t *client, char *userinfo );\n\nvoid G_InitWorldSession( void );\nvoid G_WriteSessionData( void );\n\n//\n// g_arenas.c\n//\nvoid UpdateTournamentInfo( void );\nvoid SpawnModelsOnVictoryPads( void );\nvoid Svcmd_AbortPodium_f( void );\n\n//\n// g_bot.c\n//\nvoid G_InitBots( qboolean restart );\nchar *G_GetBotInfoByNumber( int num );\nchar *G_GetBotInfoByName( const char *name );\nvoid G_CheckBotSpawn( void );\nvoid G_RemoveQueuedBotBegin( int clientNum );\nqboolean G_BotConnect( int clientNum, qboolean restart );\nvoid Svcmd_AddBot_f( void );\nvoid Svcmd_BotList_f( void );\nvoid BotInterbreedEndMatch( void );\n\n// ai_main.c\n#define MAX_FILEPATH\t\t\t144\n\n//bot settings\ntypedef struct bot_settings_s\n{\n\tchar characterfile[MAX_FILEPATH];\n\tfloat skill;\n\tchar team[MAX_FILEPATH];\n} bot_settings_t;\n\nint BotAISetup( int restart );\nint BotAIShutdown( int restart );\nint BotAILoadMap( int restart );\nint BotAISetupClient(int client, struct bot_settings_s *settings, qboolean restart);\nint BotAIShutdownClient( int client, qboolean restart );\nint BotAIStartFrame( int time );\nvoid BotTestAAS(vec3_t origin);\n\n#include \"g_team.h\" // teamplay specific stuff\n\n\nextern\tlevel_locals_t\tlevel;\nextern\tgentity_t\t\tg_entities[MAX_GENTITIES];\n\n#define\tFOFS(x) ((int)&(((gentity_t *)0)->x))\n\nextern\tvmCvar_t\tg_gametype;\nextern\tvmCvar_t\tg_dedicated;\nextern\tvmCvar_t\tg_cheats;\nextern\tvmCvar_t\tg_maxclients;\t\t\t// allow this many total, including spectators\nextern\tvmCvar_t\tg_maxGameClients;\t\t// allow this many active\nextern\tvmCvar_t\tg_restarted;\n\nextern\tvmCvar_t\tg_dmflags;\nextern\tvmCvar_t\tg_fraglimit;\nextern\tvmCvar_t\tg_timelimit;\nextern\tvmCvar_t\tg_capturelimit;\nextern\tvmCvar_t\tg_friendlyFire;\nextern\tvmCvar_t\tg_password;\nextern\tvmCvar_t\tg_needpass;\nextern\tvmCvar_t\tg_gravity;\nextern\tvmCvar_t\tg_speed;\nextern\tvmCvar_t\tg_knockback;\nextern\tvmCvar_t\tg_quadfactor;\nextern\tvmCvar_t\tg_forcerespawn;\nextern\tvmCvar_t\tg_inactivity;\nextern\tvmCvar_t\tg_debugMove;\nextern\tvmCvar_t\tg_debugAlloc;\nextern\tvmCvar_t\tg_debugDamage;\nextern\tvmCvar_t\tg_weaponRespawn;\nextern\tvmCvar_t\tg_weaponTeamRespawn;\nextern\tvmCvar_t\tg_synchronousClients;\nextern\tvmCvar_t\tg_motd;\nextern\tvmCvar_t\tg_warmup;\nextern\tvmCvar_t\tg_doWarmup;\nextern\tvmCvar_t\tg_blood;\nextern\tvmCvar_t\tg_allowVote;\nextern\tvmCvar_t\tg_teamAutoJoin;\nextern\tvmCvar_t\tg_teamForceBalance;\nextern\tvmCvar_t\tg_banIPs;\nextern\tvmCvar_t\tg_filterBan;\nextern\tvmCvar_t\tg_obeliskHealth;\nextern\tvmCvar_t\tg_obeliskRegenPeriod;\nextern\tvmCvar_t\tg_obeliskRegenAmount;\nextern\tvmCvar_t\tg_obeliskRespawnDelay;\nextern\tvmCvar_t\tg_cubeTimeout;\nextern\tvmCvar_t\tg_redteam;\nextern\tvmCvar_t\tg_blueteam;\nextern\tvmCvar_t\tg_smoothClients;\nextern\tvmCvar_t\tpmove_fixed;\nextern\tvmCvar_t\tpmove_msec;\nextern\tvmCvar_t\tg_rankings;\nextern\tvmCvar_t\tg_enableDust;\nextern\tvmCvar_t\tg_enableBreath;\nextern\tvmCvar_t\tg_singlePlayer;\nextern\tvmCvar_t\tg_proxMineTimeout;\n\nvoid\ttrap_Printf( const char *fmt );\nvoid\ttrap_Error( const char *fmt );\nint\t\ttrap_Milliseconds( void );\nint\t\ttrap_Argc( void );\nvoid\ttrap_Argv( int n, char *buffer, int bufferLength );\nvoid\ttrap_Args( char *buffer, int bufferLength );\nint\t\ttrap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode );\nvoid\ttrap_FS_Read( void *buffer, int len, fileHandle_t f );\nvoid\ttrap_FS_Write( const void *buffer, int len, fileHandle_t f );\nvoid\ttrap_FS_FCloseFile( fileHandle_t f );\nint\t\ttrap_FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize );\nint\t\ttrap_FS_Seek( fileHandle_t f, long offset, int origin ); // fsOrigin_t\nvoid\ttrap_SendConsoleCommand( int exec_when, const char *text );\nvoid\ttrap_Cvar_Register( vmCvar_t *cvar, const char *var_name, const char *value, int flags );\nvoid\ttrap_Cvar_Update( vmCvar_t *cvar );\nvoid\ttrap_Cvar_Set( const char *var_name, const char *value );\nint\t\ttrap_Cvar_VariableIntegerValue( const char *var_name );\nfloat\ttrap_Cvar_VariableValue( const char *var_name );\nvoid\ttrap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize );\nvoid\ttrap_LocateGameData( gentity_t *gEnts, int numGEntities, int sizeofGEntity_t, playerState_t *gameClients, int sizeofGameClient );\nvoid\ttrap_DropClient( int clientNum, const char *reason );\nvoid\ttrap_SendServerCommand( int clientNum, const char *text );\nvoid\ttrap_SetConfigstring( int num, const char *string );\nvoid\ttrap_GetConfigstring( int num, char *buffer, int bufferSize );\nvoid\ttrap_GetUserinfo( int num, char *buffer, int bufferSize );\nvoid\ttrap_SetUserinfo( int num, const char *buffer );\nvoid\ttrap_GetServerinfo( char *buffer, int bufferSize );\nvoid\ttrap_SetBrushModel( gentity_t *ent, const char *name );\nvoid\ttrap_Trace( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask );\nint\t\ttrap_PointContents( const vec3_t point, int passEntityNum );\nqboolean trap_InPVS( const vec3_t p1, const vec3_t p2 );\nqboolean trap_InPVSIgnorePortals( const vec3_t p1, const vec3_t p2 );\nvoid\ttrap_AdjustAreaPortalState( gentity_t *ent, qboolean open );\nqboolean trap_AreasConnected( int area1, int area2 );\nvoid\ttrap_LinkEntity( gentity_t *ent );\nvoid\ttrap_UnlinkEntity( gentity_t *ent );\nint\t\ttrap_EntitiesInBox( const vec3_t mins, const vec3_t maxs, int *entityList, int maxcount );\nqboolean trap_EntityContact( const vec3_t mins, const vec3_t maxs, const gentity_t *ent );\nint\t\ttrap_BotAllocateClient( void );\nvoid\ttrap_BotFreeClient( int clientNum );\nvoid\ttrap_GetUsercmd( int clientNum, usercmd_t *cmd );\nqboolean\ttrap_GetEntityToken( char *buffer, int bufferSize );\n\nint\t\ttrap_DebugPolygonCreate(int color, int numPoints, vec3_t *points);\nvoid\ttrap_DebugPolygonDelete(int id);\n\nint\t\ttrap_BotLibSetup( void );\nint\t\ttrap_BotLibShutdown( void );\nint\t\ttrap_BotLibVarSet(char *var_name, char *value);\nint\t\ttrap_BotLibVarGet(char *var_name, char *value, int size);\nint\t\ttrap_BotLibDefine(char *string);\nint\t\ttrap_BotLibStartFrame(float time);\nint\t\ttrap_BotLibLoadMap(const char *mapname);\nint\t\ttrap_BotLibUpdateEntity(int ent, void /* struct bot_updateentity_s */ *bue);\nint\t\ttrap_BotLibTest(int parm0, char *parm1, vec3_t parm2, vec3_t parm3);\n\nint\t\ttrap_BotGetSnapshotEntity( int clientNum, int sequence );\nint\t\ttrap_BotGetServerCommand(int clientNum, char *message, int size);\nvoid\ttrap_BotUserCommand(int client, usercmd_t *ucmd);\n\nint\t\ttrap_AAS_BBoxAreas(vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas);\nint\t\ttrap_AAS_AreaInfo( int areanum, void /* struct aas_areainfo_s */ *info );\nvoid\ttrap_AAS_EntityInfo(int entnum, void /* struct aas_entityinfo_s */ *info);\n\nint\t\ttrap_AAS_Initialized(void);\nvoid\ttrap_AAS_PresenceTypeBoundingBox(int presencetype, vec3_t mins, vec3_t maxs);\nfloat\ttrap_AAS_Time(void);\n\nint\t\ttrap_AAS_PointAreaNum(vec3_t point);\nint\t\ttrap_AAS_PointReachabilityAreaIndex(vec3_t point);\nint\t\ttrap_AAS_TraceAreas(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas);\n\nint\t\ttrap_AAS_PointContents(vec3_t point);\nint\t\ttrap_AAS_NextBSPEntity(int ent);\nint\t\ttrap_AAS_ValueForBSPEpairKey(int ent, char *key, char *value, int size);\nint\t\ttrap_AAS_VectorForBSPEpairKey(int ent, char *key, vec3_t v);\nint\t\ttrap_AAS_FloatForBSPEpairKey(int ent, char *key, float *value);\nint\t\ttrap_AAS_IntForBSPEpairKey(int ent, char *key, int *value);\n\nint\t\ttrap_AAS_AreaReachability(int areanum);\n\nint\t\ttrap_AAS_AreaTravelTimeToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags);\nint\t\ttrap_AAS_EnableRoutingArea( int areanum, int enable );\nint\t\ttrap_AAS_PredictRoute(void /*struct aas_predictroute_s*/ *route, int areanum, vec3_t origin,\n\t\t\t\t\t\t\tint goalareanum, int travelflags, int maxareas, int maxtime,\n\t\t\t\t\t\t\tint stopevent, int stopcontents, int stoptfl, int stopareanum);\n\nint\t\ttrap_AAS_AlternativeRouteGoals(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags,\n\t\t\t\t\t\t\t\t\t\tvoid /*struct aas_altroutegoal_s*/ *altroutegoals, int maxaltroutegoals,\n\t\t\t\t\t\t\t\t\t\tint type);\nint\t\ttrap_AAS_Swimming(vec3_t origin);\nint\t\ttrap_AAS_PredictClientMovement(void /* aas_clientmove_s */ *move, int entnum, vec3_t origin, int presencetype, int onground, vec3_t velocity, vec3_t cmdmove, int cmdframes, int maxframes, float frametime, int stopevent, int stopareanum, int visualize);\n\n\nvoid\ttrap_EA_Say(int client, char *str);\nvoid\ttrap_EA_SayTeam(int client, char *str);\nvoid\ttrap_EA_Command(int client, char *command);\n\nvoid\ttrap_EA_Action(int client, int action);\nvoid\ttrap_EA_Gesture(int client);\nvoid\ttrap_EA_Talk(int client);\nvoid\ttrap_EA_Attack(int client);\nvoid\ttrap_EA_Use(int client);\nvoid\ttrap_EA_Respawn(int client);\nvoid\ttrap_EA_Crouch(int client);\nvoid\ttrap_EA_MoveUp(int client);\nvoid\ttrap_EA_MoveDown(int client);\nvoid\ttrap_EA_MoveForward(int client);\nvoid\ttrap_EA_MoveBack(int client);\nvoid\ttrap_EA_MoveLeft(int client);\nvoid\ttrap_EA_MoveRight(int client);\nvoid\ttrap_EA_SelectWeapon(int client, int weapon);\nvoid\ttrap_EA_Jump(int client);\nvoid\ttrap_EA_DelayedJump(int client);\nvoid\ttrap_EA_Move(int client, vec3_t dir, float speed);\nvoid\ttrap_EA_View(int client, vec3_t viewangles);\n\nvoid\ttrap_EA_EndRegular(int client, float thinktime);\nvoid\ttrap_EA_GetInput(int client, float thinktime, void /* struct bot_input_s */ *input);\nvoid\ttrap_EA_ResetInput(int client);\n\n\nint\t\ttrap_BotLoadCharacter(char *charfile, float skill);\nvoid\ttrap_BotFreeCharacter(int character);\nfloat\ttrap_Characteristic_Float(int character, int index);\nfloat\ttrap_Characteristic_BFloat(int character, int index, float min, float max);\nint\t\ttrap_Characteristic_Integer(int character, int index);\nint\t\ttrap_Characteristic_BInteger(int character, int index, int min, int max);\nvoid\ttrap_Characteristic_String(int character, int index, char *buf, int size);\n\nint\t\ttrap_BotAllocChatState(void);\nvoid\ttrap_BotFreeChatState(int handle);\nvoid\ttrap_BotQueueConsoleMessage(int chatstate, int type, char *message);\nvoid\ttrap_BotRemoveConsoleMessage(int chatstate, int handle);\nint\t\ttrap_BotNextConsoleMessage(int chatstate, void /* struct bot_consolemessage_s */ *cm);\nint\t\ttrap_BotNumConsoleMessages(int chatstate);\nvoid\ttrap_BotInitialChat(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7 );\nint\t\ttrap_BotNumInitialChats(int chatstate, char *type);\nint\t\ttrap_BotReplyChat(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7 );\nint\t\ttrap_BotChatLength(int chatstate);\nvoid\ttrap_BotEnterChat(int chatstate, int client, int sendto);\nvoid\ttrap_BotGetChatMessage(int chatstate, char *buf, int size);\nint\t\ttrap_StringContains(char *str1, char *str2, int casesensitive);\nint\t\ttrap_BotFindMatch(char *str, void /* struct bot_match_s */ *match, unsigned long int context);\nvoid\ttrap_BotMatchVariable(void /* struct bot_match_s */ *match, int variable, char *buf, int size);\nvoid\ttrap_UnifyWhiteSpaces(char *string);\nvoid\ttrap_BotReplaceSynonyms(char *string, unsigned long int context);\nint\t\ttrap_BotLoadChatFile(int chatstate, char *chatfile, char *chatname);\nvoid\ttrap_BotSetChatGender(int chatstate, int gender);\nvoid\ttrap_BotSetChatName(int chatstate, char *name, int client);\nvoid\ttrap_BotResetGoalState(int goalstate);\nvoid\ttrap_BotRemoveFromAvoidGoals(int goalstate, int number);\nvoid\ttrap_BotResetAvoidGoals(int goalstate);\nvoid\ttrap_BotPushGoal(int goalstate, void /* struct bot_goal_s */ *goal);\nvoid\ttrap_BotPopGoal(int goalstate);\nvoid\ttrap_BotEmptyGoalStack(int goalstate);\nvoid\ttrap_BotDumpAvoidGoals(int goalstate);\nvoid\ttrap_BotDumpGoalStack(int goalstate);\nvoid\ttrap_BotGoalName(int number, char *name, int size);\nint\t\ttrap_BotGetTopGoal(int goalstate, void /* struct bot_goal_s */ *goal);\nint\t\ttrap_BotGetSecondGoal(int goalstate, void /* struct bot_goal_s */ *goal);\nint\t\ttrap_BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelflags);\nint\t\ttrap_BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelflags, void /* struct bot_goal_s */ *ltg, float maxtime);\nint\t\ttrap_BotTouchingGoal(vec3_t origin, void /* struct bot_goal_s */ *goal);\nint\t\ttrap_BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, void /* struct bot_goal_s */ *goal);\nint\t\ttrap_BotGetNextCampSpotGoal(int num, void /* struct bot_goal_s */ *goal);\nint\t\ttrap_BotGetMapLocationGoal(char *name, void /* struct bot_goal_s */ *goal);\nint\t\ttrap_BotGetLevelItemGoal(int index, char *classname, void /* struct bot_goal_s */ *goal);\nfloat\ttrap_BotAvoidGoalTime(int goalstate, int number);\nvoid\ttrap_BotSetAvoidGoalTime(int goalstate, int number, float avoidtime);\nvoid\ttrap_BotInitLevelItems(void);\nvoid\ttrap_BotUpdateEntityItems(void);\nint\t\ttrap_BotLoadItemWeights(int goalstate, char *filename);\nvoid\ttrap_BotFreeItemWeights(int goalstate);\nvoid\ttrap_BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child);\nvoid\ttrap_BotSaveGoalFuzzyLogic(int goalstate, char *filename);\nvoid\ttrap_BotMutateGoalFuzzyLogic(int goalstate, float range);\nint\t\ttrap_BotAllocGoalState(int state);\nvoid\ttrap_BotFreeGoalState(int handle);\n\nvoid\ttrap_BotResetMoveState(int movestate);\nvoid\ttrap_BotMoveToGoal(void /* struct bot_moveresult_s */ *result, int movestate, void /* struct bot_goal_s */ *goal, int travelflags);\nint\t\ttrap_BotMoveInDirection(int movestate, vec3_t dir, float speed, int type);\nvoid\ttrap_BotResetAvoidReach(int movestate);\nvoid\ttrap_BotResetLastAvoidReach(int movestate);\nint\t\ttrap_BotReachabilityArea(vec3_t origin, int testground);\nint\t\ttrap_BotMovementViewTarget(int movestate, void /* struct bot_goal_s */ *goal, int travelflags, float lookahead, vec3_t target);\nint\t\ttrap_BotPredictVisiblePosition(vec3_t origin, int areanum, void /* struct bot_goal_s */ *goal, int travelflags, vec3_t target);\nint\t\ttrap_BotAllocMoveState(void);\nvoid\ttrap_BotFreeMoveState(int handle);\nvoid\ttrap_BotInitMoveState(int handle, void /* struct bot_initmove_s */ *initmove);\nvoid\ttrap_BotAddAvoidSpot(int movestate, vec3_t origin, float radius, int type);\n\nint\t\ttrap_BotChooseBestFightWeapon(int weaponstate, int *inventory);\nvoid\ttrap_BotGetWeaponInfo(int weaponstate, int weapon, void /* struct weaponinfo_s */ *weaponinfo);\nint\t\ttrap_BotLoadWeaponWeights(int weaponstate, char *filename);\nint\t\ttrap_BotAllocWeaponState(void);\nvoid\ttrap_BotFreeWeaponState(int weaponstate);\nvoid\ttrap_BotResetWeaponState(int weaponstate);\n\nint\t\ttrap_GeneticParentsAndChildSelection(int numranks, float *ranks, int *parent1, int *parent2, int *child);\n\nvoid\ttrap_SnapVector( float *v );\n\n"
  },
  {
    "path": "code/game/g_main.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n#include \"g_local.h\"\n\nlevel_locals_t\tlevel;\n\ntypedef struct {\n\tvmCvar_t\t*vmCvar;\n\tchar\t\t*cvarName;\n\tchar\t\t*defaultString;\n\tint\t\t\tcvarFlags;\n\tint\t\t\tmodificationCount;  // for tracking changes\n\tqboolean\ttrackChange;\t    // track this variable, and announce if changed\n  qboolean teamShader;        // track and if changed, update shader state\n} cvarTable_t;\n\ngentity_t\t\tg_entities[MAX_GENTITIES];\ngclient_t\t\tg_clients[MAX_CLIENTS];\n\nvmCvar_t\tg_gametype;\nvmCvar_t\tg_dmflags;\nvmCvar_t\tg_fraglimit;\nvmCvar_t\tg_timelimit;\nvmCvar_t\tg_capturelimit;\nvmCvar_t\tg_friendlyFire;\nvmCvar_t\tg_password;\nvmCvar_t\tg_needpass;\nvmCvar_t\tg_maxclients;\nvmCvar_t\tg_maxGameClients;\nvmCvar_t\tg_dedicated;\nvmCvar_t\tg_speed;\nvmCvar_t\tg_gravity;\nvmCvar_t\tg_cheats;\nvmCvar_t\tg_knockback;\nvmCvar_t\tg_quadfactor;\nvmCvar_t\tg_forcerespawn;\nvmCvar_t\tg_inactivity;\nvmCvar_t\tg_debugMove;\nvmCvar_t\tg_debugDamage;\nvmCvar_t\tg_debugAlloc;\nvmCvar_t\tg_weaponRespawn;\nvmCvar_t\tg_weaponTeamRespawn;\nvmCvar_t\tg_motd;\nvmCvar_t\tg_synchronousClients;\nvmCvar_t\tg_warmup;\nvmCvar_t\tg_doWarmup;\nvmCvar_t\tg_restarted;\nvmCvar_t\tg_log;\nvmCvar_t\tg_logSync;\nvmCvar_t\tg_blood;\nvmCvar_t\tg_podiumDist;\nvmCvar_t\tg_podiumDrop;\nvmCvar_t\tg_allowVote;\nvmCvar_t\tg_teamAutoJoin;\nvmCvar_t\tg_teamForceBalance;\nvmCvar_t\tg_banIPs;\nvmCvar_t\tg_filterBan;\nvmCvar_t\tg_smoothClients;\nvmCvar_t\tpmove_fixed;\nvmCvar_t\tpmove_msec;\nvmCvar_t\tg_rankings;\nvmCvar_t\tg_listEntity;\n#ifdef MISSIONPACK\nvmCvar_t\tg_obeliskHealth;\nvmCvar_t\tg_obeliskRegenPeriod;\nvmCvar_t\tg_obeliskRegenAmount;\nvmCvar_t\tg_obeliskRespawnDelay;\nvmCvar_t\tg_cubeTimeout;\nvmCvar_t\tg_redteam;\nvmCvar_t\tg_blueteam;\nvmCvar_t\tg_singlePlayer;\nvmCvar_t\tg_enableDust;\nvmCvar_t\tg_enableBreath;\nvmCvar_t\tg_proxMineTimeout;\n#endif\n\n// bk001129 - made static to avoid aliasing\nstatic cvarTable_t\t\tgameCvarTable[] = {\n\t// don't override the cheat state set by the system\n\t{ &g_cheats, \"sv_cheats\", \"\", 0, 0, qfalse },\n\n\t// noset vars\n\t{ NULL, \"gamename\", GAMEVERSION , CVAR_SERVERINFO | CVAR_ROM, 0, qfalse  },\n\t{ NULL, \"gamedate\", __DATE__ , CVAR_ROM, 0, qfalse  },\n\t{ &g_restarted, \"g_restarted\", \"0\", CVAR_ROM, 0, qfalse  },\n\t{ NULL, \"sv_mapname\", \"\", CVAR_SERVERINFO | CVAR_ROM, 0, qfalse  },\n\n\t// latched vars\n\t{ &g_gametype, \"g_gametype\", \"0\", CVAR_SERVERINFO | CVAR_USERINFO | CVAR_LATCH, 0, qfalse  },\n\n\t{ &g_maxclients, \"sv_maxclients\", \"8\", CVAR_SERVERINFO | CVAR_LATCH | CVAR_ARCHIVE, 0, qfalse  },\n\t{ &g_maxGameClients, \"g_maxGameClients\", \"0\", CVAR_SERVERINFO | CVAR_LATCH | CVAR_ARCHIVE, 0, qfalse  },\n\n\t// change anytime vars\n\t{ &g_dmflags, \"dmflags\", \"0\", CVAR_SERVERINFO | CVAR_ARCHIVE, 0, qtrue  },\n\t{ &g_fraglimit, \"fraglimit\", \"20\", CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_NORESTART, 0, qtrue },\n\t{ &g_timelimit, \"timelimit\", \"0\", CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_NORESTART, 0, qtrue },\n\t{ &g_capturelimit, \"capturelimit\", \"8\", CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_NORESTART, 0, qtrue },\n\n\t{ &g_synchronousClients, \"g_synchronousClients\", \"0\", CVAR_SYSTEMINFO, 0, qfalse  },\n\n\t{ &g_friendlyFire, \"g_friendlyFire\", \"0\", CVAR_ARCHIVE, 0, qtrue  },\n\n\t{ &g_teamAutoJoin, \"g_teamAutoJoin\", \"0\", CVAR_ARCHIVE  },\n\t{ &g_teamForceBalance, \"g_teamForceBalance\", \"0\", CVAR_ARCHIVE  },\n\n\t{ &g_warmup, \"g_warmup\", \"20\", CVAR_ARCHIVE, 0, qtrue  },\n\t{ &g_doWarmup, \"g_doWarmup\", \"0\", 0, 0, qtrue  },\n\t{ &g_log, \"g_log\", \"games.log\", CVAR_ARCHIVE, 0, qfalse  },\n\t{ &g_logSync, \"g_logSync\", \"0\", CVAR_ARCHIVE, 0, qfalse  },\n\n\t{ &g_password, \"g_password\", \"\", CVAR_USERINFO, 0, qfalse  },\n\n\t{ &g_banIPs, \"g_banIPs\", \"\", CVAR_ARCHIVE, 0, qfalse  },\n\t{ &g_filterBan, \"g_filterBan\", \"1\", CVAR_ARCHIVE, 0, qfalse  },\n\n\t{ &g_needpass, \"g_needpass\", \"0\", CVAR_SERVERINFO | CVAR_ROM, 0, qfalse },\n\n\t{ &g_dedicated, \"dedicated\", \"0\", 0, 0, qfalse  },\n\n\t{ &g_speed, \"g_speed\", \"320\", 0, 0, qtrue  },\n\t{ &g_gravity, \"g_gravity\", \"800\", 0, 0, qtrue  },\n\t{ &g_knockback, \"g_knockback\", \"1000\", 0, 0, qtrue  },\n\t{ &g_quadfactor, \"g_quadfactor\", \"3\", 0, 0, qtrue  },\n\t{ &g_weaponRespawn, \"g_weaponrespawn\", \"5\", 0, 0, qtrue  },\n\t{ &g_weaponTeamRespawn, \"g_weaponTeamRespawn\", \"30\", 0, 0, qtrue },\n\t{ &g_forcerespawn, \"g_forcerespawn\", \"20\", 0, 0, qtrue },\n\t{ &g_inactivity, \"g_inactivity\", \"0\", 0, 0, qtrue },\n\t{ &g_debugMove, \"g_debugMove\", \"0\", 0, 0, qfalse },\n\t{ &g_debugDamage, \"g_debugDamage\", \"0\", 0, 0, qfalse },\n\t{ &g_debugAlloc, \"g_debugAlloc\", \"0\", 0, 0, qfalse },\n\t{ &g_motd, \"g_motd\", \"\", 0, 0, qfalse },\n\t{ &g_blood, \"com_blood\", \"1\", 0, 0, qfalse },\n\n\t{ &g_podiumDist, \"g_podiumDist\", \"80\", 0, 0, qfalse },\n\t{ &g_podiumDrop, \"g_podiumDrop\", \"70\", 0, 0, qfalse },\n\n\t{ &g_allowVote, \"g_allowVote\", \"1\", CVAR_ARCHIVE, 0, qfalse },\n\t{ &g_listEntity, \"g_listEntity\", \"0\", 0, 0, qfalse },\n\n#ifdef MISSIONPACK\n\t{ &g_obeliskHealth, \"g_obeliskHealth\", \"2500\", 0, 0, qfalse },\n\t{ &g_obeliskRegenPeriod, \"g_obeliskRegenPeriod\", \"1\", 0, 0, qfalse },\n\t{ &g_obeliskRegenAmount, \"g_obeliskRegenAmount\", \"15\", 0, 0, qfalse },\n\t{ &g_obeliskRespawnDelay, \"g_obeliskRespawnDelay\", \"10\", CVAR_SERVERINFO, 0, qfalse },\n\n\t{ &g_cubeTimeout, \"g_cubeTimeout\", \"30\", 0, 0, qfalse },\n\t{ &g_redteam, \"g_redteam\", \"Stroggs\", CVAR_ARCHIVE | CVAR_SERVERINFO | CVAR_USERINFO , 0, qtrue, qtrue },\n\t{ &g_blueteam, \"g_blueteam\", \"Pagans\", CVAR_ARCHIVE | CVAR_SERVERINFO | CVAR_USERINFO , 0, qtrue, qtrue  },\n\t{ &g_singlePlayer, \"ui_singlePlayerActive\", \"\", 0, 0, qfalse, qfalse  },\n\n\t{ &g_enableDust, \"g_enableDust\", \"0\", CVAR_SERVERINFO, 0, qtrue, qfalse },\n\t{ &g_enableBreath, \"g_enableBreath\", \"0\", CVAR_SERVERINFO, 0, qtrue, qfalse },\n\t{ &g_proxMineTimeout, \"g_proxMineTimeout\", \"20000\", 0, 0, qfalse },\n#endif\n\t{ &g_smoothClients, \"g_smoothClients\", \"1\", 0, 0, qfalse},\n\t{ &pmove_fixed, \"pmove_fixed\", \"0\", CVAR_SYSTEMINFO, 0, qfalse},\n\t{ &pmove_msec, \"pmove_msec\", \"8\", CVAR_SYSTEMINFO, 0, qfalse},\n\n\t{ &g_rankings, \"g_rankings\", \"0\", 0, 0, qfalse}\n\n};\n\n// bk001129 - made static to avoid aliasing\nstatic int gameCvarTableSize = sizeof( gameCvarTable ) / sizeof( gameCvarTable[0] );\n\n\nvoid G_InitGame( int levelTime, int randomSeed, int restart );\nvoid G_RunFrame( int levelTime );\nvoid G_ShutdownGame( int restart );\nvoid CheckExitRules( void );\n\n\n/*\n================\nvmMain\n\nThis is the only way control passes into the module.\nThis must be the very first function compiled into the .q3vm file\n================\n*/\nint vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11  ) {\n\tswitch ( command ) {\n\tcase GAME_INIT:\n\t\tG_InitGame( arg0, arg1, arg2 );\n\t\treturn 0;\n\tcase GAME_SHUTDOWN:\n\t\tG_ShutdownGame( arg0 );\n\t\treturn 0;\n\tcase GAME_CLIENT_CONNECT:\n\t\treturn (int)ClientConnect( arg0, arg1, arg2 );\n\tcase GAME_CLIENT_THINK:\n\t\tClientThink( arg0 );\n\t\treturn 0;\n\tcase GAME_CLIENT_USERINFO_CHANGED:\n\t\tClientUserinfoChanged( arg0 );\n\t\treturn 0;\n\tcase GAME_CLIENT_DISCONNECT:\n\t\tClientDisconnect( arg0 );\n\t\treturn 0;\n\tcase GAME_CLIENT_BEGIN:\n\t\tClientBegin( arg0 );\n\t\treturn 0;\n\tcase GAME_CLIENT_COMMAND:\n\t\tClientCommand( arg0 );\n\t\treturn 0;\n\tcase GAME_RUN_FRAME:\n\t\tG_RunFrame( arg0 );\n\t\treturn 0;\n\tcase GAME_CONSOLE_COMMAND:\n\t\treturn ConsoleCommand();\n\tcase BOTAI_START_FRAME:\n\t\treturn BotAIStartFrame( arg0 );\n\t}\n\n\treturn -1;\n}\n\n\nvoid QDECL G_Printf( const char *fmt, ... ) {\n\tva_list\t\targptr;\n\tchar\t\ttext[1024];\n\n\tva_start (argptr, fmt);\n\tvsprintf (text, fmt, argptr);\n\tva_end (argptr);\n\n\ttrap_Printf( text );\n}\n\nvoid QDECL G_Error( const char *fmt, ... ) {\n\tva_list\t\targptr;\n\tchar\t\ttext[1024];\n\n\tva_start (argptr, fmt);\n\tvsprintf (text, fmt, argptr);\n\tva_end (argptr);\n\n\ttrap_Error( text );\n}\n\n/*\n================\nG_FindTeams\n\nChain together all entities with a matching team field.\nEntity teams are used for item groups and multi-entity mover groups.\n\nAll but the first will have the FL_TEAMSLAVE flag set and teammaster field set\nAll but the last will have the teamchain field set to the next one\n================\n*/\nvoid G_FindTeams( void ) {\n\tgentity_t\t*e, *e2;\n\tint\t\ti, j;\n\tint\t\tc, c2;\n\n\tc = 0;\n\tc2 = 0;\n\tfor ( i=1, e=g_entities+i ; i < level.num_entities ; i++,e++ ){\n\t\tif (!e->inuse)\n\t\t\tcontinue;\n\t\tif (!e->team)\n\t\t\tcontinue;\n\t\tif (e->flags & FL_TEAMSLAVE)\n\t\t\tcontinue;\n\t\te->teammaster = e;\n\t\tc++;\n\t\tc2++;\n\t\tfor (j=i+1, e2=e+1 ; j < level.num_entities ; j++,e2++)\n\t\t{\n\t\t\tif (!e2->inuse)\n\t\t\t\tcontinue;\n\t\t\tif (!e2->team)\n\t\t\t\tcontinue;\n\t\t\tif (e2->flags & FL_TEAMSLAVE)\n\t\t\t\tcontinue;\n\t\t\tif (!strcmp(e->team, e2->team))\n\t\t\t{\n\t\t\t\tc2++;\n\t\t\t\te2->teamchain = e->teamchain;\n\t\t\t\te->teamchain = e2;\n\t\t\t\te2->teammaster = e;\n\t\t\t\te2->flags |= FL_TEAMSLAVE;\n\n\t\t\t\t// make sure that targets only point at the master\n\t\t\t\tif ( e2->targetname ) {\n\t\t\t\t\te->targetname = e2->targetname;\n\t\t\t\t\te2->targetname = NULL;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tG_Printf (\"%i teams with %i entities\\n\", c, c2);\n}\n\nvoid G_RemapTeamShaders() {\n#ifdef MISSIONPACK\n\tchar string[1024];\n\tfloat f = level.time * 0.001;\n\tCom_sprintf( string, sizeof(string), \"team_icon/%s_red\", g_redteam.string );\n\tAddRemap(\"textures/ctf2/redteam01\", string, f); \n\tAddRemap(\"textures/ctf2/redteam02\", string, f); \n\tCom_sprintf( string, sizeof(string), \"team_icon/%s_blue\", g_blueteam.string );\n\tAddRemap(\"textures/ctf2/blueteam01\", string, f); \n\tAddRemap(\"textures/ctf2/blueteam02\", string, f); \n\ttrap_SetConfigstring(CS_SHADERSTATE, BuildShaderStateConfig());\n#endif\n}\n\n\n/*\n=================\nG_RegisterCvars\n=================\n*/\nvoid G_RegisterCvars( void ) {\n\tint\t\t\ti;\n\tcvarTable_t\t*cv;\n\tqboolean remapped = qfalse;\n\n\tfor ( i = 0, cv = gameCvarTable ; i < gameCvarTableSize ; i++, cv++ ) {\n\t\ttrap_Cvar_Register( cv->vmCvar, cv->cvarName,\n\t\t\tcv->defaultString, cv->cvarFlags );\n\t\tif ( cv->vmCvar )\n\t\t\tcv->modificationCount = cv->vmCvar->modificationCount;\n\n\t\tif (cv->teamShader) {\n\t\t\tremapped = qtrue;\n\t\t}\n\t}\n\n\tif (remapped) {\n\t\tG_RemapTeamShaders();\n\t}\n\n\t// check some things\n\tif ( g_gametype.integer < 0 || g_gametype.integer >= GT_MAX_GAME_TYPE ) {\n\t\tG_Printf( \"g_gametype %i is out of range, defaulting to 0\\n\", g_gametype.integer );\n\t\ttrap_Cvar_Set( \"g_gametype\", \"0\" );\n\t}\n\n\tlevel.warmupModificationCount = g_warmup.modificationCount;\n}\n\n/*\n=================\nG_UpdateCvars\n=================\n*/\nvoid G_UpdateCvars( void ) {\n\tint\t\t\ti;\n\tcvarTable_t\t*cv;\n\tqboolean remapped = qfalse;\n\n\tfor ( i = 0, cv = gameCvarTable ; i < gameCvarTableSize ; i++, cv++ ) {\n\t\tif ( cv->vmCvar ) {\n\t\t\ttrap_Cvar_Update( cv->vmCvar );\n\n\t\t\tif ( cv->modificationCount != cv->vmCvar->modificationCount ) {\n\t\t\t\tcv->modificationCount = cv->vmCvar->modificationCount;\n\n\t\t\t\tif ( cv->trackChange ) {\n\t\t\t\t\ttrap_SendServerCommand( -1, va(\"print \\\"Server: %s changed to %s\\n\\\"\", \n\t\t\t\t\t\tcv->cvarName, cv->vmCvar->string ) );\n\t\t\t\t}\n\n\t\t\t\tif (cv->teamShader) {\n\t\t\t\t\tremapped = qtrue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (remapped) {\n\t\tG_RemapTeamShaders();\n\t}\n}\n\n/*\n============\nG_InitGame\n\n============\n*/\nvoid G_InitGame( int levelTime, int randomSeed, int restart ) {\n\tint\t\t\t\t\ti;\n\n\tG_Printf (\"------- Game Initialization -------\\n\");\n\tG_Printf (\"gamename: %s\\n\", GAMEVERSION);\n\tG_Printf (\"gamedate: %s\\n\", __DATE__);\n\n\tsrand( randomSeed );\n\n\tG_RegisterCvars();\n\n\tG_ProcessIPBans();\n\n\tG_InitMemory();\n\n\t// set some level globals\n\tmemset( &level, 0, sizeof( level ) );\n\tlevel.time = levelTime;\n\tlevel.startTime = levelTime;\n\n\tlevel.snd_fry = G_SoundIndex(\"sound/player/fry.wav\");\t// FIXME standing in lava / slime\n\n\tif ( g_gametype.integer != GT_SINGLE_PLAYER && g_log.string[0] ) {\n\t\tif ( g_logSync.integer ) {\n\t\t\ttrap_FS_FOpenFile( g_log.string, &level.logFile, FS_APPEND_SYNC );\n\t\t} else {\n\t\t\ttrap_FS_FOpenFile( g_log.string, &level.logFile, FS_APPEND );\n\t\t}\n\t\tif ( !level.logFile ) {\n\t\t\tG_Printf( \"WARNING: Couldn't open logfile: %s\\n\", g_log.string );\n\t\t} else {\n\t\t\tchar\tserverinfo[MAX_INFO_STRING];\n\n\t\t\ttrap_GetServerinfo( serverinfo, sizeof( serverinfo ) );\n\n\t\t\tG_LogPrintf(\"------------------------------------------------------------\\n\" );\n\t\t\tG_LogPrintf(\"InitGame: %s\\n\", serverinfo );\n\t\t}\n\t} else {\n\t\tG_Printf( \"Not logging to disk.\\n\" );\n\t}\n\n\tG_InitWorldSession();\n\n\t// initialize all entities for this game\n\tmemset( g_entities, 0, MAX_GENTITIES * sizeof(g_entities[0]) );\n\tlevel.gentities = g_entities;\n\n\t// initialize all clients for this game\n\tlevel.maxclients = g_maxclients.integer;\n\tmemset( g_clients, 0, MAX_CLIENTS * sizeof(g_clients[0]) );\n\tlevel.clients = g_clients;\n\n\t// set client fields on player ents\n\tfor ( i=0 ; i<level.maxclients ; i++ ) {\n\t\tg_entities[i].client = level.clients + i;\n\t}\n\n\t// always leave room for the max number of clients,\n\t// even if they aren't all used, so numbers inside that\n\t// range are NEVER anything but clients\n\tlevel.num_entities = MAX_CLIENTS;\n\n\t// let the server system know where the entites are\n\ttrap_LocateGameData( level.gentities, level.num_entities, sizeof( gentity_t ), \n\t\t&level.clients[0].ps, sizeof( level.clients[0] ) );\n\n\t// reserve some spots for dead player bodies\n\tInitBodyQue();\n\n\tClearRegisteredItems();\n\n\t// parse the key/value pairs and spawn gentities\n\tG_SpawnEntitiesFromString();\n\n\t// general initialization\n\tG_FindTeams();\n\n\t// make sure we have flags for CTF, etc\n\tif( g_gametype.integer >= GT_TEAM ) {\n\t\tG_CheckTeamItems();\n\t}\n\n\tSaveRegisteredItems();\n\n\tG_Printf (\"-----------------------------------\\n\");\n\n\tif( g_gametype.integer == GT_SINGLE_PLAYER || trap_Cvar_VariableIntegerValue( \"com_buildScript\" ) ) {\n\t\tG_ModelIndex( SP_PODIUM_MODEL );\n\t\tG_SoundIndex( \"sound/player/gurp1.wav\" );\n\t\tG_SoundIndex( \"sound/player/gurp2.wav\" );\n\t}\n\n\tif ( trap_Cvar_VariableIntegerValue( \"bot_enable\" ) ) {\n\t\tBotAISetup( restart );\n\t\tBotAILoadMap( restart );\n\t\tG_InitBots( restart );\n\t}\n\n\tG_RemapTeamShaders();\n\n}\n\n\n\n/*\n=================\nG_ShutdownGame\n=================\n*/\nvoid G_ShutdownGame( int restart ) {\n\tG_Printf (\"==== ShutdownGame ====\\n\");\n\n\tif ( level.logFile ) {\n\t\tG_LogPrintf(\"ShutdownGame:\\n\" );\n\t\tG_LogPrintf(\"------------------------------------------------------------\\n\" );\n\t\ttrap_FS_FCloseFile( level.logFile );\n\t}\n\n\t// write all the client session data so we can get it back\n\tG_WriteSessionData();\n\n\tif ( trap_Cvar_VariableIntegerValue( \"bot_enable\" ) ) {\n\t\tBotAIShutdown( restart );\n\t}\n}\n\n\n\n//===================================================================\n\n#ifndef GAME_HARD_LINKED\n// this is only here so the functions in q_shared.c and bg_*.c can link\n\nvoid QDECL Com_Error ( int level, const char *error, ... ) {\n\tva_list\t\targptr;\n\tchar\t\ttext[1024];\n\n\tva_start (argptr, error);\n\tvsprintf (text, error, argptr);\n\tva_end (argptr);\n\n\tG_Error( \"%s\", text);\n}\n\nvoid QDECL Com_Printf( const char *msg, ... ) {\n\tva_list\t\targptr;\n\tchar\t\ttext[1024];\n\n\tva_start (argptr, msg);\n\tvsprintf (text, msg, argptr);\n\tva_end (argptr);\n\n\tG_Printf (\"%s\", text);\n}\n\n#endif\n\n/*\n========================================================================\n\nPLAYER COUNTING / SCORE SORTING\n\n========================================================================\n*/\n\n/*\n=============\nAddTournamentPlayer\n\nIf there are less than two tournament players, put a\nspectator in the game and restart\n=============\n*/\nvoid AddTournamentPlayer( void ) {\n\tint\t\t\ti;\n\tgclient_t\t*client;\n\tgclient_t\t*nextInLine;\n\n\tif ( level.numPlayingClients >= 2 ) {\n\t\treturn;\n\t}\n\n\t// never change during intermission\n\tif ( level.intermissiontime ) {\n\t\treturn;\n\t}\n\n\tnextInLine = NULL;\n\n\tfor ( i = 0 ; i < level.maxclients ; i++ ) {\n\t\tclient = &level.clients[i];\n\t\tif ( client->pers.connected != CON_CONNECTED ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( client->sess.sessionTeam != TEAM_SPECTATOR ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// never select the dedicated follow or scoreboard clients\n\t\tif ( client->sess.spectatorState == SPECTATOR_SCOREBOARD || \n\t\t\tclient->sess.spectatorClient < 0  ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( !nextInLine || client->sess.spectatorTime < nextInLine->sess.spectatorTime ) {\n\t\t\tnextInLine = client;\n\t\t}\n\t}\n\n\tif ( !nextInLine ) {\n\t\treturn;\n\t}\n\n\tlevel.warmupTime = -1;\n\n\t// set them to free-for-all team\n\tSetTeam( &g_entities[ nextInLine - level.clients ], \"f\" );\n}\n\n/*\n=======================\nRemoveTournamentLoser\n\nMake the loser a spectator at the back of the line\n=======================\n*/\nvoid RemoveTournamentLoser( void ) {\n\tint\t\t\tclientNum;\n\n\tif ( level.numPlayingClients != 2 ) {\n\t\treturn;\n\t}\n\n\tclientNum = level.sortedClients[1];\n\n\tif ( level.clients[ clientNum ].pers.connected != CON_CONNECTED ) {\n\t\treturn;\n\t}\n\n\t// make them a spectator\n\tSetTeam( &g_entities[ clientNum ], \"s\" );\n}\n\n/*\n=======================\nRemoveTournamentWinner\n=======================\n*/\nvoid RemoveTournamentWinner( void ) {\n\tint\t\t\tclientNum;\n\n\tif ( level.numPlayingClients != 2 ) {\n\t\treturn;\n\t}\n\n\tclientNum = level.sortedClients[0];\n\n\tif ( level.clients[ clientNum ].pers.connected != CON_CONNECTED ) {\n\t\treturn;\n\t}\n\n\t// make them a spectator\n\tSetTeam( &g_entities[ clientNum ], \"s\" );\n}\n\n/*\n=======================\nAdjustTournamentScores\n=======================\n*/\nvoid AdjustTournamentScores( void ) {\n\tint\t\t\tclientNum;\n\n\tclientNum = level.sortedClients[0];\n\tif ( level.clients[ clientNum ].pers.connected == CON_CONNECTED ) {\n\t\tlevel.clients[ clientNum ].sess.wins++;\n\t\tClientUserinfoChanged( clientNum );\n\t}\n\n\tclientNum = level.sortedClients[1];\n\tif ( level.clients[ clientNum ].pers.connected == CON_CONNECTED ) {\n\t\tlevel.clients[ clientNum ].sess.losses++;\n\t\tClientUserinfoChanged( clientNum );\n\t}\n\n}\n\n/*\n=============\nSortRanks\n\n=============\n*/\nint QDECL SortRanks( const void *a, const void *b ) {\n\tgclient_t\t*ca, *cb;\n\n\tca = &level.clients[*(int *)a];\n\tcb = &level.clients[*(int *)b];\n\n\t// sort special clients last\n\tif ( ca->sess.spectatorState == SPECTATOR_SCOREBOARD || ca->sess.spectatorClient < 0 ) {\n\t\treturn 1;\n\t}\n\tif ( cb->sess.spectatorState == SPECTATOR_SCOREBOARD || cb->sess.spectatorClient < 0  ) {\n\t\treturn -1;\n\t}\n\n\t// then connecting clients\n\tif ( ca->pers.connected == CON_CONNECTING ) {\n\t\treturn 1;\n\t}\n\tif ( cb->pers.connected == CON_CONNECTING ) {\n\t\treturn -1;\n\t}\n\n\n\t// then spectators\n\tif ( ca->sess.sessionTeam == TEAM_SPECTATOR && cb->sess.sessionTeam == TEAM_SPECTATOR ) {\n\t\tif ( ca->sess.spectatorTime < cb->sess.spectatorTime ) {\n\t\t\treturn -1;\n\t\t}\n\t\tif ( ca->sess.spectatorTime > cb->sess.spectatorTime ) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t}\n\tif ( ca->sess.sessionTeam == TEAM_SPECTATOR ) {\n\t\treturn 1;\n\t}\n\tif ( cb->sess.sessionTeam == TEAM_SPECTATOR ) {\n\t\treturn -1;\n\t}\n\n\t// then sort by score\n\tif ( ca->ps.persistant[PERS_SCORE]\n\t\t> cb->ps.persistant[PERS_SCORE] ) {\n\t\treturn -1;\n\t}\n\tif ( ca->ps.persistant[PERS_SCORE]\n\t\t< cb->ps.persistant[PERS_SCORE] ) {\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\n/*\n============\nCalculateRanks\n\nRecalculates the score ranks of all players\nThis will be called on every client connect, begin, disconnect, death,\nand team change.\n============\n*/\nvoid CalculateRanks( void ) {\n\tint\t\ti;\n\tint\t\trank;\n\tint\t\tscore;\n\tint\t\tnewScore;\n\tgclient_t\t*cl;\n\n\tlevel.follow1 = -1;\n\tlevel.follow2 = -1;\n\tlevel.numConnectedClients = 0;\n\tlevel.numNonSpectatorClients = 0;\n\tlevel.numPlayingClients = 0;\n\tlevel.numVotingClients = 0;\t\t// don't count bots\n\tfor ( i = 0; i < TEAM_NUM_TEAMS; i++ ) {\n\t\tlevel.numteamVotingClients[i] = 0;\n\t}\n\tfor ( i = 0 ; i < level.maxclients ; i++ ) {\n\t\tif ( level.clients[i].pers.connected != CON_DISCONNECTED ) {\n\t\t\tlevel.sortedClients[level.numConnectedClients] = i;\n\t\t\tlevel.numConnectedClients++;\n\n\t\t\tif ( level.clients[i].sess.sessionTeam != TEAM_SPECTATOR ) {\n\t\t\t\tlevel.numNonSpectatorClients++;\n\t\t\t\n\t\t\t\t// decide if this should be auto-followed\n\t\t\t\tif ( level.clients[i].pers.connected == CON_CONNECTED ) {\n\t\t\t\t\tlevel.numPlayingClients++;\n\t\t\t\t\tif ( !(g_entities[i].r.svFlags & SVF_BOT) ) {\n\t\t\t\t\t\tlevel.numVotingClients++;\n\t\t\t\t\t\tif ( level.clients[i].sess.sessionTeam == TEAM_RED )\n\t\t\t\t\t\t\tlevel.numteamVotingClients[0]++;\n\t\t\t\t\t\telse if ( level.clients[i].sess.sessionTeam == TEAM_BLUE )\n\t\t\t\t\t\t\tlevel.numteamVotingClients[1]++;\n\t\t\t\t\t}\n\t\t\t\t\tif ( level.follow1 == -1 ) {\n\t\t\t\t\t\tlevel.follow1 = i;\n\t\t\t\t\t} else if ( level.follow2 == -1 ) {\n\t\t\t\t\t\tlevel.follow2 = i;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tqsort( level.sortedClients, level.numConnectedClients, \n\t\tsizeof(level.sortedClients[0]), SortRanks );\n\n\t// set the rank value for all clients that are connected and not spectators\n\tif ( g_gametype.integer >= GT_TEAM ) {\n\t\t// in team games, rank is just the order of the teams, 0=red, 1=blue, 2=tied\n\t\tfor ( i = 0;  i < level.numConnectedClients; i++ ) {\n\t\t\tcl = &level.clients[ level.sortedClients[i] ];\n\t\t\tif ( level.teamScores[TEAM_RED] == level.teamScores[TEAM_BLUE] ) {\n\t\t\t\tcl->ps.persistant[PERS_RANK] = 2;\n\t\t\t} else if ( level.teamScores[TEAM_RED] > level.teamScores[TEAM_BLUE] ) {\n\t\t\t\tcl->ps.persistant[PERS_RANK] = 0;\n\t\t\t} else {\n\t\t\t\tcl->ps.persistant[PERS_RANK] = 1;\n\t\t\t}\n\t\t}\n\t} else {\t\n\t\trank = -1;\n\t\tscore = 0;\n\t\tfor ( i = 0;  i < level.numPlayingClients; i++ ) {\n\t\t\tcl = &level.clients[ level.sortedClients[i] ];\n\t\t\tnewScore = cl->ps.persistant[PERS_SCORE];\n\t\t\tif ( i == 0 || newScore != score ) {\n\t\t\t\trank = i;\n\t\t\t\t// assume we aren't tied until the next client is checked\n\t\t\t\tlevel.clients[ level.sortedClients[i] ].ps.persistant[PERS_RANK] = rank;\n\t\t\t} else {\n\t\t\t\t// we are tied with the previous client\n\t\t\t\tlevel.clients[ level.sortedClients[i-1] ].ps.persistant[PERS_RANK] = rank | RANK_TIED_FLAG;\n\t\t\t\tlevel.clients[ level.sortedClients[i] ].ps.persistant[PERS_RANK] = rank | RANK_TIED_FLAG;\n\t\t\t}\n\t\t\tscore = newScore;\n\t\t\tif ( g_gametype.integer == GT_SINGLE_PLAYER && level.numPlayingClients == 1 ) {\n\t\t\t\tlevel.clients[ level.sortedClients[i] ].ps.persistant[PERS_RANK] = rank | RANK_TIED_FLAG;\n\t\t\t}\n\t\t}\n\t}\n\n\t// set the CS_SCORES1/2 configstrings, which will be visible to everyone\n\tif ( g_gametype.integer >= GT_TEAM ) {\n\t\ttrap_SetConfigstring( CS_SCORES1, va(\"%i\", level.teamScores[TEAM_RED] ) );\n\t\ttrap_SetConfigstring( CS_SCORES2, va(\"%i\", level.teamScores[TEAM_BLUE] ) );\n\t} else {\n\t\tif ( level.numConnectedClients == 0 ) {\n\t\t\ttrap_SetConfigstring( CS_SCORES1, va(\"%i\", SCORE_NOT_PRESENT) );\n\t\t\ttrap_SetConfigstring( CS_SCORES2, va(\"%i\", SCORE_NOT_PRESENT) );\n\t\t} else if ( level.numConnectedClients == 1 ) {\n\t\t\ttrap_SetConfigstring( CS_SCORES1, va(\"%i\", level.clients[ level.sortedClients[0] ].ps.persistant[PERS_SCORE] ) );\n\t\t\ttrap_SetConfigstring( CS_SCORES2, va(\"%i\", SCORE_NOT_PRESENT) );\n\t\t} else {\n\t\t\ttrap_SetConfigstring( CS_SCORES1, va(\"%i\", level.clients[ level.sortedClients[0] ].ps.persistant[PERS_SCORE] ) );\n\t\t\ttrap_SetConfigstring( CS_SCORES2, va(\"%i\", level.clients[ level.sortedClients[1] ].ps.persistant[PERS_SCORE] ) );\n\t\t}\n\t}\n\n\t// see if it is time to end the level\n\tCheckExitRules();\n\n\t// if we are at the intermission, send the new info to everyone\n\tif ( level.intermissiontime ) {\n\t\tSendScoreboardMessageToAllClients();\n\t}\n}\n\n\n/*\n========================================================================\n\nMAP CHANGING\n\n========================================================================\n*/\n\n/*\n========================\nSendScoreboardMessageToAllClients\n\nDo this at BeginIntermission time and whenever ranks are recalculated\ndue to enters/exits/forced team changes\n========================\n*/\nvoid SendScoreboardMessageToAllClients( void ) {\n\tint\t\ti;\n\n\tfor ( i = 0 ; i < level.maxclients ; i++ ) {\n\t\tif ( level.clients[ i ].pers.connected == CON_CONNECTED ) {\n\t\t\tDeathmatchScoreboardMessage( g_entities + i );\n\t\t}\n\t}\n}\n\n/*\n========================\nMoveClientToIntermission\n\nWhen the intermission starts, this will be called for all players.\nIf a new client connects, this will be called after the spawn function.\n========================\n*/\nvoid MoveClientToIntermission( gentity_t *ent ) {\n\t// take out of follow mode if needed\n\tif ( ent->client->sess.spectatorState == SPECTATOR_FOLLOW ) {\n\t\tStopFollowing( ent );\n\t}\n\n\n\t// move to the spot\n\tVectorCopy( level.intermission_origin, ent->s.origin );\n\tVectorCopy( level.intermission_origin, ent->client->ps.origin );\n\tVectorCopy (level.intermission_angle, ent->client->ps.viewangles);\n\tent->client->ps.pm_type = PM_INTERMISSION;\n\n\t// clean up powerup info\n\tmemset( ent->client->ps.powerups, 0, sizeof(ent->client->ps.powerups) );\n\n\tent->client->ps.eFlags = 0;\n\tent->s.eFlags = 0;\n\tent->s.eType = ET_GENERAL;\n\tent->s.modelindex = 0;\n\tent->s.loopSound = 0;\n\tent->s.event = 0;\n\tent->r.contents = 0;\n}\n\n/*\n==================\nFindIntermissionPoint\n\nThis is also used for spectator spawns\n==================\n*/\nvoid FindIntermissionPoint( void ) {\n\tgentity_t\t*ent, *target;\n\tvec3_t\t\tdir;\n\n\t// find the intermission spot\n\tent = G_Find (NULL, FOFS(classname), \"info_player_intermission\");\n\tif ( !ent ) {\t// the map creator forgot to put in an intermission point...\n\t\tSelectSpawnPoint ( vec3_origin, level.intermission_origin, level.intermission_angle );\n\t} else {\n\t\tVectorCopy (ent->s.origin, level.intermission_origin);\n\t\tVectorCopy (ent->s.angles, level.intermission_angle);\n\t\t// if it has a target, look towards it\n\t\tif ( ent->target ) {\n\t\t\ttarget = G_PickTarget( ent->target );\n\t\t\tif ( target ) {\n\t\t\t\tVectorSubtract( target->s.origin, level.intermission_origin, dir );\n\t\t\t\tvectoangles( dir, level.intermission_angle );\n\t\t\t}\n\t\t}\n\t}\n\n}\n\n/*\n==================\nBeginIntermission\n==================\n*/\nvoid BeginIntermission( void ) {\n\tint\t\t\ti;\n\tgentity_t\t*client;\n\n\tif ( level.intermissiontime ) {\n\t\treturn;\t\t// already active\n\t}\n\n\t// if in tournement mode, change the wins / losses\n\tif ( g_gametype.integer == GT_TOURNAMENT ) {\n\t\tAdjustTournamentScores();\n\t}\n\n\tlevel.intermissiontime = level.time;\n\tFindIntermissionPoint();\n\n#ifdef MISSIONPACK\n\tif (g_singlePlayer.integer) {\n\t\ttrap_Cvar_Set(\"ui_singlePlayerActive\", \"0\");\n\t\tUpdateTournamentInfo();\n\t}\n#else\n\t// if single player game\n\tif ( g_gametype.integer == GT_SINGLE_PLAYER ) {\n\t\tUpdateTournamentInfo();\n\t\tSpawnModelsOnVictoryPads();\n\t}\n#endif\n\n\t// move all clients to the intermission point\n\tfor (i=0 ; i< level.maxclients ; i++) {\n\t\tclient = g_entities + i;\n\t\tif (!client->inuse)\n\t\t\tcontinue;\n\t\t// respawn if dead\n\t\tif (client->health <= 0) {\n\t\t\trespawn(client);\n\t\t}\n\t\tMoveClientToIntermission( client );\n\t}\n\n\t// send the current scoring to all clients\n\tSendScoreboardMessageToAllClients();\n\n}\n\n\n/*\n=============\nExitLevel\n\nWhen the intermission has been exited, the server is either killed\nor moved to a new level based on the \"nextmap\" cvar \n\n=============\n*/\nvoid ExitLevel (void) {\n\tint\t\ti;\n\tgclient_t *cl;\n\n\t//bot interbreeding\n\tBotInterbreedEndMatch();\n\n\t// if we are running a tournement map, kick the loser to spectator status,\n\t// which will automatically grab the next spectator and restart\n\tif ( g_gametype.integer == GT_TOURNAMENT  ) {\n\t\tif ( !level.restarted ) {\n\t\t\tRemoveTournamentLoser();\n\t\t\ttrap_SendConsoleCommand( EXEC_APPEND, \"map_restart 0\\n\" );\n\t\t\tlevel.restarted = qtrue;\n\t\t\tlevel.changemap = NULL;\n\t\t\tlevel.intermissiontime = 0;\n\t\t}\n\t\treturn;\t\n\t}\n\n\n\ttrap_SendConsoleCommand( EXEC_APPEND, \"vstr nextmap\\n\" );\n\tlevel.changemap = NULL;\n\tlevel.intermissiontime = 0;\n\n\t// reset all the scores so we don't enter the intermission again\n\tlevel.teamScores[TEAM_RED] = 0;\n\tlevel.teamScores[TEAM_BLUE] = 0;\n\tfor ( i=0 ; i< g_maxclients.integer ; i++ ) {\n\t\tcl = level.clients + i;\n\t\tif ( cl->pers.connected != CON_CONNECTED ) {\n\t\t\tcontinue;\n\t\t}\n\t\tcl->ps.persistant[PERS_SCORE] = 0;\n\t}\n\n\t// we need to do this here before chaning to CON_CONNECTING\n\tG_WriteSessionData();\n\n\t// change all client states to connecting, so the early players into the\n\t// next level will know the others aren't done reconnecting\n\tfor (i=0 ; i< g_maxclients.integer ; i++) {\n\t\tif ( level.clients[i].pers.connected == CON_CONNECTED ) {\n\t\t\tlevel.clients[i].pers.connected = CON_CONNECTING;\n\t\t}\n\t}\n\n}\n\n/*\n=================\nG_LogPrintf\n\nPrint to the logfile with a time stamp if it is open\n=================\n*/\nvoid QDECL G_LogPrintf( const char *fmt, ... ) {\n\tva_list\t\targptr;\n\tchar\t\tstring[1024];\n\tint\t\t\tmin, tens, sec;\n\n\tsec = level.time / 1000;\n\n\tmin = sec / 60;\n\tsec -= min * 60;\n\ttens = sec / 10;\n\tsec -= tens * 10;\n\n\tCom_sprintf( string, sizeof(string), \"%3i:%i%i \", min, tens, sec );\n\n\tva_start( argptr, fmt );\n\tvsprintf( string +7 , fmt,argptr );\n\tva_end( argptr );\n\n\tif ( g_dedicated.integer ) {\n\t\tG_Printf( \"%s\", string + 7 );\n\t}\n\n\tif ( !level.logFile ) {\n\t\treturn;\n\t}\n\n\ttrap_FS_Write( string, strlen( string ), level.logFile );\n}\n\n/*\n================\nLogExit\n\nAppend information about this game to the log file\n================\n*/\nvoid LogExit( const char *string ) {\n\tint\t\t\t\ti, numSorted;\n\tgclient_t\t\t*cl;\n#ifdef MISSIONPACK // bk001205\n\tqboolean won = qtrue;\n#endif\n\tG_LogPrintf( \"Exit: %s\\n\", string );\n\n\tlevel.intermissionQueued = level.time;\n\n\t// this will keep the clients from playing any voice sounds\n\t// that will get cut off when the queued intermission starts\n\ttrap_SetConfigstring( CS_INTERMISSION, \"1\" );\n\n\t// don't send more than 32 scores (FIXME?)\n\tnumSorted = level.numConnectedClients;\n\tif ( numSorted > 32 ) {\n\t\tnumSorted = 32;\n\t}\n\n\tif ( g_gametype.integer >= GT_TEAM ) {\n\t\tG_LogPrintf( \"red:%i  blue:%i\\n\",\n\t\t\tlevel.teamScores[TEAM_RED], level.teamScores[TEAM_BLUE] );\n\t}\n\n\tfor (i=0 ; i < numSorted ; i++) {\n\t\tint\t\tping;\n\n\t\tcl = &level.clients[level.sortedClients[i]];\n\n\t\tif ( cl->sess.sessionTeam == TEAM_SPECTATOR ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( cl->pers.connected == CON_CONNECTING ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tping = cl->ps.ping < 999 ? cl->ps.ping : 999;\n\n\t\tG_LogPrintf( \"score: %i  ping: %i  client: %i %s\\n\", cl->ps.persistant[PERS_SCORE], ping, level.sortedClients[i],\tcl->pers.netname );\n#ifdef MISSIONPACK\n\t\tif (g_singlePlayer.integer && g_gametype.integer == GT_TOURNAMENT) {\n\t\t\tif (g_entities[cl - level.clients].r.svFlags & SVF_BOT && cl->ps.persistant[PERS_RANK] == 0) {\n\t\t\t\twon = qfalse;\n\t\t\t}\n\t\t}\n#endif\n\n\t}\n\n#ifdef MISSIONPACK\n\tif (g_singlePlayer.integer) {\n\t\tif (g_gametype.integer >= GT_CTF) {\n\t\t\twon = level.teamScores[TEAM_RED] > level.teamScores[TEAM_BLUE];\n\t\t}\n\t\ttrap_SendConsoleCommand( EXEC_APPEND, (won) ? \"spWin\\n\" : \"spLose\\n\" );\n\t}\n#endif\n\n\n}\n\n\n/*\n=================\nCheckIntermissionExit\n\nThe level will stay at the intermission for a minimum of 5 seconds\nIf all players wish to continue, the level will then exit.\nIf one or more players have not acknowledged the continue, the game will\nwait 10 seconds before going on.\n=================\n*/\nvoid CheckIntermissionExit( void ) {\n\tint\t\t\tready, notReady;\n\tint\t\t\ti;\n\tgclient_t\t*cl;\n\tint\t\t\treadyMask;\n\n\tif ( g_gametype.integer == GT_SINGLE_PLAYER ) {\n\t\treturn;\n\t}\n\n\t// see which players are ready\n\tready = 0;\n\tnotReady = 0;\n\treadyMask = 0;\n\tfor (i=0 ; i< g_maxclients.integer ; i++) {\n\t\tcl = level.clients + i;\n\t\tif ( cl->pers.connected != CON_CONNECTED ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( cl->readyToExit ) {\n\t\t\tready++;\n\t\t\tif ( i < 16 ) {\n\t\t\t\treadyMask |= 1 << i;\n\t\t\t}\n\t\t} else {\n\t\t\tnotReady++;\n\t\t}\n\t}\n\n\t// copy the readyMask to each player's stats so\n\t// it can be displayed on the scoreboard\n\tfor (i=0 ; i< g_maxclients.integer ; i++) {\n\t\tcl = level.clients + i;\n\t\tif ( cl->pers.connected != CON_CONNECTED ) {\n\t\t\tcontinue;\n\t\t}\n\t\tcl->ps.stats[STAT_CLIENTS_READY] = readyMask;\n\t}\n\n\t// never exit in less than five seconds\n\tif ( level.time < level.intermissiontime + 5000 ) {\n\t\treturn;\n\t}\n\n\t// if nobody wants to go, clear timer\n\tif ( !ready ) {\n\t\tlevel.readyToExit = qfalse;\n\t\treturn;\n\t}\n\n\t// if everyone wants to go, go now\n\tif ( !notReady ) {\n\t\tExitLevel();\n\t\treturn;\n\t}\n\n\t// the first person to ready starts the ten second timeout\n\tif ( !level.readyToExit ) {\n\t\tlevel.readyToExit = qtrue;\n\t\tlevel.exitTime = level.time;\n\t}\n\n\t// if we have waited ten seconds since at least one player\n\t// wanted to exit, go ahead\n\tif ( level.time < level.exitTime + 10000 ) {\n\t\treturn;\n\t}\n\n\tExitLevel();\n}\n\n/*\n=============\nScoreIsTied\n=============\n*/\nqboolean ScoreIsTied( void ) {\n\tint\t\ta, b;\n\n\tif ( level.numPlayingClients < 2 ) {\n\t\treturn qfalse;\n\t}\n\t\n\tif ( g_gametype.integer >= GT_TEAM ) {\n\t\treturn level.teamScores[TEAM_RED] == level.teamScores[TEAM_BLUE];\n\t}\n\n\ta = level.clients[level.sortedClients[0]].ps.persistant[PERS_SCORE];\n\tb = level.clients[level.sortedClients[1]].ps.persistant[PERS_SCORE];\n\n\treturn a == b;\n}\n\n/*\n=================\nCheckExitRules\n\nThere will be a delay between the time the exit is qualified for\nand the time everyone is moved to the intermission spot, so you\ncan see the last frag.\n=================\n*/\nvoid CheckExitRules( void ) {\n \tint\t\t\ti;\n\tgclient_t\t*cl;\n\t// if at the intermission, wait for all non-bots to\n\t// signal ready, then go to next level\n\tif ( level.intermissiontime ) {\n\t\tCheckIntermissionExit ();\n\t\treturn;\n\t}\n\n\tif ( level.intermissionQueued ) {\n#ifdef MISSIONPACK\n\t\tint time = (g_singlePlayer.integer) ? SP_INTERMISSION_DELAY_TIME : INTERMISSION_DELAY_TIME;\n\t\tif ( level.time - level.intermissionQueued >= time ) {\n\t\t\tlevel.intermissionQueued = 0;\n\t\t\tBeginIntermission();\n\t\t}\n#else\n\t\tif ( level.time - level.intermissionQueued >= INTERMISSION_DELAY_TIME ) {\n\t\t\tlevel.intermissionQueued = 0;\n\t\t\tBeginIntermission();\n\t\t}\n#endif\n\t\treturn;\n\t}\n\n\t// check for sudden death\n\tif ( ScoreIsTied() ) {\n\t\t// always wait for sudden death\n\t\treturn;\n\t}\n\n\tif ( g_timelimit.integer && !level.warmupTime ) {\n\t\tif ( level.time - level.startTime >= g_timelimit.integer*60000 ) {\n\t\t\ttrap_SendServerCommand( -1, \"print \\\"Timelimit hit.\\n\\\"\");\n\t\t\tLogExit( \"Timelimit hit.\" );\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif ( level.numPlayingClients < 2 ) {\n\t\treturn;\n\t}\n\n\tif ( g_gametype.integer < GT_CTF && g_fraglimit.integer ) {\n\t\tif ( level.teamScores[TEAM_RED] >= g_fraglimit.integer ) {\n\t\t\ttrap_SendServerCommand( -1, \"print \\\"Red hit the fraglimit.\\n\\\"\" );\n\t\t\tLogExit( \"Fraglimit hit.\" );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( level.teamScores[TEAM_BLUE] >= g_fraglimit.integer ) {\n\t\t\ttrap_SendServerCommand( -1, \"print \\\"Blue hit the fraglimit.\\n\\\"\" );\n\t\t\tLogExit( \"Fraglimit hit.\" );\n\t\t\treturn;\n\t\t}\n\n\t\tfor ( i=0 ; i< g_maxclients.integer ; i++ ) {\n\t\t\tcl = level.clients + i;\n\t\t\tif ( cl->pers.connected != CON_CONNECTED ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( cl->sess.sessionTeam != TEAM_FREE ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif ( cl->ps.persistant[PERS_SCORE] >= g_fraglimit.integer ) {\n\t\t\t\tLogExit( \"Fraglimit hit.\" );\n\t\t\t\ttrap_SendServerCommand( -1, va(\"print \\\"%s\" S_COLOR_WHITE \" hit the fraglimit.\\n\\\"\",\n\t\t\t\t\tcl->pers.netname ) );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( g_gametype.integer >= GT_CTF && g_capturelimit.integer ) {\n\n\t\tif ( level.teamScores[TEAM_RED] >= g_capturelimit.integer ) {\n\t\t\ttrap_SendServerCommand( -1, \"print \\\"Red hit the capturelimit.\\n\\\"\" );\n\t\t\tLogExit( \"Capturelimit hit.\" );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( level.teamScores[TEAM_BLUE] >= g_capturelimit.integer ) {\n\t\t\ttrap_SendServerCommand( -1, \"print \\\"Blue hit the capturelimit.\\n\\\"\" );\n\t\t\tLogExit( \"Capturelimit hit.\" );\n\t\t\treturn;\n\t\t}\n\t}\n}\n\n\n\n/*\n========================================================================\n\nFUNCTIONS CALLED EVERY FRAME\n\n========================================================================\n*/\n\n\n/*\n=============\nCheckTournament\n\nOnce a frame, check for changes in tournement player state\n=============\n*/\nvoid CheckTournament( void ) {\n\t// check because we run 3 game frames before calling Connect and/or ClientBegin\n\t// for clients on a map_restart\n\tif ( level.numPlayingClients == 0 ) {\n\t\treturn;\n\t}\n\n\tif ( g_gametype.integer == GT_TOURNAMENT ) {\n\n\t\t// pull in a spectator if needed\n\t\tif ( level.numPlayingClients < 2 ) {\n\t\t\tAddTournamentPlayer();\n\t\t}\n\n\t\t// if we don't have two players, go back to \"waiting for players\"\n\t\tif ( level.numPlayingClients != 2 ) {\n\t\t\tif ( level.warmupTime != -1 ) {\n\t\t\t\tlevel.warmupTime = -1;\n\t\t\t\ttrap_SetConfigstring( CS_WARMUP, va(\"%i\", level.warmupTime) );\n\t\t\t\tG_LogPrintf( \"Warmup:\\n\" );\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif ( level.warmupTime == 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// if the warmup is changed at the console, restart it\n\t\tif ( g_warmup.modificationCount != level.warmupModificationCount ) {\n\t\t\tlevel.warmupModificationCount = g_warmup.modificationCount;\n\t\t\tlevel.warmupTime = -1;\n\t\t}\n\n\t\t// if all players have arrived, start the countdown\n\t\tif ( level.warmupTime < 0 ) {\n\t\t\tif ( level.numPlayingClients == 2 ) {\n\t\t\t\t// fudge by -1 to account for extra delays\n\t\t\t\tlevel.warmupTime = level.time + ( g_warmup.integer - 1 ) * 1000;\n\t\t\t\ttrap_SetConfigstring( CS_WARMUP, va(\"%i\", level.warmupTime) );\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// if the warmup time has counted down, restart\n\t\tif ( level.time > level.warmupTime ) {\n\t\t\tlevel.warmupTime += 10000;\n\t\t\ttrap_Cvar_Set( \"g_restarted\", \"1\" );\n\t\t\ttrap_SendConsoleCommand( EXEC_APPEND, \"map_restart 0\\n\" );\n\t\t\tlevel.restarted = qtrue;\n\t\t\treturn;\n\t\t}\n\t} else if ( g_gametype.integer != GT_SINGLE_PLAYER && level.warmupTime != 0 ) {\n\t\tint\t\tcounts[TEAM_NUM_TEAMS];\n\t\tqboolean\tnotEnough = qfalse;\n\n\t\tif ( g_gametype.integer > GT_TEAM ) {\n\t\t\tcounts[TEAM_BLUE] = TeamCount( -1, TEAM_BLUE );\n\t\t\tcounts[TEAM_RED] = TeamCount( -1, TEAM_RED );\n\n\t\t\tif (counts[TEAM_RED] < 1 || counts[TEAM_BLUE] < 1) {\n\t\t\t\tnotEnough = qtrue;\n\t\t\t}\n\t\t} else if ( level.numPlayingClients < 2 ) {\n\t\t\tnotEnough = qtrue;\n\t\t}\n\n\t\tif ( notEnough ) {\n\t\t\tif ( level.warmupTime != -1 ) {\n\t\t\t\tlevel.warmupTime = -1;\n\t\t\t\ttrap_SetConfigstring( CS_WARMUP, va(\"%i\", level.warmupTime) );\n\t\t\t\tG_LogPrintf( \"Warmup:\\n\" );\n\t\t\t}\n\t\t\treturn; // still waiting for team members\n\t\t}\n\n\t\tif ( level.warmupTime == 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// if the warmup is changed at the console, restart it\n\t\tif ( g_warmup.modificationCount != level.warmupModificationCount ) {\n\t\t\tlevel.warmupModificationCount = g_warmup.modificationCount;\n\t\t\tlevel.warmupTime = -1;\n\t\t}\n\n\t\t// if all players have arrived, start the countdown\n\t\tif ( level.warmupTime < 0 ) {\n\t\t\t// fudge by -1 to account for extra delays\n\t\t\tlevel.warmupTime = level.time + ( g_warmup.integer - 1 ) * 1000;\n\t\t\ttrap_SetConfigstring( CS_WARMUP, va(\"%i\", level.warmupTime) );\n\t\t\treturn;\n\t\t}\n\n\t\t// if the warmup time has counted down, restart\n\t\tif ( level.time > level.warmupTime ) {\n\t\t\tlevel.warmupTime += 10000;\n\t\t\ttrap_Cvar_Set( \"g_restarted\", \"1\" );\n\t\t\ttrap_SendConsoleCommand( EXEC_APPEND, \"map_restart 0\\n\" );\n\t\t\tlevel.restarted = qtrue;\n\t\t\treturn;\n\t\t}\n\t}\n}\n\n\n/*\n==================\nCheckVote\n==================\n*/\nvoid CheckVote( void ) {\n\tif ( level.voteExecuteTime && level.voteExecuteTime < level.time ) {\n\t\tlevel.voteExecuteTime = 0;\n\t\ttrap_SendConsoleCommand( EXEC_APPEND, va(\"%s\\n\", level.voteString ) );\n\t}\n\tif ( !level.voteTime ) {\n\t\treturn;\n\t}\n\tif ( level.time - level.voteTime >= VOTE_TIME ) {\n\t\ttrap_SendServerCommand( -1, \"print \\\"Vote failed.\\n\\\"\" );\n\t} else {\n\t\t// ATVI Q3 1.32 Patch #9, WNF\n\t\tif ( level.voteYes > level.numVotingClients/2 ) {\n\t\t\t// execute the command, then remove the vote\n\t\t\ttrap_SendServerCommand( -1, \"print \\\"Vote passed.\\n\\\"\" );\n\t\t\tlevel.voteExecuteTime = level.time + 3000;\n\t\t} else if ( level.voteNo >= level.numVotingClients/2 ) {\n\t\t\t// same behavior as a timeout\n\t\t\ttrap_SendServerCommand( -1, \"print \\\"Vote failed.\\n\\\"\" );\n\t\t} else {\n\t\t\t// still waiting for a majority\n\t\t\treturn;\n\t\t}\n\t}\n\tlevel.voteTime = 0;\n\ttrap_SetConfigstring( CS_VOTE_TIME, \"\" );\n\n}\n\n/*\n==================\nPrintTeam\n==================\n*/\nvoid PrintTeam(int team, char *message) {\n\tint i;\n\n\tfor ( i = 0 ; i < level.maxclients ; i++ ) {\n\t\tif (level.clients[i].sess.sessionTeam != team)\n\t\t\tcontinue;\n\t\ttrap_SendServerCommand( i, message );\n\t}\n}\n\n/*\n==================\nSetLeader\n==================\n*/\nvoid SetLeader(int team, int client) {\n\tint i;\n\n\tif ( level.clients[client].pers.connected == CON_DISCONNECTED ) {\n\t\tPrintTeam(team, va(\"print \\\"%s is not connected\\n\\\"\", level.clients[client].pers.netname) );\n\t\treturn;\n\t}\n\tif (level.clients[client].sess.sessionTeam != team) {\n\t\tPrintTeam(team, va(\"print \\\"%s is not on the team anymore\\n\\\"\", level.clients[client].pers.netname) );\n\t\treturn;\n\t}\n\tfor ( i = 0 ; i < level.maxclients ; i++ ) {\n\t\tif (level.clients[i].sess.sessionTeam != team)\n\t\t\tcontinue;\n\t\tif (level.clients[i].sess.teamLeader) {\n\t\t\tlevel.clients[i].sess.teamLeader = qfalse;\n\t\t\tClientUserinfoChanged(i);\n\t\t}\n\t}\n\tlevel.clients[client].sess.teamLeader = qtrue;\n\tClientUserinfoChanged( client );\n\tPrintTeam(team, va(\"print \\\"%s is the new team leader\\n\\\"\", level.clients[client].pers.netname) );\n}\n\n/*\n==================\nCheckTeamLeader\n==================\n*/\nvoid CheckTeamLeader( int team ) {\n\tint i;\n\n\tfor ( i = 0 ; i < level.maxclients ; i++ ) {\n\t\tif (level.clients[i].sess.sessionTeam != team)\n\t\t\tcontinue;\n\t\tif (level.clients[i].sess.teamLeader)\n\t\t\tbreak;\n\t}\n\tif (i >= level.maxclients) {\n\t\tfor ( i = 0 ; i < level.maxclients ; i++ ) {\n\t\t\tif (level.clients[i].sess.sessionTeam != team)\n\t\t\t\tcontinue;\n\t\t\tif (!(g_entities[i].r.svFlags & SVF_BOT)) {\n\t\t\t\tlevel.clients[i].sess.teamLeader = qtrue;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tfor ( i = 0 ; i < level.maxclients ; i++ ) {\n\t\t\tif (level.clients[i].sess.sessionTeam != team)\n\t\t\t\tcontinue;\n\t\t\tlevel.clients[i].sess.teamLeader = qtrue;\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/*\n==================\nCheckTeamVote\n==================\n*/\nvoid CheckTeamVote( int team ) {\n\tint cs_offset;\n\n\tif ( team == TEAM_RED )\n\t\tcs_offset = 0;\n\telse if ( team == TEAM_BLUE )\n\t\tcs_offset = 1;\n\telse\n\t\treturn;\n\n\tif ( !level.teamVoteTime[cs_offset] ) {\n\t\treturn;\n\t}\n\tif ( level.time - level.teamVoteTime[cs_offset] >= VOTE_TIME ) {\n\t\ttrap_SendServerCommand( -1, \"print \\\"Team vote failed.\\n\\\"\" );\n\t} else {\n\t\tif ( level.teamVoteYes[cs_offset] > level.numteamVotingClients[cs_offset]/2 ) {\n\t\t\t// execute the command, then remove the vote\n\t\t\ttrap_SendServerCommand( -1, \"print \\\"Team vote passed.\\n\\\"\" );\n\t\t\t//\n\t\t\tif ( !Q_strncmp( \"leader\", level.teamVoteString[cs_offset], 6) ) {\n\t\t\t\t//set the team leader\n\t\t\t\tSetLeader(team, atoi(level.teamVoteString[cs_offset] + 7));\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttrap_SendConsoleCommand( EXEC_APPEND, va(\"%s\\n\", level.teamVoteString[cs_offset] ) );\n\t\t\t}\n\t\t} else if ( level.teamVoteNo[cs_offset] >= level.numteamVotingClients[cs_offset]/2 ) {\n\t\t\t// same behavior as a timeout\n\t\t\ttrap_SendServerCommand( -1, \"print \\\"Team vote failed.\\n\\\"\" );\n\t\t} else {\n\t\t\t// still waiting for a majority\n\t\t\treturn;\n\t\t}\n\t}\n\tlevel.teamVoteTime[cs_offset] = 0;\n\ttrap_SetConfigstring( CS_TEAMVOTE_TIME + cs_offset, \"\" );\n\n}\n\n\n/*\n==================\nCheckCvars\n==================\n*/\nvoid CheckCvars( void ) {\n\tstatic int lastMod = -1;\n\n\tif ( g_password.modificationCount != lastMod ) {\n\t\tlastMod = g_password.modificationCount;\n\t\tif ( *g_password.string && Q_stricmp( g_password.string, \"none\" ) ) {\n\t\t\ttrap_Cvar_Set( \"g_needpass\", \"1\" );\n\t\t} else {\n\t\t\ttrap_Cvar_Set( \"g_needpass\", \"0\" );\n\t\t}\n\t}\n}\n\n/*\n=============\nG_RunThink\n\nRuns thinking code for this frame if necessary\n=============\n*/\nvoid G_RunThink (gentity_t *ent) {\n\tfloat\tthinktime;\n\n\tthinktime = ent->nextthink;\n\tif (thinktime <= 0) {\n\t\treturn;\n\t}\n\tif (thinktime > level.time) {\n\t\treturn;\n\t}\n\t\n\tent->nextthink = 0;\n\tif (!ent->think) {\n\t\tG_Error ( \"NULL ent->think\");\n\t}\n\tent->think (ent);\n}\n\n/*\n================\nG_RunFrame\n\nAdvances the non-player objects in the world\n================\n*/\nvoid G_RunFrame( int levelTime ) {\n\tint\t\t\ti;\n\tgentity_t\t*ent;\n\tint\t\t\tmsec;\nint start, end;\n\n\t// if we are waiting for the level to restart, do nothing\n\tif ( level.restarted ) {\n\t\treturn;\n\t}\n\n\tlevel.framenum++;\n\tlevel.previousTime = level.time;\n\tlevel.time = levelTime;\n\tmsec = level.time - level.previousTime;\n\n\t// get any cvar changes\n\tG_UpdateCvars();\n\n\t//\n\t// go through all allocated objects\n\t//\n\tstart = trap_Milliseconds();\n\tent = &g_entities[0];\n\tfor (i=0 ; i<level.num_entities ; i++, ent++) {\n\t\tif ( !ent->inuse ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// clear events that are too old\n\t\tif ( level.time - ent->eventTime > EVENT_VALID_MSEC ) {\n\t\t\tif ( ent->s.event ) {\n\t\t\t\tent->s.event = 0;\t// &= EV_EVENT_BITS;\n\t\t\t\tif ( ent->client ) {\n\t\t\t\t\tent->client->ps.externalEvent = 0;\n\t\t\t\t\t// predicted events should never be set to zero\n\t\t\t\t\t//ent->client->ps.events[0] = 0;\n\t\t\t\t\t//ent->client->ps.events[1] = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( ent->freeAfterEvent ) {\n\t\t\t\t// tempEntities or dropped items completely go away after their event\n\t\t\t\tG_FreeEntity( ent );\n\t\t\t\tcontinue;\n\t\t\t} else if ( ent->unlinkAfterEvent ) {\n\t\t\t\t// items that will respawn will hide themselves after their pickup event\n\t\t\t\tent->unlinkAfterEvent = qfalse;\n\t\t\t\ttrap_UnlinkEntity( ent );\n\t\t\t}\n\t\t}\n\n\t\t// temporary entities don't think\n\t\tif ( ent->freeAfterEvent ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( !ent->r.linked && ent->neverFree ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( ent->s.eType == ET_MISSILE ) {\n\t\t\tG_RunMissile( ent );\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( ent->s.eType == ET_ITEM || ent->physicsObject ) {\n\t\t\tG_RunItem( ent );\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( ent->s.eType == ET_MOVER ) {\n\t\t\tG_RunMover( ent );\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( i < MAX_CLIENTS ) {\n\t\t\tG_RunClient( ent );\n\t\t\tcontinue;\n\t\t}\n\n\t\tG_RunThink( ent );\n\t}\nend = trap_Milliseconds();\n\nstart = trap_Milliseconds();\n\t// perform final fixups on the players\n\tent = &g_entities[0];\n\tfor (i=0 ; i < level.maxclients ; i++, ent++ ) {\n\t\tif ( ent->inuse ) {\n\t\t\tClientEndFrame( ent );\n\t\t}\n\t}\nend = trap_Milliseconds();\n\n\t// see if it is time to do a tournement restart\n\tCheckTournament();\n\n\t// see if it is time to end the level\n\tCheckExitRules();\n\n\t// update to team status?\n\tCheckTeamStatus();\n\n\t// cancel vote if timed out\n\tCheckVote();\n\n\t// check team votes\n\tCheckTeamVote( TEAM_RED );\n\tCheckTeamVote( TEAM_BLUE );\n\n\t// for tracking changes\n\tCheckCvars();\n\n\tif (g_listEntity.integer) {\n\t\tfor (i = 0; i < MAX_GENTITIES; i++) {\n\t\t\tG_Printf(\"%4i: %s\\n\", i, g_entities[i].classname);\n\t\t}\n\t\ttrap_Cvar_Set(\"g_listEntity\", \"0\");\n\t}\n}\n"
  },
  {
    "path": "code/game/g_mem.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n//\n// g_mem.c\n//\n\n\n#include \"g_local.h\"\n\n\n#define POOLSIZE\t(256 * 1024)\n\nstatic char\t\tmemoryPool[POOLSIZE];\nstatic int\t\tallocPoint;\n\nvoid *G_Alloc( int size ) {\n\tchar\t*p;\n\n\tif ( g_debugAlloc.integer ) {\n\t\tG_Printf( \"G_Alloc of %i bytes (%i left)\\n\", size, POOLSIZE - allocPoint - ( ( size + 31 ) & ~31 ) );\n\t}\n\n\tif ( allocPoint + size > POOLSIZE ) {\n\t  G_Error( \"G_Alloc: failed on allocation of %i bytes\\n\", size ); // bk010103 - was %u, but is signed\n\t\treturn NULL;\n\t}\n\n\tp = &memoryPool[allocPoint];\n\n\tallocPoint += ( size + 31 ) & ~31;\n\n\treturn p;\n}\n\nvoid G_InitMemory( void ) {\n\tallocPoint = 0;\n}\n\nvoid Svcmd_GameMem_f( void ) {\n\tG_Printf( \"Game memory status: %i out of %i bytes allocated\\n\", allocPoint, POOLSIZE );\n}\n"
  },
  {
    "path": "code/game/g_misc.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// g_misc.c\n\n#include \"g_local.h\"\n\n\n/*QUAKED func_group (0 0 0) ?\nUsed to group brushes together just for editor convenience.  They are turned into normal brushes by the utilities.\n*/\n\n\n/*QUAKED info_camp (0 0.5 0) (-4 -4 -4) (4 4 4)\nUsed as a positional target for calculations in the utilities (spotlights, etc), but removed during gameplay.\n*/\nvoid SP_info_camp( gentity_t *self ) {\n\tG_SetOrigin( self, self->s.origin );\n}\n\n\n/*QUAKED info_null (0 0.5 0) (-4 -4 -4) (4 4 4)\nUsed as a positional target for calculations in the utilities (spotlights, etc), but removed during gameplay.\n*/\nvoid SP_info_null( gentity_t *self ) {\n\tG_FreeEntity( self );\n}\n\n\n/*QUAKED info_notnull (0 0.5 0) (-4 -4 -4) (4 4 4)\nUsed as a positional target for in-game calculation, like jumppad targets.\ntarget_position does the same thing\n*/\nvoid SP_info_notnull( gentity_t *self ){\n\tG_SetOrigin( self, self->s.origin );\n}\n\n\n/*QUAKED light (0 1 0) (-8 -8 -8) (8 8 8) linear\nNon-displayed light.\n\"light\" overrides the default 300 intensity.\nLinear checbox gives linear falloff instead of inverse square\nLights pointed at a target will be spotlights.\n\"radius\" overrides the default 64 unit radius of a spotlight at the target point.\n*/\nvoid SP_light( gentity_t *self ) {\n\tG_FreeEntity( self );\n}\n\n\n\n/*\n=================================================================================\n\nTELEPORTERS\n\n=================================================================================\n*/\n\nvoid TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles ) {\n\tgentity_t\t*tent;\n\n\t// use temp events at source and destination to prevent the effect\n\t// from getting dropped by a second player event\n\tif ( player->client->sess.sessionTeam != TEAM_SPECTATOR ) {\n\t\ttent = G_TempEntity( player->client->ps.origin, EV_PLAYER_TELEPORT_OUT );\n\t\ttent->s.clientNum = player->s.clientNum;\n\n\t\ttent = G_TempEntity( origin, EV_PLAYER_TELEPORT_IN );\n\t\ttent->s.clientNum = player->s.clientNum;\n\t}\n\n\t// unlink to make sure it can't possibly interfere with G_KillBox\n\ttrap_UnlinkEntity (player);\n\n\tVectorCopy ( origin, player->client->ps.origin );\n\tplayer->client->ps.origin[2] += 1;\n\n\t// spit the player out\n\tAngleVectors( angles, player->client->ps.velocity, NULL, NULL );\n\tVectorScale( player->client->ps.velocity, 400, player->client->ps.velocity );\n\tplayer->client->ps.pm_time = 160;\t\t// hold time\n\tplayer->client->ps.pm_flags |= PMF_TIME_KNOCKBACK;\n\n\t// toggle the teleport bit so the client knows to not lerp\n\tplayer->client->ps.eFlags ^= EF_TELEPORT_BIT;\n\n\t// set angles\n\tSetClientViewAngle( player, angles );\n\n\t// kill anything at the destination\n\tif ( player->client->sess.sessionTeam != TEAM_SPECTATOR ) {\n\t\tG_KillBox (player);\n\t}\n\n\t// save results of pmove\n\tBG_PlayerStateToEntityState( &player->client->ps, &player->s, qtrue );\n\n\t// use the precise origin for linking\n\tVectorCopy( player->client->ps.origin, player->r.currentOrigin );\n\n\tif ( player->client->sess.sessionTeam != TEAM_SPECTATOR ) {\n\t\ttrap_LinkEntity (player);\n\t}\n}\n\n\n/*QUAKED misc_teleporter_dest (1 0 0) (-32 -32 -24) (32 32 -16)\nPoint teleporters at these.\nNow that we don't have teleport destination pads, this is just\nan info_notnull\n*/\nvoid SP_misc_teleporter_dest( gentity_t *ent ) {\n}\n\n\n//===========================================================\n\n/*QUAKED misc_model (1 0 0) (-16 -16 -16) (16 16 16)\n\"model\"\t\tarbitrary .md3 file to display\n*/\nvoid SP_misc_model( gentity_t *ent ) {\n\n#if 0\n\tent->s.modelindex = G_ModelIndex( ent->model );\n\tVectorSet (ent->mins, -16, -16, -16);\n\tVectorSet (ent->maxs, 16, 16, 16);\n\ttrap_LinkEntity (ent);\n\n\tG_SetOrigin( ent, ent->s.origin );\n\tVectorCopy( ent->s.angles, ent->s.apos.trBase );\n#else\n\tG_FreeEntity( ent );\n#endif\n}\n\n//===========================================================\n\nvoid locateCamera( gentity_t *ent ) {\n\tvec3_t\t\tdir;\n\tgentity_t\t*target;\n\tgentity_t\t*owner;\n\n\towner = G_PickTarget( ent->target );\n\tif ( !owner ) {\n\t\tG_Printf( \"Couldn't find target for misc_partal_surface\\n\" );\n\t\tG_FreeEntity( ent );\n\t\treturn;\n\t}\n\tent->r.ownerNum = owner->s.number;\n\n\t// frame holds the rotate speed\n\tif ( owner->spawnflags & 1 ) {\n\t\tent->s.frame = 25;\n\t} else if ( owner->spawnflags & 2 ) {\n\t\tent->s.frame = 75;\n\t}\n\n\t// swing camera ?\n\tif ( owner->spawnflags & 4 ) {\n\t\t// set to 0 for no rotation at all\n\t\tent->s.powerups = 0;\n\t}\n\telse {\n\t\tent->s.powerups = 1;\n\t}\n\n\t// clientNum holds the rotate offset\n\tent->s.clientNum = owner->s.clientNum;\n\n\tVectorCopy( owner->s.origin, ent->s.origin2 );\n\n\t// see if the portal_camera has a target\n\ttarget = G_PickTarget( owner->target );\n\tif ( target ) {\n\t\tVectorSubtract( target->s.origin, owner->s.origin, dir );\n\t\tVectorNormalize( dir );\n\t} else {\n\t\tG_SetMovedir( owner->s.angles, dir );\n\t}\n\n\tent->s.eventParm = DirToByte( dir );\n}\n\n/*QUAKED misc_portal_surface (0 0 1) (-8 -8 -8) (8 8 8)\nThe portal surface nearest this entity will show a view from the targeted misc_portal_camera, or a mirror view if untargeted.\nThis must be within 64 world units of the surface!\n*/\nvoid SP_misc_portal_surface(gentity_t *ent) {\n\tVectorClear( ent->r.mins );\n\tVectorClear( ent->r.maxs );\n\ttrap_LinkEntity (ent);\n\n\tent->r.svFlags = SVF_PORTAL;\n\tent->s.eType = ET_PORTAL;\n\n\tif ( !ent->target ) {\n\t\tVectorCopy( ent->s.origin, ent->s.origin2 );\n\t} else {\n\t\tent->think = locateCamera;\n\t\tent->nextthink = level.time + 100;\n\t}\n}\n\n/*QUAKED misc_portal_camera (0 0 1) (-8 -8 -8) (8 8 8) slowrotate fastrotate noswing\nThe target for a misc_portal_director.  You can set either angles or target another entity to determine the direction of view.\n\"roll\" an angle modifier to orient the camera around the target vector;\n*/\nvoid SP_misc_portal_camera(gentity_t *ent) {\n\tfloat\troll;\n\n\tVectorClear( ent->r.mins );\n\tVectorClear( ent->r.maxs );\n\ttrap_LinkEntity (ent);\n\n\tG_SpawnFloat( \"roll\", \"0\", &roll );\n\n\tent->s.clientNum = roll/360.0 * 256;\n}\n\n/*\n======================================================================\n\n  SHOOTERS\n\n======================================================================\n*/\n\nvoid Use_Shooter( gentity_t *ent, gentity_t *other, gentity_t *activator ) {\n\tvec3_t\t\tdir;\n\tfloat\t\tdeg;\n\tvec3_t\t\tup, right;\n\n\t// see if we have a target\n\tif ( ent->enemy ) {\n\t\tVectorSubtract( ent->enemy->r.currentOrigin, ent->s.origin, dir );\n\t\tVectorNormalize( dir );\n\t} else {\n\t\tVectorCopy( ent->movedir, dir );\n\t}\n\n\t// randomize a bit\n\tPerpendicularVector( up, dir );\n\tCrossProduct( up, dir, right );\n\n\tdeg = crandom() * ent->random;\n\tVectorMA( dir, deg, up, dir );\n\n\tdeg = crandom() * ent->random;\n\tVectorMA( dir, deg, right, dir );\n\n\tVectorNormalize( dir );\n\n\tswitch ( ent->s.weapon ) {\n\tcase WP_GRENADE_LAUNCHER:\n\t\tfire_grenade( ent, ent->s.origin, dir );\n\t\tbreak;\n\tcase WP_ROCKET_LAUNCHER:\n\t\tfire_rocket( ent, ent->s.origin, dir );\n\t\tbreak;\n\tcase WP_PLASMAGUN:\n\t\tfire_plasma( ent, ent->s.origin, dir );\n\t\tbreak;\n\t}\n\n\tG_AddEvent( ent, EV_FIRE_WEAPON, 0 );\n}\n\n\nstatic void InitShooter_Finish( gentity_t *ent ) {\n\tent->enemy = G_PickTarget( ent->target );\n\tent->think = 0;\n\tent->nextthink = 0;\n}\n\nvoid InitShooter( gentity_t *ent, int weapon ) {\n\tent->use = Use_Shooter;\n\tent->s.weapon = weapon;\n\n\tRegisterItem( BG_FindItemForWeapon( weapon ) );\n\n\tG_SetMovedir( ent->s.angles, ent->movedir );\n\n\tif ( !ent->random ) {\n\t\tent->random = 1.0;\n\t}\n\tent->random = sin( M_PI * ent->random / 180 );\n\t// target might be a moving object, so we can't set movedir for it\n\tif ( ent->target ) {\n\t\tent->think = InitShooter_Finish;\n\t\tent->nextthink = level.time + 500;\n\t}\n\ttrap_LinkEntity( ent );\n}\n\n/*QUAKED shooter_rocket (1 0 0) (-16 -16 -16) (16 16 16)\nFires at either the target or the current direction.\n\"random\" the number of degrees of deviance from the taget. (1.0 default)\n*/\nvoid SP_shooter_rocket( gentity_t *ent ) {\n\tInitShooter( ent, WP_ROCKET_LAUNCHER );\n}\n\n/*QUAKED shooter_plasma (1 0 0) (-16 -16 -16) (16 16 16)\nFires at either the target or the current direction.\n\"random\" is the number of degrees of deviance from the taget. (1.0 default)\n*/\nvoid SP_shooter_plasma( gentity_t *ent ) {\n\tInitShooter( ent, WP_PLASMAGUN);\n}\n\n/*QUAKED shooter_grenade (1 0 0) (-16 -16 -16) (16 16 16)\nFires at either the target or the current direction.\n\"random\" is the number of degrees of deviance from the taget. (1.0 default)\n*/\nvoid SP_shooter_grenade( gentity_t *ent ) {\n\tInitShooter( ent, WP_GRENADE_LAUNCHER);\n}\n\n\n#ifdef MISSIONPACK\nstatic void PortalDie (gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod) {\n\tG_FreeEntity( self );\n\t//FIXME do something more interesting\n}\n\n\nvoid DropPortalDestination( gentity_t *player ) {\n\tgentity_t\t*ent;\n\tvec3_t\t\tsnapped;\n\n\t// create the portal destination\n\tent = G_Spawn();\n\tent->s.modelindex = G_ModelIndex( \"models/powerups/teleporter/tele_exit.md3\" );\n\n\tVectorCopy( player->s.pos.trBase, snapped );\n\tSnapVector( snapped );\n\tG_SetOrigin( ent, snapped );\n\tVectorCopy( player->r.mins, ent->r.mins );\n\tVectorCopy( player->r.maxs, ent->r.maxs );\n\n\tent->classname = \"hi_portal destination\";\n\tent->s.pos.trType = TR_STATIONARY;\n\n\tent->r.contents = CONTENTS_CORPSE;\n\tent->takedamage = qtrue;\n\tent->health = 200;\n\tent->die = PortalDie;\n\n\tVectorCopy( player->s.apos.trBase, ent->s.angles );\n\n\tent->think = G_FreeEntity;\n\tent->nextthink = level.time + 2 * 60 * 1000;\n\n\ttrap_LinkEntity( ent );\n\n\tplayer->client->portalID = ++level.portalSequence;\n\tent->count = player->client->portalID;\n\n\t// give the item back so they can drop the source now\n\tplayer->client->ps.stats[STAT_HOLDABLE_ITEM] = BG_FindItem( \"Portal\" ) - bg_itemlist;\n}\n\n\nstatic void PortalTouch( gentity_t *self, gentity_t *other, trace_t *trace) {\n\tgentity_t\t*destination;\n\n\t// see if we will even let other try to use it\n\tif( other->health <= 0 ) {\n\t\treturn;\n\t}\n\tif( !other->client ) {\n\t\treturn;\n\t}\n//\tif( other->client->ps.persistant[PERS_TEAM] != self->spawnflags ) {\n//\t\treturn;\n//\t}\n\n\tif ( other->client->ps.powerups[PW_NEUTRALFLAG] ) {\t\t// only happens in One Flag CTF\n\t\tDrop_Item( other, BG_FindItemForPowerup( PW_NEUTRALFLAG ), 0 );\n\t\tother->client->ps.powerups[PW_NEUTRALFLAG] = 0;\n\t}\n\telse if ( other->client->ps.powerups[PW_REDFLAG] ) {\t\t// only happens in standard CTF\n\t\tDrop_Item( other, BG_FindItemForPowerup( PW_REDFLAG ), 0 );\n\t\tother->client->ps.powerups[PW_REDFLAG] = 0;\n\t}\n\telse if ( other->client->ps.powerups[PW_BLUEFLAG] ) {\t// only happens in standard CTF\n\t\tDrop_Item( other, BG_FindItemForPowerup( PW_BLUEFLAG ), 0 );\n\t\tother->client->ps.powerups[PW_BLUEFLAG] = 0;\n\t}\n\n\t// find the destination\n\tdestination = NULL;\n\twhile( (destination = G_Find(destination, FOFS(classname), \"hi_portal destination\")) != NULL ) {\n\t\tif( destination->count == self->count ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// if there is not one, die!\n\tif( !destination ) {\n\t\tif( self->pos1[0] || self->pos1[1] || self->pos1[2] ) {\n\t\t\tTeleportPlayer( other, self->pos1, self->s.angles );\n\t\t}\n\t\tG_Damage( other, other, other, NULL, NULL, 100000, DAMAGE_NO_PROTECTION, MOD_TELEFRAG );\n\t\treturn;\n\t}\n\n\tTeleportPlayer( other, destination->s.pos.trBase, destination->s.angles );\n}\n\n\nstatic void PortalEnable( gentity_t *self ) {\n\tself->touch = PortalTouch;\n\tself->think = G_FreeEntity;\n\tself->nextthink = level.time + 2 * 60 * 1000;\n}\n\n\nvoid DropPortalSource( gentity_t *player ) {\n\tgentity_t\t*ent;\n\tgentity_t\t*destination;\n\tvec3_t\t\tsnapped;\n\n\t// create the portal source\n\tent = G_Spawn();\n\tent->s.modelindex = G_ModelIndex( \"models/powerups/teleporter/tele_enter.md3\" );\n\n\tVectorCopy( player->s.pos.trBase, snapped );\n\tSnapVector( snapped );\n\tG_SetOrigin( ent, snapped );\n\tVectorCopy( player->r.mins, ent->r.mins );\n\tVectorCopy( player->r.maxs, ent->r.maxs );\n\n\tent->classname = \"hi_portal source\";\n\tent->s.pos.trType = TR_STATIONARY;\n\n\tent->r.contents = CONTENTS_CORPSE | CONTENTS_TRIGGER;\n\tent->takedamage = qtrue;\n\tent->health = 200;\n\tent->die = PortalDie;\n\n\ttrap_LinkEntity( ent );\n\n\tent->count = player->client->portalID;\n\tplayer->client->portalID = 0;\n\n//\tent->spawnflags = player->client->ps.persistant[PERS_TEAM];\n\n\tent->nextthink = level.time + 1000;\n\tent->think = PortalEnable;\n\n\t// find the destination\n\tdestination = NULL;\n\twhile( (destination = G_Find(destination, FOFS(classname), \"hi_portal destination\")) != NULL ) {\n\t\tif( destination->count == ent->count ) {\n\t\t\tVectorCopy( destination->s.pos.trBase, ent->pos1 );\n\t\t\tbreak;\n\t\t}\n\t}\n\n}\n#endif\n"
  },
  {
    "path": "code/game/g_missile.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#include \"g_local.h\"\n\n#define\tMISSILE_PRESTEP_TIME\t50\n\n/*\n================\nG_BounceMissile\n\n================\n*/\nvoid G_BounceMissile( gentity_t *ent, trace_t *trace ) {\n\tvec3_t\tvelocity;\n\tfloat\tdot;\n\tint\t\thitTime;\n\n\t// reflect the velocity on the trace plane\n\thitTime = level.previousTime + ( level.time - level.previousTime ) * trace->fraction;\n\tBG_EvaluateTrajectoryDelta( &ent->s.pos, hitTime, velocity );\n\tdot = DotProduct( velocity, trace->plane.normal );\n\tVectorMA( velocity, -2*dot, trace->plane.normal, ent->s.pos.trDelta );\n\n\tif ( ent->s.eFlags & EF_BOUNCE_HALF ) {\n\t\tVectorScale( ent->s.pos.trDelta, 0.65, ent->s.pos.trDelta );\n\t\t// check for stop\n\t\tif ( trace->plane.normal[2] > 0.2 && VectorLength( ent->s.pos.trDelta ) < 40 ) {\n\t\t\tG_SetOrigin( ent, trace->endpos );\n\t\t\treturn;\n\t\t}\n\t}\n\n\tVectorAdd( ent->r.currentOrigin, trace->plane.normal, ent->r.currentOrigin);\n\tVectorCopy( ent->r.currentOrigin, ent->s.pos.trBase );\n\tent->s.pos.trTime = level.time;\n}\n\n\n/*\n================\nG_ExplodeMissile\n\nExplode a missile without an impact\n================\n*/\nvoid G_ExplodeMissile( gentity_t *ent ) {\n\tvec3_t\t\tdir;\n\tvec3_t\t\torigin;\n\n\tBG_EvaluateTrajectory( &ent->s.pos, level.time, origin );\n\tSnapVector( origin );\n\tG_SetOrigin( ent, origin );\n\n\t// we don't have a valid direction, so just point straight up\n\tdir[0] = dir[1] = 0;\n\tdir[2] = 1;\n\n\tent->s.eType = ET_GENERAL;\n\tG_AddEvent( ent, EV_MISSILE_MISS, DirToByte( dir ) );\n\n\tent->freeAfterEvent = qtrue;\n\n\t// splash damage\n\tif ( ent->splashDamage ) {\n\t\tif( G_RadiusDamage( ent->r.currentOrigin, ent->parent, ent->splashDamage, ent->splashRadius, ent\n\t\t\t, ent->splashMethodOfDeath ) ) {\n\t\t\tg_entities[ent->r.ownerNum].client->accuracy_hits++;\n\t\t}\n\t}\n\n\ttrap_LinkEntity( ent );\n}\n\n\n#ifdef MISSIONPACK\n/*\n================\nProximityMine_Explode\n================\n*/\nstatic void ProximityMine_Explode( gentity_t *mine ) {\n\tG_ExplodeMissile( mine );\n\t// if the prox mine has a trigger free it\n\tif (mine->activator) {\n\t\tG_FreeEntity(mine->activator);\n\t\tmine->activator = NULL;\n\t}\n}\n\n/*\n================\nProximityMine_Die\n================\n*/\nstatic void ProximityMine_Die( gentity_t *ent, gentity_t *inflictor, gentity_t *attacker, int damage, int mod ) {\n\tent->think = ProximityMine_Explode;\n\tent->nextthink = level.time + 1;\n}\n\n/*\n================\nProximityMine_Trigger\n================\n*/\nvoid ProximityMine_Trigger( gentity_t *trigger, gentity_t *other, trace_t *trace ) {\n\tvec3_t\t\tv;\n\tgentity_t\t*mine;\n\n\tif( !other->client ) {\n\t\treturn;\n\t}\n\n\t// trigger is a cube, do a distance test now to act as if it's a sphere\n\tVectorSubtract( trigger->s.pos.trBase, other->s.pos.trBase, v );\n\tif( VectorLength( v ) > trigger->parent->splashRadius ) {\n\t\treturn;\n\t}\n\n\n\tif ( g_gametype.integer >= GT_TEAM ) {\n\t\t// don't trigger same team mines\n\t\tif (trigger->parent->s.generic1 == other->client->sess.sessionTeam) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// ok, now check for ability to damage so we don't get triggered thru walls, closed doors, etc...\n\tif( !CanDamage( other, trigger->s.pos.trBase ) ) {\n\t\treturn;\n\t}\n\n\t// trigger the mine!\n\tmine = trigger->parent;\n\tmine->s.loopSound = 0;\n\tG_AddEvent( mine, EV_PROXIMITY_MINE_TRIGGER, 0 );\n\tmine->nextthink = level.time + 500;\n\n\tG_FreeEntity( trigger );\n}\n\n/*\n================\nProximityMine_Activate\n================\n*/\nstatic void ProximityMine_Activate( gentity_t *ent ) {\n\tgentity_t\t*trigger;\n\tfloat\t\tr;\n\n\tent->think = ProximityMine_Explode;\n\tent->nextthink = level.time + g_proxMineTimeout.integer;\n\n\tent->takedamage = qtrue;\n\tent->health = 1;\n\tent->die = ProximityMine_Die;\n\n\tent->s.loopSound = G_SoundIndex( \"sound/weapons/proxmine/wstbtick.wav\" );\n\n\t// build the proximity trigger\n\ttrigger = G_Spawn ();\n\n\ttrigger->classname = \"proxmine_trigger\";\n\n\tr = ent->splashRadius;\n\tVectorSet( trigger->r.mins, -r, -r, -r );\n\tVectorSet( trigger->r.maxs, r, r, r );\n\n\tG_SetOrigin( trigger, ent->s.pos.trBase );\n\n\ttrigger->parent = ent;\n\ttrigger->r.contents = CONTENTS_TRIGGER;\n\ttrigger->touch = ProximityMine_Trigger;\n\n\ttrap_LinkEntity (trigger);\n\n\t// set pointer to trigger so the entity can be freed when the mine explodes\n\tent->activator = trigger;\n}\n\n/*\n================\nProximityMine_ExplodeOnPlayer\n================\n*/\nstatic void ProximityMine_ExplodeOnPlayer( gentity_t *mine ) {\n\tgentity_t\t*player;\n\n\tplayer = mine->enemy;\n\tplayer->client->ps.eFlags &= ~EF_TICKING;\n\n\tif ( player->client->invulnerabilityTime > level.time ) {\n\t\tG_Damage( player, mine->parent, mine->parent, vec3_origin, mine->s.origin, 1000, DAMAGE_NO_KNOCKBACK, MOD_JUICED );\n\t\tplayer->client->invulnerabilityTime = 0;\n\t\tG_TempEntity( player->client->ps.origin, EV_JUICED );\n\t}\n\telse {\n\t\tG_SetOrigin( mine, player->s.pos.trBase );\n\t\t// make sure the explosion gets to the client\n\t\tmine->r.svFlags &= ~SVF_NOCLIENT;\n\t\tmine->splashMethodOfDeath = MOD_PROXIMITY_MINE;\n\t\tG_ExplodeMissile( mine );\n\t}\n}\n\n/*\n================\nProximityMine_Player\n================\n*/\nstatic void ProximityMine_Player( gentity_t *mine, gentity_t *player ) {\n\tif( mine->s.eFlags & EF_NODRAW ) {\n\t\treturn;\n\t}\n\n\tG_AddEvent( mine, EV_PROXIMITY_MINE_STICK, 0 );\n\n\tif( player->s.eFlags & EF_TICKING ) {\n\t\tplayer->activator->splashDamage += mine->splashDamage;\n\t\tplayer->activator->splashRadius *= 1.50;\n\t\tmine->think = G_FreeEntity;\n\t\tmine->nextthink = level.time;\n\t\treturn;\n\t}\n\n\tplayer->client->ps.eFlags |= EF_TICKING;\n\tplayer->activator = mine;\n\n\tmine->s.eFlags |= EF_NODRAW;\n\tmine->r.svFlags |= SVF_NOCLIENT;\n\tmine->s.pos.trType = TR_LINEAR;\n\tVectorClear( mine->s.pos.trDelta );\n\n\tmine->enemy = player;\n\tmine->think = ProximityMine_ExplodeOnPlayer;\n\tif ( player->client->invulnerabilityTime > level.time ) {\n\t\tmine->nextthink = level.time + 2 * 1000;\n\t}\n\telse {\n\t\tmine->nextthink = level.time + 10 * 1000;\n\t}\n}\n#endif\n\n/*\n================\nG_MissileImpact\n================\n*/\nvoid G_MissileImpact( gentity_t *ent, trace_t *trace ) {\n\tgentity_t\t\t*other;\n\tqboolean\t\thitClient = qfalse;\n#ifdef MISSIONPACK\n\tvec3_t\t\t\tforward, impactpoint, bouncedir;\n\tint\t\t\t\teFlags;\n#endif\n\tother = &g_entities[trace->entityNum];\n\n\t// check for bounce\n\tif ( !other->takedamage &&\n\t\t( ent->s.eFlags & ( EF_BOUNCE | EF_BOUNCE_HALF ) ) ) {\n\t\tG_BounceMissile( ent, trace );\n\t\tG_AddEvent( ent, EV_GRENADE_BOUNCE, 0 );\n\t\treturn;\n\t}\n\n#ifdef MISSIONPACK\n\tif ( other->takedamage ) {\n\t\tif ( ent->s.weapon != WP_PROX_LAUNCHER ) {\n\t\t\tif ( other->client && other->client->invulnerabilityTime > level.time ) {\n\t\t\t\t//\n\t\t\t\tVectorCopy( ent->s.pos.trDelta, forward );\n\t\t\t\tVectorNormalize( forward );\n\t\t\t\tif (G_InvulnerabilityEffect( other, forward, ent->s.pos.trBase, impactpoint, bouncedir )) {\n\t\t\t\t\tVectorCopy( bouncedir, trace->plane.normal );\n\t\t\t\t\teFlags = ent->s.eFlags & EF_BOUNCE_HALF;\n\t\t\t\t\tent->s.eFlags &= ~EF_BOUNCE_HALF;\n\t\t\t\t\tG_BounceMissile( ent, trace );\n\t\t\t\t\tent->s.eFlags |= eFlags;\n\t\t\t\t}\n\t\t\t\tent->target_ent = other;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n#endif\n\t// impact damage\n\tif (other->takedamage) {\n\t\t// FIXME: wrong damage direction?\n\t\tif ( ent->damage ) {\n\t\t\tvec3_t\tvelocity;\n\n\t\t\tif( LogAccuracyHit( other, &g_entities[ent->r.ownerNum] ) ) {\n\t\t\t\tg_entities[ent->r.ownerNum].client->accuracy_hits++;\n\t\t\t\thitClient = qtrue;\n\t\t\t}\n\t\t\tBG_EvaluateTrajectoryDelta( &ent->s.pos, level.time, velocity );\n\t\t\tif ( VectorLength( velocity ) == 0 ) {\n\t\t\t\tvelocity[2] = 1;\t// stepped on a grenade\n\t\t\t}\n\t\t\tG_Damage (other, ent, &g_entities[ent->r.ownerNum], velocity,\n\t\t\t\tent->s.origin, ent->damage, \n\t\t\t\t0, ent->methodOfDeath);\n\t\t}\n\t}\n\n#ifdef MISSIONPACK\n\tif( ent->s.weapon == WP_PROX_LAUNCHER ) {\n\t\tif( ent->s.pos.trType != TR_GRAVITY ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// if it's a player, stick it on to them (flag them and remove this entity)\n\t\tif( other->s.eType == ET_PLAYER && other->health > 0 ) {\n\t\t\tProximityMine_Player( ent, other );\n\t\t\treturn;\n\t\t}\n\n\t\tSnapVectorTowards( trace->endpos, ent->s.pos.trBase );\n\t\tG_SetOrigin( ent, trace->endpos );\n\t\tent->s.pos.trType = TR_STATIONARY;\n\t\tVectorClear( ent->s.pos.trDelta );\n\n\t\tG_AddEvent( ent, EV_PROXIMITY_MINE_STICK, trace->surfaceFlags );\n\n\t\tent->think = ProximityMine_Activate;\n\t\tent->nextthink = level.time + 2000;\n\n\t\tvectoangles( trace->plane.normal, ent->s.angles );\n\t\tent->s.angles[0] += 90;\n\n\t\t// link the prox mine to the other entity\n\t\tent->enemy = other;\n\t\tent->die = ProximityMine_Die;\n\t\tVectorCopy(trace->plane.normal, ent->movedir);\n\t\tVectorSet(ent->r.mins, -4, -4, -4);\n\t\tVectorSet(ent->r.maxs, 4, 4, 4);\n\t\ttrap_LinkEntity(ent);\n\n\t\treturn;\n\t}\n#endif\n\n\tif (!strcmp(ent->classname, \"hook\")) {\n\t\tgentity_t *nent;\n\t\tvec3_t v;\n\n\t\tnent = G_Spawn();\n\t\tif ( other->takedamage && other->client ) {\n\n\t\t\tG_AddEvent( nent, EV_MISSILE_HIT, DirToByte( trace->plane.normal ) );\n\t\t\tnent->s.otherEntityNum = other->s.number;\n\n\t\t\tent->enemy = other;\n\n\t\t\tv[0] = other->r.currentOrigin[0] + (other->r.mins[0] + other->r.maxs[0]) * 0.5;\n\t\t\tv[1] = other->r.currentOrigin[1] + (other->r.mins[1] + other->r.maxs[1]) * 0.5;\n\t\t\tv[2] = other->r.currentOrigin[2] + (other->r.mins[2] + other->r.maxs[2]) * 0.5;\n\n\t\t\tSnapVectorTowards( v, ent->s.pos.trBase );\t// save net bandwidth\n\t\t} else {\n\t\t\tVectorCopy(trace->endpos, v);\n\t\t\tG_AddEvent( nent, EV_MISSILE_MISS, DirToByte( trace->plane.normal ) );\n\t\t\tent->enemy = NULL;\n\t\t}\n\n\t\tSnapVectorTowards( v, ent->s.pos.trBase );\t// save net bandwidth\n\n\t\tnent->freeAfterEvent = qtrue;\n\t\t// change over to a normal entity right at the point of impact\n\t\tnent->s.eType = ET_GENERAL;\n\t\tent->s.eType = ET_GRAPPLE;\n\n\t\tG_SetOrigin( ent, v );\n\t\tG_SetOrigin( nent, v );\n\n\t\tent->think = Weapon_HookThink;\n\t\tent->nextthink = level.time + FRAMETIME;\n\n\t\tent->parent->client->ps.pm_flags |= PMF_GRAPPLE_PULL;\n\t\tVectorCopy( ent->r.currentOrigin, ent->parent->client->ps.grapplePoint);\n\n\t\ttrap_LinkEntity( ent );\n\t\ttrap_LinkEntity( nent );\n\n\t\treturn;\n\t}\n\n\t// is it cheaper in bandwidth to just remove this ent and create a new\n\t// one, rather than changing the missile into the explosion?\n\n\tif ( other->takedamage && other->client ) {\n\t\tG_AddEvent( ent, EV_MISSILE_HIT, DirToByte( trace->plane.normal ) );\n\t\tent->s.otherEntityNum = other->s.number;\n\t} else if( trace->surfaceFlags & SURF_METALSTEPS ) {\n\t\tG_AddEvent( ent, EV_MISSILE_MISS_METAL, DirToByte( trace->plane.normal ) );\n\t} else {\n\t\tG_AddEvent( ent, EV_MISSILE_MISS, DirToByte( trace->plane.normal ) );\n\t}\n\n\tent->freeAfterEvent = qtrue;\n\n\t// change over to a normal entity right at the point of impact\n\tent->s.eType = ET_GENERAL;\n\n\tSnapVectorTowards( trace->endpos, ent->s.pos.trBase );\t// save net bandwidth\n\n\tG_SetOrigin( ent, trace->endpos );\n\n\t// splash damage (doesn't apply to person directly hit)\n\tif ( ent->splashDamage ) {\n\t\tif( G_RadiusDamage( trace->endpos, ent->parent, ent->splashDamage, ent->splashRadius, \n\t\t\tother, ent->splashMethodOfDeath ) ) {\n\t\t\tif( !hitClient ) {\n\t\t\t\tg_entities[ent->r.ownerNum].client->accuracy_hits++;\n\t\t\t}\n\t\t}\n\t}\n\n\ttrap_LinkEntity( ent );\n}\n\n/*\n================\nG_RunMissile\n================\n*/\nvoid G_RunMissile( gentity_t *ent ) {\n\tvec3_t\t\torigin;\n\ttrace_t\t\ttr;\n\tint\t\t\tpassent;\n\n\t// get current position\n\tBG_EvaluateTrajectory( &ent->s.pos, level.time, origin );\n\n\t// if this missile bounced off an invulnerability sphere\n\tif ( ent->target_ent ) {\n\t\tpassent = ent->target_ent->s.number;\n\t}\n#ifdef MISSIONPACK\n\t// prox mines that left the owner bbox will attach to anything, even the owner\n\telse if (ent->s.weapon == WP_PROX_LAUNCHER && ent->count) {\n\t\tpassent = ENTITYNUM_NONE;\n\t}\n#endif\n\telse {\n\t\t// ignore interactions with the missile owner\n\t\tpassent = ent->r.ownerNum;\n\t}\n\t// trace a line from the previous position to the current position\n\ttrap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, origin, passent, ent->clipmask );\n\n\tif ( tr.startsolid || tr.allsolid ) {\n\t\t// make sure the tr.entityNum is set to the entity we're stuck in\n\t\ttrap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, ent->r.currentOrigin, passent, ent->clipmask );\n\t\ttr.fraction = 0;\n\t}\n\telse {\n\t\tVectorCopy( tr.endpos, ent->r.currentOrigin );\n\t}\n\n\ttrap_LinkEntity( ent );\n\n\tif ( tr.fraction != 1 ) {\n\t\t// never explode or bounce on sky\n\t\tif ( tr.surfaceFlags & SURF_NOIMPACT ) {\n\t\t\t// If grapple, reset owner\n\t\t\tif (ent->parent && ent->parent->client && ent->parent->client->hook == ent) {\n\t\t\t\tent->parent->client->hook = NULL;\n\t\t\t}\n\t\t\tG_FreeEntity( ent );\n\t\t\treturn;\n\t\t}\n\t\tG_MissileImpact( ent, &tr );\n\t\tif ( ent->s.eType != ET_MISSILE ) {\n\t\t\treturn;\t\t// exploded\n\t\t}\n\t}\n#ifdef MISSIONPACK\n\t// if the prox mine wasn't yet outside the player body\n\tif (ent->s.weapon == WP_PROX_LAUNCHER && !ent->count) {\n\t\t// check if the prox mine is outside the owner bbox\n\t\ttrap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, ent->r.currentOrigin, ENTITYNUM_NONE, ent->clipmask );\n\t\tif (!tr.startsolid || tr.entityNum != ent->r.ownerNum) {\n\t\t\tent->count = 1;\n\t\t}\n\t}\n#endif\n\t// check think function after bouncing\n\tG_RunThink( ent );\n}\n\n\n//=============================================================================\n\n/*\n=================\nfire_plasma\n\n=================\n*/\ngentity_t *fire_plasma (gentity_t *self, vec3_t start, vec3_t dir) {\n\tgentity_t\t*bolt;\n\n\tVectorNormalize (dir);\n\n\tbolt = G_Spawn();\n\tbolt->classname = \"plasma\";\n\tbolt->nextthink = level.time + 10000;\n\tbolt->think = G_ExplodeMissile;\n\tbolt->s.eType = ET_MISSILE;\n\tbolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;\n\tbolt->s.weapon = WP_PLASMAGUN;\n\tbolt->r.ownerNum = self->s.number;\n\tbolt->parent = self;\n\tbolt->damage = 20;\n\tbolt->splashDamage = 15;\n\tbolt->splashRadius = 20;\n\tbolt->methodOfDeath = MOD_PLASMA;\n\tbolt->splashMethodOfDeath = MOD_PLASMA_SPLASH;\n\tbolt->clipmask = MASK_SHOT;\n\tbolt->target_ent = NULL;\n\n\tbolt->s.pos.trType = TR_LINEAR;\n\tbolt->s.pos.trTime = level.time - MISSILE_PRESTEP_TIME;\t\t// move a bit on the very first frame\n\tVectorCopy( start, bolt->s.pos.trBase );\n\tVectorScale( dir, 2000, bolt->s.pos.trDelta );\n\tSnapVector( bolt->s.pos.trDelta );\t\t\t// save net bandwidth\n\n\tVectorCopy (start, bolt->r.currentOrigin);\n\n\treturn bolt;\n}\t\n\n//=============================================================================\n\n\n/*\n=================\nfire_grenade\n=================\n*/\ngentity_t *fire_grenade (gentity_t *self, vec3_t start, vec3_t dir) {\n\tgentity_t\t*bolt;\n\n\tVectorNormalize (dir);\n\n\tbolt = G_Spawn();\n\tbolt->classname = \"grenade\";\n\tbolt->nextthink = level.time + 2500;\n\tbolt->think = G_ExplodeMissile;\n\tbolt->s.eType = ET_MISSILE;\n\tbolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;\n\tbolt->s.weapon = WP_GRENADE_LAUNCHER;\n\tbolt->s.eFlags = EF_BOUNCE_HALF;\n\tbolt->r.ownerNum = self->s.number;\n\tbolt->parent = self;\n\tbolt->damage = 100;\n\tbolt->splashDamage = 100;\n\tbolt->splashRadius = 150;\n\tbolt->methodOfDeath = MOD_GRENADE;\n\tbolt->splashMethodOfDeath = MOD_GRENADE_SPLASH;\n\tbolt->clipmask = MASK_SHOT;\n\tbolt->target_ent = NULL;\n\n\tbolt->s.pos.trType = TR_GRAVITY;\n\tbolt->s.pos.trTime = level.time - MISSILE_PRESTEP_TIME;\t\t// move a bit on the very first frame\n\tVectorCopy( start, bolt->s.pos.trBase );\n\tVectorScale( dir, 700, bolt->s.pos.trDelta );\n\tSnapVector( bolt->s.pos.trDelta );\t\t\t// save net bandwidth\n\n\tVectorCopy (start, bolt->r.currentOrigin);\n\n\treturn bolt;\n}\n\n//=============================================================================\n\n\n/*\n=================\nfire_bfg\n=================\n*/\ngentity_t *fire_bfg (gentity_t *self, vec3_t start, vec3_t dir) {\n\tgentity_t\t*bolt;\n\n\tVectorNormalize (dir);\n\n\tbolt = G_Spawn();\n\tbolt->classname = \"bfg\";\n\tbolt->nextthink = level.time + 10000;\n\tbolt->think = G_ExplodeMissile;\n\tbolt->s.eType = ET_MISSILE;\n\tbolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;\n\tbolt->s.weapon = WP_BFG;\n\tbolt->r.ownerNum = self->s.number;\n\tbolt->parent = self;\n\tbolt->damage = 100;\n\tbolt->splashDamage = 100;\n\tbolt->splashRadius = 120;\n\tbolt->methodOfDeath = MOD_BFG;\n\tbolt->splashMethodOfDeath = MOD_BFG_SPLASH;\n\tbolt->clipmask = MASK_SHOT;\n\tbolt->target_ent = NULL;\n\n\tbolt->s.pos.trType = TR_LINEAR;\n\tbolt->s.pos.trTime = level.time - MISSILE_PRESTEP_TIME;\t\t// move a bit on the very first frame\n\tVectorCopy( start, bolt->s.pos.trBase );\n\tVectorScale( dir, 2000, bolt->s.pos.trDelta );\n\tSnapVector( bolt->s.pos.trDelta );\t\t\t// save net bandwidth\n\tVectorCopy (start, bolt->r.currentOrigin);\n\n\treturn bolt;\n}\n\n//=============================================================================\n\n\n/*\n=================\nfire_rocket\n=================\n*/\ngentity_t *fire_rocket (gentity_t *self, vec3_t start, vec3_t dir) {\n\tgentity_t\t*bolt;\n\n\tVectorNormalize (dir);\n\n\tbolt = G_Spawn();\n\tbolt->classname = \"rocket\";\n\tbolt->nextthink = level.time + 15000;\n\tbolt->think = G_ExplodeMissile;\n\tbolt->s.eType = ET_MISSILE;\n\tbolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;\n\tbolt->s.weapon = WP_ROCKET_LAUNCHER;\n\tbolt->r.ownerNum = self->s.number;\n\tbolt->parent = self;\n\tbolt->damage = 100;\n\tbolt->splashDamage = 100;\n\tbolt->splashRadius = 120;\n\tbolt->methodOfDeath = MOD_ROCKET;\n\tbolt->splashMethodOfDeath = MOD_ROCKET_SPLASH;\n\tbolt->clipmask = MASK_SHOT;\n\tbolt->target_ent = NULL;\n\n\tbolt->s.pos.trType = TR_LINEAR;\n\tbolt->s.pos.trTime = level.time - MISSILE_PRESTEP_TIME;\t\t// move a bit on the very first frame\n\tVectorCopy( start, bolt->s.pos.trBase );\n\tVectorScale( dir, 900, bolt->s.pos.trDelta );\n\tSnapVector( bolt->s.pos.trDelta );\t\t\t// save net bandwidth\n\tVectorCopy (start, bolt->r.currentOrigin);\n\n\treturn bolt;\n}\n\n/*\n=================\nfire_grapple\n=================\n*/\ngentity_t *fire_grapple (gentity_t *self, vec3_t start, vec3_t dir) {\n\tgentity_t\t*hook;\n\n\tVectorNormalize (dir);\n\n\thook = G_Spawn();\n\thook->classname = \"hook\";\n\thook->nextthink = level.time + 10000;\n\thook->think = Weapon_HookFree;\n\thook->s.eType = ET_MISSILE;\n\thook->r.svFlags = SVF_USE_CURRENT_ORIGIN;\n\thook->s.weapon = WP_GRAPPLING_HOOK;\n\thook->r.ownerNum = self->s.number;\n\thook->methodOfDeath = MOD_GRAPPLE;\n\thook->clipmask = MASK_SHOT;\n\thook->parent = self;\n\thook->target_ent = NULL;\n\n\thook->s.pos.trType = TR_LINEAR;\n\thook->s.pos.trTime = level.time - MISSILE_PRESTEP_TIME;\t\t// move a bit on the very first frame\n\thook->s.otherEntityNum = self->s.number; // use to match beam in client\n\tVectorCopy( start, hook->s.pos.trBase );\n\tVectorScale( dir, 800, hook->s.pos.trDelta );\n\tSnapVector( hook->s.pos.trDelta );\t\t\t// save net bandwidth\n\tVectorCopy (start, hook->r.currentOrigin);\n\n\tself->client->hook = hook;\n\n\treturn hook;\n}\n\n\n#ifdef MISSIONPACK\n/*\n=================\nfire_nail\n=================\n*/\n#define NAILGUN_SPREAD\t500\n\ngentity_t *fire_nail( gentity_t *self, vec3_t start, vec3_t forward, vec3_t right, vec3_t up ) {\n\tgentity_t\t*bolt;\n\tvec3_t\t\tdir;\n\tvec3_t\t\tend;\n\tfloat\t\tr, u, scale;\n\n\tbolt = G_Spawn();\n\tbolt->classname = \"nail\";\n\tbolt->nextthink = level.time + 10000;\n\tbolt->think = G_ExplodeMissile;\n\tbolt->s.eType = ET_MISSILE;\n\tbolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;\n\tbolt->s.weapon = WP_NAILGUN;\n\tbolt->r.ownerNum = self->s.number;\n\tbolt->parent = self;\n\tbolt->damage = 20;\n\tbolt->methodOfDeath = MOD_NAIL;\n\tbolt->clipmask = MASK_SHOT;\n\tbolt->target_ent = NULL;\n\n\tbolt->s.pos.trType = TR_LINEAR;\n\tbolt->s.pos.trTime = level.time;\n\tVectorCopy( start, bolt->s.pos.trBase );\n\n\tr = random() * M_PI * 2.0f;\n\tu = sin(r) * crandom() * NAILGUN_SPREAD * 16;\n\tr = cos(r) * crandom() * NAILGUN_SPREAD * 16;\n\tVectorMA( start, 8192 * 16, forward, end);\n\tVectorMA (end, r, right, end);\n\tVectorMA (end, u, up, end);\n\tVectorSubtract( end, start, dir );\n\tVectorNormalize( dir );\n\n\tscale = 555 + random() * 1800;\n\tVectorScale( dir, scale, bolt->s.pos.trDelta );\n\tSnapVector( bolt->s.pos.trDelta );\n\n\tVectorCopy( start, bolt->r.currentOrigin );\n\n\treturn bolt;\n}\t\n\n\n/*\n=================\nfire_prox\n=================\n*/\ngentity_t *fire_prox( gentity_t *self, vec3_t start, vec3_t dir ) {\n\tgentity_t\t*bolt;\n\n\tVectorNormalize (dir);\n\n\tbolt = G_Spawn();\n\tbolt->classname = \"prox mine\";\n\tbolt->nextthink = level.time + 3000;\n\tbolt->think = G_ExplodeMissile;\n\tbolt->s.eType = ET_MISSILE;\n\tbolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;\n\tbolt->s.weapon = WP_PROX_LAUNCHER;\n\tbolt->s.eFlags = 0;\n\tbolt->r.ownerNum = self->s.number;\n\tbolt->parent = self;\n\tbolt->damage = 0;\n\tbolt->splashDamage = 100;\n\tbolt->splashRadius = 150;\n\tbolt->methodOfDeath = MOD_PROXIMITY_MINE;\n\tbolt->splashMethodOfDeath = MOD_PROXIMITY_MINE;\n\tbolt->clipmask = MASK_SHOT;\n\tbolt->target_ent = NULL;\n\t// count is used to check if the prox mine left the player bbox\n\t// if count == 1 then the prox mine left the player bbox and can attack to it\n\tbolt->count = 0;\n\n\t//FIXME: we prolly wanna abuse another field\n\tbolt->s.generic1 = self->client->sess.sessionTeam;\n\n\tbolt->s.pos.trType = TR_GRAVITY;\n\tbolt->s.pos.trTime = level.time - MISSILE_PRESTEP_TIME;\t\t// move a bit on the very first frame\n\tVectorCopy( start, bolt->s.pos.trBase );\n\tVectorScale( dir, 700, bolt->s.pos.trDelta );\n\tSnapVector( bolt->s.pos.trDelta );\t\t\t// save net bandwidth\n\n\tVectorCopy (start, bolt->r.currentOrigin);\n\n\treturn bolt;\n}\n#endif\n"
  },
  {
    "path": "code/game/g_mover.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n#include \"g_local.h\"\n\n\n\n/*\n===============================================================================\n\nPUSHMOVE\n\n===============================================================================\n*/\n\nvoid MatchTeam( gentity_t *teamLeader, int moverState, int time );\n\ntypedef struct {\n\tgentity_t\t*ent;\n\tvec3_t\torigin;\n\tvec3_t\tangles;\n\tfloat\tdeltayaw;\n} pushed_t;\npushed_t\tpushed[MAX_GENTITIES], *pushed_p;\n\n\n/*\n============\nG_TestEntityPosition\n\n============\n*/\ngentity_t\t*G_TestEntityPosition( gentity_t *ent ) {\n\ttrace_t\ttr;\n\tint\t\tmask;\n\n\tif ( ent->clipmask ) {\n\t\tmask = ent->clipmask;\n\t} else {\n\t\tmask = MASK_SOLID;\n\t}\n\tif ( ent->client ) {\n\t\ttrap_Trace( &tr, ent->client->ps.origin, ent->r.mins, ent->r.maxs, ent->client->ps.origin, ent->s.number, mask );\n\t} else {\n\t\ttrap_Trace( &tr, ent->s.pos.trBase, ent->r.mins, ent->r.maxs, ent->s.pos.trBase, ent->s.number, mask );\n\t}\n\t\n\tif (tr.startsolid)\n\t\treturn &g_entities[ tr.entityNum ];\n\t\t\n\treturn NULL;\n}\n\n/*\n================\nG_CreateRotationMatrix\n================\n*/\nvoid G_CreateRotationMatrix(vec3_t angles, vec3_t matrix[3]) {\n\tAngleVectors(angles, matrix[0], matrix[1], matrix[2]);\n\tVectorInverse(matrix[1]);\n}\n\n/*\n================\nG_TransposeMatrix\n================\n*/\nvoid G_TransposeMatrix(vec3_t matrix[3], vec3_t transpose[3]) {\n\tint i, j;\n\tfor (i = 0; i < 3; i++) {\n\t\tfor (j = 0; j < 3; j++) {\n\t\t\ttranspose[i][j] = matrix[j][i];\n\t\t}\n\t}\n}\n\n/*\n================\nG_RotatePoint\n================\n*/\nvoid G_RotatePoint(vec3_t point, vec3_t matrix[3]) {\n\tvec3_t tvec;\n\n\tVectorCopy(point, tvec);\n\tpoint[0] = DotProduct(matrix[0], tvec);\n\tpoint[1] = DotProduct(matrix[1], tvec);\n\tpoint[2] = DotProduct(matrix[2], tvec);\n}\n\n/*\n==================\nG_TryPushingEntity\n\nReturns qfalse if the move is blocked\n==================\n*/\nqboolean\tG_TryPushingEntity( gentity_t *check, gentity_t *pusher, vec3_t move, vec3_t amove ) {\n\tvec3_t\t\tmatrix[3], transpose[3];\n\tvec3_t\t\torg, org2, move2;\n\tgentity_t\t*block;\n\n\t// EF_MOVER_STOP will just stop when contacting another entity\n\t// instead of pushing it, but entities can still ride on top of it\n\tif ( ( pusher->s.eFlags & EF_MOVER_STOP ) && \n\t\tcheck->s.groundEntityNum != pusher->s.number ) {\n\t\treturn qfalse;\n\t}\n\n\t// save off the old position\n\tif (pushed_p > &pushed[MAX_GENTITIES]) {\n\t\tG_Error( \"pushed_p > &pushed[MAX_GENTITIES]\" );\n\t}\n\tpushed_p->ent = check;\n\tVectorCopy (check->s.pos.trBase, pushed_p->origin);\n\tVectorCopy (check->s.apos.trBase, pushed_p->angles);\n\tif ( check->client ) {\n\t\tpushed_p->deltayaw = check->client->ps.delta_angles[YAW];\n\t\tVectorCopy (check->client->ps.origin, pushed_p->origin);\n\t}\n\tpushed_p++;\n\n\t// try moving the contacted entity \n\t// figure movement due to the pusher's amove\n\tG_CreateRotationMatrix( amove, transpose );\n\tG_TransposeMatrix( transpose, matrix );\n\tif ( check->client ) {\n\t\tVectorSubtract (check->client->ps.origin, pusher->r.currentOrigin, org);\n\t}\n\telse {\n\t\tVectorSubtract (check->s.pos.trBase, pusher->r.currentOrigin, org);\n\t}\n\tVectorCopy( org, org2 );\n\tG_RotatePoint( org2, matrix );\n\tVectorSubtract (org2, org, move2);\n\t// add movement\n\tVectorAdd (check->s.pos.trBase, move, check->s.pos.trBase);\n\tVectorAdd (check->s.pos.trBase, move2, check->s.pos.trBase);\n\tif ( check->client ) {\n\t\tVectorAdd (check->client->ps.origin, move, check->client->ps.origin);\n\t\tVectorAdd (check->client->ps.origin, move2, check->client->ps.origin);\n\t\t// make sure the client's view rotates when on a rotating mover\n\t\tcheck->client->ps.delta_angles[YAW] += ANGLE2SHORT(amove[YAW]);\n\t}\n\n\t// may have pushed them off an edge\n\tif ( check->s.groundEntityNum != pusher->s.number ) {\n\t\tcheck->s.groundEntityNum = -1;\n\t}\n\n\tblock = G_TestEntityPosition( check );\n\tif (!block) {\n\t\t// pushed ok\n\t\tif ( check->client ) {\n\t\t\tVectorCopy( check->client->ps.origin, check->r.currentOrigin );\n\t\t} else {\n\t\t\tVectorCopy( check->s.pos.trBase, check->r.currentOrigin );\n\t\t}\n\t\ttrap_LinkEntity (check);\n\t\treturn qtrue;\n\t}\n\n\t// if it is ok to leave in the old position, do it\n\t// this is only relevent for riding entities, not pushed\n\t// Sliding trapdoors can cause this.\n\tVectorCopy( (pushed_p-1)->origin, check->s.pos.trBase);\n\tif ( check->client ) {\n\t\tVectorCopy( (pushed_p-1)->origin, check->client->ps.origin);\n\t}\n\tVectorCopy( (pushed_p-1)->angles, check->s.apos.trBase );\n\tblock = G_TestEntityPosition (check);\n\tif ( !block ) {\n\t\tcheck->s.groundEntityNum = -1;\n\t\tpushed_p--;\n\t\treturn qtrue;\n\t}\n\n\t// blocked\n\treturn qfalse;\n}\n\n/*\n==================\nG_CheckProxMinePosition\n==================\n*/\nqboolean G_CheckProxMinePosition( gentity_t *check ) {\n\tvec3_t\t\tstart, end;\n\ttrace_t\ttr;\n\n\tVectorMA(check->s.pos.trBase, 0.125, check->movedir, start);\n\tVectorMA(check->s.pos.trBase, 2, check->movedir, end);\n\ttrap_Trace( &tr, start, NULL, NULL, end, check->s.number, MASK_SOLID );\n\t\n\tif (tr.startsolid || tr.fraction < 1)\n\t\treturn qfalse;\n\n\treturn qtrue;\n}\n\n/*\n==================\nG_TryPushingProxMine\n==================\n*/\nqboolean G_TryPushingProxMine( gentity_t *check, gentity_t *pusher, vec3_t move, vec3_t amove ) {\n\tvec3_t\t\tforward, right, up;\n\tvec3_t\t\torg, org2, move2;\n\tint ret;\n\n\t// we need this for pushing things later\n\tVectorSubtract (vec3_origin, amove, org);\n\tAngleVectors (org, forward, right, up);\n\n\t// try moving the contacted entity \n\tVectorAdd (check->s.pos.trBase, move, check->s.pos.trBase);\n\n\t// figure movement due to the pusher's amove\n\tVectorSubtract (check->s.pos.trBase, pusher->r.currentOrigin, org);\n\torg2[0] = DotProduct (org, forward);\n\torg2[1] = -DotProduct (org, right);\n\torg2[2] = DotProduct (org, up);\n\tVectorSubtract (org2, org, move2);\n\tVectorAdd (check->s.pos.trBase, move2, check->s.pos.trBase);\n\n\tret = G_CheckProxMinePosition( check );\n\tif (ret) {\n\t\tVectorCopy( check->s.pos.trBase, check->r.currentOrigin );\n\t\ttrap_LinkEntity (check);\n\t}\n\treturn ret;\n}\n\nvoid G_ExplodeMissile( gentity_t *ent );\n\n/*\n============\nG_MoverPush\n\nObjects need to be moved back on a failed push,\notherwise riders would continue to slide.\nIf qfalse is returned, *obstacle will be the blocking entity\n============\n*/\nqboolean G_MoverPush( gentity_t *pusher, vec3_t move, vec3_t amove, gentity_t **obstacle ) {\n\tint\t\t\ti, e;\n\tgentity_t\t*check;\n\tvec3_t\t\tmins, maxs;\n\tpushed_t\t*p;\n\tint\t\t\tentityList[MAX_GENTITIES];\n\tint\t\t\tlistedEntities;\n\tvec3_t\t\ttotalMins, totalMaxs;\n\n\t*obstacle = NULL;\n\n\n\t// mins/maxs are the bounds at the destination\n\t// totalMins / totalMaxs are the bounds for the entire move\n\tif ( pusher->r.currentAngles[0] || pusher->r.currentAngles[1] || pusher->r.currentAngles[2]\n\t\t|| amove[0] || amove[1] || amove[2] ) {\n\t\tfloat\t\tradius;\n\n\t\tradius = RadiusFromBounds( pusher->r.mins, pusher->r.maxs );\n\t\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\t\tmins[i] = pusher->r.currentOrigin[i] + move[i] - radius;\n\t\t\tmaxs[i] = pusher->r.currentOrigin[i] + move[i] + radius;\n\t\t\ttotalMins[i] = mins[i] - move[i];\n\t\t\ttotalMaxs[i] = maxs[i] - move[i];\n\t\t}\n\t} else {\n\t\tfor (i=0 ; i<3 ; i++) {\n\t\t\tmins[i] = pusher->r.absmin[i] + move[i];\n\t\t\tmaxs[i] = pusher->r.absmax[i] + move[i];\n\t\t}\n\n\t\tVectorCopy( pusher->r.absmin, totalMins );\n\t\tVectorCopy( pusher->r.absmax, totalMaxs );\n\t\tfor (i=0 ; i<3 ; i++) {\n\t\t\tif ( move[i] > 0 ) {\n\t\t\t\ttotalMaxs[i] += move[i];\n\t\t\t} else {\n\t\t\t\ttotalMins[i] += move[i];\n\t\t\t}\n\t\t}\n\t}\n\n\t// unlink the pusher so we don't get it in the entityList\n\ttrap_UnlinkEntity( pusher );\n\n\tlistedEntities = trap_EntitiesInBox( totalMins, totalMaxs, entityList, MAX_GENTITIES );\n\n\t// move the pusher to it's final position\n\tVectorAdd( pusher->r.currentOrigin, move, pusher->r.currentOrigin );\n\tVectorAdd( pusher->r.currentAngles, amove, pusher->r.currentAngles );\n\ttrap_LinkEntity( pusher );\n\n\t// see if any solid entities are inside the final position\n\tfor ( e = 0 ; e < listedEntities ; e++ ) {\n\t\tcheck = &g_entities[ entityList[ e ] ];\n\n#ifdef MISSIONPACK\n\t\tif ( check->s.eType == ET_MISSILE ) {\n\t\t\t// if it is a prox mine\n\t\t\tif ( !strcmp(check->classname, \"prox mine\") ) {\n\t\t\t\t// if this prox mine is attached to this mover try to move it with the pusher\n\t\t\t\tif ( check->enemy == pusher ) {\n\t\t\t\t\tif (!G_TryPushingProxMine( check, pusher, move, amove )) {\n\t\t\t\t\t\t//explode\n\t\t\t\t\t\tcheck->s.loopSound = 0;\n\t\t\t\t\t\tG_AddEvent( check, EV_PROXIMITY_MINE_TRIGGER, 0 );\n\t\t\t\t\t\tG_ExplodeMissile(check);\n\t\t\t\t\t\tif (check->activator) {\n\t\t\t\t\t\t\tG_FreeEntity(check->activator);\n\t\t\t\t\t\t\tcheck->activator = NULL;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t//G_Printf(\"prox mine explodes\\n\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t//check if the prox mine is crushed by the mover\n\t\t\t\t\tif (!G_CheckProxMinePosition( check )) {\n\t\t\t\t\t\t//explode\n\t\t\t\t\t\tcheck->s.loopSound = 0;\n\t\t\t\t\t\tG_AddEvent( check, EV_PROXIMITY_MINE_TRIGGER, 0 );\n\t\t\t\t\t\tG_ExplodeMissile(check);\n\t\t\t\t\t\tif (check->activator) {\n\t\t\t\t\t\t\tG_FreeEntity(check->activator);\n\t\t\t\t\t\t\tcheck->activator = NULL;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t//G_Printf(\"prox mine explodes\\n\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n#endif\n\t\t// only push items and players\n\t\tif ( check->s.eType != ET_ITEM && check->s.eType != ET_PLAYER && !check->physicsObject ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// if the entity is standing on the pusher, it will definitely be moved\n\t\tif ( check->s.groundEntityNum != pusher->s.number ) {\n\t\t\t// see if the ent needs to be tested\n\t\t\tif ( check->r.absmin[0] >= maxs[0]\n\t\t\t|| check->r.absmin[1] >= maxs[1]\n\t\t\t|| check->r.absmin[2] >= maxs[2]\n\t\t\t|| check->r.absmax[0] <= mins[0]\n\t\t\t|| check->r.absmax[1] <= mins[1]\n\t\t\t|| check->r.absmax[2] <= mins[2] ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// see if the ent's bbox is inside the pusher's final position\n\t\t\t// this does allow a fast moving object to pass through a thin entity...\n\t\t\tif (!G_TestEntityPosition (check)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\t// the entity needs to be pushed\n\t\tif ( G_TryPushingEntity( check, pusher, move, amove ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// the move was blocked an entity\n\n\t\t// bobbing entities are instant-kill and never get blocked\n\t\tif ( pusher->s.pos.trType == TR_SINE || pusher->s.apos.trType == TR_SINE ) {\n\t\t\tG_Damage( check, pusher, pusher, NULL, NULL, 99999, 0, MOD_CRUSH );\n\t\t\tcontinue;\n\t\t}\n\n\t\t\n\t\t// save off the obstacle so we can call the block function (crush, etc)\n\t\t*obstacle = check;\n\n\t\t// move back any entities we already moved\n\t\t// go backwards, so if the same entity was pushed\n\t\t// twice, it goes back to the original position\n\t\tfor ( p=pushed_p-1 ; p>=pushed ; p-- ) {\n\t\t\tVectorCopy (p->origin, p->ent->s.pos.trBase);\n\t\t\tVectorCopy (p->angles, p->ent->s.apos.trBase);\n\t\t\tif ( p->ent->client ) {\n\t\t\t\tp->ent->client->ps.delta_angles[YAW] = p->deltayaw;\n\t\t\t\tVectorCopy (p->origin, p->ent->client->ps.origin);\n\t\t\t}\n\t\t\ttrap_LinkEntity (p->ent);\n\t\t}\n\t\treturn qfalse;\n\t}\n\n\treturn qtrue;\n}\n\n\n/*\n=================\nG_MoverTeam\n=================\n*/\nvoid G_MoverTeam( gentity_t *ent ) {\n\tvec3_t\t\tmove, amove;\n\tgentity_t\t*part, *obstacle;\n\tvec3_t\t\torigin, angles;\n\n\tobstacle = NULL;\n\n\t// make sure all team slaves can move before commiting\n\t// any moves or calling any think functions\n\t// if the move is blocked, all moved objects will be backed out\n\tpushed_p = pushed;\n\tfor (part = ent ; part ; part=part->teamchain) {\n\t\t// get current position\n\t\tBG_EvaluateTrajectory( &part->s.pos, level.time, origin );\n\t\tBG_EvaluateTrajectory( &part->s.apos, level.time, angles );\n\t\tVectorSubtract( origin, part->r.currentOrigin, move );\n\t\tVectorSubtract( angles, part->r.currentAngles, amove );\n\t\tif ( !G_MoverPush( part, move, amove, &obstacle ) ) {\n\t\t\tbreak;\t// move was blocked\n\t\t}\n\t}\n\n\tif (part) {\n\t\t// go back to the previous position\n\t\tfor ( part = ent ; part ; part = part->teamchain ) {\n\t\t\tpart->s.pos.trTime += level.time - level.previousTime;\n\t\t\tpart->s.apos.trTime += level.time - level.previousTime;\n\t\t\tBG_EvaluateTrajectory( &part->s.pos, level.time, part->r.currentOrigin );\n\t\t\tBG_EvaluateTrajectory( &part->s.apos, level.time, part->r.currentAngles );\n\t\t\ttrap_LinkEntity( part );\n\t\t}\n\n\t\t// if the pusher has a \"blocked\" function, call it\n\t\tif (ent->blocked) {\n\t\t\tent->blocked( ent, obstacle );\n\t\t}\n\t\treturn;\n\t}\n\n\t// the move succeeded\n\tfor ( part = ent ; part ; part = part->teamchain ) {\n\t\t// call the reached function if time is at or past end point\n\t\tif ( part->s.pos.trType == TR_LINEAR_STOP ) {\n\t\t\tif ( level.time >= part->s.pos.trTime + part->s.pos.trDuration ) {\n\t\t\t\tif ( part->reached ) {\n\t\t\t\t\tpart->reached( part );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n================\nG_RunMover\n\n================\n*/\nvoid G_RunMover( gentity_t *ent ) {\n\t// if not a team captain, don't do anything, because\n\t// the captain will handle everything\n\tif ( ent->flags & FL_TEAMSLAVE ) {\n\t\treturn;\n\t}\n\n\t// if stationary at one of the positions, don't move anything\n\tif ( ent->s.pos.trType != TR_STATIONARY || ent->s.apos.trType != TR_STATIONARY ) {\n\t\tG_MoverTeam( ent );\n\t}\n\n\t// check think function\n\tG_RunThink( ent );\n}\n\n/*\n============================================================================\n\nGENERAL MOVERS\n\nDoors, plats, and buttons are all binary (two position) movers\nPos1 is \"at rest\", pos2 is \"activated\"\n============================================================================\n*/\n\n/*\n===============\nSetMoverState\n===============\n*/\nvoid SetMoverState( gentity_t *ent, moverState_t moverState, int time ) {\n\tvec3_t\t\t\tdelta;\n\tfloat\t\t\tf;\n\n\tent->moverState = moverState;\n\n\tent->s.pos.trTime = time;\n\tswitch( moverState ) {\n\tcase MOVER_POS1:\n\t\tVectorCopy( ent->pos1, ent->s.pos.trBase );\n\t\tent->s.pos.trType = TR_STATIONARY;\n\t\tbreak;\n\tcase MOVER_POS2:\n\t\tVectorCopy( ent->pos2, ent->s.pos.trBase );\n\t\tent->s.pos.trType = TR_STATIONARY;\n\t\tbreak;\n\tcase MOVER_1TO2:\n\t\tVectorCopy( ent->pos1, ent->s.pos.trBase );\n\t\tVectorSubtract( ent->pos2, ent->pos1, delta );\n\t\tf = 1000.0 / ent->s.pos.trDuration;\n\t\tVectorScale( delta, f, ent->s.pos.trDelta );\n\t\tent->s.pos.trType = TR_LINEAR_STOP;\n\t\tbreak;\n\tcase MOVER_2TO1:\n\t\tVectorCopy( ent->pos2, ent->s.pos.trBase );\n\t\tVectorSubtract( ent->pos1, ent->pos2, delta );\n\t\tf = 1000.0 / ent->s.pos.trDuration;\n\t\tVectorScale( delta, f, ent->s.pos.trDelta );\n\t\tent->s.pos.trType = TR_LINEAR_STOP;\n\t\tbreak;\n\t}\n\tBG_EvaluateTrajectory( &ent->s.pos, level.time, ent->r.currentOrigin );\t\n\ttrap_LinkEntity( ent );\n}\n\n/*\n================\nMatchTeam\n\nAll entities in a mover team will move from pos1 to pos2\nin the same amount of time\n================\n*/\nvoid MatchTeam( gentity_t *teamLeader, int moverState, int time ) {\n\tgentity_t\t\t*slave;\n\n\tfor ( slave = teamLeader ; slave ; slave = slave->teamchain ) {\n\t\tSetMoverState( slave, moverState, time );\n\t}\n}\n\n\n\n/*\n================\nReturnToPos1\n================\n*/\nvoid ReturnToPos1( gentity_t *ent ) {\n\tMatchTeam( ent, MOVER_2TO1, level.time );\n\n\t// looping sound\n\tent->s.loopSound = ent->soundLoop;\n\n\t// starting sound\n\tif ( ent->sound2to1 ) {\n\t\tG_AddEvent( ent, EV_GENERAL_SOUND, ent->sound2to1 );\n\t}\n}\n\n\n/*\n================\nReached_BinaryMover\n================\n*/\nvoid Reached_BinaryMover( gentity_t *ent ) {\n\n\t// stop the looping sound\n\tent->s.loopSound = ent->soundLoop;\n\n\tif ( ent->moverState == MOVER_1TO2 ) {\n\t\t// reached pos2\n\t\tSetMoverState( ent, MOVER_POS2, level.time );\n\n\t\t// play sound\n\t\tif ( ent->soundPos2 ) {\n\t\t\tG_AddEvent( ent, EV_GENERAL_SOUND, ent->soundPos2 );\n\t\t}\n\n\t\t// return to pos1 after a delay\n\t\tent->think = ReturnToPos1;\n\t\tent->nextthink = level.time + ent->wait;\n\n\t\t// fire targets\n\t\tif ( !ent->activator ) {\n\t\t\tent->activator = ent;\n\t\t}\n\t\tG_UseTargets( ent, ent->activator );\n\t} else if ( ent->moverState == MOVER_2TO1 ) {\n\t\t// reached pos1\n\t\tSetMoverState( ent, MOVER_POS1, level.time );\n\n\t\t// play sound\n\t\tif ( ent->soundPos1 ) {\n\t\t\tG_AddEvent( ent, EV_GENERAL_SOUND, ent->soundPos1 );\n\t\t}\n\n\t\t// close areaportals\n\t\tif ( ent->teammaster == ent || !ent->teammaster ) {\n\t\t\ttrap_AdjustAreaPortalState( ent, qfalse );\n\t\t}\n\t} else {\n\t\tG_Error( \"Reached_BinaryMover: bad moverState\" );\n\t}\n}\n\n\n/*\n================\nUse_BinaryMover\n================\n*/\nvoid Use_BinaryMover( gentity_t *ent, gentity_t *other, gentity_t *activator ) {\n\tint\t\ttotal;\n\tint\t\tpartial;\n\n\t// only the master should be used\n\tif ( ent->flags & FL_TEAMSLAVE ) {\n\t\tUse_BinaryMover( ent->teammaster, other, activator );\n\t\treturn;\n\t}\n\n\tent->activator = activator;\n\n\tif ( ent->moverState == MOVER_POS1 ) {\n\t\t// start moving 50 msec later, becase if this was player\n\t\t// triggered, level.time hasn't been advanced yet\n\t\tMatchTeam( ent, MOVER_1TO2, level.time + 50 );\n\n\t\t// starting sound\n\t\tif ( ent->sound1to2 ) {\n\t\t\tG_AddEvent( ent, EV_GENERAL_SOUND, ent->sound1to2 );\n\t\t}\n\n\t\t// looping sound\n\t\tent->s.loopSound = ent->soundLoop;\n\n\t\t// open areaportal\n\t\tif ( ent->teammaster == ent || !ent->teammaster ) {\n\t\t\ttrap_AdjustAreaPortalState( ent, qtrue );\n\t\t}\n\t\treturn;\n\t}\n\n\t// if all the way up, just delay before coming down\n\tif ( ent->moverState == MOVER_POS2 ) {\n\t\tent->nextthink = level.time + ent->wait;\n\t\treturn;\n\t}\n\n\t// only partway down before reversing\n\tif ( ent->moverState == MOVER_2TO1 ) {\n\t\ttotal = ent->s.pos.trDuration;\n\t\tpartial = level.time - ent->s.pos.trTime;\n\t\tif ( partial > total ) {\n\t\t\tpartial = total;\n\t\t}\n\n\t\tMatchTeam( ent, MOVER_1TO2, level.time - ( total - partial ) );\n\n\t\tif ( ent->sound1to2 ) {\n\t\t\tG_AddEvent( ent, EV_GENERAL_SOUND, ent->sound1to2 );\n\t\t}\n\t\treturn;\n\t}\n\n\t// only partway up before reversing\n\tif ( ent->moverState == MOVER_1TO2 ) {\n\t\ttotal = ent->s.pos.trDuration;\n\t\tpartial = level.time - ent->s.pos.trTime;\n\t\tif ( partial > total ) {\n\t\t\tpartial = total;\n\t\t}\n\n\t\tMatchTeam( ent, MOVER_2TO1, level.time - ( total - partial ) );\n\n\t\tif ( ent->sound2to1 ) {\n\t\t\tG_AddEvent( ent, EV_GENERAL_SOUND, ent->sound2to1 );\n\t\t}\n\t\treturn;\n\t}\n}\n\n\n\n/*\n================\nInitMover\n\n\"pos1\", \"pos2\", and \"speed\" should be set before calling,\nso the movement delta can be calculated\n================\n*/\nvoid InitMover( gentity_t *ent ) {\n\tvec3_t\t\tmove;\n\tfloat\t\tdistance;\n\tfloat\t\tlight;\n\tvec3_t\t\tcolor;\n\tqboolean\tlightSet, colorSet;\n\tchar\t\t*sound;\n\n\t// if the \"model2\" key is set, use a seperate model\n\t// for drawing, but clip against the brushes\n\tif ( ent->model2 ) {\n\t\tent->s.modelindex2 = G_ModelIndex( ent->model2 );\n\t}\n\n\t// if the \"loopsound\" key is set, use a constant looping sound when moving\n\tif ( G_SpawnString( \"noise\", \"100\", &sound ) ) {\n\t\tent->s.loopSound = G_SoundIndex( sound );\n\t}\n\n\t// if the \"color\" or \"light\" keys are set, setup constantLight\n\tlightSet = G_SpawnFloat( \"light\", \"100\", &light );\n\tcolorSet = G_SpawnVector( \"color\", \"1 1 1\", color );\n\tif ( lightSet || colorSet ) {\n\t\tint\t\tr, g, b, i;\n\n\t\tr = color[0] * 255;\n\t\tif ( r > 255 ) {\n\t\t\tr = 255;\n\t\t}\n\t\tg = color[1] * 255;\n\t\tif ( g > 255 ) {\n\t\t\tg = 255;\n\t\t}\n\t\tb = color[2] * 255;\n\t\tif ( b > 255 ) {\n\t\t\tb = 255;\n\t\t}\n\t\ti = light / 4;\n\t\tif ( i > 255 ) {\n\t\t\ti = 255;\n\t\t}\n\t\tent->s.constantLight = r | ( g << 8 ) | ( b << 16 ) | ( i << 24 );\n\t}\n\n\n\tent->use = Use_BinaryMover;\n\tent->reached = Reached_BinaryMover;\n\n\tent->moverState = MOVER_POS1;\n\tent->r.svFlags = SVF_USE_CURRENT_ORIGIN;\n\tent->s.eType = ET_MOVER;\n\tVectorCopy (ent->pos1, ent->r.currentOrigin);\n\ttrap_LinkEntity (ent);\n\n\tent->s.pos.trType = TR_STATIONARY;\n\tVectorCopy( ent->pos1, ent->s.pos.trBase );\n\n\t// calculate time to reach second position from speed\n\tVectorSubtract( ent->pos2, ent->pos1, move );\n\tdistance = VectorLength( move );\n\tif ( ! ent->speed ) {\n\t\tent->speed = 100;\n\t}\n\tVectorScale( move, ent->speed, ent->s.pos.trDelta );\n\tent->s.pos.trDuration = distance * 1000 / ent->speed;\n\tif ( ent->s.pos.trDuration <= 0 ) {\n\t\tent->s.pos.trDuration = 1;\n\t}\n}\n\n\n/*\n===============================================================================\n\nDOOR\n\nA use can be triggered either by a touch function, by being shot, or by being\ntargeted by another entity.\n\n===============================================================================\n*/\n\n/*\n================\nBlocked_Door\n================\n*/\nvoid Blocked_Door( gentity_t *ent, gentity_t *other ) {\n\t// remove anything other than a client\n\tif ( !other->client ) {\n\t\t// except CTF flags!!!!\n\t\tif( other->s.eType == ET_ITEM && other->item->giType == IT_TEAM ) {\n\t\t\tTeam_DroppedFlagThink( other );\n\t\t\treturn;\n\t\t}\n\t\tG_TempEntity( other->s.origin, EV_ITEM_POP );\n\t\tG_FreeEntity( other );\n\t\treturn;\n\t}\n\n\tif ( ent->damage ) {\n\t\tG_Damage( other, ent, ent, NULL, NULL, ent->damage, 0, MOD_CRUSH );\n\t}\n\tif ( ent->spawnflags & 4 ) {\n\t\treturn;\t\t// crushers don't reverse\n\t}\n\n\t// reverse direction\n\tUse_BinaryMover( ent, ent, other );\n}\n\n/*\n================\nTouch_DoorTriggerSpectator\n================\n*/\nstatic void Touch_DoorTriggerSpectator( gentity_t *ent, gentity_t *other, trace_t *trace ) {\n\tint i, axis;\n\tvec3_t origin, dir, angles;\n\n\taxis = ent->count;\n\tVectorClear(dir);\n\tif (fabs(other->s.origin[axis] - ent->r.absmax[axis]) <\n\t\tfabs(other->s.origin[axis] - ent->r.absmin[axis])) {\n\t\torigin[axis] = ent->r.absmin[axis] - 10;\n\t\tdir[axis] = -1;\n\t}\n\telse {\n\t\torigin[axis] = ent->r.absmax[axis] + 10;\n\t\tdir[axis] = 1;\n\t}\n\tfor (i = 0; i < 3; i++) {\n\t\tif (i == axis) continue;\n\t\torigin[i] = (ent->r.absmin[i] + ent->r.absmax[i]) * 0.5;\n\t}\n\tvectoangles(dir, angles);\n\tTeleportPlayer(other, origin, angles );\n}\n\n/*\n================\nTouch_DoorTrigger\n================\n*/\nvoid Touch_DoorTrigger( gentity_t *ent, gentity_t *other, trace_t *trace ) {\n\tif ( other->client && other->client->sess.sessionTeam == TEAM_SPECTATOR ) {\n\t\t// if the door is not open and not opening\n\t\tif ( ent->parent->moverState != MOVER_1TO2 &&\n\t\t\tent->parent->moverState != MOVER_POS2) {\n\t\t\tTouch_DoorTriggerSpectator( ent, other, trace );\n\t\t}\n\t}\n\telse if ( ent->parent->moverState != MOVER_1TO2 ) {\n\t\tUse_BinaryMover( ent->parent, ent, other );\n\t}\n}\n\n\n/*\n======================\nThink_SpawnNewDoorTrigger\n\nAll of the parts of a door have been spawned, so create\na trigger that encloses all of them\n======================\n*/\nvoid Think_SpawnNewDoorTrigger( gentity_t *ent ) {\n\tgentity_t\t\t*other;\n\tvec3_t\t\tmins, maxs;\n\tint\t\t\ti, best;\n\n\t// set all of the slaves as shootable\n\tfor ( other = ent ; other ; other = other->teamchain ) {\n\t\tother->takedamage = qtrue;\n\t}\n\n\t// find the bounds of everything on the team\n\tVectorCopy (ent->r.absmin, mins);\n\tVectorCopy (ent->r.absmax, maxs);\n\n\tfor (other = ent->teamchain ; other ; other=other->teamchain) {\n\t\tAddPointToBounds (other->r.absmin, mins, maxs);\n\t\tAddPointToBounds (other->r.absmax, mins, maxs);\n\t}\n\n\t// find the thinnest axis, which will be the one we expand\n\tbest = 0;\n\tfor ( i = 1 ; i < 3 ; i++ ) {\n\t\tif ( maxs[i] - mins[i] < maxs[best] - mins[best] ) {\n\t\t\tbest = i;\n\t\t}\n\t}\n\tmaxs[best] += 120;\n\tmins[best] -= 120;\n\n\t// create a trigger with this size\n\tother = G_Spawn ();\n\tother->classname = \"door_trigger\";\n\tVectorCopy (mins, other->r.mins);\n\tVectorCopy (maxs, other->r.maxs);\n\tother->parent = ent;\n\tother->r.contents = CONTENTS_TRIGGER;\n\tother->touch = Touch_DoorTrigger;\n\t// remember the thinnest axis\n\tother->count = best;\n\ttrap_LinkEntity (other);\n\n\tMatchTeam( ent, ent->moverState, level.time );\n}\n\nvoid Think_MatchTeam( gentity_t *ent ) {\n\tMatchTeam( ent, ent->moverState, level.time );\n}\n\n\n/*QUAKED func_door (0 .5 .8) ? START_OPEN x CRUSHER\nTOGGLE\t\twait in both the start and end states for a trigger event.\nSTART_OPEN\tthe door to moves to its destination when spawned, and operate in reverse.  It is used to temporarily or permanently close off an area when triggered (not useful for touch or takedamage doors).\nNOMONSTER\tmonsters will not trigger this door\n\n\"model2\"\t.md3 model to also draw\n\"angle\"\t\tdetermines the opening direction\n\"targetname\" if set, no touch field will be spawned and a remote button or trigger field activates the door.\n\"speed\"\t\tmovement speed (100 default)\n\"wait\"\t\twait before returning (3 default, -1 = never return)\n\"lip\"\t\tlip remaining at end of move (8 default)\n\"dmg\"\t\tdamage to inflict when blocked (2 default)\n\"color\"\t\tconstantLight color\n\"light\"\t\tconstantLight radius\n\"health\"\tif set, the door must be shot open\n*/\nvoid SP_func_door (gentity_t *ent) {\n\tvec3_t\tabs_movedir;\n\tfloat\tdistance;\n\tvec3_t\tsize;\n\tfloat\tlip;\n\n\tent->sound1to2 = ent->sound2to1 = G_SoundIndex(\"sound/movers/doors/dr1_strt.wav\");\n\tent->soundPos1 = ent->soundPos2 = G_SoundIndex(\"sound/movers/doors/dr1_end.wav\");\n\n\tent->blocked = Blocked_Door;\n\n\t// default speed of 400\n\tif (!ent->speed)\n\t\tent->speed = 400;\n\n\t// default wait of 2 seconds\n\tif (!ent->wait)\n\t\tent->wait = 2;\n\tent->wait *= 1000;\n\n\t// default lip of 8 units\n\tG_SpawnFloat( \"lip\", \"8\", &lip );\n\n\t// default damage of 2 points\n\tG_SpawnInt( \"dmg\", \"2\", &ent->damage );\n\n\t// first position at start\n\tVectorCopy( ent->s.origin, ent->pos1 );\n\n\t// calculate second position\n\ttrap_SetBrushModel( ent, ent->model );\n\tG_SetMovedir (ent->s.angles, ent->movedir);\n\tabs_movedir[0] = fabs(ent->movedir[0]);\n\tabs_movedir[1] = fabs(ent->movedir[1]);\n\tabs_movedir[2] = fabs(ent->movedir[2]);\n\tVectorSubtract( ent->r.maxs, ent->r.mins, size );\n\tdistance = DotProduct( abs_movedir, size ) - lip;\n\tVectorMA( ent->pos1, distance, ent->movedir, ent->pos2 );\n\n\t// if \"start_open\", reverse position 1 and 2\n\tif ( ent->spawnflags & 1 ) {\n\t\tvec3_t\ttemp;\n\n\t\tVectorCopy( ent->pos2, temp );\n\t\tVectorCopy( ent->s.origin, ent->pos2 );\n\t\tVectorCopy( temp, ent->pos1 );\n\t}\n\n\tInitMover( ent );\n\n\tent->nextthink = level.time + FRAMETIME;\n\n\tif ( ! (ent->flags & FL_TEAMSLAVE ) ) {\n\t\tint health;\n\n\t\tG_SpawnInt( \"health\", \"0\", &health );\n\t\tif ( health ) {\n\t\t\tent->takedamage = qtrue;\n\t\t}\n\t\tif ( ent->targetname || health ) {\n\t\t\t// non touch/shoot doors\n\t\t\tent->think = Think_MatchTeam;\n\t\t} else {\n\t\t\tent->think = Think_SpawnNewDoorTrigger;\n\t\t}\n\t}\n\n\n}\n\n/*\n===============================================================================\n\nPLAT\n\n===============================================================================\n*/\n\n/*\n==============\nTouch_Plat\n\nDon't allow decent if a living player is on it\n===============\n*/\nvoid Touch_Plat( gentity_t *ent, gentity_t *other, trace_t *trace ) {\n\tif ( !other->client || other->client->ps.stats[STAT_HEALTH] <= 0 ) {\n\t\treturn;\n\t}\n\n\t// delay return-to-pos1 by one second\n\tif ( ent->moverState == MOVER_POS2 ) {\n\t\tent->nextthink = level.time + 1000;\n\t}\n}\n\n/*\n==============\nTouch_PlatCenterTrigger\n\nIf the plat is at the bottom position, start it going up\n===============\n*/\nvoid Touch_PlatCenterTrigger(gentity_t *ent, gentity_t *other, trace_t *trace ) {\n\tif ( !other->client ) {\n\t\treturn;\n\t}\n\n\tif ( ent->parent->moverState == MOVER_POS1 ) {\n\t\tUse_BinaryMover( ent->parent, ent, other );\n\t}\n}\n\n\n/*\n================\nSpawnPlatTrigger\n\nSpawn a trigger in the middle of the plat's low position\nElevator cars require that the trigger extend through the entire low position,\nnot just sit on top of it.\n================\n*/\nvoid SpawnPlatTrigger( gentity_t *ent ) {\n\tgentity_t\t*trigger;\n\tvec3_t\ttmin, tmax;\n\n\t// the middle trigger will be a thin trigger just\n\t// above the starting position\n\ttrigger = G_Spawn();\n\ttrigger->classname = \"plat_trigger\";\n\ttrigger->touch = Touch_PlatCenterTrigger;\n\ttrigger->r.contents = CONTENTS_TRIGGER;\n\ttrigger->parent = ent;\n\t\n\ttmin[0] = ent->pos1[0] + ent->r.mins[0] + 33;\n\ttmin[1] = ent->pos1[1] + ent->r.mins[1] + 33;\n\ttmin[2] = ent->pos1[2] + ent->r.mins[2];\n\n\ttmax[0] = ent->pos1[0] + ent->r.maxs[0] - 33;\n\ttmax[1] = ent->pos1[1] + ent->r.maxs[1] - 33;\n\ttmax[2] = ent->pos1[2] + ent->r.maxs[2] + 8;\n\n\tif ( tmax[0] <= tmin[0] ) {\n\t\ttmin[0] = ent->pos1[0] + (ent->r.mins[0] + ent->r.maxs[0]) *0.5;\n\t\ttmax[0] = tmin[0] + 1;\n\t}\n\tif ( tmax[1] <= tmin[1] ) {\n\t\ttmin[1] = ent->pos1[1] + (ent->r.mins[1] + ent->r.maxs[1]) *0.5;\n\t\ttmax[1] = tmin[1] + 1;\n\t}\n\t\n\tVectorCopy (tmin, trigger->r.mins);\n\tVectorCopy (tmax, trigger->r.maxs);\n\n\ttrap_LinkEntity (trigger);\n}\n\n\n/*QUAKED func_plat (0 .5 .8) ?\nPlats are always drawn in the extended position so they will light correctly.\n\n\"lip\"\t\tdefault 8, protrusion above rest position\n\"height\"\ttotal height of movement, defaults to model height\n\"speed\"\t\toverrides default 200.\n\"dmg\"\t\toverrides default 2\n\"model2\"\t.md3 model to also draw\n\"color\"\t\tconstantLight color\n\"light\"\t\tconstantLight radius\n*/\nvoid SP_func_plat (gentity_t *ent) {\n\tfloat\t\tlip, height;\n\n\tent->sound1to2 = ent->sound2to1 = G_SoundIndex(\"sound/movers/plats/pt1_strt.wav\");\n\tent->soundPos1 = ent->soundPos2 = G_SoundIndex(\"sound/movers/plats/pt1_end.wav\");\n\n\tVectorClear (ent->s.angles);\n\n\tG_SpawnFloat( \"speed\", \"200\", &ent->speed );\n\tG_SpawnInt( \"dmg\", \"2\", &ent->damage );\n\tG_SpawnFloat( \"wait\", \"1\", &ent->wait );\n\tG_SpawnFloat( \"lip\", \"8\", &lip );\n\n\tent->wait = 1000;\n\n\t// create second position\n\ttrap_SetBrushModel( ent, ent->model );\n\n\tif ( !G_SpawnFloat( \"height\", \"0\", &height ) ) {\n\t\theight = (ent->r.maxs[2] - ent->r.mins[2]) - lip;\n\t}\n\n\t// pos1 is the rest (bottom) position, pos2 is the top\n\tVectorCopy( ent->s.origin, ent->pos2 );\n\tVectorCopy( ent->pos2, ent->pos1 );\n\tent->pos1[2] -= height;\n\n\tInitMover( ent );\n\n\t// touch function keeps the plat from returning while\n\t// a live player is standing on it\n\tent->touch = Touch_Plat;\n\n\tent->blocked = Blocked_Door;\n\n\tent->parent = ent;\t// so it can be treated as a door\n\n\t// spawn the trigger if one hasn't been custom made\n\tif ( !ent->targetname ) {\n\t\tSpawnPlatTrigger(ent);\n\t}\n}\n\n\n/*\n===============================================================================\n\nBUTTON\n\n===============================================================================\n*/\n\n/*\n==============\nTouch_Button\n\n===============\n*/\nvoid Touch_Button(gentity_t *ent, gentity_t *other, trace_t *trace ) {\n\tif ( !other->client ) {\n\t\treturn;\n\t}\n\n\tif ( ent->moverState == MOVER_POS1 ) {\n\t\tUse_BinaryMover( ent, other, other );\n\t}\n}\n\n\n/*QUAKED func_button (0 .5 .8) ?\nWhen a button is touched, it moves some distance in the direction of it's angle, triggers all of it's targets, waits some time, then returns to it's original position where it can be triggered again.\n\n\"model2\"\t.md3 model to also draw\n\"angle\"\t\tdetermines the opening direction\n\"target\"\tall entities with a matching targetname will be used\n\"speed\"\t\toverride the default 40 speed\n\"wait\"\t\toverride the default 1 second wait (-1 = never return)\n\"lip\"\t\toverride the default 4 pixel lip remaining at end of move\n\"health\"\tif set, the button must be killed instead of touched\n\"color\"\t\tconstantLight color\n\"light\"\t\tconstantLight radius\n*/\nvoid SP_func_button( gentity_t *ent ) {\n\tvec3_t\t\tabs_movedir;\n\tfloat\t\tdistance;\n\tvec3_t\t\tsize;\n\tfloat\t\tlip;\n\n\tent->sound1to2 = G_SoundIndex(\"sound/movers/switches/butn2.wav\");\n\t\n\tif ( !ent->speed ) {\n\t\tent->speed = 40;\n\t}\n\n\tif ( !ent->wait ) {\n\t\tent->wait = 1;\n\t}\n\tent->wait *= 1000;\n\n\t// first position\n\tVectorCopy( ent->s.origin, ent->pos1 );\n\n\t// calculate second position\n\ttrap_SetBrushModel( ent, ent->model );\n\n\tG_SpawnFloat( \"lip\", \"4\", &lip );\n\n\tG_SetMovedir( ent->s.angles, ent->movedir );\n\tabs_movedir[0] = fabs(ent->movedir[0]);\n\tabs_movedir[1] = fabs(ent->movedir[1]);\n\tabs_movedir[2] = fabs(ent->movedir[2]);\n\tVectorSubtract( ent->r.maxs, ent->r.mins, size );\n\tdistance = abs_movedir[0] * size[0] + abs_movedir[1] * size[1] + abs_movedir[2] * size[2] - lip;\n\tVectorMA (ent->pos1, distance, ent->movedir, ent->pos2);\n\n\tif (ent->health) {\n\t\t// shootable button\n\t\tent->takedamage = qtrue;\n\t} else {\n\t\t// touchable button\n\t\tent->touch = Touch_Button;\n\t}\n\n\tInitMover( ent );\n}\n\n\n\n/*\n===============================================================================\n\nTRAIN\n\n===============================================================================\n*/\n\n\n#define TRAIN_START_ON\t\t1\n#define TRAIN_TOGGLE\t\t2\n#define TRAIN_BLOCK_STOPS\t4\n\n/*\n===============\nThink_BeginMoving\n\nThe wait time at a corner has completed, so start moving again\n===============\n*/\nvoid Think_BeginMoving( gentity_t *ent ) {\n\tent->s.pos.trTime = level.time;\n\tent->s.pos.trType = TR_LINEAR_STOP;\n}\n\n/*\n===============\nReached_Train\n===============\n*/\nvoid Reached_Train( gentity_t *ent ) {\n\tgentity_t\t\t*next;\n\tfloat\t\t\tspeed;\n\tvec3_t\t\t\tmove;\n\tfloat\t\t\tlength;\n\n\t// copy the apropriate values\n\tnext = ent->nextTrain;\n\tif ( !next || !next->nextTrain ) {\n\t\treturn;\t\t// just stop\n\t}\n\n\t// fire all other targets\n\tG_UseTargets( next, NULL );\n\n\t// set the new trajectory\n\tent->nextTrain = next->nextTrain;\n\tVectorCopy( next->s.origin, ent->pos1 );\n\tVectorCopy( next->nextTrain->s.origin, ent->pos2 );\n\n\t// if the path_corner has a speed, use that\n\tif ( next->speed ) {\n\t\tspeed = next->speed;\n\t} else {\n\t\t// otherwise use the train's speed\n\t\tspeed = ent->speed;\n\t}\n\tif ( speed < 1 ) {\n\t\tspeed = 1;\n\t}\n\n\t// calculate duration\n\tVectorSubtract( ent->pos2, ent->pos1, move );\n\tlength = VectorLength( move );\n\n\tent->s.pos.trDuration = length * 1000 / speed;\n\n\t// looping sound\n\tent->s.loopSound = next->soundLoop;\n\n\t// start it going\n\tSetMoverState( ent, MOVER_1TO2, level.time );\n\n\t// if there is a \"wait\" value on the target, don't start moving yet\n\tif ( next->wait ) {\n\t\tent->nextthink = level.time + next->wait * 1000;\n\t\tent->think = Think_BeginMoving;\n\t\tent->s.pos.trType = TR_STATIONARY;\n\t}\n}\n\n\n/*\n===============\nThink_SetupTrainTargets\n\nLink all the corners together\n===============\n*/\nvoid Think_SetupTrainTargets( gentity_t *ent ) {\n\tgentity_t\t\t*path, *next, *start;\n\n\tent->nextTrain = G_Find( NULL, FOFS(targetname), ent->target );\n\tif ( !ent->nextTrain ) {\n\t\tG_Printf( \"func_train at %s with an unfound target\\n\",\n\t\t\tvtos(ent->r.absmin) );\n\t\treturn;\n\t}\n\n\tstart = NULL;\n\tfor ( path = ent->nextTrain ; path != start ; path = next ) {\n\t\tif ( !start ) {\n\t\t\tstart = path;\n\t\t}\n\n\t\tif ( !path->target ) {\n\t\t\tG_Printf( \"Train corner at %s without a target\\n\",\n\t\t\t\tvtos(path->s.origin) );\n\t\t\treturn;\n\t\t}\n\n\t\t// find a path_corner among the targets\n\t\t// there may also be other targets that get fired when the corner\n\t\t// is reached\n\t\tnext = NULL;\n\t\tdo {\n\t\t\tnext = G_Find( next, FOFS(targetname), path->target );\n\t\t\tif ( !next ) {\n\t\t\t\tG_Printf( \"Train corner at %s without a target path_corner\\n\",\n\t\t\t\t\tvtos(path->s.origin) );\n\t\t\t\treturn;\n\t\t\t}\n\t\t} while ( strcmp( next->classname, \"path_corner\" ) );\n\n\t\tpath->nextTrain = next;\n\t}\n\n\t// start the train moving from the first corner\n\tReached_Train( ent );\n}\n\n\n\n/*QUAKED path_corner (.5 .3 0) (-8 -8 -8) (8 8 8)\nTrain path corners.\nTarget: next path corner and other targets to fire\n\"speed\" speed to move to the next corner\n\"wait\" seconds to wait before behining move to next corner\n*/\nvoid SP_path_corner( gentity_t *self ) {\n\tif ( !self->targetname ) {\n\t\tG_Printf (\"path_corner with no targetname at %s\\n\", vtos(self->s.origin));\n\t\tG_FreeEntity( self );\n\t\treturn;\n\t}\n\t// path corners don't need to be linked in\n}\n\n\n\n/*QUAKED func_train (0 .5 .8) ? START_ON TOGGLE BLOCK_STOPS\nA train is a mover that moves between path_corner target points.\nTrains MUST HAVE AN ORIGIN BRUSH.\nThe train spawns at the first target it is pointing at.\n\"model2\"\t.md3 model to also draw\n\"speed\"\t\tdefault 100\n\"dmg\"\t\tdefault\t2\n\"noise\"\t\tlooping sound to play when the train is in motion\n\"target\"\tnext path corner\n\"color\"\t\tconstantLight color\n\"light\"\t\tconstantLight radius\n*/\nvoid SP_func_train (gentity_t *self) {\n\tVectorClear (self->s.angles);\n\n\tif (self->spawnflags & TRAIN_BLOCK_STOPS) {\n\t\tself->damage = 0;\n\t} else {\n\t\tif (!self->damage) {\n\t\t\tself->damage = 2;\n\t\t}\n\t}\n\n\tif ( !self->speed ) {\n\t\tself->speed = 100;\n\t}\n\n\tif ( !self->target ) {\n\t\tG_Printf (\"func_train without a target at %s\\n\", vtos(self->r.absmin));\n\t\tG_FreeEntity( self );\n\t\treturn;\n\t}\n\n\ttrap_SetBrushModel( self, self->model );\n\tInitMover( self );\n\n\tself->reached = Reached_Train;\n\n\t// start trains on the second frame, to make sure their targets have had\n\t// a chance to spawn\n\tself->nextthink = level.time + FRAMETIME;\n\tself->think = Think_SetupTrainTargets;\n}\n\n/*\n===============================================================================\n\nSTATIC\n\n===============================================================================\n*/\n\n\n/*QUAKED func_static (0 .5 .8) ?\nA bmodel that just sits there, doing nothing.  Can be used for conditional walls and models.\n\"model2\"\t.md3 model to also draw\n\"color\"\t\tconstantLight color\n\"light\"\t\tconstantLight radius\n*/\nvoid SP_func_static( gentity_t *ent ) {\n\ttrap_SetBrushModel( ent, ent->model );\n\tInitMover( ent );\n\tVectorCopy( ent->s.origin, ent->s.pos.trBase );\n\tVectorCopy( ent->s.origin, ent->r.currentOrigin );\n}\n\n\n/*\n===============================================================================\n\nROTATING\n\n===============================================================================\n*/\n\n\n/*QUAKED func_rotating (0 .5 .8) ? START_ON - X_AXIS Y_AXIS\nYou need to have an origin brush as part of this entity.  The center of that brush will be\nthe point around which it is rotated. It will rotate around the Z axis by default.  You can\ncheck either the X_AXIS or Y_AXIS box to change that.\n\n\"model2\"\t.md3 model to also draw\n\"speed\"\t\tdetermines how fast it moves; default value is 100.\n\"dmg\"\t\tdamage to inflict when blocked (2 default)\n\"color\"\t\tconstantLight color\n\"light\"\t\tconstantLight radius\n*/\nvoid SP_func_rotating (gentity_t *ent) {\n\tif ( !ent->speed ) {\n\t\tent->speed = 100;\n\t}\n\n\t// set the axis of rotation\n\tent->s.apos.trType = TR_LINEAR;\n\tif ( ent->spawnflags & 4 ) {\n\t\tent->s.apos.trDelta[2] = ent->speed;\n\t} else if ( ent->spawnflags & 8 ) {\n\t\tent->s.apos.trDelta[0] = ent->speed;\n\t} else {\n\t\tent->s.apos.trDelta[1] = ent->speed;\n\t}\n\n\tif (!ent->damage) {\n\t\tent->damage = 2;\n\t}\n\n\ttrap_SetBrushModel( ent, ent->model );\n\tInitMover( ent );\n\n\tVectorCopy( ent->s.origin, ent->s.pos.trBase );\n\tVectorCopy( ent->s.pos.trBase, ent->r.currentOrigin );\n\tVectorCopy( ent->s.apos.trBase, ent->r.currentAngles );\n\n\ttrap_LinkEntity( ent );\n}\n\n\n/*\n===============================================================================\n\nBOBBING\n\n===============================================================================\n*/\n\n\n/*QUAKED func_bobbing (0 .5 .8) ? X_AXIS Y_AXIS\nNormally bobs on the Z axis\n\"model2\"\t.md3 model to also draw\n\"height\"\tamplitude of bob (32 default)\n\"speed\"\t\tseconds to complete a bob cycle (4 default)\n\"phase\"\t\tthe 0.0 to 1.0 offset in the cycle to start at\n\"dmg\"\t\tdamage to inflict when blocked (2 default)\n\"color\"\t\tconstantLight color\n\"light\"\t\tconstantLight radius\n*/\nvoid SP_func_bobbing (gentity_t *ent) {\n\tfloat\t\theight;\n\tfloat\t\tphase;\n\n\tG_SpawnFloat( \"speed\", \"4\", &ent->speed );\n\tG_SpawnFloat( \"height\", \"32\", &height );\n\tG_SpawnInt( \"dmg\", \"2\", &ent->damage );\n\tG_SpawnFloat( \"phase\", \"0\", &phase );\n\n\ttrap_SetBrushModel( ent, ent->model );\n\tInitMover( ent );\n\n\tVectorCopy( ent->s.origin, ent->s.pos.trBase );\n\tVectorCopy( ent->s.origin, ent->r.currentOrigin );\n\n\tent->s.pos.trDuration = ent->speed * 1000;\n\tent->s.pos.trTime = ent->s.pos.trDuration * phase;\n\tent->s.pos.trType = TR_SINE;\n\n\t// set the axis of bobbing\n\tif ( ent->spawnflags & 1 ) {\n\t\tent->s.pos.trDelta[0] = height;\n\t} else if ( ent->spawnflags & 2 ) {\n\t\tent->s.pos.trDelta[1] = height;\n\t} else {\n\t\tent->s.pos.trDelta[2] = height;\n\t}\n}\n\n/*\n===============================================================================\n\nPENDULUM\n\n===============================================================================\n*/\n\n\n/*QUAKED func_pendulum (0 .5 .8) ?\nYou need to have an origin brush as part of this entity.\nPendulums always swing north / south on unrotated models.  Add an angles field to the model to allow rotation in other directions.\nPendulum frequency is a physical constant based on the length of the beam and gravity.\n\"model2\"\t.md3 model to also draw\n\"speed\"\t\tthe number of degrees each way the pendulum swings, (30 default)\n\"phase\"\t\tthe 0.0 to 1.0 offset in the cycle to start at\n\"dmg\"\t\tdamage to inflict when blocked (2 default)\n\"color\"\t\tconstantLight color\n\"light\"\t\tconstantLight radius\n*/\nvoid SP_func_pendulum(gentity_t *ent) {\n\tfloat\t\tfreq;\n\tfloat\t\tlength;\n\tfloat\t\tphase;\n\tfloat\t\tspeed;\n\n\tG_SpawnFloat( \"speed\", \"30\", &speed );\n\tG_SpawnInt( \"dmg\", \"2\", &ent->damage );\n\tG_SpawnFloat( \"phase\", \"0\", &phase );\n\n\ttrap_SetBrushModel( ent, ent->model );\n\n\t// find pendulum length\n\tlength = fabs( ent->r.mins[2] );\n\tif ( length < 8 ) {\n\t\tlength = 8;\n\t}\n\n\tfreq = 1 / ( M_PI * 2 ) * sqrt( g_gravity.value / ( 3 * length ) );\n\n\tent->s.pos.trDuration = ( 1000 / freq );\n\n\tInitMover( ent );\n\n\tVectorCopy( ent->s.origin, ent->s.pos.trBase );\n\tVectorCopy( ent->s.origin, ent->r.currentOrigin );\n\n\tVectorCopy( ent->s.angles, ent->s.apos.trBase );\n\n\tent->s.apos.trDuration = 1000 / freq;\n\tent->s.apos.trTime = ent->s.apos.trDuration * phase;\n\tent->s.apos.trType = TR_SINE;\n\tent->s.apos.trDelta[2] = speed;\n}\n"
  },
  {
    "path": "code/game/g_public.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n// g_public.h -- game module information visible to server\n\n#define\tGAME_API_VERSION\t8\n\n// entity->svFlags\n// the server does not know how to interpret most of the values\n// in entityStates (level eType), so the game must explicitly flag\n// special server behaviors\n#define\tSVF_NOCLIENT\t\t\t0x00000001\t// don't send entity to clients, even if it has effects\n\n// TTimo\n// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=551\n#define SVF_CLIENTMASK 0x00000002\n\n#define SVF_BOT\t\t\t\t\t0x00000008\t// set if the entity is a bot\n#define\tSVF_BROADCAST\t\t\t0x00000020\t// send to all connected clients\n#define\tSVF_PORTAL\t\t\t\t0x00000040\t// merge a second pvs at origin2 into snapshots\n#define\tSVF_USE_CURRENT_ORIGIN\t0x00000080\t// entity->r.currentOrigin instead of entity->s.origin\n\t\t\t\t\t\t\t\t\t\t\t// for link position (missiles and movers)\n#define SVF_SINGLECLIENT\t\t0x00000100\t// only send to a single client (entityShared_t->singleClient)\n#define SVF_NOSERVERINFO\t\t0x00000200\t// don't send CS_SERVERINFO updates to this client\n\t\t\t\t\t\t\t\t\t\t\t// so that it can be updated for ping tools without\n\t\t\t\t\t\t\t\t\t\t\t// lagging clients\n#define SVF_CAPSULE\t\t\t\t0x00000400\t// use capsule for collision detection instead of bbox\n#define SVF_NOTSINGLECLIENT\t\t0x00000800\t// send entity to everyone but one client\n\t\t\t\t\t\t\t\t\t\t\t// (entityShared_t->singleClient)\n\n\n\n//===============================================================\n\n\ntypedef struct {\n\tentityState_t\ts;\t\t\t\t// communicated by server to clients\n\n\tqboolean\tlinked;\t\t\t\t// qfalse if not in any good cluster\n\tint\t\t\tlinkcount;\n\n\tint\t\t\tsvFlags;\t\t\t// SVF_NOCLIENT, SVF_BROADCAST, etc\n\n\t// only send to this client when SVF_SINGLECLIENT is set\t\n\t// if SVF_CLIENTMASK is set, use bitmask for clients to send to (maxclients must be <= 32, up to the mod to enforce this)\n\tint\t\t\tsingleClient;\t\t\n\n\tqboolean\tbmodel;\t\t\t\t// if false, assume an explicit mins / maxs bounding box\n\t\t\t\t\t\t\t\t\t// only set by trap_SetBrushModel\n\tvec3_t\t\tmins, maxs;\n\tint\t\t\tcontents;\t\t\t// CONTENTS_TRIGGER, CONTENTS_SOLID, CONTENTS_BODY, etc\n\t\t\t\t\t\t\t\t\t// a non-solid entity should set to 0\n\n\tvec3_t\t\tabsmin, absmax;\t\t// derived from mins/maxs and origin + rotation\n\n\t// currentOrigin will be used for all collision detection and world linking.\n\t// it will not necessarily be the same as the trajectory evaluation for the current\n\t// time, because each entity must be moved one at a time after time is advanced\n\t// to avoid simultanious collision issues\n\tvec3_t\t\tcurrentOrigin;\n\tvec3_t\t\tcurrentAngles;\n\n\t// when a trace call is made and passEntityNum != ENTITYNUM_NONE,\n\t// an ent will be excluded from testing if:\n\t// ent->s.number == passEntityNum\t(don't interact with self)\n\t// ent->s.ownerNum = passEntityNum\t(don't interact with your own missiles)\n\t// entity[ent->s.ownerNum].ownerNum = passEntityNum\t(don't interact with other missiles from owner)\n\tint\t\t\townerNum;\n} entityShared_t;\n\n\n\n// the server looks at a sharedEntity, which is the start of the game's gentity_t structure\ntypedef struct {\n\tentityState_t\ts;\t\t\t\t// communicated by server to clients\n\tentityShared_t\tr;\t\t\t\t// shared by both the server system and game\n} sharedEntity_t;\n\n\n\n//===============================================================\n\n//\n// system traps provided by the main engine\n//\ntypedef enum {\n\t//============== general Quake services ==================\n\n\tG_PRINT,\t\t// ( const char *string );\n\t// print message on the local console\n\n\tG_ERROR,\t\t// ( const char *string );\n\t// abort the game\n\n\tG_MILLISECONDS,\t// ( void );\n\t// get current time for profiling reasons\n\t// this should NOT be used for any game related tasks,\n\t// because it is not journaled\n\n\t// console variable interaction\n\tG_CVAR_REGISTER,\t// ( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags );\n\tG_CVAR_UPDATE,\t// ( vmCvar_t *vmCvar );\n\tG_CVAR_SET,\t\t// ( const char *var_name, const char *value );\n\tG_CVAR_VARIABLE_INTEGER_VALUE,\t// ( const char *var_name );\n\n\tG_CVAR_VARIABLE_STRING_BUFFER,\t// ( const char *var_name, char *buffer, int bufsize );\n\n\tG_ARGC,\t\t\t// ( void );\n\t// ClientCommand and ServerCommand parameter access\n\n\tG_ARGV,\t\t\t// ( int n, char *buffer, int bufferLength );\n\n\tG_FS_FOPEN_FILE,\t// ( const char *qpath, fileHandle_t *file, fsMode_t mode );\n\tG_FS_READ,\t\t// ( void *buffer, int len, fileHandle_t f );\n\tG_FS_WRITE,\t\t// ( const void *buffer, int len, fileHandle_t f );\n\tG_FS_FCLOSE_FILE,\t\t// ( fileHandle_t f );\n\n\tG_SEND_CONSOLE_COMMAND,\t// ( const char *text );\n\t// add commands to the console as if they were typed in\n\t// for map changing, etc\n\n\n\t//=========== server specific functionality =============\n\n\tG_LOCATE_GAME_DATA,\t\t// ( gentity_t *gEnts, int numGEntities, int sizeofGEntity_t,\n\t//\t\t\t\t\t\t\tplayerState_t *clients, int sizeofGameClient );\n\t// the game needs to let the server system know where and how big the gentities\n\t// are, so it can look at them directly without going through an interface\n\n\tG_DROP_CLIENT,\t\t// ( int clientNum, const char *reason );\n\t// kick a client off the server with a message\n\n\tG_SEND_SERVER_COMMAND,\t// ( int clientNum, const char *fmt, ... );\n\t// reliably sends a command string to be interpreted by the given\n\t// client.  If clientNum is -1, it will be sent to all clients\n\n\tG_SET_CONFIGSTRING,\t// ( int num, const char *string );\n\t// config strings hold all the index strings, and various other information\n\t// that is reliably communicated to all clients\n\t// All of the current configstrings are sent to clients when\n\t// they connect, and changes are sent to all connected clients.\n\t// All confgstrings are cleared at each level start.\n\n\tG_GET_CONFIGSTRING,\t// ( int num, char *buffer, int bufferSize );\n\n\tG_GET_USERINFO,\t\t// ( int num, char *buffer, int bufferSize );\n\t// userinfo strings are maintained by the server system, so they\n\t// are persistant across level loads, while all other game visible\n\t// data is completely reset\n\n\tG_SET_USERINFO,\t\t// ( int num, const char *buffer );\n\n\tG_GET_SERVERINFO,\t// ( char *buffer, int bufferSize );\n\t// the serverinfo info string has all the cvars visible to server browsers\n\n\tG_SET_BRUSH_MODEL,\t// ( gentity_t *ent, const char *name );\n\t// sets mins and maxs based on the brushmodel name\n\n\tG_TRACE,\t// ( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask );\n\t// collision detection against all linked entities\n\n\tG_POINT_CONTENTS,\t// ( const vec3_t point, int passEntityNum );\n\t// point contents against all linked entities\n\n\tG_IN_PVS,\t\t\t// ( const vec3_t p1, const vec3_t p2 );\n\n\tG_IN_PVS_IGNORE_PORTALS,\t// ( const vec3_t p1, const vec3_t p2 );\n\n\tG_ADJUST_AREA_PORTAL_STATE,\t// ( gentity_t *ent, qboolean open );\n\n\tG_AREAS_CONNECTED,\t// ( int area1, int area2 );\n\n\tG_LINKENTITY,\t\t// ( gentity_t *ent );\n\t// an entity will never be sent to a client or used for collision\n\t// if it is not passed to linkentity.  If the size, position, or\n\t// solidity changes, it must be relinked.\n\n\tG_UNLINKENTITY,\t\t// ( gentity_t *ent );\t\t\n\t// call before removing an interactive entity\n\n\tG_ENTITIES_IN_BOX,\t// ( const vec3_t mins, const vec3_t maxs, gentity_t **list, int maxcount );\n\t// EntitiesInBox will return brush models based on their bounding box,\n\t// so exact determination must still be done with EntityContact\n\n\tG_ENTITY_CONTACT,\t// ( const vec3_t mins, const vec3_t maxs, const gentity_t *ent );\n\t// perform an exact check against inline brush models of non-square shape\n\n\t// access for bots to get and free a server client (FIXME?)\n\tG_BOT_ALLOCATE_CLIENT,\t// ( void );\n\n\tG_BOT_FREE_CLIENT,\t// ( int clientNum );\n\n\tG_GET_USERCMD,\t// ( int clientNum, usercmd_t *cmd )\n\n\tG_GET_ENTITY_TOKEN,\t// qboolean ( char *buffer, int bufferSize )\n\t// Retrieves the next string token from the entity spawn text, returning\n\t// false when all tokens have been parsed.\n\t// This should only be done at GAME_INIT time.\n\n\tG_FS_GETFILELIST,\n\tG_DEBUG_POLYGON_CREATE,\n\tG_DEBUG_POLYGON_DELETE,\n\tG_REAL_TIME,\n\tG_SNAPVECTOR,\n\n\tG_TRACECAPSULE,\t// ( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask );\n\tG_ENTITY_CONTACTCAPSULE,\t// ( const vec3_t mins, const vec3_t maxs, const gentity_t *ent );\n\t\n\t// 1.32\n\tG_FS_SEEK,\n\n\tBOTLIB_SETUP = 200,\t\t\t\t// ( void );\n\tBOTLIB_SHUTDOWN,\t\t\t\t// ( void );\n\tBOTLIB_LIBVAR_SET,\n\tBOTLIB_LIBVAR_GET,\n\tBOTLIB_PC_ADD_GLOBAL_DEFINE,\n\tBOTLIB_START_FRAME,\n\tBOTLIB_LOAD_MAP,\n\tBOTLIB_UPDATENTITY,\n\tBOTLIB_TEST,\n\n\tBOTLIB_GET_SNAPSHOT_ENTITY,\t\t// ( int client, int ent );\n\tBOTLIB_GET_CONSOLE_MESSAGE,\t\t// ( int client, char *message, int size );\n\tBOTLIB_USER_COMMAND,\t\t\t// ( int client, usercmd_t *ucmd );\n\n\tBOTLIB_AAS_ENABLE_ROUTING_AREA = 300,\n\tBOTLIB_AAS_BBOX_AREAS,\n\tBOTLIB_AAS_AREA_INFO,\n\tBOTLIB_AAS_ENTITY_INFO,\n\n\tBOTLIB_AAS_INITIALIZED,\n\tBOTLIB_AAS_PRESENCE_TYPE_BOUNDING_BOX,\n\tBOTLIB_AAS_TIME,\n\n\tBOTLIB_AAS_POINT_AREA_NUM,\n\tBOTLIB_AAS_TRACE_AREAS,\n\n\tBOTLIB_AAS_POINT_CONTENTS,\n\tBOTLIB_AAS_NEXT_BSP_ENTITY,\n\tBOTLIB_AAS_VALUE_FOR_BSP_EPAIR_KEY,\n\tBOTLIB_AAS_VECTOR_FOR_BSP_EPAIR_KEY,\n\tBOTLIB_AAS_FLOAT_FOR_BSP_EPAIR_KEY,\n\tBOTLIB_AAS_INT_FOR_BSP_EPAIR_KEY,\n\n\tBOTLIB_AAS_AREA_REACHABILITY,\n\n\tBOTLIB_AAS_AREA_TRAVEL_TIME_TO_GOAL_AREA,\n\n\tBOTLIB_AAS_SWIMMING,\n\tBOTLIB_AAS_PREDICT_CLIENT_MOVEMENT,\n\n\tBOTLIB_EA_SAY = 400,\n\tBOTLIB_EA_SAY_TEAM,\n\tBOTLIB_EA_COMMAND,\n\n\tBOTLIB_EA_ACTION,\n\tBOTLIB_EA_GESTURE,\n\tBOTLIB_EA_TALK,\n\tBOTLIB_EA_ATTACK,\n\tBOTLIB_EA_USE,\n\tBOTLIB_EA_RESPAWN,\n\tBOTLIB_EA_CROUCH,\n\tBOTLIB_EA_MOVE_UP,\n\tBOTLIB_EA_MOVE_DOWN,\n\tBOTLIB_EA_MOVE_FORWARD,\n\tBOTLIB_EA_MOVE_BACK,\n\tBOTLIB_EA_MOVE_LEFT,\n\tBOTLIB_EA_MOVE_RIGHT,\n\n\tBOTLIB_EA_SELECT_WEAPON,\n\tBOTLIB_EA_JUMP,\n\tBOTLIB_EA_DELAYED_JUMP,\n\tBOTLIB_EA_MOVE,\n\tBOTLIB_EA_VIEW,\n\n\tBOTLIB_EA_END_REGULAR,\n\tBOTLIB_EA_GET_INPUT,\n\tBOTLIB_EA_RESET_INPUT,\n\n\n\tBOTLIB_AI_LOAD_CHARACTER = 500,\n\tBOTLIB_AI_FREE_CHARACTER,\n\tBOTLIB_AI_CHARACTERISTIC_FLOAT,\n\tBOTLIB_AI_CHARACTERISTIC_BFLOAT,\n\tBOTLIB_AI_CHARACTERISTIC_INTEGER,\n\tBOTLIB_AI_CHARACTERISTIC_BINTEGER,\n\tBOTLIB_AI_CHARACTERISTIC_STRING,\n\n\tBOTLIB_AI_ALLOC_CHAT_STATE,\n\tBOTLIB_AI_FREE_CHAT_STATE,\n\tBOTLIB_AI_QUEUE_CONSOLE_MESSAGE,\n\tBOTLIB_AI_REMOVE_CONSOLE_MESSAGE,\n\tBOTLIB_AI_NEXT_CONSOLE_MESSAGE,\n\tBOTLIB_AI_NUM_CONSOLE_MESSAGE,\n\tBOTLIB_AI_INITIAL_CHAT,\n\tBOTLIB_AI_REPLY_CHAT,\n\tBOTLIB_AI_CHAT_LENGTH,\n\tBOTLIB_AI_ENTER_CHAT,\n\tBOTLIB_AI_STRING_CONTAINS,\n\tBOTLIB_AI_FIND_MATCH,\n\tBOTLIB_AI_MATCH_VARIABLE,\n\tBOTLIB_AI_UNIFY_WHITE_SPACES,\n\tBOTLIB_AI_REPLACE_SYNONYMS,\n\tBOTLIB_AI_LOAD_CHAT_FILE,\n\tBOTLIB_AI_SET_CHAT_GENDER,\n\tBOTLIB_AI_SET_CHAT_NAME,\n\n\tBOTLIB_AI_RESET_GOAL_STATE,\n\tBOTLIB_AI_RESET_AVOID_GOALS,\n\tBOTLIB_AI_PUSH_GOAL,\n\tBOTLIB_AI_POP_GOAL,\n\tBOTLIB_AI_EMPTY_GOAL_STACK,\n\tBOTLIB_AI_DUMP_AVOID_GOALS,\n\tBOTLIB_AI_DUMP_GOAL_STACK,\n\tBOTLIB_AI_GOAL_NAME,\n\tBOTLIB_AI_GET_TOP_GOAL,\n\tBOTLIB_AI_GET_SECOND_GOAL,\n\tBOTLIB_AI_CHOOSE_LTG_ITEM,\n\tBOTLIB_AI_CHOOSE_NBG_ITEM,\n\tBOTLIB_AI_TOUCHING_GOAL,\n\tBOTLIB_AI_ITEM_GOAL_IN_VIS_BUT_NOT_VISIBLE,\n\tBOTLIB_AI_GET_LEVEL_ITEM_GOAL,\n\tBOTLIB_AI_AVOID_GOAL_TIME,\n\tBOTLIB_AI_INIT_LEVEL_ITEMS,\n\tBOTLIB_AI_UPDATE_ENTITY_ITEMS,\n\tBOTLIB_AI_LOAD_ITEM_WEIGHTS,\n\tBOTLIB_AI_FREE_ITEM_WEIGHTS,\n\tBOTLIB_AI_SAVE_GOAL_FUZZY_LOGIC,\n\tBOTLIB_AI_ALLOC_GOAL_STATE,\n\tBOTLIB_AI_FREE_GOAL_STATE,\n\n\tBOTLIB_AI_RESET_MOVE_STATE,\n\tBOTLIB_AI_MOVE_TO_GOAL,\n\tBOTLIB_AI_MOVE_IN_DIRECTION,\n\tBOTLIB_AI_RESET_AVOID_REACH,\n\tBOTLIB_AI_RESET_LAST_AVOID_REACH,\n\tBOTLIB_AI_REACHABILITY_AREA,\n\tBOTLIB_AI_MOVEMENT_VIEW_TARGET,\n\tBOTLIB_AI_ALLOC_MOVE_STATE,\n\tBOTLIB_AI_FREE_MOVE_STATE,\n\tBOTLIB_AI_INIT_MOVE_STATE,\n\n\tBOTLIB_AI_CHOOSE_BEST_FIGHT_WEAPON,\n\tBOTLIB_AI_GET_WEAPON_INFO,\n\tBOTLIB_AI_LOAD_WEAPON_WEIGHTS,\n\tBOTLIB_AI_ALLOC_WEAPON_STATE,\n\tBOTLIB_AI_FREE_WEAPON_STATE,\n\tBOTLIB_AI_RESET_WEAPON_STATE,\n\n\tBOTLIB_AI_GENETIC_PARENTS_AND_CHILD_SELECTION,\n\tBOTLIB_AI_INTERBREED_GOAL_FUZZY_LOGIC,\n\tBOTLIB_AI_MUTATE_GOAL_FUZZY_LOGIC,\n\tBOTLIB_AI_GET_NEXT_CAMP_SPOT_GOAL,\n\tBOTLIB_AI_GET_MAP_LOCATION_GOAL,\n\tBOTLIB_AI_NUM_INITIAL_CHATS,\n\tBOTLIB_AI_GET_CHAT_MESSAGE,\n\tBOTLIB_AI_REMOVE_FROM_AVOID_GOALS,\n\tBOTLIB_AI_PREDICT_VISIBLE_POSITION,\n\n\tBOTLIB_AI_SET_AVOID_GOAL_TIME,\n\tBOTLIB_AI_ADD_AVOID_SPOT,\n\tBOTLIB_AAS_ALTERNATIVE_ROUTE_GOAL,\n\tBOTLIB_AAS_PREDICT_ROUTE,\n\tBOTLIB_AAS_POINT_REACHABILITY_AREA_INDEX,\n\n\tBOTLIB_PC_LOAD_SOURCE,\n\tBOTLIB_PC_FREE_SOURCE,\n\tBOTLIB_PC_READ_TOKEN,\n\tBOTLIB_PC_SOURCE_FILE_AND_LINE\n\n} gameImport_t;\n\n\n//\n// functions exported by the game subsystem\n//\ntypedef enum {\n\tGAME_INIT,\t// ( int levelTime, int randomSeed, int restart );\n\t// init and shutdown will be called every single level\n\t// The game should call G_GET_ENTITY_TOKEN to parse through all the\n\t// entity configuration text and spawn gentities.\n\n\tGAME_SHUTDOWN,\t// (void);\n\n\tGAME_CLIENT_CONNECT,\t// ( int clientNum, qboolean firstTime, qboolean isBot );\n\t// return NULL if the client is allowed to connect, otherwise return\n\t// a text string with the reason for denial\n\n\tGAME_CLIENT_BEGIN,\t\t\t\t// ( int clientNum );\n\n\tGAME_CLIENT_USERINFO_CHANGED,\t// ( int clientNum );\n\n\tGAME_CLIENT_DISCONNECT,\t\t\t// ( int clientNum );\n\n\tGAME_CLIENT_COMMAND,\t\t\t// ( int clientNum );\n\n\tGAME_CLIENT_THINK,\t\t\t\t// ( int clientNum );\n\n\tGAME_RUN_FRAME,\t\t\t\t\t// ( int levelTime );\n\n\tGAME_CONSOLE_COMMAND,\t\t\t// ( void );\n\t// ConsoleCommand will be called when a command has been issued\n\t// that is not recognized as a builtin function.\n\t// The game can issue trap_argc() / trap_argv() commands to get the command\n\t// and parameters.  Return qfalse if the game doesn't recognize it as a command.\n\n\tBOTAI_START_FRAME\t\t\t\t// ( int time );\n} gameExport_t;\n\n"
  },
  {
    "path": "code/game/g_rankings.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// g_rankings.c -- reports for global rankings system\n\n#include \"g_local.h\"\n#include \"g_rankings.h\"\n\n/*\n================\nG_RankRunFrame\n================\n*/\nvoid G_RankRunFrame()\n{\n\tgentity_t*\t\tent;\n\tgentity_t*\t\tent2;\n\tgrank_status_t\told_status;\n\tgrank_status_t\tstatus;\n\tint\t\t\t\ttime;\n\tint\t\t\t\ti;\n\tint\t\t\t\tj;\n\n\tif( !trap_RankCheckInit() ) \n\t{\n\t\ttrap_RankBegin( GR_GAMEKEY );\n\t}\n\n\ttrap_RankPoll();\n\t\n\tif( trap_RankActive() )\n\t{\n\t\tfor( i = 0; i < level.maxclients; i++ )\n\t\t{\n\t\t\tent = &(g_entities[i]);\n\t\t\tif ( !ent->inuse )\n\t\t\t\tcontinue;\n\t\t\tif ( ent->client == NULL )\n\t\t\t\tcontinue;\n\t\t\tif ( ent->r.svFlags & SVF_BOT)\n\t\t\t{\n\t\t\t\t// no bots in ranked games\n\t\t\t\ttrap_SendConsoleCommand( EXEC_INSERT, va(\"kick %s\\n\", \n\t\t\t\t\tent->client->pers.netname) );\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\told_status = ent->client->client_status;\n\t\t\tstatus = trap_RankUserStatus( i );\n\t\t\t\n\t\t\tif( ent->client->client_status != status )\n\t\t\t{\n\t\t\t\t// inform client of current status\n\t\t\t\t// not needed for client side log in\n\t\t\t\ttrap_SendServerCommand( i, va(\"rank_status %i\\n\",status) );\n\t\t\t\tif ( i == 0 )\n\t\t\t\t{\n\t\t\t\t\tint j = 0;\n\t\t\t\t}\n\t\t\t\tent->client->client_status = status;\n\t\t\t}\n\t\t\t\n\t\t\tswitch( status )\n\t\t\t{\n\t\t\tcase QGR_STATUS_NEW:\n\t\t\tcase QGR_STATUS_SPECTATOR:\n\t\t\t\tif( ent->client->sess.sessionTeam != TEAM_SPECTATOR )\n\t\t\t\t{\n\t\t\t\t\tent->client->sess.sessionTeam = TEAM_SPECTATOR;\n\t\t\t\t\tent->client->sess.spectatorState = SPECTATOR_FREE;\n\t\t\t\t\tClientSpawn( ent );\n\t\t\t\t\t// make sure by now CS_GRAND rankingsGameID is ready\n\t\t\t\t\ttrap_SendServerCommand( i, va(\"rank_status %i\\n\",status) );\n\t\t\t\t\ttrap_SendServerCommand( i, \"rank_menu\\n\" );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase QGR_STATUS_NO_USER:\n\t\t\tcase QGR_STATUS_BAD_PASSWORD:\n\t\t\tcase QGR_STATUS_TIMEOUT:\n\t\t\tcase QGR_STATUS_NO_MEMBERSHIP:\n\t\t\tcase QGR_STATUS_INVALIDUSER:\n\t\t\tcase QGR_STATUS_ERROR:\n\t\t\t\tif( (ent->r.svFlags & SVF_BOT) == 0 )\n\t\t\t\t{\n\t\t\t\t\ttrap_RankUserReset( ent->s.clientNum );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase QGR_STATUS_ACTIVE:\n\t\t\t\tif( (ent->client->sess.sessionTeam == TEAM_SPECTATOR) &&\n\t\t\t\t\t(g_gametype.integer < GT_TEAM) )\n\t\t\t\t{\n\t\t\t\t\tSetTeam( ent, \"free\" );\n\t\t\t\t}\n\n\t\t\t\tif( old_status != QGR_STATUS_ACTIVE )\n\t\t\t\t{\n\t\t\t\t\t// player has just become active\n\t\t\t\t\tfor( j = 0; j < level.maxclients; j++ )\n\t\t\t\t\t{\n\t\t\t\t\t\tent2 = &(g_entities[j]);\n\t\t\t\t\t\tif ( !ent2->inuse )\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tif ( ent2->client == NULL )\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tif ( ent2->r.svFlags & SVF_BOT)\n\t\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\t\tif( (i != j) && (trap_RankUserStatus( j ) == QGR_STATUS_ACTIVE) )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttrap_RankReportInt( i, j, QGR_KEY_PLAYED_WITH, 1, 0 );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// send current scores so the player's rank will show \n\t\t\t\t\t\t// up under the crosshair immediately\n\t\t\t\t\t\tDeathmatchScoreboardMessage( ent2 );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// don't let ranked games last forever\n\t\tif( ((g_fraglimit.integer == 0) || (g_fraglimit.integer > 100)) && \n\t\t\t((g_timelimit.integer == 0) || (g_timelimit.integer > 1000)) )\n\t\t{\n\t\t\ttrap_Cvar_Set( \"timelimit\", \"1000\" );\n\t\t}\n\t}\n\n\t// tell time to clients so they can show current match rating\n\tif( level.intermissiontime == 0 )\n\t{\n\t\tfor( i = 0; i < level.maxclients; i++ )\n\t\t{\n\t\t\tent = &(g_entities[i]);\n\t\t\tif( ent->client == NULL )\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\ttime = (level.time - ent->client->pers.enterTime) / 1000;\n\t\t\tent->client->ps.persistant[PERS_MATCH_TIME] = time;\n\t\t}\n\t}\n}\n\n/*\n================\nG_RankFireWeapon\n================\n*/\nvoid G_RankFireWeapon( int self, int weapon )\n{\n\tif( level.warmupTime != 0 )\n\t{\n\t\t// no reports during warmup period\n\t\treturn;\n\t}\n\t\n\tif( weapon == WP_GAUNTLET )\n\t{\n\t\t// the gauntlet only \"fires\" when it actually hits something\n\t\treturn;\n\t}\n\t\n\ttrap_RankReportInt( self, -1, QGR_KEY_SHOT_FIRED, 1, 1 );\n\t\n\tswitch( weapon )\n\t{\n\tcase WP_MACHINEGUN:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_SHOT_FIRED_MACHINEGUN, 1, 1 );\n\t\tbreak;\n\tcase WP_SHOTGUN:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_SHOT_FIRED_SHOTGUN, 1, 1 );\n\t\tbreak;\n\tcase WP_GRENADE_LAUNCHER:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_SHOT_FIRED_GRENADE, 1, 1 );\n\t\tbreak;\n\tcase WP_ROCKET_LAUNCHER:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_SHOT_FIRED_ROCKET, 1, 1 );\n\t\tbreak;\n\tcase WP_LIGHTNING:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_SHOT_FIRED_LIGHTNING, 1, 1 );\n\t\tbreak;\n\tcase WP_RAILGUN:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_SHOT_FIRED_RAILGUN, 1, 1 );\n\t\tbreak;\n\tcase WP_PLASMAGUN:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_SHOT_FIRED_PLASMA, 1, 1 );\n\t\tbreak;\n\tcase WP_BFG:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_SHOT_FIRED_BFG, 1, 1 );\n\t\tbreak;\n\tcase WP_GRAPPLING_HOOK:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_SHOT_FIRED_GRAPPLE, 1, 1 );\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n}\n\n/*\n================\nG_RankDamage\n================\n*/\nvoid G_RankDamage( int self, int attacker, int damage, int means_of_death )\n{\n\t// state information to avoid counting each shotgun pellet as a hit\n\tstatic int\tlast_framenum = -1;\n\tstatic int\tlast_self = -1;\n\tstatic int\tlast_attacker = -1;\n\tstatic int\tlast_means_of_death = MOD_UNKNOWN;\n\n\tqboolean\tnew_hit;\n\tint\t\t\tsplash;\n\tint\t\t\tkey_hit;\n\tint\t\t\tkey_damage;\n\tint\t\t\tkey_splash;\n\n\tif( level.warmupTime != 0 )\n\t{\n\t\t// no reports during warmup period\n\t\treturn;\n\t}\n\t\n\tnew_hit = (level.framenum != last_framenum) || \n\t\t(self != last_self) || \n\t\t(attacker != last_attacker) || \n\t\t(means_of_death != last_means_of_death);\n\n\t// update state information\n\tlast_framenum = level.framenum;\n\tlast_self = self;\n\tlast_attacker = attacker;\n\tlast_means_of_death = means_of_death;\n\n\t// the gauntlet only \"fires\" when it actually hits something\n\tif( (attacker != ENTITYNUM_WORLD) && (attacker != self) && \n\t\t(means_of_death == MOD_GAUNTLET)  && \n\t\t(g_entities[attacker].client) )\n\t{\n\t\ttrap_RankReportInt( attacker, -1, QGR_KEY_SHOT_FIRED_GAUNTLET, 1, 1 );\n\t}\n\n\t// don't track hazard damage, just deaths\n\tswitch( means_of_death )\n\t{\n\tcase MOD_WATER:\n\tcase MOD_SLIME:\n\tcase MOD_LAVA:\n\tcase MOD_CRUSH:\n\tcase MOD_TELEFRAG:\n\tcase MOD_FALLING:\n\tcase MOD_SUICIDE:\n\tcase MOD_TRIGGER_HURT:\n\t\treturn;\n\tdefault:\n\t\tbreak;\n\t}\n\n\t// get splash damage\n\tswitch( means_of_death )\n\t{\n\tcase MOD_GRENADE_SPLASH:\n\tcase MOD_ROCKET_SPLASH:\n\tcase MOD_PLASMA_SPLASH:\n\tcase MOD_BFG_SPLASH:\n\t\tsplash = damage;\n\t\tbreak;\n\tdefault:\n\t\tsplash = 0;\n\t\tkey_splash = -1;\n\t\tbreak;\n\t}\n\t\n\t// hit, damage, and splash taken\n\tswitch( means_of_death )\n\t{\n\tcase MOD_GAUNTLET:\n\t\tkey_hit = QGR_KEY_HIT_TAKEN_GAUNTLET;\n\t\tkey_damage = QGR_KEY_DAMAGE_TAKEN_GAUNTLET;\n\t\tbreak;\n\tcase MOD_MACHINEGUN:\n\t\tkey_hit = QGR_KEY_HIT_TAKEN_MACHINEGUN;\n\t\tkey_damage = QGR_KEY_DAMAGE_TAKEN_MACHINEGUN;\n\t\tbreak;\n\tcase MOD_SHOTGUN:\n\t\tkey_hit = QGR_KEY_HIT_TAKEN_SHOTGUN;\n\t\tkey_damage = QGR_KEY_DAMAGE_TAKEN_SHOTGUN;\n\t\tbreak;\n\tcase MOD_GRENADE:\n\tcase MOD_GRENADE_SPLASH:\n\t\tkey_hit = QGR_KEY_HIT_TAKEN_GRENADE;\n\t\tkey_damage = QGR_KEY_DAMAGE_TAKEN_GRENADE;\n\t\tkey_splash = QGR_KEY_SPLASH_TAKEN_GRENADE;\n\t\tbreak;\n\tcase MOD_ROCKET:\n\tcase MOD_ROCKET_SPLASH:\n\t\tkey_hit = QGR_KEY_HIT_TAKEN_ROCKET;\n\t\tkey_damage = QGR_KEY_DAMAGE_TAKEN_ROCKET;\n\t\tkey_splash = QGR_KEY_SPLASH_TAKEN_ROCKET;\n\t\tbreak;\n\tcase MOD_PLASMA:\n\tcase MOD_PLASMA_SPLASH:\n\t\tkey_hit = QGR_KEY_HIT_TAKEN_PLASMA;\n\t\tkey_damage = QGR_KEY_DAMAGE_TAKEN_PLASMA;\n\t\tkey_splash = QGR_KEY_SPLASH_TAKEN_PLASMA;\n\t\tbreak;\n\tcase MOD_RAILGUN:\n\t\tkey_hit = QGR_KEY_HIT_TAKEN_RAILGUN;\n\t\tkey_damage = QGR_KEY_DAMAGE_TAKEN_RAILGUN;\n\t\tbreak;\n\tcase MOD_LIGHTNING:\n\t\tkey_hit = QGR_KEY_HIT_TAKEN_LIGHTNING;\n\t\tkey_damage = QGR_KEY_DAMAGE_TAKEN_LIGHTNING;\n\t\tbreak;\n\tcase MOD_BFG:\n\tcase MOD_BFG_SPLASH:\n\t\tkey_hit = QGR_KEY_HIT_TAKEN_BFG;\n\t\tkey_damage = QGR_KEY_DAMAGE_TAKEN_BFG;\n\t\tkey_splash = QGR_KEY_SPLASH_TAKEN_BFG;\n\t\tbreak;\n\tcase MOD_GRAPPLE:\n\t\tkey_hit = QGR_KEY_HIT_TAKEN_GRAPPLE;\n\t\tkey_damage = QGR_KEY_DAMAGE_TAKEN_GRAPPLE;\n\t\tbreak;\n\tdefault:\n\t\tkey_hit = QGR_KEY_HIT_TAKEN_UNKNOWN;\n\t\tkey_damage = QGR_KEY_DAMAGE_TAKEN_UNKNOWN;\n\t\tbreak;\n\t}\n\n\t// report general and specific hit taken\n\tif( new_hit )\n\t{\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_HIT_TAKEN, 1, 1 );\n\t\ttrap_RankReportInt( self, -1, key_hit, 1, 1 );\n\t}\n\t\n\t// report general and specific damage taken\n\ttrap_RankReportInt( self, -1, QGR_KEY_DAMAGE_TAKEN, damage, 1 );\n\ttrap_RankReportInt( self, -1, key_damage, damage, 1 );\n\n\t// report general and specific splash taken\n\tif( splash != 0 )\n\t{\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_SPLASH_TAKEN, splash, 1 );\n\t\ttrap_RankReportInt( self, -1, key_splash, splash, 1 );\n\t}\n\n\t// hit, damage, and splash given\n\tif( (attacker != ENTITYNUM_WORLD) && (attacker != self) )\n\t{\n\t\tswitch( means_of_death )\n\t\t{\n\t\tcase MOD_GAUNTLET:\n\t\t\tkey_hit = QGR_KEY_HIT_GIVEN_GAUNTLET;\n\t\t\tkey_damage = QGR_KEY_DAMAGE_GIVEN_GAUNTLET;\n\t\t\tbreak;\n\t\tcase MOD_MACHINEGUN:\n\t\t\tkey_hit = QGR_KEY_HIT_GIVEN_MACHINEGUN;\n\t\t\tkey_damage = QGR_KEY_DAMAGE_GIVEN_MACHINEGUN;\n\t\t\tbreak;\n\t\tcase MOD_SHOTGUN:\n\t\t\tkey_hit = QGR_KEY_HIT_GIVEN_SHOTGUN;\n\t\t\tkey_damage = QGR_KEY_DAMAGE_GIVEN_SHOTGUN;\n\t\t\tbreak;\n\t\tcase MOD_GRENADE:\n\t\tcase MOD_GRENADE_SPLASH:\n\t\t\tkey_hit = QGR_KEY_HIT_GIVEN_GRENADE;\n\t\t\tkey_damage = QGR_KEY_DAMAGE_GIVEN_GRENADE;\n\t\t\tkey_splash = QGR_KEY_SPLASH_GIVEN_GRENADE;\n\t\t\tbreak;\n\t\tcase MOD_ROCKET:\n\t\tcase MOD_ROCKET_SPLASH:\n\t\t\tkey_hit = QGR_KEY_HIT_GIVEN_ROCKET;\n\t\t\tkey_damage = QGR_KEY_DAMAGE_GIVEN_ROCKET;\n\t\t\tkey_splash = QGR_KEY_SPLASH_GIVEN_ROCKET;\n\t\t\tbreak;\n\t\tcase MOD_PLASMA:\n\t\tcase MOD_PLASMA_SPLASH:\n\t\t\tkey_hit = QGR_KEY_HIT_GIVEN_PLASMA;\n\t\t\tkey_damage = QGR_KEY_DAMAGE_GIVEN_PLASMA;\n\t\t\tkey_splash = QGR_KEY_SPLASH_GIVEN_PLASMA;\n\t\t\tbreak;\n\t\tcase MOD_RAILGUN:\n\t\t\tkey_hit = QGR_KEY_HIT_GIVEN_RAILGUN;\n\t\t\tkey_damage = QGR_KEY_DAMAGE_GIVEN_RAILGUN;\n\t\t\tbreak;\n\t\tcase MOD_LIGHTNING:\n\t\t\tkey_hit = QGR_KEY_HIT_GIVEN_LIGHTNING;\n\t\t\tkey_damage = QGR_KEY_DAMAGE_GIVEN_LIGHTNING;\n\t\t\tbreak;\n\t\tcase MOD_BFG:\n\t\tcase MOD_BFG_SPLASH:\n\t\t\tkey_hit = QGR_KEY_HIT_GIVEN_BFG;\n\t\t\tkey_damage = QGR_KEY_DAMAGE_GIVEN_BFG;\n\t\t\tkey_splash = QGR_KEY_SPLASH_GIVEN_BFG;\n\t\t\tbreak;\n\t\tcase MOD_GRAPPLE:\n\t\t\tkey_hit = QGR_KEY_HIT_GIVEN_GRAPPLE;\n\t\t\tkey_damage = QGR_KEY_DAMAGE_GIVEN_GRAPPLE;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tkey_hit = QGR_KEY_HIT_GIVEN_UNKNOWN;\n\t\t\tkey_damage = QGR_KEY_DAMAGE_GIVEN_UNKNOWN;\n\t\t\tbreak;\n\t\t}\n\t\t\n\t\t// report general and specific hit given\n\t\t// jwu 8/26/00\n\t\t// had a case where attacker is 245 which is grnadeshooter attacker is \n\t\t// g_entities index not necessarilly clientnum\n\t\tif (g_entities[attacker].client) {\n\t\t\tif( new_hit )\n\t\t\t{\n\t\t\t\ttrap_RankReportInt( attacker, -1, QGR_KEY_HIT_GIVEN, 1, 1 );\n\t\t\t\ttrap_RankReportInt( attacker, -1, key_hit, 1, 1 );\n\t\t\t}\n\t\t\t\n\t\t\t// report general and specific damage given\n\t\t\ttrap_RankReportInt( attacker, -1, QGR_KEY_DAMAGE_GIVEN, damage, 1 );\n\t\t\ttrap_RankReportInt( attacker, -1, key_damage, damage, 1 );\n\n\t\t\t// report general and specific splash given\n\t\t\tif( splash != 0 )\n\t\t\t{\n\t\t\t\ttrap_RankReportInt( attacker, -1, QGR_KEY_SPLASH_GIVEN, splash, 1 );\n\t\t\t\ttrap_RankReportInt( attacker, -1, key_splash, splash, 1 );\n\t\t\t}\n\t\t}\n\t}\n\n\t// friendly fire\n\tif( (attacker != self) && \n\t\tOnSameTeam( &(g_entities[self]), &(g_entities[attacker])) &&\n\t\t(g_entities[attacker].client) )\n\t{\n\t\t// report teammate hit\n\t\tif( new_hit )\n\t\t{\n\t\t\ttrap_RankReportInt( self, -1, QGR_KEY_TEAMMATE_HIT_TAKEN, 1, 1 );\n\t\t\ttrap_RankReportInt( attacker, -1, QGR_KEY_TEAMMATE_HIT_GIVEN, 1, \n\t\t\t\t1 );\n\t\t}\n\n\t\t// report teammate damage\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_TEAMMATE_DAMAGE_TAKEN, damage, \n\t\t\t1 );\n\t\ttrap_RankReportInt( attacker, -1, QGR_KEY_TEAMMATE_DAMAGE_GIVEN, \n\t\t\tdamage, 1 );\n\t\t\t\n\t\t// report teammate splash\n\t\tif( splash != 0 )\n\t\t{\n\t\t\ttrap_RankReportInt( self, -1, QGR_KEY_TEAMMATE_SPLASH_TAKEN, \n\t\t\t\tsplash, 1 );\n\t\t\ttrap_RankReportInt( attacker, -1, QGR_KEY_TEAMMATE_SPLASH_GIVEN, \n\t\t\t\tsplash, 1 );\n\t\t}\n\t}\n}\n\n/*\n================\nG_RankPlayerDie\n================\n*/\nvoid G_RankPlayerDie( int self, int attacker, int means_of_death )\n{\n\tint\tp1;\n\tint\tp2;\n\n\tif( level.warmupTime != 0 )\n\t{\n\t\t// no reports during warmup period\n\t\treturn;\n\t}\n\t\n\tif( attacker == ENTITYNUM_WORLD )\n\t{\n\t\tp1 = self;\n\t\tp2 = -1;\n\t\t\n\t\ttrap_RankReportInt( p1, p2, QGR_KEY_HAZARD_DEATH, 1, 1 );\n\n\t\tswitch( means_of_death )\n\t\t{\n\t\tcase MOD_WATER:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_WATER, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_SLIME:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_SLIME, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_LAVA:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_LAVA, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_CRUSH:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_CRUSH, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_TELEFRAG:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_TELEFRAG, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_FALLING:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_FALLING, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_SUICIDE:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_SUICIDE_CMD, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_TRIGGER_HURT:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_TRIGGER_HURT, 1, 1 );\n\t\t\tbreak;\n\t\tdefault:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_HAZARD_MISC, 1, 1 );\n\t\t\tbreak;\n\t\t}\n\t}\n\telse if( attacker == self )\n\t{\n\t\tp1 = self;\n\t\tp2 = -1;\n\t\t\n\t\ttrap_RankReportInt( p1, p2, QGR_KEY_SUICIDE, 1, 1 );\n\t\t\n\t\tswitch( means_of_death )\n\t\t{\n\t\tcase MOD_GAUNTLET:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_SUICIDE_GAUNTLET, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_MACHINEGUN:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_SUICIDE_MACHINEGUN, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_SHOTGUN:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_SUICIDE_SHOTGUN, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_GRENADE:\n\t\tcase MOD_GRENADE_SPLASH:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_SUICIDE_GRENADE, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_ROCKET:\n\t\tcase MOD_ROCKET_SPLASH:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_SUICIDE_ROCKET, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_PLASMA:\n\t\tcase MOD_PLASMA_SPLASH:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_SUICIDE_PLASMA, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_RAILGUN:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_SUICIDE_RAILGUN, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_LIGHTNING:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_SUICIDE_LIGHTNING, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_BFG:\n\t\tcase MOD_BFG_SPLASH:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_SUICIDE_BFG, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_GRAPPLE:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_SUICIDE_GRAPPLE, 1, 1 );\n\t\t\tbreak;\n\t\tdefault:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_SUICIDE_UNKNOWN, 1, 1 );\n\t\t\tbreak;\n\t\t}\n\t}\n\telse\n\t{\n\t\tp1 = attacker;\n\t\tp2 = self;\n\n\t\ttrap_RankReportInt( p1, p2, QGR_KEY_FRAG, 1, 1 );\n\t\t\n\t\tswitch( means_of_death )\n\t\t{\n\t\tcase MOD_GAUNTLET:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_FRAG_GAUNTLET, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_MACHINEGUN:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_FRAG_MACHINEGUN, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_SHOTGUN:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_FRAG_SHOTGUN, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_GRENADE:\n\t\tcase MOD_GRENADE_SPLASH:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_FRAG_GRENADE, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_ROCKET:\n\t\tcase MOD_ROCKET_SPLASH:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_FRAG_ROCKET, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_PLASMA:\n\t\tcase MOD_PLASMA_SPLASH:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_FRAG_PLASMA, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_RAILGUN:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_FRAG_RAILGUN, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_LIGHTNING:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_FRAG_LIGHTNING, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_BFG:\n\t\tcase MOD_BFG_SPLASH:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_FRAG_BFG, 1, 1 );\n\t\t\tbreak;\n\t\tcase MOD_GRAPPLE:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_FRAG_GRAPPLE, 1, 1 );\n\t\t\tbreak;\n\t\tdefault:\n\t\t\ttrap_RankReportInt( p1, p2, QGR_KEY_FRAG_UNKNOWN, 1, 1 );\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/*\n================\nG_RankWeaponTime\n================\n*/\nvoid G_RankWeaponTime( int self, int weapon )\n{\n\tgclient_t*\tclient;\n\tint\t\t\ttime;\n\n\tif( level.warmupTime != 0 )\n\t{\n\t\t// no reports during warmup period\n\t\treturn;\n\t}\n\t\n\tclient = g_entities[self].client;\n\ttime = (level.time - client->weapon_change_time) / 1000;\n\tclient->weapon_change_time = level.time;\n\n\tif( time <= 0 )\n\t{\n\t\treturn;\n\t}\n\t\n\ttrap_RankReportInt( self, -1, QGR_KEY_TIME, time, 1 );\n\n\tswitch( weapon )\n\t{\n\tcase WP_GAUNTLET:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_TIME_GAUNTLET, time, 1 );\n\t\tbreak;\n\tcase WP_MACHINEGUN:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_TIME_MACHINEGUN, time, 1 );\n\t\tbreak;\n\tcase WP_SHOTGUN:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_TIME_SHOTGUN, time, 1 );\n\t\tbreak;\n\tcase WP_GRENADE_LAUNCHER:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_TIME_GRENADE, time, 1 );\n\t\tbreak;\n\tcase WP_ROCKET_LAUNCHER:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_TIME_ROCKET, time, 1 );\n\t\tbreak;\n\tcase WP_LIGHTNING:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_TIME_LIGHTNING, time, 1 );\n\t\tbreak;\n\tcase WP_RAILGUN:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_TIME_RAILGUN, time, 1 );\n\t\tbreak;\n\tcase WP_PLASMAGUN:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_TIME_PLASMA, time, 1 );\n\t\tbreak;\n\tcase WP_BFG:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_TIME_BFG, time, 1 );\n\t\tbreak;\n\tcase WP_GRAPPLING_HOOK:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_TIME_GRAPPLE, time, 1 );\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n}\n\n/*\n================\nG_RankPickupWeapon\n================\n*/\nvoid G_RankPickupWeapon( int self, int weapon )\n{\n\tif( level.warmupTime != 0 )\n\t{\n\t\t// no reports during warmup period\n\t\treturn;\n\t}\n\t\n\ttrap_RankReportInt( self, -1, QGR_KEY_PICKUP_WEAPON, 1, 1 );\n\tswitch( weapon )\n\t{\n\tcase WP_GAUNTLET:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_PICKUP_GAUNTLET, 1, 1 );\n\t\tbreak;\n\tcase WP_MACHINEGUN:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_PICKUP_MACHINEGUN, 1, 1 );\n\t\tbreak;\n\tcase WP_SHOTGUN:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_PICKUP_SHOTGUN, 1, 1 );\n\t\tbreak;\n\tcase WP_GRENADE_LAUNCHER:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_PICKUP_GRENADE, 1, 1 );\n\t\tbreak;\n\tcase WP_ROCKET_LAUNCHER:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_PICKUP_ROCKET, 1, 1 );\n\t\tbreak;\n\tcase WP_LIGHTNING:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_PICKUP_LIGHTNING, 1, 1 );\n\t\tbreak;\n\tcase WP_RAILGUN:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_PICKUP_RAILGUN, 1, 1 );\n\t\tbreak;\n\tcase WP_PLASMAGUN:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_PICKUP_PLASMA, 1, 1 );\n\t\tbreak;\n\tcase WP_BFG:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_PICKUP_BFG, 1, 1 );\n\t\tbreak;\n\tcase WP_GRAPPLING_HOOK:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_PICKUP_GRAPPLE, 1, 1 );\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n}\n\n/*\n================\nG_RankPickupAmmo\n================\n*/\nvoid G_RankPickupAmmo( int self, int weapon, int quantity )\n{\n\tif( level.warmupTime != 0 )\n\t{\n\t\t// no reports during warmup period\n\t\treturn;\n\t}\n\t\n\ttrap_RankReportInt( self, -1, QGR_KEY_BOXES, 1, 1 );\n\ttrap_RankReportInt( self, -1, QGR_KEY_ROUNDS, quantity, 1 );\n\t\n\tswitch( weapon )\n\t{\n\tcase WP_MACHINEGUN:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_BOXES_BULLETS, 1, 1 );\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_ROUNDS_BULLETS, quantity, 1 );\n\t\tbreak;\n\tcase WP_SHOTGUN:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_BOXES_SHELLS, 1, 1 );\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_ROUNDS_SHELLS, quantity, 1 );\n\t\tbreak;\n\tcase WP_GRENADE_LAUNCHER:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_BOXES_GRENADES, 1, 1 );\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_ROUNDS_GRENADES, quantity, 1 );\n\t\tbreak;\n\tcase WP_ROCKET_LAUNCHER:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_BOXES_ROCKETS, 1, 1 );\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_ROUNDS_ROCKETS, quantity, 1 );\n\t\tbreak;\n\tcase WP_LIGHTNING:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_BOXES_LG_AMMO, 1, 1 );\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_ROUNDS_LG_AMMO, quantity, 1 );\n\t\tbreak;\n\tcase WP_RAILGUN:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_BOXES_SLUGS, 1, 1 );\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_ROUNDS_SLUGS, quantity, 1 );\n\t\tbreak;\n\tcase WP_PLASMAGUN:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_BOXES_CELLS, 1, 1 );\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_ROUNDS_CELLS, quantity, 1 );\n\t\tbreak;\n\tcase WP_BFG:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_BOXES_BFG_AMMO, 1, 1 );\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_ROUNDS_BFG_AMMO, quantity, 1 );\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n}\n\n/*\n================\nG_RankPickupHealth\n================\n*/\nvoid G_RankPickupHealth( int self, int quantity )\n{\n\tif( level.warmupTime != 0 )\n\t{\n\t\t// no reports during warmup period\n\t\treturn;\n\t}\n\t\n\ttrap_RankReportInt( self, -1, QGR_KEY_HEALTH, 1, 1 );\n\ttrap_RankReportInt( self, -1, QGR_KEY_HEALTH_TOTAL, quantity, 1 );\n\n\tswitch( quantity )\n\t{\n\tcase 5:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_HEALTH_5, 1, 1 );\n\t\tbreak;\n\tcase 25:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_HEALTH_25, 1, 1 );\n\t\tbreak;\n\tcase 50:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_HEALTH_50, 1, 1 );\n\t\tbreak;\n\tcase 100:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_HEALTH_MEGA, 1, 1 );\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n}\n\n/*\n================\nG_RankPickupArmor\n================\n*/\nvoid G_RankPickupArmor( int self, int quantity )\n{\n\tif( level.warmupTime != 0 )\n\t{\n\t\t// no reports during warmup period\n\t\treturn;\n\t}\n\t\n\ttrap_RankReportInt( self, -1, QGR_KEY_ARMOR, 1, 1 );\n\ttrap_RankReportInt( self, -1, QGR_KEY_ARMOR_TOTAL, quantity, 1 );\n\n\tswitch( quantity )\n\t{\n\tcase 5:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_ARMOR_SHARD, 1, 1 );\n\t\tbreak;\n\tcase 50:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_ARMOR_YELLOW, 1, 1 );\n\t\tbreak;\n\tcase 100:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_ARMOR_RED, 1, 1 );\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n}\n\n/*\n================\nG_RankPickupPowerup\n================\n*/\nvoid G_RankPickupPowerup( int self, int powerup )\n{\n\tif( level.warmupTime != 0 )\n\t{\n\t\t// no reports during warmup period\n\t\treturn;\n\t}\n\t\n\t// ctf flags are treated as powerups\n\tif( (powerup == PW_REDFLAG) || (powerup == PW_BLUEFLAG) )\n\t{\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_FLAG_PICKUP, 1, 1 );\n\t\treturn;\n\t}\n\n\ttrap_RankReportInt( self, -1, QGR_KEY_POWERUP, 1, 1 );\n\t\n\tswitch( powerup )\n\t{\n\tcase PW_QUAD:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_QUAD, 1, 1 );\n\t\tbreak;\n\tcase PW_BATTLESUIT:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_SUIT, 1, 1 );\n\t\tbreak;\n\tcase PW_HASTE:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_HASTE, 1, 1 );\n\t\tbreak;\n\tcase PW_INVIS:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_INVIS, 1, 1 );\n\t\tbreak;\n\tcase PW_REGEN:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_REGEN, 1, 1 );\n\t\tbreak;\n\tcase PW_FLIGHT:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_FLIGHT, 1, 1 );\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n}\n\n/*\n================\nG_RankPickupHoldable\n================\n*/\nvoid G_RankPickupHoldable( int self, int holdable )\n{\n\tif( level.warmupTime != 0 )\n\t{\n\t\t// no reports during warmup period\n\t\treturn;\n\t}\n\t\n\tswitch( holdable )\n\t{\n\tcase HI_MEDKIT:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_MEDKIT, 1, 1 );\n\t\tbreak;\n\tcase HI_TELEPORTER:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_TELEPORTER, 1, 1 );\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n}\n\n/*\n================\nG_RankUseHoldable\n================\n*/\nvoid G_RankUseHoldable( int self, int holdable )\n{\n\tif( level.warmupTime != 0 )\n\t{\n\t\t// no reports during warmup period\n\t\treturn;\n\t}\n\t\n\tswitch( holdable )\n\t{\n\tcase HI_MEDKIT:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_MEDKIT_USE, 1, 1 );\n\t\tbreak;\n\tcase HI_TELEPORTER:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_TELEPORTER_USE, 1, 1 );\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n}\n\n/*\n================\nG_RankReward\n================\n*/\nvoid G_RankReward( int self, int award )\n{\n\tif( level.warmupTime != 0 )\n\t{\n\t\t// no reports during warmup period\n\t\treturn;\n\t}\n\t\n\tswitch( award )\n\t{\n\tcase EF_AWARD_IMPRESSIVE:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_IMPRESSIVE, 1, 1 );\n\t\tbreak;\n\tcase EF_AWARD_EXCELLENT:\n\t\ttrap_RankReportInt( self, -1, QGR_KEY_EXCELLENT, 1, 1 );\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n}\n\n/*\n================\nG_RankCapture\n================\n*/\nvoid G_RankCapture( int self )\n{\n\tif( level.warmupTime != 0 )\n\t{\n\t\t// no reports during warmup period\n\t\treturn;\n\t}\n\t\n\ttrap_RankReportInt( self, -1, QGR_KEY_FLAG_CAPTURE, 1, 1 );\n}\n\n/*\n================\nG_RankUserTeamName\n================\n*/\nvoid G_RankUserTeamName( int self, char* team_name )\n{\n\tif( level.warmupTime != 0 )\n\t{\n\t\t// no reports during warmup period\n\t\treturn;\n\t}\n\t\n\ttrap_RankReportStr( self, -1, QGR_KEY_TEAM_NAME, team_name );\n}\n\n/*\n================\nG_RankClientDisconnect\n================\n*/\nvoid G_RankClientDisconnect( int self )\n{\n\tgclient_t*\tclient;\n\tint\t\t\ttime;\n\tint\t\t\tmatch_rating;\n\t\n\tif( level.warmupTime != 0 )\n\t{\n\t\t// no reports during warmup period\n\t\treturn;\n\t}\n\t\n\t// match rating\n\tclient = g_entities[self].client;\n\ttime = (level.time - client->pers.enterTime) / 1000;\n\tif( time < 60 )\n\t{\n\t\tmatch_rating = 0;\n\t}\n\telse\n\t{\n\t\tmatch_rating = client->ps.persistant[PERS_MATCH_RATING] / time;\n\t}\n\ttrap_RankReportInt( self, -1, QGR_KEY_MATCH_RATING, match_rating, 0 );\n}\n\n/*\n================\nG_RankGameOver\n================\n*/\nvoid G_RankGameOver( void )\n{\n\tint\t\ti;\n\tchar\tstr[MAX_INFO_VALUE];\n\tint\t\tnum;\n\t\n\tif( level.warmupTime != 0 )\n\t{\n\t\t// no reports during warmup period\n\t\treturn;\n\t}\n\t\n\tfor( i = 0; i < level.maxclients; i++ )\n\t{\n\t\tif( trap_RankUserStatus( i ) == QGR_STATUS_ACTIVE )\n\t\t{\n\t\t\tG_RankClientDisconnect( i );\n\t\t}\n\t}\n\t\n\t// hostname\n\ttrap_Cvar_VariableStringBuffer( \"sv_hostname\", str, sizeof(str) );\n\ttrap_RankReportStr( -1, -1, QGR_KEY_HOSTNAME, str );\n\n\t// map\n\ttrap_Cvar_VariableStringBuffer( \"mapname\", str, sizeof(str) );\n\ttrap_RankReportStr( -1, -1, QGR_KEY_MAP, str );\n\n\t// mod\n\ttrap_Cvar_VariableStringBuffer( \"fs_game\", str, sizeof(str) );\n\ttrap_RankReportStr( -1, -1, QGR_KEY_MOD, str );\n\n\t// gametype\n\tnum = trap_Cvar_VariableIntegerValue(\"g_gametype\");\n\ttrap_RankReportInt( -1, -1, QGR_KEY_GAMETYPE, num, 0 );\n\t\n\t// fraglimit\n\tnum = trap_Cvar_VariableIntegerValue(\"fraglimit\");\n\ttrap_RankReportInt( -1, -1, QGR_KEY_FRAGLIMIT, num, 0 );\n\t\n\t// timelimit\n\tnum = trap_Cvar_VariableIntegerValue(\"timelimit\");\n\ttrap_RankReportInt( -1, -1, QGR_KEY_TIMELIMIT, num, 0 );\n\n\t// maxclients\n\tnum = trap_Cvar_VariableIntegerValue(\"sv_maxclients\");\n\ttrap_RankReportInt( -1, -1, QGR_KEY_MAXCLIENTS, num, 0 );\n\n\t// maxrate\n\tnum = trap_Cvar_VariableIntegerValue(\"sv_maxRate\");\n\ttrap_RankReportInt( -1, -1, QGR_KEY_MAXRATE, num, 0 );\n\n\t// minping\n\tnum = trap_Cvar_VariableIntegerValue(\"sv_minPing\");\n\ttrap_RankReportInt( -1, -1, QGR_KEY_MINPING, num, 0 );\n\n\t// maxping\n\tnum = trap_Cvar_VariableIntegerValue(\"sv_maxPing\");\n\ttrap_RankReportInt( -1, -1, QGR_KEY_MAXPING, num, 0 );\n\n\t// dedicated\n\tnum = trap_Cvar_VariableIntegerValue(\"dedicated\");\n\ttrap_RankReportInt( -1, -1, QGR_KEY_DEDICATED, num, 0 );\n\n\t// version\n\ttrap_Cvar_VariableStringBuffer( \"version\", str, sizeof(str) );\n\ttrap_RankReportStr( -1, -1, QGR_KEY_VERSION, str );\n}\n\n"
  },
  {
    "path": "code/game/g_rankings.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// g_rankings.h -- score keys for global rankings\n\n#ifndef _G_RANKINGS_H_\n#define _G_RANKINGS_H_\n\n/*\n==============================================================================\n\nKey digits:\n\t10^9: report type\n\t\t\t1 = normal\n\t\t\t2 = developer-only\n\t10^8: stat type\n\t\t\t0 = match stat\n\t\t\t1 = single player stat\n\t\t\t2 = duel stat\n\t10^7: data type\n\t\t\t0 = string\n\t\t\t1 = uint32\n\t10^6: calculation\n\t\t\t0 = use raw value\n\t\t\t1 = add to total\n\t\t\t2 = average\n\t\t\t3 = max\n\t\t\t4 = min\n\t10^5\n\t10^4: category\n\t\t\t00 = general\n\t\t\t01 = session\n\t\t\t02 = weapon\n\t\t\t03 = ammo\n\t\t\t04 = health\n\t\t\t05 = armor\n\t\t\t06 = powerup\n\t\t\t07 = holdable\n\t\t\t08 = hazard\n\t\t\t09 = reward\n\t\t\t10 = teammate\n\t\t\t11 = ctf\n\t10^3:\n\t10^2: sub-category\n\t10^1:\n\t10^0: ordinal\n \n==============================================================================\n*/\n\n// general keys\n#define QGR_KEY_MATCH_RATING\t\t\t1112000001\n#define QGR_KEY_PLAYED_WITH\t\t\t\t1210000002\n\n// session keys\n#define QGR_KEY_HOSTNAME\t\t\t\t1000010000\n#define QGR_KEY_MAP\t\t\t\t\t\t1000010001\n#define QGR_KEY_MOD\t\t\t\t\t\t1000010002\n#define QGR_KEY_GAMETYPE\t\t\t\t1010010003\n#define QGR_KEY_FRAGLIMIT\t\t\t\t1010010004\n#define QGR_KEY_TIMELIMIT\t\t\t\t1010010005\n#define QGR_KEY_MAXCLIENTS\t\t\t\t1010010006\n#define QGR_KEY_MAXRATE\t\t\t\t\t1010010007\n#define QGR_KEY_MINPING\t\t\t\t\t1010010008\n#define QGR_KEY_MAXPING\t\t\t\t\t1010010009\n#define QGR_KEY_DEDICATED\t\t\t\t1010010010\n#define QGR_KEY_VERSION\t\t\t\t\t1000010011\n\n// weapon keys\n#define QGR_KEY_FRAG\t\t\t\t\t1211020000\n#define QGR_KEY_SUICIDE\t\t\t\t\t1111020001\n#define QGR_KEY_SHOT_FIRED\t\t\t\t1111020002\n#define QGR_KEY_HIT_GIVEN\t\t\t\t1111020003\n#define QGR_KEY_HIT_TAKEN\t\t\t\t1111020004\n#define QGR_KEY_DAMAGE_GIVEN\t\t\t1111020005\n#define QGR_KEY_DAMAGE_TAKEN\t\t\t1111020006\n#define QGR_KEY_SPLASH_GIVEN\t\t\t1111020007\n#define QGR_KEY_SPLASH_TAKEN\t\t\t1111020008\n#define QGR_KEY_PICKUP_WEAPON\t\t\t1111020009\n#define QGR_KEY_TIME\t\t\t\t\t1111020010\n\n#define QGR_KEY_FRAG_GAUNTLET\t\t\t1211020100\n#define QGR_KEY_SUICIDE_GAUNTLET\t\t1111020101\n#define QGR_KEY_SHOT_FIRED_GAUNTLET\t\t1111020102\n#define QGR_KEY_HIT_GIVEN_GAUNTLET\t\t1111020103\n#define QGR_KEY_HIT_TAKEN_GAUNTLET\t\t1111020104\n#define QGR_KEY_DAMAGE_GIVEN_GAUNTLET\t1111020105\n#define QGR_KEY_DAMAGE_TAKEN_GAUNTLET\t1111020106\n#define QGR_KEY_SPLASH_GIVEN_GAUNTLET\t1111020107\n#define QGR_KEY_SPLASH_TAKEN_GAUNTLET\t1111020108\n#define QGR_KEY_PICKUP_GAUNTLET\t\t\t1111020109\n#define QGR_KEY_TIME_GAUNTLET\t\t\t1111020110\n\n#define QGR_KEY_FRAG_MACHINEGUN\t\t\t1211020200\n#define QGR_KEY_SUICIDE_MACHINEGUN\t\t1111020201\n#define QGR_KEY_SHOT_FIRED_MACHINEGUN\t1111020202\n#define QGR_KEY_HIT_GIVEN_MACHINEGUN\t1111020203\n#define QGR_KEY_HIT_TAKEN_MACHINEGUN\t1111020204\n#define QGR_KEY_DAMAGE_GIVEN_MACHINEGUN\t1111020205\n#define QGR_KEY_DAMAGE_TAKEN_MACHINEGUN\t1111020206\n#define QGR_KEY_SPLASH_GIVEN_MACHINEGUN\t1111020207\n#define QGR_KEY_SPLASH_TAKEN_MACHINEGUN\t1111020208\n#define QGR_KEY_PICKUP_MACHINEGUN\t\t1111020209\n#define QGR_KEY_TIME_MACHINEGUN\t\t\t1111020210\n\n#define QGR_KEY_FRAG_SHOTGUN\t\t\t1211020300\n#define QGR_KEY_SUICIDE_SHOTGUN\t\t\t1111020301\n#define QGR_KEY_SHOT_FIRED_SHOTGUN\t\t1111020302\n#define QGR_KEY_HIT_GIVEN_SHOTGUN\t\t1111020303\n#define QGR_KEY_HIT_TAKEN_SHOTGUN\t\t1111020304\n#define QGR_KEY_DAMAGE_GIVEN_SHOTGUN\t1111020305\n#define QGR_KEY_DAMAGE_TAKEN_SHOTGUN\t1111020306\n#define QGR_KEY_SPLASH_GIVEN_SHOTGUN\t1111020307\n#define QGR_KEY_SPLASH_TAKEN_SHOTGUN\t1111020308\n#define QGR_KEY_PICKUP_SHOTGUN\t\t\t1111020309\n#define QGR_KEY_TIME_SHOTGUN\t\t\t1111020310\n\n#define QGR_KEY_FRAG_GRENADE\t\t\t1211020400\n#define QGR_KEY_SUICIDE_GRENADE\t\t\t1111020401\n#define QGR_KEY_SHOT_FIRED_GRENADE\t\t1111020402\n#define QGR_KEY_HIT_GIVEN_GRENADE\t\t1111020403\n#define QGR_KEY_HIT_TAKEN_GRENADE\t\t1111020404\n#define QGR_KEY_DAMAGE_GIVEN_GRENADE\t1111020405\n#define QGR_KEY_DAMAGE_TAKEN_GRENADE\t1111020406\n#define QGR_KEY_SPLASH_GIVEN_GRENADE\t1111020407\n#define QGR_KEY_SPLASH_TAKEN_GRENADE\t1111020408\n#define QGR_KEY_PICKUP_GRENADE\t\t\t1111020409\n#define QGR_KEY_TIME_GRENADE\t\t\t1111020410\n\n#define QGR_KEY_FRAG_ROCKET\t\t\t\t1211020500\n#define QGR_KEY_SUICIDE_ROCKET\t\t\t1111020501\n#define QGR_KEY_SHOT_FIRED_ROCKET\t\t1111020502\n#define QGR_KEY_HIT_GIVEN_ROCKET\t\t1111020503\n#define QGR_KEY_HIT_TAKEN_ROCKET\t\t1111020504\n#define QGR_KEY_DAMAGE_GIVEN_ROCKET\t\t1111020505\n#define QGR_KEY_DAMAGE_TAKEN_ROCKET\t\t1111020506\n#define QGR_KEY_SPLASH_GIVEN_ROCKET\t\t1111020507\n#define QGR_KEY_SPLASH_TAKEN_ROCKET\t\t1111020508\n#define QGR_KEY_PICKUP_ROCKET\t\t\t1111020509\n#define QGR_KEY_TIME_ROCKET\t\t\t\t1111020510\n\n#define QGR_KEY_FRAG_PLASMA\t\t\t\t1211020600\n#define QGR_KEY_SUICIDE_PLASMA\t\t\t1111020601\n#define QGR_KEY_SHOT_FIRED_PLASMA\t\t1111020602\n#define QGR_KEY_HIT_GIVEN_PLASMA\t\t1111020603\n#define QGR_KEY_HIT_TAKEN_PLASMA\t\t1111020604\n#define QGR_KEY_DAMAGE_GIVEN_PLASMA\t\t1111020605\n#define QGR_KEY_DAMAGE_TAKEN_PLASMA\t\t1111020606\n#define QGR_KEY_SPLASH_GIVEN_PLASMA\t\t1111020607\n#define QGR_KEY_SPLASH_TAKEN_PLASMA\t\t1111020608\n#define QGR_KEY_PICKUP_PLASMA\t\t\t1111020609\n#define QGR_KEY_TIME_PLASMA\t\t\t\t1111020610\n\n#define QGR_KEY_FRAG_RAILGUN\t\t\t1211020700\n#define QGR_KEY_SUICIDE_RAILGUN\t\t\t1111020701\n#define QGR_KEY_SHOT_FIRED_RAILGUN\t\t1111020702\n#define QGR_KEY_HIT_GIVEN_RAILGUN\t\t1111020703\n#define QGR_KEY_HIT_TAKEN_RAILGUN\t\t1111020704\n#define QGR_KEY_DAMAGE_GIVEN_RAILGUN\t1111020705\n#define QGR_KEY_DAMAGE_TAKEN_RAILGUN\t1111020706\n#define QGR_KEY_SPLASH_GIVEN_RAILGUN\t1111020707\n#define QGR_KEY_SPLASH_TAKEN_RAILGUN\t1111020708\n#define QGR_KEY_PICKUP_RAILGUN\t\t\t1111020709\n#define QGR_KEY_TIME_RAILGUN\t\t\t1111020710\n\n#define QGR_KEY_FRAG_LIGHTNING\t\t\t1211020800\n#define QGR_KEY_SUICIDE_LIGHTNING\t\t1111020801\n#define QGR_KEY_SHOT_FIRED_LIGHTNING\t1111020802\n#define QGR_KEY_HIT_GIVEN_LIGHTNING\t\t1111020803\n#define QGR_KEY_HIT_TAKEN_LIGHTNING\t\t1111020804\n#define QGR_KEY_DAMAGE_GIVEN_LIGHTNING\t1111020805\n#define QGR_KEY_DAMAGE_TAKEN_LIGHTNING\t1111020806\n#define QGR_KEY_SPLASH_GIVEN_LIGHTNING\t1111020807\n#define QGR_KEY_SPLASH_TAKEN_LIGHTNING\t1111020808\n#define QGR_KEY_PICKUP_LIGHTNING\t\t1111020809\n#define QGR_KEY_TIME_LIGHTNING\t\t\t1111020810\n\n#define QGR_KEY_FRAG_BFG\t\t\t\t1211020900\n#define QGR_KEY_SUICIDE_BFG\t\t\t\t1111020901\n#define QGR_KEY_SHOT_FIRED_BFG\t\t\t1111020902\n#define QGR_KEY_HIT_GIVEN_BFG\t\t\t1111020903\n#define QGR_KEY_HIT_TAKEN_BFG\t\t\t1111020904\n#define QGR_KEY_DAMAGE_GIVEN_BFG\t\t1111020905\n#define QGR_KEY_DAMAGE_TAKEN_BFG\t\t1111020906\n#define QGR_KEY_SPLASH_GIVEN_BFG\t\t1111020907\n#define QGR_KEY_SPLASH_TAKEN_BFG\t\t1111020908\n#define QGR_KEY_PICKUP_BFG\t\t\t\t1111020909\n#define QGR_KEY_TIME_BFG\t\t\t\t1111020910\n\n#define QGR_KEY_FRAG_GRAPPLE\t\t\t1211021000\n#define QGR_KEY_SUICIDE_GRAPPLE\t\t\t1111021001\n#define QGR_KEY_SHOT_FIRED_GRAPPLE\t\t1111021002\n#define QGR_KEY_HIT_GIVEN_GRAPPLE\t\t1111021003\n#define QGR_KEY_HIT_TAKEN_GRAPPLE\t\t1111021004\n#define QGR_KEY_DAMAGE_GIVEN_GRAPPLE\t1111021005\n#define QGR_KEY_DAMAGE_TAKEN_GRAPPLE\t1111021006\n#define QGR_KEY_SPLASH_GIVEN_GRAPPLE\t1111021007\n#define QGR_KEY_SPLASH_TAKEN_GRAPPLE\t1111021008\n#define QGR_KEY_PICKUP_GRAPPLE\t\t\t1111021009\n#define QGR_KEY_TIME_GRAPPLE\t\t\t1111021010\n\n#define QGR_KEY_FRAG_UNKNOWN\t\t\t1211021100\n#define QGR_KEY_SUICIDE_UNKNOWN\t\t\t1111021101\n#define QGR_KEY_SHOT_FIRED_UNKNOWN\t\t1111021102\n#define QGR_KEY_HIT_GIVEN_UNKNOWN\t\t1111021103\n#define QGR_KEY_HIT_TAKEN_UNKNOWN\t\t1111021104\n#define QGR_KEY_DAMAGE_GIVEN_UNKNOWN\t1111021105\n#define QGR_KEY_DAMAGE_TAKEN_UNKNOWN\t1111021106\n#define QGR_KEY_SPLASH_GIVEN_UNKNOWN\t1111021107\n#define QGR_KEY_SPLASH_TAKEN_UNKNOWN\t1111021108\n#define QGR_KEY_PICKUP_UNKNOWN\t\t\t1111021109\n#define QGR_KEY_TIME_UNKNOWN\t\t\t1111021110\n\n#ifdef MISSIONPACK\n// new to team arena\n#define QGR_KEY_FRAG_NAILGIN\t\t\t1211021200\n#define QGR_KEY_SUICIDE_NAILGIN\t\t\t1111021201\n#define QGR_KEY_SHOT_FIRED_NAILGIN\t\t1111021202\n#define QGR_KEY_HIT_GIVEN_NAILGIN\t\t1111021203\n#define QGR_KEY_HIT_TAKEN_NAILGIN\t\t1111021204\n#define QGR_KEY_DAMAGE_GIVEN_NAILGIN\t1111021205\n#define QGR_KEY_DAMAGE_TAKEN_NAILGIN\t1111021206\n#define QGR_KEY_SPLASH_GIVEN_NAILGIN\t1111021207\n#define QGR_KEY_SPLASH_TAKEN_NAILGIN\t1111021208\n#define QGR_KEY_PICKUP_NAILGIN\t\t\t1111021209\n#define QGR_KEY_TIME_NAILGIN\t\t\t1111021210\n// new to team arena\n#define QGR_KEY_FRAG_PROX_LAUNCHER\t\t\t1211021300\n#define QGR_KEY_SUICIDE_PROX_LAUNCHER\t\t1111021301\n#define QGR_KEY_SHOT_FIRED_PROX_LAUNCHER \t1111021302\n#define QGR_KEY_HIT_GIVEN_PROX_LAUNCHER\t\t1111021303\n#define QGR_KEY_HIT_TAKEN_PROX_LAUNCHER\t\t1111021304\n#define QGR_KEY_DAMAGE_GIVEN_PROX_LAUNCHER\t1111021305\n#define QGR_KEY_DAMAGE_TAKEN_PROX_LAUNCHER\t1111021306\n#define QGR_KEY_SPLASH_GIVEN_PROX_LAUNCHER\t1111021307\n#define QGR_KEY_SPLASH_TAKEN_PROX_LAUNCHER\t1111021308\n#define QGR_KEY_PICKUP_PROX_LAUNCHER\t\t1111021309\n#define QGR_KEY_TIME_PROX_LAUNCHER\t\t\t1111021310\n// new to team arena\n#define QGR_KEY_FRAG_CHAINGUN\t\t\t1211021400\n#define QGR_KEY_SUICIDE_CHAINGUN\t\t1111021401\n#define QGR_KEY_SHOT_FIRED_CHAINGUN \t1111021402\n#define QGR_KEY_HIT_GIVEN_CHAINGUN\t\t1111021403\n#define QGR_KEY_HIT_TAKEN_CHAINGUN\t\t1111021404\n#define QGR_KEY_DAMAGE_GIVEN_CHAINGUN\t1111021405\n#define QGR_KEY_DAMAGE_TAKEN_CHAINGUN\t1111021406\n#define QGR_KEY_SPLASH_GIVEN_CHAINGUN\t1111021407\n#define QGR_KEY_SPLASH_TAKEN_CHAINGUN\t1111021408\n#define QGR_KEY_PICKUP_CHAINGUN\t\t\t1111021409\n#define QGR_KEY_TIME_CHAINGUN\t\t\t1111021410\n#endif /* MISSIONPACK */\n\n// ammo keys\n#define QGR_KEY_BOXES\t\t\t\t\t1111030000\n#define QGR_KEY_ROUNDS\t\t\t\t\t1111030001\n\n#define QGR_KEY_BOXES_BULLETS\t\t\t1111030100\n#define QGR_KEY_ROUNDS_BULLETS\t\t\t1111030101\n\n#define QGR_KEY_BOXES_SHELLS\t\t\t1111030200\n#define QGR_KEY_ROUNDS_SHELLS\t\t\t1111030201\n\n#define QGR_KEY_BOXES_GRENADES\t\t\t1111030300\n#define QGR_KEY_ROUNDS_GRENADES\t\t\t1111030301\n\n#define QGR_KEY_BOXES_ROCKETS\t\t\t1111030400\n#define QGR_KEY_ROUNDS_ROCKETS\t\t\t1111030401\n\n#define QGR_KEY_BOXES_CELLS\t\t\t\t1111030500\n#define QGR_KEY_ROUNDS_CELLS\t\t\t1111030501\n\n#define QGR_KEY_BOXES_SLUGS\t\t\t\t1111030600\n#define QGR_KEY_ROUNDS_SLUGS\t\t\t1111030601\n\n#define QGR_KEY_BOXES_LG_AMMO\t\t\t1111030700\n#define QGR_KEY_ROUNDS_LG_AMMO\t\t\t1111030701\n\n#define QGR_KEY_BOXES_BFG_AMMO\t\t\t1111030800\n#define QGR_KEY_ROUNDS_BFG_AMMO\t\t\t1111030801\n\n#ifdef MISSIONPACK\n// new to team arena\n#define QGR_KEY_BOXES_NAILGUN_AMMO\t\t1111030900\n#define QGR_KEY_ROUNDS_NAILGUN_AMMO\t \t1111030901\n// new to team arena\n#define QGR_KEY_BOXES_PROX_LAUNCHER_AMMO \t1111031000\n#define QGR_KEY_ROUNDS_PROX_LAUNCHER_AMMO \t1111031001\n// new to team arena\n#define QGR_KEY_BOXES_CHAINGUN_AMMO \t1111031100\n#define QGR_KEY_ROUNDS_CHAINGUN_AMMO \t1111031101\n#endif /* MISSIONPACK */\n\n// health keys\n#define QGR_KEY_HEALTH\t\t\t\t\t1111040000\n#define QGR_KEY_HEALTH_TOTAL\t\t\t1111040001\n\n#define QGR_KEY_HEALTH_5\t\t\t\t1111040100\n#define QGR_KEY_HEALTH_25\t\t\t\t1111040200\n#define QGR_KEY_HEALTH_50\t\t\t\t1111040300\n#define QGR_KEY_HEALTH_MEGA\t\t\t\t1111040400\n\n// armor keys\n#define QGR_KEY_ARMOR\t\t\t\t\t1111050000\n#define QGR_KEY_ARMOR_TOTAL\t\t\t\t1111050001\n\n#define QGR_KEY_ARMOR_SHARD\t\t\t\t1111050100\n#define QGR_KEY_ARMOR_YELLOW\t\t\t1111050200\n#define QGR_KEY_ARMOR_RED\t\t\t\t1111050300\n\n// powerup keys\n#define QGR_KEY_POWERUP\t\t\t\t\t1111060000\n#define QGR_KEY_QUAD\t\t\t\t\t1111060100\n#define QGR_KEY_SUIT\t\t\t\t\t1111060200\n#define QGR_KEY_HASTE\t\t\t\t\t1111060300\n#define QGR_KEY_INVIS\t\t\t\t\t1111060400\n#define QGR_KEY_REGEN\t\t\t\t\t1111060500\n#define QGR_KEY_FLIGHT\t\t\t\t\t1111060600\n\n#ifdef MISSIONPACK\n// persistant powerup keys\n// new to team arena\n#define QGR_KEY_SCOUT\t\t\t\t\t1111160800\n#define QGR_KEY_GUARD\t\t\t\t\t1111160801\n#define QGR_KEY_DOUBLER\t\t\t\t\t1111160802\n#define QGR_KEY_AMMOREGEN\t\t\t\t1111160803\n\n#endif //MISSIONPACK\n\n// holdable item keys\n#define QGR_KEY_MEDKIT\t\t\t\t\t1111070000\n#define QGR_KEY_MEDKIT_USE\t\t\t\t1111070001\n\n#define QGR_KEY_TELEPORTER\t\t\t\t1111070100\n#define QGR_KEY_TELEPORTER_USE\t\t\t1111070101\n\n#ifdef MISSIONPACK\n// new to team arena\n#define QGR_KEY_KAMIKAZE\t\t\t\t1111070200\n#define QGR_KEY_KAMIKAZE_USE\t\t\t1111070201\n// new to team arena\n#define QGR_KEY_PORTAL\t\t\t\t\t1111070300\n#define QGR_KEY_PORTAL_USE\t\t\t\t1111070301\n// new to team arena\n#define QGR_KEY_INVULNERABILITY\t\t\t1111070400\n#define QGR_KEY_INVULNERABILITY_USE\t\t1111070401\n#endif /* MISSIONPACK */\n\n// hazard keys\n#define QGR_KEY_HAZARD_DEATH\t\t\t1111080000\n#define QGR_KEY_WATER\t\t\t\t\t1111080100\n#define QGR_KEY_SLIME\t\t\t\t\t1111080200\n#define QGR_KEY_LAVA\t\t\t\t\t1111080300\n#define QGR_KEY_CRUSH\t\t\t\t\t1111080400\n#define QGR_KEY_TELEFRAG\t\t\t\t1111080500\n#define QGR_KEY_FALLING\t\t\t\t\t1111080600\n#define QGR_KEY_SUICIDE_CMD\t\t\t\t1111080700\n#define QGR_KEY_TRIGGER_HURT\t\t\t1111080800\n#define QGR_KEY_HAZARD_MISC\t\t\t\t1111080900\n\n// reward keys\n#define QGR_KEY_IMPRESSIVE\t\t\t\t1111090000\n#define QGR_KEY_EXCELLENT\t\t\t\t1111090100\n\n// teammate keys\n#define QGR_KEY_TEAMMATE_FRAG\t\t\t1211100000\n#define QGR_KEY_TEAMMATE_HIT_GIVEN\t\t1111100001\n#define QGR_KEY_TEAMMATE_HIT_TAKEN\t\t1111100002\n#define QGR_KEY_TEAMMATE_DAMAGE_GIVEN\t1111100003\n#define QGR_KEY_TEAMMATE_DAMAGE_TAKEN\t1111100004\n#define QGR_KEY_TEAMMATE_SPLASH_GIVEN\t1111100005\n#define QGR_KEY_TEAMMATE_SPLASH_TAKEN\t1111100006\n#define QGR_KEY_TEAM_NAME\t\t\t\t1100100007\n\n// ctf keys\n#define QGR_KEY_FLAG_PICKUP\t\t\t\t1111110000\n#define QGR_KEY_FLAG_CAPTURE\t\t\t1111110001\n\n#endif // _G_RANKINGS_H_\n"
  },
  {
    "path": "code/game/g_session.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#include \"g_local.h\"\n\n\n/*\n=======================================================================\n\n  SESSION DATA\n\nSession data is the only data that stays persistant across level loads\nand tournament restarts.\n=======================================================================\n*/\n\n/*\n================\nG_WriteClientSessionData\n\nCalled on game shutdown\n================\n*/\nvoid G_WriteClientSessionData( gclient_t *client ) {\n\tconst char\t*s;\n\tconst char\t*var;\n\n\ts = va(\"%i %i %i %i %i %i %i\", \n\t\tclient->sess.sessionTeam,\n\t\tclient->sess.spectatorTime,\n\t\tclient->sess.spectatorState,\n\t\tclient->sess.spectatorClient,\n\t\tclient->sess.wins,\n\t\tclient->sess.losses,\n\t\tclient->sess.teamLeader\n\t\t);\n\n\tvar = va( \"session%i\", client - level.clients );\n\n\ttrap_Cvar_Set( var, s );\n}\n\n/*\n================\nG_ReadSessionData\n\nCalled on a reconnect\n================\n*/\nvoid G_ReadSessionData( gclient_t *client ) {\n\tchar\ts[MAX_STRING_CHARS];\n\tconst char\t*var;\n\n\t// bk001205 - format\n\tint teamLeader;\n\tint spectatorState;\n\tint sessionTeam;\n\n\tvar = va( \"session%i\", client - level.clients );\n\ttrap_Cvar_VariableStringBuffer( var, s, sizeof(s) );\n\n\tsscanf( s, \"%i %i %i %i %i %i %i\",\n\t\t&sessionTeam,                 // bk010221 - format\n\t\t&client->sess.spectatorTime,\n\t\t&spectatorState,              // bk010221 - format\n\t\t&client->sess.spectatorClient,\n\t\t&client->sess.wins,\n\t\t&client->sess.losses,\n\t\t&teamLeader                   // bk010221 - format\n\t\t);\n\n\t// bk001205 - format issues\n\tclient->sess.sessionTeam = (team_t)sessionTeam;\n\tclient->sess.spectatorState = (spectatorState_t)spectatorState;\n\tclient->sess.teamLeader = (qboolean)teamLeader;\n}\n\n\n/*\n================\nG_InitSessionData\n\nCalled on a first-time connect\n================\n*/\nvoid G_InitSessionData( gclient_t *client, char *userinfo ) {\n\tclientSession_t\t*sess;\n\tconst char\t\t*value;\n\n\tsess = &client->sess;\n\n\t// initial team determination\n\tif ( g_gametype.integer >= GT_TEAM ) {\n\t\tif ( g_teamAutoJoin.integer ) {\n\t\t\tsess->sessionTeam = PickTeam( -1 );\n\t\t\tBroadcastTeamChange( client, -1 );\n\t\t} else {\n\t\t\t// always spawn as spectator in team games\n\t\t\tsess->sessionTeam = TEAM_SPECTATOR;\t\n\t\t}\n\t} else {\n\t\tvalue = Info_ValueForKey( userinfo, \"team\" );\n\t\tif ( value[0] == 's' ) {\n\t\t\t// a willing spectator, not a waiting-in-line\n\t\t\tsess->sessionTeam = TEAM_SPECTATOR;\n\t\t} else {\n\t\t\tswitch ( g_gametype.integer ) {\n\t\t\tdefault:\n\t\t\tcase GT_FFA:\n\t\t\tcase GT_SINGLE_PLAYER:\n\t\t\t\tif ( g_maxGameClients.integer > 0 && \n\t\t\t\t\tlevel.numNonSpectatorClients >= g_maxGameClients.integer ) {\n\t\t\t\t\tsess->sessionTeam = TEAM_SPECTATOR;\n\t\t\t\t} else {\n\t\t\t\t\tsess->sessionTeam = TEAM_FREE;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase GT_TOURNAMENT:\n\t\t\t\t// if the game is full, go into a waiting mode\n\t\t\t\tif ( level.numNonSpectatorClients >= 2 ) {\n\t\t\t\t\tsess->sessionTeam = TEAM_SPECTATOR;\n\t\t\t\t} else {\n\t\t\t\t\tsess->sessionTeam = TEAM_FREE;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tsess->spectatorState = SPECTATOR_FREE;\n\tsess->spectatorTime = level.time;\n\n\tG_WriteClientSessionData( client );\n}\n\n\n/*\n==================\nG_InitWorldSession\n\n==================\n*/\nvoid G_InitWorldSession( void ) {\n\tchar\ts[MAX_STRING_CHARS];\n\tint\t\t\tgt;\n\n\ttrap_Cvar_VariableStringBuffer( \"session\", s, sizeof(s) );\n\tgt = atoi( s );\n\t\n\t// if the gametype changed since the last session, don't use any\n\t// client sessions\n\tif ( g_gametype.integer != gt ) {\n\t\tlevel.newSession = qtrue;\n\t\tG_Printf( \"Gametype changed, clearing session data.\\n\" );\n\t}\n}\n\n/*\n==================\nG_WriteSessionData\n\n==================\n*/\nvoid G_WriteSessionData( void ) {\n\tint\t\ti;\n\n\ttrap_Cvar_Set( \"session\", va(\"%i\", g_gametype.integer) );\n\n\tfor ( i = 0 ; i < level.maxclients ; i++ ) {\n\t\tif ( level.clients[i].pers.connected == CON_CONNECTED ) {\n\t\t\tG_WriteClientSessionData( &level.clients[i] );\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "code/game/g_spawn.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n#include \"g_local.h\"\n\nqboolean\tG_SpawnString( const char *key, const char *defaultString, char **out ) {\n\tint\t\ti;\n\n\tif ( !level.spawning ) {\n\t\t*out = (char *)defaultString;\n//\t\tG_Error( \"G_SpawnString() called while not spawning\" );\n\t}\n\n\tfor ( i = 0 ; i < level.numSpawnVars ; i++ ) {\n\t\tif ( !Q_stricmp( key, level.spawnVars[i][0] ) ) {\n\t\t\t*out = level.spawnVars[i][1];\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\n\t*out = (char *)defaultString;\n\treturn qfalse;\n}\n\nqboolean\tG_SpawnFloat( const char *key, const char *defaultString, float *out ) {\n\tchar\t\t*s;\n\tqboolean\tpresent;\n\n\tpresent = G_SpawnString( key, defaultString, &s );\n\t*out = atof( s );\n\treturn present;\n}\n\nqboolean\tG_SpawnInt( const char *key, const char *defaultString, int *out ) {\n\tchar\t\t*s;\n\tqboolean\tpresent;\n\n\tpresent = G_SpawnString( key, defaultString, &s );\n\t*out = atoi( s );\n\treturn present;\n}\n\nqboolean\tG_SpawnVector( const char *key, const char *defaultString, float *out ) {\n\tchar\t\t*s;\n\tqboolean\tpresent;\n\n\tpresent = G_SpawnString( key, defaultString, &s );\n\tsscanf( s, \"%f %f %f\", &out[0], &out[1], &out[2] );\n\treturn present;\n}\n\n\n\n//\n// fields are needed for spawning from the entity string\n//\ntypedef enum {\n\tF_INT, \n\tF_FLOAT,\n\tF_LSTRING,\t\t\t// string on disk, pointer in memory, TAG_LEVEL\n\tF_GSTRING,\t\t\t// string on disk, pointer in memory, TAG_GAME\n\tF_VECTOR,\n\tF_ANGLEHACK,\n\tF_ENTITY,\t\t\t// index on disk, pointer in memory\n\tF_ITEM,\t\t\t\t// index on disk, pointer in memory\n\tF_CLIENT,\t\t\t// index on disk, pointer in memory\n\tF_IGNORE\n} fieldtype_t;\n\ntypedef struct\n{\n\tchar\t*name;\n\tint\t\tofs;\n\tfieldtype_t\ttype;\n\tint\t\tflags;\n} field_t;\n\nfield_t fields[] = {\n\t{\"classname\", FOFS(classname), F_LSTRING},\n\t{\"origin\", FOFS(s.origin), F_VECTOR},\n\t{\"model\", FOFS(model), F_LSTRING},\n\t{\"model2\", FOFS(model2), F_LSTRING},\n\t{\"spawnflags\", FOFS(spawnflags), F_INT},\n\t{\"speed\", FOFS(speed), F_FLOAT},\n\t{\"target\", FOFS(target), F_LSTRING},\n\t{\"targetname\", FOFS(targetname), F_LSTRING},\n\t{\"message\", FOFS(message), F_LSTRING},\n\t{\"team\", FOFS(team), F_LSTRING},\n\t{\"wait\", FOFS(wait), F_FLOAT},\n\t{\"random\", FOFS(random), F_FLOAT},\n\t{\"count\", FOFS(count), F_INT},\n\t{\"health\", FOFS(health), F_INT},\n\t{\"light\", 0, F_IGNORE},\n\t{\"dmg\", FOFS(damage), F_INT},\n\t{\"angles\", FOFS(s.angles), F_VECTOR},\n\t{\"angle\", FOFS(s.angles), F_ANGLEHACK},\n\t{\"targetShaderName\", FOFS(targetShaderName), F_LSTRING},\n\t{\"targetShaderNewName\", FOFS(targetShaderNewName), F_LSTRING},\n\n\t{NULL}\n};\n\n\ntypedef struct {\n\tchar\t*name;\n\tvoid\t(*spawn)(gentity_t *ent);\n} spawn_t;\n\nvoid SP_info_player_start (gentity_t *ent);\nvoid SP_info_player_deathmatch (gentity_t *ent);\nvoid SP_info_player_intermission (gentity_t *ent);\nvoid SP_info_firstplace(gentity_t *ent);\nvoid SP_info_secondplace(gentity_t *ent);\nvoid SP_info_thirdplace(gentity_t *ent);\nvoid SP_info_podium(gentity_t *ent);\n\nvoid SP_func_plat (gentity_t *ent);\nvoid SP_func_static (gentity_t *ent);\nvoid SP_func_rotating (gentity_t *ent);\nvoid SP_func_bobbing (gentity_t *ent);\nvoid SP_func_pendulum( gentity_t *ent );\nvoid SP_func_button (gentity_t *ent);\nvoid SP_func_door (gentity_t *ent);\nvoid SP_func_train (gentity_t *ent);\nvoid SP_func_timer (gentity_t *self);\n\nvoid SP_trigger_always (gentity_t *ent);\nvoid SP_trigger_multiple (gentity_t *ent);\nvoid SP_trigger_push (gentity_t *ent);\nvoid SP_trigger_teleport (gentity_t *ent);\nvoid SP_trigger_hurt (gentity_t *ent);\n\nvoid SP_target_remove_powerups( gentity_t *ent );\nvoid SP_target_give (gentity_t *ent);\nvoid SP_target_delay (gentity_t *ent);\nvoid SP_target_speaker (gentity_t *ent);\nvoid SP_target_print (gentity_t *ent);\nvoid SP_target_laser (gentity_t *self);\nvoid SP_target_character (gentity_t *ent);\nvoid SP_target_score( gentity_t *ent );\nvoid SP_target_teleporter( gentity_t *ent );\nvoid SP_target_relay (gentity_t *ent);\nvoid SP_target_kill (gentity_t *ent);\nvoid SP_target_position (gentity_t *ent);\nvoid SP_target_location (gentity_t *ent);\nvoid SP_target_push (gentity_t *ent);\n\nvoid SP_light (gentity_t *self);\nvoid SP_info_null (gentity_t *self);\nvoid SP_info_notnull (gentity_t *self);\nvoid SP_info_camp (gentity_t *self);\nvoid SP_path_corner (gentity_t *self);\n\nvoid SP_misc_teleporter_dest (gentity_t *self);\nvoid SP_misc_model(gentity_t *ent);\nvoid SP_misc_portal_camera(gentity_t *ent);\nvoid SP_misc_portal_surface(gentity_t *ent);\n\nvoid SP_shooter_rocket( gentity_t *ent );\nvoid SP_shooter_plasma( gentity_t *ent );\nvoid SP_shooter_grenade( gentity_t *ent );\n\nvoid SP_team_CTF_redplayer( gentity_t *ent );\nvoid SP_team_CTF_blueplayer( gentity_t *ent );\n\nvoid SP_team_CTF_redspawn( gentity_t *ent );\nvoid SP_team_CTF_bluespawn( gentity_t *ent );\n\n#ifdef MISSIONPACK\nvoid SP_team_blueobelisk( gentity_t *ent );\nvoid SP_team_redobelisk( gentity_t *ent );\nvoid SP_team_neutralobelisk( gentity_t *ent );\n#endif\nvoid SP_item_botroam( gentity_t *ent ) {};\n\nspawn_t\tspawns[] = {\n\t// info entities don't do anything at all, but provide positional\n\t// information for things controlled by other processes\n\t{\"info_player_start\", SP_info_player_start},\n\t{\"info_player_deathmatch\", SP_info_player_deathmatch},\n\t{\"info_player_intermission\", SP_info_player_intermission},\n\t{\"info_null\", SP_info_null},\n\t{\"info_notnull\", SP_info_notnull},\t\t// use target_position instead\n\t{\"info_camp\", SP_info_camp},\n\n\t{\"func_plat\", SP_func_plat},\n\t{\"func_button\", SP_func_button},\n\t{\"func_door\", SP_func_door},\n\t{\"func_static\", SP_func_static},\n\t{\"func_rotating\", SP_func_rotating},\n\t{\"func_bobbing\", SP_func_bobbing},\n\t{\"func_pendulum\", SP_func_pendulum},\n\t{\"func_train\", SP_func_train},\n\t{\"func_group\", SP_info_null},\n\t{\"func_timer\", SP_func_timer},\t\t\t// rename trigger_timer?\n\n\t// Triggers are brush objects that cause an effect when contacted\n\t// by a living player, usually involving firing targets.\n\t// While almost everything could be done with\n\t// a single trigger class and different targets, triggered effects\n\t// could not be client side predicted (push and teleport).\n\t{\"trigger_always\", SP_trigger_always},\n\t{\"trigger_multiple\", SP_trigger_multiple},\n\t{\"trigger_push\", SP_trigger_push},\n\t{\"trigger_teleport\", SP_trigger_teleport},\n\t{\"trigger_hurt\", SP_trigger_hurt},\n\n\t// targets perform no action by themselves, but must be triggered\n\t// by another entity\n\t{\"target_give\", SP_target_give},\n\t{\"target_remove_powerups\", SP_target_remove_powerups},\n\t{\"target_delay\", SP_target_delay},\n\t{\"target_speaker\", SP_target_speaker},\n\t{\"target_print\", SP_target_print},\n\t{\"target_laser\", SP_target_laser},\n\t{\"target_score\", SP_target_score},\n\t{\"target_teleporter\", SP_target_teleporter},\n\t{\"target_relay\", SP_target_relay},\n\t{\"target_kill\", SP_target_kill},\n\t{\"target_position\", SP_target_position},\n\t{\"target_location\", SP_target_location},\n\t{\"target_push\", SP_target_push},\n\n\t{\"light\", SP_light},\n\t{\"path_corner\", SP_path_corner},\n\n\t{\"misc_teleporter_dest\", SP_misc_teleporter_dest},\n\t{\"misc_model\", SP_misc_model},\n\t{\"misc_portal_surface\", SP_misc_portal_surface},\n\t{\"misc_portal_camera\", SP_misc_portal_camera},\n\n\t{\"shooter_rocket\", SP_shooter_rocket},\n\t{\"shooter_grenade\", SP_shooter_grenade},\n\t{\"shooter_plasma\", SP_shooter_plasma},\n\n\t{\"team_CTF_redplayer\", SP_team_CTF_redplayer},\n\t{\"team_CTF_blueplayer\", SP_team_CTF_blueplayer},\n\n\t{\"team_CTF_redspawn\", SP_team_CTF_redspawn},\n\t{\"team_CTF_bluespawn\", SP_team_CTF_bluespawn},\n\n#ifdef MISSIONPACK\n\t{\"team_redobelisk\", SP_team_redobelisk},\n\t{\"team_blueobelisk\", SP_team_blueobelisk},\n\t{\"team_neutralobelisk\", SP_team_neutralobelisk},\n#endif\n\t{\"item_botroam\", SP_item_botroam},\n\n\t{0, 0}\n};\n\n/*\n===============\nG_CallSpawn\n\nFinds the spawn function for the entity and calls it,\nreturning qfalse if not found\n===============\n*/\nqboolean G_CallSpawn( gentity_t *ent ) {\n\tspawn_t\t*s;\n\tgitem_t\t*item;\n\n\tif ( !ent->classname ) {\n\t\tG_Printf (\"G_CallSpawn: NULL classname\\n\");\n\t\treturn qfalse;\n\t}\n\n\t// check item spawn functions\n\tfor ( item=bg_itemlist+1 ; item->classname ; item++ ) {\n\t\tif ( !strcmp(item->classname, ent->classname) ) {\n\t\t\tG_SpawnItem( ent, item );\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\n\t// check normal spawn functions\n\tfor ( s=spawns ; s->name ; s++ ) {\n\t\tif ( !strcmp(s->name, ent->classname) ) {\n\t\t\t// found it\n\t\t\ts->spawn(ent);\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\tG_Printf (\"%s doesn't have a spawn function\\n\", ent->classname);\n\treturn qfalse;\n}\n\n/*\n=============\nG_NewString\n\nBuilds a copy of the string, translating \\n to real linefeeds\nso message texts can be multi-line\n=============\n*/\nchar *G_NewString( const char *string ) {\n\tchar\t*newb, *new_p;\n\tint\t\ti,l;\n\t\n\tl = strlen(string) + 1;\n\n\tnewb = G_Alloc( l );\n\n\tnew_p = newb;\n\n\t// turn \\n into a real linefeed\n\tfor ( i=0 ; i< l ; i++ ) {\n\t\tif (string[i] == '\\\\' && i < l-1) {\n\t\t\ti++;\n\t\t\tif (string[i] == 'n') {\n\t\t\t\t*new_p++ = '\\n';\n\t\t\t} else {\n\t\t\t\t*new_p++ = '\\\\';\n\t\t\t}\n\t\t} else {\n\t\t\t*new_p++ = string[i];\n\t\t}\n\t}\n\t\n\treturn newb;\n}\n\n\n\n\n/*\n===============\nG_ParseField\n\nTakes a key/value pair and sets the binary values\nin a gentity\n===============\n*/\nvoid G_ParseField( const char *key, const char *value, gentity_t *ent ) {\n\tfield_t\t*f;\n\tbyte\t*b;\n\tfloat\tv;\n\tvec3_t\tvec;\n\n\tfor ( f=fields ; f->name ; f++ ) {\n\t\tif ( !Q_stricmp(f->name, key) ) {\n\t\t\t// found it\n\t\t\tb = (byte *)ent;\n\n\t\t\tswitch( f->type ) {\n\t\t\tcase F_LSTRING:\n\t\t\t\t*(char **)(b+f->ofs) = G_NewString (value);\n\t\t\t\tbreak;\n\t\t\tcase F_VECTOR:\n\t\t\t\tsscanf (value, \"%f %f %f\", &vec[0], &vec[1], &vec[2]);\n\t\t\t\t((float *)(b+f->ofs))[0] = vec[0];\n\t\t\t\t((float *)(b+f->ofs))[1] = vec[1];\n\t\t\t\t((float *)(b+f->ofs))[2] = vec[2];\n\t\t\t\tbreak;\n\t\t\tcase F_INT:\n\t\t\t\t*(int *)(b+f->ofs) = atoi(value);\n\t\t\t\tbreak;\n\t\t\tcase F_FLOAT:\n\t\t\t\t*(float *)(b+f->ofs) = atof(value);\n\t\t\t\tbreak;\n\t\t\tcase F_ANGLEHACK:\n\t\t\t\tv = atof(value);\n\t\t\t\t((float *)(b+f->ofs))[0] = 0;\n\t\t\t\t((float *)(b+f->ofs))[1] = v;\n\t\t\t\t((float *)(b+f->ofs))[2] = 0;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\tcase F_IGNORE:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t}\n}\n\n\n\n\n/*\n===================\nG_SpawnGEntityFromSpawnVars\n\nSpawn an entity and fill in all of the level fields from\nlevel.spawnVars[], then call the class specfic spawn function\n===================\n*/\nvoid G_SpawnGEntityFromSpawnVars( void ) {\n\tint\t\t\ti;\n\tgentity_t\t*ent;\n\tchar\t\t*s, *value, *gametypeName;\n\tstatic char *gametypeNames[] = {\"ffa\", \"tournament\", \"single\", \"team\", \"ctf\", \"oneflag\", \"obelisk\", \"harvester\", \"teamtournament\"};\n\n\t// get the next free entity\n\tent = G_Spawn();\n\n\tfor ( i = 0 ; i < level.numSpawnVars ; i++ ) {\n\t\tG_ParseField( level.spawnVars[i][0], level.spawnVars[i][1], ent );\n\t}\n\n\t// check for \"notsingle\" flag\n\tif ( g_gametype.integer == GT_SINGLE_PLAYER ) {\n\t\tG_SpawnInt( \"notsingle\", \"0\", &i );\n\t\tif ( i ) {\n\t\t\tG_FreeEntity( ent );\n\t\t\treturn;\n\t\t}\n\t}\n\t// check for \"notteam\" flag (GT_FFA, GT_TOURNAMENT, GT_SINGLE_PLAYER)\n\tif ( g_gametype.integer >= GT_TEAM ) {\n\t\tG_SpawnInt( \"notteam\", \"0\", &i );\n\t\tif ( i ) {\n\t\t\tG_FreeEntity( ent );\n\t\t\treturn;\n\t\t}\n\t} else {\n\t\tG_SpawnInt( \"notfree\", \"0\", &i );\n\t\tif ( i ) {\n\t\t\tG_FreeEntity( ent );\n\t\t\treturn;\n\t\t}\n\t}\n\n#ifdef MISSIONPACK\n\tG_SpawnInt( \"notta\", \"0\", &i );\n\tif ( i ) {\n\t\tG_FreeEntity( ent );\n\t\treturn;\n\t}\n#else\n\tG_SpawnInt( \"notq3a\", \"0\", &i );\n\tif ( i ) {\n\t\tG_FreeEntity( ent );\n\t\treturn;\n\t}\n#endif\n\n\tif( G_SpawnString( \"gametype\", NULL, &value ) ) {\n\t\tif( g_gametype.integer >= GT_FFA && g_gametype.integer < GT_MAX_GAME_TYPE ) {\n\t\t\tgametypeName = gametypeNames[g_gametype.integer];\n\n\t\t\ts = strstr( value, gametypeName );\n\t\t\tif( !s ) {\n\t\t\t\tG_FreeEntity( ent );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\t// move editor origin to pos\n\tVectorCopy( ent->s.origin, ent->s.pos.trBase );\n\tVectorCopy( ent->s.origin, ent->r.currentOrigin );\n\n\t// if we didn't get a classname, don't bother spawning anything\n\tif ( !G_CallSpawn( ent ) ) {\n\t\tG_FreeEntity( ent );\n\t}\n}\n\n\n\n/*\n====================\nG_AddSpawnVarToken\n====================\n*/\nchar *G_AddSpawnVarToken( const char *string ) {\n\tint\t\tl;\n\tchar\t*dest;\n\n\tl = strlen( string );\n\tif ( level.numSpawnVarChars + l + 1 > MAX_SPAWN_VARS_CHARS ) {\n\t\tG_Error( \"G_AddSpawnVarToken: MAX_SPAWN_CHARS\" );\n\t}\n\n\tdest = level.spawnVarChars + level.numSpawnVarChars;\n\tmemcpy( dest, string, l+1 );\n\n\tlevel.numSpawnVarChars += l + 1;\n\n\treturn dest;\n}\n\n/*\n====================\nG_ParseSpawnVars\n\nParses a brace bounded set of key / value pairs out of the\nlevel's entity strings into level.spawnVars[]\n\nThis does not actually spawn an entity.\n====================\n*/\nqboolean G_ParseSpawnVars( void ) {\n\tchar\t\tkeyname[MAX_TOKEN_CHARS];\n\tchar\t\tcom_token[MAX_TOKEN_CHARS];\n\n\tlevel.numSpawnVars = 0;\n\tlevel.numSpawnVarChars = 0;\n\n\t// parse the opening brace\n\tif ( !trap_GetEntityToken( com_token, sizeof( com_token ) ) ) {\n\t\t// end of spawn string\n\t\treturn qfalse;\n\t}\n\tif ( com_token[0] != '{' ) {\n\t\tG_Error( \"G_ParseSpawnVars: found %s when expecting {\",com_token );\n\t}\n\n\t// go through all the key / value pairs\n\twhile ( 1 ) {\t\n\t\t// parse key\n\t\tif ( !trap_GetEntityToken( keyname, sizeof( keyname ) ) ) {\n\t\t\tG_Error( \"G_ParseSpawnVars: EOF without closing brace\" );\n\t\t}\n\n\t\tif ( keyname[0] == '}' ) {\n\t\t\tbreak;\n\t\t}\n\t\t\n\t\t// parse value\t\n\t\tif ( !trap_GetEntityToken( com_token, sizeof( com_token ) ) ) {\n\t\t\tG_Error( \"G_ParseSpawnVars: EOF without closing brace\" );\n\t\t}\n\n\t\tif ( com_token[0] == '}' ) {\n\t\t\tG_Error( \"G_ParseSpawnVars: closing brace without data\" );\n\t\t}\n\t\tif ( level.numSpawnVars == MAX_SPAWN_VARS ) {\n\t\t\tG_Error( \"G_ParseSpawnVars: MAX_SPAWN_VARS\" );\n\t\t}\n\t\tlevel.spawnVars[ level.numSpawnVars ][0] = G_AddSpawnVarToken( keyname );\n\t\tlevel.spawnVars[ level.numSpawnVars ][1] = G_AddSpawnVarToken( com_token );\n\t\tlevel.numSpawnVars++;\n\t}\n\n\treturn qtrue;\n}\n\n\n\n/*QUAKED worldspawn (0 0 0) ?\n\nEvery map should have exactly one worldspawn.\n\"music\"\t\tmusic wav file\n\"gravity\"\t800 is default gravity\n\"message\"\tText to print during connection process\n*/\nvoid SP_worldspawn( void ) {\n\tchar\t*s;\n\n\tG_SpawnString( \"classname\", \"\", &s );\n\tif ( Q_stricmp( s, \"worldspawn\" ) ) {\n\t\tG_Error( \"SP_worldspawn: The first entity isn't 'worldspawn'\" );\n\t}\n\n\t// make some data visible to connecting client\n\ttrap_SetConfigstring( CS_GAME_VERSION, GAME_VERSION );\n\n\ttrap_SetConfigstring( CS_LEVEL_START_TIME, va(\"%i\", level.startTime ) );\n\n\tG_SpawnString( \"music\", \"\", &s );\n\ttrap_SetConfigstring( CS_MUSIC, s );\n\n\tG_SpawnString( \"message\", \"\", &s );\n\ttrap_SetConfigstring( CS_MESSAGE, s );\t\t\t\t// map specific message\n\n\ttrap_SetConfigstring( CS_MOTD, g_motd.string );\t\t// message of the day\n\n\tG_SpawnString( \"gravity\", \"800\", &s );\n\ttrap_Cvar_Set( \"g_gravity\", s );\n\n\tG_SpawnString( \"enableDust\", \"0\", &s );\n\ttrap_Cvar_Set( \"g_enableDust\", s );\n\n\tG_SpawnString( \"enableBreath\", \"0\", &s );\n\ttrap_Cvar_Set( \"g_enableBreath\", s );\n\n\tg_entities[ENTITYNUM_WORLD].s.number = ENTITYNUM_WORLD;\n\tg_entities[ENTITYNUM_WORLD].classname = \"worldspawn\";\n\n\t// see if we want a warmup time\n\ttrap_SetConfigstring( CS_WARMUP, \"\" );\n\tif ( g_restarted.integer ) {\n\t\ttrap_Cvar_Set( \"g_restarted\", \"0\" );\n\t\tlevel.warmupTime = 0;\n\t} else if ( g_doWarmup.integer ) { // Turn it on\n\t\tlevel.warmupTime = -1;\n\t\ttrap_SetConfigstring( CS_WARMUP, va(\"%i\", level.warmupTime) );\n\t\tG_LogPrintf( \"Warmup:\\n\" );\n\t}\n\n}\n\n\n/*\n==============\nG_SpawnEntitiesFromString\n\nParses textual entity definitions out of an entstring and spawns gentities.\n==============\n*/\nvoid G_SpawnEntitiesFromString( void ) {\n\t// allow calls to G_Spawn*()\n\tlevel.spawning = qtrue;\n\tlevel.numSpawnVars = 0;\n\n\t// the worldspawn is not an actual entity, but it still\n\t// has a \"spawn\" function to perform any global setup\n\t// needed by a level (setting configstrings or cvars, etc)\n\tif ( !G_ParseSpawnVars() ) {\n\t\tG_Error( \"SpawnEntities: no entities\" );\n\t}\n\tSP_worldspawn();\n\n\t// parse ents\n\twhile( G_ParseSpawnVars() ) {\n\t\tG_SpawnGEntityFromSpawnVars();\n\t}\t\n\n\tlevel.spawning = qfalse;\t\t\t// any future calls to G_Spawn*() will be errors\n}\n\n"
  },
  {
    "path": "code/game/g_svcmds.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n// this file holds commands that can be executed by the server console, but not remote clients\n\n#include \"g_local.h\"\n\n\n/*\n==============================================================================\n\nPACKET FILTERING\n \n\nYou can add or remove addresses from the filter list with:\n\naddip <ip>\nremoveip <ip>\n\nThe ip address is specified in dot format, and you can use '*' to match any value\nso you can specify an entire class C network with \"addip 192.246.40.*\"\n\nRemoveip will only remove an address specified exactly the same way.  You cannot addip a subnet, then removeip a single host.\n\nlistip\nPrints the current list of filters.\n\ng_filterban <0 or 1>\n\nIf 1 (the default), then ip addresses matching the current list will be prohibited from entering the game.  This is the default setting.\n\nIf 0, then only addresses matching the list will be allowed.  This lets you easily set up a private game, or a game that only allows players from your local network.\n\nTTimo NOTE: for persistence, bans are stored in g_banIPs cvar MAX_CVAR_VALUE_STRING\nThe size of the cvar string buffer is limiting the banning to around 20 masks\nthis could be improved by putting some g_banIPs2 g_banIps3 etc. maybe\nstill, you should rely on PB for banning instead\n\n==============================================================================\n*/\n\ntypedef struct ipFilter_s\n{\n\tunsigned\tmask;\n\tunsigned\tcompare;\n} ipFilter_t;\n\n#define\tMAX_IPFILTERS\t1024\n\nstatic ipFilter_t\tipFilters[MAX_IPFILTERS];\nstatic int\t\t\tnumIPFilters;\n\n/*\n=================\nStringToFilter\n=================\n*/\nstatic qboolean StringToFilter (char *s, ipFilter_t *f)\n{\n\tchar\tnum[128];\n\tint\t\ti, j;\n\tbyte\tb[4];\n\tbyte\tm[4];\n\t\n\tfor (i=0 ; i<4 ; i++)\n\t{\n\t\tb[i] = 0;\n\t\tm[i] = 0;\n\t}\n\t\n\tfor (i=0 ; i<4 ; i++)\n\t{\n\t\tif (*s < '0' || *s > '9')\n\t\t{\n\t\t\tif (*s == '*') // 'match any'\n\t\t\t{\n\t\t\t\t// b[i] and m[i] to 0\n\t\t\t\ts++;\n\t\t\t\tif (!*s)\n\t\t\t\t\tbreak;\n\t\t\t\ts++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tG_Printf( \"Bad filter address: %s\\n\", s );\n\t\t\treturn qfalse;\n\t\t}\n\t\t\n\t\tj = 0;\n\t\twhile (*s >= '0' && *s <= '9')\n\t\t{\n\t\t\tnum[j++] = *s++;\n\t\t}\n\t\tnum[j] = 0;\n\t\tb[i] = atoi(num);\n\t\tm[i] = 255;\n\n\t\tif (!*s)\n\t\t\tbreak;\n\t\ts++;\n\t}\n\t\n\tf->mask = *(unsigned *)m;\n\tf->compare = *(unsigned *)b;\n\t\n\treturn qtrue;\n}\n\n/*\n=================\nUpdateIPBans\n=================\n*/\nstatic void UpdateIPBans (void)\n{\n\tbyte\tb[4];\n\tbyte\tm[4];\n\tint\t\ti,j;\n\tchar\tiplist_final[MAX_CVAR_VALUE_STRING];\n\tchar\tip[64];\n\n\t*iplist_final = 0;\n\tfor (i = 0 ; i < numIPFilters ; i++)\n\t{\n\t\tif (ipFilters[i].compare == 0xffffffff)\n\t\t\tcontinue;\n\n\t\t*(unsigned *)b = ipFilters[i].compare;\n\t\t*(unsigned *)m = ipFilters[i].mask;\n\t\t*ip = 0;\n\t\tfor (j = 0 ; j < 4 ; j++)\n\t\t{\n\t\t\tif (m[j]!=255)\n\t\t\t\tQ_strcat(ip, sizeof(ip), \"*\");\n\t\t\telse\n\t\t\t\tQ_strcat(ip, sizeof(ip), va(\"%i\", b[j]));\n\t\t\tQ_strcat(ip, sizeof(ip), (j<3) ? \".\" : \" \");\n\t\t}\t\t\n\t\tif (strlen(iplist_final)+strlen(ip) < MAX_CVAR_VALUE_STRING)\n\t\t{\n\t\t\tQ_strcat( iplist_final, sizeof(iplist_final), ip);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tCom_Printf(\"g_banIPs overflowed at MAX_CVAR_VALUE_STRING\\n\");\n\t\t\tbreak;\n\t\t}\n\t}\n\n\ttrap_Cvar_Set( \"g_banIPs\", iplist_final );\n}\n\n/*\n=================\nG_FilterPacket\n=================\n*/\nqboolean G_FilterPacket (char *from)\n{\n\tint\t\ti;\n\tunsigned\tin;\n\tbyte m[4];\n\tchar *p;\n\n\ti = 0;\n\tp = from;\n\twhile (*p && i < 4) {\n\t\tm[i] = 0;\n\t\twhile (*p >= '0' && *p <= '9') {\n\t\t\tm[i] = m[i]*10 + (*p - '0');\n\t\t\tp++;\n\t\t}\n\t\tif (!*p || *p == ':')\n\t\t\tbreak;\n\t\ti++, p++;\n\t}\n\t\n\tin = *(unsigned *)m;\n\n\tfor (i=0 ; i<numIPFilters ; i++)\n\t\tif ( (in & ipFilters[i].mask) == ipFilters[i].compare)\n\t\t\treturn g_filterBan.integer != 0;\n\n\treturn g_filterBan.integer == 0;\n}\n\n/*\n=================\nAddIP\n=================\n*/\nstatic void AddIP( char *str )\n{\n\tint\t\ti;\n\n\tfor (i = 0 ; i < numIPFilters ; i++)\n\t\tif (ipFilters[i].compare == 0xffffffff)\n\t\t\tbreak;\t\t// free spot\n\tif (i == numIPFilters)\n\t{\n\t\tif (numIPFilters == MAX_IPFILTERS)\n\t\t{\n\t\t\tG_Printf (\"IP filter list is full\\n\");\n\t\t\treturn;\n\t\t}\n\t\tnumIPFilters++;\n\t}\n\t\n\tif (!StringToFilter (str, &ipFilters[i]))\n\t\tipFilters[i].compare = 0xffffffffu;\n\n\tUpdateIPBans();\n}\n\n/*\n=================\nG_ProcessIPBans\n=================\n*/\nvoid G_ProcessIPBans(void) \n{\n\tchar *s, *t;\n\tchar\t\tstr[MAX_CVAR_VALUE_STRING];\n\n\tQ_strncpyz( str, g_banIPs.string, sizeof(str) );\n\n\tfor (t = s = g_banIPs.string; *t; /* */ ) {\n\t\ts = strchr(s, ' ');\n\t\tif (!s)\n\t\t\tbreak;\n\t\twhile (*s == ' ')\n\t\t\t*s++ = 0;\n\t\tif (*t)\n\t\t\tAddIP( t );\n\t\tt = s;\n\t}\n}\n\n\n/*\n=================\nSvcmd_AddIP_f\n=================\n*/\nvoid Svcmd_AddIP_f (void)\n{\n\tchar\t\tstr[MAX_TOKEN_CHARS];\n\n\tif ( trap_Argc() < 2 ) {\n\t\tG_Printf(\"Usage:  addip <ip-mask>\\n\");\n\t\treturn;\n\t}\n\n\ttrap_Argv( 1, str, sizeof( str ) );\n\n\tAddIP( str );\n\n}\n\n/*\n=================\nSvcmd_RemoveIP_f\n=================\n*/\nvoid Svcmd_RemoveIP_f (void)\n{\n\tipFilter_t\tf;\n\tint\t\t\ti;\n\tchar\t\tstr[MAX_TOKEN_CHARS];\n\n\tif ( trap_Argc() < 2 ) {\n\t\tG_Printf(\"Usage:  sv removeip <ip-mask>\\n\");\n\t\treturn;\n\t}\n\n\ttrap_Argv( 1, str, sizeof( str ) );\n\n\tif (!StringToFilter (str, &f))\n\t\treturn;\n\n\tfor (i=0 ; i<numIPFilters ; i++) {\n\t\tif (ipFilters[i].mask == f.mask\t&&\n\t\t\tipFilters[i].compare == f.compare) {\n\t\t\tipFilters[i].compare = 0xffffffffu;\n\t\t\tG_Printf (\"Removed.\\n\");\n\n\t\t\tUpdateIPBans();\n\t\t\treturn;\n\t\t}\n\t}\n\n\tG_Printf ( \"Didn't find %s.\\n\", str );\n}\n\n/*\n===================\nSvcmd_EntityList_f\n===================\n*/\nvoid\tSvcmd_EntityList_f (void) {\n\tint\t\t\te;\n\tgentity_t\t\t*check;\n\n\tcheck = g_entities+1;\n\tfor (e = 1; e < level.num_entities ; e++, check++) {\n\t\tif ( !check->inuse ) {\n\t\t\tcontinue;\n\t\t}\n\t\tG_Printf(\"%3i:\", e);\n\t\tswitch ( check->s.eType ) {\n\t\tcase ET_GENERAL:\n\t\t\tG_Printf(\"ET_GENERAL          \");\n\t\t\tbreak;\n\t\tcase ET_PLAYER:\n\t\t\tG_Printf(\"ET_PLAYER           \");\n\t\t\tbreak;\n\t\tcase ET_ITEM:\n\t\t\tG_Printf(\"ET_ITEM             \");\n\t\t\tbreak;\n\t\tcase ET_MISSILE:\n\t\t\tG_Printf(\"ET_MISSILE          \");\n\t\t\tbreak;\n\t\tcase ET_MOVER:\n\t\t\tG_Printf(\"ET_MOVER            \");\n\t\t\tbreak;\n\t\tcase ET_BEAM:\n\t\t\tG_Printf(\"ET_BEAM             \");\n\t\t\tbreak;\n\t\tcase ET_PORTAL:\n\t\t\tG_Printf(\"ET_PORTAL           \");\n\t\t\tbreak;\n\t\tcase ET_SPEAKER:\n\t\t\tG_Printf(\"ET_SPEAKER          \");\n\t\t\tbreak;\n\t\tcase ET_PUSH_TRIGGER:\n\t\t\tG_Printf(\"ET_PUSH_TRIGGER     \");\n\t\t\tbreak;\n\t\tcase ET_TELEPORT_TRIGGER:\n\t\t\tG_Printf(\"ET_TELEPORT_TRIGGER \");\n\t\t\tbreak;\n\t\tcase ET_INVISIBLE:\n\t\t\tG_Printf(\"ET_INVISIBLE        \");\n\t\t\tbreak;\n\t\tcase ET_GRAPPLE:\n\t\t\tG_Printf(\"ET_GRAPPLE          \");\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tG_Printf(\"%3i                 \", check->s.eType);\n\t\t\tbreak;\n\t\t}\n\n\t\tif ( check->classname ) {\n\t\t\tG_Printf(\"%s\", check->classname);\n\t\t}\n\t\tG_Printf(\"\\n\");\n\t}\n}\n\ngclient_t\t*ClientForString( const char *s ) {\n\tgclient_t\t*cl;\n\tint\t\t\ti;\n\tint\t\t\tidnum;\n\n\t// numeric values are just slot numbers\n\tif ( s[0] >= '0' && s[0] <= '9' ) {\n\t\tidnum = atoi( s );\n\t\tif ( idnum < 0 || idnum >= level.maxclients ) {\n\t\t\tCom_Printf( \"Bad client slot: %i\\n\", idnum );\n\t\t\treturn NULL;\n\t\t}\n\n\t\tcl = &level.clients[idnum];\n\t\tif ( cl->pers.connected == CON_DISCONNECTED ) {\n\t\t\tG_Printf( \"Client %i is not connected\\n\", idnum );\n\t\t\treturn NULL;\n\t\t}\n\t\treturn cl;\n\t}\n\n\t// check for a name match\n\tfor ( i=0 ; i < level.maxclients ; i++ ) {\n\t\tcl = &level.clients[i];\n\t\tif ( cl->pers.connected == CON_DISCONNECTED ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( !Q_stricmp( cl->pers.netname, s ) ) {\n\t\t\treturn cl;\n\t\t}\n\t}\n\n\tG_Printf( \"User %s is not on the server\\n\", s );\n\n\treturn NULL;\n}\n\n/*\n===================\nSvcmd_ForceTeam_f\n\nforceteam <player> <team>\n===================\n*/\nvoid\tSvcmd_ForceTeam_f( void ) {\n\tgclient_t\t*cl;\n\tchar\t\tstr[MAX_TOKEN_CHARS];\n\n\t// find the player\n\ttrap_Argv( 1, str, sizeof( str ) );\n\tcl = ClientForString( str );\n\tif ( !cl ) {\n\t\treturn;\n\t}\n\n\t// set the team\n\ttrap_Argv( 2, str, sizeof( str ) );\n\tSetTeam( &g_entities[cl - level.clients], str );\n}\n\nchar\t*ConcatArgs( int start );\n\n/*\n=================\nConsoleCommand\n\n=================\n*/\nqboolean\tConsoleCommand( void ) {\n\tchar\tcmd[MAX_TOKEN_CHARS];\n\n\ttrap_Argv( 0, cmd, sizeof( cmd ) );\n\n\tif ( Q_stricmp (cmd, \"entitylist\") == 0 ) {\n\t\tSvcmd_EntityList_f();\n\t\treturn qtrue;\n\t}\n\n\tif ( Q_stricmp (cmd, \"forceteam\") == 0 ) {\n\t\tSvcmd_ForceTeam_f();\n\t\treturn qtrue;\n\t}\n\n\tif (Q_stricmp (cmd, \"game_memory\") == 0) {\n\t\tSvcmd_GameMem_f();\n\t\treturn qtrue;\n\t}\n\n\tif (Q_stricmp (cmd, \"addbot\") == 0) {\n\t\tSvcmd_AddBot_f();\n\t\treturn qtrue;\n\t}\n\n\tif (Q_stricmp (cmd, \"botlist\") == 0) {\n\t\tSvcmd_BotList_f();\n\t\treturn qtrue;\n\t}\n\n\tif (Q_stricmp (cmd, \"abort_podium\") == 0) {\n\t\tSvcmd_AbortPodium_f();\n\t\treturn qtrue;\n\t}\n\n\tif (Q_stricmp (cmd, \"addip\") == 0) {\n\t\tSvcmd_AddIP_f();\n\t\treturn qtrue;\n\t}\n\n\tif (Q_stricmp (cmd, \"removeip\") == 0) {\n\t\tSvcmd_RemoveIP_f();\n\t\treturn qtrue;\n\t}\n\n\tif (Q_stricmp (cmd, \"listip\") == 0) {\n\t\ttrap_SendConsoleCommand( EXEC_NOW, \"g_banIPs\\n\" );\n\t\treturn qtrue;\n\t}\n\n\tif (g_dedicated.integer) {\n\t\tif (Q_stricmp (cmd, \"say\") == 0) {\n\t\t\ttrap_SendServerCommand( -1, va(\"print \\\"server: %s\\\"\", ConcatArgs(1) ) );\n\t\t\treturn qtrue;\n\t\t}\n\t\t// everything else will also be printed as a say command\n\t\ttrap_SendServerCommand( -1, va(\"print \\\"server: %s\\\"\", ConcatArgs(0) ) );\n\t\treturn qtrue;\n\t}\n\n\treturn qfalse;\n}\n\n"
  },
  {
    "path": "code/game/g_syscalls.asm",
    "content": "code\n\nequ\ttrap_Printf\t\t\t\t-1\nequ\ttrap_Error\t\t\t\t-2\nequ\ttrap_Milliseconds\t\t-3\nequ\ttrap_Cvar_Register\t\t-4\nequ\ttrap_Cvar_Update\t\t-5\nequ\ttrap_Cvar_Set\t\t\t-6\nequ\ttrap_Cvar_VariableIntegerValue\t-7\nequ\ttrap_Cvar_VariableStringBuffer\t-8\nequ\ttrap_Argc\t\t\t\t-9\nequ\ttrap_Argv\t\t\t\t-10\nequ\ttrap_FS_FOpenFile\t\t-11\nequ\ttrap_FS_Read\t\t\t-12\nequ\ttrap_FS_Write\t\t\t-13\nequ\ttrap_FS_FCloseFile\t\t-14\nequ\ttrap_SendConsoleCommand\t-15\nequ\ttrap_LocateGameData\t\t-16\nequ\ttrap_DropClient\t\t\t-17\nequ\ttrap_SendServerCommand\t-18\nequ\ttrap_SetConfigstring\t-19\nequ\ttrap_GetConfigstring\t-20\nequ\ttrap_GetUserinfo\t\t-21\nequ\ttrap_SetUserinfo\t\t-22\nequ\ttrap_GetServerinfo\t\t-23\nequ\ttrap_SetBrushModel\t\t-24\nequ\ttrap_Trace\t\t\t\t-25\nequ\ttrap_PointContents\t\t-26\nequ trap_InPVS\t\t\t\t-27\nequ\ttrap_InPVSIgnorePortals\t-28\nequ\ttrap_AdjustAreaPortalState\t-29\nequ\ttrap_AreasConnected\t\t-30\nequ\ttrap_LinkEntity\t\t\t-31\nequ\ttrap_UnlinkEntity\t\t-32\nequ\ttrap_EntitiesInBox\t\t-33\nequ\ttrap_EntityContact\t\t-34\nequ\ttrap_BotAllocateClient\t-35\nequ\ttrap_BotFreeClient\t\t-36\nequ\ttrap_GetUsercmd\t\t\t-37\nequ\ttrap_GetEntityToken\t\t-38\nequ\ttrap_FS_GetFileList\t\t-39\nequ trap_DebugPolygonCreate\t-40\nequ trap_DebugPolygonDelete\t-41\nequ trap_RealTime\t\t\t-42\nequ trap_SnapVector\t\t\t-43\nequ trap_TraceCapsule\t\t-44\nequ trap_EntityContactCapsule\t-45\nequ trap_FS_Seek -46\n\nequ\tmemset\t\t\t\t\t-101\nequ\tmemcpy\t\t\t\t\t-102\nequ\tstrncpy\t\t\t\t\t-103\nequ\tsin\t\t\t\t\t\t-104\nequ\tcos\t\t\t\t\t\t-105\nequ\tatan2\t\t\t\t\t-106\nequ\tsqrt\t\t\t\t\t-107\nequ floor\t\t\t\t\t-111\nequ\tceil\t\t\t\t\t-112\nequ\ttestPrintInt\t\t\t-113\nequ\ttestPrintFloat\t\t\t-114\n\n\n\nequ trap_BotLibSetup\t\t\t\t\t-201\nequ trap_BotLibShutdown\t\t\t\t\t-202\nequ trap_BotLibVarSet\t\t\t\t\t-203\nequ trap_BotLibVarGet\t\t\t\t\t-204\nequ trap_BotLibDefine\t\t\t\t\t-205\nequ trap_BotLibStartFrame\t\t\t\t-206\nequ trap_BotLibLoadMap\t\t\t\t\t-207\nequ trap_BotLibUpdateEntity\t\t\t\t-208\nequ trap_BotLibTest\t\t\t\t\t\t-209\n\nequ trap_BotGetSnapshotEntity\t\t\t-210\nequ trap_BotGetServerCommand\t\t-211\nequ trap_BotUserCommand\t\t\t\t\t-212\n\n\n\nequ trap_AAS_EnableRoutingArea\t\t-301\nequ trap_AAS_BBoxAreas\t\t\t\t-302\nequ trap_AAS_AreaInfo\t\t\t\t-303\nequ trap_AAS_EntityInfo\t\t\t\t\t-304\n\nequ trap_AAS_Initialized\t\t\t\t-305\nequ trap_AAS_PresenceTypeBoundingBox\t-306\nequ trap_AAS_Time\t\t\t\t\t\t-307\n\nequ trap_AAS_PointAreaNum\t\t\t\t-308\nequ trap_AAS_TraceAreas\t\t\t\t\t-309\n\nequ trap_AAS_PointContents\t\t\t\t-310\nequ trap_AAS_NextBSPEntity\t\t\t\t-311\nequ trap_AAS_ValueForBSPEpairKey\t\t-312\nequ trap_AAS_VectorForBSPEpairKey\t\t-313\nequ trap_AAS_FloatForBSPEpairKey\t\t-314\nequ trap_AAS_IntForBSPEpairKey\t\t\t-315\n\nequ trap_AAS_AreaReachability\t\t\t-316\n\nequ trap_AAS_AreaTravelTimeToGoalArea\t-317\n\nequ trap_AAS_Swimming\t\t\t\t\t-318\nequ trap_AAS_PredictClientMovement\t\t-319\n\n\n\nequ trap_EA_Say\t\t\t\t\t\t\t-401\nequ trap_EA_SayTeam\t\t\t\t\t\t-402\nequ trap_EA_Command\t\t\t\t\t\t-403\n\nequ trap_EA_Action\t\t\t\t\t\t-404\nequ trap_EA_Gesture\t\t\t\t\t\t-405\nequ trap_EA_Talk\t\t\t\t\t\t-406\nequ trap_EA_Attack\t\t\t\t\t\t-407\nequ trap_EA_Use\t\t\t\t\t\t\t-408\nequ trap_EA_Respawn\t\t\t\t\t\t-409\nequ trap_EA_Crouch\t\t\t\t\t\t-410\nequ trap_EA_MoveUp\t\t\t\t\t\t-411\nequ trap_EA_MoveDown\t\t\t\t\t-412\nequ trap_EA_MoveForward\t\t\t\t\t-413\nequ trap_EA_MoveBack\t\t\t\t\t-414\nequ trap_EA_MoveLeft\t\t\t\t\t-415\nequ trap_EA_MoveRight\t\t\t\t\t-416\n\nequ trap_EA_SelectWeapon\t\t\t\t-417\nequ trap_EA_Jump\t\t\t\t\t\t-418\nequ trap_EA_DelayedJump\t\t\t\t\t-419\nequ trap_EA_Move\t\t\t\t\t\t-420\nequ trap_EA_View\t\t\t\t\t\t-421\n\nequ trap_EA_EndRegular\t\t\t\t\t-422\nequ trap_EA_GetInput\t\t\t\t\t-423\nequ trap_EA_ResetInput\t\t\t\t\t-424\n\n\n\nequ trap_BotLoadCharacter\t\t\t\t-501\nequ trap_BotFreeCharacter\t\t\t\t-502\nequ trap_Characteristic_Float\t\t\t-503\nequ trap_Characteristic_BFloat\t\t\t-504\nequ trap_Characteristic_Integer\t\t\t-505\nequ trap_Characteristic_BInteger\t\t-506\nequ trap_Characteristic_String\t\t\t-507\n\nequ trap_BotAllocChatState\t\t\t\t-508\nequ trap_BotFreeChatState\t\t\t\t-509\nequ trap_BotQueueConsoleMessage\t\t\t-510\nequ trap_BotRemoveConsoleMessage\t\t-511\nequ trap_BotNextConsoleMessage\t\t\t-512\nequ trap_BotNumConsoleMessages\t\t\t-513\nequ trap_BotInitialChat\t\t\t\t\t-514\nequ trap_BotReplyChat\t\t\t\t\t-515\nequ trap_BotChatLength\t\t\t\t\t-516\nequ trap_BotEnterChat\t\t\t\t\t-517\nequ trap_StringContains\t\t\t\t\t-518\nequ trap_BotFindMatch\t\t\t\t\t-519\nequ trap_BotMatchVariable\t\t\t\t-520\nequ trap_UnifyWhiteSpaces\t\t\t\t-521\nequ trap_BotReplaceSynonyms\t\t\t\t-522\nequ trap_BotLoadChatFile\t\t\t\t-523\nequ trap_BotSetChatGender\t\t\t\t-524\nequ trap_BotSetChatName\t\t\t\t\t-525\n\nequ trap_BotResetGoalState\t\t\t\t-526\nequ trap_BotResetAvoidGoals\t\t\t\t-527\nequ trap_BotPushGoal\t\t\t\t\t-528\nequ trap_BotPopGoal\t\t\t\t\t\t-529\nequ trap_BotEmptyGoalStack\t\t\t\t-530\nequ trap_BotDumpAvoidGoals\t\t\t\t-531\nequ trap_BotDumpGoalStack\t\t\t\t-532\nequ trap_BotGoalName\t\t\t\t\t-533\nequ trap_BotGetTopGoal\t\t\t\t\t-534\nequ trap_BotGetSecondGoal\t\t\t\t-535\nequ trap_BotChooseLTGItem\t\t\t\t-536\nequ trap_BotChooseNBGItem\t\t\t\t-537\nequ trap_BotTouchingGoal\t\t\t\t-538\nequ trap_BotItemGoalInVisButNotVisible\t-539\nequ trap_BotGetLevelItemGoal\t\t\t-540\nequ trap_BotAvoidGoalTime\t\t\t\t-541\nequ trap_BotInitLevelItems\t\t\t\t-542\nequ trap_BotUpdateEntityItems\t\t\t-543\nequ trap_BotLoadItemWeights\t\t\t\t-544\nequ trap_BotFreeItemWeights\t\t\t\t-546\nequ trap_BotSaveGoalFuzzyLogic\t\t\t-546\nequ trap_BotAllocGoalState\t\t\t\t-547\nequ trap_BotFreeGoalState\t\t\t\t-548\n\nequ trap_BotResetMoveState\t\t\t\t-549\nequ trap_BotMoveToGoal\t\t\t\t\t-550\nequ trap_BotMoveInDirection\t\t\t\t-551\nequ trap_BotResetAvoidReach\t\t\t\t-552\nequ trap_BotResetLastAvoidReach\t\t\t-553\nequ trap_BotReachabilityArea\t\t\t-554\nequ trap_BotMovementViewTarget\t\t\t-555\nequ trap_BotAllocMoveState\t\t\t\t-556\nequ trap_BotFreeMoveState\t\t\t\t-557\nequ trap_BotInitMoveState\t\t\t\t-558\n\nequ trap_BotChooseBestFightWeapon\t\t-559\nequ trap_BotGetWeaponInfo\t\t\t\t-560\nequ trap_BotLoadWeaponWeights\t\t\t-561\nequ trap_BotAllocWeaponState\t\t\t-562\nequ trap_BotFreeWeaponState\t\t\t\t-563\nequ trap_BotResetWeaponState\t\t\t-564\nequ trap_GeneticParentsAndChildSelection -565\nequ trap_BotInterbreedGoalFuzzyLogic\t-566\nequ trap_BotMutateGoalFuzzyLogic\t\t-567\nequ trap_BotGetNextCampSpotGoal\t\t\t-568\nequ trap_BotGetMapLocationGoal\t\t\t-569\nequ trap_BotNumInitialChats\t\t\t\t-570\nequ trap_BotGetChatMessage\t\t\t\t-571\nequ trap_BotRemoveFromAvoidGoals\t\t-572\nequ trap_BotPredictVisiblePosition\t\t-573\nequ trap_BotSetAvoidGoalTime\t\t\t-574\nequ trap_BotAddAvoidSpot\t\t\t\t-575\nequ trap_AAS_AlternativeRouteGoals\t\t-576\nequ trap_AAS_PredictRoute\t\t\t\t-577\nequ trap_AAS_PointReachabilityAreaIndex\t-578\n\nequ trap_BotLibLoadSource\t\t\t\t-579\nequ trap_BotLibFreeSource\t\t\t\t-580\nequ trap_BotLibReadToken\t\t\t\t-581\nequ trap_BotLibSourceFileAndLine\t\t-582\n \n"
  },
  {
    "path": "code/game/g_syscalls.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#include \"g_local.h\"\n\n// this file is only included when building a dll\n// g_syscalls.asm is included instead when building a qvm\n#ifdef Q3_VM\n#error \"Do not use in VM build\"\n#endif\n\nstatic int (QDECL *syscall)( int arg, ... ) = (int (QDECL *)( int, ...))-1;\n\n\nvoid dllEntry( int (QDECL *syscallptr)( int arg,... ) ) {\n\tsyscall = syscallptr;\n}\n\nint PASSFLOAT( float x ) {\n\tfloat\tfloatTemp;\n\tfloatTemp = x;\n\treturn *(int *)&floatTemp;\n}\n\nvoid\ttrap_Printf( const char *fmt ) {\n\tsyscall( G_PRINT, fmt );\n}\n\nvoid\ttrap_Error( const char *fmt ) {\n\tsyscall( G_ERROR, fmt );\n}\n\nint\t\ttrap_Milliseconds( void ) {\n\treturn syscall( G_MILLISECONDS ); \n}\nint\t\ttrap_Argc( void ) {\n\treturn syscall( G_ARGC );\n}\n\nvoid\ttrap_Argv( int n, char *buffer, int bufferLength ) {\n\tsyscall( G_ARGV, n, buffer, bufferLength );\n}\n\nint\t\ttrap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode ) {\n\treturn syscall( G_FS_FOPEN_FILE, qpath, f, mode );\n}\n\nvoid\ttrap_FS_Read( void *buffer, int len, fileHandle_t f ) {\n\tsyscall( G_FS_READ, buffer, len, f );\n}\n\nvoid\ttrap_FS_Write( const void *buffer, int len, fileHandle_t f ) {\n\tsyscall( G_FS_WRITE, buffer, len, f );\n}\n\nvoid\ttrap_FS_FCloseFile( fileHandle_t f ) {\n\tsyscall( G_FS_FCLOSE_FILE, f );\n}\n\nint trap_FS_GetFileList(  const char *path, const char *extension, char *listbuf, int bufsize ) {\n\treturn syscall( G_FS_GETFILELIST, path, extension, listbuf, bufsize );\n}\n\nint trap_FS_Seek( fileHandle_t f, long offset, int origin ) {\n\treturn syscall( G_FS_SEEK, f, offset, origin );\n}\n\nvoid\ttrap_SendConsoleCommand( int exec_when, const char *text ) {\n\tsyscall( G_SEND_CONSOLE_COMMAND, exec_when, text );\n}\n\nvoid\ttrap_Cvar_Register( vmCvar_t *cvar, const char *var_name, const char *value, int flags ) {\n\tsyscall( G_CVAR_REGISTER, cvar, var_name, value, flags );\n}\n\nvoid\ttrap_Cvar_Update( vmCvar_t *cvar ) {\n\tsyscall( G_CVAR_UPDATE, cvar );\n}\n\nvoid trap_Cvar_Set( const char *var_name, const char *value ) {\n\tsyscall( G_CVAR_SET, var_name, value );\n}\n\nint trap_Cvar_VariableIntegerValue( const char *var_name ) {\n\treturn syscall( G_CVAR_VARIABLE_INTEGER_VALUE, var_name );\n}\n\nvoid trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize ) {\n\tsyscall( G_CVAR_VARIABLE_STRING_BUFFER, var_name, buffer, bufsize );\n}\n\n\nvoid trap_LocateGameData( gentity_t *gEnts, int numGEntities, int sizeofGEntity_t,\n\t\t\t\t\t\t playerState_t *clients, int sizeofGClient ) {\n\tsyscall( G_LOCATE_GAME_DATA, gEnts, numGEntities, sizeofGEntity_t, clients, sizeofGClient );\n}\n\nvoid trap_DropClient( int clientNum, const char *reason ) {\n\tsyscall( G_DROP_CLIENT, clientNum, reason );\n}\n\nvoid trap_SendServerCommand( int clientNum, const char *text ) {\n\tsyscall( G_SEND_SERVER_COMMAND, clientNum, text );\n}\n\nvoid trap_SetConfigstring( int num, const char *string ) {\n\tsyscall( G_SET_CONFIGSTRING, num, string );\n}\n\nvoid trap_GetConfigstring( int num, char *buffer, int bufferSize ) {\n\tsyscall( G_GET_CONFIGSTRING, num, buffer, bufferSize );\n}\n\nvoid trap_GetUserinfo( int num, char *buffer, int bufferSize ) {\n\tsyscall( G_GET_USERINFO, num, buffer, bufferSize );\n}\n\nvoid trap_SetUserinfo( int num, const char *buffer ) {\n\tsyscall( G_SET_USERINFO, num, buffer );\n}\n\nvoid trap_GetServerinfo( char *buffer, int bufferSize ) {\n\tsyscall( G_GET_SERVERINFO, buffer, bufferSize );\n}\n\nvoid trap_SetBrushModel( gentity_t *ent, const char *name ) {\n\tsyscall( G_SET_BRUSH_MODEL, ent, name );\n}\n\nvoid trap_Trace( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask ) {\n\tsyscall( G_TRACE, results, start, mins, maxs, end, passEntityNum, contentmask );\n}\n\nvoid trap_TraceCapsule( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask ) {\n\tsyscall( G_TRACECAPSULE, results, start, mins, maxs, end, passEntityNum, contentmask );\n}\n\nint trap_PointContents( const vec3_t point, int passEntityNum ) {\n\treturn syscall( G_POINT_CONTENTS, point, passEntityNum );\n}\n\n\nqboolean trap_InPVS( const vec3_t p1, const vec3_t p2 ) {\n\treturn syscall( G_IN_PVS, p1, p2 );\n}\n\nqboolean trap_InPVSIgnorePortals( const vec3_t p1, const vec3_t p2 ) {\n\treturn syscall( G_IN_PVS_IGNORE_PORTALS, p1, p2 );\n}\n\nvoid trap_AdjustAreaPortalState( gentity_t *ent, qboolean open ) {\n\tsyscall( G_ADJUST_AREA_PORTAL_STATE, ent, open );\n}\n\nqboolean trap_AreasConnected( int area1, int area2 ) {\n\treturn syscall( G_AREAS_CONNECTED, area1, area2 );\n}\n\nvoid trap_LinkEntity( gentity_t *ent ) {\n\tsyscall( G_LINKENTITY, ent );\n}\n\nvoid trap_UnlinkEntity( gentity_t *ent ) {\n\tsyscall( G_UNLINKENTITY, ent );\n}\n\nint trap_EntitiesInBox( const vec3_t mins, const vec3_t maxs, int *list, int maxcount ) {\n\treturn syscall( G_ENTITIES_IN_BOX, mins, maxs, list, maxcount );\n}\n\nqboolean trap_EntityContact( const vec3_t mins, const vec3_t maxs, const gentity_t *ent ) {\n\treturn syscall( G_ENTITY_CONTACT, mins, maxs, ent );\n}\n\nqboolean trap_EntityContactCapsule( const vec3_t mins, const vec3_t maxs, const gentity_t *ent ) {\n\treturn syscall( G_ENTITY_CONTACTCAPSULE, mins, maxs, ent );\n}\n\nint trap_BotAllocateClient( void ) {\n\treturn syscall( G_BOT_ALLOCATE_CLIENT );\n}\n\nvoid trap_BotFreeClient( int clientNum ) {\n\tsyscall( G_BOT_FREE_CLIENT, clientNum );\n}\n\nvoid trap_GetUsercmd( int clientNum, usercmd_t *cmd ) {\n\tsyscall( G_GET_USERCMD, clientNum, cmd );\n}\n\nqboolean trap_GetEntityToken( char *buffer, int bufferSize ) {\n\treturn syscall( G_GET_ENTITY_TOKEN, buffer, bufferSize );\n}\n\nint trap_DebugPolygonCreate(int color, int numPoints, vec3_t *points) {\n\treturn syscall( G_DEBUG_POLYGON_CREATE, color, numPoints, points );\n}\n\nvoid trap_DebugPolygonDelete(int id) {\n\tsyscall( G_DEBUG_POLYGON_DELETE, id );\n}\n\nint trap_RealTime( qtime_t *qtime ) {\n\treturn syscall( G_REAL_TIME, qtime );\n}\n\nvoid trap_SnapVector( float *v ) {\n\tsyscall( G_SNAPVECTOR, v );\n\treturn;\n}\n\n// BotLib traps start here\nint trap_BotLibSetup( void ) {\n\treturn syscall( BOTLIB_SETUP );\n}\n\nint trap_BotLibShutdown( void ) {\n\treturn syscall( BOTLIB_SHUTDOWN );\n}\n\nint trap_BotLibVarSet(char *var_name, char *value) {\n\treturn syscall( BOTLIB_LIBVAR_SET, var_name, value );\n}\n\nint trap_BotLibVarGet(char *var_name, char *value, int size) {\n\treturn syscall( BOTLIB_LIBVAR_GET, var_name, value, size );\n}\n\nint trap_BotLibDefine(char *string) {\n\treturn syscall( BOTLIB_PC_ADD_GLOBAL_DEFINE, string );\n}\n\nint trap_BotLibStartFrame(float time) {\n\treturn syscall( BOTLIB_START_FRAME, PASSFLOAT( time ) );\n}\n\nint trap_BotLibLoadMap(const char *mapname) {\n\treturn syscall( BOTLIB_LOAD_MAP, mapname );\n}\n\nint trap_BotLibUpdateEntity(int ent, void /* struct bot_updateentity_s */ *bue) {\n\treturn syscall( BOTLIB_UPDATENTITY, ent, bue );\n}\n\nint trap_BotLibTest(int parm0, char *parm1, vec3_t parm2, vec3_t parm3) {\n\treturn syscall( BOTLIB_TEST, parm0, parm1, parm2, parm3 );\n}\n\nint trap_BotGetSnapshotEntity( int clientNum, int sequence ) {\n\treturn syscall( BOTLIB_GET_SNAPSHOT_ENTITY, clientNum, sequence );\n}\n\nint trap_BotGetServerCommand(int clientNum, char *message, int size) {\n\treturn syscall( BOTLIB_GET_CONSOLE_MESSAGE, clientNum, message, size );\n}\n\nvoid trap_BotUserCommand(int clientNum, usercmd_t *ucmd) {\n\tsyscall( BOTLIB_USER_COMMAND, clientNum, ucmd );\n}\n\nvoid trap_AAS_EntityInfo(int entnum, void /* struct aas_entityinfo_s */ *info) {\n\tsyscall( BOTLIB_AAS_ENTITY_INFO, entnum, info );\n}\n\nint trap_AAS_Initialized(void) {\n\treturn syscall( BOTLIB_AAS_INITIALIZED );\n}\n\nvoid trap_AAS_PresenceTypeBoundingBox(int presencetype, vec3_t mins, vec3_t maxs) {\n\tsyscall( BOTLIB_AAS_PRESENCE_TYPE_BOUNDING_BOX, presencetype, mins, maxs );\n}\n\nfloat trap_AAS_Time(void) {\n\tint temp;\n\ttemp = syscall( BOTLIB_AAS_TIME );\n\treturn (*(float*)&temp);\n}\n\nint trap_AAS_PointAreaNum(vec3_t point) {\n\treturn syscall( BOTLIB_AAS_POINT_AREA_NUM, point );\n}\n\nint trap_AAS_PointReachabilityAreaIndex(vec3_t point) {\n\treturn syscall( BOTLIB_AAS_POINT_REACHABILITY_AREA_INDEX, point );\n}\n\nint trap_AAS_TraceAreas(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas) {\n\treturn syscall( BOTLIB_AAS_TRACE_AREAS, start, end, areas, points, maxareas );\n}\n\nint trap_AAS_BBoxAreas(vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas) {\n\treturn syscall( BOTLIB_AAS_BBOX_AREAS, absmins, absmaxs, areas, maxareas );\n}\n\nint trap_AAS_AreaInfo( int areanum, void /* struct aas_areainfo_s */ *info ) {\n\treturn syscall( BOTLIB_AAS_AREA_INFO, areanum, info );\n}\n\nint trap_AAS_PointContents(vec3_t point) {\n\treturn syscall( BOTLIB_AAS_POINT_CONTENTS, point );\n}\n\nint trap_AAS_NextBSPEntity(int ent) {\n\treturn syscall( BOTLIB_AAS_NEXT_BSP_ENTITY, ent );\n}\n\nint trap_AAS_ValueForBSPEpairKey(int ent, char *key, char *value, int size) {\n\treturn syscall( BOTLIB_AAS_VALUE_FOR_BSP_EPAIR_KEY, ent, key, value, size );\n}\n\nint trap_AAS_VectorForBSPEpairKey(int ent, char *key, vec3_t v) {\n\treturn syscall( BOTLIB_AAS_VECTOR_FOR_BSP_EPAIR_KEY, ent, key, v );\n}\n\nint trap_AAS_FloatForBSPEpairKey(int ent, char *key, float *value) {\n\treturn syscall( BOTLIB_AAS_FLOAT_FOR_BSP_EPAIR_KEY, ent, key, value );\n}\n\nint trap_AAS_IntForBSPEpairKey(int ent, char *key, int *value) {\n\treturn syscall( BOTLIB_AAS_INT_FOR_BSP_EPAIR_KEY, ent, key, value );\n}\n\nint trap_AAS_AreaReachability(int areanum) {\n\treturn syscall( BOTLIB_AAS_AREA_REACHABILITY, areanum );\n}\n\nint trap_AAS_AreaTravelTimeToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags) {\n\treturn syscall( BOTLIB_AAS_AREA_TRAVEL_TIME_TO_GOAL_AREA, areanum, origin, goalareanum, travelflags );\n}\n\nint trap_AAS_EnableRoutingArea( int areanum, int enable ) {\n\treturn syscall( BOTLIB_AAS_ENABLE_ROUTING_AREA, areanum, enable );\n}\n\nint trap_AAS_PredictRoute(void /*struct aas_predictroute_s*/ *route, int areanum, vec3_t origin,\n\t\t\t\t\t\t\tint goalareanum, int travelflags, int maxareas, int maxtime,\n\t\t\t\t\t\t\tint stopevent, int stopcontents, int stoptfl, int stopareanum) {\n\treturn syscall( BOTLIB_AAS_PREDICT_ROUTE, route, areanum, origin, goalareanum, travelflags, maxareas, maxtime, stopevent, stopcontents, stoptfl, stopareanum );\n}\n\nint trap_AAS_AlternativeRouteGoals(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags,\n\t\t\t\t\t\t\t\t\t\tvoid /*struct aas_altroutegoal_s*/ *altroutegoals, int maxaltroutegoals,\n\t\t\t\t\t\t\t\t\t\tint type) {\n\treturn syscall( BOTLIB_AAS_ALTERNATIVE_ROUTE_GOAL, start, startareanum, goal, goalareanum, travelflags, altroutegoals, maxaltroutegoals, type );\n}\n\nint trap_AAS_Swimming(vec3_t origin) {\n\treturn syscall( BOTLIB_AAS_SWIMMING, origin );\n}\n\nint trap_AAS_PredictClientMovement(void /* struct aas_clientmove_s */ *move, int entnum, vec3_t origin, int presencetype, int onground, vec3_t velocity, vec3_t cmdmove, int cmdframes, int maxframes, float frametime, int stopevent, int stopareanum, int visualize) {\n\treturn syscall( BOTLIB_AAS_PREDICT_CLIENT_MOVEMENT, move, entnum, origin, presencetype, onground, velocity, cmdmove, cmdframes, maxframes, PASSFLOAT(frametime), stopevent, stopareanum, visualize );\n}\n\nvoid trap_EA_Say(int client, char *str) {\n\tsyscall( BOTLIB_EA_SAY, client, str );\n}\n\nvoid trap_EA_SayTeam(int client, char *str) {\n\tsyscall( BOTLIB_EA_SAY_TEAM, client, str );\n}\n\nvoid trap_EA_Command(int client, char *command) {\n\tsyscall( BOTLIB_EA_COMMAND, client, command );\n}\n\nvoid trap_EA_Action(int client, int action) {\n\tsyscall( BOTLIB_EA_ACTION, client, action );\n}\n\nvoid trap_EA_Gesture(int client) {\n\tsyscall( BOTLIB_EA_GESTURE, client );\n}\n\nvoid trap_EA_Talk(int client) {\n\tsyscall( BOTLIB_EA_TALK, client );\n}\n\nvoid trap_EA_Attack(int client) {\n\tsyscall( BOTLIB_EA_ATTACK, client );\n}\n\nvoid trap_EA_Use(int client) {\n\tsyscall( BOTLIB_EA_USE, client );\n}\n\nvoid trap_EA_Respawn(int client) {\n\tsyscall( BOTLIB_EA_RESPAWN, client );\n}\n\nvoid trap_EA_Crouch(int client) {\n\tsyscall( BOTLIB_EA_CROUCH, client );\n}\n\nvoid trap_EA_MoveUp(int client) {\n\tsyscall( BOTLIB_EA_MOVE_UP, client );\n}\n\nvoid trap_EA_MoveDown(int client) {\n\tsyscall( BOTLIB_EA_MOVE_DOWN, client );\n}\n\nvoid trap_EA_MoveForward(int client) {\n\tsyscall( BOTLIB_EA_MOVE_FORWARD, client );\n}\n\nvoid trap_EA_MoveBack(int client) {\n\tsyscall( BOTLIB_EA_MOVE_BACK, client );\n}\n\nvoid trap_EA_MoveLeft(int client) {\n\tsyscall( BOTLIB_EA_MOVE_LEFT, client );\n}\n\nvoid trap_EA_MoveRight(int client) {\n\tsyscall( BOTLIB_EA_MOVE_RIGHT, client );\n}\n\nvoid trap_EA_SelectWeapon(int client, int weapon) {\n\tsyscall( BOTLIB_EA_SELECT_WEAPON, client, weapon );\n}\n\nvoid trap_EA_Jump(int client) {\n\tsyscall( BOTLIB_EA_JUMP, client );\n}\n\nvoid trap_EA_DelayedJump(int client) {\n\tsyscall( BOTLIB_EA_DELAYED_JUMP, client );\n}\n\nvoid trap_EA_Move(int client, vec3_t dir, float speed) {\n\tsyscall( BOTLIB_EA_MOVE, client, dir, PASSFLOAT(speed) );\n}\n\nvoid trap_EA_View(int client, vec3_t viewangles) {\n\tsyscall( BOTLIB_EA_VIEW, client, viewangles );\n}\n\nvoid trap_EA_EndRegular(int client, float thinktime) {\n\tsyscall( BOTLIB_EA_END_REGULAR, client, PASSFLOAT(thinktime) );\n}\n\nvoid trap_EA_GetInput(int client, float thinktime, void /* struct bot_input_s */ *input) {\n\tsyscall( BOTLIB_EA_GET_INPUT, client, PASSFLOAT(thinktime), input );\n}\n\nvoid trap_EA_ResetInput(int client) {\n\tsyscall( BOTLIB_EA_RESET_INPUT, client );\n}\n\nint trap_BotLoadCharacter(char *charfile, float skill) {\n\treturn syscall( BOTLIB_AI_LOAD_CHARACTER, charfile, PASSFLOAT(skill));\n}\n\nvoid trap_BotFreeCharacter(int character) {\n\tsyscall( BOTLIB_AI_FREE_CHARACTER, character );\n}\n\nfloat trap_Characteristic_Float(int character, int index) {\n\tint temp;\n\ttemp = syscall( BOTLIB_AI_CHARACTERISTIC_FLOAT, character, index );\n\treturn (*(float*)&temp);\n}\n\nfloat trap_Characteristic_BFloat(int character, int index, float min, float max) {\n\tint temp;\n\ttemp = syscall( BOTLIB_AI_CHARACTERISTIC_BFLOAT, character, index, PASSFLOAT(min), PASSFLOAT(max) );\n\treturn (*(float*)&temp);\n}\n\nint trap_Characteristic_Integer(int character, int index) {\n\treturn syscall( BOTLIB_AI_CHARACTERISTIC_INTEGER, character, index );\n}\n\nint trap_Characteristic_BInteger(int character, int index, int min, int max) {\n\treturn syscall( BOTLIB_AI_CHARACTERISTIC_BINTEGER, character, index, min, max );\n}\n\nvoid trap_Characteristic_String(int character, int index, char *buf, int size) {\n\tsyscall( BOTLIB_AI_CHARACTERISTIC_STRING, character, index, buf, size );\n}\n\nint trap_BotAllocChatState(void) {\n\treturn syscall( BOTLIB_AI_ALLOC_CHAT_STATE );\n}\n\nvoid trap_BotFreeChatState(int handle) {\n\tsyscall( BOTLIB_AI_FREE_CHAT_STATE, handle );\n}\n\nvoid trap_BotQueueConsoleMessage(int chatstate, int type, char *message) {\n\tsyscall( BOTLIB_AI_QUEUE_CONSOLE_MESSAGE, chatstate, type, message );\n}\n\nvoid trap_BotRemoveConsoleMessage(int chatstate, int handle) {\n\tsyscall( BOTLIB_AI_REMOVE_CONSOLE_MESSAGE, chatstate, handle );\n}\n\nint trap_BotNextConsoleMessage(int chatstate, void /* struct bot_consolemessage_s */ *cm) {\n\treturn syscall( BOTLIB_AI_NEXT_CONSOLE_MESSAGE, chatstate, cm );\n}\n\nint trap_BotNumConsoleMessages(int chatstate) {\n\treturn syscall( BOTLIB_AI_NUM_CONSOLE_MESSAGE, chatstate );\n}\n\nvoid trap_BotInitialChat(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7 ) {\n\tsyscall( BOTLIB_AI_INITIAL_CHAT, chatstate, type, mcontext, var0, var1, var2, var3, var4, var5, var6, var7 );\n}\n\nint\ttrap_BotNumInitialChats(int chatstate, char *type) {\n\treturn syscall( BOTLIB_AI_NUM_INITIAL_CHATS, chatstate, type );\n}\n\nint trap_BotReplyChat(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7 ) {\n\treturn syscall( BOTLIB_AI_REPLY_CHAT, chatstate, message, mcontext, vcontext, var0, var1, var2, var3, var4, var5, var6, var7 );\n}\n\nint trap_BotChatLength(int chatstate) {\n\treturn syscall( BOTLIB_AI_CHAT_LENGTH, chatstate );\n}\n\nvoid trap_BotEnterChat(int chatstate, int client, int sendto) {\n\tsyscall( BOTLIB_AI_ENTER_CHAT, chatstate, client, sendto );\n}\n\nvoid trap_BotGetChatMessage(int chatstate, char *buf, int size) {\n\tsyscall( BOTLIB_AI_GET_CHAT_MESSAGE, chatstate, buf, size);\n}\n\nint trap_StringContains(char *str1, char *str2, int casesensitive) {\n\treturn syscall( BOTLIB_AI_STRING_CONTAINS, str1, str2, casesensitive );\n}\n\nint trap_BotFindMatch(char *str, void /* struct bot_match_s */ *match, unsigned long int context) {\n\treturn syscall( BOTLIB_AI_FIND_MATCH, str, match, context );\n}\n\nvoid trap_BotMatchVariable(void /* struct bot_match_s */ *match, int variable, char *buf, int size) {\n\tsyscall( BOTLIB_AI_MATCH_VARIABLE, match, variable, buf, size );\n}\n\nvoid trap_UnifyWhiteSpaces(char *string) {\n\tsyscall( BOTLIB_AI_UNIFY_WHITE_SPACES, string );\n}\n\nvoid trap_BotReplaceSynonyms(char *string, unsigned long int context) {\n\tsyscall( BOTLIB_AI_REPLACE_SYNONYMS, string, context );\n}\n\nint trap_BotLoadChatFile(int chatstate, char *chatfile, char *chatname) {\n\treturn syscall( BOTLIB_AI_LOAD_CHAT_FILE, chatstate, chatfile, chatname );\n}\n\nvoid trap_BotSetChatGender(int chatstate, int gender) {\n\tsyscall( BOTLIB_AI_SET_CHAT_GENDER, chatstate, gender );\n}\n\nvoid trap_BotSetChatName(int chatstate, char *name, int client) {\n\tsyscall( BOTLIB_AI_SET_CHAT_NAME, chatstate, name, client );\n}\n\nvoid trap_BotResetGoalState(int goalstate) {\n\tsyscall( BOTLIB_AI_RESET_GOAL_STATE, goalstate );\n}\n\nvoid trap_BotResetAvoidGoals(int goalstate) {\n\tsyscall( BOTLIB_AI_RESET_AVOID_GOALS, goalstate );\n}\n\nvoid trap_BotRemoveFromAvoidGoals(int goalstate, int number) {\n\tsyscall( BOTLIB_AI_REMOVE_FROM_AVOID_GOALS, goalstate, number);\n}\n\nvoid trap_BotPushGoal(int goalstate, void /* struct bot_goal_s */ *goal) {\n\tsyscall( BOTLIB_AI_PUSH_GOAL, goalstate, goal );\n}\n\nvoid trap_BotPopGoal(int goalstate) {\n\tsyscall( BOTLIB_AI_POP_GOAL, goalstate );\n}\n\nvoid trap_BotEmptyGoalStack(int goalstate) {\n\tsyscall( BOTLIB_AI_EMPTY_GOAL_STACK, goalstate );\n}\n\nvoid trap_BotDumpAvoidGoals(int goalstate) {\n\tsyscall( BOTLIB_AI_DUMP_AVOID_GOALS, goalstate );\n}\n\nvoid trap_BotDumpGoalStack(int goalstate) {\n\tsyscall( BOTLIB_AI_DUMP_GOAL_STACK, goalstate );\n}\n\nvoid trap_BotGoalName(int number, char *name, int size) {\n\tsyscall( BOTLIB_AI_GOAL_NAME, number, name, size );\n}\n\nint trap_BotGetTopGoal(int goalstate, void /* struct bot_goal_s */ *goal) {\n\treturn syscall( BOTLIB_AI_GET_TOP_GOAL, goalstate, goal );\n}\n\nint trap_BotGetSecondGoal(int goalstate, void /* struct bot_goal_s */ *goal) {\n\treturn syscall( BOTLIB_AI_GET_SECOND_GOAL, goalstate, goal );\n}\n\nint trap_BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelflags) {\n\treturn syscall( BOTLIB_AI_CHOOSE_LTG_ITEM, goalstate, origin, inventory, travelflags );\n}\n\nint trap_BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelflags, void /* struct bot_goal_s */ *ltg, float maxtime) {\n\treturn syscall( BOTLIB_AI_CHOOSE_NBG_ITEM, goalstate, origin, inventory, travelflags, ltg, PASSFLOAT(maxtime) );\n}\n\nint trap_BotTouchingGoal(vec3_t origin, void /* struct bot_goal_s */ *goal) {\n\treturn syscall( BOTLIB_AI_TOUCHING_GOAL, origin, goal );\n}\n\nint trap_BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, void /* struct bot_goal_s */ *goal) {\n\treturn syscall( BOTLIB_AI_ITEM_GOAL_IN_VIS_BUT_NOT_VISIBLE, viewer, eye, viewangles, goal );\n}\n\nint trap_BotGetLevelItemGoal(int index, char *classname, void /* struct bot_goal_s */ *goal) {\n\treturn syscall( BOTLIB_AI_GET_LEVEL_ITEM_GOAL, index, classname, goal );\n}\n\nint trap_BotGetNextCampSpotGoal(int num, void /* struct bot_goal_s */ *goal) {\n\treturn syscall( BOTLIB_AI_GET_NEXT_CAMP_SPOT_GOAL, num, goal );\n}\n\nint trap_BotGetMapLocationGoal(char *name, void /* struct bot_goal_s */ *goal) {\n\treturn syscall( BOTLIB_AI_GET_MAP_LOCATION_GOAL, name, goal );\n}\n\nfloat trap_BotAvoidGoalTime(int goalstate, int number) {\n\tint temp;\n\ttemp = syscall( BOTLIB_AI_AVOID_GOAL_TIME, goalstate, number );\n\treturn (*(float*)&temp);\n}\n\nvoid trap_BotSetAvoidGoalTime(int goalstate, int number, float avoidtime) {\n\tsyscall( BOTLIB_AI_SET_AVOID_GOAL_TIME, goalstate, number, PASSFLOAT(avoidtime));\n}\n\nvoid trap_BotInitLevelItems(void) {\n\tsyscall( BOTLIB_AI_INIT_LEVEL_ITEMS );\n}\n\nvoid trap_BotUpdateEntityItems(void) {\n\tsyscall( BOTLIB_AI_UPDATE_ENTITY_ITEMS );\n}\n\nint trap_BotLoadItemWeights(int goalstate, char *filename) {\n\treturn syscall( BOTLIB_AI_LOAD_ITEM_WEIGHTS, goalstate, filename );\n}\n\nvoid trap_BotFreeItemWeights(int goalstate) {\n\tsyscall( BOTLIB_AI_FREE_ITEM_WEIGHTS, goalstate );\n}\n\nvoid trap_BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child) {\n\tsyscall( BOTLIB_AI_INTERBREED_GOAL_FUZZY_LOGIC, parent1, parent2, child );\n}\n\nvoid trap_BotSaveGoalFuzzyLogic(int goalstate, char *filename) {\n\tsyscall( BOTLIB_AI_SAVE_GOAL_FUZZY_LOGIC, goalstate, filename );\n}\n\nvoid trap_BotMutateGoalFuzzyLogic(int goalstate, float range) {\n\tsyscall( BOTLIB_AI_MUTATE_GOAL_FUZZY_LOGIC, goalstate, range );\n}\n\nint trap_BotAllocGoalState(int state) {\n\treturn syscall( BOTLIB_AI_ALLOC_GOAL_STATE, state );\n}\n\nvoid trap_BotFreeGoalState(int handle) {\n\tsyscall( BOTLIB_AI_FREE_GOAL_STATE, handle );\n}\n\nvoid trap_BotResetMoveState(int movestate) {\n\tsyscall( BOTLIB_AI_RESET_MOVE_STATE, movestate );\n}\n\nvoid trap_BotAddAvoidSpot(int movestate, vec3_t origin, float radius, int type) {\n\tsyscall( BOTLIB_AI_ADD_AVOID_SPOT, movestate, origin, PASSFLOAT(radius), type);\n}\n\nvoid trap_BotMoveToGoal(void /* struct bot_moveresult_s */ *result, int movestate, void /* struct bot_goal_s */ *goal, int travelflags) {\n\tsyscall( BOTLIB_AI_MOVE_TO_GOAL, result, movestate, goal, travelflags );\n}\n\nint trap_BotMoveInDirection(int movestate, vec3_t dir, float speed, int type) {\n\treturn syscall( BOTLIB_AI_MOVE_IN_DIRECTION, movestate, dir, PASSFLOAT(speed), type );\n}\n\nvoid trap_BotResetAvoidReach(int movestate) {\n\tsyscall( BOTLIB_AI_RESET_AVOID_REACH, movestate );\n}\n\nvoid trap_BotResetLastAvoidReach(int movestate) {\n\tsyscall( BOTLIB_AI_RESET_LAST_AVOID_REACH,movestate  );\n}\n\nint trap_BotReachabilityArea(vec3_t origin, int testground) {\n\treturn syscall( BOTLIB_AI_REACHABILITY_AREA, origin, testground );\n}\n\nint trap_BotMovementViewTarget(int movestate, void /* struct bot_goal_s */ *goal, int travelflags, float lookahead, vec3_t target) {\n\treturn syscall( BOTLIB_AI_MOVEMENT_VIEW_TARGET, movestate, goal, travelflags, PASSFLOAT(lookahead), target );\n}\n\nint trap_BotPredictVisiblePosition(vec3_t origin, int areanum, void /* struct bot_goal_s */ *goal, int travelflags, vec3_t target) {\n\treturn syscall( BOTLIB_AI_PREDICT_VISIBLE_POSITION, origin, areanum, goal, travelflags, target );\n}\n\nint trap_BotAllocMoveState(void) {\n\treturn syscall( BOTLIB_AI_ALLOC_MOVE_STATE );\n}\n\nvoid trap_BotFreeMoveState(int handle) {\n\tsyscall( BOTLIB_AI_FREE_MOVE_STATE, handle );\n}\n\nvoid trap_BotInitMoveState(int handle, void /* struct bot_initmove_s */ *initmove) {\n\tsyscall( BOTLIB_AI_INIT_MOVE_STATE, handle, initmove );\n}\n\nint trap_BotChooseBestFightWeapon(int weaponstate, int *inventory) {\n\treturn syscall( BOTLIB_AI_CHOOSE_BEST_FIGHT_WEAPON, weaponstate, inventory );\n}\n\nvoid trap_BotGetWeaponInfo(int weaponstate, int weapon, void /* struct weaponinfo_s */ *weaponinfo) {\n\tsyscall( BOTLIB_AI_GET_WEAPON_INFO, weaponstate, weapon, weaponinfo );\n}\n\nint trap_BotLoadWeaponWeights(int weaponstate, char *filename) {\n\treturn syscall( BOTLIB_AI_LOAD_WEAPON_WEIGHTS, weaponstate, filename );\n}\n\nint trap_BotAllocWeaponState(void) {\n\treturn syscall( BOTLIB_AI_ALLOC_WEAPON_STATE );\n}\n\nvoid trap_BotFreeWeaponState(int weaponstate) {\n\tsyscall( BOTLIB_AI_FREE_WEAPON_STATE, weaponstate );\n}\n\nvoid trap_BotResetWeaponState(int weaponstate) {\n\tsyscall( BOTLIB_AI_RESET_WEAPON_STATE, weaponstate );\n}\n\nint trap_GeneticParentsAndChildSelection(int numranks, float *ranks, int *parent1, int *parent2, int *child) {\n\treturn syscall( BOTLIB_AI_GENETIC_PARENTS_AND_CHILD_SELECTION, numranks, ranks, parent1, parent2, child );\n}\n\nint trap_PC_LoadSource( const char *filename ) {\n\treturn syscall( BOTLIB_PC_LOAD_SOURCE, filename );\n}\n\nint trap_PC_FreeSource( int handle ) {\n\treturn syscall( BOTLIB_PC_FREE_SOURCE, handle );\n}\n\nint trap_PC_ReadToken( int handle, pc_token_t *pc_token ) {\n\treturn syscall( BOTLIB_PC_READ_TOKEN, handle, pc_token );\n}\n\nint trap_PC_SourceFileAndLine( int handle, char *filename, int *line ) {\n\treturn syscall( BOTLIB_PC_SOURCE_FILE_AND_LINE, handle, filename, line );\n}\n"
  },
  {
    "path": "code/game/g_target.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#include \"g_local.h\"\n\n//==========================================================\n\n/*QUAKED target_give (1 0 0) (-8 -8 -8) (8 8 8)\nGives the activator all the items pointed to.\n*/\nvoid Use_Target_Give( gentity_t *ent, gentity_t *other, gentity_t *activator ) {\n\tgentity_t\t*t;\n\ttrace_t\t\ttrace;\n\n\tif ( !activator->client ) {\n\t\treturn;\n\t}\n\n\tif ( !ent->target ) {\n\t\treturn;\n\t}\n\n\tmemset( &trace, 0, sizeof( trace ) );\n\tt = NULL;\n\twhile ( (t = G_Find (t, FOFS(targetname), ent->target)) != NULL ) {\n\t\tif ( !t->item ) {\n\t\t\tcontinue;\n\t\t}\n\t\tTouch_Item( t, activator, &trace );\n\n\t\t// make sure it isn't going to respawn or show any events\n\t\tt->nextthink = 0;\n\t\ttrap_UnlinkEntity( t );\n\t}\n}\n\nvoid SP_target_give( gentity_t *ent ) {\n\tent->use = Use_Target_Give;\n}\n\n\n//==========================================================\n\n/*QUAKED target_remove_powerups (1 0 0) (-8 -8 -8) (8 8 8)\ntakes away all the activators powerups.\nUsed to drop flight powerups into death puts.\n*/\nvoid Use_target_remove_powerups( gentity_t *ent, gentity_t *other, gentity_t *activator ) {\n\tif( !activator->client ) {\n\t\treturn;\n\t}\n\n\tif( activator->client->ps.powerups[PW_REDFLAG] ) {\n\t\tTeam_ReturnFlag( TEAM_RED );\n\t} else if( activator->client->ps.powerups[PW_BLUEFLAG] ) {\n\t\tTeam_ReturnFlag( TEAM_BLUE );\n\t} else if( activator->client->ps.powerups[PW_NEUTRALFLAG] ) {\n\t\tTeam_ReturnFlag( TEAM_FREE );\n\t}\n\n\tmemset( activator->client->ps.powerups, 0, sizeof( activator->client->ps.powerups ) );\n}\n\nvoid SP_target_remove_powerups( gentity_t *ent ) {\n\tent->use = Use_target_remove_powerups;\n}\n\n\n//==========================================================\n\n/*QUAKED target_delay (1 0 0) (-8 -8 -8) (8 8 8)\n\"wait\" seconds to pause before firing targets.\n\"random\" delay variance, total delay = delay +/- random seconds\n*/\nvoid Think_Target_Delay( gentity_t *ent ) {\n\tG_UseTargets( ent, ent->activator );\n}\n\nvoid Use_Target_Delay( gentity_t *ent, gentity_t *other, gentity_t *activator ) {\n\tent->nextthink = level.time + ( ent->wait + ent->random * crandom() ) * 1000;\n\tent->think = Think_Target_Delay;\n\tent->activator = activator;\n}\n\nvoid SP_target_delay( gentity_t *ent ) {\n\t// check delay for backwards compatability\n\tif ( !G_SpawnFloat( \"delay\", \"0\", &ent->wait ) ) {\n\t\tG_SpawnFloat( \"wait\", \"1\", &ent->wait );\n\t}\n\n\tif ( !ent->wait ) {\n\t\tent->wait = 1;\n\t}\n\tent->use = Use_Target_Delay;\n}\n\n\n//==========================================================\n\n/*QUAKED target_score (1 0 0) (-8 -8 -8) (8 8 8)\n\"count\" number of points to add, default 1\n\nThe activator is given this many points.\n*/\nvoid Use_Target_Score (gentity_t *ent, gentity_t *other, gentity_t *activator) {\n\tAddScore( activator, ent->r.currentOrigin, ent->count );\n}\n\nvoid SP_target_score( gentity_t *ent ) {\n\tif ( !ent->count ) {\n\t\tent->count = 1;\n\t}\n\tent->use = Use_Target_Score;\n}\n\n\n//==========================================================\n\n/*QUAKED target_print (1 0 0) (-8 -8 -8) (8 8 8) redteam blueteam private\n\"message\"\ttext to print\nIf \"private\", only the activator gets the message.  If no checks, all clients get the message.\n*/\nvoid Use_Target_Print (gentity_t *ent, gentity_t *other, gentity_t *activator) {\n\tif ( activator->client && ( ent->spawnflags & 4 ) ) {\n\t\ttrap_SendServerCommand( activator-g_entities, va(\"cp \\\"%s\\\"\", ent->message ));\n\t\treturn;\n\t}\n\n\tif ( ent->spawnflags & 3 ) {\n\t\tif ( ent->spawnflags & 1 ) {\n\t\t\tG_TeamCommand( TEAM_RED, va(\"cp \\\"%s\\\"\", ent->message) );\n\t\t}\n\t\tif ( ent->spawnflags & 2 ) {\n\t\t\tG_TeamCommand( TEAM_BLUE, va(\"cp \\\"%s\\\"\", ent->message) );\n\t\t}\n\t\treturn;\n\t}\n\n\ttrap_SendServerCommand( -1, va(\"cp \\\"%s\\\"\", ent->message ));\n}\n\nvoid SP_target_print( gentity_t *ent ) {\n\tent->use = Use_Target_Print;\n}\n\n\n//==========================================================\n\n\n/*QUAKED target_speaker (1 0 0) (-8 -8 -8) (8 8 8) looped-on looped-off global activator\n\"noise\"\t\twav file to play\n\nA global sound will play full volume throughout the level.\nActivator sounds will play on the player that activated the target.\nGlobal and activator sounds can't be combined with looping.\nNormal sounds play each time the target is used.\nLooped sounds will be toggled by use functions.\nMultiple identical looping sounds will just increase volume without any speed cost.\n\"wait\" : Seconds between auto triggerings, 0 = don't auto trigger\n\"random\"\twait variance, default is 0\n*/\nvoid Use_Target_Speaker (gentity_t *ent, gentity_t *other, gentity_t *activator) {\n\tif (ent->spawnflags & 3) {\t// looping sound toggles\n\t\tif (ent->s.loopSound)\n\t\t\tent->s.loopSound = 0;\t// turn it off\n\t\telse\n\t\t\tent->s.loopSound = ent->noise_index;\t// start it\n\t}else {\t// normal sound\n\t\tif ( ent->spawnflags & 8 ) {\n\t\t\tG_AddEvent( activator, EV_GENERAL_SOUND, ent->noise_index );\n\t\t} else if (ent->spawnflags & 4) {\n\t\t\tG_AddEvent( ent, EV_GLOBAL_SOUND, ent->noise_index );\n\t\t} else {\n\t\t\tG_AddEvent( ent, EV_GENERAL_SOUND, ent->noise_index );\n\t\t}\n\t}\n}\n\nvoid SP_target_speaker( gentity_t *ent ) {\n\tchar\tbuffer[MAX_QPATH];\n\tchar\t*s;\n\n\tG_SpawnFloat( \"wait\", \"0\", &ent->wait );\n\tG_SpawnFloat( \"random\", \"0\", &ent->random );\n\n\tif ( !G_SpawnString( \"noise\", \"NOSOUND\", &s ) ) {\n\t\tG_Error( \"target_speaker without a noise key at %s\", vtos( ent->s.origin ) );\n\t}\n\n\t// force all client reletive sounds to be \"activator\" speakers that\n\t// play on the entity that activates it\n\tif ( s[0] == '*' ) {\n\t\tent->spawnflags |= 8;\n\t}\n\n\tif (!strstr( s, \".wav\" )) {\n\t\tCom_sprintf (buffer, sizeof(buffer), \"%s.wav\", s );\n\t} else {\n\t\tQ_strncpyz( buffer, s, sizeof(buffer) );\n\t}\n\tent->noise_index = G_SoundIndex(buffer);\n\n\t// a repeating speaker can be done completely client side\n\tent->s.eType = ET_SPEAKER;\n\tent->s.eventParm = ent->noise_index;\n\tent->s.frame = ent->wait * 10;\n\tent->s.clientNum = ent->random * 10;\n\n\n\t// check for prestarted looping sound\n\tif ( ent->spawnflags & 1 ) {\n\t\tent->s.loopSound = ent->noise_index;\n\t}\n\n\tent->use = Use_Target_Speaker;\n\n\tif (ent->spawnflags & 4) {\n\t\tent->r.svFlags |= SVF_BROADCAST;\n\t}\n\n\tVectorCopy( ent->s.origin, ent->s.pos.trBase );\n\n\t// must link the entity so we get areas and clusters so\n\t// the server can determine who to send updates to\n\ttrap_LinkEntity( ent );\n}\n\n\n\n//==========================================================\n\n/*QUAKED target_laser (0 .5 .8) (-8 -8 -8) (8 8 8) START_ON\nWhen triggered, fires a laser.  You can either set a target or a direction.\n*/\nvoid target_laser_think (gentity_t *self) {\n\tvec3_t\tend;\n\ttrace_t\ttr;\n\tvec3_t\tpoint;\n\n\t// if pointed at another entity, set movedir to point at it\n\tif ( self->enemy ) {\n\t\tVectorMA (self->enemy->s.origin, 0.5, self->enemy->r.mins, point);\n\t\tVectorMA (point, 0.5, self->enemy->r.maxs, point);\n\t\tVectorSubtract (point, self->s.origin, self->movedir);\n\t\tVectorNormalize (self->movedir);\n\t}\n\n\t// fire forward and see what we hit\n\tVectorMA (self->s.origin, 2048, self->movedir, end);\n\n\ttrap_Trace( &tr, self->s.origin, NULL, NULL, end, self->s.number, CONTENTS_SOLID|CONTENTS_BODY|CONTENTS_CORPSE);\n\n\tif ( tr.entityNum ) {\n\t\t// hurt it if we can\n\t\tG_Damage ( &g_entities[tr.entityNum], self, self->activator, self->movedir, \n\t\t\ttr.endpos, self->damage, DAMAGE_NO_KNOCKBACK, MOD_TARGET_LASER);\n\t}\n\n\tVectorCopy (tr.endpos, self->s.origin2);\n\n\ttrap_LinkEntity( self );\n\tself->nextthink = level.time + FRAMETIME;\n}\n\nvoid target_laser_on (gentity_t *self)\n{\n\tif (!self->activator)\n\t\tself->activator = self;\n\ttarget_laser_think (self);\n}\n\nvoid target_laser_off (gentity_t *self)\n{\n\ttrap_UnlinkEntity( self );\n\tself->nextthink = 0;\n}\n\nvoid target_laser_use (gentity_t *self, gentity_t *other, gentity_t *activator)\n{\n\tself->activator = activator;\n\tif ( self->nextthink > 0 )\n\t\ttarget_laser_off (self);\n\telse\n\t\ttarget_laser_on (self);\n}\n\nvoid target_laser_start (gentity_t *self)\n{\n\tgentity_t *ent;\n\n\tself->s.eType = ET_BEAM;\n\n\tif (self->target) {\n\t\tent = G_Find (NULL, FOFS(targetname), self->target);\n\t\tif (!ent) {\n\t\t\tG_Printf (\"%s at %s: %s is a bad target\\n\", self->classname, vtos(self->s.origin), self->target);\n\t\t}\n\t\tself->enemy = ent;\n\t} else {\n\t\tG_SetMovedir (self->s.angles, self->movedir);\n\t}\n\n\tself->use = target_laser_use;\n\tself->think = target_laser_think;\n\n\tif ( !self->damage ) {\n\t\tself->damage = 1;\n\t}\n\n\tif (self->spawnflags & 1)\n\t\ttarget_laser_on (self);\n\telse\n\t\ttarget_laser_off (self);\n}\n\nvoid SP_target_laser (gentity_t *self)\n{\n\t// let everything else get spawned before we start firing\n\tself->think = target_laser_start;\n\tself->nextthink = level.time + FRAMETIME;\n}\n\n\n//==========================================================\n\nvoid target_teleporter_use( gentity_t *self, gentity_t *other, gentity_t *activator ) {\n\tgentity_t\t*dest;\n\n\tif (!activator->client)\n\t\treturn;\n\tdest = \tG_PickTarget( self->target );\n\tif (!dest) {\n\t\tG_Printf (\"Couldn't find teleporter destination\\n\");\n\t\treturn;\n\t}\n\n\tTeleportPlayer( activator, dest->s.origin, dest->s.angles );\n}\n\n/*QUAKED target_teleporter (1 0 0) (-8 -8 -8) (8 8 8)\nThe activator will be teleported away.\n*/\nvoid SP_target_teleporter( gentity_t *self ) {\n\tif (!self->targetname)\n\t\tG_Printf(\"untargeted %s at %s\\n\", self->classname, vtos(self->s.origin));\n\n\tself->use = target_teleporter_use;\n}\n\n//==========================================================\n\n\n/*QUAKED target_relay (.5 .5 .5) (-8 -8 -8) (8 8 8) RED_ONLY BLUE_ONLY RANDOM\nThis doesn't perform any actions except fire its targets.\nThe activator can be forced to be from a certain team.\nif RANDOM is checked, only one of the targets will be fired, not all of them\n*/\nvoid target_relay_use (gentity_t *self, gentity_t *other, gentity_t *activator) {\n\tif ( ( self->spawnflags & 1 ) && activator->client \n\t\t&& activator->client->sess.sessionTeam != TEAM_RED ) {\n\t\treturn;\n\t}\n\tif ( ( self->spawnflags & 2 ) && activator->client \n\t\t&& activator->client->sess.sessionTeam != TEAM_BLUE ) {\n\t\treturn;\n\t}\n\tif ( self->spawnflags & 4 ) {\n\t\tgentity_t\t*ent;\n\n\t\tent = G_PickTarget( self->target );\n\t\tif ( ent && ent->use ) {\n\t\t\tent->use( ent, self, activator );\n\t\t}\n\t\treturn;\n\t}\n\tG_UseTargets (self, activator);\n}\n\nvoid SP_target_relay (gentity_t *self) {\n\tself->use = target_relay_use;\n}\n\n\n//==========================================================\n\n/*QUAKED target_kill (.5 .5 .5) (-8 -8 -8) (8 8 8)\nKills the activator.\n*/\nvoid target_kill_use( gentity_t *self, gentity_t *other, gentity_t *activator ) {\n\tG_Damage ( activator, NULL, NULL, NULL, NULL, 100000, DAMAGE_NO_PROTECTION, MOD_TELEFRAG);\n}\n\nvoid SP_target_kill( gentity_t *self ) {\n\tself->use = target_kill_use;\n}\n\n/*QUAKED target_position (0 0.5 0) (-4 -4 -4) (4 4 4)\nUsed as a positional target for in-game calculation, like jumppad targets.\n*/\nvoid SP_target_position( gentity_t *self ){\n\tG_SetOrigin( self, self->s.origin );\n}\n\nstatic void target_location_linkup(gentity_t *ent)\n{\n\tint i;\n\tint n;\n\n\tif (level.locationLinked) \n\t\treturn;\n\n\tlevel.locationLinked = qtrue;\n\n\tlevel.locationHead = NULL;\n\n\ttrap_SetConfigstring( CS_LOCATIONS, \"unknown\" );\n\n\tfor (i = 0, ent = g_entities, n = 1;\n\t\t\ti < level.num_entities;\n\t\t\ti++, ent++) {\n\t\tif (ent->classname && !Q_stricmp(ent->classname, \"target_location\")) {\n\t\t\t// lets overload some variables!\n\t\t\tent->health = n; // use for location marking\n\t\t\ttrap_SetConfigstring( CS_LOCATIONS + n, ent->message );\n\t\t\tn++;\n\t\t\tent->nextTrain = level.locationHead;\n\t\t\tlevel.locationHead = ent;\n\t\t}\n\t}\n\n\t// All linked together now\n}\n\n/*QUAKED target_location (0 0.5 0) (-8 -8 -8) (8 8 8)\nSet \"message\" to the name of this location.\nSet \"count\" to 0-7 for color.\n0:white 1:red 2:green 3:yellow 4:blue 5:cyan 6:magenta 7:white\n\nClosest target_location in sight used for the location, if none\nin site, closest in distance\n*/\nvoid SP_target_location( gentity_t *self ){\n\tself->think = target_location_linkup;\n\tself->nextthink = level.time + 200;  // Let them all spawn first\n\n\tG_SetOrigin( self, self->s.origin );\n}\n\n"
  },
  {
    "path": "code/game/g_team.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n#include \"g_local.h\"\n\n\ntypedef struct teamgame_s {\n\tfloat\t\t\tlast_flag_capture;\n\tint\t\t\t\tlast_capture_team;\n\tflagStatus_t\tredStatus;\t// CTF\n\tflagStatus_t\tblueStatus;\t// CTF\n\tflagStatus_t\tflagStatus;\t// One Flag CTF\n\tint\t\t\t\tredTakenTime;\n\tint\t\t\t\tblueTakenTime;\n\tint\t\t\t\tredObeliskAttackedTime;\n\tint\t\t\t\tblueObeliskAttackedTime;\n} teamgame_t;\n\nteamgame_t teamgame;\n\ngentity_t\t*neutralObelisk;\n\nvoid Team_SetFlagStatus( int team, flagStatus_t status );\n\nvoid Team_InitGame( void ) {\n\tmemset(&teamgame, 0, sizeof teamgame);\n\n\tswitch( g_gametype.integer ) {\n\tcase GT_CTF:\n\t\tteamgame.redStatus = teamgame.blueStatus = -1; // Invalid to force update\n\t\tTeam_SetFlagStatus( TEAM_RED, FLAG_ATBASE );\n\t\tTeam_SetFlagStatus( TEAM_BLUE, FLAG_ATBASE );\n\t\tbreak;\n#ifdef MISSIONPACK\n\tcase GT_1FCTF:\n\t\tteamgame.flagStatus = -1; // Invalid to force update\n\t\tTeam_SetFlagStatus( TEAM_FREE, FLAG_ATBASE );\n\t\tbreak;\n#endif\n\tdefault:\n\t\tbreak;\n\t}\n}\n\nint OtherTeam(int team) {\n\tif (team==TEAM_RED)\n\t\treturn TEAM_BLUE;\n\telse if (team==TEAM_BLUE)\n\t\treturn TEAM_RED;\n\treturn team;\n}\n\nconst char *TeamName(int team)  {\n\tif (team==TEAM_RED)\n\t\treturn \"RED\";\n\telse if (team==TEAM_BLUE)\n\t\treturn \"BLUE\";\n\telse if (team==TEAM_SPECTATOR)\n\t\treturn \"SPECTATOR\";\n\treturn \"FREE\";\n}\n\nconst char *OtherTeamName(int team) {\n\tif (team==TEAM_RED)\n\t\treturn \"BLUE\";\n\telse if (team==TEAM_BLUE)\n\t\treturn \"RED\";\n\telse if (team==TEAM_SPECTATOR)\n\t\treturn \"SPECTATOR\";\n\treturn \"FREE\";\n}\n\nconst char *TeamColorString(int team) {\n\tif (team==TEAM_RED)\n\t\treturn S_COLOR_RED;\n\telse if (team==TEAM_BLUE)\n\t\treturn S_COLOR_BLUE;\n\telse if (team==TEAM_SPECTATOR)\n\t\treturn S_COLOR_YELLOW;\n\treturn S_COLOR_WHITE;\n}\n\n// NULL for everyone\nvoid QDECL PrintMsg( gentity_t *ent, const char *fmt, ... ) {\n\tchar\t\tmsg[1024];\n\tva_list\t\targptr;\n\tchar\t\t*p;\n\t\n\tva_start (argptr,fmt);\n\tif (vsprintf (msg, fmt, argptr) > sizeof(msg)) {\n\t\tG_Error ( \"PrintMsg overrun\" );\n\t}\n\tva_end (argptr);\n\n\t// double quotes are bad\n\twhile ((p = strchr(msg, '\"')) != NULL)\n\t\t*p = '\\'';\n\n\ttrap_SendServerCommand ( ( (ent == NULL) ? -1 : ent-g_entities ), va(\"print \\\"%s\\\"\", msg ));\n}\n\n/*\n==============\nAddTeamScore\n\n used for gametype > GT_TEAM\n for gametype GT_TEAM the level.teamScores is updated in AddScore in g_combat.c\n==============\n*/\nvoid AddTeamScore(vec3_t origin, int team, int score) {\n\tgentity_t\t*te;\n\n\tte = G_TempEntity(origin, EV_GLOBAL_TEAM_SOUND );\n\tte->r.svFlags |= SVF_BROADCAST;\n\n\tif ( team == TEAM_RED ) {\n\t\tif ( level.teamScores[ TEAM_RED ] + score == level.teamScores[ TEAM_BLUE ] ) {\n\t\t\t//teams are tied sound\n\t\t\tte->s.eventParm = GTS_TEAMS_ARE_TIED;\n\t\t}\n\t\telse if ( level.teamScores[ TEAM_RED ] <= level.teamScores[ TEAM_BLUE ] &&\n\t\t\t\t\tlevel.teamScores[ TEAM_RED ] + score > level.teamScores[ TEAM_BLUE ]) {\n\t\t\t// red took the lead sound\n\t\t\tte->s.eventParm = GTS_REDTEAM_TOOK_LEAD;\n\t\t}\n\t\telse {\n\t\t\t// red scored sound\n\t\t\tte->s.eventParm = GTS_REDTEAM_SCORED;\n\t\t}\n\t}\n\telse {\n\t\tif ( level.teamScores[ TEAM_BLUE ] + score == level.teamScores[ TEAM_RED ] ) {\n\t\t\t//teams are tied sound\n\t\t\tte->s.eventParm = GTS_TEAMS_ARE_TIED;\n\t\t}\n\t\telse if ( level.teamScores[ TEAM_BLUE ] <= level.teamScores[ TEAM_RED ] &&\n\t\t\t\t\tlevel.teamScores[ TEAM_BLUE ] + score > level.teamScores[ TEAM_RED ]) {\n\t\t\t// blue took the lead sound\n\t\t\tte->s.eventParm = GTS_BLUETEAM_TOOK_LEAD;\n\t\t}\n\t\telse {\n\t\t\t// blue scored sound\n\t\t\tte->s.eventParm = GTS_BLUETEAM_SCORED;\n\t\t}\n\t}\n\tlevel.teamScores[ team ] += score;\n}\n\n/*\n==============\nOnSameTeam\n==============\n*/\nqboolean OnSameTeam( gentity_t *ent1, gentity_t *ent2 ) {\n\tif ( !ent1->client || !ent2->client ) {\n\t\treturn qfalse;\n\t}\n\n\tif ( g_gametype.integer < GT_TEAM ) {\n\t\treturn qfalse;\n\t}\n\n\tif ( ent1->client->sess.sessionTeam == ent2->client->sess.sessionTeam ) {\n\t\treturn qtrue;\n\t}\n\n\treturn qfalse;\n}\n\n\nstatic char ctfFlagStatusRemap[] = { '0', '1', '*', '*', '2' };\nstatic char oneFlagStatusRemap[] = { '0', '1', '2', '3', '4' };\n\nvoid Team_SetFlagStatus( int team, flagStatus_t status ) {\n\tqboolean modified = qfalse;\n\n\tswitch( team ) {\n\tcase TEAM_RED:\t// CTF\n\t\tif( teamgame.redStatus != status ) {\n\t\t\tteamgame.redStatus = status;\n\t\t\tmodified = qtrue;\n\t\t}\n\t\tbreak;\n\n\tcase TEAM_BLUE:\t// CTF\n\t\tif( teamgame.blueStatus != status ) {\n\t\t\tteamgame.blueStatus = status;\n\t\t\tmodified = qtrue;\n\t\t}\n\t\tbreak;\n\n\tcase TEAM_FREE:\t// One Flag CTF\n\t\tif( teamgame.flagStatus != status ) {\n\t\t\tteamgame.flagStatus = status;\n\t\t\tmodified = qtrue;\n\t\t}\n\t\tbreak;\n\t}\n\n\tif( modified ) {\n\t\tchar st[4];\n\n\t\tif( g_gametype.integer == GT_CTF ) {\n\t\t\tst[0] = ctfFlagStatusRemap[teamgame.redStatus];\n\t\t\tst[1] = ctfFlagStatusRemap[teamgame.blueStatus];\n\t\t\tst[2] = 0;\n\t\t}\n\t\telse {\t\t// GT_1FCTF\n\t\t\tst[0] = oneFlagStatusRemap[teamgame.flagStatus];\n\t\t\tst[1] = 0;\n\t\t}\n\n\t\ttrap_SetConfigstring( CS_FLAGSTATUS, st );\n\t}\n}\n\nvoid Team_CheckDroppedItem( gentity_t *dropped ) {\n\tif( dropped->item->giTag == PW_REDFLAG ) {\n\t\tTeam_SetFlagStatus( TEAM_RED, FLAG_DROPPED );\n\t}\n\telse if( dropped->item->giTag == PW_BLUEFLAG ) {\n\t\tTeam_SetFlagStatus( TEAM_BLUE, FLAG_DROPPED );\n\t}\n\telse if( dropped->item->giTag == PW_NEUTRALFLAG ) {\n\t\tTeam_SetFlagStatus( TEAM_FREE, FLAG_DROPPED );\n\t}\n}\n\n/*\n================\nTeam_ForceGesture\n================\n*/\nvoid Team_ForceGesture(int team) {\n\tint i;\n\tgentity_t *ent;\n\n\tfor (i = 0; i < MAX_CLIENTS; i++) {\n\t\tent = &g_entities[i];\n\t\tif (!ent->inuse)\n\t\t\tcontinue;\n\t\tif (!ent->client)\n\t\t\tcontinue;\n\t\tif (ent->client->sess.sessionTeam != team)\n\t\t\tcontinue;\n\t\t//\n\t\tent->flags |= FL_FORCE_GESTURE;\n\t}\n}\n\n/*\n================\nTeam_FragBonuses\n\nCalculate the bonuses for flag defense, flag carrier defense, etc.\nNote that bonuses are not cumulative.  You get one, they are in importance\norder.\n================\n*/\nvoid Team_FragBonuses(gentity_t *targ, gentity_t *inflictor, gentity_t *attacker)\n{\n\tint i;\n\tgentity_t *ent;\n\tint flag_pw, enemy_flag_pw;\n\tint otherteam;\n\tint tokens;\n\tgentity_t *flag, *carrier = NULL;\n\tchar *c;\n\tvec3_t v1, v2;\n\tint team;\n\n\t// no bonus for fragging yourself or team mates\n\tif (!targ->client || !attacker->client || targ == attacker || OnSameTeam(targ, attacker))\n\t\treturn;\n\n\tteam = targ->client->sess.sessionTeam;\n\totherteam = OtherTeam(targ->client->sess.sessionTeam);\n\tif (otherteam < 0)\n\t\treturn; // whoever died isn't on a team\n\n\t// same team, if the flag at base, check to he has the enemy flag\n\tif (team == TEAM_RED) {\n\t\tflag_pw = PW_REDFLAG;\n\t\tenemy_flag_pw = PW_BLUEFLAG;\n\t} else {\n\t\tflag_pw = PW_BLUEFLAG;\n\t\tenemy_flag_pw = PW_REDFLAG;\n\t}\n\n\tif (g_gametype.integer == GT_1FCTF) {\n\t\tenemy_flag_pw = PW_NEUTRALFLAG;\n\t} \n\n\t// did the attacker frag the flag carrier?\n\ttokens = 0;\n#ifdef MISSIONPACK\n\tif( g_gametype.integer == GT_HARVESTER ) {\n\t\ttokens = targ->client->ps.generic1;\n\t}\n#endif\n\tif (targ->client->ps.powerups[enemy_flag_pw]) {\n\t\tattacker->client->pers.teamState.lastfraggedcarrier = level.time;\n\t\tAddScore(attacker, targ->r.currentOrigin, CTF_FRAG_CARRIER_BONUS);\n\t\tattacker->client->pers.teamState.fragcarrier++;\n\t\tPrintMsg(NULL, \"%s\" S_COLOR_WHITE \" fragged %s's flag carrier!\\n\",\n\t\t\tattacker->client->pers.netname, TeamName(team));\n\n\t\t// the target had the flag, clear the hurt carrier\n\t\t// field on the other team\n\t\tfor (i = 0; i < g_maxclients.integer; i++) {\n\t\t\tent = g_entities + i;\n\t\t\tif (ent->inuse && ent->client->sess.sessionTeam == otherteam)\n\t\t\t\tent->client->pers.teamState.lasthurtcarrier = 0;\n\t\t}\n\t\treturn;\n\t}\n\n\t// did the attacker frag a head carrier? other->client->ps.generic1\n\tif (tokens) {\n\t\tattacker->client->pers.teamState.lastfraggedcarrier = level.time;\n\t\tAddScore(attacker, targ->r.currentOrigin, CTF_FRAG_CARRIER_BONUS * tokens * tokens);\n\t\tattacker->client->pers.teamState.fragcarrier++;\n\t\tPrintMsg(NULL, \"%s\" S_COLOR_WHITE \" fragged %s's skull carrier!\\n\",\n\t\t\tattacker->client->pers.netname, TeamName(team));\n\n\t\t// the target had the flag, clear the hurt carrier\n\t\t// field on the other team\n\t\tfor (i = 0; i < g_maxclients.integer; i++) {\n\t\t\tent = g_entities + i;\n\t\t\tif (ent->inuse && ent->client->sess.sessionTeam == otherteam)\n\t\t\t\tent->client->pers.teamState.lasthurtcarrier = 0;\n\t\t}\n\t\treturn;\n\t}\n\n\tif (targ->client->pers.teamState.lasthurtcarrier &&\n\t\tlevel.time - targ->client->pers.teamState.lasthurtcarrier < CTF_CARRIER_DANGER_PROTECT_TIMEOUT &&\n\t\t!attacker->client->ps.powerups[flag_pw]) {\n\t\t// attacker is on the same team as the flag carrier and\n\t\t// fragged a guy who hurt our flag carrier\n\t\tAddScore(attacker, targ->r.currentOrigin, CTF_CARRIER_DANGER_PROTECT_BONUS);\n\n\t\tattacker->client->pers.teamState.carrierdefense++;\n\t\ttarg->client->pers.teamState.lasthurtcarrier = 0;\n\n\t\tattacker->client->ps.persistant[PERS_DEFEND_COUNT]++;\n\t\tteam = attacker->client->sess.sessionTeam;\n\t\t// add the sprite over the player's head\n\t\tattacker->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );\n\t\tattacker->client->ps.eFlags |= EF_AWARD_DEFEND;\n\t\tattacker->client->rewardTime = level.time + REWARD_SPRITE_TIME;\n\n\t\treturn;\n\t}\n\n\tif (targ->client->pers.teamState.lasthurtcarrier &&\n\t\tlevel.time - targ->client->pers.teamState.lasthurtcarrier < CTF_CARRIER_DANGER_PROTECT_TIMEOUT) {\n\t\t// attacker is on the same team as the skull carrier and\n\t\tAddScore(attacker, targ->r.currentOrigin, CTF_CARRIER_DANGER_PROTECT_BONUS);\n\n\t\tattacker->client->pers.teamState.carrierdefense++;\n\t\ttarg->client->pers.teamState.lasthurtcarrier = 0;\n\n\t\tattacker->client->ps.persistant[PERS_DEFEND_COUNT]++;\n\t\tteam = attacker->client->sess.sessionTeam;\n\t\t// add the sprite over the player's head\n\t\tattacker->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );\n\t\tattacker->client->ps.eFlags |= EF_AWARD_DEFEND;\n\t\tattacker->client->rewardTime = level.time + REWARD_SPRITE_TIME;\n\n\t\treturn;\n\t}\n\n\t// flag and flag carrier area defense bonuses\n\n\t// we have to find the flag and carrier entities\n\n#ifdef MISSIONPACK\t\n\tif( g_gametype.integer == GT_OBELISK ) {\n\t\t// find the team obelisk\n\t\tswitch (attacker->client->sess.sessionTeam) {\n\t\tcase TEAM_RED:\n\t\t\tc = \"team_redobelisk\";\n\t\t\tbreak;\n\t\tcase TEAM_BLUE:\n\t\t\tc = \"team_blueobelisk\";\n\t\t\tbreak;\t\t\n\t\tdefault:\n\t\t\treturn;\n\t\t}\n\t\t\n\t} else if (g_gametype.integer == GT_HARVESTER ) {\n\t\t// find the center obelisk\n\t\tc = \"team_neutralobelisk\";\n\t} else {\n#endif\n\t// find the flag\n\tswitch (attacker->client->sess.sessionTeam) {\n\tcase TEAM_RED:\n\t\tc = \"team_CTF_redflag\";\n\t\tbreak;\n\tcase TEAM_BLUE:\n\t\tc = \"team_CTF_blueflag\";\n\t\tbreak;\t\t\n\tdefault:\n\t\treturn;\n\t}\n\t// find attacker's team's flag carrier\n\tfor (i = 0; i < g_maxclients.integer; i++) {\n\t\tcarrier = g_entities + i;\n\t\tif (carrier->inuse && carrier->client->ps.powerups[flag_pw])\n\t\t\tbreak;\n\t\tcarrier = NULL;\n\t}\n#ifdef MISSIONPACK\n\t}\n#endif\n\tflag = NULL;\n\twhile ((flag = G_Find (flag, FOFS(classname), c)) != NULL) {\n\t\tif (!(flag->flags & FL_DROPPED_ITEM))\n\t\t\tbreak;\n\t}\n\n\tif (!flag)\n\t\treturn; // can't find attacker's flag\n\n\t// ok we have the attackers flag and a pointer to the carrier\n\n\t// check to see if we are defending the base's flag\n\tVectorSubtract(targ->r.currentOrigin, flag->r.currentOrigin, v1);\n\tVectorSubtract(attacker->r.currentOrigin, flag->r.currentOrigin, v2);\n\n\tif ( ( ( VectorLength(v1) < CTF_TARGET_PROTECT_RADIUS &&\n\t\ttrap_InPVS(flag->r.currentOrigin, targ->r.currentOrigin ) ) ||\n\t\t( VectorLength(v2) < CTF_TARGET_PROTECT_RADIUS &&\n\t\ttrap_InPVS(flag->r.currentOrigin, attacker->r.currentOrigin ) ) ) &&\n\t\tattacker->client->sess.sessionTeam != targ->client->sess.sessionTeam) {\n\n\t\t// we defended the base flag\n\t\tAddScore(attacker, targ->r.currentOrigin, CTF_FLAG_DEFENSE_BONUS);\n\t\tattacker->client->pers.teamState.basedefense++;\n\n\t\tattacker->client->ps.persistant[PERS_DEFEND_COUNT]++;\n\t\t// add the sprite over the player's head\n\t\tattacker->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );\n\t\tattacker->client->ps.eFlags |= EF_AWARD_DEFEND;\n\t\tattacker->client->rewardTime = level.time + REWARD_SPRITE_TIME;\n\n\t\treturn;\n\t}\n\n\tif (carrier && carrier != attacker) {\n\t\tVectorSubtract(targ->r.currentOrigin, carrier->r.currentOrigin, v1);\n\t\tVectorSubtract(attacker->r.currentOrigin, carrier->r.currentOrigin, v1);\n\n\t\tif ( ( ( VectorLength(v1) < CTF_ATTACKER_PROTECT_RADIUS &&\n\t\t\ttrap_InPVS(carrier->r.currentOrigin, targ->r.currentOrigin ) ) ||\n\t\t\t( VectorLength(v2) < CTF_ATTACKER_PROTECT_RADIUS &&\n\t\t\t\ttrap_InPVS(carrier->r.currentOrigin, attacker->r.currentOrigin ) ) ) &&\n\t\t\tattacker->client->sess.sessionTeam != targ->client->sess.sessionTeam) {\n\t\t\tAddScore(attacker, targ->r.currentOrigin, CTF_CARRIER_PROTECT_BONUS);\n\t\t\tattacker->client->pers.teamState.carrierdefense++;\n\n\t\t\tattacker->client->ps.persistant[PERS_DEFEND_COUNT]++;\n\t\t\t// add the sprite over the player's head\n\t\t\tattacker->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );\n\t\t\tattacker->client->ps.eFlags |= EF_AWARD_DEFEND;\n\t\t\tattacker->client->rewardTime = level.time + REWARD_SPRITE_TIME;\n\n\t\t\treturn;\n\t\t}\n\t}\n}\n\n/*\n================\nTeam_CheckHurtCarrier\n\nCheck to see if attacker hurt the flag carrier.  Needed when handing out bonuses for assistance to flag\ncarrier defense.\n================\n*/\nvoid Team_CheckHurtCarrier(gentity_t *targ, gentity_t *attacker)\n{\n\tint flag_pw;\n\n\tif (!targ->client || !attacker->client)\n\t\treturn;\n\n\tif (targ->client->sess.sessionTeam == TEAM_RED)\n\t\tflag_pw = PW_BLUEFLAG;\n\telse\n\t\tflag_pw = PW_REDFLAG;\n\n\t// flags\n\tif (targ->client->ps.powerups[flag_pw] &&\n\t\ttarg->client->sess.sessionTeam != attacker->client->sess.sessionTeam)\n\t\tattacker->client->pers.teamState.lasthurtcarrier = level.time;\n\n\t// skulls\n\tif (targ->client->ps.generic1 &&\n\t\ttarg->client->sess.sessionTeam != attacker->client->sess.sessionTeam)\n\t\tattacker->client->pers.teamState.lasthurtcarrier = level.time;\n}\n\n\ngentity_t *Team_ResetFlag( int team ) {\n\tchar *c;\n\tgentity_t *ent, *rent = NULL;\n\n\tswitch (team) {\n\tcase TEAM_RED:\n\t\tc = \"team_CTF_redflag\";\n\t\tbreak;\n\tcase TEAM_BLUE:\n\t\tc = \"team_CTF_blueflag\";\n\t\tbreak;\n\tcase TEAM_FREE:\n\t\tc = \"team_CTF_neutralflag\";\n\t\tbreak;\n\tdefault:\n\t\treturn NULL;\n\t}\n\n\tent = NULL;\n\twhile ((ent = G_Find (ent, FOFS(classname), c)) != NULL) {\n\t\tif (ent->flags & FL_DROPPED_ITEM)\n\t\t\tG_FreeEntity(ent);\n\t\telse {\n\t\t\trent = ent;\n\t\t\tRespawnItem(ent);\n\t\t}\n\t}\n\n\tTeam_SetFlagStatus( team, FLAG_ATBASE );\n\n\treturn rent;\n}\n\nvoid Team_ResetFlags( void ) {\n\tif( g_gametype.integer == GT_CTF ) {\n\t\tTeam_ResetFlag( TEAM_RED );\n\t\tTeam_ResetFlag( TEAM_BLUE );\n\t}\n#ifdef MISSIONPACK\n\telse if( g_gametype.integer == GT_1FCTF ) {\n\t\tTeam_ResetFlag( TEAM_FREE );\n\t}\n#endif\n}\n\nvoid Team_ReturnFlagSound( gentity_t *ent, int team ) {\n\tgentity_t\t*te;\n\n\tif (ent == NULL) {\n\t\tG_Printf (\"Warning:  NULL passed to Team_ReturnFlagSound\\n\");\n\t\treturn;\n\t}\n\n\tte = G_TempEntity( ent->s.pos.trBase, EV_GLOBAL_TEAM_SOUND );\n\tif( team == TEAM_BLUE ) {\n\t\tte->s.eventParm = GTS_RED_RETURN;\n\t}\n\telse {\n\t\tte->s.eventParm = GTS_BLUE_RETURN;\n\t}\n\tte->r.svFlags |= SVF_BROADCAST;\n}\n\nvoid Team_TakeFlagSound( gentity_t *ent, int team ) {\n\tgentity_t\t*te;\n\n\tif (ent == NULL) {\n\t\tG_Printf (\"Warning:  NULL passed to Team_TakeFlagSound\\n\");\n\t\treturn;\n\t}\n\n\t// only play sound when the flag was at the base\n\t// or not picked up the last 10 seconds\n\tswitch(team) {\n\t\tcase TEAM_RED:\n\t\t\tif( teamgame.blueStatus != FLAG_ATBASE ) {\n\t\t\t\tif (teamgame.blueTakenTime > level.time - 10000)\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t\tteamgame.blueTakenTime = level.time;\n\t\t\tbreak;\n\n\t\tcase TEAM_BLUE:\t// CTF\n\t\t\tif( teamgame.redStatus != FLAG_ATBASE ) {\n\t\t\t\tif (teamgame.redTakenTime > level.time - 10000)\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t\tteamgame.redTakenTime = level.time;\n\t\t\tbreak;\n\t}\n\n\tte = G_TempEntity( ent->s.pos.trBase, EV_GLOBAL_TEAM_SOUND );\n\tif( team == TEAM_BLUE ) {\n\t\tte->s.eventParm = GTS_RED_TAKEN;\n\t}\n\telse {\n\t\tte->s.eventParm = GTS_BLUE_TAKEN;\n\t}\n\tte->r.svFlags |= SVF_BROADCAST;\n}\n\nvoid Team_CaptureFlagSound( gentity_t *ent, int team ) {\n\tgentity_t\t*te;\n\n\tif (ent == NULL) {\n\t\tG_Printf (\"Warning:  NULL passed to Team_CaptureFlagSound\\n\");\n\t\treturn;\n\t}\n\n\tte = G_TempEntity( ent->s.pos.trBase, EV_GLOBAL_TEAM_SOUND );\n\tif( team == TEAM_BLUE ) {\n\t\tte->s.eventParm = GTS_BLUE_CAPTURE;\n\t}\n\telse {\n\t\tte->s.eventParm = GTS_RED_CAPTURE;\n\t}\n\tte->r.svFlags |= SVF_BROADCAST;\n}\n\nvoid Team_ReturnFlag( int team ) {\n\tTeam_ReturnFlagSound(Team_ResetFlag(team), team);\n\tif( team == TEAM_FREE ) {\n\t\tPrintMsg(NULL, \"The flag has returned!\\n\" );\n\t}\n\telse {\n\t\tPrintMsg(NULL, \"The %s flag has returned!\\n\", TeamName(team));\n\t}\n}\n\nvoid Team_FreeEntity( gentity_t *ent ) {\n\tif( ent->item->giTag == PW_REDFLAG ) {\n\t\tTeam_ReturnFlag( TEAM_RED );\n\t}\n\telse if( ent->item->giTag == PW_BLUEFLAG ) {\n\t\tTeam_ReturnFlag( TEAM_BLUE );\n\t}\n\telse if( ent->item->giTag == PW_NEUTRALFLAG ) {\n\t\tTeam_ReturnFlag( TEAM_FREE );\n\t}\n}\n\n/*\n==============\nTeam_DroppedFlagThink\n\nAutomatically set in Launch_Item if the item is one of the flags\n\nFlags are unique in that if they are dropped, the base flag must be respawned when they time out\n==============\n*/\nvoid Team_DroppedFlagThink(gentity_t *ent) {\n\tint\t\tteam = TEAM_FREE;\n\n\tif( ent->item->giTag == PW_REDFLAG ) {\n\t\tteam = TEAM_RED;\n\t}\n\telse if( ent->item->giTag == PW_BLUEFLAG ) {\n\t\tteam = TEAM_BLUE;\n\t}\n\telse if( ent->item->giTag == PW_NEUTRALFLAG ) {\n\t\tteam = TEAM_FREE;\n\t}\n\n\tTeam_ReturnFlagSound( Team_ResetFlag( team ), team );\n\t// Reset Flag will delete this entity\n}\n\n\n/*\n==============\nTeam_DroppedFlagThink\n==============\n*/\nint Team_TouchOurFlag( gentity_t *ent, gentity_t *other, int team ) {\n\tint\t\t\ti;\n\tgentity_t\t*player;\n\tgclient_t\t*cl = other->client;\n\tint\t\t\tenemy_flag;\n\n#ifdef MISSIONPACK\n\tif( g_gametype.integer == GT_1FCTF ) {\n\t\tenemy_flag = PW_NEUTRALFLAG;\n\t}\n\telse {\n#endif\n\tif (cl->sess.sessionTeam == TEAM_RED) {\n\t\tenemy_flag = PW_BLUEFLAG;\n\t} else {\n\t\tenemy_flag = PW_REDFLAG;\n\t}\n\n\tif ( ent->flags & FL_DROPPED_ITEM ) {\n\t\t// hey, its not home.  return it by teleporting it back\n\t\tPrintMsg( NULL, \"%s\" S_COLOR_WHITE \" returned the %s flag!\\n\", \n\t\t\tcl->pers.netname, TeamName(team));\n\t\tAddScore(other, ent->r.currentOrigin, CTF_RECOVERY_BONUS);\n\t\tother->client->pers.teamState.flagrecovery++;\n\t\tother->client->pers.teamState.lastreturnedflag = level.time;\n\t\t//ResetFlag will remove this entity!  We must return zero\n\t\tTeam_ReturnFlagSound(Team_ResetFlag(team), team);\n\t\treturn 0;\n\t}\n#ifdef MISSIONPACK\n\t}\n#endif\n\n\t// the flag is at home base.  if the player has the enemy\n\t// flag, he's just won!\n\tif (!cl->ps.powerups[enemy_flag])\n\t\treturn 0; // We don't have the flag\n#ifdef MISSIONPACK\n\tif( g_gametype.integer == GT_1FCTF ) {\n\t\tPrintMsg( NULL, \"%s\" S_COLOR_WHITE \" captured the flag!\\n\", cl->pers.netname );\n\t}\n\telse {\n#endif\n\tPrintMsg( NULL, \"%s\" S_COLOR_WHITE \" captured the %s flag!\\n\", cl->pers.netname, TeamName(OtherTeam(team)));\n#ifdef MISSIONPACK\n\t}\n#endif\n\n\tcl->ps.powerups[enemy_flag] = 0;\n\n\tteamgame.last_flag_capture = level.time;\n\tteamgame.last_capture_team = team;\n\n\t// Increase the team's score\n\tAddTeamScore(ent->s.pos.trBase, other->client->sess.sessionTeam, 1);\n\tTeam_ForceGesture(other->client->sess.sessionTeam);\n\n\tother->client->pers.teamState.captures++;\n\t// add the sprite over the player's head\n\tother->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );\n\tother->client->ps.eFlags |= EF_AWARD_CAP;\n\tother->client->rewardTime = level.time + REWARD_SPRITE_TIME;\n\tother->client->ps.persistant[PERS_CAPTURES]++;\n\n\t// other gets another 10 frag bonus\n\tAddScore(other, ent->r.currentOrigin, CTF_CAPTURE_BONUS);\n\n\tTeam_CaptureFlagSound( ent, team );\n\n\t// Ok, let's do the player loop, hand out the bonuses\n\tfor (i = 0; i < g_maxclients.integer; i++) {\n\t\tplayer = &g_entities[i];\n\t\tif (!player->inuse)\n\t\t\tcontinue;\n\n\t\tif (player->client->sess.sessionTeam !=\n\t\t\tcl->sess.sessionTeam) {\n\t\t\tplayer->client->pers.teamState.lasthurtcarrier = -5;\n\t\t} else if (player->client->sess.sessionTeam ==\n\t\t\tcl->sess.sessionTeam) {\n\t\t\tif (player != other)\n\t\t\t\tAddScore(player, ent->r.currentOrigin, CTF_TEAM_BONUS);\n\t\t\t// award extra points for capture assists\n\t\t\tif (player->client->pers.teamState.lastreturnedflag + \n\t\t\t\tCTF_RETURN_FLAG_ASSIST_TIMEOUT > level.time) {\n\t\t\t\tAddScore (player, ent->r.currentOrigin, CTF_RETURN_FLAG_ASSIST_BONUS);\n\t\t\t\tother->client->pers.teamState.assists++;\n\n\t\t\t\tplayer->client->ps.persistant[PERS_ASSIST_COUNT]++;\n\t\t\t\t// add the sprite over the player's head\n\t\t\t\tplayer->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );\n\t\t\t\tplayer->client->ps.eFlags |= EF_AWARD_ASSIST;\n\t\t\t\tplayer->client->rewardTime = level.time + REWARD_SPRITE_TIME;\n\n\t\t\t} else if (player->client->pers.teamState.lastfraggedcarrier + \n\t\t\t\tCTF_FRAG_CARRIER_ASSIST_TIMEOUT > level.time) {\n\t\t\t\tAddScore(player, ent->r.currentOrigin, CTF_FRAG_CARRIER_ASSIST_BONUS);\n\t\t\t\tother->client->pers.teamState.assists++;\n\t\t\t\tplayer->client->ps.persistant[PERS_ASSIST_COUNT]++;\n\t\t\t\t// add the sprite over the player's head\n\t\t\t\tplayer->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );\n\t\t\t\tplayer->client->ps.eFlags |= EF_AWARD_ASSIST;\n\t\t\t\tplayer->client->rewardTime = level.time + REWARD_SPRITE_TIME;\n\t\t\t}\n\t\t}\n\t}\n\tTeam_ResetFlags();\n\n\tCalculateRanks();\n\n\treturn 0; // Do not respawn this automatically\n}\n\nint Team_TouchEnemyFlag( gentity_t *ent, gentity_t *other, int team ) {\n\tgclient_t *cl = other->client;\n\n#ifdef MISSIONPACK\n\tif( g_gametype.integer == GT_1FCTF ) {\n\t\tPrintMsg (NULL, \"%s\" S_COLOR_WHITE \" got the flag!\\n\", other->client->pers.netname );\n\n\t\tcl->ps.powerups[PW_NEUTRALFLAG] = INT_MAX; // flags never expire\n\n\t\tif( team == TEAM_RED ) {\n\t\t\tTeam_SetFlagStatus( TEAM_FREE, FLAG_TAKEN_RED );\n\t\t}\n\t\telse {\n\t\t\tTeam_SetFlagStatus( TEAM_FREE, FLAG_TAKEN_BLUE );\n\t\t}\n\t}\n\telse{\n#endif\n\t\tPrintMsg (NULL, \"%s\" S_COLOR_WHITE \" got the %s flag!\\n\",\n\t\t\tother->client->pers.netname, TeamName(team));\n\n\t\tif (team == TEAM_RED)\n\t\t\tcl->ps.powerups[PW_REDFLAG] = INT_MAX; // flags never expire\n\t\telse\n\t\t\tcl->ps.powerups[PW_BLUEFLAG] = INT_MAX; // flags never expire\n\n\t\tTeam_SetFlagStatus( team, FLAG_TAKEN );\n#ifdef MISSIONPACK\n\t}\n#endif\n\n\tAddScore(other, ent->r.currentOrigin, CTF_FLAG_BONUS);\n\tcl->pers.teamState.flagsince = level.time;\n\tTeam_TakeFlagSound( ent, team );\n\n\treturn -1; // Do not respawn this automatically, but do delete it if it was FL_DROPPED\n}\n\nint Pickup_Team( gentity_t *ent, gentity_t *other ) {\n\tint team;\n\tgclient_t *cl = other->client;\n\n#ifdef MISSIONPACK\n\tif( g_gametype.integer == GT_OBELISK ) {\n\t\t// there are no team items that can be picked up in obelisk\n\t\tG_FreeEntity( ent );\n\t\treturn 0;\n\t}\n\n\tif( g_gametype.integer == GT_HARVESTER ) {\n\t\t// the only team items that can be picked up in harvester are the cubes\n\t\tif( ent->spawnflags != cl->sess.sessionTeam ) {\n\t\t\tcl->ps.generic1 += 1;\n\t\t}\n\t\tG_FreeEntity( ent );\n\t\treturn 0;\n\t}\n#endif\n\t// figure out what team this flag is\n\tif( strcmp(ent->classname, \"team_CTF_redflag\") == 0 ) {\n\t\tteam = TEAM_RED;\n\t}\n\telse if( strcmp(ent->classname, \"team_CTF_blueflag\") == 0 ) {\n\t\tteam = TEAM_BLUE;\n\t}\n#ifdef MISSIONPACK\n\telse if( strcmp(ent->classname, \"team_CTF_neutralflag\") == 0  ) {\n\t\tteam = TEAM_FREE;\n\t}\n#endif\n\telse {\n\t\tPrintMsg ( other, \"Don't know what team the flag is on.\\n\");\n\t\treturn 0;\n\t}\n#ifdef MISSIONPACK\n\tif( g_gametype.integer == GT_1FCTF ) {\n\t\tif( team == TEAM_FREE ) {\n\t\t\treturn Team_TouchEnemyFlag( ent, other, cl->sess.sessionTeam );\n\t\t}\n\t\tif( team != cl->sess.sessionTeam) {\n\t\t\treturn Team_TouchOurFlag( ent, other, cl->sess.sessionTeam );\n\t\t}\n\t\treturn 0;\n\t}\n#endif\n\t// GT_CTF\n\tif( team == cl->sess.sessionTeam) {\n\t\treturn Team_TouchOurFlag( ent, other, team );\n\t}\n\treturn Team_TouchEnemyFlag( ent, other, team );\n}\n\n/*\n===========\nTeam_GetLocation\n\nReport a location for the player. Uses placed nearby target_location entities\n============\n*/\ngentity_t *Team_GetLocation(gentity_t *ent)\n{\n\tgentity_t\t\t*eloc, *best;\n\tfloat\t\t\tbestlen, len;\n\tvec3_t\t\t\torigin;\n\n\tbest = NULL;\n\tbestlen = 3*8192.0*8192.0;\n\n\tVectorCopy( ent->r.currentOrigin, origin );\n\n\tfor (eloc = level.locationHead; eloc; eloc = eloc->nextTrain) {\n\t\tlen = ( origin[0] - eloc->r.currentOrigin[0] ) * ( origin[0] - eloc->r.currentOrigin[0] )\n\t\t\t+ ( origin[1] - eloc->r.currentOrigin[1] ) * ( origin[1] - eloc->r.currentOrigin[1] )\n\t\t\t+ ( origin[2] - eloc->r.currentOrigin[2] ) * ( origin[2] - eloc->r.currentOrigin[2] );\n\n\t\tif ( len > bestlen ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( !trap_InPVS( origin, eloc->r.currentOrigin ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tbestlen = len;\n\t\tbest = eloc;\n\t}\n\n\treturn best;\n}\n\n\n/*\n===========\nTeam_GetLocation\n\nReport a location for the player. Uses placed nearby target_location entities\n============\n*/\nqboolean Team_GetLocationMsg(gentity_t *ent, char *loc, int loclen)\n{\n\tgentity_t *best;\n\n\tbest = Team_GetLocation( ent );\n\t\n\tif (!best)\n\t\treturn qfalse;\n\n\tif (best->count) {\n\t\tif (best->count < 0)\n\t\t\tbest->count = 0;\n\t\tif (best->count > 7)\n\t\t\tbest->count = 7;\n\t\tCom_sprintf(loc, loclen, \"%c%c%s\" S_COLOR_WHITE, Q_COLOR_ESCAPE, best->count + '0', best->message );\n\t} else\n\t\tCom_sprintf(loc, loclen, \"%s\", best->message);\n\n\treturn qtrue;\n}\n\n\n/*---------------------------------------------------------------------------*/\n\n/*\n================\nSelectRandomDeathmatchSpawnPoint\n\ngo to a random point that doesn't telefrag\n================\n*/\n#define\tMAX_TEAM_SPAWN_POINTS\t32\ngentity_t *SelectRandomTeamSpawnPoint( int teamstate, team_t team ) {\n\tgentity_t\t*spot;\n\tint\t\t\tcount;\n\tint\t\t\tselection;\n\tgentity_t\t*spots[MAX_TEAM_SPAWN_POINTS];\n\tchar\t\t*classname;\n\n\tif (teamstate == TEAM_BEGIN) {\n\t\tif (team == TEAM_RED)\n\t\t\tclassname = \"team_CTF_redplayer\";\n\t\telse if (team == TEAM_BLUE)\n\t\t\tclassname = \"team_CTF_blueplayer\";\n\t\telse\n\t\t\treturn NULL;\n\t} else {\n\t\tif (team == TEAM_RED)\n\t\t\tclassname = \"team_CTF_redspawn\";\n\t\telse if (team == TEAM_BLUE)\n\t\t\tclassname = \"team_CTF_bluespawn\";\n\t\telse\n\t\t\treturn NULL;\n\t}\n\tcount = 0;\n\n\tspot = NULL;\n\n\twhile ((spot = G_Find (spot, FOFS(classname), classname)) != NULL) {\n\t\tif ( SpotWouldTelefrag( spot ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\tspots[ count ] = spot;\n\t\tif (++count == MAX_TEAM_SPAWN_POINTS)\n\t\t\tbreak;\n\t}\n\n\tif ( !count ) {\t// no spots that won't telefrag\n\t\treturn G_Find( NULL, FOFS(classname), classname);\n\t}\n\n\tselection = rand() % count;\n\treturn spots[ selection ];\n}\n\n\n/*\n===========\nSelectCTFSpawnPoint\n\n============\n*/\ngentity_t *SelectCTFSpawnPoint ( team_t team, int teamstate, vec3_t origin, vec3_t angles ) {\n\tgentity_t\t*spot;\n\n\tspot = SelectRandomTeamSpawnPoint ( teamstate, team );\n\n\tif (!spot) {\n\t\treturn SelectSpawnPoint( vec3_origin, origin, angles );\n\t}\n\n\tVectorCopy (spot->s.origin, origin);\n\torigin[2] += 9;\n\tVectorCopy (spot->s.angles, angles);\n\n\treturn spot;\n}\n\n/*---------------------------------------------------------------------------*/\n\nstatic int QDECL SortClients( const void *a, const void *b ) {\n\treturn *(int *)a - *(int *)b;\n}\n\n\n/*\n==================\nTeamplayLocationsMessage\n\nFormat:\n\tclientNum location health armor weapon powerups\n\n==================\n*/\nvoid TeamplayInfoMessage( gentity_t *ent ) {\n\tchar\t\tentry[1024];\n\tchar\t\tstring[8192];\n\tint\t\t\tstringlength;\n\tint\t\t\ti, j;\n\tgentity_t\t*player;\n\tint\t\t\tcnt;\n\tint\t\t\th, a;\n\tint\t\t\tclients[TEAM_MAXOVERLAY];\n\n\tif ( ! ent->client->pers.teamInfo )\n\t\treturn;\n\n\t// figure out what client should be on the display\n\t// we are limited to 8, but we want to use the top eight players\n\t// but in client order (so they don't keep changing position on the overlay)\n\tfor (i = 0, cnt = 0; i < g_maxclients.integer && cnt < TEAM_MAXOVERLAY; i++) {\n\t\tplayer = g_entities + level.sortedClients[i];\n\t\tif (player->inuse && player->client->sess.sessionTeam == \n\t\t\tent->client->sess.sessionTeam ) {\n\t\t\tclients[cnt++] = level.sortedClients[i];\n\t\t}\n\t}\n\n\t// We have the top eight players, sort them by clientNum\n\tqsort( clients, cnt, sizeof( clients[0] ), SortClients );\n\n\t// send the latest information on all clients\n\tstring[0] = 0;\n\tstringlength = 0;\n\n\tfor (i = 0, cnt = 0; i < g_maxclients.integer && cnt < TEAM_MAXOVERLAY; i++) {\n\t\tplayer = g_entities + i;\n\t\tif (player->inuse && player->client->sess.sessionTeam == \n\t\t\tent->client->sess.sessionTeam ) {\n\n\t\t\th = player->client->ps.stats[STAT_HEALTH];\n\t\t\ta = player->client->ps.stats[STAT_ARMOR];\n\t\t\tif (h < 0) h = 0;\n\t\t\tif (a < 0) a = 0;\n\n\t\t\tCom_sprintf (entry, sizeof(entry),\n\t\t\t\t\" %i %i %i %i %i %i\", \n//\t\t\t\tlevel.sortedClients[i], player->client->pers.teamState.location, h, a, \n\t\t\t\ti, player->client->pers.teamState.location, h, a, \n\t\t\t\tplayer->client->ps.weapon, player->s.powerups);\n\t\t\tj = strlen(entry);\n\t\t\tif (stringlength + j > sizeof(string))\n\t\t\t\tbreak;\n\t\t\tstrcpy (string + stringlength, entry);\n\t\t\tstringlength += j;\n\t\t\tcnt++;\n\t\t}\n\t}\n\n\ttrap_SendServerCommand( ent-g_entities, va(\"tinfo %i %s\", cnt, string) );\n}\n\nvoid CheckTeamStatus(void) {\n\tint i;\n\tgentity_t *loc, *ent;\n\n\tif (level.time - level.lastTeamLocationTime > TEAM_LOCATION_UPDATE_TIME) {\n\n\t\tlevel.lastTeamLocationTime = level.time;\n\n\t\tfor (i = 0; i < g_maxclients.integer; i++) {\n\t\t\tent = g_entities + i;\n\n\t\t\tif ( ent->client->pers.connected != CON_CONNECTED ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (ent->inuse && (ent->client->sess.sessionTeam == TEAM_RED ||\tent->client->sess.sessionTeam == TEAM_BLUE)) {\n\t\t\t\tloc = Team_GetLocation( ent );\n\t\t\t\tif (loc)\n\t\t\t\t\tent->client->pers.teamState.location = loc->health;\n\t\t\t\telse\n\t\t\t\t\tent->client->pers.teamState.location = 0;\n\t\t\t}\n\t\t}\n\n\t\tfor (i = 0; i < g_maxclients.integer; i++) {\n\t\t\tent = g_entities + i;\n\n\t\t\tif ( ent->client->pers.connected != CON_CONNECTED ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (ent->inuse && (ent->client->sess.sessionTeam == TEAM_RED ||\tent->client->sess.sessionTeam == TEAM_BLUE)) {\n\t\t\t\tTeamplayInfoMessage( ent );\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*-----------------------------------------------------------------*/\n\n/*QUAKED team_CTF_redplayer (1 0 0) (-16 -16 -16) (16 16 32)\nOnly in CTF games.  Red players spawn here at game start.\n*/\nvoid SP_team_CTF_redplayer( gentity_t *ent ) {\n}\n\n\n/*QUAKED team_CTF_blueplayer (0 0 1) (-16 -16 -16) (16 16 32)\nOnly in CTF games.  Blue players spawn here at game start.\n*/\nvoid SP_team_CTF_blueplayer( gentity_t *ent ) {\n}\n\n\n/*QUAKED team_CTF_redspawn (1 0 0) (-16 -16 -24) (16 16 32)\npotential spawning position for red team in CTF games.\nTargets will be fired when someone spawns in on them.\n*/\nvoid SP_team_CTF_redspawn(gentity_t *ent) {\n}\n\n/*QUAKED team_CTF_bluespawn (0 0 1) (-16 -16 -24) (16 16 32)\npotential spawning position for blue team in CTF games.\nTargets will be fired when someone spawns in on them.\n*/\nvoid SP_team_CTF_bluespawn(gentity_t *ent) {\n}\n\n\n#ifdef MISSIONPACK\n/*\n================\nObelisks\n================\n*/\n\nstatic void ObeliskRegen( gentity_t *self ) {\n\tself->nextthink = level.time + g_obeliskRegenPeriod.integer * 1000;\n\tif( self->health >= g_obeliskHealth.integer ) {\n\t\treturn;\n\t}\n\n\tG_AddEvent( self, EV_POWERUP_REGEN, 0 );\n\tself->health += g_obeliskRegenAmount.integer;\n\tif ( self->health > g_obeliskHealth.integer ) {\n\t\tself->health = g_obeliskHealth.integer;\n\t}\n\n\tself->activator->s.modelindex2 = self->health * 0xff / g_obeliskHealth.integer;\n\tself->activator->s.frame = 0;\n}\n\n\nstatic void ObeliskRespawn( gentity_t *self ) {\n\tself->takedamage = qtrue;\n\tself->health = g_obeliskHealth.integer;\n\n\tself->think = ObeliskRegen;\n\tself->nextthink = level.time + g_obeliskRegenPeriod.integer * 1000;\n\n\tself->activator->s.frame = 0;\n}\n\n\nstatic void ObeliskDie( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod ) {\n\tint\t\t\totherTeam;\n\n\totherTeam = OtherTeam( self->spawnflags );\n\tAddTeamScore(self->s.pos.trBase, otherTeam, 1);\n\tTeam_ForceGesture(otherTeam);\n\n\tCalculateRanks();\n\n\tself->takedamage = qfalse;\n\tself->think = ObeliskRespawn;\n\tself->nextthink = level.time + g_obeliskRespawnDelay.integer * 1000;\n\n\tself->activator->s.modelindex2 = 0xff;\n\tself->activator->s.frame = 2;\n\n\tG_AddEvent( self->activator, EV_OBELISKEXPLODE, 0 );\n\n\tAddScore(attacker, self->r.currentOrigin, CTF_CAPTURE_BONUS);\n\n\t// add the sprite over the player's head\n\tattacker->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );\n\tattacker->client->ps.eFlags |= EF_AWARD_CAP;\n\tattacker->client->rewardTime = level.time + REWARD_SPRITE_TIME;\n\tattacker->client->ps.persistant[PERS_CAPTURES]++;\n\n\tteamgame.redObeliskAttackedTime = 0;\n\tteamgame.blueObeliskAttackedTime = 0;\n}\n\n\nstatic void ObeliskTouch( gentity_t *self, gentity_t *other, trace_t *trace ) {\n\tint\t\t\ttokens;\n\n\tif ( !other->client ) {\n\t\treturn;\n\t}\n\n\tif ( OtherTeam(other->client->sess.sessionTeam) != self->spawnflags ) {\n\t\treturn;\n\t}\n\n\ttokens = other->client->ps.generic1;\n\tif( tokens <= 0 ) {\n\t\treturn;\n\t}\n\n\tPrintMsg(NULL, \"%s\" S_COLOR_WHITE \" brought in %i skull%s.\\n\",\n\t\t\t\t\tother->client->pers.netname, tokens, tokens ? \"s\" : \"\" );\n\n\tAddTeamScore(self->s.pos.trBase, other->client->sess.sessionTeam, tokens);\n\tTeam_ForceGesture(other->client->sess.sessionTeam);\n\n\tAddScore(other, self->r.currentOrigin, CTF_CAPTURE_BONUS*tokens);\n\n\t// add the sprite over the player's head\n\tother->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );\n\tother->client->ps.eFlags |= EF_AWARD_CAP;\n\tother->client->rewardTime = level.time + REWARD_SPRITE_TIME;\n\tother->client->ps.persistant[PERS_CAPTURES] += tokens;\n\t\n\tother->client->ps.generic1 = 0;\n\tCalculateRanks();\n\n\tTeam_CaptureFlagSound( self, self->spawnflags );\n}\n\nstatic void ObeliskPain( gentity_t *self, gentity_t *attacker, int damage ) {\n\tint actualDamage = damage / 10;\n\tif (actualDamage <= 0) {\n\t\tactualDamage = 1;\n\t}\n\tself->activator->s.modelindex2 = self->health * 0xff / g_obeliskHealth.integer;\n\tif (!self->activator->s.frame) {\n\t\tG_AddEvent(self, EV_OBELISKPAIN, 0);\n\t}\n\tself->activator->s.frame = 1;\n\tAddScore(attacker, self->r.currentOrigin, actualDamage);\n}\n\ngentity_t *SpawnObelisk( vec3_t origin, int team, int spawnflags) {\n\ttrace_t\t\ttr;\n\tvec3_t\t\tdest;\n\tgentity_t\t*ent;\n\n\tent = G_Spawn();\n\n\tVectorCopy( origin, ent->s.origin );\n\tVectorCopy( origin, ent->s.pos.trBase );\n\tVectorCopy( origin, ent->r.currentOrigin );\n\n\tVectorSet( ent->r.mins, -15, -15, 0 );\n\tVectorSet( ent->r.maxs, 15, 15, 87 );\n\n\tent->s.eType = ET_GENERAL;\n\tent->flags = FL_NO_KNOCKBACK;\n\n\tif( g_gametype.integer == GT_OBELISK ) {\n\t\tent->r.contents = CONTENTS_SOLID;\n\t\tent->takedamage = qtrue;\n\t\tent->health = g_obeliskHealth.integer;\n\t\tent->die = ObeliskDie;\n\t\tent->pain = ObeliskPain;\n\t\tent->think = ObeliskRegen;\n\t\tent->nextthink = level.time + g_obeliskRegenPeriod.integer * 1000;\n\t}\n\tif( g_gametype.integer == GT_HARVESTER ) {\n\t\tent->r.contents = CONTENTS_TRIGGER;\n\t\tent->touch = ObeliskTouch;\n\t}\n\n\tif ( spawnflags & 1 ) {\n\t\t// suspended\n\t\tG_SetOrigin( ent, ent->s.origin );\n\t} else {\n\t\t// mappers like to put them exactly on the floor, but being coplanar\n\t\t// will sometimes show up as starting in solid, so lif it up one pixel\n\t\tent->s.origin[2] += 1;\n\n\t\t// drop to floor\n\t\tVectorSet( dest, ent->s.origin[0], ent->s.origin[1], ent->s.origin[2] - 4096 );\n\t\ttrap_Trace( &tr, ent->s.origin, ent->r.mins, ent->r.maxs, dest, ent->s.number, MASK_SOLID );\n\t\tif ( tr.startsolid ) {\n\t\t\tent->s.origin[2] -= 1;\n\t\t\tG_Printf( \"SpawnObelisk: %s startsolid at %s\\n\", ent->classname, vtos(ent->s.origin) );\n\n\t\t\tent->s.groundEntityNum = ENTITYNUM_NONE;\n\t\t\tG_SetOrigin( ent, ent->s.origin );\n\t\t}\n\t\telse {\n\t\t\t// allow to ride movers\n\t\t\tent->s.groundEntityNum = tr.entityNum;\n\t\t\tG_SetOrigin( ent, tr.endpos );\n\t\t}\n\t}\n\n\tent->spawnflags = team;\n\n\ttrap_LinkEntity( ent );\n\n\treturn ent;\n}\n\n/*QUAKED team_redobelisk (1 0 0) (-16 -16 0) (16 16 8)\n*/\nvoid SP_team_redobelisk( gentity_t *ent ) {\n\tgentity_t *obelisk;\n\n\tif ( g_gametype.integer <= GT_TEAM ) {\n\t\tG_FreeEntity(ent);\n\t\treturn;\n\t}\n\tent->s.eType = ET_TEAM;\n\tif ( g_gametype.integer == GT_OBELISK ) {\n\t\tobelisk = SpawnObelisk( ent->s.origin, TEAM_RED, ent->spawnflags );\n\t\tobelisk->activator = ent;\n\t\t// initial obelisk health value\n\t\tent->s.modelindex2 = 0xff;\n\t\tent->s.frame = 0;\n\t}\n\tif ( g_gametype.integer == GT_HARVESTER ) {\n\t\tobelisk = SpawnObelisk( ent->s.origin, TEAM_RED, ent->spawnflags );\n\t\tobelisk->activator = ent;\n\t}\n\tent->s.modelindex = TEAM_RED;\n\ttrap_LinkEntity(ent);\n}\n\n/*QUAKED team_blueobelisk (0 0 1) (-16 -16 0) (16 16 88)\n*/\nvoid SP_team_blueobelisk( gentity_t *ent ) {\n\tgentity_t *obelisk;\n\n\tif ( g_gametype.integer <= GT_TEAM ) {\n\t\tG_FreeEntity(ent);\n\t\treturn;\n\t}\n\tent->s.eType = ET_TEAM;\n\tif ( g_gametype.integer == GT_OBELISK ) {\n\t\tobelisk = SpawnObelisk( ent->s.origin, TEAM_BLUE, ent->spawnflags );\n\t\tobelisk->activator = ent;\n\t\t// initial obelisk health value\n\t\tent->s.modelindex2 = 0xff;\n\t\tent->s.frame = 0;\n\t}\n\tif ( g_gametype.integer == GT_HARVESTER ) {\n\t\tobelisk = SpawnObelisk( ent->s.origin, TEAM_BLUE, ent->spawnflags );\n\t\tobelisk->activator = ent;\n\t}\n\tent->s.modelindex = TEAM_BLUE;\n\ttrap_LinkEntity(ent);\n}\n\n/*QUAKED team_neutralobelisk (0 0 1) (-16 -16 0) (16 16 88)\n*/\nvoid SP_team_neutralobelisk( gentity_t *ent ) {\n\tif ( g_gametype.integer != GT_1FCTF && g_gametype.integer != GT_HARVESTER ) {\n\t\tG_FreeEntity(ent);\n\t\treturn;\n\t}\n\tent->s.eType = ET_TEAM;\n\tif ( g_gametype.integer == GT_HARVESTER) {\n\t\tneutralObelisk = SpawnObelisk( ent->s.origin, TEAM_FREE, ent->spawnflags);\n\t\tneutralObelisk->spawnflags = TEAM_FREE;\n\t}\n\tent->s.modelindex = TEAM_FREE;\n\ttrap_LinkEntity(ent);\n}\n\n\n/*\n================\nCheckObeliskAttack\n================\n*/\nqboolean CheckObeliskAttack( gentity_t *obelisk, gentity_t *attacker ) {\n\tgentity_t\t*te;\n\n\t// if this really is an obelisk\n\tif( obelisk->die != ObeliskDie ) {\n\t\treturn qfalse;\n\t}\n\n\t// if the attacker is a client\n\tif( !attacker->client ) {\n\t\treturn qfalse;\n\t}\n\n\t// if the obelisk is on the same team as the attacker then don't hurt it\n\tif( obelisk->spawnflags == attacker->client->sess.sessionTeam ) {\n\t\treturn qtrue;\n\t}\n\n\t// obelisk may be hurt\n\n\t// if not played any sounds recently\n\tif ((obelisk->spawnflags == TEAM_RED &&\n\t\tteamgame.redObeliskAttackedTime < level.time - OVERLOAD_ATTACK_BASE_SOUND_TIME) ||\n\t\t(obelisk->spawnflags == TEAM_BLUE &&\n\t\tteamgame.blueObeliskAttackedTime < level.time - OVERLOAD_ATTACK_BASE_SOUND_TIME) ) {\n\n\t\t// tell which obelisk is under attack\n\t\tte = G_TempEntity( obelisk->s.pos.trBase, EV_GLOBAL_TEAM_SOUND );\n\t\tif( obelisk->spawnflags == TEAM_RED ) {\n\t\t\tte->s.eventParm = GTS_REDOBELISK_ATTACKED;\n\t\t\tteamgame.redObeliskAttackedTime = level.time;\n\t\t}\n\t\telse {\n\t\t\tte->s.eventParm = GTS_BLUEOBELISK_ATTACKED;\n\t\t\tteamgame.blueObeliskAttackedTime = level.time;\n\t\t}\n\t\tte->r.svFlags |= SVF_BROADCAST;\n\t}\n\n\treturn qfalse;\n}\n#endif\n"
  },
  {
    "path": "code/game/g_team.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n\n#ifdef MISSIONPACK\n\n#define CTF_CAPTURE_BONUS\t\t100\t\t// what you get for capture\n#define CTF_TEAM_BONUS\t\t\t25\t\t// what your team gets for capture\n#define CTF_RECOVERY_BONUS\t\t10\t\t// what you get for recovery\n#define CTF_FLAG_BONUS\t\t\t10\t\t// what you get for picking up enemy flag\n#define CTF_FRAG_CARRIER_BONUS\t20\t\t// what you get for fragging enemy flag carrier\n#define CTF_FLAG_RETURN_TIME\t40000\t// seconds until auto return\n\n#define CTF_CARRIER_DANGER_PROTECT_BONUS\t5\t// bonus for fraggin someone who has recently hurt your flag carrier\n#define CTF_CARRIER_PROTECT_BONUS\t\t\t2\t// bonus for fraggin someone while either you or your target are near your flag carrier\n#define CTF_FLAG_DEFENSE_BONUS\t\t\t\t10\t// bonus for fraggin someone while either you or your target are near your flag\n#define CTF_RETURN_FLAG_ASSIST_BONUS\t\t10\t// awarded for returning a flag that causes a capture to happen almost immediately\n#define CTF_FRAG_CARRIER_ASSIST_BONUS\t\t10\t// award for fragging a flag carrier if a capture happens almost immediately\n\n#else\n\n#define CTF_CAPTURE_BONUS\t\t5\t\t// what you get for capture\n#define CTF_TEAM_BONUS\t\t\t0\t\t// what your team gets for capture\n#define CTF_RECOVERY_BONUS\t\t1\t\t// what you get for recovery\n#define CTF_FLAG_BONUS\t\t\t0\t\t// what you get for picking up enemy flag\n#define CTF_FRAG_CARRIER_BONUS\t2\t\t// what you get for fragging enemy flag carrier\n#define CTF_FLAG_RETURN_TIME\t40000\t// seconds until auto return\n\n#define CTF_CARRIER_DANGER_PROTECT_BONUS\t2\t// bonus for fraggin someone who has recently hurt your flag carrier\n#define CTF_CARRIER_PROTECT_BONUS\t\t\t1\t// bonus for fraggin someone while either you or your target are near your flag carrier\n#define CTF_FLAG_DEFENSE_BONUS\t\t\t\t1\t// bonus for fraggin someone while either you or your target are near your flag\n#define CTF_RETURN_FLAG_ASSIST_BONUS\t\t1\t// awarded for returning a flag that causes a capture to happen almost immediately\n#define CTF_FRAG_CARRIER_ASSIST_BONUS\t\t2\t// award for fragging a flag carrier if a capture happens almost immediately\n\n#endif\n\n#define CTF_TARGET_PROTECT_RADIUS\t\t\t1000\t// the radius around an object being defended where a target will be worth extra frags\n#define CTF_ATTACKER_PROTECT_RADIUS\t\t\t1000\t// the radius around an object being defended where an attacker will get extra frags when making kills\n\n#define CTF_CARRIER_DANGER_PROTECT_TIMEOUT\t8000\n#define CTF_FRAG_CARRIER_ASSIST_TIMEOUT\t\t10000\n#define CTF_RETURN_FLAG_ASSIST_TIMEOUT\t\t10000\n\n#define CTF_GRAPPLE_SPEED\t\t\t\t\t750 // speed of grapple in flight\n#define CTF_GRAPPLE_PULL_SPEED\t\t\t\t750\t// speed player is pulled at\n\n#define OVERLOAD_ATTACK_BASE_SOUND_TIME\t\t20000\n\n// Prototypes\n\nint OtherTeam(int team);\nconst char *TeamName(int team);\nconst char *OtherTeamName(int team);\nconst char *TeamColorString(int team);\nvoid AddTeamScore(vec3_t origin, int team, int score);\n\nvoid Team_DroppedFlagThink(gentity_t *ent);\nvoid Team_FragBonuses(gentity_t *targ, gentity_t *inflictor, gentity_t *attacker);\nvoid Team_CheckHurtCarrier(gentity_t *targ, gentity_t *attacker);\nvoid Team_InitGame(void);\nvoid Team_ReturnFlag(int team);\nvoid Team_FreeEntity(gentity_t *ent);\ngentity_t *SelectCTFSpawnPoint ( team_t team, int teamstate, vec3_t origin, vec3_t angles );\ngentity_t *Team_GetLocation(gentity_t *ent);\nqboolean Team_GetLocationMsg(gentity_t *ent, char *loc, int loclen);\nvoid TeamplayInfoMessage( gentity_t *ent );\nvoid CheckTeamStatus(void);\n\nint Pickup_Team( gentity_t *ent, gentity_t *other );\n"
  },
  {
    "path": "code/game/g_trigger.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#include \"g_local.h\"\n\n\nvoid InitTrigger( gentity_t *self ) {\n\tif (!VectorCompare (self->s.angles, vec3_origin))\n\t\tG_SetMovedir (self->s.angles, self->movedir);\n\n\ttrap_SetBrushModel( self, self->model );\n\tself->r.contents = CONTENTS_TRIGGER;\t\t// replaces the -1 from trap_SetBrushModel\n\tself->r.svFlags = SVF_NOCLIENT;\n}\n\n\n// the wait time has passed, so set back up for another activation\nvoid multi_wait( gentity_t *ent ) {\n\tent->nextthink = 0;\n}\n\n\n// the trigger was just activated\n// ent->activator should be set to the activator so it can be held through a delay\n// so wait for the delay time before firing\nvoid multi_trigger( gentity_t *ent, gentity_t *activator ) {\n\tent->activator = activator;\n\tif ( ent->nextthink ) {\n\t\treturn;\t\t// can't retrigger until the wait is over\n\t}\n\n\tif ( activator->client ) {\n\t\tif ( ( ent->spawnflags & 1 ) &&\n\t\t\tactivator->client->sess.sessionTeam != TEAM_RED ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( ( ent->spawnflags & 2 ) &&\n\t\t\tactivator->client->sess.sessionTeam != TEAM_BLUE ) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\tG_UseTargets (ent, ent->activator);\n\n\tif ( ent->wait > 0 ) {\n\t\tent->think = multi_wait;\n\t\tent->nextthink = level.time + ( ent->wait + ent->random * crandom() ) * 1000;\n\t} else {\n\t\t// we can't just remove (self) here, because this is a touch function\n\t\t// called while looping through area links...\n\t\tent->touch = 0;\n\t\tent->nextthink = level.time + FRAMETIME;\n\t\tent->think = G_FreeEntity;\n\t}\n}\n\nvoid Use_Multi( gentity_t *ent, gentity_t *other, gentity_t *activator ) {\n\tmulti_trigger( ent, activator );\n}\n\nvoid Touch_Multi( gentity_t *self, gentity_t *other, trace_t *trace ) {\n\tif( !other->client ) {\n\t\treturn;\n\t}\n\tmulti_trigger( self, other );\n}\n\n/*QUAKED trigger_multiple (.5 .5 .5) ?\n\"wait\" : Seconds between triggerings, 0.5 default, -1 = one time only.\n\"random\"\twait variance, default is 0\nVariable sized repeatable trigger.  Must be targeted at one or more entities.\nso, the basic time between firing is a random time between\n(wait - random) and (wait + random)\n*/\nvoid SP_trigger_multiple( gentity_t *ent ) {\n\tG_SpawnFloat( \"wait\", \"0.5\", &ent->wait );\n\tG_SpawnFloat( \"random\", \"0\", &ent->random );\n\n\tif ( ent->random >= ent->wait && ent->wait >= 0 ) {\n\t\tent->random = ent->wait - FRAMETIME;\n\t\tG_Printf( \"trigger_multiple has random >= wait\\n\" );\n\t}\n\n\tent->touch = Touch_Multi;\n\tent->use = Use_Multi;\n\n\tInitTrigger( ent );\n\ttrap_LinkEntity (ent);\n}\n\n\n\n/*\n==============================================================================\n\ntrigger_always\n\n==============================================================================\n*/\n\nvoid trigger_always_think( gentity_t *ent ) {\n\tG_UseTargets(ent, ent);\n\tG_FreeEntity( ent );\n}\n\n/*QUAKED trigger_always (.5 .5 .5) (-8 -8 -8) (8 8 8)\nThis trigger will always fire.  It is activated by the world.\n*/\nvoid SP_trigger_always (gentity_t *ent) {\n\t// we must have some delay to make sure our use targets are present\n\tent->nextthink = level.time + 300;\n\tent->think = trigger_always_think;\n}\n\n\n/*\n==============================================================================\n\ntrigger_push\n\n==============================================================================\n*/\n\nvoid trigger_push_touch (gentity_t *self, gentity_t *other, trace_t *trace ) {\n\n\tif ( !other->client ) {\n\t\treturn;\n\t}\n\n\tBG_TouchJumpPad( &other->client->ps, &self->s );\n}\n\n\n/*\n=================\nAimAtTarget\n\nCalculate origin2 so the target apogee will be hit\n=================\n*/\nvoid AimAtTarget( gentity_t *self ) {\n\tgentity_t\t*ent;\n\tvec3_t\t\torigin;\n\tfloat\t\theight, gravity, time, forward;\n\tfloat\t\tdist;\n\n\tVectorAdd( self->r.absmin, self->r.absmax, origin );\n\tVectorScale ( origin, 0.5, origin );\n\n\tent = G_PickTarget( self->target );\n\tif ( !ent ) {\n\t\tG_FreeEntity( self );\n\t\treturn;\n\t}\n\n\theight = ent->s.origin[2] - origin[2];\n\tgravity = g_gravity.value;\n\ttime = sqrt( height / ( .5 * gravity ) );\n\tif ( !time ) {\n\t\tG_FreeEntity( self );\n\t\treturn;\n\t}\n\n\t// set s.origin2 to the push velocity\n\tVectorSubtract ( ent->s.origin, origin, self->s.origin2 );\n\tself->s.origin2[2] = 0;\n\tdist = VectorNormalize( self->s.origin2);\n\n\tforward = dist / time;\n\tVectorScale( self->s.origin2, forward, self->s.origin2 );\n\n\tself->s.origin2[2] = time * gravity;\n}\n\n\n/*QUAKED trigger_push (.5 .5 .5) ?\nMust point at a target_position, which will be the apex of the leap.\nThis will be client side predicted, unlike target_push\n*/\nvoid SP_trigger_push( gentity_t *self ) {\n\tInitTrigger (self);\n\n\t// unlike other triggers, we need to send this one to the client\n\tself->r.svFlags &= ~SVF_NOCLIENT;\n\n\t// make sure the client precaches this sound\n\tG_SoundIndex(\"sound/world/jumppad.wav\");\n\n\tself->s.eType = ET_PUSH_TRIGGER;\n\tself->touch = trigger_push_touch;\n\tself->think = AimAtTarget;\n\tself->nextthink = level.time + FRAMETIME;\n\ttrap_LinkEntity (self);\n}\n\n\nvoid Use_target_push( gentity_t *self, gentity_t *other, gentity_t *activator ) {\n\tif ( !activator->client ) {\n\t\treturn;\n\t}\n\n\tif ( activator->client->ps.pm_type != PM_NORMAL ) {\n\t\treturn;\n\t}\n\tif ( activator->client->ps.powerups[PW_FLIGHT] ) {\n\t\treturn;\n\t}\n\n\tVectorCopy (self->s.origin2, activator->client->ps.velocity);\n\n\t// play fly sound every 1.5 seconds\n\tif ( activator->fly_sound_debounce_time < level.time ) {\n\t\tactivator->fly_sound_debounce_time = level.time + 1500;\n\t\tG_Sound( activator, CHAN_AUTO, self->noise_index );\n\t}\n}\n\n/*QUAKED target_push (.5 .5 .5) (-8 -8 -8) (8 8 8) bouncepad\nPushes the activator in the direction.of angle, or towards a target apex.\n\"speed\"\t\tdefaults to 1000\nif \"bouncepad\", play bounce noise instead of windfly\n*/\nvoid SP_target_push( gentity_t *self ) {\n\tif (!self->speed) {\n\t\tself->speed = 1000;\n\t}\n\tG_SetMovedir (self->s.angles, self->s.origin2);\n\tVectorScale (self->s.origin2, self->speed, self->s.origin2);\n\n\tif ( self->spawnflags & 1 ) {\n\t\tself->noise_index = G_SoundIndex(\"sound/world/jumppad.wav\");\n\t} else {\n\t\tself->noise_index = G_SoundIndex(\"sound/misc/windfly.wav\");\n\t}\n\tif ( self->target ) {\n\t\tVectorCopy( self->s.origin, self->r.absmin );\n\t\tVectorCopy( self->s.origin, self->r.absmax );\n\t\tself->think = AimAtTarget;\n\t\tself->nextthink = level.time + FRAMETIME;\n\t}\n\tself->use = Use_target_push;\n}\n\n/*\n==============================================================================\n\ntrigger_teleport\n\n==============================================================================\n*/\n\nvoid trigger_teleporter_touch (gentity_t *self, gentity_t *other, trace_t *trace ) {\n\tgentity_t\t*dest;\n\n\tif ( !other->client ) {\n\t\treturn;\n\t}\n\tif ( other->client->ps.pm_type == PM_DEAD ) {\n\t\treturn;\n\t}\n\t// Spectators only?\n\tif ( ( self->spawnflags & 1 ) && \n\t\tother->client->sess.sessionTeam != TEAM_SPECTATOR ) {\n\t\treturn;\n\t}\n\n\n\tdest = \tG_PickTarget( self->target );\n\tif (!dest) {\n\t\tG_Printf (\"Couldn't find teleporter destination\\n\");\n\t\treturn;\n\t}\n\n\tTeleportPlayer( other, dest->s.origin, dest->s.angles );\n}\n\n\n/*QUAKED trigger_teleport (.5 .5 .5) ? SPECTATOR\nAllows client side prediction of teleportation events.\nMust point at a target_position, which will be the teleport destination.\n\nIf spectator is set, only spectators can use this teleport\nSpectator teleporters are not normally placed in the editor, but are created\nautomatically near doors to allow spectators to move through them\n*/\nvoid SP_trigger_teleport( gentity_t *self ) {\n\tInitTrigger (self);\n\n\t// unlike other triggers, we need to send this one to the client\n\t// unless is a spectator trigger\n\tif ( self->spawnflags & 1 ) {\n\t\tself->r.svFlags |= SVF_NOCLIENT;\n\t} else {\n\t\tself->r.svFlags &= ~SVF_NOCLIENT;\n\t}\n\n\t// make sure the client precaches this sound\n\tG_SoundIndex(\"sound/world/jumppad.wav\");\n\n\tself->s.eType = ET_TELEPORT_TRIGGER;\n\tself->touch = trigger_teleporter_touch;\n\n\ttrap_LinkEntity (self);\n}\n\n\n/*\n==============================================================================\n\ntrigger_hurt\n\n==============================================================================\n*/\n\n/*QUAKED trigger_hurt (.5 .5 .5) ? START_OFF - SILENT NO_PROTECTION SLOW\nAny entity that touches this will be hurt.\nIt does dmg points of damage each server frame\nTargeting the trigger will toggle its on / off state.\n\nSILENT\t\t\tsupresses playing the sound\nSLOW\t\t\tchanges the damage rate to once per second\nNO_PROTECTION\t*nothing* stops the damage\n\n\"dmg\"\t\t\tdefault 5 (whole numbers only)\n\n*/\nvoid hurt_use( gentity_t *self, gentity_t *other, gentity_t *activator ) {\n\tif ( self->r.linked ) {\n\t\ttrap_UnlinkEntity( self );\n\t} else {\n\t\ttrap_LinkEntity( self );\n\t}\n}\n\nvoid hurt_touch( gentity_t *self, gentity_t *other, trace_t *trace ) {\n\tint\t\tdflags;\n\n\tif ( !other->takedamage ) {\n\t\treturn;\n\t}\n\n\tif ( self->timestamp > level.time ) {\n\t\treturn;\n\t}\n\n\tif ( self->spawnflags & 16 ) {\n\t\tself->timestamp = level.time + 1000;\n\t} else {\n\t\tself->timestamp = level.time + FRAMETIME;\n\t}\n\n\t// play sound\n\tif ( !(self->spawnflags & 4) ) {\n\t\tG_Sound( other, CHAN_AUTO, self->noise_index );\n\t}\n\n\tif (self->spawnflags & 8)\n\t\tdflags = DAMAGE_NO_PROTECTION;\n\telse\n\t\tdflags = 0;\n\tG_Damage (other, self, self, NULL, NULL, self->damage, dflags, MOD_TRIGGER_HURT);\n}\n\nvoid SP_trigger_hurt( gentity_t *self ) {\n\tInitTrigger (self);\n\n\tself->noise_index = G_SoundIndex( \"sound/world/electro.wav\" );\n\tself->touch = hurt_touch;\n\n\tif ( !self->damage ) {\n\t\tself->damage = 5;\n\t}\n\n\tself->r.contents = CONTENTS_TRIGGER;\n\n\tif ( self->spawnflags & 2 ) {\n\t\tself->use = hurt_use;\n\t}\n\n\t// link in to the world if starting active\n\tif ( ! (self->spawnflags & 1) ) {\n\t\ttrap_LinkEntity (self);\n\t}\n}\n\n\n/*\n==============================================================================\n\ntimer\n\n==============================================================================\n*/\n\n\n/*QUAKED func_timer (0.3 0.1 0.6) (-8 -8 -8) (8 8 8) START_ON\nThis should be renamed trigger_timer...\nRepeatedly fires its targets.\nCan be turned on or off by using.\n\n\"wait\"\t\t\tbase time between triggering all targets, default is 1\n\"random\"\t\twait variance, default is 0\nso, the basic time between firing is a random time between\n(wait - random) and (wait + random)\n\n*/\nvoid func_timer_think( gentity_t *self ) {\n\tG_UseTargets (self, self->activator);\n\t// set time before next firing\n\tself->nextthink = level.time + 1000 * ( self->wait + crandom() * self->random );\n}\n\nvoid func_timer_use( gentity_t *self, gentity_t *other, gentity_t *activator ) {\n\tself->activator = activator;\n\n\t// if on, turn it off\n\tif ( self->nextthink ) {\n\t\tself->nextthink = 0;\n\t\treturn;\n\t}\n\n\t// turn it on\n\tfunc_timer_think (self);\n}\n\nvoid SP_func_timer( gentity_t *self ) {\n\tG_SpawnFloat( \"random\", \"1\", &self->random);\n\tG_SpawnFloat( \"wait\", \"1\", &self->wait );\n\n\tself->use = func_timer_use;\n\tself->think = func_timer_think;\n\n\tif ( self->random >= self->wait ) {\n\t\tself->random = self->wait - FRAMETIME;\n\t\tG_Printf( \"func_timer at %s has random >= wait\\n\", vtos( self->s.origin ) );\n\t}\n\n\tif ( self->spawnflags & 1 ) {\n\t\tself->nextthink = level.time + FRAMETIME;\n\t\tself->activator = self;\n\t}\n\n\tself->r.svFlags = SVF_NOCLIENT;\n}\n\n\n"
  },
  {
    "path": "code/game/g_utils.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// g_utils.c -- misc utility functions for game module\n\n#include \"g_local.h\"\n\ntypedef struct {\n  char oldShader[MAX_QPATH];\n  char newShader[MAX_QPATH];\n  float timeOffset;\n} shaderRemap_t;\n\n#define MAX_SHADER_REMAPS 128\n\nint remapCount = 0;\nshaderRemap_t remappedShaders[MAX_SHADER_REMAPS];\n\nvoid AddRemap(const char *oldShader, const char *newShader, float timeOffset) {\n\tint i;\n\n\tfor (i = 0; i < remapCount; i++) {\n\t\tif (Q_stricmp(oldShader, remappedShaders[i].oldShader) == 0) {\n\t\t\t// found it, just update this one\n\t\t\tstrcpy(remappedShaders[i].newShader,newShader);\n\t\t\tremappedShaders[i].timeOffset = timeOffset;\n\t\t\treturn;\n\t\t}\n\t}\n\tif (remapCount < MAX_SHADER_REMAPS) {\n\t\tstrcpy(remappedShaders[remapCount].newShader,newShader);\n\t\tstrcpy(remappedShaders[remapCount].oldShader,oldShader);\n\t\tremappedShaders[remapCount].timeOffset = timeOffset;\n\t\tremapCount++;\n\t}\n}\n\nconst char *BuildShaderStateConfig() {\n\tstatic char\tbuff[MAX_STRING_CHARS*4];\n\tchar out[(MAX_QPATH * 2) + 5];\n\tint i;\n  \n\tmemset(buff, 0, MAX_STRING_CHARS);\n\tfor (i = 0; i < remapCount; i++) {\n\t\tCom_sprintf(out, (MAX_QPATH * 2) + 5, \"%s=%s:%5.2f@\", remappedShaders[i].oldShader, remappedShaders[i].newShader, remappedShaders[i].timeOffset);\n\t\tQ_strcat( buff, sizeof( buff ), out);\n\t}\n\treturn buff;\n}\n\n/*\n=========================================================================\n\nmodel / sound configstring indexes\n\n=========================================================================\n*/\n\n/*\n================\nG_FindConfigstringIndex\n\n================\n*/\nint G_FindConfigstringIndex( char *name, int start, int max, qboolean create ) {\n\tint\t\ti;\n\tchar\ts[MAX_STRING_CHARS];\n\n\tif ( !name || !name[0] ) {\n\t\treturn 0;\n\t}\n\n\tfor ( i=1 ; i<max ; i++ ) {\n\t\ttrap_GetConfigstring( start + i, s, sizeof( s ) );\n\t\tif ( !s[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( !strcmp( s, name ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\n\tif ( !create ) {\n\t\treturn 0;\n\t}\n\n\tif ( i == max ) {\n\t\tG_Error( \"G_FindConfigstringIndex: overflow\" );\n\t}\n\n\ttrap_SetConfigstring( start + i, name );\n\n\treturn i;\n}\n\n\nint G_ModelIndex( char *name ) {\n\treturn G_FindConfigstringIndex (name, CS_MODELS, MAX_MODELS, qtrue);\n}\n\nint G_SoundIndex( char *name ) {\n\treturn G_FindConfigstringIndex (name, CS_SOUNDS, MAX_SOUNDS, qtrue);\n}\n\n//=====================================================================\n\n\n/*\n================\nG_TeamCommand\n\nBroadcasts a command to only a specific team\n================\n*/\nvoid G_TeamCommand( team_t team, char *cmd ) {\n\tint\t\ti;\n\n\tfor ( i = 0 ; i < level.maxclients ; i++ ) {\n\t\tif ( level.clients[i].pers.connected == CON_CONNECTED ) {\n\t\t\tif ( level.clients[i].sess.sessionTeam == team ) {\n\t\t\t\ttrap_SendServerCommand( i, va(\"%s\", cmd ));\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n/*\n=============\nG_Find\n\nSearches all active entities for the next one that holds\nthe matching string at fieldofs (use the FOFS() macro) in the structure.\n\nSearches beginning at the entity after from, or the beginning if NULL\nNULL will be returned if the end of the list is reached.\n\n=============\n*/\ngentity_t *G_Find (gentity_t *from, int fieldofs, const char *match)\n{\n\tchar\t*s;\n\n\tif (!from)\n\t\tfrom = g_entities;\n\telse\n\t\tfrom++;\n\n\tfor ( ; from < &g_entities[level.num_entities] ; from++)\n\t{\n\t\tif (!from->inuse)\n\t\t\tcontinue;\n\t\ts = *(char **) ((byte *)from + fieldofs);\n\t\tif (!s)\n\t\t\tcontinue;\n\t\tif (!Q_stricmp (s, match))\n\t\t\treturn from;\n\t}\n\n\treturn NULL;\n}\n\n\n/*\n=============\nG_PickTarget\n\nSelects a random entity from among the targets\n=============\n*/\n#define MAXCHOICES\t32\n\ngentity_t *G_PickTarget (char *targetname)\n{\n\tgentity_t\t*ent = NULL;\n\tint\t\tnum_choices = 0;\n\tgentity_t\t*choice[MAXCHOICES];\n\n\tif (!targetname)\n\t{\n\t\tG_Printf(\"G_PickTarget called with NULL targetname\\n\");\n\t\treturn NULL;\n\t}\n\n\twhile(1)\n\t{\n\t\tent = G_Find (ent, FOFS(targetname), targetname);\n\t\tif (!ent)\n\t\t\tbreak;\n\t\tchoice[num_choices++] = ent;\n\t\tif (num_choices == MAXCHOICES)\n\t\t\tbreak;\n\t}\n\n\tif (!num_choices)\n\t{\n\t\tG_Printf(\"G_PickTarget: target %s not found\\n\", targetname);\n\t\treturn NULL;\n\t}\n\n\treturn choice[rand() % num_choices];\n}\n\n\n/*\n==============================\nG_UseTargets\n\n\"activator\" should be set to the entity that initiated the firing.\n\nSearch for (string)targetname in all entities that\nmatch (string)self.target and call their .use function\n\n==============================\n*/\nvoid G_UseTargets( gentity_t *ent, gentity_t *activator ) {\n\tgentity_t\t\t*t;\n\t\n\tif ( !ent ) {\n\t\treturn;\n\t}\n\n\tif (ent->targetShaderName && ent->targetShaderNewName) {\n\t\tfloat f = level.time * 0.001;\n\t\tAddRemap(ent->targetShaderName, ent->targetShaderNewName, f);\n\t\ttrap_SetConfigstring(CS_SHADERSTATE, BuildShaderStateConfig());\n\t}\n\n\tif ( !ent->target ) {\n\t\treturn;\n\t}\n\n\tt = NULL;\n\twhile ( (t = G_Find (t, FOFS(targetname), ent->target)) != NULL ) {\n\t\tif ( t == ent ) {\n\t\t\tG_Printf (\"WARNING: Entity used itself.\\n\");\n\t\t} else {\n\t\t\tif ( t->use ) {\n\t\t\t\tt->use (t, ent, activator);\n\t\t\t}\n\t\t}\n\t\tif ( !ent->inuse ) {\n\t\t\tG_Printf(\"entity was removed while using targets\\n\");\n\t\t\treturn;\n\t\t}\n\t}\n}\n\n\n/*\n=============\nTempVector\n\nThis is just a convenience function\nfor making temporary vectors for function calls\n=============\n*/\nfloat\t*tv( float x, float y, float z ) {\n\tstatic\tint\t\tindex;\n\tstatic\tvec3_t\tvecs[8];\n\tfloat\t*v;\n\n\t// use an array so that multiple tempvectors won't collide\n\t// for a while\n\tv = vecs[index];\n\tindex = (index + 1)&7;\n\n\tv[0] = x;\n\tv[1] = y;\n\tv[2] = z;\n\n\treturn v;\n}\n\n\n/*\n=============\nVectorToString\n\nThis is just a convenience function\nfor printing vectors\n=============\n*/\nchar\t*vtos( const vec3_t v ) {\n\tstatic\tint\t\tindex;\n\tstatic\tchar\tstr[8][32];\n\tchar\t*s;\n\n\t// use an array so that multiple vtos won't collide\n\ts = str[index];\n\tindex = (index + 1)&7;\n\n\tCom_sprintf (s, 32, \"(%i %i %i)\", (int)v[0], (int)v[1], (int)v[2]);\n\n\treturn s;\n}\n\n\n/*\n===============\nG_SetMovedir\n\nThe editor only specifies a single value for angles (yaw),\nbut we have special constants to generate an up or down direction.\nAngles will be cleared, because it is being used to represent a direction\ninstead of an orientation.\n===============\n*/\nvoid G_SetMovedir( vec3_t angles, vec3_t movedir ) {\n\tstatic vec3_t VEC_UP\t\t= {0, -1, 0};\n\tstatic vec3_t MOVEDIR_UP\t= {0, 0, 1};\n\tstatic vec3_t VEC_DOWN\t\t= {0, -2, 0};\n\tstatic vec3_t MOVEDIR_DOWN\t= {0, 0, -1};\n\n\tif ( VectorCompare (angles, VEC_UP) ) {\n\t\tVectorCopy (MOVEDIR_UP, movedir);\n\t} else if ( VectorCompare (angles, VEC_DOWN) ) {\n\t\tVectorCopy (MOVEDIR_DOWN, movedir);\n\t} else {\n\t\tAngleVectors (angles, movedir, NULL, NULL);\n\t}\n\tVectorClear( angles );\n}\n\n\nfloat vectoyaw( const vec3_t vec ) {\n\tfloat\tyaw;\n\t\n\tif (vec[YAW] == 0 && vec[PITCH] == 0) {\n\t\tyaw = 0;\n\t} else {\n\t\tif (vec[PITCH]) {\n\t\t\tyaw = ( atan2( vec[YAW], vec[PITCH]) * 180 / M_PI );\n\t\t} else if (vec[YAW] > 0) {\n\t\t\tyaw = 90;\n\t\t} else {\n\t\t\tyaw = 270;\n\t\t}\n\t\tif (yaw < 0) {\n\t\t\tyaw += 360;\n\t\t}\n\t}\n\n\treturn yaw;\n}\n\n\nvoid G_InitGentity( gentity_t *e ) {\n\te->inuse = qtrue;\n\te->classname = \"noclass\";\n\te->s.number = e - g_entities;\n\te->r.ownerNum = ENTITYNUM_NONE;\n}\n\n/*\n=================\nG_Spawn\n\nEither finds a free entity, or allocates a new one.\n\n  The slots from 0 to MAX_CLIENTS-1 are always reserved for clients, and will\nnever be used by anything else.\n\nTry to avoid reusing an entity that was recently freed, because it\ncan cause the client to think the entity morphed into something else\ninstead of being removed and recreated, which can cause interpolated\nangles and bad trails.\n=================\n*/\ngentity_t *G_Spawn( void ) {\n\tint\t\t\ti, force;\n\tgentity_t\t*e;\n\n\te = NULL;\t// shut up warning\n\ti = 0;\t\t// shut up warning\n\tfor ( force = 0 ; force < 2 ; force++ ) {\n\t\t// if we go through all entities and can't find one to free,\n\t\t// override the normal minimum times before use\n\t\te = &g_entities[MAX_CLIENTS];\n\t\tfor ( i = MAX_CLIENTS ; i<level.num_entities ; i++, e++) {\n\t\t\tif ( e->inuse ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// the first couple seconds of server time can involve a lot of\n\t\t\t// freeing and allocating, so relax the replacement policy\n\t\t\tif ( !force && e->freetime > level.startTime + 2000 && level.time - e->freetime < 1000 ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// reuse this slot\n\t\t\tG_InitGentity( e );\n\t\t\treturn e;\n\t\t}\n\t\tif ( i != MAX_GENTITIES ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif ( i == ENTITYNUM_MAX_NORMAL ) {\n\t\tfor (i = 0; i < MAX_GENTITIES; i++) {\n\t\t\tG_Printf(\"%4i: %s\\n\", i, g_entities[i].classname);\n\t\t}\n\t\tG_Error( \"G_Spawn: no free entities\" );\n\t}\n\t\n\t// open up a new slot\n\tlevel.num_entities++;\n\n\t// let the server system know that there are more entities\n\ttrap_LocateGameData( level.gentities, level.num_entities, sizeof( gentity_t ), \n\t\t&level.clients[0].ps, sizeof( level.clients[0] ) );\n\n\tG_InitGentity( e );\n\treturn e;\n}\n\n/*\n=================\nG_EntitiesFree\n=================\n*/\nqboolean G_EntitiesFree( void ) {\n\tint\t\t\ti;\n\tgentity_t\t*e;\n\n\te = &g_entities[MAX_CLIENTS];\n\tfor ( i = MAX_CLIENTS; i < level.num_entities; i++, e++) {\n\t\tif ( e->inuse ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// slot available\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n\n/*\n=================\nG_FreeEntity\n\nMarks the entity as free\n=================\n*/\nvoid G_FreeEntity( gentity_t *ed ) {\n\ttrap_UnlinkEntity (ed);\t\t// unlink from world\n\n\tif ( ed->neverFree ) {\n\t\treturn;\n\t}\n\n\tmemset (ed, 0, sizeof(*ed));\n\ted->classname = \"freed\";\n\ted->freetime = level.time;\n\ted->inuse = qfalse;\n}\n\n/*\n=================\nG_TempEntity\n\nSpawns an event entity that will be auto-removed\nThe origin will be snapped to save net bandwidth, so care\nmust be taken if the origin is right on a surface (snap towards start vector first)\n=================\n*/\ngentity_t *G_TempEntity( vec3_t origin, int event ) {\n\tgentity_t\t\t*e;\n\tvec3_t\t\tsnapped;\n\n\te = G_Spawn();\n\te->s.eType = ET_EVENTS + event;\n\n\te->classname = \"tempEntity\";\n\te->eventTime = level.time;\n\te->freeAfterEvent = qtrue;\n\n\tVectorCopy( origin, snapped );\n\tSnapVector( snapped );\t\t// save network bandwidth\n\tG_SetOrigin( e, snapped );\n\n\t// find cluster for PVS\n\ttrap_LinkEntity( e );\n\n\treturn e;\n}\n\n\n\n/*\n==============================================================================\n\nKill box\n\n==============================================================================\n*/\n\n/*\n=================\nG_KillBox\n\nKills all entities that would touch the proposed new positioning\nof ent.  Ent should be unlinked before calling this!\n=================\n*/\nvoid G_KillBox (gentity_t *ent) {\n\tint\t\t\ti, num;\n\tint\t\t\ttouch[MAX_GENTITIES];\n\tgentity_t\t*hit;\n\tvec3_t\t\tmins, maxs;\n\n\tVectorAdd( ent->client->ps.origin, ent->r.mins, mins );\n\tVectorAdd( ent->client->ps.origin, ent->r.maxs, maxs );\n\tnum = trap_EntitiesInBox( mins, maxs, touch, MAX_GENTITIES );\n\n\tfor (i=0 ; i<num ; i++) {\n\t\thit = &g_entities[touch[i]];\n\t\tif ( !hit->client ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// nail it\n\t\tG_Damage ( hit, ent, ent, NULL, NULL,\n\t\t\t100000, DAMAGE_NO_PROTECTION, MOD_TELEFRAG);\n\t}\n\n}\n\n//==============================================================================\n\n/*\n===============\nG_AddPredictableEvent\n\nUse for non-pmove events that would also be predicted on the\nclient side: jumppads and item pickups\nAdds an event+parm and twiddles the event counter\n===============\n*/\nvoid G_AddPredictableEvent( gentity_t *ent, int event, int eventParm ) {\n\tif ( !ent->client ) {\n\t\treturn;\n\t}\n\tBG_AddPredictableEventToPlayerstate( event, eventParm, &ent->client->ps );\n}\n\n\n/*\n===============\nG_AddEvent\n\nAdds an event+parm and twiddles the event counter\n===============\n*/\nvoid G_AddEvent( gentity_t *ent, int event, int eventParm ) {\n\tint\t\tbits;\n\n\tif ( !event ) {\n\t\tG_Printf( \"G_AddEvent: zero event added for entity %i\\n\", ent->s.number );\n\t\treturn;\n\t}\n\n\t// clients need to add the event in playerState_t instead of entityState_t\n\tif ( ent->client ) {\n\t\tbits = ent->client->ps.externalEvent & EV_EVENT_BITS;\n\t\tbits = ( bits + EV_EVENT_BIT1 ) & EV_EVENT_BITS;\n\t\tent->client->ps.externalEvent = event | bits;\n\t\tent->client->ps.externalEventParm = eventParm;\n\t\tent->client->ps.externalEventTime = level.time;\n\t} else {\n\t\tbits = ent->s.event & EV_EVENT_BITS;\n\t\tbits = ( bits + EV_EVENT_BIT1 ) & EV_EVENT_BITS;\n\t\tent->s.event = event | bits;\n\t\tent->s.eventParm = eventParm;\n\t}\n\tent->eventTime = level.time;\n}\n\n\n/*\n=============\nG_Sound\n=============\n*/\nvoid G_Sound( gentity_t *ent, int channel, int soundIndex ) {\n\tgentity_t\t*te;\n\n\tte = G_TempEntity( ent->r.currentOrigin, EV_GENERAL_SOUND );\n\tte->s.eventParm = soundIndex;\n}\n\n\n//==============================================================================\n\n\n/*\n================\nG_SetOrigin\n\nSets the pos trajectory for a fixed position\n================\n*/\nvoid G_SetOrigin( gentity_t *ent, vec3_t origin ) {\n\tVectorCopy( origin, ent->s.pos.trBase );\n\tent->s.pos.trType = TR_STATIONARY;\n\tent->s.pos.trTime = 0;\n\tent->s.pos.trDuration = 0;\n\tVectorClear( ent->s.pos.trDelta );\n\n\tVectorCopy( origin, ent->r.currentOrigin );\n}\n\n/*\n================\nDebugLine\n\n  debug polygons only work when running a local game\n  with r_debugSurface set to 2\n================\n*/\nint DebugLine(vec3_t start, vec3_t end, int color) {\n\tvec3_t points[4], dir, cross, up = {0, 0, 1};\n\tfloat dot;\n\n\tVectorCopy(start, points[0]);\n\tVectorCopy(start, points[1]);\n\t//points[1][2] -= 2;\n\tVectorCopy(end, points[2]);\n\t//points[2][2] -= 2;\n\tVectorCopy(end, points[3]);\n\n\n\tVectorSubtract(end, start, dir);\n\tVectorNormalize(dir);\n\tdot = DotProduct(dir, up);\n\tif (dot > 0.99 || dot < -0.99) VectorSet(cross, 1, 0, 0);\n\telse CrossProduct(dir, up, cross);\n\n\tVectorNormalize(cross);\n\n\tVectorMA(points[0], 2, cross, points[0]);\n\tVectorMA(points[1], -2, cross, points[1]);\n\tVectorMA(points[2], -2, cross, points[2]);\n\tVectorMA(points[3], 2, cross, points[3]);\n\n\treturn trap_DebugPolygonCreate(color, 4, points);\n}\n"
  },
  {
    "path": "code/game/g_weapon.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// g_weapon.c \n// perform the server side effects of a weapon firing\n\n#include \"g_local.h\"\n\nstatic\tfloat\ts_quadFactor;\nstatic\tvec3_t\tforward, right, up;\nstatic\tvec3_t\tmuzzle;\n\n#define NUM_NAILSHOTS 15\n\n/*\n================\nG_BounceProjectile\n================\n*/\nvoid G_BounceProjectile( vec3_t start, vec3_t impact, vec3_t dir, vec3_t endout ) {\n\tvec3_t v, newv;\n\tfloat dot;\n\n\tVectorSubtract( impact, start, v );\n\tdot = DotProduct( v, dir );\n\tVectorMA( v, -2*dot, dir, newv );\n\n\tVectorNormalize(newv);\n\tVectorMA(impact, 8192, newv, endout);\n}\n\n\n/*\n======================================================================\n\nGAUNTLET\n\n======================================================================\n*/\n\nvoid Weapon_Gauntlet( gentity_t *ent ) {\n\n}\n\n/*\n===============\nCheckGauntletAttack\n===============\n*/\nqboolean CheckGauntletAttack( gentity_t *ent ) {\n\ttrace_t\t\ttr;\n\tvec3_t\t\tend;\n\tgentity_t\t*tent;\n\tgentity_t\t*traceEnt;\n\tint\t\t\tdamage;\n\n\t// set aiming directions\n\tAngleVectors (ent->client->ps.viewangles, forward, right, up);\n\n\tCalcMuzzlePoint ( ent, forward, right, up, muzzle );\n\n\tVectorMA (muzzle, 32, forward, end);\n\n\ttrap_Trace (&tr, muzzle, NULL, NULL, end, ent->s.number, MASK_SHOT);\n\tif ( tr.surfaceFlags & SURF_NOIMPACT ) {\n\t\treturn qfalse;\n\t}\n\n\ttraceEnt = &g_entities[ tr.entityNum ];\n\n\t// send blood impact\n\tif ( traceEnt->takedamage && traceEnt->client ) {\n\t\ttent = G_TempEntity( tr.endpos, EV_MISSILE_HIT );\n\t\ttent->s.otherEntityNum = traceEnt->s.number;\n\t\ttent->s.eventParm = DirToByte( tr.plane.normal );\n\t\ttent->s.weapon = ent->s.weapon;\n\t}\n\n\tif ( !traceEnt->takedamage) {\n\t\treturn qfalse;\n\t}\n\n\tif (ent->client->ps.powerups[PW_QUAD] ) {\n\t\tG_AddEvent( ent, EV_POWERUP_QUAD, 0 );\n\t\ts_quadFactor = g_quadfactor.value;\n\t} else {\n\t\ts_quadFactor = 1;\n\t}\n#ifdef MISSIONPACK\n\tif( ent->client->persistantPowerup && ent->client->persistantPowerup->item && ent->client->persistantPowerup->item->giTag == PW_DOUBLER ) {\n\t\ts_quadFactor *= 2;\n\t}\n#endif\n\n\tdamage = 50 * s_quadFactor;\n\tG_Damage( traceEnt, ent, ent, forward, tr.endpos,\n\t\tdamage, 0, MOD_GAUNTLET );\n\n\treturn qtrue;\n}\n\n\n/*\n======================================================================\n\nMACHINEGUN\n\n======================================================================\n*/\n\n/*\n======================\nSnapVectorTowards\n\nRound a vector to integers for more efficient network\ntransmission, but make sure that it rounds towards a given point\nrather than blindly truncating.  This prevents it from truncating \ninto a wall.\n======================\n*/\nvoid SnapVectorTowards( vec3_t v, vec3_t to ) {\n\tint\t\ti;\n\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tif ( to[i] <= v[i] ) {\n\t\t\tv[i] = (int)v[i];\n\t\t} else {\n\t\t\tv[i] = (int)v[i] + 1;\n\t\t}\n\t}\n}\n\n#ifdef MISSIONPACK\n#define CHAINGUN_SPREAD\t\t600\n#endif\n#define MACHINEGUN_SPREAD\t200\n#define\tMACHINEGUN_DAMAGE\t7\n#define\tMACHINEGUN_TEAM_DAMAGE\t5\t\t// wimpier MG in teamplay\n\nvoid Bullet_Fire (gentity_t *ent, float spread, int damage ) {\n\ttrace_t\t\ttr;\n\tvec3_t\t\tend;\n#ifdef MISSIONPACK\n\tvec3_t\t\timpactpoint, bouncedir;\n#endif\n\tfloat\t\tr;\n\tfloat\t\tu;\n\tgentity_t\t*tent;\n\tgentity_t\t*traceEnt;\n\tint\t\t\ti, passent;\n\n\tdamage *= s_quadFactor;\n\n\tr = random() * M_PI * 2.0f;\n\tu = sin(r) * crandom() * spread * 16;\n\tr = cos(r) * crandom() * spread * 16;\n\tVectorMA (muzzle, 8192*16, forward, end);\n\tVectorMA (end, r, right, end);\n\tVectorMA (end, u, up, end);\n\n\tpassent = ent->s.number;\n\tfor (i = 0; i < 10; i++) {\n\n\t\ttrap_Trace (&tr, muzzle, NULL, NULL, end, passent, MASK_SHOT);\n\t\tif ( tr.surfaceFlags & SURF_NOIMPACT ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttraceEnt = &g_entities[ tr.entityNum ];\n\n\t\t// snap the endpos to integers, but nudged towards the line\n\t\tSnapVectorTowards( tr.endpos, muzzle );\n\n\t\t// send bullet impact\n\t\tif ( traceEnt->takedamage && traceEnt->client ) {\n\t\t\ttent = G_TempEntity( tr.endpos, EV_BULLET_HIT_FLESH );\n\t\t\ttent->s.eventParm = traceEnt->s.number;\n\t\t\tif( LogAccuracyHit( traceEnt, ent ) ) {\n\t\t\t\tent->client->accuracy_hits++;\n\t\t\t}\n\t\t} else {\n\t\t\ttent = G_TempEntity( tr.endpos, EV_BULLET_HIT_WALL );\n\t\t\ttent->s.eventParm = DirToByte( tr.plane.normal );\n\t\t}\n\t\ttent->s.otherEntityNum = ent->s.number;\n\n\t\tif ( traceEnt->takedamage) {\n#ifdef MISSIONPACK\n\t\t\tif ( traceEnt->client && traceEnt->client->invulnerabilityTime > level.time ) {\n\t\t\t\tif (G_InvulnerabilityEffect( traceEnt, forward, tr.endpos, impactpoint, bouncedir )) {\n\t\t\t\t\tG_BounceProjectile( muzzle, impactpoint, bouncedir, end );\n\t\t\t\t\tVectorCopy( impactpoint, muzzle );\n\t\t\t\t\t// the player can hit him/herself with the bounced rail\n\t\t\t\t\tpassent = ENTITYNUM_NONE;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tVectorCopy( tr.endpos, muzzle );\n\t\t\t\t\tpassent = traceEnt->s.number;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse {\n#endif\n\t\t\t\tG_Damage( traceEnt, ent, ent, forward, tr.endpos,\n\t\t\t\t\tdamage, 0, MOD_MACHINEGUN);\n#ifdef MISSIONPACK\n\t\t\t}\n#endif\n\t\t}\n\t\tbreak;\n\t}\n}\n\n\n/*\n======================================================================\n\nBFG\n\n======================================================================\n*/\n\nvoid BFG_Fire ( gentity_t *ent ) {\n\tgentity_t\t*m;\n\n\tm = fire_bfg (ent, muzzle, forward);\n\tm->damage *= s_quadFactor;\n\tm->splashDamage *= s_quadFactor;\n\n//\tVectorAdd( m->s.pos.trDelta, ent->client->ps.velocity, m->s.pos.trDelta );\t// \"real\" physics\n}\n\n\n/*\n======================================================================\n\nSHOTGUN\n\n======================================================================\n*/\n\n// DEFAULT_SHOTGUN_SPREAD and DEFAULT_SHOTGUN_COUNT\tare in bg_public.h, because\n// client predicts same spreads\n#define\tDEFAULT_SHOTGUN_DAMAGE\t10\n\nqboolean ShotgunPellet( vec3_t start, vec3_t end, gentity_t *ent ) {\n\ttrace_t\t\ttr;\n\tint\t\t\tdamage, i, passent;\n\tgentity_t\t*traceEnt;\n#ifdef MISSIONPACK\n\tvec3_t\t\timpactpoint, bouncedir;\n#endif\n\tvec3_t\t\ttr_start, tr_end;\n\n\tpassent = ent->s.number;\n\tVectorCopy( start, tr_start );\n\tVectorCopy( end, tr_end );\n\tfor (i = 0; i < 10; i++) {\n\t\ttrap_Trace (&tr, tr_start, NULL, NULL, tr_end, passent, MASK_SHOT);\n\t\ttraceEnt = &g_entities[ tr.entityNum ];\n\n\t\t// send bullet impact\n\t\tif (  tr.surfaceFlags & SURF_NOIMPACT ) {\n\t\t\treturn qfalse;\n\t\t}\n\n\t\tif ( traceEnt->takedamage) {\n\t\t\tdamage = DEFAULT_SHOTGUN_DAMAGE * s_quadFactor;\n#ifdef MISSIONPACK\n\t\t\tif ( traceEnt->client && traceEnt->client->invulnerabilityTime > level.time ) {\n\t\t\t\tif (G_InvulnerabilityEffect( traceEnt, forward, tr.endpos, impactpoint, bouncedir )) {\n\t\t\t\t\tG_BounceProjectile( tr_start, impactpoint, bouncedir, tr_end );\n\t\t\t\t\tVectorCopy( impactpoint, tr_start );\n\t\t\t\t\t// the player can hit him/herself with the bounced rail\n\t\t\t\t\tpassent = ENTITYNUM_NONE;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tVectorCopy( tr.endpos, tr_start );\n\t\t\t\t\tpassent = traceEnt->s.number;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tG_Damage( traceEnt, ent, ent, forward, tr.endpos,\n\t\t\t\t\tdamage, 0, MOD_SHOTGUN);\n\t\t\t\tif( LogAccuracyHit( traceEnt, ent ) ) {\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n\t\t\t}\n#else\n\t\t\tG_Damage( traceEnt, ent, ent, forward, tr.endpos,\tdamage, 0, MOD_SHOTGUN);\n\t\t\t\tif( LogAccuracyHit( traceEnt, ent ) ) {\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n#endif\n\t\t}\n\t\treturn qfalse;\n\t}\n\treturn qfalse;\n}\n\n// this should match CG_ShotgunPattern\nvoid ShotgunPattern( vec3_t origin, vec3_t origin2, int seed, gentity_t *ent ) {\n\tint\t\t\ti;\n\tfloat\t\tr, u;\n\tvec3_t\t\tend;\n\tvec3_t\t\tforward, right, up;\n\tint\t\t\toldScore;\n\tqboolean\thitClient = qfalse;\n\n\t// derive the right and up vectors from the forward vector, because\n\t// the client won't have any other information\n\tVectorNormalize2( origin2, forward );\n\tPerpendicularVector( right, forward );\n\tCrossProduct( forward, right, up );\n\n\toldScore = ent->client->ps.persistant[PERS_SCORE];\n\n\t// generate the \"random\" spread pattern\n\tfor ( i = 0 ; i < DEFAULT_SHOTGUN_COUNT ; i++ ) {\n\t\tr = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * 16;\n\t\tu = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * 16;\n\t\tVectorMA( origin, 8192 * 16, forward, end);\n\t\tVectorMA (end, r, right, end);\n\t\tVectorMA (end, u, up, end);\n\t\tif( ShotgunPellet( origin, end, ent ) && !hitClient ) {\n\t\t\thitClient = qtrue;\n\t\t\tent->client->accuracy_hits++;\n\t\t}\n\t}\n}\n\n\nvoid weapon_supershotgun_fire (gentity_t *ent) {\n\tgentity_t\t\t*tent;\n\n\t// send shotgun blast\n\ttent = G_TempEntity( muzzle, EV_SHOTGUN );\n\tVectorScale( forward, 4096, tent->s.origin2 );\n\tSnapVector( tent->s.origin2 );\n\ttent->s.eventParm = rand() & 255;\t\t// seed for spread pattern\n\ttent->s.otherEntityNum = ent->s.number;\n\n\tShotgunPattern( tent->s.pos.trBase, tent->s.origin2, tent->s.eventParm, ent );\n}\n\n\n/*\n======================================================================\n\nGRENADE LAUNCHER\n\n======================================================================\n*/\n\nvoid weapon_grenadelauncher_fire (gentity_t *ent) {\n\tgentity_t\t*m;\n\n\t// extra vertical velocity\n\tforward[2] += 0.2f;\n\tVectorNormalize( forward );\n\n\tm = fire_grenade (ent, muzzle, forward);\n\tm->damage *= s_quadFactor;\n\tm->splashDamage *= s_quadFactor;\n\n//\tVectorAdd( m->s.pos.trDelta, ent->client->ps.velocity, m->s.pos.trDelta );\t// \"real\" physics\n}\n\n/*\n======================================================================\n\nROCKET\n\n======================================================================\n*/\n\nvoid Weapon_RocketLauncher_Fire (gentity_t *ent) {\n\tgentity_t\t*m;\n\n\tm = fire_rocket (ent, muzzle, forward);\n\tm->damage *= s_quadFactor;\n\tm->splashDamage *= s_quadFactor;\n\n//\tVectorAdd( m->s.pos.trDelta, ent->client->ps.velocity, m->s.pos.trDelta );\t// \"real\" physics\n}\n\n\n/*\n======================================================================\n\nPLASMA GUN\n\n======================================================================\n*/\n\nvoid Weapon_Plasmagun_Fire (gentity_t *ent) {\n\tgentity_t\t*m;\n\n\tm = fire_plasma (ent, muzzle, forward);\n\tm->damage *= s_quadFactor;\n\tm->splashDamage *= s_quadFactor;\n\n//\tVectorAdd( m->s.pos.trDelta, ent->client->ps.velocity, m->s.pos.trDelta );\t// \"real\" physics\n}\n\n/*\n======================================================================\n\nRAILGUN\n\n======================================================================\n*/\n\n\n/*\n=================\nweapon_railgun_fire\n=================\n*/\n#define\tMAX_RAIL_HITS\t4\nvoid weapon_railgun_fire (gentity_t *ent) {\n\tvec3_t\t\tend;\n#ifdef MISSIONPACK\n\tvec3_t impactpoint, bouncedir;\n#endif\n\ttrace_t\t\ttrace;\n\tgentity_t\t*tent;\n\tgentity_t\t*traceEnt;\n\tint\t\t\tdamage;\n\tint\t\t\ti;\n\tint\t\t\thits;\n\tint\t\t\tunlinked;\n\tint\t\t\tpassent;\n\tgentity_t\t*unlinkedEntities[MAX_RAIL_HITS];\n\n\tdamage = 100 * s_quadFactor;\n\n\tVectorMA (muzzle, 8192, forward, end);\n\n\t// trace only against the solids, so the railgun will go through people\n\tunlinked = 0;\n\thits = 0;\n\tpassent = ent->s.number;\n\tdo {\n\t\ttrap_Trace (&trace, muzzle, NULL, NULL, end, passent, MASK_SHOT );\n\t\tif ( trace.entityNum >= ENTITYNUM_MAX_NORMAL ) {\n\t\t\tbreak;\n\t\t}\n\t\ttraceEnt = &g_entities[ trace.entityNum ];\n\t\tif ( traceEnt->takedamage ) {\n#ifdef MISSIONPACK\n\t\t\tif ( traceEnt->client && traceEnt->client->invulnerabilityTime > level.time ) {\n\t\t\t\tif ( G_InvulnerabilityEffect( traceEnt, forward, trace.endpos, impactpoint, bouncedir ) ) {\n\t\t\t\t\tG_BounceProjectile( muzzle, impactpoint, bouncedir, end );\n\t\t\t\t\t// snap the endpos to integers to save net bandwidth, but nudged towards the line\n\t\t\t\t\tSnapVectorTowards( trace.endpos, muzzle );\n\t\t\t\t\t// send railgun beam effect\n\t\t\t\t\ttent = G_TempEntity( trace.endpos, EV_RAILTRAIL );\n\t\t\t\t\t// set player number for custom colors on the railtrail\n\t\t\t\t\ttent->s.clientNum = ent->s.clientNum;\n\t\t\t\t\tVectorCopy( muzzle, tent->s.origin2 );\n\t\t\t\t\t// move origin a bit to come closer to the drawn gun muzzle\n\t\t\t\t\tVectorMA( tent->s.origin2, 4, right, tent->s.origin2 );\n\t\t\t\t\tVectorMA( tent->s.origin2, -1, up, tent->s.origin2 );\n\t\t\t\t\ttent->s.eventParm = 255;\t// don't make the explosion at the end\n\t\t\t\t\t//\n\t\t\t\t\tVectorCopy( impactpoint, muzzle );\n\t\t\t\t\t// the player can hit him/herself with the bounced rail\n\t\t\t\t\tpassent = ENTITYNUM_NONE;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif( LogAccuracyHit( traceEnt, ent ) ) {\n\t\t\t\t\thits++;\n\t\t\t\t}\n\t\t\t\tG_Damage (traceEnt, ent, ent, forward, trace.endpos, damage, 0, MOD_RAILGUN);\n\t\t\t}\n#else\n\t\t\t\tif( LogAccuracyHit( traceEnt, ent ) ) {\n\t\t\t\t\thits++;\n\t\t\t\t}\n\t\t\t\tG_Damage (traceEnt, ent, ent, forward, trace.endpos, damage, 0, MOD_RAILGUN);\n#endif\n\t\t}\n\t\tif ( trace.contents & CONTENTS_SOLID ) {\n\t\t\tbreak;\t\t// we hit something solid enough to stop the beam\n\t\t}\n\t\t// unlink this entity, so the next trace will go past it\n\t\ttrap_UnlinkEntity( traceEnt );\n\t\tunlinkedEntities[unlinked] = traceEnt;\n\t\tunlinked++;\n\t} while ( unlinked < MAX_RAIL_HITS );\n\n\t// link back in any entities we unlinked\n\tfor ( i = 0 ; i < unlinked ; i++ ) {\n\t\ttrap_LinkEntity( unlinkedEntities[i] );\n\t}\n\n\t// the final trace endpos will be the terminal point of the rail trail\n\n\t// snap the endpos to integers to save net bandwidth, but nudged towards the line\n\tSnapVectorTowards( trace.endpos, muzzle );\n\n\t// send railgun beam effect\n\ttent = G_TempEntity( trace.endpos, EV_RAILTRAIL );\n\n\t// set player number for custom colors on the railtrail\n\ttent->s.clientNum = ent->s.clientNum;\n\n\tVectorCopy( muzzle, tent->s.origin2 );\n\t// move origin a bit to come closer to the drawn gun muzzle\n\tVectorMA( tent->s.origin2, 4, right, tent->s.origin2 );\n\tVectorMA( tent->s.origin2, -1, up, tent->s.origin2 );\n\n\t// no explosion at end if SURF_NOIMPACT, but still make the trail\n\tif ( trace.surfaceFlags & SURF_NOIMPACT ) {\n\t\ttent->s.eventParm = 255;\t// don't make the explosion at the end\n\t} else {\n\t\ttent->s.eventParm = DirToByte( trace.plane.normal );\n\t}\n\ttent->s.clientNum = ent->s.clientNum;\n\n\t// give the shooter a reward sound if they have made two railgun hits in a row\n\tif ( hits == 0 ) {\n\t\t// complete miss\n\t\tent->client->accurateCount = 0;\n\t} else {\n\t\t// check for \"impressive\" reward sound\n\t\tent->client->accurateCount += hits;\n\t\tif ( ent->client->accurateCount >= 2 ) {\n\t\t\tent->client->accurateCount -= 2;\n\t\t\tent->client->ps.persistant[PERS_IMPRESSIVE_COUNT]++;\n\t\t\t// add the sprite over the player's head\n\t\t\tent->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );\n\t\t\tent->client->ps.eFlags |= EF_AWARD_IMPRESSIVE;\n\t\t\tent->client->rewardTime = level.time + REWARD_SPRITE_TIME;\n\t\t}\n\t\tent->client->accuracy_hits++;\n\t}\n\n}\n\n\n/*\n======================================================================\n\nGRAPPLING HOOK\n\n======================================================================\n*/\n\nvoid Weapon_GrapplingHook_Fire (gentity_t *ent)\n{\n\tif (!ent->client->fireHeld && !ent->client->hook)\n\t\tfire_grapple (ent, muzzle, forward);\n\n\tent->client->fireHeld = qtrue;\n}\n\nvoid Weapon_HookFree (gentity_t *ent)\n{\n\tent->parent->client->hook = NULL;\n\tent->parent->client->ps.pm_flags &= ~PMF_GRAPPLE_PULL;\n\tG_FreeEntity( ent );\n}\n\nvoid Weapon_HookThink (gentity_t *ent)\n{\n\tif (ent->enemy) {\n\t\tvec3_t v, oldorigin;\n\n\t\tVectorCopy(ent->r.currentOrigin, oldorigin);\n\t\tv[0] = ent->enemy->r.currentOrigin[0] + (ent->enemy->r.mins[0] + ent->enemy->r.maxs[0]) * 0.5;\n\t\tv[1] = ent->enemy->r.currentOrigin[1] + (ent->enemy->r.mins[1] + ent->enemy->r.maxs[1]) * 0.5;\n\t\tv[2] = ent->enemy->r.currentOrigin[2] + (ent->enemy->r.mins[2] + ent->enemy->r.maxs[2]) * 0.5;\n\t\tSnapVectorTowards( v, oldorigin );\t// save net bandwidth\n\n\t\tG_SetOrigin( ent, v );\n\t}\n\n\tVectorCopy( ent->r.currentOrigin, ent->parent->client->ps.grapplePoint);\n}\n\n/*\n======================================================================\n\nLIGHTNING GUN\n\n======================================================================\n*/\n\nvoid Weapon_LightningFire( gentity_t *ent ) {\n\ttrace_t\t\ttr;\n\tvec3_t\t\tend;\n#ifdef MISSIONPACK\n\tvec3_t impactpoint, bouncedir;\n#endif\n\tgentity_t\t*traceEnt, *tent;\n\tint\t\t\tdamage, i, passent;\n\n\tdamage = 8 * s_quadFactor;\n\n\tpassent = ent->s.number;\n\tfor (i = 0; i < 10; i++) {\n\t\tVectorMA( muzzle, LIGHTNING_RANGE, forward, end );\n\n\t\ttrap_Trace( &tr, muzzle, NULL, NULL, end, passent, MASK_SHOT );\n\n#ifdef MISSIONPACK\n\t\t// if not the first trace (the lightning bounced of an invulnerability sphere)\n\t\tif (i) {\n\t\t\t// add bounced off lightning bolt temp entity\n\t\t\t// the first lightning bolt is a cgame only visual\n\t\t\t//\n\t\t\ttent = G_TempEntity( muzzle, EV_LIGHTNINGBOLT );\n\t\t\tVectorCopy( tr.endpos, end );\n\t\t\tSnapVector( end );\n\t\t\tVectorCopy( end, tent->s.origin2 );\n\t\t}\n#endif\n\t\tif ( tr.entityNum == ENTITYNUM_NONE ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttraceEnt = &g_entities[ tr.entityNum ];\n\n\t\tif ( traceEnt->takedamage) {\n#ifdef MISSIONPACK\n\t\t\tif ( traceEnt->client && traceEnt->client->invulnerabilityTime > level.time ) {\n\t\t\t\tif (G_InvulnerabilityEffect( traceEnt, forward, tr.endpos, impactpoint, bouncedir )) {\n\t\t\t\t\tG_BounceProjectile( muzzle, impactpoint, bouncedir, end );\n\t\t\t\t\tVectorCopy( impactpoint, muzzle );\n\t\t\t\t\tVectorSubtract( end, impactpoint, forward );\n\t\t\t\t\tVectorNormalize(forward);\n\t\t\t\t\t// the player can hit him/herself with the bounced lightning\n\t\t\t\t\tpassent = ENTITYNUM_NONE;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tVectorCopy( tr.endpos, muzzle );\n\t\t\t\t\tpassent = traceEnt->s.number;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tG_Damage( traceEnt, ent, ent, forward, tr.endpos,\n\t\t\t\t\tdamage, 0, MOD_LIGHTNING);\n\t\t\t}\n#else\n\t\t\t\tG_Damage( traceEnt, ent, ent, forward, tr.endpos,\n\t\t\t\t\tdamage, 0, MOD_LIGHTNING);\n#endif\n\t\t}\n\n\t\tif ( traceEnt->takedamage && traceEnt->client ) {\n\t\t\ttent = G_TempEntity( tr.endpos, EV_MISSILE_HIT );\n\t\t\ttent->s.otherEntityNum = traceEnt->s.number;\n\t\t\ttent->s.eventParm = DirToByte( tr.plane.normal );\n\t\t\ttent->s.weapon = ent->s.weapon;\n\t\t\tif( LogAccuracyHit( traceEnt, ent ) ) {\n\t\t\t\tent->client->accuracy_hits++;\n\t\t\t}\n\t\t} else if ( !( tr.surfaceFlags & SURF_NOIMPACT ) ) {\n\t\t\ttent = G_TempEntity( tr.endpos, EV_MISSILE_MISS );\n\t\t\ttent->s.eventParm = DirToByte( tr.plane.normal );\n\t\t}\n\n\t\tbreak;\n\t}\n}\n\n#ifdef MISSIONPACK\n/*\n======================================================================\n\nNAILGUN\n\n======================================================================\n*/\n\nvoid Weapon_Nailgun_Fire (gentity_t *ent) {\n\tgentity_t\t*m;\n\tint\t\t\tcount;\n\n\tfor( count = 0; count < NUM_NAILSHOTS; count++ ) {\n\t\tm = fire_nail (ent, muzzle, forward, right, up );\n\t\tm->damage *= s_quadFactor;\n\t\tm->splashDamage *= s_quadFactor;\n\t}\n\n//\tVectorAdd( m->s.pos.trDelta, ent->client->ps.velocity, m->s.pos.trDelta );\t// \"real\" physics\n}\n\n\n/*\n======================================================================\n\nPROXIMITY MINE LAUNCHER\n\n======================================================================\n*/\n\nvoid weapon_proxlauncher_fire (gentity_t *ent) {\n\tgentity_t\t*m;\n\n\t// extra vertical velocity\n\tforward[2] += 0.2f;\n\tVectorNormalize( forward );\n\n\tm = fire_prox (ent, muzzle, forward);\n\tm->damage *= s_quadFactor;\n\tm->splashDamage *= s_quadFactor;\n\n//\tVectorAdd( m->s.pos.trDelta, ent->client->ps.velocity, m->s.pos.trDelta );\t// \"real\" physics\n}\n\n#endif\n\n//======================================================================\n\n\n/*\n===============\nLogAccuracyHit\n===============\n*/\nqboolean LogAccuracyHit( gentity_t *target, gentity_t *attacker ) {\n\tif( !target->takedamage ) {\n\t\treturn qfalse;\n\t}\n\n\tif ( target == attacker ) {\n\t\treturn qfalse;\n\t}\n\n\tif( !target->client ) {\n\t\treturn qfalse;\n\t}\n\n\tif( !attacker->client ) {\n\t\treturn qfalse;\n\t}\n\n\tif( target->client->ps.stats[STAT_HEALTH] <= 0 ) {\n\t\treturn qfalse;\n\t}\n\n\tif ( OnSameTeam( target, attacker ) ) {\n\t\treturn qfalse;\n\t}\n\n\treturn qtrue;\n}\n\n\n/*\n===============\nCalcMuzzlePoint\n\nset muzzle location relative to pivoting eye\n===============\n*/\nvoid CalcMuzzlePoint ( gentity_t *ent, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint ) {\n\tVectorCopy( ent->s.pos.trBase, muzzlePoint );\n\tmuzzlePoint[2] += ent->client->ps.viewheight;\n\tVectorMA( muzzlePoint, 14, forward, muzzlePoint );\n\t// snap to integer coordinates for more efficient network bandwidth usage\n\tSnapVector( muzzlePoint );\n}\n\n/*\n===============\nCalcMuzzlePointOrigin\n\nset muzzle location relative to pivoting eye\n===============\n*/\nvoid CalcMuzzlePointOrigin ( gentity_t *ent, vec3_t origin, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint ) {\n\tVectorCopy( ent->s.pos.trBase, muzzlePoint );\n\tmuzzlePoint[2] += ent->client->ps.viewheight;\n\tVectorMA( muzzlePoint, 14, forward, muzzlePoint );\n\t// snap to integer coordinates for more efficient network bandwidth usage\n\tSnapVector( muzzlePoint );\n}\n\n\n\n/*\n===============\nFireWeapon\n===============\n*/\nvoid FireWeapon( gentity_t *ent ) {\n\tif (ent->client->ps.powerups[PW_QUAD] ) {\n\t\ts_quadFactor = g_quadfactor.value;\n\t} else {\n\t\ts_quadFactor = 1;\n\t}\n#ifdef MISSIONPACK\n\tif( ent->client->persistantPowerup && ent->client->persistantPowerup->item && ent->client->persistantPowerup->item->giTag == PW_DOUBLER ) {\n\t\ts_quadFactor *= 2;\n\t}\n#endif\n\n\t// track shots taken for accuracy tracking.  Grapple is not a weapon and gauntet is just not tracked\n\tif( ent->s.weapon != WP_GRAPPLING_HOOK && ent->s.weapon != WP_GAUNTLET ) {\n#ifdef MISSIONPACK\n\t\tif( ent->s.weapon == WP_NAILGUN ) {\n\t\t\tent->client->accuracy_shots += NUM_NAILSHOTS;\n\t\t} else {\n\t\t\tent->client->accuracy_shots++;\n\t\t}\n#else\n\t\tent->client->accuracy_shots++;\n#endif\n\t}\n\n\t// set aiming directions\n\tAngleVectors (ent->client->ps.viewangles, forward, right, up);\n\n\tCalcMuzzlePointOrigin ( ent, ent->client->oldOrigin, forward, right, up, muzzle );\n\n\t// fire the specific weapon\n\tswitch( ent->s.weapon ) {\n\tcase WP_GAUNTLET:\n\t\tWeapon_Gauntlet( ent );\n\t\tbreak;\n\tcase WP_LIGHTNING:\n\t\tWeapon_LightningFire( ent );\n\t\tbreak;\n\tcase WP_SHOTGUN:\n\t\tweapon_supershotgun_fire( ent );\n\t\tbreak;\n\tcase WP_MACHINEGUN:\n\t\tif ( g_gametype.integer != GT_TEAM ) {\n\t\t\tBullet_Fire( ent, MACHINEGUN_SPREAD, MACHINEGUN_DAMAGE );\n\t\t} else {\n\t\t\tBullet_Fire( ent, MACHINEGUN_SPREAD, MACHINEGUN_TEAM_DAMAGE );\n\t\t}\n\t\tbreak;\n\tcase WP_GRENADE_LAUNCHER:\n\t\tweapon_grenadelauncher_fire( ent );\n\t\tbreak;\n\tcase WP_ROCKET_LAUNCHER:\n\t\tWeapon_RocketLauncher_Fire( ent );\n\t\tbreak;\n\tcase WP_PLASMAGUN:\n\t\tWeapon_Plasmagun_Fire( ent );\n\t\tbreak;\n\tcase WP_RAILGUN:\n\t\tweapon_railgun_fire( ent );\n\t\tbreak;\n\tcase WP_BFG:\n\t\tBFG_Fire( ent );\n\t\tbreak;\n\tcase WP_GRAPPLING_HOOK:\n\t\tWeapon_GrapplingHook_Fire( ent );\n\t\tbreak;\n#ifdef MISSIONPACK\n\tcase WP_NAILGUN:\n\t\tWeapon_Nailgun_Fire( ent );\n\t\tbreak;\n\tcase WP_PROX_LAUNCHER:\n\t\tweapon_proxlauncher_fire( ent );\n\t\tbreak;\n\tcase WP_CHAINGUN:\n\t\tBullet_Fire( ent, CHAINGUN_SPREAD, MACHINEGUN_DAMAGE );\n\t\tbreak;\n#endif\n\tdefault:\n// FIXME\t\tG_Error( \"Bad ent->s.weapon\" );\n\t\tbreak;\n\t}\n}\n\n\n#ifdef MISSIONPACK\n\n/*\n===============\nKamikazeRadiusDamage\n===============\n*/\nstatic void KamikazeRadiusDamage( vec3_t origin, gentity_t *attacker, float damage, float radius ) {\n\tfloat\t\tdist;\n\tgentity_t\t*ent;\n\tint\t\t\tentityList[MAX_GENTITIES];\n\tint\t\t\tnumListedEntities;\n\tvec3_t\t\tmins, maxs;\n\tvec3_t\t\tv;\n\tvec3_t\t\tdir;\n\tint\t\t\ti, e;\n\n\tif ( radius < 1 ) {\n\t\tradius = 1;\n\t}\n\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tmins[i] = origin[i] - radius;\n\t\tmaxs[i] = origin[i] + radius;\n\t}\n\n\tnumListedEntities = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES );\n\n\tfor ( e = 0 ; e < numListedEntities ; e++ ) {\n\t\tent = &g_entities[entityList[ e ]];\n\n\t\tif (!ent->takedamage) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// dont hit things we have already hit\n\t\tif( ent->kamikazeTime > level.time ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// find the distance from the edge of the bounding box\n\t\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\t\tif ( origin[i] < ent->r.absmin[i] ) {\n\t\t\t\tv[i] = ent->r.absmin[i] - origin[i];\n\t\t\t} else if ( origin[i] > ent->r.absmax[i] ) {\n\t\t\t\tv[i] = origin[i] - ent->r.absmax[i];\n\t\t\t} else {\n\t\t\t\tv[i] = 0;\n\t\t\t}\n\t\t}\n\n\t\tdist = VectorLength( v );\n\t\tif ( dist >= radius ) {\n\t\t\tcontinue;\n\t\t}\n\n//\t\tif( CanDamage (ent, origin) ) {\n\t\t\tVectorSubtract (ent->r.currentOrigin, origin, dir);\n\t\t\t// push the center of mass higher than the origin so players\n\t\t\t// get knocked into the air more\n\t\t\tdir[2] += 24;\n\t\t\tG_Damage( ent, NULL, attacker, dir, origin, damage, DAMAGE_RADIUS|DAMAGE_NO_TEAM_PROTECTION, MOD_KAMIKAZE );\n\t\t\tent->kamikazeTime = level.time + 3000;\n//\t\t}\n\t}\n}\n\n/*\n===============\nKamikazeShockWave\n===============\n*/\nstatic void KamikazeShockWave( vec3_t origin, gentity_t *attacker, float damage, float push, float radius ) {\n\tfloat\t\tdist;\n\tgentity_t\t*ent;\n\tint\t\t\tentityList[MAX_GENTITIES];\n\tint\t\t\tnumListedEntities;\n\tvec3_t\t\tmins, maxs;\n\tvec3_t\t\tv;\n\tvec3_t\t\tdir;\n\tint\t\t\ti, e;\n\n\tif ( radius < 1 )\n\t\tradius = 1;\n\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tmins[i] = origin[i] - radius;\n\t\tmaxs[i] = origin[i] + radius;\n\t}\n\n\tnumListedEntities = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES );\n\n\tfor ( e = 0 ; e < numListedEntities ; e++ ) {\n\t\tent = &g_entities[entityList[ e ]];\n\n\t\t// dont hit things we have already hit\n\t\tif( ent->kamikazeShockTime > level.time ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// find the distance from the edge of the bounding box\n\t\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\t\tif ( origin[i] < ent->r.absmin[i] ) {\n\t\t\t\tv[i] = ent->r.absmin[i] - origin[i];\n\t\t\t} else if ( origin[i] > ent->r.absmax[i] ) {\n\t\t\t\tv[i] = origin[i] - ent->r.absmax[i];\n\t\t\t} else {\n\t\t\t\tv[i] = 0;\n\t\t\t}\n\t\t}\n\n\t\tdist = VectorLength( v );\n\t\tif ( dist >= radius ) {\n\t\t\tcontinue;\n\t\t}\n\n//\t\tif( CanDamage (ent, origin) ) {\n\t\t\tVectorSubtract (ent->r.currentOrigin, origin, dir);\n\t\t\tdir[2] += 24;\n\t\t\tG_Damage( ent, NULL, attacker, dir, origin, damage, DAMAGE_RADIUS|DAMAGE_NO_TEAM_PROTECTION, MOD_KAMIKAZE );\n\t\t\t//\n\t\t\tdir[2] = 0;\n\t\t\tVectorNormalize(dir);\n\t\t\tif ( ent->client ) {\n\t\t\t\tent->client->ps.velocity[0] = dir[0] * push;\n\t\t\t\tent->client->ps.velocity[1] = dir[1] * push;\n\t\t\t\tent->client->ps.velocity[2] = 100;\n\t\t\t}\n\t\t\tent->kamikazeShockTime = level.time + 3000;\n//\t\t}\n\t}\n}\n\n/*\n===============\nKamikazeDamage\n===============\n*/\nstatic void KamikazeDamage( gentity_t *self ) {\n\tint i;\n\tfloat t;\n\tgentity_t *ent;\n\tvec3_t newangles;\n\n\tself->count += 100;\n\n\tif (self->count >= KAMI_SHOCKWAVE_STARTTIME) {\n\t\t// shockwave push back\n\t\tt = self->count - KAMI_SHOCKWAVE_STARTTIME;\n\t\tKamikazeShockWave(self->s.pos.trBase, self->activator, 25, 400,\t(int) (float) t * KAMI_SHOCKWAVE_MAXRADIUS / (KAMI_SHOCKWAVE_ENDTIME - KAMI_SHOCKWAVE_STARTTIME) );\n\t}\n\t//\n\tif (self->count >= KAMI_EXPLODE_STARTTIME) {\n\t\t// do our damage\n\t\tt = self->count - KAMI_EXPLODE_STARTTIME;\n\t\tKamikazeRadiusDamage( self->s.pos.trBase, self->activator, 400,\t(int) (float) t * KAMI_BOOMSPHERE_MAXRADIUS / (KAMI_IMPLODE_STARTTIME - KAMI_EXPLODE_STARTTIME) );\n\t}\n\n\t// either cycle or kill self\n\tif( self->count >= KAMI_SHOCKWAVE_ENDTIME ) {\n\t\tG_FreeEntity( self );\n\t\treturn;\n\t}\n\tself->nextthink = level.time + 100;\n\n\t// add earth quake effect\n\tnewangles[0] = crandom() * 2;\n\tnewangles[1] = crandom() * 2;\n\tnewangles[2] = 0;\n\tfor (i = 0; i < MAX_CLIENTS; i++)\n\t{\n\t\tent = &g_entities[i];\n\t\tif (!ent->inuse)\n\t\t\tcontinue;\n\t\tif (!ent->client)\n\t\t\tcontinue;\n\n\t\tif (ent->client->ps.groundEntityNum != ENTITYNUM_NONE) {\n\t\t\tent->client->ps.velocity[0] += crandom() * 120;\n\t\t\tent->client->ps.velocity[1] += crandom() * 120;\n\t\t\tent->client->ps.velocity[2] = 30 + random() * 25;\n\t\t}\n\n\t\tent->client->ps.delta_angles[0] += ANGLE2SHORT(newangles[0] - self->movedir[0]);\n\t\tent->client->ps.delta_angles[1] += ANGLE2SHORT(newangles[1] - self->movedir[1]);\n\t\tent->client->ps.delta_angles[2] += ANGLE2SHORT(newangles[2] - self->movedir[2]);\n\t}\n\tVectorCopy(newangles, self->movedir);\n}\n\n/*\n===============\nG_StartKamikaze\n===============\n*/\nvoid G_StartKamikaze( gentity_t *ent ) {\n\tgentity_t\t*explosion;\n\tgentity_t\t*te;\n\tvec3_t\t\tsnapped;\n\n\t// start up the explosion logic\n\texplosion = G_Spawn();\n\n\texplosion->s.eType = ET_EVENTS + EV_KAMIKAZE;\n\texplosion->eventTime = level.time;\n\n\tif ( ent->client ) {\n\t\tVectorCopy( ent->s.pos.trBase, snapped );\n\t}\n\telse {\n\t\tVectorCopy( ent->activator->s.pos.trBase, snapped );\n\t}\n\tSnapVector( snapped );\t\t// save network bandwidth\n\tG_SetOrigin( explosion, snapped );\n\n\texplosion->classname = \"kamikaze\";\n\texplosion->s.pos.trType = TR_STATIONARY;\n\n\texplosion->kamikazeTime = level.time;\n\n\texplosion->think = KamikazeDamage;\n\texplosion->nextthink = level.time + 100;\n\texplosion->count = 0;\n\tVectorClear(explosion->movedir);\n\n\ttrap_LinkEntity( explosion );\n\n\tif (ent->client) {\n\t\t//\n\t\texplosion->activator = ent;\n\t\t//\n\t\tent->s.eFlags &= ~EF_KAMIKAZE;\n\t\t// nuke the guy that used it\n\t\tG_Damage( ent, ent, ent, NULL, NULL, 100000, DAMAGE_NO_PROTECTION, MOD_KAMIKAZE );\n\t}\n\telse {\n\t\tif ( !strcmp(ent->activator->classname, \"bodyque\") ) {\n\t\t\texplosion->activator = &g_entities[ent->activator->r.ownerNum];\n\t\t}\n\t\telse {\n\t\t\texplosion->activator = ent->activator;\n\t\t}\n\t}\n\n\t// play global sound at all clients\n\tte = G_TempEntity(snapped, EV_GLOBAL_TEAM_SOUND );\n\tte->r.svFlags |= SVF_BROADCAST;\n\tte->s.eventParm = GTS_KAMIKAZE;\n}\n#endif\n"
  },
  {
    "path": "code/game/game.bat",
    "content": "rem make sure we have a safe environement\nset LIBRARY=\nset INCLUDE=\n\nmkdir vm\ncd vm\nset cc=lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\ui %1\n\n%cc%  ../g_main.c\n@if errorlevel 1 goto quit\n\n%cc%  ../g_syscalls.c\n@if errorlevel 1 goto quit\n\n%cc%  ../bg_misc.c\n@if errorlevel 1 goto quit\n%cc%  ../bg_lib.c\n@if errorlevel 1 goto quit\n%cc%  ../bg_pmove.c\n@if errorlevel 1 goto quit\n%cc%  ../bg_slidemove.c\n@if errorlevel 1 goto quit\n%cc%  ../q_math.c\n@if errorlevel 1 goto quit\n%cc%  ../q_shared.c\n@if errorlevel 1 goto quit\n\n%cc%  ../ai_dmnet.c\n@if errorlevel 1 goto quit\n%cc%  ../ai_dmq3.c\n@if errorlevel 1 goto quit\n%cc%  ../ai_main.c\n@if errorlevel 1 goto quit\n%cc%  ../ai_chat.c\n@if errorlevel 1 goto quit\n%cc%  ../ai_cmd.c\n@if errorlevel 1 goto quit\n%cc%  ../ai_team.c\n@if errorlevel 1 goto quit\n\n%cc%  ../g_active.c\n@if errorlevel 1 goto quit\n%cc%  ../g_arenas.c\n@if errorlevel 1 goto quit\n%cc%  ../g_bot.c\n@if errorlevel 1 goto quit\n%cc%  ../g_client.c\n@if errorlevel 1 goto quit\n%cc%  ../g_cmds.c\n@if errorlevel 1 goto quit\n%cc%  ../g_combat.c\n@if errorlevel 1 goto quit\n%cc%  ../g_items.c\n@if errorlevel 1 goto quit\n%cc%  ../g_mem.c\n@if errorlevel 1 goto quit\n%cc%  ../g_misc.c\n@if errorlevel 1 goto quit\n%cc%  ../g_missile.c\n@if errorlevel 1 goto quit\n%cc%  ../g_mover.c\n@if errorlevel 1 goto quit\n%cc%  ../g_session.c\n@if errorlevel 1 goto quit\n%cc%  ../g_spawn.c\n@if errorlevel 1 goto quit\n%cc%  ../g_svcmds.c\n@if errorlevel 1 goto quit\n%cc%  ../g_target.c\n@if errorlevel 1 goto quit\n%cc%  ../g_team.c\n@if errorlevel 1 goto quit\n%cc%  ../g_trigger.c\n@if errorlevel 1 goto quit\n%cc%  ../g_utils.c\n@if errorlevel 1 goto quit\n%cc%  ../g_weapon.c\n@if errorlevel 1 goto quit\n%cc%  ../ai_vcmd.c\n@if errorlevel 1 goto quit\n\n\nq3asm -f ../game\n:quit\ncd ..\n"
  },
  {
    "path": "code/game/game.def",
    "content": "EXPORTS\n\tdllEntry\n\tvmMain\n"
  },
  {
    "path": "code/game/game.q3asm",
    "content": "-o \"\\quake3\\baseq3\\vm\\qagame\"\ng_main\n..\\g_syscalls\nbg_misc\nbg_lib\nbg_pmove\nbg_slidemove\nq_math\nq_shared\nai_dmnet\nai_dmq3\nai_team\nai_main\nai_chat\nai_cmd\nai_vcmd\ng_active\ng_arenas\ng_bot\ng_client\ng_cmds\ng_combat\ng_items\ng_mem\ng_misc\ng_missile\ng_mover\ng_session\ng_spawn\ng_svcmds\ng_target\ng_team\ng_trigger\ng_utils\ng_weapon\n"
  },
  {
    "path": "code/game/game.sh",
    "content": "#!/bin/sh\n\nmkdir -p vm\ncd vm\n\nCC=\"q3lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I../../cgame -I../../game -I../../q3_ui\"\n\n$CC  ../g_main.c\n$CC  ../g_syscalls.c\n\n$CC  ../bg_misc.c\n$CC  ../bg_lib.c\n$CC  ../bg_pmove.c\n$CC  ../bg_slidemove.c\n$CC  ../q_math.c\n$CC  ../q_shared.c\n\n$CC  ../ai_vcmd.c\n$CC  ../ai_dmnet.c\n$CC  ../ai_dmq3.c\n$CC  ../ai_main.c\n$CC  ../ai_chat.c\n$CC  ../ai_cmd.c\n$CC  ../ai_team.c\n\n$CC  ../g_active.c\n$CC  ../g_arenas.c\n$CC  ../g_bot.c\n$CC  ../g_client.c\n$CC  ../g_cmds.c\n$CC  ../g_combat.c\n$CC  ../g_items.c\n$CC  ../g_mem.c\n$CC  ../g_misc.c\n$CC  ../g_missile.c\n$CC  ../g_mover.c\n$CC  ../g_session.c\n$CC  ../g_spawn.c\n$CC  ../g_svcmds.c\n$CC  ../g_target.c\n$CC  ../g_team.c\n$CC  ../g_trigger.c\n$CC  ../g_utils.c\n$CC  ../g_weapon.c\n\nq3asm -f ../game\n\ncd ..\n"
  },
  {
    "path": "code/game/game.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<VisualStudioProject\n\tProjectType=\"Visual C++\"\n\tVersion=\"7.10\"\n\tName=\"game\"\n\tSccProjectName=\"&quot;$/MissionPack/code/game&quot;, CYAAAAAA\"\n\tSccLocalPath=\".\">\n\t<Platforms>\n\t\t<Platform\n\t\t\tName=\"Win32\"/>\n\t</Platforms>\n\t<Configurations>\n\t\t<Configuration\n\t\t\tName=\"Debug TA|Win32\"\n\t\t\tOutputDirectory=\".\\Debug_TA\"\n\t\t\tIntermediateDirectory=\".\\Debug_TA\"\n\t\t\tConfigurationType=\"2\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tOptimizeForProcessor=\"1\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Debug_TA/game.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug_TA/\"\n\t\t\t\tObjectFile=\".\\Debug_TA/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Debug_TA/\"\n\t\t\t\tBrowseInformation=\"1\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"winmm.lib\"\n\t\t\t\tOutputFile=\"..\\Debug_TA\\qagamex86.dll\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tModuleDefinitionFile=\".\\game.def\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\Debug_TA/qagamex86.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\".\\Debug_TA/qagamex86.map\"\n\t\t\t\tSubSystem=\"2\"\n\t\t\t\tBaseAddress=\"0x20000000\"\n\t\t\t\tImportLibrary=\".\\Debug_TA/qagamex86.lib\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Debug_TA/game.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Debug|Win32\"\n\t\t\tOutputDirectory=\".\\Debug\"\n\t\t\tIntermediateDirectory=\".\\Debug\"\n\t\t\tConfigurationType=\"2\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tOptimizeForProcessor=\"1\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Debug/game.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug/\"\n\t\t\t\tObjectFile=\".\\Debug/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Debug/\"\n\t\t\t\tBrowseInformation=\"1\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"winmm.lib\"\n\t\t\t\tOutputFile=\"../Debug/qagamex86.dll\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tModuleDefinitionFile=\".\\game.def\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\Debug/qagamex86.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\".\\Debug/qagamex86.map\"\n\t\t\t\tSubSystem=\"2\"\n\t\t\t\tBaseAddress=\"0x20000000\"\n\t\t\t\tImportLibrary=\".\\Debug/qagamex86.lib\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Debug/game.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Release Alpha|Win32\"\n\t\t\tOutputDirectory=\".\\..\\ReleaseAXP\"\n\t\t\tIntermediateDirectory=\".\\ReleaseAXP\"\n\t\t\tConfigurationType=\"2\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tAdditionalOptions=\"/QA21164 \"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"4\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\ReleaseAXP/game.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\ReleaseAXP/\"\n\t\t\t\tObjectFile=\".\\ReleaseAXP/\"\n\t\t\t\tProgramDataBaseFileName=\".\\ReleaseAXP/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"2\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"winmm.lib\"\n\t\t\t\tOutputFile=\"..\\ReleaseAXP/qagameaxp.dll\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tModuleDefinitionFile=\".\\game.def\"\n\t\t\t\tProgramDatabaseFile=\".\\..\\ReleaseAXP/qagameaxp.pdb\"\n\t\t\t\tSubSystem=\"2\"\n\t\t\t\tBaseAddress=\"0x20000000\"\n\t\t\t\tImportLibrary=\".\\..\\ReleaseAXP/qagameaxp.lib\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\..\\ReleaseAXP/game.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Debug Alpha|Win32\"\n\t\t\tOutputDirectory=\".\\..\\DebugAxp\"\n\t\t\tIntermediateDirectory=\".\\DebugAxp\"\n\t\t\tConfigurationType=\"2\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tAdditionalOptions=\"/QA21164 /MTd \"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY\"\n\t\t\t\tRuntimeLibrary=\"5\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\DebugAxp/game.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\DebugAxp/\"\n\t\t\t\tObjectFile=\".\\DebugAxp/\"\n\t\t\t\tProgramDataBaseFileName=\".\\DebugAxp/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"3\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"winmm.lib\"\n\t\t\t\tOutputFile=\"..\\DebugAxp/qagameaxp.dll\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tModuleDefinitionFile=\".\\game.def\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\..\\DebugAxp/qagameaxp.pdb\"\n\t\t\t\tSubSystem=\"2\"\n\t\t\t\tBaseAddress=\"0x20000000\"\n\t\t\t\tImportLibrary=\".\\..\\DebugAxp/qagameaxp.lib\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\..\\DebugAxp/game.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Release|Win32\"\n\t\t\tOutputDirectory=\".\\Release\"\n\t\t\tIntermediateDirectory=\".\\Release\"\n\t\t\tConfigurationType=\"2\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tOptimizeForProcessor=\"2\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"4\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release/game.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release/\"\n\t\t\t\tObjectFile=\".\\Release/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release/\"\n\t\t\t\tWarningLevel=\"4\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"winmm.lib\"\n\t\t\t\tOutputFile=\"../Release/qagamex86.dll\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tModuleDefinitionFile=\".\\game.def\"\n\t\t\t\tProgramDatabaseFile=\".\\Release/qagamex86.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\".\\Release/qagamex86.map\"\n\t\t\t\tSubSystem=\"2\"\n\t\t\t\tBaseAddress=\"0x20000000\"\n\t\t\t\tImportLibrary=\".\\Release/qagamex86.lib\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Release/game.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Release TA|Win32\"\n\t\t\tOutputDirectory=\".\\Release_TA\"\n\t\t\tIntermediateDirectory=\".\\Release_TA\"\n\t\t\tConfigurationType=\"2\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tOptimizeForProcessor=\"2\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"4\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release_TA/game.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release_TA/\"\n\t\t\t\tObjectFile=\".\\Release_TA/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release_TA/\"\n\t\t\t\tWarningLevel=\"4\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"winmm.lib\"\n\t\t\t\tOutputFile=\"../Release_TA/qagamex86.dll\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tModuleDefinitionFile=\".\\game.def\"\n\t\t\t\tProgramDatabaseFile=\".\\Release_TA/qagamex86.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\".\\Release_TA/qagamex86.map\"\n\t\t\t\tSubSystem=\"2\"\n\t\t\t\tBaseAddress=\"0x20000000\"\n\t\t\t\tImportLibrary=\".\\Release_TA/qagamex86.lib\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Release_TA/game.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t</Configurations>\n\t<References>\n\t</References>\n\t<Files>\n\t\t<Filter\n\t\t\tName=\"Source Files\"\n\t\t\tFilter=\"cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"ai_chat.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ai_cmd.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ai_dmnet.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ai_dmq3.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ai_main.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ai_team.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ai_vcmd.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"bg_lib.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"bg_misc.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"bg_pmove.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"bg_slidemove.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_active.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_arenas.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_bot.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_client.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_cmds.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_combat.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_items.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_main.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_mem.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_misc.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_missile.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_mover.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_session.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_spawn.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_svcmds.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_syscalls.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_target.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_team.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_trigger.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_utils.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_weapon.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"game.def\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"q_math.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"q_shared.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;MISSIONPACK;QAGAME;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;BUILDING_REF_GL;DEBUG;GLOBALRANK;$(NoInherit)\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug Alpha|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;C_ONLY;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;GLOBALRANK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;MISSIONPACK;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Header Files\"\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;fi;fd\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"ai_chat.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ai_cmd.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ai_dmnet.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ai_dmq3.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ai_main.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ai_team.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ai_vcmd.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_aas.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_ai_char.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_ai_chat.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_ai_gen.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_ai_goal.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_ai_move.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_ai_weap.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"be_ea.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"bg_local.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"bg_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"botlib.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"chars.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_local.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"g_team.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"inv.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"match.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"q_shared.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"surfaceflags.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"syn.h\">\n\t\t\t</File>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Resource Files\"\n\t\t\tFilter=\"ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe\">\n\t\t</Filter>\n\t</Files>\n\t<Globals>\n\t</Globals>\n</VisualStudioProject>\n"
  },
  {
    "path": "code/game/game_ta.bat",
    "content": "rem make sure we have a safe environement\nset LIBRARY=\nset INCLUDE=\n\nmkdir vm\ncd vm\nset cc=lcc -DQ3_VM -DMISSIONPACK -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\ui %1\n\n%cc%  ../g_main.c\n@if errorlevel 1 goto quit\n\n%cc%  ../g_syscalls.c\n@if errorlevel 1 goto quit\n\n%cc%  ../bg_misc.c\n@if errorlevel 1 goto quit\n%cc%  ../bg_lib.c\n@if errorlevel 1 goto quit\n%cc%  ../bg_pmove.c\n@if errorlevel 1 goto quit\n%cc%  ../bg_slidemove.c\n@if errorlevel 1 goto quit\n%cc%  ../q_math.c\n@if errorlevel 1 goto quit\n%cc%  ../q_shared.c\n@if errorlevel 1 goto quit\n\n%cc%  ../ai_dmnet.c\n@if errorlevel 1 goto quit\n%cc%  ../ai_dmq3.c\n@if errorlevel 1 goto quit\n%cc%  ../ai_main.c\n@if errorlevel 1 goto quit\n%cc%  ../ai_chat.c\n@if errorlevel 1 goto quit\n%cc%  ../ai_cmd.c\n@if errorlevel 1 goto quit\n%cc%  ../ai_team.c\n@if errorlevel 1 goto quit\n\n%cc%  ../g_active.c\n@if errorlevel 1 goto quit\n%cc%  ../g_arenas.c\n@if errorlevel 1 goto quit\n%cc%  ../g_bot.c\n@if errorlevel 1 goto quit\n%cc%  ../g_client.c\n@if errorlevel 1 goto quit\n%cc%  ../g_cmds.c\n@if errorlevel 1 goto quit\n%cc%  ../g_combat.c\n@if errorlevel 1 goto quit\n%cc%  ../g_items.c\n@if errorlevel 1 goto quit\n%cc%  ../g_mem.c\n@if errorlevel 1 goto quit\n%cc%  ../g_misc.c\n@if errorlevel 1 goto quit\n%cc%  ../g_missile.c\n@if errorlevel 1 goto quit\n%cc%  ../g_mover.c\n@if errorlevel 1 goto quit\n%cc%  ../g_session.c\n@if errorlevel 1 goto quit\n%cc%  ../g_spawn.c\n@if errorlevel 1 goto quit\n%cc%  ../g_svcmds.c\n@if errorlevel 1 goto quit\n%cc%  ../g_target.c\n@if errorlevel 1 goto quit\n%cc%  ../g_team.c\n@if errorlevel 1 goto quit\n%cc%  ../g_trigger.c\n@if errorlevel 1 goto quit\n%cc%  ../g_utils.c\n@if errorlevel 1 goto quit\n%cc%  ../g_weapon.c\n@if errorlevel 1 goto quit\n%cc%  ../ai_vcmd.c\n@if errorlevel 1 goto quit\n\n\n\nq3asm -f ../game_ta\n:quit\ncd ..\n"
  },
  {
    "path": "code/game/game_ta.q3asm",
    "content": "-o \"\\quake3\\missionpack\\vm\\qagame\"\ng_main\n..\\g_syscalls\nbg_misc\nbg_lib\nbg_pmove\nbg_slidemove\nq_math\nq_shared\nai_dmnet\nai_dmq3\nai_team\nai_main\nai_chat\nai_cmd\ng_active\ng_arenas\ng_bot\ng_client\ng_cmds\ng_combat\ng_items\ng_mem\ng_misc\ng_missile\ng_mover\ng_session\ng_spawn\ng_svcmds\ng_target\ng_team\ng_trigger\ng_utils\ng_weapon\nai_vcmd\n"
  },
  {
    "path": "code/game/game_ta.sh",
    "content": "#!/bin/sh\n\nmkdir -p vm\ncd vm\n\nCC=\"q3lcc -DQ3_VM -DMISSIONPACK -S -Wf-target=bytecode -Wf-g -I../../cgame -I../../game -I../../ui\"\n\n$CC  ../g_main.c\n$CC  ../g_syscalls.c\n\n$CC  ../bg_misc.c\n$CC  ../bg_lib.c\n$CC  ../bg_pmove.c\n$CC  ../bg_slidemove.c\n$CC  ../q_math.c\n$CC  ../q_shared.c\n\n$CC  ../ai_vcmd.c\n$CC  ../ai_dmnet.c\n$CC  ../ai_dmq3.c\n$CC  ../ai_main.c\n$CC  ../ai_chat.c\n$CC  ../ai_cmd.c\n$CC  ../ai_team.c\n\n$CC  ../g_active.c\n$CC  ../g_arenas.c\n$CC  ../g_bot.c\n$CC  ../g_client.c\n$CC  ../g_cmds.c\n$CC  ../g_combat.c\n$CC  ../g_items.c\n$CC  ../g_mem.c\n$CC  ../g_misc.c\n$CC  ../g_missile.c\n$CC  ../g_mover.c\n$CC  ../g_session.c\n$CC  ../g_spawn.c\n$CC  ../g_svcmds.c\n$CC  ../g_target.c\n$CC  ../g_team.c\n$CC  ../g_trigger.c\n$CC  ../g_utils.c\n$CC  ../g_weapon.c\n\nq3asm -f ../game_ta\n\ncd ..\n"
  },
  {
    "path": "code/game/inv.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#define INVENTORY_NONE\t\t\t\t0\n//armor\n#define INVENTORY_ARMOR\t\t\t\t1\n//weapons\n#define INVENTORY_GAUNTLET\t\t\t4\n#define INVENTORY_SHOTGUN\t\t\t5\n#define INVENTORY_MACHINEGUN\t\t6\n#define INVENTORY_GRENADELAUNCHER\t7\n#define INVENTORY_ROCKETLAUNCHER\t8\n#define INVENTORY_LIGHTNING\t\t\t9\n#define INVENTORY_RAILGUN\t\t\t10\n#define INVENTORY_PLASMAGUN\t\t\t11\n#define INVENTORY_BFG10K\t\t\t13\n#define INVENTORY_GRAPPLINGHOOK\t\t14\n#define INVENTORY_NAILGUN\t\t\t15\n#define INVENTORY_PROXLAUNCHER\t\t16\n#define INVENTORY_CHAINGUN\t\t\t17\n//ammo\n#define INVENTORY_SHELLS\t\t\t18\n#define INVENTORY_BULLETS\t\t\t19\n#define INVENTORY_GRENADES\t\t\t20\n#define INVENTORY_CELLS\t\t\t\t21\n#define INVENTORY_LIGHTNINGAMMO\t\t22\n#define INVENTORY_ROCKETS\t\t\t23\n#define INVENTORY_SLUGS\t\t\t\t24\n#define INVENTORY_BFGAMMO\t\t\t25\n#define INVENTORY_NAILS\t\t\t\t26\n#define INVENTORY_MINES\t\t\t\t27\n#define INVENTORY_BELT\t\t\t\t28\n//powerups\n#define INVENTORY_HEALTH\t\t\t29\n#define INVENTORY_TELEPORTER\t\t30\n#define INVENTORY_MEDKIT\t\t\t31\n#define INVENTORY_KAMIKAZE\t\t\t32\n#define INVENTORY_PORTAL\t\t\t33\n#define INVENTORY_INVULNERABILITY\t34\n#define INVENTORY_QUAD\t\t\t\t35\n#define INVENTORY_ENVIRONMENTSUIT\t36\n#define INVENTORY_HASTE\t\t\t\t37\n#define INVENTORY_INVISIBILITY\t\t38\n#define INVENTORY_REGEN\t\t\t\t39\n#define INVENTORY_FLIGHT\t\t\t40\n#define INVENTORY_SCOUT\t\t\t\t41\n#define INVENTORY_GUARD\t\t\t\t42\n#define INVENTORY_DOUBLER\t\t\t43\n#define INVENTORY_AMMOREGEN\t\t\t44\n\n#define INVENTORY_REDFLAG\t\t\t45\n#define INVENTORY_BLUEFLAG\t\t\t46\n#define INVENTORY_NEUTRALFLAG\t\t47\n#define INVENTORY_REDCUBE\t\t\t48\n#define INVENTORY_BLUECUBE\t\t\t49\n//enemy stuff\n#define ENEMY_HORIZONTAL_DIST\t\t200\n#define ENEMY_HEIGHT\t\t\t\t201\n#define NUM_VISIBLE_ENEMIES\t\t\t202\n#define NUM_VISIBLE_TEAMMATES\t\t203\n\n// if running the mission pack\n#ifdef MISSIONPACK\n\n//#error \"running mission pack\"\n\n#endif\n\n//item numbers (make sure they are in sync with bg_itemlist in bg_misc.c)\n#define MODELINDEX_ARMORSHARD\t\t1\n#define MODELINDEX_ARMORCOMBAT\t\t2\n#define MODELINDEX_ARMORBODY\t\t3\n#define MODELINDEX_HEALTHSMALL\t\t4\n#define MODELINDEX_HEALTH\t\t\t5\n#define MODELINDEX_HEALTHLARGE\t\t6\n#define MODELINDEX_HEALTHMEGA\t\t7\n\n#define MODELINDEX_GAUNTLET\t\t\t8\n#define MODELINDEX_SHOTGUN\t\t\t9\n#define MODELINDEX_MACHINEGUN\t\t10\n#define MODELINDEX_GRENADELAUNCHER\t11\n#define MODELINDEX_ROCKETLAUNCHER\t12\n#define MODELINDEX_LIGHTNING\t\t13\n#define MODELINDEX_RAILGUN\t\t\t14\n#define MODELINDEX_PLASMAGUN\t\t15\n#define MODELINDEX_BFG10K\t\t\t16\n#define MODELINDEX_GRAPPLINGHOOK\t17\n\n#define MODELINDEX_SHELLS\t\t\t18\n#define MODELINDEX_BULLETS\t\t\t19\n#define MODELINDEX_GRENADES\t\t\t20\n#define MODELINDEX_CELLS\t\t\t21\n#define MODELINDEX_LIGHTNINGAMMO\t22\n#define MODELINDEX_ROCKETS\t\t\t23\n#define MODELINDEX_SLUGS\t\t\t24\n#define MODELINDEX_BFGAMMO\t\t\t25\n\n#define MODELINDEX_TELEPORTER\t\t26\n#define MODELINDEX_MEDKIT\t\t\t27\n#define MODELINDEX_QUAD\t\t\t\t28\n#define MODELINDEX_ENVIRONMENTSUIT\t29\n#define MODELINDEX_HASTE\t\t\t30\n#define MODELINDEX_INVISIBILITY\t\t31\n#define MODELINDEX_REGEN\t\t\t32\n#define MODELINDEX_FLIGHT\t\t\t33\n\n#define MODELINDEX_REDFLAG\t\t\t34\n#define MODELINDEX_BLUEFLAG\t\t\t35\n\n// mission pack only defines\n\n#define MODELINDEX_KAMIKAZE\t\t\t36\n#define MODELINDEX_PORTAL\t\t\t37\n#define MODELINDEX_INVULNERABILITY\t38\n\n#define MODELINDEX_NAILS\t\t\t39\n#define MODELINDEX_MINES\t\t\t40\n#define MODELINDEX_BELT\t\t\t\t41\n\n#define MODELINDEX_SCOUT\t\t\t42\n#define MODELINDEX_GUARD\t\t\t43\n#define MODELINDEX_DOUBLER\t\t\t44\n#define MODELINDEX_AMMOREGEN\t\t45\n\n#define MODELINDEX_NEUTRALFLAG\t\t46\n#define MODELINDEX_REDCUBE\t\t\t47\n#define MODELINDEX_BLUECUBE\t\t\t48\n\n#define MODELINDEX_NAILGUN\t\t\t49\n#define MODELINDEX_PROXLAUNCHER\t\t50\n#define MODELINDEX_CHAINGUN\t\t\t51\n\n\n//\n#define WEAPONINDEX_GAUNTLET\t\t\t1\n#define WEAPONINDEX_MACHINEGUN\t\t\t2\n#define WEAPONINDEX_SHOTGUN\t\t\t\t3\n#define WEAPONINDEX_GRENADE_LAUNCHER\t4\n#define WEAPONINDEX_ROCKET_LAUNCHER\t\t5\n#define WEAPONINDEX_LIGHTNING\t\t\t6\n#define WEAPONINDEX_RAILGUN\t\t\t\t7\n#define WEAPONINDEX_PLASMAGUN\t\t\t8\n#define WEAPONINDEX_BFG\t\t\t\t\t9\n#define WEAPONINDEX_GRAPPLING_HOOK\t\t10\n#define WEAPONINDEX_NAILGUN\t\t\t\t11\n#define WEAPONINDEX_PROXLAUNCHER\t\t12\n#define WEAPONINDEX_CHAINGUN\t\t\t13\n"
  },
  {
    "path": "code/game/match.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n// make sure this is the same character as we use in chats in g_cmd.c\n#define EC\t\"\\x19\"\n\n//match template contexts\n#define MTCONTEXT_MISC\t\t\t\t\t2\n#define MTCONTEXT_INITIALTEAMCHAT\t\t4\n#define MTCONTEXT_TIME\t\t\t\t\t8\n#define MTCONTEXT_TEAMMATE\t\t\t\t16\n#define MTCONTEXT_ADDRESSEE\t\t\t\t32\n#define MTCONTEXT_PATROLKEYAREA\t\t\t64\n#define MTCONTEXT_REPLYCHAT\t\t\t\t128\n#define MTCONTEXT_CTF\t\t\t\t\t256\n\n//message types\n#define MSG_NEWLEADER\t\t\t\t\t1\t\t//new leader\n#define MSG_ENTERGAME\t\t\t\t\t2\t\t//enter game message\n#define MSG_HELP\t\t\t\t\t\t3\t\t//help someone\n#define MSG_ACCOMPANY\t\t\t\t\t4\t\t//accompany someone\n#define MSG_DEFENDKEYAREA\t\t\t\t5\t\t//defend a key area\n#define MSG_RUSHBASE\t\t\t\t\t6\t\t//everyone rush to base\n#define MSG_GETFLAG\t\t\t\t\t\t7\t\t//get the enemy flag\n#define MSG_STARTTEAMLEADERSHIP\t\t\t8\t\t//someone wants to become the team leader\n#define MSG_STOPTEAMLEADERSHIP\t\t\t9\t\t//someone wants to stop being the team leader\n#define MSG_WHOISTEAMLAEDER\t\t\t\t10\t\t//who is the team leader\n#define MSG_WAIT\t\t\t\t\t\t11\t\t//wait for someone\n#define MSG_WHATAREYOUDOING\t\t\t\t12\t\t//what are you doing?\n#define MSG_JOINSUBTEAM\t\t\t\t\t13\t\t//join a sub-team\n#define MSG_LEAVESUBTEAM\t\t\t\t14\t\t//leave a sub-team\n#define MSG_CREATENEWFORMATION\t\t\t15\t\t//create a new formation\n#define MSG_FORMATIONPOSITION\t\t\t16\t\t//tell someone his/her position in a formation\n#define MSG_FORMATIONSPACE\t\t\t\t17\t\t//set the formation intervening space\n#define MSG_DOFORMATION\t\t\t\t\t18\t\t//form a known formation\n#define MSG_DISMISS\t\t\t\t\t\t19\t\t//dismiss commanded team mates\n#define MSG_CAMP\t\t\t\t\t\t20\t\t//camp somewhere\n#define MSG_CHECKPOINT\t\t\t\t\t21\t\t//remember a check point\n#define MSG_PATROL\t\t\t\t\t\t22\t\t//patrol between certain keypoints\n#define MSG_LEADTHEWAY\t\t\t\t\t23\t\t//lead the way\n#define MSG_GETITEM\t\t\t\t\t\t24\t\t//get an item\n#define MSG_KILL\t\t\t\t\t\t25\t\t//kill someone\n#define MSG_WHEREAREYOU\t\t\t\t\t26\t\t//where is someone\n#define MSG_RETURNFLAG\t\t\t\t\t27\t\t//return the flag\n#define MSG_WHATISMYCOMMAND\t\t\t\t28\t\t//ask the team leader what to do\n#define MSG_WHICHTEAM\t\t\t\t\t29\t\t//ask which team a bot is in\n#define MSG_TASKPREFERENCE\t\t\t\t30\t\t//tell your teamplay task preference\n#define MSG_ATTACKENEMYBASE\t\t\t\t31\t\t//attack the enemy base\n#define MSG_HARVEST\t\t\t\t\t\t32\t\t//go harvest\n#define MSG_SUICIDE\t\t\t\t\t\t33\t\t//order to suicide\n//\n#define MSG_ME\t\t\t\t\t\t\t100\n#define MSG_EVERYONE\t\t\t\t\t101\n#define MSG_MULTIPLENAMES\t\t\t\t102\n#define MSG_NAME\t\t\t\t\t\t103\n#define MSG_PATROLKEYAREA\t\t\t\t104\n#define MSG_MINUTES\t\t\t\t\t\t105\n#define MSG_SECONDS\t\t\t\t\t\t106\n#define MSG_FOREVER\t\t\t\t\t\t107\n#define MSG_FORALONGTIME\t\t\t\t108\n#define MSG_FORAWHILE\t\t\t\t\t109\n//\n#define MSG_CHATALL\t\t\t\t\t\t200\n#define MSG_CHATTEAM\t\t\t\t\t201\n#define MSG_CHATTELL\t\t\t\t\t202\n//\n#define MSG_CTF\t\t\t\t\t\t\t300\t\t//ctf message\n\n//command sub types\n#define ST_SOMEWHERE\t\t\t\t\t0\n#define ST_NEARITEM\t\t\t\t\t\t1\n#define ST_ADDRESSED\t\t\t\t\t2\n#define ST_METER\t\t\t\t\t\t4\n#define ST_FEET\t\t\t\t\t\t\t8\n#define ST_TIME\t\t\t\t\t\t\t16\n#define ST_HERE\t\t\t\t\t\t\t32\n#define ST_THERE\t\t\t\t\t\t64\n#define ST_I\t\t\t\t\t\t\t128\n#define ST_MORE\t\t\t\t\t\t\t256\n#define ST_BACK\t\t\t\t\t\t\t512\n#define ST_REVERSE\t\t\t\t\t\t1024\n#define ST_SOMEONE\t\t\t\t\t\t2048\n#define ST_GOTFLAG\t\t\t\t\t\t4096\n#define ST_CAPTUREDFLAG\t\t\t\t\t8192\n#define ST_RETURNEDFLAG\t\t\t\t\t16384\n#define ST_TEAM\t\t\t\t\t\t\t32768\n#define ST_1FCTFGOTFLAG\t\t\t\t\t65535\n//ctf task preferences\n#define ST_DEFENDER\t\t\t\t\t\t1\n#define ST_ATTACKER\t\t\t\t\t\t2\n#define ST_ROAMER\t\t\t\t\t\t4\n\n\n//word replacement variables\n#define THE_ENEMY\t\t\t\t\t\t7\n#define THE_TEAM\t\t\t\t\t\t7\n//team message variables\n#define NETNAME\t\t\t\t\t\t\t0\n#define PLACE\t\t\t\t\t\t\t1\n#define FLAG\t\t\t\t\t\t\t1\n#define MESSAGE\t\t\t\t\t\t\t2\n#define ADDRESSEE\t\t\t\t\t\t2\n#define ITEM\t\t\t\t\t\t\t3\n#define TEAMMATE\t\t\t\t\t\t4\n#define TEAMNAME\t\t\t\t\t\t4\n#define ENEMY\t\t\t\t\t\t\t4\n#define KEYAREA\t\t\t\t\t\t\t5\n#define FORMATION\t\t\t\t\t\t5\n#define POSITION\t\t\t\t\t\t5\n#define NUMBER\t\t\t\t\t\t\t5\n#define TIME\t\t\t\t\t\t\t6\n#define NAME\t\t\t\t\t\t\t6\n#define MORE\t\t\t\t\t\t\t6\n\n\n"
  },
  {
    "path": "code/game/q_math.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// q_math.c -- stateless support routines that are included in each code module\n#include \"q_shared.h\"\n\n\nvec3_t\tvec3_origin = {0,0,0};\nvec3_t\taxisDefault[3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };\n\n\nvec4_t\t\tcolorBlack\t= {0, 0, 0, 1};\nvec4_t\t\tcolorRed\t= {1, 0, 0, 1};\nvec4_t\t\tcolorGreen\t= {0, 1, 0, 1};\nvec4_t\t\tcolorBlue\t= {0, 0, 1, 1};\nvec4_t\t\tcolorYellow\t= {1, 1, 0, 1};\nvec4_t\t\tcolorMagenta= {1, 0, 1, 1};\nvec4_t\t\tcolorCyan\t= {0, 1, 1, 1};\nvec4_t\t\tcolorWhite\t= {1, 1, 1, 1};\nvec4_t\t\tcolorLtGrey\t= {0.75, 0.75, 0.75, 1};\nvec4_t\t\tcolorMdGrey\t= {0.5, 0.5, 0.5, 1};\nvec4_t\t\tcolorDkGrey\t= {0.25, 0.25, 0.25, 1};\n\nvec4_t\tg_color_table[8] =\n\t{\n\t{0.0, 0.0, 0.0, 1.0},\n\t{1.0, 0.0, 0.0, 1.0},\n\t{0.0, 1.0, 0.0, 1.0},\n\t{1.0, 1.0, 0.0, 1.0},\n\t{0.0, 0.0, 1.0, 1.0},\n\t{0.0, 1.0, 1.0, 1.0},\n\t{1.0, 0.0, 1.0, 1.0},\n\t{1.0, 1.0, 1.0, 1.0},\n\t};\n\n\nvec3_t\tbytedirs[NUMVERTEXNORMALS] =\n{\n{-0.525731f, 0.000000f, 0.850651f}, {-0.442863f, 0.238856f, 0.864188f}, \n{-0.295242f, 0.000000f, 0.955423f}, {-0.309017f, 0.500000f, 0.809017f}, \n{-0.162460f, 0.262866f, 0.951056f}, {0.000000f, 0.000000f, 1.000000f}, \n{0.000000f, 0.850651f, 0.525731f}, {-0.147621f, 0.716567f, 0.681718f}, \n{0.147621f, 0.716567f, 0.681718f}, {0.000000f, 0.525731f, 0.850651f}, \n{0.309017f, 0.500000f, 0.809017f}, {0.525731f, 0.000000f, 0.850651f}, \n{0.295242f, 0.000000f, 0.955423f}, {0.442863f, 0.238856f, 0.864188f}, \n{0.162460f, 0.262866f, 0.951056f}, {-0.681718f, 0.147621f, 0.716567f}, \n{-0.809017f, 0.309017f, 0.500000f},{-0.587785f, 0.425325f, 0.688191f}, \n{-0.850651f, 0.525731f, 0.000000f},{-0.864188f, 0.442863f, 0.238856f}, \n{-0.716567f, 0.681718f, 0.147621f},{-0.688191f, 0.587785f, 0.425325f}, \n{-0.500000f, 0.809017f, 0.309017f}, {-0.238856f, 0.864188f, 0.442863f}, \n{-0.425325f, 0.688191f, 0.587785f}, {-0.716567f, 0.681718f, -0.147621f}, \n{-0.500000f, 0.809017f, -0.309017f}, {-0.525731f, 0.850651f, 0.000000f}, \n{0.000000f, 0.850651f, -0.525731f}, {-0.238856f, 0.864188f, -0.442863f}, \n{0.000000f, 0.955423f, -0.295242f}, {-0.262866f, 0.951056f, -0.162460f}, \n{0.000000f, 1.000000f, 0.000000f}, {0.000000f, 0.955423f, 0.295242f}, \n{-0.262866f, 0.951056f, 0.162460f}, {0.238856f, 0.864188f, 0.442863f}, \n{0.262866f, 0.951056f, 0.162460f}, {0.500000f, 0.809017f, 0.309017f}, \n{0.238856f, 0.864188f, -0.442863f},{0.262866f, 0.951056f, -0.162460f}, \n{0.500000f, 0.809017f, -0.309017f},{0.850651f, 0.525731f, 0.000000f}, \n{0.716567f, 0.681718f, 0.147621f}, {0.716567f, 0.681718f, -0.147621f}, \n{0.525731f, 0.850651f, 0.000000f}, {0.425325f, 0.688191f, 0.587785f}, \n{0.864188f, 0.442863f, 0.238856f}, {0.688191f, 0.587785f, 0.425325f}, \n{0.809017f, 0.309017f, 0.500000f}, {0.681718f, 0.147621f, 0.716567f}, \n{0.587785f, 0.425325f, 0.688191f}, {0.955423f, 0.295242f, 0.000000f}, \n{1.000000f, 0.000000f, 0.000000f}, {0.951056f, 0.162460f, 0.262866f}, \n{0.850651f, -0.525731f, 0.000000f},{0.955423f, -0.295242f, 0.000000f}, \n{0.864188f, -0.442863f, 0.238856f}, {0.951056f, -0.162460f, 0.262866f}, \n{0.809017f, -0.309017f, 0.500000f}, {0.681718f, -0.147621f, 0.716567f}, \n{0.850651f, 0.000000f, 0.525731f}, {0.864188f, 0.442863f, -0.238856f}, \n{0.809017f, 0.309017f, -0.500000f}, {0.951056f, 0.162460f, -0.262866f}, \n{0.525731f, 0.000000f, -0.850651f}, {0.681718f, 0.147621f, -0.716567f}, \n{0.681718f, -0.147621f, -0.716567f},{0.850651f, 0.000000f, -0.525731f}, \n{0.809017f, -0.309017f, -0.500000f}, {0.864188f, -0.442863f, -0.238856f}, \n{0.951056f, -0.162460f, -0.262866f}, {0.147621f, 0.716567f, -0.681718f}, \n{0.309017f, 0.500000f, -0.809017f}, {0.425325f, 0.688191f, -0.587785f}, \n{0.442863f, 0.238856f, -0.864188f}, {0.587785f, 0.425325f, -0.688191f}, \n{0.688191f, 0.587785f, -0.425325f}, {-0.147621f, 0.716567f, -0.681718f}, \n{-0.309017f, 0.500000f, -0.809017f}, {0.000000f, 0.525731f, -0.850651f}, \n{-0.525731f, 0.000000f, -0.850651f}, {-0.442863f, 0.238856f, -0.864188f}, \n{-0.295242f, 0.000000f, -0.955423f}, {-0.162460f, 0.262866f, -0.951056f}, \n{0.000000f, 0.000000f, -1.000000f}, {0.295242f, 0.000000f, -0.955423f}, \n{0.162460f, 0.262866f, -0.951056f}, {-0.442863f, -0.238856f, -0.864188f}, \n{-0.309017f, -0.500000f, -0.809017f}, {-0.162460f, -0.262866f, -0.951056f}, \n{0.000000f, -0.850651f, -0.525731f}, {-0.147621f, -0.716567f, -0.681718f}, \n{0.147621f, -0.716567f, -0.681718f}, {0.000000f, -0.525731f, -0.850651f}, \n{0.309017f, -0.500000f, -0.809017f}, {0.442863f, -0.238856f, -0.864188f}, \n{0.162460f, -0.262866f, -0.951056f}, {0.238856f, -0.864188f, -0.442863f}, \n{0.500000f, -0.809017f, -0.309017f}, {0.425325f, -0.688191f, -0.587785f}, \n{0.716567f, -0.681718f, -0.147621f}, {0.688191f, -0.587785f, -0.425325f}, \n{0.587785f, -0.425325f, -0.688191f}, {0.000000f, -0.955423f, -0.295242f}, \n{0.000000f, -1.000000f, 0.000000f}, {0.262866f, -0.951056f, -0.162460f}, \n{0.000000f, -0.850651f, 0.525731f}, {0.000000f, -0.955423f, 0.295242f}, \n{0.238856f, -0.864188f, 0.442863f}, {0.262866f, -0.951056f, 0.162460f}, \n{0.500000f, -0.809017f, 0.309017f}, {0.716567f, -0.681718f, 0.147621f}, \n{0.525731f, -0.850651f, 0.000000f}, {-0.238856f, -0.864188f, -0.442863f}, \n{-0.500000f, -0.809017f, -0.309017f}, {-0.262866f, -0.951056f, -0.162460f}, \n{-0.850651f, -0.525731f, 0.000000f}, {-0.716567f, -0.681718f, -0.147621f}, \n{-0.716567f, -0.681718f, 0.147621f}, {-0.525731f, -0.850651f, 0.000000f}, \n{-0.500000f, -0.809017f, 0.309017f}, {-0.238856f, -0.864188f, 0.442863f}, \n{-0.262866f, -0.951056f, 0.162460f}, {-0.864188f, -0.442863f, 0.238856f}, \n{-0.809017f, -0.309017f, 0.500000f}, {-0.688191f, -0.587785f, 0.425325f}, \n{-0.681718f, -0.147621f, 0.716567f}, {-0.442863f, -0.238856f, 0.864188f}, \n{-0.587785f, -0.425325f, 0.688191f}, {-0.309017f, -0.500000f, 0.809017f}, \n{-0.147621f, -0.716567f, 0.681718f}, {-0.425325f, -0.688191f, 0.587785f}, \n{-0.162460f, -0.262866f, 0.951056f}, {0.442863f, -0.238856f, 0.864188f}, \n{0.162460f, -0.262866f, 0.951056f}, {0.309017f, -0.500000f, 0.809017f}, \n{0.147621f, -0.716567f, 0.681718f}, {0.000000f, -0.525731f, 0.850651f}, \n{0.425325f, -0.688191f, 0.587785f}, {0.587785f, -0.425325f, 0.688191f}, \n{0.688191f, -0.587785f, 0.425325f}, {-0.955423f, 0.295242f, 0.000000f}, \n{-0.951056f, 0.162460f, 0.262866f}, {-1.000000f, 0.000000f, 0.000000f}, \n{-0.850651f, 0.000000f, 0.525731f}, {-0.955423f, -0.295242f, 0.000000f}, \n{-0.951056f, -0.162460f, 0.262866f}, {-0.864188f, 0.442863f, -0.238856f}, \n{-0.951056f, 0.162460f, -0.262866f}, {-0.809017f, 0.309017f, -0.500000f}, \n{-0.864188f, -0.442863f, -0.238856f}, {-0.951056f, -0.162460f, -0.262866f}, \n{-0.809017f, -0.309017f, -0.500000f}, {-0.681718f, 0.147621f, -0.716567f}, \n{-0.681718f, -0.147621f, -0.716567f}, {-0.850651f, 0.000000f, -0.525731f}, \n{-0.688191f, 0.587785f, -0.425325f}, {-0.587785f, 0.425325f, -0.688191f}, \n{-0.425325f, 0.688191f, -0.587785f}, {-0.425325f, -0.688191f, -0.587785f}, \n{-0.587785f, -0.425325f, -0.688191f}, {-0.688191f, -0.587785f, -0.425325f}\n};\n\n//==============================================================\n\nint\t\tQ_rand( int *seed ) {\n\t*seed = (69069 * *seed + 1);\n\treturn *seed;\n}\n\nfloat\tQ_random( int *seed ) {\n\treturn ( Q_rand( seed ) & 0xffff ) / (float)0x10000;\n}\n\nfloat\tQ_crandom( int *seed ) {\n\treturn 2.0 * ( Q_random( seed ) - 0.5 );\n}\n\n#ifdef __LCC__\n\nint VectorCompare( const vec3_t v1, const vec3_t v2 ) {\n\tif (v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]) {\n\t\treturn 0;\n\t}\t\t\t\n\treturn 1;\n}\n\nvec_t VectorLength( const vec3_t v ) {\n\treturn (vec_t)sqrt (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);\n}\n\nvec_t VectorLengthSquared( const vec3_t v ) {\n\treturn (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);\n}\n\nvec_t Distance( const vec3_t p1, const vec3_t p2 ) {\n\tvec3_t\tv;\n\n\tVectorSubtract (p2, p1, v);\n\treturn VectorLength( v );\n}\n\nvec_t DistanceSquared( const vec3_t p1, const vec3_t p2 ) {\n\tvec3_t\tv;\n\n\tVectorSubtract (p2, p1, v);\n\treturn v[0]*v[0] + v[1]*v[1] + v[2]*v[2];\n}\n\n// fast vector normalize routine that does not check to make sure\n// that length != 0, nor does it return length, uses rsqrt approximation\nvoid VectorNormalizeFast( vec3_t v )\n{\n\tfloat ilength;\n\n\tilength = Q_rsqrt( DotProduct( v, v ) );\n\n\tv[0] *= ilength;\n\tv[1] *= ilength;\n\tv[2] *= ilength;\n}\n\nvoid VectorInverse( vec3_t v ){\n\tv[0] = -v[0];\n\tv[1] = -v[1];\n\tv[2] = -v[2];\n}\n\nvoid CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ) {\n\tcross[0] = v1[1]*v2[2] - v1[2]*v2[1];\n\tcross[1] = v1[2]*v2[0] - v1[0]*v2[2];\n\tcross[2] = v1[0]*v2[1] - v1[1]*v2[0];\n}\n#endif\n\n//=======================================================\n\nsigned char ClampChar( int i ) {\n\tif ( i < -128 ) {\n\t\treturn -128;\n\t}\n\tif ( i > 127 ) {\n\t\treturn 127;\n\t}\n\treturn i;\n}\n\nsigned short ClampShort( int i ) {\n\tif ( i < -32768 ) {\n\t\treturn -32768;\n\t}\n\tif ( i > 0x7fff ) {\n\t\treturn 0x7fff;\n\t}\n\treturn i;\n}\n\n\n// this isn't a real cheap function to call!\nint DirToByte( vec3_t dir ) {\n\tint\t\ti, best;\n\tfloat\td, bestd;\n\n\tif ( !dir ) {\n\t\treturn 0;\n\t}\n\n\tbestd = 0;\n\tbest = 0;\n\tfor (i=0 ; i<NUMVERTEXNORMALS ; i++)\n\t{\n\t\td = DotProduct (dir, bytedirs[i]);\n\t\tif (d > bestd)\n\t\t{\n\t\t\tbestd = d;\n\t\t\tbest = i;\n\t\t}\n\t}\n\n\treturn best;\n}\n\nvoid ByteToDir( int b, vec3_t dir ) {\n\tif ( b < 0 || b >= NUMVERTEXNORMALS ) {\n\t\tVectorCopy( vec3_origin, dir );\n\t\treturn;\n\t}\n\tVectorCopy (bytedirs[b], dir);\n}\n\n\nunsigned ColorBytes3 (float r, float g, float b) {\n\tunsigned\ti;\n\n\t( (byte *)&i )[0] = r * 255;\n\t( (byte *)&i )[1] = g * 255;\n\t( (byte *)&i )[2] = b * 255;\n\n\treturn i;\n}\n\nunsigned ColorBytes4 (float r, float g, float b, float a) {\n\tunsigned\ti;\n\n\t( (byte *)&i )[0] = r * 255;\n\t( (byte *)&i )[1] = g * 255;\n\t( (byte *)&i )[2] = b * 255;\n\t( (byte *)&i )[3] = a * 255;\n\n\treturn i;\n}\n\nfloat NormalizeColor( const vec3_t in, vec3_t out ) {\n\tfloat\tmax;\n\t\n\tmax = in[0];\n\tif ( in[1] > max ) {\n\t\tmax = in[1];\n\t}\n\tif ( in[2] > max ) {\n\t\tmax = in[2];\n\t}\n\n\tif ( !max ) {\n\t\tVectorClear( out );\n\t} else {\n\t\tout[0] = in[0] / max;\n\t\tout[1] = in[1] / max;\n\t\tout[2] = in[2] / max;\n\t}\n\treturn max;\n}\n\n\n/*\n=====================\nPlaneFromPoints\n\nReturns false if the triangle is degenrate.\nThe normal will point out of the clock for clockwise ordered points\n=====================\n*/\nqboolean PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const vec3_t c ) {\n\tvec3_t\td1, d2;\n\n\tVectorSubtract( b, a, d1 );\n\tVectorSubtract( c, a, d2 );\n\tCrossProduct( d2, d1, plane );\n\tif ( VectorNormalize( plane ) == 0 ) {\n\t\treturn qfalse;\n\t}\n\n\tplane[3] = DotProduct( a, plane );\n\treturn qtrue;\n}\n\n/*\n===============\nRotatePointAroundVector\n\nThis is not implemented very well...\n===============\n*/\nvoid RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point,\n\t\t\t\t\t\t\t float degrees ) {\n\tfloat\tm[3][3];\n\tfloat\tim[3][3];\n\tfloat\tzrot[3][3];\n\tfloat\ttmpmat[3][3];\n\tfloat\trot[3][3];\n\tint\ti;\n\tvec3_t vr, vup, vf;\n\tfloat\trad;\n\n\tvf[0] = dir[0];\n\tvf[1] = dir[1];\n\tvf[2] = dir[2];\n\n\tPerpendicularVector( vr, dir );\n\tCrossProduct( vr, vf, vup );\n\n\tm[0][0] = vr[0];\n\tm[1][0] = vr[1];\n\tm[2][0] = vr[2];\n\n\tm[0][1] = vup[0];\n\tm[1][1] = vup[1];\n\tm[2][1] = vup[2];\n\n\tm[0][2] = vf[0];\n\tm[1][2] = vf[1];\n\tm[2][2] = vf[2];\n\n\tmemcpy( im, m, sizeof( im ) );\n\n\tim[0][1] = m[1][0];\n\tim[0][2] = m[2][0];\n\tim[1][0] = m[0][1];\n\tim[1][2] = m[2][1];\n\tim[2][0] = m[0][2];\n\tim[2][1] = m[1][2];\n\n\tmemset( zrot, 0, sizeof( zrot ) );\n\tzrot[0][0] = zrot[1][1] = zrot[2][2] = 1.0F;\n\n\trad = DEG2RAD( degrees );\n\tzrot[0][0] = cos( rad );\n\tzrot[0][1] = sin( rad );\n\tzrot[1][0] = -sin( rad );\n\tzrot[1][1] = cos( rad );\n\n\tMatrixMultiply( m, zrot, tmpmat );\n\tMatrixMultiply( tmpmat, im, rot );\n\n\tfor ( i = 0; i < 3; i++ ) {\n\t\tdst[i] = rot[i][0] * point[0] + rot[i][1] * point[1] + rot[i][2] * point[2];\n\t}\n}\n\n/*\n===============\nRotateAroundDirection\n===============\n*/\nvoid RotateAroundDirection( vec3_t axis[3], float yaw ) {\n\n\t// create an arbitrary axis[1] \n\tPerpendicularVector( axis[1], axis[0] );\n\n\t// rotate it around axis[0] by yaw\n\tif ( yaw ) {\n\t\tvec3_t\ttemp;\n\n\t\tVectorCopy( axis[1], temp );\n\t\tRotatePointAroundVector( axis[1], axis[0], temp, yaw );\n\t}\n\n\t// cross to get axis[2]\n\tCrossProduct( axis[0], axis[1], axis[2] );\n}\n\n\n\nvoid vectoangles( const vec3_t value1, vec3_t angles ) {\n\tfloat\tforward;\n\tfloat\tyaw, pitch;\n\t\n\tif ( value1[1] == 0 && value1[0] == 0 ) {\n\t\tyaw = 0;\n\t\tif ( value1[2] > 0 ) {\n\t\t\tpitch = 90;\n\t\t}\n\t\telse {\n\t\t\tpitch = 270;\n\t\t}\n\t}\n\telse {\n\t\tif ( value1[0] ) {\n\t\t\tyaw = ( atan2 ( value1[1], value1[0] ) * 180 / M_PI );\n\t\t}\n\t\telse if ( value1[1] > 0 ) {\n\t\t\tyaw = 90;\n\t\t}\n\t\telse {\n\t\t\tyaw = 270;\n\t\t}\n\t\tif ( yaw < 0 ) {\n\t\t\tyaw += 360;\n\t\t}\n\n\t\tforward = sqrt ( value1[0]*value1[0] + value1[1]*value1[1] );\n\t\tpitch = ( atan2(value1[2], forward) * 180 / M_PI );\n\t\tif ( pitch < 0 ) {\n\t\t\tpitch += 360;\n\t\t}\n\t}\n\n\tangles[PITCH] = -pitch;\n\tangles[YAW] = yaw;\n\tangles[ROLL] = 0;\n}\n\n\n/*\n=================\nAnglesToAxis\n=================\n*/\nvoid AnglesToAxis( const vec3_t angles, vec3_t axis[3] ) {\n\tvec3_t\tright;\n\n\t// angle vectors returns \"right\" instead of \"y axis\"\n\tAngleVectors( angles, axis[0], right, axis[2] );\n\tVectorSubtract( vec3_origin, right, axis[1] );\n}\n\nvoid AxisClear( vec3_t axis[3] ) {\n\taxis[0][0] = 1;\n\taxis[0][1] = 0;\n\taxis[0][2] = 0;\n\taxis[1][0] = 0;\n\taxis[1][1] = 1;\n\taxis[1][2] = 0;\n\taxis[2][0] = 0;\n\taxis[2][1] = 0;\n\taxis[2][2] = 1;\n}\n\nvoid AxisCopy( vec3_t in[3], vec3_t out[3] ) {\n\tVectorCopy( in[0], out[0] );\n\tVectorCopy( in[1], out[1] );\n\tVectorCopy( in[2], out[2] );\n}\n\nvoid ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal )\n{\n\tfloat d;\n\tvec3_t n;\n\tfloat inv_denom;\n\n\tinv_denom =  DotProduct( normal, normal );\n#ifndef Q3_VM\n\tassert( Q_fabs(inv_denom) != 0.0f ); // bk010122 - zero vectors get here\n#endif\n\tinv_denom = 1.0f / inv_denom;\n\n\td = DotProduct( normal, p ) * inv_denom;\n\n\tn[0] = normal[0] * inv_denom;\n\tn[1] = normal[1] * inv_denom;\n\tn[2] = normal[2] * inv_denom;\n\n\tdst[0] = p[0] - d * n[0];\n\tdst[1] = p[1] - d * n[1];\n\tdst[2] = p[2] - d * n[2];\n}\n\n/*\n================\nMakeNormalVectors\n\nGiven a normalized forward vector, create two\nother perpendicular vectors\n================\n*/\nvoid MakeNormalVectors( const vec3_t forward, vec3_t right, vec3_t up) {\n\tfloat\t\td;\n\n\t// this rotate and negate guarantees a vector\n\t// not colinear with the original\n\tright[1] = -forward[0];\n\tright[2] = forward[1];\n\tright[0] = forward[2];\n\n\td = DotProduct (right, forward);\n\tVectorMA (right, -d, forward, right);\n\tVectorNormalize (right);\n\tCrossProduct (right, forward, up);\n}\n\n\nvoid VectorRotate( vec3_t in, vec3_t matrix[3], vec3_t out )\n{\n\tout[0] = DotProduct( in, matrix[0] );\n\tout[1] = DotProduct( in, matrix[1] );\n\tout[2] = DotProduct( in, matrix[2] );\n}\n\n//============================================================================\n\n#if !idppc\n/*\n** float q_rsqrt( float number )\n*/\nfloat Q_rsqrt( float number )\n{\n\tlong i;\n\tfloat x2, y;\n\tconst float threehalfs = 1.5F;\n\n\tx2 = number * 0.5F;\n\ty  = number;\n\ti  = * ( long * ) &y;\t\t\t\t\t\t// evil floating point bit level hacking\n\ti  = 0x5f3759df - ( i >> 1 );               // what the fuck?\n\ty  = * ( float * ) &i;\n\ty  = y * ( threehalfs - ( x2 * y * y ) );   // 1st iteration\n//\ty  = y * ( threehalfs - ( x2 * y * y ) );   // 2nd iteration, this can be removed\n\n#ifndef Q3_VM\n#ifdef __linux__\n\tassert( !isnan(y) ); // bk010122 - FPE?\n#endif\n#endif\n\treturn y;\n}\n\nfloat Q_fabs( float f ) {\n\tint tmp = * ( int * ) &f;\n\ttmp &= 0x7FFFFFFF;\n\treturn * ( float * ) &tmp;\n}\n#endif\n\n//============================================================\n\n/*\n===============\nLerpAngle\n\n===============\n*/\nfloat LerpAngle (float from, float to, float frac) {\n\tfloat\ta;\n\n\tif ( to - from > 180 ) {\n\t\tto -= 360;\n\t}\n\tif ( to - from < -180 ) {\n\t\tto += 360;\n\t}\n\ta = from + frac * (to - from);\n\n\treturn a;\n}\n\n\n/*\n=================\nAngleSubtract\n\nAlways returns a value from -180 to 180\n=================\n*/\nfloat\tAngleSubtract( float a1, float a2 ) {\n\tfloat\ta;\n\n\ta = a1 - a2;\n\twhile ( a > 180 ) {\n\t\ta -= 360;\n\t}\n\twhile ( a < -180 ) {\n\t\ta += 360;\n\t}\n\treturn a;\n}\n\n\nvoid AnglesSubtract( vec3_t v1, vec3_t v2, vec3_t v3 ) {\n\tv3[0] = AngleSubtract( v1[0], v2[0] );\n\tv3[1] = AngleSubtract( v1[1], v2[1] );\n\tv3[2] = AngleSubtract( v1[2], v2[2] );\n}\n\n\nfloat\tAngleMod(float a) {\n\ta = (360.0/65536) * ((int)(a*(65536/360.0)) & 65535);\n\treturn a;\n}\n\n\n/*\n=================\nAngleNormalize360\n\nreturns angle normalized to the range [0 <= angle < 360]\n=================\n*/\nfloat AngleNormalize360 ( float angle ) {\n\treturn (360.0 / 65536) * ((int)(angle * (65536 / 360.0)) & 65535);\n}\n\n\n/*\n=================\nAngleNormalize180\n\nreturns angle normalized to the range [-180 < angle <= 180]\n=================\n*/\nfloat AngleNormalize180 ( float angle ) {\n\tangle = AngleNormalize360( angle );\n\tif ( angle > 180.0 ) {\n\t\tangle -= 360.0;\n\t}\n\treturn angle;\n}\n\n\n/*\n=================\nAngleDelta\n\nreturns the normalized delta from angle1 to angle2\n=================\n*/\nfloat AngleDelta ( float angle1, float angle2 ) {\n\treturn AngleNormalize180( angle1 - angle2 );\n}\n\n\n//============================================================\n\n\n/*\n=================\nSetPlaneSignbits\n=================\n*/\nvoid SetPlaneSignbits (cplane_t *out) {\n\tint\tbits, j;\n\n\t// for fast box on planeside test\n\tbits = 0;\n\tfor (j=0 ; j<3 ; j++) {\n\t\tif (out->normal[j] < 0) {\n\t\t\tbits |= 1<<j;\n\t\t}\n\t}\n\tout->signbits = bits;\n}\n\n\n/*\n==================\nBoxOnPlaneSide\n\nReturns 1, 2, or 1 + 2\n\n// this is the slow, general version\nint BoxOnPlaneSide2 (vec3_t emins, vec3_t emaxs, struct cplane_s *p)\n{\n\tint\t\ti;\n\tfloat\tdist1, dist2;\n\tint\t\tsides;\n\tvec3_t\tcorners[2];\n\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tif (p->normal[i] < 0)\n\t\t{\n\t\t\tcorners[0][i] = emins[i];\n\t\t\tcorners[1][i] = emaxs[i];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcorners[1][i] = emins[i];\n\t\t\tcorners[0][i] = emaxs[i];\n\t\t}\n\t}\n\tdist1 = DotProduct (p->normal, corners[0]) - p->dist;\n\tdist2 = DotProduct (p->normal, corners[1]) - p->dist;\n\tsides = 0;\n\tif (dist1 >= 0)\n\t\tsides = 1;\n\tif (dist2 < 0)\n\t\tsides |= 2;\n\n\treturn sides;\n}\n\n==================\n*/\n\n#if !( (defined __linux__ || __FreeBSD__) && (defined __i386__) && (!defined C_ONLY)) // rb010123\n\n#if defined __LCC__ || defined C_ONLY || !id386 || defined __VECTORC\n\nint BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *p)\n{\n\tfloat\tdist1, dist2;\n\tint\t\tsides;\n\n// fast axial cases\n\tif (p->type < 3)\n\t{\n\t\tif (p->dist <= emins[p->type])\n\t\t\treturn 1;\n\t\tif (p->dist >= emaxs[p->type])\n\t\t\treturn 2;\n\t\treturn 3;\n\t}\n\n// general case\n\tswitch (p->signbits)\n\t{\n\tcase 0:\n\t\tdist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];\n\t\tdist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];\n\t\tbreak;\n\tcase 1:\n\t\tdist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];\n\t\tdist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];\n\t\tbreak;\n\tcase 2:\n\t\tdist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];\n\t\tdist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];\n\t\tbreak;\n\tcase 3:\n\t\tdist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];\n\t\tdist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];\n\t\tbreak;\n\tcase 4:\n\t\tdist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];\n\t\tdist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];\n\t\tbreak;\n\tcase 5:\n\t\tdist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];\n\t\tdist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];\n\t\tbreak;\n\tcase 6:\n\t\tdist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];\n\t\tdist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];\n\t\tbreak;\n\tcase 7:\n\t\tdist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];\n\t\tdist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];\n\t\tbreak;\n\tdefault:\n\t\tdist1 = dist2 = 0;\t\t// shut up compiler\n\t\tbreak;\n\t}\n\n\tsides = 0;\n\tif (dist1 >= p->dist)\n\t\tsides = 1;\n\tif (dist2 < p->dist)\n\t\tsides |= 2;\n\n\treturn sides;\n}\n#else\n#pragma warning( disable: 4035 )\n\n__declspec( naked ) int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *p)\n{\n\tstatic int bops_initialized;\n\tstatic int Ljmptab[8];\n\n\t__asm {\n\n\t\tpush ebx\n\t\t\t\n\t\tcmp bops_initialized, 1\n\t\tje  initialized\n\t\tmov bops_initialized, 1\n\t\t\n\t\tmov Ljmptab[0*4], offset Lcase0\n\t\tmov Ljmptab[1*4], offset Lcase1\n\t\tmov Ljmptab[2*4], offset Lcase2\n\t\tmov Ljmptab[3*4], offset Lcase3\n\t\tmov Ljmptab[4*4], offset Lcase4\n\t\tmov Ljmptab[5*4], offset Lcase5\n\t\tmov Ljmptab[6*4], offset Lcase6\n\t\tmov Ljmptab[7*4], offset Lcase7\n\t\t\t\ninitialized:\n\n\t\tmov edx,dword ptr[4+12+esp]\n\t\tmov ecx,dword ptr[4+4+esp]\n\t\txor eax,eax\n\t\tmov ebx,dword ptr[4+8+esp]\n\t\tmov al,byte ptr[17+edx]\n\t\tcmp al,8\n\t\tjge Lerror\n\t\tfld dword ptr[0+edx]\n\t\tfld st(0)\n\t\tjmp dword ptr[Ljmptab+eax*4]\nLcase0:\n\t\tfmul dword ptr[ebx]\n\t\tfld dword ptr[0+4+edx]\n\t\tfxch st(2)\n\t\tfmul dword ptr[ecx]\n\t\tfxch st(2)\n\t\tfld st(0)\n\t\tfmul dword ptr[4+ebx]\n\t\tfld dword ptr[0+8+edx]\n\t\tfxch st(2)\n\t\tfmul dword ptr[4+ecx]\n\t\tfxch st(2)\n\t\tfld st(0)\n\t\tfmul dword ptr[8+ebx]\n\t\tfxch st(5)\n\t\tfaddp st(3),st(0)\n\t\tfmul dword ptr[8+ecx]\n\t\tfxch st(1)\n\t\tfaddp st(3),st(0)\n\t\tfxch st(3)\n\t\tfaddp st(2),st(0)\n\t\tjmp LSetSides\nLcase1:\n\t\tfmul dword ptr[ecx]\n\t\tfld dword ptr[0+4+edx]\n\t\tfxch st(2)\n\t\tfmul dword ptr[ebx]\n\t\tfxch st(2)\n\t\tfld st(0)\n\t\tfmul dword ptr[4+ebx]\n\t\tfld dword ptr[0+8+edx]\n\t\tfxch st(2)\n\t\tfmul dword ptr[4+ecx]\n\t\tfxch st(2)\n\t\tfld st(0)\n\t\tfmul dword ptr[8+ebx]\n\t\tfxch st(5)\n\t\tfaddp st(3),st(0)\n\t\tfmul dword ptr[8+ecx]\n\t\tfxch st(1)\n\t\tfaddp st(3),st(0)\n\t\tfxch st(3)\n\t\tfaddp st(2),st(0)\n\t\tjmp LSetSides\nLcase2:\n\t\tfmul dword ptr[ebx]\n\t\tfld dword ptr[0+4+edx]\n\t\tfxch st(2)\n\t\tfmul dword ptr[ecx]\n\t\tfxch st(2)\n\t\tfld st(0)\n\t\tfmul dword ptr[4+ecx]\n\t\tfld dword ptr[0+8+edx]\n\t\tfxch st(2)\n\t\tfmul dword ptr[4+ebx]\n\t\tfxch st(2)\n\t\tfld st(0)\n\t\tfmul dword ptr[8+ebx]\n\t\tfxch st(5)\n\t\tfaddp st(3),st(0)\n\t\tfmul dword ptr[8+ecx]\n\t\tfxch st(1)\n\t\tfaddp st(3),st(0)\n\t\tfxch st(3)\n\t\tfaddp st(2),st(0)\n\t\tjmp LSetSides\nLcase3:\n\t\tfmul dword ptr[ecx]\n\t\tfld dword ptr[0+4+edx]\n\t\tfxch st(2)\n\t\tfmul dword ptr[ebx]\n\t\tfxch st(2)\n\t\tfld st(0)\n\t\tfmul dword ptr[4+ecx]\n\t\tfld dword ptr[0+8+edx]\n\t\tfxch st(2)\n\t\tfmul dword ptr[4+ebx]\n\t\tfxch st(2)\n\t\tfld st(0)\n\t\tfmul dword ptr[8+ebx]\n\t\tfxch st(5)\n\t\tfaddp st(3),st(0)\n\t\tfmul dword ptr[8+ecx]\n\t\tfxch st(1)\n\t\tfaddp st(3),st(0)\n\t\tfxch st(3)\n\t\tfaddp st(2),st(0)\n\t\tjmp LSetSides\nLcase4:\n\t\tfmul dword ptr[ebx]\n\t\tfld dword ptr[0+4+edx]\n\t\tfxch st(2)\n\t\tfmul dword ptr[ecx]\n\t\tfxch st(2)\n\t\tfld st(0)\n\t\tfmul dword ptr[4+ebx]\n\t\tfld dword ptr[0+8+edx]\n\t\tfxch st(2)\n\t\tfmul dword ptr[4+ecx]\n\t\tfxch st(2)\n\t\tfld st(0)\n\t\tfmul dword ptr[8+ecx]\n\t\tfxch st(5)\n\t\tfaddp st(3),st(0)\n\t\tfmul dword ptr[8+ebx]\n\t\tfxch st(1)\n\t\tfaddp st(3),st(0)\n\t\tfxch st(3)\n\t\tfaddp st(2),st(0)\n\t\tjmp LSetSides\nLcase5:\n\t\tfmul dword ptr[ecx]\n\t\tfld dword ptr[0+4+edx]\n\t\tfxch st(2)\n\t\tfmul dword ptr[ebx]\n\t\tfxch st(2)\n\t\tfld st(0)\n\t\tfmul dword ptr[4+ebx]\n\t\tfld dword ptr[0+8+edx]\n\t\tfxch st(2)\n\t\tfmul dword ptr[4+ecx]\n\t\tfxch st(2)\n\t\tfld st(0)\n\t\tfmul dword ptr[8+ecx]\n\t\tfxch st(5)\n\t\tfaddp st(3),st(0)\n\t\tfmul dword ptr[8+ebx]\n\t\tfxch st(1)\n\t\tfaddp st(3),st(0)\n\t\tfxch st(3)\n\t\tfaddp st(2),st(0)\n\t\tjmp LSetSides\nLcase6:\n\t\tfmul dword ptr[ebx]\n\t\tfld dword ptr[0+4+edx]\n\t\tfxch st(2)\n\t\tfmul dword ptr[ecx]\n\t\tfxch st(2)\n\t\tfld st(0)\n\t\tfmul dword ptr[4+ecx]\n\t\tfld dword ptr[0+8+edx]\n\t\tfxch st(2)\n\t\tfmul dword ptr[4+ebx]\n\t\tfxch st(2)\n\t\tfld st(0)\n\t\tfmul dword ptr[8+ecx]\n\t\tfxch st(5)\n\t\tfaddp st(3),st(0)\n\t\tfmul dword ptr[8+ebx]\n\t\tfxch st(1)\n\t\tfaddp st(3),st(0)\n\t\tfxch st(3)\n\t\tfaddp st(2),st(0)\n\t\tjmp LSetSides\nLcase7:\n\t\tfmul dword ptr[ecx]\n\t\tfld dword ptr[0+4+edx]\n\t\tfxch st(2)\n\t\tfmul dword ptr[ebx]\n\t\tfxch st(2)\n\t\tfld st(0)\n\t\tfmul dword ptr[4+ecx]\n\t\tfld dword ptr[0+8+edx]\n\t\tfxch st(2)\n\t\tfmul dword ptr[4+ebx]\n\t\tfxch st(2)\n\t\tfld st(0)\n\t\tfmul dword ptr[8+ecx]\n\t\tfxch st(5)\n\t\tfaddp st(3),st(0)\n\t\tfmul dword ptr[8+ebx]\n\t\tfxch st(1)\n\t\tfaddp st(3),st(0)\n\t\tfxch st(3)\n\t\tfaddp st(2),st(0)\nLSetSides:\n\t\tfaddp st(2),st(0)\n\t\tfcomp dword ptr[12+edx]\n\t\txor ecx,ecx\n\t\tfnstsw ax\n\t\tfcomp dword ptr[12+edx]\n\t\tand ah,1\n\t\txor ah,1\n\t\tadd cl,ah\n\t\tfnstsw ax\n\t\tand ah,1\n\t\tadd ah,ah\n\t\tadd cl,ah\n\t\tpop ebx\n\t\tmov eax,ecx\n\t\tret\nLerror:\n\t\tint 3\n\t}\n}\n#pragma warning( default: 4035 )\n\n#endif\n#endif\n\n/*\n=================\nRadiusFromBounds\n=================\n*/\nfloat RadiusFromBounds( const vec3_t mins, const vec3_t maxs ) {\n\tint\t\ti;\n\tvec3_t\tcorner;\n\tfloat\ta, b;\n\n\tfor (i=0 ; i<3 ; i++) {\n\t\ta = fabs( mins[i] );\n\t\tb = fabs( maxs[i] );\n\t\tcorner[i] = a > b ? a : b;\n\t}\n\n\treturn VectorLength (corner);\n}\n\n\nvoid ClearBounds( vec3_t mins, vec3_t maxs ) {\n\tmins[0] = mins[1] = mins[2] = 99999;\n\tmaxs[0] = maxs[1] = maxs[2] = -99999;\n}\n\nvoid AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs ) {\n\tif ( v[0] < mins[0] ) {\n\t\tmins[0] = v[0];\n\t}\n\tif ( v[0] > maxs[0]) {\n\t\tmaxs[0] = v[0];\n\t}\n\n\tif ( v[1] < mins[1] ) {\n\t\tmins[1] = v[1];\n\t}\n\tif ( v[1] > maxs[1]) {\n\t\tmaxs[1] = v[1];\n\t}\n\n\tif ( v[2] < mins[2] ) {\n\t\tmins[2] = v[2];\n\t}\n\tif ( v[2] > maxs[2]) {\n\t\tmaxs[2] = v[2];\n\t}\n}\n\n\nvec_t VectorNormalize( vec3_t v ) {\n\t// NOTE: TTimo - Apple G4 altivec source uses double?\n\tfloat\tlength, ilength;\n\n\tlength = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];\n\tlength = sqrt (length);\n\n\tif ( length ) {\n\t\tilength = 1/length;\n\t\tv[0] *= ilength;\n\t\tv[1] *= ilength;\n\t\tv[2] *= ilength;\n\t}\n\t\t\n\treturn length;\n}\n\nvec_t VectorNormalize2( const vec3_t v, vec3_t out) {\n\tfloat\tlength, ilength;\n\n\tlength = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];\n\tlength = sqrt (length);\n\n\tif (length)\n\t{\n#ifndef Q3_VM // bk0101022 - FPE related\n//\t  assert( ((Q_fabs(v[0])!=0.0f) || (Q_fabs(v[1])!=0.0f) || (Q_fabs(v[2])!=0.0f)) );\n#endif\n\t\tilength = 1/length;\n\t\tout[0] = v[0]*ilength;\n\t\tout[1] = v[1]*ilength;\n\t\tout[2] = v[2]*ilength;\n\t} else {\n#ifndef Q3_VM // bk0101022 - FPE related\n//\t  assert( ((Q_fabs(v[0])==0.0f) && (Q_fabs(v[1])==0.0f) && (Q_fabs(v[2])==0.0f)) );\n#endif\n\t\tVectorClear( out );\n\t}\n\t\t\n\treturn length;\n\n}\n\nvoid _VectorMA( const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc) {\n\tvecc[0] = veca[0] + scale*vecb[0];\n\tvecc[1] = veca[1] + scale*vecb[1];\n\tvecc[2] = veca[2] + scale*vecb[2];\n}\n\n\nvec_t _DotProduct( const vec3_t v1, const vec3_t v2 ) {\n\treturn v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];\n}\n\nvoid _VectorSubtract( const vec3_t veca, const vec3_t vecb, vec3_t out ) {\n\tout[0] = veca[0]-vecb[0];\n\tout[1] = veca[1]-vecb[1];\n\tout[2] = veca[2]-vecb[2];\n}\n\nvoid _VectorAdd( const vec3_t veca, const vec3_t vecb, vec3_t out ) {\n\tout[0] = veca[0]+vecb[0];\n\tout[1] = veca[1]+vecb[1];\n\tout[2] = veca[2]+vecb[2];\n}\n\nvoid _VectorCopy( const vec3_t in, vec3_t out ) {\n\tout[0] = in[0];\n\tout[1] = in[1];\n\tout[2] = in[2];\n}\n\nvoid _VectorScale( const vec3_t in, vec_t scale, vec3_t out ) {\n\tout[0] = in[0]*scale;\n\tout[1] = in[1]*scale;\n\tout[2] = in[2]*scale;\n}\n\nvoid Vector4Scale( const vec4_t in, vec_t scale, vec4_t out ) {\n\tout[0] = in[0]*scale;\n\tout[1] = in[1]*scale;\n\tout[2] = in[2]*scale;\n\tout[3] = in[3]*scale;\n}\n\n\nint Q_log2( int val ) {\n\tint answer;\n\n\tanswer = 0;\n\twhile ( ( val>>=1 ) != 0 ) {\n\t\tanswer++;\n\t}\n\treturn answer;\n}\n\n\n\n/*\n=================\nPlaneTypeForNormal\n=================\n*/\n/*\nint\tPlaneTypeForNormal (vec3_t normal) {\n\tif ( normal[0] == 1.0 )\n\t\treturn PLANE_X;\n\tif ( normal[1] == 1.0 )\n\t\treturn PLANE_Y;\n\tif ( normal[2] == 1.0 )\n\t\treturn PLANE_Z;\n\t\n\treturn PLANE_NON_AXIAL;\n}\n*/\n\n\n/*\n================\nMatrixMultiply\n================\n*/\nvoid MatrixMultiply(float in1[3][3], float in2[3][3], float out[3][3]) {\n\tout[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] +\n\t\t\t\tin1[0][2] * in2[2][0];\n\tout[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] +\n\t\t\t\tin1[0][2] * in2[2][1];\n\tout[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] +\n\t\t\t\tin1[0][2] * in2[2][2];\n\tout[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] +\n\t\t\t\tin1[1][2] * in2[2][0];\n\tout[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] +\n\t\t\t\tin1[1][2] * in2[2][1];\n\tout[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] +\n\t\t\t\tin1[1][2] * in2[2][2];\n\tout[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] +\n\t\t\t\tin1[2][2] * in2[2][0];\n\tout[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] +\n\t\t\t\tin1[2][2] * in2[2][1];\n\tout[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] +\n\t\t\t\tin1[2][2] * in2[2][2];\n}\n\n\nvoid AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) {\n\tfloat\t\tangle;\n\tstatic float\t\tsr, sp, sy, cr, cp, cy;\n\t// static to help MS compiler fp bugs\n\n\tangle = angles[YAW] * (M_PI*2 / 360);\n\tsy = sin(angle);\n\tcy = cos(angle);\n\tangle = angles[PITCH] * (M_PI*2 / 360);\n\tsp = sin(angle);\n\tcp = cos(angle);\n\tangle = angles[ROLL] * (M_PI*2 / 360);\n\tsr = sin(angle);\n\tcr = cos(angle);\n\n\tif (forward)\n\t{\n\t\tforward[0] = cp*cy;\n\t\tforward[1] = cp*sy;\n\t\tforward[2] = -sp;\n\t}\n\tif (right)\n\t{\n\t\tright[0] = (-1*sr*sp*cy+-1*cr*-sy);\n\t\tright[1] = (-1*sr*sp*sy+-1*cr*cy);\n\t\tright[2] = -1*sr*cp;\n\t}\n\tif (up)\n\t{\n\t\tup[0] = (cr*sp*cy+-sr*-sy);\n\t\tup[1] = (cr*sp*sy+-sr*cy);\n\t\tup[2] = cr*cp;\n\t}\n}\n\n/*\n** assumes \"src\" is normalized\n*/\nvoid PerpendicularVector( vec3_t dst, const vec3_t src )\n{\n\tint\tpos;\n\tint i;\n\tfloat minelem = 1.0F;\n\tvec3_t tempvec;\n\n\t/*\n\t** find the smallest magnitude axially aligned vector\n\t*/\n\tfor ( pos = 0, i = 0; i < 3; i++ )\n\t{\n\t\tif ( fabs( src[i] ) < minelem )\n\t\t{\n\t\t\tpos = i;\n\t\t\tminelem = fabs( src[i] );\n\t\t}\n\t}\n\ttempvec[0] = tempvec[1] = tempvec[2] = 0.0F;\n\ttempvec[pos] = 1.0F;\n\n\t/*\n\t** project the point onto the plane defined by src\n\t*/\n\tProjectPointOnPlane( dst, tempvec, src );\n\n\t/*\n\t** normalize the result\n\t*/\n\tVectorNormalize( dst );\n}\n\n\n"
  },
  {
    "path": "code/game/q_shared.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// q_shared.c -- stateless support routines that are included in each code dll\n#include \"q_shared.h\"\n\nfloat Com_Clamp( float min, float max, float value ) {\n\tif ( value < min ) {\n\t\treturn min;\n\t}\n\tif ( value > max ) {\n\t\treturn max;\n\t}\n\treturn value;\n}\n\n\n/*\n============\nCOM_SkipPath\n============\n*/\nchar *COM_SkipPath (char *pathname)\n{\n\tchar\t*last;\n\t\n\tlast = pathname;\n\twhile (*pathname)\n\t{\n\t\tif (*pathname=='/')\n\t\t\tlast = pathname+1;\n\t\tpathname++;\n\t}\n\treturn last;\n}\n\n/*\n============\nCOM_StripExtension\n============\n*/\nvoid COM_StripExtension( const char *in, char *out ) {\n\twhile ( *in && *in != '.' ) {\n\t\t*out++ = *in++;\n\t}\n\t*out = 0;\n}\n\n\n/*\n==================\nCOM_DefaultExtension\n==================\n*/\nvoid COM_DefaultExtension (char *path, int maxSize, const char *extension ) {\n\tchar\toldPath[MAX_QPATH];\n\tchar    *src;\n\n//\n// if path doesn't have a .EXT, append extension\n// (extension should include the .)\n//\n\tsrc = path + strlen(path) - 1;\n\n\twhile (*src != '/' && src != path) {\n\t\tif ( *src == '.' ) {\n\t\t\treturn;                 // it has an extension\n\t\t}\n\t\tsrc--;\n\t}\n\n\tQ_strncpyz( oldPath, path, sizeof( oldPath ) );\n\tCom_sprintf( path, maxSize, \"%s%s\", oldPath, extension );\n}\n\n/*\n============================================================================\n\n\t\t\t\t\tBYTE ORDER FUNCTIONS\n\n============================================================================\n*/\n/*\n// can't just use function pointers, or dll linkage can\n// mess up when qcommon is included in multiple places\nstatic short\t(*_BigShort) (short l);\nstatic short\t(*_LittleShort) (short l);\nstatic int\t\t(*_BigLong) (int l);\nstatic int\t\t(*_LittleLong) (int l);\nstatic qint64\t(*_BigLong64) (qint64 l);\nstatic qint64\t(*_LittleLong64) (qint64 l);\nstatic float\t(*_BigFloat) (const float *l);\nstatic float\t(*_LittleFloat) (const float *l);\n\nshort\tBigShort(short l){return _BigShort(l);}\nshort\tLittleShort(short l) {return _LittleShort(l);}\nint\t\tBigLong (int l) {return _BigLong(l);}\nint\t\tLittleLong (int l) {return _LittleLong(l);}\nqint64 \tBigLong64 (qint64 l) {return _BigLong64(l);}\nqint64 \tLittleLong64 (qint64 l) {return _LittleLong64(l);}\nfloat\tBigFloat (const float *l) {return _BigFloat(l);}\nfloat\tLittleFloat (const float *l) {return _LittleFloat(l);}\n*/\n\nshort   ShortSwap (short l)\n{\n\tbyte    b1,b2;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\n\treturn (b1<<8) + b2;\n}\n\nshort\tShortNoSwap (short l)\n{\n\treturn l;\n}\n\nint    LongSwap (int l)\n{\n\tbyte    b1,b2,b3,b4;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\tb3 = (l>>16)&255;\n\tb4 = (l>>24)&255;\n\n\treturn ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;\n}\n\nint\tLongNoSwap (int l)\n{\n\treturn l;\n}\n\nqint64 Long64Swap (qint64 ll)\n{\n\tqint64\tresult;\n\n\tresult.b0 = ll.b7;\n\tresult.b1 = ll.b6;\n\tresult.b2 = ll.b5;\n\tresult.b3 = ll.b4;\n\tresult.b4 = ll.b3;\n\tresult.b5 = ll.b2;\n\tresult.b6 = ll.b1;\n\tresult.b7 = ll.b0;\n\n\treturn result;\n}\n\nqint64 Long64NoSwap (qint64 ll)\n{\n\treturn ll;\n}\n\ntypedef union {\n    float\tf;\n    unsigned int i;\n} _FloatByteUnion;\n\nfloat FloatSwap (const float *f) {\n\tconst _FloatByteUnion *in;\n\t_FloatByteUnion out;\n\n\tin = (_FloatByteUnion *)f;\n\tout.i = LongSwap(in->i);\n\n\treturn out.f;\n}\n\nfloat FloatNoSwap (const float *f)\n{\n\treturn *f;\n}\n\n/*\n================\nSwap_Init\n================\n*/\n/*\nvoid Swap_Init (void)\n{\n\tbyte\tswaptest[2] = {1,0};\n\n// set the byte swapping variables in a portable manner\t\n\tif ( *(short *)swaptest == 1)\n\t{\n\t\t_BigShort = ShortSwap;\n\t\t_LittleShort = ShortNoSwap;\n\t\t_BigLong = LongSwap;\n\t\t_LittleLong = LongNoSwap;\n\t\t_BigLong64 = Long64Swap;\n\t\t_LittleLong64 = Long64NoSwap;\n\t\t_BigFloat = FloatSwap;\n\t\t_LittleFloat = FloatNoSwap;\n\t}\n\telse\n\t{\n\t\t_BigShort = ShortNoSwap;\n\t\t_LittleShort = ShortSwap;\n\t\t_BigLong = LongNoSwap;\n\t\t_LittleLong = LongSwap;\n\t\t_BigLong64 = Long64NoSwap;\n\t\t_LittleLong64 = Long64Swap;\n\t\t_BigFloat = FloatNoSwap;\n\t\t_LittleFloat = FloatSwap;\n\t}\n\n}\n*/\n\n/*\n============================================================================\n\nPARSING\n\n============================================================================\n*/\n\nstatic\tchar\tcom_token[MAX_TOKEN_CHARS];\nstatic\tchar\tcom_parsename[MAX_TOKEN_CHARS];\nstatic\tint\t\tcom_lines;\n\nvoid COM_BeginParseSession( const char *name )\n{\n\tcom_lines = 0;\n\tCom_sprintf(com_parsename, sizeof(com_parsename), \"%s\", name);\n}\n\nint COM_GetCurrentParseLine( void )\n{\n\treturn com_lines;\n}\n\nchar *COM_Parse( char **data_p )\n{\n\treturn COM_ParseExt( data_p, qtrue );\n}\n\nvoid COM_ParseError( char *format, ... )\n{\n\tva_list argptr;\n\tstatic char string[4096];\n\n\tva_start (argptr, format);\n\tvsprintf (string, format, argptr);\n\tva_end (argptr);\n\n\tCom_Printf(\"ERROR: %s, line %d: %s\\n\", com_parsename, com_lines, string);\n}\n\nvoid COM_ParseWarning( char *format, ... )\n{\n\tva_list argptr;\n\tstatic char string[4096];\n\n\tva_start (argptr, format);\n\tvsprintf (string, format, argptr);\n\tva_end (argptr);\n\n\tCom_Printf(\"WARNING: %s, line %d: %s\\n\", com_parsename, com_lines, string);\n}\n\n/*\n==============\nCOM_Parse\n\nParse a token out of a string\nWill never return NULL, just empty strings\n\nIf \"allowLineBreaks\" is qtrue then an empty\nstring will be returned if the next token is\na newline.\n==============\n*/\nstatic char *SkipWhitespace( char *data, qboolean *hasNewLines ) {\n\tint c;\n\n\twhile( (c = *data) <= ' ') {\n\t\tif( !c ) {\n\t\t\treturn NULL;\n\t\t}\n\t\tif( c == '\\n' ) {\n\t\t\tcom_lines++;\n\t\t\t*hasNewLines = qtrue;\n\t\t}\n\t\tdata++;\n\t}\n\n\treturn data;\n}\n\nint COM_Compress( char *data_p ) {\n\tchar *in, *out;\n\tint c;\n\tqboolean newline = qfalse, whitespace = qfalse;\n\n\tin = out = data_p;\n\tif (in) {\n\t\twhile ((c = *in) != 0) {\n\t\t\t// skip double slash comments\n\t\t\tif ( c == '/' && in[1] == '/' ) {\n\t\t\t\twhile (*in && *in != '\\n') {\n\t\t\t\t\tin++;\n\t\t\t\t}\n\t\t\t// skip /* */ comments\n\t\t\t} else if ( c == '/' && in[1] == '*' ) {\n\t\t\t\twhile ( *in && ( *in != '*' || in[1] != '/' ) ) \n\t\t\t\t\tin++;\n\t\t\t\tif ( *in ) \n\t\t\t\t\tin += 2;\n                        // record when we hit a newline\n                        } else if ( c == '\\n' || c == '\\r' ) {\n                            newline = qtrue;\n                            in++;\n                        // record when we hit whitespace\n                        } else if ( c == ' ' || c == '\\t') {\n                            whitespace = qtrue;\n                            in++;\n                        // an actual token\n\t\t\t} else {\n                            // if we have a pending newline, emit it (and it counts as whitespace)\n                            if (newline) {\n                                *out++ = '\\n';\n                                newline = qfalse;\n                                whitespace = qfalse;\n                            } if (whitespace) {\n                                *out++ = ' ';\n                                whitespace = qfalse;\n                            }\n                            \n                            // copy quoted strings unmolested\n                            if (c == '\"') {\n                                    *out++ = c;\n                                    in++;\n                                    while (1) {\n                                        c = *in;\n                                        if (c && c != '\"') {\n                                            *out++ = c;\n                                            in++;\n                                        } else {\n                                            break;\n                                        }\n                                    }\n                                    if (c == '\"') {\n                                        *out++ = c;\n                                        in++;\n                                    }\n                            } else {\n                                *out = c;\n                                out++;\n                                in++;\n                            }\n\t\t\t}\n\t\t}\n\t}\n\t*out = 0;\n\treturn out - data_p;\n}\n\nchar *COM_ParseExt( char **data_p, qboolean allowLineBreaks )\n{\n\tint c = 0, len;\n\tqboolean hasNewLines = qfalse;\n\tchar *data;\n\n\tdata = *data_p;\n\tlen = 0;\n\tcom_token[0] = 0;\n\n\t// make sure incoming data is valid\n\tif ( !data )\n\t{\n\t\t*data_p = NULL;\n\t\treturn com_token;\n\t}\n\n\twhile ( 1 )\n\t{\n\t\t// skip whitespace\n\t\tdata = SkipWhitespace( data, &hasNewLines );\n\t\tif ( !data )\n\t\t{\n\t\t\t*data_p = NULL;\n\t\t\treturn com_token;\n\t\t}\n\t\tif ( hasNewLines && !allowLineBreaks )\n\t\t{\n\t\t\t*data_p = data;\n\t\t\treturn com_token;\n\t\t}\n\n\t\tc = *data;\n\n\t\t// skip double slash comments\n\t\tif ( c == '/' && data[1] == '/' )\n\t\t{\n\t\t\tdata += 2;\n\t\t\twhile (*data && *data != '\\n') {\n\t\t\t\tdata++;\n\t\t\t}\n\t\t}\n\t\t// skip /* */ comments\n\t\telse if ( c=='/' && data[1] == '*' ) \n\t\t{\n\t\t\tdata += 2;\n\t\t\twhile ( *data && ( *data != '*' || data[1] != '/' ) ) \n\t\t\t{\n\t\t\t\tdata++;\n\t\t\t}\n\t\t\tif ( *data ) \n\t\t\t{\n\t\t\t\tdata += 2;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// handle quoted strings\n\tif (c == '\\\"')\n\t{\n\t\tdata++;\n\t\twhile (1)\n\t\t{\n\t\t\tc = *data++;\n\t\t\tif (c=='\\\"' || !c)\n\t\t\t{\n\t\t\t\tcom_token[len] = 0;\n\t\t\t\t*data_p = ( char * ) data;\n\t\t\t\treturn com_token;\n\t\t\t}\n\t\t\tif (len < MAX_TOKEN_CHARS)\n\t\t\t{\n\t\t\t\tcom_token[len] = c;\n\t\t\t\tlen++;\n\t\t\t}\n\t\t}\n\t}\n\n\t// parse a regular word\n\tdo\n\t{\n\t\tif (len < MAX_TOKEN_CHARS)\n\t\t{\n\t\t\tcom_token[len] = c;\n\t\t\tlen++;\n\t\t}\n\t\tdata++;\n\t\tc = *data;\n\t\tif ( c == '\\n' )\n\t\t\tcom_lines++;\n\t} while (c>32);\n\n\tif (len == MAX_TOKEN_CHARS)\n\t{\n//\t\tCom_Printf (\"Token exceeded %i chars, discarded.\\n\", MAX_TOKEN_CHARS);\n\t\tlen = 0;\n\t}\n\tcom_token[len] = 0;\n\n\t*data_p = ( char * ) data;\n\treturn com_token;\n}\n\n\n#if 0\n// no longer used\n/*\n===============\nCOM_ParseInfos\n===============\n*/\nint COM_ParseInfos( char *buf, int max, char infos[][MAX_INFO_STRING] ) {\n\tchar\t*token;\n\tint\t\tcount;\n\tchar\tkey[MAX_TOKEN_CHARS];\n\n\tcount = 0;\n\n\twhile ( 1 ) {\n\t\ttoken = COM_Parse( &buf );\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( strcmp( token, \"{\" ) ) {\n\t\t\tCom_Printf( \"Missing { in info file\\n\" );\n\t\t\tbreak;\n\t\t}\n\n\t\tif ( count == max ) {\n\t\t\tCom_Printf( \"Max infos exceeded\\n\" );\n\t\t\tbreak;\n\t\t}\n\n\t\tinfos[count][0] = 0;\n\t\twhile ( 1 ) {\n\t\t\ttoken = COM_ParseExt( &buf, qtrue );\n\t\t\tif ( !token[0] ) {\n\t\t\t\tCom_Printf( \"Unexpected end of info file\\n\" );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( !strcmp( token, \"}\" ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tQ_strncpyz( key, token, sizeof( key ) );\n\n\t\t\ttoken = COM_ParseExt( &buf, qfalse );\n\t\t\tif ( !token[0] ) {\n\t\t\t\tstrcpy( token, \"<NULL>\" );\n\t\t\t}\n\t\t\tInfo_SetValueForKey( infos[count], key, token );\n\t\t}\n\t\tcount++;\n\t}\n\n\treturn count;\n}\n#endif\n\n\n/*\n==================\nCOM_MatchToken\n==================\n*/\nvoid COM_MatchToken( char **buf_p, char *match ) {\n\tchar\t*token;\n\n\ttoken = COM_Parse( buf_p );\n\tif ( strcmp( token, match ) ) {\n\t\tCom_Error( ERR_DROP, \"MatchToken: %s != %s\", token, match );\n\t}\n}\n\n\n/*\n=================\nSkipBracedSection\n\nThe next token should be an open brace.\nSkips until a matching close brace is found.\nInternal brace depths are properly skipped.\n=================\n*/\nvoid SkipBracedSection (char **program) {\n\tchar\t\t\t*token;\n\tint\t\t\t\tdepth;\n\n\tdepth = 0;\n\tdo {\n\t\ttoken = COM_ParseExt( program, qtrue );\n\t\tif( token[1] == 0 ) {\n\t\t\tif( token[0] == '{' ) {\n\t\t\t\tdepth++;\n\t\t\t}\n\t\t\telse if( token[0] == '}' ) {\n\t\t\t\tdepth--;\n\t\t\t}\n\t\t}\n\t} while( depth && *program );\n}\n\n/*\n=================\nSkipRestOfLine\n=================\n*/\nvoid SkipRestOfLine ( char **data ) {\n\tchar\t*p;\n\tint\t\tc;\n\n\tp = *data;\n\twhile ( (c = *p++) != 0 ) {\n\t\tif ( c == '\\n' ) {\n\t\t\tcom_lines++;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t*data = p;\n}\n\n\nvoid Parse1DMatrix (char **buf_p, int x, float *m) {\n\tchar\t*token;\n\tint\t\ti;\n\n\tCOM_MatchToken( buf_p, \"(\" );\n\n\tfor (i = 0 ; i < x ; i++) {\n\t\ttoken = COM_Parse(buf_p);\n\t\tm[i] = atof(token);\n\t}\n\n\tCOM_MatchToken( buf_p, \")\" );\n}\n\nvoid Parse2DMatrix (char **buf_p, int y, int x, float *m) {\n\tint\t\ti;\n\n\tCOM_MatchToken( buf_p, \"(\" );\n\n\tfor (i = 0 ; i < y ; i++) {\n\t\tParse1DMatrix (buf_p, x, m + i * x);\n\t}\n\n\tCOM_MatchToken( buf_p, \")\" );\n}\n\nvoid Parse3DMatrix (char **buf_p, int z, int y, int x, float *m) {\n\tint\t\ti;\n\n\tCOM_MatchToken( buf_p, \"(\" );\n\n\tfor (i = 0 ; i < z ; i++) {\n\t\tParse2DMatrix (buf_p, y, x, m + i * x*y);\n\t}\n\n\tCOM_MatchToken( buf_p, \")\" );\n}\n\n\n/*\n============================================================================\n\n\t\t\t\t\tLIBRARY REPLACEMENT FUNCTIONS\n\n============================================================================\n*/\n\nint Q_isprint( int c )\n{\n\tif ( c >= 0x20 && c <= 0x7E )\n\t\treturn ( 1 );\n\treturn ( 0 );\n}\n\nint Q_islower( int c )\n{\n\tif (c >= 'a' && c <= 'z')\n\t\treturn ( 1 );\n\treturn ( 0 );\n}\n\nint Q_isupper( int c )\n{\n\tif (c >= 'A' && c <= 'Z')\n\t\treturn ( 1 );\n\treturn ( 0 );\n}\n\nint Q_isalpha( int c )\n{\n\tif ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))\n\t\treturn ( 1 );\n\treturn ( 0 );\n}\n\nchar* Q_strrchr( const char* string, int c )\n{\n\tchar cc = c;\n\tchar *s;\n\tchar *sp=(char *)0;\n\n\ts = (char*)string;\n\n\twhile (*s)\n\t{\n\t\tif (*s == cc)\n\t\t\tsp = s;\n\t\ts++;\n\t}\n\tif (cc == 0)\n\t\tsp = s;\n\n\treturn sp;\n}\n\n/*\n=============\nQ_strncpyz\n \nSafe strncpy that ensures a trailing zero\n=============\n*/\nvoid Q_strncpyz( char *dest, const char *src, int destsize ) {\n  // bk001129 - also NULL dest\n  if ( !dest ) {\n    Com_Error( ERR_FATAL, \"Q_strncpyz: NULL dest\" );\n  }\n\tif ( !src ) {\n\t\tCom_Error( ERR_FATAL, \"Q_strncpyz: NULL src\" );\n\t}\n\tif ( destsize < 1 ) {\n\t\tCom_Error(ERR_FATAL,\"Q_strncpyz: destsize < 1\" ); \n\t}\n\n\tstrncpy( dest, src, destsize-1 );\n  dest[destsize-1] = 0;\n}\n                 \nint Q_stricmpn (const char *s1, const char *s2, int n) {\n\tint\t\tc1, c2;\n\n\t// bk001129 - moved in 1.17 fix not in id codebase\n        if ( s1 == NULL ) {\n           if ( s2 == NULL )\n             return 0;\n           else\n             return -1;\n        }\n        else if ( s2==NULL )\n          return 1;\n\n\n\t\n\tdo {\n\t\tc1 = *s1++;\n\t\tc2 = *s2++;\n\n\t\tif (!n--) {\n\t\t\treturn 0;\t\t// strings are equal until end point\n\t\t}\n\t\t\n\t\tif (c1 != c2) {\n\t\t\tif (c1 >= 'a' && c1 <= 'z') {\n\t\t\t\tc1 -= ('a' - 'A');\n\t\t\t}\n\t\t\tif (c2 >= 'a' && c2 <= 'z') {\n\t\t\t\tc2 -= ('a' - 'A');\n\t\t\t}\n\t\t\tif (c1 != c2) {\n\t\t\t\treturn c1 < c2 ? -1 : 1;\n\t\t\t}\n\t\t}\n\t} while (c1);\n\t\n\treturn 0;\t\t// strings are equal\n}\n\nint Q_strncmp (const char *s1, const char *s2, int n) {\n\tint\t\tc1, c2;\n\t\n\tdo {\n\t\tc1 = *s1++;\n\t\tc2 = *s2++;\n\n\t\tif (!n--) {\n\t\t\treturn 0;\t\t// strings are equal until end point\n\t\t}\n\t\t\n\t\tif (c1 != c2) {\n\t\t\treturn c1 < c2 ? -1 : 1;\n\t\t}\n\t} while (c1);\n\t\n\treturn 0;\t\t// strings are equal\n}\n\nint Q_stricmp (const char *s1, const char *s2) {\n\treturn (s1 && s2) ? Q_stricmpn (s1, s2, 99999) : -1;\n}\n\n\nchar *Q_strlwr( char *s1 ) {\n    char\t*s;\n\n    s = s1;\n\twhile ( *s ) {\n\t\t*s = tolower(*s);\n\t\ts++;\n\t}\n    return s1;\n}\n\nchar *Q_strupr( char *s1 ) {\n    char\t*s;\n\n    s = s1;\n\twhile ( *s ) {\n\t\t*s = toupper(*s);\n\t\ts++;\n\t}\n    return s1;\n}\n\n\n// never goes past bounds or leaves without a terminating 0\nvoid Q_strcat( char *dest, int size, const char *src ) {\n\tint\t\tl1;\n\n\tl1 = strlen( dest );\n\tif ( l1 >= size ) {\n\t\tCom_Error( ERR_FATAL, \"Q_strcat: already overflowed\" );\n\t}\n\tQ_strncpyz( dest + l1, src, size - l1 );\n}\n\n\nint Q_PrintStrlen( const char *string ) {\n\tint\t\t\tlen;\n\tconst char\t*p;\n\n\tif( !string ) {\n\t\treturn 0;\n\t}\n\n\tlen = 0;\n\tp = string;\n\twhile( *p ) {\n\t\tif( Q_IsColorString( p ) ) {\n\t\t\tp += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tp++;\n\t\tlen++;\n\t}\n\n\treturn len;\n}\n\n\nchar *Q_CleanStr( char *string ) {\n\tchar*\td;\n\tchar*\ts;\n\tint\t\tc;\n\n\ts = string;\n\td = string;\n\twhile ((c = *s) != 0 ) {\n\t\tif ( Q_IsColorString( s ) ) {\n\t\t\ts++;\n\t\t}\t\t\n\t\telse if ( c >= 0x20 && c <= 0x7E ) {\n\t\t\t*d++ = c;\n\t\t}\n\t\ts++;\n\t}\n\t*d = '\\0';\n\n\treturn string;\n}\n\n\nvoid QDECL Com_sprintf( char *dest, int size, const char *fmt, ...) {\n\tint\t\tlen;\n\tva_list\t\targptr;\n\tchar\tbigbuffer[32000];\t// big, but small enough to fit in PPC stack\n\n\tva_start (argptr,fmt);\n\tlen = vsprintf (bigbuffer,fmt,argptr);\n\tva_end (argptr);\n\tif ( len >= sizeof( bigbuffer ) ) {\n\t\tCom_Error( ERR_FATAL, \"Com_sprintf: overflowed bigbuffer\" );\n\t}\n\tif (len >= size) {\n\t\tCom_Printf (\"Com_sprintf: overflow of %i in %i\\n\", len, size);\n#ifdef\t_DEBUG\n\t\t__asm {\n\t\t\tint 3;\n\t\t}\n#endif\n\t}\n\tQ_strncpyz (dest, bigbuffer, size );\n}\n\n\n/*\n============\nva\n\ndoes a varargs printf into a temp buffer, so I don't need to have\nvarargs versions of all text functions.\nFIXME: make this buffer size safe someday\n============\n*/\nchar\t* QDECL va( char *format, ... ) {\n\tva_list\t\targptr;\n\tstatic char\t\tstring[2][32000];\t// in case va is called by nested functions\n\tstatic int\t\tindex = 0;\n\tchar\t*buf;\n\n\tbuf = string[index & 1];\n\tindex++;\n\n\tva_start (argptr, format);\n\tvsprintf (buf, format,argptr);\n\tva_end (argptr);\n\n\treturn buf;\n}\n\n\n/*\n=====================================================================\n\n  INFO STRINGS\n\n=====================================================================\n*/\n\n/*\n===============\nInfo_ValueForKey\n\nSearches the string for the given\nkey and returns the associated value, or an empty string.\nFIXME: overflow check?\n===============\n*/\nchar *Info_ValueForKey( const char *s, const char *key ) {\n\tchar\tpkey[BIG_INFO_KEY];\n\tstatic\tchar value[2][BIG_INFO_VALUE];\t// use two buffers so compares\n\t\t\t\t\t\t\t\t\t\t\t// work without stomping on each other\n\tstatic\tint\tvalueindex = 0;\n\tchar\t*o;\n\t\n\tif ( !s || !key ) {\n\t\treturn \"\";\n\t}\n\n\tif ( strlen( s ) >= BIG_INFO_STRING ) {\n\t\tCom_Error( ERR_DROP, \"Info_ValueForKey: oversize infostring\" );\n\t}\n\n\tvalueindex ^= 1;\n\tif (*s == '\\\\')\n\t\ts++;\n\twhile (1)\n\t{\n\t\to = pkey;\n\t\twhile (*s != '\\\\')\n\t\t{\n\t\t\tif (!*s)\n\t\t\t\treturn \"\";\n\t\t\t*o++ = *s++;\n\t\t}\n\t\t*o = 0;\n\t\ts++;\n\n\t\to = value[valueindex];\n\n\t\twhile (*s != '\\\\' && *s)\n\t\t{\n\t\t\t*o++ = *s++;\n\t\t}\n\t\t*o = 0;\n\n\t\tif (!Q_stricmp (key, pkey) )\n\t\t\treturn value[valueindex];\n\n\t\tif (!*s)\n\t\t\tbreak;\n\t\ts++;\n\t}\n\n\treturn \"\";\n}\n\n\n/*\n===================\nInfo_NextPair\n\nUsed to itterate through all the key/value pairs in an info string\n===================\n*/\nvoid Info_NextPair( const char **head, char *key, char *value ) {\n\tchar\t*o;\n\tconst char\t*s;\n\n\ts = *head;\n\n\tif ( *s == '\\\\' ) {\n\t\ts++;\n\t}\n\tkey[0] = 0;\n\tvalue[0] = 0;\n\n\to = key;\n\twhile ( *s != '\\\\' ) {\n\t\tif ( !*s ) {\n\t\t\t*o = 0;\n\t\t\t*head = s;\n\t\t\treturn;\n\t\t}\n\t\t*o++ = *s++;\n\t}\n\t*o = 0;\n\ts++;\n\n\to = value;\n\twhile ( *s != '\\\\' && *s ) {\n\t\t*o++ = *s++;\n\t}\n\t*o = 0;\n\n\t*head = s;\n}\n\n\n/*\n===================\nInfo_RemoveKey\n===================\n*/\nvoid Info_RemoveKey( char *s, const char *key ) {\n\tchar\t*start;\n\tchar\tpkey[MAX_INFO_KEY];\n\tchar\tvalue[MAX_INFO_VALUE];\n\tchar\t*o;\n\n\tif ( strlen( s ) >= MAX_INFO_STRING ) {\n\t\tCom_Error( ERR_DROP, \"Info_RemoveKey: oversize infostring\" );\n\t}\n\n\tif (strchr (key, '\\\\')) {\n\t\treturn;\n\t}\n\n\twhile (1)\n\t{\n\t\tstart = s;\n\t\tif (*s == '\\\\')\n\t\t\ts++;\n\t\to = pkey;\n\t\twhile (*s != '\\\\')\n\t\t{\n\t\t\tif (!*s)\n\t\t\t\treturn;\n\t\t\t*o++ = *s++;\n\t\t}\n\t\t*o = 0;\n\t\ts++;\n\n\t\to = value;\n\t\twhile (*s != '\\\\' && *s)\n\t\t{\n\t\t\tif (!*s)\n\t\t\t\treturn;\n\t\t\t*o++ = *s++;\n\t\t}\n\t\t*o = 0;\n\n\t\tif (!strcmp (key, pkey) )\n\t\t{\n\t\t\tstrcpy (start, s);\t// remove this part\n\t\t\treturn;\n\t\t}\n\n\t\tif (!*s)\n\t\t\treturn;\n\t}\n\n}\n\n/*\n===================\nInfo_RemoveKey_Big\n===================\n*/\nvoid Info_RemoveKey_Big( char *s, const char *key ) {\n\tchar\t*start;\n\tchar\tpkey[BIG_INFO_KEY];\n\tchar\tvalue[BIG_INFO_VALUE];\n\tchar\t*o;\n\n\tif ( strlen( s ) >= BIG_INFO_STRING ) {\n\t\tCom_Error( ERR_DROP, \"Info_RemoveKey_Big: oversize infostring\" );\n\t}\n\n\tif (strchr (key, '\\\\')) {\n\t\treturn;\n\t}\n\n\twhile (1)\n\t{\n\t\tstart = s;\n\t\tif (*s == '\\\\')\n\t\t\ts++;\n\t\to = pkey;\n\t\twhile (*s != '\\\\')\n\t\t{\n\t\t\tif (!*s)\n\t\t\t\treturn;\n\t\t\t*o++ = *s++;\n\t\t}\n\t\t*o = 0;\n\t\ts++;\n\n\t\to = value;\n\t\twhile (*s != '\\\\' && *s)\n\t\t{\n\t\t\tif (!*s)\n\t\t\t\treturn;\n\t\t\t*o++ = *s++;\n\t\t}\n\t\t*o = 0;\n\n\t\tif (!strcmp (key, pkey) )\n\t\t{\n\t\t\tstrcpy (start, s);\t// remove this part\n\t\t\treturn;\n\t\t}\n\n\t\tif (!*s)\n\t\t\treturn;\n\t}\n\n}\n\n\n\n\n/*\n==================\nInfo_Validate\n\nSome characters are illegal in info strings because they\ncan mess up the server's parsing\n==================\n*/\nqboolean Info_Validate( const char *s ) {\n\tif ( strchr( s, '\\\"' ) ) {\n\t\treturn qfalse;\n\t}\n\tif ( strchr( s, ';' ) ) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n/*\n==================\nInfo_SetValueForKey\n\nChanges or adds a key/value pair\n==================\n*/\nvoid Info_SetValueForKey( char *s, const char *key, const char *value ) {\n\tchar\tnewi[MAX_INFO_STRING];\n\n\tif ( strlen( s ) >= MAX_INFO_STRING ) {\n\t\tCom_Error( ERR_DROP, \"Info_SetValueForKey: oversize infostring\" );\n\t}\n\n\tif (strchr (key, '\\\\') || strchr (value, '\\\\'))\n\t{\n\t\tCom_Printf (\"Can't use keys or values with a \\\\\\n\");\n\t\treturn;\n\t}\n\n\tif (strchr (key, ';') || strchr (value, ';'))\n\t{\n\t\tCom_Printf (\"Can't use keys or values with a semicolon\\n\");\n\t\treturn;\n\t}\n\n\tif (strchr (key, '\\\"') || strchr (value, '\\\"'))\n\t{\n\t\tCom_Printf (\"Can't use keys or values with a \\\"\\n\");\n\t\treturn;\n\t}\n\n\tInfo_RemoveKey (s, key);\n\tif (!value || !strlen(value))\n\t\treturn;\n\n\tCom_sprintf (newi, sizeof(newi), \"\\\\%s\\\\%s\", key, value);\n\n\tif (strlen(newi) + strlen(s) > MAX_INFO_STRING)\n\t{\n\t\tCom_Printf (\"Info string length exceeded\\n\");\n\t\treturn;\n\t}\n\n\tstrcat (newi, s);\n\tstrcpy (s, newi);\n}\n\n/*\n==================\nInfo_SetValueForKey_Big\n\nChanges or adds a key/value pair\n==================\n*/\nvoid Info_SetValueForKey_Big( char *s, const char *key, const char *value ) {\n\tchar\tnewi[BIG_INFO_STRING];\n\n\tif ( strlen( s ) >= BIG_INFO_STRING ) {\n\t\tCom_Error( ERR_DROP, \"Info_SetValueForKey: oversize infostring\" );\n\t}\n\n\tif (strchr (key, '\\\\') || strchr (value, '\\\\'))\n\t{\n\t\tCom_Printf (\"Can't use keys or values with a \\\\\\n\");\n\t\treturn;\n\t}\n\n\tif (strchr (key, ';') || strchr (value, ';'))\n\t{\n\t\tCom_Printf (\"Can't use keys or values with a semicolon\\n\");\n\t\treturn;\n\t}\n\n\tif (strchr (key, '\\\"') || strchr (value, '\\\"'))\n\t{\n\t\tCom_Printf (\"Can't use keys or values with a \\\"\\n\");\n\t\treturn;\n\t}\n\n\tInfo_RemoveKey_Big (s, key);\n\tif (!value || !strlen(value))\n\t\treturn;\n\n\tCom_sprintf (newi, sizeof(newi), \"\\\\%s\\\\%s\", key, value);\n\n\tif (strlen(newi) + strlen(s) > BIG_INFO_STRING)\n\t{\n\t\tCom_Printf (\"BIG Info string length exceeded\\n\");\n\t\treturn;\n\t}\n\n\tstrcat (s, newi);\n}\n\n\n\n\n//====================================================================\n\n\n"
  },
  {
    "path": "code/game/q_shared.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#ifndef __Q_SHARED_H\n#define __Q_SHARED_H\n\n// q_shared.h -- included first by ALL program modules.\n// A user mod should never modify this file\n\n#define\tQ3_VERSION\t\t\"Q3 1.32b\"\n// 1.32 released 7-10-2002\n\n#define MAX_TEAMNAME 32\n\n#ifdef _WIN32\n\n#pragma warning(disable : 4018)     // signed/unsigned mismatch\n#pragma warning(disable : 4032)\n#pragma warning(disable : 4051)\n#pragma warning(disable : 4057)\t\t// slightly different base types\n#pragma warning(disable : 4100)\t\t// unreferenced formal parameter\n#pragma warning(disable : 4115)\n#pragma warning(disable : 4125)\t\t// decimal digit terminates octal escape sequence\n#pragma warning(disable : 4127)\t\t// conditional expression is constant\n#pragma warning(disable : 4136)\n#pragma warning(disable : 4152)\t\t// nonstandard extension, function/data pointer conversion in expression\n//#pragma warning(disable : 4201)\n//#pragma warning(disable : 4214)\n#pragma warning(disable : 4244)\n#pragma warning(disable : 4142)\t\t// benign redefinition\n//#pragma warning(disable : 4305)\t\t// truncation from const double to float\n//#pragma warning(disable : 4310)\t\t// cast truncates constant value\n//#pragma warning(disable:  4505) \t// unreferenced local function has been removed\n#pragma warning(disable : 4514)\n#pragma warning(disable : 4702)\t\t// unreachable code\n#pragma warning(disable : 4711)\t\t// selected for automatic inline expansion\n#pragma warning(disable : 4220)\t\t// varargs matches remaining parameters\n#endif\n\n/**********************************************************************\n  VM Considerations\n\n  The VM can not use the standard system headers because we aren't really\n  using the compiler they were meant for.  We use bg_lib.h which contains\n  prototypes for the functions we define for our own use in bg_lib.c.\n\n  When writing mods, please add needed headers HERE, do not start including\n  stuff like <stdio.h> in the various .c files that make up each of the VMs\n  since you will be including system headers files can will have issues.\n\n  Remember, if you use a C library function that is not defined in bg_lib.c,\n  you will have to add your own version for support in the VM.\n\n **********************************************************************/\n\n#ifdef Q3_VM\n\n#include \"bg_lib.h\"\n\n#else\n\n#include <assert.h>\n#include <math.h>\n#include <stdio.h>\n#include <stdarg.h>\n#include <string.h>\n#include <stdlib.h>\n#include <time.h>\n#include <ctype.h>\n#include <limits.h>\n\n#endif\n\n#ifdef _WIN32\n\n//#pragma intrinsic( memset, memcpy )\n\n#endif\n\n\n// this is the define for determining if we have an asm version of a C function\n#if (defined _M_IX86 || defined __i386__) && !defined __sun__  && !defined __LCC__\n#define id386\t1\n#else\n#define id386\t0\n#endif\n\n#if (defined(powerc) || defined(powerpc) || defined(ppc) || defined(__ppc) || defined(__ppc__)) && !defined(C_ONLY)\n#define idppc\t1\n#if defined(__VEC__)\n#define idppc_altivec 1\n#else\n#define idppc_altivec 0\n#endif\n#else\n#define idppc\t0\n#define idppc_altivec 0\n#endif\n\n// for windows fastcall option\n\n#define\tQDECL\n\nshort   ShortSwap (short l);\nint\t\tLongSwap (int l);\nfloat\tFloatSwap (const float *f);\n\n//======================= WIN32 DEFINES =================================\n\n#ifdef WIN32\n\n#define\tMAC_STATIC\n\n#undef QDECL\n#define\tQDECL\t__cdecl\n\n// buildstring will be incorporated into the version string\n#ifdef NDEBUG\n#ifdef _M_IX86\n#define\tCPUSTRING\t\"win-x86\"\n#elif defined _M_ALPHA\n#define\tCPUSTRING\t\"win-AXP\"\n#endif\n#else\n#ifdef _M_IX86\n#define\tCPUSTRING\t\"win-x86-debug\"\n#elif defined _M_ALPHA\n#define\tCPUSTRING\t\"win-AXP-debug\"\n#endif\n#endif\n\n#define ID_INLINE __inline \n\nstatic ID_INLINE short BigShort( short l) { return ShortSwap(l); }\n#define LittleShort\nstatic ID_INLINE int BigLong(int l) { LongSwap(l); }\n#define LittleLong\nstatic ID_INLINE float BigFloat(const float *l) { FloatSwap(l); }\n#define LittleFloat\n\n#define\tPATH_SEP '\\\\'\n\n#endif\n\n//======================= MAC OS X DEFINES =====================\n\n#if defined(MACOS_X)\n\n#define MAC_STATIC\n#define __cdecl\n#define __declspec(x)\n#define stricmp strcasecmp\n#define ID_INLINE inline \n\n#ifdef __ppc__\n#define CPUSTRING\t\"MacOSX-ppc\"\n#elif defined __i386__\n#define CPUSTRING\t\"MacOSX-i386\"\n#else\n#define CPUSTRING\t\"MacOSX-other\"\n#endif\n\n#define\tPATH_SEP\t'/'\n\n#define __rlwimi(out, in, shift, maskBegin, maskEnd) asm(\"rlwimi %0,%1,%2,%3,%4\" : \"=r\" (out) : \"r\" (in), \"i\" (shift), \"i\" (maskBegin), \"i\" (maskEnd))\n#define __dcbt(addr, offset) asm(\"dcbt %0,%1\" : : \"b\" (addr), \"r\" (offset))\n\nstatic inline unsigned int __lwbrx(register void *addr, register int offset) {\n    register unsigned int word;\n    \n    asm(\"lwbrx %0,%2,%1\" : \"=r\" (word) : \"r\" (addr), \"b\" (offset));\n    return word;\n}\n\nstatic inline unsigned short __lhbrx(register void *addr, register int offset) {\n    register unsigned short halfword;\n    \n    asm(\"lhbrx %0,%2,%1\" : \"=r\" (halfword) : \"r\" (addr), \"b\" (offset));\n    return halfword;\n}\n\nstatic inline float __fctiw(register float f) {\n    register float fi;\n    \n    asm(\"fctiw %0,%1\" : \"=f\" (fi) : \"f\" (f));\n\n    return fi;\n}\n\n#define BigShort\nstatic inline short LittleShort(short l) { return ShortSwap(l); }\n#define BigLong\nstatic inline int LittleLong (int l) { return LongSwap(l); }\n#define BigFloat\nstatic inline float LittleFloat (const float l) { return FloatSwap(&l); }\n\n#endif\n\n//======================= MAC DEFINES =================================\n\n#ifdef __MACOS__\n\n#include <MacTypes.h>\n#define\tMAC_STATIC\n#define ID_INLINE inline \n\n#define\tCPUSTRING\t\"MacOS-PPC\"\n\n#define\tPATH_SEP ':'\n\nvoid Sys_PumpEvents( void );\n\n#define BigShort\nstatic inline short LittleShort(short l) { return ShortSwap(l); }\n#define BigLong\nstatic inline int LittleLong (int l) { return LongSwap(l); }\n#define BigFloat\nstatic inline float LittleFloat (const float l) { return FloatSwap(&l); }\n\n#endif\n\n//======================= LINUX DEFINES =================================\n\n// the mac compiler can't handle >32k of locals, so we\n// just waste space and make big arrays static...\n#ifdef __linux__\n\n// bk001205 - from Makefile\n#define stricmp strcasecmp\n\n#define\tMAC_STATIC // bk: FIXME\n#define ID_INLINE inline \n\n#ifdef __i386__\n#define\tCPUSTRING\t\"linux-i386\"\n#elif defined __axp__\n#define\tCPUSTRING\t\"linux-alpha\"\n#else\n#define\tCPUSTRING\t\"linux-other\"\n#endif\n\n#define\tPATH_SEP '/'\n\n// bk001205 - try\n#ifdef Q3_STATIC\n#define\tGAME_HARD_LINKED\n#define\tCGAME_HARD_LINKED\n#define\tUI_HARD_LINKED\n#define\tBOTLIB_HARD_LINKED\n#endif\n\n#if !idppc\ninline static short BigShort( short l) { return ShortSwap(l); }\n#define LittleShort\ninline static int BigLong(int l) { return LongSwap(l); }\n#define LittleLong\ninline static float BigFloat(const float *l) { return FloatSwap(l); }\n#define LittleFloat\n#else\n#define BigShort\ninline static short LittleShort(short l) { return ShortSwap(l); }\n#define BigLong\ninline static int LittleLong (int l) { return LongSwap(l); }\n#define BigFloat\ninline static float LittleFloat (const float *l) { return FloatSwap(l); }\n#endif\n\n#endif\n\n//======================= FreeBSD DEFINES =====================\n#ifdef __FreeBSD__ // rb010123\n\n#define stricmp strcasecmp\n\n#define MAC_STATIC\n#define ID_INLINE inline \n\n#ifdef __i386__\n#define CPUSTRING       \"freebsd-i386\"\n#elif defined __axp__\n#define CPUSTRING       \"freebsd-alpha\"\n#else\n#define CPUSTRING       \"freebsd-other\"\n#endif\n\n#define\tPATH_SEP '/'\n\n// bk010116 - omitted Q3STATIC (see Linux above), broken target\n\n#if !idppc\nstatic short BigShort( short l) { return ShortSwap(l); }\n#define LittleShort\nstatic int BigLong(int l) { LongSwap(l); }\n#define LittleLong\nstatic float BigFloat(const float *l) { FloatSwap(l); }\n#define LittleFloat\n#else\n#define BigShort\nstatic short LittleShort(short l) { return ShortSwap(l); }\n#define BigLong\nstatic int LittleLong (int l) { return LongSwap(l); }\n#define BigFloat\nstatic float LittleFloat (const float *l) { return FloatSwap(l); }\n#endif\n\n#endif\n\n//=============================================================\n\ntypedef unsigned char \t\tbyte;\n\ntypedef enum {qfalse, qtrue}\tqboolean;\n\ntypedef int\t\tqhandle_t;\ntypedef int\t\tsfxHandle_t;\ntypedef int\t\tfileHandle_t;\ntypedef int\t\tclipHandle_t;\n\n\n#ifndef NULL\n#define NULL ((void *)0)\n#endif\n\n#define\tMAX_QINT\t\t\t0x7fffffff\n#define\tMIN_QINT\t\t\t(-MAX_QINT-1)\n\n\n// angle indexes\n#define\tPITCH\t\t\t\t0\t\t// up / down\n#define\tYAW\t\t\t\t\t1\t\t// left / right\n#define\tROLL\t\t\t\t2\t\t// fall over\n\n// the game guarantees that no string from the network will ever\n// exceed MAX_STRING_CHARS\n#define\tMAX_STRING_CHARS\t1024\t// max length of a string passed to Cmd_TokenizeString\n#define\tMAX_STRING_TOKENS\t1024\t// max tokens resulting from Cmd_TokenizeString\n#define\tMAX_TOKEN_CHARS\t\t1024\t// max length of an individual token\n\n#define\tMAX_INFO_STRING\t\t1024\n#define\tMAX_INFO_KEY\t\t  1024\n#define\tMAX_INFO_VALUE\t\t1024\n\n#define\tBIG_INFO_STRING\t\t8192  // used for system info key only\n#define\tBIG_INFO_KEY\t\t  8192\n#define\tBIG_INFO_VALUE\t\t8192\n\n\n#define\tMAX_QPATH\t\t\t64\t\t// max length of a quake game pathname\n#ifdef PATH_MAX\n#define MAX_OSPATH\t\t\tPATH_MAX\n#else\n#define\tMAX_OSPATH\t\t\t256\t\t// max length of a filesystem pathname\n#endif\n\n#define\tMAX_NAME_LENGTH\t\t32\t\t// max length of a client name\n\n#define\tMAX_SAY_TEXT\t150\n\n// paramters for command buffer stuffing\ntypedef enum {\n\tEXEC_NOW,\t\t\t// don't return until completed, a VM should NEVER use this,\n\t\t\t\t\t\t// because some commands might cause the VM to be unloaded...\n\tEXEC_INSERT,\t\t// insert at current position, but don't run yet\n\tEXEC_APPEND\t\t\t// add to end of the command buffer (normal case)\n} cbufExec_t;\n\n\n//\n// these aren't needed by any of the VMs.  put in another header?\n//\n#define\tMAX_MAP_AREA_BYTES\t\t32\t\t// bit vector of area visibility\n\n\n// print levels from renderer (FIXME: set up for game / cgame?)\ntypedef enum {\n\tPRINT_ALL,\n\tPRINT_DEVELOPER,\t\t// only print when \"developer 1\"\n\tPRINT_WARNING,\n\tPRINT_ERROR\n} printParm_t;\n\n\n#ifdef ERR_FATAL\n#undef ERR_FATAL\t\t\t// this is be defined in malloc.h\n#endif\n\n// parameters to the main Error routine\ntypedef enum {\n\tERR_FATAL,\t\t\t\t\t// exit the entire game with a popup window\n\tERR_DROP,\t\t\t\t\t// print to console and disconnect from game\n\tERR_SERVERDISCONNECT,\t\t// don't kill server\n\tERR_DISCONNECT,\t\t\t\t// client disconnected from the server\n\tERR_NEED_CD\t\t\t\t\t// pop up the need-cd dialog\n} errorParm_t;\n\n\n// font rendering values used by ui and cgame\n\n#define PROP_GAP_WIDTH\t\t\t3\n#define PROP_SPACE_WIDTH\t\t8\n#define PROP_HEIGHT\t\t\t\t27\n#define PROP_SMALL_SIZE_SCALE\t0.75\n\n#define BLINK_DIVISOR\t\t\t200\n#define PULSE_DIVISOR\t\t\t75\n\n#define UI_LEFT\t\t\t0x00000000\t// default\n#define UI_CENTER\t\t0x00000001\n#define UI_RIGHT\t\t0x00000002\n#define UI_FORMATMASK\t0x00000007\n#define UI_SMALLFONT\t0x00000010\n#define UI_BIGFONT\t\t0x00000020\t// default\n#define UI_GIANTFONT\t0x00000040\n#define UI_DROPSHADOW\t0x00000800\n#define UI_BLINK\t\t0x00001000\n#define UI_INVERSE\t\t0x00002000\n#define UI_PULSE\t\t0x00004000\n\n#if defined(_DEBUG) && !defined(BSPC)\n\t#define HUNK_DEBUG\n#endif\n\ntypedef enum {\n\th_high,\n\th_low,\n\th_dontcare\n} ha_pref;\n\n#ifdef HUNK_DEBUG\n#define Hunk_Alloc( size, preference )\t\t\t\tHunk_AllocDebug(size, preference, #size, __FILE__, __LINE__)\nvoid *Hunk_AllocDebug( int size, ha_pref preference, char *label, char *file, int line );\n#else\nvoid *Hunk_Alloc( int size, ha_pref preference );\n#endif\n\n#ifdef __linux__\n// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=371\n// custom Snd_Memset implementation for glibc memset bug workaround\nvoid Snd_Memset (void* dest, const int val, const size_t count);\n#else\n#define Snd_Memset Com_Memset\n#endif\n\n#if !( defined __VECTORC )\nvoid Com_Memset (void* dest, const int val, const size_t count);\nvoid Com_Memcpy (void* dest, const void* src, const size_t count);\n#else\n#define Com_Memset memset\n#define Com_Memcpy memcpy\n#endif\n\n#define CIN_system\t1\n#define CIN_loop\t2\n#define\tCIN_hold\t4\n#define CIN_silent\t8\n#define CIN_shader\t16\n\n/*\n==============================================================\n\nMATHLIB\n\n==============================================================\n*/\n\n\ntypedef float vec_t;\ntypedef vec_t vec2_t[2];\ntypedef vec_t vec3_t[3];\ntypedef vec_t vec4_t[4];\ntypedef vec_t vec5_t[5];\n\ntypedef\tint\tfixed4_t;\ntypedef\tint\tfixed8_t;\ntypedef\tint\tfixed16_t;\n\n#ifndef M_PI\n#define M_PI\t\t3.14159265358979323846f\t// matches value in gcc v2 math.h\n#endif\n\n#define NUMVERTEXNORMALS\t162\nextern\tvec3_t\tbytedirs[NUMVERTEXNORMALS];\n\n// all drawing is done to a 640*480 virtual screen size\n// and will be automatically scaled to the real resolution\n#define\tSCREEN_WIDTH\t\t640\n#define\tSCREEN_HEIGHT\t\t480\n\n#define TINYCHAR_WIDTH\t\t(SMALLCHAR_WIDTH)\n#define TINYCHAR_HEIGHT\t\t(SMALLCHAR_HEIGHT/2)\n\n#define SMALLCHAR_WIDTH\t\t8\n#define SMALLCHAR_HEIGHT\t16\n\n#define BIGCHAR_WIDTH\t\t16\n#define BIGCHAR_HEIGHT\t\t16\n\n#define\tGIANTCHAR_WIDTH\t\t32\n#define\tGIANTCHAR_HEIGHT\t48\n\nextern\tvec4_t\t\tcolorBlack;\nextern\tvec4_t\t\tcolorRed;\nextern\tvec4_t\t\tcolorGreen;\nextern\tvec4_t\t\tcolorBlue;\nextern\tvec4_t\t\tcolorYellow;\nextern\tvec4_t\t\tcolorMagenta;\nextern\tvec4_t\t\tcolorCyan;\nextern\tvec4_t\t\tcolorWhite;\nextern\tvec4_t\t\tcolorLtGrey;\nextern\tvec4_t\t\tcolorMdGrey;\nextern\tvec4_t\t\tcolorDkGrey;\n\n#define Q_COLOR_ESCAPE\t'^'\n#define Q_IsColorString(p)\t( p && *(p) == Q_COLOR_ESCAPE && *((p)+1) && *((p)+1) != Q_COLOR_ESCAPE )\n\n#define COLOR_BLACK\t\t'0'\n#define COLOR_RED\t\t'1'\n#define COLOR_GREEN\t\t'2'\n#define COLOR_YELLOW\t'3'\n#define COLOR_BLUE\t\t'4'\n#define COLOR_CYAN\t\t'5'\n#define COLOR_MAGENTA\t'6'\n#define COLOR_WHITE\t\t'7'\n#define ColorIndex(c)\t( ( (c) - '0' ) & 7 )\n\n#define S_COLOR_BLACK\t\"^0\"\n#define S_COLOR_RED\t\t\"^1\"\n#define S_COLOR_GREEN\t\"^2\"\n#define S_COLOR_YELLOW\t\"^3\"\n#define S_COLOR_BLUE\t\"^4\"\n#define S_COLOR_CYAN\t\"^5\"\n#define S_COLOR_MAGENTA\t\"^6\"\n#define S_COLOR_WHITE\t\"^7\"\n\nextern vec4_t\tg_color_table[8];\n\n#define\tMAKERGB( v, r, g, b ) v[0]=r;v[1]=g;v[2]=b\n#define\tMAKERGBA( v, r, g, b, a ) v[0]=r;v[1]=g;v[2]=b;v[3]=a\n\n#define DEG2RAD( a ) ( ( (a) * M_PI ) / 180.0F )\n#define RAD2DEG( a ) ( ( (a) * 180.0f ) / M_PI )\n\nstruct cplane_s;\n\nextern\tvec3_t\tvec3_origin;\nextern\tvec3_t\taxisDefault[3];\n\n#define\tnanmask (255<<23)\n\n#define\tIS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)\n\n#if idppc\n\nstatic inline float Q_rsqrt( float number ) {\n\t\tfloat x = 0.5f * number;\n                float y;\n#ifdef __GNUC__            \n                asm(\"frsqrte %0,%1\" : \"=f\" (y) : \"f\" (number));\n#else\n\t\ty = __frsqrte( number );\n#endif\n\t\treturn y * (1.5f - (x * y * y));\n\t}\n\n#ifdef __GNUC__            \nstatic inline float Q_fabs(float x) {\n    float abs_x;\n    \n    asm(\"fabs %0,%1\" : \"=f\" (abs_x) : \"f\" (x));\n    return abs_x;\n}\n#else\n#define Q_fabs __fabsf\n#endif\n\n#else\nfloat Q_fabs( float f );\nfloat Q_rsqrt( float f );\t\t// reciprocal square root\n#endif\n\n#define SQRTFAST( x ) ( (x) * Q_rsqrt( x ) )\n\nsigned char ClampChar( int i );\nsigned short ClampShort( int i );\n\n// this isn't a real cheap function to call!\nint DirToByte( vec3_t dir );\nvoid ByteToDir( int b, vec3_t dir );\n\n#if\t1\n\n#define DotProduct(x,y)\t\t\t((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])\n#define VectorSubtract(a,b,c)\t((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2])\n#define VectorAdd(a,b,c)\t\t((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2])\n#define VectorCopy(a,b)\t\t\t((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2])\n#define\tVectorScale(v, s, o)\t((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s))\n#define\tVectorMA(v, s, b, o)\t((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s))\n\n#else\n\n#define DotProduct(x,y)\t\t\t_DotProduct(x,y)\n#define VectorSubtract(a,b,c)\t_VectorSubtract(a,b,c)\n#define VectorAdd(a,b,c)\t\t_VectorAdd(a,b,c)\n#define VectorCopy(a,b)\t\t\t_VectorCopy(a,b)\n#define\tVectorScale(v, s, o)\t_VectorScale(v,s,o)\n#define\tVectorMA(v, s, b, o)\t_VectorMA(v,s,b,o)\n\n#endif\n\n#ifdef __LCC__\n#ifdef VectorCopy\n#undef VectorCopy\n// this is a little hack to get more efficient copies in our interpreter\ntypedef struct {\n\tfloat\tv[3];\n} vec3struct_t;\n#define VectorCopy(a,b)\t(*(vec3struct_t *)b=*(vec3struct_t *)a)\n#define ID_INLINE static\n#endif\n#endif\n\n#define VectorClear(a)\t\t\t((a)[0]=(a)[1]=(a)[2]=0)\n#define VectorNegate(a,b)\t\t((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2])\n#define VectorSet(v, x, y, z)\t((v)[0]=(x), (v)[1]=(y), (v)[2]=(z))\n#define Vector4Copy(a,b)\t\t((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])\n\n#define\tSnapVector(v) {v[0]=((int)(v[0]));v[1]=((int)(v[1]));v[2]=((int)(v[2]));}\n// just in case you do't want to use the macros\nvec_t _DotProduct( const vec3_t v1, const vec3_t v2 );\nvoid _VectorSubtract( const vec3_t veca, const vec3_t vecb, vec3_t out );\nvoid _VectorAdd( const vec3_t veca, const vec3_t vecb, vec3_t out );\nvoid _VectorCopy( const vec3_t in, vec3_t out );\nvoid _VectorScale( const vec3_t in, float scale, vec3_t out );\nvoid _VectorMA( const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc );\n\nunsigned ColorBytes3 (float r, float g, float b);\nunsigned ColorBytes4 (float r, float g, float b, float a);\n\nfloat NormalizeColor( const vec3_t in, vec3_t out );\n\nfloat RadiusFromBounds( const vec3_t mins, const vec3_t maxs );\nvoid ClearBounds( vec3_t mins, vec3_t maxs );\nvoid AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs );\n\n#ifndef __LCC__\nstatic ID_INLINE int VectorCompare( const vec3_t v1, const vec3_t v2 ) {\n\tif (v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]) {\n\t\treturn 0;\n\t}\t\t\t\n\treturn 1;\n}\n\nstatic ID_INLINE vec_t VectorLength( const vec3_t v ) {\n\treturn (vec_t)sqrt (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);\n}\n\nstatic ID_INLINE vec_t VectorLengthSquared( const vec3_t v ) {\n\treturn (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);\n}\n\nstatic ID_INLINE vec_t Distance( const vec3_t p1, const vec3_t p2 ) {\n\tvec3_t\tv;\n\n\tVectorSubtract (p2, p1, v);\n\treturn VectorLength( v );\n}\n\nstatic ID_INLINE vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 ) {\n\tvec3_t\tv;\n\n\tVectorSubtract (p2, p1, v);\n\treturn v[0]*v[0] + v[1]*v[1] + v[2]*v[2];\n}\n\n// fast vector normalize routine that does not check to make sure\n// that length != 0, nor does it return length, uses rsqrt approximation\nstatic ID_INLINE void VectorNormalizeFast( vec3_t v )\n{\n\tfloat ilength;\n\n\tilength = Q_rsqrt( DotProduct( v, v ) );\n\n\tv[0] *= ilength;\n\tv[1] *= ilength;\n\tv[2] *= ilength;\n}\n\nstatic ID_INLINE void VectorInverse( vec3_t v ){\n\tv[0] = -v[0];\n\tv[1] = -v[1];\n\tv[2] = -v[2];\n}\n\nstatic ID_INLINE void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ) {\n\tcross[0] = v1[1]*v2[2] - v1[2]*v2[1];\n\tcross[1] = v1[2]*v2[0] - v1[0]*v2[2];\n\tcross[2] = v1[0]*v2[1] - v1[1]*v2[0];\n}\n\n#else\nint VectorCompare( const vec3_t v1, const vec3_t v2 );\n\nvec_t VectorLength( const vec3_t v );\n\nvec_t VectorLengthSquared( const vec3_t v );\n\nvec_t Distance( const vec3_t p1, const vec3_t p2 );\n\nvec_t DistanceSquared( const vec3_t p1, const vec3_t p2 );\n \nvoid VectorNormalizeFast( vec3_t v );\n\nvoid VectorInverse( vec3_t v );\n\nvoid CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross );\n\n#endif\n\nvec_t VectorNormalize (vec3_t v);\t\t// returns vector length\nvec_t VectorNormalize2( const vec3_t v, vec3_t out );\nvoid Vector4Scale( const vec4_t in, vec_t scale, vec4_t out );\nvoid VectorRotate( vec3_t in, vec3_t matrix[3], vec3_t out );\nint Q_log2(int val);\n\nfloat Q_acos(float c);\n\nint\t\tQ_rand( int *seed );\nfloat\tQ_random( int *seed );\nfloat\tQ_crandom( int *seed );\n\n#define random()\t((rand () & 0x7fff) / ((float)0x7fff))\n#define crandom()\t(2.0 * (random() - 0.5))\n\nvoid vectoangles( const vec3_t value1, vec3_t angles);\nvoid AnglesToAxis( const vec3_t angles, vec3_t axis[3] );\n\nvoid AxisClear( vec3_t axis[3] );\nvoid AxisCopy( vec3_t in[3], vec3_t out[3] );\n\nvoid SetPlaneSignbits( struct cplane_s *out );\nint BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *plane);\n\nfloat\tAngleMod(float a);\nfloat\tLerpAngle (float from, float to, float frac);\nfloat\tAngleSubtract( float a1, float a2 );\nvoid\tAnglesSubtract( vec3_t v1, vec3_t v2, vec3_t v3 );\n\nfloat AngleNormalize360 ( float angle );\nfloat AngleNormalize180 ( float angle );\nfloat AngleDelta ( float angle1, float angle2 );\n\nqboolean PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const vec3_t c );\nvoid ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal );\nvoid RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees );\nvoid RotateAroundDirection( vec3_t axis[3], float yaw );\nvoid MakeNormalVectors( const vec3_t forward, vec3_t right, vec3_t up );\n// perpendicular vector could be replaced by this\n\n//int\tPlaneTypeForNormal (vec3_t normal);\n\nvoid MatrixMultiply(float in1[3][3], float in2[3][3], float out[3][3]);\nvoid AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);\nvoid PerpendicularVector( vec3_t dst, const vec3_t src );\n\n\n//=============================================\n\nfloat Com_Clamp( float min, float max, float value );\n\nchar\t*COM_SkipPath( char *pathname );\nvoid\tCOM_StripExtension( const char *in, char *out );\nvoid\tCOM_DefaultExtension( char *path, int maxSize, const char *extension );\n\nvoid\tCOM_BeginParseSession( const char *name );\nint\t\tCOM_GetCurrentParseLine( void );\nchar\t*COM_Parse( char **data_p );\nchar\t*COM_ParseExt( char **data_p, qboolean allowLineBreak );\nint\t\tCOM_Compress( char *data_p );\nvoid\tCOM_ParseError( char *format, ... );\nvoid\tCOM_ParseWarning( char *format, ... );\n//int\t\tCOM_ParseInfos( char *buf, int max, char infos[][MAX_INFO_STRING] );\n\n#define MAX_TOKENLENGTH\t\t1024\n\n#ifndef TT_STRING\n//token types\n#define TT_STRING\t\t\t\t\t1\t\t\t// string\n#define TT_LITERAL\t\t\t\t\t2\t\t\t// literal\n#define TT_NUMBER\t\t\t\t\t3\t\t\t// number\n#define TT_NAME\t\t\t\t\t\t4\t\t\t// name\n#define TT_PUNCTUATION\t\t\t\t5\t\t\t// punctuation\n#endif\n\ntypedef struct pc_token_s\n{\n\tint type;\n\tint subtype;\n\tint intvalue;\n\tfloat floatvalue;\n\tchar string[MAX_TOKENLENGTH];\n} pc_token_t;\n\n// data is an in/out parm, returns a parsed out token\n\nvoid\tCOM_MatchToken( char**buf_p, char *match );\n\nvoid SkipBracedSection (char **program);\nvoid SkipRestOfLine ( char **data );\n\nvoid Parse1DMatrix (char **buf_p, int x, float *m);\nvoid Parse2DMatrix (char **buf_p, int y, int x, float *m);\nvoid Parse3DMatrix (char **buf_p, int z, int y, int x, float *m);\n\nvoid\tQDECL Com_sprintf (char *dest, int size, const char *fmt, ...);\n\n\n// mode parm for FS_FOpenFile\ntypedef enum {\n\tFS_READ,\n\tFS_WRITE,\n\tFS_APPEND,\n\tFS_APPEND_SYNC\n} fsMode_t;\n\ntypedef enum {\n\tFS_SEEK_CUR,\n\tFS_SEEK_END,\n\tFS_SEEK_SET\n} fsOrigin_t;\n\n//=============================================\n\nint Q_isprint( int c );\nint Q_islower( int c );\nint Q_isupper( int c );\nint Q_isalpha( int c );\n\n// portable case insensitive compare\nint\t\tQ_stricmp (const char *s1, const char *s2);\nint\t\tQ_strncmp (const char *s1, const char *s2, int n);\nint\t\tQ_stricmpn (const char *s1, const char *s2, int n);\nchar\t*Q_strlwr( char *s1 );\nchar\t*Q_strupr( char *s1 );\nchar\t*Q_strrchr( const char* string, int c );\n\n// buffer size safe library replacements\nvoid\tQ_strncpyz( char *dest, const char *src, int destsize );\nvoid\tQ_strcat( char *dest, int size, const char *src );\n\n// strlen that discounts Quake color sequences\nint Q_PrintStrlen( const char *string );\n// removes color sequences from string\nchar *Q_CleanStr( char *string );\n\n//=============================================\n\n// 64-bit integers for global rankings interface\n// implemented as a struct for qvm compatibility\ntypedef struct\n{\n\tbyte\tb0;\n\tbyte\tb1;\n\tbyte\tb2;\n\tbyte\tb3;\n\tbyte\tb4;\n\tbyte\tb5;\n\tbyte\tb6;\n\tbyte\tb7;\n} qint64;\n\n//=============================================\n/*\nshort\tBigShort(short l);\nshort\tLittleShort(short l);\nint\t\tBigLong (int l);\nint\t\tLittleLong (int l);\nqint64  BigLong64 (qint64 l);\nqint64  LittleLong64 (qint64 l);\nfloat\tBigFloat (const float *l);\nfloat\tLittleFloat (const float *l);\n\nvoid\tSwap_Init (void);\n*/\nchar\t* QDECL va(char *format, ...);\n\n//=============================================\n\n//\n// key / value info strings\n//\nchar *Info_ValueForKey( const char *s, const char *key );\nvoid Info_RemoveKey( char *s, const char *key );\nvoid Info_RemoveKey_big( char *s, const char *key );\nvoid Info_SetValueForKey( char *s, const char *key, const char *value );\nvoid Info_SetValueForKey_Big( char *s, const char *key, const char *value );\nqboolean Info_Validate( const char *s );\nvoid Info_NextPair( const char **s, char *key, char *value );\n\n// this is only here so the functions in q_shared.c and bg_*.c can link\nvoid\tQDECL Com_Error( int level, const char *error, ... );\nvoid\tQDECL Com_Printf( const char *msg, ... );\n\n\n/*\n==========================================================\n\nCVARS (console variables)\n\nMany variables can be used for cheating purposes, so when\ncheats is zero, force all unspecified variables to their\ndefault values.\n==========================================================\n*/\n\n#define\tCVAR_ARCHIVE\t\t1\t// set to cause it to be saved to vars.rc\n\t\t\t\t\t\t\t\t// used for system variables, not for player\n\t\t\t\t\t\t\t\t// specific configurations\n#define\tCVAR_USERINFO\t\t2\t// sent to server on connect or change\n#define\tCVAR_SERVERINFO\t\t4\t// sent in response to front end requests\n#define\tCVAR_SYSTEMINFO\t\t8\t// these cvars will be duplicated on all clients\n#define\tCVAR_INIT\t\t\t16\t// don't allow change from console at all,\n\t\t\t\t\t\t\t\t// but can be set from the command line\n#define\tCVAR_LATCH\t\t\t32\t// will only change when C code next does\n\t\t\t\t\t\t\t\t// a Cvar_Get(), so it can't be changed\n\t\t\t\t\t\t\t\t// without proper initialization.  modified\n\t\t\t\t\t\t\t\t// will be set, even though the value hasn't\n\t\t\t\t\t\t\t\t// changed yet\n#define\tCVAR_ROM\t\t\t64\t// display only, cannot be set by user at all\n#define\tCVAR_USER_CREATED\t128\t// created by a set command\n#define\tCVAR_TEMP\t\t\t256\t// can be set even when cheats are disabled, but is not archived\n#define CVAR_CHEAT\t\t\t512\t// can not be changed if cheats are disabled\n#define CVAR_NORESTART\t\t1024\t// do not clear when a cvar_restart is issued\n\n// nothing outside the Cvar_*() functions should modify these fields!\ntypedef struct cvar_s {\n\tchar\t\t*name;\n\tchar\t\t*string;\n\tchar\t\t*resetString;\t\t// cvar_restart will reset to this value\n\tchar\t\t*latchedString;\t\t// for CVAR_LATCH vars\n\tint\t\t\tflags;\n\tqboolean\tmodified;\t\t\t// set each time the cvar is changed\n\tint\t\t\tmodificationCount;\t// incremented each time the cvar is changed\n\tfloat\t\tvalue;\t\t\t\t// atof( string )\n\tint\t\t\tinteger;\t\t\t// atoi( string )\n\tstruct cvar_s *next;\n\tstruct cvar_s *hashNext;\n} cvar_t;\n\n#define\tMAX_CVAR_VALUE_STRING\t256\n\ntypedef int\tcvarHandle_t;\n\n// the modules that run in the virtual machine can't access the cvar_t directly,\n// so they must ask for structured updates\ntypedef struct {\n\tcvarHandle_t\thandle;\n\tint\t\t\tmodificationCount;\n\tfloat\t\tvalue;\n\tint\t\t\tinteger;\n\tchar\t\tstring[MAX_CVAR_VALUE_STRING];\n} vmCvar_t;\n\n/*\n==============================================================\n\nCOLLISION DETECTION\n\n==============================================================\n*/\n\n#include \"surfaceflags.h\"\t\t\t// shared with the q3map utility\n\n// plane types are used to speed some tests\n// 0-2 are axial planes\n#define\tPLANE_X\t\t\t0\n#define\tPLANE_Y\t\t\t1\n#define\tPLANE_Z\t\t\t2\n#define\tPLANE_NON_AXIAL\t3\n\n\n/*\n=================\nPlaneTypeForNormal\n=================\n*/\n\n#define PlaneTypeForNormal(x) (x[0] == 1.0 ? PLANE_X : (x[1] == 1.0 ? PLANE_Y : (x[2] == 1.0 ? PLANE_Z : PLANE_NON_AXIAL) ) )\n\n// plane_t structure\n// !!! if this is changed, it must be changed in asm code too !!!\ntypedef struct cplane_s {\n\tvec3_t\tnormal;\n\tfloat\tdist;\n\tbyte\ttype;\t\t\t// for fast side tests: 0,1,2 = axial, 3 = nonaxial\n\tbyte\tsignbits;\t\t// signx + (signy<<1) + (signz<<2), used as lookup during collision\n\tbyte\tpad[2];\n} cplane_t;\n\n\n// a trace is returned when a box is swept through the world\ntypedef struct {\n\tqboolean\tallsolid;\t// if true, plane is not valid\n\tqboolean\tstartsolid;\t// if true, the initial point was in a solid area\n\tfloat\t\tfraction;\t// time completed, 1.0 = didn't hit anything\n\tvec3_t\t\tendpos;\t\t// final position\n\tcplane_t\tplane;\t\t// surface normal at impact, transformed to world space\n\tint\t\t\tsurfaceFlags;\t// surface hit\n\tint\t\t\tcontents;\t// contents on other side of surface hit\n\tint\t\t\tentityNum;\t// entity the contacted sirface is a part of\n} trace_t;\n\n// trace->entityNum can also be 0 to (MAX_GENTITIES-1)\n// or ENTITYNUM_NONE, ENTITYNUM_WORLD\n\n\n// markfragments are returned by CM_MarkFragments()\ntypedef struct {\n\tint\t\tfirstPoint;\n\tint\t\tnumPoints;\n} markFragment_t;\n\n\n\ntypedef struct {\n\tvec3_t\t\torigin;\n\tvec3_t\t\taxis[3];\n} orientation_t;\n\n//=====================================================================\n\n\n// in order from highest priority to lowest\n// if none of the catchers are active, bound key strings will be executed\n#define KEYCATCH_CONSOLE\t\t0x0001\n#define\tKEYCATCH_UI\t\t\t\t\t0x0002\n#define\tKEYCATCH_MESSAGE\t\t0x0004\n#define\tKEYCATCH_CGAME\t\t\t0x0008\n\n\n// sound channels\n// channel 0 never willingly overrides\n// other channels will allways override a playing sound on that channel\ntypedef enum {\n\tCHAN_AUTO,\n\tCHAN_LOCAL,\t\t// menu sounds, etc\n\tCHAN_WEAPON,\n\tCHAN_VOICE,\n\tCHAN_ITEM,\n\tCHAN_BODY,\n\tCHAN_LOCAL_SOUND,\t// chat messages, etc\n\tCHAN_ANNOUNCER\t\t// announcer voices, etc\n} soundChannel_t;\n\n\n/*\n========================================================================\n\n  ELEMENTS COMMUNICATED ACROSS THE NET\n\n========================================================================\n*/\n\n#define\tANGLE2SHORT(x)\t((int)((x)*65536/360) & 65535)\n#define\tSHORT2ANGLE(x)\t((x)*(360.0/65536))\n\n#define\tSNAPFLAG_RATE_DELAYED\t1\n#define\tSNAPFLAG_NOT_ACTIVE\t\t2\t// snapshot used during connection and for zombies\n#define SNAPFLAG_SERVERCOUNT\t4\t// toggled every map_restart so transitions can be detected\n\n//\n// per-level limits\n//\n#define\tMAX_CLIENTS\t\t\t64\t\t// absolute limit\n#define MAX_LOCATIONS\t\t64\n\n#define\tGENTITYNUM_BITS\t\t10\t\t// don't need to send any more\n#define\tMAX_GENTITIES\t\t(1<<GENTITYNUM_BITS)\n\n// entitynums are communicated with GENTITY_BITS, so any reserved\n// values that are going to be communcated over the net need to\n// also be in this range\n#define\tENTITYNUM_NONE\t\t(MAX_GENTITIES-1)\n#define\tENTITYNUM_WORLD\t\t(MAX_GENTITIES-2)\n#define\tENTITYNUM_MAX_NORMAL\t(MAX_GENTITIES-2)\n\n\n#define\tMAX_MODELS\t\t\t256\t\t// these are sent over the net as 8 bits\n#define\tMAX_SOUNDS\t\t\t256\t\t// so they cannot be blindly increased\n\n\n#define\tMAX_CONFIGSTRINGS\t1024\n\n// these are the only configstrings that the system reserves, all the\n// other ones are strictly for servergame to clientgame communication\n#define\tCS_SERVERINFO\t\t0\t\t// an info string with all the serverinfo cvars\n#define\tCS_SYSTEMINFO\t\t1\t\t// an info string for server system to client system configuration (timescale, etc)\n\n#define\tRESERVED_CONFIGSTRINGS\t2\t// game can't modify below this, only the system can\n\n#define\tMAX_GAMESTATE_CHARS\t16000\ntypedef struct {\n\tint\t\t\tstringOffsets[MAX_CONFIGSTRINGS];\n\tchar\t\tstringData[MAX_GAMESTATE_CHARS];\n\tint\t\t\tdataCount;\n} gameState_t;\n\n//=========================================================\n\n// bit field limits\n#define\tMAX_STATS\t\t\t\t16\n#define\tMAX_PERSISTANT\t\t\t16\n#define\tMAX_POWERUPS\t\t\t16\n#define\tMAX_WEAPONS\t\t\t\t16\t\t\n\n#define\tMAX_PS_EVENTS\t\t\t2\n\n#define PS_PMOVEFRAMECOUNTBITS\t6\n\n// playerState_t is the information needed by both the client and server\n// to predict player motion and actions\n// nothing outside of pmove should modify these, or some degree of prediction error\n// will occur\n\n// you can't add anything to this without modifying the code in msg.c\n\n// playerState_t is a full superset of entityState_t as it is used by players,\n// so if a playerState_t is transmitted, the entityState_t can be fully derived\n// from it.\ntypedef struct playerState_s {\n\tint\t\t\tcommandTime;\t// cmd->serverTime of last executed command\n\tint\t\t\tpm_type;\n\tint\t\t\tbobCycle;\t\t// for view bobbing and footstep generation\n\tint\t\t\tpm_flags;\t\t// ducked, jump_held, etc\n\tint\t\t\tpm_time;\n\n\tvec3_t\t\torigin;\n\tvec3_t\t\tvelocity;\n\tint\t\t\tweaponTime;\n\tint\t\t\tgravity;\n\tint\t\t\tspeed;\n\tint\t\t\tdelta_angles[3];\t// add to command angles to get view direction\n\t\t\t\t\t\t\t\t\t// changed by spawns, rotating objects, and teleporters\n\n\tint\t\t\tgroundEntityNum;// ENTITYNUM_NONE = in air\n\n\tint\t\t\tlegsTimer;\t\t// don't change low priority animations until this runs out\n\tint\t\t\tlegsAnim;\t\t// mask off ANIM_TOGGLEBIT\n\n\tint\t\t\ttorsoTimer;\t\t// don't change low priority animations until this runs out\n\tint\t\t\ttorsoAnim;\t\t// mask off ANIM_TOGGLEBIT\n\n\tint\t\t\tmovementDir;\t// a number 0 to 7 that represents the reletive angle\n\t\t\t\t\t\t\t\t// of movement to the view angle (axial and diagonals)\n\t\t\t\t\t\t\t\t// when at rest, the value will remain unchanged\n\t\t\t\t\t\t\t\t// used to twist the legs during strafing\n\n\tvec3_t\t\tgrapplePoint;\t// location of grapple to pull towards if PMF_GRAPPLE_PULL\n\n\tint\t\t\teFlags;\t\t\t// copied to entityState_t->eFlags\n\n\tint\t\t\teventSequence;\t// pmove generated events\n\tint\t\t\tevents[MAX_PS_EVENTS];\n\tint\t\t\teventParms[MAX_PS_EVENTS];\n\n\tint\t\t\texternalEvent;\t// events set on player from another source\n\tint\t\t\texternalEventParm;\n\tint\t\t\texternalEventTime;\n\n\tint\t\t\tclientNum;\t\t// ranges from 0 to MAX_CLIENTS-1\n\tint\t\t\tweapon;\t\t\t// copied to entityState_t->weapon\n\tint\t\t\tweaponstate;\n\n\tvec3_t\t\tviewangles;\t\t// for fixed views\n\tint\t\t\tviewheight;\n\n\t// damage feedback\n\tint\t\t\tdamageEvent;\t// when it changes, latch the other parms\n\tint\t\t\tdamageYaw;\n\tint\t\t\tdamagePitch;\n\tint\t\t\tdamageCount;\n\n\tint\t\t\tstats[MAX_STATS];\n\tint\t\t\tpersistant[MAX_PERSISTANT];\t// stats that aren't cleared on death\n\tint\t\t\tpowerups[MAX_POWERUPS];\t// level.time that the powerup runs out\n\tint\t\t\tammo[MAX_WEAPONS];\n\n\tint\t\t\tgeneric1;\n\tint\t\t\tloopSound;\n\tint\t\t\tjumppad_ent;\t// jumppad entity hit this frame\n\n\t// not communicated over the net at all\n\tint\t\t\tping;\t\t\t// server to game info for scoreboard\n\tint\t\t\tpmove_framecount;\t// FIXME: don't transmit over the network\n\tint\t\t\tjumppad_frame;\n\tint\t\t\tentityEventSequence;\n} playerState_t;\n\n\n//====================================================================\n\n\n//\n// usercmd_t->button bits, many of which are generated by the client system,\n// so they aren't game/cgame only definitions\n//\n#define\tBUTTON_ATTACK\t\t1\n#define\tBUTTON_TALK\t\t\t2\t\t\t// displays talk balloon and disables actions\n#define\tBUTTON_USE_HOLDABLE\t4\n#define\tBUTTON_GESTURE\t\t8\n#define\tBUTTON_WALKING\t\t16\t\t\t// walking can't just be infered from MOVE_RUN\n\t\t\t\t\t\t\t\t\t\t// because a key pressed late in the frame will\n\t\t\t\t\t\t\t\t\t\t// only generate a small move value for that frame\n\t\t\t\t\t\t\t\t\t\t// walking will use different animations and\n\t\t\t\t\t\t\t\t\t\t// won't generate footsteps\n#define BUTTON_AFFIRMATIVE\t32\n#define\tBUTTON_NEGATIVE\t\t64\n\n#define BUTTON_GETFLAG\t\t128\n#define BUTTON_GUARDBASE\t256\n#define BUTTON_PATROL\t\t512\n#define BUTTON_FOLLOWME\t\t1024\n\n#define\tBUTTON_ANY\t\t\t2048\t\t\t// any key whatsoever\n\n#define\tMOVE_RUN\t\t\t120\t\t\t// if forwardmove or rightmove are >= MOVE_RUN,\n\t\t\t\t\t\t\t\t\t\t// then BUTTON_WALKING should be set\n\n// usercmd_t is sent to the server each client frame\ntypedef struct usercmd_s {\n\tint\t\t\t\tserverTime;\n\tint\t\t\t\tangles[3];\n\tint \t\t\tbuttons;\n\tbyte\t\t\tweapon;           // weapon \n\tsigned char\tforwardmove, rightmove, upmove;\n} usercmd_t;\n\n//===================================================================\n\n// if entityState->solid == SOLID_BMODEL, modelindex is an inline model number\n#define\tSOLID_BMODEL\t0xffffff\n\ntypedef enum {\n\tTR_STATIONARY,\n\tTR_INTERPOLATE,\t\t\t\t// non-parametric, but interpolate between snapshots\n\tTR_LINEAR,\n\tTR_LINEAR_STOP,\n\tTR_SINE,\t\t\t\t\t// value = base + sin( time / duration ) * delta\n\tTR_GRAVITY\n} trType_t;\n\ntypedef struct {\n\ttrType_t\ttrType;\n\tint\t\ttrTime;\n\tint\t\ttrDuration;\t\t\t// if non 0, trTime + trDuration = stop time\n\tvec3_t\ttrBase;\n\tvec3_t\ttrDelta;\t\t\t// velocity, etc\n} trajectory_t;\n\n// entityState_t is the information conveyed from the server\n// in an update message about entities that the client will\n// need to render in some way\n// Different eTypes may use the information in different ways\n// The messages are delta compressed, so it doesn't really matter if\n// the structure size is fairly large\n\ntypedef struct entityState_s {\n\tint\t\tnumber;\t\t\t// entity index\n\tint\t\teType;\t\t\t// entityType_t\n\tint\t\teFlags;\n\n\ttrajectory_t\tpos;\t// for calculating position\n\ttrajectory_t\tapos;\t// for calculating angles\n\n\tint\t\ttime;\n\tint\t\ttime2;\n\n\tvec3_t\torigin;\n\tvec3_t\torigin2;\n\n\tvec3_t\tangles;\n\tvec3_t\tangles2;\n\n\tint\t\totherEntityNum;\t// shotgun sources, etc\n\tint\t\totherEntityNum2;\n\n\tint\t\tgroundEntityNum;\t// -1 = in air\n\n\tint\t\tconstantLight;\t// r + (g<<8) + (b<<16) + (intensity<<24)\n\tint\t\tloopSound;\t\t// constantly loop this sound\n\n\tint\t\tmodelindex;\n\tint\t\tmodelindex2;\n\tint\t\tclientNum;\t\t// 0 to (MAX_CLIENTS - 1), for players and corpses\n\tint\t\tframe;\n\n\tint\t\tsolid;\t\t\t// for client side prediction, trap_linkentity sets this properly\n\n\tint\t\tevent;\t\t\t// impulse events -- muzzle flashes, footsteps, etc\n\tint\t\teventParm;\n\n\t// for players\n\tint\t\tpowerups;\t\t// bit flags\n\tint\t\tweapon;\t\t\t// determines weapon and flash model, etc\n\tint\t\tlegsAnim;\t\t// mask off ANIM_TOGGLEBIT\n\tint\t\ttorsoAnim;\t\t// mask off ANIM_TOGGLEBIT\n\n\tint\t\tgeneric1;\n} entityState_t;\n\ntypedef enum {\n\tCA_UNINITIALIZED,\n\tCA_DISCONNECTED, \t// not talking to a server\n\tCA_AUTHORIZING,\t\t// not used any more, was checking cd key \n\tCA_CONNECTING,\t\t// sending request packets to the server\n\tCA_CHALLENGING,\t\t// sending challenge packets to the server\n\tCA_CONNECTED,\t\t// netchan_t established, getting gamestate\n\tCA_LOADING,\t\t\t// only during cgame initialization, never during main loop\n\tCA_PRIMED,\t\t\t// got gamestate, waiting for first frame\n\tCA_ACTIVE,\t\t\t// game views should be displayed\n\tCA_CINEMATIC\t\t// playing a cinematic or a static pic, not connected to a server\n} connstate_t;\n\n// font support \n\n#define GLYPH_START 0\n#define GLYPH_END 255\n#define GLYPH_CHARSTART 32\n#define GLYPH_CHAREND 127\n#define GLYPHS_PER_FONT GLYPH_END - GLYPH_START + 1\ntypedef struct {\n  int height;       // number of scan lines\n  int top;          // top of glyph in buffer\n  int bottom;       // bottom of glyph in buffer\n  int pitch;        // width for copying\n  int xSkip;        // x adjustment\n  int imageWidth;   // width of actual image\n  int imageHeight;  // height of actual image\n  float s;          // x offset in image where glyph starts\n  float t;          // y offset in image where glyph starts\n  float s2;\n  float t2;\n  qhandle_t glyph;  // handle to the shader with the glyph\n  char shaderName[32];\n} glyphInfo_t;\n\ntypedef struct {\n  glyphInfo_t glyphs [GLYPHS_PER_FONT];\n  float glyphScale;\n  char name[MAX_QPATH];\n} fontInfo_t;\n\n#define Square(x) ((x)*(x))\n\n// real time\n//=============================================\n\n\ntypedef struct qtime_s {\n\tint tm_sec;     /* seconds after the minute - [0,59] */\n\tint tm_min;     /* minutes after the hour - [0,59] */\n\tint tm_hour;    /* hours since midnight - [0,23] */\n\tint tm_mday;    /* day of the month - [1,31] */\n\tint tm_mon;     /* months since January - [0,11] */\n\tint tm_year;    /* years since 1900 */\n\tint tm_wday;    /* days since Sunday - [0,6] */\n\tint tm_yday;    /* days since January 1 - [0,365] */\n\tint tm_isdst;   /* daylight savings time flag */\n} qtime_t;\n\n\n// server browser sources\n// TTimo: AS_MPLAYER is no longer used\n#define AS_LOCAL\t\t\t0\n#define AS_MPLAYER\t\t1\n#define AS_GLOBAL\t\t\t2\n#define AS_FAVORITES\t3\n\n\n// cinematic states\ntypedef enum {\n\tFMV_IDLE,\n\tFMV_PLAY,\t\t// play\n\tFMV_EOF,\t\t// all other conditions, i.e. stop/EOF/abort\n\tFMV_ID_BLT,\n\tFMV_ID_IDLE,\n\tFMV_LOOPED,\n\tFMV_ID_WAIT\n} e_status;\n\ntypedef enum _flag_status {\n\tFLAG_ATBASE = 0,\n\tFLAG_TAKEN,\t\t\t// CTF\n\tFLAG_TAKEN_RED,\t\t// One Flag CTF\n\tFLAG_TAKEN_BLUE,\t// One Flag CTF\n\tFLAG_DROPPED\n} flagStatus_t;\n\n\n\n#define\tMAX_GLOBAL_SERVERS\t\t\t\t4096\n#define\tMAX_OTHER_SERVERS\t\t\t\t\t128\n#define MAX_PINGREQUESTS\t\t\t\t\t32\n#define MAX_SERVERSTATUSREQUESTS\t16\n\n#define SAY_ALL\t\t0\n#define SAY_TEAM\t1\n#define SAY_TELL\t2\n\n#define CDKEY_LEN 16\n#define CDCHKSUM_LEN 2\n\n\n#endif\t// __Q_SHARED_H\n"
  },
  {
    "path": "code/game/surfaceflags.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// This file must be identical in the quake and utils directories\n\n// contents flags are seperate bits\n// a given brush can contribute multiple content bits\n\n// these definitions also need to be in q_shared.h!\n\n#define\tCONTENTS_SOLID\t\t\t1\t\t// an eye is never valid in a solid\n#define\tCONTENTS_LAVA\t\t\t8\n#define\tCONTENTS_SLIME\t\t\t16\n#define\tCONTENTS_WATER\t\t\t32\n#define\tCONTENTS_FOG\t\t\t64\n\n#define CONTENTS_NOTTEAM1\t\t0x0080\n#define CONTENTS_NOTTEAM2\t\t0x0100\n#define CONTENTS_NOBOTCLIP\t\t0x0200\n\n#define\tCONTENTS_AREAPORTAL\t\t0x8000\n\n#define\tCONTENTS_PLAYERCLIP\t\t0x10000\n#define\tCONTENTS_MONSTERCLIP\t0x20000\n//bot specific contents types\n#define\tCONTENTS_TELEPORTER\t\t0x40000\n#define\tCONTENTS_JUMPPAD\t\t0x80000\n#define CONTENTS_CLUSTERPORTAL\t0x100000\n#define CONTENTS_DONOTENTER\t\t0x200000\n#define CONTENTS_BOTCLIP\t\t0x400000\n#define CONTENTS_MOVER\t\t\t0x800000\n\n#define\tCONTENTS_ORIGIN\t\t\t0x1000000\t// removed before bsping an entity\n\n#define\tCONTENTS_BODY\t\t\t0x2000000\t// should never be on a brush, only in game\n#define\tCONTENTS_CORPSE\t\t\t0x4000000\n#define\tCONTENTS_DETAIL\t\t\t0x8000000\t// brushes not used for the bsp\n#define\tCONTENTS_STRUCTURAL\t\t0x10000000\t// brushes used for the bsp\n#define\tCONTENTS_TRANSLUCENT\t0x20000000\t// don't consume surface fragments inside\n#define\tCONTENTS_TRIGGER\t\t0x40000000\n#define\tCONTENTS_NODROP\t\t\t0x80000000\t// don't leave bodies or items (death fog, lava)\n\n#define\tSURF_NODAMAGE\t\t\t0x1\t\t// never give falling damage\n#define\tSURF_SLICK\t\t\t\t0x2\t\t// effects game physics\n#define\tSURF_SKY\t\t\t\t0x4\t\t// lighting from environment map\n#define\tSURF_LADDER\t\t\t\t0x8\n#define\tSURF_NOIMPACT\t\t\t0x10\t// don't make missile explosions\n#define\tSURF_NOMARKS\t\t\t0x20\t// don't leave missile marks\n#define\tSURF_FLESH\t\t\t\t0x40\t// make flesh sounds and effects\n#define\tSURF_NODRAW\t\t\t\t0x80\t// don't generate a drawsurface at all\n#define\tSURF_HINT\t\t\t\t0x100\t// make a primary bsp splitter\n#define\tSURF_SKIP\t\t\t\t0x200\t// completely ignore, allowing non-closed brushes\n#define\tSURF_NOLIGHTMAP\t\t\t0x400\t// surface doesn't need a lightmap\n#define\tSURF_POINTLIGHT\t\t\t0x800\t// generate lighting info at vertexes\n#define\tSURF_METALSTEPS\t\t\t0x1000\t// clanking footsteps\n#define\tSURF_NOSTEPS\t\t\t0x2000\t// no footstep sounds\n#define\tSURF_NONSOLID\t\t\t0x4000\t// don't collide against curves with this set\n#define\tSURF_LIGHTFILTER\t\t0x8000\t// act as a light filter during q3map -light\n#define\tSURF_ALPHASHADOW\t\t0x10000\t// do per-pixel light shadow casting in q3map\n#define\tSURF_NODLIGHT\t\t\t0x20000\t// don't dlight even if solid (solid lava, skies)\n#define SURF_DUST\t\t\t\t0x40000 // leave a dust trail when walking on this surface\n"
  },
  {
    "path": "code/game/syn.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#define CONTEXT_ALL\t\t\t\t\t\t0xFFFFFFFF\n#define CONTEXT_NORMAL\t\t\t\t\t1\n#define CONTEXT_NEARBYITEM\t\t\t\t2\n#define CONTEXT_CTFREDTEAM\t\t\t\t4\n#define CONTEXT_CTFBLUETEAM\t\t\t\t8\n#define CONTEXT_REPLY\t\t\t\t\t16\n#define CONTEXT_OBELISKREDTEAM\t\t\t32\n#define CONTEXT_OBELISKBLUETEAM\t\t\t64\n#define CONTEXT_HARVESTERREDTEAM\t\t128\n#define CONTEXT_HARVESTERBLUETEAM\t\t256\n\n#define CONTEXT_NAMES 1024\n"
  },
  {
    "path": "code/game.lnt",
    "content": "opts.lnt\n\ngame\\bg_misc.c\ngame\\bg_pmove.c\ngame\\bg_slidemove.c\ngame\\q_math.c\ngame\\q_shared.c\n\nbotai\\ai_chat.c\nbotai\\ai_cmd.c\nbotai\\ai_dmnet.c\nbotai\\ai_dmq3.c\nbotai\\ai_main.c\nbotai\\ai_team.c\n\ngame\\g_active.c\ngame\\g_arenas.c\ngame\\g_bot.c\ngame\\g_client.c\ngame\\g_cmds.c\ngame\\g_combat.c\ngame\\g_items.c\ngame\\g_main.c\ngame\\g_mem.c\ngame\\g_misc.c\ngame\\g_missile.c\ngame\\g_mover.c\ngame\\g_session.c\ngame\\g_spawn.c\ngame\\g_svcmds.c\ngame\\g_target.c\ngame\\g_team.c\ngame\\g_trigger.c\ngame\\g_utils.c\ngame\\g_weapon.c\n"
  },
  {
    "path": "code/installdebug.bat",
    "content": "call closefiles\ncopy debug\\quake3.exe g:\\quake3\ncopy debug\\qagamex86.dll g:\\quake3\ncopy debug\\cgamex86.dll g:\\quake3\ncopy debug\\uix86.dll g:\\quake3\n\n"
  },
  {
    "path": "code/installrelease.bat",
    "content": "cd game\ncall game_ta\ncall game\ncd ..\\cgame\ncall cgame_ta\ncall cgame\ncd ..\\ui\ncall ui\ncd ..\\q3_ui\ncall q3_ui\ncd ..\ncall closefiles\ncopy release_ta\\quake3.exe g:\\quake3\\quake3.exe\ncall installvms"
  },
  {
    "path": "code/installvms.bat",
    "content": "copy \\quake3\\missionpack\\vm\\cgame.* g:\\quake3\\missionpack\\vm\ncopy \\quake3\\missionpack\\vm\\qagame.* g:\\quake3\\missionpack\\vm\ncopy \\quake3\\missionpack\\vm\\ui.* g:\\quake3\\missionpack\\vm\ncopy \\quake3\\baseq3\\vm\\cgame.* g:\\quake3\\baseq3\\vm\ncopy \\quake3\\baseq3\\vm\\qagame.* g:\\quake3\\baseq3\\vm\ncopy \\quake3\\baseq3\\vm\\q3_ui.qvm g:\\quake3\\baseq3\\vm\\ui.qvm\n\n"
  },
  {
    "path": "code/jpeg-6/README",
    "content": "The Independent JPEG Group's JPEG software\n==========================================\n\nREADME for release 6b of 27-Mar-1998\n====================================\n\nThis distribution contains the sixth public release of the Independent JPEG\nGroup's free JPEG software.  You are welcome to redistribute this software and\nto use it for any purpose, subject to the conditions under LEGAL ISSUES, below.\n\nSerious users of this software (particularly those incorporating it into\nlarger programs) should contact IJG at jpeg-info@uunet.uu.net to be added to\nour electronic mailing list.  Mailing list members are notified of updates\nand have a chance to participate in technical discussions, etc.\n\nThis software is the work of Tom Lane, Philip Gladstone, Jim Boucher,\nLee Crocker, Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi,\nGuido Vollbeding, Ge' Weijers, and other members of the Independent JPEG\nGroup.\n\nIJG is not affiliated with the official ISO JPEG standards committee.\n\n\nDOCUMENTATION ROADMAP\n=====================\n\nThis file contains the following sections:\n\nOVERVIEW            General description of JPEG and the IJG software.\nLEGAL ISSUES        Copyright, lack of warranty, terms of distribution.\nREFERENCES          Where to learn more about JPEG.\nARCHIVE LOCATIONS   Where to find newer versions of this software.\nRELATED SOFTWARE    Other stuff you should get.\nFILE FORMAT WARS    Software *not* to get.\nTO DO               Plans for future IJG releases.\n\nOther documentation files in the distribution are:\n\nUser documentation:\n  install.doc       How to configure and install the IJG software.\n  usage.doc         Usage instructions for cjpeg, djpeg, jpegtran,\n                    rdjpgcom, and wrjpgcom.\n  *.1               Unix-style man pages for programs (same info as usage.doc).\n  wizard.doc        Advanced usage instructions for JPEG wizards only.\n  change.log        Version-to-version change highlights.\nProgrammer and internal documentation:\n  libjpeg.doc       How to use the JPEG library in your own programs.\n  example.c         Sample code for calling the JPEG library.\n  structure.doc     Overview of the JPEG library's internal structure.\n  filelist.doc      Road map of IJG files.\n  coderules.doc     Coding style rules --- please read if you contribute code.\n\nPlease read at least the files install.doc and usage.doc.  Useful information\ncan also be found in the JPEG FAQ (Frequently Asked Questions) article.  See\nARCHIVE LOCATIONS below to find out where to obtain the FAQ article.\n\nIf you want to understand how the JPEG code works, we suggest reading one or\nmore of the REFERENCES, then looking at the documentation files (in roughly\nthe order listed) before diving into the code.\n\n\nOVERVIEW\n========\n\nThis package contains C software to implement JPEG image compression and\ndecompression.  JPEG (pronounced \"jay-peg\") is a standardized compression\nmethod for full-color and gray-scale images.  JPEG is intended for compressing\n\"real-world\" scenes; line drawings, cartoons and other non-realistic images\nare not its strong suit.  JPEG is lossy, meaning that the output image is not\nexactly identical to the input image.  Hence you must not use JPEG if you\nhave to have identical output bits.  However, on typical photographic images,\nvery good compression levels can be obtained with no visible change, and\nremarkably high compression levels are possible if you can tolerate a\nlow-quality image.  For more details, see the references, or just experiment\nwith various compression settings.\n\nThis software implements JPEG baseline, extended-sequential, and progressive\ncompression processes.  Provision is made for supporting all variants of these\nprocesses, although some uncommon parameter settings aren't implemented yet.\nFor legal reasons, we are not distributing code for the arithmetic-coding\nvariants of JPEG; see LEGAL ISSUES.  We have made no provision for supporting\nthe hierarchical or lossless processes defined in the standard.\n\nWe provide a set of library routines for reading and writing JPEG image files,\nplus two sample applications \"cjpeg\" and \"djpeg\", which use the library to\nperform conversion between JPEG and some other popular image file formats.\nThe library is intended to be reused in other applications.\n\nIn order to support file conversion and viewing software, we have included\nconsiderable functionality beyond the bare JPEG coding/decoding capability;\nfor example, the color quantization modules are not strictly part of JPEG\ndecoding, but they are essential for output to colormapped file formats or\ncolormapped displays.  These extra functions can be compiled out of the\nlibrary if not required for a particular application.  We have also included\n\"jpegtran\", a utility for lossless transcoding between different JPEG\nprocesses, and \"rdjpgcom\" and \"wrjpgcom\", two simple applications for\ninserting and extracting textual comments in JFIF files.\n\nThe emphasis in designing this software has been on achieving portability and\nflexibility, while also making it fast enough to be useful.  In particular,\nthe software is not intended to be read as a tutorial on JPEG.  (See the\nREFERENCES section for introductory material.)  Rather, it is intended to\nbe reliable, portable, industrial-strength code.  We do not claim to have\nachieved that goal in every aspect of the software, but we strive for it.\n\nWe welcome the use of this software as a component of commercial products.\nNo royalty is required, but we do ask for an acknowledgement in product\ndocumentation, as described under LEGAL ISSUES.\n\n\nLEGAL ISSUES\n============\n\nIn plain English:\n\n1. We don't promise that this software works.  (But if you find any bugs,\n   please let us know!)\n2. You can use this software for whatever you want.  You don't have to pay us.\n3. You may not pretend that you wrote this software.  If you use it in a\n   program, you must acknowledge somewhere in your documentation that\n   you've used the IJG code.\n\nIn legalese:\n\nThe authors make NO WARRANTY or representation, either express or implied,\nwith respect to this software, its quality, accuracy, merchantability, or\nfitness for a particular purpose.  This software is provided \"AS IS\", and you,\nits user, assume the entire risk as to its quality and accuracy.\n\nThis software is copyright (C) 1991-1998, Thomas G. Lane.\nAll Rights Reserved except as specified below.\n\nPermission is hereby granted to use, copy, modify, and distribute this\nsoftware (or portions thereof) for any purpose, without fee, subject to these\nconditions:\n(1) If any part of the source code for this software is distributed, then this\nREADME file must be included, with this copyright and no-warranty notice\nunaltered; and any additions, deletions, or changes to the original files\nmust be clearly indicated in accompanying documentation.\n(2) If only executable code is distributed, then the accompanying\ndocumentation must state that \"this software is based in part on the work of\nthe Independent JPEG Group\".\n(3) Permission for use of this software is granted only if the user accepts\nfull responsibility for any undesirable consequences; the authors accept\nNO LIABILITY for damages of any kind.\n\nThese conditions apply to any software derived from or based on the IJG code,\nnot just to the unmodified library.  If you use our work, you ought to\nacknowledge us.\n\nPermission is NOT granted for the use of any IJG author's name or company name\nin advertising or publicity relating to this software or products derived from\nit.  This software may be referred to only as \"the Independent JPEG Group's\nsoftware\".\n\nWe specifically permit and encourage the use of this software as the basis of\ncommercial products, provided that all warranty or liability claims are\nassumed by the product vendor.\n\n\nansi2knr.c is included in this distribution by permission of L. Peter Deutsch,\nsole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA.\nansi2knr.c is NOT covered by the above copyright and conditions, but instead\nby the usual distribution terms of the Free Software Foundation; principally,\nthat you must include source code if you redistribute it.  (See the file\nansi2knr.c for full details.)  However, since ansi2knr.c is not needed as part\nof any program generated from the IJG code, this does not limit you more than\nthe foregoing paragraphs do.\n\nThe Unix configuration script \"configure\" was produced with GNU Autoconf.\nIt is copyright by the Free Software Foundation but is freely distributable.\nThe same holds for its supporting scripts (config.guess, config.sub,\nltconfig, ltmain.sh).  Another support script, install-sh, is copyright\nby M.I.T. but is also freely distributable.\n\nIt appears that the arithmetic coding option of the JPEG spec is covered by\npatents owned by IBM, AT&T, and Mitsubishi.  Hence arithmetic coding cannot\nlegally be used without obtaining one or more licenses.  For this reason,\nsupport for arithmetic coding has been removed from the free JPEG software.\n(Since arithmetic coding provides only a marginal gain over the unpatented\nHuffman mode, it is unlikely that very many implementations will support it.)\nSo far as we are aware, there are no patent restrictions on the remaining\ncode.\n\nThe IJG distribution formerly included code to read and write GIF files.\nTo avoid entanglement with the Unisys LZW patent, GIF reading support has\nbeen removed altogether, and the GIF writer has been simplified to produce\n\"uncompressed GIFs\".  This technique does not use the LZW algorithm; the\nresulting GIF files are larger than usual, but are readable by all standard\nGIF decoders.\n\nWe are required to state that\n    \"The Graphics Interchange Format(c) is the Copyright property of\n    CompuServe Incorporated.  GIF(sm) is a Service Mark property of\n    CompuServe Incorporated.\"\n\n\nREFERENCES\n==========\n\nWe highly recommend reading one or more of these references before trying to\nunderstand the innards of the JPEG software.\n\nThe best short technical introduction to the JPEG compression algorithm is\n\tWallace, Gregory K.  \"The JPEG Still Picture Compression Standard\",\n\tCommunications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44.\n(Adjacent articles in that issue discuss MPEG motion picture compression,\napplications of JPEG, and related topics.)  If you don't have the CACM issue\nhandy, a PostScript file containing a revised version of Wallace's article is\navailable at ftp://ftp.uu.net/graphics/jpeg/wallace.ps.gz.  The file (actually\na preprint for an article that appeared in IEEE Trans. Consumer Electronics)\nomits the sample images that appeared in CACM, but it includes corrections\nand some added material.  Note: the Wallace article is copyright ACM and IEEE,\nand it may not be used for commercial purposes.\n\nA somewhat less technical, more leisurely introduction to JPEG can be found in\n\"The Data Compression Book\" by Mark Nelson and Jean-loup Gailly, published by\nM&T Books (New York), 2nd ed. 1996, ISBN 1-55851-434-1.  This book provides\ngood explanations and example C code for a multitude of compression methods\nincluding JPEG.  It is an excellent source if you are comfortable reading C\ncode but don't know much about data compression in general.  The book's JPEG\nsample code is far from industrial-strength, but when you are ready to look\nat a full implementation, you've got one here...\n\nThe best full description of JPEG is the textbook \"JPEG Still Image Data\nCompression Standard\" by William B. Pennebaker and Joan L. Mitchell, published\nby Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1.  Price US$59.95, 638 pp.\nThe book includes the complete text of the ISO JPEG standards (DIS 10918-1\nand draft DIS 10918-2).  This is by far the most complete exposition of JPEG\nin existence, and we highly recommend it.\n\nThe JPEG standard itself is not available electronically; you must order a\npaper copy through ISO or ITU.  (Unless you feel a need to own a certified\nofficial copy, we recommend buying the Pennebaker and Mitchell book instead;\nit's much cheaper and includes a great deal of useful explanatory material.)\nIn the USA, copies of the standard may be ordered from ANSI Sales at (212)\n642-4900, or from Global Engineering Documents at (800) 854-7179.  (ANSI\ndoesn't take credit card orders, but Global does.)  It's not cheap: as of\n1992, ANSI was charging $95 for Part 1 and $47 for Part 2, plus 7%\nshipping/handling.  The standard is divided into two parts, Part 1 being the\nactual specification, while Part 2 covers compliance testing methods.  Part 1\nis titled \"Digital Compression and Coding of Continuous-tone Still Images,\nPart 1: Requirements and guidelines\" and has document numbers ISO/IEC IS\n10918-1, ITU-T T.81.  Part 2 is titled \"Digital Compression and Coding of\nContinuous-tone Still Images, Part 2: Compliance testing\" and has document\nnumbers ISO/IEC IS 10918-2, ITU-T T.83.\n\nSome extensions to the original JPEG standard are defined in JPEG Part 3,\na newer ISO standard numbered ISO/IEC IS 10918-3 and ITU-T T.84.  IJG\ncurrently does not support any Part 3 extensions.\n\nThe JPEG standard does not specify all details of an interchangeable file\nformat.  For the omitted details we follow the \"JFIF\" conventions, revision\n1.02.  A copy of the JFIF spec is available from:\n\tLiterature Department\n\tC-Cube Microsystems, Inc.\n\t1778 McCarthy Blvd.\n\tMilpitas, CA 95035\n\tphone (408) 944-6300,  fax (408) 944-6314\nA PostScript version of this document is available by FTP at\nftp://ftp.uu.net/graphics/jpeg/jfif.ps.gz.  There is also a plain text\nversion at ftp://ftp.uu.net/graphics/jpeg/jfif.txt.gz, but it is missing\nthe figures.\n\nThe TIFF 6.0 file format specification can be obtained by FTP from\nftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz.  The JPEG incorporation scheme\nfound in the TIFF 6.0 spec of 3-June-92 has a number of serious problems.\nIJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6).\nInstead, we recommend the JPEG design proposed by TIFF Technical Note #2\n(Compression tag 7).  Copies of this Note can be obtained from ftp.sgi.com or\nfrom ftp://ftp.uu.net/graphics/jpeg/.  It is expected that the next revision\nof the TIFF spec will replace the 6.0 JPEG design with the Note's design.\nAlthough IJG's own code does not support TIFF/JPEG, the free libtiff library\nuses our library to implement TIFF/JPEG per the Note.  libtiff is available\nfrom ftp://ftp.sgi.com/graphics/tiff/.\n\n\nARCHIVE LOCATIONS\n=================\n\nThe \"official\" archive site for this software is ftp.uu.net (Internet\naddress 192.48.96.9).  The most recent released version can always be found\nthere in directory graphics/jpeg.  This particular version will be archived\nas ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz.  If you don't have\ndirect Internet access, UUNET's archives are also available via UUCP; contact\nhelp@uunet.uu.net for information on retrieving files that way.\n\nNumerous Internet sites maintain copies of the UUNET files.  However, only\nftp.uu.net is guaranteed to have the latest official version.\n\nYou can also obtain this software in DOS-compatible \"zip\" archive format from\nthe SimTel archives (ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/), or\non CompuServe in the Graphics Support forum (GO CIS:GRAPHSUP), library 12\n\"JPEG Tools\".  Again, these versions may sometimes lag behind the ftp.uu.net\nrelease.\n\nThe JPEG FAQ (Frequently Asked Questions) article is a useful source of\ngeneral information about JPEG.  It is updated constantly and therefore is\nnot included in this distribution.  The FAQ is posted every two weeks to\nUsenet newsgroups comp.graphics.misc, news.answers, and other groups.\nIt is available on the World Wide Web at http://www.faqs.org/faqs/jpeg-faq/\nand other news.answers archive sites, including the official news.answers\narchive at rtfm.mit.edu: ftp://rtfm.mit.edu/pub/usenet/news.answers/jpeg-faq/.\nIf you don't have Web or FTP access, send e-mail to mail-server@rtfm.mit.edu\nwith body\n\tsend usenet/news.answers/jpeg-faq/part1\n\tsend usenet/news.answers/jpeg-faq/part2\n\n\nRELATED SOFTWARE\n================\n\nNumerous viewing and image manipulation programs now support JPEG.  (Quite a\nfew of them use this library to do so.)  The JPEG FAQ described above lists\nsome of the more popular free and shareware viewers, and tells where to\nobtain them on Internet.\n\nIf you are on a Unix machine, we highly recommend Jef Poskanzer's free\nPBMPLUS software, which provides many useful operations on PPM-format image\nfiles.  In particular, it can convert PPM images to and from a wide range of\nother formats, thus making cjpeg/djpeg considerably more useful.  The latest\nversion is distributed by the NetPBM group, and is available from numerous\nsites, notably ftp://wuarchive.wustl.edu/graphics/graphics/packages/NetPBM/.\nUnfortunately PBMPLUS/NETPBM is not nearly as portable as the IJG software is;\nyou are likely to have difficulty making it work on any non-Unix machine.\n\nA different free JPEG implementation, written by the PVRG group at Stanford,\nis available from ftp://havefun.stanford.edu/pub/jpeg/.  This program\nis designed for research and experimentation rather than production use;\nit is slower, harder to use, and less portable than the IJG code, but it\nis easier to read and modify.  Also, the PVRG code supports lossless JPEG,\nwhich we do not.  (On the other hand, it doesn't do progressive JPEG.)\n\n\nFILE FORMAT WARS\n================\n\nSome JPEG programs produce files that are not compatible with our library.\nThe root of the problem is that the ISO JPEG committee failed to specify a\nconcrete file format.  Some vendors \"filled in the blanks\" on their own,\ncreating proprietary formats that no one else could read.  (For example, none\nof the early commercial JPEG implementations for the Macintosh were able to\nexchange compressed files.)\n\nThe file format we have adopted is called JFIF (see REFERENCES).  This format\nhas been agreed to by a number of major commercial JPEG vendors, and it has\nbecome the de facto standard.  JFIF is a minimal or \"low end\" representation.\nWe recommend the use of TIFF/JPEG (TIFF revision 6.0 as modified by TIFF\nTechnical Note #2) for \"high end\" applications that need to record a lot of\nadditional data about an image.  TIFF/JPEG is fairly new and not yet widely\nsupported, unfortunately.\n\nThe upcoming JPEG Part 3 standard defines a file format called SPIFF.\nSPIFF is interoperable with JFIF, in the sense that most JFIF decoders should\nbe able to read the most common variant of SPIFF.  SPIFF has some technical\nadvantages over JFIF, but its major claim to fame is simply that it is an\nofficial standard rather than an informal one.  At this point it is unclear\nwhether SPIFF will supersede JFIF or whether JFIF will remain the de-facto\nstandard.  IJG intends to support SPIFF once the standard is frozen, but we\nhave not decided whether it should become our default output format or not.\n(In any case, our decoder will remain capable of reading JFIF indefinitely.)\n\nVarious proprietary file formats incorporating JPEG compression also exist.\nWe have little or no sympathy for the existence of these formats.  Indeed,\none of the original reasons for developing this free software was to help\nforce convergence on common, open format standards for JPEG files.  Don't\nuse a proprietary file format!\n\n\nTO DO\n=====\n\nThe major thrust for v7 will probably be improvement of visual quality.\nThe current method for scaling the quantization tables is known not to be\nvery good at low Q values.  We also intend to investigate block boundary\nsmoothing, \"poor man's variable quantization\", and other means of improving\nquality-vs-file-size performance without sacrificing compatibility.\n\nIn future versions, we are considering supporting some of the upcoming JPEG\nPart 3 extensions --- principally, variable quantization and the SPIFF file\nformat.\n\nAs always, speeding things up is of great interest.\n\nPlease send bug reports, offers of help, etc. to jpeg-info@uunet.uu.net.\n"
  },
  {
    "path": "code/jpeg-6/jcapimin.c",
    "content": "/*\n * jcapimin.c\n *\n * Copyright (C) 1994-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains application interface code for the compression half\n * of the JPEG library.  These are the \"minimum\" API routines that may be\n * needed in either the normal full-compression case or the transcoding-only\n * case.\n *\n * Most of the routines intended to be called directly by an application\n * are in this file or in jcapistd.c.  But also see jcparam.c for\n * parameter-setup helper routines, jcomapi.c for routines shared by\n * compression and decompression, and jctrans.c for the transcoding case.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/*\n * Initialization of a JPEG compression object.\n * The error manager must already be set up (in case memory manager fails).\n */\n\nGLOBAL void\njpeg_create_compress (j_compress_ptr cinfo)\n{\n  int i;\n\n  /* For debugging purposes, zero the whole master structure.\n   * But error manager pointer is already there, so save and restore it.\n   */\n  {\n    struct jpeg_error_mgr * err = cinfo->err;\n    MEMZERO(cinfo, SIZEOF(struct jpeg_compress_struct));\n    cinfo->err = err;\n  }\n  cinfo->is_decompressor = FALSE;\n\n  /* Initialize a memory manager instance for this object */\n  jinit_memory_mgr((j_common_ptr) cinfo);\n\n  /* Zero out pointers to permanent structures. */\n  cinfo->progress = NULL;\n  cinfo->dest = NULL;\n\n  cinfo->comp_info = NULL;\n\n  for (i = 0; i < NUM_QUANT_TBLS; i++)\n    cinfo->quant_tbl_ptrs[i] = NULL;\n\n  for (i = 0; i < NUM_HUFF_TBLS; i++) {\n    cinfo->dc_huff_tbl_ptrs[i] = NULL;\n    cinfo->ac_huff_tbl_ptrs[i] = NULL;\n  }\n\n  cinfo->input_gamma = 1.0;\t/* in case application forgets */\n\n  /* OK, I'm ready */\n  cinfo->global_state = CSTATE_START;\n}\n\n\n/*\n * Destruction of a JPEG compression object\n */\n\nGLOBAL void\njpeg_destroy_compress (j_compress_ptr cinfo)\n{\n  jpeg_destroy((j_common_ptr) cinfo); /* use common routine */\n}\n\n\n/*\n * Abort processing of a JPEG compression operation,\n * but don't destroy the object itself.\n */\n\nGLOBAL void\njpeg_abort_compress (j_compress_ptr cinfo)\n{\n  jpeg_abort((j_common_ptr) cinfo); /* use common routine */\n}\n\n\n/*\n * Forcibly suppress or un-suppress all quantization and Huffman tables.\n * Marks all currently defined tables as already written (if suppress)\n * or not written (if !suppress).  This will control whether they get emitted\n * by a subsequent jpeg_start_compress call.\n *\n * This routine is exported for use by applications that want to produce\n * abbreviated JPEG datastreams.  It logically belongs in jcparam.c, but\n * since it is called by jpeg_start_compress, we put it here --- otherwise\n * jcparam.o would be linked whether the application used it or not.\n */\n\nGLOBAL void\njpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress)\n{\n  int i;\n  JQUANT_TBL * qtbl;\n  JHUFF_TBL * htbl;\n\n  for (i = 0; i < NUM_QUANT_TBLS; i++) {\n    if ((qtbl = cinfo->quant_tbl_ptrs[i]) != NULL)\n      qtbl->sent_table = suppress;\n  }\n\n  for (i = 0; i < NUM_HUFF_TBLS; i++) {\n    if ((htbl = cinfo->dc_huff_tbl_ptrs[i]) != NULL)\n      htbl->sent_table = suppress;\n    if ((htbl = cinfo->ac_huff_tbl_ptrs[i]) != NULL)\n      htbl->sent_table = suppress;\n  }\n}\n\n\n/*\n * Finish JPEG compression.\n *\n * If a multipass operating mode was selected, this may do a great deal of\n * work including most of the actual output.\n */\n\nGLOBAL void\njpeg_finish_compress (j_compress_ptr cinfo)\n{\n  JDIMENSION iMCU_row;\n\n  if (cinfo->global_state == CSTATE_SCANNING ||\n      cinfo->global_state == CSTATE_RAW_OK) {\n    /* Terminate first pass */\n    if (cinfo->next_scanline < cinfo->image_height)\n      ERREXIT(cinfo, JERR_TOO_LITTLE_DATA);\n    (*cinfo->master->finish_pass) (cinfo);\n  } else if (cinfo->global_state != CSTATE_WRCOEFS)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  /* Perform any remaining passes */\n  while (! cinfo->master->is_last_pass) {\n    (*cinfo->master->prepare_for_pass) (cinfo);\n    for (iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++) {\n      if (cinfo->progress != NULL) {\n\tcinfo->progress->pass_counter = (long) iMCU_row;\n\tcinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows;\n\t(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);\n      }\n      /* We bypass the main controller and invoke coef controller directly;\n       * all work is being done from the coefficient buffer.\n       */\n      if (! (*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE) NULL))\n\tERREXIT(cinfo, JERR_CANT_SUSPEND);\n    }\n    (*cinfo->master->finish_pass) (cinfo);\n  }\n  /* Write EOI, do final cleanup */\n  (*cinfo->marker->write_file_trailer) (cinfo);\n  (*cinfo->dest->term_destination) (cinfo);\n  /* We can use jpeg_abort to release memory and reset global_state */\n  jpeg_abort((j_common_ptr) cinfo);\n}\n\n\n/*\n * Write a special marker.\n * This is only recommended for writing COM or APPn markers.\n * Must be called after jpeg_start_compress() and before\n * first call to jpeg_write_scanlines() or jpeg_write_raw_data().\n */\n\nGLOBAL void\njpeg_write_marker (j_compress_ptr cinfo, int marker,\n\t\t   const JOCTET *dataptr, unsigned int datalen)\n{\n  if (cinfo->next_scanline != 0 ||\n      (cinfo->global_state != CSTATE_SCANNING &&\n       cinfo->global_state != CSTATE_RAW_OK &&\n       cinfo->global_state != CSTATE_WRCOEFS))\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n\n  (*cinfo->marker->write_any_marker) (cinfo, marker, dataptr, datalen);\n}\n\n\n/*\n * Alternate compression function: just write an abbreviated table file.\n * Before calling this, all parameters and a data destination must be set up.\n *\n * To produce a pair of files containing abbreviated tables and abbreviated\n * image data, one would proceed as follows:\n *\n *\t\tinitialize JPEG object\n *\t\tset JPEG parameters\n *\t\tset destination to table file\n *\t\tjpeg_write_tables(cinfo);\n *\t\tset destination to image file\n *\t\tjpeg_start_compress(cinfo, FALSE);\n *\t\twrite data...\n *\t\tjpeg_finish_compress(cinfo);\n *\n * jpeg_write_tables has the side effect of marking all tables written\n * (same as jpeg_suppress_tables(..., TRUE)).  Thus a subsequent start_compress\n * will not re-emit the tables unless it is passed write_all_tables=TRUE.\n */\n\nGLOBAL void\njpeg_write_tables (j_compress_ptr cinfo)\n{\n  if (cinfo->global_state != CSTATE_START)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n\n  /* (Re)initialize error mgr and destination modules */\n  (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);\n  (*cinfo->dest->init_destination) (cinfo);\n  /* Initialize the marker writer ... bit of a crock to do it here. */\n  jinit_marker_writer(cinfo);\n  /* Write them tables! */\n  (*cinfo->marker->write_tables_only) (cinfo);\n  /* And clean up. */\n  (*cinfo->dest->term_destination) (cinfo);\n  /* We can use jpeg_abort to release memory. */\n  jpeg_abort((j_common_ptr) cinfo);\n}\n"
  },
  {
    "path": "code/jpeg-6/jcapistd.c",
    "content": "/*\n * jcapistd.c\n *\n * Copyright (C) 1994-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains application interface code for the compression half\n * of the JPEG library.  These are the \"standard\" API routines that are\n * used in the normal full-compression case.  They are not used by a\n * transcoding-only application.  Note that if an application links in\n * jpeg_start_compress, it will end up linking in the entire compressor.\n * We thus must separate this file from jcapimin.c to avoid linking the\n * whole compression library into a transcoder.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/*\n * Compression initialization.\n * Before calling this, all parameters and a data destination must be set up.\n *\n * We require a write_all_tables parameter as a failsafe check when writing\n * multiple datastreams from the same compression object.  Since prior runs\n * will have left all the tables marked sent_table=TRUE, a subsequent run\n * would emit an abbreviated stream (no tables) by default.  This may be what\n * is wanted, but for safety's sake it should not be the default behavior:\n * programmers should have to make a deliberate choice to emit abbreviated\n * images.  Therefore the documentation and examples should encourage people\n * to pass write_all_tables=TRUE; then it will take active thought to do the\n * wrong thing.\n */\n\nGLOBAL void\njpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables)\n{\n  if (cinfo->global_state != CSTATE_START)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n\n  if (write_all_tables)\n    jpeg_suppress_tables(cinfo, FALSE);\t/* mark all tables to be written */\n\n  /* (Re)initialize error mgr and destination modules */\n  (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);\n  (*cinfo->dest->init_destination) (cinfo);\n  /* Perform master selection of active modules */\n  jinit_compress_master(cinfo);\n  /* Set up for the first pass */\n  (*cinfo->master->prepare_for_pass) (cinfo);\n  /* Ready for application to drive first pass through jpeg_write_scanlines\n   * or jpeg_write_raw_data.\n   */\n  cinfo->next_scanline = 0;\n  cinfo->global_state = (cinfo->raw_data_in ? CSTATE_RAW_OK : CSTATE_SCANNING);\n}\n\n\n/*\n * Write some scanlines of data to the JPEG compressor.\n *\n * The return value will be the number of lines actually written.\n * This should be less than the supplied num_lines only in case that\n * the data destination module has requested suspension of the compressor,\n * or if more than image_height scanlines are passed in.\n *\n * Note: we warn about excess calls to jpeg_write_scanlines() since\n * this likely signals an application programmer error.  However,\n * excess scanlines passed in the last valid call are *silently* ignored,\n * so that the application need not adjust num_lines for end-of-image\n * when using a multiple-scanline buffer.\n */\n\nGLOBAL JDIMENSION\njpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines,\n\t\t      JDIMENSION num_lines)\n{\n  JDIMENSION row_ctr, rows_left;\n\n  if (cinfo->global_state != CSTATE_SCANNING)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  if (cinfo->next_scanline >= cinfo->image_height)\n    WARNMS(cinfo, JWRN_TOO_MUCH_DATA);\n\n  /* Call progress monitor hook if present */\n  if (cinfo->progress != NULL) {\n    cinfo->progress->pass_counter = (long) cinfo->next_scanline;\n    cinfo->progress->pass_limit = (long) cinfo->image_height;\n    (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);\n  }\n\n  /* Give master control module another chance if this is first call to\n   * jpeg_write_scanlines.  This lets output of the frame/scan headers be\n   * delayed so that application can write COM, etc, markers between\n   * jpeg_start_compress and jpeg_write_scanlines.\n   */\n  if (cinfo->master->call_pass_startup)\n    (*cinfo->master->pass_startup) (cinfo);\n\n  /* Ignore any extra scanlines at bottom of image. */\n  rows_left = cinfo->image_height - cinfo->next_scanline;\n  if (num_lines > rows_left)\n    num_lines = rows_left;\n\n  row_ctr = 0;\n  (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, num_lines);\n  cinfo->next_scanline += row_ctr;\n  return row_ctr;\n}\n\n\n/*\n * Alternate entry point to write raw data.\n * Processes exactly one iMCU row per call, unless suspended.\n */\n\nGLOBAL JDIMENSION\njpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data,\n\t\t     JDIMENSION num_lines)\n{\n  JDIMENSION lines_per_iMCU_row;\n\n  if (cinfo->global_state != CSTATE_RAW_OK)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  if (cinfo->next_scanline >= cinfo->image_height) {\n    WARNMS(cinfo, JWRN_TOO_MUCH_DATA);\n    return 0;\n  }\n\n  /* Call progress monitor hook if present */\n  if (cinfo->progress != NULL) {\n    cinfo->progress->pass_counter = (long) cinfo->next_scanline;\n    cinfo->progress->pass_limit = (long) cinfo->image_height;\n    (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);\n  }\n\n  /* Give master control module another chance if this is first call to\n   * jpeg_write_raw_data.  This lets output of the frame/scan headers be\n   * delayed so that application can write COM, etc, markers between\n   * jpeg_start_compress and jpeg_write_raw_data.\n   */\n  if (cinfo->master->call_pass_startup)\n    (*cinfo->master->pass_startup) (cinfo);\n\n  /* Verify that at least one iMCU row has been passed. */\n  lines_per_iMCU_row = cinfo->max_v_samp_factor * DCTSIZE;\n  if (num_lines < lines_per_iMCU_row)\n    ERREXIT(cinfo, JERR_BUFFER_SIZE);\n\n  /* Directly compress the row. */\n  if (! (*cinfo->coef->compress_data) (cinfo, data)) {\n    /* If compressor did not consume the whole row, suspend processing. */\n    return 0;\n  }\n\n  /* OK, we processed one iMCU row. */\n  cinfo->next_scanline += lines_per_iMCU_row;\n  return lines_per_iMCU_row;\n}\n"
  },
  {
    "path": "code/jpeg-6/jccoefct.c",
    "content": "/*\n * jccoefct.c\n *\n * Copyright (C) 1994-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains the coefficient buffer controller for compression.\n * This controller is the top level of the JPEG compressor proper.\n * The coefficient buffer lies between forward-DCT and entropy encoding steps.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/* We use a full-image coefficient buffer when doing Huffman optimization,\n * and also for writing multiple-scan JPEG files.  In all cases, the DCT\n * step is run during the first pass, and subsequent passes need only read\n * the buffered coefficients.\n */\n#ifdef ENTROPY_OPT_SUPPORTED\n#define FULL_COEF_BUFFER_SUPPORTED\n#else\n#ifdef C_MULTISCAN_FILES_SUPPORTED\n#define FULL_COEF_BUFFER_SUPPORTED\n#endif\n#endif\n\n\n/* Private buffer controller object */\n\ntypedef struct {\n  struct jpeg_c_coef_controller pub; /* public fields */\n\n  JDIMENSION iMCU_row_num;\t/* iMCU row # within image */\n  JDIMENSION mcu_ctr;\t\t/* counts MCUs processed in current row */\n  int MCU_vert_offset;\t\t/* counts MCU rows within iMCU row */\n  int MCU_rows_per_iMCU_row;\t/* number of such rows needed */\n\n  /* For single-pass compression, it's sufficient to buffer just one MCU\n   * (although this may prove a bit slow in practice).  We allocate a\n   * workspace of C_MAX_BLOCKS_IN_MCU coefficient blocks, and reuse it for each\n   * MCU constructed and sent.  (On 80x86, the workspace is FAR even though\n   * it's not really very big; this is to keep the module interfaces unchanged\n   * when a large coefficient buffer is necessary.)\n   * In multi-pass modes, this array points to the current MCU's blocks\n   * within the virtual arrays.\n   */\n  JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU];\n\n  /* In multi-pass modes, we need a virtual block array for each component. */\n  jvirt_barray_ptr whole_image[MAX_COMPONENTS];\n} my_coef_controller;\n\ntypedef my_coef_controller * my_coef_ptr;\n\n\n/* Forward declarations */\nMETHODDEF boolean compress_data\n    JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf));\n#ifdef FULL_COEF_BUFFER_SUPPORTED\nMETHODDEF boolean compress_first_pass\n    JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf));\nMETHODDEF boolean compress_output\n    JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf));\n#endif\n\n\nLOCAL void\nstart_iMCU_row (j_compress_ptr cinfo)\n/* Reset within-iMCU-row counters for a new row */\n{\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n\n  /* In an interleaved scan, an MCU row is the same as an iMCU row.\n   * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.\n   * But at the bottom of the image, process only what's left.\n   */\n  if (cinfo->comps_in_scan > 1) {\n    coef->MCU_rows_per_iMCU_row = 1;\n  } else {\n    if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1))\n      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;\n    else\n      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;\n  }\n\n  coef->mcu_ctr = 0;\n  coef->MCU_vert_offset = 0;\n}\n\n\n/*\n * Initialize for a processing pass.\n */\n\nMETHODDEF void\nstart_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode)\n{\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n\n  coef->iMCU_row_num = 0;\n  start_iMCU_row(cinfo);\n\n  switch (pass_mode) {\n  case JBUF_PASS_THRU:\n    if (coef->whole_image[0] != NULL)\n      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n    coef->pub.compress_data = compress_data;\n    break;\n#ifdef FULL_COEF_BUFFER_SUPPORTED\n  case JBUF_SAVE_AND_PASS:\n    if (coef->whole_image[0] == NULL)\n      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n    coef->pub.compress_data = compress_first_pass;\n    break;\n  case JBUF_CRANK_DEST:\n    if (coef->whole_image[0] == NULL)\n      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n    coef->pub.compress_data = compress_output;\n    break;\n#endif\n  default:\n    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n    break;\n  }\n}\n\n\n/*\n * Process some data in the single-pass case.\n * We process the equivalent of one fully interleaved MCU row (\"iMCU\" row)\n * per call, ie, v_samp_factor block rows for each component in the image.\n * Returns TRUE if the iMCU row is completed, FALSE if suspended.\n *\n * NB: input_buf contains a plane for each component in image.\n * For single pass, this is the same as the components in the scan.\n */\n\nMETHODDEF boolean\ncompress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)\n{\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n  JDIMENSION MCU_col_num;\t/* index of current MCU within row */\n  JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;\n  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;\n  int blkn, bi, ci, yindex, yoffset, blockcnt;\n  JDIMENSION ypos, xpos;\n  jpeg_component_info *compptr;\n\n  /* Loop to write as much as one whole iMCU row */\n  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;\n       yoffset++) {\n    for (MCU_col_num = coef->mcu_ctr; MCU_col_num <= last_MCU_col;\n\t MCU_col_num++) {\n      /* Determine where data comes from in input_buf and do the DCT thing.\n       * Each call on forward_DCT processes a horizontal row of DCT blocks\n       * as wide as an MCU; we rely on having allocated the MCU_buffer[] blocks\n       * sequentially.  Dummy blocks at the right or bottom edge are filled in\n       * specially.  The data in them does not matter for image reconstruction,\n       * so we fill them with values that will encode to the smallest amount of\n       * data, viz: all zeroes in the AC entries, DC entries equal to previous\n       * block's DC value.  (Thanks to Thomas Kinsman for this idea.)\n       */\n      blkn = 0;\n      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n\tcompptr = cinfo->cur_comp_info[ci];\n\tblockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width\n\t\t\t\t\t\t: compptr->last_col_width;\n\txpos = MCU_col_num * compptr->MCU_sample_width;\n\typos = yoffset * DCTSIZE; /* ypos == (yoffset+yindex) * DCTSIZE */\n\tfor (yindex = 0; yindex < compptr->MCU_height; yindex++) {\n\t  if (coef->iMCU_row_num < last_iMCU_row ||\n\t      yoffset+yindex < compptr->last_row_height) {\n\t    (*cinfo->fdct->forward_DCT) (cinfo, compptr,\n\t\t\t\t\t input_buf[ci], coef->MCU_buffer[blkn],\n\t\t\t\t\t ypos, xpos, (JDIMENSION) blockcnt);\n\t    if (blockcnt < compptr->MCU_width) {\n\t      /* Create some dummy blocks at the right edge of the image. */\n\t      jzero_far((void FAR *) coef->MCU_buffer[blkn + blockcnt],\n\t\t\t(compptr->MCU_width - blockcnt) * SIZEOF(JBLOCK));\n\t      for (bi = blockcnt; bi < compptr->MCU_width; bi++) {\n\t\tcoef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn+bi-1][0][0];\n\t      }\n\t    }\n\t  } else {\n\t    /* Create a row of dummy blocks at the bottom of the image. */\n\t    jzero_far((void FAR *) coef->MCU_buffer[blkn],\n\t\t      compptr->MCU_width * SIZEOF(JBLOCK));\n\t    for (bi = 0; bi < compptr->MCU_width; bi++) {\n\t      coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn-1][0][0];\n\t    }\n\t  }\n\t  blkn += compptr->MCU_width;\n\t  ypos += DCTSIZE;\n\t}\n      }\n      /* Try to write the MCU.  In event of a suspension failure, we will\n       * re-DCT the MCU on restart (a bit inefficient, could be fixed...)\n       */\n      if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {\n\t/* Suspension forced; update state counters and exit */\n\tcoef->MCU_vert_offset = yoffset;\n\tcoef->mcu_ctr = MCU_col_num;\n\treturn FALSE;\n      }\n    }\n    /* Completed an MCU row, but perhaps not an iMCU row */\n    coef->mcu_ctr = 0;\n  }\n  /* Completed the iMCU row, advance counters for next one */\n  coef->iMCU_row_num++;\n  start_iMCU_row(cinfo);\n  return TRUE;\n}\n\n\n#ifdef FULL_COEF_BUFFER_SUPPORTED\n\n/*\n * Process some data in the first pass of a multi-pass case.\n * We process the equivalent of one fully interleaved MCU row (\"iMCU\" row)\n * per call, ie, v_samp_factor block rows for each component in the image.\n * This amount of data is read from the source buffer, DCT'd and quantized,\n * and saved into the virtual arrays.  We also generate suitable dummy blocks\n * as needed at the right and lower edges.  (The dummy blocks are constructed\n * in the virtual arrays, which have been padded appropriately.)  This makes\n * it possible for subsequent passes not to worry about real vs. dummy blocks.\n *\n * We must also emit the data to the entropy encoder.  This is conveniently\n * done by calling compress_output() after we've loaded the current strip\n * of the virtual arrays.\n *\n * NB: input_buf contains a plane for each component in image.  All\n * components are DCT'd and loaded into the virtual arrays in this pass.\n * However, it may be that only a subset of the components are emitted to\n * the entropy encoder during this first pass; be careful about looking\n * at the scan-dependent variables (MCU dimensions, etc).\n */\n\nMETHODDEF boolean\ncompress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)\n{\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;\n  JDIMENSION blocks_across, MCUs_across, MCUindex;\n  int bi, ci, h_samp_factor, block_row, block_rows, ndummy;\n  JCOEF lastDC;\n  jpeg_component_info *compptr;\n  JBLOCKARRAY buffer;\n  JBLOCKROW thisblockrow, lastblockrow;\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    /* Align the virtual buffer for this component. */\n    buffer = (*cinfo->mem->access_virt_barray)\n      ((j_common_ptr) cinfo, coef->whole_image[ci],\n       coef->iMCU_row_num * compptr->v_samp_factor,\n       (JDIMENSION) compptr->v_samp_factor, TRUE);\n    /* Count non-dummy DCT block rows in this iMCU row. */\n    if (coef->iMCU_row_num < last_iMCU_row)\n      block_rows = compptr->v_samp_factor;\n    else {\n      /* NB: can't use last_row_height here, since may not be set! */\n      block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);\n      if (block_rows == 0) block_rows = compptr->v_samp_factor;\n    }\n    blocks_across = compptr->width_in_blocks;\n    h_samp_factor = compptr->h_samp_factor;\n    /* Count number of dummy blocks to be added at the right margin. */\n    ndummy = (int) (blocks_across % h_samp_factor);\n    if (ndummy > 0)\n      ndummy = h_samp_factor - ndummy;\n    /* Perform DCT for all non-dummy blocks in this iMCU row.  Each call\n     * on forward_DCT processes a complete horizontal row of DCT blocks.\n     */\n    for (block_row = 0; block_row < block_rows; block_row++) {\n      thisblockrow = buffer[block_row];\n      (*cinfo->fdct->forward_DCT) (cinfo, compptr,\n\t\t\t\t   input_buf[ci], thisblockrow,\n\t\t\t\t   (JDIMENSION) (block_row * DCTSIZE),\n\t\t\t\t   (JDIMENSION) 0, blocks_across);\n      if (ndummy > 0) {\n\t/* Create dummy blocks at the right edge of the image. */\n\tthisblockrow += blocks_across; /* => first dummy block */\n\tjzero_far((void FAR *) thisblockrow, ndummy * SIZEOF(JBLOCK));\n\tlastDC = thisblockrow[-1][0];\n\tfor (bi = 0; bi < ndummy; bi++) {\n\t  thisblockrow[bi][0] = lastDC;\n\t}\n      }\n    }\n    /* If at end of image, create dummy block rows as needed.\n     * The tricky part here is that within each MCU, we want the DC values\n     * of the dummy blocks to match the last real block's DC value.\n     * This squeezes a few more bytes out of the resulting file...\n     */\n    if (coef->iMCU_row_num == last_iMCU_row) {\n      blocks_across += ndummy;\t/* include lower right corner */\n      MCUs_across = blocks_across / h_samp_factor;\n      for (block_row = block_rows; block_row < compptr->v_samp_factor;\n\t   block_row++) {\n\tthisblockrow = buffer[block_row];\n\tlastblockrow = buffer[block_row-1];\n\tjzero_far((void FAR *) thisblockrow,\n\t\t  (size_t) (blocks_across * SIZEOF(JBLOCK)));\n\tfor (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) {\n\t  lastDC = lastblockrow[h_samp_factor-1][0];\n\t  for (bi = 0; bi < h_samp_factor; bi++) {\n\t    thisblockrow[bi][0] = lastDC;\n\t  }\n\t  thisblockrow += h_samp_factor; /* advance to next MCU in row */\n\t  lastblockrow += h_samp_factor;\n\t}\n      }\n    }\n  }\n  /* NB: compress_output will increment iMCU_row_num if successful.\n   * A suspension return will result in redoing all the work above next time.\n   */\n\n  /* Emit data to the entropy encoder, sharing code with subsequent passes */\n  return compress_output(cinfo, input_buf);\n}\n\n\n/*\n * Process some data in subsequent passes of a multi-pass case.\n * We process the equivalent of one fully interleaved MCU row (\"iMCU\" row)\n * per call, ie, v_samp_factor block rows for each component in the scan.\n * The data is obtained from the virtual arrays and fed to the entropy coder.\n * Returns TRUE if the iMCU row is completed, FALSE if suspended.\n *\n * NB: input_buf is ignored; it is likely to be a NULL pointer.\n */\n\nMETHODDEF boolean\ncompress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)\n{\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n  JDIMENSION MCU_col_num;\t/* index of current MCU within row */\n  int blkn, ci, xindex, yindex, yoffset;\n  JDIMENSION start_col;\n  JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];\n  JBLOCKROW buffer_ptr;\n  jpeg_component_info *compptr;\n\n  /* Align the virtual buffers for the components used in this scan.\n   * NB: during first pass, this is safe only because the buffers will\n   * already be aligned properly, so jmemmgr.c won't need to do any I/O.\n   */\n  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n    compptr = cinfo->cur_comp_info[ci];\n    buffer[ci] = (*cinfo->mem->access_virt_barray)\n      ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],\n       coef->iMCU_row_num * compptr->v_samp_factor,\n       (JDIMENSION) compptr->v_samp_factor, FALSE);\n  }\n\n  /* Loop to process one whole iMCU row */\n  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;\n       yoffset++) {\n    for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row;\n\t MCU_col_num++) {\n      /* Construct list of pointers to DCT blocks belonging to this MCU */\n      blkn = 0;\t\t\t/* index of current DCT block within MCU */\n      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n\tcompptr = cinfo->cur_comp_info[ci];\n\tstart_col = MCU_col_num * compptr->MCU_width;\n\tfor (yindex = 0; yindex < compptr->MCU_height; yindex++) {\n\t  buffer_ptr = buffer[ci][yindex+yoffset] + start_col;\n\t  for (xindex = 0; xindex < compptr->MCU_width; xindex++) {\n\t    coef->MCU_buffer[blkn++] = buffer_ptr++;\n\t  }\n\t}\n      }\n      /* Try to write the MCU. */\n      if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {\n\t/* Suspension forced; update state counters and exit */\n\tcoef->MCU_vert_offset = yoffset;\n\tcoef->mcu_ctr = MCU_col_num;\n\treturn FALSE;\n      }\n    }\n    /* Completed an MCU row, but perhaps not an iMCU row */\n    coef->mcu_ctr = 0;\n  }\n  /* Completed the iMCU row, advance counters for next one */\n  coef->iMCU_row_num++;\n  start_iMCU_row(cinfo);\n  return TRUE;\n}\n\n#endif /* FULL_COEF_BUFFER_SUPPORTED */\n\n\n/*\n * Initialize coefficient buffer controller.\n */\n\nGLOBAL void\njinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer)\n{\n  my_coef_ptr coef;\n\n  coef = (my_coef_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_coef_controller));\n  cinfo->coef = (struct jpeg_c_coef_controller *) coef;\n  coef->pub.start_pass = start_pass_coef;\n\n  /* Create the coefficient buffer. */\n  if (need_full_buffer) {\n#ifdef FULL_COEF_BUFFER_SUPPORTED\n    /* Allocate a full-image virtual array for each component, */\n    /* padded to a multiple of samp_factor DCT blocks in each direction. */\n    int ci;\n    jpeg_component_info *compptr;\n\n    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n\t ci++, compptr++) {\n      coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)\n\t((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,\n\t (JDIMENSION) jround_up((long) compptr->width_in_blocks,\n\t\t\t\t(long) compptr->h_samp_factor),\n\t (JDIMENSION) jround_up((long) compptr->height_in_blocks,\n\t\t\t\t(long) compptr->v_samp_factor),\n\t (JDIMENSION) compptr->v_samp_factor);\n    }\n#else\n    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n#endif\n  } else {\n    /* We only need a single-MCU buffer. */\n    JBLOCKROW buffer;\n    int i;\n\n    buffer = (JBLOCKROW)\n      (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t  C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));\n    for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {\n      coef->MCU_buffer[i] = buffer + i;\n    }\n    coef->whole_image[0] = NULL; /* flag for no virtual arrays */\n  }\n}\n"
  },
  {
    "path": "code/jpeg-6/jccolor.c",
    "content": "/*\n * jccolor.c\n *\n * Copyright (C) 1991-1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains input colorspace conversion routines.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/* Private subobject */\n\ntypedef struct {\n  struct jpeg_color_converter pub; /* public fields */\n\n  /* Private state for RGB->YCC conversion */\n  INT32 * rgb_ycc_tab;\t\t/* => table for RGB to YCbCr conversion */\n} my_color_converter;\n\ntypedef my_color_converter * my_cconvert_ptr;\n\n\n/**************** RGB -> YCbCr conversion: most common case **************/\n\n/*\n * YCbCr is defined per CCIR 601-1, except that Cb and Cr are\n * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.\n * The conversion equations to be implemented are therefore\n *\tY  =  0.29900 * R + 0.58700 * G + 0.11400 * B\n *\tCb = -0.16874 * R - 0.33126 * G + 0.50000 * B  + CENTERJSAMPLE\n *\tCr =  0.50000 * R - 0.41869 * G - 0.08131 * B  + CENTERJSAMPLE\n * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)\n * Note: older versions of the IJG code used a zero offset of MAXJSAMPLE/2,\n * rather than CENTERJSAMPLE, for Cb and Cr.  This gave equal positive and\n * negative swings for Cb/Cr, but meant that grayscale values (Cb=Cr=0)\n * were not represented exactly.  Now we sacrifice exact representation of\n * maximum red and maximum blue in order to get exact grayscales.\n *\n * To avoid floating-point arithmetic, we represent the fractional constants\n * as integers scaled up by 2^16 (about 4 digits precision); we have to divide\n * the products by 2^16, with appropriate rounding, to get the correct answer.\n *\n * For even more speed, we avoid doing any multiplications in the inner loop\n * by precalculating the constants times R,G,B for all possible values.\n * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);\n * for 12-bit samples it is still acceptable.  It's not very reasonable for\n * 16-bit samples, but if you want lossless storage you shouldn't be changing\n * colorspace anyway.\n * The CENTERJSAMPLE offsets and the rounding fudge-factor of 0.5 are included\n * in the tables to save adding them separately in the inner loop.\n */\n\n#define SCALEBITS\t16\t/* speediest right-shift on some machines */\n#define CBCR_OFFSET\t((INT32) CENTERJSAMPLE << SCALEBITS)\n#define ONE_HALF\t((INT32) 1 << (SCALEBITS-1))\n#define FIX(x)\t\t((INT32) ((x) * (1L<<SCALEBITS) + 0.5))\n\n/* We allocate one big table and divide it up into eight parts, instead of\n * doing eight alloc_small requests.  This lets us use a single table base\n * address, which can be held in a register in the inner loops on many\n * machines (more than can hold all eight addresses, anyway).\n */\n\n#define R_Y_OFF\t\t0\t\t\t/* offset to R => Y section */\n#define G_Y_OFF\t\t(1*(MAXJSAMPLE+1))\t/* offset to G => Y section */\n#define B_Y_OFF\t\t(2*(MAXJSAMPLE+1))\t/* etc. */\n#define R_CB_OFF\t(3*(MAXJSAMPLE+1))\n#define G_CB_OFF\t(4*(MAXJSAMPLE+1))\n#define B_CB_OFF\t(5*(MAXJSAMPLE+1))\n#define R_CR_OFF\tB_CB_OFF\t\t/* B=>Cb, R=>Cr are the same */\n#define G_CR_OFF\t(6*(MAXJSAMPLE+1))\n#define B_CR_OFF\t(7*(MAXJSAMPLE+1))\n#define TABLE_SIZE\t(8*(MAXJSAMPLE+1))\n\n\n/*\n * Initialize for RGB->YCC colorspace conversion.\n */\n\nMETHODDEF void\nrgb_ycc_start (j_compress_ptr cinfo)\n{\n  my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;\n  INT32 * rgb_ycc_tab;\n  INT32 i;\n\n  /* Allocate and fill in the conversion tables. */\n  cconvert->rgb_ycc_tab = rgb_ycc_tab = (INT32 *)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t(TABLE_SIZE * SIZEOF(INT32)));\n\n  for (i = 0; i <= MAXJSAMPLE; i++) {\n    rgb_ycc_tab[i+R_Y_OFF] = FIX(0.29900) * i;\n    rgb_ycc_tab[i+G_Y_OFF] = FIX(0.58700) * i;\n    rgb_ycc_tab[i+B_Y_OFF] = FIX(0.11400) * i     + ONE_HALF;\n    rgb_ycc_tab[i+R_CB_OFF] = (-FIX(0.16874)) * i;\n    rgb_ycc_tab[i+G_CB_OFF] = (-FIX(0.33126)) * i;\n    /* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr.\n     * This ensures that the maximum output will round to MAXJSAMPLE\n     * not MAXJSAMPLE+1, and thus that we don't have to range-limit.\n     */\n    rgb_ycc_tab[i+B_CB_OFF] = FIX(0.50000) * i    + CBCR_OFFSET + ONE_HALF-1;\n/*  B=>Cb and R=>Cr tables are the same\n    rgb_ycc_tab[i+R_CR_OFF] = FIX(0.50000) * i    + CBCR_OFFSET + ONE_HALF-1;\n*/\n    rgb_ycc_tab[i+G_CR_OFF] = (-FIX(0.41869)) * i;\n    rgb_ycc_tab[i+B_CR_OFF] = (-FIX(0.08131)) * i;\n  }\n}\n\n\n/*\n * Convert some rows of samples to the JPEG colorspace.\n *\n * Note that we change from the application's interleaved-pixel format\n * to our internal noninterleaved, one-plane-per-component format.\n * The input buffer is therefore three times as wide as the output buffer.\n *\n * A starting row offset is provided only for the output buffer.  The caller\n * can easily adjust the passed input_buf value to accommodate any row\n * offset required on that side.\n */\n\nMETHODDEF void\nrgb_ycc_convert (j_compress_ptr cinfo,\n\t\t JSAMPARRAY input_buf, JSAMPIMAGE output_buf,\n\t\t JDIMENSION output_row, int num_rows)\n{\n  my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;\n  register int r, g, b;\n  register INT32 * ctab = cconvert->rgb_ycc_tab;\n  register JSAMPROW inptr;\n  register JSAMPROW outptr0, outptr1, outptr2;\n  register JDIMENSION col;\n  JDIMENSION num_cols = cinfo->image_width;\n\n  while (--num_rows >= 0) {\n    inptr = *input_buf++;\n    outptr0 = output_buf[0][output_row];\n    outptr1 = output_buf[1][output_row];\n    outptr2 = output_buf[2][output_row];\n    output_row++;\n    for (col = 0; col < num_cols; col++) {\n      r = GETJSAMPLE(inptr[RGB_RED]);\n      g = GETJSAMPLE(inptr[RGB_GREEN]);\n      b = GETJSAMPLE(inptr[RGB_BLUE]);\n      inptr += RGB_PIXELSIZE;\n      /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations\n       * must be too; we do not need an explicit range-limiting operation.\n       * Hence the value being shifted is never negative, and we don't\n       * need the general RIGHT_SHIFT macro.\n       */\n      /* Y */\n      outptr0[col] = (JSAMPLE)\n\t\t((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF])\n\t\t >> SCALEBITS);\n      /* Cb */\n      outptr1[col] = (JSAMPLE)\n\t\t((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF])\n\t\t >> SCALEBITS);\n      /* Cr */\n      outptr2[col] = (JSAMPLE)\n\t\t((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF])\n\t\t >> SCALEBITS);\n    }\n  }\n}\n\n\n/**************** Cases other than RGB -> YCbCr **************/\n\n\n/*\n * Convert some rows of samples to the JPEG colorspace.\n * This version handles RGB->grayscale conversion, which is the same\n * as the RGB->Y portion of RGB->YCbCr.\n * We assume rgb_ycc_start has been called (we only use the Y tables).\n */\n\nMETHODDEF void\nrgb_gray_convert (j_compress_ptr cinfo,\n\t\t  JSAMPARRAY input_buf, JSAMPIMAGE output_buf,\n\t\t  JDIMENSION output_row, int num_rows)\n{\n  my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;\n  register int r, g, b;\n  register INT32 * ctab = cconvert->rgb_ycc_tab;\n  register JSAMPROW inptr;\n  register JSAMPROW outptr;\n  register JDIMENSION col;\n  JDIMENSION num_cols = cinfo->image_width;\n\n  while (--num_rows >= 0) {\n    inptr = *input_buf++;\n    outptr = output_buf[0][output_row];\n    output_row++;\n    for (col = 0; col < num_cols; col++) {\n      r = GETJSAMPLE(inptr[RGB_RED]);\n      g = GETJSAMPLE(inptr[RGB_GREEN]);\n      b = GETJSAMPLE(inptr[RGB_BLUE]);\n      inptr += RGB_PIXELSIZE;\n      /* Y */\n      outptr[col] = (JSAMPLE)\n\t\t((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF])\n\t\t >> SCALEBITS);\n    }\n  }\n}\n\n\n/*\n * Convert some rows of samples to the JPEG colorspace.\n * This version handles Adobe-style CMYK->YCCK conversion,\n * where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the same\n * conversion as above, while passing K (black) unchanged.\n * We assume rgb_ycc_start has been called.\n */\n\nMETHODDEF void\ncmyk_ycck_convert (j_compress_ptr cinfo,\n\t\t   JSAMPARRAY input_buf, JSAMPIMAGE output_buf,\n\t\t   JDIMENSION output_row, int num_rows)\n{\n  my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;\n  register int r, g, b;\n  register INT32 * ctab = cconvert->rgb_ycc_tab;\n  register JSAMPROW inptr;\n  register JSAMPROW outptr0, outptr1, outptr2, outptr3;\n  register JDIMENSION col;\n  JDIMENSION num_cols = cinfo->image_width;\n\n  while (--num_rows >= 0) {\n    inptr = *input_buf++;\n    outptr0 = output_buf[0][output_row];\n    outptr1 = output_buf[1][output_row];\n    outptr2 = output_buf[2][output_row];\n    outptr3 = output_buf[3][output_row];\n    output_row++;\n    for (col = 0; col < num_cols; col++) {\n      r = MAXJSAMPLE - GETJSAMPLE(inptr[0]);\n      g = MAXJSAMPLE - GETJSAMPLE(inptr[1]);\n      b = MAXJSAMPLE - GETJSAMPLE(inptr[2]);\n      /* K passes through as-is */\n      outptr3[col] = inptr[3];\t/* don't need GETJSAMPLE here */\n      inptr += 4;\n      /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations\n       * must be too; we do not need an explicit range-limiting operation.\n       * Hence the value being shifted is never negative, and we don't\n       * need the general RIGHT_SHIFT macro.\n       */\n      /* Y */\n      outptr0[col] = (JSAMPLE)\n\t\t((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF])\n\t\t >> SCALEBITS);\n      /* Cb */\n      outptr1[col] = (JSAMPLE)\n\t\t((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF])\n\t\t >> SCALEBITS);\n      /* Cr */\n      outptr2[col] = (JSAMPLE)\n\t\t((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF])\n\t\t >> SCALEBITS);\n    }\n  }\n}\n\n\n/*\n * Convert some rows of samples to the JPEG colorspace.\n * This version handles grayscale output with no conversion.\n * The source can be either plain grayscale or YCbCr (since Y == gray).\n */\n\nMETHODDEF void\ngrayscale_convert (j_compress_ptr cinfo,\n\t\t   JSAMPARRAY input_buf, JSAMPIMAGE output_buf,\n\t\t   JDIMENSION output_row, int num_rows)\n{\n  register JSAMPROW inptr;\n  register JSAMPROW outptr;\n  register JDIMENSION col;\n  JDIMENSION num_cols = cinfo->image_width;\n  int instride = cinfo->input_components;\n\n  while (--num_rows >= 0) {\n    inptr = *input_buf++;\n    outptr = output_buf[0][output_row];\n    output_row++;\n    for (col = 0; col < num_cols; col++) {\n      outptr[col] = inptr[0];\t/* don't need GETJSAMPLE() here */\n      inptr += instride;\n    }\n  }\n}\n\n\n/*\n * Convert some rows of samples to the JPEG colorspace.\n * This version handles multi-component colorspaces without conversion.\n * We assume input_components == num_components.\n */\n\nMETHODDEF void\nnull_convert (j_compress_ptr cinfo,\n\t      JSAMPARRAY input_buf, JSAMPIMAGE output_buf,\n\t      JDIMENSION output_row, int num_rows)\n{\n  register JSAMPROW inptr;\n  register JSAMPROW outptr;\n  register JDIMENSION col;\n  register int ci;\n  int nc = cinfo->num_components;\n  JDIMENSION num_cols = cinfo->image_width;\n\n  while (--num_rows >= 0) {\n    /* It seems fastest to make a separate pass for each component. */\n    for (ci = 0; ci < nc; ci++) {\n      inptr = *input_buf;\n      outptr = output_buf[ci][output_row];\n      for (col = 0; col < num_cols; col++) {\n\toutptr[col] = inptr[ci]; /* don't need GETJSAMPLE() here */\n\tinptr += nc;\n      }\n    }\n    input_buf++;\n    output_row++;\n  }\n}\n\n\n/*\n * Empty method for start_pass.\n */\n\nMETHODDEF void\nnull_method (j_compress_ptr cinfo)\n{\n  /* no work needed */\n}\n\n\n/*\n * Module initialization routine for input colorspace conversion.\n */\n\nGLOBAL void\njinit_color_converter (j_compress_ptr cinfo)\n{\n  my_cconvert_ptr cconvert;\n\n  cconvert = (my_cconvert_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_color_converter));\n  cinfo->cconvert = (struct jpeg_color_converter *) cconvert;\n  /* set start_pass to null method until we find out differently */\n  cconvert->pub.start_pass = null_method;\n\n  /* Make sure input_components agrees with in_color_space */\n  switch (cinfo->in_color_space) {\n  case JCS_GRAYSCALE:\n    if (cinfo->input_components != 1)\n      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);\n    break;\n\n  case JCS_RGB:\n#if RGB_PIXELSIZE != 3\n    if (cinfo->input_components != RGB_PIXELSIZE)\n      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);\n    break;\n#endif /* else share code with YCbCr */\n\n  case JCS_YCbCr:\n    if (cinfo->input_components != 3)\n      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);\n    break;\n\n  case JCS_CMYK:\n  case JCS_YCCK:\n    if (cinfo->input_components != 4)\n      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);\n    break;\n\n  default:\t\t\t/* JCS_UNKNOWN can be anything */\n    if (cinfo->input_components < 1)\n      ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);\n    break;\n  }\n\n  /* Check num_components, set conversion method based on requested space */\n  switch (cinfo->jpeg_color_space) {\n  case JCS_GRAYSCALE:\n    if (cinfo->num_components != 1)\n      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);\n    if (cinfo->in_color_space == JCS_GRAYSCALE)\n      cconvert->pub.color_convert = grayscale_convert;\n    else if (cinfo->in_color_space == JCS_RGB) {\n      cconvert->pub.start_pass = rgb_ycc_start;\n      cconvert->pub.color_convert = rgb_gray_convert;\n    } else if (cinfo->in_color_space == JCS_YCbCr)\n      cconvert->pub.color_convert = grayscale_convert;\n    else\n      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);\n    break;\n\n  case JCS_RGB:\n    if (cinfo->num_components != 3)\n      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);\n    if (cinfo->in_color_space == JCS_RGB && RGB_PIXELSIZE == 3)\n      cconvert->pub.color_convert = null_convert;\n    else\n      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);\n    break;\n\n  case JCS_YCbCr:\n    if (cinfo->num_components != 3)\n      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);\n    if (cinfo->in_color_space == JCS_RGB) {\n      cconvert->pub.start_pass = rgb_ycc_start;\n      cconvert->pub.color_convert = rgb_ycc_convert;\n    } else if (cinfo->in_color_space == JCS_YCbCr)\n      cconvert->pub.color_convert = null_convert;\n    else\n      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);\n    break;\n\n  case JCS_CMYK:\n    if (cinfo->num_components != 4)\n      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);\n    if (cinfo->in_color_space == JCS_CMYK)\n      cconvert->pub.color_convert = null_convert;\n    else\n      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);\n    break;\n\n  case JCS_YCCK:\n    if (cinfo->num_components != 4)\n      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);\n    if (cinfo->in_color_space == JCS_CMYK) {\n      cconvert->pub.start_pass = rgb_ycc_start;\n      cconvert->pub.color_convert = cmyk_ycck_convert;\n    } else if (cinfo->in_color_space == JCS_YCCK)\n      cconvert->pub.color_convert = null_convert;\n    else\n      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);\n    break;\n\n  default:\t\t\t/* allow null conversion of JCS_UNKNOWN */\n    if (cinfo->jpeg_color_space != cinfo->in_color_space ||\n\tcinfo->num_components != cinfo->input_components)\n      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);\n    cconvert->pub.color_convert = null_convert;\n    break;\n  }\n}\n"
  },
  {
    "path": "code/jpeg-6/jcdctmgr.c",
    "content": "/*\n * jcdctmgr.c\n *\n * Copyright (C) 1994-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains the forward-DCT management logic.\n * This code selects a particular DCT implementation to be used,\n * and it performs related housekeeping chores including coefficient\n * quantization.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jdct.h\"\t\t/* Private declarations for DCT subsystem */\n\n\n/* Private subobject for this module */\n\ntypedef struct {\n  struct jpeg_forward_dct pub;\t/* public fields */\n\n  /* Pointer to the DCT routine actually in use */\n  forward_DCT_method_ptr do_dct;\n\n  /* The actual post-DCT divisors --- not identical to the quant table\n   * entries, because of scaling (especially for an unnormalized DCT).\n   * Each table is given in normal array order; note that this must\n   * be converted from the zigzag order of the quantization tables.\n   */\n  DCTELEM * divisors[NUM_QUANT_TBLS];\n\n#ifdef DCT_FLOAT_SUPPORTED\n  /* Same as above for the floating-point case. */\n  float_DCT_method_ptr do_float_dct;\n  FAST_FLOAT * float_divisors[NUM_QUANT_TBLS];\n#endif\n} my_fdct_controller;\n\ntypedef my_fdct_controller * my_fdct_ptr;\n\n\n/*\n * Initialize for a processing pass.\n * Verify that all referenced Q-tables are present, and set up\n * the divisor table for each one.\n * In the current implementation, DCT of all components is done during\n * the first pass, even if only some components will be output in the\n * first scan.  Hence all components should be examined here.\n */\n\nMETHODDEF void\nstart_pass_fdctmgr (j_compress_ptr cinfo)\n{\n  my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;\n  int ci, qtblno, i;\n  jpeg_component_info *compptr;\n  JQUANT_TBL * qtbl;\n#ifdef DCT_ISLOW_SUPPORTED\n  DCTELEM * dtbl;\n#endif\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    qtblno = compptr->quant_tbl_no;\n    /* Make sure specified quantization table is present */\n    if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS ||\n\tcinfo->quant_tbl_ptrs[qtblno] == NULL)\n      ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);\n    qtbl = cinfo->quant_tbl_ptrs[qtblno];\n    /* Compute divisors for this quant table */\n    /* We may do this more than once for same table, but it's not a big deal */\n    switch (cinfo->dct_method) {\n#ifdef DCT_ISLOW_SUPPORTED\n    case JDCT_ISLOW:\n      /* For LL&M IDCT method, divisors are equal to raw quantization\n       * coefficients multiplied by 8 (to counteract scaling).\n       */\n      if (fdct->divisors[qtblno] == NULL) {\n\tfdct->divisors[qtblno] = (DCTELEM *)\n\t  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t      DCTSIZE2 * SIZEOF(DCTELEM));\n      }\n      dtbl = fdct->divisors[qtblno];\n      for (i = 0; i < DCTSIZE2; i++) {\n\tdtbl[i] = ((DCTELEM) qtbl->quantval[jpeg_zigzag_order[i]]) << 3;\n      }\n      break;\n#endif\n#ifdef DCT_IFAST_SUPPORTED\n    case JDCT_IFAST:\n      {\n\t/* For AA&N IDCT method, divisors are equal to quantization\n\t * coefficients scaled by scalefactor[row]*scalefactor[col], where\n\t *   scalefactor[0] = 1\n\t *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7\n\t * We apply a further scale factor of 8.\n\t */\n#define CONST_BITS 14\n\tstatic const INT16 aanscales[DCTSIZE2] = {\n\t  /* precomputed values scaled up by 14 bits: in natural order */\n\t  16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,\n\t  22725, 31521, 29692, 26722, 22725, 17855, 12299,  6270,\n\t  21407, 29692, 27969, 25172, 21407, 16819, 11585,  5906,\n\t  19266, 26722, 25172, 22654, 19266, 15137, 10426,  5315,\n\t  16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,\n\t  12873, 17855, 16819, 15137, 12873, 10114,  6967,  3552,\n\t   8867, 12299, 11585, 10426,  8867,  6967,  4799,  2446,\n\t   4520,  6270,  5906,  5315,  4520,  3552,  2446,  1247\n\t};\n\tSHIFT_TEMPS\n\n\tif (fdct->divisors[qtblno] == NULL) {\n\t  fdct->divisors[qtblno] = (DCTELEM *)\n\t    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t\tDCTSIZE2 * SIZEOF(DCTELEM));\n\t}\n\tdtbl = fdct->divisors[qtblno];\n\tfor (i = 0; i < DCTSIZE2; i++) {\n\t  dtbl[i] = (DCTELEM)\n\t    DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[jpeg_zigzag_order[i]],\n\t\t\t\t  (INT32) aanscales[i]),\n\t\t    CONST_BITS-3);\n\t}\n      }\n      break;\n#endif\n#ifdef DCT_FLOAT_SUPPORTED\n    case JDCT_FLOAT:\n      {\n\t/* For float AA&N IDCT method, divisors are equal to quantization\n\t * coefficients scaled by scalefactor[row]*scalefactor[col], where\n\t *   scalefactor[0] = 1\n\t *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7\n\t * We apply a further scale factor of 8.\n\t * What's actually stored is 1/divisor so that the inner loop can\n\t * use a multiplication rather than a division.\n\t */\n\tFAST_FLOAT * fdtbl;\n\tint row, col;\n\tstatic const double aanscalefactor[DCTSIZE] = {\n\t  1.0, 1.387039845, 1.306562965, 1.175875602,\n\t  1.0, 0.785694958, 0.541196100, 0.275899379\n\t};\n\n\tif (fdct->float_divisors[qtblno] == NULL) {\n\t  fdct->float_divisors[qtblno] = (FAST_FLOAT *)\n\t    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t\tDCTSIZE2 * SIZEOF(FAST_FLOAT));\n\t}\n\tfdtbl = fdct->float_divisors[qtblno];\n\ti = 0;\n\tfor (row = 0; row < DCTSIZE; row++) {\n\t  for (col = 0; col < DCTSIZE; col++) {\n\t    fdtbl[i] = (FAST_FLOAT)\n\t      (1.0 / (((double) qtbl->quantval[jpeg_zigzag_order[i]] *\n\t\t       aanscalefactor[row] * aanscalefactor[col] * 8.0)));\n\t    i++;\n\t  }\n\t}\n      }\n      break;\n#endif\n    default:\n      ERREXIT(cinfo, JERR_NOT_COMPILED);\n      break;\n    }\n  }\n}\n\n\n/*\n * Perform forward DCT on one or more blocks of a component.\n *\n * The input samples are taken from the sample_data[] array starting at\n * position start_row/start_col, and moving to the right for any additional\n * blocks. The quantized coefficients are returned in coef_blocks[].\n */\n\n#if 0 // bk001204\nMETHODDEF void\nforward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr,\n\t     JSAMPARRAY sample_data, JBLOCKROW coef_blocks,\n\t     JDIMENSION start_row, JDIMENSION start_col,\n\t     JDIMENSION num_blocks)\n/* This version is used for integer DCT implementations. */\n{\n  /* This routine is heavily used, so it's worth coding it tightly. */\n  my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;\n  forward_DCT_method_ptr do_dct = fdct->do_dct;\n  DCTELEM * divisors = fdct->divisors[compptr->quant_tbl_no];\n  DCTELEM workspace[DCTSIZE2];\t/* work area for FDCT subroutine */\n  JDIMENSION bi;\n\n  sample_data += start_row;\t/* fold in the vertical offset once */\n\n  for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) {\n    /* Load data into workspace, applying unsigned->signed conversion */\n    { register DCTELEM *workspaceptr;\n      register JSAMPROW elemptr;\n      register int elemr;\n\n      workspaceptr = workspace;\n      for (elemr = 0; elemr < DCTSIZE; elemr++) {\n\telemptr = sample_data[elemr] + start_col;\n#if DCTSIZE == 8\t\t/* unroll the inner loop */\n\t*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;\n\t*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;\n\t*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;\n\t*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;\n\t*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;\n\t*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;\n\t*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;\n\t*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;\n#else\n\t{ register int elemc;\n\t  for (elemc = DCTSIZE; elemc > 0; elemc--) {\n\t    *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;\n\t  }\n\t}\n#endif\n      }\n    }\n\n    /* Perform the DCT */\n    (*do_dct) (workspace);\n\n    /* Quantize/descale the coefficients, and store into coef_blocks[] */\n    { register DCTELEM temp, qval;\n      register int i;\n      register JCOEFPTR output_ptr = coef_blocks[bi];\n\n      for (i = 0; i < DCTSIZE2; i++) {\n\tqval = divisors[i];\n\ttemp = workspace[i];\n\t/* Divide the coefficient value by qval, ensuring proper rounding.\n\t * Since C does not specify the direction of rounding for negative\n\t * quotients, we have to force the dividend positive for portability.\n\t *\n\t * In most files, at least half of the output values will be zero\n\t * (at default quantization settings, more like three-quarters...)\n\t * so we should ensure that this case is fast.  On many machines,\n\t * a comparison is enough cheaper than a divide to make a special test\n\t * a win.  Since both inputs will be nonnegative, we need only test\n\t * for a < b to discover whether a/b is 0.\n\t * If your machine's division is fast enough, define FAST_DIVIDE.\n\t */\n#ifdef FAST_DIVIDE\n#define DIVIDE_BY(a,b)\ta /= b\n#else\n#define DIVIDE_BY(a,b)\tif (a >= b) a /= b; else a = 0\n#endif\n\tif (temp < 0) {\n\t  temp = -temp;\n\t  temp += qval>>1;\t/* for rounding */\n\t  DIVIDE_BY(temp, qval);\n\t  temp = -temp;\n\t} else {\n\t  temp += qval>>1;\t/* for rounding */\n\t  DIVIDE_BY(temp, qval);\n\t}\n\toutput_ptr[i] = (JCOEF) temp;\n      }\n    }\n  }\n}\n#endif // 0\n\n#ifdef DCT_FLOAT_SUPPORTED\n\nMETHODDEF void\nforward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr,\n\t\t   JSAMPARRAY sample_data, JBLOCKROW coef_blocks,\n\t\t   JDIMENSION start_row, JDIMENSION start_col,\n\t\t   JDIMENSION num_blocks)\n/* This version is used for floating-point DCT implementations. */\n{\n  /* This routine is heavily used, so it's worth coding it tightly. */\n  my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;\n  float_DCT_method_ptr do_dct = fdct->do_float_dct;\n  FAST_FLOAT * divisors = fdct->float_divisors[compptr->quant_tbl_no];\n  FAST_FLOAT workspace[DCTSIZE2]; /* work area for FDCT subroutine */\n  JDIMENSION bi;\n\n  sample_data += start_row;\t/* fold in the vertical offset once */\n\n  for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) {\n    /* Load data into workspace, applying unsigned->signed conversion */\n    { register FAST_FLOAT *workspaceptr;\n      register JSAMPROW elemptr;\n      register int elemr;\n\n      workspaceptr = workspace;\n      for (elemr = 0; elemr < DCTSIZE; elemr++) {\n\telemptr = sample_data[elemr] + start_col;\n#if DCTSIZE == 8\t\t/* unroll the inner loop */\n\t*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);\n\t*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);\n\t*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);\n\t*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);\n\t*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);\n\t*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);\n\t*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);\n\t*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);\n#else\n\t{ register int elemc;\n\t  for (elemc = DCTSIZE; elemc > 0; elemc--) {\n\t    *workspaceptr++ = (FAST_FLOAT)\n\t      (GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);\n\t  }\n\t}\n#endif\n      }\n    }\n\n    /* Perform the DCT */\n    (*do_dct) (workspace);\n\n    /* Quantize/descale the coefficients, and store into coef_blocks[] */\n    { register FAST_FLOAT temp;\n      register int i;\n      register JCOEFPTR output_ptr = coef_blocks[bi];\n\n      for (i = 0; i < DCTSIZE2; i++) {\n\t/* Apply the quantization and scaling factor */\n\ttemp = workspace[i] * divisors[i];\n\t/* Round to nearest integer.\n\t * Since C does not specify the direction of rounding for negative\n\t * quotients, we have to force the dividend positive for portability.\n\t * The maximum coefficient size is +-16K (for 12-bit data), so this\n\t * code should work for either 16-bit or 32-bit ints.\n\t */\n\toutput_ptr[i] = (JCOEF) ((int) (temp + (FAST_FLOAT) 16384.5) - 16384);\n      }\n    }\n  }\n}\n\n#endif /* DCT_FLOAT_SUPPORTED */\n\n\n/*\n * Initialize FDCT manager.\n */\n\nGLOBAL void\njinit_forward_dct (j_compress_ptr cinfo)\n{\n  my_fdct_ptr fdct;\n  int i;\n\n  fdct = (my_fdct_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_fdct_controller));\n  cinfo->fdct = (struct jpeg_forward_dct *) fdct;\n  fdct->pub.start_pass = start_pass_fdctmgr;\n\n  switch (cinfo->dct_method) {\n#ifdef DCT_ISLOW_SUPPORTED\n  case JDCT_ISLOW:\n    fdct->pub.forward_DCT = forward_DCT;\n    fdct->do_dct = jpeg_fdct_islow;\n    break;\n#endif\n#ifdef DCT_IFAST_SUPPORTED\n  case JDCT_IFAST:\n    fdct->pub.forward_DCT = forward_DCT;\n    fdct->do_dct = jpeg_fdct_ifast;\n    break;\n#endif\n#ifdef DCT_FLOAT_SUPPORTED\n  case JDCT_FLOAT:\n    fdct->pub.forward_DCT = forward_DCT_float;\n    fdct->do_float_dct = jpeg_fdct_float;\n    break;\n#endif\n  default:\n    ERREXIT(cinfo, JERR_NOT_COMPILED);\n    break;\n  }\n\n  /* Mark divisor tables unallocated */\n  for (i = 0; i < NUM_QUANT_TBLS; i++) {\n    fdct->divisors[i] = NULL;\n#ifdef DCT_FLOAT_SUPPORTED\n    fdct->float_divisors[i] = NULL;\n#endif\n  }\n}\n"
  },
  {
    "path": "code/jpeg-6/jchuff.c",
    "content": "/*\n * jchuff.c\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains Huffman entropy encoding routines.\n *\n * Much of the complexity here has to do with supporting output suspension.\n * If the data destination module demands suspension, we want to be able to\n * back up to the start of the current MCU.  To do this, we copy state\n * variables into local working storage, and update them back to the\n * permanent JPEG objects only upon successful completion of an MCU.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jchuff.h\"\t\t/* Declarations shared with jcphuff.c */\n\n\n/* Expanded entropy encoder object for Huffman encoding.\n *\n * The savable_state subrecord contains fields that change within an MCU,\n * but must not be updated permanently until we complete the MCU.\n */\n\ntypedef struct {\n  INT32 put_buffer;\t\t/* current bit-accumulation buffer */\n  int put_bits;\t\t\t/* # of bits now in it */\n  int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */\n} savable_state;\n\n/* This macro is to work around compilers with missing or broken\n * structure assignment.  You'll need to fix this code if you have\n * such a compiler and you change MAX_COMPS_IN_SCAN.\n */\n\n#ifndef NO_STRUCT_ASSIGN\n#define ASSIGN_STATE(dest,src)  ((dest) = (src))\n#else\n#if MAX_COMPS_IN_SCAN == 4\n#define ASSIGN_STATE(dest,src)  \\\n\t((dest).put_buffer = (src).put_buffer, \\\n\t (dest).put_bits = (src).put_bits, \\\n\t (dest).last_dc_val[0] = (src).last_dc_val[0], \\\n\t (dest).last_dc_val[1] = (src).last_dc_val[1], \\\n\t (dest).last_dc_val[2] = (src).last_dc_val[2], \\\n\t (dest).last_dc_val[3] = (src).last_dc_val[3])\n#endif\n#endif\n\n\ntypedef struct {\n  struct jpeg_entropy_encoder pub; /* public fields */\n\n  savable_state saved;\t\t/* Bit buffer & DC state at start of MCU */\n\n  /* These fields are NOT loaded into local working state. */\n  unsigned int restarts_to_go;\t/* MCUs left in this restart interval */\n  int next_restart_num;\t\t/* next restart number to write (0-7) */\n\n  /* Pointers to derived tables (these workspaces have image lifespan) */\n  c_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS];\n  c_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS];\n\n#ifdef ENTROPY_OPT_SUPPORTED\t/* Statistics tables for optimization */\n  long * dc_count_ptrs[NUM_HUFF_TBLS];\n  long * ac_count_ptrs[NUM_HUFF_TBLS];\n#endif\n} huff_entropy_encoder;\n\ntypedef huff_entropy_encoder * huff_entropy_ptr;\n\n/* Working state while writing an MCU.\n * This struct contains all the fields that are needed by subroutines.\n */\n\ntypedef struct {\n  JOCTET * next_output_byte;\t/* => next byte to write in buffer */\n  size_t free_in_buffer;\t/* # of byte spaces remaining in buffer */\n  savable_state cur;\t\t/* Current bit buffer & DC state */\n  j_compress_ptr cinfo;\t\t/* dump_buffer needs access to this */\n} working_state;\n\n\n/* Forward declarations */\nMETHODDEF boolean encode_mcu_huff JPP((j_compress_ptr cinfo,\n\t\t\t\t       JBLOCKROW *MCU_data));\nMETHODDEF void finish_pass_huff JPP((j_compress_ptr cinfo));\n#ifdef ENTROPY_OPT_SUPPORTED\nMETHODDEF boolean encode_mcu_gather JPP((j_compress_ptr cinfo,\n\t\t\t\t\t JBLOCKROW *MCU_data));\nMETHODDEF void finish_pass_gather JPP((j_compress_ptr cinfo));\n#endif\n\n\n/*\n * Initialize for a Huffman-compressed scan.\n * If gather_statistics is TRUE, we do not output anything during the scan,\n * just count the Huffman symbols used and generate Huffman code tables.\n */\n\nMETHODDEF void\nstart_pass_huff (j_compress_ptr cinfo, boolean gather_statistics)\n{\n  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;\n  int ci, dctbl, actbl;\n  jpeg_component_info * compptr;\n\n  if (gather_statistics) {\n#ifdef ENTROPY_OPT_SUPPORTED\n    entropy->pub.encode_mcu = encode_mcu_gather;\n    entropy->pub.finish_pass = finish_pass_gather;\n#else\n    ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif\n  } else {\n    entropy->pub.encode_mcu = encode_mcu_huff;\n    entropy->pub.finish_pass = finish_pass_huff;\n  }\n\n  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n    compptr = cinfo->cur_comp_info[ci];\n    dctbl = compptr->dc_tbl_no;\n    actbl = compptr->ac_tbl_no;\n    /* Make sure requested tables are present */\n    /* (In gather mode, tables need not be allocated yet) */\n    if (dctbl < 0 || dctbl >= NUM_HUFF_TBLS ||\n\t(cinfo->dc_huff_tbl_ptrs[dctbl] == NULL && !gather_statistics))\n      ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, dctbl);\n    if (actbl < 0 || actbl >= NUM_HUFF_TBLS ||\n\t(cinfo->ac_huff_tbl_ptrs[actbl] == NULL && !gather_statistics))\n      ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, actbl);\n    if (gather_statistics) {\n#ifdef ENTROPY_OPT_SUPPORTED\n      /* Allocate and zero the statistics tables */\n      /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */\n      if (entropy->dc_count_ptrs[dctbl] == NULL)\n\tentropy->dc_count_ptrs[dctbl] = (long *)\n\t  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t      257 * SIZEOF(long));\n      MEMZERO(entropy->dc_count_ptrs[dctbl], 257 * SIZEOF(long));\n      if (entropy->ac_count_ptrs[actbl] == NULL)\n\tentropy->ac_count_ptrs[actbl] = (long *)\n\t  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t      257 * SIZEOF(long));\n      MEMZERO(entropy->ac_count_ptrs[actbl], 257 * SIZEOF(long));\n#endif\n    } else {\n      /* Compute derived values for Huffman tables */\n      /* We may do this more than once for a table, but it's not expensive */\n      jpeg_make_c_derived_tbl(cinfo, cinfo->dc_huff_tbl_ptrs[dctbl],\n\t\t\t      & entropy->dc_derived_tbls[dctbl]);\n      jpeg_make_c_derived_tbl(cinfo, cinfo->ac_huff_tbl_ptrs[actbl],\n\t\t\t      & entropy->ac_derived_tbls[actbl]);\n    }\n    /* Initialize DC predictions to 0 */\n    entropy->saved.last_dc_val[ci] = 0;\n  }\n\n  /* Initialize bit buffer to empty */\n  entropy->saved.put_buffer = 0;\n  entropy->saved.put_bits = 0;\n\n  /* Initialize restart stuff */\n  entropy->restarts_to_go = cinfo->restart_interval;\n  entropy->next_restart_num = 0;\n}\n\n\n/*\n * Compute the derived values for a Huffman table.\n * Note this is also used by jcphuff.c.\n */\n\nGLOBAL void\njpeg_make_c_derived_tbl (j_compress_ptr cinfo, JHUFF_TBL * htbl,\n\t\t\t c_derived_tbl ** pdtbl)\n{\n  c_derived_tbl *dtbl;\n  int p, i, l, lastp, si;\n  char huffsize[257];\n  unsigned int huffcode[257];\n  unsigned int code;\n\n  /* Allocate a workspace if we haven't already done so. */\n  if (*pdtbl == NULL)\n    *pdtbl = (c_derived_tbl *)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t  SIZEOF(c_derived_tbl));\n  dtbl = *pdtbl;\n  \n  /* Figure C.1: make table of Huffman code length for each symbol */\n  /* Note that this is in code-length order. */\n\n  p = 0;\n  for (l = 1; l <= 16; l++) {\n    for (i = 1; i <= (int) htbl->bits[l]; i++)\n      huffsize[p++] = (char) l;\n  }\n  huffsize[p] = 0;\n  lastp = p;\n  \n  /* Figure C.2: generate the codes themselves */\n  /* Note that this is in code-length order. */\n  \n  code = 0;\n  si = huffsize[0];\n  p = 0;\n  while (huffsize[p]) {\n    while (((int) huffsize[p]) == si) {\n      huffcode[p++] = code;\n      code++;\n    }\n    code <<= 1;\n    si++;\n  }\n  \n  /* Figure C.3: generate encoding tables */\n  /* These are code and size indexed by symbol value */\n\n  /* Set any codeless symbols to have code length 0;\n   * this allows emit_bits to detect any attempt to emit such symbols.\n   */\n  MEMZERO(dtbl->ehufsi, SIZEOF(dtbl->ehufsi));\n\n  for (p = 0; p < lastp; p++) {\n    dtbl->ehufco[htbl->huffval[p]] = huffcode[p];\n    dtbl->ehufsi[htbl->huffval[p]] = huffsize[p];\n  }\n}\n\n\n/* Outputting bytes to the file */\n\n/* Emit a byte, taking 'action' if must suspend. */\n#define emit_byte(state,val,action)  \\\n\t{ *(state)->next_output_byte++ = (JOCTET) (val);  \\\n\t  if (--(state)->free_in_buffer == 0)  \\\n\t    if (! dump_buffer(state))  \\\n\t      { action; } }\n\n\nLOCAL boolean\ndump_buffer (working_state * state)\n/* Empty the output buffer; return TRUE if successful, FALSE if must suspend */\n{\n  struct jpeg_destination_mgr * dest = state->cinfo->dest;\n\n  if (! (*dest->empty_output_buffer) (state->cinfo))\n    return FALSE;\n  /* After a successful buffer dump, must reset buffer pointers */\n  state->next_output_byte = dest->next_output_byte;\n  state->free_in_buffer = dest->free_in_buffer;\n  return TRUE;\n}\n\n\n/* Outputting bits to the file */\n\n/* Only the right 24 bits of put_buffer are used; the valid bits are\n * left-justified in this part.  At most 16 bits can be passed to emit_bits\n * in one call, and we never retain more than 7 bits in put_buffer\n * between calls, so 24 bits are sufficient.\n */\n\nINLINE\nLOCAL boolean\nemit_bits (working_state * state, unsigned int code, int size)\n/* Emit some bits; return TRUE if successful, FALSE if must suspend */\n{\n  /* This routine is heavily used, so it's worth coding tightly. */\n  register INT32 put_buffer = (INT32) code;\n  register int put_bits = state->cur.put_bits;\n\n  /* if size is 0, caller used an invalid Huffman table entry */\n  if (size == 0)\n    ERREXIT(state->cinfo, JERR_HUFF_MISSING_CODE);\n\n  put_buffer &= (((INT32) 1)<<size) - 1; /* mask off any extra bits in code */\n  \n  put_bits += size;\t\t/* new number of bits in buffer */\n  \n  put_buffer <<= 24 - put_bits; /* align incoming bits */\n\n  put_buffer |= state->cur.put_buffer; /* and merge with old buffer contents */\n  \n  while (put_bits >= 8) {\n    int c = (int) ((put_buffer >> 16) & 0xFF);\n    \n    emit_byte(state, c, return FALSE);\n    if (c == 0xFF) {\t\t/* need to stuff a zero byte? */\n      emit_byte(state, 0, return FALSE);\n    }\n    put_buffer <<= 8;\n    put_bits -= 8;\n  }\n\n  state->cur.put_buffer = put_buffer; /* update state variables */\n  state->cur.put_bits = put_bits;\n\n  return TRUE;\n}\n\n\nLOCAL boolean\nflush_bits (working_state * state)\n{\n  if (! emit_bits(state, 0x7F, 7)) /* fill any partial byte with ones */\n    return FALSE;\n  state->cur.put_buffer = 0;\t/* and reset bit-buffer to empty */\n  state->cur.put_bits = 0;\n  return TRUE;\n}\n\n\n/* Encode a single block's worth of coefficients */\n\nLOCAL boolean\nencode_one_block (working_state * state, JCOEFPTR block, int last_dc_val,\n\t\t  c_derived_tbl *dctbl, c_derived_tbl *actbl)\n{\n  register int temp, temp2;\n  register int nbits;\n  register int k, r, i;\n  \n  /* Encode the DC coefficient difference per section F.1.2.1 */\n  \n  temp = temp2 = block[0] - last_dc_val;\n\n  if (temp < 0) {\n    temp = -temp;\t\t/* temp is abs value of input */\n    /* For a negative input, want temp2 = bitwise complement of abs(input) */\n    /* This code assumes we are on a two's complement machine */\n    temp2--;\n  }\n  \n  /* Find the number of bits needed for the magnitude of the coefficient */\n  nbits = 0;\n  while (temp) {\n    nbits++;\n    temp >>= 1;\n  }\n  \n  /* Emit the Huffman-coded symbol for the number of bits */\n  if (! emit_bits(state, dctbl->ehufco[nbits], dctbl->ehufsi[nbits]))\n    return FALSE;\n\n  /* Emit that number of bits of the value, if positive, */\n  /* or the complement of its magnitude, if negative. */\n  if (nbits)\t\t\t/* emit_bits rejects calls with size 0 */\n    if (! emit_bits(state, (unsigned int) temp2, nbits))\n      return FALSE;\n\n  /* Encode the AC coefficients per section F.1.2.2 */\n  \n  r = 0;\t\t\t/* r = run length of zeros */\n  \n  for (k = 1; k < DCTSIZE2; k++) {\n    if ((temp = block[jpeg_natural_order[k]]) == 0) {\n      r++;\n    } else {\n      /* if run length > 15, must emit special run-length-16 codes (0xF0) */\n      while (r > 15) {\n\tif (! emit_bits(state, actbl->ehufco[0xF0], actbl->ehufsi[0xF0]))\n\t  return FALSE;\n\tr -= 16;\n      }\n\n      temp2 = temp;\n      if (temp < 0) {\n\ttemp = -temp;\t\t/* temp is abs value of input */\n\t/* This code assumes we are on a two's complement machine */\n\ttemp2--;\n      }\n      \n      /* Find the number of bits needed for the magnitude of the coefficient */\n      nbits = 1;\t\t/* there must be at least one 1 bit */\n      while ((temp >>= 1))\n\tnbits++;\n      \n      /* Emit Huffman symbol for run length / number of bits */\n      i = (r << 4) + nbits;\n      if (! emit_bits(state, actbl->ehufco[i], actbl->ehufsi[i]))\n\treturn FALSE;\n\n      /* Emit that number of bits of the value, if positive, */\n      /* or the complement of its magnitude, if negative. */\n      if (! emit_bits(state, (unsigned int) temp2, nbits))\n\treturn FALSE;\n      \n      r = 0;\n    }\n  }\n\n  /* If the last coef(s) were zero, emit an end-of-block code */\n  if (r > 0)\n    if (! emit_bits(state, actbl->ehufco[0], actbl->ehufsi[0]))\n      return FALSE;\n\n  return TRUE;\n}\n\n\n/*\n * Emit a restart marker & resynchronize predictions.\n */\n\nLOCAL boolean\nemit_restart (working_state * state, int restart_num)\n{\n  int ci;\n\n  if (! flush_bits(state))\n    return FALSE;\n\n  emit_byte(state, 0xFF, return FALSE);\n  emit_byte(state, JPEG_RST0 + restart_num, return FALSE);\n\n  /* Re-initialize DC predictions to 0 */\n  for (ci = 0; ci < state->cinfo->comps_in_scan; ci++)\n    state->cur.last_dc_val[ci] = 0;\n\n  /* The restart counter is not updated until we successfully write the MCU. */\n\n  return TRUE;\n}\n\n\n/*\n * Encode and output one MCU's worth of Huffman-compressed coefficients.\n */\n\nMETHODDEF boolean\nencode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data)\n{\n  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;\n  working_state state;\n  int blkn, ci;\n  jpeg_component_info * compptr;\n\n  /* Load up working state */\n  state.next_output_byte = cinfo->dest->next_output_byte;\n  state.free_in_buffer = cinfo->dest->free_in_buffer;\n  ASSIGN_STATE(state.cur, entropy->saved);\n  state.cinfo = cinfo;\n\n  /* Emit restart marker if needed */\n  if (cinfo->restart_interval) {\n    if (entropy->restarts_to_go == 0)\n      if (! emit_restart(&state, entropy->next_restart_num))\n\treturn FALSE;\n  }\n\n  /* Encode the MCU data blocks */\n  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {\n    ci = cinfo->MCU_membership[blkn];\n    compptr = cinfo->cur_comp_info[ci];\n    if (! encode_one_block(&state,\n\t\t\t   MCU_data[blkn][0], state.cur.last_dc_val[ci],\n\t\t\t   entropy->dc_derived_tbls[compptr->dc_tbl_no],\n\t\t\t   entropy->ac_derived_tbls[compptr->ac_tbl_no]))\n      return FALSE;\n    /* Update last_dc_val */\n    state.cur.last_dc_val[ci] = MCU_data[blkn][0][0];\n  }\n\n  /* Completed MCU, so update state */\n  cinfo->dest->next_output_byte = state.next_output_byte;\n  cinfo->dest->free_in_buffer = state.free_in_buffer;\n  ASSIGN_STATE(entropy->saved, state.cur);\n\n  /* Update restart-interval state too */\n  if (cinfo->restart_interval) {\n    if (entropy->restarts_to_go == 0) {\n      entropy->restarts_to_go = cinfo->restart_interval;\n      entropy->next_restart_num++;\n      entropy->next_restart_num &= 7;\n    }\n    entropy->restarts_to_go--;\n  }\n\n  return TRUE;\n}\n\n\n/*\n * Finish up at the end of a Huffman-compressed scan.\n */\n\nMETHODDEF void\nfinish_pass_huff (j_compress_ptr cinfo)\n{\n  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;\n  working_state state;\n\n  /* Load up working state ... flush_bits needs it */\n  state.next_output_byte = cinfo->dest->next_output_byte;\n  state.free_in_buffer = cinfo->dest->free_in_buffer;\n  ASSIGN_STATE(state.cur, entropy->saved);\n  state.cinfo = cinfo;\n\n  /* Flush out the last data */\n  if (! flush_bits(&state))\n    ERREXIT(cinfo, JERR_CANT_SUSPEND);\n\n  /* Update state */\n  cinfo->dest->next_output_byte = state.next_output_byte;\n  cinfo->dest->free_in_buffer = state.free_in_buffer;\n  ASSIGN_STATE(entropy->saved, state.cur);\n}\n\n\n/*\n * Huffman coding optimization.\n *\n * This actually is optimization, in the sense that we find the best possible\n * Huffman table(s) for the given data.  We first scan the supplied data and\n * count the number of uses of each symbol that is to be Huffman-coded.\n * (This process must agree with the code above.)  Then we build an\n * optimal Huffman coding tree for the observed counts.\n *\n * The JPEG standard requires Huffman codes to be no more than 16 bits long.\n * If some symbols have a very small but nonzero probability, the Huffman tree\n * must be adjusted to meet the code length restriction.  We currently use\n * the adjustment method suggested in the JPEG spec.  This method is *not*\n * optimal; it may not choose the best possible limited-length code.  But\n * since the symbols involved are infrequently used, it's not clear that\n * going to extra trouble is worthwhile.\n */\n\n#ifdef ENTROPY_OPT_SUPPORTED\n\n\n/* Process a single block's worth of coefficients */\n\nLOCAL void\nhtest_one_block (JCOEFPTR block, int last_dc_val,\n\t\t long dc_counts[], long ac_counts[])\n{\n  register int temp;\n  register int nbits;\n  register int k, r;\n  \n  /* Encode the DC coefficient difference per section F.1.2.1 */\n  \n  temp = block[0] - last_dc_val;\n  if (temp < 0)\n    temp = -temp;\n  \n  /* Find the number of bits needed for the magnitude of the coefficient */\n  nbits = 0;\n  while (temp) {\n    nbits++;\n    temp >>= 1;\n  }\n\n  /* Count the Huffman symbol for the number of bits */\n  dc_counts[nbits]++;\n  \n  /* Encode the AC coefficients per section F.1.2.2 */\n  \n  r = 0;\t\t\t/* r = run length of zeros */\n  \n  for (k = 1; k < DCTSIZE2; k++) {\n    if ((temp = block[jpeg_natural_order[k]]) == 0) {\n      r++;\n    } else {\n      /* if run length > 15, must emit special run-length-16 codes (0xF0) */\n      while (r > 15) {\n\tac_counts[0xF0]++;\n\tr -= 16;\n      }\n      \n      /* Find the number of bits needed for the magnitude of the coefficient */\n      if (temp < 0)\n\ttemp = -temp;\n      \n      /* Find the number of bits needed for the magnitude of the coefficient */\n      nbits = 1;\t\t/* there must be at least one 1 bit */\n      while ((temp >>= 1))\n\tnbits++;\n      \n      /* Count Huffman symbol for run length / number of bits */\n      ac_counts[(r << 4) + nbits]++;\n      \n      r = 0;\n    }\n  }\n\n  /* If the last coef(s) were zero, emit an end-of-block code */\n  if (r > 0)\n    ac_counts[0]++;\n}\n\n\n/*\n * Trial-encode one MCU's worth of Huffman-compressed coefficients.\n * No data is actually output, so no suspension return is possible.\n */\n\nMETHODDEF boolean\nencode_mcu_gather (j_compress_ptr cinfo, JBLOCKROW *MCU_data)\n{\n  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;\n  int blkn, ci;\n  jpeg_component_info * compptr;\n\n  /* Take care of restart intervals if needed */\n  if (cinfo->restart_interval) {\n    if (entropy->restarts_to_go == 0) {\n      /* Re-initialize DC predictions to 0 */\n      for (ci = 0; ci < cinfo->comps_in_scan; ci++)\n\tentropy->saved.last_dc_val[ci] = 0;\n      /* Update restart state */\n      entropy->restarts_to_go = cinfo->restart_interval;\n    }\n    entropy->restarts_to_go--;\n  }\n\n  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {\n    ci = cinfo->MCU_membership[blkn];\n    compptr = cinfo->cur_comp_info[ci];\n    htest_one_block(MCU_data[blkn][0], entropy->saved.last_dc_val[ci],\n\t\t    entropy->dc_count_ptrs[compptr->dc_tbl_no],\n\t\t    entropy->ac_count_ptrs[compptr->ac_tbl_no]);\n    entropy->saved.last_dc_val[ci] = MCU_data[blkn][0][0];\n  }\n\n  return TRUE;\n}\n\n\n/*\n * Generate the optimal coding for the given counts, fill htbl.\n * Note this is also used by jcphuff.c.\n */\n\nGLOBAL void\njpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])\n{\n#define MAX_CLEN 32\t\t/* assumed maximum initial code length */\n  UINT8 bits[MAX_CLEN+1];\t/* bits[k] = # of symbols with code length k */\n  int codesize[257];\t\t/* codesize[k] = code length of symbol k */\n  int others[257];\t\t/* next symbol in current branch of tree */\n  int c1, c2;\n  int p, i, j;\n  long v;\n\n  /* This algorithm is explained in section K.2 of the JPEG standard */\n\n  MEMZERO(bits, SIZEOF(bits));\n  MEMZERO(codesize, SIZEOF(codesize));\n  for (i = 0; i < 257; i++)\n    others[i] = -1;\t\t/* init links to empty */\n  \n  freq[256] = 1;\t\t/* make sure there is a nonzero count */\n  /* Including the pseudo-symbol 256 in the Huffman procedure guarantees\n   * that no real symbol is given code-value of all ones, because 256\n   * will be placed in the largest codeword category.\n   */\n\n  /* Huffman's basic algorithm to assign optimal code lengths to symbols */\n\n  for (;;) {\n    /* Find the smallest nonzero frequency, set c1 = its symbol */\n    /* In case of ties, take the larger symbol number */\n    c1 = -1;\n    v = 1000000000L;\n    for (i = 0; i <= 256; i++) {\n      if (freq[i] && freq[i] <= v) {\n\tv = freq[i];\n\tc1 = i;\n      }\n    }\n\n    /* Find the next smallest nonzero frequency, set c2 = its symbol */\n    /* In case of ties, take the larger symbol number */\n    c2 = -1;\n    v = 1000000000L;\n    for (i = 0; i <= 256; i++) {\n      if (freq[i] && freq[i] <= v && i != c1) {\n\tv = freq[i];\n\tc2 = i;\n      }\n    }\n\n    /* Done if we've merged everything into one frequency */\n    if (c2 < 0)\n      break;\n    \n    /* Else merge the two counts/trees */\n    freq[c1] += freq[c2];\n    freq[c2] = 0;\n\n    /* Increment the codesize of everything in c1's tree branch */\n    codesize[c1]++;\n    while (others[c1] >= 0) {\n      c1 = others[c1];\n      codesize[c1]++;\n    }\n    \n    others[c1] = c2;\t\t/* chain c2 onto c1's tree branch */\n    \n    /* Increment the codesize of everything in c2's tree branch */\n    codesize[c2]++;\n    while (others[c2] >= 0) {\n      c2 = others[c2];\n      codesize[c2]++;\n    }\n  }\n\n  /* Now count the number of symbols of each code length */\n  for (i = 0; i <= 256; i++) {\n    if (codesize[i]) {\n      /* The JPEG standard seems to think that this can't happen, */\n      /* but I'm paranoid... */\n      if (codesize[i] > MAX_CLEN)\n\tERREXIT(cinfo, JERR_HUFF_CLEN_OVERFLOW);\n\n      bits[codesize[i]]++;\n    }\n  }\n\n  /* JPEG doesn't allow symbols with code lengths over 16 bits, so if the pure\n   * Huffman procedure assigned any such lengths, we must adjust the coding.\n   * Here is what the JPEG spec says about how this next bit works:\n   * Since symbols are paired for the longest Huffman code, the symbols are\n   * removed from this length category two at a time.  The prefix for the pair\n   * (which is one bit shorter) is allocated to one of the pair; then,\n   * skipping the BITS entry for that prefix length, a code word from the next\n   * shortest nonzero BITS entry is converted into a prefix for two code words\n   * one bit longer.\n   */\n  \n  for (i = MAX_CLEN; i > 16; i--) {\n    while (bits[i] > 0) {\n      j = i - 2;\t\t/* find length of new prefix to be used */\n      while (bits[j] == 0)\n\tj--;\n      \n      bits[i] -= 2;\t\t/* remove two symbols */\n      bits[i-1]++;\t\t/* one goes in this length */\n      bits[j+1] += 2;\t\t/* two new symbols in this length */\n      bits[j]--;\t\t/* symbol of this length is now a prefix */\n    }\n  }\n\n  /* Remove the count for the pseudo-symbol 256 from the largest codelength */\n  while (bits[i] == 0)\t\t/* find largest codelength still in use */\n    i--;\n  bits[i]--;\n  \n  /* Return final symbol counts (only for lengths 0..16) */\n  MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits));\n  \n  /* Return a list of the symbols sorted by code length */\n  /* It's not real clear to me why we don't need to consider the codelength\n   * changes made above, but the JPEG spec seems to think this works.\n   */\n  p = 0;\n  for (i = 1; i <= MAX_CLEN; i++) {\n    for (j = 0; j <= 255; j++) {\n      if (codesize[j] == i) {\n\thtbl->huffval[p] = (UINT8) j;\n\tp++;\n      }\n    }\n  }\n\n  /* Set sent_table FALSE so updated table will be written to JPEG file. */\n  htbl->sent_table = FALSE;\n}\n\n\n/*\n * Finish up a statistics-gathering pass and create the new Huffman tables.\n */\n\nMETHODDEF void\nfinish_pass_gather (j_compress_ptr cinfo)\n{\n  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;\n  int ci, dctbl, actbl;\n  jpeg_component_info * compptr;\n  JHUFF_TBL **htblptr;\n  boolean did_dc[NUM_HUFF_TBLS];\n  boolean did_ac[NUM_HUFF_TBLS];\n\n  /* It's important not to apply jpeg_gen_optimal_table more than once\n   * per table, because it clobbers the input frequency counts!\n   */\n  MEMZERO(did_dc, SIZEOF(did_dc));\n  MEMZERO(did_ac, SIZEOF(did_ac));\n\n  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n    compptr = cinfo->cur_comp_info[ci];\n    dctbl = compptr->dc_tbl_no;\n    actbl = compptr->ac_tbl_no;\n    if (! did_dc[dctbl]) {\n      htblptr = & cinfo->dc_huff_tbl_ptrs[dctbl];\n      if (*htblptr == NULL)\n\t*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);\n      jpeg_gen_optimal_table(cinfo, *htblptr, entropy->dc_count_ptrs[dctbl]);\n      did_dc[dctbl] = TRUE;\n    }\n    if (! did_ac[actbl]) {\n      htblptr = & cinfo->ac_huff_tbl_ptrs[actbl];\n      if (*htblptr == NULL)\n\t*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);\n      jpeg_gen_optimal_table(cinfo, *htblptr, entropy->ac_count_ptrs[actbl]);\n      did_ac[actbl] = TRUE;\n    }\n  }\n}\n\n\n#endif /* ENTROPY_OPT_SUPPORTED */\n\n\n/*\n * Module initialization routine for Huffman entropy encoding.\n */\n\nGLOBAL void\njinit_huff_encoder (j_compress_ptr cinfo)\n{\n  huff_entropy_ptr entropy;\n  int i;\n\n  entropy = (huff_entropy_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(huff_entropy_encoder));\n  cinfo->entropy = (struct jpeg_entropy_encoder *) entropy;\n  entropy->pub.start_pass = start_pass_huff;\n\n  /* Mark tables unallocated */\n  for (i = 0; i < NUM_HUFF_TBLS; i++) {\n    entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL;\n#ifdef ENTROPY_OPT_SUPPORTED\n    entropy->dc_count_ptrs[i] = entropy->ac_count_ptrs[i] = NULL;\n#endif\n  }\n}\n"
  },
  {
    "path": "code/jpeg-6/jchuff.h",
    "content": "/*\n * jchuff.h\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains declarations for Huffman entropy encoding routines\n * that are shared between the sequential encoder (jchuff.c) and the\n * progressive encoder (jcphuff.c).  No other modules need to see these.\n */\n\n/* Derived data constructed for each Huffman table */\n\ntypedef struct {\n  unsigned int ehufco[256];\t/* code for each symbol */\n  char ehufsi[256];\t\t/* length of code for each symbol */\n  /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */\n} c_derived_tbl;\n\n/* Short forms of external names for systems with brain-damaged linkers. */\n\n#ifdef NEED_SHORT_EXTERNAL_NAMES\n#define jpeg_make_c_derived_tbl\tjMkCDerived\n#define jpeg_gen_optimal_table\tjGenOptTbl\n#endif /* NEED_SHORT_EXTERNAL_NAMES */\n\n/* Expand a Huffman table definition into the derived format */\nEXTERN void jpeg_make_c_derived_tbl JPP((j_compress_ptr cinfo,\n\t\t\t\tJHUFF_TBL * htbl, c_derived_tbl ** pdtbl));\n\n/* Generate an optimal table definition given the specified counts */\nEXTERN void jpeg_gen_optimal_table JPP((j_compress_ptr cinfo,\n\t\t\t\t\tJHUFF_TBL * htbl, long freq[]));\n"
  },
  {
    "path": "code/jpeg-6/jcinit.c",
    "content": "/*\n * jcinit.c\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains initialization logic for the JPEG compressor.\n * This routine is in charge of selecting the modules to be executed and\n * making an initialization call to each one.\n *\n * Logically, this code belongs in jcmaster.c.  It's split out because\n * linking this routine implies linking the entire compression library.\n * For a transcoding-only application, we want to be able to use jcmaster.c\n * without linking in the whole library.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/*\n * Master selection of compression modules.\n * This is done once at the start of processing an image.  We determine\n * which modules will be used and give them appropriate initialization calls.\n */\n\nGLOBAL void\njinit_compress_master (j_compress_ptr cinfo)\n{\n  /* Initialize master control (includes parameter checking/processing) */\n  jinit_c_master_control(cinfo, FALSE /* full compression */);\n\n  /* Preprocessing */\n  if (! cinfo->raw_data_in) {\n    jinit_color_converter(cinfo);\n    jinit_downsampler(cinfo);\n    jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */);\n  }\n  /* Forward DCT */\n  jinit_forward_dct(cinfo);\n  /* Entropy encoding: either Huffman or arithmetic coding. */\n  if (cinfo->arith_code) {\n    ERREXIT(cinfo, JERR_ARITH_NOTIMPL);\n  } else {\n    if (cinfo->progressive_mode) {\n#ifdef C_PROGRESSIVE_SUPPORTED\n      jinit_phuff_encoder(cinfo);\n#else\n      ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif\n    } else\n      jinit_huff_encoder(cinfo);\n  }\n\n  /* Need a full-image coefficient buffer in any multi-pass mode. */\n  jinit_c_coef_controller(cinfo,\n\t\t\t  (cinfo->num_scans > 1 || cinfo->optimize_coding));\n  jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */);\n\n  jinit_marker_writer(cinfo);\n\n  /* We can now tell the memory manager to allocate virtual arrays. */\n  (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);\n\n  /* Write the datastream header (SOI) immediately.\n   * Frame and scan headers are postponed till later.\n   * This lets application insert special markers after the SOI.\n   */\n  (*cinfo->marker->write_file_header) (cinfo);\n}\n"
  },
  {
    "path": "code/jpeg-6/jcmainct.c",
    "content": "/*\n * jcmainct.c\n *\n * Copyright (C) 1994-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains the main buffer controller for compression.\n * The main buffer lies between the pre-processor and the JPEG\n * compressor proper; it holds downsampled data in the JPEG colorspace.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/* Note: currently, there is no operating mode in which a full-image buffer\n * is needed at this step.  If there were, that mode could not be used with\n * \"raw data\" input, since this module is bypassed in that case.  However,\n * we've left the code here for possible use in special applications.\n */\n#undef FULL_MAIN_BUFFER_SUPPORTED\n\n\n/* Private buffer controller object */\n\ntypedef struct {\n  struct jpeg_c_main_controller pub; /* public fields */\n\n  JDIMENSION cur_iMCU_row;\t/* number of current iMCU row */\n  JDIMENSION rowgroup_ctr;\t/* counts row groups received in iMCU row */\n  boolean suspended;\t\t/* remember if we suspended output */\n  J_BUF_MODE pass_mode;\t\t/* current operating mode */\n\n  /* If using just a strip buffer, this points to the entire set of buffers\n   * (we allocate one for each component).  In the full-image case, this\n   * points to the currently accessible strips of the virtual arrays.\n   */\n  JSAMPARRAY buffer[MAX_COMPONENTS];\n\n#ifdef FULL_MAIN_BUFFER_SUPPORTED\n  /* If using full-image storage, this array holds pointers to virtual-array\n   * control blocks for each component.  Unused if not full-image storage.\n   */\n  jvirt_sarray_ptr whole_image[MAX_COMPONENTS];\n#endif\n} my_main_controller;\n\ntypedef my_main_controller * my_main_ptr;\n\n\n/* Forward declarations */\nMETHODDEF void process_data_simple_main\n\tJPP((j_compress_ptr cinfo, JSAMPARRAY input_buf,\n\t     JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail));\n#ifdef FULL_MAIN_BUFFER_SUPPORTED\nMETHODDEF void process_data_buffer_main\n\tJPP((j_compress_ptr cinfo, JSAMPARRAY input_buf,\n\t     JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail));\n#endif\n\n\n/*\n * Initialize for a processing pass.\n */\n\nMETHODDEF void\nstart_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode)\n{\n  // bk001204 - don't use main...\n  my_main_ptr jmain = (my_main_ptr) cinfo->main;\n\n  /* Do nothing in raw-data mode. */\n  if (cinfo->raw_data_in)\n    return;\n\n  jmain->cur_iMCU_row = 0;\t/* initialize counters */\n  jmain->rowgroup_ctr = 0;\n  jmain->suspended = FALSE;\n  jmain->pass_mode = pass_mode;\t/* save mode for use by process_data */\n\n  switch (pass_mode) {\n  case JBUF_PASS_THRU:\n#ifdef FULL_MAIN_BUFFER_SUPPORTED\n    if (jmain->whole_image[0] != NULL)\n      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n#endif\n    jmain->pub.process_data = process_data_simple_main;\n    break;\n#ifdef FULL_MAIN_BUFFER_SUPPORTED\n  case JBUF_SAVE_SOURCE:\n  case JBUF_CRANK_DEST:\n  case JBUF_SAVE_AND_PASS:\n    if (jmain->whole_image[0] == NULL)\n      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n    jmain->pub.process_data = process_data_buffer_main;\n    break;\n#endif\n  default:\n    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n    break;\n  }\n}\n\n\n/*\n * Process some data.\n * This routine handles the simple pass-through mode,\n * where we have only a strip buffer.\n */\n\nMETHODDEF void\nprocess_data_simple_main (j_compress_ptr cinfo,\n\t\t\t  JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,\n\t\t\t  JDIMENSION in_rows_avail)\n{\n  // bk001204 - don't use main\n  my_main_ptr jmain = (my_main_ptr) cinfo->main;\n\n  while (jmain->cur_iMCU_row < cinfo->total_iMCU_rows) {\n    /* Read input data if we haven't filled the main buffer yet */\n    if (jmain->rowgroup_ctr < DCTSIZE)\n      (*cinfo->prep->pre_process_data) (cinfo,\n\t\t\t\t\tinput_buf, in_row_ctr, in_rows_avail,\n\t\t\t\t\tjmain->buffer, &jmain->rowgroup_ctr,\n\t\t\t\t\t(JDIMENSION) DCTSIZE);\n\n    /* If we don't have a full iMCU row buffered, return to application for\n     * more data.  Note that preprocessor will always pad to fill the iMCU row\n     * at the bottom of the image.\n     */\n    if (jmain->rowgroup_ctr != DCTSIZE)\n      return;\n\n    /* Send the completed row to the compressor */\n    if (! (*cinfo->coef->compress_data) (cinfo, jmain->buffer)) {\n      /* If compressor did not consume the whole row, then we must need to\n       * suspend processing and return to the application.  In this situation\n       * we pretend we didn't yet consume the last input row; otherwise, if\n       * it happened to be the last row of the image, the application would\n       * think we were done.\n       */\n      if (! jmain->suspended) {\n\t(*in_row_ctr)--;\n\tjmain->suspended = TRUE;\n      }\n      return;\n    }\n    /* We did finish the row.  Undo our little suspension hack if a previous\n     * call suspended; then mark the main buffer empty.\n     */\n    if (jmain->suspended) {\n      (*in_row_ctr)++;\n      jmain->suspended = FALSE;\n    }\n    jmain->rowgroup_ctr = 0;\n    jmain->cur_iMCU_row++;\n  }\n}\n\n\n#ifdef FULL_MAIN_BUFFER_SUPPORTED\n\n/*\n * Process some data.\n * This routine handles all of the modes that use a full-size buffer.\n */\n\nMETHODDEF void\nprocess_data_buffer_main (j_compress_ptr cinfo,\n\t\t\t  JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,\n\t\t\t  JDIMENSION in_rows_avail)\n{\n  my_main_ptr main = (my_main_ptr) cinfo->main;\n  int ci;\n  jpeg_component_info *compptr;\n  boolean writing = (main->pass_mode != JBUF_CRANK_DEST);\n\n  while (main->cur_iMCU_row < cinfo->total_iMCU_rows) {\n    /* Realign the virtual buffers if at the start of an iMCU row. */\n    if (main->rowgroup_ctr == 0) {\n      for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n\t   ci++, compptr++) {\n\tmain->buffer[ci] = (*cinfo->mem->access_virt_sarray)\n\t  ((j_common_ptr) cinfo, main->whole_image[ci],\n\t   main->cur_iMCU_row * (compptr->v_samp_factor * DCTSIZE),\n\t   (JDIMENSION) (compptr->v_samp_factor * DCTSIZE), writing);\n      }\n      /* In a read pass, pretend we just read some source data. */\n      if (! writing) {\n\t*in_row_ctr += cinfo->max_v_samp_factor * DCTSIZE;\n\tmain->rowgroup_ctr = DCTSIZE;\n      }\n    }\n\n    /* If a write pass, read input data until the current iMCU row is full. */\n    /* Note: preprocessor will pad if necessary to fill the last iMCU row. */\n    if (writing) {\n      (*cinfo->prep->pre_process_data) (cinfo,\n\t\t\t\t\tinput_buf, in_row_ctr, in_rows_avail,\n\t\t\t\t\tmain->buffer, &main->rowgroup_ctr,\n\t\t\t\t\t(JDIMENSION) DCTSIZE);\n      /* Return to application if we need more data to fill the iMCU row. */\n      if (main->rowgroup_ctr < DCTSIZE)\n\treturn;\n    }\n\n    /* Emit data, unless this is a sink-only pass. */\n    if (main->pass_mode != JBUF_SAVE_SOURCE) {\n      if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) {\n\t/* If compressor did not consume the whole row, then we must need to\n\t * suspend processing and return to the application.  In this situation\n\t * we pretend we didn't yet consume the last input row; otherwise, if\n\t * it happened to be the last row of the image, the application would\n\t * think we were done.\n\t */\n\tif (! main->suspended) {\n\t  (*in_row_ctr)--;\n\t  main->suspended = TRUE;\n\t}\n\treturn;\n      }\n      /* We did finish the row.  Undo our little suspension hack if a previous\n       * call suspended; then mark the main buffer empty.\n       */\n      if (main->suspended) {\n\t(*in_row_ctr)++;\n\tmain->suspended = FALSE;\n      }\n    }\n\n    /* If get here, we are done with this iMCU row.  Mark buffer empty. */\n    main->rowgroup_ctr = 0;\n    main->cur_iMCU_row++;\n  }\n}\n\n#endif /* FULL_MAIN_BUFFER_SUPPORTED */\n\n\n/*\n * Initialize main buffer controller.\n */\n\nGLOBAL void\njinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer)\n{\n  // bk001204 - don't use main\n  my_main_ptr jmain;\n  int ci;\n  jpeg_component_info *compptr;\n\n  jmain = (my_main_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_main_controller));\n  cinfo->main = (struct jpeg_c_main_controller *) jmain;\n  jmain->pub.start_pass = start_pass_main;\n\n  /* We don't need to create a buffer in raw-data mode. */\n  if (cinfo->raw_data_in)\n    return;\n\n  /* Create the buffer.  It holds downsampled data, so each component\n   * may be of a different size.\n   */\n  if (need_full_buffer) {\n#ifdef FULL_MAIN_BUFFER_SUPPORTED\n    /* Allocate a full-image virtual array for each component */\n    /* Note we pad the bottom to a multiple of the iMCU height */\n    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n\t ci++, compptr++) {\n      jmain->whole_image[ci] = (*cinfo->mem->request_virt_sarray)\n\t((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,\n\t compptr->width_in_blocks * DCTSIZE,\n\t (JDIMENSION) jround_up((long) compptr->height_in_blocks,\n\t\t\t\t(long) compptr->v_samp_factor) * DCTSIZE,\n\t (JDIMENSION) (compptr->v_samp_factor * DCTSIZE));\n    }\n#else\n    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n#endif\n  } else {\n#ifdef FULL_MAIN_BUFFER_SUPPORTED\n    jmain->whole_image[0] = NULL; /* flag for no virtual arrays */\n#endif\n    /* Allocate a strip buffer for each component */\n    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n\t ci++, compptr++) {\n      jmain->buffer[ci] = (*cinfo->mem->alloc_sarray)\n\t((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t compptr->width_in_blocks * DCTSIZE,\n\t (JDIMENSION) (compptr->v_samp_factor * DCTSIZE));\n    }\n  }\n}\n"
  },
  {
    "path": "code/jpeg-6/jcmarker.c",
    "content": "/*\n * jcmarker.c\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains routines to write JPEG datastream markers.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\ntypedef enum {\t\t\t/* JPEG marker codes */\n  M_SOF0  = 0xc0,\n  M_SOF1  = 0xc1,\n  M_SOF2  = 0xc2,\n  M_SOF3  = 0xc3,\n  \n  M_SOF5  = 0xc5,\n  M_SOF6  = 0xc6,\n  M_SOF7  = 0xc7,\n  \n  M_JPG   = 0xc8,\n  M_SOF9  = 0xc9,\n  M_SOF10 = 0xca,\n  M_SOF11 = 0xcb,\n  \n  M_SOF13 = 0xcd,\n  M_SOF14 = 0xce,\n  M_SOF15 = 0xcf,\n  \n  M_DHT   = 0xc4,\n  \n  M_DAC   = 0xcc,\n  \n  M_RST0  = 0xd0,\n  M_RST1  = 0xd1,\n  M_RST2  = 0xd2,\n  M_RST3  = 0xd3,\n  M_RST4  = 0xd4,\n  M_RST5  = 0xd5,\n  M_RST6  = 0xd6,\n  M_RST7  = 0xd7,\n  \n  M_SOI   = 0xd8,\n  M_EOI   = 0xd9,\n  M_SOS   = 0xda,\n  M_DQT   = 0xdb,\n  M_DNL   = 0xdc,\n  M_DRI   = 0xdd,\n  M_DHP   = 0xde,\n  M_EXP   = 0xdf,\n  \n  M_APP0  = 0xe0,\n  M_APP1  = 0xe1,\n  M_APP2  = 0xe2,\n  M_APP3  = 0xe3,\n  M_APP4  = 0xe4,\n  M_APP5  = 0xe5,\n  M_APP6  = 0xe6,\n  M_APP7  = 0xe7,\n  M_APP8  = 0xe8,\n  M_APP9  = 0xe9,\n  M_APP10 = 0xea,\n  M_APP11 = 0xeb,\n  M_APP12 = 0xec,\n  M_APP13 = 0xed,\n  M_APP14 = 0xee,\n  M_APP15 = 0xef,\n  \n  M_JPG0  = 0xf0,\n  M_JPG13 = 0xfd,\n  M_COM   = 0xfe,\n  \n  M_TEM   = 0x01,\n  \n  M_ERROR = 0x100\n} JPEG_MARKER;\n\n\n/*\n * Basic output routines.\n *\n * Note that we do not support suspension while writing a marker.\n * Therefore, an application using suspension must ensure that there is\n * enough buffer space for the initial markers (typ. 600-700 bytes) before\n * calling jpeg_start_compress, and enough space to write the trailing EOI\n * (a few bytes) before calling jpeg_finish_compress.  Multipass compression\n * modes are not supported at all with suspension, so those two are the only\n * points where markers will be written.\n */\n\nLOCAL void\nemit_byte (j_compress_ptr cinfo, int val)\n/* Emit a byte */\n{\n  struct jpeg_destination_mgr * dest = cinfo->dest;\n\n  *(dest->next_output_byte)++ = (JOCTET) val;\n  if (--dest->free_in_buffer == 0) {\n    if (! (*dest->empty_output_buffer) (cinfo))\n      ERREXIT(cinfo, JERR_CANT_SUSPEND);\n  }\n}\n\n\nLOCAL void\nemit_marker (j_compress_ptr cinfo, JPEG_MARKER mark)\n/* Emit a marker code */\n{\n  emit_byte(cinfo, 0xFF);\n  emit_byte(cinfo, (int) mark);\n}\n\n\nLOCAL void\nemit_2bytes (j_compress_ptr cinfo, int value)\n/* Emit a 2-byte integer; these are always MSB first in JPEG files */\n{\n  emit_byte(cinfo, (value >> 8) & 0xFF);\n  emit_byte(cinfo, value & 0xFF);\n}\n\n\n/*\n * Routines to write specific marker types.\n */\n\nLOCAL int\nemit_dqt (j_compress_ptr cinfo, int index)\n/* Emit a DQT marker */\n/* Returns the precision used (0 = 8bits, 1 = 16bits) for baseline checking */\n{\n  JQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[index];\n  int prec;\n  int i;\n\n  if (qtbl == NULL)\n    ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, index);\n\n  prec = 0;\n  for (i = 0; i < DCTSIZE2; i++) {\n    if (qtbl->quantval[i] > 255)\n      prec = 1;\n  }\n\n  if (! qtbl->sent_table) {\n    emit_marker(cinfo, M_DQT);\n\n    emit_2bytes(cinfo, prec ? DCTSIZE2*2 + 1 + 2 : DCTSIZE2 + 1 + 2);\n\n    emit_byte(cinfo, index + (prec<<4));\n\n    for (i = 0; i < DCTSIZE2; i++) {\n      if (prec)\n\temit_byte(cinfo, qtbl->quantval[i] >> 8);\n      emit_byte(cinfo, qtbl->quantval[i] & 0xFF);\n    }\n\n    qtbl->sent_table = TRUE;\n  }\n\n  return prec;\n}\n\n\nLOCAL void\nemit_dht (j_compress_ptr cinfo, int index, boolean is_ac)\n/* Emit a DHT marker */\n{\n  JHUFF_TBL * htbl;\n  int length, i;\n  \n  if (is_ac) {\n    htbl = cinfo->ac_huff_tbl_ptrs[index];\n    index += 0x10;\t\t/* output index has AC bit set */\n  } else {\n    htbl = cinfo->dc_huff_tbl_ptrs[index];\n  }\n\n  if (htbl == NULL)\n    ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index);\n  \n  if (! htbl->sent_table) {\n    emit_marker(cinfo, M_DHT);\n    \n    length = 0;\n    for (i = 1; i <= 16; i++)\n      length += htbl->bits[i];\n    \n    emit_2bytes(cinfo, length + 2 + 1 + 16);\n    emit_byte(cinfo, index);\n    \n    for (i = 1; i <= 16; i++)\n      emit_byte(cinfo, htbl->bits[i]);\n    \n    for (i = 0; i < length; i++)\n      emit_byte(cinfo, htbl->huffval[i]);\n    \n    htbl->sent_table = TRUE;\n  }\n}\n\n\nLOCAL void\nemit_dac (j_compress_ptr cinfo)\n/* Emit a DAC marker */\n/* Since the useful info is so small, we want to emit all the tables in */\n/* one DAC marker.  Therefore this routine does its own scan of the table. */\n{\n#ifdef C_ARITH_CODING_SUPPORTED\n  char dc_in_use[NUM_ARITH_TBLS];\n  char ac_in_use[NUM_ARITH_TBLS];\n  int length, i;\n  jpeg_component_info *compptr;\n  \n  for (i = 0; i < NUM_ARITH_TBLS; i++)\n    dc_in_use[i] = ac_in_use[i] = 0;\n  \n  for (i = 0; i < cinfo->comps_in_scan; i++) {\n    compptr = cinfo->cur_comp_info[i];\n    dc_in_use[compptr->dc_tbl_no] = 1;\n    ac_in_use[compptr->ac_tbl_no] = 1;\n  }\n  \n  length = 0;\n  for (i = 0; i < NUM_ARITH_TBLS; i++)\n    length += dc_in_use[i] + ac_in_use[i];\n  \n  emit_marker(cinfo, M_DAC);\n  \n  emit_2bytes(cinfo, length*2 + 2);\n  \n  for (i = 0; i < NUM_ARITH_TBLS; i++) {\n    if (dc_in_use[i]) {\n      emit_byte(cinfo, i);\n      emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4));\n    }\n    if (ac_in_use[i]) {\n      emit_byte(cinfo, i + 0x10);\n      emit_byte(cinfo, cinfo->arith_ac_K[i]);\n    }\n  }\n#endif /* C_ARITH_CODING_SUPPORTED */\n}\n\n\nLOCAL void\nemit_dri (j_compress_ptr cinfo)\n/* Emit a DRI marker */\n{\n  emit_marker(cinfo, M_DRI);\n  \n  emit_2bytes(cinfo, 4);\t/* fixed length */\n\n  emit_2bytes(cinfo, (int) cinfo->restart_interval);\n}\n\n\nLOCAL void\nemit_sof (j_compress_ptr cinfo, JPEG_MARKER code)\n/* Emit a SOF marker */\n{\n  int ci;\n  jpeg_component_info *compptr;\n  \n  emit_marker(cinfo, code);\n  \n  emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */\n\n  /* Make sure image isn't bigger than SOF field can handle */\n  if ((long) cinfo->image_height > 65535L ||\n      (long) cinfo->image_width > 65535L)\n    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535);\n\n  emit_byte(cinfo, cinfo->data_precision);\n  emit_2bytes(cinfo, (int) cinfo->image_height);\n  emit_2bytes(cinfo, (int) cinfo->image_width);\n\n  emit_byte(cinfo, cinfo->num_components);\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    emit_byte(cinfo, compptr->component_id);\n    emit_byte(cinfo, (compptr->h_samp_factor << 4) + compptr->v_samp_factor);\n    emit_byte(cinfo, compptr->quant_tbl_no);\n  }\n}\n\n\nLOCAL void\nemit_sos (j_compress_ptr cinfo)\n/* Emit a SOS marker */\n{\n  int i, td, ta;\n  jpeg_component_info *compptr;\n  \n  emit_marker(cinfo, M_SOS);\n  \n  emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */\n  \n  emit_byte(cinfo, cinfo->comps_in_scan);\n  \n  for (i = 0; i < cinfo->comps_in_scan; i++) {\n    compptr = cinfo->cur_comp_info[i];\n    emit_byte(cinfo, compptr->component_id);\n    td = compptr->dc_tbl_no;\n    ta = compptr->ac_tbl_no;\n    if (cinfo->progressive_mode) {\n      /* Progressive mode: only DC or only AC tables are used in one scan;\n       * furthermore, Huffman coding of DC refinement uses no table at all.\n       * We emit 0 for unused field(s); this is recommended by the P&M text\n       * but does not seem to be specified in the standard.\n       */\n      if (cinfo->Ss == 0) {\n\tta = 0;\t\t\t/* DC scan */\n\tif (cinfo->Ah != 0 && !cinfo->arith_code)\n\t  td = 0;\t\t/* no DC table either */\n      } else {\n\ttd = 0;\t\t\t/* AC scan */\n      }\n    }\n    emit_byte(cinfo, (td << 4) + ta);\n  }\n\n  emit_byte(cinfo, cinfo->Ss);\n  emit_byte(cinfo, cinfo->Se);\n  emit_byte(cinfo, (cinfo->Ah << 4) + cinfo->Al);\n}\n\n\nLOCAL void\nemit_jfif_app0 (j_compress_ptr cinfo)\n/* Emit a JFIF-compliant APP0 marker */\n{\n  /*\n   * Length of APP0 block\t(2 bytes)\n   * Block ID\t\t\t(4 bytes - ASCII \"JFIF\")\n   * Zero byte\t\t\t(1 byte to terminate the ID string)\n   * Version Major, Minor\t(2 bytes - 0x01, 0x01)\n   * Units\t\t\t(1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm)\n   * Xdpu\t\t\t(2 bytes - dots per unit horizontal)\n   * Ydpu\t\t\t(2 bytes - dots per unit vertical)\n   * Thumbnail X size\t\t(1 byte)\n   * Thumbnail Y size\t\t(1 byte)\n   */\n  \n  emit_marker(cinfo, M_APP0);\n  \n  emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */\n\n  emit_byte(cinfo, 0x4A);\t/* Identifier: ASCII \"JFIF\" */\n  emit_byte(cinfo, 0x46);\n  emit_byte(cinfo, 0x49);\n  emit_byte(cinfo, 0x46);\n  emit_byte(cinfo, 0);\n  /* We currently emit version code 1.01 since we use no 1.02 features.\n   * This may avoid complaints from some older decoders.\n   */\n  emit_byte(cinfo, 1);\t\t/* Major version */\n  emit_byte(cinfo, 1);\t\t/* Minor version */\n  emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */\n  emit_2bytes(cinfo, (int) cinfo->X_density);\n  emit_2bytes(cinfo, (int) cinfo->Y_density);\n  emit_byte(cinfo, 0);\t\t/* No thumbnail image */\n  emit_byte(cinfo, 0);\n}\n\n\nLOCAL void\nemit_adobe_app14 (j_compress_ptr cinfo)\n/* Emit an Adobe APP14 marker */\n{\n  /*\n   * Length of APP14 block\t(2 bytes)\n   * Block ID\t\t\t(5 bytes - ASCII \"Adobe\")\n   * Version Number\t\t(2 bytes - currently 100)\n   * Flags0\t\t\t(2 bytes - currently 0)\n   * Flags1\t\t\t(2 bytes - currently 0)\n   * Color transform\t\t(1 byte)\n   *\n   * Although Adobe TN 5116 mentions Version = 101, all the Adobe files\n   * now in circulation seem to use Version = 100, so that's what we write.\n   *\n   * We write the color transform byte as 1 if the JPEG color space is\n   * YCbCr, 2 if it's YCCK, 0 otherwise.  Adobe's definition has to do with\n   * whether the encoder performed a transformation, which is pretty useless.\n   */\n  \n  emit_marker(cinfo, M_APP14);\n  \n  emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */\n\n  emit_byte(cinfo, 0x41);\t/* Identifier: ASCII \"Adobe\" */\n  emit_byte(cinfo, 0x64);\n  emit_byte(cinfo, 0x6F);\n  emit_byte(cinfo, 0x62);\n  emit_byte(cinfo, 0x65);\n  emit_2bytes(cinfo, 100);\t/* Version */\n  emit_2bytes(cinfo, 0);\t/* Flags0 */\n  emit_2bytes(cinfo, 0);\t/* Flags1 */\n  switch (cinfo->jpeg_color_space) {\n  case JCS_YCbCr:\n    emit_byte(cinfo, 1);\t/* Color transform = 1 */\n    break;\n  case JCS_YCCK:\n    emit_byte(cinfo, 2);\t/* Color transform = 2 */\n    break;\n  default:\n    emit_byte(cinfo, 0);\t/* Color transform = 0 */\n    break;\n  }\n}\n\n\n/*\n * This routine is exported for possible use by applications.\n * The intended use is to emit COM or APPn markers after calling\n * jpeg_start_compress() and before the first jpeg_write_scanlines() call\n * (hence, after write_file_header but before write_frame_header).\n * Other uses are not guaranteed to produce desirable results.\n */\n\nMETHODDEF void\nwrite_any_marker (j_compress_ptr cinfo, int marker,\n\t\t  const JOCTET *dataptr, unsigned int datalen)\n/* Emit an arbitrary marker with parameters */\n{\n  if (datalen <= (unsigned int) 65533) { /* safety check */\n    emit_marker(cinfo, (JPEG_MARKER) marker);\n  \n    emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */\n\n    while (datalen--) {\n      emit_byte(cinfo, *dataptr);\n      dataptr++;\n    }\n  }\n}\n\n\n/*\n * Write datastream header.\n * This consists of an SOI and optional APPn markers.\n * We recommend use of the JFIF marker, but not the Adobe marker,\n * when using YCbCr or grayscale data.  The JFIF marker should NOT\n * be used for any other JPEG colorspace.  The Adobe marker is helpful\n * to distinguish RGB, CMYK, and YCCK colorspaces.\n * Note that an application can write additional header markers after\n * jpeg_start_compress returns.\n */\n\nMETHODDEF void\nwrite_file_header (j_compress_ptr cinfo)\n{\n  emit_marker(cinfo, M_SOI);\t/* first the SOI */\n\n  if (cinfo->write_JFIF_header)\t/* next an optional JFIF APP0 */\n    emit_jfif_app0(cinfo);\n  if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */\n    emit_adobe_app14(cinfo);\n}\n\n\n/*\n * Write frame header.\n * This consists of DQT and SOFn markers.\n * Note that we do not emit the SOF until we have emitted the DQT(s).\n * This avoids compatibility problems with incorrect implementations that\n * try to error-check the quant table numbers as soon as they see the SOF.\n */\n\nMETHODDEF void\nwrite_frame_header (j_compress_ptr cinfo)\n{\n  int ci, prec;\n  boolean is_baseline;\n  jpeg_component_info *compptr;\n  \n  /* Emit DQT for each quantization table.\n   * Note that emit_dqt() suppresses any duplicate tables.\n   */\n  prec = 0;\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    prec += emit_dqt(cinfo, compptr->quant_tbl_no);\n  }\n  /* now prec is nonzero iff there are any 16-bit quant tables. */\n\n  /* Check for a non-baseline specification.\n   * Note we assume that Huffman table numbers won't be changed later.\n   */\n  if (cinfo->arith_code || cinfo->progressive_mode ||\n      cinfo->data_precision != 8) {\n    is_baseline = FALSE;\n  } else {\n    is_baseline = TRUE;\n    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n\t ci++, compptr++) {\n      if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1)\n\tis_baseline = FALSE;\n    }\n    if (prec && is_baseline) {\n      is_baseline = FALSE;\n      /* If it's baseline except for quantizer size, warn the user */\n      TRACEMS(cinfo, 0, JTRC_16BIT_TABLES);\n    }\n  }\n\n  /* Emit the proper SOF marker */\n  if (cinfo->arith_code) {\n    emit_sof(cinfo, M_SOF9);\t/* SOF code for arithmetic coding */\n  } else {\n    if (cinfo->progressive_mode)\n      emit_sof(cinfo, M_SOF2);\t/* SOF code for progressive Huffman */\n    else if (is_baseline)\n      emit_sof(cinfo, M_SOF0);\t/* SOF code for baseline implementation */\n    else\n      emit_sof(cinfo, M_SOF1);\t/* SOF code for non-baseline Huffman file */\n  }\n}\n\n\n/*\n * Write scan header.\n * This consists of DHT or DAC markers, optional DRI, and SOS.\n * Compressed data will be written following the SOS.\n */\n\nMETHODDEF void\nwrite_scan_header (j_compress_ptr cinfo)\n{\n  int i;\n  jpeg_component_info *compptr;\n\n  if (cinfo->arith_code) {\n    /* Emit arith conditioning info.  We may have some duplication\n     * if the file has multiple scans, but it's so small it's hardly\n     * worth worrying about.\n     */\n    emit_dac(cinfo);\n  } else {\n    /* Emit Huffman tables.\n     * Note that emit_dht() suppresses any duplicate tables.\n     */\n    for (i = 0; i < cinfo->comps_in_scan; i++) {\n      compptr = cinfo->cur_comp_info[i];\n      if (cinfo->progressive_mode) {\n\t/* Progressive mode: only DC or only AC tables are used in one scan */\n\tif (cinfo->Ss == 0) {\n\t  if (cinfo->Ah == 0)\t/* DC needs no table for refinement scan */\n\t    emit_dht(cinfo, compptr->dc_tbl_no, FALSE);\n\t} else {\n\t  emit_dht(cinfo, compptr->ac_tbl_no, TRUE);\n\t}\n      } else {\n\t/* Sequential mode: need both DC and AC tables */\n\temit_dht(cinfo, compptr->dc_tbl_no, FALSE);\n\temit_dht(cinfo, compptr->ac_tbl_no, TRUE);\n      }\n    }\n  }\n\n  /* Emit DRI if required --- note that DRI value could change for each scan.\n   * If it doesn't, a tiny amount of space is wasted in multiple-scan files.\n   * We assume DRI will never be nonzero for one scan and zero for a later one.\n   */\n  if (cinfo->restart_interval)\n    emit_dri(cinfo);\n\n  emit_sos(cinfo);\n}\n\n\n/*\n * Write datastream trailer.\n */\n\nMETHODDEF void\nwrite_file_trailer (j_compress_ptr cinfo)\n{\n  emit_marker(cinfo, M_EOI);\n}\n\n\n/*\n * Write an abbreviated table-specification datastream.\n * This consists of SOI, DQT and DHT tables, and EOI.\n * Any table that is defined and not marked sent_table = TRUE will be\n * emitted.  Note that all tables will be marked sent_table = TRUE at exit.\n */\n\nMETHODDEF void\nwrite_tables_only (j_compress_ptr cinfo)\n{\n  int i;\n\n  emit_marker(cinfo, M_SOI);\n\n  for (i = 0; i < NUM_QUANT_TBLS; i++) {\n    if (cinfo->quant_tbl_ptrs[i] != NULL)\n      (void) emit_dqt(cinfo, i);\n  }\n\n  if (! cinfo->arith_code) {\n    for (i = 0; i < NUM_HUFF_TBLS; i++) {\n      if (cinfo->dc_huff_tbl_ptrs[i] != NULL)\n\temit_dht(cinfo, i, FALSE);\n      if (cinfo->ac_huff_tbl_ptrs[i] != NULL)\n\temit_dht(cinfo, i, TRUE);\n    }\n  }\n\n  emit_marker(cinfo, M_EOI);\n}\n\n\n/*\n * Initialize the marker writer module.\n */\n\nGLOBAL void\njinit_marker_writer (j_compress_ptr cinfo)\n{\n  /* Create the subobject */\n  cinfo->marker = (struct jpeg_marker_writer *)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(struct jpeg_marker_writer));\n  /* Initialize method pointers */\n  cinfo->marker->write_any_marker = write_any_marker;\n  cinfo->marker->write_file_header = write_file_header;\n  cinfo->marker->write_frame_header = write_frame_header;\n  cinfo->marker->write_scan_header = write_scan_header;\n  cinfo->marker->write_file_trailer = write_file_trailer;\n  cinfo->marker->write_tables_only = write_tables_only;\n}\n"
  },
  {
    "path": "code/jpeg-6/jcmaster.c",
    "content": "/*\n * jcmaster.c\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains master control logic for the JPEG compressor.\n * These routines are concerned with parameter validation, initial setup,\n * and inter-pass control (determining the number of passes and the work \n * to be done in each pass).\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/* Private state */\n\ntypedef enum {\n\tmain_pass,\t\t/* input data, also do first output step */\n\thuff_opt_pass,\t\t/* Huffman code optimization pass */\n\toutput_pass\t\t/* data output pass */\n} c_pass_type;\n\ntypedef struct {\n  struct jpeg_comp_master pub;\t/* public fields */\n\n  c_pass_type pass_type;\t/* the type of the current pass */\n\n  int pass_number;\t\t/* # of passes completed */\n  int total_passes;\t\t/* total # of passes needed */\n\n  int scan_number;\t\t/* current index in scan_info[] */\n} my_comp_master;\n\ntypedef my_comp_master * my_master_ptr;\n\n\n/*\n * Support routines that do various essential calculations.\n */\n\nLOCAL void\ninitial_setup (j_compress_ptr cinfo)\n/* Do computations that are needed before master selection phase */\n{\n  int ci;\n  jpeg_component_info *compptr;\n  long samplesperrow;\n  JDIMENSION jd_samplesperrow;\n\n  /* Sanity check on image dimensions */\n  if (cinfo->image_height <= 0 || cinfo->image_width <= 0\n      || cinfo->num_components <= 0 || cinfo->input_components <= 0)\n    ERREXIT(cinfo, JERR_EMPTY_IMAGE);\n\n  /* Make sure image isn't bigger than I can handle */\n  if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION ||\n      (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION)\n    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);\n\n  /* Width of an input scanline must be representable as JDIMENSION. */\n  samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components;\n  jd_samplesperrow = (JDIMENSION) samplesperrow;\n  if ((long) jd_samplesperrow != samplesperrow)\n    ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);\n\n  /* For now, precision must match compiled-in value... */\n  if (cinfo->data_precision != BITS_IN_JSAMPLE)\n    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);\n\n  /* Check that number of components won't exceed internal array sizes */\n  if (cinfo->num_components > MAX_COMPONENTS)\n    ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,\n\t     MAX_COMPONENTS);\n\n  /* Compute maximum sampling factors; check factor validity */\n  cinfo->max_h_samp_factor = 1;\n  cinfo->max_v_samp_factor = 1;\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR ||\n\tcompptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR)\n      ERREXIT(cinfo, JERR_BAD_SAMPLING);\n    cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,\n\t\t\t\t   compptr->h_samp_factor);\n    cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor,\n\t\t\t\t   compptr->v_samp_factor);\n  }\n\n  /* Compute dimensions of components */\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    /* Fill in the correct component_index value; don't rely on application */\n    compptr->component_index = ci;\n    /* For compression, we never do DCT scaling. */\n    compptr->DCT_scaled_size = DCTSIZE;\n    /* Size in DCT blocks */\n    compptr->width_in_blocks = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,\n\t\t    (long) (cinfo->max_h_samp_factor * DCTSIZE));\n    compptr->height_in_blocks = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,\n\t\t    (long) (cinfo->max_v_samp_factor * DCTSIZE));\n    /* Size in samples */\n    compptr->downsampled_width = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,\n\t\t    (long) cinfo->max_h_samp_factor);\n    compptr->downsampled_height = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,\n\t\t    (long) cinfo->max_v_samp_factor);\n    /* Mark component needed (this flag isn't actually used for compression) */\n    compptr->component_needed = TRUE;\n  }\n\n  /* Compute number of fully interleaved MCU rows (number of times that\n   * main controller will call coefficient controller).\n   */\n  cinfo->total_iMCU_rows = (JDIMENSION)\n    jdiv_round_up((long) cinfo->image_height,\n\t\t  (long) (cinfo->max_v_samp_factor*DCTSIZE));\n}\n\n\n#ifdef C_MULTISCAN_FILES_SUPPORTED\n\nLOCAL void\nvalidate_script (j_compress_ptr cinfo)\n/* Verify that the scan script in cinfo->scan_info[] is valid; also\n * determine whether it uses progressive JPEG, and set cinfo->progressive_mode.\n */\n{\n  const jpeg_scan_info * scanptr;\n  int scanno, ncomps, ci, coefi, thisi;\n  int Ss, Se, Ah, Al;\n  boolean component_sent[MAX_COMPONENTS];\n#ifdef C_PROGRESSIVE_SUPPORTED\n  int * last_bitpos_ptr;\n  int last_bitpos[MAX_COMPONENTS][DCTSIZE2];\n  /* -1 until that coefficient has been seen; then last Al for it */\n#endif\n\n  if (cinfo->num_scans <= 0)\n    ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, 0);\n\n  /* For sequential JPEG, all scans must have Ss=0, Se=DCTSIZE2-1;\n   * for progressive JPEG, no scan can have this.\n   */\n  scanptr = cinfo->scan_info;\n  if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2-1) {\n#ifdef C_PROGRESSIVE_SUPPORTED\n    cinfo->progressive_mode = TRUE;\n    last_bitpos_ptr = & last_bitpos[0][0];\n    for (ci = 0; ci < cinfo->num_components; ci++) \n      for (coefi = 0; coefi < DCTSIZE2; coefi++)\n\t*last_bitpos_ptr++ = -1;\n#else\n    ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif\n  } else {\n    cinfo->progressive_mode = FALSE;\n    for (ci = 0; ci < cinfo->num_components; ci++) \n      component_sent[ci] = FALSE;\n  }\n\n  for (scanno = 1; scanno <= cinfo->num_scans; scanptr++, scanno++) {\n    /* Validate component indexes */\n    ncomps = scanptr->comps_in_scan;\n    if (ncomps <= 0 || ncomps > MAX_COMPS_IN_SCAN)\n      ERREXIT2(cinfo, JERR_COMPONENT_COUNT, ncomps, MAX_COMPS_IN_SCAN);\n    for (ci = 0; ci < ncomps; ci++) {\n      thisi = scanptr->component_index[ci];\n      if (thisi < 0 || thisi >= cinfo->num_components)\n\tERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);\n      /* Components must appear in SOF order within each scan */\n      if (ci > 0 && thisi <= scanptr->component_index[ci-1])\n\tERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);\n    }\n    /* Validate progression parameters */\n    Ss = scanptr->Ss;\n    Se = scanptr->Se;\n    Ah = scanptr->Ah;\n    Al = scanptr->Al;\n    if (cinfo->progressive_mode) {\n#ifdef C_PROGRESSIVE_SUPPORTED\n      if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 ||\n\t  Ah < 0 || Ah > 13 || Al < 0 || Al > 13)\n\tERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);\n      if (Ss == 0) {\n\tif (Se != 0)\t\t/* DC and AC together not OK */\n\t  ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);\n      } else {\n\tif (ncomps != 1)\t/* AC scans must be for only one component */\n\t  ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);\n      }\n      for (ci = 0; ci < ncomps; ci++) {\n\tlast_bitpos_ptr = & last_bitpos[scanptr->component_index[ci]][0];\n\tif (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */\n\t  ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);\n\tfor (coefi = Ss; coefi <= Se; coefi++) {\n\t  if (last_bitpos_ptr[coefi] < 0) {\n\t    /* first scan of this coefficient */\n\t    if (Ah != 0)\n\t      ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);\n\t  } else {\n\t    /* not first scan */\n\t    if (Ah != last_bitpos_ptr[coefi] || Al != Ah-1)\n\t      ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);\n\t  }\n\t  last_bitpos_ptr[coefi] = Al;\n\t}\n      }\n#endif\n    } else {\n      /* For sequential JPEG, all progression parameters must be these: */\n      if (Ss != 0 || Se != DCTSIZE2-1 || Ah != 0 || Al != 0)\n\tERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);\n      /* Make sure components are not sent twice */\n      for (ci = 0; ci < ncomps; ci++) {\n\tthisi = scanptr->component_index[ci];\n\tif (component_sent[thisi])\n\t  ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);\n\tcomponent_sent[thisi] = TRUE;\n      }\n    }\n  }\n\n  /* Now verify that everything got sent. */\n  if (cinfo->progressive_mode) {\n#ifdef C_PROGRESSIVE_SUPPORTED\n    /* For progressive mode, we only check that at least some DC data\n     * got sent for each component; the spec does not require that all bits\n     * of all coefficients be transmitted.  Would it be wiser to enforce\n     * transmission of all coefficient bits??\n     */\n    for (ci = 0; ci < cinfo->num_components; ci++) {\n      if (last_bitpos[ci][0] < 0)\n\tERREXIT(cinfo, JERR_MISSING_DATA);\n    }\n#endif\n  } else {\n    for (ci = 0; ci < cinfo->num_components; ci++) {\n      if (! component_sent[ci])\n\tERREXIT(cinfo, JERR_MISSING_DATA);\n    }\n  }\n}\n\n#endif /* C_MULTISCAN_FILES_SUPPORTED */\n\n\nLOCAL void\nselect_scan_parameters (j_compress_ptr cinfo)\n/* Set up the scan parameters for the current scan */\n{\n  int ci;\n\n#ifdef C_MULTISCAN_FILES_SUPPORTED\n  if (cinfo->scan_info != NULL) {\n    /* Prepare for current scan --- the script is already validated */\n    my_master_ptr master = (my_master_ptr) cinfo->master;\n    const jpeg_scan_info * scanptr = cinfo->scan_info + master->scan_number;\n\n    cinfo->comps_in_scan = scanptr->comps_in_scan;\n    for (ci = 0; ci < scanptr->comps_in_scan; ci++) {\n      cinfo->cur_comp_info[ci] =\n\t&cinfo->comp_info[scanptr->component_index[ci]];\n    }\n    cinfo->Ss = scanptr->Ss;\n    cinfo->Se = scanptr->Se;\n    cinfo->Ah = scanptr->Ah;\n    cinfo->Al = scanptr->Al;\n  }\n  else\n#endif\n  {\n    /* Prepare for single sequential-JPEG scan containing all components */\n    if (cinfo->num_components > MAX_COMPS_IN_SCAN)\n      ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,\n\t       MAX_COMPS_IN_SCAN);\n    cinfo->comps_in_scan = cinfo->num_components;\n    for (ci = 0; ci < cinfo->num_components; ci++) {\n      cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci];\n    }\n    cinfo->Ss = 0;\n    cinfo->Se = DCTSIZE2-1;\n    cinfo->Ah = 0;\n    cinfo->Al = 0;\n  }\n}\n\n\nLOCAL void\nper_scan_setup (j_compress_ptr cinfo)\n/* Do computations that are needed before processing a JPEG scan */\n/* cinfo->comps_in_scan and cinfo->cur_comp_info[] are already set */\n{\n  int ci, mcublks, tmp;\n  jpeg_component_info *compptr;\n  \n  if (cinfo->comps_in_scan == 1) {\n    \n    /* Noninterleaved (single-component) scan */\n    compptr = cinfo->cur_comp_info[0];\n    \n    /* Overall image size in MCUs */\n    cinfo->MCUs_per_row = compptr->width_in_blocks;\n    cinfo->MCU_rows_in_scan = compptr->height_in_blocks;\n    \n    /* For noninterleaved scan, always one block per MCU */\n    compptr->MCU_width = 1;\n    compptr->MCU_height = 1;\n    compptr->MCU_blocks = 1;\n    compptr->MCU_sample_width = DCTSIZE;\n    compptr->last_col_width = 1;\n    /* For noninterleaved scans, it is convenient to define last_row_height\n     * as the number of block rows present in the last iMCU row.\n     */\n    tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor);\n    if (tmp == 0) tmp = compptr->v_samp_factor;\n    compptr->last_row_height = tmp;\n    \n    /* Prepare array describing MCU composition */\n    cinfo->blocks_in_MCU = 1;\n    cinfo->MCU_membership[0] = 0;\n    \n  } else {\n    \n    /* Interleaved (multi-component) scan */\n    if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)\n      ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,\n\t       MAX_COMPS_IN_SCAN);\n    \n    /* Overall image size in MCUs */\n    cinfo->MCUs_per_row = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_width,\n\t\t    (long) (cinfo->max_h_samp_factor*DCTSIZE));\n    cinfo->MCU_rows_in_scan = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_height,\n\t\t    (long) (cinfo->max_v_samp_factor*DCTSIZE));\n    \n    cinfo->blocks_in_MCU = 0;\n    \n    for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n      compptr = cinfo->cur_comp_info[ci];\n      /* Sampling factors give # of blocks of component in each MCU */\n      compptr->MCU_width = compptr->h_samp_factor;\n      compptr->MCU_height = compptr->v_samp_factor;\n      compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;\n      compptr->MCU_sample_width = compptr->MCU_width * DCTSIZE;\n      /* Figure number of non-dummy blocks in last MCU column & row */\n      tmp = (int) (compptr->width_in_blocks % compptr->MCU_width);\n      if (tmp == 0) tmp = compptr->MCU_width;\n      compptr->last_col_width = tmp;\n      tmp = (int) (compptr->height_in_blocks % compptr->MCU_height);\n      if (tmp == 0) tmp = compptr->MCU_height;\n      compptr->last_row_height = tmp;\n      /* Prepare array describing MCU composition */\n      mcublks = compptr->MCU_blocks;\n      if (cinfo->blocks_in_MCU + mcublks > C_MAX_BLOCKS_IN_MCU)\n\tERREXIT(cinfo, JERR_BAD_MCU_SIZE);\n      while (mcublks-- > 0) {\n\tcinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;\n      }\n    }\n    \n  }\n\n  /* Convert restart specified in rows to actual MCU count. */\n  /* Note that count must fit in 16 bits, so we provide limiting. */\n  if (cinfo->restart_in_rows > 0) {\n    long nominal = (long) cinfo->restart_in_rows * (long) cinfo->MCUs_per_row;\n    cinfo->restart_interval = (unsigned int) MIN(nominal, 65535L);\n  }\n}\n\n\n/*\n * Per-pass setup.\n * This is called at the beginning of each pass.  We determine which modules\n * will be active during this pass and give them appropriate start_pass calls.\n * We also set is_last_pass to indicate whether any more passes will be\n * required.\n */\n\nMETHODDEF void\nprepare_for_pass (j_compress_ptr cinfo)\n{\n  my_master_ptr master = (my_master_ptr) cinfo->master;\n\n  switch (master->pass_type) {\n  case main_pass:\n    /* Initial pass: will collect input data, and do either Huffman\n     * optimization or data output for the first scan.\n     */\n    select_scan_parameters(cinfo);\n    per_scan_setup(cinfo);\n    if (! cinfo->raw_data_in) {\n      (*cinfo->cconvert->start_pass) (cinfo);\n      (*cinfo->downsample->start_pass) (cinfo);\n      (*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU);\n    }\n    (*cinfo->fdct->start_pass) (cinfo);\n    (*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding);\n    (*cinfo->coef->start_pass) (cinfo,\n\t\t\t\t(master->total_passes > 1 ?\n\t\t\t\t JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));\n    (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);\n    if (cinfo->optimize_coding) {\n      /* No immediate data output; postpone writing frame/scan headers */\n      master->pub.call_pass_startup = FALSE;\n    } else {\n      /* Will write frame/scan headers at first jpeg_write_scanlines call */\n      master->pub.call_pass_startup = TRUE;\n    }\n    break;\n#ifdef ENTROPY_OPT_SUPPORTED\n  case huff_opt_pass:\n    /* Do Huffman optimization for a scan after the first one. */\n    select_scan_parameters(cinfo);\n    per_scan_setup(cinfo);\n    if (cinfo->Ss != 0 || cinfo->Ah == 0 || cinfo->arith_code) {\n      (*cinfo->entropy->start_pass) (cinfo, TRUE);\n      (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST);\n      master->pub.call_pass_startup = FALSE;\n      break;\n    }\n    /* Special case: Huffman DC refinement scans need no Huffman table\n     * and therefore we can skip the optimization pass for them.\n     */\n    master->pass_type = output_pass;\n    master->pass_number++;\n    /*FALLTHROUGH*/\n#endif\n  case output_pass:\n    /* Do a data-output pass. */\n    /* We need not repeat per-scan setup if prior optimization pass did it. */\n    if (! cinfo->optimize_coding) {\n      select_scan_parameters(cinfo);\n      per_scan_setup(cinfo);\n    }\n    (*cinfo->entropy->start_pass) (cinfo, FALSE);\n    (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST);\n    /* We emit frame/scan headers now */\n    if (master->scan_number == 0)\n      (*cinfo->marker->write_frame_header) (cinfo);\n    (*cinfo->marker->write_scan_header) (cinfo);\n    master->pub.call_pass_startup = FALSE;\n    break;\n  default:\n    ERREXIT(cinfo, JERR_NOT_COMPILED);\n  }\n\n  master->pub.is_last_pass = (master->pass_number == master->total_passes-1);\n\n  /* Set up progress monitor's pass info if present */\n  if (cinfo->progress != NULL) {\n    cinfo->progress->completed_passes = master->pass_number;\n    cinfo->progress->total_passes = master->total_passes;\n  }\n}\n\n\n/*\n * Special start-of-pass hook.\n * This is called by jpeg_write_scanlines if call_pass_startup is TRUE.\n * In single-pass processing, we need this hook because we don't want to\n * write frame/scan headers during jpeg_start_compress; we want to let the\n * application write COM markers etc. between jpeg_start_compress and the\n * jpeg_write_scanlines loop.\n * In multi-pass processing, this routine is not used.\n */\n\nMETHODDEF void\npass_startup (j_compress_ptr cinfo)\n{\n  cinfo->master->call_pass_startup = FALSE; /* reset flag so call only once */\n\n  (*cinfo->marker->write_frame_header) (cinfo);\n  (*cinfo->marker->write_scan_header) (cinfo);\n}\n\n\n/*\n * Finish up at end of pass.\n */\n\nMETHODDEF void\nfinish_pass_master (j_compress_ptr cinfo)\n{\n  my_master_ptr master = (my_master_ptr) cinfo->master;\n\n  /* The entropy coder always needs an end-of-pass call,\n   * either to analyze statistics or to flush its output buffer.\n   */\n  (*cinfo->entropy->finish_pass) (cinfo);\n\n  /* Update state for next pass */\n  switch (master->pass_type) {\n  case main_pass:\n    /* next pass is either output of scan 0 (after optimization)\n     * or output of scan 1 (if no optimization).\n     */\n    master->pass_type = output_pass;\n    if (! cinfo->optimize_coding)\n      master->scan_number++;\n    break;\n  case huff_opt_pass:\n    /* next pass is always output of current scan */\n    master->pass_type = output_pass;\n    break;\n  case output_pass:\n    /* next pass is either optimization or output of next scan */\n    if (cinfo->optimize_coding)\n      master->pass_type = huff_opt_pass;\n    master->scan_number++;\n    break;\n  }\n\n  master->pass_number++;\n}\n\n\n/*\n * Initialize master compression control.\n */\n\nGLOBAL void\njinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)\n{\n  my_master_ptr master;\n\n  master = (my_master_ptr)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t  SIZEOF(my_comp_master));\n  cinfo->master = (struct jpeg_comp_master *) master;\n  master->pub.prepare_for_pass = prepare_for_pass;\n  master->pub.pass_startup = pass_startup;\n  master->pub.finish_pass = finish_pass_master;\n  master->pub.is_last_pass = FALSE;\n\n  /* Validate parameters, determine derived values */\n  initial_setup(cinfo);\n\n  if (cinfo->scan_info != NULL) {\n#ifdef C_MULTISCAN_FILES_SUPPORTED\n    validate_script(cinfo);\n#else\n    ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif\n  } else {\n    cinfo->progressive_mode = FALSE;\n    cinfo->num_scans = 1;\n  }\n\n  if (cinfo->progressive_mode)\t/*  TEMPORARY HACK ??? */\n    cinfo->optimize_coding = TRUE; /* assume default tables no good for progressive mode */\n\n  /* Initialize my private state */\n  if (transcode_only) {\n    /* no main pass in transcoding */\n    if (cinfo->optimize_coding)\n      master->pass_type = huff_opt_pass;\n    else\n      master->pass_type = output_pass;\n  } else {\n    /* for normal compression, first pass is always this type: */\n    master->pass_type = main_pass;\n  }\n  master->scan_number = 0;\n  master->pass_number = 0;\n  if (cinfo->optimize_coding)\n    master->total_passes = cinfo->num_scans * 2;\n  else\n    master->total_passes = cinfo->num_scans;\n}\n"
  },
  {
    "path": "code/jpeg-6/jcomapi.c",
    "content": "/*\n * jcomapi.c\n *\n * Copyright (C) 1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains application interface routines that are used for both\n * compression and decompression.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/*\n * Abort processing of a JPEG compression or decompression operation,\n * but don't destroy the object itself.\n *\n * For this, we merely clean up all the nonpermanent memory pools.\n * Note that temp files (virtual arrays) are not allowed to belong to\n * the permanent pool, so we will be able to close all temp files here.\n * Closing a data source or destination, if necessary, is the application's\n * responsibility.\n */\n\nGLOBAL void\njpeg_abort (j_common_ptr cinfo)\n{\n  int pool;\n\n  /* Releasing pools in reverse order might help avoid fragmentation\n   * with some (brain-damaged) malloc libraries.\n   */\n  for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) {\n    (*cinfo->mem->free_pool) (cinfo, pool);\n  }\n\n  /* Reset overall state for possible reuse of object */\n  cinfo->global_state = (cinfo->is_decompressor ? DSTATE_START : CSTATE_START);\n}\n\n\n/*\n * Destruction of a JPEG object.\n *\n * Everything gets deallocated except the master jpeg_compress_struct itself\n * and the error manager struct.  Both of these are supplied by the application\n * and must be freed, if necessary, by the application.  (Often they are on\n * the stack and so don't need to be freed anyway.)\n * Closing a data source or destination, if necessary, is the application's\n * responsibility.\n */\n\nGLOBAL void\njpeg_destroy (j_common_ptr cinfo)\n{\n  /* We need only tell the memory manager to release everything. */\n  /* NB: mem pointer is NULL if memory mgr failed to initialize. */\n  if (cinfo->mem != NULL)\n    (*cinfo->mem->self_destruct) (cinfo);\n  cinfo->mem = NULL;\t\t/* be safe if jpeg_destroy is called twice */\n  cinfo->global_state = 0;\t/* mark it destroyed */\n}\n\n\n/*\n * Convenience routines for allocating quantization and Huffman tables.\n * (Would jutils.c be a more reasonable place to put these?)\n */\n\nGLOBAL JQUANT_TBL *\njpeg_alloc_quant_table (j_common_ptr cinfo)\n{\n  JQUANT_TBL *tbl;\n\n  tbl = (JQUANT_TBL *)\n    (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL));\n  tbl->sent_table = FALSE;\t/* make sure this is false in any new table */\n  return tbl;\n}\n\n\nGLOBAL JHUFF_TBL *\njpeg_alloc_huff_table (j_common_ptr cinfo)\n{\n  JHUFF_TBL *tbl;\n\n  tbl = (JHUFF_TBL *)\n    (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL));\n  tbl->sent_table = FALSE;\t/* make sure this is false in any new table */\n  return tbl;\n}\n"
  },
  {
    "path": "code/jpeg-6/jconfig.h",
    "content": "/* jconfig.wat --- jconfig.h for Watcom C/C++ on MS-DOS or OS/2. */\n/* see jconfig.doc for explanations */\n\n#define HAVE_PROTOTYPES\n#define HAVE_UNSIGNED_CHAR\n#define HAVE_UNSIGNED_SHORT\n/* #define void char */\n/* #define const */\n#define CHAR_IS_UNSIGNED\n#define HAVE_STDDEF_H\n#define HAVE_STDLIB_H\n#undef NEED_BSD_STRINGS\n#undef NEED_SYS_TYPES_H\n#undef NEED_FAR_POINTERS\t/* Watcom uses flat 32-bit addressing */\n#undef NEED_SHORT_EXTERNAL_NAMES\n#undef INCOMPLETE_TYPES_BROKEN\n\n#define JDCT_DEFAULT  JDCT_FLOAT\n#define JDCT_FASTEST  JDCT_FLOAT\n\n#ifdef JPEG_INTERNALS\n\n#undef RIGHT_SHIFT_IS_UNSIGNED\n\n#endif /* JPEG_INTERNALS */\n\n#ifdef JPEG_CJPEG_DJPEG\n\n#define BMP_SUPPORTED\t\t/* BMP image file format */\n#define GIF_SUPPORTED\t\t/* GIF image file format */\n#define PPM_SUPPORTED\t\t/* PBMPLUS PPM/PGM image file format */\n#undef RLE_SUPPORTED\t\t/* Utah RLE image file format */\n#define TARGA_SUPPORTED\t\t/* Targa image file format */\n\n#undef TWO_FILE_COMMANDLINE\t/* optional */\n#define USE_SETMODE\t\t/* Needed to make one-file style work in Watcom */\n#undef NEED_SIGNAL_CATCHER\t/* Define this if you use jmemname.c */\n#undef DONT_USE_B_MODE\n#undef PROGRESS_REPORT\t\t/* optional */\n\n#endif /* JPEG_CJPEG_DJPEG */\n"
  },
  {
    "path": "code/jpeg-6/jcparam.c",
    "content": "/*\n * jcparam.c\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains optional default-setting code for the JPEG compressor.\n * Applications do not have to use this file, but those that don't use it\n * must know a lot more about the innards of the JPEG code.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/*\n * Quantization table setup routines\n */\n\nGLOBAL void\njpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,\n\t\t      const unsigned int *basic_table,\n\t\t      int scale_factor, boolean force_baseline)\n/* Define a quantization table equal to the basic_table times\n * a scale factor (given as a percentage).\n * If force_baseline is TRUE, the computed quantization table entries\n * are limited to 1..255 for JPEG baseline compatibility.\n */\n{\n  JQUANT_TBL ** qtblptr = & cinfo->quant_tbl_ptrs[which_tbl];\n  int i;\n  long temp;\n\n  /* Safety check to ensure start_compress not called yet. */\n  if (cinfo->global_state != CSTATE_START)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n\n  if (*qtblptr == NULL)\n    *qtblptr = jpeg_alloc_quant_table((j_common_ptr) cinfo);\n\n  for (i = 0; i < DCTSIZE2; i++) {\n    temp = ((long) basic_table[i] * scale_factor + 50L) / 100L;\n    /* limit the values to the valid range */\n    if (temp <= 0L) temp = 1L;\n    if (temp > 32767L) temp = 32767L; /* max quantizer needed for 12 bits */\n    if (force_baseline && temp > 255L)\n      temp = 255L;\t\t/* limit to baseline range if requested */\n    (*qtblptr)->quantval[i] = (UINT16) temp;\n  }\n\n  /* Initialize sent_table FALSE so table will be written to JPEG file. */\n  (*qtblptr)->sent_table = FALSE;\n}\n\n\nGLOBAL void\njpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,\n\t\t\t boolean force_baseline)\n/* Set or change the 'quality' (quantization) setting, using default tables\n * and a straight percentage-scaling quality scale.  In most cases it's better\n * to use jpeg_set_quality (below); this entry point is provided for\n * applications that insist on a linear percentage scaling.\n */\n{\n  /* This is the sample quantization table given in the JPEG spec section K.1,\n   * but expressed in zigzag order (as are all of our quant. tables).\n   * The spec says that the values given produce \"good\" quality, and\n   * when divided by 2, \"very good\" quality.\n   */\n  static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = {\n    16,  11,  12,  14,  12,  10,  16,  14,\n    13,  14,  18,  17,  16,  19,  24,  40,\n    26,  24,  22,  22,  24,  49,  35,  37,\n    29,  40,  58,  51,  61,  60,  57,  51,\n    56,  55,  64,  72,  92,  78,  64,  68,\n    87,  69,  55,  56,  80, 109,  81,  87,\n    95,  98, 103, 104, 103,  62,  77, 113,\n    121, 112, 100, 120,  92, 101, 103,  99\n    };\n  static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = {\n    17,  18,  18,  24,  21,  24,  47,  26,\n    26,  47,  99,  66,  56,  66,  99,  99,\n    99,  99,  99,  99,  99,  99,  99,  99,\n    99,  99,  99,  99,  99,  99,  99,  99,\n    99,  99,  99,  99,  99,  99,  99,  99,\n    99,  99,  99,  99,  99,  99,  99,  99,\n    99,  99,  99,  99,  99,  99,  99,  99,\n    99,  99,  99,  99,  99,  99,  99,  99\n    };\n\n  /* Set up two quantization tables using the specified scaling */\n  jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,\n\t\t       scale_factor, force_baseline);\n  jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,\n\t\t       scale_factor, force_baseline);\n}\n\n\nGLOBAL int\njpeg_quality_scaling (int quality)\n/* Convert a user-specified quality rating to a percentage scaling factor\n * for an underlying quantization table, using our recommended scaling curve.\n * The input 'quality' factor should be 0 (terrible) to 100 (very good).\n */\n{\n  /* Safety limit on quality factor.  Convert 0 to 1 to avoid zero divide. */\n  if (quality <= 0) quality = 1;\n  if (quality > 100) quality = 100;\n\n  /* The basic table is used as-is (scaling 100) for a quality of 50.\n   * Qualities 50..100 are converted to scaling percentage 200 - 2*Q;\n   * note that at Q=100 the scaling is 0, which will cause j_add_quant_table\n   * to make all the table entries 1 (hence, no quantization loss).\n   * Qualities 1..50 are converted to scaling percentage 5000/Q.\n   */\n  if (quality < 50)\n    quality = 5000 / quality;\n  else\n    quality = 200 - quality*2;\n\n  return quality;\n}\n\n\nGLOBAL void\njpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline)\n/* Set or change the 'quality' (quantization) setting, using default tables.\n * This is the standard quality-adjusting entry point for typical user\n * interfaces; only those who want detailed control over quantization tables\n * would use the preceding three routines directly.\n */\n{\n  /* Convert user 0-100 rating to percentage scaling */\n  quality = jpeg_quality_scaling(quality);\n\n  /* Set up standard quality tables */\n  jpeg_set_linear_quality(cinfo, quality, force_baseline);\n}\n\n\n/*\n * Huffman table setup routines\n */\n\nLOCAL void\nadd_huff_table (j_compress_ptr cinfo,\n\t\tJHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val)\n/* Define a Huffman table */\n{\n  if (*htblptr == NULL)\n    *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);\n  \n  MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits));\n  MEMCOPY((*htblptr)->huffval, val, SIZEOF((*htblptr)->huffval));\n\n  /* Initialize sent_table FALSE so table will be written to JPEG file. */\n  (*htblptr)->sent_table = FALSE;\n}\n\n\nLOCAL void\nstd_huff_tables (j_compress_ptr cinfo)\n/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */\n/* IMPORTANT: these are only valid for 8-bit data precision! */\n{\n  static const UINT8 bits_dc_luminance[17] =\n    { /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 };\n  static const UINT8 val_dc_luminance[] =\n    { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };\n  \n  static const UINT8 bits_dc_chrominance[17] =\n    { /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 };\n  static const UINT8 val_dc_chrominance[] =\n    { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };\n  \n  static const UINT8 bits_ac_luminance[17] =\n    { /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d };\n  static const UINT8 val_ac_luminance[] =\n    { 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,\n      0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,\n      0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,\n      0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,\n      0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,\n      0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,\n      0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,\n      0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,\n      0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,\n      0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,\n      0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,\n      0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,\n      0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,\n      0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,\n      0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,\n      0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,\n      0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,\n      0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,\n      0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,\n      0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,\n      0xf9, 0xfa };\n  \n  static const UINT8 bits_ac_chrominance[17] =\n    { /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 };\n  static const UINT8 val_ac_chrominance[] =\n    { 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,\n      0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,\n      0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,\n      0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,\n      0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,\n      0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26,\n      0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38,\n      0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,\n      0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,\n      0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,\n      0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,\n      0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,\n      0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,\n      0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,\n      0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,\n      0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3,\n      0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,\n      0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,\n      0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,\n      0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,\n      0xf9, 0xfa };\n  \n  add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[0],\n\t\t bits_dc_luminance, val_dc_luminance);\n  add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[0],\n\t\t bits_ac_luminance, val_ac_luminance);\n  add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[1],\n\t\t bits_dc_chrominance, val_dc_chrominance);\n  add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[1],\n\t\t bits_ac_chrominance, val_ac_chrominance);\n}\n\n\n/*\n * Default parameter setup for compression.\n *\n * Applications that don't choose to use this routine must do their\n * own setup of all these parameters.  Alternately, you can call this\n * to establish defaults and then alter parameters selectively.  This\n * is the recommended approach since, if we add any new parameters,\n * your code will still work (they'll be set to reasonable defaults).\n */\n\nGLOBAL void\njpeg_set_defaults (j_compress_ptr cinfo)\n{\n  int i;\n\n  /* Safety check to ensure start_compress not called yet. */\n  if (cinfo->global_state != CSTATE_START)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n\n  /* Allocate comp_info array large enough for maximum component count.\n   * Array is made permanent in case application wants to compress\n   * multiple images at same param settings.\n   */\n  if (cinfo->comp_info == NULL)\n    cinfo->comp_info = (jpeg_component_info *)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,\n\t\t\t\t  MAX_COMPONENTS * SIZEOF(jpeg_component_info));\n\n  /* Initialize everything not dependent on the color space */\n\n  cinfo->data_precision = BITS_IN_JSAMPLE;\n  /* Set up two quantization tables using default quality of 75 */\n  jpeg_set_quality(cinfo, 75, TRUE);\n  /* Set up two Huffman tables */\n  std_huff_tables(cinfo);\n\n  /* Initialize default arithmetic coding conditioning */\n  for (i = 0; i < NUM_ARITH_TBLS; i++) {\n    cinfo->arith_dc_L[i] = 0;\n    cinfo->arith_dc_U[i] = 1;\n    cinfo->arith_ac_K[i] = 5;\n  }\n\n  /* Default is no multiple-scan output */\n  cinfo->scan_info = NULL;\n  cinfo->num_scans = 0;\n\n  /* Expect normal source image, not raw downsampled data */\n  cinfo->raw_data_in = FALSE;\n\n  /* Use Huffman coding, not arithmetic coding, by default */\n  cinfo->arith_code = FALSE;\n\n  /* By default, don't do extra passes to optimize entropy coding */\n  cinfo->optimize_coding = FALSE;\n  /* The standard Huffman tables are only valid for 8-bit data precision.\n   * If the precision is higher, force optimization on so that usable\n   * tables will be computed.  This test can be removed if default tables\n   * are supplied that are valid for the desired precision.\n   */\n  if (cinfo->data_precision > 8)\n    cinfo->optimize_coding = TRUE;\n\n  /* By default, use the simpler non-cosited sampling alignment */\n  cinfo->CCIR601_sampling = FALSE;\n\n  /* No input smoothing */\n  cinfo->smoothing_factor = 0;\n\n  /* DCT algorithm preference */\n  cinfo->dct_method = JDCT_DEFAULT;\n\n  /* No restart markers */\n  cinfo->restart_interval = 0;\n  cinfo->restart_in_rows = 0;\n\n  /* Fill in default JFIF marker parameters.  Note that whether the marker\n   * will actually be written is determined by jpeg_set_colorspace.\n   */\n  cinfo->density_unit = 0;\t/* Pixel size is unknown by default */\n  cinfo->X_density = 1;\t\t/* Pixel aspect ratio is square by default */\n  cinfo->Y_density = 1;\n\n  /* Choose JPEG colorspace based on input space, set defaults accordingly */\n\n  jpeg_default_colorspace(cinfo);\n}\n\n\n/*\n * Select an appropriate JPEG colorspace for in_color_space.\n */\n\nGLOBAL void\njpeg_default_colorspace (j_compress_ptr cinfo)\n{\n  switch (cinfo->in_color_space) {\n  case JCS_GRAYSCALE:\n    jpeg_set_colorspace(cinfo, JCS_GRAYSCALE);\n    break;\n  case JCS_RGB:\n    jpeg_set_colorspace(cinfo, JCS_YCbCr);\n    break;\n  case JCS_YCbCr:\n    jpeg_set_colorspace(cinfo, JCS_YCbCr);\n    break;\n  case JCS_CMYK:\n    jpeg_set_colorspace(cinfo, JCS_CMYK); /* By default, no translation */\n    break;\n  case JCS_YCCK:\n    jpeg_set_colorspace(cinfo, JCS_YCCK);\n    break;\n  case JCS_UNKNOWN:\n    jpeg_set_colorspace(cinfo, JCS_UNKNOWN);\n    break;\n  default:\n    ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);\n  }\n}\n\n\n/*\n * Set the JPEG colorspace, and choose colorspace-dependent default values.\n */\n\nGLOBAL void\njpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace)\n{\n  jpeg_component_info * compptr;\n  int ci;\n\n#define SET_COMP(index,id,hsamp,vsamp,quant,dctbl,actbl)  \\\n  (compptr = &cinfo->comp_info[index], \\\n   compptr->component_id = (id), \\\n   compptr->h_samp_factor = (hsamp), \\\n   compptr->v_samp_factor = (vsamp), \\\n   compptr->quant_tbl_no = (quant), \\\n   compptr->dc_tbl_no = (dctbl), \\\n   compptr->ac_tbl_no = (actbl) )\n\n  /* Safety check to ensure start_compress not called yet. */\n  if (cinfo->global_state != CSTATE_START)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n\n  /* For all colorspaces, we use Q and Huff tables 0 for luminance components,\n   * tables 1 for chrominance components.\n   */\n\n  cinfo->jpeg_color_space = colorspace;\n\n  cinfo->write_JFIF_header = FALSE; /* No marker for non-JFIF colorspaces */\n  cinfo->write_Adobe_marker = FALSE; /* write no Adobe marker by default */\n\n  switch (colorspace) {\n  case JCS_GRAYSCALE:\n    cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */\n    cinfo->num_components = 1;\n    /* JFIF specifies component ID 1 */\n    SET_COMP(0, 1, 1,1, 0, 0,0);\n    break;\n  case JCS_RGB:\n    cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */\n    cinfo->num_components = 3;\n    SET_COMP(0, 0x52 /* 'R' */, 1,1, 0, 0,0);\n    SET_COMP(1, 0x47 /* 'G' */, 1,1, 0, 0,0);\n    SET_COMP(2, 0x42 /* 'B' */, 1,1, 0, 0,0);\n    break;\n  case JCS_YCbCr:\n    cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */\n    cinfo->num_components = 3;\n    /* JFIF specifies component IDs 1,2,3 */\n    /* We default to 2x2 subsamples of chrominance */\n    SET_COMP(0, 1, 2,2, 0, 0,0);\n    SET_COMP(1, 2, 1,1, 1, 1,1);\n    SET_COMP(2, 3, 1,1, 1, 1,1);\n    break;\n  case JCS_CMYK:\n    cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */\n    cinfo->num_components = 4;\n    SET_COMP(0, 0x43 /* 'C' */, 1,1, 0, 0,0);\n    SET_COMP(1, 0x4D /* 'M' */, 1,1, 0, 0,0);\n    SET_COMP(2, 0x59 /* 'Y' */, 1,1, 0, 0,0);\n    SET_COMP(3, 0x4B /* 'K' */, 1,1, 0, 0,0);\n    break;\n  case JCS_YCCK:\n    cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */\n    cinfo->num_components = 4;\n    SET_COMP(0, 1, 2,2, 0, 0,0);\n    SET_COMP(1, 2, 1,1, 1, 1,1);\n    SET_COMP(2, 3, 1,1, 1, 1,1);\n    SET_COMP(3, 4, 2,2, 0, 0,0);\n    break;\n  case JCS_UNKNOWN:\n    cinfo->num_components = cinfo->input_components;\n    if (cinfo->num_components < 1 || cinfo->num_components > MAX_COMPONENTS)\n      ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,\n\t       MAX_COMPONENTS);\n    for (ci = 0; ci < cinfo->num_components; ci++) {\n      SET_COMP(ci, ci, 1,1, 0, 0,0);\n    }\n    break;\n  default:\n    ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);\n  }\n}\n\n\n#ifdef C_PROGRESSIVE_SUPPORTED\n\nLOCAL jpeg_scan_info *\nfill_a_scan (jpeg_scan_info * scanptr, int ci,\n\t     int Ss, int Se, int Ah, int Al)\n/* Support routine: generate one scan for specified component */\n{\n  scanptr->comps_in_scan = 1;\n  scanptr->component_index[0] = ci;\n  scanptr->Ss = Ss;\n  scanptr->Se = Se;\n  scanptr->Ah = Ah;\n  scanptr->Al = Al;\n  scanptr++;\n  return scanptr;\n}\n\nLOCAL jpeg_scan_info *\nfill_scans (jpeg_scan_info * scanptr, int ncomps,\n\t    int Ss, int Se, int Ah, int Al)\n/* Support routine: generate one scan for each component */\n{\n  int ci;\n\n  for (ci = 0; ci < ncomps; ci++) {\n    scanptr->comps_in_scan = 1;\n    scanptr->component_index[0] = ci;\n    scanptr->Ss = Ss;\n    scanptr->Se = Se;\n    scanptr->Ah = Ah;\n    scanptr->Al = Al;\n    scanptr++;\n  }\n  return scanptr;\n}\n\nLOCAL jpeg_scan_info *\nfill_dc_scans (jpeg_scan_info * scanptr, int ncomps, int Ah, int Al)\n/* Support routine: generate interleaved DC scan if possible, else N scans */\n{\n  int ci;\n\n  if (ncomps <= MAX_COMPS_IN_SCAN) {\n    /* Single interleaved DC scan */\n    scanptr->comps_in_scan = ncomps;\n    for (ci = 0; ci < ncomps; ci++)\n      scanptr->component_index[ci] = ci;\n    scanptr->Ss = scanptr->Se = 0;\n    scanptr->Ah = Ah;\n    scanptr->Al = Al;\n    scanptr++;\n  } else {\n    /* Noninterleaved DC scan for each component */\n    scanptr = fill_scans(scanptr, ncomps, 0, 0, Ah, Al);\n  }\n  return scanptr;\n}\n\n\n/*\n * Create a recommended progressive-JPEG script.\n * cinfo->num_components and cinfo->jpeg_color_space must be correct.\n */\n\nGLOBAL void\njpeg_simple_progression (j_compress_ptr cinfo)\n{\n  int ncomps = cinfo->num_components;\n  int nscans;\n  jpeg_scan_info * scanptr;\n\n  /* Safety check to ensure start_compress not called yet. */\n  if (cinfo->global_state != CSTATE_START)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n\n  /* Figure space needed for script.  Calculation must match code below! */\n  if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {\n    /* Custom script for YCbCr color images. */\n    nscans = 10;\n  } else {\n    /* All-purpose script for other color spaces. */\n    if (ncomps > MAX_COMPS_IN_SCAN)\n      nscans = 6 * ncomps;\t/* 2 DC + 4 AC scans per component */\n    else\n      nscans = 2 + 4 * ncomps;\t/* 2 DC scans; 4 AC scans per component */\n  }\n\n  /* Allocate space for script. */\n  /* We use permanent pool just in case application re-uses script. */\n  scanptr = (jpeg_scan_info *)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,\n\t\t\t\tnscans * SIZEOF(jpeg_scan_info));\n  cinfo->scan_info = scanptr;\n  cinfo->num_scans = nscans;\n\n  if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {\n    /* Custom script for YCbCr color images. */\n    /* Initial DC scan */\n    scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);\n    /* Initial AC scan: get some luma data out in a hurry */\n    scanptr = fill_a_scan(scanptr, 0, 1, 5, 0, 2);\n    /* Chroma data is too small to be worth expending many scans on */\n    scanptr = fill_a_scan(scanptr, 2, 1, 63, 0, 1);\n    scanptr = fill_a_scan(scanptr, 1, 1, 63, 0, 1);\n    /* Complete spectral selection for luma AC */\n    scanptr = fill_a_scan(scanptr, 0, 6, 63, 0, 2);\n    /* Refine next bit of luma AC */\n    scanptr = fill_a_scan(scanptr, 0, 1, 63, 2, 1);\n    /* Finish DC successive approximation */\n    scanptr = fill_dc_scans(scanptr, ncomps, 1, 0);\n    /* Finish AC successive approximation */\n    scanptr = fill_a_scan(scanptr, 2, 1, 63, 1, 0);\n    scanptr = fill_a_scan(scanptr, 1, 1, 63, 1, 0);\n    /* Luma bottom bit comes last since it's usually largest scan */\n    scanptr = fill_a_scan(scanptr, 0, 1, 63, 1, 0);\n  } else {\n    /* All-purpose script for other color spaces. */\n    /* Successive approximation first pass */\n    scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);\n    scanptr = fill_scans(scanptr, ncomps, 1, 5, 0, 2);\n    scanptr = fill_scans(scanptr, ncomps, 6, 63, 0, 2);\n    /* Successive approximation second pass */\n    scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1);\n    /* Successive approximation final pass */\n    scanptr = fill_dc_scans(scanptr, ncomps, 1, 0);\n    scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0);\n  }\n}\n\n#endif /* C_PROGRESSIVE_SUPPORTED */\n"
  },
  {
    "path": "code/jpeg-6/jcphuff.c",
    "content": "/*\n * jcphuff.c\n *\n * Copyright (C) 1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains Huffman entropy encoding routines for progressive JPEG.\n *\n * We do not support output suspension in this module, since the library\n * currently does not allow multiple-scan files to be written with output\n * suspension.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jchuff.h\"\t\t/* Declarations shared with jchuff.c */\n\n#ifdef C_PROGRESSIVE_SUPPORTED\n\n/* Expanded entropy encoder object for progressive Huffman encoding. */\n\ntypedef struct {\n  struct jpeg_entropy_encoder pub; /* public fields */\n\n  /* Mode flag: TRUE for optimization, FALSE for actual data output */\n  boolean gather_statistics;\n\n  /* Bit-level coding status.\n   * next_output_byte/free_in_buffer are local copies of cinfo->dest fields.\n   */\n  JOCTET * next_output_byte;\t/* => next byte to write in buffer */\n  size_t free_in_buffer;\t/* # of byte spaces remaining in buffer */\n  INT32 put_buffer;\t\t/* current bit-accumulation buffer */\n  int put_bits;\t\t\t/* # of bits now in it */\n  j_compress_ptr cinfo;\t\t/* link to cinfo (needed for dump_buffer) */\n\n  /* Coding status for DC components */\n  int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */\n\n  /* Coding status for AC components */\n  int ac_tbl_no;\t\t/* the table number of the single component */\n  unsigned int EOBRUN;\t\t/* run length of EOBs */\n  unsigned int BE;\t\t/* # of buffered correction bits before MCU */\n  char * bit_buffer;\t\t/* buffer for correction bits (1 per char) */\n  /* packing correction bits tightly would save some space but cost time... */\n\n  unsigned int restarts_to_go;\t/* MCUs left in this restart interval */\n  int next_restart_num;\t\t/* next restart number to write (0-7) */\n\n  /* Pointers to derived tables (these workspaces have image lifespan).\n   * Since any one scan codes only DC or only AC, we only need one set\n   * of tables, not one for DC and one for AC.\n   */\n  c_derived_tbl * derived_tbls[NUM_HUFF_TBLS];\n\n  /* Statistics tables for optimization; again, one set is enough */\n  long * count_ptrs[NUM_HUFF_TBLS];\n} phuff_entropy_encoder;\n\ntypedef phuff_entropy_encoder * phuff_entropy_ptr;\n\n/* MAX_CORR_BITS is the number of bits the AC refinement correction-bit\n * buffer can hold.  Larger sizes may slightly improve compression, but\n * 1000 is already well into the realm of overkill.\n * The minimum safe size is 64 bits.\n */\n\n#define MAX_CORR_BITS  1000\t/* Max # of correction bits I can buffer */\n\n/* IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than INT32.\n * We assume that int right shift is unsigned if INT32 right shift is,\n * which should be safe.\n */\n\n#ifdef RIGHT_SHIFT_IS_UNSIGNED\n#define ISHIFT_TEMPS\tint ishift_temp;\n#define IRIGHT_SHIFT(x,shft)  \\\n\t((ishift_temp = (x)) < 0 ? \\\n\t (ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \\\n\t (ishift_temp >> (shft)))\n#else\n#define ISHIFT_TEMPS\n#define IRIGHT_SHIFT(x,shft)\t((x) >> (shft))\n#endif\n\n/* Forward declarations */\nMETHODDEF boolean encode_mcu_DC_first JPP((j_compress_ptr cinfo,\n\t\t\t\t\t   JBLOCKROW *MCU_data));\nMETHODDEF boolean encode_mcu_AC_first JPP((j_compress_ptr cinfo,\n\t\t\t\t\t   JBLOCKROW *MCU_data));\nMETHODDEF boolean encode_mcu_DC_refine JPP((j_compress_ptr cinfo,\n\t\t\t\t\t    JBLOCKROW *MCU_data));\nMETHODDEF boolean encode_mcu_AC_refine JPP((j_compress_ptr cinfo,\n\t\t\t\t\t    JBLOCKROW *MCU_data));\nMETHODDEF void finish_pass_phuff JPP((j_compress_ptr cinfo));\nMETHODDEF void finish_pass_gather_phuff JPP((j_compress_ptr cinfo));\n\n\n/*\n * Initialize for a Huffman-compressed scan using progressive JPEG.\n */\n\nMETHODDEF void\nstart_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics)\n{  \n  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;\n  boolean is_DC_band;\n  int ci, tbl;\n  jpeg_component_info * compptr;\n\n  entropy->cinfo = cinfo;\n  entropy->gather_statistics = gather_statistics;\n\n  is_DC_band = (cinfo->Ss == 0);\n\n  /* We assume jcmaster.c already validated the scan parameters. */\n\n  /* Select execution routines */\n  if (cinfo->Ah == 0) {\n    if (is_DC_band)\n      entropy->pub.encode_mcu = encode_mcu_DC_first;\n    else\n      entropy->pub.encode_mcu = encode_mcu_AC_first;\n  } else {\n    if (is_DC_band)\n      entropy->pub.encode_mcu = encode_mcu_DC_refine;\n    else {\n      entropy->pub.encode_mcu = encode_mcu_AC_refine;\n      /* AC refinement needs a correction bit buffer */\n      if (entropy->bit_buffer == NULL)\n\tentropy->bit_buffer = (char *)\n\t  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t      MAX_CORR_BITS * SIZEOF(char));\n    }\n  }\n  if (gather_statistics)\n    entropy->pub.finish_pass = finish_pass_gather_phuff;\n  else\n    entropy->pub.finish_pass = finish_pass_phuff;\n\n  /* Only DC coefficients may be interleaved, so cinfo->comps_in_scan = 1\n   * for AC coefficients.\n   */\n  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n    compptr = cinfo->cur_comp_info[ci];\n    /* Initialize DC predictions to 0 */\n    entropy->last_dc_val[ci] = 0;\n    /* Make sure requested tables are present */\n    /* (In gather mode, tables need not be allocated yet) */\n    if (is_DC_band) {\n      if (cinfo->Ah != 0)\t/* DC refinement needs no table */\n\tcontinue;\n      tbl = compptr->dc_tbl_no;\n      if (tbl < 0 || tbl >= NUM_HUFF_TBLS ||\n\t  (cinfo->dc_huff_tbl_ptrs[tbl] == NULL && !gather_statistics))\n\tERREXIT1(cinfo,JERR_NO_HUFF_TABLE, tbl);\n    } else {\n      entropy->ac_tbl_no = tbl = compptr->ac_tbl_no;\n      if (tbl < 0 || tbl >= NUM_HUFF_TBLS ||\n          (cinfo->ac_huff_tbl_ptrs[tbl] == NULL && !gather_statistics))\n        ERREXIT1(cinfo,JERR_NO_HUFF_TABLE, tbl);\n    }\n    if (gather_statistics) {\n      /* Allocate and zero the statistics tables */\n      /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */\n      if (entropy->count_ptrs[tbl] == NULL)\n\tentropy->count_ptrs[tbl] = (long *)\n\t  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t      257 * SIZEOF(long));\n      MEMZERO(entropy->count_ptrs[tbl], 257 * SIZEOF(long));\n    } else {\n      /* Compute derived values for Huffman tables */\n      /* We may do this more than once for a table, but it's not expensive */\n      if (is_DC_band)\n        jpeg_make_c_derived_tbl(cinfo, cinfo->dc_huff_tbl_ptrs[tbl],\n\t\t\t\t& entropy->derived_tbls[tbl]);\n      else\n        jpeg_make_c_derived_tbl(cinfo, cinfo->ac_huff_tbl_ptrs[tbl],\n\t\t\t\t& entropy->derived_tbls[tbl]);\n    }\n  }\n\n  /* Initialize AC stuff */\n  entropy->EOBRUN = 0;\n  entropy->BE = 0;\n\n  /* Initialize bit buffer to empty */\n  entropy->put_buffer = 0;\n  entropy->put_bits = 0;\n\n  /* Initialize restart stuff */\n  entropy->restarts_to_go = cinfo->restart_interval;\n  entropy->next_restart_num = 0;\n}\n\n\n/* Outputting bytes to the file.\n * NB: these must be called only when actually outputting,\n * that is, entropy->gather_statistics == FALSE.\n */\n\n/* Emit a byte */\n#define emit_byte(entropy,val)  \\\n\t{ *(entropy)->next_output_byte++ = (JOCTET) (val);  \\\n\t  if (--(entropy)->free_in_buffer == 0)  \\\n\t    dump_buffer(entropy); }\n\n\nLOCAL void\ndump_buffer (phuff_entropy_ptr entropy)\n/* Empty the output buffer; we do not support suspension in this module. */\n{\n  struct jpeg_destination_mgr * dest = entropy->cinfo->dest;\n\n  if (! (*dest->empty_output_buffer) (entropy->cinfo))\n    ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND);\n  /* After a successful buffer dump, must reset buffer pointers */\n  entropy->next_output_byte = dest->next_output_byte;\n  entropy->free_in_buffer = dest->free_in_buffer;\n}\n\n\n/* Outputting bits to the file */\n\n/* Only the right 24 bits of put_buffer are used; the valid bits are\n * left-justified in this part.  At most 16 bits can be passed to emit_bits\n * in one call, and we never retain more than 7 bits in put_buffer\n * between calls, so 24 bits are sufficient.\n */\n\nINLINE\nLOCAL void\nemit_bits (phuff_entropy_ptr entropy, unsigned int code, int size)\n/* Emit some bits, unless we are in gather mode */\n{\n  /* This routine is heavily used, so it's worth coding tightly. */\n  register INT32 put_buffer = (INT32) code;\n  register int put_bits = entropy->put_bits;\n\n  /* if size is 0, caller used an invalid Huffman table entry */\n  if (size == 0)\n    ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE);\n\n  if (entropy->gather_statistics)\n    return;\t\t\t/* do nothing if we're only getting stats */\n\n  put_buffer &= (((INT32) 1)<<size) - 1; /* mask off any extra bits in code */\n  \n  put_bits += size;\t\t/* new number of bits in buffer */\n  \n  put_buffer <<= 24 - put_bits; /* align incoming bits */\n\n  put_buffer |= entropy->put_buffer; /* and merge with old buffer contents */\n\n  while (put_bits >= 8) {\n    int c = (int) ((put_buffer >> 16) & 0xFF);\n    \n    emit_byte(entropy, c);\n    if (c == 0xFF) {\t\t/* need to stuff a zero byte? */\n      emit_byte(entropy, 0);\n    }\n    put_buffer <<= 8;\n    put_bits -= 8;\n  }\n\n  entropy->put_buffer = put_buffer; /* update variables */\n  entropy->put_bits = put_bits;\n}\n\n\nLOCAL void\nflush_bits (phuff_entropy_ptr entropy)\n{\n  emit_bits(entropy, 0x7F, 7); /* fill any partial byte with ones */\n  entropy->put_buffer = 0;     /* and reset bit-buffer to empty */\n  entropy->put_bits = 0;\n}\n\n\n/*\n * Emit (or just count) a Huffman symbol.\n */\n\nINLINE\nLOCAL void\nemit_symbol (phuff_entropy_ptr entropy, int tbl_no, int symbol)\n{\n  if (entropy->gather_statistics)\n    entropy->count_ptrs[tbl_no][symbol]++;\n  else {\n    c_derived_tbl * tbl = entropy->derived_tbls[tbl_no];\n    emit_bits(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]);\n  }\n}\n\n\n/*\n * Emit bits from a correction bit buffer.\n */\n\nLOCAL void\nemit_buffered_bits (phuff_entropy_ptr entropy, char * bufstart,\n\t\t    unsigned int nbits)\n{\n  if (entropy->gather_statistics)\n    return;\t\t\t/* no real work */\n\n  while (nbits > 0) {\n    emit_bits(entropy, (unsigned int) (*bufstart), 1);\n    bufstart++;\n    nbits--;\n  }\n}\n\n\n/*\n * Emit any pending EOBRUN symbol.\n */\n\nLOCAL void\nemit_eobrun (phuff_entropy_ptr entropy)\n{\n  register int temp, nbits;\n\n  if (entropy->EOBRUN > 0) {\t/* if there is any pending EOBRUN */\n    temp = entropy->EOBRUN;\n    nbits = 0;\n    while ((temp >>= 1))\n      nbits++;\n\n    emit_symbol(entropy, entropy->ac_tbl_no, nbits << 4);\n    if (nbits)\n      emit_bits(entropy, entropy->EOBRUN, nbits);\n\n    entropy->EOBRUN = 0;\n\n    /* Emit any buffered correction bits */\n    emit_buffered_bits(entropy, entropy->bit_buffer, entropy->BE);\n    entropy->BE = 0;\n  }\n}\n\n\n/*\n * Emit a restart marker & resynchronize predictions.\n */\n\nLOCAL void\nemit_restart (phuff_entropy_ptr entropy, int restart_num)\n{\n  int ci;\n\n  emit_eobrun(entropy);\n\n  if (! entropy->gather_statistics) {\n    flush_bits(entropy);\n    emit_byte(entropy, 0xFF);\n    emit_byte(entropy, JPEG_RST0 + restart_num);\n  }\n\n  if (entropy->cinfo->Ss == 0) {\n    /* Re-initialize DC predictions to 0 */\n    for (ci = 0; ci < entropy->cinfo->comps_in_scan; ci++)\n      entropy->last_dc_val[ci] = 0;\n  } else {\n    /* Re-initialize all AC-related fields to 0 */\n    entropy->EOBRUN = 0;\n    entropy->BE = 0;\n  }\n}\n\n\n/*\n * MCU encoding for DC initial scan (either spectral selection,\n * or first pass of successive approximation).\n */\n\nMETHODDEF boolean\nencode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)\n{\n  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;\n  register int temp, temp2;\n  register int nbits;\n  int blkn, ci;\n  int Al = cinfo->Al;\n  JBLOCKROW block;\n  jpeg_component_info * compptr;\n  ISHIFT_TEMPS\n\n  entropy->next_output_byte = cinfo->dest->next_output_byte;\n  entropy->free_in_buffer = cinfo->dest->free_in_buffer;\n\n  /* Emit restart marker if needed */\n  if (cinfo->restart_interval)\n    if (entropy->restarts_to_go == 0)\n      emit_restart(entropy, entropy->next_restart_num);\n\n  /* Encode the MCU data blocks */\n  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {\n    block = MCU_data[blkn];\n    ci = cinfo->MCU_membership[blkn];\n    compptr = cinfo->cur_comp_info[ci];\n\n    /* Compute the DC value after the required point transform by Al.\n     * This is simply an arithmetic right shift.\n     */\n    temp2 = IRIGHT_SHIFT((int) ((*block)[0]), Al);\n\n    /* DC differences are figured on the point-transformed values. */\n    temp = temp2 - entropy->last_dc_val[ci];\n    entropy->last_dc_val[ci] = temp2;\n\n    /* Encode the DC coefficient difference per section G.1.2.1 */\n    temp2 = temp;\n    if (temp < 0) {\n      temp = -temp;\t\t/* temp is abs value of input */\n      /* For a negative input, want temp2 = bitwise complement of abs(input) */\n      /* This code assumes we are on a two's complement machine */\n      temp2--;\n    }\n    \n    /* Find the number of bits needed for the magnitude of the coefficient */\n    nbits = 0;\n    while (temp) {\n      nbits++;\n      temp >>= 1;\n    }\n    \n    /* Count/emit the Huffman-coded symbol for the number of bits */\n    emit_symbol(entropy, compptr->dc_tbl_no, nbits);\n    \n    /* Emit that number of bits of the value, if positive, */\n    /* or the complement of its magnitude, if negative. */\n    if (nbits)\t\t\t/* emit_bits rejects calls with size 0 */\n      emit_bits(entropy, (unsigned int) temp2, nbits);\n  }\n\n  cinfo->dest->next_output_byte = entropy->next_output_byte;\n  cinfo->dest->free_in_buffer = entropy->free_in_buffer;\n\n  /* Update restart-interval state too */\n  if (cinfo->restart_interval) {\n    if (entropy->restarts_to_go == 0) {\n      entropy->restarts_to_go = cinfo->restart_interval;\n      entropy->next_restart_num++;\n      entropy->next_restart_num &= 7;\n    }\n    entropy->restarts_to_go--;\n  }\n\n  return TRUE;\n}\n\n\n/*\n * MCU encoding for AC initial scan (either spectral selection,\n * or first pass of successive approximation).\n */\n\nMETHODDEF boolean\nencode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)\n{\n  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;\n  register int temp, temp2;\n  register int nbits;\n  register int r, k;\n  int Se = cinfo->Se;\n  int Al = cinfo->Al;\n  JBLOCKROW block;\n\n  entropy->next_output_byte = cinfo->dest->next_output_byte;\n  entropy->free_in_buffer = cinfo->dest->free_in_buffer;\n\n  /* Emit restart marker if needed */\n  if (cinfo->restart_interval)\n    if (entropy->restarts_to_go == 0)\n      emit_restart(entropy, entropy->next_restart_num);\n\n  /* Encode the MCU data block */\n  block = MCU_data[0];\n\n  /* Encode the AC coefficients per section G.1.2.2, fig. G.3 */\n  \n  r = 0;\t\t\t/* r = run length of zeros */\n   \n  for (k = cinfo->Ss; k <= Se; k++) {\n    if ((temp = (*block)[jpeg_natural_order[k]]) == 0) {\n      r++;\n      continue;\n    }\n    /* We must apply the point transform by Al.  For AC coefficients this\n     * is an integer division with rounding towards 0.  To do this portably\n     * in C, we shift after obtaining the absolute value; so the code is\n     * interwoven with finding the abs value (temp) and output bits (temp2).\n     */\n    if (temp < 0) {\n      temp = -temp;\t\t/* temp is abs value of input */\n      temp >>= Al;\t\t/* apply the point transform */\n      /* For a negative coef, want temp2 = bitwise complement of abs(coef) */\n      temp2 = ~temp;\n    } else {\n      temp >>= Al;\t\t/* apply the point transform */\n      temp2 = temp;\n    }\n    /* Watch out for case that nonzero coef is zero after point transform */\n    if (temp == 0) {\n      r++;\n      continue;\n    }\n\n    /* Emit any pending EOBRUN */\n    if (entropy->EOBRUN > 0)\n      emit_eobrun(entropy);\n    /* if run length > 15, must emit special run-length-16 codes (0xF0) */\n    while (r > 15) {\n      emit_symbol(entropy, entropy->ac_tbl_no, 0xF0);\n      r -= 16;\n    }\n\n    /* Find the number of bits needed for the magnitude of the coefficient */\n    nbits = 1;\t\t\t/* there must be at least one 1 bit */\n    while ((temp >>= 1))\n      nbits++;\n\n    /* Count/emit Huffman symbol for run length / number of bits */\n    emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + nbits);\n\n    /* Emit that number of bits of the value, if positive, */\n    /* or the complement of its magnitude, if negative. */\n    emit_bits(entropy, (unsigned int) temp2, nbits);\n\n    r = 0;\t\t\t/* reset zero run length */\n  }\n\n  if (r > 0) {\t\t\t/* If there are trailing zeroes, */\n    entropy->EOBRUN++;\t\t/* count an EOB */\n    if (entropy->EOBRUN == 0x7FFF)\n      emit_eobrun(entropy);\t/* force it out to avoid overflow */\n  }\n\n  cinfo->dest->next_output_byte = entropy->next_output_byte;\n  cinfo->dest->free_in_buffer = entropy->free_in_buffer;\n\n  /* Update restart-interval state too */\n  if (cinfo->restart_interval) {\n    if (entropy->restarts_to_go == 0) {\n      entropy->restarts_to_go = cinfo->restart_interval;\n      entropy->next_restart_num++;\n      entropy->next_restart_num &= 7;\n    }\n    entropy->restarts_to_go--;\n  }\n\n  return TRUE;\n}\n\n\n/*\n * MCU encoding for DC successive approximation refinement scan.\n * Note: we assume such scans can be multi-component, although the spec\n * is not very clear on the point.\n */\n\nMETHODDEF boolean\nencode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)\n{\n  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;\n  register int temp;\n  int blkn;\n  int Al = cinfo->Al;\n  JBLOCKROW block;\n\n  entropy->next_output_byte = cinfo->dest->next_output_byte;\n  entropy->free_in_buffer = cinfo->dest->free_in_buffer;\n\n  /* Emit restart marker if needed */\n  if (cinfo->restart_interval)\n    if (entropy->restarts_to_go == 0)\n      emit_restart(entropy, entropy->next_restart_num);\n\n  /* Encode the MCU data blocks */\n  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {\n    block = MCU_data[blkn];\n\n    /* We simply emit the Al'th bit of the DC coefficient value. */\n    temp = (*block)[0];\n    emit_bits(entropy, (unsigned int) (temp >> Al), 1);\n  }\n\n  cinfo->dest->next_output_byte = entropy->next_output_byte;\n  cinfo->dest->free_in_buffer = entropy->free_in_buffer;\n\n  /* Update restart-interval state too */\n  if (cinfo->restart_interval) {\n    if (entropy->restarts_to_go == 0) {\n      entropy->restarts_to_go = cinfo->restart_interval;\n      entropy->next_restart_num++;\n      entropy->next_restart_num &= 7;\n    }\n    entropy->restarts_to_go--;\n  }\n\n  return TRUE;\n}\n\n\n/*\n * MCU encoding for AC successive approximation refinement scan.\n */\n\nMETHODDEF boolean\nencode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)\n{\n  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;\n  register int temp;\n  register int r, k;\n  int EOB;\n  char *BR_buffer;\n  unsigned int BR;\n  int Se = cinfo->Se;\n  int Al = cinfo->Al;\n  JBLOCKROW block;\n  int absvalues[DCTSIZE2];\n\n  entropy->next_output_byte = cinfo->dest->next_output_byte;\n  entropy->free_in_buffer = cinfo->dest->free_in_buffer;\n\n  /* Emit restart marker if needed */\n  if (cinfo->restart_interval)\n    if (entropy->restarts_to_go == 0)\n      emit_restart(entropy, entropy->next_restart_num);\n\n  /* Encode the MCU data block */\n  block = MCU_data[0];\n\n  /* It is convenient to make a pre-pass to determine the transformed\n   * coefficients' absolute values and the EOB position.\n   */\n  EOB = 0;\n  for (k = cinfo->Ss; k <= Se; k++) {\n    temp = (*block)[jpeg_natural_order[k]];\n    /* We must apply the point transform by Al.  For AC coefficients this\n     * is an integer division with rounding towards 0.  To do this portably\n     * in C, we shift after obtaining the absolute value.\n     */\n    if (temp < 0)\n      temp = -temp;\t\t/* temp is abs value of input */\n    temp >>= Al;\t\t/* apply the point transform */\n    absvalues[k] = temp;\t/* save abs value for main pass */\n    if (temp == 1)\n      EOB = k;\t\t\t/* EOB = index of last newly-nonzero coef */\n  }\n\n  /* Encode the AC coefficients per section G.1.2.3, fig. G.7 */\n  \n  r = 0;\t\t\t/* r = run length of zeros */\n  BR = 0;\t\t\t/* BR = count of buffered bits added now */\n  BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */\n\n  for (k = cinfo->Ss; k <= Se; k++) {\n    if ((temp = absvalues[k]) == 0) {\n      r++;\n      continue;\n    }\n\n    /* Emit any required ZRLs, but not if they can be folded into EOB */\n    while (r > 15 && k <= EOB) {\n      /* emit any pending EOBRUN and the BE correction bits */\n      emit_eobrun(entropy);\n      /* Emit ZRL */\n      emit_symbol(entropy, entropy->ac_tbl_no, 0xF0);\n      r -= 16;\n      /* Emit buffered correction bits that must be associated with ZRL */\n      emit_buffered_bits(entropy, BR_buffer, BR);\n      BR_buffer = entropy->bit_buffer; /* BE bits are gone now */\n      BR = 0;\n    }\n\n    /* If the coef was previously nonzero, it only needs a correction bit.\n     * NOTE: a straight translation of the spec's figure G.7 would suggest\n     * that we also need to test r > 15.  But if r > 15, we can only get here\n     * if k > EOB, which implies that this coefficient is not 1.\n     */\n    if (temp > 1) {\n      /* The correction bit is the next bit of the absolute value. */\n      BR_buffer[BR++] = (char) (temp & 1);\n      continue;\n    }\n\n    /* Emit any pending EOBRUN and the BE correction bits */\n    emit_eobrun(entropy);\n\n    /* Count/emit Huffman symbol for run length / number of bits */\n    emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + 1);\n\n    /* Emit output bit for newly-nonzero coef */\n    temp = ((*block)[jpeg_natural_order[k]] < 0) ? 0 : 1;\n    emit_bits(entropy, (unsigned int) temp, 1);\n\n    /* Emit buffered correction bits that must be associated with this code */\n    emit_buffered_bits(entropy, BR_buffer, BR);\n    BR_buffer = entropy->bit_buffer; /* BE bits are gone now */\n    BR = 0;\n    r = 0;\t\t\t/* reset zero run length */\n  }\n\n  if (r > 0 || BR > 0) {\t/* If there are trailing zeroes, */\n    entropy->EOBRUN++;\t\t/* count an EOB */\n    entropy->BE += BR;\t\t/* concat my correction bits to older ones */\n    /* We force out the EOB if we risk either:\n     * 1. overflow of the EOB counter;\n     * 2. overflow of the correction bit buffer during the next MCU.\n     */\n    if (entropy->EOBRUN == 0x7FFF || entropy->BE > (MAX_CORR_BITS-DCTSIZE2+1))\n      emit_eobrun(entropy);\n  }\n\n  cinfo->dest->next_output_byte = entropy->next_output_byte;\n  cinfo->dest->free_in_buffer = entropy->free_in_buffer;\n\n  /* Update restart-interval state too */\n  if (cinfo->restart_interval) {\n    if (entropy->restarts_to_go == 0) {\n      entropy->restarts_to_go = cinfo->restart_interval;\n      entropy->next_restart_num++;\n      entropy->next_restart_num &= 7;\n    }\n    entropy->restarts_to_go--;\n  }\n\n  return TRUE;\n}\n\n\n/*\n * Finish up at the end of a Huffman-compressed progressive scan.\n */\n\nMETHODDEF void\nfinish_pass_phuff (j_compress_ptr cinfo)\n{   \n  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;\n\n  entropy->next_output_byte = cinfo->dest->next_output_byte;\n  entropy->free_in_buffer = cinfo->dest->free_in_buffer;\n\n  /* Flush out any buffered data */\n  emit_eobrun(entropy);\n  flush_bits(entropy);\n\n  cinfo->dest->next_output_byte = entropy->next_output_byte;\n  cinfo->dest->free_in_buffer = entropy->free_in_buffer;\n}\n\n\n/*\n * Finish up a statistics-gathering pass and create the new Huffman tables.\n */\n\nMETHODDEF void\nfinish_pass_gather_phuff (j_compress_ptr cinfo)\n{\n  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;\n  boolean is_DC_band;\n  int ci, tbl;\n  jpeg_component_info * compptr;\n  JHUFF_TBL **htblptr;\n  boolean did[NUM_HUFF_TBLS];\n\n  /* Flush out buffered data (all we care about is counting the EOB symbol) */\n  emit_eobrun(entropy);\n\n  is_DC_band = (cinfo->Ss == 0);\n\n  /* It's important not to apply jpeg_gen_optimal_table more than once\n   * per table, because it clobbers the input frequency counts!\n   */\n  MEMZERO(did, SIZEOF(did));\n\n  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n    compptr = cinfo->cur_comp_info[ci];\n    if (is_DC_band) {\n      if (cinfo->Ah != 0)\t/* DC refinement needs no table */\n\tcontinue;\n      tbl = compptr->dc_tbl_no;\n    } else {\n      tbl = compptr->ac_tbl_no;\n    }\n    if (! did[tbl]) {\n      if (is_DC_band)\n        htblptr = & cinfo->dc_huff_tbl_ptrs[tbl];\n      else\n        htblptr = & cinfo->ac_huff_tbl_ptrs[tbl];\n      if (*htblptr == NULL)\n        *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);\n      jpeg_gen_optimal_table(cinfo, *htblptr, entropy->count_ptrs[tbl]);\n      did[tbl] = TRUE;\n    }\n  }\n}\n\n\n/*\n * Module initialization routine for progressive Huffman entropy encoding.\n */\n\nGLOBAL void\njinit_phuff_encoder (j_compress_ptr cinfo)\n{\n  phuff_entropy_ptr entropy;\n  int i;\n\n  entropy = (phuff_entropy_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(phuff_entropy_encoder));\n  cinfo->entropy = (struct jpeg_entropy_encoder *) entropy;\n  entropy->pub.start_pass = start_pass_phuff;\n\n  /* Mark tables unallocated */\n  for (i = 0; i < NUM_HUFF_TBLS; i++) {\n    entropy->derived_tbls[i] = NULL;\n    entropy->count_ptrs[i] = NULL;\n  }\n  entropy->bit_buffer = NULL;\t/* needed only in AC refinement scan */\n}\n\n#endif /* C_PROGRESSIVE_SUPPORTED */\n"
  },
  {
    "path": "code/jpeg-6/jcprepct.c",
    "content": "/*\n * jcprepct.c\n *\n * Copyright (C) 1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains the compression preprocessing controller.\n * This controller manages the color conversion, downsampling,\n * and edge expansion steps.\n *\n * Most of the complexity here is associated with buffering input rows\n * as required by the downsampler.  See the comments at the head of\n * jcsample.c for the downsampler's needs.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/* At present, jcsample.c can request context rows only for smoothing.\n * In the future, we might also need context rows for CCIR601 sampling\n * or other more-complex downsampling procedures.  The code to support\n * context rows should be compiled only if needed.\n */\n#ifdef INPUT_SMOOTHING_SUPPORTED\n#define CONTEXT_ROWS_SUPPORTED\n#endif\n\n\n/*\n * For the simple (no-context-row) case, we just need to buffer one\n * row group's worth of pixels for the downsampling step.  At the bottom of\n * the image, we pad to a full row group by replicating the last pixel row.\n * The downsampler's last output row is then replicated if needed to pad\n * out to a full iMCU row.\n *\n * When providing context rows, we must buffer three row groups' worth of\n * pixels.  Three row groups are physically allocated, but the row pointer\n * arrays are made five row groups high, with the extra pointers above and\n * below \"wrapping around\" to point to the last and first real row groups.\n * This allows the downsampler to access the proper context rows.\n * At the top and bottom of the image, we create dummy context rows by\n * copying the first or last real pixel row.  This copying could be avoided\n * by pointer hacking as is done in jdmainct.c, but it doesn't seem worth the\n * trouble on the compression side.\n */\n\n\n/* Private buffer controller object */\n\ntypedef struct {\n  struct jpeg_c_prep_controller pub; /* public fields */\n\n  /* Downsampling input buffer.  This buffer holds color-converted data\n   * until we have enough to do a downsample step.\n   */\n  JSAMPARRAY color_buf[MAX_COMPONENTS];\n\n  JDIMENSION rows_to_go;\t/* counts rows remaining in source image */\n  int next_buf_row;\t\t/* index of next row to store in color_buf */\n\n#ifdef CONTEXT_ROWS_SUPPORTED\t/* only needed for context case */\n  int this_row_group;\t\t/* starting row index of group to process */\n  int next_buf_stop;\t\t/* downsample when we reach this index */\n#endif\n} my_prep_controller;\n\ntypedef my_prep_controller * my_prep_ptr;\n\n\n/*\n * Initialize for a processing pass.\n */\n\nMETHODDEF void\nstart_pass_prep (j_compress_ptr cinfo, J_BUF_MODE pass_mode)\n{\n  my_prep_ptr prep = (my_prep_ptr) cinfo->prep;\n\n  if (pass_mode != JBUF_PASS_THRU)\n    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n\n  /* Initialize total-height counter for detecting bottom of image */\n  prep->rows_to_go = cinfo->image_height;\n  /* Mark the conversion buffer empty */\n  prep->next_buf_row = 0;\n#ifdef CONTEXT_ROWS_SUPPORTED\n  /* Preset additional state variables for context mode.\n   * These aren't used in non-context mode, so we needn't test which mode.\n   */\n  prep->this_row_group = 0;\n  /* Set next_buf_stop to stop after two row groups have been read in. */\n  prep->next_buf_stop = 2 * cinfo->max_v_samp_factor;\n#endif\n}\n\n\n/*\n * Expand an image vertically from height input_rows to height output_rows,\n * by duplicating the bottom row.\n */\n\nLOCAL void\nexpand_bottom_edge (JSAMPARRAY image_data, JDIMENSION num_cols,\n\t\t    int input_rows, int output_rows)\n{\n  register int row;\n\n  for (row = input_rows; row < output_rows; row++) {\n    jcopy_sample_rows(image_data, input_rows-1, image_data, row,\n\t\t      1, num_cols);\n  }\n}\n\n\n/*\n * Process some data in the simple no-context case.\n *\n * Preprocessor output data is counted in \"row groups\".  A row group\n * is defined to be v_samp_factor sample rows of each component.\n * Downsampling will produce this much data from each max_v_samp_factor\n * input rows.\n */\n\nMETHODDEF void\npre_process_data (j_compress_ptr cinfo,\n\t\t  JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,\n\t\t  JDIMENSION in_rows_avail,\n\t\t  JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr,\n\t\t  JDIMENSION out_row_groups_avail)\n{\n  my_prep_ptr prep = (my_prep_ptr) cinfo->prep;\n  int numrows, ci;\n  JDIMENSION inrows;\n  jpeg_component_info * compptr;\n\n  while (*in_row_ctr < in_rows_avail &&\n\t *out_row_group_ctr < out_row_groups_avail) {\n    /* Do color conversion to fill the conversion buffer. */\n    inrows = in_rows_avail - *in_row_ctr;\n    numrows = cinfo->max_v_samp_factor - prep->next_buf_row;\n    numrows = (int) MIN((JDIMENSION) numrows, inrows);\n    (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr,\n\t\t\t\t       prep->color_buf,\n\t\t\t\t       (JDIMENSION) prep->next_buf_row,\n\t\t\t\t       numrows);\n    *in_row_ctr += numrows;\n    prep->next_buf_row += numrows;\n    prep->rows_to_go -= numrows;\n    /* If at bottom of image, pad to fill the conversion buffer. */\n    if (prep->rows_to_go == 0 &&\n\tprep->next_buf_row < cinfo->max_v_samp_factor) {\n      for (ci = 0; ci < cinfo->num_components; ci++) {\n\texpand_bottom_edge(prep->color_buf[ci], cinfo->image_width,\n\t\t\t   prep->next_buf_row, cinfo->max_v_samp_factor);\n      }\n      prep->next_buf_row = cinfo->max_v_samp_factor;\n    }\n    /* If we've filled the conversion buffer, empty it. */\n    if (prep->next_buf_row == cinfo->max_v_samp_factor) {\n      (*cinfo->downsample->downsample) (cinfo,\n\t\t\t\t\tprep->color_buf, (JDIMENSION) 0,\n\t\t\t\t\toutput_buf, *out_row_group_ctr);\n      prep->next_buf_row = 0;\n      (*out_row_group_ctr)++;\n    }\n    /* If at bottom of image, pad the output to a full iMCU height.\n     * Note we assume the caller is providing a one-iMCU-height output buffer!\n     */\n    if (prep->rows_to_go == 0 &&\n\t*out_row_group_ctr < out_row_groups_avail) {\n      for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n\t   ci++, compptr++) {\n\texpand_bottom_edge(output_buf[ci],\n\t\t\t   compptr->width_in_blocks * DCTSIZE,\n\t\t\t   (int) (*out_row_group_ctr * compptr->v_samp_factor),\n\t\t\t   (int) (out_row_groups_avail * compptr->v_samp_factor));\n      }\n      *out_row_group_ctr = out_row_groups_avail;\n      break;\t\t\t/* can exit outer loop without test */\n    }\n  }\n}\n\n\n#ifdef CONTEXT_ROWS_SUPPORTED\n\n/*\n * Process some data in the context case.\n */\n\nMETHODDEF void\npre_process_context (j_compress_ptr cinfo,\n\t\t     JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,\n\t\t     JDIMENSION in_rows_avail,\n\t\t     JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr,\n\t\t     JDIMENSION out_row_groups_avail)\n{\n  my_prep_ptr prep = (my_prep_ptr) cinfo->prep;\n  int numrows, ci;\n  int buf_height = cinfo->max_v_samp_factor * 3;\n  JDIMENSION inrows;\n  jpeg_component_info * compptr;\n\n  while (*out_row_group_ctr < out_row_groups_avail) {\n    if (*in_row_ctr < in_rows_avail) {\n      /* Do color conversion to fill the conversion buffer. */\n      inrows = in_rows_avail - *in_row_ctr;\n      numrows = prep->next_buf_stop - prep->next_buf_row;\n      numrows = (int) MIN((JDIMENSION) numrows, inrows);\n      (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr,\n\t\t\t\t\t prep->color_buf,\n\t\t\t\t\t (JDIMENSION) prep->next_buf_row,\n\t\t\t\t\t numrows);\n      /* Pad at top of image, if first time through */\n      if (prep->rows_to_go == cinfo->image_height) {\n\tfor (ci = 0; ci < cinfo->num_components; ci++) {\n\t  int row;\n\t  for (row = 1; row <= cinfo->max_v_samp_factor; row++) {\n\t    jcopy_sample_rows(prep->color_buf[ci], 0,\n\t\t\t      prep->color_buf[ci], -row,\n\t\t\t      1, cinfo->image_width);\n\t  }\n\t}\n      }\n      *in_row_ctr += numrows;\n      prep->next_buf_row += numrows;\n      prep->rows_to_go -= numrows;\n    } else {\n      /* Return for more data, unless we are at the bottom of the image. */\n      if (prep->rows_to_go != 0)\n\tbreak;\n    }\n    /* If at bottom of image, pad to fill the conversion buffer. */\n    if (prep->rows_to_go == 0 &&\n\tprep->next_buf_row < prep->next_buf_stop) {\n      for (ci = 0; ci < cinfo->num_components; ci++) {\n\texpand_bottom_edge(prep->color_buf[ci], cinfo->image_width,\n\t\t\t   prep->next_buf_row, prep->next_buf_stop);\n      }\n      prep->next_buf_row = prep->next_buf_stop;\n    }\n    /* If we've gotten enough data, downsample a row group. */\n    if (prep->next_buf_row == prep->next_buf_stop) {\n      (*cinfo->downsample->downsample) (cinfo,\n\t\t\t\t\tprep->color_buf,\n\t\t\t\t\t(JDIMENSION) prep->this_row_group,\n\t\t\t\t\toutput_buf, *out_row_group_ctr);\n      (*out_row_group_ctr)++;\n      /* Advance pointers with wraparound as necessary. */\n      prep->this_row_group += cinfo->max_v_samp_factor;\n      if (prep->this_row_group >= buf_height)\n\tprep->this_row_group = 0;\n      if (prep->next_buf_row >= buf_height)\n\tprep->next_buf_row = 0;\n      prep->next_buf_stop = prep->next_buf_row + cinfo->max_v_samp_factor;\n    }\n    /* If at bottom of image, pad the output to a full iMCU height.\n     * Note we assume the caller is providing a one-iMCU-height output buffer!\n     */\n    if (prep->rows_to_go == 0 &&\n\t*out_row_group_ctr < out_row_groups_avail) {\n      for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n\t   ci++, compptr++) {\n\texpand_bottom_edge(output_buf[ci],\n\t\t\t   compptr->width_in_blocks * DCTSIZE,\n\t\t\t   (int) (*out_row_group_ctr * compptr->v_samp_factor),\n\t\t\t   (int) (out_row_groups_avail * compptr->v_samp_factor));\n      }\n      *out_row_group_ctr = out_row_groups_avail;\n      break;\t\t\t/* can exit outer loop without test */\n    }\n  }\n}\n\n\n/*\n * Create the wrapped-around downsampling input buffer needed for context mode.\n */\n\nLOCAL void\ncreate_context_buffer (j_compress_ptr cinfo)\n{\n  my_prep_ptr prep = (my_prep_ptr) cinfo->prep;\n  int rgroup_height = cinfo->max_v_samp_factor;\n  int ci, i;\n  jpeg_component_info * compptr;\n  JSAMPARRAY true_buffer, fake_buffer;\n\n  /* Grab enough space for fake row pointers for all the components;\n   * we need five row groups' worth of pointers for each component.\n   */\n  fake_buffer = (JSAMPARRAY)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t(cinfo->num_components * 5 * rgroup_height) *\n\t\t\t\tSIZEOF(JSAMPROW));\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    /* Allocate the actual buffer space (3 row groups) for this component.\n     * We make the buffer wide enough to allow the downsampler to edge-expand\n     * horizontally within the buffer, if it so chooses.\n     */\n    true_buffer = (*cinfo->mem->alloc_sarray)\n      ((j_common_ptr) cinfo, JPOOL_IMAGE,\n       (JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE *\n\t\t      cinfo->max_h_samp_factor) / compptr->h_samp_factor),\n       (JDIMENSION) (3 * rgroup_height));\n    /* Copy true buffer row pointers into the middle of the fake row array */\n    MEMCOPY(fake_buffer + rgroup_height, true_buffer,\n\t    3 * rgroup_height * SIZEOF(JSAMPROW));\n    /* Fill in the above and below wraparound pointers */\n    for (i = 0; i < rgroup_height; i++) {\n      fake_buffer[i] = true_buffer[2 * rgroup_height + i];\n      fake_buffer[4 * rgroup_height + i] = true_buffer[i];\n    }\n    prep->color_buf[ci] = fake_buffer + rgroup_height;\n    fake_buffer += 5 * rgroup_height; /* point to space for next component */\n  }\n}\n\n#endif /* CONTEXT_ROWS_SUPPORTED */\n\n\n/*\n * Initialize preprocessing controller.\n */\n\nGLOBAL void\njinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer)\n{\n  my_prep_ptr prep;\n  int ci;\n  jpeg_component_info * compptr;\n\n  if (need_full_buffer)\t\t/* safety check */\n    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n\n  prep = (my_prep_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_prep_controller));\n  cinfo->prep = (struct jpeg_c_prep_controller *) prep;\n  prep->pub.start_pass = start_pass_prep;\n\n  /* Allocate the color conversion buffer.\n   * We make the buffer wide enough to allow the downsampler to edge-expand\n   * horizontally within the buffer, if it so chooses.\n   */\n  if (cinfo->downsample->need_context_rows) {\n    /* Set up to provide context rows */\n#ifdef CONTEXT_ROWS_SUPPORTED\n    prep->pub.pre_process_data = pre_process_context;\n    create_context_buffer(cinfo);\n#else\n    ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif\n  } else {\n    /* No context, just make it tall enough for one row group */\n    prep->pub.pre_process_data = pre_process_data;\n    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n\t ci++, compptr++) {\n      prep->color_buf[ci] = (*cinfo->mem->alloc_sarray)\n\t((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t (JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE *\n\t\t\tcinfo->max_h_samp_factor) / compptr->h_samp_factor),\n\t (JDIMENSION) cinfo->max_v_samp_factor);\n    }\n  }\n}\n"
  },
  {
    "path": "code/jpeg-6/jcsample.c",
    "content": "/*\n * jcsample.c\n *\n * Copyright (C) 1991-1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains downsampling routines.\n *\n * Downsampling input data is counted in \"row groups\".  A row group\n * is defined to be max_v_samp_factor pixel rows of each component,\n * from which the downsampler produces v_samp_factor sample rows.\n * A single row group is processed in each call to the downsampler module.\n *\n * The downsampler is responsible for edge-expansion of its output data\n * to fill an integral number of DCT blocks horizontally.  The source buffer\n * may be modified if it is helpful for this purpose (the source buffer is\n * allocated wide enough to correspond to the desired output width).\n * The caller (the prep controller) is responsible for vertical padding.\n *\n * The downsampler may request \"context rows\" by setting need_context_rows\n * during startup.  In this case, the input arrays will contain at least\n * one row group's worth of pixels above and below the passed-in data;\n * the caller will create dummy rows at image top and bottom by replicating\n * the first or last real pixel row.\n *\n * An excellent reference for image resampling is\n *   Digital Image Warping, George Wolberg, 1990.\n *   Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7.\n *\n * The downsampling algorithm used here is a simple average of the source\n * pixels covered by the output pixel.  The hi-falutin sampling literature\n * refers to this as a \"box filter\".  In general the characteristics of a box\n * filter are not very good, but for the specific cases we normally use (1:1\n * and 2:1 ratios) the box is equivalent to a \"triangle filter\" which is not\n * nearly so bad.  If you intend to use other sampling ratios, you'd be well\n * advised to improve this code.\n *\n * A simple input-smoothing capability is provided.  This is mainly intended\n * for cleaning up color-dithered GIF input files (if you find it inadequate,\n * we suggest using an external filtering program such as pnmconvol).  When\n * enabled, each input pixel P is replaced by a weighted sum of itself and its\n * eight neighbors.  P's weight is 1-8*SF and each neighbor's weight is SF,\n * where SF = (smoothing_factor / 1024).\n * Currently, smoothing is only supported for 2h2v sampling factors.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/* Pointer to routine to downsample a single component */\ntypedef JMETHOD(void, downsample1_ptr,\n\t\t(j_compress_ptr cinfo, jpeg_component_info * compptr,\n\t\t JSAMPARRAY input_data, JSAMPARRAY output_data));\n\n/* Private subobject */\n\ntypedef struct {\n  struct jpeg_downsampler pub;\t/* public fields */\n\n  /* Downsampling method pointers, one per component */\n  downsample1_ptr methods[MAX_COMPONENTS];\n} my_downsampler;\n\ntypedef my_downsampler * my_downsample_ptr;\n\n\n/*\n * Initialize for a downsampling pass.\n */\n\nMETHODDEF void\nstart_pass_downsample (j_compress_ptr cinfo)\n{\n  /* no work for now */\n}\n\n\n/*\n * Expand a component horizontally from width input_cols to width output_cols,\n * by duplicating the rightmost samples.\n */\n\nLOCAL void\nexpand_right_edge (JSAMPARRAY image_data, int num_rows,\n\t\t   JDIMENSION input_cols, JDIMENSION output_cols)\n{\n  register JSAMPROW ptr;\n  register JSAMPLE pixval;\n  register int count;\n  int row;\n  int numcols = (int) (output_cols - input_cols);\n\n  if (numcols > 0) {\n    for (row = 0; row < num_rows; row++) {\n      ptr = image_data[row] + input_cols;\n      pixval = ptr[-1];\t\t/* don't need GETJSAMPLE() here */\n      for (count = numcols; count > 0; count--)\n\t*ptr++ = pixval;\n    }\n  }\n}\n\n\n/*\n * Do downsampling for a whole row group (all components).\n *\n * In this version we simply downsample each component independently.\n */\n\nMETHODDEF void\nsep_downsample (j_compress_ptr cinfo,\n\t\tJSAMPIMAGE input_buf, JDIMENSION in_row_index,\n\t\tJSAMPIMAGE output_buf, JDIMENSION out_row_group_index)\n{\n  my_downsample_ptr downsample = (my_downsample_ptr) cinfo->downsample;\n  int ci;\n  jpeg_component_info * compptr;\n  JSAMPARRAY in_ptr, out_ptr;\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    in_ptr = input_buf[ci] + in_row_index;\n    out_ptr = output_buf[ci] + (out_row_group_index * compptr->v_samp_factor);\n    (*downsample->methods[ci]) (cinfo, compptr, in_ptr, out_ptr);\n  }\n}\n\n\n/*\n * Downsample pixel values of a single component.\n * One row group is processed per call.\n * This version handles arbitrary integral sampling ratios, without smoothing.\n * Note that this version is not actually used for customary sampling ratios.\n */\n\nMETHODDEF void\nint_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,\n\t\tJSAMPARRAY input_data, JSAMPARRAY output_data)\n{\n  int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v;\n  JDIMENSION outcol, outcol_h;\t/* outcol_h == outcol*h_expand */\n  JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;\n  JSAMPROW inptr, outptr;\n  INT32 outvalue;\n\n  h_expand = cinfo->max_h_samp_factor / compptr->h_samp_factor;\n  v_expand = cinfo->max_v_samp_factor / compptr->v_samp_factor;\n  numpix = h_expand * v_expand;\n  numpix2 = numpix/2;\n\n  /* Expand input data enough to let all the output samples be generated\n   * by the standard loop.  Special-casing padded output would be more\n   * efficient.\n   */\n  expand_right_edge(input_data, cinfo->max_v_samp_factor,\n\t\t    cinfo->image_width, output_cols * h_expand);\n\n  inrow = 0;\n  for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {\n    outptr = output_data[outrow];\n    for (outcol = 0, outcol_h = 0; outcol < output_cols;\n\t outcol++, outcol_h += h_expand) {\n      outvalue = 0;\n      for (v = 0; v < v_expand; v++) {\n\tinptr = input_data[inrow+v] + outcol_h;\n\tfor (h = 0; h < h_expand; h++) {\n\t  outvalue += (INT32) GETJSAMPLE(*inptr++);\n\t}\n      }\n      *outptr++ = (JSAMPLE) ((outvalue + numpix2) / numpix);\n    }\n    inrow += v_expand;\n  }\n}\n\n\n/*\n * Downsample pixel values of a single component.\n * This version handles the special case of a full-size component,\n * without smoothing.\n */\n\nMETHODDEF void\nfullsize_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,\n\t\t     JSAMPARRAY input_data, JSAMPARRAY output_data)\n{\n  /* Copy the data */\n  jcopy_sample_rows(input_data, 0, output_data, 0,\n\t\t    cinfo->max_v_samp_factor, cinfo->image_width);\n  /* Edge-expand */\n  expand_right_edge(output_data, cinfo->max_v_samp_factor,\n\t\t    cinfo->image_width, compptr->width_in_blocks * DCTSIZE);\n}\n\n\n/*\n * Downsample pixel values of a single component.\n * This version handles the common case of 2:1 horizontal and 1:1 vertical,\n * without smoothing.\n *\n * A note about the \"bias\" calculations: when rounding fractional values to\n * integer, we do not want to always round 0.5 up to the next integer.\n * If we did that, we'd introduce a noticeable bias towards larger values.\n * Instead, this code is arranged so that 0.5 will be rounded up or down at\n * alternate pixel locations (a simple ordered dither pattern).\n */\n\nMETHODDEF void\nh2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,\n\t\t JSAMPARRAY input_data, JSAMPARRAY output_data)\n{\n  int outrow;\n  JDIMENSION outcol;\n  JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;\n  register JSAMPROW inptr, outptr;\n  register int bias;\n\n  /* Expand input data enough to let all the output samples be generated\n   * by the standard loop.  Special-casing padded output would be more\n   * efficient.\n   */\n  expand_right_edge(input_data, cinfo->max_v_samp_factor,\n\t\t    cinfo->image_width, output_cols * 2);\n\n  for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {\n    outptr = output_data[outrow];\n    inptr = input_data[outrow];\n    bias = 0;\t\t\t/* bias = 0,1,0,1,... for successive samples */\n    for (outcol = 0; outcol < output_cols; outcol++) {\n      *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr) + GETJSAMPLE(inptr[1])\n\t\t\t      + bias) >> 1);\n      bias ^= 1;\t\t/* 0=>1, 1=>0 */\n      inptr += 2;\n    }\n  }\n}\n\n\n/*\n * Downsample pixel values of a single component.\n * This version handles the standard case of 2:1 horizontal and 2:1 vertical,\n * without smoothing.\n */\n\nMETHODDEF void\nh2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,\n\t\t JSAMPARRAY input_data, JSAMPARRAY output_data)\n{\n  int inrow, outrow;\n  JDIMENSION outcol;\n  JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;\n  register JSAMPROW inptr0, inptr1, outptr;\n  register int bias;\n\n  /* Expand input data enough to let all the output samples be generated\n   * by the standard loop.  Special-casing padded output would be more\n   * efficient.\n   */\n  expand_right_edge(input_data, cinfo->max_v_samp_factor,\n\t\t    cinfo->image_width, output_cols * 2);\n\n  inrow = 0;\n  for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {\n    outptr = output_data[outrow];\n    inptr0 = input_data[inrow];\n    inptr1 = input_data[inrow+1];\n    bias = 1;\t\t\t/* bias = 1,2,1,2,... for successive samples */\n    for (outcol = 0; outcol < output_cols; outcol++) {\n      *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) +\n\t\t\t      GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1])\n\t\t\t      + bias) >> 2);\n      bias ^= 3;\t\t/* 1=>2, 2=>1 */\n      inptr0 += 2; inptr1 += 2;\n    }\n    inrow += 2;\n  }\n}\n\n\n#ifdef INPUT_SMOOTHING_SUPPORTED\n\n/*\n * Downsample pixel values of a single component.\n * This version handles the standard case of 2:1 horizontal and 2:1 vertical,\n * with smoothing.  One row of context is required.\n */\n\nMETHODDEF void\nh2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,\n\t\t\tJSAMPARRAY input_data, JSAMPARRAY output_data)\n{\n  int inrow, outrow;\n  JDIMENSION colctr;\n  JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;\n  register JSAMPROW inptr0, inptr1, above_ptr, below_ptr, outptr;\n  INT32 membersum, neighsum, memberscale, neighscale;\n\n  /* Expand input data enough to let all the output samples be generated\n   * by the standard loop.  Special-casing padded output would be more\n   * efficient.\n   */\n  expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2,\n\t\t    cinfo->image_width, output_cols * 2);\n\n  /* We don't bother to form the individual \"smoothed\" input pixel values;\n   * we can directly compute the output which is the average of the four\n   * smoothed values.  Each of the four member pixels contributes a fraction\n   * (1-8*SF) to its own smoothed image and a fraction SF to each of the three\n   * other smoothed pixels, therefore a total fraction (1-5*SF)/4 to the final\n   * output.  The four corner-adjacent neighbor pixels contribute a fraction\n   * SF to just one smoothed pixel, or SF/4 to the final output; while the\n   * eight edge-adjacent neighbors contribute SF to each of two smoothed\n   * pixels, or SF/2 overall.  In order to use integer arithmetic, these\n   * factors are scaled by 2^16 = 65536.\n   * Also recall that SF = smoothing_factor / 1024.\n   */\n\n  memberscale = 16384 - cinfo->smoothing_factor * 80; /* scaled (1-5*SF)/4 */\n  neighscale = cinfo->smoothing_factor * 16; /* scaled SF/4 */\n\n  inrow = 0;\n  for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {\n    outptr = output_data[outrow];\n    inptr0 = input_data[inrow];\n    inptr1 = input_data[inrow+1];\n    above_ptr = input_data[inrow-1];\n    below_ptr = input_data[inrow+2];\n\n    /* Special case for first column: pretend column -1 is same as column 0 */\n    membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) +\n\t\tGETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]);\n    neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) +\n\t       GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) +\n\t       GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[2]) +\n\t       GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[2]);\n    neighsum += neighsum;\n    neighsum += GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[2]) +\n\t\tGETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[2]);\n    membersum = membersum * memberscale + neighsum * neighscale;\n    *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16);\n    inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2;\n\n    for (colctr = output_cols - 2; colctr > 0; colctr--) {\n      /* sum of pixels directly mapped to this output element */\n      membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) +\n\t\t  GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]);\n      /* sum of edge-neighbor pixels */\n      neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) +\n\t\t GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) +\n\t\t GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[2]) +\n\t\t GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[2]);\n      /* The edge-neighbors count twice as much as corner-neighbors */\n      neighsum += neighsum;\n      /* Add in the corner-neighbors */\n      neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[2]) +\n\t\t  GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[2]);\n      /* form final output scaled up by 2^16 */\n      membersum = membersum * memberscale + neighsum * neighscale;\n      /* round, descale and output it */\n      *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16);\n      inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2;\n    }\n\n    /* Special case for last column */\n    membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) +\n\t\tGETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]);\n    neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) +\n\t       GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) +\n\t       GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[1]) +\n\t       GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[1]);\n    neighsum += neighsum;\n    neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[1]) +\n\t\tGETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[1]);\n    membersum = membersum * memberscale + neighsum * neighscale;\n    *outptr = (JSAMPLE) ((membersum + 32768) >> 16);\n\n    inrow += 2;\n  }\n}\n\n\n/*\n * Downsample pixel values of a single component.\n * This version handles the special case of a full-size component,\n * with smoothing.  One row of context is required.\n */\n\nMETHODDEF void\nfullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,\n\t\t\t    JSAMPARRAY input_data, JSAMPARRAY output_data)\n{\n  int outrow;\n  JDIMENSION colctr;\n  JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;\n  register JSAMPROW inptr, above_ptr, below_ptr, outptr;\n  INT32 membersum, neighsum, memberscale, neighscale;\n  int colsum, lastcolsum, nextcolsum;\n\n  /* Expand input data enough to let all the output samples be generated\n   * by the standard loop.  Special-casing padded output would be more\n   * efficient.\n   */\n  expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2,\n\t\t    cinfo->image_width, output_cols);\n\n  /* Each of the eight neighbor pixels contributes a fraction SF to the\n   * smoothed pixel, while the main pixel contributes (1-8*SF).  In order\n   * to use integer arithmetic, these factors are multiplied by 2^16 = 65536.\n   * Also recall that SF = smoothing_factor / 1024.\n   */\n\n  memberscale = 65536L - cinfo->smoothing_factor * 512L; /* scaled 1-8*SF */\n  neighscale = cinfo->smoothing_factor * 64; /* scaled SF */\n\n  for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {\n    outptr = output_data[outrow];\n    inptr = input_data[outrow];\n    above_ptr = input_data[outrow-1];\n    below_ptr = input_data[outrow+1];\n\n    /* Special case for first column */\n    colsum = GETJSAMPLE(*above_ptr++) + GETJSAMPLE(*below_ptr++) +\n\t     GETJSAMPLE(*inptr);\n    membersum = GETJSAMPLE(*inptr++);\n    nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) +\n\t\t GETJSAMPLE(*inptr);\n    neighsum = colsum + (colsum - membersum) + nextcolsum;\n    membersum = membersum * memberscale + neighsum * neighscale;\n    *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16);\n    lastcolsum = colsum; colsum = nextcolsum;\n\n    for (colctr = output_cols - 2; colctr > 0; colctr--) {\n      membersum = GETJSAMPLE(*inptr++);\n      above_ptr++; below_ptr++;\n      nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) +\n\t\t   GETJSAMPLE(*inptr);\n      neighsum = lastcolsum + (colsum - membersum) + nextcolsum;\n      membersum = membersum * memberscale + neighsum * neighscale;\n      *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16);\n      lastcolsum = colsum; colsum = nextcolsum;\n    }\n\n    /* Special case for last column */\n    membersum = GETJSAMPLE(*inptr);\n    neighsum = lastcolsum + (colsum - membersum) + colsum;\n    membersum = membersum * memberscale + neighsum * neighscale;\n    *outptr = (JSAMPLE) ((membersum + 32768) >> 16);\n\n  }\n}\n\n#endif /* INPUT_SMOOTHING_SUPPORTED */\n\n\n/*\n * Module initialization routine for downsampling.\n * Note that we must select a routine for each component.\n */\n\nGLOBAL void\njinit_downsampler (j_compress_ptr cinfo)\n{\n  my_downsample_ptr downsample;\n  int ci;\n  jpeg_component_info * compptr;\n  boolean smoothok = TRUE;\n\n  downsample = (my_downsample_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_downsampler));\n  cinfo->downsample = (struct jpeg_downsampler *) downsample;\n  downsample->pub.start_pass = start_pass_downsample;\n  downsample->pub.downsample = sep_downsample;\n  downsample->pub.need_context_rows = FALSE;\n\n  if (cinfo->CCIR601_sampling)\n    ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);\n\n  /* Verify we can handle the sampling factors, and set up method pointers */\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    if (compptr->h_samp_factor == cinfo->max_h_samp_factor &&\n\tcompptr->v_samp_factor == cinfo->max_v_samp_factor) {\n#ifdef INPUT_SMOOTHING_SUPPORTED\n      if (cinfo->smoothing_factor) {\n\tdownsample->methods[ci] = fullsize_smooth_downsample;\n\tdownsample->pub.need_context_rows = TRUE;\n      } else\n#endif\n\tdownsample->methods[ci] = fullsize_downsample;\n    } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor &&\n\t       compptr->v_samp_factor == cinfo->max_v_samp_factor) {\n      smoothok = FALSE;\n      downsample->methods[ci] = h2v1_downsample;\n    } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor &&\n\t       compptr->v_samp_factor * 2 == cinfo->max_v_samp_factor) {\n#ifdef INPUT_SMOOTHING_SUPPORTED\n      if (cinfo->smoothing_factor) {\n\tdownsample->methods[ci] = h2v2_smooth_downsample;\n\tdownsample->pub.need_context_rows = TRUE;\n      } else\n#endif\n\tdownsample->methods[ci] = h2v2_downsample;\n    } else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 &&\n\t       (cinfo->max_v_samp_factor % compptr->v_samp_factor) == 0) {\n      smoothok = FALSE;\n      downsample->methods[ci] = int_downsample;\n    } else\n      ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);\n  }\n\n#ifdef INPUT_SMOOTHING_SUPPORTED\n  if (cinfo->smoothing_factor && !smoothok)\n    TRACEMS(cinfo, 0, JTRC_SMOOTH_NOTIMPL);\n#endif\n}\n"
  },
  {
    "path": "code/jpeg-6/jctrans.c",
    "content": "/*\n * jctrans.c\n *\n * Copyright (C) 1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains library routines for transcoding compression,\n * that is, writing raw DCT coefficient arrays to an output JPEG file.\n * The routines in jcapimin.c will also be needed by a transcoder.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/* Forward declarations */\nLOCAL void transencode_master_selection\n\tJPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays));\nLOCAL void transencode_coef_controller\n\tJPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays));\n\n\n/*\n * Compression initialization for writing raw-coefficient data.\n * Before calling this, all parameters and a data destination must be set up.\n * Call jpeg_finish_compress() to actually write the data.\n *\n * The number of passed virtual arrays must match cinfo->num_components.\n * Note that the virtual arrays need not be filled or even realized at\n * the time write_coefficients is called; indeed, if the virtual arrays\n * were requested from this compression object's memory manager, they\n * typically will be realized during this routine and filled afterwards.\n */\n\nGLOBAL void\njpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)\n{\n  if (cinfo->global_state != CSTATE_START)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  /* Mark all tables to be written */\n  jpeg_suppress_tables(cinfo, FALSE);\n  /* (Re)initialize error mgr and destination modules */\n  (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);\n  (*cinfo->dest->init_destination) (cinfo);\n  /* Perform master selection of active modules */\n  transencode_master_selection(cinfo, coef_arrays);\n  /* Wait for jpeg_finish_compress() call */\n  cinfo->next_scanline = 0;\t/* so jpeg_write_marker works */\n  cinfo->global_state = CSTATE_WRCOEFS;\n}\n\n\n/*\n * Initialize the compression object with default parameters,\n * then copy from the source object all parameters needed for lossless\n * transcoding.  Parameters that can be varied without loss (such as\n * scan script and Huffman optimization) are left in their default states.\n */\n\nGLOBAL void\njpeg_copy_critical_parameters (j_decompress_ptr srcinfo,\n\t\t\t       j_compress_ptr dstinfo)\n{\n  JQUANT_TBL ** qtblptr;\n  jpeg_component_info *incomp, *outcomp;\n  JQUANT_TBL *c_quant, *slot_quant;\n  int tblno, ci, coefi;\n\n  /* Safety check to ensure start_compress not called yet. */\n  if (dstinfo->global_state != CSTATE_START)\n    ERREXIT1(dstinfo, JERR_BAD_STATE, dstinfo->global_state);\n  /* Copy fundamental image dimensions */\n  dstinfo->image_width = srcinfo->image_width;\n  dstinfo->image_height = srcinfo->image_height;\n  dstinfo->input_components = srcinfo->num_components;\n  dstinfo->in_color_space = srcinfo->jpeg_color_space;\n  /* Initialize all parameters to default values */\n  jpeg_set_defaults(dstinfo);\n  /* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB.\n   * Fix it to get the right header markers for the image colorspace.\n   */\n  jpeg_set_colorspace(dstinfo, srcinfo->jpeg_color_space);\n  dstinfo->data_precision = srcinfo->data_precision;\n  dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling;\n  /* Copy the source's quantization tables. */\n  for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) {\n    if (srcinfo->quant_tbl_ptrs[tblno] != NULL) {\n      qtblptr = & dstinfo->quant_tbl_ptrs[tblno];\n      if (*qtblptr == NULL)\n\t*qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo);\n      MEMCOPY((*qtblptr)->quantval,\n\t      srcinfo->quant_tbl_ptrs[tblno]->quantval,\n\t      SIZEOF((*qtblptr)->quantval));\n      (*qtblptr)->sent_table = FALSE;\n    }\n  }\n  /* Copy the source's per-component info.\n   * Note we assume jpeg_set_defaults has allocated the dest comp_info array.\n   */\n  dstinfo->num_components = srcinfo->num_components;\n  if (dstinfo->num_components < 1 || dstinfo->num_components > MAX_COMPONENTS)\n    ERREXIT2(dstinfo, JERR_COMPONENT_COUNT, dstinfo->num_components,\n\t     MAX_COMPONENTS);\n  for (ci = 0, incomp = srcinfo->comp_info, outcomp = dstinfo->comp_info;\n       ci < dstinfo->num_components; ci++, incomp++, outcomp++) {\n    outcomp->component_id = incomp->component_id;\n    outcomp->h_samp_factor = incomp->h_samp_factor;\n    outcomp->v_samp_factor = incomp->v_samp_factor;\n    outcomp->quant_tbl_no = incomp->quant_tbl_no;\n    /* Make sure saved quantization table for component matches the qtable\n     * slot.  If not, the input file re-used this qtable slot.\n     * IJG encoder currently cannot duplicate this.\n     */\n    tblno = outcomp->quant_tbl_no;\n    if (tblno < 0 || tblno >= NUM_QUANT_TBLS ||\n\tsrcinfo->quant_tbl_ptrs[tblno] == NULL)\n      ERREXIT1(dstinfo, JERR_NO_QUANT_TABLE, tblno);\n    slot_quant = srcinfo->quant_tbl_ptrs[tblno];\n    c_quant = incomp->quant_table;\n    if (c_quant != NULL) {\n      for (coefi = 0; coefi < DCTSIZE2; coefi++) {\n\tif (c_quant->quantval[coefi] != slot_quant->quantval[coefi])\n\t  ERREXIT1(dstinfo, JERR_MISMATCHED_QUANT_TABLE, tblno);\n      }\n    }\n    /* Note: we do not copy the source's Huffman table assignments;\n     * instead we rely on jpeg_set_colorspace to have made a suitable choice.\n     */\n  }\n}\n\n\n/*\n * Master selection of compression modules for transcoding.\n * This substitutes for jcinit.c's initialization of the full compressor.\n */\n\nLOCAL void\ntransencode_master_selection (j_compress_ptr cinfo,\n\t\t\t      jvirt_barray_ptr * coef_arrays)\n{\n  /* Although we don't actually use input_components for transcoding,\n   * jcmaster.c's initial_setup will complain if input_components is 0.\n   */\n  cinfo->input_components = 1;\n  /* Initialize master control (includes parameter checking/processing) */\n  jinit_c_master_control(cinfo, TRUE /* transcode only */);\n\n  /* Entropy encoding: either Huffman or arithmetic coding. */\n  if (cinfo->arith_code) {\n    ERREXIT(cinfo, JERR_ARITH_NOTIMPL);\n  } else {\n    if (cinfo->progressive_mode) {\n#ifdef C_PROGRESSIVE_SUPPORTED\n      jinit_phuff_encoder(cinfo);\n#else\n      ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif\n    } else\n      jinit_huff_encoder(cinfo);\n  }\n\n  /* We need a special coefficient buffer controller. */\n  transencode_coef_controller(cinfo, coef_arrays);\n\n  jinit_marker_writer(cinfo);\n\n  /* We can now tell the memory manager to allocate virtual arrays. */\n  (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);\n\n  /* Write the datastream header (SOI) immediately.\n   * Frame and scan headers are postponed till later.\n   * This lets application insert special markers after the SOI.\n   */\n  (*cinfo->marker->write_file_header) (cinfo);\n}\n\n\n/*\n * The rest of this file is a special implementation of the coefficient\n * buffer controller.  This is similar to jccoefct.c, but it handles only\n * output from presupplied virtual arrays.  Furthermore, we generate any\n * dummy padding blocks on-the-fly rather than expecting them to be present\n * in the arrays.\n */\n\n/* Private buffer controller object */\n\ntypedef struct {\n  struct jpeg_c_coef_controller pub; /* public fields */\n\n  JDIMENSION iMCU_row_num;\t/* iMCU row # within image */\n  JDIMENSION mcu_ctr;\t\t/* counts MCUs processed in current row */\n  int MCU_vert_offset;\t\t/* counts MCU rows within iMCU row */\n  int MCU_rows_per_iMCU_row;\t/* number of such rows needed */\n\n  /* Virtual block array for each component. */\n  jvirt_barray_ptr * whole_image;\n\n  /* Workspace for constructing dummy blocks at right/bottom edges. */\n  JBLOCKROW dummy_buffer[C_MAX_BLOCKS_IN_MCU];\n} my_coef_controller;\n\ntypedef my_coef_controller * my_coef_ptr;\n\n\nLOCAL void\nstart_iMCU_row (j_compress_ptr cinfo)\n/* Reset within-iMCU-row counters for a new row */\n{\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n\n  /* In an interleaved scan, an MCU row is the same as an iMCU row.\n   * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.\n   * But at the bottom of the image, process only what's left.\n   */\n  if (cinfo->comps_in_scan > 1) {\n    coef->MCU_rows_per_iMCU_row = 1;\n  } else {\n    if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1))\n      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;\n    else\n      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;\n  }\n\n  coef->mcu_ctr = 0;\n  coef->MCU_vert_offset = 0;\n}\n\n\n/*\n * Initialize for a processing pass.\n */\n\nMETHODDEF void\nstart_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode)\n{\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n\n  if (pass_mode != JBUF_CRANK_DEST)\n    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n\n  coef->iMCU_row_num = 0;\n  start_iMCU_row(cinfo);\n}\n\n\n/*\n * Process some data.\n * We process the equivalent of one fully interleaved MCU row (\"iMCU\" row)\n * per call, ie, v_samp_factor block rows for each component in the scan.\n * The data is obtained from the virtual arrays and fed to the entropy coder.\n * Returns TRUE if the iMCU row is completed, FALSE if suspended.\n *\n * NB: input_buf is ignored; it is likely to be a NULL pointer.\n */\n\nMETHODDEF boolean\ncompress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)\n{\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n  JDIMENSION MCU_col_num;\t/* index of current MCU within row */\n  JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;\n  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;\n  int blkn, ci, xindex, yindex, yoffset, blockcnt;\n  JDIMENSION start_col;\n  JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];\n  JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU];\n  JBLOCKROW buffer_ptr;\n  jpeg_component_info *compptr;\n\n  /* Align the virtual buffers for the components used in this scan. */\n  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n    compptr = cinfo->cur_comp_info[ci];\n    buffer[ci] = (*cinfo->mem->access_virt_barray)\n      ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],\n       coef->iMCU_row_num * compptr->v_samp_factor,\n       (JDIMENSION) compptr->v_samp_factor, FALSE);\n  }\n\n  /* Loop to process one whole iMCU row */\n  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;\n       yoffset++) {\n    for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row;\n\t MCU_col_num++) {\n      /* Construct list of pointers to DCT blocks belonging to this MCU */\n      blkn = 0;\t\t\t/* index of current DCT block within MCU */\n      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n\tcompptr = cinfo->cur_comp_info[ci];\n\tstart_col = MCU_col_num * compptr->MCU_width;\n\tblockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width\n\t\t\t\t\t\t: compptr->last_col_width;\n\tfor (yindex = 0; yindex < compptr->MCU_height; yindex++) {\n\t  if (coef->iMCU_row_num < last_iMCU_row ||\n\t      yindex+yoffset < compptr->last_row_height) {\n\t    /* Fill in pointers to real blocks in this row */\n\t    buffer_ptr = buffer[ci][yindex+yoffset] + start_col;\n\t    for (xindex = 0; xindex < blockcnt; xindex++)\n\t      MCU_buffer[blkn++] = buffer_ptr++;\n\t  } else {\n\t    /* At bottom of image, need a whole row of dummy blocks */\n\t    xindex = 0;\n\t  }\n\t  /* Fill in any dummy blocks needed in this row.\n\t   * Dummy blocks are filled in the same way as in jccoefct.c:\n\t   * all zeroes in the AC entries, DC entries equal to previous\n\t   * block's DC value.  The init routine has already zeroed the\n\t   * AC entries, so we need only set the DC entries correctly.\n\t   */\n\t  for (; xindex < compptr->MCU_width; xindex++) {\n\t    MCU_buffer[blkn] = coef->dummy_buffer[blkn];\n\t    MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0];\n\t    blkn++;\n\t  }\n\t}\n      }\n      /* Try to write the MCU. */\n      if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) {\n\t/* Suspension forced; update state counters and exit */\n\tcoef->MCU_vert_offset = yoffset;\n\tcoef->mcu_ctr = MCU_col_num;\n\treturn FALSE;\n      }\n    }\n    /* Completed an MCU row, but perhaps not an iMCU row */\n    coef->mcu_ctr = 0;\n  }\n  /* Completed the iMCU row, advance counters for next one */\n  coef->iMCU_row_num++;\n  start_iMCU_row(cinfo);\n  return TRUE;\n}\n\n\n/*\n * Initialize coefficient buffer controller.\n *\n * Each passed coefficient array must be the right size for that\n * coefficient: width_in_blocks wide and height_in_blocks high,\n * with unitheight at least v_samp_factor.\n */\n\nLOCAL void\ntransencode_coef_controller (j_compress_ptr cinfo,\n\t\t\t     jvirt_barray_ptr * coef_arrays)\n{\n  my_coef_ptr coef;\n  JBLOCKROW buffer;\n  int i;\n\n  coef = (my_coef_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_coef_controller));\n  cinfo->coef = (struct jpeg_c_coef_controller *) coef;\n  coef->pub.start_pass = start_pass_coef;\n  coef->pub.compress_data = compress_output;\n\n  /* Save pointer to virtual arrays */\n  coef->whole_image = coef_arrays;\n\n  /* Allocate and pre-zero space for dummy DCT blocks. */\n  buffer = (JBLOCKROW)\n    (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tC_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));\n  jzero_far((void FAR *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));\n  for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {\n    coef->dummy_buffer[i] = buffer + i;\n  }\n}\n"
  },
  {
    "path": "code/jpeg-6/jdapimin.c",
    "content": "/*\n * jdapimin.c\n *\n * Copyright (C) 1994-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains application interface code for the decompression half\n * of the JPEG library.  These are the \"minimum\" API routines that may be\n * needed in either the normal full-decompression case or the\n * transcoding-only case.\n *\n * Most of the routines intended to be called directly by an application\n * are in this file or in jdapistd.c.  But also see jcomapi.c for routines\n * shared by compression and decompression, and jdtrans.c for the transcoding\n * case.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/*\n * Initialization of a JPEG decompression object.\n * The error manager must already be set up (in case memory manager fails).\n */\n\nGLOBAL void\njpeg_create_decompress (j_decompress_ptr cinfo)\n{\n  int i;\n\n  /* For debugging purposes, zero the whole master structure.\n   * But error manager pointer is already there, so save and restore it.\n   */\n  {\n    struct jpeg_error_mgr * err = cinfo->err;\n    MEMZERO(cinfo, SIZEOF(struct jpeg_decompress_struct));\n    cinfo->err = err;\n  }\n  cinfo->is_decompressor = TRUE;\n\n  /* Initialize a memory manager instance for this object */\n  jinit_memory_mgr((j_common_ptr) cinfo);\n\n  /* Zero out pointers to permanent structures. */\n  cinfo->progress = NULL;\n  cinfo->src = NULL;\n\n  for (i = 0; i < NUM_QUANT_TBLS; i++)\n    cinfo->quant_tbl_ptrs[i] = NULL;\n\n  for (i = 0; i < NUM_HUFF_TBLS; i++) {\n    cinfo->dc_huff_tbl_ptrs[i] = NULL;\n    cinfo->ac_huff_tbl_ptrs[i] = NULL;\n  }\n\n  /* Initialize marker processor so application can override methods\n   * for COM, APPn markers before calling jpeg_read_header.\n   */\n  jinit_marker_reader(cinfo);\n\n  /* And initialize the overall input controller. */\n  jinit_input_controller(cinfo);\n\n  /* OK, I'm ready */\n  cinfo->global_state = DSTATE_START;\n}\n\n\n/*\n * Destruction of a JPEG decompression object\n */\n\nGLOBAL void\njpeg_destroy_decompress (j_decompress_ptr cinfo)\n{\n  jpeg_destroy((j_common_ptr) cinfo); /* use common routine */\n}\n\n\n/*\n * Abort processing of a JPEG decompression operation,\n * but don't destroy the object itself.\n */\n\nGLOBAL void\njpeg_abort_decompress (j_decompress_ptr cinfo)\n{\n  jpeg_abort((j_common_ptr) cinfo); /* use common routine */\n}\n\n\n/*\n * Install a special processing method for COM or APPn markers.\n */\n\nGLOBAL void\njpeg_set_marker_processor (j_decompress_ptr cinfo, int marker_code,\n\t\t\t   jpeg_marker_parser_method routine)\n{\n  if (marker_code == JPEG_COM)\n    cinfo->marker->process_COM = routine;\n  else if (marker_code >= JPEG_APP0 && marker_code <= JPEG_APP0+15)\n    cinfo->marker->process_APPn[marker_code-JPEG_APP0] = routine;\n  else\n    ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code);\n}\n\n\n/*\n * Set default decompression parameters.\n */\n\nLOCAL void\ndefault_decompress_parms (j_decompress_ptr cinfo)\n{\n  /* Guess the input colorspace, and set output colorspace accordingly. */\n  /* (Wish JPEG committee had provided a real way to specify this...) */\n  /* Note application may override our guesses. */\n  switch (cinfo->num_components) {\n  case 1:\n    cinfo->jpeg_color_space = JCS_GRAYSCALE;\n    cinfo->out_color_space = JCS_GRAYSCALE;\n    break;\n    \n  case 3:\n    if (cinfo->saw_JFIF_marker) {\n      cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */\n    } else if (cinfo->saw_Adobe_marker) {\n      switch (cinfo->Adobe_transform) {\n      case 0:\n\tcinfo->jpeg_color_space = JCS_RGB;\n\tbreak;\n      case 1:\n\tcinfo->jpeg_color_space = JCS_YCbCr;\n\tbreak;\n      default:\n\tWARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);\n\tcinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */\n\tbreak;\n      }\n    } else {\n      /* Saw no special markers, try to guess from the component IDs */\n      int cid0 = cinfo->comp_info[0].component_id;\n      int cid1 = cinfo->comp_info[1].component_id;\n      int cid2 = cinfo->comp_info[2].component_id;\n\n      if (cid0 == 1 && cid1 == 2 && cid2 == 3)\n\tcinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */\n      else if (cid0 == 82 && cid1 == 71 && cid2 == 66)\n\tcinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */\n      else {\n\tTRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);\n\tcinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */\n      }\n    }\n    /* Always guess RGB is proper output colorspace. */\n    cinfo->out_color_space = JCS_RGB;\n    break;\n    \n  case 4:\n    if (cinfo->saw_Adobe_marker) {\n      switch (cinfo->Adobe_transform) {\n      case 0:\n\tcinfo->jpeg_color_space = JCS_CMYK;\n\tbreak;\n      case 2:\n\tcinfo->jpeg_color_space = JCS_YCCK;\n\tbreak;\n      default:\n\tWARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);\n\tcinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */\n\tbreak;\n      }\n    } else {\n      /* No special markers, assume straight CMYK. */\n      cinfo->jpeg_color_space = JCS_CMYK;\n    }\n    cinfo->out_color_space = JCS_CMYK;\n    break;\n    \n  default:\n    cinfo->jpeg_color_space = JCS_UNKNOWN;\n    cinfo->out_color_space = JCS_UNKNOWN;\n    break;\n  }\n\n  /* Set defaults for other decompression parameters. */\n  cinfo->scale_num = 1;\t\t/* 1:1 scaling */\n  cinfo->scale_denom = 1;\n  cinfo->output_gamma = 1.0;\n  cinfo->buffered_image = FALSE;\n  cinfo->raw_data_out = FALSE;\n  cinfo->dct_method = JDCT_DEFAULT;\n  cinfo->do_fancy_upsampling = TRUE;\n  cinfo->do_block_smoothing = TRUE;\n  cinfo->quantize_colors = FALSE;\n  /* We set these in case application only sets quantize_colors. */\n  cinfo->dither_mode = JDITHER_FS;\n#ifdef QUANT_2PASS_SUPPORTED\n  cinfo->two_pass_quantize = TRUE;\n#else\n  cinfo->two_pass_quantize = FALSE;\n#endif\n  cinfo->desired_number_of_colors = 256;\n  cinfo->colormap = NULL;\n  /* Initialize for no mode change in buffered-image mode. */\n  cinfo->enable_1pass_quant = FALSE;\n  cinfo->enable_external_quant = FALSE;\n  cinfo->enable_2pass_quant = FALSE;\n}\n\n\n/*\n * Decompression startup: read start of JPEG datastream to see what's there.\n * Need only initialize JPEG object and supply a data source before calling.\n *\n * This routine will read as far as the first SOS marker (ie, actual start of\n * compressed data), and will save all tables and parameters in the JPEG\n * object.  It will also initialize the decompression parameters to default\n * values, and finally return JPEG_HEADER_OK.  On return, the application may\n * adjust the decompression parameters and then call jpeg_start_decompress.\n * (Or, if the application only wanted to determine the image parameters,\n * the data need not be decompressed.  In that case, call jpeg_abort or\n * jpeg_destroy to release any temporary space.)\n * If an abbreviated (tables only) datastream is presented, the routine will\n * return JPEG_HEADER_TABLES_ONLY upon reaching EOI.  The application may then\n * re-use the JPEG object to read the abbreviated image datastream(s).\n * It is unnecessary (but OK) to call jpeg_abort in this case.\n * The JPEG_SUSPENDED return code only occurs if the data source module\n * requests suspension of the decompressor.  In this case the application\n * should load more source data and then re-call jpeg_read_header to resume\n * processing.\n * If a non-suspending data source is used and require_image is TRUE, then the\n * return code need not be inspected since only JPEG_HEADER_OK is possible.\n *\n * This routine is now just a front end to jpeg_consume_input, with some\n * extra error checking.\n */\n\nGLOBAL int\njpeg_read_header (j_decompress_ptr cinfo, boolean require_image)\n{\n  int retcode;\n\n  if (cinfo->global_state != DSTATE_START &&\n      cinfo->global_state != DSTATE_INHEADER)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n\n  retcode = jpeg_consume_input(cinfo);\n\n  switch (retcode) {\n  case JPEG_REACHED_SOS:\n    retcode = JPEG_HEADER_OK;\n    break;\n  case JPEG_REACHED_EOI:\n    if (require_image)\t\t/* Complain if application wanted an image */\n      ERREXIT(cinfo, JERR_NO_IMAGE);\n    /* Reset to start state; it would be safer to require the application to\n     * call jpeg_abort, but we can't change it now for compatibility reasons.\n     * A side effect is to free any temporary memory (there shouldn't be any).\n     */\n    jpeg_abort((j_common_ptr) cinfo); /* sets state = DSTATE_START */\n    retcode = JPEG_HEADER_TABLES_ONLY;\n    break;\n  case JPEG_SUSPENDED:\n    /* no work */\n    break;\n  }\n\n  return retcode;\n}\n\n\n/*\n * Consume data in advance of what the decompressor requires.\n * This can be called at any time once the decompressor object has\n * been created and a data source has been set up.\n *\n * This routine is essentially a state machine that handles a couple\n * of critical state-transition actions, namely initial setup and\n * transition from header scanning to ready-for-start_decompress.\n * All the actual input is done via the input controller's consume_input\n * method.\n */\n\nGLOBAL int\njpeg_consume_input (j_decompress_ptr cinfo)\n{\n  int retcode = JPEG_SUSPENDED;\n\n  /* NB: every possible DSTATE value should be listed in this switch */\n  switch (cinfo->global_state) {\n  case DSTATE_START:\n    /* Start-of-datastream actions: reset appropriate modules */\n    (*cinfo->inputctl->reset_input_controller) (cinfo);\n    /* Initialize application's data source module */\n    (*cinfo->src->init_source) (cinfo);\n    cinfo->global_state = DSTATE_INHEADER;\n    /*FALLTHROUGH*/\n  case DSTATE_INHEADER:\n    retcode = (*cinfo->inputctl->consume_input) (cinfo);\n    if (retcode == JPEG_REACHED_SOS) { /* Found SOS, prepare to decompress */\n      /* Set up default parameters based on header data */\n      default_decompress_parms(cinfo);\n      /* Set global state: ready for start_decompress */\n      cinfo->global_state = DSTATE_READY;\n    }\n    break;\n  case DSTATE_READY:\n    /* Can't advance past first SOS until start_decompress is called */\n    retcode = JPEG_REACHED_SOS;\n    break;\n  case DSTATE_PRELOAD:\n  case DSTATE_PRESCAN:\n  case DSTATE_SCANNING:\n  case DSTATE_RAW_OK:\n  case DSTATE_BUFIMAGE:\n  case DSTATE_BUFPOST:\n  case DSTATE_STOPPING:\n    retcode = (*cinfo->inputctl->consume_input) (cinfo);\n    break;\n  default:\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  }\n  return retcode;\n}\n\n\n/*\n * Have we finished reading the input file?\n */\n\nGLOBAL boolean\njpeg_input_complete (j_decompress_ptr cinfo)\n{\n  /* Check for valid jpeg object */\n  if (cinfo->global_state < DSTATE_START ||\n      cinfo->global_state > DSTATE_STOPPING)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  return cinfo->inputctl->eoi_reached;\n}\n\n\n/*\n * Is there more than one scan?\n */\n\nGLOBAL boolean\njpeg_has_multiple_scans (j_decompress_ptr cinfo)\n{\n  /* Only valid after jpeg_read_header completes */\n  if (cinfo->global_state < DSTATE_READY ||\n      cinfo->global_state > DSTATE_STOPPING)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  return cinfo->inputctl->has_multiple_scans;\n}\n\n\n/*\n * Finish JPEG decompression.\n *\n * This will normally just verify the file trailer and release temp storage.\n *\n * Returns FALSE if suspended.  The return value need be inspected only if\n * a suspending data source is used.\n */\n\nGLOBAL boolean\njpeg_finish_decompress (j_decompress_ptr cinfo)\n{\n  if ((cinfo->global_state == DSTATE_SCANNING ||\n       cinfo->global_state == DSTATE_RAW_OK) && ! cinfo->buffered_image) {\n    /* Terminate final pass of non-buffered mode */\n    if (cinfo->output_scanline < cinfo->output_height)\n      ERREXIT(cinfo, JERR_TOO_LITTLE_DATA);\n    (*cinfo->master->finish_output_pass) (cinfo);\n    cinfo->global_state = DSTATE_STOPPING;\n  } else if (cinfo->global_state == DSTATE_BUFIMAGE) {\n    /* Finishing after a buffered-image operation */\n    cinfo->global_state = DSTATE_STOPPING;\n  } else if (cinfo->global_state != DSTATE_STOPPING) {\n    /* STOPPING = repeat call after a suspension, anything else is error */\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  }\n  /* Read until EOI */\n  while (! cinfo->inputctl->eoi_reached) {\n    if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)\n      return FALSE;\t\t/* Suspend, come back later */\n  }\n  /* Do final cleanup */\n  (*cinfo->src->term_source) (cinfo);\n  /* We can use jpeg_abort to release memory and reset global_state */\n  jpeg_abort((j_common_ptr) cinfo);\n  return TRUE;\n}\n"
  },
  {
    "path": "code/jpeg-6/jdapistd.c",
    "content": "/*\n * jdapistd.c\n *\n * Copyright (C) 1994-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains application interface code for the decompression half\n * of the JPEG library.  These are the \"standard\" API routines that are\n * used in the normal full-decompression case.  They are not used by a\n * transcoding-only application.  Note that if an application links in\n * jpeg_start_decompress, it will end up linking in the entire decompressor.\n * We thus must separate this file from jdapimin.c to avoid linking the\n * whole decompression library into a transcoder.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/* Forward declarations */\nLOCAL boolean output_pass_setup JPP((j_decompress_ptr cinfo));\n\n\n/*\n * Decompression initialization.\n * jpeg_read_header must be completed before calling this.\n *\n * If a multipass operating mode was selected, this will do all but the\n * last pass, and thus may take a great deal of time.\n *\n * Returns FALSE if suspended.  The return value need be inspected only if\n * a suspending data source is used.\n */\n\nGLOBAL boolean\njpeg_start_decompress (j_decompress_ptr cinfo)\n{\n  if (cinfo->global_state == DSTATE_READY) {\n    /* First call: initialize master control, select active modules */\n    jinit_master_decompress(cinfo);\n    if (cinfo->buffered_image) {\n      /* No more work here; expecting jpeg_start_output next */\n      cinfo->global_state = DSTATE_BUFIMAGE;\n      return TRUE;\n    }\n    cinfo->global_state = DSTATE_PRELOAD;\n  }\n  if (cinfo->global_state == DSTATE_PRELOAD) {\n    /* If file has multiple scans, absorb them all into the coef buffer */\n    if (cinfo->inputctl->has_multiple_scans) {\n#ifdef D_MULTISCAN_FILES_SUPPORTED\n      for (;;) {\n\tint retcode;\n\t/* Call progress monitor hook if present */\n\tif (cinfo->progress != NULL)\n\t  (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);\n\t/* Absorb some more input */\n\tretcode = (*cinfo->inputctl->consume_input) (cinfo);\n\tif (retcode == JPEG_SUSPENDED)\n\t  return FALSE;\n\tif (retcode == JPEG_REACHED_EOI)\n\t  break;\n\t/* Advance progress counter if appropriate */\n\tif (cinfo->progress != NULL &&\n\t    (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {\n\t  if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {\n\t    /* jdmaster underestimated number of scans; ratchet up one scan */\n\t    cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;\n\t  }\n\t}\n      }\n#else\n      ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif /* D_MULTISCAN_FILES_SUPPORTED */\n    }\n    cinfo->output_scan_number = cinfo->input_scan_number;\n  } else if (cinfo->global_state != DSTATE_PRESCAN)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  /* Perform any dummy output passes, and set up for the final pass */\n  return output_pass_setup(cinfo);\n}\n\n\n/*\n * Set up for an output pass, and perform any dummy pass(es) needed.\n * Common subroutine for jpeg_start_decompress and jpeg_start_output.\n * Entry: global_state = DSTATE_PRESCAN only if previously suspended.\n * Exit: If done, returns TRUE and sets global_state for proper output mode.\n *       If suspended, returns FALSE and sets global_state = DSTATE_PRESCAN.\n */\n\nLOCAL boolean\noutput_pass_setup (j_decompress_ptr cinfo)\n{\n  if (cinfo->global_state != DSTATE_PRESCAN) {\n    /* First call: do pass setup */\n    (*cinfo->master->prepare_for_output_pass) (cinfo);\n    cinfo->output_scanline = 0;\n    cinfo->global_state = DSTATE_PRESCAN;\n  }\n  /* Loop over any required dummy passes */\n  while (cinfo->master->is_dummy_pass) {\n#ifdef QUANT_2PASS_SUPPORTED\n    /* Crank through the dummy pass */\n    while (cinfo->output_scanline < cinfo->output_height) {\n      JDIMENSION last_scanline;\n      /* Call progress monitor hook if present */\n      if (cinfo->progress != NULL) {\n\tcinfo->progress->pass_counter = (long) cinfo->output_scanline;\n\tcinfo->progress->pass_limit = (long) cinfo->output_height;\n\t(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);\n      }\n      /* Process some data */\n      last_scanline = cinfo->output_scanline;\n      (*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL,\n\t\t\t\t    &cinfo->output_scanline, (JDIMENSION) 0);\n      if (cinfo->output_scanline == last_scanline)\n\treturn FALSE;\t\t/* No progress made, must suspend */\n    }\n    /* Finish up dummy pass, and set up for another one */\n    (*cinfo->master->finish_output_pass) (cinfo);\n    (*cinfo->master->prepare_for_output_pass) (cinfo);\n    cinfo->output_scanline = 0;\n#else\n    ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif /* QUANT_2PASS_SUPPORTED */\n  }\n  /* Ready for application to drive output pass through\n   * jpeg_read_scanlines or jpeg_read_raw_data.\n   */\n  cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING;\n  return TRUE;\n}\n\n\n/*\n * Read some scanlines of data from the JPEG decompressor.\n *\n * The return value will be the number of lines actually read.\n * This may be less than the number requested in several cases,\n * including bottom of image, data source suspension, and operating\n * modes that emit multiple scanlines at a time.\n *\n * Note: we warn about excess calls to jpeg_read_scanlines() since\n * this likely signals an application programmer error.  However,\n * an oversize buffer (max_lines > scanlines remaining) is not an error.\n */\n\nGLOBAL JDIMENSION\njpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines,\n\t\t     JDIMENSION max_lines)\n{\n  JDIMENSION row_ctr;\n\n  if (cinfo->global_state != DSTATE_SCANNING)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  if (cinfo->output_scanline >= cinfo->output_height) {\n    WARNMS(cinfo, JWRN_TOO_MUCH_DATA);\n    return 0;\n  }\n\n  /* Call progress monitor hook if present */\n  if (cinfo->progress != NULL) {\n    cinfo->progress->pass_counter = (long) cinfo->output_scanline;\n    cinfo->progress->pass_limit = (long) cinfo->output_height;\n    (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);\n  }\n\n  /* Process some data */\n  row_ctr = 0;\n  (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines);\n  cinfo->output_scanline += row_ctr;\n  return row_ctr;\n}\n\n\n/*\n * Alternate entry point to read raw data.\n * Processes exactly one iMCU row per call, unless suspended.\n */\n\nGLOBAL JDIMENSION\njpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,\n\t\t    JDIMENSION max_lines)\n{\n  JDIMENSION lines_per_iMCU_row;\n\n  if (cinfo->global_state != DSTATE_RAW_OK)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  if (cinfo->output_scanline >= cinfo->output_height) {\n    WARNMS(cinfo, JWRN_TOO_MUCH_DATA);\n    return 0;\n  }\n\n  /* Call progress monitor hook if present */\n  if (cinfo->progress != NULL) {\n    cinfo->progress->pass_counter = (long) cinfo->output_scanline;\n    cinfo->progress->pass_limit = (long) cinfo->output_height;\n    (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);\n  }\n\n  /* Verify that at least one iMCU row can be returned. */\n  lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size;\n  if (max_lines < lines_per_iMCU_row)\n    ERREXIT(cinfo, JERR_BUFFER_SIZE);\n\n  /* Decompress directly into user's buffer. */\n  if (! (*cinfo->coef->decompress_data) (cinfo, data))\n    return 0;\t\t\t/* suspension forced, can do nothing more */\n\n  /* OK, we processed one iMCU row. */\n  cinfo->output_scanline += lines_per_iMCU_row;\n  return lines_per_iMCU_row;\n}\n\n\n/* Additional entry points for buffered-image mode. */\n\n#ifdef D_MULTISCAN_FILES_SUPPORTED\n\n/*\n * Initialize for an output pass in buffered-image mode.\n */\n\nGLOBAL boolean\njpeg_start_output (j_decompress_ptr cinfo, int scan_number)\n{\n  if (cinfo->global_state != DSTATE_BUFIMAGE &&\n      cinfo->global_state != DSTATE_PRESCAN)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  /* Limit scan number to valid range */\n  if (scan_number <= 0)\n    scan_number = 1;\n  if (cinfo->inputctl->eoi_reached &&\n      scan_number > cinfo->input_scan_number)\n    scan_number = cinfo->input_scan_number;\n  cinfo->output_scan_number = scan_number;\n  /* Perform any dummy output passes, and set up for the real pass */\n  return output_pass_setup(cinfo);\n}\n\n\n/*\n * Finish up after an output pass in buffered-image mode.\n *\n * Returns FALSE if suspended.  The return value need be inspected only if\n * a suspending data source is used.\n */\n\nGLOBAL boolean\njpeg_finish_output (j_decompress_ptr cinfo)\n{\n  if ((cinfo->global_state == DSTATE_SCANNING ||\n       cinfo->global_state == DSTATE_RAW_OK) && cinfo->buffered_image) {\n    /* Terminate this pass. */\n    /* We do not require the whole pass to have been completed. */\n    (*cinfo->master->finish_output_pass) (cinfo);\n    cinfo->global_state = DSTATE_BUFPOST;\n  } else if (cinfo->global_state != DSTATE_BUFPOST) {\n    /* BUFPOST = repeat call after a suspension, anything else is error */\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  }\n  /* Read markers looking for SOS or EOI */\n  while (cinfo->input_scan_number <= cinfo->output_scan_number &&\n\t ! cinfo->inputctl->eoi_reached) {\n    if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)\n      return FALSE;\t\t/* Suspend, come back later */\n  }\n  cinfo->global_state = DSTATE_BUFIMAGE;\n  return TRUE;\n}\n\n#endif /* D_MULTISCAN_FILES_SUPPORTED */\n"
  },
  {
    "path": "code/jpeg-6/jdatadst.c",
    "content": "/*\n * jdatadst.c\n *\n * Copyright (C) 1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains compression data destination routines for the case of\n * emitting JPEG data to a file (or any stdio stream).  While these routines\n * are sufficient for most applications, some will want to use a different\n * destination manager.\n * IMPORTANT: we assume that fwrite() will correctly transcribe an array of\n * JOCTETs into 8-bit-wide elements on external storage.  If char is wider\n * than 8 bits on your machine, you may need to do some tweaking.\n */\n\n/* this is not a core library module, so it doesn't define JPEG_INTERNALS */\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jerror.h\"\n\n\n/* Expanded data destination object for stdio output */\n\ntypedef struct {\n  struct jpeg_destination_mgr pub; /* public fields */\n\n  FILE * outfile;\t\t/* target stream */\n  JOCTET * buffer;\t\t/* start of buffer */\n} my_destination_mgr;\n\ntypedef my_destination_mgr * my_dest_ptr;\n\n#define OUTPUT_BUF_SIZE  4096\t/* choose an efficiently fwrite'able size */\n\n\n/*\n * Initialize destination --- called by jpeg_start_compress\n * before any data is actually written.\n */\n\nMETHODDEF void\ninit_destination (j_compress_ptr cinfo)\n{\n  my_dest_ptr dest = (my_dest_ptr) cinfo->dest;\n\n  /* Allocate the output buffer --- it will be released when done with image */\n  dest->buffer = (JOCTET *)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t  OUTPUT_BUF_SIZE * SIZEOF(JOCTET));\n\n  dest->pub.next_output_byte = dest->buffer;\n  dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;\n}\n\n\n/*\n * Empty the output buffer --- called whenever buffer fills up.\n *\n * In typical applications, this should write the entire output buffer\n * (ignoring the current state of next_output_byte & free_in_buffer),\n * reset the pointer & count to the start of the buffer, and return TRUE\n * indicating that the buffer has been dumped.\n *\n * In applications that need to be able to suspend compression due to output\n * overrun, a FALSE return indicates that the buffer cannot be emptied now.\n * In this situation, the compressor will return to its caller (possibly with\n * an indication that it has not accepted all the supplied scanlines).  The\n * application should resume compression after it has made more room in the\n * output buffer.  Note that there are substantial restrictions on the use of\n * suspension --- see the documentation.\n *\n * When suspending, the compressor will back up to a convenient restart point\n * (typically the start of the current MCU). next_output_byte & free_in_buffer\n * indicate where the restart point will be if the current call returns FALSE.\n * Data beyond this point will be regenerated after resumption, so do not\n * write it out when emptying the buffer externally.\n */\n\nMETHODDEF boolean\nempty_output_buffer (j_compress_ptr cinfo)\n{\n  my_dest_ptr dest = (my_dest_ptr) cinfo->dest;\n\n  if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) !=\n      (size_t) OUTPUT_BUF_SIZE)\n    ERREXIT(cinfo, JERR_FILE_WRITE);\n\n  dest->pub.next_output_byte = dest->buffer;\n  dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;\n\n  return TRUE;\n}\n\n\n/*\n * Terminate destination --- called by jpeg_finish_compress\n * after all data has been written.  Usually needs to flush buffer.\n *\n * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding\n * application must deal with any cleanup that should happen even\n * for error exit.\n */\n\nMETHODDEF void\nterm_destination (j_compress_ptr cinfo)\n{\n  my_dest_ptr dest = (my_dest_ptr) cinfo->dest;\n  size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer;\n\n  /* Write any data remaining in the buffer */\n  if (datacount > 0) {\n    if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount)\n      ERREXIT(cinfo, JERR_FILE_WRITE);\n  }\n  fflush(dest->outfile);\n  /* Make sure we wrote the output file OK */\n  if (ferror(dest->outfile))\n    ERREXIT(cinfo, JERR_FILE_WRITE);\n}\n\n\n/*\n * Prepare for output to a stdio stream.\n * The caller must have already opened the stream, and is responsible\n * for closing it after finishing compression.\n */\n\nGLOBAL void\njpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile)\n{\n  my_dest_ptr dest;\n\n  /* The destination object is made permanent so that multiple JPEG images\n   * can be written to the same file without re-executing jpeg_stdio_dest.\n   * This makes it dangerous to use this manager and a different destination\n   * manager serially with the same JPEG object, because their private object\n   * sizes may be different.  Caveat programmer.\n   */\n  if (cinfo->dest == NULL) {\t/* first time for this JPEG object? */\n    cinfo->dest = (struct jpeg_destination_mgr *)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,\n\t\t\t\t  SIZEOF(my_destination_mgr));\n  }\n\n  dest = (my_dest_ptr) cinfo->dest;\n  dest->pub.init_destination = init_destination;\n  dest->pub.empty_output_buffer = empty_output_buffer;\n  dest->pub.term_destination = term_destination;\n  dest->outfile = outfile;\n}\n"
  },
  {
    "path": "code/jpeg-6/jdatasrc.c",
    "content": "/*\n * jdatasrc.c\n *\n * Copyright (C) 1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains decompression data source routines for the case of\n * reading JPEG data from a file (or any stdio stream).  While these routines\n * are sufficient for most applications, some will want to use a different\n * source manager.\n * IMPORTANT: we assume that fread() will correctly transcribe an array of\n * JOCTETs from 8-bit-wide elements on external storage.  If char is wider\n * than 8 bits on your machine, you may need to do some tweaking.\n */\n\n\n/* this is not a core library module, so it doesn't define JPEG_INTERNALS */\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jerror.h\"\n\n\n/* Expanded data source object for stdio input */\n\ntypedef struct {\n  struct jpeg_source_mgr pub;\t/* public fields */\n\n  unsigned char *infile;\t\t/* source stream */\n  JOCTET * buffer;\t\t/* start of buffer */\n  boolean start_of_file;\t/* have we gotten any data yet? */\n} my_source_mgr;\n\ntypedef my_source_mgr * my_src_ptr;\n\n#define INPUT_BUF_SIZE  4096\t/* choose an efficiently fread'able size */\n\n\n/*\n * Initialize source --- called by jpeg_read_header\n * before any data is actually read.\n */\n\nMETHODDEF void\ninit_source (j_decompress_ptr cinfo)\n{\n  my_src_ptr src = (my_src_ptr) cinfo->src;\n\n  /* We reset the empty-input-file flag for each image,\n   * but we don't clear the input buffer.\n   * This is correct behavior for reading a series of images from one source.\n   */\n  src->start_of_file = TRUE;\n}\n\n\n/*\n * Fill the input buffer --- called whenever buffer is emptied.\n *\n * In typical applications, this should read fresh data into the buffer\n * (ignoring the current state of next_input_byte & bytes_in_buffer),\n * reset the pointer & count to the start of the buffer, and return TRUE\n * indicating that the buffer has been reloaded.  It is not necessary to\n * fill the buffer entirely, only to obtain at least one more byte.\n *\n * There is no such thing as an EOF return.  If the end of the file has been\n * reached, the routine has a choice of ERREXIT() or inserting fake data into\n * the buffer.  In most cases, generating a warning message and inserting a\n * fake EOI marker is the best course of action --- this will allow the\n * decompressor to output however much of the image is there.  However,\n * the resulting error message is misleading if the real problem is an empty\n * input file, so we handle that case specially.\n *\n * In applications that need to be able to suspend compression due to input\n * not being available yet, a FALSE return indicates that no more data can be\n * obtained right now, but more may be forthcoming later.  In this situation,\n * the decompressor will return to its caller (with an indication of the\n * number of scanlines it has read, if any).  The application should resume\n * decompression after it has loaded more data into the input buffer.  Note\n * that there are substantial restrictions on the use of suspension --- see\n * the documentation.\n *\n * When suspending, the decompressor will back up to a convenient restart point\n * (typically the start of the current MCU). next_input_byte & bytes_in_buffer\n * indicate where the restart point will be if the current call returns FALSE.\n * Data beyond this point must be rescanned after resumption, so move it to\n * the front of the buffer rather than discarding it.\n */\n\nMETHODDEF boolean\nfill_input_buffer (j_decompress_ptr cinfo)\n{\n  my_src_ptr src = (my_src_ptr) cinfo->src;\n\n  memcpy( src->buffer, src->infile, INPUT_BUF_SIZE );\n\n  src->infile += INPUT_BUF_SIZE;\n\n  src->pub.next_input_byte = src->buffer;\n  src->pub.bytes_in_buffer = INPUT_BUF_SIZE;\n  src->start_of_file = FALSE;\n\n  return TRUE;\n}\n\n\n/*\n * Skip data --- used to skip over a potentially large amount of\n * uninteresting data (such as an APPn marker).\n *\n * Writers of suspendable-input applications must note that skip_input_data\n * is not granted the right to give a suspension return.  If the skip extends\n * beyond the data currently in the buffer, the buffer can be marked empty so\n * that the next read will cause a fill_input_buffer call that can suspend.\n * Arranging for additional bytes to be discarded before reloading the input\n * buffer is the application writer's problem.\n */\n\nMETHODDEF void\nskip_input_data (j_decompress_ptr cinfo, long num_bytes)\n{\n  my_src_ptr src = (my_src_ptr) cinfo->src;\n\n  /* Just a dumb implementation for now.  Could use fseek() except\n   * it doesn't work on pipes.  Not clear that being smart is worth\n   * any trouble anyway --- large skips are infrequent.\n   */\n  if (num_bytes > 0) {\n    while (num_bytes > (long) src->pub.bytes_in_buffer) {\n      num_bytes -= (long) src->pub.bytes_in_buffer;\n      (void) fill_input_buffer(cinfo);\n      /* note we assume that fill_input_buffer will never return FALSE,\n       * so suspension need not be handled.\n       */\n    }\n    src->pub.next_input_byte += (size_t) num_bytes;\n    src->pub.bytes_in_buffer -= (size_t) num_bytes;\n  }\n}\n\n\n/*\n * An additional method that can be provided by data source modules is the\n * resync_to_restart method for error recovery in the presence of RST markers.\n * For the moment, this source module just uses the default resync method\n * provided by the JPEG library.  That method assumes that no backtracking\n * is possible.\n */\n\n\n/*\n * Terminate source --- called by jpeg_finish_decompress\n * after all data has been read.  Often a no-op.\n *\n * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding\n * application must deal with any cleanup that should happen even\n * for error exit.\n */\n\nMETHODDEF void\nterm_source (j_decompress_ptr cinfo)\n{\n  /* no work necessary here */\n}\n\n\n/*\n * Prepare for input from a stdio stream.\n * The caller must have already opened the stream, and is responsible\n * for closing it after finishing decompression.\n */\n\nGLOBAL void\njpeg_stdio_src (j_decompress_ptr cinfo, unsigned char *infile)\n{\n  my_src_ptr src;\n\n  /* The source object and input buffer are made permanent so that a series\n   * of JPEG images can be read from the same file by calling jpeg_stdio_src\n   * only before the first one.  (If we discarded the buffer at the end of\n   * one image, we'd likely lose the start of the next one.)\n   * This makes it unsafe to use this manager and a different source\n   * manager serially with the same JPEG object.  Caveat programmer.\n   */\n  if (cinfo->src == NULL) {\t/* first time for this JPEG object? */\n    cinfo->src = (struct jpeg_source_mgr *)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,\n\t\t\t\t  SIZEOF(my_source_mgr));\n    src = (my_src_ptr) cinfo->src;\n    src->buffer = (JOCTET *)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,\n\t\t\t\t  INPUT_BUF_SIZE * SIZEOF(JOCTET));\n  }\n\n  src = (my_src_ptr) cinfo->src;\n  src->pub.init_source = init_source;\n  src->pub.fill_input_buffer = fill_input_buffer;\n  src->pub.skip_input_data = skip_input_data;\n  src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */\n  src->pub.term_source = term_source;\n  src->infile = infile;\n  src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */\n  src->pub.next_input_byte = NULL; /* until buffer loaded */\n}\n"
  },
  {
    "path": "code/jpeg-6/jdcoefct.c",
    "content": "/*\n * jdcoefct.c\n *\n * Copyright (C) 1994-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains the coefficient buffer controller for decompression.\n * This controller is the top level of the JPEG decompressor proper.\n * The coefficient buffer lies between entropy decoding and inverse-DCT steps.\n *\n * In buffered-image mode, this controller is the interface between\n * input-oriented processing and output-oriented processing.\n * Also, the input side (only) is used when reading a file for transcoding.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n/* Block smoothing is only applicable for progressive JPEG, so: */\n#ifndef D_PROGRESSIVE_SUPPORTED\n#undef BLOCK_SMOOTHING_SUPPORTED\n#endif\n\n/* Private buffer controller object */\n\ntypedef struct {\n  struct jpeg_d_coef_controller pub; /* public fields */\n\n  /* These variables keep track of the current location of the input side. */\n  /* cinfo->input_iMCU_row is also used for this. */\n  JDIMENSION MCU_ctr;\t\t/* counts MCUs processed in current row */\n  int MCU_vert_offset;\t\t/* counts MCU rows within iMCU row */\n  int MCU_rows_per_iMCU_row;\t/* number of such rows needed */\n\n  /* The output side's location is represented by cinfo->output_iMCU_row. */\n\n  /* In single-pass modes, it's sufficient to buffer just one MCU.\n   * We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks,\n   * and let the entropy decoder write into that workspace each time.\n   * (On 80x86, the workspace is FAR even though it's not really very big;\n   * this is to keep the module interfaces unchanged when a large coefficient\n   * buffer is necessary.)\n   * In multi-pass modes, this array points to the current MCU's blocks\n   * within the virtual arrays; it is used only by the input side.\n   */\n  JBLOCKROW MCU_buffer[D_MAX_BLOCKS_IN_MCU];\n\n#ifdef D_MULTISCAN_FILES_SUPPORTED\n  /* In multi-pass modes, we need a virtual block array for each component. */\n  jvirt_barray_ptr whole_image[MAX_COMPONENTS];\n#endif\n\n#ifdef BLOCK_SMOOTHING_SUPPORTED\n  /* When doing block smoothing, we latch coefficient Al values here */\n  int * coef_bits_latch;\n#define SAVED_COEFS  6\t\t/* we save coef_bits[0..5] */\n#endif\n} my_coef_controller;\n\ntypedef my_coef_controller * my_coef_ptr;\n\n/* Forward declarations */\nMETHODDEF int decompress_onepass\n\tJPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));\n#ifdef D_MULTISCAN_FILES_SUPPORTED\nMETHODDEF int decompress_data\n\tJPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));\n#endif\n#ifdef BLOCK_SMOOTHING_SUPPORTED\nLOCAL boolean smoothing_ok JPP((j_decompress_ptr cinfo));\nMETHODDEF int decompress_smooth_data\n\tJPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));\n#endif\n\n\nLOCAL void\nstart_iMCU_row (j_decompress_ptr cinfo)\n/* Reset within-iMCU-row counters for a new row (input side) */\n{\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n\n  /* In an interleaved scan, an MCU row is the same as an iMCU row.\n   * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.\n   * But at the bottom of the image, process only what's left.\n   */\n  if (cinfo->comps_in_scan > 1) {\n    coef->MCU_rows_per_iMCU_row = 1;\n  } else {\n    if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1))\n      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;\n    else\n      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;\n  }\n\n  coef->MCU_ctr = 0;\n  coef->MCU_vert_offset = 0;\n}\n\n\n/*\n * Initialize for an input processing pass.\n */\n\nMETHODDEF void\nstart_input_pass (j_decompress_ptr cinfo)\n{\n  cinfo->input_iMCU_row = 0;\n  start_iMCU_row(cinfo);\n}\n\n\n/*\n * Initialize for an output processing pass.\n */\n\nMETHODDEF void\nstart_output_pass (j_decompress_ptr cinfo)\n{\n#ifdef BLOCK_SMOOTHING_SUPPORTED\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n\n  /* If multipass, check to see whether to use block smoothing on this pass */\n  if (coef->pub.coef_arrays != NULL) {\n    if (cinfo->do_block_smoothing && smoothing_ok(cinfo))\n      coef->pub.decompress_data = decompress_smooth_data;\n    else\n      coef->pub.decompress_data = decompress_data;\n  }\n#endif\n  cinfo->output_iMCU_row = 0;\n}\n\n\n/*\n * Decompress and return some data in the single-pass case.\n * Always attempts to emit one fully interleaved MCU row (\"iMCU\" row).\n * Input and output must run in lockstep since we have only a one-MCU buffer.\n * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.\n *\n * NB: output_buf contains a plane for each component in image.\n * For single pass, this is the same as the components in the scan.\n */\n\nMETHODDEF int\ndecompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)\n{\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n  JDIMENSION MCU_col_num;\t/* index of current MCU within row */\n  JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;\n  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;\n  int blkn, ci, xindex, yindex, yoffset, useful_width;\n  JSAMPARRAY output_ptr;\n  JDIMENSION start_col, output_col;\n  jpeg_component_info *compptr;\n  inverse_DCT_method_ptr inverse_DCT;\n\n  /* Loop to process as much as one whole iMCU row */\n  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;\n       yoffset++) {\n    for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;\n\t MCU_col_num++) {\n      /* Try to fetch an MCU.  Entropy decoder expects buffer to be zeroed. */\n      jzero_far((void FAR *) coef->MCU_buffer[0],\n\t\t(size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK)));\n      if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {\n\t/* Suspension forced; update state counters and exit */\n\tcoef->MCU_vert_offset = yoffset;\n\tcoef->MCU_ctr = MCU_col_num;\n\treturn JPEG_SUSPENDED;\n      }\n      /* Determine where data should go in output_buf and do the IDCT thing.\n       * We skip dummy blocks at the right and bottom edges (but blkn gets\n       * incremented past them!).  Note the inner loop relies on having\n       * allocated the MCU_buffer[] blocks sequentially.\n       */\n      blkn = 0;\t\t\t/* index of current DCT block within MCU */\n      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n\tcompptr = cinfo->cur_comp_info[ci];\n\t/* Don't bother to IDCT an uninteresting component. */\n\tif (! compptr->component_needed) {\n\t  blkn += compptr->MCU_blocks;\n\t  continue;\n\t}\n\tinverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index];\n\tuseful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width\n\t\t\t\t\t\t    : compptr->last_col_width;\n\toutput_ptr = output_buf[ci] + yoffset * compptr->DCT_scaled_size;\n\tstart_col = MCU_col_num * compptr->MCU_sample_width;\n\tfor (yindex = 0; yindex < compptr->MCU_height; yindex++) {\n\t  if (cinfo->input_iMCU_row < last_iMCU_row ||\n\t      yoffset+yindex < compptr->last_row_height) {\n\t    output_col = start_col;\n\t    for (xindex = 0; xindex < useful_width; xindex++) {\n\t      (*inverse_DCT) (cinfo, compptr,\n\t\t\t      (JCOEFPTR) coef->MCU_buffer[blkn+xindex],\n\t\t\t      output_ptr, output_col);\n\t      output_col += compptr->DCT_scaled_size;\n\t    }\n\t  }\n\t  blkn += compptr->MCU_width;\n\t  output_ptr += compptr->DCT_scaled_size;\n\t}\n      }\n    }\n    /* Completed an MCU row, but perhaps not an iMCU row */\n    coef->MCU_ctr = 0;\n  }\n  /* Completed the iMCU row, advance counters for next one */\n  cinfo->output_iMCU_row++;\n  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {\n    start_iMCU_row(cinfo);\n    return JPEG_ROW_COMPLETED;\n  }\n  /* Completed the scan */\n  (*cinfo->inputctl->finish_input_pass) (cinfo);\n  return JPEG_SCAN_COMPLETED;\n}\n\n\n/*\n * Dummy consume-input routine for single-pass operation.\n */\n\nMETHODDEF int\ndummy_consume_data (j_decompress_ptr cinfo)\n{\n  return JPEG_SUSPENDED;\t/* Always indicate nothing was done */\n}\n\n\n#ifdef D_MULTISCAN_FILES_SUPPORTED\n\n/*\n * Consume input data and store it in the full-image coefficient buffer.\n * We read as much as one fully interleaved MCU row (\"iMCU\" row) per call,\n * ie, v_samp_factor block rows for each component in the scan.\n * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.\n */\n\nMETHODDEF int\nconsume_data (j_decompress_ptr cinfo)\n{\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n  JDIMENSION MCU_col_num;\t/* index of current MCU within row */\n  int blkn, ci, xindex, yindex, yoffset;\n  JDIMENSION start_col;\n  JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];\n  JBLOCKROW buffer_ptr;\n  jpeg_component_info *compptr;\n\n  /* Align the virtual buffers for the components used in this scan. */\n  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n    compptr = cinfo->cur_comp_info[ci];\n    buffer[ci] = (*cinfo->mem->access_virt_barray)\n      ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],\n       cinfo->input_iMCU_row * compptr->v_samp_factor,\n       (JDIMENSION) compptr->v_samp_factor, TRUE);\n    /* Note: entropy decoder expects buffer to be zeroed,\n     * but this is handled automatically by the memory manager\n     * because we requested a pre-zeroed array.\n     */\n  }\n\n  /* Loop to process one whole iMCU row */\n  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;\n       yoffset++) {\n    for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;\n\t MCU_col_num++) {\n      /* Construct list of pointers to DCT blocks belonging to this MCU */\n      blkn = 0;\t\t\t/* index of current DCT block within MCU */\n      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n\tcompptr = cinfo->cur_comp_info[ci];\n\tstart_col = MCU_col_num * compptr->MCU_width;\n\tfor (yindex = 0; yindex < compptr->MCU_height; yindex++) {\n\t  buffer_ptr = buffer[ci][yindex+yoffset] + start_col;\n\t  for (xindex = 0; xindex < compptr->MCU_width; xindex++) {\n\t    coef->MCU_buffer[blkn++] = buffer_ptr++;\n\t  }\n\t}\n      }\n      /* Try to fetch the MCU. */\n      if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {\n\t/* Suspension forced; update state counters and exit */\n\tcoef->MCU_vert_offset = yoffset;\n\tcoef->MCU_ctr = MCU_col_num;\n\treturn JPEG_SUSPENDED;\n      }\n    }\n    /* Completed an MCU row, but perhaps not an iMCU row */\n    coef->MCU_ctr = 0;\n  }\n  /* Completed the iMCU row, advance counters for next one */\n  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {\n    start_iMCU_row(cinfo);\n    return JPEG_ROW_COMPLETED;\n  }\n  /* Completed the scan */\n  (*cinfo->inputctl->finish_input_pass) (cinfo);\n  return JPEG_SCAN_COMPLETED;\n}\n\n\n/*\n * Decompress and return some data in the multi-pass case.\n * Always attempts to emit one fully interleaved MCU row (\"iMCU\" row).\n * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.\n *\n * NB: output_buf contains a plane for each component in image.\n */\n\nMETHODDEF int\ndecompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)\n{\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;\n  JDIMENSION block_num;\n  int ci, block_row, block_rows;\n  JBLOCKARRAY buffer;\n  JBLOCKROW buffer_ptr;\n  JSAMPARRAY output_ptr;\n  JDIMENSION output_col;\n  jpeg_component_info *compptr;\n  inverse_DCT_method_ptr inverse_DCT;\n\n  /* Force some input to be done if we are getting ahead of the input. */\n  while (cinfo->input_scan_number < cinfo->output_scan_number ||\n\t (cinfo->input_scan_number == cinfo->output_scan_number &&\n\t  cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) {\n    if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED)\n      return JPEG_SUSPENDED;\n  }\n\n  /* OK, output from the virtual arrays. */\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    /* Don't bother to IDCT an uninteresting component. */\n    if (! compptr->component_needed)\n      continue;\n    /* Align the virtual buffer for this component. */\n    buffer = (*cinfo->mem->access_virt_barray)\n      ((j_common_ptr) cinfo, coef->whole_image[ci],\n       cinfo->output_iMCU_row * compptr->v_samp_factor,\n       (JDIMENSION) compptr->v_samp_factor, FALSE);\n    /* Count non-dummy DCT block rows in this iMCU row. */\n    if (cinfo->output_iMCU_row < last_iMCU_row)\n      block_rows = compptr->v_samp_factor;\n    else {\n      /* NB: can't use last_row_height here; it is input-side-dependent! */\n      block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);\n      if (block_rows == 0) block_rows = compptr->v_samp_factor;\n    }\n    inverse_DCT = cinfo->idct->inverse_DCT[ci];\n    output_ptr = output_buf[ci];\n    /* Loop over all DCT blocks to be processed. */\n    for (block_row = 0; block_row < block_rows; block_row++) {\n      buffer_ptr = buffer[block_row];\n      output_col = 0;\n      for (block_num = 0; block_num < compptr->width_in_blocks; block_num++) {\n\t(*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr,\n\t\t\toutput_ptr, output_col);\n\tbuffer_ptr++;\n\toutput_col += compptr->DCT_scaled_size;\n      }\n      output_ptr += compptr->DCT_scaled_size;\n    }\n  }\n\n  if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)\n    return JPEG_ROW_COMPLETED;\n  return JPEG_SCAN_COMPLETED;\n}\n\n#endif /* D_MULTISCAN_FILES_SUPPORTED */\n\n\n#ifdef BLOCK_SMOOTHING_SUPPORTED\n\n/*\n * This code applies interblock smoothing as described by section K.8\n * of the JPEG standard: the first 5 AC coefficients are estimated from\n * the DC values of a DCT block and its 8 neighboring blocks.\n * We apply smoothing only for progressive JPEG decoding, and only if\n * the coefficients it can estimate are not yet known to full precision.\n */\n\n/*\n * Determine whether block smoothing is applicable and safe.\n * We also latch the current states of the coef_bits[] entries for the\n * AC coefficients; otherwise, if the input side of the decompressor\n * advances into a new scan, we might think the coefficients are known\n * more accurately than they really are.\n */\n\nLOCAL boolean\nsmoothing_ok (j_decompress_ptr cinfo)\n{\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n  boolean smoothing_useful = FALSE;\n  int ci, coefi;\n  jpeg_component_info *compptr;\n  JQUANT_TBL * qtable;\n  int * coef_bits;\n  int * coef_bits_latch;\n\n  if (! cinfo->progressive_mode || cinfo->coef_bits == NULL)\n    return FALSE;\n\n  /* Allocate latch area if not already done */\n  if (coef->coef_bits_latch == NULL)\n    coef->coef_bits_latch = (int *)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t  cinfo->num_components *\n\t\t\t\t  (SAVED_COEFS * SIZEOF(int)));\n  coef_bits_latch = coef->coef_bits_latch;\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    /* All components' quantization values must already be latched. */\n    if ((qtable = compptr->quant_table) == NULL)\n      return FALSE;\n    /* Verify DC & first 5 AC quantizers are nonzero to avoid zero-divide. */\n    for (coefi = 0; coefi <= 5; coefi++) {\n      if (qtable->quantval[coefi] == 0)\n\treturn FALSE;\n    }\n    /* DC values must be at least partly known for all components. */\n    coef_bits = cinfo->coef_bits[ci];\n    if (coef_bits[0] < 0)\n      return FALSE;\n    /* Block smoothing is helpful if some AC coefficients remain inaccurate. */\n    for (coefi = 1; coefi <= 5; coefi++) {\n      coef_bits_latch[coefi] = coef_bits[coefi];\n      if (coef_bits[coefi] != 0)\n\tsmoothing_useful = TRUE;\n    }\n    coef_bits_latch += SAVED_COEFS;\n  }\n\n  return smoothing_useful;\n}\n\n\n/*\n * Variant of decompress_data for use when doing block smoothing.\n */\n\nMETHODDEF int\ndecompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)\n{\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;\n  JDIMENSION block_num, last_block_column;\n  int ci, block_row, block_rows, access_rows;\n  JBLOCKARRAY buffer;\n  JBLOCKROW buffer_ptr, prev_block_row, next_block_row;\n  JSAMPARRAY output_ptr;\n  JDIMENSION output_col;\n  jpeg_component_info *compptr;\n  inverse_DCT_method_ptr inverse_DCT;\n  boolean first_row, last_row;\n  JBLOCK workspace;\n  int *coef_bits;\n  JQUANT_TBL *quanttbl;\n  INT32 Q00,Q01,Q02,Q10,Q11,Q20, num;\n  int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9;\n  int Al, pred;\n\n  /* Force some input to be done if we are getting ahead of the input. */\n  while (cinfo->input_scan_number <= cinfo->output_scan_number &&\n\t ! cinfo->inputctl->eoi_reached) {\n    if (cinfo->input_scan_number == cinfo->output_scan_number) {\n      /* If input is working on current scan, we ordinarily want it to\n       * have completed the current row.  But if input scan is DC,\n       * we want it to keep one row ahead so that next block row's DC\n       * values are up to date.\n       */\n      JDIMENSION delta = (cinfo->Ss == 0) ? 1 : 0;\n      if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta)\n\tbreak;\n    }\n    if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED)\n      return JPEG_SUSPENDED;\n  }\n\n  /* OK, output from the virtual arrays. */\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    /* Don't bother to IDCT an uninteresting component. */\n    if (! compptr->component_needed)\n      continue;\n    /* Count non-dummy DCT block rows in this iMCU row. */\n    if (cinfo->output_iMCU_row < last_iMCU_row) {\n      block_rows = compptr->v_samp_factor;\n      access_rows = block_rows * 2; /* this and next iMCU row */\n      last_row = FALSE;\n    } else {\n      /* NB: can't use last_row_height here; it is input-side-dependent! */\n      block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);\n      if (block_rows == 0) block_rows = compptr->v_samp_factor;\n      access_rows = block_rows; /* this iMCU row only */\n      last_row = TRUE;\n    }\n    /* Align the virtual buffer for this component. */\n    if (cinfo->output_iMCU_row > 0) {\n      access_rows += compptr->v_samp_factor; /* prior iMCU row too */\n      buffer = (*cinfo->mem->access_virt_barray)\n\t((j_common_ptr) cinfo, coef->whole_image[ci],\n\t (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor,\n\t (JDIMENSION) access_rows, FALSE);\n      buffer += compptr->v_samp_factor;\t/* point to current iMCU row */\n      first_row = FALSE;\n    } else {\n      buffer = (*cinfo->mem->access_virt_barray)\n\t((j_common_ptr) cinfo, coef->whole_image[ci],\n\t (JDIMENSION) 0, (JDIMENSION) access_rows, FALSE);\n      first_row = TRUE;\n    }\n    /* Fetch component-dependent info */\n    coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS);\n    quanttbl = compptr->quant_table;\n    Q00 = quanttbl->quantval[0];\n    Q01 = quanttbl->quantval[1];\n    Q10 = quanttbl->quantval[2];\n    Q20 = quanttbl->quantval[3];\n    Q11 = quanttbl->quantval[4];\n    Q02 = quanttbl->quantval[5];\n    inverse_DCT = cinfo->idct->inverse_DCT[ci];\n    output_ptr = output_buf[ci];\n    /* Loop over all DCT blocks to be processed. */\n    for (block_row = 0; block_row < block_rows; block_row++) {\n      buffer_ptr = buffer[block_row];\n      if (first_row && block_row == 0)\n\tprev_block_row = buffer_ptr;\n      else\n\tprev_block_row = buffer[block_row-1];\n      if (last_row && block_row == block_rows-1)\n\tnext_block_row = buffer_ptr;\n      else\n\tnext_block_row = buffer[block_row+1];\n      /* We fetch the surrounding DC values using a sliding-register approach.\n       * Initialize all nine here so as to do the right thing on narrow pics.\n       */\n      DC1 = DC2 = DC3 = (int) prev_block_row[0][0];\n      DC4 = DC5 = DC6 = (int) buffer_ptr[0][0];\n      DC7 = DC8 = DC9 = (int) next_block_row[0][0];\n      output_col = 0;\n      last_block_column = compptr->width_in_blocks - 1;\n      for (block_num = 0; block_num <= last_block_column; block_num++) {\n\t/* Fetch current DCT block into workspace so we can modify it. */\n\tjcopy_block_row(buffer_ptr, (JBLOCKROW) workspace, (JDIMENSION) 1);\n\t/* Update DC values */\n\tif (block_num < last_block_column) {\n\t  DC3 = (int) prev_block_row[1][0];\n\t  DC6 = (int) buffer_ptr[1][0];\n\t  DC9 = (int) next_block_row[1][0];\n\t}\n\t/* Compute coefficient estimates per K.8.\n\t * An estimate is applied only if coefficient is still zero,\n\t * and is not known to be fully accurate.\n\t */\n\t/* AC01 */\n\tif ((Al=coef_bits[1]) != 0 && workspace[1] == 0) {\n\t  num = 36 * Q00 * (DC4 - DC6);\n\t  if (num >= 0) {\n\t    pred = (int) (((Q01<<7) + num) / (Q01<<8));\n\t    if (Al > 0 && pred >= (1<<Al))\n\t      pred = (1<<Al)-1;\n\t  } else {\n\t    pred = (int) (((Q01<<7) - num) / (Q01<<8));\n\t    if (Al > 0 && pred >= (1<<Al))\n\t      pred = (1<<Al)-1;\n\t    pred = -pred;\n\t  }\n\t  workspace[1] = (JCOEF) pred;\n\t}\n\t/* AC10 */\n\tif ((Al=coef_bits[2]) != 0 && workspace[8] == 0) {\n\t  num = 36 * Q00 * (DC2 - DC8);\n\t  if (num >= 0) {\n\t    pred = (int) (((Q10<<7) + num) / (Q10<<8));\n\t    if (Al > 0 && pred >= (1<<Al))\n\t      pred = (1<<Al)-1;\n\t  } else {\n\t    pred = (int) (((Q10<<7) - num) / (Q10<<8));\n\t    if (Al > 0 && pred >= (1<<Al))\n\t      pred = (1<<Al)-1;\n\t    pred = -pred;\n\t  }\n\t  workspace[8] = (JCOEF) pred;\n\t}\n\t/* AC20 */\n\tif ((Al=coef_bits[3]) != 0 && workspace[16] == 0) {\n\t  num = 9 * Q00 * (DC2 + DC8 - 2*DC5);\n\t  if (num >= 0) {\n\t    pred = (int) (((Q20<<7) + num) / (Q20<<8));\n\t    if (Al > 0 && pred >= (1<<Al))\n\t      pred = (1<<Al)-1;\n\t  } else {\n\t    pred = (int) (((Q20<<7) - num) / (Q20<<8));\n\t    if (Al > 0 && pred >= (1<<Al))\n\t      pred = (1<<Al)-1;\n\t    pred = -pred;\n\t  }\n\t  workspace[16] = (JCOEF) pred;\n\t}\n\t/* AC11 */\n\tif ((Al=coef_bits[4]) != 0 && workspace[9] == 0) {\n\t  num = 5 * Q00 * (DC1 - DC3 - DC7 + DC9);\n\t  if (num >= 0) {\n\t    pred = (int) (((Q11<<7) + num) / (Q11<<8));\n\t    if (Al > 0 && pred >= (1<<Al))\n\t      pred = (1<<Al)-1;\n\t  } else {\n\t    pred = (int) (((Q11<<7) - num) / (Q11<<8));\n\t    if (Al > 0 && pred >= (1<<Al))\n\t      pred = (1<<Al)-1;\n\t    pred = -pred;\n\t  }\n\t  workspace[9] = (JCOEF) pred;\n\t}\n\t/* AC02 */\n\tif ((Al=coef_bits[5]) != 0 && workspace[2] == 0) {\n\t  num = 9 * Q00 * (DC4 + DC6 - 2*DC5);\n\t  if (num >= 0) {\n\t    pred = (int) (((Q02<<7) + num) / (Q02<<8));\n\t    if (Al > 0 && pred >= (1<<Al))\n\t      pred = (1<<Al)-1;\n\t  } else {\n\t    pred = (int) (((Q02<<7) - num) / (Q02<<8));\n\t    if (Al > 0 && pred >= (1<<Al))\n\t      pred = (1<<Al)-1;\n\t    pred = -pred;\n\t  }\n\t  workspace[2] = (JCOEF) pred;\n\t}\n\t/* OK, do the IDCT */\n\t(*inverse_DCT) (cinfo, compptr, (JCOEFPTR) workspace,\n\t\t\toutput_ptr, output_col);\n\t/* Advance for next column */\n\tDC1 = DC2; DC2 = DC3;\n\tDC4 = DC5; DC5 = DC6;\n\tDC7 = DC8; DC8 = DC9;\n\tbuffer_ptr++, prev_block_row++, next_block_row++;\n\toutput_col += compptr->DCT_scaled_size;\n      }\n      output_ptr += compptr->DCT_scaled_size;\n    }\n  }\n\n  if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)\n    return JPEG_ROW_COMPLETED;\n  return JPEG_SCAN_COMPLETED;\n}\n\n#endif /* BLOCK_SMOOTHING_SUPPORTED */\n\n\n/*\n * Initialize coefficient buffer controller.\n */\n\nGLOBAL void\njinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)\n{\n  my_coef_ptr coef;\n\n  coef = (my_coef_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_coef_controller));\n  cinfo->coef = (struct jpeg_d_coef_controller *) coef;\n  coef->pub.start_input_pass = start_input_pass;\n  coef->pub.start_output_pass = start_output_pass;\n#ifdef BLOCK_SMOOTHING_SUPPORTED\n  coef->coef_bits_latch = NULL;\n#endif\n\n  /* Create the coefficient buffer. */\n  if (need_full_buffer) {\n#ifdef D_MULTISCAN_FILES_SUPPORTED\n    /* Allocate a full-image virtual array for each component, */\n    /* padded to a multiple of samp_factor DCT blocks in each direction. */\n    /* Note we ask for a pre-zeroed array. */\n    int ci, access_rows;\n    jpeg_component_info *compptr;\n\n    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n\t ci++, compptr++) {\n      access_rows = compptr->v_samp_factor;\n#ifdef BLOCK_SMOOTHING_SUPPORTED\n      /* If block smoothing could be used, need a bigger window */\n      if (cinfo->progressive_mode)\n\taccess_rows *= 3;\n#endif\n      coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)\n\t((j_common_ptr) cinfo, JPOOL_IMAGE, TRUE,\n\t (JDIMENSION) jround_up((long) compptr->width_in_blocks,\n\t\t\t\t(long) compptr->h_samp_factor),\n\t (JDIMENSION) jround_up((long) compptr->height_in_blocks,\n\t\t\t\t(long) compptr->v_samp_factor),\n\t (JDIMENSION) access_rows);\n    }\n    coef->pub.consume_data = consume_data;\n    coef->pub.decompress_data = decompress_data;\n    coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */\n#else\n    ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif\n  } else {\n    /* We only need a single-MCU buffer. */\n    JBLOCKROW buffer;\n    int i;\n\n    buffer = (JBLOCKROW)\n      (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t  D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));\n    for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {\n      coef->MCU_buffer[i] = buffer + i;\n    }\n    coef->pub.consume_data = dummy_consume_data;\n    coef->pub.decompress_data = decompress_onepass;\n    coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */\n  }\n}\n"
  },
  {
    "path": "code/jpeg-6/jdcolor.c",
    "content": "/*\n * jdcolor.c\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains output colorspace conversion routines.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/* Private subobject */\n\ntypedef struct {\n  struct jpeg_color_deconverter pub; /* public fields */\n\n  /* Private state for YCC->RGB conversion */\n  int * Cr_r_tab;\t\t/* => table for Cr to R conversion */\n  int * Cb_b_tab;\t\t/* => table for Cb to B conversion */\n  INT32 * Cr_g_tab;\t\t/* => table for Cr to G conversion */\n  INT32 * Cb_g_tab;\t\t/* => table for Cb to G conversion */\n} my_color_deconverter;\n\ntypedef my_color_deconverter * my_cconvert_ptr;\n\n\n/**************** YCbCr -> RGB conversion: most common case **************/\n\n/*\n * YCbCr is defined per CCIR 601-1, except that Cb and Cr are\n * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.\n * The conversion equations to be implemented are therefore\n *\tR = Y                + 1.40200 * Cr\n *\tG = Y - 0.34414 * Cb - 0.71414 * Cr\n *\tB = Y + 1.77200 * Cb\n * where Cb and Cr represent the incoming values less CENTERJSAMPLE.\n * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)\n *\n * To avoid floating-point arithmetic, we represent the fractional constants\n * as integers scaled up by 2^16 (about 4 digits precision); we have to divide\n * the products by 2^16, with appropriate rounding, to get the correct answer.\n * Notice that Y, being an integral input, does not contribute any fraction\n * so it need not participate in the rounding.\n *\n * For even more speed, we avoid doing any multiplications in the inner loop\n * by precalculating the constants times Cb and Cr for all possible values.\n * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);\n * for 12-bit samples it is still acceptable.  It's not very reasonable for\n * 16-bit samples, but if you want lossless storage you shouldn't be changing\n * colorspace anyway.\n * The Cr=>R and Cb=>B values can be rounded to integers in advance; the\n * values for the G calculation are left scaled up, since we must add them\n * together before rounding.\n */\n\n#define SCALEBITS\t16\t/* speediest right-shift on some machines */\n#define ONE_HALF\t((INT32) 1 << (SCALEBITS-1))\n#define FIX(x)\t\t((INT32) ((x) * (1L<<SCALEBITS) + 0.5))\n\n\n/*\n * Initialize tables for YCC->RGB colorspace conversion.\n */\n\nLOCAL void\nbuild_ycc_rgb_table (j_decompress_ptr cinfo)\n{\n  my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;\n  int i;\n  INT32 x;\n  SHIFT_TEMPS\n\n  cconvert->Cr_r_tab = (int *)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t(MAXJSAMPLE+1) * SIZEOF(int));\n  cconvert->Cb_b_tab = (int *)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t(MAXJSAMPLE+1) * SIZEOF(int));\n  cconvert->Cr_g_tab = (INT32 *)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t(MAXJSAMPLE+1) * SIZEOF(INT32));\n  cconvert->Cb_g_tab = (INT32 *)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t(MAXJSAMPLE+1) * SIZEOF(INT32));\n\n  for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {\n    /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */\n    /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */\n    /* Cr=>R value is nearest int to 1.40200 * x */\n    cconvert->Cr_r_tab[i] = (int)\n\t\t    RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS);\n    /* Cb=>B value is nearest int to 1.77200 * x */\n    cconvert->Cb_b_tab[i] = (int)\n\t\t    RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS);\n    /* Cr=>G value is scaled-up -0.71414 * x */\n    cconvert->Cr_g_tab[i] = (- FIX(0.71414)) * x;\n    /* Cb=>G value is scaled-up -0.34414 * x */\n    /* We also add in ONE_HALF so that need not do it in inner loop */\n    cconvert->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF;\n  }\n}\n\n\n/*\n * Convert some rows of samples to the output colorspace.\n *\n * Note that we change from noninterleaved, one-plane-per-component format\n * to interleaved-pixel format.  The output buffer is therefore three times\n * as wide as the input buffer.\n * A starting row offset is provided only for the input buffer.  The caller\n * can easily adjust the passed output_buf value to accommodate any row\n * offset required on that side.\n */\n\nMETHODDEF void\nycc_rgb_convert (j_decompress_ptr cinfo,\n\t\t JSAMPIMAGE input_buf, JDIMENSION input_row,\n\t\t JSAMPARRAY output_buf, int num_rows)\n{\n  my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;\n  register int y, cb, cr;\n  register JSAMPROW outptr;\n  register JSAMPROW inptr0, inptr1, inptr2;\n  register JDIMENSION col;\n  JDIMENSION num_cols = cinfo->output_width;\n  /* copy these pointers into registers if possible */\n  register JSAMPLE * range_limit = cinfo->sample_range_limit;\n  register int * Crrtab = cconvert->Cr_r_tab;\n  register int * Cbbtab = cconvert->Cb_b_tab;\n  register INT32 * Crgtab = cconvert->Cr_g_tab;\n  register INT32 * Cbgtab = cconvert->Cb_g_tab;\n  SHIFT_TEMPS\n\n  while (--num_rows >= 0) {\n    inptr0 = input_buf[0][input_row];\n    inptr1 = input_buf[1][input_row];\n    inptr2 = input_buf[2][input_row];\n    input_row++;\n    outptr = *output_buf++;\n    for (col = 0; col < num_cols; col++) {\n      y  = GETJSAMPLE(inptr0[col]);\n      cb = GETJSAMPLE(inptr1[col]);\n      cr = GETJSAMPLE(inptr2[col]);\n      /* Range-limiting is essential due to noise introduced by DCT losses. */\n      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];\n      outptr[RGB_GREEN] = range_limit[y +\n\t\t\t      ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],\n\t\t\t\t\t\t SCALEBITS))];\n      outptr[RGB_BLUE] =  range_limit[y + Cbbtab[cb]];\n      outptr += RGB_PIXELSIZE;\n    }\n  }\n}\n\n\n/**************** Cases other than YCbCr -> RGB **************/\n\n\n/*\n * Color conversion for no colorspace change: just copy the data,\n * converting from separate-planes to interleaved representation.\n */\n\nMETHODDEF void\nnull_convert (j_decompress_ptr cinfo,\n\t      JSAMPIMAGE input_buf, JDIMENSION input_row,\n\t      JSAMPARRAY output_buf, int num_rows)\n{\n  register JSAMPROW inptr, outptr;\n  register JDIMENSION count;\n  register int num_components = cinfo->num_components;\n  JDIMENSION num_cols = cinfo->output_width;\n  int ci;\n\n  while (--num_rows >= 0) {\n    for (ci = 0; ci < num_components; ci++) {\n      inptr = input_buf[ci][input_row];\n      outptr = output_buf[0] + ci;\n      for (count = num_cols; count > 0; count--) {\n\t*outptr = *inptr++;\t/* needn't bother with GETJSAMPLE() here */\n\toutptr += num_components;\n      }\n    }\n    input_row++;\n    output_buf++;\n  }\n}\n\n\n/*\n * Color conversion for grayscale: just copy the data.\n * This also works for YCbCr -> grayscale conversion, in which\n * we just copy the Y (luminance) component and ignore chrominance.\n */\n\nMETHODDEF void\ngrayscale_convert (j_decompress_ptr cinfo,\n\t\t   JSAMPIMAGE input_buf, JDIMENSION input_row,\n\t\t   JSAMPARRAY output_buf, int num_rows)\n{\n  jcopy_sample_rows(input_buf[0], (int) input_row, output_buf, 0,\n\t\t    num_rows, cinfo->output_width);\n}\n\n\n/*\n * Adobe-style YCCK->CMYK conversion.\n * We convert YCbCr to R=1-C, G=1-M, and B=1-Y using the same\n * conversion as above, while passing K (black) unchanged.\n * We assume build_ycc_rgb_table has been called.\n */\n\nMETHODDEF void\nycck_cmyk_convert (j_decompress_ptr cinfo,\n\t\t   JSAMPIMAGE input_buf, JDIMENSION input_row,\n\t\t   JSAMPARRAY output_buf, int num_rows)\n{\n  my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;\n  register int y, cb, cr;\n  register JSAMPROW outptr;\n  register JSAMPROW inptr0, inptr1, inptr2, inptr3;\n  register JDIMENSION col;\n  JDIMENSION num_cols = cinfo->output_width;\n  /* copy these pointers into registers if possible */\n  register JSAMPLE * range_limit = cinfo->sample_range_limit;\n  register int * Crrtab = cconvert->Cr_r_tab;\n  register int * Cbbtab = cconvert->Cb_b_tab;\n  register INT32 * Crgtab = cconvert->Cr_g_tab;\n  register INT32 * Cbgtab = cconvert->Cb_g_tab;\n  SHIFT_TEMPS\n\n  while (--num_rows >= 0) {\n    inptr0 = input_buf[0][input_row];\n    inptr1 = input_buf[1][input_row];\n    inptr2 = input_buf[2][input_row];\n    inptr3 = input_buf[3][input_row];\n    input_row++;\n    outptr = *output_buf++;\n    for (col = 0; col < num_cols; col++) {\n      y  = GETJSAMPLE(inptr0[col]);\n      cb = GETJSAMPLE(inptr1[col]);\n      cr = GETJSAMPLE(inptr2[col]);\n      /* Range-limiting is essential due to noise introduced by DCT losses. */\n      outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])];\t/* red */\n      outptr[1] = range_limit[MAXJSAMPLE - (y +\t\t\t/* green */\n\t\t\t      ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],\n\t\t\t\t\t\t SCALEBITS)))];\n      outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])];\t/* blue */\n      /* K passes through unchanged */\n      outptr[3] = inptr3[col];\t/* don't need GETJSAMPLE here */\n      outptr += 4;\n    }\n  }\n}\n\n\n/*\n * Empty method for start_pass.\n */\n\nMETHODDEF void\nstart_pass_dcolor (j_decompress_ptr cinfo)\n{\n  /* no work needed */\n}\n\n\n/*\n * Module initialization routine for output colorspace conversion.\n */\n\nGLOBAL void\njinit_color_deconverter (j_decompress_ptr cinfo)\n{\n  my_cconvert_ptr cconvert;\n  int ci;\n\n  cconvert = (my_cconvert_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_color_deconverter));\n  cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert;\n  cconvert->pub.start_pass = start_pass_dcolor;\n\n  /* Make sure num_components agrees with jpeg_color_space */\n  switch (cinfo->jpeg_color_space) {\n  case JCS_GRAYSCALE:\n    if (cinfo->num_components != 1)\n      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);\n    break;\n\n  case JCS_RGB:\n  case JCS_YCbCr:\n    if (cinfo->num_components != 3)\n      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);\n    break;\n\n  case JCS_CMYK:\n  case JCS_YCCK:\n    if (cinfo->num_components != 4)\n      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);\n    break;\n\n  default:\t\t\t/* JCS_UNKNOWN can be anything */\n    if (cinfo->num_components < 1)\n      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);\n    break;\n  }\n\n  /* Set out_color_components and conversion method based on requested space.\n   * Also clear the component_needed flags for any unused components,\n   * so that earlier pipeline stages can avoid useless computation.\n   */\n\n  switch (cinfo->out_color_space) {\n  case JCS_GRAYSCALE:\n    cinfo->out_color_components = 1;\n    if (cinfo->jpeg_color_space == JCS_GRAYSCALE ||\n\tcinfo->jpeg_color_space == JCS_YCbCr) {\n      cconvert->pub.color_convert = grayscale_convert;\n      /* For color->grayscale conversion, only the Y (0) component is needed */\n      for (ci = 1; ci < cinfo->num_components; ci++)\n\tcinfo->comp_info[ci].component_needed = FALSE;\n    } else\n      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);\n    break;\n\n  case JCS_RGB:\n    cinfo->out_color_components = RGB_PIXELSIZE;\n    if (cinfo->jpeg_color_space == JCS_YCbCr) {\n      cconvert->pub.color_convert = ycc_rgb_convert;\n      build_ycc_rgb_table(cinfo);\n    } else if (cinfo->jpeg_color_space == JCS_RGB && RGB_PIXELSIZE == 3) {\n      cconvert->pub.color_convert = null_convert;\n    } else\n      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);\n    break;\n\n  case JCS_CMYK:\n    cinfo->out_color_components = 4;\n    if (cinfo->jpeg_color_space == JCS_YCCK) {\n      cconvert->pub.color_convert = ycck_cmyk_convert;\n      build_ycc_rgb_table(cinfo);\n    } else if (cinfo->jpeg_color_space == JCS_CMYK) {\n      cconvert->pub.color_convert = null_convert;\n    } else\n      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);\n    break;\n\n  default:\n    /* Permit null conversion to same output space */\n    if (cinfo->out_color_space == cinfo->jpeg_color_space) {\n      cinfo->out_color_components = cinfo->num_components;\n      cconvert->pub.color_convert = null_convert;\n    } else\t\t\t/* unsupported non-null conversion */\n      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);\n    break;\n  }\n\n  if (cinfo->quantize_colors)\n    cinfo->output_components = 1; /* single colormapped output component */\n  else\n    cinfo->output_components = cinfo->out_color_components;\n}\n"
  },
  {
    "path": "code/jpeg-6/jdct.h",
    "content": "/*\n * jdct.h\n *\n * Copyright (C) 1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This include file contains common declarations for the forward and\n * inverse DCT modules.  These declarations are private to the DCT managers\n * (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms.\n * The individual DCT algorithms are kept in separate files to ease \n * machine-dependent tuning (e.g., assembly coding).\n */\n\n\n/*\n * A forward DCT routine is given a pointer to a work area of type DCTELEM[];\n * the DCT is to be performed in-place in that buffer.  Type DCTELEM is int\n * for 8-bit samples, INT32 for 12-bit samples.  (NOTE: Floating-point DCT\n * implementations use an array of type FAST_FLOAT, instead.)\n * The DCT inputs are expected to be signed (range +-CENTERJSAMPLE).\n * The DCT outputs are returned scaled up by a factor of 8; they therefore\n * have a range of +-8K for 8-bit data, +-128K for 12-bit data.  This\n * convention improves accuracy in integer implementations and saves some\n * work in floating-point ones.\n * Quantization of the output coefficients is done by jcdctmgr.c.\n */\n\n#if BITS_IN_JSAMPLE == 8\ntypedef int DCTELEM;\t\t/* 16 or 32 bits is fine */\n#else\ntypedef INT32 DCTELEM;\t\t/* must have 32 bits */\n#endif\n\ntypedef JMETHOD(void, forward_DCT_method_ptr, (DCTELEM * data));\ntypedef JMETHOD(void, float_DCT_method_ptr, (FAST_FLOAT * data));\n\n\n/*\n * An inverse DCT routine is given a pointer to the input JBLOCK and a pointer\n * to an output sample array.  The routine must dequantize the input data as\n * well as perform the IDCT; for dequantization, it uses the multiplier table\n * pointed to by compptr->dct_table.  The output data is to be placed into the\n * sample array starting at a specified column.  (Any row offset needed will\n * be applied to the array pointer before it is passed to the IDCT code.)\n * Note that the number of samples emitted by the IDCT routine is\n * DCT_scaled_size * DCT_scaled_size.\n */\n\n/* typedef inverse_DCT_method_ptr is declared in jpegint.h */\n\n/*\n * Each IDCT routine has its own ideas about the best dct_table element type.\n */\n\ntypedef MULTIPLIER ISLOW_MULT_TYPE; /* short or int, whichever is faster */\n#if BITS_IN_JSAMPLE == 8\ntypedef MULTIPLIER IFAST_MULT_TYPE; /* 16 bits is OK, use short if faster */\n#define IFAST_SCALE_BITS  2\t/* fractional bits in scale factors */\n#else\ntypedef INT32 IFAST_MULT_TYPE;\t/* need 32 bits for scaled quantizers */\n#define IFAST_SCALE_BITS  13\t/* fractional bits in scale factors */\n#endif\ntypedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */\n\n\n/*\n * Each IDCT routine is responsible for range-limiting its results and\n * converting them to unsigned form (0..MAXJSAMPLE).  The raw outputs could\n * be quite far out of range if the input data is corrupt, so a bulletproof\n * range-limiting step is required.  We use a mask-and-table-lookup method\n * to do the combined operations quickly.  See the comments with\n * prepare_range_limit_table (in jdmaster.c) for more info.\n */\n\n#define IDCT_range_limit(cinfo)  ((cinfo)->sample_range_limit + CENTERJSAMPLE)\n\n#define RANGE_MASK  (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */\n\n\n/* Short forms of external names for systems with brain-damaged linkers. */\n\n#ifdef NEED_SHORT_EXTERNAL_NAMES\n#define jpeg_fdct_islow\t\tjFDislow\n#define jpeg_fdct_ifast\t\tjFDifast\n#define jpeg_fdct_float\t\tjFDfloat\n#define jpeg_idct_islow\t\tjRDislow\n#define jpeg_idct_ifast\t\tjRDifast\n#define jpeg_idct_float\t\tjRDfloat\n#define jpeg_idct_4x4\t\tjRD4x4\n#define jpeg_idct_2x2\t\tjRD2x2\n#define jpeg_idct_1x1\t\tjRD1x1\n#endif /* NEED_SHORT_EXTERNAL_NAMES */\n\n/* Extern declarations for the forward and inverse DCT routines. */\n\nEXTERN void jpeg_fdct_islow JPP((DCTELEM * data));\nEXTERN void jpeg_fdct_ifast JPP((DCTELEM * data));\nEXTERN void jpeg_fdct_float JPP((FAST_FLOAT * data));\n\nEXTERN void jpeg_idct_islow\n    JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));\nEXTERN void jpeg_idct_ifast\n    JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));\nEXTERN void jpeg_idct_float\n    JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));\nEXTERN void jpeg_idct_4x4\n    JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));\nEXTERN void jpeg_idct_2x2\n    JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));\nEXTERN void jpeg_idct_1x1\n    JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));\n\n\n/*\n * Macros for handling fixed-point arithmetic; these are used by many\n * but not all of the DCT/IDCT modules.\n *\n * All values are expected to be of type INT32.\n * Fractional constants are scaled left by CONST_BITS bits.\n * CONST_BITS is defined within each module using these macros,\n * and may differ from one module to the next.\n */\n\n#define ONE\t((INT32) 1)\n#define CONST_SCALE (ONE << CONST_BITS)\n\n/* Convert a positive real constant to an integer scaled by CONST_SCALE.\n * Caution: some C compilers fail to reduce \"FIX(constant)\" at compile time,\n * thus causing a lot of useless floating-point operations at run time.\n */\n\n#define FIX(x)\t((INT32) ((x) * CONST_SCALE + 0.5))\n\n/* Descale and correctly round an INT32 value that's scaled by N bits.\n * We assume RIGHT_SHIFT rounds towards minus infinity, so adding\n * the fudge factor is correct for either sign of X.\n */\n\n#define DESCALE(x,n)  RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)\n\n/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.\n * This macro is used only when the two inputs will actually be no more than\n * 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a\n * full 32x32 multiply.  This provides a useful speedup on many machines.\n * Unfortunately there is no way to specify a 16x16->32 multiply portably\n * in C, but some C compilers will do the right thing if you provide the\n * correct combination of casts.\n */\n\n#ifdef SHORTxSHORT_32\t\t/* may work if 'int' is 32 bits */\n#define MULTIPLY16C16(var,const)  (((INT16) (var)) * ((INT16) (const)))\n#endif\n#ifdef SHORTxLCONST_32\t\t/* known to work with Microsoft C 6.0 */\n#define MULTIPLY16C16(var,const)  (((INT16) (var)) * ((INT32) (const)))\n#endif\n\n#ifndef MULTIPLY16C16\t\t/* default definition */\n#define MULTIPLY16C16(var,const)  ((var) * (const))\n#endif\n\n/* Same except both inputs are variables. */\n\n#ifdef SHORTxSHORT_32\t\t/* may work if 'int' is 32 bits */\n#define MULTIPLY16V16(var1,var2)  (((INT16) (var1)) * ((INT16) (var2)))\n#endif\n\n#ifndef MULTIPLY16V16\t\t/* default definition */\n#define MULTIPLY16V16(var1,var2)  ((var1) * (var2))\n#endif\n"
  },
  {
    "path": "code/jpeg-6/jddctmgr.c",
    "content": "/*\n * jddctmgr.c\n *\n * Copyright (C) 1994-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains the inverse-DCT management logic.\n * This code selects a particular IDCT implementation to be used,\n * and it performs related housekeeping chores.  No code in this file\n * is executed per IDCT step, only during output pass setup.\n *\n * Note that the IDCT routines are responsible for performing coefficient\n * dequantization as well as the IDCT proper.  This module sets up the\n * dequantization multiplier table needed by the IDCT routine.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jdct.h\"\t\t/* Private declarations for DCT subsystem */\n\n\n/*\n * The decompressor input side (jdinput.c) saves away the appropriate\n * quantization table for each component at the start of the first scan\n * involving that component.  (This is necessary in order to correctly\n * decode files that reuse Q-table slots.)\n * When we are ready to make an output pass, the saved Q-table is converted\n * to a multiplier table that will actually be used by the IDCT routine.\n * The multiplier table contents are IDCT-method-dependent.  To support\n * application changes in IDCT method between scans, we can remake the\n * multiplier tables if necessary.\n * In buffered-image mode, the first output pass may occur before any data\n * has been seen for some components, and thus before their Q-tables have\n * been saved away.  To handle this case, multiplier tables are preset\n * to zeroes; the result of the IDCT will be a neutral gray level.\n */\n\n\n/* Private subobject for this module */\n\ntypedef struct {\n  struct jpeg_inverse_dct pub;\t/* public fields */\n\n  /* This array contains the IDCT method code that each multiplier table\n   * is currently set up for, or -1 if it's not yet set up.\n   * The actual multiplier tables are pointed to by dct_table in the\n   * per-component comp_info structures.\n   */\n  int cur_method[MAX_COMPONENTS];\n} my_idct_controller;\n\ntypedef my_idct_controller * my_idct_ptr;\n\n\n/* Allocated multiplier tables: big enough for any supported variant */\n\ntypedef union {\n  ISLOW_MULT_TYPE islow_array[DCTSIZE2];\n#ifdef DCT_IFAST_SUPPORTED\n  IFAST_MULT_TYPE ifast_array[DCTSIZE2];\n#endif\n#ifdef DCT_FLOAT_SUPPORTED\n  FLOAT_MULT_TYPE float_array[DCTSIZE2];\n#endif\n} multiplier_table;\n\n\n/* The current scaled-IDCT routines require ISLOW-style multiplier tables,\n * so be sure to compile that code if either ISLOW or SCALING is requested.\n */\n#ifdef DCT_ISLOW_SUPPORTED\n#define PROVIDE_ISLOW_TABLES\n#else\n#ifdef IDCT_SCALING_SUPPORTED\n#define PROVIDE_ISLOW_TABLES\n#endif\n#endif\n\n\n/*\n * Prepare for an output pass.\n * Here we select the proper IDCT routine for each component and build\n * a matching multiplier table.\n */\n\nMETHODDEF void\nstart_pass (j_decompress_ptr cinfo)\n{\n  my_idct_ptr idct = (my_idct_ptr) cinfo->idct;\n  int ci, i;\n  jpeg_component_info *compptr;\n  int method = 0;\n  inverse_DCT_method_ptr method_ptr = NULL;\n  JQUANT_TBL * qtbl;\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    /* Select the proper IDCT routine for this component's scaling */\n    switch (compptr->DCT_scaled_size) {\n#ifdef IDCT_SCALING_SUPPORTED\n    case 1:\n      method_ptr = jpeg_idct_1x1;\n      method = JDCT_ISLOW;\t/* jidctred uses islow-style table */\n      break;\n    case 2:\n      method_ptr = jpeg_idct_2x2;\n      method = JDCT_ISLOW;\t/* jidctred uses islow-style table */\n      break;\n    case 4:\n      method_ptr = jpeg_idct_4x4;\n      method = JDCT_ISLOW;\t/* jidctred uses islow-style table */\n      break;\n#endif\n    case DCTSIZE:\n      switch (cinfo->dct_method) {\n#ifdef DCT_ISLOW_SUPPORTED\n      case JDCT_ISLOW:\n\tmethod_ptr = jpeg_idct_islow;\n\tmethod = JDCT_ISLOW;\n\tbreak;\n#endif\n#ifdef DCT_IFAST_SUPPORTED\n      case JDCT_IFAST:\n\tmethod_ptr = jpeg_idct_ifast;\n\tmethod = JDCT_IFAST;\n\tbreak;\n#endif\n#ifdef DCT_FLOAT_SUPPORTED\n      case JDCT_FLOAT:\n\tmethod_ptr = jpeg_idct_float;\n\tmethod = JDCT_FLOAT;\n\tbreak;\n#endif\n      default:\n\tERREXIT(cinfo, JERR_NOT_COMPILED);\n\tbreak;\n      }\n      break;\n    default:\n      ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->DCT_scaled_size);\n      break;\n    }\n    idct->pub.inverse_DCT[ci] = method_ptr;\n    /* Create multiplier table from quant table.\n     * However, we can skip this if the component is uninteresting\n     * or if we already built the table.  Also, if no quant table\n     * has yet been saved for the component, we leave the\n     * multiplier table all-zero; we'll be reading zeroes from the\n     * coefficient controller's buffer anyway.\n     */\n    if (! compptr->component_needed || idct->cur_method[ci] == method)\n      continue;\n    qtbl = compptr->quant_table;\n    if (qtbl == NULL)\t\t/* happens if no data yet for component */\n      continue;\n    idct->cur_method[ci] = method;\n    switch (method) {\n#ifdef PROVIDE_ISLOW_TABLES\n    case JDCT_ISLOW:\n      {\n\t/* For LL&M IDCT method, multipliers are equal to raw quantization\n\t * coefficients, but are stored in natural order as ints.\n\t */\n\tISLOW_MULT_TYPE * ismtbl = (ISLOW_MULT_TYPE *) compptr->dct_table;\n\tfor (i = 0; i < DCTSIZE2; i++) {\n\t  ismtbl[i] = (ISLOW_MULT_TYPE) qtbl->quantval[jpeg_zigzag_order[i]];\n\t}\n      }\n      break;\n#endif\n#ifdef DCT_IFAST_SUPPORTED\n    case JDCT_IFAST:\n      {\n\t/* For AA&N IDCT method, multipliers are equal to quantization\n\t * coefficients scaled by scalefactor[row]*scalefactor[col], where\n\t *   scalefactor[0] = 1\n\t *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7\n\t * For integer operation, the multiplier table is to be scaled by\n\t * IFAST_SCALE_BITS.  The multipliers are stored in natural order.\n\t */\n\tIFAST_MULT_TYPE * ifmtbl = (IFAST_MULT_TYPE *) compptr->dct_table;\n#define CONST_BITS 14\n\tstatic const INT16 aanscales[DCTSIZE2] = {\n\t  /* precomputed values scaled up by 14 bits */\n\t  16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,\n\t  22725, 31521, 29692, 26722, 22725, 17855, 12299,  6270,\n\t  21407, 29692, 27969, 25172, 21407, 16819, 11585,  5906,\n\t  19266, 26722, 25172, 22654, 19266, 15137, 10426,  5315,\n\t  16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,\n\t  12873, 17855, 16819, 15137, 12873, 10114,  6967,  3552,\n\t   8867, 12299, 11585, 10426,  8867,  6967,  4799,  2446,\n\t   4520,  6270,  5906,  5315,  4520,  3552,  2446,  1247\n\t};\n\tSHIFT_TEMPS\n\n\tfor (i = 0; i < DCTSIZE2; i++) {\n\t  ifmtbl[i] = (IFAST_MULT_TYPE)\n\t    DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[jpeg_zigzag_order[i]],\n\t\t\t\t  (INT32) aanscales[i]),\n\t\t    CONST_BITS-IFAST_SCALE_BITS);\n\t}\n      }\n      break;\n#endif\n#ifdef DCT_FLOAT_SUPPORTED\n    case JDCT_FLOAT:\n      {\n\t/* For float AA&N IDCT method, multipliers are equal to quantization\n\t * coefficients scaled by scalefactor[row]*scalefactor[col], where\n\t *   scalefactor[0] = 1\n\t *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7\n\t * The multipliers are stored in natural order.\n\t */\n\tFLOAT_MULT_TYPE * fmtbl = (FLOAT_MULT_TYPE *) compptr->dct_table;\n\tint row, col;\n\tstatic const double aanscalefactor[DCTSIZE] = {\n\t  1.0, 1.387039845, 1.306562965, 1.175875602,\n\t  1.0, 0.785694958, 0.541196100, 0.275899379\n\t};\n\n\ti = 0;\n\tfor (row = 0; row < DCTSIZE; row++) {\n\t  for (col = 0; col < DCTSIZE; col++) {\n\t    fmtbl[i] = (FLOAT_MULT_TYPE)\n\t      ((double) qtbl->quantval[jpeg_zigzag_order[i]] *\n\t       aanscalefactor[row] * aanscalefactor[col]);\n\t    i++;\n\t  }\n\t}\n      }\n      break;\n#endif\n    default:\n      ERREXIT(cinfo, JERR_NOT_COMPILED);\n      break;\n    }\n  }\n}\n\n\n/*\n * Initialize IDCT manager.\n */\n\nGLOBAL void\njinit_inverse_dct (j_decompress_ptr cinfo)\n{\n  my_idct_ptr idct;\n  int ci;\n  jpeg_component_info *compptr;\n\n  idct = (my_idct_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_idct_controller));\n  cinfo->idct = (struct jpeg_inverse_dct *) idct;\n  idct->pub.start_pass = start_pass;\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    /* Allocate and pre-zero a multiplier table for each component */\n    compptr->dct_table =\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t  SIZEOF(multiplier_table));\n    MEMZERO(compptr->dct_table, SIZEOF(multiplier_table));\n    /* Mark multiplier table not yet set up for any method */\n    idct->cur_method[ci] = -1;\n  }\n}\n"
  },
  {
    "path": "code/jpeg-6/jdhuff.c",
    "content": "/*\n * jdhuff.c\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains Huffman entropy decoding routines.\n *\n * Much of the complexity here has to do with supporting input suspension.\n * If the data source module demands suspension, we want to be able to back\n * up to the start of the current MCU.  To do this, we copy state variables\n * into local working storage, and update them back to the permanent\n * storage only upon successful completion of an MCU.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jdhuff.h\"\t\t/* Declarations shared with jdphuff.c */\n\n\n/*\n * Expanded entropy decoder object for Huffman decoding.\n *\n * The savable_state subrecord contains fields that change within an MCU,\n * but must not be updated permanently until we complete the MCU.\n */\n\ntypedef struct {\n  int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */\n} savable_state;\n\n/* This macro is to work around compilers with missing or broken\n * structure assignment.  You'll need to fix this code if you have\n * such a compiler and you change MAX_COMPS_IN_SCAN.\n */\n\n#ifndef NO_STRUCT_ASSIGN\n#define ASSIGN_STATE(dest,src)  ((dest) = (src))\n#else\n#if MAX_COMPS_IN_SCAN == 4\n#define ASSIGN_STATE(dest,src)  \\\n\t((dest).last_dc_val[0] = (src).last_dc_val[0], \\\n\t (dest).last_dc_val[1] = (src).last_dc_val[1], \\\n\t (dest).last_dc_val[2] = (src).last_dc_val[2], \\\n\t (dest).last_dc_val[3] = (src).last_dc_val[3])\n#endif\n#endif\n\n\ntypedef struct {\n  struct jpeg_entropy_decoder pub; /* public fields */\n\n  /* These fields are loaded into local variables at start of each MCU.\n   * In case of suspension, we exit WITHOUT updating them.\n   */\n  bitread_perm_state bitstate;\t/* Bit buffer at start of MCU */\n  savable_state saved;\t\t/* Other state at start of MCU */\n\n  /* These fields are NOT loaded into local working state. */\n  unsigned int restarts_to_go;\t/* MCUs left in this restart interval */\n\n  /* Pointers to derived tables (these workspaces have image lifespan) */\n  d_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS];\n  d_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS];\n} huff_entropy_decoder;\n\ntypedef huff_entropy_decoder * huff_entropy_ptr;\n\n\n/*\n * Initialize for a Huffman-compressed scan.\n */\n\nMETHODDEF void\nstart_pass_huff_decoder (j_decompress_ptr cinfo)\n{\n  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;\n  int ci, dctbl, actbl;\n  jpeg_component_info * compptr;\n\n  /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG.\n   * This ought to be an error condition, but we make it a warning because\n   * there are some baseline files out there with all zeroes in these bytes.\n   */\n  if (cinfo->Ss != 0 || cinfo->Se != DCTSIZE2-1 ||\n      cinfo->Ah != 0 || cinfo->Al != 0)\n    WARNMS(cinfo, JWRN_NOT_SEQUENTIAL);\n\n  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n    compptr = cinfo->cur_comp_info[ci];\n    dctbl = compptr->dc_tbl_no;\n    actbl = compptr->ac_tbl_no;\n    /* Make sure requested tables are present */\n    if (dctbl < 0 || dctbl >= NUM_HUFF_TBLS ||\n\tcinfo->dc_huff_tbl_ptrs[dctbl] == NULL)\n      ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, dctbl);\n    if (actbl < 0 || actbl >= NUM_HUFF_TBLS ||\n\tcinfo->ac_huff_tbl_ptrs[actbl] == NULL)\n      ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, actbl);\n    /* Compute derived values for Huffman tables */\n    /* We may do this more than once for a table, but it's not expensive */\n    jpeg_make_d_derived_tbl(cinfo, cinfo->dc_huff_tbl_ptrs[dctbl],\n\t\t\t    & entropy->dc_derived_tbls[dctbl]);\n    jpeg_make_d_derived_tbl(cinfo, cinfo->ac_huff_tbl_ptrs[actbl],\n\t\t\t    & entropy->ac_derived_tbls[actbl]);\n    /* Initialize DC predictions to 0 */\n    entropy->saved.last_dc_val[ci] = 0;\n  }\n\n  /* Initialize bitread state variables */\n  entropy->bitstate.bits_left = 0;\n  entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */\n  entropy->bitstate.printed_eod = FALSE;\n\n  /* Initialize restart counter */\n  entropy->restarts_to_go = cinfo->restart_interval;\n}\n\n\n/*\n * Compute the derived values for a Huffman table.\n * Note this is also used by jdphuff.c.\n */\n\nGLOBAL void\njpeg_make_d_derived_tbl (j_decompress_ptr cinfo, JHUFF_TBL * htbl,\n\t\t\t d_derived_tbl ** pdtbl)\n{\n  d_derived_tbl *dtbl;\n  int p, i, l, si;\n  int lookbits, ctr;\n  char huffsize[257];\n  unsigned int huffcode[257];\n  unsigned int code;\n\n  /* Allocate a workspace if we haven't already done so. */\n  if (*pdtbl == NULL)\n    *pdtbl = (d_derived_tbl *)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t  SIZEOF(d_derived_tbl));\n  dtbl = *pdtbl;\n  dtbl->pub = htbl;\t\t/* fill in back link */\n  \n  /* Figure C.1: make table of Huffman code length for each symbol */\n  /* Note that this is in code-length order. */\n\n  p = 0;\n  for (l = 1; l <= 16; l++) {\n    for (i = 1; i <= (int) htbl->bits[l]; i++)\n      huffsize[p++] = (char) l;\n  }\n  huffsize[p] = 0;\n  \n  /* Figure C.2: generate the codes themselves */\n  /* Note that this is in code-length order. */\n  \n  code = 0;\n  si = huffsize[0];\n  p = 0;\n  while (huffsize[p]) {\n    while (((int) huffsize[p]) == si) {\n      huffcode[p++] = code;\n      code++;\n    }\n    code <<= 1;\n    si++;\n  }\n\n  /* Figure F.15: generate decoding tables for bit-sequential decoding */\n\n  p = 0;\n  for (l = 1; l <= 16; l++) {\n    if (htbl->bits[l]) {\n      dtbl->valptr[l] = p; /* huffval[] index of 1st symbol of code length l */\n      dtbl->mincode[l] = huffcode[p]; /* minimum code of length l */\n      p += htbl->bits[l];\n      dtbl->maxcode[l] = huffcode[p-1]; /* maximum code of length l */\n    } else {\n      dtbl->maxcode[l] = -1;\t/* -1 if no codes of this length */\n    }\n  }\n  dtbl->maxcode[17] = 0xFFFFFL; /* ensures jpeg_huff_decode terminates */\n\n  /* Compute lookahead tables to speed up decoding.\n   * First we set all the table entries to 0, indicating \"too long\";\n   * then we iterate through the Huffman codes that are short enough and\n   * fill in all the entries that correspond to bit sequences starting\n   * with that code.\n   */\n\n  MEMZERO(dtbl->look_nbits, SIZEOF(dtbl->look_nbits));\n\n  p = 0;\n  for (l = 1; l <= HUFF_LOOKAHEAD; l++) {\n    for (i = 1; i <= (int) htbl->bits[l]; i++, p++) {\n      /* l = current code's length, p = its index in huffcode[] & huffval[]. */\n      /* Generate left-justified code followed by all possible bit sequences */\n      lookbits = huffcode[p] << (HUFF_LOOKAHEAD-l);\n      for (ctr = 1 << (HUFF_LOOKAHEAD-l); ctr > 0; ctr--) {\n\tdtbl->look_nbits[lookbits] = l;\n\tdtbl->look_sym[lookbits] = htbl->huffval[p];\n\tlookbits++;\n      }\n    }\n  }\n}\n\n\n/*\n * Out-of-line code for bit fetching (shared with jdphuff.c).\n * See jdhuff.h for info about usage.\n * Note: current values of get_buffer and bits_left are passed as parameters,\n * but are returned in the corresponding fields of the state struct.\n *\n * On most machines MIN_GET_BITS should be 25 to allow the full 32-bit width\n * of get_buffer to be used.  (On machines with wider words, an even larger\n * buffer could be used.)  However, on some machines 32-bit shifts are\n * quite slow and take time proportional to the number of places shifted.\n * (This is true with most PC compilers, for instance.)  In this case it may\n * be a win to set MIN_GET_BITS to the minimum value of 15.  This reduces the\n * average shift distance at the cost of more calls to jpeg_fill_bit_buffer.\n */\n\n#ifdef SLOW_SHIFT_32\n#define MIN_GET_BITS  15\t/* minimum allowable value */\n#else\n#define MIN_GET_BITS  (BIT_BUF_SIZE-7)\n#endif\n\n\nGLOBAL boolean\njpeg_fill_bit_buffer (bitread_working_state * state,\n\t\t      register bit_buf_type get_buffer, register int bits_left,\n\t\t      int nbits)\n/* Load up the bit buffer to a depth of at least nbits */\n{\n  /* Copy heavily used state fields into locals (hopefully registers) */\n  register const JOCTET * next_input_byte = state->next_input_byte;\n  register size_t bytes_in_buffer = state->bytes_in_buffer;\n  register int c;\n\n  /* Attempt to load at least MIN_GET_BITS bits into get_buffer. */\n  /* (It is assumed that no request will be for more than that many bits.) */\n\n  while (bits_left < MIN_GET_BITS) {\n    /* Attempt to read a byte */\n    if (state->unread_marker != 0)\n      goto no_more_data;\t/* can't advance past a marker */\n\n    if (bytes_in_buffer == 0) {\n      if (! (*state->cinfo->src->fill_input_buffer) (state->cinfo))\n\treturn FALSE;\n      next_input_byte = state->cinfo->src->next_input_byte;\n      bytes_in_buffer = state->cinfo->src->bytes_in_buffer;\n    }\n    bytes_in_buffer--;\n    c = GETJOCTET(*next_input_byte++);\n\n    /* If it's 0xFF, check and discard stuffed zero byte */\n    if (c == 0xFF) {\n      do {\n\tif (bytes_in_buffer == 0) {\n\t  if (! (*state->cinfo->src->fill_input_buffer) (state->cinfo))\n\t    return FALSE;\n\t  next_input_byte = state->cinfo->src->next_input_byte;\n\t  bytes_in_buffer = state->cinfo->src->bytes_in_buffer;\n\t}\n\tbytes_in_buffer--;\n\tc = GETJOCTET(*next_input_byte++);\n      } while (c == 0xFF);\n\n      if (c == 0) {\n\t/* Found FF/00, which represents an FF data byte */\n\tc = 0xFF;\n      } else {\n\t/* Oops, it's actually a marker indicating end of compressed data. */\n\t/* Better put it back for use later */\n\tstate->unread_marker = c;\n\n      no_more_data:\n\t/* There should be enough bits still left in the data segment; */\n\t/* if so, just break out of the outer while loop. */\n\tif (bits_left >= nbits)\n\t  break;\n\t/* Uh-oh.  Report corrupted data to user and stuff zeroes into\n\t * the data stream, so that we can produce some kind of image.\n\t * Note that this code will be repeated for each byte demanded\n\t * for the rest of the segment.  We use a nonvolatile flag to ensure\n\t * that only one warning message appears.\n\t */\n\tif (! *(state->printed_eod_ptr)) {\n\t  WARNMS(state->cinfo, JWRN_HIT_MARKER);\n\t  *(state->printed_eod_ptr) = TRUE;\n\t}\n\tc = 0;\t\t\t/* insert a zero byte into bit buffer */\n      }\n    }\n\n    /* OK, load c into get_buffer */\n    get_buffer = (get_buffer << 8) | c;\n    bits_left += 8;\n  }\n\n  /* Unload the local registers */\n  state->next_input_byte = next_input_byte;\n  state->bytes_in_buffer = bytes_in_buffer;\n  state->get_buffer = get_buffer;\n  state->bits_left = bits_left;\n\n  return TRUE;\n}\n\n\n/*\n * Out-of-line code for Huffman code decoding.\n * See jdhuff.h for info about usage.\n */\n\nGLOBAL int\njpeg_huff_decode (bitread_working_state * state,\n\t\t  register bit_buf_type get_buffer, register int bits_left,\n\t\t  d_derived_tbl * htbl, int min_bits)\n{\n  register int l = min_bits;\n  register INT32 code;\n\n  /* HUFF_DECODE has determined that the code is at least min_bits */\n  /* bits long, so fetch that many bits in one swoop. */\n\n  CHECK_BIT_BUFFER(*state, l, return -1);\n  code = GET_BITS(l);\n\n  /* Collect the rest of the Huffman code one bit at a time. */\n  /* This is per Figure F.16 in the JPEG spec. */\n\n  while (code > htbl->maxcode[l]) {\n    code <<= 1;\n    CHECK_BIT_BUFFER(*state, 1, return -1);\n    code |= GET_BITS(1);\n    l++;\n  }\n\n  /* Unload the local registers */\n  state->get_buffer = get_buffer;\n  state->bits_left = bits_left;\n\n  /* With garbage input we may reach the sentinel value l = 17. */\n\n  if (l > 16) {\n    WARNMS(state->cinfo, JWRN_HUFF_BAD_CODE);\n    return 0;\t\t\t/* fake a zero as the safest result */\n  }\n\n  return htbl->pub->huffval[ htbl->valptr[l] +\n\t\t\t    ((int) (code - htbl->mincode[l])) ];\n}\n\n\n/*\n * Figure F.12: extend sign bit.\n * On some machines, a shift and add will be faster than a table lookup.\n */\n\n#ifdef AVOID_TABLES\n\n#define HUFF_EXTEND(x,s)  ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x))\n\n#else\n\n#define HUFF_EXTEND(x,s)  ((x) < extend_test[s] ? (x) + extend_offset[s] : (x))\n\nstatic const int extend_test[16] =   /* entry n is 2**(n-1) */\n  { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,\n    0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 };\n\nstatic const int extend_offset[16] = /* entry n is (-1 << n) + 1 */\n  { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1,\n    ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1,\n    ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1,\n    ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 };\n\n#endif /* AVOID_TABLES */\n\n\n/*\n * Check for a restart marker & resynchronize decoder.\n * Returns FALSE if must suspend.\n */\n\nLOCAL boolean\nprocess_restart (j_decompress_ptr cinfo)\n{\n  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;\n  int ci;\n\n  /* Throw away any unused bits remaining in bit buffer; */\n  /* include any full bytes in next_marker's count of discarded bytes */\n  cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8;\n  entropy->bitstate.bits_left = 0;\n\n  /* Advance past the RSTn marker */\n  if (! (*cinfo->marker->read_restart_marker) (cinfo))\n    return FALSE;\n\n  /* Re-initialize DC predictions to 0 */\n  for (ci = 0; ci < cinfo->comps_in_scan; ci++)\n    entropy->saved.last_dc_val[ci] = 0;\n\n  /* Reset restart counter */\n  entropy->restarts_to_go = cinfo->restart_interval;\n\n  /* Next segment can get another out-of-data warning */\n  entropy->bitstate.printed_eod = FALSE;\n\n  return TRUE;\n}\n\n\n/*\n * Decode and return one MCU's worth of Huffman-compressed coefficients.\n * The coefficients are reordered from zigzag order into natural array order,\n * but are not dequantized.\n *\n * The i'th block of the MCU is stored into the block pointed to by\n * MCU_data[i].  WE ASSUME THIS AREA HAS BEEN ZEROED BY THE CALLER.\n * (Wholesale zeroing is usually a little faster than retail...)\n *\n * Returns FALSE if data source requested suspension.  In that case no\n * changes have been made to permanent state.  (Exception: some output\n * coefficients may already have been assigned.  This is harmless for\n * this module, since we'll just re-assign them on the next call.)\n */\n\nMETHODDEF boolean\ndecode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)\n{\n  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;\n  register int s, k, r;\n  int blkn, ci;\n  JBLOCKROW block;\n  BITREAD_STATE_VARS;\n  savable_state state;\n  d_derived_tbl * dctbl;\n  d_derived_tbl * actbl;\n  jpeg_component_info * compptr;\n\n  /* Process restart marker if needed; may have to suspend */\n  if (cinfo->restart_interval) {\n    if (entropy->restarts_to_go == 0)\n      if (! process_restart(cinfo))\n\treturn FALSE;\n  }\n\n  /* Load up working state */\n  BITREAD_LOAD_STATE(cinfo,entropy->bitstate);\n  ASSIGN_STATE(state, entropy->saved);\n\n  /* Outer loop handles each block in the MCU */\n\n  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {\n    block = MCU_data[blkn];\n    ci = cinfo->MCU_membership[blkn];\n    compptr = cinfo->cur_comp_info[ci];\n    dctbl = entropy->dc_derived_tbls[compptr->dc_tbl_no];\n    actbl = entropy->ac_derived_tbls[compptr->ac_tbl_no];\n\n    /* Decode a single block's worth of coefficients */\n\n    /* Section F.2.2.1: decode the DC coefficient difference */\n    HUFF_DECODE(s, br_state, dctbl, return FALSE, label1);\n    if (s) {\n      CHECK_BIT_BUFFER(br_state, s, return FALSE);\n      r = GET_BITS(s);\n      s = HUFF_EXTEND(r, s);\n    }\n\n    /* Shortcut if component's values are not interesting */\n    if (! compptr->component_needed)\n      goto skip_ACs;\n\n    /* Convert DC difference to actual value, update last_dc_val */\n    s += state.last_dc_val[ci];\n    state.last_dc_val[ci] = s;\n    /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */\n    (*block)[0] = (JCOEF) s;\n\n    /* Do we need to decode the AC coefficients for this component? */\n    if (compptr->DCT_scaled_size > 1) {\n\n      /* Section F.2.2.2: decode the AC coefficients */\n      /* Since zeroes are skipped, output area must be cleared beforehand */\n      for (k = 1; k < DCTSIZE2; k++) {\n\tHUFF_DECODE(s, br_state, actbl, return FALSE, label2);\n      \n\tr = s >> 4;\n\ts &= 15;\n      \n\tif (s) {\n\t  k += r;\n\t  CHECK_BIT_BUFFER(br_state, s, return FALSE);\n\t  r = GET_BITS(s);\n\t  s = HUFF_EXTEND(r, s);\n\t  /* Output coefficient in natural (dezigzagged) order.\n\t   * Note: the extra entries in jpeg_natural_order[] will save us\n\t   * if k >= DCTSIZE2, which could happen if the data is corrupted.\n\t   */\n\t  (*block)[jpeg_natural_order[k]] = (JCOEF) s;\n\t} else {\n\t  if (r != 15)\n\t    break;\n\t  k += 15;\n\t}\n      }\n\n    } else {\nskip_ACs:\n\n      /* Section F.2.2.2: decode the AC coefficients */\n      /* In this path we just discard the values */\n      for (k = 1; k < DCTSIZE2; k++) {\n\tHUFF_DECODE(s, br_state, actbl, return FALSE, label3);\n      \n\tr = s >> 4;\n\ts &= 15;\n      \n\tif (s) {\n\t  k += r;\n\t  CHECK_BIT_BUFFER(br_state, s, return FALSE);\n\t  DROP_BITS(s);\n\t} else {\n\t  if (r != 15)\n\t    break;\n\t  k += 15;\n\t}\n      }\n\n    }\n  }\n\n  /* Completed MCU, so update state */\n  BITREAD_SAVE_STATE(cinfo,entropy->bitstate);\n  ASSIGN_STATE(entropy->saved, state);\n\n  /* Account for restart interval (no-op if not using restarts) */\n  entropy->restarts_to_go--;\n\n  return TRUE;\n}\n\n\n/*\n * Module initialization routine for Huffman entropy decoding.\n */\n\nGLOBAL void\njinit_huff_decoder (j_decompress_ptr cinfo)\n{\n  huff_entropy_ptr entropy;\n  int i;\n\n  entropy = (huff_entropy_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(huff_entropy_decoder));\n  cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;\n  entropy->pub.start_pass = start_pass_huff_decoder;\n  entropy->pub.decode_mcu = decode_mcu;\n\n  /* Mark tables unallocated */\n  for (i = 0; i < NUM_HUFF_TBLS; i++) {\n    entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL;\n  }\n}\n"
  },
  {
    "path": "code/jpeg-6/jdhuff.h",
    "content": "/*\n * jdhuff.h\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains declarations for Huffman entropy decoding routines\n * that are shared between the sequential decoder (jdhuff.c) and the\n * progressive decoder (jdphuff.c).  No other modules need to see these.\n */\n\n/* Short forms of external names for systems with brain-damaged linkers. */\n\n#ifdef NEED_SHORT_EXTERNAL_NAMES\n#define jpeg_make_d_derived_tbl\tjMkDDerived\n#define jpeg_fill_bit_buffer\tjFilBitBuf\n#define jpeg_huff_decode\tjHufDecode\n#endif /* NEED_SHORT_EXTERNAL_NAMES */\n\n\n/* Derived data constructed for each Huffman table */\n\n#define HUFF_LOOKAHEAD\t8\t/* # of bits of lookahead */\n\ntypedef struct {\n  /* Basic tables: (element [0] of each array is unused) */\n  INT32 mincode[17];\t\t/* smallest code of length k */\n  INT32 maxcode[18];\t\t/* largest code of length k (-1 if none) */\n  /* (maxcode[17] is a sentinel to ensure jpeg_huff_decode terminates) */\n  int valptr[17];\t\t/* huffval[] index of 1st symbol of length k */\n\n  /* Link to public Huffman table (needed only in jpeg_huff_decode) */\n  JHUFF_TBL *pub;\n\n  /* Lookahead tables: indexed by the next HUFF_LOOKAHEAD bits of\n   * the input data stream.  If the next Huffman code is no more\n   * than HUFF_LOOKAHEAD bits long, we can obtain its length and\n   * the corresponding symbol directly from these tables.\n   */\n  int look_nbits[1<<HUFF_LOOKAHEAD]; /* # bits, or 0 if too long */\n  UINT8 look_sym[1<<HUFF_LOOKAHEAD]; /* symbol, or unused */\n} d_derived_tbl;\n\n/* Expand a Huffman table definition into the derived format */\nEXTERN void jpeg_make_d_derived_tbl JPP((j_decompress_ptr cinfo,\n\t\t\t\tJHUFF_TBL * htbl, d_derived_tbl ** pdtbl));\n\n\n/*\n * Fetching the next N bits from the input stream is a time-critical operation\n * for the Huffman decoders.  We implement it with a combination of inline\n * macros and out-of-line subroutines.  Note that N (the number of bits\n * demanded at one time) never exceeds 15 for JPEG use.\n *\n * We read source bytes into get_buffer and dole out bits as needed.\n * If get_buffer already contains enough bits, they are fetched in-line\n * by the macros CHECK_BIT_BUFFER and GET_BITS.  When there aren't enough\n * bits, jpeg_fill_bit_buffer is called; it will attempt to fill get_buffer\n * as full as possible (not just to the number of bits needed; this\n * prefetching reduces the overhead cost of calling jpeg_fill_bit_buffer).\n * Note that jpeg_fill_bit_buffer may return FALSE to indicate suspension.\n * On TRUE return, jpeg_fill_bit_buffer guarantees that get_buffer contains\n * at least the requested number of bits --- dummy zeroes are inserted if\n * necessary.\n */\n\ntypedef INT32 bit_buf_type;\t/* type of bit-extraction buffer */\n#define BIT_BUF_SIZE  32\t/* size of buffer in bits */\n\n/* If long is > 32 bits on your machine, and shifting/masking longs is\n * reasonably fast, making bit_buf_type be long and setting BIT_BUF_SIZE\n * appropriately should be a win.  Unfortunately we can't do this with\n * something like  #define BIT_BUF_SIZE (sizeof(bit_buf_type)*8)\n * because not all machines measure sizeof in 8-bit bytes.\n */\n\ntypedef struct {\t\t/* Bitreading state saved across MCUs */\n  bit_buf_type get_buffer;\t/* current bit-extraction buffer */\n  int bits_left;\t\t/* # of unused bits in it */\n  boolean printed_eod;\t\t/* flag to suppress multiple warning msgs */\n} bitread_perm_state;\n\ntypedef struct {\t\t/* Bitreading working state within an MCU */\n  /* current data source state */\n  const JOCTET * next_input_byte; /* => next byte to read from source */\n  size_t bytes_in_buffer;\t/* # of bytes remaining in source buffer */\n  int unread_marker;\t\t/* nonzero if we have hit a marker */\n  /* bit input buffer --- note these values are kept in register variables,\n   * not in this struct, inside the inner loops.\n   */\n  bit_buf_type get_buffer;\t/* current bit-extraction buffer */\n  int bits_left;\t\t/* # of unused bits in it */\n  /* pointers needed by jpeg_fill_bit_buffer */\n  j_decompress_ptr cinfo;\t/* back link to decompress master record */\n  boolean * printed_eod_ptr;\t/* => flag in permanent state */\n} bitread_working_state;\n\n/* Macros to declare and load/save bitread local variables. */\n#define BITREAD_STATE_VARS  \\\n\tregister bit_buf_type get_buffer;  \\\n\tregister int bits_left;  \\\n\tbitread_working_state br_state\n\n#define BITREAD_LOAD_STATE(cinfop,permstate)  \\\n\tbr_state.cinfo = cinfop; \\\n\tbr_state.next_input_byte = cinfop->src->next_input_byte; \\\n\tbr_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \\\n\tbr_state.unread_marker = cinfop->unread_marker; \\\n\tget_buffer = permstate.get_buffer; \\\n\tbits_left = permstate.bits_left; \\\n\tbr_state.printed_eod_ptr = & permstate.printed_eod\n\n#define BITREAD_SAVE_STATE(cinfop,permstate)  \\\n\tcinfop->src->next_input_byte = br_state.next_input_byte; \\\n\tcinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \\\n\tcinfop->unread_marker = br_state.unread_marker; \\\n\tpermstate.get_buffer = get_buffer; \\\n\tpermstate.bits_left = bits_left\n\n/*\n * These macros provide the in-line portion of bit fetching.\n * Use CHECK_BIT_BUFFER to ensure there are N bits in get_buffer\n * before using GET_BITS, PEEK_BITS, or DROP_BITS.\n * The variables get_buffer and bits_left are assumed to be locals,\n * but the state struct might not be (jpeg_huff_decode needs this).\n *\tCHECK_BIT_BUFFER(state,n,action);\n *\t\tEnsure there are N bits in get_buffer; if suspend, take action.\n *      val = GET_BITS(n);\n *\t\tFetch next N bits.\n *      val = PEEK_BITS(n);\n *\t\tFetch next N bits without removing them from the buffer.\n *\tDROP_BITS(n);\n *\t\tDiscard next N bits.\n * The value N should be a simple variable, not an expression, because it\n * is evaluated multiple times.\n */\n\n#define CHECK_BIT_BUFFER(state,nbits,action) \\\n\t{ if (bits_left < (nbits)) {  \\\n\t    if (! jpeg_fill_bit_buffer(&(state),get_buffer,bits_left,nbits))  \\\n\t      { action; }  \\\n\t    get_buffer = (state).get_buffer; bits_left = (state).bits_left; } }\n\n#define GET_BITS(nbits) \\\n\t(((int) (get_buffer >> (bits_left -= (nbits)))) & ((1<<(nbits))-1))\n\n#define PEEK_BITS(nbits) \\\n\t(((int) (get_buffer >> (bits_left -  (nbits)))) & ((1<<(nbits))-1))\n\n#define DROP_BITS(nbits) \\\n\t(bits_left -= (nbits))\n\n/* Load up the bit buffer to a depth of at least nbits */\nEXTERN boolean jpeg_fill_bit_buffer JPP((bitread_working_state * state,\n\t\tregister bit_buf_type get_buffer, register int bits_left,\n\t\tint nbits));\n\n\n/*\n * Code for extracting next Huffman-coded symbol from input bit stream.\n * Again, this is time-critical and we make the main paths be macros.\n *\n * We use a lookahead table to process codes of up to HUFF_LOOKAHEAD bits\n * without looping.  Usually, more than 95% of the Huffman codes will be 8\n * or fewer bits long.  The few overlength codes are handled with a loop,\n * which need not be inline code.\n *\n * Notes about the HUFF_DECODE macro:\n * 1. Near the end of the data segment, we may fail to get enough bits\n *    for a lookahead.  In that case, we do it the hard way.\n * 2. If the lookahead table contains no entry, the next code must be\n *    more than HUFF_LOOKAHEAD bits long.\n * 3. jpeg_huff_decode returns -1 if forced to suspend.\n */\n\n#define HUFF_DECODE(result,state,htbl,failaction,slowlabel) \\\n{ register int nb, look; \\\n  if (bits_left < HUFF_LOOKAHEAD) { \\\n    if (! jpeg_fill_bit_buffer(&state,get_buffer,bits_left, 0)) {failaction;} \\\n    get_buffer = state.get_buffer; bits_left = state.bits_left; \\\n    if (bits_left < HUFF_LOOKAHEAD) { \\\n      nb = 1; goto slowlabel; \\\n    } \\\n  } \\\n  look = PEEK_BITS(HUFF_LOOKAHEAD); \\\n  if ((nb = htbl->look_nbits[look]) != 0) { \\\n    DROP_BITS(nb); \\\n    result = htbl->look_sym[look]; \\\n  } else { \\\n    nb = HUFF_LOOKAHEAD+1; \\\nslowlabel: \\\n    if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \\\n\t{ failaction; } \\\n    get_buffer = state.get_buffer; bits_left = state.bits_left; \\\n  } \\\n}\n\n/* Out-of-line case for Huffman code fetching */\nEXTERN int jpeg_huff_decode JPP((bitread_working_state * state,\n\t\tregister bit_buf_type get_buffer, register int bits_left,\n\t\td_derived_tbl * htbl, int min_bits));\n"
  },
  {
    "path": "code/jpeg-6/jdinput.c",
    "content": "/*\n * jdinput.c\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains input control logic for the JPEG decompressor.\n * These routines are concerned with controlling the decompressor's input\n * processing (marker reading and coefficient decoding).  The actual input\n * reading is done in jdmarker.c, jdhuff.c, and jdphuff.c.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/* Private state */\n\ntypedef struct {\n  struct jpeg_input_controller pub; /* public fields */\n\n  boolean inheaders;\t\t/* TRUE until first SOS is reached */\n} my_input_controller;\n\ntypedef my_input_controller * my_inputctl_ptr;\n\n\n/* Forward declarations */\nMETHODDEF int consume_markers JPP((j_decompress_ptr cinfo));\n\n\n/*\n * Routines to calculate various quantities related to the size of the image.\n */\n\nLOCAL void\ninitial_setup (j_decompress_ptr cinfo)\n/* Called once, when first SOS marker is reached */\n{\n  int ci;\n  jpeg_component_info *compptr;\n\n  /* Make sure image isn't bigger than I can handle */\n  if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION ||\n      (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION)\n    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);\n\n  /* For now, precision must match compiled-in value... */\n  if (cinfo->data_precision != BITS_IN_JSAMPLE)\n    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);\n\n  /* Check that number of components won't exceed internal array sizes */\n  if (cinfo->num_components > MAX_COMPONENTS)\n    ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,\n\t     MAX_COMPONENTS);\n\n  /* Compute maximum sampling factors; check factor validity */\n  cinfo->max_h_samp_factor = 1;\n  cinfo->max_v_samp_factor = 1;\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR ||\n\tcompptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR)\n      ERREXIT(cinfo, JERR_BAD_SAMPLING);\n    cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,\n\t\t\t\t   compptr->h_samp_factor);\n    cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor,\n\t\t\t\t   compptr->v_samp_factor);\n  }\n\n  /* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE.\n   * In the full decompressor, this will be overridden by jdmaster.c;\n   * but in the transcoder, jdmaster.c is not used, so we must do it here.\n   */\n  cinfo->min_DCT_scaled_size = DCTSIZE;\n\n  /* Compute dimensions of components */\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    compptr->DCT_scaled_size = DCTSIZE;\n    /* Size in DCT blocks */\n    compptr->width_in_blocks = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,\n\t\t    (long) (cinfo->max_h_samp_factor * DCTSIZE));\n    compptr->height_in_blocks = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,\n\t\t    (long) (cinfo->max_v_samp_factor * DCTSIZE));\n    /* downsampled_width and downsampled_height will also be overridden by\n     * jdmaster.c if we are doing full decompression.  The transcoder library\n     * doesn't use these values, but the calling application might.\n     */\n    /* Size in samples */\n    compptr->downsampled_width = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,\n\t\t    (long) cinfo->max_h_samp_factor);\n    compptr->downsampled_height = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,\n\t\t    (long) cinfo->max_v_samp_factor);\n    /* Mark component needed, until color conversion says otherwise */\n    compptr->component_needed = TRUE;\n    /* Mark no quantization table yet saved for component */\n    compptr->quant_table = NULL;\n  }\n\n  /* Compute number of fully interleaved MCU rows. */\n  cinfo->total_iMCU_rows = (JDIMENSION)\n    jdiv_round_up((long) cinfo->image_height,\n\t\t  (long) (cinfo->max_v_samp_factor*DCTSIZE));\n\n  /* Decide whether file contains multiple scans */\n  if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode)\n    cinfo->inputctl->has_multiple_scans = TRUE;\n  else\n    cinfo->inputctl->has_multiple_scans = FALSE;\n}\n\n\nLOCAL void\nper_scan_setup (j_decompress_ptr cinfo)\n/* Do computations that are needed before processing a JPEG scan */\n/* cinfo->comps_in_scan and cinfo->cur_comp_info[] were set from SOS marker */\n{\n  int ci, mcublks, tmp;\n  jpeg_component_info *compptr;\n  \n  if (cinfo->comps_in_scan == 1) {\n    \n    /* Noninterleaved (single-component) scan */\n    compptr = cinfo->cur_comp_info[0];\n    \n    /* Overall image size in MCUs */\n    cinfo->MCUs_per_row = compptr->width_in_blocks;\n    cinfo->MCU_rows_in_scan = compptr->height_in_blocks;\n    \n    /* For noninterleaved scan, always one block per MCU */\n    compptr->MCU_width = 1;\n    compptr->MCU_height = 1;\n    compptr->MCU_blocks = 1;\n    compptr->MCU_sample_width = compptr->DCT_scaled_size;\n    compptr->last_col_width = 1;\n    /* For noninterleaved scans, it is convenient to define last_row_height\n     * as the number of block rows present in the last iMCU row.\n     */\n    tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor);\n    if (tmp == 0) tmp = compptr->v_samp_factor;\n    compptr->last_row_height = tmp;\n    \n    /* Prepare array describing MCU composition */\n    cinfo->blocks_in_MCU = 1;\n    cinfo->MCU_membership[0] = 0;\n    \n  } else {\n    \n    /* Interleaved (multi-component) scan */\n    if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)\n      ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,\n\t       MAX_COMPS_IN_SCAN);\n    \n    /* Overall image size in MCUs */\n    cinfo->MCUs_per_row = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_width,\n\t\t    (long) (cinfo->max_h_samp_factor*DCTSIZE));\n    cinfo->MCU_rows_in_scan = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_height,\n\t\t    (long) (cinfo->max_v_samp_factor*DCTSIZE));\n    \n    cinfo->blocks_in_MCU = 0;\n    \n    for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n      compptr = cinfo->cur_comp_info[ci];\n      /* Sampling factors give # of blocks of component in each MCU */\n      compptr->MCU_width = compptr->h_samp_factor;\n      compptr->MCU_height = compptr->v_samp_factor;\n      compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;\n      compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_scaled_size;\n      /* Figure number of non-dummy blocks in last MCU column & row */\n      tmp = (int) (compptr->width_in_blocks % compptr->MCU_width);\n      if (tmp == 0) tmp = compptr->MCU_width;\n      compptr->last_col_width = tmp;\n      tmp = (int) (compptr->height_in_blocks % compptr->MCU_height);\n      if (tmp == 0) tmp = compptr->MCU_height;\n      compptr->last_row_height = tmp;\n      /* Prepare array describing MCU composition */\n      mcublks = compptr->MCU_blocks;\n      if (cinfo->blocks_in_MCU + mcublks > D_MAX_BLOCKS_IN_MCU)\n\tERREXIT(cinfo, JERR_BAD_MCU_SIZE);\n      while (mcublks-- > 0) {\n\tcinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;\n      }\n    }\n    \n  }\n}\n\n\n/*\n * Save away a copy of the Q-table referenced by each component present\n * in the current scan, unless already saved during a prior scan.\n *\n * In a multiple-scan JPEG file, the encoder could assign different components\n * the same Q-table slot number, but change table definitions between scans\n * so that each component uses a different Q-table.  (The IJG encoder is not\n * currently capable of doing this, but other encoders might.)  Since we want\n * to be able to dequantize all the components at the end of the file, this\n * means that we have to save away the table actually used for each component.\n * We do this by copying the table at the start of the first scan containing\n * the component.\n * The JPEG spec prohibits the encoder from changing the contents of a Q-table\n * slot between scans of a component using that slot.  If the encoder does so\n * anyway, this decoder will simply use the Q-table values that were current\n * at the start of the first scan for the component.\n *\n * The decompressor output side looks only at the saved quant tables,\n * not at the current Q-table slots.\n */\n\nLOCAL void\nlatch_quant_tables (j_decompress_ptr cinfo)\n{\n  int ci, qtblno;\n  jpeg_component_info *compptr;\n  JQUANT_TBL * qtbl;\n\n  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n    compptr = cinfo->cur_comp_info[ci];\n    /* No work if we already saved Q-table for this component */\n    if (compptr->quant_table != NULL)\n      continue;\n    /* Make sure specified quantization table is present */\n    qtblno = compptr->quant_tbl_no;\n    if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS ||\n\tcinfo->quant_tbl_ptrs[qtblno] == NULL)\n      ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);\n    /* OK, save away the quantization table */\n    qtbl = (JQUANT_TBL *)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t  SIZEOF(JQUANT_TBL));\n    MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], SIZEOF(JQUANT_TBL));\n    compptr->quant_table = qtbl;\n  }\n}\n\n\n/*\n * Initialize the input modules to read a scan of compressed data.\n * The first call to this is done by jdmaster.c after initializing\n * the entire decompressor (during jpeg_start_decompress).\n * Subsequent calls come from consume_markers, below.\n */\n\nMETHODDEF void\nstart_input_pass (j_decompress_ptr cinfo)\n{\n  per_scan_setup(cinfo);\n  latch_quant_tables(cinfo);\n  (*cinfo->entropy->start_pass) (cinfo);\n  (*cinfo->coef->start_input_pass) (cinfo);\n  cinfo->inputctl->consume_input = cinfo->coef->consume_data;\n}\n\n\n/*\n * Finish up after inputting a compressed-data scan.\n * This is called by the coefficient controller after it's read all\n * the expected data of the scan.\n */\n\nMETHODDEF void\nfinish_input_pass (j_decompress_ptr cinfo)\n{\n  cinfo->inputctl->consume_input = consume_markers;\n}\n\n\n/*\n * Read JPEG markers before, between, or after compressed-data scans.\n * Change state as necessary when a new scan is reached.\n * Return value is JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.\n *\n * The consume_input method pointer points either here or to the\n * coefficient controller's consume_data routine, depending on whether\n * we are reading a compressed data segment or inter-segment markers.\n */\n\nMETHODDEF int\nconsume_markers (j_decompress_ptr cinfo)\n{\n  my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl;\n  int val;\n\n  if (inputctl->pub.eoi_reached) /* After hitting EOI, read no further */\n    return JPEG_REACHED_EOI;\n\n  val = (*cinfo->marker->read_markers) (cinfo);\n\n  switch (val) {\n  case JPEG_REACHED_SOS:\t/* Found SOS */\n    if (inputctl->inheaders) {\t/* 1st SOS */\n      initial_setup(cinfo);\n      inputctl->inheaders = FALSE;\n      /* Note: start_input_pass must be called by jdmaster.c\n       * before any more input can be consumed.  jdapi.c is\n       * responsible for enforcing this sequencing.\n       */\n    } else {\t\t\t/* 2nd or later SOS marker */\n      if (! inputctl->pub.has_multiple_scans)\n\tERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */\n      start_input_pass(cinfo);\n    }\n    break;\n  case JPEG_REACHED_EOI:\t/* Found EOI */\n    inputctl->pub.eoi_reached = TRUE;\n    if (inputctl->inheaders) {\t/* Tables-only datastream, apparently */\n      if (cinfo->marker->saw_SOF)\n\tERREXIT(cinfo, JERR_SOF_NO_SOS);\n    } else {\n      /* Prevent infinite loop in coef ctlr's decompress_data routine\n       * if user set output_scan_number larger than number of scans.\n       */\n      if (cinfo->output_scan_number > cinfo->input_scan_number)\n\tcinfo->output_scan_number = cinfo->input_scan_number;\n    }\n    break;\n  case JPEG_SUSPENDED:\n    break;\n  }\n\n  return val;\n}\n\n\n/*\n * Reset state to begin a fresh datastream.\n */\n\nMETHODDEF void\nreset_input_controller (j_decompress_ptr cinfo)\n{\n  my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl;\n\n  inputctl->pub.consume_input = consume_markers;\n  inputctl->pub.has_multiple_scans = FALSE; /* \"unknown\" would be better */\n  inputctl->pub.eoi_reached = FALSE;\n  inputctl->inheaders = TRUE;\n  /* Reset other modules */\n  (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);\n  (*cinfo->marker->reset_marker_reader) (cinfo);\n  /* Reset progression state -- would be cleaner if entropy decoder did this */\n  cinfo->coef_bits = NULL;\n}\n\n\n/*\n * Initialize the input controller module.\n * This is called only once, when the decompression object is created.\n */\n\nGLOBAL void\njinit_input_controller (j_decompress_ptr cinfo)\n{\n  my_inputctl_ptr inputctl;\n\n  /* Create subobject in permanent pool */\n  inputctl = (my_inputctl_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,\n\t\t\t\tSIZEOF(my_input_controller));\n  cinfo->inputctl = (struct jpeg_input_controller *) inputctl;\n  /* Initialize method pointers */\n  inputctl->pub.consume_input = consume_markers;\n  inputctl->pub.reset_input_controller = reset_input_controller;\n  inputctl->pub.start_input_pass = start_input_pass;\n  inputctl->pub.finish_input_pass = finish_input_pass;\n  /* Initialize state: can't use reset_input_controller since we don't\n   * want to try to reset other modules yet.\n   */\n  inputctl->pub.has_multiple_scans = FALSE; /* \"unknown\" would be better */\n  inputctl->pub.eoi_reached = FALSE;\n  inputctl->inheaders = TRUE;\n}\n"
  },
  {
    "path": "code/jpeg-6/jdmainct.c",
    "content": "/*\n * jdmainct.c\n *\n * Copyright (C) 1994-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains the main buffer controller for decompression.\n * The main buffer lies between the JPEG decompressor proper and the\n * post-processor; it holds downsampled data in the JPEG colorspace.\n *\n * Note that this code is bypassed in raw-data mode, since the application\n * supplies the equivalent of the main buffer in that case.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/*\n * In the current system design, the main buffer need never be a full-image\n * buffer; any full-height buffers will be found inside the coefficient or\n * postprocessing controllers.  Nonetheless, the main controller is not\n * trivial.  Its responsibility is to provide context rows for upsampling/\n * rescaling, and doing this in an efficient fashion is a bit tricky.\n *\n * Postprocessor input data is counted in \"row groups\".  A row group\n * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size)\n * sample rows of each component.  (We require DCT_scaled_size values to be\n * chosen such that these numbers are integers.  In practice DCT_scaled_size\n * values will likely be powers of two, so we actually have the stronger\n * condition that DCT_scaled_size / min_DCT_scaled_size is an integer.)\n * Upsampling will typically produce max_v_samp_factor pixel rows from each\n * row group (times any additional scale factor that the upsampler is\n * applying).\n *\n * The coefficient controller will deliver data to us one iMCU row at a time;\n * each iMCU row contains v_samp_factor * DCT_scaled_size sample rows, or\n * exactly min_DCT_scaled_size row groups.  (This amount of data corresponds\n * to one row of MCUs when the image is fully interleaved.)  Note that the\n * number of sample rows varies across components, but the number of row\n * groups does not.  Some garbage sample rows may be included in the last iMCU\n * row at the bottom of the image.\n *\n * Depending on the vertical scaling algorithm used, the upsampler may need\n * access to the sample row(s) above and below its current input row group.\n * The upsampler is required to set need_context_rows TRUE at global selection\n * time if so.  When need_context_rows is FALSE, this controller can simply\n * obtain one iMCU row at a time from the coefficient controller and dole it\n * out as row groups to the postprocessor.\n *\n * When need_context_rows is TRUE, this controller guarantees that the buffer\n * passed to postprocessing contains at least one row group's worth of samples\n * above and below the row group(s) being processed.  Note that the context\n * rows \"above\" the first passed row group appear at negative row offsets in\n * the passed buffer.  At the top and bottom of the image, the required\n * context rows are manufactured by duplicating the first or last real sample\n * row; this avoids having special cases in the upsampling inner loops.\n *\n * The amount of context is fixed at one row group just because that's a\n * convenient number for this controller to work with.  The existing\n * upsamplers really only need one sample row of context.  An upsampler\n * supporting arbitrary output rescaling might wish for more than one row\n * group of context when shrinking the image; tough, we don't handle that.\n * (This is justified by the assumption that downsizing will be handled mostly\n * by adjusting the DCT_scaled_size values, so that the actual scale factor at\n * the upsample step needn't be much less than one.)\n *\n * To provide the desired context, we have to retain the last two row groups\n * of one iMCU row while reading in the next iMCU row.  (The last row group\n * can't be processed until we have another row group for its below-context,\n * and so we have to save the next-to-last group too for its above-context.)\n * We could do this most simply by copying data around in our buffer, but\n * that'd be very slow.  We can avoid copying any data by creating a rather\n * strange pointer structure.  Here's how it works.  We allocate a workspace\n * consisting of M+2 row groups (where M = min_DCT_scaled_size is the number\n * of row groups per iMCU row).  We create two sets of redundant pointers to\n * the workspace.  Labeling the physical row groups 0 to M+1, the synthesized\n * pointer lists look like this:\n *                   M+1                          M-1\n * master pointer --> 0         master pointer --> 0\n *                    1                            1\n *                   ...                          ...\n *                   M-3                          M-3\n *                   M-2                           M\n *                   M-1                          M+1\n *                    M                           M-2\n *                   M+1                          M-1\n *                    0                            0\n * We read alternate iMCU rows using each master pointer; thus the last two\n * row groups of the previous iMCU row remain un-overwritten in the workspace.\n * The pointer lists are set up so that the required context rows appear to\n * be adjacent to the proper places when we pass the pointer lists to the\n * upsampler.\n *\n * The above pictures describe the normal state of the pointer lists.\n * At top and bottom of the image, we diddle the pointer lists to duplicate\n * the first or last sample row as necessary (this is cheaper than copying\n * sample rows around).\n *\n * This scheme breaks down if M < 2, ie, min_DCT_scaled_size is 1.  In that\n * situation each iMCU row provides only one row group so the buffering logic\n * must be different (eg, we must read two iMCU rows before we can emit the\n * first row group).  For now, we simply do not support providing context\n * rows when min_DCT_scaled_size is 1.  That combination seems unlikely to\n * be worth providing --- if someone wants a 1/8th-size preview, they probably\n * want it quick and dirty, so a context-free upsampler is sufficient.\n */\n\n\n/* Private buffer controller object */\n\ntypedef struct {\n  struct jpeg_d_main_controller pub; /* public fields */\n\n  /* Pointer to allocated workspace (M or M+2 row groups). */\n  JSAMPARRAY buffer[MAX_COMPONENTS];\n\n  boolean buffer_full;\t\t/* Have we gotten an iMCU row from decoder? */\n  JDIMENSION rowgroup_ctr;\t/* counts row groups output to postprocessor */\n\n  /* Remaining fields are only used in the context case. */\n\n  /* These are the master pointers to the funny-order pointer lists. */\n  JSAMPIMAGE xbuffer[2];\t/* pointers to weird pointer lists */\n\n  int whichptr;\t\t\t/* indicates which pointer set is now in use */\n  int context_state;\t\t/* process_data state machine status */\n  JDIMENSION rowgroups_avail;\t/* row groups available to postprocessor */\n  JDIMENSION iMCU_row_ctr;\t/* counts iMCU rows to detect image top/bot */\n} my_main_controller;\n\ntypedef my_main_controller * my_main_ptr;\n\n/* context_state values: */\n#define CTX_PREPARE_FOR_IMCU\t0\t/* need to prepare for MCU row */\n#define CTX_PROCESS_IMCU\t1\t/* feeding iMCU to postprocessor */\n#define CTX_POSTPONED_ROW\t2\t/* feeding postponed row group */\n\n\n/* Forward declarations */\nMETHODDEF void process_data_simple_main\n\tJPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf,\n\t     JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail));\nMETHODDEF void process_data_context_main\n\tJPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf,\n\t     JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail));\n#ifdef QUANT_2PASS_SUPPORTED\nMETHODDEF void process_data_crank_post\n\tJPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf,\n\t     JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail));\n#endif\n\n\nLOCAL void\nalloc_funny_pointers (j_decompress_ptr cinfo)\n/* Allocate space for the funny pointer lists.\n * This is done only once, not once per pass.\n */\n{\n  // bk001204 - no use main\n  my_main_ptr jmain = (my_main_ptr) cinfo->main;\n  int ci, rgroup;\n  int M = cinfo->min_DCT_scaled_size;\n  jpeg_component_info *compptr;\n  JSAMPARRAY xbuf;\n\n  /* Get top-level space for component array pointers.\n   * We alloc both arrays with one call to save a few cycles.\n   */\n  jmain->xbuffer[0] = (JSAMPIMAGE)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tcinfo->num_components * 2 * SIZEOF(JSAMPARRAY));\n  jmain->xbuffer[1] = jmain->xbuffer[0] + cinfo->num_components;\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /\n      cinfo->min_DCT_scaled_size; /* height of a row group of component */\n    /* Get space for pointer lists --- M+4 row groups in each list.\n     * We alloc both pointer lists with one call to save a few cycles.\n     */\n    xbuf = (JSAMPARRAY)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t  2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW));\n    xbuf += rgroup;\t\t/* want one row group at negative offsets */\n    jmain->xbuffer[0][ci] = xbuf;\n    xbuf += rgroup * (M + 4);\n    jmain->xbuffer[1][ci] = xbuf;\n  }\n}\n\n\nLOCAL void\nmake_funny_pointers (j_decompress_ptr cinfo)\n/* Create the funny pointer lists discussed in the comments above.\n * The actual workspace is already allocated (in main->buffer),\n * and the space for the pointer lists is allocated too.\n * This routine just fills in the curiously ordered lists.\n * This will be repeated at the beginning of each pass.\n */\n{\n // bk001204 - no use main\n  my_main_ptr jmain = (my_main_ptr) cinfo->main;\n  int ci, i, rgroup;\n  int M = cinfo->min_DCT_scaled_size;\n  jpeg_component_info *compptr;\n  JSAMPARRAY buf, xbuf0, xbuf1;\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /\n      cinfo->min_DCT_scaled_size; /* height of a row group of component */\n    xbuf0 = jmain->xbuffer[0][ci];\n    xbuf1 = jmain->xbuffer[1][ci];\n    /* First copy the workspace pointers as-is */\n    buf = jmain->buffer[ci];\n    for (i = 0; i < rgroup * (M + 2); i++) {\n      xbuf0[i] = xbuf1[i] = buf[i];\n    }\n    /* In the second list, put the last four row groups in swapped order */\n    for (i = 0; i < rgroup * 2; i++) {\n      xbuf1[rgroup*(M-2) + i] = buf[rgroup*M + i];\n      xbuf1[rgroup*M + i] = buf[rgroup*(M-2) + i];\n    }\n    /* The wraparound pointers at top and bottom will be filled later\n     * (see set_wraparound_pointers, below).  Initially we want the \"above\"\n     * pointers to duplicate the first actual data line.  This only needs\n     * to happen in xbuffer[0].\n     */\n    for (i = 0; i < rgroup; i++) {\n      xbuf0[i - rgroup] = xbuf0[0];\n    }\n  }\n}\n\n\nLOCAL void\nset_wraparound_pointers (j_decompress_ptr cinfo)\n/* Set up the \"wraparound\" pointers at top and bottom of the pointer lists.\n * This changes the pointer list state from top-of-image to the normal state.\n */\n{\n // bk001204 - no use main\n  my_main_ptr jmain = (my_main_ptr) cinfo->main;\n  int ci, i, rgroup;\n  int M = cinfo->min_DCT_scaled_size;\n  jpeg_component_info *compptr;\n  JSAMPARRAY xbuf0, xbuf1;\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /\n      cinfo->min_DCT_scaled_size; /* height of a row group of component */\n    xbuf0 = jmain->xbuffer[0][ci];\n    xbuf1 = jmain->xbuffer[1][ci];\n    for (i = 0; i < rgroup; i++) {\n      xbuf0[i - rgroup] = xbuf0[rgroup*(M+1) + i];\n      xbuf1[i - rgroup] = xbuf1[rgroup*(M+1) + i];\n      xbuf0[rgroup*(M+2) + i] = xbuf0[i];\n      xbuf1[rgroup*(M+2) + i] = xbuf1[i];\n    }\n  }\n}\n\n\nLOCAL void\nset_bottom_pointers (j_decompress_ptr cinfo)\n/* Change the pointer lists to duplicate the last sample row at the bottom\n * of the image.  whichptr indicates which xbuffer holds the final iMCU row.\n * Also sets rowgroups_avail to indicate number of nondummy row groups in row.\n */\n{\n // bk001204 - no use main\n  my_main_ptr jmain = (my_main_ptr) cinfo->main;\n  int ci, i, rgroup, iMCUheight, rows_left;\n  jpeg_component_info *compptr;\n  JSAMPARRAY xbuf;\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    /* Count sample rows in one iMCU row and in one row group */\n    iMCUheight = compptr->v_samp_factor * compptr->DCT_scaled_size;\n    rgroup = iMCUheight / cinfo->min_DCT_scaled_size;\n    /* Count nondummy sample rows remaining for this component */\n    rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight);\n    if (rows_left == 0) rows_left = iMCUheight;\n    /* Count nondummy row groups.  Should get same answer for each component,\n     * so we need only do it once.\n     */\n    if (ci == 0) {\n      jmain->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1);\n    }\n    /* Duplicate the last real sample row rgroup*2 times; this pads out the\n     * last partial rowgroup and ensures at least one full rowgroup of context.\n     */\n    xbuf = jmain->xbuffer[jmain->whichptr][ci];\n    for (i = 0; i < rgroup * 2; i++) {\n      xbuf[rows_left + i] = xbuf[rows_left-1];\n    }\n  }\n}\n\n\n/*\n * Initialize for a processing pass.\n */\n\nMETHODDEF void\nstart_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)\n{\n  // bk001204 - no use main\n  my_main_ptr jmain = (my_main_ptr) cinfo->main;\n\n  switch (pass_mode) {\n  case JBUF_PASS_THRU:\n    if (cinfo->upsample->need_context_rows) {\n      jmain->pub.process_data = process_data_context_main;\n      make_funny_pointers(cinfo); /* Create the xbuffer[] lists */\n      jmain->whichptr = 0;\t/* Read first iMCU row into xbuffer[0] */\n      jmain->context_state = CTX_PREPARE_FOR_IMCU;\n      jmain->iMCU_row_ctr = 0;\n    } else {\n      /* Simple case with no context needed */\n      jmain->pub.process_data = process_data_simple_main;\n    }\n    jmain->buffer_full = FALSE;\t/* Mark buffer empty */\n    jmain->rowgroup_ctr = 0;\n    break;\n#ifdef QUANT_2PASS_SUPPORTED\n  case JBUF_CRANK_DEST:\n    /* For last pass of 2-pass quantization, just crank the postprocessor */\n    jmain->pub.process_data = process_data_crank_post;\n    break;\n#endif\n  default:\n    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n    break;\n  }\n}\n\n\n/*\n * Process some data.\n * This handles the simple case where no context is required.\n */\n\nMETHODDEF void\nprocess_data_simple_main (j_decompress_ptr cinfo,\n\t\t\t  JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t\t\t  JDIMENSION out_rows_avail)\n{\n  // bk001204 - no use main\n  my_main_ptr jmain = (my_main_ptr) cinfo->main;\n  JDIMENSION rowgroups_avail;\n\n  /* Read input data if we haven't filled the main buffer yet */\n  if (! jmain->buffer_full) {\n    if (! (*cinfo->coef->decompress_data) (cinfo, jmain->buffer))\n      return;\t\t\t/* suspension forced, can do nothing more */\n    jmain->buffer_full = TRUE;\t/* OK, we have an iMCU row to work with */\n  }\n\n  /* There are always min_DCT_scaled_size row groups in an iMCU row. */\n  rowgroups_avail = (JDIMENSION) cinfo->min_DCT_scaled_size;\n  /* Note: at the bottom of the image, we may pass extra garbage row groups\n   * to the postprocessor.  The postprocessor has to check for bottom\n   * of image anyway (at row resolution), so no point in us doing it too.\n   */\n\n  /* Feed the postprocessor */\n  (*cinfo->post->post_process_data) (cinfo, jmain->buffer,\n\t\t\t\t     &jmain->rowgroup_ctr, rowgroups_avail,\n\t\t\t\t     output_buf, out_row_ctr, out_rows_avail);\n\n  /* Has postprocessor consumed all the data yet? If so, mark buffer empty */\n  if (jmain->rowgroup_ctr >= rowgroups_avail) {\n    jmain->buffer_full = FALSE;\n    jmain->rowgroup_ctr = 0;\n  }\n}\n\n\n/*\n * Process some data.\n * This handles the case where context rows must be provided.\n */\n\nMETHODDEF void\nprocess_data_context_main (j_decompress_ptr cinfo,\n\t\t\t   JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t\t\t   JDIMENSION out_rows_avail)\n{\n  // bk001204 - no use main\n  my_main_ptr jmain = (my_main_ptr) cinfo->main;\n\n  /* Read input data if we haven't filled the main buffer yet */\n  if (! jmain->buffer_full) {\n    if (! (*cinfo->coef->decompress_data) (cinfo,\n\t\t\t\t\t   jmain->xbuffer[jmain->whichptr]))\n      return;\t\t\t/* suspension forced, can do nothing more */\n    jmain->buffer_full = TRUE;\t/* OK, we have an iMCU row to work with */\n    jmain->iMCU_row_ctr++;\t/* count rows received */\n  }\n\n  /* Postprocessor typically will not swallow all the input data it is handed\n   * in one call (due to filling the output buffer first).  Must be prepared\n   * to exit and restart.  This switch lets us keep track of how far we got.\n   * Note that each case falls through to the next on successful completion.\n   */\n  switch (jmain->context_state) {\n  case CTX_POSTPONED_ROW:\n    /* Call postprocessor using previously set pointers for postponed row */\n    (*cinfo->post->post_process_data) (cinfo, jmain->xbuffer[jmain->whichptr],\n\t\t\t&jmain->rowgroup_ctr, jmain->rowgroups_avail,\n\t\t\toutput_buf, out_row_ctr, out_rows_avail);\n    if (jmain->rowgroup_ctr < jmain->rowgroups_avail)\n      return;\t\t\t/* Need to suspend */\n    jmain->context_state = CTX_PREPARE_FOR_IMCU;\n    if (*out_row_ctr >= out_rows_avail)\n      return;\t\t\t/* Postprocessor exactly filled output buf */\n    /*FALLTHROUGH*/\n  case CTX_PREPARE_FOR_IMCU:\n    /* Prepare to process first M-1 row groups of this iMCU row */\n    jmain->rowgroup_ctr = 0;\n    jmain->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size - 1);\n    /* Check for bottom of image: if so, tweak pointers to \"duplicate\"\n     * the last sample row, and adjust rowgroups_avail to ignore padding rows.\n     */\n    if (jmain->iMCU_row_ctr == cinfo->total_iMCU_rows)\n      set_bottom_pointers(cinfo);\n    jmain->context_state = CTX_PROCESS_IMCU;\n    /*FALLTHROUGH*/\n  case CTX_PROCESS_IMCU:\n    /* Call postprocessor using previously set pointers */\n    (*cinfo->post->post_process_data) (cinfo, jmain->xbuffer[jmain->whichptr],\n\t\t\t&jmain->rowgroup_ctr, jmain->rowgroups_avail,\n\t\t\toutput_buf, out_row_ctr, out_rows_avail);\n    if (jmain->rowgroup_ctr < jmain->rowgroups_avail)\n      return;\t\t\t/* Need to suspend */\n    /* After the first iMCU, change wraparound pointers to normal state */\n    if (jmain->iMCU_row_ctr == 1)\n      set_wraparound_pointers(cinfo);\n    /* Prepare to load new iMCU row using other xbuffer list */\n    jmain->whichptr ^= 1;\t/* 0=>1 or 1=>0 */\n    jmain->buffer_full = FALSE;\n    /* Still need to process last row group of this iMCU row, */\n    /* which is saved at index M+1 of the other xbuffer */\n    jmain->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_scaled_size + 1);\n    jmain->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size + 2);\n    jmain->context_state = CTX_POSTPONED_ROW;\n  }\n}\n\n\n/*\n * Process some data.\n * Final pass of two-pass quantization: just call the postprocessor.\n * Source data will be the postprocessor controller's internal buffer.\n */\n\n#ifdef QUANT_2PASS_SUPPORTED\n\nMETHODDEF void\nprocess_data_crank_post (j_decompress_ptr cinfo,\n\t\t\t JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t\t\t JDIMENSION out_rows_avail)\n{\n  (*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL,\n\t\t\t\t     (JDIMENSION *) NULL, (JDIMENSION) 0,\n\t\t\t\t     output_buf, out_row_ctr, out_rows_avail);\n}\n\n#endif /* QUANT_2PASS_SUPPORTED */\n\n\n/*\n * Initialize main buffer controller.\n */\n\nGLOBAL void\njinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer)\n{\n  // bk001204 - no use main\n  my_main_ptr jmain;\n  int ci, rgroup, ngroups;\n  jpeg_component_info *compptr;\n\n  jmain = (my_main_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_main_controller));\n  cinfo->main = (struct jpeg_d_main_controller *) jmain;\n  jmain->pub.start_pass = start_pass_main;\n\n  if (need_full_buffer)\t\t/* shouldn't happen */\n    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n\n  /* Allocate the workspace.\n   * ngroups is the number of row groups we need.\n   */\n  if (cinfo->upsample->need_context_rows) {\n    if (cinfo->min_DCT_scaled_size < 2) /* unsupported, see comments above */\n      ERREXIT(cinfo, JERR_NOTIMPL);\n    alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */\n    ngroups = cinfo->min_DCT_scaled_size + 2;\n  } else {\n    ngroups = cinfo->min_DCT_scaled_size;\n  }\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /\n      cinfo->min_DCT_scaled_size; /* height of a row group of component */\n    jmain->buffer[ci] = (*cinfo->mem->alloc_sarray)\n\t\t\t((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t compptr->width_in_blocks * compptr->DCT_scaled_size,\n\t\t\t (JDIMENSION) (rgroup * ngroups));\n  }\n}\n"
  },
  {
    "path": "code/jpeg-6/jdmarker.c",
    "content": "/*\n * jdmarker.c\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains routines to decode JPEG datastream markers.\n * Most of the complexity arises from our desire to support input\n * suspension: if not all of the data for a marker is available,\n * we must exit back to the application.  On resumption, we reprocess\n * the marker.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\ntypedef enum {\t\t\t/* JPEG marker codes */\n  M_SOF0  = 0xc0,\n  M_SOF1  = 0xc1,\n  M_SOF2  = 0xc2,\n  M_SOF3  = 0xc3,\n  \n  M_SOF5  = 0xc5,\n  M_SOF6  = 0xc6,\n  M_SOF7  = 0xc7,\n  \n  M_JPG   = 0xc8,\n  M_SOF9  = 0xc9,\n  M_SOF10 = 0xca,\n  M_SOF11 = 0xcb,\n  \n  M_SOF13 = 0xcd,\n  M_SOF14 = 0xce,\n  M_SOF15 = 0xcf,\n  \n  M_DHT   = 0xc4,\n  \n  M_DAC   = 0xcc,\n  \n  M_RST0  = 0xd0,\n  M_RST1  = 0xd1,\n  M_RST2  = 0xd2,\n  M_RST3  = 0xd3,\n  M_RST4  = 0xd4,\n  M_RST5  = 0xd5,\n  M_RST6  = 0xd6,\n  M_RST7  = 0xd7,\n  \n  M_SOI   = 0xd8,\n  M_EOI   = 0xd9,\n  M_SOS   = 0xda,\n  M_DQT   = 0xdb,\n  M_DNL   = 0xdc,\n  M_DRI   = 0xdd,\n  M_DHP   = 0xde,\n  M_EXP   = 0xdf,\n  \n  M_APP0  = 0xe0,\n  M_APP1  = 0xe1,\n  M_APP2  = 0xe2,\n  M_APP3  = 0xe3,\n  M_APP4  = 0xe4,\n  M_APP5  = 0xe5,\n  M_APP6  = 0xe6,\n  M_APP7  = 0xe7,\n  M_APP8  = 0xe8,\n  M_APP9  = 0xe9,\n  M_APP10 = 0xea,\n  M_APP11 = 0xeb,\n  M_APP12 = 0xec,\n  M_APP13 = 0xed,\n  M_APP14 = 0xee,\n  M_APP15 = 0xef,\n  \n  M_JPG0  = 0xf0,\n  M_JPG13 = 0xfd,\n  M_COM   = 0xfe,\n  \n  M_TEM   = 0x01,\n  \n  M_ERROR = 0x100\n} JPEG_MARKER;\n\n\n/*\n * Macros for fetching data from the data source module.\n *\n * At all times, cinfo->src->next_input_byte and ->bytes_in_buffer reflect\n * the current restart point; we update them only when we have reached a\n * suitable place to restart if a suspension occurs.\n */\n\n/* Declare and initialize local copies of input pointer/count */\n#define INPUT_VARS(cinfo)  \\\n\tstruct jpeg_source_mgr * datasrc = (cinfo)->src;  \\\n\tconst JOCTET * next_input_byte = datasrc->next_input_byte;  \\\n\tsize_t bytes_in_buffer = datasrc->bytes_in_buffer\n\n/* Unload the local copies --- do this only at a restart boundary */\n#define INPUT_SYNC(cinfo)  \\\n\t( datasrc->next_input_byte = next_input_byte,  \\\n\t  datasrc->bytes_in_buffer = bytes_in_buffer )\n\n/* Reload the local copies --- seldom used except in MAKE_BYTE_AVAIL */\n#define INPUT_RELOAD(cinfo)  \\\n\t( next_input_byte = datasrc->next_input_byte,  \\\n\t  bytes_in_buffer = datasrc->bytes_in_buffer )\n\n/* Internal macro for INPUT_BYTE and INPUT_2BYTES: make a byte available.\n * Note we do *not* do INPUT_SYNC before calling fill_input_buffer,\n * but we must reload the local copies after a successful fill.\n */\n#define MAKE_BYTE_AVAIL(cinfo,action)  \\\n\tif (bytes_in_buffer == 0) {  \\\n\t  if (! (*datasrc->fill_input_buffer) (cinfo))  \\\n\t    { action; }  \\\n\t  INPUT_RELOAD(cinfo);  \\\n\t}  \\\n\tbytes_in_buffer--\n\n/* Read a byte into variable V.\n * If must suspend, take the specified action (typically \"return FALSE\").\n */\n#define INPUT_BYTE(cinfo,V,action)  \\\n\tMAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \\\n\t\t  V = GETJOCTET(*next_input_byte++); )\n\n/* As above, but read two bytes interpreted as an unsigned 16-bit integer.\n * V should be declared unsigned int or perhaps INT32.\n */\n#define INPUT_2BYTES(cinfo,V,action)  \\\n\tMAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \\\n\t\t  V = ((unsigned int) GETJOCTET(*next_input_byte++)) << 8; \\\n\t\t  MAKE_BYTE_AVAIL(cinfo,action); \\\n\t\t  V += GETJOCTET(*next_input_byte++); )\n\n\n/*\n * Routines to process JPEG markers.\n *\n * Entry condition: JPEG marker itself has been read and its code saved\n *   in cinfo->unread_marker; input restart point is just after the marker.\n *\n * Exit: if return TRUE, have read and processed any parameters, and have\n *   updated the restart point to point after the parameters.\n *   If return FALSE, was forced to suspend before reaching end of\n *   marker parameters; restart point has not been moved.  Same routine\n *   will be called again after application supplies more input data.\n *\n * This approach to suspension assumes that all of a marker's parameters can\n * fit into a single input bufferload.  This should hold for \"normal\"\n * markers.  Some COM/APPn markers might have large parameter segments,\n * but we use skip_input_data to get past those, and thereby put the problem\n * on the source manager's shoulders.\n *\n * Note that we don't bother to avoid duplicate trace messages if a\n * suspension occurs within marker parameters.  Other side effects\n * require more care.\n */\n\n\nLOCAL boolean\nget_soi (j_decompress_ptr cinfo)\n/* Process an SOI marker */\n{\n  int i;\n  \n  TRACEMS(cinfo, 1, JTRC_SOI);\n\n  if (cinfo->marker->saw_SOI)\n    ERREXIT(cinfo, JERR_SOI_DUPLICATE);\n\n  /* Reset all parameters that are defined to be reset by SOI */\n\n  for (i = 0; i < NUM_ARITH_TBLS; i++) {\n    cinfo->arith_dc_L[i] = 0;\n    cinfo->arith_dc_U[i] = 1;\n    cinfo->arith_ac_K[i] = 5;\n  }\n  cinfo->restart_interval = 0;\n\n  /* Set initial assumptions for colorspace etc */\n\n  cinfo->jpeg_color_space = JCS_UNKNOWN;\n  cinfo->CCIR601_sampling = FALSE; /* Assume non-CCIR sampling??? */\n\n  cinfo->saw_JFIF_marker = FALSE;\n  cinfo->density_unit = 0;\t/* set default JFIF APP0 values */\n  cinfo->X_density = 1;\n  cinfo->Y_density = 1;\n  cinfo->saw_Adobe_marker = FALSE;\n  cinfo->Adobe_transform = 0;\n\n  cinfo->marker->saw_SOI = TRUE;\n\n  return TRUE;\n}\n\n\nLOCAL boolean\nget_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)\n/* Process a SOFn marker */\n{\n  INT32 length;\n  int c, ci;\n  jpeg_component_info * compptr;\n  INPUT_VARS(cinfo);\n\n  cinfo->progressive_mode = is_prog;\n  cinfo->arith_code = is_arith;\n\n  INPUT_2BYTES(cinfo, length, return FALSE);\n\n  INPUT_BYTE(cinfo, cinfo->data_precision, return FALSE);\n  INPUT_2BYTES(cinfo, cinfo->image_height, return FALSE);\n  INPUT_2BYTES(cinfo, cinfo->image_width, return FALSE);\n  INPUT_BYTE(cinfo, cinfo->num_components, return FALSE);\n\n  length -= 8;\n\n  TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker,\n\t   (int) cinfo->image_width, (int) cinfo->image_height,\n\t   cinfo->num_components);\n\n  if (cinfo->marker->saw_SOF)\n    ERREXIT(cinfo, JERR_SOF_DUPLICATE);\n\n  /* We don't support files in which the image height is initially specified */\n  /* as 0 and is later redefined by DNL.  As long as we have to check that,  */\n  /* might as well have a general sanity check. */\n  if (cinfo->image_height <= 0 || cinfo->image_width <= 0\n      || cinfo->num_components <= 0)\n    ERREXIT(cinfo, JERR_EMPTY_IMAGE);\n\n  if (length != (cinfo->num_components * 3))\n    ERREXIT(cinfo, JERR_BAD_LENGTH);\n\n  if (cinfo->comp_info == NULL)\t/* do only once, even if suspend */\n    cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small)\n\t\t\t((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t cinfo->num_components * SIZEOF(jpeg_component_info));\n  \n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    compptr->component_index = ci;\n    INPUT_BYTE(cinfo, compptr->component_id, return FALSE);\n    INPUT_BYTE(cinfo, c, return FALSE);\n    compptr->h_samp_factor = (c >> 4) & 15;\n    compptr->v_samp_factor = (c     ) & 15;\n    INPUT_BYTE(cinfo, compptr->quant_tbl_no, return FALSE);\n\n    TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT,\n\t     compptr->component_id, compptr->h_samp_factor,\n\t     compptr->v_samp_factor, compptr->quant_tbl_no);\n  }\n\n  cinfo->marker->saw_SOF = TRUE;\n\n  INPUT_SYNC(cinfo);\n  return TRUE;\n}\n\n\nLOCAL boolean\nget_sos (j_decompress_ptr cinfo)\n/* Process a SOS marker */\n{\n  INT32 length;\n  int i, ci, n, c, cc;\n  jpeg_component_info * compptr;\n  INPUT_VARS(cinfo);\n\n  if (! cinfo->marker->saw_SOF)\n    ERREXIT(cinfo, JERR_SOS_NO_SOF);\n\n  INPUT_2BYTES(cinfo, length, return FALSE);\n\n  INPUT_BYTE(cinfo, n, return FALSE); /* Number of components */\n\n  if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN)\n    ERREXIT(cinfo, JERR_BAD_LENGTH);\n\n  TRACEMS1(cinfo, 1, JTRC_SOS, n);\n\n  cinfo->comps_in_scan = n;\n\n  /* Collect the component-spec parameters */\n\n  for (i = 0; i < n; i++) {\n    INPUT_BYTE(cinfo, cc, return FALSE);\n    INPUT_BYTE(cinfo, c, return FALSE);\n    \n    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n\t ci++, compptr++) {\n      if (cc == compptr->component_id)\n\tgoto id_found;\n    }\n\n    ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);\n\n  id_found:\n\n    cinfo->cur_comp_info[i] = compptr;\n    compptr->dc_tbl_no = (c >> 4) & 15;\n    compptr->ac_tbl_no = (c     ) & 15;\n    \n    TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc,\n\t     compptr->dc_tbl_no, compptr->ac_tbl_no);\n  }\n\n  /* Collect the additional scan parameters Ss, Se, Ah/Al. */\n  INPUT_BYTE(cinfo, c, return FALSE);\n  cinfo->Ss = c;\n  INPUT_BYTE(cinfo, c, return FALSE);\n  cinfo->Se = c;\n  INPUT_BYTE(cinfo, c, return FALSE);\n  cinfo->Ah = (c >> 4) & 15;\n  cinfo->Al = (c     ) & 15;\n\n  TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo->Ss, cinfo->Se,\n\t   cinfo->Ah, cinfo->Al);\n\n  /* Prepare to scan data & restart markers */\n  cinfo->marker->next_restart_num = 0;\n\n  /* Count another SOS marker */\n  cinfo->input_scan_number++;\n\n  INPUT_SYNC(cinfo);\n  return TRUE;\n}\n\n\nMETHODDEF boolean\nget_app0 (j_decompress_ptr cinfo)\n/* Process an APP0 marker */\n{\n#define JFIF_LEN 14\n  INT32 length;\n  UINT8 b[JFIF_LEN];\n  int buffp;\n  INPUT_VARS(cinfo);\n\n  INPUT_2BYTES(cinfo, length, return FALSE);\n  length -= 2;\n\n  /* See if a JFIF APP0 marker is present */\n\n  if (length >= JFIF_LEN) {\n    for (buffp = 0; buffp < JFIF_LEN; buffp++)\n      INPUT_BYTE(cinfo, b[buffp], return FALSE);\n    length -= JFIF_LEN;\n\n    if (b[0]==0x4A && b[1]==0x46 && b[2]==0x49 && b[3]==0x46 && b[4]==0) {\n      /* Found JFIF APP0 marker: check version */\n      /* Major version must be 1, anything else signals an incompatible change.\n       * We used to treat this as an error, but now it's a nonfatal warning,\n       * because some bozo at Hijaak couldn't read the spec.\n       * Minor version should be 0..2, but process anyway if newer.\n       */\n      if (b[5] != 1)\n\tWARNMS2(cinfo, JWRN_JFIF_MAJOR, b[5], b[6]);\n      else if (b[6] > 2)\n\tTRACEMS2(cinfo, 1, JTRC_JFIF_MINOR, b[5], b[6]);\n      /* Save info */\n      cinfo->saw_JFIF_marker = TRUE;\n      cinfo->density_unit = b[7];\n      cinfo->X_density = (b[8] << 8) + b[9];\n      cinfo->Y_density = (b[10] << 8) + b[11];\n      TRACEMS3(cinfo, 1, JTRC_JFIF,\n\t       cinfo->X_density, cinfo->Y_density, cinfo->density_unit);\n      if (b[12] | b[13])\n\tTRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL, b[12], b[13]);\n      if (length != ((INT32) b[12] * (INT32) b[13] * (INT32) 3))\n\tTRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int) length);\n    } else {\n      /* Start of APP0 does not match \"JFIF\" */\n      TRACEMS1(cinfo, 1, JTRC_APP0, (int) length + JFIF_LEN);\n    }\n  } else {\n    /* Too short to be JFIF marker */\n    TRACEMS1(cinfo, 1, JTRC_APP0, (int) length);\n  }\n\n  INPUT_SYNC(cinfo);\n  if (length > 0)\t\t/* skip any remaining data -- could be lots */\n    (*cinfo->src->skip_input_data) (cinfo, (long) length);\n\n  return TRUE;\n}\n\n\nMETHODDEF boolean\nget_app14 (j_decompress_ptr cinfo)\n/* Process an APP14 marker */\n{\n#define ADOBE_LEN 12\n  INT32 length;\n  UINT8 b[ADOBE_LEN];\n  int buffp;\n  unsigned int version, flags0, flags1, transform;\n  INPUT_VARS(cinfo);\n\n  INPUT_2BYTES(cinfo, length, return FALSE);\n  length -= 2;\n\n  /* See if an Adobe APP14 marker is present */\n\n  if (length >= ADOBE_LEN) {\n    for (buffp = 0; buffp < ADOBE_LEN; buffp++)\n      INPUT_BYTE(cinfo, b[buffp], return FALSE);\n    length -= ADOBE_LEN;\n\n    if (b[0]==0x41 && b[1]==0x64 && b[2]==0x6F && b[3]==0x62 && b[4]==0x65) {\n      /* Found Adobe APP14 marker */\n      version = (b[5] << 8) + b[6];\n      flags0 = (b[7] << 8) + b[8];\n      flags1 = (b[9] << 8) + b[10];\n      transform = b[11];\n      TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform);\n      cinfo->saw_Adobe_marker = TRUE;\n      cinfo->Adobe_transform = (UINT8) transform;\n    } else {\n      /* Start of APP14 does not match \"Adobe\" */\n      TRACEMS1(cinfo, 1, JTRC_APP14, (int) length + ADOBE_LEN);\n    }\n  } else {\n    /* Too short to be Adobe marker */\n    TRACEMS1(cinfo, 1, JTRC_APP14, (int) length);\n  }\n\n  INPUT_SYNC(cinfo);\n  if (length > 0)\t\t/* skip any remaining data -- could be lots */\n    (*cinfo->src->skip_input_data) (cinfo, (long) length);\n\n  return TRUE;\n}\n\n\nLOCAL boolean\nget_dac (j_decompress_ptr cinfo)\n/* Process a DAC marker */\n{\n  INT32 length;\n  int index, val;\n  INPUT_VARS(cinfo);\n\n  INPUT_2BYTES(cinfo, length, return FALSE);\n  length -= 2;\n  \n  while (length > 0) {\n    INPUT_BYTE(cinfo, index, return FALSE);\n    INPUT_BYTE(cinfo, val, return FALSE);\n\n    length -= 2;\n\n    TRACEMS2(cinfo, 1, JTRC_DAC, index, val);\n\n    if (index < 0 || index >= (2*NUM_ARITH_TBLS))\n      ERREXIT1(cinfo, JERR_DAC_INDEX, index);\n\n    if (index >= NUM_ARITH_TBLS) { /* define AC table */\n      cinfo->arith_ac_K[index-NUM_ARITH_TBLS] = (UINT8) val;\n    } else {\t\t\t/* define DC table */\n      cinfo->arith_dc_L[index] = (UINT8) (val & 0x0F);\n      cinfo->arith_dc_U[index] = (UINT8) (val >> 4);\n      if (cinfo->arith_dc_L[index] > cinfo->arith_dc_U[index])\n\tERREXIT1(cinfo, JERR_DAC_VALUE, val);\n    }\n  }\n\n  INPUT_SYNC(cinfo);\n  return TRUE;\n}\n\n\nLOCAL boolean\nget_dht (j_decompress_ptr cinfo)\n/* Process a DHT marker */\n{\n  INT32 length;\n  UINT8 bits[17];\n  UINT8 huffval[256];\n  int i, index, count;\n  JHUFF_TBL **htblptr;\n  INPUT_VARS(cinfo);\n\n  INPUT_2BYTES(cinfo, length, return FALSE);\n  length -= 2;\n  \n  while (length > 0) {\n    INPUT_BYTE(cinfo, index, return FALSE);\n\n    TRACEMS1(cinfo, 1, JTRC_DHT, index);\n      \n    bits[0] = 0;\n    count = 0;\n    for (i = 1; i <= 16; i++) {\n      INPUT_BYTE(cinfo, bits[i], return FALSE);\n      count += bits[i];\n    }\n\n    length -= 1 + 16;\n\n    TRACEMS8(cinfo, 2, JTRC_HUFFBITS,\n\t     bits[1], bits[2], bits[3], bits[4],\n\t     bits[5], bits[6], bits[7], bits[8]);\n    TRACEMS8(cinfo, 2, JTRC_HUFFBITS,\n\t     bits[9], bits[10], bits[11], bits[12],\n\t     bits[13], bits[14], bits[15], bits[16]);\n\n    if (count > 256 || ((INT32) count) > length)\n      ERREXIT(cinfo, JERR_DHT_COUNTS);\n\n    for (i = 0; i < count; i++)\n      INPUT_BYTE(cinfo, huffval[i], return FALSE);\n\n    length -= count;\n\n    if (index & 0x10) {\t\t/* AC table definition */\n      index -= 0x10;\n      htblptr = &cinfo->ac_huff_tbl_ptrs[index];\n    } else {\t\t\t/* DC table definition */\n      htblptr = &cinfo->dc_huff_tbl_ptrs[index];\n    }\n\n    if (index < 0 || index >= NUM_HUFF_TBLS)\n      ERREXIT1(cinfo, JERR_DHT_INDEX, index);\n\n    if (*htblptr == NULL)\n      *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);\n  \n    MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits));\n    MEMCOPY((*htblptr)->huffval, huffval, SIZEOF((*htblptr)->huffval));\n  }\n\n  INPUT_SYNC(cinfo);\n  return TRUE;\n}\n\n\nLOCAL boolean\nget_dqt (j_decompress_ptr cinfo)\n/* Process a DQT marker */\n{\n  INT32 length;\n  int n, i, prec;\n  unsigned int tmp;\n  JQUANT_TBL *quant_ptr;\n  INPUT_VARS(cinfo);\n\n  INPUT_2BYTES(cinfo, length, return FALSE);\n  length -= 2;\n\n  while (length > 0) {\n    INPUT_BYTE(cinfo, n, return FALSE);\n    prec = n >> 4;\n    n &= 0x0F;\n\n    TRACEMS2(cinfo, 1, JTRC_DQT, n, prec);\n\n    if (n >= NUM_QUANT_TBLS)\n      ERREXIT1(cinfo, JERR_DQT_INDEX, n);\n      \n    if (cinfo->quant_tbl_ptrs[n] == NULL)\n      cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo);\n    quant_ptr = cinfo->quant_tbl_ptrs[n];\n\n    for (i = 0; i < DCTSIZE2; i++) {\n      if (prec)\n\tINPUT_2BYTES(cinfo, tmp, return FALSE);\n      else\n\tINPUT_BYTE(cinfo, tmp, return FALSE);\n      quant_ptr->quantval[i] = (UINT16) tmp;\n    }\n\n    for (i = 0; i < DCTSIZE2; i += 8) {\n      TRACEMS8(cinfo, 2, JTRC_QUANTVALS,\n\t       quant_ptr->quantval[i  ], quant_ptr->quantval[i+1],\n\t       quant_ptr->quantval[i+2], quant_ptr->quantval[i+3],\n\t       quant_ptr->quantval[i+4], quant_ptr->quantval[i+5],\n\t       quant_ptr->quantval[i+6], quant_ptr->quantval[i+7]);\n    }\n\n    length -= DCTSIZE2+1;\n    if (prec) length -= DCTSIZE2;\n  }\n\n  INPUT_SYNC(cinfo);\n  return TRUE;\n}\n\n\nLOCAL boolean\nget_dri (j_decompress_ptr cinfo)\n/* Process a DRI marker */\n{\n  INT32 length;\n  unsigned int tmp;\n  INPUT_VARS(cinfo);\n\n  INPUT_2BYTES(cinfo, length, return FALSE);\n  \n  if (length != 4)\n    ERREXIT(cinfo, JERR_BAD_LENGTH);\n\n  INPUT_2BYTES(cinfo, tmp, return FALSE);\n\n  TRACEMS1(cinfo, 1, JTRC_DRI, tmp);\n\n  cinfo->restart_interval = tmp;\n\n  INPUT_SYNC(cinfo);\n  return TRUE;\n}\n\n\nMETHODDEF boolean\nskip_variable (j_decompress_ptr cinfo)\n/* Skip over an unknown or uninteresting variable-length marker */\n{\n  INT32 length;\n  INPUT_VARS(cinfo);\n\n  INPUT_2BYTES(cinfo, length, return FALSE);\n  \n  TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int) length);\n\n  INPUT_SYNC(cinfo);\t\t/* do before skip_input_data */\n  (*cinfo->src->skip_input_data) (cinfo, (long) length - 2L);\n\n  return TRUE;\n}\n\n\n/*\n * Find the next JPEG marker, save it in cinfo->unread_marker.\n * Returns FALSE if had to suspend before reaching a marker;\n * in that case cinfo->unread_marker is unchanged.\n *\n * Note that the result might not be a valid marker code,\n * but it will never be 0 or FF.\n */\n\nLOCAL boolean\nnext_marker (j_decompress_ptr cinfo)\n{\n  int c;\n  INPUT_VARS(cinfo);\n\n  for (;;) {\n    INPUT_BYTE(cinfo, c, return FALSE);\n    /* Skip any non-FF bytes.\n     * This may look a bit inefficient, but it will not occur in a valid file.\n     * We sync after each discarded byte so that a suspending data source\n     * can discard the byte from its buffer.\n     */\n    while (c != 0xFF) {\n      cinfo->marker->discarded_bytes++;\n      INPUT_SYNC(cinfo);\n      INPUT_BYTE(cinfo, c, return FALSE);\n    }\n    /* This loop swallows any duplicate FF bytes.  Extra FFs are legal as\n     * pad bytes, so don't count them in discarded_bytes.  We assume there\n     * will not be so many consecutive FF bytes as to overflow a suspending\n     * data source's input buffer.\n     */\n    do {\n      INPUT_BYTE(cinfo, c, return FALSE);\n    } while (c == 0xFF);\n    if (c != 0)\n      break;\t\t\t/* found a valid marker, exit loop */\n    /* Reach here if we found a stuffed-zero data sequence (FF/00).\n     * Discard it and loop back to try again.\n     */\n    cinfo->marker->discarded_bytes += 2;\n    INPUT_SYNC(cinfo);\n  }\n\n  if (cinfo->marker->discarded_bytes != 0) {\n    WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes, c);\n    cinfo->marker->discarded_bytes = 0;\n  }\n\n  cinfo->unread_marker = c;\n\n  INPUT_SYNC(cinfo);\n  return TRUE;\n}\n\n\nLOCAL boolean\nfirst_marker (j_decompress_ptr cinfo)\n/* Like next_marker, but used to obtain the initial SOI marker. */\n/* For this marker, we do not allow preceding garbage or fill; otherwise,\n * we might well scan an entire input file before realizing it ain't JPEG.\n * If an application wants to process non-JFIF files, it must seek to the\n * SOI before calling the JPEG library.\n */\n{\n  int c, c2;\n  INPUT_VARS(cinfo);\n\n  INPUT_BYTE(cinfo, c, return FALSE);\n  INPUT_BYTE(cinfo, c2, return FALSE);\n  if (c != 0xFF || c2 != (int) M_SOI)\n    ERREXIT2(cinfo, JERR_NO_SOI, c, c2);\n\n  cinfo->unread_marker = c2;\n\n  INPUT_SYNC(cinfo);\n  return TRUE;\n}\n\n\n/*\n * Read markers until SOS or EOI.\n *\n * Returns same codes as are defined for jpeg_consume_input:\n * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.\n */\n\nMETHODDEF int\nread_markers (j_decompress_ptr cinfo)\n{\n  /* Outer loop repeats once for each marker. */\n  for (;;) {\n    /* Collect the marker proper, unless we already did. */\n    /* NB: first_marker() enforces the requirement that SOI appear first. */\n    if (cinfo->unread_marker == 0) {\n      if (! cinfo->marker->saw_SOI) {\n\tif (! first_marker(cinfo))\n\t  return JPEG_SUSPENDED;\n      } else {\n\tif (! next_marker(cinfo))\n\t  return JPEG_SUSPENDED;\n      }\n    }\n    /* At this point cinfo->unread_marker contains the marker code and the\n     * input point is just past the marker proper, but before any parameters.\n     * A suspension will cause us to return with this state still true.\n     */\n    switch (cinfo->unread_marker) {\n    case M_SOI:\n      if (! get_soi(cinfo))\n\treturn JPEG_SUSPENDED;\n      break;\n\n    case M_SOF0:\t\t/* Baseline */\n    case M_SOF1:\t\t/* Extended sequential, Huffman */\n      if (! get_sof(cinfo, FALSE, FALSE))\n\treturn JPEG_SUSPENDED;\n      break;\n\n    case M_SOF2:\t\t/* Progressive, Huffman */\n      if (! get_sof(cinfo, TRUE, FALSE))\n\treturn JPEG_SUSPENDED;\n      break;\n\n    case M_SOF9:\t\t/* Extended sequential, arithmetic */\n      if (! get_sof(cinfo, FALSE, TRUE))\n\treturn JPEG_SUSPENDED;\n      break;\n\n    case M_SOF10:\t\t/* Progressive, arithmetic */\n      if (! get_sof(cinfo, TRUE, TRUE))\n\treturn JPEG_SUSPENDED;\n      break;\n\n    /* Currently unsupported SOFn types */\n    case M_SOF3:\t\t/* Lossless, Huffman */\n    case M_SOF5:\t\t/* Differential sequential, Huffman */\n    case M_SOF6:\t\t/* Differential progressive, Huffman */\n    case M_SOF7:\t\t/* Differential lossless, Huffman */\n    case M_JPG:\t\t\t/* Reserved for JPEG extensions */\n    case M_SOF11:\t\t/* Lossless, arithmetic */\n    case M_SOF13:\t\t/* Differential sequential, arithmetic */\n    case M_SOF14:\t\t/* Differential progressive, arithmetic */\n    case M_SOF15:\t\t/* Differential lossless, arithmetic */\n      ERREXIT1(cinfo, JERR_SOF_UNSUPPORTED, cinfo->unread_marker);\n      break;\n\n    case M_SOS:\n      if (! get_sos(cinfo))\n\treturn JPEG_SUSPENDED;\n      cinfo->unread_marker = 0;\t/* processed the marker */\n      return JPEG_REACHED_SOS;\n    \n    case M_EOI:\n      TRACEMS(cinfo, 1, JTRC_EOI);\n      cinfo->unread_marker = 0;\t/* processed the marker */\n      return JPEG_REACHED_EOI;\n      \n    case M_DAC:\n      if (! get_dac(cinfo))\n\treturn JPEG_SUSPENDED;\n      break;\n      \n    case M_DHT:\n      if (! get_dht(cinfo))\n\treturn JPEG_SUSPENDED;\n      break;\n      \n    case M_DQT:\n      if (! get_dqt(cinfo))\n\treturn JPEG_SUSPENDED;\n      break;\n      \n    case M_DRI:\n      if (! get_dri(cinfo))\n\treturn JPEG_SUSPENDED;\n      break;\n      \n    case M_APP0:\n    case M_APP1:\n    case M_APP2:\n    case M_APP3:\n    case M_APP4:\n    case M_APP5:\n    case M_APP6:\n    case M_APP7:\n    case M_APP8:\n    case M_APP9:\n    case M_APP10:\n    case M_APP11:\n    case M_APP12:\n    case M_APP13:\n    case M_APP14:\n    case M_APP15:\n      if (! (*cinfo->marker->process_APPn[cinfo->unread_marker - (int) M_APP0]) (cinfo))\n\treturn JPEG_SUSPENDED;\n      break;\n      \n    case M_COM:\n      if (! (*cinfo->marker->process_COM) (cinfo))\n\treturn JPEG_SUSPENDED;\n      break;\n\n    case M_RST0:\t\t/* these are all parameterless */\n    case M_RST1:\n    case M_RST2:\n    case M_RST3:\n    case M_RST4:\n    case M_RST5:\n    case M_RST6:\n    case M_RST7:\n    case M_TEM:\n      TRACEMS1(cinfo, 1, JTRC_PARMLESS_MARKER, cinfo->unread_marker);\n      break;\n\n    case M_DNL:\t\t\t/* Ignore DNL ... perhaps the wrong thing */\n      if (! skip_variable(cinfo))\n\treturn JPEG_SUSPENDED;\n      break;\n\n    default:\t\t\t/* must be DHP, EXP, JPGn, or RESn */\n      /* For now, we treat the reserved markers as fatal errors since they are\n       * likely to be used to signal incompatible JPEG Part 3 extensions.\n       * Once the JPEG 3 version-number marker is well defined, this code\n       * ought to change!\n       */\n      ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);\n      break;\n    }\n    /* Successfully processed marker, so reset state variable */\n    cinfo->unread_marker = 0;\n  } /* end loop */\n}\n\n\n/*\n * Read a restart marker, which is expected to appear next in the datastream;\n * if the marker is not there, take appropriate recovery action.\n * Returns FALSE if suspension is required.\n *\n * This is called by the entropy decoder after it has read an appropriate\n * number of MCUs.  cinfo->unread_marker may be nonzero if the entropy decoder\n * has already read a marker from the data source.  Under normal conditions\n * cinfo->unread_marker will be reset to 0 before returning; if not reset,\n * it holds a marker which the decoder will be unable to read past.\n */\n\nMETHODDEF boolean\nread_restart_marker (j_decompress_ptr cinfo)\n{\n  /* Obtain a marker unless we already did. */\n  /* Note that next_marker will complain if it skips any data. */\n  if (cinfo->unread_marker == 0) {\n    if (! next_marker(cinfo))\n      return FALSE;\n  }\n\n  if (cinfo->unread_marker ==\n      ((int) M_RST0 + cinfo->marker->next_restart_num)) {\n    /* Normal case --- swallow the marker and let entropy decoder continue */\n    TRACEMS1(cinfo, 2, JTRC_RST, cinfo->marker->next_restart_num);\n    cinfo->unread_marker = 0;\n  } else {\n    /* Uh-oh, the restart markers have been messed up. */\n    /* Let the data source manager determine how to resync. */\n    if (! (*cinfo->src->resync_to_restart) (cinfo,\n\t\t\t\t\t    cinfo->marker->next_restart_num))\n      return FALSE;\n  }\n\n  /* Update next-restart state */\n  cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7;\n\n  return TRUE;\n}\n\n\n/*\n * This is the default resync_to_restart method for data source managers\n * to use if they don't have any better approach.  Some data source managers\n * may be able to back up, or may have additional knowledge about the data\n * which permits a more intelligent recovery strategy; such managers would\n * presumably supply their own resync method.\n *\n * read_restart_marker calls resync_to_restart if it finds a marker other than\n * the restart marker it was expecting.  (This code is *not* used unless\n * a nonzero restart interval has been declared.)  cinfo->unread_marker is\n * the marker code actually found (might be anything, except 0 or FF).\n * The desired restart marker number (0..7) is passed as a parameter.\n * This routine is supposed to apply whatever error recovery strategy seems\n * appropriate in order to position the input stream to the next data segment.\n * Note that cinfo->unread_marker is treated as a marker appearing before\n * the current data-source input point; usually it should be reset to zero\n * before returning.\n * Returns FALSE if suspension is required.\n *\n * This implementation is substantially constrained by wanting to treat the\n * input as a data stream; this means we can't back up.  Therefore, we have\n * only the following actions to work with:\n *   1. Simply discard the marker and let the entropy decoder resume at next\n *      byte of file.\n *   2. Read forward until we find another marker, discarding intervening\n *      data.  (In theory we could look ahead within the current bufferload,\n *      without having to discard data if we don't find the desired marker.\n *      This idea is not implemented here, in part because it makes behavior\n *      dependent on buffer size and chance buffer-boundary positions.)\n *   3. Leave the marker unread (by failing to zero cinfo->unread_marker).\n *      This will cause the entropy decoder to process an empty data segment,\n *      inserting dummy zeroes, and then we will reprocess the marker.\n *\n * #2 is appropriate if we think the desired marker lies ahead, while #3 is\n * appropriate if the found marker is a future restart marker (indicating\n * that we have missed the desired restart marker, probably because it got\n * corrupted).\n * We apply #2 or #3 if the found marker is a restart marker no more than\n * two counts behind or ahead of the expected one.  We also apply #2 if the\n * found marker is not a legal JPEG marker code (it's certainly bogus data).\n * If the found marker is a restart marker more than 2 counts away, we do #1\n * (too much risk that the marker is erroneous; with luck we will be able to\n * resync at some future point).\n * For any valid non-restart JPEG marker, we apply #3.  This keeps us from\n * overrunning the end of a scan.  An implementation limited to single-scan\n * files might find it better to apply #2 for markers other than EOI, since\n * any other marker would have to be bogus data in that case.\n */\n\nGLOBAL boolean\njpeg_resync_to_restart (j_decompress_ptr cinfo, int desired)\n{\n  int marker = cinfo->unread_marker;\n  int action = 1;\n  \n  /* Always put up a warning. */\n  WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired);\n  \n  /* Outer loop handles repeated decision after scanning forward. */\n  for (;;) {\n    if (marker < (int) M_SOF0)\n      action = 2;\t\t/* invalid marker */\n    else if (marker < (int) M_RST0 || marker > (int) M_RST7)\n      action = 3;\t\t/* valid non-restart marker */\n    else {\n      if (marker == ((int) M_RST0 + ((desired+1) & 7)) ||\n\t  marker == ((int) M_RST0 + ((desired+2) & 7)))\n\taction = 3;\t\t/* one of the next two expected restarts */\n      else if (marker == ((int) M_RST0 + ((desired-1) & 7)) ||\n\t       marker == ((int) M_RST0 + ((desired-2) & 7)))\n\taction = 2;\t\t/* a prior restart, so advance */\n      else\n\taction = 1;\t\t/* desired restart or too far away */\n    }\n    TRACEMS2(cinfo, 4, JTRC_RECOVERY_ACTION, marker, action);\n    switch (action) {\n    case 1:\n      /* Discard marker and let entropy decoder resume processing. */\n      cinfo->unread_marker = 0;\n      return TRUE;\n    case 2:\n      /* Scan to the next marker, and repeat the decision loop. */\n      if (! next_marker(cinfo))\n\treturn FALSE;\n      marker = cinfo->unread_marker;\n      break;\n    case 3:\n      /* Return without advancing past this marker. */\n      /* Entropy decoder will be forced to process an empty segment. */\n      return TRUE;\n    }\n  } /* end loop */\n}\n\n\n/*\n * Reset marker processing state to begin a fresh datastream.\n */\n\nMETHODDEF void\nreset_marker_reader (j_decompress_ptr cinfo)\n{\n  cinfo->comp_info = NULL;\t\t/* until allocated by get_sof */\n  cinfo->input_scan_number = 0;\t\t/* no SOS seen yet */\n  cinfo->unread_marker = 0;\t\t/* no pending marker */\n  cinfo->marker->saw_SOI = FALSE;\t/* set internal state too */\n  cinfo->marker->saw_SOF = FALSE;\n  cinfo->marker->discarded_bytes = 0;\n}\n\n\n/*\n * Initialize the marker reader module.\n * This is called only once, when the decompression object is created.\n */\n\nGLOBAL void\njinit_marker_reader (j_decompress_ptr cinfo)\n{\n  int i;\n\n  /* Create subobject in permanent pool */\n  cinfo->marker = (struct jpeg_marker_reader *)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,\n\t\t\t\tSIZEOF(struct jpeg_marker_reader));\n  /* Initialize method pointers */\n  cinfo->marker->reset_marker_reader = reset_marker_reader;\n  cinfo->marker->read_markers = read_markers;\n  cinfo->marker->read_restart_marker = read_restart_marker;\n  cinfo->marker->process_COM = skip_variable;\n  for (i = 0; i < 16; i++)\n    cinfo->marker->process_APPn[i] = skip_variable;\n  cinfo->marker->process_APPn[0] = get_app0;\n  cinfo->marker->process_APPn[14] = get_app14;\n  /* Reset marker processing state */\n  reset_marker_reader(cinfo);\n}\n"
  },
  {
    "path": "code/jpeg-6/jdmaster.c",
    "content": "/*\n * jdmaster.c\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains master control logic for the JPEG decompressor.\n * These routines are concerned with selecting the modules to be executed\n * and with determining the number of passes and the work to be done in each\n * pass.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/* Private state */\n\ntypedef struct {\n  struct jpeg_decomp_master pub; /* public fields */\n\n  int pass_number;\t\t/* # of passes completed */\n\n  boolean using_merged_upsample; /* TRUE if using merged upsample/cconvert */\n\n  /* Saved references to initialized quantizer modules,\n   * in case we need to switch modes.\n   */\n  struct jpeg_color_quantizer * quantizer_1pass;\n  struct jpeg_color_quantizer * quantizer_2pass;\n} my_decomp_master;\n\ntypedef my_decomp_master * my_master_ptr;\n\n\n/*\n * Determine whether merged upsample/color conversion should be used.\n * CRUCIAL: this must match the actual capabilities of jdmerge.c!\n */\n\nLOCAL boolean\nuse_merged_upsample (j_decompress_ptr cinfo)\n{\n#ifdef UPSAMPLE_MERGING_SUPPORTED\n  /* Merging is the equivalent of plain box-filter upsampling */\n  if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling)\n    return FALSE;\n  /* jdmerge.c only supports YCC=>RGB color conversion */\n  if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 ||\n      cinfo->out_color_space != JCS_RGB ||\n      cinfo->out_color_components != RGB_PIXELSIZE)\n    return FALSE;\n  /* and it only handles 2h1v or 2h2v sampling ratios */\n  if (cinfo->comp_info[0].h_samp_factor != 2 ||\n      cinfo->comp_info[1].h_samp_factor != 1 ||\n      cinfo->comp_info[2].h_samp_factor != 1 ||\n      cinfo->comp_info[0].v_samp_factor >  2 ||\n      cinfo->comp_info[1].v_samp_factor != 1 ||\n      cinfo->comp_info[2].v_samp_factor != 1)\n    return FALSE;\n  /* furthermore, it doesn't work if we've scaled the IDCTs differently */\n  if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size ||\n      cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size ||\n      cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size)\n    return FALSE;\n  /* ??? also need to test for upsample-time rescaling, when & if supported */\n  return TRUE;\t\t\t/* by golly, it'll work... */\n#else\n  return FALSE;\n#endif\n}\n\n\n/*\n * Compute output image dimensions and related values.\n * NOTE: this is exported for possible use by application.\n * Hence it mustn't do anything that can't be done twice.\n * Also note that it may be called before the master module is initialized!\n */\n\nGLOBAL void\njpeg_calc_output_dimensions (j_decompress_ptr cinfo)\n/* Do computations that are needed before master selection phase */\n{\n#if 0\t// JDC: commented out to remove warning\n  int ci;\n  jpeg_component_info *compptr;\n#endif\n\n  /* Prevent application from calling me at wrong times */\n  if (cinfo->global_state != DSTATE_READY)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n\n#ifdef IDCT_SCALING_SUPPORTED\n\n  /* Compute actual output image dimensions and DCT scaling choices. */\n  if (cinfo->scale_num * 8 <= cinfo->scale_denom) {\n    /* Provide 1/8 scaling */\n    cinfo->output_width = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_width, 8L);\n    cinfo->output_height = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_height, 8L);\n    cinfo->min_DCT_scaled_size = 1;\n  } else if (cinfo->scale_num * 4 <= cinfo->scale_denom) {\n    /* Provide 1/4 scaling */\n    cinfo->output_width = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_width, 4L);\n    cinfo->output_height = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_height, 4L);\n    cinfo->min_DCT_scaled_size = 2;\n  } else if (cinfo->scale_num * 2 <= cinfo->scale_denom) {\n    /* Provide 1/2 scaling */\n    cinfo->output_width = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_width, 2L);\n    cinfo->output_height = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_height, 2L);\n    cinfo->min_DCT_scaled_size = 4;\n  } else {\n    /* Provide 1/1 scaling */\n    cinfo->output_width = cinfo->image_width;\n    cinfo->output_height = cinfo->image_height;\n    cinfo->min_DCT_scaled_size = DCTSIZE;\n  }\n  /* In selecting the actual DCT scaling for each component, we try to\n   * scale up the chroma components via IDCT scaling rather than upsampling.\n   * This saves time if the upsampler gets to use 1:1 scaling.\n   * Note this code assumes that the supported DCT scalings are powers of 2.\n   */\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    int ssize = cinfo->min_DCT_scaled_size;\n    while (ssize < DCTSIZE &&\n\t   (compptr->h_samp_factor * ssize * 2 <=\n\t    cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) &&\n\t   (compptr->v_samp_factor * ssize * 2 <=\n\t    cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) {\n      ssize = ssize * 2;\n    }\n    compptr->DCT_scaled_size = ssize;\n  }\n\n  /* Recompute downsampled dimensions of components;\n   * application needs to know these if using raw downsampled data.\n   */\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    /* Size in samples, after IDCT scaling */\n    compptr->downsampled_width = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_width *\n\t\t    (long) (compptr->h_samp_factor * compptr->DCT_scaled_size),\n\t\t    (long) (cinfo->max_h_samp_factor * DCTSIZE));\n    compptr->downsampled_height = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_height *\n\t\t    (long) (compptr->v_samp_factor * compptr->DCT_scaled_size),\n\t\t    (long) (cinfo->max_v_samp_factor * DCTSIZE));\n  }\n\n#else /* !IDCT_SCALING_SUPPORTED */\n\n  /* Hardwire it to \"no scaling\" */\n  cinfo->output_width = cinfo->image_width;\n  cinfo->output_height = cinfo->image_height;\n  /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE,\n   * and has computed unscaled downsampled_width and downsampled_height.\n   */\n\n#endif /* IDCT_SCALING_SUPPORTED */\n\n  /* Report number of components in selected colorspace. */\n  /* Probably this should be in the color conversion module... */\n  switch (cinfo->out_color_space) {\n  case JCS_GRAYSCALE:\n    cinfo->out_color_components = 1;\n    break;\n  case JCS_RGB:\n#if RGB_PIXELSIZE != 3\n    cinfo->out_color_components = RGB_PIXELSIZE;\n    break;\n#endif /* else share code with YCbCr */\n  case JCS_YCbCr:\n    cinfo->out_color_components = 3;\n    break;\n  case JCS_CMYK:\n  case JCS_YCCK:\n    cinfo->out_color_components = 4;\n    break;\n  default:\t\t\t/* else must be same colorspace as in file */\n    cinfo->out_color_components = cinfo->num_components;\n    break;\n  }\n  cinfo->output_components = (cinfo->quantize_colors ? 1 :\n\t\t\t      cinfo->out_color_components);\n\n  /* See if upsampler will want to emit more than one row at a time */\n  if (use_merged_upsample(cinfo))\n    cinfo->rec_outbuf_height = cinfo->max_v_samp_factor;\n  else\n    cinfo->rec_outbuf_height = 1;\n}\n\n\n/*\n * Several decompression processes need to range-limit values to the range\n * 0..MAXJSAMPLE; the input value may fall somewhat outside this range\n * due to noise introduced by quantization, roundoff error, etc.  These\n * processes are inner loops and need to be as fast as possible.  On most\n * machines, particularly CPUs with pipelines or instruction prefetch,\n * a (subscript-check-less) C table lookup\n *\t\tx = sample_range_limit[x];\n * is faster than explicit tests\n *\t\tif (x < 0)  x = 0;\n *\t\telse if (x > MAXJSAMPLE)  x = MAXJSAMPLE;\n * These processes all use a common table prepared by the routine below.\n *\n * For most steps we can mathematically guarantee that the initial value\n * of x is within MAXJSAMPLE+1 of the legal range, so a table running from\n * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient.  But for the initial\n * limiting step (just after the IDCT), a wildly out-of-range value is \n * possible if the input data is corrupt.  To avoid any chance of indexing\n * off the end of memory and getting a bad-pointer trap, we perform the\n * post-IDCT limiting thus:\n *\t\tx = range_limit[x & MASK];\n * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit\n * samples.  Under normal circumstances this is more than enough range and\n * a correct output will be generated; with bogus input data the mask will\n * cause wraparound, and we will safely generate a bogus-but-in-range output.\n * For the post-IDCT step, we want to convert the data from signed to unsigned\n * representation by adding CENTERJSAMPLE at the same time that we limit it.\n * So the post-IDCT limiting table ends up looking like this:\n *   CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE,\n *   MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),\n *   0          (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),\n *   0,1,...,CENTERJSAMPLE-1\n * Negative inputs select values from the upper half of the table after\n * masking.\n *\n * We can save some space by overlapping the start of the post-IDCT table\n * with the simpler range limiting table.  The post-IDCT table begins at\n * sample_range_limit + CENTERJSAMPLE.\n *\n * Note that the table is allocated in near data space on PCs; it's small\n * enough and used often enough to justify this.\n */\n\nLOCAL void\nprepare_range_limit_table (j_decompress_ptr cinfo)\n/* Allocate and fill in the sample_range_limit table */\n{\n  JSAMPLE * table;\n  int i;\n\n  table = (JSAMPLE *)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t(5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE));\n  table += (MAXJSAMPLE+1);\t/* allow negative subscripts of simple table */\n  cinfo->sample_range_limit = table;\n  /* First segment of \"simple\" table: limit[x] = 0 for x < 0 */\n  MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));\n  /* Main part of \"simple\" table: limit[x] = x */\n  for (i = 0; i <= MAXJSAMPLE; i++)\n    table[i] = (JSAMPLE) i;\n  table += CENTERJSAMPLE;\t/* Point to where post-IDCT table starts */\n  /* End of simple table, rest of first half of post-IDCT table */\n  for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++)\n    table[i] = MAXJSAMPLE;\n  /* Second half of post-IDCT table */\n  MEMZERO(table + (2 * (MAXJSAMPLE+1)),\n\t  (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE));\n  MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE),\n\t  cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE));\n}\n\n\n/*\n * Master selection of decompression modules.\n * This is done once at jpeg_start_decompress time.  We determine\n * which modules will be used and give them appropriate initialization calls.\n * We also initialize the decompressor input side to begin consuming data.\n *\n * Since jpeg_read_header has finished, we know what is in the SOF\n * and (first) SOS markers.  We also have all the application parameter\n * settings.\n */\n\nLOCAL void\nmaster_selection (j_decompress_ptr cinfo)\n{\n  my_master_ptr master = (my_master_ptr) cinfo->master;\n  boolean use_c_buffer;\n  long samplesperrow;\n  JDIMENSION jd_samplesperrow;\n\n  /* Initialize dimensions and other stuff */\n  jpeg_calc_output_dimensions(cinfo);\n  prepare_range_limit_table(cinfo);\n\n  /* Width of an output scanline must be representable as JDIMENSION. */\n  samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components;\n  jd_samplesperrow = (JDIMENSION) samplesperrow;\n  if ((long) jd_samplesperrow != samplesperrow)\n    ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);\n\n  /* Initialize my private state */\n  master->pass_number = 0;\n  master->using_merged_upsample = use_merged_upsample(cinfo);\n\n  /* Color quantizer selection */\n  master->quantizer_1pass = NULL;\n  master->quantizer_2pass = NULL;\n  /* No mode changes if not using buffered-image mode. */\n  if (! cinfo->quantize_colors || ! cinfo->buffered_image) {\n    cinfo->enable_1pass_quant = FALSE;\n    cinfo->enable_external_quant = FALSE;\n    cinfo->enable_2pass_quant = FALSE;\n  }\n  if (cinfo->quantize_colors) {\n    if (cinfo->raw_data_out)\n      ERREXIT(cinfo, JERR_NOTIMPL);\n    /* 2-pass quantizer only works in 3-component color space. */\n    if (cinfo->out_color_components != 3) {\n      cinfo->enable_1pass_quant = TRUE;\n      cinfo->enable_external_quant = FALSE;\n      cinfo->enable_2pass_quant = FALSE;\n      cinfo->colormap = NULL;\n    } else if (cinfo->colormap != NULL) {\n      cinfo->enable_external_quant = TRUE;\n    } else if (cinfo->two_pass_quantize) {\n      cinfo->enable_2pass_quant = TRUE;\n    } else {\n      cinfo->enable_1pass_quant = TRUE;\n    }\n\n    if (cinfo->enable_1pass_quant) {\n#ifdef QUANT_1PASS_SUPPORTED\n      jinit_1pass_quantizer(cinfo);\n      master->quantizer_1pass = cinfo->cquantize;\n#else\n      ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif\n    }\n\n    /* We use the 2-pass code to map to external colormaps. */\n    if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) {\n#ifdef QUANT_2PASS_SUPPORTED\n      jinit_2pass_quantizer(cinfo);\n      master->quantizer_2pass = cinfo->cquantize;\n#else\n      ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif\n    }\n    /* If both quantizers are initialized, the 2-pass one is left active;\n     * this is necessary for starting with quantization to an external map.\n     */\n  }\n\n  /* Post-processing: in particular, color conversion first */\n  if (! cinfo->raw_data_out) {\n    if (master->using_merged_upsample) {\n#ifdef UPSAMPLE_MERGING_SUPPORTED\n      jinit_merged_upsampler(cinfo); /* does color conversion too */\n#else\n      ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif\n    } else {\n      jinit_color_deconverter(cinfo);\n      jinit_upsampler(cinfo);\n    }\n    jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant);\n  }\n  /* Inverse DCT */\n  jinit_inverse_dct(cinfo);\n  /* Entropy decoding: either Huffman or arithmetic coding. */\n  if (cinfo->arith_code) {\n    ERREXIT(cinfo, JERR_ARITH_NOTIMPL);\n  } else {\n    if (cinfo->progressive_mode) {\n#ifdef D_PROGRESSIVE_SUPPORTED\n      jinit_phuff_decoder(cinfo);\n#else\n      ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif\n    } else\n      jinit_huff_decoder(cinfo);\n  }\n\n  /* Initialize principal buffer controllers. */\n  use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image;\n  jinit_d_coef_controller(cinfo, use_c_buffer);\n\n  if (! cinfo->raw_data_out)\n    jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */);\n\n  /* We can now tell the memory manager to allocate virtual arrays. */\n  (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);\n\n  /* Initialize input side of decompressor to consume first scan. */\n  (*cinfo->inputctl->start_input_pass) (cinfo);\n\n#ifdef D_MULTISCAN_FILES_SUPPORTED\n  /* If jpeg_start_decompress will read the whole file, initialize\n   * progress monitoring appropriately.  The input step is counted\n   * as one pass.\n   */\n  if (cinfo->progress != NULL && ! cinfo->buffered_image &&\n      cinfo->inputctl->has_multiple_scans) {\n    int nscans;\n    /* Estimate number of scans to set pass_limit. */\n    if (cinfo->progressive_mode) {\n      /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */\n      nscans = 2 + 3 * cinfo->num_components;\n    } else {\n      /* For a nonprogressive multiscan file, estimate 1 scan per component. */\n      nscans = cinfo->num_components;\n    }\n    cinfo->progress->pass_counter = 0L;\n    cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans;\n    cinfo->progress->completed_passes = 0;\n    cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2);\n    /* Count the input pass as done */\n    master->pass_number++;\n  }\n#endif /* D_MULTISCAN_FILES_SUPPORTED */\n}\n\n\n/*\n * Per-pass setup.\n * This is called at the beginning of each output pass.  We determine which\n * modules will be active during this pass and give them appropriate\n * start_pass calls.  We also set is_dummy_pass to indicate whether this\n * is a \"real\" output pass or a dummy pass for color quantization.\n * (In the latter case, jdapi.c will crank the pass to completion.)\n */\n\nMETHODDEF void\nprepare_for_output_pass (j_decompress_ptr cinfo)\n{\n  my_master_ptr master = (my_master_ptr) cinfo->master;\n\n  if (master->pub.is_dummy_pass) {\n#ifdef QUANT_2PASS_SUPPORTED\n    /* Final pass of 2-pass quantization */\n    master->pub.is_dummy_pass = FALSE;\n    (*cinfo->cquantize->start_pass) (cinfo, FALSE);\n    (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST);\n    (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST);\n#else\n    ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif /* QUANT_2PASS_SUPPORTED */\n  } else {\n    if (cinfo->quantize_colors && cinfo->colormap == NULL) {\n      /* Select new quantization method */\n      if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) {\n\tcinfo->cquantize = master->quantizer_2pass;\n\tmaster->pub.is_dummy_pass = TRUE;\n      } else if (cinfo->enable_1pass_quant) {\n\tcinfo->cquantize = master->quantizer_1pass;\n      } else {\n\tERREXIT(cinfo, JERR_MODE_CHANGE);\n      }\n    }\n    (*cinfo->idct->start_pass) (cinfo);\n    (*cinfo->coef->start_output_pass) (cinfo);\n    if (! cinfo->raw_data_out) {\n      if (! master->using_merged_upsample)\n\t(*cinfo->cconvert->start_pass) (cinfo);\n      (*cinfo->upsample->start_pass) (cinfo);\n      if (cinfo->quantize_colors)\n\t(*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass);\n      (*cinfo->post->start_pass) (cinfo,\n\t    (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));\n      (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);\n    }\n  }\n\n  /* Set up progress monitor's pass info if present */\n  if (cinfo->progress != NULL) {\n    cinfo->progress->completed_passes = master->pass_number;\n    cinfo->progress->total_passes = master->pass_number +\n\t\t\t\t    (master->pub.is_dummy_pass ? 2 : 1);\n    /* In buffered-image mode, we assume one more output pass if EOI not\n     * yet reached, but no more passes if EOI has been reached.\n     */\n    if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) {\n      cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1);\n    }\n  }\n}\n\n\n/*\n * Finish up at end of an output pass.\n */\n\nMETHODDEF void\nfinish_output_pass (j_decompress_ptr cinfo)\n{\n  my_master_ptr master = (my_master_ptr) cinfo->master;\n\n  if (cinfo->quantize_colors)\n    (*cinfo->cquantize->finish_pass) (cinfo);\n  master->pass_number++;\n}\n\n\n#ifdef D_MULTISCAN_FILES_SUPPORTED\n\n/*\n * Switch to a new external colormap between output passes.\n */\n\nGLOBAL void\njpeg_new_colormap (j_decompress_ptr cinfo)\n{\n  my_master_ptr master = (my_master_ptr) cinfo->master;\n\n  /* Prevent application from calling me at wrong times */\n  if (cinfo->global_state != DSTATE_BUFIMAGE)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n\n  if (cinfo->quantize_colors && cinfo->enable_external_quant &&\n      cinfo->colormap != NULL) {\n    /* Select 2-pass quantizer for external colormap use */\n    cinfo->cquantize = master->quantizer_2pass;\n    /* Notify quantizer of colormap change */\n    (*cinfo->cquantize->new_color_map) (cinfo);\n    master->pub.is_dummy_pass = FALSE; /* just in case */\n  } else\n    ERREXIT(cinfo, JERR_MODE_CHANGE);\n}\n\n#endif /* D_MULTISCAN_FILES_SUPPORTED */\n\n\n/*\n * Initialize master decompression control and select active modules.\n * This is performed at the start of jpeg_start_decompress.\n */\n\nGLOBAL void\njinit_master_decompress (j_decompress_ptr cinfo)\n{\n  my_master_ptr master;\n\n  master = (my_master_ptr)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t  SIZEOF(my_decomp_master));\n  cinfo->master = (struct jpeg_decomp_master *) master;\n  master->pub.prepare_for_output_pass = prepare_for_output_pass;\n  master->pub.finish_output_pass = finish_output_pass;\n\n  master->pub.is_dummy_pass = FALSE;\n\n  master_selection(cinfo);\n}\n"
  },
  {
    "path": "code/jpeg-6/jdmerge.c",
    "content": "/*\n * jdmerge.c\n *\n * Copyright (C) 1994-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains code for merged upsampling/color conversion.\n *\n * This file combines functions from jdsample.c and jdcolor.c;\n * read those files first to understand what's going on.\n *\n * When the chroma components are to be upsampled by simple replication\n * (ie, box filtering), we can save some work in color conversion by\n * calculating all the output pixels corresponding to a pair of chroma\n * samples at one time.  In the conversion equations\n *\tR = Y           + K1 * Cr\n *\tG = Y + K2 * Cb + K3 * Cr\n *\tB = Y + K4 * Cb\n * only the Y term varies among the group of pixels corresponding to a pair\n * of chroma samples, so the rest of the terms can be calculated just once.\n * At typical sampling ratios, this eliminates half or three-quarters of the\n * multiplications needed for color conversion.\n *\n * This file currently provides implementations for the following cases:\n *\tYCbCr => RGB color conversion only.\n *\tSampling ratios of 2h1v or 2h2v.\n *\tNo scaling needed at upsample time.\n *\tCorner-aligned (non-CCIR601) sampling alignment.\n * Other special cases could be added, but in most applications these are\n * the only common cases.  (For uncommon cases we fall back on the more\n * general code in jdsample.c and jdcolor.c.)\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n#ifdef UPSAMPLE_MERGING_SUPPORTED\n\n\n/* Private subobject */\n\ntypedef struct {\n  struct jpeg_upsampler pub;\t/* public fields */\n\n  /* Pointer to routine to do actual upsampling/conversion of one row group */\n  JMETHOD(void, upmethod, (j_decompress_ptr cinfo,\n\t\t\t   JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,\n\t\t\t   JSAMPARRAY output_buf));\n\n  /* Private state for YCC->RGB conversion */\n  int * Cr_r_tab;\t\t/* => table for Cr to R conversion */\n  int * Cb_b_tab;\t\t/* => table for Cb to B conversion */\n  INT32 * Cr_g_tab;\t\t/* => table for Cr to G conversion */\n  INT32 * Cb_g_tab;\t\t/* => table for Cb to G conversion */\n\n  /* For 2:1 vertical sampling, we produce two output rows at a time.\n   * We need a \"spare\" row buffer to hold the second output row if the\n   * application provides just a one-row buffer; we also use the spare\n   * to discard the dummy last row if the image height is odd.\n   */\n  JSAMPROW spare_row;\n  boolean spare_full;\t\t/* T if spare buffer is occupied */\n\n  JDIMENSION out_row_width;\t/* samples per output row */\n  JDIMENSION rows_to_go;\t/* counts rows remaining in image */\n} my_upsampler;\n\ntypedef my_upsampler * my_upsample_ptr;\n\n#define SCALEBITS\t16\t/* speediest right-shift on some machines */\n#define ONE_HALF\t((INT32) 1 << (SCALEBITS-1))\n#define FIX(x)\t\t((INT32) ((x) * (1L<<SCALEBITS) + 0.5))\n\n\n/*\n * Initialize tables for YCC->RGB colorspace conversion.\n * This is taken directly from jdcolor.c; see that file for more info.\n */\n\nLOCAL void\nbuild_ycc_rgb_table (j_decompress_ptr cinfo)\n{\n  my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;\n  int i;\n  INT32 x;\n  SHIFT_TEMPS\n\n  upsample->Cr_r_tab = (int *)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t(MAXJSAMPLE+1) * SIZEOF(int));\n  upsample->Cb_b_tab = (int *)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t(MAXJSAMPLE+1) * SIZEOF(int));\n  upsample->Cr_g_tab = (INT32 *)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t(MAXJSAMPLE+1) * SIZEOF(INT32));\n  upsample->Cb_g_tab = (INT32 *)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t(MAXJSAMPLE+1) * SIZEOF(INT32));\n\n  for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {\n    /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */\n    /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */\n    /* Cr=>R value is nearest int to 1.40200 * x */\n    upsample->Cr_r_tab[i] = (int)\n\t\t    RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS);\n    /* Cb=>B value is nearest int to 1.77200 * x */\n    upsample->Cb_b_tab[i] = (int)\n\t\t    RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS);\n    /* Cr=>G value is scaled-up -0.71414 * x */\n    upsample->Cr_g_tab[i] = (- FIX(0.71414)) * x;\n    /* Cb=>G value is scaled-up -0.34414 * x */\n    /* We also add in ONE_HALF so that need not do it in inner loop */\n    upsample->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF;\n  }\n}\n\n\n/*\n * Initialize for an upsampling pass.\n */\n\nMETHODDEF void\nstart_pass_merged_upsample (j_decompress_ptr cinfo)\n{\n  my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;\n\n  /* Mark the spare buffer empty */\n  upsample->spare_full = FALSE;\n  /* Initialize total-height counter for detecting bottom of image */\n  upsample->rows_to_go = cinfo->output_height;\n}\n\n\n/*\n * Control routine to do upsampling (and color conversion).\n *\n * The control routine just handles the row buffering considerations.\n */\n\nMETHODDEF void\nmerged_2v_upsample (j_decompress_ptr cinfo,\n\t\t    JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,\n\t\t    JDIMENSION in_row_groups_avail,\n\t\t    JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t\t    JDIMENSION out_rows_avail)\n/* 2:1 vertical sampling case: may need a spare row. */\n{\n  my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;\n  JSAMPROW work_ptrs[2];\n  JDIMENSION num_rows;\t\t/* number of rows returned to caller */\n\n  if (upsample->spare_full) {\n    /* If we have a spare row saved from a previous cycle, just return it. */\n    jcopy_sample_rows(& upsample->spare_row, 0, output_buf + *out_row_ctr, 0,\n\t\t      1, upsample->out_row_width);\n    num_rows = 1;\n    upsample->spare_full = FALSE;\n  } else {\n    /* Figure number of rows to return to caller. */\n    num_rows = 2;\n    /* Not more than the distance to the end of the image. */\n    if (num_rows > upsample->rows_to_go)\n      num_rows = upsample->rows_to_go;\n    /* And not more than what the client can accept: */\n    out_rows_avail -= *out_row_ctr;\n    if (num_rows > out_rows_avail)\n      num_rows = out_rows_avail;\n    /* Create output pointer array for upsampler. */\n    work_ptrs[0] = output_buf[*out_row_ctr];\n    if (num_rows > 1) {\n      work_ptrs[1] = output_buf[*out_row_ctr + 1];\n    } else {\n      work_ptrs[1] = upsample->spare_row;\n      upsample->spare_full = TRUE;\n    }\n    /* Now do the upsampling. */\n    (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, work_ptrs);\n  }\n\n  /* Adjust counts */\n  *out_row_ctr += num_rows;\n  upsample->rows_to_go -= num_rows;\n  /* When the buffer is emptied, declare this input row group consumed */\n  if (! upsample->spare_full)\n    (*in_row_group_ctr)++;\n}\n\n\nMETHODDEF void\nmerged_1v_upsample (j_decompress_ptr cinfo,\n\t\t    JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,\n\t\t    JDIMENSION in_row_groups_avail,\n\t\t    JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t\t    JDIMENSION out_rows_avail)\n/* 1:1 vertical sampling case: much easier, never need a spare row. */\n{\n  my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;\n\n  /* Just do the upsampling. */\n  (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr,\n\t\t\t output_buf + *out_row_ctr);\n  /* Adjust counts */\n  (*out_row_ctr)++;\n  (*in_row_group_ctr)++;\n}\n\n\n/*\n * These are the routines invoked by the control routines to do\n * the actual upsampling/conversion.  One row group is processed per call.\n *\n * Note: since we may be writing directly into application-supplied buffers,\n * we have to be honest about the output width; we can't assume the buffer\n * has been rounded up to an even width.\n */\n\n\n/*\n * Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical.\n */\n\nMETHODDEF void\nh2v1_merged_upsample (j_decompress_ptr cinfo,\n\t\t      JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,\n\t\t      JSAMPARRAY output_buf)\n{\n  my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;\n  register int y, cred, cgreen, cblue;\n  int cb, cr;\n  register JSAMPROW outptr;\n  JSAMPROW inptr0, inptr1, inptr2;\n  JDIMENSION col;\n  /* copy these pointers into registers if possible */\n  register JSAMPLE * range_limit = cinfo->sample_range_limit;\n  int * Crrtab = upsample->Cr_r_tab;\n  int * Cbbtab = upsample->Cb_b_tab;\n  INT32 * Crgtab = upsample->Cr_g_tab;\n  INT32 * Cbgtab = upsample->Cb_g_tab;\n  SHIFT_TEMPS\n\n  inptr0 = input_buf[0][in_row_group_ctr];\n  inptr1 = input_buf[1][in_row_group_ctr];\n  inptr2 = input_buf[2][in_row_group_ctr];\n  outptr = output_buf[0];\n  /* Loop for each pair of output pixels */\n  for (col = cinfo->output_width >> 1; col > 0; col--) {\n    /* Do the chroma part of the calculation */\n    cb = GETJSAMPLE(*inptr1++);\n    cr = GETJSAMPLE(*inptr2++);\n    cred = Crrtab[cr];\n    cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);\n    cblue = Cbbtab[cb];\n    /* Fetch 2 Y values and emit 2 pixels */\n    y  = GETJSAMPLE(*inptr0++);\n    outptr[RGB_RED] =   range_limit[y + cred];\n    outptr[RGB_GREEN] = range_limit[y + cgreen];\n    outptr[RGB_BLUE] =  range_limit[y + cblue];\n    outptr += RGB_PIXELSIZE;\n    y  = GETJSAMPLE(*inptr0++);\n    outptr[RGB_RED] =   range_limit[y + cred];\n    outptr[RGB_GREEN] = range_limit[y + cgreen];\n    outptr[RGB_BLUE] =  range_limit[y + cblue];\n    outptr += RGB_PIXELSIZE;\n  }\n  /* If image width is odd, do the last output column separately */\n  if (cinfo->output_width & 1) {\n    cb = GETJSAMPLE(*inptr1);\n    cr = GETJSAMPLE(*inptr2);\n    cred = Crrtab[cr];\n    cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);\n    cblue = Cbbtab[cb];\n    y  = GETJSAMPLE(*inptr0);\n    outptr[RGB_RED] =   range_limit[y + cred];\n    outptr[RGB_GREEN] = range_limit[y + cgreen];\n    outptr[RGB_BLUE] =  range_limit[y + cblue];\n  }\n}\n\n\n/*\n * Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical.\n */\n\nMETHODDEF void\nh2v2_merged_upsample (j_decompress_ptr cinfo,\n\t\t      JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,\n\t\t      JSAMPARRAY output_buf)\n{\n  my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;\n  register int y, cred, cgreen, cblue;\n  int cb, cr;\n  register JSAMPROW outptr0, outptr1;\n  JSAMPROW inptr00, inptr01, inptr1, inptr2;\n  JDIMENSION col;\n  /* copy these pointers into registers if possible */\n  register JSAMPLE * range_limit = cinfo->sample_range_limit;\n  int * Crrtab = upsample->Cr_r_tab;\n  int * Cbbtab = upsample->Cb_b_tab;\n  INT32 * Crgtab = upsample->Cr_g_tab;\n  INT32 * Cbgtab = upsample->Cb_g_tab;\n  SHIFT_TEMPS\n\n  inptr00 = input_buf[0][in_row_group_ctr*2];\n  inptr01 = input_buf[0][in_row_group_ctr*2 + 1];\n  inptr1 = input_buf[1][in_row_group_ctr];\n  inptr2 = input_buf[2][in_row_group_ctr];\n  outptr0 = output_buf[0];\n  outptr1 = output_buf[1];\n  /* Loop for each group of output pixels */\n  for (col = cinfo->output_width >> 1; col > 0; col--) {\n    /* Do the chroma part of the calculation */\n    cb = GETJSAMPLE(*inptr1++);\n    cr = GETJSAMPLE(*inptr2++);\n    cred = Crrtab[cr];\n    cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);\n    cblue = Cbbtab[cb];\n    /* Fetch 4 Y values and emit 4 pixels */\n    y  = GETJSAMPLE(*inptr00++);\n    outptr0[RGB_RED] =   range_limit[y + cred];\n    outptr0[RGB_GREEN] = range_limit[y + cgreen];\n    outptr0[RGB_BLUE] =  range_limit[y + cblue];\n    outptr0 += RGB_PIXELSIZE;\n    y  = GETJSAMPLE(*inptr00++);\n    outptr0[RGB_RED] =   range_limit[y + cred];\n    outptr0[RGB_GREEN] = range_limit[y + cgreen];\n    outptr0[RGB_BLUE] =  range_limit[y + cblue];\n    outptr0 += RGB_PIXELSIZE;\n    y  = GETJSAMPLE(*inptr01++);\n    outptr1[RGB_RED] =   range_limit[y + cred];\n    outptr1[RGB_GREEN] = range_limit[y + cgreen];\n    outptr1[RGB_BLUE] =  range_limit[y + cblue];\n    outptr1 += RGB_PIXELSIZE;\n    y  = GETJSAMPLE(*inptr01++);\n    outptr1[RGB_RED] =   range_limit[y + cred];\n    outptr1[RGB_GREEN] = range_limit[y + cgreen];\n    outptr1[RGB_BLUE] =  range_limit[y + cblue];\n    outptr1 += RGB_PIXELSIZE;\n  }\n  /* If image width is odd, do the last output column separately */\n  if (cinfo->output_width & 1) {\n    cb = GETJSAMPLE(*inptr1);\n    cr = GETJSAMPLE(*inptr2);\n    cred = Crrtab[cr];\n    cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);\n    cblue = Cbbtab[cb];\n    y  = GETJSAMPLE(*inptr00);\n    outptr0[RGB_RED] =   range_limit[y + cred];\n    outptr0[RGB_GREEN] = range_limit[y + cgreen];\n    outptr0[RGB_BLUE] =  range_limit[y + cblue];\n    y  = GETJSAMPLE(*inptr01);\n    outptr1[RGB_RED] =   range_limit[y + cred];\n    outptr1[RGB_GREEN] = range_limit[y + cgreen];\n    outptr1[RGB_BLUE] =  range_limit[y + cblue];\n  }\n}\n\n\n/*\n * Module initialization routine for merged upsampling/color conversion.\n *\n * NB: this is called under the conditions determined by use_merged_upsample()\n * in jdmaster.c.  That routine MUST correspond to the actual capabilities\n * of this module; no safety checks are made here.\n */\n\nGLOBAL void\njinit_merged_upsampler (j_decompress_ptr cinfo)\n{\n  my_upsample_ptr upsample;\n\n  upsample = (my_upsample_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_upsampler));\n  cinfo->upsample = (struct jpeg_upsampler *) upsample;\n  upsample->pub.start_pass = start_pass_merged_upsample;\n  upsample->pub.need_context_rows = FALSE;\n\n  upsample->out_row_width = cinfo->output_width * cinfo->out_color_components;\n\n  if (cinfo->max_v_samp_factor == 2) {\n    upsample->pub.upsample = merged_2v_upsample;\n    upsample->upmethod = h2v2_merged_upsample;\n    /* Allocate a spare row buffer */\n    upsample->spare_row = (JSAMPROW)\n      (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t(size_t) (upsample->out_row_width * SIZEOF(JSAMPLE)));\n  } else {\n    upsample->pub.upsample = merged_1v_upsample;\n    upsample->upmethod = h2v1_merged_upsample;\n    /* No spare row needed */\n    upsample->spare_row = NULL;\n  }\n\n  build_ycc_rgb_table(cinfo);\n}\n\n#endif /* UPSAMPLE_MERGING_SUPPORTED */\n"
  },
  {
    "path": "code/jpeg-6/jdphuff.c",
    "content": "/*\n * jdphuff.c\n *\n * Copyright (C) 1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains Huffman entropy decoding routines for progressive JPEG.\n *\n * Much of the complexity here has to do with supporting input suspension.\n * If the data source module demands suspension, we want to be able to back\n * up to the start of the current MCU.  To do this, we copy state variables\n * into local working storage, and update them back to the permanent\n * storage only upon successful completion of an MCU.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jdhuff.h\"\t\t/* Declarations shared with jdhuff.c */\n\n\n#ifdef D_PROGRESSIVE_SUPPORTED\n\n/*\n * Expanded entropy decoder object for progressive Huffman decoding.\n *\n * The savable_state subrecord contains fields that change within an MCU,\n * but must not be updated permanently until we complete the MCU.\n */\n\ntypedef struct {\n  unsigned int EOBRUN;\t\t\t/* remaining EOBs in EOBRUN */\n  int last_dc_val[MAX_COMPS_IN_SCAN];\t/* last DC coef for each component */\n} savable_state;\n\n/* This macro is to work around compilers with missing or broken\n * structure assignment.  You'll need to fix this code if you have\n * such a compiler and you change MAX_COMPS_IN_SCAN.\n */\n\n#ifndef NO_STRUCT_ASSIGN\n#define ASSIGN_STATE(dest,src)  ((dest) = (src))\n#else\n#if MAX_COMPS_IN_SCAN == 4\n#define ASSIGN_STATE(dest,src)  \\\n\t((dest).EOBRUN = (src).EOBRUN, \\\n\t (dest).last_dc_val[0] = (src).last_dc_val[0], \\\n\t (dest).last_dc_val[1] = (src).last_dc_val[1], \\\n\t (dest).last_dc_val[2] = (src).last_dc_val[2], \\\n\t (dest).last_dc_val[3] = (src).last_dc_val[3])\n#endif\n#endif\n\n\ntypedef struct {\n  struct jpeg_entropy_decoder pub; /* public fields */\n\n  /* These fields are loaded into local variables at start of each MCU.\n   * In case of suspension, we exit WITHOUT updating them.\n   */\n  bitread_perm_state bitstate;\t/* Bit buffer at start of MCU */\n  savable_state saved;\t\t/* Other state at start of MCU */\n\n  /* These fields are NOT loaded into local working state. */\n  unsigned int restarts_to_go;\t/* MCUs left in this restart interval */\n\n  /* Pointers to derived tables (these workspaces have image lifespan) */\n  d_derived_tbl * derived_tbls[NUM_HUFF_TBLS];\n\n  d_derived_tbl * ac_derived_tbl; /* active table during an AC scan */\n} phuff_entropy_decoder;\n\ntypedef phuff_entropy_decoder * phuff_entropy_ptr;\n\n/* Forward declarations */\nMETHODDEF boolean decode_mcu_DC_first JPP((j_decompress_ptr cinfo,\n\t\t\t\t\t   JBLOCKROW *MCU_data));\nMETHODDEF boolean decode_mcu_AC_first JPP((j_decompress_ptr cinfo,\n\t\t\t\t\t   JBLOCKROW *MCU_data));\nMETHODDEF boolean decode_mcu_DC_refine JPP((j_decompress_ptr cinfo,\n\t\t\t\t\t    JBLOCKROW *MCU_data));\nMETHODDEF boolean decode_mcu_AC_refine JPP((j_decompress_ptr cinfo,\n\t\t\t\t\t    JBLOCKROW *MCU_data));\n\n\n/*\n * Initialize for a Huffman-compressed scan.\n */\n\nMETHODDEF void\nstart_pass_phuff_decoder (j_decompress_ptr cinfo)\n{\n  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;\n  boolean is_DC_band, bad;\n  int ci, coefi, tbl;\n  int *coef_bit_ptr;\n  jpeg_component_info * compptr;\n\n  is_DC_band = (cinfo->Ss == 0);\n\n  /* Validate scan parameters */\n  bad = FALSE;\n  if (is_DC_band) {\n    if (cinfo->Se != 0)\n      bad = TRUE;\n  } else {\n    /* need not check Ss/Se < 0 since they came from unsigned bytes */\n    if (cinfo->Ss > cinfo->Se || cinfo->Se >= DCTSIZE2)\n      bad = TRUE;\n    /* AC scans may have only one component */\n    if (cinfo->comps_in_scan != 1)\n      bad = TRUE;\n  }\n  if (cinfo->Ah != 0) {\n    /* Successive approximation refinement scan: must have Al = Ah-1. */\n    if (cinfo->Al != cinfo->Ah-1)\n      bad = TRUE;\n  }\n  if (cinfo->Al > 13)\t\t/* need not check for < 0 */\n    bad = TRUE;\n  if (bad)\n    ERREXIT4(cinfo, JERR_BAD_PROGRESSION,\n\t     cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al);\n  /* Update progression status, and verify that scan order is legal.\n   * Note that inter-scan inconsistencies are treated as warnings\n   * not fatal errors ... not clear if this is right way to behave.\n   */\n  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n    int cindex = cinfo->cur_comp_info[ci]->component_index;\n    coef_bit_ptr = & cinfo->coef_bits[cindex][0];\n    if (!is_DC_band && coef_bit_ptr[0] < 0) /* AC without prior DC scan */\n      WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0);\n    for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) {\n      int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi];\n      if (cinfo->Ah != expected)\n\tWARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi);\n      coef_bit_ptr[coefi] = cinfo->Al;\n    }\n  }\n\n  /* Select MCU decoding routine */\n  if (cinfo->Ah == 0) {\n    if (is_DC_band)\n      entropy->pub.decode_mcu = decode_mcu_DC_first;\n    else\n      entropy->pub.decode_mcu = decode_mcu_AC_first;\n  } else {\n    if (is_DC_band)\n      entropy->pub.decode_mcu = decode_mcu_DC_refine;\n    else\n      entropy->pub.decode_mcu = decode_mcu_AC_refine;\n  }\n\n  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n    compptr = cinfo->cur_comp_info[ci];\n    /* Make sure requested tables are present, and compute derived tables.\n     * We may build same derived table more than once, but it's not expensive.\n     */\n    if (is_DC_band) {\n      if (cinfo->Ah == 0) {\t/* DC refinement needs no table */\n\ttbl = compptr->dc_tbl_no;\n\tif (tbl < 0 || tbl >= NUM_HUFF_TBLS ||\n\t    cinfo->dc_huff_tbl_ptrs[tbl] == NULL)\n\t  ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl);\n\tjpeg_make_d_derived_tbl(cinfo, cinfo->dc_huff_tbl_ptrs[tbl],\n\t\t\t\t& entropy->derived_tbls[tbl]);\n      }\n    } else {\n      tbl = compptr->ac_tbl_no;\n      if (tbl < 0 || tbl >= NUM_HUFF_TBLS ||\n          cinfo->ac_huff_tbl_ptrs[tbl] == NULL)\n        ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl);\n      jpeg_make_d_derived_tbl(cinfo, cinfo->ac_huff_tbl_ptrs[tbl],\n\t\t\t      & entropy->derived_tbls[tbl]);\n      /* remember the single active table */\n      entropy->ac_derived_tbl = entropy->derived_tbls[tbl];\n    }\n    /* Initialize DC predictions to 0 */\n    entropy->saved.last_dc_val[ci] = 0;\n  }\n\n  /* Initialize bitread state variables */\n  entropy->bitstate.bits_left = 0;\n  entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */\n  entropy->bitstate.printed_eod = FALSE;\n\n  /* Initialize private state variables */\n  entropy->saved.EOBRUN = 0;\n\n  /* Initialize restart counter */\n  entropy->restarts_to_go = cinfo->restart_interval;\n}\n\n\n/*\n * Figure F.12: extend sign bit.\n * On some machines, a shift and add will be faster than a table lookup.\n */\n\n#ifdef AVOID_TABLES\n\n#define HUFF_EXTEND(x,s)  ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x))\n\n#else\n\n#define HUFF_EXTEND(x,s)  ((x) < extend_test[s] ? (x) + extend_offset[s] : (x))\n\nstatic const int extend_test[16] =   /* entry n is 2**(n-1) */\n  { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,\n    0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 };\n\nstatic const int extend_offset[16] = /* entry n is (-1 << n) + 1 */\n  { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1,\n    ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1,\n    ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1,\n    ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 };\n\n#endif /* AVOID_TABLES */\n\n\n/*\n * Check for a restart marker & resynchronize decoder.\n * Returns FALSE if must suspend.\n */\n\nLOCAL boolean\nprocess_restart (j_decompress_ptr cinfo)\n{\n  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;\n  int ci;\n\n  /* Throw away any unused bits remaining in bit buffer; */\n  /* include any full bytes in next_marker's count of discarded bytes */\n  cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8;\n  entropy->bitstate.bits_left = 0;\n\n  /* Advance past the RSTn marker */\n  if (! (*cinfo->marker->read_restart_marker) (cinfo))\n    return FALSE;\n\n  /* Re-initialize DC predictions to 0 */\n  for (ci = 0; ci < cinfo->comps_in_scan; ci++)\n    entropy->saved.last_dc_val[ci] = 0;\n  /* Re-init EOB run count, too */\n  entropy->saved.EOBRUN = 0;\n\n  /* Reset restart counter */\n  entropy->restarts_to_go = cinfo->restart_interval;\n\n  /* Next segment can get another out-of-data warning */\n  entropy->bitstate.printed_eod = FALSE;\n\n  return TRUE;\n}\n\n\n/*\n * Huffman MCU decoding.\n * Each of these routines decodes and returns one MCU's worth of\n * Huffman-compressed coefficients. \n * The coefficients are reordered from zigzag order into natural array order,\n * but are not dequantized.\n *\n * The i'th block of the MCU is stored into the block pointed to by\n * MCU_data[i].  WE ASSUME THIS AREA IS INITIALLY ZEROED BY THE CALLER.\n *\n * We return FALSE if data source requested suspension.  In that case no\n * changes have been made to permanent state.  (Exception: some output\n * coefficients may already have been assigned.  This is harmless for\n * spectral selection, since we'll just re-assign them on the next call.\n * Successive approximation AC refinement has to be more careful, however.)\n */\n\n/*\n * MCU decoding for DC initial scan (either spectral selection,\n * or first pass of successive approximation).\n */\n\nMETHODDEF boolean\ndecode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)\n{   \n  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;\n  int Al = cinfo->Al;\n  register int s, r;\n  int blkn, ci;\n  JBLOCKROW block;\n  BITREAD_STATE_VARS;\n  savable_state state;\n  d_derived_tbl * tbl;\n  jpeg_component_info * compptr;\n\n  /* Process restart marker if needed; may have to suspend */\n  if (cinfo->restart_interval) {\n    if (entropy->restarts_to_go == 0)\n      if (! process_restart(cinfo))\n\treturn FALSE;\n  }\n\n  /* Load up working state */\n  BITREAD_LOAD_STATE(cinfo,entropy->bitstate);\n  ASSIGN_STATE(state, entropy->saved);\n\n  /* Outer loop handles each block in the MCU */\n\n  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {\n    block = MCU_data[blkn];\n    ci = cinfo->MCU_membership[blkn];\n    compptr = cinfo->cur_comp_info[ci];\n    tbl = entropy->derived_tbls[compptr->dc_tbl_no];\n\n    /* Decode a single block's worth of coefficients */\n\n    /* Section F.2.2.1: decode the DC coefficient difference */\n    HUFF_DECODE(s, br_state, tbl, return FALSE, label1);\n    if (s) {\n      CHECK_BIT_BUFFER(br_state, s, return FALSE);\n      r = GET_BITS(s);\n      s = HUFF_EXTEND(r, s);\n    }\n\n    /* Convert DC difference to actual value, update last_dc_val */\n    s += state.last_dc_val[ci];\n    state.last_dc_val[ci] = s;\n    /* Scale and output the DC coefficient (assumes jpeg_natural_order[0]=0) */\n    (*block)[0] = (JCOEF) (s << Al);\n  }\n\n  /* Completed MCU, so update state */\n  BITREAD_SAVE_STATE(cinfo,entropy->bitstate);\n  ASSIGN_STATE(entropy->saved, state);\n\n  /* Account for restart interval (no-op if not using restarts) */\n  entropy->restarts_to_go--;\n\n  return TRUE;\n}\n\n\n/*\n * MCU decoding for AC initial scan (either spectral selection,\n * or first pass of successive approximation).\n */\n\nMETHODDEF boolean\ndecode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)\n{   \n  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;\n  int Se = cinfo->Se;\n  int Al = cinfo->Al;\n  register int s, k, r;\n  unsigned int EOBRUN;\n  JBLOCKROW block;\n  BITREAD_STATE_VARS;\n  d_derived_tbl * tbl;\n\n  /* Process restart marker if needed; may have to suspend */\n  if (cinfo->restart_interval) {\n    if (entropy->restarts_to_go == 0)\n      if (! process_restart(cinfo))\n\treturn FALSE;\n  }\n\n  /* Load up working state.\n   * We can avoid loading/saving bitread state if in an EOB run.\n   */\n  EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we care about */\n\n  /* There is always only one block per MCU */\n\n  if (EOBRUN > 0)\t\t/* if it's a band of zeroes... */\n    EOBRUN--;\t\t\t/* ...process it now (we do nothing) */\n  else {\n    BITREAD_LOAD_STATE(cinfo,entropy->bitstate);\n    block = MCU_data[0];\n    tbl = entropy->ac_derived_tbl;\n\n    for (k = cinfo->Ss; k <= Se; k++) {\n      HUFF_DECODE(s, br_state, tbl, return FALSE, label2);\n      r = s >> 4;\n      s &= 15;\n      if (s) {\n        k += r;\n        CHECK_BIT_BUFFER(br_state, s, return FALSE);\n        r = GET_BITS(s);\n        s = HUFF_EXTEND(r, s);\n\t/* Scale and output coefficient in natural (dezigzagged) order */\n        (*block)[jpeg_natural_order[k]] = (JCOEF) (s << Al);\n      } else {\n        if (r == 15) {\t\t/* ZRL */\n          k += 15;\t\t/* skip 15 zeroes in band */\n        } else {\t\t/* EOBr, run length is 2^r + appended bits */\n          EOBRUN = 1 << r;\n          if (r) {\t\t/* EOBr, r > 0 */\n\t    CHECK_BIT_BUFFER(br_state, r, return FALSE);\n            r = GET_BITS(r);\n            EOBRUN += r;\n          }\n\t  EOBRUN--;\t\t/* this band is processed at this moment */\n\t  break;\t\t/* force end-of-band */\n\t}\n      }\n    }\n\n    BITREAD_SAVE_STATE(cinfo,entropy->bitstate);\n  }\n\n  /* Completed MCU, so update state */\n  entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we care about */\n\n  /* Account for restart interval (no-op if not using restarts) */\n  entropy->restarts_to_go--;\n\n  return TRUE;\n}\n\n\n/*\n * MCU decoding for DC successive approximation refinement scan.\n * Note: we assume such scans can be multi-component, although the spec\n * is not very clear on the point.\n */\n\nMETHODDEF boolean\ndecode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)\n{   \n  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;\n  int p1 = 1 << cinfo->Al;\t/* 1 in the bit position being coded */\n  int blkn;\n  JBLOCKROW block;\n  BITREAD_STATE_VARS;\n\n  /* Process restart marker if needed; may have to suspend */\n  if (cinfo->restart_interval) {\n    if (entropy->restarts_to_go == 0)\n      if (! process_restart(cinfo))\n\treturn FALSE;\n  }\n\n  /* Load up working state */\n  BITREAD_LOAD_STATE(cinfo,entropy->bitstate);\n\n  /* Outer loop handles each block in the MCU */\n\n  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {\n    block = MCU_data[blkn];\n\n    /* Encoded data is simply the next bit of the two's-complement DC value */\n    CHECK_BIT_BUFFER(br_state, 1, return FALSE);\n    if (GET_BITS(1))\n      (*block)[0] |= p1;\n    /* Note: since we use |=, repeating the assignment later is safe */\n  }\n\n  /* Completed MCU, so update state */\n  BITREAD_SAVE_STATE(cinfo,entropy->bitstate);\n\n  /* Account for restart interval (no-op if not using restarts) */\n  entropy->restarts_to_go--;\n\n  return TRUE;\n}\n\n\n/*\n * MCU decoding for AC successive approximation refinement scan.\n */\n\nMETHODDEF boolean\ndecode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)\n{   \n  phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;\n  int Se = cinfo->Se;\n  int p1 = 1 << cinfo->Al;\t/* 1 in the bit position being coded */\n  int m1 = (-1) << cinfo->Al;\t/* -1 in the bit position being coded */\n  register int s, k, r;\n  unsigned int EOBRUN;\n  JBLOCKROW block;\n  JCOEFPTR thiscoef;\n  BITREAD_STATE_VARS;\n  d_derived_tbl * tbl;\n  int num_newnz;\n  int newnz_pos[DCTSIZE2];\n\n  /* Process restart marker if needed; may have to suspend */\n  if (cinfo->restart_interval) {\n    if (entropy->restarts_to_go == 0)\n      if (! process_restart(cinfo))\n\treturn FALSE;\n  }\n\n  /* Load up working state */\n  BITREAD_LOAD_STATE(cinfo,entropy->bitstate);\n  EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we care about */\n\n  /* There is always only one block per MCU */\n  block = MCU_data[0];\n  tbl = entropy->ac_derived_tbl;\n\n  /* If we are forced to suspend, we must undo the assignments to any newly\n   * nonzero coefficients in the block, because otherwise we'd get confused\n   * next time about which coefficients were already nonzero.\n   * But we need not undo addition of bits to already-nonzero coefficients;\n   * instead, we can test the current bit position to see if we already did it.\n   */\n  num_newnz = 0;\n\n  /* initialize coefficient loop counter to start of band */\n  k = cinfo->Ss;\n\n  if (EOBRUN == 0) {\n    for (; k <= Se; k++) {\n      HUFF_DECODE(s, br_state, tbl, goto undoit, label3);\n      r = s >> 4;\n      s &= 15;\n      if (s) {\n\tif (s != 1)\t\t/* size of new coef should always be 1 */\n\t  WARNMS(cinfo, JWRN_HUFF_BAD_CODE);\n        CHECK_BIT_BUFFER(br_state, 1, goto undoit);\n        if (GET_BITS(1))\n\t  s = p1;\t\t/* newly nonzero coef is positive */\n\telse\n\t  s = m1;\t\t/* newly nonzero coef is negative */\n      } else {\n\tif (r != 15) {\n\t  EOBRUN = 1 << r;\t/* EOBr, run length is 2^r + appended bits */\n\t  if (r) {\n\t    CHECK_BIT_BUFFER(br_state, r, goto undoit);\n\t    r = GET_BITS(r);\n\t    EOBRUN += r;\n\t  }\n\t  break;\t\t/* rest of block is handled by EOB logic */\n\t}\n\t/* note s = 0 for processing ZRL */\n      }\n      /* Advance over already-nonzero coefs and r still-zero coefs,\n       * appending correction bits to the nonzeroes.  A correction bit is 1\n       * if the absolute value of the coefficient must be increased.\n       */\n      do {\n\tthiscoef = *block + jpeg_natural_order[k];\n\tif (*thiscoef != 0) {\n\t  CHECK_BIT_BUFFER(br_state, 1, goto undoit);\n\t  if (GET_BITS(1)) {\n\t    if ((*thiscoef & p1) == 0) { /* do nothing if already changed it */\n\t      if (*thiscoef >= 0)\n\t\t*thiscoef += p1;\n\t      else\n\t\t*thiscoef += m1;\n\t    }\n\t  }\n\t} else {\n\t  if (--r < 0)\n\t    break;\t\t/* reached target zero coefficient */\n\t}\n\tk++;\n      } while (k <= Se);\n      if (s) {\n\tint pos = jpeg_natural_order[k];\n\t/* Output newly nonzero coefficient */\n\t(*block)[pos] = (JCOEF) s;\n\t/* Remember its position in case we have to suspend */\n\tnewnz_pos[num_newnz++] = pos;\n      }\n    }\n  }\n\n  if (EOBRUN > 0) {\n    /* Scan any remaining coefficient positions after the end-of-band\n     * (the last newly nonzero coefficient, if any).  Append a correction\n     * bit to each already-nonzero coefficient.  A correction bit is 1\n     * if the absolute value of the coefficient must be increased.\n     */\n    for (; k <= Se; k++) {\n      thiscoef = *block + jpeg_natural_order[k];\n      if (*thiscoef != 0) {\n\tCHECK_BIT_BUFFER(br_state, 1, goto undoit);\n\tif (GET_BITS(1)) {\n\t  if ((*thiscoef & p1) == 0) { /* do nothing if already changed it */\n\t    if (*thiscoef >= 0)\n\t      *thiscoef += p1;\n\t    else\n\t      *thiscoef += m1;\n\t  }\n\t}\n      }\n    }\n    /* Count one block completed in EOB run */\n    EOBRUN--;\n  }\n\n  /* Completed MCU, so update state */\n  BITREAD_SAVE_STATE(cinfo,entropy->bitstate);\n  entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we care about */\n\n  /* Account for restart interval (no-op if not using restarts) */\n  entropy->restarts_to_go--;\n\n  return TRUE;\n\nundoit:\n  /* Re-zero any output coefficients that we made newly nonzero */\n  while (num_newnz > 0)\n    (*block)[newnz_pos[--num_newnz]] = 0;\n\n  return FALSE;\n}\n\n\n/*\n * Module initialization routine for progressive Huffman entropy decoding.\n */\n\nGLOBAL void\njinit_phuff_decoder (j_decompress_ptr cinfo)\n{\n  phuff_entropy_ptr entropy;\n  int *coef_bit_ptr;\n  int ci, i;\n\n  entropy = (phuff_entropy_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(phuff_entropy_decoder));\n  cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;\n  entropy->pub.start_pass = start_pass_phuff_decoder;\n\n  /* Mark derived tables unallocated */\n  for (i = 0; i < NUM_HUFF_TBLS; i++) {\n    entropy->derived_tbls[i] = NULL;\n  }\n\n  /* Create progression status table */\n  cinfo->coef_bits = (int (*)[DCTSIZE2])\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tcinfo->num_components*DCTSIZE2*SIZEOF(int));\n  coef_bit_ptr = & cinfo->coef_bits[0][0];\n  for (ci = 0; ci < cinfo->num_components; ci++) \n    for (i = 0; i < DCTSIZE2; i++)\n      *coef_bit_ptr++ = -1;\n}\n\n#endif /* D_PROGRESSIVE_SUPPORTED */\n"
  },
  {
    "path": "code/jpeg-6/jdpostct.c",
    "content": "/*\n * jdpostct.c\n *\n * Copyright (C) 1994-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains the decompression postprocessing controller.\n * This controller manages the upsampling, color conversion, and color\n * quantization/reduction steps; specifically, it controls the buffering\n * between upsample/color conversion and color quantization/reduction.\n *\n * If no color quantization/reduction is required, then this module has no\n * work to do, and it just hands off to the upsample/color conversion code.\n * An integrated upsample/convert/quantize process would replace this module\n * entirely.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/* Private buffer controller object */\n\ntypedef struct {\n  struct jpeg_d_post_controller pub; /* public fields */\n\n  /* Color quantization source buffer: this holds output data from\n   * the upsample/color conversion step to be passed to the quantizer.\n   * For two-pass color quantization, we need a full-image buffer;\n   * for one-pass operation, a strip buffer is sufficient.\n   */\n  jvirt_sarray_ptr whole_image;\t/* virtual array, or NULL if one-pass */\n  JSAMPARRAY buffer;\t\t/* strip buffer, or current strip of virtual */\n  JDIMENSION strip_height;\t/* buffer size in rows */\n  /* for two-pass mode only: */\n  JDIMENSION starting_row;\t/* row # of first row in current strip */\n  JDIMENSION next_row;\t\t/* index of next row to fill/empty in strip */\n} my_post_controller;\n\ntypedef my_post_controller * my_post_ptr;\n\n\n/* Forward declarations */\nMETHODDEF void post_process_1pass\n\tJPP((j_decompress_ptr cinfo,\n\t     JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,\n\t     JDIMENSION in_row_groups_avail,\n\t     JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t     JDIMENSION out_rows_avail));\n#ifdef QUANT_2PASS_SUPPORTED\nMETHODDEF void post_process_prepass\n\tJPP((j_decompress_ptr cinfo,\n\t     JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,\n\t     JDIMENSION in_row_groups_avail,\n\t     JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t     JDIMENSION out_rows_avail));\nMETHODDEF void post_process_2pass\n\tJPP((j_decompress_ptr cinfo,\n\t     JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,\n\t     JDIMENSION in_row_groups_avail,\n\t     JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t     JDIMENSION out_rows_avail));\n#endif\n\n\n/*\n * Initialize for a processing pass.\n */\n\nMETHODDEF void\nstart_pass_dpost (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)\n{\n  my_post_ptr post = (my_post_ptr) cinfo->post;\n\n  switch (pass_mode) {\n  case JBUF_PASS_THRU:\n    if (cinfo->quantize_colors) {\n      /* Single-pass processing with color quantization. */\n      post->pub.post_process_data = post_process_1pass;\n      /* We could be doing buffered-image output before starting a 2-pass\n       * color quantization; in that case, jinit_d_post_controller did not\n       * allocate a strip buffer.  Use the virtual-array buffer as workspace.\n       */\n      if (post->buffer == NULL) {\n\tpost->buffer = (*cinfo->mem->access_virt_sarray)\n\t  ((j_common_ptr) cinfo, post->whole_image,\n\t   (JDIMENSION) 0, post->strip_height, TRUE);\n      }\n    } else {\n      /* For single-pass processing without color quantization,\n       * I have no work to do; just call the upsampler directly.\n       */\n      post->pub.post_process_data = cinfo->upsample->upsample;\n    }\n    break;\n#ifdef QUANT_2PASS_SUPPORTED\n  case JBUF_SAVE_AND_PASS:\n    /* First pass of 2-pass quantization */\n    if (post->whole_image == NULL)\n      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n    post->pub.post_process_data = post_process_prepass;\n    break;\n  case JBUF_CRANK_DEST:\n    /* Second pass of 2-pass quantization */\n    if (post->whole_image == NULL)\n      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n    post->pub.post_process_data = post_process_2pass;\n    break;\n#endif /* QUANT_2PASS_SUPPORTED */\n  default:\n    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n    break;\n  }\n  post->starting_row = post->next_row = 0;\n}\n\n\n/*\n * Process some data in the one-pass (strip buffer) case.\n * This is used for color precision reduction as well as one-pass quantization.\n */\n\nMETHODDEF void\npost_process_1pass (j_decompress_ptr cinfo,\n\t\t    JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,\n\t\t    JDIMENSION in_row_groups_avail,\n\t\t    JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t\t    JDIMENSION out_rows_avail)\n{\n  my_post_ptr post = (my_post_ptr) cinfo->post;\n  JDIMENSION num_rows, max_rows;\n\n  /* Fill the buffer, but not more than what we can dump out in one go. */\n  /* Note we rely on the upsampler to detect bottom of image. */\n  max_rows = out_rows_avail - *out_row_ctr;\n  if (max_rows > post->strip_height)\n    max_rows = post->strip_height;\n  num_rows = 0;\n  (*cinfo->upsample->upsample) (cinfo,\n\t\tinput_buf, in_row_group_ctr, in_row_groups_avail,\n\t\tpost->buffer, &num_rows, max_rows);\n  /* Quantize and emit data. */\n  (*cinfo->cquantize->color_quantize) (cinfo,\n\t\tpost->buffer, output_buf + *out_row_ctr, (int) num_rows);\n  *out_row_ctr += num_rows;\n}\n\n\n#ifdef QUANT_2PASS_SUPPORTED\n\n/*\n * Process some data in the first pass of 2-pass quantization.\n */\n\nMETHODDEF void\npost_process_prepass (j_decompress_ptr cinfo,\n\t\t      JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,\n\t\t      JDIMENSION in_row_groups_avail,\n\t\t      JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t\t      JDIMENSION out_rows_avail)\n{\n  my_post_ptr post = (my_post_ptr) cinfo->post;\n  JDIMENSION old_next_row, num_rows;\n\n  /* Reposition virtual buffer if at start of strip. */\n  if (post->next_row == 0) {\n    post->buffer = (*cinfo->mem->access_virt_sarray)\n\t((j_common_ptr) cinfo, post->whole_image,\n\t post->starting_row, post->strip_height, TRUE);\n  }\n\n  /* Upsample some data (up to a strip height's worth). */\n  old_next_row = post->next_row;\n  (*cinfo->upsample->upsample) (cinfo,\n\t\tinput_buf, in_row_group_ctr, in_row_groups_avail,\n\t\tpost->buffer, &post->next_row, post->strip_height);\n\n  /* Allow quantizer to scan new data.  No data is emitted, */\n  /* but we advance out_row_ctr so outer loop can tell when we're done. */\n  if (post->next_row > old_next_row) {\n    num_rows = post->next_row - old_next_row;\n    (*cinfo->cquantize->color_quantize) (cinfo, post->buffer + old_next_row,\n\t\t\t\t\t (JSAMPARRAY) NULL, (int) num_rows);\n    *out_row_ctr += num_rows;\n  }\n\n  /* Advance if we filled the strip. */\n  if (post->next_row >= post->strip_height) {\n    post->starting_row += post->strip_height;\n    post->next_row = 0;\n  }\n}\n\n\n/*\n * Process some data in the second pass of 2-pass quantization.\n */\n\nMETHODDEF void\npost_process_2pass (j_decompress_ptr cinfo,\n\t\t    JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,\n\t\t    JDIMENSION in_row_groups_avail,\n\t\t    JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t\t    JDIMENSION out_rows_avail)\n{\n  my_post_ptr post = (my_post_ptr) cinfo->post;\n  JDIMENSION num_rows, max_rows;\n\n  /* Reposition virtual buffer if at start of strip. */\n  if (post->next_row == 0) {\n    post->buffer = (*cinfo->mem->access_virt_sarray)\n\t((j_common_ptr) cinfo, post->whole_image,\n\t post->starting_row, post->strip_height, FALSE);\n  }\n\n  /* Determine number of rows to emit. */\n  num_rows = post->strip_height - post->next_row; /* available in strip */\n  max_rows = out_rows_avail - *out_row_ctr; /* available in output area */\n  if (num_rows > max_rows)\n    num_rows = max_rows;\n  /* We have to check bottom of image here, can't depend on upsampler. */\n  max_rows = cinfo->output_height - post->starting_row;\n  if (num_rows > max_rows)\n    num_rows = max_rows;\n\n  /* Quantize and emit data. */\n  (*cinfo->cquantize->color_quantize) (cinfo,\n\t\tpost->buffer + post->next_row, output_buf + *out_row_ctr,\n\t\t(int) num_rows);\n  *out_row_ctr += num_rows;\n\n  /* Advance if we filled the strip. */\n  post->next_row += num_rows;\n  if (post->next_row >= post->strip_height) {\n    post->starting_row += post->strip_height;\n    post->next_row = 0;\n  }\n}\n\n#endif /* QUANT_2PASS_SUPPORTED */\n\n\n/*\n * Initialize postprocessing controller.\n */\n\nGLOBAL void\njinit_d_post_controller (j_decompress_ptr cinfo, boolean need_full_buffer)\n{\n  my_post_ptr post;\n\n  post = (my_post_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_post_controller));\n  cinfo->post = (struct jpeg_d_post_controller *) post;\n  post->pub.start_pass = start_pass_dpost;\n  post->whole_image = NULL;\t/* flag for no virtual arrays */\n  post->buffer = NULL;\t\t/* flag for no strip buffer */\n\n  /* Create the quantization buffer, if needed */\n  if (cinfo->quantize_colors) {\n    /* The buffer strip height is max_v_samp_factor, which is typically\n     * an efficient number of rows for upsampling to return.\n     * (In the presence of output rescaling, we might want to be smarter?)\n     */\n    post->strip_height = (JDIMENSION) cinfo->max_v_samp_factor;\n    if (need_full_buffer) {\n      /* Two-pass color quantization: need full-image storage. */\n      /* We round up the number of rows to a multiple of the strip height. */\n#ifdef QUANT_2PASS_SUPPORTED\n      post->whole_image = (*cinfo->mem->request_virt_sarray)\n\t((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,\n\t cinfo->output_width * cinfo->out_color_components,\n\t (JDIMENSION) jround_up((long) cinfo->output_height,\n\t\t\t\t(long) post->strip_height),\n\t post->strip_height);\n#else\n      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n#endif /* QUANT_2PASS_SUPPORTED */\n    } else {\n      /* One-pass color quantization: just make a strip buffer. */\n      post->buffer = (*cinfo->mem->alloc_sarray)\n\t((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t cinfo->output_width * cinfo->out_color_components,\n\t post->strip_height);\n    }\n  }\n}\n"
  },
  {
    "path": "code/jpeg-6/jdsample.c",
    "content": "/*\n * jdsample.c\n *\n * Copyright (C) 1991-1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains upsampling routines.\n *\n * Upsampling input data is counted in \"row groups\".  A row group\n * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size)\n * sample rows of each component.  Upsampling will normally produce\n * max_v_samp_factor pixel rows from each row group (but this could vary\n * if the upsampler is applying a scale factor of its own).\n *\n * An excellent reference for image resampling is\n *   Digital Image Warping, George Wolberg, 1990.\n *   Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/* Pointer to routine to upsample a single component */\ntypedef JMETHOD(void, upsample1_ptr,\n\t\t(j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t\t JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr));\n\n/* Private subobject */\n\ntypedef struct {\n  struct jpeg_upsampler pub;\t/* public fields */\n\n  /* Color conversion buffer.  When using separate upsampling and color\n   * conversion steps, this buffer holds one upsampled row group until it\n   * has been color converted and output.\n   * Note: we do not allocate any storage for component(s) which are full-size,\n   * ie do not need rescaling.  The corresponding entry of color_buf[] is\n   * simply set to point to the input data array, thereby avoiding copying.\n   */\n  JSAMPARRAY color_buf[MAX_COMPONENTS];\n\n  /* Per-component upsampling method pointers */\n  upsample1_ptr methods[MAX_COMPONENTS];\n\n  int next_row_out;\t\t/* counts rows emitted from color_buf */\n  JDIMENSION rows_to_go;\t/* counts rows remaining in image */\n\n  /* Height of an input row group for each component. */\n  int rowgroup_height[MAX_COMPONENTS];\n\n  /* These arrays save pixel expansion factors so that int_expand need not\n   * recompute them each time.  They are unused for other upsampling methods.\n   */\n  UINT8 h_expand[MAX_COMPONENTS];\n  UINT8 v_expand[MAX_COMPONENTS];\n} my_upsampler;\n\ntypedef my_upsampler * my_upsample_ptr;\n\n\n/*\n * Initialize for an upsampling pass.\n */\n\nMETHODDEF void\nstart_pass_upsample (j_decompress_ptr cinfo)\n{\n  my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;\n\n  /* Mark the conversion buffer empty */\n  upsample->next_row_out = cinfo->max_v_samp_factor;\n  /* Initialize total-height counter for detecting bottom of image */\n  upsample->rows_to_go = cinfo->output_height;\n}\n\n\n/*\n * Control routine to do upsampling (and color conversion).\n *\n * In this version we upsample each component independently.\n * We upsample one row group into the conversion buffer, then apply\n * color conversion a row at a time.\n */\n\nMETHODDEF void\nsep_upsample (j_decompress_ptr cinfo,\n\t      JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,\n\t      JDIMENSION in_row_groups_avail,\n\t      JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t      JDIMENSION out_rows_avail)\n{\n  my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;\n  int ci;\n  jpeg_component_info * compptr;\n  JDIMENSION num_rows;\n\n  /* Fill the conversion buffer, if it's empty */\n  if (upsample->next_row_out >= cinfo->max_v_samp_factor) {\n    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n\t ci++, compptr++) {\n      /* Invoke per-component upsample method.  Notice we pass a POINTER\n       * to color_buf[ci], so that fullsize_upsample can change it.\n       */\n      (*upsample->methods[ci]) (cinfo, compptr,\n\tinput_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]),\n\tupsample->color_buf + ci);\n    }\n    upsample->next_row_out = 0;\n  }\n\n  /* Color-convert and emit rows */\n\n  /* How many we have in the buffer: */\n  num_rows = (JDIMENSION) (cinfo->max_v_samp_factor - upsample->next_row_out);\n  /* Not more than the distance to the end of the image.  Need this test\n   * in case the image height is not a multiple of max_v_samp_factor:\n   */\n  if (num_rows > upsample->rows_to_go) \n    num_rows = upsample->rows_to_go;\n  /* And not more than what the client can accept: */\n  out_rows_avail -= *out_row_ctr;\n  if (num_rows > out_rows_avail)\n    num_rows = out_rows_avail;\n\n  (*cinfo->cconvert->color_convert) (cinfo, upsample->color_buf,\n\t\t\t\t     (JDIMENSION) upsample->next_row_out,\n\t\t\t\t     output_buf + *out_row_ctr,\n\t\t\t\t     (int) num_rows);\n\n  /* Adjust counts */\n  *out_row_ctr += num_rows;\n  upsample->rows_to_go -= num_rows;\n  upsample->next_row_out += num_rows;\n  /* When the buffer is emptied, declare this input row group consumed */\n  if (upsample->next_row_out >= cinfo->max_v_samp_factor)\n    (*in_row_group_ctr)++;\n}\n\n\n/*\n * These are the routines invoked by sep_upsample to upsample pixel values\n * of a single component.  One row group is processed per call.\n */\n\n\n/*\n * For full-size components, we just make color_buf[ci] point at the\n * input buffer, and thus avoid copying any data.  Note that this is\n * safe only because sep_upsample doesn't declare the input row group\n * \"consumed\" until we are done color converting and emitting it.\n */\n\nMETHODDEF void\nfullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t\t   JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)\n{\n  *output_data_ptr = input_data;\n}\n\n\n/*\n * This is a no-op version used for \"uninteresting\" components.\n * These components will not be referenced by color conversion.\n */\n\nMETHODDEF void\nnoop_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t       JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)\n{\n  *output_data_ptr = NULL;\t/* safety check */\n}\n\n\n/*\n * This version handles any integral sampling ratios.\n * This is not used for typical JPEG files, so it need not be fast.\n * Nor, for that matter, is it particularly accurate: the algorithm is\n * simple replication of the input pixel onto the corresponding output\n * pixels.  The hi-falutin sampling literature refers to this as a\n * \"box filter\".  A box filter tends to introduce visible artifacts,\n * so if you are actually going to use 3:1 or 4:1 sampling ratios\n * you would be well advised to improve this code.\n */\n\nMETHODDEF void\nint_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t      JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)\n{\n  my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;\n  JSAMPARRAY output_data = *output_data_ptr;\n  register JSAMPROW inptr, outptr;\n  register JSAMPLE invalue;\n  register int h;\n  JSAMPROW outend;\n  int h_expand, v_expand;\n  int inrow, outrow;\n\n  h_expand = upsample->h_expand[compptr->component_index];\n  v_expand = upsample->v_expand[compptr->component_index];\n\n  inrow = outrow = 0;\n  while (outrow < cinfo->max_v_samp_factor) {\n    /* Generate one output row with proper horizontal expansion */\n    inptr = input_data[inrow];\n    outptr = output_data[outrow];\n    outend = outptr + cinfo->output_width;\n    while (outptr < outend) {\n      invalue = *inptr++;\t/* don't need GETJSAMPLE() here */\n      for (h = h_expand; h > 0; h--) {\n\t*outptr++ = invalue;\n      }\n    }\n    /* Generate any additional output rows by duplicating the first one */\n    if (v_expand > 1) {\n      jcopy_sample_rows(output_data, outrow, output_data, outrow+1,\n\t\t\tv_expand-1, cinfo->output_width);\n    }\n    inrow++;\n    outrow += v_expand;\n  }\n}\n\n\n/*\n * Fast processing for the common case of 2:1 horizontal and 1:1 vertical.\n * It's still a box filter.\n */\n\nMETHODDEF void\nh2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t       JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)\n{\n  JSAMPARRAY output_data = *output_data_ptr;\n  register JSAMPROW inptr, outptr;\n  register JSAMPLE invalue;\n  JSAMPROW outend;\n  int inrow;\n\n  for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) {\n    inptr = input_data[inrow];\n    outptr = output_data[inrow];\n    outend = outptr + cinfo->output_width;\n    while (outptr < outend) {\n      invalue = *inptr++;\t/* don't need GETJSAMPLE() here */\n      *outptr++ = invalue;\n      *outptr++ = invalue;\n    }\n  }\n}\n\n\n/*\n * Fast processing for the common case of 2:1 horizontal and 2:1 vertical.\n * It's still a box filter.\n */\n\nMETHODDEF void\nh2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t       JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)\n{\n  JSAMPARRAY output_data = *output_data_ptr;\n  register JSAMPROW inptr, outptr;\n  register JSAMPLE invalue;\n  JSAMPROW outend;\n  int inrow, outrow;\n\n  inrow = outrow = 0;\n  while (outrow < cinfo->max_v_samp_factor) {\n    inptr = input_data[inrow];\n    outptr = output_data[outrow];\n    outend = outptr + cinfo->output_width;\n    while (outptr < outend) {\n      invalue = *inptr++;\t/* don't need GETJSAMPLE() here */\n      *outptr++ = invalue;\n      *outptr++ = invalue;\n    }\n    jcopy_sample_rows(output_data, outrow, output_data, outrow+1,\n\t\t      1, cinfo->output_width);\n    inrow++;\n    outrow += 2;\n  }\n}\n\n\n/*\n * Fancy processing for the common case of 2:1 horizontal and 1:1 vertical.\n *\n * The upsampling algorithm is linear interpolation between pixel centers,\n * also known as a \"triangle filter\".  This is a good compromise between\n * speed and visual quality.  The centers of the output pixels are 1/4 and 3/4\n * of the way between input pixel centers.\n *\n * A note about the \"bias\" calculations: when rounding fractional values to\n * integer, we do not want to always round 0.5 up to the next integer.\n * If we did that, we'd introduce a noticeable bias towards larger values.\n * Instead, this code is arranged so that 0.5 will be rounded up or down at\n * alternate pixel locations (a simple ordered dither pattern).\n */\n\nMETHODDEF void\nh2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t\t     JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)\n{\n  JSAMPARRAY output_data = *output_data_ptr;\n  register JSAMPROW inptr, outptr;\n  register int invalue;\n  register JDIMENSION colctr;\n  int inrow;\n\n  for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) {\n    inptr = input_data[inrow];\n    outptr = output_data[inrow];\n    /* Special case for first column */\n    invalue = GETJSAMPLE(*inptr++);\n    *outptr++ = (JSAMPLE) invalue;\n    *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(*inptr) + 2) >> 2);\n\n    for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) {\n      /* General case: 3/4 * nearer pixel + 1/4 * further pixel */\n      invalue = GETJSAMPLE(*inptr++) * 3;\n      *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(inptr[-2]) + 1) >> 2);\n      *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(*inptr) + 2) >> 2);\n    }\n\n    /* Special case for last column */\n    invalue = GETJSAMPLE(*inptr);\n    *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(inptr[-1]) + 1) >> 2);\n    *outptr++ = (JSAMPLE) invalue;\n  }\n}\n\n\n/*\n * Fancy processing for the common case of 2:1 horizontal and 2:1 vertical.\n * Again a triangle filter; see comments for h2v1 case, above.\n *\n * It is OK for us to reference the adjacent input rows because we demanded\n * context from the main buffer controller (see initialization code).\n */\n\nMETHODDEF void\nh2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t\t     JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)\n{\n  JSAMPARRAY output_data = *output_data_ptr;\n  register JSAMPROW inptr0, inptr1, outptr;\n#if BITS_IN_JSAMPLE == 8\n  register int thiscolsum, lastcolsum, nextcolsum;\n#else\n  register INT32 thiscolsum, lastcolsum, nextcolsum;\n#endif\n  register JDIMENSION colctr;\n  int inrow, outrow, v;\n\n  inrow = outrow = 0;\n  while (outrow < cinfo->max_v_samp_factor) {\n    for (v = 0; v < 2; v++) {\n      /* inptr0 points to nearest input row, inptr1 points to next nearest */\n      inptr0 = input_data[inrow];\n      if (v == 0)\t\t/* next nearest is row above */\n\tinptr1 = input_data[inrow-1];\n      else\t\t\t/* next nearest is row below */\n\tinptr1 = input_data[inrow+1];\n      outptr = output_data[outrow++];\n\n      /* Special case for first column */\n      thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);\n      nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);\n      *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 8) >> 4);\n      *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4);\n      lastcolsum = thiscolsum; thiscolsum = nextcolsum;\n\n      for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) {\n\t/* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */\n\t/* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */\n\tnextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);\n\t*outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4);\n\t*outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4);\n\tlastcolsum = thiscolsum; thiscolsum = nextcolsum;\n      }\n\n      /* Special case for last column */\n      *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4);\n      *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 7) >> 4);\n    }\n    inrow++;\n  }\n}\n\n\n/*\n * Module initialization routine for upsampling.\n */\n\nGLOBAL void\njinit_upsampler (j_decompress_ptr cinfo)\n{\n  my_upsample_ptr upsample;\n  int ci;\n  jpeg_component_info * compptr;\n  boolean need_buffer, do_fancy;\n  int h_in_group, v_in_group, h_out_group, v_out_group;\n\n  upsample = (my_upsample_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_upsampler));\n  cinfo->upsample = (struct jpeg_upsampler *) upsample;\n  upsample->pub.start_pass = start_pass_upsample;\n  upsample->pub.upsample = sep_upsample;\n  upsample->pub.need_context_rows = FALSE; /* until we find out differently */\n\n  if (cinfo->CCIR601_sampling)\t/* this isn't supported */\n    ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);\n\n  /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1,\n   * so don't ask for it.\n   */\n  do_fancy = cinfo->do_fancy_upsampling && cinfo->min_DCT_scaled_size > 1;\n\n  /* Verify we can handle the sampling factors, select per-component methods,\n   * and create storage as needed.\n   */\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    /* Compute size of an \"input group\" after IDCT scaling.  This many samples\n     * are to be converted to max_h_samp_factor * max_v_samp_factor pixels.\n     */\n    h_in_group = (compptr->h_samp_factor * compptr->DCT_scaled_size) /\n\t\t cinfo->min_DCT_scaled_size;\n    v_in_group = (compptr->v_samp_factor * compptr->DCT_scaled_size) /\n\t\t cinfo->min_DCT_scaled_size;\n    h_out_group = cinfo->max_h_samp_factor;\n    v_out_group = cinfo->max_v_samp_factor;\n    upsample->rowgroup_height[ci] = v_in_group; /* save for use later */\n    need_buffer = TRUE;\n    if (! compptr->component_needed) {\n      /* Don't bother to upsample an uninteresting component. */\n      upsample->methods[ci] = noop_upsample;\n      need_buffer = FALSE;\n    } else if (h_in_group == h_out_group && v_in_group == v_out_group) {\n      /* Fullsize components can be processed without any work. */\n      upsample->methods[ci] = fullsize_upsample;\n      need_buffer = FALSE;\n    } else if (h_in_group * 2 == h_out_group &&\n\t       v_in_group == v_out_group) {\n      /* Special cases for 2h1v upsampling */\n      if (do_fancy && compptr->downsampled_width > 2)\n\tupsample->methods[ci] = h2v1_fancy_upsample;\n      else\n\tupsample->methods[ci] = h2v1_upsample;\n    } else if (h_in_group * 2 == h_out_group &&\n\t       v_in_group * 2 == v_out_group) {\n      /* Special cases for 2h2v upsampling */\n      if (do_fancy && compptr->downsampled_width > 2) {\n\tupsample->methods[ci] = h2v2_fancy_upsample;\n\tupsample->pub.need_context_rows = TRUE;\n      } else\n\tupsample->methods[ci] = h2v2_upsample;\n    } else if ((h_out_group % h_in_group) == 0 &&\n\t       (v_out_group % v_in_group) == 0) {\n      /* Generic integral-factors upsampling method */\n      upsample->methods[ci] = int_upsample;\n      upsample->h_expand[ci] = (UINT8) (h_out_group / h_in_group);\n      upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group);\n    } else\n      ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);\n    if (need_buffer) {\n      upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray)\n\t((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t (JDIMENSION) jround_up((long) cinfo->output_width,\n\t\t\t\t(long) cinfo->max_h_samp_factor),\n\t (JDIMENSION) cinfo->max_v_samp_factor);\n    }\n  }\n}\n"
  },
  {
    "path": "code/jpeg-6/jdtrans.c",
    "content": "/*\n * jdtrans.c\n *\n * Copyright (C) 1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains library routines for transcoding decompression,\n * that is, reading raw DCT coefficient arrays from an input JPEG file.\n * The routines in jdapimin.c will also be needed by a transcoder.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/* Forward declarations */\nLOCAL void transdecode_master_selection JPP((j_decompress_ptr cinfo));\n\n\n/*\n * Read the coefficient arrays from a JPEG file.\n * jpeg_read_header must be completed before calling this.\n *\n * The entire image is read into a set of virtual coefficient-block arrays,\n * one per component.  The return value is a pointer to the array of\n * virtual-array descriptors.  These can be manipulated directly via the\n * JPEG memory manager, or handed off to jpeg_write_coefficients().\n * To release the memory occupied by the virtual arrays, call\n * jpeg_finish_decompress() when done with the data.\n *\n * Returns NULL if suspended.  This case need be checked only if\n * a suspending data source is used.\n */\n\nGLOBAL jvirt_barray_ptr *\njpeg_read_coefficients (j_decompress_ptr cinfo)\n{\n  if (cinfo->global_state == DSTATE_READY) {\n    /* First call: initialize active modules */\n    transdecode_master_selection(cinfo);\n    cinfo->global_state = DSTATE_RDCOEFS;\n  } else if (cinfo->global_state != DSTATE_RDCOEFS)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  /* Absorb whole file into the coef buffer */\n  for (;;) {\n    int retcode;\n    /* Call progress monitor hook if present */\n    if (cinfo->progress != NULL)\n      (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);\n    /* Absorb some more input */\n    retcode = (*cinfo->inputctl->consume_input) (cinfo);\n    if (retcode == JPEG_SUSPENDED)\n      return NULL;\n    if (retcode == JPEG_REACHED_EOI)\n      break;\n    /* Advance progress counter if appropriate */\n    if (cinfo->progress != NULL &&\n\t(retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {\n      if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {\n\t/* startup underestimated number of scans; ratchet up one scan */\n\tcinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;\n      }\n    }\n  }\n  /* Set state so that jpeg_finish_decompress does the right thing */\n  cinfo->global_state = DSTATE_STOPPING;\n  return cinfo->coef->coef_arrays;\n}\n\n\n/*\n * Master selection of decompression modules for transcoding.\n * This substitutes for jdmaster.c's initialization of the full decompressor.\n */\n\nLOCAL void\ntransdecode_master_selection (j_decompress_ptr cinfo)\n{\n  /* Entropy decoding: either Huffman or arithmetic coding. */\n  if (cinfo->arith_code) {\n    ERREXIT(cinfo, JERR_ARITH_NOTIMPL);\n  } else {\n    if (cinfo->progressive_mode) {\n#ifdef D_PROGRESSIVE_SUPPORTED\n      jinit_phuff_decoder(cinfo);\n#else\n      ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif\n    } else\n      jinit_huff_decoder(cinfo);\n  }\n\n  /* Always get a full-image coefficient buffer. */\n  jinit_d_coef_controller(cinfo, TRUE);\n\n  /* We can now tell the memory manager to allocate virtual arrays. */\n  (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);\n\n  /* Initialize input side of decompressor to consume first scan. */\n  (*cinfo->inputctl->start_input_pass) (cinfo);\n\n  /* Initialize progress monitoring. */\n  if (cinfo->progress != NULL) {\n    int nscans;\n    /* Estimate number of scans to set pass_limit. */\n    if (cinfo->progressive_mode) {\n      /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */\n      nscans = 2 + 3 * cinfo->num_components;\n    } else if (cinfo->inputctl->has_multiple_scans) {\n      /* For a nonprogressive multiscan file, estimate 1 scan per component. */\n      nscans = cinfo->num_components;\n    } else {\n      nscans = 1;\n    }\n    cinfo->progress->pass_counter = 0L;\n    cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans;\n    cinfo->progress->completed_passes = 0;\n    cinfo->progress->total_passes = 1;\n  }\n}\n"
  },
  {
    "path": "code/jpeg-6/jerror.c",
    "content": "/*\n * jerror.c\n *\n * Copyright (C) 1991-1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains simple error-reporting and trace-message routines.\n * These are suitable for Unix-like systems and others where writing to\n * stderr is the right thing to do.  Many applications will want to replace\n * some or all of these routines.\n *\n * These routines are used by both the compression and decompression code.\n */\n\n/* this is not a core library module, so it doesn't define JPEG_INTERNALS */\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jversion.h\"\n#include \"jerror.h\"\n\n#include \"../renderer/tr_local.h\"\n\n#ifndef EXIT_FAILURE\t\t/* define exit() codes if not provided */\n#define EXIT_FAILURE  1\n#endif\n\n\n/*\n * Create the message string table.\n * We do this from the master message list in jerror.h by re-reading\n * jerror.h with a suitable definition for macro JMESSAGE.\n * The message table is made an external symbol just in case any applications\n * want to refer to it directly.\n */\n\n#ifdef NEED_SHORT_EXTERNAL_NAMES\n#define jpeg_std_message_table\tjMsgTable\n#endif\n\n#define JMESSAGE(code,string)\tstring ,\n\nconst char * const jpeg_std_message_table[] = {\n#include \"jerror.h\"\n  NULL\n};\n\n\n/*\n * Error exit handler: must not return to caller.\n *\n * Applications may override this if they want to get control back after\n * an error.  Typically one would longjmp somewhere instead of exiting.\n * The setjmp buffer can be made a private field within an expanded error\n * handler object.  Note that the info needed to generate an error message\n * is stored in the error object, so you can generate the message now or\n * later, at your convenience.\n * You should make sure that the JPEG object is cleaned up (with jpeg_abort\n * or jpeg_destroy) at some point.\n */\n\nMETHODDEF void\nerror_exit (j_common_ptr cinfo)\n{\n  char buffer[JMSG_LENGTH_MAX];\n\n  /* Create the message */\n  (*cinfo->err->format_message) (cinfo, buffer);\n\n  /* Let the memory manager delete any temp files before we die */\n  jpeg_destroy(cinfo);\n\n  ri.Error( ERR_FATAL, \"%s\\n\", buffer );\n}\n\n\n/*\n * Actual output of an error or trace message.\n * Applications may override this method to send JPEG messages somewhere\n * other than stderr.\n */\n\nMETHODDEF void\noutput_message (j_common_ptr cinfo)\n{\n  char buffer[JMSG_LENGTH_MAX];\n\n  /* Create the message */\n  (*cinfo->err->format_message) (cinfo, buffer);\n\n  /* Send it to stderr, adding a newline */\n  ri.Printf(PRINT_ALL, \"%s\\n\", buffer);\n}\n\n\n/*\n * Decide whether to emit a trace or warning message.\n * msg_level is one of:\n *   -1: recoverable corrupt-data warning, may want to abort.\n *    0: important advisory messages (always display to user).\n *    1: first level of tracing detail.\n *    2,3,...: successively more detailed tracing messages.\n * An application might override this method if it wanted to abort on warnings\n * or change the policy about which messages to display.\n */\n\nMETHODDEF void\nemit_message (j_common_ptr cinfo, int msg_level)\n{\n  struct jpeg_error_mgr * err = cinfo->err;\n\n  if (msg_level < 0) {\n    /* It's a warning message.  Since corrupt files may generate many warnings,\n     * the policy implemented here is to show only the first warning,\n     * unless trace_level >= 3.\n     */\n    if (err->num_warnings == 0 || err->trace_level >= 3)\n      (*err->output_message) (cinfo);\n    /* Always count warnings in num_warnings. */\n    err->num_warnings++;\n  } else {\n    /* It's a trace message.  Show it if trace_level >= msg_level. */\n    if (err->trace_level >= msg_level)\n      (*err->output_message) (cinfo);\n  }\n}\n\n\n/*\n * Format a message string for the most recent JPEG error or message.\n * The message is stored into buffer, which should be at least JMSG_LENGTH_MAX\n * characters.  Note that no '\\n' character is added to the string.\n * Few applications should need to override this method.\n */\n\nMETHODDEF void\nformat_message (j_common_ptr cinfo, char * buffer)\n{\n  struct jpeg_error_mgr * err = cinfo->err;\n  int msg_code = err->msg_code;\n  const char * msgtext = NULL;\n  const char * msgptr;\n  char ch;\n  boolean isstring;\n\n  /* Look up message string in proper table */\n  if (msg_code > 0 && msg_code <= err->last_jpeg_message) {\n    msgtext = err->jpeg_message_table[msg_code];\n  } else if (err->addon_message_table != NULL &&\n\t     msg_code >= err->first_addon_message &&\n\t     msg_code <= err->last_addon_message) {\n    msgtext = err->addon_message_table[msg_code - err->first_addon_message];\n  }\n\n  /* Defend against bogus message number */\n  if (msgtext == NULL) {\n    err->msg_parm.i[0] = msg_code;\n    msgtext = err->jpeg_message_table[0];\n  }\n\n  /* Check for string parameter, as indicated by %s in the message text */\n  isstring = FALSE;\n  msgptr = msgtext;\n  while ((ch = *msgptr++) != '\\0') {\n    if (ch == '%') {\n      if (*msgptr == 's') isstring = TRUE;\n      break;\n    }\n  }\n\n  /* Format the message into the passed buffer */\n  if (isstring)\n    sprintf(buffer, msgtext, err->msg_parm.s);\n  else\n    sprintf(buffer, msgtext,\n\t    err->msg_parm.i[0], err->msg_parm.i[1],\n\t    err->msg_parm.i[2], err->msg_parm.i[3],\n\t    err->msg_parm.i[4], err->msg_parm.i[5],\n\t    err->msg_parm.i[6], err->msg_parm.i[7]);\n}\n\n\n/*\n * Reset error state variables at start of a new image.\n * This is called during compression startup to reset trace/error\n * processing to default state, without losing any application-specific\n * method pointers.  An application might possibly want to override\n * this method if it has additional error processing state.\n */\n\nMETHODDEF void\nreset_error_mgr (j_common_ptr cinfo)\n{\n  cinfo->err->num_warnings = 0;\n  /* trace_level is not reset since it is an application-supplied parameter */\n  cinfo->err->msg_code = 0;\t/* may be useful as a flag for \"no error\" */\n}\n\n\n/*\n * Fill in the standard error-handling methods in a jpeg_error_mgr object.\n * Typical call is:\n *\tstruct jpeg_compress_struct cinfo;\n *\tstruct jpeg_error_mgr err;\n *\n *\tcinfo.err = jpeg_std_error(&err);\n * after which the application may override some of the methods.\n */\n\nGLOBAL struct jpeg_error_mgr *\njpeg_std_error (struct jpeg_error_mgr * err)\n{\n  err->error_exit = error_exit;\n  err->emit_message = emit_message;\n  err->output_message = output_message;\n  err->format_message = format_message;\n  err->reset_error_mgr = reset_error_mgr;\n\n  err->trace_level = 0;\t\t/* default = no tracing */\n  err->num_warnings = 0;\t/* no warnings emitted yet */\n  err->msg_code = 0;\t\t/* may be useful as a flag for \"no error\" */\n\n  /* Initialize message table pointers */\n  err->jpeg_message_table = jpeg_std_message_table;\n  err->last_jpeg_message = (int) JMSG_LASTMSGCODE - 1;\n\n  err->addon_message_table = NULL;\n  err->first_addon_message = 0;\t/* for safety */\n  err->last_addon_message = 0;\n\n  return err;\n}\n"
  },
  {
    "path": "code/jpeg-6/jerror.h",
    "content": "/*\n * jerror.h\n *\n * Copyright (C) 1994-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file defines the error and message codes for the JPEG library.\n * Edit this file to add new codes, or to translate the message strings to\n * some other language.\n * A set of error-reporting macros are defined too.  Some applications using\n * the JPEG library may wish to include this file to get the error codes\n * and/or the macros.\n */\n\n/*\n * To define the enum list of message codes, include this file without\n * defining macro JMESSAGE.  To create a message string table, include it\n * again with a suitable JMESSAGE definition (see jerror.c for an example).\n */\n#ifndef JMESSAGE\n#ifndef JERROR_H\n/* First time through, define the enum list */\n#define JMAKE_ENUM_LIST\n#else\n/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */\n#define JMESSAGE(code,string)\n#endif /* JERROR_H */\n#endif /* JMESSAGE */\n\n#ifdef JMAKE_ENUM_LIST\n\ntypedef enum {\n\n#define JMESSAGE(code,string)\tcode ,\n\n#endif /* JMAKE_ENUM_LIST */\n\nJMESSAGE(JMSG_NOMESSAGE, \"Bogus message code %d\") /* Must be first entry! */\n\n/* For maintenance convenience, list is alphabetical by message code name */\nJMESSAGE(JERR_ARITH_NOTIMPL,\n\t \"Sorry, there are legal restrictions on arithmetic coding\")\nJMESSAGE(JERR_BAD_ALIGN_TYPE, \"ALIGN_TYPE is wrong, please fix\")\nJMESSAGE(JERR_BAD_ALLOC_CHUNK, \"MAX_ALLOC_CHUNK is wrong, please fix\")\nJMESSAGE(JERR_BAD_BUFFER_MODE, \"Bogus buffer control mode\")\nJMESSAGE(JERR_BAD_COMPONENT_ID, \"Invalid component ID %d in SOS\")\nJMESSAGE(JERR_BAD_DCTSIZE, \"IDCT output block size %d not supported\")\nJMESSAGE(JERR_BAD_IN_COLORSPACE, \"Bogus input colorspace\")\nJMESSAGE(JERR_BAD_J_COLORSPACE, \"Bogus JPEG colorspace\")\nJMESSAGE(JERR_BAD_LENGTH, \"Bogus marker length\")\nJMESSAGE(JERR_BAD_MCU_SIZE, \"Sampling factors too large for interleaved scan\")\nJMESSAGE(JERR_BAD_POOL_ID, \"Invalid memory pool code %d\")\nJMESSAGE(JERR_BAD_PRECISION, \"Unsupported JPEG data precision %d\")\nJMESSAGE(JERR_BAD_PROGRESSION,\n\t \"Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d\")\nJMESSAGE(JERR_BAD_PROG_SCRIPT,\n\t \"Invalid progressive parameters at scan script entry %d\")\nJMESSAGE(JERR_BAD_SAMPLING, \"Bogus sampling factors\")\nJMESSAGE(JERR_BAD_SCAN_SCRIPT, \"Invalid scan script at entry %d\")\nJMESSAGE(JERR_BAD_STATE, \"Improper call to JPEG library in state %d\")\nJMESSAGE(JERR_BAD_VIRTUAL_ACCESS, \"Bogus virtual array access\")\nJMESSAGE(JERR_BUFFER_SIZE, \"Buffer passed to JPEG library is too small\")\nJMESSAGE(JERR_CANT_SUSPEND, \"Suspension not allowed here\")\nJMESSAGE(JERR_CCIR601_NOTIMPL, \"CCIR601 sampling not implemented yet\")\nJMESSAGE(JERR_COMPONENT_COUNT, \"Too many color components: %d, max %d\")\nJMESSAGE(JERR_CONVERSION_NOTIMPL, \"Unsupported color conversion request\")\nJMESSAGE(JERR_DAC_INDEX, \"Bogus DAC index %d\")\nJMESSAGE(JERR_DAC_VALUE, \"Bogus DAC value 0x%x\")\nJMESSAGE(JERR_DHT_COUNTS, \"Bogus DHT counts\")\nJMESSAGE(JERR_DHT_INDEX, \"Bogus DHT index %d\")\nJMESSAGE(JERR_DQT_INDEX, \"Bogus DQT index %d\")\nJMESSAGE(JERR_EMPTY_IMAGE, \"Empty JPEG image (DNL not supported)\")\nJMESSAGE(JERR_EMS_READ, \"Read from EMS failed\")\nJMESSAGE(JERR_EMS_WRITE, \"Write to EMS failed\")\nJMESSAGE(JERR_EOI_EXPECTED, \"Didn't expect more than one scan\")\nJMESSAGE(JERR_FILE_READ, \"Input file read error\")\nJMESSAGE(JERR_FILE_WRITE, \"Output file write error --- out of disk space?\")\nJMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, \"Fractional sampling not implemented yet\")\nJMESSAGE(JERR_HUFF_CLEN_OVERFLOW, \"Huffman code size table overflow\")\nJMESSAGE(JERR_HUFF_MISSING_CODE, \"Missing Huffman code table entry\")\nJMESSAGE(JERR_IMAGE_TOO_BIG, \"Maximum supported image dimension is %u pixels\")\nJMESSAGE(JERR_INPUT_EMPTY, \"Empty input file\")\nJMESSAGE(JERR_INPUT_EOF, \"Premature end of input file\")\nJMESSAGE(JERR_MISMATCHED_QUANT_TABLE,\n\t \"Cannot transcode due to multiple use of quantization table %d\")\nJMESSAGE(JERR_MISSING_DATA, \"Scan script does not transmit all data\")\nJMESSAGE(JERR_MODE_CHANGE, \"Invalid color quantization mode change\")\nJMESSAGE(JERR_NOTIMPL, \"Not implemented yet\")\nJMESSAGE(JERR_NOT_COMPILED, \"Requested feature was omitted at compile time\")\nJMESSAGE(JERR_NO_BACKING_STORE, \"Backing store not supported\")\nJMESSAGE(JERR_NO_HUFF_TABLE, \"Huffman table 0x%02x was not defined\")\nJMESSAGE(JERR_NO_IMAGE, \"JPEG datastream contains no image\")\nJMESSAGE(JERR_NO_QUANT_TABLE, \"Quantization table 0x%02x was not defined\")\nJMESSAGE(JERR_NO_SOI, \"Not a JPEG file: starts with 0x%02x 0x%02x\")\nJMESSAGE(JERR_OUT_OF_MEMORY, \"Insufficient memory (case %d)\")\nJMESSAGE(JERR_QUANT_COMPONENTS,\n\t \"Cannot quantize more than %d color components\")\nJMESSAGE(JERR_QUANT_FEW_COLORS, \"Cannot quantize to fewer than %d colors\")\nJMESSAGE(JERR_QUANT_MANY_COLORS, \"Cannot quantize to more than %d colors\")\nJMESSAGE(JERR_SOF_DUPLICATE, \"Invalid JPEG file structure: two SOF markers\")\nJMESSAGE(JERR_SOF_NO_SOS, \"Invalid JPEG file structure: missing SOS marker\")\nJMESSAGE(JERR_SOF_UNSUPPORTED, \"Unsupported JPEG process: SOF type 0x%02x\")\nJMESSAGE(JERR_SOI_DUPLICATE, \"Invalid JPEG file structure: two SOI markers\")\nJMESSAGE(JERR_SOS_NO_SOF, \"Invalid JPEG file structure: SOS before SOF\")\nJMESSAGE(JERR_TFILE_CREATE, \"Failed to create temporary file %s\")\nJMESSAGE(JERR_TFILE_READ, \"Read failed on temporary file\")\nJMESSAGE(JERR_TFILE_SEEK, \"Seek failed on temporary file\")\nJMESSAGE(JERR_TFILE_WRITE,\n\t \"Write failed on temporary file --- out of disk space?\")\nJMESSAGE(JERR_TOO_LITTLE_DATA, \"Application transferred too few scanlines\")\nJMESSAGE(JERR_UNKNOWN_MARKER, \"Unsupported marker type 0x%02x\")\nJMESSAGE(JERR_VIRTUAL_BUG, \"Virtual array controller messed up\")\nJMESSAGE(JERR_WIDTH_OVERFLOW, \"Image too wide for this implementation\")\nJMESSAGE(JERR_XMS_READ, \"Read from XMS failed\")\nJMESSAGE(JERR_XMS_WRITE, \"Write to XMS failed\")\nJMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT)\nJMESSAGE(JMSG_VERSION, JVERSION)\nJMESSAGE(JTRC_16BIT_TABLES,\n\t \"Caution: quantization tables are too coarse for baseline JPEG\")\nJMESSAGE(JTRC_ADOBE,\n\t \"Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d\")\nJMESSAGE(JTRC_APP0, \"Unknown APP0 marker (not JFIF), length %u\")\nJMESSAGE(JTRC_APP14, \"Unknown APP14 marker (not Adobe), length %u\")\nJMESSAGE(JTRC_DAC, \"Define Arithmetic Table 0x%02x: 0x%02x\")\nJMESSAGE(JTRC_DHT, \"Define Huffman Table 0x%02x\")\nJMESSAGE(JTRC_DQT, \"Define Quantization Table %d  precision %d\")\nJMESSAGE(JTRC_DRI, \"Define Restart Interval %u\")\nJMESSAGE(JTRC_EMS_CLOSE, \"Freed EMS handle %u\")\nJMESSAGE(JTRC_EMS_OPEN, \"Obtained EMS handle %u\")\nJMESSAGE(JTRC_EOI, \"End Of Image\")\nJMESSAGE(JTRC_HUFFBITS, \"        %3d %3d %3d %3d %3d %3d %3d %3d\")\nJMESSAGE(JTRC_JFIF, \"JFIF APP0 marker, density %dx%d  %d\")\nJMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE,\n\t \"Warning: thumbnail image size does not match data length %u\")\nJMESSAGE(JTRC_JFIF_MINOR, \"Unknown JFIF minor revision number %d.%02d\")\nJMESSAGE(JTRC_JFIF_THUMBNAIL, \"    with %d x %d thumbnail image\")\nJMESSAGE(JTRC_MISC_MARKER, \"Skipping marker 0x%02x, length %u\")\nJMESSAGE(JTRC_PARMLESS_MARKER, \"Unexpected marker 0x%02x\")\nJMESSAGE(JTRC_QUANTVALS, \"        %4u %4u %4u %4u %4u %4u %4u %4u\")\nJMESSAGE(JTRC_QUANT_3_NCOLORS, \"Quantizing to %d = %d*%d*%d colors\")\nJMESSAGE(JTRC_QUANT_NCOLORS, \"Quantizing to %d colors\")\nJMESSAGE(JTRC_QUANT_SELECTED, \"Selected %d colors for quantization\")\nJMESSAGE(JTRC_RECOVERY_ACTION, \"At marker 0x%02x, recovery action %d\")\nJMESSAGE(JTRC_RST, \"RST%d\")\nJMESSAGE(JTRC_SMOOTH_NOTIMPL,\n\t \"Smoothing not supported with nonstandard sampling ratios\")\nJMESSAGE(JTRC_SOF, \"Start Of Frame 0x%02x: width=%u, height=%u, components=%d\")\nJMESSAGE(JTRC_SOF_COMPONENT, \"    Component %d: %dhx%dv q=%d\")\nJMESSAGE(JTRC_SOI, \"Start of Image\")\nJMESSAGE(JTRC_SOS, \"Start Of Scan: %d components\")\nJMESSAGE(JTRC_SOS_COMPONENT, \"    Component %d: dc=%d ac=%d\")\nJMESSAGE(JTRC_SOS_PARAMS, \"  Ss=%d, Se=%d, Ah=%d, Al=%d\")\nJMESSAGE(JTRC_TFILE_CLOSE, \"Closed temporary file %s\")\nJMESSAGE(JTRC_TFILE_OPEN, \"Opened temporary file %s\")\nJMESSAGE(JTRC_UNKNOWN_IDS,\n\t \"Unrecognized component IDs %d %d %d, assuming YCbCr\")\nJMESSAGE(JTRC_XMS_CLOSE, \"Freed XMS handle %u\")\nJMESSAGE(JTRC_XMS_OPEN, \"Obtained XMS handle %u\")\nJMESSAGE(JWRN_ADOBE_XFORM, \"Unknown Adobe color transform code %d\")\nJMESSAGE(JWRN_BOGUS_PROGRESSION,\n\t \"Inconsistent progression sequence for component %d coefficient %d\")\nJMESSAGE(JWRN_EXTRANEOUS_DATA,\n\t \"Corrupt JPEG data: %u extraneous bytes before marker 0x%02x\")\nJMESSAGE(JWRN_HIT_MARKER, \"Corrupt JPEG data: premature end of data segment\")\nJMESSAGE(JWRN_HUFF_BAD_CODE, \"Corrupt JPEG data: bad Huffman code\")\nJMESSAGE(JWRN_JFIF_MAJOR, \"Warning: unknown JFIF revision number %d.%02d\")\nJMESSAGE(JWRN_JPEG_EOF, \"Premature end of JPEG file\")\nJMESSAGE(JWRN_MUST_RESYNC,\n\t \"Corrupt JPEG data: found marker 0x%02x instead of RST%d\")\nJMESSAGE(JWRN_NOT_SEQUENTIAL, \"Invalid SOS parameters for sequential JPEG\")\nJMESSAGE(JWRN_TOO_MUCH_DATA, \"Application transferred too many scanlines\")\n\n#ifdef JMAKE_ENUM_LIST\n\n  JMSG_LASTMSGCODE\n} J_MESSAGE_CODE;\n\n#undef JMAKE_ENUM_LIST\n#endif /* JMAKE_ENUM_LIST */\n\n/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */\n#undef JMESSAGE\n\n\n#ifndef JERROR_H\n#define JERROR_H\n\n/* Macros to simplify using the error and trace message stuff */\n/* The first parameter is either type of cinfo pointer */\n\n/* Fatal errors (print message and exit) */\n#define ERREXIT(cinfo,code)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))\n#define ERREXIT1(cinfo,code,p1)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (cinfo)->err->msg_parm.i[0] = (p1), \\\n   (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))\n#define ERREXIT2(cinfo,code,p1,p2)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (cinfo)->err->msg_parm.i[0] = (p1), \\\n   (cinfo)->err->msg_parm.i[1] = (p2), \\\n   (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))\n#define ERREXIT3(cinfo,code,p1,p2,p3)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (cinfo)->err->msg_parm.i[0] = (p1), \\\n   (cinfo)->err->msg_parm.i[1] = (p2), \\\n   (cinfo)->err->msg_parm.i[2] = (p3), \\\n   (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))\n#define ERREXIT4(cinfo,code,p1,p2,p3,p4)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (cinfo)->err->msg_parm.i[0] = (p1), \\\n   (cinfo)->err->msg_parm.i[1] = (p2), \\\n   (cinfo)->err->msg_parm.i[2] = (p3), \\\n   (cinfo)->err->msg_parm.i[3] = (p4), \\\n   (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))\n#define ERREXITS(cinfo,code,str)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \\\n   (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))\n\n#define MAKESTMT(stuff)\t\tdo { stuff } while (0)\n\n/* Nonfatal errors (we can keep going, but the data is probably corrupt) */\n#define WARNMS(cinfo,code)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))\n#define WARNMS1(cinfo,code,p1)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (cinfo)->err->msg_parm.i[0] = (p1), \\\n   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))\n#define WARNMS2(cinfo,code,p1,p2)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (cinfo)->err->msg_parm.i[0] = (p1), \\\n   (cinfo)->err->msg_parm.i[1] = (p2), \\\n   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))\n\n/* Informational/debugging messages */\n#define TRACEMS(cinfo,lvl,code)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))\n#define TRACEMS1(cinfo,lvl,code,p1)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (cinfo)->err->msg_parm.i[0] = (p1), \\\n   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))\n#define TRACEMS2(cinfo,lvl,code,p1,p2)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (cinfo)->err->msg_parm.i[0] = (p1), \\\n   (cinfo)->err->msg_parm.i[1] = (p2), \\\n   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))\n#define TRACEMS3(cinfo,lvl,code,p1,p2,p3)  \\\n  MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \\\n\t   _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \\\n\t   (cinfo)->err->msg_code = (code); \\\n\t   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )\n#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4)  \\\n  MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \\\n\t   _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \\\n\t   (cinfo)->err->msg_code = (code); \\\n\t   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )\n#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8)  \\\n  MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \\\n\t   _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \\\n\t   _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \\\n\t   (cinfo)->err->msg_code = (code); \\\n\t   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )\n#define TRACEMSS(cinfo,lvl,code,str)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \\\n   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))\n\n#endif /* JERROR_H */\n"
  },
  {
    "path": "code/jpeg-6/jfdctflt.c",
    "content": "/*\n * jfdctflt.c\n *\n * Copyright (C) 1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains a floating-point implementation of the\n * forward DCT (Discrete Cosine Transform).\n *\n * This implementation should be more accurate than either of the integer\n * DCT implementations.  However, it may not give the same results on all\n * machines because of differences in roundoff behavior.  Speed will depend\n * on the hardware's floating point capacity.\n *\n * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT\n * on each column.  Direct algorithms are also available, but they are\n * much more complex and seem not to be any faster when reduced to code.\n *\n * This implementation is based on Arai, Agui, and Nakajima's algorithm for\n * scaled DCT.  Their original paper (Trans. IEICE E-71(11):1095) is in\n * Japanese, but the algorithm is described in the Pennebaker & Mitchell\n * JPEG textbook (see REFERENCES section in file README).  The following code\n * is based directly on figure 4-8 in P&M.\n * While an 8-point DCT cannot be done in less than 11 multiplies, it is\n * possible to arrange the computation so that many of the multiplies are\n * simple scalings of the final outputs.  These multiplies can then be\n * folded into the multiplications or divisions by the JPEG quantization\n * table entries.  The AA&N method leaves only 5 multiplies and 29 adds\n * to be done in the DCT itself.\n * The primary disadvantage of this method is that with a fixed-point\n * implementation, accuracy is lost due to imprecise representation of the\n * scaled quantization values.  However, that problem does not arise if\n * we use floating point arithmetic.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jdct.h\"\t\t/* Private declarations for DCT subsystem */\n\n#ifdef DCT_FLOAT_SUPPORTED\n\n\n/*\n * This module is specialized to the case DCTSIZE = 8.\n */\n\n#if DCTSIZE != 8\n  Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */\n#endif\n\n\n/*\n * Perform the forward DCT on one block of samples.\n */\n\nGLOBAL void\njpeg_fdct_float (FAST_FLOAT * data)\n{\n  FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;\n  FAST_FLOAT tmp10, tmp11, tmp12, tmp13;\n  FAST_FLOAT z1, z2, z3, z4, z5, z11, z13;\n  FAST_FLOAT *dataptr;\n  int ctr;\n\n  /* Pass 1: process rows. */\n\n  dataptr = data;\n  for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {\n    tmp0 = dataptr[0] + dataptr[7];\n    tmp7 = dataptr[0] - dataptr[7];\n    tmp1 = dataptr[1] + dataptr[6];\n    tmp6 = dataptr[1] - dataptr[6];\n    tmp2 = dataptr[2] + dataptr[5];\n    tmp5 = dataptr[2] - dataptr[5];\n    tmp3 = dataptr[3] + dataptr[4];\n    tmp4 = dataptr[3] - dataptr[4];\n    \n    /* Even part */\n    \n    tmp10 = tmp0 + tmp3;\t/* phase 2 */\n    tmp13 = tmp0 - tmp3;\n    tmp11 = tmp1 + tmp2;\n    tmp12 = tmp1 - tmp2;\n    \n    dataptr[0] = tmp10 + tmp11; /* phase 3 */\n    dataptr[4] = tmp10 - tmp11;\n    \n    z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */\n    dataptr[2] = tmp13 + z1;\t/* phase 5 */\n    dataptr[6] = tmp13 - z1;\n    \n    /* Odd part */\n\n    tmp10 = tmp4 + tmp5;\t/* phase 2 */\n    tmp11 = tmp5 + tmp6;\n    tmp12 = tmp6 + tmp7;\n\n    /* The rotator is modified from fig 4-8 to avoid extra negations. */\n    z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */\n    z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */\n    z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */\n    z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */\n\n    z11 = tmp7 + z3;\t\t/* phase 5 */\n    z13 = tmp7 - z3;\n\n    dataptr[5] = z13 + z2;\t/* phase 6 */\n    dataptr[3] = z13 - z2;\n    dataptr[1] = z11 + z4;\n    dataptr[7] = z11 - z4;\n\n    dataptr += DCTSIZE;\t\t/* advance pointer to next row */\n  }\n\n  /* Pass 2: process columns. */\n\n  dataptr = data;\n  for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {\n    tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7];\n    tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7];\n    tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6];\n    tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6];\n    tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5];\n    tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5];\n    tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4];\n    tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4];\n    \n    /* Even part */\n    \n    tmp10 = tmp0 + tmp3;\t/* phase 2 */\n    tmp13 = tmp0 - tmp3;\n    tmp11 = tmp1 + tmp2;\n    tmp12 = tmp1 - tmp2;\n    \n    dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */\n    dataptr[DCTSIZE*4] = tmp10 - tmp11;\n    \n    z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */\n    dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */\n    dataptr[DCTSIZE*6] = tmp13 - z1;\n    \n    /* Odd part */\n\n    tmp10 = tmp4 + tmp5;\t/* phase 2 */\n    tmp11 = tmp5 + tmp6;\n    tmp12 = tmp6 + tmp7;\n\n    /* The rotator is modified from fig 4-8 to avoid extra negations. */\n    z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */\n    z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */\n    z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */\n    z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */\n\n    z11 = tmp7 + z3;\t\t/* phase 5 */\n    z13 = tmp7 - z3;\n\n    dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */\n    dataptr[DCTSIZE*3] = z13 - z2;\n    dataptr[DCTSIZE*1] = z11 + z4;\n    dataptr[DCTSIZE*7] = z11 - z4;\n\n    dataptr++;\t\t\t/* advance pointer to next column */\n  }\n}\n\n#endif /* DCT_FLOAT_SUPPORTED */\n"
  },
  {
    "path": "code/jpeg-6/jfdctfst.c",
    "content": "/*\n * jfdctfst.c\n *\n * Copyright (C) 1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains a fast, not so accurate integer implementation of the\n * forward DCT (Discrete Cosine Transform).\n *\n * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT\n * on each column.  Direct algorithms are also available, but they are\n * much more complex and seem not to be any faster when reduced to code.\n *\n * This implementation is based on Arai, Agui, and Nakajima's algorithm for\n * scaled DCT.  Their original paper (Trans. IEICE E-71(11):1095) is in\n * Japanese, but the algorithm is described in the Pennebaker & Mitchell\n * JPEG textbook (see REFERENCES section in file README).  The following code\n * is based directly on figure 4-8 in P&M.\n * While an 8-point DCT cannot be done in less than 11 multiplies, it is\n * possible to arrange the computation so that many of the multiplies are\n * simple scalings of the final outputs.  These multiplies can then be\n * folded into the multiplications or divisions by the JPEG quantization\n * table entries.  The AA&N method leaves only 5 multiplies and 29 adds\n * to be done in the DCT itself.\n * The primary disadvantage of this method is that with fixed-point math,\n * accuracy is lost due to imprecise representation of the scaled\n * quantization values.  The smaller the quantization table entry, the less\n * precise the scaled value, so this implementation does worse with high-\n * quality-setting files than with low-quality ones.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jdct.h\"\t\t/* Private declarations for DCT subsystem */\n\n#ifdef DCT_IFAST_SUPPORTED\n\n\n/*\n * This module is specialized to the case DCTSIZE = 8.\n */\n\n#if DCTSIZE != 8\n  Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */\n#endif\n\n\n/* Scaling decisions are generally the same as in the LL&M algorithm;\n * see jfdctint.c for more details.  However, we choose to descale\n * (right shift) multiplication products as soon as they are formed,\n * rather than carrying additional fractional bits into subsequent additions.\n * This compromises accuracy slightly, but it lets us save a few shifts.\n * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples)\n * everywhere except in the multiplications proper; this saves a good deal\n * of work on 16-bit-int machines.\n *\n * Again to save a few shifts, the intermediate results between pass 1 and\n * pass 2 are not upscaled, but are represented only to integral precision.\n *\n * A final compromise is to represent the multiplicative constants to only\n * 8 fractional bits, rather than 13.  This saves some shifting work on some\n * machines, and may also reduce the cost of multiplication (since there\n * are fewer one-bits in the constants).\n */\n\n#define CONST_BITS  8\n\n\n/* Some C compilers fail to reduce \"FIX(constant)\" at compile time, thus\n * causing a lot of useless floating-point operations at run time.\n * To get around this we use the following pre-calculated constants.\n * If you change CONST_BITS you may want to add appropriate values.\n * (With a reasonable C compiler, you can just rely on the FIX() macro...)\n */\n\n#if CONST_BITS == 8\n#define FIX_0_382683433  ((INT32)   98)\t\t/* FIX(0.382683433) */\n#define FIX_0_541196100  ((INT32)  139)\t\t/* FIX(0.541196100) */\n#define FIX_0_707106781  ((INT32)  181)\t\t/* FIX(0.707106781) */\n#define FIX_1_306562965  ((INT32)  334)\t\t/* FIX(1.306562965) */\n#else\n#define FIX_0_382683433  FIX(0.382683433)\n#define FIX_0_541196100  FIX(0.541196100)\n#define FIX_0_707106781  FIX(0.707106781)\n#define FIX_1_306562965  FIX(1.306562965)\n#endif\n\n\n/* We can gain a little more speed, with a further compromise in accuracy,\n * by omitting the addition in a descaling shift.  This yields an incorrectly\n * rounded result half the time...\n */\n\n#ifndef USE_ACCURATE_ROUNDING\n#undef DESCALE\n#define DESCALE(x,n)  RIGHT_SHIFT(x, n)\n#endif\n\n\n/* Multiply a DCTELEM variable by an INT32 constant, and immediately\n * descale to yield a DCTELEM result.\n */\n\n#define MULTIPLY(var,const)  ((DCTELEM) DESCALE((var) * (const), CONST_BITS))\n\n\n/*\n * Perform the forward DCT on one block of samples.\n */\n\nGLOBAL void\njpeg_fdct_ifast (DCTELEM * data)\n{\n  DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;\n  DCTELEM tmp10, tmp11, tmp12, tmp13;\n  DCTELEM z1, z2, z3, z4, z5, z11, z13;\n  DCTELEM *dataptr;\n  int ctr;\n  SHIFT_TEMPS\n\n  /* Pass 1: process rows. */\n\n  dataptr = data;\n  for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {\n    tmp0 = dataptr[0] + dataptr[7];\n    tmp7 = dataptr[0] - dataptr[7];\n    tmp1 = dataptr[1] + dataptr[6];\n    tmp6 = dataptr[1] - dataptr[6];\n    tmp2 = dataptr[2] + dataptr[5];\n    tmp5 = dataptr[2] - dataptr[5];\n    tmp3 = dataptr[3] + dataptr[4];\n    tmp4 = dataptr[3] - dataptr[4];\n    \n    /* Even part */\n    \n    tmp10 = tmp0 + tmp3;\t/* phase 2 */\n    tmp13 = tmp0 - tmp3;\n    tmp11 = tmp1 + tmp2;\n    tmp12 = tmp1 - tmp2;\n    \n    dataptr[0] = tmp10 + tmp11; /* phase 3 */\n    dataptr[4] = tmp10 - tmp11;\n    \n    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */\n    dataptr[2] = tmp13 + z1;\t/* phase 5 */\n    dataptr[6] = tmp13 - z1;\n    \n    /* Odd part */\n\n    tmp10 = tmp4 + tmp5;\t/* phase 2 */\n    tmp11 = tmp5 + tmp6;\n    tmp12 = tmp6 + tmp7;\n\n    /* The rotator is modified from fig 4-8 to avoid extra negations. */\n    z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */\n    z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */\n    z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */\n    z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */\n\n    z11 = tmp7 + z3;\t\t/* phase 5 */\n    z13 = tmp7 - z3;\n\n    dataptr[5] = z13 + z2;\t/* phase 6 */\n    dataptr[3] = z13 - z2;\n    dataptr[1] = z11 + z4;\n    dataptr[7] = z11 - z4;\n\n    dataptr += DCTSIZE;\t\t/* advance pointer to next row */\n  }\n\n  /* Pass 2: process columns. */\n\n  dataptr = data;\n  for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {\n    tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7];\n    tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7];\n    tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6];\n    tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6];\n    tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5];\n    tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5];\n    tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4];\n    tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4];\n    \n    /* Even part */\n    \n    tmp10 = tmp0 + tmp3;\t/* phase 2 */\n    tmp13 = tmp0 - tmp3;\n    tmp11 = tmp1 + tmp2;\n    tmp12 = tmp1 - tmp2;\n    \n    dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */\n    dataptr[DCTSIZE*4] = tmp10 - tmp11;\n    \n    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */\n    dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */\n    dataptr[DCTSIZE*6] = tmp13 - z1;\n    \n    /* Odd part */\n\n    tmp10 = tmp4 + tmp5;\t/* phase 2 */\n    tmp11 = tmp5 + tmp6;\n    tmp12 = tmp6 + tmp7;\n\n    /* The rotator is modified from fig 4-8 to avoid extra negations. */\n    z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */\n    z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */\n    z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */\n    z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */\n\n    z11 = tmp7 + z3;\t\t/* phase 5 */\n    z13 = tmp7 - z3;\n\n    dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */\n    dataptr[DCTSIZE*3] = z13 - z2;\n    dataptr[DCTSIZE*1] = z11 + z4;\n    dataptr[DCTSIZE*7] = z11 - z4;\n\n    dataptr++;\t\t\t/* advance pointer to next column */\n  }\n}\n\n#endif /* DCT_IFAST_SUPPORTED */\n"
  },
  {
    "path": "code/jpeg-6/jfdctint.c",
    "content": "/*\n * jfdctint.c\n *\n * Copyright (C) 1991-1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains a slow-but-accurate integer implementation of the\n * forward DCT (Discrete Cosine Transform).\n *\n * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT\n * on each column.  Direct algorithms are also available, but they are\n * much more complex and seem not to be any faster when reduced to code.\n *\n * This implementation is based on an algorithm described in\n *   C. Loeffler, A. Ligtenberg and G. Moschytz, \"Practical Fast 1-D DCT\n *   Algorithms with 11 Multiplications\", Proc. Int'l. Conf. on Acoustics,\n *   Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991.\n * The primary algorithm described there uses 11 multiplies and 29 adds.\n * We use their alternate method with 12 multiplies and 32 adds.\n * The advantage of this method is that no data path contains more than one\n * multiplication; this allows a very simple and accurate implementation in\n * scaled fixed-point arithmetic, with a minimal number of shifts.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jdct.h\"\t\t/* Private declarations for DCT subsystem */\n\n#ifdef DCT_ISLOW_SUPPORTED\n\n\n/*\n * This module is specialized to the case DCTSIZE = 8.\n */\n\n#if DCTSIZE != 8\n  Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */\n#endif\n\n\n/*\n * The poop on this scaling stuff is as follows:\n *\n * Each 1-D DCT step produces outputs which are a factor of sqrt(N)\n * larger than the true DCT outputs.  The final outputs are therefore\n * a factor of N larger than desired; since N=8 this can be cured by\n * a simple right shift at the end of the algorithm.  The advantage of\n * this arrangement is that we save two multiplications per 1-D DCT,\n * because the y0 and y4 outputs need not be divided by sqrt(N).\n * In the IJG code, this factor of 8 is removed by the quantization step\n * (in jcdctmgr.c), NOT in this module.\n *\n * We have to do addition and subtraction of the integer inputs, which\n * is no problem, and multiplication by fractional constants, which is\n * a problem to do in integer arithmetic.  We multiply all the constants\n * by CONST_SCALE and convert them to integer constants (thus retaining\n * CONST_BITS bits of precision in the constants).  After doing a\n * multiplication we have to divide the product by CONST_SCALE, with proper\n * rounding, to produce the correct output.  This division can be done\n * cheaply as a right shift of CONST_BITS bits.  We postpone shifting\n * as long as possible so that partial sums can be added together with\n * full fractional precision.\n *\n * The outputs of the first pass are scaled up by PASS1_BITS bits so that\n * they are represented to better-than-integral precision.  These outputs\n * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word\n * with the recommended scaling.  (For 12-bit sample data, the intermediate\n * array is INT32 anyway.)\n *\n * To avoid overflow of the 32-bit intermediate results in pass 2, we must\n * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26.  Error analysis\n * shows that the values given below are the most effective.\n */\n\n#if BITS_IN_JSAMPLE == 8\n#define CONST_BITS  13\n#define PASS1_BITS  2\n#else\n#define CONST_BITS  13\n#define PASS1_BITS  1\t\t/* lose a little precision to avoid overflow */\n#endif\n\n/* Some C compilers fail to reduce \"FIX(constant)\" at compile time, thus\n * causing a lot of useless floating-point operations at run time.\n * To get around this we use the following pre-calculated constants.\n * If you change CONST_BITS you may want to add appropriate values.\n * (With a reasonable C compiler, you can just rely on the FIX() macro...)\n */\n\n#if CONST_BITS == 13\n#define FIX_0_298631336  ((INT32)  2446)\t/* FIX(0.298631336) */\n#define FIX_0_390180644  ((INT32)  3196)\t/* FIX(0.390180644) */\n#define FIX_0_541196100  ((INT32)  4433)\t/* FIX(0.541196100) */\n#define FIX_0_765366865  ((INT32)  6270)\t/* FIX(0.765366865) */\n#define FIX_0_899976223  ((INT32)  7373)\t/* FIX(0.899976223) */\n#define FIX_1_175875602  ((INT32)  9633)\t/* FIX(1.175875602) */\n#define FIX_1_501321110  ((INT32)  12299)\t/* FIX(1.501321110) */\n#define FIX_1_847759065  ((INT32)  15137)\t/* FIX(1.847759065) */\n#define FIX_1_961570560  ((INT32)  16069)\t/* FIX(1.961570560) */\n#define FIX_2_053119869  ((INT32)  16819)\t/* FIX(2.053119869) */\n#define FIX_2_562915447  ((INT32)  20995)\t/* FIX(2.562915447) */\n#define FIX_3_072711026  ((INT32)  25172)\t/* FIX(3.072711026) */\n#else\n#define FIX_0_298631336  FIX(0.298631336)\n#define FIX_0_390180644  FIX(0.390180644)\n#define FIX_0_541196100  FIX(0.541196100)\n#define FIX_0_765366865  FIX(0.765366865)\n#define FIX_0_899976223  FIX(0.899976223)\n#define FIX_1_175875602  FIX(1.175875602)\n#define FIX_1_501321110  FIX(1.501321110)\n#define FIX_1_847759065  FIX(1.847759065)\n#define FIX_1_961570560  FIX(1.961570560)\n#define FIX_2_053119869  FIX(2.053119869)\n#define FIX_2_562915447  FIX(2.562915447)\n#define FIX_3_072711026  FIX(3.072711026)\n#endif\n\n\n/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.\n * For 8-bit samples with the recommended scaling, all the variable\n * and constant values involved are no more than 16 bits wide, so a\n * 16x16->32 bit multiply can be used instead of a full 32x32 multiply.\n * For 12-bit samples, a full 32-bit multiplication will be needed.\n */\n\n#if BITS_IN_JSAMPLE == 8\n#define MULTIPLY(var,const)  MULTIPLY16C16(var,const)\n#else\n#define MULTIPLY(var,const)  ((var) * (const))\n#endif\n\n\n/*\n * Perform the forward DCT on one block of samples.\n */\n\nGLOBAL void\njpeg_fdct_islow (DCTELEM * data)\n{\n  INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;\n  INT32 tmp10, tmp11, tmp12, tmp13;\n  INT32 z1, z2, z3, z4, z5;\n  DCTELEM *dataptr;\n  int ctr;\n  SHIFT_TEMPS\n\n  /* Pass 1: process rows. */\n  /* Note results are scaled up by sqrt(8) compared to a true DCT; */\n  /* furthermore, we scale the results by 2**PASS1_BITS. */\n\n  dataptr = data;\n  for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {\n    tmp0 = dataptr[0] + dataptr[7];\n    tmp7 = dataptr[0] - dataptr[7];\n    tmp1 = dataptr[1] + dataptr[6];\n    tmp6 = dataptr[1] - dataptr[6];\n    tmp2 = dataptr[2] + dataptr[5];\n    tmp5 = dataptr[2] - dataptr[5];\n    tmp3 = dataptr[3] + dataptr[4];\n    tmp4 = dataptr[3] - dataptr[4];\n    \n    /* Even part per LL&M figure 1 --- note that published figure is faulty;\n     * rotator \"sqrt(2)*c1\" should be \"sqrt(2)*c6\".\n     */\n    \n    tmp10 = tmp0 + tmp3;\n    tmp13 = tmp0 - tmp3;\n    tmp11 = tmp1 + tmp2;\n    tmp12 = tmp1 - tmp2;\n    \n    dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS);\n    dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS);\n    \n    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);\n    dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),\n\t\t\t\t   CONST_BITS-PASS1_BITS);\n    dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065),\n\t\t\t\t   CONST_BITS-PASS1_BITS);\n    \n    /* Odd part per figure 8 --- note paper omits factor of sqrt(2).\n     * cK represents cos(K*pi/16).\n     * i0..i3 in the paper are tmp4..tmp7 here.\n     */\n    \n    z1 = tmp4 + tmp7;\n    z2 = tmp5 + tmp6;\n    z3 = tmp4 + tmp6;\n    z4 = tmp5 + tmp7;\n    z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */\n    \n    tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */\n    tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */\n    tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */\n    tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */\n    z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */\n    z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */\n    z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */\n    z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */\n    \n    z3 += z5;\n    z4 += z5;\n    \n    dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS);\n    dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS);\n    dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS);\n    dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS);\n    \n    dataptr += DCTSIZE;\t\t/* advance pointer to next row */\n  }\n\n  /* Pass 2: process columns.\n   * We remove the PASS1_BITS scaling, but leave the results scaled up\n   * by an overall factor of 8.\n   */\n\n  dataptr = data;\n  for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {\n    tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7];\n    tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7];\n    tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6];\n    tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6];\n    tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5];\n    tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5];\n    tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4];\n    tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4];\n    \n    /* Even part per LL&M figure 1 --- note that published figure is faulty;\n     * rotator \"sqrt(2)*c1\" should be \"sqrt(2)*c6\".\n     */\n    \n    tmp10 = tmp0 + tmp3;\n    tmp13 = tmp0 - tmp3;\n    tmp11 = tmp1 + tmp2;\n    tmp12 = tmp1 - tmp2;\n    \n    dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS);\n    dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS);\n    \n    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);\n    dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),\n\t\t\t\t\t   CONST_BITS+PASS1_BITS);\n    dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065),\n\t\t\t\t\t   CONST_BITS+PASS1_BITS);\n    \n    /* Odd part per figure 8 --- note paper omits factor of sqrt(2).\n     * cK represents cos(K*pi/16).\n     * i0..i3 in the paper are tmp4..tmp7 here.\n     */\n    \n    z1 = tmp4 + tmp7;\n    z2 = tmp5 + tmp6;\n    z3 = tmp4 + tmp6;\n    z4 = tmp5 + tmp7;\n    z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */\n    \n    tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */\n    tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */\n    tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */\n    tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */\n    z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */\n    z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */\n    z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */\n    z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */\n    \n    z3 += z5;\n    z4 += z5;\n    \n    dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp4 + z1 + z3,\n\t\t\t\t\t   CONST_BITS+PASS1_BITS);\n    dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp5 + z2 + z4,\n\t\t\t\t\t   CONST_BITS+PASS1_BITS);\n    dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp6 + z2 + z3,\n\t\t\t\t\t   CONST_BITS+PASS1_BITS);\n    dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp7 + z1 + z4,\n\t\t\t\t\t   CONST_BITS+PASS1_BITS);\n    \n    dataptr++;\t\t\t/* advance pointer to next column */\n  }\n}\n\n#endif /* DCT_ISLOW_SUPPORTED */\n"
  },
  {
    "path": "code/jpeg-6/jidctflt.c",
    "content": "/*\n * jidctflt.c\n *\n * Copyright (C) 1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains a floating-point implementation of the\n * inverse DCT (Discrete Cosine Transform).  In the IJG code, this routine\n * must also perform dequantization of the input coefficients.\n *\n * This implementation should be more accurate than either of the integer\n * IDCT implementations.  However, it may not give the same results on all\n * machines because of differences in roundoff behavior.  Speed will depend\n * on the hardware's floating point capacity.\n *\n * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT\n * on each row (or vice versa, but it's more convenient to emit a row at\n * a time).  Direct algorithms are also available, but they are much more\n * complex and seem not to be any faster when reduced to code.\n *\n * This implementation is based on Arai, Agui, and Nakajima's algorithm for\n * scaled DCT.  Their original paper (Trans. IEICE E-71(11):1095) is in\n * Japanese, but the algorithm is described in the Pennebaker & Mitchell\n * JPEG textbook (see REFERENCES section in file README).  The following code\n * is based directly on figure 4-8 in P&M.\n * While an 8-point DCT cannot be done in less than 11 multiplies, it is\n * possible to arrange the computation so that many of the multiplies are\n * simple scalings of the final outputs.  These multiplies can then be\n * folded into the multiplications or divisions by the JPEG quantization\n * table entries.  The AA&N method leaves only 5 multiplies and 29 adds\n * to be done in the DCT itself.\n * The primary disadvantage of this method is that with a fixed-point\n * implementation, accuracy is lost due to imprecise representation of the\n * scaled quantization values.  However, that problem does not arise if\n * we use floating point arithmetic.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jdct.h\"\t\t/* Private declarations for DCT subsystem */\n\n#ifdef DCT_FLOAT_SUPPORTED\n\n\n/*\n * This module is specialized to the case DCTSIZE = 8.\n */\n\n#if DCTSIZE != 8\n  Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */\n#endif\n\n\n/* Dequantize a coefficient by multiplying it by the multiplier-table\n * entry; produce a float result.\n */\n\n#define DEQUANTIZE(coef,quantval)  (((FAST_FLOAT) (coef)) * (quantval))\n\n\n/*\n * Perform dequantization and inverse DCT on one block of coefficients.\n */\n\nGLOBAL void\njpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t\t JCOEFPTR coef_block,\n\t\t JSAMPARRAY output_buf, JDIMENSION output_col)\n{\n  FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;\n  FAST_FLOAT tmp10, tmp11, tmp12, tmp13;\n  FAST_FLOAT z5, z10, z11, z12, z13;\n  JCOEFPTR inptr;\n  FLOAT_MULT_TYPE * quantptr;\n  FAST_FLOAT * wsptr;\n  JSAMPROW outptr;\n  JSAMPLE *range_limit = IDCT_range_limit(cinfo);\n  int ctr;\n  FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */\n  SHIFT_TEMPS\n\n  /* Pass 1: process columns from input, store into work array. */\n\n  inptr = coef_block;\n  quantptr = (FLOAT_MULT_TYPE *) compptr->dct_table;\n  wsptr = workspace;\n  for (ctr = DCTSIZE; ctr > 0; ctr--) {\n    /* Due to quantization, we will usually find that many of the input\n     * coefficients are zero, especially the AC terms.  We can exploit this\n     * by short-circuiting the IDCT calculation for any column in which all\n     * the AC terms are zero.  In that case each output is equal to the\n     * DC coefficient (with scale factor as needed).\n     * With typical images and quantization tables, half or more of the\n     * column DCT calculations can be simplified this way.\n     */\n    \n    if ((inptr[DCTSIZE*1] | inptr[DCTSIZE*2] | inptr[DCTSIZE*3] |\n\t inptr[DCTSIZE*4] | inptr[DCTSIZE*5] | inptr[DCTSIZE*6] |\n\t inptr[DCTSIZE*7]) == 0) {\n      /* AC terms all zero */\n      FAST_FLOAT dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);\n      \n      wsptr[DCTSIZE*0] = dcval;\n      wsptr[DCTSIZE*1] = dcval;\n      wsptr[DCTSIZE*2] = dcval;\n      wsptr[DCTSIZE*3] = dcval;\n      wsptr[DCTSIZE*4] = dcval;\n      wsptr[DCTSIZE*5] = dcval;\n      wsptr[DCTSIZE*6] = dcval;\n      wsptr[DCTSIZE*7] = dcval;\n      \n      inptr++;\t\t\t/* advance pointers to next column */\n      quantptr++;\n      wsptr++;\n      continue;\n    }\n    \n    /* Even part */\n\n    tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);\n    tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);\n    tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);\n    tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);\n\n    tmp10 = tmp0 + tmp2;\t/* phase 3 */\n    tmp11 = tmp0 - tmp2;\n\n    tmp13 = tmp1 + tmp3;\t/* phases 5-3 */\n    tmp12 = (tmp1 - tmp3) * ((FAST_FLOAT) 1.414213562) - tmp13; /* 2*c4 */\n\n    tmp0 = tmp10 + tmp13;\t/* phase 2 */\n    tmp3 = tmp10 - tmp13;\n    tmp1 = tmp11 + tmp12;\n    tmp2 = tmp11 - tmp12;\n    \n    /* Odd part */\n\n    tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);\n    tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);\n    tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);\n    tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);\n\n    z13 = tmp6 + tmp5;\t\t/* phase 6 */\n    z10 = tmp6 - tmp5;\n    z11 = tmp4 + tmp7;\n    z12 = tmp4 - tmp7;\n\n    tmp7 = z11 + z13;\t\t/* phase 5 */\n    tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */\n\n    z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */\n    tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */\n    tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */\n\n    tmp6 = tmp12 - tmp7;\t/* phase 2 */\n    tmp5 = tmp11 - tmp6;\n    tmp4 = tmp10 + tmp5;\n\n    wsptr[DCTSIZE*0] = tmp0 + tmp7;\n    wsptr[DCTSIZE*7] = tmp0 - tmp7;\n    wsptr[DCTSIZE*1] = tmp1 + tmp6;\n    wsptr[DCTSIZE*6] = tmp1 - tmp6;\n    wsptr[DCTSIZE*2] = tmp2 + tmp5;\n    wsptr[DCTSIZE*5] = tmp2 - tmp5;\n    wsptr[DCTSIZE*4] = tmp3 + tmp4;\n    wsptr[DCTSIZE*3] = tmp3 - tmp4;\n\n    inptr++;\t\t\t/* advance pointers to next column */\n    quantptr++;\n    wsptr++;\n  }\n  \n  /* Pass 2: process rows from work array, store into output array. */\n  /* Note that we must descale the results by a factor of 8 == 2**3. */\n\n  wsptr = workspace;\n  for (ctr = 0; ctr < DCTSIZE; ctr++) {\n    outptr = output_buf[ctr] + output_col;\n    /* Rows of zeroes can be exploited in the same way as we did with columns.\n     * However, the column calculation has created many nonzero AC terms, so\n     * the simplification applies less often (typically 5% to 10% of the time).\n     * And testing floats for zero is relatively expensive, so we don't bother.\n     */\n    \n    /* Even part */\n\n    tmp10 = wsptr[0] + wsptr[4];\n    tmp11 = wsptr[0] - wsptr[4];\n\n    tmp13 = wsptr[2] + wsptr[6];\n    tmp12 = (wsptr[2] - wsptr[6]) * ((FAST_FLOAT) 1.414213562) - tmp13;\n\n    tmp0 = tmp10 + tmp13;\n    tmp3 = tmp10 - tmp13;\n    tmp1 = tmp11 + tmp12;\n    tmp2 = tmp11 - tmp12;\n\n    /* Odd part */\n\n    z13 = wsptr[5] + wsptr[3];\n    z10 = wsptr[5] - wsptr[3];\n    z11 = wsptr[1] + wsptr[7];\n    z12 = wsptr[1] - wsptr[7];\n\n    tmp7 = z11 + z13;\n    tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562);\n\n    z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */\n    tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */\n    tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */\n\n    tmp6 = tmp12 - tmp7;\n    tmp5 = tmp11 - tmp6;\n    tmp4 = tmp10 + tmp5;\n\n    /* Final output stage: scale down by a factor of 8 and range-limit */\n\n    outptr[0] = range_limit[(int) DESCALE((INT32) (tmp0 + tmp7), 3)\n\t\t\t    & RANGE_MASK];\n    outptr[7] = range_limit[(int) DESCALE((INT32) (tmp0 - tmp7), 3)\n\t\t\t    & RANGE_MASK];\n    outptr[1] = range_limit[(int) DESCALE((INT32) (tmp1 + tmp6), 3)\n\t\t\t    & RANGE_MASK];\n    outptr[6] = range_limit[(int) DESCALE((INT32) (tmp1 - tmp6), 3)\n\t\t\t    & RANGE_MASK];\n    outptr[2] = range_limit[(int) DESCALE((INT32) (tmp2 + tmp5), 3)\n\t\t\t    & RANGE_MASK];\n    outptr[5] = range_limit[(int) DESCALE((INT32) (tmp2 - tmp5), 3)\n\t\t\t    & RANGE_MASK];\n    outptr[4] = range_limit[(int) DESCALE((INT32) (tmp3 + tmp4), 3)\n\t\t\t    & RANGE_MASK];\n    outptr[3] = range_limit[(int) DESCALE((INT32) (tmp3 - tmp4), 3)\n\t\t\t    & RANGE_MASK];\n    \n    wsptr += DCTSIZE;\t\t/* advance pointer to next row */\n  }\n}\n\n#endif /* DCT_FLOAT_SUPPORTED */\n"
  },
  {
    "path": "code/jpeg-6/jidctfst.c",
    "content": "/*\n * jidctfst.c\n *\n * Copyright (C) 1994-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains a fast, not so accurate integer implementation of the\n * inverse DCT (Discrete Cosine Transform).  In the IJG code, this routine\n * must also perform dequantization of the input coefficients.\n *\n * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT\n * on each row (or vice versa, but it's more convenient to emit a row at\n * a time).  Direct algorithms are also available, but they are much more\n * complex and seem not to be any faster when reduced to code.\n *\n * This implementation is based on Arai, Agui, and Nakajima's algorithm for\n * scaled DCT.  Their original paper (Trans. IEICE E-71(11):1095) is in\n * Japanese, but the algorithm is described in the Pennebaker & Mitchell\n * JPEG textbook (see REFERENCES section in file README).  The following code\n * is based directly on figure 4-8 in P&M.\n * While an 8-point DCT cannot be done in less than 11 multiplies, it is\n * possible to arrange the computation so that many of the multiplies are\n * simple scalings of the final outputs.  These multiplies can then be\n * folded into the multiplications or divisions by the JPEG quantization\n * table entries.  The AA&N method leaves only 5 multiplies and 29 adds\n * to be done in the DCT itself.\n * The primary disadvantage of this method is that with fixed-point math,\n * accuracy is lost due to imprecise representation of the scaled\n * quantization values.  The smaller the quantization table entry, the less\n * precise the scaled value, so this implementation does worse with high-\n * quality-setting files than with low-quality ones.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jdct.h\"\t\t/* Private declarations for DCT subsystem */\n\n#ifdef DCT_IFAST_SUPPORTED\n\n\n/*\n * This module is specialized to the case DCTSIZE = 8.\n */\n\n#if DCTSIZE != 8\n  Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */\n#endif\n\n\n/* Scaling decisions are generally the same as in the LL&M algorithm;\n * see jidctint.c for more details.  However, we choose to descale\n * (right shift) multiplication products as soon as they are formed,\n * rather than carrying additional fractional bits into subsequent additions.\n * This compromises accuracy slightly, but it lets us save a few shifts.\n * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples)\n * everywhere except in the multiplications proper; this saves a good deal\n * of work on 16-bit-int machines.\n *\n * The dequantized coefficients are not integers because the AA&N scaling\n * factors have been incorporated.  We represent them scaled up by PASS1_BITS,\n * so that the first and second IDCT rounds have the same input scaling.\n * For 8-bit JSAMPLEs, we choose IFAST_SCALE_BITS = PASS1_BITS so as to\n * avoid a descaling shift; this compromises accuracy rather drastically\n * for small quantization table entries, but it saves a lot of shifts.\n * For 12-bit JSAMPLEs, there's no hope of using 16x16 multiplies anyway,\n * so we use a much larger scaling factor to preserve accuracy.\n *\n * A final compromise is to represent the multiplicative constants to only\n * 8 fractional bits, rather than 13.  This saves some shifting work on some\n * machines, and may also reduce the cost of multiplication (since there\n * are fewer one-bits in the constants).\n */\n\n#if BITS_IN_JSAMPLE == 8\n#define CONST_BITS  8\n#define PASS1_BITS  2\n#else\n#define CONST_BITS  8\n#define PASS1_BITS  1\t\t/* lose a little precision to avoid overflow */\n#endif\n\n/* Some C compilers fail to reduce \"FIX(constant)\" at compile time, thus\n * causing a lot of useless floating-point operations at run time.\n * To get around this we use the following pre-calculated constants.\n * If you change CONST_BITS you may want to add appropriate values.\n * (With a reasonable C compiler, you can just rely on the FIX() macro...)\n */\n\n#if CONST_BITS == 8\n#define FIX_1_082392200  ((INT32)  277)\t\t/* FIX(1.082392200) */\n#define FIX_1_414213562  ((INT32)  362)\t\t/* FIX(1.414213562) */\n#define FIX_1_847759065  ((INT32)  473)\t\t/* FIX(1.847759065) */\n#define FIX_2_613125930  ((INT32)  669)\t\t/* FIX(2.613125930) */\n#else\n#define FIX_1_082392200  FIX(1.082392200)\n#define FIX_1_414213562  FIX(1.414213562)\n#define FIX_1_847759065  FIX(1.847759065)\n#define FIX_2_613125930  FIX(2.613125930)\n#endif\n\n\n/* We can gain a little more speed, with a further compromise in accuracy,\n * by omitting the addition in a descaling shift.  This yields an incorrectly\n * rounded result half the time...\n */\n\n#ifndef USE_ACCURATE_ROUNDING\n#undef DESCALE\n#define DESCALE(x,n)  RIGHT_SHIFT(x, n)\n#endif\n\n\n/* Multiply a DCTELEM variable by an INT32 constant, and immediately\n * descale to yield a DCTELEM result.\n */\n\n#define MULTIPLY(var,const)  ((DCTELEM) DESCALE((var) * (const), CONST_BITS))\n\n\n/* Dequantize a coefficient by multiplying it by the multiplier-table\n * entry; produce a DCTELEM result.  For 8-bit data a 16x16->16\n * multiplication will do.  For 12-bit data, the multiplier table is\n * declared INT32, so a 32-bit multiply will be used.\n */\n\n#if BITS_IN_JSAMPLE == 8\n#define DEQUANTIZE(coef,quantval)  (((IFAST_MULT_TYPE) (coef)) * (quantval))\n#else\n#define DEQUANTIZE(coef,quantval)  \\\n\tDESCALE((coef)*(quantval), IFAST_SCALE_BITS-PASS1_BITS)\n#endif\n\n\n/* Like DESCALE, but applies to a DCTELEM and produces an int.\n * We assume that int right shift is unsigned if INT32 right shift is.\n */\n\n#ifdef RIGHT_SHIFT_IS_UNSIGNED\n#define ISHIFT_TEMPS\tDCTELEM ishift_temp;\n#if BITS_IN_JSAMPLE == 8\n#define DCTELEMBITS  16\t\t/* DCTELEM may be 16 or 32 bits */\n#else\n#define DCTELEMBITS  32\t\t/* DCTELEM must be 32 bits */\n#endif\n#define IRIGHT_SHIFT(x,shft)  \\\n    ((ishift_temp = (x)) < 0 ? \\\n     (ishift_temp >> (shft)) | ((~((DCTELEM) 0)) << (DCTELEMBITS-(shft))) : \\\n     (ishift_temp >> (shft)))\n#else\n#define ISHIFT_TEMPS\n#define IRIGHT_SHIFT(x,shft)\t((x) >> (shft))\n#endif\n\n#ifdef USE_ACCURATE_ROUNDING\n#define IDESCALE(x,n)  ((int) IRIGHT_SHIFT((x) + (1 << ((n)-1)), n))\n#else\n#define IDESCALE(x,n)  ((int) IRIGHT_SHIFT(x, n))\n#endif\n\n\n/*\n * Perform dequantization and inverse DCT on one block of coefficients.\n */\n\nGLOBAL void\njpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t\t JCOEFPTR coef_block,\n\t\t JSAMPARRAY output_buf, JDIMENSION output_col)\n{\n  DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;\n  DCTELEM tmp10, tmp11, tmp12, tmp13;\n  DCTELEM z5, z10, z11, z12, z13;\n  JCOEFPTR inptr;\n  IFAST_MULT_TYPE * quantptr;\n  int * wsptr;\n  JSAMPROW outptr;\n  JSAMPLE *range_limit = IDCT_range_limit(cinfo);\n  int ctr;\n  int workspace[DCTSIZE2];\t/* buffers data between passes */\n  SHIFT_TEMPS\t\t\t/* for DESCALE */\n  ISHIFT_TEMPS\t\t\t/* for IDESCALE */\n\n  /* Pass 1: process columns from input, store into work array. */\n\n  inptr = coef_block;\n  quantptr = (IFAST_MULT_TYPE *) compptr->dct_table;\n  wsptr = workspace;\n  for (ctr = DCTSIZE; ctr > 0; ctr--) {\n    /* Due to quantization, we will usually find that many of the input\n     * coefficients are zero, especially the AC terms.  We can exploit this\n     * by short-circuiting the IDCT calculation for any column in which all\n     * the AC terms are zero.  In that case each output is equal to the\n     * DC coefficient (with scale factor as needed).\n     * With typical images and quantization tables, half or more of the\n     * column DCT calculations can be simplified this way.\n     */\n    \n    if ((inptr[DCTSIZE*1] | inptr[DCTSIZE*2] | inptr[DCTSIZE*3] |\n\t inptr[DCTSIZE*4] | inptr[DCTSIZE*5] | inptr[DCTSIZE*6] |\n\t inptr[DCTSIZE*7]) == 0) {\n      /* AC terms all zero */\n      int dcval = (int) DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);\n\n      wsptr[DCTSIZE*0] = dcval;\n      wsptr[DCTSIZE*1] = dcval;\n      wsptr[DCTSIZE*2] = dcval;\n      wsptr[DCTSIZE*3] = dcval;\n      wsptr[DCTSIZE*4] = dcval;\n      wsptr[DCTSIZE*5] = dcval;\n      wsptr[DCTSIZE*6] = dcval;\n      wsptr[DCTSIZE*7] = dcval;\n      \n      inptr++;\t\t\t/* advance pointers to next column */\n      quantptr++;\n      wsptr++;\n      continue;\n    }\n    \n    /* Even part */\n\n    tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);\n    tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);\n    tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);\n    tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);\n\n    tmp10 = tmp0 + tmp2;\t/* phase 3 */\n    tmp11 = tmp0 - tmp2;\n\n    tmp13 = tmp1 + tmp3;\t/* phases 5-3 */\n    tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; /* 2*c4 */\n\n    tmp0 = tmp10 + tmp13;\t/* phase 2 */\n    tmp3 = tmp10 - tmp13;\n    tmp1 = tmp11 + tmp12;\n    tmp2 = tmp11 - tmp12;\n    \n    /* Odd part */\n\n    tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);\n    tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);\n    tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);\n    tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);\n\n    z13 = tmp6 + tmp5;\t\t/* phase 6 */\n    z10 = tmp6 - tmp5;\n    z11 = tmp4 + tmp7;\n    z12 = tmp4 - tmp7;\n\n    tmp7 = z11 + z13;\t\t/* phase 5 */\n    tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */\n\n    z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */\n    tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */\n    tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */\n\n    tmp6 = tmp12 - tmp7;\t/* phase 2 */\n    tmp5 = tmp11 - tmp6;\n    tmp4 = tmp10 + tmp5;\n\n    wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7);\n    wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7);\n    wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6);\n    wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6);\n    wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5);\n    wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5);\n    wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4);\n    wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4);\n\n    inptr++;\t\t\t/* advance pointers to next column */\n    quantptr++;\n    wsptr++;\n  }\n  \n  /* Pass 2: process rows from work array, store into output array. */\n  /* Note that we must descale the results by a factor of 8 == 2**3, */\n  /* and also undo the PASS1_BITS scaling. */\n\n  wsptr = workspace;\n  for (ctr = 0; ctr < DCTSIZE; ctr++) {\n    outptr = output_buf[ctr] + output_col;\n    /* Rows of zeroes can be exploited in the same way as we did with columns.\n     * However, the column calculation has created many nonzero AC terms, so\n     * the simplification applies less often (typically 5% to 10% of the time).\n     * On machines with very fast multiplication, it's possible that the\n     * test takes more time than it's worth.  In that case this section\n     * may be commented out.\n     */\n    \n#ifndef NO_ZERO_ROW_TEST\n    if ((wsptr[1] | wsptr[2] | wsptr[3] | wsptr[4] | wsptr[5] | wsptr[6] |\n\t wsptr[7]) == 0) {\n      /* AC terms all zero */\n      JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3)\n\t\t\t\t  & RANGE_MASK];\n      \n      outptr[0] = dcval;\n      outptr[1] = dcval;\n      outptr[2] = dcval;\n      outptr[3] = dcval;\n      outptr[4] = dcval;\n      outptr[5] = dcval;\n      outptr[6] = dcval;\n      outptr[7] = dcval;\n\n      wsptr += DCTSIZE;\t\t/* advance pointer to next row */\n      continue;\n    }\n#endif\n    \n    /* Even part */\n\n    tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]);\n    tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]);\n\n    tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]);\n    tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6], FIX_1_414213562)\n\t    - tmp13;\n\n    tmp0 = tmp10 + tmp13;\n    tmp3 = tmp10 - tmp13;\n    tmp1 = tmp11 + tmp12;\n    tmp2 = tmp11 - tmp12;\n\n    /* Odd part */\n\n    z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3];\n    z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3];\n    z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7];\n    z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7];\n\n    tmp7 = z11 + z13;\t\t/* phase 5 */\n    tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */\n\n    z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */\n    tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */\n    tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */\n\n    tmp6 = tmp12 - tmp7;\t/* phase 2 */\n    tmp5 = tmp11 - tmp6;\n    tmp4 = tmp10 + tmp5;\n\n    /* Final output stage: scale down by a factor of 8 and range-limit */\n\n    outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3)\n\t\t\t    & RANGE_MASK];\n    outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3)\n\t\t\t    & RANGE_MASK];\n    outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3)\n\t\t\t    & RANGE_MASK];\n    outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3)\n\t\t\t    & RANGE_MASK];\n    outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3)\n\t\t\t    & RANGE_MASK];\n    outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3)\n\t\t\t    & RANGE_MASK];\n    outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3)\n\t\t\t    & RANGE_MASK];\n    outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3)\n\t\t\t    & RANGE_MASK];\n\n    wsptr += DCTSIZE;\t\t/* advance pointer to next row */\n  }\n}\n\n#endif /* DCT_IFAST_SUPPORTED */\n"
  },
  {
    "path": "code/jpeg-6/jidctint.c",
    "content": "/*\n * jidctint.c\n *\n * Copyright (C) 1991-1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains a slow-but-accurate integer implementation of the\n * inverse DCT (Discrete Cosine Transform).  In the IJG code, this routine\n * must also perform dequantization of the input coefficients.\n *\n * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT\n * on each row (or vice versa, but it's more convenient to emit a row at\n * a time).  Direct algorithms are also available, but they are much more\n * complex and seem not to be any faster when reduced to code.\n *\n * This implementation is based on an algorithm described in\n *   C. Loeffler, A. Ligtenberg and G. Moschytz, \"Practical Fast 1-D DCT\n *   Algorithms with 11 Multiplications\", Proc. Int'l. Conf. on Acoustics,\n *   Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991.\n * The primary algorithm described there uses 11 multiplies and 29 adds.\n * We use their alternate method with 12 multiplies and 32 adds.\n * The advantage of this method is that no data path contains more than one\n * multiplication; this allows a very simple and accurate implementation in\n * scaled fixed-point arithmetic, with a minimal number of shifts.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jdct.h\"\t\t/* Private declarations for DCT subsystem */\n\n#ifdef DCT_ISLOW_SUPPORTED\n\n\n/*\n * This module is specialized to the case DCTSIZE = 8.\n */\n\n#if DCTSIZE != 8\n  Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */\n#endif\n\n\n/*\n * The poop on this scaling stuff is as follows:\n *\n * Each 1-D IDCT step produces outputs which are a factor of sqrt(N)\n * larger than the true IDCT outputs.  The final outputs are therefore\n * a factor of N larger than desired; since N=8 this can be cured by\n * a simple right shift at the end of the algorithm.  The advantage of\n * this arrangement is that we save two multiplications per 1-D IDCT,\n * because the y0 and y4 inputs need not be divided by sqrt(N).\n *\n * We have to do addition and subtraction of the integer inputs, which\n * is no problem, and multiplication by fractional constants, which is\n * a problem to do in integer arithmetic.  We multiply all the constants\n * by CONST_SCALE and convert them to integer constants (thus retaining\n * CONST_BITS bits of precision in the constants).  After doing a\n * multiplication we have to divide the product by CONST_SCALE, with proper\n * rounding, to produce the correct output.  This division can be done\n * cheaply as a right shift of CONST_BITS bits.  We postpone shifting\n * as long as possible so that partial sums can be added together with\n * full fractional precision.\n *\n * The outputs of the first pass are scaled up by PASS1_BITS bits so that\n * they are represented to better-than-integral precision.  These outputs\n * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word\n * with the recommended scaling.  (To scale up 12-bit sample data further, an\n * intermediate INT32 array would be needed.)\n *\n * To avoid overflow of the 32-bit intermediate results in pass 2, we must\n * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26.  Error analysis\n * shows that the values given below are the most effective.\n */\n\n#if BITS_IN_JSAMPLE == 8\n#define CONST_BITS  13\n#define PASS1_BITS  2\n#else\n#define CONST_BITS  13\n#define PASS1_BITS  1\t\t/* lose a little precision to avoid overflow */\n#endif\n\n/* Some C compilers fail to reduce \"FIX(constant)\" at compile time, thus\n * causing a lot of useless floating-point operations at run time.\n * To get around this we use the following pre-calculated constants.\n * If you change CONST_BITS you may want to add appropriate values.\n * (With a reasonable C compiler, you can just rely on the FIX() macro...)\n */\n\n#if CONST_BITS == 13\n#define FIX_0_298631336  ((INT32)  2446)\t/* FIX(0.298631336) */\n#define FIX_0_390180644  ((INT32)  3196)\t/* FIX(0.390180644) */\n#define FIX_0_541196100  ((INT32)  4433)\t/* FIX(0.541196100) */\n#define FIX_0_765366865  ((INT32)  6270)\t/* FIX(0.765366865) */\n#define FIX_0_899976223  ((INT32)  7373)\t/* FIX(0.899976223) */\n#define FIX_1_175875602  ((INT32)  9633)\t/* FIX(1.175875602) */\n#define FIX_1_501321110  ((INT32)  12299)\t/* FIX(1.501321110) */\n#define FIX_1_847759065  ((INT32)  15137)\t/* FIX(1.847759065) */\n#define FIX_1_961570560  ((INT32)  16069)\t/* FIX(1.961570560) */\n#define FIX_2_053119869  ((INT32)  16819)\t/* FIX(2.053119869) */\n#define FIX_2_562915447  ((INT32)  20995)\t/* FIX(2.562915447) */\n#define FIX_3_072711026  ((INT32)  25172)\t/* FIX(3.072711026) */\n#else\n#define FIX_0_298631336  FIX(0.298631336)\n#define FIX_0_390180644  FIX(0.390180644)\n#define FIX_0_541196100  FIX(0.541196100)\n#define FIX_0_765366865  FIX(0.765366865)\n#define FIX_0_899976223  FIX(0.899976223)\n#define FIX_1_175875602  FIX(1.175875602)\n#define FIX_1_501321110  FIX(1.501321110)\n#define FIX_1_847759065  FIX(1.847759065)\n#define FIX_1_961570560  FIX(1.961570560)\n#define FIX_2_053119869  FIX(2.053119869)\n#define FIX_2_562915447  FIX(2.562915447)\n#define FIX_3_072711026  FIX(3.072711026)\n#endif\n\n\n/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.\n * For 8-bit samples with the recommended scaling, all the variable\n * and constant values involved are no more than 16 bits wide, so a\n * 16x16->32 bit multiply can be used instead of a full 32x32 multiply.\n * For 12-bit samples, a full 32-bit multiplication will be needed.\n */\n\n#if BITS_IN_JSAMPLE == 8\n#define MULTIPLY(var,const)  MULTIPLY16C16(var,const)\n#else\n#define MULTIPLY(var,const)  ((var) * (const))\n#endif\n\n\n/* Dequantize a coefficient by multiplying it by the multiplier-table\n * entry; produce an int result.  In this module, both inputs and result\n * are 16 bits or less, so either int or short multiply will work.\n */\n\n#define DEQUANTIZE(coef,quantval)  (((ISLOW_MULT_TYPE) (coef)) * (quantval))\n\n\n/*\n * Perform dequantization and inverse DCT on one block of coefficients.\n */\n\nGLOBAL void\njpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t\t JCOEFPTR coef_block,\n\t\t JSAMPARRAY output_buf, JDIMENSION output_col)\n{\n  INT32 tmp0, tmp1, tmp2, tmp3;\n  INT32 tmp10, tmp11, tmp12, tmp13;\n  INT32 z1, z2, z3, z4, z5;\n  JCOEFPTR inptr;\n  ISLOW_MULT_TYPE * quantptr;\n  int * wsptr;\n  JSAMPROW outptr;\n  JSAMPLE *range_limit = IDCT_range_limit(cinfo);\n  int ctr;\n  int workspace[DCTSIZE2];\t/* buffers data between passes */\n  SHIFT_TEMPS\n\n  /* Pass 1: process columns from input, store into work array. */\n  /* Note results are scaled up by sqrt(8) compared to a true IDCT; */\n  /* furthermore, we scale the results by 2**PASS1_BITS. */\n\n  inptr = coef_block;\n  quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;\n  wsptr = workspace;\n  for (ctr = DCTSIZE; ctr > 0; ctr--) {\n    /* Due to quantization, we will usually find that many of the input\n     * coefficients are zero, especially the AC terms.  We can exploit this\n     * by short-circuiting the IDCT calculation for any column in which all\n     * the AC terms are zero.  In that case each output is equal to the\n     * DC coefficient (with scale factor as needed).\n     * With typical images and quantization tables, half or more of the\n     * column DCT calculations can be simplified this way.\n     */\n    \n    if ((inptr[DCTSIZE*1] | inptr[DCTSIZE*2] | inptr[DCTSIZE*3] |\n\t inptr[DCTSIZE*4] | inptr[DCTSIZE*5] | inptr[DCTSIZE*6] |\n\t inptr[DCTSIZE*7]) == 0) {\n      /* AC terms all zero */\n      int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS;\n      \n      wsptr[DCTSIZE*0] = dcval;\n      wsptr[DCTSIZE*1] = dcval;\n      wsptr[DCTSIZE*2] = dcval;\n      wsptr[DCTSIZE*3] = dcval;\n      wsptr[DCTSIZE*4] = dcval;\n      wsptr[DCTSIZE*5] = dcval;\n      wsptr[DCTSIZE*6] = dcval;\n      wsptr[DCTSIZE*7] = dcval;\n      \n      inptr++;\t\t\t/* advance pointers to next column */\n      quantptr++;\n      wsptr++;\n      continue;\n    }\n    \n    /* Even part: reverse the even part of the forward DCT. */\n    /* The rotator is sqrt(2)*c(-6). */\n    \n    z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);\n    z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);\n    \n    z1 = MULTIPLY(z2 + z3, FIX_0_541196100);\n    tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065);\n    tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865);\n    \n    z2 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);\n    z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);\n\n    tmp0 = (z2 + z3) << CONST_BITS;\n    tmp1 = (z2 - z3) << CONST_BITS;\n    \n    tmp10 = tmp0 + tmp3;\n    tmp13 = tmp0 - tmp3;\n    tmp11 = tmp1 + tmp2;\n    tmp12 = tmp1 - tmp2;\n    \n    /* Odd part per figure 8; the matrix is unitary and hence its\n     * transpose is its inverse.  i0..i3 are y7,y5,y3,y1 respectively.\n     */\n    \n    tmp0 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);\n    tmp1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);\n    tmp2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);\n    tmp3 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);\n    \n    z1 = tmp0 + tmp3;\n    z2 = tmp1 + tmp2;\n    z3 = tmp0 + tmp2;\n    z4 = tmp1 + tmp3;\n    z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */\n    \n    tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */\n    tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */\n    tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */\n    tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */\n    z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */\n    z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */\n    z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */\n    z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */\n    \n    z3 += z5;\n    z4 += z5;\n    \n    tmp0 += z1 + z3;\n    tmp1 += z2 + z4;\n    tmp2 += z2 + z3;\n    tmp3 += z1 + z4;\n    \n    /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */\n    \n    wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS);\n    wsptr[DCTSIZE*7] = (int) DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS);\n    wsptr[DCTSIZE*1] = (int) DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS);\n    wsptr[DCTSIZE*6] = (int) DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS);\n    wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS);\n    wsptr[DCTSIZE*5] = (int) DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS);\n    wsptr[DCTSIZE*3] = (int) DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS);\n    wsptr[DCTSIZE*4] = (int) DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS);\n    \n    inptr++;\t\t\t/* advance pointers to next column */\n    quantptr++;\n    wsptr++;\n  }\n  \n  /* Pass 2: process rows from work array, store into output array. */\n  /* Note that we must descale the results by a factor of 8 == 2**3, */\n  /* and also undo the PASS1_BITS scaling. */\n\n  wsptr = workspace;\n  for (ctr = 0; ctr < DCTSIZE; ctr++) {\n    outptr = output_buf[ctr] + output_col;\n    /* Rows of zeroes can be exploited in the same way as we did with columns.\n     * However, the column calculation has created many nonzero AC terms, so\n     * the simplification applies less often (typically 5% to 10% of the time).\n     * On machines with very fast multiplication, it's possible that the\n     * test takes more time than it's worth.  In that case this section\n     * may be commented out.\n     */\n    \n#ifndef NO_ZERO_ROW_TEST\n    if ((wsptr[1] | wsptr[2] | wsptr[3] | wsptr[4] | wsptr[5] | wsptr[6] |\n\t wsptr[7]) == 0) {\n      /* AC terms all zero */\n      JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3)\n\t\t\t\t  & RANGE_MASK];\n      \n      outptr[0] = dcval;\n      outptr[1] = dcval;\n      outptr[2] = dcval;\n      outptr[3] = dcval;\n      outptr[4] = dcval;\n      outptr[5] = dcval;\n      outptr[6] = dcval;\n      outptr[7] = dcval;\n\n      wsptr += DCTSIZE;\t\t/* advance pointer to next row */\n      continue;\n    }\n#endif\n    \n    /* Even part: reverse the even part of the forward DCT. */\n    /* The rotator is sqrt(2)*c(-6). */\n    \n    z2 = (INT32) wsptr[2];\n    z3 = (INT32) wsptr[6];\n    \n    z1 = MULTIPLY(z2 + z3, FIX_0_541196100);\n    tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065);\n    tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865);\n    \n    tmp0 = ((INT32) wsptr[0] + (INT32) wsptr[4]) << CONST_BITS;\n    tmp1 = ((INT32) wsptr[0] - (INT32) wsptr[4]) << CONST_BITS;\n    \n    tmp10 = tmp0 + tmp3;\n    tmp13 = tmp0 - tmp3;\n    tmp11 = tmp1 + tmp2;\n    tmp12 = tmp1 - tmp2;\n    \n    /* Odd part per figure 8; the matrix is unitary and hence its\n     * transpose is its inverse.  i0..i3 are y7,y5,y3,y1 respectively.\n     */\n    \n    tmp0 = (INT32) wsptr[7];\n    tmp1 = (INT32) wsptr[5];\n    tmp2 = (INT32) wsptr[3];\n    tmp3 = (INT32) wsptr[1];\n    \n    z1 = tmp0 + tmp3;\n    z2 = tmp1 + tmp2;\n    z3 = tmp0 + tmp2;\n    z4 = tmp1 + tmp3;\n    z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */\n    \n    tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */\n    tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */\n    tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */\n    tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */\n    z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */\n    z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */\n    z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */\n    z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */\n    \n    z3 += z5;\n    z4 += z5;\n    \n    tmp0 += z1 + z3;\n    tmp1 += z2 + z4;\n    tmp2 += z2 + z3;\n    tmp3 += z1 + z4;\n    \n    /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */\n    \n    outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp3,\n\t\t\t\t\t  CONST_BITS+PASS1_BITS+3)\n\t\t\t    & RANGE_MASK];\n    outptr[7] = range_limit[(int) DESCALE(tmp10 - tmp3,\n\t\t\t\t\t  CONST_BITS+PASS1_BITS+3)\n\t\t\t    & RANGE_MASK];\n    outptr[1] = range_limit[(int) DESCALE(tmp11 + tmp2,\n\t\t\t\t\t  CONST_BITS+PASS1_BITS+3)\n\t\t\t    & RANGE_MASK];\n    outptr[6] = range_limit[(int) DESCALE(tmp11 - tmp2,\n\t\t\t\t\t  CONST_BITS+PASS1_BITS+3)\n\t\t\t    & RANGE_MASK];\n    outptr[2] = range_limit[(int) DESCALE(tmp12 + tmp1,\n\t\t\t\t\t  CONST_BITS+PASS1_BITS+3)\n\t\t\t    & RANGE_MASK];\n    outptr[5] = range_limit[(int) DESCALE(tmp12 - tmp1,\n\t\t\t\t\t  CONST_BITS+PASS1_BITS+3)\n\t\t\t    & RANGE_MASK];\n    outptr[3] = range_limit[(int) DESCALE(tmp13 + tmp0,\n\t\t\t\t\t  CONST_BITS+PASS1_BITS+3)\n\t\t\t    & RANGE_MASK];\n    outptr[4] = range_limit[(int) DESCALE(tmp13 - tmp0,\n\t\t\t\t\t  CONST_BITS+PASS1_BITS+3)\n\t\t\t    & RANGE_MASK];\n    \n    wsptr += DCTSIZE;\t\t/* advance pointer to next row */\n  }\n}\n\n#endif /* DCT_ISLOW_SUPPORTED */\n"
  },
  {
    "path": "code/jpeg-6/jidctred.c",
    "content": "/*\n * jidctred.c\n *\n * Copyright (C) 1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains inverse-DCT routines that produce reduced-size output:\n * either 4x4, 2x2, or 1x1 pixels from an 8x8 DCT block.\n *\n * The implementation is based on the Loeffler, Ligtenberg and Moschytz (LL&M)\n * algorithm used in jidctint.c.  We simply replace each 8-to-8 1-D IDCT step\n * with an 8-to-4 step that produces the four averages of two adjacent outputs\n * (or an 8-to-2 step producing two averages of four outputs, for 2x2 output).\n * These steps were derived by computing the corresponding values at the end\n * of the normal LL&M code, then simplifying as much as possible.\n *\n * 1x1 is trivial: just take the DC coefficient divided by 8.\n *\n * See jidctint.c for additional comments.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jdct.h\"\t\t/* Private declarations for DCT subsystem */\n\n#ifdef IDCT_SCALING_SUPPORTED\n\n\n/*\n * This module is specialized to the case DCTSIZE = 8.\n */\n\n#if DCTSIZE != 8\n  Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */\n#endif\n\n\n/* Scaling is the same as in jidctint.c. */\n\n#if BITS_IN_JSAMPLE == 8\n#define CONST_BITS  13\n#define PASS1_BITS  2\n#else\n#define CONST_BITS  13\n#define PASS1_BITS  1\t\t/* lose a little precision to avoid overflow */\n#endif\n\n/* Some C compilers fail to reduce \"FIX(constant)\" at compile time, thus\n * causing a lot of useless floating-point operations at run time.\n * To get around this we use the following pre-calculated constants.\n * If you change CONST_BITS you may want to add appropriate values.\n * (With a reasonable C compiler, you can just rely on the FIX() macro...)\n */\n\n#if CONST_BITS == 13\n#define FIX_0_211164243  ((INT32)  1730)\t/* FIX(0.211164243) */\n#define FIX_0_509795579  ((INT32)  4176)\t/* FIX(0.509795579) */\n#define FIX_0_601344887  ((INT32)  4926)\t/* FIX(0.601344887) */\n#define FIX_0_720959822  ((INT32)  5906)\t/* FIX(0.720959822) */\n#define FIX_0_765366865  ((INT32)  6270)\t/* FIX(0.765366865) */\n#define FIX_0_850430095  ((INT32)  6967)\t/* FIX(0.850430095) */\n#define FIX_0_899976223  ((INT32)  7373)\t/* FIX(0.899976223) */\n#define FIX_1_061594337  ((INT32)  8697)\t/* FIX(1.061594337) */\n#define FIX_1_272758580  ((INT32)  10426)\t/* FIX(1.272758580) */\n#define FIX_1_451774981  ((INT32)  11893)\t/* FIX(1.451774981) */\n#define FIX_1_847759065  ((INT32)  15137)\t/* FIX(1.847759065) */\n#define FIX_2_172734803  ((INT32)  17799)\t/* FIX(2.172734803) */\n#define FIX_2_562915447  ((INT32)  20995)\t/* FIX(2.562915447) */\n#define FIX_3_624509785  ((INT32)  29692)\t/* FIX(3.624509785) */\n#else\n#define FIX_0_211164243  FIX(0.211164243)\n#define FIX_0_509795579  FIX(0.509795579)\n#define FIX_0_601344887  FIX(0.601344887)\n#define FIX_0_720959822  FIX(0.720959822)\n#define FIX_0_765366865  FIX(0.765366865)\n#define FIX_0_850430095  FIX(0.850430095)\n#define FIX_0_899976223  FIX(0.899976223)\n#define FIX_1_061594337  FIX(1.061594337)\n#define FIX_1_272758580  FIX(1.272758580)\n#define FIX_1_451774981  FIX(1.451774981)\n#define FIX_1_847759065  FIX(1.847759065)\n#define FIX_2_172734803  FIX(2.172734803)\n#define FIX_2_562915447  FIX(2.562915447)\n#define FIX_3_624509785  FIX(3.624509785)\n#endif\n\n\n/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.\n * For 8-bit samples with the recommended scaling, all the variable\n * and constant values involved are no more than 16 bits wide, so a\n * 16x16->32 bit multiply can be used instead of a full 32x32 multiply.\n * For 12-bit samples, a full 32-bit multiplication will be needed.\n */\n\n#if BITS_IN_JSAMPLE == 8\n#define MULTIPLY(var,const)  MULTIPLY16C16(var,const)\n#else\n#define MULTIPLY(var,const)  ((var) * (const))\n#endif\n\n\n/* Dequantize a coefficient by multiplying it by the multiplier-table\n * entry; produce an int result.  In this module, both inputs and result\n * are 16 bits or less, so either int or short multiply will work.\n */\n\n#define DEQUANTIZE(coef,quantval)  (((ISLOW_MULT_TYPE) (coef)) * (quantval))\n\n\n/*\n * Perform dequantization and inverse DCT on one block of coefficients,\n * producing a reduced-size 4x4 output block.\n */\n\nGLOBAL void\njpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t       JCOEFPTR coef_block,\n\t       JSAMPARRAY output_buf, JDIMENSION output_col)\n{\n  INT32 tmp0, tmp2, tmp10, tmp12;\n  INT32 z1, z2, z3, z4;\n  JCOEFPTR inptr;\n  ISLOW_MULT_TYPE * quantptr;\n  int * wsptr;\n  JSAMPROW outptr;\n  JSAMPLE *range_limit = IDCT_range_limit(cinfo);\n  int ctr;\n  int workspace[DCTSIZE*4];\t/* buffers data between passes */\n  SHIFT_TEMPS\n\n  /* Pass 1: process columns from input, store into work array. */\n\n  inptr = coef_block;\n  quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;\n  wsptr = workspace;\n  for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) {\n    /* Don't bother to process column 4, because second pass won't use it */\n    if (ctr == DCTSIZE-4)\n      continue;\n    if ((inptr[DCTSIZE*1] | inptr[DCTSIZE*2] | inptr[DCTSIZE*3] |\n\t inptr[DCTSIZE*5] | inptr[DCTSIZE*6] | inptr[DCTSIZE*7]) == 0) {\n      /* AC terms all zero; we need not examine term 4 for 4x4 output */\n      int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS;\n      \n      wsptr[DCTSIZE*0] = dcval;\n      wsptr[DCTSIZE*1] = dcval;\n      wsptr[DCTSIZE*2] = dcval;\n      wsptr[DCTSIZE*3] = dcval;\n      \n      continue;\n    }\n    \n    /* Even part */\n    \n    tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);\n    tmp0 <<= (CONST_BITS+1);\n    \n    z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);\n    z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);\n\n    tmp2 = MULTIPLY(z2, FIX_1_847759065) + MULTIPLY(z3, - FIX_0_765366865);\n    \n    tmp10 = tmp0 + tmp2;\n    tmp12 = tmp0 - tmp2;\n    \n    /* Odd part */\n    \n    z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);\n    z2 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);\n    z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);\n    z4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);\n    \n    tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */\n\t + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */\n\t + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */\n\t + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */\n    \n    tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */\n\t + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */\n\t + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */\n\t + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */\n\n    /* Final output stage */\n    \n    wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp2, CONST_BITS-PASS1_BITS+1);\n    wsptr[DCTSIZE*3] = (int) DESCALE(tmp10 - tmp2, CONST_BITS-PASS1_BITS+1);\n    wsptr[DCTSIZE*1] = (int) DESCALE(tmp12 + tmp0, CONST_BITS-PASS1_BITS+1);\n    wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 - tmp0, CONST_BITS-PASS1_BITS+1);\n  }\n  \n  /* Pass 2: process 4 rows from work array, store into output array. */\n\n  wsptr = workspace;\n  for (ctr = 0; ctr < 4; ctr++) {\n    outptr = output_buf[ctr] + output_col;\n    /* It's not clear whether a zero row test is worthwhile here ... */\n\n#ifndef NO_ZERO_ROW_TEST\n    if ((wsptr[1] | wsptr[2] | wsptr[3] | wsptr[5] | wsptr[6] |\n\t wsptr[7]) == 0) {\n      /* AC terms all zero */\n      JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3)\n\t\t\t\t  & RANGE_MASK];\n      \n      outptr[0] = dcval;\n      outptr[1] = dcval;\n      outptr[2] = dcval;\n      outptr[3] = dcval;\n      \n      wsptr += DCTSIZE;\t\t/* advance pointer to next row */\n      continue;\n    }\n#endif\n    \n    /* Even part */\n    \n    tmp0 = ((INT32) wsptr[0]) << (CONST_BITS+1);\n    \n    tmp2 = MULTIPLY((INT32) wsptr[2], FIX_1_847759065)\n\t + MULTIPLY((INT32) wsptr[6], - FIX_0_765366865);\n    \n    tmp10 = tmp0 + tmp2;\n    tmp12 = tmp0 - tmp2;\n    \n    /* Odd part */\n    \n    z1 = (INT32) wsptr[7];\n    z2 = (INT32) wsptr[5];\n    z3 = (INT32) wsptr[3];\n    z4 = (INT32) wsptr[1];\n    \n    tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */\n\t + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */\n\t + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */\n\t + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */\n    \n    tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */\n\t + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */\n\t + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */\n\t + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */\n\n    /* Final output stage */\n    \n    outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp2,\n\t\t\t\t\t  CONST_BITS+PASS1_BITS+3+1)\n\t\t\t    & RANGE_MASK];\n    outptr[3] = range_limit[(int) DESCALE(tmp10 - tmp2,\n\t\t\t\t\t  CONST_BITS+PASS1_BITS+3+1)\n\t\t\t    & RANGE_MASK];\n    outptr[1] = range_limit[(int) DESCALE(tmp12 + tmp0,\n\t\t\t\t\t  CONST_BITS+PASS1_BITS+3+1)\n\t\t\t    & RANGE_MASK];\n    outptr[2] = range_limit[(int) DESCALE(tmp12 - tmp0,\n\t\t\t\t\t  CONST_BITS+PASS1_BITS+3+1)\n\t\t\t    & RANGE_MASK];\n    \n    wsptr += DCTSIZE;\t\t/* advance pointer to next row */\n  }\n}\n\n\n/*\n * Perform dequantization and inverse DCT on one block of coefficients,\n * producing a reduced-size 2x2 output block.\n */\n\nGLOBAL void\njpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t       JCOEFPTR coef_block,\n\t       JSAMPARRAY output_buf, JDIMENSION output_col)\n{\n  INT32 tmp0, tmp10, z1;\n  JCOEFPTR inptr;\n  ISLOW_MULT_TYPE * quantptr;\n  int * wsptr;\n  JSAMPROW outptr;\n  JSAMPLE *range_limit = IDCT_range_limit(cinfo);\n  int ctr;\n  int workspace[DCTSIZE*2];\t/* buffers data between passes */\n  SHIFT_TEMPS\n\n  /* Pass 1: process columns from input, store into work array. */\n\n  inptr = coef_block;\n  quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;\n  wsptr = workspace;\n  for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) {\n    /* Don't bother to process columns 2,4,6 */\n    if (ctr == DCTSIZE-2 || ctr == DCTSIZE-4 || ctr == DCTSIZE-6)\n      continue;\n    if ((inptr[DCTSIZE*1] | inptr[DCTSIZE*3] |\n\t inptr[DCTSIZE*5] | inptr[DCTSIZE*7]) == 0) {\n      /* AC terms all zero; we need not examine terms 2,4,6 for 2x2 output */\n      int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS;\n      \n      wsptr[DCTSIZE*0] = dcval;\n      wsptr[DCTSIZE*1] = dcval;\n      \n      continue;\n    }\n    \n    /* Even part */\n    \n    z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);\n    tmp10 = z1 << (CONST_BITS+2);\n    \n    /* Odd part */\n\n    z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);\n    tmp0 = MULTIPLY(z1, - FIX_0_720959822); /* sqrt(2) * (c7-c5+c3-c1) */\n    z1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);\n    tmp0 += MULTIPLY(z1, FIX_0_850430095); /* sqrt(2) * (-c1+c3+c5+c7) */\n    z1 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);\n    tmp0 += MULTIPLY(z1, - FIX_1_272758580); /* sqrt(2) * (-c1+c3-c5-c7) */\n    z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);\n    tmp0 += MULTIPLY(z1, FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */\n\n    /* Final output stage */\n    \n    wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp0, CONST_BITS-PASS1_BITS+2);\n    wsptr[DCTSIZE*1] = (int) DESCALE(tmp10 - tmp0, CONST_BITS-PASS1_BITS+2);\n  }\n  \n  /* Pass 2: process 2 rows from work array, store into output array. */\n\n  wsptr = workspace;\n  for (ctr = 0; ctr < 2; ctr++) {\n    outptr = output_buf[ctr] + output_col;\n    /* It's not clear whether a zero row test is worthwhile here ... */\n\n#ifndef NO_ZERO_ROW_TEST\n    if ((wsptr[1] | wsptr[3] | wsptr[5] | wsptr[7]) == 0) {\n      /* AC terms all zero */\n      JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3)\n\t\t\t\t  & RANGE_MASK];\n      \n      outptr[0] = dcval;\n      outptr[1] = dcval;\n      \n      wsptr += DCTSIZE;\t\t/* advance pointer to next row */\n      continue;\n    }\n#endif\n    \n    /* Even part */\n    \n    tmp10 = ((INT32) wsptr[0]) << (CONST_BITS+2);\n    \n    /* Odd part */\n\n    tmp0 = MULTIPLY((INT32) wsptr[7], - FIX_0_720959822) /* sqrt(2) * (c7-c5+c3-c1) */\n\t + MULTIPLY((INT32) wsptr[5], FIX_0_850430095) /* sqrt(2) * (-c1+c3+c5+c7) */\n\t + MULTIPLY((INT32) wsptr[3], - FIX_1_272758580) /* sqrt(2) * (-c1+c3-c5-c7) */\n\t + MULTIPLY((INT32) wsptr[1], FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */\n\n    /* Final output stage */\n    \n    outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp0,\n\t\t\t\t\t  CONST_BITS+PASS1_BITS+3+2)\n\t\t\t    & RANGE_MASK];\n    outptr[1] = range_limit[(int) DESCALE(tmp10 - tmp0,\n\t\t\t\t\t  CONST_BITS+PASS1_BITS+3+2)\n\t\t\t    & RANGE_MASK];\n    \n    wsptr += DCTSIZE;\t\t/* advance pointer to next row */\n  }\n}\n\n\n/*\n * Perform dequantization and inverse DCT on one block of coefficients,\n * producing a reduced-size 1x1 output block.\n */\n\nGLOBAL void\njpeg_idct_1x1 (j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t       JCOEFPTR coef_block,\n\t       JSAMPARRAY output_buf, JDIMENSION output_col)\n{\n  int dcval;\n  ISLOW_MULT_TYPE * quantptr;\n  JSAMPLE *range_limit = IDCT_range_limit(cinfo);\n  SHIFT_TEMPS\n\n  /* We hardly need an inverse DCT routine for this: just take the\n   * average pixel value, which is one-eighth of the DC coefficient.\n   */\n  quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;\n  dcval = DEQUANTIZE(coef_block[0], quantptr[0]);\n  dcval = (int) DESCALE((INT32) dcval, 3);\n\n  output_buf[0][output_col] = range_limit[dcval & RANGE_MASK];\n}\n\n#endif /* IDCT_SCALING_SUPPORTED */\n"
  },
  {
    "path": "code/jpeg-6/jinclude.h",
    "content": "/*\n * jinclude.h\n *\n * Copyright (C) 1991-1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file exists to provide a single place to fix any problems with\n * including the wrong system include files.  (Common problems are taken\n * care of by the standard jconfig symbols, but on really weird systems\n * you may have to edit this file.)\n *\n * NOTE: this file is NOT intended to be included by applications using the\n * JPEG library.  Most applications need only include jpeglib.h.\n */\n\n\n#ifdef _WIN32\n\n#pragma warning(disable : 4018)     // signed/unsigned mismatch\n#pragma warning(disable : 4032)\n#pragma warning(disable : 4051)\n#pragma warning(disable : 4057)\t\t// slightly different base types\n#pragma warning(disable : 4100)\t\t// unreferenced formal parameter\n#pragma warning(disable : 4115)\n#pragma warning(disable : 4125)\t\t// decimal digit terminates octal escape sequence\n#pragma warning(disable : 4127)\t\t// conditional expression is constant\n#pragma warning(disable : 4136)\n#pragma warning(disable : 4152)\t\t// nonstandard extension, function/data pointer conversion in expression\n#pragma warning(disable : 4201)\n#pragma warning(disable : 4214)\n#pragma warning(disable : 4244)\n#pragma warning(disable : 4305)\t\t// truncation from const double to float\n#pragma warning(disable : 4310)\t\t// cast truncates constant value\n#pragma warning(disable:  4505) \t// unreferenced local function has been removed\n#pragma warning(disable : 4514)\n#pragma warning(disable : 4702)\t\t// unreachable code\n#pragma warning(disable : 4711)\t\t// selected for automatic inline expansion\n#pragma warning(disable : 4220)\t\t// varargs matches remaining parameters\n#pragma warning(disable : 4761)\t\t// integral size mismatch \n#endif\n\n/* Include auto-config file to find out which system include files we need. */\n\n#include \"../jpeg-6/jconfig.h\"\t\t/* auto configuration options */\n#define JCONFIG_INCLUDED\t/* so that jpeglib.h doesn't do it again */\n\n/*\n * We need the NULL macro and size_t typedef.\n * On an ANSI-conforming system it is sufficient to include <stddef.h>.\n * Otherwise, we get them from <stdlib.h> or <stdio.h>; we may have to\n * pull in <sys/types.h> as well.\n * Note that the core JPEG library does not require <stdio.h>;\n * only the default error handler and data source/destination modules do.\n * But we must pull it in because of the references to FILE in jpeglib.h.\n * You can remove those references if you want to compile without <stdio.h>.\n */\n\n#ifdef HAVE_STDDEF_H\n#include <stddef.h>\n#endif\n\n#ifdef HAVE_STDLIB_H\n#include <stdlib.h>\n#endif\n\n#ifdef NEED_SYS_TYPES_H\n#include <sys/types.h>\n#endif\n\n#include <stdio.h>\n\n/*\n * We need memory copying and zeroing functions, plus strncpy().\n * ANSI and System V implementations declare these in <string.h>.\n * BSD doesn't have the mem() functions, but it does have bcopy()/bzero().\n * Some systems may declare memset and memcpy in <memory.h>.\n *\n * NOTE: we assume the size parameters to these functions are of type size_t.\n * Change the casts in these macros if not!\n */\n\n#ifdef NEED_BSD_STRINGS\n\n#include <strings.h>\n#define MEMZERO(target,size)\tbzero((void *)(target), (size_t)(size))\n#define MEMCOPY(dest,src,size)\tbcopy((const void *)(src), (void *)(dest), (size_t)(size))\n\n#else /* not BSD, assume ANSI/SysV string lib */\n\n#include <string.h>\n#define MEMZERO(target,size)\tmemset((void *)(target), 0, (size_t)(size))\n#define MEMCOPY(dest,src,size)\tmemcpy((void *)(dest), (const void *)(src), (size_t)(size))\n\n#endif\n\n/*\n * In ANSI C, and indeed any rational implementation, size_t is also the\n * type returned by sizeof().  However, it seems there are some irrational\n * implementations out there, in which sizeof() returns an int even though\n * size_t is defined as long or unsigned long.  To ensure consistent results\n * we always use this SIZEOF() macro in place of using sizeof() directly.\n */\n\n#define SIZEOF(object)\t((size_t) sizeof(object))\n\n/*\n * The modules that use fread() and fwrite() always invoke them through\n * these macros.  On some systems you may need to twiddle the argument casts.\n * CAUTION: argument order is different from underlying functions!\n */\n\n#define JFREAD(file,buf,sizeofbuf)  \\\n  ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))\n#define JFWRITE(file,buf,sizeofbuf)  \\\n  ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))\n"
  },
  {
    "path": "code/jpeg-6/jload.c",
    "content": "\n#include \"../game/q_shared.h\"\n#include \"../qcommon/qcommon.h\"\n\n/*\n * Include file for users of JPEG library.\n * You will need to have included system headers that define at least\n * the typedefs FILE and size_t before you can include jpeglib.h.\n * (stdio.h is sufficient on ANSI-conforming systems.)\n * You may also wish to include \"jerror.h\".\n */\n\n#include \"jpeglib.h\"\n\n\nint LoadJPG( const char *filename, unsigned char **pic, int *width, int *height ) {\n  /* This struct contains the JPEG decompression parameters and pointers to\n   * working space (which is allocated as needed by the JPEG library).\n   */\n  struct jpeg_decompress_struct cinfo;\n  /* We use our private extension JPEG error handler.\n   * Note that this struct must live as long as the main JPEG parameter\n   * struct, to avoid dangling-pointer problems.\n   */\n  /* This struct represents a JPEG error handler.  It is declared separately\n   * because applications often want to supply a specialized error handler\n   * (see the second half of this file for an example).  But here we just\n   * take the easy way out and use the standard error handler, which will\n   * print a message on stderr and call exit() if compression fails.\n   * Note that this struct must live as long as the main JPEG parameter\n   * struct, to avoid dangling-pointer problems.\n   */\n  struct jpeg_error_mgr jerr;\n  /* More stuff */\n  fileHandle_t infile;\t\t/* source file */\n  JSAMPARRAY buffer;\t\t/* Output row buffer */\n  int row_stride;\t\t/* physical row width in output buffer */\n  unsigned char *out;\n\n  /* In this example we want to open the input file before doing anything else,\n   * so that the setjmp() error recovery below can assume the file is open.\n   * VERY IMPORTANT: use \"b\" option to fopen() if you are on a machine that\n   * requires it in order to read binary files.\n   */\n\n  FS_FOpenFileRead( filename, &infile, qfalse );\n  if (infile == 0) {\n    return 0;\n  }\n\n  /* Step 1: allocate and initialize JPEG decompression object */\n\n  /* We have to set up the error handler first, in case the initialization\n   * step fails.  (Unlikely, but it could happen if you are out of memory.)\n   * This routine fills in the contents of struct jerr, and returns jerr's\n   * address which we place into the link field in cinfo.\n   */\n  cinfo.err = jpeg_std_error(&jerr);\n\n  /* Now we can initialize the JPEG decompression object. */\n  jpeg_create_decompress(&cinfo);\n\n  /* Step 2: specify data source (eg, a file) */\n\n  jpeg_stdio_src(&cinfo, infile);\n\n  /* Step 3: read file parameters with jpeg_read_header() */\n\n  (void) jpeg_read_header(&cinfo, TRUE);\n  /* We can ignore the return value from jpeg_read_header since\n   *   (a) suspension is not possible with the stdio data source, and\n   *   (b) we passed TRUE to reject a tables-only JPEG file as an error.\n   * See libjpeg.doc for more info.\n   */\n\n  /* Step 4: set parameters for decompression */\n\n  /* In this example, we don't need to change any of the defaults set by\n   * jpeg_read_header(), so we do nothing here.\n   */\n\n  /* Step 5: Start decompressor */\n\n  (void) jpeg_start_decompress(&cinfo);\n  /* We can ignore the return value since suspension is not possible\n   * with the stdio data source.\n   */\n\n  /* We may need to do some setup of our own at this point before reading\n   * the data.  After jpeg_start_decompress() we have the correct scaled\n   * output image dimensions available, as well as the output colormap\n   * if we asked for color quantization.\n   * In this example, we need to make an output work buffer of the right size.\n   */ \n  /* JSAMPLEs per row in output buffer */\n  row_stride = cinfo.output_width * cinfo.output_components;\n\n  out = Z_Malloc(cinfo.output_width*cinfo.output_height*cinfo.output_components);\n\n  *pic = out;\n  *width = cinfo.output_width;\n  *height = cinfo.output_height;\n\n  /* Step 6: while (scan lines remain to be read) */\n  /*           jpeg_read_scanlines(...); */\n\n  /* Here we use the library's state variable cinfo.output_scanline as the\n   * loop counter, so that we don't have to keep track ourselves.\n   */\n  while (cinfo.output_scanline < cinfo.output_height) {\n    /* jpeg_read_scanlines expects an array of pointers to scanlines.\n     * Here the array is only one element long, but you could ask for\n     * more than one scanline at a time if that's more convenient.\n     */\n\tbuffer = (JSAMPARRAY)out+(row_stride*cinfo.output_scanline);\n    (void) jpeg_read_scanlines(&cinfo, buffer, 1);\n  }\n\n  /* Step 7: Finish decompression */\n\n  (void) jpeg_finish_decompress(&cinfo);\n  /* We can ignore the return value since suspension is not possible\n   * with the stdio data source.\n   */\n\n  /* Step 8: Release JPEG decompression object */\n\n  /* This is an important step since it will release a good deal of memory. */\n  jpeg_destroy_decompress(&cinfo);\n\n  /* After finish_decompress, we can close the input file.\n   * Here we postpone it until after no more JPEG errors are possible,\n   * so as to simplify the setjmp error logic above.  (Actually, I don't\n   * think that jpeg_destroy can do an error exit, but why assume anything...)\n   */\n  FS_FCloseFile(infile);\n\n  /* At this point you may want to check to see whether any corrupt-data\n   * warnings occurred (test whether jerr.pub.num_warnings is nonzero).\n   */\n\n  /* And we're done! */\n  return 1;\n}\n\n"
  },
  {
    "path": "code/jpeg-6/jmemansi.c",
    "content": "/*\n * jmemansi.c\n *\n * Copyright (C) 1992-1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file provides a simple generic implementation of the system-\n * dependent portion of the JPEG memory manager.  This implementation\n * assumes that you have the ANSI-standard library routine tmpfile().\n * Also, the problem of determining the amount of memory available\n * is shoved onto the user.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jmemsys.h\"\t\t/* import the system-dependent declarations */\n\n#ifndef HAVE_STDLIB_H\t\t/* <stdlib.h> should declare malloc(),free() */\nextern void * malloc JPP((size_t size));\nextern void free JPP((void *ptr));\n#endif\n\n#ifndef SEEK_SET\t\t/* pre-ANSI systems may not define this; */\n#define SEEK_SET  0\t\t/* if not, assume 0 is correct */\n#endif\n\n\n/*\n * Memory allocation and freeing are controlled by the regular library\n * routines malloc() and free().\n */\n\nGLOBAL void *\njpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)\n{\n  return (void *) malloc(sizeofobject);\n}\n\nGLOBAL void\njpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)\n{\n  free(object);\n}\n\n\n/*\n * \"Large\" objects are treated the same as \"small\" ones.\n * NB: although we include FAR keywords in the routine declarations,\n * this file won't actually work in 80x86 small/medium model; at least,\n * you probably won't be able to process useful-size images in only 64KB.\n */\n\nGLOBAL void FAR *\njpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)\n{\n  return (void FAR *) malloc(sizeofobject);\n}\n\nGLOBAL void\njpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)\n{\n  free(object);\n}\n\n\n/*\n * This routine computes the total memory space available for allocation.\n * It's impossible to do this in a portable way; our current solution is\n * to make the user tell us (with a default value set at compile time).\n * If you can actually get the available space, it's a good idea to subtract\n * a slop factor of 5% or so.\n */\n\n#ifndef DEFAULT_MAX_MEM\t\t/* so can override from makefile */\n#define DEFAULT_MAX_MEM\t\t1000000L /* default: one megabyte */\n#endif\n\nGLOBAL long\njpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,\n\t\t    long max_bytes_needed, long already_allocated)\n{\n  return cinfo->mem->max_memory_to_use - already_allocated;\n}\n\n\n/*\n * Backing store (temporary file) management.\n * Backing store objects are only used when the value returned by\n * jpeg_mem_available is less than the total space needed.  You can dispense\n * with these routines if you have plenty of virtual memory; see jmemnobs.c.\n */\n\n\nMETHODDEF void\nread_backing_store (j_common_ptr cinfo, backing_store_ptr info,\n\t\t    void FAR * buffer_address,\n\t\t    long file_offset, long byte_count)\n{\n  if (fseek(info->temp_file, file_offset, SEEK_SET))\n    ERREXIT(cinfo, JERR_TFILE_SEEK);\n  if (JFREAD(info->temp_file, buffer_address, byte_count)\n      != (size_t) byte_count)\n    ERREXIT(cinfo, JERR_TFILE_READ);\n}\n\n\nMETHODDEF void\nwrite_backing_store (j_common_ptr cinfo, backing_store_ptr info,\n\t\t     void FAR * buffer_address,\n\t\t     long file_offset, long byte_count)\n{\n  if (fseek(info->temp_file, file_offset, SEEK_SET))\n    ERREXIT(cinfo, JERR_TFILE_SEEK);\n  if (JFWRITE(info->temp_file, buffer_address, byte_count)\n      != (size_t) byte_count)\n    ERREXIT(cinfo, JERR_TFILE_WRITE);\n}\n\n\nMETHODDEF void\nclose_backing_store (j_common_ptr cinfo, backing_store_ptr info)\n{\n  fclose(info->temp_file);\n  /* Since this implementation uses tmpfile() to create the file,\n   * no explicit file deletion is needed.\n   */\n}\n\n\n/*\n * Initial opening of a backing-store object.\n *\n * This version uses tmpfile(), which constructs a suitable file name\n * behind the scenes.  We don't have to use info->temp_name[] at all;\n * indeed, we can't even find out the actual name of the temp file.\n */\n\nGLOBAL void\njpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,\n\t\t\t long total_bytes_needed)\n{\n  if ((info->temp_file = tmpfile()) == NULL)\n    ERREXITS(cinfo, JERR_TFILE_CREATE, \"\");\n  info->read_backing_store = read_backing_store;\n  info->write_backing_store = write_backing_store;\n  info->close_backing_store = close_backing_store;\n}\n\n\n/*\n * These routines take care of any system-dependent initialization and\n * cleanup required.\n */\n\nGLOBAL long\njpeg_mem_init (j_common_ptr cinfo)\n{\n  return DEFAULT_MAX_MEM;\t/* default for max_memory_to_use */\n}\n\nGLOBAL void\njpeg_mem_term (j_common_ptr cinfo)\n{\n  /* no work */\n}\n"
  },
  {
    "path": "code/jpeg-6/jmemdos.c",
    "content": "/*\n * jmemdos.c\n *\n * Copyright (C) 1992-1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file provides an MS-DOS-compatible implementation of the system-\n * dependent portion of the JPEG memory manager.  Temporary data can be\n * stored in extended or expanded memory as well as in regular DOS files.\n *\n * If you use this file, you must be sure that NEED_FAR_POINTERS is defined\n * if you compile in a small-data memory model; it should NOT be defined if\n * you use a large-data memory model.  This file is not recommended if you\n * are using a flat-memory-space 386 environment such as DJGCC or Watcom C.\n * Also, this code will NOT work if struct fields are aligned on greater than\n * 2-byte boundaries.\n *\n * Based on code contributed by Ge' Weijers.\n */\n\n/*\n * If you have both extended and expanded memory, you may want to change the\n * order in which they are tried in jopen_backing_store.  On a 286 machine\n * expanded memory is usually faster, since extended memory access involves\n * an expensive protected-mode-and-back switch.  On 386 and better, extended\n * memory is usually faster.  As distributed, the code tries extended memory\n * first (what? not everyone has a 386? :-).\n *\n * You can disable use of extended/expanded memory entirely by altering these\n * definitions or overriding them from the Makefile (eg, -DEMS_SUPPORTED=0).\n */\n\n#ifndef XMS_SUPPORTED\n#define XMS_SUPPORTED  1\n#endif\n#ifndef EMS_SUPPORTED\n#define EMS_SUPPORTED  1\n#endif\n\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jmemsys.h\"\t\t/* import the system-dependent declarations */\n\n#ifndef HAVE_STDLIB_H\t\t/* <stdlib.h> should declare these */\nextern void * malloc JPP((size_t size));\nextern void free JPP((void *ptr));\nextern char * getenv JPP((const char * name));\n#endif\n\n#ifdef NEED_FAR_POINTERS\n\n#ifdef __TURBOC__\n/* These definitions work for Borland C (Turbo C) */\n#include <alloc.h>\t\t/* need farmalloc(), farfree() */\n#define far_malloc(x)\tfarmalloc(x)\n#define far_free(x)\tfarfree(x)\n#else\n/* These definitions work for Microsoft C and compatible compilers */\n#include <malloc.h>\t\t/* need _fmalloc(), _ffree() */\n#define far_malloc(x)\t_fmalloc(x)\n#define far_free(x)\t_ffree(x)\n#endif\n\n#else /* not NEED_FAR_POINTERS */\n\n#define far_malloc(x)\tmalloc(x)\n#define far_free(x)\tfree(x)\n\n#endif /* NEED_FAR_POINTERS */\n\n#ifdef DONT_USE_B_MODE\t\t/* define mode parameters for fopen() */\n#define READ_BINARY\t\"r\"\n#else\n#define READ_BINARY\t\"rb\"\n#endif\n\n#if MAX_ALLOC_CHUNK >= 65535L\t/* make sure jconfig.h got this right */\n  MAX_ALLOC_CHUNK should be less than 64K. /* deliberate syntax error */\n#endif\n\n\n/*\n * Declarations for assembly-language support routines (see jmemdosa.asm).\n *\n * The functions are declared \"far\" as are all pointer arguments;\n * this ensures the assembly source code will work regardless of the\n * compiler memory model.  We assume \"short\" is 16 bits, \"long\" is 32.\n */\n\ntypedef void far * XMSDRIVER;\t/* actually a pointer to code */\ntypedef struct {\t\t/* registers for calling XMS driver */\n\tunsigned short ax, dx, bx;\n\tvoid far * ds_si;\n      } XMScontext;\ntypedef struct {\t\t/* registers for calling EMS driver */\n\tunsigned short ax, dx, bx;\n\tvoid far * ds_si;\n      } EMScontext;\n\nEXTERN short far jdos_open JPP((short far * handle, char far * filename));\nEXTERN short far jdos_close JPP((short handle));\nEXTERN short far jdos_seek JPP((short handle, long offset));\nEXTERN short far jdos_read JPP((short handle, void far * buffer,\n\t\t\t\tunsigned short count));\nEXTERN short far jdos_write JPP((short handle, void far * buffer,\n\t\t\t\t unsigned short count));\nEXTERN void far jxms_getdriver JPP((XMSDRIVER far *));\nEXTERN void far jxms_calldriver JPP((XMSDRIVER, XMScontext far *));\nEXTERN short far jems_available JPP((void));\nEXTERN void far jems_calldriver JPP((EMScontext far *));\n\n\n/*\n * Selection of a file name for a temporary file.\n * This is highly system-dependent, and you may want to customize it.\n */\n\nstatic int next_file_num;\t/* to distinguish among several temp files */\n\nLOCAL void\nselect_file_name (char * fname)\n{\n  const char * env;\n  char * ptr;\n  FILE * tfile;\n\n  /* Keep generating file names till we find one that's not in use */\n  for (;;) {\n    /* Get temp directory name from environment TMP or TEMP variable;\n     * if none, use \".\"\n     */\n    if ((env = (const char *) getenv(\"TMP\")) == NULL)\n      if ((env = (const char *) getenv(\"TEMP\")) == NULL)\n\tenv = \".\";\n    if (*env == '\\0')\t\t/* null string means \".\" */\n      env = \".\";\n    ptr = fname;\t\t/* copy name to fname */\n    while (*env != '\\0')\n      *ptr++ = *env++;\n    if (ptr[-1] != '\\\\' && ptr[-1] != '/')\n      *ptr++ = '\\\\';\t\t/* append backslash if not in env variable */\n    /* Append a suitable file name */\n    next_file_num++;\t\t/* advance counter */\n    sprintf(ptr, \"JPG%03d.TMP\", next_file_num);\n    /* Probe to see if file name is already in use */\n    if ((tfile = fopen(fname, READ_BINARY)) == NULL)\n      break;\n    fclose(tfile);\t\t/* oops, it's there; close tfile & try again */\n  }\n}\n\n\n/*\n * Near-memory allocation and freeing are controlled by the regular library\n * routines malloc() and free().\n */\n\nGLOBAL void *\njpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)\n{\n  return (void *) malloc(sizeofobject);\n}\n\nGLOBAL void\njpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)\n{\n  free(object);\n}\n\n\n/*\n * \"Large\" objects are allocated in far memory, if possible\n */\n\nGLOBAL void FAR *\njpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)\n{\n  return (void FAR *) far_malloc(sizeofobject);\n}\n\nGLOBAL void\njpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)\n{\n  far_free(object);\n}\n\n\n/*\n * This routine computes the total memory space available for allocation.\n * It's impossible to do this in a portable way; our current solution is\n * to make the user tell us (with a default value set at compile time).\n * If you can actually get the available space, it's a good idea to subtract\n * a slop factor of 5% or so.\n */\n\n#ifndef DEFAULT_MAX_MEM\t\t/* so can override from makefile */\n#define DEFAULT_MAX_MEM\t\t300000L /* for total usage about 450K */\n#endif\n\nGLOBAL long\njpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,\n\t\t    long max_bytes_needed, long already_allocated)\n{\n  return cinfo->mem->max_memory_to_use - already_allocated;\n}\n\n\n/*\n * Backing store (temporary file) management.\n * Backing store objects are only used when the value returned by\n * jpeg_mem_available is less than the total space needed.  You can dispense\n * with these routines if you have plenty of virtual memory; see jmemnobs.c.\n */\n\n/*\n * For MS-DOS we support three types of backing storage:\n *   1. Conventional DOS files.  We access these by direct DOS calls rather\n *      than via the stdio package.  This provides a bit better performance,\n *      but the real reason is that the buffers to be read or written are FAR.\n *      The stdio library for small-data memory models can't cope with that.\n *   2. Extended memory, accessed per the XMS V2.0 specification.\n *   3. Expanded memory, accessed per the LIM/EMS 4.0 specification.\n * You'll need copies of those specs to make sense of the related code.\n * The specs are available by Internet FTP from the SIMTEL archives \n * (oak.oakland.edu and its various mirror sites).  See files\n * pub/msdos/microsoft/xms20.arc and pub/msdos/info/limems41.zip.\n */\n\n\n/*\n * Access methods for a DOS file.\n */\n\n\nMETHODDEF void\nread_file_store (j_common_ptr cinfo, backing_store_ptr info,\n\t\t void FAR * buffer_address,\n\t\t long file_offset, long byte_count)\n{\n  if (jdos_seek(info->handle.file_handle, file_offset))\n    ERREXIT(cinfo, JERR_TFILE_SEEK);\n  /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */\n  if (byte_count > 65535L)\t/* safety check */\n    ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK);\n  if (jdos_read(info->handle.file_handle, buffer_address,\n\t\t(unsigned short) byte_count))\n    ERREXIT(cinfo, JERR_TFILE_READ);\n}\n\n\nMETHODDEF void\nwrite_file_store (j_common_ptr cinfo, backing_store_ptr info,\n\t\t  void FAR * buffer_address,\n\t\t  long file_offset, long byte_count)\n{\n  if (jdos_seek(info->handle.file_handle, file_offset))\n    ERREXIT(cinfo, JERR_TFILE_SEEK);\n  /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */\n  if (byte_count > 65535L)\t/* safety check */\n    ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK);\n  if (jdos_write(info->handle.file_handle, buffer_address,\n\t\t (unsigned short) byte_count))\n    ERREXIT(cinfo, JERR_TFILE_WRITE);\n}\n\n\nMETHODDEF void\nclose_file_store (j_common_ptr cinfo, backing_store_ptr info)\n{\n  jdos_close(info->handle.file_handle);\t/* close the file */\n  remove(info->temp_name);\t/* delete the file */\n/* If your system doesn't have remove(), try unlink() instead.\n * remove() is the ANSI-standard name for this function, but\n * unlink() was more common in pre-ANSI systems.\n */\n  TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name);\n}\n\n\nLOCAL boolean\nopen_file_store (j_common_ptr cinfo, backing_store_ptr info,\n\t\t long total_bytes_needed)\n{\n  short handle;\n\n  select_file_name(info->temp_name);\n  if (jdos_open((short far *) & handle, (char far *) info->temp_name)) {\n    /* might as well exit since jpeg_open_backing_store will fail anyway */\n    ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name);\n    return FALSE;\n  }\n  info->handle.file_handle = handle;\n  info->read_backing_store = read_file_store;\n  info->write_backing_store = write_file_store;\n  info->close_backing_store = close_file_store;\n  TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name);\n  return TRUE;\t\t\t/* succeeded */\n}\n\n\n/*\n * Access methods for extended memory.\n */\n\n#if XMS_SUPPORTED\n\nstatic XMSDRIVER xms_driver;\t/* saved address of XMS driver */\n\ntypedef union {\t\t\t/* either long offset or real-mode pointer */\n\tlong offset;\n\tvoid far * ptr;\n      } XMSPTR;\n\ntypedef struct {\t\t/* XMS move specification structure */\n\tlong length;\n\tXMSH src_handle;\n\tXMSPTR src;\n\tXMSH dst_handle;\n\tXMSPTR dst;\n      } XMSspec;\n\n#define ODD(X)\t(((X) & 1L) != 0)\n\n\nMETHODDEF void\nread_xms_store (j_common_ptr cinfo, backing_store_ptr info,\n\t\tvoid FAR * buffer_address,\n\t\tlong file_offset, long byte_count)\n{\n  XMScontext ctx;\n  XMSspec spec;\n  char endbuffer[2];\n\n  /* The XMS driver can't cope with an odd length, so handle the last byte\n   * specially if byte_count is odd.  We don't expect this to be common.\n   */\n\n  spec.length = byte_count & (~ 1L);\n  spec.src_handle = info->handle.xms_handle;\n  spec.src.offset = file_offset;\n  spec.dst_handle = 0;\n  spec.dst.ptr = buffer_address;\n  \n  ctx.ds_si = (void far *) & spec;\n  ctx.ax = 0x0b00;\t\t/* EMB move */\n  jxms_calldriver(xms_driver, (XMScontext far *) & ctx);\n  if (ctx.ax != 1)\n    ERREXIT(cinfo, JERR_XMS_READ);\n\n  if (ODD(byte_count)) {\n    read_xms_store(cinfo, info, (void FAR *) endbuffer,\n\t\t   file_offset + byte_count - 1L, 2L);\n    ((char FAR *) buffer_address)[byte_count - 1L] = endbuffer[0];\n  }\n}\n\n\nMETHODDEF void\nwrite_xms_store (j_common_ptr cinfo, backing_store_ptr info,\n\t\t void FAR * buffer_address,\n\t\t long file_offset, long byte_count)\n{\n  XMScontext ctx;\n  XMSspec spec;\n  char endbuffer[2];\n\n  /* The XMS driver can't cope with an odd length, so handle the last byte\n   * specially if byte_count is odd.  We don't expect this to be common.\n   */\n\n  spec.length = byte_count & (~ 1L);\n  spec.src_handle = 0;\n  spec.src.ptr = buffer_address;\n  spec.dst_handle = info->handle.xms_handle;\n  spec.dst.offset = file_offset;\n\n  ctx.ds_si = (void far *) & spec;\n  ctx.ax = 0x0b00;\t\t/* EMB move */\n  jxms_calldriver(xms_driver, (XMScontext far *) & ctx);\n  if (ctx.ax != 1)\n    ERREXIT(cinfo, JERR_XMS_WRITE);\n\n  if (ODD(byte_count)) {\n    read_xms_store(cinfo, info, (void FAR *) endbuffer,\n\t\t   file_offset + byte_count - 1L, 2L);\n    endbuffer[0] = ((char FAR *) buffer_address)[byte_count - 1L];\n    write_xms_store(cinfo, info, (void FAR *) endbuffer,\n\t\t    file_offset + byte_count - 1L, 2L);\n  }\n}\n\n\nMETHODDEF void\nclose_xms_store (j_common_ptr cinfo, backing_store_ptr info)\n{\n  XMScontext ctx;\n\n  ctx.dx = info->handle.xms_handle;\n  ctx.ax = 0x0a00;\n  jxms_calldriver(xms_driver, (XMScontext far *) & ctx);\n  TRACEMS1(cinfo, 1, JTRC_XMS_CLOSE, info->handle.xms_handle);\n  /* we ignore any error return from the driver */\n}\n\n\nLOCAL boolean\nopen_xms_store (j_common_ptr cinfo, backing_store_ptr info,\n\t\tlong total_bytes_needed)\n{\n  XMScontext ctx;\n\n  /* Get address of XMS driver */\n  jxms_getdriver((XMSDRIVER far *) & xms_driver);\n  if (xms_driver == NULL)\n    return FALSE;\t\t/* no driver to be had */\n\n  /* Get version number, must be >= 2.00 */\n  ctx.ax = 0x0000;\n  jxms_calldriver(xms_driver, (XMScontext far *) & ctx);\n  if (ctx.ax < (unsigned short) 0x0200)\n    return FALSE;\n\n  /* Try to get space (expressed in kilobytes) */\n  ctx.dx = (unsigned short) ((total_bytes_needed + 1023L) >> 10);\n  ctx.ax = 0x0900;\n  jxms_calldriver(xms_driver, (XMScontext far *) & ctx);\n  if (ctx.ax != 1)\n    return FALSE;\n\n  /* Succeeded, save the handle and away we go */\n  info->handle.xms_handle = ctx.dx;\n  info->read_backing_store = read_xms_store;\n  info->write_backing_store = write_xms_store;\n  info->close_backing_store = close_xms_store;\n  TRACEMS1(cinfo, 1, JTRC_XMS_OPEN, ctx.dx);\n  return TRUE;\t\t\t/* succeeded */\n}\n\n#endif /* XMS_SUPPORTED */\n\n\n/*\n * Access methods for expanded memory.\n */\n\n#if EMS_SUPPORTED\n\n/* The EMS move specification structure requires word and long fields aligned\n * at odd byte boundaries.  Some compilers will align struct fields at even\n * byte boundaries.  While it's usually possible to force byte alignment,\n * that causes an overall performance penalty and may pose problems in merging\n * JPEG into a larger application.  Instead we accept some rather dirty code\n * here.  Note this code would fail if the hardware did not allow odd-byte\n * word & long accesses, but all 80x86 CPUs do.\n */\n\ntypedef void far * EMSPTR;\n\ntypedef union {\t\t\t/* EMS move specification structure */\n\tlong length;\t\t/* It's easy to access first 4 bytes */\n\tchar bytes[18];\t\t/* Misaligned fields in here! */\n      } EMSspec;\n\n/* Macros for accessing misaligned fields */\n#define FIELD_AT(spec,offset,type)  (*((type *) &(spec.bytes[offset])))\n#define SRC_TYPE(spec)\t\tFIELD_AT(spec,4,char)\n#define SRC_HANDLE(spec)\tFIELD_AT(spec,5,EMSH)\n#define SRC_OFFSET(spec)\tFIELD_AT(spec,7,unsigned short)\n#define SRC_PAGE(spec)\t\tFIELD_AT(spec,9,unsigned short)\n#define SRC_PTR(spec)\t\tFIELD_AT(spec,7,EMSPTR)\n#define DST_TYPE(spec)\t\tFIELD_AT(spec,11,char)\n#define DST_HANDLE(spec)\tFIELD_AT(spec,12,EMSH)\n#define DST_OFFSET(spec)\tFIELD_AT(spec,14,unsigned short)\n#define DST_PAGE(spec)\t\tFIELD_AT(spec,16,unsigned short)\n#define DST_PTR(spec)\t\tFIELD_AT(spec,14,EMSPTR)\n\n#define EMSPAGESIZE\t16384L\t/* gospel, see the EMS specs */\n\n#define HIBYTE(W)  (((W) >> 8) & 0xFF)\n#define LOBYTE(W)  ((W) & 0xFF)\n\n\nMETHODDEF void\nread_ems_store (j_common_ptr cinfo, backing_store_ptr info,\n\t\tvoid FAR * buffer_address,\n\t\tlong file_offset, long byte_count)\n{\n  EMScontext ctx;\n  EMSspec spec;\n\n  spec.length = byte_count;\n  SRC_TYPE(spec) = 1;\n  SRC_HANDLE(spec) = info->handle.ems_handle;\n  SRC_PAGE(spec)   = (unsigned short) (file_offset / EMSPAGESIZE);\n  SRC_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE);\n  DST_TYPE(spec) = 0;\n  DST_HANDLE(spec) = 0;\n  DST_PTR(spec)    = buffer_address;\n  \n  ctx.ds_si = (void far *) & spec;\n  ctx.ax = 0x5700;\t\t/* move memory region */\n  jems_calldriver((EMScontext far *) & ctx);\n  if (HIBYTE(ctx.ax) != 0)\n    ERREXIT(cinfo, JERR_EMS_READ);\n}\n\n\nMETHODDEF void\nwrite_ems_store (j_common_ptr cinfo, backing_store_ptr info,\n\t\t void FAR * buffer_address,\n\t\t long file_offset, long byte_count)\n{\n  EMScontext ctx;\n  EMSspec spec;\n\n  spec.length = byte_count;\n  SRC_TYPE(spec) = 0;\n  SRC_HANDLE(spec) = 0;\n  SRC_PTR(spec)    = buffer_address;\n  DST_TYPE(spec) = 1;\n  DST_HANDLE(spec) = info->handle.ems_handle;\n  DST_PAGE(spec)   = (unsigned short) (file_offset / EMSPAGESIZE);\n  DST_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE);\n  \n  ctx.ds_si = (void far *) & spec;\n  ctx.ax = 0x5700;\t\t/* move memory region */\n  jems_calldriver((EMScontext far *) & ctx);\n  if (HIBYTE(ctx.ax) != 0)\n    ERREXIT(cinfo, JERR_EMS_WRITE);\n}\n\n\nMETHODDEF void\nclose_ems_store (j_common_ptr cinfo, backing_store_ptr info)\n{\n  EMScontext ctx;\n\n  ctx.ax = 0x4500;\n  ctx.dx = info->handle.ems_handle;\n  jems_calldriver((EMScontext far *) & ctx);\n  TRACEMS1(cinfo, 1, JTRC_EMS_CLOSE, info->handle.ems_handle);\n  /* we ignore any error return from the driver */\n}\n\n\nLOCAL boolean\nopen_ems_store (j_common_ptr cinfo, backing_store_ptr info,\n\t\tlong total_bytes_needed)\n{\n  EMScontext ctx;\n\n  /* Is EMS driver there? */\n  if (! jems_available())\n    return FALSE;\n\n  /* Get status, make sure EMS is OK */\n  ctx.ax = 0x4000;\n  jems_calldriver((EMScontext far *) & ctx);\n  if (HIBYTE(ctx.ax) != 0)\n    return FALSE;\n\n  /* Get version, must be >= 4.0 */\n  ctx.ax = 0x4600;\n  jems_calldriver((EMScontext far *) & ctx);\n  if (HIBYTE(ctx.ax) != 0 || LOBYTE(ctx.ax) < 0x40)\n    return FALSE;\n\n  /* Try to allocate requested space */\n  ctx.ax = 0x4300;\n  ctx.bx = (unsigned short) ((total_bytes_needed + EMSPAGESIZE-1L) / EMSPAGESIZE);\n  jems_calldriver((EMScontext far *) & ctx);\n  if (HIBYTE(ctx.ax) != 0)\n    return FALSE;\n\n  /* Succeeded, save the handle and away we go */\n  info->handle.ems_handle = ctx.dx;\n  info->read_backing_store = read_ems_store;\n  info->write_backing_store = write_ems_store;\n  info->close_backing_store = close_ems_store;\n  TRACEMS1(cinfo, 1, JTRC_EMS_OPEN, ctx.dx);\n  return TRUE;\t\t\t/* succeeded */\n}\n\n#endif /* EMS_SUPPORTED */\n\n\n/*\n * Initial opening of a backing-store object.\n */\n\nGLOBAL void\njpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,\n\t\t\t long total_bytes_needed)\n{\n  /* Try extended memory, then expanded memory, then regular file. */\n#if XMS_SUPPORTED\n  if (open_xms_store(cinfo, info, total_bytes_needed))\n    return;\n#endif\n#if EMS_SUPPORTED\n  if (open_ems_store(cinfo, info, total_bytes_needed))\n    return;\n#endif\n  if (open_file_store(cinfo, info, total_bytes_needed))\n    return;\n  ERREXITS(cinfo, JERR_TFILE_CREATE, \"\");\n}\n\n\n/*\n * These routines take care of any system-dependent initialization and\n * cleanup required.\n */\n\nGLOBAL long\njpeg_mem_init (j_common_ptr cinfo)\n{\n  next_file_num = 0;\t\t/* initialize temp file name generator */\n  return DEFAULT_MAX_MEM;\t/* default for max_memory_to_use */\n}\n\nGLOBAL void\njpeg_mem_term (j_common_ptr cinfo)\n{\n  /* Microsoft C, at least in v6.00A, will not successfully reclaim freed\n   * blocks of size > 32Kbytes unless we give it a kick in the rear, like so:\n   */\n#ifdef NEED_FHEAPMIN\n  _fheapmin();\n#endif\n}\n"
  },
  {
    "path": "code/jpeg-6/jmemmgr.c",
    "content": "/*\n * jmemmgr.c\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains the JPEG system-independent memory management\n * routines.  This code is usable across a wide variety of machines; most\n * of the system dependencies have been isolated in a separate file.\n * The major functions provided here are:\n *   * pool-based allocation and freeing of memory;\n *   * policy decisions about how to divide available memory among the\n *     virtual arrays;\n *   * control logic for swapping virtual arrays between main memory and\n *     backing storage.\n * The separate system-dependent file provides the actual backing-storage\n * access code, and it contains the policy decision about how much total\n * main memory to use.\n * This file is system-dependent in the sense that some of its functions\n * are unnecessary in some systems.  For example, if there is enough virtual\n * memory so that backing storage will never be used, much of the virtual\n * array control logic could be removed.  (Of course, if you have that much\n * memory then you shouldn't care about a little bit of unused code...)\n */\n\n#define JPEG_INTERNALS\n#define AM_MEMORY_MANAGER\t/* we define jvirt_Xarray_control structs */\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jmemsys.h\"\t\t/* import the system-dependent declarations */\n\n#ifndef NO_GETENV\n#ifndef HAVE_STDLIB_H\t\t/* <stdlib.h> should declare getenv() */\nextern char * getenv JPP((const char * name));\n#endif\n#endif\n\n\n/*\n * Some important notes:\n *   The allocation routines provided here must never return NULL.\n *   They should exit to error_exit if unsuccessful.\n *\n *   It's not a good idea to try to merge the sarray and barray routines,\n *   even though they are textually almost the same, because samples are\n *   usually stored as bytes while coefficients are shorts or ints.  Thus,\n *   in machines where byte pointers have a different representation from\n *   word pointers, the resulting machine code could not be the same.\n */\n\n\n/*\n * Many machines require storage alignment: longs must start on 4-byte\n * boundaries, doubles on 8-byte boundaries, etc.  On such machines, malloc()\n * always returns pointers that are multiples of the worst-case alignment\n * requirement, and we had better do so too.\n * There isn't any really portable way to determine the worst-case alignment\n * requirement.  This module assumes that the alignment requirement is\n * multiples of sizeof(ALIGN_TYPE).\n * By default, we define ALIGN_TYPE as double.  This is necessary on some\n * workstations (where doubles really do need 8-byte alignment) and will work\n * fine on nearly everything.  If your machine has lesser alignment needs,\n * you can save a few bytes by making ALIGN_TYPE smaller.\n * The only place I know of where this will NOT work is certain Macintosh\n * 680x0 compilers that define double as a 10-byte IEEE extended float.\n * Doing 10-byte alignment is counterproductive because longwords won't be\n * aligned well.  Put \"#define ALIGN_TYPE long\" in jconfig.h if you have\n * such a compiler.\n */\n\n#ifndef ALIGN_TYPE\t\t/* so can override from jconfig.h */\n#define ALIGN_TYPE  double\n#endif\n\n\n/*\n * We allocate objects from \"pools\", where each pool is gotten with a single\n * request to jpeg_get_small() or jpeg_get_large().  There is no per-object\n * overhead within a pool, except for alignment padding.  Each pool has a\n * header with a link to the next pool of the same class.\n * Small and large pool headers are identical except that the latter's\n * link pointer must be FAR on 80x86 machines.\n * Notice that the \"real\" header fields are union'ed with a dummy ALIGN_TYPE\n * field.  This forces the compiler to make SIZEOF(small_pool_hdr) a multiple\n * of the alignment requirement of ALIGN_TYPE.\n */\n\ntypedef union small_pool_struct * small_pool_ptr;\n\ntypedef union small_pool_struct {\n  struct {\n    small_pool_ptr next;\t/* next in list of pools */\n    size_t bytes_used;\t\t/* how many bytes already used within pool */\n    size_t bytes_left;\t\t/* bytes still available in this pool */\n  } hdr;\n  ALIGN_TYPE dummy;\t\t/* included in union to ensure alignment */\n} small_pool_hdr;\n\ntypedef union large_pool_struct FAR * large_pool_ptr;\n\ntypedef union large_pool_struct {\n  struct {\n    large_pool_ptr next;\t/* next in list of pools */\n    size_t bytes_used;\t\t/* how many bytes already used within pool */\n    size_t bytes_left;\t\t/* bytes still available in this pool */\n  } hdr;\n  ALIGN_TYPE dummy;\t\t/* included in union to ensure alignment */\n} large_pool_hdr;\n\n\n/*\n * Here is the full definition of a memory manager object.\n */\n\ntypedef struct {\n  struct jpeg_memory_mgr pub;\t/* public fields */\n\n  /* Each pool identifier (lifetime class) names a linked list of pools. */\n  small_pool_ptr small_list[JPOOL_NUMPOOLS];\n  large_pool_ptr large_list[JPOOL_NUMPOOLS];\n\n  /* Since we only have one lifetime class of virtual arrays, only one\n   * linked list is necessary (for each datatype).  Note that the virtual\n   * array control blocks being linked together are actually stored somewhere\n   * in the small-pool list.\n   */\n  jvirt_sarray_ptr virt_sarray_list;\n  jvirt_barray_ptr virt_barray_list;\n\n  /* This counts total space obtained from jpeg_get_small/large */\n  long total_space_allocated;\n\n  /* alloc_sarray and alloc_barray set this value for use by virtual\n   * array routines.\n   */\n  JDIMENSION last_rowsperchunk;\t/* from most recent alloc_sarray/barray */\n} my_memory_mgr;\n\ntypedef my_memory_mgr * my_mem_ptr;\n\n\n/*\n * The control blocks for virtual arrays.\n * Note that these blocks are allocated in the \"small\" pool area.\n * System-dependent info for the associated backing store (if any) is hidden\n * inside the backing_store_info struct.\n */\n\nstruct jvirt_sarray_control {\n  JSAMPARRAY mem_buffer;\t/* => the in-memory buffer */\n  JDIMENSION rows_in_array;\t/* total virtual array height */\n  JDIMENSION samplesperrow;\t/* width of array (and of memory buffer) */\n  JDIMENSION maxaccess;\t\t/* max rows accessed by access_virt_sarray */\n  JDIMENSION rows_in_mem;\t/* height of memory buffer */\n  JDIMENSION rowsperchunk;\t/* allocation chunk size in mem_buffer */\n  JDIMENSION cur_start_row;\t/* first logical row # in the buffer */\n  JDIMENSION first_undef_row;\t/* row # of first uninitialized row */\n  boolean pre_zero;\t\t/* pre-zero mode requested? */\n  boolean dirty;\t\t/* do current buffer contents need written? */\n  boolean b_s_open;\t\t/* is backing-store data valid? */\n  jvirt_sarray_ptr next;\t/* link to next virtual sarray control block */\n  backing_store_info b_s_info;\t/* System-dependent control info */\n};\n\nstruct jvirt_barray_control {\n  JBLOCKARRAY mem_buffer;\t/* => the in-memory buffer */\n  JDIMENSION rows_in_array;\t/* total virtual array height */\n  JDIMENSION blocksperrow;\t/* width of array (and of memory buffer) */\n  JDIMENSION maxaccess;\t\t/* max rows accessed by access_virt_barray */\n  JDIMENSION rows_in_mem;\t/* height of memory buffer */\n  JDIMENSION rowsperchunk;\t/* allocation chunk size in mem_buffer */\n  JDIMENSION cur_start_row;\t/* first logical row # in the buffer */\n  JDIMENSION first_undef_row;\t/* row # of first uninitialized row */\n  boolean pre_zero;\t\t/* pre-zero mode requested? */\n  boolean dirty;\t\t/* do current buffer contents need written? */\n  boolean b_s_open;\t\t/* is backing-store data valid? */\n  jvirt_barray_ptr next;\t/* link to next virtual barray control block */\n  backing_store_info b_s_info;\t/* System-dependent control info */\n};\n\n\n#ifdef MEM_STATS\t\t/* optional extra stuff for statistics */\n\nLOCAL void\nprint_mem_stats (j_common_ptr cinfo, int pool_id)\n{\n  my_mem_ptr mem = (my_mem_ptr) cinfo->mem;\n  small_pool_ptr shdr_ptr;\n  large_pool_ptr lhdr_ptr;\n\n  /* Since this is only a debugging stub, we can cheat a little by using\n   * fprintf directly rather than going through the trace message code.\n   * This is helpful because message parm array can't handle longs.\n   */\n  fprintf(stderr, \"Freeing pool %d, total space = %ld\\n\",\n\t  pool_id, mem->total_space_allocated);\n\n  for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL;\n       lhdr_ptr = lhdr_ptr->hdr.next) {\n    fprintf(stderr, \"  Large chunk used %ld\\n\",\n\t    (long) lhdr_ptr->hdr.bytes_used);\n  }\n\n  for (shdr_ptr = mem->small_list[pool_id]; shdr_ptr != NULL;\n       shdr_ptr = shdr_ptr->hdr.next) {\n    fprintf(stderr, \"  Small chunk used %ld free %ld\\n\",\n\t    (long) shdr_ptr->hdr.bytes_used,\n\t    (long) shdr_ptr->hdr.bytes_left);\n  }\n}\n\n#endif /* MEM_STATS */\n\n\nLOCAL void\nout_of_memory (j_common_ptr cinfo, int which)\n/* Report an out-of-memory error and stop execution */\n/* If we compiled MEM_STATS support, report alloc requests before dying */\n{\n#ifdef MEM_STATS\n  cinfo->err->trace_level = 2;\t/* force self_destruct to report stats */\n#endif\n  ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, which);\n}\n\n\n/*\n * Allocation of \"small\" objects.\n *\n * For these, we use pooled storage.  When a new pool must be created,\n * we try to get enough space for the current request plus a \"slop\" factor,\n * where the slop will be the amount of leftover space in the new pool.\n * The speed vs. space tradeoff is largely determined by the slop values.\n * A different slop value is provided for each pool class (lifetime),\n * and we also distinguish the first pool of a class from later ones.\n * NOTE: the values given work fairly well on both 16- and 32-bit-int\n * machines, but may be too small if longs are 64 bits or more.\n */\n\nstatic const size_t first_pool_slop[JPOOL_NUMPOOLS] = \n{\n\t1600,\t\t\t/* first PERMANENT pool */\n\t16000\t\t\t/* first IMAGE pool */\n};\n\nstatic const size_t extra_pool_slop[JPOOL_NUMPOOLS] = \n{\n\t0,\t\t\t/* additional PERMANENT pools */\n\t5000\t\t\t/* additional IMAGE pools */\n};\n\n#define MIN_SLOP  50\t\t/* greater than 0 to avoid futile looping */\n\n\nMETHODDEF void *\nalloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)\n/* Allocate a \"small\" object */\n{\n  my_mem_ptr mem = (my_mem_ptr) cinfo->mem;\n  small_pool_ptr hdr_ptr, prev_hdr_ptr;\n  char * data_ptr;\n  size_t odd_bytes, min_request, slop;\n\n  /* Check for unsatisfiable request (do now to ensure no overflow below) */\n  if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(small_pool_hdr)))\n    out_of_memory(cinfo, 1);\t/* request exceeds malloc's ability */\n\n  /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */\n  odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE);\n  if (odd_bytes > 0)\n    sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes;\n\n  /* See if space is available in any existing pool */\n  if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS)\n    ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id);\t/* safety check */\n  prev_hdr_ptr = NULL;\n  hdr_ptr = mem->small_list[pool_id];\n  while (hdr_ptr != NULL) {\n    if (hdr_ptr->hdr.bytes_left >= sizeofobject)\n      break;\t\t\t/* found pool with enough space */\n    prev_hdr_ptr = hdr_ptr;\n    hdr_ptr = hdr_ptr->hdr.next;\n  }\n\n  /* Time to make a new pool? */\n  if (hdr_ptr == NULL) {\n    /* min_request is what we need now, slop is what will be leftover */\n    min_request = sizeofobject + SIZEOF(small_pool_hdr);\n    if (prev_hdr_ptr == NULL)\t/* first pool in class? */\n      slop = first_pool_slop[pool_id];\n    else\n      slop = extra_pool_slop[pool_id];\n    /* Don't ask for more than MAX_ALLOC_CHUNK */\n    if (slop > (size_t) (MAX_ALLOC_CHUNK-min_request))\n      slop = (size_t) (MAX_ALLOC_CHUNK-min_request);\n    /* Try to get space, if fail reduce slop and try again */\n    for (;;) {\n      hdr_ptr = (small_pool_ptr) jpeg_get_small(cinfo, min_request + slop);\n      if (hdr_ptr != NULL)\n\tbreak;\n      slop /= 2;\n      if (slop < MIN_SLOP)\t/* give up when it gets real small */\n\tout_of_memory(cinfo, 2); /* jpeg_get_small failed */\n    }\n    mem->total_space_allocated += min_request + slop;\n    /* Success, initialize the new pool header and add to end of list */\n    hdr_ptr->hdr.next = NULL;\n    hdr_ptr->hdr.bytes_used = 0;\n    hdr_ptr->hdr.bytes_left = sizeofobject + slop;\n    if (prev_hdr_ptr == NULL)\t/* first pool in class? */\n      mem->small_list[pool_id] = hdr_ptr;\n    else\n      prev_hdr_ptr->hdr.next = hdr_ptr;\n  }\n\n  /* OK, allocate the object from the current pool */\n  data_ptr = (char *) (hdr_ptr + 1); /* point to first data byte in pool */\n  data_ptr += hdr_ptr->hdr.bytes_used; /* point to place for object */\n  hdr_ptr->hdr.bytes_used += sizeofobject;\n  hdr_ptr->hdr.bytes_left -= sizeofobject;\n\n  return (void *) data_ptr;\n}\n\n\n/*\n * Allocation of \"large\" objects.\n *\n * The external semantics of these are the same as \"small\" objects,\n * except that FAR pointers are used on 80x86.  However the pool\n * management heuristics are quite different.  We assume that each\n * request is large enough that it may as well be passed directly to\n * jpeg_get_large; the pool management just links everything together\n * so that we can free it all on demand.\n * Note: the major use of \"large\" objects is in JSAMPARRAY and JBLOCKARRAY\n * structures.  The routines that create these structures (see below)\n * deliberately bunch rows together to ensure a large request size.\n */\n\nMETHODDEF void FAR *\nalloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)\n/* Allocate a \"large\" object */\n{\n  my_mem_ptr mem = (my_mem_ptr) cinfo->mem;\n  large_pool_ptr hdr_ptr;\n  size_t odd_bytes;\n\n  /* Check for unsatisfiable request (do now to ensure no overflow below) */\n  if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)))\n    out_of_memory(cinfo, 3);\t/* request exceeds malloc's ability */\n\n  /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */\n  odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE);\n  if (odd_bytes > 0)\n    sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes;\n\n  /* Always make a new pool */\n  if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS)\n    ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id);\t/* safety check */\n\n  hdr_ptr = (large_pool_ptr) jpeg_get_large(cinfo, sizeofobject +\n\t\t\t\t\t    SIZEOF(large_pool_hdr));\n  if (hdr_ptr == NULL)\n    out_of_memory(cinfo, 4);\t/* jpeg_get_large failed */\n  mem->total_space_allocated += sizeofobject + SIZEOF(large_pool_hdr);\n\n  /* Success, initialize the new pool header and add to list */\n  hdr_ptr->hdr.next = mem->large_list[pool_id];\n  /* We maintain space counts in each pool header for statistical purposes,\n   * even though they are not needed for allocation.\n   */\n  hdr_ptr->hdr.bytes_used = sizeofobject;\n  hdr_ptr->hdr.bytes_left = 0;\n  mem->large_list[pool_id] = hdr_ptr;\n\n  return (void FAR *) (hdr_ptr + 1); /* point to first data byte in pool */\n}\n\n\n/*\n * Creation of 2-D sample arrays.\n * The pointers are in near heap, the samples themselves in FAR heap.\n *\n * To minimize allocation overhead and to allow I/O of large contiguous\n * blocks, we allocate the sample rows in groups of as many rows as possible\n * without exceeding MAX_ALLOC_CHUNK total bytes per allocation request.\n * NB: the virtual array control routines, later in this file, know about\n * this chunking of rows.  The rowsperchunk value is left in the mem manager\n * object so that it can be saved away if this sarray is the workspace for\n * a virtual array.\n */\n\nMETHODDEF JSAMPARRAY\nalloc_sarray (j_common_ptr cinfo, int pool_id,\n\t      JDIMENSION samplesperrow, JDIMENSION numrows)\n/* Allocate a 2-D sample array */\n{\n  my_mem_ptr mem = (my_mem_ptr) cinfo->mem;\n  JSAMPARRAY result;\n  JSAMPROW workspace;\n  JDIMENSION rowsperchunk, currow, i;\n  long ltemp;\n\n  /* Calculate max # of rows allowed in one allocation chunk */\n  ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) /\n\t  ((long) samplesperrow * SIZEOF(JSAMPLE));\n  if (ltemp <= 0)\n    ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);\n  if (ltemp < (long) numrows)\n    rowsperchunk = (JDIMENSION) ltemp;\n  else\n    rowsperchunk = numrows;\n  mem->last_rowsperchunk = rowsperchunk;\n\n  /* Get space for row pointers (small object) */\n  result = (JSAMPARRAY) alloc_small(cinfo, pool_id,\n\t\t\t\t    (size_t) (numrows * SIZEOF(JSAMPROW)));\n\n  /* Get the rows themselves (large objects) */\n  currow = 0;\n  while (currow < numrows) {\n    rowsperchunk = MIN(rowsperchunk, numrows - currow);\n    workspace = (JSAMPROW) alloc_large(cinfo, pool_id,\n\t(size_t) ((size_t) rowsperchunk * (size_t) samplesperrow\n\t\t  * SIZEOF(JSAMPLE)));\n    for (i = rowsperchunk; i > 0; i--) {\n      result[currow++] = workspace;\n      workspace += samplesperrow;\n    }\n  }\n\n  return result;\n}\n\n\n/*\n * Creation of 2-D coefficient-block arrays.\n * This is essentially the same as the code for sample arrays, above.\n */\n\nMETHODDEF JBLOCKARRAY\nalloc_barray (j_common_ptr cinfo, int pool_id,\n\t      JDIMENSION blocksperrow, JDIMENSION numrows)\n/* Allocate a 2-D coefficient-block array */\n{\n  my_mem_ptr mem = (my_mem_ptr) cinfo->mem;\n  JBLOCKARRAY result;\n  JBLOCKROW workspace;\n  JDIMENSION rowsperchunk, currow, i;\n  long ltemp;\n\n  /* Calculate max # of rows allowed in one allocation chunk */\n  ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) /\n\t  ((long) blocksperrow * SIZEOF(JBLOCK));\n  if (ltemp <= 0)\n    ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);\n  if (ltemp < (long) numrows)\n    rowsperchunk = (JDIMENSION) ltemp;\n  else\n    rowsperchunk = numrows;\n  mem->last_rowsperchunk = rowsperchunk;\n\n  /* Get space for row pointers (small object) */\n  result = (JBLOCKARRAY) alloc_small(cinfo, pool_id,\n\t\t\t\t     (size_t) (numrows * SIZEOF(JBLOCKROW)));\n\n  /* Get the rows themselves (large objects) */\n  currow = 0;\n  while (currow < numrows) {\n    rowsperchunk = MIN(rowsperchunk, numrows - currow);\n    workspace = (JBLOCKROW) alloc_large(cinfo, pool_id,\n\t(size_t) ((size_t) rowsperchunk * (size_t) blocksperrow\n\t\t  * SIZEOF(JBLOCK)));\n    for (i = rowsperchunk; i > 0; i--) {\n      result[currow++] = workspace;\n      workspace += blocksperrow;\n    }\n  }\n\n  return result;\n}\n\n\n/*\n * About virtual array management:\n *\n * The above \"normal\" array routines are only used to allocate strip buffers\n * (as wide as the image, but just a few rows high).  Full-image-sized buffers\n * are handled as \"virtual\" arrays.  The array is still accessed a strip at a\n * time, but the memory manager must save the whole array for repeated\n * accesses.  The intended implementation is that there is a strip buffer in\n * memory (as high as is possible given the desired memory limit), plus a\n * backing file that holds the rest of the array.\n *\n * The request_virt_array routines are told the total size of the image and\n * the maximum number of rows that will be accessed at once.  The in-memory\n * buffer must be at least as large as the maxaccess value.\n *\n * The request routines create control blocks but not the in-memory buffers.\n * That is postponed until realize_virt_arrays is called.  At that time the\n * total amount of space needed is known (approximately, anyway), so free\n * memory can be divided up fairly.\n *\n * The access_virt_array routines are responsible for making a specific strip\n * area accessible (after reading or writing the backing file, if necessary).\n * Note that the access routines are told whether the caller intends to modify\n * the accessed strip; during a read-only pass this saves having to rewrite\n * data to disk.  The access routines are also responsible for pre-zeroing\n * any newly accessed rows, if pre-zeroing was requested.\n *\n * In current usage, the access requests are usually for nonoverlapping\n * strips; that is, successive access start_row numbers differ by exactly\n * num_rows = maxaccess.  This means we can get good performance with simple\n * buffer dump/reload logic, by making the in-memory buffer be a multiple\n * of the access height; then there will never be accesses across bufferload\n * boundaries.  The code will still work with overlapping access requests,\n * but it doesn't handle bufferload overlaps very efficiently.\n */\n\n\nMETHODDEF jvirt_sarray_ptr\nrequest_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero,\n\t\t     JDIMENSION samplesperrow, JDIMENSION numrows,\n\t\t     JDIMENSION maxaccess)\n/* Request a virtual 2-D sample array */\n{\n  my_mem_ptr mem = (my_mem_ptr) cinfo->mem;\n  jvirt_sarray_ptr result;\n\n  /* Only IMAGE-lifetime virtual arrays are currently supported */\n  if (pool_id != JPOOL_IMAGE)\n    ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id);\t/* safety check */\n\n  /* get control block */\n  result = (jvirt_sarray_ptr) alloc_small(cinfo, pool_id,\n\t\t\t\t\t  SIZEOF(struct jvirt_sarray_control));\n\n  result->mem_buffer = NULL;\t/* marks array not yet realized */\n  result->rows_in_array = numrows;\n  result->samplesperrow = samplesperrow;\n  result->maxaccess = maxaccess;\n  result->pre_zero = pre_zero;\n  result->b_s_open = FALSE;\t/* no associated backing-store object */\n  result->next = mem->virt_sarray_list; /* add to list of virtual arrays */\n  mem->virt_sarray_list = result;\n\n  return result;\n}\n\n\nMETHODDEF jvirt_barray_ptr\nrequest_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero,\n\t\t     JDIMENSION blocksperrow, JDIMENSION numrows,\n\t\t     JDIMENSION maxaccess)\n/* Request a virtual 2-D coefficient-block array */\n{\n  my_mem_ptr mem = (my_mem_ptr) cinfo->mem;\n  jvirt_barray_ptr result;\n\n  /* Only IMAGE-lifetime virtual arrays are currently supported */\n  if (pool_id != JPOOL_IMAGE)\n    ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id);\t/* safety check */\n\n  /* get control block */\n  result = (jvirt_barray_ptr) alloc_small(cinfo, pool_id,\n\t\t\t\t\t  SIZEOF(struct jvirt_barray_control));\n\n  result->mem_buffer = NULL;\t/* marks array not yet realized */\n  result->rows_in_array = numrows;\n  result->blocksperrow = blocksperrow;\n  result->maxaccess = maxaccess;\n  result->pre_zero = pre_zero;\n  result->b_s_open = FALSE;\t/* no associated backing-store object */\n  result->next = mem->virt_barray_list; /* add to list of virtual arrays */\n  mem->virt_barray_list = result;\n\n  return result;\n}\n\n\nMETHODDEF void\nrealize_virt_arrays (j_common_ptr cinfo)\n/* Allocate the in-memory buffers for any unrealized virtual arrays */\n{\n  my_mem_ptr mem = (my_mem_ptr) cinfo->mem;\n  long space_per_minheight, maximum_space, avail_mem;\n  long minheights, max_minheights;\n  jvirt_sarray_ptr sptr;\n  jvirt_barray_ptr bptr;\n\n  /* Compute the minimum space needed (maxaccess rows in each buffer)\n   * and the maximum space needed (full image height in each buffer).\n   * These may be of use to the system-dependent jpeg_mem_available routine.\n   */\n  space_per_minheight = 0;\n  maximum_space = 0;\n  for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {\n    if (sptr->mem_buffer == NULL) { /* if not realized yet */\n      space_per_minheight += (long) sptr->maxaccess *\n\t\t\t     (long) sptr->samplesperrow * SIZEOF(JSAMPLE);\n      maximum_space += (long) sptr->rows_in_array *\n\t\t       (long) sptr->samplesperrow * SIZEOF(JSAMPLE);\n    }\n  }\n  for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {\n    if (bptr->mem_buffer == NULL) { /* if not realized yet */\n      space_per_minheight += (long) bptr->maxaccess *\n\t\t\t     (long) bptr->blocksperrow * SIZEOF(JBLOCK);\n      maximum_space += (long) bptr->rows_in_array *\n\t\t       (long) bptr->blocksperrow * SIZEOF(JBLOCK);\n    }\n  }\n\n  if (space_per_minheight <= 0)\n    return;\t\t\t/* no unrealized arrays, no work */\n\n  /* Determine amount of memory to actually use; this is system-dependent. */\n  avail_mem = jpeg_mem_available(cinfo, space_per_minheight, maximum_space,\n\t\t\t\t mem->total_space_allocated);\n\n  /* If the maximum space needed is available, make all the buffers full\n   * height; otherwise parcel it out with the same number of minheights\n   * in each buffer.\n   */\n  if (avail_mem >= maximum_space)\n    max_minheights = 1000000000L;\n  else {\n    max_minheights = avail_mem / space_per_minheight;\n    /* If there doesn't seem to be enough space, try to get the minimum\n     * anyway.  This allows a \"stub\" implementation of jpeg_mem_available().\n     */\n    if (max_minheights <= 0)\n      max_minheights = 1;\n  }\n\n  /* Allocate the in-memory buffers and initialize backing store as needed. */\n\n  for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {\n    if (sptr->mem_buffer == NULL) { /* if not realized yet */\n      minheights = ((long) sptr->rows_in_array - 1L) / sptr->maxaccess + 1L;\n      if (minheights <= max_minheights) {\n\t/* This buffer fits in memory */\n\tsptr->rows_in_mem = sptr->rows_in_array;\n      } else {\n\t/* It doesn't fit in memory, create backing store. */\n\tsptr->rows_in_mem = (JDIMENSION) (max_minheights * sptr->maxaccess);\n\tjpeg_open_backing_store(cinfo, & sptr->b_s_info,\n\t\t\t\t(long) sptr->rows_in_array *\n\t\t\t\t(long) sptr->samplesperrow *\n\t\t\t\t(long) SIZEOF(JSAMPLE));\n\tsptr->b_s_open = TRUE;\n      }\n      sptr->mem_buffer = alloc_sarray(cinfo, JPOOL_IMAGE,\n\t\t\t\t      sptr->samplesperrow, sptr->rows_in_mem);\n      sptr->rowsperchunk = mem->last_rowsperchunk;\n      sptr->cur_start_row = 0;\n      sptr->first_undef_row = 0;\n      sptr->dirty = FALSE;\n    }\n  }\n\n  for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {\n    if (bptr->mem_buffer == NULL) { /* if not realized yet */\n      minheights = ((long) bptr->rows_in_array - 1L) / bptr->maxaccess + 1L;\n      if (minheights <= max_minheights) {\n\t/* This buffer fits in memory */\n\tbptr->rows_in_mem = bptr->rows_in_array;\n      } else {\n\t/* It doesn't fit in memory, create backing store. */\n\tbptr->rows_in_mem = (JDIMENSION) (max_minheights * bptr->maxaccess);\n\tjpeg_open_backing_store(cinfo, & bptr->b_s_info,\n\t\t\t\t(long) bptr->rows_in_array *\n\t\t\t\t(long) bptr->blocksperrow *\n\t\t\t\t(long) SIZEOF(JBLOCK));\n\tbptr->b_s_open = TRUE;\n      }\n      bptr->mem_buffer = alloc_barray(cinfo, JPOOL_IMAGE,\n\t\t\t\t      bptr->blocksperrow, bptr->rows_in_mem);\n      bptr->rowsperchunk = mem->last_rowsperchunk;\n      bptr->cur_start_row = 0;\n      bptr->first_undef_row = 0;\n      bptr->dirty = FALSE;\n    }\n  }\n}\n\n\nLOCAL void\ndo_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)\n/* Do backing store read or write of a virtual sample array */\n{\n  long bytesperrow, file_offset, byte_count, rows, thisrow, i;\n\n  bytesperrow = (long) ptr->samplesperrow * SIZEOF(JSAMPLE);\n  file_offset = ptr->cur_start_row * bytesperrow;\n  /* Loop to read or write each allocation chunk in mem_buffer */\n  for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {\n    /* One chunk, but check for short chunk at end of buffer */\n    rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i);\n    /* Transfer no more than is currently defined */\n    thisrow = (long) ptr->cur_start_row + i;\n    rows = MIN(rows, (long) ptr->first_undef_row - thisrow);\n    /* Transfer no more than fits in file */\n    rows = MIN(rows, (long) ptr->rows_in_array - thisrow);\n    if (rows <= 0)\t\t/* this chunk might be past end of file! */\n      break;\n    byte_count = rows * bytesperrow;\n    if (writing)\n      (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info,\n\t\t\t\t\t    (void FAR *) ptr->mem_buffer[i],\n\t\t\t\t\t    file_offset, byte_count);\n    else\n      (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info,\n\t\t\t\t\t   (void FAR *) ptr->mem_buffer[i],\n\t\t\t\t\t   file_offset, byte_count);\n    file_offset += byte_count;\n  }\n}\n\n\nLOCAL void\ndo_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing)\n/* Do backing store read or write of a virtual coefficient-block array */\n{\n  long bytesperrow, file_offset, byte_count, rows, thisrow, i;\n\n  bytesperrow = (long) ptr->blocksperrow * SIZEOF(JBLOCK);\n  file_offset = ptr->cur_start_row * bytesperrow;\n  /* Loop to read or write each allocation chunk in mem_buffer */\n  for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {\n    /* One chunk, but check for short chunk at end of buffer */\n    rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i);\n    /* Transfer no more than is currently defined */\n    thisrow = (long) ptr->cur_start_row + i;\n    rows = MIN(rows, (long) ptr->first_undef_row - thisrow);\n    /* Transfer no more than fits in file */\n    rows = MIN(rows, (long) ptr->rows_in_array - thisrow);\n    if (rows <= 0)\t\t/* this chunk might be past end of file! */\n      break;\n    byte_count = rows * bytesperrow;\n    if (writing)\n      (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info,\n\t\t\t\t\t    (void FAR *) ptr->mem_buffer[i],\n\t\t\t\t\t    file_offset, byte_count);\n    else\n      (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info,\n\t\t\t\t\t   (void FAR *) ptr->mem_buffer[i],\n\t\t\t\t\t   file_offset, byte_count);\n    file_offset += byte_count;\n  }\n}\n\n\nMETHODDEF JSAMPARRAY\naccess_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,\n\t\t    JDIMENSION start_row, JDIMENSION num_rows,\n\t\t    boolean writable)\n/* Access the part of a virtual sample array starting at start_row */\n/* and extending for num_rows rows.  writable is true if  */\n/* caller intends to modify the accessed area. */\n{\n  JDIMENSION end_row = start_row + num_rows;\n  JDIMENSION undef_row;\n\n  /* debugging check */\n  if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess ||\n      ptr->mem_buffer == NULL)\n    ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);\n\n  /* Make the desired part of the virtual array accessible */\n  if (start_row < ptr->cur_start_row ||\n      end_row > ptr->cur_start_row+ptr->rows_in_mem) {\n    if (! ptr->b_s_open)\n      ERREXIT(cinfo, JERR_VIRTUAL_BUG);\n    /* Flush old buffer contents if necessary */\n    if (ptr->dirty) {\n      do_sarray_io(cinfo, ptr, TRUE);\n      ptr->dirty = FALSE;\n    }\n    /* Decide what part of virtual array to access.\n     * Algorithm: if target address > current window, assume forward scan,\n     * load starting at target address.  If target address < current window,\n     * assume backward scan, load so that target area is top of window.\n     * Note that when switching from forward write to forward read, will have\n     * start_row = 0, so the limiting case applies and we load from 0 anyway.\n     */\n    if (start_row > ptr->cur_start_row) {\n      ptr->cur_start_row = start_row;\n    } else {\n      /* use long arithmetic here to avoid overflow & unsigned problems */\n      long ltemp;\n\n      ltemp = (long) end_row - (long) ptr->rows_in_mem;\n      if (ltemp < 0)\n\tltemp = 0;\t\t/* don't fall off front end of file */\n      ptr->cur_start_row = (JDIMENSION) ltemp;\n    }\n    /* Read in the selected part of the array.\n     * During the initial write pass, we will do no actual read\n     * because the selected part is all undefined.\n     */\n    do_sarray_io(cinfo, ptr, FALSE);\n  }\n  /* Ensure the accessed part of the array is defined; prezero if needed.\n   * To improve locality of access, we only prezero the part of the array\n   * that the caller is about to access, not the entire in-memory array.\n   */\n  if (ptr->first_undef_row < end_row) {\n    if (ptr->first_undef_row < start_row) {\n      if (writable)\t\t/* writer skipped over a section of array */\n\tERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);\n      undef_row = start_row;\t/* but reader is allowed to read ahead */\n    } else {\n      undef_row = ptr->first_undef_row;\n    }\n    if (writable)\n      ptr->first_undef_row = end_row;\n    if (ptr->pre_zero) {\n      size_t bytesperrow = (size_t) ptr->samplesperrow * SIZEOF(JSAMPLE);\n      undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */\n      end_row -= ptr->cur_start_row;\n      while (undef_row < end_row) {\n\tjzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow);\n\tundef_row++;\n      }\n    } else {\n      if (! writable)\t\t/* reader looking at undefined data */\n\tERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);\n    }\n  }\n  /* Flag the buffer dirty if caller will write in it */\n  if (writable)\n    ptr->dirty = TRUE;\n  /* Return address of proper part of the buffer */\n  return ptr->mem_buffer + (start_row - ptr->cur_start_row);\n}\n\n\nMETHODDEF JBLOCKARRAY\naccess_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,\n\t\t    JDIMENSION start_row, JDIMENSION num_rows,\n\t\t    boolean writable)\n/* Access the part of a virtual block array starting at start_row */\n/* and extending for num_rows rows.  writable is true if  */\n/* caller intends to modify the accessed area. */\n{\n  JDIMENSION end_row = start_row + num_rows;\n  JDIMENSION undef_row;\n\n  /* debugging check */\n  if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess ||\n      ptr->mem_buffer == NULL)\n    ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);\n\n  /* Make the desired part of the virtual array accessible */\n  if (start_row < ptr->cur_start_row ||\n      end_row > ptr->cur_start_row+ptr->rows_in_mem) {\n    if (! ptr->b_s_open)\n      ERREXIT(cinfo, JERR_VIRTUAL_BUG);\n    /* Flush old buffer contents if necessary */\n    if (ptr->dirty) {\n      do_barray_io(cinfo, ptr, TRUE);\n      ptr->dirty = FALSE;\n    }\n    /* Decide what part of virtual array to access.\n     * Algorithm: if target address > current window, assume forward scan,\n     * load starting at target address.  If target address < current window,\n     * assume backward scan, load so that target area is top of window.\n     * Note that when switching from forward write to forward read, will have\n     * start_row = 0, so the limiting case applies and we load from 0 anyway.\n     */\n    if (start_row > ptr->cur_start_row) {\n      ptr->cur_start_row = start_row;\n    } else {\n      /* use long arithmetic here to avoid overflow & unsigned problems */\n      long ltemp;\n\n      ltemp = (long) end_row - (long) ptr->rows_in_mem;\n      if (ltemp < 0)\n\tltemp = 0;\t\t/* don't fall off front end of file */\n      ptr->cur_start_row = (JDIMENSION) ltemp;\n    }\n    /* Read in the selected part of the array.\n     * During the initial write pass, we will do no actual read\n     * because the selected part is all undefined.\n     */\n    do_barray_io(cinfo, ptr, FALSE);\n  }\n  /* Ensure the accessed part of the array is defined; prezero if needed.\n   * To improve locality of access, we only prezero the part of the array\n   * that the caller is about to access, not the entire in-memory array.\n   */\n  if (ptr->first_undef_row < end_row) {\n    if (ptr->first_undef_row < start_row) {\n      if (writable)\t\t/* writer skipped over a section of array */\n\tERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);\n      undef_row = start_row;\t/* but reader is allowed to read ahead */\n    } else {\n      undef_row = ptr->first_undef_row;\n    }\n    if (writable)\n      ptr->first_undef_row = end_row;\n    if (ptr->pre_zero) {\n      size_t bytesperrow = (size_t) ptr->blocksperrow * SIZEOF(JBLOCK);\n      undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */\n      end_row -= ptr->cur_start_row;\n      while (undef_row < end_row) {\n\tjzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow);\n\tundef_row++;\n      }\n    } else {\n      if (! writable)\t\t/* reader looking at undefined data */\n\tERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);\n    }\n  }\n  /* Flag the buffer dirty if caller will write in it */\n  if (writable)\n    ptr->dirty = TRUE;\n  /* Return address of proper part of the buffer */\n  return ptr->mem_buffer + (start_row - ptr->cur_start_row);\n}\n\n\n/*\n * Release all objects belonging to a specified pool.\n */\n\nMETHODDEF void\nfree_pool (j_common_ptr cinfo, int pool_id)\n{\n  my_mem_ptr mem = (my_mem_ptr) cinfo->mem;\n  small_pool_ptr shdr_ptr;\n  large_pool_ptr lhdr_ptr;\n  size_t space_freed;\n\n  if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS)\n    ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id);\t/* safety check */\n\n#ifdef MEM_STATS\n  if (cinfo->err->trace_level > 1)\n    print_mem_stats(cinfo, pool_id); /* print pool's memory usage statistics */\n#endif\n\n  /* If freeing IMAGE pool, close any virtual arrays first */\n  if (pool_id == JPOOL_IMAGE) {\n    jvirt_sarray_ptr sptr;\n    jvirt_barray_ptr bptr;\n\n    for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {\n      if (sptr->b_s_open) {\t/* there may be no backing store */\n\tsptr->b_s_open = FALSE;\t/* prevent recursive close if error */\n\t(*sptr->b_s_info.close_backing_store) (cinfo, & sptr->b_s_info);\n      }\n    }\n    mem->virt_sarray_list = NULL;\n    for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {\n      if (bptr->b_s_open) {\t/* there may be no backing store */\n\tbptr->b_s_open = FALSE;\t/* prevent recursive close if error */\n\t(*bptr->b_s_info.close_backing_store) (cinfo, & bptr->b_s_info);\n      }\n    }\n    mem->virt_barray_list = NULL;\n  }\n\n  /* Release large objects */\n  lhdr_ptr = mem->large_list[pool_id];\n  mem->large_list[pool_id] = NULL;\n\n  while (lhdr_ptr != NULL) {\n    large_pool_ptr next_lhdr_ptr = lhdr_ptr->hdr.next;\n    space_freed = lhdr_ptr->hdr.bytes_used +\n\t\t  lhdr_ptr->hdr.bytes_left +\n\t\t  SIZEOF(large_pool_hdr);\n    jpeg_free_large(cinfo, (void FAR *) lhdr_ptr, space_freed);\n    mem->total_space_allocated -= space_freed;\n    lhdr_ptr = next_lhdr_ptr;\n  }\n\n  /* Release small objects */\n  shdr_ptr = mem->small_list[pool_id];\n  mem->small_list[pool_id] = NULL;\n\n  while (shdr_ptr != NULL) {\n    small_pool_ptr next_shdr_ptr = shdr_ptr->hdr.next;\n    space_freed = shdr_ptr->hdr.bytes_used +\n\t\t  shdr_ptr->hdr.bytes_left +\n\t\t  SIZEOF(small_pool_hdr);\n    jpeg_free_small(cinfo, (void *) shdr_ptr, space_freed);\n    mem->total_space_allocated -= space_freed;\n    shdr_ptr = next_shdr_ptr;\n  }\n}\n\n\n/*\n * Close up shop entirely.\n * Note that this cannot be called unless cinfo->mem is non-NULL.\n */\n\nMETHODDEF void\nself_destruct (j_common_ptr cinfo)\n{\n  int pool;\n\n  /* Close all backing store, release all memory.\n   * Releasing pools in reverse order might help avoid fragmentation\n   * with some (brain-damaged) malloc libraries.\n   */\n  for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) {\n    free_pool(cinfo, pool);\n  }\n\n  /* Release the memory manager control block too. */\n  jpeg_free_small(cinfo, (void *) cinfo->mem, SIZEOF(my_memory_mgr));\n  cinfo->mem = NULL;\t\t/* ensures I will be called only once */\n\n  jpeg_mem_term(cinfo);\t\t/* system-dependent cleanup */\n}\n\n\n/*\n * Memory manager initialization.\n * When this is called, only the error manager pointer is valid in cinfo!\n */\n\nGLOBAL void\njinit_memory_mgr (j_common_ptr cinfo)\n{\n  my_mem_ptr mem;\n  long max_to_use;\n  int pool;\n  size_t test_mac;\n\n  cinfo->mem = NULL;\t\t/* for safety if init fails */\n\n  /* Check for configuration errors.\n   * SIZEOF(ALIGN_TYPE) should be a power of 2; otherwise, it probably\n   * doesn't reflect any real hardware alignment requirement.\n   * The test is a little tricky: for X>0, X and X-1 have no one-bits\n   * in common if and only if X is a power of 2, ie has only one one-bit.\n   * Some compilers may give an \"unreachable code\" warning here; ignore it.\n   */\n  if ((SIZEOF(ALIGN_TYPE) & (SIZEOF(ALIGN_TYPE)-1)) != 0)\n    ERREXIT(cinfo, JERR_BAD_ALIGN_TYPE);\n  /* MAX_ALLOC_CHUNK must be representable as type size_t, and must be\n   * a multiple of SIZEOF(ALIGN_TYPE).\n   * Again, an \"unreachable code\" warning may be ignored here.\n   * But a \"constant too large\" warning means you need to fix MAX_ALLOC_CHUNK.\n   */\n  test_mac = (size_t) MAX_ALLOC_CHUNK;\n  if ((long) test_mac != MAX_ALLOC_CHUNK ||\n      (MAX_ALLOC_CHUNK % SIZEOF(ALIGN_TYPE)) != 0)\n    ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK);\n\n  max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */\n\n  /* Attempt to allocate memory manager's control block */\n  mem = (my_mem_ptr) jpeg_get_small(cinfo, SIZEOF(my_memory_mgr));\n\n  if (mem == NULL) {\n    jpeg_mem_term(cinfo);\t/* system-dependent cleanup */\n    ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 0);\n  }\n\n  /* OK, fill in the method pointers */\n  mem->pub.alloc_small = alloc_small;\n  mem->pub.alloc_large = alloc_large;\n  mem->pub.alloc_sarray = alloc_sarray;\n  mem->pub.alloc_barray = alloc_barray;\n  mem->pub.request_virt_sarray = request_virt_sarray;\n  mem->pub.request_virt_barray = request_virt_barray;\n  mem->pub.realize_virt_arrays = realize_virt_arrays;\n  mem->pub.access_virt_sarray = access_virt_sarray;\n  mem->pub.access_virt_barray = access_virt_barray;\n  mem->pub.free_pool = free_pool;\n  mem->pub.self_destruct = self_destruct;\n\n  /* Initialize working state */\n  mem->pub.max_memory_to_use = max_to_use;\n\n  for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) {\n    mem->small_list[pool] = NULL;\n    mem->large_list[pool] = NULL;\n  }\n  mem->virt_sarray_list = NULL;\n  mem->virt_barray_list = NULL;\n\n  mem->total_space_allocated = SIZEOF(my_memory_mgr);\n\n  /* Declare ourselves open for business */\n  cinfo->mem = & mem->pub;\n\n  /* Check for an environment variable JPEGMEM; if found, override the\n   * default max_memory setting from jpeg_mem_init.  Note that the\n   * surrounding application may again override this value.\n   * If your system doesn't support getenv(), define NO_GETENV to disable\n   * this feature.\n   */\n#ifndef NO_GETENV\n  { char * memenv;\n\n    if ((memenv = getenv(\"JPEGMEM\")) != NULL) {\n      char ch = 'x';\n\n      if (sscanf(memenv, \"%ld%c\", &max_to_use, &ch) > 0) {\n\tif (ch == 'm' || ch == 'M')\n\t  max_to_use *= 1000L;\n\tmem->pub.max_memory_to_use = max_to_use * 1000L;\n      }\n    }\n  }\n#endif\n\n}\n"
  },
  {
    "path": "code/jpeg-6/jmemname.c",
    "content": "/*\n * jmemname.c\n *\n * Copyright (C) 1992-1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file provides a generic implementation of the system-dependent\n * portion of the JPEG memory manager.  This implementation assumes that\n * you must explicitly construct a name for each temp file.\n * Also, the problem of determining the amount of memory available\n * is shoved onto the user.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jmemsys.h\"\t\t/* import the system-dependent declarations */\n\n#ifndef HAVE_STDLIB_H\t\t/* <stdlib.h> should declare malloc(),free() */\nextern void * malloc JPP((size_t size));\nextern void free JPP((void *ptr));\n#endif\n\n#ifndef SEEK_SET\t\t/* pre-ANSI systems may not define this; */\n#define SEEK_SET  0\t\t/* if not, assume 0 is correct */\n#endif\n\n#ifdef DONT_USE_B_MODE\t\t/* define mode parameters for fopen() */\n#define READ_BINARY\t\"r\"\n#define RW_BINARY\t\"w+\"\n#else\n#define READ_BINARY\t\"rb\"\n#define RW_BINARY\t\"w+b\"\n#endif\n\n\n/*\n * Selection of a file name for a temporary file.\n * This is system-dependent!\n *\n * The code as given is suitable for most Unix systems, and it is easily\n * modified for most non-Unix systems.  Some notes:\n *  1.  The temp file is created in the directory named by TEMP_DIRECTORY.\n *      The default value is /usr/tmp, which is the conventional place for\n *      creating large temp files on Unix.  On other systems you'll probably\n *      want to change the file location.  You can do this by editing the\n *      #define, or (preferred) by defining TEMP_DIRECTORY in jconfig.h.\n *\n *  2.  If you need to change the file name as well as its location,\n *      you can override the TEMP_FILE_NAME macro.  (Note that this is\n *      actually a printf format string; it must contain %s and %d.)\n *      Few people should need to do this.\n *\n *  3.  mktemp() is used to ensure that multiple processes running\n *      simultaneously won't select the same file names.  If your system\n *      doesn't have mktemp(), define NO_MKTEMP to do it the hard way.\n *      (If you don't have <errno.h>, also define NO_ERRNO_H.)\n *\n *  4.  You probably want to define NEED_SIGNAL_CATCHER so that cjpeg.c/djpeg.c\n *      will cause the temp files to be removed if you stop the program early.\n */\n\n#ifndef TEMP_DIRECTORY\t\t/* can override from jconfig.h or Makefile */\n#define TEMP_DIRECTORY  \"/usr/tmp/\" /* recommended setting for Unix */\n#endif\n\nstatic int next_file_num;\t/* to distinguish among several temp files */\n\n#ifdef NO_MKTEMP\n\n#ifndef TEMP_FILE_NAME\t\t/* can override from jconfig.h or Makefile */\n#define TEMP_FILE_NAME  \"%sJPG%03d.TMP\"\n#endif\n\n#ifndef NO_ERRNO_H\n#include <errno.h>\t\t/* to define ENOENT */\n#endif\n\n/* ANSI C specifies that errno is a macro, but on older systems it's more\n * likely to be a plain int variable.  And not all versions of errno.h\n * bother to declare it, so we have to in order to be most portable.  Thus:\n */\n#ifndef errno\nextern int errno;\n#endif\n\n\nLOCAL void\nselect_file_name (char * fname)\n{\n  FILE * tfile;\n\n  /* Keep generating file names till we find one that's not in use */\n  for (;;) {\n    next_file_num++;\t\t/* advance counter */\n    sprintf(fname, TEMP_FILE_NAME, TEMP_DIRECTORY, next_file_num);\n    if ((tfile = fopen(fname, READ_BINARY)) == NULL) {\n      /* fopen could have failed for a reason other than the file not\n       * being there; for example, file there but unreadable.\n       * If <errno.h> isn't available, then we cannot test the cause.\n       */\n#ifdef ENOENT\n      if (errno != ENOENT)\n\tcontinue;\n#endif\n      break;\n    }\n    fclose(tfile);\t\t/* oops, it's there; close tfile & try again */\n  }\n}\n\n#else /* ! NO_MKTEMP */\n\n/* Note that mktemp() requires the initial filename to end in six X's */\n#ifndef TEMP_FILE_NAME\t\t/* can override from jconfig.h or Makefile */\n#define TEMP_FILE_NAME  \"%sJPG%dXXXXXX\"\n#endif\n\nLOCAL void\nselect_file_name (char * fname)\n{\n  next_file_num++;\t\t/* advance counter */\n  sprintf(fname, TEMP_FILE_NAME, TEMP_DIRECTORY, next_file_num);\n  mktemp(fname);\t\t/* make sure file name is unique */\n  /* mktemp replaces the trailing XXXXXX with a unique string of characters */\n}\n\n#endif /* NO_MKTEMP */\n\n\n/*\n * Memory allocation and freeing are controlled by the regular library\n * routines malloc() and free().\n */\n\nGLOBAL void *\njpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)\n{\n  return (void *) malloc(sizeofobject);\n}\n\nGLOBAL void\njpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)\n{\n  free(object);\n}\n\n\n/*\n * \"Large\" objects are treated the same as \"small\" ones.\n * NB: although we include FAR keywords in the routine declarations,\n * this file won't actually work in 80x86 small/medium model; at least,\n * you probably won't be able to process useful-size images in only 64KB.\n */\n\nGLOBAL void FAR *\njpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)\n{\n  return (void FAR *) malloc(sizeofobject);\n}\n\nGLOBAL void\njpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)\n{\n  free(object);\n}\n\n\n/*\n * This routine computes the total memory space available for allocation.\n * It's impossible to do this in a portable way; our current solution is\n * to make the user tell us (with a default value set at compile time).\n * If you can actually get the available space, it's a good idea to subtract\n * a slop factor of 5% or so.\n */\n\n#ifndef DEFAULT_MAX_MEM\t\t/* so can override from makefile */\n#define DEFAULT_MAX_MEM\t\t1000000L /* default: one megabyte */\n#endif\n\nGLOBAL long\njpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,\n\t\t    long max_bytes_needed, long already_allocated)\n{\n  return cinfo->mem->max_memory_to_use - already_allocated;\n}\n\n\n/*\n * Backing store (temporary file) management.\n * Backing store objects are only used when the value returned by\n * jpeg_mem_available is less than the total space needed.  You can dispense\n * with these routines if you have plenty of virtual memory; see jmemnobs.c.\n */\n\n\nMETHODDEF void\nread_backing_store (j_common_ptr cinfo, backing_store_ptr info,\n\t\t    void FAR * buffer_address,\n\t\t    long file_offset, long byte_count)\n{\n  if (fseek(info->temp_file, file_offset, SEEK_SET))\n    ERREXIT(cinfo, JERR_TFILE_SEEK);\n  if (JFREAD(info->temp_file, buffer_address, byte_count)\n      != (size_t) byte_count)\n    ERREXIT(cinfo, JERR_TFILE_READ);\n}\n\n\nMETHODDEF void\nwrite_backing_store (j_common_ptr cinfo, backing_store_ptr info,\n\t\t     void FAR * buffer_address,\n\t\t     long file_offset, long byte_count)\n{\n  if (fseek(info->temp_file, file_offset, SEEK_SET))\n    ERREXIT(cinfo, JERR_TFILE_SEEK);\n  if (JFWRITE(info->temp_file, buffer_address, byte_count)\n      != (size_t) byte_count)\n    ERREXIT(cinfo, JERR_TFILE_WRITE);\n}\n\n\nMETHODDEF void\nclose_backing_store (j_common_ptr cinfo, backing_store_ptr info)\n{\n  fclose(info->temp_file);\t/* close the file */\n  unlink(info->temp_name);\t/* delete the file */\n/* If your system doesn't have unlink(), use remove() instead.\n * remove() is the ANSI-standard name for this function, but if\n * your system was ANSI you'd be using jmemansi.c, right?\n */\n  TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name);\n}\n\n\n/*\n * Initial opening of a backing-store object.\n */\n\nGLOBAL void\njpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,\n\t\t\t long total_bytes_needed)\n{\n  select_file_name(info->temp_name);\n  if ((info->temp_file = fopen(info->temp_name, RW_BINARY)) == NULL)\n    ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name);\n  info->read_backing_store = read_backing_store;\n  info->write_backing_store = write_backing_store;\n  info->close_backing_store = close_backing_store;\n  TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name);\n}\n\n\n/*\n * These routines take care of any system-dependent initialization and\n * cleanup required.\n */\n\nGLOBAL long\njpeg_mem_init (j_common_ptr cinfo)\n{\n  next_file_num = 0;\t\t/* initialize temp file name generator */\n  return DEFAULT_MAX_MEM;\t/* default for max_memory_to_use */\n}\n\nGLOBAL void\njpeg_mem_term (j_common_ptr cinfo)\n{\n  /* no work */\n}\n"
  },
  {
    "path": "code/jpeg-6/jmemnobs.c",
    "content": "/*\n * jmemnobs.c\n *\n * Copyright (C) 1992-1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file provides a really simple implementation of the system-\n * dependent portion of the JPEG memory manager.  This implementation\n * assumes that no backing-store files are needed: all required space\n * can be obtained from ri.Malloc().\n * This is very portable in the sense that it'll compile on almost anything,\n * but you'd better have lots of main memory (or virtual memory) if you want\n * to process big images.\n * Note that the max_memory_to_use option is ignored by this implementation.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jmemsys.h\"\t\t/* import the system-dependent declarations */\n\n#include \"../renderer/tr_local.h\"\n\n/*\n * Memory allocation and ri.Freeing are controlled by the regular library\n * routines ri.Malloc() and ri.Free().\n */\n\nGLOBAL void *\njpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)\n{\n  return (void *) ri.Malloc(sizeofobject);\n}\n\nGLOBAL void\njpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)\n{\n  ri.Free(object);\n}\n\n\n/*\n * \"Large\" objects are treated the same as \"small\" ones.\n * NB: although we include FAR keywords in the routine declarations,\n * this file won't actually work in 80x86 small/medium model; at least,\n * you probably won't be able to process useful-size images in only 64KB.\n */\n\nGLOBAL void FAR *\njpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)\n{\n  return (void FAR *) ri.Malloc(sizeofobject);\n}\n\nGLOBAL void\njpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)\n{\n  ri.Free(object);\n}\n\n\n/*\n * This routine computes the total memory space available for allocation.\n * Here we always say, \"we got all you want bud!\"\n */\n\nGLOBAL long\njpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,\n\t\t    long max_bytes_needed, long already_allocated)\n{\n  return max_bytes_needed;\n}\n\n\n/*\n * Backing store (temporary file) management.\n * Since jpeg_mem_available always promised the moon,\n * this should never be called and we can just error out.\n */\n\nGLOBAL void\njpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,\n\t\t\t long total_bytes_needed)\n{\n  ERREXIT(cinfo, JERR_NO_BACKING_STORE);\n}\n\n\n/*\n * These routines take care of any system-dependent initialization and\n * cleanup required.  Here, there isn't any.\n */\n\nGLOBAL long\njpeg_mem_init (j_common_ptr cinfo)\n{\n  return 0;\t\t\t/* just set max_memory_to_use to 0 */\n}\n\nGLOBAL void\njpeg_mem_term (j_common_ptr cinfo)\n{\n  /* no work */\n}\n"
  },
  {
    "path": "code/jpeg-6/jmemsys.h",
    "content": "/*\n * jmemsys.h\n *\n * Copyright (C) 1992-1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This include file defines the interface between the system-independent\n * and system-dependent portions of the JPEG memory manager.  No other\n * modules need include it.  (The system-independent portion is jmemmgr.c;\n * there are several different versions of the system-dependent portion.)\n *\n * This file works as-is for the system-dependent memory managers supplied\n * in the IJG distribution.  You may need to modify it if you write a\n * custom memory manager.  If system-dependent changes are needed in\n * this file, the best method is to #ifdef them based on a configuration\n * symbol supplied in jconfig.h, as we have done with USE_MSDOS_MEMMGR.\n */\n\n\n/* Short forms of external names for systems with brain-damaged linkers. */\n\n#ifdef NEED_SHORT_EXTERNAL_NAMES\n#define jpeg_get_small\t\tjGetSmall\n#define jpeg_free_small\t\tjFreeSmall\n#define jpeg_get_large\t\tjGetLarge\n#define jpeg_free_large\t\tjFreeLarge\n#define jpeg_mem_available\tjMemAvail\n#define jpeg_open_backing_store\tjOpenBackStore\n#define jpeg_mem_init\t\tjMemInit\n#define jpeg_mem_term\t\tjMemTerm\n#endif /* NEED_SHORT_EXTERNAL_NAMES */\n\n\n/*\n * These two functions are used to allocate and release small chunks of\n * memory.  (Typically the total amount requested through jpeg_get_small is\n * no more than 20K or so; this will be requested in chunks of a few K each.)\n * Behavior should be the same as for the standard library functions malloc\n * and free; in particular, jpeg_get_small must return NULL on failure.\n * On most systems, these ARE malloc and free.  jpeg_free_small is passed the\n * size of the object being freed, just in case it's needed.\n * On an 80x86 machine using small-data memory model, these manage near heap.\n */\n\nEXTERN void * jpeg_get_small JPP((j_common_ptr cinfo, size_t sizeofobject));\nEXTERN void jpeg_free_small JPP((j_common_ptr cinfo, void * object,\n\t\t\t\t size_t sizeofobject));\n\n/*\n * These two functions are used to allocate and release large chunks of\n * memory (up to the total free space designated by jpeg_mem_available).\n * The interface is the same as above, except that on an 80x86 machine,\n * far pointers are used.  On most other machines these are identical to\n * the jpeg_get/free_small routines; but we keep them separate anyway,\n * in case a different allocation strategy is desirable for large chunks.\n */\n\nEXTERN void FAR * jpeg_get_large JPP((j_common_ptr cinfo,size_t sizeofobject));\nEXTERN void jpeg_free_large JPP((j_common_ptr cinfo, void FAR * object,\n\t\t\t\t size_t sizeofobject));\n\n/*\n * The macro MAX_ALLOC_CHUNK designates the maximum number of bytes that may\n * be requested in a single call to jpeg_get_large (and jpeg_get_small for that\n * matter, but that case should never come into play).  This macro is needed\n * to model the 64Kb-segment-size limit of far addressing on 80x86 machines.\n * On those machines, we expect that jconfig.h will provide a proper value.\n * On machines with 32-bit flat address spaces, any large constant may be used.\n *\n * NB: jmemmgr.c expects that MAX_ALLOC_CHUNK will be representable as type\n * size_t and will be a multiple of sizeof(align_type).\n */\n\n#ifndef MAX_ALLOC_CHUNK\t\t/* may be overridden in jconfig.h */\n#define MAX_ALLOC_CHUNK  1000000000L\n#endif\n\n/*\n * This routine computes the total space still available for allocation by\n * jpeg_get_large.  If more space than this is needed, backing store will be\n * used.  NOTE: any memory already allocated must not be counted.\n *\n * There is a minimum space requirement, corresponding to the minimum\n * feasible buffer sizes; jmemmgr.c will request that much space even if\n * jpeg_mem_available returns zero.  The maximum space needed, enough to hold\n * all working storage in memory, is also passed in case it is useful.\n * Finally, the total space already allocated is passed.  If no better\n * method is available, cinfo->mem->max_memory_to_use - already_allocated\n * is often a suitable calculation.\n *\n * It is OK for jpeg_mem_available to underestimate the space available\n * (that'll just lead to more backing-store access than is really necessary).\n * However, an overestimate will lead to failure.  Hence it's wise to subtract\n * a slop factor from the true available space.  5% should be enough.\n *\n * On machines with lots of virtual memory, any large constant may be returned.\n * Conversely, zero may be returned to always use the minimum amount of memory.\n */\n\nEXTERN long jpeg_mem_available JPP((j_common_ptr cinfo,\n\t\t\t\t    long min_bytes_needed,\n\t\t\t\t    long max_bytes_needed,\n\t\t\t\t    long already_allocated));\n\n\n/*\n * This structure holds whatever state is needed to access a single\n * backing-store object.  The read/write/close method pointers are called\n * by jmemmgr.c to manipulate the backing-store object; all other fields\n * are private to the system-dependent backing store routines.\n */\n\n#define TEMP_NAME_LENGTH   64\t/* max length of a temporary file's name */\n\n#ifdef USE_MSDOS_MEMMGR\t\t/* DOS-specific junk */\n\ntypedef unsigned short XMSH;\t/* type of extended-memory handles */\ntypedef unsigned short EMSH;\t/* type of expanded-memory handles */\n\ntypedef union {\n  short file_handle;\t\t/* DOS file handle if it's a temp file */\n  XMSH xms_handle;\t\t/* handle if it's a chunk of XMS */\n  EMSH ems_handle;\t\t/* handle if it's a chunk of EMS */\n} handle_union;\n\n#endif /* USE_MSDOS_MEMMGR */\n\ntypedef struct backing_store_struct * backing_store_ptr;\n\ntypedef struct backing_store_struct {\n  /* Methods for reading/writing/closing this backing-store object */\n  JMETHOD(void, read_backing_store, (j_common_ptr cinfo,\n\t\t\t\t     backing_store_ptr info,\n\t\t\t\t     void FAR * buffer_address,\n\t\t\t\t     long file_offset, long byte_count));\n  JMETHOD(void, write_backing_store, (j_common_ptr cinfo,\n\t\t\t\t      backing_store_ptr info,\n\t\t\t\t      void FAR * buffer_address,\n\t\t\t\t      long file_offset, long byte_count));\n  JMETHOD(void, close_backing_store, (j_common_ptr cinfo,\n\t\t\t\t      backing_store_ptr info));\n\n  /* Private fields for system-dependent backing-store management */\n#ifdef USE_MSDOS_MEMMGR\n  /* For the MS-DOS manager (jmemdos.c), we need: */\n  handle_union handle;\t\t/* reference to backing-store storage object */\n  char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */\n#else\n  /* For a typical implementation with temp files, we need: */\n  FILE * temp_file;\t\t/* stdio reference to temp file */\n  char temp_name[TEMP_NAME_LENGTH]; /* name of temp file */\n#endif\n} backing_store_info;\n\n/*\n * Initial opening of a backing-store object.  This must fill in the\n * read/write/close pointers in the object.  The read/write routines\n * may take an error exit if the specified maximum file size is exceeded.\n * (If jpeg_mem_available always returns a large value, this routine can\n * just take an error exit.)\n */\n\nEXTERN void jpeg_open_backing_store JPP((j_common_ptr cinfo,\n\t\t\t\t\t backing_store_ptr info,\n\t\t\t\t\t long total_bytes_needed));\n\n\n/*\n * These routines take care of any system-dependent initialization and\n * cleanup required.  jpeg_mem_init will be called before anything is\n * allocated (and, therefore, nothing in cinfo is of use except the error\n * manager pointer).  It should return a suitable default value for\n * max_memory_to_use; this may subsequently be overridden by the surrounding\n * application.  (Note that max_memory_to_use is only important if\n * jpeg_mem_available chooses to consult it ... no one else will.)\n * jpeg_mem_term may assume that all requested memory has been freed and that\n * all opened backing-store objects have been closed.\n */\n\nEXTERN long jpeg_mem_init JPP((j_common_ptr cinfo));\nEXTERN void jpeg_mem_term JPP((j_common_ptr cinfo));\n"
  },
  {
    "path": "code/jpeg-6/jmorecfg.h",
    "content": "/*\n * jmorecfg.h\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains additional configuration options that customize the\n * JPEG software for special applications or support machine-dependent\n * optimizations.  Most users will not need to touch this file.\n */\n\n\n/*\n * Define BITS_IN_JSAMPLE as either\n *   8   for 8-bit sample values (the usual setting)\n *   12  for 12-bit sample values\n * Only 8 and 12 are legal data precisions for lossy JPEG according to the\n * JPEG standard, and the IJG code does not support anything else!\n * We do not support run-time selection of data precision, sorry.\n */\n\n#define BITS_IN_JSAMPLE  8\t/* use 8 or 12 */\n\n\n/*\n * Maximum number of components (color channels) allowed in JPEG image.\n * To meet the letter of the JPEG spec, set this to 255.  However, darn\n * few applications need more than 4 channels (maybe 5 for CMYK + alpha\n * mask).  We recommend 10 as a reasonable compromise; use 4 if you are\n * really short on memory.  (Each allowed component costs a hundred or so\n * bytes of storage, whether actually used in an image or not.)\n */\n\n#define MAX_COMPONENTS  10\t/* maximum number of image components */\n\n\n/*\n * Basic data types.\n * You may need to change these if you have a machine with unusual data\n * type sizes; for example, \"char\" not 8 bits, \"short\" not 16 bits,\n * or \"long\" not 32 bits.  We don't care whether \"int\" is 16 or 32 bits,\n * but it had better be at least 16.\n */\n\n/* Representation of a single sample (pixel element value).\n * We frequently allocate large arrays of these, so it's important to keep\n * them small.  But if you have memory to burn and access to char or short\n * arrays is very slow on your hardware, you might want to change these.\n */\n\n#if BITS_IN_JSAMPLE == 8\n/* JSAMPLE should be the smallest type that will hold the values 0..255.\n * You can use a signed char by having GETJSAMPLE mask it with 0xFF.\n */\n\n#ifdef HAVE_UNSIGNED_CHAR\n\ntypedef unsigned char JSAMPLE;\n#define GETJSAMPLE(value)  ((int) (value))\n\n#else /* not HAVE_UNSIGNED_CHAR */\n\ntypedef char JSAMPLE;\n#ifdef CHAR_IS_UNSIGNED\n#define GETJSAMPLE(value)  ((int) (value))\n#else\n#define GETJSAMPLE(value)  ((int) (value) & 0xFF)\n#endif /* CHAR_IS_UNSIGNED */\n\n#endif /* HAVE_UNSIGNED_CHAR */\n\n#define MAXJSAMPLE\t255\n#define CENTERJSAMPLE\t128\n\n#endif /* BITS_IN_JSAMPLE == 8 */\n\n\n#if BITS_IN_JSAMPLE == 12\n/* JSAMPLE should be the smallest type that will hold the values 0..4095.\n * On nearly all machines \"short\" will do nicely.\n */\n\ntypedef short JSAMPLE;\n#define GETJSAMPLE(value)  ((int) (value))\n\n#define MAXJSAMPLE\t4095\n#define CENTERJSAMPLE\t2048\n\n#endif /* BITS_IN_JSAMPLE == 12 */\n\n\n/* Representation of a DCT frequency coefficient.\n * This should be a signed value of at least 16 bits; \"short\" is usually OK.\n * Again, we allocate large arrays of these, but you can change to int\n * if you have memory to burn and \"short\" is really slow.\n */\n\ntypedef short JCOEF;\n\n\n/* Compressed datastreams are represented as arrays of JOCTET.\n * These must be EXACTLY 8 bits wide, at least once they are written to\n * external storage.  Note that when using the stdio data source/destination\n * managers, this is also the data type passed to fread/fwrite.\n */\n\n#ifdef HAVE_UNSIGNED_CHAR\n\ntypedef unsigned char JOCTET;\n#define GETJOCTET(value)  (value)\n\n#else /* not HAVE_UNSIGNED_CHAR */\n\ntypedef char JOCTET;\n#ifdef CHAR_IS_UNSIGNED\n#define GETJOCTET(value)  (value)\n#else\n#define GETJOCTET(value)  ((value) & 0xFF)\n#endif /* CHAR_IS_UNSIGNED */\n\n#endif /* HAVE_UNSIGNED_CHAR */\n\n\n/* These typedefs are used for various table entries and so forth.\n * They must be at least as wide as specified; but making them too big\n * won't cost a huge amount of memory, so we don't provide special\n * extraction code like we did for JSAMPLE.  (In other words, these\n * typedefs live at a different point on the speed/space tradeoff curve.)\n */\n\n/* UINT8 must hold at least the values 0..255. */\n\n#ifdef HAVE_UNSIGNED_CHAR\ntypedef unsigned char UINT8;\n#else /* not HAVE_UNSIGNED_CHAR */\n#ifdef CHAR_IS_UNSIGNED\ntypedef char UINT8;\n#else /* not CHAR_IS_UNSIGNED */\ntypedef short UINT8;\n#endif /* CHAR_IS_UNSIGNED */\n#endif /* HAVE_UNSIGNED_CHAR */\n\n/* UINT16 must hold at least the values 0..65535. */\n\n#ifdef HAVE_UNSIGNED_SHORT\ntypedef unsigned short UINT16;\n#else /* not HAVE_UNSIGNED_SHORT */\ntypedef unsigned int UINT16;\n#endif /* HAVE_UNSIGNED_SHORT */\n\ntypedef long INT32;\n\n/* INT16 must hold at least the values -32768..32767. */\n\n#ifndef XMD_H\t\t\t/* X11/xmd.h correctly defines INT16 */\ntypedef short INT16;\n#endif\n\n/* INT32 must hold at least signed 32-bit values. */\n\n//#ifndef XMD_H\t\t\t/* X11/xmd.h correctly defines INT32 */\n//typedef long INT32;\n//#endif\n\n/* Datatype used for image dimensions.  The JPEG standard only supports\n * images up to 64K*64K due to 16-bit fields in SOF markers.  Therefore\n * \"unsigned int\" is sufficient on all machines.  However, if you need to\n * handle larger images and you don't mind deviating from the spec, you\n * can change this datatype.\n */\n\ntypedef unsigned int JDIMENSION;\n\n#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */\n\n\n/* These defines are used in all function definitions and extern declarations.\n * You could modify them if you need to change function linkage conventions.\n * Another application is to make all functions global for use with debuggers\n * or code profilers that require it.\n */\n\n#define METHODDEF static\t/* a function called through method pointers */\n#define LOCAL\t  static\t/* a function used only in its module */\n#define GLOBAL\t\t\t/* a function referenced thru EXTERNs */\n#define EXTERN\t  extern\t/* a reference to a GLOBAL function */\n\n\n/* Here is the pseudo-keyword for declaring pointers that must be \"far\"\n * on 80x86 machines.  Most of the specialized coding for 80x86 is handled\n * by just saying \"FAR *\" where such a pointer is needed.  In a few places\n * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol.\n */\n\n#ifdef NEED_FAR_POINTERS\n#undef FAR\n#define FAR  far\n#else\n#undef FAR\n#define FAR\n#endif\n\n\n/*\n * On a few systems, type boolean and/or its values FALSE, TRUE may appear\n * in standard header files.  Or you may have conflicts with application-\n * specific header files that you want to include together with these files.\n * Defining HAVE_BOOLEAN before including jpeglib.h should make it work.\n */\n\n//#ifndef HAVE_BOOLEAN\n//typedef int boolean;\n//#endif\n#ifndef FALSE\t\t\t/* in case these macros already exist */\n#define FALSE\t0\t\t/* values of boolean */\n#endif\n#ifndef TRUE\n#define TRUE\t1\n#endif\n\n\n/*\n * The remaining options affect code selection within the JPEG library,\n * but they don't need to be visible to most applications using the library.\n * To minimize application namespace pollution, the symbols won't be\n * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.\n */\n\n#ifdef JPEG_INTERNALS\n#define JPEG_INTERNAL_OPTIONS\n#endif\n\n#ifdef JPEG_INTERNAL_OPTIONS\n\n\n/*\n * These defines indicate whether to include various optional functions.\n * Undefining some of these symbols will produce a smaller but less capable\n * library.  Note that you can leave certain source files out of the\n * compilation/linking process if you've #undef'd the corresponding symbols.\n * (You may HAVE to do that if your compiler doesn't like null source files.)\n */\n\n/* Arithmetic coding is unsupported for legal reasons.  Complaints to IBM. */\n\n/* Capability options common to encoder and decoder: */\n\n#undef DCT_ISLOW_SUPPORTED\t/* slow but accurate integer algorithm */\n#undef DCT_IFAST_SUPPORTED\t/* faster, less accurate integer method */\n#define DCT_FLOAT_SUPPORTED\t/* floating-point: accurate, fast on fast HW */\n\n/* Encoder capability options: */\n\n#undef  C_ARITH_CODING_SUPPORTED    /* Arithmetic coding back end? */\n#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */\n#define C_PROGRESSIVE_SUPPORTED\t    /* Progressive JPEG? (Requires MULTISCAN)*/\n#define ENTROPY_OPT_SUPPORTED\t    /* Optimization of entropy coding parms? */\n/* Note: if you selected 12-bit data precision, it is dangerous to turn off\n * ENTROPY_OPT_SUPPORTED.  The standard Huffman tables are only good for 8-bit\n * precision, so jchuff.c normally uses entropy optimization to compute\n * usable tables for higher precision.  If you don't want to do optimization,\n * you'll have to supply different default Huffman tables.\n * The exact same statements apply for progressive JPEG: the default tables\n * don't work for progressive mode.  (This may get fixed, however.)\n */\n#define INPUT_SMOOTHING_SUPPORTED   /* Input image smoothing option? */\n\n/* Decoder capability options: */\n\n#undef  D_ARITH_CODING_SUPPORTED    /* Arithmetic coding back end? */\n#undef D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */\n#undef D_PROGRESSIVE_SUPPORTED\t    /* Progressive JPEG? (Requires MULTISCAN)*/\n#undef BLOCK_SMOOTHING_SUPPORTED   /* Block smoothing? (Progressive only) */\n#undef IDCT_SCALING_SUPPORTED\t    /* Output rescaling via IDCT? */\n#undef  UPSAMPLE_SCALING_SUPPORTED  /* Output rescaling at upsample stage? */\n#undef UPSAMPLE_MERGING_SUPPORTED  /* Fast path for sloppy upsampling? */\n#undef QUANT_1PASS_SUPPORTED\t    /* 1-pass color quantization? */\n#undef QUANT_2PASS_SUPPORTED\t    /* 2-pass color quantization? */\n\n/* more capability options later, no doubt */\n\n\n/*\n * Ordering of RGB data in scanlines passed to or from the application.\n * If your application wants to deal with data in the order B,G,R, just\n * change these macros.  You can also deal with formats such as R,G,B,X\n * (one extra byte per pixel) by changing RGB_PIXELSIZE.  Note that changing\n * the offsets will also change the order in which colormap data is organized.\n * RESTRICTIONS:\n * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.\n * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not\n *    useful if you are using JPEG color spaces other than YCbCr or grayscale.\n * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE\n *    is not 3 (they don't understand about dummy color components!).  So you\n *    can't use color quantization if you change that value.\n */\n\n#define RGB_RED\t\t0\t/* Offset of Red in an RGB scanline element */\n#define RGB_GREEN\t1\t/* Offset of Green */\n#define RGB_BLUE\t2\t/* Offset of Blue */\n#define RGB_PIXELSIZE\t4\t/* JSAMPLEs per RGB scanline element */\n\n\n/* Definitions for speed-related optimizations. */\n\n\n/* If your compiler supports inline functions, define INLINE\n * as the inline keyword; otherwise define it as empty.\n */\n\n#ifndef INLINE\n#ifdef __GNUC__\t\t\t/* for instance, GNU C knows about inline */\n#define INLINE __inline__\n#endif\n#ifndef INLINE\n#define INLINE\t\t\t/* default is to define it as empty */\n#endif\n#endif\n\n\n/* On some machines (notably 68000 series) \"int\" is 32 bits, but multiplying\n * two 16-bit shorts is faster than multiplying two ints.  Define MULTIPLIER\n * as short on such a machine.  MULTIPLIER must be at least 16 bits wide.\n */\n\n#ifndef MULTIPLIER\n#define MULTIPLIER  int\t\t/* type for fastest integer multiply */\n#endif\n\n\n/* FAST_FLOAT should be either float or double, whichever is done faster\n * by your compiler.  (Note that this type is only used in the floating point\n * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)\n * Typically, float is faster in ANSI C compilers, while double is faster in\n * pre-ANSI compilers (because they insist on converting to double anyway).\n * The code below therefore chooses float if we have ANSI-style prototypes.\n */\n\n#ifndef FAST_FLOAT\n#ifdef HAVE_PROTOTYPES\n#define FAST_FLOAT  float\n#else\n#define FAST_FLOAT  double\n#endif\n#endif\n\n#endif /* JPEG_INTERNAL_OPTIONS */\n"
  },
  {
    "path": "code/jpeg-6/jpegint.h",
    "content": "/*\n * jpegint.h\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file provides common declarations for the various JPEG modules.\n * These declarations are considered internal to the JPEG library; most\n * applications using the library shouldn't need to include this file.\n */\n\n\n/* Declarations for both compression & decompression */\n\ntypedef enum {\t\t\t/* Operating modes for buffer controllers */\n\tJBUF_PASS_THRU,\t\t/* Plain stripwise operation */\n\t/* Remaining modes require a full-image buffer to have been created */\n\tJBUF_SAVE_SOURCE,\t/* Run source subobject only, save output */\n\tJBUF_CRANK_DEST,\t/* Run dest subobject only, using saved data */\n\tJBUF_SAVE_AND_PASS\t/* Run both subobjects, save output */\n} J_BUF_MODE;\n\n/* Values of global_state field (jdapi.c has some dependencies on ordering!) */\n#define CSTATE_START\t100\t/* after create_compress */\n#define CSTATE_SCANNING\t101\t/* start_compress done, write_scanlines OK */\n#define CSTATE_RAW_OK\t102\t/* start_compress done, write_raw_data OK */\n#define CSTATE_WRCOEFS\t103\t/* jpeg_write_coefficients done */\n#define DSTATE_START\t200\t/* after create_decompress */\n#define DSTATE_INHEADER\t201\t/* reading header markers, no SOS yet */\n#define DSTATE_READY\t202\t/* found SOS, ready for start_decompress */\n#define DSTATE_PRELOAD\t203\t/* reading multiscan file in start_decompress*/\n#define DSTATE_PRESCAN\t204\t/* performing dummy pass for 2-pass quant */\n#define DSTATE_SCANNING\t205\t/* start_decompress done, read_scanlines OK */\n#define DSTATE_RAW_OK\t206\t/* start_decompress done, read_raw_data OK */\n#define DSTATE_BUFIMAGE\t207\t/* expecting jpeg_start_output */\n#define DSTATE_BUFPOST\t208\t/* looking for SOS/EOI in jpeg_finish_output */\n#define DSTATE_RDCOEFS\t209\t/* reading file in jpeg_read_coefficients */\n#define DSTATE_STOPPING\t210\t/* looking for EOI in jpeg_finish_decompress */\n\n\n/* Declarations for compression modules */\n\n/* Master control module */\nstruct jpeg_comp_master {\n  JMETHOD(void, prepare_for_pass, (j_compress_ptr cinfo));\n  JMETHOD(void, pass_startup, (j_compress_ptr cinfo));\n  JMETHOD(void, finish_pass, (j_compress_ptr cinfo));\n\n  /* State variables made visible to other modules */\n  boolean call_pass_startup;\t/* True if pass_startup must be called */\n  boolean is_last_pass;\t\t/* True during last pass */\n};\n\n/* Main buffer control (downsampled-data buffer) */\nstruct jpeg_c_main_controller {\n  JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));\n  JMETHOD(void, process_data, (j_compress_ptr cinfo,\n\t\t\t       JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,\n\t\t\t       JDIMENSION in_rows_avail));\n};\n\n/* Compression preprocessing (downsampling input buffer control) */\nstruct jpeg_c_prep_controller {\n  JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));\n  JMETHOD(void, pre_process_data, (j_compress_ptr cinfo,\n\t\t\t\t   JSAMPARRAY input_buf,\n\t\t\t\t   JDIMENSION *in_row_ctr,\n\t\t\t\t   JDIMENSION in_rows_avail,\n\t\t\t\t   JSAMPIMAGE output_buf,\n\t\t\t\t   JDIMENSION *out_row_group_ctr,\n\t\t\t\t   JDIMENSION out_row_groups_avail));\n};\n\n/* Coefficient buffer control */\nstruct jpeg_c_coef_controller {\n  JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));\n  JMETHOD(boolean, compress_data, (j_compress_ptr cinfo,\n\t\t\t\t   JSAMPIMAGE input_buf));\n};\n\n/* Colorspace conversion */\nstruct jpeg_color_converter {\n  JMETHOD(void, start_pass, (j_compress_ptr cinfo));\n  JMETHOD(void, color_convert, (j_compress_ptr cinfo,\n\t\t\t\tJSAMPARRAY input_buf, JSAMPIMAGE output_buf,\n\t\t\t\tJDIMENSION output_row, int num_rows));\n};\n\n/* Downsampling */\nstruct jpeg_downsampler {\n  JMETHOD(void, start_pass, (j_compress_ptr cinfo));\n  JMETHOD(void, downsample, (j_compress_ptr cinfo,\n\t\t\t     JSAMPIMAGE input_buf, JDIMENSION in_row_index,\n\t\t\t     JSAMPIMAGE output_buf,\n\t\t\t     JDIMENSION out_row_group_index));\n\n  boolean need_context_rows;\t/* TRUE if need rows above & below */\n};\n\n/* Forward DCT (also controls coefficient quantization) */\nstruct jpeg_forward_dct {\n  JMETHOD(void, start_pass, (j_compress_ptr cinfo));\n  /* perhaps this should be an array??? */\n  JMETHOD(void, forward_DCT, (j_compress_ptr cinfo,\n\t\t\t      jpeg_component_info * compptr,\n\t\t\t      JSAMPARRAY sample_data, JBLOCKROW coef_blocks,\n\t\t\t      JDIMENSION start_row, JDIMENSION start_col,\n\t\t\t      JDIMENSION num_blocks));\n};\n\n/* Entropy encoding */\nstruct jpeg_entropy_encoder {\n  JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics));\n  JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKROW *MCU_data));\n  JMETHOD(void, finish_pass, (j_compress_ptr cinfo));\n};\n\n/* Marker writing */\nstruct jpeg_marker_writer {\n  /* write_any_marker is exported for use by applications */\n  /* Probably only COM and APPn markers should be written */\n  JMETHOD(void, write_any_marker, (j_compress_ptr cinfo, int marker,\n\t\t\t\t   const JOCTET *dataptr, unsigned int datalen));\n  JMETHOD(void, write_file_header, (j_compress_ptr cinfo));\n  JMETHOD(void, write_frame_header, (j_compress_ptr cinfo));\n  JMETHOD(void, write_scan_header, (j_compress_ptr cinfo));\n  JMETHOD(void, write_file_trailer, (j_compress_ptr cinfo));\n  JMETHOD(void, write_tables_only, (j_compress_ptr cinfo));\n};\n\n\n/* Declarations for decompression modules */\n\n/* Master control module */\nstruct jpeg_decomp_master {\n  JMETHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo));\n  JMETHOD(void, finish_output_pass, (j_decompress_ptr cinfo));\n\n  /* State variables made visible to other modules */\n  boolean is_dummy_pass;\t/* True during 1st pass for 2-pass quant */\n};\n\n/* Input control module */\nstruct jpeg_input_controller {\n  JMETHOD(int, consume_input, (j_decompress_ptr cinfo));\n  JMETHOD(void, reset_input_controller, (j_decompress_ptr cinfo));\n  JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo));\n  JMETHOD(void, finish_input_pass, (j_decompress_ptr cinfo));\n\n  /* State variables made visible to other modules */\n  boolean has_multiple_scans;\t/* True if file has multiple scans */\n  boolean eoi_reached;\t\t/* True when EOI has been consumed */\n};\n\n/* Main buffer control (downsampled-data buffer) */\nstruct jpeg_d_main_controller {\n  JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));\n  JMETHOD(void, process_data, (j_decompress_ptr cinfo,\n\t\t\t       JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t\t\t       JDIMENSION out_rows_avail));\n};\n\n/* Coefficient buffer control */\nstruct jpeg_d_coef_controller {\n  JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo));\n  JMETHOD(int, consume_data, (j_decompress_ptr cinfo));\n  JMETHOD(void, start_output_pass, (j_decompress_ptr cinfo));\n  JMETHOD(int, decompress_data, (j_decompress_ptr cinfo,\n\t\t\t\t JSAMPIMAGE output_buf));\n  /* Pointer to array of coefficient virtual arrays, or NULL if none */\n  jvirt_barray_ptr *coef_arrays;\n};\n\n/* Decompression postprocessing (color quantization buffer control) */\nstruct jpeg_d_post_controller {\n  JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));\n  JMETHOD(void, post_process_data, (j_decompress_ptr cinfo,\n\t\t\t\t    JSAMPIMAGE input_buf,\n\t\t\t\t    JDIMENSION *in_row_group_ctr,\n\t\t\t\t    JDIMENSION in_row_groups_avail,\n\t\t\t\t    JSAMPARRAY output_buf,\n\t\t\t\t    JDIMENSION *out_row_ctr,\n\t\t\t\t    JDIMENSION out_rows_avail));\n};\n\n/* Marker reading & parsing */\nstruct jpeg_marker_reader {\n  JMETHOD(void, reset_marker_reader, (j_decompress_ptr cinfo));\n  /* Read markers until SOS or EOI.\n   * Returns same codes as are defined for jpeg_consume_input:\n   * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.\n   */\n  JMETHOD(int, read_markers, (j_decompress_ptr cinfo));\n  /* Read a restart marker --- exported for use by entropy decoder only */\n  jpeg_marker_parser_method read_restart_marker;\n  /* Application-overridable marker processing methods */\n  jpeg_marker_parser_method process_COM;\n  jpeg_marker_parser_method process_APPn[16];\n\n  /* State of marker reader --- nominally internal, but applications\n   * supplying COM or APPn handlers might like to know the state.\n   */\n  boolean saw_SOI;\t\t/* found SOI? */\n  boolean saw_SOF;\t\t/* found SOF? */\n  int next_restart_num;\t\t/* next restart number expected (0-7) */\n  unsigned int discarded_bytes;\t/* # of bytes skipped looking for a marker */\n};\n\n/* Entropy decoding */\nstruct jpeg_entropy_decoder {\n  JMETHOD(void, start_pass, (j_decompress_ptr cinfo));\n  JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo,\n\t\t\t\tJBLOCKROW *MCU_data));\n};\n\n/* Inverse DCT (also performs dequantization) */\ntypedef JMETHOD(void, inverse_DCT_method_ptr,\n\t\t(j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t\t JCOEFPTR coef_block,\n\t\t JSAMPARRAY output_buf, JDIMENSION output_col));\n\nstruct jpeg_inverse_dct {\n  JMETHOD(void, start_pass, (j_decompress_ptr cinfo));\n  /* It is useful to allow each component to have a separate IDCT method. */\n  inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS];\n};\n\n/* Upsampling (note that upsampler must also call color converter) */\nstruct jpeg_upsampler {\n  JMETHOD(void, start_pass, (j_decompress_ptr cinfo));\n  JMETHOD(void, upsample, (j_decompress_ptr cinfo,\n\t\t\t   JSAMPIMAGE input_buf,\n\t\t\t   JDIMENSION *in_row_group_ctr,\n\t\t\t   JDIMENSION in_row_groups_avail,\n\t\t\t   JSAMPARRAY output_buf,\n\t\t\t   JDIMENSION *out_row_ctr,\n\t\t\t   JDIMENSION out_rows_avail));\n\n  boolean need_context_rows;\t/* TRUE if need rows above & below */\n};\n\n/* Colorspace conversion */\nstruct jpeg_color_deconverter {\n  JMETHOD(void, start_pass, (j_decompress_ptr cinfo));\n  JMETHOD(void, color_convert, (j_decompress_ptr cinfo,\n\t\t\t\tJSAMPIMAGE input_buf, JDIMENSION input_row,\n\t\t\t\tJSAMPARRAY output_buf, int num_rows));\n};\n\n/* Color quantization or color precision reduction */\nstruct jpeg_color_quantizer {\n  JMETHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan));\n  JMETHOD(void, color_quantize, (j_decompress_ptr cinfo,\n\t\t\t\t JSAMPARRAY input_buf, JSAMPARRAY output_buf,\n\t\t\t\t int num_rows));\n  JMETHOD(void, finish_pass, (j_decompress_ptr cinfo));\n  JMETHOD(void, new_color_map, (j_decompress_ptr cinfo));\n};\n\n\n/* Miscellaneous useful macros */\n\n#undef MAX\n#define MAX(a,b)\t((a) > (b) ? (a) : (b))\n#undef MIN\n#define MIN(a,b)\t((a) < (b) ? (a) : (b))\n\n\n/* We assume that right shift corresponds to signed division by 2 with\n * rounding towards minus infinity.  This is correct for typical \"arithmetic\n * shift\" instructions that shift in copies of the sign bit.  But some\n * C compilers implement >> with an unsigned shift.  For these machines you\n * must define RIGHT_SHIFT_IS_UNSIGNED.\n * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity.\n * It is only applied with constant shift counts.  SHIFT_TEMPS must be\n * included in the variables of any routine using RIGHT_SHIFT.\n */\n\n#ifdef RIGHT_SHIFT_IS_UNSIGNED\n#define SHIFT_TEMPS\tINT32 shift_temp;\n#define RIGHT_SHIFT(x,shft)  \\\n\t((shift_temp = (x)) < 0 ? \\\n\t (shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \\\n\t (shift_temp >> (shft)))\n#else\n#define SHIFT_TEMPS\n#define RIGHT_SHIFT(x,shft)\t((x) >> (shft))\n#endif\n\n\n/* Short forms of external names for systems with brain-damaged linkers. */\n\n#ifdef NEED_SHORT_EXTERNAL_NAMES\n#define jinit_compress_master\tjICompress\n#define jinit_c_master_control\tjICMaster\n#define jinit_c_main_controller\tjICMainC\n#define jinit_c_prep_controller\tjICPrepC\n#define jinit_c_coef_controller\tjICCoefC\n#define jinit_color_converter\tjICColor\n#define jinit_downsampler\tjIDownsampler\n#define jinit_forward_dct\tjIFDCT\n#define jinit_huff_encoder\tjIHEncoder\n#define jinit_phuff_encoder\tjIPHEncoder\n#define jinit_marker_writer\tjIMWriter\n#define jinit_master_decompress\tjIDMaster\n#define jinit_d_main_controller\tjIDMainC\n#define jinit_d_coef_controller\tjIDCoefC\n#define jinit_d_post_controller\tjIDPostC\n#define jinit_input_controller\tjIInCtlr\n#define jinit_marker_reader\tjIMReader\n#define jinit_huff_decoder\tjIHDecoder\n#define jinit_phuff_decoder\tjIPHDecoder\n#define jinit_inverse_dct\tjIIDCT\n#define jinit_upsampler\t\tjIUpsampler\n#define jinit_color_deconverter\tjIDColor\n#define jinit_1pass_quantizer\tjI1Quant\n#define jinit_2pass_quantizer\tjI2Quant\n#define jinit_merged_upsampler\tjIMUpsampler\n#define jinit_memory_mgr\tjIMemMgr\n#define jdiv_round_up\t\tjDivRound\n#define jround_up\t\tjRound\n#define jcopy_sample_rows\tjCopySamples\n#define jcopy_block_row\t\tjCopyBlocks\n#define jzero_far\t\tjZeroFar\n#define jpeg_zigzag_order\tjZIGTable\n#define jpeg_natural_order\tjZAGTable\n#endif /* NEED_SHORT_EXTERNAL_NAMES */\n\n\n/* Compression module initialization routines */\nEXTERN void jinit_compress_master JPP((j_compress_ptr cinfo));\nEXTERN void jinit_c_master_control JPP((j_compress_ptr cinfo,\n\t\t\t\t\tboolean transcode_only));\nEXTERN void jinit_c_main_controller JPP((j_compress_ptr cinfo,\n\t\t\t\t\t boolean need_full_buffer));\nEXTERN void jinit_c_prep_controller JPP((j_compress_ptr cinfo,\n\t\t\t\t\t boolean need_full_buffer));\nEXTERN void jinit_c_coef_controller JPP((j_compress_ptr cinfo,\n\t\t\t\t\t boolean need_full_buffer));\nEXTERN void jinit_color_converter JPP((j_compress_ptr cinfo));\nEXTERN void jinit_downsampler JPP((j_compress_ptr cinfo));\nEXTERN void jinit_forward_dct JPP((j_compress_ptr cinfo));\nEXTERN void jinit_huff_encoder JPP((j_compress_ptr cinfo));\nEXTERN void jinit_phuff_encoder JPP((j_compress_ptr cinfo));\nEXTERN void jinit_marker_writer JPP((j_compress_ptr cinfo));\n/* Decompression module initialization routines */\nEXTERN void jinit_master_decompress JPP((j_decompress_ptr cinfo));\nEXTERN void jinit_d_main_controller JPP((j_decompress_ptr cinfo,\n\t\t\t\t\t boolean need_full_buffer));\nEXTERN void jinit_d_coef_controller JPP((j_decompress_ptr cinfo,\n\t\t\t\t\t boolean need_full_buffer));\nEXTERN void jinit_d_post_controller JPP((j_decompress_ptr cinfo,\n\t\t\t\t\t boolean need_full_buffer));\nEXTERN void jinit_input_controller JPP((j_decompress_ptr cinfo));\nEXTERN void jinit_marker_reader JPP((j_decompress_ptr cinfo));\nEXTERN void jinit_huff_decoder JPP((j_decompress_ptr cinfo));\nEXTERN void jinit_phuff_decoder JPP((j_decompress_ptr cinfo));\nEXTERN void jinit_inverse_dct JPP((j_decompress_ptr cinfo));\nEXTERN void jinit_upsampler JPP((j_decompress_ptr cinfo));\nEXTERN void jinit_color_deconverter JPP((j_decompress_ptr cinfo));\nEXTERN void jinit_1pass_quantizer JPP((j_decompress_ptr cinfo));\nEXTERN void jinit_2pass_quantizer JPP((j_decompress_ptr cinfo));\nEXTERN void jinit_merged_upsampler JPP((j_decompress_ptr cinfo));\n/* Memory manager initialization */\nEXTERN void jinit_memory_mgr JPP((j_common_ptr cinfo));\n\n/* Utility routines in jutils.c */\nEXTERN long jdiv_round_up JPP((long a, long b));\nEXTERN long jround_up JPP((long a, long b));\nEXTERN void jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row,\n\t\t\t\t   JSAMPARRAY output_array, int dest_row,\n\t\t\t\t   int num_rows, JDIMENSION num_cols));\nEXTERN void jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row,\n\t\t\t\t JDIMENSION num_blocks));\nEXTERN void jzero_far JPP((void FAR * target, size_t bytestozero));\n/* Constant tables in jutils.c */\nextern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */\nextern const int jpeg_natural_order[]; /* zigzag coef order to natural order */\n\n/* Suppress undefined-structure complaints if necessary. */\n\n#ifdef INCOMPLETE_TYPES_BROKEN\n#ifndef AM_MEMORY_MANAGER\t/* only jmemmgr.c defines these */\nstruct jvirt_sarray_control { long dummy; };\nstruct jvirt_barray_control { long dummy; };\n#endif\n#endif /* INCOMPLETE_TYPES_BROKEN */\n"
  },
  {
    "path": "code/jpeg-6/jpeglib.h",
    "content": "/*\n * jpeglib.h\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file defines the application interface for the JPEG library.\n * Most applications using the library need only include this file,\n * and perhaps jerror.h if they want to know the exact error codes.\n */\n\n#ifndef JPEGLIB_H\n#define JPEGLIB_H\n\ntypedef unsigned char boolean;\n/*\n * First we include the configuration files that record how this\n * installation of the JPEG library is set up.  jconfig.h can be\n * generated automatically for many systems.  jmorecfg.h contains\n * manual configuration options that most people need not worry about.\n */\n\n#ifndef JCONFIG_INCLUDED\t/* in case jinclude.h already did */\n#include \"../jpeg-6/jconfig.h\"\t\t/* widely used configuration options */\n#endif\n#include \"../jpeg-6/jmorecfg.h\"\t\t/* seldom changed options */\n\n\n/* Version ID for the JPEG library.\n * Might be useful for tests like \"#if JPEG_LIB_VERSION >= 60\".\n */\n\n#define JPEG_LIB_VERSION  60\t/* Version 6 */\n\n\n/* Various constants determining the sizes of things.\n * All of these are specified by the JPEG standard, so don't change them\n * if you want to be compatible.\n */\n\n#define DCTSIZE\t\t    8\t/* The basic DCT block is 8x8 samples */\n#define DCTSIZE2\t    64\t/* DCTSIZE squared; # of elements in a block */\n#define NUM_QUANT_TBLS      4\t/* Quantization tables are numbered 0..3 */\n#define NUM_HUFF_TBLS       4\t/* Huffman tables are numbered 0..3 */\n#define NUM_ARITH_TBLS      16\t/* Arith-coding tables are numbered 0..15 */\n#define MAX_COMPS_IN_SCAN   4\t/* JPEG limit on # of components in one scan */\n#define MAX_SAMP_FACTOR     4\t/* JPEG limit on sampling factors */\n/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard;\n * the PostScript DCT filter can emit files with many more than 10 blocks/MCU.\n * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU\n * to handle it.  We even let you do this from the jconfig.h file.  However,\n * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe\n * sometimes emits noncompliant files doesn't mean you should too.\n */\n#define C_MAX_BLOCKS_IN_MCU   10 /* compressor's limit on blocks per MCU */\n#ifndef D_MAX_BLOCKS_IN_MCU\n#define D_MAX_BLOCKS_IN_MCU   10 /* decompressor's limit on blocks per MCU */\n#endif\n\n\n/* This macro is used to declare a \"method\", that is, a function pointer.\n * We want to supply prototype parameters if the compiler can cope.\n * Note that the arglist parameter must be parenthesized!\n */\n\n#ifdef HAVE_PROTOTYPES\n#define JMETHOD(type,methodname,arglist)  type (*methodname) arglist\n#else\n#define JMETHOD(type,methodname,arglist)  type (*methodname) ()\n#endif\n\n\n/* Data structures for images (arrays of samples and of DCT coefficients).\n * On 80x86 machines, the image arrays are too big for near pointers,\n * but the pointer arrays can fit in near memory.\n */\n\ntypedef JSAMPLE FAR *JSAMPROW;\t/* ptr to one image row of pixel samples. */\ntypedef JSAMPROW *JSAMPARRAY;\t/* ptr to some rows (a 2-D sample array) */\ntypedef JSAMPARRAY *JSAMPIMAGE;\t/* a 3-D sample array: top index is color */\n\ntypedef JCOEF JBLOCK[DCTSIZE2];\t/* one block of coefficients */\ntypedef JBLOCK FAR *JBLOCKROW;\t/* pointer to one row of coefficient blocks */\ntypedef JBLOCKROW *JBLOCKARRAY;\t\t/* a 2-D array of coefficient blocks */\ntypedef JBLOCKARRAY *JBLOCKIMAGE;\t/* a 3-D array of coefficient blocks */\n\ntypedef JCOEF FAR *JCOEFPTR;\t/* useful in a couple of places */\n\n\n/* Types for JPEG compression parameters and working tables. */\n\n\n/* DCT coefficient quantization tables. */\n\ntypedef struct {\n  /* This field directly represents the contents of a JPEG DQT marker.\n   * Note: the values are always given in zigzag order.\n   */\n  UINT16 quantval[DCTSIZE2];\t/* quantization step for each coefficient */\n  /* This field is used only during compression.  It's initialized FALSE when\n   * the table is created, and set TRUE when it's been output to the file.\n   * You could suppress output of a table by setting this to TRUE.\n   * (See jpeg_suppress_tables for an example.)\n   */\n  boolean sent_table;\t\t/* TRUE when table has been output */\n} JQUANT_TBL;\n\n\n/* Huffman coding tables. */\n\ntypedef struct {\n  /* These two fields directly represent the contents of a JPEG DHT marker */\n  UINT8 bits[17];\t\t/* bits[k] = # of symbols with codes of */\n\t\t\t\t/* length k bits; bits[0] is unused */\n  UINT8 huffval[256];\t\t/* The symbols, in order of incr code length */\n  /* This field is used only during compression.  It's initialized FALSE when\n   * the table is created, and set TRUE when it's been output to the file.\n   * You could suppress output of a table by setting this to TRUE.\n   * (See jpeg_suppress_tables for an example.)\n   */\n  boolean sent_table;\t\t/* TRUE when table has been output */\n} JHUFF_TBL;\n\n\n/* Basic info about one component (color channel). */\n\ntypedef struct {\n  /* These values are fixed over the whole image. */\n  /* For compression, they must be supplied by parameter setup; */\n  /* for decompression, they are read from the SOF marker. */\n  int component_id;\t\t/* identifier for this component (0..255) */\n  int component_index;\t\t/* its index in SOF or cinfo->comp_info[] */\n  int h_samp_factor;\t\t/* horizontal sampling factor (1..4) */\n  int v_samp_factor;\t\t/* vertical sampling factor (1..4) */\n  int quant_tbl_no;\t\t/* quantization table selector (0..3) */\n  /* These values may vary between scans. */\n  /* For compression, they must be supplied by parameter setup; */\n  /* for decompression, they are read from the SOS marker. */\n  /* The decompressor output side may not use these variables. */\n  int dc_tbl_no;\t\t/* DC entropy table selector (0..3) */\n  int ac_tbl_no;\t\t/* AC entropy table selector (0..3) */\n  \n  /* Remaining fields should be treated as private by applications. */\n  \n  /* These values are computed during compression or decompression startup: */\n  /* Component's size in DCT blocks.\n   * Any dummy blocks added to complete an MCU are not counted; therefore\n   * these values do not depend on whether a scan is interleaved or not.\n   */\n  JDIMENSION width_in_blocks;\n  JDIMENSION height_in_blocks;\n  /* Size of a DCT block in samples.  Always DCTSIZE for compression.\n   * For decompression this is the size of the output from one DCT block,\n   * reflecting any scaling we choose to apply during the IDCT step.\n   * Values of 1,2,4,8 are likely to be supported.  Note that different\n   * components may receive different IDCT scalings.\n   */\n  int DCT_scaled_size;\n  /* The downsampled dimensions are the component's actual, unpadded number\n   * of samples at the main buffer (preprocessing/compression interface), thus\n   * downsampled_width = ceil(image_width * Hi/Hmax)\n   * and similarly for height.  For decompression, IDCT scaling is included, so\n   * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE)\n   */\n  JDIMENSION downsampled_width;\t /* actual width in samples */\n  JDIMENSION downsampled_height; /* actual height in samples */\n  /* This flag is used only for decompression.  In cases where some of the\n   * components will be ignored (eg grayscale output from YCbCr image),\n   * we can skip most computations for the unused components.\n   */\n  boolean component_needed;\t/* do we need the value of this component? */\n\n  /* These values are computed before starting a scan of the component. */\n  /* The decompressor output side may not use these variables. */\n  int MCU_width;\t\t/* number of blocks per MCU, horizontally */\n  int MCU_height;\t\t/* number of blocks per MCU, vertically */\n  int MCU_blocks;\t\t/* MCU_width * MCU_height */\n  int MCU_sample_width;\t\t/* MCU width in samples, MCU_width*DCT_scaled_size */\n  int last_col_width;\t\t/* # of non-dummy blocks across in last MCU */\n  int last_row_height;\t\t/* # of non-dummy blocks down in last MCU */\n\n  /* Saved quantization table for component; NULL if none yet saved.\n   * See jdinput.c comments about the need for this information.\n   * This field is not currently used by the compressor.\n   */\n  JQUANT_TBL * quant_table;\n\n  /* Private per-component storage for DCT or IDCT subsystem. */\n  void * dct_table;\n} jpeg_component_info;\n\n\n/* The script for encoding a multiple-scan file is an array of these: */\n\ntypedef struct {\n  int comps_in_scan;\t\t/* number of components encoded in this scan */\n  int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */\n  int Ss, Se;\t\t\t/* progressive JPEG spectral selection parms */\n  int Ah, Al;\t\t\t/* progressive JPEG successive approx. parms */\n} jpeg_scan_info;\n\n\n/* Known color spaces. */\n\ntypedef enum {\n\tJCS_UNKNOWN,\t\t/* error/unspecified */\n\tJCS_GRAYSCALE,\t\t/* monochrome */\n\tJCS_RGB,\t\t/* red/green/blue */\n\tJCS_YCbCr,\t\t/* Y/Cb/Cr (also known as YUV) */\n\tJCS_CMYK,\t\t/* C/M/Y/K */\n\tJCS_YCCK\t\t/* Y/Cb/Cr/K */\n} J_COLOR_SPACE;\n\n/* DCT/IDCT algorithm options. */\n\ntypedef enum {\n\tJDCT_ISLOW,\t\t/* slow but accurate integer algorithm */\n\tJDCT_IFAST,\t\t/* faster, less accurate integer method */\n\tJDCT_FLOAT\t\t/* floating-point: accurate, fast on fast HW */\n} J_DCT_METHOD;\n\n#ifndef JDCT_DEFAULT\t\t/* may be overridden in jconfig.h */\n#define JDCT_DEFAULT  JDCT_ISLOW\n#endif\n#ifndef JDCT_FASTEST\t\t/* may be overridden in jconfig.h */\n#define JDCT_FASTEST  JDCT_IFAST\n#endif\n\n/* Dithering options for decompression. */\n\ntypedef enum {\n\tJDITHER_NONE,\t\t/* no dithering */\n\tJDITHER_ORDERED,\t/* simple ordered dither */\n\tJDITHER_FS\t\t/* Floyd-Steinberg error diffusion dither */\n} J_DITHER_MODE;\n\n\n/* Common fields between JPEG compression and decompression master structs. */\n\n#define jpeg_common_fields \\\n  struct jpeg_error_mgr * err;\t/* Error handler module */\\\n  struct jpeg_memory_mgr * mem;\t/* Memory manager module */\\\n  struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\\\n  boolean is_decompressor;\t/* so common code can tell which is which */\\\n  int global_state\t\t/* for checking call sequence validity */\n\n/* Routines that are to be used by both halves of the library are declared\n * to receive a pointer to this structure.  There are no actual instances of\n * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct.\n */\nstruct jpeg_common_struct {\n  jpeg_common_fields;\t\t/* Fields common to both master struct types */\n  /* Additional fields follow in an actual jpeg_compress_struct or\n   * jpeg_decompress_struct.  All three structs must agree on these\n   * initial fields!  (This would be a lot cleaner in C++.)\n   */\n};\n\ntypedef struct jpeg_common_struct * j_common_ptr;\ntypedef struct jpeg_compress_struct * j_compress_ptr;\ntypedef struct jpeg_decompress_struct * j_decompress_ptr;\n\n\n/* Master record for a compression instance */\n\nstruct jpeg_compress_struct {\n  jpeg_common_fields;\t\t/* Fields shared with jpeg_decompress_struct */\n\n  /* Destination for compressed data */\n  struct jpeg_destination_mgr * dest;\n\n  /* Description of source image --- these fields must be filled in by\n   * outer application before starting compression.  in_color_space must\n   * be correct before you can even call jpeg_set_defaults().\n   */\n\n  JDIMENSION image_width;\t/* input image width */\n  JDIMENSION image_height;\t/* input image height */\n  int input_components;\t\t/* # of color components in input image */\n  J_COLOR_SPACE in_color_space;\t/* colorspace of input image */\n\n  double input_gamma;\t\t/* image gamma of input image */\n\n  /* Compression parameters --- these fields must be set before calling\n   * jpeg_start_compress().  We recommend calling jpeg_set_defaults() to\n   * initialize everything to reasonable defaults, then changing anything\n   * the application specifically wants to change.  That way you won't get\n   * burnt when new parameters are added.  Also note that there are several\n   * helper routines to simplify changing parameters.\n   */\n\n  int data_precision;\t\t/* bits of precision in image data */\n\n  int num_components;\t\t/* # of color components in JPEG image */\n  J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */\n\n  jpeg_component_info * comp_info;\n  /* comp_info[i] describes component that appears i'th in SOF */\n  \n  JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS];\n  /* ptrs to coefficient quantization tables, or NULL if not defined */\n  \n  JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS];\n  JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS];\n  /* ptrs to Huffman coding tables, or NULL if not defined */\n  \n  UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */\n  UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */\n  UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */\n\n  int num_scans;\t\t/* # of entries in scan_info array */\n  const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */\n  /* The default value of scan_info is NULL, which causes a single-scan\n   * sequential JPEG file to be emitted.  To create a multi-scan file,\n   * set num_scans and scan_info to point to an array of scan definitions.\n   */\n\n  boolean raw_data_in;\t\t/* TRUE=caller supplies downsampled data */\n  boolean arith_code;\t\t/* TRUE=arithmetic coding, FALSE=Huffman */\n  boolean optimize_coding;\t/* TRUE=optimize entropy encoding parms */\n  boolean CCIR601_sampling;\t/* TRUE=first samples are cosited */\n  int smoothing_factor;\t\t/* 1..100, or 0 for no input smoothing */\n  J_DCT_METHOD dct_method;\t/* DCT algorithm selector */\n\n  /* The restart interval can be specified in absolute MCUs by setting\n   * restart_interval, or in MCU rows by setting restart_in_rows\n   * (in which case the correct restart_interval will be figured\n   * for each scan).\n   */\n  unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */\n  int restart_in_rows;\t\t/* if > 0, MCU rows per restart interval */\n\n  /* Parameters controlling emission of special markers. */\n\n  boolean write_JFIF_header;\t/* should a JFIF marker be written? */\n  /* These three values are not used by the JPEG code, merely copied */\n  /* into the JFIF APP0 marker.  density_unit can be 0 for unknown, */\n  /* 1 for dots/inch, or 2 for dots/cm.  Note that the pixel aspect */\n  /* ratio is defined by X_density/Y_density even when density_unit=0. */\n  UINT8 density_unit;\t\t/* JFIF code for pixel size units */\n  UINT16 X_density;\t\t/* Horizontal pixel density */\n  UINT16 Y_density;\t\t/* Vertical pixel density */\n  boolean write_Adobe_marker;\t/* should an Adobe marker be written? */\n  \n  /* State variable: index of next scanline to be written to\n   * jpeg_write_scanlines().  Application may use this to control its\n   * processing loop, e.g., \"while (next_scanline < image_height)\".\n   */\n\n  JDIMENSION next_scanline;\t/* 0 .. image_height-1  */\n\n  /* Remaining fields are known throughout compressor, but generally\n   * should not be touched by a surrounding application.\n   */\n\n  /*\n   * These fields are computed during compression startup\n   */\n  boolean progressive_mode;\t/* TRUE if scan script uses progressive mode */\n  int max_h_samp_factor;\t/* largest h_samp_factor */\n  int max_v_samp_factor;\t/* largest v_samp_factor */\n\n  JDIMENSION total_iMCU_rows;\t/* # of iMCU rows to be input to coef ctlr */\n  /* The coefficient controller receives data in units of MCU rows as defined\n   * for fully interleaved scans (whether the JPEG file is interleaved or not).\n   * There are v_samp_factor * DCTSIZE sample rows of each component in an\n   * \"iMCU\" (interleaved MCU) row.\n   */\n  \n  /*\n   * These fields are valid during any one scan.\n   * They describe the components and MCUs actually appearing in the scan.\n   */\n  int comps_in_scan;\t\t/* # of JPEG components in this scan */\n  jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];\n  /* *cur_comp_info[i] describes component that appears i'th in SOS */\n  \n  JDIMENSION MCUs_per_row;\t/* # of MCUs across the image */\n  JDIMENSION MCU_rows_in_scan;\t/* # of MCU rows in the image */\n  \n  int blocks_in_MCU;\t\t/* # of DCT blocks per MCU */\n  int MCU_membership[C_MAX_BLOCKS_IN_MCU];\n  /* MCU_membership[i] is index in cur_comp_info of component owning */\n  /* i'th block in an MCU */\n\n  int Ss, Se, Ah, Al;\t\t/* progressive JPEG parameters for scan */\n\n  /*\n   * Links to compression subobjects (methods and private variables of modules)\n   */\n  struct jpeg_comp_master * master;\n  struct jpeg_c_main_controller * main;\n  struct jpeg_c_prep_controller * prep;\n  struct jpeg_c_coef_controller * coef;\n  struct jpeg_marker_writer * marker;\n  struct jpeg_color_converter * cconvert;\n  struct jpeg_downsampler * downsample;\n  struct jpeg_forward_dct * fdct;\n  struct jpeg_entropy_encoder * entropy;\n};\n\n\n/* Master record for a decompression instance */\n\nstruct jpeg_decompress_struct {\n  jpeg_common_fields;\t\t/* Fields shared with jpeg_compress_struct */\n\n  /* Source of compressed data */\n  struct jpeg_source_mgr * src;\n\n  /* Basic description of image --- filled in by jpeg_read_header(). */\n  /* Application may inspect these values to decide how to process image. */\n\n  JDIMENSION image_width;\t/* nominal image width (from SOF marker) */\n  JDIMENSION image_height;\t/* nominal image height */\n  int num_components;\t\t/* # of color components in JPEG image */\n  J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */\n\n  /* Decompression processing parameters --- these fields must be set before\n   * calling jpeg_start_decompress().  Note that jpeg_read_header() initializes\n   * them to default values.\n   */\n\n  J_COLOR_SPACE out_color_space; /* colorspace for output */\n\n  unsigned int scale_num, scale_denom; /* fraction by which to scale image */\n\n  double output_gamma;\t\t/* image gamma wanted in output */\n\n  boolean buffered_image;\t/* TRUE=multiple output passes */\n  boolean raw_data_out;\t\t/* TRUE=downsampled data wanted */\n\n  J_DCT_METHOD dct_method;\t/* IDCT algorithm selector */\n  boolean do_fancy_upsampling;\t/* TRUE=apply fancy upsampling */\n  boolean do_block_smoothing;\t/* TRUE=apply interblock smoothing */\n\n  boolean quantize_colors;\t/* TRUE=colormapped output wanted */\n  /* the following are ignored if not quantize_colors: */\n  J_DITHER_MODE dither_mode;\t/* type of color dithering to use */\n  boolean two_pass_quantize;\t/* TRUE=use two-pass color quantization */\n  int desired_number_of_colors;\t/* max # colors to use in created colormap */\n  /* these are significant only in buffered-image mode: */\n  boolean enable_1pass_quant;\t/* enable future use of 1-pass quantizer */\n  boolean enable_external_quant;/* enable future use of external colormap */\n  boolean enable_2pass_quant;\t/* enable future use of 2-pass quantizer */\n\n  /* Description of actual output image that will be returned to application.\n   * These fields are computed by jpeg_start_decompress().\n   * You can also use jpeg_calc_output_dimensions() to determine these values\n   * in advance of calling jpeg_start_decompress().\n   */\n\n  JDIMENSION output_width;\t/* scaled image width */\n  JDIMENSION output_height;\t/* scaled image height */\n  int out_color_components;\t/* # of color components in out_color_space */\n  int output_components;\t/* # of color components returned */\n  /* output_components is 1 (a colormap index) when quantizing colors;\n   * otherwise it equals out_color_components.\n   */\n  int rec_outbuf_height;\t/* min recommended height of scanline buffer */\n  /* If the buffer passed to jpeg_read_scanlines() is less than this many rows\n   * high, space and time will be wasted due to unnecessary data copying.\n   * Usually rec_outbuf_height will be 1 or 2, at most 4.\n   */\n\n  /* When quantizing colors, the output colormap is described by these fields.\n   * The application can supply a colormap by setting colormap non-NULL before\n   * calling jpeg_start_decompress; otherwise a colormap is created during\n   * jpeg_start_decompress or jpeg_start_output.\n   * The map has out_color_components rows and actual_number_of_colors columns.\n   */\n  int actual_number_of_colors;\t/* number of entries in use */\n  JSAMPARRAY colormap;\t\t/* The color map as a 2-D pixel array */\n\n  /* State variables: these variables indicate the progress of decompression.\n   * The application may examine these but must not modify them.\n   */\n\n  /* Row index of next scanline to be read from jpeg_read_scanlines().\n   * Application may use this to control its processing loop, e.g.,\n   * \"while (output_scanline < output_height)\".\n   */\n  JDIMENSION output_scanline;\t/* 0 .. output_height-1  */\n\n  /* Current input scan number and number of iMCU rows completed in scan.\n   * These indicate the progress of the decompressor input side.\n   */\n  int input_scan_number;\t/* Number of SOS markers seen so far */\n  JDIMENSION input_iMCU_row;\t/* Number of iMCU rows completed */\n\n  /* The \"output scan number\" is the notional scan being displayed by the\n   * output side.  The decompressor will not allow output scan/row number\n   * to get ahead of input scan/row, but it can fall arbitrarily far behind.\n   */\n  int output_scan_number;\t/* Nominal scan number being displayed */\n  JDIMENSION output_iMCU_row;\t/* Number of iMCU rows read */\n\n  /* Current progression status.  coef_bits[c][i] indicates the precision\n   * with which component c's DCT coefficient i (in zigzag order) is known.\n   * It is -1 when no data has yet been received, otherwise it is the point\n   * transform (shift) value for the most recent scan of the coefficient\n   * (thus, 0 at completion of the progression).\n   * This pointer is NULL when reading a non-progressive file.\n   */\n  int (*coef_bits)[DCTSIZE2];\t/* -1 or current Al value for each coef */\n\n  /* Internal JPEG parameters --- the application usually need not look at\n   * these fields.  Note that the decompressor output side may not use\n   * any parameters that can change between scans.\n   */\n\n  /* Quantization and Huffman tables are carried forward across input\n   * datastreams when processing abbreviated JPEG datastreams.\n   */\n\n  JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS];\n  /* ptrs to coefficient quantization tables, or NULL if not defined */\n\n  JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS];\n  JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS];\n  /* ptrs to Huffman coding tables, or NULL if not defined */\n\n  /* These parameters are never carried across datastreams, since they\n   * are given in SOF/SOS markers or defined to be reset by SOI.\n   */\n\n  int data_precision;\t\t/* bits of precision in image data */\n\n  jpeg_component_info * comp_info;\n  /* comp_info[i] describes component that appears i'th in SOF */\n\n  boolean progressive_mode;\t/* TRUE if SOFn specifies progressive mode */\n  boolean arith_code;\t\t/* TRUE=arithmetic coding, FALSE=Huffman */\n\n  UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */\n  UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */\n  UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */\n\n  unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */\n\n  /* These fields record data obtained from optional markers recognized by\n   * the JPEG library.\n   */\n  boolean saw_JFIF_marker;\t/* TRUE iff a JFIF APP0 marker was found */\n  /* Data copied from JFIF marker: */\n  UINT8 density_unit;\t\t/* JFIF code for pixel size units */\n  UINT16 X_density;\t\t/* Horizontal pixel density */\n  UINT16 Y_density;\t\t/* Vertical pixel density */\n  boolean saw_Adobe_marker;\t/* TRUE iff an Adobe APP14 marker was found */\n  UINT8 Adobe_transform;\t/* Color transform code from Adobe marker */\n\n  boolean CCIR601_sampling;\t/* TRUE=first samples are cosited */\n\n  /* Remaining fields are known throughout decompressor, but generally\n   * should not be touched by a surrounding application.\n   */\n\n  /*\n   * These fields are computed during decompression startup\n   */\n  int max_h_samp_factor;\t/* largest h_samp_factor */\n  int max_v_samp_factor;\t/* largest v_samp_factor */\n\n  int min_DCT_scaled_size;\t/* smallest DCT_scaled_size of any component */\n\n  JDIMENSION total_iMCU_rows;\t/* # of iMCU rows in image */\n  /* The coefficient controller's input and output progress is measured in\n   * units of \"iMCU\" (interleaved MCU) rows.  These are the same as MCU rows\n   * in fully interleaved JPEG scans, but are used whether the scan is\n   * interleaved or not.  We define an iMCU row as v_samp_factor DCT block\n   * rows of each component.  Therefore, the IDCT output contains\n   * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row.\n   */\n\n  JSAMPLE * sample_range_limit; /* table for fast range-limiting */\n\n  /*\n   * These fields are valid during any one scan.\n   * They describe the components and MCUs actually appearing in the scan.\n   * Note that the decompressor output side must not use these fields.\n   */\n  int comps_in_scan;\t\t/* # of JPEG components in this scan */\n  jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];\n  /* *cur_comp_info[i] describes component that appears i'th in SOS */\n\n  JDIMENSION MCUs_per_row;\t/* # of MCUs across the image */\n  JDIMENSION MCU_rows_in_scan;\t/* # of MCU rows in the image */\n\n  int blocks_in_MCU;\t\t/* # of DCT blocks per MCU */\n  int MCU_membership[D_MAX_BLOCKS_IN_MCU];\n  /* MCU_membership[i] is index in cur_comp_info of component owning */\n  /* i'th block in an MCU */\n\n  int Ss, Se, Ah, Al;\t\t/* progressive JPEG parameters for scan */\n\n  /* This field is shared between entropy decoder and marker parser.\n   * It is either zero or the code of a JPEG marker that has been\n   * read from the data source, but has not yet been processed.\n   */\n  int unread_marker;\n\n  /*\n   * Links to decompression subobjects (methods, private variables of modules)\n   */\n  struct jpeg_decomp_master * master;\n  struct jpeg_d_main_controller * main;\n  struct jpeg_d_coef_controller * coef;\n  struct jpeg_d_post_controller * post;\n  struct jpeg_input_controller * inputctl;\n  struct jpeg_marker_reader * marker;\n  struct jpeg_entropy_decoder * entropy;\n  struct jpeg_inverse_dct * idct;\n  struct jpeg_upsampler * upsample;\n  struct jpeg_color_deconverter * cconvert;\n  struct jpeg_color_quantizer * cquantize;\n};\n\n\n/* \"Object\" declarations for JPEG modules that may be supplied or called\n * directly by the surrounding application.\n * As with all objects in the JPEG library, these structs only define the\n * publicly visible methods and state variables of a module.  Additional\n * private fields may exist after the public ones.\n */\n\n\n/* Error handler object */\n\nstruct jpeg_error_mgr {\n  /* Error exit handler: does not return to caller */\n  JMETHOD(void, error_exit, (j_common_ptr cinfo));\n  /* Conditionally emit a trace or warning message */\n  JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level));\n  /* Routine that actually outputs a trace or error message */\n  JMETHOD(void, output_message, (j_common_ptr cinfo));\n  /* Format a message string for the most recent JPEG error or message */\n  JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer));\n#define JMSG_LENGTH_MAX  200\t/* recommended size of format_message buffer */\n  /* Reset error state variables at start of a new image */\n  JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo));\n  \n  /* The message ID code and any parameters are saved here.\n   * A message can have one string parameter or up to 8 int parameters.\n   */\n  int msg_code;\n#define JMSG_STR_PARM_MAX  80\n  union {\n    int i[8];\n    char s[JMSG_STR_PARM_MAX];\n  } msg_parm;\n  \n  /* Standard state variables for error facility */\n  \n  int trace_level;\t\t/* max msg_level that will be displayed */\n  \n  /* For recoverable corrupt-data errors, we emit a warning message,\n   * but keep going unless emit_message chooses to abort.  emit_message\n   * should count warnings in num_warnings.  The surrounding application\n   * can check for bad data by seeing if num_warnings is nonzero at the\n   * end of processing.\n   */\n  long num_warnings;\t\t/* number of corrupt-data warnings */\n\n  /* These fields point to the table(s) of error message strings.\n   * An application can change the table pointer to switch to a different\n   * message list (typically, to change the language in which errors are\n   * reported).  Some applications may wish to add additional error codes\n   * that will be handled by the JPEG library error mechanism; the second\n   * table pointer is used for this purpose.\n   *\n   * First table includes all errors generated by JPEG library itself.\n   * Error code 0 is reserved for a \"no such error string\" message.\n   */\n  const char * const * jpeg_message_table; /* Library errors */\n  int last_jpeg_message;    /* Table contains strings 0..last_jpeg_message */\n  /* Second table can be added by application (see cjpeg/djpeg for example).\n   * It contains strings numbered first_addon_message..last_addon_message.\n   */\n  const char * const * addon_message_table; /* Non-library errors */\n  int first_addon_message;\t/* code for first string in addon table */\n  int last_addon_message;\t/* code for last string in addon table */\n};\n\n\n/* Progress monitor object */\n\nstruct jpeg_progress_mgr {\n  JMETHOD(void, progress_monitor, (j_common_ptr cinfo));\n\n  long pass_counter;\t\t/* work units completed in this pass */\n  long pass_limit;\t\t/* total number of work units in this pass */\n  int completed_passes;\t\t/* passes completed so far */\n  int total_passes;\t\t/* total number of passes expected */\n};\n\n\n/* Data destination object for compression */\n\nstruct jpeg_destination_mgr {\n  JOCTET * next_output_byte;\t/* => next byte to write in buffer */\n  size_t free_in_buffer;\t/* # of byte spaces remaining in buffer */\n\n  JMETHOD(void, init_destination, (j_compress_ptr cinfo));\n  JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo));\n  JMETHOD(void, term_destination, (j_compress_ptr cinfo));\n};\n\n\n/* Data source object for decompression */\n\nstruct jpeg_source_mgr {\n  const JOCTET * next_input_byte; /* => next byte to read from buffer */\n  size_t bytes_in_buffer;\t/* # of bytes remaining in buffer */\n\n  JMETHOD(void, init_source, (j_decompress_ptr cinfo));\n  JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo));\n  JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes));\n  JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired));\n  JMETHOD(void, term_source, (j_decompress_ptr cinfo));\n};\n\n\n/* Memory manager object.\n * Allocates \"small\" objects (a few K total), \"large\" objects (tens of K),\n * and \"really big\" objects (virtual arrays with backing store if needed).\n * The memory manager does not allow individual objects to be freed; rather,\n * each created object is assigned to a pool, and whole pools can be freed\n * at once.  This is faster and more convenient than remembering exactly what\n * to free, especially where malloc()/free() are not too speedy.\n * NB: alloc routines never return NULL.  They exit to error_exit if not\n * successful.\n */\n\n#define JPOOL_PERMANENT\t0\t/* lasts until master record is destroyed */\n#define JPOOL_IMAGE\t1\t/* lasts until done with image/datastream */\n#define JPOOL_NUMPOOLS\t2\n\ntypedef struct jvirt_sarray_control * jvirt_sarray_ptr;\ntypedef struct jvirt_barray_control * jvirt_barray_ptr;\n\n\nstruct jpeg_memory_mgr {\n  /* Method pointers */\n  JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id,\n\t\t\t\tsize_t sizeofobject));\n  JMETHOD(void FAR *, alloc_large, (j_common_ptr cinfo, int pool_id,\n\t\t\t\t     size_t sizeofobject));\n  JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id,\n\t\t\t\t     JDIMENSION samplesperrow,\n\t\t\t\t     JDIMENSION numrows));\n  JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id,\n\t\t\t\t      JDIMENSION blocksperrow,\n\t\t\t\t      JDIMENSION numrows));\n  JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo,\n\t\t\t\t\t\t  int pool_id,\n\t\t\t\t\t\t  boolean pre_zero,\n\t\t\t\t\t\t  JDIMENSION samplesperrow,\n\t\t\t\t\t\t  JDIMENSION numrows,\n\t\t\t\t\t\t  JDIMENSION maxaccess));\n  JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo,\n\t\t\t\t\t\t  int pool_id,\n\t\t\t\t\t\t  boolean pre_zero,\n\t\t\t\t\t\t  JDIMENSION blocksperrow,\n\t\t\t\t\t\t  JDIMENSION numrows,\n\t\t\t\t\t\t  JDIMENSION maxaccess));\n  JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo));\n  JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo,\n\t\t\t\t\t   jvirt_sarray_ptr ptr,\n\t\t\t\t\t   JDIMENSION start_row,\n\t\t\t\t\t   JDIMENSION num_rows,\n\t\t\t\t\t   boolean writable));\n  JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo,\n\t\t\t\t\t    jvirt_barray_ptr ptr,\n\t\t\t\t\t    JDIMENSION start_row,\n\t\t\t\t\t    JDIMENSION num_rows,\n\t\t\t\t\t    boolean writable));\n  JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id));\n  JMETHOD(void, self_destruct, (j_common_ptr cinfo));\n\n  /* Limit on memory allocation for this JPEG object.  (Note that this is\n   * merely advisory, not a guaranteed maximum; it only affects the space\n   * used for virtual-array buffers.)  May be changed by outer application\n   * after creating the JPEG object.\n   */\n  long max_memory_to_use;\n};\n\n\n/* Routine signature for application-supplied marker processing methods.\n * Need not pass marker code since it is stored in cinfo->unread_marker.\n */\ntypedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo));\n\n\n/* Declarations for routines called by application.\n * The JPP macro hides prototype parameters from compilers that can't cope.\n * Note JPP requires double parentheses.\n */\n\n#ifdef HAVE_PROTOTYPES\n#define JPP(arglist)\targlist\n#else\n#define JPP(arglist)\t()\n#endif\n\n\n/* Short forms of external names for systems with brain-damaged linkers.\n * We shorten external names to be unique in the first six letters, which\n * is good enough for all known systems.\n * (If your compiler itself needs names to be unique in less than 15 \n * characters, you are out of luck.  Get a better compiler.)\n */\n\n#ifdef NEED_SHORT_EXTERNAL_NAMES\n#define jpeg_std_error\t\tjStdError\n#define jpeg_create_compress\tjCreaCompress\n#define jpeg_create_decompress\tjCreaDecompress\n#define jpeg_destroy_compress\tjDestCompress\n#define jpeg_destroy_decompress\tjDestDecompress\n#define jpeg_stdio_dest\t\tjStdDest\n#define jpeg_stdio_src\t\tjStdSrc\n#define jpeg_set_defaults\tjSetDefaults\n#define jpeg_set_colorspace\tjSetColorspace\n#define jpeg_default_colorspace\tjDefColorspace\n#define jpeg_set_quality\tjSetQuality\n#define jpeg_set_linear_quality\tjSetLQuality\n#define jpeg_add_quant_table\tjAddQuantTable\n#define jpeg_quality_scaling\tjQualityScaling\n#define jpeg_simple_progression\tjSimProgress\n#define jpeg_suppress_tables\tjSuppressTables\n#define jpeg_alloc_quant_table\tjAlcQTable\n#define jpeg_alloc_huff_table\tjAlcHTable\n#define jpeg_start_compress\tjStrtCompress\n#define jpeg_write_scanlines\tjWrtScanlines\n#define jpeg_finish_compress\tjFinCompress\n#define jpeg_write_raw_data\tjWrtRawData\n#define jpeg_write_marker\tjWrtMarker\n#define jpeg_write_tables\tjWrtTables\n#define jpeg_read_header\tjReadHeader\n#define jpeg_start_decompress\tjStrtDecompress\n#define jpeg_read_scanlines\tjReadScanlines\n#define jpeg_finish_decompress\tjFinDecompress\n#define jpeg_read_raw_data\tjReadRawData\n#define jpeg_has_multiple_scans\tjHasMultScn\n#define jpeg_start_output\tjStrtOutput\n#define jpeg_finish_output\tjFinOutput\n#define jpeg_input_complete\tjInComplete\n#define jpeg_new_colormap\tjNewCMap\n#define jpeg_consume_input\tjConsumeInput\n#define jpeg_calc_output_dimensions\tjCalcDimensions\n#define jpeg_set_marker_processor\tjSetMarker\n#define jpeg_read_coefficients\tjReadCoefs\n#define jpeg_write_coefficients\tjWrtCoefs\n#define jpeg_copy_critical_parameters\tjCopyCrit\n#define jpeg_abort_compress\tjAbrtCompress\n#define jpeg_abort_decompress\tjAbrtDecompress\n#define jpeg_abort\t\tjAbort\n#define jpeg_destroy\t\tjDestroy\n#define jpeg_resync_to_restart\tjResyncRestart\n#endif /* NEED_SHORT_EXTERNAL_NAMES */\n\n\n/* Default error-management setup */\nEXTERN struct jpeg_error_mgr *jpeg_std_error JPP((struct jpeg_error_mgr *err));\n\n/* Initialization and destruction of JPEG compression objects */\n/* NB: you must set up the error-manager BEFORE calling jpeg_create_xxx */\nEXTERN void jpeg_create_compress JPP((j_compress_ptr cinfo));\nEXTERN void jpeg_create_decompress JPP((j_decompress_ptr cinfo));\nEXTERN void jpeg_destroy_compress JPP((j_compress_ptr cinfo));\nEXTERN void jpeg_destroy_decompress JPP((j_decompress_ptr cinfo));\n\n/* Standard data source and destination managers: stdio streams. */\n/* Caller is responsible for opening the file before and closing after. */\nEXTERN void jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile));\nEXTERN void jpeg_stdio_src JPP((j_decompress_ptr cinfo, unsigned char *infile));\n\n/* Default parameter setup for compression */\nEXTERN void jpeg_set_defaults JPP((j_compress_ptr cinfo));\n/* Compression parameter setup aids */\nEXTERN void jpeg_set_colorspace JPP((j_compress_ptr cinfo,\n\t\t\t\t     J_COLOR_SPACE colorspace));\nEXTERN void jpeg_default_colorspace JPP((j_compress_ptr cinfo));\nEXTERN void jpeg_set_quality JPP((j_compress_ptr cinfo, int quality,\n\t\t\t\t  boolean force_baseline));\nEXTERN void jpeg_set_linear_quality JPP((j_compress_ptr cinfo,\n\t\t\t\t\t int scale_factor,\n\t\t\t\t\t boolean force_baseline));\nEXTERN void jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl,\n\t\t\t\t      const unsigned int *basic_table,\n\t\t\t\t      int scale_factor,\n\t\t\t\t      boolean force_baseline));\nEXTERN int jpeg_quality_scaling JPP((int quality));\nEXTERN void jpeg_simple_progression JPP((j_compress_ptr cinfo));\nEXTERN void jpeg_suppress_tables JPP((j_compress_ptr cinfo,\n\t\t\t\t      boolean suppress));\nEXTERN JQUANT_TBL * jpeg_alloc_quant_table JPP((j_common_ptr cinfo));\nEXTERN JHUFF_TBL * jpeg_alloc_huff_table JPP((j_common_ptr cinfo));\n\n/* Main entry points for compression */\nEXTERN void jpeg_start_compress JPP((j_compress_ptr cinfo,\n\t\t\t\t     boolean write_all_tables));\nEXTERN JDIMENSION jpeg_write_scanlines JPP((j_compress_ptr cinfo,\n\t\t\t\t\t    JSAMPARRAY scanlines,\n\t\t\t\t\t    JDIMENSION num_lines));\nEXTERN void jpeg_finish_compress JPP((j_compress_ptr cinfo));\n\n/* Replaces jpeg_write_scanlines when writing raw downsampled data. */\nEXTERN JDIMENSION jpeg_write_raw_data JPP((j_compress_ptr cinfo,\n\t\t\t\t\t   JSAMPIMAGE data,\n\t\t\t\t\t   JDIMENSION num_lines));\n\n/* Write a special marker.  See libjpeg.doc concerning safe usage. */\nEXTERN void jpeg_write_marker JPP((j_compress_ptr cinfo, int marker,\n\t\t\t\t   const JOCTET *dataptr, unsigned int datalen));\n\n/* Alternate compression function: just write an abbreviated table file */\nEXTERN void jpeg_write_tables JPP((j_compress_ptr cinfo));\n\n/* Decompression startup: read start of JPEG datastream to see what's there */\nEXTERN int jpeg_read_header JPP((j_decompress_ptr cinfo,\n\t\t\t\t boolean require_image));\n/* Return value is one of: */\n#define JPEG_SUSPENDED\t\t0 /* Suspended due to lack of input data */\n#define JPEG_HEADER_OK\t\t1 /* Found valid image datastream */\n#define JPEG_HEADER_TABLES_ONLY\t2 /* Found valid table-specs-only datastream */\n/* If you pass require_image = TRUE (normal case), you need not check for\n * a TABLES_ONLY return code; an abbreviated file will cause an error exit.\n * JPEG_SUSPENDED is only possible if you use a data source module that can\n * give a suspension return (the stdio source module doesn't).\n */\n\n/* Main entry points for decompression */\nEXTERN boolean jpeg_start_decompress JPP((j_decompress_ptr cinfo));\nEXTERN JDIMENSION jpeg_read_scanlines JPP((j_decompress_ptr cinfo,\n\t\t\t\t\t   JSAMPARRAY scanlines,\n\t\t\t\t\t   JDIMENSION max_lines));\nEXTERN boolean jpeg_finish_decompress JPP((j_decompress_ptr cinfo));\n\n/* Replaces jpeg_read_scanlines when reading raw downsampled data. */\nEXTERN JDIMENSION jpeg_read_raw_data JPP((j_decompress_ptr cinfo,\n\t\t\t\t\t  JSAMPIMAGE data,\n\t\t\t\t\t  JDIMENSION max_lines));\n\n/* Additional entry points for buffered-image mode. */\nEXTERN boolean jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo));\nEXTERN boolean jpeg_start_output JPP((j_decompress_ptr cinfo,\n\t\t\t\t      int scan_number));\nEXTERN boolean jpeg_finish_output JPP((j_decompress_ptr cinfo));\nEXTERN boolean jpeg_input_complete JPP((j_decompress_ptr cinfo));\nEXTERN void jpeg_new_colormap JPP((j_decompress_ptr cinfo));\nEXTERN int jpeg_consume_input JPP((j_decompress_ptr cinfo));\n/* Return value is one of: */\n/* #define JPEG_SUSPENDED\t0    Suspended due to lack of input data */\n#define JPEG_REACHED_SOS\t1 /* Reached start of new scan */\n#define JPEG_REACHED_EOI\t2 /* Reached end of image */\n#define JPEG_ROW_COMPLETED\t3 /* Completed one iMCU row */\n#define JPEG_SCAN_COMPLETED\t4 /* Completed last iMCU row of a scan */\n\n/* Precalculate output dimensions for current decompression parameters. */\nEXTERN void jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo));\n\n/* Install a special processing method for COM or APPn markers. */\nEXTERN void jpeg_set_marker_processor JPP((j_decompress_ptr cinfo,\n\t\t\t\t\t   int marker_code,\n\t\t\t\t\t   jpeg_marker_parser_method routine));\n\n/* Read or write raw DCT coefficients --- useful for lossless transcoding. */\nEXTERN jvirt_barray_ptr * jpeg_read_coefficients JPP((j_decompress_ptr cinfo));\nEXTERN void jpeg_write_coefficients JPP((j_compress_ptr cinfo,\n\t\t\t\t\t jvirt_barray_ptr * coef_arrays));\nEXTERN void jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo,\n\t\t\t\t\t       j_compress_ptr dstinfo));\n\n/* If you choose to abort compression or decompression before completing\n * jpeg_finish_(de)compress, then you need to clean up to release memory,\n * temporary files, etc.  You can just call jpeg_destroy_(de)compress\n * if you're done with the JPEG object, but if you want to clean it up and\n * reuse it, call this:\n */\nEXTERN void jpeg_abort_compress JPP((j_compress_ptr cinfo));\nEXTERN void jpeg_abort_decompress JPP((j_decompress_ptr cinfo));\n\n/* Generic versions of jpeg_abort and jpeg_destroy that work on either\n * flavor of JPEG object.  These may be more convenient in some places.\n */\nEXTERN void jpeg_abort JPP((j_common_ptr cinfo));\nEXTERN void jpeg_destroy JPP((j_common_ptr cinfo));\n\n/* Default restart-marker-resync procedure for use by data source modules */\nEXTERN boolean jpeg_resync_to_restart JPP((j_decompress_ptr cinfo,\n\t\t\t\t\t   int desired));\n\n\n/* These marker codes are exported since applications and data source modules\n * are likely to want to use them.\n */\n\n#define JPEG_RST0\t0xD0\t/* RST0 marker code */\n#define JPEG_EOI\t0xD9\t/* EOI marker code */\n#define JPEG_APP0\t0xE0\t/* APP0 marker code */\n#define JPEG_COM\t0xFE\t/* COM marker code */\n\n\n/* If we have a brain-damaged compiler that emits warnings (or worse, errors)\n * for structure definitions that are never filled in, keep it quiet by\n * supplying dummy definitions for the various substructures.\n */\n\n#ifdef INCOMPLETE_TYPES_BROKEN\n#ifndef JPEG_INTERNALS\t\t/* will be defined in jpegint.h */\nstruct jvirt_sarray_control { long dummy; };\nstruct jvirt_barray_control { long dummy; };\nstruct jpeg_comp_master { long dummy; };\nstruct jpeg_c_main_controller { long dummy; };\nstruct jpeg_c_prep_controller { long dummy; };\nstruct jpeg_c_coef_controller { long dummy; };\nstruct jpeg_marker_writer { long dummy; };\nstruct jpeg_color_converter { long dummy; };\nstruct jpeg_downsampler { long dummy; };\nstruct jpeg_forward_dct { long dummy; };\nstruct jpeg_entropy_encoder { long dummy; };\nstruct jpeg_decomp_master { long dummy; };\nstruct jpeg_d_main_controller { long dummy; };\nstruct jpeg_d_coef_controller { long dummy; };\nstruct jpeg_d_post_controller { long dummy; };\nstruct jpeg_input_controller { long dummy; };\nstruct jpeg_marker_reader { long dummy; };\nstruct jpeg_entropy_decoder { long dummy; };\nstruct jpeg_inverse_dct { long dummy; };\nstruct jpeg_upsampler { long dummy; };\nstruct jpeg_color_deconverter { long dummy; };\nstruct jpeg_color_quantizer { long dummy; };\n#endif /* JPEG_INTERNALS */\n#endif /* INCOMPLETE_TYPES_BROKEN */\n\n\n/*\n * The JPEG library modules define JPEG_INTERNALS before including this file.\n * The internal structure declarations are read only when that is true.\n * Applications using the library should not include jpegint.h, but may wish\n * to include jerror.h.\n */\n\n#ifdef JPEG_INTERNALS\n#include \"../jpeg-6/jpegint.h\"\t\t/* fetch private declarations */\n#include \"../jpeg-6/jerror.h\"\t\t/* fetch error codes too */\n#endif\n\n#endif /* JPEGLIB_H */\n"
  },
  {
    "path": "code/jpeg-6/jpegtran.c",
    "content": "/*\n * jpegtran.c\n *\n * Copyright (C) 1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains a command-line user interface for JPEG transcoding.\n * It is very similar to cjpeg.c, but provides lossless transcoding between\n * different JPEG file formats.\n */\n\n#include \"cdjpeg.h\"\t\t/* Common decls for cjpeg/djpeg applications */\n#include \"jversion.h\"\t\t/* for version message */\n\n#ifdef USE_CCOMMAND\t\t/* command-line reader for Macintosh */\n#ifdef __MWERKS__\n#include <SIOUX.h>              /* Metrowerks declares it here */\n#endif\n#ifdef THINK_C\n#include <console.h>\t\t/* Think declares it here */\n#endif\n#endif\n\n\n/*\n * Argument-parsing code.\n * The switch parser is designed to be useful with DOS-style command line\n * syntax, ie, intermixed switches and file names, where only the switches\n * to the left of a given file name affect processing of that file.\n * The main program in this file doesn't actually use this capability...\n */\n\n\nstatic const char * progname;\t/* program name for error messages */\nstatic char * outfilename;\t/* for -outfile switch */\n\n\nLOCAL void\nusage (void)\n/* complain about bad command line */\n{\n  fprintf(stderr, \"usage: %s [switches] \", progname);\n#ifdef TWO_FILE_COMMANDLINE\n  fprintf(stderr, \"inputfile outputfile\\n\");\n#else\n  fprintf(stderr, \"[inputfile]\\n\");\n#endif\n\n  fprintf(stderr, \"Switches (names may be abbreviated):\\n\");\n#ifdef ENTROPY_OPT_SUPPORTED\n  fprintf(stderr, \"  -optimize      Optimize Huffman table (smaller file, but slow compression)\\n\");\n#endif\n#ifdef C_PROGRESSIVE_SUPPORTED\n  fprintf(stderr, \"  -progressive   Create progressive JPEG file\\n\");\n#endif\n  fprintf(stderr, \"Switches for advanced users:\\n\");\n  fprintf(stderr, \"  -restart N     Set restart interval in rows, or in blocks with B\\n\");\n  fprintf(stderr, \"  -maxmemory N   Maximum memory to use (in kbytes)\\n\");\n  fprintf(stderr, \"  -outfile name  Specify name for output file\\n\");\n  fprintf(stderr, \"  -verbose  or  -debug   Emit debug output\\n\");\n  fprintf(stderr, \"Switches for wizards:\\n\");\n#ifdef C_ARITH_CODING_SUPPORTED\n  fprintf(stderr, \"  -arithmetic    Use arithmetic coding\\n\");\n#endif\n#ifdef C_MULTISCAN_FILES_SUPPORTED\n  fprintf(stderr, \"  -scans file    Create multi-scan JPEG per script file\\n\");\n#endif\n  exit(EXIT_FAILURE);\n}\n\n\nLOCAL int\nparse_switches (j_compress_ptr cinfo, int argc, char **argv,\n\t\tint last_file_arg_seen, boolean for_real)\n/* Parse optional switches.\n * Returns argv[] index of first file-name argument (== argc if none).\n * Any file names with indexes <= last_file_arg_seen are ignored;\n * they have presumably been processed in a previous iteration.\n * (Pass 0 for last_file_arg_seen on the first or only iteration.)\n * for_real is FALSE on the first (dummy) pass; we may skip any expensive\n * processing.\n */\n{\n  int argn;\n  char * arg;\n  boolean simple_progressive;\n  char * scansarg = NULL;\t/* saves -scans parm if any */\n\n  /* Set up default JPEG parameters. */\n  simple_progressive = FALSE;\n  outfilename = NULL;\n  cinfo->err->trace_level = 0;\n\n  /* Scan command line options, adjust parameters */\n\n  for (argn = 1; argn < argc; argn++) {\n    arg = argv[argn];\n    if (*arg != '-') {\n      /* Not a switch, must be a file name argument */\n      if (argn <= last_file_arg_seen) {\n\toutfilename = NULL;\t/* -outfile applies to just one input file */\n\tcontinue;\t\t/* ignore this name if previously processed */\n      }\n      break;\t\t\t/* else done parsing switches */\n    }\n    arg++;\t\t\t/* advance past switch marker character */\n\n    if (keymatch(arg, \"arithmetic\", 1)) {\n      /* Use arithmetic coding. */\n#ifdef C_ARITH_CODING_SUPPORTED\n      cinfo->arith_code = TRUE;\n#else\n      fprintf(stderr, \"%s: sorry, arithmetic coding not supported\\n\",\n\t      progname);\n      exit(EXIT_FAILURE);\n#endif\n\n    } else if (keymatch(arg, \"debug\", 1) || keymatch(arg, \"verbose\", 1)) {\n      /* Enable debug printouts. */\n      /* On first -d, print version identification */\n      static boolean printed_version = FALSE;\n\n      if (! printed_version) {\n\tfprintf(stderr, \"Independent JPEG Group's JPEGTRAN, version %s\\n%s\\n\",\n\t\tJVERSION, JCOPYRIGHT);\n\tprinted_version = TRUE;\n      }\n      cinfo->err->trace_level++;\n\n    } else if (keymatch(arg, \"maxmemory\", 3)) {\n      /* Maximum memory in Kb (or Mb with 'm'). */\n      long lval;\n      char ch = 'x';\n\n      if (++argn >= argc)\t/* advance to next argument */\n\tusage();\n      if (sscanf(argv[argn], \"%ld%c\", &lval, &ch) < 1)\n\tusage();\n      if (ch == 'm' || ch == 'M')\n\tlval *= 1000L;\n      cinfo->mem->max_memory_to_use = lval * 1000L;\n\n    } else if (keymatch(arg, \"optimize\", 1) || keymatch(arg, \"optimise\", 1)) {\n      /* Enable entropy parm optimization. */\n#ifdef ENTROPY_OPT_SUPPORTED\n      cinfo->optimize_coding = TRUE;\n#else\n      fprintf(stderr, \"%s: sorry, entropy optimization was not compiled\\n\",\n\t      progname);\n      exit(EXIT_FAILURE);\n#endif\n\n    } else if (keymatch(arg, \"outfile\", 4)) {\n      /* Set output file name. */\n      if (++argn >= argc)\t/* advance to next argument */\n\tusage();\n      outfilename = argv[argn];\t/* save it away for later use */\n\n    } else if (keymatch(arg, \"progressive\", 1)) {\n      /* Select simple progressive mode. */\n#ifdef C_PROGRESSIVE_SUPPORTED\n      simple_progressive = TRUE;\n      /* We must postpone execution until num_components is known. */\n#else\n      fprintf(stderr, \"%s: sorry, progressive output was not compiled\\n\",\n\t      progname);\n      exit(EXIT_FAILURE);\n#endif\n\n    } else if (keymatch(arg, \"restart\", 1)) {\n      /* Restart interval in MCU rows (or in MCUs with 'b'). */\n      long lval;\n      char ch = 'x';\n\n      if (++argn >= argc)\t/* advance to next argument */\n\tusage();\n      if (sscanf(argv[argn], \"%ld%c\", &lval, &ch) < 1)\n\tusage();\n      if (lval < 0 || lval > 65535L)\n\tusage();\n      if (ch == 'b' || ch == 'B') {\n\tcinfo->restart_interval = (unsigned int) lval;\n\tcinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */\n      } else {\n\tcinfo->restart_in_rows = (int) lval;\n\t/* restart_interval will be computed during startup */\n      }\n\n    } else if (keymatch(arg, \"scans\", 2)) {\n      /* Set scan script. */\n#ifdef C_MULTISCAN_FILES_SUPPORTED\n      if (++argn >= argc)\t/* advance to next argument */\n\tusage();\n      scansarg = argv[argn];\n      /* We must postpone reading the file in case -progressive appears. */\n#else\n      fprintf(stderr, \"%s: sorry, multi-scan output was not compiled\\n\",\n\t      progname);\n      exit(EXIT_FAILURE);\n#endif\n\n    } else {\n      usage();\t\t\t/* bogus switch */\n    }\n  }\n\n  /* Post-switch-scanning cleanup */\n\n  if (for_real) {\n\n#ifdef C_PROGRESSIVE_SUPPORTED\n    if (simple_progressive)\t/* process -progressive; -scans can override */\n      jpeg_simple_progression(cinfo);\n#endif\n\n#ifdef C_MULTISCAN_FILES_SUPPORTED\n    if (scansarg != NULL)\t/* process -scans if it was present */\n      if (! read_scan_script(cinfo, scansarg))\n\tusage();\n#endif\n  }\n\n  return argn;\t\t\t/* return index of next arg (file name) */\n}\n\n\n/*\n * The main program.\n */\n\nGLOBAL int\nmain (int argc, char **argv)\n{\n  struct jpeg_decompress_struct srcinfo;\n  struct jpeg_compress_struct dstinfo;\n  struct jpeg_error_mgr jsrcerr, jdsterr;\n#ifdef PROGRESS_REPORT\n  struct cdjpeg_progress_mgr progress;\n#endif\n  jvirt_barray_ptr * coef_arrays;\n  int file_index;\n  FILE * input_file;\n  FILE * output_file;\n\n  /* On Mac, fetch a command line. */\n#ifdef USE_CCOMMAND\n  argc = ccommand(&argv);\n#endif\n\n  progname = argv[0];\n  if (progname == NULL || progname[0] == 0)\n    progname = \"jpegtran\";\t/* in case C library doesn't provide it */\n\n  /* Initialize the JPEG decompression object with default error handling. */\n  srcinfo.err = jpeg_std_error(&jsrcerr);\n  jpeg_create_decompress(&srcinfo);\n  /* Initialize the JPEG compression object with default error handling. */\n  dstinfo.err = jpeg_std_error(&jdsterr);\n  jpeg_create_compress(&dstinfo);\n\n  /* Now safe to enable signal catcher.\n   * Note: we assume only the decompression object will have virtual arrays.\n   */\n#ifdef NEED_SIGNAL_CATCHER\n  enable_signal_catcher((j_common_ptr) &srcinfo);\n#endif\n\n  /* Scan command line to find file names.\n   * It is convenient to use just one switch-parsing routine, but the switch\n   * values read here are ignored; we will rescan the switches after opening\n   * the input file.\n   */\n\n  file_index = parse_switches(&dstinfo, argc, argv, 0, FALSE);\n  jsrcerr.trace_level = jdsterr.trace_level;\n\n#ifdef TWO_FILE_COMMANDLINE\n  /* Must have either -outfile switch or explicit output file name */\n  if (outfilename == NULL) {\n    if (file_index != argc-2) {\n      fprintf(stderr, \"%s: must name one input and one output file\\n\",\n\t      progname);\n      usage();\n    }\n    outfilename = argv[file_index+1];\n  } else {\n    if (file_index != argc-1) {\n      fprintf(stderr, \"%s: must name one input and one output file\\n\",\n\t      progname);\n      usage();\n    }\n  }\n#else\n  /* Unix style: expect zero or one file name */\n  if (file_index < argc-1) {\n    fprintf(stderr, \"%s: only one input file\\n\", progname);\n    usage();\n  }\n#endif /* TWO_FILE_COMMANDLINE */\n\n  /* Open the input file. */\n  if (file_index < argc) {\n    if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) {\n      fprintf(stderr, \"%s: can't open %s\\n\", progname, argv[file_index]);\n      exit(EXIT_FAILURE);\n    }\n  } else {\n    /* default input file is stdin */\n    input_file = read_stdin();\n  }\n\n  /* Open the output file. */\n  if (outfilename != NULL) {\n    if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) {\n      fprintf(stderr, \"%s: can't open %s\\n\", progname, outfilename);\n      exit(EXIT_FAILURE);\n    }\n  } else {\n    /* default output file is stdout */\n    output_file = write_stdout();\n  }\n\n#ifdef PROGRESS_REPORT\n  start_progress_monitor((j_common_ptr) &dstinfo, &progress);\n#endif\n\n  /* Specify data source for decompression */\n  jpeg_stdio_src(&srcinfo, input_file);\n\n  /* Read file header */\n  (void) jpeg_read_header(&srcinfo, TRUE);\n\n  /* Read source file as DCT coefficients */\n  coef_arrays = jpeg_read_coefficients(&srcinfo);\n\n  /* Initialize destination compression parameters from source values */\n  jpeg_copy_critical_parameters(&srcinfo, &dstinfo);\n\n  /* Adjust default compression parameters by re-parsing the options */\n  file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE);\n\n  /* Specify data destination for compression */\n  jpeg_stdio_dest(&dstinfo, output_file);\n\n  /* Start compressor */\n  jpeg_write_coefficients(&dstinfo, coef_arrays);\n\n  /* ought to copy source comments here... */\n\n  /* Finish compression and release memory */\n  jpeg_finish_compress(&dstinfo);\n  jpeg_destroy_compress(&dstinfo);\n  (void) jpeg_finish_decompress(&srcinfo);\n  jpeg_destroy_decompress(&srcinfo);\n\n  /* Close files, if we opened them */\n  if (input_file != stdin)\n    fclose(input_file);\n  if (output_file != stdout)\n    fclose(output_file);\n\n#ifdef PROGRESS_REPORT\n  end_progress_monitor((j_common_ptr) &dstinfo);\n#endif\n\n  /* All done. */\n  exit(jsrcerr.num_warnings + jdsterr.num_warnings ?EXIT_WARNING:EXIT_SUCCESS);\n  return 0;\t\t\t/* suppress no-return-value warnings */\n}\n"
  },
  {
    "path": "code/jpeg-6/jquant1.c",
    "content": "/*\n * jquant1.c\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains 1-pass color quantization (color mapping) routines.\n * These routines provide mapping to a fixed color map using equally spaced\n * color values.  Optional Floyd-Steinberg or ordered dithering is available.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n#ifdef QUANT_1PASS_SUPPORTED\n\n\n/*\n * The main purpose of 1-pass quantization is to provide a fast, if not very\n * high quality, colormapped output capability.  A 2-pass quantizer usually\n * gives better visual quality; however, for quantized grayscale output this\n * quantizer is perfectly adequate.  Dithering is highly recommended with this\n * quantizer, though you can turn it off if you really want to.\n *\n * In 1-pass quantization the colormap must be chosen in advance of seeing the\n * image.  We use a map consisting of all combinations of Ncolors[i] color\n * values for the i'th component.  The Ncolors[] values are chosen so that\n * their product, the total number of colors, is no more than that requested.\n * (In most cases, the product will be somewhat less.)\n *\n * Since the colormap is orthogonal, the representative value for each color\n * component can be determined without considering the other components;\n * then these indexes can be combined into a colormap index by a standard\n * N-dimensional-array-subscript calculation.  Most of the arithmetic involved\n * can be precalculated and stored in the lookup table colorindex[].\n * colorindex[i][j] maps pixel value j in component i to the nearest\n * representative value (grid plane) for that component; this index is\n * multiplied by the array stride for component i, so that the\n * index of the colormap entry closest to a given pixel value is just\n *    sum( colorindex[component-number][pixel-component-value] )\n * Aside from being fast, this scheme allows for variable spacing between\n * representative values with no additional lookup cost.\n *\n * If gamma correction has been applied in color conversion, it might be wise\n * to adjust the color grid spacing so that the representative colors are\n * equidistant in linear space.  At this writing, gamma correction is not\n * implemented by jdcolor, so nothing is done here.\n */\n\n\n/* Declarations for ordered dithering.\n *\n * We use a standard 16x16 ordered dither array.  The basic concept of ordered\n * dithering is described in many references, for instance Dale Schumacher's\n * chapter II.2 of Graphics Gems II (James Arvo, ed. Academic Press, 1991).\n * In place of Schumacher's comparisons against a \"threshold\" value, we add a\n * \"dither\" value to the input pixel and then round the result to the nearest\n * output value.  The dither value is equivalent to (0.5 - threshold) times\n * the distance between output values.  For ordered dithering, we assume that\n * the output colors are equally spaced; if not, results will probably be\n * worse, since the dither may be too much or too little at a given point.\n *\n * The normal calculation would be to form pixel value + dither, range-limit\n * this to 0..MAXJSAMPLE, and then index into the colorindex table as usual.\n * We can skip the separate range-limiting step by extending the colorindex\n * table in both directions.\n */\n\n#define ODITHER_SIZE  16\t/* dimension of dither matrix */\n/* NB: if ODITHER_SIZE is not a power of 2, ODITHER_MASK uses will break */\n#define ODITHER_CELLS (ODITHER_SIZE*ODITHER_SIZE)\t/* # cells in matrix */\n#define ODITHER_MASK  (ODITHER_SIZE-1) /* mask for wrapping around counters */\n\ntypedef int ODITHER_MATRIX[ODITHER_SIZE][ODITHER_SIZE];\ntypedef int (*ODITHER_MATRIX_PTR)[ODITHER_SIZE];\n\nstatic const UINT8 base_dither_matrix[ODITHER_SIZE][ODITHER_SIZE] = {\n  /* Bayer's order-4 dither array.  Generated by the code given in\n   * Stephen Hawley's article \"Ordered Dithering\" in Graphics Gems I.\n   * The values in this array must range from 0 to ODITHER_CELLS-1.\n   */\n  {   0,192, 48,240, 12,204, 60,252,  3,195, 51,243, 15,207, 63,255 },\n  { 128, 64,176,112,140, 76,188,124,131, 67,179,115,143, 79,191,127 },\n  {  32,224, 16,208, 44,236, 28,220, 35,227, 19,211, 47,239, 31,223 },\n  { 160, 96,144, 80,172,108,156, 92,163, 99,147, 83,175,111,159, 95 },\n  {   8,200, 56,248,  4,196, 52,244, 11,203, 59,251,  7,199, 55,247 },\n  { 136, 72,184,120,132, 68,180,116,139, 75,187,123,135, 71,183,119 },\n  {  40,232, 24,216, 36,228, 20,212, 43,235, 27,219, 39,231, 23,215 },\n  { 168,104,152, 88,164,100,148, 84,171,107,155, 91,167,103,151, 87 },\n  {   2,194, 50,242, 14,206, 62,254,  1,193, 49,241, 13,205, 61,253 },\n  { 130, 66,178,114,142, 78,190,126,129, 65,177,113,141, 77,189,125 },\n  {  34,226, 18,210, 46,238, 30,222, 33,225, 17,209, 45,237, 29,221 },\n  { 162, 98,146, 82,174,110,158, 94,161, 97,145, 81,173,109,157, 93 },\n  {  10,202, 58,250,  6,198, 54,246,  9,201, 57,249,  5,197, 53,245 },\n  { 138, 74,186,122,134, 70,182,118,137, 73,185,121,133, 69,181,117 },\n  {  42,234, 26,218, 38,230, 22,214, 41,233, 25,217, 37,229, 21,213 },\n  { 170,106,154, 90,166,102,150, 86,169,105,153, 89,165,101,149, 85 }\n};\n\n\n/* Declarations for Floyd-Steinberg dithering.\n *\n * Errors are accumulated into the array fserrors[], at a resolution of\n * 1/16th of a pixel count.  The error at a given pixel is propagated\n * to its not-yet-processed neighbors using the standard F-S fractions,\n *\t\t...\t(here)\t7/16\n *\t\t3/16\t5/16\t1/16\n * We work left-to-right on even rows, right-to-left on odd rows.\n *\n * We can get away with a single array (holding one row's worth of errors)\n * by using it to store the current row's errors at pixel columns not yet\n * processed, but the next row's errors at columns already processed.  We\n * need only a few extra variables to hold the errors immediately around the\n * current column.  (If we are lucky, those variables are in registers, but\n * even if not, they're probably cheaper to access than array elements are.)\n *\n * The fserrors[] array is indexed [component#][position].\n * We provide (#columns + 2) entries per component; the extra entry at each\n * end saves us from special-casing the first and last pixels.\n *\n * Note: on a wide image, we might not have enough room in a PC's near data\n * segment to hold the error array; so it is allocated with alloc_large.\n */\n\n#if BITS_IN_JSAMPLE == 8\ntypedef INT16 FSERROR;\t\t/* 16 bits should be enough */\ntypedef int LOCFSERROR;\t\t/* use 'int' for calculation temps */\n#else\ntypedef INT32 FSERROR;\t\t/* may need more than 16 bits */\ntypedef INT32 LOCFSERROR;\t/* be sure calculation temps are big enough */\n#endif\n\ntypedef FSERROR FAR *FSERRPTR;\t/* pointer to error array (in FAR storage!) */\n\n\n/* Private subobject */\n\n#define MAX_Q_COMPS 4\t\t/* max components I can handle */\n\ntypedef struct {\n  struct jpeg_color_quantizer pub; /* public fields */\n\n  /* Initially allocated colormap is saved here */\n  JSAMPARRAY sv_colormap;\t/* The color map as a 2-D pixel array */\n  int sv_actual;\t\t/* number of entries in use */\n\n  JSAMPARRAY colorindex;\t/* Precomputed mapping for speed */\n  /* colorindex[i][j] = index of color closest to pixel value j in component i,\n   * premultiplied as described above.  Since colormap indexes must fit into\n   * JSAMPLEs, the entries of this array will too.\n   */\n  boolean is_padded;\t\t/* is the colorindex padded for odither? */\n\n  int Ncolors[MAX_Q_COMPS];\t/* # of values alloced to each component */\n\n  /* Variables for ordered dithering */\n  int row_index;\t\t/* cur row's vertical index in dither matrix */\n  ODITHER_MATRIX_PTR odither[MAX_Q_COMPS]; /* one dither array per component */\n\n  /* Variables for Floyd-Steinberg dithering */\n  FSERRPTR fserrors[MAX_Q_COMPS]; /* accumulated errors */\n  boolean on_odd_row;\t\t/* flag to remember which row we are on */\n} my_cquantizer;\n\ntypedef my_cquantizer * my_cquantize_ptr;\n\n\n/*\n * Policy-making subroutines for create_colormap and create_colorindex.\n * These routines determine the colormap to be used.  The rest of the module\n * only assumes that the colormap is orthogonal.\n *\n *  * select_ncolors decides how to divvy up the available colors\n *    among the components.\n *  * output_value defines the set of representative values for a component.\n *  * largest_input_value defines the mapping from input values to\n *    representative values for a component.\n * Note that the latter two routines may impose different policies for\n * different components, though this is not currently done.\n */\n\n\nLOCAL int\nselect_ncolors (j_decompress_ptr cinfo, int Ncolors[])\n/* Determine allocation of desired colors to components, */\n/* and fill in Ncolors[] array to indicate choice. */\n/* Return value is total number of colors (product of Ncolors[] values). */\n{\n  int nc = cinfo->out_color_components; /* number of color components */\n  int max_colors = cinfo->desired_number_of_colors;\n  int total_colors, iroot, i, j;\n  boolean changed;\n  long temp;\n  static const int RGB_order[3] = { RGB_GREEN, RGB_RED, RGB_BLUE };\n\n  /* We can allocate at least the nc'th root of max_colors per component. */\n  /* Compute floor(nc'th root of max_colors). */\n  iroot = 1;\n  do {\n    iroot++;\n    temp = iroot;\t\t/* set temp = iroot ** nc */\n    for (i = 1; i < nc; i++)\n      temp *= iroot;\n  } while (temp <= (long) max_colors); /* repeat till iroot exceeds root */\n  iroot--;\t\t\t/* now iroot = floor(root) */\n\n  /* Must have at least 2 color values per component */\n  if (iroot < 2)\n    ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, (int) temp);\n\n  /* Initialize to iroot color values for each component */\n  total_colors = 1;\n  for (i = 0; i < nc; i++) {\n    Ncolors[i] = iroot;\n    total_colors *= iroot;\n  }\n  /* We may be able to increment the count for one or more components without\n   * exceeding max_colors, though we know not all can be incremented.\n   * Sometimes, the first component can be incremented more than once!\n   * (Example: for 16 colors, we start at 2*2*2, go to 3*2*2, then 4*2*2.)\n   * In RGB colorspace, try to increment G first, then R, then B.\n   */\n  do {\n    changed = FALSE;\n    for (i = 0; i < nc; i++) {\n      j = (cinfo->out_color_space == JCS_RGB ? RGB_order[i] : i);\n      /* calculate new total_colors if Ncolors[j] is incremented */\n      temp = total_colors / Ncolors[j];\n      temp *= Ncolors[j]+1;\t/* done in long arith to avoid oflo */\n      if (temp > (long) max_colors)\n\tbreak;\t\t\t/* won't fit, done with this pass */\n      Ncolors[j]++;\t\t/* OK, apply the increment */\n      total_colors = (int) temp;\n      changed = TRUE;\n    }\n  } while (changed);\n\n  return total_colors;\n}\n\n\nLOCAL int\noutput_value (j_decompress_ptr cinfo, int ci, int j, int maxj)\n/* Return j'th output value, where j will range from 0 to maxj */\n/* The output values must fall in 0..MAXJSAMPLE in increasing order */\n{\n  /* We always provide values 0 and MAXJSAMPLE for each component;\n   * any additional values are equally spaced between these limits.\n   * (Forcing the upper and lower values to the limits ensures that\n   * dithering can't produce a color outside the selected gamut.)\n   */\n  return (int) (((INT32) j * MAXJSAMPLE + maxj/2) / maxj);\n}\n\n\nLOCAL int\nlargest_input_value (j_decompress_ptr cinfo, int ci, int j, int maxj)\n/* Return largest input value that should map to j'th output value */\n/* Must have largest(j=0) >= 0, and largest(j=maxj) >= MAXJSAMPLE */\n{\n  /* Breakpoints are halfway between values returned by output_value */\n  return (int) (((INT32) (2*j + 1) * MAXJSAMPLE + maxj) / (2*maxj));\n}\n\n\n/*\n * Create the colormap.\n */\n\nLOCAL void\ncreate_colormap (j_decompress_ptr cinfo)\n{\n  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;\n  JSAMPARRAY colormap;\t\t/* Created colormap */\n  int total_colors;\t\t/* Number of distinct output colors */\n  int i,j,k, nci, blksize, blkdist, ptr, val;\n\n  /* Select number of colors for each component */\n  total_colors = select_ncolors(cinfo, cquantize->Ncolors);\n\n  /* Report selected color counts */\n  if (cinfo->out_color_components == 3)\n    TRACEMS4(cinfo, 1, JTRC_QUANT_3_NCOLORS,\n\t     total_colors, cquantize->Ncolors[0],\n\t     cquantize->Ncolors[1], cquantize->Ncolors[2]);\n  else\n    TRACEMS1(cinfo, 1, JTRC_QUANT_NCOLORS, total_colors);\n\n  /* Allocate and fill in the colormap. */\n  /* The colors are ordered in the map in standard row-major order, */\n  /* i.e. rightmost (highest-indexed) color changes most rapidly. */\n\n  colormap = (*cinfo->mem->alloc_sarray)\n    ((j_common_ptr) cinfo, JPOOL_IMAGE,\n     (JDIMENSION) total_colors, (JDIMENSION) cinfo->out_color_components);\n\n  /* blksize is number of adjacent repeated entries for a component */\n  /* blkdist is distance between groups of identical entries for a component */\n  blkdist = total_colors;\n\n  for (i = 0; i < cinfo->out_color_components; i++) {\n    /* fill in colormap entries for i'th color component */\n    nci = cquantize->Ncolors[i]; /* # of distinct values for this color */\n    blksize = blkdist / nci;\n    for (j = 0; j < nci; j++) {\n      /* Compute j'th output value (out of nci) for component */\n      val = output_value(cinfo, i, j, nci-1);\n      /* Fill in all colormap entries that have this value of this component */\n      for (ptr = j * blksize; ptr < total_colors; ptr += blkdist) {\n\t/* fill in blksize entries beginning at ptr */\n\tfor (k = 0; k < blksize; k++)\n\t  colormap[i][ptr+k] = (JSAMPLE) val;\n      }\n    }\n    blkdist = blksize;\t\t/* blksize of this color is blkdist of next */\n  }\n\n  /* Save the colormap in private storage,\n   * where it will survive color quantization mode changes.\n   */\n  cquantize->sv_colormap = colormap;\n  cquantize->sv_actual = total_colors;\n}\n\n\n/*\n * Create the color index table.\n */\n\nLOCAL void\ncreate_colorindex (j_decompress_ptr cinfo)\n{\n  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;\n  JSAMPROW indexptr;\n  int i,j,k, nci, blksize, val, pad;\n\n  /* For ordered dither, we pad the color index tables by MAXJSAMPLE in\n   * each direction (input index values can be -MAXJSAMPLE .. 2*MAXJSAMPLE).\n   * This is not necessary in the other dithering modes.  However, we\n   * flag whether it was done in case user changes dithering mode.\n   */\n  if (cinfo->dither_mode == JDITHER_ORDERED) {\n    pad = MAXJSAMPLE*2;\n    cquantize->is_padded = TRUE;\n  } else {\n    pad = 0;\n    cquantize->is_padded = FALSE;\n  }\n\n  cquantize->colorindex = (*cinfo->mem->alloc_sarray)\n    ((j_common_ptr) cinfo, JPOOL_IMAGE,\n     (JDIMENSION) (MAXJSAMPLE+1 + pad),\n     (JDIMENSION) cinfo->out_color_components);\n\n  /* blksize is number of adjacent repeated entries for a component */\n  blksize = cquantize->sv_actual;\n\n  for (i = 0; i < cinfo->out_color_components; i++) {\n    /* fill in colorindex entries for i'th color component */\n    nci = cquantize->Ncolors[i]; /* # of distinct values for this color */\n    blksize = blksize / nci;\n\n    /* adjust colorindex pointers to provide padding at negative indexes. */\n    if (pad)\n      cquantize->colorindex[i] += MAXJSAMPLE;\n\n    /* in loop, val = index of current output value, */\n    /* and k = largest j that maps to current val */\n    indexptr = cquantize->colorindex[i];\n    val = 0;\n    k = largest_input_value(cinfo, i, 0, nci-1);\n    for (j = 0; j <= MAXJSAMPLE; j++) {\n      while (j > k)\t\t/* advance val if past boundary */\n\tk = largest_input_value(cinfo, i, ++val, nci-1);\n      /* premultiply so that no multiplication needed in main processing */\n      indexptr[j] = (JSAMPLE) (val * blksize);\n    }\n    /* Pad at both ends if necessary */\n    if (pad)\n      for (j = 1; j <= MAXJSAMPLE; j++) {\n\tindexptr[-j] = indexptr[0];\n\tindexptr[MAXJSAMPLE+j] = indexptr[MAXJSAMPLE];\n      }\n  }\n}\n\n\n/*\n * Create an ordered-dither array for a component having ncolors\n * distinct output values.\n */\n\nLOCAL ODITHER_MATRIX_PTR\nmake_odither_array (j_decompress_ptr cinfo, int ncolors)\n{\n  ODITHER_MATRIX_PTR odither;\n  int j,k;\n  INT32 num,den;\n\n  odither = (ODITHER_MATRIX_PTR)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(ODITHER_MATRIX));\n  /* The inter-value distance for this color is MAXJSAMPLE/(ncolors-1).\n   * Hence the dither value for the matrix cell with fill order f\n   * (f=0..N-1) should be (N-1-2*f)/(2*N) * MAXJSAMPLE/(ncolors-1).\n   * On 16-bit-int machine, be careful to avoid overflow.\n   */\n  den = 2 * ODITHER_CELLS * ((INT32) (ncolors - 1));\n  for (j = 0; j < ODITHER_SIZE; j++) {\n    for (k = 0; k < ODITHER_SIZE; k++) {\n      num = ((INT32) (ODITHER_CELLS-1 - 2*((int)base_dither_matrix[j][k])))\n\t    * MAXJSAMPLE;\n      /* Ensure round towards zero despite C's lack of consistency\n       * about rounding negative values in integer division...\n       */\n      odither[j][k] = (int) (num<0 ? -((-num)/den) : num/den);\n    }\n  }\n  return odither;\n}\n\n\n/*\n * Create the ordered-dither tables.\n * Components having the same number of representative colors may \n * share a dither table.\n */\n\nLOCAL void\ncreate_odither_tables (j_decompress_ptr cinfo)\n{\n  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;\n  ODITHER_MATRIX_PTR odither;\n  int i, j, nci;\n\n  for (i = 0; i < cinfo->out_color_components; i++) {\n    nci = cquantize->Ncolors[i]; /* # of distinct values for this color */\n    odither = NULL;\t\t/* search for matching prior component */\n    for (j = 0; j < i; j++) {\n      if (nci == cquantize->Ncolors[j]) {\n\todither = cquantize->odither[j];\n\tbreak;\n      }\n    }\n    if (odither == NULL)\t/* need a new table? */\n      odither = make_odither_array(cinfo, nci);\n    cquantize->odither[i] = odither;\n  }\n}\n\n\n/*\n * Map some rows of pixels to the output colormapped representation.\n */\n\nMETHODDEF void\ncolor_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,\n\t\tJSAMPARRAY output_buf, int num_rows)\n/* General case, no dithering */\n{\n  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;\n  JSAMPARRAY colorindex = cquantize->colorindex;\n  register int pixcode, ci;\n  register JSAMPROW ptrin, ptrout;\n  int row;\n  JDIMENSION col;\n  JDIMENSION width = cinfo->output_width;\n  register int nc = cinfo->out_color_components;\n\n  for (row = 0; row < num_rows; row++) {\n    ptrin = input_buf[row];\n    ptrout = output_buf[row];\n    for (col = width; col > 0; col--) {\n      pixcode = 0;\n      for (ci = 0; ci < nc; ci++) {\n\tpixcode += GETJSAMPLE(colorindex[ci][GETJSAMPLE(*ptrin++)]);\n      }\n      *ptrout++ = (JSAMPLE) pixcode;\n    }\n  }\n}\n\n\nMETHODDEF void\ncolor_quantize3 (j_decompress_ptr cinfo, JSAMPARRAY input_buf,\n\t\t JSAMPARRAY output_buf, int num_rows)\n/* Fast path for out_color_components==3, no dithering */\n{\n  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;\n  register int pixcode;\n  register JSAMPROW ptrin, ptrout;\n  JSAMPROW colorindex0 = cquantize->colorindex[0];\n  JSAMPROW colorindex1 = cquantize->colorindex[1];\n  JSAMPROW colorindex2 = cquantize->colorindex[2];\n  int row;\n  JDIMENSION col;\n  JDIMENSION width = cinfo->output_width;\n\n  for (row = 0; row < num_rows; row++) {\n    ptrin = input_buf[row];\n    ptrout = output_buf[row];\n    for (col = width; col > 0; col--) {\n      pixcode  = GETJSAMPLE(colorindex0[GETJSAMPLE(*ptrin++)]);\n      pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*ptrin++)]);\n      pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*ptrin++)]);\n      *ptrout++ = (JSAMPLE) pixcode;\n    }\n  }\n}\n\n\nMETHODDEF void\nquantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,\n\t\t     JSAMPARRAY output_buf, int num_rows)\n/* General case, with ordered dithering */\n{\n  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;\n  register JSAMPROW input_ptr;\n  register JSAMPROW output_ptr;\n  JSAMPROW colorindex_ci;\n  int * dither;\t\t\t/* points to active row of dither matrix */\n  int row_index, col_index;\t/* current indexes into dither matrix */\n  int nc = cinfo->out_color_components;\n  int ci;\n  int row;\n  JDIMENSION col;\n  JDIMENSION width = cinfo->output_width;\n\n  for (row = 0; row < num_rows; row++) {\n    /* Initialize output values to 0 so can process components separately */\n    jzero_far((void FAR *) output_buf[row],\n\t      (size_t) (width * SIZEOF(JSAMPLE)));\n    row_index = cquantize->row_index;\n    for (ci = 0; ci < nc; ci++) {\n      input_ptr = input_buf[row] + ci;\n      output_ptr = output_buf[row];\n      colorindex_ci = cquantize->colorindex[ci];\n      dither = cquantize->odither[ci][row_index];\n      col_index = 0;\n\n      for (col = width; col > 0; col--) {\n\t/* Form pixel value + dither, range-limit to 0..MAXJSAMPLE,\n\t * select output value, accumulate into output code for this pixel.\n\t * Range-limiting need not be done explicitly, as we have extended\n\t * the colorindex table to produce the right answers for out-of-range\n\t * inputs.  The maximum dither is +- MAXJSAMPLE; this sets the\n\t * required amount of padding.\n\t */\n\t*output_ptr += colorindex_ci[GETJSAMPLE(*input_ptr)+dither[col_index]];\n\tinput_ptr += nc;\n\toutput_ptr++;\n\tcol_index = (col_index + 1) & ODITHER_MASK;\n      }\n    }\n    /* Advance row index for next row */\n    row_index = (row_index + 1) & ODITHER_MASK;\n    cquantize->row_index = row_index;\n  }\n}\n\n\nMETHODDEF void\nquantize3_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,\n\t\t      JSAMPARRAY output_buf, int num_rows)\n/* Fast path for out_color_components==3, with ordered dithering */\n{\n  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;\n  register int pixcode;\n  register JSAMPROW input_ptr;\n  register JSAMPROW output_ptr;\n  JSAMPROW colorindex0 = cquantize->colorindex[0];\n  JSAMPROW colorindex1 = cquantize->colorindex[1];\n  JSAMPROW colorindex2 = cquantize->colorindex[2];\n  int * dither0;\t\t/* points to active row of dither matrix */\n  int * dither1;\n  int * dither2;\n  int row_index, col_index;\t/* current indexes into dither matrix */\n  int row;\n  JDIMENSION col;\n  JDIMENSION width = cinfo->output_width;\n\n  for (row = 0; row < num_rows; row++) {\n    row_index = cquantize->row_index;\n    input_ptr = input_buf[row];\n    output_ptr = output_buf[row];\n    dither0 = cquantize->odither[0][row_index];\n    dither1 = cquantize->odither[1][row_index];\n    dither2 = cquantize->odither[2][row_index];\n    col_index = 0;\n\n    for (col = width; col > 0; col--) {\n      pixcode  = GETJSAMPLE(colorindex0[GETJSAMPLE(*input_ptr++) +\n\t\t\t\t\tdither0[col_index]]);\n      pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*input_ptr++) +\n\t\t\t\t\tdither1[col_index]]);\n      pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*input_ptr++) +\n\t\t\t\t\tdither2[col_index]]);\n      *output_ptr++ = (JSAMPLE) pixcode;\n      col_index = (col_index + 1) & ODITHER_MASK;\n    }\n    row_index = (row_index + 1) & ODITHER_MASK;\n    cquantize->row_index = row_index;\n  }\n}\n\n\nMETHODDEF void\nquantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,\n\t\t    JSAMPARRAY output_buf, int num_rows)\n/* General case, with Floyd-Steinberg dithering */\n{\n  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;\n  register LOCFSERROR cur;\t/* current error or pixel value */\n  LOCFSERROR belowerr;\t\t/* error for pixel below cur */\n  LOCFSERROR bpreverr;\t\t/* error for below/prev col */\n  LOCFSERROR bnexterr;\t\t/* error for below/next col */\n  LOCFSERROR delta;\n  register FSERRPTR errorptr;\t/* => fserrors[] at column before current */\n  register JSAMPROW input_ptr;\n  register JSAMPROW output_ptr;\n  JSAMPROW colorindex_ci;\n  JSAMPROW colormap_ci;\n  int pixcode;\n  int nc = cinfo->out_color_components;\n  int dir;\t\t\t/* 1 for left-to-right, -1 for right-to-left */\n  int dirnc;\t\t\t/* dir * nc */\n  int ci;\n  int row;\n  JDIMENSION col;\n  JDIMENSION width = cinfo->output_width;\n  JSAMPLE *range_limit = cinfo->sample_range_limit;\n  SHIFT_TEMPS\n\n  for (row = 0; row < num_rows; row++) {\n    /* Initialize output values to 0 so can process components separately */\n    jzero_far((void FAR *) output_buf[row],\n\t      (size_t) (width * SIZEOF(JSAMPLE)));\n    for (ci = 0; ci < nc; ci++) {\n      input_ptr = input_buf[row] + ci;\n      output_ptr = output_buf[row];\n      if (cquantize->on_odd_row) {\n\t/* work right to left in this row */\n\tinput_ptr += (width-1) * nc; /* so point to rightmost pixel */\n\toutput_ptr += width-1;\n\tdir = -1;\n\tdirnc = -nc;\n\terrorptr = cquantize->fserrors[ci] + (width+1); /* => entry after last column */\n      } else {\n\t/* work left to right in this row */\n\tdir = 1;\n\tdirnc = nc;\n\terrorptr = cquantize->fserrors[ci]; /* => entry before first column */\n      }\n      colorindex_ci = cquantize->colorindex[ci];\n      colormap_ci = cquantize->sv_colormap[ci];\n      /* Preset error values: no error propagated to first pixel from left */\n      cur = 0;\n      /* and no error propagated to row below yet */\n      belowerr = bpreverr = 0;\n\n      for (col = width; col > 0; col--) {\n\t/* cur holds the error propagated from the previous pixel on the\n\t * current line.  Add the error propagated from the previous line\n\t * to form the complete error correction term for this pixel, and\n\t * round the error term (which is expressed * 16) to an integer.\n\t * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct\n\t * for either sign of the error value.\n\t * Note: errorptr points to *previous* column's array entry.\n\t */\n\tcur = RIGHT_SHIFT(cur + errorptr[dir] + 8, 4);\n\t/* Form pixel value + error, and range-limit to 0..MAXJSAMPLE.\n\t * The maximum error is +- MAXJSAMPLE; this sets the required size\n\t * of the range_limit array.\n\t */\n\tcur += GETJSAMPLE(*input_ptr);\n\tcur = GETJSAMPLE(range_limit[cur]);\n\t/* Select output value, accumulate into output code for this pixel */\n\tpixcode = GETJSAMPLE(colorindex_ci[cur]);\n\t*output_ptr += (JSAMPLE) pixcode;\n\t/* Compute actual representation error at this pixel */\n\t/* Note: we can do this even though we don't have the final */\n\t/* pixel code, because the colormap is orthogonal. */\n\tcur -= GETJSAMPLE(colormap_ci[pixcode]);\n\t/* Compute error fractions to be propagated to adjacent pixels.\n\t * Add these into the running sums, and simultaneously shift the\n\t * next-line error sums left by 1 column.\n\t */\n\tbnexterr = cur;\n\tdelta = cur * 2;\n\tcur += delta;\t\t/* form error * 3 */\n\terrorptr[0] = (FSERROR) (bpreverr + cur);\n\tcur += delta;\t\t/* form error * 5 */\n\tbpreverr = belowerr + cur;\n\tbelowerr = bnexterr;\n\tcur += delta;\t\t/* form error * 7 */\n\t/* At this point cur contains the 7/16 error value to be propagated\n\t * to the next pixel on the current line, and all the errors for the\n\t * next line have been shifted over. We are therefore ready to move on.\n\t */\n\tinput_ptr += dirnc;\t/* advance input ptr to next column */\n\toutput_ptr += dir;\t/* advance output ptr to next column */\n\terrorptr += dir;\t/* advance errorptr to current column */\n      }\n      /* Post-loop cleanup: we must unload the final error value into the\n       * final fserrors[] entry.  Note we need not unload belowerr because\n       * it is for the dummy column before or after the actual array.\n       */\n      errorptr[0] = (FSERROR) bpreverr; /* unload prev err into array */\n    }\n    cquantize->on_odd_row = (cquantize->on_odd_row ? FALSE : TRUE);\n  }\n}\n\n\n/*\n * Allocate workspace for Floyd-Steinberg errors.\n */\n\nLOCAL void\nalloc_fs_workspace (j_decompress_ptr cinfo)\n{\n  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;\n  size_t arraysize;\n  int i;\n\n  arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR));\n  for (i = 0; i < cinfo->out_color_components; i++) {\n    cquantize->fserrors[i] = (FSERRPTR)\n      (*cinfo->mem->alloc_large)((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize);\n  }\n}\n\n\n/*\n * Initialize for one-pass color quantization.\n */\n\nMETHODDEF void\nstart_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan)\n{\n  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;\n  size_t arraysize;\n  int i;\n\n  /* Install my colormap. */\n  cinfo->colormap = cquantize->sv_colormap;\n  cinfo->actual_number_of_colors = cquantize->sv_actual;\n\n  /* Initialize for desired dithering mode. */\n  switch (cinfo->dither_mode) {\n  case JDITHER_NONE:\n    if (cinfo->out_color_components == 3)\n      cquantize->pub.color_quantize = color_quantize3;\n    else\n      cquantize->pub.color_quantize = color_quantize;\n    break;\n  case JDITHER_ORDERED:\n    if (cinfo->out_color_components == 3)\n      cquantize->pub.color_quantize = quantize3_ord_dither;\n    else\n      cquantize->pub.color_quantize = quantize_ord_dither;\n    cquantize->row_index = 0;\t/* initialize state for ordered dither */\n    /* If user changed to ordered dither from another mode,\n     * we must recreate the color index table with padding.\n     * This will cost extra space, but probably isn't very likely.\n     */\n    if (! cquantize->is_padded)\n      create_colorindex(cinfo);\n    /* Create ordered-dither tables if we didn't already. */\n    if (cquantize->odither[0] == NULL)\n      create_odither_tables(cinfo);\n    break;\n  case JDITHER_FS:\n    cquantize->pub.color_quantize = quantize_fs_dither;\n    cquantize->on_odd_row = FALSE; /* initialize state for F-S dither */\n    /* Allocate Floyd-Steinberg workspace if didn't already. */\n    if (cquantize->fserrors[0] == NULL)\n      alloc_fs_workspace(cinfo);\n    /* Initialize the propagated errors to zero. */\n    arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR));\n    for (i = 0; i < cinfo->out_color_components; i++)\n      jzero_far((void FAR *) cquantize->fserrors[i], arraysize);\n    break;\n  default:\n    ERREXIT(cinfo, JERR_NOT_COMPILED);\n    break;\n  }\n}\n\n\n/*\n * Finish up at the end of the pass.\n */\n\nMETHODDEF void\nfinish_pass_1_quant (j_decompress_ptr cinfo)\n{\n  /* no work in 1-pass case */\n}\n\n\n/*\n * Switch to a new external colormap between output passes.\n * Shouldn't get to this module!\n */\n\nMETHODDEF void\nnew_color_map_1_quant (j_decompress_ptr cinfo)\n{\n  ERREXIT(cinfo, JERR_MODE_CHANGE);\n}\n\n\n/*\n * Module initialization routine for 1-pass color quantization.\n */\n\nGLOBAL void\njinit_1pass_quantizer (j_decompress_ptr cinfo)\n{\n  my_cquantize_ptr cquantize;\n\n  cquantize = (my_cquantize_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_cquantizer));\n  cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize;\n  cquantize->pub.start_pass = start_pass_1_quant;\n  cquantize->pub.finish_pass = finish_pass_1_quant;\n  cquantize->pub.new_color_map = new_color_map_1_quant;\n  cquantize->fserrors[0] = NULL; /* Flag FS workspace not allocated */\n  cquantize->odither[0] = NULL;\t/* Also flag odither arrays not allocated */\n\n  /* Make sure my internal arrays won't overflow */\n  if (cinfo->out_color_components > MAX_Q_COMPS)\n    ERREXIT1(cinfo, JERR_QUANT_COMPONENTS, MAX_Q_COMPS);\n  /* Make sure colormap indexes can be represented by JSAMPLEs */\n  if (cinfo->desired_number_of_colors > (MAXJSAMPLE+1))\n    ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXJSAMPLE+1);\n\n  /* Create the colormap and color index table. */\n  create_colormap(cinfo);\n  create_colorindex(cinfo);\n\n  /* Allocate Floyd-Steinberg workspace now if requested.\n   * We do this now since it is FAR storage and may affect the memory\n   * manager's space calculations.  If the user changes to FS dither\n   * mode in a later pass, we will allocate the space then, and will\n   * possibly overrun the max_memory_to_use setting.\n   */\n  if (cinfo->dither_mode == JDITHER_FS)\n    alloc_fs_workspace(cinfo);\n}\n\n#endif /* QUANT_1PASS_SUPPORTED */\n"
  },
  {
    "path": "code/jpeg-6/jquant2.c",
    "content": "/*\n * jquant2.c\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains 2-pass color quantization (color mapping) routines.\n * These routines provide selection of a custom color map for an image,\n * followed by mapping of the image to that color map, with optional\n * Floyd-Steinberg dithering.\n * It is also possible to use just the second pass to map to an arbitrary\n * externally-given color map.\n *\n * Note: ordered dithering is not supported, since there isn't any fast\n * way to compute intercolor distances; it's unclear that ordered dither's\n * fundamental assumptions even hold with an irregularly spaced color map.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n#ifdef QUANT_2PASS_SUPPORTED\n\n\n/*\n * This module implements the well-known Heckbert paradigm for color\n * quantization.  Most of the ideas used here can be traced back to\n * Heckbert's seminal paper\n *   Heckbert, Paul.  \"Color Image Quantization for Frame Buffer Display\",\n *   Proc. SIGGRAPH '82, Computer Graphics v.16 #3 (July 1982), pp 297-304.\n *\n * In the first pass over the image, we accumulate a histogram showing the\n * usage count of each possible color.  To keep the histogram to a reasonable\n * size, we reduce the precision of the input; typical practice is to retain\n * 5 or 6 bits per color, so that 8 or 4 different input values are counted\n * in the same histogram cell.\n *\n * Next, the color-selection step begins with a box representing the whole\n * color space, and repeatedly splits the \"largest\" remaining box until we\n * have as many boxes as desired colors.  Then the mean color in each\n * remaining box becomes one of the possible output colors.\n * \n * The second pass over the image maps each input pixel to the closest output\n * color (optionally after applying a Floyd-Steinberg dithering correction).\n * This mapping is logically trivial, but making it go fast enough requires\n * considerable care.\n *\n * Heckbert-style quantizers vary a good deal in their policies for choosing\n * the \"largest\" box and deciding where to cut it.  The particular policies\n * used here have proved out well in experimental comparisons, but better ones\n * may yet be found.\n *\n * In earlier versions of the IJG code, this module quantized in YCbCr color\n * space, processing the raw upsampled data without a color conversion step.\n * This allowed the color conversion math to be done only once per colormap\n * entry, not once per pixel.  However, that optimization precluded other\n * useful optimizations (such as merging color conversion with upsampling)\n * and it also interfered with desired capabilities such as quantizing to an\n * externally-supplied colormap.  We have therefore abandoned that approach.\n * The present code works in the post-conversion color space, typically RGB.\n *\n * To improve the visual quality of the results, we actually work in scaled\n * RGB space, giving G distances more weight than R, and R in turn more than\n * B.  To do everything in integer math, we must use integer scale factors.\n * The 2/3/1 scale factors used here correspond loosely to the relative\n * weights of the colors in the NTSC grayscale equation.\n * If you want to use this code to quantize a non-RGB color space, you'll\n * probably need to change these scale factors.\n */\n\n#define R_SCALE 2\t\t/* scale R distances by this much */\n#define G_SCALE 3\t\t/* scale G distances by this much */\n#define B_SCALE 1\t\t/* and B by this much */\n\n/* Relabel R/G/B as components 0/1/2, respecting the RGB ordering defined\n * in jmorecfg.h.  As the code stands, it will do the right thing for R,G,B\n * and B,G,R orders.  If you define some other weird order in jmorecfg.h,\n * you'll get compile errors until you extend this logic.  In that case\n * you'll probably want to tweak the histogram sizes too.\n */\n\n#if RGB_RED == 0\n#define C0_SCALE R_SCALE\n#endif\n#if RGB_BLUE == 0\n#define C0_SCALE B_SCALE\n#endif\n#if RGB_GREEN == 1\n#define C1_SCALE G_SCALE\n#endif\n#if RGB_RED == 2\n#define C2_SCALE R_SCALE\n#endif\n#if RGB_BLUE == 2\n#define C2_SCALE B_SCALE\n#endif\n\n\n/*\n * First we have the histogram data structure and routines for creating it.\n *\n * The number of bits of precision can be adjusted by changing these symbols.\n * We recommend keeping 6 bits for G and 5 each for R and B.\n * If you have plenty of memory and cycles, 6 bits all around gives marginally\n * better results; if you are short of memory, 5 bits all around will save\n * some space but degrade the results.\n * To maintain a fully accurate histogram, we'd need to allocate a \"long\"\n * (preferably unsigned long) for each cell.  In practice this is overkill;\n * we can get by with 16 bits per cell.  Few of the cell counts will overflow,\n * and clamping those that do overflow to the maximum value will give close-\n * enough results.  This reduces the recommended histogram size from 256Kb\n * to 128Kb, which is a useful savings on PC-class machines.\n * (In the second pass the histogram space is re-used for pixel mapping data;\n * in that capacity, each cell must be able to store zero to the number of\n * desired colors.  16 bits/cell is plenty for that too.)\n * Since the JPEG code is intended to run in small memory model on 80x86\n * machines, we can't just allocate the histogram in one chunk.  Instead\n * of a true 3-D array, we use a row of pointers to 2-D arrays.  Each\n * pointer corresponds to a C0 value (typically 2^5 = 32 pointers) and\n * each 2-D array has 2^6*2^5 = 2048 or 2^6*2^6 = 4096 entries.  Note that\n * on 80x86 machines, the pointer row is in near memory but the actual\n * arrays are in far memory (same arrangement as we use for image arrays).\n */\n\n#define MAXNUMCOLORS  (MAXJSAMPLE+1) /* maximum size of colormap */\n\n/* These will do the right thing for either R,G,B or B,G,R color order,\n * but you may not like the results for other color orders.\n */\n#define HIST_C0_BITS  5\t\t/* bits of precision in R/B histogram */\n#define HIST_C1_BITS  6\t\t/* bits of precision in G histogram */\n#define HIST_C2_BITS  5\t\t/* bits of precision in B/R histogram */\n\n/* Number of elements along histogram axes. */\n#define HIST_C0_ELEMS  (1<<HIST_C0_BITS)\n#define HIST_C1_ELEMS  (1<<HIST_C1_BITS)\n#define HIST_C2_ELEMS  (1<<HIST_C2_BITS)\n\n/* These are the amounts to shift an input value to get a histogram index. */\n#define C0_SHIFT  (BITS_IN_JSAMPLE-HIST_C0_BITS)\n#define C1_SHIFT  (BITS_IN_JSAMPLE-HIST_C1_BITS)\n#define C2_SHIFT  (BITS_IN_JSAMPLE-HIST_C2_BITS)\n\n\ntypedef UINT16 histcell;\t/* histogram cell; prefer an unsigned type */\n\ntypedef histcell FAR * histptr;\t/* for pointers to histogram cells */\n\ntypedef histcell hist1d[HIST_C2_ELEMS]; /* typedefs for the array */\ntypedef hist1d FAR * hist2d;\t/* type for the 2nd-level pointers */\ntypedef hist2d * hist3d;\t/* type for top-level pointer */\n\n\n/* Declarations for Floyd-Steinberg dithering.\n *\n * Errors are accumulated into the array fserrors[], at a resolution of\n * 1/16th of a pixel count.  The error at a given pixel is propagated\n * to its not-yet-processed neighbors using the standard F-S fractions,\n *\t\t...\t(here)\t7/16\n *\t\t3/16\t5/16\t1/16\n * We work left-to-right on even rows, right-to-left on odd rows.\n *\n * We can get away with a single array (holding one row's worth of errors)\n * by using it to store the current row's errors at pixel columns not yet\n * processed, but the next row's errors at columns already processed.  We\n * need only a few extra variables to hold the errors immediately around the\n * current column.  (If we are lucky, those variables are in registers, but\n * even if not, they're probably cheaper to access than array elements are.)\n *\n * The fserrors[] array has (#columns + 2) entries; the extra entry at\n * each end saves us from special-casing the first and last pixels.\n * Each entry is three values long, one value for each color component.\n *\n * Note: on a wide image, we might not have enough room in a PC's near data\n * segment to hold the error array; so it is allocated with alloc_large.\n */\n\n#if BITS_IN_JSAMPLE == 8\ntypedef INT16 FSERROR;\t\t/* 16 bits should be enough */\ntypedef int LOCFSERROR;\t\t/* use 'int' for calculation temps */\n#else\ntypedef INT32 FSERROR;\t\t/* may need more than 16 bits */\ntypedef INT32 LOCFSERROR;\t/* be sure calculation temps are big enough */\n#endif\n\ntypedef FSERROR FAR *FSERRPTR;\t/* pointer to error array (in FAR storage!) */\n\n\n/* Private subobject */\n\ntypedef struct {\n  struct jpeg_color_quantizer pub; /* public fields */\n\n  /* Space for the eventually created colormap is stashed here */\n  JSAMPARRAY sv_colormap;\t/* colormap allocated at init time */\n  int desired;\t\t\t/* desired # of colors = size of colormap */\n\n  /* Variables for accumulating image statistics */\n  hist3d histogram;\t\t/* pointer to the histogram */\n\n  boolean needs_zeroed;\t\t/* TRUE if next pass must zero histogram */\n\n  /* Variables for Floyd-Steinberg dithering */\n  FSERRPTR fserrors;\t\t/* accumulated errors */\n  boolean on_odd_row;\t\t/* flag to remember which row we are on */\n  int * error_limiter;\t\t/* table for clamping the applied error */\n} my_cquantizer;\n\ntypedef my_cquantizer * my_cquantize_ptr;\n\n\n/*\n * Prescan some rows of pixels.\n * In this module the prescan simply updates the histogram, which has been\n * initialized to zeroes by start_pass.\n * An output_buf parameter is required by the method signature, but no data\n * is actually output (in fact the buffer controller is probably passing a\n * NULL pointer).\n */\n\nMETHODDEF void\nprescan_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,\n\t\t  JSAMPARRAY output_buf, int num_rows)\n{\n  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;\n  register JSAMPROW ptr;\n  register histptr histp;\n  register hist3d histogram = cquantize->histogram;\n  int row;\n  JDIMENSION col;\n  JDIMENSION width = cinfo->output_width;\n\n  for (row = 0; row < num_rows; row++) {\n    ptr = input_buf[row];\n    for (col = width; col > 0; col--) {\n      /* get pixel value and index into the histogram */\n      histp = & histogram[GETJSAMPLE(ptr[0]) >> C0_SHIFT]\n\t\t\t [GETJSAMPLE(ptr[1]) >> C1_SHIFT]\n\t\t\t [GETJSAMPLE(ptr[2]) >> C2_SHIFT];\n      /* increment, check for overflow and undo increment if so. */\n      if (++(*histp) <= 0)\n\t(*histp)--;\n      ptr += 3;\n    }\n  }\n}\n\n\n/*\n * Next we have the really interesting routines: selection of a colormap\n * given the completed histogram.\n * These routines work with a list of \"boxes\", each representing a rectangular\n * subset of the input color space (to histogram precision).\n */\n\ntypedef struct {\n  /* The bounds of the box (inclusive); expressed as histogram indexes */\n  int c0min, c0max;\n  int c1min, c1max;\n  int c2min, c2max;\n  /* The volume (actually 2-norm) of the box */\n  INT32 volume;\n  /* The number of nonzero histogram cells within this box */\n  long colorcount;\n} box;\n\ntypedef box * boxptr;\n\n\nLOCAL boxptr\nfind_biggest_color_pop (boxptr boxlist, int numboxes)\n/* Find the splittable box with the largest color population */\n/* Returns NULL if no splittable boxes remain */\n{\n  register boxptr boxp;\n  register int i;\n  register long maxc = 0;\n  boxptr which = NULL;\n  \n  for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) {\n    if (boxp->colorcount > maxc && boxp->volume > 0) {\n      which = boxp;\n      maxc = boxp->colorcount;\n    }\n  }\n  return which;\n}\n\n\nLOCAL boxptr\nfind_biggest_volume (boxptr boxlist, int numboxes)\n/* Find the splittable box with the largest (scaled) volume */\n/* Returns NULL if no splittable boxes remain */\n{\n  register boxptr boxp;\n  register int i;\n  register INT32 maxv = 0;\n  boxptr which = NULL;\n  \n  for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) {\n    if (boxp->volume > maxv) {\n      which = boxp;\n      maxv = boxp->volume;\n    }\n  }\n  return which;\n}\n\n\nLOCAL void\nupdate_box (j_decompress_ptr cinfo, boxptr boxp)\n/* Shrink the min/max bounds of a box to enclose only nonzero elements, */\n/* and recompute its volume and population */\n{\n  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;\n  hist3d histogram = cquantize->histogram;\n  histptr histp;\n  int c0,c1,c2;\n  int c0min,c0max,c1min,c1max,c2min,c2max;\n  INT32 dist0,dist1,dist2;\n  long ccount;\n  \n  c0min = boxp->c0min;  c0max = boxp->c0max;\n  c1min = boxp->c1min;  c1max = boxp->c1max;\n  c2min = boxp->c2min;  c2max = boxp->c2max;\n  \n  if (c0max > c0min)\n    for (c0 = c0min; c0 <= c0max; c0++)\n      for (c1 = c1min; c1 <= c1max; c1++) {\n\thistp = & histogram[c0][c1][c2min];\n\tfor (c2 = c2min; c2 <= c2max; c2++)\n\t  if (*histp++ != 0) {\n\t    boxp->c0min = c0min = c0;\n\t    goto have_c0min;\n\t  }\n      }\n have_c0min:\n  if (c0max > c0min)\n    for (c0 = c0max; c0 >= c0min; c0--)\n      for (c1 = c1min; c1 <= c1max; c1++) {\n\thistp = & histogram[c0][c1][c2min];\n\tfor (c2 = c2min; c2 <= c2max; c2++)\n\t  if (*histp++ != 0) {\n\t    boxp->c0max = c0max = c0;\n\t    goto have_c0max;\n\t  }\n      }\n have_c0max:\n  if (c1max > c1min)\n    for (c1 = c1min; c1 <= c1max; c1++)\n      for (c0 = c0min; c0 <= c0max; c0++) {\n\thistp = & histogram[c0][c1][c2min];\n\tfor (c2 = c2min; c2 <= c2max; c2++)\n\t  if (*histp++ != 0) {\n\t    boxp->c1min = c1min = c1;\n\t    goto have_c1min;\n\t  }\n      }\n have_c1min:\n  if (c1max > c1min)\n    for (c1 = c1max; c1 >= c1min; c1--)\n      for (c0 = c0min; c0 <= c0max; c0++) {\n\thistp = & histogram[c0][c1][c2min];\n\tfor (c2 = c2min; c2 <= c2max; c2++)\n\t  if (*histp++ != 0) {\n\t    boxp->c1max = c1max = c1;\n\t    goto have_c1max;\n\t  }\n      }\n have_c1max:\n  if (c2max > c2min)\n    for (c2 = c2min; c2 <= c2max; c2++)\n      for (c0 = c0min; c0 <= c0max; c0++) {\n\thistp = & histogram[c0][c1min][c2];\n\tfor (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS)\n\t  if (*histp != 0) {\n\t    boxp->c2min = c2min = c2;\n\t    goto have_c2min;\n\t  }\n      }\n have_c2min:\n  if (c2max > c2min)\n    for (c2 = c2max; c2 >= c2min; c2--)\n      for (c0 = c0min; c0 <= c0max; c0++) {\n\thistp = & histogram[c0][c1min][c2];\n\tfor (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS)\n\t  if (*histp != 0) {\n\t    boxp->c2max = c2max = c2;\n\t    goto have_c2max;\n\t  }\n      }\n have_c2max:\n\n  /* Update box volume.\n   * We use 2-norm rather than real volume here; this biases the method\n   * against making long narrow boxes, and it has the side benefit that\n   * a box is splittable iff norm > 0.\n   * Since the differences are expressed in histogram-cell units,\n   * we have to shift back to JSAMPLE units to get consistent distances;\n   * after which, we scale according to the selected distance scale factors.\n   */\n  dist0 = ((c0max - c0min) << C0_SHIFT) * C0_SCALE;\n  dist1 = ((c1max - c1min) << C1_SHIFT) * C1_SCALE;\n  dist2 = ((c2max - c2min) << C2_SHIFT) * C2_SCALE;\n  boxp->volume = dist0*dist0 + dist1*dist1 + dist2*dist2;\n  \n  /* Now scan remaining volume of box and compute population */\n  ccount = 0;\n  for (c0 = c0min; c0 <= c0max; c0++)\n    for (c1 = c1min; c1 <= c1max; c1++) {\n      histp = & histogram[c0][c1][c2min];\n      for (c2 = c2min; c2 <= c2max; c2++, histp++)\n\tif (*histp != 0) {\n\t  ccount++;\n\t}\n    }\n  boxp->colorcount = ccount;\n}\n\n\nLOCAL int\nmedian_cut (j_decompress_ptr cinfo, boxptr boxlist, int numboxes,\n\t    int desired_colors)\n/* Repeatedly select and split the largest box until we have enough boxes */\n{\n  int n,lb;\n  int c0,c1,c2,cmax;\n  register boxptr b1,b2;\n\n  while (numboxes < desired_colors) {\n    /* Select box to split.\n     * Current algorithm: by population for first half, then by volume.\n     */\n    if (numboxes*2 <= desired_colors) {\n      b1 = find_biggest_color_pop(boxlist, numboxes);\n    } else {\n      b1 = find_biggest_volume(boxlist, numboxes);\n    }\n    if (b1 == NULL)\t\t/* no splittable boxes left! */\n      break;\n    b2 = &boxlist[numboxes];\t/* where new box will go */\n    /* Copy the color bounds to the new box. */\n    b2->c0max = b1->c0max; b2->c1max = b1->c1max; b2->c2max = b1->c2max;\n    b2->c0min = b1->c0min; b2->c1min = b1->c1min; b2->c2min = b1->c2min;\n    /* Choose which axis to split the box on.\n     * Current algorithm: longest scaled axis.\n     * See notes in update_box about scaling distances.\n     */\n    c0 = ((b1->c0max - b1->c0min) << C0_SHIFT) * C0_SCALE;\n    c1 = ((b1->c1max - b1->c1min) << C1_SHIFT) * C1_SCALE;\n    c2 = ((b1->c2max - b1->c2min) << C2_SHIFT) * C2_SCALE;\n    /* We want to break any ties in favor of green, then red, blue last.\n     * This code does the right thing for R,G,B or B,G,R color orders only.\n     */\n#if RGB_RED == 0\n    cmax = c1; n = 1;\n    if (c0 > cmax) { cmax = c0; n = 0; }\n    if (c2 > cmax) { n = 2; }\n#else\n    cmax = c1; n = 1;\n    if (c2 > cmax) { cmax = c2; n = 2; }\n    if (c0 > cmax) { n = 0; }\n#endif\n    /* Choose split point along selected axis, and update box bounds.\n     * Current algorithm: split at halfway point.\n     * (Since the box has been shrunk to minimum volume,\n     * any split will produce two nonempty subboxes.)\n     * Note that lb value is max for lower box, so must be < old max.\n     */\n    switch (n) {\n    case 0:\n      lb = (b1->c0max + b1->c0min) / 2;\n      b1->c0max = lb;\n      b2->c0min = lb+1;\n      break;\n    case 1:\n      lb = (b1->c1max + b1->c1min) / 2;\n      b1->c1max = lb;\n      b2->c1min = lb+1;\n      break;\n    case 2:\n      lb = (b1->c2max + b1->c2min) / 2;\n      b1->c2max = lb;\n      b2->c2min = lb+1;\n      break;\n    }\n    /* Update stats for boxes */\n    update_box(cinfo, b1);\n    update_box(cinfo, b2);\n    numboxes++;\n  }\n  return numboxes;\n}\n\n\nLOCAL void\ncompute_color (j_decompress_ptr cinfo, boxptr boxp, int icolor)\n/* Compute representative color for a box, put it in colormap[icolor] */\n{\n  /* Current algorithm: mean weighted by pixels (not colors) */\n  /* Note it is important to get the rounding correct! */\n  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;\n  hist3d histogram = cquantize->histogram;\n  histptr histp;\n  int c0,c1,c2;\n  int c0min,c0max,c1min,c1max,c2min,c2max;\n  long count;\n  long total = 0;\n  long c0total = 0;\n  long c1total = 0;\n  long c2total = 0;\n  \n  c0min = boxp->c0min;  c0max = boxp->c0max;\n  c1min = boxp->c1min;  c1max = boxp->c1max;\n  c2min = boxp->c2min;  c2max = boxp->c2max;\n  \n  for (c0 = c0min; c0 <= c0max; c0++)\n    for (c1 = c1min; c1 <= c1max; c1++) {\n      histp = & histogram[c0][c1][c2min];\n      for (c2 = c2min; c2 <= c2max; c2++) {\n\tif ((count = *histp++) != 0) {\n\t  total += count;\n\t  c0total += ((c0 << C0_SHIFT) + ((1<<C0_SHIFT)>>1)) * count;\n\t  c1total += ((c1 << C1_SHIFT) + ((1<<C1_SHIFT)>>1)) * count;\n\t  c2total += ((c2 << C2_SHIFT) + ((1<<C2_SHIFT)>>1)) * count;\n\t}\n      }\n    }\n  \n  cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total);\n  cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total);\n  cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total);\n}\n\n\nLOCAL void\nselect_colors (j_decompress_ptr cinfo, int desired_colors)\n/* Master routine for color selection */\n{\n  boxptr boxlist;\n  int numboxes;\n  int i;\n\n  /* Allocate workspace for box list */\n  boxlist = (boxptr) (*cinfo->mem->alloc_small)\n    ((j_common_ptr) cinfo, JPOOL_IMAGE, desired_colors * SIZEOF(box));\n  /* Initialize one box containing whole space */\n  numboxes = 1;\n  boxlist[0].c0min = 0;\n  boxlist[0].c0max = MAXJSAMPLE >> C0_SHIFT;\n  boxlist[0].c1min = 0;\n  boxlist[0].c1max = MAXJSAMPLE >> C1_SHIFT;\n  boxlist[0].c2min = 0;\n  boxlist[0].c2max = MAXJSAMPLE >> C2_SHIFT;\n  /* Shrink it to actually-used volume and set its statistics */\n  update_box(cinfo, & boxlist[0]);\n  /* Perform median-cut to produce final box list */\n  numboxes = median_cut(cinfo, boxlist, numboxes, desired_colors);\n  /* Compute the representative color for each box, fill colormap */\n  for (i = 0; i < numboxes; i++)\n    compute_color(cinfo, & boxlist[i], i);\n  cinfo->actual_number_of_colors = numboxes;\n  TRACEMS1(cinfo, 1, JTRC_QUANT_SELECTED, numboxes);\n}\n\n\n/*\n * These routines are concerned with the time-critical task of mapping input\n * colors to the nearest color in the selected colormap.\n *\n * We re-use the histogram space as an \"inverse color map\", essentially a\n * cache for the results of nearest-color searches.  All colors within a\n * histogram cell will be mapped to the same colormap entry, namely the one\n * closest to the cell's center.  This may not be quite the closest entry to\n * the actual input color, but it's almost as good.  A zero in the cache\n * indicates we haven't found the nearest color for that cell yet; the array\n * is cleared to zeroes before starting the mapping pass.  When we find the\n * nearest color for a cell, its colormap index plus one is recorded in the\n * cache for future use.  The pass2 scanning routines call fill_inverse_cmap\n * when they need to use an unfilled entry in the cache.\n *\n * Our method of efficiently finding nearest colors is based on the \"locally\n * sorted search\" idea described by Heckbert and on the incremental distance\n * calculation described by Spencer W. Thomas in chapter III.1 of Graphics\n * Gems II (James Arvo, ed.  Academic Press, 1991).  Thomas points out that\n * the distances from a given colormap entry to each cell of the histogram can\n * be computed quickly using an incremental method: the differences between\n * distances to adjacent cells themselves differ by a constant.  This allows a\n * fairly fast implementation of the \"brute force\" approach of computing the\n * distance from every colormap entry to every histogram cell.  Unfortunately,\n * it needs a work array to hold the best-distance-so-far for each histogram\n * cell (because the inner loop has to be over cells, not colormap entries).\n * The work array elements have to be INT32s, so the work array would need\n * 256Kb at our recommended precision.  This is not feasible in DOS machines.\n *\n * To get around these problems, we apply Thomas' method to compute the\n * nearest colors for only the cells within a small subbox of the histogram.\n * The work array need be only as big as the subbox, so the memory usage\n * problem is solved.  Furthermore, we need not fill subboxes that are never\n * referenced in pass2; many images use only part of the color gamut, so a\n * fair amount of work is saved.  An additional advantage of this\n * approach is that we can apply Heckbert's locality criterion to quickly\n * eliminate colormap entries that are far away from the subbox; typically\n * three-fourths of the colormap entries are rejected by Heckbert's criterion,\n * and we need not compute their distances to individual cells in the subbox.\n * The speed of this approach is heavily influenced by the subbox size: too\n * small means too much overhead, too big loses because Heckbert's criterion\n * can't eliminate as many colormap entries.  Empirically the best subbox\n * size seems to be about 1/512th of the histogram (1/8th in each direction).\n *\n * Thomas' article also describes a refined method which is asymptotically\n * faster than the brute-force method, but it is also far more complex and\n * cannot efficiently be applied to small subboxes.  It is therefore not\n * useful for programs intended to be portable to DOS machines.  On machines\n * with plenty of memory, filling the whole histogram in one shot with Thomas'\n * refined method might be faster than the present code --- but then again,\n * it might not be any faster, and it's certainly more complicated.\n */\n\n\n/* log2(histogram cells in update box) for each axis; this can be adjusted */\n#define BOX_C0_LOG  (HIST_C0_BITS-3)\n#define BOX_C1_LOG  (HIST_C1_BITS-3)\n#define BOX_C2_LOG  (HIST_C2_BITS-3)\n\n#define BOX_C0_ELEMS  (1<<BOX_C0_LOG) /* # of hist cells in update box */\n#define BOX_C1_ELEMS  (1<<BOX_C1_LOG)\n#define BOX_C2_ELEMS  (1<<BOX_C2_LOG)\n\n#define BOX_C0_SHIFT  (C0_SHIFT + BOX_C0_LOG)\n#define BOX_C1_SHIFT  (C1_SHIFT + BOX_C1_LOG)\n#define BOX_C2_SHIFT  (C2_SHIFT + BOX_C2_LOG)\n\n\n/*\n * The next three routines implement inverse colormap filling.  They could\n * all be folded into one big routine, but splitting them up this way saves\n * some stack space (the mindist[] and bestdist[] arrays need not coexist)\n * and may allow some compilers to produce better code by registerizing more\n * inner-loop variables.\n */\n\nLOCAL int\nfind_nearby_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,\n\t\t    JSAMPLE colorlist[])\n/* Locate the colormap entries close enough to an update box to be candidates\n * for the nearest entry to some cell(s) in the update box.  The update box\n * is specified by the center coordinates of its first cell.  The number of\n * candidate colormap entries is returned, and their colormap indexes are\n * placed in colorlist[].\n * This routine uses Heckbert's \"locally sorted search\" criterion to select\n * the colors that need further consideration.\n */\n{\n  int numcolors = cinfo->actual_number_of_colors;\n  int maxc0, maxc1, maxc2;\n  int centerc0, centerc1, centerc2;\n  int i, x, ncolors;\n  INT32 minmaxdist, min_dist, max_dist, tdist;\n  INT32 mindist[MAXNUMCOLORS];\t/* min distance to colormap entry i */\n\n  /* Compute true coordinates of update box's upper corner and center.\n   * Actually we compute the coordinates of the center of the upper-corner\n   * histogram cell, which are the upper bounds of the volume we care about.\n   * Note that since \">>\" rounds down, the \"center\" values may be closer to\n   * min than to max; hence comparisons to them must be \"<=\", not \"<\".\n   */\n  maxc0 = minc0 + ((1 << BOX_C0_SHIFT) - (1 << C0_SHIFT));\n  centerc0 = (minc0 + maxc0) >> 1;\n  maxc1 = minc1 + ((1 << BOX_C1_SHIFT) - (1 << C1_SHIFT));\n  centerc1 = (minc1 + maxc1) >> 1;\n  maxc2 = minc2 + ((1 << BOX_C2_SHIFT) - (1 << C2_SHIFT));\n  centerc2 = (minc2 + maxc2) >> 1;\n\n  /* For each color in colormap, find:\n   *  1. its minimum squared-distance to any point in the update box\n   *     (zero if color is within update box);\n   *  2. its maximum squared-distance to any point in the update box.\n   * Both of these can be found by considering only the corners of the box.\n   * We save the minimum distance for each color in mindist[];\n   * only the smallest maximum distance is of interest.\n   */\n  minmaxdist = 0x7FFFFFFFL;\n\n  for (i = 0; i < numcolors; i++) {\n    /* We compute the squared-c0-distance term, then add in the other two. */\n    x = GETJSAMPLE(cinfo->colormap[0][i]);\n    if (x < minc0) {\n      tdist = (x - minc0) * C0_SCALE;\n      min_dist = tdist*tdist;\n      tdist = (x - maxc0) * C0_SCALE;\n      max_dist = tdist*tdist;\n    } else if (x > maxc0) {\n      tdist = (x - maxc0) * C0_SCALE;\n      min_dist = tdist*tdist;\n      tdist = (x - minc0) * C0_SCALE;\n      max_dist = tdist*tdist;\n    } else {\n      /* within cell range so no contribution to min_dist */\n      min_dist = 0;\n      if (x <= centerc0) {\n\ttdist = (x - maxc0) * C0_SCALE;\n\tmax_dist = tdist*tdist;\n      } else {\n\ttdist = (x - minc0) * C0_SCALE;\n\tmax_dist = tdist*tdist;\n      }\n    }\n\n    x = GETJSAMPLE(cinfo->colormap[1][i]);\n    if (x < minc1) {\n      tdist = (x - minc1) * C1_SCALE;\n      min_dist += tdist*tdist;\n      tdist = (x - maxc1) * C1_SCALE;\n      max_dist += tdist*tdist;\n    } else if (x > maxc1) {\n      tdist = (x - maxc1) * C1_SCALE;\n      min_dist += tdist*tdist;\n      tdist = (x - minc1) * C1_SCALE;\n      max_dist += tdist*tdist;\n    } else {\n      /* within cell range so no contribution to min_dist */\n      if (x <= centerc1) {\n\ttdist = (x - maxc1) * C1_SCALE;\n\tmax_dist += tdist*tdist;\n      } else {\n\ttdist = (x - minc1) * C1_SCALE;\n\tmax_dist += tdist*tdist;\n      }\n    }\n\n    x = GETJSAMPLE(cinfo->colormap[2][i]);\n    if (x < minc2) {\n      tdist = (x - minc2) * C2_SCALE;\n      min_dist += tdist*tdist;\n      tdist = (x - maxc2) * C2_SCALE;\n      max_dist += tdist*tdist;\n    } else if (x > maxc2) {\n      tdist = (x - maxc2) * C2_SCALE;\n      min_dist += tdist*tdist;\n      tdist = (x - minc2) * C2_SCALE;\n      max_dist += tdist*tdist;\n    } else {\n      /* within cell range so no contribution to min_dist */\n      if (x <= centerc2) {\n\ttdist = (x - maxc2) * C2_SCALE;\n\tmax_dist += tdist*tdist;\n      } else {\n\ttdist = (x - minc2) * C2_SCALE;\n\tmax_dist += tdist*tdist;\n      }\n    }\n\n    mindist[i] = min_dist;\t/* save away the results */\n    if (max_dist < minmaxdist)\n      minmaxdist = max_dist;\n  }\n\n  /* Now we know that no cell in the update box is more than minmaxdist\n   * away from some colormap entry.  Therefore, only colors that are\n   * within minmaxdist of some part of the box need be considered.\n   */\n  ncolors = 0;\n  for (i = 0; i < numcolors; i++) {\n    if (mindist[i] <= minmaxdist)\n      colorlist[ncolors++] = (JSAMPLE) i;\n  }\n  return ncolors;\n}\n\n\nLOCAL void\nfind_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,\n\t\t  int numcolors, JSAMPLE colorlist[], JSAMPLE bestcolor[])\n/* Find the closest colormap entry for each cell in the update box,\n * given the list of candidate colors prepared by find_nearby_colors.\n * Return the indexes of the closest entries in the bestcolor[] array.\n * This routine uses Thomas' incremental distance calculation method to\n * find the distance from a colormap entry to successive cells in the box.\n */\n{\n  int ic0, ic1, ic2;\n  int i, icolor;\n  register INT32 * bptr;\t/* pointer into bestdist[] array */\n  JSAMPLE * cptr;\t\t/* pointer into bestcolor[] array */\n  INT32 dist0, dist1;\t\t/* initial distance values */\n  register INT32 dist2;\t\t/* current distance in inner loop */\n  INT32 xx0, xx1;\t\t/* distance increments */\n  register INT32 xx2;\n  INT32 inc0, inc1, inc2;\t/* initial values for increments */\n  /* This array holds the distance to the nearest-so-far color for each cell */\n  INT32 bestdist[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS];\n\n  /* Initialize best-distance for each cell of the update box */\n  bptr = bestdist;\n  for (i = BOX_C0_ELEMS*BOX_C1_ELEMS*BOX_C2_ELEMS-1; i >= 0; i--)\n    *bptr++ = 0x7FFFFFFFL;\n  \n  /* For each color selected by find_nearby_colors,\n   * compute its distance to the center of each cell in the box.\n   * If that's less than best-so-far, update best distance and color number.\n   */\n  \n  /* Nominal steps between cell centers (\"x\" in Thomas article) */\n#define STEP_C0  ((1 << C0_SHIFT) * C0_SCALE)\n#define STEP_C1  ((1 << C1_SHIFT) * C1_SCALE)\n#define STEP_C2  ((1 << C2_SHIFT) * C2_SCALE)\n  \n  for (i = 0; i < numcolors; i++) {\n    icolor = GETJSAMPLE(colorlist[i]);\n    /* Compute (square of) distance from minc0/c1/c2 to this color */\n    inc0 = (minc0 - GETJSAMPLE(cinfo->colormap[0][icolor])) * C0_SCALE;\n    dist0 = inc0*inc0;\n    inc1 = (minc1 - GETJSAMPLE(cinfo->colormap[1][icolor])) * C1_SCALE;\n    dist0 += inc1*inc1;\n    inc2 = (minc2 - GETJSAMPLE(cinfo->colormap[2][icolor])) * C2_SCALE;\n    dist0 += inc2*inc2;\n    /* Form the initial difference increments */\n    inc0 = inc0 * (2 * STEP_C0) + STEP_C0 * STEP_C0;\n    inc1 = inc1 * (2 * STEP_C1) + STEP_C1 * STEP_C1;\n    inc2 = inc2 * (2 * STEP_C2) + STEP_C2 * STEP_C2;\n    /* Now loop over all cells in box, updating distance per Thomas method */\n    bptr = bestdist;\n    cptr = bestcolor;\n    xx0 = inc0;\n    for (ic0 = BOX_C0_ELEMS-1; ic0 >= 0; ic0--) {\n      dist1 = dist0;\n      xx1 = inc1;\n      for (ic1 = BOX_C1_ELEMS-1; ic1 >= 0; ic1--) {\n\tdist2 = dist1;\n\txx2 = inc2;\n\tfor (ic2 = BOX_C2_ELEMS-1; ic2 >= 0; ic2--) {\n\t  if (dist2 < *bptr) {\n\t    *bptr = dist2;\n\t    *cptr = (JSAMPLE) icolor;\n\t  }\n\t  dist2 += xx2;\n\t  xx2 += 2 * STEP_C2 * STEP_C2;\n\t  bptr++;\n\t  cptr++;\n\t}\n\tdist1 += xx1;\n\txx1 += 2 * STEP_C1 * STEP_C1;\n      }\n      dist0 += xx0;\n      xx0 += 2 * STEP_C0 * STEP_C0;\n    }\n  }\n}\n\n\nLOCAL void\nfill_inverse_cmap (j_decompress_ptr cinfo, int c0, int c1, int c2)\n/* Fill the inverse-colormap entries in the update box that contains */\n/* histogram cell c0/c1/c2.  (Only that one cell MUST be filled, but */\n/* we can fill as many others as we wish.) */\n{\n  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;\n  hist3d histogram = cquantize->histogram;\n  int minc0, minc1, minc2;\t/* lower left corner of update box */\n  int ic0, ic1, ic2;\n  register JSAMPLE * cptr;\t/* pointer into bestcolor[] array */\n  register histptr cachep;\t/* pointer into main cache array */\n  /* This array lists the candidate colormap indexes. */\n  JSAMPLE colorlist[MAXNUMCOLORS];\n  int numcolors;\t\t/* number of candidate colors */\n  /* This array holds the actually closest colormap index for each cell. */\n  JSAMPLE bestcolor[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS];\n\n  /* Convert cell coordinates to update box ID */\n  c0 >>= BOX_C0_LOG;\n  c1 >>= BOX_C1_LOG;\n  c2 >>= BOX_C2_LOG;\n\n  /* Compute true coordinates of update box's origin corner.\n   * Actually we compute the coordinates of the center of the corner\n   * histogram cell, which are the lower bounds of the volume we care about.\n   */\n  minc0 = (c0 << BOX_C0_SHIFT) + ((1 << C0_SHIFT) >> 1);\n  minc1 = (c1 << BOX_C1_SHIFT) + ((1 << C1_SHIFT) >> 1);\n  minc2 = (c2 << BOX_C2_SHIFT) + ((1 << C2_SHIFT) >> 1);\n  \n  /* Determine which colormap entries are close enough to be candidates\n   * for the nearest entry to some cell in the update box.\n   */\n  numcolors = find_nearby_colors(cinfo, minc0, minc1, minc2, colorlist);\n\n  /* Determine the actually nearest colors. */\n  find_best_colors(cinfo, minc0, minc1, minc2, numcolors, colorlist,\n\t\t   bestcolor);\n\n  /* Save the best color numbers (plus 1) in the main cache array */\n  c0 <<= BOX_C0_LOG;\t\t/* convert ID back to base cell indexes */\n  c1 <<= BOX_C1_LOG;\n  c2 <<= BOX_C2_LOG;\n  cptr = bestcolor;\n  for (ic0 = 0; ic0 < BOX_C0_ELEMS; ic0++) {\n    for (ic1 = 0; ic1 < BOX_C1_ELEMS; ic1++) {\n      cachep = & histogram[c0+ic0][c1+ic1][c2];\n      for (ic2 = 0; ic2 < BOX_C2_ELEMS; ic2++) {\n\t*cachep++ = (histcell) (GETJSAMPLE(*cptr++) + 1);\n      }\n    }\n  }\n}\n\n\n/*\n * Map some rows of pixels to the output colormapped representation.\n */\n\nMETHODDEF void\npass2_no_dither (j_decompress_ptr cinfo,\n\t\t JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows)\n/* This version performs no dithering */\n{\n  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;\n  hist3d histogram = cquantize->histogram;\n  register JSAMPROW inptr, outptr;\n  register histptr cachep;\n  register int c0, c1, c2;\n  int row;\n  JDIMENSION col;\n  JDIMENSION width = cinfo->output_width;\n\n  for (row = 0; row < num_rows; row++) {\n    inptr = input_buf[row];\n    outptr = output_buf[row];\n    for (col = width; col > 0; col--) {\n      /* get pixel value and index into the cache */\n      c0 = GETJSAMPLE(*inptr++) >> C0_SHIFT;\n      c1 = GETJSAMPLE(*inptr++) >> C1_SHIFT;\n      c2 = GETJSAMPLE(*inptr++) >> C2_SHIFT;\n      cachep = & histogram[c0][c1][c2];\n      /* If we have not seen this color before, find nearest colormap entry */\n      /* and update the cache */\n      if (*cachep == 0)\n\tfill_inverse_cmap(cinfo, c0,c1,c2);\n      /* Now emit the colormap index for this cell */\n      *outptr++ = (JSAMPLE) (*cachep - 1);\n    }\n  }\n}\n\n\nMETHODDEF void\npass2_fs_dither (j_decompress_ptr cinfo,\n\t\t JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows)\n/* This version performs Floyd-Steinberg dithering */\n{\n  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;\n  hist3d histogram = cquantize->histogram;\n  register LOCFSERROR cur0, cur1, cur2;\t/* current error or pixel value */\n  LOCFSERROR belowerr0, belowerr1, belowerr2; /* error for pixel below cur */\n  LOCFSERROR bpreverr0, bpreverr1, bpreverr2; /* error for below/prev col */\n  register FSERRPTR errorptr;\t/* => fserrors[] at column before current */\n  JSAMPROW inptr;\t\t/* => current input pixel */\n  JSAMPROW outptr;\t\t/* => current output pixel */\n  histptr cachep;\n  int dir;\t\t\t/* +1 or -1 depending on direction */\n  int dir3;\t\t\t/* 3*dir, for advancing inptr & errorptr */\n  int row;\n  JDIMENSION col;\n  JDIMENSION width = cinfo->output_width;\n  JSAMPLE *range_limit = cinfo->sample_range_limit;\n  int *error_limit = cquantize->error_limiter;\n  JSAMPROW colormap0 = cinfo->colormap[0];\n  JSAMPROW colormap1 = cinfo->colormap[1];\n  JSAMPROW colormap2 = cinfo->colormap[2];\n  SHIFT_TEMPS\n\n  for (row = 0; row < num_rows; row++) {\n    inptr = input_buf[row];\n    outptr = output_buf[row];\n    if (cquantize->on_odd_row) {\n      /* work right to left in this row */\n      inptr += (width-1) * 3;\t/* so point to rightmost pixel */\n      outptr += width-1;\n      dir = -1;\n      dir3 = -3;\n      errorptr = cquantize->fserrors + (width+1)*3; /* => entry after last column */\n      cquantize->on_odd_row = FALSE; /* flip for next time */\n    } else {\n      /* work left to right in this row */\n      dir = 1;\n      dir3 = 3;\n      errorptr = cquantize->fserrors; /* => entry before first real column */\n      cquantize->on_odd_row = TRUE; /* flip for next time */\n    }\n    /* Preset error values: no error propagated to first pixel from left */\n    cur0 = cur1 = cur2 = 0;\n    /* and no error propagated to row below yet */\n    belowerr0 = belowerr1 = belowerr2 = 0;\n    bpreverr0 = bpreverr1 = bpreverr2 = 0;\n\n    for (col = width; col > 0; col--) {\n      /* curN holds the error propagated from the previous pixel on the\n       * current line.  Add the error propagated from the previous line\n       * to form the complete error correction term for this pixel, and\n       * round the error term (which is expressed * 16) to an integer.\n       * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct\n       * for either sign of the error value.\n       * Note: errorptr points to *previous* column's array entry.\n       */\n      cur0 = RIGHT_SHIFT(cur0 + errorptr[dir3+0] + 8, 4);\n      cur1 = RIGHT_SHIFT(cur1 + errorptr[dir3+1] + 8, 4);\n      cur2 = RIGHT_SHIFT(cur2 + errorptr[dir3+2] + 8, 4);\n      /* Limit the error using transfer function set by init_error_limit.\n       * See comments with init_error_limit for rationale.\n       */\n      cur0 = error_limit[cur0];\n      cur1 = error_limit[cur1];\n      cur2 = error_limit[cur2];\n      /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE.\n       * The maximum error is +- MAXJSAMPLE (or less with error limiting);\n       * this sets the required size of the range_limit array.\n       */\n      cur0 += GETJSAMPLE(inptr[0]);\n      cur1 += GETJSAMPLE(inptr[1]);\n      cur2 += GETJSAMPLE(inptr[2]);\n      cur0 = GETJSAMPLE(range_limit[cur0]);\n      cur1 = GETJSAMPLE(range_limit[cur1]);\n      cur2 = GETJSAMPLE(range_limit[cur2]);\n      /* Index into the cache with adjusted pixel value */\n      cachep = & histogram[cur0>>C0_SHIFT][cur1>>C1_SHIFT][cur2>>C2_SHIFT];\n      /* If we have not seen this color before, find nearest colormap */\n      /* entry and update the cache */\n      if (*cachep == 0)\n\tfill_inverse_cmap(cinfo, cur0>>C0_SHIFT,cur1>>C1_SHIFT,cur2>>C2_SHIFT);\n      /* Now emit the colormap index for this cell */\n      { register int pixcode = *cachep - 1;\n\t*outptr = (JSAMPLE) pixcode;\n\t/* Compute representation error for this pixel */\n\tcur0 -= GETJSAMPLE(colormap0[pixcode]);\n\tcur1 -= GETJSAMPLE(colormap1[pixcode]);\n\tcur2 -= GETJSAMPLE(colormap2[pixcode]);\n      }\n      /* Compute error fractions to be propagated to adjacent pixels.\n       * Add these into the running sums, and simultaneously shift the\n       * next-line error sums left by 1 column.\n       */\n      { register LOCFSERROR bnexterr, delta;\n\n\tbnexterr = cur0;\t/* Process component 0 */\n\tdelta = cur0 * 2;\n\tcur0 += delta;\t\t/* form error * 3 */\n\terrorptr[0] = (FSERROR) (bpreverr0 + cur0);\n\tcur0 += delta;\t\t/* form error * 5 */\n\tbpreverr0 = belowerr0 + cur0;\n\tbelowerr0 = bnexterr;\n\tcur0 += delta;\t\t/* form error * 7 */\n\tbnexterr = cur1;\t/* Process component 1 */\n\tdelta = cur1 * 2;\n\tcur1 += delta;\t\t/* form error * 3 */\n\terrorptr[1] = (FSERROR) (bpreverr1 + cur1);\n\tcur1 += delta;\t\t/* form error * 5 */\n\tbpreverr1 = belowerr1 + cur1;\n\tbelowerr1 = bnexterr;\n\tcur1 += delta;\t\t/* form error * 7 */\n\tbnexterr = cur2;\t/* Process component 2 */\n\tdelta = cur2 * 2;\n\tcur2 += delta;\t\t/* form error * 3 */\n\terrorptr[2] = (FSERROR) (bpreverr2 + cur2);\n\tcur2 += delta;\t\t/* form error * 5 */\n\tbpreverr2 = belowerr2 + cur2;\n\tbelowerr2 = bnexterr;\n\tcur2 += delta;\t\t/* form error * 7 */\n      }\n      /* At this point curN contains the 7/16 error value to be propagated\n       * to the next pixel on the current line, and all the errors for the\n       * next line have been shifted over.  We are therefore ready to move on.\n       */\n      inptr += dir3;\t\t/* Advance pixel pointers to next column */\n      outptr += dir;\n      errorptr += dir3;\t\t/* advance errorptr to current column */\n    }\n    /* Post-loop cleanup: we must unload the final error values into the\n     * final fserrors[] entry.  Note we need not unload belowerrN because\n     * it is for the dummy column before or after the actual array.\n     */\n    errorptr[0] = (FSERROR) bpreverr0; /* unload prev errs into array */\n    errorptr[1] = (FSERROR) bpreverr1;\n    errorptr[2] = (FSERROR) bpreverr2;\n  }\n}\n\n\n/*\n * Initialize the error-limiting transfer function (lookup table).\n * The raw F-S error computation can potentially compute error values of up to\n * +- MAXJSAMPLE.  But we want the maximum correction applied to a pixel to be\n * much less, otherwise obviously wrong pixels will be created.  (Typical\n * effects include weird fringes at color-area boundaries, isolated bright\n * pixels in a dark area, etc.)  The standard advice for avoiding this problem\n * is to ensure that the \"corners\" of the color cube are allocated as output\n * colors; then repeated errors in the same direction cannot cause cascading\n * error buildup.  However, that only prevents the error from getting\n * completely out of hand; Aaron Giles reports that error limiting improves\n * the results even with corner colors allocated.\n * A simple clamping of the error values to about +- MAXJSAMPLE/8 works pretty\n * well, but the smoother transfer function used below is even better.  Thanks\n * to Aaron Giles for this idea.\n */\n\nLOCAL void\ninit_error_limit (j_decompress_ptr cinfo)\n/* Allocate and fill in the error_limiter table */\n{\n  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;\n  int * table;\n  int in, out;\n\n  table = (int *) (*cinfo->mem->alloc_small)\n    ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE*2+1) * SIZEOF(int));\n  table += MAXJSAMPLE;\t\t/* so can index -MAXJSAMPLE .. +MAXJSAMPLE */\n  cquantize->error_limiter = table;\n\n#define STEPSIZE ((MAXJSAMPLE+1)/16)\n  /* Map errors 1:1 up to +- MAXJSAMPLE/16 */\n  out = 0;\n  for (in = 0; in < STEPSIZE; in++, out++) {\n    table[in] = out; table[-in] = -out;\n  }\n  /* Map errors 1:2 up to +- 3*MAXJSAMPLE/16 */\n  for (; in < STEPSIZE*3; in++, out += (in&1) ? 0 : 1) {\n    table[in] = out; table[-in] = -out;\n  }\n  /* Clamp the rest to final out value (which is (MAXJSAMPLE+1)/8) */\n  for (; in <= MAXJSAMPLE; in++) {\n    table[in] = out; table[-in] = -out;\n  }\n#undef STEPSIZE\n}\n\n\n/*\n * Finish up at the end of each pass.\n */\n\nMETHODDEF void\nfinish_pass1 (j_decompress_ptr cinfo)\n{\n  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;\n\n  /* Select the representative colors and fill in cinfo->colormap */\n  cinfo->colormap = cquantize->sv_colormap;\n  select_colors(cinfo, cquantize->desired);\n  /* Force next pass to zero the color index table */\n  cquantize->needs_zeroed = TRUE;\n}\n\n\nMETHODDEF void\nfinish_pass2 (j_decompress_ptr cinfo)\n{\n  /* no work */\n}\n\n\n/*\n * Initialize for each processing pass.\n */\n\nMETHODDEF void\nstart_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan)\n{\n  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;\n  hist3d histogram = cquantize->histogram;\n  int i;\n\n  /* Only F-S dithering or no dithering is supported. */\n  /* If user asks for ordered dither, give him F-S. */\n  if (cinfo->dither_mode != JDITHER_NONE)\n    cinfo->dither_mode = JDITHER_FS;\n\n  if (is_pre_scan) {\n    /* Set up method pointers */\n    cquantize->pub.color_quantize = prescan_quantize;\n    cquantize->pub.finish_pass = finish_pass1;\n    cquantize->needs_zeroed = TRUE; /* Always zero histogram */\n  } else {\n    /* Set up method pointers */\n    if (cinfo->dither_mode == JDITHER_FS)\n      cquantize->pub.color_quantize = pass2_fs_dither;\n    else\n      cquantize->pub.color_quantize = pass2_no_dither;\n    cquantize->pub.finish_pass = finish_pass2;\n\n    /* Make sure color count is acceptable */\n    i = cinfo->actual_number_of_colors;\n    if (i < 1)\n      ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, 1);\n    if (i > MAXNUMCOLORS)\n      ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS);\n\n    if (cinfo->dither_mode == JDITHER_FS) {\n      size_t arraysize = (size_t) ((cinfo->output_width + 2) *\n\t\t\t\t   (3 * SIZEOF(FSERROR)));\n      /* Allocate Floyd-Steinberg workspace if we didn't already. */\n      if (cquantize->fserrors == NULL)\n\tcquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large)\n\t  ((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize);\n      /* Initialize the propagated errors to zero. */\n      jzero_far((void FAR *) cquantize->fserrors, arraysize);\n      /* Make the error-limit table if we didn't already. */\n      if (cquantize->error_limiter == NULL)\n\tinit_error_limit(cinfo);\n      cquantize->on_odd_row = FALSE;\n    }\n\n  }\n  /* Zero the histogram or inverse color map, if necessary */\n  if (cquantize->needs_zeroed) {\n    for (i = 0; i < HIST_C0_ELEMS; i++) {\n      jzero_far((void FAR *) histogram[i],\n\t\tHIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell));\n    }\n    cquantize->needs_zeroed = FALSE;\n  }\n}\n\n\n/*\n * Switch to a new external colormap between output passes.\n */\n\nMETHODDEF void\nnew_color_map_2_quant (j_decompress_ptr cinfo)\n{\n  my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;\n\n  /* Reset the inverse color map */\n  cquantize->needs_zeroed = TRUE;\n}\n\n\n/*\n * Module initialization routine for 2-pass color quantization.\n */\n\nGLOBAL void\njinit_2pass_quantizer (j_decompress_ptr cinfo)\n{\n  my_cquantize_ptr cquantize;\n  int i;\n\n  cquantize = (my_cquantize_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_cquantizer));\n  cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize;\n  cquantize->pub.start_pass = start_pass_2_quant;\n  cquantize->pub.new_color_map = new_color_map_2_quant;\n  cquantize->fserrors = NULL;\t/* flag optional arrays not allocated */\n  cquantize->error_limiter = NULL;\n\n  /* Make sure jdmaster didn't give me a case I can't handle */\n  if (cinfo->out_color_components != 3)\n    ERREXIT(cinfo, JERR_NOTIMPL);\n\n  /* Allocate the histogram/inverse colormap storage */\n  cquantize->histogram = (hist3d) (*cinfo->mem->alloc_small)\n    ((j_common_ptr) cinfo, JPOOL_IMAGE, HIST_C0_ELEMS * SIZEOF(hist2d));\n  for (i = 0; i < HIST_C0_ELEMS; i++) {\n    cquantize->histogram[i] = (hist2d) (*cinfo->mem->alloc_large)\n      ((j_common_ptr) cinfo, JPOOL_IMAGE,\n       HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell));\n  }\n  cquantize->needs_zeroed = TRUE; /* histogram is garbage now */\n\n  /* Allocate storage for the completed colormap, if required.\n   * We do this now since it is FAR storage and may affect\n   * the memory manager's space calculations.\n   */\n  if (cinfo->enable_2pass_quant) {\n    /* Make sure color count is acceptable */\n    int desired = cinfo->desired_number_of_colors;\n    /* Lower bound on # of colors ... somewhat arbitrary as long as > 0 */\n    if (desired < 8)\n      ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, 8);\n    /* Make sure colormap indexes can be represented by JSAMPLEs */\n    if (desired > MAXNUMCOLORS)\n      ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS);\n    cquantize->sv_colormap = (*cinfo->mem->alloc_sarray)\n      ((j_common_ptr) cinfo,JPOOL_IMAGE, (JDIMENSION) desired, (JDIMENSION) 3);\n    cquantize->desired = desired;\n  } else\n    cquantize->sv_colormap = NULL;\n\n  /* Only F-S dithering or no dithering is supported. */\n  /* If user asks for ordered dither, give him F-S. */\n  if (cinfo->dither_mode != JDITHER_NONE)\n    cinfo->dither_mode = JDITHER_FS;\n\n  /* Allocate Floyd-Steinberg workspace if necessary.\n   * This isn't really needed until pass 2, but again it is FAR storage.\n   * Although we will cope with a later change in dither_mode,\n   * we do not promise to honor max_memory_to_use if dither_mode changes.\n   */\n  if (cinfo->dither_mode == JDITHER_FS) {\n    cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large)\n      ((j_common_ptr) cinfo, JPOOL_IMAGE,\n       (size_t) ((cinfo->output_width + 2) * (3 * SIZEOF(FSERROR))));\n    /* Might as well create the error-limiting table too. */\n    init_error_limit(cinfo);\n  }\n}\n\n#endif /* QUANT_2PASS_SUPPORTED */\n"
  },
  {
    "path": "code/jpeg-6/jutils.c",
    "content": "/*\n * jutils.c\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains tables and miscellaneous utility routines needed\n * for both compression and decompression.\n * Note we prefix all global names with \"j\" to minimize conflicts with\n * a surrounding application.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/*\n * jpeg_zigzag_order[i] is the zigzag-order position of the i'th element\n * of a DCT block read in natural order (left to right, top to bottom).\n */\n\nconst int jpeg_zigzag_order[DCTSIZE2] = {\n   0,  1,  5,  6, 14, 15, 27, 28,\n   2,  4,  7, 13, 16, 26, 29, 42,\n   3,  8, 12, 17, 25, 30, 41, 43,\n   9, 11, 18, 24, 31, 40, 44, 53,\n  10, 19, 23, 32, 39, 45, 52, 54,\n  20, 22, 33, 38, 46, 51, 55, 60,\n  21, 34, 37, 47, 50, 56, 59, 61,\n  35, 36, 48, 49, 57, 58, 62, 63\n};\n\n/*\n * jpeg_natural_order[i] is the natural-order position of the i'th element\n * of zigzag order.\n *\n * When reading corrupted data, the Huffman decoders could attempt\n * to reference an entry beyond the end of this array (if the decoded\n * zero run length reaches past the end of the block).  To prevent\n * wild stores without adding an inner-loop test, we put some extra\n * \"63\"s after the real entries.  This will cause the extra coefficient\n * to be stored in location 63 of the block, not somewhere random.\n * The worst case would be a run-length of 15, which means we need 16\n * fake entries.\n */\n\nconst int jpeg_natural_order[DCTSIZE2+16] = {\n  0,  1,  8, 16,  9,  2,  3, 10,\n 17, 24, 32, 25, 18, 11,  4,  5,\n 12, 19, 26, 33, 40, 48, 41, 34,\n 27, 20, 13,  6,  7, 14, 21, 28,\n 35, 42, 49, 56, 57, 50, 43, 36,\n 29, 22, 15, 23, 30, 37, 44, 51,\n 58, 59, 52, 45, 38, 31, 39, 46,\n 53, 60, 61, 54, 47, 55, 62, 63,\n 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */\n 63, 63, 63, 63, 63, 63, 63, 63\n};\n\n\n/*\n * Arithmetic utilities\n */\n\nGLOBAL long\njdiv_round_up (long a, long b)\n/* Compute a/b rounded up to next integer, ie, ceil(a/b) */\n/* Assumes a >= 0, b > 0 */\n{\n  return (a + b - 1L) / b;\n}\n\n\nGLOBAL long\njround_up (long a, long b)\n/* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */\n/* Assumes a >= 0, b > 0 */\n{\n  a += b - 1L;\n  return a - (a % b);\n}\n\n\n/* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays\n * and coefficient-block arrays.  This won't work on 80x86 because the arrays\n * are FAR and we're assuming a small-pointer memory model.  However, some\n * DOS compilers provide far-pointer versions of memcpy() and memset() even\n * in the small-model libraries.  These will be used if USE_FMEM is defined.\n * Otherwise, the routines below do it the hard way.  (The performance cost\n * is not all that great, because these routines aren't very heavily used.)\n */\n\n#ifndef NEED_FAR_POINTERS\t/* normal case, same as regular macros */\n#define FMEMCOPY(dest,src,size)\tMEMCOPY(dest,src,size)\n#define FMEMZERO(target,size)\tMEMZERO(target,size)\n#else\t\t\t\t/* 80x86 case, define if we can */\n#ifdef USE_FMEM\n#define FMEMCOPY(dest,src,size)\t_fmemcpy((void FAR *)(dest), (const void FAR *)(src), (size_t)(size))\n#define FMEMZERO(target,size)\t_fmemset((void FAR *)(target), 0, (size_t)(size))\n#endif\n#endif\n\n\nGLOBAL void\njcopy_sample_rows (JSAMPARRAY input_array, int source_row,\n\t\t   JSAMPARRAY output_array, int dest_row,\n\t\t   int num_rows, JDIMENSION num_cols)\n/* Copy some rows of samples from one place to another.\n * num_rows rows are copied from input_array[source_row++]\n * to output_array[dest_row++]; these areas may overlap for duplication.\n * The source and destination arrays must be at least as wide as num_cols.\n */\n{\n  register JSAMPROW inptr, outptr;\n#ifdef FMEMCOPY\n  register size_t count = (size_t) (num_cols * SIZEOF(JSAMPLE));\n#else\n  register JDIMENSION count;\n#endif\n  register int row;\n\n  input_array += source_row;\n  output_array += dest_row;\n\n  for (row = num_rows; row > 0; row--) {\n    inptr = *input_array++;\n    outptr = *output_array++;\n#ifdef FMEMCOPY\n    FMEMCOPY(outptr, inptr, count);\n#else\n    for (count = num_cols; count > 0; count--)\n      *outptr++ = *inptr++;\t/* needn't bother with GETJSAMPLE() here */\n#endif\n  }\n}\n\n\nGLOBAL void\njcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row,\n\t\t JDIMENSION num_blocks)\n/* Copy a row of coefficient blocks from one place to another. */\n{\n#ifdef FMEMCOPY\n  FMEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF)));\n#else\n  register JCOEFPTR inptr, outptr;\n  register long count;\n\n  inptr = (JCOEFPTR) input_row;\n  outptr = (JCOEFPTR) output_row;\n  for (count = (long) num_blocks * DCTSIZE2; count > 0; count--) {\n    *outptr++ = *inptr++;\n  }\n#endif\n}\n\n\nGLOBAL void\njzero_far (void FAR * target, size_t bytestozero)\n/* Zero out a chunk of FAR memory. */\n/* This might be sample-array data, block-array data, or alloc_large data. */\n{\n#ifdef FMEMZERO\n  FMEMZERO(target, bytestozero);\n#else\n  register char FAR * ptr = (char FAR *) target;\n  register size_t count;\n\n  for (count = bytestozero; count > 0; count--) {\n    *ptr++ = 0;\n  }\n#endif\n}\n"
  },
  {
    "path": "code/jpeg-6/jversion.h",
    "content": "/*\n * jversion.h\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains software version identification.\n */\n\n\n#define JVERSION\t\"6  2-Aug-95\"\n\n#define JCOPYRIGHT\t\"Copyright (C) 1995, Thomas G. Lane\"\n"
  },
  {
    "path": "code/macosx/BuildRelease",
    "content": "#!/bin/zsh\n\nAPPNAME=\"Quake3\"\nPACKAGENAME= Quake3\n\n(cd $OMNI_SOURCE_ROOT; ./Build Quake3 install)\n\nrm -rf \"/tmp/$APPNAME\"\nmkdir \"/tmp/$APPNAME\"\ncp \"Read Me.rtf\" \"/tmp/$APPNAME\"\n\ncd /Users/Shared/$USER/InstalledProducts\ngnutar cf - FAKK2.app | (cd \"/tmp/$APPNAME\"; gnutar xf -)\n\ncd \"/tmp/$APPNAME\"\nsudo ~bungi/Unix/bin/files2image $PACKAGENAME ./*\n\n"
  },
  {
    "path": "code/macosx/CGMouseDeltaFix.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#import <ApplicationServices/ApplicationServices.h>\n\nextern void CGFix_Initialize();\n\nextern void CGFix_GetLastMouseDelta(CGMouseDelta *dx, CGMouseDelta *dy);\n\n"
  },
  {
    "path": "code/macosx/CGMouseDeltaFix.m",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#import \"CGMouseDeltaFix.h\"\n#import \"CGPrivateAPI.h\"\n\n#import <Foundation/Foundation.h>\n#import <mach-o/dyld.h>\n\n\n// We will try to automatically fall back to using the original CGGetLastMouseDelta when we are on a system new enough to have the fix.  Any version of CoreGraphics past 1.93.0 will have the fixed version.\n\n\nstatic BOOL originalVersionShouldWork = YES;\nstatic CGMouseDelta CGFix_Mouse_DeltaX, CGFix_Mouse_DeltaY;\n\nstatic void CGFix_NotificationCallback(CGSNotificationType note, CGSNotificationData data, CGSByteCount dataLength, CGSNotificationArg arg);\n\nstatic CGSRegisterNotifyProcType registerNotifyProc = NULL;\n\nvoid CGFix_Initialize()\n{\n    NSAutoreleasePool *pool;\n    NSBundle *cgBundle;\n    NSString *version;\n    NSArray *components;\n    \n    if (registerNotifyProc)\n        // We've already been called once and have registered our callbacks.  If the original version works, this will be NULL, but we'll end up doing nothing (again, possibly).\n        return;\n\n    //NSLog(@\"CGFix_Initialize\\n\");\n        \n    pool = [[NSAutoreleasePool alloc] init];\n    cgBundle = [NSBundle bundleWithPath: @\"/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework\"];\n    if (!cgBundle) {\n        // If it's moved, it must be newer than what we know about and should work\n        //NSLog(@\"No /System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework\\n\");\n        goto done;\n    }\n    \n    version = [[cgBundle infoDictionary] objectForKey: @\"CFBundleShortVersionString\"];\n    components = [version componentsSeparatedByString: @\".\"];\n    //NSLog(@\"version = %@\\n\", version);\n    //NSLog(@\"components = %@\\n\", components);\n\n\n    if ([components count] < 2)\n        // We don't understand this versioning scheme.  Must have changed.\n        goto done;\n    \n    if (![[components objectAtIndex: 0] isEqualToString: @\"1\"] || [[components objectAtIndex: 1] intValue] > 93)\n        // This version should be new enough to work\n        goto done;\n    \n    // Look up the function pointer we need to register our callback.\n    if (!NSIsSymbolNameDefined(\"_CGSRegisterNotifyProc\")) {\n        //NSLog(@\"No _CGSRegisterNotifyProc\\n\");\n        goto done;\n    }\n    \n    registerNotifyProc = NSAddressOfSymbol(NSLookupAndBindSymbol(\"_CGSRegisterNotifyProc\"));\n    //NSLog(@\"registerNotifyProc = 0x%08x\", registerNotifyProc);\n\n    // Must not work if we got here\n    originalVersionShouldWork = NO;\n    \n    // We want to catch all the events that could possible indicate mouse movement and sum them up\n    registerNotifyProc( CGFix_NotificationCallback, kCGSEventNotificationMouseMoved, NULL);\n    registerNotifyProc( CGFix_NotificationCallback, kCGSEventNotificationLeftMouseDragged, NULL);\n    registerNotifyProc( CGFix_NotificationCallback, kCGSEventNotificationRightMouseDragged, NULL);\n    registerNotifyProc( CGFix_NotificationCallback, kCGSEventNotificationNotificationOtherMouseDragged, NULL);\n    \ndone:\n    [pool release];\n}\n\nvoid CGFix_GetLastMouseDelta(CGMouseDelta *dx, CGMouseDelta *dy)\n{\n    if (originalVersionShouldWork) {\n        CGGetLastMouseDelta(dx, dy);\n        return;\n    }\n    \n    *dx = CGFix_Mouse_DeltaX;\n    *dy = CGFix_Mouse_DeltaY;\n    \n    CGFix_Mouse_DeltaX = CGFix_Mouse_DeltaY = 0;\n}\n\nstatic void CGFix_NotificationCallback(CGSNotificationType note, CGSNotificationData data, CGSByteCount dataLength, CGSNotificationArg arg)\n{\n    CGSEventRecordPtr event;\n\n    //fprintf(stderr, \"CGFix_NotificationCallback(note=%d, date=0x%08x, dataLength=%d, arg=0x%08x)\\n\", note, data, dataLength, arg);\n    \n#ifdef DEBUG\n    if ((note != kCGSEventNotificationMouseMoved && \n         note != kCGSEventNotificationLeftMouseDragged &&\n         note != kCGSEventNotificationRightMouseDragged &&\n         note != kCGSEventNotificationNotificationOtherMouseDragged) ||\n         dataLength != sizeof (CGSEventRecord))\n         fprintf(stderr, \"Unexpected arguments to callback function CGFix_NotificationCallback(note=%d, date=0x%08x, dataLength=%d, arg=0x%08x)\\n\", note, data, dataLength, arg);\n         abort();\n    }\n#endif\n\n    event = (CGSEventRecordPtr)data;\n\n    CGFix_Mouse_DeltaX += event->data.move.deltaX;\n    CGFix_Mouse_DeltaY += event->data.move.deltaY;\n    //fprintf(stderr, \"  dx += %d, dy += %d\\n\", event->data.move.deltaX, event->data.move.deltaY);\n}\n"
  },
  {
    "path": "code/macosx/CGPrivateAPI.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n\ntypedef unsigned long CGSNotificationType;\ntypedef void * CGSNotificationData;\ntypedef void * CGSNotificationArg;\ntypedef void * CGSWindowID;\ntypedef void * CGSConnectionID;\n\ntypedef unsigned long long      CGSUInt64;\ntypedef long long               CGSInt64;\ntypedef unsigned long           CGSUInt32;\ntypedef long                    CGSInt32;\ntypedef unsigned short          CGSUInt16;\ntypedef short                   CGSInt16;\ntypedef unsigned char           CGSUInt8;\ntypedef char                    CGSInt8;\ntypedef float                   CGSFloat32;\n\ntypedef CGSUInt32 CGSByteCount;\ntypedef CGSUInt16 CGSEventRecordVersion;\ntypedef unsigned long CGSEventType;\ntypedef CGSUInt64 CGSEventRecordTime;  /* nanosecond timer */\ntypedef unsigned long CGSEventFlag;\ntypedef CGSUInt32  CGSError;\n\n\ntypedef\tunion {\n    struct {\t/* For mouse events */\n        CGSUInt8\tsubx;\t\t\t/* sub-pixel position for x */\n        CGSUInt8\tsuby;\t\t\t/* sub-pixel position for y */\n        CGSInt16\teventNum;\t\t/* unique identifier for this button */\n        CGSInt32\tclick;\t\t\t/* click state of this event */\n        CGSUInt8\tpressure;\t/* pressure value: 0=none, 255=full */\n        CGSInt8\t\t_reserved1;\n        CGSInt16\t_reserved2;\n        CGSInt16\tdeltaX;\n        CGSInt16\tdeltaY;\n        CGSInt32\t_padding[8];\n    } mouse;\n    struct {\t/* For pointer movement events */\n        CGSInt16\t_obsolete_deltaX;\t/* Revert to subX, subY, eventNum */\n        CGSInt16\t_obsolete_deltaY;\t/* for Gonzo 1H */\n        CGSInt32\tclick;\t\t\t/* click state of this event */\n        CGSUInt8\tpressure;\t/* pressure value: 0=none, 255=full */\n        CGSInt8\t\t_reserved1;\n        CGSInt16\t_reserved2;\n        CGSInt16\tdeltaX;\n        CGSInt16\tdeltaY;\n        CGSInt32\t_padding[8];\n    } move;\n    struct {\t/* For key-down and key-up events */\n        CGSInt16\treserved;\n        CGSInt16\trepeat;\t\t/* for key-down: nonzero if really a repeat */\n        CGSUInt16\tcharSet;\t/* character set code */\n        CGSUInt16\tcharCode;\t/* character code in that set */\n        CGSUInt16\tkeyCode;\t/* device-dependent virtual key code */\n        CGSInt16\tkeyData;\t/* device-dependent info */\n        CGSInt16\tspecialKey;\t/* CPSSpecialKeyID if kCGSFlagsMaskSpecialKey is set */\n        CGSInt16\t_pad;\n        CGSInt32\t_padding[8];\n    } key;\n    struct {\t/* For mouse-entered and mouse-exited events */\n        CGSInt16\treserved;\n        CGSInt16\teventNum;\t/* unique identifier from mouse down event */\n        CGSInt32\ttrackingNum;\t/* unique identifier from settrackingrect */\n        CGSInt32\tuserData;\t/* unCGSInt32erpreted CGSInt32eger from settrackingrect */\n        CGSInt32\t_padding[9];\n    } tracking;\n    struct {\t/* For process-related events */\n        CGSUInt16\tnotifyCode;\t/* CPSNotificationCodes in CPSProcesses.h */\n        CGSUInt16\tflags;\t\t/* CPSEventFlags in CPSProcesses.h */\n        CGSUInt32\ttargetHiPSN;\t/* hiword of PSN */\n        CGSUInt32\ttargetLoPSN;\t/* loword of PSN */\n        CGSInt32\tstatus;\t\t/* operation result */\n        CGSInt32\t_padding[8];\n    } process;\n    struct {\t\t/* For scroll wheel events */\n        CGSInt16\tdeltaAxis1;\n        CGSInt16\tdeltaAxis2;\n        CGSInt16\tdeltaAxis3;\n        CGSInt16\treserved1;\n        CGSInt32\treserved2;\n        CGSInt32\t_padding[9];\n    } scrollWheel;\n    struct {\n        CGSInt32\tx;\t/* absolute x coordinate in tablet space at full tablet resolution */\n        CGSInt32\ty;\t/* absolute y coordinate in tablet space at full tablet resolution */\n        CGSInt32\tz;\t/* absolute z coordinate in tablet space at full tablet resolution */\n        CGSUInt16\tbuttons;\t/* one bit per button - bit 0 is first button - 1 = closed */\n        CGSUInt16\tpressure;\t/* scaled pressure value; MAXPRESSURE=(2^16)-1, MINPRESSURE=0 */\n        struct {\n            CGSInt16 x;\t/* scaled tilt x value; range is -((2^15)-1) to (2^15)-1 (-32767 to 32767) */\n            CGSInt16 y;\t/* scaled tilt y value; range is -((2^15)-1) to (2^15)-1 (-32767 to 32767) */\n        } tilt;\n        CGSUInt16\trotation;\t/* Fixed-point representation of device rotation in a 10.6 format */\n        CGSInt16\ttangentialPressure;\t/* tangential pressure on the device; range same as tilt */\n        CGSUInt16\tdeviceID;\t/* system-assigned unique device ID - matches to deviceID field in proximity event */\n        CGSInt16\tvendor1;\t/* vendor-defined signed 16-bit integer */\n        CGSInt16\tvendor2;\t/* vendor-defined signed 16-bit integer */\n        CGSInt16\tvendor3;\t/* vendor-defined signed 16-bit integer */\n        CGSInt32\t_padding[4];\n    } tablet;\n    struct {\n        CGSUInt16\tvendorID;\t/* vendor-defined ID - typically will be USB vendor ID */\n        CGSUInt16\ttabletID;\t/* vendor-defined tablet ID - typically will be USB product ID for the tablet */\n        CGSUInt16\tpointerID;\t/* vendor-defined ID of the specific pointing device */\n        CGSUInt16\tdeviceID;\t/* system-assigned unique device ID - matches to deviceID field in tablet event */\n        CGSUInt16\tsystemTabletID;\t/* system-assigned unique tablet ID */\n        CGSUInt16\tvendorPointerType;\t/* vendor-defined pointer type */\n        CGSUInt32  pointerSerialNumber;\t/* vendor-defined serial number of the specific pointing device */\n        CGSUInt64\tuniqueID;\t/* vendor-defined unique ID for this pointer */\n        CGSUInt32\tcapabilityMask;\t/* mask representing the capabilities of the device */\n        CGSUInt8\tpointerType;\t/* type of pointing device - enum to be defined */\n        CGSUInt8\tenterProximity;\t/* non-zero = entering; zero = leaving */\n        CGSInt16\treserved1;\n        CGSInt32\t_padding[4];\n    } proximity;\n    struct {\t/* For AppKit-defined, sys-defined, and app-defined events */\n        CGSInt16\treserved;\n        CGSInt16\tsubtype;\t/* event subtype for compound events */\n        union {\n            CGSFloat32\tF[11];\t/* for use in compound events */\n            CGSInt32\tL[11];\t/* for use in compound events */\n            CGSInt16\tS[22];\t/* for use in compound events */\n            CGSInt8\tC[44];\t/* for use in compound events */\n        } misc;\n    } compound;\n} CGSEventRecordData;\n\n\nstruct _CGSEventRecord {\n    CGSEventRecordVersion major;\n    CGSEventRecordVersion minor;\n    CGSByteCount length;\t/* Length of complete event record */\n    CGSEventType type;\t\t/* An event type from above */\n    CGPoint location;\t\t/* Base coordinates (global), from upper-left */\n    CGPoint windowLocation;\t/* Coordinates relative to window */\n    CGSEventRecordTime time;\t/* nanoseconds since startup */\n    CGSEventFlag flags;\t\t/* key state flags */\n    CGSWindowID\twindow;\t\t/* window number of assigned window */\n    CGSConnectionID connection;\t/* connection the event came from */\n    CGSEventRecordData data;\t/* type-dependent data: 40 bytes */\n};\ntypedef struct _CGSEventRecord CGSEventRecord;\ntypedef CGSEventRecord *CGSEventRecordPtr;\n\n\ntypedef void (*CGSNotifyProcPtr)(CGSNotificationType type,\n                                CGSNotificationData data,\n                                CGSByteCount dataLength,\n                                CGSNotificationArg arg);\n\n// Define a type for the 'CGSRegisterNotifyProc' call.  Don't reference it explicitly since we don't want link errors if Apple removes this private function.\ntypedef CGSError (*CGSRegisterNotifyProcType)(CGSNotifyProcPtr proc,\n                                              CGSNotificationType type,\n                                              CGSNotificationArg arg);\n\n\n#define kCGSEventNotificationMouseMoved                    (710 + 5)\n#define kCGSEventNotificationLeftMouseDragged              (710 + 6)\n#define kCGSEventNotificationRightMouseDragged             (710 + 7)\n#define kCGSEventNotificationNotificationOtherMouseDragged (710 + 27)\n\n\n"
  },
  {
    "path": "code/macosx/GenerateQGL.pl",
    "content": "#!/usr/bin/perl\n\nopen(INPUT_FILE, \">/tmp/input-$$.h\") || die \"$!\";\nprint INPUT_FILE \"#import <OpenGL/gl.h>\\n\";\nclose INPUT_FILE;\nopen(CPP, \"cpp /tmp/input-$$.h|\") || die \"$!\";\n\nprint \"/**** This file is autogenerated.  Run GenerateQGL.pl to update it ****/\\n\\n\";\n\nprint \"#ifdef QGL_LOG_GL_CALLS\\n\";\nprint \"extern unsigned int QGLLogGLCalls;\\n\";\nprint \"extern FILE *QGLDebugFile(void);\\n\";\nprint \"#endif\\n\\n\";\n\nprint \"extern void QGLCheckError(const char *message);\\n\";\nprint \"extern unsigned int QGLBeginStarted;\\n\\n\";\nprint \"// This has to be done to avoid infinite recursion between our glGetError wrapper and QGLCheckError()\\n\";\nprint \"static inline GLenum _glGetError(void) {\\n\";\nprint \"    return glGetError();\\n\";\nprint \"}\\n\\n\";\n\n@functionNames = ();\n\nwhile (<CPP>) {\n    chop;\n    /^extern/ || next;\n    s/extern //;\n    print \"// $_\\n\";\n\n    # This approach is necessary to deal with glGetString whos type isn't a single word\n    ($type, $rest) = m/(.+)\\s+(gl.*)/;\n#    print \"type='$type'\\n\";\n#    print \"rest='$rest'\\n\";\n\n    ($name, $argString) = ($rest =~ m/(\\w+).*\\s*\\((.*)\\)/);\n    $isVoid = ($type =~ m/void/);\n    push(@functionNames, $name);\n\n#    print \"name=$name\\n\";\n#    print \"argString=$argString\\n\";\n#    print \"argCount=$#args\\n\";\n\n    # Parse the argument list into two arrays, one of types and one of argument names\n    if ($argString =~ m/^void$/) {\n        @args = ();\n    } else {\n        @args = split(\",\", $argString);\n    }\n    @argTypes = ();\n    @argNames = ();\n    for $arg (@args) {\n        ($argType, $argName) = ($arg =~ m/(.*[ \\*])([_a-zA-Z0-9]+)/);\n        $argType =~ s/^ *//;\n        $argType =~ s/ *$//;\n\n        push(@argTypes, $argType);\n        push(@argNames, $argName);\n#        print \"argType='$argType'\\n\";\n#        print \"argName='$argName'\\n\";\n    }\n\n\n    print \"static inline $type q$name($argString)\\n\";\n    print \"{\\n\";\n\n    if (! $isVoid) {\n        print \"    $type returnValue;\\n\";\n    }\n\n    print \"#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\\n\";\n    print \"    if (QGLLogGLCalls)\\n\";\n    print \"        fprintf(QGLDebugFile(), \\\"$name(\";\n\n    if ($#argTypes >= 0) {\n        for ($i = 0; $i <= $#argTypes; $i++) {\n            $argType = $argTypes[$i];\n            $argName = $argNames[$i];\n            $_ = $argType;\n            if (/^GLenum$/ || /^GLuint$/ || /^GLbitfield$/) {\n                print \"$argName=%lu\";\n            } elsif (/^GLsizei$/ || /^GLint$/) {\n                print \"$argName=%ld\";\n            } elsif (/^GLfloat$/ || /^GLdouble$/ || /^GLclampf$/ || /^GLclampd$/) {\n                print \"$argName=%f\";\n            } elsif (/^GLbyte$/) {\n                print \"$argName=%d\";\n            } elsif (/^GLubyte$/) {\n                print \"$argName=%u\";\n            } elsif (/^GLshort$/) {\n                print \"$argName=%d\";\n            } elsif (/^GLushort$/) {\n                print \"$argName=%u\";\n            } elsif (/^GLboolean$/) {\n                print \"$argName=%u\";\n            } elsif (/\\*$/) {\n                # TJW -- Later we should look at the count specified in the function name, look at the basic type and print out an array.  Or we could just special case them...\n                print \"$argName=%p\";\n            } else {\n                print STDERR \"Unknown type '$argType'\\n\";\n                exit(1);\n            }\n\n            print \", \" if ($i != $#argTypes);\n        }\n    } else {\n        print \"void\";\n    }\n\n    print \")\\\\n\\\"\";\n    print \", \" if $#argTypes >= 0;\n    print join(\", \", @argNames);\n    print \");\\n\";\n    print \"#endif\\n\";\n\n    if (! $isVoid) {\n        print \"    returnValue = \";\n    } else {\n        print \"    \";\n    }\n    print \"$name(\" . join(\", \", @argNames) . \");\\n\";\n\n    print \"#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\\n\";\n    if ($name eq \"glBegin\") {\n        print \"    QGLBeginStarted++;\\n\";\n    }\n    if ($name eq \"glEnd\") {\n        print \"    QGLBeginStarted--;\\n\";\n    }\n    print \"    if (!QGLBeginStarted)\\n\";\n    print \"        QGLCheckError(\\\"$name\\\");\\n\";\n    print \"#endif\\n\";\n\n    if (! $isVoid) {\n        print \"    return returnValue;\\n\";\n    }\n    \n    print \"}\\n\\n\";\n}\n\n\nprint \"// Prevent calls to the 'normal' GL functions\\n\";\nfor $name (@functionNames) {\n    print \"#define $name CALL_THE_QGL_VERSION_OF_$name\\n\";\n}\n\n\n"
  },
  {
    "path": "code/macosx/Performance.rtf",
    "content": "{\\rtf1\\mac\\ansicpg10000{\\fonttbl\\f0\\fswiss\\fcharset77 Helvetica;}\n{\\colortbl;\\red255\\green255\\blue255;\\red255\\green0\\blue16;\\red255\\green0\\blue16;}\n\\paperw14240\\paperh14700\n\\pard\\tx1440\\tx2880\\tx4320\\tx5760\\tx7200\\ql\\qnatural\n\n\\f0\\fs24 \\cf0 \\\n\n\\b +set timedemo 1 +demo die.dm3 +set s_initsound 0 +set r_enablerender 0 +set vm_cgame 0 +set vm_game 0\\\n4865 frames, 154.3 seconds: 31.5 fps\\\n\\\n\\\n+set timedemo 1 +demo die.dm3 +set s_initsound 0 +set r_enablerender 0 +set vm_cgame 2 +set vm_game 2\\\n4865 frames, 199.8 seconds: 24.4 fps\\\n\\\n\\\n+set timedemo 1 +demo demo001.dm3 +set s_initsound 0 +set r_enablerender 0 +set vm_cgame 0 +set vm_game 0\\\n1346 frames, 10.1 seconds: 133.0 fps\\\n\\\n\\\n+set timedemo 1 +demo demo001.dm3 +set s_initsound 0 +set r_enablerender 0 +set vm_cgame 2 +set vm_game 2\\\n1346 frames, 12.8 seconds: 105.4 fps\\\n\\\n\\\n\\\nStarting point\\\n\n\\b0 4865 frames, 154.5 seconds: 31.5 fps\\\n[seconds spent locally, % of parent, % of total, # of samples]\\\n[133.623469 -- 60130560955, 100.00%, 100.00%, 4866] Root\\\n        [126.853849 -- 57084231997, 94.93%, 94.93%, 4866] CL_Frame\\\n                [125.895845 -- 56653130083, 99.24%, 94.22%, 4918] SCR_UpdateScreen\\\n                        [50.532841 -- 22739778533, 40.14%, 37.82%, 524036] RB_SurfaceMesh\\\n                                [46.583051 -- 20962372767, 92.18%, 34.86%, 524036] LerpMeshVertexes\\\n                                        [8.465527 -- 3809487228, 18.17%, 6.34%, 455917] LerpMeshVertexes 1\\\n\n\\b \\cf2                                         [37.967433 -- 17085344910, 81.50%, 28.41%, 68119] LerpMeshVertexes 2\\\n\n\\b0 \\cf0                                 [0.32% spent locally]\\\n                        [7.82% spent locally]\\\n                [59.86% spent locally]\\\n        [0.76% spent locally]\\\n[5.07% spent locally]\\\n\\\n\n\\b Minor cleanup of local variables\\\n\n\\b0 [seconds spent locally, % of parent, % of total, # of samples]\\\n[133.121489 -- 59904670191, 100.00%, 100.00%, 4866] Root\\\n        [126.329343 -- 56848204176, 94.90%, 94.90%, 4866] CL_Frame\\\n                [125.402239 -- 56431007399, 99.27%, 94.20%, 4918] SCR_UpdateScreen\\\n                        [50.013076 -- 22505884288, 39.88%, 37.57%, 524036] RB_SurfaceMesh\\\n                                [46.085775 -- 20738598809, 92.15%, 34.62%, 524036] LerpMeshVertexes\\\n                                        [8.427565 -- 3792404277, 18.29%, 6.33%, 455917] LerpMeshVertexes 1\\\n\\pard\\tx1440\\tx2880\\tx4320\\tx5760\\tx7200\\ql\\qnatural\n\n\\b \\cf3                                         [37.517092 -- 16882691281, 81.41%, 28.18%, 68119] LerpMeshVertexes 2\\\n\\pard\\tx1440\\tx2880\\tx4320\\tx5760\\tx7200\\ql\\qnatural\n\n\\b0 \\cf0                                 [0.31% spent locally]\\\n                        [7.85% spent locally]\\\n                [60.12% spent locally]\\\n        [0.73% spent locally]\\\n[5.10% spent locally]\\\n\\\n\\\n\n\\b Split out normalization of LERPed normals (i.e., all the sqrt calls)\\\n\n\\b0 [seconds spent locally, % of parent, % of total, # of samples]\\\n[133.110463 -- 59899708244, 100.00%, 100.00%, 4866] Root\\\n        [126.357393 -- 56860826689, 94.93%, 94.93%, 4866] CL_Frame\\\n                [125.364641 -- 56414088645, 99.21%, 94.18%, 4918] SCR_UpdateScreen\\\n                        [49.854816 -- 22434667309, 39.77%, 37.45%, 524036] RB_SurfaceMesh\\\n                                [45.981802 -- 20691810706, 92.23%, 34.54%, 524036] LerpMeshVertexes\\\n                                        [8.407983 -- 3783592133, 18.29%, 6.32%, 455917] LerpMeshVertexes 1\\\n                                        [37.432159 -- 16844471717, 81.41%, 28.12%, 68119] LerpMeshVertexes 2\\\n\\pard\\tx1440\\tx2880\\tx4320\\tx5760\\tx7200\\ql\\qnatural\n\n\\b \\cf3                                                 [30.288000 -- 13629599780, 80.91%, 22.75%, 68119] VectorArrayNormalize\\\n\\pard\\tx1440\\tx2880\\tx4320\\tx5760\\tx7200\\ql\\qnatural\n\n\\b0 \\cf0                                         [19.09% spent locally]\\\n                        [0.31% spent locally]\\\n                        [7.77% spent locally]\\\n                [60.23% spent locally]\\\n        [0.79% spent locally]\\\n[5.07% spent locally]\\\n\\\n\n\\b Rewrote VectorArrayNormalize to use PPC frsqrt instruction (with Newton-Rhapson refinement)\\\n\n\\b0 4865 frames, 128.7 seconds: 37.8 fps\\\n[seconds spent locally, % of parent, % of total, # of samples]\\\n[103.972710 -- 46787719721, 100.00%, 100.00%, 4866] Root\\\n        [97.153160 -- 43718922078, 93.44%, 93.44%, 4866] CL_Frame\\\n                [96.219348 -- 43298706398, 99.04%, 92.54%, 4918] SCR_UpdateScreen\\\n                        [20.873944 -- 9393274747, 21.69%, 20.08%, 524036] RB_SurfaceMesh\\\n                                [17.053245 -- 7673960266, 81.70%, 16.40%, 524036] LerpMeshVertexes\\\n                                        [8.356579 -- 3760460537, 49.00%, 8.04%, 455917] LerpMeshVertexes 1\\\n                                        [8.560159 -- 3852071404, 50.20%, 8.23%, 68119] LerpMeshVertexes 2\\\n\\pard\\tx1440\\tx2880\\tx4320\\tx5760\\tx7200\\ql\\qnatural\n\n\\b \\cf3                                                 [1.429376 -- 643219234, 16.70%, 1.37%, 68119] VectorArrayNormalize\\\n\\pard\\tx1440\\tx2880\\tx4320\\tx5760\\tx7200\\ql\\qnatural\n\n\\b0 \\cf0                                         [83.30% spent locally]\\\n                        [0.80% spent locally]\\\n                        [18.30% spent locally]\\\n                [78.31% spent locally]\\\n        [0.96% spent locally]\\\n[6.56% spent locally]\\\n\\\n\\\n}\n"
  },
  {
    "path": "code/macosx/Q3Controller.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#import <AppKit/AppKit.h>\n\n@interface Q3Controller : NSObject\n{\n    IBOutlet NSPanel *bannerPanel;\n}\n\n#ifndef DEDICATED\n- (IBAction)paste:(id)sender;\n- (IBAction)requestTerminate:(id)sender;\n\n- (void) showBanner;\n#endif\n\n- (void)quakeMain;\n\n@end\n\n"
  },
  {
    "path": "code/macosx/Q3Controller.m",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#import \"Q3Controller.h\"\n\n#import <Foundation/Foundation.h>\n#import <AppKit/AppKit.h>\n\n#include \"client.h\"\n#include \"macosx_local.h\"\n//#include \"GameRanger SDK/gameranger.h\"\n#ifdef OMNI_TIMER\n#import \"macosx_timers.h\"\n#endif\n\n#define MAX_ARGC 1024\n\nstatic qboolean Sys_IsProcessingTerminationRequest = qfalse;\nstatic void Sys_CreatePathToFile(NSString *path, NSDictionary *attributes);\n\n@interface Q3Controller (Private)\n- (void)quakeMain;\n@end\n\n@implementation Q3Controller\n\n#ifndef DEDICATED\n\n- (void)applicationDidFinishLaunching:(NSNotification *)notification;\n{\n    NS_DURING {\n        [self quakeMain];\n    } NS_HANDLER {\n        Sys_Error(\"%@\", [localException reason]);\n    } NS_ENDHANDLER;\n    Sys_Quit();\n}\n\n- (void)applicationDidUnhide:(NSNotification *)notification;\n{\n    // Don't reactivate the game if we are asking whether to quit\n    if (Sys_IsProcessingTerminationRequest)\n        return;\n        \n    if (!Sys_Unhide())\n        // Didn't work -- hide again so we should get another chance to unhide later\n        [NSApp hide: nil];\n}\n\n- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;\n{\n    int choice;\n\n    if (!Sys_IsHidden) {\n        // We're terminating via -terminate:\n        return NSTerminateNow;\n    }\n    \n    // Avoid reactivating GL when we unhide due to this panel\n    Sys_IsProcessingTerminationRequest = qtrue;\n    choice = NSRunAlertPanel(nil, @\"Quit without saving?\", @\"Don't Quit\", @\"Quit\", nil);\n    Sys_IsProcessingTerminationRequest = qfalse;\n\n    if (choice == NSAlertAlternateReturn)\n        return NSTerminateNow;\n        \n    // Make sure we get re-hidden\n    [NSApp hide:nil];\n    \n    return NSTerminateCancel;\n}\n\n// Actions\n\n- (IBAction)paste:(id)sender;\n{\n    int shiftWasDown, insertWasDown;\n    unsigned int currentTime;\n\n    currentTime = Sys_Milliseconds();\n    // Save the original keyboard state\n    shiftWasDown = keys[K_SHIFT].down;\n    insertWasDown = keys[K_INS].down;\n    // Fake a Shift-Insert keyboard event\n    keys[K_SHIFT].down = qtrue;\n    Sys_QueEvent(currentTime, SE_KEY, K_INS, qtrue, 0, NULL);\n    Sys_QueEvent(currentTime, SE_KEY, K_INS, qfalse, 0, NULL);\n    // Restore the original keyboard state\n    keys[K_SHIFT].down = shiftWasDown;\n    keys[K_INS].down = insertWasDown;\n}\n\nextern void CL_Quit_f(void);\n\n\n- (IBAction)requestTerminate:(id)sender;\n{\n    Com_Quit_f();\n    // UI_QuitMenu();\n}\n\n- (void)showBanner;\n{\n    static BOOL hasShownBanner = NO;\n\n    if (!hasShownBanner) {\n        cvar_t *showBanner;\n\n        hasShownBanner = YES;\n        showBanner = Cvar_Get(\"cl_showBanner\", \"1\", 0);\n        if (showBanner->integer != 0) {\n            NSPanel *splashPanel;\n            NSImage *bannerImage;\n            NSRect bannerRect;\n            NSImageView *bannerImageView;\n            \n            bannerImage = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForImageResource:@\"banner.jpg\"]];\n            bannerRect = NSMakeRect(0.0, 0.0, [bannerImage size].width, [bannerImage size].height);\n            \n            splashPanel = [[NSPanel alloc] initWithContentRect:bannerRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];\n            \n            bannerImageView = [[NSImageView alloc] initWithFrame:bannerRect];\n            [bannerImageView setImage:bannerImage];\n            [splashPanel setContentView:bannerImageView];\n            [bannerImageView release];\n            \n            [splashPanel center];\n            [splashPanel setHasShadow:YES];\n            [splashPanel orderFront: nil];\n            [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.5]];\n            [splashPanel close];\n            \n            [bannerImage release];\n        }\n    }\n}\n\n// Services\n\n- (void)connectToServer:(NSPasteboard *)pasteboard userData:(NSString *)data error:(NSString **)error;\n{\n    NSArray *pasteboardTypes;\n\n    pasteboardTypes = [pasteboard types];\n    if ([pasteboardTypes containsObject:NSStringPboardType]) {\n        NSString *requestedServer;\n\n        requestedServer = [pasteboard stringForType:NSStringPboardType];\n        if (requestedServer) {\n            Cbuf_AddText(va(\"connect %s\\n\", [requestedServer cString]));\n            return;\n        }\n    }\n    *error = @\"Unable to connect to server:  could not find string on pasteboard\";\n}\n\n- (void)performCommand:(NSPasteboard *)pasteboard userData:(NSString *)data error:(NSString **)error;\n{\n    NSArray *pasteboardTypes;\n\n    pasteboardTypes = [pasteboard types];\n    if ([pasteboardTypes containsObject:NSStringPboardType]) {\n        NSString *requestedCommand;\n\n        requestedCommand = [pasteboard stringForType:NSStringPboardType];\n        if (requestedCommand) {\n            Cbuf_AddText(va(\"%s\\n\", [requestedCommand cString]));\n            return;\n        }\n    }\n    *error = @\"Unable to perform command:  could not find string on pasteboard\";\n}\n\n#endif\n\n- (void)quakeMain;\n{\n    NSAutoreleasePool *pool;\n    int argc = 0;\n    const char *argv[MAX_ARGC];\n    NSProcessInfo *processInfo;\n    NSArray *arguments;\n    unsigned int argumentIndex, argumentCount;\n    NSFileManager *defaultManager;\n    unsigned int commandLineLength;\n    NSString *installationPathKey, *installationPath;\n    char *cmdline;\n    BOOL foundDirectory;\n    NSString *appName, *demoAppName, *selectButton;\n    int count = 0;\n    pool = [[NSAutoreleasePool alloc] init];\n\n    [NSApp setServicesProvider:self];\n\n    processInfo = [NSProcessInfo processInfo];\n    arguments = [processInfo arguments];\n    argumentCount = [arguments count];\n    for (argumentIndex = 0; argumentIndex < argumentCount; argumentIndex++) {\n        NSString *arg;\n        \n        arg = [arguments objectAtIndex:argumentIndex];\n        // Don't pass the Process Serial Number command line arg that the Window Server/Finder invokes us with\n        if ([arg hasPrefix: @\"-psn_\"])\n            continue;\n            \n        argv[argc++] = strdup([arg cString]);\n    }\n    \n    // Figure out where the level data is stored.\n    installationPathKey = @\"RetailInstallationPath\";\n\n    installationPath = [[NSUserDefaults standardUserDefaults] objectForKey:installationPathKey];\n    if (!installationPath) {\n        // Default to the directory containing the executable (which is where most users will want to put it\n        installationPath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];\n    }\n\n#if !defined(DEDICATED)    \n    appName = [[[NSBundle mainBundle] infoDictionary] objectForKey: @\"CFBundleName\"];\n#else\n\t// We are hard coding the app name here since the dedicated server is a tool, not a app bundle and does not have access to the Info.plist that the client app does.  Suck.\n    appName = @\"Quake3\";\n#endif\n    demoAppName = appName;\n\n    while (YES) {\n        NSString *dataPath;\n        NSOpenPanel *openPanel;\n        int result;\n        \n        foundDirectory = NO;\n        defaultManager = [NSFileManager defaultManager];\n        //NSLog(@\"Candidate installation path = %@\", installationPath);\n        dataPath = [installationPath stringByAppendingPathComponent: @\"baseq3\"];\n        \n        if ([defaultManager fileExistsAtPath: dataPath]) {\n            // Check that the data directory contains at least one .pk3 file.  We don't know what it will be named, so don't hard code a name (for example it might be named 'french.pk3' for a French release\n            NSArray *files;\n            unsigned int fileIndex;\n            \n            files = [defaultManager directoryContentsAtPath: dataPath];\n            fileIndex = [files count];\n            while (fileIndex--) {\n                if ([[files objectAtIndex: fileIndex] hasSuffix: @\"pk3\"]) {\n                    //NSLog(@\"Found %@.\", [files objectAtIndex: fileIndex]);\n                    foundDirectory = YES;\n                    break;\n                }\n            }\n        }\n        \n        if (foundDirectory)\n            break;\n\n#ifdef DEDICATED\n            break;\n#warning TJW: We are hard coding the app name and default domain here since the dedicated server is a tool, not a app bundle and does not have access to the Info.plist that the client app does.  Suck.\n        NSLog(@\"Unable to determine installation directory.  Please move the executable into the '%@' installation directory or add a '%@' key in the 'Q3DedicatedServer' defaults domain.\", appName, installationPathKey, [[NSBundle mainBundle] bundleIdentifier]);\n        Sys_Quit();\n        exit(1);\n#else\n        selectButton = @\"Select Retail Installation...\";\n\n        result = NSRunAlertPanel(demoAppName, @\"You need to select the installation directory for %@ (not any directory inside of it -- the installation directory itself).\", selectButton, @\"Quit\", nil, appName);\n        switch (result) {\n            case NSAlertDefaultReturn:\n                break;\n            default:\n                Sys_Quit();\n                break;\n        }\n        \n        openPanel = [NSOpenPanel openPanel];\n        [openPanel setAllowsMultipleSelection:NO];\n        [openPanel setCanChooseDirectories:YES];\n        [openPanel setCanChooseFiles:NO];\n        result = [openPanel runModalForDirectory:nil file:nil];\n        if (result == NSOKButton) {\n            NSArray *filenames;\n\n            filenames = [openPanel filenames];\n            if ([filenames count] == 1) {\n                installationPath = [filenames objectAtIndex:0];\n                [[NSUserDefaults standardUserDefaults] setObject:installationPath forKey:installationPathKey];\n                [[NSUserDefaults standardUserDefaults] synchronize];\n            }\n        }\n#endif\n    }\n    \n    // Create the application support directory if it doesn't exist already\n    do {\n        NSArray *results;\n        NSString *libraryPath, *homePath, *filePath;\n        NSDictionary *attributes;\n        \n        results = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);\n        if (![results count])\n            break;\n        \n        libraryPath = [results objectAtIndex: 0];\n        homePath = [libraryPath stringByAppendingPathComponent: @\"Application Support\"];\n        homePath = [homePath stringByAppendingPathComponent: appName];\n        filePath = [homePath stringByAppendingPathComponent: @\"foo\"];\n        \n        attributes = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithUnsignedInt: 0750], NSFilePosixPermissions, nil];\n        NS_DURING {\n            Sys_CreatePathToFile(filePath, attributes);\n            Sys_SetDefaultHomePath([homePath fileSystemRepresentation]);\n        } NS_HANDLER {\n            NSLog(@\"Exception: %@\", localException);\n#ifndef DEDICATED\n            NSRunAlertPanel(nil, @\"Unable to create '%@'.  Please make sure that you have permission to write to this folder and re-run the game.\", @\"OK\", nil, nil, homePath);\n#endif\n            Sys_Quit();\n        } NS_ENDHANDLER;\n    } while(0);\n    \n    // Provoke the CD scanning code into looking up the CD.\n    Sys_CheckCD();\n    \n    // Let the filesystem know where our local install is\n    Sys_SetDefaultInstallPath([installationPath cString]);\n\n    cmdline = NULL;\n#if 0\n    if (GRCheckFileForCmd()) {\n\tGRGetWaitingCmd();\n\tif (GRHasProperty( 'Exec' )) {\n            NSString *cfgPath, *grCfg;\n            cfgPath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];\n            cfgPath = [cfgPath stringByAppendingPathComponent: [NSString stringWithCString: GRGetPropertyStr( 'Exec' )]];\n            grCfg = [NSString stringWithContentsOfFile: cfgPath];\n            cmdline = malloc(strlen([grCfg cString])+1);\n            [grCfg getCString: cmdline];\n\t}\n    }\n#endif\n    if (!cmdline) {\n        // merge the command line, this is kinda silly\t\n        for (commandLineLength = 1, argumentIndex = 1; argumentIndex < argc; argumentIndex++)\n            commandLineLength += strlen(argv[argumentIndex]) + 1;\n        cmdline = malloc(commandLineLength);\n        *cmdline = '\\0';\n        for (argumentIndex = 1; argumentIndex < argc; argumentIndex++) {\n            if (argumentIndex > 1)\n                strcat(cmdline, \" \");\n            strcat(cmdline, argv[argumentIndex]);\n        }\n    }\n    Com_Printf(\"command line: %s\\n\", cmdline);\n    \n    Com_Init(cmdline);\n\n#ifndef DEDICATED\n    [NSApp activateIgnoringOtherApps:YES];\n#endif\n\n    while (1) {\n        Com_Frame();\n\n        if ((count & 15)==0) {\n            // We should think about doing this less frequently than every frame\n            [pool release];\n            pool = [[NSAutoreleasePool alloc] init];\n        }\n    }\n\n    [pool release];\n}\n\n@end\n\n\n\n// Creates any directories needed to be able to create a file at the specified path.  Raises an exception on failure.\nstatic void Sys_CreatePathToFile(NSString *path, NSDictionary *attributes)\n{\n    NSArray *pathComponents;\n    unsigned int dirIndex, dirCount;\n    unsigned int startingIndex;\n    NSFileManager *manager;\n    \n    manager = [NSFileManager defaultManager];\n    pathComponents = [path pathComponents];\n    dirCount = [pathComponents count] - 1;\n\n    startingIndex = 0;\n    for (dirIndex = startingIndex; dirIndex < dirCount; dirIndex++) {\n        NSString *partialPath;\n        BOOL fileExists;\n\n        partialPath = [NSString pathWithComponents:[pathComponents subarrayWithRange:NSMakeRange(0, dirIndex + 1)]];\n        \n        // Don't use the 'fileExistsAtPath:isDirectory:' version since it doesn't traverse symlinks\n        fileExists = [manager fileExistsAtPath:partialPath];\n        if (!fileExists) {\n            if (![manager createDirectoryAtPath:partialPath attributes:attributes]) {\n                [NSException raise:NSGenericException format:@\"Unable to create a directory at path: %@\", partialPath];\n            }\n        } else {\n            NSDictionary *attributes;\n\n            attributes = [manager fileAttributesAtPath:partialPath traverseLink:YES];\n            if (![[attributes objectForKey:NSFileType] isEqualToString: NSFileTypeDirectory]) {\n                [NSException raise:NSGenericException format:@\"Unable to write to path \\\"%@\\\" because \\\"%@\\\" is not a directory\",\n                    path, partialPath];\n            }\n        }\n    }\n}\n\n#ifdef DEDICATED\nvoid S_ClearSoundBuffer( void ) {\n}\n#endif\n"
  },
  {
    "path": "code/macosx/Quake3.nib/classes.nib",
    "content": "{\n    IBClasses = (\n        {\n            ACTIONS = {showHelp = id; }; \n            CLASS = FirstResponder; \n            LANGUAGE = ObjC; \n            SUPERCLASS = NSObject; \n        }, \n        {\n            ACTIONS = {paste = id; requestTerminate = id; }; \n            CLASS = Q3Controller; \n            LANGUAGE = ObjC; \n            OUTLETS = {bannerPanel = id; }; \n            SUPERCLASS = NSObject; \n        }\n    ); \n    IBVersion = 1; \n}"
  },
  {
    "path": "code/macosx/Quake3.nib/info.nib",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist SYSTEM \"file://localhost/System/Library/DTDs/PropertyList.dtd\">\n<plist version=\"0.9\">\n<dict>\n\t<key>IBEditorPositions</key>\n\t<dict>\n\t\t<key>29</key>\n\t\t<string>69 252 121 44 0 0 1152 746 </string>\n\t</dict>\n\t<key>IBFramework Version</key>\n\t<string>248.0</string>\n\t<key>IBOpenObjects</key>\n\t<array>\n\t\t<integer>29</integer>\n\t</array>\n\t<key>IBSystem Version</key>\n\t<string>5V21</string>\n</dict>\n</plist>\n"
  },
  {
    "path": "code/macosx/Quake3.pbproj/apple.pbxuser",
    "content": "// !$*UTF8*$!\n{\n\t00F5ED38FEBA95B7C697A12F = {\n\t\tactiveExec = 0;\n\t};\n\t00F5ED90FEBA9615C697A12F = {\n\t\tactiveExec = 0;\n\t};\n\t016EAE0300B4BDD1C697A10E = {\n\t\tactiveExec = 0;\n\t};\n\t0170304B00B4885DC697A10E = {\n\t\tactiveExec = 0;\n\t\texecutables = (\n\t\t\t1895FF35065E291B00F8B3F4,\n\t\t);\n\t};\n\t0170311C00B49352C697A10E = {\n\t\tactiveExec = 0;\n\t};\n\t043627B100868916C697A10E = {\n\t\tuiCtxt = {\n\t\t\tsepNavIntBoundsRect = \"{{0, 0}, {1586, 6033}}\";\n\t\t\tsepNavSelRange = \"{136, 0}\";\n\t\t\tsepNavVisRect = \"{{0, 0}, {711, 428}}\";\n\t\t};\n\t};\n\t0654BA41FE8ECEE0C697A12F = {\n\t\tactiveBuildStyle = 07F3F50BFFE98E8EC697A10E;\n\t\tactiveExecutable = 1895FF30065E291B00F8B3F4;\n\t\tactiveTarget = 00F5ED90FEBA9615C697A12F;\n\t\tcodeSenseManager = 1895FF4C065E294000F8B3F4;\n\t\texecutables = (\n\t\t\t1895FF2F065E291B00F8B3F4,\n\t\t\t1895FF30065E291B00F8B3F4,\n\t\t\t1895FF31065E291B00F8B3F4,\n\t\t\t1895FF35065E291B00F8B3F4,\n\t\t);\n\t\tperUserDictionary = {\n\t\t\tPBXConfiguration.PBXFileTableDataSource3.PBXExecutablesDataSource = {\n\t\t\t\tPBXFileTableDataSourceColumnSortingDirectionKey = \"-1\";\n\t\t\t\tPBXFileTableDataSourceColumnSortingKey = PBXExecutablesDataSource_NameID;\n\t\t\t\tPBXFileTableDataSourceColumnWidthsKey = (\n\t\t\t\t\t22,\n\t\t\t\t\t843.7974,\n\t\t\t\t);\n\t\t\t\tPBXFileTableDataSourceColumnsKey = (\n\t\t\t\t\tPBXExecutablesDataSource_ActiveFlagID,\n\t\t\t\t\tPBXExecutablesDataSource_NameID,\n\t\t\t\t);\n\t\t\t};\n\t\t\tPBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = {\n\t\t\t\tPBXFileTableDataSourceColumnSortingDirectionKey = \"-1\";\n\t\t\t\tPBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID;\n\t\t\t\tPBXFileTableDataSourceColumnWidthsKey = (\n\t\t\t\t\t20,\n\t\t\t\t\t550,\n\t\t\t\t\t20,\n\t\t\t\t\t99,\n\t\t\t\t\t43,\n\t\t\t\t\t43,\n\t\t\t\t\t20,\n\t\t\t\t);\n\t\t\t\tPBXFileTableDataSourceColumnsKey = (\n\t\t\t\t\tPBXFileDataSource_FiletypeID,\n\t\t\t\t\tPBXFileDataSource_Filename_ColumnID,\n\t\t\t\t\tPBXFileDataSource_Built_ColumnID,\n\t\t\t\t\tPBXFileDataSource_ObjectSize_ColumnID,\n\t\t\t\t\tPBXFileDataSource_Errors_ColumnID,\n\t\t\t\t\tPBXFileDataSource_Warnings_ColumnID,\n\t\t\t\t\tPBXFileDataSource_Target_ColumnID,\n\t\t\t\t);\n\t\t\t};\n\t\t\tPBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = {\n\t\t\t\tPBXFileTableDataSourceColumnSortingDirectionKey = \"-1\";\n\t\t\t\tPBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID;\n\t\t\t\tPBXFileTableDataSourceColumnWidthsKey = (\n\t\t\t\t\t20,\n\t\t\t\t\t467,\n\t\t\t\t\t101,\n\t\t\t\t\t20,\n\t\t\t\t\t101,\n\t\t\t\t\t43,\n\t\t\t\t\t43,\n\t\t\t\t);\n\t\t\t\tPBXFileTableDataSourceColumnsKey = (\n\t\t\t\t\tPBXFileDataSource_FiletypeID,\n\t\t\t\t\tPBXFileDataSource_Filename_ColumnID,\n\t\t\t\t\tPBXTargetDataSource_PrimaryAttribute,\n\t\t\t\t\tPBXFileDataSource_Built_ColumnID,\n\t\t\t\t\tPBXFileDataSource_ObjectSize_ColumnID,\n\t\t\t\t\tPBXFileDataSource_Errors_ColumnID,\n\t\t\t\t\tPBXFileDataSource_Warnings_ColumnID,\n\t\t\t\t);\n\t\t\t};\n\t\t\tPBXPerProjectTemplateStateSaveDate = 106915007;\n\t\t\tPBXPrepackagedSmartGroups_v2 = (\n\t\t\t\t{\n\t\t\t\t\tPBXTransientLocationAtTop = bottom;\n\t\t\t\t\tabsolutePathToBundle = \"\";\n\t\t\t\t\tactivationKey = OldTargetSmartGroup;\n\t\t\t\t\tclz = PBXTargetSmartGroup;\n\t\t\t\t\tdescription = \"Displays all targets of the project.\";\n\t\t\t\t\tglobalID = 1C37FABC04509CD000000102;\n\t\t\t\t\tname = Targets;\n\t\t\t\t\tpreferences = {\n\t\t\t\t\t\timage = Targets;\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tPBXTransientLocationAtTop = bottom;\n\t\t\t\t\tabsolutePathToBundle = \"\";\n\t\t\t\t\tclz = PBXTargetSmartGroup2;\n\t\t\t\t\tdescription = \"Displays all targets of the project as well as nested build phases.\";\n\t\t\t\t\tglobalID = 1C37FBAC04509CD000000102;\n\t\t\t\t\tname = Targets;\n\t\t\t\t\tpreferences = {\n\t\t\t\t\t\timage = Targets;\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tPBXTransientLocationAtTop = bottom;\n\t\t\t\t\tabsolutePathToBundle = \"\";\n\t\t\t\t\tclz = PBXExecutablesSmartGroup;\n\t\t\t\t\tdescription = \"Displays all executables of the project.\";\n\t\t\t\t\tglobalID = 1C37FAAC04509CD000000102;\n\t\t\t\t\tname = Executables;\n\t\t\t\t\tpreferences = {\n\t\t\t\t\t\timage = Executable;\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\" PBXTransientLocationAtTop \" = bottom;\n\t\t\t\t\tabsolutePathToBundle = \"\";\n\t\t\t\t\tclz = PBXErrorsWarningsSmartGroup;\n\t\t\t\t\tdescription = \"Displays files with errors or warnings.\";\n\t\t\t\t\tglobalID = 1C08E77C0454961000C914BD;\n\t\t\t\t\tname = \"Errors and Warnings\";\n\t\t\t\t\tpreferences = {\n\t\t\t\t\t\tfnmatch = \"\";\n\t\t\t\t\t\timage = WarningsErrors;\n\t\t\t\t\t\trecursive = 1;\n\t\t\t\t\t\tregex = \"\";\n\t\t\t\t\t\troot = \"<PROJECT>\";\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tPBXTransientLocationAtTop = bottom;\n\t\t\t\t\tabsolutePathToBundle = \"\";\n\t\t\t\t\tclz = PBXFilenameSmartGroup;\n\t\t\t\t\tdescription = \"Filters items in a given group (potentially recursively) based on matching the name with the regular expression of the filter.\";\n\t\t\t\t\tglobalID = 1CC0EA4004350EF90044410B;\n\t\t\t\t\tname = \"Implementation Files\";\n\t\t\t\t\tpreferences = {\n\t\t\t\t\t\tcanSave = 1;\n\t\t\t\t\t\tfnmatch = \"\";\n\t\t\t\t\t\timage = SmartFolder;\n\t\t\t\t\t\tisLeaf = 0;\n\t\t\t\t\t\trecursive = 1;\n\t\t\t\t\t\tregex = \"?*\\\\.[mcMC]\";\n\t\t\t\t\t\troot = \"<PROJECT>\";\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tPBXTransientLocationAtTop = bottom;\n\t\t\t\t\tabsolutePathToBundle = \"\";\n\t\t\t\t\tclz = PBXFilenameSmartGroup;\n\t\t\t\t\tdescription = \"This group displays Interface Builder NIB Files.\";\n\t\t\t\t\tglobalID = 1CC0EA4004350EF90041110B;\n\t\t\t\t\tname = \"NIB Files\";\n\t\t\t\t\tpreferences = {\n\t\t\t\t\t\tcanSave = 1;\n\t\t\t\t\t\tfnmatch = \"*.nib\";\n\t\t\t\t\t\timage = SmartFolder;\n\t\t\t\t\t\tisLeaf = 0;\n\t\t\t\t\t\trecursive = 1;\n\t\t\t\t\t\tregex = \"\";\n\t\t\t\t\t\troot = \"<PROJECT>\";\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tPBXTransientLocationAtTop = no;\n\t\t\t\t\tabsolutePathToBundle = \"\";\n\t\t\t\t\tclz = PBXFindSmartGroup;\n\t\t\t\t\tdescription = \"Displays Find Results.\";\n\t\t\t\t\tglobalID = 1C37FABC05509CD000000102;\n\t\t\t\t\tname = \"Find Results\";\n\t\t\t\t\tpreferences = {\n\t\t\t\t\t\timage = spyglass;\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tPBXTransientLocationAtTop = no;\n\t\t\t\t\tabsolutePathToBundle = \"\";\n\t\t\t\t\tclz = PBXBookmarksSmartGroup;\n\t\t\t\t\tdescription = \"Displays Project Bookmarks.\";\n\t\t\t\t\tglobalID = 1C37FABC05539CD112110102;\n\t\t\t\t\tname = Bookmarks;\n\t\t\t\t\tpreferences = {\n\t\t\t\t\t\timage = Bookmarks;\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tPBXTransientLocationAtTop = bottom;\n\t\t\t\t\tabsolutePathToBundle = \"\";\n\t\t\t\t\tclz = XCSCMSmartGroup;\n\t\t\t\t\tdescription = \"Displays files with interesting SCM status.\";\n\t\t\t\t\tglobalID = E2644B35053B69B200211256;\n\t\t\t\t\tname = SCM;\n\t\t\t\t\tpreferences = {\n\t\t\t\t\t\timage = PBXRepository;\n\t\t\t\t\t\tisLeaf = 0;\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tPBXTransientLocationAtTop = bottom;\n\t\t\t\t\tabsolutePathToBundle = \"\";\n\t\t\t\t\tclz = PBXSymbolsSmartGroup;\n\t\t\t\t\tdescription = \"Displays all symbols for the project.\";\n\t\t\t\t\tglobalID = 1C37FABC04509CD000100104;\n\t\t\t\t\tname = \"Project Symbols\";\n\t\t\t\t\tpreferences = {\n\t\t\t\t\t\timage = ProjectSymbols;\n\t\t\t\t\t\tisLeaf = 1;\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tPBXTransientLocationAtTop = bottom;\n\t\t\t\t\tabsolutePathToBundle = \"\";\n\t\t\t\t\tclz = PBXFilenameSmartGroup;\n\t\t\t\t\tdescription = \"Filters items in a given group (potentially recursively) based on matching the name with the regular expression of the filter.\";\n\t\t\t\t\tglobalID = PBXTemplateMarker;\n\t\t\t\t\tname = \"Simple Filter SmartGroup\";\n\t\t\t\t\tpreferences = {\n\t\t\t\t\t\tcanSave = 1;\n\t\t\t\t\t\tfnmatch = \"*.nib\";\n\t\t\t\t\t\timage = SmartFolder;\n\t\t\t\t\t\tisLeaf = 0;\n\t\t\t\t\t\trecursive = 1;\n\t\t\t\t\t\tregex = \"\";\n\t\t\t\t\t\troot = \"<PROJECT>\";\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tPBXTransientLocationAtTop = bottom;\n\t\t\t\t\tabsolutePathToBundle = \"\";\n\t\t\t\t\tclz = PBXFilenameSmartGroup;\n\t\t\t\t\tdescription = \"Filters items in a given group (potentially recursively) based on matching the name with the regular expression of the filter.\";\n\t\t\t\t\tglobalID = PBXTemplateMarker;\n\t\t\t\t\tname = \"Simple Regular Expression SmartGroup\";\n\t\t\t\t\tpreferences = {\n\t\t\t\t\t\tcanSave = 1;\n\t\t\t\t\t\tfnmatch = \"\";\n\t\t\t\t\t\timage = SmartFolder;\n\t\t\t\t\t\tisLeaf = 0;\n\t\t\t\t\t\trecursive = 1;\n\t\t\t\t\t\tregex = \"?*\\\\.[mcMC]\";\n\t\t\t\t\t\troot = \"<PROJECT>\";\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t);\n\t\t\tPBXWorkspaceContents = (\n\t\t\t\t{\n\t\t\t\t\tPBXProjectWorkspaceModule_StateKey_Rev39 = {\n\t\t\t\t\t\tPBXProjectWorkspaceModule_DataSourceSelectionKey_Rev6 = {\n\t\t\t\t\t\t\tBoundsStr = \"{{0, 0}, {823, 735}}\";\n\t\t\t\t\t\t\tRows = (\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tVisibleRectStr = \"{{0, 0}, {823, 735}}\";\n\t\t\t\t\t\t};\n\t\t\t\t\t\tPBXProjectWorkspaceModule_EditorOpen = false;\n\t\t\t\t\t\tPBXProjectWorkspaceModule_EmbeddedNavigatorGroup = {\n\t\t\t\t\t\t\tPBXSplitModuleInNavigatorKey = {\n\t\t\t\t\t\t\t\tSplitCount = 1;\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t};\n\t\t\t\t\t\tPBXProjectWorkspaceModule_GeometryKey_Rev15 = {\n\t\t\t\t\t\t\tPBXProjectWorkspaceModule_SGTM_Geometry = {\n\t\t\t\t\t\t\t\t_collapsingFrameDimension = 0;\n\t\t\t\t\t\t\t\t_indexOfCollapsedView = 0;\n\t\t\t\t\t\t\t\t_percentageOfCollapsedView = 0;\n\t\t\t\t\t\t\t\tsizes = (\n\t\t\t\t\t\t\t\t\t\"{{0, 0}, {210, 752}}\",\n\t\t\t\t\t\t\t\t\t\"{{210, 0}, {838, 752}}\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t};\n\t\t\t\t\t\tPBXProjectWorkspaceModule_OldDetailFrame = \"{{0, 0}, {838, 752}}\";\n\t\t\t\t\t\tPBXProjectWorkspaceModule_OldEditorFrame = \"{{0, 0}, {750, 480}}\";\n\t\t\t\t\t\tPBXProjectWorkspaceModule_OldSuperviewFrame = \"{{210, 0}, {838, 752}}\";\n\t\t\t\t\t\tPBXProjectWorkspaceModule_SGTM = {\n\t\t\t\t\t\t\tPBXBottomSmartGroupGIDs = (\n\t\t\t\t\t\t\t\t1C37FBAC04509CD000000102,\n\t\t\t\t\t\t\t\t1C37FAAC04509CD000000102,\n\t\t\t\t\t\t\t\t1C08E77C0454961000C914BD,\n\t\t\t\t\t\t\t\t1CC0EA4004350EF90044410B,\n\t\t\t\t\t\t\t\t1CC0EA4004350EF90041110B,\n\t\t\t\t\t\t\t\t1C37FABC05509CD000000102,\n\t\t\t\t\t\t\t\t1C37FABC05539CD112110102,\n\t\t\t\t\t\t\t\tE2644B35053B69B200211256,\n\t\t\t\t\t\t\t\t1C37FABC04509CD000100104,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tPBXSmartGroupTreeModuleColumnData = {\n\t\t\t\t\t\t\t\tPBXSmartGroupTreeModuleColumnWidthsKey = (\n\t\t\t\t\t\t\t\t\t193,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tPBXSmartGroupTreeModuleColumnsKey_v4 = (\n\t\t\t\t\t\t\t\t\tMainColumn,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tPBXSmartGroupTreeModuleOutlineStateKey_v7 = {\n\t\t\t\t\t\t\t\tPBXSmartGroupTreeModuleOutlineStateExpansionKey = (\n\t\t\t\t\t\t\t\t\t1C37FBAC04509CD000000102,\n\t\t\t\t\t\t\t\t\t18A3D348065F659F006A719A,\n\t\t\t\t\t\t\t\t\t18A3D35B065F6655006A719A,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tPBXSmartGroupTreeModuleOutlineStateSelectionKey = (\n\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t2,\n\t\t\t\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tPBXSmartGroupTreeModuleOutlineStateVisibleRectKey = \"{{0, 0}, {193, 734}}\";\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tPBXTopSmartGroupGIDs = (\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t};\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t);\n\t\t\t\"PBXWorkspaceContents:PBXConfiguration.PBXModule.PBXBuildResultsModule\" = {\n\t\t\t};\n\t\t\t\"PBXWorkspaceContents:PBXConfiguration.PBXModule.PBXCVSModule\" = {\n\t\t\t};\n\t\t\t\"PBXWorkspaceContents:PBXConfiguration.PBXModule.PBXDebugCLIModule\" = {\n\t\t\t};\n\t\t\t\"PBXWorkspaceContents:PBXConfiguration.PBXModule.PBXNavigatorGroup\" = {\n\t\t\t\tPBXSplitModuleInNavigatorKey = {\n\t\t\t\t\tSplitCount = 1;\n\t\t\t\t};\n\t\t\t};\n\t\t\t\"PBXWorkspaceContents:PBXConfiguration.PBXModule.PBXProjectWorkspaceModule\" = {\n\t\t\t\tPBXProjectWorkspaceModule_StateKey_Rev39 = {\n\t\t\t\t\tPBXProjectWorkspaceModule_DataSourceSelectionKey_Rev6 = {\n\t\t\t\t\t\tBoundsStr = \"{{0, 0}, {851, 4290}}\";\n\t\t\t\t\t\tRows = (\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tVisibleRectStr = \"{{0, 0}, {851, 735}}\";\n\t\t\t\t\t};\n\t\t\t\t\tPBXProjectWorkspaceModule_EditorOpen = false;\n\t\t\t\t\tPBXProjectWorkspaceModule_EmbeddedNavigatorGroup = {\n\t\t\t\t\t\tPBXSplitModuleInNavigatorKey = {\n\t\t\t\t\t\t\tSplitCount = 1;\n\t\t\t\t\t\t};\n\t\t\t\t\t};\n\t\t\t\t\tPBXProjectWorkspaceModule_GeometryKey_Rev15 = {\n\t\t\t\t\t\tPBXProjectWorkspaceModule_SGTM_Geometry = {\n\t\t\t\t\t\t\t_collapsingFrameDimension = 0;\n\t\t\t\t\t\t\t_indexOfCollapsedView = 0;\n\t\t\t\t\t\t\t_percentageOfCollapsedView = 0;\n\t\t\t\t\t\t\tsizes = (\n\t\t\t\t\t\t\t\t\"{{0, 0}, {182, 752}}\",\n\t\t\t\t\t\t\t\t\"{{182, 0}, {866, 752}}\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t};\n\t\t\t\t\t};\n\t\t\t\t\tPBXProjectWorkspaceModule_OldDetailFrame = \"{{0, 0}, {866, 752}}\";\n\t\t\t\t\tPBXProjectWorkspaceModule_OldEditorFrame = \"{{0, 0}, {750, 480}}\";\n\t\t\t\t\tPBXProjectWorkspaceModule_OldSuperviewFrame = \"{{182, 0}, {866, 752}}\";\n\t\t\t\t\tPBXProjectWorkspaceModule_SGTM = {\n\t\t\t\t\t\tPBXBottomSmartGroupGIDs = (\n\t\t\t\t\t\t\t1C37FBAC04509CD000000102,\n\t\t\t\t\t\t\t1C37FAAC04509CD000000102,\n\t\t\t\t\t\t\t1C08E77C0454961000C914BD,\n\t\t\t\t\t\t\t1CC0EA4004350EF90044410B,\n\t\t\t\t\t\t\t1CC0EA4004350EF90041110B,\n\t\t\t\t\t\t\t1C37FABC05509CD000000102,\n\t\t\t\t\t\t\t1C37FABC05539CD112110102,\n\t\t\t\t\t\t\tE2644B35053B69B200211256,\n\t\t\t\t\t\t\t1C37FABC04509CD000100104,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tPBXSmartGroupTreeModuleColumnData = {\n\t\t\t\t\t\t\tPBXSmartGroupTreeModuleColumnWidthsKey = (\n\t\t\t\t\t\t\t\t165,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tPBXSmartGroupTreeModuleColumnsKey_v4 = (\n\t\t\t\t\t\t\t\tMainColumn,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t};\n\t\t\t\t\t\tPBXSmartGroupTreeModuleOutlineStateKey_v7 = {\n\t\t\t\t\t\t\tPBXSmartGroupTreeModuleOutlineStateExpansionKey = (\n\t\t\t\t\t\t\t\t1C37FBAC04509CD000000102,\n\t\t\t\t\t\t\t\t18A3D340065F651C006A719A,\n\t\t\t\t\t\t\t\t18A3D341065F651D006A719A,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tPBXSmartGroupTreeModuleOutlineStateSelectionKey = (\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tPBXSmartGroupTreeModuleOutlineStateVisibleRectKey = \"{{0, 0}, {165, 734}}\";\n\t\t\t\t\t\t};\n\t\t\t\t\t\tPBXTopSmartGroupGIDs = (\n\t\t\t\t\t\t);\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t};\n\t\t\tPBXWorkspaceGeometries = (\n\t\t\t\t{\n\t\t\t\t\tFrame = \"{{0, 0}, {1048, 752}}\";\n\t\t\t\t\tPBXProjectWorkspaceModule_GeometryKey_Rev15 = {\n\t\t\t\t\t};\n\t\t\t\t\tRubberWindowFrame = \"17 182 1048 794 0 0 1680 1028 \";\n\t\t\t\t},\n\t\t\t);\n\t\t\t\"PBXWorkspaceGeometries:PBXConfiguration.PBXModule.PBXBuildResultsModule\" = {\n\t\t\t\tFrame = \"{{0, 0}, {755, 578}}\";\n\t\t\t\tPBXModuleWindowStatusBarHidden = YES;\n\t\t\t\tRubberWindowFrame = \"612 317 755 599 0 0 1680 1028 \";\n\t\t\t};\n\t\t\t\"PBXWorkspaceGeometries:PBXConfiguration.PBXModule.PBXCVSModule\" = {\n\t\t\t\tFrame = \"{{0, 0}, {482, 276}}\";\n\t\t\t\tRubberWindowFrame = \"590 449 482 318 0 0 1680 1028 \";\n\t\t\t};\n\t\t\t\"PBXWorkspaceGeometries:PBXConfiguration.PBXModule.PBXDebugCLIModule\" = {\n\t\t\t\tFrame = \"{{0, 0}, {400, 201}}\";\n\t\t\t\tPBXModuleWindowStatusBarHidden = YES;\n\t\t\t\tRubberWindowFrame = \"50 1000 400 222 0 0 1680 1028 \";\n\t\t\t};\n\t\t\t\"PBXWorkspaceGeometries:PBXConfiguration.PBXModule.PBXNavigatorGroup\" = {\n\t\t\t\tFrame = \"{{0, 0}, {750, 460}}\";\n\t\t\t\tRubberWindowFrame = \"428 357 750 502 0 0 1680 1028 \";\n\t\t\t};\n\t\t\t\"PBXWorkspaceGeometries:PBXConfiguration.PBXModule.PBXProjectWorkspaceModule\" = {\n\t\t\t\tFrame = \"{{0, 0}, {1048, 752}}\";\n\t\t\t\tPBXProjectWorkspaceModule_GeometryKey_Rev15 = {\n\t\t\t\t\tPBXProjectWorkspaceModule_BuildResultsWindowVisible = true;\n\t\t\t\t};\n\t\t\t\tRubberWindowFrame = \"17 182 1048 794 0 0 1680 1028 \";\n\t\t\t};\n\t\t\tPBXWorkspaceStateSaveDate = 106915007;\n\t\t};\n\t\tsourceControlManager = 1895FF4B065E294000F8B3F4;\n\t\tuserBuildSettings = {\n\t\t};\n\t};\n\t0654BA5CFE8ECEE0C697A12F = {\n\t\tactiveExec = 0;\n\t\texecutables = (\n\t\t\t1895FF2F065E291B00F8B3F4,\n\t\t);\n\t};\n\t1895FF2F065E291B00F8B3F4 = {\n\t\tactiveArgIndex = 2147483647;\n\t\tactiveArgIndices = (\n\t\t);\n\t\targumentStrings = (\n\t\t);\n\t\tconfigStateDict = {\n\t\t};\n\t\tdebuggerPlugin = GDBDebugging;\n\t\tdylibVariantSuffix = \"\";\n\t\tenableDebugStr = 1;\n\t\tenvironmentEntries = (\n\t\t);\n\t\tisa = PBXExecutable;\n\t\tname = \"Quake3 (Application)\";\n\t\tshlibInfoDictList = (\n\t\t);\n\t\tsourceDirectories = (\n\t\t);\n\t};\n\t1895FF30065E291B00F8B3F4 = {\n\t\tactiveArgIndex = 2147483647;\n\t\tactiveArgIndices = (\n\t\t);\n\t\targumentStrings = (\n\t\t);\n\t\tconfigStateDict = {\n\t\t};\n\t\tdebuggerPlugin = GDBDebugging;\n\t\tenableDebugStr = 1;\n\t\tenvironmentEntries = (\n\t\t);\n\t\tisa = PBXExecutable;\n\t\tname = \"Dedicated Server G4\";\n\t\tshlibInfoDictList = (\n\t\t);\n\t\tsourceDirectories = (\n\t\t);\n\t};\n\t1895FF31065E291B00F8B3F4 = {\n\t\tactiveArgIndex = 2147483647;\n\t\tactiveArgIndices = (\n\t\t);\n\t\targumentStrings = (\n\t\t);\n\t\tconfigStateDict = {\n\t\t};\n\t\tdebuggerPlugin = GDBDebugging;\n\t\tenableDebugStr = 1;\n\t\tenvironmentEntries = (\n\t\t);\n\t\tisa = PBXExecutable;\n\t\tname = \"Quake3 G4 (Application)\";\n\t\tshlibInfoDictList = (\n\t\t);\n\t\tsourceDirectories = (\n\t\t);\n\t};\n\t1895FF35065E291B00F8B3F4 = {\n\t\tactiveArgIndex = 2147483647;\n\t\tactiveArgIndices = (\n\t\t);\n\t\targumentStrings = (\n\t\t);\n\t\tconfigStateDict = {\n\t\t};\n\t\tdebuggerPlugin = GDBDebugging;\n\t\tenableDebugStr = 1;\n\t\tenvironmentEntries = (\n\t\t);\n\t\tisa = PBXExecutable;\n\t\tname = \"Dedicated Server\";\n\t\tshlibInfoDictList = (\n\t\t);\n\t\tsourceDirectories = (\n\t\t);\n\t};\n\t1895FF4B065E294000F8B3F4 = {\n\t\tisa = PBXSourceControlManager;\n\t\tscmConfiguration = {\n\t\t};\n\t\tscmType = scm.cvs;\n\t};\n\t1895FF4C065E294000F8B3F4 = {\n\t\tindexTemplatePath = \"\";\n\t\tisa = PBXCodeSenseManager;\n\t\tusesDefaults = 1;\n\t\twantsCodeCompletion = 1;\n\t\twantsCodeCompletionAutoPopup = 0;\n\t\twantsCodeCompletionAutoSuggestions = 0;\n\t\twantsCodeCompletionCaseSensitivity = 1;\n\t\twantsCodeCompletionOnlyMatchingItems = 1;\n\t\twantsCodeCompletionParametersIncluded = 1;\n\t\twantsCodeCompletionPlaceholdersInserted = 1;\n\t\twantsCodeCompletionTabCompletes = 1;\n\t\twantsIndex = 1;\n\t};\n\t4FF0904804896C0E00030DA8 = {\n\t\tactiveExec = 0;\n\t\texecutables = (\n\t\t\t1895FF31065E291B00F8B3F4,\n\t\t);\n\t};\n\t4FF0912704896C1600030DA8 = {\n\t\tactiveExec = 0;\n\t\texecutables = (\n\t\t\t1895FF30065E291B00F8B3F4,\n\t\t);\n\t};\n}\n"
  },
  {
    "path": "code/macosx/Quake3.pbproj/project.pbxproj",
    "content": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 39;\n\tobjects = {\n\t\t00E9D914FEDB4D29C697A12F = {\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = wrapper.framework;\n\t\t\tname = CoreAudio.framework;\n\t\t\tpath = /System/Library/Frameworks/CoreAudio.framework;\n\t\t\trefType = 0;\n\t\t\tsourceTree = \"<absolute>\";\n\t\t};\n\t\t00E9D91DFEDB5295C697A12F = {\n\t\t\tfileRef = 00E9D914FEDB4D29C697A12F;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t00F5ED38FEBA95B7C697A12F = {\n\t\t\tbuildPhases = (\n\t\t\t\t00F5ED39FEBA95B7C697A12F,\n\t\t\t\t00F5ED55FEBA95B7C697A12F,\n\t\t\t\t00F5ED56FEBA95B7C697A12F,\n\t\t\t\t00F5ED77FEBA95B7C697A12F,\n\t\t\t\t00F5ED78FEBA95B7C697A12F,\n\t\t\t);\n\t\t\tbuildSettings = {\n\t\t\t\tFRAMEWORK_SEARCH_PATHS = \"\";\n\t\t\t\tHEADER_SEARCH_PATHS = \"\";\n\t\t\t\tINSTALL_PATH = \"/Users/Shared/$(USER)/InstalledProducts\";\n\t\t\t\tLIBRARY_SEARCH_PATHS = \"\";\n\t\t\t\tOTHER_LDFLAGS = \"-bundle -undefined error\";\n\t\t\t\tOTHER_REZFLAGS = \"\";\n\t\t\t\tPRODUCT_NAME = qagame;\n\t\t\t\tPROFILE_FLAGS = \"\";\n\t\t\t\tSECTORDER_FLAGS = \"\";\n\t\t\t\tWARNING_CFLAGS = \"-Wall -Wno-four-char-constants -Wno-unknown-pragmas\";\n\t\t\t\tWRAPPER_EXTENSION = bundle;\n\t\t\t};\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tisa = PBXBundleTarget;\n\t\t\tname = qagame;\n\t\t\tproductInstallPath = \"/Users/Shared/$(USER)/InstalledProducts\";\n\t\t\tproductName = game;\n\t\t\tproductReference = 07F3F507FFE98E8EC697A10E;\n\t\t\tproductSettingsXML = \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\n<!DOCTYPE plist PUBLIC \\\"-//Apple Computer//DTD PLIST 1.0//EN\\\" \\\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\\\">\n<plist version=\\\"1.0\\\">\n<dict>\n\t<key>CFBundleDevelopmentRegion</key>\n\t<string>English</string>\n\t<key>CFBundleExecutable</key>\n\t<string>qagame</string>\n\t<key>CFBundleGetInfoString</key>\n\t<string>Quake 3 Arena (1.16)</string>\n\t<key>CFBundleIconFile</key>\n\t<string>Quake3.icns</string>\n\t<key>CFBundleIdentifier</key>\n\t<string></string>\n\t<key>CFBundleInfoDictionaryVersion</key>\n\t<string>6.0</string>\n\t<key>CFBundleName</key>\n\t<string></string>\n\t<key>CFBundlePackageType</key>\n\t<string>APPL</string>\n\t<key>CFBundleShortVersionString</key>\n\t<string>1.16</string>\n\t<key>CFBundleSignature</key>\n\t<string>????</string>\n\t<key>CFBundleVersion</key>\n\t<string>0.0.1d1</string>\n</dict>\n</plist>\n\";\n\t\t};\n\t\t00F5ED39FEBA95B7C697A12F = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t13380E0F00ADFAACC697A10E,\n\t\t\t\t13380E1300ADFAD5C697A10E,\n\t\t\t\t13380E1500ADFB0CC697A10E,\n\t\t\t\t13380E1700ADFBFDC697A10E,\n\t\t\t\t13380E1900ADFC10C697A10E,\n\t\t\t\t13380E1B00ADFC22C697A10E,\n\t\t\t\t13380E1D00ADFC32C697A10E,\n\t\t\t\t13380E1F00ADFC43C697A10E,\n\t\t\t\t13380E2500ADFCA7C697A10E,\n\t\t\t);\n\t\t\tisa = PBXHeadersBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t00F5ED55FEBA95B7C697A12F = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t00F5ED56FEBA95B7C697A12F = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t13380E0900ADF941C697A10E,\n\t\t\t\t13380E0B00ADFA16C697A10E,\n\t\t\t\t13380E0C00ADFA72C697A10E,\n\t\t\t\t13380E0D00ADFA94C697A10E,\n\t\t\t\t13380E0E00ADFA9EC697A10E,\n\t\t\t\t13380E1000ADFAACC697A10E,\n\t\t\t\t13380E1100ADFAACC697A10E,\n\t\t\t\t13380E1200ADFACAC697A10E,\n\t\t\t\t13380E1400ADFAD5C697A10E,\n\t\t\t\t13380E1600ADFB0CC697A10E,\n\t\t\t\t13380E1800ADFBFDC697A10E,\n\t\t\t\t13380E1A00ADFC10C697A10E,\n\t\t\t\t13380E1C00ADFC22C697A10E,\n\t\t\t\t13380E1E00ADFC32C697A10E,\n\t\t\t\t13380E2000ADFC43C697A10E,\n\t\t\t\t13380E2100ADFC59C697A10E,\n\t\t\t\t13380E2200ADFC78C697A10E,\n\t\t\t\t13380E2300ADFC85C697A10E,\n\t\t\t\t13380E2400ADFC9CC697A10E,\n\t\t\t\t13380E2600ADFCA7C697A10E,\n\t\t\t\t13380E2700ADFCBDC697A10E,\n\t\t\t\t13380E2800ADFCC8C697A10E,\n\t\t\t\t13380E2900ADFCD1C697A10E,\n\t\t\t\t13380E2A00ADFCEBC697A10E,\n\t\t\t\t13380E2B00ADFCF6C697A10E,\n\t\t\t\t13380E2C00ADFD01C697A10E,\n\t\t\t\t13380E2D00ADFD1FC697A10E,\n\t\t\t\t13380E2E00ADFD28C697A10E,\n\t\t\t\t13380E2F00ADFD38C697A10E,\n\t\t\t\t13380E3000ADFD46C697A10E,\n\t\t\t\t13380E3100ADFD58C697A10E,\n\t\t\t\t13380E3200ADFD71C697A10E,\n\t\t\t\t13380E3300ADFD85C697A10E,\n\t\t\t);\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t00F5ED77FEBA95B7C697A12F = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t00F5ED78FEBA95B7C697A12F = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tisa = PBXRezBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t00F5ED90FEBA9615C697A12F = {\n\t\t\tbuildPhases = (\n\t\t\t\t00F5ED91FEBA9615C697A12F,\n\t\t\t\t00F5ED92FEBA9615C697A12F,\n\t\t\t\t00F5ED93FEBA9615C697A12F,\n\t\t\t\t00F5ED94FEBA9615C697A12F,\n\t\t\t\t00F5ED95FEBA9615C697A12F,\n\t\t\t);\n\t\t\tbuildSettings = {\n\t\t\t\tFRAMEWORK_SEARCH_PATHS = \"\";\n\t\t\t\tHEADER_SEARCH_PATHS = \"\";\n\t\t\t\tINSTALL_PATH = \"/Users/Shared/$(USER)/InstalledProducts\";\n\t\t\t\tLIBRARY_SEARCH_PATHS = \"\";\n\t\t\t\tOTHER_LDFLAGS = \"-bundle -undefined error\";\n\t\t\t\tOTHER_REZFLAGS = \"\";\n\t\t\t\tPRODUCT_NAME = cgame;\n\t\t\t\tPROFILE_FLAGS = \"\";\n\t\t\t\tSECTORDER_FLAGS = \"\";\n\t\t\t\tWARNING_CFLAGS = \"-Wall -Wno-four-char-constants -Wno-unknown-pragmas\";\n\t\t\t\tWRAPPER_EXTENSION = bundle;\n\t\t\t};\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tisa = PBXBundleTarget;\n\t\t\tname = cgame;\n\t\t\tproductInstallPath = \"/Users/Shared/$(USER)/InstalledProducts\";\n\t\t\tproductName = cgame;\n\t\t\tproductReference = 07F3F508FFE98E8EC697A10E;\n\t\t\tproductSettingsXML = \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\n<!DOCTYPE plist PUBLIC \\\"-//Apple Computer//DTD PLIST 1.0//EN\\\" \\\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\\\">\n<plist version=\\\"1.0\\\">\n<dict>\n\t<key>CFBundleDevelopmentRegion</key>\n\t<string>English</string>\n\t<key>CFBundleExecutable</key>\n\t<string></string>\n\t<key>CFBundleGetInfoString</key>\n\t<string></string>\n\t<key>CFBundleIconFile</key>\n\t<string></string>\n\t<key>CFBundleIdentifier</key>\n\t<string></string>\n\t<key>CFBundleInfoDictionaryVersion</key>\n\t<string>6.0</string>\n\t<key>CFBundleName</key>\n\t<string></string>\n\t<key>CFBundlePackageType</key>\n\t<string>BNDL</string>\n\t<key>CFBundleShortVersionString</key>\n\t<string></string>\n\t<key>CFBundleSignature</key>\n\t<string>????</string>\n\t<key>CFBundleVersion</key>\n\t<string>0.0.1d1</string>\n</dict>\n</plist>\n\";\n\t\t};\n\t\t00F5ED91FEBA9615C697A12F = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t13380E3600ADFDCFC697A10E,\n\t\t\t\t13380E5100AE0235C697A10E,\n\t\t\t);\n\t\t\tisa = PBXHeadersBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t00F5ED92FEBA9615C697A12F = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t00F5ED93FEBA9615C697A12F = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t13380E3400ADFDA1C697A10E,\n\t\t\t\t13380E3500ADFDA1C697A10E,\n\t\t\t\t13380E3700ADFDCFC697A10E,\n\t\t\t\t13380E3800ADFDCFC697A10E,\n\t\t\t\t13380E3900ADFDE1C697A10E,\n\t\t\t\t13380E3B00ADFE0CC697A10E,\n\t\t\t\t13380E3C00ADFE1EC697A10E,\n\t\t\t\t13380E3D00ADFE24C697A10E,\n\t\t\t\t13380E3E00ADFE3DC697A10E,\n\t\t\t\t13380E3F00ADFE4AC697A10E,\n\t\t\t\t13380E4000ADFE58C697A10E,\n\t\t\t\t13380E4100ADFE6BC697A10E,\n\t\t\t\t13380E4200ADFE7AC697A10E,\n\t\t\t\t13380E4300ADFE88C697A10E,\n\t\t\t\t13380E4400ADFE97C697A10E,\n\t\t\t\t13380E4500ADFEA7C697A10E,\n\t\t\t\t13380E4600ADFEB8C697A10E,\n\t\t\t\t13380E4700ADFEC9C697A10E,\n\t\t\t\t13380E4800ADFED7C697A10E,\n\t\t\t\t13380E4900ADFEE7C697A10E,\n\t\t\t\t13380E4A00ADFEF5C697A10E,\n\t\t\t\t13380E4B00ADFF05C697A10E,\n\t\t\t\t13380E4C00ADFF27C697A10E,\n\t\t\t\t13380E4F00AE0112C697A10E,\n\t\t\t\t13380E5000AE020FC697A10E,\n\t\t\t\t13380E5200AE0235C697A10E,\n\t\t\t);\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t00F5ED94FEBA9615C697A12F = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t00F5ED95FEBA9615C697A12F = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tisa = PBXRezBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n//000\n//001\n//002\n//003\n//004\n//010\n//011\n//012\n//013\n//014\n\t\t011F78F200B25B65C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = macosx_qgl.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t011F78F300B25B66C697A10E = {\n\t\t\tfileRef = 011F78F200B25B65C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t012AD90700868211C697A10E = {\n\t\t\tchildren = (\n\t\t\t\t012AD90800868211C697A10E,\n\t\t\t\t012AD90900868211C697A10E,\n\t\t\t\t012AD90A00868211C697A10E,\n\t\t\t\t012AD90B00868211C697A10E,\n\t\t\t\t012AD90C00868211C697A10E,\n\t\t\t\t012AD90D00868211C697A10E,\n\t\t\t\t012AD90E00868211C697A10E,\n\t\t\t\t012AD90F00868211C697A10E,\n\t\t\t\t012AD91000868211C697A10E,\n\t\t\t\t012AD91100868211C697A10E,\n\t\t\t\t012AD91200868211C697A10E,\n\t\t\t\t012AD91300868211C697A10E,\n\t\t\t\t012AD91400868211C697A10E,\n\t\t\t\t012AD91500868211C697A10E,\n\t\t\t\t012AD91600868211C697A10E,\n\t\t\t\t012AD91700868211C697A10E,\n\t\t\t\t012AD91800868211C697A10E,\n\t\t\t\t012AD91900868211C697A10E,\n\t\t\t\t012AD91A00868211C697A10E,\n\t\t\t\t012AD91B00868211C697A10E,\n\t\t\t\t012AD91C00868211C697A10E,\n\t\t\t\t012AD91D00868211C697A10E,\n\t\t\t\t012AD91E00868211C697A10E,\n\t\t\t\t012AD91F00868211C697A10E,\n\t\t\t\t012AD92000868211C697A10E,\n\t\t\t\t012AD92100868211C697A10E,\n\t\t\t\t012AD92200868211C697A10E,\n\t\t\t\t012AD92300868211C697A10E,\n\t\t\t\t012AD92400868211C697A10E,\n\t\t\t\t012AD92500868211C697A10E,\n\t\t\t\t012AD92600868211C697A10E,\n\t\t\t\t012AD92700868211C697A10E,\n\t\t\t\t012AD92800868211C697A10E,\n\t\t\t\t012AD92900868211C697A10E,\n\t\t\t\t012AD92A00868211C697A10E,\n\t\t\t\t012AD92B00868211C697A10E,\n\t\t\t\t012AD92C00868211C697A10E,\n\t\t\t\t012AD92D00868211C697A10E,\n\t\t\t\t012AD92E00868211C697A10E,\n\t\t\t\t012AD92F00868211C697A10E,\n\t\t\t\t012AD93000868211C697A10E,\n\t\t\t\t012AD93100868211C697A10E,\n\t\t\t\t012AD93200868211C697A10E,\n\t\t\t\t012AD93300868211C697A10E,\n\t\t\t\t012AD93400868211C697A10E,\n\t\t\t\t012AD93500868211C697A10E,\n\t\t\t\t012AD93600868211C697A10E,\n\t\t\t\t012AD93700868211C697A10E,\n\t\t\t\t012AD93800868211C697A10E,\n\t\t\t\t012AD93900868211C697A10E,\n\t\t\t\t012AD93A00868211C697A10E,\n\t\t\t\t012AD93B00868211C697A10E,\n\t\t\t\t012AD93C00868211C697A10E,\n\t\t\t);\n\t\t\tisa = PBXGroup;\n\t\t\tpath = botlib;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD90800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = aasfile.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD90900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_aas_bsp.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD90A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_aas_bspq3.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD90B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_aas_cluster.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD90C00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_aas_cluster.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD90D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_aas_debug.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD90E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_aas_debug.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD90F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_aas_def.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD91000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_aas_entity.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD91100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_aas_entity.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD91200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_aas_file.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD91300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_aas_file.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD91400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_aas_funcs.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD91500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_aas_main.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD91600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_aas_main.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD91700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_aas_move.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD91800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_aas_move.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD91900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_aas_optimize.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD91A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_aas_optimize.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD91B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_aas_reach.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD91C00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_aas_reach.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD91D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_aas_route.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD91E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_aas_route.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD91F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_aas_routealt.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD92000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_aas_routealt.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD92100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_aas_sample.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD92200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_aas_sample.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD92300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_ai_char.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD92400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_ai_chat.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD92500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_ai_gen.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD92600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_ai_goal.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD92700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_ai_move.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD92800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_ai_weap.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD92900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_ai_weight.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD92A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_ai_weight.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD92B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_ea.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD92C00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_interface.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD92D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_interface.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD92E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = l_crc.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD92F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_crc.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD93000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = l_libvar.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD93100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_libvar.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD93200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = l_log.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD93300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_log.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD93400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = l_memory.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD93500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_memory.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD93600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = l_precomp.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD93700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_precomp.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD93800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = l_script.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD93900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_script.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD93A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = l_struct.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD93B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_struct.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD93C00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_utils.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD93D00868211C697A10E = {\n\t\t\tchildren = (\n\t\t\t\t012AD93E00868211C697A10E,\n\t\t\t\t012AD93F00868211C697A10E,\n\t\t\t\t012AD94000868211C697A10E,\n\t\t\t\t012AD94100868211C697A10E,\n\t\t\t\t012AD94200868211C697A10E,\n\t\t\t\t012AD94300868211C697A10E,\n\t\t\t\t012AD94400868211C697A10E,\n\t\t\t\t012AD94500868211C697A10E,\n\t\t\t\t012AD94600868211C697A10E,\n\t\t\t\t012AD94700868211C697A10E,\n\t\t\t\t012AD94800868211C697A10E,\n\t\t\t\t012AD94900868211C697A10E,\n\t\t\t\t012AD94A00868211C697A10E,\n\t\t\t\t012AD94B00868211C697A10E,\n\t\t\t\t012AD94C00868211C697A10E,\n\t\t\t\t012AD94D00868211C697A10E,\n\t\t\t\t012AD94E00868211C697A10E,\n\t\t\t\t012AD94F00868211C697A10E,\n\t\t\t\t012AD95000868211C697A10E,\n\t\t\t\t012AD95100868211C697A10E,\n\t\t\t\t012AD95200868211C697A10E,\n\t\t\t\t012AD95300868211C697A10E,\n\t\t\t\t012AD95400868211C697A10E,\n\t\t\t\t012AD95500868211C697A10E,\n\t\t\t\t012AD95600868211C697A10E,\n\t\t\t\t012AD95700868211C697A10E,\n\t\t\t\t012AD95800868211C697A10E,\n\t\t\t\t012AD95900868211C697A10E,\n\t\t\t\t012AD95A00868211C697A10E,\n\t\t\t\t012AD95B00868211C697A10E,\n\t\t\t\t012AD95C00868211C697A10E,\n\t\t\t\t012AD95D00868211C697A10E,\n\t\t\t\t012AD95E00868211C697A10E,\n\t\t\t\t012AD95F00868211C697A10E,\n\t\t\t\t012AD96000868211C697A10E,\n\t\t\t\t012AD96100868211C697A10E,\n\t\t\t\t012AD96200868211C697A10E,\n\t\t\t\t012AD96300868211C697A10E,\n\t\t\t\t012AD96400868211C697A10E,\n\t\t\t\t012AD96500868211C697A10E,\n\t\t\t\t012AD96600868211C697A10E,\n\t\t\t\t012AD96700868211C697A10E,\n\t\t\t\t012AD96800868211C697A10E,\n\t\t\t\t012AD96900868211C697A10E,\n\t\t\t\t012AD96A00868211C697A10E,\n\t\t\t\t012AD96B00868211C697A10E,\n\t\t\t\t012AD96C00868211C697A10E,\n\t\t\t\t012AD96D00868211C697A10E,\n\t\t\t\t012AD96E00868211C697A10E,\n\t\t\t\t012AD96F00868211C697A10E,\n\t\t\t\t012AD97000868211C697A10E,\n\t\t\t\t012AD97100868211C697A10E,\n\t\t\t\t012AD97200868211C697A10E,\n\t\t\t\t012AD97300868211C697A10E,\n\t\t\t\t012AD97400868211C697A10E,\n\t\t\t\t012AD97500868211C697A10E,\n\t\t\t\t012AD97600868211C697A10E,\n\t\t\t\t012AD97700868211C697A10E,\n\t\t\t\t012AD97800868211C697A10E,\n\t\t\t\t012AD97900868211C697A10E,\n\t\t\t\t012AD97A00868211C697A10E,\n\t\t\t\t012AD97B00868211C697A10E,\n\t\t\t\t012AD97C00868211C697A10E,\n\t\t\t\t012AD97D00868211C697A10E,\n\t\t\t\t012AD97E00868211C697A10E,\n\t\t\t\t012AD97F00868211C697A10E,\n\t\t\t\t012AD98000868211C697A10E,\n\t\t\t\t012AD98100868211C697A10E,\n\t\t\t\t012AD98200868211C697A10E,\n\t\t\t\t012AD98300868211C697A10E,\n\t\t\t\t012AD98400868211C697A10E,\n\t\t\t\t012AD98500868211C697A10E,\n\t\t\t\t012AD98600868211C697A10E,\n\t\t\t\t012AD98700868211C697A10E,\n\t\t\t\t012AD98800868211C697A10E,\n\t\t\t\t012AD98900868211C697A10E,\n\t\t\t\t012AD98A00868211C697A10E,\n\t\t\t\t012AD98B00868211C697A10E,\n\t\t\t\t012AD98C00868211C697A10E,\n\t\t\t);\n\t\t\tisa = PBXGroup;\n\t\t\tpath = bspc;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD93E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = _files.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD93F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = aas_areamerging.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD94000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = aas_areamerging.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD94100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = aas_cfg.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD94200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = aas_cfg.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD94300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = aas_create.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD94400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = aas_create.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD94500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = aas_edgemelting.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD94600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = aas_edgemelting.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD94700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = aas_facemerging.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD94800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = aas_facemerging.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD94900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = aas_file.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD94A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = aas_file.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD94B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = aas_gsubdiv.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD94C00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = aas_gsubdiv.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD94D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = aas_map.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD94E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = aas_map.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD94F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = aas_prunenodes.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD95000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = aas_prunenodes.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD95100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = aas_store.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD95200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = aas_store.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD95300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = aasfile.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD95400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = be_aas_bspc.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD95500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_aas_bspc.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD95600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = brushbsp.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD95700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = bspc.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD95800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cfgq3.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD95900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = csg.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD95A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = faces.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD95B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = gldraw.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD95C00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = glfile.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD95D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = l_bsp_ent.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD95E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_bsp_ent.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD95F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = l_bsp_hl.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD96000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_bsp_hl.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD96100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = l_bsp_q1.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD96200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_bsp_q1.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD96300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = l_bsp_q2.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD96400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_bsp_q2.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD96500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = l_bsp_q3.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD96600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_bsp_q3.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD96700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = l_bsp_sin.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD96800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_bsp_sin.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD96900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = l_cmd.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD96A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_cmd.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD96B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = l_log.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD96C00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_log.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD96D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = l_math.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD96E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_math.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD96F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = l_mem.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD97000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_mem.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD97100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = l_poly.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD97200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_poly.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD97300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = l_qfiles.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD97400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_qfiles.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD97500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = l_threads.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD97600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_threads.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD97700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = l_utils.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD97800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = l_utils.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD97900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = leakfile.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD97A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = map.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD97B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = map_hl.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD97C00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = map_q1.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD97D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = map_q2.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD97E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = map_q3.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD97F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = map_sin.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD98000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = nodraw.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD98100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = portals.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD98200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = prtfile.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD98300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = q2files.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD98400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = q3files.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD98500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = qbsp.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD98600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = qfiles.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD98700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = sinfiles.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD98800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tetrahedron.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD98900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = tetrahedron.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD98A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = textures.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD98B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tree.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD98C00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = writebsp.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD98D00868211C697A10E = {\n\t\t\tchildren = (\n\t\t\t\t012AD98E00868211C697A10E,\n\t\t\t\t012AD98F00868211C697A10E,\n\t\t\t\t012AD99000868211C697A10E,\n\t\t\t\t012AD99100868211C697A10E,\n\t\t\t\t012AD99200868211C697A10E,\n\t\t\t\t012AD99300868211C697A10E,\n\t\t\t\t012AD99400868211C697A10E,\n\t\t\t\t012AD99500868211C697A10E,\n\t\t\t\t012AD99600868211C697A10E,\n\t\t\t\t012AD99700868211C697A10E,\n\t\t\t\t012AD99800868211C697A10E,\n\t\t\t\t012AD99900868211C697A10E,\n\t\t\t\t012AD99A00868211C697A10E,\n\t\t\t\t012AD99B00868211C697A10E,\n\t\t\t\t012AD99C00868211C697A10E,\n\t\t\t\t012AD99D00868211C697A10E,\n\t\t\t\t012AD99E00868211C697A10E,\n\t\t\t\t012AD99F00868211C697A10E,\n\t\t\t\t012AD9A000868211C697A10E,\n\t\t\t\t012AD9A100868211C697A10E,\n\t\t\t\t012AD9A200868211C697A10E,\n\t\t\t\t012AD9A300868211C697A10E,\n\t\t\t\t012AD9A400868211C697A10E,\n\t\t\t);\n\t\t\tisa = PBXGroup;\n\t\t\tpath = cgame;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD98E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cg_consolecmds.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD98F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cg_draw.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD99000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cg_drawtools.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD99100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cg_effects.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD99200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cg_ents.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD99300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cg_event.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD99400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cg_info.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD99500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = cg_local.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD99600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cg_localents.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD99700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cg_main.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD99800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cg_marks.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD99900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cg_newdraw.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD99A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cg_players.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD99B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cg_playerstate.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD99C00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cg_predict.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD99D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = cg_public.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD99E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cg_scoreboard.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD99F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cg_servercmds.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9A000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cg_snapshot.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9A100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cg_syscalls.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9A200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cg_view.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9A300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cg_weapons.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9A400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = tr_types.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9A500868211C697A10E = {\n\t\t\tchildren = (\n\t\t\t\t012AD9A600868211C697A10E,\n\t\t\t\t012AD9A700868211C697A10E,\n\t\t\t\t012AD9A800868211C697A10E,\n\t\t\t\t012AD9A900868211C697A10E,\n\t\t\t\t012AD9AA00868211C697A10E,\n\t\t\t\t012AD9AB00868211C697A10E,\n\t\t\t\t012AD9AC00868211C697A10E,\n\t\t\t\t012AD9AD00868211C697A10E,\n\t\t\t\t012AD9AE00868211C697A10E,\n\t\t\t\t012AD9AF00868211C697A10E,\n\t\t\t\t012AD9B000868211C697A10E,\n\t\t\t\t012AD9B100868211C697A10E,\n\t\t\t\t012AD9B200868211C697A10E,\n\t\t\t\t012AD9B300868211C697A10E,\n\t\t\t\t012AD9B400868211C697A10E,\n\t\t\t\t012AD9B500868211C697A10E,\n\t\t\t\t012AD9B600868211C697A10E,\n\t\t\t\t012AD9B700868211C697A10E,\n\t\t\t\t012AD9B800868211C697A10E,\n\t\t\t);\n\t\t\tisa = PBXGroup;\n\t\t\tpath = client;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9A600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cl_cgame.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9A700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cl_cin.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9A800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cl_console.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9A900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cl_input.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9AA00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cl_keys.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9AB00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cl_main.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9AC00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cl_net_chan.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9AD00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cl_parse.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9AE00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cl_scrn.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9AF00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cl_ui.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9B000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = client.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9B100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = keys.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9B200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = snd_adpcm.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9B300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = snd_dma.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9B400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = snd_local.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9B500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = snd_mem.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9B600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = snd_mix.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9B700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = snd_public.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012AD9B800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = snd_wavelet.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA2400868211C697A10E = {\n\t\t\tchildren = (\n\t\t\t\t012ADA2500868211C697A10E,\n\t\t\t\t012ADA2600868211C697A10E,\n\t\t\t\t012ADA2700868211C697A10E,\n\t\t\t\t012ADA2800868211C697A10E,\n\t\t\t\t012ADA2900868211C697A10E,\n\t\t\t\t012ADA2A00868211C697A10E,\n\t\t\t\t012ADA2B00868211C697A10E,\n\t\t\t\t012ADA2C00868211C697A10E,\n\t\t\t\t012ADA2D00868211C697A10E,\n\t\t\t\t012ADA2E00868211C697A10E,\n\t\t\t\t012ADA2F00868211C697A10E,\n\t\t\t\t012ADA3000868211C697A10E,\n\t\t\t\t012ADA3100868211C697A10E,\n\t\t\t\t012ADA3200868211C697A10E,\n\t\t\t\t012ADA3300868211C697A10E,\n\t\t\t\t012ADA3400868211C697A10E,\n\t\t\t\t012ADA3500868211C697A10E,\n\t\t\t\t012ADA3600868211C697A10E,\n\t\t\t\t012ADA3700868211C697A10E,\n\t\t\t\t012ADA3800868211C697A10E,\n\t\t\t\t012ADA3900868211C697A10E,\n\t\t\t\t012ADA3A00868211C697A10E,\n\t\t\t\t012ADA3B00868211C697A10E,\n\t\t\t\t012ADA3C00868211C697A10E,\n\t\t\t\t012ADA3D00868211C697A10E,\n\t\t\t\t012ADA3E00868211C697A10E,\n\t\t\t\t012ADA3F00868211C697A10E,\n\t\t\t\t012ADA4000868211C697A10E,\n\t\t\t\t012ADA4100868211C697A10E,\n\t\t\t\t012ADA4200868211C697A10E,\n\t\t\t\t012ADA4300868211C697A10E,\n\t\t\t\t012ADA4400868211C697A10E,\n\t\t\t\t012ADA4500868211C697A10E,\n\t\t\t\t012ADA4600868211C697A10E,\n\t\t\t\t012ADA4700868211C697A10E,\n\t\t\t\t012ADA4800868211C697A10E,\n\t\t\t\t012ADA4900868211C697A10E,\n\t\t\t\t012ADA4A00868211C697A10E,\n\t\t\t\t012ADA4B00868211C697A10E,\n\t\t\t\t012ADA4C00868211C697A10E,\n\t\t\t\t012ADA4D00868211C697A10E,\n\t\t\t\t012ADA4E00868211C697A10E,\n\t\t\t\t012ADA4F00868211C697A10E,\n\t\t\t\t012ADA5000868211C697A10E,\n\t\t\t\t012ADA5100868211C697A10E,\n\t\t\t\t012ADA5200868211C697A10E,\n\t\t\t\t012ADA5300868211C697A10E,\n\t\t\t\t012ADA5400868211C697A10E,\n\t\t\t\t012ADA5500868211C697A10E,\n\t\t\t\t012ADA5600868211C697A10E,\n\t\t\t\t012ADA5700868211C697A10E,\n\t\t\t\t012ADA5800868211C697A10E,\n\t\t\t\t012ADA5900868211C697A10E,\n\t\t\t\t012ADA5A00868211C697A10E,\n\t\t\t\t012ADA5B00868211C697A10E,\n\t\t\t\t012ADA5C00868211C697A10E,\n\t\t\t\t012ADA5D00868211C697A10E,\n\t\t\t\t012ADA5E00868211C697A10E,\n\t\t\t\t012ADA5F00868211C697A10E,\n\t\t\t\t012ADA6000868211C697A10E,\n\t\t\t\t012ADA6100868211C697A10E,\n\t\t\t\t012ADA6200868211C697A10E,\n\t\t\t\t012ADA6300868211C697A10E,\n\t\t\t\t012ADA6400868211C697A10E,\n\t\t\t);\n\t\t\tisa = PBXGroup;\n\t\t\tpath = game;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA2500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ai_chat.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA2600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = ai_chat.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA2700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ai_cmd.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA2800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = ai_cmd.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA2900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ai_dmnet.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA2A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = ai_dmnet.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA2B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ai_dmq3.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA2C00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = ai_dmq3.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA2D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ai_main.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA2E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = ai_main.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA2F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ai_team.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA3000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = ai_team.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA3100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ai_vcmd.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA3200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = ai_vcmd.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA3300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_aas.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA3400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_ai_char.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA3500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_ai_chat.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA3600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_ai_gen.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA3700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_ai_goal.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA3800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_ai_move.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA3900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_ai_weap.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA3A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = be_ea.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA3B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = bg_lib.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA3C00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = bg_lib.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA3D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = bg_local.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA3E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = bg_misc.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA3F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = bg_pmove.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA4000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = bg_public.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA4100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = bg_slidemove.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA4200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = botlib.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA4300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = chars.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA4400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_active.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA4500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_arenas.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA4600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_bot.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA4700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_client.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA4800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_cmds.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA4900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_combat.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA4A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_items.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA4B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = g_local.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA4C00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_main.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA4D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_mem.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA4E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_misc.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA4F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_missile.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA5000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_mover.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA5100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = g_public.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA5200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_rankings.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA5300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = g_rankings.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA5400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_session.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA5500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_spawn.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA5600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_svcmds.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA5700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_syscalls.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA5800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_target.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA5900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_team.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA5A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = g_team.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA5B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_trigger.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA5C00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_utils.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA5D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = g_weapon.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA5E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = inv.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA5F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = match.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA6000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = q_math.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA6100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = q_shared.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA6200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = q_shared.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA6300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = surfaceflags.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA6400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = syn.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA6500868211C697A10E = {\n\t\t\tchildren = (\n\t\t\t\t012ADA6600868211C697A10E,\n\t\t\t\t012ADA6700868211C697A10E,\n\t\t\t\t012ADA6800868211C697A10E,\n\t\t\t\t012ADA6900868211C697A10E,\n\t\t\t\t012ADA6A00868211C697A10E,\n\t\t\t\t012ADA6B00868211C697A10E,\n\t\t\t\t012ADA6C00868211C697A10E,\n\t\t\t\t012ADA6D00868211C697A10E,\n\t\t\t\t012ADA6E00868211C697A10E,\n\t\t\t\t012ADA6F00868211C697A10E,\n\t\t\t\t012ADA7000868211C697A10E,\n\t\t\t\t012ADA7100868211C697A10E,\n\t\t\t\t012ADA7200868211C697A10E,\n\t\t\t\t012ADA7300868211C697A10E,\n\t\t\t\t012ADA7400868211C697A10E,\n\t\t\t\t012ADA7500868211C697A10E,\n\t\t\t\t012ADA7600868211C697A10E,\n\t\t\t\t012ADA7700868211C697A10E,\n\t\t\t\t012ADA7800868211C697A10E,\n\t\t\t\t012ADA7900868211C697A10E,\n\t\t\t\t012ADA7A00868211C697A10E,\n\t\t\t\t012ADA7B00868211C697A10E,\n\t\t\t\t012ADA7C00868211C697A10E,\n\t\t\t\t012ADA7D00868211C697A10E,\n\t\t\t\t012ADA7E00868211C697A10E,\n\t\t\t\t012ADA7F00868211C697A10E,\n\t\t\t\t012ADA8000868211C697A10E,\n\t\t\t\t012ADA8100868211C697A10E,\n\t\t\t\t012ADA8200868211C697A10E,\n\t\t\t\t012ADA8300868211C697A10E,\n\t\t\t\t012ADA8400868211C697A10E,\n\t\t\t\t012ADA8500868211C697A10E,\n\t\t\t\t012ADA8600868211C697A10E,\n\t\t\t\t012ADA8700868211C697A10E,\n\t\t\t\t012ADA8800868211C697A10E,\n\t\t\t\t012ADA8900868211C697A10E,\n\t\t\t\t012ADA8A00868211C697A10E,\n\t\t\t\t012ADA8B00868211C697A10E,\n\t\t\t\t012ADA8C00868211C697A10E,\n\t\t\t\t012ADA8D00868211C697A10E,\n\t\t\t\t012ADA8E00868211C697A10E,\n\t\t\t\t012ADA8F00868211C697A10E,\n\t\t\t\t012ADA9000868211C697A10E,\n\t\t\t\t012ADA9100868211C697A10E,\n\t\t\t\t012ADA9200868211C697A10E,\n\t\t\t\t012ADA9300868211C697A10E,\n\t\t\t\t012ADA9400868211C697A10E,\n\t\t\t\t012ADA9500868211C697A10E,\n\t\t\t\t012ADA9600868211C697A10E,\n\t\t\t\t012ADA9700868211C697A10E,\n\t\t\t\t012ADA9800868211C697A10E,\n\t\t\t\t012ADA9900868211C697A10E,\n\t\t\t\t012ADA9A00868211C697A10E,\n\t\t\t\t012ADA9B00868211C697A10E,\n\t\t\t\t012ADA9C00868211C697A10E,\n\t\t\t\t012ADA9D00868211C697A10E,\n\t\t\t\t012ADA9E00868211C697A10E,\n\t\t\t\t012ADA9F00868211C697A10E,\n\t\t\t\t012ADAA000868211C697A10E,\n\t\t\t\t012ADAA100868211C697A10E,\n\t\t\t\t012ADAA200868211C697A10E,\n\t\t\t\t012ADAA300868211C697A10E,\n\t\t\t);\n\t\t\tisa = PBXGroup;\n\t\t\tpath = \"jpeg-6\";\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA6600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jcapimin.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA6700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jcapistd.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA6800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jccoefct.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA6900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jccolor.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA6A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jcdctmgr.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA6B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jchuff.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA6C00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = jchuff.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA6D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jcinit.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA6E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jcmainct.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA6F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jcmarker.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA7000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jcmaster.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA7100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jcomapi.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA7200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = jconfig.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA7300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jcparam.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA7400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jcphuff.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA7500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jcprepct.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA7600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jcsample.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA7700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jctrans.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA7800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jdapimin.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA7900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jdapistd.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA7A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jdatadst.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA7B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jdatasrc.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA7C00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jdcoefct.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA7D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jdcolor.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA7E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = jdct.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA7F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jddctmgr.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA8000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jdhuff.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA8100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = jdhuff.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA8200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jdinput.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA8300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jdmainct.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA8400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jdmarker.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA8500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jdmaster.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA8600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jdmerge.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA8700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jdphuff.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA8800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jdpostct.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA8900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jdsample.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA8A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jdtrans.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA8B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jerror.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA8C00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = jerror.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA8D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jfdctflt.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA8E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jfdctfst.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA8F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jfdctint.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA9000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jidctflt.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA9100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jidctfst.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA9200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jidctint.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA9300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jidctred.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA9400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = jinclude.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA9500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jload.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA9600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jmemansi.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA9700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jmemdos.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA9800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jmemmgr.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA9900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jmemname.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA9A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jmemnobs.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA9B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = jmemsys.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA9C00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = jmorecfg.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA9D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = jpegint.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA9E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = jpeglib.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADA9F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jpegtran.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAA000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jquant1.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAA100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jquant2.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAA200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = jutils.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAA300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = jversion.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAA400868211C697A10E = {\n\t\t\tchildren = (\n\t\t\t\t012ADAA500868211C697A10E,\n\t\t\t\t012ADAA600868211C697A10E,\n\t\t\t\t012ADAA700868211C697A10E,\n\t\t\t\t012ADAA800868211C697A10E,\n\t\t\t\t012ADAA900868211C697A10E,\n\t\t\t\t012ADAAA00868211C697A10E,\n\t\t\t\t012ADAAB00868211C697A10E,\n\t\t\t\t012ADAAC00868211C697A10E,\n\t\t\t\t012ADAAD00868211C697A10E,\n\t\t\t\t012ADAAE00868211C697A10E,\n\t\t\t\t012ADAAF00868211C697A10E,\n\t\t\t\t012ADAB000868211C697A10E,\n\t\t\t\t012ADAB100868211C697A10E,\n\t\t\t\t012ADAB200868211C697A10E,\n\t\t\t);\n\t\t\tisa = PBXGroup;\n\t\t\tpath = mac;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAA500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = mac_console.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAA600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = mac_event.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAA700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = mac_glimp2.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAA800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = mac_input.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAA900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = mac_local.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAAA00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = mac_main.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAAB00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = mac_net.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAAC00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = mac_snddma.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAAD00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = MacGamma.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAAE00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = MacGamma.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAAF00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = macprefix.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAB000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.rez;\n\t\t\tpath = q3.r;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAB100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = SetupGL.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAB200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = SetupGL.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAB300868211C697A10E = {\n\t\t\tchildren = (\n\t\t\t\t012ADAB400868211C697A10E,\n\t\t\t\t012ADAB500868211C697A10E,\n\t\t\t\t012ADAB600868211C697A10E,\n\t\t\t\t012ADAB700868211C697A10E,\n\t\t\t\t012ADAB800868211C697A10E,\n\t\t\t\t012ADAB900868211C697A10E,\n\t\t\t\t012ADABA00868211C697A10E,\n\t\t\t);\n\t\t\tisa = PBXGroup;\n\t\t\tpath = null;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAB400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = mac_net.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAB500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = null_client.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAB600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = null_glimp.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAB700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = null_input.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAB800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = null_main.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAB900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = null_net.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADABA00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = null_snddma.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADABB00868211C697A10E = {\n\t\t\tchildren = (\n\t\t\t\t012ADABC00868211C697A10E,\n\t\t\t\t012ADABD00868211C697A10E,\n\t\t\t\t012ADABE00868211C697A10E,\n\t\t\t\t012ADABF00868211C697A10E,\n\t\t\t\t012ADAC000868211C697A10E,\n\t\t\t\t012ADAC100868211C697A10E,\n\t\t\t\t012ADAC200868211C697A10E,\n\t\t\t\t012ADAC300868211C697A10E,\n\t\t\t\t012ADAC400868211C697A10E,\n\t\t\t\t012ADAC500868211C697A10E,\n\t\t\t\t012ADAC600868211C697A10E,\n\t\t\t\t012ADAC700868211C697A10E,\n\t\t\t\t012ADAC800868211C697A10E,\n\t\t\t\t012ADAC900868211C697A10E,\n\t\t\t\t012ADACA00868211C697A10E,\n\t\t\t\t012ADACB00868211C697A10E,\n\t\t\t\t012ADACC00868211C697A10E,\n\t\t\t\t012ADACD00868211C697A10E,\n\t\t\t\t012ADACE00868211C697A10E,\n\t\t\t\t012ADACF00868211C697A10E,\n\t\t\t\t012ADAD000868211C697A10E,\n\t\t\t\t012ADAD100868211C697A10E,\n\t\t\t\t012ADAD200868211C697A10E,\n\t\t\t\t012ADAD300868211C697A10E,\n\t\t\t\t012ADAD400868211C697A10E,\n\t\t\t\t012ADAD500868211C697A10E,\n\t\t\t\t012ADAD600868211C697A10E,\n\t\t\t\t012ADAD700868211C697A10E,\n\t\t\t\t012ADAD800868211C697A10E,\n\t\t\t\t012ADAD900868211C697A10E,\n\t\t\t\t012ADADA00868211C697A10E,\n\t\t\t\t012ADADB00868211C697A10E,\n\t\t\t\t012ADADC00868211C697A10E,\n\t\t\t\t012ADADD00868211C697A10E,\n\t\t\t\t012ADADE00868211C697A10E,\n\t\t\t\t012ADADF00868211C697A10E,\n\t\t\t\t012ADAE000868211C697A10E,\n\t\t\t\t012ADAE100868211C697A10E,\n\t\t\t\t012ADAE200868211C697A10E,\n\t\t\t\t012ADAE300868211C697A10E,\n\t\t\t\t012ADAE400868211C697A10E,\n\t\t\t\t012ADAE500868211C697A10E,\n\t\t\t\t012ADAE600868211C697A10E,\n\t\t\t\t012ADAE700868211C697A10E,\n\t\t\t\t012ADAE800868211C697A10E,\n\t\t\t\t012ADAE900868211C697A10E,\n\t\t\t\t012ADAEA00868211C697A10E,\n\t\t\t\t012ADAEB00868211C697A10E,\n\t\t\t);\n\t\t\tisa = PBXGroup;\n\t\t\tpath = q3_ui;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADABC00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = keycodes.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADABD00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_addbots.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADABE00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_atoms.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADABF00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_cdkey.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAC000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_cinematics.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAC100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_confirm.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAC200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_connect.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAC300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_controls2.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAC400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_credits.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAC500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_demo2.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAC600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_display.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAC700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_gameinfo.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAC800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_ingame.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAC900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_loadconfig.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADACA00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = ui_local.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADACB00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_login.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADACC00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_main.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADACD00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_menu.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADACE00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_mfield.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADACF00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_mods.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAD000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_network.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAD100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_options.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAD200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_playermodel.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAD300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_players.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAD400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_playersettings.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAD500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_preferences.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAD600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_qmenu.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAD700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_rankings.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAD800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_rankstatus.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAD900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_removebots.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADADA00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_saveconfig.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADADB00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_serverinfo.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADADC00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_servers2.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADADD00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_setup.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADADE00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_signup.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADADF00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_sound.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAE000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_sparena.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAE100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_specifyleague.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAE200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_specifyserver.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAE300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_splevel.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAE400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_sppostgame.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAE500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_spreset.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAE600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_spskill.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAE700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_startserver.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAE800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = file;\n\t\t\tpath = ui_syscalls.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAE900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_team.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAEA00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_teamorders.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAEB00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_video.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAEC00868211C697A10E = {\n\t\t\tchildren = (\n\t\t\t\t012ADAED00868211C697A10E,\n\t\t\t\t012ADAEE00868211C697A10E,\n\t\t\t\t012ADAEF00868211C697A10E,\n\t\t\t\t012ADAF000868211C697A10E,\n\t\t\t\t012ADAF100868211C697A10E,\n\t\t\t\t012ADAF200868211C697A10E,\n\t\t\t\t012ADAF300868211C697A10E,\n\t\t\t\t012ADAF400868211C697A10E,\n\t\t\t\t012ADAF500868211C697A10E,\n\t\t\t\t012ADAF600868211C697A10E,\n\t\t\t\t012ADAF700868211C697A10E,\n\t\t\t\t012ADAF800868211C697A10E,\n\t\t\t\t012ADAF900868211C697A10E,\n\t\t\t\t016F1B6300ACDA9BC697A10E,\n\t\t\t\t012ADAFA00868211C697A10E,\n\t\t\t\t012ADAFB00868211C697A10E,\n\t\t\t\t012ADAFC00868211C697A10E,\n\t\t\t\t012ADAFD00868211C697A10E,\n\t\t\t\t012ADAFE00868211C697A10E,\n\t\t\t\t012ADAFF00868211C697A10E,\n\t\t\t\t012ADB0000868211C697A10E,\n\t\t\t\t012ADB0100868211C697A10E,\n\t\t\t\t012ADB0200868211C697A10E,\n\t\t\t\t012ADB0300868211C697A10E,\n\t\t\t\t012ADB0400868211C697A10E,\n\t\t\t\t012ADB0500868211C697A10E,\n\t\t\t\t4FB23863047AB9F60098ACF3,\n\t\t\t);\n\t\t\tisa = PBXGroup;\n\t\t\tpath = qcommon;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAED00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cm_load.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAEE00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = cm_local.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAEF00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cm_patch.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAF000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = cm_patch.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAF100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cm_polylib.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAF200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = cm_polylib.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAF300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = cm_public.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAF400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cm_test.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAF500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cm_trace.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAF600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cmd.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAF700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = common.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAF800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = cvar.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAF900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = files.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAFA00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = md4.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAFB00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = msg.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAFC00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = net_chan.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAFD00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = qcommon.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAFE00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = qfiles.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADAFF00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = unzip.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB0000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = unzip.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB0100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = vm.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB0200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = vm_interpreted.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB0300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = vm_local.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB0400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = vm_ppc.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB0500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = vm_x86.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB0600868211C697A10E = {\n\t\t\tchildren = (\n\t\t\t\t012ADB0700868211C697A10E,\n\t\t\t\t012ADB0800868211C697A10E,\n\t\t\t\t012ADB0900868211C697A10E,\n\t\t\t\t012ADB0A00868211C697A10E,\n\t\t\t\t012ADB0B00868211C697A10E,\n\t\t\t\t012ADB0C00868211C697A10E,\n\t\t\t\t012ADB0D00868211C697A10E,\n\t\t\t\t012ADB0E00868211C697A10E,\n\t\t\t\t012ADB0F00868211C697A10E,\n\t\t\t\t012ADB1000868211C697A10E,\n\t\t\t\t012ADB1100868211C697A10E,\n\t\t\t\t012ADB1200868211C697A10E,\n\t\t\t\t012ADB1300868211C697A10E,\n\t\t\t\t012ADB1400868211C697A10E,\n\t\t\t\t012ADB1500868211C697A10E,\n\t\t\t\t012ADB1600868211C697A10E,\n\t\t\t\t012ADB1700868211C697A10E,\n\t\t\t\t012ADB1800868211C697A10E,\n\t\t\t\t012ADB1900868211C697A10E,\n\t\t\t\t012ADB1A00868211C697A10E,\n\t\t\t\t012ADB1B00868211C697A10E,\n\t\t\t\t012ADB1C00868211C697A10E,\n\t\t\t\t012ADB1D00868211C697A10E,\n\t\t\t\t012ADB1E00868211C697A10E,\n\t\t\t\t012ADB1F00868211C697A10E,\n\t\t\t\t012ADB2000868211C697A10E,\n\t\t\t\t012ADB2100868211C697A10E,\n\t\t\t\t012ADB2200868211C697A10E,\n\t\t\t);\n\t\t\tisa = PBXGroup;\n\t\t\tpath = renderer;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB0700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = amd3d.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB0800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = qgl.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB0900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = qgl_linked.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB0A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_animation.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB0B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_backend.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB0C00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tlineEnding = 0;\n\t\t\tpath = tr_bsp.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB0D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_cmds.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB0E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_curve.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB0F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_flares.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB1000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_font.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB1100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_image.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB1200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_init.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB1300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_light.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB1400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = tr_local.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB1500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_main.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB1600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_marks.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB1700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_mesh.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB1800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_model.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB1900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_noise.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB1A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = tr_public.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB1B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_scene.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB1C00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_shade.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB1D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_shade_calc.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB1E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_shader.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB1F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_shadows.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB2000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_sky.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB2100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_surface.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB2200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = tr_world.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB2300868211C697A10E = {\n\t\t\tchildren = (\n\t\t\t\t012ADB2400868211C697A10E,\n\t\t\t\t012ADB2500868211C697A10E,\n\t\t\t\t012ADB2600868211C697A10E,\n\t\t\t\t012ADB2700868211C697A10E,\n\t\t\t\t012ADB2800868211C697A10E,\n\t\t\t\t012ADB2900868211C697A10E,\n\t\t\t\t012ADB2A00868211C697A10E,\n\t\t\t\t012ADB2B00868211C697A10E,\n\t\t\t\t012ADB2C00868211C697A10E,\n\t\t\t\t012ADB2D00868211C697A10E,\n\t\t\t\t012ADB2E00868211C697A10E,\n\t\t\t);\n\t\t\tisa = PBXGroup;\n\t\t\tpath = server;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB2400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = server.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB2500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = sv_bot.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB2600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = sv_ccmds.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB2700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = sv_client.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB2800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = sv_game.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB2900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = sv_init.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB2A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = sv_main.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB2B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = sv_net_chan.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB2C00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = sv_rankings.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB2D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = sv_snapshot.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB2E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = sv_world.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB2F00868211C697A10E = {\n\t\t\tchildren = (\n\t\t\t\t012ADB3000868211C697A10E,\n\t\t\t\t012ADB3100868211C697A10E,\n\t\t\t\t012ADB3200868211C697A10E,\n\t\t\t\t012ADB3300868211C697A10E,\n\t\t\t\t012ADB3400868211C697A10E,\n\t\t\t\t012ADB3500868211C697A10E,\n\t\t\t\t012ADB3600868211C697A10E,\n\t\t\t\t012ADB3700868211C697A10E,\n\t\t\t\t012ADB3800868211C697A10E,\n\t\t\t\t012ADB3900868211C697A10E,\n\t\t\t\t012ADB3A00868211C697A10E,\n\t\t\t\t012ADB3B00868211C697A10E,\n\t\t\t\t012ADB3D00868211C697A10E,\n\t\t\t\t012ADB3E00868211C697A10E,\n\t\t\t\t012ADB3F00868211C697A10E,\n\t\t\t\tF5ED1435037096A001F6289A,\n\t\t\t);\n\t\t\tisa = PBXGroup;\n\t\t\tpath = splines;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB3000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.cpp.cpp;\n\t\t\tpath = math_angles.cpp;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB3100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = math_angles.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB3200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.cpp.cpp;\n\t\t\tpath = math_matrix.cpp;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB3300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = math_matrix.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB3400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.cpp.cpp;\n\t\t\tpath = math_quaternion.cpp;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB3500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = math_quaternion.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB3600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.cpp.cpp;\n\t\t\tpath = math_vector.cpp;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB3700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = math_vector.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB3800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.cpp.cpp;\n\t\t\tpath = q_parse.cpp;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB3900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.cpp.cpp;\n\t\t\tpath = q_shared.cpp;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB3A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.cpp.h;\n\t\t\tpath = q_shared.hpp;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB3B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.cpp.cpp;\n\t\t\tpath = splines.cpp;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB3D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = util_list.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB3E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.cpp.cpp;\n\t\t\tpath = util_str.cpp;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB3F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = util_str.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB4000868211C697A10E = {\n\t\t\tchildren = (\n\t\t\t\t012ADB4100868211C697A10E,\n\t\t\t\t012ADB4200868211C697A10E,\n\t\t\t\t012ADB4300868211C697A10E,\n\t\t\t\t012ADB4400868211C697A10E,\n\t\t\t\t012ADB4500868211C697A10E,\n\t\t\t\t012ADB4600868211C697A10E,\n\t\t\t\t012ADB4700868211C697A10E,\n\t\t\t\t012ADB4800868211C697A10E,\n\t\t\t\t012ADB4900868211C697A10E,\n\t\t\t\t012ADB4A00868211C697A10E,\n\t\t\t\t012ADB4B00868211C697A10E,\n\t\t\t);\n\t\t\tisa = PBXGroup;\n\t\t\tpath = ui;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB4100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = keycodes.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB4200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_atoms.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB4300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_gameinfo.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB4400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = ui_local.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB4500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_main.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB4600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_players.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB4700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = ui_public.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB4800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_shared.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB4900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = ui_shared.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB4A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_syscalls.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB4B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = ui_util.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB4C00868211C697A10E = {\n\t\t\tchildren = (\n\t\t\t\t012ADB4D00868211C697A10E,\n\t\t\t\t012ADB4E00868211C697A10E,\n\t\t\t\t012ADB4F00868211C697A10E,\n\t\t\t\t012ADB5000868211C697A10E,\n\t\t\t\t012ADB5100868211C697A10E,\n\t\t\t\t012ADB5200868211C697A10E,\n\t\t\t\t012ADB5300868211C697A10E,\n\t\t\t\t012ADB5400868211C697A10E,\n\t\t\t\t012ADB5500868211C697A10E,\n\t\t\t\t012ADB5600868211C697A10E,\n\t\t\t\t012ADB5700868211C697A10E,\n\t\t\t\t012ADB5800868211C697A10E,\n\t\t\t\t012ADB5900868211C697A10E,\n\t\t\t);\n\t\t\tisa = PBXGroup;\n\t\t\tpath = unix;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB4D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = linux_common.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB4E00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = linux_glimp.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB4F00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = linux_joystick.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB5000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = linux_local.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB5100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = linux_qgl.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB5200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = linux_snd.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB5300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = qasm.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB5400868211C697A10E = {\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = image.gif;\n\t\t\tpath = quake3.gif;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB5500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = unix_glw.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB5600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = unix_main.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB5700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = unix_net.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB5800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = unix_shared.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB5900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = vm_x86.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB5A00868211C697A10E = {\n\t\t\tchildren = (\n\t\t\t\t012ADB5B00868211C697A10E,\n\t\t\t\t012ADB5C00868211C697A10E,\n\t\t\t\t012ADB5D00868211C697A10E,\n\t\t\t\t012ADB5E00868211C697A10E,\n\t\t\t\t012ADB5F00868211C697A10E,\n\t\t\t\t012ADB6000868211C697A10E,\n\t\t\t\t012ADB6100868211C697A10E,\n\t\t\t\t012ADB6200868211C697A10E,\n\t\t\t\t012ADB6300868211C697A10E,\n\t\t\t\t012ADB6400868211C697A10E,\n\t\t\t\t012ADB6500868211C697A10E,\n\t\t\t\t012ADB6600868211C697A10E,\n\t\t\t\t012ADB6700868211C697A10E,\n\t\t\t\t012ADB6800868211C697A10E,\n\t\t\t\t012ADB6900868211C697A10E,\n\t\t\t\t012ADB6A00868211C697A10E,\n\t\t\t\t012ADB6B00868211C697A10E,\n\t\t\t);\n\t\t\tisa = PBXGroup;\n\t\t\tpath = win32;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB5B00868211C697A10E = {\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = image.bmp;\n\t\t\tpath = background.bmp;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB5C00868211C697A10E = {\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = image.bmp;\n\t\t\tpath = clear.bmp;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB5D00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = glw_win.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB5E00868211C697A10E = {\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = image.ico;\n\t\t\tpath = icon2.ico;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB5F00868211C697A10E = {\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = image.ico;\n\t\t\tpath = qe3.ico;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB6000868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = resource.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB6100868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = win_gamma.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB6200868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = win_glimp.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB6300868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = win_input.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB6400868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = win_local.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB6500868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = win_main.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB6600868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = win_net.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB6700868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = win_qgl.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB6800868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = win_shared.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB6900868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = win_snd.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB6A00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = win_syscon.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t012ADB6B00868211C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = win_wndproc.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t015ECC0C00894EC0C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = macosx_display.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t015ECC0D00894EC0C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.objc;\n\t\t\tpath = macosx_display.m;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t015ECC0E00894EC0C697A10E = {\n\t\t\tfileRef = 015ECC0C00894EC0C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t015ECC0F00894EC0C697A10E = {\n\t\t\tfileRef = 015ECC0D00894EC0C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t016B4A3B00ACCF9FC697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.objc;\n\t\t\tpath = macosx_glsmp_mutex.m;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t016B4A3C00ACCF9FC697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.objc;\n\t\t\tpath = macosx_glsmp_null.m;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t016B4A3D00ACCF9FC697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.objc;\n\t\t\tpath = macosx_glsmp_ports.m;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t016B4A3E00ACCF9FC697A10E = {\n\t\t\tfileRef = 016B4A3B00ACCF9FC697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t016EAE0200B4BDD1C697A10E = {\n\t\t\texplicitFileType = wrapper.cfbundle;\n\t\t\tisa = PBXFileReference;\n\t\t\tpath = ui.bundle;\n\t\t\trefType = 3;\n\t\t\tsourceTree = BUILT_PRODUCTS_DIR;\n\t\t};\n\t\t016EAE0300B4BDD1C697A10E = {\n\t\t\tbuildPhases = (\n\t\t\t\t016EAE0400B4BDD1C697A10E,\n\t\t\t\t016EAE0900B4BDD1C697A10E,\n\t\t\t\t016EAE0A00B4BDD1C697A10E,\n\t\t\t\t016EAE1200B4BDD1C697A10E,\n\t\t\t\t016EAE1300B4BDD1C697A10E,\n\t\t\t);\n\t\t\tbuildSettings = {\n\t\t\t\tINSTALL_PATH = \"/Users/Shared/$(USER)/InstalledProducts\";\n\t\t\t\tOTHER_CFLAGS = \"\";\n\t\t\t\tOTHER_LDFLAGS = \"-bundle -undefined error\";\n\t\t\t\tOTHER_REZFLAGS = \"\";\n\t\t\t\tPRODUCT_NAME = ui;\n\t\t\t\tSECTORDER_FLAGS = \"\";\n\t\t\t\tWARNING_CFLAGS = \"-Wmost -Wno-four-char-constants -Wno-unknown-pragmas\";\n\t\t\t\tWRAPPER_EXTENSION = bundle;\n\t\t\t};\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tisa = PBXBundleTarget;\n\t\t\tname = ui;\n\t\t\tproductInstallPath = \"/Users/Shared/$(USER)/InstalledProducts\";\n\t\t\tproductName = ui;\n\t\t\tproductReference = 016EAE0200B4BDD1C697A10E;\n\t\t\tproductSettingsXML = \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\n<!DOCTYPE plist PUBLIC \\\"-//Apple Computer//DTD PLIST 1.0//EN\\\" \\\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\\\">\n<plist version=\\\"1.0\\\">\n<dict>\n\t<key>CFBundleDevelopmentRegion</key>\n\t<string>English</string>\n\t<key>CFBundleExecutable</key>\n\t<string></string>\n\t<key>CFBundleGetInfoString</key>\n\t<string></string>\n\t<key>CFBundleIconFile</key>\n\t<string></string>\n\t<key>CFBundleIdentifier</key>\n\t<string></string>\n\t<key>CFBundleInfoDictionaryVersion</key>\n\t<string>6.0</string>\n\t<key>CFBundleName</key>\n\t<string></string>\n\t<key>CFBundlePackageType</key>\n\t<string>BNDL</string>\n\t<key>CFBundleShortVersionString</key>\n\t<string></string>\n\t<key>CFBundleSignature</key>\n\t<string>????</string>\n\t<key>CFBundleVersion</key>\n\t<string>0.0.1d1</string>\n</dict>\n</plist>\n\";\n\t\t};\n\t\t016EAE0400B4BDD1C697A10E = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t016EAE0500B4BDD1C697A10E,\n\t\t\t\t016EAE0600B4BDD1C697A10E,\n\t\t\t\t016EAE0700B4BDD1C697A10E,\n\t\t\t\t016EAE0800B4BDD1C697A10E,\n\t\t\t\t016EAE1400B4BE42C697A10E,\n\t\t\t);\n\t\t\tisa = PBXHeadersBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t016EAE0500B4BDD1C697A10E = {\n\t\t\tfileRef = 012ADB4900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t016EAE0600B4BDD1C697A10E = {\n\t\t\tfileRef = 012ADB4700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t016EAE0700B4BDD1C697A10E = {\n\t\t\tfileRef = 012ADB4400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t016EAE0800B4BDD1C697A10E = {\n\t\t\tfileRef = 012ADB4100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t016EAE0900B4BDD1C697A10E = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t016EAE0A00B4BDD1C697A10E = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t016EAE0B00B4BDD1C697A10E,\n\t\t\t\t016EAE0C00B4BDD1C697A10E,\n\t\t\t\t016EAE0D00B4BDD1C697A10E,\n\t\t\t\t016EAE0E00B4BDD1C697A10E,\n\t\t\t\t016EAE0F00B4BDD1C697A10E,\n\t\t\t\t016EAE1000B4BDD1C697A10E,\n\t\t\t\t016EAE1100B4BDD1C697A10E,\n\t\t\t\t016EAE1500B4BE42C697A10E,\n\t\t\t\t016EAE1600B4BE42C697A10E,\n\t\t\t\t016EAE1700B4BE53C697A10E,\n\t\t\t);\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t016EAE0B00B4BDD1C697A10E = {\n\t\t\tfileRef = 012ADB4B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t016EAE0C00B4BDD1C697A10E = {\n\t\t\tfileRef = 012ADB4A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t016EAE0D00B4BDD1C697A10E = {\n\t\t\tfileRef = 012ADB4800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t016EAE0E00B4BDD1C697A10E = {\n\t\t\tfileRef = 012ADB4600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t016EAE0F00B4BDD1C697A10E = {\n\t\t\tfileRef = 012ADB4500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t016EAE1000B4BDD1C697A10E = {\n\t\t\tfileRef = 012ADB4300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t016EAE1100B4BDD1C697A10E = {\n\t\t\tfileRef = 012ADB4200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t016EAE1200B4BDD1C697A10E = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t016EAE1300B4BDD1C697A10E = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tisa = PBXRezBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t016EAE1400B4BE42C697A10E = {\n\t\t\tfileRef = 012ADA6200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t016EAE1500B4BE42C697A10E = {\n\t\t\tfileRef = 012ADA6000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t016EAE1600B4BE42C697A10E = {\n\t\t\tfileRef = 012ADA6100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t016EAE1700B4BE53C697A10E = {\n\t\t\tfileRef = 012ADA3E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t016F1B6300ACDA9BC697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = huffman.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t016F1B6400ACDA9BC697A10E = {\n\t\t\tfileRef = 016F1B6300ACDA9BC697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170304A00B4885DC697A10E = {\n\t\t\texplicitFileType = \"compiled.mach-o.executable\";\n\t\t\tisa = PBXFileReference;\n\t\t\tpath = Q3DedicatedServer;\n\t\t\trefType = 3;\n\t\t\tsourceTree = BUILT_PRODUCTS_DIR;\n\t\t};\n\t\t0170304B00B4885DC697A10E = {\n\t\t\tbuildPhases = (\n\t\t\t\t0170304C00B4885DC697A10E,\n\t\t\t\t0170304D00B4885DC697A10E,\n\t\t\t\t0170304E00B4885DC697A10E,\n\t\t\t\t0170304F00B4885DC697A10E,\n\t\t\t);\n\t\t\tbuildSettings = {\n\t\t\t\tDEBUGGING_SYMBOLS = NO;\n\t\t\t\tGCC_VERSION = 3.3;\n\t\t\t\tINSTALL_PATH = \"\";\n\t\t\t\tLIBRARY_SEARCH_PATHS = \"\\\"/Users/zaphod/Quake3/code/macosx/GameRanger SDK/Libraries\\\"\";\n\t\t\t\tOPTIMIZATION_CFLAGS = \"-O2\";\n\t\t\t\tOTHER_CFLAGS = \"-DDEDICATED -DMACOS_X -DBOTLIB -DMISSIONPACK -force_cpusubtype_ALL -Wno-long-double\";\n\t\t\t\tOTHER_LDFLAGS = \"\";\n\t\t\t\tOTHER_REZFLAGS = \"\";\n\t\t\t\tPRODUCT_NAME = Q3DedicatedServer;\n\t\t\t\tREZ_EXECUTABLE = YES;\n\t\t\t\tSECTORDER_FLAGS = \"\";\n\t\t\t\tWARNING_CFLAGS = \"-Wmost -Wno-four-char-constants -Wno-unknown-pragmas\";\n\t\t\t};\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tisa = PBXToolTarget;\n\t\t\tname = \"Dedicated Server\";\n\t\t\tproductInstallPath = \"\";\n\t\t\tproductName = \"Dedicated Server\";\n\t\t\tproductReference = 0170304A00B4885DC697A10E;\n\t\t};\n\t\t0170304C00B4885DC697A10E = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t0170305200B488AEC697A10E,\n\t\t\t\t0170305300B488AEC697A10E,\n\t\t\t\t0170305400B488AEC697A10E,\n\t\t\t\t0170305500B488AEC697A10E,\n\t\t\t\t0170305600B488AEC697A10E,\n\t\t\t\t0170305700B488AEC697A10E,\n\t\t\t\t0170305800B488AEC697A10E,\n\t\t\t\t0170305900B488AEC697A10E,\n\t\t\t\t0170306B00B489B5C697A10E,\n\t\t\t\t0170307600B48B5CC697A10E,\n\t\t\t\t0170307700B48B5CC697A10E,\n\t\t\t\t0170307800B48B5CC697A10E,\n\t\t\t\t0170307900B48B5CC697A10E,\n\t\t\t\t0170307A00B48B5CC697A10E,\n\t\t\t\t0170307B00B48B5CC697A10E,\n\t\t\t\t0170307C00B48B5CC697A10E,\n\t\t\t\t0170307D00B48B5CC697A10E,\n\t\t\t\t0170307E00B48B5CC697A10E,\n\t\t\t\t0170307F00B48B5CC697A10E,\n\t\t\t\t0170308400B48B5CC697A10E,\n\t\t\t\t0170308500B48B5CC697A10E,\n\t\t\t\t0170308600B48B5CC697A10E,\n\t\t\t\t0170308700B48B5CC697A10E,\n\t\t\t\t0170308800B48B5CC697A10E,\n\t\t\t\t0170308900B48B5CC697A10E,\n\t\t\t\t0170308A00B48B5CC697A10E,\n\t\t\t\t0170308B00B48B5CC697A10E,\n\t\t\t\t0170308C00B48B5CC697A10E,\n\t\t\t\t0170308D00B48B5CC697A10E,\n\t\t\t\t0170308E00B48B5CC697A10E,\n\t\t\t\t0170308F00B48B5CC697A10E,\n\t\t\t\t0170309000B48B5CC697A10E,\n\t\t\t\t0170309100B48B5CC697A10E,\n\t\t\t\t0170309200B48B5CC697A10E,\n\t\t\t\t0170309300B48B5CC697A10E,\n\t\t\t\t0170309400B48B5CC697A10E,\n\t\t\t\t0170309500B48B5CC697A10E,\n\t\t\t\t0170309600B48B5CC697A10E,\n\t\t\t\t0170309700B48B5CC697A10E,\n\t\t\t\t0170309800B48B5CC697A10E,\n\t\t\t\t0170309900B48B5CC697A10E,\n\t\t\t\t0170309A00B48B5CC697A10E,\n\t\t\t\t0170309B00B48B5CC697A10E,\n\t\t\t\t0170309C00B48B5CC697A10E,\n\t\t\t\t0170309E00B48B5CC697A10E,\n\t\t\t\t0170309F00B48B5CC697A10E,\n\t\t\t\t017030A000B48B5CC697A10E,\n\t\t\t\t017030A100B48B5CC697A10E,\n\t\t\t\t017030A200B48B5CC697A10E,\n\t\t\t\t017030A300B48B5CC697A10E,\n\t\t\t);\n\t\t\tisa = PBXHeadersBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t0170304D00B4885DC697A10E = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t0170305B00B488AEC697A10E,\n\t\t\t\t0170305C00B488AEC697A10E,\n\t\t\t\t0170305D00B488AEC697A10E,\n\t\t\t\t0170305E00B488AEC697A10E,\n\t\t\t\t0170305F00B488AEC697A10E,\n\t\t\t\t0170306000B488AEC697A10E,\n\t\t\t\t0170306100B488AEC697A10E,\n\t\t\t\t0170306200B488AEC697A10E,\n\t\t\t\t0170306300B488AEC697A10E,\n\t\t\t\t0170306400B488AEC697A10E,\n\t\t\t\t0170306500B488AEC697A10E,\n\t\t\t\t0170306600B488AEC697A10E,\n\t\t\t\t0170306700B488AEC697A10E,\n\t\t\t\t0170306800B488AEC697A10E,\n\t\t\t\t0170306900B488AEC697A10E,\n\t\t\t\t0170306A00B488AEC697A10E,\n\t\t\t\t0170306C00B489B5C697A10E,\n\t\t\t\t0170306D00B489B5C697A10E,\n\t\t\t\t0170306E00B489B5C697A10E,\n\t\t\t\t0170306F00B489B5C697A10E,\n\t\t\t\t0170307000B489B5C697A10E,\n\t\t\t\t0170307100B489B5C697A10E,\n\t\t\t\t0170307200B489B5C697A10E,\n\t\t\t\t0170307400B489B5C697A10E,\n\t\t\t\t0170307500B489B5C697A10E,\n\t\t\t\t017030A400B48B5CC697A10E,\n\t\t\t\t017030A500B48B5CC697A10E,\n\t\t\t\t017030A600B48B5CC697A10E,\n\t\t\t\t017030A700B48B5CC697A10E,\n\t\t\t\t017030A800B48B5CC697A10E,\n\t\t\t\t017030A900B48B5CC697A10E,\n\t\t\t\t017030AA00B48B5CC697A10E,\n\t\t\t\t017030AB00B48B5CC697A10E,\n\t\t\t\t017030AC00B48B5CC697A10E,\n\t\t\t\t017030AD00B48B5CC697A10E,\n\t\t\t\t017030AE00B48B5CC697A10E,\n\t\t\t\t017030AF00B48B5CC697A10E,\n\t\t\t\t017030B000B48B5CC697A10E,\n\t\t\t\t017030B100B48B5CC697A10E,\n\t\t\t\t017030B200B48B5CC697A10E,\n\t\t\t\t017030B300B48B5CC697A10E,\n\t\t\t\t017030B400B48B5CC697A10E,\n\t\t\t\t017030B500B48B5CC697A10E,\n\t\t\t\t017030B600B48B5CC697A10E,\n\t\t\t\t017030B700B48B5CC697A10E,\n\t\t\t\t017030B800B48B5CC697A10E,\n\t\t\t\t017030B900B48B5CC697A10E,\n\t\t\t\t017030BA00B48B5CC697A10E,\n\t\t\t\t017030BB00B48B5CC697A10E,\n\t\t\t\t017030BC00B48B5CC697A10E,\n\t\t\t\t017030BD00B48B5CC697A10E,\n\t\t\t\t017030BE00B48B5CC697A10E,\n\t\t\t\t017030BF00B48B5CC697A10E,\n\t\t\t\t017030C000B48B5CC697A10E,\n\t\t\t\t017030C100B48B5CC697A10E,\n\t\t\t\t017030C200B48B5CC697A10E,\n\t\t\t\t017030C300B48B5CC697A10E,\n\t\t\t\t017030C400B48B5CC697A10E,\n\t\t\t\t017030C500B48B5CC697A10E,\n\t\t\t\t017030C600B48B5CC697A10E,\n\t\t\t\t017030C700B48B5CC697A10E,\n\t\t\t\t017030C800B48B5CC697A10E,\n\t\t\t\t017030C900B48B5CC697A10E,\n\t\t\t\t017030CA00B48B5CC697A10E,\n\t\t\t\t017030CB00B48B5CC697A10E,\n\t\t\t\t017030CC00B48B5CC697A10E,\n\t\t\t\t017030CD00B48B5CC697A10E,\n\t\t\t\t017030CE00B48B5CC697A10E,\n\t\t\t\t017030CF00B48B5CC697A10E,\n\t\t\t\t017030D000B48B5CC697A10E,\n\t\t\t\t017030D100B48B5CC697A10E,\n\t\t\t\t017030D200B48B5CC697A10E,\n\t\t\t\t017030D300B48B5CC697A10E,\n\t\t\t\t017030D400B48B5CC697A10E,\n\t\t\t\t017030D500B48B5CC697A10E,\n\t\t\t\t017030D600B48B5CC697A10E,\n\t\t\t\t017030D700B48B5CC697A10E,\n\t\t\t\t017030D800B48B5CC697A10E,\n\t\t\t\t017030D900B48B5CC697A10E,\n\t\t\t\t017030DA00B48B5CC697A10E,\n\t\t\t\t017030DB00B48B5CC697A10E,\n\t\t\t\t017030DC00B48B5CC697A10E,\n\t\t\t\t017030DD00B48B5CC697A10E,\n\t\t\t\t017030DE00B48B5CC697A10E,\n\t\t\t\t017030DF00B48B5CC697A10E,\n\t\t\t\t017030E000B48B5CC697A10E,\n\t\t\t\t017030E100B48B5CC697A10E,\n\t\t\t\t017030E200B48B5CC697A10E,\n\t\t\t\t017030F200B48B5CC697A10E,\n\t\t\t\t017030F300B48B5CC697A10E,\n\t\t\t\t017030F400B48B5CC697A10E,\n\t\t\t\t017030F500B48B5CC697A10E,\n\t\t\t\t017030F600B48B5CC697A10E,\n\t\t\t\t017030F700B48B5CC697A10E,\n\t\t\t\t017030F800B48B5CC697A10E,\n\t\t\t\t017030F900B48B5CC697A10E,\n\t\t\t\t017030FA00B48B5CC697A10E,\n\t\t\t\t017030FB00B48B5CC697A10E,\n\t\t\t\t017030FC00B48B5CC697A10E,\n\t\t\t\t017030FD00B48B5CC697A10E,\n\t\t\t\t017030FE00B48B5CC697A10E,\n\t\t\t\t017030FF00B48B5CC697A10E,\n\t\t\t\t0170310000B48B5CC697A10E,\n\t\t\t\t0170310100B48B5CC697A10E,\n\t\t\t\t0170310200B48B5CC697A10E,\n\t\t\t\t0170310300B48B5CC697A10E,\n\t\t\t\t0170310400B48B5CC697A10E,\n\t\t\t\t0170310500B48B5CC697A10E,\n\t\t\t\t0170310600B48B5CC697A10E,\n\t\t\t\t0170310700B48B5CC697A10E,\n\t\t\t\t0170310800B48B5CC697A10E,\n\t\t\t\t0170310900B48B5CC697A10E,\n\t\t\t\t0170310A00B48B5CC697A10E,\n\t\t\t\t0170310B00B48B5CC697A10E,\n\t\t\t\t0170310C00B48B5CC697A10E,\n\t\t\t\t0170310D00B48B5CC697A10E,\n\t\t\t\t0170310F00B48B5CC697A10E,\n\t\t\t\t0170311000B48B5CC697A10E,\n\t\t\t\t0170311100B48B5CC697A10E,\n\t\t\t\t0170311200B48B5CC697A10E,\n\t\t\t\t0170311400B48B5CC697A10E,\n\t\t\t\t0170311500B48B5CC697A10E,\n\t\t\t\t0170311600B48B5CC697A10E,\n\t\t\t\tF54951F40354EAA2011BCB42,\n\t\t\t\t4FB23865047AB9F60098ACF3,\n\t\t\t);\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t0170304E00B4885DC697A10E = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t0170311700B48E9AC697A10E,\n\t\t\t\t0170311800B48E9AC697A10E,\n\t\t\t\t0170311900B48E9AC697A10E,\n\t\t\t\t0170311A00B48E9AC697A10E,\n\t\t\t\t0170311B00B48E9AC697A10E,\n\t\t\t\tF54951E80354E75E011BCB42,\n\t\t\t);\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t0170304F00B4885DC697A10E = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tisa = PBXRezBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t0170305200B488AEC697A10E = {\n\t\t\tfileRef = 012ADB0300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170305300B488AEC697A10E = {\n\t\t\tfileRef = 012ADB0000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170305400B488AEC697A10E = {\n\t\t\tfileRef = 012ADAFE00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170305500B488AEC697A10E = {\n\t\t\tfileRef = 012ADAFD00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170305600B488AEC697A10E = {\n\t\t\tfileRef = 012ADAF300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170305700B488AEC697A10E = {\n\t\t\tfileRef = 012ADAF200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170305800B488AEC697A10E = {\n\t\t\tfileRef = 012ADAF000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170305900B488AEC697A10E = {\n\t\t\tfileRef = 012ADAEE00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170305B00B488AEC697A10E = {\n\t\t\tfileRef = 012ADB0200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170305C00B488AEC697A10E = {\n\t\t\tfileRef = 012ADAFF00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170305D00B488AEC697A10E = {\n\t\t\tfileRef = 012ADB0100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170305E00B488AEC697A10E = {\n\t\t\tfileRef = 012ADAFC00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170305F00B488AEC697A10E = {\n\t\t\tfileRef = 012ADAFB00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170306000B488AEC697A10E = {\n\t\t\tfileRef = 012ADAFA00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170306100B488AEC697A10E = {\n\t\t\tfileRef = 016F1B6300ACDA9BC697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170306200B488AEC697A10E = {\n\t\t\tfileRef = 012ADAF900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170306300B488AEC697A10E = {\n\t\t\tfileRef = 012ADAF800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170306400B488AEC697A10E = {\n\t\t\tfileRef = 012ADAF700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170306500B488AEC697A10E = {\n\t\t\tfileRef = 012ADAF600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170306600B488AEC697A10E = {\n\t\t\tfileRef = 012ADAF500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170306700B488AEC697A10E = {\n\t\t\tfileRef = 012ADAF400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170306800B488AEC697A10E = {\n\t\t\tfileRef = 012ADAF100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170306900B488AEC697A10E = {\n\t\t\tfileRef = 012ADAEF00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170306A00B488AEC697A10E = {\n\t\t\tfileRef = 012ADAED00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170306B00B489B5C697A10E = {\n\t\t\tfileRef = 012ADB2400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170306C00B489B5C697A10E = {\n\t\t\tfileRef = 012ADB2500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170306D00B489B5C697A10E = {\n\t\t\tfileRef = 012ADB2600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170306E00B489B5C697A10E = {\n\t\t\tfileRef = 012ADB2700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170306F00B489B5C697A10E = {\n\t\t\tfileRef = 012ADB2800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170307000B489B5C697A10E = {\n\t\t\tfileRef = 012ADB2900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170307100B489B5C697A10E = {\n\t\t\tfileRef = 012ADB2A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170307200B489B5C697A10E = {\n\t\t\tfileRef = 012ADB2B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170307400B489B5C697A10E = {\n\t\t\tfileRef = 012ADB2D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170307500B489B5C697A10E = {\n\t\t\tfileRef = 012ADB2E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170307600B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB3F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170307700B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB1400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170307800B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB1A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170307900B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB0800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170307A00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB0900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170307B00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA6C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170307C00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA8100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170307D00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA8C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170307E00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA9B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170307F00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA6200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170308400B48B5CC697A10E = {\n\t\t\tfileRef = 012AD90800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170308500B48B5CC697A10E = {\n\t\t\tfileRef = 012AD90900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170308600B48B5CC697A10E = {\n\t\t\tfileRef = 012AD90C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170308700B48B5CC697A10E = {\n\t\t\tfileRef = 012AD90E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170308800B48B5CC697A10E = {\n\t\t\tfileRef = 012AD90F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170308900B48B5CC697A10E = {\n\t\t\tfileRef = 012AD91100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170308A00B48B5CC697A10E = {\n\t\t\tfileRef = 012AD91300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170308B00B48B5CC697A10E = {\n\t\t\tfileRef = 012AD91400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170308C00B48B5CC697A10E = {\n\t\t\tfileRef = 012AD91600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170308D00B48B5CC697A10E = {\n\t\t\tfileRef = 012AD91800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170308E00B48B5CC697A10E = {\n\t\t\tfileRef = 012AD91A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170308F00B48B5CC697A10E = {\n\t\t\tfileRef = 012AD91C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170309000B48B5CC697A10E = {\n\t\t\tfileRef = 012AD91E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170309100B48B5CC697A10E = {\n\t\t\tfileRef = 012AD92000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170309200B48B5CC697A10E = {\n\t\t\tfileRef = 012AD92200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170309300B48B5CC697A10E = {\n\t\t\tfileRef = 012AD92A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170309400B48B5CC697A10E = {\n\t\t\tfileRef = 012AD92D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170309500B48B5CC697A10E = {\n\t\t\tfileRef = 012AD92F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170309600B48B5CC697A10E = {\n\t\t\tfileRef = 012AD93100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170309700B48B5CC697A10E = {\n\t\t\tfileRef = 012AD93300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170309800B48B5CC697A10E = {\n\t\t\tfileRef = 012AD93500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170309900B48B5CC697A10E = {\n\t\t\tfileRef = 012AD93700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170309A00B48B5CC697A10E = {\n\t\t\tfileRef = 012AD93900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170309B00B48B5CC697A10E = {\n\t\t\tfileRef = 012AD93B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170309C00B48B5CC697A10E = {\n\t\t\tfileRef = 012AD93C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170309E00B48B5CC697A10E = {\n\t\t\tfileRef = 015ECC0C00894EC0C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170309F00B48B5CC697A10E = {\n\t\t\tfileRef = 011F78F200B25B65C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030A000B48B5CC697A10E = {\n\t\t\tfileRef = 043627A600868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030A100B48B5CC697A10E = {\n\t\t\tfileRef = 043627A900868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030A200B48B5CC697A10E = {\n\t\t\tfileRef = 043627B000868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030A300B48B5CC697A10E = {\n\t\t\tfileRef = 043627AE00868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030A400B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB5700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030A500B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB5800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030A600B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB3800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030A700B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB3B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030A800B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB3E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030A900B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB0A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030AA00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB0B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030AB00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB0C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030AC00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB0D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030AD00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB0E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030AE00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB0F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030AF00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB1000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030B000B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB1100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030B100B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB1200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030B200B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB1300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030B300B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB1500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030B400B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB1600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030B500B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB1700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030B600B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB1800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030B700B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB1900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030B800B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB1B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030B900B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB1C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030BA00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB1D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030BB00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB1E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030BC00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB1F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030BD00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB2000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030BE00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB2100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030BF00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADB2200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030C000B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA6600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030C100B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA6800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030C200B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA6900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030C300B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA6A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030C400B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA6B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030C500B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA6D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030C600B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA6E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030C700B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA6F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030C800B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA7000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030C900B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA7100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030CA00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA7300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030CB00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA7400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030CC00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA7500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030CD00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA7600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030CE00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA7800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030CF00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA7900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030D000B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA7B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030D100B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA7C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030D200B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA7D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030D300B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA7F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030D400B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA8000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030D500B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA8200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030D600B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA8300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030D700B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA8400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030D800B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA8500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030D900B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA8900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030DA00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA8800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030DB00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA8B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030DC00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA8D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030DD00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA9000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030DE00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA9600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030DF00B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA9800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030E000B48B5CC697A10E = {\n\t\t\tfileRef = 012ADAA200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030E100B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA6000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030E200B48B5CC697A10E = {\n\t\t\tfileRef = 012ADA6100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030F200B48B5CC697A10E = {\n\t\t\tfileRef = 012AD90A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030F300B48B5CC697A10E = {\n\t\t\tfileRef = 012AD90B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030F400B48B5CC697A10E = {\n\t\t\tfileRef = 012AD90D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030F500B48B5CC697A10E = {\n\t\t\tfileRef = 012AD91000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030F600B48B5CC697A10E = {\n\t\t\tfileRef = 012AD91200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030F700B48B5CC697A10E = {\n\t\t\tfileRef = 012AD91500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030F800B48B5CC697A10E = {\n\t\t\tfileRef = 012AD91700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030F900B48B5CC697A10E = {\n\t\t\tfileRef = 012AD91900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030FA00B48B5CC697A10E = {\n\t\t\tfileRef = 012AD91B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030FB00B48B5CC697A10E = {\n\t\t\tfileRef = 012AD91D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030FC00B48B5CC697A10E = {\n\t\t\tfileRef = 012AD91F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030FD00B48B5CC697A10E = {\n\t\t\tfileRef = 012AD92100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030FE00B48B5CC697A10E = {\n\t\t\tfileRef = 012AD92300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t017030FF00B48B5CC697A10E = {\n\t\t\tfileRef = 012AD92400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170310000B48B5CC697A10E = {\n\t\t\tfileRef = 012AD92500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170310100B48B5CC697A10E = {\n\t\t\tfileRef = 012AD92600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170310200B48B5CC697A10E = {\n\t\t\tfileRef = 012AD92700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170310300B48B5CC697A10E = {\n\t\t\tfileRef = 012AD92800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170310400B48B5CC697A10E = {\n\t\t\tfileRef = 012AD92900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170310500B48B5CC697A10E = {\n\t\t\tfileRef = 012AD92B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170310600B48B5CC697A10E = {\n\t\t\tfileRef = 012AD92C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170310700B48B5CC697A10E = {\n\t\t\tfileRef = 012AD92E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170310800B48B5CC697A10E = {\n\t\t\tfileRef = 012AD93000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170310900B48B5CC697A10E = {\n\t\t\tfileRef = 012AD93200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170310A00B48B5CC697A10E = {\n\t\t\tfileRef = 012AD93400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170310B00B48B5CC697A10E = {\n\t\t\tfileRef = 012AD93600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170310C00B48B5CC697A10E = {\n\t\t\tfileRef = 012AD93800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170310D00B48B5CC697A10E = {\n\t\t\tfileRef = 012AD93A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170310F00B48B5CC697A10E = {\n\t\t\tfileRef = 015ECC0D00894EC0C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170311000B48B5CC697A10E = {\n\t\t\tfileRef = 043627A700868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170311100B48B5CC697A10E = {\n\t\t\tfileRef = 016B4A3B00ACCF9FC697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170311200B48B5CC697A10E = {\n\t\t\tfileRef = 043627A800868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170311400B48B5CC697A10E = {\n\t\t\tfileRef = 043627AD00868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170311500B48B5CC697A10E = {\n\t\t\tfileRef = 043627B100868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170311600B48B5CC697A10E = {\n\t\t\tfileRef = 043627AF00868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170311700B48E9AC697A10E = {\n\t\t\tfileRef = 0654BA58FE8ECEE0C697A12F;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170311800B48E9AC697A10E = {\n\t\t\tfileRef = 0654BA59FE8ECEE0C697A12F;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170311900B48E9AC697A10E = {\n\t\t\tfileRef = 00E9D914FEDB4D29C697A12F;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170311A00B48E9AC697A10E = {\n\t\t\tfileRef = 0654BA5AFE8ECEE0C697A12F;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170311B00B48E9AC697A10E = {\n\t\t\tfileRef = 0654BA5BFE8ECEE0C697A12F;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0170311C00B49352C697A10E = {\n\t\t\tbuildPhases = (\n\t\t\t);\n\t\t\tbuildSettings = {\n\t\t\t\tOTHER_CFLAGS = \"\";\n\t\t\t\tOTHER_LDFLAGS = \"\";\n\t\t\t\tOTHER_REZFLAGS = \"\";\n\t\t\t\tPRODUCT_NAME = All;\n\t\t\t\tSECTORDER_FLAGS = \"\";\n\t\t\t\tWARNING_CFLAGS = \"-Wmost -Wno-four-char-constants -Wno-unknown-pragmas\";\n\t\t\t};\n\t\t\tdependencies = (\n\t\t\t\t0170311D00B49352C697A10E,\n\t\t\t\t4FF091EA04897B0000030DA8,\n\t\t\t\t18A3D356065F6636006A719A,\n\t\t\t\t18A3D358065F663A006A719A,\n\t\t\t\t18A3D35A065F663F006A719A,\n\t\t\t);\n\t\t\tisa = PBXAggregateTarget;\n\t\t\tname = All;\n\t\t\tproductName = All;\n\t\t};\n\t\t0170311D00B49352C697A10E = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 0654BA5CFE8ECEE0C697A12F;\n\t\t\ttargetProxy = 1895FF33065E291B00F8B3F4;\n\t\t};\n//010\n//011\n//012\n//013\n//014\n//040\n//041\n//042\n//043\n//044\n\t\t043627A000868916C697A10E = {\n\t\t\tchildren = (\n\t\t\t\t015ECC0C00894EC0C697A10E,\n\t\t\t\t015ECC0D00894EC0C697A10E,\n\t\t\t\t011F78F200B25B65C697A10E,\n\t\t\t\t043627A600868916C697A10E,\n\t\t\t\t043627A700868916C697A10E,\n\t\t\t\t016B4A3B00ACCF9FC697A10E,\n\t\t\t\t016B4A3C00ACCF9FC697A10E,\n\t\t\t\t016B4A3D00ACCF9FC697A10E,\n\t\t\t\t043627A800868916C697A10E,\n\t\t\t\t043627A900868916C697A10E,\n\t\t\t\t043627AB00868916C697A10E,\n\t\t\t\t043627AD00868916C697A10E,\n\t\t\t\t043627AE00868916C697A10E,\n\t\t\t\t043627AF00868916C697A10E,\n\t\t\t\t043627B000868916C697A10E,\n\t\t\t\t043627B100868916C697A10E,\n\t\t\t\t043627B200868916C697A10E,\n\t\t\t\t043627B300868916C697A10E,\n\t\t\t\t043627B400868916C697A10E,\n\t\t\t\t043627B500868916C697A10E,\n\t\t\t\t043627B600868916C697A10E,\n\t\t\t\t043627B700868916C697A10E,\n\t\t\t\t043627B800868916C697A10E,\n\t\t\t);\n\t\t\tisa = PBXGroup;\n\t\t\tname = \"Mac OS X\";\n\t\t\tpath = \"\";\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t043627A600868916C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = macosx_glimp.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t043627A700868916C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.objc;\n\t\t\tpath = macosx_glimp.m;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t043627A800868916C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.objc;\n\t\t\tpath = macosx_input.m;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t043627A900868916C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = macosx_local.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t043627AB00868916C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.objc;\n\t\t\tpath = macosx_sndcore.m;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t043627AD00868916C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.objc;\n\t\t\tpath = macosx_sys.m;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t043627AE00868916C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = macosx_timers.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t043627AF00868916C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.objc;\n\t\t\tpath = macosx_timers.m;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t043627B000868916C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = Q3Controller.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t043627B100868916C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.objc;\n\t\t\tpath = Q3Controller.m;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t043627B200868916C697A10E = {\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = wrapper.nib;\n\t\t\tpath = Quake3.nib;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t043627B300868916C697A10E = {\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = image.icns;\n\t\t\tpath = Quake3.icns;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t043627B400868916C697A10E = {\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = image.jpeg;\n\t\t\tpath = banner.jpg;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t043627B500868916C697A10E = {\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = text.rtf;\n\t\t\tpath = Performance.rtf;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t043627B600868916C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = text.script.sh;\n\t\t\tpath = BuildRelease;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t043627B700868916C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = text.script.sh;\n\t\t\tpath = RecordDemo.zsh;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t043627B800868916C697A10E = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = text.script.sh;\n\t\t\tpath = timedemo.zsh;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t043627BC00868916C697A10E = {\n\t\t\tfileRef = 043627A600868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627BD00868916C697A10E = {\n\t\t\tfileRef = 043627A900868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627BE00868916C697A10E = {\n\t\t\tfileRef = 043627AE00868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627BF00868916C697A10E = {\n\t\t\tfileRef = 043627B000868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627C000868916C697A10E = {\n\t\t\tfileRef = 043627B300868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627C100868916C697A10E = {\n\t\t\tfileRef = 043627B200868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627C200868916C697A10E = {\n\t\t\tfileRef = 043627B400868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627C500868916C697A10E = {\n\t\t\tfileRef = 043627A700868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627C600868916C697A10E = {\n\t\t\tfileRef = 043627A800868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627C800868916C697A10E = {\n\t\t\tfileRef = 043627AB00868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627CA00868916C697A10E = {\n\t\t\tfileRef = 043627AD00868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627CB00868916C697A10E = {\n\t\t\tfileRef = 043627AF00868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627CC00868916C697A10E = {\n\t\t\tfileRef = 043627B100868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627D20086963EC697A10E = {\n\t\t\tfileRef = 012ADAF600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627D30086965EC697A10E = {\n\t\t\tfileRef = 012ADA6200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627D40086965EC697A10E = {\n\t\t\tfileRef = 012ADA6100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627D50086965EC697A10E = {\n\t\t\tfileRef = 012ADA6000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627D600869679C697A10E = {\n\t\t\tfileRef = 012ADB1200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627D700869713C697A10E = {\n\t\t\tfileRef = 012ADB0300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627D800869713C697A10E = {\n\t\t\tfileRef = 012ADAF700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627D900869713C697A10E = {\n\t\t\tfileRef = 012ADAF800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627DA00869713C697A10E = {\n\t\t\tfileRef = 012ADAF900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627DB00869713C697A10E = {\n\t\t\tfileRef = 012ADB0100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627DD00869713C697A10E = {\n\t\t\tfileRef = 012ADB0200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627DE00869726C697A10E = {\n\t\t\tfileRef = 012ADB0000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627DF00869726C697A10E = {\n\t\t\tfileRef = 012ADAFF00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627E00086978DC697A10E = {\n\t\t\tfileRef = 012ADB5800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627E100869827C697A10E = {\n\t\t\tfileRef = 012ADAEE00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627E200869827C697A10E = {\n\t\t\tfileRef = 012ADAF000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627E300869827C697A10E = {\n\t\t\tfileRef = 012ADAF200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627E400869827C697A10E = {\n\t\t\tfileRef = 012ADAF300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627E500869827C697A10E = {\n\t\t\tfileRef = 012ADAFD00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627E600869827C697A10E = {\n\t\t\tfileRef = 012ADAFE00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627E700869827C697A10E = {\n\t\t\tfileRef = 012ADB0800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627E800869827C697A10E = {\n\t\t\tfileRef = 012ADB0900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627E900869827C697A10E = {\n\t\t\tfileRef = 012ADB1400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627EA00869827C697A10E = {\n\t\t\tfileRef = 012ADB1A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627EB00869827C697A10E = {\n\t\t\tfileRef = 012ADB2400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627EC00869827C697A10E = {\n\t\t\tfileRef = 012AD9A600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627ED00869827C697A10E = {\n\t\t\tfileRef = 012AD9A700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627EE00869827C697A10E = {\n\t\t\tfileRef = 012AD9A800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627EF00869827C697A10E = {\n\t\t\tfileRef = 012AD9A900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627F000869827C697A10E = {\n\t\t\tfileRef = 012AD9AA00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627F100869827C697A10E = {\n\t\t\tfileRef = 012AD9AB00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627F200869827C697A10E = {\n\t\t\tfileRef = 012AD9AC00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627F300869827C697A10E = {\n\t\t\tfileRef = 012AD9AD00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627F400869827C697A10E = {\n\t\t\tfileRef = 012AD9AE00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627F500869827C697A10E = {\n\t\t\tfileRef = 012AD9AF00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627F600869827C697A10E = {\n\t\t\tfileRef = 012ADAED00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627F700869827C697A10E = {\n\t\t\tfileRef = 012ADAEF00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627F900869827C697A10E = {\n\t\t\tfileRef = 012ADAF400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627FA00869827C697A10E = {\n\t\t\tfileRef = 012ADAF500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627FB00869827C697A10E = {\n\t\t\tfileRef = 012ADAFA00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627FC00869827C697A10E = {\n\t\t\tfileRef = 012ADAFB00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627FD00869827C697A10E = {\n\t\t\tfileRef = 012ADAFC00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627FE00869827C697A10E = {\n\t\t\tfileRef = 012ADB0A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043627FF00869827C697A10E = {\n\t\t\tfileRef = 012ADB0B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436280000869827C697A10E = {\n\t\t\tfileRef = 012ADB0C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436280100869827C697A10E = {\n\t\t\tfileRef = 012ADB0D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436280200869827C697A10E = {\n\t\t\tfileRef = 012ADB0E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436280300869827C697A10E = {\n\t\t\tfileRef = 012ADB0F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436280400869827C697A10E = {\n\t\t\tfileRef = 012ADB1000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436280500869827C697A10E = {\n\t\t\tfileRef = 012ADB1100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436280600869827C697A10E = {\n\t\t\tfileRef = 012ADB1300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436280700869827C697A10E = {\n\t\t\tfileRef = 012ADB1500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436280800869827C697A10E = {\n\t\t\tfileRef = 012ADB1600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436280900869827C697A10E = {\n\t\t\tfileRef = 012ADB1700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436280A00869827C697A10E = {\n\t\t\tfileRef = 012ADB1800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436280B00869827C697A10E = {\n\t\t\tfileRef = 012ADB1900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436280C00869827C697A10E = {\n\t\t\tfileRef = 012ADB1B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436280D00869827C697A10E = {\n\t\t\tfileRef = 012ADB1C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436280E00869827C697A10E = {\n\t\t\tfileRef = 012ADB1D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436280F00869827C697A10E = {\n\t\t\tfileRef = 012ADB1E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436281000869827C697A10E = {\n\t\t\tfileRef = 012ADB1F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436281100869827C697A10E = {\n\t\t\tfileRef = 012ADB2000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436281200869827C697A10E = {\n\t\t\tfileRef = 012ADB2100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436281300869827C697A10E = {\n\t\t\tfileRef = 012ADB2200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436281400869827C697A10E = {\n\t\t\tfileRef = 012ADB2500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436281500869827C697A10E = {\n\t\t\tfileRef = 012ADB2600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436281600869827C697A10E = {\n\t\t\tfileRef = 012ADB2700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436281700869827C697A10E = {\n\t\t\tfileRef = 012ADB2800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436281800869827C697A10E = {\n\t\t\tfileRef = 012ADB2900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436281900869827C697A10E = {\n\t\t\tfileRef = 012ADB2A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436281A00869827C697A10E = {\n\t\t\tfileRef = 012ADB2B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436281C00869827C697A10E = {\n\t\t\tfileRef = 012ADB2D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436281D00869827C697A10E = {\n\t\t\tfileRef = 012ADB2E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436281E00869827C697A10E = {\n\t\t\tfileRef = 012ADB5700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436281F008698F8C697A10E = {\n\t\t\tfileRef = 012AD9B000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t04362820008698F8C697A10E = {\n\t\t\tfileRef = 012AD9B100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t04362821008698F8C697A10E = {\n\t\t\tfileRef = 012AD9B400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t04362822008698F8C697A10E = {\n\t\t\tfileRef = 012AD9B700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t04362823008698F8C697A10E = {\n\t\t\tfileRef = 012AD9B200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t04362824008698F8C697A10E = {\n\t\t\tfileRef = 012AD9B300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t04362825008698F8C697A10E = {\n\t\t\tfileRef = 012AD9B500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t04362826008698F8C697A10E = {\n\t\t\tfileRef = 012AD9B600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628270086991FC697A10E = {\n\t\t\tfileRef = 012AD9B800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436282E00869A16C697A10E = {\n\t\t\tfileRef = 012ADB3B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436282F00869A7FC697A10E = {\n\t\t\tfileRef = 012ADB3800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436283000869A8EC697A10E = {\n\t\t\tfileRef = 012ADB3F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436283100869A8EC697A10E = {\n\t\t\tfileRef = 012ADB3E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436283300869AC5C697A10E = {\n\t\t\tfileRef = 012ADA9800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436283400869AC5C697A10E = {\n\t\t\tfileRef = 012ADA9600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436284900869B0BC697A10E = {\n\t\t\tfileRef = 012ADA8C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436284B00869B0BC697A10E = {\n\t\t\tfileRef = 012ADA9B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436286A00869C36C697A10E = {\n\t\t\tfileRef = 012ADA8B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436286B00869C6FC697A10E = {\n\t\t\tfileRef = 012ADA6600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436286C00869CB4C697A10E = {\n\t\t\tfileRef = 012ADA7100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436286D00869CC9C697A10E = {\n\t\t\tfileRef = 012ADAA200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436286E00869D0AC697A10E = {\n\t\t\tfileRef = 012ADA6F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436286F00869D18C697A10E = {\n\t\t\tfileRef = 012ADA7900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436287000869D23C697A10E = {\n\t\t\tfileRef = 012ADA6D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436287100869D3BC697A10E = {\n\t\t\tfileRef = 012ADA7400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436287200869D48C697A10E = {\n\t\t\tfileRef = 012ADA6C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436287300869D48C697A10E = {\n\t\t\tfileRef = 012ADA6B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436287400869D56C697A10E = {\n\t\t\tfileRef = 012ADA6A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436287500869D61C697A10E = {\n\t\t\tfileRef = 012ADA7600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436287600869D71C697A10E = {\n\t\t\tfileRef = 012ADA6900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436287700869D7FC697A10E = {\n\t\t\tfileRef = 012ADA7500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436287800869D92C697A10E = {\n\t\t\tfileRef = 012ADA6800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436287900869DBBC697A10E = {\n\t\t\tfileRef = 012ADA8D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436287A00869DC7C697A10E = {\n\t\t\tfileRef = 012ADA7000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436287B00869DD4C697A10E = {\n\t\t\tfileRef = 012ADA8500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436287C00869DDDC697A10E = {\n\t\t\tfileRef = 012ADA7800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436287D00869DF1C697A10E = {\n\t\t\tfileRef = 012ADA8400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436287E00869DFAC697A10E = {\n\t\t\tfileRef = 012ADA8200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436287F00869E04C697A10E = {\n\t\t\tfileRef = 012ADA8900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436288000869E10C697A10E = {\n\t\t\tfileRef = 012ADA7F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436288100869E21C697A10E = {\n\t\t\tfileRef = 012ADA8100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436288200869E21C697A10E = {\n\t\t\tfileRef = 012ADA8000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436288300869E3DC697A10E = {\n\t\t\tfileRef = 012ADA9000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436288400869E4CC697A10E = {\n\t\t\tfileRef = 012ADA8800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436288500869E56C697A10E = {\n\t\t\tfileRef = 012ADA7300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436288600869E60C697A10E = {\n\t\t\tfileRef = 012ADA7B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436288700869E80C697A10E = {\n\t\t\tfileRef = 012ADA8300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436288800869E8DC697A10E = {\n\t\t\tfileRef = 012ADA7C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436288900869E96C697A10E = {\n\t\t\tfileRef = 012ADA7D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436288A00869EA2C697A10E = {\n\t\t\tfileRef = 012ADA6E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436288B00869ED7C697A10E = {\n\t\t\tfileRef = 012AD92C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436288C00869EF3C697A10E = {\n\t\t\tfileRef = 012AD92400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436288D00869F06C697A10E = {\n\t\t\tfileRef = 012AD93700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436288E00869F06C697A10E = {\n\t\t\tfileRef = 012AD93600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436288F00869F0FC697A10E = {\n\t\t\tfileRef = 012AD93100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436289000869F0FC697A10E = {\n\t\t\tfileRef = 012AD93000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436289100869F2AC697A10E = {\n\t\t\tfileRef = 012AD93900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436289200869F2AC697A10E = {\n\t\t\tfileRef = 012AD93800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436289300869F38C697A10E = {\n\t\t\tfileRef = 012AD93500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436289400869F38C697A10E = {\n\t\t\tfileRef = 012AD93400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436289500869F40C697A10E = {\n\t\t\tfileRef = 012AD93300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436289600869F40C697A10E = {\n\t\t\tfileRef = 012AD93200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436289700869F4BC697A10E = {\n\t\t\tfileRef = 012AD92500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436289800869F63C697A10E = {\n\t\t\tfileRef = 012AD92B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436289900869F7FC697A10E = {\n\t\t\tfileRef = 012AD92300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436289A00869F8EC697A10E = {\n\t\t\tfileRef = 012AD92700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436289B00869FAEC697A10E = {\n\t\t\tfileRef = 012AD91E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436289C00869FAEC697A10E = {\n\t\t\tfileRef = 012AD91D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436289D00869FBBC697A10E = {\n\t\t\tfileRef = 012AD91800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436289E00869FBBC697A10E = {\n\t\t\tfileRef = 012AD91700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0436289F00869FC3C697A10E = {\n\t\t\tfileRef = 012AD92200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628A000869FC3C697A10E = {\n\t\t\tfileRef = 012AD92100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628A100869FDEC697A10E = {\n\t\t\tfileRef = 012AD90900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628A200869FDEC697A10E = {\n\t\t\tfileRef = 012AD90A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628A300869FE8C697A10E = {\n\t\t\tfileRef = 012AD90E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628A400869FE8C697A10E = {\n\t\t\tfileRef = 012AD90D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628A500869FEFC697A10E = {\n\t\t\tfileRef = 012AD91C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628A600869FEFC697A10E = {\n\t\t\tfileRef = 012AD91B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628A70086A057C697A10E = {\n\t\t\tfileRef = 012AD91600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628A80086A057C697A10E = {\n\t\t\tfileRef = 012AD91500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628A90086A061C697A10E = {\n\t\t\tfileRef = 012AD92600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628AA0086A081C697A10E = {\n\t\t\tfileRef = 012AD92A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628AB0086A081C697A10E = {\n\t\t\tfileRef = 012AD92900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628AC0086A092C697A10E = {\n\t\t\tfileRef = 012AD91A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628AD0086A092C697A10E = {\n\t\t\tfileRef = 012AD91900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628AE0086A099C697A10E = {\n\t\t\tfileRef = 012AD92000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628AF0086A099C697A10E = {\n\t\t\tfileRef = 012AD91F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628B00086A0B9C697A10E = {\n\t\t\tfileRef = 012AD93B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628B10086A0B9C697A10E = {\n\t\t\tfileRef = 012AD92D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628B20086A0B9C697A10E = {\n\t\t\tfileRef = 012AD92F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628B30086A0B9C697A10E = {\n\t\t\tfileRef = 012AD93C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628B40086A0B9C697A10E = {\n\t\t\tfileRef = 012AD93A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628B50086A0B9C697A10E = {\n\t\t\tfileRef = 012AD92E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628B60086A0BFC697A10E = {\n\t\t\tfileRef = 012AD92800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628B70086A0E6C697A10E = {\n\t\t\tfileRef = 012AD91300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628B80086A0E6C697A10E = {\n\t\t\tfileRef = 012AD91200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628B90086A0F1C697A10E = {\n\t\t\tfileRef = 012AD91100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628BA0086A0F1C697A10E = {\n\t\t\tfileRef = 012AD91000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628BB0086A136C697A10E = {\n\t\t\tfileRef = 012AD90C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628BC0086A136C697A10E = {\n\t\t\tfileRef = 012AD90F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628BD0086A136C697A10E = {\n\t\t\tfileRef = 012AD91400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628BE0086A136C697A10E = {\n\t\t\tfileRef = 012AD90800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t043628BF0086A136C697A10E = {\n\t\t\tfileRef = 012AD90B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n//040\n//041\n//042\n//043\n//044\n//060\n//061\n//062\n//063\n//064\n\t\t0654BA41FE8ECEE0C697A12F = {\n\t\t\tbuildSettings = {\n\t\t\t};\n\t\t\tbuildStyles = (\n\t\t\t\t07F3F50BFFE98E8EC697A10E,\n\t\t\t\t07F3F50CFFE98E8EC697A10E,\n\t\t\t);\n\t\t\thasScannedForEncodings = 1;\n\t\t\tisa = PBXProject;\n\t\t\tmainGroup = 0654BA42FE8ECEE0C697A12F;\n\t\t\tprojectDirPath = \"\";\n\t\t\ttargets = (\n\t\t\t\t0170311C00B49352C697A10E,\n\t\t\t\t0654BA5CFE8ECEE0C697A12F,\n\t\t\t\t4FF0904804896C0E00030DA8,\n\t\t\t\t00F5ED38FEBA95B7C697A12F,\n\t\t\t\t00F5ED90FEBA9615C697A12F,\n\t\t\t\t016EAE0300B4BDD1C697A10E,\n\t\t\t\t0170304B00B4885DC697A10E,\n\t\t\t\t4FF0912704896C1600030DA8,\n\t\t\t);\n\t\t};\n\t\t0654BA42FE8ECEE0C697A12F = {\n\t\t\tchildren = (\n\t\t\t\t043627A000868916C697A10E,\n\t\t\t\t0654BA76FE8ED011C697A12F,\n\t\t\t\t0654BA57FE8ECEE0C697A12F,\n\t\t\t\t07FB599DFEB762C8C697A12F,\n\t\t\t);\n\t\t\tisa = PBXGroup;\n\t\t\tname = Quake3;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t0654BA57FE8ECEE0C697A12F = {\n\t\t\tchildren = (\n\t\t\t\t0654BA58FE8ECEE0C697A12F,\n\t\t\t\t0654BA5AFE8ECEE0C697A12F,\n\t\t\t\t0654BA5BFE8ECEE0C697A12F,\n\t\t\t\tF564505801E623B201F62882,\n\t\t\t\t00E9D914FEDB4D29C697A12F,\n\t\t\t\t0654BA59FE8ECEE0C697A12F,\n\t\t\t);\n\t\t\tisa = PBXGroup;\n\t\t\tname = \"External Frameworks and Libraries\";\n\t\t\tpath = \"\";\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t0654BA58FE8ECEE0C697A12F = {\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = wrapper.framework;\n\t\t\tname = OpenGL.framework;\n\t\t\tpath = /System/Library/Frameworks/OpenGL.framework;\n\t\t\trefType = 0;\n\t\t\tsourceTree = \"<absolute>\";\n\t\t};\n\t\t0654BA59FE8ECEE0C697A12F = {\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = wrapper.framework;\n\t\t\tname = Carbon.framework;\n\t\t\tpath = /System/Library/Frameworks/Carbon.framework;\n\t\t\trefType = 0;\n\t\t\tsourceTree = \"<absolute>\";\n\t\t};\n\t\t0654BA5AFE8ECEE0C697A12F = {\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = wrapper.framework;\n\t\t\tname = AppKit.framework;\n\t\t\tpath = /System/Library/Frameworks/AppKit.framework;\n\t\t\trefType = 0;\n\t\t\tsourceTree = \"<absolute>\";\n\t\t};\n\t\t0654BA5BFE8ECEE0C697A12F = {\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = wrapper.framework;\n\t\t\tname = Foundation.framework;\n\t\t\tpath = /System/Library/Frameworks/Foundation.framework;\n\t\t\trefType = 0;\n\t\t\tsourceTree = \"<absolute>\";\n\t\t};\n\t\t0654BA5CFE8ECEE0C697A12F = {\n\t\t\tbuildPhases = (\n\t\t\t\t0654BA5DFE8ECEE0C697A12F,\n\t\t\t\t0654BA61FE8ECEE0C697A12F,\n\t\t\t\t0654BA65FE8ECEE0C697A12F,\n\t\t\t\t0654BA6BFE8ECEE0C697A12F,\n\t\t\t\t0654BA70FE8ECEE0C697A12F,\n\t\t\t);\n\t\t\tbuildSettings = {\n\t\t\t\tFRAMEWORK_SEARCH_PATHS = \"\";\n\t\t\t\tHEADER_SEARCH_PATHS = \"\";\n\t\t\t\tINSTALL_PATH = \"/Users/Shared/$(USER)/InstalledProducts\";\n\t\t\t\tLIBRARY_SEARCH_PATHS = \"\";\n\t\t\t\tOPTIMIZATION_CFLAGS = \"-O2\";\n\t\t\t\tOTHER_CFLAGS = \"-DMACOS_X -DBOTLIB -DMISSIONPACK -DSMP -force_cpusubtype_ALL\";\n\t\t\t\tOTHER_LDFLAGS = \"\";\n\t\t\t\tOTHER_REZFLAGS = \"\";\n\t\t\t\tPRODUCT_NAME = Quake3;\n\t\t\t\tSECTORDER_FLAGS = \"\";\n\t\t\t\tUSE_GCC3_PFE_SUPPORT = NO;\n\t\t\t\tWARNING_CFLAGS = \"-Wno-long-double -Wall -Wno-four-char-constants -Wno-unknown-pragmas\";\n\t\t\t\tWRAPPER_EXTENSION = app;\n\t\t\t};\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tisa = PBXApplicationTarget;\n\t\t\tname = \"Quake3 (Application)\";\n\t\t\tproductInstallPath = \"/Users/Shared/$(USER)/InstalledProducts\";\n\t\t\tproductName = Quake3;\n\t\t\tproductReference = 09143A93FF39F3EF11CA2562;\n\t\t\tproductSettingsXML = \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\n<!DOCTYPE plist PUBLIC \\\"-//Apple Computer//DTD PLIST 1.0//EN\\\" \\\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\\\">\n<plist version=\\\"1.0\\\">\n<dict>\n\t<key>CFBundleDevelopmentRegion</key>\n\t<string>English</string>\n\t<key>CFBundleExecutable</key>\n\t<string>Quake3</string>\n\t<key>CFBundleGetInfoString</key>\n\t<string>Quake 3 Arena 1.32b</string>\n\t<key>CFBundleIconFile</key>\n\t<string>Quake3.icns</string>\n\t<key>CFBundleIdentifier</key>\n\t<string>com.idsoftware.Quake3</string>\n\t<key>CFBundleInfoDictionaryVersion</key>\n\t<string>6.0</string>\n\t<key>CFBundleName</key>\n\t<string>Quake3</string>\n\t<key>CFBundlePackageType</key>\n\t<string>APPL</string>\n\t<key>CFBundleShortVersionString</key>\n\t<string>1.32b</string>\n\t<key>CFBundleSignature</key>\n\t<string>IDQ3</string>\n\t<key>CFBundleVersion</key>\n\t<string>1.3.2</string>\n\t<key>NSExtensions</key>\n\t<dict/>\n\t<key>NSMainNibFile</key>\n\t<string>Quake3.nib</string>\n\t<key>NSPrincipalClass</key>\n\t<string>NSApplication</string>\n\t<key>NSServices</key>\n\t<array>\n\t\t<dict>\n\t\t\t<key>NSMenuItem</key>\n\t\t\t<dict>\n\t\t\t\t<key>default</key>\n\t\t\t\t<string>Quake3/Connect To Server</string>\n\t\t\t</dict>\n\t\t\t<key>NSMessage</key>\n\t\t\t<string>connectToServer</string>\n\t\t\t<key>NSPortName</key>\n\t\t\t<string>Quake3</string>\n\t\t\t<key>NSSendTypes</key>\n\t\t\t<array>\n\t\t\t\t<string>NSStringPboardType</string>\n\t\t\t</array>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>NSMenuItem</key>\n\t\t\t<dict>\n\t\t\t\t<key>default</key>\n\t\t\t\t<string>Quake3/Perform Command</string>\n\t\t\t</dict>\n\t\t\t<key>NSMessage</key>\n\t\t\t<string>performCommand</string>\n\t\t\t<key>NSPortName</key>\n\t\t\t<string>Quake3</string>\n\t\t\t<key>NSSendTypes</key>\n\t\t\t<array>\n\t\t\t\t<string>NSStringPboardType</string>\n\t\t\t</array>\n\t\t</dict>\n\t</array>\n</dict>\n</plist>\n\";\n\t\t};\n\t\t0654BA5DFE8ECEE0C697A12F = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t043627BC00868916C697A10E,\n\t\t\t\t043627BD00868916C697A10E,\n\t\t\t\t043627BE00868916C697A10E,\n\t\t\t\t043627BF00868916C697A10E,\n\t\t\t\t043627D30086965EC697A10E,\n\t\t\t\t043627D700869713C697A10E,\n\t\t\t\t043627DE00869726C697A10E,\n\t\t\t\t043627E100869827C697A10E,\n\t\t\t\t043627E200869827C697A10E,\n\t\t\t\t043627E300869827C697A10E,\n\t\t\t\t043627E400869827C697A10E,\n\t\t\t\t043627E500869827C697A10E,\n\t\t\t\t043627E600869827C697A10E,\n\t\t\t\t043627E700869827C697A10E,\n\t\t\t\t043627E800869827C697A10E,\n\t\t\t\t043627E900869827C697A10E,\n\t\t\t\t043627EA00869827C697A10E,\n\t\t\t\t043627EB00869827C697A10E,\n\t\t\t\t0436281F008698F8C697A10E,\n\t\t\t\t04362820008698F8C697A10E,\n\t\t\t\t04362821008698F8C697A10E,\n\t\t\t\t04362822008698F8C697A10E,\n\t\t\t\t0436283000869A8EC697A10E,\n\t\t\t\t0436284900869B0BC697A10E,\n\t\t\t\t0436284B00869B0BC697A10E,\n\t\t\t\t0436287200869D48C697A10E,\n\t\t\t\t0436288100869E21C697A10E,\n\t\t\t\t0436288D00869F06C697A10E,\n\t\t\t\t0436288F00869F0FC697A10E,\n\t\t\t\t0436289100869F2AC697A10E,\n\t\t\t\t0436289300869F38C697A10E,\n\t\t\t\t0436289500869F40C697A10E,\n\t\t\t\t0436289B00869FAEC697A10E,\n\t\t\t\t0436289D00869FBBC697A10E,\n\t\t\t\t0436289F00869FC3C697A10E,\n\t\t\t\t043628A100869FDEC697A10E,\n\t\t\t\t043628A300869FE8C697A10E,\n\t\t\t\t043628A500869FEFC697A10E,\n\t\t\t\t043628A70086A057C697A10E,\n\t\t\t\t043628AA0086A081C697A10E,\n\t\t\t\t043628AC0086A092C697A10E,\n\t\t\t\t043628AE0086A099C697A10E,\n\t\t\t\t043628B00086A0B9C697A10E,\n\t\t\t\t043628B10086A0B9C697A10E,\n\t\t\t\t043628B20086A0B9C697A10E,\n\t\t\t\t043628B30086A0B9C697A10E,\n\t\t\t\t043628B70086A0E6C697A10E,\n\t\t\t\t043628B90086A0F1C697A10E,\n\t\t\t\t043628BB0086A136C697A10E,\n\t\t\t\t043628BC0086A136C697A10E,\n\t\t\t\t043628BD0086A136C697A10E,\n\t\t\t\t043628BE0086A136C697A10E,\n\t\t\t\t015ECC0E00894EC0C697A10E,\n\t\t\t\t011F78F300B25B66C697A10E,\n\t\t\t\tF5ED1436037096A001F6289A,\n\t\t\t);\n\t\t\tisa = PBXHeadersBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t0654BA61FE8ECEE0C697A12F = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t043627C000868916C697A10E,\n\t\t\t\t043627C100868916C697A10E,\n\t\t\t\t043627C200868916C697A10E,\n\t\t\t);\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t0654BA65FE8ECEE0C697A12F = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t043627C500868916C697A10E,\n\t\t\t\t043627C600868916C697A10E,\n\t\t\t\t043627C800868916C697A10E,\n\t\t\t\t043627CA00868916C697A10E,\n\t\t\t\t043627CB00868916C697A10E,\n\t\t\t\t043627CC00868916C697A10E,\n\t\t\t\t043627D20086963EC697A10E,\n\t\t\t\t043627D40086965EC697A10E,\n\t\t\t\t043627D50086965EC697A10E,\n\t\t\t\t043627D600869679C697A10E,\n\t\t\t\t043627D800869713C697A10E,\n\t\t\t\t043627D900869713C697A10E,\n\t\t\t\t043627DA00869713C697A10E,\n\t\t\t\t043627DB00869713C697A10E,\n\t\t\t\t043627DD00869713C697A10E,\n\t\t\t\t043627DF00869726C697A10E,\n\t\t\t\t043627E00086978DC697A10E,\n\t\t\t\t043627EC00869827C697A10E,\n\t\t\t\t043627ED00869827C697A10E,\n\t\t\t\t043627EE00869827C697A10E,\n\t\t\t\t043627EF00869827C697A10E,\n\t\t\t\t043627F000869827C697A10E,\n\t\t\t\t043627F100869827C697A10E,\n\t\t\t\t043627F200869827C697A10E,\n\t\t\t\t043627F300869827C697A10E,\n\t\t\t\t043627F400869827C697A10E,\n\t\t\t\t043627F500869827C697A10E,\n\t\t\t\t043627F600869827C697A10E,\n\t\t\t\t043627F700869827C697A10E,\n\t\t\t\t043627F900869827C697A10E,\n\t\t\t\t043627FA00869827C697A10E,\n\t\t\t\t043627FB00869827C697A10E,\n\t\t\t\t043627FC00869827C697A10E,\n\t\t\t\t043627FD00869827C697A10E,\n\t\t\t\t043627FE00869827C697A10E,\n\t\t\t\t043627FF00869827C697A10E,\n\t\t\t\t0436280000869827C697A10E,\n\t\t\t\t0436280100869827C697A10E,\n\t\t\t\t0436280200869827C697A10E,\n\t\t\t\t0436280300869827C697A10E,\n\t\t\t\t0436280400869827C697A10E,\n\t\t\t\t0436280500869827C697A10E,\n\t\t\t\t0436280600869827C697A10E,\n\t\t\t\t0436280700869827C697A10E,\n\t\t\t\t0436280800869827C697A10E,\n\t\t\t\t0436280900869827C697A10E,\n\t\t\t\t0436280A00869827C697A10E,\n\t\t\t\t0436280B00869827C697A10E,\n\t\t\t\t0436280C00869827C697A10E,\n\t\t\t\t0436280D00869827C697A10E,\n\t\t\t\t0436280E00869827C697A10E,\n\t\t\t\t0436280F00869827C697A10E,\n\t\t\t\t0436281000869827C697A10E,\n\t\t\t\t0436281100869827C697A10E,\n\t\t\t\t0436281200869827C697A10E,\n\t\t\t\t0436281300869827C697A10E,\n\t\t\t\t0436281400869827C697A10E,\n\t\t\t\t0436281500869827C697A10E,\n\t\t\t\t0436281600869827C697A10E,\n\t\t\t\t0436281700869827C697A10E,\n\t\t\t\t0436281800869827C697A10E,\n\t\t\t\t0436281900869827C697A10E,\n\t\t\t\t0436281A00869827C697A10E,\n\t\t\t\t0436281C00869827C697A10E,\n\t\t\t\t0436281D00869827C697A10E,\n\t\t\t\t0436281E00869827C697A10E,\n\t\t\t\t04362823008698F8C697A10E,\n\t\t\t\t04362824008698F8C697A10E,\n\t\t\t\t04362825008698F8C697A10E,\n\t\t\t\t04362826008698F8C697A10E,\n\t\t\t\t043628270086991FC697A10E,\n\t\t\t\t0436282E00869A16C697A10E,\n\t\t\t\t0436282F00869A7FC697A10E,\n\t\t\t\t0436283100869A8EC697A10E,\n\t\t\t\t0436283300869AC5C697A10E,\n\t\t\t\t0436283400869AC5C697A10E,\n\t\t\t\t0436286A00869C36C697A10E,\n\t\t\t\t0436286B00869C6FC697A10E,\n\t\t\t\t0436286C00869CB4C697A10E,\n\t\t\t\t0436286D00869CC9C697A10E,\n\t\t\t\t0436286E00869D0AC697A10E,\n\t\t\t\t0436286F00869D18C697A10E,\n\t\t\t\t0436287000869D23C697A10E,\n\t\t\t\t0436287100869D3BC697A10E,\n\t\t\t\t0436287300869D48C697A10E,\n\t\t\t\t0436287400869D56C697A10E,\n\t\t\t\t0436287500869D61C697A10E,\n\t\t\t\t0436287600869D71C697A10E,\n\t\t\t\t0436287700869D7FC697A10E,\n\t\t\t\t0436287800869D92C697A10E,\n\t\t\t\t0436287900869DBBC697A10E,\n\t\t\t\t0436287A00869DC7C697A10E,\n\t\t\t\t0436287B00869DD4C697A10E,\n\t\t\t\t0436287C00869DDDC697A10E,\n\t\t\t\t0436287D00869DF1C697A10E,\n\t\t\t\t0436287E00869DFAC697A10E,\n\t\t\t\t0436287F00869E04C697A10E,\n\t\t\t\t0436288000869E10C697A10E,\n\t\t\t\t0436288200869E21C697A10E,\n\t\t\t\t0436288300869E3DC697A10E,\n\t\t\t\t0436288400869E4CC697A10E,\n\t\t\t\t0436288500869E56C697A10E,\n\t\t\t\t0436288600869E60C697A10E,\n\t\t\t\t0436288700869E80C697A10E,\n\t\t\t\t0436288800869E8DC697A10E,\n\t\t\t\t0436288900869E96C697A10E,\n\t\t\t\t0436288A00869EA2C697A10E,\n\t\t\t\t0436288B00869ED7C697A10E,\n\t\t\t\t0436288C00869EF3C697A10E,\n\t\t\t\t0436288E00869F06C697A10E,\n\t\t\t\t0436289000869F0FC697A10E,\n\t\t\t\t0436289200869F2AC697A10E,\n\t\t\t\t0436289400869F38C697A10E,\n\t\t\t\t0436289600869F40C697A10E,\n\t\t\t\t0436289700869F4BC697A10E,\n\t\t\t\t0436289800869F63C697A10E,\n\t\t\t\t0436289900869F7FC697A10E,\n\t\t\t\t0436289A00869F8EC697A10E,\n\t\t\t\t0436289C00869FAEC697A10E,\n\t\t\t\t0436289E00869FBBC697A10E,\n\t\t\t\t043628A000869FC3C697A10E,\n\t\t\t\t043628A200869FDEC697A10E,\n\t\t\t\t043628A400869FE8C697A10E,\n\t\t\t\t043628A600869FEFC697A10E,\n\t\t\t\t043628A80086A057C697A10E,\n\t\t\t\t043628A90086A061C697A10E,\n\t\t\t\t043628AB0086A081C697A10E,\n\t\t\t\t043628AD0086A092C697A10E,\n\t\t\t\t043628AF0086A099C697A10E,\n\t\t\t\t043628B40086A0B9C697A10E,\n\t\t\t\t043628B50086A0B9C697A10E,\n\t\t\t\t043628B60086A0BFC697A10E,\n\t\t\t\t043628B80086A0E6C697A10E,\n\t\t\t\t043628BA0086A0F1C697A10E,\n\t\t\t\t043628BF0086A136C697A10E,\n\t\t\t\t015ECC0F00894EC0C697A10E,\n\t\t\t\t016B4A3E00ACCF9FC697A10E,\n\t\t\t\t016F1B6400ACDA9BC697A10E,\n\t\t\t\t4FB23867047ABF780098ACF3,\n\t\t\t\t4FEFFEDA047B008000719638,\n\t\t\t);\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t0654BA6BFE8ECEE0C697A12F = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t0654BA6CFE8ECEE0C697A12F,\n\t\t\t\t0654BA6EFE8ECEE0C697A12F,\n\t\t\t\t0654BA6FFE8ECEE0C697A12F,\n\t\t\t\t00E9D91DFEDB5295C697A12F,\n\t\t\t\tF564505901E623B201F62882,\n\t\t\t\tF5D8C5E0035259DF0106E832,\n\t\t\t);\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t0654BA6CFE8ECEE0C697A12F = {\n\t\t\tfileRef = 0654BA58FE8ECEE0C697A12F;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0654BA6EFE8ECEE0C697A12F = {\n\t\t\tfileRef = 0654BA5AFE8ECEE0C697A12F;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0654BA6FFE8ECEE0C697A12F = {\n\t\t\tfileRef = 0654BA5BFE8ECEE0C697A12F;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t0654BA70FE8ECEE0C697A12F = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tisa = PBXRezBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t0654BA76FE8ED011C697A12F = {\n\t\t\tchildren = (\n\t\t\t\t012AD90700868211C697A10E,\n\t\t\t\t012AD93D00868211C697A10E,\n\t\t\t\t012AD98D00868211C697A10E,\n\t\t\t\t012AD9A500868211C697A10E,\n\t\t\t\t012ADA2400868211C697A10E,\n\t\t\t\t012ADA6500868211C697A10E,\n\t\t\t\t012ADAA400868211C697A10E,\n\t\t\t\t012ADAB300868211C697A10E,\n\t\t\t\t012ADABB00868211C697A10E,\n\t\t\t\t012ADAEC00868211C697A10E,\n\t\t\t\t012ADB0600868211C697A10E,\n\t\t\t\t012ADB2300868211C697A10E,\n\t\t\t\t012ADB2F00868211C697A10E,\n\t\t\t\t012ADB4000868211C697A10E,\n\t\t\t\t012ADB4C00868211C697A10E,\n\t\t\t\t012ADB5A00868211C697A10E,\n\t\t\t);\n\t\t\tisa = PBXGroup;\n\t\t\tname = \"Id Source\";\n\t\t\tpath = ..;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n//060\n//061\n//062\n//063\n//064\n//070\n//071\n//072\n//073\n//074\n\t\t07F3F507FFE98E8EC697A10E = {\n\t\t\texplicitFileType = wrapper.cfbundle;\n\t\t\tisa = PBXFileReference;\n\t\t\tpath = qagame.bundle;\n\t\t\trefType = 3;\n\t\t\tsourceTree = BUILT_PRODUCTS_DIR;\n\t\t};\n\t\t07F3F508FFE98E8EC697A10E = {\n\t\t\texplicitFileType = wrapper.cfbundle;\n\t\t\tisa = PBXFileReference;\n\t\t\tpath = cgame.bundle;\n\t\t\trefType = 3;\n\t\t\tsourceTree = BUILT_PRODUCTS_DIR;\n\t\t};\n\t\t07F3F50BFFE98E8EC697A10E = {\n\t\t\tbuildSettings = {\n\t\t\t\tCOMMON_CFLAGS = \"-DMISSIONPACK -DBOTLIB -DMACOS_X -force_cpusubtype_ALL\";\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;\n\t\t\t\tGCC_ENABLE_FIX_AND_CONTINUE = YES;\n\t\t\t\tGCC_GENERATE_DEBUGGING_SYMBOLS = YES;\n\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;\n\t\t\t\tNO_OPT_CFLAGS = \"-O0 -fno-inline -fno-inline-functions\";\n\t\t\t\tOPTIMIZATION_CFLAGS = \"-O0\";\n\t\t\t\tOTHER_CFLAGS = \"\\U0001-g -Wall -DQGL_CHECK_GL_ERRORS $(NO_OPT_CFLAGS) $(COMMON_CFLAGS)\";\n\t\t\t\tZERO_LINK = YES;\n\t\t\t};\n\t\t\tisa = PBXBuildStyle;\n\t\t\tname = Development;\n\t\t};\n\t\t07F3F50CFFE98E8EC697A10E = {\n\t\t\tbuildSettings = {\n\t\t\t\tCOMMON_CFLAGS = \"-DMISSIONPACK -DBOTLIB -DMACOS_X -force_cpusubtype_ALL\\n\";\n\t\t\t\tCOPY_PHASE_STRIP = YES;\n\t\t\t\tGCC_ENABLE_FIX_AND_CONTINUE = NO;\n\t\t\t\tZERO_LINK = NO;\n\t\t\t};\n\t\t\tisa = PBXBuildStyle;\n\t\t\tname = Deployment;\n\t\t};\n\t\t07FB599DFEB762C8C697A12F = {\n\t\t\tchildren = (\n\t\t\t\t09143A93FF39F3EF11CA2562,\n\t\t\t\t07F3F507FFE98E8EC697A10E,\n\t\t\t\t07F3F508FFE98E8EC697A10E,\n\t\t\t\t016EAE0200B4BDD1C697A10E,\n\t\t\t\t0170304A00B4885DC697A10E,\n\t\t\t\t4FF0912504896C0E00030DA8,\n\t\t\t\t4FF091E804896C1600030DA8,\n\t\t\t);\n\t\t\tisa = PBXGroup;\n\t\t\tname = Products;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n//070\n//071\n//072\n//073\n//074\n//090\n//091\n//092\n//093\n//094\n\t\t09143A93FF39F3EF11CA2562 = {\n\t\t\texplicitFileType = wrapper.application;\n\t\t\tisa = PBXFileReference;\n\t\t\tpath = Quake3.app;\n\t\t\trefType = 3;\n\t\t\tsourceTree = BUILT_PRODUCTS_DIR;\n\t\t};\n//090\n//091\n//092\n//093\n//094\n//130\n//131\n//132\n//133\n//134\n\t\t13380E0900ADF941C697A10E = {\n\t\t\tfileRef = 012ADA4C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E0B00ADFA16C697A10E = {\n\t\t\tfileRef = 012ADA5700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E0C00ADFA72C697A10E = {\n\t\t\tfileRef = 012ADA5600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E0D00ADFA94C697A10E = {\n\t\t\tfileRef = 012ADA4D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E0E00ADFA9EC697A10E = {\n\t\t\tfileRef = 012ADA4600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E0F00ADFAACC697A10E = {\n\t\t\tfileRef = 012ADA6200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E1000ADFAACC697A10E = {\n\t\t\tfileRef = 012ADA6000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E1100ADFAACC697A10E = {\n\t\t\tfileRef = 012ADA6100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E1200ADFACAC697A10E = {\n\t\t\tfileRef = 012ADA4500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E1300ADFAD5C697A10E = {\n\t\t\tfileRef = 012ADA2E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E1400ADFAD5C697A10E = {\n\t\t\tfileRef = 012ADA2D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E1500ADFB0CC697A10E = {\n\t\t\tfileRef = 012ADA2C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E1600ADFB0CC697A10E = {\n\t\t\tfileRef = 012ADA2B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E1700ADFBFDC697A10E = {\n\t\t\tfileRef = 012ADA3200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E1800ADFBFDC697A10E = {\n\t\t\tfileRef = 012ADA3100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E1900ADFC10C697A10E = {\n\t\t\tfileRef = 012ADA2800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E1A00ADFC10C697A10E = {\n\t\t\tfileRef = 012ADA2700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E1B00ADFC22C697A10E = {\n\t\t\tfileRef = 012ADA3000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E1C00ADFC22C697A10E = {\n\t\t\tfileRef = 012ADA2F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E1D00ADFC32C697A10E = {\n\t\t\tfileRef = 012ADA2600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E1E00ADFC32C697A10E = {\n\t\t\tfileRef = 012ADA2500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E1F00ADFC43C697A10E = {\n\t\t\tfileRef = 012ADA2A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E2000ADFC43C697A10E = {\n\t\t\tfileRef = 012ADA2900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E2100ADFC59C697A10E = {\n\t\t\tfileRef = 012ADA5C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E2200ADFC78C697A10E = {\n\t\t\tfileRef = 012ADA4900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E2300ADFC85C697A10E = {\n\t\t\tfileRef = 012ADA3E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E2400ADFC9CC697A10E = {\n\t\t\tfileRef = 012ADA5D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E2500ADFCA7C697A10E = {\n\t\t\tfileRef = 012ADA5A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E2600ADFCA7C697A10E = {\n\t\t\tfileRef = 012ADA5900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E2700ADFCBDC697A10E = {\n\t\t\tfileRef = 012ADA4700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E2800ADFCC8C697A10E = {\n\t\t\tfileRef = 012ADA4A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E2900ADFCD1C697A10E = {\n\t\t\tfileRef = 012ADA4F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E2A00ADFCEBC697A10E = {\n\t\t\tfileRef = 012ADA5500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E2B00ADFCF6C697A10E = {\n\t\t\tfileRef = 012ADA5400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E2C00ADFD01C697A10E = {\n\t\t\tfileRef = 012ADA4800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E2D00ADFD1FC697A10E = {\n\t\t\tfileRef = 012ADA4E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E2E00ADFD28C697A10E = {\n\t\t\tfileRef = 012ADA5B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E2F00ADFD38C697A10E = {\n\t\t\tfileRef = 012ADA5800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E3000ADFD46C697A10E = {\n\t\t\tfileRef = 012ADA5000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E3100ADFD58C697A10E = {\n\t\t\tfileRef = 012ADA4400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E3200ADFD71C697A10E = {\n\t\t\tfileRef = 012ADA3F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E3300ADFD85C697A10E = {\n\t\t\tfileRef = 012ADA4100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E3400ADFDA1C697A10E = {\n\t\t\tfileRef = 012AD99700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E3500ADFDA1C697A10E = {\n\t\t\tfileRef = 012AD9A100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E3600ADFDCFC697A10E = {\n\t\t\tfileRef = 012ADA6200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E3700ADFDCFC697A10E = {\n\t\t\tfileRef = 012ADA6100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E3800ADFDCFC697A10E = {\n\t\t\tfileRef = 012ADA6000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E3900ADFDE1C697A10E = {\n\t\t\tfileRef = 012ADA3E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E3B00ADFE0CC697A10E = {\n\t\t\tfileRef = 012AD99C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E3C00ADFE1EC697A10E = {\n\t\t\tfileRef = 012ADA3F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E3D00ADFE24C697A10E = {\n\t\t\tfileRef = 012ADA4100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E3E00ADFE3DC697A10E = {\n\t\t\tfileRef = 012AD99B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E3F00ADFE4AC697A10E = {\n\t\t\tfileRef = 012AD99300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E4000ADFE58C697A10E = {\n\t\t\tfileRef = 012AD99100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E4100ADFE6BC697A10E = {\n\t\t\tfileRef = 012AD99600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E4200ADFE7AC697A10E = {\n\t\t\tfileRef = 012AD99800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E4300ADFE88C697A10E = {\n\t\t\tfileRef = 012AD9A300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E4400ADFE97C697A10E = {\n\t\t\tfileRef = 012AD99200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E4500ADFEA7C697A10E = {\n\t\t\tfileRef = 012AD99A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E4600ADFEB8C697A10E = {\n\t\t\tfileRef = 012AD99000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E4700ADFEC9C697A10E = {\n\t\t\tfileRef = 012AD9A200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E4800ADFED7C697A10E = {\n\t\t\tfileRef = 012AD9A000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E4900ADFEE7C697A10E = {\n\t\t\tfileRef = 012AD99F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E4A00ADFEF5C697A10E = {\n\t\t\tfileRef = 012AD99E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E4B00ADFF05C697A10E = {\n\t\t\tfileRef = 012AD99400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E4C00ADFF27C697A10E = {\n\t\t\tfileRef = 012AD98E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E4F00AE0112C697A10E = {\n\t\t\tfileRef = 012AD98F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E5000AE020FC697A10E = {\n\t\t\tfileRef = 012AD99900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E5100AE0235C697A10E = {\n\t\t\tfileRef = 012ADB4900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t13380E5200AE0235C697A10E = {\n\t\t\tfileRef = 012ADB4800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n//130\n//131\n//132\n//133\n//134\n//180\n//181\n//182\n//183\n//184\n\t\t1895FF2E065E291B00F8B3F4 = {\n\t\t\tcontainerPortal = 0654BA41FE8ECEE0C697A12F;\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 4FF0904804896C0E00030DA8;\n\t\t\tremoteInfo = \"Quake3 G4 (Application)\";\n\t\t};\n\t\t1895FF33065E291B00F8B3F4 = {\n\t\t\tcontainerPortal = 0654BA41FE8ECEE0C697A12F;\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 0654BA5CFE8ECEE0C697A12F;\n\t\t\tremoteInfo = \"Quake3 (Application)\";\n\t\t};\n\t\t18A3D355065F6636006A719A = {\n\t\t\tcontainerPortal = 0654BA41FE8ECEE0C697A12F;\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 00F5ED38FEBA95B7C697A12F;\n\t\t\tremoteInfo = qagame;\n\t\t};\n\t\t18A3D356065F6636006A719A = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 00F5ED38FEBA95B7C697A12F;\n\t\t\ttargetProxy = 18A3D355065F6636006A719A;\n\t\t};\n\t\t18A3D357065F663A006A719A = {\n\t\t\tcontainerPortal = 0654BA41FE8ECEE0C697A12F;\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 00F5ED90FEBA9615C697A12F;\n\t\t\tremoteInfo = cgame;\n\t\t};\n\t\t18A3D358065F663A006A719A = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 00F5ED90FEBA9615C697A12F;\n\t\t\ttargetProxy = 18A3D357065F663A006A719A;\n\t\t};\n\t\t18A3D359065F663F006A719A = {\n\t\t\tcontainerPortal = 0654BA41FE8ECEE0C697A12F;\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 016EAE0300B4BDD1C697A10E;\n\t\t\tremoteInfo = ui;\n\t\t};\n\t\t18A3D35A065F663F006A719A = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 016EAE0300B4BDD1C697A10E;\n\t\t\ttargetProxy = 18A3D359065F663F006A719A;\n\t\t};\n//180\n//181\n//182\n//183\n//184\n//4F0\n//4F1\n//4F2\n//4F3\n//4F4\n\t\t4FB23863047AB9F60098ACF3 = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.c;\n\t\t\tpath = vm_ppc_new.c;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t4FB23865047AB9F60098ACF3 = {\n\t\t\tfileRef = 4FB23863047AB9F60098ACF3;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FB23867047ABF780098ACF3 = {\n\t\t\tfileRef = 4FB23863047AB9F60098ACF3;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FEFFEDA047B008000719638 = {\n\t\t\tfileRef = 012ADAF100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0904804896C0E00030DA8 = {\n\t\t\tbuildPhases = (\n\t\t\t\t4FF0904904896C0E00030DA8,\n\t\t\t\t4FF0908704896C0E00030DA8,\n\t\t\t\t4FF0908B04896C0E00030DA8,\n\t\t\t\t4FF0911D04896C0E00030DA8,\n\t\t\t\t4FF0912404896C0E00030DA8,\n\t\t\t);\n\t\t\tbuildSettings = {\n\t\t\t\tFRAMEWORK_SEARCH_PATHS = \"\";\n\t\t\t\tGCC_VERSION = 3.3;\n\t\t\t\tHEADER_SEARCH_PATHS = \"\";\n\t\t\t\tINSTALL_PATH = \"/Users/Shared/$(USER)/InstalledProducts\";\n\t\t\t\tLIBRARY_SEARCH_PATHS = \"\\\"/Users/zaphod/QUAKE3/CODE/macosx/GameRanger SDK/Libraries\\\"\";\n\t\t\t\tOPTIMIZATION_CFLAGS = \"-O2\";\n\t\t\t\tOTHER_CFLAGS = \"-DMACOS_X -DBOTLIB -DMISSIONPACK -DSMP -force_cpusubtype_ALL -faltivec\";\n\t\t\t\tOTHER_LDFLAGS = \"\";\n\t\t\t\tOTHER_REZFLAGS = \"\";\n\t\t\t\tPRODUCT_NAME = \"Quake3 G4\";\n\t\t\t\tSECTORDER_FLAGS = \"\";\n\t\t\t\tUSE_GCC3_PFE_SUPPORT = NO;\n\t\t\t\tWARNING_CFLAGS = \"-Wno-long-double -Wall -Wno-four-char-constants -Wno-unknown-pragmas\";\n\t\t\t\tWRAPPER_EXTENSION = app;\n\t\t\t};\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tisa = PBXApplicationTarget;\n\t\t\tname = \"Quake3 G4 (Application)\";\n\t\t\tproductInstallPath = \"/Users/Shared/$(USER)/InstalledProducts\";\n\t\t\tproductName = Quake3;\n\t\t\tproductReference = 4FF0912504896C0E00030DA8;\n\t\t\tproductSettingsXML = \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\n<!DOCTYPE plist PUBLIC \\\"-//Apple Computer//DTD PLIST 1.0//EN\\\" \\\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\\\">\n<plist version=\\\"1.0\\\">\n<dict>\n\t<key>CFBundleDevelopmentRegion</key>\n\t<string>English</string>\n\t<key>CFBundleExecutable</key>\n\t<string>Quake3 G4</string>\n\t<key>CFBundleGetInfoString</key>\n\t<string>Quake 3 Arena 1.3.2</string>\n\t<key>CFBundleIconFile</key>\n\t<string>Quake3.icns</string>\n\t<key>CFBundleIdentifier</key>\n\t<string>com.idsoftware.Quake3</string>\n\t<key>CFBundleInfoDictionaryVersion</key>\n\t<string>6.0</string>\n\t<key>CFBundleName</key>\n\t<string>Quake3</string>\n\t<key>CFBundlePackageType</key>\n\t<string>APPL</string>\n\t<key>CFBundleShortVersionString</key>\n\t<string>1.3.2</string>\n\t<key>CFBundleSignature</key>\n\t<string>IDQ3</string>\n\t<key>CFBundleVersion</key>\n\t<string>1.3.2</string>\n\t<key>NSExtensions</key>\n\t<dict/>\n\t<key>NSMainNibFile</key>\n\t<string>Quake3.nib</string>\n\t<key>NSPrincipalClass</key>\n\t<string>NSApplication</string>\n\t<key>NSServices</key>\n\t<array>\n\t\t<dict>\n\t\t\t<key>NSMenuItem</key>\n\t\t\t<dict>\n\t\t\t\t<key>default</key>\n\t\t\t\t<string>Quake3/Connect To Server</string>\n\t\t\t</dict>\n\t\t\t<key>NSMessage</key>\n\t\t\t<string>connectToServer</string>\n\t\t\t<key>NSPortName</key>\n\t\t\t<string>Quake3</string>\n\t\t\t<key>NSSendTypes</key>\n\t\t\t<array>\n\t\t\t\t<string>NSStringPboardType</string>\n\t\t\t</array>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>NSMenuItem</key>\n\t\t\t<dict>\n\t\t\t\t<key>default</key>\n\t\t\t\t<string>Quake3/Perform Command</string>\n\t\t\t</dict>\n\t\t\t<key>NSMessage</key>\n\t\t\t<string>performCommand</string>\n\t\t\t<key>NSPortName</key>\n\t\t\t<string>Quake3</string>\n\t\t\t<key>NSSendTypes</key>\n\t\t\t<array>\n\t\t\t\t<string>NSStringPboardType</string>\n\t\t\t</array>\n\t\t</dict>\n\t</array>\n</dict>\n</plist>\n\";\n\t\t};\n\t\t4FF0904904896C0E00030DA8 = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t4FF0904A04896C0E00030DA8,\n\t\t\t\t4FF0904B04896C0E00030DA8,\n\t\t\t\t4FF0904C04896C0E00030DA8,\n\t\t\t\t4FF0904D04896C0E00030DA8,\n\t\t\t\t4FF0904E04896C0E00030DA8,\n\t\t\t\t4FF0904F04896C0E00030DA8,\n\t\t\t\t4FF0905004896C0E00030DA8,\n\t\t\t\t4FF0905104896C0E00030DA8,\n\t\t\t\t4FF0905204896C0E00030DA8,\n\t\t\t\t4FF0905304896C0E00030DA8,\n\t\t\t\t4FF0905404896C0E00030DA8,\n\t\t\t\t4FF0905504896C0E00030DA8,\n\t\t\t\t4FF0905604896C0E00030DA8,\n\t\t\t\t4FF0905704896C0E00030DA8,\n\t\t\t\t4FF0905804896C0E00030DA8,\n\t\t\t\t4FF0905904896C0E00030DA8,\n\t\t\t\t4FF0905A04896C0E00030DA8,\n\t\t\t\t4FF0905B04896C0E00030DA8,\n\t\t\t\t4FF0905C04896C0E00030DA8,\n\t\t\t\t4FF0905D04896C0E00030DA8,\n\t\t\t\t4FF0905E04896C0E00030DA8,\n\t\t\t\t4FF0905F04896C0E00030DA8,\n\t\t\t\t4FF0906004896C0E00030DA8,\n\t\t\t\t4FF0906104896C0E00030DA8,\n\t\t\t\t4FF0906204896C0E00030DA8,\n\t\t\t\t4FF0906304896C0E00030DA8,\n\t\t\t\t4FF0906404896C0E00030DA8,\n\t\t\t\t4FF0906504896C0E00030DA8,\n\t\t\t\t4FF0906604896C0E00030DA8,\n\t\t\t\t4FF0906704896C0E00030DA8,\n\t\t\t\t4FF0906804896C0E00030DA8,\n\t\t\t\t4FF0906904896C0E00030DA8,\n\t\t\t\t4FF0906A04896C0E00030DA8,\n\t\t\t\t4FF0906B04896C0E00030DA8,\n\t\t\t\t4FF0906C04896C0E00030DA8,\n\t\t\t\t4FF0906D04896C0E00030DA8,\n\t\t\t\t4FF0906E04896C0E00030DA8,\n\t\t\t\t4FF0906F04896C0E00030DA8,\n\t\t\t\t4FF0907004896C0E00030DA8,\n\t\t\t\t4FF0907104896C0E00030DA8,\n\t\t\t\t4FF0907204896C0E00030DA8,\n\t\t\t\t4FF0907304896C0E00030DA8,\n\t\t\t\t4FF0907404896C0E00030DA8,\n\t\t\t\t4FF0907504896C0E00030DA8,\n\t\t\t\t4FF0907604896C0E00030DA8,\n\t\t\t\t4FF0907704896C0E00030DA8,\n\t\t\t\t4FF0907804896C0E00030DA8,\n\t\t\t\t4FF0907904896C0E00030DA8,\n\t\t\t\t4FF0907A04896C0E00030DA8,\n\t\t\t\t4FF0907B04896C0E00030DA8,\n\t\t\t\t4FF0907C04896C0E00030DA8,\n\t\t\t\t4FF0907D04896C0E00030DA8,\n\t\t\t\t4FF0907E04896C0E00030DA8,\n\t\t\t\t4FF0907F04896C0E00030DA8,\n\t\t\t\t4FF0908604896C0E00030DA8,\n\t\t\t);\n\t\t\tisa = PBXHeadersBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t4FF0904A04896C0E00030DA8 = {\n\t\t\tfileRef = 043627A600868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0904B04896C0E00030DA8 = {\n\t\t\tfileRef = 043627A900868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0904C04896C0E00030DA8 = {\n\t\t\tfileRef = 043627AE00868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0904D04896C0E00030DA8 = {\n\t\t\tfileRef = 043627B000868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0904E04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA6200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0904F04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB0300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0905004896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB0000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0905104896C0E00030DA8 = {\n\t\t\tfileRef = 012ADAEE00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0905204896C0E00030DA8 = {\n\t\t\tfileRef = 012ADAF000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0905304896C0E00030DA8 = {\n\t\t\tfileRef = 012ADAF200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0905404896C0E00030DA8 = {\n\t\t\tfileRef = 012ADAF300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0905504896C0E00030DA8 = {\n\t\t\tfileRef = 012ADAFD00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0905604896C0E00030DA8 = {\n\t\t\tfileRef = 012ADAFE00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0905704896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB0800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0905804896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB0900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0905904896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB1400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0905A04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB1A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0905B04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB2400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0905C04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD9B000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0905D04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD9B100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0905E04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD9B400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0905F04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD9B700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0906004896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB3F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0906104896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA8C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0906204896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA9B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0906304896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA6C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0906404896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA8100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0906504896C0E00030DA8 = {\n\t\t\tfileRef = 012AD93700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0906604896C0E00030DA8 = {\n\t\t\tfileRef = 012AD93100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0906704896C0E00030DA8 = {\n\t\t\tfileRef = 012AD93900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0906804896C0E00030DA8 = {\n\t\t\tfileRef = 012AD93500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0906904896C0E00030DA8 = {\n\t\t\tfileRef = 012AD93300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0906A04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD91E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0906B04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD91800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0906C04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD92200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0906D04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD90900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0906E04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD90E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0906F04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD91C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0907004896C0E00030DA8 = {\n\t\t\tfileRef = 012AD91600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0907104896C0E00030DA8 = {\n\t\t\tfileRef = 012AD92A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0907204896C0E00030DA8 = {\n\t\t\tfileRef = 012AD91A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0907304896C0E00030DA8 = {\n\t\t\tfileRef = 012AD92000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0907404896C0E00030DA8 = {\n\t\t\tfileRef = 012AD93B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0907504896C0E00030DA8 = {\n\t\t\tfileRef = 012AD92D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0907604896C0E00030DA8 = {\n\t\t\tfileRef = 012AD92F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0907704896C0E00030DA8 = {\n\t\t\tfileRef = 012AD93C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0907804896C0E00030DA8 = {\n\t\t\tfileRef = 012AD91300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0907904896C0E00030DA8 = {\n\t\t\tfileRef = 012AD91100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0907A04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD90C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0907B04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD90F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0907C04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD91400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0907D04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD90800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0907E04896C0E00030DA8 = {\n\t\t\tfileRef = 015ECC0C00894EC0C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0907F04896C0E00030DA8 = {\n\t\t\tfileRef = 011F78F200B25B65C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0908604896C0E00030DA8 = {\n\t\t\tfileRef = F5ED1435037096A001F6289A;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0908704896C0E00030DA8 = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t4FF0908804896C0E00030DA8,\n\t\t\t\t4FF0908904896C0E00030DA8,\n\t\t\t\t4FF0908A04896C0E00030DA8,\n\t\t\t);\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t4FF0908804896C0E00030DA8 = {\n\t\t\tfileRef = 043627B300868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0908904896C0E00030DA8 = {\n\t\t\tfileRef = 043627B200868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0908A04896C0E00030DA8 = {\n\t\t\tfileRef = 043627B400868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0908B04896C0E00030DA8 = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t4FF0908C04896C0E00030DA8,\n\t\t\t\t4FF0908D04896C0E00030DA8,\n\t\t\t\t4FF0908E04896C0E00030DA8,\n\t\t\t\t4FF0908F04896C0E00030DA8,\n\t\t\t\t4FF0909004896C0E00030DA8,\n\t\t\t\t4FF0909104896C0E00030DA8,\n\t\t\t\t4FF0909204896C0E00030DA8,\n\t\t\t\t4FF0909304896C0E00030DA8,\n\t\t\t\t4FF0909404896C0E00030DA8,\n\t\t\t\t4FF0909504896C0E00030DA8,\n\t\t\t\t4FF0909604896C0E00030DA8,\n\t\t\t\t4FF0909704896C0E00030DA8,\n\t\t\t\t4FF0909804896C0E00030DA8,\n\t\t\t\t4FF0909904896C0E00030DA8,\n\t\t\t\t4FF0909A04896C0E00030DA8,\n\t\t\t\t4FF0909B04896C0E00030DA8,\n\t\t\t\t4FF0909C04896C0E00030DA8,\n\t\t\t\t4FF0909D04896C0E00030DA8,\n\t\t\t\t4FF0909E04896C0E00030DA8,\n\t\t\t\t4FF0909F04896C0E00030DA8,\n\t\t\t\t4FF090A004896C0E00030DA8,\n\t\t\t\t4FF090A104896C0E00030DA8,\n\t\t\t\t4FF090A204896C0E00030DA8,\n\t\t\t\t4FF090A304896C0E00030DA8,\n\t\t\t\t4FF090A404896C0E00030DA8,\n\t\t\t\t4FF090A504896C0E00030DA8,\n\t\t\t\t4FF090A604896C0E00030DA8,\n\t\t\t\t4FF090A704896C0E00030DA8,\n\t\t\t\t4FF090A804896C0E00030DA8,\n\t\t\t\t4FF090A904896C0E00030DA8,\n\t\t\t\t4FF090AA04896C0E00030DA8,\n\t\t\t\t4FF090AB04896C0E00030DA8,\n\t\t\t\t4FF090AC04896C0E00030DA8,\n\t\t\t\t4FF090AD04896C0E00030DA8,\n\t\t\t\t4FF090AE04896C0E00030DA8,\n\t\t\t\t4FF090AF04896C0E00030DA8,\n\t\t\t\t4FF090B004896C0E00030DA8,\n\t\t\t\t4FF090B104896C0E00030DA8,\n\t\t\t\t4FF090B204896C0E00030DA8,\n\t\t\t\t4FF090B304896C0E00030DA8,\n\t\t\t\t4FF090B404896C0E00030DA8,\n\t\t\t\t4FF090B504896C0E00030DA8,\n\t\t\t\t4FF090B604896C0E00030DA8,\n\t\t\t\t4FF090B704896C0E00030DA8,\n\t\t\t\t4FF090B804896C0E00030DA8,\n\t\t\t\t4FF090B904896C0E00030DA8,\n\t\t\t\t4FF090BA04896C0E00030DA8,\n\t\t\t\t4FF090BB04896C0E00030DA8,\n\t\t\t\t4FF090BC04896C0E00030DA8,\n\t\t\t\t4FF090BD04896C0E00030DA8,\n\t\t\t\t4FF090BE04896C0E00030DA8,\n\t\t\t\t4FF090BF04896C0E00030DA8,\n\t\t\t\t4FF090C004896C0E00030DA8,\n\t\t\t\t4FF090C104896C0E00030DA8,\n\t\t\t\t4FF090C204896C0E00030DA8,\n\t\t\t\t4FF090C304896C0E00030DA8,\n\t\t\t\t4FF090C404896C0E00030DA8,\n\t\t\t\t4FF090C504896C0E00030DA8,\n\t\t\t\t4FF090C604896C0E00030DA8,\n\t\t\t\t4FF090C704896C0E00030DA8,\n\t\t\t\t4FF090C804896C0E00030DA8,\n\t\t\t\t4FF090C904896C0E00030DA8,\n\t\t\t\t4FF090CA04896C0E00030DA8,\n\t\t\t\t4FF090CB04896C0E00030DA8,\n\t\t\t\t4FF090CC04896C0E00030DA8,\n\t\t\t\t4FF090CD04896C0E00030DA8,\n\t\t\t\t4FF090CE04896C0E00030DA8,\n\t\t\t\t4FF090CF04896C0E00030DA8,\n\t\t\t\t4FF090D004896C0E00030DA8,\n\t\t\t\t4FF090D104896C0E00030DA8,\n\t\t\t\t4FF090D204896C0E00030DA8,\n\t\t\t\t4FF090D304896C0E00030DA8,\n\t\t\t\t4FF090D404896C0E00030DA8,\n\t\t\t\t4FF090D504896C0E00030DA8,\n\t\t\t\t4FF090D604896C0E00030DA8,\n\t\t\t\t4FF090D704896C0E00030DA8,\n\t\t\t\t4FF090D804896C0E00030DA8,\n\t\t\t\t4FF090D904896C0E00030DA8,\n\t\t\t\t4FF090DA04896C0E00030DA8,\n\t\t\t\t4FF090DB04896C0E00030DA8,\n\t\t\t\t4FF090DC04896C0E00030DA8,\n\t\t\t\t4FF090DD04896C0E00030DA8,\n\t\t\t\t4FF090DE04896C0E00030DA8,\n\t\t\t\t4FF090DF04896C0E00030DA8,\n\t\t\t\t4FF090E004896C0E00030DA8,\n\t\t\t\t4FF090E104896C0E00030DA8,\n\t\t\t\t4FF090E204896C0E00030DA8,\n\t\t\t\t4FF090E304896C0E00030DA8,\n\t\t\t\t4FF090E404896C0E00030DA8,\n\t\t\t\t4FF090E504896C0E00030DA8,\n\t\t\t\t4FF090E604896C0E00030DA8,\n\t\t\t\t4FF090E704896C0E00030DA8,\n\t\t\t\t4FF090E804896C0E00030DA8,\n\t\t\t\t4FF090E904896C0E00030DA8,\n\t\t\t\t4FF090EA04896C0E00030DA8,\n\t\t\t\t4FF090EB04896C0E00030DA8,\n\t\t\t\t4FF090EC04896C0E00030DA8,\n\t\t\t\t4FF090ED04896C0E00030DA8,\n\t\t\t\t4FF090EE04896C0E00030DA8,\n\t\t\t\t4FF090EF04896C0E00030DA8,\n\t\t\t\t4FF090F004896C0E00030DA8,\n\t\t\t\t4FF090F104896C0E00030DA8,\n\t\t\t\t4FF090F204896C0E00030DA8,\n\t\t\t\t4FF090F304896C0E00030DA8,\n\t\t\t\t4FF090F404896C0E00030DA8,\n\t\t\t\t4FF090F504896C0E00030DA8,\n\t\t\t\t4FF090F604896C0E00030DA8,\n\t\t\t\t4FF090F704896C0E00030DA8,\n\t\t\t\t4FF090F804896C0E00030DA8,\n\t\t\t\t4FF090F904896C0E00030DA8,\n\t\t\t\t4FF090FA04896C0E00030DA8,\n\t\t\t\t4FF090FB04896C0E00030DA8,\n\t\t\t\t4FF090FC04896C0E00030DA8,\n\t\t\t\t4FF090FD04896C0E00030DA8,\n\t\t\t\t4FF090FE04896C0E00030DA8,\n\t\t\t\t4FF090FF04896C0E00030DA8,\n\t\t\t\t4FF0910004896C0E00030DA8,\n\t\t\t\t4FF0910104896C0E00030DA8,\n\t\t\t\t4FF0910204896C0E00030DA8,\n\t\t\t\t4FF0910304896C0E00030DA8,\n\t\t\t\t4FF0910404896C0E00030DA8,\n\t\t\t\t4FF0910504896C0E00030DA8,\n\t\t\t\t4FF0910604896C0E00030DA8,\n\t\t\t\t4FF0910704896C0E00030DA8,\n\t\t\t\t4FF0910804896C0E00030DA8,\n\t\t\t\t4FF0910904896C0E00030DA8,\n\t\t\t\t4FF0910A04896C0E00030DA8,\n\t\t\t\t4FF0910B04896C0E00030DA8,\n\t\t\t\t4FF0910C04896C0E00030DA8,\n\t\t\t\t4FF0910D04896C0E00030DA8,\n\t\t\t\t4FF0910E04896C0E00030DA8,\n\t\t\t\t4FF0910F04896C0E00030DA8,\n\t\t\t\t4FF0911004896C0E00030DA8,\n\t\t\t\t4FF0911104896C0E00030DA8,\n\t\t\t\t4FF0911204896C0E00030DA8,\n\t\t\t\t4FF0911304896C0E00030DA8,\n\t\t\t\t4FF0911404896C0E00030DA8,\n\t\t\t\t4FF0911504896C0E00030DA8,\n\t\t\t\t4FF0911B04896C0E00030DA8,\n\t\t\t\t4FF0911C04896C0E00030DA8,\n\t\t\t);\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t4FF0908C04896C0E00030DA8 = {\n\t\t\tfileRef = 043627A700868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0908D04896C0E00030DA8 = {\n\t\t\tfileRef = 043627A800868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0908E04896C0E00030DA8 = {\n\t\t\tfileRef = 043627AB00868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0908F04896C0E00030DA8 = {\n\t\t\tfileRef = 043627AD00868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0909004896C0E00030DA8 = {\n\t\t\tfileRef = 043627AF00868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0909104896C0E00030DA8 = {\n\t\t\tfileRef = 043627B100868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0909204896C0E00030DA8 = {\n\t\t\tfileRef = 012ADAF600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0909304896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA6100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0909404896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA6000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0909504896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB1200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0909604896C0E00030DA8 = {\n\t\t\tfileRef = 012ADAF700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0909704896C0E00030DA8 = {\n\t\t\tfileRef = 012ADAF800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0909804896C0E00030DA8 = {\n\t\t\tfileRef = 012ADAF900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0909904896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB0100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0909A04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB0200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0909B04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADAFF00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0909C04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB5800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0909D04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD9A600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0909E04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD9A700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0909F04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD9A800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090A004896C0E00030DA8 = {\n\t\t\tfileRef = 012AD9A900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090A104896C0E00030DA8 = {\n\t\t\tfileRef = 012AD9AA00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090A204896C0E00030DA8 = {\n\t\t\tfileRef = 012AD9AB00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090A304896C0E00030DA8 = {\n\t\t\tfileRef = 012AD9AC00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090A404896C0E00030DA8 = {\n\t\t\tfileRef = 012AD9AD00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090A504896C0E00030DA8 = {\n\t\t\tfileRef = 012AD9AE00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090A604896C0E00030DA8 = {\n\t\t\tfileRef = 012AD9AF00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090A704896C0E00030DA8 = {\n\t\t\tfileRef = 012ADAED00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090A804896C0E00030DA8 = {\n\t\t\tfileRef = 012ADAEF00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090A904896C0E00030DA8 = {\n\t\t\tfileRef = 012ADAF400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090AA04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADAF500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090AB04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADAFA00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090AC04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADAFB00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090AD04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADAFC00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090AE04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB0A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090AF04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB0B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090B004896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB0C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090B104896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB0D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090B204896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB0E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090B304896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB0F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090B404896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB1000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090B504896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB1100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090B604896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB1300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090B704896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB1500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090B804896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB1600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090B904896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB1700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090BA04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB1800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090BB04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB1900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090BC04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB1B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090BD04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB1C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090BE04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB1D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090BF04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB1E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090C004896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB1F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090C104896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB2000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090C204896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB2100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090C304896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB2200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090C404896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB2500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090C504896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB2600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090C604896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB2700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090C704896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB2800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090C804896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB2900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090C904896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB2A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090CA04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB2B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090CB04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB2D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090CC04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB2E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090CD04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB5700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090CE04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD9B200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090CF04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD9B300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090D004896C0E00030DA8 = {\n\t\t\tfileRef = 012AD9B500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090D104896C0E00030DA8 = {\n\t\t\tfileRef = 012AD9B600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090D204896C0E00030DA8 = {\n\t\t\tfileRef = 012AD9B800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090D304896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB3B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090D404896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB3800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090D504896C0E00030DA8 = {\n\t\t\tfileRef = 012ADB3E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090D604896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA9800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090D704896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA9600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090D804896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA8B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090D904896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA6600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090DA04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA7100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090DB04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADAA200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090DC04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA6F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090DD04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA7900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090DE04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA6D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090DF04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA7400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090E004896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA6B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090E104896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA6A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090E204896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA7600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090E304896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA6900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090E404896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA7500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090E504896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA6800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090E604896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA8D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090E704896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA7000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090E804896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA8500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090E904896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA7800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090EA04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA8400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090EB04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA8200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090EC04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA8900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090ED04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA7F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090EE04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA8000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090EF04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA9000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090F004896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA8800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090F104896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA7300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090F204896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA7B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090F304896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA8300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090F404896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA7C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090F504896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA7D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090F604896C0E00030DA8 = {\n\t\t\tfileRef = 012ADA6E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090F704896C0E00030DA8 = {\n\t\t\tfileRef = 012AD92C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090F804896C0E00030DA8 = {\n\t\t\tfileRef = 012AD92400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090F904896C0E00030DA8 = {\n\t\t\tfileRef = 012AD93600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090FA04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD93000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090FB04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD93800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090FC04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD93400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090FD04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD93200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090FE04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD92500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF090FF04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD92B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0910004896C0E00030DA8 = {\n\t\t\tfileRef = 012AD92300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0910104896C0E00030DA8 = {\n\t\t\tfileRef = 012AD92700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0910204896C0E00030DA8 = {\n\t\t\tfileRef = 012AD91D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0910304896C0E00030DA8 = {\n\t\t\tfileRef = 012AD91700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0910404896C0E00030DA8 = {\n\t\t\tfileRef = 012AD92100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0910504896C0E00030DA8 = {\n\t\t\tfileRef = 012AD90A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0910604896C0E00030DA8 = {\n\t\t\tfileRef = 012AD90D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0910704896C0E00030DA8 = {\n\t\t\tfileRef = 012AD91B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0910804896C0E00030DA8 = {\n\t\t\tfileRef = 012AD91500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0910904896C0E00030DA8 = {\n\t\t\tfileRef = 012AD92600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0910A04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD92900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0910B04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD91900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0910C04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD91F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0910D04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD93A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0910E04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD92E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0910F04896C0E00030DA8 = {\n\t\t\tfileRef = 012AD92800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0911004896C0E00030DA8 = {\n\t\t\tfileRef = 012AD91200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0911104896C0E00030DA8 = {\n\t\t\tfileRef = 012AD91000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0911204896C0E00030DA8 = {\n\t\t\tfileRef = 012AD90B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0911304896C0E00030DA8 = {\n\t\t\tfileRef = 015ECC0D00894EC0C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0911404896C0E00030DA8 = {\n\t\t\tfileRef = 016B4A3B00ACCF9FC697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0911504896C0E00030DA8 = {\n\t\t\tfileRef = 016F1B6300ACDA9BC697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0911B04896C0E00030DA8 = {\n\t\t\tfileRef = 4FB23863047AB9F60098ACF3;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0911C04896C0E00030DA8 = {\n\t\t\tfileRef = 012ADAF100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0911D04896C0E00030DA8 = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t4FF0911E04896C0E00030DA8,\n\t\t\t\t4FF0911F04896C0E00030DA8,\n\t\t\t\t4FF0912004896C0E00030DA8,\n\t\t\t\t4FF0912104896C0E00030DA8,\n\t\t\t\t4FF0912204896C0E00030DA8,\n\t\t\t\t4FF0912304896C0E00030DA8,\n\t\t\t);\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t4FF0911E04896C0E00030DA8 = {\n\t\t\tfileRef = 0654BA58FE8ECEE0C697A12F;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0911F04896C0E00030DA8 = {\n\t\t\tfileRef = 0654BA5AFE8ECEE0C697A12F;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0912004896C0E00030DA8 = {\n\t\t\tfileRef = 0654BA5BFE8ECEE0C697A12F;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0912104896C0E00030DA8 = {\n\t\t\tfileRef = 00E9D914FEDB4D29C697A12F;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0912204896C0E00030DA8 = {\n\t\t\tfileRef = F564505801E623B201F62882;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0912304896C0E00030DA8 = {\n\t\t\tfileRef = 0654BA59FE8ECEE0C697A12F;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0912404896C0E00030DA8 = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tisa = PBXRezBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t4FF0912504896C0E00030DA8 = {\n\t\t\texplicitFileType = wrapper.application;\n\t\t\tisa = PBXFileReference;\n\t\t\tpath = \"Quake3 G4.app\";\n\t\t\trefType = 3;\n\t\t\tsourceTree = BUILT_PRODUCTS_DIR;\n\t\t};\n\t\t4FF0912704896C1600030DA8 = {\n\t\t\tbuildPhases = (\n\t\t\t\t4FF0912804896C1600030DA8,\n\t\t\t\t4FF0915C04896C1600030DA8,\n\t\t\t\t4FF091E004896C1600030DA8,\n\t\t\t\t4FF091E704896C1600030DA8,\n\t\t\t);\n\t\t\tbuildSettings = {\n\t\t\t\tDEBUGGING_SYMBOLS = NO;\n\t\t\t\tGCC_VERSION = 3.3;\n\t\t\t\tINSTALL_PATH = \"\";\n\t\t\t\tLIBRARY_SEARCH_PATHS = \"\\\"/Users/zaphod/Quake3/code/macosx/GameRanger SDK/Libraries\\\"\";\n\t\t\t\tOPTIMIZATION_CFLAGS = \"-O2\";\n\t\t\t\tOTHER_CFLAGS = \"-DMACOS_X -DBOTLIB -DMISSIONPACK -DSMP -force_cpusubtype_ALL -faltivec -falign-loops=16 -falign-jumps=16 -fstrict-aliasing \";\n\t\t\t\tOTHER_LDFLAGS = \"\";\n\t\t\t\tOTHER_REZFLAGS = \"\";\n\t\t\t\tPRODUCT_NAME = Q3DedicatedServer;\n\t\t\t\tREZ_EXECUTABLE = YES;\n\t\t\t\tSECTORDER_FLAGS = \"\";\n\t\t\t\tWARNING_CFLAGS = \"-Wmost -Wno-four-char-constants -Wno-unknown-pragmas\";\n\t\t\t};\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tisa = PBXToolTarget;\n\t\t\tname = \"Dedicated Server G4\";\n\t\t\tproductInstallPath = \"\";\n\t\t\tproductName = \"Dedicated Server\";\n\t\t\tproductReference = 4FF091E804896C1600030DA8;\n\t\t};\n\t\t4FF0912804896C1600030DA8 = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t4FF0912904896C1600030DA8,\n\t\t\t\t4FF0912A04896C1600030DA8,\n\t\t\t\t4FF0912B04896C1600030DA8,\n\t\t\t\t4FF0912C04896C1600030DA8,\n\t\t\t\t4FF0912D04896C1600030DA8,\n\t\t\t\t4FF0912E04896C1600030DA8,\n\t\t\t\t4FF0912F04896C1600030DA8,\n\t\t\t\t4FF0913004896C1600030DA8,\n\t\t\t\t4FF0913104896C1600030DA8,\n\t\t\t\t4FF0913204896C1600030DA8,\n\t\t\t\t4FF0913304896C1600030DA8,\n\t\t\t\t4FF0913404896C1600030DA8,\n\t\t\t\t4FF0913504896C1600030DA8,\n\t\t\t\t4FF0913604896C1600030DA8,\n\t\t\t\t4FF0913704896C1600030DA8,\n\t\t\t\t4FF0913804896C1600030DA8,\n\t\t\t\t4FF0913904896C1600030DA8,\n\t\t\t\t4FF0913A04896C1600030DA8,\n\t\t\t\t4FF0913B04896C1600030DA8,\n\t\t\t\t4FF0913C04896C1600030DA8,\n\t\t\t\t4FF0913D04896C1600030DA8,\n\t\t\t\t4FF0913E04896C1600030DA8,\n\t\t\t\t4FF0913F04896C1600030DA8,\n\t\t\t\t4FF0914004896C1600030DA8,\n\t\t\t\t4FF0914104896C1600030DA8,\n\t\t\t\t4FF0914204896C1600030DA8,\n\t\t\t\t4FF0914304896C1600030DA8,\n\t\t\t\t4FF0914404896C1600030DA8,\n\t\t\t\t4FF0914504896C1600030DA8,\n\t\t\t\t4FF0914604896C1600030DA8,\n\t\t\t\t4FF0914704896C1600030DA8,\n\t\t\t\t4FF0914804896C1600030DA8,\n\t\t\t\t4FF0914904896C1600030DA8,\n\t\t\t\t4FF0914A04896C1600030DA8,\n\t\t\t\t4FF0914B04896C1600030DA8,\n\t\t\t\t4FF0914C04896C1600030DA8,\n\t\t\t\t4FF0914D04896C1600030DA8,\n\t\t\t\t4FF0914E04896C1600030DA8,\n\t\t\t\t4FF0914F04896C1600030DA8,\n\t\t\t\t4FF0915004896C1600030DA8,\n\t\t\t\t4FF0915104896C1600030DA8,\n\t\t\t\t4FF0915204896C1600030DA8,\n\t\t\t\t4FF0915304896C1600030DA8,\n\t\t\t\t4FF0915404896C1600030DA8,\n\t\t\t\t4FF0915604896C1600030DA8,\n\t\t\t\t4FF0915704896C1600030DA8,\n\t\t\t\t4FF0915804896C1600030DA8,\n\t\t\t\t4FF0915904896C1600030DA8,\n\t\t\t\t4FF0915A04896C1600030DA8,\n\t\t\t\t4FF0915B04896C1600030DA8,\n\t\t\t);\n\t\t\tisa = PBXHeadersBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t4FF0912904896C1600030DA8 = {\n\t\t\tfileRef = 012ADB0300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0912A04896C1600030DA8 = {\n\t\t\tfileRef = 012ADB0000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0912B04896C1600030DA8 = {\n\t\t\tfileRef = 012ADAFE00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0912C04896C1600030DA8 = {\n\t\t\tfileRef = 012ADAFD00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0912D04896C1600030DA8 = {\n\t\t\tfileRef = 012ADAF300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0912E04896C1600030DA8 = {\n\t\t\tfileRef = 012ADAF200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0912F04896C1600030DA8 = {\n\t\t\tfileRef = 012ADAF000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0913004896C1600030DA8 = {\n\t\t\tfileRef = 012ADAEE00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0913104896C1600030DA8 = {\n\t\t\tfileRef = 012ADB2400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0913204896C1600030DA8 = {\n\t\t\tfileRef = 012ADB3F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0913304896C1600030DA8 = {\n\t\t\tfileRef = 012ADB1400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0913404896C1600030DA8 = {\n\t\t\tfileRef = 012ADB1A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0913504896C1600030DA8 = {\n\t\t\tfileRef = 012ADB0800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0913604896C1600030DA8 = {\n\t\t\tfileRef = 012ADB0900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0913704896C1600030DA8 = {\n\t\t\tfileRef = 012ADA6C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0913804896C1600030DA8 = {\n\t\t\tfileRef = 012ADA8100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0913904896C1600030DA8 = {\n\t\t\tfileRef = 012ADA8C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0913A04896C1600030DA8 = {\n\t\t\tfileRef = 012ADA9B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0913B04896C1600030DA8 = {\n\t\t\tfileRef = 012ADA6200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0913C04896C1600030DA8 = {\n\t\t\tfileRef = 012AD90800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0913D04896C1600030DA8 = {\n\t\t\tfileRef = 012AD90900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0913E04896C1600030DA8 = {\n\t\t\tfileRef = 012AD90C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0913F04896C1600030DA8 = {\n\t\t\tfileRef = 012AD90E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0914004896C1600030DA8 = {\n\t\t\tfileRef = 012AD90F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0914104896C1600030DA8 = {\n\t\t\tfileRef = 012AD91100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0914204896C1600030DA8 = {\n\t\t\tfileRef = 012AD91300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0914304896C1600030DA8 = {\n\t\t\tfileRef = 012AD91400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0914404896C1600030DA8 = {\n\t\t\tfileRef = 012AD91600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0914504896C1600030DA8 = {\n\t\t\tfileRef = 012AD91800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0914604896C1600030DA8 = {\n\t\t\tfileRef = 012AD91A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0914704896C1600030DA8 = {\n\t\t\tfileRef = 012AD91C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0914804896C1600030DA8 = {\n\t\t\tfileRef = 012AD91E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0914904896C1600030DA8 = {\n\t\t\tfileRef = 012AD92000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0914A04896C1600030DA8 = {\n\t\t\tfileRef = 012AD92200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0914B04896C1600030DA8 = {\n\t\t\tfileRef = 012AD92A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0914C04896C1600030DA8 = {\n\t\t\tfileRef = 012AD92D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0914D04896C1600030DA8 = {\n\t\t\tfileRef = 012AD92F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0914E04896C1600030DA8 = {\n\t\t\tfileRef = 012AD93100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0914F04896C1600030DA8 = {\n\t\t\tfileRef = 012AD93300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0915004896C1600030DA8 = {\n\t\t\tfileRef = 012AD93500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0915104896C1600030DA8 = {\n\t\t\tfileRef = 012AD93700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0915204896C1600030DA8 = {\n\t\t\tfileRef = 012AD93900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0915304896C1600030DA8 = {\n\t\t\tfileRef = 012AD93B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0915404896C1600030DA8 = {\n\t\t\tfileRef = 012AD93C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0915604896C1600030DA8 = {\n\t\t\tfileRef = 015ECC0C00894EC0C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0915704896C1600030DA8 = {\n\t\t\tfileRef = 011F78F200B25B65C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0915804896C1600030DA8 = {\n\t\t\tfileRef = 043627A600868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0915904896C1600030DA8 = {\n\t\t\tfileRef = 043627A900868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0915A04896C1600030DA8 = {\n\t\t\tfileRef = 043627B000868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0915B04896C1600030DA8 = {\n\t\t\tfileRef = 043627AE00868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0915C04896C1600030DA8 = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t4FF0915E04896C1600030DA8,\n\t\t\t\t4FF0915F04896C1600030DA8,\n\t\t\t\t4FF0916004896C1600030DA8,\n\t\t\t\t4FF0916104896C1600030DA8,\n\t\t\t\t4FF0916204896C1600030DA8,\n\t\t\t\t4FF0916304896C1600030DA8,\n\t\t\t\t4FF0916404896C1600030DA8,\n\t\t\t\t4FF0916504896C1600030DA8,\n\t\t\t\t4FF0916604896C1600030DA8,\n\t\t\t\t4FF0916704896C1600030DA8,\n\t\t\t\t4FF0916804896C1600030DA8,\n\t\t\t\t4FF0916904896C1600030DA8,\n\t\t\t\t4FF0916A04896C1600030DA8,\n\t\t\t\t4FF0916B04896C1600030DA8,\n\t\t\t\t4FF0916C04896C1600030DA8,\n\t\t\t\t4FF0916D04896C1600030DA8,\n\t\t\t\t4FF0916E04896C1600030DA8,\n\t\t\t\t4FF0916F04896C1600030DA8,\n\t\t\t\t4FF0917004896C1600030DA8,\n\t\t\t\t4FF0917104896C1600030DA8,\n\t\t\t\t4FF0917204896C1600030DA8,\n\t\t\t\t4FF0917304896C1600030DA8,\n\t\t\t\t4FF0917404896C1600030DA8,\n\t\t\t\t4FF0917504896C1600030DA8,\n\t\t\t\t4FF0917604896C1600030DA8,\n\t\t\t\t4FF0917704896C1600030DA8,\n\t\t\t\t4FF0917804896C1600030DA8,\n\t\t\t\t4FF0917904896C1600030DA8,\n\t\t\t\t4FF0917A04896C1600030DA8,\n\t\t\t\t4FF0917B04896C1600030DA8,\n\t\t\t\t4FF0917C04896C1600030DA8,\n\t\t\t\t4FF0917D04896C1600030DA8,\n\t\t\t\t4FF0917E04896C1600030DA8,\n\t\t\t\t4FF0917F04896C1600030DA8,\n\t\t\t\t4FF0918004896C1600030DA8,\n\t\t\t\t4FF0918104896C1600030DA8,\n\t\t\t\t4FF0918204896C1600030DA8,\n\t\t\t\t4FF0918304896C1600030DA8,\n\t\t\t\t4FF0918404896C1600030DA8,\n\t\t\t\t4FF0918504896C1600030DA8,\n\t\t\t\t4FF0918604896C1600030DA8,\n\t\t\t\t4FF0918704896C1600030DA8,\n\t\t\t\t4FF0918804896C1600030DA8,\n\t\t\t\t4FF0918904896C1600030DA8,\n\t\t\t\t4FF0918A04896C1600030DA8,\n\t\t\t\t4FF0918B04896C1600030DA8,\n\t\t\t\t4FF0918C04896C1600030DA8,\n\t\t\t\t4FF0918D04896C1600030DA8,\n\t\t\t\t4FF0918E04896C1600030DA8,\n\t\t\t\t4FF0918F04896C1600030DA8,\n\t\t\t\t4FF0919004896C1600030DA8,\n\t\t\t\t4FF0919104896C1600030DA8,\n\t\t\t\t4FF0919204896C1600030DA8,\n\t\t\t\t4FF0919304896C1600030DA8,\n\t\t\t\t4FF0919404896C1600030DA8,\n\t\t\t\t4FF0919504896C1600030DA8,\n\t\t\t\t4FF0919604896C1600030DA8,\n\t\t\t\t4FF0919704896C1600030DA8,\n\t\t\t\t4FF0919804896C1600030DA8,\n\t\t\t\t4FF0919904896C1600030DA8,\n\t\t\t\t4FF0919A04896C1600030DA8,\n\t\t\t\t4FF0919B04896C1600030DA8,\n\t\t\t\t4FF0919C04896C1600030DA8,\n\t\t\t\t4FF0919D04896C1600030DA8,\n\t\t\t\t4FF0919E04896C1600030DA8,\n\t\t\t\t4FF0919F04896C1600030DA8,\n\t\t\t\t4FF091A004896C1600030DA8,\n\t\t\t\t4FF091A104896C1600030DA8,\n\t\t\t\t4FF091A204896C1600030DA8,\n\t\t\t\t4FF091A304896C1600030DA8,\n\t\t\t\t4FF091A404896C1600030DA8,\n\t\t\t\t4FF091A504896C1600030DA8,\n\t\t\t\t4FF091A604896C1600030DA8,\n\t\t\t\t4FF091A704896C1600030DA8,\n\t\t\t\t4FF091A804896C1600030DA8,\n\t\t\t\t4FF091A904896C1600030DA8,\n\t\t\t\t4FF091AA04896C1600030DA8,\n\t\t\t\t4FF091AB04896C1600030DA8,\n\t\t\t\t4FF091AC04896C1600030DA8,\n\t\t\t\t4FF091AD04896C1600030DA8,\n\t\t\t\t4FF091AE04896C1600030DA8,\n\t\t\t\t4FF091AF04896C1600030DA8,\n\t\t\t\t4FF091B004896C1600030DA8,\n\t\t\t\t4FF091B104896C1600030DA8,\n\t\t\t\t4FF091B204896C1600030DA8,\n\t\t\t\t4FF091B304896C1600030DA8,\n\t\t\t\t4FF091B404896C1600030DA8,\n\t\t\t\t4FF091B504896C1600030DA8,\n\t\t\t\t4FF091B604896C1600030DA8,\n\t\t\t\t4FF091B704896C1600030DA8,\n\t\t\t\t4FF091B804896C1600030DA8,\n\t\t\t\t4FF091B904896C1600030DA8,\n\t\t\t\t4FF091BA04896C1600030DA8,\n\t\t\t\t4FF091BB04896C1600030DA8,\n\t\t\t\t4FF091BC04896C1600030DA8,\n\t\t\t\t4FF091BD04896C1600030DA8,\n\t\t\t\t4FF091BE04896C1600030DA8,\n\t\t\t\t4FF091BF04896C1600030DA8,\n\t\t\t\t4FF091C004896C1600030DA8,\n\t\t\t\t4FF091C104896C1600030DA8,\n\t\t\t\t4FF091C204896C1600030DA8,\n\t\t\t\t4FF091C304896C1600030DA8,\n\t\t\t\t4FF091C404896C1600030DA8,\n\t\t\t\t4FF091C504896C1600030DA8,\n\t\t\t\t4FF091C604896C1600030DA8,\n\t\t\t\t4FF091C704896C1600030DA8,\n\t\t\t\t4FF091C804896C1600030DA8,\n\t\t\t\t4FF091C904896C1600030DA8,\n\t\t\t\t4FF091CA04896C1600030DA8,\n\t\t\t\t4FF091CB04896C1600030DA8,\n\t\t\t\t4FF091CC04896C1600030DA8,\n\t\t\t\t4FF091CD04896C1600030DA8,\n\t\t\t\t4FF091CE04896C1600030DA8,\n\t\t\t\t4FF091CF04896C1600030DA8,\n\t\t\t\t4FF091D004896C1600030DA8,\n\t\t\t\t4FF091D104896C1600030DA8,\n\t\t\t\t4FF091D304896C1600030DA8,\n\t\t\t\t4FF091D404896C1600030DA8,\n\t\t\t\t4FF091D504896C1600030DA8,\n\t\t\t\t4FF091D604896C1600030DA8,\n\t\t\t\t4FF091D704896C1600030DA8,\n\t\t\t\t4FF091D804896C1600030DA8,\n\t\t\t\t4FF091D904896C1600030DA8,\n\t\t\t\t4FF091DD04896C1600030DA8,\n\t\t\t\t4FF091DF04896C1600030DA8,\n\t\t\t);\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t4FF0915E04896C1600030DA8 = {\n\t\t\tfileRef = 012ADB0200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0915F04896C1600030DA8 = {\n\t\t\tfileRef = 012ADAFF00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0916004896C1600030DA8 = {\n\t\t\tfileRef = 012ADB0100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0916104896C1600030DA8 = {\n\t\t\tfileRef = 012ADAFC00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0916204896C1600030DA8 = {\n\t\t\tfileRef = 012ADAFB00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0916304896C1600030DA8 = {\n\t\t\tfileRef = 012ADAFA00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0916404896C1600030DA8 = {\n\t\t\tfileRef = 016F1B6300ACDA9BC697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0916504896C1600030DA8 = {\n\t\t\tfileRef = 012ADAF900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0916604896C1600030DA8 = {\n\t\t\tfileRef = 012ADAF800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0916704896C1600030DA8 = {\n\t\t\tfileRef = 012ADAF700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0916804896C1600030DA8 = {\n\t\t\tfileRef = 012ADAF600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0916904896C1600030DA8 = {\n\t\t\tfileRef = 012ADAF500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0916A04896C1600030DA8 = {\n\t\t\tfileRef = 012ADAF400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0916B04896C1600030DA8 = {\n\t\t\tfileRef = 012ADAF100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0916C04896C1600030DA8 = {\n\t\t\tfileRef = 012ADAEF00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0916D04896C1600030DA8 = {\n\t\t\tfileRef = 012ADAED00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0916E04896C1600030DA8 = {\n\t\t\tfileRef = 012ADB2500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0916F04896C1600030DA8 = {\n\t\t\tfileRef = 012ADB2600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0917004896C1600030DA8 = {\n\t\t\tfileRef = 012ADB2700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0917104896C1600030DA8 = {\n\t\t\tfileRef = 012ADB2800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0917204896C1600030DA8 = {\n\t\t\tfileRef = 012ADB2900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0917304896C1600030DA8 = {\n\t\t\tfileRef = 012ADB2A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0917404896C1600030DA8 = {\n\t\t\tfileRef = 012ADB2B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0917504896C1600030DA8 = {\n\t\t\tfileRef = 012ADB2D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0917604896C1600030DA8 = {\n\t\t\tfileRef = 012ADB2E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0917704896C1600030DA8 = {\n\t\t\tfileRef = 012ADB5700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0917804896C1600030DA8 = {\n\t\t\tfileRef = 012ADB5800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0917904896C1600030DA8 = {\n\t\t\tfileRef = 012ADB3800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0917A04896C1600030DA8 = {\n\t\t\tfileRef = 012ADB3B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0917B04896C1600030DA8 = {\n\t\t\tfileRef = 012ADB3E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0917C04896C1600030DA8 = {\n\t\t\tfileRef = 012ADB0A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0917D04896C1600030DA8 = {\n\t\t\tfileRef = 012ADB0B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0917E04896C1600030DA8 = {\n\t\t\tfileRef = 012ADB0C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0917F04896C1600030DA8 = {\n\t\t\tfileRef = 012ADB0D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0918004896C1600030DA8 = {\n\t\t\tfileRef = 012ADB0E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0918104896C1600030DA8 = {\n\t\t\tfileRef = 012ADB0F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0918204896C1600030DA8 = {\n\t\t\tfileRef = 012ADB1000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0918304896C1600030DA8 = {\n\t\t\tfileRef = 012ADB1100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0918404896C1600030DA8 = {\n\t\t\tfileRef = 012ADB1200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0918504896C1600030DA8 = {\n\t\t\tfileRef = 012ADB1300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0918604896C1600030DA8 = {\n\t\t\tfileRef = 012ADB1500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0918704896C1600030DA8 = {\n\t\t\tfileRef = 012ADB1600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0918804896C1600030DA8 = {\n\t\t\tfileRef = 012ADB1700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0918904896C1600030DA8 = {\n\t\t\tfileRef = 012ADB1800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0918A04896C1600030DA8 = {\n\t\t\tfileRef = 012ADB1900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0918B04896C1600030DA8 = {\n\t\t\tfileRef = 012ADB1B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0918C04896C1600030DA8 = {\n\t\t\tfileRef = 012ADB1C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0918D04896C1600030DA8 = {\n\t\t\tfileRef = 012ADB1D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0918E04896C1600030DA8 = {\n\t\t\tfileRef = 012ADB1E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0918F04896C1600030DA8 = {\n\t\t\tfileRef = 012ADB1F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0919004896C1600030DA8 = {\n\t\t\tfileRef = 012ADB2000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0919104896C1600030DA8 = {\n\t\t\tfileRef = 012ADB2100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0919204896C1600030DA8 = {\n\t\t\tfileRef = 012ADB2200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0919304896C1600030DA8 = {\n\t\t\tfileRef = 012ADA6600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0919404896C1600030DA8 = {\n\t\t\tfileRef = 012ADA6800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0919504896C1600030DA8 = {\n\t\t\tfileRef = 012ADA6900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0919604896C1600030DA8 = {\n\t\t\tfileRef = 012ADA6A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0919704896C1600030DA8 = {\n\t\t\tfileRef = 012ADA6B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0919804896C1600030DA8 = {\n\t\t\tfileRef = 012ADA6D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0919904896C1600030DA8 = {\n\t\t\tfileRef = 012ADA6E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0919A04896C1600030DA8 = {\n\t\t\tfileRef = 012ADA6F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0919B04896C1600030DA8 = {\n\t\t\tfileRef = 012ADA7000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0919C04896C1600030DA8 = {\n\t\t\tfileRef = 012ADA7100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0919D04896C1600030DA8 = {\n\t\t\tfileRef = 012ADA7300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0919E04896C1600030DA8 = {\n\t\t\tfileRef = 012ADA7400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF0919F04896C1600030DA8 = {\n\t\t\tfileRef = 012ADA7500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091A004896C1600030DA8 = {\n\t\t\tfileRef = 012ADA7600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091A104896C1600030DA8 = {\n\t\t\tfileRef = 012ADA7800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091A204896C1600030DA8 = {\n\t\t\tfileRef = 012ADA7900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091A304896C1600030DA8 = {\n\t\t\tfileRef = 012ADA7B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091A404896C1600030DA8 = {\n\t\t\tfileRef = 012ADA7C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091A504896C1600030DA8 = {\n\t\t\tfileRef = 012ADA7D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091A604896C1600030DA8 = {\n\t\t\tfileRef = 012ADA7F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091A704896C1600030DA8 = {\n\t\t\tfileRef = 012ADA8000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091A804896C1600030DA8 = {\n\t\t\tfileRef = 012ADA8200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091A904896C1600030DA8 = {\n\t\t\tfileRef = 012ADA8300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091AA04896C1600030DA8 = {\n\t\t\tfileRef = 012ADA8400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091AB04896C1600030DA8 = {\n\t\t\tfileRef = 012ADA8500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091AC04896C1600030DA8 = {\n\t\t\tfileRef = 012ADA8900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091AD04896C1600030DA8 = {\n\t\t\tfileRef = 012ADA8800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091AE04896C1600030DA8 = {\n\t\t\tfileRef = 012ADA8B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091AF04896C1600030DA8 = {\n\t\t\tfileRef = 012ADA8D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091B004896C1600030DA8 = {\n\t\t\tfileRef = 012ADA9000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091B104896C1600030DA8 = {\n\t\t\tfileRef = 012ADA9600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091B204896C1600030DA8 = {\n\t\t\tfileRef = 012ADA9800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091B304896C1600030DA8 = {\n\t\t\tfileRef = 012ADAA200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091B404896C1600030DA8 = {\n\t\t\tfileRef = 012ADA6000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091B504896C1600030DA8 = {\n\t\t\tfileRef = 012ADA6100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091B604896C1600030DA8 = {\n\t\t\tfileRef = 012AD90A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091B704896C1600030DA8 = {\n\t\t\tfileRef = 012AD90B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091B804896C1600030DA8 = {\n\t\t\tfileRef = 012AD90D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091B904896C1600030DA8 = {\n\t\t\tfileRef = 012AD91000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091BA04896C1600030DA8 = {\n\t\t\tfileRef = 012AD91200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091BB04896C1600030DA8 = {\n\t\t\tfileRef = 012AD91500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091BC04896C1600030DA8 = {\n\t\t\tfileRef = 012AD91700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091BD04896C1600030DA8 = {\n\t\t\tfileRef = 012AD91900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091BE04896C1600030DA8 = {\n\t\t\tfileRef = 012AD91B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091BF04896C1600030DA8 = {\n\t\t\tfileRef = 012AD91D00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091C004896C1600030DA8 = {\n\t\t\tfileRef = 012AD91F00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091C104896C1600030DA8 = {\n\t\t\tfileRef = 012AD92100868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091C204896C1600030DA8 = {\n\t\t\tfileRef = 012AD92300868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091C304896C1600030DA8 = {\n\t\t\tfileRef = 012AD92400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091C404896C1600030DA8 = {\n\t\t\tfileRef = 012AD92500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091C504896C1600030DA8 = {\n\t\t\tfileRef = 012AD92600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091C604896C1600030DA8 = {\n\t\t\tfileRef = 012AD92700868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091C704896C1600030DA8 = {\n\t\t\tfileRef = 012AD92800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091C804896C1600030DA8 = {\n\t\t\tfileRef = 012AD92900868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091C904896C1600030DA8 = {\n\t\t\tfileRef = 012AD92B00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091CA04896C1600030DA8 = {\n\t\t\tfileRef = 012AD92C00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091CB04896C1600030DA8 = {\n\t\t\tfileRef = 012AD92E00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091CC04896C1600030DA8 = {\n\t\t\tfileRef = 012AD93000868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091CD04896C1600030DA8 = {\n\t\t\tfileRef = 012AD93200868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091CE04896C1600030DA8 = {\n\t\t\tfileRef = 012AD93400868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091CF04896C1600030DA8 = {\n\t\t\tfileRef = 012AD93600868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091D004896C1600030DA8 = {\n\t\t\tfileRef = 012AD93800868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091D104896C1600030DA8 = {\n\t\t\tfileRef = 012AD93A00868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091D304896C1600030DA8 = {\n\t\t\tfileRef = 015ECC0D00894EC0C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091D404896C1600030DA8 = {\n\t\t\tfileRef = 043627A700868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091D504896C1600030DA8 = {\n\t\t\tfileRef = 016B4A3B00ACCF9FC697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091D604896C1600030DA8 = {\n\t\t\tfileRef = 043627A800868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091D704896C1600030DA8 = {\n\t\t\tfileRef = 043627AD00868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091D804896C1600030DA8 = {\n\t\t\tfileRef = 043627B100868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091D904896C1600030DA8 = {\n\t\t\tfileRef = 043627AF00868916C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091DD04896C1600030DA8 = {\n\t\t\tfileRef = 012ADAB500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091DF04896C1600030DA8 = {\n\t\t\tfileRef = 4FB23863047AB9F60098ACF3;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091E004896C1600030DA8 = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t4FF091E104896C1600030DA8,\n\t\t\t\t4FF091E204896C1600030DA8,\n\t\t\t\t4FF091E304896C1600030DA8,\n\t\t\t\t4FF091E404896C1600030DA8,\n\t\t\t\t4FF091E504896C1600030DA8,\n\t\t\t\t4FF091E604896C1600030DA8,\n\t\t\t);\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t4FF091E104896C1600030DA8 = {\n\t\t\tfileRef = 0654BA58FE8ECEE0C697A12F;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091E204896C1600030DA8 = {\n\t\t\tfileRef = 0654BA59FE8ECEE0C697A12F;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091E304896C1600030DA8 = {\n\t\t\tfileRef = 00E9D914FEDB4D29C697A12F;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091E404896C1600030DA8 = {\n\t\t\tfileRef = 0654BA5AFE8ECEE0C697A12F;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091E504896C1600030DA8 = {\n\t\t\tfileRef = 0654BA5BFE8ECEE0C697A12F;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091E604896C1600030DA8 = {\n\t\t\tfileRef = F564505801E623B201F62882;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\t4FF091E704896C1600030DA8 = {\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tisa = PBXRezBuildPhase;\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t4FF091E804896C1600030DA8 = {\n\t\t\texplicitFileType = \"compiled.mach-o.executable\";\n\t\t\tisa = PBXFileReference;\n\t\t\tpath = Q3DedicatedServer;\n\t\t\trefType = 3;\n\t\t\tsourceTree = BUILT_PRODUCTS_DIR;\n\t\t};\n\t\t4FF091EA04897B0000030DA8 = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 4FF0904804896C0E00030DA8;\n\t\t\ttargetProxy = 1895FF2E065E291B00F8B3F4;\n\t\t};\n//4F0\n//4F1\n//4F2\n//4F3\n//4F4\n//F50\n//F51\n//F52\n//F53\n//F54\n\t\tF54951E80354E75E011BCB42 = {\n\t\t\tfileRef = F564505801E623B201F62882;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\tF54951F40354EAA2011BCB42 = {\n\t\t\tfileRef = 012ADAB500868211C697A10E;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\tF564505801E623B201F62882 = {\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = wrapper.framework;\n\t\t\tname = IOKit.framework;\n\t\t\tpath = /System/Library/Frameworks/IOKit.framework;\n\t\t\trefType = 0;\n\t\t\tsourceTree = \"<absolute>\";\n\t\t};\n\t\tF564505901E623B201F62882 = {\n\t\t\tfileRef = F564505801E623B201F62882;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\tF5D8C5E0035259DF0106E832 = {\n\t\t\tfileRef = 0654BA59FE8ECEE0C697A12F;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t\tF5ED1435037096A001F6289A = {\n\t\t\tfileEncoding = 30;\n\t\t\tisa = PBXFileReference;\n\t\t\tlastKnownFileType = sourcecode.c.h;\n\t\t\tpath = splines.h;\n\t\t\trefType = 4;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tF5ED1436037096A001F6289A = {\n\t\t\tfileRef = F5ED1435037096A001F6289A;\n\t\t\tisa = PBXBuildFile;\n\t\t\tsettings = {\n\t\t\t};\n\t\t};\n\t};\n\trootObject = 0654BA41FE8ECEE0C697A12F;\n}\n"
  },
  {
    "path": "code/macosx/RecordDemo.zsh",
    "content": "#!/bin/zsh -x\n\n/Local/Public/bungi/BuildOutput/Quake3.app/Contents/MacOS/Quake3 \\\n  +set sv_pure 0 \\\n  +set g_syncronousClients 1 \\\n  +map q3dm6 \\\n  +record foo\n\n\n"
  },
  {
    "path": "code/macosx/botlib.log",
    "content": "item team_redobelisk has modelindex 0item team_blueobelisk has modelindex 0item team_neutralobelisk has modelindex 0item item_botroam has modelindex 0entity worldspawn unknown item\nentity target_delay unknown item\nentity light unknown item\nentity target_delay unknown item\nentity target_speaker unknown item\nentity trigger_multiple unknown item\nentity target_speaker unknown item\nentity trigger_multiple unknown item\nentity target_speaker unknown item\nentity trigger_multiple unknown item\nentity target_speaker unknown item\nentity trigger_multiple unknown item\nentity target_speaker unknown item\nentity trigger_multiple unknown item\nentity target_speaker unknown item\nentity trigger_multiple unknown item\nentity misc_model unknown item\nentity light unknown item\nentity light unknown item\nentity target_speaker unknown item\nentity target_speaker unknown item\nentity func_timer unknown item\nentity target_speaker unknown item\nentity target_speaker unknown item\nentity target_position unknown item\nentity info_player_intermission unknown item\nentity target_speaker unknown item\nentity func_timer unknown item\nentity target_speaker unknown item\nentity misc_model unknown item\nentity light unknown item\nentity misc_teleporter_dest unknown item\nentity target_position unknown item\nentity misc_portal_camera unknown item\nentity light unknown item\nentity light unknown item\nentity target_position unknown item\nentity light unknown item\nentity info_player_deathmatch unknown item\nentity light unknown item\nentity light unknown item\nentity info_null unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity target_position unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity info_player_deathmatch unknown item\nentity info_player_deathmatch unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity misc_model unknown item\nentity light unknown item\nentity light unknown item\nentity misc_model unknown item\nentity info_player_deathmatch unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity trigger_multiple unknown item\nentity func_timer unknown item\nentity target_speaker unknown item\nentity trigger_multiple unknown item\nentity func_timer unknown item\nentity target_speaker unknown item\nentity target_speaker unknown item\nentity trigger_teleport unknown item\nentity misc_portal_surface unknown item\nentity misc_portal_surface unknown item\nentity info_player_deathmatch unknown item\nentity misc_model unknown item\nentity light unknown item\nentity func_rotating unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity target_position unknown item\nentity light unknown item\nentity light unknown item\nentity target_position unknown item\nentity light unknown item\nentity light unknown item\nentity func_rotating unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity light unknown item\nentity misc_model unknown item\nentity misc_model unknown item\nentity func_timer unknown item\nentity target_speaker unknown item\nentity target_speaker unknown item\nentity func_timer unknown item\nentity target_speaker unknown item\nentity func_timer unknown item\nentity target_speaker unknown item\nentity func_door unknown item\nentity func_door unknown item\nentity light unknown item\nentity light unknown item\nentity misc_model unknown item\nentity light unknown item\nbots/crash_c.cskill 1073741824\n{\n    0 Crash\n    1 female\n    2 0.366667\n    3 bots/crash_w.c\n    4 0.366667\n    5 180\n    6 4.166667\n    7 0.366667\n    8 0.366667\n    9 0.450000\n   10 0.450000\n   11 0.450000\n   12 0.450000\n   13 0.450000\n   14 0.450000\n   15 0.450000\n   16 0.366667\n   17 0.450000\n   18 0.450000\n   19 0.450000\n   20 0.450000\n   21 bots/crash_t.c\n   22 crash\n   23 400\n   24 0.400000\n   25 1.000000\n   26 1.000000\n   27 1.000000\n   28 1.000000\n   29 1.000000\n   30 1.000000\n   31 1.000000\n   32 1.000000\n   33 1.000000\n   34 1.000000\n   35 1.000000\n   36 0.000000\n   37 0.000000\n   38 0.000000\n   39 0.000000\n   40 bots/crash_i.c\n   41 0.233333\n   42 0.233333\n   43 0.233333\n   44 0.233333\n   45 0.000000\n   46 0.233333\n   47 0.333333\n   48 1.000000\n}\nitem info 7 \"weapon_gauntlet\" has no fuzzy weight\nitem info 16 \"weapon_grapplinghook\" has no fuzzy weight\nitem info 49 \"team_redobelisk\" has no fuzzy weight\nitem info 50 \"team_blueobelisk\" has no fuzzy weight\nitem info 51 \"team_neutralobelisk\" has no fuzzy weight\n"
  },
  {
    "path": "code/macosx/macosx_display.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"tr_local.h\"\n#include \"macosx_local.h\"\n\n@class NSDictionary;\n\nextern NSDictionary *Sys_GetMatchingDisplayMode(qboolean allowStretchedModes);\n\nextern void Sys_StoreGammaTables();\nextern void Sys_GetGammaTable(glwgamma_t *table);\nextern void Sys_SetScreenFade(glwgamma_t *table, float fraction);\n\nextern void Sys_FadeScreens();\nextern void Sys_FadeScreen(CGDirectDisplayID display);\nextern void Sys_UnfadeScreens();\nextern void Sys_UnfadeScreen(CGDirectDisplayID display, glwgamma_t *table);\nextern void Sys_ReleaseAllDisplays();\n\n"
  },
  {
    "path": "code/macosx/macosx_display.m",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#import \"macosx_display.h\"\n\n#include \"tr_local.h\"\n#import \"macosx_local.h\"\n\n#import <Foundation/Foundation.h>\n#import <IOKit/graphics/IOGraphicsTypes.h>  // for interpreting the kCGDisplayIOFlags element of the display mode\n\n\nNSDictionary *Sys_GetMatchingDisplayMode(qboolean allowStretchedModes)\n{\n    NSArray *displayModes;\n    NSDictionary *mode;\n    unsigned int modeIndex, modeCount, bestModeIndex;\n    int verbose;\n    cvar_t *cMinFreq, *cMaxFreq;\n    int minFreq, maxFreq;\n    unsigned int colorDepth;\n    \n    verbose = r_verbose->integer;\n\n    colorDepth = r_colorbits->integer;\n    if (colorDepth < 16 || !r_fullscreen->integer)\n        colorDepth = [[glw_state.desktopMode objectForKey: (id)kCGDisplayBitsPerPixel] intValue];\n\n    cMinFreq = ri.Cvar_Get(\"r_minDisplayRefresh\", \"0\", CVAR_ARCHIVE);\n    cMaxFreq = ri.Cvar_Get(\"r_maxDisplayRefresh\", \"0\", CVAR_ARCHIVE);\n\n    if (cMinFreq && cMaxFreq && cMinFreq->integer && cMaxFreq->integer &&\n        cMinFreq->integer > cMaxFreq->integer) {\n        ri.Error(ERR_FATAL, \"r_minDisplayRefresh must be less than or equal to r_maxDisplayRefresh\");\n    }\n\n    minFreq = cMinFreq ? cMinFreq->integer : 0;\n    maxFreq = cMaxFreq ? cMaxFreq->integer : 0;\n    \n    displayModes = (NSArray *)CGDisplayAvailableModes(glw_state.display);\n    if (!displayModes) {\n        ri.Error(ERR_FATAL, \"CGDisplayAvailableModes returned NULL -- 0x%0x is an invalid display\", glw_state.display);\n    }\n    \n    modeCount = [displayModes count];\n    if (verbose) {\n        ri.Printf(PRINT_ALL, \"%d modes avaliable\\n\", modeCount);\n        ri.Printf(PRINT_ALL, \"Current mode is %s\\n\", [[(id)CGDisplayCurrentMode(glw_state.display) description] cString]);\n    }\n    \n    // Default to the current desktop mode\n    bestModeIndex = 0xFFFFFFFF;\n    \n    for ( modeIndex = 0; modeIndex < modeCount; ++modeIndex ) {\n        id object;\n        int refresh;\n        \n        mode = [displayModes objectAtIndex: modeIndex];\n        if (verbose) {\n            ri.Printf(PRINT_ALL, \" mode %d -- %s\\n\", modeIndex, [[mode description] cString]);\n        }\n\n        // Make sure we get the right size\n        object = [mode objectForKey: (id)kCGDisplayWidth];\n\n        if ([[mode objectForKey: (id)kCGDisplayWidth] intValue] != glConfig.vidWidth ||\n            [[mode objectForKey: (id)kCGDisplayHeight] intValue] != glConfig.vidHeight) {\n            if (verbose)\n                ri.Printf(PRINT_ALL, \" -- bad size\\n\");\n            continue;\n        }\n\n        if (!allowStretchedModes) {\n            if ([[mode objectForKey: (id)kCGDisplayIOFlags] intValue] & kDisplayModeStretchedFlag) {\n                if (verbose)\n                    ri.Printf(PRINT_ALL, \" -- stretched modes disallowed\\n\");\n                continue;\n            }\n        }\n\n        // Make sure that our frequency restrictions are observed\n        refresh = [[mode objectForKey: (id)kCGDisplayRefreshRate] intValue];\n        if (minFreq &&  refresh < minFreq) {\n            if (verbose)\n                ri.Printf(PRINT_ALL, \" -- refresh too low\\n\");\n            continue;\n        }\n\n        if (maxFreq && refresh > maxFreq) {\n            if (verbose)\n                ri.Printf(PRINT_ALL, \" -- refresh too high\\n\");\n            continue;\n        }\n\n        if ([[mode objectForKey: (id)kCGDisplayBitsPerPixel] intValue] != colorDepth) {\n            if (verbose)\n                ri.Printf(PRINT_ALL, \" -- bad depth\\n\");\n            continue;\n        }\n\n        bestModeIndex = modeIndex;\n        if (verbose)\n            ri.Printf(PRINT_ALL, \" -- OK\\n\", bestModeIndex);\n    }\n\n    if (verbose)\n        ri.Printf(PRINT_ALL, \" bestModeIndex = %d\\n\", bestModeIndex);\n\n    if (bestModeIndex == 0xFFFFFFFF) {\n        ri.Printf(PRINT_ALL, \"No suitable display mode available.\\n\");\n        return nil;\n    }\n    \n    return [displayModes objectAtIndex: bestModeIndex];\n}\n\n\n#define MAX_DISPLAYS 128\n\nvoid Sys_GetGammaTable(glwgamma_t *table)\n{\n    CGTableCount tableSize = 512;\n    CGDisplayErr err;\n    \n    table->tableSize = tableSize;\n    if (table->red)\n        free(table->red);\n    table->red = malloc(tableSize * sizeof(*table->red));\n    if (table->green)\n        free(table->green);\n    table->green = malloc(tableSize * sizeof(*table->green));\n    if (table->blue)\n        free(table->blue);\n    table->blue = malloc(tableSize * sizeof(*table->blue));\n    \n    // TJW: We _could_ loop here if we get back the same size as our table, increasing the table size.\n    err = CGGetDisplayTransferByTable(table->display, tableSize, table->red, table->green, table->blue,\n&table->tableSize);\n    if (err != CGDisplayNoErr) {\n        Com_Printf(\"GLimp_Init: CGGetDisplayTransferByTable returned %d.\\n\", err);\n        table->tableSize = 0;\n    }\n}\n\nvoid Sys_SetGammaTable(glwgamma_t *table)\n{\n}\n\n\nvoid Sys_StoreGammaTables()\n{\n    // Store the original gamma for all monitors so that we can fade and unfade them all\n    CGDirectDisplayID displays[MAX_DISPLAYS];\n    CGDisplayCount displayIndex;\n    CGDisplayErr err;\n\n    err = CGGetActiveDisplayList(MAX_DISPLAYS, displays, &glw_state.displayCount);\n    if (err != CGDisplayNoErr)\n        Sys_Error(\"Cannot get display list -- CGGetActiveDisplayList returned %d.\\n\", err);\n    \n    glw_state.originalDisplayGammaTables = calloc(glw_state.displayCount, sizeof(*glw_state.originalDisplayGammaTables));\n    for (displayIndex = 0; displayIndex < glw_state.displayCount; displayIndex++) {\n        glwgamma_t *table;\n\n        table = &glw_state.originalDisplayGammaTables[displayIndex];\n        table->display = displays[displayIndex];\n        Sys_GetGammaTable(table);\n    }\n}\n\n\n//  This isn't a mathematically correct fade, but we don't care that much.\nvoid Sys_SetScreenFade(glwgamma_t *table, float fraction)\n{\n    CGTableCount tableSize;\n    CGGammaValue *red, *blue, *green;\n    CGTableCount gammaIndex;\n    \n    if (!glConfig.deviceSupportsGamma)\n        return;\n\n    if (!(tableSize = table->tableSize))\n        // we couldn't get the table for this display for some reason\n        return;\n    \n//    Com_Printf(\"0x%08x %f\\n\", table->display, fraction);\n    \n    red = glw_state.tempTable.red;\n    green = glw_state.tempTable.green;\n    blue = glw_state.tempTable.blue;\n    if (glw_state.tempTable.tableSize < tableSize) {\n        glw_state.tempTable.tableSize = tableSize;\n        red = realloc(red, sizeof(*red) * tableSize);\n        green = realloc(green, sizeof(*green) * tableSize);\n        blue = realloc(blue, sizeof(*blue) * tableSize);\n        glw_state.tempTable.red = red;\n        glw_state.tempTable.green = green;\n        glw_state.tempTable.blue = blue;\n    }\n\n    for (gammaIndex = 0; gammaIndex < table->tableSize; gammaIndex++) {\n        red[gammaIndex] = table->red[gammaIndex] * fraction;\n        blue[gammaIndex] = table->blue[gammaIndex] * fraction;\n        green[gammaIndex] = table->green[gammaIndex] * fraction;\n    }\n    \n    CGSetDisplayTransferByTable(table->display, table->tableSize, red, green, blue);\n}\n\n// Fades all the active displays at the same time.\n\n#define FADE_DURATION 0.5\nvoid Sys_FadeScreens()\n{\n    CGDisplayCount displayIndex;\n    int stepIndex;\n    glwgamma_t *table;\n    NSTimeInterval start, current;\n    float time;\n    \n    if (!glConfig.deviceSupportsGamma)\n        return;\n\n    Com_Printf(\"Fading all displays\\n\");\n    \n    start = [NSDate timeIntervalSinceReferenceDate];\n    time = 0.0;\n    while (time != FADE_DURATION) {\n        current = [NSDate timeIntervalSinceReferenceDate];\n        time = current - start;\n        if (time > FADE_DURATION)\n            time = FADE_DURATION;\n            \n        for (displayIndex = 0; displayIndex < glw_state.displayCount; displayIndex++) {            \n            table = &glw_state.originalDisplayGammaTables[displayIndex];\n            Sys_SetScreenFade(table, 1.0 - time / FADE_DURATION);\n        }\n    }\n}\n\nvoid Sys_FadeScreen(CGDirectDisplayID display)\n{\n    CGDisplayCount displayIndex;\n    glwgamma_t *table;\n    int stepIndex;\n    \n    if (!glConfig.deviceSupportsGamma)\n        return;\n\n    Com_Printf(\"Fading display 0x%08x\\n\", display);\n\n    for (displayIndex = 0; displayIndex < glw_state.displayCount; displayIndex++) {\n        if (display == glw_state.originalDisplayGammaTables[displayIndex].display) {\n            NSTimeInterval start, current;\n            float time;\n            \n            start = [NSDate timeIntervalSinceReferenceDate];\n            time = 0.0;\n\n            table = &glw_state.originalDisplayGammaTables[displayIndex];\n            while (time != FADE_DURATION) {\n                current = [NSDate timeIntervalSinceReferenceDate];\n                time = current - start;\n                if (time > FADE_DURATION)\n                    time = FADE_DURATION;\n\n                Sys_SetScreenFade(table, 1.0 - time / FADE_DURATION);\n            }\n            return;\n        }\n    }\n\n    Com_Printf(\"Unable to find display to fade it\\n\");\n}\n\nvoid Sys_UnfadeScreens()\n{\n    CGDisplayCount displayIndex;\n    int stepIndex;\n    glwgamma_t *table;\n    NSTimeInterval start, current;\n    float time;\n    \n    if (!glConfig.deviceSupportsGamma)\n        return;\n        \n    Com_Printf(\"Unfading all displays\\n\");\n\n    start = [NSDate timeIntervalSinceReferenceDate];\n    time = 0.0;\n    while (time != FADE_DURATION) {\n        current = [NSDate timeIntervalSinceReferenceDate];\n        time = current - start;\n        if (time > FADE_DURATION)\n            time = FADE_DURATION;\n            \n        for (displayIndex = 0; displayIndex < glw_state.displayCount; displayIndex++) {            \n            table = &glw_state.originalDisplayGammaTables[displayIndex];\n            Sys_SetScreenFade(table, time / FADE_DURATION);\n        }\n    }\n}\n\nvoid Sys_UnfadeScreen(CGDirectDisplayID display, glwgamma_t *table)\n{\n    CGDisplayCount displayIndex;\n    int stepIndex;\n    \n    if (!glConfig.deviceSupportsGamma)\n        return;\n    \n    Com_Printf(\"Unfading display 0x%08x\\n\", display);\n\n    if (table) {\n        CGTableCount i;\n        \n        Com_Printf(\"Given table:\\n\");\n        for (i = 0; i < table->tableSize; i++) {\n            Com_Printf(\"  %f %f %f\\n\", table->red[i], table->blue[i], table->green[i]);\n        }\n    }\n    \n    // Search for the original gamma table for the display\n    if (!table) {\n        for (displayIndex = 0; displayIndex < glw_state.displayCount; displayIndex++) {\n            if (display == glw_state.originalDisplayGammaTables[displayIndex].display) {\n                table = &glw_state.originalDisplayGammaTables[displayIndex];\n                break;\n            }\n        }\n    }\n    \n    if (table) {\n        NSTimeInterval start, current;\n        float time;\n        \n        start = [NSDate timeIntervalSinceReferenceDate];\n        time = 0.0;\n\n        while (time != FADE_DURATION) {\n            current = [NSDate timeIntervalSinceReferenceDate];\n            time = current - start;\n            if (time > FADE_DURATION)\n                time = FADE_DURATION;\n            Sys_SetScreenFade(table, time / FADE_DURATION);\n        }\n        return;\n    }\n    \n    Com_Printf(\"Unable to find display to unfade it\\n\");\n}\n\n\n\n"
  },
  {
    "path": "code/macosx/macosx_glimp.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include <OpenGL/OpenGL.h>\n#include <OpenGL/gl.h>\n#include <OpenGL/glu.h>\n#ifndef GL_EXT_abgr\n#include <OpenGL/glext.h>\n#endif\n\n// This can be defined to use the CGLMacro.h support which avoids looking up\n// the current context.\n//#define USE_CGLMACROS\n\n#ifdef USE_CGLMACROS\n#include \"macosx_local.h\"\n#define cgl_ctx glw_state._cgl_ctx\n#include <OpenGL/CGLMacro.h>\n#endif\n"
  },
  {
    "path": "code/macosx/macosx_glimp.m",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#import \"macosx_glimp.h\"\n\n#include \"tr_local.h\"\n#import \"macosx_local.h\"\n#import \"macosx_display.h\"\n#import \"macosx_timers.h\"\n\n#import <AppKit/AppKit.h>\n#import <Foundation/Foundation.h>\n\n#import <mach-o/dyld.h>\n#import <mach/mach.h>\n#import <mach/mach_error.h>\n\ncvar_t\t*r_allowSoftwareGL;\t\t// don't abort out if the pixelformat claims software\ncvar_t  *r_enablerender;                // Enable actual rendering\ncvar_t  *r_appleTransformHint;          // Enable Apple transform hint\n\nstatic void GLW_InitExtensions( void );\nstatic qboolean CreateGameWindow( qboolean isSecondTry );\nstatic unsigned long Sys_QueryVideoMemory();\nstatic CGDisplayErr Sys_CaptureActiveDisplays(void);\n\n\nglwstate_t glw_state;\nqboolean Sys_IsHidden = qfalse;\n\n#ifdef OMNI_TIMER\nOTStampList glThreadStampList;\n#endif\n\n@interface NSOpenGLContext (CGLContextAccess)\n- (CGLContextObj) cglContext;\n@end\n\n@implementation NSOpenGLContext (CGLContextAccess)\n- (CGLContextObj) cglContext;\n{\n    return _contextAuxiliary;\n}\n@end\n\n/*\n============\nCheckErrors\n============\n*/\nvoid CheckErrors( void )\n{\t\t\n    GLenum   err;\n\n    err = qglGetError();\n    if ( err != GL_NO_ERROR ) {\n        ri.Error( ERR_FATAL, \"glGetError: %s\\n\", qglGetString( err ) );\n    }\n}\n\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n\nunsigned int QGLBeginStarted = 0;\n\nvoid QGLErrorBreak(void)\n{\n}\n\nvoid QGLCheckError(const char *message)\n{\n    GLenum        error;\n    static unsigned int errorCount = 0;\n    \n    error = _glGetError();\n    if (error != GL_NO_ERROR) {\n        if (errorCount == 100) {\n            Com_Printf(\"100 GL errors printed ... disabling further error reporting.\\n\");\n        } else if (errorCount < 100) {\n            if (errorCount == 0) {\n                fprintf(stderr, \"BREAK ON QGLErrorBreak to stop at the GL errors\\n\");\n            }\n            fprintf(stderr, \"OpenGL Error(%s): 0x%04x -- %s\\n\", message, (int)error,  gluErrorString(error));\n            QGLErrorBreak();\n        }\n        errorCount++;\n    }\n}\n#endif\n\n/*\n** GLimp_SetMode\n*/\n\nqboolean GLimp_SetMode( qboolean isSecondTry )\n{\n    if ( !CreateGameWindow(isSecondTry) ) {\n        ri.Printf( PRINT_ALL, \"GLimp_Init: window could not be created!\\n\" );\n        return qfalse;\n    }\n\n    // draw something to show that GL is alive\t\n    if (r_enablerender->integer) {\n        qglClearColor( 0.5, 0.5, 0.7, 0 );\n        qglClear( GL_COLOR_BUFFER_BIT );\n        GLimp_EndFrame();\n        \n        qglClearColor( 0.5, 0.5, 0.7, 0 );\n        qglClear( GL_COLOR_BUFFER_BIT );\n        GLimp_EndFrame();\n    }\n\n    Sys_UnfadeScreen(Sys_DisplayToUse(), NULL);\n    \n    CheckErrors();\n\n    return qtrue;\n}\n\n/*\n =================\n GetPixelAttributes\n =================\n */\n\n#define ADD_ATTR(x) \\\ndo { \\\n    if (attributeIndex >= attributeSize) { \\\n        attributeSize *= 2; \\\n        pixelAttributes = NSZoneRealloc(NULL, pixelAttributes, sizeof(*pixelAttributes) * attributeSize); \\\n    } \\\n    pixelAttributes[attributeIndex] = x; \\\n    attributeIndex++; \\\n    if (verbose) { \\\n        ri.Printf(PRINT_ALL, \"Adding pixel attribute: %d (%s)\\n\", x, #x); \\\n    } \\\n} while(0)\n\nstatic NSOpenGLPixelFormatAttribute *GetPixelAttributes()\n{\n    NSOpenGLPixelFormatAttribute *pixelAttributes;\n    unsigned int attributeIndex = 0;\n    unsigned int attributeSize = 128;\n    int verbose = 0;\n    unsigned int colorDepth;\n    \n    verbose = r_verbose->integer;\n    \n    pixelAttributes = NSZoneMalloc(NULL, sizeof(*pixelAttributes) * attributeSize);\n\n    if (r_fullscreen->integer) {\n        ADD_ATTR(NSOpenGLPFAFullScreen);\n\n        // Since we are fullscreen, specify the screen that we need.\n        ADD_ATTR(NSOpenGLPFAScreenMask);\n        ADD_ATTR(CGDisplayIDToOpenGLDisplayMask(Sys_DisplayToUse()));\n    }\n    \n    // Require hardware acceleration unless otherwise directed\n    if (!r_allowSoftwareGL->integer) {\n        ADD_ATTR(NSOpenGLPFAAccelerated);\n    }\n\n    // Require double-buffer\n    ADD_ATTR(NSOpenGLPFADoubleBuffer);\n\n    // Specify the number of color bits.  If we don't have a valid specified value or we are not full screen, use the current display mode's value.\n    ADD_ATTR(NSOpenGLPFAColorSize);\n    colorDepth = r_colorbits->integer;\n    if (colorDepth < 16)\n        colorDepth = 16;\n    else if (colorDepth > 16)\n        colorDepth = 32;\n    if (!r_fullscreen->integer)\n        colorDepth = [[glw_state.desktopMode objectForKey: (id)kCGDisplayBitsPerPixel] intValue];\n    ADD_ATTR(colorDepth);\n\n    // Specify the number of depth bits\n    ADD_ATTR(NSOpenGLPFADepthSize);\n    ADD_ATTR(r_depthbits->integer ? r_depthbits->integer : 16);\n\n    // Specify the number of stencil bits\n    if (r_stencilbits->integer) {\n        ADD_ATTR(NSOpenGLPFAStencilSize);\n        ADD_ATTR(r_stencilbits->integer);\n    }\n\n    // Terminate the list\n    ADD_ATTR(0);\n    \n    return pixelAttributes;\n}\n\n// Needs to be visible to Q3Controller.m.\nvoid Sys_UpdateWindowMouseInputRect(void)\n{\t\t\n    NSRect           windowRect, screenRect;\n    NSScreen        *screen;\n\n    // It appears we need to flip the coordinate system here.  This means we need\n    // to know the size of the screen.\n    screen = [glw_state.window screen];\n    screenRect = [screen frame];\n    windowRect = [glw_state.window frame];\n    windowRect.origin.y = screenRect.size.height - (windowRect.origin.y + windowRect.size.height);\n    \n    Sys_SetMouseInputRect(CGRectMake(windowRect.origin.x, windowRect.origin.y,\n                                    windowRect.size.width, windowRect.size.height));\n}\t\t\t\t\t\t\t\t\t\n\n// This is needed since CGReleaseAllDisplays() restores the gamma on the displays and we want to fade it up rather than just flickering all the displays\nstatic void ReleaseAllDisplays()\n{\n    CGDisplayCount displayIndex;\n\n    Com_Printf(\"Releasing displays\\n\");\n    for (displayIndex = 0; displayIndex < glw_state.displayCount; displayIndex++) {\n        CGDisplayRelease(glw_state.originalDisplayGammaTables[displayIndex].display);\n    }\n}\n\n/*\n=================\nCreateGameWindow\n=================\n*/\nstatic qboolean CreateGameWindow( qboolean isSecondTry )\n{\n    const char *windowed[] = { \"Windowed\", \"Fullscreen\" };\n    int\t\t\tcurrent_mode;\n    NSOpenGLPixelFormatAttribute *pixelAttributes;\n    NSOpenGLPixelFormat *pixelFormat;\n    CGDisplayErr err;\n            \n\n    // get mode info\n    current_mode = r_mode->integer;\n    glConfig.isFullscreen = (r_fullscreen->integer != 0);\n\n    glw_state.desktopMode = (NSDictionary *)CGDisplayCurrentMode(glw_state.display);\n    if (!glw_state.desktopMode) {\n        ri.Error(ERR_FATAL, \"Could not get current graphics mode for display 0x%08x\\n\", glw_state.display);\n    }\n\n#if 0\n    ri.Printf( PRINT_ALL, \"... desktop mode %d = %dx%d %s\\n\", glw_state.desktopMode,\n               glw_state.desktopDesc.width, glw_state.desktopDesc.height,\n               depthStrings[glw_state.desktopDesc.depth]);\n#endif\n\n    ri.Printf( PRINT_ALL, \"...setting mode %d:\\n\", current_mode );\n    if ( !R_GetModeInfo( &glConfig.vidWidth, &glConfig.vidHeight, &glConfig.windowAspect, current_mode ) )  {\n        ri.Printf( PRINT_ALL, \" invalid mode\\n\" );\n        return qfalse;\n    }\n    ri.Printf( PRINT_ALL, \" %d %d %s\\n\", glConfig.vidWidth, glConfig.vidHeight, windowed[glConfig.isFullscreen] );\n\n    if (glConfig.isFullscreen) {\n        \n        // We'll set up the screen resolution first in case that effects the list of pixel\n        // formats that are available (for example, a smaller frame buffer might mean more\n        // bits for depth/stencil buffers).  Allow stretched video modes if we are in fallback mode.\n        glw_state.gameMode = Sys_GetMatchingDisplayMode(isSecondTry);\n        if (!glw_state.gameMode) {\n            ri.Printf( PRINT_ALL, \"Unable to find requested display mode.\\n\");\n            return qfalse;\n        }\n\n        // Fade all screens to black\n        Sys_FadeScreens();\n        \n        err = Sys_CaptureActiveDisplays();\n        if ( err != CGDisplayNoErr ) {\n            CGDisplayRestoreColorSyncSettings();\n            ri.Printf( PRINT_ALL, \" Unable to capture displays err = %d\\n\", err );\n            return qfalse;\n        }\n\n        err = CGDisplaySwitchToMode(glw_state.display, (CFDictionaryRef)glw_state.gameMode);\n        if ( err != CGDisplayNoErr ) {\n            CGDisplayRestoreColorSyncSettings();\n            ReleaseAllDisplays();\n            ri.Printf( PRINT_ALL, \" Unable to set display mode, err = %d\\n\", err );\n            return qfalse;\n        }\n    } else {\n        glw_state.gameMode = glw_state.desktopMode;\n    }\n\n    \n    // Get the GL pixel format\n    pixelAttributes = GetPixelAttributes();\n    pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes: pixelAttributes] autorelease];\n    NSZoneFree(NULL, pixelAttributes);\n    \n    if (!pixelFormat) {\n        CGDisplayRestoreColorSyncSettings();\n        CGDisplaySwitchToMode(glw_state.display, (CFDictionaryRef)glw_state.desktopMode);\n        ReleaseAllDisplays();\n        ri.Printf( PRINT_ALL, \" No pixel format found\\n\");\n        return qfalse;\n    }\n\n    // Create a context with the desired pixel attributes\n    OSX_SetGLContext([[NSOpenGLContext alloc] initWithFormat: pixelFormat shareContext: nil]);\n    if (!OSX_GetNSGLContext()) {\n        CGDisplayRestoreColorSyncSettings();\n        CGDisplaySwitchToMode(glw_state.display, (CFDictionaryRef)glw_state.desktopMode);\n        ReleaseAllDisplays();\n        ri.Printf(PRINT_ALL, \"... +[NSOpenGLContext createWithFormat:share:] failed.\\n\" );\n        return qfalse;\n    }\n\n    if (!glConfig.isFullscreen) {\n        cvar_t\t\t*vid_xpos;\n        cvar_t\t\t*vid_ypos;\n        NSRect           windowRect;\n        \n        vid_xpos = ri.Cvar_Get( \"vid_xpos\", \"100\", CVAR_ARCHIVE );\n        vid_ypos = ri.Cvar_Get( \"vid_ypos\", \"100\", CVAR_ARCHIVE );\n\n        // Create a window of the desired size\n        windowRect.origin.x = vid_xpos->integer;\n        windowRect.origin.y = vid_ypos->integer;\n        windowRect.size.width = glConfig.vidWidth;\n        windowRect.size.height = glConfig.vidHeight;\n        \n        glw_state.window = [[NSWindow alloc] initWithContentRect:windowRect\n                                                       styleMask:NSTitledWindowMask\n                                                         backing:NSBackingStoreRetained\n                                                           defer:NO];\n                                                           \n        [glw_state.window setTitle: @\"Quake3\"];\n\n        [glw_state.window orderFront: nil];\n\n        // Always get mouse moved events (if mouse support is turned off (rare)\n        // the event system will filter them out.\n        [glw_state.window setAcceptsMouseMovedEvents: YES];\n        \n        // Direct the context to draw in this window\n        [OSX_GetNSGLContext() setView: [glw_state.window contentView]];\n\n        // Sync input rect with where the window actually is...\n        Sys_UpdateWindowMouseInputRect();\n    } else {\n        CGLError err;\n        \n        err = CGLSetFullScreen(OSX_GetCGLContext());\n        if (err) {\n            CGDisplayRestoreColorSyncSettings();\n            CGDisplaySwitchToMode(glw_state.display, (CFDictionaryRef)glw_state.desktopMode);\n            ReleaseAllDisplays();\n            Com_Printf(\"CGLSetFullScreen -> %d (%s)\\n\", err, CGLErrorString(err));\n            return qfalse;\n        }\n        \n        Sys_SetMouseInputRect(CGDisplayBounds(glw_state.display));\n    }\n\n\n#ifndef USE_CGLMACROS\n    // Make this the current context\n    OSX_GLContextSetCurrent();\n#endif\n\n    // Store off the pixel format attributes that we actually got\n    [pixelFormat getValues: (long *) &glConfig.colorBits forAttribute: NSOpenGLPFAColorSize forVirtualScreen: 0];\n    [pixelFormat getValues: (long *) &glConfig.depthBits forAttribute: NSOpenGLPFADepthSize forVirtualScreen: 0];\n    [pixelFormat getValues: (long *) &glConfig.stencilBits forAttribute: NSOpenGLPFAStencilSize forVirtualScreen: 0];\n\n    glConfig.displayFrequency = [[glw_state.gameMode objectForKey: (id)kCGDisplayRefreshRate] intValue];\n    \n    \n    ri.Printf(PRINT_ALL, \"ok\\n\" );\n\n    return qtrue;\n}\n\n// This can be used to temporarily disassociate the GL context from the screen so that CoreGraphics can be used to draw to the screen.\nvoid Sys_PauseGL ()\n{\n    if (!glw_state.glPauseCount) {\n        qglFinish (); // must do this to ensure the queue is complete\n        \n        // Have to call both to actually deallocate kernel resources and free the NSSurface\n        CGLClearDrawable(OSX_GetCGLContext());\n        [OSX_GetNSGLContext() clearDrawable];\n    }\n    glw_state.glPauseCount++;\n}\n\n// This can be used to reverse the pausing caused by Sys_PauseGL()\nvoid Sys_ResumeGL ()\n{\n    if (glw_state.glPauseCount) {\n        glw_state.glPauseCount--;\n        if (!glw_state.glPauseCount) {\n            if (!glConfig.isFullscreen) {\n                [OSX_GetNSGLContext() setView: [glw_state.window contentView]];\n            } else {\n                CGLError err;\n                \n                err = CGLSetFullScreen(OSX_GetCGLContext());\n                if (err)\n                    Com_Printf(\"CGLSetFullScreen -> %d (%s)\\n\", err, CGLErrorString(err));\n            }\n        }\n    }\n}\n\n/*\n===================\nGLimp_Init\n\nDon't return unless OpenGL has been properly initialized\n===================\n*/\n\nstatic void GLImp_Toggle_Renderer_f(void)\n{\n    ri.Cvar_Set(\"r_enablerender\", r_enablerender->integer ? \"0\" : \"1\");\n}\n\n#ifdef OMNI_TIMER\nstatic void GLImp_Dump_Stamp_List_f(void)\n{\n    OTStampListDumpToFile(glThreadStampList, \"/tmp/gl_stamps\");\n}\n#endif\n\nvoid GLimp_Init( void )\n{\n    static BOOL addedCommands = NO;\n    cvar_t *lastValidRenderer = ri.Cvar_Get( \"r_lastValidRenderer\", \"(uninitialized)\", CVAR_ARCHIVE );\n    char *buf;\n\n    if (!addedCommands) {\n        addedCommands = YES;\n\n#ifdef OMNI_TIMER\n        glThreadStampList = OTStampListCreate(64);\n        Cmd_AddCommand (\"dump_stamp_list\", GLImp_Dump_Stamp_List_f);\n#endif\n        Cmd_AddCommand (\"toggle_renderer\", GLImp_Toggle_Renderer_f);\n    }\n\n    ri.Printf( PRINT_ALL, \"Initializing OpenGL subsystem\\n\" );\n    ri.Printf( PRINT_ALL, \"  Last renderer was '%s'\\n\", lastValidRenderer->string);\n    ri.Printf( PRINT_ALL, \"  r_fullscreen = %d\\n\", r_fullscreen->integer);\n\n    memset( &glConfig, 0, sizeof( glConfig ) );\n\n    // We only allow changing the gamma if we are full screen\n    glConfig.deviceSupportsGamma = (r_fullscreen->integer != 0);\n    if (glConfig.deviceSupportsGamma) {\n        Sys_StoreGammaTables();\n    }\n    \n    r_allowSoftwareGL = ri.Cvar_Get( \"r_allowSoftwareGL\", \"0\", CVAR_LATCH );\n    r_enablerender = ri.Cvar_Get(\"r_enablerender\", \"1\", 0 );\n\n    if (Sys_QueryVideoMemory() == 0 && !r_allowSoftwareGL->integer) {\n        ri.Error( ERR_FATAL, \"Could not initialize OpenGL.  There does not appear to be an OpenGL-supported video card in your system.\\n\" );\n    }\n    \n    if ( ! GLimp_SetMode(qfalse) ) {\n        // fall back to the known-good mode\n        ri.Cvar_Set( \"r_fullscreen\", \"1\" );\n        ri.Cvar_Set( \"r_mode\", \"3\" );\n        ri.Cvar_Set( \"r_stereo\", \"0\" );\n        ri.Cvar_Set( \"r_depthBits\", \"16\" );\n        ri.Cvar_Set( \"r_colorBits\", \"16\" );\n        ri.Cvar_Set( \"r_stencilBits\", \"0\" );\n        if ( GLimp_SetMode(qtrue) ) {\n            ri.Printf( PRINT_ALL, \"------------------\\n\" );\n            return;\n        }\n\n        ri.Error( ERR_FATAL, \"Could not initialize OpenGL\\n\" );\n        return;\n    }\n\n    ri.Printf( PRINT_ALL, \"------------------\\n\" );\n\n    // get our config strings\n    Q_strncpyz( glConfig.vendor_string, (const char *)qglGetString (GL_VENDOR), sizeof( glConfig.vendor_string ) );\n    Q_strncpyz( glConfig.renderer_string, (const char *)qglGetString (GL_RENDERER), sizeof( glConfig.renderer_string ) );\n    Q_strncpyz( glConfig.version_string, (const char *)qglGetString (GL_VERSION), sizeof( glConfig.version_string ) );\n    Q_strncpyz( glConfig.extensions_string, (const char *)qglGetString (GL_EXTENSIONS), sizeof( glConfig.extensions_string ) );\n\n    //\n    // chipset specific configuration\n    //\n    buf = malloc(strlen(glConfig.renderer_string) + 1);\n    strcpy( buf, glConfig.renderer_string );\n    Q_strlwr( buf );\n\n    ri.Cvar_Set( \"r_lastValidRenderer\", glConfig.renderer_string );\n    free(buf);\n\n    GLW_InitExtensions();\n    \n#ifndef USE_CGLMACROS\n    if (!r_enablerender->integer)\n        OSX_GLContextClearCurrent();\n#endif\n}\n\n\n/*\n** GLimp_EndFrame\n** \n** Responsible for doing a swapbuffers and possibly for other stuff\n** as yet to be determined.  Probably better not to make this a GLimp\n** function and instead do a call to GLimp_SwapBuffers.\n*/\nvoid GLimp_EndFrame (void)\n{\n    GLSTAMP(\"GLimp_EndFrame start\", 0);\n    \n    //\n    // swapinterval stuff\n    //\n    if ( r_swapInterval->modified ) {\n        r_swapInterval->modified = qfalse;\n\n        if ( !glConfig.stereoEnabled ) {\t// why?\n            [[NSOpenGLContext currentContext] setValues: (long *)&r_swapInterval->integer\n            forParameter: NSOpenGLCPSwapInterval];\n        }\n    }\n\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    QGLCheckError(\"GLimp_EndFrame\");\n#endif\n\n    if (!glw_state.glPauseCount && !Sys_IsHidden) {\n        glw_state.bufferSwapCount++;\n        [OSX_GetNSGLContext() flushBuffer];\n    }\n    \n    // Enable turning off GL at any point for performance testing\n    if (OSX_GLContextIsCurrent() != r_enablerender->integer) {\n        if (r_enablerender->integer) {\n            Com_Printf(\"--- Enabling Renderer ---\\n\");\n            OSX_GLContextSetCurrent();\n        } else {\n            Com_Printf(\"--- Disabling Renderer ---\\n\");\n            OSX_GLContextClearCurrent();\n        }\n    }\n\n    GLSTAMP(\"GLimp_EndFrame end\", 0);\n}\n\n/*\n** GLimp_Shutdown\n**\n** This routine does all OS specific shutdown procedures for the OpenGL\n** subsystem.  Under OpenGL this means NULLing out the current DC and\n** HGLRC, deleting the rendering context, and releasing the DC acquired\n** for the window.  The state structure is also nulled out.\n**\n*/\n\nstatic void _GLimp_RestoreOriginalVideoSettings()\n{\n    CGDisplayErr err;\n    \n    // CGDisplayCurrentMode lies because we've captured the display and thus we won't\n    // get any notifications about what the current display mode really is.  For now,\n    // we just always force it back to what mode we remember the desktop being in.\n    if (glConfig.isFullscreen) {\n        err = CGDisplaySwitchToMode(glw_state.display, (CFDictionaryRef)glw_state.desktopMode);\n        if ( err != CGDisplayNoErr )\n            ri.Printf( PRINT_ALL, \" Unable to restore display mode!\\n\" );\n\n        ReleaseAllDisplays();\n    }\n}\n\nvoid GLimp_Shutdown( void )\n{\n    CGDisplayCount displayIndex;\n\n    Com_Printf(\"----- Shutting down GL -----\\n\");\n\n    Sys_FadeScreen(Sys_DisplayToUse());\n    \n    if (OSX_GetNSGLContext()) {\n#ifndef USE_CGLMACROS\n        OSX_GLContextClearCurrent();\n#endif\n        // Have to call both to actually deallocate kernel resources and free the NSSurface\n        CGLClearDrawable(OSX_GetCGLContext());\n        [OSX_GetNSGLContext() clearDrawable];\n        \n        [OSX_GetNSGLContext() release];\n        OSX_SetGLContext((id)nil);\n    }\n\n    _GLimp_RestoreOriginalVideoSettings();\n    \n    Sys_UnfadeScreens();\n\n    // Restore the original gamma if needed.\n    if (glConfig.deviceSupportsGamma) {\n        Com_Printf(\"Restoring ColorSync settings\\n\");\n        CGDisplayRestoreColorSyncSettings();\n    }\n\n    if (glw_state.window) {\n        [glw_state.window release];\n        glw_state.window = nil;\n    }\n\n    if (glw_state.log_fp) {\n        fclose(glw_state.log_fp);\n        glw_state.log_fp = 0;\n    }\n\n    for (displayIndex = 0; displayIndex < glw_state.displayCount; displayIndex++) {\n        free(glw_state.originalDisplayGammaTables[displayIndex].red);\n        free(glw_state.originalDisplayGammaTables[displayIndex].blue);\n        free(glw_state.originalDisplayGammaTables[displayIndex].green);\n    }\n    free(glw_state.originalDisplayGammaTables);\n    if (glw_state.tempTable.red) {\n        free(glw_state.tempTable.red);\n        free(glw_state.tempTable.blue);\n        free(glw_state.tempTable.green);\n    }\n    if (glw_state.inGameTable.red) {\n        free(glw_state.inGameTable.red);\n        free(glw_state.inGameTable.blue);\n        free(glw_state.inGameTable.green);\n    }\n    \n    memset(&glConfig, 0, sizeof(glConfig));\n    memset(&glState, 0, sizeof(glState));\n    memset(&glw_state, 0, sizeof(glw_state));\n\n    Com_Printf(\"----- Done shutting down GL -----\\n\");\n}\n\n/*\n===============\nGLimp_LogComment\n\n===============\n*/\nvoid\tGLimp_LogComment( char *comment ) {\n        }\n\n/*\n===============\nGLimp_SetGamma\n\n===============\n*/\nvoid GLimp_SetGamma(unsigned char red[256],\n                    unsigned char green[256],\n                    unsigned char blue[256])\n{\n    CGGammaValue redGamma[256], greenGamma[256], blueGamma[256];\n    CGTableCount i;\n    CGDisplayErr err;\n    \n    if (!glConfig.deviceSupportsGamma)\n        return;\n        \n    for (i = 0; i < 256; i++) {\n        redGamma[i]   = red[i]   / 255.0;\n        greenGamma[i] = green[i] / 255.0;\n        blueGamma[i]  = blue[i]  / 255.0;\n    }\n    \n    err = CGSetDisplayTransferByTable(glw_state.display, 256, redGamma, greenGamma, blueGamma);\n    if (err != CGDisplayNoErr) {\n        Com_Printf(\"GLimp_SetGamma: CGSetDisplayTransferByByteTable returned %d.\\n\", err);\n    }\n    \n    // Store the gamma table that we ended up using so we can reapply it later when unhiding or to work around the bug where if you leave the game sitting and the monitor sleeps, when it wakes, the gamma isn't reset.\n    glw_state.inGameTable.display = glw_state.display;\n    Sys_GetGammaTable(&glw_state.inGameTable);\n}\n\nqboolean GLimp_ChangeMode( int mode )\n{\n    qboolean result;\n    int oldvalue = r_mode->integer;\n\n    Com_Printf(\"*** GLimp_ChangeMode\\n\");\n    r_mode->integer = mode;\n    if (!(result = GLimp_SetMode(qfalse)))\n        r_mode->integer = oldvalue;\n    \n   return result;\n}\n\n/*****************************************************************************/\n\nvoid *qwglGetProcAddress(const char *name)\n{\n    NSSymbol symbol;\n    char *symbolName;\n\n    // Prepend a '_' for the Unix C symbol mangling convention\n    symbolName = malloc(strlen(name) + 2);\n    strcpy(symbolName + 1, name);\n    symbolName[0] = '_';\n\n    if (NSIsSymbolNameDefined(symbolName))\n        symbol = NSLookupAndBindSymbol(symbolName);\n    else\n        symbol = NULL;\n    \n    free(symbolName);\n    \n    if (!symbol)\n        // shouldn't happen ...\n        return NULL;\n\n    return NSAddressOfSymbol(symbol);\n}\n\n/*\n** GLW_InitExtensions\n*/\nstatic void GLW_InitExtensions( void )\n{\n        if ( !r_allowExtensions->integer )\n        {\n                ri.Printf( PRINT_ALL, \"*** IGNORING OPENGL EXTENSIONS ***\\n\" );\n                return;\n        }\n\n        ri.Printf( PRINT_ALL, \"Initializing OpenGL extensions\\n\" );\n        ri.Printf( PRINT_ALL, \"... Supported extensions are %s\\n\", glConfig.extensions_string);\n        \n        // GL_S3_s3tc\n        glConfig.textureCompression = TC_NONE;\n        if ( strstr( glConfig.extensions_string, \"GL_S3_s3tc\" ) )\n        {\n                if ( r_ext_compressed_textures->integer )\n                {\n                        glConfig.textureCompression = TC_S3TC;\n                        ri.Printf( PRINT_ALL, \"...using GL_S3_s3tc\\n\" );\n                }\n                else\n                {\n                        glConfig.textureCompression = TC_NONE;\n                        ri.Printf( PRINT_ALL, \"...ignoring GL_S3_s3tc\\n\" );\n                }\n        }\n        else\n        {\n                ri.Printf( PRINT_ALL, \"...GL_S3_s3tc not found\\n\" );\n        }\n\n\n#ifdef GL_EXT_texture_env_add\n        // GL_EXT_texture_env_add\n        glConfig.textureEnvAddAvailable = qfalse;\n        if ( strstr( glConfig.extensions_string, \"GL_EXT_texture_env_add\" ) )\n        {\n                if ( r_ext_texture_env_add->integer )\n                {\n                        glConfig.textureEnvAddAvailable = qtrue;\n                        ri.Printf( PRINT_ALL, \"...using GL_EXT_texture_env_add\\n\" );\n                }\n                else\n                {\n                        glConfig.textureEnvAddAvailable = qfalse;\n                        ri.Printf( PRINT_ALL, \"...ignoring GL_EXT_texture_env_add\\n\" );\n                }\n        }\n        else\n        {\n                ri.Printf( PRINT_ALL, \"...GL_EXT_texture_env_add not found\\n\" );\n        }\n#endif\n\n#ifdef GL_ARB_texture_env_add\n        // GL_ARB_texture_env_add -- only if we didn't find GL_EXT_texture_env_add\n        if (!glConfig.textureEnvAddAvailable) {\n            if ( strstr( glConfig.extensions_string, \"GL_ARB_texture_env_add\" ) )\n            {\n                    if ( r_ext_texture_env_add->integer )\n                    {\n                            glConfig.textureEnvAddAvailable = qtrue;\n                            ri.Printf( PRINT_ALL, \"...using GL_ARB_texture_env_add\\n\" );\n                    }\n                    else\n                    {\n                            glConfig.textureEnvAddAvailable = qfalse;\n                            ri.Printf( PRINT_ALL, \"...ignoring GL_ARB_texture_env_add\\n\" );\n                    }\n            }\n            else\n            {\n                    ri.Printf( PRINT_ALL, \"...GL_ARB_texture_env_add not found\\n\" );\n            }\n        }\n#endif\n\n\n#if 0   // Win32 does this differently than we do -- I'll provide a C function that looks the same\n        // that will do the correct ObjC stuff\n        // WGL_EXT_swap_control\n        qwglSwapIntervalEXT = ( BOOL (WINAPI *)(int)) qwglGetProcAddress( \"wglSwapIntervalEXT\" );\n        if ( qwglSwapIntervalEXT )\n        {\n                ri.Printf( PRINT_ALL, \"...using WGL_EXT_swap_control\\n\" );\n                r_swapInterval->modified = qtrue;\t// force a set next frame\n        }\n        else\n        {\n                ri.Printf( PRINT_ALL, \"...WGL_EXT_swap_control not found\\n\" );\n        }\n#else\n        if (r_swapInterval) {\n            ri.Printf( PRINT_ALL, \"...using +[NSOpenGLContext setParameter:] for qwglSwapIntervalEXT\\n\" );\n            r_swapInterval->modified = qtrue;\t// force a set next frame\n        }\n#endif\n        \n        // GL_ARB_multitexture\n        qglMultiTexCoord2fARB = NULL;\n        qglActiveTextureARB = NULL;\n        qglClientActiveTextureARB = NULL;\n        if ( strstr( glConfig.extensions_string, \"GL_ARB_multitexture\" )  )\n        {\n                if ( r_ext_multitexture->integer )\n                {\n                        qglMultiTexCoord2fARB = ( PFNGLMULTITEXCOORD2FARBPROC ) qwglGetProcAddress( \"glMultiTexCoord2fARB\" );\n                        qglActiveTextureARB = ( PFNGLACTIVETEXTUREARBPROC ) qwglGetProcAddress( \"glActiveTextureARB\" );\n                        qglClientActiveTextureARB = ( PFNGLCLIENTACTIVETEXTUREARBPROC ) qwglGetProcAddress( \"glClientActiveTextureARB\" );\n\n                        if ( qglActiveTextureARB )\n                        {\n                                qglGetIntegerv( GL_MAX_ACTIVE_TEXTURES_ARB, (GLint *)&glConfig.maxActiveTextures );\n\n                                if ( glConfig.maxActiveTextures > 1 )\n                                {\n                                        ri.Printf( PRINT_ALL, \"...using GL_ARB_multitexture\\n\" );\n                                }\n                                else\n                                {\n                                        qglMultiTexCoord2fARB = NULL;\n                                        qglActiveTextureARB = NULL;\n                                        qglClientActiveTextureARB = NULL;\n                                        ri.Printf( PRINT_ALL, \"...not using GL_ARB_multitexture, < 2 texture units\\n\" );\n                                }\n                        }\n                }\n                else\n                {\n                        ri.Printf( PRINT_ALL, \"...ignoring GL_ARB_multitexture\\n\" );\n                }\n        }\n        else\n        {\n                ri.Printf( PRINT_ALL, \"...GL_ARB_multitexture not found\\n\" );\n        }\n\n        // GL_EXT_compiled_vertex_array\n        qglLockArraysEXT = NULL;\n        qglUnlockArraysEXT = NULL;\n        if ( strstr( glConfig.extensions_string, \"GL_EXT_compiled_vertex_array\" ) && ( glConfig.hardwareType != GLHW_RIVA128 ) )\n        {\n                if ( r_ext_compiled_vertex_array->integer )\n                {\n                        ri.Printf( PRINT_ALL, \"...using GL_EXT_compiled_vertex_array\\n\" );\n                        qglLockArraysEXT = ( void ( APIENTRY * )( GLint, GLint ) ) qwglGetProcAddress( \"glLockArraysEXT\" );\n                        qglUnlockArraysEXT = ( void ( APIENTRY * )( void ) ) qwglGetProcAddress( \"glUnlockArraysEXT\" );\n                        if (!qglLockArraysEXT || !qglUnlockArraysEXT) {\n                                ri.Error (ERR_FATAL, \"bad getprocaddress\\n\");\n                        }\n                }\n                else\n                {\n                        ri.Printf( PRINT_ALL, \"...ignoring GL_EXT_compiled_vertex_array\\n\" );\n                }\n        }\n        else\n        {\n                ri.Printf( PRINT_ALL, \"...GL_EXT_compiled_vertex_array not found\\n\" );\n        }\n\n#ifdef GL_APPLE_transform_hint\n        if ( strstr( glConfig.extensions_string, \"GL_APPLE_transform_hint\" )  ) {\n            r_appleTransformHint = ri.Cvar_Get(\"r_appleTransformHint\", \"1\", CVAR_ARCHIVE );\n            if (r_appleTransformHint->value) {\n                ri.Printf( PRINT_ALL, \"...using GL_APPLE_transform_hint\\n\");\n                qglHint(GL_TRANSFORM_HINT_APPLE, GL_FASTEST);\n                CheckErrors();\n            } else {\n                ri.Printf( PRINT_ALL, \"...ignoring using GL_APPLE_transform_hint\\n\");\n            }\n        } else {\n            ri.Printf( PRINT_ALL, \"...GL_APPLE_transform_hint not found\\n\" );\n        }\n#endif\n}\n\n\n#define MAX_RENDERER_INFO_COUNT 128\n\n// Returns zero if there are no hardware renderers.  Otherwise, returns the max memory across all renderers (on the presumption that the screen that we'll use has the most memory).\nstatic unsigned long Sys_QueryVideoMemory()\n{\n    CGLError err;\n    CGLRendererInfoObj rendererInfo, rendererInfos[MAX_RENDERER_INFO_COUNT];\n    long rendererInfoIndex, rendererInfoCount = MAX_RENDERER_INFO_COUNT;\n    long rendererIndex, rendererCount;\n    long maxVRAM = 0, vram;\n    long accelerated;\n    long rendererID;\n    long totalRenderers = 0;\n    \n    err = CGLQueryRendererInfo(CGDisplayIDToOpenGLDisplayMask(Sys_DisplayToUse()), rendererInfos, &rendererInfoCount);\n    if (err) {\n        Com_Printf(\"CGLQueryRendererInfo -> %d\\n\", err);\n        return vram;\n    }\n    \n    //Com_Printf(\"rendererInfoCount = %d\\n\", rendererInfoCount);\n    for (rendererInfoIndex = 0; rendererInfoIndex < rendererInfoCount && totalRenderers < rendererInfoCount; rendererInfoIndex++) {\n        rendererInfo = rendererInfos[rendererInfoIndex];\n        //Com_Printf(\"rendererInfo: 0x%08x\\n\", rendererInfo);\n        \n\n        err = CGLDescribeRenderer(rendererInfo, 0, kCGLRPRendererCount, &rendererCount);\n        if (err) {\n            Com_Printf(\"CGLDescribeRenderer(kCGLRPRendererID) -> %d\\n\", err);\n            continue;\n        }\n        //Com_Printf(\"  rendererCount: %d\\n\", rendererCount);\n\n        for (rendererIndex = 0; rendererIndex < rendererCount; rendererIndex++) {\n            totalRenderers++;\n            //Com_Printf(\"  rendererIndex: %d\\n\", rendererIndex);\n            \n            rendererID = 0xffffffff;\n            err = CGLDescribeRenderer(rendererInfo, rendererIndex, kCGLRPRendererID, &rendererID);\n            if (err) {\n                Com_Printf(\"CGLDescribeRenderer(kCGLRPRendererID) -> %d\\n\", err);\n                continue;\n            }\n            //Com_Printf(\"    rendererID: 0x%08x\\n\", rendererID);\n            \n            accelerated = 0;\n            err = CGLDescribeRenderer(rendererInfo, rendererIndex, kCGLRPAccelerated, &accelerated);\n            if (err) {\n                Com_Printf(\"CGLDescribeRenderer(kCGLRPAccelerated) -> %d\\n\", err);\n                continue;\n            }\n            //Com_Printf(\"    accelerated: %d\\n\", accelerated);\n            if (!accelerated)\n                continue;\n            \n            vram = 0;\n            err = CGLDescribeRenderer(rendererInfo, rendererIndex, kCGLRPVideoMemory, &vram);\n            if (err) {\n                Com_Printf(\"CGLDescribeRenderer -> %d\\n\", err);\n                continue;\n            }\n            //Com_Printf(\"    vram: 0x%08x\\n\", vram);\n            \n            // presumably we'll be running on the best card, so we'll take the max of the vrams\n            if (vram > maxVRAM)\n                maxVRAM = vram;\n        }\n        \n#if 0\n        err = CGLDestroyRendererInfo(rendererInfo);\n        if (err) {\n            Com_Printf(\"CGLDestroyRendererInfo -> %d\\n\", err);\n        }\n#endif\n    }\n\n    return maxVRAM;\n}\n\n\n// We will set the Sys_IsHidden global to cause input to be handle differently (we'll just let NSApp handle events in this case).  We also will unbind the GL context and restore the video mode.\nqboolean Sys_Hide()\n{\n    if (Sys_IsHidden)\n        // Eh?\n        return qfalse;\n    \n    if (!r_fullscreen->integer)\n        // We only support hiding in fullscreen mode right now\n        return qfalse;\n    \n    Sys_IsHidden = qtrue;\n\n    // Don't need to store the current gamma since we always keep it around in glw_state.inGameTable.\n\n    Sys_FadeScreen(Sys_DisplayToUse());\n\n    // Disassociate the GL context from the screen\n    // Have to call both to actually deallocate kernel resources and free the NSSurface\n    CGLClearDrawable(OSX_GetCGLContext());\n    [OSX_GetNSGLContext() clearDrawable];\n    \n    // Restore the original video mode\n    _GLimp_RestoreOriginalVideoSettings();\n\n    // Restore the original gamma if needed.\n    if (glConfig.deviceSupportsGamma) {\n        CGDisplayRestoreColorSyncSettings();\n    }\n\n    // Release the screen(s)\n    ReleaseAllDisplays();\n    \n    Sys_UnfadeScreens();\n    \n    // Shut down the input system so the mouse and keyboard settings are restore to normal\n    Sys_ShutdownInput();\n    \n    // Hide the application so that when the user clicks on our app icon, we'll get an unhide notification\n    [NSApp hide: nil];\n    \n    return qtrue;\n}\n\nstatic CGDisplayErr Sys_CaptureActiveDisplays(void)\n{\n    CGDisplayErr err;\n    CGDisplayCount displayIndex;\n    for (displayIndex = 0; displayIndex < glw_state.displayCount; displayIndex++) {\n\tconst glwgamma_t *table;\n\ttable = &glw_state.originalDisplayGammaTables[displayIndex];\n\terr = CGDisplayCapture(table->display);\n\tif (err != CGDisplayNoErr)\n\t    return err;\n    }\n    return CGDisplayNoErr;\n}\n\nqboolean Sys_Unhide()\n{\n    CGDisplayErr err;\n    CGLError glErr;\n    \n    if (!Sys_IsHidden)\n        // Eh?\n        return qfalse;\n        \n    Sys_FadeScreens();\n\n    // Capture the screen(s)\n    err = Sys_CaptureActiveDisplays();\n    if (err != CGDisplayNoErr) {\n        Sys_UnfadeScreens();\n        ri.Printf( PRINT_ALL, \"Unhide failed -- cannot capture the display again.\\n\" );\n        return qfalse;\n    }\n    \n    // Restore the game mode\n    err = CGDisplaySwitchToMode(glw_state.display, (CFDictionaryRef)glw_state.gameMode);\n    if ( err != CGDisplayNoErr ) {\n        ReleaseAllDisplays();\n        Sys_UnfadeScreens();\n        ri.Printf( PRINT_ALL, \"Unhide failed -- Unable to set display mode\\n\" );\n        return qfalse;\n    }\n\n    // Reassociate the GL context and the screen\n    glErr = CGLSetFullScreen(OSX_GetCGLContext());\n    if (err) {\n        ReleaseAllDisplays();\n        Sys_UnfadeScreens();\n        ri.Printf( PRINT_ALL, \"Unhide failed: CGLSetFullScreen -> %d (%s)\\n\", err, CGLErrorString(err));\n        return qfalse;\n    }\n\n    // Restore the current context\n    [OSX_GetNSGLContext() makeCurrentContext];\n    \n    // Restore the gamma that the game had set\n    Sys_UnfadeScreen(Sys_DisplayToUse(), &glw_state.inGameTable);\n    \n    // Restore the input system (last so if something goes wrong we don't eat the mouse)\n    Sys_InitInput();\n    \n    Sys_IsHidden = qfalse;\n    return qtrue;\n}\n\n\n"
  },
  {
    "path": "code/macosx/macosx_glsmp_mutex.m",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#import \"macosx_glimp.h\"\n\n#include \"tr_local.h\"\n#import \"macosx_local.h\"\n#import \"macosx_display.h\"\n\n#import <AppKit/AppKit.h>\n#import <Foundation/Foundation.h>\n#import <pthread.h>\n\n//\n// The main Q3 SMP API\n//\n\nstatic pthread_mutex_t  smpMutex;\nstatic pthread_cond_t   mainThreadCondition;\nstatic pthread_cond_t   renderThreadCondition;\n\nstatic  volatile qboolean  smpDataChanged;\nstatic\tvolatile void     *smpData;\n\n\nstatic void *GLimp_RenderThreadWrapper(void *arg)\n{\n    Com_Printf(\"Render thread starting\\n\");\n\n    ((void (*)())arg)();\n\n#ifndef USE_CGLMACROS\n    // Unbind the context before we die\n    OSX_GLContextClearCurrent();\n#endif\n\n    Com_Printf(\"Render thread terminating\\n\");\n\t\n    return arg;\n}\n\nqboolean GLimp_SpawnRenderThread( void (*function)( void ) )\n{\n    pthread_t renderThread;\n    int       rc;\n\n    pthread_mutex_init(&smpMutex, NULL);\n    pthread_cond_init(&mainThreadCondition, NULL);\n    pthread_cond_init(&renderThreadCondition, NULL);\n    \n    rc = pthread_create(&renderThread, NULL, GLimp_RenderThreadWrapper, function);\n    if (rc) {\n        ri.Printf(PRINT_ALL, \"pthread_create returned %d: %s\", rc, strerror(rc));\n        return qfalse;\n    } else {\n        rc = pthread_detach(renderThread);\n        if (rc) {\n            ri.Printf(PRINT_ALL, \"pthread_detach returned %d: %s\", rc, strerror(rc));\n        }\n    }\n\n    return qtrue;\n}\n\n// Called in the rendering thread to wait until a command buffer is ready.\n// The command buffer returned might be NULL, indicating that the rendering thread should exit.\nvoid *GLimp_RendererSleep(void)\n{\n    void *data;\n    \n    GLSTAMP(\"GLimp_RendererSleep start\", 0);\n\n#ifndef USE_CGLMACROS\n    // Clear the current context while we sleep so the main thread can access it\n    OSX_GLContextClearCurrent();\n#endif\n\n    pthread_mutex_lock(&smpMutex); {\n        // Clear out any data we had and signal the main thread that we are no longer busy\n        smpData = NULL;\n        smpDataChanged = qfalse;\n        pthread_cond_signal(&mainThreadCondition);\n        \n        // Wait until we get something new to work on\n        while (!smpDataChanged)\n            pthread_cond_wait(&renderThreadCondition, &smpMutex);\n            \n        // Record the data (if any).\n        data = smpData;\n    } pthread_mutex_unlock(&smpMutex);\n    \n#ifndef USE_CGLMACROS\n    // We are going to render a frame... retake the context\n    OSX_GLContextSetCurrent();\n#endif\n\n    GLSTAMP(\"GLimp_RendererSleep end\", 0);\n\n    return (void *)data;\n}\n\n// Called from the main thread to wait until the rendering thread is done with the command buffer.\nvoid GLimp_FrontEndSleep(void)\n{\n    GLSTAMP(\"GLimp_FrontEndSleep start\", 0);\n\n    pthread_mutex_lock(&smpMutex); {\n        while (smpData) {\n#if 0\n            struct timespec ts;\n            int result;\n            \n            ts.tv_sec = 1;\n            ts.tv_nsec = 0;\n            result = pthread_cond_timedwait_relative_np(&mainThreadCondition, &smpMutex, &ts);\n            if (result) {\n                Com_Printf(\"GLimp_FrontEndSleep timed out.  Probably due to R_SyncRenderThread called due to Com_Error being called\\n\");\n                break;\n            }\n#else\n            pthread_cond_wait(&mainThreadCondition, &smpMutex);\n#endif\n        }\n    } pthread_mutex_unlock(&smpMutex);\n\n\n#ifndef USE_CGLMACROS\n    // We are done waiting for the background thread, take the current context back.\n    OSX_GLContextSetCurrent();\n#endif\n\n    GLSTAMP(\"GLimp_FrontEndSleep end\", 0);\n}\n\n// This is called in the main thread to issue another command\n// buffer to the rendering thread.  This is always called AFTER\n// GLimp_FrontEndSleep, so we know that there is no command\n// pending in 'smpData'.\nvoid GLimp_WakeRenderer( void *data )\n{\n    GLSTAMP(\"GLimp_WakeRenderer start\", data);\n\n#ifndef USE_CGLMACROS\n    // We want the background thread to draw stuff.  Give up the current context\n    OSX_GLContextClearCurrent();\n#endif\n\n    pthread_mutex_lock(&smpMutex); {\n        // Store the new data pointer and wake up the rendering thread\n        assert(smpData == NULL);\n        smpData = data;\n        smpDataChanged = qtrue;\n        pthread_cond_signal(&renderThreadCondition);\n    } pthread_mutex_unlock(&smpMutex);\n    \n    GLSTAMP(\"GLimp_WakeRenderer end\", data);\n}\n\n"
  },
  {
    "path": "code/macosx/macosx_glsmp_null.m",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#import \"macosx_glimp.h\"\n\n#include \"tr_local.h\"\n#import \"macosx_local.h\"\n\nqboolean GLimp_SpawnRenderThread( void (*function)( void ) )\n{\n    return qfalse;\n}\n\nvoid *GLimp_RendererSleep(void)\n{\n    return NULL;\n}\n\nvoid GLimp_FrontEndSleep(void)\n{\n\n}\n\nvoid GLimp_WakeRenderer( void *data )\n{\n    \n}\n\n"
  },
  {
    "path": "code/macosx/macosx_glsmp_ports.m",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#import \"macosx_glimp.h\"\n\n#include \"tr_local.h\"\n#import \"macosx_local.h\"\n#import \"macosx_display.h\"\n\n#import <AppKit/AppKit.h>\n#import <Foundation/Foundation.h>\n#import <mach/mach.h>\n#import <mach/mach_error.h>\n\n\n#warning Using Mach Ports SMP acceleration implementation\n\n/*\n===========================================================\n\nSMP acceleration\n\n===========================================================\n*/\n\n#import <pthread.h>\n\n#define USE_MACH_PORTS 1\n\n// This is a small cover layer that makes for easier calling\n\ntypedef struct _MsgPort {\n#if USE_MACH_PORTS    \n    mach_port_t port; \n    id nsPort;\n#else    \n    pthread_mutex_t mutex;\n    pthread_cond_t condition;\n    volatile unsigned int   status;\n    unsigned int   msgCode;\n    void          *msgData;\n#endif    \n} MsgPort;\n \nstatic BOOL portsInited = NO;\nstatic pthread_mutex_t logMutex;\n\nstatic unsigned int renderMsgOutstanding;\nstatic unsigned int rendererProcessingCommand;\n\nstatic MsgPort rendererMsgPort;\nstatic MsgPort frontEndMsgPort;\n\nenum {\n    MsgNone,\n    MsgPending,\n};\n\nenum {\n    MsgCodeInvalid = 0,\n    RenderCommandMsg = 1,\n    RenderCompletedMsg = 2,\n};\n\nstatic /*inline*/ void MsgPortInit(MsgPort *port)\n{\n#if USE_MACH_PORTS  \n    port->nsPort = [[NSMachPort alloc] init];\n    port->port = [port->nsPort machPort];\n      \n    //rc = mach_port_allocate(mach_task_self(), MACH_PORT_TYPE_SEND_RECEIVE, &port->port);\n    //if (rc) {\n    //  fprintf(stderr, \"MsgPortInit: mach_port_allocate returned: %d: %s \\n\",rc, mach_error_string(rc));\n   // }\n#else\n    int rc;\n    rc = pthread_mutex_init(&port->mutex, NULL);\n    if (rc) {\n        ri.Printf(PRINT_ALL, \"MsgPortInit: pthread_mutex_init returned: %d: %s\\n\", rc, strerror(rc));\n    }\n    rc = pthread_cond_init(&port->condition, NULL);\n    if (rc) {\n        ri.Printf(PRINT_ALL, \"EventInit: pthread_cond_init returned %d: %s\\n\", rc, strerror(rc));\n    }\n    port->status = MsgNone;\n    port->msgCode = MsgCodeInvalid;\n    port->msgData = NULL;\n#endif    \n}\n\nstatic /*inline*/ void _SendMsg(MsgPort *port, unsigned int msgCode, void *msgData, \n                         const char *functionName, const char *portName, const char *msgName)\n{\n    int rc;\n    \n#if USE_MACH_PORTS\n    mach_msg_header_t msg;\n\n    //printf(\"SendMsg: %s %s %s (%d %08lx)\\n\",functionName, portName, msgName, msgCode, msgData);\n/*\n typedef\tstruct\n {\n   mach_msg_bits_t\tmsgh_bits;\n   mach_msg_size_t\tmsgh_size;\n   mach_port_t\t\tmsgh_remote_port;\n   mach_port_t\t\tmsgh_local_port;\n   mach_msg_size_t \tmsgh_reserved;\n   mach_msg_id_t\t\tmsgh_id;\n } mach_msg_header_t;\n*/\n    msg.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND,MACH_MSG_TYPE_MAKE_SEND_ONCE);\n    msg.msgh_size=sizeof(msg);\n    //msg.msg_type=MSG_TYPE_NORMAL;\n    msg.msgh_local_port=MACH_PORT_NULL;\n    msg.msgh_remote_port=port->port;\n    msg.msgh_reserved = 0;\n    msg.msgh_id=(mach_msg_id_t)msgData; // HACK\n\n    rc = mach_msg_send(&msg);\n    if(rc) {\n        fprintf(stderr,\"SendMsg: mach_msg_send returned %d: %s\\n\", rc, mach_error_string(rc));\n    }\n#else    \n    //printf(\"SendMsg: %s %s %s (%d %08lx)\\n\",functionName, portName, msgName, msgCode, msgData);\n    rc = pthread_mutex_lock(&port->mutex);\n    if(rc) {\n        fprintf(stderr,\"SendMsg: pthread_mutex_lock returned %d: %s\\n\", rc, strerror(rc));\n    }\n    \n    /* Block until port is empty */\n    while(port->status != MsgNone) {\n      //fprintf(stderr, \"SendMsg: %s blocking until port %s is empty\\n\", functionName, portName);      \n      rc = pthread_cond_wait(&port->condition, &port->mutex);\n      if(rc) {\n        fprintf(stderr, \"SendMsg: pthread_cond_wait returned %d: %s\\n\", rc, strerror(rc));\n      }\n    }\n    \n    /* Queue msg */\n    port->msgCode = msgCode;\n    port->msgData = msgData;\n    port->status = MsgPending;\n    \n    /* Unlock port */\n    rc = pthread_mutex_unlock(&port->mutex);\n    if(rc) {\n        fprintf(stderr, \"SendMsg: pthread_mutex_unlock returned %d: %s\\n\", rc, strerror(rc));\n    }    \n\n    /* Wake up any threads blocked waiting for a message */\n    rc = pthread_cond_broadcast(&port->condition);\n    if(rc) {\n       fprintf(stderr, \"SendMsg: pthread_cond_broadcast returned %d: %s\\n\", rc, strerror(rc));\n    }\n#endif            \n}\n\nstatic /*inline*/ void _WaitMsg(MsgPort *port, unsigned int *msgCode, void **msgData, \n                                const char *functionName, const char *portName)\n{\n    int rc;\n#if USE_MACH_PORTS\n    mach_msg_empty_rcv_t msg;\n\n    //printf(\"WaitMsg: %s %s\\n\",functionName, portName);\n    \n    msg.header.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND,MACH_MSG_TYPE_MAKE_SEND_ONCE);\n    msg.header.msgh_size= sizeof(msg);\n    //msg.msg_type=MSG_TYPE_NORMAL;\n    msg.header.msgh_local_port=port->port;\n    msg.header.msgh_remote_port=MACH_PORT_NULL;\n    msg.header.msgh_reserved = 0;\n    msg.header.msgh_id=(mach_msg_id_t)msgData; // HACK\n\n    rc = mach_msg_receive(&msg.header);\n    if(rc) {\n        fprintf(stderr,\"SendMsg: mach_msg_receive returned %d: %s\\n\", rc, mach_error_string(rc));\n    }\n\n    *msgData = (void *)msg.header.msgh_id;\n    //printf(\"WaitMsg: %s %s got %08lx\\n\",functionName, portName, *msgData);\n#else   \n    //printf(\"WaitMsg: %s %s\\n\",functionName, portName);\n    \n    rc = pthread_mutex_lock(&port->mutex);\n    if(rc) {\n        fprintf(stderr, \"WaitMsg: pthread_mutex_lock returned %d: %s\\n\", rc, strerror(rc));\n    }\n    \n    /* Block until port is empty */\n    while(port->status != MsgPending) {\n      rc = pthread_cond_wait(&port->condition, &port->mutex);\n      if(rc) {\n        fprintf(stderr, \"WaitMsg: pthread_cond_wait returned %d: %s\\n\", rc, strerror(rc));\n      }\n    }\n    \n    /* Remove msg */\n    *msgCode = port->msgCode;\n    *msgData = port->msgData;\n\n    //printf(\"WaitMsg: %s %s got %d %08lx\\n\",functionName, portName, *msgCode, *msgData);\n\n    port->status = MsgNone;\n    port->msgCode = 0;\n    port->msgData = NULL;\n    \n    rc = pthread_mutex_unlock(&port->mutex);\n    if(rc) {\n        fprintf(stderr, \"WaitMsg: pthread_mutex_unlock returned %d: %s\\n\", rc, strerror(rc));\n    }    \n\n    /* Wake up any threads blocked waiting for port to be empty. */\n    rc = pthread_cond_broadcast(&port->condition);\n    if(rc) {\n       fprintf(stderr, \"SendMsg: pthread_cond_broadcast returned %d: %s\\n\", rc, strerror(rc));\n    }\n#endif            \n}\n\n\n#define SendMsg(p, c, d) _SendMsg(p, c, d, __PRETTY_FUNCTION__, #p, #c)\n#define WaitMsg(p, c, d) _WaitMsg(p, c, d, __PRETTY_FUNCTION__, #p)\n\n#if 0\nstatic void _Log(const char *msg)\n{\n    int rc;\n    \n    rc = pthread_mutex_lock(&logMutex);\n    if (rc)\n        ri.Printf(PRINT_ALL, \"_Log: pthread_mutex_lock returned %d: %s\\n\", rc, strerror(rc));\n\n    fputs(msg,stderr);\n    fflush(stderr);\n    \n    rc = pthread_mutex_unlock(&logMutex);\n    if (rc)\n        ri.Printf(PRINT_ALL, \"_Log: pthread_mutex_unlock returned %d: %s\\n\", rc, strerror(rc));\n}\n#endif\n\n\n//\n// The main Q3 SMP API\n//\n\nstatic void (*glimpRenderThread)( void ) = NULL;\n\nstatic void *GLimp_RenderThreadWrapper(void *arg)\n{\n    Com_Printf(\"Render thread starting\\n\");\n\n    glimpRenderThread();\n\n#ifndef USE_CGLMACROS\n    // Unbind the context before we die\n    OSX_GLContextClearCurrent();\n#endif\n\n    // Send one last message back to front end before we die...\n    // This is somewhat of a hack.. fixme.\n    if (rendererProcessingCommand) {\n        SendMsg(&frontEndMsgPort, RenderCompletedMsg, NULL);\n        rendererProcessingCommand = NO;\n    }\n\n    Com_Printf(\"Render thread terminating\\n\");\n\t\n    return arg;\n}\n\nqboolean GLimp_SpawnRenderThread( void (*function)( void ) )\n{\n    pthread_t renderThread;\n    int       rc;\n\n    if (!portsInited) {\n        portsInited = YES;\n        MsgPortInit(&rendererMsgPort);\n        MsgPortInit(&frontEndMsgPort);\n        renderMsgOutstanding = NO;\n        rendererProcessingCommand = NO;\n        pthread_mutex_init(&logMutex, NULL);\n    }\n    \n    glimpRenderThread = function;\n\n    rc = pthread_create(&renderThread,\n                        NULL, // attributes\n                        GLimp_RenderThreadWrapper,\n                        NULL); // argument\n    if (rc) {\n        ri.Printf(PRINT_ALL, \"pthread_create returned %d: %s\", rc, strerror(rc));\n        return qfalse;\n    } else {\n        rc = pthread_detach(renderThread);\n        if (rc) {\n            ri.Printf(PRINT_ALL, \"pthread_detach returned %d: %s\", rc, strerror(rc));\n        }\n    }\n\n    return qtrue;\n}\n\nstatic\tvolatile void\t*smpData;\n\n// TJW - This is calling in the rendering thread to wait until another\n// command buffer is ready.  The command buffer returned might be NULL,\n// indicating that the rendering thread should exit.\nvoid *GLimp_RendererSleep(void)\n{\n    //_Log(__PRETTY_FUNCTION__ \" entered\");\n    unsigned int msgCode;\n    void *msgData;\n    \n    GLSTAMP(\"GLimp_RendererSleep start\", 0);\n\n#ifndef USE_CGLMACROS\n    // Clear the current context while we sleep so the main thread can access it\n    OSX_GLContextClearCurrent();\n#endif\n\n    // Let the main thread we are idle and that no work is queued\n    //_Log(\"rs0\\n\");\n    /* If we actually had some work to do, then tell the front end we completed it. */\n    if (rendererProcessingCommand) {\n        SendMsg(&frontEndMsgPort, RenderCompletedMsg, NULL);\n        rendererProcessingCommand = NO;\n    }\n    \n    // Wait for new msg\n    for (;;) {\n        WaitMsg(&rendererMsgPort, &msgCode, &msgData);\n        if (1 || msgCode == RenderCommandMsg) {\n            smpData = msgData;\n            break;\n        } else {\n            printf(\"renderer received unknown message: %d\\n\",msgCode);\n        }\n    }\n    \n#ifndef USE_CGLMACROS\n    // We are going to render a frame... retake the context\n    OSX_GLContextSetCurrent();\n#endif\n\n    rendererProcessingCommand = YES;\n    \n    GLSTAMP(\"GLimp_RendererSleep end\", 0);\n\n    return (void *)smpData;\n}\n\n\n// TJW - This is from the main thread to wait until the rendering thread\n// has completed the command buffer that it has\nvoid GLimp_FrontEndSleep(void)\n{\n    unsigned int msgCode;\n    void *msgData;\n    \n    GLSTAMP(\"GLimp_FrontEndSleep start\", 1);\n\n    if (renderMsgOutstanding) {\n        for (;;) {\n            WaitMsg(&frontEndMsgPort, &msgCode, &msgData);\n            if(1 || msgCode == RenderCompletedMsg) {\n                break;\n            } else {\n                printf(\"front end received unknown message: %d\\n\",msgCode);\n            }\n        }\n        renderMsgOutstanding = NO;\n    }\n\n#ifndef USE_CGLMACROS\n    // We are done waiting for the background thread, take the current context back.\n    OSX_GLContextSetCurrent();\n#endif\n\n    GLSTAMP(\"GLimp_FrontEndSleep end\", 1);\n}\n\n\n// TJW - This is called in the main thread to issue another command\n// buffer to the rendering thread.  This is always called AFTER\n// GLimp_FrontEndSleep, so we know that there is no command\n// pending in 'smpData'.\nvoid GLimp_WakeRenderer( void *data )\n{\n    GLSTAMP(\"GLimp_WakeRenderer start\", 1);\n\n#ifndef USE_CGLMACROS\n    // We want the background thread to draw stuff.  Give up the current context\n    OSX_GLContextClearCurrent();\n#endif\n\n    SendMsg(&rendererMsgPort, RenderCommandMsg, data);   \n\t\n    // Don't set flag saying that the renderer is processing something if it's just\n    // being told to exit.\n    //if(data != NULL)     \n    renderMsgOutstanding = YES;\n\n    GLSTAMP(\"GLimp_WakeRenderer end\", 1);\n}\n"
  },
  {
    "path": "code/macosx/macosx_input.m",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#import <AppKit/AppKit.h>\n#import <Foundation/Foundation.h>\n#include <ApplicationServices/ApplicationServices.h>\n\n#import \"../client/client.h\"\n#import \"macosx_local.h\"\n#import \"../renderer/tr_local.h\"\n\n#import \"Q3Controller.h\"\n//#import \"CGMouseDeltaFix.h\"\n#import \"macosx_timers.h\"\n#import \"macosx_display.h\" // For Sys_SetScreenFade\n\n#import <drivers/event_status_driver.h>\n#import <sys/types.h>\n#import <sys/time.h>\n#import <unistd.h>\n\n\nstatic qboolean inputActive;\n\nstatic NSDate *distantPast;\n\nstatic cvar_t *in_nomouse;\nstatic cvar_t *in_showevents;\nstatic cvar_t *in_mouseLowEndSlope;\nstatic cvar_t *in_mouseHighEndCutoff;\nstatic cvar_t *in_disableOSMouseScaling;\n\nstatic void Sys_StartMouseInput();\nstatic void Sys_StopMouseInput();\nstatic qboolean mouseactive = qfalse;\nstatic BOOL inputRectValid = NO;\nstatic CGRect inputRect;\nstatic NXMouseScaling originalScaling;\n\nstatic unsigned int currentModifierFlags;\n\n\n\nstatic void Sys_PreventMouseMovement(CGPoint point)\n{\n    CGEventErr err;\n\n    //Com_Printf(\"**** Calling CGAssociateMouseAndMouseCursorPosition(false)\\n\");\n    err = CGAssociateMouseAndMouseCursorPosition(false);\n    if (err != CGEventNoErr) {\n        Sys_Error(\"Could not disable mouse movement, CGAssociateMouseAndMouseCursorPosition returned %d\\n\", err);\n    }\n\n    // Put the mouse in the position we want to leave it at\n    err = CGWarpMouseCursorPosition(point);\n    if (err != CGEventNoErr) {\n        Sys_Error(\"Could not disable mouse movement, CGWarpMouseCursorPosition returned %d\\n\", err);\n    }\n}\n\nstatic void Sys_ReenableMouseMovement()\n{\n    CGEventErr err;\n    \n    //Com_Printf(\"**** Calling CGAssociateMouseAndMouseCursorPosition(true)\\n\");\n    \n    err = CGAssociateMouseAndMouseCursorPosition(true);\n    if (err != CGEventNoErr) {\n        Sys_Error(\"Could not reenable mouse movement, CGAssociateMouseAndMouseCursorPosition returned %d\\n\", err);\n    }\n    \n    // Leave the mouse where it was -- don't warp here.\n}\n\n\nvoid Sys_InitInput(void)\n{\n    // no input with dedicated servers\n    if ( com_dedicated->integer ) {\n            return;\n    }\n\t\n    // The Cvars don't seem to work really early.\n    [(Q3Controller *)[NSApp delegate] showBanner];\n\n    Com_Printf( \"------- Input Initialization -------\\n\" );\n\n    if (!distantPast)\n        distantPast = [[NSDate distantPast] retain];\n\n    // For hide support.  If we don't do this, then the command key will get stuck on when we hide (since we won't get the flags changed event when it goes up).\n    currentModifierFlags = 0;\n    \n    r_fullscreen = Cvar_Get( \"r_fullscreen\", \"1\", CVAR_ARCHIVE | CVAR_LATCH );\n    in_nomouse = Cvar_Get( \"in_nomouse\", \"0\", 0 );\n    in_showevents = Cvar_Get( \"in_showevents\", \"0\", 0 );\n\n    // these defaults were arrived at via emprical testing between a Windows box and a Mac OS X box\n#define ACT_LIKE_WINDOWS\n#ifdef ACT_LIKE_WINDOWS\n    in_mouseLowEndSlope = Cvar_Get(\"in_mouseLowEndSlope\", \"3.5\", CVAR_ARCHIVE);\n    if (in_mouseLowEndSlope->value < 1) {\n        Cvar_Set(\"in_mouseLowEndSlope\", \"1\");\n    }\n#else\n    in_mouseLowEndSlope = Cvar_Get(\"in_mouseLowEndSlope\", \"1\", CVAR_ARCHIVE);\n    if (in_mouseLowEndSlope->value < 1) {\n        Cvar_Set(\"in_mouseLowEndSlope\", \"1\");\n    }\n#endif\n\n    in_mouseHighEndCutoff = Cvar_Get(\"in_mouseHighEndCutoff\", \"20\", CVAR_ARCHIVE);\n    if (in_mouseLowEndSlope->value < 1) {\n        Cvar_Set(\"in_mouseHighEndCutoff\", \"1\");\n    }\n    in_disableOSMouseScaling = Cvar_Get(\"in_disableOSMouseScaling\", \"1\", CVAR_ARCHIVE );\n    \n    glw_state.display = Sys_DisplayToUse();\n\n    inputActive = qtrue;\n\n    if ( in_nomouse->integer == 0 )\n        Sys_StartMouseInput();\n    else\n        Com_Printf( \"  in_nomouse is set, skipping.\\n\" );\n\n    Com_Printf( \"------------------------------------\\n\" );\n}\n\nvoid Sys_ShutdownInput(void)\n{\n    // no input with dedicated servers\n    if ( !com_dedicated || com_dedicated->integer ) {\n            return;\n    }\n\n    Com_Printf( \"------- Input Shutdown -------\\n\" );\n    if ( !inputActive ) {\n        return;\n    }\n    inputActive = qfalse;\n\n    if (mouseactive)\n        Sys_StopMouseInput();\n\n    Com_Printf( \"------------------------------\\n\" );\n}\n\nstatic void Sys_LockMouseInInputRect(CGRect rect)\n{\n    CGPoint center;\n    \n    center.x = rect.origin.x + rect.size.width / 2.0;\n    center.y = rect.origin.y + rect.size.height / 2.0;\n\n    // Now, put the mouse in the middle of the input rect (anywhere over it would do)\n    // and don't allow it to move.  This means that the user won't be able to accidentally\n    // select another application.\n    Sys_PreventMouseMovement(center);\n}\n\nextern void Sys_UpdateWindowMouseInputRect(void);\n\nstatic void Sys_StartMouseInput()\n{\n    NXEventHandle eventStatus;\n    CGMouseDelta dx, dy;\n\n    if (mouseactive) {\n        //Com_Printf(\"**** Attempted to start mouse input while already started\\n\");\n        return;\n    }\n\n    Com_Printf(\"Starting mouse input\\n\");\n\n    mouseactive = qtrue;\n    if (inputRectValid && !glConfig.isFullscreen)\n        // Make sure that if window moved we don't hose the user...\n        Sys_UpdateWindowMouseInputRect();\n\n    Sys_LockMouseInInputRect(inputRect);\n\n    // Grab any mouse delta information to reset the last delta buffer\n    CGGetLastMouseDelta(&dx, &dy);\n    \n    // Turn off mouse scaling\n    if (in_disableOSMouseScaling->integer==0 && (eventStatus = NXOpenEventStatus())) {\n        NXMouseScaling newScaling;\n\n        NXGetMouseScaling(eventStatus, &originalScaling);\n        newScaling.numScaleLevels = 1;\n        newScaling.scaleThresholds[0] = 1;\n        newScaling.scaleFactors[0] = -1;\n        NXSetMouseScaling(eventStatus, &newScaling);\n        NXCloseEventStatus(eventStatus);\n    }\n    \n    [NSCursor hide];\n}\n\nstatic void Sys_StopMouseInput()\n{\n    NXEventHandle eventStatus;\n    if (!mouseactive) {\n        //Com_Printf(\"**** Attempted to stop mouse input while already stopped\\n\");\n        return;\n    }\n    \n    Com_Printf(\"Stopping mouse input\\n\");\n    \n    // Restore mouse scaling\n    if (in_disableOSMouseScaling->integer == 0 && (eventStatus = NXOpenEventStatus())) {\n        NXSetMouseScaling(eventStatus, &originalScaling);\n        NXCloseEventStatus(eventStatus);\n    }\n\n    mouseactive = qfalse;\n    Sys_ReenableMouseMovement();\n\n    [NSCursor unhide];\n}\n\n//===========================================================================\n\n#include <sys/types.h>\n#include <sys/time.h>\n#include <unistd.h>\n\nstatic char *Sys_ConsoleInput(void)\n{\n    extern qboolean stdin_active;\n    static char text[256];\n    int     len;\n    fd_set\tfdset;\n    struct timeval timeout;\n\n    if (!com_dedicated || !com_dedicated->integer)\n        return NULL;\n    \n    if (!stdin_active)\n        return NULL;\n    \n    FD_ZERO(&fdset);\n    FD_SET(fileno(stdin), &fdset);\n    timeout.tv_sec = 0;\n    timeout.tv_usec = 0;\n    if (select (1, &fdset, NULL, NULL, &timeout) == -1 || !FD_ISSET(fileno(stdin), &fdset))\n        return NULL;\n\n    len = read (fileno(stdin), text, sizeof(text));\n    if (len == 0) { // eof!\n        stdin_active = qfalse;\n        return NULL;\n    }\n\n    if (len < 1)\n        return NULL;\n    text[len-1] = 0;    // rip off the /n and terminate\n\n    return text;\n}\n\n//===========================================================================\n// Mouse input\n//===========================================================================\n\n#define MAX_DISPLAYS 128\n\nCGDirectDisplayID Sys_DisplayToUse(void)\n{\n    static BOOL gotDisplay =  NO;\n    static CGDirectDisplayID displayToUse;\n    \n    cvar_t   *vid_screen;\n    CGDisplayErr err;\n    CGDirectDisplayID displays[MAX_DISPLAYS];\n    CGDisplayCount displayCount;\n    int displayIndex;\n    \n    if (gotDisplay)\n        return displayToUse;\n    gotDisplay = YES;    \n    \n    err = CGGetActiveDisplayList(MAX_DISPLAYS, displays, &displayCount);\n    if (err != CGDisplayNoErr)\n        Sys_Error(\"Cannot get display list -- CGGetActiveDisplayList returned %d.\\n\", err);\n\n    // -1, the default, means to use the main screen\n    if ((vid_screen = Cvar_Get(\"vid_screen\", \"-1\", CVAR_ARCHIVE)))\n        displayIndex = vid_screen->integer;\n    else\n        displayIndex = -1;\n        \n    if (displayIndex < 0 || displayIndex >= displayCount)\n        // This is documented (in CGDirectDisplay.h) to be the main display.  We want to\n        // return this instead of kCGDirectMainDisplay since this will allow us to compare\n        // display IDs.\n        displayToUse = displays[0];\n    else\n        displayToUse = displays[displayIndex];\n\n    return displayToUse;\n}\n\nvoid Sys_SetMouseInputRect(CGRect newRect)\n{\n    inputRectValid = YES;\n    inputRect = newRect;\n    //Com_Printf(\"**** inputRect = (%f, %f, %f, %f)\\n\", newRect.origin.x, newRect.origin.y, newRect.size.width, newRect.size.height);\n    \n    if (mouseactive)\n        Sys_LockMouseInInputRect(inputRect);\n}\n\n\nstatic void Sys_ProcessMouseMovedEvent(NSEvent *mouseMovedEvent, int currentTime)\n{\n    float dx, dy;\n    \n    if (!mouseactive)\n        return;\n        \n    dx = [mouseMovedEvent deltaX];\n    dy = [mouseMovedEvent deltaY];\n    \n    if (in_showevents->integer)\n        Com_Printf(\"MOUSE MOVED: %d, %d\\n\", dx, dy);\n\n    Sys_QueEvent(currentTime, SE_MOUSE, dx, dy, 0, NULL );\n}\n\n// If we are 'paused' (i.e., in any state that our normal key bindings aren't in effect), then interpret cmd-h and cmd-tab as hiding the application.\nstatic qboolean maybeHide()\n{\n    if ((currentModifierFlags & NSCommandKeyMask) == 0)\n        return qfalse;\n\n    return Sys_Hide();\n}\n\nstatic inline void sendEventForCharacter(NSEvent *event, unichar character, qboolean keyDownFlag, int currentTime)\n{\n    if (in_showevents->integer)\n        Com_Printf(\"CHARACTER: 0x%02x down=%d\\n\", character, keyDownFlag);\n        \n#ifdef OMNI_TIMER\n    if (character == NSF9FunctionKey && !keyDownFlag) {\n        // Log and reset the root timer.  We should currently only have the root on the stack.\n        OTStackPopRoot();\n        OTStackReportResults(NULL);\n        OTStackReset();\n        OTStackPushRoot(rootNode);\n    }\n#endif\n\n    switch (character) {\n        case 0x03:\n            Sys_QueEvent(currentTime, SE_KEY, K_KP_ENTER, keyDownFlag, 0, NULL);\n            break;\n        case '\\b':\n        case '\\177':\n            Sys_QueEvent(currentTime, SE_KEY, K_BACKSPACE, keyDownFlag, 0, NULL);\n            if (keyDownFlag) {\n               Sys_QueEvent(currentTime, SE_CHAR, '\\b', 0, 0, NULL);\n            }\n            break;\n        case '\\t':\n            if (maybeHide())\n                return;\n            Sys_QueEvent(currentTime, SE_KEY, K_TAB, keyDownFlag, 0, NULL);\n            if (keyDownFlag) {\n                Sys_QueEvent(currentTime, SE_CHAR, '\\t', 0, 0, NULL);\n            }\n            break;\n        case '\\r':\n        case '\\n':\n            Sys_QueEvent(currentTime, SE_KEY, K_ENTER, keyDownFlag, 0, NULL);\n            if (keyDownFlag) {\n                Sys_QueEvent(currentTime, SE_CHAR, '\\r', 0, 0, NULL);\n            }\n            break;\n        case '\\033':\n            Sys_QueEvent(currentTime, SE_KEY, K_ESCAPE, keyDownFlag, 0, NULL);\n            break;\n        case ' ':\n            Sys_QueEvent(currentTime, SE_KEY, K_SPACE, keyDownFlag, 0, NULL);\n            if (keyDownFlag) {\n                Sys_QueEvent(currentTime, SE_CHAR, ' ', 0, 0, NULL);\n            }\n            break;\n        case NSUpArrowFunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_UPARROW, keyDownFlag, 0, NULL);\n            break;\n        case NSDownArrowFunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_DOWNARROW, keyDownFlag, 0, NULL);\n            break;\n        case NSLeftArrowFunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_LEFTARROW, keyDownFlag, 0, NULL);\n            break;\n        case NSRightArrowFunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_RIGHTARROW, keyDownFlag, 0, NULL);\n            break;\n        case NSF1FunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_F1, keyDownFlag, 0, NULL);\n            break;\n        case NSF2FunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_F2, keyDownFlag, 0, NULL);\n            break;\n        case NSF3FunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_F3, keyDownFlag, 0, NULL);\n            break;\n        case NSF4FunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_F4, keyDownFlag, 0, NULL);\n            break;\n        case NSF5FunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_F5, keyDownFlag, 0, NULL);\n            break;\n        case NSF6FunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_F6, keyDownFlag, 0, NULL);\n            break;\n        case NSF7FunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_F7, keyDownFlag, 0, NULL);\n            break;\n        case NSF8FunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_F8, keyDownFlag, 0, NULL);\n            break;\n        case NSF9FunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_F9, keyDownFlag, 0, NULL);\n            break;\n        case NSF10FunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_F10, keyDownFlag, 0, NULL);\n            break;\n        case NSF11FunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_F11, keyDownFlag, 0, NULL);\n            break;\n        case NSF12FunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_F12, keyDownFlag, 0, NULL);\n            break;\n        case NSF13FunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, '`', keyDownFlag, 0, NULL);\n            if (keyDownFlag) {\n                Sys_QueEvent(currentTime, SE_CHAR, '`', 0, 0, NULL);\n            }\n            break;\n        case NSInsertFunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_INS, keyDownFlag, 0, NULL);\n            break;\n        case NSDeleteFunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_DEL, keyDownFlag, 0, NULL);\n            break;\n        case NSPageDownFunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_PGDN, keyDownFlag, 0, NULL);\n            break;\n        case NSPageUpFunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_PGUP, keyDownFlag, 0, NULL);\n            break;\n        case NSHomeFunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_HOME, keyDownFlag, 0, NULL);\n            break;\n        case NSEndFunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_END, keyDownFlag, 0, NULL);\n            break;\n        case NSPauseFunctionKey:\n            Sys_QueEvent(currentTime, SE_KEY, K_PAUSE, keyDownFlag, 0, NULL);\n            break;\n        default:\n            if ([event modifierFlags] & NSNumericPadKeyMask) {\n                switch (character) {\n                    case '0':\n                        Sys_QueEvent(currentTime, SE_KEY, K_KP_INS, keyDownFlag, 0, NULL);\n                        break;\n                    case '1':\n                        Sys_QueEvent(currentTime, SE_KEY, K_KP_END, keyDownFlag, 0, NULL);\n                        break;\n                    case '2':\n                        Sys_QueEvent(currentTime, SE_KEY, K_KP_DOWNARROW, keyDownFlag, 0, NULL);\n                        break;\n                    case '3':\n                        Sys_QueEvent(currentTime, SE_KEY, K_KP_PGDN, keyDownFlag, 0, NULL);\n                        break;\n                    case '4':\n                        Sys_QueEvent(currentTime, SE_KEY, K_KP_LEFTARROW, keyDownFlag, 0, NULL);\n                        break;\n                    case '5':\n                        Sys_QueEvent(currentTime, SE_KEY, K_KP_5, keyDownFlag, 0, NULL);\n                        break;\n                    case '6':\n                        Sys_QueEvent(currentTime, SE_KEY, K_KP_RIGHTARROW, keyDownFlag, 0, NULL);\n                        break;\n                    case '7':\n                        Sys_QueEvent(currentTime, SE_KEY, K_KP_HOME, keyDownFlag, 0, NULL);\n                        break;\n                    case '8':\n                        Sys_QueEvent(currentTime, SE_KEY, K_KP_UPARROW, keyDownFlag, 0, NULL);\n                        break;\n                    case '9':\n                        Sys_QueEvent(currentTime, SE_KEY, K_KP_PGUP, keyDownFlag, 0, NULL);\n                        break;\n                    case '.':\n                    case ',':\n                        Sys_QueEvent(currentTime, SE_KEY, K_KP_DEL, keyDownFlag, 0, NULL);\n                        break;\n                    case '+':\n                        Sys_QueEvent(currentTime, SE_KEY, K_KP_PLUS, keyDownFlag, 0, NULL);\n                        break;\n                    case '-':\n                        Sys_QueEvent(currentTime, SE_KEY, K_KP_MINUS, keyDownFlag, 0, NULL);\n                        break;\n                    case '*':\n                        Sys_QueEvent(currentTime, SE_KEY, K_KP_STAR, keyDownFlag, 0, NULL);\n                        break;\n                    case '/':\n                        Sys_QueEvent(currentTime, SE_KEY, K_KP_SLASH, keyDownFlag, 0, NULL);\n                        break;\n                    case '=':\n                        Sys_QueEvent(currentTime, SE_KEY, K_KP_EQUALS, keyDownFlag, 0, NULL);\n                        break;\n                    default:\n                        //NSLog(@\"TODO: Implement character %d\", (int)character);\n                        break;\n                 }       \n            } else if (character >= 'a' && character <= 'z') {\n                if (character == 'h') {\n                    if (maybeHide())\n                        return;\n                }\n                Sys_QueEvent(currentTime, SE_KEY, character, keyDownFlag, 0, NULL);\n                if (keyDownFlag) {\n                    Sys_QueEvent(currentTime, SE_CHAR, (char)character, 0, 0, NULL);\n                }\n            } else if (character >= 'A' && character <= 'Z') {\n                Sys_QueEvent(currentTime, SE_KEY, 'a' + (character - 'A'), keyDownFlag, 0, NULL);\n                if (keyDownFlag) {\n                    Sys_QueEvent(currentTime, SE_CHAR, character, 0, 0, NULL);\n                }\n            } else if (character >= 32 && character < 127) {\n                Sys_QueEvent(currentTime, SE_KEY, character, keyDownFlag, 0, NULL);\n                if (keyDownFlag) {\n                    Sys_QueEvent(currentTime, SE_CHAR, (char)character, 0, 0, NULL);\n                }\n            } else {\n                //NSLog(@\"TODO: Implement character %d\", (int)character);\n            }\n            break;\n    }\n}\n\nstatic inline void processKeyEvent(NSEvent *keyEvent, qboolean keyDownFlag, int currentTime)\n{\n    NSEventType eventType;\n    NSString *characters;\n    unsigned int characterIndex, characterCount;\n\n    eventType = [keyEvent type];\n    characters = [keyEvent charactersIgnoringModifiers];\n    characterCount = [characters length];\n\n    for (characterIndex = 0; characterIndex < characterCount; characterIndex++) {\n        sendEventForCharacter(keyEvent, [characters characterAtIndex:characterIndex], keyDownFlag, currentTime);\n    }\n}\n\nstatic inline void sendEventForMaskChangeInFlags(int quakeKey, unsigned int modifierMask, unsigned int newModifierFlags, int currentTime)\n{\n    BOOL oldHadModifier, newHasModifier;\n\n    oldHadModifier = (currentModifierFlags & modifierMask) != 0;\n    newHasModifier = (newModifierFlags & modifierMask) != 0;\n    if (oldHadModifier != newHasModifier) {\n        // NSLog(@\"Key %d posted for modifier mask modifierMask\", quakeKey);\n        Sys_QueEvent(currentTime, SE_KEY, quakeKey, newHasModifier, 0, NULL);\n    }\n}\n\nstatic inline void processFlagsChangedEvent(NSEvent *flagsChangedEvent, int currentTime)\n{\n    int newModifierFlags;\n\n    newModifierFlags = [flagsChangedEvent modifierFlags];\n    sendEventForMaskChangeInFlags(K_COMMAND, NSCommandKeyMask, newModifierFlags, currentTime);\n    sendEventForMaskChangeInFlags(K_CAPSLOCK, NSAlphaShiftKeyMask, newModifierFlags, currentTime);\n    sendEventForMaskChangeInFlags(K_ALT, NSAlternateKeyMask, newModifierFlags, currentTime);\n    sendEventForMaskChangeInFlags(K_CTRL, NSControlKeyMask, newModifierFlags, currentTime);\n    sendEventForMaskChangeInFlags(K_SHIFT, NSShiftKeyMask, newModifierFlags, currentTime);\n    currentModifierFlags = newModifierFlags;\n}\n\nstatic inline void processSystemDefinedEvent(NSEvent *systemDefinedEvent, int currentTime)\n{\n    static int oldButtons = 0;\n    int buttonsDelta;\n    int buttons;\n    int isDown;\n    \n    if ([systemDefinedEvent subtype] == 7) {\n\n        if (!mouseactive)\n            return;\n        \n    \n\tbuttons = [systemDefinedEvent data2];\n        buttonsDelta = oldButtons ^ buttons;\n        \n        //Com_Printf(\"uberbuttons: %08lx %08lx\\n\",buttonsDelta,buttons);\n\n\n\tif (buttonsDelta & 1) {\n            isDown = buttons & 1;\n            Sys_QueEvent(currentTime, SE_KEY, K_MOUSE1, isDown, 0, NULL);\n            if (in_showevents->integer) {\n                Com_Printf(\"MOUSE2: %s\\n\", isDown ? \"down\" : \"up\");\n            }\n\t}\n\n\tif (buttonsDelta & 2) {\n            isDown = buttons & 2;\n            Sys_QueEvent(currentTime, SE_KEY, K_MOUSE2, isDown, 0, NULL);\n            if (in_showevents->integer) {\n                Com_Printf(\"MOUSE3: %s\\n\", isDown ? \"down\" : \"up\");\n            }\n\t}\n\n\tif (buttonsDelta & 4) {\n            isDown = buttons & 4;\n            Sys_QueEvent(currentTime, SE_KEY, K_MOUSE3, isDown, 0, NULL);\n            if (in_showevents->integer) {\n                Com_Printf(\"MOUSE1: %s\\n\", isDown ? \"down\" : \"up\");\n            }\n\t}\n\n\tif (buttonsDelta & 8) {\n            isDown = buttons & 8;\n            Sys_QueEvent(currentTime, SE_KEY, K_MOUSE4, isDown, 0, NULL);\n            if (in_showevents->integer) {\n                Com_Printf(\"MOUSE4: %s\\n\", isDown ? \"down\" : \"up\");\n            }\n        }\n        \n\tif (buttonsDelta & 16) {\n            isDown = buttons & 16;\n            Sys_QueEvent(currentTime, SE_KEY, K_MOUSE5, isDown, 0, NULL);\n            if (in_showevents->integer) {\n                Com_Printf(\"MOUSE5: %s\\n\", isDown ? \"down\" : \"up\");\n            }\n\t}\n        \n        oldButtons = buttons;\n    }\n}\n\nstatic inline void processEvent(NSEvent *event, int currentTime)\n{\n    NSEventType eventType;\n\n    if (!inputActive)\n        return;\n\n    eventType = [event type];\n\n    if (in_showevents->integer)\n        NSLog(@\"event = %@\", event);\n    \n    switch (eventType) {\n        // These six event types are ignored since we do all of our mouse down/up process via the uber-mouse system defined event.  We have to accept these events however since they get enqueued and the queue will fill up if we don't.\n        case NSLeftMouseDown:\n            //Sys_QueEvent(currentTime, SE_KEY, K_MOUSE1, qtrue, 0, NULL);\n            return;\n        case NSLeftMouseUp:\n            //Sys_QueEvent(currentTime, SE_KEY, K_MOUSE1, qfalse, 0, NULL);\n            return;\n        case NSRightMouseDown:\n            //Sys_QueEvent(currentTime, SE_KEY, K_MOUSE2, qtrue, 0, NULL);\n            return;\n        case NSRightMouseUp:\n            //Sys_QueEvent(currentTime, SE_KEY, K_MOUSE2, qfalse, 0, NULL);\n            return;\n        case 25: // other mouse down\n            return;\n        case 26: // other mouse up\n            return;\n            \n        case NSMouseMoved:\n        case NSLeftMouseDragged:\n        case NSRightMouseDragged:\n        case 27: // other mouse dragged\n            Sys_ProcessMouseMovedEvent(event, currentTime);\n            return;\n        case NSKeyDown:\n        case NSKeyUp:\n            processKeyEvent(event, eventType == NSKeyDown, currentTime);\n            return;\n        case NSFlagsChanged:\n            processFlagsChangedEvent(event, currentTime);\n            return;\n\tcase NSSystemDefined:\n\t    processSystemDefinedEvent(event, currentTime);\n\t    return;\n        case NSScrollWheel:\n            if ([event deltaY] < 0.0) {\n                Sys_QueEvent(currentTime, SE_KEY, K_MWHEELDOWN, qtrue, 0, NULL );\n                Sys_QueEvent(currentTime, SE_KEY, K_MWHEELDOWN, qfalse, 0, NULL );\n            } else {\n                Sys_QueEvent(currentTime, SE_KEY, K_MWHEELUP, qtrue, 0, NULL );\n                Sys_QueEvent(currentTime, SE_KEY, K_MWHEELUP, qfalse, 0, NULL );\n            }\n            return;\n        default:\n            break;\n    }\n    [NSApp sendEvent:event];\n}\n\nstatic void Sys_SendKeyEvents(int currentTime)\n{\n#ifndef DEDICATED\n    NSEvent *event;\n    NSDate *timeout;\n    extern float SNDDMA_GetBufferDuration();\n    \n    timeout = distantPast;\n    if (Sys_IsHidden)\n        timeout = [NSDate dateWithTimeIntervalSinceNow: 0.25 * SNDDMA_GetBufferDuration()];\n    \n    // This gets call regardless of whether inputActive is true or not.  This is important since we need to be poking the event queue in order for the unhide event to make its way through the system.  This means that when we hide, we can just shut down the input system and reeanbled it when we unhide.\n    while ((event = [NSApp nextEventMatchingMask: NSAnyEventMask\n                                       untilDate: timeout\n                                          inMode: NSDefaultRunLoopMode\n                                         dequeue:YES])) {\n            if (Sys_IsHidden) {\n                // Just let NSApp handle events so that we'll get the app activation event\n                [NSApp sendEvent: event];\n                timeout = [NSDate dateWithTimeIntervalSinceNow: 0.1];\n            } else {\n                static int lastEventTime = 0;\n                static BOOL lastEventTimeValid = NO;\n\n                // Mac OS X 10.0.3 has a bug where the if the monitor goes to sleep in fullscreen GL mode, the gamma won't be restored.  We'll restore the gamma if there is a pause while in the game of more than 10 seconds.  We don't do this on the 'Sys_IsHidden' branch since unhiding will restore the monitor gamma.\n                if ((currentTime - lastEventTime > 1 * 1000) && lastEventTimeValid) {\n                    //Com_Printf(\"Restoring monitor gamma after being idle for %f seconds.\\n\", (currentTime - lastEventTime) / 1000.0);\n                    [NSCursor hide];\n                    Sys_SetScreenFade(&glw_state.inGameTable, 1.0);\n                }\n                lastEventTime = [event timestamp] * 1000.0;\t//currentTime;\n                lastEventTimeValid = YES;\n                \n                processEvent(event, lastEventTime);\n            }\n    }\n#endif\n}\n\n/*\n========================================================================\n\nEVENT LOOP\n\n========================================================================\n*/\n\nextern qboolean\tSys_GetPacket ( netadr_t *net_from, msg_t *net_message );\n\n#define\tMAX_QUED_EVENTS\t\t256\n#define\tMASK_QUED_EVENTS\t( MAX_QUED_EVENTS - 1 )\n\nstatic sysEvent_t\teventQue[MAX_QUED_EVENTS];\nstatic int              eventHead, eventTail;\nstatic byte\t\tsys_packetReceived[MAX_MSGLEN];\n\n/*\n================\nSys_QueEvent\n\nA time of 0 will get the current time\nPtr should either be null, or point to a block of data that can\nbe freed by the game later.\n================\n*/\nvoid Sys_QueEvent( int time, sysEventType_t type, int value, int value2, int ptrLength, void *ptr ) {\n\tsysEvent_t\t*ev;\n        int\ti,j;\n#ifndef DEDICATED\n    if (in_showevents->integer)\n        NSLog(@\"EVENT ENQUEUE:  time=%d type=%d value=0x%08x value2=0x%08x\\n\", time, type, value, value2);\n#endif\n\n\tif ( eventHead - eventTail >= MAX_QUED_EVENTS ) {\n\t\tCom_Printf(\"Sys_QueEvent: overflow\\n\");\n\t}\n\n\tif ( !time ) {\n\t\ttime = Sys_Milliseconds();\n\t}\n\n\t// insert it by time\n\tfor ( i = eventTail ; i < eventHead ; i++ ) {\n\t\tev = &eventQue[ i & MASK_QUED_EVENTS ];\n\t\tif ( ev->evTime > time ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// insert before i\n\tfor ( j = eventHead ; j > i ; j-- ) {\n\t\teventQue[ j & MASK_QUED_EVENTS ] = eventQue[ (j-1) & MASK_QUED_EVENTS ];\n\t}\n\tev = &eventQue[ i & MASK_QUED_EVENTS ];\n\n\teventHead++;\n\n\tev->evTime = time;\n\tev->evType = type;\n\tev->evValue = value;\n\tev->evValue2 = value2;\n\tev->evPtrLength = ptrLength;\n\tev->evPtr = ptr;\n}\n\n/*\n================\nSys_GetEvent\n\n================\n*/\nsysEvent_t Sys_GetEvent( void )\n{\n    sysEvent_t\tev;\n    char       *s;\n    msg_t       netmsg;\n    netadr_t\tadr;\n    int         currentTime;\n    \n    // return if we have data\n    if (eventHead > eventTail) {\n        eventTail++;\n        return eventQue[ ( eventTail - 1 ) & MASK_QUED_EVENTS ];\n    }\n\n    // The queue must be empty.  Check all of the event sources.  If the events are\n    // already in the queue, we can't imply any real ordering, so we'll avoid extra\n    // system calls and give them all the same time.\n    currentTime = Sys_Milliseconds();\n\n    // Check for mouse and keyboard events\n    Sys_SendKeyEvents(currentTime);\n\n    // check for console commands\n    s = Sys_ConsoleInput();\n    if ( s ) {\n        char\t*b;\n        int\t\tlen;\n    \n        len = strlen( s ) + 1;\n        b = Z_Malloc( len );\n        strcpy( b, s );\n        Sys_QueEvent( currentTime, SE_CONSOLE, 0, 0, len, b );\n    }\n    \n\n    // During debugging it is sometimes usefull to be able to start/stop mouse input.\n    // Don't turn on the input when we've disabled it because we're hidden, however.\n    if (!com_dedicated->integer) {\n        if (in_nomouse->integer == mouseactive && !Sys_IsHidden) {\n            if (in_nomouse->integer)\n                Sys_StopMouseInput();\n            else\n                Sys_StartMouseInput();\n        }\n    }\n    \n    // check for network packets\n    MSG_Init( &netmsg, sys_packetReceived, sizeof( sys_packetReceived ) );\n    if ( Sys_GetPacket ( &adr, &netmsg ) ) {\n        netadr_t\t\t*buf;\n        int\t\t\t\tlen;\n    \n        // copy out to a seperate buffer for qeueing\n        len = sizeof( netadr_t ) + netmsg.cursize;\n        buf = Z_Malloc( len );\n        *buf = adr;\n        memcpy( buf+1, netmsg.data, netmsg.cursize );\n        Sys_QueEvent( currentTime, SE_PACKET, 0, 0, len, buf );\n    }\n\n    // If we got an event, return it\n    if (eventHead > eventTail) {\n        eventTail++;\n        return eventQue[ ( eventTail - 1 ) & MASK_QUED_EVENTS ];\n    }\n    \n    // Otherwise, return an empty event to indicate that there are no events pending.\n    memset( &ev, 0, sizeof( ev ) );\n    ev.evTime = currentTime;\n\n    return ev;\n}\n\n\n\n"
  },
  {
    "path": "code/macosx/macosx_local.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __macosx_local_h\n#define __macosx_local_h\n\n#include \"qcommon.h\"\n\n#ifdef __cplusplus\ntypedef void NSDictionary;\ntypedef void NSOpenGLContext;\ntypedef void NSWindow;\n\nextern \"C\" {\n#else\n#import <Foundation/NSGeometry.h>\n@class NSEvent, NSOpenGLContext, NSWindow;\n#endif\n\n#include <ApplicationServices/ApplicationServices.h>\n#include <OpenGL/CGLTypes.h>\n\n// In macosx_input.m\nextern void Sys_InitInput(void);\nextern void Sys_ShutdownInput(void);\nextern void Sys_SetMouseInputRect(CGRect newRect);\nextern CGDirectDisplayID Sys_DisplayToUse(void);\n\n// In macosx_sys.m\nextern void Sys_QueEvent(int time, sysEventType_t type, int value, int value2, int ptrLength, void *ptr);\nextern void Sys_AnnoyingBanner();\n\n// In macosx_glimp.m\nextern qboolean Sys_IsHidden;\nextern qboolean Sys_Hide();\nextern qboolean Sys_Unhide();\n\ntypedef struct {\n    CGDirectDisplayID     display;\n    CGTableCount          tableSize;\n    CGGammaValue\t *red;\n    CGGammaValue\t *blue;\n    CGGammaValue\t *green;\n} glwgamma_t;\n\ntypedef struct\n{\n    CGDirectDisplayID     display;\n    NSDictionary         *desktopMode;\n    NSDictionary         *gameMode;\n\n    CGDisplayCount        displayCount;\n    glwgamma_t           *originalDisplayGammaTables;\n    glwgamma_t            inGameTable;\n    glwgamma_t            tempTable;\n    \n    NSOpenGLContext      *_ctx;\n    CGLContextObj         _cgl_ctx;\n    qboolean              _ctx_is_current;\n    NSWindow             *window;\n    \n    FILE                 *log_fp;\n    \n    unsigned int          bufferSwapCount;\n    unsigned int          glPauseCount;\n} glwstate_t;\n\nextern glwstate_t glw_state;\n\n#define OSX_SetGLContext(context) \\\ndo { \\\n    NSOpenGLContext *_context = (context); \\\n    glw_state._ctx = _context; \\\n    glw_state._cgl_ctx = [_context cglContext]; \\\n} while (0)\n\n#define OSX_GetNSGLContext() glw_state._ctx\n#define OSX_GetCGLContext() glw_state._cgl_ctx\n\n#define OSX_GLContextIsCurrent() glw_state._ctx_is_current\n#define OSX_GLContextSetCurrent() \\\ndo { \\\n  [glw_state._ctx makeCurrentContext]; \\\n  glw_state._ctx_is_current = (glw_state._ctx != nil); \\\n} while (0)\n\n#define OSX_GLContextClearCurrent() \\\ndo { \\\n  [NSOpenGLContext clearCurrentContext]; \\\n  glw_state._ctx_is_current = NO; \\\n} while (0)\n\n\nextern void Sys_PauseGL();\nextern void Sys_ResumeGL();\n\n\n#import \"macosx_timers.h\"\n\n#ifdef OMNI_TIMER\nextern OTStampList glThreadStampList;\n#define GLSTAMP(name, data) OTStampListAddStamp(glThreadStampList, name, data)\n#else\n#define GLSTAMP(name, data)\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif // __macosx_local_h\n"
  },
  {
    "path": "code/macosx/macosx_qgl.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n/**** This file is autogenerated.  Run GenerateQGL.pl to update it ****/\n\n#ifdef QGL_LOG_GL_CALLS\nextern unsigned int QGLLogGLCalls;\nextern FILE *QGLDebugFile(void);\n#endif\n\nextern void QGLCheckError(const char *message);\nextern unsigned int QGLBeginStarted;\n\n// This has to be done to avoid infinite recursion between our glGetError wrapper and QGLCheckError()\nstatic inline GLenum _glGetError(void) {\n    return glGetError();\n}\n\n// void glAccum (GLenum op, GLfloat value);\nstatic inline void qglAccum(GLenum op, GLfloat value)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glAccum(op=%lu, value=%f)\\n\", op, value);\n#endif\n    glAccum(op, value);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glAccum\");\n#endif\n}\n\n// void glAlphaFunc (GLenum func, GLclampf ref);\nstatic inline void qglAlphaFunc(GLenum func, GLclampf ref)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glAlphaFunc(func=%lu, ref=%f)\\n\", func, ref);\n#endif\n    glAlphaFunc(func, ref);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glAlphaFunc\");\n#endif\n}\n\n// GLboolean glAreTexturesResident (GLsizei n, const GLuint *textures, GLboolean *residences);\nstatic inline GLboolean qglAreTexturesResident(GLsizei n, const GLuint *textures, GLboolean *residences)\n{\n    GLboolean returnValue;\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glAreTexturesResident(n=%ld, textures=%p, residences=%p)\\n\", n, textures, residences);\n#endif\n    returnValue = glAreTexturesResident(n, textures, residences);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glAreTexturesResident\");\n#endif\n    return returnValue;\n}\n\n// void glArrayElement (GLint i);\nstatic inline void qglArrayElement(GLint i)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glArrayElement(i=%ld)\\n\", i);\n#endif\n    glArrayElement(i);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glArrayElement\");\n#endif\n}\n\n// void glBegin (GLenum mode);\nstatic inline void qglBegin(GLenum mode)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glBegin(mode=%lu)\\n\", mode);\n#endif\n    glBegin(mode);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    QGLBeginStarted++;\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glBegin\");\n#endif\n}\n\n// void glBindTexture (GLenum target, GLuint texture);\nstatic inline void qglBindTexture(GLenum target, GLuint texture)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glBindTexture(target=%lu, texture=%lu)\\n\", target, texture);\n#endif\n    glBindTexture(target, texture);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glBindTexture\");\n#endif\n}\n\n// void glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);\nstatic inline void qglBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glBitmap(width=%ld, height=%ld, xorig=%f, yorig=%f, xmove=%f, ymove=%f, bitmap=%p)\\n\", width, height, xorig, yorig, xmove, ymove, bitmap);\n#endif\n    glBitmap(width, height, xorig, yorig, xmove, ymove, bitmap);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glBitmap\");\n#endif\n}\n\n// void glBlendFunc (GLenum sfactor, GLenum dfactor);\nstatic inline void qglBlendFunc(GLenum sfactor, GLenum dfactor)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glBlendFunc(sfactor=%lu, dfactor=%lu)\\n\", sfactor, dfactor);\n#endif\n    glBlendFunc(sfactor, dfactor);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glBlendFunc\");\n#endif\n}\n\n// void glCallList (GLuint list);\nstatic inline void qglCallList(GLuint list)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glCallList(list=%lu)\\n\", list);\n#endif\n    glCallList(list);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glCallList\");\n#endif\n}\n\n// void glCallLists (GLsizei n, GLenum type, const GLvoid *lists);\nstatic inline void qglCallLists(GLsizei n, GLenum type, const GLvoid *lists)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glCallLists(n=%ld, type=%lu, lists=%p)\\n\", n, type, lists);\n#endif\n    glCallLists(n, type, lists);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glCallLists\");\n#endif\n}\n\n// void glClear (GLbitfield mask);\nstatic inline void qglClear(GLbitfield mask)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glClear(mask=%lu)\\n\", mask);\n#endif\n    glClear(mask);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glClear\");\n#endif\n}\n\n// void glClearAccum (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nstatic inline void qglClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glClearAccum(red=%f, green=%f, blue=%f, alpha=%f)\\n\", red, green, blue, alpha);\n#endif\n    glClearAccum(red, green, blue, alpha);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glClearAccum\");\n#endif\n}\n\n// void glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);\nstatic inline void qglClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glClearColor(red=%f, green=%f, blue=%f, alpha=%f)\\n\", red, green, blue, alpha);\n#endif\n    glClearColor(red, green, blue, alpha);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glClearColor\");\n#endif\n}\n\n// void glClearDepth (GLclampd depth);\nstatic inline void qglClearDepth(GLclampd depth)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glClearDepth(depth=%f)\\n\", depth);\n#endif\n    glClearDepth(depth);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glClearDepth\");\n#endif\n}\n\n// void glClearIndex (GLfloat c);\nstatic inline void qglClearIndex(GLfloat c)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glClearIndex(c=%f)\\n\", c);\n#endif\n    glClearIndex(c);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glClearIndex\");\n#endif\n}\n\n// void glClearStencil (GLint s);\nstatic inline void qglClearStencil(GLint s)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glClearStencil(s=%ld)\\n\", s);\n#endif\n    glClearStencil(s);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glClearStencil\");\n#endif\n}\n\n// void glClipPlane (GLenum plane, const GLdouble *equation);\nstatic inline void qglClipPlane(GLenum plane, const GLdouble *equation)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glClipPlane(plane=%lu, equation=%p)\\n\", plane, equation);\n#endif\n    glClipPlane(plane, equation);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glClipPlane\");\n#endif\n}\n\n// void glColor3b (GLbyte red, GLbyte green, GLbyte blue);\nstatic inline void qglColor3b(GLbyte red, GLbyte green, GLbyte blue)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor3b(red=%d, green=%d, blue=%d)\\n\", red, green, blue);\n#endif\n    glColor3b(red, green, blue);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor3b\");\n#endif\n}\n\n// void glColor3bv (const GLbyte *v);\nstatic inline void qglColor3bv(const GLbyte *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor3bv(v=%p)\\n\", v);\n#endif\n    glColor3bv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor3bv\");\n#endif\n}\n\n// void glColor3d (GLdouble red, GLdouble green, GLdouble blue);\nstatic inline void qglColor3d(GLdouble red, GLdouble green, GLdouble blue)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor3d(red=%f, green=%f, blue=%f)\\n\", red, green, blue);\n#endif\n    glColor3d(red, green, blue);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor3d\");\n#endif\n}\n\n// void glColor3dv (const GLdouble *v);\nstatic inline void qglColor3dv(const GLdouble *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor3dv(v=%p)\\n\", v);\n#endif\n    glColor3dv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor3dv\");\n#endif\n}\n\n// void glColor3f (GLfloat red, GLfloat green, GLfloat blue);\nstatic inline void qglColor3f(GLfloat red, GLfloat green, GLfloat blue)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor3f(red=%f, green=%f, blue=%f)\\n\", red, green, blue);\n#endif\n    glColor3f(red, green, blue);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor3f\");\n#endif\n}\n\n// void glColor3fv (const GLfloat *v);\nstatic inline void qglColor3fv(const GLfloat *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor3fv(v=%p)\\n\", v);\n#endif\n    glColor3fv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor3fv\");\n#endif\n}\n\n// void glColor3i (GLint red, GLint green, GLint blue);\nstatic inline void qglColor3i(GLint red, GLint green, GLint blue)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor3i(red=%ld, green=%ld, blue=%ld)\\n\", red, green, blue);\n#endif\n    glColor3i(red, green, blue);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor3i\");\n#endif\n}\n\n// void glColor3iv (const GLint *v);\nstatic inline void qglColor3iv(const GLint *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor3iv(v=%p)\\n\", v);\n#endif\n    glColor3iv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor3iv\");\n#endif\n}\n\n// void glColor3s (GLshort red, GLshort green, GLshort blue);\nstatic inline void qglColor3s(GLshort red, GLshort green, GLshort blue)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor3s(red=%d, green=%d, blue=%d)\\n\", red, green, blue);\n#endif\n    glColor3s(red, green, blue);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor3s\");\n#endif\n}\n\n// void glColor3sv (const GLshort *v);\nstatic inline void qglColor3sv(const GLshort *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor3sv(v=%p)\\n\", v);\n#endif\n    glColor3sv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor3sv\");\n#endif\n}\n\n// void glColor3ub (GLubyte red, GLubyte green, GLubyte blue);\nstatic inline void qglColor3ub(GLubyte red, GLubyte green, GLubyte blue)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor3ub(red=%u, green=%u, blue=%u)\\n\", red, green, blue);\n#endif\n    glColor3ub(red, green, blue);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor3ub\");\n#endif\n}\n\n// void glColor3ubv (const GLubyte *v);\nstatic inline void qglColor3ubv(const GLubyte *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor3ubv(v=%p)\\n\", v);\n#endif\n    glColor3ubv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor3ubv\");\n#endif\n}\n\n// void glColor3ui (GLuint red, GLuint green, GLuint blue);\nstatic inline void qglColor3ui(GLuint red, GLuint green, GLuint blue)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor3ui(red=%lu, green=%lu, blue=%lu)\\n\", red, green, blue);\n#endif\n    glColor3ui(red, green, blue);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor3ui\");\n#endif\n}\n\n// void glColor3uiv (const GLuint *v);\nstatic inline void qglColor3uiv(const GLuint *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor3uiv(v=%p)\\n\", v);\n#endif\n    glColor3uiv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor3uiv\");\n#endif\n}\n\n// void glColor3us (GLushort red, GLushort green, GLushort blue);\nstatic inline void qglColor3us(GLushort red, GLushort green, GLushort blue)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor3us(red=%u, green=%u, blue=%u)\\n\", red, green, blue);\n#endif\n    glColor3us(red, green, blue);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor3us\");\n#endif\n}\n\n// void glColor3usv (const GLushort *v);\nstatic inline void qglColor3usv(const GLushort *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor3usv(v=%p)\\n\", v);\n#endif\n    glColor3usv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor3usv\");\n#endif\n}\n\n// void glColor4b (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha);\nstatic inline void qglColor4b(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor4b(red=%d, green=%d, blue=%d, alpha=%d)\\n\", red, green, blue, alpha);\n#endif\n    glColor4b(red, green, blue, alpha);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor4b\");\n#endif\n}\n\n// void glColor4bv (const GLbyte *v);\nstatic inline void qglColor4bv(const GLbyte *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor4bv(v=%p)\\n\", v);\n#endif\n    glColor4bv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor4bv\");\n#endif\n}\n\n// void glColor4d (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);\nstatic inline void qglColor4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor4d(red=%f, green=%f, blue=%f, alpha=%f)\\n\", red, green, blue, alpha);\n#endif\n    glColor4d(red, green, blue, alpha);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor4d\");\n#endif\n}\n\n// void glColor4dv (const GLdouble *v);\nstatic inline void qglColor4dv(const GLdouble *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor4dv(v=%p)\\n\", v);\n#endif\n    glColor4dv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor4dv\");\n#endif\n}\n\n// void glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nstatic inline void qglColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor4f(red=%f, green=%f, blue=%f, alpha=%f)\\n\", red, green, blue, alpha);\n#endif\n    glColor4f(red, green, blue, alpha);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor4f\");\n#endif\n}\n\n// void glColor4fv (const GLfloat *v);\nstatic inline void qglColor4fv(const GLfloat *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor4fv(v=%p)\\n\", v);\n#endif\n    glColor4fv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor4fv\");\n#endif\n}\n\n// void glColor4i (GLint red, GLint green, GLint blue, GLint alpha);\nstatic inline void qglColor4i(GLint red, GLint green, GLint blue, GLint alpha)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor4i(red=%ld, green=%ld, blue=%ld, alpha=%ld)\\n\", red, green, blue, alpha);\n#endif\n    glColor4i(red, green, blue, alpha);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor4i\");\n#endif\n}\n\n// void glColor4iv (const GLint *v);\nstatic inline void qglColor4iv(const GLint *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor4iv(v=%p)\\n\", v);\n#endif\n    glColor4iv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor4iv\");\n#endif\n}\n\n// void glColor4s (GLshort red, GLshort green, GLshort blue, GLshort alpha);\nstatic inline void qglColor4s(GLshort red, GLshort green, GLshort blue, GLshort alpha)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor4s(red=%d, green=%d, blue=%d, alpha=%d)\\n\", red, green, blue, alpha);\n#endif\n    glColor4s(red, green, blue, alpha);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor4s\");\n#endif\n}\n\n// void glColor4sv (const GLshort *v);\nstatic inline void qglColor4sv(const GLshort *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor4sv(v=%p)\\n\", v);\n#endif\n    glColor4sv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor4sv\");\n#endif\n}\n\n// void glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);\nstatic inline void qglColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor4ub(red=%u, green=%u, blue=%u, alpha=%u)\\n\", red, green, blue, alpha);\n#endif\n    glColor4ub(red, green, blue, alpha);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor4ub\");\n#endif\n}\n\n// void glColor4ubv (const GLubyte *v);\nstatic inline void qglColor4ubv(const GLubyte *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor4ubv(v=%p)\\n\", v);\n#endif\n    glColor4ubv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor4ubv\");\n#endif\n}\n\n// void glColor4ui (GLuint red, GLuint green, GLuint blue, GLuint alpha);\nstatic inline void qglColor4ui(GLuint red, GLuint green, GLuint blue, GLuint alpha)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor4ui(red=%lu, green=%lu, blue=%lu, alpha=%lu)\\n\", red, green, blue, alpha);\n#endif\n    glColor4ui(red, green, blue, alpha);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor4ui\");\n#endif\n}\n\n// void glColor4uiv (const GLuint *v);\nstatic inline void qglColor4uiv(const GLuint *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor4uiv(v=%p)\\n\", v);\n#endif\n    glColor4uiv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor4uiv\");\n#endif\n}\n\n// void glColor4us (GLushort red, GLushort green, GLushort blue, GLushort alpha);\nstatic inline void qglColor4us(GLushort red, GLushort green, GLushort blue, GLushort alpha)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor4us(red=%u, green=%u, blue=%u, alpha=%u)\\n\", red, green, blue, alpha);\n#endif\n    glColor4us(red, green, blue, alpha);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor4us\");\n#endif\n}\n\n// void glColor4usv (const GLushort *v);\nstatic inline void qglColor4usv(const GLushort *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColor4usv(v=%p)\\n\", v);\n#endif\n    glColor4usv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColor4usv\");\n#endif\n}\n\n// void glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);\nstatic inline void qglColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColorMask(red=%u, green=%u, blue=%u, alpha=%u)\\n\", red, green, blue, alpha);\n#endif\n    glColorMask(red, green, blue, alpha);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColorMask\");\n#endif\n}\n\n// void glColorMaterial (GLenum face, GLenum mode);\nstatic inline void qglColorMaterial(GLenum face, GLenum mode)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColorMaterial(face=%lu, mode=%lu)\\n\", face, mode);\n#endif\n    glColorMaterial(face, mode);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColorMaterial\");\n#endif\n}\n\n// void glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nstatic inline void qglColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glColorPointer(size=%ld, type=%lu, stride=%ld, pointer=%p)\\n\", size, type, stride, pointer);\n#endif\n    glColorPointer(size, type, stride, pointer);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glColorPointer\");\n#endif\n}\n\n// void glCopyPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);\nstatic inline void qglCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glCopyPixels(x=%ld, y=%ld, width=%ld, height=%ld, type=%lu)\\n\", x, y, width, height, type);\n#endif\n    glCopyPixels(x, y, width, height, type);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glCopyPixels\");\n#endif\n}\n\n// void glCopyTexImage1D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border);\nstatic inline void qglCopyTexImage1D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glCopyTexImage1D(target=%lu, level=%ld, internalFormat=%lu, x=%ld, y=%ld, width=%ld, border=%ld)\\n\", target, level, internalFormat, x, y, width, border);\n#endif\n    glCopyTexImage1D(target, level, internalFormat, x, y, width, border);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glCopyTexImage1D\");\n#endif\n}\n\n// void glCopyTexImage2D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\nstatic inline void qglCopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glCopyTexImage2D(target=%lu, level=%ld, internalFormat=%lu, x=%ld, y=%ld, width=%ld, height=%ld, border=%ld)\\n\", target, level, internalFormat, x, y, width, height, border);\n#endif\n    glCopyTexImage2D(target, level, internalFormat, x, y, width, height, border);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glCopyTexImage2D\");\n#endif\n}\n\n// void glCopyTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\nstatic inline void qglCopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glCopyTexSubImage1D(target=%lu, level=%ld, xoffset=%ld, x=%ld, y=%ld, width=%ld)\\n\", target, level, xoffset, x, y, width);\n#endif\n    glCopyTexSubImage1D(target, level, xoffset, x, y, width);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glCopyTexSubImage1D\");\n#endif\n}\n\n// void glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nstatic inline void qglCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glCopyTexSubImage2D(target=%lu, level=%ld, xoffset=%ld, yoffset=%ld, x=%ld, y=%ld, width=%ld, height=%ld)\\n\", target, level, xoffset, yoffset, x, y, width, height);\n#endif\n    glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glCopyTexSubImage2D\");\n#endif\n}\n\n// void glCullFace (GLenum mode);\nstatic inline void qglCullFace(GLenum mode)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glCullFace(mode=%lu)\\n\", mode);\n#endif\n    glCullFace(mode);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glCullFace\");\n#endif\n}\n\n// void glDeleteLists (GLuint list, GLsizei range);\nstatic inline void qglDeleteLists(GLuint list, GLsizei range)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glDeleteLists(list=%lu, range=%ld)\\n\", list, range);\n#endif\n    glDeleteLists(list, range);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glDeleteLists\");\n#endif\n}\n\n// void glDeleteTextures (GLsizei n, const GLuint *textures);\nstatic inline void qglDeleteTextures(GLsizei n, const GLuint *textures)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glDeleteTextures(n=%ld, textures=%p)\\n\", n, textures);\n#endif\n    glDeleteTextures(n, textures);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glDeleteTextures\");\n#endif\n}\n\n// void glDepthFunc (GLenum func);\nstatic inline void qglDepthFunc(GLenum func)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glDepthFunc(func=%lu)\\n\", func);\n#endif\n    glDepthFunc(func);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glDepthFunc\");\n#endif\n}\n\n// void glDepthMask (GLboolean flag);\nstatic inline void qglDepthMask(GLboolean flag)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glDepthMask(flag=%u)\\n\", flag);\n#endif\n    glDepthMask(flag);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glDepthMask\");\n#endif\n}\n\n// void glDepthRange (GLclampd zNear, GLclampd zFar);\nstatic inline void qglDepthRange(GLclampd zNear, GLclampd zFar)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glDepthRange(zNear=%f, zFar=%f)\\n\", zNear, zFar);\n#endif\n    glDepthRange(zNear, zFar);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glDepthRange\");\n#endif\n}\n\n// void glDisable (GLenum cap);\nstatic inline void qglDisable(GLenum cap)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glDisable(cap=%lu)\\n\", cap);\n#endif\n    glDisable(cap);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glDisable\");\n#endif\n}\n\n// void glDisableClientState (GLenum array);\nstatic inline void qglDisableClientState(GLenum array)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glDisableClientState(array=%lu)\\n\", array);\n#endif\n    glDisableClientState(array);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glDisableClientState\");\n#endif\n}\n\n// void glDrawArrays (GLenum mode, GLint first, GLsizei count);\nstatic inline void qglDrawArrays(GLenum mode, GLint first, GLsizei count)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glDrawArrays(mode=%lu, first=%ld, count=%ld)\\n\", mode, first, count);\n#endif\n    glDrawArrays(mode, first, count);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glDrawArrays\");\n#endif\n}\n\n// void glDrawBuffer (GLenum mode);\nstatic inline void qglDrawBuffer(GLenum mode)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glDrawBuffer(mode=%lu)\\n\", mode);\n#endif\n    glDrawBuffer(mode);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glDrawBuffer\");\n#endif\n}\n\n// void glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);\nstatic inline void qglDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glDrawElements(mode=%lu, count=%ld, type=%lu, indices=%p)\\n\", mode, count, type, indices);\n#endif\n    glDrawElements(mode, count, type, indices);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glDrawElements\");\n#endif\n}\n\n// void glDrawPixels (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nstatic inline void qglDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glDrawPixels(width=%ld, height=%ld, format=%lu, type=%lu, pixels=%p)\\n\", width, height, format, type, pixels);\n#endif\n    glDrawPixels(width, height, format, type, pixels);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glDrawPixels\");\n#endif\n}\n\n// void glEdgeFlag (GLboolean flag);\nstatic inline void qglEdgeFlag(GLboolean flag)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glEdgeFlag(flag=%u)\\n\", flag);\n#endif\n    glEdgeFlag(flag);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glEdgeFlag\");\n#endif\n}\n\n// void glEdgeFlagPointer (GLsizei stride, const GLvoid *pointer);\nstatic inline void qglEdgeFlagPointer(GLsizei stride, const GLvoid *pointer)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glEdgeFlagPointer(stride=%ld, pointer=%p)\\n\", stride, pointer);\n#endif\n    glEdgeFlagPointer(stride, pointer);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glEdgeFlagPointer\");\n#endif\n}\n\n// void glEdgeFlagv (const GLboolean *flag);\nstatic inline void qglEdgeFlagv(const GLboolean *flag)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glEdgeFlagv(flag=%p)\\n\", flag);\n#endif\n    glEdgeFlagv(flag);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glEdgeFlagv\");\n#endif\n}\n\n// void glEnable (GLenum cap);\nstatic inline void qglEnable(GLenum cap)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glEnable(cap=%lu)\\n\", cap);\n#endif\n    glEnable(cap);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glEnable\");\n#endif\n}\n\n// void glEnableClientState (GLenum array);\nstatic inline void qglEnableClientState(GLenum array)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glEnableClientState(array=%lu)\\n\", array);\n#endif\n    glEnableClientState(array);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glEnableClientState\");\n#endif\n}\n\n// void glEnd (void);\nstatic inline void qglEnd(void)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glEnd(void)\\n\");\n#endif\n    glEnd();\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    QGLBeginStarted--;\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glEnd\");\n#endif\n}\n\n// void glEndList (void);\nstatic inline void qglEndList(void)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glEndList(void)\\n\");\n#endif\n    glEndList();\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glEndList\");\n#endif\n}\n\n// void glEvalCoord1d (GLdouble u);\nstatic inline void qglEvalCoord1d(GLdouble u)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glEvalCoord1d(u=%f)\\n\", u);\n#endif\n    glEvalCoord1d(u);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glEvalCoord1d\");\n#endif\n}\n\n// void glEvalCoord1dv (const GLdouble *u);\nstatic inline void qglEvalCoord1dv(const GLdouble *u)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glEvalCoord1dv(u=%p)\\n\", u);\n#endif\n    glEvalCoord1dv(u);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glEvalCoord1dv\");\n#endif\n}\n\n// void glEvalCoord1f (GLfloat u);\nstatic inline void qglEvalCoord1f(GLfloat u)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glEvalCoord1f(u=%f)\\n\", u);\n#endif\n    glEvalCoord1f(u);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glEvalCoord1f\");\n#endif\n}\n\n// void glEvalCoord1fv (const GLfloat *u);\nstatic inline void qglEvalCoord1fv(const GLfloat *u)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glEvalCoord1fv(u=%p)\\n\", u);\n#endif\n    glEvalCoord1fv(u);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glEvalCoord1fv\");\n#endif\n}\n\n// void glEvalCoord2d (GLdouble u, GLdouble v);\nstatic inline void qglEvalCoord2d(GLdouble u, GLdouble v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glEvalCoord2d(u=%f, v=%f)\\n\", u, v);\n#endif\n    glEvalCoord2d(u, v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glEvalCoord2d\");\n#endif\n}\n\n// void glEvalCoord2dv (const GLdouble *u);\nstatic inline void qglEvalCoord2dv(const GLdouble *u)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glEvalCoord2dv(u=%p)\\n\", u);\n#endif\n    glEvalCoord2dv(u);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glEvalCoord2dv\");\n#endif\n}\n\n// void glEvalCoord2f (GLfloat u, GLfloat v);\nstatic inline void qglEvalCoord2f(GLfloat u, GLfloat v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glEvalCoord2f(u=%f, v=%f)\\n\", u, v);\n#endif\n    glEvalCoord2f(u, v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glEvalCoord2f\");\n#endif\n}\n\n// void glEvalCoord2fv (const GLfloat *u);\nstatic inline void qglEvalCoord2fv(const GLfloat *u)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glEvalCoord2fv(u=%p)\\n\", u);\n#endif\n    glEvalCoord2fv(u);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glEvalCoord2fv\");\n#endif\n}\n\n// void glEvalMesh1 (GLenum mode, GLint i1, GLint i2);\nstatic inline void qglEvalMesh1(GLenum mode, GLint i1, GLint i2)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glEvalMesh1(mode=%lu, i1=%ld, i2=%ld)\\n\", mode, i1, i2);\n#endif\n    glEvalMesh1(mode, i1, i2);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glEvalMesh1\");\n#endif\n}\n\n// void glEvalMesh2 (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);\nstatic inline void qglEvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glEvalMesh2(mode=%lu, i1=%ld, i2=%ld, j1=%ld, j2=%ld)\\n\", mode, i1, i2, j1, j2);\n#endif\n    glEvalMesh2(mode, i1, i2, j1, j2);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glEvalMesh2\");\n#endif\n}\n\n// void glEvalPoint1 (GLint i);\nstatic inline void qglEvalPoint1(GLint i)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glEvalPoint1(i=%ld)\\n\", i);\n#endif\n    glEvalPoint1(i);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glEvalPoint1\");\n#endif\n}\n\n// void glEvalPoint2 (GLint i, GLint j);\nstatic inline void qglEvalPoint2(GLint i, GLint j)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glEvalPoint2(i=%ld, j=%ld)\\n\", i, j);\n#endif\n    glEvalPoint2(i, j);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glEvalPoint2\");\n#endif\n}\n\n// void glFeedbackBuffer (GLsizei size, GLenum type, GLfloat *buffer);\nstatic inline void qglFeedbackBuffer(GLsizei size, GLenum type, GLfloat *buffer)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glFeedbackBuffer(size=%ld, type=%lu, buffer=%p)\\n\", size, type, buffer);\n#endif\n    glFeedbackBuffer(size, type, buffer);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glFeedbackBuffer\");\n#endif\n}\n\n// void glFinish (void);\nstatic inline void qglFinish(void)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glFinish(void)\\n\");\n#endif\n    glFinish();\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glFinish\");\n#endif\n}\n\n// void glFlush (void);\nstatic inline void qglFlush(void)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glFlush(void)\\n\");\n#endif\n    glFlush();\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glFlush\");\n#endif\n}\n\n// void glFogf (GLenum pname, GLfloat param);\nstatic inline void qglFogf(GLenum pname, GLfloat param)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glFogf(pname=%lu, param=%f)\\n\", pname, param);\n#endif\n    glFogf(pname, param);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glFogf\");\n#endif\n}\n\n// void glFogfv (GLenum pname, const GLfloat *params);\nstatic inline void qglFogfv(GLenum pname, const GLfloat *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glFogfv(pname=%lu, params=%p)\\n\", pname, params);\n#endif\n    glFogfv(pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glFogfv\");\n#endif\n}\n\n// void glFogi (GLenum pname, GLint param);\nstatic inline void qglFogi(GLenum pname, GLint param)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glFogi(pname=%lu, param=%ld)\\n\", pname, param);\n#endif\n    glFogi(pname, param);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glFogi\");\n#endif\n}\n\n// void glFogiv (GLenum pname, const GLint *params);\nstatic inline void qglFogiv(GLenum pname, const GLint *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glFogiv(pname=%lu, params=%p)\\n\", pname, params);\n#endif\n    glFogiv(pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glFogiv\");\n#endif\n}\n\n// void glFrontFace (GLenum mode);\nstatic inline void qglFrontFace(GLenum mode)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glFrontFace(mode=%lu)\\n\", mode);\n#endif\n    glFrontFace(mode);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glFrontFace\");\n#endif\n}\n\n// void glFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nstatic inline void qglFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glFrustum(left=%f, right=%f, bottom=%f, top=%f, zNear=%f, zFar=%f)\\n\", left, right, bottom, top, zNear, zFar);\n#endif\n    glFrustum(left, right, bottom, top, zNear, zFar);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glFrustum\");\n#endif\n}\n\n// GLuint glGenLists (GLsizei range);\nstatic inline GLuint qglGenLists(GLsizei range)\n{\n    GLuint returnValue;\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGenLists(range=%ld)\\n\", range);\n#endif\n    returnValue = glGenLists(range);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGenLists\");\n#endif\n    return returnValue;\n}\n\n// void glGenTextures (GLsizei n, GLuint *textures);\nstatic inline void qglGenTextures(GLsizei n, GLuint *textures)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGenTextures(n=%ld, textures=%p)\\n\", n, textures);\n#endif\n    glGenTextures(n, textures);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGenTextures\");\n#endif\n}\n\n// void glGetBooleanv (GLenum pname, GLboolean *params);\nstatic inline void qglGetBooleanv(GLenum pname, GLboolean *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetBooleanv(pname=%lu, params=%p)\\n\", pname, params);\n#endif\n    glGetBooleanv(pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetBooleanv\");\n#endif\n}\n\n// void glGetClipPlane (GLenum plane, GLdouble *equation);\nstatic inline void qglGetClipPlane(GLenum plane, GLdouble *equation)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetClipPlane(plane=%lu, equation=%p)\\n\", plane, equation);\n#endif\n    glGetClipPlane(plane, equation);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetClipPlane\");\n#endif\n}\n\n// void glGetDoublev (GLenum pname, GLdouble *params);\nstatic inline void qglGetDoublev(GLenum pname, GLdouble *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetDoublev(pname=%lu, params=%p)\\n\", pname, params);\n#endif\n    glGetDoublev(pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetDoublev\");\n#endif\n}\n\n// GLenum glGetError (void);\nstatic inline GLenum qglGetError(void)\n{\n    GLenum returnValue;\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetError(void)\\n\");\n#endif\n    returnValue = glGetError();\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetError\");\n#endif\n    return returnValue;\n}\n\n// void glGetFloatv (GLenum pname, GLfloat *params);\nstatic inline void qglGetFloatv(GLenum pname, GLfloat *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetFloatv(pname=%lu, params=%p)\\n\", pname, params);\n#endif\n    glGetFloatv(pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetFloatv\");\n#endif\n}\n\n// void glGetIntegerv (GLenum pname, GLint *params);\nstatic inline void qglGetIntegerv(GLenum pname, GLint *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetIntegerv(pname=%lu, params=%p)\\n\", pname, params);\n#endif\n    glGetIntegerv(pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetIntegerv\");\n#endif\n}\n\n// void glGetLightfv (GLenum light, GLenum pname, GLfloat *params);\nstatic inline void qglGetLightfv(GLenum light, GLenum pname, GLfloat *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetLightfv(light=%lu, pname=%lu, params=%p)\\n\", light, pname, params);\n#endif\n    glGetLightfv(light, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetLightfv\");\n#endif\n}\n\n// void glGetLightiv (GLenum light, GLenum pname, GLint *params);\nstatic inline void qglGetLightiv(GLenum light, GLenum pname, GLint *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetLightiv(light=%lu, pname=%lu, params=%p)\\n\", light, pname, params);\n#endif\n    glGetLightiv(light, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetLightiv\");\n#endif\n}\n\n// void glGetMapdv (GLenum target, GLenum query, GLdouble *v);\nstatic inline void qglGetMapdv(GLenum target, GLenum query, GLdouble *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetMapdv(target=%lu, query=%lu, v=%p)\\n\", target, query, v);\n#endif\n    glGetMapdv(target, query, v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetMapdv\");\n#endif\n}\n\n// void glGetMapfv (GLenum target, GLenum query, GLfloat *v);\nstatic inline void qglGetMapfv(GLenum target, GLenum query, GLfloat *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetMapfv(target=%lu, query=%lu, v=%p)\\n\", target, query, v);\n#endif\n    glGetMapfv(target, query, v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetMapfv\");\n#endif\n}\n\n// void glGetMapiv (GLenum target, GLenum query, GLint *v);\nstatic inline void qglGetMapiv(GLenum target, GLenum query, GLint *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetMapiv(target=%lu, query=%lu, v=%p)\\n\", target, query, v);\n#endif\n    glGetMapiv(target, query, v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetMapiv\");\n#endif\n}\n\n// void glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params);\nstatic inline void qglGetMaterialfv(GLenum face, GLenum pname, GLfloat *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetMaterialfv(face=%lu, pname=%lu, params=%p)\\n\", face, pname, params);\n#endif\n    glGetMaterialfv(face, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetMaterialfv\");\n#endif\n}\n\n// void glGetMaterialiv (GLenum face, GLenum pname, GLint *params);\nstatic inline void qglGetMaterialiv(GLenum face, GLenum pname, GLint *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetMaterialiv(face=%lu, pname=%lu, params=%p)\\n\", face, pname, params);\n#endif\n    glGetMaterialiv(face, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetMaterialiv\");\n#endif\n}\n\n// void glGetPixelMapfv (GLenum map, GLfloat *values);\nstatic inline void qglGetPixelMapfv(GLenum map, GLfloat *values)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetPixelMapfv(map=%lu, values=%p)\\n\", map, values);\n#endif\n    glGetPixelMapfv(map, values);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetPixelMapfv\");\n#endif\n}\n\n// void glGetPixelMapuiv (GLenum map, GLuint *values);\nstatic inline void qglGetPixelMapuiv(GLenum map, GLuint *values)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetPixelMapuiv(map=%lu, values=%p)\\n\", map, values);\n#endif\n    glGetPixelMapuiv(map, values);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetPixelMapuiv\");\n#endif\n}\n\n// void glGetPixelMapusv (GLenum map, GLushort *values);\nstatic inline void qglGetPixelMapusv(GLenum map, GLushort *values)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetPixelMapusv(map=%lu, values=%p)\\n\", map, values);\n#endif\n    glGetPixelMapusv(map, values);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetPixelMapusv\");\n#endif\n}\n\n// void glGetPointerv (GLenum pname, GLvoid* *params);\nstatic inline void qglGetPointerv(GLenum pname, GLvoid* *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetPointerv(pname=%lu, params=%p)\\n\", pname, params);\n#endif\n    glGetPointerv(pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetPointerv\");\n#endif\n}\n\n// void glGetPolygonStipple (GLubyte *mask);\nstatic inline void qglGetPolygonStipple(GLubyte *mask)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetPolygonStipple(mask=%p)\\n\", mask);\n#endif\n    glGetPolygonStipple(mask);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetPolygonStipple\");\n#endif\n}\n\n// const GLubyte * glGetString (GLenum name);\nstatic inline const GLubyte * qglGetString(GLenum name)\n{\n    const GLubyte * returnValue;\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetString(name=%lu)\\n\", name);\n#endif\n    returnValue = glGetString(name);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetString\");\n#endif\n    return returnValue;\n}\n\n// void glGetTexEnvfv (GLenum target, GLenum pname, GLfloat *params);\nstatic inline void qglGetTexEnvfv(GLenum target, GLenum pname, GLfloat *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetTexEnvfv(target=%lu, pname=%lu, params=%p)\\n\", target, pname, params);\n#endif\n    glGetTexEnvfv(target, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetTexEnvfv\");\n#endif\n}\n\n// void glGetTexEnviv (GLenum target, GLenum pname, GLint *params);\nstatic inline void qglGetTexEnviv(GLenum target, GLenum pname, GLint *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetTexEnviv(target=%lu, pname=%lu, params=%p)\\n\", target, pname, params);\n#endif\n    glGetTexEnviv(target, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetTexEnviv\");\n#endif\n}\n\n// void glGetTexGendv (GLenum coord, GLenum pname, GLdouble *params);\nstatic inline void qglGetTexGendv(GLenum coord, GLenum pname, GLdouble *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetTexGendv(coord=%lu, pname=%lu, params=%p)\\n\", coord, pname, params);\n#endif\n    glGetTexGendv(coord, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetTexGendv\");\n#endif\n}\n\n// void glGetTexGenfv (GLenum coord, GLenum pname, GLfloat *params);\nstatic inline void qglGetTexGenfv(GLenum coord, GLenum pname, GLfloat *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetTexGenfv(coord=%lu, pname=%lu, params=%p)\\n\", coord, pname, params);\n#endif\n    glGetTexGenfv(coord, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetTexGenfv\");\n#endif\n}\n\n// void glGetTexGeniv (GLenum coord, GLenum pname, GLint *params);\nstatic inline void qglGetTexGeniv(GLenum coord, GLenum pname, GLint *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetTexGeniv(coord=%lu, pname=%lu, params=%p)\\n\", coord, pname, params);\n#endif\n    glGetTexGeniv(coord, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetTexGeniv\");\n#endif\n}\n\n// void glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);\nstatic inline void qglGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetTexImage(target=%lu, level=%ld, format=%lu, type=%lu, pixels=%p)\\n\", target, level, format, type, pixels);\n#endif\n    glGetTexImage(target, level, format, type, pixels);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetTexImage\");\n#endif\n}\n\n// void glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params);\nstatic inline void qglGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetTexLevelParameterfv(target=%lu, level=%ld, pname=%lu, params=%p)\\n\", target, level, pname, params);\n#endif\n    glGetTexLevelParameterfv(target, level, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetTexLevelParameterfv\");\n#endif\n}\n\n// void glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params);\nstatic inline void qglGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetTexLevelParameteriv(target=%lu, level=%ld, pname=%lu, params=%p)\\n\", target, level, pname, params);\n#endif\n    glGetTexLevelParameteriv(target, level, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetTexLevelParameteriv\");\n#endif\n}\n\n// void glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params);\nstatic inline void qglGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetTexParameterfv(target=%lu, pname=%lu, params=%p)\\n\", target, pname, params);\n#endif\n    glGetTexParameterfv(target, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetTexParameterfv\");\n#endif\n}\n\n// void glGetTexParameteriv (GLenum target, GLenum pname, GLint *params);\nstatic inline void qglGetTexParameteriv(GLenum target, GLenum pname, GLint *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glGetTexParameteriv(target=%lu, pname=%lu, params=%p)\\n\", target, pname, params);\n#endif\n    glGetTexParameteriv(target, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glGetTexParameteriv\");\n#endif\n}\n\n// void glHint (GLenum target, GLenum mode);\nstatic inline void qglHint(GLenum target, GLenum mode)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glHint(target=%lu, mode=%lu)\\n\", target, mode);\n#endif\n    glHint(target, mode);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glHint\");\n#endif\n}\n\n// void glIndexMask (GLuint mask);\nstatic inline void qglIndexMask(GLuint mask)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glIndexMask(mask=%lu)\\n\", mask);\n#endif\n    glIndexMask(mask);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glIndexMask\");\n#endif\n}\n\n// void glIndexPointer (GLenum type, GLsizei stride, const GLvoid *pointer);\nstatic inline void qglIndexPointer(GLenum type, GLsizei stride, const GLvoid *pointer)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glIndexPointer(type=%lu, stride=%ld, pointer=%p)\\n\", type, stride, pointer);\n#endif\n    glIndexPointer(type, stride, pointer);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glIndexPointer\");\n#endif\n}\n\n// void glIndexd (GLdouble c);\nstatic inline void qglIndexd(GLdouble c)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glIndexd(c=%f)\\n\", c);\n#endif\n    glIndexd(c);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glIndexd\");\n#endif\n}\n\n// void glIndexdv (const GLdouble *c);\nstatic inline void qglIndexdv(const GLdouble *c)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glIndexdv(c=%p)\\n\", c);\n#endif\n    glIndexdv(c);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glIndexdv\");\n#endif\n}\n\n// void glIndexf (GLfloat c);\nstatic inline void qglIndexf(GLfloat c)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glIndexf(c=%f)\\n\", c);\n#endif\n    glIndexf(c);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glIndexf\");\n#endif\n}\n\n// void glIndexfv (const GLfloat *c);\nstatic inline void qglIndexfv(const GLfloat *c)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glIndexfv(c=%p)\\n\", c);\n#endif\n    glIndexfv(c);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glIndexfv\");\n#endif\n}\n\n// void glIndexi (GLint c);\nstatic inline void qglIndexi(GLint c)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glIndexi(c=%ld)\\n\", c);\n#endif\n    glIndexi(c);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glIndexi\");\n#endif\n}\n\n// void glIndexiv (const GLint *c);\nstatic inline void qglIndexiv(const GLint *c)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glIndexiv(c=%p)\\n\", c);\n#endif\n    glIndexiv(c);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glIndexiv\");\n#endif\n}\n\n// void glIndexs (GLshort c);\nstatic inline void qglIndexs(GLshort c)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glIndexs(c=%d)\\n\", c);\n#endif\n    glIndexs(c);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glIndexs\");\n#endif\n}\n\n// void glIndexsv (const GLshort *c);\nstatic inline void qglIndexsv(const GLshort *c)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glIndexsv(c=%p)\\n\", c);\n#endif\n    glIndexsv(c);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glIndexsv\");\n#endif\n}\n\n// void glIndexub (GLubyte c);\nstatic inline void qglIndexub(GLubyte c)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glIndexub(c=%u)\\n\", c);\n#endif\n    glIndexub(c);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glIndexub\");\n#endif\n}\n\n// void glIndexubv (const GLubyte *c);\nstatic inline void qglIndexubv(const GLubyte *c)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glIndexubv(c=%p)\\n\", c);\n#endif\n    glIndexubv(c);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glIndexubv\");\n#endif\n}\n\n// void glInitNames (void);\nstatic inline void qglInitNames(void)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glInitNames(void)\\n\");\n#endif\n    glInitNames();\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glInitNames\");\n#endif\n}\n\n// void glInterleavedArrays (GLenum format, GLsizei stride, const GLvoid *pointer);\nstatic inline void qglInterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glInterleavedArrays(format=%lu, stride=%ld, pointer=%p)\\n\", format, stride, pointer);\n#endif\n    glInterleavedArrays(format, stride, pointer);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glInterleavedArrays\");\n#endif\n}\n\n// GLboolean glIsEnabled (GLenum cap);\nstatic inline GLboolean qglIsEnabled(GLenum cap)\n{\n    GLboolean returnValue;\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glIsEnabled(cap=%lu)\\n\", cap);\n#endif\n    returnValue = glIsEnabled(cap);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glIsEnabled\");\n#endif\n    return returnValue;\n}\n\n// GLboolean glIsList (GLuint list);\nstatic inline GLboolean qglIsList(GLuint list)\n{\n    GLboolean returnValue;\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glIsList(list=%lu)\\n\", list);\n#endif\n    returnValue = glIsList(list);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glIsList\");\n#endif\n    return returnValue;\n}\n\n// GLboolean glIsTexture (GLuint texture);\nstatic inline GLboolean qglIsTexture(GLuint texture)\n{\n    GLboolean returnValue;\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glIsTexture(texture=%lu)\\n\", texture);\n#endif\n    returnValue = glIsTexture(texture);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glIsTexture\");\n#endif\n    return returnValue;\n}\n\n// void glLightModelf (GLenum pname, GLfloat param);\nstatic inline void qglLightModelf(GLenum pname, GLfloat param)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glLightModelf(pname=%lu, param=%f)\\n\", pname, param);\n#endif\n    glLightModelf(pname, param);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glLightModelf\");\n#endif\n}\n\n// void glLightModelfv (GLenum pname, const GLfloat *params);\nstatic inline void qglLightModelfv(GLenum pname, const GLfloat *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glLightModelfv(pname=%lu, params=%p)\\n\", pname, params);\n#endif\n    glLightModelfv(pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glLightModelfv\");\n#endif\n}\n\n// void glLightModeli (GLenum pname, GLint param);\nstatic inline void qglLightModeli(GLenum pname, GLint param)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glLightModeli(pname=%lu, param=%ld)\\n\", pname, param);\n#endif\n    glLightModeli(pname, param);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glLightModeli\");\n#endif\n}\n\n// void glLightModeliv (GLenum pname, const GLint *params);\nstatic inline void qglLightModeliv(GLenum pname, const GLint *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glLightModeliv(pname=%lu, params=%p)\\n\", pname, params);\n#endif\n    glLightModeliv(pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glLightModeliv\");\n#endif\n}\n\n// void glLightf (GLenum light, GLenum pname, GLfloat param);\nstatic inline void qglLightf(GLenum light, GLenum pname, GLfloat param)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glLightf(light=%lu, pname=%lu, param=%f)\\n\", light, pname, param);\n#endif\n    glLightf(light, pname, param);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glLightf\");\n#endif\n}\n\n// void glLightfv (GLenum light, GLenum pname, const GLfloat *params);\nstatic inline void qglLightfv(GLenum light, GLenum pname, const GLfloat *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glLightfv(light=%lu, pname=%lu, params=%p)\\n\", light, pname, params);\n#endif\n    glLightfv(light, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glLightfv\");\n#endif\n}\n\n// void glLighti (GLenum light, GLenum pname, GLint param);\nstatic inline void qglLighti(GLenum light, GLenum pname, GLint param)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glLighti(light=%lu, pname=%lu, param=%ld)\\n\", light, pname, param);\n#endif\n    glLighti(light, pname, param);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glLighti\");\n#endif\n}\n\n// void glLightiv (GLenum light, GLenum pname, const GLint *params);\nstatic inline void qglLightiv(GLenum light, GLenum pname, const GLint *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glLightiv(light=%lu, pname=%lu, params=%p)\\n\", light, pname, params);\n#endif\n    glLightiv(light, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glLightiv\");\n#endif\n}\n\n// void glLineStipple (GLint factor, GLushort pattern);\nstatic inline void qglLineStipple(GLint factor, GLushort pattern)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glLineStipple(factor=%ld, pattern=%u)\\n\", factor, pattern);\n#endif\n    glLineStipple(factor, pattern);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glLineStipple\");\n#endif\n}\n\n// void glLineWidth (GLfloat width);\nstatic inline void qglLineWidth(GLfloat width)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glLineWidth(width=%f)\\n\", width);\n#endif\n    glLineWidth(width);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glLineWidth\");\n#endif\n}\n\n// void glListBase (GLuint base);\nstatic inline void qglListBase(GLuint base)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glListBase(base=%lu)\\n\", base);\n#endif\n    glListBase(base);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glListBase\");\n#endif\n}\n\n// void glLoadIdentity (void);\nstatic inline void qglLoadIdentity(void)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glLoadIdentity(void)\\n\");\n#endif\n    glLoadIdentity();\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glLoadIdentity\");\n#endif\n}\n\n// void glLoadMatrixd (const GLdouble *m);\nstatic inline void qglLoadMatrixd(const GLdouble *m)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glLoadMatrixd(m=%p)\\n\", m);\n#endif\n    glLoadMatrixd(m);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glLoadMatrixd\");\n#endif\n}\n\n// void glLoadMatrixf (const GLfloat *m);\nstatic inline void qglLoadMatrixf(const GLfloat *m)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glLoadMatrixf(m=%p)\\n\", m);\n#endif\n    glLoadMatrixf(m);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glLoadMatrixf\");\n#endif\n}\n\n// void glLoadName (GLuint name);\nstatic inline void qglLoadName(GLuint name)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glLoadName(name=%lu)\\n\", name);\n#endif\n    glLoadName(name);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glLoadName\");\n#endif\n}\n\n// void glLogicOp (GLenum opcode);\nstatic inline void qglLogicOp(GLenum opcode)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glLogicOp(opcode=%lu)\\n\", opcode);\n#endif\n    glLogicOp(opcode);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glLogicOp\");\n#endif\n}\n\n// void glMap1d (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);\nstatic inline void qglMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glMap1d(target=%lu, u1=%f, u2=%f, stride=%ld, order=%ld, points=%p)\\n\", target, u1, u2, stride, order, points);\n#endif\n    glMap1d(target, u1, u2, stride, order, points);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glMap1d\");\n#endif\n}\n\n// void glMap1f (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);\nstatic inline void qglMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glMap1f(target=%lu, u1=%f, u2=%f, stride=%ld, order=%ld, points=%p)\\n\", target, u1, u2, stride, order, points);\n#endif\n    glMap1f(target, u1, u2, stride, order, points);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glMap1f\");\n#endif\n}\n\n// void glMap2d (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);\nstatic inline void qglMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glMap2d(target=%lu, u1=%f, u2=%f, ustride=%ld, uorder=%ld, v1=%f, v2=%f, vstride=%ld, vorder=%ld, points=%p)\\n\", target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);\n#endif\n    glMap2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glMap2d\");\n#endif\n}\n\n// void glMap2f (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);\nstatic inline void qglMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glMap2f(target=%lu, u1=%f, u2=%f, ustride=%ld, uorder=%ld, v1=%f, v2=%f, vstride=%ld, vorder=%ld, points=%p)\\n\", target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);\n#endif\n    glMap2f(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glMap2f\");\n#endif\n}\n\n// void glMapGrid1d (GLint un, GLdouble u1, GLdouble u2);\nstatic inline void qglMapGrid1d(GLint un, GLdouble u1, GLdouble u2)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glMapGrid1d(un=%ld, u1=%f, u2=%f)\\n\", un, u1, u2);\n#endif\n    glMapGrid1d(un, u1, u2);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glMapGrid1d\");\n#endif\n}\n\n// void glMapGrid1f (GLint un, GLfloat u1, GLfloat u2);\nstatic inline void qglMapGrid1f(GLint un, GLfloat u1, GLfloat u2)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glMapGrid1f(un=%ld, u1=%f, u2=%f)\\n\", un, u1, u2);\n#endif\n    glMapGrid1f(un, u1, u2);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glMapGrid1f\");\n#endif\n}\n\n// void glMapGrid2d (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);\nstatic inline void qglMapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glMapGrid2d(un=%ld, u1=%f, u2=%f, vn=%ld, v1=%f, v2=%f)\\n\", un, u1, u2, vn, v1, v2);\n#endif\n    glMapGrid2d(un, u1, u2, vn, v1, v2);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glMapGrid2d\");\n#endif\n}\n\n// void glMapGrid2f (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);\nstatic inline void qglMapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glMapGrid2f(un=%ld, u1=%f, u2=%f, vn=%ld, v1=%f, v2=%f)\\n\", un, u1, u2, vn, v1, v2);\n#endif\n    glMapGrid2f(un, u1, u2, vn, v1, v2);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glMapGrid2f\");\n#endif\n}\n\n// void glMaterialf (GLenum face, GLenum pname, GLfloat param);\nstatic inline void qglMaterialf(GLenum face, GLenum pname, GLfloat param)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glMaterialf(face=%lu, pname=%lu, param=%f)\\n\", face, pname, param);\n#endif\n    glMaterialf(face, pname, param);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glMaterialf\");\n#endif\n}\n\n// void glMaterialfv (GLenum face, GLenum pname, const GLfloat *params);\nstatic inline void qglMaterialfv(GLenum face, GLenum pname, const GLfloat *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glMaterialfv(face=%lu, pname=%lu, params=%p)\\n\", face, pname, params);\n#endif\n    glMaterialfv(face, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glMaterialfv\");\n#endif\n}\n\n// void glMateriali (GLenum face, GLenum pname, GLint param);\nstatic inline void qglMateriali(GLenum face, GLenum pname, GLint param)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glMateriali(face=%lu, pname=%lu, param=%ld)\\n\", face, pname, param);\n#endif\n    glMateriali(face, pname, param);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glMateriali\");\n#endif\n}\n\n// void glMaterialiv (GLenum face, GLenum pname, const GLint *params);\nstatic inline void qglMaterialiv(GLenum face, GLenum pname, const GLint *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glMaterialiv(face=%lu, pname=%lu, params=%p)\\n\", face, pname, params);\n#endif\n    glMaterialiv(face, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glMaterialiv\");\n#endif\n}\n\n// void glMatrixMode (GLenum mode);\nstatic inline void qglMatrixMode(GLenum mode)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glMatrixMode(mode=%lu)\\n\", mode);\n#endif\n    glMatrixMode(mode);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glMatrixMode\");\n#endif\n}\n\n// void glMultMatrixd (const GLdouble *m);\nstatic inline void qglMultMatrixd(const GLdouble *m)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glMultMatrixd(m=%p)\\n\", m);\n#endif\n    glMultMatrixd(m);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glMultMatrixd\");\n#endif\n}\n\n// void glMultMatrixf (const GLfloat *m);\nstatic inline void qglMultMatrixf(const GLfloat *m)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glMultMatrixf(m=%p)\\n\", m);\n#endif\n    glMultMatrixf(m);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glMultMatrixf\");\n#endif\n}\n\n// void glNewList (GLuint list, GLenum mode);\nstatic inline void qglNewList(GLuint list, GLenum mode)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glNewList(list=%lu, mode=%lu)\\n\", list, mode);\n#endif\n    glNewList(list, mode);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glNewList\");\n#endif\n}\n\n// void glNormal3b (GLbyte nx, GLbyte ny, GLbyte nz);\nstatic inline void qglNormal3b(GLbyte nx, GLbyte ny, GLbyte nz)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glNormal3b(nx=%d, ny=%d, nz=%d)\\n\", nx, ny, nz);\n#endif\n    glNormal3b(nx, ny, nz);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glNormal3b\");\n#endif\n}\n\n// void glNormal3bv (const GLbyte *v);\nstatic inline void qglNormal3bv(const GLbyte *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glNormal3bv(v=%p)\\n\", v);\n#endif\n    glNormal3bv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glNormal3bv\");\n#endif\n}\n\n// void glNormal3d (GLdouble nx, GLdouble ny, GLdouble nz);\nstatic inline void qglNormal3d(GLdouble nx, GLdouble ny, GLdouble nz)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glNormal3d(nx=%f, ny=%f, nz=%f)\\n\", nx, ny, nz);\n#endif\n    glNormal3d(nx, ny, nz);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glNormal3d\");\n#endif\n}\n\n// void glNormal3dv (const GLdouble *v);\nstatic inline void qglNormal3dv(const GLdouble *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glNormal3dv(v=%p)\\n\", v);\n#endif\n    glNormal3dv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glNormal3dv\");\n#endif\n}\n\n// void glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz);\nstatic inline void qglNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glNormal3f(nx=%f, ny=%f, nz=%f)\\n\", nx, ny, nz);\n#endif\n    glNormal3f(nx, ny, nz);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glNormal3f\");\n#endif\n}\n\n// void glNormal3fv (const GLfloat *v);\nstatic inline void qglNormal3fv(const GLfloat *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glNormal3fv(v=%p)\\n\", v);\n#endif\n    glNormal3fv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glNormal3fv\");\n#endif\n}\n\n// void glNormal3i (GLint nx, GLint ny, GLint nz);\nstatic inline void qglNormal3i(GLint nx, GLint ny, GLint nz)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glNormal3i(nx=%ld, ny=%ld, nz=%ld)\\n\", nx, ny, nz);\n#endif\n    glNormal3i(nx, ny, nz);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glNormal3i\");\n#endif\n}\n\n// void glNormal3iv (const GLint *v);\nstatic inline void qglNormal3iv(const GLint *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glNormal3iv(v=%p)\\n\", v);\n#endif\n    glNormal3iv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glNormal3iv\");\n#endif\n}\n\n// void glNormal3s (GLshort nx, GLshort ny, GLshort nz);\nstatic inline void qglNormal3s(GLshort nx, GLshort ny, GLshort nz)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glNormal3s(nx=%d, ny=%d, nz=%d)\\n\", nx, ny, nz);\n#endif\n    glNormal3s(nx, ny, nz);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glNormal3s\");\n#endif\n}\n\n// void glNormal3sv (const GLshort *v);\nstatic inline void qglNormal3sv(const GLshort *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glNormal3sv(v=%p)\\n\", v);\n#endif\n    glNormal3sv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glNormal3sv\");\n#endif\n}\n\n// void glNormalPointer (GLenum type, GLsizei stride, const GLvoid *pointer);\nstatic inline void qglNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glNormalPointer(type=%lu, stride=%ld, pointer=%p)\\n\", type, stride, pointer);\n#endif\n    glNormalPointer(type, stride, pointer);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glNormalPointer\");\n#endif\n}\n\n// void glOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nstatic inline void qglOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glOrtho(left=%f, right=%f, bottom=%f, top=%f, zNear=%f, zFar=%f)\\n\", left, right, bottom, top, zNear, zFar);\n#endif\n    glOrtho(left, right, bottom, top, zNear, zFar);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glOrtho\");\n#endif\n}\n\n// void glPassThrough (GLfloat token);\nstatic inline void qglPassThrough(GLfloat token)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPassThrough(token=%f)\\n\", token);\n#endif\n    glPassThrough(token);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPassThrough\");\n#endif\n}\n\n// void glPixelMapfv (GLenum map, GLsizei mapsize, const GLfloat *values);\nstatic inline void qglPixelMapfv(GLenum map, GLsizei mapsize, const GLfloat *values)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPixelMapfv(map=%lu, mapsize=%ld, values=%p)\\n\", map, mapsize, values);\n#endif\n    glPixelMapfv(map, mapsize, values);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPixelMapfv\");\n#endif\n}\n\n// void glPixelMapuiv (GLenum map, GLsizei mapsize, const GLuint *values);\nstatic inline void qglPixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPixelMapuiv(map=%lu, mapsize=%ld, values=%p)\\n\", map, mapsize, values);\n#endif\n    glPixelMapuiv(map, mapsize, values);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPixelMapuiv\");\n#endif\n}\n\n// void glPixelMapusv (GLenum map, GLsizei mapsize, const GLushort *values);\nstatic inline void qglPixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPixelMapusv(map=%lu, mapsize=%ld, values=%p)\\n\", map, mapsize, values);\n#endif\n    glPixelMapusv(map, mapsize, values);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPixelMapusv\");\n#endif\n}\n\n// void glPixelStoref (GLenum pname, GLfloat param);\nstatic inline void qglPixelStoref(GLenum pname, GLfloat param)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPixelStoref(pname=%lu, param=%f)\\n\", pname, param);\n#endif\n    glPixelStoref(pname, param);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPixelStoref\");\n#endif\n}\n\n// void glPixelStorei (GLenum pname, GLint param);\nstatic inline void qglPixelStorei(GLenum pname, GLint param)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPixelStorei(pname=%lu, param=%ld)\\n\", pname, param);\n#endif\n    glPixelStorei(pname, param);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPixelStorei\");\n#endif\n}\n\n// void glPixelTransferf (GLenum pname, GLfloat param);\nstatic inline void qglPixelTransferf(GLenum pname, GLfloat param)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPixelTransferf(pname=%lu, param=%f)\\n\", pname, param);\n#endif\n    glPixelTransferf(pname, param);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPixelTransferf\");\n#endif\n}\n\n// void glPixelTransferi (GLenum pname, GLint param);\nstatic inline void qglPixelTransferi(GLenum pname, GLint param)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPixelTransferi(pname=%lu, param=%ld)\\n\", pname, param);\n#endif\n    glPixelTransferi(pname, param);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPixelTransferi\");\n#endif\n}\n\n// void glPixelZoom (GLfloat xfactor, GLfloat yfactor);\nstatic inline void qglPixelZoom(GLfloat xfactor, GLfloat yfactor)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPixelZoom(xfactor=%f, yfactor=%f)\\n\", xfactor, yfactor);\n#endif\n    glPixelZoom(xfactor, yfactor);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPixelZoom\");\n#endif\n}\n\n// void glPointSize (GLfloat size);\nstatic inline void qglPointSize(GLfloat size)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPointSize(size=%f)\\n\", size);\n#endif\n    glPointSize(size);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPointSize\");\n#endif\n}\n\n// void glPolygonMode (GLenum face, GLenum mode);\nstatic inline void qglPolygonMode(GLenum face, GLenum mode)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPolygonMode(face=%lu, mode=%lu)\\n\", face, mode);\n#endif\n    glPolygonMode(face, mode);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPolygonMode\");\n#endif\n}\n\n// void glPolygonOffset (GLfloat factor, GLfloat units);\nstatic inline void qglPolygonOffset(GLfloat factor, GLfloat units)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPolygonOffset(factor=%f, units=%f)\\n\", factor, units);\n#endif\n    glPolygonOffset(factor, units);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPolygonOffset\");\n#endif\n}\n\n// void glPolygonStipple (const GLubyte *mask);\nstatic inline void qglPolygonStipple(const GLubyte *mask)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPolygonStipple(mask=%p)\\n\", mask);\n#endif\n    glPolygonStipple(mask);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPolygonStipple\");\n#endif\n}\n\n// void glPopAttrib (void);\nstatic inline void qglPopAttrib(void)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPopAttrib(void)\\n\");\n#endif\n    glPopAttrib();\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPopAttrib\");\n#endif\n}\n\n// void glPopClientAttrib (void);\nstatic inline void qglPopClientAttrib(void)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPopClientAttrib(void)\\n\");\n#endif\n    glPopClientAttrib();\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPopClientAttrib\");\n#endif\n}\n\n// void glPopMatrix (void);\nstatic inline void qglPopMatrix(void)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPopMatrix(void)\\n\");\n#endif\n    glPopMatrix();\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPopMatrix\");\n#endif\n}\n\n// void glPopName (void);\nstatic inline void qglPopName(void)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPopName(void)\\n\");\n#endif\n    glPopName();\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPopName\");\n#endif\n}\n\n// void glPrioritizeTextures (GLsizei n, const GLuint *textures, const GLclampf *priorities);\nstatic inline void qglPrioritizeTextures(GLsizei n, const GLuint *textures, const GLclampf *priorities)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPrioritizeTextures(n=%ld, textures=%p, priorities=%p)\\n\", n, textures, priorities);\n#endif\n    glPrioritizeTextures(n, textures, priorities);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPrioritizeTextures\");\n#endif\n}\n\n// void glPushAttrib (GLbitfield mask);\nstatic inline void qglPushAttrib(GLbitfield mask)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPushAttrib(mask=%lu)\\n\", mask);\n#endif\n    glPushAttrib(mask);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPushAttrib\");\n#endif\n}\n\n// void glPushClientAttrib (GLbitfield mask);\nstatic inline void qglPushClientAttrib(GLbitfield mask)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPushClientAttrib(mask=%lu)\\n\", mask);\n#endif\n    glPushClientAttrib(mask);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPushClientAttrib\");\n#endif\n}\n\n// void glPushMatrix (void);\nstatic inline void qglPushMatrix(void)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPushMatrix(void)\\n\");\n#endif\n    glPushMatrix();\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPushMatrix\");\n#endif\n}\n\n// void glPushName (GLuint name);\nstatic inline void qglPushName(GLuint name)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glPushName(name=%lu)\\n\", name);\n#endif\n    glPushName(name);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glPushName\");\n#endif\n}\n\n// void glRasterPos2d (GLdouble x, GLdouble y);\nstatic inline void qglRasterPos2d(GLdouble x, GLdouble y)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos2d(x=%f, y=%f)\\n\", x, y);\n#endif\n    glRasterPos2d(x, y);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos2d\");\n#endif\n}\n\n// void glRasterPos2dv (const GLdouble *v);\nstatic inline void qglRasterPos2dv(const GLdouble *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos2dv(v=%p)\\n\", v);\n#endif\n    glRasterPos2dv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos2dv\");\n#endif\n}\n\n// void glRasterPos2f (GLfloat x, GLfloat y);\nstatic inline void qglRasterPos2f(GLfloat x, GLfloat y)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos2f(x=%f, y=%f)\\n\", x, y);\n#endif\n    glRasterPos2f(x, y);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos2f\");\n#endif\n}\n\n// void glRasterPos2fv (const GLfloat *v);\nstatic inline void qglRasterPos2fv(const GLfloat *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos2fv(v=%p)\\n\", v);\n#endif\n    glRasterPos2fv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos2fv\");\n#endif\n}\n\n// void glRasterPos2i (GLint x, GLint y);\nstatic inline void qglRasterPos2i(GLint x, GLint y)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos2i(x=%ld, y=%ld)\\n\", x, y);\n#endif\n    glRasterPos2i(x, y);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos2i\");\n#endif\n}\n\n// void glRasterPos2iv (const GLint *v);\nstatic inline void qglRasterPos2iv(const GLint *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos2iv(v=%p)\\n\", v);\n#endif\n    glRasterPos2iv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos2iv\");\n#endif\n}\n\n// void glRasterPos2s (GLshort x, GLshort y);\nstatic inline void qglRasterPos2s(GLshort x, GLshort y)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos2s(x=%d, y=%d)\\n\", x, y);\n#endif\n    glRasterPos2s(x, y);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos2s\");\n#endif\n}\n\n// void glRasterPos2sv (const GLshort *v);\nstatic inline void qglRasterPos2sv(const GLshort *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos2sv(v=%p)\\n\", v);\n#endif\n    glRasterPos2sv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos2sv\");\n#endif\n}\n\n// void glRasterPos3d (GLdouble x, GLdouble y, GLdouble z);\nstatic inline void qglRasterPos3d(GLdouble x, GLdouble y, GLdouble z)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos3d(x=%f, y=%f, z=%f)\\n\", x, y, z);\n#endif\n    glRasterPos3d(x, y, z);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos3d\");\n#endif\n}\n\n// void glRasterPos3dv (const GLdouble *v);\nstatic inline void qglRasterPos3dv(const GLdouble *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos3dv(v=%p)\\n\", v);\n#endif\n    glRasterPos3dv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos3dv\");\n#endif\n}\n\n// void glRasterPos3f (GLfloat x, GLfloat y, GLfloat z);\nstatic inline void qglRasterPos3f(GLfloat x, GLfloat y, GLfloat z)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos3f(x=%f, y=%f, z=%f)\\n\", x, y, z);\n#endif\n    glRasterPos3f(x, y, z);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos3f\");\n#endif\n}\n\n// void glRasterPos3fv (const GLfloat *v);\nstatic inline void qglRasterPos3fv(const GLfloat *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos3fv(v=%p)\\n\", v);\n#endif\n    glRasterPos3fv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos3fv\");\n#endif\n}\n\n// void glRasterPos3i (GLint x, GLint y, GLint z);\nstatic inline void qglRasterPos3i(GLint x, GLint y, GLint z)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos3i(x=%ld, y=%ld, z=%ld)\\n\", x, y, z);\n#endif\n    glRasterPos3i(x, y, z);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos3i\");\n#endif\n}\n\n// void glRasterPos3iv (const GLint *v);\nstatic inline void qglRasterPos3iv(const GLint *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos3iv(v=%p)\\n\", v);\n#endif\n    glRasterPos3iv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos3iv\");\n#endif\n}\n\n// void glRasterPos3s (GLshort x, GLshort y, GLshort z);\nstatic inline void qglRasterPos3s(GLshort x, GLshort y, GLshort z)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos3s(x=%d, y=%d, z=%d)\\n\", x, y, z);\n#endif\n    glRasterPos3s(x, y, z);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos3s\");\n#endif\n}\n\n// void glRasterPos3sv (const GLshort *v);\nstatic inline void qglRasterPos3sv(const GLshort *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos3sv(v=%p)\\n\", v);\n#endif\n    glRasterPos3sv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos3sv\");\n#endif\n}\n\n// void glRasterPos4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nstatic inline void qglRasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos4d(x=%f, y=%f, z=%f, w=%f)\\n\", x, y, z, w);\n#endif\n    glRasterPos4d(x, y, z, w);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos4d\");\n#endif\n}\n\n// void glRasterPos4dv (const GLdouble *v);\nstatic inline void qglRasterPos4dv(const GLdouble *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos4dv(v=%p)\\n\", v);\n#endif\n    glRasterPos4dv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos4dv\");\n#endif\n}\n\n// void glRasterPos4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nstatic inline void qglRasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos4f(x=%f, y=%f, z=%f, w=%f)\\n\", x, y, z, w);\n#endif\n    glRasterPos4f(x, y, z, w);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos4f\");\n#endif\n}\n\n// void glRasterPos4fv (const GLfloat *v);\nstatic inline void qglRasterPos4fv(const GLfloat *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos4fv(v=%p)\\n\", v);\n#endif\n    glRasterPos4fv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos4fv\");\n#endif\n}\n\n// void glRasterPos4i (GLint x, GLint y, GLint z, GLint w);\nstatic inline void qglRasterPos4i(GLint x, GLint y, GLint z, GLint w)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos4i(x=%ld, y=%ld, z=%ld, w=%ld)\\n\", x, y, z, w);\n#endif\n    glRasterPos4i(x, y, z, w);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos4i\");\n#endif\n}\n\n// void glRasterPos4iv (const GLint *v);\nstatic inline void qglRasterPos4iv(const GLint *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos4iv(v=%p)\\n\", v);\n#endif\n    glRasterPos4iv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos4iv\");\n#endif\n}\n\n// void glRasterPos4s (GLshort x, GLshort y, GLshort z, GLshort w);\nstatic inline void qglRasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos4s(x=%d, y=%d, z=%d, w=%d)\\n\", x, y, z, w);\n#endif\n    glRasterPos4s(x, y, z, w);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos4s\");\n#endif\n}\n\n// void glRasterPos4sv (const GLshort *v);\nstatic inline void qglRasterPos4sv(const GLshort *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRasterPos4sv(v=%p)\\n\", v);\n#endif\n    glRasterPos4sv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRasterPos4sv\");\n#endif\n}\n\n// void glReadBuffer (GLenum mode);\nstatic inline void qglReadBuffer(GLenum mode)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glReadBuffer(mode=%lu)\\n\", mode);\n#endif\n    glReadBuffer(mode);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glReadBuffer\");\n#endif\n}\n\n// void glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);\nstatic inline void qglReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glReadPixels(x=%ld, y=%ld, width=%ld, height=%ld, format=%lu, type=%lu, pixels=%p)\\n\", x, y, width, height, format, type, pixels);\n#endif\n    glReadPixels(x, y, width, height, format, type, pixels);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glReadPixels\");\n#endif\n}\n\n// void glRectd (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);\nstatic inline void qglRectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRectd(x1=%f, y1=%f, x2=%f, y2=%f)\\n\", x1, y1, x2, y2);\n#endif\n    glRectd(x1, y1, x2, y2);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRectd\");\n#endif\n}\n\n// void glRectdv (const GLdouble *v1, const GLdouble *v2);\nstatic inline void qglRectdv(const GLdouble *v1, const GLdouble *v2)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRectdv(v1=%p, v2=%p)\\n\", v1, v2);\n#endif\n    glRectdv(v1, v2);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRectdv\");\n#endif\n}\n\n// void glRectf (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);\nstatic inline void qglRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRectf(x1=%f, y1=%f, x2=%f, y2=%f)\\n\", x1, y1, x2, y2);\n#endif\n    glRectf(x1, y1, x2, y2);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRectf\");\n#endif\n}\n\n// void glRectfv (const GLfloat *v1, const GLfloat *v2);\nstatic inline void qglRectfv(const GLfloat *v1, const GLfloat *v2)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRectfv(v1=%p, v2=%p)\\n\", v1, v2);\n#endif\n    glRectfv(v1, v2);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRectfv\");\n#endif\n}\n\n// void glRecti (GLint x1, GLint y1, GLint x2, GLint y2);\nstatic inline void qglRecti(GLint x1, GLint y1, GLint x2, GLint y2)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRecti(x1=%ld, y1=%ld, x2=%ld, y2=%ld)\\n\", x1, y1, x2, y2);\n#endif\n    glRecti(x1, y1, x2, y2);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRecti\");\n#endif\n}\n\n// void glRectiv (const GLint *v1, const GLint *v2);\nstatic inline void qglRectiv(const GLint *v1, const GLint *v2)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRectiv(v1=%p, v2=%p)\\n\", v1, v2);\n#endif\n    glRectiv(v1, v2);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRectiv\");\n#endif\n}\n\n// void glRects (GLshort x1, GLshort y1, GLshort x2, GLshort y2);\nstatic inline void qglRects(GLshort x1, GLshort y1, GLshort x2, GLshort y2)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRects(x1=%d, y1=%d, x2=%d, y2=%d)\\n\", x1, y1, x2, y2);\n#endif\n    glRects(x1, y1, x2, y2);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRects\");\n#endif\n}\n\n// void glRectsv (const GLshort *v1, const GLshort *v2);\nstatic inline void qglRectsv(const GLshort *v1, const GLshort *v2)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRectsv(v1=%p, v2=%p)\\n\", v1, v2);\n#endif\n    glRectsv(v1, v2);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRectsv\");\n#endif\n}\n\n// GLint glRenderMode (GLenum mode);\nstatic inline GLint qglRenderMode(GLenum mode)\n{\n    GLint returnValue;\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRenderMode(mode=%lu)\\n\", mode);\n#endif\n    returnValue = glRenderMode(mode);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRenderMode\");\n#endif\n    return returnValue;\n}\n\n// void glRotated (GLdouble angle, GLdouble x, GLdouble y, GLdouble z);\nstatic inline void qglRotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRotated(angle=%f, x=%f, y=%f, z=%f)\\n\", angle, x, y, z);\n#endif\n    glRotated(angle, x, y, z);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRotated\");\n#endif\n}\n\n// void glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z);\nstatic inline void qglRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glRotatef(angle=%f, x=%f, y=%f, z=%f)\\n\", angle, x, y, z);\n#endif\n    glRotatef(angle, x, y, z);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glRotatef\");\n#endif\n}\n\n// void glScaled (GLdouble x, GLdouble y, GLdouble z);\nstatic inline void qglScaled(GLdouble x, GLdouble y, GLdouble z)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glScaled(x=%f, y=%f, z=%f)\\n\", x, y, z);\n#endif\n    glScaled(x, y, z);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glScaled\");\n#endif\n}\n\n// void glScalef (GLfloat x, GLfloat y, GLfloat z);\nstatic inline void qglScalef(GLfloat x, GLfloat y, GLfloat z)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glScalef(x=%f, y=%f, z=%f)\\n\", x, y, z);\n#endif\n    glScalef(x, y, z);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glScalef\");\n#endif\n}\n\n// void glScissor (GLint x, GLint y, GLsizei width, GLsizei height);\nstatic inline void qglScissor(GLint x, GLint y, GLsizei width, GLsizei height)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glScissor(x=%ld, y=%ld, width=%ld, height=%ld)\\n\", x, y, width, height);\n#endif\n    glScissor(x, y, width, height);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glScissor\");\n#endif\n}\n\n// void glSelectBuffer (GLsizei size, GLuint *buffer);\nstatic inline void qglSelectBuffer(GLsizei size, GLuint *buffer)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glSelectBuffer(size=%ld, buffer=%p)\\n\", size, buffer);\n#endif\n    glSelectBuffer(size, buffer);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glSelectBuffer\");\n#endif\n}\n\n// void glShadeModel (GLenum mode);\nstatic inline void qglShadeModel(GLenum mode)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glShadeModel(mode=%lu)\\n\", mode);\n#endif\n    glShadeModel(mode);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glShadeModel\");\n#endif\n}\n\n// void glStencilFunc (GLenum func, GLint ref, GLuint mask);\nstatic inline void qglStencilFunc(GLenum func, GLint ref, GLuint mask)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glStencilFunc(func=%lu, ref=%ld, mask=%lu)\\n\", func, ref, mask);\n#endif\n    glStencilFunc(func, ref, mask);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glStencilFunc\");\n#endif\n}\n\n// void glStencilMask (GLuint mask);\nstatic inline void qglStencilMask(GLuint mask)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glStencilMask(mask=%lu)\\n\", mask);\n#endif\n    glStencilMask(mask);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glStencilMask\");\n#endif\n}\n\n// void glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);\nstatic inline void qglStencilOp(GLenum fail, GLenum zfail, GLenum zpass)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glStencilOp(fail=%lu, zfail=%lu, zpass=%lu)\\n\", fail, zfail, zpass);\n#endif\n    glStencilOp(fail, zfail, zpass);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glStencilOp\");\n#endif\n}\n\n// void glTexCoord1d (GLdouble s);\nstatic inline void qglTexCoord1d(GLdouble s)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord1d(s=%f)\\n\", s);\n#endif\n    glTexCoord1d(s);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord1d\");\n#endif\n}\n\n// void glTexCoord1dv (const GLdouble *v);\nstatic inline void qglTexCoord1dv(const GLdouble *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord1dv(v=%p)\\n\", v);\n#endif\n    glTexCoord1dv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord1dv\");\n#endif\n}\n\n// void glTexCoord1f (GLfloat s);\nstatic inline void qglTexCoord1f(GLfloat s)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord1f(s=%f)\\n\", s);\n#endif\n    glTexCoord1f(s);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord1f\");\n#endif\n}\n\n// void glTexCoord1fv (const GLfloat *v);\nstatic inline void qglTexCoord1fv(const GLfloat *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord1fv(v=%p)\\n\", v);\n#endif\n    glTexCoord1fv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord1fv\");\n#endif\n}\n\n// void glTexCoord1i (GLint s);\nstatic inline void qglTexCoord1i(GLint s)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord1i(s=%ld)\\n\", s);\n#endif\n    glTexCoord1i(s);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord1i\");\n#endif\n}\n\n// void glTexCoord1iv (const GLint *v);\nstatic inline void qglTexCoord1iv(const GLint *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord1iv(v=%p)\\n\", v);\n#endif\n    glTexCoord1iv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord1iv\");\n#endif\n}\n\n// void glTexCoord1s (GLshort s);\nstatic inline void qglTexCoord1s(GLshort s)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord1s(s=%d)\\n\", s);\n#endif\n    glTexCoord1s(s);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord1s\");\n#endif\n}\n\n// void glTexCoord1sv (const GLshort *v);\nstatic inline void qglTexCoord1sv(const GLshort *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord1sv(v=%p)\\n\", v);\n#endif\n    glTexCoord1sv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord1sv\");\n#endif\n}\n\n// void glTexCoord2d (GLdouble s, GLdouble t);\nstatic inline void qglTexCoord2d(GLdouble s, GLdouble t)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord2d(s=%f, t=%f)\\n\", s, t);\n#endif\n    glTexCoord2d(s, t);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord2d\");\n#endif\n}\n\n// void glTexCoord2dv (const GLdouble *v);\nstatic inline void qglTexCoord2dv(const GLdouble *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord2dv(v=%p)\\n\", v);\n#endif\n    glTexCoord2dv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord2dv\");\n#endif\n}\n\n// void glTexCoord2f (GLfloat s, GLfloat t);\nstatic inline void qglTexCoord2f(GLfloat s, GLfloat t)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord2f(s=%f, t=%f)\\n\", s, t);\n#endif\n    glTexCoord2f(s, t);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord2f\");\n#endif\n}\n\n// void glTexCoord2fv (const GLfloat *v);\nstatic inline void qglTexCoord2fv(const GLfloat *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord2fv(v=%p)\\n\", v);\n#endif\n    glTexCoord2fv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord2fv\");\n#endif\n}\n\n// void glTexCoord2i (GLint s, GLint t);\nstatic inline void qglTexCoord2i(GLint s, GLint t)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord2i(s=%ld, t=%ld)\\n\", s, t);\n#endif\n    glTexCoord2i(s, t);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord2i\");\n#endif\n}\n\n// void glTexCoord2iv (const GLint *v);\nstatic inline void qglTexCoord2iv(const GLint *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord2iv(v=%p)\\n\", v);\n#endif\n    glTexCoord2iv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord2iv\");\n#endif\n}\n\n// void glTexCoord2s (GLshort s, GLshort t);\nstatic inline void qglTexCoord2s(GLshort s, GLshort t)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord2s(s=%d, t=%d)\\n\", s, t);\n#endif\n    glTexCoord2s(s, t);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord2s\");\n#endif\n}\n\n// void glTexCoord2sv (const GLshort *v);\nstatic inline void qglTexCoord2sv(const GLshort *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord2sv(v=%p)\\n\", v);\n#endif\n    glTexCoord2sv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord2sv\");\n#endif\n}\n\n// void glTexCoord3d (GLdouble s, GLdouble t, GLdouble r);\nstatic inline void qglTexCoord3d(GLdouble s, GLdouble t, GLdouble r)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord3d(s=%f, t=%f, r=%f)\\n\", s, t, r);\n#endif\n    glTexCoord3d(s, t, r);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord3d\");\n#endif\n}\n\n// void glTexCoord3dv (const GLdouble *v);\nstatic inline void qglTexCoord3dv(const GLdouble *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord3dv(v=%p)\\n\", v);\n#endif\n    glTexCoord3dv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord3dv\");\n#endif\n}\n\n// void glTexCoord3f (GLfloat s, GLfloat t, GLfloat r);\nstatic inline void qglTexCoord3f(GLfloat s, GLfloat t, GLfloat r)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord3f(s=%f, t=%f, r=%f)\\n\", s, t, r);\n#endif\n    glTexCoord3f(s, t, r);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord3f\");\n#endif\n}\n\n// void glTexCoord3fv (const GLfloat *v);\nstatic inline void qglTexCoord3fv(const GLfloat *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord3fv(v=%p)\\n\", v);\n#endif\n    glTexCoord3fv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord3fv\");\n#endif\n}\n\n// void glTexCoord3i (GLint s, GLint t, GLint r);\nstatic inline void qglTexCoord3i(GLint s, GLint t, GLint r)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord3i(s=%ld, t=%ld, r=%ld)\\n\", s, t, r);\n#endif\n    glTexCoord3i(s, t, r);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord3i\");\n#endif\n}\n\n// void glTexCoord3iv (const GLint *v);\nstatic inline void qglTexCoord3iv(const GLint *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord3iv(v=%p)\\n\", v);\n#endif\n    glTexCoord3iv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord3iv\");\n#endif\n}\n\n// void glTexCoord3s (GLshort s, GLshort t, GLshort r);\nstatic inline void qglTexCoord3s(GLshort s, GLshort t, GLshort r)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord3s(s=%d, t=%d, r=%d)\\n\", s, t, r);\n#endif\n    glTexCoord3s(s, t, r);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord3s\");\n#endif\n}\n\n// void glTexCoord3sv (const GLshort *v);\nstatic inline void qglTexCoord3sv(const GLshort *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord3sv(v=%p)\\n\", v);\n#endif\n    glTexCoord3sv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord3sv\");\n#endif\n}\n\n// void glTexCoord4d (GLdouble s, GLdouble t, GLdouble r, GLdouble q);\nstatic inline void qglTexCoord4d(GLdouble s, GLdouble t, GLdouble r, GLdouble q)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord4d(s=%f, t=%f, r=%f, q=%f)\\n\", s, t, r, q);\n#endif\n    glTexCoord4d(s, t, r, q);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord4d\");\n#endif\n}\n\n// void glTexCoord4dv (const GLdouble *v);\nstatic inline void qglTexCoord4dv(const GLdouble *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord4dv(v=%p)\\n\", v);\n#endif\n    glTexCoord4dv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord4dv\");\n#endif\n}\n\n// void glTexCoord4f (GLfloat s, GLfloat t, GLfloat r, GLfloat q);\nstatic inline void qglTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord4f(s=%f, t=%f, r=%f, q=%f)\\n\", s, t, r, q);\n#endif\n    glTexCoord4f(s, t, r, q);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord4f\");\n#endif\n}\n\n// void glTexCoord4fv (const GLfloat *v);\nstatic inline void qglTexCoord4fv(const GLfloat *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord4fv(v=%p)\\n\", v);\n#endif\n    glTexCoord4fv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord4fv\");\n#endif\n}\n\n// void glTexCoord4i (GLint s, GLint t, GLint r, GLint q);\nstatic inline void qglTexCoord4i(GLint s, GLint t, GLint r, GLint q)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord4i(s=%ld, t=%ld, r=%ld, q=%ld)\\n\", s, t, r, q);\n#endif\n    glTexCoord4i(s, t, r, q);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord4i\");\n#endif\n}\n\n// void glTexCoord4iv (const GLint *v);\nstatic inline void qglTexCoord4iv(const GLint *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord4iv(v=%p)\\n\", v);\n#endif\n    glTexCoord4iv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord4iv\");\n#endif\n}\n\n// void glTexCoord4s (GLshort s, GLshort t, GLshort r, GLshort q);\nstatic inline void qglTexCoord4s(GLshort s, GLshort t, GLshort r, GLshort q)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord4s(s=%d, t=%d, r=%d, q=%d)\\n\", s, t, r, q);\n#endif\n    glTexCoord4s(s, t, r, q);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord4s\");\n#endif\n}\n\n// void glTexCoord4sv (const GLshort *v);\nstatic inline void qglTexCoord4sv(const GLshort *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoord4sv(v=%p)\\n\", v);\n#endif\n    glTexCoord4sv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoord4sv\");\n#endif\n}\n\n// void glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nstatic inline void qglTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexCoordPointer(size=%ld, type=%lu, stride=%ld, pointer=%p)\\n\", size, type, stride, pointer);\n#endif\n    glTexCoordPointer(size, type, stride, pointer);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexCoordPointer\");\n#endif\n}\n\n// void glTexEnvf (GLenum target, GLenum pname, GLfloat param);\nstatic inline void qglTexEnvf(GLenum target, GLenum pname, GLfloat param)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexEnvf(target=%lu, pname=%lu, param=%f)\\n\", target, pname, param);\n#endif\n    glTexEnvf(target, pname, param);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexEnvf\");\n#endif\n}\n\n// void glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params);\nstatic inline void qglTexEnvfv(GLenum target, GLenum pname, const GLfloat *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexEnvfv(target=%lu, pname=%lu, params=%p)\\n\", target, pname, params);\n#endif\n    glTexEnvfv(target, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexEnvfv\");\n#endif\n}\n\n// void glTexEnvi (GLenum target, GLenum pname, GLint param);\nstatic inline void qglTexEnvi(GLenum target, GLenum pname, GLint param)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexEnvi(target=%lu, pname=%lu, param=%ld)\\n\", target, pname, param);\n#endif\n    glTexEnvi(target, pname, param);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexEnvi\");\n#endif\n}\n\n// void glTexEnviv (GLenum target, GLenum pname, const GLint *params);\nstatic inline void qglTexEnviv(GLenum target, GLenum pname, const GLint *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexEnviv(target=%lu, pname=%lu, params=%p)\\n\", target, pname, params);\n#endif\n    glTexEnviv(target, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexEnviv\");\n#endif\n}\n\n// void glTexGend (GLenum coord, GLenum pname, GLdouble param);\nstatic inline void qglTexGend(GLenum coord, GLenum pname, GLdouble param)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexGend(coord=%lu, pname=%lu, param=%f)\\n\", coord, pname, param);\n#endif\n    glTexGend(coord, pname, param);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexGend\");\n#endif\n}\n\n// void glTexGendv (GLenum coord, GLenum pname, const GLdouble *params);\nstatic inline void qglTexGendv(GLenum coord, GLenum pname, const GLdouble *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexGendv(coord=%lu, pname=%lu, params=%p)\\n\", coord, pname, params);\n#endif\n    glTexGendv(coord, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexGendv\");\n#endif\n}\n\n// void glTexGenf (GLenum coord, GLenum pname, GLfloat param);\nstatic inline void qglTexGenf(GLenum coord, GLenum pname, GLfloat param)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexGenf(coord=%lu, pname=%lu, param=%f)\\n\", coord, pname, param);\n#endif\n    glTexGenf(coord, pname, param);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexGenf\");\n#endif\n}\n\n// void glTexGenfv (GLenum coord, GLenum pname, const GLfloat *params);\nstatic inline void qglTexGenfv(GLenum coord, GLenum pname, const GLfloat *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexGenfv(coord=%lu, pname=%lu, params=%p)\\n\", coord, pname, params);\n#endif\n    glTexGenfv(coord, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexGenfv\");\n#endif\n}\n\n// void glTexGeni (GLenum coord, GLenum pname, GLint param);\nstatic inline void qglTexGeni(GLenum coord, GLenum pname, GLint param)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexGeni(coord=%lu, pname=%lu, param=%ld)\\n\", coord, pname, param);\n#endif\n    glTexGeni(coord, pname, param);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexGeni\");\n#endif\n}\n\n// void glTexGeniv (GLenum coord, GLenum pname, const GLint *params);\nstatic inline void qglTexGeniv(GLenum coord, GLenum pname, const GLint *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexGeniv(coord=%lu, pname=%lu, params=%p)\\n\", coord, pname, params);\n#endif\n    glTexGeniv(coord, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexGeniv\");\n#endif\n}\n\n// void glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nstatic inline void qglTexImage1D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexImage1D(target=%lu, level=%ld, internalformat=%ld, width=%ld, border=%ld, format=%lu, type=%lu, pixels=%p)\\n\", target, level, internalformat, width, border, format, type, pixels);\n#endif\n    glTexImage1D(target, level, internalformat, width, border, format, type, pixels);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexImage1D\");\n#endif\n}\n\n// void glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nstatic inline void qglTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexImage2D(target=%lu, level=%ld, internalformat=%ld, width=%ld, height=%ld, border=%ld, format=%lu, type=%lu, pixels=%p)\\n\", target, level, internalformat, width, height, border, format, type, pixels);\n#endif\n    glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexImage2D\");\n#endif\n}\n\n// void glTexParameterf (GLenum target, GLenum pname, GLfloat param);\nstatic inline void qglTexParameterf(GLenum target, GLenum pname, GLfloat param)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexParameterf(target=%lu, pname=%lu, param=%f)\\n\", target, pname, param);\n#endif\n    glTexParameterf(target, pname, param);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexParameterf\");\n#endif\n}\n\n// void glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params);\nstatic inline void qglTexParameterfv(GLenum target, GLenum pname, const GLfloat *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexParameterfv(target=%lu, pname=%lu, params=%p)\\n\", target, pname, params);\n#endif\n    glTexParameterfv(target, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexParameterfv\");\n#endif\n}\n\n// void glTexParameteri (GLenum target, GLenum pname, GLint param);\nstatic inline void qglTexParameteri(GLenum target, GLenum pname, GLint param)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexParameteri(target=%lu, pname=%lu, param=%ld)\\n\", target, pname, param);\n#endif\n    glTexParameteri(target, pname, param);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexParameteri\");\n#endif\n}\n\n// void glTexParameteriv (GLenum target, GLenum pname, const GLint *params);\nstatic inline void qglTexParameteriv(GLenum target, GLenum pname, const GLint *params)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexParameteriv(target=%lu, pname=%lu, params=%p)\\n\", target, pname, params);\n#endif\n    glTexParameteriv(target, pname, params);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexParameteriv\");\n#endif\n}\n\n// void glTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);\nstatic inline void qglTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexSubImage1D(target=%lu, level=%ld, xoffset=%ld, width=%ld, format=%lu, type=%lu, pixels=%p)\\n\", target, level, xoffset, width, format, type, pixels);\n#endif\n    glTexSubImage1D(target, level, xoffset, width, format, type, pixels);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexSubImage1D\");\n#endif\n}\n\n// void glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nstatic inline void qglTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTexSubImage2D(target=%lu, level=%ld, xoffset=%ld, yoffset=%ld, width=%ld, height=%ld, format=%lu, type=%lu, pixels=%p)\\n\", target, level, xoffset, yoffset, width, height, format, type, pixels);\n#endif\n    glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTexSubImage2D\");\n#endif\n}\n\n// void glTranslated (GLdouble x, GLdouble y, GLdouble z);\nstatic inline void qglTranslated(GLdouble x, GLdouble y, GLdouble z)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTranslated(x=%f, y=%f, z=%f)\\n\", x, y, z);\n#endif\n    glTranslated(x, y, z);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTranslated\");\n#endif\n}\n\n// void glTranslatef (GLfloat x, GLfloat y, GLfloat z);\nstatic inline void qglTranslatef(GLfloat x, GLfloat y, GLfloat z)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glTranslatef(x=%f, y=%f, z=%f)\\n\", x, y, z);\n#endif\n    glTranslatef(x, y, z);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glTranslatef\");\n#endif\n}\n\n// void glVertex2d (GLdouble x, GLdouble y);\nstatic inline void qglVertex2d(GLdouble x, GLdouble y)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex2d(x=%f, y=%f)\\n\", x, y);\n#endif\n    glVertex2d(x, y);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex2d\");\n#endif\n}\n\n// void glVertex2dv (const GLdouble *v);\nstatic inline void qglVertex2dv(const GLdouble *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex2dv(v=%p)\\n\", v);\n#endif\n    glVertex2dv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex2dv\");\n#endif\n}\n\n// void glVertex2f (GLfloat x, GLfloat y);\nstatic inline void qglVertex2f(GLfloat x, GLfloat y)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex2f(x=%f, y=%f)\\n\", x, y);\n#endif\n    glVertex2f(x, y);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex2f\");\n#endif\n}\n\n// void glVertex2fv (const GLfloat *v);\nstatic inline void qglVertex2fv(const GLfloat *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex2fv(v=%p)\\n\", v);\n#endif\n    glVertex2fv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex2fv\");\n#endif\n}\n\n// void glVertex2i (GLint x, GLint y);\nstatic inline void qglVertex2i(GLint x, GLint y)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex2i(x=%ld, y=%ld)\\n\", x, y);\n#endif\n    glVertex2i(x, y);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex2i\");\n#endif\n}\n\n// void glVertex2iv (const GLint *v);\nstatic inline void qglVertex2iv(const GLint *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex2iv(v=%p)\\n\", v);\n#endif\n    glVertex2iv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex2iv\");\n#endif\n}\n\n// void glVertex2s (GLshort x, GLshort y);\nstatic inline void qglVertex2s(GLshort x, GLshort y)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex2s(x=%d, y=%d)\\n\", x, y);\n#endif\n    glVertex2s(x, y);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex2s\");\n#endif\n}\n\n// void glVertex2sv (const GLshort *v);\nstatic inline void qglVertex2sv(const GLshort *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex2sv(v=%p)\\n\", v);\n#endif\n    glVertex2sv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex2sv\");\n#endif\n}\n\n// void glVertex3d (GLdouble x, GLdouble y, GLdouble z);\nstatic inline void qglVertex3d(GLdouble x, GLdouble y, GLdouble z)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex3d(x=%f, y=%f, z=%f)\\n\", x, y, z);\n#endif\n    glVertex3d(x, y, z);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex3d\");\n#endif\n}\n\n// void glVertex3dv (const GLdouble *v);\nstatic inline void qglVertex3dv(const GLdouble *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex3dv(v=%p)\\n\", v);\n#endif\n    glVertex3dv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex3dv\");\n#endif\n}\n\n// void glVertex3f (GLfloat x, GLfloat y, GLfloat z);\nstatic inline void qglVertex3f(GLfloat x, GLfloat y, GLfloat z)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex3f(x=%f, y=%f, z=%f)\\n\", x, y, z);\n#endif\n    glVertex3f(x, y, z);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex3f\");\n#endif\n}\n\n// void glVertex3fv (const GLfloat *v);\nstatic inline void qglVertex3fv(const GLfloat *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex3fv(v=%p)\\n\", v);\n#endif\n    glVertex3fv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex3fv\");\n#endif\n}\n\n// void glVertex3i (GLint x, GLint y, GLint z);\nstatic inline void qglVertex3i(GLint x, GLint y, GLint z)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex3i(x=%ld, y=%ld, z=%ld)\\n\", x, y, z);\n#endif\n    glVertex3i(x, y, z);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex3i\");\n#endif\n}\n\n// void glVertex3iv (const GLint *v);\nstatic inline void qglVertex3iv(const GLint *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex3iv(v=%p)\\n\", v);\n#endif\n    glVertex3iv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex3iv\");\n#endif\n}\n\n// void glVertex3s (GLshort x, GLshort y, GLshort z);\nstatic inline void qglVertex3s(GLshort x, GLshort y, GLshort z)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex3s(x=%d, y=%d, z=%d)\\n\", x, y, z);\n#endif\n    glVertex3s(x, y, z);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex3s\");\n#endif\n}\n\n// void glVertex3sv (const GLshort *v);\nstatic inline void qglVertex3sv(const GLshort *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex3sv(v=%p)\\n\", v);\n#endif\n    glVertex3sv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex3sv\");\n#endif\n}\n\n// void glVertex4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nstatic inline void qglVertex4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex4d(x=%f, y=%f, z=%f, w=%f)\\n\", x, y, z, w);\n#endif\n    glVertex4d(x, y, z, w);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex4d\");\n#endif\n}\n\n// void glVertex4dv (const GLdouble *v);\nstatic inline void qglVertex4dv(const GLdouble *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex4dv(v=%p)\\n\", v);\n#endif\n    glVertex4dv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex4dv\");\n#endif\n}\n\n// void glVertex4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nstatic inline void qglVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex4f(x=%f, y=%f, z=%f, w=%f)\\n\", x, y, z, w);\n#endif\n    glVertex4f(x, y, z, w);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex4f\");\n#endif\n}\n\n// void glVertex4fv (const GLfloat *v);\nstatic inline void qglVertex4fv(const GLfloat *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex4fv(v=%p)\\n\", v);\n#endif\n    glVertex4fv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex4fv\");\n#endif\n}\n\n// void glVertex4i (GLint x, GLint y, GLint z, GLint w);\nstatic inline void qglVertex4i(GLint x, GLint y, GLint z, GLint w)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex4i(x=%ld, y=%ld, z=%ld, w=%ld)\\n\", x, y, z, w);\n#endif\n    glVertex4i(x, y, z, w);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex4i\");\n#endif\n}\n\n// void glVertex4iv (const GLint *v);\nstatic inline void qglVertex4iv(const GLint *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex4iv(v=%p)\\n\", v);\n#endif\n    glVertex4iv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex4iv\");\n#endif\n}\n\n// void glVertex4s (GLshort x, GLshort y, GLshort z, GLshort w);\nstatic inline void qglVertex4s(GLshort x, GLshort y, GLshort z, GLshort w)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex4s(x=%d, y=%d, z=%d, w=%d)\\n\", x, y, z, w);\n#endif\n    glVertex4s(x, y, z, w);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex4s\");\n#endif\n}\n\n// void glVertex4sv (const GLshort *v);\nstatic inline void qglVertex4sv(const GLshort *v)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertex4sv(v=%p)\\n\", v);\n#endif\n    glVertex4sv(v);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertex4sv\");\n#endif\n}\n\n// void glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nstatic inline void qglVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glVertexPointer(size=%ld, type=%lu, stride=%ld, pointer=%p)\\n\", size, type, stride, pointer);\n#endif\n    glVertexPointer(size, type, stride, pointer);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glVertexPointer\");\n#endif\n}\n\n// void glViewport (GLint x, GLint y, GLsizei width, GLsizei height);\nstatic inline void qglViewport(GLint x, GLint y, GLsizei width, GLsizei height)\n{\n#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS)\n    if (QGLLogGLCalls)\n        fprintf(QGLDebugFile(), \"glViewport(x=%ld, y=%ld, width=%ld, height=%ld)\\n\", x, y, width, height);\n#endif\n    glViewport(x, y, width, height);\n#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS)\n    if (!QGLBeginStarted)\n        QGLCheckError(\"glViewport\");\n#endif\n}\n\n// Prevent calls to the 'normal' GL functions\n#define glAccum CALL_THE_QGL_VERSION_OF_glAccum\n#define glAlphaFunc CALL_THE_QGL_VERSION_OF_glAlphaFunc\n#define glAreTexturesResident CALL_THE_QGL_VERSION_OF_glAreTexturesResident\n#define glArrayElement CALL_THE_QGL_VERSION_OF_glArrayElement\n#define glBegin CALL_THE_QGL_VERSION_OF_glBegin\n#define glBindTexture CALL_THE_QGL_VERSION_OF_glBindTexture\n#define glBitmap CALL_THE_QGL_VERSION_OF_glBitmap\n#define glBlendFunc CALL_THE_QGL_VERSION_OF_glBlendFunc\n#define glCallList CALL_THE_QGL_VERSION_OF_glCallList\n#define glCallLists CALL_THE_QGL_VERSION_OF_glCallLists\n#define glClear CALL_THE_QGL_VERSION_OF_glClear\n#define glClearAccum CALL_THE_QGL_VERSION_OF_glClearAccum\n#define glClearColor CALL_THE_QGL_VERSION_OF_glClearColor\n#define glClearDepth CALL_THE_QGL_VERSION_OF_glClearDepth\n#define glClearIndex CALL_THE_QGL_VERSION_OF_glClearIndex\n#define glClearStencil CALL_THE_QGL_VERSION_OF_glClearStencil\n#define glClipPlane CALL_THE_QGL_VERSION_OF_glClipPlane\n#define glColor3b CALL_THE_QGL_VERSION_OF_glColor3b\n#define glColor3bv CALL_THE_QGL_VERSION_OF_glColor3bv\n#define glColor3d CALL_THE_QGL_VERSION_OF_glColor3d\n#define glColor3dv CALL_THE_QGL_VERSION_OF_glColor3dv\n#define glColor3f CALL_THE_QGL_VERSION_OF_glColor3f\n#define glColor3fv CALL_THE_QGL_VERSION_OF_glColor3fv\n#define glColor3i CALL_THE_QGL_VERSION_OF_glColor3i\n#define glColor3iv CALL_THE_QGL_VERSION_OF_glColor3iv\n#define glColor3s CALL_THE_QGL_VERSION_OF_glColor3s\n#define glColor3sv CALL_THE_QGL_VERSION_OF_glColor3sv\n#define glColor3ub CALL_THE_QGL_VERSION_OF_glColor3ub\n#define glColor3ubv CALL_THE_QGL_VERSION_OF_glColor3ubv\n#define glColor3ui CALL_THE_QGL_VERSION_OF_glColor3ui\n#define glColor3uiv CALL_THE_QGL_VERSION_OF_glColor3uiv\n#define glColor3us CALL_THE_QGL_VERSION_OF_glColor3us\n#define glColor3usv CALL_THE_QGL_VERSION_OF_glColor3usv\n#define glColor4b CALL_THE_QGL_VERSION_OF_glColor4b\n#define glColor4bv CALL_THE_QGL_VERSION_OF_glColor4bv\n#define glColor4d CALL_THE_QGL_VERSION_OF_glColor4d\n#define glColor4dv CALL_THE_QGL_VERSION_OF_glColor4dv\n#define glColor4f CALL_THE_QGL_VERSION_OF_glColor4f\n#define glColor4fv CALL_THE_QGL_VERSION_OF_glColor4fv\n#define glColor4i CALL_THE_QGL_VERSION_OF_glColor4i\n#define glColor4iv CALL_THE_QGL_VERSION_OF_glColor4iv\n#define glColor4s CALL_THE_QGL_VERSION_OF_glColor4s\n#define glColor4sv CALL_THE_QGL_VERSION_OF_glColor4sv\n#define glColor4ub CALL_THE_QGL_VERSION_OF_glColor4ub\n#define glColor4ubv CALL_THE_QGL_VERSION_OF_glColor4ubv\n#define glColor4ui CALL_THE_QGL_VERSION_OF_glColor4ui\n#define glColor4uiv CALL_THE_QGL_VERSION_OF_glColor4uiv\n#define glColor4us CALL_THE_QGL_VERSION_OF_glColor4us\n#define glColor4usv CALL_THE_QGL_VERSION_OF_glColor4usv\n#define glColorMask CALL_THE_QGL_VERSION_OF_glColorMask\n#define glColorMaterial CALL_THE_QGL_VERSION_OF_glColorMaterial\n#define glColorPointer CALL_THE_QGL_VERSION_OF_glColorPointer\n#define glCopyPixels CALL_THE_QGL_VERSION_OF_glCopyPixels\n#define glCopyTexImage1D CALL_THE_QGL_VERSION_OF_glCopyTexImage1D\n#define glCopyTexImage2D CALL_THE_QGL_VERSION_OF_glCopyTexImage2D\n#define glCopyTexSubImage1D CALL_THE_QGL_VERSION_OF_glCopyTexSubImage1D\n#define glCopyTexSubImage2D CALL_THE_QGL_VERSION_OF_glCopyTexSubImage2D\n#define glCullFace CALL_THE_QGL_VERSION_OF_glCullFace\n#define glDeleteLists CALL_THE_QGL_VERSION_OF_glDeleteLists\n#define glDeleteTextures CALL_THE_QGL_VERSION_OF_glDeleteTextures\n#define glDepthFunc CALL_THE_QGL_VERSION_OF_glDepthFunc\n#define glDepthMask CALL_THE_QGL_VERSION_OF_glDepthMask\n#define glDepthRange CALL_THE_QGL_VERSION_OF_glDepthRange\n#define glDisable CALL_THE_QGL_VERSION_OF_glDisable\n#define glDisableClientState CALL_THE_QGL_VERSION_OF_glDisableClientState\n#define glDrawArrays CALL_THE_QGL_VERSION_OF_glDrawArrays\n#define glDrawBuffer CALL_THE_QGL_VERSION_OF_glDrawBuffer\n#define glDrawElements CALL_THE_QGL_VERSION_OF_glDrawElements\n#define glDrawPixels CALL_THE_QGL_VERSION_OF_glDrawPixels\n#define glEdgeFlag CALL_THE_QGL_VERSION_OF_glEdgeFlag\n#define glEdgeFlagPointer CALL_THE_QGL_VERSION_OF_glEdgeFlagPointer\n#define glEdgeFlagv CALL_THE_QGL_VERSION_OF_glEdgeFlagv\n#define glEnable CALL_THE_QGL_VERSION_OF_glEnable\n#define glEnableClientState CALL_THE_QGL_VERSION_OF_glEnableClientState\n#define glEnd CALL_THE_QGL_VERSION_OF_glEnd\n#define glEndList CALL_THE_QGL_VERSION_OF_glEndList\n#define glEvalCoord1d CALL_THE_QGL_VERSION_OF_glEvalCoord1d\n#define glEvalCoord1dv CALL_THE_QGL_VERSION_OF_glEvalCoord1dv\n#define glEvalCoord1f CALL_THE_QGL_VERSION_OF_glEvalCoord1f\n#define glEvalCoord1fv CALL_THE_QGL_VERSION_OF_glEvalCoord1fv\n#define glEvalCoord2d CALL_THE_QGL_VERSION_OF_glEvalCoord2d\n#define glEvalCoord2dv CALL_THE_QGL_VERSION_OF_glEvalCoord2dv\n#define glEvalCoord2f CALL_THE_QGL_VERSION_OF_glEvalCoord2f\n#define glEvalCoord2fv CALL_THE_QGL_VERSION_OF_glEvalCoord2fv\n#define glEvalMesh1 CALL_THE_QGL_VERSION_OF_glEvalMesh1\n#define glEvalMesh2 CALL_THE_QGL_VERSION_OF_glEvalMesh2\n#define glEvalPoint1 CALL_THE_QGL_VERSION_OF_glEvalPoint1\n#define glEvalPoint2 CALL_THE_QGL_VERSION_OF_glEvalPoint2\n#define glFeedbackBuffer CALL_THE_QGL_VERSION_OF_glFeedbackBuffer\n#define glFinish CALL_THE_QGL_VERSION_OF_glFinish\n#define glFlush CALL_THE_QGL_VERSION_OF_glFlush\n#define glFogf CALL_THE_QGL_VERSION_OF_glFogf\n#define glFogfv CALL_THE_QGL_VERSION_OF_glFogfv\n#define glFogi CALL_THE_QGL_VERSION_OF_glFogi\n#define glFogiv CALL_THE_QGL_VERSION_OF_glFogiv\n#define glFrontFace CALL_THE_QGL_VERSION_OF_glFrontFace\n#define glFrustum CALL_THE_QGL_VERSION_OF_glFrustum\n#define glGenLists CALL_THE_QGL_VERSION_OF_glGenLists\n#define glGenTextures CALL_THE_QGL_VERSION_OF_glGenTextures\n#define glGetBooleanv CALL_THE_QGL_VERSION_OF_glGetBooleanv\n#define glGetClipPlane CALL_THE_QGL_VERSION_OF_glGetClipPlane\n#define glGetDoublev CALL_THE_QGL_VERSION_OF_glGetDoublev\n#define glGetError CALL_THE_QGL_VERSION_OF_glGetError\n#define glGetFloatv CALL_THE_QGL_VERSION_OF_glGetFloatv\n#define glGetIntegerv CALL_THE_QGL_VERSION_OF_glGetIntegerv\n#define glGetLightfv CALL_THE_QGL_VERSION_OF_glGetLightfv\n#define glGetLightiv CALL_THE_QGL_VERSION_OF_glGetLightiv\n#define glGetMapdv CALL_THE_QGL_VERSION_OF_glGetMapdv\n#define glGetMapfv CALL_THE_QGL_VERSION_OF_glGetMapfv\n#define glGetMapiv CALL_THE_QGL_VERSION_OF_glGetMapiv\n#define glGetMaterialfv CALL_THE_QGL_VERSION_OF_glGetMaterialfv\n#define glGetMaterialiv CALL_THE_QGL_VERSION_OF_glGetMaterialiv\n#define glGetPixelMapfv CALL_THE_QGL_VERSION_OF_glGetPixelMapfv\n#define glGetPixelMapuiv CALL_THE_QGL_VERSION_OF_glGetPixelMapuiv\n#define glGetPixelMapusv CALL_THE_QGL_VERSION_OF_glGetPixelMapusv\n#define glGetPointerv CALL_THE_QGL_VERSION_OF_glGetPointerv\n#define glGetPolygonStipple CALL_THE_QGL_VERSION_OF_glGetPolygonStipple\n#define glGetString CALL_THE_QGL_VERSION_OF_glGetString\n#define glGetTexEnvfv CALL_THE_QGL_VERSION_OF_glGetTexEnvfv\n#define glGetTexEnviv CALL_THE_QGL_VERSION_OF_glGetTexEnviv\n#define glGetTexGendv CALL_THE_QGL_VERSION_OF_glGetTexGendv\n#define glGetTexGenfv CALL_THE_QGL_VERSION_OF_glGetTexGenfv\n#define glGetTexGeniv CALL_THE_QGL_VERSION_OF_glGetTexGeniv\n#define glGetTexImage CALL_THE_QGL_VERSION_OF_glGetTexImage\n#define glGetTexLevelParameterfv CALL_THE_QGL_VERSION_OF_glGetTexLevelParameterfv\n#define glGetTexLevelParameteriv CALL_THE_QGL_VERSION_OF_glGetTexLevelParameteriv\n#define glGetTexParameterfv CALL_THE_QGL_VERSION_OF_glGetTexParameterfv\n#define glGetTexParameteriv CALL_THE_QGL_VERSION_OF_glGetTexParameteriv\n#define glHint CALL_THE_QGL_VERSION_OF_glHint\n#define glIndexMask CALL_THE_QGL_VERSION_OF_glIndexMask\n#define glIndexPointer CALL_THE_QGL_VERSION_OF_glIndexPointer\n#define glIndexd CALL_THE_QGL_VERSION_OF_glIndexd\n#define glIndexdv CALL_THE_QGL_VERSION_OF_glIndexdv\n#define glIndexf CALL_THE_QGL_VERSION_OF_glIndexf\n#define glIndexfv CALL_THE_QGL_VERSION_OF_glIndexfv\n#define glIndexi CALL_THE_QGL_VERSION_OF_glIndexi\n#define glIndexiv CALL_THE_QGL_VERSION_OF_glIndexiv\n#define glIndexs CALL_THE_QGL_VERSION_OF_glIndexs\n#define glIndexsv CALL_THE_QGL_VERSION_OF_glIndexsv\n#define glIndexub CALL_THE_QGL_VERSION_OF_glIndexub\n#define glIndexubv CALL_THE_QGL_VERSION_OF_glIndexubv\n#define glInitNames CALL_THE_QGL_VERSION_OF_glInitNames\n#define glInterleavedArrays CALL_THE_QGL_VERSION_OF_glInterleavedArrays\n#define glIsEnabled CALL_THE_QGL_VERSION_OF_glIsEnabled\n#define glIsList CALL_THE_QGL_VERSION_OF_glIsList\n#define glIsTexture CALL_THE_QGL_VERSION_OF_glIsTexture\n#define glLightModelf CALL_THE_QGL_VERSION_OF_glLightModelf\n#define glLightModelfv CALL_THE_QGL_VERSION_OF_glLightModelfv\n#define glLightModeli CALL_THE_QGL_VERSION_OF_glLightModeli\n#define glLightModeliv CALL_THE_QGL_VERSION_OF_glLightModeliv\n#define glLightf CALL_THE_QGL_VERSION_OF_glLightf\n#define glLightfv CALL_THE_QGL_VERSION_OF_glLightfv\n#define glLighti CALL_THE_QGL_VERSION_OF_glLighti\n#define glLightiv CALL_THE_QGL_VERSION_OF_glLightiv\n#define glLineStipple CALL_THE_QGL_VERSION_OF_glLineStipple\n#define glLineWidth CALL_THE_QGL_VERSION_OF_glLineWidth\n#define glListBase CALL_THE_QGL_VERSION_OF_glListBase\n#define glLoadIdentity CALL_THE_QGL_VERSION_OF_glLoadIdentity\n#define glLoadMatrixd CALL_THE_QGL_VERSION_OF_glLoadMatrixd\n#define glLoadMatrixf CALL_THE_QGL_VERSION_OF_glLoadMatrixf\n#define glLoadName CALL_THE_QGL_VERSION_OF_glLoadName\n#define glLogicOp CALL_THE_QGL_VERSION_OF_glLogicOp\n#define glMap1d CALL_THE_QGL_VERSION_OF_glMap1d\n#define glMap1f CALL_THE_QGL_VERSION_OF_glMap1f\n#define glMap2d CALL_THE_QGL_VERSION_OF_glMap2d\n#define glMap2f CALL_THE_QGL_VERSION_OF_glMap2f\n#define glMapGrid1d CALL_THE_QGL_VERSION_OF_glMapGrid1d\n#define glMapGrid1f CALL_THE_QGL_VERSION_OF_glMapGrid1f\n#define glMapGrid2d CALL_THE_QGL_VERSION_OF_glMapGrid2d\n#define glMapGrid2f CALL_THE_QGL_VERSION_OF_glMapGrid2f\n#define glMaterialf CALL_THE_QGL_VERSION_OF_glMaterialf\n#define glMaterialfv CALL_THE_QGL_VERSION_OF_glMaterialfv\n#define glMateriali CALL_THE_QGL_VERSION_OF_glMateriali\n#define glMaterialiv CALL_THE_QGL_VERSION_OF_glMaterialiv\n#define glMatrixMode CALL_THE_QGL_VERSION_OF_glMatrixMode\n#define glMultMatrixd CALL_THE_QGL_VERSION_OF_glMultMatrixd\n#define glMultMatrixf CALL_THE_QGL_VERSION_OF_glMultMatrixf\n#define glNewList CALL_THE_QGL_VERSION_OF_glNewList\n#define glNormal3b CALL_THE_QGL_VERSION_OF_glNormal3b\n#define glNormal3bv CALL_THE_QGL_VERSION_OF_glNormal3bv\n#define glNormal3d CALL_THE_QGL_VERSION_OF_glNormal3d\n#define glNormal3dv CALL_THE_QGL_VERSION_OF_glNormal3dv\n#define glNormal3f CALL_THE_QGL_VERSION_OF_glNormal3f\n#define glNormal3fv CALL_THE_QGL_VERSION_OF_glNormal3fv\n#define glNormal3i CALL_THE_QGL_VERSION_OF_glNormal3i\n#define glNormal3iv CALL_THE_QGL_VERSION_OF_glNormal3iv\n#define glNormal3s CALL_THE_QGL_VERSION_OF_glNormal3s\n#define glNormal3sv CALL_THE_QGL_VERSION_OF_glNormal3sv\n#define glNormalPointer CALL_THE_QGL_VERSION_OF_glNormalPointer\n#define glOrtho CALL_THE_QGL_VERSION_OF_glOrtho\n#define glPassThrough CALL_THE_QGL_VERSION_OF_glPassThrough\n#define glPixelMapfv CALL_THE_QGL_VERSION_OF_glPixelMapfv\n#define glPixelMapuiv CALL_THE_QGL_VERSION_OF_glPixelMapuiv\n#define glPixelMapusv CALL_THE_QGL_VERSION_OF_glPixelMapusv\n#define glPixelStoref CALL_THE_QGL_VERSION_OF_glPixelStoref\n#define glPixelStorei CALL_THE_QGL_VERSION_OF_glPixelStorei\n#define glPixelTransferf CALL_THE_QGL_VERSION_OF_glPixelTransferf\n#define glPixelTransferi CALL_THE_QGL_VERSION_OF_glPixelTransferi\n#define glPixelZoom CALL_THE_QGL_VERSION_OF_glPixelZoom\n#define glPointSize CALL_THE_QGL_VERSION_OF_glPointSize\n#define glPolygonMode CALL_THE_QGL_VERSION_OF_glPolygonMode\n#define glPolygonOffset CALL_THE_QGL_VERSION_OF_glPolygonOffset\n#define glPolygonStipple CALL_THE_QGL_VERSION_OF_glPolygonStipple\n#define glPopAttrib CALL_THE_QGL_VERSION_OF_glPopAttrib\n#define glPopClientAttrib CALL_THE_QGL_VERSION_OF_glPopClientAttrib\n#define glPopMatrix CALL_THE_QGL_VERSION_OF_glPopMatrix\n#define glPopName CALL_THE_QGL_VERSION_OF_glPopName\n#define glPrioritizeTextures CALL_THE_QGL_VERSION_OF_glPrioritizeTextures\n#define glPushAttrib CALL_THE_QGL_VERSION_OF_glPushAttrib\n#define glPushClientAttrib CALL_THE_QGL_VERSION_OF_glPushClientAttrib\n#define glPushMatrix CALL_THE_QGL_VERSION_OF_glPushMatrix\n#define glPushName CALL_THE_QGL_VERSION_OF_glPushName\n#define glRasterPos2d CALL_THE_QGL_VERSION_OF_glRasterPos2d\n#define glRasterPos2dv CALL_THE_QGL_VERSION_OF_glRasterPos2dv\n#define glRasterPos2f CALL_THE_QGL_VERSION_OF_glRasterPos2f\n#define glRasterPos2fv CALL_THE_QGL_VERSION_OF_glRasterPos2fv\n#define glRasterPos2i CALL_THE_QGL_VERSION_OF_glRasterPos2i\n#define glRasterPos2iv CALL_THE_QGL_VERSION_OF_glRasterPos2iv\n#define glRasterPos2s CALL_THE_QGL_VERSION_OF_glRasterPos2s\n#define glRasterPos2sv CALL_THE_QGL_VERSION_OF_glRasterPos2sv\n#define glRasterPos3d CALL_THE_QGL_VERSION_OF_glRasterPos3d\n#define glRasterPos3dv CALL_THE_QGL_VERSION_OF_glRasterPos3dv\n#define glRasterPos3f CALL_THE_QGL_VERSION_OF_glRasterPos3f\n#define glRasterPos3fv CALL_THE_QGL_VERSION_OF_glRasterPos3fv\n#define glRasterPos3i CALL_THE_QGL_VERSION_OF_glRasterPos3i\n#define glRasterPos3iv CALL_THE_QGL_VERSION_OF_glRasterPos3iv\n#define glRasterPos3s CALL_THE_QGL_VERSION_OF_glRasterPos3s\n#define glRasterPos3sv CALL_THE_QGL_VERSION_OF_glRasterPos3sv\n#define glRasterPos4d CALL_THE_QGL_VERSION_OF_glRasterPos4d\n#define glRasterPos4dv CALL_THE_QGL_VERSION_OF_glRasterPos4dv\n#define glRasterPos4f CALL_THE_QGL_VERSION_OF_glRasterPos4f\n#define glRasterPos4fv CALL_THE_QGL_VERSION_OF_glRasterPos4fv\n#define glRasterPos4i CALL_THE_QGL_VERSION_OF_glRasterPos4i\n#define glRasterPos4iv CALL_THE_QGL_VERSION_OF_glRasterPos4iv\n#define glRasterPos4s CALL_THE_QGL_VERSION_OF_glRasterPos4s\n#define glRasterPos4sv CALL_THE_QGL_VERSION_OF_glRasterPos4sv\n#define glReadBuffer CALL_THE_QGL_VERSION_OF_glReadBuffer\n#define glReadPixels CALL_THE_QGL_VERSION_OF_glReadPixels\n#define glRectd CALL_THE_QGL_VERSION_OF_glRectd\n#define glRectdv CALL_THE_QGL_VERSION_OF_glRectdv\n#define glRectf CALL_THE_QGL_VERSION_OF_glRectf\n#define glRectfv CALL_THE_QGL_VERSION_OF_glRectfv\n#define glRecti CALL_THE_QGL_VERSION_OF_glRecti\n#define glRectiv CALL_THE_QGL_VERSION_OF_glRectiv\n#define glRects CALL_THE_QGL_VERSION_OF_glRects\n#define glRectsv CALL_THE_QGL_VERSION_OF_glRectsv\n#define glRenderMode CALL_THE_QGL_VERSION_OF_glRenderMode\n#define glRotated CALL_THE_QGL_VERSION_OF_glRotated\n#define glRotatef CALL_THE_QGL_VERSION_OF_glRotatef\n#define glScaled CALL_THE_QGL_VERSION_OF_glScaled\n#define glScalef CALL_THE_QGL_VERSION_OF_glScalef\n#define glScissor CALL_THE_QGL_VERSION_OF_glScissor\n#define glSelectBuffer CALL_THE_QGL_VERSION_OF_glSelectBuffer\n#define glShadeModel CALL_THE_QGL_VERSION_OF_glShadeModel\n#define glStencilFunc CALL_THE_QGL_VERSION_OF_glStencilFunc\n#define glStencilMask CALL_THE_QGL_VERSION_OF_glStencilMask\n#define glStencilOp CALL_THE_QGL_VERSION_OF_glStencilOp\n#define glTexCoord1d CALL_THE_QGL_VERSION_OF_glTexCoord1d\n#define glTexCoord1dv CALL_THE_QGL_VERSION_OF_glTexCoord1dv\n#define glTexCoord1f CALL_THE_QGL_VERSION_OF_glTexCoord1f\n#define glTexCoord1fv CALL_THE_QGL_VERSION_OF_glTexCoord1fv\n#define glTexCoord1i CALL_THE_QGL_VERSION_OF_glTexCoord1i\n#define glTexCoord1iv CALL_THE_QGL_VERSION_OF_glTexCoord1iv\n#define glTexCoord1s CALL_THE_QGL_VERSION_OF_glTexCoord1s\n#define glTexCoord1sv CALL_THE_QGL_VERSION_OF_glTexCoord1sv\n#define glTexCoord2d CALL_THE_QGL_VERSION_OF_glTexCoord2d\n#define glTexCoord2dv CALL_THE_QGL_VERSION_OF_glTexCoord2dv\n#define glTexCoord2f CALL_THE_QGL_VERSION_OF_glTexCoord2f\n#define glTexCoord2fv CALL_THE_QGL_VERSION_OF_glTexCoord2fv\n#define glTexCoord2i CALL_THE_QGL_VERSION_OF_glTexCoord2i\n#define glTexCoord2iv CALL_THE_QGL_VERSION_OF_glTexCoord2iv\n#define glTexCoord2s CALL_THE_QGL_VERSION_OF_glTexCoord2s\n#define glTexCoord2sv CALL_THE_QGL_VERSION_OF_glTexCoord2sv\n#define glTexCoord3d CALL_THE_QGL_VERSION_OF_glTexCoord3d\n#define glTexCoord3dv CALL_THE_QGL_VERSION_OF_glTexCoord3dv\n#define glTexCoord3f CALL_THE_QGL_VERSION_OF_glTexCoord3f\n#define glTexCoord3fv CALL_THE_QGL_VERSION_OF_glTexCoord3fv\n#define glTexCoord3i CALL_THE_QGL_VERSION_OF_glTexCoord3i\n#define glTexCoord3iv CALL_THE_QGL_VERSION_OF_glTexCoord3iv\n#define glTexCoord3s CALL_THE_QGL_VERSION_OF_glTexCoord3s\n#define glTexCoord3sv CALL_THE_QGL_VERSION_OF_glTexCoord3sv\n#define glTexCoord4d CALL_THE_QGL_VERSION_OF_glTexCoord4d\n#define glTexCoord4dv CALL_THE_QGL_VERSION_OF_glTexCoord4dv\n#define glTexCoord4f CALL_THE_QGL_VERSION_OF_glTexCoord4f\n#define glTexCoord4fv CALL_THE_QGL_VERSION_OF_glTexCoord4fv\n#define glTexCoord4i CALL_THE_QGL_VERSION_OF_glTexCoord4i\n#define glTexCoord4iv CALL_THE_QGL_VERSION_OF_glTexCoord4iv\n#define glTexCoord4s CALL_THE_QGL_VERSION_OF_glTexCoord4s\n#define glTexCoord4sv CALL_THE_QGL_VERSION_OF_glTexCoord4sv\n#define glTexCoordPointer CALL_THE_QGL_VERSION_OF_glTexCoordPointer\n#define glTexEnvf CALL_THE_QGL_VERSION_OF_glTexEnvf\n#define glTexEnvfv CALL_THE_QGL_VERSION_OF_glTexEnvfv\n#define glTexEnvi CALL_THE_QGL_VERSION_OF_glTexEnvi\n#define glTexEnviv CALL_THE_QGL_VERSION_OF_glTexEnviv\n#define glTexGend CALL_THE_QGL_VERSION_OF_glTexGend\n#define glTexGendv CALL_THE_QGL_VERSION_OF_glTexGendv\n#define glTexGenf CALL_THE_QGL_VERSION_OF_glTexGenf\n#define glTexGenfv CALL_THE_QGL_VERSION_OF_glTexGenfv\n#define glTexGeni CALL_THE_QGL_VERSION_OF_glTexGeni\n#define glTexGeniv CALL_THE_QGL_VERSION_OF_glTexGeniv\n#define glTexImage1D CALL_THE_QGL_VERSION_OF_glTexImage1D\n#define glTexImage2D CALL_THE_QGL_VERSION_OF_glTexImage2D\n#define glTexParameterf CALL_THE_QGL_VERSION_OF_glTexParameterf\n#define glTexParameterfv CALL_THE_QGL_VERSION_OF_glTexParameterfv\n#define glTexParameteri CALL_THE_QGL_VERSION_OF_glTexParameteri\n#define glTexParameteriv CALL_THE_QGL_VERSION_OF_glTexParameteriv\n#define glTexSubImage1D CALL_THE_QGL_VERSION_OF_glTexSubImage1D\n#define glTexSubImage2D CALL_THE_QGL_VERSION_OF_glTexSubImage2D\n#define glTranslated CALL_THE_QGL_VERSION_OF_glTranslated\n#define glTranslatef CALL_THE_QGL_VERSION_OF_glTranslatef\n#define glVertex2d CALL_THE_QGL_VERSION_OF_glVertex2d\n#define glVertex2dv CALL_THE_QGL_VERSION_OF_glVertex2dv\n#define glVertex2f CALL_THE_QGL_VERSION_OF_glVertex2f\n#define glVertex2fv CALL_THE_QGL_VERSION_OF_glVertex2fv\n#define glVertex2i CALL_THE_QGL_VERSION_OF_glVertex2i\n#define glVertex2iv CALL_THE_QGL_VERSION_OF_glVertex2iv\n#define glVertex2s CALL_THE_QGL_VERSION_OF_glVertex2s\n#define glVertex2sv CALL_THE_QGL_VERSION_OF_glVertex2sv\n#define glVertex3d CALL_THE_QGL_VERSION_OF_glVertex3d\n#define glVertex3dv CALL_THE_QGL_VERSION_OF_glVertex3dv\n#define glVertex3f CALL_THE_QGL_VERSION_OF_glVertex3f\n#define glVertex3fv CALL_THE_QGL_VERSION_OF_glVertex3fv\n#define glVertex3i CALL_THE_QGL_VERSION_OF_glVertex3i\n#define glVertex3iv CALL_THE_QGL_VERSION_OF_glVertex3iv\n#define glVertex3s CALL_THE_QGL_VERSION_OF_glVertex3s\n#define glVertex3sv CALL_THE_QGL_VERSION_OF_glVertex3sv\n#define glVertex4d CALL_THE_QGL_VERSION_OF_glVertex4d\n#define glVertex4dv CALL_THE_QGL_VERSION_OF_glVertex4dv\n#define glVertex4f CALL_THE_QGL_VERSION_OF_glVertex4f\n#define glVertex4fv CALL_THE_QGL_VERSION_OF_glVertex4fv\n#define glVertex4i CALL_THE_QGL_VERSION_OF_glVertex4i\n#define glVertex4iv CALL_THE_QGL_VERSION_OF_glVertex4iv\n#define glVertex4s CALL_THE_QGL_VERSION_OF_glVertex4s\n#define glVertex4sv CALL_THE_QGL_VERSION_OF_glVertex4sv\n#define glVertexPointer CALL_THE_QGL_VERSION_OF_glVertexPointer\n#define glViewport CALL_THE_QGL_VERSION_OF_glViewport\n"
  },
  {
    "path": "code/macosx/macosx_sndcore.m",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n// mac_snddma.c\n// all other sound mixing is portable\n\n#include \"../client/snd_local.h\"\n\n#include <CoreServices/CoreServices.h>\n#include <CoreAudio/AudioHardware.h>\n#include <QuickTime/QuickTime.h>\n\n// For 'ri'\n#include \"../renderer/tr_local.h\"\n\n#import <Foundation/NSData.h>\n#import <Foundation/NSString.h>\n\nstatic unsigned int  submissionChunk;\nstatic unsigned int  maxMixedSamples;\nstatic short       *s_mixedSamples;\nstatic int          s_chunkCount;\t\t// number of chunks submitted\nstatic qboolean     s_isRunning;\n\nstatic AudioDeviceID outputDeviceID;\nstatic AudioStreamBasicDescription outputStreamBasicDescription;\n\n/*\n===============\naudioDeviceIOProc\n===============\n*/\n\nOSStatus audioDeviceIOProc(AudioDeviceID inDevice,\n                           const AudioTimeStamp *inNow,\n                           const AudioBufferList *inInputData,\n                           const AudioTimeStamp *inInputTime,\n                           AudioBufferList *outOutputData,\n                           const AudioTimeStamp *inOutputTime,\n                           void *inClientData)\n{\n    int           offset;\n    short        *samples;\n    unsigned int  sampleIndex;\n    float        *outBuffer;\n    float         scale, temp;\n\n    offset = ( s_chunkCount * submissionChunk ) % maxMixedSamples;\n    samples = s_mixedSamples + offset;\n\n    assert(outOutputData->mNumberBuffers == 1);\n    assert(outOutputData->mBuffers[0].mNumberChannels == 2);\n    //assert(outOutputData->mBuffers[0].mDataByteSize == (dma.submission_chunk * sizeof(float)));\n\n    outBuffer = (float *)outOutputData->mBuffers[0].mData;\n    \n    // If we have run out of samples, return silence\n    if (s_chunkCount * submissionChunk > dma.channels * s_paintedtime) {\n        memset(outBuffer, 0, sizeof(*outBuffer) * dma.submission_chunk);\n    } else {\n        scale = (1.0f / SHRT_MAX);\n        if (outputStreamBasicDescription.mSampleRate == 44100  && dma.speed == 22050) {\n            for (sampleIndex = 0; sampleIndex < dma.submission_chunk; sampleIndex+=2) {\n                // Convert the samples from shorts to floats.  Scale the floats to be [-1..1].\n                temp = samples[sampleIndex + 0] * scale;\n                outBuffer[(sampleIndex<<1)+0] = temp;\n                outBuffer[(sampleIndex<<1)+2] = temp;\n\n                temp = samples[sampleIndex + 1] * scale;\n                outBuffer[(sampleIndex<<1)+1] = temp;\n                outBuffer[(sampleIndex<<1)+3] = temp;\n            }\n        } else if (outputStreamBasicDescription.mSampleRate == 44100  && dma.speed == 11025) {\n            for (sampleIndex = 0; sampleIndex < dma.submission_chunk; sampleIndex+=4) {\n                // Convert the samples from shorts to floats.  Scale the floats to be [-1..1].\n                temp = samples[sampleIndex + 0] * scale;\n                outBuffer[(sampleIndex<<1)+0] = temp;\n                outBuffer[(sampleIndex<<1)+2] = temp;\n                outBuffer[(sampleIndex<<1)+4] = temp;\n                outBuffer[(sampleIndex<<1)+6] = temp;\n\n                temp = samples[sampleIndex + 1] * scale;\n                outBuffer[(sampleIndex<<1)+1] = temp;\n                outBuffer[(sampleIndex<<1)+3] = temp;\n                outBuffer[(sampleIndex<<1)+5] = temp;\n                outBuffer[(sampleIndex<<1)+7] = temp;\n            }\n        } else {\n            for (sampleIndex = 0; sampleIndex < dma.submission_chunk; sampleIndex++) {\n                // Convert the samples from shorts to floats.  Scale the floats to be [-1..1].\n                outBuffer[sampleIndex] = samples[sampleIndex] * scale;\n            }\n        }\n    }\n    \n    s_chunkCount++; // this is the next buffer we will submit\n    return 0;\n}\n\n\n/*\n===============\nS_MakeTestPattern\n===============\n*/\nvoid S_MakeTestPattern( void ) {\n    int i;\n    float v;\n    int sample;\n    \n    for ( i = 0 ; i < dma.samples / 2 ; i ++ ) {\n        v = sin( M_PI * 2 * i / 64 );\n        sample = v * 0x4000;\n        ((short *)dma.buffer)[i*2] = sample;\t\n        ((short *)dma.buffer)[i*2+1] = sample;\t\n    }\n}\n\n/*\n===============\nSNDDMA_Init\n===============\n*/\nqboolean SNDDMA_Init(void)\n{\n    cvar_t *bufferSize;\n    cvar_t *chunkSize;\n    OSStatus status;\n    UInt32 propertySize, bufferByteCount;\n\n    if (s_isRunning)\n        return qtrue;\n        \n    chunkSize = ri.Cvar_Get( \"s_chunksize\", \"2048\", CVAR_ARCHIVE );\n    bufferSize = ri.Cvar_Get( \"s_buffersize\", \"16384\", CVAR_ARCHIVE );\n    Com_Printf(\" Chunk size = %d\\n\", chunkSize->integer);\n    Com_Printf(\"Buffer size = %d\\n\", bufferSize->integer);\n\n    if (!chunkSize->integer)\n        ri.Error(ERR_FATAL, \"s_chunksize must be non-zero\\n\");\n    if (!bufferSize->integer)\n        ri.Error(ERR_FATAL, \"s_buffersize must be non-zero\\n\");\n    if (chunkSize->integer >= bufferSize->integer)\n        ri.Error(ERR_FATAL, \"s_chunksize must be less than s_buffersize\\n\");\n    if (bufferSize->integer % chunkSize->integer)\n        ri.Error(ERR_FATAL, \"s_buffersize must be an even multiple of s_chunksize\\n\");\n\n    // Get the output device\n    propertySize = sizeof(outputDeviceID);\n    status = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &propertySize, &outputDeviceID);\n    if (status) {\n        Com_Printf(\"AudioHardwareGetProperty returned %d\\n\", status);\n        return qfalse;\n    }\n\t\n    if (outputDeviceID == kAudioDeviceUnknown) {\n        Com_Printf(\"AudioHardwareGetProperty: outputDeviceID is kAudioDeviceUnknown\\n\");\n        return qfalse;\n    }\n\n    // Configure the output device\t\n    propertySize = sizeof(bufferByteCount);\n    bufferByteCount = chunkSize->integer * sizeof(float);\n    status = AudioDeviceSetProperty(outputDeviceID, NULL, 0, NO, kAudioDevicePropertyBufferSize, propertySize, &bufferByteCount);\n    if (status) {\n        Com_Printf(\"AudioDeviceSetProperty: returned %d when setting kAudioDevicePropertyBufferSize to %d\\n\", status, chunkSize->integer);\n        return qfalse;\n    }\n    \n    propertySize = sizeof(bufferByteCount);\n    status = AudioDeviceGetProperty(outputDeviceID, 0, NO, kAudioDevicePropertyBufferSize, &propertySize, &bufferByteCount);\n    if (status) {\n        Com_Printf(\"AudioDeviceGetProperty: returned %d when setting kAudioDevicePropertyBufferSize\\n\", status);\n        return qfalse;\n    }\n\n    // Print out the device status\n    propertySize = sizeof(outputStreamBasicDescription);\n    status = AudioDeviceGetProperty(outputDeviceID, 0, NO, kAudioDevicePropertyStreamFormat, &propertySize, &outputStreamBasicDescription);\n    if (status) {\n        Com_Printf(\"AudioDeviceGetProperty: returned %d when getting kAudioDevicePropertyStreamFormat\\n\", status);\n        return qfalse;\n    }\n\n    Com_Printf(\"Hardware format:\\n\");\n    Com_Printf(\"  %f mSampleRate\\n\", outputStreamBasicDescription.mSampleRate);\n    Com_Printf(\"  %c%c%c%c mFormatID\\n\",\n               (outputStreamBasicDescription.mFormatID & 0xff000000) >> 24,\n               (outputStreamBasicDescription.mFormatID & 0x00ff0000) >> 16,\n               (outputStreamBasicDescription.mFormatID & 0x0000ff00) >>  8,\n               (outputStreamBasicDescription.mFormatID & 0x000000ff) >>  0);\n    Com_Printf(\"  %5d mBytesPerPacket\\n\", outputStreamBasicDescription.mBytesPerPacket);\n    Com_Printf(\"  %5d mFramesPerPacket\\n\", outputStreamBasicDescription.mFramesPerPacket);\n    Com_Printf(\"  %5d mBytesPerFrame\\n\", outputStreamBasicDescription.mBytesPerFrame);\n    Com_Printf(\"  %5d mChannelsPerFrame\\n\", outputStreamBasicDescription.mChannelsPerFrame);\n    Com_Printf(\"  %5d mBitsPerChannel\\n\", outputStreamBasicDescription.mBitsPerChannel);\n\n    if(outputStreamBasicDescription.mFormatID != kAudioFormatLinearPCM) {\n            Com_Printf(\"Default Audio Device doesn't support Linear PCM!\");\n            return qfalse;\n    }\n    \n    // Start sound running\n    status = AudioDeviceAddIOProc(outputDeviceID, audioDeviceIOProc, NULL);\n    if (status) {\n        Com_Printf(\"AudioDeviceAddIOProc: returned %d\\n\", status);\n        return qfalse;\n    }\n\n    submissionChunk = chunkSize->integer;\n    if (outputStreamBasicDescription.mSampleRate == 44100) {\n        submissionChunk = chunkSize->integer/2;\n    }\n    maxMixedSamples = bufferSize->integer;\n    s_mixedSamples = calloc(1, sizeof(*s_mixedSamples) * maxMixedSamples);\n    Com_Printf(\"Chunk Count = %d\\n\", (maxMixedSamples / submissionChunk));\n    \n    // Tell the main app what we expect from it\n    dma.samples = maxMixedSamples;\n    dma.submission_chunk = submissionChunk;\n    dma.samplebits = 16;\n    dma.buffer = (byte *)s_mixedSamples;\n    dma.channels = outputStreamBasicDescription.mChannelsPerFrame;\n    dma.speed = 22050;\t//(unsigned long)outputStreamBasicDescription.mSampleRate;\n\n    // We haven't enqueued anything yet\n    s_chunkCount = 0;\n\n    status = AudioDeviceStart(outputDeviceID, audioDeviceIOProc);\n    if (status) {\n        Com_Printf(\"AudioDeviceStart: returned %d\\n\", status);\n        return qfalse;\n    }\n\n    s_isRunning = qtrue;\n    \n    return qtrue;\n}\n\n/*\n===============\nSNDDMA_GetBufferDuration\n===============\n*/\nfloat SNDDMA_GetBufferDuration(void)\n{\n    return (float)dma.samples / (float)(dma.channels * dma.speed);\n}\n\n/*\n===============\nSNDDMA_GetDMAPos\n===============\n*/\nint SNDDMA_GetDMAPos(void)\n{\n    return s_chunkCount * dma.submission_chunk;\n}\n\n/*\n===============\nSNDDMA_Shutdown\n===============\n*/\nvoid SNDDMA_Shutdown(void)\n{\n    OSStatus status;\n    \n    if (!s_isRunning)\n        return;\n        \n    status = AudioDeviceStop(outputDeviceID, audioDeviceIOProc);\n    if (status) {\n        Com_Printf(\"AudioDeviceStop: returned %d\\n\", status);\n        return;\n    }\n    \n    s_isRunning = qfalse;\n    \n    status = AudioDeviceRemoveIOProc(outputDeviceID, audioDeviceIOProc);\n    if (status) {\n        Com_Printf(\"AudioDeviceRemoveIOProc: returned %d\\n\", status);\n        return;\n    }\n    \n    free(s_mixedSamples);\n    s_mixedSamples = NULL;\n    dma.samples = NULL;\n}\n\n/*\n===============\nSNDDMA_BeginPainting\n===============\n*/\nvoid SNDDMA_BeginPainting(void) {\n}\n\n/*\n===============\nSNDDMA_Submit\n===============\n*/\nvoid SNDDMA_Submit(void) {\n}\n\n"
  },
  {
    "path": "code/macosx/macosx_snddma.m",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n// mac_snddma.c\n// all other sound mixing is portable\n\n#include \"../client/snd_local.h\"\n#include <Carbon/Carbon.h>\n\n// For 'ri'\n#include \"../renderer/tr_local.h\"\n\n#import <Foundation/NSZone.h>\n\n// TJW - Different versions of SoundManager have different DMA buffer sizes.  On MacOS X DP2,\n// the buffer size is 8K.  On MacOS 9 it is much smaller.  The SoundManager guy at Apple says\n// that the size of the buffer will be decreasing for final release to help get rid of latency.\n//#define\tMAX_MIXED_SAMPLES\t(0x8000 * 64)\n//#define\tSUBMISSION_CHUNK\t (0x100 * 64)\n\n// Original MacOS 9 sizes\n//#define\tMAX_MIXED_SAMPLES\t0x8000\n//#define\tSUBMISSION_CHUNK\t 0x100 \n\n\nstatic unsigned int submissionChunk;\nstatic unsigned int maxMixedSamples;\n\nstatic\tshort\t\t*s_mixedSamples;\nstatic\tint\t\t\t\t s_chunkCount;\t\t// number of chunks submitted\nstatic\tSndChannel\t\t*s_sndChan;\nstatic\tExtSoundHeader\ts_sndHeader;\n\n/*\n===============\nS_Callback\n===============\n*/\nvoid S_Callback( SndChannel *sc, SndCommand *cmd )\n{\n    SndCommand\t\tmySndCmd;\n    SndCommand\t\tmySndCmd2;\n    int\t\t\t\toffset;\n\n    offset = ( s_chunkCount * submissionChunk ) & (maxMixedSamples-1);\n\n    // queue up another sound buffer\n    memset( &s_sndHeader, 0, sizeof( s_sndHeader ) );\n    s_sndHeader.samplePtr = (void *)(s_mixedSamples + offset);\n    s_sndHeader.numChannels = 2;\n    s_sndHeader.sampleRate = rate22khz;\n    s_sndHeader.loopStart = 0;\n    s_sndHeader.loopEnd = 0;\n    s_sndHeader.encode = extSH;\n    s_sndHeader.baseFrequency = 1;\n    s_sndHeader.numFrames = submissionChunk / 2;\n    s_sndHeader.markerChunk = NULL;\n    s_sndHeader.instrumentChunks = NULL;\n    s_sndHeader.AESRecording = NULL;\n    s_sndHeader.sampleSize = 16;\n\n    mySndCmd.cmd = bufferCmd;\n    mySndCmd.param1 = 0;\n    mySndCmd.param2 = (int)&s_sndHeader;\n    SndDoCommand( sc, &mySndCmd, true );\n\n    // and another callback\n    mySndCmd2.cmd = callBackCmd;\n    mySndCmd2.param1 = 0;\n    mySndCmd2.param2 = 0;\n    SndDoCommand( sc, &mySndCmd2, true );\n\n    s_chunkCount++;\t\t// this is the next buffer we will submit\n}\n\n/*\n===============\nS_MakeTestPattern\n===============\n*/\nvoid S_MakeTestPattern( void ) {\n\tint\t\ti;\n\tfloat\tv;\n\tint\t\tsample;\n\t\n\tfor ( i = 0 ; i < dma.samples / 2 ; i ++ ) {\n\t\tv = sin( M_PI * 2 * i / 64 );\n\t\tsample = v * 0x4000;\n\t\t((short *)dma.buffer)[i*2] = sample;\t\n\t\t((short *)dma.buffer)[i*2+1] = sample;\t\n\t}\n}\n\n/*\n===============\nSNDDMA_Init\n===============\n*/\nqboolean SNDDMA_Init(void)\n{\n    int\t\terr;\n    cvar_t *bufferSize;\n    cvar_t *chunkSize;\n\n    chunkSize = ri.Cvar_Get( \"s_chunksize\", \"8192\", CVAR_ARCHIVE );\n    bufferSize = ri.Cvar_Get( \"s_buffersize\", \"65536\", CVAR_ARCHIVE );\n\n    if (!chunkSize->integer) {\n        ri.Error(ERR_FATAL, \"snd_chunkSize must be non-zero\\n\");\n    }\n\n    if (!bufferSize->integer) {\n        ri.Error(ERR_FATAL, \"snd_bufferSize must be non-zero\\n\");\n    }\n\n    if (chunkSize->integer >= bufferSize->integer) {\n        ri.Error(ERR_FATAL, \"snd_chunkSize must be less than snd_bufferSize\\n\");\n    }\n\n    if (bufferSize->integer % chunkSize->integer) {\n        ri.Error(ERR_FATAL, \"snd_bufferSize must be an even multiple of snd_chunkSize\\n\");\n    }\n\n    // create a sound channel\n    s_sndChan = NULL;\n    err = SndNewChannel( &s_sndChan, sampledSynth, initStereo, NewSndCallBackProc(S_Callback) );\n    if ( err ) {\n        return false;\n    }\n\n    submissionChunk = chunkSize->integer;\n    maxMixedSamples = bufferSize->integer;\n\n    s_mixedSamples = NSZoneMalloc(NULL, sizeof(*s_mixedSamples) * maxMixedSamples);\n    \n    dma.channels = 2;\n    dma.samples = maxMixedSamples;\n    dma.submission_chunk = submissionChunk;\n    dma.samplebits = 16;\n    dma.speed = 22050;\n    dma.buffer = (byte *)s_mixedSamples;\n\n    // que up the first submission-chunk sized buffer\n    s_chunkCount = 0;\n\n    S_Callback( s_sndChan, NULL );\n\n    return qtrue;\n}\n\n/*\n===============\nSNDDMA_GetDMAPos\n===============\n*/\nint\tSNDDMA_GetDMAPos(void) {\n    return s_chunkCount * submissionChunk;\n}\n\n/*\n===============\nSNDDMA_Shutdown\n===============\n*/\nvoid SNDDMA_Shutdown(void) {\n\tif ( s_sndChan ) {\n\t\tSndDisposeChannel( s_sndChan, true );\n\t\ts_sndChan = NULL;\n\t}\n}\n\n/*\n===============\nSNDDMA_BeginPainting\n===============\n*/\nvoid SNDDMA_BeginPainting(void) {\n}\n\n/*\n===============\nSNDDMA_Submit\n===============\n*/\nvoid SNDDMA_Submit(void) {\n}\n"
  },
  {
    "path": "code/macosx/macosx_sys.m",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#import \"../client/client.h\"\n#import \"macosx_local.h\"\n\n#import \"dlfcn.h\"\n#import \"Q3Controller.h\"\n\n#import <AppKit/AppKit.h>\n#import <IOKit/IOKitLib.h>\n#import <IOKit/IOBSD.h>\n#import <IOKit/storage/IOCDMedia.h>\n#import <mach/mach_error.h>\n\n#import <sys/types.h>\n#import <unistd.h>\n#import <sys/param.h>\n#import <sys/mount.h>\n#import <sys/sysctl.h>\n\n#ifdef OMNI_TIMER\n#import \"macosx_timers.h\"\n#endif\n\nqboolean stdin_active = qfalse;\n\n//===========================================================================\n\nint main(int argc, const char *argv[]) {\n#ifdef DEDICATED\n    Q3Controller *controller;\n    \n    stdin_active = qtrue;\n    controller = [[Q3Controller alloc] init];\n    [controller quakeMain];\n    return 0;\n#else\n    return NSApplicationMain(argc, argv);\n#endif\n}\n\n//===========================================================================\n\n/*\n=================\nSys_UnloadDll\n\n=================\n*/\nvoid Sys_UnloadDll( void *dllHandle ) {\n\tif ( !dllHandle ) {\n\t\treturn;\n\t}\n\tdlclose( dllHandle );\n}\n\n/*\n=================\nSys_LoadDll\n\nUsed to load a development dll instead of a virtual machine\n=================\n*/\nextern char\t\t*FS_BuildOSPath( const char *base, const char *game, const char *qpath );\n\nvoid\t* QDECL Sys_LoadDll( const char *name, char *fqpath , int (QDECL **entryPoint)(int, ...),\n\t\t\t\t  int (QDECL *systemcalls)(int, ...) ) {\n    void *libHandle;\n    void\t(*dllEntry)( int (*syscallptr)(int, ...) );\n    NSString *bundlePath, *libraryPath;\n    const char *path;\n    \n\t// TTimo\n\t// I don't understand the search strategy here. How can the Quake3 bundle know about the location\n\t// of the other bundles? is that configured somewhere in XCode?\n\t/*\n    bundlePath = [[NSBundle mainBundle] pathForResource: [NSString stringWithCString: name] ofType: @\"bundle\"];\n    libraryPath = [NSString stringWithFormat: @\"%@/Contents/MacOS/%s\", bundlePath, name];\n\t*/\t\n\tlibraryPath = [NSString stringWithFormat: @\"%s.bundle/Contents/MacOS/%s\", name, name];\n    if (!libraryPath)\n        return NULL;\n    \n    path = [libraryPath cString];\n    Com_Printf(\"Loading '%s'.\\n\", path);\n    libHandle = dlopen( [libraryPath cString], RTLD_LAZY );\n    if (!libHandle) {\n        libHandle = dlopen( name, RTLD_LAZY );\n        if (!libHandle) {\n            Com_Printf(\"Error loading dll: %s\\n\", dlerror());\n            return NULL;\n        }\n    }\n\n    dllEntry = dlsym( libHandle, \"_dllEntry\" );\n    if (!dllEntry) {\n        Com_Printf(\"Error loading dll:  No dllEntry symbol.\\n\");\n        dlclose(libHandle);\n        return NULL;\n    }\n    \n    *entryPoint = dlsym( libHandle, \"_vmMain\" );\n    if (!*entryPoint) {\n        Com_Printf(\"Error loading dll:  No vmMain symbol.\\n\");\n        dlclose(libHandle);\n        return NULL;\n    }\n    \n    dllEntry(systemcalls);\n    return libHandle;\n}\n\n//===========================================================================\n\nchar *Sys_GetClipboardData(void) // FIXME\n{\n    NSPasteboard *pasteboard;\n    NSArray *pasteboardTypes;\n\n    pasteboard = [NSPasteboard generalPasteboard];\n    pasteboardTypes = [pasteboard types];\n    if ([pasteboardTypes containsObject:NSStringPboardType]) {\n        NSString *clipboardString;\n\n        clipboardString = [pasteboard stringForType:NSStringPboardType];\n        if (clipboardString && [clipboardString length] > 0) {\n            return strdup([clipboardString cString]);\n        }\n    }\n    return NULL;\n}\n\nchar *Sys_GetWholeClipboard ( void )\n{\n    return NULL;\n}\n\nvoid Sys_SetClipboard (const char *contents)\n{\n}\n\n\n/*\n==================\nSys_FunctionCheckSum\n==================\n*/\nint Sys_FunctionCheckSum(void *f1) {\n\treturn 0;\n}\n\n/*\n==================\nSys_MonkeyShouldBeSpanked\n==================\n*/\nint Sys_MonkeyShouldBeSpanked( void ) {\n\treturn 0;\n}\n\n//===========================================================================\n\nvoid Sys_BeginProfiling(void)\n{\n}\n\nvoid Sys_EndProfiling(void)\n{\n}\n\n//===========================================================================\n\n/*\n================\nSys_Init\n\nThe cvar and file system has been setup, so configurations are loaded\n================\n*/\nvoid Sys_Init(void)\n{\n#ifdef OMNI_TIMER\n    InitializeTimers();\n    OTStackPushRoot(rootNode);\n#endif\n\n    NET_Init();\n    Sys_InitInput();\t\n}\n\n/*\n=================\nSys_Shutdown\n=================\n*/\nvoid Sys_Shutdown(void)\n{\n    Com_Printf( \"----- Sys_Shutdown -----\\n\" );\n    Sys_EndProfiling();\n    Sys_ShutdownInput();\t\n    Com_Printf( \"------------------------\\n\" );\n}\n\nvoid Sys_Error(const char *error, ...)\n{\n    va_list argptr;\n    NSString *formattedString;\n\n    Sys_Shutdown();\n\n    va_start(argptr,error);\n    formattedString = [[NSString alloc] initWithFormat:[NSString stringWithCString:error] arguments:argptr];\n    va_end(argptr);\n\n    NSLog(@\"Sys_Error: %@\", formattedString);\n    NSRunAlertPanel(@\"Quake 3 Error\", formattedString, nil, nil, nil);\n\n    Sys_Quit();\n}\n\nvoid Sys_Quit(void)\n{\n    Sys_Shutdown();\n    [NSApp terminate:nil];\n}\n\n/*\n================\nSys_Print\n\nThis is called for all console output, even if the game is running\nfull screen and the dedicated console window is hidden.\n================\n*/\n\nchar *ansiColors[8] =\n\t{ \"\\033[30m\" ,\t/* ANSI Black */\n\t  \"\\033[31m\" ,\t/* ANSI Red */\n\t  \"\\033[32m\" ,\t/* ANSI Green */\n\t  \"\\033[33m\" ,  /* ANSI Yellow */\n\t  \"\\033[34m\" ,\t/* ANSI Blue */\n\t  \"\\033[36m\" ,  /* ANSI Cyan */\n\t  \"\\033[35m\" ,\t/* ANSI Magenta */\n\t  \"\\033[37m\" }; /* ANSI White */\n\t  \nvoid Sys_Print(const char *text)\n{\n#if 0\n\t/* Okay, this is a stupid hack, but what the hell, I was bored. ;) */\n\tconst char *scan = text;\n\tint index;\n\t\n\t/* Make sure terminal mode is reset at the start of the line... */\n\tfputs(\"\\033[0m\", stdout);\n\t\n\twhile(*scan) {\n\t\t/* See if we have a color control code.  If so, snarf the character, \n\t\tprint what we have so far, print the ANSI Terminal color code,\n\t\tskip over the color control code and continue */\n\t\tif(Q_IsColorString(scan)) {\n\t\t\tindex = ColorIndex(scan[1]);\n\t\t\t\n\t\t\t/* Flush current message */\n\t\t\tif(scan != text) {\n\t\t\t\tfwrite(text, scan - text, 1, stdout);\n\t\t\t}\n\t\t\t\n\t\t\t/* Write ANSI color code */\n\t\t\tfputs(ansiColors[index], stdout);\n\t\t\t\n\t\t\t/* Reset search */\n\t\t\ttext = scan+2;\n\t\t\tscan = text;\n\t\t\tcontinue;\t\t\t\n\t\t}\n\t\tscan++;\n\t}\n\n\t/* Flush whatever's left */\n\tfputs(text, stdout);\n\n\t/* Make sure terminal mode is reset at the end of the line too... */\n\tfputs(\"\\033[0m\", stdout);\n\n#else\n    fputs(text, stdout);\n#endif\t\n}\n\n\n\n/*\n================\nSys_CheckCD\n\nReturn true if the proper CD is in the drive\n================\n*/\n\nqboolean Sys_ObjectIsCDRomDevice(io_object_t object)\n{\n    CFStringRef value;\n    kern_return_t krc;\n    CFDictionaryRef properties;\n    qboolean isCDROM = qfalse;\n    io_iterator_t parentIterator;\n    io_object_t parent;\n    \n    krc = IORegistryEntryCreateCFProperties(object, &properties, kCFAllocatorDefault, (IOOptionBits)0);\n    if (krc != KERN_SUCCESS) {\n        fprintf(stderr, \"IORegistryEntryCreateCFProperties returned 0x%08x -- %s\\n\", krc, mach_error_string(krc));\n        return qfalse;\n    }\n\n    //NSLog(@\"properties = %@\", properties);\n    \n    // See if this is a CD-ROM\n    value = CFDictionaryGetValue(properties, CFSTR(kIOCDMediaTypeKey));\n    if (value && CFStringCompare(value, CFSTR(\"CD-ROM\"), 0) == kCFCompareEqualTo)\n        isCDROM = qtrue;\n    CFRelease(properties);\n\n    // If it isn't check each of its parents.  It seems that the parent enumerator only returns the immediate parent.  Maybe the plural indicates that an object can have multiple direct parents.  So, we'll call ourselves recursively for each parent.\n    if (!isCDROM) {\n        krc = IORegistryEntryGetParentIterator(object, kIOServicePlane, &parentIterator);\n        if (krc != KERN_SUCCESS) {\n            fprintf(stderr, \"IOServiceGetMatchingServices returned 0x%08x -- %s\\n\",\n                    krc, mach_error_string(krc));\n        } else {\n            while (!isCDROM && (parent = IOIteratorNext(parentIterator))) {\n                if (Sys_ObjectIsCDRomDevice(parent))\n                    isCDROM = qtrue;\n                IOObjectRelease(parent);\n            }\n    \n            IOObjectRelease(parentIterator);\n        }\n    }\n    \n    //NSLog(@\"Sys_ObjectIsCDRomDevice -> %d\", isCDROM);\n    return isCDROM;\n}\n\nqboolean Sys_IsCDROMDevice(const char *deviceName)\n{\n    kern_return_t krc;\n    io_iterator_t deviceIterator;\n    mach_port_t masterPort;\n    io_object_t object;\n    qboolean isCDROM = qfalse;\n    \n    krc = IOMasterPort(bootstrap_port, &masterPort);\n    if (krc != KERN_SUCCESS) {\n        fprintf(stderr, \"IOMasterPort returned 0x%08x -- %s\\n\", krc, mach_error_string(krc));\n        return qfalse;\n    }\n\n    // Get an iterator for this BSD device.  If it is a CD, it will likely only be one partition of the larger CD-ROM device.\n    krc = IOServiceGetMatchingServices(masterPort,\n                                       IOBSDNameMatching(masterPort, 0, deviceName),\n                                       &deviceIterator);\n    if (krc != KERN_SUCCESS) {\n        fprintf(stderr, \"IOServiceGetMatchingServices returned 0x%08x -- %s\\n\",\n                krc, mach_error_string(krc));\n        return qfalse;\n    }\n\n    while (!isCDROM && (object = IOIteratorNext(deviceIterator))) {\n        if (Sys_ObjectIsCDRomDevice(object)) {\n            isCDROM = qtrue;\n        }\n        IOObjectRelease(object);\n    }\n    \n    IOObjectRelease(deviceIterator);\n\n    //NSLog(@\"Sys_IsCDROMDevice -> %d\", isCDROM);\n    return isCDROM;\n}\n\nqboolean        Sys_CheckCD( void )\n{\n    // DO NOT just return success here if we have a library directory.\n    // Actually look for the CD.\n\n    // We'll look through the actual mount points rather than just looking\n    // for a particular directory since (a) the mount point may change\n    // between OS version (/foo in Public Beta, /Volumes/foo after Public Beta)\n    // and (b) this way someone can't just create a directory and warez the files.\n    \n    unsigned int mountCount;\n    struct statfs  *mounts;\n    \n    mountCount = getmntinfo(&mounts, MNT_NOWAIT);\n    if (mountCount <= 0) {\n        perror(\"getmntinfo\");\n#if 1 // Q3:TA doesn't need a CD, but we still need to locate it to allow for partial installs\n        return qtrue;\n#else\n        return qfalse;\n#endif\n    }\n    \n    while (mountCount--) {\n        const char *lastComponent;\n        \n        if ((mounts[mountCount].f_flags & MNT_RDONLY) != MNT_RDONLY) {\n            // Should have been a read only CD... this isn't it\n            continue;\n        }\n        \n        if ((mounts[mountCount].f_flags & MNT_LOCAL) != MNT_LOCAL) {\n            // Should have been a local filesystem\n            continue;\n        }\n        \n        lastComponent = strrchr(mounts[mountCount].f_mntonname, '/');\n        if (!lastComponent) {\n            // No slash in the mount point!  How is that possible?\n            continue;\n        }\n        \n        // Skip the slash and look for the game name\n        lastComponent++;\n        if ((strcasecmp(lastComponent, \"Quake3\") != 0)) {\n            continue;\n        }\n\n            \n#if 0\n        fprintf(stderr, \"f_bsize: %d\\n\", mounts[mountCount].f_bsize);\n        fprintf(stderr, \"f_blocks: %d\\n\", mounts[mountCount].f_blocks);\n        fprintf(stderr, \"type: %d\\n\", mounts[mountCount].f_type);\n        fprintf(stderr, \"flags: %d\\n\", mounts[mountCount].f_flags);\n        fprintf(stderr, \"fstype: %s\\n\", mounts[mountCount].f_fstypename);\n        fprintf(stderr, \"f_mntonname: %s\\n\", mounts[mountCount].f_mntonname);\n        fprintf(stderr, \"f_mntfromname: %s\\n\", mounts[mountCount].f_mntfromname);\n        fprintf(stderr, \"\\n\\n\");\n#endif\n\n        lastComponent = strrchr(mounts[mountCount].f_mntfromname, '/');\n        if (!lastComponent) {\n            // No slash in the device name!  How is that possible?\n            continue;\n        }\n        lastComponent++;\n        if (!Sys_IsCDROMDevice(lastComponent))\n            continue;\n\n        // This looks good\n        Sys_SetDefaultCDPath(mounts[mountCount].f_mntonname);\n        return qtrue;\n    }\n    \n#if 1 // Q3:TA doesn't need a CD, but we still need to locate it to allow for partial installs\n    return qtrue;\n#else\n    return qfalse;\n#endif\n}\n\n\n//===================================================================\n\nvoid Sys_BeginStreamedFile( fileHandle_t f, int readAhead ) {\n}\n\nvoid Sys_EndStreamedFile( fileHandle_t f ) {\n}\n\nint Sys_StreamedRead( void *buffer, int size, int count, fileHandle_t f ) {\n\treturn FS_Read( buffer, size * count, f );\n}\n\nvoid Sys_StreamSeek( fileHandle_t f, int offset, int origin ) {\n\tFS_Seek( f, offset, origin );\n}\n\n\nvoid OutputDebugString(char * s)\n{\n#ifdef DEBUG\n    fprintf(stderr, \"%s\", s);\n#endif\n}\n\n/*\n==================\nSys_LowPhysicalMemory()\n==================\n*/\n#define MEM_THRESHOLD 96*1024*1024\n\nqboolean Sys_LowPhysicalMemory()\n{\n    return NSRealMemoryAvailable() <= MEM_THRESHOLD;\n}\n\nstatic unsigned int _Sys_ProcessorCount = 0;\n\nunsigned int Sys_ProcessorCount()\n{\n    if (!_Sys_ProcessorCount) {\n        int name[] = {CTL_HW, HW_NCPU};\n        size_t size;\n    \n        size = sizeof(_Sys_ProcessorCount);\n        if (sysctl(name, 2, &_Sys_ProcessorCount, &size, NULL, 0) < 0) {\n            perror(\"sysctl\");\n            _Sys_ProcessorCount = 1;\n        } else {\n            Com_Printf(\"System processor count is %d\\n\", _Sys_ProcessorCount);\n        }\n    }\n    \n    return _Sys_ProcessorCount;\n}\n\n"
  },
  {
    "path": "code/macosx/macosx_timers.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifdef OMNI_TIMER\n\n#import <OmniTimer/OmniTimer.h>\n\n#define OTSTART(node) OTStackPush(node)\n#define OTSTOP(node)  OTStackPop()\n\nextern OTStackNode *rootNode;\nextern OTStackNode *markFragmentsNode1;\nextern OTStackNode *markFragmentsNode2;\nextern OTStackNode *markFragmentsGrid;\nextern OTStackNode *markFragmentsNode4;\nextern OTStackNode *addMarkFragmentsNode;\nextern OTStackNode *chopPolyNode;\nextern OTStackNode *boxTraceNode;\nextern OTStackNode *boxOnPlaneSideNode;\nextern OTStackNode *recursiveWorldNode;\nextern OTStackNode *surfaceAnimNode;\nextern OTStackNode *surfaceFaceNode;\nextern OTStackNode *surfaceMeshNode;\nextern OTStackNode *surfaceEndNode;\nextern OTStackNode *shadowEndNode;\nextern OTStackNode *stageIteratorGenericNode;\nextern OTStackNode *computeColorAndTexNode;\nextern OTStackNode *mp3DecodeNode;\n\nextern void InitializeTimers();\n\n#else\n\n#define OTSTART(node)\n#define OTSTOP(node)\n\n#endif\n\n"
  },
  {
    "path": "code/macosx/macosx_timers.m",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifdef OMNI_TIMER\n\n#import \"macosx_timers.h\"\n\n#import <Foundation/NSString.h>\n#import <stdio.h>\n\nOTStackNode *rootNode;\nOTStackNode *markFragmentsNode1;\nOTStackNode *markFragmentsNode2;\nOTStackNode *markFragmentsGrid;\nOTStackNode *markFragmentsNode4;\nOTStackNode *addMarkFragmentsNode;\nOTStackNode *chopPolyNode;\nOTStackNode *boxTraceNode;\nOTStackNode *boxOnPlaneSideNode;\nOTStackNode *recursiveWorldNode;\nOTStackNode *surfaceAnimNode;\nOTStackNode *surfaceFaceNode;\nOTStackNode *surfaceMeshNode;\nOTStackNode *surfaceEndNode;\nOTStackNode *shadowEndNode;\nOTStackNode *stageIteratorGenericNode;\nOTStackNode *computeColorAndTexNode;\nOTStackNode *mp3DecodeNode;\n\nvoid InitializeTimers()\n{\n    const char *env;\n    \n    OTSetup();\n    \n    rootNode = OTStackNodeCreate(\"root\");\n    markFragmentsNode1 = OTStackNodeCreate(\"R_MarkFragments 1\");\n    markFragmentsNode2 = OTStackNodeCreate(\"R_MarkFragments 2\");\n    markFragmentsGrid = OTStackNodeCreate(\"R_MarkFragmentsGrid\");\n    markFragmentsNode4 = OTStackNodeCreate(\"R_MarkFragments 4\");\n    addMarkFragmentsNode = OTStackNodeCreate(\"R_AddMarkFragments\");\n    chopPolyNode = OTStackNodeCreate(\"R_ChopPolyBehindPlane\");\n    boxTraceNode = OTStackNodeCreate(\"CM_BoxTrace\");\n    boxOnPlaneSideNode = OTStackNodeCreate(\"BoxOnPlaneSide\");\n    recursiveWorldNode = OTStackNodeCreate(\"R_RecursiveWorldNode\");\n    surfaceAnimNode = OTStackNodeCreate(\"RB_SurfaceAnim\");\n    surfaceFaceNode = OTStackNodeCreate(\"RB_SurfaceFace\");\n    surfaceMeshNode = OTStackNodeCreate(\"RB_SurfaceMesh\");\n    surfaceEndNode = OTStackNodeCreate(\"RB_EndSurface\");\n    shadowEndNode = OTStackNodeCreate(\"RB_ShadowTessEnd\");\n    stageIteratorGenericNode = OTStackNodeCreate(\"RB_StageIteratorGeneric\");\n    computeColorAndTexNode = OTStackNodeCreate(\"ComputeColors & ComputeTexCoords\");\n    mp3DecodeNode = OTStackNodeCreate(\"MP3Stream_Decode\");\n}\n\n#endif // OMNI_TIMER\n\n"
  },
  {
    "path": "code/macosx/timedemo.zsh",
    "content": "#!/bin/zsh\n\nbuildRoot=./build\nexecutable=$buildRoot/Quake3.app/Contents/MacOS/Quake3\nls -l $executable\n\nflags=\"$flags +set timedemo 1\"\nflags=\"$flags +set s_initsound 0\"\nflags=\"$flags +set vm_cgame 1\"\nflags=\"$flags +set vm_game 1\"\nflags=\"$flags +set r_texturebits 16\"\nflags=\"$flags +set r_depthbits 16\"\nflags=\"$flags +set r_colorbits 16\"\nflags=\"$flags +set stencilbits 8\"\n\nflags=\"$flags +set r_appleTransformHint 1\"\n\necho flags=$flags\n\nfunction demo {\n    echo Demo $*\n    $executable $flags +demo $* |& egrep \"(seconds|VM)\"\n}\n\ndemo foo\n\n"
  },
  {
    "path": "code/null/mac_net.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"../game/q_shared.h\"\n#include \"../qcommon/qcommon.h\"\n\n/*\n=============\nNET_StringToAdr\n\nlocalhost\nidnewt\nidnewt:28000\n192.246.40.70\n192.246.40.70:28000\n=============\n*/\nqboolean\tNET_StringToAdr (char *s, netadr_t *a)\n{\t\n\tif (!strcmp (s, \"localhost\")) {\n\t\tmemset (a, 0, sizeof(*a));\n\t\ta->type = NA_LOOPBACK;\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\n/*\n==================\nSys_SendPacket\n==================\n*/\nvoid Sys_SendPacket( int length, void *data, netadr_t to ) {\n}\n\n/*\n==================\nSys_GetPacket\n\nNever called by the game logic, just the system event queing\n==================\n*/\nqboolean\tSys_GetPacket ( netadr_t *net_from, msg_t *net_message ) {\n\treturn false;\n}\n"
  },
  {
    "path": "code/null/null_client.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"../client/client.h\"\n\ncvar_t *cl_shownet;\n\nvoid CL_Shutdown( void ) {\n}\n\nvoid CL_Init( void ) {\n\tcl_shownet = Cvar_Get (\"cl_shownet\", \"0\", CVAR_TEMP );\n}\n\nvoid CL_MouseEvent( int dx, int dy, int time ) {\n}\n\nvoid Key_WriteBindings( fileHandle_t f ) {\n}\n\nvoid CL_Frame ( int msec ) {\n}\n\nvoid CL_PacketEvent( netadr_t from, msg_t *msg ) {\n}\n\nvoid CL_CharEvent( int key ) {\n}\n\nvoid CL_Disconnect( qboolean showMainMenu ) {\n}\n\nvoid CL_MapLoading( void ) {\n}\n\nqboolean CL_GameCommand( void ) {\n  return qfalse; // bk001204 - non-void\n}\n\nvoid CL_KeyEvent (int key, qboolean down, unsigned time) {\n}\n\nqboolean UI_GameCommand( void ) {\n\treturn qfalse;\n}\n\nvoid CL_ForwardCommandToServer( const char *string ) {\n}\n\nvoid CL_ConsolePrint( char *txt ) {\n}\n\nvoid CL_JoystickEvent( int axis, int value, int time ) {\n}\n\nvoid CL_InitKeyCommands( void ) {\n}\n\nvoid CL_CDDialog( void ) {\n}\n\nvoid CL_FlushMemory( void ) {\n}\n\nvoid CL_StartHunkUsers( void ) {\n}\n\n// bk001119 - added new dummy for sv_init.c\nvoid CL_ShutdownAll(void) {};\n\n// bk001208 - added new dummy (RC4)\nqboolean CL_CDKeyValidate( const char *key, const char *checksum ) { return qtrue; }\n"
  },
  {
    "path": "code/null/null_glimp.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"../renderer/tr_local.h\"\n\n\nqboolean ( * qwglSwapIntervalEXT)( int interval );\nvoid ( * qglMultiTexCoord2fARB )( GLenum texture, float s, float t );\nvoid ( * qglActiveTextureARB )( GLenum texture );\nvoid ( * qglClientActiveTextureARB )( GLenum texture );\n\n\nvoid ( * qglLockArraysEXT)( int, int);\nvoid ( * qglUnlockArraysEXT) ( void );\n\n\nvoid\t\tGLimp_EndFrame( void ) {\n}\n\nint \t\tGLimp_Init( void )\n{\n}\n\nvoid\t\tGLimp_Shutdown( void ) {\n}\n\nvoid\t\tGLimp_EnableLogging( qboolean enable ) {\n}\n\nvoid GLimp_LogComment( char *comment ) {\n}\n\nqboolean QGL_Init( const char *dllname ) {\n\treturn qtrue;\n}\n\nvoid\t\tQGL_Shutdown( void ) {\n}\n"
  },
  {
    "path": "code/null/null_input.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"../client/client.h\"\n\nvoid IN_Init( void ) {\n}\n\nvoid IN_Frame (void) {\n}\n\nvoid IN_Shutdown( void ) {\n}\n\nvoid Sys_SendKeyEvents (void) {\n}\n\n"
  },
  {
    "path": "code/null/null_main.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// sys_null.h -- null system driver to aid porting efforts\n\n#include <errno.h>\n#include <stdio.h>\n#include \"../qcommon/qcommon.h\"\n\nint\t\t\tsys_curtime;\n\n\n//===================================================================\n\nvoid Sys_BeginStreamedFile( FILE *f, int readAhead ) {\n}\n\nvoid Sys_EndStreamedFile( FILE *f ) {\n}\n\nint Sys_StreamedRead( void *buffer, int size, int count, FILE *f ) {\n\treturn fread( buffer, size, count, f );\n}\n\nvoid Sys_StreamSeek( FILE *f, int offset, int origin ) {\n\tfseek( f, offset, origin );\n}\n\n\n//===================================================================\n\n\nvoid Sys_mkdir ( const char *path ) {\n}\n\nvoid Sys_Error (char *error, ...) {\n\tva_list\t\targptr;\n\n\tprintf (\"Sys_Error: \");\t\n\tva_start (argptr,error);\n\tvprintf (error,argptr);\n\tva_end (argptr);\n\tprintf (\"\\n\");\n\n\texit (1);\n}\n\nvoid Sys_Quit (void) {\n\texit (0);\n}\n\nvoid\tSys_UnloadGame (void) {\n}\n\nvoid\t*Sys_GetGameAPI (void *parms) {\n\treturn NULL;\n}\n\nchar *Sys_GetClipboardData( void ) {\n\treturn NULL;\n}\n\nint\t\tSys_Milliseconds (void) {\n\treturn 0;\n}\n\nvoid\tSys_Mkdir (char *path) {\n}\n\nchar\t*Sys_FindFirst (char *path, unsigned musthave, unsigned canthave) {\n\treturn NULL;\n}\n\nchar\t*Sys_FindNext (unsigned musthave, unsigned canthave) {\n\treturn NULL;\n}\n\nvoid\tSys_FindClose (void) {\n}\n\nvoid\tSys_Init (void) {\n}\n\n\nvoid\tSys_EarlyOutput( char *string ) {\n\tprintf( \"%s\", string );\n}\n\n\nvoid main (int argc, char **argv) {\n\tCom_Init (argc, argv);\n\n\twhile (1) {\n\t\tCom_Frame( );\n\t}\n}\n\n\n"
  },
  {
    "path": "code/null/null_net.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"../qcommon/qcommon.h\"\n\n/*\n=============\nNET_StringToAdr\n\nlocalhost\nidnewt\nidnewt:28000\n192.246.40.70\n192.246.40.70:28000\n=============\n*/\nqboolean\tNET_StringToAdr (char *s, netadr_t *a)\n{\t\n\tif (!strcmp (s, \"localhost\")) {\n\t\tmemset (a, 0, sizeof(*a));\n\t\ta->type = NA_LOOPBACK;\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\n/*\n==================\nSys_SendPacket\n==================\n*/\nvoid Sys_SendPacket( int length, void *data, netadr_t to ) {\n}\n\n/*\n==================\nSys_GetPacket\n\nNever called by the game logic, just the system event queing\n==================\n*/\nqboolean\tSys_GetPacket ( netadr_t *net_from, msg_t *net_message ) {\n\treturn false;\n}\n"
  },
  {
    "path": "code/null/null_snddma.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n// snddma_null.c\n// all other sound mixing is portable\n\n#include \"../client/client.h\"\n\nqboolean SNDDMA_Init(void)\n{\n\treturn qfalse;\n}\n\nint\tSNDDMA_GetDMAPos(void)\n{\n\treturn 0;\n}\n\nvoid SNDDMA_Shutdown(void)\n{\n}\n\nvoid SNDDMA_BeginPainting (void)\n{\n}\n\nvoid SNDDMA_Submit(void)\n{\n}\n\n// bk001119 - added boolean flag, match client/snd_public.h\nsfxHandle_t S_RegisterSound( const char *name, qboolean compressed ) \n{\n\treturn 0;\n}\n\nvoid S_StartLocalSound( sfxHandle_t sfxHandle, int channelNum ) {\n}\n\nvoid S_ClearSoundBuffer( void ) {\n}\n"
  },
  {
    "path": "code/opts.lnt",
    "content": "-e64\t// type mismatch (enum to int)\n-e641\t// converting enum to int\n-e734\t// loss of precision\n-e736\t// loss of precision\n-e747\t// float to double prototype coersion\n-e534\t// ignoring return value\n-e524\t// loss of precision (float to int)\n-e732\t// loss of sign (float to unsigned char)\n-e702\t// shift right of signed quantity\n-e737\t// loss of sign bit (int to unsigned int)\n-e713\t// loss of precision (unsigned int to int)\n-e701\t// shift left of signed quantity\n\n-e765\t// external could be made static\n\n-d__LINT__\n-ig:\\quake3\\bin_nt\\supplement\\ansi\n-ig:\\quake3\\bin_nt\\supplement\n-igame\n-ibotai\n-icgame\n-igame\n-iserver\n-iclient\n-iqcommon\n-irenderer\n"
  },
  {
    "path": "code/q3_ui/Conscript",
    "content": "# Q3 ui building\n\n# qvm building against native:\n# only native has ui_syscalls.c\n# qvm uses a ui_syscalls.asm with equ stubs\n# qvm has additional bg_lib.c\n\nImport qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );\n\n$env = new cons(\n  # the code has the very bad habit of doing things like #include \"../ui/ui_shared.h\"\n  # this seems to confuse the dependency analysis, explicit toplevel includes seem to fix\n  CPPPATH => '#cgame:#game:#q3_ui',\n  CC => $CC,\n  CXX => $CXX,\n  LINK => $LINK,\n\tENV => { PATH => $ENV{PATH}, HOME => $ENV{HOME} },\n  CFLAGS => $BASE_CFLAGS . '-fPIC',\n  LDFLAGS => '-shared -ldl -lm'\n);\n\n# qvm building\n# we heavily customize the cons environment\n$vm_env = new cons(\n  # the code has the very bad habit of doing things like #include \"../ui/ui_shared.h\"\n  # this seems to confuse the dependency analysis, explicit toplevel includes seem to fix\n  CPPPATH => '#cgame:#game:#q3_ui',\n  CC => 'q3lcc',\n  CCCOM => '%CC %CFLAGS %_IFLAGS -c %< -o %>',\n  SUFOBJ => '.asm',\n  LINK => 'q3asm',\n  CFLAGS => '-DQ3_VM -S -Wf-target=bytecode -Wf-g',\n  # need to know where to find the compiler tools\n  ENV => { PATH => $ENV{PATH} . \":./qvmtools\", },\n);\n\n# the file with vmMain function MUST be the first one of the list\n@FILES = qw(\n  ui_main.c\n  ../game/bg_misc.c\n  ../game/q_math.c\n  ../game/q_shared.c\n  ui_addbots.c\n  ui_atoms.c\n  ui_cdkey.c\n  ui_cinematics.c\n  ui_confirm.c\n  ui_connect.c\n  ui_controls2.c\n  ui_credits.c\n  ui_demo2.c\n  ui_display.c\n  ui_gameinfo.c\n  ui_ingame.c\n  ui_menu.c\n  ui_mfield.c\n  ui_mods.c\n  ui_network.c\n  ui_options.c\n  ui_playermodel.c\n  ui_players.c\n  ui_playersettings.c\n  ui_preferences.c\n  ui_qmenu.c\n  ui_removebots.c\n  ui_serverinfo.c\n  ui_servers2.c\n  ui_setup.c\n  ui_sound.c\n  ui_sparena.c\n  ui_specifyserver.c\n  ui_splevel.c\n  ui_sppostgame.c\n  ui_spskill.c\n  ui_startserver.c\n  ui_team.c\n  ui_teamorders.c\n  ui_video.c  \n  );\n$FILESREF = \\@FILES;\n\nif ($NO_SO eq 0)\n{\n\tProgram $env 'uii386.so', @$FILESREF, '../ui/ui_syscalls.c';\n\tInstall $env $INSTALL_DIR, 'uii386.so';\n}\nif ($NO_VM eq 0)\n{\n  Depends $vm_env 'ui.qvm', '#qvmtools/q3lcc';\n  Depends $vm_env 'ui.qvm', '#qvmtools/q3asm';\n\tProgram $vm_env 'ui.qvm', @$FILESREF, '../game/bg_lib.c', '../ui/ui_syscalls.asm';\n\tInstall $vm_env $INSTALL_DIR . '/vm', 'ui.qvm';\n}\n"
  },
  {
    "path": "code/q3_ui/compile.bat",
    "content": "lcc -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\ui %1\n\n"
  },
  {
    "path": "code/q3_ui/keycodes.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#ifndef __KEYCODES_H__\n#define __KEYCODES_H__\n\n//\n// these are the key numbers that should be passed to KeyEvent\n//\n\n// normal keys should be passed as lowercased ascii\n\ntypedef enum {\n\tK_TAB = 9,\n\tK_ENTER = 13,\n\tK_ESCAPE = 27,\n\tK_SPACE = 32,\n\n\tK_BACKSPACE = 127,\n\n\tK_COMMAND = 128,\n\tK_CAPSLOCK,\n\tK_POWER,\n\tK_PAUSE,\n\n\tK_UPARROW,\n\tK_DOWNARROW,\n\tK_LEFTARROW,\n\tK_RIGHTARROW,\n\n\tK_ALT,\n\tK_CTRL,\n\tK_SHIFT,\n\tK_INS,\n\tK_DEL,\n\tK_PGDN,\n\tK_PGUP,\n\tK_HOME,\n\tK_END,\n\n\tK_F1,\n\tK_F2,\n\tK_F3,\n\tK_F4,\n\tK_F5,\n\tK_F6,\n\tK_F7,\n\tK_F8,\n\tK_F9,\n\tK_F10,\n\tK_F11,\n\tK_F12,\n\tK_F13,\n\tK_F14,\n\tK_F15,\n\n\tK_KP_HOME,\n\tK_KP_UPARROW,\n\tK_KP_PGUP,\n\tK_KP_LEFTARROW,\n\tK_KP_5,\n\tK_KP_RIGHTARROW,\n\tK_KP_END,\n\tK_KP_DOWNARROW,\n\tK_KP_PGDN,\n\tK_KP_ENTER,\n\tK_KP_INS,\n\tK_KP_DEL,\n\tK_KP_SLASH,\n\tK_KP_MINUS,\n\tK_KP_PLUS,\n\tK_KP_NUMLOCK,\n\tK_KP_STAR,\n\tK_KP_EQUALS,\n\n\tK_MOUSE1,\n\tK_MOUSE2,\n\tK_MOUSE3,\n\tK_MOUSE4,\n\tK_MOUSE5,\n\n\tK_MWHEELDOWN,\n\tK_MWHEELUP,\n\n\tK_JOY1,\n\tK_JOY2,\n\tK_JOY3,\n\tK_JOY4,\n\tK_JOY5,\n\tK_JOY6,\n\tK_JOY7,\n\tK_JOY8,\n\tK_JOY9,\n\tK_JOY10,\n\tK_JOY11,\n\tK_JOY12,\n\tK_JOY13,\n\tK_JOY14,\n\tK_JOY15,\n\tK_JOY16,\n\tK_JOY17,\n\tK_JOY18,\n\tK_JOY19,\n\tK_JOY20,\n\tK_JOY21,\n\tK_JOY22,\n\tK_JOY23,\n\tK_JOY24,\n\tK_JOY25,\n\tK_JOY26,\n\tK_JOY27,\n\tK_JOY28,\n\tK_JOY29,\n\tK_JOY30,\n\tK_JOY31,\n\tK_JOY32,\n\n\tK_AUX1,\n\tK_AUX2,\n\tK_AUX3,\n\tK_AUX4,\n\tK_AUX5,\n\tK_AUX6,\n\tK_AUX7,\n\tK_AUX8,\n\tK_AUX9,\n\tK_AUX10,\n\tK_AUX11,\n\tK_AUX12,\n\tK_AUX13,\n\tK_AUX14,\n\tK_AUX15,\n\tK_AUX16,\n\n\tK_LAST_KEY\t\t// this had better be <256!\n} keyNum_t;\n\n\n// The menu code needs to get both key and char events, but\n// to avoid duplicating the paths, the char events are just\n// distinguished by or'ing in K_CHAR_FLAG (ugly)\n#define\tK_CHAR_FLAG\t\t1024\n\n#endif\n"
  },
  {
    "path": "code/q3_ui/q3_ui.bat",
    "content": "rem make sure we have a safe environement\nset LIBRARY=\nset INCLUDE=\n\nmkdir vm\ncd vm\n\nset cc=lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui %1\n\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_main.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_cdkey.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_ingame.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_serverinfo.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_confirm.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_setup.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../../game/bg_misc.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../../game/bg_lib.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../../game/q_math.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../../game/q_shared.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_gameinfo.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_atoms.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_connect.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_controls2.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_demo2.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_mfield.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_credits.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_menu.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_options.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_display.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_sound.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_network.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_playermodel.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_players.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_playersettings.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_preferences.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_qmenu.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_servers2.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_sparena.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_specifyserver.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_splevel.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_sppostgame.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_startserver.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_team.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_video.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_cinematics.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_spskill.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_addbots.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_removebots.c\n@if errorlevel 1 goto quit\nrem lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_loadconfig.c\nrem @if errorlevel 1 goto quit\nrem lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_saveconfig.c\nrem @if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_teamorders.c\n@if errorlevel 1 goto quit\nlcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\q3_ui ../ui_mods.c\n@if errorlevel 1 goto quit\n\n\nq3asm -f ../q3_ui\n:quit\ncd ..\n"
  },
  {
    "path": "code/q3_ui/q3_ui.q3asm",
    "content": "-o \"\\quake3\\baseq3\\vm\\ui\"\nui_main\n..\\..\\ui\\ui_syscalls\nui_gameinfo\nui_atoms\nui_cinematics\nui_connect\nui_controls2\nui_demo2\nui_mfield\nui_credits\nui_menu\nui_ingame\nui_confirm\nui_setup\nui_options\nui_display\nui_sound\nui_network\nui_playermodel\nui_players\nui_playersettings\nui_preferences\nui_qmenu\nui_serverinfo\nui_servers2\nui_sparena\nui_specifyserver\nui_sppostgame\nui_splevel\nui_spskill\nui_startserver\nui_team\nui_video\nui_addbots\nui_removebots\nui_teamorders\nui_cdkey\nui_mods\nbg_misc\nbg_lib\nq_math\nq_shared\n"
  },
  {
    "path": "code/q3_ui/q3_ui.sh",
    "content": "#!/bin/sh\n\nmkdir -p vm\ncd vm\n\nCC=\"q3lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I../../cgame -I../../game -I../../q3_ui \"\n\n$CC ../ui_main.c\n$CC ../ui_cdkey.c\n$CC ../ui_ingame.c\n$CC ../ui_confirm.c\n$CC ../ui_setup.c\n$CC ../../game/bg_misc.c\n$CC ../../game/bg_lib.c\n$CC ../../game/q_math.c\n$CC ../../game/q_shared.c\n$CC ../ui_gameinfo.c\n$CC ../ui_atoms.c\n$CC ../ui_connect.c\n$CC ../ui_controls2.c\n$CC ../ui_demo2.c\n$CC ../ui_mfield.c\n$CC ../ui_credits.c\n$CC ../ui_menu.c\n$CC ../ui_options.c\n$CC ../ui_display.c\n$CC ../ui_sound.c\n$CC ../ui_network.c\n$CC ../ui_playermodel.c\n$CC ../ui_players.c\n$CC ../ui_playersettings.c\n$CC ../ui_preferences.c\n$CC ../ui_qmenu.c\n$CC ../ui_serverinfo.c\n$CC ../ui_servers2.c\n$CC ../ui_sparena.c\n$CC ../ui_specifyserver.c\n$CC ../ui_splevel.c\n$CC ../ui_sppostgame.c\n$CC ../ui_startserver.c\n$CC ../ui_syscalls.c\n$CC ../ui_team.c\n$CC ../ui_video.c\n$CC ../ui_cinematics.c\n$CC ../ui_spskill.c\n$CC ../ui_addbots.c\n$CC ../ui_removebots.c\n$CC ../ui_loadconfig.c\n$CC ../ui_saveconfig.c\n$CC ../ui_teamorders.c\n$CC ../ui_mods.c\n\nq3asm -f ../q3_ui\n\ncd ..\n"
  },
  {
    "path": "code/q3_ui/q3_ui.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<VisualStudioProject\n\tProjectType=\"Visual C++\"\n\tVersion=\"7.10\"\n\tName=\"q3_ui\"\n\tSccProjectName=\"&quot;$/MissionPack/code/q3_ui&quot;, VFLAAAAA\"\n\tSccLocalPath=\".\">\n\t<Platforms>\n\t\t<Platform\n\t\t\tName=\"Win32\"/>\n\t</Platforms>\n\t<Configurations>\n\t\t<Configuration\n\t\t\tName=\"Debug TA|Win32\"\n\t\t\tOutputDirectory=\".\\Debug_TA\"\n\t\t\tIntermediateDirectory=\".\\Debug_TA\"\n\t\t\tConfigurationType=\"2\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tOptimizeForProcessor=\"1\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_USRDLL;UI_EXPORTS\"\n\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\"Debug/q3_ui.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug_TA/\"\n\t\t\t\tObjectFile=\"Debug/\"\n\t\t\t\tProgramDataBaseFileName=\"Debug/\"\n\t\t\t\tBrowseInformation=\"1\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"odbc32.lib odbccp32.lib\"\n\t\t\t\tOutputFile=\"../Debug_TA/uix86_old.dll\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tModuleDefinitionFile=\".\\ui.def\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\"../Debug_TA/ui.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\"Debug_TA/uix86.map\"\n\t\t\t\tBaseAddress=\"0x40000000\"\n\t\t\t\tImportLibrary=\"Debug_TA/uix86.lib\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Debug_TA/q3_ui.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Release TA|Win32\"\n\t\t\tOutputDirectory=\".\\Release_TA\"\n\t\t\tIntermediateDirectory=\".\\Release_TA\"\n\t\t\tConfigurationType=\"2\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_USRDLL;Q3_UI_EXPORTS\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"0\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release_TA/q3_ui.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release_TA/\"\n\t\t\t\tObjectFile=\".\\Release_TA/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release_TA/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"odbc32.lib odbccp32.lib\"\n\t\t\t\tOutputFile=\"../Release_TA/uix86_old.dll\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tModuleDefinitionFile=\".\\ui.def\"\n\t\t\t\tProgramDatabaseFile=\".\\Release_TA/uix86_old.pdb\"\n\t\t\t\tImportLibrary=\"Release_TA/q3_ui.lib\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Release_TA/q3_ui.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Release|Win32\"\n\t\t\tOutputDirectory=\".\\Release\"\n\t\t\tIntermediateDirectory=\".\\Release\"\n\t\t\tConfigurationType=\"2\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_USRDLL;Q3_UI_EXPORTS\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"0\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release/q3_ui.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release/\"\n\t\t\t\tObjectFile=\".\\Release/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tOutputFile=\"../Release/uix86.dll\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tModuleDefinitionFile=\".\\ui.def\"\n\t\t\t\tProgramDatabaseFile=\".\\Release/uix86.pdb\"\n\t\t\t\tImportLibrary=\".\\Release/uix86.lib\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Release/q3_ui.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Debug|Win32\"\n\t\t\tOutputDirectory=\".\\q3_ui___Win32_Debug\"\n\t\t\tIntermediateDirectory=\".\\q3_ui___Win32_Debug\"\n\t\t\tConfigurationType=\"2\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tOptimizeForProcessor=\"1\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_USRDLL;UI_EXPORTS\"\n\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\"Debug/q3_ui.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\q3_ui___Win32_Debug/\"\n\t\t\t\tObjectFile=\"Debug/\"\n\t\t\t\tProgramDataBaseFileName=\"Debug/\"\n\t\t\t\tBrowseInformation=\"1\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"odbc32.lib odbccp32.lib\"\n\t\t\t\tOutputFile=\"../Debug/uix86.dll\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tModuleDefinitionFile=\".\\ui.def\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\"../Debug/ui.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\"Debug/uix86.map\"\n\t\t\t\tBaseAddress=\"0x40000000\"\n\t\t\t\tImportLibrary=\"Debug/uix86.lib\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\q3_ui___Win32_Debug/q3_ui.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t</Configurations>\n\t<References>\n\t</References>\n\t<Files>\n\t\t<Filter\n\t\t\tName=\"Source Files\"\n\t\t\tFilter=\"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\bg_misc.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\q_math.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\q_shared.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui.def\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_addbots.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_atoms.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_cdkey.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_cinematics.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_confirm.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_connect.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_controls2.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_credits.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_demo2.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_display.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_gameinfo.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_ingame.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_loadconfig.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_main.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_menu.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_mfield.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_mods.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_network.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_options.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_playermodel.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_players.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_playersettings.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_preferences.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_qmenu.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_removebots.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_saveconfig.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_serverinfo.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_servers2.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_setup.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_sound.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_sparena.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_specifyserver.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_splevel.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_sppostgame.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_spreset.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_spskill.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_startserver.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ui\\ui_syscalls.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_team.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_teamorders.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_video.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;Q3_UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Header Files\"\n\t\t\tFilter=\"h;hpp;hxx;hm;inl\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"keycodes.h\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\q_shared.h\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_local.h\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_public.h\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Resource Files\"\n\t\t\tFilter=\"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\">\n\t\t</Filter>\n\t</Files>\n\t<Globals>\n\t</Globals>\n</VisualStudioProject>\n"
  },
  {
    "path": "code/q3_ui/ui.def",
    "content": "EXPORTS\n\tvmMain\n\tdllEntry\n"
  },
  {
    "path": "code/q3_ui/ui.q3asm",
    "content": "-o \"\\quake3\\baseq3\\vm\\ui\"\nui_main\n..\\ui_syscalls\nui_gameinfo\nui_atoms\nui_cinematics\nui_connect\nui_controls2\nui_demo2\nui_mfield\nui_credits\nui_menu\nui_ingame\nui_confirm\nui_setup\nui_options\nui_display\nui_sound\nui_network\nui_playermodel\nui_players\nui_playersettings\nui_preferences\nui_qmenu\nui_serverinfo\nui_servers2\nui_sparena\nui_specifyserver\nui_sppostgame\nui_splevel\nui_spskill\nui_startserver\nui_team\nui_video\nui_addbots\nui_removebots\nui_teamorders\nui_loadconfig\nui_saveconfig\nui_cdkey\nui_mods\nbg_misc\nbg_lib\nq_math\nq_shared\n"
  },
  {
    "path": "code/q3_ui/ui_addbots.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=======================================================================\n\nADD BOTS MENU\n\n=======================================================================\n*/\n\n\n#include \"ui_local.h\"\n\n\n#define ART_BACK0\t\t\t\"menu/art/back_0\"\n#define ART_BACK1\t\t\t\"menu/art/back_1\"\t\n#define ART_FIGHT0\t\t\t\"menu/art/accept_0\"\n#define ART_FIGHT1\t\t\t\"menu/art/accept_1\"\n#define ART_BACKGROUND\t\t\"menu/art/addbotframe\"\n#define ART_ARROWS\t\t\t\"menu/art/arrows_vert_0\"\n#define ART_ARROWUP\t\t\t\"menu/art/arrows_vert_top\"\n#define ART_ARROWDOWN\t\t\"menu/art/arrows_vert_bot\"\n\n#define ID_BACK\t\t\t\t10\n#define ID_GO\t\t\t\t11\n#define ID_LIST\t\t\t\t12\n#define ID_UP\t\t\t\t13\n#define ID_DOWN\t\t\t\t14\n#define ID_SKILL\t\t\t15\n#define ID_TEAM\t\t\t\t16\n#define ID_BOTNAME0\t\t\t20\n#define ID_BOTNAME1\t\t\t21\n#define ID_BOTNAME2\t\t\t22\n#define ID_BOTNAME3\t\t\t23\n#define ID_BOTNAME4\t\t\t24\n#define ID_BOTNAME5\t\t\t25\n#define ID_BOTNAME6\t\t\t26\n\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n\tmenubitmap_s\tarrows;\n\tmenubitmap_s\tup;\n\tmenubitmap_s\tdown;\n\tmenutext_s\t\tbots[7];\n\tmenulist_s\t\tskill;\n\tmenulist_s\t\tteam;\n\tmenubitmap_s\tgo;\n\tmenubitmap_s\tback;\n\n\tint\t\t\t\tnumBots;\n\tint\t\t\t\tdelay;\n\tint\t\t\t\tbaseBotNum;\n\tint\t\t\t\tselectedBotNum;\n\tint\t\t\t\tsortedBotNums[MAX_BOTS];\n\tchar\t\t\tbotnames[7][32];\n} addBotsMenuInfo_t;\n\nstatic addBotsMenuInfo_t\taddBotsMenuInfo;\n\n\n/*\n=================\nUI_AddBotsMenu_FightEvent\n=================\n*/\nstatic void UI_AddBotsMenu_FightEvent( void* ptr, int event ) {\n\tconst char\t*team;\n\tint\t\t\tskill;\n\n\tif (event != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\n\tteam = addBotsMenuInfo.team.itemnames[addBotsMenuInfo.team.curvalue];\n\tskill = addBotsMenuInfo.skill.curvalue + 1;\n\n\ttrap_Cmd_ExecuteText( EXEC_APPEND, va(\"addbot %s %i %s %i\\n\",\n\t\taddBotsMenuInfo.botnames[addBotsMenuInfo.selectedBotNum], skill, team, addBotsMenuInfo.delay) );\n\n\taddBotsMenuInfo.delay += 1500;\n}\n\n\n/*\n=================\nUI_AddBotsMenu_BotEvent\n=================\n*/\nstatic void UI_AddBotsMenu_BotEvent( void* ptr, int event ) {\n\tif (event != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\n\taddBotsMenuInfo.bots[addBotsMenuInfo.selectedBotNum].color = color_orange;\n\taddBotsMenuInfo.selectedBotNum = ((menucommon_s*)ptr)->id - ID_BOTNAME0;\n\taddBotsMenuInfo.bots[addBotsMenuInfo.selectedBotNum].color = color_white;\n}\n\n\n/*\n=================\nUI_AddBotsMenu_BackEvent\n=================\n*/\nstatic void UI_AddBotsMenu_BackEvent( void* ptr, int event ) {\n\tif (event != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\tUI_PopMenu();\n}\n\n\n/*\n=================\nUI_AddBotsMenu_SetBotNames\n=================\n*/\nstatic void UI_AddBotsMenu_SetBotNames( void ) {\n\tint\t\t\tn;\n\tconst char\t*info;\n\n\tfor ( n = 0; n < 7; n++ ) {\n\t\tinfo = UI_GetBotInfoByNumber( addBotsMenuInfo.sortedBotNums[addBotsMenuInfo.baseBotNum + n] );\n\t\tQ_strncpyz( addBotsMenuInfo.botnames[n], Info_ValueForKey( info, \"name\" ), sizeof(addBotsMenuInfo.botnames[n]) );\n\t}\n\n}\n\n\n/*\n=================\nUI_AddBotsMenu_UpEvent\n=================\n*/\nstatic void UI_AddBotsMenu_UpEvent( void* ptr, int event ) {\n\tif (event != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\n\tif( addBotsMenuInfo.baseBotNum > 0 ) {\n\t\taddBotsMenuInfo.baseBotNum--;\n\t\tUI_AddBotsMenu_SetBotNames();\n\t}\n}\n\n\n/*\n=================\nUI_AddBotsMenu_DownEvent\n=================\n*/\nstatic void UI_AddBotsMenu_DownEvent( void* ptr, int event ) {\n\tif (event != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\n\tif( addBotsMenuInfo.baseBotNum + 7 < addBotsMenuInfo.numBots ) {\n\t\taddBotsMenuInfo.baseBotNum++;\n\t\tUI_AddBotsMenu_SetBotNames();\n\t}\n}\n\n\n/*\n=================\nUI_AddBotsMenu_GetSortedBotNums\n=================\n*/\nstatic int QDECL UI_AddBotsMenu_SortCompare( const void *arg1, const void *arg2 ) {\n\tint\t\t\tnum1, num2;\n\tconst char\t*info1, *info2;\n\tconst char\t*name1, *name2;\n\n\tnum1 = *(int *)arg1;\n\tnum2 = *(int *)arg2;\n\n\tinfo1 = UI_GetBotInfoByNumber( num1 );\n\tinfo2 = UI_GetBotInfoByNumber( num2 );\n\n\tname1 = Info_ValueForKey( info1, \"name\" );\n\tname2 = Info_ValueForKey( info2, \"name\" );\n\n\treturn Q_stricmp( name1, name2 );\n}\n\nstatic void UI_AddBotsMenu_GetSortedBotNums( void ) {\n\tint\t\tn;\n\n\t// initialize the array\n\tfor( n = 0; n < addBotsMenuInfo.numBots; n++ ) {\n\t\taddBotsMenuInfo.sortedBotNums[n] = n;\n\t}\n\n\tqsort( addBotsMenuInfo.sortedBotNums, addBotsMenuInfo.numBots, sizeof(addBotsMenuInfo.sortedBotNums[0]), UI_AddBotsMenu_SortCompare );\n}\n\n\n/*\n=================\nUI_AddBotsMenu_Draw\n=================\n*/\nstatic void UI_AddBotsMenu_Draw( void ) {\n\tUI_DrawBannerString( 320, 16, \"ADD BOTS\", UI_CENTER, color_white );\n\tUI_DrawNamedPic( 320-233, 240-166, 466, 332, ART_BACKGROUND );\n\n\t// standard menu drawing\n\tMenu_Draw( &addBotsMenuInfo.menu );\n}\n\n\t\n/*\n=================\nUI_AddBotsMenu_Init\n=================\n*/\nstatic const char *skillNames[] = {\n\t\"I Can Win\",\n\t\"Bring It On\",\n\t\"Hurt Me Plenty\",\n\t\"Hardcore\",\n\t\"Nightmare!\",\n\t0\n};\n\nstatic const char *teamNames1[] = {\n\t\"Free\",\n\t0\n};\n\nstatic const char *teamNames2[] = {\n\t\"Red\",\n\t\"Blue\",\n\t0\n};\n\nstatic void UI_AddBotsMenu_Init( void ) {\n\tint\t\tn;\n\tint\t\ty;\n\tint\t\tgametype;\n\tint\t\tcount;\n\tchar\tinfo[MAX_INFO_STRING];\n\n\ttrap_GetConfigString(CS_SERVERINFO, info, MAX_INFO_STRING);   \n\tgametype = atoi( Info_ValueForKey( info,\"g_gametype\" ) );\n\n\tmemset( &addBotsMenuInfo, 0 ,sizeof(addBotsMenuInfo) );\n\taddBotsMenuInfo.menu.draw = UI_AddBotsMenu_Draw;\n\taddBotsMenuInfo.menu.fullscreen = qfalse;\n\taddBotsMenuInfo.menu.wrapAround = qtrue;\n\taddBotsMenuInfo.delay = 1000;\n\n\tUI_AddBots_Cache();\n\n\taddBotsMenuInfo.numBots = UI_GetNumBots();\n\tcount = addBotsMenuInfo.numBots < 7 ? addBotsMenuInfo.numBots : 7;\n\n\taddBotsMenuInfo.arrows.generic.type  = MTYPE_BITMAP;\n\taddBotsMenuInfo.arrows.generic.name  = ART_ARROWS;\n\taddBotsMenuInfo.arrows.generic.flags = QMF_INACTIVE;\n\taddBotsMenuInfo.arrows.generic.x\t = 200;\n\taddBotsMenuInfo.arrows.generic.y\t = 128;\n\taddBotsMenuInfo.arrows.width  \t     = 64;\n\taddBotsMenuInfo.arrows.height  \t     = 128;\n\n\taddBotsMenuInfo.up.generic.type\t    = MTYPE_BITMAP;\n\taddBotsMenuInfo.up.generic.flags    = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\taddBotsMenuInfo.up.generic.x\t\t= 200;\n\taddBotsMenuInfo.up.generic.y\t\t= 128;\n\taddBotsMenuInfo.up.generic.id\t    = ID_UP;\n\taddBotsMenuInfo.up.generic.callback = UI_AddBotsMenu_UpEvent;\n\taddBotsMenuInfo.up.width  \t\t    = 64;\n\taddBotsMenuInfo.up.height  \t\t    = 64;\n\taddBotsMenuInfo.up.focuspic         = ART_ARROWUP;\n\n\taddBotsMenuInfo.down.generic.type\t  = MTYPE_BITMAP;\n\taddBotsMenuInfo.down.generic.flags    = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\taddBotsMenuInfo.down.generic.x\t\t  = 200;\n\taddBotsMenuInfo.down.generic.y\t\t  = 128+64;\n\taddBotsMenuInfo.down.generic.id\t      = ID_DOWN;\n\taddBotsMenuInfo.down.generic.callback = UI_AddBotsMenu_DownEvent;\n\taddBotsMenuInfo.down.width  \t\t  = 64;\n\taddBotsMenuInfo.down.height  \t\t  = 64;\n\taddBotsMenuInfo.down.focuspic         = ART_ARROWDOWN;\n\n\tfor( n = 0, y = 120; n < count; n++, y += 20 ) {\n\t\taddBotsMenuInfo.bots[n].generic.type\t\t= MTYPE_PTEXT;\n\t\taddBotsMenuInfo.bots[n].generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\t\taddBotsMenuInfo.bots[n].generic.id\t\t\t= ID_BOTNAME0 + n;\n\t\taddBotsMenuInfo.bots[n].generic.x\t\t\t= 320 - 56;\n\t\taddBotsMenuInfo.bots[n].generic.y\t\t\t= y;\n\t\taddBotsMenuInfo.bots[n].generic.callback\t= UI_AddBotsMenu_BotEvent;\n\t\taddBotsMenuInfo.bots[n].string\t\t\t\t= addBotsMenuInfo.botnames[n];\n\t\taddBotsMenuInfo.bots[n].color\t\t\t\t= color_orange;\n\t\taddBotsMenuInfo.bots[n].style\t\t\t\t= UI_LEFT|UI_SMALLFONT;\n\t}\n\n\ty += 12;\n\taddBotsMenuInfo.skill.generic.type\t\t= MTYPE_SPINCONTROL;\n\taddBotsMenuInfo.skill.generic.flags\t\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\taddBotsMenuInfo.skill.generic.x\t\t\t= 320;\n\taddBotsMenuInfo.skill.generic.y\t\t\t= y;\n\taddBotsMenuInfo.skill.generic.name\t\t= \"Skill:\";\n\taddBotsMenuInfo.skill.generic.id\t\t= ID_SKILL;\n\taddBotsMenuInfo.skill.itemnames\t\t\t= skillNames;\n\taddBotsMenuInfo.skill.curvalue\t\t\t= Com_Clamp( 0, 4, (int)trap_Cvar_VariableValue( \"g_spSkill\" ) - 1 );\n\n\ty += SMALLCHAR_HEIGHT;\n\taddBotsMenuInfo.team.generic.type\t\t= MTYPE_SPINCONTROL;\n\taddBotsMenuInfo.team.generic.flags\t\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\taddBotsMenuInfo.team.generic.x\t\t\t= 320;\n\taddBotsMenuInfo.team.generic.y\t\t\t= y;\n\taddBotsMenuInfo.team.generic.name\t\t= \"Team: \";\n\taddBotsMenuInfo.team.generic.id\t\t\t= ID_TEAM;\n\tif( gametype >= GT_TEAM ) {\n\t\taddBotsMenuInfo.team.itemnames\t\t= teamNames2;\n\t}\n\telse {\n\t\taddBotsMenuInfo.team.itemnames\t\t= teamNames1;\n\t\taddBotsMenuInfo.team.generic.flags\t= QMF_GRAYED;\n\t}\n\n\taddBotsMenuInfo.go.generic.type\t\t\t= MTYPE_BITMAP;\n\taddBotsMenuInfo.go.generic.name\t\t\t= ART_FIGHT0;\n\taddBotsMenuInfo.go.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\taddBotsMenuInfo.go.generic.id\t\t\t= ID_GO;\n\taddBotsMenuInfo.go.generic.callback\t\t= UI_AddBotsMenu_FightEvent;\n\taddBotsMenuInfo.go.generic.x\t\t\t= 320+128-128;\n\taddBotsMenuInfo.go.generic.y\t\t\t= 256+128-64;\n\taddBotsMenuInfo.go.width  \t\t\t\t= 128;\n\taddBotsMenuInfo.go.height  \t\t\t\t= 64;\n\taddBotsMenuInfo.go.focuspic\t\t\t\t= ART_FIGHT1;\n\n\taddBotsMenuInfo.back.generic.type\t\t= MTYPE_BITMAP;\n\taddBotsMenuInfo.back.generic.name\t\t= ART_BACK0;\n\taddBotsMenuInfo.back.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\taddBotsMenuInfo.back.generic.id\t\t\t= ID_BACK;\n\taddBotsMenuInfo.back.generic.callback\t= UI_AddBotsMenu_BackEvent;\n\taddBotsMenuInfo.back.generic.x\t\t\t= 320-128;\n\taddBotsMenuInfo.back.generic.y\t\t\t= 256+128-64;\n\taddBotsMenuInfo.back.width\t\t\t\t= 128;\n\taddBotsMenuInfo.back.height\t\t\t\t= 64;\n\taddBotsMenuInfo.back.focuspic\t\t\t= ART_BACK1;\n\n\taddBotsMenuInfo.baseBotNum = 0;\n\taddBotsMenuInfo.selectedBotNum = 0;\n\taddBotsMenuInfo.bots[0].color = color_white;\n\n\tUI_AddBotsMenu_GetSortedBotNums();\n\tUI_AddBotsMenu_SetBotNames();\n\n\tMenu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.arrows );\n\n\tMenu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.up );\n\tMenu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.down );\n\tfor( n = 0; n < count; n++ ) {\n\t\tMenu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.bots[n] );\n\t}\n\tMenu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.skill );\n\tMenu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.team );\n\tMenu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.go );\n\tMenu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.back );\n}\n\n\n/*\n=================\nUI_AddBots_Cache\n=================\n*/\nvoid UI_AddBots_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( ART_BACK0 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK1 );\n\ttrap_R_RegisterShaderNoMip( ART_FIGHT0 );\n\ttrap_R_RegisterShaderNoMip( ART_FIGHT1 );\n\ttrap_R_RegisterShaderNoMip( ART_BACKGROUND );\n\ttrap_R_RegisterShaderNoMip( ART_ARROWS );\n\ttrap_R_RegisterShaderNoMip( ART_ARROWUP );\n\ttrap_R_RegisterShaderNoMip( ART_ARROWDOWN );\n}\n\n\n/*\n=================\nUI_AddBotsMenu\n=================\n*/\nvoid UI_AddBotsMenu( void ) {\n\tUI_AddBotsMenu_Init();\n\tUI_PushMenu( &addBotsMenuInfo.menu );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_atoms.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/**********************************************************************\n\tUI_ATOMS.C\n\n\tUser interface building blocks and support functions.\n**********************************************************************/\n#include \"ui_local.h\"\n\nuiStatic_t\t\tuis;\nqboolean\t\tm_entersound;\t\t// after a frame, so caching won't disrupt the sound\n\n// these are here so the functions in q_shared.c can link\n#ifndef UI_HARD_LINKED\n\nvoid QDECL Com_Error( int level, const char *error, ... ) {\n\tva_list\t\targptr;\n\tchar\t\ttext[1024];\n\n\tva_start (argptr, error);\n\tvsprintf (text, error, argptr);\n\tva_end (argptr);\n\n\ttrap_Error( va(\"%s\", text) );\n}\n\nvoid QDECL Com_Printf( const char *msg, ... ) {\n\tva_list\t\targptr;\n\tchar\t\ttext[1024];\n\n\tva_start (argptr, msg);\n\tvsprintf (text, msg, argptr);\n\tva_end (argptr);\n\n\ttrap_Print( va(\"%s\", text) );\n}\n\n#endif\n\n/*\n=================\nUI_ClampCvar\n=================\n*/\nfloat UI_ClampCvar( float min, float max, float value )\n{\n\tif ( value < min ) return min;\n\tif ( value > max ) return max;\n\treturn value;\n}\n\n/*\n=================\nUI_StartDemoLoop\n=================\n*/\nvoid UI_StartDemoLoop( void ) {\n\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"d1\\n\" );\n}\n\n/*\n=================\nUI_PushMenu\n=================\n*/\nvoid UI_PushMenu( menuframework_s *menu )\n{\n\tint\t\t\t\ti;\n\tmenucommon_s*\titem;\n\n\t// avoid stacking menus invoked by hotkeys\n\tfor (i=0 ; i<uis.menusp ; i++)\n\t{\n\t\tif (uis.stack[i] == menu)\n\t\t{\n\t\t\tuis.menusp = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (i == uis.menusp)\n\t{\n\t\tif (uis.menusp >= MAX_MENUDEPTH)\n\t\t\ttrap_Error(\"UI_PushMenu: menu stack overflow\");\n\n\t\tuis.stack[uis.menusp++] = menu;\n\t}\n\n\tuis.activemenu = menu;\n\n\t// default cursor position\n\tmenu->cursor      = 0;\n\tmenu->cursor_prev = 0;\n\n\tm_entersound = qtrue;\n\n\ttrap_Key_SetCatcher( KEYCATCH_UI );\n\n\t// force first available item to have focus\n\tfor (i=0; i<menu->nitems; i++)\n\t{\n\t\titem = (menucommon_s *)menu->items[i];\n\t\tif (!(item->flags & (QMF_GRAYED|QMF_MOUSEONLY|QMF_INACTIVE)))\n\t\t{\n\t\t\tmenu->cursor_prev = -1;\n\t\t\tMenu_SetCursor( menu, i );\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tuis.firstdraw = qtrue;\n}\n\n/*\n=================\nUI_PopMenu\n=================\n*/\nvoid UI_PopMenu (void)\n{\n\ttrap_S_StartLocalSound( menu_out_sound, CHAN_LOCAL_SOUND );\n\n\tuis.menusp--;\n\n\tif (uis.menusp < 0)\n\t\ttrap_Error (\"UI_PopMenu: menu stack underflow\");\n\n\tif (uis.menusp) {\n\t\tuis.activemenu = uis.stack[uis.menusp-1];\n\t\tuis.firstdraw = qtrue;\n\t}\n\telse {\n\t\tUI_ForceMenuOff ();\n\t}\n}\n\nvoid UI_ForceMenuOff (void)\n{\n\tuis.menusp     = 0;\n\tuis.activemenu = NULL;\n\n\ttrap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI );\n\ttrap_Key_ClearStates();\n\ttrap_Cvar_Set( \"cl_paused\", \"0\" );\n}\n\n/*\n=================\nUI_LerpColor\n=================\n*/\nvoid UI_LerpColor(vec4_t a, vec4_t b, vec4_t c, float t)\n{\n\tint i;\n\n\t// lerp and clamp each component\n\tfor (i=0; i<4; i++)\n\t{\n\t\tc[i] = a[i] + t*(b[i]-a[i]);\n\t\tif (c[i] < 0)\n\t\t\tc[i] = 0;\n\t\telse if (c[i] > 1.0)\n\t\t\tc[i] = 1.0;\n\t}\n}\n\n/*\n=================\nUI_DrawProportionalString2\n=================\n*/\nstatic int\tpropMap[128][3] = {\n{0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1},\n{0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1},\n\n{0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1},\n{0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1},\n\n{0, 0, PROP_SPACE_WIDTH},\t\t// SPACE\n{11, 122, 7},\t// !\n{154, 181, 14},\t// \"\n{55, 122, 17},\t// #\n{79, 122, 18},\t// $\n{101, 122, 23},\t// %\n{153, 122, 18},\t// &\n{9, 93, 7},\t\t// '\n{207, 122, 8},\t// (\n{230, 122, 9},\t// )\n{177, 122, 18},\t// *\n{30, 152, 18},\t// +\n{85, 181, 7},\t// ,\n{34, 93, 11},\t// -\n{110, 181, 6},\t// .\n{130, 152, 14},\t// /\n\n{22, 64, 17},\t// 0\n{41, 64, 12},\t// 1\n{58, 64, 17},\t// 2\n{78, 64, 18},\t// 3\n{98, 64, 19},\t// 4\n{120, 64, 18},\t// 5\n{141, 64, 18},\t// 6\n{204, 64, 16},\t// 7\n{162, 64, 17},\t// 8\n{182, 64, 18},\t// 9\n{59, 181, 7},\t// :\n{35,181, 7},\t// ;\n{203, 152, 14},\t// <\n{56, 93, 14},\t// =\n{228, 152, 14},\t// >\n{177, 181, 18},\t// ?\n\n{28, 122, 22},\t// @\n{5, 4, 18},\t\t// A\n{27, 4, 18},\t// B\n{48, 4, 18},\t// C\n{69, 4, 17},\t// D\n{90, 4, 13},\t// E\n{106, 4, 13},\t// F\n{121, 4, 18},\t// G\n{143, 4, 17},\t// H\n{164, 4, 8},\t// I\n{175, 4, 16},\t// J\n{195, 4, 18},\t// K\n{216, 4, 12},\t// L\n{230, 4, 23},\t// M\n{6, 34, 18},\t// N\n{27, 34, 18},\t// O\n\n{48, 34, 18},\t// P\n{68, 34, 18},\t// Q\n{90, 34, 17},\t// R\n{110, 34, 18},\t// S\n{130, 34, 14},\t// T\n{146, 34, 18},\t// U\n{166, 34, 19},\t// V\n{185, 34, 29},\t// W\n{215, 34, 18},\t// X\n{234, 34, 18},\t// Y\n{5, 64, 14},\t// Z\n{60, 152, 7},\t// [\n{106, 151, 13},\t// '\\'\n{83, 152, 7},\t// ]\n{128, 122, 17},\t// ^\n{4, 152, 21},\t// _\n\n{134, 181, 5},\t// '\n{5, 4, 18},\t\t// A\n{27, 4, 18},\t// B\n{48, 4, 18},\t// C\n{69, 4, 17},\t// D\n{90, 4, 13},\t// E\n{106, 4, 13},\t// F\n{121, 4, 18},\t// G\n{143, 4, 17},\t// H\n{164, 4, 8},\t// I\n{175, 4, 16},\t// J\n{195, 4, 18},\t// K\n{216, 4, 12},\t// L\n{230, 4, 23},\t// M\n{6, 34, 18},\t// N\n{27, 34, 18},\t// O\n\n{48, 34, 18},\t// P\n{68, 34, 18},\t// Q\n{90, 34, 17},\t// R\n{110, 34, 18},\t// S\n{130, 34, 14},\t// T\n{146, 34, 18},\t// U\n{166, 34, 19},\t// V\n{185, 34, 29},\t// W\n{215, 34, 18},\t// X\n{234, 34, 18},\t// Y\n{5, 64, 14},\t// Z\n{153, 152, 13},\t// {\n{11, 181, 5},\t// |\n{180, 152, 13},\t// }\n{79, 93, 17},\t// ~\n{0, 0, -1}\t\t// DEL\n};\n\nstatic int propMapB[26][3] = {\n{11, 12, 33},\n{49, 12, 31},\n{85, 12, 31},\n{120, 12, 30},\n{156, 12, 21},\n{183, 12, 21},\n{207, 12, 32},\n\n{13, 55, 30},\n{49, 55, 13},\n{66, 55, 29},\n{101, 55, 31},\n{135, 55, 21},\n{158, 55, 40},\n{204, 55, 32},\n\n{12, 97, 31},\n{48, 97, 31},\n{82, 97, 30},\n{118, 97, 30},\n{153, 97, 30},\n{185, 97, 25},\n{213, 97, 30},\n\n{11, 139, 32},\n{42, 139, 51},\n{93, 139, 32},\n{126, 139, 31},\n{158, 139, 25},\n};\n\n#define PROPB_GAP_WIDTH\t\t4\n#define PROPB_SPACE_WIDTH\t12\n#define PROPB_HEIGHT\t\t36\n\n// bk001205 - code below duplicated in cgame/cg_drawtools.c\n// bk001205 - FIXME: does this belong in ui_shared.c?\n/*\n=================\nUI_DrawBannerString\n=================\n*/\nstatic void UI_DrawBannerString2( int x, int y, const char* str, vec4_t color )\n{\n\tconst char* s;\n\tunsigned char\tch; // bk001204 - unsigned\n\tfloat\tax;\n\tfloat\tay;\n\tfloat\taw;\n\tfloat\tah;\n\tfloat\tfrow;\n\tfloat\tfcol;\n\tfloat\tfwidth;\n\tfloat\tfheight;\n\n\t// draw the colored text\n\ttrap_R_SetColor( color );\n\t\n\tax = x * uis.scale + uis.bias;\n\tay = y * uis.scale;\n\n\ts = str;\n\twhile ( *s )\n\t{\n\t\tch = *s & 127;\n\t\tif ( ch == ' ' ) {\n\t\t\tax += ((float)PROPB_SPACE_WIDTH + (float)PROPB_GAP_WIDTH)* uis.scale;\n\t\t}\n\t\telse if ( ch >= 'A' && ch <= 'Z' ) {\n\t\t\tch -= 'A';\n\t\t\tfcol = (float)propMapB[ch][0] / 256.0f;\n\t\t\tfrow = (float)propMapB[ch][1] / 256.0f;\n\t\t\tfwidth = (float)propMapB[ch][2] / 256.0f;\n\t\t\tfheight = (float)PROPB_HEIGHT / 256.0f;\n\t\t\taw = (float)propMapB[ch][2] * uis.scale;\n\t\t\tah = (float)PROPB_HEIGHT * uis.scale;\n\t\t\ttrap_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol+fwidth, frow+fheight, uis.charsetPropB );\n\t\t\tax += (aw + (float)PROPB_GAP_WIDTH * uis.scale);\n\t\t}\n\t\ts++;\n\t}\n\n\ttrap_R_SetColor( NULL );\n}\n\nvoid UI_DrawBannerString( int x, int y, const char* str, int style, vec4_t color ) {\n\tconst char *\ts;\n\tint\t\t\t\tch;\n\tint\t\t\t\twidth;\n\tvec4_t\t\t\tdrawcolor;\n\n\t// find the width of the drawn text\n\ts = str;\n\twidth = 0;\n\twhile ( *s ) {\n\t\tch = *s;\n\t\tif ( ch == ' ' ) {\n\t\t\twidth += PROPB_SPACE_WIDTH;\n\t\t}\n\t\telse if ( ch >= 'A' && ch <= 'Z' ) {\n\t\t\twidth += propMapB[ch - 'A'][2] + PROPB_GAP_WIDTH;\n\t\t}\n\t\ts++;\n\t}\n\twidth -= PROPB_GAP_WIDTH;\n\n\tswitch( style & UI_FORMATMASK ) {\n\t\tcase UI_CENTER:\n\t\t\tx -= width / 2;\n\t\t\tbreak;\n\n\t\tcase UI_RIGHT:\n\t\t\tx -= width;\n\t\t\tbreak;\n\n\t\tcase UI_LEFT:\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\n\tif ( style & UI_DROPSHADOW ) {\n\t\tdrawcolor[0] = drawcolor[1] = drawcolor[2] = 0;\n\t\tdrawcolor[3] = color[3];\n\t\tUI_DrawBannerString2( x+2, y+2, str, drawcolor );\n\t}\n\n\tUI_DrawBannerString2( x, y, str, color );\n}\n\n\nint UI_ProportionalStringWidth( const char* str ) {\n\tconst char *\ts;\n\tint\t\t\t\tch;\n\tint\t\t\t\tcharWidth;\n\tint\t\t\t\twidth;\n\n\ts = str;\n\twidth = 0;\n\twhile ( *s ) {\n\t\tch = *s & 127;\n\t\tcharWidth = propMap[ch][2];\n\t\tif ( charWidth != -1 ) {\n\t\t\twidth += charWidth;\n\t\t\twidth += PROP_GAP_WIDTH;\n\t\t}\n\t\ts++;\n\t}\n\n\twidth -= PROP_GAP_WIDTH;\n\treturn width;\n}\n\nstatic void UI_DrawProportionalString2( int x, int y, const char* str, vec4_t color, float sizeScale, qhandle_t charset )\n{\n\tconst char* s;\n\tunsigned char\tch; // bk001204 - unsigned\n\tfloat\tax;\n\tfloat\tay;\n\tfloat\taw = 0; // bk001204 - init\n\tfloat\tah;\n\tfloat\tfrow;\n\tfloat\tfcol;\n\tfloat\tfwidth;\n\tfloat\tfheight;\n\n\t// draw the colored text\n\ttrap_R_SetColor( color );\n\t\n\tax = x * uis.scale + uis.bias;\n\tay = y * uis.scale;\n\n\ts = str;\n\twhile ( *s )\n\t{\n\t\tch = *s & 127;\n\t\tif ( ch == ' ' ) {\n\t\t\taw = (float)PROP_SPACE_WIDTH * uis.scale * sizeScale;\n\t\t}\n\t\telse if ( propMap[ch][2] != -1 ) {\n\t\t\tfcol = (float)propMap[ch][0] / 256.0f;\n\t\t\tfrow = (float)propMap[ch][1] / 256.0f;\n\t\t\tfwidth = (float)propMap[ch][2] / 256.0f;\n\t\t\tfheight = (float)PROP_HEIGHT / 256.0f;\n\t\t\taw = (float)propMap[ch][2] * uis.scale * sizeScale;\n\t\t\tah = (float)PROP_HEIGHT * uis.scale * sizeScale;\n\t\t\ttrap_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol+fwidth, frow+fheight, charset );\n\t\t}\n\n\t\tax += (aw + (float)PROP_GAP_WIDTH * uis.scale * sizeScale);\n\t\ts++;\n\t}\n\n\ttrap_R_SetColor( NULL );\n}\n\n/*\n=================\nUI_ProportionalSizeScale\n=================\n*/\nfloat UI_ProportionalSizeScale( int style ) {\n\tif(  style & UI_SMALLFONT ) {\n\t\treturn PROP_SMALL_SIZE_SCALE;\n\t}\n\n\treturn 1.00;\n}\n\n\n/*\n=================\nUI_DrawProportionalString\n=================\n*/\nvoid UI_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color ) {\n\tvec4_t\tdrawcolor;\n\tint\t\twidth;\n\tfloat\tsizeScale;\n\n\tsizeScale = UI_ProportionalSizeScale( style );\n\n\tswitch( style & UI_FORMATMASK ) {\n\t\tcase UI_CENTER:\n\t\t\twidth = UI_ProportionalStringWidth( str ) * sizeScale;\n\t\t\tx -= width / 2;\n\t\t\tbreak;\n\n\t\tcase UI_RIGHT:\n\t\t\twidth = UI_ProportionalStringWidth( str ) * sizeScale;\n\t\t\tx -= width;\n\t\t\tbreak;\n\n\t\tcase UI_LEFT:\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\n\tif ( style & UI_DROPSHADOW ) {\n\t\tdrawcolor[0] = drawcolor[1] = drawcolor[2] = 0;\n\t\tdrawcolor[3] = color[3];\n\t\tUI_DrawProportionalString2( x+2, y+2, str, drawcolor, sizeScale, uis.charsetProp );\n\t}\n\n\tif ( style & UI_INVERSE ) {\n\t\tdrawcolor[0] = color[0] * 0.7;\n\t\tdrawcolor[1] = color[1] * 0.7;\n\t\tdrawcolor[2] = color[2] * 0.7;\n\t\tdrawcolor[3] = color[3];\n\t\tUI_DrawProportionalString2( x, y, str, drawcolor, sizeScale, uis.charsetProp );\n\t\treturn;\n\t}\n\n\tif ( style & UI_PULSE ) {\n\t\tdrawcolor[0] = color[0] * 0.7;\n\t\tdrawcolor[1] = color[1] * 0.7;\n\t\tdrawcolor[2] = color[2] * 0.7;\n\t\tdrawcolor[3] = color[3];\n\t\tUI_DrawProportionalString2( x, y, str, color, sizeScale, uis.charsetProp );\n\n\t\tdrawcolor[0] = color[0];\n\t\tdrawcolor[1] = color[1];\n\t\tdrawcolor[2] = color[2];\n\t\tdrawcolor[3] = 0.5 + 0.5 * sin( uis.realtime / PULSE_DIVISOR );\n\t\tUI_DrawProportionalString2( x, y, str, drawcolor, sizeScale, uis.charsetPropGlow );\n\t\treturn;\n\t}\n\n\tUI_DrawProportionalString2( x, y, str, color, sizeScale, uis.charsetProp );\n}\n\n/*\n=================\nUI_DrawProportionalString_Wrapped\n=================\n*/\nvoid UI_DrawProportionalString_AutoWrapped( int x, int y, int xmax, int ystep, const char* str, int style, vec4_t color ) {\n\tint width;\n\tchar *s1,*s2,*s3;\n\tchar c_bcp;\n\tchar buf[1024];\n\tfloat   sizeScale;\n\n\tif (!str || str[0]=='\\0')\n\t\treturn;\n\t\n\tsizeScale = UI_ProportionalSizeScale( style );\n\t\n\tQ_strncpyz(buf, str, sizeof(buf));\n\ts1 = s2 = s3 = buf;\n\n\twhile (1) {\n\t\tdo {\n\t\t\ts3++;\n\t\t} while (*s3!=' ' && *s3!='\\0');\n\t\tc_bcp = *s3;\n\t\t*s3 = '\\0';\n\t\twidth = UI_ProportionalStringWidth(s1) * sizeScale;\n\t\t*s3 = c_bcp;\n\t\tif (width > xmax) {\n\t\t\tif (s1==s2)\n\t\t\t{\n\t\t\t\t// fuck, don't have a clean cut, we'll overflow\n\t\t\t\ts2 = s3;\n\t\t\t}\n\t\t\t*s2 = '\\0';\n\t\t\tUI_DrawProportionalString(x, y, s1, style, color);\n\t\t\ty += ystep;\n\t\t\tif (c_bcp == '\\0')\n      {\n        // that was the last word\n        // we could start a new loop, but that wouldn't be much use\n        // even if the word is too long, we would overflow it (see above)\n        // so just print it now if needed\n        s2++;\n        if (*s2 != '\\0') // if we are printing an overflowing line we have s2 == s3\n          UI_DrawProportionalString(x, y, s2, style, color);\n\t\t\t\tbreak; \n      }\n\t\t\ts2++;\n\t\t\ts1 = s2;\n\t\t\ts3 = s2;\n\t\t}\n\t\telse\n\t\t{\n\t\t\ts2 = s3;\n\t\t\tif (c_bcp == '\\0') // we reached the end\n\t\t\t{\n\t\t\t\tUI_DrawProportionalString(x, y, s1, style, color);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n=================\nUI_DrawString2\n=================\n*/\nstatic void UI_DrawString2( int x, int y, const char* str, vec4_t color, int charw, int charh )\n{\n\tconst char* s;\n\tchar\tch;\n\tint forceColor = qfalse; //APSFIXME;\n\tvec4_t\ttempcolor;\n\tfloat\tax;\n\tfloat\tay;\n\tfloat\taw;\n\tfloat\tah;\n\tfloat\tfrow;\n\tfloat\tfcol;\n\n\tif (y < -charh)\n\t\t// offscreen\n\t\treturn;\n\n\t// draw the colored text\n\ttrap_R_SetColor( color );\n\t\n\tax = x * uis.scale + uis.bias;\n\tay = y * uis.scale;\n\taw = charw * uis.scale;\n\tah = charh * uis.scale;\n\n\ts = str;\n\twhile ( *s )\n\t{\n\t\tif ( Q_IsColorString( s ) )\n\t\t{\n\t\t\tif ( !forceColor )\n\t\t\t{\n\t\t\t\tmemcpy( tempcolor, g_color_table[ColorIndex(s[1])], sizeof( tempcolor ) );\n\t\t\t\ttempcolor[3] = color[3];\n\t\t\t\ttrap_R_SetColor( tempcolor );\n\t\t\t}\n\t\t\ts += 2;\n\t\t\tcontinue;\n\t\t}\n\n\t\tch = *s & 255;\n\t\tif (ch != ' ')\n\t\t{\n\t\t\tfrow = (ch>>4)*0.0625;\n\t\t\tfcol = (ch&15)*0.0625;\n\t\t\ttrap_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol + 0.0625, frow + 0.0625, uis.charset );\n\t\t}\n\n\t\tax += aw;\n\t\ts++;\n\t}\n\n\ttrap_R_SetColor( NULL );\n}\n\n/*\n=================\nUI_DrawString\n=================\n*/\nvoid UI_DrawString( int x, int y, const char* str, int style, vec4_t color )\n{\n\tint\t\tlen;\n\tint\t\tcharw;\n\tint\t\tcharh;\n\tvec4_t\tnewcolor;\n\tvec4_t\tlowlight;\n\tfloat\t*drawcolor;\n\tvec4_t\tdropcolor;\n\n\tif( !str ) {\n\t\treturn;\n\t}\n\n\tif ((style & UI_BLINK) && ((uis.realtime/BLINK_DIVISOR) & 1))\n\t\treturn;\n\n\tif (style & UI_SMALLFONT)\n\t{\n\t\tcharw =\tSMALLCHAR_WIDTH;\n\t\tcharh =\tSMALLCHAR_HEIGHT;\n\t}\n\telse if (style & UI_GIANTFONT)\n\t{\n\t\tcharw =\tGIANTCHAR_WIDTH;\n\t\tcharh =\tGIANTCHAR_HEIGHT;\n\t}\n\telse\n\t{\n\t\tcharw =\tBIGCHAR_WIDTH;\n\t\tcharh =\tBIGCHAR_HEIGHT;\n\t}\n\n\tif (style & UI_PULSE)\n\t{\n\t\tlowlight[0] = 0.8*color[0]; \n\t\tlowlight[1] = 0.8*color[1];\n\t\tlowlight[2] = 0.8*color[2];\n\t\tlowlight[3] = 0.8*color[3];\n\t\tUI_LerpColor(color,lowlight,newcolor,0.5+0.5*sin(uis.realtime/PULSE_DIVISOR));\n\t\tdrawcolor = newcolor;\n\t}\t\n\telse\n\t\tdrawcolor = color;\n\n\tswitch (style & UI_FORMATMASK)\n\t{\n\t\tcase UI_CENTER:\n\t\t\t// center justify at x\n\t\t\tlen = strlen(str);\n\t\t\tx   = x - len*charw/2;\n\t\t\tbreak;\n\n\t\tcase UI_RIGHT:\n\t\t\t// right justify at x\n\t\t\tlen = strlen(str);\n\t\t\tx   = x - len*charw;\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\t// left justify at x\n\t\t\tbreak;\n\t}\n\n\tif ( style & UI_DROPSHADOW )\n\t{\n\t\tdropcolor[0] = dropcolor[1] = dropcolor[2] = 0;\n\t\tdropcolor[3] = drawcolor[3];\n\t\tUI_DrawString2(x+2,y+2,str,dropcolor,charw,charh);\n\t}\n\n\tUI_DrawString2(x,y,str,drawcolor,charw,charh);\n}\n\n/*\n=================\nUI_DrawChar\n=================\n*/\nvoid UI_DrawChar( int x, int y, int ch, int style, vec4_t color )\n{\n\tchar\tbuff[2];\n\n\tbuff[0] = ch;\n\tbuff[1] = '\\0';\n\n\tUI_DrawString( x, y, buff, style, color );\n}\n\nqboolean UI_IsFullscreen( void ) {\n\tif ( uis.activemenu && ( trap_Key_GetCatcher() & KEYCATCH_UI ) ) {\n\t\treturn uis.activemenu->fullscreen;\n\t}\n\n\treturn qfalse;\n}\n\nstatic void NeedCDAction( qboolean result ) {\n\tif ( !result ) {\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"quit\\n\" );\n\t}\n}\n\nstatic void NeedCDKeyAction( qboolean result ) {\n\tif ( !result ) {\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"quit\\n\" );\n\t}\n}\n\nvoid UI_SetActiveMenu( uiMenuCommand_t menu ) {\n\t// this should be the ONLY way the menu system is brought up\n\t// enusure minumum menu data is cached\n\tMenu_Cache();\n\n\tswitch ( menu ) {\n\tcase UIMENU_NONE:\n\t\tUI_ForceMenuOff();\n\t\treturn;\n\tcase UIMENU_MAIN:\n\t\tUI_MainMenu();\n\t\treturn;\n\tcase UIMENU_NEED_CD:\n\t\tUI_ConfirmMenu( \"Insert the CD\", (voidfunc_f)NULL, NeedCDAction );\n\t\treturn;\n\tcase UIMENU_BAD_CD_KEY:\n\t\tUI_ConfirmMenu( \"Bad CD Key\", (voidfunc_f)NULL, NeedCDKeyAction );\n\t\treturn;\n\tcase UIMENU_INGAME:\n\t\t/*\n\t\t//GRank\n\t\tUI_RankingsMenu();\n\t\treturn;\n\t\t*/\n\t\ttrap_Cvar_Set( \"cl_paused\", \"1\" );\n\t\tUI_InGameMenu();\n\t\treturn;\n\t\t\n\t// bk001204\n\tcase UIMENU_TEAM:\n\tcase UIMENU_POSTGAME:\n\tdefault:\n#ifndef NDEBUG\n\t  Com_Printf(\"UI_SetActiveMenu: bad enum %d\\n\", menu );\n#endif\n\t  break;\n\t}\n}\n\n/*\n=================\nUI_KeyEvent\n=================\n*/\nvoid UI_KeyEvent( int key, int down ) {\n\tsfxHandle_t\t\ts;\n\n\tif (!uis.activemenu) {\n\t\treturn;\n\t}\n\n\tif (!down) {\n\t\treturn;\n\t}\n\n\tif (uis.activemenu->key)\n\t\ts = uis.activemenu->key( key );\n\telse\n\t\ts = Menu_DefaultKey( uis.activemenu, key );\n\n\tif ((s > 0) && (s != menu_null_sound))\n\t\ttrap_S_StartLocalSound( s, CHAN_LOCAL_SOUND );\n}\n\n/*\n=================\nUI_MouseEvent\n=================\n*/\nvoid UI_MouseEvent( int dx, int dy )\n{\n\tint\t\t\t\ti;\n\tmenucommon_s*\tm;\n\n\tif (!uis.activemenu)\n\t\treturn;\n\n\t// update mouse screen position\n\tuis.cursorx += dx;\n\tif (uis.cursorx < 0)\n\t\tuis.cursorx = 0;\n\telse if (uis.cursorx > SCREEN_WIDTH)\n\t\tuis.cursorx = SCREEN_WIDTH;\n\n\tuis.cursory += dy;\n\tif (uis.cursory < 0)\n\t\tuis.cursory = 0;\n\telse if (uis.cursory > SCREEN_HEIGHT)\n\t\tuis.cursory = SCREEN_HEIGHT;\n\n\t// region test the active menu items\n\tfor (i=0; i<uis.activemenu->nitems; i++)\n\t{\n\t\tm = (menucommon_s*)uis.activemenu->items[i];\n\n\t\tif (m->flags & (QMF_GRAYED|QMF_INACTIVE))\n\t\t\tcontinue;\n\n\t\tif ((uis.cursorx < m->left) ||\n\t\t\t(uis.cursorx > m->right) ||\n\t\t\t(uis.cursory < m->top) ||\n\t\t\t(uis.cursory > m->bottom))\n\t\t{\n\t\t\t// cursor out of item bounds\n\t\t\tcontinue;\n\t\t}\n\n\t\t// set focus to item at cursor\n\t\tif (uis.activemenu->cursor != i)\n\t\t{\n\t\t\tMenu_SetCursor( uis.activemenu, i );\n\t\t\t((menucommon_s*)(uis.activemenu->items[uis.activemenu->cursor_prev]))->flags &= ~QMF_HASMOUSEFOCUS;\n\n\t\t\tif ( !(((menucommon_s*)(uis.activemenu->items[uis.activemenu->cursor]))->flags & QMF_SILENT ) ) {\n\t\t\t\ttrap_S_StartLocalSound( menu_move_sound, CHAN_LOCAL_SOUND );\n\t\t\t}\n\t\t}\n\n\t\t((menucommon_s*)(uis.activemenu->items[uis.activemenu->cursor]))->flags |= QMF_HASMOUSEFOCUS;\n\t\treturn;\n\t}  \n\n\tif (uis.activemenu->nitems > 0) {\n\t\t// out of any region\n\t\t((menucommon_s*)(uis.activemenu->items[uis.activemenu->cursor]))->flags &= ~QMF_HASMOUSEFOCUS;\n\t}\n}\n\nchar *UI_Argv( int arg ) {\n\tstatic char\tbuffer[MAX_STRING_CHARS];\n\n\ttrap_Argv( arg, buffer, sizeof( buffer ) );\n\n\treturn buffer;\n}\n\n\nchar *UI_Cvar_VariableString( const char *var_name ) {\n\tstatic char\tbuffer[MAX_STRING_CHARS];\n\n\ttrap_Cvar_VariableStringBuffer( var_name, buffer, sizeof( buffer ) );\n\n\treturn buffer;\n}\n\n\n/*\n=================\nUI_Cache\n=================\n*/\nvoid UI_Cache_f( void ) {\n\tMainMenu_Cache();\n\tInGame_Cache();\n\tConfirmMenu_Cache();\n\tPlayerModel_Cache();\n\tPlayerSettings_Cache();\n\tControls_Cache();\n\tDemos_Cache();\n\tUI_CinematicsMenu_Cache();\n\tPreferences_Cache();\n\tServerInfo_Cache();\n\tSpecifyServer_Cache();\n\tArenaServers_Cache();\n\tStartServer_Cache();\n\tServerOptions_Cache();\n\tDriverInfo_Cache();\n\tGraphicsOptions_Cache();\n\tUI_DisplayOptionsMenu_Cache();\n\tUI_SoundOptionsMenu_Cache();\n\tUI_NetworkOptionsMenu_Cache();\n\tUI_SPLevelMenu_Cache();\n\tUI_SPSkillMenu_Cache();\n\tUI_SPPostgameMenu_Cache();\n\tTeamMain_Cache();\n\tUI_AddBots_Cache();\n\tUI_RemoveBots_Cache();\n\tUI_SetupMenu_Cache();\n//\tUI_LoadConfig_Cache();\n//\tUI_SaveConfigMenu_Cache();\n\tUI_BotSelectMenu_Cache();\n\tUI_CDKeyMenu_Cache();\n\tUI_ModsMenu_Cache();\n\n}\n\n\n/*\n=================\nUI_ConsoleCommand\n=================\n*/\nqboolean UI_ConsoleCommand( int realTime ) {\n\tchar\t*cmd;\n\n\tcmd = UI_Argv( 0 );\n\n\t// ensure minimum menu data is available\n\tMenu_Cache();\n\n\tif ( Q_stricmp (cmd, \"levelselect\") == 0 ) {\n\t\tUI_SPLevelMenu_f();\n\t\treturn qtrue;\n\t}\n\n\tif ( Q_stricmp (cmd, \"postgame\") == 0 ) {\n\t\tUI_SPPostgameMenu_f();\n\t\treturn qtrue;\n\t}\n\n\tif ( Q_stricmp (cmd, \"ui_cache\") == 0 ) {\n\t\tUI_Cache_f();\n\t\treturn qtrue;\n\t}\n\n\tif ( Q_stricmp (cmd, \"ui_cinematics\") == 0 ) {\n\t\tUI_CinematicsMenu_f();\n\t\treturn qtrue;\n\t}\n\n\tif ( Q_stricmp (cmd, \"ui_teamOrders\") == 0 ) {\n\t\tUI_TeamOrdersMenu_f();\n\t\treturn qtrue;\n\t}\n\n\tif ( Q_stricmp (cmd, \"iamacheater\") == 0 ) {\n\t\tUI_SPUnlock_f();\n\t\treturn qtrue;\n\t}\n\n\tif ( Q_stricmp (cmd, \"iamamonkey\") == 0 ) {\n\t\tUI_SPUnlockMedals_f();\n\t\treturn qtrue;\n\t}\n\n\tif ( Q_stricmp (cmd, \"ui_cdkey\") == 0 ) {\n\t\tUI_CDKeyMenu_f();\n\t\treturn qtrue;\n\t}\n\n\treturn qfalse;\n}\n\n/*\n=================\nUI_Shutdown\n=================\n*/\nvoid UI_Shutdown( void ) {\n}\n\n/*\n=================\nUI_Init\n=================\n*/\nvoid UI_Init( void ) {\n\tUI_RegisterCvars();\n\n\tUI_InitGameinfo();\n\n\t// cache redundant calulations\n\ttrap_GetGlconfig( &uis.glconfig );\n\n\t// for 640x480 virtualized screen\n\tuis.scale = uis.glconfig.vidHeight * (1.0/480.0);\n\tif ( uis.glconfig.vidWidth * 480 > uis.glconfig.vidHeight * 640 ) {\n\t\t// wide screen\n\t\tuis.bias = 0.5 * ( uis.glconfig.vidWidth - ( uis.glconfig.vidHeight * (640.0/480.0) ) );\n\t}\n\telse {\n\t\t// no wide screen\n\t\tuis.bias = 0;\n\t}\n\n\t// initialize the menu system\n\tMenu_Cache();\n\n\tuis.activemenu = NULL;\n\tuis.menusp     = 0;\n}\n\n/*\n================\nUI_AdjustFrom640\n\nAdjusted for resolution and screen aspect ratio\n================\n*/\nvoid UI_AdjustFrom640( float *x, float *y, float *w, float *h ) {\n\t// expect valid pointers\n\t*x = *x * uis.scale + uis.bias;\n\t*y *= uis.scale;\n\t*w *= uis.scale;\n\t*h *= uis.scale;\n}\n\nvoid UI_DrawNamedPic( float x, float y, float width, float height, const char *picname ) {\n\tqhandle_t\thShader;\n\n\thShader = trap_R_RegisterShaderNoMip( picname );\n\tUI_AdjustFrom640( &x, &y, &width, &height );\n\ttrap_R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader );\n}\n\nvoid UI_DrawHandlePic( float x, float y, float w, float h, qhandle_t hShader ) {\n\tfloat\ts0;\n\tfloat\ts1;\n\tfloat\tt0;\n\tfloat\tt1;\n\n\tif( w < 0 ) {\t// flip about vertical\n\t\tw  = -w;\n\t\ts0 = 1;\n\t\ts1 = 0;\n\t}\n\telse {\n\t\ts0 = 0;\n\t\ts1 = 1;\n\t}\n\n\tif( h < 0 ) {\t// flip about horizontal\n\t\th  = -h;\n\t\tt0 = 1;\n\t\tt1 = 0;\n\t}\n\telse {\n\t\tt0 = 0;\n\t\tt1 = 1;\n\t}\n\t\n\tUI_AdjustFrom640( &x, &y, &w, &h );\n\ttrap_R_DrawStretchPic( x, y, w, h, s0, t0, s1, t1, hShader );\n}\n\n/*\n================\nUI_FillRect\n\nCoordinates are 640*480 virtual values\n=================\n*/\nvoid UI_FillRect( float x, float y, float width, float height, const float *color ) {\n\ttrap_R_SetColor( color );\n\n\tUI_AdjustFrom640( &x, &y, &width, &height );\n\ttrap_R_DrawStretchPic( x, y, width, height, 0, 0, 0, 0, uis.whiteShader );\n\n\ttrap_R_SetColor( NULL );\n}\n\n/*\n================\nUI_DrawRect\n\nCoordinates are 640*480 virtual values\n=================\n*/\nvoid UI_DrawRect( float x, float y, float width, float height, const float *color ) {\n\ttrap_R_SetColor( color );\n\n\tUI_AdjustFrom640( &x, &y, &width, &height );\n\n\ttrap_R_DrawStretchPic( x, y, width, 1, 0, 0, 0, 0, uis.whiteShader );\n\ttrap_R_DrawStretchPic( x, y, 1, height, 0, 0, 0, 0, uis.whiteShader );\n\ttrap_R_DrawStretchPic( x, y + height - 1, width, 1, 0, 0, 0, 0, uis.whiteShader );\n\ttrap_R_DrawStretchPic( x + width - 1, y, 1, height, 0, 0, 0, 0, uis.whiteShader );\n\n\ttrap_R_SetColor( NULL );\n}\n\nvoid UI_SetColor( const float *rgba ) {\n\ttrap_R_SetColor( rgba );\n}\n\nvoid UI_UpdateScreen( void ) {\n\ttrap_UpdateScreen();\n}\n\n/*\n=================\nUI_Refresh\n=================\n*/\nvoid UI_Refresh( int realtime )\n{\n\tuis.frametime = realtime - uis.realtime;\n\tuis.realtime  = realtime;\n\n\tif ( !( trap_Key_GetCatcher() & KEYCATCH_UI ) ) {\n\t\treturn;\n\t}\n\n\tUI_UpdateCvars();\n\n\tif ( uis.activemenu )\n\t{\n\t\tif (uis.activemenu->fullscreen)\n\t\t{\n\t\t\t// draw the background\n\t\t\tif( uis.activemenu->showlogo ) {\n\t\t\t\tUI_DrawHandlePic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, uis.menuBackShader );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tUI_DrawHandlePic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, uis.menuBackNoLogoShader );\n\t\t\t}\n\t\t}\n\n\t\tif (uis.activemenu->draw)\n\t\t\tuis.activemenu->draw();\n\t\telse\n\t\t\tMenu_Draw( uis.activemenu );\n\n\t\tif( uis.firstdraw ) {\n\t\t\tUI_MouseEvent( 0, 0 );\n\t\t\tuis.firstdraw = qfalse;\n\t\t}\n\t}\n\n\t// draw cursor\n\tUI_SetColor( NULL );\n\tUI_DrawHandlePic( uis.cursorx-16, uis.cursory-16, 32, 32, uis.cursor);\n\n#ifndef NDEBUG\n\tif (uis.debug)\n\t{\n\t\t// cursor coordinates\n\t\tUI_DrawString( 0, 0, va(\"(%d,%d)\",uis.cursorx,uis.cursory), UI_LEFT|UI_SMALLFONT, colorRed );\n\t}\n#endif\n\n\t// delay playing the enter sound until after the\n\t// menu has been drawn, to avoid delay while\n\t// caching images\n\tif (m_entersound)\n\t{\n\t\ttrap_S_StartLocalSound( menu_in_sound, CHAN_LOCAL_SOUND );\n\t\tm_entersound = qfalse;\n\t}\n}\n\nvoid UI_DrawTextBox (int x, int y, int width, int lines)\n{\n\tUI_FillRect( x + BIGCHAR_WIDTH/2, y + BIGCHAR_HEIGHT/2, ( width + 1 ) * BIGCHAR_WIDTH, ( lines + 1 ) * BIGCHAR_HEIGHT, colorBlack );\n\tUI_DrawRect( x + BIGCHAR_WIDTH/2, y + BIGCHAR_HEIGHT/2, ( width + 1 ) * BIGCHAR_WIDTH, ( lines + 1 ) * BIGCHAR_HEIGHT, colorWhite );\n}\n\nqboolean UI_CursorInRect (int x, int y, int width, int height)\n{\n\tif (uis.cursorx < x ||\n\t\tuis.cursory < y ||\n\t\tuis.cursorx > x+width ||\n\t\tuis.cursory > y+height)\n\t\treturn qfalse;\n\n\treturn qtrue;\n}\n"
  },
  {
    "path": "code/q3_ui/ui_cdkey.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=======================================================================\n\nCD KEY MENU\n\n=======================================================================\n*/\n\n\n#include \"ui_local.h\"\n\n\n#define ART_FRAME\t\t\"menu/art/cut_frame\"\n#define ART_ACCEPT0\t\t\"menu/art/accept_0\"\n#define ART_ACCEPT1\t\t\"menu/art/accept_1\"\t\n#define ART_BACK0\t\t\"menu/art/back_0\"\n#define ART_BACK1\t\t\"menu/art/back_1\"\t\n\n#define ID_CDKEY\t\t10\n#define ID_ACCEPT\t\t11\n#define ID_BACK\t\t\t12\n\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n\n\tmenutext_s\t\tbanner;\n\tmenubitmap_s\tframe;\n\n\tmenufield_s\t\tcdkey;\n\n\tmenubitmap_s\taccept;\n\tmenubitmap_s\tback;\n} cdkeyMenuInfo_t;\n\nstatic cdkeyMenuInfo_t\tcdkeyMenuInfo;\n\n\n/*\n===============\nUI_CDKeyMenu_Event\n===============\n*/\nstatic void UI_CDKeyMenu_Event( void *ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tswitch( ((menucommon_s*)ptr)->id ) {\n\tcase ID_ACCEPT:\n\t\tif( cdkeyMenuInfo.cdkey.field.buffer[0] ) {\n\t\t\ttrap_SetCDKey( cdkeyMenuInfo.cdkey.field.buffer );\n\t\t}\n\t\tUI_PopMenu();\n\t\tbreak;\n\n\tcase ID_BACK:\n\t\tUI_PopMenu();\n\t\tbreak;\n\t}\n}\n\n\n/*\n=================\nUI_CDKeyMenu_PreValidateKey\n=================\n*/\nstatic int UI_CDKeyMenu_PreValidateKey( const char *key ) {\n\tchar\tch;\n\n\tif( strlen( key ) != 16 ) {\n\t\treturn 1;\n\t}\n\n\twhile( ( ch = *key++ ) ) {\n\t\tswitch( ch ) {\n\t\tcase '2':\n\t\tcase '3':\n\t\tcase '7':\n\t\tcase 'a':\n\t\tcase 'b':\n\t\tcase 'c':\n\t\tcase 'd':\n\t\tcase 'g':\n\t\tcase 'h':\n\t\tcase 'j':\n\t\tcase 'l':\n\t\tcase 'p':\n\t\tcase 'r':\n\t\tcase 's':\n\t\tcase 't':\n\t\tcase 'w':\n\t\t\tcontinue;\n\t\tdefault:\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\n\n/*\n=================\nUI_CDKeyMenu_DrawKey\n=================\n*/\nstatic void UI_CDKeyMenu_DrawKey( void *self ) {\n\tmenufield_s\t\t*f;\n\tqboolean\t\tfocus;\n\tint\t\t\t\tstyle;\n\tchar\t\t\tc;\n\tfloat\t\t\t*color;\n\tint\t\t\t\tx, y;\n\tint\t\t\t\tval;\n\n\tf = (menufield_s *)self;\n\n\tfocus = (f->generic.parent->cursor == f->generic.menuPosition);\n\n\tstyle = UI_LEFT;\n\tif( focus ) {\n\t\tcolor = color_yellow;\n\t}\n\telse {\n\t\tcolor = color_orange;\n\t}\n\n\tx = 320 - 8 * BIGCHAR_WIDTH;\n\ty = 240 - BIGCHAR_HEIGHT / 2;\n\tUI_FillRect( x, y, 16 * BIGCHAR_WIDTH, BIGCHAR_HEIGHT, listbar_color );\n\tUI_DrawString( x, y, f->field.buffer, style, color );\n\n\t// draw cursor if we have focus\n\tif( focus ) {\n\t\tif ( trap_Key_GetOverstrikeMode() ) {\n\t\t\tc = 11;\n\t\t} else {\n\t\t\tc = 10;\n\t\t}\n\n\t\tstyle &= ~UI_PULSE;\n\t\tstyle |= UI_BLINK;\n\n\t\tUI_DrawChar( x + f->field.cursor * BIGCHAR_WIDTH, y, c, style, color_white );\n\t}\n\n\tval = UI_CDKeyMenu_PreValidateKey( f->field.buffer );\n\tif( val == 1 ) {\n\t\tUI_DrawProportionalString( 320, 376, \"Please enter your CD Key\", UI_CENTER|UI_SMALLFONT, color_yellow );\n\t}\n\telse if ( val == 0 ) {\n\t\tUI_DrawProportionalString( 320, 376, \"The CD Key appears to be valid, thank you\", UI_CENTER|UI_SMALLFONT, color_white );\n\t}\n\telse {\n\t\tUI_DrawProportionalString( 320, 376, \"The CD Key is not valid\", UI_CENTER|UI_SMALLFONT, color_red );\n\t}\n}\n\n\n/*\n===============\nUI_CDKeyMenu_Init\n===============\n*/\nstatic void UI_CDKeyMenu_Init( void ) {\n\ttrap_Cvar_Set( \"ui_cdkeychecked\", \"1\" );\n\n\tUI_CDKeyMenu_Cache();\n\n\tmemset( &cdkeyMenuInfo, 0, sizeof(cdkeyMenuInfo) );\n\tcdkeyMenuInfo.menu.wrapAround = qtrue;\n\tcdkeyMenuInfo.menu.fullscreen = qtrue;\n\n\tcdkeyMenuInfo.banner.generic.type\t\t\t\t= MTYPE_BTEXT;\n\tcdkeyMenuInfo.banner.generic.x\t\t\t\t\t= 320;\n\tcdkeyMenuInfo.banner.generic.y\t\t\t\t\t= 16;\n\tcdkeyMenuInfo.banner.string\t\t\t\t\t\t= \"CD KEY\";\n\tcdkeyMenuInfo.banner.color\t\t\t\t\t\t= color_white;\n\tcdkeyMenuInfo.banner.style\t\t\t\t\t\t= UI_CENTER;\n\n\tcdkeyMenuInfo.frame.generic.type\t\t\t\t= MTYPE_BITMAP;\n\tcdkeyMenuInfo.frame.generic.name\t\t\t\t= ART_FRAME;\n\tcdkeyMenuInfo.frame.generic.flags\t\t\t\t= QMF_INACTIVE;\n\tcdkeyMenuInfo.frame.generic.x\t\t\t\t\t= 142;\n\tcdkeyMenuInfo.frame.generic.y\t\t\t\t\t= 118;\n\tcdkeyMenuInfo.frame.width  \t\t\t\t\t\t= 359;\n\tcdkeyMenuInfo.frame.height  \t\t\t\t\t= 256;\n\n\tcdkeyMenuInfo.cdkey.generic.type\t\t\t\t= MTYPE_FIELD;\n\tcdkeyMenuInfo.cdkey.generic.name\t\t\t\t= \"CD Key:\";\n\tcdkeyMenuInfo.cdkey.generic.flags\t\t\t\t= QMF_LOWERCASE;\n\tcdkeyMenuInfo.cdkey.generic.x\t\t\t\t\t= 320 - BIGCHAR_WIDTH * 2.5;\n\tcdkeyMenuInfo.cdkey.generic.y\t\t\t\t\t= 240 - BIGCHAR_HEIGHT / 2;\n\tcdkeyMenuInfo.cdkey.field.widthInChars\t\t\t= 16;\n\tcdkeyMenuInfo.cdkey.field.maxchars\t\t\t\t= 16;\n\tcdkeyMenuInfo.cdkey.generic.ownerdraw\t\t\t= UI_CDKeyMenu_DrawKey;\n\n\tcdkeyMenuInfo.accept.generic.type\t\t\t\t= MTYPE_BITMAP;\n\tcdkeyMenuInfo.accept.generic.name\t\t\t\t= ART_ACCEPT0;\n\tcdkeyMenuInfo.accept.generic.flags\t\t\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tcdkeyMenuInfo.accept.generic.id\t\t\t\t\t= ID_ACCEPT;\n\tcdkeyMenuInfo.accept.generic.callback\t\t\t= UI_CDKeyMenu_Event;\n\tcdkeyMenuInfo.accept.generic.x\t\t\t\t\t= 640;\n\tcdkeyMenuInfo.accept.generic.y\t\t\t\t\t= 480-64;\n\tcdkeyMenuInfo.accept.width\t\t\t\t\t\t= 128;\n\tcdkeyMenuInfo.accept.height\t\t\t\t\t\t= 64;\n\tcdkeyMenuInfo.accept.focuspic\t\t\t\t\t= ART_ACCEPT1;\n\n\tcdkeyMenuInfo.back.generic.type\t\t\t\t\t= MTYPE_BITMAP;\n\tcdkeyMenuInfo.back.generic.name\t\t\t\t\t= ART_BACK0;\n\tcdkeyMenuInfo.back.generic.flags\t\t\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tcdkeyMenuInfo.back.generic.id\t\t\t\t\t= ID_BACK;\n\tcdkeyMenuInfo.back.generic.callback\t\t\t\t= UI_CDKeyMenu_Event;\n\tcdkeyMenuInfo.back.generic.x\t\t\t\t\t= 0;\n\tcdkeyMenuInfo.back.generic.y\t\t\t\t\t= 480-64;\n\tcdkeyMenuInfo.back.width\t\t\t\t\t\t= 128;\n\tcdkeyMenuInfo.back.height\t\t\t\t\t\t= 64;\n\tcdkeyMenuInfo.back.focuspic\t\t\t\t\t\t= ART_BACK1;\n\n\tMenu_AddItem( &cdkeyMenuInfo.menu, &cdkeyMenuInfo.banner );\n\tMenu_AddItem( &cdkeyMenuInfo.menu, &cdkeyMenuInfo.frame );\n\tMenu_AddItem( &cdkeyMenuInfo.menu, &cdkeyMenuInfo.cdkey );\n\tMenu_AddItem( &cdkeyMenuInfo.menu, &cdkeyMenuInfo.accept );\n\tif( uis.menusp ) {\n\t\tMenu_AddItem( &cdkeyMenuInfo.menu, &cdkeyMenuInfo.back );\n\t}\n\n\ttrap_GetCDKey( cdkeyMenuInfo.cdkey.field.buffer, cdkeyMenuInfo.cdkey.field.maxchars + 1 );\n\tif( trap_VerifyCDKey( cdkeyMenuInfo.cdkey.field.buffer, NULL ) == qfalse ) {\n\t\tcdkeyMenuInfo.cdkey.field.buffer[0] = 0;\n\t}\n}\n\n\n/*\n=================\nUI_CDKeyMenu_Cache\n=================\n*/\nvoid UI_CDKeyMenu_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( ART_ACCEPT0 );\n\ttrap_R_RegisterShaderNoMip( ART_ACCEPT1 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK0 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK1 );\n\ttrap_R_RegisterShaderNoMip( ART_FRAME );\n}\n\n\n/*\n===============\nUI_CDKeyMenu\n===============\n*/\nvoid UI_CDKeyMenu( void ) {\n\tUI_CDKeyMenu_Init();\n\tUI_PushMenu( &cdkeyMenuInfo.menu );\n}\n\n\n/*\n===============\nUI_CDKeyMenu_f\n===============\n*/\nvoid UI_CDKeyMenu_f( void ) {\n\tUI_CDKeyMenu();\n}\n"
  },
  {
    "path": "code/q3_ui/ui_cinematics.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#include \"ui_local.h\"\n\n\n#define ART_BACK0\t\t\"menu/art/back_0\"\n#define ART_BACK1\t\t\"menu/art/back_1\"\t\n#define ART_FRAMEL\t\t\"menu/art/frame2_l\"\n#define ART_FRAMER\t\t\"menu/art/frame1_r\"\n\n#define VERTICAL_SPACING\t30\n\n#define ID_BACK\t\t\t10\n#define ID_CIN_IDLOGO\t11\n#define ID_CIN_INTRO\t12\n#define ID_CIN_TIER1\t13\n#define ID_CIN_TIER2\t14\n#define ID_CIN_TIER3\t15\n#define ID_CIN_TIER4\t16\n#define ID_CIN_TIER5\t17\n#define ID_CIN_TIER6\t18\n#define ID_CIN_TIER7\t19\n#define ID_CIN_END\t\t20\n\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n\tmenutext_s\t\tbanner;\n\tmenubitmap_s\tframel;\n\tmenubitmap_s\tframer;\n\tmenutext_s\t\tcin_idlogo;\n\tmenutext_s\t\tcin_intro;\n\tmenutext_s\t\tcin_tier1;\n\tmenutext_s\t\tcin_tier2;\n\tmenutext_s\t\tcin_tier3;\n\tmenutext_s\t\tcin_tier4;\n\tmenutext_s\t\tcin_tier5;\n\tmenutext_s\t\tcin_tier6;\n\tmenutext_s\t\tcin_tier7;\n\tmenutext_s\t\tcin_end;\n\tmenubitmap_s\tback;\n} cinematicsMenuInfo_t;\n\nstatic cinematicsMenuInfo_t\tcinematicsMenuInfo;\n\nstatic char *cinematics[] = {\n\t\"idlogo\",\n\t\"intro\",\n\t\"tier1\",\n\t\"tier2\",\n\t\"tier3\",\n\t\"tier4\",\n\t\"tier5\",\n\t\"tier6\",\n\t\"tier7\",\n\t\"end\"\n};\n\n/*\n===============\nUI_CinematicsMenu_BackEvent\n===============\n*/\nstatic void UI_CinematicsMenu_BackEvent( void *ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\tUI_PopMenu();\n}\n\n\n/*\n===============\nUI_CinematicsMenu_Event\n===============\n*/\nstatic void UI_CinematicsMenu_Event( void *ptr, int event ) {\n\tint\t\tn;\n\n\tif (event != QM_ACTIVATED)\n\t\treturn;\n\n\tn = ((menucommon_s*)ptr)->id - ID_CIN_IDLOGO;\n\ttrap_Cvar_Set( \"nextmap\", va( \"ui_cinematics %i\", n ) );\n\tif( uis.demoversion && ((menucommon_s*)ptr)->id == ID_CIN_END ) {\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"disconnect; cinematic demoEnd.RoQ 1\\n\" );\n\t}\n\telse {\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va( \"disconnect; cinematic %s.RoQ\\n\", cinematics[n] ) );\n\t}\n}\n\n\n/*\n===============\nUI_CinematicsMenu_Init\n===============\n*/\nstatic void UI_CinematicsMenu_Init( void ) {\n\tint\t\ty;\n\n\tUI_CinematicsMenu_Cache();\n\n\tmemset( &cinematicsMenuInfo, 0, sizeof(cinematicsMenuInfo) );\n\tcinematicsMenuInfo.menu.fullscreen = qtrue;\n\n\tcinematicsMenuInfo.banner.generic.type\t\t= MTYPE_BTEXT;\n\tcinematicsMenuInfo.banner.generic.x\t\t\t= 320;\n\tcinematicsMenuInfo.banner.generic.y\t\t\t= 16;\n\tcinematicsMenuInfo.banner.string\t\t\t= \"CINEMATICS\";\n\tcinematicsMenuInfo.banner.color\t\t\t\t= color_white;\n\tcinematicsMenuInfo.banner.style\t\t\t\t= UI_CENTER;\n\n\tcinematicsMenuInfo.framel.generic.type\t\t= MTYPE_BITMAP;\n\tcinematicsMenuInfo.framel.generic.name\t\t= ART_FRAMEL;\n\tcinematicsMenuInfo.framel.generic.flags\t\t= QMF_INACTIVE;\n\tcinematicsMenuInfo.framel.generic.x\t\t\t= 0;  \n\tcinematicsMenuInfo.framel.generic.y\t\t\t= 78;\n\tcinematicsMenuInfo.framel.width  \t\t\t= 256;\n\tcinematicsMenuInfo.framel.height  \t\t\t= 329;\n\n\tcinematicsMenuInfo.framer.generic.type\t\t= MTYPE_BITMAP;\n\tcinematicsMenuInfo.framer.generic.name\t\t= ART_FRAMER;\n\tcinematicsMenuInfo.framer.generic.flags\t\t= QMF_INACTIVE;\n\tcinematicsMenuInfo.framer.generic.x\t\t\t= 376;\n\tcinematicsMenuInfo.framer.generic.y\t\t\t= 76;\n\tcinematicsMenuInfo.framer.width  \t\t\t= 256;\n\tcinematicsMenuInfo.framer.height  \t\t\t= 334;\n\n\ty = 100;\n\tcinematicsMenuInfo.cin_idlogo.generic.type\t\t= MTYPE_PTEXT;\n\tcinematicsMenuInfo.cin_idlogo.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\tcinematicsMenuInfo.cin_idlogo.generic.x\t\t\t= 320;\n\tcinematicsMenuInfo.cin_idlogo.generic.y\t\t\t= y;\n\tcinematicsMenuInfo.cin_idlogo.generic.id\t\t= ID_CIN_IDLOGO;\n\tcinematicsMenuInfo.cin_idlogo.generic.callback\t= UI_CinematicsMenu_Event; \n\tcinematicsMenuInfo.cin_idlogo.string\t\t\t= \"ID LOGO\";\n\tcinematicsMenuInfo.cin_idlogo.color\t\t\t\t= color_red;\n\tcinematicsMenuInfo.cin_idlogo.style\t\t\t\t= UI_CENTER;\n\n\ty += VERTICAL_SPACING;\n\tcinematicsMenuInfo.cin_intro.generic.type\t\t= MTYPE_PTEXT;\n\tcinematicsMenuInfo.cin_intro.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\tcinematicsMenuInfo.cin_intro.generic.x\t\t\t= 320;\n\tcinematicsMenuInfo.cin_intro.generic.y\t\t\t= y;\n\tcinematicsMenuInfo.cin_intro.generic.id\t\t\t= ID_CIN_INTRO;\n\tcinematicsMenuInfo.cin_intro.generic.callback\t= UI_CinematicsMenu_Event; \n\tcinematicsMenuInfo.cin_intro.string\t\t\t\t= \"INTRO\";\n\tcinematicsMenuInfo.cin_intro.color\t\t\t\t= color_red;\n\tcinematicsMenuInfo.cin_intro.style\t\t\t\t= UI_CENTER;\n\tif( uis.demoversion ) {\n\t\tcinematicsMenuInfo.cin_intro.generic.flags |= QMF_GRAYED;\n\t}\n\n\ty += VERTICAL_SPACING;\n\tcinematicsMenuInfo.cin_tier1.generic.type\t\t= MTYPE_PTEXT;\n\tcinematicsMenuInfo.cin_tier1.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\tcinematicsMenuInfo.cin_tier1.generic.x\t\t\t= 320;\n\tcinematicsMenuInfo.cin_tier1.generic.y\t\t\t= y;\n\tcinematicsMenuInfo.cin_tier1.generic.id\t\t\t= ID_CIN_TIER1;\n\tcinematicsMenuInfo.cin_tier1.generic.callback\t= UI_CinematicsMenu_Event; \n\tcinematicsMenuInfo.cin_tier1.string\t\t\t\t= \"Tier 1\";\n\tcinematicsMenuInfo.cin_tier1.color\t\t\t\t= color_red;\n\tcinematicsMenuInfo.cin_tier1.style\t\t\t\t= UI_CENTER;\n\tif( !UI_CanShowTierVideo( 1 ) ) {\n\t\tcinematicsMenuInfo.cin_tier1.generic.flags |= QMF_GRAYED;\n\t}\n\n\ty += VERTICAL_SPACING;\n\tcinematicsMenuInfo.cin_tier2.generic.type\t\t= MTYPE_PTEXT;\n\tcinematicsMenuInfo.cin_tier2.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\tcinematicsMenuInfo.cin_tier2.generic.x\t\t\t= 320;\n\tcinematicsMenuInfo.cin_tier2.generic.y\t\t\t= y;\n\tcinematicsMenuInfo.cin_tier2.generic.id\t\t\t= ID_CIN_TIER2;\n\tcinematicsMenuInfo.cin_tier2.generic.callback\t= UI_CinematicsMenu_Event; \n\tcinematicsMenuInfo.cin_tier2.string\t\t\t\t= \"Tier 2\";\n\tcinematicsMenuInfo.cin_tier2.color\t\t\t\t= color_red;\n\tcinematicsMenuInfo.cin_tier2.style\t\t\t\t= UI_CENTER;\n\tif( !UI_CanShowTierVideo( 2 ) ) {\n\t\tcinematicsMenuInfo.cin_tier2.generic.flags |= QMF_GRAYED;\n\t}\n\n\ty += VERTICAL_SPACING;\n\tcinematicsMenuInfo.cin_tier3.generic.type\t\t= MTYPE_PTEXT;\n\tcinematicsMenuInfo.cin_tier3.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\tcinematicsMenuInfo.cin_tier3.generic.x\t\t\t= 320;\n\tcinematicsMenuInfo.cin_tier3.generic.y\t\t\t= y;\n\tcinematicsMenuInfo.cin_tier3.generic.id\t\t\t= ID_CIN_TIER3;\n\tcinematicsMenuInfo.cin_tier3.generic.callback\t= UI_CinematicsMenu_Event; \n\tcinematicsMenuInfo.cin_tier3.string\t\t\t\t= \"Tier 3\";\n\tcinematicsMenuInfo.cin_tier3.color\t\t\t\t= color_red;\n\tcinematicsMenuInfo.cin_tier3.style\t\t\t\t= UI_CENTER;\n\tif( !UI_CanShowTierVideo( 3 ) ) {\n\t\tcinematicsMenuInfo.cin_tier3.generic.flags |= QMF_GRAYED;\n\t}\n\n\ty += VERTICAL_SPACING;\n\tcinematicsMenuInfo.cin_tier4.generic.type\t\t= MTYPE_PTEXT;\n\tcinematicsMenuInfo.cin_tier4.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\tcinematicsMenuInfo.cin_tier4.generic.x\t\t\t= 320;\n\tcinematicsMenuInfo.cin_tier4.generic.y\t\t\t= y;\n\tcinematicsMenuInfo.cin_tier4.generic.id\t\t\t= ID_CIN_TIER4;\n\tcinematicsMenuInfo.cin_tier4.generic.callback\t= UI_CinematicsMenu_Event; \n\tcinematicsMenuInfo.cin_tier4.string\t\t\t\t= \"Tier 4\";\n\tcinematicsMenuInfo.cin_tier4.color\t\t\t\t= color_red;\n\tcinematicsMenuInfo.cin_tier4.style\t\t\t\t= UI_CENTER;\n\tif( !UI_CanShowTierVideo( 4 ) ) {\n\t\tcinematicsMenuInfo.cin_tier4.generic.flags |= QMF_GRAYED;\n\t}\n\n\ty += VERTICAL_SPACING;\n\tcinematicsMenuInfo.cin_tier5.generic.type\t\t= MTYPE_PTEXT;\n\tcinematicsMenuInfo.cin_tier5.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\tcinematicsMenuInfo.cin_tier5.generic.x\t\t\t= 320;\n\tcinematicsMenuInfo.cin_tier5.generic.y\t\t\t= y;\n\tcinematicsMenuInfo.cin_tier5.generic.id\t\t\t= ID_CIN_TIER5;\n\tcinematicsMenuInfo.cin_tier5.generic.callback\t= UI_CinematicsMenu_Event; \n\tcinematicsMenuInfo.cin_tier5.string\t\t\t\t= \"Tier 5\";\n\tcinematicsMenuInfo.cin_tier5.color\t\t\t\t= color_red;\n\tcinematicsMenuInfo.cin_tier5.style\t\t\t\t= UI_CENTER;\n\tif( !UI_CanShowTierVideo( 5 ) ) {\n\t\tcinematicsMenuInfo.cin_tier5.generic.flags |= QMF_GRAYED;\n\t}\n\n\ty += VERTICAL_SPACING;\n\tcinematicsMenuInfo.cin_tier6.generic.type\t\t= MTYPE_PTEXT;\n\tcinematicsMenuInfo.cin_tier6.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\tcinematicsMenuInfo.cin_tier6.generic.x\t\t\t= 320;\n\tcinematicsMenuInfo.cin_tier6.generic.y\t\t\t= y;\n\tcinematicsMenuInfo.cin_tier6.generic.id\t\t\t= ID_CIN_TIER6;\n\tcinematicsMenuInfo.cin_tier6.generic.callback\t= UI_CinematicsMenu_Event; \n\tcinematicsMenuInfo.cin_tier6.string\t\t\t\t= \"Tier 6\";\n\tcinematicsMenuInfo.cin_tier6.color\t\t\t\t= color_red;\n\tcinematicsMenuInfo.cin_tier6.style\t\t\t\t= UI_CENTER;\n\tif( !UI_CanShowTierVideo( 6 ) ) {\n\t\tcinematicsMenuInfo.cin_tier6.generic.flags |= QMF_GRAYED;\n\t}\n\n\ty += VERTICAL_SPACING;\n\tcinematicsMenuInfo.cin_tier7.generic.type\t\t= MTYPE_PTEXT;\n\tcinematicsMenuInfo.cin_tier7.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\tcinematicsMenuInfo.cin_tier7.generic.x\t\t\t= 320;\n\tcinematicsMenuInfo.cin_tier7.generic.y\t\t\t= y;\n\tcinematicsMenuInfo.cin_tier7.generic.id\t\t\t= ID_CIN_TIER7;\n\tcinematicsMenuInfo.cin_tier7.generic.callback\t= UI_CinematicsMenu_Event; \n\tcinematicsMenuInfo.cin_tier7.string\t\t\t\t= \"Tier 7\";\n\tcinematicsMenuInfo.cin_tier7.color\t\t\t\t= color_red;\n\tcinematicsMenuInfo.cin_tier7.style\t\t\t\t= UI_CENTER;\n\tif( !UI_CanShowTierVideo( 7 ) ) {\n\t\tcinematicsMenuInfo.cin_tier7.generic.flags |= QMF_GRAYED;\n\t}\n\n\ty += VERTICAL_SPACING;\n\tcinematicsMenuInfo.cin_end.generic.type\t\t\t= MTYPE_PTEXT;\n\tcinematicsMenuInfo.cin_end.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\tcinematicsMenuInfo.cin_end.generic.x\t\t\t= 320;\n\tcinematicsMenuInfo.cin_end.generic.y\t\t\t= y;\n\tcinematicsMenuInfo.cin_end.generic.id\t\t\t= ID_CIN_END;\n\tcinematicsMenuInfo.cin_end.generic.callback\t\t= UI_CinematicsMenu_Event; \n\tcinematicsMenuInfo.cin_end.string\t\t\t\t= \"END\";\n\tcinematicsMenuInfo.cin_end.color\t\t\t\t= color_red;\n\tcinematicsMenuInfo.cin_end.style\t\t\t\t= UI_CENTER;\n\tif( !UI_CanShowTierVideo( 8 ) ) {\n\t\tcinematicsMenuInfo.cin_end.generic.flags |= QMF_GRAYED;\n\t}\n\n\tcinematicsMenuInfo.back.generic.type\t\t= MTYPE_BITMAP;\n\tcinematicsMenuInfo.back.generic.name\t\t= ART_BACK0;\n\tcinematicsMenuInfo.back.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tcinematicsMenuInfo.back.generic.id\t\t\t= ID_BACK;\n\tcinematicsMenuInfo.back.generic.callback\t= UI_CinematicsMenu_BackEvent;\n\tcinematicsMenuInfo.back.generic.x\t\t\t= 0;\n\tcinematicsMenuInfo.back.generic.y\t\t\t= 480-64;\n\tcinematicsMenuInfo.back.width\t\t\t\t= 128;\n\tcinematicsMenuInfo.back.height\t\t\t\t= 64;\n\tcinematicsMenuInfo.back.focuspic\t\t\t= ART_BACK1;\n\n\tMenu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.banner );\n\tMenu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.framel );\n\tMenu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.framer );\n\tMenu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_idlogo );\n\tMenu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_intro );\n\tMenu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier1 );\n\tMenu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier2 );\n\tMenu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier3 );\n\tMenu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier4 );\n\tMenu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier5 );\n\tMenu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier6 );\n\tMenu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_tier7 );\n\tMenu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.cin_end );\n\tMenu_AddItem( &cinematicsMenuInfo.menu, &cinematicsMenuInfo.back );\n}\n\n\n/*\n=================\nUI_CinematicsMenu_Cache\n=================\n*/\nvoid UI_CinematicsMenu_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( ART_BACK0 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK1 );\n\ttrap_R_RegisterShaderNoMip( ART_FRAMEL );\n\ttrap_R_RegisterShaderNoMip( ART_FRAMER );\n}\n\n\n/*\n===============\nUI_CinematicsMenu\n===============\n*/\nvoid UI_CinematicsMenu( void ) {\n\tUI_CinematicsMenu_Init();\n\tUI_PushMenu( &cinematicsMenuInfo.menu );\n}\n\n\n/*\n===============\nUI_CinematicsMenu_f\n===============\n*/\nvoid UI_CinematicsMenu_f( void ) {\n\tint\t\tn;\n\n\tn = atoi( UI_Argv( 1 ) );\n\tUI_CinematicsMenu();\n\tMenu_SetCursorToItem( &cinematicsMenuInfo.menu, cinematicsMenuInfo.menu.items[n + 3] );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_confirm.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=======================================================================\n\nCONFIRMATION MENU\n\n=======================================================================\n*/\n\n\n#include \"ui_local.h\"\n\n\n#define ART_CONFIRM_FRAME\t\"menu/art/cut_frame\"\n\n#define ID_CONFIRM_NO\t\t10\n#define ID_CONFIRM_YES\t\t11\n\n\ntypedef struct {\n\tmenuframework_s menu;\n\n\tmenutext_s\t\tno;\n\tmenutext_s\t\tyes;\n\n\tint\t\t\t\tslashX;\n\tconst char *\tquestion;\n\tvoid\t\t\t(*draw)( void );\n\tvoid\t\t\t(*action)( qboolean result );\n\t\n\tint style;\n\tconst char **lines;\n} confirmMenu_t;\n\n\nstatic confirmMenu_t\ts_confirm;\n\n\n/*\n=================\nConfirmMenu_Event\n=================\n*/\nstatic void ConfirmMenu_Event( void* ptr, int event ) {\n\tqboolean\tresult;\n\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tUI_PopMenu();\n\n\tif( ((menucommon_s*)ptr)->id == ID_CONFIRM_NO ) {\n\t\tresult = qfalse;\n\t}\n\telse {\n\t\tresult = qtrue;\n\t}\n\n\tif( s_confirm.action ) {\n\t\ts_confirm.action( result );\n\t}\n}\n\n\n/*\n=================\nConfirmMenu_Key\n=================\n*/\nstatic sfxHandle_t ConfirmMenu_Key( int key ) {\n\tswitch ( key ) {\n\tcase K_KP_LEFTARROW:\n\tcase K_LEFTARROW:\n\tcase K_KP_RIGHTARROW:\n\tcase K_RIGHTARROW:\n\t\tkey = K_TAB;\n\t\tbreak;\n\n\tcase 'n':\n\tcase 'N':\n\t\tConfirmMenu_Event( &s_confirm.no, QM_ACTIVATED );\n\t\tbreak;\n\n\tcase 'y':\n\tcase 'Y':\n\t\tConfirmMenu_Event( &s_confirm.yes, QM_ACTIVATED );\n\t\tbreak;\n\t}\n\n\treturn Menu_DefaultKey( &s_confirm.menu, key );\n}\n\n\n/*\n=================\nMessaheMenu_Draw\n=================\n*/\nstatic void MessageMenu_Draw( void ) {\n\tint i,y;\n\t\n\tUI_DrawNamedPic( 142, 118, 359, 256, ART_CONFIRM_FRAME );\n\t\n\ty = 188;\n\tfor(i=0; s_confirm.lines[i]; i++)\n\t{\n\t\tUI_DrawProportionalString( 320, y, s_confirm.lines[i], s_confirm.style, color_red );\n\t\ty += 18;\n\t}\n\n\tMenu_Draw( &s_confirm.menu );\n\n\tif( s_confirm.draw ) {\n\t\ts_confirm.draw();\n\t}\n}\n\n/*\n=================\nConfirmMenu_Draw\n=================\n*/\nstatic void ConfirmMenu_Draw( void ) {\n\tUI_DrawNamedPic( 142, 118, 359, 256, ART_CONFIRM_FRAME );\n\tUI_DrawProportionalString( 320, 204, s_confirm.question, s_confirm.style, color_red );\n\tUI_DrawProportionalString( s_confirm.slashX, 265, \"/\", UI_LEFT|UI_INVERSE, color_red );\n\n\tMenu_Draw( &s_confirm.menu );\n\n\tif( s_confirm.draw ) {\n\t\ts_confirm.draw();\n\t}\n}\n\n\n/*\n=================\nConfirmMenu_Cache\n=================\n*/\nvoid ConfirmMenu_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( ART_CONFIRM_FRAME );\n}\n\n\n/*\n=================\nUI_ConfirmMenu_Stlye\n=================\n*/\nvoid UI_ConfirmMenu_Style( const char *question, int style, void (*draw)( void ), void (*action)( qboolean result ) ) {\n\tuiClientState_t\tcstate;\n\tint\tn1, n2, n3;\n\tint\tl1, l2, l3;\n\n\t// zero set all our globals\n\tmemset( &s_confirm, 0, sizeof(s_confirm) );\n\n\tConfirmMenu_Cache();\n\n\tn1 = UI_ProportionalStringWidth( \"YES/NO\" );\n\tn2 = UI_ProportionalStringWidth( \"YES\" ) + PROP_GAP_WIDTH;\n\tn3 = UI_ProportionalStringWidth( \"/\" )  + PROP_GAP_WIDTH;\n\tl1 = 320 - ( n1 / 2 );\n\tl2 = l1 + n2;\n\tl3 = l2 + n3;\n\ts_confirm.slashX = l2;\n\n\ts_confirm.question = question;\n\ts_confirm.draw = draw;\n\ts_confirm.action = action;\n\ts_confirm.style = style;\n\n\ts_confirm.menu.draw       = ConfirmMenu_Draw;\n\ts_confirm.menu.key        = ConfirmMenu_Key;\n\ts_confirm.menu.wrapAround = qtrue;\n\n\ttrap_GetClientState( &cstate );\n\tif ( cstate.connState >= CA_CONNECTED ) {\n\t\ts_confirm.menu.fullscreen = qfalse;\n\t}\n\telse {\n\t\ts_confirm.menu.fullscreen = qtrue;\n\t}\n\n\ts_confirm.yes.generic.type\t\t= MTYPE_PTEXT;      \n\ts_confirm.yes.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; \n\ts_confirm.yes.generic.callback\t= ConfirmMenu_Event;\n\ts_confirm.yes.generic.id\t\t= ID_CONFIRM_YES;\n\ts_confirm.yes.generic.x\t\t\t= l1;\n\ts_confirm.yes.generic.y\t\t\t= 264;\n\ts_confirm.yes.string\t\t\t= \"YES\";\n\ts_confirm.yes.color\t\t\t\t= color_red;\n\ts_confirm.yes.style\t\t\t\t= UI_LEFT;\n\n\ts_confirm.no.generic.type\t\t= MTYPE_PTEXT;      \n\ts_confirm.no.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; \n\ts_confirm.no.generic.callback\t= ConfirmMenu_Event;\n\ts_confirm.no.generic.id\t\t\t= ID_CONFIRM_NO;\n\ts_confirm.no.generic.x\t\t    = l3;\n\ts_confirm.no.generic.y\t\t    = 264;\n\ts_confirm.no.string\t\t\t\t= \"NO\";\n\ts_confirm.no.color\t\t\t    = color_red;\n\ts_confirm.no.style\t\t\t    = UI_LEFT;\n\n\tMenu_AddItem( &s_confirm.menu,\t&s_confirm.yes );             \n\tMenu_AddItem( &s_confirm.menu,\t&s_confirm.no );\n\n\tUI_PushMenu( &s_confirm.menu );\n\n\tMenu_SetCursorToItem( &s_confirm.menu, &s_confirm.no );\n}\n\n/*\n=================\nUI_ConfirmMenu\n=================\n*/\nvoid UI_ConfirmMenu( const char *question, void (*draw)( void ), void (*action)( qboolean result ) ) {\n\tUI_ConfirmMenu_Style(question, UI_CENTER|UI_INVERSE, draw, action);\n}\n\n/*\n=================\nUI_Message\nhacked over from Confirm stuff\n=================\n*/\nvoid UI_Message( const char **lines ) {\n\tuiClientState_t\tcstate;\n\tint n1, l1;\n\t\n\t// zero set all our globals\n\tmemset( &s_confirm, 0, sizeof(s_confirm) );\n\n\tConfirmMenu_Cache();\n\n\tn1 = UI_ProportionalStringWidth( \"OK\" );\n\tl1 = 320 - ( n1 / 2 );\n\t\n\ts_confirm.lines = lines;\n\ts_confirm.style = UI_CENTER|UI_INVERSE|UI_SMALLFONT;\n\n\ts_confirm.menu.draw       = MessageMenu_Draw;\n\ts_confirm.menu.key        = ConfirmMenu_Key;\n\ts_confirm.menu.wrapAround = qtrue;\n\t\n\ttrap_GetClientState( &cstate );\n\tif ( cstate.connState >= CA_CONNECTED ) {\n\t\ts_confirm.menu.fullscreen = qfalse;\n\t}\n\telse {\n\t\ts_confirm.menu.fullscreen = qtrue;\n\t}\n\n\ts_confirm.yes.generic.type\t\t= MTYPE_PTEXT;      \n\ts_confirm.yes.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; \n\ts_confirm.yes.generic.callback\t= ConfirmMenu_Event;\n\ts_confirm.yes.generic.id\t\t= ID_CONFIRM_YES;\n\ts_confirm.yes.generic.x\t\t\t= l1;\n\ts_confirm.yes.generic.y\t\t\t= 280;\n\ts_confirm.yes.string\t\t\t= \"OK\";\n\ts_confirm.yes.color\t\t\t\t= color_red;\n\ts_confirm.yes.style\t\t\t\t= UI_LEFT;\n\n\tMenu_AddItem( &s_confirm.menu,\t&s_confirm.yes );\n\t\n\tUI_PushMenu( &s_confirm.menu );\n\n\tMenu_SetCursorToItem( &s_confirm.menu, &s_confirm.yes );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_connect.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#include \"ui_local.h\"\n\n/*\n===============================================================================\n\nCONNECTION SCREEN\n\n===============================================================================\n*/\n\nqboolean\tpasswordNeeded = qtrue;\nmenufield_s passwordField;\n\nstatic connstate_t\tlastConnState;\nstatic char\t\t\tlastLoadingText[MAX_INFO_VALUE];\n\nstatic void UI_ReadableSize ( char *buf, int bufsize, int value )\n{\n\tif (value > 1024*1024*1024 ) { // gigs\n\t\tCom_sprintf( buf, bufsize, \"%d\", value / (1024*1024*1024) );\n\t\tCom_sprintf( buf+strlen(buf), bufsize-strlen(buf), \".%02d GB\", \n\t\t\t(value % (1024*1024*1024))*100 / (1024*1024*1024) );\n\t} else if (value > 1024*1024 ) { // megs\n\t\tCom_sprintf( buf, bufsize, \"%d\", value / (1024*1024) );\n\t\tCom_sprintf( buf+strlen(buf), bufsize-strlen(buf), \".%02d MB\", \n\t\t\t(value % (1024*1024))*100 / (1024*1024) );\n\t} else if (value > 1024 ) { // kilos\n\t\tCom_sprintf( buf, bufsize, \"%d KB\", value / 1024 );\n\t} else { // bytes\n\t\tCom_sprintf( buf, bufsize, \"%d bytes\", value );\n\t}\n}\n\n// Assumes time is in msec\nstatic void UI_PrintTime ( char *buf, int bufsize, int time ) {\n\ttime /= 1000;  // change to seconds\n\n\tif (time > 3600) { // in the hours range\n\t\tCom_sprintf( buf, bufsize, \"%d hr %d min\", time / 3600, (time % 3600) / 60 );\n\t} else if (time > 60) { // mins\n\t\tCom_sprintf( buf, bufsize, \"%d min %d sec\", time / 60, time % 60 );\n\t} else  { // secs\n\t\tCom_sprintf( buf, bufsize, \"%d sec\", time );\n\t}\n}\n\nstatic void UI_DisplayDownloadInfo( const char *downloadName ) {\n\tstatic char dlText[]\t= \"Downloading:\";\n\tstatic char etaText[]\t= \"Estimated time left:\";\n\tstatic char xferText[]\t= \"Transfer rate:\";\n\n\tint downloadSize, downloadCount, downloadTime;\n\tchar dlSizeBuf[64], totalSizeBuf[64], xferRateBuf[64], dlTimeBuf[64];\n\tint xferRate;\n\tint width, leftWidth;\n\tint style = UI_LEFT|UI_SMALLFONT|UI_DROPSHADOW;\n\tconst char *s;\n\n\tdownloadSize = trap_Cvar_VariableValue( \"cl_downloadSize\" );\n\tdownloadCount = trap_Cvar_VariableValue( \"cl_downloadCount\" );\n\tdownloadTime = trap_Cvar_VariableValue( \"cl_downloadTime\" );\n\n#if 0 // bk010104\n\tfprintf( stderr, \"\\n\\n-----------------------------------------------\\n\");\n\tfprintf( stderr, \"DB: downloadSize:  %16d\\n\", downloadSize );\n\tfprintf( stderr, \"DB: downloadCount: %16d\\n\", downloadCount );\n\tfprintf( stderr, \"DB: downloadTime:  %16d\\n\", downloadTime );  \n  \tfprintf( stderr, \"DB: UI realtime:   %16d\\n\", uis.realtime );\t// bk\n\tfprintf( stderr, \"DB: UI frametime:  %16d\\n\", uis.frametime );\t// bk\n#endif\n\n\tleftWidth = width = UI_ProportionalStringWidth( dlText ) * UI_ProportionalSizeScale( style );\n\twidth = UI_ProportionalStringWidth( etaText ) * UI_ProportionalSizeScale( style );\n\tif (width > leftWidth) leftWidth = width;\n\twidth = UI_ProportionalStringWidth( xferText ) * UI_ProportionalSizeScale( style );\n\tif (width > leftWidth) leftWidth = width;\n\tleftWidth += 16;\n\n\tUI_DrawProportionalString( 8, 128, dlText, style, color_white );\n\tUI_DrawProportionalString( 8, 160, etaText, style, color_white );\n\tUI_DrawProportionalString( 8, 224, xferText, style, color_white );\n\n\tif (downloadSize > 0) {\n\t\ts = va( \"%s (%d%%)\", downloadName, downloadCount * 100 / downloadSize );\n\t} else {\n\t\ts = downloadName;\n\t}\n\n\tUI_DrawProportionalString( leftWidth, 128, s, style, color_white );\n\n\tUI_ReadableSize( dlSizeBuf,\t\tsizeof dlSizeBuf,\t\tdownloadCount );\n\tUI_ReadableSize( totalSizeBuf,\tsizeof totalSizeBuf,\tdownloadSize );\n\n\tif (downloadCount < 4096 || !downloadTime) {\n\t\tUI_DrawProportionalString( leftWidth, 160, \"estimating\", style, color_white );\n\t\tUI_DrawProportionalString( leftWidth, 192, \n\t\t\tva(\"(%s of %s copied)\", dlSizeBuf, totalSizeBuf), style, color_white );\n\t} else {\n\t  // bk010108\n\t  //float elapsedTime = (float)(uis.realtime - downloadTime); // current - start (msecs)\n\t  //elapsedTime = elapsedTime * 0.001f; // in seconds\n\t  //if ( elapsedTime <= 0.0f ) elapsedTime == 0.0f;\n\t  if ( (uis.realtime - downloadTime) / 1000) {\n\t\t\txferRate = downloadCount / ((uis.realtime - downloadTime) / 1000);\n\t\t  //xferRate = (int)( ((float)downloadCount) / elapsedTime);\n\t\t} else {\n\t\t\txferRate = 0;\n\t\t}\n\n\t  //fprintf( stderr, \"DB: elapsedTime:  %16.8f\\n\", elapsedTime );\t// bk\n\t  //fprintf( stderr, \"DB: xferRate:   %16d\\n\", xferRate );\t// bk\n\n\t\tUI_ReadableSize( xferRateBuf, sizeof xferRateBuf, xferRate );\n\n\t\t// Extrapolate estimated completion time\n\t\tif (downloadSize && xferRate) {\n\t\t\tint n = downloadSize / xferRate; // estimated time for entire d/l in secs\n\n\t\t\t// We do it in K (/1024) because we'd overflow around 4MB\n\t\t\tn = (n - (((downloadCount/1024) * n) / (downloadSize/1024))) * 1000;\n\t\t\t\n\t\t\tUI_PrintTime ( dlTimeBuf, sizeof dlTimeBuf, n ); // bk010104\n\t\t\t\t//(n - (((downloadCount/1024) * n) / (downloadSize/1024))) * 1000);\n\n\t\t\tUI_DrawProportionalString( leftWidth, 160, \n\t\t\t\tdlTimeBuf, style, color_white );\n\t\t\tUI_DrawProportionalString( leftWidth, 192, \n\t\t\t\tva(\"(%s of %s copied)\", dlSizeBuf, totalSizeBuf), style, color_white );\n\t\t} else {\n\t\t\tUI_DrawProportionalString( leftWidth, 160, \n\t\t\t\t\"estimating\", style, color_white );\n\t\t\tif (downloadSize) {\n\t\t\t\tUI_DrawProportionalString( leftWidth, 192, \n\t\t\t\t\tva(\"(%s of %s copied)\", dlSizeBuf, totalSizeBuf), style, color_white );\n\t\t\t} else {\n\t\t\t\tUI_DrawProportionalString( leftWidth, 192, \n\t\t\t\t\tva(\"(%s copied)\", dlSizeBuf), style, color_white );\n\t\t\t}\n\t\t}\n\n\t\tif (xferRate) {\n\t\t\tUI_DrawProportionalString( leftWidth, 224, \n\t\t\t\tva(\"%s/Sec\", xferRateBuf), style, color_white );\n\t\t}\n\t}\n}\n\n/*\n========================\nUI_DrawConnectScreen\n\nThis will also be overlaid on the cgame info screen during loading\nto prevent it from blinking away too rapidly on local or lan games.\n========================\n*/\nvoid UI_DrawConnectScreen( qboolean overlay ) {\n\tchar\t\t\t*s;\n\tuiClientState_t\tcstate;\n\tchar\t\t\tinfo[MAX_INFO_VALUE];\n\n\tMenu_Cache();\n\n\tif ( !overlay ) {\n\t\t// draw the dialog background\n\t\tUI_SetColor( color_white );\n\t\tUI_DrawHandlePic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, uis.menuBackShader );\n\t}\n\n\t// see what information we should display\n\ttrap_GetClientState( &cstate );\n\n\tinfo[0] = '\\0';\n\tif( trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) ) ) {\n\t\tUI_DrawProportionalString( 320, 16, va( \"Loading %s\", Info_ValueForKey( info, \"mapname\" ) ), UI_BIGFONT|UI_CENTER|UI_DROPSHADOW, color_white );\n\t}\n\n\tUI_DrawProportionalString( 320, 64, va(\"Connecting to %s\", cstate.servername), UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );\n\t//UI_DrawProportionalString( 320, 96, \"Press Esc to abort\", UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );\n\n\t// display global MOTD at bottom\n\tUI_DrawProportionalString( SCREEN_WIDTH/2, SCREEN_HEIGHT-32, \n\t\tInfo_ValueForKey( cstate.updateInfoString, \"motd\" ), UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );\n\t\n\t// print any server info (server full, bad version, etc)\n\tif ( cstate.connState < CA_CONNECTED ) {\n\t\tUI_DrawProportionalString_AutoWrapped( 320, 192, 630, 20, cstate.messageString, UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );\n\t}\n\n#if 0\n\t// display password field\n\tif ( passwordNeeded ) {\n\t\ts_ingame_menu.x = SCREEN_WIDTH * 0.50 - 128;\n\t\ts_ingame_menu.nitems = 0;\n\t\ts_ingame_menu.wrapAround = qtrue;\n\n\t\tpasswordField.generic.type = MTYPE_FIELD;\n\t\tpasswordField.generic.name = \"Password:\";\n\t\tpasswordField.generic.callback = 0;\n\t\tpasswordField.generic.x\t\t= 10;\n\t\tpasswordField.generic.y\t\t= 180;\n\t\tField_Clear( &passwordField.field );\n\t\tpasswordField.width = 256;\n\t\tpasswordField.field.widthInChars = 16;\n\t\tQ_strncpyz( passwordField.field.buffer, Cvar_VariableString(\"password\"), \n\t\t\tsizeof(passwordField.field.buffer) );\n\n\t\tMenu_AddItem( &s_ingame_menu, ( void * ) &s_customize_player_action );\n\n\t\tMField_Draw( &passwordField );\n\t}\n#endif\n\n\tif ( lastConnState > cstate.connState ) {\n\t\tlastLoadingText[0] = '\\0';\n\t}\n\tlastConnState = cstate.connState;\n\n\tswitch ( cstate.connState ) {\n\tcase CA_CONNECTING:\n\t\ts = va(\"Awaiting challenge...%i\", cstate.connectPacketCount);\n\t\tbreak;\n\tcase CA_CHALLENGING:\n\t\ts = va(\"Awaiting connection...%i\", cstate.connectPacketCount);\n\t\tbreak;\n\tcase CA_CONNECTED: {\n\t\tchar downloadName[MAX_INFO_VALUE];\n\n\t\t\ttrap_Cvar_VariableStringBuffer( \"cl_downloadName\", downloadName, sizeof(downloadName) );\n\t\t\tif (*downloadName) {\n\t\t\t\tUI_DisplayDownloadInfo( downloadName );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\ts = \"Awaiting gamestate...\";\n\t\tbreak;\n\tcase CA_LOADING:\n\t\treturn;\n\tcase CA_PRIMED:\n\t\treturn;\n\tdefault:\n\t\treturn;\n\t}\n\n\tUI_DrawProportionalString( 320, 128, s, UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, color_white );\n\n\t// password required / connection rejected information goes here\n}\n\n\n/*\n===================\nUI_KeyConnect\n===================\n*/\nvoid UI_KeyConnect( int key ) {\n\tif ( key == K_ESCAPE ) {\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"disconnect\\n\" );\n\t\treturn;\n\t}\n}\n"
  },
  {
    "path": "code/q3_ui/ui_controls2.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=======================================================================\n\nCONTROLS MENU\n\n=======================================================================\n*/\n\n\n#include \"ui_local.h\"\n\n#define ART_BACK0\t\t\t\"menu/art/back_0\"\n#define ART_BACK1\t\t\t\"menu/art/back_1\"\n#define ART_FRAMEL\t\t\t\"menu/art/frame2_l\"\n#define ART_FRAMER\t\t\t\"menu/art/frame1_r\"\n\n\ntypedef struct {\n\tchar\t*command;\n\tchar\t*label;\n\tint\t\tid;\n\tint\t\tanim;\n\tint\t\tdefaultbind1;\n\tint\t\tdefaultbind2;\n\tint\t\tbind1;\n\tint\t\tbind2;\n} bind_t;\n\ntypedef struct\n{\n\tchar*\tname;\n\tfloat\tdefaultvalue;\n\tfloat\tvalue;\t\n} configcvar_t;\n\n#define SAVE_NOOP\t\t0\n#define SAVE_YES\t\t1\n#define SAVE_NO\t\t\t2\n#define SAVE_CANCEL\t\t3\n\n// control sections\n#define C_MOVEMENT\t\t0\n#define C_LOOKING\t\t1\n#define C_WEAPONS\t\t2\n#define C_MISC\t\t\t3\n#define C_MAX\t\t\t4\n\n#define ID_MOVEMENT\t\t100\n#define ID_LOOKING\t\t101\n#define ID_WEAPONS\t\t102\n#define ID_MISC\t\t\t103\n#define ID_DEFAULTS\t\t104\n#define ID_BACK\t\t\t105\n#define ID_SAVEANDEXIT\t106\n#define ID_EXIT\t\t\t107\n\n// bindable actions\n#define ID_SHOWSCORES\t0\n#define ID_USEITEM\t\t1\t\n#define ID_SPEED\t\t2\t\n#define ID_FORWARD\t\t3\t\n#define ID_BACKPEDAL\t4\n#define ID_MOVELEFT\t\t5\n#define ID_MOVERIGHT\t6\n#define ID_MOVEUP\t\t7\t\n#define ID_MOVEDOWN\t\t8\n#define ID_LEFT\t\t\t9\t\n#define ID_RIGHT\t\t10\t\n#define ID_STRAFE\t\t11\t\n#define ID_LOOKUP\t\t12\t\n#define ID_LOOKDOWN\t\t13\n#define ID_MOUSELOOK\t14\n#define ID_CENTERVIEW\t15\n#define ID_ZOOMVIEW\t\t16\n#define ID_WEAPON1\t\t17\t\n#define ID_WEAPON2\t\t18\t\n#define ID_WEAPON3\t\t19\t\n#define ID_WEAPON4\t\t20\t\n#define ID_WEAPON5\t\t21\t\n#define ID_WEAPON6\t\t22\t\n#define ID_WEAPON7\t\t23\t\n#define ID_WEAPON8\t\t24\t\n#define ID_WEAPON9\t\t25\t\n#define ID_ATTACK\t\t26\n#define ID_WEAPPREV\t\t27\n#define ID_WEAPNEXT\t\t28\n#define ID_GESTURE\t\t29\n#define ID_CHAT\t\t\t30\n#define ID_CHAT2\t\t31\n#define ID_CHAT3\t\t32\n#define ID_CHAT4\t\t33\n\n// all others\n#define ID_FREELOOK\t\t34\n#define ID_INVERTMOUSE\t35\n#define ID_ALWAYSRUN\t36\n#define ID_AUTOSWITCH\t37\n#define ID_MOUSESPEED\t38\n#define ID_JOYENABLE\t39\n#define ID_JOYTHRESHOLD\t40\n#define ID_SMOOTHMOUSE\t41\n\n#define ANIM_IDLE\t\t0\n#define ANIM_RUN\t\t1\n#define ANIM_WALK\t\t2\n#define ANIM_BACK\t\t3\n#define ANIM_JUMP\t\t4\n#define ANIM_CROUCH\t\t5\n#define ANIM_STEPLEFT\t6\n#define ANIM_STEPRIGHT\t7\n#define ANIM_TURNLEFT\t8\n#define ANIM_TURNRIGHT\t9\n#define ANIM_LOOKUP\t\t10\n#define ANIM_LOOKDOWN\t11\n#define ANIM_WEAPON1\t12\n#define ANIM_WEAPON2\t13\n#define ANIM_WEAPON3\t14\n#define ANIM_WEAPON4\t15\n#define ANIM_WEAPON5\t16\n#define ANIM_WEAPON6\t17\n#define ANIM_WEAPON7\t18\n#define ANIM_WEAPON8\t19\n#define ANIM_WEAPON9\t20\n#define ANIM_WEAPON10\t21\n#define ANIM_ATTACK\t\t22\n#define ANIM_GESTURE\t23\n#define ANIM_DIE\t\t24\n#define ANIM_CHAT\t\t25\n\ntypedef struct\n{\n\tmenuframework_s\t\tmenu;\n\n\tmenutext_s\t\t\tbanner;\n\tmenubitmap_s\t\tframel;\n\tmenubitmap_s\t\tframer;\n\tmenubitmap_s\t\tplayer;\n\n\tmenutext_s\t\t\tmovement;\n\tmenutext_s\t\t\tlooking;\n\tmenutext_s\t\t\tweapons;\n\tmenutext_s\t\t\tmisc;\n\n\tmenuaction_s\t\twalkforward;\n\tmenuaction_s\t\tbackpedal;\n\tmenuaction_s\t\tstepleft;\n\tmenuaction_s\t\tstepright;\n\tmenuaction_s\t\tmoveup;\n\tmenuaction_s\t\tmovedown;\n\tmenuaction_s\t\tturnleft;\n\tmenuaction_s\t\tturnright;\n\tmenuaction_s\t\tsidestep;\n\tmenuaction_s\t\trun;\n\tmenuaction_s\t\tmachinegun;\n\tmenuaction_s\t\tchainsaw;\n\tmenuaction_s\t\tshotgun;\n\tmenuaction_s\t\tgrenadelauncher;\n\tmenuaction_s\t\trocketlauncher;\n\tmenuaction_s\t\tlightning;\n\tmenuaction_s\t\trailgun;\n\tmenuaction_s\t\tplasma;\n\tmenuaction_s\t\tbfg;\n\tmenuaction_s\t\tattack;\n\tmenuaction_s\t\tprevweapon;\n\tmenuaction_s\t\tnextweapon;\n\tmenuaction_s\t\tlookup;\n\tmenuaction_s\t\tlookdown;\n\tmenuaction_s\t\tmouselook;\n\tmenuradiobutton_s\tfreelook;\n\tmenuaction_s\t\tcenterview;\n\tmenuaction_s\t\tzoomview;\n\tmenuaction_s\t\tgesture;\n\tmenuradiobutton_s\tinvertmouse;\n\tmenuslider_s\t\tsensitivity;\n\tmenuradiobutton_s\tsmoothmouse;\n\tmenuradiobutton_s\talwaysrun;\n\tmenuaction_s\t\tshowscores;\n\tmenuradiobutton_s\tautoswitch;\n\tmenuaction_s\t\tuseitem;\n\tplayerInfo_t\t\tplayerinfo;\n\tqboolean\t\t\tchangesmade;\n\tmenuaction_s\t\tchat;\n\tmenuaction_s\t\tchat2;\n\tmenuaction_s\t\tchat3;\n\tmenuaction_s\t\tchat4;\n\tmenuradiobutton_s\tjoyenable;\n\tmenuslider_s\t\tjoythreshold;\n\tint\t\t\t\t\tsection;\n\tqboolean\t\t\twaitingforkey;\n\tchar\t\t\t\tplayerModel[64];\n\tvec3_t\t\t\t\tplayerViewangles;\n\tvec3_t\t\t\t\tplayerMoveangles;\n\tint\t\t\t\t\tplayerLegs;\n\tint\t\t\t\t\tplayerTorso;\n\tint\t\t\t\t\tplayerWeapon;\n\tqboolean\t\t\tplayerChat;\n\n\tmenubitmap_s\t\tback;\n\tmenutext_s\t\t\tname;\n} controls_t; \t\n\nstatic controls_t s_controls;\n\nstatic vec4_t controls_binding_color  = {1.00f, 0.43f, 0.00f, 1.00f}; // bk: Win32 C4305\n\nstatic bind_t g_bindings[] = \n{\n\t{\"+scores\",\t\t\t\"show scores\",\t\tID_SHOWSCORES,\tANIM_IDLE,\t\tK_TAB,\t\t\t-1,\t\t-1, -1},\n\t{\"+button2\",\t\t\"use item\",\t\t\tID_USEITEM,\t\tANIM_IDLE,\t\tK_ENTER,\t\t-1,\t\t-1, -1},\n\t{\"+speed\", \t\t\t\"run / walk\",\t\tID_SPEED,\t\tANIM_RUN,\t\tK_SHIFT,\t\t-1,\t\t-1,\t-1},\n\t{\"+forward\", \t\t\"walk forward\",\t\tID_FORWARD,\t\tANIM_WALK,\t\tK_UPARROW,\t\t-1,\t\t-1, -1},\n\t{\"+back\", \t\t\t\"backpedal\",\t\tID_BACKPEDAL,\tANIM_BACK,\t\tK_DOWNARROW,\t-1,\t\t-1, -1},\n\t{\"+moveleft\", \t\t\"step left\",\t\tID_MOVELEFT,\tANIM_STEPLEFT,\t',',\t\t\t-1,\t\t-1, -1},\n\t{\"+moveright\", \t\t\"step right\",\t\tID_MOVERIGHT,\tANIM_STEPRIGHT,\t'.',\t\t\t-1,\t\t-1, -1},\n\t{\"+moveup\",\t\t\t\"up / jump\",\t\tID_MOVEUP,\t\tANIM_JUMP,\t\tK_SPACE,\t\t-1,\t\t-1, -1},\n\t{\"+movedown\",\t\t\"down / crouch\",\tID_MOVEDOWN,\tANIM_CROUCH,\t'c',\t\t\t-1,\t\t-1, -1},\n\t{\"+left\", \t\t\t\"turn left\",\t\tID_LEFT,\t\tANIM_TURNLEFT,\tK_LEFTARROW,\t-1,\t\t-1, -1},\n\t{\"+right\", \t\t\t\"turn right\",\t\tID_RIGHT,\t\tANIM_TURNRIGHT,\tK_RIGHTARROW,\t-1,\t\t-1, -1},\n\t{\"+strafe\", \t\t\"sidestep / turn\",\tID_STRAFE,\t\tANIM_IDLE,\t\tK_ALT,\t\t\t-1,\t\t-1, -1},\n\t{\"+lookup\", \t\t\"look up\",\t\t\tID_LOOKUP,\t\tANIM_LOOKUP,\tK_PGDN,\t\t\t-1,\t\t-1, -1},\n\t{\"+lookdown\", \t\t\"look down\",\t\tID_LOOKDOWN,\tANIM_LOOKDOWN,\tK_DEL,\t\t\t-1,\t\t-1, -1},\n\t{\"+mlook\", \t\t\t\"mouse look\",\t\tID_MOUSELOOK,\tANIM_IDLE,\t\t'/',\t\t\t-1,\t\t-1, -1},\n\t{\"centerview\", \t\t\"center view\",\t\tID_CENTERVIEW,\tANIM_IDLE,\t\tK_END,\t\t\t-1,\t\t-1, -1},\n\t{\"+zoom\", \t\t\t\"zoom view\",\t\tID_ZOOMVIEW,\tANIM_IDLE,\t\t-1,\t\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 1\",\t\t\"gauntlet\",\t\t\tID_WEAPON1,\t\tANIM_WEAPON1,\t'1',\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 2\",\t\t\"machinegun\",\t\tID_WEAPON2,\t\tANIM_WEAPON2,\t'2',\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 3\",\t\t\"shotgun\",\t\t\tID_WEAPON3,\t\tANIM_WEAPON3,\t'3',\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 4\",\t\t\"grenade launcher\",\tID_WEAPON4,\t\tANIM_WEAPON4,\t'4',\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 5\",\t\t\"rocket launcher\",\tID_WEAPON5,\t\tANIM_WEAPON5,\t'5',\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 6\",\t\t\"lightning\",\t\tID_WEAPON6,\t\tANIM_WEAPON6,\t'6',\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 7\",\t\t\"railgun\",\t\t\tID_WEAPON7,\t\tANIM_WEAPON7,\t'7',\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 8\",\t\t\"plasma gun\",\t\tID_WEAPON8,\t\tANIM_WEAPON8,\t'8',\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 9\",\t\t\"BFG\",\t\t\t\tID_WEAPON9,\t\tANIM_WEAPON9,\t'9',\t\t\t-1,\t\t-1, -1},\n\t{\"+attack\", \t\t\"attack\",\t\t\tID_ATTACK,\t\tANIM_ATTACK,\tK_CTRL,\t\t\t-1,\t\t-1, -1},\n\t{\"weapprev\",\t\t\"prev weapon\",\t\tID_WEAPPREV,\tANIM_IDLE,\t\t'[',\t\t\t-1,\t\t-1, -1},\n\t{\"weapnext\", \t\t\"next weapon\",\t\tID_WEAPNEXT,\tANIM_IDLE,\t\t']',\t\t\t-1,\t\t-1, -1},\n\t{\"+button3\", \t\t\"gesture\",\t\t\tID_GESTURE,\t\tANIM_GESTURE,\tK_MOUSE3,\t\t-1,\t\t-1, -1},\n\t{\"messagemode\", \t\"chat\",\t\t\t\tID_CHAT,\t\tANIM_CHAT,\t\t't',\t\t\t-1,\t\t-1, -1},\n\t{\"messagemode2\", \t\"chat - team\",\t\tID_CHAT2,\t\tANIM_CHAT,\t\t-1,\t\t\t\t-1,\t\t-1, -1},\n\t{\"messagemode3\", \t\"chat - target\",\tID_CHAT3,\t\tANIM_CHAT,\t\t-1,\t\t\t\t-1,\t\t-1, -1},\n\t{\"messagemode4\", \t\"chat - attacker\",\tID_CHAT4,\t\tANIM_CHAT,\t\t-1,\t\t\t\t-1,\t\t-1, -1},\n\t{(char*)NULL,\t\t(char*)NULL,\t\t0,\t\t\t\t0,\t\t\t\t-1,\t\t\t\t-1,\t\t-1,\t-1},\n};\n\nstatic configcvar_t g_configcvars[] =\n{\n\t{\"cl_run\",\t\t\t0,\t\t\t\t\t0},\n\t{\"m_pitch\",\t\t\t0,\t\t\t\t\t0},\n\t{\"cg_autoswitch\",\t0,\t\t\t\t\t0},\n\t{\"sensitivity\",\t\t0,\t\t\t\t\t0},\n\t{\"in_joystick\",\t\t0,\t\t\t\t\t0},\n\t{\"joy_threshold\",\t0,\t\t\t\t\t0},\n\t{\"m_filter\",\t\t0,\t\t\t\t\t0},\n\t{\"cl_freelook\",\t\t0,\t\t\t\t\t0},\n\t{NULL,\t\t\t\t0,\t\t\t\t\t0}\n};\n\nstatic menucommon_s *g_movement_controls[] =\n{\n\t(menucommon_s *)&s_controls.alwaysrun,     \n\t(menucommon_s *)&s_controls.run,            \n\t(menucommon_s *)&s_controls.walkforward,\n\t(menucommon_s *)&s_controls.backpedal,\n\t(menucommon_s *)&s_controls.stepleft,      \n\t(menucommon_s *)&s_controls.stepright,     \n\t(menucommon_s *)&s_controls.moveup,        \n\t(menucommon_s *)&s_controls.movedown,      \n\t(menucommon_s *)&s_controls.turnleft,      \n\t(menucommon_s *)&s_controls.turnright,     \n\t(menucommon_s *)&s_controls.sidestep,\n\tNULL\n};\n\nstatic menucommon_s *g_weapons_controls[] = {\n\t(menucommon_s *)&s_controls.attack,           \n\t(menucommon_s *)&s_controls.nextweapon,\n\t(menucommon_s *)&s_controls.prevweapon,\n\t(menucommon_s *)&s_controls.autoswitch,    \n\t(menucommon_s *)&s_controls.chainsaw,         \n\t(menucommon_s *)&s_controls.machinegun,\n\t(menucommon_s *)&s_controls.shotgun,          \n\t(menucommon_s *)&s_controls.grenadelauncher,\n\t(menucommon_s *)&s_controls.rocketlauncher,   \n\t(menucommon_s *)&s_controls.lightning,   \n\t(menucommon_s *)&s_controls.railgun,          \n\t(menucommon_s *)&s_controls.plasma,           \n\t(menucommon_s *)&s_controls.bfg,              \n\tNULL,\n};\n\nstatic menucommon_s *g_looking_controls[] = {\n\t(menucommon_s *)&s_controls.sensitivity,\n\t(menucommon_s *)&s_controls.smoothmouse,\n\t(menucommon_s *)&s_controls.invertmouse,\n\t(menucommon_s *)&s_controls.lookup,\n\t(menucommon_s *)&s_controls.lookdown,\n\t(menucommon_s *)&s_controls.mouselook,\n\t(menucommon_s *)&s_controls.freelook,\n\t(menucommon_s *)&s_controls.centerview,\n\t(menucommon_s *)&s_controls.zoomview,\n\t(menucommon_s *)&s_controls.joyenable,\n\t(menucommon_s *)&s_controls.joythreshold,\n\tNULL,\n};\n\nstatic menucommon_s *g_misc_controls[] = {\n\t(menucommon_s *)&s_controls.showscores, \n\t(menucommon_s *)&s_controls.useitem,\n\t(menucommon_s *)&s_controls.gesture,\n\t(menucommon_s *)&s_controls.chat,\n\t(menucommon_s *)&s_controls.chat2,\n\t(menucommon_s *)&s_controls.chat3,\n\t(menucommon_s *)&s_controls.chat4,\n\tNULL,\n};\n\nstatic menucommon_s **g_controls[] = {\n\tg_movement_controls,\n\tg_looking_controls,\n\tg_weapons_controls,\n\tg_misc_controls,\n};\n\n/*\n=================\nControls_InitCvars\n=================\n*/\nstatic void Controls_InitCvars( void )\n{\n\tint\t\t\t\ti;\n\tconfigcvar_t*\tcvarptr;\n\n\tcvarptr = g_configcvars;\n\tfor (i=0; ;i++,cvarptr++)\n\t{\n\t\tif (!cvarptr->name)\n\t\t\tbreak;\n\n\t\t// get current value\n\t\tcvarptr->value = trap_Cvar_VariableValue( cvarptr->name );\n\n\t\t// get default value\n\t\ttrap_Cvar_Reset( cvarptr->name );\n\t\tcvarptr->defaultvalue = trap_Cvar_VariableValue( cvarptr->name );\n\n\t\t// restore current value\n\t\ttrap_Cvar_SetValue( cvarptr->name, cvarptr->value );\n\t}\n}\n\n/*\n=================\nControls_GetCvarDefault\n=================\n*/\nstatic float Controls_GetCvarDefault( char* name )\n{\n\tconfigcvar_t*\tcvarptr;\n\tint\t\t\t\ti;\n\n\tcvarptr = g_configcvars;\n\tfor (i=0; ;i++,cvarptr++)\n\t{\n\t\tif (!cvarptr->name)\n\t\t\treturn (0);\n\n\t\tif (!strcmp(cvarptr->name,name))\n\t\t\tbreak;\n\t}\n\n\treturn (cvarptr->defaultvalue);\n}\n\n/*\n=================\nControls_GetCvarValue\n=================\n*/\nstatic float Controls_GetCvarValue( char* name )\n{\n\tconfigcvar_t*\tcvarptr;\n\tint\t\t\t\ti;\n\n\tcvarptr = g_configcvars;\n\tfor (i=0; ;i++,cvarptr++)\n\t{\n\t\tif (!cvarptr->name)\n\t\t\treturn (0);\n\n\t\tif (!strcmp(cvarptr->name,name))\n\t\t\tbreak;\n\t}\n\n\treturn (cvarptr->value);\n}\n\n\n/*\n=================\nControls_UpdateModel\n=================\n*/\nstatic void Controls_UpdateModel( int anim ) {\n\tVectorClear( s_controls.playerViewangles );\n\tVectorClear( s_controls.playerMoveangles );\n\ts_controls.playerViewangles[YAW] = 180 - 30;\n\ts_controls.playerMoveangles[YAW] = s_controls.playerViewangles[YAW];\n\ts_controls.playerLegs\t\t     = LEGS_IDLE;\n\ts_controls.playerTorso\t\t\t = TORSO_STAND;\n\ts_controls.playerWeapon\t\t\t = -1;\n\ts_controls.playerChat\t\t\t = qfalse;\n\n\tswitch( anim ) {\n\tcase ANIM_RUN:\t\n\t\ts_controls.playerLegs = LEGS_RUN;\n\t\tbreak;\n\n\tcase ANIM_WALK:\t\n\t\ts_controls.playerLegs = LEGS_WALK;\n\t\tbreak;\n\n\tcase ANIM_BACK:\t\n\t\ts_controls.playerLegs = LEGS_BACK;\n\t\tbreak;\n\n\tcase ANIM_JUMP:\t\n\t\ts_controls.playerLegs = LEGS_JUMP;\n\t\tbreak;\n\n\tcase ANIM_CROUCH:\t\n\t\ts_controls.playerLegs = LEGS_IDLECR;\n\t\tbreak;\n\n\tcase ANIM_TURNLEFT:\n\t\ts_controls.playerViewangles[YAW] += 90;\n\t\tbreak;\n\n\tcase ANIM_TURNRIGHT:\n\t\ts_controls.playerViewangles[YAW] -= 90;\n\t\tbreak;\n\n\tcase ANIM_STEPLEFT:\n\t\ts_controls.playerLegs = LEGS_WALK;\n\t\ts_controls.playerMoveangles[YAW] = s_controls.playerViewangles[YAW] + 90;\n\t\tbreak;\n\n\tcase ANIM_STEPRIGHT:\n\t\ts_controls.playerLegs = LEGS_WALK;\n\t\ts_controls.playerMoveangles[YAW] = s_controls.playerViewangles[YAW] - 90;\n\t\tbreak;\n\n\tcase ANIM_LOOKUP:\n\t\ts_controls.playerViewangles[PITCH] = -45;\n\t\tbreak;\n\n\tcase ANIM_LOOKDOWN:\n\t\ts_controls.playerViewangles[PITCH] = 45;\n\t\tbreak;\n\n\tcase ANIM_WEAPON1:\n\t\ts_controls.playerWeapon = WP_GAUNTLET;\n\t\tbreak;\n\n\tcase ANIM_WEAPON2:\n\t\ts_controls.playerWeapon = WP_MACHINEGUN;\n\t\tbreak;\n\n\tcase ANIM_WEAPON3:\n\t\ts_controls.playerWeapon = WP_SHOTGUN;\n\t\tbreak;\n\n\tcase ANIM_WEAPON4:\n\t\ts_controls.playerWeapon = WP_GRENADE_LAUNCHER;\n\t\tbreak;\n\n\tcase ANIM_WEAPON5:\n\t\ts_controls.playerWeapon = WP_ROCKET_LAUNCHER;\n\t\tbreak;\n\n\tcase ANIM_WEAPON6:\n\t\ts_controls.playerWeapon = WP_LIGHTNING;\n\t\tbreak;\n\n\tcase ANIM_WEAPON7:\n\t\ts_controls.playerWeapon = WP_RAILGUN;\n\t\tbreak;\n\n\tcase ANIM_WEAPON8:\n\t\ts_controls.playerWeapon = WP_PLASMAGUN;\n\t\tbreak;\n\n\tcase ANIM_WEAPON9:\n\t\ts_controls.playerWeapon = WP_BFG;\n\t\tbreak;\n\n\tcase ANIM_WEAPON10:\n\t\ts_controls.playerWeapon = WP_GRAPPLING_HOOK;\n\t\tbreak;\n\n\tcase ANIM_ATTACK:\n\t\ts_controls.playerTorso = TORSO_ATTACK;\n\t\tbreak;\n\n\tcase ANIM_GESTURE:\n\t\ts_controls.playerTorso = TORSO_GESTURE;\n\t\tbreak;\n\n\tcase ANIM_DIE:\n\t\ts_controls.playerLegs = BOTH_DEATH1;\n\t\ts_controls.playerTorso = BOTH_DEATH1;\n\t\ts_controls.playerWeapon = WP_NONE;\n\t\tbreak;\n\n\tcase ANIM_CHAT:\n\t\ts_controls.playerChat = qtrue;\n\t\tbreak;\n\n\tdefault:\n\t\tbreak;\n\t}\n\n\tUI_PlayerInfo_SetInfo( &s_controls.playerinfo, s_controls.playerLegs, s_controls.playerTorso, s_controls.playerViewangles, s_controls.playerMoveangles, s_controls.playerWeapon, s_controls.playerChat );\n}\n\n\n/*\n=================\nControls_Update\n=================\n*/\nstatic void Controls_Update( void ) {\n\tint\t\ti;\n\tint\t\tj;\n\tint\t\ty;\n\tmenucommon_s\t**controls;\n\tmenucommon_s\t*control;\n\n\t// disable all controls in all groups\n\tfor( i = 0; i < C_MAX; i++ ) {\n\t\tcontrols = g_controls[i];\n\t\t// bk001204 - parentheses\n\t\tfor( j = 0;  (control = controls[j]) ; j++ ) {\n\t\t\tcontrol->flags |= (QMF_HIDDEN|QMF_INACTIVE);\n\t\t}\n\t}\n\n\tcontrols = g_controls[s_controls.section];\n\n\t// enable controls in active group (and count number of items for vertical centering)\n\t// bk001204 - parentheses\n\tfor( j = 0;  (control = controls[j]) ; j++ ) {\n\t\tcontrol->flags &= ~(QMF_GRAYED|QMF_HIDDEN|QMF_INACTIVE);\n\t}\n\n\t// position controls\n\ty = ( SCREEN_HEIGHT - j * SMALLCHAR_HEIGHT ) / 2;\n\t// bk001204 - parentheses\n\tfor( j = 0;\t(control = controls[j]) ; j++, y += SMALLCHAR_HEIGHT ) {\n\t\tcontrol->x      = 320;\n\t\tcontrol->y      = y;\n\t\tcontrol->left   = 320 - 19*SMALLCHAR_WIDTH;\n\t\tcontrol->right  = 320 + 21*SMALLCHAR_WIDTH;\n\t\tcontrol->top    = y;\n\t\tcontrol->bottom = y + SMALLCHAR_HEIGHT;\n\t}\n\n\tif( s_controls.waitingforkey ) {\n\t\t// disable everybody\n\t\tfor( i = 0; i < s_controls.menu.nitems; i++ ) {\n\t\t\t((menucommon_s*)(s_controls.menu.items[i]))->flags |= QMF_GRAYED;\n\t\t}\n\n\t\t// enable action item\n\t\t((menucommon_s*)(s_controls.menu.items[s_controls.menu.cursor]))->flags &= ~QMF_GRAYED;\n\n\t\t// don't gray out player's name\n\t\ts_controls.name.generic.flags &= ~QMF_GRAYED;\n\n\t\treturn;\n\t}\n\n\t// enable everybody\n\tfor( i = 0; i < s_controls.menu.nitems; i++ ) {\n\t\t((menucommon_s*)(s_controls.menu.items[i]))->flags &= ~QMF_GRAYED;\n\t}\n\n\t// makes sure flags are right on the group selection controls\n\ts_controls.looking.generic.flags  &= ~(QMF_GRAYED|QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS);\n\ts_controls.movement.generic.flags &= ~(QMF_GRAYED|QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS);\n\ts_controls.weapons.generic.flags  &= ~(QMF_GRAYED|QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS);\n\ts_controls.misc.generic.flags     &= ~(QMF_GRAYED|QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS);\n\n\ts_controls.looking.generic.flags  |= QMF_PULSEIFFOCUS;\n\ts_controls.movement.generic.flags |= QMF_PULSEIFFOCUS;\n\ts_controls.weapons.generic.flags  |= QMF_PULSEIFFOCUS;\n\ts_controls.misc.generic.flags     |= QMF_PULSEIFFOCUS;\n\n\t// set buttons\n\tswitch( s_controls.section ) {\n\tcase C_MOVEMENT:\n\t\ts_controls.movement.generic.flags &= ~QMF_PULSEIFFOCUS;\n\t\ts_controls.movement.generic.flags |= (QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS);\n\t\tbreak;\n\t\n\tcase C_LOOKING:\n\t\ts_controls.looking.generic.flags &= ~QMF_PULSEIFFOCUS;\n\t\ts_controls.looking.generic.flags |= (QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS);\n\t\tbreak;\n\t\n\tcase C_WEAPONS:\n\t\ts_controls.weapons.generic.flags &= ~QMF_PULSEIFFOCUS;\n\t\ts_controls.weapons.generic.flags |= (QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS);\n\t\tbreak;\t\t\n\n\tcase C_MISC:\n\t\ts_controls.misc.generic.flags &= ~QMF_PULSEIFFOCUS;\n\t\ts_controls.misc.generic.flags |= (QMF_HIGHLIGHT|QMF_HIGHLIGHT_IF_FOCUS);\n\t\tbreak;\n\t}\n}\n\n\n/*\n=================\nControls_DrawKeyBinding\n=================\n*/\nstatic void Controls_DrawKeyBinding( void *self )\n{\n\tmenuaction_s*\ta;\n\tint\t\t\t\tx;\n\tint\t\t\t\ty;\n\tint\t\t\t\tb1;\n\tint\t\t\t\tb2;\n\tqboolean\t\tc;\n\tchar\t\t\tname[32];\n\tchar\t\t\tname2[32];\n\n\ta = (menuaction_s*) self;\n\n\tx =\ta->generic.x;\n\ty = a->generic.y;\n\n\tc = (Menu_ItemAtCursor( a->generic.parent ) == a);\n\n\tb1 = g_bindings[a->generic.id].bind1;\n\tif (b1 == -1)\n\t\tstrcpy(name,\"???\");\n\telse\n\t{\n\t\ttrap_Key_KeynumToStringBuf( b1, name, 32 );\n\t\tQ_strupr(name);\n\n\t\tb2 = g_bindings[a->generic.id].bind2;\n\t\tif (b2 != -1)\n\t\t{\n\t\t\ttrap_Key_KeynumToStringBuf( b2, name2, 32 );\n\t\t\tQ_strupr(name2);\n\n\t\t\tstrcat( name, \" or \" );\n\t\t\tstrcat( name, name2 );\n\t\t}\n\t}\n\n\tif (c)\n\t{\n\t\tUI_FillRect( a->generic.left, a->generic.top, a->generic.right-a->generic.left+1, a->generic.bottom-a->generic.top+1, listbar_color ); \n\n\t\tUI_DrawString( x - SMALLCHAR_WIDTH, y, g_bindings[a->generic.id].label, UI_RIGHT|UI_SMALLFONT, text_color_highlight );\n\t\tUI_DrawString( x + SMALLCHAR_WIDTH, y, name, UI_LEFT|UI_SMALLFONT|UI_PULSE, text_color_highlight );\n\n\t\tif (s_controls.waitingforkey)\n\t\t{\n\t\t\tUI_DrawChar( x, y, '=', UI_CENTER|UI_BLINK|UI_SMALLFONT, text_color_highlight);\n\t\t\tUI_DrawString(SCREEN_WIDTH * 0.50, SCREEN_HEIGHT * 0.80, \"Waiting for new key ... ESCAPE to cancel\", UI_SMALLFONT|UI_CENTER|UI_PULSE, colorWhite );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tUI_DrawChar( x, y, 13, UI_CENTER|UI_BLINK|UI_SMALLFONT, text_color_highlight);\n\t\t\tUI_DrawString(SCREEN_WIDTH * 0.50, SCREEN_HEIGHT * 0.78, \"Press ENTER or CLICK to change\", UI_SMALLFONT|UI_CENTER, colorWhite );\n\t\t\tUI_DrawString(SCREEN_WIDTH * 0.50, SCREEN_HEIGHT * 0.82, \"Press BACKSPACE to clear\", UI_SMALLFONT|UI_CENTER, colorWhite );\n\t\t}\n\t}\n\telse\n\t{\n\t\tif (a->generic.flags & QMF_GRAYED)\n\t\t{\n\t\t\tUI_DrawString( x - SMALLCHAR_WIDTH, y, g_bindings[a->generic.id].label, UI_RIGHT|UI_SMALLFONT, text_color_disabled );\n\t\t\tUI_DrawString( x + SMALLCHAR_WIDTH, y, name, UI_LEFT|UI_SMALLFONT, text_color_disabled );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tUI_DrawString( x - SMALLCHAR_WIDTH, y, g_bindings[a->generic.id].label, UI_RIGHT|UI_SMALLFONT, controls_binding_color );\n\t\t\tUI_DrawString( x + SMALLCHAR_WIDTH, y, name, UI_LEFT|UI_SMALLFONT, controls_binding_color );\n\t\t}\n\t}\n}\n\n/*\n=================\nControls_StatusBar\n=================\n*/\nstatic void Controls_StatusBar( void *self )\n{\n\tUI_DrawString(SCREEN_WIDTH * 0.50, SCREEN_HEIGHT * 0.80, \"Use Arrow Keys or CLICK to change\", UI_SMALLFONT|UI_CENTER, colorWhite );\n}\n\n\n/*\n=================\nControls_DrawPlayer\n=================\n*/\nstatic void Controls_DrawPlayer( void *self ) {\n\tmenubitmap_s\t*b;\n\tchar\t\t\tbuf[MAX_QPATH];\n\n\ttrap_Cvar_VariableStringBuffer( \"model\", buf, sizeof( buf ) );\n\tif ( strcmp( buf, s_controls.playerModel ) != 0 ) {\n\t\tUI_PlayerInfo_SetModel( &s_controls.playerinfo, buf );\n\t\tstrcpy( s_controls.playerModel, buf );\n\t\tControls_UpdateModel( ANIM_IDLE );\n\t}\n\n\tb = (menubitmap_s*) self;\n\tUI_DrawPlayer( b->generic.x, b->generic.y, b->width, b->height, &s_controls.playerinfo, uis.realtime/2 );\n}\n\n\n/*\n=================\nControls_GetKeyAssignment\n=================\n*/\nstatic void Controls_GetKeyAssignment (char *command, int *twokeys)\n{\n\tint\t\tcount;\n\tint\t\tj;\n\tchar\tb[256];\n\n\ttwokeys[0] = twokeys[1] = -1;\n\tcount = 0;\n\n\tfor ( j = 0; j < 256; j++ )\n\t{\n\t\ttrap_Key_GetBindingBuf( j, b, 256 );\n\t\tif ( *b == 0 ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( !Q_stricmp( b, command ) ) {\n\t\t\ttwokeys[count] = j;\n\t\t\tcount++;\n\t\t\tif (count == 2)\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/*\n=================\nControls_GetConfig\n=================\n*/\nstatic void Controls_GetConfig( void )\n{\n\tint\t\ti;\n\tint\t\ttwokeys[2];\n\tbind_t*\tbindptr;\n\n\t// put the bindings into a local store\n\tbindptr = g_bindings;\n\n\t// iterate each command, get its numeric binding\n\tfor (i=0; ;i++,bindptr++)\n\t{\n\t\tif (!bindptr->label)\n\t\t\tbreak;\n\n\t\tControls_GetKeyAssignment(bindptr->command, twokeys);\n\n\t\tbindptr->bind1 = twokeys[0];\n\t\tbindptr->bind2 = twokeys[1];\n\t}\n\n\ts_controls.invertmouse.curvalue  = Controls_GetCvarValue( \"m_pitch\" ) < 0;\n\ts_controls.smoothmouse.curvalue  = UI_ClampCvar( 0, 1, Controls_GetCvarValue( \"m_filter\" ) );\n\ts_controls.alwaysrun.curvalue    = UI_ClampCvar( 0, 1, Controls_GetCvarValue( \"cl_run\" ) );\n\ts_controls.autoswitch.curvalue   = UI_ClampCvar( 0, 1, Controls_GetCvarValue( \"cg_autoswitch\" ) );\n\ts_controls.sensitivity.curvalue  = UI_ClampCvar( 2, 30, Controls_GetCvarValue( \"sensitivity\" ) );\n\ts_controls.joyenable.curvalue    = UI_ClampCvar( 0, 1, Controls_GetCvarValue( \"in_joystick\" ) );\n\ts_controls.joythreshold.curvalue = UI_ClampCvar( 0.05f, 0.75f, Controls_GetCvarValue( \"joy_threshold\" ) );\n\ts_controls.freelook.curvalue     = UI_ClampCvar( 0, 1, Controls_GetCvarValue( \"cl_freelook\" ) );\n}\n\n/*\n=================\nControls_SetConfig\n=================\n*/\nstatic void Controls_SetConfig( void )\n{\n\tint\t\ti;\n\tbind_t*\tbindptr;\n\n\t// set the bindings from the local store\n\tbindptr = g_bindings;\n\n\t// iterate each command, get its numeric binding\n\tfor (i=0; ;i++,bindptr++)\n\t{\n\t\tif (!bindptr->label)\n\t\t\tbreak;\n\n\t\tif (bindptr->bind1 != -1)\n\t\t{\t\n\t\t\ttrap_Key_SetBinding( bindptr->bind1, bindptr->command );\n\n\t\t\tif (bindptr->bind2 != -1)\n\t\t\t\ttrap_Key_SetBinding( bindptr->bind2, bindptr->command );\n\t\t}\n\t}\n\n\tif ( s_controls.invertmouse.curvalue )\n\t\ttrap_Cvar_SetValue( \"m_pitch\", -fabs( trap_Cvar_VariableValue( \"m_pitch\" ) ) );\n\telse\n\t\ttrap_Cvar_SetValue( \"m_pitch\", fabs( trap_Cvar_VariableValue( \"m_pitch\" ) ) );\n\n\ttrap_Cvar_SetValue( \"m_filter\", s_controls.smoothmouse.curvalue );\n\ttrap_Cvar_SetValue( \"cl_run\", s_controls.alwaysrun.curvalue );\n\ttrap_Cvar_SetValue( \"cg_autoswitch\", s_controls.autoswitch.curvalue );\n\ttrap_Cvar_SetValue( \"sensitivity\", s_controls.sensitivity.curvalue );\n\ttrap_Cvar_SetValue( \"in_joystick\", s_controls.joyenable.curvalue );\n\ttrap_Cvar_SetValue( \"joy_threshold\", s_controls.joythreshold.curvalue );\n\ttrap_Cvar_SetValue( \"cl_freelook\", s_controls.freelook.curvalue );\n\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"in_restart\\n\" );\n}\n\n/*\n=================\nControls_SetDefaults\n=================\n*/\nstatic void Controls_SetDefaults( void )\n{\n\tint\ti;\n\tbind_t*\tbindptr;\n\n\t// set the bindings from the local store\n\tbindptr = g_bindings;\n\n\t// iterate each command, set its default binding\n\tfor (i=0; ;i++,bindptr++)\n\t{\n\t\tif (!bindptr->label)\n\t\t\tbreak;\n\n\t\tbindptr->bind1 = bindptr->defaultbind1;\n\t\tbindptr->bind2 = bindptr->defaultbind2;\n\t}\n\n\ts_controls.invertmouse.curvalue  = Controls_GetCvarDefault( \"m_pitch\" ) < 0;\n\ts_controls.smoothmouse.curvalue  = Controls_GetCvarDefault( \"m_filter\" );\n\ts_controls.alwaysrun.curvalue    = Controls_GetCvarDefault( \"cl_run\" );\n\ts_controls.autoswitch.curvalue   = Controls_GetCvarDefault( \"cg_autoswitch\" );\n\ts_controls.sensitivity.curvalue  = Controls_GetCvarDefault( \"sensitivity\" );\n\ts_controls.joyenable.curvalue    = Controls_GetCvarDefault( \"in_joystick\" );\n\ts_controls.joythreshold.curvalue = Controls_GetCvarDefault( \"joy_threshold\" );\n\ts_controls.freelook.curvalue     = Controls_GetCvarDefault( \"cl_freelook\" );\n}\n\n/*\n=================\nControls_MenuKey\n=================\n*/\nstatic sfxHandle_t Controls_MenuKey( int key )\n{\n\tint\t\t\tid;\n\tint\t\t\ti;\n\tqboolean\tfound;\n\tbind_t*\t\tbindptr;\n\tfound = qfalse;\n\n\tif (!s_controls.waitingforkey)\n\t{\n\t\tswitch (key)\n\t\t{\n\t\t\tcase K_BACKSPACE:\n\t\t\tcase K_DEL:\n\t\t\tcase K_KP_DEL:\n\t\t\t\tkey = -1;\n\t\t\t\tbreak;\n\t\t\n\t\t\tcase K_MOUSE2:\n\t\t\tcase K_ESCAPE:\n\t\t\t\tif (s_controls.changesmade)\n\t\t\t\t\tControls_SetConfig();\n\t\t\t\tgoto ignorekey;\t\n\n\t\t\tdefault:\n\t\t\t\tgoto ignorekey;\n\t\t}\n\t}\n\telse\n\t{\n\t\tif (key & K_CHAR_FLAG)\n\t\t\tgoto ignorekey;\n\n\t\tswitch (key)\n\t\t{\n\t\t\tcase K_ESCAPE:\n\t\t\t\ts_controls.waitingforkey = qfalse;\n\t\t\t\tControls_Update();\n\t\t\t\treturn (menu_out_sound);\n\t\n\t\t\tcase '`':\n\t\t\t\tgoto ignorekey;\n\t\t}\n\t}\n\n\ts_controls.changesmade = qtrue;\n\t\n\tif (key != -1)\n\t{\n\t\t// remove from any other bind\n\t\tbindptr = g_bindings;\n\t\tfor (i=0; ;i++,bindptr++)\n\t\t{\n\t\t\tif (!bindptr->label)\t\n\t\t\t\tbreak;\n\n\t\t\tif (bindptr->bind2 == key)\n\t\t\t\tbindptr->bind2 = -1;\n\n\t\t\tif (bindptr->bind1 == key)\n\t\t\t{\n\t\t\t\tbindptr->bind1 = bindptr->bind2;\t\n\t\t\t\tbindptr->bind2 = -1;\n\t\t\t}\n\t\t}\n\t}\n\n\t// assign key to local store\n\tid      = ((menucommon_s*)(s_controls.menu.items[s_controls.menu.cursor]))->id;\n\tbindptr = g_bindings;\n\tfor (i=0; ;i++,bindptr++)\n\t{\n\t\tif (!bindptr->label)\t\n\t\t\tbreak;\n\t\t\n\t\tif (bindptr->id == id)\n\t\t{\n\t\t\tfound = qtrue;\n\t\t\tif (key == -1)\n\t\t\t{\n\t\t\t\tif( bindptr->bind1 != -1 ) {\n\t\t\t\t\ttrap_Key_SetBinding( bindptr->bind1, \"\" );\n\t\t\t\t\tbindptr->bind1 = -1;\n\t\t\t\t}\n\t\t\t\tif( bindptr->bind2 != -1 ) {\n\t\t\t\t\ttrap_Key_SetBinding( bindptr->bind2, \"\" );\n\t\t\t\t\tbindptr->bind2 = -1;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (bindptr->bind1 == -1) {\n\t\t\t\tbindptr->bind1 = key;\n\t\t\t}\n\t\t\telse if (bindptr->bind1 != key && bindptr->bind2 == -1) {\n\t\t\t\tbindptr->bind2 = key;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttrap_Key_SetBinding( bindptr->bind1, \"\" );\n\t\t\t\ttrap_Key_SetBinding( bindptr->bind2, \"\" );\n\t\t\t\tbindptr->bind1 = key;\n\t\t\t\tbindptr->bind2 = -1;\n\t\t\t}\t\t\t\t\t\t\n\t\t\tbreak;\n\t\t}\n\t}\t\t\t\t\n\t\t\n\ts_controls.waitingforkey = qfalse;\n\n\tif (found)\n\t{\t\n\t\tControls_Update();\n\t\treturn (menu_out_sound);\n\t}\n\nignorekey:\n\treturn Menu_DefaultKey( &s_controls.menu, key );\n}\n\n/*\n=================\nControls_ResetDefaults_Action\n=================\n*/\nstatic void Controls_ResetDefaults_Action( qboolean result ) {\n\tif( !result ) {\n\t\treturn;\n\t}\n\n\ts_controls.changesmade = qtrue;\n\tControls_SetDefaults();\n\tControls_Update();\n}\n\n/*\n=================\nControls_ResetDefaults_Draw\n=================\n*/\nstatic void Controls_ResetDefaults_Draw( void ) {\n\tUI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 0, \"WARNING: This will reset all\", UI_CENTER|UI_SMALLFONT, color_yellow );\n\tUI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 1, \"controls to their default values.\", UI_CENTER|UI_SMALLFONT, color_yellow );\n}\n\n/*\n=================\nControls_MenuEvent\n=================\n*/\nstatic void Controls_MenuEvent( void* ptr, int event )\n{\n\tswitch (((menucommon_s*)ptr)->id)\n\t{\n\t\tcase ID_MOVEMENT:\n\t\t\tif (event == QM_ACTIVATED)\n\t\t\t{\n\t\t\t\ts_controls.section = C_MOVEMENT; \n\t\t\t\tControls_Update();\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase ID_LOOKING:\n\t\t\tif (event == QM_ACTIVATED)\n\t\t\t{\n\t\t\t\ts_controls.section = C_LOOKING; \n\t\t\t\tControls_Update();\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase ID_WEAPONS:\n\t\t\tif (event == QM_ACTIVATED)\n\t\t\t{\n\t\t\t\ts_controls.section = C_WEAPONS; \n\t\t\t\tControls_Update();\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase ID_MISC:\n\t\t\tif (event == QM_ACTIVATED)\n\t\t\t{\n\t\t\t\ts_controls.section = C_MISC; \n\t\t\t\tControls_Update();\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase ID_DEFAULTS:\n\t\t\tif (event == QM_ACTIVATED)\n\t\t\t{\n\t\t\t\tUI_ConfirmMenu( \"SET TO DEFAULTS?\", Controls_ResetDefaults_Draw, Controls_ResetDefaults_Action );\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase ID_BACK:\n\t\t\tif (event == QM_ACTIVATED)\n\t\t\t{\n\t\t\t\tif (s_controls.changesmade)\n\t\t\t\t\tControls_SetConfig();\n\t\t\t\tUI_PopMenu();\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase ID_SAVEANDEXIT:\n\t\t\tif (event == QM_ACTIVATED)\n\t\t\t{\n\t\t\t\tControls_SetConfig();\n\t\t\t\tUI_PopMenu();\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase ID_EXIT:\n\t\t\tif (event == QM_ACTIVATED)\n\t\t\t{\n\t\t\t\tUI_PopMenu();\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase ID_FREELOOK:\n\t\tcase ID_MOUSESPEED:\n\t\tcase ID_INVERTMOUSE:\n\t\tcase ID_SMOOTHMOUSE:\n\t\tcase ID_ALWAYSRUN:\n\t\tcase ID_AUTOSWITCH:\n\t\tcase ID_JOYENABLE:\n\t\tcase ID_JOYTHRESHOLD:\n\t\t\tif (event == QM_ACTIVATED)\n\t\t\t{\n\t\t\t\ts_controls.changesmade = qtrue;\n\t\t\t}\n\t\t\tbreak;\t\t\n\t}\n}\n\n/*\n=================\nControls_ActionEvent\n=================\n*/\nstatic void Controls_ActionEvent( void* ptr, int event )\n{\n\tif (event == QM_LOSTFOCUS)\n\t{\n\t\tControls_UpdateModel( ANIM_IDLE );\n\t}\n\telse if (event == QM_GOTFOCUS)\n\t{\n\t\tControls_UpdateModel( g_bindings[((menucommon_s*)ptr)->id].anim );\n\t}\n\telse if ((event == QM_ACTIVATED) && !s_controls.waitingforkey)\n\t{\n\t\ts_controls.waitingforkey = 1;\n\t\tControls_Update();\n\t}\n}\n\n/*\n=================\nControls_InitModel\n=================\n*/\nstatic void Controls_InitModel( void )\n{\n\tmemset( &s_controls.playerinfo, 0, sizeof(playerInfo_t) );\n\n\tUI_PlayerInfo_SetModel( &s_controls.playerinfo, UI_Cvar_VariableString( \"model\" ) );\n\n\tControls_UpdateModel( ANIM_IDLE );\n}\n\n/*\n=================\nControls_InitWeapons\n=================\n*/\nstatic void Controls_InitWeapons( void ) {\n\tgitem_t *\titem;\n\n\tfor ( item = bg_itemlist + 1 ; item->classname ; item++ ) {\n\t\tif ( item->giType != IT_WEAPON ) {\n\t\t\tcontinue;\n\t\t}\n\t\ttrap_R_RegisterModel( item->world_model[0] );\n\t}\n}\n\n/*\n=================\nControls_MenuInit\n=================\n*/\nstatic void Controls_MenuInit( void )\n{\n\tstatic char playername[32];\n\n\t// zero set all our globals\n\tmemset( &s_controls, 0 ,sizeof(controls_t) );\n\n\tControls_Cache();\n\n\ts_controls.menu.key        = Controls_MenuKey;\n\ts_controls.menu.wrapAround = qtrue;\n\ts_controls.menu.fullscreen = qtrue;\n\n\ts_controls.banner.generic.type\t= MTYPE_BTEXT;\n\ts_controls.banner.generic.flags\t= QMF_CENTER_JUSTIFY;\n\ts_controls.banner.generic.x\t\t= 320;\n\ts_controls.banner.generic.y\t\t= 16;\n\ts_controls.banner.string\t\t= \"CONTROLS\";\n\ts_controls.banner.color\t\t\t= color_white;\n\ts_controls.banner.style\t\t\t= UI_CENTER;\n\n\ts_controls.framel.generic.type  = MTYPE_BITMAP;\n\ts_controls.framel.generic.name  = ART_FRAMEL;\n\ts_controls.framel.generic.flags = QMF_LEFT_JUSTIFY|QMF_INACTIVE;\n\ts_controls.framel.generic.x     = 0;\n\ts_controls.framel.generic.y     = 78;\n\ts_controls.framel.width  \t    = 256;\n\ts_controls.framel.height  \t    = 329;\n\n\ts_controls.framer.generic.type  = MTYPE_BITMAP;\n\ts_controls.framer.generic.name  = ART_FRAMER;\n\ts_controls.framer.generic.flags = QMF_LEFT_JUSTIFY|QMF_INACTIVE;\n\ts_controls.framer.generic.x     = 376;\n\ts_controls.framer.generic.y     = 76;\n\ts_controls.framer.width  \t    = 256;\n\ts_controls.framer.height  \t    = 334;\n\n\ts_controls.looking.generic.type     = MTYPE_PTEXT;\n\ts_controls.looking.generic.flags    = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_controls.looking.generic.id\t    = ID_LOOKING;\n\ts_controls.looking.generic.callback\t= Controls_MenuEvent;\n\ts_controls.looking.generic.x\t    = 152;\n\ts_controls.looking.generic.y\t    = 240 - 2 * PROP_HEIGHT;\n\ts_controls.looking.string\t\t\t= \"LOOK\";\n\ts_controls.looking.style\t\t\t= UI_RIGHT;\n\ts_controls.looking.color\t\t\t= color_red;\n\n\ts_controls.movement.generic.type     = MTYPE_PTEXT;\n\ts_controls.movement.generic.flags    = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_controls.movement.generic.id\t     = ID_MOVEMENT;\n\ts_controls.movement.generic.callback = Controls_MenuEvent;\n\ts_controls.movement.generic.x\t     = 152;\n\ts_controls.movement.generic.y\t     = 240 - PROP_HEIGHT;\n\ts_controls.movement.string\t\t\t= \"MOVE\";\n\ts_controls.movement.style\t\t\t= UI_RIGHT;\n\ts_controls.movement.color\t\t\t= color_red;\n\n\ts_controls.weapons.generic.type\t    = MTYPE_PTEXT;\n\ts_controls.weapons.generic.flags    = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_controls.weapons.generic.id\t    = ID_WEAPONS;\n\ts_controls.weapons.generic.callback\t= Controls_MenuEvent;\n\ts_controls.weapons.generic.x\t    = 152;\n\ts_controls.weapons.generic.y\t    = 240;\n\ts_controls.weapons.string\t\t\t= \"SHOOT\";\n\ts_controls.weapons.style\t\t\t= UI_RIGHT;\n\ts_controls.weapons.color\t\t\t= color_red;\n\n\ts_controls.misc.generic.type\t = MTYPE_PTEXT;\n\ts_controls.misc.generic.flags    = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_controls.misc.generic.id\t     = ID_MISC;\n\ts_controls.misc.generic.callback = Controls_MenuEvent;\n\ts_controls.misc.generic.x\t\t = 152;\n\ts_controls.misc.generic.y\t\t = 240 + PROP_HEIGHT;\n\ts_controls.misc.string\t\t\t= \"MISC\";\n\ts_controls.misc.style\t\t\t= UI_RIGHT;\n\ts_controls.misc.color\t\t\t= color_red;\n\n\ts_controls.back.generic.type\t = MTYPE_BITMAP;\n\ts_controls.back.generic.name     = ART_BACK0;\n\ts_controls.back.generic.flags    = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_controls.back.generic.x\t\t = 0;\n\ts_controls.back.generic.y\t\t = 480-64;\n\ts_controls.back.generic.id\t     = ID_BACK;\n\ts_controls.back.generic.callback = Controls_MenuEvent;\n\ts_controls.back.width  \t\t     = 128;\n\ts_controls.back.height  \t\t = 64;\n\ts_controls.back.focuspic         = ART_BACK1;\n\n\ts_controls.player.generic.type      = MTYPE_BITMAP;\n\ts_controls.player.generic.flags     = QMF_INACTIVE;\n\ts_controls.player.generic.ownerdraw = Controls_DrawPlayer;\n\ts_controls.player.generic.x\t        = 400;\n\ts_controls.player.generic.y\t        = -40;\n\ts_controls.player.width\t            = 32*10;\n\ts_controls.player.height            = 56*10;\n\n\ts_controls.walkforward.generic.type\t     = MTYPE_ACTION;\n\ts_controls.walkforward.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.walkforward.generic.callback  = Controls_ActionEvent;\n\ts_controls.walkforward.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.walkforward.generic.id \t     = ID_FORWARD;\n\n\ts_controls.backpedal.generic.type\t   = MTYPE_ACTION;\n\ts_controls.backpedal.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.backpedal.generic.callback  = Controls_ActionEvent;\n\ts_controls.backpedal.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.backpedal.generic.id \t   = ID_BACKPEDAL;\n\n\ts_controls.stepleft.generic.type\t  = MTYPE_ACTION;\n\ts_controls.stepleft.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.stepleft.generic.callback  = Controls_ActionEvent;\n\ts_controls.stepleft.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.stepleft.generic.id \t\t  = ID_MOVELEFT;\n\n\ts_controls.stepright.generic.type\t   = MTYPE_ACTION;\n\ts_controls.stepright.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.stepright.generic.callback  = Controls_ActionEvent;\n\ts_controls.stepright.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.stepright.generic.id        = ID_MOVERIGHT;\n\n\ts_controls.moveup.generic.type\t    = MTYPE_ACTION;\n\ts_controls.moveup.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.moveup.generic.callback  = Controls_ActionEvent;\n\ts_controls.moveup.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.moveup.generic.id        = ID_MOVEUP;\n\n\ts_controls.movedown.generic.type\t  = MTYPE_ACTION;\n\ts_controls.movedown.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.movedown.generic.callback  = Controls_ActionEvent;\n\ts_controls.movedown.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.movedown.generic.id        = ID_MOVEDOWN;\n\n\ts_controls.turnleft.generic.type\t  = MTYPE_ACTION;\n\ts_controls.turnleft.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.turnleft.generic.callback  = Controls_ActionEvent;\n\ts_controls.turnleft.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.turnleft.generic.id        = ID_LEFT;\n\n\ts_controls.turnright.generic.type\t   = MTYPE_ACTION;\n\ts_controls.turnright.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.turnright.generic.callback  = Controls_ActionEvent;\n\ts_controls.turnright.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.turnright.generic.id        = ID_RIGHT;\n\n\ts_controls.sidestep.generic.type\t  = MTYPE_ACTION;\n\ts_controls.sidestep.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.sidestep.generic.callback  = Controls_ActionEvent;\n\ts_controls.sidestep.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.sidestep.generic.id        = ID_STRAFE;\n\n\ts_controls.run.generic.type\t     = MTYPE_ACTION;\n\ts_controls.run.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.run.generic.callback  = Controls_ActionEvent;\n\ts_controls.run.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.run.generic.id        = ID_SPEED;\n\n\ts_controls.chainsaw.generic.type\t  = MTYPE_ACTION;\n\ts_controls.chainsaw.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.chainsaw.generic.callback  = Controls_ActionEvent;\n\ts_controls.chainsaw.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.chainsaw.generic.id        = ID_WEAPON1;\n\n\ts_controls.machinegun.generic.type\t    = MTYPE_ACTION;\n\ts_controls.machinegun.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.machinegun.generic.callback  = Controls_ActionEvent;\n\ts_controls.machinegun.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.machinegun.generic.id        = ID_WEAPON2;\n\n\ts_controls.shotgun.generic.type\t     = MTYPE_ACTION;\n\ts_controls.shotgun.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.shotgun.generic.callback  = Controls_ActionEvent;\n\ts_controls.shotgun.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.shotgun.generic.id        = ID_WEAPON3;\n\n\ts_controls.grenadelauncher.generic.type\t     = MTYPE_ACTION;\n\ts_controls.grenadelauncher.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.grenadelauncher.generic.callback  = Controls_ActionEvent;\n\ts_controls.grenadelauncher.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.grenadelauncher.generic.id        = ID_WEAPON4;\n\n\ts_controls.rocketlauncher.generic.type\t    = MTYPE_ACTION;\n\ts_controls.rocketlauncher.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.rocketlauncher.generic.callback  = Controls_ActionEvent;\n\ts_controls.rocketlauncher.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.rocketlauncher.generic.id        = ID_WEAPON5;\n\n\ts_controls.lightning.generic.type\t   = MTYPE_ACTION;\n\ts_controls.lightning.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.lightning.generic.callback  = Controls_ActionEvent;\n\ts_controls.lightning.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.lightning.generic.id        = ID_WEAPON6;\n\n\ts_controls.railgun.generic.type\t     = MTYPE_ACTION;\n\ts_controls.railgun.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.railgun.generic.callback  = Controls_ActionEvent;\n\ts_controls.railgun.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.railgun.generic.id        = ID_WEAPON7;\n\n\ts_controls.plasma.generic.type\t    = MTYPE_ACTION;\n\ts_controls.plasma.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.plasma.generic.callback  = Controls_ActionEvent;\n\ts_controls.plasma.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.plasma.generic.id        = ID_WEAPON8;\n\n\ts_controls.bfg.generic.type\t     = MTYPE_ACTION;\n\ts_controls.bfg.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.bfg.generic.callback  = Controls_ActionEvent;\n\ts_controls.bfg.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.bfg.generic.id        = ID_WEAPON9;\n\n\ts_controls.attack.generic.type\t    = MTYPE_ACTION;\n\ts_controls.attack.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.attack.generic.callback  = Controls_ActionEvent;\n\ts_controls.attack.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.attack.generic.id        = ID_ATTACK;\n\n\ts_controls.prevweapon.generic.type\t    = MTYPE_ACTION;\n\ts_controls.prevweapon.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.prevweapon.generic.callback  = Controls_ActionEvent;\n\ts_controls.prevweapon.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.prevweapon.generic.id        = ID_WEAPPREV;\n\n\ts_controls.nextweapon.generic.type\t    = MTYPE_ACTION;\n\ts_controls.nextweapon.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.nextweapon.generic.callback  = Controls_ActionEvent;\n\ts_controls.nextweapon.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.nextweapon.generic.id        = ID_WEAPNEXT;\n\n\ts_controls.lookup.generic.type\t    = MTYPE_ACTION;\n\ts_controls.lookup.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.lookup.generic.callback  = Controls_ActionEvent;\n\ts_controls.lookup.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.lookup.generic.id        = ID_LOOKUP;\n\n\ts_controls.lookdown.generic.type\t  = MTYPE_ACTION;\n\ts_controls.lookdown.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.lookdown.generic.callback  = Controls_ActionEvent;\n\ts_controls.lookdown.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.lookdown.generic.id        = ID_LOOKDOWN;\n\n\ts_controls.mouselook.generic.type\t   = MTYPE_ACTION;\n\ts_controls.mouselook.generic.flags     = QMF_LEFT_JUSTIFY|QMF_HIGHLIGHT_IF_FOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.mouselook.generic.callback  = Controls_ActionEvent;\n\ts_controls.mouselook.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.mouselook.generic.id        = ID_MOUSELOOK;\n\n\ts_controls.freelook.generic.type\t\t= MTYPE_RADIOBUTTON;\n\ts_controls.freelook.generic.flags\t\t= QMF_SMALLFONT;\n\ts_controls.freelook.generic.x\t\t\t= SCREEN_WIDTH/2;\n\ts_controls.freelook.generic.name\t\t= \"free look\";\n\ts_controls.freelook.generic.id\t\t\t= ID_FREELOOK;\n\ts_controls.freelook.generic.callback\t= Controls_MenuEvent;\n\ts_controls.freelook.generic.statusbar\t= Controls_StatusBar;\n\n\ts_controls.centerview.generic.type\t    = MTYPE_ACTION;\n\ts_controls.centerview.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.centerview.generic.callback  = Controls_ActionEvent;\n\ts_controls.centerview.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.centerview.generic.id        = ID_CENTERVIEW;\n\n\ts_controls.zoomview.generic.type\t  = MTYPE_ACTION;\n\ts_controls.zoomview.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.zoomview.generic.callback  = Controls_ActionEvent;\n\ts_controls.zoomview.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.zoomview.generic.id        = ID_ZOOMVIEW;\n\n\ts_controls.useitem.generic.type\t     = MTYPE_ACTION;\n\ts_controls.useitem.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.useitem.generic.callback  = Controls_ActionEvent;\n\ts_controls.useitem.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.useitem.generic.id        = ID_USEITEM;\n\n\ts_controls.showscores.generic.type\t    = MTYPE_ACTION;\n\ts_controls.showscores.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.showscores.generic.callback  = Controls_ActionEvent;\n\ts_controls.showscores.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.showscores.generic.id        = ID_SHOWSCORES;\n\n\ts_controls.invertmouse.generic.type      = MTYPE_RADIOBUTTON;\n\ts_controls.invertmouse.generic.flags\t = QMF_SMALLFONT;\n\ts_controls.invertmouse.generic.x\t     = SCREEN_WIDTH/2;\n\ts_controls.invertmouse.generic.name\t     = \"invert mouse\";\n\ts_controls.invertmouse.generic.id        = ID_INVERTMOUSE;\n\ts_controls.invertmouse.generic.callback  = Controls_MenuEvent;\n\ts_controls.invertmouse.generic.statusbar = Controls_StatusBar;\n\n\ts_controls.smoothmouse.generic.type      = MTYPE_RADIOBUTTON;\n\ts_controls.smoothmouse.generic.flags\t = QMF_SMALLFONT;\n\ts_controls.smoothmouse.generic.x\t     = SCREEN_WIDTH/2;\n\ts_controls.smoothmouse.generic.name\t     = \"smooth mouse\";\n\ts_controls.smoothmouse.generic.id        = ID_SMOOTHMOUSE;\n\ts_controls.smoothmouse.generic.callback  = Controls_MenuEvent;\n\ts_controls.smoothmouse.generic.statusbar = Controls_StatusBar;\n\n\ts_controls.alwaysrun.generic.type      = MTYPE_RADIOBUTTON;\n\ts_controls.alwaysrun.generic.flags\t   = QMF_SMALLFONT;\n\ts_controls.alwaysrun.generic.x\t       = SCREEN_WIDTH/2;\n\ts_controls.alwaysrun.generic.name\t   = \"always run\";\n\ts_controls.alwaysrun.generic.id        = ID_ALWAYSRUN;\n\ts_controls.alwaysrun.generic.callback  = Controls_MenuEvent;\n\ts_controls.alwaysrun.generic.statusbar = Controls_StatusBar;\n\n\ts_controls.autoswitch.generic.type      = MTYPE_RADIOBUTTON;\n\ts_controls.autoswitch.generic.flags\t    = QMF_SMALLFONT;\n\ts_controls.autoswitch.generic.x\t        = SCREEN_WIDTH/2;\n\ts_controls.autoswitch.generic.name\t    = \"autoswitch weapons\";\n\ts_controls.autoswitch.generic.id        = ID_AUTOSWITCH;\n\ts_controls.autoswitch.generic.callback  = Controls_MenuEvent;\n\ts_controls.autoswitch.generic.statusbar = Controls_StatusBar;\n\n\ts_controls.sensitivity.generic.type\t     = MTYPE_SLIDER;\n\ts_controls.sensitivity.generic.x\t\t = SCREEN_WIDTH/2;\n\ts_controls.sensitivity.generic.flags\t = QMF_SMALLFONT;\n\ts_controls.sensitivity.generic.name\t     = \"mouse speed\";\n\ts_controls.sensitivity.generic.id \t     = ID_MOUSESPEED;\n\ts_controls.sensitivity.generic.callback  = Controls_MenuEvent;\n\ts_controls.sensitivity.minvalue\t\t     = 2;\n\ts_controls.sensitivity.maxvalue\t\t     = 30;\n\ts_controls.sensitivity.generic.statusbar = Controls_StatusBar;\n\n\ts_controls.gesture.generic.type\t     = MTYPE_ACTION;\n\ts_controls.gesture.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.gesture.generic.callback  = Controls_ActionEvent;\n\ts_controls.gesture.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.gesture.generic.id        = ID_GESTURE;\n\n\ts_controls.chat.generic.type\t  = MTYPE_ACTION;\n\ts_controls.chat.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.chat.generic.callback  = Controls_ActionEvent;\n\ts_controls.chat.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.chat.generic.id        = ID_CHAT;\n\n\ts_controls.chat2.generic.type\t   = MTYPE_ACTION;\n\ts_controls.chat2.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.chat2.generic.callback  = Controls_ActionEvent;\n\ts_controls.chat2.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.chat2.generic.id        = ID_CHAT2;\n\n\ts_controls.chat3.generic.type\t   = MTYPE_ACTION;\n\ts_controls.chat3.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.chat3.generic.callback  = Controls_ActionEvent;\n\ts_controls.chat3.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.chat3.generic.id        = ID_CHAT3;\n\n\ts_controls.chat4.generic.type\t   = MTYPE_ACTION;\n\ts_controls.chat4.generic.flags     = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;\n\ts_controls.chat4.generic.callback  = Controls_ActionEvent;\n\ts_controls.chat4.generic.ownerdraw = Controls_DrawKeyBinding;\n\ts_controls.chat4.generic.id        = ID_CHAT4;\n\n\ts_controls.joyenable.generic.type      = MTYPE_RADIOBUTTON;\n\ts_controls.joyenable.generic.flags\t   = QMF_SMALLFONT;\n\ts_controls.joyenable.generic.x\t       = SCREEN_WIDTH/2;\n\ts_controls.joyenable.generic.name\t   = \"joystick\";\n\ts_controls.joyenable.generic.id        = ID_JOYENABLE;\n\ts_controls.joyenable.generic.callback  = Controls_MenuEvent;\n\ts_controls.joyenable.generic.statusbar = Controls_StatusBar;\n\n\ts_controls.joythreshold.generic.type\t  = MTYPE_SLIDER;\n\ts_controls.joythreshold.generic.x\t\t  = SCREEN_WIDTH/2;\n\ts_controls.joythreshold.generic.flags\t  = QMF_SMALLFONT;\n\ts_controls.joythreshold.generic.name\t  = \"joystick threshold\";\n\ts_controls.joythreshold.generic.id \t      = ID_JOYTHRESHOLD;\n\ts_controls.joythreshold.generic.callback  = Controls_MenuEvent;\n\ts_controls.joythreshold.minvalue\t\t  = 0.05f;\n\ts_controls.joythreshold.maxvalue\t\t  = 0.75f;\n\ts_controls.joythreshold.generic.statusbar = Controls_StatusBar;\n\n\ts_controls.name.generic.type\t= MTYPE_PTEXT;\n\ts_controls.name.generic.flags\t= QMF_CENTER_JUSTIFY|QMF_INACTIVE;\n\ts_controls.name.generic.x\t\t= 320;\n\ts_controls.name.generic.y\t\t= 440;\n\ts_controls.name.string\t\t\t= playername;\n\ts_controls.name.style\t\t\t= UI_CENTER;\n\ts_controls.name.color\t\t\t= text_color_normal;\n\n\tMenu_AddItem( &s_controls.menu, &s_controls.banner );\n\tMenu_AddItem( &s_controls.menu, &s_controls.framel );\n\tMenu_AddItem( &s_controls.menu, &s_controls.framer );\n\tMenu_AddItem( &s_controls.menu, &s_controls.player );\n\tMenu_AddItem( &s_controls.menu, &s_controls.name );\n\n\tMenu_AddItem( &s_controls.menu, &s_controls.looking );\n\tMenu_AddItem( &s_controls.menu, &s_controls.movement );\n\tMenu_AddItem( &s_controls.menu, &s_controls.weapons );\n\tMenu_AddItem( &s_controls.menu, &s_controls.misc );\n\n\tMenu_AddItem( &s_controls.menu, &s_controls.sensitivity );\n\tMenu_AddItem( &s_controls.menu, &s_controls.smoothmouse );\n\tMenu_AddItem( &s_controls.menu, &s_controls.invertmouse );\n\tMenu_AddItem( &s_controls.menu, &s_controls.lookup );\n\tMenu_AddItem( &s_controls.menu, &s_controls.lookdown );\n\tMenu_AddItem( &s_controls.menu, &s_controls.mouselook );\n\tMenu_AddItem( &s_controls.menu, &s_controls.freelook );\n\tMenu_AddItem( &s_controls.menu, &s_controls.centerview );\n\tMenu_AddItem( &s_controls.menu, &s_controls.zoomview );\n\tMenu_AddItem( &s_controls.menu, &s_controls.joyenable );\n\tMenu_AddItem( &s_controls.menu, &s_controls.joythreshold );\n\n\tMenu_AddItem( &s_controls.menu, &s_controls.alwaysrun );\n\tMenu_AddItem( &s_controls.menu, &s_controls.run );\n\tMenu_AddItem( &s_controls.menu, &s_controls.walkforward );\n\tMenu_AddItem( &s_controls.menu, &s_controls.backpedal );\n\tMenu_AddItem( &s_controls.menu, &s_controls.stepleft );\n\tMenu_AddItem( &s_controls.menu, &s_controls.stepright );\n\tMenu_AddItem( &s_controls.menu, &s_controls.moveup );\n\tMenu_AddItem( &s_controls.menu, &s_controls.movedown );\n\tMenu_AddItem( &s_controls.menu, &s_controls.turnleft );\n\tMenu_AddItem( &s_controls.menu, &s_controls.turnright );\n\tMenu_AddItem( &s_controls.menu, &s_controls.sidestep );\n\n\tMenu_AddItem( &s_controls.menu, &s_controls.attack );\n\tMenu_AddItem( &s_controls.menu, &s_controls.nextweapon );\n\tMenu_AddItem( &s_controls.menu, &s_controls.prevweapon );\n\tMenu_AddItem( &s_controls.menu, &s_controls.autoswitch );\n\tMenu_AddItem( &s_controls.menu, &s_controls.chainsaw );\n\tMenu_AddItem( &s_controls.menu, &s_controls.machinegun );\n\tMenu_AddItem( &s_controls.menu, &s_controls.shotgun );\n\tMenu_AddItem( &s_controls.menu, &s_controls.grenadelauncher );\n\tMenu_AddItem( &s_controls.menu, &s_controls.rocketlauncher );\n\tMenu_AddItem( &s_controls.menu, &s_controls.lightning );\n\tMenu_AddItem( &s_controls.menu, &s_controls.railgun );\n\tMenu_AddItem( &s_controls.menu, &s_controls.plasma );\n\tMenu_AddItem( &s_controls.menu, &s_controls.bfg );\n\n\tMenu_AddItem( &s_controls.menu, &s_controls.showscores );\n\tMenu_AddItem( &s_controls.menu, &s_controls.useitem );\n\tMenu_AddItem( &s_controls.menu, &s_controls.gesture );\n\tMenu_AddItem( &s_controls.menu, &s_controls.chat );\n\tMenu_AddItem( &s_controls.menu, &s_controls.chat2 );\n\tMenu_AddItem( &s_controls.menu, &s_controls.chat3 );\n\tMenu_AddItem( &s_controls.menu, &s_controls.chat4 );\n\n\tMenu_AddItem( &s_controls.menu, &s_controls.back );\n\n\ttrap_Cvar_VariableStringBuffer( \"name\", s_controls.name.string, 16 );\n\tQ_CleanStr( s_controls.name.string );\n\n\t// initialize the configurable cvars\n\tControls_InitCvars();\n\n\t// initialize the current config\n\tControls_GetConfig();\n\n\t// intialize the model\n\tControls_InitModel();\n\n\t// intialize the weapons\n\tControls_InitWeapons ();\n\n\t// initial default section\n\ts_controls.section = C_LOOKING;\n\n\t// update the ui\n\tControls_Update();\n}\n\n\n/*\n=================\nControls_Cache\n=================\n*/\nvoid Controls_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( ART_BACK0 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK1 );\n\ttrap_R_RegisterShaderNoMip( ART_FRAMEL );\n\ttrap_R_RegisterShaderNoMip( ART_FRAMER );\n}\n\n\n/*\n=================\nUI_ControlsMenu\n=================\n*/\nvoid UI_ControlsMenu( void ) {\n\tControls_MenuInit();\n\tUI_PushMenu( &s_controls.menu );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_credits.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=======================================================================\n\nCREDITS\n\n=======================================================================\n*/\n\n\n#include \"ui_local.h\"\n\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n} creditsmenu_t;\n\nstatic creditsmenu_t\ts_credits;\n\n\n/*\n=================\nUI_CreditMenu_Key\n=================\n*/\nstatic sfxHandle_t UI_CreditMenu_Key( int key ) {\n\tif( key & K_CHAR_FLAG ) {\n\t\treturn 0;\n\t}\n\n\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"quit\\n\" );\n\treturn 0;\n}\n\n\n/*\n===============\nUI_CreditMenu_Draw\n===============\n*/\nstatic void UI_CreditMenu_Draw( void ) {\n\tint\t\ty;\n\n\ty = 12;\n\tUI_DrawProportionalString( 320, y, \"id Software is:\", UI_CENTER|UI_SMALLFONT, color_white );\n\n\ty += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;\n\tUI_DrawProportionalString( 320, y, \"Programming\", UI_CENTER|UI_SMALLFONT, color_white );\n\ty += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;\n\tUI_DrawProportionalString( 320, y, \"John Carmack, Robert A. Duffy, Jim Dose'\", UI_CENTER|UI_SMALLFONT, color_white );\n\n\ty += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;\n\tUI_DrawProportionalString( 320, y, \"Art\", UI_CENTER|UI_SMALLFONT, color_white );\n\ty += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;\n\tUI_DrawProportionalString( 320, y, \"Adrian Carmack, Kevin Cloud,\", UI_CENTER|UI_SMALLFONT, color_white );\n\ty += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;\n\tUI_DrawProportionalString( 320, y, \"Kenneth Scott, Seneca Menard, Fred Nilsson\", UI_CENTER|UI_SMALLFONT, color_white );\n\n\ty += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;\n\tUI_DrawProportionalString( 320, y, \"Game Designer\", UI_CENTER|UI_SMALLFONT, color_white );\n\ty += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;\n\tUI_DrawProportionalString( 320, y, \"Graeme Devine\", UI_CENTER|UI_SMALLFONT, color_white );\n\n\ty += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;\n\tUI_DrawProportionalString( 320, y, \"Level Design\", UI_CENTER|UI_SMALLFONT, color_white );\n\ty += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;\n\tUI_DrawProportionalString( 320, y, \"Tim Willits, Christian Antkow, Paul Jaquays\", UI_CENTER|UI_SMALLFONT, color_white );\n\n\ty += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;\n\tUI_DrawProportionalString( 320, y, \"CEO\", UI_CENTER|UI_SMALLFONT, color_white );\n\ty += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;\n\tUI_DrawProportionalString( 320, y, \"Todd Hollenshead\", UI_CENTER|UI_SMALLFONT, color_white );\n\n\ty += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;\n\tUI_DrawProportionalString( 320, y, \"Director of Business Development\", UI_CENTER|UI_SMALLFONT, color_white );\n\ty += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;\n\tUI_DrawProportionalString( 320, y, \"Marty Stratton\", UI_CENTER|UI_SMALLFONT, color_white );\n\n\ty += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;\n\tUI_DrawProportionalString( 320, y, \"Biz Assist and id Mom\", UI_CENTER|UI_SMALLFONT, color_white );\n\ty += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;\n\tUI_DrawProportionalString( 320, y, \"Donna Jackson\", UI_CENTER|UI_SMALLFONT, color_white );\n\n\ty += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;\n\tUI_DrawProportionalString( 320, y, \"Development Assistance\", UI_CENTER|UI_SMALLFONT, color_white );\n\ty += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;\n\tUI_DrawProportionalString( 320, y, \"Eric Webb\", UI_CENTER|UI_SMALLFONT, color_white );\n\n\ty += 1.35 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE;\n\tUI_DrawString( 320, y, \"To order: 1-800-idgames     www.quake3arena.com     www.idsoftware.com\", UI_CENTER|UI_SMALLFONT, color_red );\n\ty += SMALLCHAR_HEIGHT;\n\tUI_DrawString( 320, y, \"Quake III Arena(c) 1999-2000, Id Software, Inc.  All Rights Reserved\", UI_CENTER|UI_SMALLFONT, color_red );\n}\n\n\n/*\n===============\nUI_CreditMenu\n===============\n*/\nvoid UI_CreditMenu( void ) {\n\tmemset( &s_credits, 0 ,sizeof(s_credits) );\n\n\ts_credits.menu.draw = UI_CreditMenu_Draw;\n\ts_credits.menu.key = UI_CreditMenu_Key;\n\ts_credits.menu.fullscreen = qtrue;\n\tUI_PushMenu ( &s_credits.menu );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_demo2.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=======================================================================\n\nDEMOS MENU\n\n=======================================================================\n*/\n\n\n#include \"ui_local.h\"\n\n\n#define ART_BACK0\t\t\t\"menu/art/back_0\"\n#define ART_BACK1\t\t\t\"menu/art/back_1\"\t\n#define ART_GO0\t\t\t\t\"menu/art/play_0\"\n#define ART_GO1\t\t\t\t\"menu/art/play_1\"\n#define ART_FRAMEL\t\t\t\"menu/art/frame2_l\"\n#define ART_FRAMER\t\t\t\"menu/art/frame1_r\"\n#define ART_ARROWS\t\t\t\"menu/art/arrows_horz_0\"\n#define ART_ARROWLEFT\t\t\"menu/art/arrows_horz_left\"\n#define ART_ARROWRIGHT\t\t\"menu/art/arrows_horz_right\"\n\n#define MAX_DEMOS\t\t\t128\n#define NAMEBUFSIZE\t\t\t( MAX_DEMOS * 16 )\n\n#define ID_BACK\t\t\t\t10\n#define ID_GO\t\t\t\t11\n#define ID_LIST\t\t\t\t12\n#define ID_RIGHT\t\t\t13\n#define ID_LEFT\t\t\t\t14\n\n#define ARROWS_WIDTH\t\t128\n#define ARROWS_HEIGHT\t\t48\n\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n\n\tmenutext_s\t\tbanner;\n\tmenubitmap_s\tframel;\n\tmenubitmap_s\tframer;\n\n\tmenulist_s\t\tlist;\n\n\tmenubitmap_s\tarrows;\n\tmenubitmap_s\tleft;\n\tmenubitmap_s\tright;\n\tmenubitmap_s\tback;\n\tmenubitmap_s\tgo;\n\n\tint\t\t\t\tnumDemos;\n\tchar\t\t\tnames[NAMEBUFSIZE];\n\tchar\t\t\t*demolist[MAX_DEMOS];\n} demos_t;\n\nstatic demos_t\ts_demos;\n\n\n/*\n===============\nDemos_MenuEvent\n===============\n*/\nstatic void Demos_MenuEvent( void *ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tswitch( ((menucommon_s*)ptr)->id ) {\n\tcase ID_GO:\n\t\tUI_ForceMenuOff ();\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va( \"demo %s\\n\",\n\t\t\t\t\t\t\t\ts_demos.list.itemnames[s_demos.list.curvalue]) );\n\t\tbreak;\n\n\tcase ID_BACK:\n\t\tUI_PopMenu();\n\t\tbreak;\n\n\tcase ID_LEFT:\n\t\tScrollList_Key( &s_demos.list, K_LEFTARROW );\n\t\tbreak;\n\n\tcase ID_RIGHT:\n\t\tScrollList_Key( &s_demos.list, K_RIGHTARROW );\n\t\tbreak;\n\t}\n}\n\n\n/*\n=================\nUI_DemosMenu_Key\n=================\n*/\nstatic sfxHandle_t UI_DemosMenu_Key( int key ) {\n\tmenucommon_s\t*item;\n\n\titem = Menu_ItemAtCursor( &s_demos.menu );\n\n\treturn Menu_DefaultKey( &s_demos.menu, key );\n}\n\n\n/*\n===============\nDemos_MenuInit\n===============\n*/\nstatic void Demos_MenuInit( void ) {\n\tint\t\ti;\n\tint\t\tlen;\n\tchar\t*demoname, extension[32];\n\n\tmemset( &s_demos, 0 ,sizeof(demos_t) );\n\ts_demos.menu.key = UI_DemosMenu_Key;\n\n\tDemos_Cache();\n\n\ts_demos.menu.fullscreen = qtrue;\n\ts_demos.menu.wrapAround = qtrue;\n\n\ts_demos.banner.generic.type\t\t= MTYPE_BTEXT;\n\ts_demos.banner.generic.x\t\t= 320;\n\ts_demos.banner.generic.y\t\t= 16;\n\ts_demos.banner.string\t\t\t= \"DEMOS\";\n\ts_demos.banner.color\t\t\t= color_white;\n\ts_demos.banner.style\t\t\t= UI_CENTER;\n\n\ts_demos.framel.generic.type\t\t= MTYPE_BITMAP;\n\ts_demos.framel.generic.name\t\t= ART_FRAMEL;\n\ts_demos.framel.generic.flags\t= QMF_INACTIVE;\n\ts_demos.framel.generic.x\t\t= 0;  \n\ts_demos.framel.generic.y\t\t= 78;\n\ts_demos.framel.width\t\t\t= 256;\n\ts_demos.framel.height\t\t\t= 329;\n\n\ts_demos.framer.generic.type\t\t= MTYPE_BITMAP;\n\ts_demos.framer.generic.name\t\t= ART_FRAMER;\n\ts_demos.framer.generic.flags\t= QMF_INACTIVE;\n\ts_demos.framer.generic.x\t\t= 376;\n\ts_demos.framer.generic.y\t\t= 76;\n\ts_demos.framer.width\t\t\t= 256;\n\ts_demos.framer.height\t\t\t= 334;\n\n\ts_demos.arrows.generic.type\t\t= MTYPE_BITMAP;\n\ts_demos.arrows.generic.name\t\t= ART_ARROWS;\n\ts_demos.arrows.generic.flags\t= QMF_INACTIVE;\n\ts_demos.arrows.generic.x\t\t= 320-ARROWS_WIDTH/2;\n\ts_demos.arrows.generic.y\t\t= 400;\n\ts_demos.arrows.width\t\t\t= ARROWS_WIDTH;\n\ts_demos.arrows.height\t\t\t= ARROWS_HEIGHT;\n\n\ts_demos.left.generic.type\t\t= MTYPE_BITMAP;\n\ts_demos.left.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;\n\ts_demos.left.generic.x\t\t\t= 320-ARROWS_WIDTH/2;\n\ts_demos.left.generic.y\t\t\t= 400;\n\ts_demos.left.generic.id\t\t\t= ID_LEFT;\n\ts_demos.left.generic.callback\t= Demos_MenuEvent;\n\ts_demos.left.width\t\t\t\t= ARROWS_WIDTH/2;\n\ts_demos.left.height\t\t\t\t= ARROWS_HEIGHT;\n\ts_demos.left.focuspic\t\t\t= ART_ARROWLEFT;\n\n\ts_demos.right.generic.type\t\t= MTYPE_BITMAP;\n\ts_demos.right.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;\n\ts_demos.right.generic.x\t\t\t= 320;\n\ts_demos.right.generic.y\t\t\t= 400;\n\ts_demos.right.generic.id\t\t= ID_RIGHT;\n\ts_demos.right.generic.callback\t= Demos_MenuEvent;\n\ts_demos.right.width\t\t\t\t= ARROWS_WIDTH/2;\n\ts_demos.right.height\t\t\t= ARROWS_HEIGHT;\n\ts_demos.right.focuspic\t\t\t= ART_ARROWRIGHT;\n\n\ts_demos.back.generic.type\t\t= MTYPE_BITMAP;\n\ts_demos.back.generic.name\t\t= ART_BACK0;\n\ts_demos.back.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_demos.back.generic.id\t\t\t= ID_BACK;\n\ts_demos.back.generic.callback\t= Demos_MenuEvent;\n\ts_demos.back.generic.x\t\t\t= 0;\n\ts_demos.back.generic.y\t\t\t= 480-64;\n\ts_demos.back.width\t\t\t\t= 128;\n\ts_demos.back.height\t\t\t\t= 64;\n\ts_demos.back.focuspic\t\t\t= ART_BACK1;\n\n\ts_demos.go.generic.type\t\t\t= MTYPE_BITMAP;\n\ts_demos.go.generic.name\t\t\t= ART_GO0;\n\ts_demos.go.generic.flags\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_demos.go.generic.id\t\t\t= ID_GO;\n\ts_demos.go.generic.callback\t\t= Demos_MenuEvent;\n\ts_demos.go.generic.x\t\t\t= 640;\n\ts_demos.go.generic.y\t\t\t= 480-64;\n\ts_demos.go.width\t\t\t\t= 128;\n\ts_demos.go.height\t\t\t\t= 64;\n\ts_demos.go.focuspic\t\t\t\t= ART_GO1;\n\n\ts_demos.list.generic.type\t\t= MTYPE_SCROLLLIST;\n\ts_demos.list.generic.flags\t\t= QMF_PULSEIFFOCUS;\n\ts_demos.list.generic.callback\t= Demos_MenuEvent;\n\ts_demos.list.generic.id\t\t\t= ID_LIST;\n\ts_demos.list.generic.x\t\t\t= 118;\n\ts_demos.list.generic.y\t\t\t= 130;\n\ts_demos.list.width\t\t\t\t= 16;\n\ts_demos.list.height\t\t\t\t= 14;\n\tCom_sprintf(extension, sizeof(extension), \"dm_%d\", (int)trap_Cvar_VariableValue( \"protocol\" ) );\n\ts_demos.list.numitems\t\t\t= trap_FS_GetFileList( \"demos\", extension, s_demos.names, NAMEBUFSIZE );\n\ts_demos.list.itemnames\t\t\t= (const char **)s_demos.demolist;\n\ts_demos.list.columns\t\t\t= 3;\n\n\tif (!s_demos.list.numitems) {\n\t\tstrcpy( s_demos.names, \"No Demos Found.\" );\n\t\ts_demos.list.numitems = 1;\n\n\t\t//degenerate case, not selectable\n\t\ts_demos.go.generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);\n\t}\n\telse if (s_demos.list.numitems > MAX_DEMOS)\n\t\ts_demos.list.numitems = MAX_DEMOS;\n\n\tdemoname = s_demos.names;\n\tfor ( i = 0; i < s_demos.list.numitems; i++ ) {\n\t\ts_demos.list.itemnames[i] = demoname;\n\t\t\n\t\t// strip extension\n\t\tlen = strlen( demoname );\n\t\tif (!Q_stricmp(demoname +  len - 4,\".dm3\"))\n\t\t\tdemoname[len-4] = '\\0';\n\n\t\tQ_strupr(demoname);\n\n\t\tdemoname += len + 1;\n\t}\n\n\tMenu_AddItem( &s_demos.menu, &s_demos.banner );\n\tMenu_AddItem( &s_demos.menu, &s_demos.framel );\n\tMenu_AddItem( &s_demos.menu, &s_demos.framer );\n\tMenu_AddItem( &s_demos.menu, &s_demos.list );\n\tMenu_AddItem( &s_demos.menu, &s_demos.arrows );\n\tMenu_AddItem( &s_demos.menu, &s_demos.left );\n\tMenu_AddItem( &s_demos.menu, &s_demos.right );\n\tMenu_AddItem( &s_demos.menu, &s_demos.back );\n\tMenu_AddItem( &s_demos.menu, &s_demos.go );\n}\n\n/*\n=================\nDemos_Cache\n=================\n*/\nvoid Demos_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( ART_BACK0 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK1 );\n\ttrap_R_RegisterShaderNoMip( ART_GO0 );\n\ttrap_R_RegisterShaderNoMip( ART_GO1 );\n\ttrap_R_RegisterShaderNoMip( ART_FRAMEL );\n\ttrap_R_RegisterShaderNoMip( ART_FRAMER );\n\ttrap_R_RegisterShaderNoMip( ART_ARROWS );\n\ttrap_R_RegisterShaderNoMip( ART_ARROWLEFT );\n\ttrap_R_RegisterShaderNoMip( ART_ARROWRIGHT );\n}\n\n/*\n===============\nUI_DemosMenu\n===============\n*/\nvoid UI_DemosMenu( void ) {\n\tDemos_MenuInit();\n\tUI_PushMenu( &s_demos.menu );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_display.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=======================================================================\n\nDISPLAY OPTIONS MENU\n\n=======================================================================\n*/\n\n#include \"ui_local.h\"\n\n\n#define ART_FRAMEL\t\t\t\"menu/art/frame2_l\"\n#define ART_FRAMER\t\t\t\"menu/art/frame1_r\"\n#define ART_BACK0\t\t\t\"menu/art/back_0\"\n#define ART_BACK1\t\t\t\"menu/art/back_1\"\n\n#define ID_GRAPHICS\t\t\t10\n#define ID_DISPLAY\t\t\t11\n#define ID_SOUND\t\t\t12\n#define ID_NETWORK\t\t\t13\n#define ID_BRIGHTNESS\t\t14\n#define ID_SCREENSIZE\t\t15\n#define ID_BACK\t\t\t\t16\n\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n\n\tmenutext_s\t\tbanner;\n\tmenubitmap_s\tframel;\n\tmenubitmap_s\tframer;\n\n\tmenutext_s\t\tgraphics;\n\tmenutext_s\t\tdisplay;\n\tmenutext_s\t\tsound;\n\tmenutext_s\t\tnetwork;\n\n\tmenuslider_s\tbrightness;\n\tmenuslider_s\tscreensize;\n\n\tmenubitmap_s\tback;\n} displayOptionsInfo_t;\n\nstatic displayOptionsInfo_t\tdisplayOptionsInfo;\n\n\n/*\n=================\nUI_DisplayOptionsMenu_Event\n=================\n*/\nstatic void UI_DisplayOptionsMenu_Event( void* ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tswitch( ((menucommon_s*)ptr)->id ) {\n\tcase ID_GRAPHICS:\n\t\tUI_PopMenu();\n\t\tUI_GraphicsOptionsMenu();\n\t\tbreak;\n\n\tcase ID_DISPLAY:\n\t\tbreak;\n\n\tcase ID_SOUND:\n\t\tUI_PopMenu();\n\t\tUI_SoundOptionsMenu();\n\t\tbreak;\n\n\tcase ID_NETWORK:\n\t\tUI_PopMenu();\n\t\tUI_NetworkOptionsMenu();\n\t\tbreak;\n\n\tcase ID_BRIGHTNESS:\n\t\ttrap_Cvar_SetValue( \"r_gamma\", displayOptionsInfo.brightness.curvalue / 10.0f );\n\t\tbreak;\n\t\n\tcase ID_SCREENSIZE:\n\t\ttrap_Cvar_SetValue( \"cg_viewsize\", displayOptionsInfo.screensize.curvalue * 10 );\n\t\tbreak;\n\n\tcase ID_BACK:\n\t\tUI_PopMenu();\n\t\tbreak;\n\t}\n}\n\n\n/*\n===============\nUI_DisplayOptionsMenu_Init\n===============\n*/\nstatic void UI_DisplayOptionsMenu_Init( void ) {\n\tint\t\ty;\n\n\tmemset( &displayOptionsInfo, 0, sizeof(displayOptionsInfo) );\n\n\tUI_DisplayOptionsMenu_Cache();\n\tdisplayOptionsInfo.menu.wrapAround = qtrue;\n\tdisplayOptionsInfo.menu.fullscreen = qtrue;\n\n\tdisplayOptionsInfo.banner.generic.type\t\t= MTYPE_BTEXT;\n\tdisplayOptionsInfo.banner.generic.flags\t\t= QMF_CENTER_JUSTIFY;\n\tdisplayOptionsInfo.banner.generic.x\t\t\t= 320;\n\tdisplayOptionsInfo.banner.generic.y\t\t\t= 16;\n\tdisplayOptionsInfo.banner.string\t\t\t= \"SYSTEM SETUP\";\n\tdisplayOptionsInfo.banner.color\t\t\t\t= color_white;\n\tdisplayOptionsInfo.banner.style\t\t\t\t= UI_CENTER;\n\n\tdisplayOptionsInfo.framel.generic.type\t\t= MTYPE_BITMAP;\n\tdisplayOptionsInfo.framel.generic.name\t\t= ART_FRAMEL;\n\tdisplayOptionsInfo.framel.generic.flags\t\t= QMF_INACTIVE;\n\tdisplayOptionsInfo.framel.generic.x\t\t\t= 0;  \n\tdisplayOptionsInfo.framel.generic.y\t\t\t= 78;\n\tdisplayOptionsInfo.framel.width\t\t\t\t= 256;\n\tdisplayOptionsInfo.framel.height\t\t\t= 329;\n\n\tdisplayOptionsInfo.framer.generic.type\t\t= MTYPE_BITMAP;\n\tdisplayOptionsInfo.framer.generic.name\t\t= ART_FRAMER;\n\tdisplayOptionsInfo.framer.generic.flags\t\t= QMF_INACTIVE;\n\tdisplayOptionsInfo.framer.generic.x\t\t\t= 376;\n\tdisplayOptionsInfo.framer.generic.y\t\t\t= 76;\n\tdisplayOptionsInfo.framer.width\t\t\t\t= 256;\n\tdisplayOptionsInfo.framer.height\t\t\t= 334;\n\n\tdisplayOptionsInfo.graphics.generic.type\t\t= MTYPE_PTEXT;\n\tdisplayOptionsInfo.graphics.generic.flags\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tdisplayOptionsInfo.graphics.generic.id\t\t\t= ID_GRAPHICS;\n\tdisplayOptionsInfo.graphics.generic.callback\t= UI_DisplayOptionsMenu_Event;\n\tdisplayOptionsInfo.graphics.generic.x\t\t\t= 216;\n\tdisplayOptionsInfo.graphics.generic.y\t\t\t= 240 - 2 * PROP_HEIGHT;\n\tdisplayOptionsInfo.graphics.string\t\t\t\t= \"GRAPHICS\";\n\tdisplayOptionsInfo.graphics.style\t\t\t\t= UI_RIGHT;\n\tdisplayOptionsInfo.graphics.color\t\t\t\t= color_red;\n\n\tdisplayOptionsInfo.display.generic.type\t\t\t= MTYPE_PTEXT;\n\tdisplayOptionsInfo.display.generic.flags\t\t= QMF_RIGHT_JUSTIFY;\n\tdisplayOptionsInfo.display.generic.id\t\t\t= ID_DISPLAY;\n\tdisplayOptionsInfo.display.generic.callback\t\t= UI_DisplayOptionsMenu_Event;\n\tdisplayOptionsInfo.display.generic.x\t\t\t= 216;\n\tdisplayOptionsInfo.display.generic.y\t\t\t= 240 - PROP_HEIGHT;\n\tdisplayOptionsInfo.display.string\t\t\t\t= \"DISPLAY\";\n\tdisplayOptionsInfo.display.style\t\t\t\t= UI_RIGHT;\n\tdisplayOptionsInfo.display.color\t\t\t\t= color_red;\n\n\tdisplayOptionsInfo.sound.generic.type\t\t\t= MTYPE_PTEXT;\n\tdisplayOptionsInfo.sound.generic.flags\t\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tdisplayOptionsInfo.sound.generic.id\t\t\t\t= ID_SOUND;\n\tdisplayOptionsInfo.sound.generic.callback\t\t= UI_DisplayOptionsMenu_Event;\n\tdisplayOptionsInfo.sound.generic.x\t\t\t\t= 216;\n\tdisplayOptionsInfo.sound.generic.y\t\t\t\t= 240;\n\tdisplayOptionsInfo.sound.string\t\t\t\t\t= \"SOUND\";\n\tdisplayOptionsInfo.sound.style\t\t\t\t\t= UI_RIGHT;\n\tdisplayOptionsInfo.sound.color\t\t\t\t\t= color_red;\n\n\tdisplayOptionsInfo.network.generic.type\t\t\t= MTYPE_PTEXT;\n\tdisplayOptionsInfo.network.generic.flags\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tdisplayOptionsInfo.network.generic.id\t\t\t= ID_NETWORK;\n\tdisplayOptionsInfo.network.generic.callback\t\t= UI_DisplayOptionsMenu_Event;\n\tdisplayOptionsInfo.network.generic.x\t\t\t= 216;\n\tdisplayOptionsInfo.network.generic.y\t\t\t= 240 + PROP_HEIGHT;\n\tdisplayOptionsInfo.network.string\t\t\t\t= \"NETWORK\";\n\tdisplayOptionsInfo.network.style\t\t\t\t= UI_RIGHT;\n\tdisplayOptionsInfo.network.color\t\t\t\t= color_red;\n\n\ty = 240 - 1 * (BIGCHAR_HEIGHT+2);\n\tdisplayOptionsInfo.brightness.generic.type\t\t= MTYPE_SLIDER;\n\tdisplayOptionsInfo.brightness.generic.name\t\t= \"Brightness:\";\n\tdisplayOptionsInfo.brightness.generic.flags\t\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\tdisplayOptionsInfo.brightness.generic.callback\t= UI_DisplayOptionsMenu_Event;\n\tdisplayOptionsInfo.brightness.generic.id\t\t= ID_BRIGHTNESS;\n\tdisplayOptionsInfo.brightness.generic.x\t\t\t= 400;\n\tdisplayOptionsInfo.brightness.generic.y\t\t\t= y;\n\tdisplayOptionsInfo.brightness.minvalue\t\t\t= 5;\n\tdisplayOptionsInfo.brightness.maxvalue\t\t\t= 20;\n\tif( !uis.glconfig.deviceSupportsGamma ) {\n\t\tdisplayOptionsInfo.brightness.generic.flags |= QMF_GRAYED;\n\t}\n\n\ty += BIGCHAR_HEIGHT+2;\n\tdisplayOptionsInfo.screensize.generic.type\t\t= MTYPE_SLIDER;\n\tdisplayOptionsInfo.screensize.generic.name\t\t= \"Screen Size:\";\n\tdisplayOptionsInfo.screensize.generic.flags\t\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\tdisplayOptionsInfo.screensize.generic.callback\t= UI_DisplayOptionsMenu_Event;\n\tdisplayOptionsInfo.screensize.generic.id\t\t= ID_SCREENSIZE;\n\tdisplayOptionsInfo.screensize.generic.x\t\t\t= 400;\n\tdisplayOptionsInfo.screensize.generic.y\t\t\t= y;\n\tdisplayOptionsInfo.screensize.minvalue\t\t\t= 3;\n    displayOptionsInfo.screensize.maxvalue\t\t\t= 10;\n\n\tdisplayOptionsInfo.back.generic.type\t\t= MTYPE_BITMAP;\n\tdisplayOptionsInfo.back.generic.name\t\t= ART_BACK0;\n\tdisplayOptionsInfo.back.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tdisplayOptionsInfo.back.generic.callback\t= UI_DisplayOptionsMenu_Event;\n\tdisplayOptionsInfo.back.generic.id\t\t\t= ID_BACK;\n\tdisplayOptionsInfo.back.generic.x\t\t\t= 0;\n\tdisplayOptionsInfo.back.generic.y\t\t\t= 480-64;\n\tdisplayOptionsInfo.back.width\t\t\t\t= 128;\n\tdisplayOptionsInfo.back.height\t\t\t\t= 64;\n\tdisplayOptionsInfo.back.focuspic\t\t\t= ART_BACK1;\n\n\tMenu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.banner );\n\tMenu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.framel );\n\tMenu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.framer );\n\tMenu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.graphics );\n\tMenu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.display );\n\tMenu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.sound );\n\tMenu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.network );\n\tMenu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.brightness );\n\tMenu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.screensize );\n\tMenu_AddItem( &displayOptionsInfo.menu, ( void * ) &displayOptionsInfo.back );\n\n\tdisplayOptionsInfo.brightness.curvalue  = trap_Cvar_VariableValue(\"r_gamma\") * 10;\n\tdisplayOptionsInfo.screensize.curvalue  = trap_Cvar_VariableValue( \"cg_viewsize\")/10;\n}\n\n\n/*\n===============\nUI_DisplayOptionsMenu_Cache\n===============\n*/\nvoid UI_DisplayOptionsMenu_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( ART_FRAMEL );\n\ttrap_R_RegisterShaderNoMip( ART_FRAMER );\n\ttrap_R_RegisterShaderNoMip( ART_BACK0 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK1 );\n}\n\n\n/*\n===============\nUI_DisplayOptionsMenu\n===============\n*/\nvoid UI_DisplayOptionsMenu( void ) {\n\tUI_DisplayOptionsMenu_Init();\n\tUI_PushMenu( &displayOptionsInfo.menu );\n\tMenu_SetCursorToItem( &displayOptionsInfo.menu, &displayOptionsInfo.display );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_gameinfo.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n//\n// gameinfo.c\n//\n\n#include \"ui_local.h\"\n\n\n//\n// arena and bot info\n//\n\n#define POOLSIZE\t128 * 1024\n\nint\t\t\t\tui_numBots;\nstatic char\t\t*ui_botInfos[MAX_BOTS];\n\nstatic int\t\tui_numArenas;\nstatic char\t\t*ui_arenaInfos[MAX_ARENAS];\n\nstatic int\t\tui_numSinglePlayerArenas;\nstatic int\t\tui_numSpecialSinglePlayerArenas;\n\nstatic char\t\tmemoryPool[POOLSIZE];\nstatic int\t\tallocPoint, outOfMemory;\n\n\n/*\n===============\nUI_Alloc\n===============\n*/\nvoid *UI_Alloc( int size ) {\n\tchar\t*p;\n\n\tif ( allocPoint + size > POOLSIZE ) {\n\t\toutOfMemory = qtrue;\n\t\treturn NULL;\n\t}\n\n\tp = &memoryPool[allocPoint];\n\n\tallocPoint += ( size + 31 ) & ~31;\n\n\treturn p;\n}\n\n/*\n===============\nUI_InitMemory\n===============\n*/\nvoid UI_InitMemory( void ) {\n\tallocPoint = 0;\n\toutOfMemory = qfalse;\n}\n\n/*\n===============\nUI_ParseInfos\n===============\n*/\nint UI_ParseInfos( char *buf, int max, char *infos[] ) {\n\tchar\t*token;\n\tint\t\tcount;\n\tchar\tkey[MAX_TOKEN_CHARS];\n\tchar\tinfo[MAX_INFO_STRING];\n\n\tcount = 0;\n\n\twhile ( 1 ) {\n\t\ttoken = COM_Parse( &buf );\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( strcmp( token, \"{\" ) ) {\n\t\t\tCom_Printf( \"Missing { in info file\\n\" );\n\t\t\tbreak;\n\t\t}\n\n\t\tif ( count == max ) {\n\t\t\tCom_Printf( \"Max infos exceeded\\n\" );\n\t\t\tbreak;\n\t\t}\n\n\t\tinfo[0] = '\\0';\n\t\twhile ( 1 ) {\n\t\t\ttoken = COM_ParseExt( &buf, qtrue );\n\t\t\tif ( !token[0] ) {\n\t\t\t\tCom_Printf( \"Unexpected end of info file\\n\" );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( !strcmp( token, \"}\" ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tQ_strncpyz( key, token, sizeof( key ) );\n\n\t\t\ttoken = COM_ParseExt( &buf, qfalse );\n\t\t\tif ( !token[0] ) {\n\t\t\t\tstrcpy( token, \"<NULL>\" );\n\t\t\t}\n\t\t\tInfo_SetValueForKey( info, key, token );\n\t\t}\n\t\t//NOTE: extra space for arena number\n\t\tinfos[count] = UI_Alloc(strlen(info) + strlen(\"\\\\num\\\\\") + strlen(va(\"%d\", MAX_ARENAS)) + 1);\n\t\tif (infos[count]) {\n\t\t\tstrcpy(infos[count], info);\n\t\t\tcount++;\n\t\t}\n\t}\n\treturn count;\n}\n\n/*\n===============\nUI_LoadArenasFromFile\n===============\n*/\nstatic void UI_LoadArenasFromFile( char *filename ) {\n\tint\t\t\t\tlen;\n\tfileHandle_t\tf;\n\tchar\t\t\tbuf[MAX_ARENAS_TEXT];\n\n\tlen = trap_FS_FOpenFile( filename, &f, FS_READ );\n\tif ( !f ) {\n\t\ttrap_Print( va( S_COLOR_RED \"file not found: %s\\n\", filename ) );\n\t\treturn;\n\t}\n\tif ( len >= MAX_ARENAS_TEXT ) {\n\t\ttrap_Print( va( S_COLOR_RED \"file too large: %s is %i, max allowed is %i\", filename, len, MAX_ARENAS_TEXT ) );\n\t\ttrap_FS_FCloseFile( f );\n\t\treturn;\n\t}\n\n\ttrap_FS_Read( buf, len, f );\n\tbuf[len] = 0;\n\ttrap_FS_FCloseFile( f );\n\n\tui_numArenas += UI_ParseInfos( buf, MAX_ARENAS - ui_numArenas, &ui_arenaInfos[ui_numArenas] );\n}\n\n/*\n===============\nUI_LoadArenas\n===============\n*/\nstatic void UI_LoadArenas( void ) {\n\tint\t\t\tnumdirs;\n\tvmCvar_t\tarenasFile;\n\tchar\t\tfilename[128];\n\tchar\t\tdirlist[1024];\n\tchar*\t\tdirptr;\n\tint\t\t\ti, n;\n\tint\t\t\tdirlen;\n\tchar\t\t*type;\n\tchar\t\t*tag;\n\tint\t\t\tsinglePlayerNum, specialNum, otherNum;\n\n\tui_numArenas = 0;\n\n\ttrap_Cvar_Register( &arenasFile, \"g_arenasFile\", \"\", CVAR_INIT|CVAR_ROM );\n\tif( *arenasFile.string ) {\n\t\tUI_LoadArenasFromFile(arenasFile.string);\n\t}\n\telse {\n\t\tUI_LoadArenasFromFile(\"scripts/arenas.txt\");\n\t}\n\n\t// get all arenas from .arena files\n\tnumdirs = trap_FS_GetFileList(\"scripts\", \".arena\", dirlist, 1024 );\n\tdirptr  = dirlist;\n\tfor (i = 0; i < numdirs; i++, dirptr += dirlen+1) {\n\t\tdirlen = strlen(dirptr);\n\t\tstrcpy(filename, \"scripts/\");\n\t\tstrcat(filename, dirptr);\n\t\tUI_LoadArenasFromFile(filename);\n\t}\n\ttrap_Print( va( \"%i arenas parsed\\n\", ui_numArenas ) );\n\tif (outOfMemory) trap_Print(S_COLOR_YELLOW\"WARNING: not anough memory in pool to load all arenas\\n\");\n\n\t// set initial numbers\n\tfor( n = 0; n < ui_numArenas; n++ ) {\n\t\tInfo_SetValueForKey( ui_arenaInfos[n], \"num\", va( \"%i\", n ) );\n\t}\n\n\t// go through and count single players levels\n\tui_numSinglePlayerArenas = 0;\n\tui_numSpecialSinglePlayerArenas = 0;\n\tfor( n = 0; n < ui_numArenas; n++ ) {\n\t\t// determine type\n\t\ttype = Info_ValueForKey( ui_arenaInfos[n], \"type\" );\n\n\t\t// if no type specified, it will be treated as \"ffa\"\n\t\tif( !*type ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif( strstr( type, \"single\" ) ) {\n\t\t\t// check for special single player arenas (training, final)\n\t\t\ttag = Info_ValueForKey( ui_arenaInfos[n], \"special\" );\n\t\t\tif( *tag ) {\n\t\t\t\tui_numSpecialSinglePlayerArenas++;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tui_numSinglePlayerArenas++;\n\t\t}\n\t}\n\n\tn = ui_numSinglePlayerArenas % ARENAS_PER_TIER;\n\tif( n != 0 ) {\n\t\tui_numSinglePlayerArenas -= n;\n\t\ttrap_Print( va( \"%i arenas ignored to make count divisible by %i\\n\", n, ARENAS_PER_TIER ) );\n\t}\n\n\t// go through once more and assign number to the levels\n\tsinglePlayerNum = 0;\n\tspecialNum = singlePlayerNum + ui_numSinglePlayerArenas;\n\totherNum = specialNum + ui_numSpecialSinglePlayerArenas;\n\tfor( n = 0; n < ui_numArenas; n++ ) {\n\t\t// determine type\n\t\ttype = Info_ValueForKey( ui_arenaInfos[n], \"type\" );\n\n\t\t// if no type specified, it will be treated as \"ffa\"\n\t\tif( *type ) {\n\t\t\tif( strstr( type, \"single\" ) ) {\n\t\t\t\t// check for special single player arenas (training, final)\n\t\t\t\ttag = Info_ValueForKey( ui_arenaInfos[n], \"special\" );\n\t\t\t\tif( *tag ) {\n\t\t\t\t\tInfo_SetValueForKey( ui_arenaInfos[n], \"num\", va( \"%i\", specialNum++ ) );\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tInfo_SetValueForKey( ui_arenaInfos[n], \"num\", va( \"%i\", singlePlayerNum++ ) );\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tInfo_SetValueForKey( ui_arenaInfos[n], \"num\", va( \"%i\", otherNum++ ) );\n\t}\n}\n\n/*\n===============\nUI_GetArenaInfoByNumber\n===============\n*/\nconst char *UI_GetArenaInfoByNumber( int num ) {\n\tint\t\tn;\n\tchar\t*value;\n\n\tif( num < 0 || num >= ui_numArenas ) {\n\t\ttrap_Print( va( S_COLOR_RED \"Invalid arena number: %i\\n\", num ) );\n\t\treturn NULL;\n\t}\n\n\tfor( n = 0; n < ui_numArenas; n++ ) {\n\t\tvalue = Info_ValueForKey( ui_arenaInfos[n], \"num\" );\n\t\tif( *value && atoi(value) == num ) {\n\t\t\treturn ui_arenaInfos[n];\n\t\t}\n\t}\n\n\treturn NULL;\n}\n\n\n/*\n===============\nUI_GetArenaInfoByNumber\n===============\n*/\nconst char *UI_GetArenaInfoByMap( const char *map ) {\n\tint\t\t\tn;\n\n\tfor( n = 0; n < ui_numArenas; n++ ) {\n\t\tif( Q_stricmp( Info_ValueForKey( ui_arenaInfos[n], \"map\" ), map ) == 0 ) {\n\t\t\treturn ui_arenaInfos[n];\n\t\t}\n\t}\n\n\treturn NULL;\n}\n\n\n/*\n===============\nUI_GetSpecialArenaInfo\n===============\n*/\nconst char *UI_GetSpecialArenaInfo( const char *tag ) {\n\tint\t\t\tn;\n\n\tfor( n = 0; n < ui_numArenas; n++ ) {\n\t\tif( Q_stricmp( Info_ValueForKey( ui_arenaInfos[n], \"special\" ), tag ) == 0 ) {\n\t\t\treturn ui_arenaInfos[n];\n\t\t}\n\t}\n\n\treturn NULL;\n}\n\n/*\n===============\nUI_LoadBotsFromFile\n===============\n*/\nstatic void UI_LoadBotsFromFile( char *filename ) {\n\tint\t\t\t\tlen;\n\tfileHandle_t\tf;\n\tchar\t\t\tbuf[MAX_BOTS_TEXT];\n\n\tlen = trap_FS_FOpenFile( filename, &f, FS_READ );\n\tif ( !f ) {\n\t\ttrap_Print( va( S_COLOR_RED \"file not found: %s\\n\", filename ) );\n\t\treturn;\n\t}\n\tif ( len >= MAX_BOTS_TEXT ) {\n\t\ttrap_Print( va( S_COLOR_RED \"file too large: %s is %i, max allowed is %i\", filename, len, MAX_BOTS_TEXT ) );\n\t\ttrap_FS_FCloseFile( f );\n\t\treturn;\n\t}\n\n\ttrap_FS_Read( buf, len, f );\n\tbuf[len] = 0;\n\ttrap_FS_FCloseFile( f );\n\n\tui_numBots += UI_ParseInfos( buf, MAX_BOTS - ui_numBots, &ui_botInfos[ui_numBots] );\n\tif (outOfMemory) trap_Print(S_COLOR_YELLOW\"WARNING: not anough memory in pool to load all bots\\n\");\n}\n\n/*\n===============\nUI_LoadBots\n===============\n*/\nstatic void UI_LoadBots( void ) {\n\tvmCvar_t\tbotsFile;\n\tint\t\t\tnumdirs;\n\tchar\t\tfilename[128];\n\tchar\t\tdirlist[1024];\n\tchar*\t\tdirptr;\n\tint\t\t\ti;\n\tint\t\t\tdirlen;\n\n\tui_numBots = 0;\n\n\ttrap_Cvar_Register( &botsFile, \"g_botsFile\", \"\", CVAR_INIT|CVAR_ROM );\n\tif( *botsFile.string ) {\n\t\tUI_LoadBotsFromFile(botsFile.string);\n\t}\n\telse {\n\t\tUI_LoadBotsFromFile(\"scripts/bots.txt\");\n\t}\n\n\t// get all bots from .bot files\n\tnumdirs = trap_FS_GetFileList(\"scripts\", \".bot\", dirlist, 1024 );\n\tdirptr  = dirlist;\n\tfor (i = 0; i < numdirs; i++, dirptr += dirlen+1) {\n\t\tdirlen = strlen(dirptr);\n\t\tstrcpy(filename, \"scripts/\");\n\t\tstrcat(filename, dirptr);\n\t\tUI_LoadBotsFromFile(filename);\n\t}\n\ttrap_Print( va( \"%i bots parsed\\n\", ui_numBots ) );\n}\n\n\n/*\n===============\nUI_GetBotInfoByNumber\n===============\n*/\nchar *UI_GetBotInfoByNumber( int num ) {\n\tif( num < 0 || num >= ui_numBots ) {\n\t\ttrap_Print( va( S_COLOR_RED \"Invalid bot number: %i\\n\", num ) );\n\t\treturn NULL;\n\t}\n\treturn ui_botInfos[num];\n}\n\n\n/*\n===============\nUI_GetBotInfoByName\n===============\n*/\nchar *UI_GetBotInfoByName( const char *name ) {\n\tint\t\tn;\n\tchar\t*value;\n\n\tfor ( n = 0; n < ui_numBots ; n++ ) {\n\t\tvalue = Info_ValueForKey( ui_botInfos[n], \"name\" );\n\t\tif ( !Q_stricmp( value, name ) ) {\n\t\t\treturn ui_botInfos[n];\n\t\t}\n\t}\n\n\treturn NULL;\n}\n\n\n//\n// single player game info\n//\n\n/*\n===============\nUI_GetBestScore\n\nReturns the player's best finish on a given level, 0 if the have not played the level\n===============\n*/\nvoid UI_GetBestScore( int level, int *score, int *skill ) {\n\tint\t\tn;\n\tint\t\tskillScore;\n\tint\t\tbestScore;\n\tint\t\tbestScoreSkill;\n\tchar\tarenaKey[16];\n\tchar\tscores[MAX_INFO_VALUE];\n\n\tif( !score || !skill ) {\n\t\treturn;\n\t}\n\n\tif( level < 0 || level > ui_numArenas ) {\n\t\treturn;\n\t}\n\n\tbestScore = 0;\n\tbestScoreSkill = 0;\n\n\tfor( n = 1; n <= 5; n++ ) {\n\t\ttrap_Cvar_VariableStringBuffer( va( \"g_spScores%i\", n ), scores, MAX_INFO_VALUE );\n\n\t\tCom_sprintf( arenaKey, sizeof( arenaKey ), \"l%i\", level );\n\t\tskillScore = atoi( Info_ValueForKey( scores, arenaKey ) );\n\n\t\tif( skillScore < 1 || skillScore > 8 ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif( !bestScore || skillScore <= bestScore ) {\n\t\t\tbestScore = skillScore;\n\t\t\tbestScoreSkill = n;\n\t\t}\n\t}\n\n\t*score = bestScore;\n\t*skill = bestScoreSkill;\n}\n\n\n/*\n===============\nUI_SetBestScore\n\nSet the player's best finish for a level\n===============\n*/\nvoid UI_SetBestScore( int level, int score ) {\n\tint\t\tskill;\n\tint\t\toldScore;\n\tchar\tarenaKey[16];\n\tchar\tscores[MAX_INFO_VALUE];\n\n\t// validate score\n\tif( score < 1 || score > 8 ) {\n\t\treturn;\n\t}\n\n\t// validate skill\n\tskill = (int)trap_Cvar_VariableValue( \"g_spSkill\" );\n\tif( skill < 1 || skill > 5 ) {\n\t\treturn;\n\t}\n\n\t// get scores\n\ttrap_Cvar_VariableStringBuffer( va( \"g_spScores%i\", skill ), scores, MAX_INFO_VALUE );\n\n\t// see if this is better\n\tCom_sprintf( arenaKey, sizeof( arenaKey ), \"l%i\", level );\n\toldScore = atoi( Info_ValueForKey( scores, arenaKey ) );\n\tif( oldScore && oldScore <= score ) {\n\t\treturn;\n\t}\n\n\t// update scores\n\tInfo_SetValueForKey( scores, arenaKey, va( \"%i\", score ) );\n\ttrap_Cvar_Set( va( \"g_spScores%i\", skill ), scores );\n}\n\n\n/*\n===============\nUI_LogAwardData\n===============\n*/\nvoid UI_LogAwardData( int award, int data ) {\n\tchar\tkey[16];\n\tchar\tawardData[MAX_INFO_VALUE];\n\tint\t\toldValue;\n\n\tif( data == 0 ) {\n\t\treturn;\n\t}\n\n\tif( award > AWARD_PERFECT ) {\n\t\ttrap_Print( va( S_COLOR_RED \"Bad award %i in UI_LogAwardData\\n\", award ) );\n\t\treturn;\n\t}\n\n\ttrap_Cvar_VariableStringBuffer( \"g_spAwards\", awardData, sizeof(awardData) );\n\n\tCom_sprintf( key, sizeof(key), \"a%i\", award );\n\toldValue = atoi( Info_ValueForKey( awardData, key ) );\n\n\tInfo_SetValueForKey( awardData, key, va( \"%i\", oldValue + data ) );\n\ttrap_Cvar_Set( \"g_spAwards\", awardData );\n}\n\n\n/*\n===============\nUI_GetAwardLevel\n===============\n*/\nint UI_GetAwardLevel( int award ) {\n\tchar\tkey[16];\n\tchar\tawardData[MAX_INFO_VALUE];\n\n\ttrap_Cvar_VariableStringBuffer( \"g_spAwards\", awardData, sizeof(awardData) );\n\n\tCom_sprintf( key, sizeof(key), \"a%i\", award );\n\treturn atoi( Info_ValueForKey( awardData, key ) );\n}\n\n\n/*\n===============\nUI_TierCompleted\n===============\n*/\nint UI_TierCompleted( int levelWon ) {\n\tint\t\t\tlevel;\n\tint\t\t\tn;\n\tint\t\t\ttier;\n\tint\t\t\tscore;\n\tint\t\t\tskill;\n\tconst char\t*info;\n\n\ttier = levelWon / ARENAS_PER_TIER;\n\tlevel = tier * ARENAS_PER_TIER;\n\n\tif( tier == UI_GetNumSPTiers() ) {\n\t\tinfo = UI_GetSpecialArenaInfo( \"training\" );\n\t\tif( levelWon == atoi( Info_ValueForKey( info, \"num\" ) ) ) {\n\t\t\treturn 0;\n\t\t}\n\t\tinfo = UI_GetSpecialArenaInfo( \"final\" );\n\t\tif( !info || levelWon == atoi( Info_ValueForKey( info, \"num\" ) ) ) {\n\t\t\treturn tier + 1;\n\t\t}\n\t\treturn -1;\n\t}\n\n\tfor( n = 0; n < ARENAS_PER_TIER; n++, level++ ) {\n\t\tUI_GetBestScore( level, &score, &skill );\n\t\tif ( score != 1 ) {\n\t\t\treturn -1;\n\t\t}\n\t}\n\treturn tier + 1;\n}\n\n\n/*\n===============\nUI_ShowTierVideo\n===============\n*/\nqboolean UI_ShowTierVideo( int tier ) {\n\tchar\tkey[16];\n\tchar\tvideos[MAX_INFO_VALUE];\n\n\tif( tier <= 0 ) {\n\t\treturn qfalse;\n\t}\n\n\ttrap_Cvar_VariableStringBuffer( \"g_spVideos\", videos, sizeof(videos) );\n\n\tCom_sprintf( key, sizeof(key), \"tier%i\", tier );\n\tif( atoi( Info_ValueForKey( videos, key ) ) ) {\n\t\treturn qfalse;\n\t}\n\n\tInfo_SetValueForKey( videos, key, va( \"%i\", 1 ) );\n\ttrap_Cvar_Set( \"g_spVideos\", videos );\n\n\treturn qtrue;\n}\n\n\n/*\n===============\nUI_CanShowTierVideo\n===============\n*/\nqboolean UI_CanShowTierVideo( int tier ) {\n\tchar\tkey[16];\n\tchar\tvideos[MAX_INFO_VALUE];\n\n\tif( !tier ) {\n\t\treturn qfalse;\n\t}\n\n\tif( uis.demoversion && tier != 8 ) {\n\t\treturn qfalse;\n\t}\n\n\ttrap_Cvar_VariableStringBuffer( \"g_spVideos\", videos, sizeof(videos) );\n\n\tCom_sprintf( key, sizeof(key), \"tier%i\", tier );\n\tif( atoi( Info_ValueForKey( videos, key ) ) ) {\n\t\treturn qtrue;\n\t}\n\n\treturn qfalse;\n}\n\n\n/*\n===============\nUI_GetCurrentGame\n\nReturns the next level the player has not won\n===============\n*/\nint UI_GetCurrentGame( void ) {\n\tint\t\tlevel;\n\tint\t\trank;\n\tint\t\tskill;\n\tconst char *info;\n\n\tinfo = UI_GetSpecialArenaInfo( \"training\" );\n\tif( info ) {\n\t\tlevel = atoi( Info_ValueForKey( info, \"num\" ) );\n\t\tUI_GetBestScore( level, &rank, &skill );\n\t\tif ( !rank || rank > 1 ) {\n\t\t\treturn level;\n\t\t}\n\t}\n\n\tfor( level = 0; level < ui_numSinglePlayerArenas; level++ ) {\n\t\tUI_GetBestScore( level, &rank, &skill );\n\t\tif ( !rank || rank > 1 ) {\n\t\t\treturn level;\n\t\t}\n\t}\n\n\tinfo = UI_GetSpecialArenaInfo( \"final\" );\n\tif( !info ) {\n\t\treturn -1;\n\t}\n\treturn atoi( Info_ValueForKey( info, \"num\" ) );\n}\n\n\n/*\n===============\nUI_NewGame\n\nClears the scores and sets the difficutly level\n===============\n*/\nvoid UI_NewGame( void ) {\n\ttrap_Cvar_Set( \"g_spScores1\", \"\" );\n\ttrap_Cvar_Set( \"g_spScores2\", \"\" );\n\ttrap_Cvar_Set( \"g_spScores3\", \"\" );\n\ttrap_Cvar_Set( \"g_spScores4\", \"\" );\n\ttrap_Cvar_Set( \"g_spScores5\", \"\" );\n\ttrap_Cvar_Set( \"g_spAwards\", \"\" );\n\ttrap_Cvar_Set( \"g_spVideos\", \"\" );\n}\n\n\n/*\n===============\nUI_GetNumArenas\n===============\n*/\nint UI_GetNumArenas( void ) {\n\treturn ui_numArenas;\n}\n\n\n/*\n===============\nUI_GetNumSPArenas\n===============\n*/\nint UI_GetNumSPArenas( void ) {\n\treturn ui_numSinglePlayerArenas;\n}\n\n\n/*\n===============\nUI_GetNumSPTiers\n===============\n*/\nint UI_GetNumSPTiers( void ) {\n\treturn ui_numSinglePlayerArenas / ARENAS_PER_TIER;\n}\n\n\n/*\n===============\nUI_GetNumBots\n===============\n*/\nint UI_GetNumBots( void ) {\n\treturn ui_numBots;\n}\n\n\n/*\n===============\nUI_SPUnlock_f\n===============\n*/\nvoid UI_SPUnlock_f( void ) {\n\tchar\tarenaKey[16];\n\tchar\tscores[MAX_INFO_VALUE];\n\tint\t\tlevel;\n\tint\t\ttier;\n\n\t// get scores for skill 1\n\ttrap_Cvar_VariableStringBuffer( \"g_spScores1\", scores, MAX_INFO_VALUE );\n\n\t// update scores\n\tfor( level = 0; level < ui_numSinglePlayerArenas + ui_numSpecialSinglePlayerArenas; level++ ) {\n\t\tCom_sprintf( arenaKey, sizeof( arenaKey ), \"l%i\", level );\n\t\tInfo_SetValueForKey( scores, arenaKey, \"1\" );\n\t}\n\ttrap_Cvar_Set( \"g_spScores1\", scores );\n\n\t// unlock cinematics\n\tfor( tier = 1; tier <= 8; tier++ ) {\n\t\tUI_ShowTierVideo( tier );\n\t}\n\n\ttrap_Print( \"All levels unlocked at skill level 1\\n\" );\n\n\tUI_SPLevelMenu_ReInit();\n}\n\n\n/*\n===============\nUI_SPUnlockMedals_f\n===============\n*/\nvoid UI_SPUnlockMedals_f( void ) {\n\tint\t\tn;\n\tchar\tkey[16];\n\tchar\tawardData[MAX_INFO_VALUE];\n\n\ttrap_Cvar_VariableStringBuffer( \"g_spAwards\", awardData, MAX_INFO_VALUE );\n\n\tfor( n = 0; n < 6; n++ ) {\n\t\tCom_sprintf( key, sizeof(key), \"a%i\", n );\n\t\tInfo_SetValueForKey( awardData, key, \"100\" );\n\t}\n\n\ttrap_Cvar_Set( \"g_spAwards\", awardData );\n\n\ttrap_Print( \"All levels unlocked at 100\\n\" );\n}\n\n\n/*\n===============\nUI_InitGameinfo\n===============\n*/\nvoid UI_InitGameinfo( void ) {\n\n\tUI_InitMemory();\n\tUI_LoadArenas();\n\tUI_LoadBots();\n\n\tif( (trap_Cvar_VariableValue( \"fs_restrict\" )) || (ui_numSpecialSinglePlayerArenas == 0 && ui_numSinglePlayerArenas == 4) ) {\n\t\tuis.demoversion = qtrue;\n\t}\n\telse {\n\t\tuis.demoversion = qfalse;\n\t}\n}\n"
  },
  {
    "path": "code/q3_ui/ui_ingame.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=======================================================================\n\nINGAME MENU\n\n=======================================================================\n*/\n\n\n#include \"ui_local.h\"\n\n\n#define INGAME_FRAME\t\t\t\t\t\"menu/art/addbotframe\"\n//#define INGAME_FRAME\t\t\t\t\t\"menu/art/cut_frame\"\n#define INGAME_MENU_VERTICAL_SPACING\t28\n\n#define ID_TEAM\t\t\t\t\t10\n#define ID_ADDBOTS\t\t\t\t11\n#define ID_REMOVEBOTS\t\t\t12\n#define ID_SETUP\t\t\t\t13\n#define ID_SERVERINFO\t\t\t14\n#define ID_LEAVEARENA\t\t\t15\n#define ID_RESTART\t\t\t\t16\n#define ID_QUIT\t\t\t\t\t17\n#define ID_RESUME\t\t\t\t18\n#define ID_TEAMORDERS\t\t\t19\n\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n\n\tmenubitmap_s\tframe;\n\tmenutext_s\t\tteam;\n\tmenutext_s\t\tsetup;\n\tmenutext_s\t\tserver;\n\tmenutext_s\t\tleave;\n\tmenutext_s\t\trestart;\n\tmenutext_s\t\taddbots;\n\tmenutext_s\t\tremovebots;\n\tmenutext_s\t\tteamorders;\n\tmenutext_s\t\tquit;\n\tmenutext_s\t\tresume;\n} ingamemenu_t;\n\nstatic ingamemenu_t\ts_ingame;\n\n\n/*\n=================\nInGame_RestartAction\n=================\n*/\nstatic void InGame_RestartAction( qboolean result ) {\n\tif( !result ) {\n\t\treturn;\n\t}\n\n\tUI_PopMenu();\n\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"map_restart 0\\n\" );\n}\n\n\n/*\n=================\nInGame_QuitAction\n=================\n*/\nstatic void InGame_QuitAction( qboolean result ) {\n\tif( !result ) {\n\t\treturn;\n\t}\n\tUI_PopMenu();\n\tUI_CreditMenu();\n}\n\n\n/*\n=================\nInGame_Event\n=================\n*/\nvoid InGame_Event( void *ptr, int notification ) {\n\tif( notification != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tswitch( ((menucommon_s*)ptr)->id ) {\n\tcase ID_TEAM:\n\t\tUI_TeamMainMenu();\n\t\tbreak;\n\n\tcase ID_SETUP:\n\t\tUI_SetupMenu();\n\t\tbreak;\n\n\tcase ID_LEAVEARENA:\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"disconnect\\n\" );\n\t\tbreak;\n\n\tcase ID_RESTART:\n\t\tUI_ConfirmMenu( \"RESTART ARENA?\", (voidfunc_f)NULL, InGame_RestartAction );\n\t\tbreak;\n\n\tcase ID_QUIT:\n\t\tUI_ConfirmMenu( \"EXIT GAME?\",  (voidfunc_f)NULL, InGame_QuitAction );\n\t\tbreak;\n\n\tcase ID_SERVERINFO:\n\t\tUI_ServerInfoMenu();\n\t\tbreak;\n\n\tcase ID_ADDBOTS:\n\t\tUI_AddBotsMenu();\n\t\tbreak;\n\n\tcase ID_REMOVEBOTS:\n\t\tUI_RemoveBotsMenu();\n\t\tbreak;\n\n\tcase ID_TEAMORDERS:\n\t\tUI_TeamOrdersMenu();\n\t\tbreak;\n\n\tcase ID_RESUME:\n\t\tUI_PopMenu();\n\t\tbreak;\n\t}\n}\n\n\n/*\n=================\nInGame_MenuInit\n=================\n*/\nvoid InGame_MenuInit( void ) {\n\tint\t\ty;\n\tuiClientState_t\tcs;\n\tchar\tinfo[MAX_INFO_STRING];\n\tint\t\tteam;\n\n\tmemset( &s_ingame, 0 ,sizeof(ingamemenu_t) );\n\n\tInGame_Cache();\n\n\ts_ingame.menu.wrapAround = qtrue;\n\ts_ingame.menu.fullscreen = qfalse;\n\n\ts_ingame.frame.generic.type\t\t\t= MTYPE_BITMAP;\n\ts_ingame.frame.generic.flags\t\t= QMF_INACTIVE;\n\ts_ingame.frame.generic.name\t\t\t= INGAME_FRAME;\n\ts_ingame.frame.generic.x\t\t\t= 320-233;//142;\n\ts_ingame.frame.generic.y\t\t\t= 240-166;//118;\n\ts_ingame.frame.width\t\t\t\t= 466;//359;\n\ts_ingame.frame.height\t\t\t\t= 332;//256;\n\n\t//y = 96;\n\ty = 88;\n\ts_ingame.team.generic.type\t\t\t= MTYPE_PTEXT;\n\ts_ingame.team.generic.flags\t\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_ingame.team.generic.x\t\t\t\t= 320;\n\ts_ingame.team.generic.y\t\t\t\t= y;\n\ts_ingame.team.generic.id\t\t\t= ID_TEAM;\n\ts_ingame.team.generic.callback\t\t= InGame_Event; \n\ts_ingame.team.string\t\t\t\t= \"START\";\n\ts_ingame.team.color\t\t\t\t\t= color_red;\n\ts_ingame.team.style\t\t\t\t\t= UI_CENTER|UI_SMALLFONT;\n\n\ty += INGAME_MENU_VERTICAL_SPACING;\n\ts_ingame.addbots.generic.type\t\t= MTYPE_PTEXT;\n\ts_ingame.addbots.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_ingame.addbots.generic.x\t\t\t= 320;\n\ts_ingame.addbots.generic.y\t\t\t= y;\n\ts_ingame.addbots.generic.id\t\t\t= ID_ADDBOTS;\n\ts_ingame.addbots.generic.callback\t= InGame_Event; \n\ts_ingame.addbots.string\t\t\t\t= \"ADD BOTS\";\n\ts_ingame.addbots.color\t\t\t\t= color_red;\n\ts_ingame.addbots.style\t\t\t\t= UI_CENTER|UI_SMALLFONT;\n\tif( !trap_Cvar_VariableValue( \"sv_running\" ) || !trap_Cvar_VariableValue( \"bot_enable\" ) || (trap_Cvar_VariableValue( \"g_gametype\" ) == GT_SINGLE_PLAYER)) {\n\t\ts_ingame.addbots.generic.flags |= QMF_GRAYED;\n\t}\n\n\ty += INGAME_MENU_VERTICAL_SPACING;\n\ts_ingame.removebots.generic.type\t\t= MTYPE_PTEXT;\n\ts_ingame.removebots.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_ingame.removebots.generic.x\t\t\t= 320;\n\ts_ingame.removebots.generic.y\t\t\t= y;\n\ts_ingame.removebots.generic.id\t\t\t= ID_REMOVEBOTS;\n\ts_ingame.removebots.generic.callback\t= InGame_Event; \n\ts_ingame.removebots.string\t\t\t\t= \"REMOVE BOTS\";\n\ts_ingame.removebots.color\t\t\t\t= color_red;\n\ts_ingame.removebots.style\t\t\t\t= UI_CENTER|UI_SMALLFONT;\n\tif( !trap_Cvar_VariableValue( \"sv_running\" ) || !trap_Cvar_VariableValue( \"bot_enable\" ) || (trap_Cvar_VariableValue( \"g_gametype\" ) == GT_SINGLE_PLAYER)) {\n\t\ts_ingame.removebots.generic.flags |= QMF_GRAYED;\n\t}\n\n\ty += INGAME_MENU_VERTICAL_SPACING;\n\ts_ingame.teamorders.generic.type\t\t= MTYPE_PTEXT;\n\ts_ingame.teamorders.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_ingame.teamorders.generic.x\t\t\t= 320;\n\ts_ingame.teamorders.generic.y\t\t\t= y;\n\ts_ingame.teamorders.generic.id\t\t\t= ID_TEAMORDERS;\n\ts_ingame.teamorders.generic.callback\t= InGame_Event; \n\ts_ingame.teamorders.string\t\t\t\t= \"TEAM ORDERS\";\n\ts_ingame.teamorders.color\t\t\t\t= color_red;\n\ts_ingame.teamorders.style\t\t\t\t= UI_CENTER|UI_SMALLFONT;\n\tif( !(trap_Cvar_VariableValue( \"g_gametype\" ) >= GT_TEAM) ) {\n\t\ts_ingame.teamorders.generic.flags |= QMF_GRAYED;\n\t}\n\telse {\n\t\ttrap_GetClientState( &cs );\n\t\ttrap_GetConfigString( CS_PLAYERS + cs.clientNum, info, MAX_INFO_STRING );\n\t\tteam = atoi( Info_ValueForKey( info, \"t\" ) );\n\t\tif( team == TEAM_SPECTATOR ) {\n\t\t\ts_ingame.teamorders.generic.flags |= QMF_GRAYED;\n\t\t}\n\t}\n\n\ty += INGAME_MENU_VERTICAL_SPACING;\n\ts_ingame.setup.generic.type\t\t\t= MTYPE_PTEXT;\n\ts_ingame.setup.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_ingame.setup.generic.x\t\t\t= 320;\n\ts_ingame.setup.generic.y\t\t\t= y;\n\ts_ingame.setup.generic.id\t\t\t= ID_SETUP;\n\ts_ingame.setup.generic.callback\t\t= InGame_Event; \n\ts_ingame.setup.string\t\t\t\t= \"SETUP\";\n\ts_ingame.setup.color\t\t\t\t= color_red;\n\ts_ingame.setup.style\t\t\t\t= UI_CENTER|UI_SMALLFONT;\n\n\ty += INGAME_MENU_VERTICAL_SPACING;\n\ts_ingame.server.generic.type\t\t= MTYPE_PTEXT;\n\ts_ingame.server.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_ingame.server.generic.x\t\t\t= 320;\n\ts_ingame.server.generic.y\t\t\t= y;\n\ts_ingame.server.generic.id\t\t\t= ID_SERVERINFO;\n\ts_ingame.server.generic.callback\t= InGame_Event; \n\ts_ingame.server.string\t\t\t\t= \"SERVER INFO\";\n\ts_ingame.server.color\t\t\t\t= color_red;\n\ts_ingame.server.style\t\t\t\t= UI_CENTER|UI_SMALLFONT;\n\n\ty += INGAME_MENU_VERTICAL_SPACING;\n\ts_ingame.restart.generic.type\t\t= MTYPE_PTEXT;\n\ts_ingame.restart.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_ingame.restart.generic.x\t\t\t= 320;\n\ts_ingame.restart.generic.y\t\t\t= y;\n\ts_ingame.restart.generic.id\t\t\t= ID_RESTART;\n\ts_ingame.restart.generic.callback\t= InGame_Event; \n\ts_ingame.restart.string\t\t\t\t= \"RESTART ARENA\";\n\ts_ingame.restart.color\t\t\t\t= color_red;\n\ts_ingame.restart.style\t\t\t\t= UI_CENTER|UI_SMALLFONT;\n\tif( !trap_Cvar_VariableValue( \"sv_running\" ) ) {\n\t\ts_ingame.restart.generic.flags |= QMF_GRAYED;\n\t}\n\n\ty += INGAME_MENU_VERTICAL_SPACING;\n\ts_ingame.resume.generic.type\t\t\t= MTYPE_PTEXT;\n\ts_ingame.resume.generic.flags\t\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_ingame.resume.generic.x\t\t\t\t= 320;\n\ts_ingame.resume.generic.y\t\t\t\t= y;\n\ts_ingame.resume.generic.id\t\t\t\t= ID_RESUME;\n\ts_ingame.resume.generic.callback\t\t= InGame_Event; \n\ts_ingame.resume.string\t\t\t\t\t= \"RESUME GAME\";\n\ts_ingame.resume.color\t\t\t\t\t= color_red;\n\ts_ingame.resume.style\t\t\t\t\t= UI_CENTER|UI_SMALLFONT;\n\n\ty += INGAME_MENU_VERTICAL_SPACING;\n\ts_ingame.leave.generic.type\t\t\t= MTYPE_PTEXT;\n\ts_ingame.leave.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_ingame.leave.generic.x\t\t\t= 320;\n\ts_ingame.leave.generic.y\t\t\t= y;\n\ts_ingame.leave.generic.id\t\t\t= ID_LEAVEARENA;\n\ts_ingame.leave.generic.callback\t\t= InGame_Event; \n\ts_ingame.leave.string\t\t\t\t= \"LEAVE ARENA\";\n\ts_ingame.leave.color\t\t\t\t= color_red;\n\ts_ingame.leave.style\t\t\t\t= UI_CENTER|UI_SMALLFONT;\n\n\ty += INGAME_MENU_VERTICAL_SPACING;\n\ts_ingame.quit.generic.type\t\t\t= MTYPE_PTEXT;\n\ts_ingame.quit.generic.flags\t\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_ingame.quit.generic.x\t\t\t\t= 320;\n\ts_ingame.quit.generic.y\t\t\t\t= y;\n\ts_ingame.quit.generic.id\t\t\t= ID_QUIT;\n\ts_ingame.quit.generic.callback\t\t= InGame_Event; \n\ts_ingame.quit.string\t\t\t\t= \"EXIT GAME\";\n\ts_ingame.quit.color\t\t\t\t\t= color_red;\n\ts_ingame.quit.style\t\t\t\t\t= UI_CENTER|UI_SMALLFONT;\n\n\tMenu_AddItem( &s_ingame.menu, &s_ingame.frame );\n\tMenu_AddItem( &s_ingame.menu, &s_ingame.team );\n\tMenu_AddItem( &s_ingame.menu, &s_ingame.addbots );\n\tMenu_AddItem( &s_ingame.menu, &s_ingame.removebots );\n\tMenu_AddItem( &s_ingame.menu, &s_ingame.teamorders );\n\tMenu_AddItem( &s_ingame.menu, &s_ingame.setup );\n\tMenu_AddItem( &s_ingame.menu, &s_ingame.server );\n\tMenu_AddItem( &s_ingame.menu, &s_ingame.restart );\n\tMenu_AddItem( &s_ingame.menu, &s_ingame.resume );\n\tMenu_AddItem( &s_ingame.menu, &s_ingame.leave );\n\tMenu_AddItem( &s_ingame.menu, &s_ingame.quit );\n}\n\n\n/*\n=================\nInGame_Cache\n=================\n*/\nvoid InGame_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( INGAME_FRAME );\n}\n\n\n/*\n=================\nUI_InGameMenu\n=================\n*/\nvoid UI_InGameMenu( void ) {\n\t// force as top level menu\n\tuis.menusp = 0;  \n\n\t// set menu cursor to a nice location\n\tuis.cursorx = 319;\n\tuis.cursory = 80;\n\n\tInGame_MenuInit();\n\tUI_PushMenu( &s_ingame.menu );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_loadconfig.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=============================================================================\n\nLOAD CONFIG MENU\n\n=============================================================================\n*/\n\n#include \"ui_local.h\"\n\n\n#define ART_BACK0\t\t\t\"menu/art/back_0\"\n#define ART_BACK1\t\t\t\"menu/art/back_1\"\t\n#define ART_FIGHT0\t\t\t\"menu/art/load_0\"\n#define ART_FIGHT1\t\t\t\"menu/art/load_1\"\n#define ART_FRAMEL\t\t\t\"menu/art/frame2_l\"\n#define ART_FRAMER\t\t\t\"menu/art/frame1_r\"\n#define ART_ARROWS\t\t\t\"menu/art/arrows_horz_0\"\n#define ART_ARROWLEFT\t\t\"menu/art/arrows_horz_left\"\n#define ART_ARROWRIGHT\t\t\"menu/art/arrows_horz_right\"\n\n#define MAX_CONFIGS\t\t\t128\n#define NAMEBUFSIZE\t\t\t( MAX_CONFIGS * 16 )\n\n#define ID_BACK\t\t\t\t10\n#define ID_GO\t\t\t\t11\n#define ID_LIST\t\t\t\t12\n#define ID_LEFT\t\t\t\t13\n#define ID_RIGHT\t\t\t14\n\n#define ARROWS_WIDTH\t\t128\n#define ARROWS_HEIGHT\t\t48\n\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n\n\tmenutext_s\t\tbanner;\n\tmenubitmap_s\tframel;\n\tmenubitmap_s\tframer;\n\n\tmenulist_s\t\tlist;\n\n\tmenubitmap_s\tarrows;\n\tmenubitmap_s\tleft;\n\tmenubitmap_s\tright;\n\tmenubitmap_s\tback;\n\tmenubitmap_s\tgo;\n\n\tchar\t\t\tnames[NAMEBUFSIZE];\n\tchar*\t\t\tconfiglist[MAX_CONFIGS];\n} configs_t;\n\nstatic configs_t\ts_configs;\n\n\n/*\n===============\nLoadConfig_MenuEvent\n===============\n*/\nstatic void LoadConfig_MenuEvent( void *ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tswitch ( ((menucommon_s*)ptr)->id ) {\n\tcase ID_GO:\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va( \"exec %s\\n\", s_configs.list.itemnames[s_configs.list.curvalue] ) );\n\t\tUI_PopMenu();\n\t\tbreak;\n\n\tcase ID_BACK:\n\t\tUI_PopMenu();\n\t\tbreak;\n\n\tcase ID_LEFT:\n\t\tScrollList_Key( &s_configs.list, K_LEFTARROW );\n\t\tbreak;\n\n\tcase ID_RIGHT:\n\t\tScrollList_Key( &s_configs.list, K_RIGHTARROW );\n\t\tbreak;\n\t}\n}\n\n\n/*\n===============\nLoadConfig_MenuInit\n===============\n*/\nstatic void LoadConfig_MenuInit( void ) {\n\tint\t\ti;\n\tint\t\tlen;\n\tchar\t*configname;\n\n\tUI_LoadConfig_Cache();\n\n\tmemset( &s_configs, 0 ,sizeof(configs_t) );\n\ts_configs.menu.wrapAround = qtrue;\n\ts_configs.menu.fullscreen = qtrue;\n\n\ts_configs.banner.generic.type\t= MTYPE_BTEXT;\n\ts_configs.banner.generic.x\t\t= 320;\n\ts_configs.banner.generic.y\t\t= 16;\n\ts_configs.banner.string\t\t\t= \"LOAD CONFIG\";\n\ts_configs.banner.color\t\t\t= color_white;\n\ts_configs.banner.style\t\t\t= UI_CENTER;\n\n\ts_configs.framel.generic.type\t= MTYPE_BITMAP;\n\ts_configs.framel.generic.name\t= ART_FRAMEL;\n\ts_configs.framel.generic.flags\t= QMF_INACTIVE;\n\ts_configs.framel.generic.x\t\t= 0;  \n\ts_configs.framel.generic.y\t\t= 78;\n\ts_configs.framel.width\t\t\t= 256;\n\ts_configs.framel.height\t\t\t= 329;\n\n\ts_configs.framer.generic.type\t= MTYPE_BITMAP;\n\ts_configs.framer.generic.name\t= ART_FRAMER;\n\ts_configs.framer.generic.flags\t= QMF_INACTIVE;\n\ts_configs.framer.generic.x\t\t= 376;\n\ts_configs.framer.generic.y\t\t= 76;\n\ts_configs.framer.width\t\t\t= 256;\n\ts_configs.framer.height\t\t\t= 334;\n\n\ts_configs.arrows.generic.type\t= MTYPE_BITMAP;\n\ts_configs.arrows.generic.name\t= ART_ARROWS;\n\ts_configs.arrows.generic.flags\t= QMF_INACTIVE;\n\ts_configs.arrows.generic.x\t\t= 320-ARROWS_WIDTH/2;\n\ts_configs.arrows.generic.y\t\t= 400;\n\ts_configs.arrows.width\t\t\t= ARROWS_WIDTH;\n\ts_configs.arrows.height\t\t\t= ARROWS_HEIGHT;\n\n\ts_configs.left.generic.type\t\t= MTYPE_BITMAP;\n\ts_configs.left.generic.flags\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;\n\ts_configs.left.generic.x\t\t= 320-ARROWS_WIDTH/2;\n\ts_configs.left.generic.y\t\t= 400;\n\ts_configs.left.generic.id\t\t= ID_LEFT;\n\ts_configs.left.generic.callback\t= LoadConfig_MenuEvent;\n\ts_configs.left.width\t\t\t= ARROWS_WIDTH/2;\n\ts_configs.left.height\t\t\t= ARROWS_HEIGHT;\n\ts_configs.left.focuspic\t\t\t= ART_ARROWLEFT;\n\n\ts_configs.right.generic.type\t= MTYPE_BITMAP;\n\ts_configs.right.generic.flags\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;\n\ts_configs.right.generic.x\t\t= 320;\n\ts_configs.right.generic.y\t\t= 400;\n\ts_configs.right.generic.id\t\t= ID_RIGHT;\n\ts_configs.right.generic.callback = LoadConfig_MenuEvent;\n\ts_configs.right.width\t\t\t= ARROWS_WIDTH/2;\n\ts_configs.right.height\t\t\t= ARROWS_HEIGHT;\n\ts_configs.right.focuspic\t\t= ART_ARROWRIGHT;\n\n\ts_configs.back.generic.type\t\t= MTYPE_BITMAP;\n\ts_configs.back.generic.name\t\t= ART_BACK0;\n\ts_configs.back.generic.flags\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_configs.back.generic.id\t\t= ID_BACK;\n\ts_configs.back.generic.callback\t= LoadConfig_MenuEvent;\n\ts_configs.back.generic.x\t\t= 0;\n\ts_configs.back.generic.y\t\t= 480-64;\n\ts_configs.back.width\t\t\t= 128;\n\ts_configs.back.height\t\t\t= 64;\n\ts_configs.back.focuspic\t\t\t= ART_BACK1;\n\n\ts_configs.go.generic.type\t\t= MTYPE_BITMAP;\n\ts_configs.go.generic.name\t\t= ART_FIGHT0;\n\ts_configs.go.generic.flags\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_configs.go.generic.id\t\t\t= ID_GO;\n\ts_configs.go.generic.callback\t= LoadConfig_MenuEvent;\n\ts_configs.go.generic.x\t\t\t= 640;\n\ts_configs.go.generic.y\t\t\t= 480-64;\n\ts_configs.go.width\t\t\t\t= 128;\n\ts_configs.go.height\t\t\t\t= 64;\n\ts_configs.go.focuspic\t\t\t= ART_FIGHT1;\n\n\t// scan for configs\n\ts_configs.list.generic.type\t\t= MTYPE_SCROLLLIST;\n\ts_configs.list.generic.flags\t= QMF_PULSEIFFOCUS;\n\ts_configs.list.generic.callback\t= LoadConfig_MenuEvent;\n\ts_configs.list.generic.id\t\t= ID_LIST;\n\ts_configs.list.generic.x\t\t= 118;\n\ts_configs.list.generic.y\t\t= 130;\n\ts_configs.list.width\t\t\t= 16;\n\ts_configs.list.height\t\t\t= 14;\n\ts_configs.list.numitems\t\t\t= trap_FS_GetFileList( \"\", \"cfg\", s_configs.names, NAMEBUFSIZE );\n\ts_configs.list.itemnames\t\t= (const char **)s_configs.configlist;\n\ts_configs.list.columns\t\t\t= 3;\n\n\tif (!s_configs.list.numitems) {\n\t\tstrcpy(s_configs.names,\"No Files Found.\");\n\t\ts_configs.list.numitems = 1;\n\n\t\t//degenerate case, not selectable\n\t\ts_configs.go.generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);\n\t}\n\telse if (s_configs.list.numitems > MAX_CONFIGS)\n\t\ts_configs.list.numitems = MAX_CONFIGS;\n\t\n\tconfigname = s_configs.names;\n\tfor ( i = 0; i < s_configs.list.numitems; i++ ) {\n\t\ts_configs.list.itemnames[i] = configname;\n\t\t\n\t\t// strip extension\n\t\tlen = strlen( configname );\n\t\tif (!Q_stricmp(configname +  len - 4,\".cfg\"))\n\t\t\tconfigname[len-4] = '\\0';\n\n\t\tQ_strupr(configname);\n\n\t\tconfigname += len + 1;\n\t}\n\n\tMenu_AddItem( &s_configs.menu, &s_configs.banner );\n\tMenu_AddItem( &s_configs.menu, &s_configs.framel );\n\tMenu_AddItem( &s_configs.menu, &s_configs.framer );\n\tMenu_AddItem( &s_configs.menu, &s_configs.list );\n\tMenu_AddItem( &s_configs.menu, &s_configs.arrows );\n\tMenu_AddItem( &s_configs.menu, &s_configs.left );\n\tMenu_AddItem( &s_configs.menu, &s_configs.right );\n\tMenu_AddItem( &s_configs.menu, &s_configs.back );\n\tMenu_AddItem( &s_configs.menu, &s_configs.go );\n}\n\n/*\n=================\nUI_LoadConfig_Cache\n=================\n*/\nvoid UI_LoadConfig_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( ART_BACK0 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK1 );\n\ttrap_R_RegisterShaderNoMip( ART_FIGHT0 );\n\ttrap_R_RegisterShaderNoMip( ART_FIGHT1 );\n\ttrap_R_RegisterShaderNoMip( ART_FRAMEL );\n\ttrap_R_RegisterShaderNoMip( ART_FRAMER );\n\ttrap_R_RegisterShaderNoMip( ART_ARROWS );\n\ttrap_R_RegisterShaderNoMip( ART_ARROWLEFT );\n\ttrap_R_RegisterShaderNoMip( ART_ARROWRIGHT );\n}\n\n\n/*\n===============\nUI_LoadConfigMenu\n===============\n*/\nvoid UI_LoadConfigMenu( void ) {\n\tLoadConfig_MenuInit();\n\tUI_PushMenu( &s_configs.menu );\n}\n\n"
  },
  {
    "path": "code/q3_ui/ui_local.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#ifndef __UI_LOCAL_H__\n#define __UI_LOCAL_H__\n\n#include \"../game/q_shared.h\"\n#include \"../cgame/tr_types.h\"\n//NOTE: include the ui_public.h from the new UI\n#include \"../ui/ui_public.h\" // bk001205 - yes, do have to use this\n//redefine to old API version\n#undef UI_API_VERSION\n#define UI_API_VERSION\t4\n#include \"keycodes.h\"\n#include \"../game/bg_public.h\"\n\ntypedef void (*voidfunc_f)(void);\n\nextern vmCvar_t\tui_ffa_fraglimit;\nextern vmCvar_t\tui_ffa_timelimit;\n\nextern vmCvar_t\tui_tourney_fraglimit;\nextern vmCvar_t\tui_tourney_timelimit;\n\nextern vmCvar_t\tui_team_fraglimit;\nextern vmCvar_t\tui_team_timelimit;\nextern vmCvar_t\tui_team_friendly;\n\nextern vmCvar_t\tui_ctf_capturelimit;\nextern vmCvar_t\tui_ctf_timelimit;\nextern vmCvar_t\tui_ctf_friendly;\n\nextern vmCvar_t\tui_arenasFile;\nextern vmCvar_t\tui_botsFile;\nextern vmCvar_t\tui_spScores1;\nextern vmCvar_t\tui_spScores2;\nextern vmCvar_t\tui_spScores3;\nextern vmCvar_t\tui_spScores4;\nextern vmCvar_t\tui_spScores5;\nextern vmCvar_t\tui_spAwards;\nextern vmCvar_t\tui_spVideos;\nextern vmCvar_t\tui_spSkill;\n\nextern vmCvar_t\tui_spSelection;\n\nextern vmCvar_t\tui_browserMaster;\nextern vmCvar_t\tui_browserGameType;\nextern vmCvar_t\tui_browserSortKey;\nextern vmCvar_t\tui_browserShowFull;\nextern vmCvar_t\tui_browserShowEmpty;\n\nextern vmCvar_t\tui_brassTime;\nextern vmCvar_t\tui_drawCrosshair;\nextern vmCvar_t\tui_drawCrosshairNames;\nextern vmCvar_t\tui_marks;\n\nextern vmCvar_t\tui_server1;\nextern vmCvar_t\tui_server2;\nextern vmCvar_t\tui_server3;\nextern vmCvar_t\tui_server4;\nextern vmCvar_t\tui_server5;\nextern vmCvar_t\tui_server6;\nextern vmCvar_t\tui_server7;\nextern vmCvar_t\tui_server8;\nextern vmCvar_t\tui_server9;\nextern vmCvar_t\tui_server10;\nextern vmCvar_t\tui_server11;\nextern vmCvar_t\tui_server12;\nextern vmCvar_t\tui_server13;\nextern vmCvar_t\tui_server14;\nextern vmCvar_t\tui_server15;\nextern vmCvar_t\tui_server16;\n\nextern vmCvar_t\tui_cdkey;\nextern vmCvar_t\tui_cdkeychecked;\n\n\n//\n// ui_qmenu.c\n//\n\n#define RCOLUMN_OFFSET\t\t\t( BIGCHAR_WIDTH )\n#define LCOLUMN_OFFSET\t\t\t(-BIGCHAR_WIDTH )\n\n#define SLIDER_RANGE\t\t\t10\n#define\tMAX_EDIT_LINE\t\t\t256\n\n#define MAX_MENUDEPTH\t\t\t8\n#define MAX_MENUITEMS\t\t\t64\n\n#define MTYPE_NULL\t\t\t\t0\n#define MTYPE_SLIDER\t\t\t1\t\n#define MTYPE_ACTION\t\t\t2\n#define MTYPE_SPINCONTROL\t\t3\n#define MTYPE_FIELD\t\t\t\t4\n#define MTYPE_RADIOBUTTON\t\t5\n#define MTYPE_BITMAP\t\t\t6\t\n#define MTYPE_TEXT\t\t\t\t7\n#define MTYPE_SCROLLLIST\t\t8\n#define MTYPE_PTEXT\t\t\t\t9\n#define MTYPE_BTEXT\t\t\t\t10\n\n#define QMF_BLINK\t\t\t\t0x00000001\n#define QMF_SMALLFONT\t\t\t0x00000002\n#define QMF_LEFT_JUSTIFY\t\t0x00000004\n#define QMF_CENTER_JUSTIFY\t\t0x00000008\n#define QMF_RIGHT_JUSTIFY\t\t0x00000010\n#define QMF_NUMBERSONLY\t\t\t0x00000020\t// edit field is only numbers\n#define QMF_HIGHLIGHT\t\t\t0x00000040\n#define QMF_HIGHLIGHT_IF_FOCUS\t0x00000080\t// steady focus\n#define QMF_PULSEIFFOCUS\t\t0x00000100\t// pulse if focus\n#define QMF_HASMOUSEFOCUS\t\t0x00000200\n#define QMF_NOONOFFTEXT\t\t\t0x00000400\n#define QMF_MOUSEONLY\t\t\t0x00000800\t// only mouse input allowed\n#define QMF_HIDDEN\t\t\t\t0x00001000\t// skips drawing\n#define QMF_GRAYED\t\t\t\t0x00002000\t// grays and disables\n#define QMF_INACTIVE\t\t\t0x00004000\t// disables any input\n#define QMF_NODEFAULTINIT\t\t0x00008000\t// skip default initialization\n#define QMF_OWNERDRAW\t\t\t0x00010000\n#define QMF_PULSE\t\t\t\t0x00020000\n#define QMF_LOWERCASE\t\t\t0x00040000\t// edit field is all lower case\n#define QMF_UPPERCASE\t\t\t0x00080000\t// edit field is all upper case\n#define QMF_SILENT\t\t\t\t0x00100000\n\n// callback notifications\n#define QM_GOTFOCUS\t\t\t\t1\n#define QM_LOSTFOCUS\t\t\t2\n#define QM_ACTIVATED\t\t\t3\n\ntypedef struct _tag_menuframework\n{\n\tint\tcursor;\n\tint cursor_prev;\n\n\tint\tnitems;\n\tvoid *items[MAX_MENUITEMS];\n\n\tvoid (*draw) (void);\n\tsfxHandle_t (*key) (int key);\n\n\tqboolean\twrapAround;\n\tqboolean\tfullscreen;\n\tqboolean\tshowlogo;\n} menuframework_s;\n\ntypedef struct\n{\n\tint type;\n\tconst char *name;\n\tint\tid;\n\tint x, y;\n\tint left;\n\tint\ttop;\n\tint\tright;\n\tint\tbottom;\n\tmenuframework_s *parent;\n\tint menuPosition;\n\tunsigned flags;\n\n\tvoid (*callback)( void *self, int event );\n\tvoid (*statusbar)( void *self );\n\tvoid (*ownerdraw)( void *self );\n} menucommon_s;\n\ntypedef struct {\n\tint\t\tcursor;\n\tint\t\tscroll;\n\tint\t\twidthInChars;\n\tchar\tbuffer[MAX_EDIT_LINE];\n\tint\t\tmaxchars;\n} mfield_t;\n\ntypedef struct\n{\n\tmenucommon_s\tgeneric;\n\tmfield_t\t\tfield;\n} menufield_s;\n\ntypedef struct \n{\n\tmenucommon_s generic;\n\n\tfloat minvalue;\n\tfloat maxvalue;\n\tfloat curvalue;\n\n\tfloat range;\n} menuslider_s;\n\ntypedef struct\n{\n\tmenucommon_s generic;\n\n\tint\toldvalue;\n\tint curvalue;\n\tint\tnumitems;\n\tint\ttop;\n\t\t\n\tconst char **itemnames;\n\n\tint width;\n\tint height;\n\tint\tcolumns;\n\tint\tseperation;\n} menulist_s;\n\ntypedef struct\n{\n\tmenucommon_s generic;\n} menuaction_s;\n\ntypedef struct\n{\n\tmenucommon_s generic;\n\tint curvalue;\n} menuradiobutton_s;\n\ntypedef struct\n{\n\tmenucommon_s\tgeneric;\n\tchar*\t\t\tfocuspic;\t\n\tchar*\t\t\terrorpic;\n\tqhandle_t\t\tshader;\n\tqhandle_t\t\tfocusshader;\n\tint\t\t\t\twidth;\n\tint\t\t\t\theight;\n\tfloat*\t\t\tfocuscolor;\n} menubitmap_s;\n\ntypedef struct\n{\n\tmenucommon_s\tgeneric;\n\tchar*\t\t\tstring;\n\tint\t\t\t\tstyle;\n\tfloat*\t\t\tcolor;\n} menutext_s;\n\nextern void\t\t\tMenu_Cache( void );\nextern void\t\t\tMenu_Focus( menucommon_s *m );\nextern void\t\t\tMenu_AddItem( menuframework_s *menu, void *item );\nextern void\t\t\tMenu_AdjustCursor( menuframework_s *menu, int dir );\nextern void\t\t\tMenu_Draw( menuframework_s *menu );\nextern void\t\t\t*Menu_ItemAtCursor( menuframework_s *m );\nextern sfxHandle_t\tMenu_ActivateItem( menuframework_s *s, menucommon_s* item );\nextern void\t\t\tMenu_SetCursor( menuframework_s *s, int cursor );\nextern void\t\t\tMenu_SetCursorToItem( menuframework_s *m, void* ptr );\nextern sfxHandle_t\tMenu_DefaultKey( menuframework_s *s, int key );\nextern void\t\t\tBitmap_Init( menubitmap_s *b );\nextern void\t\t\tBitmap_Draw( menubitmap_s *b );\nextern void\t\t\tScrollList_Draw( menulist_s *l );\nextern sfxHandle_t\tScrollList_Key( menulist_s *l, int key );\nextern sfxHandle_t\tmenu_in_sound;\nextern sfxHandle_t\tmenu_move_sound;\nextern sfxHandle_t\tmenu_out_sound;\nextern sfxHandle_t\tmenu_buzz_sound;\nextern sfxHandle_t\tmenu_null_sound;\nextern sfxHandle_t\tweaponChangeSound;\nextern vec4_t\t\tmenu_text_color;\nextern vec4_t\t\tmenu_grayed_color;\nextern vec4_t\t\tmenu_dark_color;\nextern vec4_t\t\tmenu_highlight_color;\nextern vec4_t\t\tmenu_red_color;\nextern vec4_t\t\tmenu_black_color;\nextern vec4_t\t\tmenu_dim_color;\nextern vec4_t\t\tcolor_black;\nextern vec4_t\t\tcolor_white;\nextern vec4_t\t\tcolor_yellow;\nextern vec4_t\t\tcolor_blue;\nextern vec4_t\t\tcolor_orange;\nextern vec4_t\t\tcolor_red;\nextern vec4_t\t\tcolor_dim;\nextern vec4_t\t\tname_color;\nextern vec4_t\t\tlist_color;\nextern vec4_t\t\tlistbar_color;\nextern vec4_t\t\ttext_color_disabled; \nextern vec4_t\t\ttext_color_normal;\nextern vec4_t\t\ttext_color_highlight;\n\nextern char\t*ui_medalNames[];\nextern char\t*ui_medalPicNames[];\nextern char\t*ui_medalSounds[];\n\n//\n// ui_mfield.c\n//\nextern void\t\t\tMField_Clear( mfield_t *edit );\nextern void\t\t\tMField_KeyDownEvent( mfield_t *edit, int key );\nextern void\t\t\tMField_CharEvent( mfield_t *edit, int ch );\nextern void\t\t\tMField_Draw( mfield_t *edit, int x, int y, int style, vec4_t color );\nextern void\t\t\tMenuField_Init( menufield_s* m );\nextern void\t\t\tMenuField_Draw( menufield_s *f );\nextern sfxHandle_t\tMenuField_Key( menufield_s* m, int* key );\n\n//\n// ui_menu.c\n//\nextern void MainMenu_Cache( void );\nextern void UI_MainMenu(void);\nextern void UI_RegisterCvars( void );\nextern void UI_UpdateCvars( void );\n\n//\n// ui_credits.c\n//\nextern void UI_CreditMenu( void );\n\n//\n// ui_ingame.c\n//\nextern void InGame_Cache( void );\nextern void UI_InGameMenu(void);\n\n//\n// ui_confirm.c\n//\nextern void ConfirmMenu_Cache( void );\nextern void UI_ConfirmMenu( const char *question, void (*draw)( void ), void (*action)( qboolean result ) );\nextern void UI_ConfirmMenu_Style( const char *question, int style, void (*draw)( void ), void (*action)( qboolean result ) );\nextern void UI_Message( const char **lines );\n\n//\n// ui_setup.c\n//\nextern void UI_SetupMenu_Cache( void );\nextern void UI_SetupMenu(void);\n\n//\n// ui_team.c\n//\nextern void UI_TeamMainMenu( void );\nextern void TeamMain_Cache( void );\n\n//\n// ui_connect.c\n//\nextern void UI_DrawConnectScreen( qboolean overlay );\n\n//\n// ui_controls2.c\n//\nextern void UI_ControlsMenu( void );\nextern void Controls_Cache( void );\n\n//\n// ui_demo2.c\n//\nextern void UI_DemosMenu( void );\nextern void Demos_Cache( void );\n\n//\n// ui_cinematics.c\n//\nextern void UI_CinematicsMenu( void );\nextern void UI_CinematicsMenu_f( void );\nextern void UI_CinematicsMenu_Cache( void );\n\n//\n// ui_mods.c\n//\nextern void UI_ModsMenu( void );\nextern void UI_ModsMenu_Cache( void );\n\n//\n// ui_cdkey.c\n//\nextern void UI_CDKeyMenu( void );\nextern void UI_CDKeyMenu_Cache( void );\nextern void UI_CDKeyMenu_f( void );\n\n//\n// ui_playermodel.c\n//\nextern void UI_PlayerModelMenu( void );\nextern void PlayerModel_Cache( void );\n\n//\n// ui_playersettings.c\n//\nextern void UI_PlayerSettingsMenu( void );\nextern void PlayerSettings_Cache( void );\n\n//\n// ui_preferences.c\n//\nextern void UI_PreferencesMenu( void );\nextern void Preferences_Cache( void );\n\n//\n// ui_specifyleague.c\n//\nextern void UI_SpecifyLeagueMenu( void );\nextern void SpecifyLeague_Cache( void );\n\n//\n// ui_specifyserver.c\n//\nextern void UI_SpecifyServerMenu( void );\nextern void SpecifyServer_Cache( void );\n\n//\n// ui_servers2.c\n//\n#define MAX_FAVORITESERVERS 16\n\nextern void UI_ArenaServersMenu( void );\nextern void ArenaServers_Cache( void );\n\n//\n// ui_startserver.c\n//\nextern void UI_StartServerMenu( qboolean multiplayer );\nextern void StartServer_Cache( void );\nextern void ServerOptions_Cache( void );\nextern void UI_BotSelectMenu( char *bot );\nextern void UI_BotSelectMenu_Cache( void );\n\n//\n// ui_serverinfo.c\n//\nextern void UI_ServerInfoMenu( void );\nextern void ServerInfo_Cache( void );\n\n//\n// ui_video.c\n//\nextern void UI_GraphicsOptionsMenu( void );\nextern void GraphicsOptions_Cache( void );\nextern void DriverInfo_Cache( void );\n\n//\n// ui_players.c\n//\n\n//FIXME ripped from cg_local.h\ntypedef struct {\n\tint\t\t\toldFrame;\n\tint\t\t\toldFrameTime;\t\t// time when ->oldFrame was exactly on\n\n\tint\t\t\tframe;\n\tint\t\t\tframeTime;\t\t\t// time when ->frame will be exactly on\n\n\tfloat\t\tbacklerp;\n\n\tfloat\t\tyawAngle;\n\tqboolean\tyawing;\n\tfloat\t\tpitchAngle;\n\tqboolean\tpitching;\n\n\tint\t\t\tanimationNumber;\t// may include ANIM_TOGGLEBIT\n\tanimation_t\t*animation;\n\tint\t\t\tanimationTime;\t\t// time when the first frame of the animation will be exact\n} lerpFrame_t;\n\ntypedef struct {\n\t// model info\n\tqhandle_t\t\tlegsModel;\n\tqhandle_t\t\tlegsSkin;\n\tlerpFrame_t\t\tlegs;\n\n\tqhandle_t\t\ttorsoModel;\n\tqhandle_t\t\ttorsoSkin;\n\tlerpFrame_t\t\ttorso;\n\n\tqhandle_t\t\theadModel;\n\tqhandle_t\t\theadSkin;\n\n\tanimation_t\t\tanimations[MAX_ANIMATIONS];\n\n\tqhandle_t\t\tweaponModel;\n\tqhandle_t\t\tbarrelModel;\n\tqhandle_t\t\tflashModel;\n\tvec3_t\t\t\tflashDlightColor;\n\tint\t\t\t\tmuzzleFlashTime;\n\n\t// currently in use drawing parms\n\tvec3_t\t\t\tviewAngles;\n\tvec3_t\t\t\tmoveAngles;\n\tweapon_t\t\tcurrentWeapon;\n\tint\t\t\t\tlegsAnim;\n\tint\t\t\t\ttorsoAnim;\n\n\t// animation vars\n\tweapon_t\t\tweapon;\n\tweapon_t\t\tlastWeapon;\n\tweapon_t\t\tpendingWeapon;\n\tint\t\t\t\tweaponTimer;\n\tint\t\t\t\tpendingLegsAnim;\n\tint\t\t\t\ttorsoAnimationTimer;\n\n\tint\t\t\t\tpendingTorsoAnim;\n\tint\t\t\t\tlegsAnimationTimer;\n\n\tqboolean\t\tchat;\n\tqboolean\t\tnewModel;\n\n\tqboolean\t\tbarrelSpinning;\n\tfloat\t\t\tbarrelAngle;\n\tint\t\t\t\tbarrelTime;\n\n\tint\t\t\t\trealWeapon;\n} playerInfo_t;\n\nvoid UI_DrawPlayer( float x, float y, float w, float h, playerInfo_t *pi, int time );\nvoid UI_PlayerInfo_SetModel( playerInfo_t *pi, const char *model );\nvoid UI_PlayerInfo_SetInfo( playerInfo_t *pi, int legsAnim, int torsoAnim, vec3_t viewAngles, vec3_t moveAngles, weapon_t weaponNum, qboolean chat );\nqboolean UI_RegisterClientModelname( playerInfo_t *pi, const char *modelSkinName );\n\n//\n// ui_atoms.c\n//\ntypedef struct {\n\tint\t\t\t\t\tframetime;\n\tint\t\t\t\t\trealtime;\n\tint\t\t\t\t\tcursorx;\n\tint\t\t\t\t\tcursory;\n\tint\t\t\t\t\tmenusp;\n\tmenuframework_s*\tactivemenu;\n\tmenuframework_s*\tstack[MAX_MENUDEPTH];\n\tglconfig_t\t\t\tglconfig;\n\tqboolean\t\t\tdebug;\n\tqhandle_t\t\t\twhiteShader;\n\tqhandle_t\t\t\tmenuBackShader;\n\tqhandle_t\t\t\tmenuBackNoLogoShader;\n\tqhandle_t\t\t\tcharset;\n\tqhandle_t\t\t\tcharsetProp;\n\tqhandle_t\t\t\tcharsetPropGlow;\n\tqhandle_t\t\t\tcharsetPropB;\n\tqhandle_t\t\t\tcursor;\n\tqhandle_t\t\t\trb_on;\n\tqhandle_t\t\t\trb_off;\n\tfloat\t\t\t\tscale;\n\tfloat\t\t\t\tbias;\n\tqboolean\t\t\tdemoversion;\n\tqboolean\t\t\tfirstdraw;\n} uiStatic_t;\n\nextern void\t\t\tUI_Init( void );\nextern void\t\t\tUI_Shutdown( void );\nextern void\t\t\tUI_KeyEvent( int key, int down );\nextern void\t\t\tUI_MouseEvent( int dx, int dy );\nextern void\t\t\tUI_Refresh( int realtime );\nextern qboolean\t\tUI_ConsoleCommand( int realTime );\nextern float\t\tUI_ClampCvar( float min, float max, float value );\nextern void\t\t\tUI_DrawNamedPic( float x, float y, float width, float height, const char *picname );\nextern void\t\t\tUI_DrawHandlePic( float x, float y, float w, float h, qhandle_t hShader ); \nextern void\t\t\tUI_FillRect( float x, float y, float width, float height, const float *color );\nextern void\t\t\tUI_DrawRect( float x, float y, float width, float height, const float *color );\nextern void\t\t\tUI_UpdateScreen( void );\nextern void\t\t\tUI_SetColor( const float *rgba );\nextern void\t\t\tUI_LerpColor(vec4_t a, vec4_t b, vec4_t c, float t);\nextern void\t\t\tUI_DrawBannerString( int x, int y, const char* str, int style, vec4_t color );\nextern float\t\tUI_ProportionalSizeScale( int style );\nextern void\t\t\tUI_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color );\nextern void\t\t\tUI_DrawProportionalString_AutoWrapped( int x, int ystart, int xmax, int ystep, const char* str, int style, vec4_t color );\nextern int\t\t\tUI_ProportionalStringWidth( const char* str );\nextern void\t\t\tUI_DrawString( int x, int y, const char* str, int style, vec4_t color );\nextern void\t\t\tUI_DrawChar( int x, int y, int ch, int style, vec4_t color );\nextern qboolean \tUI_CursorInRect (int x, int y, int width, int height);\nextern void\t\t\tUI_AdjustFrom640( float *x, float *y, float *w, float *h );\nextern void\t\t\tUI_DrawTextBox (int x, int y, int width, int lines);\nextern qboolean\t\tUI_IsFullscreen( void );\nextern void\t\t\tUI_SetActiveMenu( uiMenuCommand_t menu );\nextern void\t\t\tUI_PushMenu ( menuframework_s *menu );\nextern void\t\t\tUI_PopMenu (void);\nextern void\t\t\tUI_ForceMenuOff (void);\nextern char\t\t\t*UI_Argv( int arg );\nextern char\t\t\t*UI_Cvar_VariableString( const char *var_name );\nextern void\t\t\tUI_Refresh( int time );\nextern void\t\t\tUI_StartDemoLoop( void );\nextern qboolean\t\tm_entersound;\nextern uiStatic_t\tuis;\n\n//\n// ui_spLevel.c\n//\nvoid UI_SPLevelMenu_Cache( void );\nvoid UI_SPLevelMenu( void );\nvoid UI_SPLevelMenu_f( void );\nvoid UI_SPLevelMenu_ReInit( void );\n\n//\n// ui_spArena.c\n//\nvoid UI_SPArena_Start( const char *arenaInfo );\n\n//\n// ui_spPostgame.c\n//\nvoid UI_SPPostgameMenu_Cache( void );\nvoid UI_SPPostgameMenu_f( void );\n\n//\n// ui_spSkill.c\n//\nvoid UI_SPSkillMenu( const char *arenaInfo );\nvoid UI_SPSkillMenu_Cache( void );\n\n//\n// ui_syscalls.c\n//\nvoid\t\t\ttrap_Print( const char *string );\nvoid\t\t\ttrap_Error( const char *string );\nint\t\t\t\ttrap_Milliseconds( void );\nvoid\t\t\ttrap_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags );\nvoid\t\t\ttrap_Cvar_Update( vmCvar_t *vmCvar );\nvoid\t\t\ttrap_Cvar_Set( const char *var_name, const char *value );\nfloat\t\t\ttrap_Cvar_VariableValue( const char *var_name );\nvoid\t\t\ttrap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize );\nvoid\t\t\ttrap_Cvar_SetValue( const char *var_name, float value );\nvoid\t\t\ttrap_Cvar_Reset( const char *name );\nvoid\t\t\ttrap_Cvar_Create( const char *var_name, const char *var_value, int flags );\nvoid\t\t\ttrap_Cvar_InfoStringBuffer( int bit, char *buffer, int bufsize );\nint\t\t\t\ttrap_Argc( void );\nvoid\t\t\ttrap_Argv( int n, char *buffer, int bufferLength );\nvoid\t\t\ttrap_Cmd_ExecuteText( int exec_when, const char *text );\t// don't use EXEC_NOW!\nint\t\t\t\ttrap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode );\nvoid\t\t\ttrap_FS_Read( void *buffer, int len, fileHandle_t f );\nvoid\t\t\ttrap_FS_Write( const void *buffer, int len, fileHandle_t f );\nvoid\t\t\ttrap_FS_FCloseFile( fileHandle_t f );\nint\t\t\t\ttrap_FS_GetFileList(  const char *path, const char *extension, char *listbuf, int bufsize );\nint\t\t\t\ttrap_FS_Seek( fileHandle_t f, long offset, int origin ); // fsOrigin_t\nqhandle_t\t\ttrap_R_RegisterModel( const char *name );\nqhandle_t\t\ttrap_R_RegisterSkin( const char *name );\nqhandle_t\t\ttrap_R_RegisterShaderNoMip( const char *name );\nvoid\t\t\ttrap_R_ClearScene( void );\nvoid\t\t\ttrap_R_AddRefEntityToScene( const refEntity_t *re );\nvoid\t\t\ttrap_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts );\nvoid\t\t\ttrap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b );\nvoid\t\t\ttrap_R_RenderScene( const refdef_t *fd );\nvoid\t\t\ttrap_R_SetColor( const float *rgba );\nvoid\t\t\ttrap_R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader );\nvoid\t\t\ttrap_UpdateScreen( void );\nint\t\t\t\ttrap_CM_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame, float frac, const char *tagName );\nvoid\t\t\ttrap_S_StartLocalSound( sfxHandle_t sfx, int channelNum );\nsfxHandle_t\ttrap_S_RegisterSound( const char *sample, qboolean compressed );\nvoid\t\t\ttrap_Key_KeynumToStringBuf( int keynum, char *buf, int buflen );\nvoid\t\t\ttrap_Key_GetBindingBuf( int keynum, char *buf, int buflen );\nvoid\t\t\ttrap_Key_SetBinding( int keynum, const char *binding );\nqboolean\t\ttrap_Key_IsDown( int keynum );\nqboolean\t\ttrap_Key_GetOverstrikeMode( void );\nvoid\t\t\ttrap_Key_SetOverstrikeMode( qboolean state );\nvoid\t\t\ttrap_Key_ClearStates( void );\nint\t\t\t\ttrap_Key_GetCatcher( void );\nvoid\t\t\ttrap_Key_SetCatcher( int catcher );\nvoid\t\t\ttrap_GetClipboardData( char *buf, int bufsize );\nvoid\t\t\ttrap_GetClientState( uiClientState_t *state );\nvoid\t\t\ttrap_GetGlconfig( glconfig_t *glconfig );\nint\t\t\t\ttrap_GetConfigString( int index, char* buff, int buffsize );\nint\t\t\t\ttrap_LAN_GetServerCount( int source );\nvoid\t\t\ttrap_LAN_GetServerAddressString( int source, int n, char *buf, int buflen );\nvoid\t\t\ttrap_LAN_GetServerInfo( int source, int n, char *buf, int buflen );\nint\t\t\t\ttrap_LAN_GetPingQueueCount( void );\nint\t\t\t\ttrap_LAN_ServerStatus( const char *serverAddress, char *serverStatus, int maxLen );\nvoid\t\t\ttrap_LAN_ClearPing( int n );\nvoid\t\t\ttrap_LAN_GetPing( int n, char *buf, int buflen, int *pingtime );\nvoid\t\t\ttrap_LAN_GetPingInfo( int n, char *buf, int buflen );\nint\t\t\t\ttrap_MemoryRemaining( void );\nvoid\t\t\ttrap_GetCDKey( char *buf, int buflen );\nvoid\t\t\ttrap_SetCDKey( char *buf );\n\nqboolean               trap_VerifyCDKey( const char *key, const char *chksum); // bk001208 - RC4\n\nvoid\t\t\ttrap_SetPbClStatus( int status );\n\n//\n// ui_addbots.c\n//\nvoid UI_AddBots_Cache( void );\nvoid UI_AddBotsMenu( void );\n\n//\n// ui_removebots.c\n//\nvoid UI_RemoveBots_Cache( void );\nvoid UI_RemoveBotsMenu( void );\n\n//\n// ui_teamorders.c\n//\nextern void UI_TeamOrdersMenu( void );\nextern void UI_TeamOrdersMenu_f( void );\nextern void UI_TeamOrdersMenu_Cache( void );\n\n//\n// ui_loadconfig.c\n//\nvoid UI_LoadConfig_Cache( void );\nvoid UI_LoadConfigMenu( void );\n\n//\n// ui_saveconfig.c\n//\nvoid UI_SaveConfigMenu_Cache( void );\nvoid UI_SaveConfigMenu( void );\n\n//\n// ui_display.c\n//\nvoid UI_DisplayOptionsMenu_Cache( void );\nvoid UI_DisplayOptionsMenu( void );\n\n//\n// ui_sound.c\n//\nvoid UI_SoundOptionsMenu_Cache( void );\nvoid UI_SoundOptionsMenu( void );\n\n//\n// ui_network.c\n//\nvoid UI_NetworkOptionsMenu_Cache( void );\nvoid UI_NetworkOptionsMenu( void );\n\n//\n// ui_gameinfo.c\n//\ntypedef enum {\n\tAWARD_ACCURACY,\n\tAWARD_IMPRESSIVE,\n\tAWARD_EXCELLENT,\n\tAWARD_GAUNTLET,\n\tAWARD_FRAGS,\n\tAWARD_PERFECT\n} awardType_t;\n\nconst char *UI_GetArenaInfoByNumber( int num );\nconst char *UI_GetArenaInfoByMap( const char *map );\nconst char *UI_GetSpecialArenaInfo( const char *tag );\nint UI_GetNumArenas( void );\nint UI_GetNumSPArenas( void );\nint UI_GetNumSPTiers( void );\n\nchar *UI_GetBotInfoByNumber( int num );\nchar *UI_GetBotInfoByName( const char *name );\nint UI_GetNumBots( void );\n\nvoid UI_GetBestScore( int level, int *score, int *skill );\nvoid UI_SetBestScore( int level, int score );\nint UI_TierCompleted( int levelWon );\nqboolean UI_ShowTierVideo( int tier );\nqboolean UI_CanShowTierVideo( int tier );\nint  UI_GetCurrentGame( void );\nvoid UI_NewGame( void );\nvoid UI_LogAwardData( int award, int data );\nint UI_GetAwardLevel( int award );\n\nvoid UI_SPUnlock_f( void );\nvoid UI_SPUnlockMedals_f( void );\n\nvoid UI_InitGameinfo( void );\n\n//GRank\n\n//\n// ui_rankings.c\n//\nvoid Rankings_DrawText( void* self );\nvoid Rankings_DrawName( void* self );\nvoid Rankings_DrawPassword( void* self );\nvoid Rankings_Cache( void );\nvoid UI_RankingsMenu( void );\n\n//\n// ui_login.c\n//\nvoid Login_Cache( void );\nvoid UI_LoginMenu( void );\n\n//\n// ui_signup.c\n//\nvoid Signup_Cache( void );\nvoid UI_SignupMenu( void );\n\n//\n// ui_rankstatus.c\n//\nvoid RankStatus_Cache( void );\nvoid UI_RankStatusMenu( void );\n\n#endif\n"
  },
  {
    "path": "code/q3_ui/ui_login.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n//\n// ui_login.c\n//\n\n#include \"ui_local.h\"\n\n\n#define LOGIN_FRAME\t\t\"menu/art/cut_frame\"\n\n#define ID_NAME\t\t\t100\n#define ID_NAME_BOX\t\t101\n#define ID_PASSWORD\t\t102\n#define ID_PASSWORD_BOX\t103\n#define ID_LOGIN\t\t104\n#define ID_CANCEL\t\t105\n\n\ntypedef struct\n{\n\tmenuframework_s\tmenu;\n\tmenubitmap_s\tframe;\n\tmenutext_s\t\tname;\n\tmenufield_s\t\tname_box;\n\tmenutext_s\t\tpassword;\n\tmenufield_s\t\tpassword_box;\n\tmenutext_s\t\tlogin;\n\tmenutext_s\t\tcancel;\n} login_t;\n\nstatic login_t\ts_login;\n\nstatic menuframework_s\ts_login_menu;\nstatic menuaction_s\t\ts_login_login;\nstatic menuaction_s\t\ts_login_cancel;\n\nstatic vec4_t s_login_color_prompt  = {1.00, 0.43, 0.00, 1.00};\n\n/*\n===============\nLogin_MenuEvent\n===============\n*/\nstatic void Login_MenuEvent( void* ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tswitch( ((menucommon_s*)ptr)->id ) {\n\tcase ID_LOGIN:\n\t\t// set name\t\t\t\t\t\t\t\t``\n\t\t//trap_Cvar_Set( \"name\", s_login.name_box.field.buffer );\n\t\t/*\n\t\ttrap_Cvar_Set( \"rank_name\", s_login.name_box.field.buffer );\n\t\ttrap_Cvar_Set( \"rank_pwd\", s_login.password_box.field.buffer );\n\t\t*/\n\n\t\t// login\n\t\ttrap_CL_UI_RankUserLogin(\n\t\t\ts_login.name_box.field.buffer, \n\t\t\ts_login.password_box.field.buffer );\n\n\t\tUI_ForceMenuOff();\n\t\tbreak;\n\t\t\n\tcase ID_CANCEL:\n\t\tUI_PopMenu();\n\t\tbreak;\n\t}\n}\n\n\n/*\n===============\nLogin_MenuInit\n===============\n*/\nvoid Login_MenuInit( void ) {\n\tint\t\t\t\ty;\n\n\tmemset( &s_login, 0, sizeof(s_login) );\n\n\tLogin_Cache();\n\n\ts_login.menu.wrapAround = qtrue;\n\ts_login.menu.fullscreen = qfalse;\n\n\ts_login.frame.generic.type\t\t\t= MTYPE_BITMAP;\n\ts_login.frame.generic.flags\t\t\t= QMF_INACTIVE;\n\ts_login.frame.generic.name\t\t\t= LOGIN_FRAME;\n\ts_login.frame.generic.x\t\t\t\t= 142; //320-233;\n\ts_login.frame.generic.y\t\t\t\t= 118; //240-166;\n\ts_login.frame.width\t\t\t\t\t= 359; //466;\n\ts_login.frame.height\t\t\t\t= 256; //332;\n\n\ty = 214;\n\n\ts_login.name.generic.type\t\t\t= MTYPE_PTEXT;\n\ts_login.name.generic.flags\t\t\t= QMF_RIGHT_JUSTIFY|QMF_INACTIVE;\n\ts_login.name.generic.id\t\t\t\t= ID_NAME;\n\ts_login.name.generic.x\t\t\t\t= 310;\n\ts_login.name.generic.y\t\t\t\t= y;\n\ts_login.name.string\t\t\t\t\t= \"NAME\";\n\ts_login.name.style\t\t\t\t\t= UI_RIGHT|UI_SMALLFONT;\n\ts_login.name.color\t\t\t\t\t= s_login_color_prompt;\n\n\ts_login.name_box.generic.type\t\t= MTYPE_FIELD;\n\ts_login.name_box.generic.ownerdraw\t= Rankings_DrawName;\n\ts_login.name_box.generic.name\t\t= \"\";\n\ts_login.name_box.generic.flags\t\t= 0;\n\ts_login.name_box.generic.x\t\t\t= 330;\n\ts_login.name_box.generic.y\t\t\t= y;\n\ts_login.name_box.field.widthInChars\t= 16;\n\ts_login.name_box.field.maxchars\t\t= 16;\n\ty += 20;\n\t\n\ts_login.password.generic.type\t\t= MTYPE_PTEXT;\n\ts_login.password.generic.flags\t\t= QMF_RIGHT_JUSTIFY|QMF_INACTIVE;\n\ts_login.password.generic.id\t\t\t= ID_PASSWORD;\n\ts_login.password.generic.x\t\t\t= 310;\n\ts_login.password.generic.y\t\t\t= y;\n\ts_login.password.string\t\t\t\t= \"PASSWORD\";\n\ts_login.password.style\t\t\t\t= UI_RIGHT|UI_SMALLFONT;\n\ts_login.password.color\t\t\t\t= s_login_color_prompt;\n\n\ts_login.password_box.generic.type\t\t= MTYPE_FIELD;\n\ts_login.password_box.generic.ownerdraw\t= Rankings_DrawPassword;\n\ts_login.password_box.generic.name\t\t= \"\";\n\ts_login.password_box.generic.flags\t\t= 0;\n\ts_login.password_box.generic.x\t\t\t= 330;\n\ts_login.password_box.generic.y\t\t\t= y;\n\ts_login.password_box.field.widthInChars\t= 16;\n\ts_login.password_box.field.maxchars\t\t= 16;\n\ty += 40;\n\n\ts_login.login.generic.type\t\t\t\t= MTYPE_PTEXT;\n\ts_login.login.generic.flags\t\t\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_login.login.generic.id\t\t\t\t= ID_LOGIN;\n\ts_login.login.generic.callback\t\t\t= Login_MenuEvent;\n\ts_login.login.generic.x\t\t\t\t\t= 310;\n\ts_login.login.generic.y\t\t\t\t\t= y;\n\ts_login.login.string\t\t\t\t\t= \"LOGIN\";\n\ts_login.login.style\t\t\t\t\t\t= UI_RIGHT|UI_SMALLFONT;\n\ts_login.login.color\t\t\t\t\t\t= colorRed;\n\n\ts_login.cancel.generic.type\t\t\t\t= MTYPE_PTEXT;\n\ts_login.cancel.generic.flags\t\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_login.cancel.generic.id\t\t\t\t= ID_CANCEL;\n\ts_login.cancel.generic.callback\t\t\t= Login_MenuEvent;\n\ts_login.cancel.generic.x\t\t\t\t= 330;\n\ts_login.cancel.generic.y\t\t\t\t= y;\n\ts_login.cancel.string\t\t\t\t\t= \"CANCEL\";\n\ts_login.cancel.style\t\t\t\t\t= UI_LEFT|UI_SMALLFONT;\n\ts_login.cancel.color\t\t\t\t\t= colorRed;\n\ty += 20;\n\n\tMenu_AddItem( &s_login.menu, (void*) &s_login.frame );\n\tMenu_AddItem( &s_login.menu, (void*) &s_login.name );\n\tMenu_AddItem( &s_login.menu, (void*) &s_login.name_box );\n\tMenu_AddItem( &s_login.menu, (void*) &s_login.password );\n\tMenu_AddItem( &s_login.menu, (void*) &s_login.password_box );\n\tMenu_AddItem( &s_login.menu, (void*) &s_login.login );\n\tMenu_AddItem( &s_login.menu, (void*) &s_login.cancel );\n}\n\n\n/*\n===============\nLogin_Cache\n===============\n*/\nvoid Login_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( LOGIN_FRAME );\n}\n\n\n/*\n===============\nUI_LoginMenu\n===============\n*/\nvoid UI_LoginMenu( void ) {\n\tLogin_MenuInit();\n\tUI_PushMenu ( &s_login.menu );\n}\n\n\n"
  },
  {
    "path": "code/q3_ui/ui_main.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=======================================================================\n\nUSER INTERFACE MAIN\n\n=======================================================================\n*/\n\n\n#include \"ui_local.h\"\n\n\n/*\n================\nvmMain\n\nThis is the only way control passes into the module.\nThis must be the very first function compiled into the .qvm file\n================\n*/\nint vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11  ) {\n\tswitch ( command ) {\n\tcase UI_GETAPIVERSION:\n\t\treturn UI_API_VERSION;\n\n\tcase UI_INIT:\n\t\tUI_Init();\n\t\treturn 0;\n\n\tcase UI_SHUTDOWN:\n\t\tUI_Shutdown();\n\t\treturn 0;\n\n\tcase UI_KEY_EVENT:\n\t\tUI_KeyEvent( arg0, arg1 );\n\t\treturn 0;\n\n\tcase UI_MOUSE_EVENT:\n\t\tUI_MouseEvent( arg0, arg1 );\n\t\treturn 0;\n\n\tcase UI_REFRESH:\n\t\tUI_Refresh( arg0 );\n\t\treturn 0;\n\n\tcase UI_IS_FULLSCREEN:\n\t\treturn UI_IsFullscreen();\n\n\tcase UI_SET_ACTIVE_MENU:\n\t\tUI_SetActiveMenu( arg0 );\n\t\treturn 0;\n\n\tcase UI_CONSOLE_COMMAND:\n\t\treturn UI_ConsoleCommand(arg0);\n\n\tcase UI_DRAW_CONNECT_SCREEN:\n\t\tUI_DrawConnectScreen( arg0 );\n\t\treturn 0;\n\tcase UI_HASUNIQUECDKEY:\t\t\t\t// mod authors need to observe this\n\t\treturn qtrue;  // bk010117 - change this to qfalse for mods!\n\t}\n\n\treturn -1;\n}\n\n\n/*\n================\ncvars\n================\n*/\n\ntypedef struct {\n\tvmCvar_t\t*vmCvar;\n\tchar\t\t*cvarName;\n\tchar\t\t*defaultString;\n\tint\t\t\tcvarFlags;\n} cvarTable_t;\n\nvmCvar_t\tui_ffa_fraglimit;\nvmCvar_t\tui_ffa_timelimit;\n\nvmCvar_t\tui_tourney_fraglimit;\nvmCvar_t\tui_tourney_timelimit;\n\nvmCvar_t\tui_team_fraglimit;\nvmCvar_t\tui_team_timelimit;\nvmCvar_t\tui_team_friendly;\n\nvmCvar_t\tui_ctf_capturelimit;\nvmCvar_t\tui_ctf_timelimit;\nvmCvar_t\tui_ctf_friendly;\n\nvmCvar_t\tui_arenasFile;\nvmCvar_t\tui_botsFile;\nvmCvar_t\tui_spScores1;\nvmCvar_t\tui_spScores2;\nvmCvar_t\tui_spScores3;\nvmCvar_t\tui_spScores4;\nvmCvar_t\tui_spScores5;\nvmCvar_t\tui_spAwards;\nvmCvar_t\tui_spVideos;\nvmCvar_t\tui_spSkill;\n\nvmCvar_t\tui_spSelection;\n\nvmCvar_t\tui_browserMaster;\nvmCvar_t\tui_browserGameType;\nvmCvar_t\tui_browserSortKey;\nvmCvar_t\tui_browserShowFull;\nvmCvar_t\tui_browserShowEmpty;\n\nvmCvar_t\tui_brassTime;\nvmCvar_t\tui_drawCrosshair;\nvmCvar_t\tui_drawCrosshairNames;\nvmCvar_t\tui_marks;\n\nvmCvar_t\tui_server1;\nvmCvar_t\tui_server2;\nvmCvar_t\tui_server3;\nvmCvar_t\tui_server4;\nvmCvar_t\tui_server5;\nvmCvar_t\tui_server6;\nvmCvar_t\tui_server7;\nvmCvar_t\tui_server8;\nvmCvar_t\tui_server9;\nvmCvar_t\tui_server10;\nvmCvar_t\tui_server11;\nvmCvar_t\tui_server12;\nvmCvar_t\tui_server13;\nvmCvar_t\tui_server14;\nvmCvar_t\tui_server15;\nvmCvar_t\tui_server16;\n\nvmCvar_t\tui_cdkeychecked;\n\n// bk001129 - made static to avoid aliasing.\nstatic cvarTable_t\t\tcvarTable[] = {\n\t{ &ui_ffa_fraglimit, \"ui_ffa_fraglimit\", \"20\", CVAR_ARCHIVE },\n\t{ &ui_ffa_timelimit, \"ui_ffa_timelimit\", \"0\", CVAR_ARCHIVE },\n\n\t{ &ui_tourney_fraglimit, \"ui_tourney_fraglimit\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_tourney_timelimit, \"ui_tourney_timelimit\", \"15\", CVAR_ARCHIVE },\n\n\t{ &ui_team_fraglimit, \"ui_team_fraglimit\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_team_timelimit, \"ui_team_timelimit\", \"20\", CVAR_ARCHIVE },\n\t{ &ui_team_friendly, \"ui_team_friendly\",  \"1\", CVAR_ARCHIVE },\n\n\t{ &ui_ctf_capturelimit, \"ui_ctf_capturelimit\", \"8\", CVAR_ARCHIVE },\n\t{ &ui_ctf_timelimit, \"ui_ctf_timelimit\", \"30\", CVAR_ARCHIVE },\n\t{ &ui_ctf_friendly, \"ui_ctf_friendly\",  \"0\", CVAR_ARCHIVE },\n\n\t{ &ui_arenasFile, \"g_arenasFile\", \"\", CVAR_INIT|CVAR_ROM },\n\t{ &ui_botsFile, \"g_botsFile\", \"\", CVAR_INIT|CVAR_ROM },\n\t{ &ui_spScores1, \"g_spScores1\", \"\", CVAR_ARCHIVE | CVAR_ROM },\n\t{ &ui_spScores2, \"g_spScores2\", \"\", CVAR_ARCHIVE | CVAR_ROM },\n\t{ &ui_spScores3, \"g_spScores3\", \"\", CVAR_ARCHIVE | CVAR_ROM },\n\t{ &ui_spScores4, \"g_spScores4\", \"\", CVAR_ARCHIVE | CVAR_ROM },\n\t{ &ui_spScores5, \"g_spScores5\", \"\", CVAR_ARCHIVE | CVAR_ROM },\n\t{ &ui_spAwards, \"g_spAwards\", \"\", CVAR_ARCHIVE | CVAR_ROM },\n\t{ &ui_spVideos, \"g_spVideos\", \"\", CVAR_ARCHIVE | CVAR_ROM },\n\t{ &ui_spSkill, \"g_spSkill\", \"2\", CVAR_ARCHIVE | CVAR_LATCH },\n\n\t{ &ui_spSelection, \"ui_spSelection\", \"\", CVAR_ROM },\n\n\t{ &ui_browserMaster, \"ui_browserMaster\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_browserGameType, \"ui_browserGameType\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_browserSortKey, \"ui_browserSortKey\", \"4\", CVAR_ARCHIVE },\n\t{ &ui_browserShowFull, \"ui_browserShowFull\", \"1\", CVAR_ARCHIVE },\n\t{ &ui_browserShowEmpty, \"ui_browserShowEmpty\", \"1\", CVAR_ARCHIVE },\n\n\t{ &ui_brassTime, \"cg_brassTime\", \"2500\", CVAR_ARCHIVE },\n\t{ &ui_drawCrosshair, \"cg_drawCrosshair\", \"4\", CVAR_ARCHIVE },\n\t{ &ui_drawCrosshairNames, \"cg_drawCrosshairNames\", \"1\", CVAR_ARCHIVE },\n\t{ &ui_marks, \"cg_marks\", \"1\", CVAR_ARCHIVE },\n\n\t{ &ui_server1, \"server1\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server2, \"server2\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server3, \"server3\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server4, \"server4\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server5, \"server5\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server6, \"server6\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server7, \"server7\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server8, \"server8\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server9, \"server9\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server10, \"server10\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server11, \"server11\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server12, \"server12\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server13, \"server13\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server14, \"server14\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server15, \"server15\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server16, \"server16\", \"\", CVAR_ARCHIVE },\n\n\t{ &ui_cdkeychecked, \"ui_cdkeychecked\", \"0\", CVAR_ROM }\n};\n\n// bk001129 - made static to avoid aliasing\nstatic int cvarTableSize = sizeof(cvarTable) / sizeof(cvarTable[0]);\n\n\n/*\n=================\nUI_RegisterCvars\n=================\n*/\nvoid UI_RegisterCvars( void ) {\n\tint\t\t\ti;\n\tcvarTable_t\t*cv;\n\n\tfor ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {\n\t\ttrap_Cvar_Register( cv->vmCvar, cv->cvarName, cv->defaultString, cv->cvarFlags );\n\t}\n}\n\n/*\n=================\nUI_UpdateCvars\n=================\n*/\nvoid UI_UpdateCvars( void ) {\n\tint\t\t\ti;\n\tcvarTable_t\t*cv;\n\n\tfor ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {\n\t\ttrap_Cvar_Update( cv->vmCvar );\n\t}\n}\n"
  },
  {
    "path": "code/q3_ui/ui_menu.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=======================================================================\n\nMAIN MENU\n\n=======================================================================\n*/\n\n\n#include \"ui_local.h\"\n\n\n#define ID_SINGLEPLAYER\t\t\t10\n#define ID_MULTIPLAYER\t\t\t11\n#define ID_SETUP\t\t\t\t12\n#define ID_DEMOS\t\t\t\t13\n#define ID_CINEMATICS\t\t\t14\n#define ID_TEAMARENA\t\t15\n#define ID_MODS\t\t\t\t\t16\n#define ID_EXIT\t\t\t\t\t17\n\n#define MAIN_BANNER_MODEL\t\t\t\t\"models/mapobjects/banner/banner5.md3\"\n#define MAIN_MENU_VERTICAL_SPACING\t\t34\n\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n\n\tmenutext_s\t\tsingleplayer;\n\tmenutext_s\t\tmultiplayer;\n\tmenutext_s\t\tsetup;\n\tmenutext_s\t\tdemos;\n\tmenutext_s\t\tcinematics;\n\tmenutext_s\t\tteamArena;\n\tmenutext_s\t\tmods;\n\tmenutext_s\t\texit;\n\n\tqhandle_t\t\tbannerModel;\n} mainmenu_t;\n\n\nstatic mainmenu_t s_main;\n\ntypedef struct {\n\tmenuframework_s menu;\t\n\tchar errorMessage[4096];\n} errorMessage_t;\n\nstatic errorMessage_t s_errorMessage;\n\n/*\n=================\nMainMenu_ExitAction\n=================\n*/\nstatic void MainMenu_ExitAction( qboolean result ) {\n\tif( !result ) {\n\t\treturn;\n\t}\n\tUI_PopMenu();\n\tUI_CreditMenu();\n}\n\n\n\n/*\n=================\nMain_MenuEvent\n=================\n*/\nvoid Main_MenuEvent (void* ptr, int event) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tswitch( ((menucommon_s*)ptr)->id ) {\n\tcase ID_SINGLEPLAYER:\n\t\tUI_SPLevelMenu();\n\t\tbreak;\n\n\tcase ID_MULTIPLAYER:\n\t\tUI_ArenaServersMenu();\n\t\tbreak;\n\n\tcase ID_SETUP:\n\t\tUI_SetupMenu();\n\t\tbreak;\n\n\tcase ID_DEMOS:\n\t\tUI_DemosMenu();\n\t\tbreak;\n\n\tcase ID_CINEMATICS:\n\t\tUI_CinematicsMenu();\n\t\tbreak;\n\n\tcase ID_MODS:\n\t\tUI_ModsMenu();\n\t\tbreak;\n\n\tcase ID_TEAMARENA:\n\t\ttrap_Cvar_Set( \"fs_game\", \"missionpack\");\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"vid_restart;\" );\n\t\tbreak;\n\n\tcase ID_EXIT:\n\t\tUI_ConfirmMenu( \"EXIT GAME?\", NULL, MainMenu_ExitAction );\n\t\tbreak;\n\t}\n}\n\n\n/*\n===============\nMainMenu_Cache\n===============\n*/\nvoid MainMenu_Cache( void ) {\n\ts_main.bannerModel = trap_R_RegisterModel( MAIN_BANNER_MODEL );\n}\n\nsfxHandle_t ErrorMessage_Key(int key)\n{\n\ttrap_Cvar_Set( \"com_errorMessage\", \"\" );\n\tUI_MainMenu();\n\treturn (menu_null_sound);\n}\n\n/*\n===============\nMain_MenuDraw\nTTimo: this function is common to the main menu and errorMessage menu\n===============\n*/\n\nstatic void Main_MenuDraw( void ) {\n\trefdef_t\t\trefdef;\n\trefEntity_t\t\tent;\n\tvec3_t\t\t\torigin;\n\tvec3_t\t\t\tangles;\n\tfloat\t\t\tadjust;\n\tfloat\t\t\tx, y, w, h;\n\tvec4_t\t\t\tcolor = {0.5, 0, 0, 1};\n\n\t// setup the refdef\n\n\tmemset( &refdef, 0, sizeof( refdef ) );\n\n\trefdef.rdflags = RDF_NOWORLDMODEL;\n\n\tAxisClear( refdef.viewaxis );\n\n\tx = 0;\n\ty = 0;\n\tw = 640;\n\th = 120;\n\tUI_AdjustFrom640( &x, &y, &w, &h );\n\trefdef.x = x;\n\trefdef.y = y;\n\trefdef.width = w;\n\trefdef.height = h;\n\n\tadjust = 0; // JDC: Kenneth asked me to stop this 1.0 * sin( (float)uis.realtime / 1000 );\n\trefdef.fov_x = 60 + adjust;\n\trefdef.fov_y = 19.6875 + adjust;\n\n\trefdef.time = uis.realtime;\n\n\torigin[0] = 300;\n\torigin[1] = 0;\n\torigin[2] = -32;\n\n\ttrap_R_ClearScene();\n\n\t// add the model\n\n\tmemset( &ent, 0, sizeof(ent) );\n\n\tadjust = 5.0 * sin( (float)uis.realtime / 5000 );\n\tVectorSet( angles, 0, 180 + adjust, 0 );\n\tAnglesToAxis( angles, ent.axis );\n\tent.hModel = s_main.bannerModel;\n\tVectorCopy( origin, ent.origin );\n\tVectorCopy( origin, ent.lightingOrigin );\n\tent.renderfx = RF_LIGHTING_ORIGIN | RF_NOSHADOW;\n\tVectorCopy( ent.origin, ent.oldorigin );\n\n\ttrap_R_AddRefEntityToScene( &ent );\n\n\ttrap_R_RenderScene( &refdef );\n\t\n\tif (strlen(s_errorMessage.errorMessage))\n\t{\n\t\tUI_DrawProportionalString_AutoWrapped( 320, 192, 600, 20, s_errorMessage.errorMessage, UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );\n\t}\n\telse\n\t{\n\t\t// standard menu drawing\n\t\tMenu_Draw( &s_main.menu );\t\t\n\t}\n\n\tif (uis.demoversion) {\n\t\tUI_DrawProportionalString( 320, 372, \"DEMO      FOR MATURE AUDIENCES      DEMO\", UI_CENTER|UI_SMALLFONT, color );\n\t\tUI_DrawString( 320, 400, \"Quake III Arena(c) 1999-2000, Id Software, Inc.  All Rights Reserved\", UI_CENTER|UI_SMALLFONT, color );\n\t} else {\n\t\tUI_DrawString( 320, 450, \"Quake III Arena(c) 1999-2000, Id Software, Inc.  All Rights Reserved\", UI_CENTER|UI_SMALLFONT, color );\n\t}\n}\n\n\n/*\n===============\nUI_TeamArenaExists\n===============\n*/\nstatic qboolean UI_TeamArenaExists( void ) {\n\tint\t\tnumdirs;\n\tchar\tdirlist[2048];\n\tchar\t*dirptr;\n  char  *descptr;\n\tint\t\ti;\n\tint\t\tdirlen;\n\n\tnumdirs = trap_FS_GetFileList( \"$modlist\", \"\", dirlist, sizeof(dirlist) );\n\tdirptr  = dirlist;\n\tfor( i = 0; i < numdirs; i++ ) {\n\t\tdirlen = strlen( dirptr ) + 1;\n    descptr = dirptr + dirlen;\n\t\tif (Q_stricmp(dirptr, \"missionpack\") == 0) {\n\t\t\treturn qtrue;\n\t\t}\n    dirptr += dirlen + strlen(descptr) + 1;\n\t}\n\treturn qfalse;\n}\n\n\n/*\n===============\nUI_MainMenu\n\nThe main menu only comes up when not in a game,\nso make sure that the attract loop server is down\nand that local cinematics are killed\n===============\n*/\nvoid UI_MainMenu( void ) {\n\tint\t\ty;\n\tqboolean teamArena = qfalse;\n\tint\t\tstyle = UI_CENTER | UI_DROPSHADOW;\n\n\ttrap_Cvar_Set( \"sv_killserver\", \"1\" );\n\n\tif( !uis.demoversion && !ui_cdkeychecked.integer ) {\n\t\tchar\tkey[17];\n\n\t\ttrap_GetCDKey( key, sizeof(key) );\n\t\tif( trap_VerifyCDKey( key, NULL ) == qfalse ) {\n\t\t\tUI_CDKeyMenu();\n\t\t\treturn;\n\t\t}\n\t}\n\t\n\tmemset( &s_main, 0 ,sizeof(mainmenu_t) );\n\tmemset( &s_errorMessage, 0 ,sizeof(errorMessage_t) );\n\n\t// com_errorMessage would need that too\n\tMainMenu_Cache();\n\t\n\ttrap_Cvar_VariableStringBuffer( \"com_errorMessage\", s_errorMessage.errorMessage, sizeof(s_errorMessage.errorMessage) );\n\tif (strlen(s_errorMessage.errorMessage))\n\t{\t\n\t\ts_errorMessage.menu.draw = Main_MenuDraw;\n\t\ts_errorMessage.menu.key = ErrorMessage_Key;\n\t\ts_errorMessage.menu.fullscreen = qtrue;\n\t\ts_errorMessage.menu.wrapAround = qtrue;\n\t\ts_errorMessage.menu.showlogo = qtrue;\t\t\n\n\t\ttrap_Key_SetCatcher( KEYCATCH_UI );\n\t\tuis.menusp = 0;\n\t\tUI_PushMenu ( &s_errorMessage.menu );\n\t\t\n\t\treturn;\n\t}\n\n\ts_main.menu.draw = Main_MenuDraw;\n\ts_main.menu.fullscreen = qtrue;\n\ts_main.menu.wrapAround = qtrue;\n\ts_main.menu.showlogo = qtrue;\n\n\ty = 134;\n\ts_main.singleplayer.generic.type\t\t= MTYPE_PTEXT;\n\ts_main.singleplayer.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_main.singleplayer.generic.x\t\t\t= 320;\n\ts_main.singleplayer.generic.y\t\t\t= y;\n\ts_main.singleplayer.generic.id\t\t\t= ID_SINGLEPLAYER;\n\ts_main.singleplayer.generic.callback\t= Main_MenuEvent; \n\ts_main.singleplayer.string\t\t\t\t= \"SINGLE PLAYER\";\n\ts_main.singleplayer.color\t\t\t\t= color_red;\n\ts_main.singleplayer.style\t\t\t\t= style;\n\n\ty += MAIN_MENU_VERTICAL_SPACING;\n\ts_main.multiplayer.generic.type\t\t\t= MTYPE_PTEXT;\n\ts_main.multiplayer.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_main.multiplayer.generic.x\t\t\t= 320;\n\ts_main.multiplayer.generic.y\t\t\t= y;\n\ts_main.multiplayer.generic.id\t\t\t= ID_MULTIPLAYER;\n\ts_main.multiplayer.generic.callback\t\t= Main_MenuEvent; \n\ts_main.multiplayer.string\t\t\t\t= \"MULTIPLAYER\";\n\ts_main.multiplayer.color\t\t\t\t= color_red;\n\ts_main.multiplayer.style\t\t\t\t= style;\n\n\ty += MAIN_MENU_VERTICAL_SPACING;\n\ts_main.setup.generic.type\t\t\t\t= MTYPE_PTEXT;\n\ts_main.setup.generic.flags\t\t\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_main.setup.generic.x\t\t\t\t\t= 320;\n\ts_main.setup.generic.y\t\t\t\t\t= y;\n\ts_main.setup.generic.id\t\t\t\t\t= ID_SETUP;\n\ts_main.setup.generic.callback\t\t\t= Main_MenuEvent; \n\ts_main.setup.string\t\t\t\t\t\t= \"SETUP\";\n\ts_main.setup.color\t\t\t\t\t\t= color_red;\n\ts_main.setup.style\t\t\t\t\t\t= style;\n\n\ty += MAIN_MENU_VERTICAL_SPACING;\n\ts_main.demos.generic.type\t\t\t\t= MTYPE_PTEXT;\n\ts_main.demos.generic.flags\t\t\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_main.demos.generic.x\t\t\t\t\t= 320;\n\ts_main.demos.generic.y\t\t\t\t\t= y;\n\ts_main.demos.generic.id\t\t\t\t\t= ID_DEMOS;\n\ts_main.demos.generic.callback\t\t\t= Main_MenuEvent; \n\ts_main.demos.string\t\t\t\t\t\t= \"DEMOS\";\n\ts_main.demos.color\t\t\t\t\t\t= color_red;\n\ts_main.demos.style\t\t\t\t\t\t= style;\n\n\ty += MAIN_MENU_VERTICAL_SPACING;\n\ts_main.cinematics.generic.type\t\t\t= MTYPE_PTEXT;\n\ts_main.cinematics.generic.flags\t\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_main.cinematics.generic.x\t\t\t\t= 320;\n\ts_main.cinematics.generic.y\t\t\t\t= y;\n\ts_main.cinematics.generic.id\t\t\t= ID_CINEMATICS;\n\ts_main.cinematics.generic.callback\t\t= Main_MenuEvent; \n\ts_main.cinematics.string\t\t\t\t= \"CINEMATICS\";\n\ts_main.cinematics.color\t\t\t\t\t= color_red;\n\ts_main.cinematics.style\t\t\t\t\t= style;\n\n\tif (UI_TeamArenaExists()) {\n\t\tteamArena = qtrue;\n\t\ty += MAIN_MENU_VERTICAL_SPACING;\n\t\ts_main.teamArena.generic.type\t\t\t= MTYPE_PTEXT;\n\t\ts_main.teamArena.generic.flags\t\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\t\ts_main.teamArena.generic.x\t\t\t\t= 320;\n\t\ts_main.teamArena.generic.y\t\t\t\t= y;\n\t\ts_main.teamArena.generic.id\t\t\t\t= ID_TEAMARENA;\n\t\ts_main.teamArena.generic.callback\t\t= Main_MenuEvent; \n\t\ts_main.teamArena.string\t\t\t\t\t= \"TEAM ARENA\";\n\t\ts_main.teamArena.color\t\t\t\t\t= color_red;\n\t\ts_main.teamArena.style\t\t\t\t\t= style;\n\t}\n\n\ty += MAIN_MENU_VERTICAL_SPACING;\n\ts_main.mods.generic.type\t\t\t= MTYPE_PTEXT;\n\ts_main.mods.generic.flags\t\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_main.mods.generic.x\t\t\t\t= 320;\n\ts_main.mods.generic.y\t\t\t\t= y;\n\ts_main.mods.generic.id\t\t\t\t= ID_MODS;\n\ts_main.mods.generic.callback\t\t= Main_MenuEvent; \n\ts_main.mods.string\t\t\t\t\t= \"MODS\";\n\ts_main.mods.color\t\t\t\t\t= color_red;\n\ts_main.mods.style\t\t\t\t\t= style;\n\n\ty += MAIN_MENU_VERTICAL_SPACING;\n\ts_main.exit.generic.type\t\t\t\t= MTYPE_PTEXT;\n\ts_main.exit.generic.flags\t\t\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_main.exit.generic.x\t\t\t\t\t= 320;\n\ts_main.exit.generic.y\t\t\t\t\t= y;\n\ts_main.exit.generic.id\t\t\t\t\t= ID_EXIT;\n\ts_main.exit.generic.callback\t\t\t= Main_MenuEvent; \n\ts_main.exit.string\t\t\t\t\t\t= \"EXIT\";\n\ts_main.exit.color\t\t\t\t\t\t= color_red;\n\ts_main.exit.style\t\t\t\t\t\t= style;\n\n\tMenu_AddItem( &s_main.menu,\t&s_main.singleplayer );\n\tMenu_AddItem( &s_main.menu,\t&s_main.multiplayer );\n\tMenu_AddItem( &s_main.menu,\t&s_main.setup );\n\tMenu_AddItem( &s_main.menu,\t&s_main.demos );\n\tMenu_AddItem( &s_main.menu,\t&s_main.cinematics );\n\tif (teamArena) {\n\t\tMenu_AddItem( &s_main.menu,\t&s_main.teamArena );\n\t}\n\tMenu_AddItem( &s_main.menu,\t&s_main.mods );\n\tMenu_AddItem( &s_main.menu,\t&s_main.exit );             \n\n\ttrap_Key_SetCatcher( KEYCATCH_UI );\n\tuis.menusp = 0;\n\tUI_PushMenu ( &s_main.menu );\n\t\t\n}\n"
  },
  {
    "path": "code/q3_ui/ui_mfield.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#include \"ui_local.h\"\n\n/*\n===================\nMField_Draw\n\nHandles horizontal scrolling and cursor blinking\nx, y, are in pixels\n===================\n*/\nvoid MField_Draw( mfield_t *edit, int x, int y, int style, vec4_t color ) {\n\tint\t\tlen;\n\tint\t\tcharw;\n\tint\t\tdrawLen;\n\tint\t\tprestep;\n\tint\t\tcursorChar;\n\tchar\tstr[MAX_STRING_CHARS];\n\n\tdrawLen = edit->widthInChars;\n\tlen     = strlen( edit->buffer ) + 1;\n\n\t// guarantee that cursor will be visible\n\tif ( len <= drawLen ) {\n\t\tprestep = 0;\n\t} else {\n\t\tif ( edit->scroll + drawLen > len ) {\n\t\t\tedit->scroll = len - drawLen;\n\t\t\tif ( edit->scroll < 0 ) {\n\t\t\t\tedit->scroll = 0;\n\t\t\t}\n\t\t}\n\t\tprestep = edit->scroll;\n\t}\n\n\tif ( prestep + drawLen > len ) {\n\t\tdrawLen = len - prestep;\n\t}\n\n\t// extract <drawLen> characters from the field at <prestep>\n\tif ( drawLen >= MAX_STRING_CHARS ) {\n\t\ttrap_Error( \"drawLen >= MAX_STRING_CHARS\" );\n\t}\n\tmemcpy( str, edit->buffer + prestep, drawLen );\n\tstr[ drawLen ] = 0;\n\n\tUI_DrawString( x, y, str, style, color );\n\n\t// draw the cursor\n\tif (!(style & UI_PULSE)) {\n\t\treturn;\n\t}\n\n\tif ( trap_Key_GetOverstrikeMode() ) {\n\t\tcursorChar = 11;\n\t} else {\n\t\tcursorChar = 10;\n\t}\n\n\tstyle &= ~UI_PULSE;\n\tstyle |= UI_BLINK;\n\n\tif (style & UI_SMALLFONT)\n\t{\n\t\tcharw =\tSMALLCHAR_WIDTH;\n\t}\n\telse if (style & UI_GIANTFONT)\n\t{\n\t\tcharw =\tGIANTCHAR_WIDTH;\n\t}\n\telse\n\t{\n\t\tcharw =\tBIGCHAR_WIDTH;\n\t}\n\n\tif (style & UI_CENTER)\n\t{\n\t\tlen = strlen(str);\n\t\tx = x - len*charw/2;\n\t}\n\telse if (style & UI_RIGHT)\n\t{\n\t\tlen = strlen(str);\n\t\tx = x - len*charw;\n\t}\n\t\n\tUI_DrawChar( x + ( edit->cursor - prestep ) * charw, y, cursorChar, style & ~(UI_CENTER|UI_RIGHT), color );\n}\n\n/*\n================\nMField_Paste\n================\n*/\nvoid MField_Paste( mfield_t *edit ) {\n\tchar\tpasteBuffer[64];\n\tint\t\tpasteLen, i;\n\n\ttrap_GetClipboardData( pasteBuffer, 64 );\n\n\t// send as if typed, so insert / overstrike works properly\n\tpasteLen = strlen( pasteBuffer );\n\tfor ( i = 0 ; i < pasteLen ; i++ ) {\n\t\tMField_CharEvent( edit, pasteBuffer[i] );\n\t}\n}\n\n/*\n=================\nMField_KeyDownEvent\n\nPerforms the basic line editing functions for the console,\nin-game talk, and menu fields\n\nKey events are used for non-printable characters, others are gotten from char events.\n=================\n*/\nvoid MField_KeyDownEvent( mfield_t *edit, int key ) {\n\tint\t\tlen;\n\n\t// shift-insert is paste\n\tif ( ( ( key == K_INS ) || ( key == K_KP_INS ) ) && trap_Key_IsDown( K_SHIFT ) ) {\n\t\tMField_Paste( edit );\n\t\treturn;\n\t}\n\n\tlen = strlen( edit->buffer );\n\n\tif ( key == K_DEL || key == K_KP_DEL ) {\n\t\tif ( edit->cursor < len ) {\n\t\t\tmemmove( edit->buffer + edit->cursor, \n\t\t\t\tedit->buffer + edit->cursor + 1, len - edit->cursor );\n\t\t}\n\t\treturn;\n\t}\n\n\tif ( key == K_RIGHTARROW || key == K_KP_RIGHTARROW ) \n\t{\n\t\tif ( edit->cursor < len ) {\n\t\t\tedit->cursor++;\n\t\t}\n\t\tif ( edit->cursor >= edit->scroll + edit->widthInChars && edit->cursor <= len )\n\t\t{\n\t\t\tedit->scroll++;\n\t\t}\n\t\treturn;\n\t}\n\n\tif ( key == K_LEFTARROW || key == K_KP_LEFTARROW ) \n\t{\n\t\tif ( edit->cursor > 0 ) {\n\t\t\tedit->cursor--;\n\t\t}\n\t\tif ( edit->cursor < edit->scroll )\n\t\t{\n\t\t\tedit->scroll--;\n\t\t}\n\t\treturn;\n\t}\n\n\tif ( key == K_HOME || key == K_KP_HOME || ( tolower(key) == 'a' && trap_Key_IsDown( K_CTRL ) ) ) {\n\t\tedit->cursor = 0;\n\t\tedit->scroll = 0;\n\t\treturn;\n\t}\n\n\tif ( key == K_END || key == K_KP_END || ( tolower(key) == 'e' && trap_Key_IsDown( K_CTRL ) ) ) {\n\t\tedit->cursor = len;\n\t\tedit->scroll = len - edit->widthInChars + 1;\n\t\tif (edit->scroll < 0)\n\t\t\tedit->scroll = 0;\n\t\treturn;\n\t}\n\n\tif ( key == K_INS || key == K_KP_INS ) {\n\t\ttrap_Key_SetOverstrikeMode( !trap_Key_GetOverstrikeMode() );\n\t\treturn;\n\t}\n}\n\n/*\n==================\nMField_CharEvent\n==================\n*/\nvoid MField_CharEvent( mfield_t *edit, int ch ) {\n\tint\t\tlen;\n\n\tif ( ch == 'v' - 'a' + 1 ) {\t// ctrl-v is paste\n\t\tMField_Paste( edit );\n\t\treturn;\n\t}\n\n\tif ( ch == 'c' - 'a' + 1 ) {\t// ctrl-c clears the field\n\t\tMField_Clear( edit );\n\t\treturn;\n\t}\n\n\tlen = strlen( edit->buffer );\n\n\tif ( ch == 'h' - 'a' + 1 )\t{\t// ctrl-h is backspace\n\t\tif ( edit->cursor > 0 ) {\n\t\t\tmemmove( edit->buffer + edit->cursor - 1, \n\t\t\t\tedit->buffer + edit->cursor, len + 1 - edit->cursor );\n\t\t\tedit->cursor--;\n\t\t\tif ( edit->cursor < edit->scroll )\n\t\t\t{\n\t\t\t\tedit->scroll--;\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\n\tif ( ch == 'a' - 'a' + 1 ) {\t// ctrl-a is home\n\t\tedit->cursor = 0;\n\t\tedit->scroll = 0;\n\t\treturn;\n\t}\n\n\tif ( ch == 'e' - 'a' + 1 ) {\t// ctrl-e is end\n\t\tedit->cursor = len;\n\t\tedit->scroll = edit->cursor - edit->widthInChars + 1;\n\t\tif (edit->scroll < 0)\n\t\t\tedit->scroll = 0;\n\t\treturn;\n\t}\n\n\t//\n\t// ignore any other non printable chars\n\t//\n\tif ( ch < 32 ) {\n\t\treturn;\n\t}\n\n\tif ( !trap_Key_GetOverstrikeMode() ) {\t\n\t\tif ((edit->cursor == MAX_EDIT_LINE - 1) || (edit->maxchars && edit->cursor >= edit->maxchars))\n\t\t\treturn;\n\t} else {\n\t\t// insert mode\n\t\tif (( len == MAX_EDIT_LINE - 1 ) || (edit->maxchars && len >= edit->maxchars))\n\t\t\treturn;\n\t\tmemmove( edit->buffer + edit->cursor + 1, edit->buffer + edit->cursor, len + 1 - edit->cursor );\n\t}\n\n\tedit->buffer[edit->cursor] = ch;\n\tif (!edit->maxchars || edit->cursor < edit->maxchars-1)\n\t\tedit->cursor++;\n\n\tif ( edit->cursor >= edit->widthInChars )\n\t{\n\t\tedit->scroll++;\n\t}\n\n\tif ( edit->cursor == len + 1) {\n\t\tedit->buffer[edit->cursor] = 0;\n\t}\n}\n\n/*\n==================\nMField_Clear\n==================\n*/\nvoid MField_Clear( mfield_t *edit ) {\n\tedit->buffer[0] = 0;\n\tedit->cursor = 0;\n\tedit->scroll = 0;\n}\n\n/*\n==================\nMenuField_Init\n==================\n*/\nvoid MenuField_Init( menufield_s* m ) {\n\tint\tl;\n\tint\tw;\n\tint\th;\n\n\tMField_Clear( &m->field );\n\n\tif (m->generic.flags & QMF_SMALLFONT)\n\t{\n\t\tw = SMALLCHAR_WIDTH;\n\t\th = SMALLCHAR_HEIGHT;\n\t}\n\telse\n\t{\n\t\tw = BIGCHAR_WIDTH;\n\t\th = BIGCHAR_HEIGHT;\n\t}\t\n\n\tif (m->generic.name) {\n\t\tl = (strlen( m->generic.name )+1) * w;\t\t\n\t}\n\telse {\n\t\tl = 0;\n\t}\n\n\tm->generic.left   = m->generic.x - l;\n\tm->generic.top    = m->generic.y;\n\tm->generic.right  = m->generic.x + w + m->field.widthInChars*w;\n\tm->generic.bottom = m->generic.y + h;\n}\n\n/*\n==================\nMenuField_Draw\n==================\n*/\nvoid MenuField_Draw( menufield_s *f )\n{\n\tint\t\tx;\n\tint\t\ty;\n\tint\t\tw;\n\tint\t\th;\n\tint\t\tstyle;\n\tqboolean focus;\n\tfloat\t*color;\n\n\tx =\tf->generic.x;\n\ty =\tf->generic.y;\n\n\tif (f->generic.flags & QMF_SMALLFONT)\n\t{\n\t\tw = SMALLCHAR_WIDTH;\n\t\th = SMALLCHAR_HEIGHT;\n\t\tstyle = UI_SMALLFONT;\n\t}\n\telse\n\t{\n\t\tw = BIGCHAR_WIDTH;\n\t\th = BIGCHAR_HEIGHT;\n\t\tstyle = UI_BIGFONT;\n\t}\t\n\n\tif (Menu_ItemAtCursor( f->generic.parent ) == f) {\n\t\tfocus = qtrue;\n\t\tstyle |= UI_PULSE;\n\t}\n\telse {\n\t\tfocus = qfalse;\n\t}\n\n\tif (f->generic.flags & QMF_GRAYED)\n\t\tcolor = text_color_disabled;\n\telse if (focus)\n\t\tcolor = text_color_highlight;\n\telse\n\t\tcolor = text_color_normal;\n\n\tif ( focus )\n\t{\n\t\t// draw cursor\n\t\tUI_FillRect( f->generic.left, f->generic.top, f->generic.right-f->generic.left+1, f->generic.bottom-f->generic.top+1, listbar_color ); \n\t\tUI_DrawChar( x, y, 13, UI_CENTER|UI_BLINK|style, color);\n\t}\n\n\tif ( f->generic.name ) {\n\t\tUI_DrawString( x - w, y, f->generic.name, style|UI_RIGHT, color );\n\t}\n\n\tMField_Draw( &f->field, x + w, y, style, color );\n}\n\n/*\n==================\nMenuField_Key\n==================\n*/\nsfxHandle_t MenuField_Key( menufield_s* m, int* key )\n{\n\tint keycode;\n\n\tkeycode = *key;\n\n\tswitch ( keycode )\n\t{\n\t\tcase K_KP_ENTER:\n\t\tcase K_ENTER:\n\t\tcase K_JOY1:\n\t\tcase K_JOY2:\n\t\tcase K_JOY3:\n\t\tcase K_JOY4:\n\t\t\t// have enter go to next cursor point\n\t\t\t*key = K_TAB;\n\t\t\tbreak;\n\n\t\tcase K_TAB:\n\t\tcase K_KP_DOWNARROW:\n\t\tcase K_DOWNARROW:\n\t\tcase K_KP_UPARROW:\n\t\tcase K_UPARROW:\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tif ( keycode & K_CHAR_FLAG )\n\t\t\t{\n\t\t\t\tkeycode &= ~K_CHAR_FLAG;\n\n\t\t\t\tif ((m->generic.flags & QMF_UPPERCASE) && Q_islower( keycode ))\n\t\t\t\t\tkeycode -= 'a' - 'A';\n\t\t\t\telse if ((m->generic.flags & QMF_LOWERCASE) && Q_isupper( keycode ))\n\t\t\t\t\tkeycode -= 'A' - 'a';\n\t\t\t\telse if ((m->generic.flags & QMF_NUMBERSONLY) && Q_isalpha( keycode ))\n\t\t\t\t\treturn (menu_buzz_sound);\n\n\t\t\t\tMField_CharEvent( &m->field, keycode);\n\t\t\t}\n\t\t\telse\n\t\t\t\tMField_KeyDownEvent( &m->field, keycode );\n\t\t\tbreak;\n\t}\n\n\treturn (0);\n}\n\n\n"
  },
  {
    "path": "code/q3_ui/ui_mods.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#include \"ui_local.h\"\n\n#define ART_BACK0\t\t\t\"menu/art/back_0\"\n#define ART_BACK1\t\t\t\"menu/art/back_1\"\t\n#define ART_FIGHT0\t\t\t\"menu/art/load_0\"\n#define ART_FIGHT1\t\t\t\"menu/art/load_1\"\n#define ART_FRAMEL\t\t\t\"menu/art/frame2_l\"\n#define ART_FRAMER\t\t\t\"menu/art/frame1_r\"\n\n#define MAX_MODS\t\t\t64\n#define NAMEBUFSIZE\t\t\t( MAX_MODS * 48 )\n#define GAMEBUFSIZE\t\t\t( MAX_MODS * 16 )\n\n#define ID_BACK\t\t\t\t10\n#define ID_GO\t\t\t\t11\n#define ID_LIST\t\t\t\t12\n\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n\n\tmenutext_s\t\tbanner;\n\tmenubitmap_s\tframel;\n\tmenubitmap_s\tframer;\n\n\tmenulist_s\t\tlist;\n\n\tmenubitmap_s\tback;\n\tmenubitmap_s\tgo;\n\n\tchar\t\t\tdescription[NAMEBUFSIZE];\n\tchar\t\t\tfs_game[GAMEBUFSIZE];\n\n\tchar\t\t\t*descriptionPtr;\n\tchar\t\t\t*fs_gamePtr;\n\n\tchar\t\t\t*descriptionList[MAX_MODS];\n\tchar\t\t\t*fs_gameList[MAX_MODS];\n} mods_t;\n\nstatic mods_t\ts_mods;\n\n\n/*\n===============\nUI_Mods_MenuEvent\n===============\n*/\nstatic void UI_Mods_MenuEvent( void *ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tswitch ( ((menucommon_s*)ptr)->id ) {\n\tcase ID_GO:\n\t\ttrap_Cvar_Set( \"fs_game\", s_mods.fs_gameList[s_mods.list.curvalue] );\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"vid_restart;\" );\n\t\tUI_PopMenu();\n\t\tbreak;\n\n\tcase ID_BACK:\n\t\tUI_PopMenu();\n\t\tbreak;\n\t}\n}\n\n\n/*\n===============\nUI_Mods_ParseInfos\n===============\n*/\nstatic void UI_Mods_ParseInfos( char *modDir, char *modDesc ) {\n\ts_mods.fs_gameList[s_mods.list.numitems] = s_mods.fs_gamePtr;\n\tQ_strncpyz( s_mods.fs_gamePtr, modDir, 16 );\n\n\ts_mods.descriptionList[s_mods.list.numitems] = s_mods.descriptionPtr;\n\tQ_strncpyz( s_mods.descriptionPtr, modDesc, 48 );\n\n\ts_mods.list.itemnames[s_mods.list.numitems] = s_mods.descriptionPtr;\n\ts_mods.descriptionPtr += strlen( s_mods.descriptionPtr ) + 1;\n\ts_mods.fs_gamePtr += strlen( s_mods.fs_gamePtr ) + 1;\n\ts_mods.list.numitems++;\n}\n\n\n#if 0 // bk001204 - unused\n/*\n===============\nUI_Mods_LoadModsFromFile\n===============\n*/\nstatic void UI_Mods_LoadModsFromFile( char *filename ) {\n\tint\t\t\t\tlen;\n\tfileHandle_t\tf;\n\tchar\t\t\tbuf[1024];\n\n\tlen = trap_FS_FOpenFile( filename, &f, FS_READ );\n\tif ( !f ) {\n\t\ttrap_Print( va( S_COLOR_RED \"file not found: %s\\n\", filename ) );\n\t\treturn;\n\t}\n\tif ( len >= sizeof(buf) ) {\n\t\ttrap_Print( va( S_COLOR_RED \"file too large: %s is %i, max allowed is %i\", filename, len, sizeof(buf) ) );\n\t\ttrap_FS_FCloseFile( f );\n\t\treturn;\n\t}\n\n\ttrap_FS_Read( buf, len, f );\n\tbuf[len] = 0;\n\ttrap_FS_FCloseFile( f );\n\n\tlen = strlen( filename );\n\tif( !Q_stricmp(filename +  len - 4,\".mod\") ) {\n\t\tfilename[len-4] = '\\0';\n\t}\n\n\tUI_Mods_ParseInfos( filename, buf );\n}\n#endif\n\n\n/*\n===============\nUI_Mods_LoadMods\n===============\n*/\nstatic void UI_Mods_LoadMods( void ) {\n\tint\t\tnumdirs;\n\tchar\tdirlist[2048];\n\tchar\t*dirptr;\n  char  *descptr;\n\tint\t\ti;\n\tint\t\tdirlen;\n\n\ts_mods.list.itemnames = (const char **)s_mods.descriptionList;\n\ts_mods.descriptionPtr = s_mods.description;\n\ts_mods.fs_gamePtr = s_mods.fs_game;\n\n\t// always start off with baseq3\n\ts_mods.list.numitems = 1;\n\ts_mods.list.itemnames[0] = s_mods.descriptionList[0] = \"Quake III Arena\";\n\ts_mods.fs_gameList[0] = \"\";\n\n\tnumdirs = trap_FS_GetFileList( \"$modlist\", \"\", dirlist, sizeof(dirlist) );\n\tdirptr  = dirlist;\n\tfor( i = 0; i < numdirs; i++ ) {\n\t\tdirlen = strlen( dirptr ) + 1;\n    descptr = dirptr + dirlen;\n  \tUI_Mods_ParseInfos( dirptr, descptr);\n    dirptr += dirlen + strlen(descptr) + 1;\n\t}\n\n\ttrap_Print( va( \"%i mods parsed\\n\", s_mods.list.numitems ) );\n\tif (s_mods.list.numitems > MAX_MODS) {\n\t\ts_mods.list.numitems = MAX_MODS;\n\t}\n}\n\n\n/*\n===============\nUI_Mods_MenuInit\n===============\n*/\nstatic void UI_Mods_MenuInit( void ) {\n\tUI_ModsMenu_Cache();\n\n\tmemset( &s_mods, 0 ,sizeof(mods_t) );\n\ts_mods.menu.wrapAround = qtrue;\n\ts_mods.menu.fullscreen = qtrue;\n\n\ts_mods.banner.generic.type\t\t= MTYPE_BTEXT;\n\ts_mods.banner.generic.x\t\t\t= 320;\n\ts_mods.banner.generic.y\t\t\t= 16;\n\ts_mods.banner.string\t\t\t= \"MODS\";\n\ts_mods.banner.color\t\t\t\t= color_white;\n\ts_mods.banner.style\t\t\t\t= UI_CENTER;\n\n\ts_mods.framel.generic.type\t\t= MTYPE_BITMAP;\n\ts_mods.framel.generic.name\t\t= ART_FRAMEL;\n\ts_mods.framel.generic.flags\t\t= QMF_INACTIVE;\n\ts_mods.framel.generic.x\t\t\t= 0;  \n\ts_mods.framel.generic.y\t\t\t= 78;\n\ts_mods.framel.width\t\t\t\t= 256;\n\ts_mods.framel.height\t\t\t= 329;\n\n\ts_mods.framer.generic.type\t\t= MTYPE_BITMAP;\n\ts_mods.framer.generic.name\t\t= ART_FRAMER;\n\ts_mods.framer.generic.flags\t\t= QMF_INACTIVE;\n\ts_mods.framer.generic.x\t\t\t= 376;\n\ts_mods.framer.generic.y\t\t\t= 76;\n\ts_mods.framer.width\t\t\t\t= 256;\n\ts_mods.framer.height\t\t\t= 334;\n\n\ts_mods.back.generic.type\t\t= MTYPE_BITMAP;\n\ts_mods.back.generic.name\t\t= ART_BACK0;\n\ts_mods.back.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_mods.back.generic.id\t\t\t= ID_BACK;\n\ts_mods.back.generic.callback\t= UI_Mods_MenuEvent;\n\ts_mods.back.generic.x\t\t\t= 0;\n\ts_mods.back.generic.y\t\t\t= 480-64;\n\ts_mods.back.width\t\t\t\t= 128;\n\ts_mods.back.height\t\t\t\t= 64;\n\ts_mods.back.focuspic\t\t\t= ART_BACK1;\n\n\ts_mods.go.generic.type\t\t\t= MTYPE_BITMAP;\n\ts_mods.go.generic.name\t\t\t= ART_FIGHT0;\n\ts_mods.go.generic.flags\t\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_mods.go.generic.id\t\t\t= ID_GO;\n\ts_mods.go.generic.callback\t\t= UI_Mods_MenuEvent;\n\ts_mods.go.generic.x\t\t\t\t= 640;\n\ts_mods.go.generic.y\t\t\t\t= 480-64;\n\ts_mods.go.width\t\t\t\t\t= 128;\n\ts_mods.go.height\t\t\t\t= 64;\n\ts_mods.go.focuspic\t\t\t\t= ART_FIGHT1;\n\n\t// scan for mods\n\ts_mods.list.generic.type\t\t= MTYPE_SCROLLLIST;\n\ts_mods.list.generic.flags\t\t= QMF_PULSEIFFOCUS|QMF_CENTER_JUSTIFY;\n\ts_mods.list.generic.callback\t= UI_Mods_MenuEvent;\n\ts_mods.list.generic.id\t\t\t= ID_LIST;\n\ts_mods.list.generic.x\t\t\t= 320;\n\ts_mods.list.generic.y\t\t\t= 130;\n\ts_mods.list.width\t\t\t\t= 48;\n\ts_mods.list.height\t\t\t\t= 14;\n\n\tUI_Mods_LoadMods();\n\n\tMenu_AddItem( &s_mods.menu, &s_mods.banner );\n\tMenu_AddItem( &s_mods.menu, &s_mods.framel );\n\tMenu_AddItem( &s_mods.menu, &s_mods.framer );\n\tMenu_AddItem( &s_mods.menu, &s_mods.list );\n\tMenu_AddItem( &s_mods.menu, &s_mods.back );\n\tMenu_AddItem( &s_mods.menu, &s_mods.go );\n}\n\n/*\n=================\nUI_Mods_Cache\n=================\n*/\nvoid UI_ModsMenu_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( ART_BACK0 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK1 );\n\ttrap_R_RegisterShaderNoMip( ART_FIGHT0 );\n\ttrap_R_RegisterShaderNoMip( ART_FIGHT1 );\n\ttrap_R_RegisterShaderNoMip( ART_FRAMEL );\n\ttrap_R_RegisterShaderNoMip( ART_FRAMER );\n}\n\n\n/*\n===============\nUI_ModsMenu\n===============\n*/\nvoid UI_ModsMenu( void ) {\n\tUI_Mods_MenuInit();\n\tUI_PushMenu( &s_mods.menu );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_network.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=======================================================================\n\nNETWORK OPTIONS MENU\n\n=======================================================================\n*/\n\n#include \"ui_local.h\"\n\n\n#define ART_FRAMEL\t\t\t\"menu/art/frame2_l\"\n#define ART_FRAMER\t\t\t\"menu/art/frame1_r\"\n#define ART_BACK0\t\t\t\"menu/art/back_0\"\n#define ART_BACK1\t\t\t\"menu/art/back_1\"\n\n#define ID_GRAPHICS\t\t\t10\n#define ID_DISPLAY\t\t\t11\n#define ID_SOUND\t\t\t12\n#define ID_NETWORK\t\t\t13\n#define ID_RATE\t\t\t\t14\n#define ID_BACK\t\t\t\t15\n\n\nstatic const char *rate_items[] = {\n\t\"<= 28.8K\",\n\t\"33.6K\",\n\t\"56K\",\n\t\"ISDN\",\n\t\"LAN/Cable/xDSL\",\n\t0\n};\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n\n\tmenutext_s\t\tbanner;\n\tmenubitmap_s\tframel;\n\tmenubitmap_s\tframer;\n\n\tmenutext_s\t\tgraphics;\n\tmenutext_s\t\tdisplay;\n\tmenutext_s\t\tsound;\n\tmenutext_s\t\tnetwork;\n\n\tmenulist_s\t\trate;\n\n\tmenubitmap_s\tback;\n} networkOptionsInfo_t;\n\nstatic networkOptionsInfo_t\tnetworkOptionsInfo;\n\n\n/*\n=================\nUI_NetworkOptionsMenu_Event\n=================\n*/\nstatic void UI_NetworkOptionsMenu_Event( void* ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tswitch( ((menucommon_s*)ptr)->id ) {\n\tcase ID_GRAPHICS:\n\t\tUI_PopMenu();\n\t\tUI_GraphicsOptionsMenu();\n\t\tbreak;\n\n\tcase ID_DISPLAY:\n\t\tUI_PopMenu();\n\t\tUI_DisplayOptionsMenu();\n\t\tbreak;\n\n\tcase ID_SOUND:\n\t\tUI_PopMenu();\n\t\tUI_SoundOptionsMenu();\n\t\tbreak;\n\n\tcase ID_NETWORK:\n\t\tbreak;\n\n\tcase ID_RATE:\n\t\tif( networkOptionsInfo.rate.curvalue == 0 ) {\n\t\t\ttrap_Cvar_SetValue( \"rate\", 2500 );\n\t\t}\n\t\telse if( networkOptionsInfo.rate.curvalue == 1 ) {\n\t\t\ttrap_Cvar_SetValue( \"rate\", 3000 );\n\t\t}\n\t\telse if( networkOptionsInfo.rate.curvalue == 2 ) {\n\t\t\ttrap_Cvar_SetValue( \"rate\", 4000 );\n\t\t}\n\t\telse if( networkOptionsInfo.rate.curvalue == 3 ) {\n\t\t\ttrap_Cvar_SetValue( \"rate\", 5000 );\n\t\t}\n\t\telse if( networkOptionsInfo.rate.curvalue == 4 ) {\n\t\t\ttrap_Cvar_SetValue( \"rate\", 25000 );\n\t\t}\n\t\tbreak;\n\n\tcase ID_BACK:\n\t\tUI_PopMenu();\n\t\tbreak;\n\t}\n}\n\n\n/*\n===============\nUI_NetworkOptionsMenu_Init\n===============\n*/\nstatic void UI_NetworkOptionsMenu_Init( void ) {\n\tint\t\ty;\n\tint\t\trate;\n\n\tmemset( &networkOptionsInfo, 0, sizeof(networkOptionsInfo) );\n\n\tUI_NetworkOptionsMenu_Cache();\n\tnetworkOptionsInfo.menu.wrapAround = qtrue;\n\tnetworkOptionsInfo.menu.fullscreen = qtrue;\n\n\tnetworkOptionsInfo.banner.generic.type\t\t= MTYPE_BTEXT;\n\tnetworkOptionsInfo.banner.generic.flags\t\t= QMF_CENTER_JUSTIFY;\n\tnetworkOptionsInfo.banner.generic.x\t\t\t= 320;\n\tnetworkOptionsInfo.banner.generic.y\t\t\t= 16;\n\tnetworkOptionsInfo.banner.string\t\t\t= \"SYSTEM SETUP\";\n\tnetworkOptionsInfo.banner.color\t\t\t\t= color_white;\n\tnetworkOptionsInfo.banner.style\t\t\t\t= UI_CENTER;\n\n\tnetworkOptionsInfo.framel.generic.type\t\t= MTYPE_BITMAP;\n\tnetworkOptionsInfo.framel.generic.name\t\t= ART_FRAMEL;\n\tnetworkOptionsInfo.framel.generic.flags\t\t= QMF_INACTIVE;\n\tnetworkOptionsInfo.framel.generic.x\t\t\t= 0;  \n\tnetworkOptionsInfo.framel.generic.y\t\t\t= 78;\n\tnetworkOptionsInfo.framel.width\t\t\t\t= 256;\n\tnetworkOptionsInfo.framel.height\t\t\t= 329;\n\n\tnetworkOptionsInfo.framer.generic.type\t\t= MTYPE_BITMAP;\n\tnetworkOptionsInfo.framer.generic.name\t\t= ART_FRAMER;\n\tnetworkOptionsInfo.framer.generic.flags\t\t= QMF_INACTIVE;\n\tnetworkOptionsInfo.framer.generic.x\t\t\t= 376;\n\tnetworkOptionsInfo.framer.generic.y\t\t\t= 76;\n\tnetworkOptionsInfo.framer.width\t\t\t\t= 256;\n\tnetworkOptionsInfo.framer.height\t\t\t= 334;\n\n\tnetworkOptionsInfo.graphics.generic.type\t\t= MTYPE_PTEXT;\n\tnetworkOptionsInfo.graphics.generic.flags\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tnetworkOptionsInfo.graphics.generic.id\t\t\t= ID_GRAPHICS;\n\tnetworkOptionsInfo.graphics.generic.callback\t= UI_NetworkOptionsMenu_Event;\n\tnetworkOptionsInfo.graphics.generic.x\t\t\t= 216;\n\tnetworkOptionsInfo.graphics.generic.y\t\t\t= 240 - 2 * PROP_HEIGHT;\n\tnetworkOptionsInfo.graphics.string\t\t\t\t= \"GRAPHICS\";\n\tnetworkOptionsInfo.graphics.style\t\t\t\t= UI_RIGHT;\n\tnetworkOptionsInfo.graphics.color\t\t\t\t= color_red;\n\n\tnetworkOptionsInfo.display.generic.type\t\t\t= MTYPE_PTEXT;\n\tnetworkOptionsInfo.display.generic.flags\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tnetworkOptionsInfo.display.generic.id\t\t\t= ID_DISPLAY;\n\tnetworkOptionsInfo.display.generic.callback\t\t= UI_NetworkOptionsMenu_Event;\n\tnetworkOptionsInfo.display.generic.x\t\t\t= 216;\n\tnetworkOptionsInfo.display.generic.y\t\t\t= 240 - PROP_HEIGHT;\n\tnetworkOptionsInfo.display.string\t\t\t\t= \"DISPLAY\";\n\tnetworkOptionsInfo.display.style\t\t\t\t= UI_RIGHT;\n\tnetworkOptionsInfo.display.color\t\t\t\t= color_red;\n\n\tnetworkOptionsInfo.sound.generic.type\t\t\t= MTYPE_PTEXT;\n\tnetworkOptionsInfo.sound.generic.flags\t\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tnetworkOptionsInfo.sound.generic.id\t\t\t\t= ID_SOUND;\n\tnetworkOptionsInfo.sound.generic.callback\t\t= UI_NetworkOptionsMenu_Event;\n\tnetworkOptionsInfo.sound.generic.x\t\t\t\t= 216;\n\tnetworkOptionsInfo.sound.generic.y\t\t\t\t= 240;\n\tnetworkOptionsInfo.sound.string\t\t\t\t\t= \"SOUND\";\n\tnetworkOptionsInfo.sound.style\t\t\t\t\t= UI_RIGHT;\n\tnetworkOptionsInfo.sound.color\t\t\t\t\t= color_red;\n\n\tnetworkOptionsInfo.network.generic.type\t\t\t= MTYPE_PTEXT;\n\tnetworkOptionsInfo.network.generic.flags\t\t= QMF_RIGHT_JUSTIFY;\n\tnetworkOptionsInfo.network.generic.id\t\t\t= ID_NETWORK;\n\tnetworkOptionsInfo.network.generic.callback\t\t= UI_NetworkOptionsMenu_Event;\n\tnetworkOptionsInfo.network.generic.x\t\t\t= 216;\n\tnetworkOptionsInfo.network.generic.y\t\t\t= 240 + PROP_HEIGHT;\n\tnetworkOptionsInfo.network.string\t\t\t\t= \"NETWORK\";\n\tnetworkOptionsInfo.network.style\t\t\t\t= UI_RIGHT;\n\tnetworkOptionsInfo.network.color\t\t\t\t= color_red;\n\n\ty = 240 - 1 * (BIGCHAR_HEIGHT+2);\n\tnetworkOptionsInfo.rate.generic.type\t\t= MTYPE_SPINCONTROL;\n\tnetworkOptionsInfo.rate.generic.name\t\t= \"Data Rate:\";\n\tnetworkOptionsInfo.rate.generic.flags\t\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\tnetworkOptionsInfo.rate.generic.callback\t= UI_NetworkOptionsMenu_Event;\n\tnetworkOptionsInfo.rate.generic.id\t\t\t= ID_RATE;\n\tnetworkOptionsInfo.rate.generic.x\t\t\t= 400;\n\tnetworkOptionsInfo.rate.generic.y\t\t\t= y;\n\tnetworkOptionsInfo.rate.itemnames\t\t\t= rate_items;\n\n\tnetworkOptionsInfo.back.generic.type\t\t= MTYPE_BITMAP;\n\tnetworkOptionsInfo.back.generic.name\t\t= ART_BACK0;\n\tnetworkOptionsInfo.back.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tnetworkOptionsInfo.back.generic.callback\t= UI_NetworkOptionsMenu_Event;\n\tnetworkOptionsInfo.back.generic.id\t\t\t= ID_BACK;\n\tnetworkOptionsInfo.back.generic.x\t\t\t= 0;\n\tnetworkOptionsInfo.back.generic.y\t\t\t= 480-64;\n\tnetworkOptionsInfo.back.width\t\t\t\t= 128;\n\tnetworkOptionsInfo.back.height\t\t\t\t= 64;\n\tnetworkOptionsInfo.back.focuspic\t\t\t= ART_BACK1;\n\n\tMenu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.banner );\n\tMenu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.framel );\n\tMenu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.framer );\n\tMenu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.graphics );\n\tMenu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.display );\n\tMenu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.sound );\n\tMenu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.network );\n\tMenu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.rate );\n\tMenu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.back );\n\n\trate = trap_Cvar_VariableValue( \"rate\" );\n\tif( rate <= 2500 ) {\n\t\tnetworkOptionsInfo.rate.curvalue = 0;\n\t}\n\telse if( rate <= 3000 ) {\n\t\tnetworkOptionsInfo.rate.curvalue = 1;\n\t}\n\telse if( rate <= 4000 ) {\n\t\tnetworkOptionsInfo.rate.curvalue = 2;\n\t}\n\telse if( rate <= 5000 ) {\n\t\tnetworkOptionsInfo.rate.curvalue = 3;\n\t}\n\telse {\n\t\tnetworkOptionsInfo.rate.curvalue = 4;\n\t}\n}\n\n\n/*\n===============\nUI_NetworkOptionsMenu_Cache\n===============\n*/\nvoid UI_NetworkOptionsMenu_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( ART_FRAMEL );\n\ttrap_R_RegisterShaderNoMip( ART_FRAMER );\n\ttrap_R_RegisterShaderNoMip( ART_BACK0 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK1 );\n}\n\n\n/*\n===============\nUI_NetworkOptionsMenu\n===============\n*/\nvoid UI_NetworkOptionsMenu( void ) {\n\tUI_NetworkOptionsMenu_Init();\n\tUI_PushMenu( &networkOptionsInfo.menu );\n\tMenu_SetCursorToItem( &networkOptionsInfo.menu, &networkOptionsInfo.network );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_options.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n/*\n=======================================================================\n\nSYSTEM CONFIGURATION MENU\n\n=======================================================================\n*/\n\n#include \"ui_local.h\"\n\n\n#define ART_FRAMEL\t\t\t\"menu/art/frame2_l\"\n#define ART_FRAMER\t\t\t\"menu/art/frame1_r\"\n#define ART_BACK0\t\t\t\"menu/art/back_0\"\n#define ART_BACK1\t\t\t\"menu/art/back_1\"\n\n#define ID_GRAPHICS\t\t\t10\n#define ID_DISPLAY\t\t\t11\n#define ID_SOUND\t\t\t12\n#define ID_NETWORK\t\t\t13\n#define ID_BACK\t\t\t\t14\n\n#define VERTICAL_SPACING\t34\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n\n\tmenutext_s\t\tbanner;\n\tmenubitmap_s\tframel;\n\tmenubitmap_s\tframer;\n\n\tmenutext_s\t\tgraphics;\n\tmenutext_s\t\tdisplay;\n\tmenutext_s\t\tsound;\n\tmenutext_s\t\tnetwork;\n\tmenubitmap_s\tback;\n} optionsmenu_t;\n\nstatic optionsmenu_t\ts_options;\n\n\n/*\n=================\nOptions_Event\n=================\n*/\nstatic void Options_Event( void* ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tswitch( ((menucommon_s*)ptr)->id ) {\n\tcase ID_GRAPHICS:\n\t\tUI_GraphicsOptionsMenu();\n\t\tbreak;\n\n\tcase ID_DISPLAY:\n\t\tUI_DisplayOptionsMenu();\n\t\tbreak;\n\n\tcase ID_SOUND:\n\t\tUI_SoundOptionsMenu();\n\t\tbreak;\n\n\tcase ID_NETWORK:\n\t\tUI_NetworkOptionsMenu();\n\t\tbreak;\n\n\tcase ID_BACK:\n\t\tUI_PopMenu();\n\t\tbreak;\n\t}\n}\n\n\n/*\n===============\nSystemConfig_Cache\n===============\n*/\nvoid SystemConfig_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( ART_FRAMEL );\n\ttrap_R_RegisterShaderNoMip( ART_FRAMER );\n\ttrap_R_RegisterShaderNoMip( ART_BACK0 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK1 );\n}\n\n/*\n===============\nOptions_MenuInit\n===============\n*/\nvoid Options_MenuInit( void ) {\n\tint\t\t\t\ty;\n\tuiClientState_t\tcstate;\n\n\tmemset( &s_options, 0, sizeof(optionsmenu_t) );\n\n\tSystemConfig_Cache();\n\ts_options.menu.wrapAround = qtrue;\n\n\ttrap_GetClientState( &cstate );\n\tif ( cstate.connState >= CA_CONNECTED ) {\n\t\ts_options.menu.fullscreen = qfalse;\n\t}\n\telse {\n\t\ts_options.menu.fullscreen = qtrue;\n\t}\n\n\ts_options.banner.generic.type\t= MTYPE_BTEXT;\n\ts_options.banner.generic.flags\t= QMF_CENTER_JUSTIFY;\n\ts_options.banner.generic.x\t\t= 320;\n\ts_options.banner.generic.y\t\t= 16;\n\ts_options.banner.string\t\t    = \"SYSTEM SETUP\";\n\ts_options.banner.color\t\t\t= color_white;\n\ts_options.banner.style\t\t\t= UI_CENTER;\n\n\ts_options.framel.generic.type  = MTYPE_BITMAP;\n\ts_options.framel.generic.name  = ART_FRAMEL;\n\ts_options.framel.generic.flags = QMF_INACTIVE;\n\ts_options.framel.generic.x\t   = 8;  \n\ts_options.framel.generic.y\t   = 76;\n\ts_options.framel.width  \t   = 256;\n\ts_options.framel.height  \t   = 334;\n\n\ts_options.framer.generic.type  = MTYPE_BITMAP;\n\ts_options.framer.generic.name  = ART_FRAMER;\n\ts_options.framer.generic.flags = QMF_INACTIVE;\n\ts_options.framer.generic.x\t   = 376;\n\ts_options.framer.generic.y\t   = 76;\n\ts_options.framer.width  \t   = 256;\n\ts_options.framer.height  \t   = 334;\n\n\ty = 168;\n\ts_options.graphics.generic.type\t\t= MTYPE_PTEXT;\n\ts_options.graphics.generic.flags\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_options.graphics.generic.callback\t= Options_Event;\n\ts_options.graphics.generic.id\t\t= ID_GRAPHICS;\n\ts_options.graphics.generic.x\t\t= 320;\n\ts_options.graphics.generic.y\t\t= y;\n\ts_options.graphics.string\t\t\t= \"GRAPHICS\";\n\ts_options.graphics.color\t\t\t= color_red;\n\ts_options.graphics.style\t\t\t= UI_CENTER;\n\n\ty += VERTICAL_SPACING;\n\ts_options.display.generic.type\t\t= MTYPE_PTEXT;\n\ts_options.display.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_options.display.generic.callback\t= Options_Event;\n\ts_options.display.generic.id\t\t= ID_DISPLAY;\n\ts_options.display.generic.x\t\t\t= 320;\n\ts_options.display.generic.y\t\t\t= y;\n\ts_options.display.string\t\t\t= \"DISPLAY\";\n\ts_options.display.color\t\t\t\t= color_red;\n\ts_options.display.style\t\t\t\t= UI_CENTER;\n\n\ty += VERTICAL_SPACING;\n\ts_options.sound.generic.type\t\t= MTYPE_PTEXT;\n\ts_options.sound.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_options.sound.generic.callback\t= Options_Event;\n\ts_options.sound.generic.id\t\t\t= ID_SOUND;\n\ts_options.sound.generic.x\t\t\t= 320;\n\ts_options.sound.generic.y\t\t\t= y;\n\ts_options.sound.string\t\t\t\t= \"SOUND\";\n\ts_options.sound.color\t\t\t\t= color_red;\n\ts_options.sound.style\t\t\t\t= UI_CENTER;\n\n\ty += VERTICAL_SPACING;\n\ts_options.network.generic.type\t\t= MTYPE_PTEXT;\n\ts_options.network.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_options.network.generic.callback\t= Options_Event;\n\ts_options.network.generic.id\t\t= ID_NETWORK;\n\ts_options.network.generic.x\t\t\t= 320;\n\ts_options.network.generic.y\t\t\t= y;\n\ts_options.network.string\t\t\t= \"NETWORK\";\n\ts_options.network.color\t\t\t\t= color_red;\n\ts_options.network.style\t\t\t\t= UI_CENTER;\n\n\ts_options.back.generic.type\t    = MTYPE_BITMAP;\n\ts_options.back.generic.name     = ART_BACK0;\n\ts_options.back.generic.flags    = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_options.back.generic.callback = Options_Event;\n\ts_options.back.generic.id\t    = ID_BACK;\n\ts_options.back.generic.x\t\t= 0;\n\ts_options.back.generic.y\t\t= 480-64;\n\ts_options.back.width  \t\t    = 128;\n\ts_options.back.height  \t\t    = 64;\n\ts_options.back.focuspic         = ART_BACK1;\n\n\tMenu_AddItem( &s_options.menu, ( void * ) &s_options.banner );\n\tMenu_AddItem( &s_options.menu, ( void * ) &s_options.framel );\n\tMenu_AddItem( &s_options.menu, ( void * ) &s_options.framer );\n\tMenu_AddItem( &s_options.menu, ( void * ) &s_options.graphics );\n\tMenu_AddItem( &s_options.menu, ( void * ) &s_options.display );\n\tMenu_AddItem( &s_options.menu, ( void * ) &s_options.sound );\n\tMenu_AddItem( &s_options.menu, ( void * ) &s_options.network );\n\tMenu_AddItem( &s_options.menu, ( void * ) &s_options.back );\n}\n\n\n/*\n===============\nUI_SystemConfigMenu\n===============\n*/\nvoid UI_SystemConfigMenu( void ) {\n\tOptions_MenuInit();\n\tUI_PushMenu ( &s_options.menu );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_playermodel.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#include \"ui_local.h\"\n\n#define MODEL_BACK0\t\t\t\"menu/art/back_0\"\n#define MODEL_BACK1\t\t\t\"menu/art/back_1\"\n#define MODEL_SELECT\t\t\"menu/art/opponents_select\"\n#define MODEL_SELECTED\t\t\"menu/art/opponents_selected\"\n#define MODEL_FRAMEL\t\t\"menu/art/frame1_l\"\n#define MODEL_FRAMER\t\t\"menu/art/frame1_r\"\n#define MODEL_PORTS\t\t\t\"menu/art/player_models_ports\"\n#define MODEL_ARROWS\t\t\"menu/art/gs_arrows_0\"\n#define MODEL_ARROWSL\t\t\"menu/art/gs_arrows_l\"\n#define MODEL_ARROWSR\t\t\"menu/art/gs_arrows_r\"\n\n#define LOW_MEMORY\t\t\t(5 * 1024 * 1024)\n\nstatic char* playermodel_artlist[] =\n{\n\tMODEL_BACK0,\t\n\tMODEL_BACK1,\t\n\tMODEL_SELECT,\n\tMODEL_SELECTED,\n\tMODEL_FRAMEL,\n\tMODEL_FRAMER,\n\tMODEL_PORTS,\t\n\tMODEL_ARROWS,\n\tMODEL_ARROWSL,\n\tMODEL_ARROWSR,\n\tNULL\n};\n\n#define PLAYERGRID_COLS\t\t4\n#define PLAYERGRID_ROWS\t\t4\n#define MAX_MODELSPERPAGE\t(PLAYERGRID_ROWS*PLAYERGRID_COLS)\n\n#define MAX_PLAYERMODELS\t256\n\n#define ID_PLAYERPIC0\t\t0\n#define ID_PLAYERPIC1\t\t1\n#define ID_PLAYERPIC2\t\t2\n#define ID_PLAYERPIC3\t\t3\n#define ID_PLAYERPIC4\t\t4\n#define ID_PLAYERPIC5\t\t5\n#define ID_PLAYERPIC6\t\t6\n#define ID_PLAYERPIC7\t\t7\n#define ID_PLAYERPIC8\t\t8\n#define ID_PLAYERPIC9\t\t9\n#define ID_PLAYERPIC10\t\t10\n#define ID_PLAYERPIC11\t\t11\n#define ID_PLAYERPIC12\t\t12\n#define ID_PLAYERPIC13\t\t13\n#define ID_PLAYERPIC14\t\t14\n#define ID_PLAYERPIC15\t\t15\n#define ID_PREVPAGE\t\t\t100\n#define ID_NEXTPAGE\t\t\t101\n#define ID_BACK\t\t\t\t102\n\ntypedef struct\n{\n\tmenuframework_s\tmenu;\n\tmenubitmap_s\tpics[MAX_MODELSPERPAGE];\n\tmenubitmap_s\tpicbuttons[MAX_MODELSPERPAGE];\n\tmenubitmap_s\tframel;\n\tmenubitmap_s\tframer;\n\tmenubitmap_s\tports;\n\tmenutext_s\t\tbanner;\n\tmenubitmap_s\tback;\n\tmenubitmap_s\tplayer;\n\tmenubitmap_s\tarrows;\n\tmenubitmap_s\tleft;\n\tmenubitmap_s\tright;\n\tmenutext_s\t\tmodelname;\n\tmenutext_s\t\tskinname;\n\tmenutext_s\t\tplayername;\n\tplayerInfo_t\tplayerinfo;\n\tint\t\t\t\tnummodels;\n\tchar\t\t\tmodelnames[MAX_PLAYERMODELS][128];\n\tint\t\t\t\tmodelpage;\n\tint\t\t\t\tnumpages;\n\tchar\t\t\tmodelskin[64];\n\tint\t\t\t\tselectedmodel;\n} playermodel_t;\n\nstatic playermodel_t s_playermodel;\n\n/*\n=================\nPlayerModel_UpdateGrid\n=================\n*/\nstatic void PlayerModel_UpdateGrid( void )\n{\n\tint\ti;\n    int\tj;\n\n\tj = s_playermodel.modelpage * MAX_MODELSPERPAGE;\n\tfor (i=0; i<PLAYERGRID_ROWS*PLAYERGRID_COLS; i++,j++)\n\t{\n\t\tif (j < s_playermodel.nummodels)\n\t\t{ \n\t\t\t// model/skin portrait\n \t\t\ts_playermodel.pics[i].generic.name         = s_playermodel.modelnames[j];\n\t\t\ts_playermodel.picbuttons[i].generic.flags &= ~QMF_INACTIVE;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// dead slot\n \t\t\ts_playermodel.pics[i].generic.name         = NULL;\n\t\t\ts_playermodel.picbuttons[i].generic.flags |= QMF_INACTIVE;\n\t\t}\n\n \t\ts_playermodel.pics[i].generic.flags       &= ~QMF_HIGHLIGHT;\n \t\ts_playermodel.pics[i].shader               = 0;\n \t\ts_playermodel.picbuttons[i].generic.flags |= QMF_PULSEIFFOCUS;\n\t}\n\n\tif (s_playermodel.selectedmodel/MAX_MODELSPERPAGE == s_playermodel.modelpage)\n\t{\n\t\t// set selected model\n\t\ti = s_playermodel.selectedmodel % MAX_MODELSPERPAGE;\n\n\t\ts_playermodel.pics[i].generic.flags       |= QMF_HIGHLIGHT;\n\t\ts_playermodel.picbuttons[i].generic.flags &= ~QMF_PULSEIFFOCUS;\n\t}\n\n\tif (s_playermodel.numpages > 1)\n\t{\n\t\tif (s_playermodel.modelpage > 0)\n\t\t\ts_playermodel.left.generic.flags &= ~QMF_INACTIVE;\n\t\telse\n\t\t\ts_playermodel.left.generic.flags |= QMF_INACTIVE;\n\n\t\tif (s_playermodel.modelpage < s_playermodel.numpages-1)\n\t\t\ts_playermodel.right.generic.flags &= ~QMF_INACTIVE;\n\t\telse\n\t\t\ts_playermodel.right.generic.flags |= QMF_INACTIVE;\n\t}\n\telse\n\t{\n\t\t// hide left/right markers\n\t\ts_playermodel.left.generic.flags |= QMF_INACTIVE;\n\t\ts_playermodel.right.generic.flags |= QMF_INACTIVE;\n\t}\n}\n\n/*\n=================\nPlayerModel_UpdateModel\n=================\n*/\nstatic void PlayerModel_UpdateModel( void )\n{\n\tvec3_t\tviewangles;\n\tvec3_t\tmoveangles;\n\n\tmemset( &s_playermodel.playerinfo, 0, sizeof(playerInfo_t) );\n\t\n\tviewangles[YAW]   = 180 - 30;\n\tviewangles[PITCH] = 0;\n\tviewangles[ROLL]  = 0;\n\tVectorClear( moveangles );\n\n\tUI_PlayerInfo_SetModel( &s_playermodel.playerinfo, s_playermodel.modelskin );\n\tUI_PlayerInfo_SetInfo( &s_playermodel.playerinfo, LEGS_IDLE, TORSO_STAND, viewangles, moveangles, WP_MACHINEGUN, qfalse );\n}\n\n/*\n=================\nPlayerModel_SaveChanges\n=================\n*/\nstatic void PlayerModel_SaveChanges( void )\n{\n\ttrap_Cvar_Set( \"model\", s_playermodel.modelskin );\n\ttrap_Cvar_Set( \"headmodel\", s_playermodel.modelskin );\n\ttrap_Cvar_Set( \"team_model\", s_playermodel.modelskin );\n\ttrap_Cvar_Set( \"team_headmodel\", s_playermodel.modelskin );\n}\n\n/*\n=================\nPlayerModel_MenuEvent\n=================\n*/\nstatic void PlayerModel_MenuEvent( void* ptr, int event )\n{\n\tif (event != QM_ACTIVATED)\n\t\treturn;\n\n\tswitch (((menucommon_s*)ptr)->id)\n\t{\n\t\tcase ID_PREVPAGE:\n\t\t\tif (s_playermodel.modelpage > 0)\n\t\t\t{\n\t\t\t\ts_playermodel.modelpage--;\n\t\t\t\tPlayerModel_UpdateGrid();\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase ID_NEXTPAGE:\n\t\t\tif (s_playermodel.modelpage < s_playermodel.numpages-1)\n\t\t\t{\n\t\t\t\ts_playermodel.modelpage++;\n\t\t\t\tPlayerModel_UpdateGrid();\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase ID_BACK:\n\t\t\tPlayerModel_SaveChanges();\n\t\t\tUI_PopMenu();\n\t\t\tbreak;\n\t}\n}\n\n/*\n=================\nPlayerModel_MenuKey\n=================\n*/\nstatic sfxHandle_t PlayerModel_MenuKey( int key )\n{\n\tmenucommon_s*\tm;\n\tint\t\t\t\tpicnum;\n\n\tswitch (key)\n\t{\n\t\tcase K_KP_LEFTARROW:\n\t\tcase K_LEFTARROW:\n\t\t\tm = Menu_ItemAtCursor(&s_playermodel.menu);\n\t\t\tpicnum = m->id - ID_PLAYERPIC0;\n\t\t\tif (picnum >= 0 && picnum <= 15)\n\t\t\t{\n\t\t\t\tif (picnum > 0)\n\t\t\t\t{\n\t\t\t\t\tMenu_SetCursor(&s_playermodel.menu,s_playermodel.menu.cursor-1);\n\t\t\t\t\treturn (menu_move_sound);\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\telse if (s_playermodel.modelpage > 0)\n\t\t\t\t{\n\t\t\t\t\ts_playermodel.modelpage--;\n\t\t\t\t\tMenu_SetCursor(&s_playermodel.menu,s_playermodel.menu.cursor+15);\n\t\t\t\t\tPlayerModel_UpdateGrid();\n\t\t\t\t\treturn (menu_move_sound);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\treturn (menu_buzz_sound);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase K_KP_RIGHTARROW:\n\t\tcase K_RIGHTARROW:\n\t\t\tm = Menu_ItemAtCursor(&s_playermodel.menu);\n\t\t\tpicnum = m->id - ID_PLAYERPIC0;\n\t\t\tif (picnum >= 0 && picnum <= 15)\n\t\t\t{\n\t\t\t\tif ((picnum < 15) && (s_playermodel.modelpage*MAX_MODELSPERPAGE + picnum+1 < s_playermodel.nummodels))\n\t\t\t\t{\n\t\t\t\t\tMenu_SetCursor(&s_playermodel.menu,s_playermodel.menu.cursor+1);\n\t\t\t\t\treturn (menu_move_sound);\n\t\t\t\t}\t\t\t\t\t\n\t\t\t\telse if ((picnum == 15) && (s_playermodel.modelpage < s_playermodel.numpages-1))\n\t\t\t\t{\n\t\t\t\t\ts_playermodel.modelpage++;\n\t\t\t\t\tMenu_SetCursor(&s_playermodel.menu,s_playermodel.menu.cursor-15);\n\t\t\t\t\tPlayerModel_UpdateGrid();\n\t\t\t\t\treturn (menu_move_sound);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\treturn (menu_buzz_sound);\n\t\t\t}\n\t\t\tbreak;\n\t\t\t\n\t\tcase K_MOUSE2:\n\t\tcase K_ESCAPE:\n\t\t\tPlayerModel_SaveChanges();\n\t\t\tbreak;\n\t}\n\n\treturn ( Menu_DefaultKey( &s_playermodel.menu, key ) );\n}\n\n/*\n=================\nPlayerModel_PicEvent\n=================\n*/\nstatic void PlayerModel_PicEvent( void* ptr, int event )\n{\n\tint\t\t\t\tmodelnum;\n\tint\t\t\t\tmaxlen;\n\tchar*\t\t\tbuffptr;\n\tchar*\t\t\tpdest;\n\tint\t\t\t\ti;\n\n\tif (event != QM_ACTIVATED)\n\t\treturn;\n\n\tfor (i=0; i<PLAYERGRID_ROWS*PLAYERGRID_COLS; i++)\n\t{\n\t\t// reset\n \t\ts_playermodel.pics[i].generic.flags       &= ~QMF_HIGHLIGHT;\n \t\ts_playermodel.picbuttons[i].generic.flags |= QMF_PULSEIFFOCUS;\n\t}\n\n\t// set selected\n\ti = ((menucommon_s*)ptr)->id - ID_PLAYERPIC0;\n\ts_playermodel.pics[i].generic.flags       |= QMF_HIGHLIGHT;\n\ts_playermodel.picbuttons[i].generic.flags &= ~QMF_PULSEIFFOCUS;\n\n\t// get model and strip icon_\n\tmodelnum = s_playermodel.modelpage*MAX_MODELSPERPAGE + i;\n\tbuffptr  = s_playermodel.modelnames[modelnum] + strlen(\"models/players/\");\n\tpdest    = strstr(buffptr,\"icon_\");\n\tif (pdest)\n\t{\n\t\t// track the whole model/skin name\n\t\tQ_strncpyz(s_playermodel.modelskin,buffptr,pdest-buffptr+1);\n\t\tstrcat(s_playermodel.modelskin,pdest + 5);\n\n\t\t// seperate the model name\n\t\tmaxlen = pdest-buffptr;\n\t\tif (maxlen > 16)\n\t\t\tmaxlen = 16;\n\t\tQ_strncpyz( s_playermodel.modelname.string, buffptr, maxlen );\n\t\tQ_strupr( s_playermodel.modelname.string );\n\n\t\t// seperate the skin name\n\t\tmaxlen = strlen(pdest+5)+1;\n\t\tif (maxlen > 16)\n\t\t\tmaxlen = 16;\n\t\tQ_strncpyz( s_playermodel.skinname.string, pdest+5, maxlen );\n\t\tQ_strupr( s_playermodel.skinname.string );\n\n\t\ts_playermodel.selectedmodel = modelnum;\n\n\t\tif( trap_MemoryRemaining() > LOW_MEMORY ) {\n\t\t\tPlayerModel_UpdateModel();\n\t\t}\n\t}\n}\n\n/*\n=================\nPlayerModel_DrawPlayer\n=================\n*/\nstatic void PlayerModel_DrawPlayer( void *self )\n{\n\tmenubitmap_s*\tb;\n\n\tb = (menubitmap_s*) self;\n\n\tif( trap_MemoryRemaining() <= LOW_MEMORY ) {\n\t\tUI_DrawProportionalString( b->generic.x, b->generic.y + b->height / 2, \"LOW MEMORY\", UI_LEFT, color_red );\n\t\treturn;\n\t}\n\n\tUI_DrawPlayer( b->generic.x, b->generic.y, b->width, b->height, &s_playermodel.playerinfo, uis.realtime/2 );\n}\n\n/*\n=================\nPlayerModel_BuildList\n=================\n*/\nstatic void PlayerModel_BuildList( void )\n{\n\tint\t\tnumdirs;\n\tint\t\tnumfiles;\n\tchar\tdirlist[2048];\n\tchar\tfilelist[2048];\n\tchar\tskinname[64];\n\tchar*\tdirptr;\n\tchar*\tfileptr;\n\tint\t\ti;\n\tint\t\tj;\n\tint\t\tdirlen;\n\tint\t\tfilelen;\n\tqboolean precache;\n\n\tprecache = trap_Cvar_VariableValue(\"com_buildscript\");\n\n\ts_playermodel.modelpage = 0;\n\ts_playermodel.nummodels = 0;\n\n\t// iterate directory of all player models\n\tnumdirs = trap_FS_GetFileList(\"models/players\", \"/\", dirlist, 2048 );\n\tdirptr  = dirlist;\n\tfor (i=0; i<numdirs && s_playermodel.nummodels < MAX_PLAYERMODELS; i++,dirptr+=dirlen+1)\n\t{\n\t\tdirlen = strlen(dirptr);\n\t\t\n\t\tif (dirlen && dirptr[dirlen-1]=='/') dirptr[dirlen-1]='\\0';\n\n\t\tif (!strcmp(dirptr,\".\") || !strcmp(dirptr,\"..\"))\n\t\t\tcontinue;\n\t\t\t\n\t\t// iterate all skin files in directory\n\t\tnumfiles = trap_FS_GetFileList( va(\"models/players/%s\",dirptr), \"tga\", filelist, 2048 );\n\t\tfileptr  = filelist;\n\t\tfor (j=0; j<numfiles && s_playermodel.nummodels < MAX_PLAYERMODELS;j++,fileptr+=filelen+1)\n\t\t{\n\t\t\tfilelen = strlen(fileptr);\n\n\t\t\tCOM_StripExtension(fileptr,skinname);\n\n\t\t\t// look for icon_????\n\t\t\tif (!Q_stricmpn(skinname,\"icon_\",5))\n\t\t\t{\n\t\t\t\tCom_sprintf( s_playermodel.modelnames[s_playermodel.nummodels++],\n\t\t\t\t\tsizeof( s_playermodel.modelnames[s_playermodel.nummodels] ),\n\t\t\t\t\t\"models/players/%s/%s\", dirptr, skinname );\n\t\t\t\t//if (s_playermodel.nummodels >= MAX_PLAYERMODELS)\n\t\t\t\t//\treturn;\n\t\t\t}\n\n\t\t\tif( precache ) {\n\t\t\t\ttrap_S_RegisterSound( va( \"sound/player/announce/%s_wins.wav\", skinname), qfalse );\n\t\t\t}\n\t\t}\n\t}\t\n\n\t//APSFIXME - Degenerate no models case\n\n\ts_playermodel.numpages = s_playermodel.nummodels/MAX_MODELSPERPAGE;\n\tif (s_playermodel.nummodels % MAX_MODELSPERPAGE)\n\t\ts_playermodel.numpages++;\n}\n\n/*\n=================\nPlayerModel_SetMenuItems\n=================\n*/\nstatic void PlayerModel_SetMenuItems( void )\n{\n\tint\t\t\t\ti;\n\tint\t\t\t\tmaxlen;\n\tchar\t\t\tmodelskin[64];\n\tchar*\t\t\tbuffptr;\n\tchar*\t\t\tpdest;\n\n\t// name\n\ttrap_Cvar_VariableStringBuffer( \"name\", s_playermodel.playername.string, 16 );\n\tQ_CleanStr( s_playermodel.playername.string );\n\n\t// model\n\ttrap_Cvar_VariableStringBuffer( \"model\", s_playermodel.modelskin, 64 );\n\t\n\t// find model in our list\n\tfor (i=0; i<s_playermodel.nummodels; i++)\n\t{\n\t\t// strip icon_\n\t\tbuffptr  = s_playermodel.modelnames[i] + strlen(\"models/players/\");\n\t\tpdest    = strstr(buffptr,\"icon_\");\n\t\tif (pdest)\n\t\t{\n\t\t\tQ_strncpyz(modelskin,buffptr,pdest-buffptr+1);\n\t\t\tstrcat(modelskin,pdest + 5);\n\t\t}\n\t\telse\n\t\t\tcontinue;\n\n\t\tif (!Q_stricmp( s_playermodel.modelskin, modelskin ))\n\t\t{\n\t\t\t// found pic, set selection here\t\t\n\t\t\ts_playermodel.selectedmodel = i;\n\t\t\ts_playermodel.modelpage     = i/MAX_MODELSPERPAGE;\n\n\t\t\t// seperate the model name\n\t\t\tmaxlen = pdest-buffptr;\n\t\t\tif (maxlen > 16)\n\t\t\t\tmaxlen = 16;\n\t\t\tQ_strncpyz( s_playermodel.modelname.string, buffptr, maxlen );\n\t\t\tQ_strupr( s_playermodel.modelname.string );\n\n\t\t\t// seperate the skin name\n\t\t\tmaxlen = strlen(pdest+5)+1;\n\t\t\tif (maxlen > 16)\n\t\t\t\tmaxlen = 16;\n\t\t\tQ_strncpyz( s_playermodel.skinname.string, pdest+5, maxlen );\n\t\t\tQ_strupr( s_playermodel.skinname.string );\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/*\n=================\nPlayerModel_MenuInit\n=================\n*/\nstatic void PlayerModel_MenuInit( void )\n{\n\tint\t\t\ti;\n\tint\t\t\tj;\n\tint\t\t\tk;\n\tint\t\t\tx;\n\tint\t\t\ty;\n\tstatic char\tplayername[32];\n\tstatic char\tmodelname[32];\n\tstatic char\tskinname[32];\n\n\t// zero set all our globals\n\tmemset( &s_playermodel, 0 ,sizeof(playermodel_t) );\n\n\tPlayerModel_Cache();\n\n\ts_playermodel.menu.key        = PlayerModel_MenuKey;\n\ts_playermodel.menu.wrapAround = qtrue;\n\ts_playermodel.menu.fullscreen = qtrue;\n\n\ts_playermodel.banner.generic.type  = MTYPE_BTEXT;\n\ts_playermodel.banner.generic.x     = 320;\n\ts_playermodel.banner.generic.y     = 16;\n\ts_playermodel.banner.string        = \"PLAYER MODEL\";\n\ts_playermodel.banner.color         = color_white;\n\ts_playermodel.banner.style         = UI_CENTER;\n\n\ts_playermodel.framel.generic.type  = MTYPE_BITMAP;\n\ts_playermodel.framel.generic.name  = MODEL_FRAMEL;\n\ts_playermodel.framel.generic.flags = QMF_LEFT_JUSTIFY|QMF_INACTIVE;\n\ts_playermodel.framel.generic.x     = 0;\n\ts_playermodel.framel.generic.y     = 78;\n\ts_playermodel.framel.width         = 256;\n\ts_playermodel.framel.height        = 329;\n\n\ts_playermodel.framer.generic.type  = MTYPE_BITMAP;\n\ts_playermodel.framer.generic.name  = MODEL_FRAMER;\n\ts_playermodel.framer.generic.flags = QMF_LEFT_JUSTIFY|QMF_INACTIVE;\n\ts_playermodel.framer.generic.x     = 376;\n\ts_playermodel.framer.generic.y     = 76;\n\ts_playermodel.framer.width         = 256;\n\ts_playermodel.framer.height        = 334;\n\n\ts_playermodel.ports.generic.type  = MTYPE_BITMAP;\n\ts_playermodel.ports.generic.name  = MODEL_PORTS;\n\ts_playermodel.ports.generic.flags = QMF_LEFT_JUSTIFY|QMF_INACTIVE;\n\ts_playermodel.ports.generic.x     = 50;\n\ts_playermodel.ports.generic.y     = 59;\n\ts_playermodel.ports.width         = 274;\n\ts_playermodel.ports.height        = 274;\n\n\ty =\t59;\n\tfor (i=0,k=0; i<PLAYERGRID_ROWS; i++)\n\t{\n\t\tx =\t50;\n\t\tfor (j=0; j<PLAYERGRID_COLS; j++,k++)\n\t\t{\n\t\t\ts_playermodel.pics[k].generic.type\t   = MTYPE_BITMAP;\n\t\t\ts_playermodel.pics[k].generic.flags    = QMF_LEFT_JUSTIFY|QMF_INACTIVE;\n\t\t\ts_playermodel.pics[k].generic.x\t\t   = x;\n\t\t\ts_playermodel.pics[k].generic.y\t\t   = y;\n\t\t\ts_playermodel.pics[k].width  \t\t   = 64;\n\t\t\ts_playermodel.pics[k].height  \t\t   = 64;\n\t\t\ts_playermodel.pics[k].focuspic         = MODEL_SELECTED;\n\t\t\ts_playermodel.pics[k].focuscolor       = colorRed;\n\n\t\t\ts_playermodel.picbuttons[k].generic.type\t = MTYPE_BITMAP;\n\t\t\ts_playermodel.picbuttons[k].generic.flags    = QMF_LEFT_JUSTIFY|QMF_NODEFAULTINIT|QMF_PULSEIFFOCUS;\n\t\t\ts_playermodel.picbuttons[k].generic.id\t     = ID_PLAYERPIC0+k;\n\t\t\ts_playermodel.picbuttons[k].generic.callback = PlayerModel_PicEvent;\n\t\t\ts_playermodel.picbuttons[k].generic.x    \t = x - 16;\n\t\t\ts_playermodel.picbuttons[k].generic.y\t\t = y - 16;\n\t\t\ts_playermodel.picbuttons[k].generic.left\t = x;\n\t\t\ts_playermodel.picbuttons[k].generic.top\t\t = y;\n\t\t\ts_playermodel.picbuttons[k].generic.right\t = x + 64;\n\t\t\ts_playermodel.picbuttons[k].generic.bottom   = y + 64;\n\t\t\ts_playermodel.picbuttons[k].width  \t\t     = 128;\n\t\t\ts_playermodel.picbuttons[k].height  \t\t = 128;\n\t\t\ts_playermodel.picbuttons[k].focuspic  \t\t = MODEL_SELECT;\n\t\t\ts_playermodel.picbuttons[k].focuscolor  \t = colorRed;\n\n\t\t\tx += 64+6;\n\t\t}\n\t\ty += 64+6;\n\t}\n\n\ts_playermodel.playername.generic.type  = MTYPE_PTEXT;\n\ts_playermodel.playername.generic.flags = QMF_CENTER_JUSTIFY|QMF_INACTIVE;\n\ts_playermodel.playername.generic.x\t   = 320;\n\ts_playermodel.playername.generic.y\t   = 440;\n\ts_playermodel.playername.string\t       = playername;\n\ts_playermodel.playername.style\t\t   = UI_CENTER;\n\ts_playermodel.playername.color         = text_color_normal;\n\n\ts_playermodel.modelname.generic.type  = MTYPE_PTEXT;\n\ts_playermodel.modelname.generic.flags = QMF_CENTER_JUSTIFY|QMF_INACTIVE;\n\ts_playermodel.modelname.generic.x\t  = 497;\n\ts_playermodel.modelname.generic.y\t  = 54;\n\ts_playermodel.modelname.string\t      = modelname;\n\ts_playermodel.modelname.style\t\t  = UI_CENTER;\n\ts_playermodel.modelname.color         = text_color_normal;\n\n\ts_playermodel.skinname.generic.type   = MTYPE_PTEXT;\n\ts_playermodel.skinname.generic.flags  = QMF_CENTER_JUSTIFY|QMF_INACTIVE;\n\ts_playermodel.skinname.generic.x\t  = 497;\n\ts_playermodel.skinname.generic.y\t  = 394;\n\ts_playermodel.skinname.string\t      = skinname;\n\ts_playermodel.skinname.style\t\t  = UI_CENTER;\n\ts_playermodel.skinname.color          = text_color_normal;\n\n\ts_playermodel.player.generic.type      = MTYPE_BITMAP;\n\ts_playermodel.player.generic.flags     = QMF_INACTIVE;\n\ts_playermodel.player.generic.ownerdraw = PlayerModel_DrawPlayer;\n\ts_playermodel.player.generic.x\t       = 400;\n\ts_playermodel.player.generic.y\t       = -40;\n\ts_playermodel.player.width\t           = 32*10;\n\ts_playermodel.player.height            = 56*10;\n\n\ts_playermodel.arrows.generic.type\t\t= MTYPE_BITMAP;\n\ts_playermodel.arrows.generic.name\t\t= MODEL_ARROWS;\n\ts_playermodel.arrows.generic.flags\t\t= QMF_INACTIVE;\n\ts_playermodel.arrows.generic.x\t\t\t= 125;\n\ts_playermodel.arrows.generic.y\t\t\t= 340;\n\ts_playermodel.arrows.width\t\t\t\t= 128;\n\ts_playermodel.arrows.height\t\t\t\t= 32;\n\n\ts_playermodel.left.generic.type\t\t\t= MTYPE_BITMAP;\n\ts_playermodel.left.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_playermodel.left.generic.callback\t\t= PlayerModel_MenuEvent;\n\ts_playermodel.left.generic.id\t\t\t= ID_PREVPAGE;\n\ts_playermodel.left.generic.x\t\t\t= 125;\n\ts_playermodel.left.generic.y\t\t\t= 340;\n\ts_playermodel.left.width  \t\t\t\t= 64;\n\ts_playermodel.left.height  \t\t\t\t= 32;\n\ts_playermodel.left.focuspic\t\t\t\t= MODEL_ARROWSL;\n\n\ts_playermodel.right.generic.type\t    = MTYPE_BITMAP;\n\ts_playermodel.right.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_playermodel.right.generic.callback\t= PlayerModel_MenuEvent;\n\ts_playermodel.right.generic.id\t\t\t= ID_NEXTPAGE;\n\ts_playermodel.right.generic.x\t\t\t= 125+61;\n\ts_playermodel.right.generic.y\t\t\t= 340;\n\ts_playermodel.right.width  \t\t\t\t= 64;\n\ts_playermodel.right.height  \t\t    = 32;\n\ts_playermodel.right.focuspic\t\t\t= MODEL_ARROWSR;\n\n\ts_playermodel.back.generic.type\t    = MTYPE_BITMAP;\n\ts_playermodel.back.generic.name     = MODEL_BACK0;\n\ts_playermodel.back.generic.flags    = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_playermodel.back.generic.callback = PlayerModel_MenuEvent;\n\ts_playermodel.back.generic.id\t    = ID_BACK;\n\ts_playermodel.back.generic.x\t\t= 0;\n\ts_playermodel.back.generic.y\t\t= 480-64;\n\ts_playermodel.back.width  \t\t    = 128;\n\ts_playermodel.back.height  \t\t    = 64;\n\ts_playermodel.back.focuspic         = MODEL_BACK1;\n\n\tMenu_AddItem( &s_playermodel.menu,\t&s_playermodel.banner );\n\tMenu_AddItem( &s_playermodel.menu,\t&s_playermodel.framel );\n\tMenu_AddItem( &s_playermodel.menu,\t&s_playermodel.framer );\n\tMenu_AddItem( &s_playermodel.menu,\t&s_playermodel.ports );\n\tMenu_AddItem( &s_playermodel.menu,\t&s_playermodel.playername );\n\tMenu_AddItem( &s_playermodel.menu,\t&s_playermodel.modelname );\n\tMenu_AddItem( &s_playermodel.menu,\t&s_playermodel.skinname );\n\n\tfor (i=0; i<MAX_MODELSPERPAGE; i++)\n\t{\n\t\tMenu_AddItem( &s_playermodel.menu,\t&s_playermodel.pics[i] );\n\t\tMenu_AddItem( &s_playermodel.menu,\t&s_playermodel.picbuttons[i] );\n\t}\n\n\tMenu_AddItem( &s_playermodel.menu,\t&s_playermodel.player );\n\tMenu_AddItem( &s_playermodel.menu,\t&s_playermodel.arrows );\n\tMenu_AddItem( &s_playermodel.menu,\t&s_playermodel.left );\n\tMenu_AddItem( &s_playermodel.menu,\t&s_playermodel.right );\n\tMenu_AddItem( &s_playermodel.menu,\t&s_playermodel.back );\n\n\t// find all available models\n//\tPlayerModel_BuildList();\n\n\t// set initial states\n\tPlayerModel_SetMenuItems();\n\n\t// update user interface\n\tPlayerModel_UpdateGrid();\n\tPlayerModel_UpdateModel();\n}\n\n/*\n=================\nPlayerModel_Cache\n=================\n*/\nvoid PlayerModel_Cache( void )\n{\n\tint\ti;\n\n\tfor( i = 0; playermodel_artlist[i]; i++ ) {\n\t\ttrap_R_RegisterShaderNoMip( playermodel_artlist[i] );\n\t}\n\n\tPlayerModel_BuildList();\n\tfor( i = 0; i < s_playermodel.nummodels; i++ ) {\n\t\ttrap_R_RegisterShaderNoMip( s_playermodel.modelnames[i] );\n\t}\n}\n\nvoid UI_PlayerModelMenu(void)\n{\n\tPlayerModel_MenuInit();\n\n\tUI_PushMenu( &s_playermodel.menu );\n\n\tMenu_SetCursorToItem( &s_playermodel.menu, &s_playermodel.pics[s_playermodel.selectedmodel % MAX_MODELSPERPAGE] );\n}\n\n\n"
  },
  {
    "path": "code/q3_ui/ui_players.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// ui_players.c\n\n#include \"ui_local.h\"\n\n\n#define UI_TIMER_GESTURE\t\t2300\n#define UI_TIMER_JUMP\t\t\t1000\n#define UI_TIMER_LAND\t\t\t130\n#define UI_TIMER_WEAPON_SWITCH\t300\n#define UI_TIMER_ATTACK\t\t\t500\n#define\tUI_TIMER_MUZZLE_FLASH\t20\n#define\tUI_TIMER_WEAPON_DELAY\t250\n\n#define JUMP_HEIGHT\t\t\t\t56\n\n#define SWINGSPEED\t\t\t\t0.3f\n\n#define SPIN_SPEED\t\t\t\t0.9f\n#define COAST_TIME\t\t\t\t1000\n\n\nstatic int\t\t\tdp_realtime;\nstatic float\t\tjumpHeight;\n\n\n/*\n===============\nUI_PlayerInfo_SetWeapon\n===============\n*/\nstatic void UI_PlayerInfo_SetWeapon( playerInfo_t *pi, weapon_t weaponNum ) {\n\tgitem_t *\titem;\n\tchar\t\tpath[MAX_QPATH];\n\n\tpi->currentWeapon = weaponNum;\ntryagain:\n\tpi->realWeapon = weaponNum;\n\tpi->weaponModel = 0;\n\tpi->barrelModel = 0;\n\tpi->flashModel = 0;\n\n\tif ( weaponNum == WP_NONE ) {\n\t\treturn;\n\t}\n\n\tfor ( item = bg_itemlist + 1; item->classname ; item++ ) {\n\t\tif ( item->giType != IT_WEAPON ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( item->giTag == weaponNum ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif ( item->classname ) {\n\t\tpi->weaponModel = trap_R_RegisterModel( item->world_model[0] );\n\t}\n\n\tif( pi->weaponModel == 0 ) {\n\t\tif( weaponNum == WP_MACHINEGUN ) {\n\t\t\tweaponNum = WP_NONE;\n\t\t\tgoto tryagain;\n\t\t}\n\t\tweaponNum = WP_MACHINEGUN;\n\t\tgoto tryagain;\n\t}\n\n\tif ( weaponNum == WP_MACHINEGUN || weaponNum == WP_GAUNTLET || weaponNum == WP_BFG ) {\n\t\tstrcpy( path, item->world_model[0] );\n\t\tCOM_StripExtension( path, path );\n\t\tstrcat( path, \"_barrel.md3\" );\n\t\tpi->barrelModel = trap_R_RegisterModel( path );\n\t}\n\n\tstrcpy( path, item->world_model[0] );\n\tCOM_StripExtension( path, path );\n\tstrcat( path, \"_flash.md3\" );\n\tpi->flashModel = trap_R_RegisterModel( path );\n\n\tswitch( weaponNum ) {\n\tcase WP_GAUNTLET:\n\t\tMAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 );\n\t\tbreak;\n\n\tcase WP_MACHINEGUN:\n\t\tMAKERGB( pi->flashDlightColor, 1, 1, 0 );\n\t\tbreak;\n\n\tcase WP_SHOTGUN:\n\t\tMAKERGB( pi->flashDlightColor, 1, 1, 0 );\n\t\tbreak;\n\n\tcase WP_GRENADE_LAUNCHER:\n\t\tMAKERGB( pi->flashDlightColor, 1, 0.7f, 0.5f );\n\t\tbreak;\n\n\tcase WP_ROCKET_LAUNCHER:\n\t\tMAKERGB( pi->flashDlightColor, 1, 0.75f, 0 );\n\t\tbreak;\n\n\tcase WP_LIGHTNING:\n\t\tMAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 );\n\t\tbreak;\n\n\tcase WP_RAILGUN:\n\t\tMAKERGB( pi->flashDlightColor, 1, 0.5f, 0 );\n\t\tbreak;\n\n\tcase WP_PLASMAGUN:\n\t\tMAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 );\n\t\tbreak;\n\n\tcase WP_BFG:\n\t\tMAKERGB( pi->flashDlightColor, 1, 0.7f, 1 );\n\t\tbreak;\n\n\tcase WP_GRAPPLING_HOOK:\n\t\tMAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 );\n\t\tbreak;\n\n\tdefault:\n\t\tMAKERGB( pi->flashDlightColor, 1, 1, 1 );\n\t\tbreak;\n\t}\n}\n\n\n/*\n===============\nUI_ForceLegsAnim\n===============\n*/\nstatic void UI_ForceLegsAnim( playerInfo_t *pi, int anim ) {\n\tpi->legsAnim = ( ( pi->legsAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim;\n\n\tif ( anim == LEGS_JUMP ) {\n\t\tpi->legsAnimationTimer = UI_TIMER_JUMP;\n\t}\n}\n\n\n/*\n===============\nUI_SetLegsAnim\n===============\n*/\nstatic void UI_SetLegsAnim( playerInfo_t *pi, int anim ) {\n\tif ( pi->pendingLegsAnim ) {\n\t\tanim = pi->pendingLegsAnim;\n\t\tpi->pendingLegsAnim = 0;\n\t}\n\tUI_ForceLegsAnim( pi, anim );\n}\n\n\n/*\n===============\nUI_ForceTorsoAnim\n===============\n*/\nstatic void UI_ForceTorsoAnim( playerInfo_t *pi, int anim ) {\n\tpi->torsoAnim = ( ( pi->torsoAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim;\n\n\tif ( anim == TORSO_GESTURE ) {\n\t\tpi->torsoAnimationTimer = UI_TIMER_GESTURE;\n\t}\n\n\tif ( anim == TORSO_ATTACK || anim == TORSO_ATTACK2 ) {\n\t\tpi->torsoAnimationTimer = UI_TIMER_ATTACK;\n\t}\n}\n\n\n/*\n===============\nUI_SetTorsoAnim\n===============\n*/\nstatic void UI_SetTorsoAnim( playerInfo_t *pi, int anim ) {\n\tif ( pi->pendingTorsoAnim ) {\n\t\tanim = pi->pendingTorsoAnim;\n\t\tpi->pendingTorsoAnim = 0;\n\t}\n\n\tUI_ForceTorsoAnim( pi, anim );\n}\n\n\n/*\n===============\nUI_TorsoSequencing\n===============\n*/\nstatic void UI_TorsoSequencing( playerInfo_t *pi ) {\n\tint\t\tcurrentAnim;\n\n\tcurrentAnim = pi->torsoAnim & ~ANIM_TOGGLEBIT;\n\n\tif ( pi->weapon != pi->currentWeapon ) {\n\t\tif ( currentAnim != TORSO_DROP ) {\n\t\t\tpi->torsoAnimationTimer = UI_TIMER_WEAPON_SWITCH;\n\t\t\tUI_ForceTorsoAnim( pi, TORSO_DROP );\n\t\t}\n\t}\n\n\tif ( pi->torsoAnimationTimer > 0 ) {\n\t\treturn;\n\t}\n\n\tif( currentAnim == TORSO_GESTURE ) {\n\t\tUI_SetTorsoAnim( pi, TORSO_STAND );\n\t\treturn;\n\t}\n\n\tif( currentAnim == TORSO_ATTACK || currentAnim == TORSO_ATTACK2 ) {\n\t\tUI_SetTorsoAnim( pi, TORSO_STAND );\n\t\treturn;\n\t}\n\n\tif ( currentAnim == TORSO_DROP ) {\n\t\tUI_PlayerInfo_SetWeapon( pi, pi->weapon );\n\t\tpi->torsoAnimationTimer = UI_TIMER_WEAPON_SWITCH;\n\t\tUI_ForceTorsoAnim( pi, TORSO_RAISE );\n\t\treturn;\n\t}\n\n\tif ( currentAnim == TORSO_RAISE ) {\n\t\tUI_SetTorsoAnim( pi, TORSO_STAND );\n\t\treturn;\n\t}\n}\n\n\n/*\n===============\nUI_LegsSequencing\n===============\n*/\nstatic void UI_LegsSequencing( playerInfo_t *pi ) {\n\tint\t\tcurrentAnim;\n\n\tcurrentAnim = pi->legsAnim & ~ANIM_TOGGLEBIT;\n\n\tif ( pi->legsAnimationTimer > 0 ) {\n\t\tif ( currentAnim == LEGS_JUMP ) {\n\t\t\tjumpHeight = JUMP_HEIGHT * sin( M_PI * ( UI_TIMER_JUMP - pi->legsAnimationTimer ) / UI_TIMER_JUMP );\n\t\t}\n\t\treturn;\n\t}\n\n\tif ( currentAnim == LEGS_JUMP ) {\n\t\tUI_ForceLegsAnim( pi, LEGS_LAND );\n\t\tpi->legsAnimationTimer = UI_TIMER_LAND;\n\t\tjumpHeight = 0;\n\t\treturn;\n\t}\n\n\tif ( currentAnim == LEGS_LAND ) {\n\t\tUI_SetLegsAnim( pi, LEGS_IDLE );\n\t\treturn;\n\t}\n}\n\n\n/*\n======================\nUI_PositionEntityOnTag\n======================\n*/\nstatic void UI_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent, \n\t\t\t\t\t\t\tclipHandle_t parentModel, char *tagName ) {\n\tint\t\t\t\ti;\n\torientation_t\tlerped;\n\t\n\t// lerp the tag\n\ttrap_CM_LerpTag( &lerped, parentModel, parent->oldframe, parent->frame,\n\t\t1.0 - parent->backlerp, tagName );\n\n\t// FIXME: allow origin offsets along tag?\n\tVectorCopy( parent->origin, entity->origin );\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tVectorMA( entity->origin, lerped.origin[i], parent->axis[i], entity->origin );\n\t}\n\n\t// cast away const because of compiler problems\n\tMatrixMultiply( lerped.axis, ((refEntity_t*)parent)->axis, entity->axis );\n\tentity->backlerp = parent->backlerp;\n}\n\n\n/*\n======================\nUI_PositionRotatedEntityOnTag\n======================\n*/\nstatic void UI_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *parent, \n\t\t\t\t\t\t\tclipHandle_t parentModel, char *tagName ) {\n\tint\t\t\t\ti;\n\torientation_t\tlerped;\n\tvec3_t\t\t\ttempAxis[3];\n\n\t// lerp the tag\n\ttrap_CM_LerpTag( &lerped, parentModel, parent->oldframe, parent->frame,\n\t\t1.0 - parent->backlerp, tagName );\n\n\t// FIXME: allow origin offsets along tag?\n\tVectorCopy( parent->origin, entity->origin );\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tVectorMA( entity->origin, lerped.origin[i], parent->axis[i], entity->origin );\n\t}\n\n\t// cast away const because of compiler problems\n\tMatrixMultiply( entity->axis, ((refEntity_t *)parent)->axis, tempAxis );\n\tMatrixMultiply( lerped.axis, tempAxis, entity->axis );\n}\n\n\n/*\n===============\nUI_SetLerpFrameAnimation\n===============\n*/\nstatic void UI_SetLerpFrameAnimation( playerInfo_t *ci, lerpFrame_t *lf, int newAnimation ) {\n\tanimation_t\t*anim;\n\n\tlf->animationNumber = newAnimation;\n\tnewAnimation &= ~ANIM_TOGGLEBIT;\n\n\tif ( newAnimation < 0 || newAnimation >= MAX_ANIMATIONS ) {\n\t\ttrap_Error( va(\"Bad animation number: %i\", newAnimation) );\n\t}\n\n\tanim = &ci->animations[ newAnimation ];\n\n\tlf->animation = anim;\n\tlf->animationTime = lf->frameTime + anim->initialLerp;\n}\n\n\n/*\n===============\nUI_RunLerpFrame\n===============\n*/\nstatic void UI_RunLerpFrame( playerInfo_t *ci, lerpFrame_t *lf, int newAnimation ) {\n\tint\t\t\tf;\n\tanimation_t\t*anim;\n\n\t// see if the animation sequence is switching\n\tif ( newAnimation != lf->animationNumber || !lf->animation ) {\n\t\tUI_SetLerpFrameAnimation( ci, lf, newAnimation );\n\t}\n\n\t// if we have passed the current frame, move it to\n\t// oldFrame and calculate a new frame\n\tif ( dp_realtime >= lf->frameTime ) {\n\t\tlf->oldFrame = lf->frame;\n\t\tlf->oldFrameTime = lf->frameTime;\n\n\t\t// get the next frame based on the animation\n\t\tanim = lf->animation;\n\t\tif ( dp_realtime < lf->animationTime ) {\n\t\t\tlf->frameTime = lf->animationTime;\t\t// initial lerp\n\t\t} else {\n\t\t\tlf->frameTime = lf->oldFrameTime + anim->frameLerp;\n\t\t}\n\t\tf = ( lf->frameTime - lf->animationTime ) / anim->frameLerp;\n\t\tif ( f >= anim->numFrames ) {\n\t\t\tf -= anim->numFrames;\n\t\t\tif ( anim->loopFrames ) {\n\t\t\t\tf %= anim->loopFrames;\n\t\t\t\tf += anim->numFrames - anim->loopFrames;\n\t\t\t} else {\n\t\t\t\tf = anim->numFrames - 1;\n\t\t\t\t// the animation is stuck at the end, so it\n\t\t\t\t// can immediately transition to another sequence\n\t\t\t\tlf->frameTime = dp_realtime;\n\t\t\t}\n\t\t}\n\t\tlf->frame = anim->firstFrame + f;\n\t\tif ( dp_realtime > lf->frameTime ) {\n\t\t\tlf->frameTime = dp_realtime;\n\t\t}\n\t}\n\n\tif ( lf->frameTime > dp_realtime + 200 ) {\n\t\tlf->frameTime = dp_realtime;\n\t}\n\n\tif ( lf->oldFrameTime > dp_realtime ) {\n\t\tlf->oldFrameTime = dp_realtime;\n\t}\n\t// calculate current lerp value\n\tif ( lf->frameTime == lf->oldFrameTime ) {\n\t\tlf->backlerp = 0;\n\t} else {\n\t\tlf->backlerp = 1.0 - (float)( dp_realtime - lf->oldFrameTime ) / ( lf->frameTime - lf->oldFrameTime );\n\t}\n}\n\n\n/*\n===============\nUI_PlayerAnimation\n===============\n*/\nstatic void UI_PlayerAnimation( playerInfo_t *pi, int *legsOld, int *legs, float *legsBackLerp,\n\t\t\t\t\t\tint *torsoOld, int *torso, float *torsoBackLerp ) {\n\n\t// legs animation\n\tpi->legsAnimationTimer -= uis.frametime;\n\tif ( pi->legsAnimationTimer < 0 ) {\n\t\tpi->legsAnimationTimer = 0;\n\t}\n\n\tUI_LegsSequencing( pi );\n\n\tif ( pi->legs.yawing && ( pi->legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_IDLE ) {\n\t\tUI_RunLerpFrame( pi, &pi->legs, LEGS_TURN );\n\t} else {\n\t\tUI_RunLerpFrame( pi, &pi->legs, pi->legsAnim );\n\t}\n\t*legsOld = pi->legs.oldFrame;\n\t*legs = pi->legs.frame;\n\t*legsBackLerp = pi->legs.backlerp;\n\n\t// torso animation\n\tpi->torsoAnimationTimer -= uis.frametime;\n\tif ( pi->torsoAnimationTimer < 0 ) {\n\t\tpi->torsoAnimationTimer = 0;\n\t}\n\n\tUI_TorsoSequencing( pi );\n\n\tUI_RunLerpFrame( pi, &pi->torso, pi->torsoAnim );\n\t*torsoOld = pi->torso.oldFrame;\n\t*torso = pi->torso.frame;\n\t*torsoBackLerp = pi->torso.backlerp;\n}\n\n\n/*\n==================\nUI_SwingAngles\n==================\n*/\nstatic void UI_SwingAngles( float destination, float swingTolerance, float clampTolerance,\n\t\t\t\t\tfloat speed, float *angle, qboolean *swinging ) {\n\tfloat\tswing;\n\tfloat\tmove;\n\tfloat\tscale;\n\n\tif ( !*swinging ) {\n\t\t// see if a swing should be started\n\t\tswing = AngleSubtract( *angle, destination );\n\t\tif ( swing > swingTolerance || swing < -swingTolerance ) {\n\t\t\t*swinging = qtrue;\n\t\t}\n\t}\n\n\tif ( !*swinging ) {\n\t\treturn;\n\t}\n\t\n\t// modify the speed depending on the delta\n\t// so it doesn't seem so linear\n\tswing = AngleSubtract( destination, *angle );\n\tscale = fabs( swing );\n\tif ( scale < swingTolerance * 0.5 ) {\n\t\tscale = 0.5;\n\t} else if ( scale < swingTolerance ) {\n\t\tscale = 1.0;\n\t} else {\n\t\tscale = 2.0;\n\t}\n\n\t// swing towards the destination angle\n\tif ( swing >= 0 ) {\n\t\tmove = uis.frametime * scale * speed;\n\t\tif ( move >= swing ) {\n\t\t\tmove = swing;\n\t\t\t*swinging = qfalse;\n\t\t}\n\t\t*angle = AngleMod( *angle + move );\n\t} else if ( swing < 0 ) {\n\t\tmove = uis.frametime * scale * -speed;\n\t\tif ( move <= swing ) {\n\t\t\tmove = swing;\n\t\t\t*swinging = qfalse;\n\t\t}\n\t\t*angle = AngleMod( *angle + move );\n\t}\n\n\t// clamp to no more than tolerance\n\tswing = AngleSubtract( destination, *angle );\n\tif ( swing > clampTolerance ) {\n\t\t*angle = AngleMod( destination - (clampTolerance - 1) );\n\t} else if ( swing < -clampTolerance ) {\n\t\t*angle = AngleMod( destination + (clampTolerance - 1) );\n\t}\n}\n\n\n/*\n======================\nUI_MovedirAdjustment\n======================\n*/\nstatic float UI_MovedirAdjustment( playerInfo_t *pi ) {\n\tvec3_t\t\trelativeAngles;\n\tvec3_t\t\tmoveVector;\n\n\tVectorSubtract( pi->viewAngles, pi->moveAngles, relativeAngles );\n\tAngleVectors( relativeAngles, moveVector, NULL, NULL );\n\tif ( Q_fabs( moveVector[0] ) < 0.01 ) {\n\t\tmoveVector[0] = 0.0;\n\t}\n\tif ( Q_fabs( moveVector[1] ) < 0.01 ) {\n\t\tmoveVector[1] = 0.0;\n\t}\n\n\tif ( moveVector[1] == 0 && moveVector[0] > 0 ) {\n\t\treturn 0;\n\t}\n\tif ( moveVector[1] < 0 && moveVector[0] > 0 ) {\n\t\treturn 22;\n\t}\n\tif ( moveVector[1] < 0 && moveVector[0] == 0 ) {\n\t\treturn 45;\n\t}\n\tif ( moveVector[1] < 0 && moveVector[0] < 0 ) {\n\t\treturn -22;\n\t}\n\tif ( moveVector[1] == 0 && moveVector[0] < 0 ) {\n\t\treturn 0;\n\t}\n\tif ( moveVector[1] > 0 && moveVector[0] < 0 ) {\n\t\treturn 22;\n\t}\n\tif ( moveVector[1] > 0 && moveVector[0] == 0 ) {\n\t\treturn  -45;\n\t}\n\n\treturn -22;\n}\n\n\n/*\n===============\nUI_PlayerAngles\n===============\n*/\nstatic void UI_PlayerAngles( playerInfo_t *pi, vec3_t legs[3], vec3_t torso[3], vec3_t head[3] ) {\n\tvec3_t\t\tlegsAngles, torsoAngles, headAngles;\n\tfloat\t\tdest;\n\tfloat\t\tadjust;\n\n\tVectorCopy( pi->viewAngles, headAngles );\n\theadAngles[YAW] = AngleMod( headAngles[YAW] );\n\tVectorClear( legsAngles );\n\tVectorClear( torsoAngles );\n\n\t// --------- yaw -------------\n\n\t// allow yaw to drift a bit\n\tif ( ( pi->legsAnim & ~ANIM_TOGGLEBIT ) != LEGS_IDLE \n\t\t|| ( pi->torsoAnim & ~ANIM_TOGGLEBIT ) != TORSO_STAND  ) {\n\t\t// if not standing still, always point all in the same direction\n\t\tpi->torso.yawing = qtrue;\t// always center\n\t\tpi->torso.pitching = qtrue;\t// always center\n\t\tpi->legs.yawing = qtrue;\t// always center\n\t}\n\n\t// adjust legs for movement dir\n\tadjust = UI_MovedirAdjustment( pi );\n\tlegsAngles[YAW] = headAngles[YAW] + adjust;\n\ttorsoAngles[YAW] = headAngles[YAW] + 0.25 * adjust;\n\n\n\t// torso\n\tUI_SwingAngles( torsoAngles[YAW], 25, 90, SWINGSPEED, &pi->torso.yawAngle, &pi->torso.yawing );\n\tUI_SwingAngles( legsAngles[YAW], 40, 90, SWINGSPEED, &pi->legs.yawAngle, &pi->legs.yawing );\n\n\ttorsoAngles[YAW] = pi->torso.yawAngle;\n\tlegsAngles[YAW] = pi->legs.yawAngle;\n\n\t// --------- pitch -------------\n\n\t// only show a fraction of the pitch angle in the torso\n\tif ( headAngles[PITCH] > 180 ) {\n\t\tdest = (-360 + headAngles[PITCH]) * 0.75;\n\t} else {\n\t\tdest = headAngles[PITCH] * 0.75;\n\t}\n\tUI_SwingAngles( dest, 15, 30, 0.1f, &pi->torso.pitchAngle, &pi->torso.pitching );\n\ttorsoAngles[PITCH] = pi->torso.pitchAngle;\n\n\t// pull the angles back out of the hierarchial chain\n\tAnglesSubtract( headAngles, torsoAngles, headAngles );\n\tAnglesSubtract( torsoAngles, legsAngles, torsoAngles );\n\tAnglesToAxis( legsAngles, legs );\n\tAnglesToAxis( torsoAngles, torso );\n\tAnglesToAxis( headAngles, head );\n}\n\n\n/*\n===============\nUI_PlayerFloatSprite\n===============\n*/\nstatic void UI_PlayerFloatSprite( playerInfo_t *pi, vec3_t origin, qhandle_t shader ) {\n\trefEntity_t\t\tent;\n\n\tmemset( &ent, 0, sizeof( ent ) );\n\tVectorCopy( origin, ent.origin );\n\tent.origin[2] += 48;\n\tent.reType = RT_SPRITE;\n\tent.customShader = shader;\n\tent.radius = 10;\n\tent.renderfx = 0;\n\ttrap_R_AddRefEntityToScene( &ent );\n}\n\n\n/*\n======================\nUI_MachinegunSpinAngle\n======================\n*/\nfloat\tUI_MachinegunSpinAngle( playerInfo_t *pi ) {\n\tint\t\tdelta;\n\tfloat\tangle;\n\tfloat\tspeed;\n\tint\t\ttorsoAnim;\n\n\tdelta = dp_realtime - pi->barrelTime;\n\tif ( pi->barrelSpinning ) {\n\t\tangle = pi->barrelAngle + delta * SPIN_SPEED;\n\t} else {\n\t\tif ( delta > COAST_TIME ) {\n\t\t\tdelta = COAST_TIME;\n\t\t}\n\n\t\tspeed = 0.5 * ( SPIN_SPEED + (float)( COAST_TIME - delta ) / COAST_TIME );\n\t\tangle = pi->barrelAngle + delta * speed;\n\t}\n\n\ttorsoAnim = pi->torsoAnim  & ~ANIM_TOGGLEBIT;\n\tif( torsoAnim == TORSO_ATTACK2 ) {\n\t\ttorsoAnim = TORSO_ATTACK;\n\t}\n\tif ( pi->barrelSpinning == !(torsoAnim == TORSO_ATTACK) ) {\n\t\tpi->barrelTime = dp_realtime;\n\t\tpi->barrelAngle = AngleMod( angle );\n\t\tpi->barrelSpinning = !!(torsoAnim == TORSO_ATTACK);\n\t}\n\n\treturn angle;\n}\n\n\n/*\n===============\nUI_DrawPlayer\n===============\n*/\nvoid UI_DrawPlayer( float x, float y, float w, float h, playerInfo_t *pi, int time ) {\n\trefdef_t\t\trefdef;\n\trefEntity_t\t\tlegs;\n\trefEntity_t\t\ttorso;\n\trefEntity_t\t\thead;\n\trefEntity_t\t\tgun;\n\trefEntity_t\t\tbarrel;\n\trefEntity_t\t\tflash;\n\tvec3_t\t\t\torigin;\n\tint\t\t\t\trenderfx;\n\tvec3_t\t\t\tmins = {-16, -16, -24};\n\tvec3_t\t\t\tmaxs = {16, 16, 32};\n\tfloat\t\t\tlen;\n\tfloat\t\t\txx;\n\n\tif ( !pi->legsModel || !pi->torsoModel || !pi->headModel || !pi->animations[0].numFrames ) {\n\t\treturn;\n\t}\n\n\tdp_realtime = time;\n\n\tif ( pi->pendingWeapon != -1 && dp_realtime > pi->weaponTimer ) {\n\t\tpi->weapon = pi->pendingWeapon;\n\t\tpi->lastWeapon = pi->pendingWeapon;\n\t\tpi->pendingWeapon = -1;\n\t\tpi->weaponTimer = 0;\n\t\tif( pi->currentWeapon != pi->weapon ) {\n\t\t\ttrap_S_StartLocalSound( weaponChangeSound, CHAN_LOCAL );\n\t\t}\n\t}\n\n\tUI_AdjustFrom640( &x, &y, &w, &h );\n\n\ty -= jumpHeight;\n\n\tmemset( &refdef, 0, sizeof( refdef ) );\n\tmemset( &legs, 0, sizeof(legs) );\n\tmemset( &torso, 0, sizeof(torso) );\n\tmemset( &head, 0, sizeof(head) );\n\n\trefdef.rdflags = RDF_NOWORLDMODEL;\n\n\tAxisClear( refdef.viewaxis );\n\n\trefdef.x = x;\n\trefdef.y = y;\n\trefdef.width = w;\n\trefdef.height = h;\n\n\trefdef.fov_x = (int)((float)refdef.width / 640.0f * 90.0f);\n\txx = refdef.width / tan( refdef.fov_x / 360 * M_PI );\n\trefdef.fov_y = atan2( refdef.height, xx );\n\trefdef.fov_y *= ( 360 / M_PI );\n\n\t// calculate distance so the player nearly fills the box\n\tlen = 0.7 * ( maxs[2] - mins[2] );\t\t\n\torigin[0] = len / tan( DEG2RAD(refdef.fov_x) * 0.5 );\n\torigin[1] = 0.5 * ( mins[1] + maxs[1] );\n\torigin[2] = -0.5 * ( mins[2] + maxs[2] );\n\n\trefdef.time = dp_realtime;\n\n\ttrap_R_ClearScene();\n\n\t// get the rotation information\n\tUI_PlayerAngles( pi, legs.axis, torso.axis, head.axis );\n\t\n\t// get the animation state (after rotation, to allow feet shuffle)\n\tUI_PlayerAnimation( pi, &legs.oldframe, &legs.frame, &legs.backlerp,\n\t\t &torso.oldframe, &torso.frame, &torso.backlerp );\n\n\trenderfx = RF_LIGHTING_ORIGIN | RF_NOSHADOW;\n\n\t//\n\t// add the legs\n\t//\n\tlegs.hModel = pi->legsModel;\n\tlegs.customSkin = pi->legsSkin;\n\n\tVectorCopy( origin, legs.origin );\n\n\tVectorCopy( origin, legs.lightingOrigin );\n\tlegs.renderfx = renderfx;\n\tVectorCopy (legs.origin, legs.oldorigin);\n\n\ttrap_R_AddRefEntityToScene( &legs );\n\n\tif (!legs.hModel) {\n\t\treturn;\n\t}\n\n\t//\n\t// add the torso\n\t//\n\ttorso.hModel = pi->torsoModel;\n\tif (!torso.hModel) {\n\t\treturn;\n\t}\n\n\ttorso.customSkin = pi->torsoSkin;\n\n\tVectorCopy( origin, torso.lightingOrigin );\n\n\tUI_PositionRotatedEntityOnTag( &torso, &legs, pi->legsModel, \"tag_torso\");\n\n\ttorso.renderfx = renderfx;\n\n\ttrap_R_AddRefEntityToScene( &torso );\n\n\t//\n\t// add the head\n\t//\n\thead.hModel = pi->headModel;\n\tif (!head.hModel) {\n\t\treturn;\n\t}\n\thead.customSkin = pi->headSkin;\n\n\tVectorCopy( origin, head.lightingOrigin );\n\n\tUI_PositionRotatedEntityOnTag( &head, &torso, pi->torsoModel, \"tag_head\");\n\n\thead.renderfx = renderfx;\n\n\ttrap_R_AddRefEntityToScene( &head );\n\n\t//\n\t// add the gun\n\t//\n\tif ( pi->currentWeapon != WP_NONE ) {\n\t\tmemset( &gun, 0, sizeof(gun) );\n\t\tgun.hModel = pi->weaponModel;\n\t\tVectorCopy( origin, gun.lightingOrigin );\n\t\tUI_PositionEntityOnTag( &gun, &torso, pi->torsoModel, \"tag_weapon\");\n\t\tgun.renderfx = renderfx;\n\t\ttrap_R_AddRefEntityToScene( &gun );\n\t}\n\n\t//\n\t// add the spinning barrel\n\t//\n\tif ( pi->realWeapon == WP_MACHINEGUN || pi->realWeapon == WP_GAUNTLET || pi->realWeapon == WP_BFG ) {\n\t\tvec3_t\tangles;\n\n\t\tmemset( &barrel, 0, sizeof(barrel) );\n\t\tVectorCopy( origin, barrel.lightingOrigin );\n\t\tbarrel.renderfx = renderfx;\n\n\t\tbarrel.hModel = pi->barrelModel;\n\t\tangles[YAW] = 0;\n\t\tangles[PITCH] = 0;\n\t\tangles[ROLL] = UI_MachinegunSpinAngle( pi );\n\t\tif( pi->realWeapon == WP_GAUNTLET || pi->realWeapon == WP_BFG ) {\n\t\t\tangles[PITCH] = angles[ROLL];\n\t\t\tangles[ROLL] = 0;\n\t\t}\n\t\tAnglesToAxis( angles, barrel.axis );\n\n\t\tUI_PositionRotatedEntityOnTag( &barrel, &gun, pi->weaponModel, \"tag_barrel\");\n\n\t\ttrap_R_AddRefEntityToScene( &barrel );\n\t}\n\n\t//\n\t// add muzzle flash\n\t//\n\tif ( dp_realtime <= pi->muzzleFlashTime ) {\n\t\tif ( pi->flashModel ) {\n\t\t\tmemset( &flash, 0, sizeof(flash) );\n\t\t\tflash.hModel = pi->flashModel;\n\t\t\tVectorCopy( origin, flash.lightingOrigin );\n\t\t\tUI_PositionEntityOnTag( &flash, &gun, pi->weaponModel, \"tag_flash\");\n\t\t\tflash.renderfx = renderfx;\n\t\t\ttrap_R_AddRefEntityToScene( &flash );\n\t\t}\n\n\t\t// make a dlight for the flash\n\t\tif ( pi->flashDlightColor[0] || pi->flashDlightColor[1] || pi->flashDlightColor[2] ) {\n\t\t\ttrap_R_AddLightToScene( flash.origin, 200 + (rand()&31), pi->flashDlightColor[0],\n\t\t\t\tpi->flashDlightColor[1], pi->flashDlightColor[2] );\n\t\t}\n\t}\n\n\t//\n\t// add the chat icon\n\t//\n\tif ( pi->chat ) {\n\t\tUI_PlayerFloatSprite( pi, origin, trap_R_RegisterShaderNoMip( \"sprites/balloon3\" ) );\n\t}\n\n\t//\n\t// add an accent light\n\t//\n\torigin[0] -= 100;\t// + = behind, - = in front\n\torigin[1] += 100;\t// + = left, - = right\n\torigin[2] += 100;\t// + = above, - = below\n\ttrap_R_AddLightToScene( origin, 500, 1.0, 1.0, 1.0 );\n\n\torigin[0] -= 100;\n\torigin[1] -= 100;\n\torigin[2] -= 100;\n\ttrap_R_AddLightToScene( origin, 500, 1.0, 0.0, 0.0 );\n\n\ttrap_R_RenderScene( &refdef );\n}\n\n\n/*\n==========================\nUI_RegisterClientSkin\n==========================\n*/\nstatic qboolean UI_RegisterClientSkin( playerInfo_t *pi, const char *modelName, const char *skinName ) {\n\tchar\t\tfilename[MAX_QPATH];\n\n\tCom_sprintf( filename, sizeof( filename ), \"models/players/%s/lower_%s.skin\", modelName, skinName );\n\tpi->legsSkin = trap_R_RegisterSkin( filename );\n\n\tCom_sprintf( filename, sizeof( filename ), \"models/players/%s/upper_%s.skin\", modelName, skinName );\n\tpi->torsoSkin = trap_R_RegisterSkin( filename );\n\n\tCom_sprintf( filename, sizeof( filename ), \"models/players/%s/head_%s.skin\", modelName, skinName );\n\tpi->headSkin = trap_R_RegisterSkin( filename );\n\n\tif ( !pi->legsSkin || !pi->torsoSkin || !pi->headSkin ) {\n\t\treturn qfalse;\n\t}\n\n\treturn qtrue;\n}\n\n\n/*\n======================\nUI_ParseAnimationFile\n======================\n*/\nstatic qboolean UI_ParseAnimationFile( const char *filename, animation_t *animations ) {\n\tchar\t\t*text_p, *prev;\n\tint\t\t\tlen;\n\tint\t\t\ti;\n\tchar\t\t*token;\n\tfloat\t\tfps;\n\tint\t\t\tskip;\n\tchar\t\ttext[20000];\n\tfileHandle_t\tf;\n\n\tmemset( animations, 0, sizeof( animation_t ) * MAX_ANIMATIONS );\n\n\t// load the file\n\tlen = trap_FS_FOpenFile( filename, &f, FS_READ );\n\tif ( len <= 0 ) {\n\t\treturn qfalse;\n\t}\n\tif ( len >= ( sizeof( text ) - 1 ) ) {\n\t\tCom_Printf( \"File %s too long\\n\", filename );\n\t\treturn qfalse;\n\t}\n\ttrap_FS_Read( text, len, f );\n\ttext[len] = 0;\n\ttrap_FS_FCloseFile( f );\n\n\t// parse the text\n\ttext_p = text;\n\tskip = 0;\t// quite the compiler warning\n\n\t// read optional parameters\n\twhile ( 1 ) {\n\t\tprev = text_p;\t// so we can unget\n\t\ttoken = COM_Parse( &text_p );\n\t\tif ( !token ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( !Q_stricmp( token, \"footsteps\" ) ) {\n\t\t\ttoken = COM_Parse( &text_p );\n\t\t\tif ( !token ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcontinue;\n\t\t} else if ( !Q_stricmp( token, \"headoffset\" ) ) {\n\t\t\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\t\t\ttoken = COM_Parse( &text_p );\n\t\t\t\tif ( !token ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontinue;\n\t\t} else if ( !Q_stricmp( token, \"sex\" ) ) {\n\t\t\ttoken = COM_Parse( &text_p );\n\t\t\tif ( !token ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// if it is a number, start parsing animations\n\t\tif ( token[0] >= '0' && token[0] <= '9' ) {\n\t\t\ttext_p = prev;\t// unget the token\n\t\t\tbreak;\n\t\t}\n\n\t\tCom_Printf( \"unknown token '%s' is %s\\n\", token, filename );\n\t}\n\n\t// read information for each frame\n\tfor ( i = 0 ; i < MAX_ANIMATIONS ; i++ ) {\n\n\t\ttoken = COM_Parse( &text_p );\n\t\tif ( !token ) {\n\t\t\tbreak;\n\t\t}\n\t\tanimations[i].firstFrame = atoi( token );\n\t\t// leg only frames are adjusted to not count the upper body only frames\n\t\tif ( i == LEGS_WALKCR ) {\n\t\t\tskip = animations[LEGS_WALKCR].firstFrame - animations[TORSO_GESTURE].firstFrame;\n\t\t}\n\t\tif ( i >= LEGS_WALKCR ) {\n\t\t\tanimations[i].firstFrame -= skip;\n\t\t}\n\n\t\ttoken = COM_Parse( &text_p );\n\t\tif ( !token ) {\n\t\t\tbreak;\n\t\t}\n\t\tanimations[i].numFrames = atoi( token );\n\n\t\ttoken = COM_Parse( &text_p );\n\t\tif ( !token ) {\n\t\t\tbreak;\n\t\t}\n\t\tanimations[i].loopFrames = atoi( token );\n\n\t\ttoken = COM_Parse( &text_p );\n\t\tif ( !token ) {\n\t\t\tbreak;\n\t\t}\n\t\tfps = atof( token );\n\t\tif ( fps == 0 ) {\n\t\t\tfps = 1;\n\t\t}\n\t\tanimations[i].frameLerp = 1000 / fps;\n\t\tanimations[i].initialLerp = 1000 / fps;\n\t}\n\n\tif ( i != MAX_ANIMATIONS ) {\n\t\tCom_Printf( \"Error parsing animation file: %s\", filename );\n\t\treturn qfalse;\n\t}\n\n\treturn qtrue;\n}\n\n\n/*\n==========================\nUI_RegisterClientModelname\n==========================\n*/\nqboolean UI_RegisterClientModelname( playerInfo_t *pi, const char *modelSkinName ) {\n\tchar\t\tmodelName[MAX_QPATH];\n\tchar\t\tskinName[MAX_QPATH];\n\tchar\t\tfilename[MAX_QPATH];\n\tchar\t\t*slash;\n\n\tpi->torsoModel = 0;\n\tpi->headModel = 0;\n\n\tif ( !modelSkinName[0] ) {\n\t\treturn qfalse;\n\t}\n\n\tQ_strncpyz( modelName, modelSkinName, sizeof( modelName ) );\n\n\tslash = strchr( modelName, '/' );\n\tif ( !slash ) {\n\t\t// modelName did not include a skin name\n\t\tQ_strncpyz( skinName, \"default\", sizeof( skinName ) );\n\t} else {\n\t\tQ_strncpyz( skinName, slash + 1, sizeof( skinName ) );\n\t\t// truncate modelName\n\t\t*slash = 0;\n\t}\n\n\t// load cmodels before models so filecache works\n\n\tCom_sprintf( filename, sizeof( filename ), \"models/players/%s/lower.md3\", modelName );\n\tpi->legsModel = trap_R_RegisterModel( filename );\n\tif ( !pi->legsModel ) {\n\t\tCom_Printf( \"Failed to load model file %s\\n\", filename );\n\t\treturn qfalse;\n\t}\n\n\tCom_sprintf( filename, sizeof( filename ), \"models/players/%s/upper.md3\", modelName );\n\tpi->torsoModel = trap_R_RegisterModel( filename );\n\tif ( !pi->torsoModel ) {\n\t\tCom_Printf( \"Failed to load model file %s\\n\", filename );\n\t\treturn qfalse;\n\t}\n\n\tCom_sprintf( filename, sizeof( filename ), \"models/players/%s/head.md3\", modelName );\n\tpi->headModel = trap_R_RegisterModel( filename );\n\tif ( !pi->headModel ) {\n\t\tCom_Printf( \"Failed to load model file %s\\n\", filename );\n\t\treturn qfalse;\n\t}\n\n\t// if any skins failed to load, fall back to default\n\tif ( !UI_RegisterClientSkin( pi, modelName, skinName ) ) {\n\t\tif ( !UI_RegisterClientSkin( pi, modelName, \"default\" ) ) {\n\t\t\tCom_Printf( \"Failed to load skin file: %s : %s\\n\", modelName, skinName );\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\t// load the animations\n\tCom_sprintf( filename, sizeof( filename ), \"models/players/%s/animation.cfg\", modelName );\n\tif ( !UI_ParseAnimationFile( filename, pi->animations ) ) {\n\t\tCom_Printf( \"Failed to load animation file %s\\n\", filename );\n\t\treturn qfalse;\n\t}\n\n\treturn qtrue;\n}\n\n\n/*\n===============\nUI_PlayerInfo_SetModel\n===============\n*/\nvoid UI_PlayerInfo_SetModel( playerInfo_t *pi, const char *model ) {\n\tmemset( pi, 0, sizeof(*pi) );\n\tUI_RegisterClientModelname( pi, model );\n\tpi->weapon = WP_MACHINEGUN;\n\tpi->currentWeapon = pi->weapon;\n\tpi->lastWeapon = pi->weapon;\n\tpi->pendingWeapon = -1;\n\tpi->weaponTimer = 0;\n\tpi->chat = qfalse;\n\tpi->newModel = qtrue;\n\tUI_PlayerInfo_SetWeapon( pi, pi->weapon );\n}\n\n\n/*\n===============\nUI_PlayerInfo_SetInfo\n===============\n*/\nvoid UI_PlayerInfo_SetInfo( playerInfo_t *pi, int legsAnim, int torsoAnim, vec3_t viewAngles, vec3_t moveAngles, weapon_t weaponNumber, qboolean chat ) {\n\tint\t\t\tcurrentAnim;\n\tweapon_t\tweaponNum;\n\n\tpi->chat = chat;\n\n\t// view angles\n\tVectorCopy( viewAngles, pi->viewAngles );\n\n\t// move angles\n\tVectorCopy( moveAngles, pi->moveAngles );\n\n\tif ( pi->newModel ) {\n\t\tpi->newModel = qfalse;\n\n\t\tjumpHeight = 0;\n\t\tpi->pendingLegsAnim = 0;\n\t\tUI_ForceLegsAnim( pi, legsAnim );\n\t\tpi->legs.yawAngle = viewAngles[YAW];\n\t\tpi->legs.yawing = qfalse;\n\n\t\tpi->pendingTorsoAnim = 0;\n\t\tUI_ForceTorsoAnim( pi, torsoAnim );\n\t\tpi->torso.yawAngle = viewAngles[YAW];\n\t\tpi->torso.yawing = qfalse;\n\n\t\tif ( weaponNumber != -1 ) {\n\t\t\tpi->weapon = weaponNumber;\n\t\t\tpi->currentWeapon = weaponNumber;\n\t\t\tpi->lastWeapon = weaponNumber;\n\t\t\tpi->pendingWeapon = -1;\n\t\t\tpi->weaponTimer = 0;\n\t\t\tUI_PlayerInfo_SetWeapon( pi, pi->weapon );\n\t\t}\n\n\t\treturn;\n\t}\n\n\t// weapon\n\tif ( weaponNumber == -1 ) {\n\t\tpi->pendingWeapon = -1;\n\t\tpi->weaponTimer = 0;\n\t}\n\telse if ( weaponNumber != WP_NONE ) {\n\t\tpi->pendingWeapon = weaponNumber;\n\t\tpi->weaponTimer = dp_realtime + UI_TIMER_WEAPON_DELAY;\n\t}\n\tweaponNum = pi->lastWeapon;\n\tpi->weapon = weaponNum;\n\n\tif ( torsoAnim == BOTH_DEATH1 || legsAnim == BOTH_DEATH1 ) {\n\t\ttorsoAnim = legsAnim = BOTH_DEATH1;\n\t\tpi->weapon = pi->currentWeapon = WP_NONE;\n\t\tUI_PlayerInfo_SetWeapon( pi, pi->weapon );\n\n\t\tjumpHeight = 0;\n\t\tpi->pendingLegsAnim = 0;\n\t\tUI_ForceLegsAnim( pi, legsAnim );\n\n\t\tpi->pendingTorsoAnim = 0;\n\t\tUI_ForceTorsoAnim( pi, torsoAnim );\n\n\t\treturn;\n\t}\n\n\t// leg animation\n\tcurrentAnim = pi->legsAnim & ~ANIM_TOGGLEBIT;\n\tif ( legsAnim != LEGS_JUMP && ( currentAnim == LEGS_JUMP || currentAnim == LEGS_LAND ) ) {\n\t\tpi->pendingLegsAnim = legsAnim;\n\t}\n\telse if ( legsAnim != currentAnim ) {\n\t\tjumpHeight = 0;\n\t\tpi->pendingLegsAnim = 0;\n\t\tUI_ForceLegsAnim( pi, legsAnim );\n\t}\n\n\t// torso animation\n\tif ( torsoAnim == TORSO_STAND || torsoAnim == TORSO_STAND2 ) {\n\t\tif ( weaponNum == WP_NONE || weaponNum == WP_GAUNTLET ) {\n\t\t\ttorsoAnim = TORSO_STAND2;\n\t\t}\n\t\telse {\n\t\t\ttorsoAnim = TORSO_STAND;\n\t\t}\n\t}\n\n\tif ( torsoAnim == TORSO_ATTACK || torsoAnim == TORSO_ATTACK2 ) {\n\t\tif ( weaponNum == WP_NONE || weaponNum == WP_GAUNTLET ) {\n\t\t\ttorsoAnim = TORSO_ATTACK2;\n\t\t}\n\t\telse {\n\t\t\ttorsoAnim = TORSO_ATTACK;\n\t\t}\n\t\tpi->muzzleFlashTime = dp_realtime + UI_TIMER_MUZZLE_FLASH;\n\t\t//FIXME play firing sound here\n\t}\n\n\tcurrentAnim = pi->torsoAnim & ~ANIM_TOGGLEBIT;\n\n\tif ( weaponNum != pi->currentWeapon || currentAnim == TORSO_RAISE || currentAnim == TORSO_DROP ) {\n\t\tpi->pendingTorsoAnim = torsoAnim;\n\t}\n\telse if ( ( currentAnim == TORSO_GESTURE || currentAnim == TORSO_ATTACK ) && ( torsoAnim != currentAnim ) ) {\n\t\tpi->pendingTorsoAnim = torsoAnim;\n\t}\n\telse if ( torsoAnim != currentAnim ) {\n\t\tpi->pendingTorsoAnim = 0;\n\t\tUI_ForceTorsoAnim( pi, torsoAnim );\n\t}\n}\n"
  },
  {
    "path": "code/q3_ui/ui_playersettings.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#include \"ui_local.h\"\n\n#define ART_FRAMEL\t\t\t\"menu/art/frame2_l\"\n#define ART_FRAMER\t\t\t\"menu/art/frame1_r\"\n#define ART_MODEL0\t\t\t\"menu/art/model_0\"\n#define ART_MODEL1\t\t\t\"menu/art/model_1\"\n#define ART_BACK0\t\t\t\"menu/art/back_0\"\n#define ART_BACK1\t\t\t\"menu/art/back_1\"\n#define ART_FX_BASE\t\t\t\"menu/art/fx_base\"\n#define ART_FX_BLUE\t\t\t\"menu/art/fx_blue\"\n#define ART_FX_CYAN\t\t\t\"menu/art/fx_cyan\"\n#define ART_FX_GREEN\t\t\"menu/art/fx_grn\"\n#define ART_FX_RED\t\t\t\"menu/art/fx_red\"\n#define ART_FX_TEAL\t\t\t\"menu/art/fx_teal\"\n#define ART_FX_WHITE\t\t\"menu/art/fx_white\"\n#define ART_FX_YELLOW\t\t\"menu/art/fx_yel\"\n\n#define ID_NAME\t\t\t10\n#define ID_HANDICAP\t\t11\n#define ID_EFFECTS\t\t12\n#define ID_BACK\t\t\t13\n#define ID_MODEL\t\t14\n\n#define MAX_NAMELENGTH\t20\n\n\ntypedef struct {\n\tmenuframework_s\t\tmenu;\n\n\tmenutext_s\t\t\tbanner;\n\tmenubitmap_s\t\tframel;\n\tmenubitmap_s\t\tframer;\n\tmenubitmap_s\t\tplayer;\n\n\tmenufield_s\t\t\tname;\n\tmenulist_s\t\t\thandicap;\n\tmenulist_s\t\t\teffects;\n\n\tmenubitmap_s\t\tback;\n\tmenubitmap_s\t\tmodel;\n\tmenubitmap_s\t\titem_null;\n\n\tqhandle_t\t\t\tfxBasePic;\n\tqhandle_t\t\t\tfxPic[7];\n\tplayerInfo_t\t\tplayerinfo;\n\tint\t\t\t\t\tcurrent_fx;\n\tchar\t\t\t\tplayerModel[MAX_QPATH];\n} playersettings_t;\n\nstatic playersettings_t\ts_playersettings;\n\nstatic int gamecodetoui[] = {4,2,3,0,5,1,6};\nstatic int uitogamecode[] = {4,6,2,3,1,5,7};\n\nstatic const char *handicap_items[] = {\n\t\"None\",\n\t\"95\",\n\t\"90\",\n\t\"85\",\n\t\"80\",\n\t\"75\",\n\t\"70\",\n\t\"65\",\n\t\"60\",\n\t\"55\",\n\t\"50\",\n\t\"45\",\n\t\"40\",\n\t\"35\",\n\t\"30\",\n\t\"25\",\n\t\"20\",\n\t\"15\",\n\t\"10\",\n\t\"5\",\n\t0\n};\n\n\n/*\n=================\nPlayerSettings_DrawName\n=================\n*/\nstatic void PlayerSettings_DrawName( void *self ) {\n\tmenufield_s\t\t*f;\n\tqboolean\t\tfocus;\n\tint\t\t\t\tstyle;\n\tchar\t\t\t*txt;\n\tchar\t\t\tc;\n\tfloat\t\t\t*color;\n\tint\t\t\t\tn;\n\tint\t\t\t\tbasex, x, y;\n\tchar\t\t\tname[32];\n\n\tf = (menufield_s*)self;\n\tbasex = f->generic.x;\n\ty = f->generic.y;\n\tfocus = (f->generic.parent->cursor == f->generic.menuPosition);\n\n\tstyle = UI_LEFT|UI_SMALLFONT;\n\tcolor = text_color_normal;\n\tif( focus ) {\n\t\tstyle |= UI_PULSE;\n\t\tcolor = text_color_highlight;\n\t}\n\n\tUI_DrawProportionalString( basex, y, \"Name\", style, color );\n\n\t// draw the actual name\n\tbasex += 64;\n\ty += PROP_HEIGHT;\n\ttxt = f->field.buffer;\n\tcolor = g_color_table[ColorIndex(COLOR_WHITE)];\n\tx = basex;\n\twhile ( (c = *txt) != 0 ) {\n\t\tif ( !focus && Q_IsColorString( txt ) ) {\n\t\t\tn = ColorIndex( *(txt+1) );\n\t\t\tif( n == 0 ) {\n\t\t\t\tn = 7;\n\t\t\t}\n\t\t\tcolor = g_color_table[n];\n\t\t\ttxt += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tUI_DrawChar( x, y, c, style, color );\n\t\ttxt++;\n\t\tx += SMALLCHAR_WIDTH;\n\t}\n\n\t// draw cursor if we have focus\n\tif( focus ) {\n\t\tif ( trap_Key_GetOverstrikeMode() ) {\n\t\t\tc = 11;\n\t\t} else {\n\t\t\tc = 10;\n\t\t}\n\n\t\tstyle &= ~UI_PULSE;\n\t\tstyle |= UI_BLINK;\n\n\t\tUI_DrawChar( basex + f->field.cursor * SMALLCHAR_WIDTH, y, c, style, color_white );\n\t}\n\n\t// draw at bottom also using proportional font\n\tQ_strncpyz( name, f->field.buffer, sizeof(name) );\n\tQ_CleanStr( name );\n\tUI_DrawProportionalString( 320, 440, name, UI_CENTER|UI_BIGFONT, text_color_normal );\n}\n\n\n/*\n=================\nPlayerSettings_DrawHandicap\n=================\n*/\nstatic void PlayerSettings_DrawHandicap( void *self ) {\n\tmenulist_s\t\t*item;\n\tqboolean\t\tfocus;\n\tint\t\t\t\tstyle;\n\tfloat\t\t\t*color;\n\n\titem = (menulist_s *)self;\n\tfocus = (item->generic.parent->cursor == item->generic.menuPosition);\n\n\tstyle = UI_LEFT|UI_SMALLFONT;\n\tcolor = text_color_normal;\n\tif( focus ) {\n\t\tstyle |= UI_PULSE;\n\t\tcolor = text_color_highlight;\n\t}\n\n\tUI_DrawProportionalString( item->generic.x, item->generic.y, \"Handicap\", style, color );\n\tUI_DrawProportionalString( item->generic.x + 64, item->generic.y + PROP_HEIGHT, handicap_items[item->curvalue], style, color );\n}\n\n\n/*\n=================\nPlayerSettings_DrawEffects\n=================\n*/\nstatic void PlayerSettings_DrawEffects( void *self ) {\n\tmenulist_s\t\t*item;\n\tqboolean\t\tfocus;\n\tint\t\t\t\tstyle;\n\tfloat\t\t\t*color;\n\n\titem = (menulist_s *)self;\n\tfocus = (item->generic.parent->cursor == item->generic.menuPosition);\n\n\tstyle = UI_LEFT|UI_SMALLFONT;\n\tcolor = text_color_normal;\n\tif( focus ) {\n\t\tstyle |= UI_PULSE;\n\t\tcolor = text_color_highlight;\n\t}\n\n\tUI_DrawProportionalString( item->generic.x, item->generic.y, \"Effects\", style, color );\n\n\tUI_DrawHandlePic( item->generic.x + 64, item->generic.y + PROP_HEIGHT + 8, 128, 8, s_playersettings.fxBasePic );\n\tUI_DrawHandlePic( item->generic.x + 64 + item->curvalue * 16 + 8, item->generic.y + PROP_HEIGHT + 6, 16, 12, s_playersettings.fxPic[item->curvalue] );\n}\n\n\n/*\n=================\nPlayerSettings_DrawPlayer\n=================\n*/\nstatic void PlayerSettings_DrawPlayer( void *self ) {\n\tmenubitmap_s\t*b;\n\tvec3_t\t\t\tviewangles;\n\tchar\t\t\tbuf[MAX_QPATH];\n\n\ttrap_Cvar_VariableStringBuffer( \"model\", buf, sizeof( buf ) );\n\tif ( strcmp( buf, s_playersettings.playerModel ) != 0 ) {\n\t\tUI_PlayerInfo_SetModel( &s_playersettings.playerinfo, buf );\n\t\tstrcpy( s_playersettings.playerModel, buf );\n\n\t\tviewangles[YAW]   = 180 - 30;\n\t\tviewangles[PITCH] = 0;\n\t\tviewangles[ROLL]  = 0;\n\t\tUI_PlayerInfo_SetInfo( &s_playersettings.playerinfo, LEGS_IDLE, TORSO_STAND, viewangles, vec3_origin, WP_MACHINEGUN, qfalse );\n\t}\n\n\tb = (menubitmap_s*) self;\n\tUI_DrawPlayer( b->generic.x, b->generic.y, b->width, b->height, &s_playersettings.playerinfo, uis.realtime/2 );\n}\n\n\n/*\n=================\nPlayerSettings_SaveChanges\n=================\n*/\nstatic void PlayerSettings_SaveChanges( void ) {\n\t// name\n\ttrap_Cvar_Set( \"name\", s_playersettings.name.field.buffer );\n\n\t// handicap\n\ttrap_Cvar_SetValue( \"handicap\", 100 - s_playersettings.handicap.curvalue * 5 );\n\n\t// effects color\n\ttrap_Cvar_SetValue( \"color1\", uitogamecode[s_playersettings.effects.curvalue] );\n}\n\n\n/*\n=================\nPlayerSettings_MenuKey\n=================\n*/\nstatic sfxHandle_t PlayerSettings_MenuKey( int key ) {\n\tif( key == K_MOUSE2 || key == K_ESCAPE ) {\n\t\tPlayerSettings_SaveChanges();\n\t}\n\treturn Menu_DefaultKey( &s_playersettings.menu, key );\n}\n\n\n/*\n=================\nPlayerSettings_SetMenuItems\n=================\n*/\nstatic void PlayerSettings_SetMenuItems( void ) {\n\tvec3_t\tviewangles;\n\tint\t\tc;\n\tint\t\th;\n\n\t// name\n\tQ_strncpyz( s_playersettings.name.field.buffer, UI_Cvar_VariableString(\"name\"), sizeof(s_playersettings.name.field.buffer) );\n\n\t// effects color\n\tc = trap_Cvar_VariableValue( \"color1\" ) - 1;\n\tif( c < 0 || c > 6 ) {\n\t\tc = 6;\n\t}\n\ts_playersettings.effects.curvalue = gamecodetoui[c];\n\n\t// model/skin\n\tmemset( &s_playersettings.playerinfo, 0, sizeof(playerInfo_t) );\n\t\n\tviewangles[YAW]   = 180 - 30;\n\tviewangles[PITCH] = 0;\n\tviewangles[ROLL]  = 0;\n\n\tUI_PlayerInfo_SetModel( &s_playersettings.playerinfo, UI_Cvar_VariableString( \"model\" ) );\n\tUI_PlayerInfo_SetInfo( &s_playersettings.playerinfo, LEGS_IDLE, TORSO_STAND, viewangles, vec3_origin, WP_MACHINEGUN, qfalse );\n\n\t// handicap\n\th = Com_Clamp( 5, 100, trap_Cvar_VariableValue(\"handicap\") );\n\ts_playersettings.handicap.curvalue = 20 - h / 5;\n}\n\n\n/*\n=================\nPlayerSettings_MenuEvent\n=================\n*/\nstatic void PlayerSettings_MenuEvent( void* ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tswitch( ((menucommon_s*)ptr)->id ) {\n\tcase ID_HANDICAP:\n\t\ttrap_Cvar_Set( \"handicap\", va( \"%i\", 100 - 25 * s_playersettings.handicap.curvalue ) );\n\t\tbreak;\n\n\tcase ID_MODEL:\n\t\tPlayerSettings_SaveChanges();\n\t\tUI_PlayerModelMenu();\n\t\tbreak;\n\n\tcase ID_BACK:\n\t\tPlayerSettings_SaveChanges();\n\t\tUI_PopMenu();\n\t\tbreak;\n\t}\n}\n\n\n/*\n=================\nPlayerSettings_MenuInit\n=================\n*/\nstatic void PlayerSettings_MenuInit( void ) {\n\tint\t\ty;\n\n\tmemset(&s_playersettings,0,sizeof(playersettings_t));\n\n\tPlayerSettings_Cache();\n\n\ts_playersettings.menu.key        = PlayerSettings_MenuKey;\n\ts_playersettings.menu.wrapAround = qtrue;\n\ts_playersettings.menu.fullscreen = qtrue;\n\n\ts_playersettings.banner.generic.type  = MTYPE_BTEXT;\n\ts_playersettings.banner.generic.x     = 320;\n\ts_playersettings.banner.generic.y     = 16;\n\ts_playersettings.banner.string        = \"PLAYER SETTINGS\";\n\ts_playersettings.banner.color         = color_white;\n\ts_playersettings.banner.style         = UI_CENTER;\n\n\ts_playersettings.framel.generic.type  = MTYPE_BITMAP;\n\ts_playersettings.framel.generic.name  = ART_FRAMEL;\n\ts_playersettings.framel.generic.flags = QMF_LEFT_JUSTIFY|QMF_INACTIVE;\n\ts_playersettings.framel.generic.x     = 0;\n\ts_playersettings.framel.generic.y     = 78;\n\ts_playersettings.framel.width         = 256;\n\ts_playersettings.framel.height        = 329;\n\n\ts_playersettings.framer.generic.type  = MTYPE_BITMAP;\n\ts_playersettings.framer.generic.name  = ART_FRAMER;\n\ts_playersettings.framer.generic.flags = QMF_LEFT_JUSTIFY|QMF_INACTIVE;\n\ts_playersettings.framer.generic.x     = 376;\n\ts_playersettings.framer.generic.y     = 76;\n\ts_playersettings.framer.width         = 256;\n\ts_playersettings.framer.height        = 334;\n\n\ty = 144;\n\ts_playersettings.name.generic.type\t\t\t= MTYPE_FIELD;\n\ts_playersettings.name.generic.flags\t\t\t= QMF_NODEFAULTINIT;\n\ts_playersettings.name.generic.ownerdraw\t\t= PlayerSettings_DrawName;\n\ts_playersettings.name.field.widthInChars\t= MAX_NAMELENGTH;\n\ts_playersettings.name.field.maxchars\t\t= MAX_NAMELENGTH;\n\ts_playersettings.name.generic.x\t\t\t\t= 192;\n\ts_playersettings.name.generic.y\t\t\t\t= y;\n\ts_playersettings.name.generic.left\t\t\t= 192 - 8;\n\ts_playersettings.name.generic.top\t\t\t= y - 8;\n\ts_playersettings.name.generic.right\t\t\t= 192 + 200;\n\ts_playersettings.name.generic.bottom\t\t= y + 2 * PROP_HEIGHT;\n\n\ty += 3 * PROP_HEIGHT;\n\ts_playersettings.handicap.generic.type\t\t= MTYPE_SPINCONTROL;\n\ts_playersettings.handicap.generic.flags\t\t= QMF_NODEFAULTINIT;\n\ts_playersettings.handicap.generic.id\t\t= ID_HANDICAP;\n\ts_playersettings.handicap.generic.ownerdraw\t= PlayerSettings_DrawHandicap;\n\ts_playersettings.handicap.generic.x\t\t\t= 192;\n\ts_playersettings.handicap.generic.y\t\t\t= y;\n\ts_playersettings.handicap.generic.left\t\t= 192 - 8;\n\ts_playersettings.handicap.generic.top\t\t= y - 8;\n\ts_playersettings.handicap.generic.right\t\t= 192 + 200;\n\ts_playersettings.handicap.generic.bottom\t= y + 2 * PROP_HEIGHT;\n\ts_playersettings.handicap.numitems\t\t\t= 20;\n\n\ty += 3 * PROP_HEIGHT;\n\ts_playersettings.effects.generic.type\t\t= MTYPE_SPINCONTROL;\n\ts_playersettings.effects.generic.flags\t\t= QMF_NODEFAULTINIT;\n\ts_playersettings.effects.generic.id\t\t\t= ID_EFFECTS;\n\ts_playersettings.effects.generic.ownerdraw\t= PlayerSettings_DrawEffects;\n\ts_playersettings.effects.generic.x\t\t\t= 192;\n\ts_playersettings.effects.generic.y\t\t\t= y;\n\ts_playersettings.effects.generic.left\t\t= 192 - 8;\n\ts_playersettings.effects.generic.top\t\t= y - 8;\n\ts_playersettings.effects.generic.right\t\t= 192 + 200;\n\ts_playersettings.effects.generic.bottom\t\t= y + 2* PROP_HEIGHT;\n\ts_playersettings.effects.numitems\t\t\t= 7;\n\n\ts_playersettings.model.generic.type\t\t\t= MTYPE_BITMAP;\n\ts_playersettings.model.generic.name\t\t\t= ART_MODEL0;\n\ts_playersettings.model.generic.flags\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_playersettings.model.generic.id\t\t\t= ID_MODEL;\n\ts_playersettings.model.generic.callback\t\t= PlayerSettings_MenuEvent;\n\ts_playersettings.model.generic.x\t\t\t= 640;\n\ts_playersettings.model.generic.y\t\t\t= 480-64;\n\ts_playersettings.model.width\t\t\t\t= 128;\n\ts_playersettings.model.height\t\t\t\t= 64;\n\ts_playersettings.model.focuspic\t\t\t\t= ART_MODEL1;\n\n\ts_playersettings.player.generic.type\t\t= MTYPE_BITMAP;\n\ts_playersettings.player.generic.flags\t\t= QMF_INACTIVE;\n\ts_playersettings.player.generic.ownerdraw\t= PlayerSettings_DrawPlayer;\n\ts_playersettings.player.generic.x\t\t\t= 400;\n\ts_playersettings.player.generic.y\t\t\t= -40;\n\ts_playersettings.player.width\t\t\t\t= 32*10;\n\ts_playersettings.player.height\t\t\t\t= 56*10;\n\n\ts_playersettings.back.generic.type\t\t\t= MTYPE_BITMAP;\n\ts_playersettings.back.generic.name\t\t\t= ART_BACK0;\n\ts_playersettings.back.generic.flags\t\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_playersettings.back.generic.id\t\t\t= ID_BACK;\n\ts_playersettings.back.generic.callback\t\t= PlayerSettings_MenuEvent;\n\ts_playersettings.back.generic.x\t\t\t\t= 0;\n\ts_playersettings.back.generic.y\t\t\t\t= 480-64;\n\ts_playersettings.back.width\t\t\t\t\t= 128;\n\ts_playersettings.back.height\t\t\t\t= 64;\n\ts_playersettings.back.focuspic\t\t\t\t= ART_BACK1;\n\n\ts_playersettings.item_null.generic.type\t\t= MTYPE_BITMAP;\n\ts_playersettings.item_null.generic.flags\t= QMF_LEFT_JUSTIFY|QMF_MOUSEONLY|QMF_SILENT;\n\ts_playersettings.item_null.generic.x\t\t= 0;\n\ts_playersettings.item_null.generic.y\t\t= 0;\n\ts_playersettings.item_null.width\t\t\t= 640;\n\ts_playersettings.item_null.height\t\t\t= 480;\n\n\tMenu_AddItem( &s_playersettings.menu, &s_playersettings.banner );\n\tMenu_AddItem( &s_playersettings.menu, &s_playersettings.framel );\n\tMenu_AddItem( &s_playersettings.menu, &s_playersettings.framer );\n\n\tMenu_AddItem( &s_playersettings.menu, &s_playersettings.name );\n\tMenu_AddItem( &s_playersettings.menu, &s_playersettings.handicap );\n\tMenu_AddItem( &s_playersettings.menu, &s_playersettings.effects );\n\tMenu_AddItem( &s_playersettings.menu, &s_playersettings.model );\n\tMenu_AddItem( &s_playersettings.menu, &s_playersettings.back );\n\n\tMenu_AddItem( &s_playersettings.menu, &s_playersettings.player );\n\n\tMenu_AddItem( &s_playersettings.menu, &s_playersettings.item_null );\n\n\tPlayerSettings_SetMenuItems();\n}\n\n\n/*\n=================\nPlayerSettings_Cache\n=================\n*/\nvoid PlayerSettings_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( ART_FRAMEL );\n\ttrap_R_RegisterShaderNoMip( ART_FRAMER );\n\ttrap_R_RegisterShaderNoMip( ART_MODEL0 );\n\ttrap_R_RegisterShaderNoMip( ART_MODEL1 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK0 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK1 );\n\n\ts_playersettings.fxBasePic = trap_R_RegisterShaderNoMip( ART_FX_BASE );\n\ts_playersettings.fxPic[0] = trap_R_RegisterShaderNoMip( ART_FX_RED );\n\ts_playersettings.fxPic[1] = trap_R_RegisterShaderNoMip( ART_FX_YELLOW );\n\ts_playersettings.fxPic[2] = trap_R_RegisterShaderNoMip( ART_FX_GREEN );\n\ts_playersettings.fxPic[3] = trap_R_RegisterShaderNoMip( ART_FX_TEAL );\n\ts_playersettings.fxPic[4] = trap_R_RegisterShaderNoMip( ART_FX_BLUE );\n\ts_playersettings.fxPic[5] = trap_R_RegisterShaderNoMip( ART_FX_CYAN );\n\ts_playersettings.fxPic[6] = trap_R_RegisterShaderNoMip( ART_FX_WHITE );\n}\n\n\n/*\n=================\nUI_PlayerSettingsMenu\n=================\n*/\nvoid UI_PlayerSettingsMenu( void ) {\n\tPlayerSettings_MenuInit();\n\tUI_PushMenu( &s_playersettings.menu );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_preferences.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=======================================================================\n\nGAME OPTIONS MENU\n\n=======================================================================\n*/\n\n\n#include \"ui_local.h\"\n\n\n#define ART_FRAMEL\t\t\t\t\"menu/art/frame2_l\"\n#define ART_FRAMER\t\t\t\t\"menu/art/frame1_r\"\n#define ART_BACK0\t\t\t\t\"menu/art/back_0\"\n#define ART_BACK1\t\t\t\t\"menu/art/back_1\"\n\n#define PREFERENCES_X_POS\t\t360\n\n#define ID_CROSSHAIR\t\t\t127\n#define ID_SIMPLEITEMS\t\t\t128\n#define ID_HIGHQUALITYSKY\t\t129\n#define ID_EJECTINGBRASS\t\t130\n#define ID_WALLMARKS\t\t\t131\n#define ID_DYNAMICLIGHTS\t\t132\n#define ID_IDENTIFYTARGET\t\t133\n#define ID_SYNCEVERYFRAME\t\t134\n#define ID_FORCEMODEL\t\t\t135\n#define ID_DRAWTEAMOVERLAY\t\t136\n#define ID_ALLOWDOWNLOAD\t\t\t137\n#define ID_BACK\t\t\t\t\t138\n\n#define\tNUM_CROSSHAIRS\t\t\t10\n\n\ntypedef struct {\n\tmenuframework_s\t\tmenu;\n\n\tmenutext_s\t\t\tbanner;\n\tmenubitmap_s\t\tframel;\n\tmenubitmap_s\t\tframer;\n\n\tmenulist_s\t\t\tcrosshair;\n\tmenuradiobutton_s\tsimpleitems;\n\tmenuradiobutton_s\tbrass;\n\tmenuradiobutton_s\twallmarks;\n\tmenuradiobutton_s\tdynamiclights;\n\tmenuradiobutton_s\tidentifytarget;\n\tmenuradiobutton_s\thighqualitysky;\n\tmenuradiobutton_s\tsynceveryframe;\n\tmenuradiobutton_s\tforcemodel;\n\tmenulist_s\t\t\tdrawteamoverlay;\n\tmenuradiobutton_s\tallowdownload;\n\tmenubitmap_s\t\tback;\n\n\tqhandle_t\t\t\tcrosshairShader[NUM_CROSSHAIRS];\n} preferences_t;\n\nstatic preferences_t s_preferences;\n\nstatic const char *teamoverlay_names[] =\n{\n\t\"off\",\n\t\"upper right\",\n\t\"lower right\",\n\t\"lower left\",\n\t0\n};\n\nstatic void Preferences_SetMenuItems( void ) {\n\ts_preferences.crosshair.curvalue\t\t= (int)trap_Cvar_VariableValue( \"cg_drawCrosshair\" ) % NUM_CROSSHAIRS;\n\ts_preferences.simpleitems.curvalue\t\t= trap_Cvar_VariableValue( \"cg_simpleItems\" ) != 0;\n\ts_preferences.brass.curvalue\t\t\t= trap_Cvar_VariableValue( \"cg_brassTime\" ) != 0;\n\ts_preferences.wallmarks.curvalue\t\t= trap_Cvar_VariableValue( \"cg_marks\" ) != 0;\n\ts_preferences.identifytarget.curvalue\t= trap_Cvar_VariableValue( \"cg_drawCrosshairNames\" ) != 0;\n\ts_preferences.dynamiclights.curvalue\t= trap_Cvar_VariableValue( \"r_dynamiclight\" ) != 0;\n\ts_preferences.highqualitysky.curvalue\t= trap_Cvar_VariableValue ( \"r_fastsky\" ) == 0;\n\ts_preferences.synceveryframe.curvalue\t= trap_Cvar_VariableValue( \"r_finish\" ) != 0;\n\ts_preferences.forcemodel.curvalue\t\t= trap_Cvar_VariableValue( \"cg_forcemodel\" ) != 0;\n\ts_preferences.drawteamoverlay.curvalue\t= Com_Clamp( 0, 3, trap_Cvar_VariableValue( \"cg_drawTeamOverlay\" ) );\n\ts_preferences.allowdownload.curvalue\t= trap_Cvar_VariableValue( \"cl_allowDownload\" ) != 0;\n}\n\n\nstatic void Preferences_Event( void* ptr, int notification ) {\n\tif( notification != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tswitch( ((menucommon_s*)ptr)->id ) {\n\tcase ID_CROSSHAIR:\n\t\ts_preferences.crosshair.curvalue++;\n\t\tif( s_preferences.crosshair.curvalue == NUM_CROSSHAIRS ) {\n\t\t\ts_preferences.crosshair.curvalue = 0;\n\t\t}\n\t\ttrap_Cvar_SetValue( \"cg_drawCrosshair\", s_preferences.crosshair.curvalue );\n\t\tbreak;\n\n\tcase ID_SIMPLEITEMS:\n\t\ttrap_Cvar_SetValue( \"cg_simpleItems\", s_preferences.simpleitems.curvalue );\n\t\tbreak;\n\n\tcase ID_HIGHQUALITYSKY:\n\t\ttrap_Cvar_SetValue( \"r_fastsky\", !s_preferences.highqualitysky.curvalue );\n\t\tbreak;\n\n\tcase ID_EJECTINGBRASS:\n\t\tif ( s_preferences.brass.curvalue )\n\t\t\ttrap_Cvar_Reset( \"cg_brassTime\" );\n\t\telse\n\t\t\ttrap_Cvar_SetValue( \"cg_brassTime\", 0 );\n\t\tbreak;\n\n\tcase ID_WALLMARKS:\n\t\ttrap_Cvar_SetValue( \"cg_marks\", s_preferences.wallmarks.curvalue );\n\t\tbreak;\n\n\tcase ID_DYNAMICLIGHTS:\n\t\ttrap_Cvar_SetValue( \"r_dynamiclight\", s_preferences.dynamiclights.curvalue );\n\t\tbreak;\t\t\n\n\tcase ID_IDENTIFYTARGET:\n\t\ttrap_Cvar_SetValue( \"cg_drawCrosshairNames\", s_preferences.identifytarget.curvalue );\n\t\tbreak;\n\n\tcase ID_SYNCEVERYFRAME:\n\t\ttrap_Cvar_SetValue( \"r_finish\", s_preferences.synceveryframe.curvalue );\n\t\tbreak;\n\n\tcase ID_FORCEMODEL:\n\t\ttrap_Cvar_SetValue( \"cg_forcemodel\", s_preferences.forcemodel.curvalue );\n\t\tbreak;\n\n\tcase ID_DRAWTEAMOVERLAY:\n\t\ttrap_Cvar_SetValue( \"cg_drawTeamOverlay\", s_preferences.drawteamoverlay.curvalue );\n\t\tbreak;\n\n\tcase ID_ALLOWDOWNLOAD:\n\t\ttrap_Cvar_SetValue( \"cl_allowDownload\", s_preferences.allowdownload.curvalue );\n\t\ttrap_Cvar_SetValue( \"sv_allowDownload\", s_preferences.allowdownload.curvalue );\n\t\tbreak;\n\n\tcase ID_BACK:\n\t\tUI_PopMenu();\n\t\tbreak;\n\t}\n}\n\n\n/*\n=================\nCrosshair_Draw\n=================\n*/\nstatic void Crosshair_Draw( void *self ) {\n\tmenulist_s\t*s;\n\tfloat\t\t*color;\n\tint\t\t\tx, y;\n\tint\t\t\tstyle;\n\tqboolean\tfocus;\n\n\ts = (menulist_s *)self;\n\tx = s->generic.x;\n\ty =\ts->generic.y;\n\n\tstyle = UI_SMALLFONT;\n\tfocus = (s->generic.parent->cursor == s->generic.menuPosition);\n\n\tif ( s->generic.flags & QMF_GRAYED )\n\t\tcolor = text_color_disabled;\n\telse if ( focus )\n\t{\n\t\tcolor = text_color_highlight;\n\t\tstyle |= UI_PULSE;\n\t}\n\telse if ( s->generic.flags & QMF_BLINK )\n\t{\n\t\tcolor = text_color_highlight;\n\t\tstyle |= UI_BLINK;\n\t}\n\telse\n\t\tcolor = text_color_normal;\n\n\tif ( focus )\n\t{\n\t\t// draw cursor\n\t\tUI_FillRect( s->generic.left, s->generic.top, s->generic.right-s->generic.left+1, s->generic.bottom-s->generic.top+1, listbar_color ); \n\t\tUI_DrawChar( x, y, 13, UI_CENTER|UI_BLINK|UI_SMALLFONT, color);\n\t}\n\n\tUI_DrawString( x - SMALLCHAR_WIDTH, y, s->generic.name, style|UI_RIGHT, color );\n\tif( !s->curvalue ) {\n\t\treturn;\n\t}\n\tUI_DrawHandlePic( x + SMALLCHAR_WIDTH, y - 4, 24, 24, s_preferences.crosshairShader[s->curvalue] );\n}\n\n\nstatic void Preferences_MenuInit( void ) {\n\tint\t\t\t\ty;\n\n\tmemset( &s_preferences, 0 ,sizeof(preferences_t) );\n\n\tPreferences_Cache();\n\n\ts_preferences.menu.wrapAround = qtrue;\n\ts_preferences.menu.fullscreen = qtrue;\n\n\ts_preferences.banner.generic.type  = MTYPE_BTEXT;\n\ts_preferences.banner.generic.x\t   = 320;\n\ts_preferences.banner.generic.y\t   = 16;\n\ts_preferences.banner.string\t\t   = \"GAME OPTIONS\";\n\ts_preferences.banner.color         = color_white;\n\ts_preferences.banner.style         = UI_CENTER;\n\n\ts_preferences.framel.generic.type  = MTYPE_BITMAP;\n\ts_preferences.framel.generic.name  = ART_FRAMEL;\n\ts_preferences.framel.generic.flags = QMF_INACTIVE;\n\ts_preferences.framel.generic.x\t   = 0;\n\ts_preferences.framel.generic.y\t   = 78;\n\ts_preferences.framel.width  \t   = 256;\n\ts_preferences.framel.height  \t   = 329;\n\n\ts_preferences.framer.generic.type  = MTYPE_BITMAP;\n\ts_preferences.framer.generic.name  = ART_FRAMER;\n\ts_preferences.framer.generic.flags = QMF_INACTIVE;\n\ts_preferences.framer.generic.x\t   = 376;\n\ts_preferences.framer.generic.y\t   = 76;\n\ts_preferences.framer.width  \t   = 256;\n\ts_preferences.framer.height  \t   = 334;\n\n\ty = 144;\n\ts_preferences.crosshair.generic.type\t\t= MTYPE_TEXT;\n\ts_preferences.crosshair.generic.flags\t\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT|QMF_NODEFAULTINIT|QMF_OWNERDRAW;\n\ts_preferences.crosshair.generic.x\t\t\t= PREFERENCES_X_POS;\n\ts_preferences.crosshair.generic.y\t\t\t= y;\n\ts_preferences.crosshair.generic.name\t\t= \"Crosshair:\";\n\ts_preferences.crosshair.generic.callback\t= Preferences_Event;\n\ts_preferences.crosshair.generic.ownerdraw\t= Crosshair_Draw;\n\ts_preferences.crosshair.generic.id\t\t\t= ID_CROSSHAIR;\n\ts_preferences.crosshair.generic.top\t\t\t= y - 4;\n\ts_preferences.crosshair.generic.bottom\t\t= y + 20;\n\ts_preferences.crosshair.generic.left\t\t= PREFERENCES_X_POS - ( ( strlen(s_preferences.crosshair.generic.name) + 1 ) * SMALLCHAR_WIDTH );\n\ts_preferences.crosshair.generic.right\t\t= PREFERENCES_X_POS + 48;\n\n\ty += BIGCHAR_HEIGHT+2+4;\n\ts_preferences.simpleitems.generic.type        = MTYPE_RADIOBUTTON;\n\ts_preferences.simpleitems.generic.name\t      = \"Simple Items:\";\n\ts_preferences.simpleitems.generic.flags\t      = QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_preferences.simpleitems.generic.callback    = Preferences_Event;\n\ts_preferences.simpleitems.generic.id          = ID_SIMPLEITEMS;\n\ts_preferences.simpleitems.generic.x\t          = PREFERENCES_X_POS;\n\ts_preferences.simpleitems.generic.y\t          = y;\n\n\ty += BIGCHAR_HEIGHT;\n\ts_preferences.wallmarks.generic.type          = MTYPE_RADIOBUTTON;\n\ts_preferences.wallmarks.generic.name\t      = \"Marks on Walls:\";\n\ts_preferences.wallmarks.generic.flags\t      = QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_preferences.wallmarks.generic.callback      = Preferences_Event;\n\ts_preferences.wallmarks.generic.id            = ID_WALLMARKS;\n\ts_preferences.wallmarks.generic.x\t          = PREFERENCES_X_POS;\n\ts_preferences.wallmarks.generic.y\t          = y;\n\n\ty += BIGCHAR_HEIGHT+2;\n\ts_preferences.brass.generic.type              = MTYPE_RADIOBUTTON;\n\ts_preferences.brass.generic.name\t          = \"Ejecting Brass:\";\n\ts_preferences.brass.generic.flags\t          = QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_preferences.brass.generic.callback          = Preferences_Event;\n\ts_preferences.brass.generic.id                = ID_EJECTINGBRASS;\n\ts_preferences.brass.generic.x\t              = PREFERENCES_X_POS;\n\ts_preferences.brass.generic.y\t              = y;\n\n\ty += BIGCHAR_HEIGHT+2;\n\ts_preferences.dynamiclights.generic.type      = MTYPE_RADIOBUTTON;\n\ts_preferences.dynamiclights.generic.name\t  = \"Dynamic Lights:\";\n\ts_preferences.dynamiclights.generic.flags     = QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_preferences.dynamiclights.generic.callback  = Preferences_Event;\n\ts_preferences.dynamiclights.generic.id        = ID_DYNAMICLIGHTS;\n\ts_preferences.dynamiclights.generic.x\t      = PREFERENCES_X_POS;\n\ts_preferences.dynamiclights.generic.y\t      = y;\n\n\ty += BIGCHAR_HEIGHT+2;\n\ts_preferences.identifytarget.generic.type     = MTYPE_RADIOBUTTON;\n\ts_preferences.identifytarget.generic.name\t  = \"Identify Target:\";\n\ts_preferences.identifytarget.generic.flags    = QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_preferences.identifytarget.generic.callback = Preferences_Event;\n\ts_preferences.identifytarget.generic.id       = ID_IDENTIFYTARGET;\n\ts_preferences.identifytarget.generic.x\t      = PREFERENCES_X_POS;\n\ts_preferences.identifytarget.generic.y\t      = y;\n\n\ty += BIGCHAR_HEIGHT+2;\n\ts_preferences.highqualitysky.generic.type     = MTYPE_RADIOBUTTON;\n\ts_preferences.highqualitysky.generic.name\t  = \"High Quality Sky:\";\n\ts_preferences.highqualitysky.generic.flags\t  = QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_preferences.highqualitysky.generic.callback = Preferences_Event;\n\ts_preferences.highqualitysky.generic.id       = ID_HIGHQUALITYSKY;\n\ts_preferences.highqualitysky.generic.x\t      = PREFERENCES_X_POS;\n\ts_preferences.highqualitysky.generic.y\t      = y;\n\n\ty += BIGCHAR_HEIGHT+2;\n\ts_preferences.synceveryframe.generic.type     = MTYPE_RADIOBUTTON;\n\ts_preferences.synceveryframe.generic.name\t  = \"Sync Every Frame:\";\n\ts_preferences.synceveryframe.generic.flags\t  = QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_preferences.synceveryframe.generic.callback = Preferences_Event;\n\ts_preferences.synceveryframe.generic.id       = ID_SYNCEVERYFRAME;\n\ts_preferences.synceveryframe.generic.x\t      = PREFERENCES_X_POS;\n\ts_preferences.synceveryframe.generic.y\t      = y;\n\n\ty += BIGCHAR_HEIGHT+2;\n\ts_preferences.forcemodel.generic.type     = MTYPE_RADIOBUTTON;\n\ts_preferences.forcemodel.generic.name\t  = \"Force Player Models:\";\n\ts_preferences.forcemodel.generic.flags\t  = QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_preferences.forcemodel.generic.callback = Preferences_Event;\n\ts_preferences.forcemodel.generic.id       = ID_FORCEMODEL;\n\ts_preferences.forcemodel.generic.x\t      = PREFERENCES_X_POS;\n\ts_preferences.forcemodel.generic.y\t      = y;\n\n\ty += BIGCHAR_HEIGHT+2;\n\ts_preferences.drawteamoverlay.generic.type     = MTYPE_SPINCONTROL;\n\ts_preferences.drawteamoverlay.generic.name\t   = \"Draw Team Overlay:\";\n\ts_preferences.drawteamoverlay.generic.flags\t   = QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_preferences.drawteamoverlay.generic.callback = Preferences_Event;\n\ts_preferences.drawteamoverlay.generic.id       = ID_DRAWTEAMOVERLAY;\n\ts_preferences.drawteamoverlay.generic.x\t       = PREFERENCES_X_POS;\n\ts_preferences.drawteamoverlay.generic.y\t       = y;\n\ts_preferences.drawteamoverlay.itemnames\t\t\t= teamoverlay_names;\n\n\ty += BIGCHAR_HEIGHT+2;\n\ts_preferences.allowdownload.generic.type     = MTYPE_RADIOBUTTON;\n\ts_preferences.allowdownload.generic.name\t   = \"Automatic Downloading:\";\n\ts_preferences.allowdownload.generic.flags\t   = QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_preferences.allowdownload.generic.callback = Preferences_Event;\n\ts_preferences.allowdownload.generic.id       = ID_ALLOWDOWNLOAD;\n\ts_preferences.allowdownload.generic.x\t       = PREFERENCES_X_POS;\n\ts_preferences.allowdownload.generic.y\t       = y;\n\n\ty += BIGCHAR_HEIGHT+2;\n\ts_preferences.back.generic.type\t    = MTYPE_BITMAP;\n\ts_preferences.back.generic.name     = ART_BACK0;\n\ts_preferences.back.generic.flags    = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_preferences.back.generic.callback = Preferences_Event;\n\ts_preferences.back.generic.id\t    = ID_BACK;\n\ts_preferences.back.generic.x\t\t= 0;\n\ts_preferences.back.generic.y\t\t= 480-64;\n\ts_preferences.back.width  \t\t    = 128;\n\ts_preferences.back.height  \t\t    = 64;\n\ts_preferences.back.focuspic         = ART_BACK1;\n\n\tMenu_AddItem( &s_preferences.menu, &s_preferences.banner );\n\tMenu_AddItem( &s_preferences.menu, &s_preferences.framel );\n\tMenu_AddItem( &s_preferences.menu, &s_preferences.framer );\n\n\tMenu_AddItem( &s_preferences.menu, &s_preferences.crosshair );\n\tMenu_AddItem( &s_preferences.menu, &s_preferences.simpleitems );\n\tMenu_AddItem( &s_preferences.menu, &s_preferences.wallmarks );\n\tMenu_AddItem( &s_preferences.menu, &s_preferences.brass );\n\tMenu_AddItem( &s_preferences.menu, &s_preferences.dynamiclights );\n\tMenu_AddItem( &s_preferences.menu, &s_preferences.identifytarget );\n\tMenu_AddItem( &s_preferences.menu, &s_preferences.highqualitysky );\n\tMenu_AddItem( &s_preferences.menu, &s_preferences.synceveryframe );\n\tMenu_AddItem( &s_preferences.menu, &s_preferences.forcemodel );\n\tMenu_AddItem( &s_preferences.menu, &s_preferences.drawteamoverlay );\n\tMenu_AddItem( &s_preferences.menu, &s_preferences.allowdownload );\n\n\tMenu_AddItem( &s_preferences.menu, &s_preferences.back );\n\n\tPreferences_SetMenuItems();\n}\n\n\n/*\n===============\nPreferences_Cache\n===============\n*/\nvoid Preferences_Cache( void ) {\n\tint\t\tn;\n\n\ttrap_R_RegisterShaderNoMip( ART_FRAMEL );\n\ttrap_R_RegisterShaderNoMip( ART_FRAMER );\n\ttrap_R_RegisterShaderNoMip( ART_BACK0 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK1 );\n\tfor( n = 0; n < NUM_CROSSHAIRS; n++ ) {\n\t\ts_preferences.crosshairShader[n] = trap_R_RegisterShaderNoMip( va(\"gfx/2d/crosshair%c\", 'a' + n ) );\n\t}\n}\n\n\n/*\n===============\nUI_PreferencesMenu\n===============\n*/\nvoid UI_PreferencesMenu( void ) {\n\tPreferences_MenuInit();\n\tUI_PushMenu( &s_preferences.menu );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_qmenu.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/**********************************************************************\n\tUI_QMENU.C\n\n\tQuake's menu framework system.\n**********************************************************************/\n#include \"ui_local.h\"\n\nsfxHandle_t menu_in_sound;\nsfxHandle_t menu_move_sound;\nsfxHandle_t menu_out_sound;\nsfxHandle_t menu_buzz_sound;\nsfxHandle_t menu_null_sound;\nsfxHandle_t weaponChangeSound;\n\nstatic qhandle_t\tsliderBar;\nstatic qhandle_t\tsliderButton_0;\nstatic qhandle_t\tsliderButton_1;\n\nvec4_t menu_text_color\t    = {1.0f, 1.0f, 1.0f, 1.0f};\nvec4_t menu_dim_color       = {0.0f, 0.0f, 0.0f, 0.75f};\nvec4_t color_black\t    = {0.00f, 0.00f, 0.00f, 1.00f};\nvec4_t color_white\t    = {1.00f, 1.00f, 1.00f, 1.00f};\nvec4_t color_yellow\t    = {1.00f, 1.00f, 0.00f, 1.00f};\nvec4_t color_blue\t    = {0.00f, 0.00f, 1.00f, 1.00f};\nvec4_t color_lightOrange    = {1.00f, 0.68f, 0.00f, 1.00f };\nvec4_t color_orange\t    = {1.00f, 0.43f, 0.00f, 1.00f};\nvec4_t color_red\t    = {1.00f, 0.00f, 0.00f, 1.00f};\nvec4_t color_dim\t    = {0.00f, 0.00f, 0.00f, 0.25f};\n\n// current color scheme\nvec4_t pulse_color          = {1.00f, 1.00f, 1.00f, 1.00f};\nvec4_t text_color_disabled  = {0.50f, 0.50f, 0.50f, 1.00f};\t// light gray\nvec4_t text_color_normal    = {1.00f, 0.43f, 0.00f, 1.00f};\t// light orange\nvec4_t text_color_highlight = {1.00f, 1.00f, 0.00f, 1.00f};\t// bright yellow\nvec4_t listbar_color        = {1.00f, 0.43f, 0.00f, 0.30f};\t// transluscent orange\nvec4_t text_color_status    = {1.00f, 1.00f, 1.00f, 1.00f};\t// bright white\t\n\n// action widget\nstatic void\tAction_Init( menuaction_s *a );\nstatic void\tAction_Draw( menuaction_s *a );\n\n// radio button widget\nstatic void\tRadioButton_Init( menuradiobutton_s *rb );\nstatic void\tRadioButton_Draw( menuradiobutton_s *rb );\nstatic sfxHandle_t RadioButton_Key( menuradiobutton_s *rb, int key );\n\n// slider widget\nstatic void Slider_Init( menuslider_s *s );\nstatic sfxHandle_t Slider_Key( menuslider_s *s, int key );\nstatic void\tSlider_Draw( menuslider_s *s );\n\n// spin control widget\nstatic void\tSpinControl_Init( menulist_s *s );\nstatic void\tSpinControl_Draw( menulist_s *s );\nstatic sfxHandle_t SpinControl_Key( menulist_s *l, int key );\n\n// text widget\nstatic void Text_Init( menutext_s *b );\nstatic void Text_Draw( menutext_s *b );\n\n// scrolllist widget\nstatic void\tScrollList_Init( menulist_s *l );\nsfxHandle_t ScrollList_Key( menulist_s *l, int key );\n\n// proportional text widget\nstatic void PText_Init( menutext_s *b );\nstatic void PText_Draw( menutext_s *b );\n\n// proportional banner text widget\nstatic void BText_Init( menutext_s *b );\nstatic void BText_Draw( menutext_s *b );\n\n/*\n=================\nText_Init\n=================\n*/\nstatic void Text_Init( menutext_s *t )\n{\n\tt->generic.flags |= QMF_INACTIVE;\n}\n\n/*\n=================\nText_Draw\n=================\n*/\nstatic void Text_Draw( menutext_s *t )\n{\n\tint\t\tx;\n\tint\t\ty;\n\tchar\tbuff[512];\t\n\tfloat*\tcolor;\n\n\tx = t->generic.x;\n\ty = t->generic.y;\n\n\tbuff[0] = '\\0';\n\n\t// possible label\n\tif (t->generic.name)\n\t\tstrcpy(buff,t->generic.name);\n\n\t// possible value\n\tif (t->string)\n\t\tstrcat(buff,t->string);\n\t\t\n\tif (t->generic.flags & QMF_GRAYED)\n\t\tcolor = text_color_disabled;\n\telse\n\t\tcolor = t->color;\n\n\tUI_DrawString( x, y, buff, t->style, color );\n}\n\n/*\n=================\nBText_Init\n=================\n*/\nstatic void BText_Init( menutext_s *t )\n{\n\tt->generic.flags |= QMF_INACTIVE;\n}\n\n/*\n=================\nBText_Draw\n=================\n*/\nstatic void BText_Draw( menutext_s *t )\n{\n\tint\t\tx;\n\tint\t\ty;\n\tfloat*\tcolor;\n\n\tx = t->generic.x;\n\ty = t->generic.y;\n\n\tif (t->generic.flags & QMF_GRAYED)\n\t\tcolor = text_color_disabled;\n\telse\n\t\tcolor = t->color;\n\n\tUI_DrawBannerString( x, y, t->string, t->style, color );\n}\n\n/*\n=================\nPText_Init\n=================\n*/\nstatic void PText_Init( menutext_s *t )\n{\n\tint\tx;\n\tint\ty;\n\tint\tw;\n\tint\th;\n\tfloat\tsizeScale;\n\n\tsizeScale = UI_ProportionalSizeScale( t->style );\n\n\tx = t->generic.x;\n\ty = t->generic.y;\n\tw = UI_ProportionalStringWidth( t->string ) * sizeScale;\n\th =\tPROP_HEIGHT * sizeScale;\n\n\tif( t->generic.flags & QMF_RIGHT_JUSTIFY ) {\n\t\tx -= w;\n\t}\n\telse if( t->generic.flags & QMF_CENTER_JUSTIFY ) {\n\t\tx -= w / 2;\n\t}\n\n\tt->generic.left   = x - PROP_GAP_WIDTH * sizeScale;\n\tt->generic.right  = x + w + PROP_GAP_WIDTH * sizeScale;\n\tt->generic.top    = y;\n\tt->generic.bottom = y + h;\n}\n\n/*\n=================\nPText_Draw\n=================\n*/\nstatic void PText_Draw( menutext_s *t )\n{\n\tint\t\tx;\n\tint\t\ty;\n\tfloat *\tcolor;\n\tint\t\tstyle;\n\n\tx = t->generic.x;\n\ty = t->generic.y;\n\n\tif (t->generic.flags & QMF_GRAYED)\n\t\tcolor = text_color_disabled;\n\telse\n\t\tcolor = t->color;\n\n\tstyle = t->style;\n\tif( t->generic.flags & QMF_PULSEIFFOCUS ) {\n\t\tif( Menu_ItemAtCursor( t->generic.parent ) == t ) {\n\t\t\tstyle |= UI_PULSE;\n\t\t}\n\t\telse {\n\t\t\tstyle |= UI_INVERSE;\n\t\t}\n\t}\n\n\tUI_DrawProportionalString( x, y, t->string, style, color );\n}\n\n/*\n=================\nBitmap_Init\n=================\n*/\nvoid Bitmap_Init( menubitmap_s *b )\n{\n\tint\tx;\n\tint\ty;\n\tint\tw;\n\tint\th;\n\n\tx = b->generic.x;\n\ty = b->generic.y;\n\tw = b->width;\n\th =\tb->height;\n\tif( w < 0 ) {\n\t\tw = -w;\n\t}\n\tif( h < 0 ) {\n\t\th = -h;\n\t}\n\n\tif (b->generic.flags & QMF_RIGHT_JUSTIFY)\n\t{\n\t\tx = x - w;\n\t}\n\telse if (b->generic.flags & QMF_CENTER_JUSTIFY)\n\t{\n\t\tx = x - w/2;\n\t}\n\n\tb->generic.left   = x;\n\tb->generic.right  = x + w;\n\tb->generic.top    = y;\n\tb->generic.bottom = y + h;\n\n\tb->shader      = 0;\n\tb->focusshader = 0;\n}\n\n/*\n=================\nBitmap_Draw\n=================\n*/\nvoid Bitmap_Draw( menubitmap_s *b )\n{\n\tfloat\tx;\n\tfloat\ty;\n\tfloat\tw;\n\tfloat\th;\n\tvec4_t\ttempcolor;\n\tfloat*\tcolor;\n\n\tx = b->generic.x;\n\ty = b->generic.y;\n\tw = b->width;\n\th =\tb->height;\n\n\tif (b->generic.flags & QMF_RIGHT_JUSTIFY)\n\t{\n\t\tx = x - w;\n\t}\n\telse if (b->generic.flags & QMF_CENTER_JUSTIFY)\n\t{\n\t\tx = x - w/2;\n\t}\n\n\t// used to refresh shader\n\tif (b->generic.name && !b->shader)\n\t{\n\t\tb->shader = trap_R_RegisterShaderNoMip( b->generic.name );\n\t\tif (!b->shader && b->errorpic)\n\t\t\tb->shader = trap_R_RegisterShaderNoMip( b->errorpic );\n\t}\n\n\tif (b->focuspic && !b->focusshader)\n\t\tb->focusshader = trap_R_RegisterShaderNoMip( b->focuspic );\n\n\tif (b->generic.flags & QMF_GRAYED)\n\t{\n\t\tif (b->shader)\n\t\t{\n\t\t\ttrap_R_SetColor( colorMdGrey );\n\t\t\tUI_DrawHandlePic( x, y, w, h, b->shader );\n\t\t\ttrap_R_SetColor( NULL );\n\t\t}\n\t}\n\telse\n\t{\n\t\tif (b->shader)\n\t\t\tUI_DrawHandlePic( x, y, w, h, b->shader );\n\n\t\t// bk001204 - parentheses\n\t\tif (  ( (b->generic.flags & QMF_PULSE) \n\t\t\t|| (b->generic.flags & QMF_PULSEIFFOCUS) )\n\t\t      && (Menu_ItemAtCursor( b->generic.parent ) == b))\n\t\t{\t\n\t\t\tif (b->focuscolor)\t\t\t\n\t\t\t{\n\t\t\t\ttempcolor[0] = b->focuscolor[0];\n\t\t\t\ttempcolor[1] = b->focuscolor[1];\n\t\t\t\ttempcolor[2] = b->focuscolor[2];\n\t\t\t\tcolor        = tempcolor;\t\n\t\t\t}\n\t\t\telse\n\t\t\t\tcolor = pulse_color;\n\t\t\tcolor[3] = 0.5+0.5*sin(uis.realtime/PULSE_DIVISOR);\n\n\t\t\ttrap_R_SetColor( color );\n\t\t\tUI_DrawHandlePic( x, y, w, h, b->focusshader );\n\t\t\ttrap_R_SetColor( NULL );\n\t\t}\n\t\telse if ((b->generic.flags & QMF_HIGHLIGHT) || ((b->generic.flags & QMF_HIGHLIGHT_IF_FOCUS) && (Menu_ItemAtCursor( b->generic.parent ) == b)))\n\t\t{\t\n\t\t\tif (b->focuscolor)\n\t\t\t{\n\t\t\t\ttrap_R_SetColor( b->focuscolor );\n\t\t\t\tUI_DrawHandlePic( x, y, w, h, b->focusshader );\n\t\t\t\ttrap_R_SetColor( NULL );\n\t\t\t}\n\t\t\telse\n\t\t\t\tUI_DrawHandlePic( x, y, w, h, b->focusshader );\n\t\t}\n\t}\n}\n\n/*\n=================\nAction_Init\n=================\n*/\nstatic void Action_Init( menuaction_s *a )\n{\n\tint\tlen;\n\n\t// calculate bounds\n\tif (a->generic.name)\n\t\tlen = strlen(a->generic.name);\n\telse\n\t\tlen = 0;\n\n\t// left justify text\n\ta->generic.left   = a->generic.x; \n\ta->generic.right  = a->generic.x + len*BIGCHAR_WIDTH;\n\ta->generic.top    = a->generic.y;\n\ta->generic.bottom = a->generic.y + BIGCHAR_HEIGHT;\n}\n\n/*\n=================\nAction_Draw\n=================\n*/\nstatic void Action_Draw( menuaction_s *a )\n{\n\tint\t\tx, y;\n\tint\t\tstyle;\n\tfloat*\tcolor;\n\n\tstyle = 0;\n\tcolor = menu_text_color;\n\tif ( a->generic.flags & QMF_GRAYED )\n\t{\n\t\tcolor = text_color_disabled;\n\t}\n\telse if (( a->generic.flags & QMF_PULSEIFFOCUS ) && ( a->generic.parent->cursor == a->generic.menuPosition ))\n\t{\n\t\tcolor = text_color_highlight;\n\t\tstyle = UI_PULSE;\n\t}\n\telse if (( a->generic.flags & QMF_HIGHLIGHT_IF_FOCUS ) && ( a->generic.parent->cursor == a->generic.menuPosition ))\n\t{\n\t\tcolor = text_color_highlight;\n\t}\n\telse if ( a->generic.flags & QMF_BLINK )\n\t{\n\t\tstyle = UI_BLINK;\n\t\tcolor = text_color_highlight;\n\t}\n\n\tx = a->generic.x;\n\ty = a->generic.y;\n\n\tUI_DrawString( x, y, a->generic.name, UI_LEFT|style, color );\n\n\tif ( a->generic.parent->cursor == a->generic.menuPosition )\n\t{\n\t\t// draw cursor\n\t\tUI_DrawChar( x - BIGCHAR_WIDTH, y, 13, UI_LEFT|UI_BLINK, color);\n\t}\n}\n\n/*\n=================\nRadioButton_Init\n=================\n*/\nstatic void RadioButton_Init( menuradiobutton_s *rb )\n{\n\tint\tlen;\n\n\t// calculate bounds\n\tif (rb->generic.name)\n\t\tlen = strlen(rb->generic.name);\n\telse\n\t\tlen = 0;\n\n\trb->generic.left   = rb->generic.x - (len+1)*SMALLCHAR_WIDTH;\n\trb->generic.right  = rb->generic.x + 6*SMALLCHAR_WIDTH;\n\trb->generic.top    = rb->generic.y;\n\trb->generic.bottom = rb->generic.y + SMALLCHAR_HEIGHT;\n}\n\n/*\n=================\nRadioButton_Key\n=================\n*/\nstatic sfxHandle_t RadioButton_Key( menuradiobutton_s *rb, int key )\n{\n\tswitch (key)\n\t{\n\t\tcase K_MOUSE1:\n\t\t\tif (!(rb->generic.flags & QMF_HASMOUSEFOCUS))\n\t\t\t\tbreak;\n\n\t\tcase K_JOY1:\n\t\tcase K_JOY2:\n\t\tcase K_JOY3:\n\t\tcase K_JOY4:\n\t\tcase K_ENTER:\n\t\tcase K_KP_ENTER:\n\t\tcase K_KP_LEFTARROW:\n\t\tcase K_LEFTARROW:\n\t\tcase K_KP_RIGHTARROW:\n\t\tcase K_RIGHTARROW:\n\t\t\trb->curvalue = !rb->curvalue;\n\t\t\tif ( rb->generic.callback )\n\t\t\t\trb->generic.callback( rb, QM_ACTIVATED );\n\n\t\t\treturn (menu_move_sound);\n\t}\n\n\t// key not handled\n\treturn 0;\n}\n\n/*\n=================\nRadioButton_Draw\n=================\n*/\nstatic void RadioButton_Draw( menuradiobutton_s *rb )\n{\n\tint\tx;\n\tint y;\n\tfloat *color;\n\tint\tstyle;\n\tqboolean focus;\n\n\tx = rb->generic.x;\n\ty = rb->generic.y;\n\n\tfocus = (rb->generic.parent->cursor == rb->generic.menuPosition);\n\n\tif ( rb->generic.flags & QMF_GRAYED )\n\t{\n\t\tcolor = text_color_disabled;\n\t\tstyle = UI_LEFT|UI_SMALLFONT;\n\t}\n\telse if ( focus )\n\t{\n\t\tcolor = text_color_highlight;\n\t\tstyle = UI_LEFT|UI_PULSE|UI_SMALLFONT;\n\t}\n\telse\n\t{\n\t\tcolor = text_color_normal;\n\t\tstyle = UI_LEFT|UI_SMALLFONT;\n\t}\n\n\tif ( focus )\n\t{\n\t\t// draw cursor\n\t\tUI_FillRect( rb->generic.left, rb->generic.top, rb->generic.right-rb->generic.left+1, rb->generic.bottom-rb->generic.top+1, listbar_color ); \n\t\tUI_DrawChar( x, y, 13, UI_CENTER|UI_BLINK|UI_SMALLFONT, color);\n\t}\n\n\tif ( rb->generic.name )\n\t\tUI_DrawString( x - SMALLCHAR_WIDTH, y, rb->generic.name, UI_RIGHT|UI_SMALLFONT, color );\n\n\tif ( !rb->curvalue )\n\t{\n\t\tUI_DrawHandlePic( x + SMALLCHAR_WIDTH, y + 2, 16, 16, uis.rb_off);\n\t\tUI_DrawString( x + SMALLCHAR_WIDTH + 16, y, \"off\", style, color );\n\t}\n\telse\n\t{\n\t\tUI_DrawHandlePic( x + SMALLCHAR_WIDTH, y + 2, 16, 16, uis.rb_on );\n\t\tUI_DrawString( x + SMALLCHAR_WIDTH + 16, y, \"on\", style, color );\n\t}\n}\n\n/*\n=================\nSlider_Init\n=================\n*/\nstatic void Slider_Init( menuslider_s *s )\n{\n\tint len;\n\n\t// calculate bounds\n\tif (s->generic.name)\n\t\tlen = strlen(s->generic.name);\n\telse\n\t\tlen = 0;\n\n\ts->generic.left   = s->generic.x - (len+1)*SMALLCHAR_WIDTH; \n\ts->generic.right  = s->generic.x + (SLIDER_RANGE+2+1)*SMALLCHAR_WIDTH;\n\ts->generic.top    = s->generic.y;\n\ts->generic.bottom = s->generic.y + SMALLCHAR_HEIGHT;\n}\n\n/*\n=================\nSlider_Key\n=================\n*/\nstatic sfxHandle_t Slider_Key( menuslider_s *s, int key )\n{\n\tsfxHandle_t\tsound;\n\tint\t\t\tx;\n\tint\t\t\toldvalue;\n\n\tswitch (key)\n\t{\n\t\tcase K_MOUSE1:\n\t\t\tx           = uis.cursorx - s->generic.x - 2*SMALLCHAR_WIDTH;\n\t\t\toldvalue    = s->curvalue;\n\t\t\ts->curvalue = (x/(float)(SLIDER_RANGE*SMALLCHAR_WIDTH)) * (s->maxvalue-s->minvalue) + s->minvalue;\n\n\t\t\tif (s->curvalue < s->minvalue)\n\t\t\t\ts->curvalue = s->minvalue;\n\t\t\telse if (s->curvalue > s->maxvalue)\n\t\t\t\ts->curvalue = s->maxvalue;\n\t\t\tif (s->curvalue != oldvalue)\n\t\t\t\tsound = menu_move_sound;\n\t\t\telse\n\t\t\t\tsound = 0;\n\t\t\tbreak;\n\n\t\tcase K_KP_LEFTARROW:\n\t\tcase K_LEFTARROW:\n\t\t\tif (s->curvalue > s->minvalue)\n\t\t\t{\n\t\t\t\ts->curvalue--;\n\t\t\t\tsound = menu_move_sound;\n\t\t\t}\n\t\t\telse\n\t\t\t\tsound = menu_buzz_sound;\n\t\t\tbreak;\t\t\t\n\n\t\tcase K_KP_RIGHTARROW:\n\t\tcase K_RIGHTARROW:\n\t\t\tif (s->curvalue < s->maxvalue)\n\t\t\t{\n\t\t\t\ts->curvalue++;\n\t\t\t\tsound = menu_move_sound;\n\t\t\t}\n\t\t\telse\n\t\t\t\tsound = menu_buzz_sound;\n\t\t\tbreak;\t\t\t\n\n\t\tdefault:\n\t\t\t// key not handled\n\t\t\tsound = 0;\n\t\t\tbreak;\n\t}\n\n\tif ( sound && s->generic.callback )\n\t\ts->generic.callback( s, QM_ACTIVATED );\n\n\treturn (sound);\n}\n\n#if 1\n/*\n=================\nSlider_Draw\n=================\n*/\nstatic void Slider_Draw( menuslider_s *s ) {\n\tint\t\t\tx;\n\tint\t\t\ty;\n\tint\t\t\tstyle;\n\tfloat\t\t*color;\n\tint\t\t\tbutton;\n\tqboolean\tfocus;\n\t\n\tx =\ts->generic.x;\n\ty = s->generic.y;\n\tfocus = (s->generic.parent->cursor == s->generic.menuPosition);\n\n\tif( s->generic.flags & QMF_GRAYED ) {\n\t\tcolor = text_color_disabled;\n\t\tstyle = UI_SMALLFONT;\n\t}\n\telse if( focus ) {\n\t\tcolor  = text_color_highlight;\n\t\tstyle = UI_SMALLFONT | UI_PULSE;\n\t}\n\telse {\n\t\tcolor = text_color_normal;\n\t\tstyle = UI_SMALLFONT;\n\t}\n\n\t// draw label\n\tUI_DrawString( x - SMALLCHAR_WIDTH, y, s->generic.name, UI_RIGHT|style, color );\n\n\t// draw slider\n\tUI_SetColor( color );\n\tUI_DrawHandlePic( x + SMALLCHAR_WIDTH, y, 96, 16, sliderBar );\n\tUI_SetColor( NULL );\n\n\t// clamp thumb\n\tif( s->maxvalue > s->minvalue )\t{\n\t\ts->range = ( s->curvalue - s->minvalue ) / ( float ) ( s->maxvalue - s->minvalue );\n\t\tif( s->range < 0 ) {\n\t\t\ts->range = 0;\n\t\t}\n\t\telse if( s->range > 1) {\n\t\t\ts->range = 1;\n\t\t}\n\t}\n\telse {\n\t\ts->range = 0;\n\t}\n\n\t// draw thumb\n\tif( style & UI_PULSE) {\n\t\tbutton = sliderButton_1;\n\t}\n\telse {\n\t\tbutton = sliderButton_0;\n\t}\n\n\tUI_DrawHandlePic( (int)( x + 2*SMALLCHAR_WIDTH + (SLIDER_RANGE-1)*SMALLCHAR_WIDTH* s->range ) - 2, y - 2, 12, 20, button );\n}\n#else\n/*\n=================\nSlider_Draw\n=================\n*/\nstatic void Slider_Draw( menuslider_s *s )\n{\n\tfloat *color;\n\tint\tstyle;\n\tint\ti;\n\tint x;\n\tint y;\n\tqboolean focus;\n\t\n\tx =\ts->generic.x;\n\ty = s->generic.y;\n\tfocus = (s->generic.parent->cursor == s->generic.menuPosition);\n\n\tstyle = UI_SMALLFONT;\n\tif ( s->generic.flags & QMF_GRAYED )\n\t{\n\t\tcolor = text_color_disabled;\n\t}\n\telse if (focus)\n\t{\n\t\tcolor  = text_color_highlight;\n\t\tstyle |= UI_PULSE;\n\t}\n\telse\n\t{\n\t\tcolor = text_color_normal;\n\t}\n\n\tif ( focus )\n\t{\n\t\t// draw cursor\n\t\tUI_FillRect( s->generic.left, s->generic.top, s->generic.right-s->generic.left+1, s->generic.bottom-s->generic.top+1, listbar_color ); \n\t\tUI_DrawChar( x, y, 13, UI_CENTER|UI_BLINK|UI_SMALLFONT, color);\n\t}\n\n\t// draw label\n\tUI_DrawString( x - SMALLCHAR_WIDTH, y, s->generic.name, UI_RIGHT|style, color );\n\n\t// draw slider\n\tUI_DrawChar( x + SMALLCHAR_WIDTH, y, 128, UI_LEFT|style, color);\n\tfor ( i = 0; i < SLIDER_RANGE; i++ )\n\t\tUI_DrawChar( x + (i+2)*SMALLCHAR_WIDTH, y, 129, UI_LEFT|style, color);\n\tUI_DrawChar( x + (i+2)*SMALLCHAR_WIDTH, y, 130, UI_LEFT|style, color);\n\n\t// clamp thumb\n\tif (s->maxvalue > s->minvalue)\n\t{\n\t\ts->range = ( s->curvalue - s->minvalue ) / ( float ) ( s->maxvalue - s->minvalue );\n\t\tif ( s->range < 0)\n\t\t\ts->range = 0;\n\t\telse if ( s->range > 1)\n\t\t\ts->range = 1;\n\t}\n\telse\n\t\ts->range = 0;\n\n\t// draw thumb\n\tif (style & UI_PULSE) {\n\t\tstyle &= ~UI_PULSE;\n\t\tstyle |= UI_BLINK;\n\t}\n\tUI_DrawChar( (int)( x + 2*SMALLCHAR_WIDTH + (SLIDER_RANGE-1)*SMALLCHAR_WIDTH* s->range ), y, 131, UI_LEFT|style, color);\n}\n#endif\n\n/*\n=================\nSpinControl_Init\n=================\n*/\nstatic void SpinControl_Init( menulist_s *s ) {\n\tint\tlen;\n\tint\tl;\n\tconst char* str;\n\n\tif (s->generic.name)\n\t\tlen = strlen(s->generic.name) * SMALLCHAR_WIDTH;\n\telse\n\t\tlen = 0;\n\n\ts->generic.left\t= s->generic.x - SMALLCHAR_WIDTH - len;\n\n\tlen = s->numitems = 0;\n\twhile ( (str = s->itemnames[s->numitems]) != 0 )\n\t{\n\t\tl = strlen(str);\n\t\tif (l > len)\n\t\t\tlen = l;\n\n\t\ts->numitems++;\n\t}\t\t\n\n\ts->generic.top\t  =\ts->generic.y;\n\ts->generic.right  =\ts->generic.x + (len+1)*SMALLCHAR_WIDTH;\n\ts->generic.bottom =\ts->generic.y + SMALLCHAR_HEIGHT;\n}\n\n/*\n=================\nSpinControl_Key\n=================\n*/\nstatic sfxHandle_t SpinControl_Key( menulist_s *s, int key )\n{\n\tsfxHandle_t\tsound;\n\n\tsound = 0;\n\tswitch (key)\n\t{\n\t\tcase K_MOUSE1:\n\t\t\ts->curvalue++;\n\t\t\tif (s->curvalue >= s->numitems)\n\t\t\t\ts->curvalue = 0;\n\t\t\tsound = menu_move_sound;\n\t\t\tbreak;\n\t\t\n\t\tcase K_KP_LEFTARROW:\n\t\tcase K_LEFTARROW:\n\t\t\tif (s->curvalue > 0)\n\t\t\t{\n\t\t\t\ts->curvalue--;\n\t\t\t\tsound = menu_move_sound;\n\t\t\t}\n\t\t\telse\n\t\t\t\tsound = menu_buzz_sound;\n\t\t\tbreak;\n\n\t\tcase K_KP_RIGHTARROW:\n\t\tcase K_RIGHTARROW:\n\t\t\tif (s->curvalue < s->numitems-1)\n\t\t\t{\n\t\t\t\ts->curvalue++;\n\t\t\t\tsound = menu_move_sound;\n\t\t\t}\n\t\t\telse\n\t\t\t\tsound = menu_buzz_sound;\n\t\t\tbreak;\n\t}\n\n\tif ( sound && s->generic.callback )\n\t\ts->generic.callback( s, QM_ACTIVATED );\n\n\treturn (sound);\n}\n\n/*\n=================\nSpinControl_Draw\n=================\n*/\nstatic void SpinControl_Draw( menulist_s *s )\n{\n\tfloat *color;\n\tint\tx,y;\n\tint\tstyle;\n\tqboolean focus;\n\n\tx = s->generic.x;\n\ty =\ts->generic.y;\n\n\tstyle = UI_SMALLFONT;\n\tfocus = (s->generic.parent->cursor == s->generic.menuPosition);\n\n\tif ( s->generic.flags & QMF_GRAYED )\n\t\tcolor = text_color_disabled;\n\telse if ( focus )\n\t{\n\t\tcolor = text_color_highlight;\n\t\tstyle |= UI_PULSE;\n\t}\n\telse if ( s->generic.flags & QMF_BLINK )\n\t{\n\t\tcolor = text_color_highlight;\n\t\tstyle |= UI_BLINK;\n\t}\n\telse\n\t\tcolor = text_color_normal;\n\n\tif ( focus )\n\t{\n\t\t// draw cursor\n\t\tUI_FillRect( s->generic.left, s->generic.top, s->generic.right-s->generic.left+1, s->generic.bottom-s->generic.top+1, listbar_color ); \n\t\tUI_DrawChar( x, y, 13, UI_CENTER|UI_BLINK|UI_SMALLFONT, color);\n\t}\n\n\tUI_DrawString( x - SMALLCHAR_WIDTH, y, s->generic.name, style|UI_RIGHT, color );\n\tUI_DrawString( x + SMALLCHAR_WIDTH, y, s->itemnames[s->curvalue], style|UI_LEFT, color );\n}\n\n/*\n=================\nScrollList_Init\n=================\n*/\nstatic void ScrollList_Init( menulist_s *l )\n{\n\tint\t\tw;\n\n\tl->oldvalue = 0;\n\tl->curvalue = 0;\n\tl->top      = 0;\n\n\tif( !l->columns ) {\n\t\tl->columns = 1;\n\t\tl->seperation = 0;\n\t}\n\telse if( !l->seperation ) {\n\t\tl->seperation = 3;\n\t}\n\n\tw = ( (l->width + l->seperation) * l->columns - l->seperation) * SMALLCHAR_WIDTH;\n\n\tl->generic.left   =\tl->generic.x;\n\tl->generic.top    = l->generic.y;\t\n\tl->generic.right  =\tl->generic.x + w;\n\tl->generic.bottom =\tl->generic.y + l->height * SMALLCHAR_HEIGHT;\n\n\tif( l->generic.flags & QMF_CENTER_JUSTIFY ) {\n\t\tl->generic.left -= w / 2;\n\t\tl->generic.right -= w / 2;\n\t}\n}\n\n/*\n=================\nScrollList_Key\n=================\n*/\nsfxHandle_t ScrollList_Key( menulist_s *l, int key )\n{\n\tint\tx;\n\tint\ty;\n\tint\tw;\n\tint\ti;\n\tint\tj;\t\n\tint\tc;\n\tint\tcursorx;\n\tint\tcursory;\n\tint\tcolumn;\n\tint\tindex;\n\n\tswitch (key)\n\t{\n\t\tcase K_MOUSE1:\n\t\t\tif (l->generic.flags & QMF_HASMOUSEFOCUS)\n\t\t\t{\n\t\t\t\t// check scroll region\n\t\t\t\tx = l->generic.x;\n\t\t\t\ty = l->generic.y;\n\t\t\t\tw = ( (l->width + l->seperation) * l->columns - l->seperation) * SMALLCHAR_WIDTH;\n\t\t\t\tif( l->generic.flags & QMF_CENTER_JUSTIFY ) {\n\t\t\t\t\tx -= w / 2;\n\t\t\t\t}\n\t\t\t\tif (UI_CursorInRect( x, y, w, l->height*SMALLCHAR_HEIGHT ))\n\t\t\t\t{\n\t\t\t\t\tcursorx = (uis.cursorx - x)/SMALLCHAR_WIDTH;\n\t\t\t\t\tcolumn = cursorx / (l->width + l->seperation);\n\t\t\t\t\tcursory = (uis.cursory - y)/SMALLCHAR_HEIGHT;\n\t\t\t\t\tindex = column * l->height + cursory;\n\t\t\t\t\tif (l->top + index < l->numitems)\n\t\t\t\t\t{\n\t\t\t\t\t\tl->oldvalue = l->curvalue;\n\t\t\t\t\t\tl->curvalue = l->top + index;\n\n\t\t\t\t\t\tif (l->oldvalue != l->curvalue && l->generic.callback)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tl->generic.callback( l, QM_GOTFOCUS );\n\t\t\t\t\t\t\treturn (menu_move_sound);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t\t// absorbed, silent sound effect\n\t\t\t\treturn (menu_null_sound);\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase K_KP_HOME:\n\t\tcase K_HOME:\n\t\t\tl->oldvalue = l->curvalue;\n\t\t\tl->curvalue = 0;\n\t\t\tl->top      = 0;\n\n\t\t\tif (l->oldvalue != l->curvalue && l->generic.callback)\n\t\t\t{\n\t\t\t\tl->generic.callback( l, QM_GOTFOCUS );\n\t\t\t\treturn (menu_move_sound);\n\t\t\t}\n\t\t\treturn (menu_buzz_sound);\n\n\t\tcase K_KP_END:\n\t\tcase K_END:\n\t\t\tl->oldvalue = l->curvalue;\n\t\t\tl->curvalue = l->numitems-1;\n\t\t\tif( l->columns > 1 ) {\n\t\t\t\tc = (l->curvalue / l->height + 1) * l->height;\n\t\t\t\tl->top = c - (l->columns * l->height);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tl->top = l->curvalue - (l->height - 1);\n\t\t\t}\n\t\t\tif (l->top < 0)\n\t\t\t\tl->top = 0;\t\t\t\n\n\t\t\tif (l->oldvalue != l->curvalue && l->generic.callback)\n\t\t\t{\n\t\t\t\tl->generic.callback( l, QM_GOTFOCUS );\n\t\t\t\treturn (menu_move_sound);\n\t\t\t}\n\t\t\treturn (menu_buzz_sound);\n\n\t\tcase K_PGUP:\n\t\tcase K_KP_PGUP:\n\t\t\tif( l->columns > 1 ) {\n\t\t\t\treturn menu_null_sound;\n\t\t\t}\n\n\t\t\tif (l->curvalue > 0)\n\t\t\t{\n\t\t\t\tl->oldvalue = l->curvalue;\n\t\t\t\tl->curvalue -= l->height-1;\n\t\t\t\tif (l->curvalue < 0)\n\t\t\t\t\tl->curvalue = 0;\n\t\t\t\tl->top = l->curvalue;\n\t\t\t\tif (l->top < 0)\n\t\t\t\t\tl->top = 0;\n\n\t\t\t\tif (l->generic.callback)\n\t\t\t\t\tl->generic.callback( l, QM_GOTFOCUS );\n\n\t\t\t\treturn (menu_move_sound);\n\t\t\t}\n\t\t\treturn (menu_buzz_sound);\n\n\t\tcase K_PGDN:\n\t\tcase K_KP_PGDN:\n\t\t\tif( l->columns > 1 ) {\n\t\t\t\treturn menu_null_sound;\n\t\t\t}\n\n\t\t\tif (l->curvalue < l->numitems-1)\n\t\t\t{\n\t\t\t\tl->oldvalue = l->curvalue;\n\t\t\t\tl->curvalue += l->height-1;\n\t\t\t\tif (l->curvalue > l->numitems-1)\n\t\t\t\t\tl->curvalue = l->numitems-1;\n\t\t\t\tl->top = l->curvalue - (l->height-1);\n\t\t\t\tif (l->top < 0)\n\t\t\t\t\tl->top = 0;\n\n\t\t\t\tif (l->generic.callback)\n\t\t\t\t\tl->generic.callback( l, QM_GOTFOCUS );\n\n\t\t\t\treturn (menu_move_sound);\n\t\t\t}\n\t\t\treturn (menu_buzz_sound);\n\n\t\tcase K_KP_UPARROW:\n\t\tcase K_UPARROW:\n\t\t\tif( l->curvalue == 0 ) {\n\t\t\t\treturn menu_buzz_sound;\n\t\t\t}\n\n\t\t\tl->oldvalue = l->curvalue;\n\t\t\tl->curvalue--;\n\n\t\t\tif( l->curvalue < l->top ) {\n\t\t\t\tif( l->columns == 1 ) {\n\t\t\t\t\tl->top--;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tl->top -= l->height;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif( l->generic.callback ) {\n\t\t\t\tl->generic.callback( l, QM_GOTFOCUS );\n\t\t\t}\n\n\t\t\treturn (menu_move_sound);\n\n\t\tcase K_KP_DOWNARROW:\n\t\tcase K_DOWNARROW:\n\t\t\tif( l->curvalue == l->numitems - 1 ) {\n\t\t\t\treturn menu_buzz_sound;\n\t\t\t}\n\n\t\t\tl->oldvalue = l->curvalue;\n\t\t\tl->curvalue++;\n\n\t\t\tif( l->curvalue >= l->top + l->columns * l->height ) {\n\t\t\t\tif( l->columns == 1 ) {\n\t\t\t\t\tl->top++;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tl->top += l->height;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif( l->generic.callback ) {\n\t\t\t\tl->generic.callback( l, QM_GOTFOCUS );\n\t\t\t}\n\n\t\t\treturn menu_move_sound;\n\n\t\tcase K_KP_LEFTARROW:\n\t\tcase K_LEFTARROW:\n\t\t\tif( l->columns == 1 ) {\n\t\t\t\treturn menu_null_sound;\n\t\t\t}\n\n\t\t\tif( l->curvalue < l->height ) {\n\t\t\t\treturn menu_buzz_sound;\n\t\t\t}\n\n\t\t\tl->oldvalue = l->curvalue;\n\t\t\tl->curvalue -= l->height;\n\n\t\t\tif( l->curvalue < l->top ) {\n\t\t\t\tl->top -= l->height;\n\t\t\t}\n\n\t\t\tif( l->generic.callback ) {\n\t\t\t\tl->generic.callback( l, QM_GOTFOCUS );\n\t\t\t}\n\n\t\t\treturn menu_move_sound;\n\n\t\tcase K_KP_RIGHTARROW:\n\t\tcase K_RIGHTARROW:\n\t\t\tif( l->columns == 1 ) {\n\t\t\t\treturn menu_null_sound;\n\t\t\t}\n\n\t\t\tc = l->curvalue + l->height;\n\n\t\t\tif( c >= l->numitems ) {\n\t\t\t\treturn menu_buzz_sound;\n\t\t\t}\n\n\t\t\tl->oldvalue = l->curvalue;\n\t\t\tl->curvalue = c;\n\n\t\t\tif( l->curvalue > l->top + l->columns * l->height - 1 ) {\n\t\t\t\tl->top += l->height;\n\t\t\t}\n\n\t\t\tif( l->generic.callback ) {\n\t\t\t\tl->generic.callback( l, QM_GOTFOCUS );\n\t\t\t}\n\n\t\t\treturn menu_move_sound;\n\t}\n\n\t// cycle look for ascii key inside list items\n\tif ( !Q_isprint( key ) )\n\t\treturn (0);\n\n\t// force to lower for case insensitive compare\n\tif ( Q_isupper( key ) )\n\t{\n\t\tkey -= 'A' - 'a';\n\t}\n\n\t// iterate list items\n\tfor (i=1; i<=l->numitems; i++)\n\t{\n\t\tj = (l->curvalue + i) % l->numitems;\n\t\tc = l->itemnames[j][0];\n\t\tif ( Q_isupper( c ) )\n\t\t{\n\t\t\tc -= 'A' - 'a';\n\t\t}\n\n\t\tif (c == key)\n\t\t{\n\t\t\t// set current item, mimic windows listbox scroll behavior\n\t\t\tif (j < l->top)\n\t\t\t{\n\t\t\t\t// behind top most item, set this as new top\n\t\t\t\tl->top = j;\n\t\t\t}\n\t\t\telse if (j > l->top+l->height-1)\n\t\t\t{\n\t\t\t\t// past end of list box, do page down\n\t\t\t\tl->top = (j+1) - l->height;\n\t\t\t}\n\t\t\t\n\t\t\tif (l->curvalue != j)\n\t\t\t{\n\t\t\t\tl->oldvalue = l->curvalue;\n\t\t\t\tl->curvalue = j;\n\t\t\t\tif (l->generic.callback)\n\t\t\t\t\tl->generic.callback( l, QM_GOTFOCUS );\n\t\t\t\treturn ( menu_move_sound );\t\t\t\n\t\t\t}\n\n\t\t\treturn (menu_buzz_sound);\n\t\t}\n\t}\n\n\treturn (menu_buzz_sound);\n}\n\n/*\n=================\nScrollList_Draw\n=================\n*/\nvoid ScrollList_Draw( menulist_s *l )\n{\n\tint\t\t\tx;\n\tint\t\t\tu;\n\tint\t\t\ty;\n\tint\t\t\ti;\n\tint\t\t\tbase;\n\tint\t\t\tcolumn;\n\tfloat*\t\tcolor;\n\tqboolean\thasfocus;\n\tint\t\t\tstyle;\n\n\thasfocus = (l->generic.parent->cursor == l->generic.menuPosition);\n\n\tx =\tl->generic.x;\n\tfor( column = 0; column < l->columns; column++ ) {\n\t\ty =\tl->generic.y;\n\t\tbase = l->top + column * l->height;\n\t\tfor( i = base; i < base + l->height; i++) {\n\t\t\tif (i >= l->numitems)\n\t\t\t\tbreak;\n\n\t\t\tif (i == l->curvalue)\n\t\t\t{\n\t\t\t\tu = x - 2;\n\t\t\t\tif( l->generic.flags & QMF_CENTER_JUSTIFY ) {\n\t\t\t\t\tu -= (l->width * SMALLCHAR_WIDTH) / 2 + 1;\n\t\t\t\t}\n\n\t\t\t\tUI_FillRect(u,y,l->width*SMALLCHAR_WIDTH,SMALLCHAR_HEIGHT+2,listbar_color);\n\t\t\t\tcolor = text_color_highlight;\n\n\t\t\t\tif (hasfocus)\n\t\t\t\t\tstyle = UI_PULSE|UI_LEFT|UI_SMALLFONT;\n\t\t\t\telse\n\t\t\t\t\tstyle = UI_LEFT|UI_SMALLFONT;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcolor = text_color_normal;\n\t\t\t\tstyle = UI_LEFT|UI_SMALLFONT;\n\t\t\t}\n\t\t\tif( l->generic.flags & QMF_CENTER_JUSTIFY ) {\n\t\t\t\tstyle |= UI_CENTER;\n\t\t\t}\n\n\t\t\tUI_DrawString(\n\t\t\t\tx,\n\t\t\t\ty,\n\t\t\t\tl->itemnames[i],\n\t\t\t\tstyle,\n\t\t\t\tcolor);\n\n\t\t\ty += SMALLCHAR_HEIGHT;\n\t\t}\n\t\tx += (l->width + l->seperation) * SMALLCHAR_WIDTH;\n\t}\n}\n\n/*\n=================\nMenu_AddItem\n=================\n*/\nvoid Menu_AddItem( menuframework_s *menu, void *item )\n{\n\tmenucommon_s\t*itemptr;\n\n\tif (menu->nitems >= MAX_MENUITEMS)\n\t\ttrap_Error (\"Menu_AddItem: excessive items\");\n\n\tmenu->items[menu->nitems] = item;\n\t((menucommon_s*)menu->items[menu->nitems])->parent        = menu;\n\t((menucommon_s*)menu->items[menu->nitems])->menuPosition  = menu->nitems;\n\t((menucommon_s*)menu->items[menu->nitems])->flags        &= ~QMF_HASMOUSEFOCUS;\n\n\t// perform any item specific initializations\n\titemptr = (menucommon_s*)item;\n\tif (!(itemptr->flags & QMF_NODEFAULTINIT))\n\t{\n\t\tswitch (itemptr->type)\n\t\t{\n\t\t\tcase MTYPE_ACTION:\n\t\t\t\tAction_Init((menuaction_s*)item);\n\t\t\t\tbreak;\n\n\t\t\tcase MTYPE_FIELD:\n\t\t\t\tMenuField_Init((menufield_s*)item);\n\t\t\t\tbreak;\n\n\t\t\tcase MTYPE_SPINCONTROL:\n\t\t\t\tSpinControl_Init((menulist_s*)item);\n\t\t\t\tbreak;\n\n\t\t\tcase MTYPE_RADIOBUTTON:\n\t\t\t\tRadioButton_Init((menuradiobutton_s*)item);\n\t\t\t\tbreak;\n\n\t\t\tcase MTYPE_SLIDER:\n\t\t\t\tSlider_Init((menuslider_s*)item);\n\t\t\t\tbreak;\n\n\t\t\tcase MTYPE_BITMAP:\n\t\t\t\tBitmap_Init((menubitmap_s*)item);\n\t\t\t\tbreak;\n\n\t\t\tcase MTYPE_TEXT:\n\t\t\t\tText_Init((menutext_s*)item);\n\t\t\t\tbreak;\n\n\t\t\tcase MTYPE_SCROLLLIST:\n\t\t\t\tScrollList_Init((menulist_s*)item);\n\t\t\t\tbreak;\n\n\t\t\tcase MTYPE_PTEXT:\n\t\t\t\tPText_Init((menutext_s*)item);\n\t\t\t\tbreak;\n\n\t\t\tcase MTYPE_BTEXT:\n\t\t\t\tBText_Init((menutext_s*)item);\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\ttrap_Error( va(\"Menu_Init: unknown type %d\", itemptr->type) );\n\t\t}\n\t}\n\n\tmenu->nitems++;\n}\n\n/*\n=================\nMenu_CursorMoved\n=================\n*/\nvoid Menu_CursorMoved( menuframework_s *m )\n{\n\tvoid (*callback)( void *self, int notification );\n\t\n\tif (m->cursor_prev == m->cursor)\n\t\treturn;\n\n\tif (m->cursor_prev >= 0 && m->cursor_prev < m->nitems)\n\t{\n\t\tcallback = ((menucommon_s*)(m->items[m->cursor_prev]))->callback;\n\t\tif (callback)\n\t\t\tcallback(m->items[m->cursor_prev],QM_LOSTFOCUS);\n\t}\n\t\n\tif (m->cursor >= 0 && m->cursor < m->nitems)\n\t{\n\t\tcallback = ((menucommon_s*)(m->items[m->cursor]))->callback;\n\t\tif (callback)\n\t\t\tcallback(m->items[m->cursor],QM_GOTFOCUS);\n\t}\n}\n\n/*\n=================\nMenu_SetCursor\n=================\n*/\nvoid Menu_SetCursor( menuframework_s *m, int cursor )\n{\n\tif (((menucommon_s*)(m->items[cursor]))->flags & (QMF_GRAYED|QMF_INACTIVE))\n\t{\n\t\t// cursor can't go there\n\t\treturn;\n\t}\n\n\tm->cursor_prev = m->cursor;\n\tm->cursor      = cursor;\n\n\tMenu_CursorMoved( m );\n}\n\n/*\n=================\nMenu_SetCursorToItem\n=================\n*/\nvoid Menu_SetCursorToItem( menuframework_s *m, void* ptr )\n{\n\tint\ti;\n\n\tfor (i=0; i<m->nitems; i++)\n\t{\n\t\tif (m->items[i] == ptr)\n\t\t{\n\t\t\tMenu_SetCursor( m, i );\n\t\t\treturn;\n\t\t}\n\t}\n}\n\n/*\n** Menu_AdjustCursor\n**\n** This function takes the given menu, the direction, and attempts\n** to adjust the menu's cursor so that it's at the next available\n** slot.\n*/\nvoid Menu_AdjustCursor( menuframework_s *m, int dir ) {\n\tmenucommon_s\t*item = NULL;\n\tqboolean\t\twrapped = qfalse;\n\nwrap:\n\twhile ( m->cursor >= 0 && m->cursor < m->nitems ) {\n\t\titem = ( menucommon_s * ) m->items[m->cursor];\n\t\tif (( item->flags & (QMF_GRAYED|QMF_MOUSEONLY|QMF_INACTIVE) ) ) {\n\t\t\tm->cursor += dir;\n\t\t}\n\t\telse {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif ( dir == 1 ) {\n\t\tif ( m->cursor >= m->nitems ) {\n\t\t\tif ( m->wrapAround ) {\n\t\t\t\tif ( wrapped ) {\n\t\t\t\t\tm->cursor = m->cursor_prev;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tm->cursor = 0;\n\t\t\t\twrapped = qtrue;\n\t\t\t\tgoto wrap;\n\t\t\t}\n\t\t\tm->cursor = m->cursor_prev;\n\t\t}\n\t}\n\telse {\n\t\tif ( m->cursor < 0 ) {\n\t\t\tif ( m->wrapAround ) {\n\t\t\t\tif ( wrapped ) {\n\t\t\t\t\tm->cursor = m->cursor_prev;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tm->cursor = m->nitems - 1;\n\t\t\t\twrapped = qtrue;\n\t\t\t\tgoto wrap;\n\t\t\t}\n\t\t\tm->cursor = m->cursor_prev;\n\t\t}\n\t}\n}\n\n/*\n=================\nMenu_Draw\n=================\n*/\nvoid Menu_Draw( menuframework_s *menu )\n{\n\tint\t\t\t\ti;\n\tmenucommon_s\t*itemptr;\n\n\t// draw menu\n\tfor (i=0; i<menu->nitems; i++)\n\t{\n\t\titemptr = (menucommon_s*)menu->items[i];\n\n\t\tif (itemptr->flags & QMF_HIDDEN)\n\t\t\tcontinue;\n\n\t\tif (itemptr->ownerdraw)\n\t\t{\n\t\t\t// total subclassing, owner draws everything\n\t\t\titemptr->ownerdraw( itemptr );\n\t\t}\t\n\t\telse \n\t\t{\n\t\t\tswitch (itemptr->type)\n\t\t\t{\t\n\t\t\t\tcase MTYPE_RADIOBUTTON:\n\t\t\t\t\tRadioButton_Draw( (menuradiobutton_s*)itemptr );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase MTYPE_FIELD:\n\t\t\t\t\tMenuField_Draw( (menufield_s*)itemptr );\n\t\t\t\t\tbreak;\n\t\t\n\t\t\t\tcase MTYPE_SLIDER:\n\t\t\t\t\tSlider_Draw( (menuslider_s*)itemptr );\n\t\t\t\t\tbreak;\n \n\t\t\t\tcase MTYPE_SPINCONTROL:\n\t\t\t\t\tSpinControl_Draw( (menulist_s*)itemptr );\n\t\t\t\t\tbreak;\n\t\t\n\t\t\t\tcase MTYPE_ACTION:\n\t\t\t\t\tAction_Draw( (menuaction_s*)itemptr );\n\t\t\t\t\tbreak;\n\t\t\n\t\t\t\tcase MTYPE_BITMAP:\n\t\t\t\t\tBitmap_Draw( (menubitmap_s*)itemptr );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase MTYPE_TEXT:\n\t\t\t\t\tText_Draw( (menutext_s*)itemptr );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase MTYPE_SCROLLLIST:\n\t\t\t\t\tScrollList_Draw( (menulist_s*)itemptr );\n\t\t\t\t\tbreak;\n\t\t\t\t\n\t\t\t\tcase MTYPE_PTEXT:\n\t\t\t\t\tPText_Draw( (menutext_s*)itemptr );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase MTYPE_BTEXT:\n\t\t\t\t\tBText_Draw( (menutext_s*)itemptr );\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\ttrap_Error( va(\"Menu_Draw: unknown type %d\", itemptr->type) );\n\t\t\t}\n\t\t}\n#ifndef NDEBUG\n\t\tif( uis.debug ) {\n\t\t\tint\tx;\n\t\t\tint\ty;\n\t\t\tint\tw;\n\t\t\tint\th;\n\n\t\t\tif( !( itemptr->flags & QMF_INACTIVE ) ) {\n\t\t\t\tx = itemptr->left;\n\t\t\t\ty = itemptr->top;\n\t\t\t\tw = itemptr->right - itemptr->left + 1;\n\t\t\t\th =\titemptr->bottom - itemptr->top + 1;\n\n\t\t\t\tif (itemptr->flags & QMF_HASMOUSEFOCUS) {\n\t\t\t\t\tUI_DrawRect(x, y, w, h, colorYellow );\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tUI_DrawRect(x, y, w, h, colorWhite );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n#endif\n\t}\n\n\titemptr = Menu_ItemAtCursor( menu );\n\tif ( itemptr && itemptr->statusbar)\n\t\titemptr->statusbar( ( void * ) itemptr );\n}\n\n/*\n=================\nMenu_ItemAtCursor\n=================\n*/\nvoid *Menu_ItemAtCursor( menuframework_s *m )\n{\n\tif ( m->cursor < 0 || m->cursor >= m->nitems )\n\t\treturn 0;\n\n\treturn m->items[m->cursor];\n}\n\n/*\n=================\nMenu_ActivateItem\n=================\n*/\nsfxHandle_t Menu_ActivateItem( menuframework_s *s, menucommon_s* item ) {\n\tif ( item->callback ) {\n\t\titem->callback( item, QM_ACTIVATED );\n\t\tif( !( item->flags & QMF_SILENT ) ) {\n\t\t\treturn menu_move_sound;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\n/*\n=================\nMenu_DefaultKey\n=================\n*/\nsfxHandle_t Menu_DefaultKey( menuframework_s *m, int key )\n{\n\tsfxHandle_t\t\tsound = 0;\n\tmenucommon_s\t*item;\n\tint\t\t\t\tcursor_prev;\n\n\t// menu system keys\n\tswitch ( key )\n\t{\n\t\tcase K_MOUSE2:\n\t\tcase K_ESCAPE:\n\t\t\tUI_PopMenu();\n\t\t\treturn menu_out_sound;\n\t}\n\n\tif (!m || !m->nitems)\n\t\treturn 0;\n\n\t// route key stimulus to widget\n\titem = Menu_ItemAtCursor( m );\n\tif (item && !(item->flags & (QMF_GRAYED|QMF_INACTIVE)))\n\t{\n\t\tswitch (item->type)\n\t\t{\n\t\t\tcase MTYPE_SPINCONTROL:\n\t\t\t\tsound = SpinControl_Key( (menulist_s*)item, key );\n\t\t\t\tbreak;\n\n\t\t\tcase MTYPE_RADIOBUTTON:\n\t\t\t\tsound = RadioButton_Key( (menuradiobutton_s*)item, key );\n\t\t\t\tbreak;\n\n\t\t\tcase MTYPE_SLIDER:\n\t\t\t\tsound = Slider_Key( (menuslider_s*)item, key );\n\t\t\t\tbreak;\n\n\t\t\tcase MTYPE_SCROLLLIST:\n\t\t\t\tsound = ScrollList_Key( (menulist_s*)item, key );\n\t\t\t\tbreak;\n\n\t\t\tcase MTYPE_FIELD:\n\t\t\t\tsound = MenuField_Key( (menufield_s*)item, &key );\n\t\t\t\tbreak;\n\t\t}\n\n\t\tif (sound) {\n\t\t\t// key was handled\n\t\t\treturn sound;\t\t\n\t\t}\n\t}\n\n\t// default handling\n\tswitch ( key )\n\t{\n#ifndef NDEBUG\n\t\tcase K_F11:\n\t\t\tuis.debug ^= 1;\n\t\t\tbreak;\n\n\t\tcase K_F12:\n\t\t\ttrap_Cmd_ExecuteText(EXEC_APPEND, \"screenshot\\n\");\n\t\t\tbreak;\n#endif\n\t\tcase K_KP_UPARROW:\n\t\tcase K_UPARROW:\n\t\t\tcursor_prev    = m->cursor;\n\t\t\tm->cursor_prev = m->cursor;\n\t\t\tm->cursor--;\n\t\t\tMenu_AdjustCursor( m, -1 );\n\t\t\tif ( cursor_prev != m->cursor ) {\n\t\t\t\tMenu_CursorMoved( m );\n\t\t\t\tsound = menu_move_sound;\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase K_TAB:\n\t\tcase K_KP_DOWNARROW:\n\t\tcase K_DOWNARROW:\n\t\t\tcursor_prev    = m->cursor;\n\t\t\tm->cursor_prev = m->cursor;\n\t\t\tm->cursor++;\n\t\t\tMenu_AdjustCursor( m, 1 );\n\t\t\tif ( cursor_prev != m->cursor ) {\n\t\t\t\tMenu_CursorMoved( m );\n\t\t\t\tsound = menu_move_sound;\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase K_MOUSE1:\n\t\tcase K_MOUSE3:\n\t\t\tif (item)\n\t\t\t\tif ((item->flags & QMF_HASMOUSEFOCUS) && !(item->flags & (QMF_GRAYED|QMF_INACTIVE)))\n\t\t\t\t\treturn (Menu_ActivateItem( m, item ));\n\t\t\tbreak;\n\n\t\tcase K_JOY1:\n\t\tcase K_JOY2:\n\t\tcase K_JOY3:\n\t\tcase K_JOY4:\n\t\tcase K_AUX1:\n\t\tcase K_AUX2:\n\t\tcase K_AUX3:\n\t\tcase K_AUX4:\n\t\tcase K_AUX5:\n\t\tcase K_AUX6:\n\t\tcase K_AUX7:\n\t\tcase K_AUX8:\n\t\tcase K_AUX9:\n\t\tcase K_AUX10:\n\t\tcase K_AUX11:\n\t\tcase K_AUX12:\n\t\tcase K_AUX13:\n\t\tcase K_AUX14:\n\t\tcase K_AUX15:\n\t\tcase K_AUX16:\n\t\tcase K_KP_ENTER:\n\t\tcase K_ENTER:\n\t\t\tif (item)\n\t\t\t\tif (!(item->flags & (QMF_MOUSEONLY|QMF_GRAYED|QMF_INACTIVE)))\n\t\t\t\t\treturn (Menu_ActivateItem( m, item ));\n\t\t\tbreak;\n\t}\n\n\treturn sound;\n}\n\n/*\n=================\nMenu_Cache\n=================\n*/\nvoid Menu_Cache( void )\n{\n\tuis.charset\t\t\t= trap_R_RegisterShaderNoMip( \"gfx/2d/bigchars\" );\n\tuis.charsetProp\t\t= trap_R_RegisterShaderNoMip( \"menu/art/font1_prop.tga\" );\n\tuis.charsetPropGlow\t= trap_R_RegisterShaderNoMip( \"menu/art/font1_prop_glo.tga\" );\n\tuis.charsetPropB\t= trap_R_RegisterShaderNoMip( \"menu/art/font2_prop.tga\" );\n\tuis.cursor          = trap_R_RegisterShaderNoMip( \"menu/art/3_cursor2\" );\n\tuis.rb_on           = trap_R_RegisterShaderNoMip( \"menu/art/switch_on\" );\n\tuis.rb_off          = trap_R_RegisterShaderNoMip( \"menu/art/switch_off\" );\n\n\tuis.whiteShader = trap_R_RegisterShaderNoMip( \"white\" );\n\tif ( uis.glconfig.hardwareType == GLHW_RAGEPRO ) {\n\t\t// the blend effect turns to shit with the normal \n\t\tuis.menuBackShader\t= trap_R_RegisterShaderNoMip( \"menubackRagePro\" );\n\t} else {\n\t\tuis.menuBackShader\t= trap_R_RegisterShaderNoMip( \"menuback\" );\n\t}\n\tuis.menuBackNoLogoShader = trap_R_RegisterShaderNoMip( \"menubacknologo\" );\n\n\tmenu_in_sound\t= trap_S_RegisterSound( \"sound/misc/menu1.wav\", qfalse );\n\tmenu_move_sound\t= trap_S_RegisterSound( \"sound/misc/menu2.wav\", qfalse );\n\tmenu_out_sound\t= trap_S_RegisterSound( \"sound/misc/menu3.wav\", qfalse );\n\tmenu_buzz_sound\t= trap_S_RegisterSound( \"sound/misc/menu4.wav\", qfalse );\n\tweaponChangeSound\t= trap_S_RegisterSound( \"sound/weapons/change.wav\", qfalse );\n\n\t// need a nonzero sound, make an empty sound for this\n\tmenu_null_sound = -1;\n\n\tsliderBar = trap_R_RegisterShaderNoMip( \"menu/art/slider2\" );\n\tsliderButton_0 = trap_R_RegisterShaderNoMip( \"menu/art/sliderbutt_0\" );\n\tsliderButton_1 = trap_R_RegisterShaderNoMip( \"menu/art/sliderbutt_1\" );\n}\n\t\n"
  },
  {
    "path": "code/q3_ui/ui_rankings.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n//\n// ui_rankings.c\n//\n\n#include \"ui_local.h\"\n\n\n#define RANKINGS_FRAME\t\"menu/art/cut_frame\"\n\n#define ID_LOGIN\t\t100\n#define ID_LOGOUT\t\t101\n#define ID_CREATE\t\t102\n#define ID_SPECTATE\t\t103\n#define ID_SETUP\t\t104\n#define ID_LEAVE\t\t105\n\n\ntypedef struct\n{\n\tmenuframework_s\tmenu;\n\tmenubitmap_s\tframe;\n\tmenutext_s\t\tlogin;\n\tmenutext_s\t\tlogout;\n\tmenutext_s\t\tcreate;\n\tmenutext_s\t\tspectate;\n\tmenutext_s\t\tsetup;\n\tmenutext_s\t\tleave;\n} rankings_t;\n\nstatic rankings_t\ts_rankings;\n\nstatic menuframework_s\ts_rankings_menu;\nstatic menuaction_s\t\ts_rankings_login;\nstatic menuaction_s\t\ts_rankings_logout;\nstatic menuaction_s\t\ts_rankings_create;\nstatic menuaction_s\t\ts_rankings_spectate;\nstatic menuaction_s\t\ts_rankings_setup;\nstatic menuaction_s\t\ts_rankings_leave;\n\n\n/*\n===============\nRankings_DrawText\n===============\n*/\nvoid Rankings_DrawText( void* self )\n{\n\tmenufield_s\t\t*f;\n\tqboolean\t\tfocus;\n\tint\t\t\t\tstyle;\n\tchar\t\t\t*txt;\n\tchar\t\t\tc;\n\tfloat\t\t\t*color;\n\tint\t\t\t\tbasex, x, y;\n\n\tf = (menufield_s*)self;\n\tbasex = f->generic.x;\n\ty = f->generic.y + 4;\n\tfocus = (f->generic.parent->cursor == f->generic.menuPosition);\n\n\tstyle = UI_LEFT|UI_SMALLFONT;\n\tcolor = text_color_normal;\n\tif( focus ) {\n\t\tstyle |= UI_PULSE;\n\t\tcolor = text_color_highlight;\n\t}\n\n\t// draw the actual text\n\ttxt = f->field.buffer;\n\tcolor = g_color_table[ColorIndex(COLOR_WHITE)];\n\tx = basex;\n\twhile ( (c = *txt) != 0 ) {\n\t\tUI_DrawChar( x, y, c, style, color );\n\t\ttxt++;\n\t\tx += SMALLCHAR_WIDTH;\n\t}\n\n\t// draw cursor if we have focus\n\tif( focus ) {\n\t\tif ( trap_Key_GetOverstrikeMode() ) {\n\t\t\tc = 11;\n\t\t} else {\n\t\t\tc = 10;\n\t\t}\n\n\t\tstyle &= ~UI_PULSE;\n\t\tstyle |= UI_BLINK;\n\n\t\tUI_DrawChar( basex + f->field.cursor * SMALLCHAR_WIDTH, y, c, style, color_white );\n\t}\n}\n\n/*\n===============\nRankings_DrawName\n===============\n*/\nvoid Rankings_DrawName( void* self )\n{\n\tmenufield_s\t\t*f;\n\tint\t\t\t\tlength;\n\tchar*\t\t\tp;\n\t\n\tf = (menufield_s*)self;\n\n\t// GRANK_FIXME - enforce valid characters\n\tfor( p = f->field.buffer; *p != '\\0'; p++ )\n\t{\n\t\t//if( ispunct(*p) || isspace(*p) )\n\t\tif( !( ( (*p) >= '0' && (*p) <= '9') || Q_isalpha(*p)) )\n\t\t{\n\t\t\t*p = '\\0';\n\t\t}\n\t}\n\t\n\t// strip color codes\n\tQ_CleanStr( f->field.buffer );\n\tlength = strlen( f->field.buffer );\n\tif( f->field.cursor > length )\n\t{\n\t\tf->field.cursor = length;\n\t}\t\n\n\tRankings_DrawText( f );\n}\n\n#if 0 // old version\n/*\n===============\nRankings_DrawName\n===============\n*/\nvoid Rankings_DrawName( void* self )\n{\n\tmenufield_s*\tf;\n\tint\t\t\t\tlength;\n\t\n\tf = (menufield_s*)self;\n\n\t// strip color codes\n\tQ_CleanStr( f->field.buffer );\n\tlength = strlen( f->field.buffer );\n\tif( f->field.cursor > length )\n\t{\n\t\tf->field.cursor = length;\n\t}\n\t\n\t// show beginning of long names\n\t/*\n\tif( Menu_ItemAtCursor( f->generic.parent ) != f )\n\t{\n\t\tif( f->field.scroll > 0 )\n\t\t{\n\t\t\tf->field.cursor = 0;\n\t\t\tf->field.scroll = 0;\n\t\t}\n\t}\n\t*/\n\t\n\tMenuField_Draw( f );\n}\n#endif\n\n/*\n===============\nRankings_DrawPassword\n===============\n*/\nvoid Rankings_DrawPassword( void* self )\n{\n\tmenufield_s*\tf;\n\tchar\t\t\tpassword[MAX_EDIT_LINE];\n\tint\t\t\t\tlength;\n\tint\t\t\t\ti;\n\tchar*\t\t\tp;\n\n\tf = (menufield_s*)self;\n\t\n\t// GRANK_FIXME - enforce valid characters\n\tfor( p = f->field.buffer; *p != '\\0'; p++ )\n\t{\n\t\t//if( ispunct(*p) || isspace(*p) )\n\t\tif( !( ( (*p) >= '0' && (*p) <= '9') || Q_isalpha(*p)) )\n\t\t{\n\t\t\t*p = '\\0';\n\t\t}\n\t}\n\t\n\tlength = strlen( f->field.buffer );\n\tif( f->field.cursor > length )\n\t{\n\t\tf->field.cursor = length;\n\t}\n\t\n\t// save password\n\tQ_strncpyz( password, f->field.buffer, sizeof(password) );\n\n\t// mask password with *\n\tfor( i = 0; i < length; i++ )\n\t{\n\t\tf->field.buffer[i] = '*';\n\t}\n\n\t// draw masked password\n\tRankings_DrawText( f );\n\t//MenuField_Draw( f );\n\n\t// restore password\n\tQ_strncpyz( f->field.buffer, password, sizeof(f->field.buffer) );\n}\n\n/*\n===============\nRankings_MenuEvent\n===============\n*/\nstatic void Rankings_MenuEvent( void* ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tswitch( ((menucommon_s*)ptr)->id ) {\n\tcase ID_LOGIN:\n\t\tUI_LoginMenu();\n\t\tbreak;\n\n\tcase ID_LOGOUT:\n\t\t// server side masqueraded player logout first\n\t\ttrap_CL_UI_RankUserRequestLogout();\n\t\tUI_ForceMenuOff();\n\t\tbreak;\n\t\t\n\tcase ID_CREATE:\n\t\tUI_SignupMenu();\n\t\tbreak;\n\n\tcase ID_SPECTATE:\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"cmd rank_spectate\\n\" );\n\t\tUI_ForceMenuOff();\n\t\tbreak;\n\n\tcase ID_SETUP:\n\t\tUI_SetupMenu();\n\t\tbreak;\n\t\t\n\tcase ID_LEAVE:\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"disconnect\\n\" );\n\t\tUI_ForceMenuOff();\n\t\tbreak;\n\n\t}\n}\n\n\n/*\n===============\nRankings_MenuInit\n===============\n*/\nvoid Rankings_MenuInit( void ) {\n\tgrank_status_t\tstatus;\n\tint\t\t\t\ty;\n\n\tmemset( &s_rankings, 0, sizeof(s_rankings) );\n\n\tRankings_Cache();\n\n\ts_rankings.menu.wrapAround = qtrue;\n\ts_rankings.menu.fullscreen = qfalse;\n\n\ts_rankings.frame.generic.type\t\t= MTYPE_BITMAP;\n\ts_rankings.frame.generic.flags\t\t= QMF_INACTIVE;\n\ts_rankings.frame.generic.name\t\t= RANKINGS_FRAME;\n\ts_rankings.frame.generic.x\t\t\t= 142;\n\ts_rankings.frame.generic.y\t\t\t= 118;\n\ts_rankings.frame.width\t\t\t\t= 359;\n\ts_rankings.frame.height\t\t\t\t= 256;\n\n\ty = 194;\n\n\ts_rankings.login.generic.type\t\t= MTYPE_PTEXT;\n\ts_rankings.login.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_rankings.login.generic.id\t\t\t= ID_LOGIN;\n\ts_rankings.login.generic.callback\t= Rankings_MenuEvent;\n\ts_rankings.login.generic.x\t\t\t= 320;\n\ts_rankings.login.generic.y\t\t\t= y;\n\ts_rankings.login.string\t\t\t\t= \"LOGIN\";\n\ts_rankings.login.style\t\t\t\t= UI_CENTER|UI_SMALLFONT;\n\ts_rankings.login.color\t\t\t\t= colorRed;\n\ty += 20;\n\n\ts_rankings.logout.generic.type\t\t= MTYPE_PTEXT;\n\ts_rankings.logout.generic.flags\t\t= QMF_HIDDEN|QMF_INACTIVE|QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_rankings.logout.generic.id\t\t= ID_LOGOUT;\n\ts_rankings.logout.generic.callback\t= Rankings_MenuEvent;\n\ts_rankings.logout.generic.x\t\t\t= 320;\n\ts_rankings.logout.generic.y\t\t\t= y;\n\ts_rankings.logout.string\t\t\t\t= \"LOGOUT\";\n\ts_rankings.logout.style\t\t\t\t= UI_CENTER|UI_SMALLFONT;\n\ts_rankings.logout.color\t\t\t\t= colorRed;\n\n\ts_rankings.create.generic.type\t\t= MTYPE_PTEXT;\n\ts_rankings.create.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_rankings.create.generic.id\t\t= ID_CREATE;\n\ts_rankings.create.generic.callback\t= Rankings_MenuEvent;\n\ts_rankings.create.generic.x\t\t\t= 320;\n\ts_rankings.create.generic.y\t\t\t= y;\n\ts_rankings.create.string\t\t\t= \"SIGN UP\";\n\ts_rankings.create.style\t\t\t\t= UI_CENTER|UI_SMALLFONT;\n\ts_rankings.create.color\t\t\t\t= colorRed;\n\ty += 20;\n\n\ts_rankings.spectate.generic.type\t\t= MTYPE_PTEXT;\n\ts_rankings.spectate.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_rankings.spectate.generic.id\t\t\t= ID_SPECTATE;\n\ts_rankings.spectate.generic.callback\t= Rankings_MenuEvent;\n\ts_rankings.spectate.generic.x\t\t\t= 320;\n\ts_rankings.spectate.generic.y\t\t\t= y;\n\ts_rankings.spectate.string\t\t\t\t= \"SPECTATE\";\n\ts_rankings.spectate.style\t\t\t\t= UI_CENTER|UI_SMALLFONT;\n\ts_rankings.spectate.color\t\t\t\t= colorRed;\n\ty += 20;\n\n\ts_rankings.setup.generic.type\t\t= MTYPE_PTEXT;\n\ts_rankings.setup.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_rankings.setup.generic.id\t\t\t= ID_SETUP;\n\ts_rankings.setup.generic.callback\t= Rankings_MenuEvent;\n\ts_rankings.setup.generic.x\t\t\t= 320;\n\ts_rankings.setup.generic.y\t\t\t= y;\n\ts_rankings.setup.string\t\t\t\t= \"SETUP\";\n\ts_rankings.setup.style\t\t\t\t= UI_CENTER|UI_SMALLFONT;\n\ts_rankings.setup.color\t\t\t\t= colorRed;\n\ty += 20;\n\n\ts_rankings.leave.generic.type\t\t= MTYPE_PTEXT;\n\ts_rankings.leave.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_rankings.leave.generic.id\t\t\t= ID_LEAVE;\n\ts_rankings.leave.generic.callback\t= Rankings_MenuEvent;\n\ts_rankings.leave.generic.x\t\t\t= 320;\n\ts_rankings.leave.generic.y\t\t\t= y;\n\ts_rankings.leave.string\t\t\t\t= \"LEAVE ARENA\";\n\ts_rankings.leave.style\t\t\t\t= UI_CENTER|UI_SMALLFONT;\n\ts_rankings.leave.color\t\t\t\t= colorRed;\n\ty += 20;\n\n\tstatus = (grank_status_t)trap_Cvar_VariableValue(\"client_status\");\n\tif( (status != QGR_STATUS_NEW) && (status != QGR_STATUS_SPECTATOR) )\n\t{\n\t\ts_rankings.login.generic.flags |= QMF_HIDDEN | QMF_INACTIVE;\t\n\t\ts_rankings.create.generic.flags |= QMF_HIDDEN | QMF_INACTIVE;\n\t\ts_rankings.spectate.generic.flags |= QMF_HIDDEN | QMF_INACTIVE;\n\n\t\ts_rankings.logout.generic.flags &= ~(QMF_HIDDEN | QMF_INACTIVE);\n\t}\n\t\n\tif ( (status == QGR_STATUS_VALIDATING) ||\n\t\t (status == QGR_STATUS_PENDING) ||\n\t\t (status == QGR_STATUS_LEAVING) )\n\t{\n\t\ts_rankings.login.generic.flags  |= QMF_GRAYED;\n\t\ts_rankings.create.generic.flags |= QMF_GRAYED;\n\t\ts_rankings.logout.generic.flags |= QMF_GRAYED;\n\t}\n\t\n\t//GRank FIXME -- don't need setup option any more\n\ts_rankings.setup.generic.flags |= QMF_HIDDEN | QMF_INACTIVE;\n\n\tMenu_AddItem( &s_rankings.menu, (void*) &s_rankings.frame );\n\tMenu_AddItem( &s_rankings.menu, (void*) &s_rankings.login );\n\tMenu_AddItem( &s_rankings.menu, (void*) &s_rankings.logout );\n\tMenu_AddItem( &s_rankings.menu, (void*) &s_rankings.create );\n\tMenu_AddItem( &s_rankings.menu, (void*) &s_rankings.spectate );\n\tMenu_AddItem( &s_rankings.menu, (void*) &s_rankings.setup );\n\tMenu_AddItem( &s_rankings.menu, (void*) &s_rankings.leave );\n}\n\n\n/*\n===============\nRankings_Cache\n===============\n*/\nvoid Rankings_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( RANKINGS_FRAME );\n}\n\n\n/*\n===============\nUI_RankingsMenu\n===============\n*/\nvoid UI_RankingsMenu( void ) {\n\tRankings_MenuInit();\n\tUI_PushMenu ( &s_rankings.menu );\n}\n\n\n"
  },
  {
    "path": "code/q3_ui/ui_rankstatus.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n//\n// ui_rankstatus.c\n//\n\n#include \"ui_local.h\"\n\n\n#define RANKSTATUS_FRAME\t\t\"menu/art/cut_frame\"\n\n#define ID_MESSAGE\t\t100\n#define ID_OK\t\t\t101\n\n\ntypedef struct\n{\n\tmenuframework_s\tmenu;\n\tmenubitmap_s\tframe;\n\tmenutext_s\t\tmessage;\n\tmenutext_s\t\tok;\n} rankstatus_t;\n\nstatic rankstatus_t\ts_rankstatus;\n\nstatic menuframework_s\ts_rankstatus_menu;\nstatic menuaction_s\t\ts_rankstatus_ok;\n\nstatic grank_status_t\ts_status = 0;\nstatic char*\t\t\ts_rankstatus_message = NULL;\n\nstatic vec4_t s_rankingstatus_color_prompt  = {1.00, 0.43, 0.00, 1.00};\n\n/*\n===============\nRankStatus_MenuEvent\n===============\n*/\nstatic void RankStatus_MenuEvent( void* ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tswitch( ((menucommon_s*)ptr)->id ) {\n\tcase ID_OK:\n\t\tUI_PopMenu();\n\t\t\n\t\tswitch( s_status )\n\t\t{\n\t\tcase QGR_STATUS_NO_USER:\n\t\t\tUI_RankingsMenu();\n\t\t\tbreak;\n\t\tcase QGR_STATUS_BAD_PASSWORD:\n\t\t\tUI_RankingsMenu();\n\t\t\tUI_LoginMenu();\n\t\t\tbreak;\n\t\tcase QGR_STATUS_USER_EXISTS:\n\t\t\tUI_RankingsMenu();\n\t\t\tUI_SignupMenu();\n\t\t\tbreak;\n\t\tcase QGR_STATUS_NO_MEMBERSHIP:\n\t\t\tUI_RankingsMenu();\n\t\t\tbreak;\n\t\tcase QGR_STATUS_TIMEOUT:\n\t\t\tUI_RankingsMenu();\n\t\t\tbreak;\n\t\tcase QGR_STATUS_INVALIDUSER:\n\t\t\tUI_RankingsMenu();\n\t\t\tbreak;\n\t\tcase QGR_STATUS_ERROR:\n\t\t\tUI_RankingsMenu();\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\n\t\tbreak;\n\t}\n}\n\n\n/*\n===============\nRankStatus_MenuInit\n===============\n*/\nvoid RankStatus_MenuInit( void ) {\n\tint\t\ty;\n\n\tmemset( &s_rankstatus, 0, sizeof(s_rankstatus) );\n\n\tRankStatus_Cache();\n\n\ts_rankstatus.menu.wrapAround = qtrue;\n\ts_rankstatus.menu.fullscreen = qfalse;\n\n\ts_rankstatus.frame.generic.type\t\t\t= MTYPE_BITMAP;\n\ts_rankstatus.frame.generic.flags\t\t= QMF_INACTIVE;\n\ts_rankstatus.frame.generic.name\t\t\t= RANKSTATUS_FRAME;\n\ts_rankstatus.frame.generic.x\t\t\t= 142; //320-233;\n\ts_rankstatus.frame.generic.y\t\t\t= 118; //240-166;\n\ts_rankstatus.frame.width\t\t\t\t= 359; //466;\n\ts_rankstatus.frame.height\t\t\t\t= 256; //332;\n\n\ty = 214;\n\n\ts_rankstatus.message.generic.type\t\t\t= MTYPE_PTEXT;\n\ts_rankstatus.message.generic.flags\t\t\t= QMF_CENTER_JUSTIFY|QMF_INACTIVE;\n\ts_rankstatus.message.generic.id\t\t\t\t= ID_MESSAGE;\n\ts_rankstatus.message.generic.x\t\t\t\t= 320;\n\ts_rankstatus.message.generic.y\t\t\t\t= y;\n\ts_rankstatus.message.string\t\t\t\t\t= s_rankstatus_message;\n\ts_rankstatus.message.style\t\t\t\t\t= UI_CENTER|UI_SMALLFONT;\n\ts_rankstatus.message.color\t\t\t\t\t= s_rankingstatus_color_prompt;\n\ty += 40;\n\n\ts_rankstatus.ok.generic.type\t\t\t\t= MTYPE_PTEXT;\n\ts_rankstatus.ok.generic.flags\t\t\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_rankstatus.ok.generic.id\t\t\t\t\t= ID_OK;\n\ts_rankstatus.ok.generic.callback\t\t\t= RankStatus_MenuEvent;\n\ts_rankstatus.ok.generic.x\t\t\t\t\t= 320;\n\ts_rankstatus.ok.generic.y\t\t\t\t\t= y;\n\ts_rankstatus.ok.string\t\t\t\t\t\t= \"OK\";\n\ts_rankstatus.ok.style\t\t\t\t\t\t= UI_CENTER|UI_SMALLFONT;\n\ts_rankstatus.ok.color\t\t\t\t\t\t= colorRed;\n\n\tMenu_AddItem( &s_rankstatus.menu, (void*) &s_rankstatus.frame );\n\tMenu_AddItem( &s_rankstatus.menu, (void*) &s_rankstatus.message );\n\tMenu_AddItem( &s_rankstatus.menu, (void*) &s_rankstatus.ok );\n}\n\n\n/*\n===============\nRankStatus_Cache\n===============\n*/\nvoid RankStatus_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( RANKSTATUS_FRAME );\n}\n\n\n/*\n===============\nUI_RankStatusMenu\n===============\n*/\nvoid UI_RankStatusMenu( void ) {\n\n\ts_status = (grank_status_t)trap_Cvar_VariableValue(\"client_status\");\n\n\tswitch( s_status )\n\t{\n\tcase QGR_STATUS_NEW:\n\t\treturn;\n\tcase QGR_STATUS_PENDING:\n\t\t// GRANK_FIXME\n\t\treturn;\n\tcase QGR_STATUS_NO_USER:\n\t\t// GRANK_FIXME - get this when user exists\n\t\ts_rankstatus_message = \"Username unavailable\";\n\t\tbreak;\n\tcase QGR_STATUS_BAD_PASSWORD:\n\t\ts_rankstatus_message = \"Invalid password\";\n\t\tbreak;\n\tcase QGR_STATUS_TIMEOUT:\n\t\ts_rankstatus_message = \"Timed out\";\n\t\tbreak;\n\tcase QGR_STATUS_NO_MEMBERSHIP:\n\t\ts_rankstatus_message = \"No membership\";\n\t\tbreak;\n\tcase QGR_STATUS_INVALIDUSER:\n\t\ts_rankstatus_message = \"Validation failed\";\n\t\tbreak;\n\tcase QGR_STATUS_ERROR:\n\t\ts_rankstatus_message = \"Error\";\n\t\tbreak;\n\tcase QGR_STATUS_SPECTATOR:\n\tcase QGR_STATUS_ACTIVE:\n\t\tUI_ForceMenuOff();\n\t\treturn;\n\tdefault:\n\t\treturn;\n\t}\n\tRankStatus_MenuInit();\n\ttrap_CL_UI_RankUserReset();\n\tUI_PushMenu ( &s_rankstatus.menu );\n}\n\n"
  },
  {
    "path": "code/q3_ui/ui_removebots.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=======================================================================\n\nREMOVE BOTS MENU\n\n=======================================================================\n*/\n\n\n#include \"ui_local.h\"\n\n\n#define ART_BACKGROUND\t\t\"menu/art/addbotframe\"\n#define ART_BACK0\t\t\t\"menu/art/back_0\"\n#define ART_BACK1\t\t\t\"menu/art/back_1\"\t\n#define ART_DELETE0\t\t\t\"menu/art/delete_0\"\n#define ART_DELETE1\t\t\t\"menu/art/delete_1\"\n#define ART_ARROWS\t\t\t\"menu/art/arrows_vert_0\"\n#define ART_ARROWUP\t\t\t\"menu/art/arrows_vert_top\"\n#define ART_ARROWDOWN\t\t\"menu/art/arrows_vert_bot\"\n\n#define ID_UP\t\t\t\t10\n#define ID_DOWN\t\t\t\t11\n#define ID_DELETE\t\t\t12\n#define ID_BACK\t\t\t\t13\n#define ID_BOTNAME0\t\t\t20\n#define ID_BOTNAME1\t\t\t21\n#define ID_BOTNAME2\t\t\t22\n#define ID_BOTNAME3\t\t\t23\n#define ID_BOTNAME4\t\t\t24\n#define ID_BOTNAME5\t\t\t25\n#define ID_BOTNAME6\t\t\t26\n\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n\n\tmenutext_s\t\tbanner;\n\tmenubitmap_s\tbackground;\n\n\tmenubitmap_s\tarrows;\n\tmenubitmap_s\tup;\n\tmenubitmap_s\tdown;\n\n\tmenutext_s\t\tbots[7];\n\n\tmenubitmap_s\tdelete;\n\tmenubitmap_s\tback;\n\n\tint\t\t\t\tnumBots;\n\tint\t\t\t\tbaseBotNum;\n\tint\t\t\t\tselectedBotNum;\n\tchar\t\t\tbotnames[7][32];\n\tint\t\t\t\tbotClientNums[MAX_BOTS];\n} removeBotsMenuInfo_t;\n\nstatic removeBotsMenuInfo_t\tremoveBotsMenuInfo;\n\n\n/*\n=================\nUI_RemoveBotsMenu_SetBotNames\n=================\n*/\nstatic void UI_RemoveBotsMenu_SetBotNames( void ) {\n\tint\t\tn;\n\tchar\tinfo[MAX_INFO_STRING];\n\n\tfor ( n = 0; (n < 7) && (removeBotsMenuInfo.baseBotNum + n < removeBotsMenuInfo.numBots); n++ ) {\n\t\ttrap_GetConfigString( CS_PLAYERS + removeBotsMenuInfo.botClientNums[removeBotsMenuInfo.baseBotNum + n], info, MAX_INFO_STRING );\n\t\tQ_strncpyz( removeBotsMenuInfo.botnames[n], Info_ValueForKey( info, \"n\" ), sizeof(removeBotsMenuInfo.botnames[n]) );\n\t\tQ_CleanStr( removeBotsMenuInfo.botnames[n] );\n\t}\n\n}\n\n\n/*\n=================\nUI_RemoveBotsMenu_DeleteEvent\n=================\n*/\nstatic void UI_RemoveBotsMenu_DeleteEvent( void* ptr, int event ) {\n\tif (event != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\n\ttrap_Cmd_ExecuteText( EXEC_APPEND, va(\"clientkick %i\\n\", removeBotsMenuInfo.botClientNums[removeBotsMenuInfo.baseBotNum + removeBotsMenuInfo.selectedBotNum]) );\n}\n\n\n/*\n=================\nUI_RemoveBotsMenu_BotEvent\n=================\n*/\nstatic void UI_RemoveBotsMenu_BotEvent( void* ptr, int event ) {\n\tif (event != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\n\tremoveBotsMenuInfo.bots[removeBotsMenuInfo.selectedBotNum].color = color_orange;\n\tremoveBotsMenuInfo.selectedBotNum = ((menucommon_s*)ptr)->id - ID_BOTNAME0;\n\tremoveBotsMenuInfo.bots[removeBotsMenuInfo.selectedBotNum].color = color_white;\n}\n\n\n/*\n=================\nUI_RemoveAddBotsMenu_BackEvent\n=================\n*/\nstatic void UI_RemoveBotsMenu_BackEvent( void* ptr, int event ) {\n\tif (event != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\tUI_PopMenu();\n}\n\n\n/*\n=================\nUI_RemoveBotsMenu_UpEvent\n=================\n*/\nstatic void UI_RemoveBotsMenu_UpEvent( void* ptr, int event ) {\n\tif (event != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\n\tif( removeBotsMenuInfo.baseBotNum > 0 ) {\n\t\tremoveBotsMenuInfo.baseBotNum--;\n\t\tUI_RemoveBotsMenu_SetBotNames();\n\t}\n}\n\n\n/*\n=================\nUI_RemoveBotsMenu_DownEvent\n=================\n*/\nstatic void UI_RemoveBotsMenu_DownEvent( void* ptr, int event ) {\n\tif (event != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\n\tif( removeBotsMenuInfo.baseBotNum + 7 < removeBotsMenuInfo.numBots ) {\n\t\tremoveBotsMenuInfo.baseBotNum++;\n\t\tUI_RemoveBotsMenu_SetBotNames();\n\t}\n}\n\n\n/*\n=================\nUI_RemoveBotsMenu_GetBots\n=================\n*/\nstatic void UI_RemoveBotsMenu_GetBots( void ) {\n\tint\t\tnumPlayers;\n\tint\t\tisBot;\n\tint\t\tn;\n\tchar\tinfo[MAX_INFO_STRING];\n\n\ttrap_GetConfigString( CS_SERVERINFO, info, sizeof(info) );\n\tnumPlayers = atoi( Info_ValueForKey( info, \"sv_maxclients\" ) );\n\tremoveBotsMenuInfo.numBots = 0;\n\n\tfor( n = 0; n < numPlayers; n++ ) {\n\t\ttrap_GetConfigString( CS_PLAYERS + n, info, MAX_INFO_STRING );\n\n\t\tisBot = atoi( Info_ValueForKey( info, \"skill\" ) );\n\t\tif( !isBot ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tremoveBotsMenuInfo.botClientNums[removeBotsMenuInfo.numBots] = n;\n\t\tremoveBotsMenuInfo.numBots++;\n\t}\n}\n\n\n/*\n=================\nUI_RemoveBots_Cache\n=================\n*/\nvoid UI_RemoveBots_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( ART_BACKGROUND );\n\ttrap_R_RegisterShaderNoMip( ART_BACK0 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK1 );\n\ttrap_R_RegisterShaderNoMip( ART_DELETE0 );\n\ttrap_R_RegisterShaderNoMip( ART_DELETE1 );\n}\n\n\n/*\n=================\nUI_RemoveBotsMenu_Init\n=================\n*/\nstatic void UI_RemoveBotsMenu_Init( void ) {\n\tint\t\tn;\n\tint\t\tcount;\n\tint\t\ty;\n\n\tmemset( &removeBotsMenuInfo, 0 ,sizeof(removeBotsMenuInfo) );\n\tremoveBotsMenuInfo.menu.fullscreen = qfalse;\n\tremoveBotsMenuInfo.menu.wrapAround = qtrue;\n\n\tUI_RemoveBots_Cache();\n\n\tUI_RemoveBotsMenu_GetBots();\n\tUI_RemoveBotsMenu_SetBotNames();\n\tcount = removeBotsMenuInfo.numBots < 7 ? removeBotsMenuInfo.numBots : 7;\n\n\tremoveBotsMenuInfo.banner.generic.type\t\t= MTYPE_BTEXT;\n\tremoveBotsMenuInfo.banner.generic.x\t\t\t= 320;\n\tremoveBotsMenuInfo.banner.generic.y\t\t\t= 16;\n\tremoveBotsMenuInfo.banner.string\t\t\t= \"REMOVE BOTS\";\n\tremoveBotsMenuInfo.banner.color\t\t\t\t= color_white;\n\tremoveBotsMenuInfo.banner.style\t\t\t\t= UI_CENTER;\n\n\tremoveBotsMenuInfo.background.generic.type\t= MTYPE_BITMAP;\n\tremoveBotsMenuInfo.background.generic.name\t= ART_BACKGROUND;\n\tremoveBotsMenuInfo.background.generic.flags\t= QMF_INACTIVE;\n\tremoveBotsMenuInfo.background.generic.x\t\t= 320-233;\n\tremoveBotsMenuInfo.background.generic.y\t\t= 240-166;\n\tremoveBotsMenuInfo.background.width\t\t\t= 466;\n\tremoveBotsMenuInfo.background.height\t\t= 332;\n\n\tremoveBotsMenuInfo.arrows.generic.type\t\t= MTYPE_BITMAP;\n\tremoveBotsMenuInfo.arrows.generic.name\t\t= ART_ARROWS;\n\tremoveBotsMenuInfo.arrows.generic.flags\t\t= QMF_INACTIVE;\n\tremoveBotsMenuInfo.arrows.generic.x\t\t\t= 200;\n\tremoveBotsMenuInfo.arrows.generic.y\t\t\t= 128;\n\tremoveBotsMenuInfo.arrows.width\t\t\t\t= 64;\n\tremoveBotsMenuInfo.arrows.height\t\t\t= 128;\n\n\tremoveBotsMenuInfo.up.generic.type\t\t\t= MTYPE_BITMAP;\n\tremoveBotsMenuInfo.up.generic.flags\t\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tremoveBotsMenuInfo.up.generic.x\t\t\t\t= 200;\n\tremoveBotsMenuInfo.up.generic.y\t\t\t\t= 128;\n\tremoveBotsMenuInfo.up.generic.id\t\t\t= ID_UP;\n\tremoveBotsMenuInfo.up.generic.callback\t\t= UI_RemoveBotsMenu_UpEvent;\n\tremoveBotsMenuInfo.up.width\t\t\t\t\t= 64;\n\tremoveBotsMenuInfo.up.height\t\t\t\t= 64;\n\tremoveBotsMenuInfo.up.focuspic\t\t\t\t= ART_ARROWUP;\n\n\tremoveBotsMenuInfo.down.generic.type\t\t= MTYPE_BITMAP;\n\tremoveBotsMenuInfo.down.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tremoveBotsMenuInfo.down.generic.x\t\t\t= 200;\n\tremoveBotsMenuInfo.down.generic.y\t\t\t= 128+64;\n\tremoveBotsMenuInfo.down.generic.id\t\t\t= ID_DOWN;\n\tremoveBotsMenuInfo.down.generic.callback\t= UI_RemoveBotsMenu_DownEvent;\n\tremoveBotsMenuInfo.down.width\t\t\t\t= 64;\n\tremoveBotsMenuInfo.down.height\t\t\t\t= 64;\n\tremoveBotsMenuInfo.down.focuspic\t\t\t= ART_ARROWDOWN;\n\n\tfor( n = 0, y = 120; n < count; n++, y += 20 ) {\n\t\tremoveBotsMenuInfo.bots[n].generic.type\t\t= MTYPE_PTEXT;\n\t\tremoveBotsMenuInfo.bots[n].generic.flags\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\t\tremoveBotsMenuInfo.bots[n].generic.id\t\t= ID_BOTNAME0 + n;\n\t\tremoveBotsMenuInfo.bots[n].generic.x\t\t= 320 - 56;\n\t\tremoveBotsMenuInfo.bots[n].generic.y\t\t= y;\n\t\tremoveBotsMenuInfo.bots[n].generic.callback\t= UI_RemoveBotsMenu_BotEvent;\n\t\tremoveBotsMenuInfo.bots[n].string\t\t\t= removeBotsMenuInfo.botnames[n];\n\t\tremoveBotsMenuInfo.bots[n].color\t\t\t= color_orange;\n\t\tremoveBotsMenuInfo.bots[n].style\t\t\t= UI_LEFT|UI_SMALLFONT;\n\t}\n\n\tremoveBotsMenuInfo.delete.generic.type\t\t= MTYPE_BITMAP;\n\tremoveBotsMenuInfo.delete.generic.name\t\t= ART_DELETE0;\n\tremoveBotsMenuInfo.delete.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tremoveBotsMenuInfo.delete.generic.id\t\t= ID_DELETE;\n\tremoveBotsMenuInfo.delete.generic.callback\t= UI_RemoveBotsMenu_DeleteEvent;\n\tremoveBotsMenuInfo.delete.generic.x\t\t\t= 320+128-128;\n\tremoveBotsMenuInfo.delete.generic.y\t\t\t= 256+128-64;\n\tremoveBotsMenuInfo.delete.width  \t\t\t= 128;\n\tremoveBotsMenuInfo.delete.height  \t\t\t= 64;\n\tremoveBotsMenuInfo.delete.focuspic\t\t\t= ART_DELETE1;\n\n\tremoveBotsMenuInfo.back.generic.type\t\t= MTYPE_BITMAP;\n\tremoveBotsMenuInfo.back.generic.name\t\t= ART_BACK0;\n\tremoveBotsMenuInfo.back.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tremoveBotsMenuInfo.back.generic.id\t\t\t= ID_BACK;\n\tremoveBotsMenuInfo.back.generic.callback\t= UI_RemoveBotsMenu_BackEvent;\n\tremoveBotsMenuInfo.back.generic.x\t\t\t= 320-128;\n\tremoveBotsMenuInfo.back.generic.y\t\t\t= 256+128-64;\n\tremoveBotsMenuInfo.back.width\t\t\t\t= 128;\n\tremoveBotsMenuInfo.back.height\t\t\t\t= 64;\n\tremoveBotsMenuInfo.back.focuspic\t\t\t= ART_BACK1;\n\n\tMenu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.background );\n\tMenu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.banner );\n\tMenu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.arrows );\n\tMenu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.up );\n\tMenu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.down );\n\tfor( n = 0; n < count; n++ ) {\n\t\tMenu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.bots[n] );\n\t}\n\tMenu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.delete );\n\tMenu_AddItem( &removeBotsMenuInfo.menu, &removeBotsMenuInfo.back );\n\n\tremoveBotsMenuInfo.baseBotNum = 0;\n\tremoveBotsMenuInfo.selectedBotNum = 0;\n\tremoveBotsMenuInfo.bots[0].color = color_white;\n}\n\n\n/*\n=================\nUI_RemoveBotsMenu\n=================\n*/\nvoid UI_RemoveBotsMenu( void ) {\n\tUI_RemoveBotsMenu_Init();\n\tUI_PushMenu( &removeBotsMenuInfo.menu );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_saveconfig.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=============================================================================\n\nSAVE CONFIG MENU\n\n=============================================================================\n*/\n\n#include \"ui_local.h\"\n\n\n#define ART_BACK0\t\t\t\"menu/art/back_0\"\n#define ART_BACK1\t\t\t\"menu/art/back_1\"\t\n#define ART_SAVE0\t\t\t\"menu/art/save_0\"\n#define ART_SAVE1\t\t\t\"menu/art/save_1\"\n#define ART_BACKGROUND\t\t\"menu/art/cut_frame\"\n\n#define ID_NAME\t\t\t10\n#define ID_BACK\t\t\t11\n#define ID_SAVE\t\t\t12\n\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n\n\tmenutext_s\t\tbanner;\n\tmenubitmap_s\tbackground;\n\tmenufield_s\t\tsavename;\n\tmenubitmap_s\tback;\n\tmenubitmap_s\tsave;\n} saveConfig_t;\n\nstatic saveConfig_t\t\tsaveConfig;\n\n\n/*\n===============\nUI_SaveConfigMenu_BackEvent\n===============\n*/\nstatic void UI_SaveConfigMenu_BackEvent( void *ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tUI_PopMenu();\n}\n\n\n/*\n===============\nUI_SaveConfigMenu_SaveEvent\n===============\n*/\nstatic void UI_SaveConfigMenu_SaveEvent( void *ptr, int event ) {\n\tchar\tconfigname[MAX_QPATH];\n\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tif( !saveConfig.savename.field.buffer[0] ) {\n\t\treturn;\n\t}\n\n\tCOM_StripExtension(saveConfig.savename.field.buffer, configname );\n\ttrap_Cmd_ExecuteText( EXEC_APPEND, va( \"writeconfig %s.cfg\\n\", configname ) );\n\tUI_PopMenu();\n}\n\n\n/*\n===============\nUI_SaveConfigMenu_SavenameDraw\n===============\n*/\nstatic void UI_SaveConfigMenu_SavenameDraw( void *self ) {\n\tmenufield_s\t\t*f;\n\tint\t\t\t\tstyle;\n\tfloat\t\t\t*color;\n\n\tf = (menufield_s *)self;\n\n\tif( f == Menu_ItemAtCursor( &saveConfig.menu ) ) {\n\t\tstyle = UI_LEFT|UI_PULSE|UI_SMALLFONT;\n\t\tcolor = text_color_highlight;\n\t}\n\telse {\n\t\tstyle = UI_LEFT|UI_SMALLFONT;\n\t\tcolor = colorRed;\n\t}\n\n\tUI_DrawProportionalString( 320, 192, \"Enter filename:\", UI_CENTER|UI_SMALLFONT, color_orange );\n\tUI_FillRect( f->generic.x, f->generic.y, f->field.widthInChars*SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, colorBlack );\n\tMField_Draw( &f->field, f->generic.x, f->generic.y, style, color );\n}\n\n\n/*\n=================\nUI_SaveConfigMenu_Init\n=================\n*/\nstatic void UI_SaveConfigMenu_Init( void ) {\n\tmemset( &saveConfig, 0, sizeof(saveConfig) );\n\n\tUI_SaveConfigMenu_Cache();\n\tsaveConfig.menu.wrapAround = qtrue;\n\tsaveConfig.menu.fullscreen = qtrue;\n\n\tsaveConfig.banner.generic.type\t\t= MTYPE_BTEXT;\n\tsaveConfig.banner.generic.x\t\t\t= 320;\n\tsaveConfig.banner.generic.y\t\t\t= 16;\n\tsaveConfig.banner.string\t\t\t= \"SAVE CONFIG\";\n\tsaveConfig.banner.color\t\t\t\t= color_white;\n\tsaveConfig.banner.style\t\t\t\t= UI_CENTER;\n\n\tsaveConfig.background.generic.type\t\t= MTYPE_BITMAP;\n\tsaveConfig.background.generic.name\t\t= ART_BACKGROUND;\n\tsaveConfig.background.generic.flags\t\t= QMF_INACTIVE;\n\tsaveConfig.background.generic.x\t\t\t= 142;\n\tsaveConfig.background.generic.y\t\t\t= 118;\n\tsaveConfig.background.width\t\t\t\t= 359;\n\tsaveConfig.background.height\t\t\t= 256;\n\n\tsaveConfig.savename.generic.type\t\t= MTYPE_FIELD;\n\tsaveConfig.savename.generic.flags\t\t= QMF_NODEFAULTINIT|QMF_UPPERCASE;\n\tsaveConfig.savename.generic.ownerdraw\t= UI_SaveConfigMenu_SavenameDraw;\n\tsaveConfig.savename.field.widthInChars\t= 20;\n\tsaveConfig.savename.field.maxchars\t\t= 20;\n\tsaveConfig.savename.generic.x\t\t\t= 240;\n\tsaveConfig.savename.generic.y\t\t\t= 155+72;\n\tsaveConfig.savename.generic.left\t\t= 240;\n\tsaveConfig.savename.generic.top\t\t\t= 155+72;\n\tsaveConfig.savename.generic.right\t\t= 233 + 20*SMALLCHAR_WIDTH;\n\tsaveConfig.savename.generic.bottom\t\t= 155+72 + SMALLCHAR_HEIGHT+2;\n\n\tsaveConfig.back.generic.type\t\t= MTYPE_BITMAP;\n\tsaveConfig.back.generic.name\t\t= ART_BACK0;\n\tsaveConfig.back.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tsaveConfig.back.generic.id\t\t\t= ID_BACK;\n\tsaveConfig.back.generic.callback\t= UI_SaveConfigMenu_BackEvent;\n\tsaveConfig.back.generic.x\t\t\t= 0;\n\tsaveConfig.back.generic.y\t\t\t= 480-64;\n\tsaveConfig.back.width\t\t\t\t= 128;\n\tsaveConfig.back.height\t\t\t\t= 64;\n\tsaveConfig.back.focuspic\t\t\t= ART_BACK1;\n\n\tsaveConfig.save.generic.type\t\t= MTYPE_BITMAP;\n\tsaveConfig.save.generic.name\t\t= ART_SAVE0;\n\tsaveConfig.save.generic.flags\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tsaveConfig.save.generic.id\t\t\t= ID_SAVE;\n\tsaveConfig.save.generic.callback\t= UI_SaveConfigMenu_SaveEvent;\n\tsaveConfig.save.generic.x\t\t\t= 640;\n\tsaveConfig.save.generic.y\t\t\t= 480-64;\n\tsaveConfig.save.width  \t\t\t\t= 128;\n\tsaveConfig.save.height  \t\t    = 64;\n\tsaveConfig.save.focuspic\t\t\t= ART_SAVE1;\n\n\tMenu_AddItem( &saveConfig.menu, &saveConfig.banner );\n\tMenu_AddItem( &saveConfig.menu, &saveConfig.background );\n\tMenu_AddItem( &saveConfig.menu, &saveConfig.savename );\n\tMenu_AddItem( &saveConfig.menu, &saveConfig.back );\n\tMenu_AddItem( &saveConfig.menu, &saveConfig.save );\n}\n\n\n/*\n=================\nUI_SaveConfigMenu_Cache\n=================\n*/\nvoid UI_SaveConfigMenu_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( ART_BACK0 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK1 );\n\ttrap_R_RegisterShaderNoMip( ART_SAVE0 );\n\ttrap_R_RegisterShaderNoMip( ART_SAVE1 );\n\ttrap_R_RegisterShaderNoMip( ART_BACKGROUND );\n}\n\n\n/*\n===============\nUI_SaveConfigMenu\n===============\n*/\nvoid UI_SaveConfigMenu( void ) {\n\tUI_SaveConfigMenu_Init();\n\tUI_PushMenu( &saveConfig.menu );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_serverinfo.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#include \"ui_local.h\"\n\n#define SERVERINFO_FRAMEL\t\"menu/art/frame2_l\"\n#define SERVERINFO_FRAMER\t\"menu/art/frame1_r\"\n#define SERVERINFO_BACK0\t\"menu/art/back_0\"\n#define SERVERINFO_BACK1\t\"menu/art/back_1\"\n\nstatic char* serverinfo_artlist[] =\n{\n\tSERVERINFO_FRAMEL,\t\n\tSERVERINFO_FRAMER,\n\tSERVERINFO_BACK0,\n\tSERVERINFO_BACK1,\n\tNULL\n};\n\n#define ID_ADD\t 100\n#define ID_BACK\t 101\n\ntypedef struct\n{\n\tmenuframework_s\tmenu;\n\tmenutext_s\t\tbanner;\n\tmenubitmap_s\tframel;\n\tmenubitmap_s\tframer;\n\tmenubitmap_s\tback;\n\tmenutext_s\t\tadd;\n\tchar\t\t\tinfo[MAX_INFO_STRING];\n\tint\t\t\t\tnumlines;\n} serverinfo_t;\n\nstatic serverinfo_t\ts_serverinfo;\n\n\n/*\n=================\nFavorites_Add\n\nAdd current server to favorites\n=================\n*/\nvoid Favorites_Add( void )\n{\n\tchar\tadrstr[128];\n\tchar\tserverbuff[128];\n\tint\t\ti;\n\tint\t\tbest;\n\n\ttrap_Cvar_VariableStringBuffer( \"cl_currentServerAddress\", serverbuff, sizeof(serverbuff) );\n\tif (!serverbuff[0])\n\t\treturn;\n\n\tbest = 0;\n\tfor (i=0; i<MAX_FAVORITESERVERS; i++)\n\t{\n\t\ttrap_Cvar_VariableStringBuffer( va(\"server%d\",i+1), adrstr, sizeof(adrstr) );\n\t\tif (!Q_stricmp(serverbuff,adrstr))\n\t\t{\n\t\t\t// already in list\n\t\t\treturn;\n\t\t}\n\t\t\n\t\t// use first empty or non-numeric available slot\n\t\tif ((adrstr[0]  < '0' || adrstr[0] > '9' ) && !best)\n\t\t\tbest = i+1;\n\t}\n\n\tif (best)\n\t\ttrap_Cvar_Set( va(\"server%d\",best), serverbuff);\n}\n\n\n/*\n=================\nServerInfo_Event\n=================\n*/\nstatic void ServerInfo_Event( void* ptr, int event )\n{\n\tswitch (((menucommon_s*)ptr)->id)\n\t{\n\t\tcase ID_ADD:\n\t\t\tif (event != QM_ACTIVATED)\n\t\t\t\tbreak;\n\t\t\n\t\t\tFavorites_Add();\n\t\t\tUI_PopMenu();\n\t\t\tbreak;\n\n\t\tcase ID_BACK:\n\t\t\tif (event != QM_ACTIVATED)\n\t\t\t\tbreak;\n\n\t\t\tUI_PopMenu();\n\t\t\tbreak;\n\t}\n}\n\n/*\n=================\nServerInfo_MenuDraw\n=================\n*/\nstatic void ServerInfo_MenuDraw( void )\n{\n\tconst char\t\t*s;\n\tchar\t\t\tkey[MAX_INFO_KEY];\n\tchar\t\t\tvalue[MAX_INFO_VALUE];\n\tint\t\t\t\ty;\n\n\ty = SCREEN_HEIGHT/2 - s_serverinfo.numlines*(SMALLCHAR_HEIGHT)/2 - 20;\n\ts = s_serverinfo.info;\n\twhile ( s ) {\n\t\tInfo_NextPair( &s, key, value );\n\t\tif ( !key[0] ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tQ_strcat( key, MAX_INFO_KEY, \":\" ); \n\n\t\tUI_DrawString(SCREEN_WIDTH*0.50 - 8,y,key,UI_RIGHT|UI_SMALLFONT,color_red);\n\t\tUI_DrawString(SCREEN_WIDTH*0.50 + 8,y,value,UI_LEFT|UI_SMALLFONT,text_color_normal);\n\n\t\ty += SMALLCHAR_HEIGHT;\n\t}\n\n\tMenu_Draw( &s_serverinfo.menu );\n}\n\n/*\n=================\nServerInfo_MenuKey\n=================\n*/\nstatic sfxHandle_t ServerInfo_MenuKey( int key )\n{\n\treturn ( Menu_DefaultKey( &s_serverinfo.menu, key ) );\n}\n\n/*\n=================\nServerInfo_Cache\n=================\n*/\nvoid ServerInfo_Cache( void )\n{\n\tint\ti;\n\n\t// touch all our pics\n\tfor (i=0; ;i++)\n\t{\n\t\tif (!serverinfo_artlist[i])\n\t\t\tbreak;\n\t\ttrap_R_RegisterShaderNoMip(serverinfo_artlist[i]);\n\t}\n}\n\n/*\n=================\nUI_ServerInfoMenu\n=================\n*/\nvoid UI_ServerInfoMenu( void )\n{\n\tconst char\t\t*s;\n\tchar\t\t\tkey[MAX_INFO_KEY];\n\tchar\t\t\tvalue[MAX_INFO_VALUE];\n\n\t// zero set all our globals\n\tmemset( &s_serverinfo, 0 ,sizeof(serverinfo_t) );\n\n\tServerInfo_Cache();\n\n\ts_serverinfo.menu.draw       = ServerInfo_MenuDraw;\n\ts_serverinfo.menu.key        = ServerInfo_MenuKey;\n\ts_serverinfo.menu.wrapAround = qtrue;\n\ts_serverinfo.menu.fullscreen = qtrue;\n\n\ts_serverinfo.banner.generic.type  = MTYPE_BTEXT;\n\ts_serverinfo.banner.generic.x\t  = 320;\n\ts_serverinfo.banner.generic.y\t  = 16;\n\ts_serverinfo.banner.string\t\t  = \"SERVER INFO\";\n\ts_serverinfo.banner.color\t      = color_white;\n\ts_serverinfo.banner.style\t      = UI_CENTER;\n\n\ts_serverinfo.framel.generic.type  = MTYPE_BITMAP;\n\ts_serverinfo.framel.generic.name  = SERVERINFO_FRAMEL;\n\ts_serverinfo.framel.generic.flags = QMF_INACTIVE;\n\ts_serverinfo.framel.generic.x\t  = 0;  \n\ts_serverinfo.framel.generic.y\t  = 78;\n\ts_serverinfo.framel.width  \t      = 256;\n\ts_serverinfo.framel.height  \t  = 329;\n\n\ts_serverinfo.framer.generic.type  = MTYPE_BITMAP;\n\ts_serverinfo.framer.generic.name  = SERVERINFO_FRAMER;\n\ts_serverinfo.framer.generic.flags = QMF_INACTIVE;\n\ts_serverinfo.framer.generic.x\t  = 376;\n\ts_serverinfo.framer.generic.y\t  = 76;\n\ts_serverinfo.framer.width  \t      = 256;\n\ts_serverinfo.framer.height  \t  = 334;\n\n\ts_serverinfo.add.generic.type\t  = MTYPE_PTEXT;\n\ts_serverinfo.add.generic.flags    = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_serverinfo.add.generic.callback = ServerInfo_Event;\n\ts_serverinfo.add.generic.id\t      = ID_ADD;\n\ts_serverinfo.add.generic.x\t\t  = 320;\n\ts_serverinfo.add.generic.y\t\t  = 371;\n\ts_serverinfo.add.string  \t\t  = \"ADD TO FAVORITES\";\n\ts_serverinfo.add.style  \t\t  = UI_CENTER|UI_SMALLFONT;\n\ts_serverinfo.add.color\t\t\t  =\tcolor_red;\n\tif( trap_Cvar_VariableValue( \"sv_running\" ) ) {\n\t\ts_serverinfo.add.generic.flags |= QMF_GRAYED;\n\t}\n\n\ts_serverinfo.back.generic.type\t   = MTYPE_BITMAP;\n\ts_serverinfo.back.generic.name     = SERVERINFO_BACK0;\n\ts_serverinfo.back.generic.flags    = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_serverinfo.back.generic.callback = ServerInfo_Event;\n\ts_serverinfo.back.generic.id\t   = ID_BACK;\n\ts_serverinfo.back.generic.x\t\t   = 0;\n\ts_serverinfo.back.generic.y\t\t   = 480-64;\n\ts_serverinfo.back.width  \t\t   = 128;\n\ts_serverinfo.back.height  \t\t   = 64;\n\ts_serverinfo.back.focuspic         = SERVERINFO_BACK1;\n\n\ttrap_GetConfigString( CS_SERVERINFO, s_serverinfo.info, MAX_INFO_STRING );\n\n\ts_serverinfo.numlines = 0;\n\ts = s_serverinfo.info;\n\twhile ( s ) {\n\t\tInfo_NextPair( &s, key, value );\n\t\tif ( !key[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\ts_serverinfo.numlines++;\n\t}\n\n\tif (s_serverinfo.numlines > 16)\n\t\ts_serverinfo.numlines = 16;\n\n\tMenu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.banner );\n\tMenu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.framel );\n\tMenu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.framer );\n\tMenu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.add );\n\tMenu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.back );\n\n\tUI_PushMenu( &s_serverinfo.menu );\n}\n\n\n"
  },
  {
    "path": "code/q3_ui/ui_servers2.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=======================================================================\n\nMULTIPLAYER MENU (SERVER BROWSER)\n\n=======================================================================\n*/\n\n\n#include \"ui_local.h\"\n\n\n#define MAX_GLOBALSERVERS\t\t128\n#define MAX_PINGREQUESTS\t\t32\n#define MAX_ADDRESSLENGTH\t\t64\n#define MAX_HOSTNAMELENGTH\t\t22\n#define MAX_MAPNAMELENGTH\t\t16\n#define MAX_LISTBOXITEMS\t\t128\n#define MAX_LOCALSERVERS\t\t128\n#define MAX_STATUSLENGTH\t\t64\n#define MAX_LEAGUELENGTH\t\t28\n#define MAX_LISTBOXWIDTH\t\t68\n\n#define ART_BACK0\t\t\t\t\"menu/art/back_0\"\n#define ART_BACK1\t\t\t\t\"menu/art/back_1\"\n#define ART_CREATE0\t\t\t\t\"menu/art/create_0\"\n#define ART_CREATE1\t\t\t\t\"menu/art/create_1\"\n#define ART_SPECIFY0\t\t\t\"menu/art/specify_0\"\n#define ART_SPECIFY1\t\t\t\"menu/art/specify_1\"\n#define ART_REFRESH0\t\t\t\"menu/art/refresh_0\"\n#define ART_REFRESH1\t\t\t\"menu/art/refresh_1\"\n#define ART_CONNECT0\t\t\t\"menu/art/fight_0\"\n#define ART_CONNECT1\t\t\t\"menu/art/fight_1\"\n#define ART_ARROWS0\t\t\t\t\"menu/art/arrows_vert_0\"\n#define ART_ARROWS_UP\t\t\t\"menu/art/arrows_vert_top\"\n#define ART_ARROWS_DOWN\t\t\t\"menu/art/arrows_vert_bot\"\n#define ART_UNKNOWNMAP\t\t\t\"menu/art/unknownmap\"\n#define ART_REMOVE0\t\t\t\t\"menu/art/delete_0\"\n#define ART_REMOVE1\t\t\t\t\"menu/art/delete_1\"\n#define ART_PUNKBUSTER\t\t\"menu/art/pblogo\"\n\n#define ID_MASTER\t\t\t10\n#define ID_GAMETYPE\t\t\t11\n#define ID_SORTKEY\t\t\t12\n#define ID_SHOW_FULL\t\t13\n#define ID_SHOW_EMPTY\t\t14\n#define ID_LIST\t\t\t\t15\n#define ID_SCROLL_UP\t\t16\n#define ID_SCROLL_DOWN\t\t17\n#define ID_BACK\t\t\t\t18\n#define ID_REFRESH\t\t\t19\n#define ID_SPECIFY\t\t\t20\n#define ID_CREATE\t\t\t21\n#define ID_CONNECT\t\t\t22\n#define ID_REMOVE\t\t\t23\n#define ID_PUNKBUSTER 24\n\n#define GR_LOGO\t\t\t\t30\n#define GR_LETTERS\t\t\t31\n\n#define AS_LOCAL\t\t\t0\n#define AS_MPLAYER\t\t\t1\n#define AS_GLOBAL\t\t\t2\n#define AS_FAVORITES\t\t3\n\n#define SORT_HOST\t\t\t0\n#define SORT_MAP\t\t\t1\n#define SORT_CLIENTS\t\t2\n#define SORT_GAME\t\t\t3\n#define SORT_PING\t\t\t4\n\n#define GAMES_ALL\t\t\t0\n#define GAMES_FFA\t\t\t1\n#define GAMES_TEAMPLAY\t\t2\n#define GAMES_TOURNEY\t\t3\n#define GAMES_CTF\t\t\t4\n\nstatic const char *master_items[] = {\n\t\"Local\",\n\t\"Internet\",\n\t\"Favorites\",\n\t0\n};\n\nstatic const char *servertype_items[] = {\n\t\"All\",\n\t\"Free For All\",\n\t\"Team Deathmatch\",\n\t\"Tournament\",\n\t\"Capture the Flag\",\n\t0\n};\n\nstatic const char *sortkey_items[] = {\n\t\"Server Name\",\n\t\"Map Name\",\n\t\"Open Player Spots\",\n\t\"Game Type\",\n\t\"Ping Time\",\n\t0\n};\n\nstatic char* gamenames[] = {\n\t\"DM \",\t// deathmatch\n\t\"1v1\",\t// tournament\n\t\"SP \",\t// single player\n\t\"Team DM\",\t// team deathmatch\n\t\"CTF\",\t// capture the flag\n\t\"One Flag CTF\",\t\t// one flag ctf\n\t\"OverLoad\",\t\t\t\t// Overload\n\t\"Harvester\",\t\t\t// Harvester\n\t\"Rocket Arena 3\",\t// Rocket Arena 3\n\t\"Q3F\",\t\t\t\t\t\t// Q3F\n\t\"Urban Terror\",\t\t// Urban Terror\n\t\"OSP\",\t\t\t\t\t\t// Orange Smoothie Productions\n\t\"???\",\t\t\t// unknown\n\t0\n};\n\nstatic char* netnames[] = {\n\t\"???\",\n\t\"UDP\",\n\t\"IPX\",\n\tNULL\n};\n\nstatic char quake3worldMessage[] = \"Visit www.quake3world.com - News, Community, Events, Files\";\n\nconst char* punkbuster_items[] = {\n\t\"Disabled\",\n\t\"Enabled\",\n\tNULL\n};\n\nconst char* punkbuster_msg[] = {\n\t\"PunkBuster will be\",\n\t\"disabled the next time\",\n\t\"Quake III Arena\",\n\t\"is started.\",\n\tNULL\n};\n\ntypedef struct {\n\tchar\tadrstr[MAX_ADDRESSLENGTH];\n\tint\t\tstart;\n} pinglist_t;\n\ntypedef struct servernode_s {\n\tchar\tadrstr[MAX_ADDRESSLENGTH];\n\tchar\thostname[MAX_HOSTNAMELENGTH+3];\n\tchar\tmapname[MAX_MAPNAMELENGTH];\n\tint\t\tnumclients;\n\tint\t\tmaxclients;\n\tint\t\tpingtime;\n\tint\t\tgametype;\n\tchar\tgamename[12];\n\tint\t\tnettype;\n\tint\t\tminPing;\n\tint\t\tmaxPing;\n\tqboolean bPB;\n\n} servernode_t; \n\ntypedef struct {\n\tchar\t\t\tbuff[MAX_LISTBOXWIDTH];\n\tservernode_t*\tservernode;\n} table_t;\n\ntypedef struct {\n\tmenuframework_s\t\tmenu;\n\n\tmenutext_s\t\t\tbanner;\n\n\tmenulist_s\t\t\tmaster;\n\tmenulist_s\t\t\tgametype;\n\tmenulist_s\t\t\tsortkey;\n\tmenuradiobutton_s\tshowfull;\n\tmenuradiobutton_s\tshowempty;\n\n\tmenulist_s\t\t\tlist;\n\tmenubitmap_s\t\tmappic;\n\tmenubitmap_s\t\tarrows;\n\tmenubitmap_s\t\tup;\n\tmenubitmap_s\t\tdown;\n\tmenutext_s\t\t\tstatus;\n\tmenutext_s\t\t\tstatusbar;\n\n\tmenubitmap_s\t\tremove;\n\tmenubitmap_s\t\tback;\n\tmenubitmap_s\t\trefresh;\n\tmenubitmap_s\t\tspecify;\n\tmenubitmap_s\t\tcreate;\n\tmenubitmap_s\t\tgo;\n\n\tpinglist_t\t\t\tpinglist[MAX_PINGREQUESTS];\n\ttable_t\t\t\t\ttable[MAX_LISTBOXITEMS];\n\tchar*\t\t\t\titems[MAX_LISTBOXITEMS];\n\tint\t\t\t\t\tnumqueriedservers;\n\tint\t\t\t\t\t*numservers;\n\tservernode_t\t\t*serverlist;\t\n\tint\t\t\t\t\tcurrentping;\n\tqboolean\t\t\trefreshservers;\n\tint\t\t\t\t\tnextpingtime;\n\tint\t\t\t\t\tmaxservers;\n\tint\t\t\t\t\trefreshtime;\n\tchar\t\t\t\tfavoriteaddresses[MAX_FAVORITESERVERS][MAX_ADDRESSLENGTH];\n\tint\t\t\t\t\tnumfavoriteaddresses;\n\n\tmenulist_s\t\tpunkbuster;\n\tmenubitmap_s\tpblogo;\n} arenaservers_t;\n\nstatic arenaservers_t\tg_arenaservers;\n\n\nstatic servernode_t\t\tg_globalserverlist[MAX_GLOBALSERVERS];\nstatic int\t\t\t\tg_numglobalservers;\nstatic servernode_t\t\tg_localserverlist[MAX_LOCALSERVERS];\nstatic int\t\t\t\tg_numlocalservers;\nstatic servernode_t\t\tg_favoriteserverlist[MAX_FAVORITESERVERS];\nstatic int\t\t\t\tg_numfavoriteservers;\nstatic servernode_t\t\tg_mplayerserverlist[MAX_GLOBALSERVERS];\nstatic int\t\t\t\tg_nummplayerservers;\nstatic int\t\t\t\tg_servertype;\nstatic int\t\t\t\tg_gametype;\nstatic int\t\t\t\tg_sortkey;\nstatic int\t\t\t\tg_emptyservers;\nstatic int\t\t\t\tg_fullservers;\n\n\n/*\n=================\nArenaServers_MaxPing\n=================\n*/\nstatic int ArenaServers_MaxPing( void ) {\n\tint\t\tmaxPing;\n\n\tmaxPing = (int)trap_Cvar_VariableValue( \"cl_maxPing\" );\n\tif( maxPing < 100 ) {\n\t\tmaxPing = 100;\n\t}\n\treturn maxPing;\n}\n\n\n/*\n=================\nArenaServers_Compare\n=================\n*/\nstatic int QDECL ArenaServers_Compare( const void *arg1, const void *arg2 ) {\n\tfloat\t\t\tf1;\n\tfloat\t\t\tf2;\n\tservernode_t*\tt1;\n\tservernode_t*\tt2;\n\n\tt1 = (servernode_t *)arg1;\n\tt2 = (servernode_t *)arg2;\n\n\tswitch( g_sortkey ) {\n\tcase SORT_HOST:\n\t\treturn Q_stricmp( t1->hostname, t2->hostname );\n\n\tcase SORT_MAP:\n\t\treturn Q_stricmp( t1->mapname, t2->mapname );\n\n\tcase SORT_CLIENTS:\n\t\tf1 = t1->maxclients - t1->numclients;\n\t\tif( f1 < 0 ) {\n\t\t\tf1 = 0;\n\t\t}\n\n\t\tf2 = t2->maxclients - t2->numclients;\n\t\tif( f2 < 0 ) {\n\t\t\tf2 = 0;\n\t\t}\n\n\t\tif( f1 < f2 ) {\n\t\t\treturn 1;\n\t\t}\n\t\tif( f1 == f2 ) {\n\t\t\treturn 0;\n\t\t}\n\t\treturn -1;\n\n\tcase SORT_GAME:\n\t\tif( t1->gametype < t2->gametype ) {\n\t\t\treturn -1;\n\t\t}\n\t\tif( t1->gametype == t2->gametype ) {\n\t\t\treturn 0;\n\t\t}\n\t\treturn 1;\n\n\tcase SORT_PING:\n\t\tif( t1->pingtime < t2->pingtime ) {\n\t\t\treturn -1;\n\t\t}\n\t\tif( t1->pingtime > t2->pingtime ) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn Q_stricmp( t1->hostname, t2->hostname );\n\t}\n\n\treturn 0;\n}\n\n\n/*\n=================\nArenaServers_Go\n=================\n*/\nstatic void ArenaServers_Go( void ) {\n\tservernode_t*\tservernode;\n\n\tservernode = g_arenaservers.table[g_arenaservers.list.curvalue].servernode;\n\tif( servernode ) {\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va( \"connect %s\\n\", servernode->adrstr ) );\n\t}\n}\n\n\n/*\n=================\nArenaServers_UpdatePicture\n=================\n*/\nstatic void ArenaServers_UpdatePicture( void ) {\n\tstatic char\t\tpicname[64];\n\tservernode_t*\tservernodeptr;\n\n\tif( !g_arenaservers.list.numitems ) {\n\t\tg_arenaservers.mappic.generic.name = NULL;\n\t}\n\telse {\n\t\tservernodeptr = g_arenaservers.table[g_arenaservers.list.curvalue].servernode;\n\t\tCom_sprintf( picname, sizeof(picname), \"levelshots/%s.tga\", servernodeptr->mapname );\n\t\tg_arenaservers.mappic.generic.name = picname;\n\t\n\t}\n\n\t// force shader update during draw\n\tg_arenaservers.mappic.shader = 0;\n}\n\n\n/*\n=================\nArenaServers_UpdateMenu\n=================\n*/\nstatic void ArenaServers_UpdateMenu( void ) {\n\tint\t\t\t\ti;\n\tint\t\t\t\tj;\n\tint\t\t\t\tcount;\n\tchar*\t\t\tbuff;\n\tservernode_t*\tservernodeptr;\n\ttable_t*\t\ttableptr;\n\tchar\t\t\t*pingColor;\n\n\tif( g_arenaservers.numqueriedservers > 0 ) {\n\t\t// servers found\n\t\tif( g_arenaservers.refreshservers && ( g_arenaservers.currentping <= g_arenaservers.numqueriedservers ) ) {\n\t\t\t// show progress\n\t\t\tCom_sprintf( g_arenaservers.status.string, MAX_STATUSLENGTH, \"%d of %d Arena Servers.\", g_arenaservers.currentping, g_arenaservers.numqueriedservers);\n\t\t\tg_arenaservers.statusbar.string  = \"Press SPACE to stop\";\n\t\t\tqsort( g_arenaservers.serverlist, *g_arenaservers.numservers, sizeof( servernode_t ), ArenaServers_Compare);\n\t\t}\n\t\telse {\n\t\t\t// all servers pinged - enable controls\n\t\t\tg_arenaservers.master.generic.flags\t\t&= ~QMF_GRAYED;\n\t\t\tg_arenaservers.gametype.generic.flags\t&= ~QMF_GRAYED;\n\t\t\tg_arenaservers.sortkey.generic.flags\t&= ~QMF_GRAYED;\n\t\t\tg_arenaservers.showempty.generic.flags\t&= ~QMF_GRAYED;\n\t\t\tg_arenaservers.showfull.generic.flags\t&= ~QMF_GRAYED;\n\t\t\tg_arenaservers.list.generic.flags\t\t&= ~QMF_GRAYED;\n\t\t\tg_arenaservers.refresh.generic.flags\t&= ~QMF_GRAYED;\n\t\t\tg_arenaservers.go.generic.flags\t\t\t&= ~QMF_GRAYED;\n\t\t\tg_arenaservers.punkbuster.generic.flags &= ~QMF_GRAYED;\n\n\t\t\t// update status bar\n\t\t\tif( g_servertype == AS_GLOBAL || g_servertype == AS_MPLAYER ) {\n\t\t\t\tg_arenaservers.statusbar.string = quake3worldMessage;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tg_arenaservers.statusbar.string = \"\";\n\t\t\t}\n\n\t\t}\n\t}\n\telse {\n\t\t// no servers found\n\t\tif( g_arenaservers.refreshservers ) {\n\t\t\tstrcpy( g_arenaservers.status.string,\"Scanning For Servers.\" );\n\t\t\tg_arenaservers.statusbar.string = \"Press SPACE to stop\";\n\n\t\t\t// disable controls during refresh\n\t\t\tg_arenaservers.master.generic.flags\t\t|= QMF_GRAYED;\n\t\t\tg_arenaservers.gametype.generic.flags\t|= QMF_GRAYED;\n\t\t\tg_arenaservers.sortkey.generic.flags\t|= QMF_GRAYED;\n\t\t\tg_arenaservers.showempty.generic.flags\t|= QMF_GRAYED;\n\t\t\tg_arenaservers.showfull.generic.flags\t|= QMF_GRAYED;\n\t\t\tg_arenaservers.list.generic.flags\t\t|= QMF_GRAYED;\n\t\t\tg_arenaservers.refresh.generic.flags\t|= QMF_GRAYED;\n\t\t\tg_arenaservers.go.generic.flags\t\t\t|= QMF_GRAYED;\n\t\t\tg_arenaservers.punkbuster.generic.flags |= QMF_GRAYED;\n\t\t}\n\t\telse {\n\t\t\tif( g_arenaservers.numqueriedservers < 0 ) {\n\t\t\t\tstrcpy(g_arenaservers.status.string,\"No Response From Master Server.\" );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tstrcpy(g_arenaservers.status.string,\"No Servers Found.\" );\n\t\t\t}\n\n\t\t\t// update status bar\n\t\t\tif( g_servertype == AS_GLOBAL || g_servertype == AS_MPLAYER ) {\n\t\t\t\tg_arenaservers.statusbar.string = quake3worldMessage;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tg_arenaservers.statusbar.string = \"\";\n\t\t\t}\n\n\t\t\t// end of refresh - set control state\n\t\t\tg_arenaservers.master.generic.flags\t\t&= ~QMF_GRAYED;\n\t\t\tg_arenaservers.gametype.generic.flags\t&= ~QMF_GRAYED;\n\t\t\tg_arenaservers.sortkey.generic.flags\t&= ~QMF_GRAYED;\n\t\t\tg_arenaservers.showempty.generic.flags\t&= ~QMF_GRAYED;\n\t\t\tg_arenaservers.showfull.generic.flags\t&= ~QMF_GRAYED;\n\t\t\tg_arenaservers.list.generic.flags\t\t|= QMF_GRAYED;\n\t\t\tg_arenaservers.refresh.generic.flags\t&= ~QMF_GRAYED;\n\t\t\tg_arenaservers.go.generic.flags\t\t\t|= QMF_GRAYED;\n\t\t\tg_arenaservers.punkbuster.generic.flags &= ~QMF_GRAYED;\n\t\t}\n\n\t\t// zero out list box\n\t\tg_arenaservers.list.numitems = 0;\n\t\tg_arenaservers.list.curvalue = 0;\n\t\tg_arenaservers.list.top      = 0;\n\n\t\t// update picture\n\t\tArenaServers_UpdatePicture();\n\t\treturn;\n\t}\n\n\t// build list box strings - apply culling filters\n\tservernodeptr = g_arenaservers.serverlist;\n\tcount         = *g_arenaservers.numservers;\n\tfor( i = 0, j = 0; i < count; i++, servernodeptr++ ) {\n\t\ttableptr = &g_arenaservers.table[j];\n\t\ttableptr->servernode = servernodeptr;\n\t\tbuff = tableptr->buff;\n\n\t\t// can only cull valid results\n\t\tif( !g_emptyservers && !servernodeptr->numclients ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif( !g_fullservers && ( servernodeptr->numclients == servernodeptr->maxclients ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tswitch( g_gametype ) {\n\t\tcase GAMES_ALL:\n\t\t\tbreak;\n\n\t\tcase GAMES_FFA:\n\t\t\tif( servernodeptr->gametype != GT_FFA ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase GAMES_TEAMPLAY:\n\t\t\tif( servernodeptr->gametype != GT_TEAM ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase GAMES_TOURNEY:\n\t\t\tif( servernodeptr->gametype != GT_TOURNAMENT ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase GAMES_CTF:\n\t\t\tif( servernodeptr->gametype != GT_CTF ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tif( servernodeptr->pingtime < servernodeptr->minPing ) {\n\t\t\tpingColor = S_COLOR_BLUE;\n\t\t}\n\t\telse if( servernodeptr->maxPing && servernodeptr->pingtime > servernodeptr->maxPing ) {\n\t\t\tpingColor = S_COLOR_BLUE;\n\t\t}\n\t\telse if( servernodeptr->pingtime < 200 ) {\n\t\t\tpingColor = S_COLOR_GREEN;\n\t\t}\n\t\telse if( servernodeptr->pingtime < 400 ) {\n\t\t\tpingColor = S_COLOR_YELLOW;\n\t\t}\n\t\telse {\n\t\t\tpingColor = S_COLOR_RED;\n\t\t}\n\n\t\tCom_sprintf( buff, MAX_LISTBOXWIDTH, \"%-20.20s %-12.12s %2d/%2d %-8.8s %3s %s%3d \" S_COLOR_YELLOW \"%s\", \n\t\t\tservernodeptr->hostname, servernodeptr->mapname, servernodeptr->numclients,\n \t\t\tservernodeptr->maxclients, servernodeptr->gamename,\n\t\t\tnetnames[servernodeptr->nettype], pingColor, servernodeptr->pingtime, servernodeptr->bPB ? \"Yes\" : \"No\" );\n\t\tj++;\n\t}\n\n\tg_arenaservers.list.numitems = j;\n\tg_arenaservers.list.curvalue = 0;\n\tg_arenaservers.list.top      = 0;\n\n\t// update picture\n\tArenaServers_UpdatePicture();\n}\n\n\n/*\n=================\nArenaServers_Remove\n=================\n*/\nstatic void ArenaServers_Remove( void )\n{\n\tint\t\t\t\ti;\n\tservernode_t*\tservernodeptr;\n\ttable_t*\t\ttableptr;\n\n\tif (!g_arenaservers.list.numitems)\n\t\treturn;\n\n\t// remove selected item from display list\n\t// items are in scattered order due to sort and cull\n\t// perform delete on list box contents, resync all lists\n\n\ttableptr      = &g_arenaservers.table[g_arenaservers.list.curvalue];\n\tservernodeptr = tableptr->servernode;\n\n\t// find address in master list\n\tfor (i=0; i<g_arenaservers.numfavoriteaddresses; i++)\n\t\tif (!Q_stricmp(g_arenaservers.favoriteaddresses[i],servernodeptr->adrstr))\n\t\t\t\tbreak;\n\n\t// delete address from master list\n\tif (i <= g_arenaservers.numfavoriteaddresses-1)\n\t{\n\t\tif (i < g_arenaservers.numfavoriteaddresses-1)\n\t\t{\n\t\t\t// shift items up\n\t\t\tmemcpy( &g_arenaservers.favoriteaddresses[i], &g_arenaservers.favoriteaddresses[i+1], (g_arenaservers.numfavoriteaddresses - i - 1)*sizeof(MAX_ADDRESSLENGTH));\n\t\t}\n\t\tg_arenaservers.numfavoriteaddresses--;\n\t}\t\n\n\t// find address in server list\n\tfor (i=0; i<g_numfavoriteservers; i++)\n\t\tif (&g_favoriteserverlist[i] == servernodeptr)\n\t\t\t\tbreak;\n\n\t// delete address from server list\n\tif (i <= g_numfavoriteservers-1)\n\t{\n\t\tif (i < g_numfavoriteservers-1)\n\t\t{\n\t\t\t// shift items up\n\t\t\tmemcpy( &g_favoriteserverlist[i], &g_favoriteserverlist[i+1], (g_numfavoriteservers - i - 1)*sizeof(servernode_t));\n\t\t}\n\t\tg_numfavoriteservers--;\n\t}\t\n\n\tg_arenaservers.numqueriedservers = g_arenaservers.numfavoriteaddresses;\n\tg_arenaservers.currentping       = g_arenaservers.numfavoriteaddresses;\n}\n\n\n/*\n=================\nArenaServers_Insert\n=================\n*/\nstatic void ArenaServers_Insert( char* adrstr, char* info, int pingtime )\n{\n\tservernode_t*\tservernodeptr;\n\tchar*\t\t\ts;\n\tint\t\t\t\ti;\n\n\n\tif ((pingtime >= ArenaServers_MaxPing()) && (g_servertype != AS_FAVORITES))\n\t{\n\t\t// slow global or local servers do not get entered\n\t\treturn;\n\t}\n\n\tif (*g_arenaservers.numservers >= g_arenaservers.maxservers) {\n\t\t// list full;\n\t\tservernodeptr = g_arenaservers.serverlist+(*g_arenaservers.numservers)-1;\n\t} else {\n\t\t// next slot\n\t\tservernodeptr = g_arenaservers.serverlist+(*g_arenaservers.numservers);\n\t\t(*g_arenaservers.numservers)++;\n\t}\n\n\tQ_strncpyz( servernodeptr->adrstr, adrstr, MAX_ADDRESSLENGTH );\n\n\tQ_strncpyz( servernodeptr->hostname, Info_ValueForKey( info, \"hostname\"), MAX_HOSTNAMELENGTH );\n\tQ_CleanStr( servernodeptr->hostname );\n\tQ_strupr( servernodeptr->hostname );\n\n\tQ_strncpyz( servernodeptr->mapname, Info_ValueForKey( info, \"mapname\"), MAX_MAPNAMELENGTH );\n\tQ_CleanStr( servernodeptr->mapname );\n\tQ_strupr( servernodeptr->mapname );\n\n\tservernodeptr->numclients = atoi( Info_ValueForKey( info, \"clients\") );\n\tservernodeptr->maxclients = atoi( Info_ValueForKey( info, \"sv_maxclients\") );\n\tservernodeptr->pingtime   = pingtime;\n\tservernodeptr->minPing    = atoi( Info_ValueForKey( info, \"minPing\") );\n\tservernodeptr->maxPing    = atoi( Info_ValueForKey( info, \"maxPing\") );\n\tservernodeptr->bPB = atoi( Info_ValueForKey( info, \"punkbuster\") );\n\n\t/*\n\ts = Info_ValueForKey( info, \"nettype\" );\n\tfor (i=0; ;i++)\n\t{\n\t\tif (!netnames[i])\n\t\t{\n\t\t\tservernodeptr->nettype = 0;\n\t\t\tbreak;\n\t\t}\n\t\telse if (!Q_stricmp( netnames[i], s ))\n\t\t{\n\t\t\tservernodeptr->nettype = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\t*/\n\tservernodeptr->nettype = atoi(Info_ValueForKey(info, \"nettype\"));\n\n\ts = Info_ValueForKey( info, \"game\");\n\ti = atoi( Info_ValueForKey( info, \"gametype\") );\n\tif( i < 0 ) {\n\t\ti = 0;\n\t}\n\telse if( i > 11 ) {\n\t\ti = 12;\n\t}\n\tif( *s ) {\n\t\tservernodeptr->gametype = i;//-1;\n\t\tQ_strncpyz( servernodeptr->gamename, s, sizeof(servernodeptr->gamename) );\n\t}\n\telse {\n\t\tservernodeptr->gametype = i;\n\t\tQ_strncpyz( servernodeptr->gamename, gamenames[i], sizeof(servernodeptr->gamename) );\n\t}\n}\n\n\n/*\n=================\nArenaServers_InsertFavorites\n\nInsert nonresponsive address book entries into display lists.\n=================\n*/\nvoid ArenaServers_InsertFavorites( void )\n{\n\tint\t\ti;\n\tint\t\tj;\n\tchar\tinfo[MAX_INFO_STRING];\n\n\t// resync existing results with new or deleted cvars\n\tinfo[0] = '\\0';\n\tInfo_SetValueForKey( info, \"hostname\", \"No Response\" );\n\tfor (i=0; i<g_arenaservers.numfavoriteaddresses; i++)\n\t{\n\t\t// find favorite address in refresh list\n\t\tfor (j=0; j<g_numfavoriteservers; j++)\n\t\t\tif (!Q_stricmp(g_arenaservers.favoriteaddresses[i],g_favoriteserverlist[j].adrstr))\n\t\t\t\tbreak;\n\n\t\tif ( j >= g_numfavoriteservers)\n\t\t{\n\t\t\t// not in list, add it\n\t\t\tArenaServers_Insert( g_arenaservers.favoriteaddresses[i], info, ArenaServers_MaxPing() );\n\t\t}\n\t}\n}\n\n\n/*\n=================\nArenaServers_LoadFavorites\n\nLoad cvar address book entries into local lists.\n=================\n*/\nvoid ArenaServers_LoadFavorites( void )\n{\n\tint\t\t\t\ti;\n\tint\t\t\t\tj;\n\tint\t\t\t\tnumtempitems;\n\tchar\t\t\temptyinfo[MAX_INFO_STRING];\n\tchar\t\t\tadrstr[MAX_ADDRESSLENGTH];\n\tservernode_t\ttemplist[MAX_FAVORITESERVERS];\n\tqboolean\t\tfound;\n\n\tfound        = qfalse;\n\temptyinfo[0] = '\\0';\n\n\t// copy the old\n\tmemcpy( templist, g_favoriteserverlist, sizeof(servernode_t)*MAX_FAVORITESERVERS );\n\tnumtempitems = g_numfavoriteservers;\n\n\t// clear the current for sync\n\tmemset( g_favoriteserverlist, 0, sizeof(servernode_t)*MAX_FAVORITESERVERS );\n\tg_numfavoriteservers = 0;\n\n\t// resync existing results with new or deleted cvars\n\tfor (i=0; i<MAX_FAVORITESERVERS; i++)\n\t{\n\t\ttrap_Cvar_VariableStringBuffer( va(\"server%d\",i+1), adrstr, MAX_ADDRESSLENGTH );\n\t\tif (!adrstr[0])\n\t\t\tcontinue;\n\n\t\t// quick sanity check to avoid slow domain name resolving\n\t\t// first character must be numeric\n\t\tif (adrstr[0] < '0' || adrstr[0] > '9')\n\t\t\tcontinue;\n\n\t\t// favorite server addresses must be maintained outside refresh list\n\t\t// this mimics local and global netadr's stored in client\n\t\t// these can be fetched to fill ping list\n\t\tstrcpy( g_arenaservers.favoriteaddresses[g_numfavoriteservers], adrstr );\n\n\t\t// find this server in the old list\n\t\tfor (j=0; j<numtempitems; j++)\n\t\t\tif (!Q_stricmp( templist[j].adrstr, adrstr ))\n\t\t\t\tbreak;\n\n\t\tif (j < numtempitems)\n\t\t{\n\t\t\t// found server - add exisiting results\n\t\t\tmemcpy( &g_favoriteserverlist[g_numfavoriteservers], &templist[j], sizeof(servernode_t) );\n\t\t\tfound = qtrue;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// add new server\n\t\t\tQ_strncpyz( g_favoriteserverlist[g_numfavoriteservers].adrstr, adrstr, MAX_ADDRESSLENGTH );\n\t\t\tg_favoriteserverlist[g_numfavoriteservers].pingtime = ArenaServers_MaxPing();\n\t\t}\n\n\t\tg_numfavoriteservers++;\n\t}\n\n\tg_arenaservers.numfavoriteaddresses = g_numfavoriteservers;\n\n\tif (!found)\n\t{\n\t\t// no results were found, reset server list\n\t\t// list will be automatically refreshed when selected\n\t\tg_numfavoriteservers = 0;\n\t}\n}\n\n\n/*\n=================\nArenaServers_StopRefresh\n=================\n*/\nstatic void ArenaServers_StopRefresh( void )\n{\n\tif (!g_arenaservers.refreshservers)\n\t\t// not currently refreshing\n\t\treturn;\n\n\tg_arenaservers.refreshservers = qfalse;\n\n\tif (g_servertype == AS_FAVORITES)\n\t{\n\t\t// nonresponsive favorites must be shown\n\t\tArenaServers_InsertFavorites();\n\t}\n\n\t// final tally\n\tif (g_arenaservers.numqueriedservers >= 0)\n\t{\n\t\tg_arenaservers.currentping       = *g_arenaservers.numservers;\n\t\tg_arenaservers.numqueriedservers = *g_arenaservers.numservers; \n\t}\n\t\n\t// sort\n\tqsort( g_arenaservers.serverlist, *g_arenaservers.numservers, sizeof( servernode_t ), ArenaServers_Compare);\n\n\tArenaServers_UpdateMenu();\n}\n\n\n/*\n=================\nArenaServers_DoRefresh\n=================\n*/\nstatic void ArenaServers_DoRefresh( void )\n{\n\tint\t\ti;\n\tint\t\tj;\n\tint\t\ttime;\n\tint\t\tmaxPing;\n\tchar\tadrstr[MAX_ADDRESSLENGTH];\n\tchar\tinfo[MAX_INFO_STRING];\n\n\tif (uis.realtime < g_arenaservers.refreshtime)\n\t{\n\t  if (g_servertype != AS_FAVORITES) {\n\t\t\tif (g_servertype == AS_LOCAL) {\n\t\t\t\tif (!trap_LAN_GetServerCount(g_servertype)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (trap_LAN_GetServerCount(g_servertype) < 0) {\n\t\t\t  // still waiting for response\n\t\t\t  return;\n\t\t\t}\n\t  }\n\t}\n\n\tif (uis.realtime < g_arenaservers.nextpingtime)\n\t{\n\t\t// wait for time trigger\n\t\treturn;\n\t}\n\n\t// trigger at 10Hz intervals\n\tg_arenaservers.nextpingtime = uis.realtime + 10;\n\n\t// process ping results\n\tmaxPing = ArenaServers_MaxPing();\n\tfor (i=0; i<MAX_PINGREQUESTS; i++)\n\t{\n\t\ttrap_LAN_GetPing( i, adrstr, MAX_ADDRESSLENGTH, &time );\n\t\tif (!adrstr[0])\n\t\t{\n\t\t\t// ignore empty or pending pings\n\t\t\tcontinue;\n\t\t}\n\n\t\t// find ping result in our local list\n\t\tfor (j=0; j<MAX_PINGREQUESTS; j++)\n\t\t\tif (!Q_stricmp( adrstr, g_arenaservers.pinglist[j].adrstr ))\n\t\t\t\tbreak;\n\n\t\tif (j < MAX_PINGREQUESTS)\n\t\t{\n\t\t\t// found it\n\t\t\tif (!time)\n\t\t\t{\n\t\t\t\ttime = uis.realtime - g_arenaservers.pinglist[j].start;\n\t\t\t\tif (time < maxPing)\n\t\t\t\t{\n\t\t\t\t\t// still waiting\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (time > maxPing)\n\t\t\t{\n\t\t\t\t// stale it out\n\t\t\t\tinfo[0] = '\\0';\n\t\t\t\ttime    = maxPing;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttrap_LAN_GetPingInfo( i, info, MAX_INFO_STRING );\n\t\t\t}\n\n\t\t\t// insert ping results\n\t\t\tArenaServers_Insert( adrstr, info, time );\n\n\t\t\t// clear this query from internal list\n\t\t\tg_arenaservers.pinglist[j].adrstr[0] = '\\0';\n   \t\t}\n\n\t\t// clear this query from external list\n\t\ttrap_LAN_ClearPing( i );\n\t}\n\n\t// get results of servers query\n\t// counts can increase as servers respond\n\tif (g_servertype == AS_FAVORITES) {\n\t  g_arenaservers.numqueriedservers = g_arenaservers.numfavoriteaddresses;\n\t} else {\n\t  g_arenaservers.numqueriedservers = trap_LAN_GetServerCount(g_servertype);\n\t}\n\n//\tif (g_arenaservers.numqueriedservers > g_arenaservers.maxservers)\n//\t\tg_arenaservers.numqueriedservers = g_arenaservers.maxservers;\n\n\t// send ping requests in reasonable bursts\n\t// iterate ping through all found servers\n\tfor (i=0; i<MAX_PINGREQUESTS && g_arenaservers.currentping < g_arenaservers.numqueriedservers; i++)\n\t{\n\t\tif (trap_LAN_GetPingQueueCount() >= MAX_PINGREQUESTS)\n\t\t{\n\t\t\t// ping queue is full\n\t\t\tbreak;\n\t\t}\n\n\t\t// find empty slot\n\t\tfor (j=0; j<MAX_PINGREQUESTS; j++)\n\t\t\tif (!g_arenaservers.pinglist[j].adrstr[0])\n\t\t\t\tbreak;\n\n\t\tif (j >= MAX_PINGREQUESTS)\n\t\t\t// no empty slots available yet - wait for timeout\n\t\t\tbreak;\n\n\t\t// get an address to ping\n\n\t\tif (g_servertype == AS_FAVORITES) {\n\t\t  strcpy( adrstr, g_arenaservers.favoriteaddresses[g_arenaservers.currentping] ); \t\t\n\t\t} else {\n\t\t  trap_LAN_GetServerAddressString(g_servertype, g_arenaservers.currentping, adrstr, MAX_ADDRESSLENGTH );\n\t\t}\n\n\t\tstrcpy( g_arenaservers.pinglist[j].adrstr, adrstr );\n\t\tg_arenaservers.pinglist[j].start = uis.realtime;\n\n\t\ttrap_Cmd_ExecuteText( EXEC_NOW, va( \"ping %s\\n\", adrstr )  );\n\t\t\n\t\t// advance to next server\n\t\tg_arenaservers.currentping++;\n\t}\n\n\tif (!trap_LAN_GetPingQueueCount())\n\t{\n\t\t// all pings completed\n\t\tArenaServers_StopRefresh();\n\t\treturn;\n\t}\n\n\t// update the user interface with ping status\n\tArenaServers_UpdateMenu();\n}\n\n\n/*\n=================\nArenaServers_StartRefresh\n=================\n*/\nstatic void ArenaServers_StartRefresh( void )\n{\n\tint\t\ti;\n\tchar\tmyargs[32], protocol[32];\n\n\tmemset( g_arenaservers.serverlist, 0, g_arenaservers.maxservers*sizeof(table_t) );\n\n\tfor (i=0; i<MAX_PINGREQUESTS; i++)\n\t{\n\t\tg_arenaservers.pinglist[i].adrstr[0] = '\\0';\n\t\ttrap_LAN_ClearPing( i );\n\t}\n\n\tg_arenaservers.refreshservers    = qtrue;\n\tg_arenaservers.currentping       = 0;\n\tg_arenaservers.nextpingtime      = 0;\n\t*g_arenaservers.numservers       = 0;\n\tg_arenaservers.numqueriedservers = 0;\n\n\t// allow max 5 seconds for responses\n\tg_arenaservers.refreshtime = uis.realtime + 5000;\n\n\t// place menu in zeroed state\n\tArenaServers_UpdateMenu();\n\n\tif( g_servertype == AS_LOCAL ) {\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"localservers\\n\" );\n\t\treturn;\n\t}\n\n\tif( g_servertype == AS_GLOBAL || g_servertype == AS_MPLAYER ) {\n\t\tif( g_servertype == AS_GLOBAL ) {\n\t\t\ti = 0;\n\t\t}\n\t\telse {\n\t\t\ti = 1;\n\t\t}\n\n\t\tswitch( g_arenaservers.gametype.curvalue ) {\n\t\tdefault:\n\t\tcase GAMES_ALL:\n\t\t\tmyargs[0] = 0;\n\t\t\tbreak;\n\n\t\tcase GAMES_FFA:\n\t\t\tstrcpy( myargs, \" ffa\" );\n\t\t\tbreak;\n\n\t\tcase GAMES_TEAMPLAY:\n\t\t\tstrcpy( myargs, \" team\" );\n\t\t\tbreak;\n\n\t\tcase GAMES_TOURNEY:\n\t\t\tstrcpy( myargs, \" tourney\" );\n\t\t\tbreak;\n\n\t\tcase GAMES_CTF:\n\t\t\tstrcpy( myargs, \" ctf\" );\n\t\t\tbreak;\n\t\t}\n\n\n\t\tif (g_emptyservers) {\n\t\t\tstrcat(myargs, \" empty\");\n\t\t}\n\n\t\tif (g_fullservers) {\n\t\t\tstrcat(myargs, \" full\");\n\t\t}\n\n\t\tprotocol[0] = '\\0';\n\t\ttrap_Cvar_VariableStringBuffer( \"debug_protocol\", protocol, sizeof(protocol) );\n\t\tif (strlen(protocol)) {\n\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va( \"globalservers %d %s%s\\n\", i, protocol, myargs ));\n\t\t}\n\t\telse {\n\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va( \"globalservers %d %d%s\\n\", i, (int)trap_Cvar_VariableValue( \"protocol\" ), myargs ) );\n\t\t}\n\t}\n}\n\n\n/*\n=================\nArenaServers_SaveChanges\n=================\n*/\nvoid ArenaServers_SaveChanges( void )\n{\n\tint\ti;\n\n\tfor (i=0; i<g_arenaservers.numfavoriteaddresses; i++)\n\t\ttrap_Cvar_Set( va(\"server%d\",i+1), g_arenaservers.favoriteaddresses[i] );\n\n\tfor (; i<MAX_FAVORITESERVERS; i++)\n\t\ttrap_Cvar_Set( va(\"server%d\",i+1), \"\" );\n}\n\n\n/*\n=================\nArenaServers_Sort\n=================\n*/\nvoid ArenaServers_Sort( int type ) {\n\tif( g_sortkey == type ) {\n\t\treturn;\n\t}\n\n\tg_sortkey = type;\n\tqsort( g_arenaservers.serverlist, *g_arenaservers.numservers, sizeof( servernode_t ), ArenaServers_Compare);\n}\n\n\n/*\n=================\nArenaServers_SetType\n=================\n*/\nvoid ArenaServers_SetType( int type )\n{\n\tif (g_servertype == type)\n\t\treturn;\n\n\tg_servertype = type;\n\n\tswitch( type ) {\n\tdefault:\n\tcase AS_LOCAL:\n\t\tg_arenaservers.remove.generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);\n\t\tg_arenaservers.serverlist = g_localserverlist;\n\t\tg_arenaservers.numservers = &g_numlocalservers;\n\t\tg_arenaservers.maxservers = MAX_LOCALSERVERS;\n\t\tbreak;\n\n\tcase AS_GLOBAL:\n\t\tg_arenaservers.remove.generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);\n\t\tg_arenaservers.serverlist = g_globalserverlist;\n\t\tg_arenaservers.numservers = &g_numglobalservers;\n\t\tg_arenaservers.maxservers = MAX_GLOBALSERVERS;\n\t\tbreak;\n\n\tcase AS_FAVORITES:\n\t\tg_arenaservers.remove.generic.flags &= ~(QMF_INACTIVE|QMF_HIDDEN);\n\t\tg_arenaservers.serverlist = g_favoriteserverlist;\n\t\tg_arenaservers.numservers = &g_numfavoriteservers;\n\t\tg_arenaservers.maxservers = MAX_FAVORITESERVERS;\n\t\tbreak;\n\n\tcase AS_MPLAYER:\n\t\tg_arenaservers.remove.generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);\n\t\tg_arenaservers.serverlist = g_mplayerserverlist;\n\t\tg_arenaservers.numservers = &g_nummplayerservers;\n\t\tg_arenaservers.maxservers = MAX_GLOBALSERVERS;\n\t\tbreak;\n\t\t\n\t}\n\n\tif( !*g_arenaservers.numservers ) {\n\t\tArenaServers_StartRefresh();\n\t}\n\telse {\n\t\t// avoid slow operation, use existing results\n\t\tg_arenaservers.currentping       = *g_arenaservers.numservers;\n\t\tg_arenaservers.numqueriedservers = *g_arenaservers.numservers; \n\t\tArenaServers_UpdateMenu();\n\t}\n\tstrcpy(g_arenaservers.status.string,\"hit refresh to update\");\n}\n\n/*\n=================\nPunkBuster_Confirm\n=================\n*/\nstatic void Punkbuster_ConfirmEnable( qboolean result ) {\n\tif (result)\n\t{\t\t\n\t\ttrap_SetPbClStatus(1);\n\t}\n\tg_arenaservers.punkbuster.curvalue = Com_Clamp( 0, 1, trap_Cvar_VariableValue( \"cl_punkbuster\" ) );\n}\n\nstatic void Punkbuster_ConfirmDisable( qboolean result ) {\n\tif (result)\n\t{\n\t\ttrap_SetPbClStatus(0);\n\t\tUI_Message( punkbuster_msg );\n\t}\n\tg_arenaservers.punkbuster.curvalue = Com_Clamp( 0, 1, trap_Cvar_VariableValue( \"cl_punkbuster\" ) );\n}\n\n/*\n=================\nArenaServers_Event\n=================\n*/\nstatic void ArenaServers_Event( void* ptr, int event ) {\n\tint\t\tid;\n\tint value;\n\n\tid = ((menucommon_s*)ptr)->id;\n\n\tif( event != QM_ACTIVATED && id != ID_LIST ) {\n\t\treturn;\n\t}\n\n\tswitch( id ) {\n\tcase ID_MASTER:\n\t\tvalue = g_arenaservers.master.curvalue;\n\t\tif (value >= 1)\n\t\t{\n\t\t\tvalue++;\n\t\t}\n\t\ttrap_Cvar_SetValue( \"ui_browserMaster\", value );\n\t\tArenaServers_SetType( value );\n\t\tbreak;\n\n\tcase ID_GAMETYPE:\n\t\ttrap_Cvar_SetValue( \"ui_browserGameType\", g_arenaservers.gametype.curvalue );\n\t\tg_gametype = g_arenaservers.gametype.curvalue;\n\t\tArenaServers_UpdateMenu();\n\t\tbreak;\n\n\tcase ID_SORTKEY:\n\t\ttrap_Cvar_SetValue( \"ui_browserSortKey\", g_arenaservers.sortkey.curvalue );\n\t\tArenaServers_Sort( g_arenaservers.sortkey.curvalue );\n\t\tArenaServers_UpdateMenu();\n\t\tbreak;\n\n\tcase ID_SHOW_FULL:\n\t\ttrap_Cvar_SetValue( \"ui_browserShowFull\", g_arenaservers.showfull.curvalue );\n\t\tg_fullservers = g_arenaservers.showfull.curvalue;\n\t\tArenaServers_UpdateMenu();\n\t\tbreak;\n\n\tcase ID_SHOW_EMPTY:\n\t\ttrap_Cvar_SetValue( \"ui_browserShowEmpty\", g_arenaservers.showempty.curvalue );\n\t\tg_emptyservers = g_arenaservers.showempty.curvalue;\n\t\tArenaServers_UpdateMenu();\n\t\tbreak;\n\n\tcase ID_LIST:\n\t\tif( event == QM_GOTFOCUS ) {\n\t\t\tArenaServers_UpdatePicture();\n\t\t}\n\t\tbreak;\n\n\tcase ID_SCROLL_UP:\n\t\tScrollList_Key( &g_arenaservers.list, K_UPARROW );\n\t\tbreak;\n\n\tcase ID_SCROLL_DOWN:\n\t\tScrollList_Key( &g_arenaservers.list, K_DOWNARROW );\n\t\tbreak;\n\n\tcase ID_BACK:\n\t\tArenaServers_StopRefresh();\n\t\tArenaServers_SaveChanges();\n\t\tUI_PopMenu();\n\t\tbreak;\n\n\tcase ID_REFRESH:\n\t\tArenaServers_StartRefresh();\n\t\tbreak;\n\n\tcase ID_SPECIFY:\n\t\tUI_SpecifyServerMenu();\n\t\tbreak;\n\n\tcase ID_CREATE:\n\t\tUI_StartServerMenu( qtrue );\n\t\tbreak;\n\n\tcase ID_CONNECT:\n\t\tArenaServers_Go();\n\t\tbreak;\n\n\tcase ID_REMOVE:\n\t\tArenaServers_Remove();\n\t\tArenaServers_UpdateMenu();\n\t\tbreak;\n\t\n\tcase ID_PUNKBUSTER:\n\t\tif (g_arenaservers.punkbuster.curvalue)\t\t\t\n\t\t{\n\t\t\tUI_ConfirmMenu_Style( \"Enable Punkbuster?\",  UI_CENTER|UI_INVERSE|UI_SMALLFONT, (voidfunc_f)NULL, Punkbuster_ConfirmEnable );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tUI_ConfirmMenu_Style( \"Disable Punkbuster?\", UI_CENTER|UI_INVERSE|UI_SMALLFONT, (voidfunc_f)NULL, Punkbuster_ConfirmDisable );\n\t\t}\n\t\tbreak;\n\t}\n}\n\n\n/*\n=================\nArenaServers_MenuDraw\n=================\n*/\nstatic void ArenaServers_MenuDraw( void )\n{\n\tif (g_arenaservers.refreshservers)\n\t\tArenaServers_DoRefresh();\n\n\tMenu_Draw( &g_arenaservers.menu );\n}\n\n\n/*\n=================\nArenaServers_MenuKey\n=================\n*/\nstatic sfxHandle_t ArenaServers_MenuKey( int key ) {\n\tif( key == K_SPACE  && g_arenaservers.refreshservers ) {\n\t\tArenaServers_StopRefresh();\t\n\t\treturn menu_move_sound;\n\t}\n\n\tif( ( key == K_DEL || key == K_KP_DEL ) && ( g_servertype == AS_FAVORITES ) &&\n\t\t( Menu_ItemAtCursor( &g_arenaservers.menu) == &g_arenaservers.list ) ) {\n\t\tArenaServers_Remove();\n\t\tArenaServers_UpdateMenu();\n\t\treturn menu_move_sound;\n\t}\n\n\tif( key == K_MOUSE2 || key == K_ESCAPE ) {\n\t\tArenaServers_StopRefresh();\n\t\tArenaServers_SaveChanges();\n\t}\n\n\n\treturn Menu_DefaultKey( &g_arenaservers.menu, key );\n}\n\n\n/*\n=================\nArenaServers_MenuInit\n=================\n*/\nstatic void ArenaServers_MenuInit( void ) {\n\tint\t\t\ti;\n\tint\t\t\ttype;\n\tint\t\t\ty;\n\tint\t\t\tvalue;\n\tstatic char\tstatusbuffer[MAX_STATUSLENGTH];\n\n\t// zero set all our globals\n\tmemset( &g_arenaservers, 0 ,sizeof(arenaservers_t) );\n\n\tArenaServers_Cache();\n\n\tg_arenaservers.menu.fullscreen = qtrue;\n\tg_arenaservers.menu.wrapAround = qtrue;\n\tg_arenaservers.menu.draw       = ArenaServers_MenuDraw;\n\tg_arenaservers.menu.key        = ArenaServers_MenuKey;\n\n\tg_arenaservers.banner.generic.type  = MTYPE_BTEXT;\n\tg_arenaservers.banner.generic.flags = QMF_CENTER_JUSTIFY;\n\tg_arenaservers.banner.generic.x\t    = 320;\n\tg_arenaservers.banner.generic.y\t    = 16;\n\tg_arenaservers.banner.string  \t\t= \"ARENA SERVERS\";\n\tg_arenaservers.banner.style  \t    = UI_CENTER;\n\tg_arenaservers.banner.color  \t    = color_white;\n\n\ty = 80;\n\tg_arenaservers.master.generic.type\t\t\t= MTYPE_SPINCONTROL;\n\tg_arenaservers.master.generic.name\t\t\t= \"Servers:\";\n\tg_arenaservers.master.generic.flags\t\t\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\tg_arenaservers.master.generic.callback\t\t= ArenaServers_Event;\n\tg_arenaservers.master.generic.id\t\t\t= ID_MASTER;\n\tg_arenaservers.master.generic.x\t\t\t\t= 320;\n\tg_arenaservers.master.generic.y\t\t\t\t= y;\n\tg_arenaservers.master.itemnames\t\t\t\t= master_items;\n\n\ty += SMALLCHAR_HEIGHT;\n\tg_arenaservers.gametype.generic.type\t\t= MTYPE_SPINCONTROL;\n\tg_arenaservers.gametype.generic.name\t\t= \"Game Type:\";\n\tg_arenaservers.gametype.generic.flags\t\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\tg_arenaservers.gametype.generic.callback\t= ArenaServers_Event;\n\tg_arenaservers.gametype.generic.id\t\t\t= ID_GAMETYPE;\n\tg_arenaservers.gametype.generic.x\t\t\t= 320;\n\tg_arenaservers.gametype.generic.y\t\t\t= y;\n\tg_arenaservers.gametype.itemnames\t\t\t= servertype_items;\n\n\ty += SMALLCHAR_HEIGHT;\n\tg_arenaservers.sortkey.generic.type\t\t\t= MTYPE_SPINCONTROL;\n\tg_arenaservers.sortkey.generic.name\t\t\t= \"Sort By:\";\n\tg_arenaservers.sortkey.generic.flags\t\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\tg_arenaservers.sortkey.generic.callback\t\t= ArenaServers_Event;\n\tg_arenaservers.sortkey.generic.id\t\t\t= ID_SORTKEY;\n\tg_arenaservers.sortkey.generic.x\t\t\t= 320;\n\tg_arenaservers.sortkey.generic.y\t\t\t= y;\n\tg_arenaservers.sortkey.itemnames\t\t\t= sortkey_items;\n\n\ty += SMALLCHAR_HEIGHT;\n\tg_arenaservers.showfull.generic.type\t\t= MTYPE_RADIOBUTTON;\n\tg_arenaservers.showfull.generic.name\t\t= \"Show Full:\";\n\tg_arenaservers.showfull.generic.flags\t\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\tg_arenaservers.showfull.generic.callback\t= ArenaServers_Event;\n\tg_arenaservers.showfull.generic.id\t\t\t= ID_SHOW_FULL;\n\tg_arenaservers.showfull.generic.x\t\t\t= 320;\n\tg_arenaservers.showfull.generic.y\t\t\t= y;\n\n\ty += SMALLCHAR_HEIGHT;\n\tg_arenaservers.showempty.generic.type\t\t= MTYPE_RADIOBUTTON;\n\tg_arenaservers.showempty.generic.name\t\t= \"Show Empty:\";\n\tg_arenaservers.showempty.generic.flags\t\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\tg_arenaservers.showempty.generic.callback\t= ArenaServers_Event;\n\tg_arenaservers.showempty.generic.id\t\t\t= ID_SHOW_EMPTY;\n\tg_arenaservers.showempty.generic.x\t\t\t= 320;\n\tg_arenaservers.showempty.generic.y\t\t\t= y;\n\n\ty += 3 * SMALLCHAR_HEIGHT;\n\tg_arenaservers.list.generic.type\t\t\t= MTYPE_SCROLLLIST;\n\tg_arenaservers.list.generic.flags\t\t\t= QMF_HIGHLIGHT_IF_FOCUS;\n\tg_arenaservers.list.generic.id\t\t\t\t= ID_LIST;\n\tg_arenaservers.list.generic.callback\t\t= ArenaServers_Event;\n\tg_arenaservers.list.generic.x\t\t\t\t= 72;\n\tg_arenaservers.list.generic.y\t\t\t\t= y;\n\tg_arenaservers.list.width\t\t\t\t\t= MAX_LISTBOXWIDTH;\n\tg_arenaservers.list.height\t\t\t\t\t= 11;\n\tg_arenaservers.list.itemnames\t\t\t\t= (const char **)g_arenaservers.items;\n\tfor( i = 0; i < MAX_LISTBOXITEMS; i++ ) {\n\t\tg_arenaservers.items[i] = g_arenaservers.table[i].buff;\n\t}\n\n\tg_arenaservers.mappic.generic.type\t\t\t= MTYPE_BITMAP;\n\tg_arenaservers.mappic.generic.flags\t\t\t= QMF_LEFT_JUSTIFY|QMF_INACTIVE;\n\tg_arenaservers.mappic.generic.x\t\t\t\t= 72;\n\tg_arenaservers.mappic.generic.y\t\t\t\t= 80;\n\tg_arenaservers.mappic.width\t\t\t\t\t= 128;\n\tg_arenaservers.mappic.height\t\t\t\t= 96;\n\tg_arenaservers.mappic.errorpic\t\t\t\t= ART_UNKNOWNMAP;\n\n\tg_arenaservers.arrows.generic.type\t\t\t= MTYPE_BITMAP;\n\tg_arenaservers.arrows.generic.name\t\t\t= ART_ARROWS0;\n\tg_arenaservers.arrows.generic.flags\t\t\t= QMF_LEFT_JUSTIFY|QMF_INACTIVE;\n\tg_arenaservers.arrows.generic.callback\t\t= ArenaServers_Event;\n\tg_arenaservers.arrows.generic.x\t\t\t\t= 512+48;\n\tg_arenaservers.arrows.generic.y\t\t\t\t= 240-64+16;\n\tg_arenaservers.arrows.width\t\t\t\t\t= 64;\n\tg_arenaservers.arrows.height\t\t\t\t= 128;\n\n\tg_arenaservers.up.generic.type\t\t\t\t= MTYPE_BITMAP;\n\tg_arenaservers.up.generic.flags\t\t\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;\n\tg_arenaservers.up.generic.callback\t\t\t= ArenaServers_Event;\n\tg_arenaservers.up.generic.id\t\t\t\t= ID_SCROLL_UP;\n\tg_arenaservers.up.generic.x\t\t\t\t\t= 512+48;\n\tg_arenaservers.up.generic.y\t\t\t\t\t= 240-64+16;\n\tg_arenaservers.up.width\t\t\t\t\t\t= 64;\n\tg_arenaservers.up.height\t\t\t\t\t= 64;\n\tg_arenaservers.up.focuspic\t\t\t\t\t= ART_ARROWS_UP;\n\n\tg_arenaservers.down.generic.type\t\t\t= MTYPE_BITMAP;\n\tg_arenaservers.down.generic.flags\t\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;\n\tg_arenaservers.down.generic.callback\t\t= ArenaServers_Event;\n\tg_arenaservers.down.generic.id\t\t\t\t= ID_SCROLL_DOWN;\n\tg_arenaservers.down.generic.x\t\t\t\t= 512+48;\n\tg_arenaservers.down.generic.y\t\t\t\t= 240+16;\n\tg_arenaservers.down.width\t\t\t\t\t= 64;\n\tg_arenaservers.down.height\t\t\t\t\t= 64;\n\tg_arenaservers.down.focuspic\t\t\t\t= ART_ARROWS_DOWN;\n\n\ty = 376;\n\tg_arenaservers.status.generic.type\t\t= MTYPE_TEXT;\n\tg_arenaservers.status.generic.x\t\t\t= 320;\n\tg_arenaservers.status.generic.y\t\t\t= y;\n\tg_arenaservers.status.string\t\t\t= statusbuffer;\n\tg_arenaservers.status.style\t\t\t\t= UI_CENTER|UI_SMALLFONT;\n\tg_arenaservers.status.color\t\t\t\t= menu_text_color;\n\n\ty += SMALLCHAR_HEIGHT;\n\tg_arenaservers.statusbar.generic.type   = MTYPE_TEXT;\n\tg_arenaservers.statusbar.generic.x\t    = 320;\n\tg_arenaservers.statusbar.generic.y\t    = y;\n\tg_arenaservers.statusbar.string\t        = \"\";\n\tg_arenaservers.statusbar.style\t        = UI_CENTER|UI_SMALLFONT;\n\tg_arenaservers.statusbar.color\t        = text_color_normal;\n\n\tg_arenaservers.remove.generic.type\t\t= MTYPE_BITMAP;\n\tg_arenaservers.remove.generic.name\t\t= ART_REMOVE0;\n\tg_arenaservers.remove.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tg_arenaservers.remove.generic.callback\t= ArenaServers_Event;\n\tg_arenaservers.remove.generic.id\t\t= ID_REMOVE;\n\tg_arenaservers.remove.generic.x\t\t\t= 450;\n\tg_arenaservers.remove.generic.y\t\t\t= 86;\n\tg_arenaservers.remove.width\t\t\t\t= 96;\n\tg_arenaservers.remove.height\t\t\t= 48;\n\tg_arenaservers.remove.focuspic\t\t\t= ART_REMOVE1;\n\n\tg_arenaservers.back.generic.type\t\t= MTYPE_BITMAP;\n\tg_arenaservers.back.generic.name\t\t= ART_BACK0;\n\tg_arenaservers.back.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tg_arenaservers.back.generic.callback\t= ArenaServers_Event;\n\tg_arenaservers.back.generic.id\t\t\t= ID_BACK;\n\tg_arenaservers.back.generic.x\t\t\t= 0;\n\tg_arenaservers.back.generic.y\t\t\t= 480-64;\n\tg_arenaservers.back.width\t\t\t\t= 128;\n\tg_arenaservers.back.height\t\t\t\t= 64;\n\tg_arenaservers.back.focuspic\t\t\t= ART_BACK1;\n\n\tg_arenaservers.specify.generic.type\t    = MTYPE_BITMAP;\n\tg_arenaservers.specify.generic.name\t\t= ART_SPECIFY0;\n\tg_arenaservers.specify.generic.flags    = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tg_arenaservers.specify.generic.callback = ArenaServers_Event;\n\tg_arenaservers.specify.generic.id\t    = ID_SPECIFY;\n\tg_arenaservers.specify.generic.x\t\t= 128;\n\tg_arenaservers.specify.generic.y\t\t= 480-64;\n\tg_arenaservers.specify.width  \t\t    = 128;\n\tg_arenaservers.specify.height  \t\t    = 64;\n\tg_arenaservers.specify.focuspic         = ART_SPECIFY1;\n\n\tg_arenaservers.refresh.generic.type\t\t= MTYPE_BITMAP;\n\tg_arenaservers.refresh.generic.name\t\t= ART_REFRESH0;\n\tg_arenaservers.refresh.generic.flags\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tg_arenaservers.refresh.generic.callback\t= ArenaServers_Event;\n\tg_arenaservers.refresh.generic.id\t\t= ID_REFRESH;\n\tg_arenaservers.refresh.generic.x\t\t= 256;\n\tg_arenaservers.refresh.generic.y\t\t= 480-64;\n\tg_arenaservers.refresh.width\t\t\t= 128;\n\tg_arenaservers.refresh.height\t\t\t= 64;\n\tg_arenaservers.refresh.focuspic\t\t\t= ART_REFRESH1;\n\n\tg_arenaservers.create.generic.type\t\t= MTYPE_BITMAP;\n\tg_arenaservers.create.generic.name\t\t= ART_CREATE0;\n\tg_arenaservers.create.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tg_arenaservers.create.generic.callback\t= ArenaServers_Event;\n\tg_arenaservers.create.generic.id\t\t= ID_CREATE;\n\tg_arenaservers.create.generic.x\t\t\t= 384;\n\tg_arenaservers.create.generic.y\t\t\t= 480-64;\n\tg_arenaservers.create.width\t\t\t\t= 128;\n\tg_arenaservers.create.height\t\t\t= 64;\n\tg_arenaservers.create.focuspic\t\t\t= ART_CREATE1;\n\n\tg_arenaservers.go.generic.type\t\t\t= MTYPE_BITMAP;\n\tg_arenaservers.go.generic.name\t\t\t= ART_CONNECT0;\n\tg_arenaservers.go.generic.flags\t\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tg_arenaservers.go.generic.callback\t\t= ArenaServers_Event;\n\tg_arenaservers.go.generic.id\t\t\t= ID_CONNECT;\n\tg_arenaservers.go.generic.x\t\t\t\t= 640;\n\tg_arenaservers.go.generic.y\t\t\t\t= 480-64;\n\tg_arenaservers.go.width\t\t\t\t\t= 128;\n\tg_arenaservers.go.height\t\t\t\t= 64;\n\tg_arenaservers.go.focuspic\t\t\t\t= ART_CONNECT1;\n\n\tg_arenaservers.punkbuster.generic.type\t\t\t= MTYPE_SPINCONTROL;\n\tg_arenaservers.punkbuster.generic.name\t\t\t= \"Punkbuster:\";\n\tg_arenaservers.punkbuster.generic.flags\t\t\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\tg_arenaservers.punkbuster.generic.callback\t\t= ArenaServers_Event;\n\tg_arenaservers.punkbuster.generic.id\t\t\t= ID_PUNKBUSTER;\n\tg_arenaservers.punkbuster.generic.x\t\t\t\t= 480+32;\n\tg_arenaservers.punkbuster.generic.y\t\t\t\t= 144;\n\tg_arenaservers.punkbuster.itemnames\t\t\t\t= punkbuster_items;\n\t\n\tg_arenaservers.pblogo.generic.type\t\t\t= MTYPE_BITMAP;\n\tg_arenaservers.pblogo.generic.name\t\t\t= ART_PUNKBUSTER;\n\tg_arenaservers.pblogo.generic.flags\t\t\t= QMF_LEFT_JUSTIFY|QMF_INACTIVE;\n\tg_arenaservers.pblogo.generic.x\t\t\t\t= 526;\n\tg_arenaservers.pblogo.generic.y\t\t\t\t= 176;\n\tg_arenaservers.pblogo.width\t\t\t\t\t= 32;\n\tg_arenaservers.pblogo.height\t\t\t\t= 16;\n\tg_arenaservers.pblogo.errorpic\t\t\t\t= ART_UNKNOWNMAP;\n\t\n\tMenu_AddItem( &g_arenaservers.menu, (void*) &g_arenaservers.banner );\n\n\tMenu_AddItem( &g_arenaservers.menu, (void*) &g_arenaservers.master );\n\tMenu_AddItem( &g_arenaservers.menu, (void*) &g_arenaservers.gametype );\n\tMenu_AddItem( &g_arenaservers.menu, (void*) &g_arenaservers.sortkey );\n\tMenu_AddItem( &g_arenaservers.menu, (void*) &g_arenaservers.showfull);\n\tMenu_AddItem( &g_arenaservers.menu, (void*) &g_arenaservers.showempty );\n\n\tMenu_AddItem( &g_arenaservers.menu, (void*) &g_arenaservers.mappic );\n\tMenu_AddItem( &g_arenaservers.menu, (void*) &g_arenaservers.list );\n\tMenu_AddItem( &g_arenaservers.menu, (void*) &g_arenaservers.status );\n\tMenu_AddItem( &g_arenaservers.menu, (void*) &g_arenaservers.statusbar );\n\tMenu_AddItem( &g_arenaservers.menu, (void*) &g_arenaservers.arrows );\n\tMenu_AddItem( &g_arenaservers.menu, (void*) &g_arenaservers.up );\n\tMenu_AddItem( &g_arenaservers.menu, (void*) &g_arenaservers.down );\n\n\tMenu_AddItem( &g_arenaservers.menu, (void*) &g_arenaservers.remove );\n\tMenu_AddItem( &g_arenaservers.menu, (void*) &g_arenaservers.back );\n\tMenu_AddItem( &g_arenaservers.menu, (void*) &g_arenaservers.specify );\n\tMenu_AddItem( &g_arenaservers.menu, (void*) &g_arenaservers.refresh );\n\tMenu_AddItem( &g_arenaservers.menu, (void*) &g_arenaservers.create );\n\tMenu_AddItem( &g_arenaservers.menu, (void*) &g_arenaservers.go );\n\n\tMenu_AddItem( &g_arenaservers.menu, (void*) &g_arenaservers.punkbuster );\n\tMenu_AddItem( &g_arenaservers.menu, (void*) &g_arenaservers.pblogo );\n\t\n\tArenaServers_LoadFavorites();\n\n\tg_servertype = Com_Clamp( 0, 3, ui_browserMaster.integer );\n\t// hack to get rid of MPlayer stuff\n\tvalue = g_servertype;\n\tif (value >= 1)\n\t\tvalue--;\n\tg_arenaservers.master.curvalue = value;\n\n\tg_gametype = Com_Clamp( 0, 4, ui_browserGameType.integer );\n\tg_arenaservers.gametype.curvalue = g_gametype;\n\n\tg_sortkey = Com_Clamp( 0, 4, ui_browserSortKey.integer );\n\tg_arenaservers.sortkey.curvalue = g_sortkey;\n\n\tg_fullservers = Com_Clamp( 0, 1, ui_browserShowFull.integer );\n\tg_arenaservers.showfull.curvalue = g_fullservers;\n\n\tg_emptyservers = Com_Clamp( 0, 1, ui_browserShowEmpty.integer );\n\tg_arenaservers.showempty.curvalue = g_emptyservers;\n\t\n\tg_arenaservers.punkbuster.curvalue = Com_Clamp( 0, 1, trap_Cvar_VariableValue( \"cl_punkbuster\" ) );\n\n\t// force to initial state and refresh\n\ttype = g_servertype;\n\tg_servertype = -1;\n\tArenaServers_SetType( type );\n\n\ttrap_Cvar_Register(NULL, \"debug_protocol\", \"\", 0 );\n}\n\n\n/*\n=================\nArenaServers_Cache\n=================\n*/\nvoid ArenaServers_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( ART_BACK0 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK1 );\n\ttrap_R_RegisterShaderNoMip( ART_CREATE0 );\n\ttrap_R_RegisterShaderNoMip( ART_CREATE1 );\n\ttrap_R_RegisterShaderNoMip( ART_SPECIFY0 );\n\ttrap_R_RegisterShaderNoMip( ART_SPECIFY1 );\n\ttrap_R_RegisterShaderNoMip( ART_REFRESH0 );\n\ttrap_R_RegisterShaderNoMip( ART_REFRESH1 );\n\ttrap_R_RegisterShaderNoMip( ART_CONNECT0 );\n\ttrap_R_RegisterShaderNoMip( ART_CONNECT1 );\n\ttrap_R_RegisterShaderNoMip( ART_ARROWS0  );\n\ttrap_R_RegisterShaderNoMip( ART_ARROWS_UP );\n\ttrap_R_RegisterShaderNoMip( ART_ARROWS_DOWN );\n\ttrap_R_RegisterShaderNoMip( ART_UNKNOWNMAP );\n\ttrap_R_RegisterShaderNoMip( ART_PUNKBUSTER );\n}\n\n\n/*\n=================\nUI_ArenaServersMenu\n=================\n*/\nvoid UI_ArenaServersMenu( void ) {\n\tArenaServers_MenuInit();\n\tUI_PushMenu( &g_arenaservers.menu );\n}\t\t\t\t\t\t  \n"
  },
  {
    "path": "code/q3_ui/ui_setup.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=======================================================================\n\nSETUP MENU\n\n=======================================================================\n*/\n\n\n#include \"ui_local.h\"\n\n\n#define SETUP_MENU_VERTICAL_SPACING\t\t34\n\n#define ART_BACK0\t\t\"menu/art/back_0\"\n#define ART_BACK1\t\t\"menu/art/back_1\"\t\n#define ART_FRAMEL\t\t\"menu/art/frame2_l\"\n#define ART_FRAMER\t\t\"menu/art/frame1_r\"\n\n#define ID_CUSTOMIZEPLAYER\t\t10\n#define ID_CUSTOMIZECONTROLS\t11\n#define ID_SYSTEMCONFIG\t\t\t12\n#define ID_GAME\t\t\t\t\t13\n#define ID_CDKEY\t\t\t\t14\n#define ID_LOAD\t\t\t\t\t15\n#define ID_SAVE\t\t\t\t\t16\n#define ID_DEFAULTS\t\t\t\t17\n#define ID_BACK\t\t\t\t\t18\n\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n\n\tmenutext_s\t\tbanner;\n\tmenubitmap_s\tframel;\n\tmenubitmap_s\tframer;\n\tmenutext_s\t\tsetupplayer;\n\tmenutext_s\t\tsetupcontrols;\n\tmenutext_s\t\tsetupsystem;\n\tmenutext_s\t\tgame;\n\tmenutext_s\t\tcdkey;\n//\tmenutext_s\t\tload;\n//\tmenutext_s\t\tsave;\n\tmenutext_s\t\tdefaults;\n\tmenubitmap_s\tback;\n} setupMenuInfo_t;\n\nstatic setupMenuInfo_t\tsetupMenuInfo;\n\n\n/*\n=================\nSetup_ResetDefaults_Action\n=================\n*/\nstatic void Setup_ResetDefaults_Action( qboolean result ) {\n\tif( !result ) {\n\t\treturn;\n\t}\n\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"exec default.cfg\\n\");\n\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"cvar_restart\\n\");\n\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"vid_restart\\n\" );\n}\n\n\n/*\n=================\nSetup_ResetDefaults_Draw\n=================\n*/\nstatic void Setup_ResetDefaults_Draw( void ) {\n\tUI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 0, \"WARNING: This will reset *ALL*\", UI_CENTER|UI_SMALLFONT, color_yellow );\n\tUI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 1, \"options to their default values.\", UI_CENTER|UI_SMALLFONT, color_yellow );\n}\n\n\n/*\n===============\nUI_SetupMenu_Event\n===============\n*/\nstatic void UI_SetupMenu_Event( void *ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tswitch( ((menucommon_s*)ptr)->id ) {\n\tcase ID_CUSTOMIZEPLAYER:\n\t\tUI_PlayerSettingsMenu();\n\t\tbreak;\n\n\tcase ID_CUSTOMIZECONTROLS:\n\t\tUI_ControlsMenu();\n\t\tbreak;\n\n\tcase ID_SYSTEMCONFIG:\n\t\tUI_GraphicsOptionsMenu();\n\t\tbreak;\n\n\tcase ID_GAME:\n\t\tUI_PreferencesMenu();\n\t\tbreak;\n\n\tcase ID_CDKEY:\n\t\tUI_CDKeyMenu();\n\t\tbreak;\n\n//\tcase ID_LOAD:\n//\t\tUI_LoadConfigMenu();\n//\t\tbreak;\n\n//\tcase ID_SAVE:\n//\t\tUI_SaveConfigMenu();\n//\t\tbreak;\n\n\tcase ID_DEFAULTS:\n\t\tUI_ConfirmMenu( \"SET TO DEFAULTS?\", Setup_ResetDefaults_Draw, Setup_ResetDefaults_Action );\n\t\tbreak;\n\n\tcase ID_BACK:\n\t\tUI_PopMenu();\n\t\tbreak;\n\t}\n}\n\n\n/*\n===============\nUI_SetupMenu_Init\n===============\n*/\nstatic void UI_SetupMenu_Init( void ) {\n\tint\t\t\t\ty;\n\n\tUI_SetupMenu_Cache();\n\n\tmemset( &setupMenuInfo, 0, sizeof(setupMenuInfo) );\n\tsetupMenuInfo.menu.wrapAround = qtrue;\n\tsetupMenuInfo.menu.fullscreen = qtrue;\n\n\tsetupMenuInfo.banner.generic.type\t\t\t\t= MTYPE_BTEXT;\n\tsetupMenuInfo.banner.generic.x\t\t\t\t\t= 320;\n\tsetupMenuInfo.banner.generic.y\t\t\t\t\t= 16;\n\tsetupMenuInfo.banner.string\t\t\t\t\t\t= \"SETUP\";\n\tsetupMenuInfo.banner.color\t\t\t\t\t\t= color_white;\n\tsetupMenuInfo.banner.style\t\t\t\t\t\t= UI_CENTER;\n\n\tsetupMenuInfo.framel.generic.type\t\t\t\t= MTYPE_BITMAP;\n\tsetupMenuInfo.framel.generic.name\t\t\t\t= ART_FRAMEL;\n\tsetupMenuInfo.framel.generic.flags\t\t\t\t= QMF_INACTIVE;\n\tsetupMenuInfo.framel.generic.x\t\t\t\t\t= 0;  \n\tsetupMenuInfo.framel.generic.y\t\t\t\t\t= 78;\n\tsetupMenuInfo.framel.width  \t\t\t\t\t= 256;\n\tsetupMenuInfo.framel.height  \t\t\t\t\t= 329;\n\n\tsetupMenuInfo.framer.generic.type\t\t\t\t= MTYPE_BITMAP;\n\tsetupMenuInfo.framer.generic.name\t\t\t\t= ART_FRAMER;\n\tsetupMenuInfo.framer.generic.flags\t\t\t\t= QMF_INACTIVE;\n\tsetupMenuInfo.framer.generic.x\t\t\t\t\t= 376;\n\tsetupMenuInfo.framer.generic.y\t\t\t\t\t= 76;\n\tsetupMenuInfo.framer.width  \t\t\t\t\t= 256;\n\tsetupMenuInfo.framer.height  \t\t\t\t\t= 334;\n\n\ty = 134;\n\tsetupMenuInfo.setupplayer.generic.type\t\t\t= MTYPE_PTEXT;\n\tsetupMenuInfo.setupplayer.generic.flags\t\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\tsetupMenuInfo.setupplayer.generic.x\t\t\t\t= 320;\n\tsetupMenuInfo.setupplayer.generic.y\t\t\t\t= y;\n\tsetupMenuInfo.setupplayer.generic.id\t\t\t= ID_CUSTOMIZEPLAYER;\n\tsetupMenuInfo.setupplayer.generic.callback\t\t= UI_SetupMenu_Event; \n\tsetupMenuInfo.setupplayer.string\t\t\t\t= \"PLAYER\";\n\tsetupMenuInfo.setupplayer.color\t\t\t\t\t= color_red;\n\tsetupMenuInfo.setupplayer.style\t\t\t\t\t= UI_CENTER;\n\n\ty += SETUP_MENU_VERTICAL_SPACING;\n\tsetupMenuInfo.setupcontrols.generic.type\t\t= MTYPE_PTEXT;\n\tsetupMenuInfo.setupcontrols.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\tsetupMenuInfo.setupcontrols.generic.x\t\t\t= 320;\n\tsetupMenuInfo.setupcontrols.generic.y\t\t\t= y;\n\tsetupMenuInfo.setupcontrols.generic.id\t\t\t= ID_CUSTOMIZECONTROLS;\n\tsetupMenuInfo.setupcontrols.generic.callback\t= UI_SetupMenu_Event; \n\tsetupMenuInfo.setupcontrols.string\t\t\t\t= \"CONTROLS\";\n\tsetupMenuInfo.setupcontrols.color\t\t\t\t= color_red;\n\tsetupMenuInfo.setupcontrols.style\t\t\t\t= UI_CENTER;\n\n\ty += SETUP_MENU_VERTICAL_SPACING;\n\tsetupMenuInfo.setupsystem.generic.type\t\t\t= MTYPE_PTEXT;\n\tsetupMenuInfo.setupsystem.generic.flags\t\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\tsetupMenuInfo.setupsystem.generic.x\t\t\t\t= 320;\n\tsetupMenuInfo.setupsystem.generic.y\t\t\t\t= y;\n\tsetupMenuInfo.setupsystem.generic.id\t\t\t= ID_SYSTEMCONFIG;\n\tsetupMenuInfo.setupsystem.generic.callback\t\t= UI_SetupMenu_Event; \n\tsetupMenuInfo.setupsystem.string\t\t\t\t= \"SYSTEM\";\n\tsetupMenuInfo.setupsystem.color\t\t\t\t\t= color_red;\n\tsetupMenuInfo.setupsystem.style\t\t\t\t\t= UI_CENTER;\n\n\ty += SETUP_MENU_VERTICAL_SPACING;\n\tsetupMenuInfo.game.generic.type\t\t\t\t\t= MTYPE_PTEXT;\n\tsetupMenuInfo.game.generic.flags\t\t\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\tsetupMenuInfo.game.generic.x\t\t\t\t\t= 320;\n\tsetupMenuInfo.game.generic.y\t\t\t\t\t= y;\n\tsetupMenuInfo.game.generic.id\t\t\t\t\t= ID_GAME;\n\tsetupMenuInfo.game.generic.callback\t\t\t\t= UI_SetupMenu_Event; \n\tsetupMenuInfo.game.string\t\t\t\t\t\t= \"GAME OPTIONS\";\n\tsetupMenuInfo.game.color\t\t\t\t\t\t= color_red;\n\tsetupMenuInfo.game.style\t\t\t\t\t\t= UI_CENTER;\n\n\ty += SETUP_MENU_VERTICAL_SPACING;\n\tsetupMenuInfo.cdkey.generic.type\t\t\t\t= MTYPE_PTEXT;\n\tsetupMenuInfo.cdkey.generic.flags\t\t\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\tsetupMenuInfo.cdkey.generic.x\t\t\t\t\t= 320;\n\tsetupMenuInfo.cdkey.generic.y\t\t\t\t\t= y;\n\tsetupMenuInfo.cdkey.generic.id\t\t\t\t\t= ID_CDKEY;\n\tsetupMenuInfo.cdkey.generic.callback\t\t\t= UI_SetupMenu_Event; \n\tsetupMenuInfo.cdkey.string\t\t\t\t\t\t= \"CD Key\";\n\tsetupMenuInfo.cdkey.color\t\t\t\t\t\t= color_red;\n\tsetupMenuInfo.cdkey.style\t\t\t\t\t\t= UI_CENTER;\n\n\tif( !trap_Cvar_VariableValue( \"cl_paused\" ) ) {\n#if 0\n\t\ty += SETUP_MENU_VERTICAL_SPACING;\n\t\tsetupMenuInfo.load.generic.type\t\t\t\t\t= MTYPE_PTEXT;\n\t\tsetupMenuInfo.load.generic.flags\t\t\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\t\tsetupMenuInfo.load.generic.x\t\t\t\t\t= 320;\n\t\tsetupMenuInfo.load.generic.y\t\t\t\t\t= y;\n\t\tsetupMenuInfo.load.generic.id\t\t\t\t\t= ID_LOAD;\n\t\tsetupMenuInfo.load.generic.callback\t\t\t\t= UI_SetupMenu_Event; \n\t\tsetupMenuInfo.load.string\t\t\t\t\t\t= \"LOAD\";\n\t\tsetupMenuInfo.load.color\t\t\t\t\t\t= color_red;\n\t\tsetupMenuInfo.load.style\t\t\t\t\t\t= UI_CENTER;\n\n\t\ty += SETUP_MENU_VERTICAL_SPACING;\n\t\tsetupMenuInfo.save.generic.type\t\t\t\t\t= MTYPE_PTEXT;\n\t\tsetupMenuInfo.save.generic.flags\t\t\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\t\tsetupMenuInfo.save.generic.x\t\t\t\t\t= 320;\n\t\tsetupMenuInfo.save.generic.y\t\t\t\t\t= y;\n\t\tsetupMenuInfo.save.generic.id\t\t\t\t\t= ID_SAVE;\n\t\tsetupMenuInfo.save.generic.callback\t\t\t\t= UI_SetupMenu_Event; \n\t\tsetupMenuInfo.save.string\t\t\t\t\t\t= \"SAVE\";\n\t\tsetupMenuInfo.save.color\t\t\t\t\t\t= color_red;\n\t\tsetupMenuInfo.save.style\t\t\t\t\t\t= UI_CENTER;\n#endif\n\n\t\ty += SETUP_MENU_VERTICAL_SPACING;\n\t\tsetupMenuInfo.defaults.generic.type\t\t\t\t= MTYPE_PTEXT;\n\t\tsetupMenuInfo.defaults.generic.flags\t\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\t\tsetupMenuInfo.defaults.generic.x\t\t\t\t= 320;\n\t\tsetupMenuInfo.defaults.generic.y\t\t\t\t= y;\n\t\tsetupMenuInfo.defaults.generic.id\t\t\t\t= ID_DEFAULTS;\n\t\tsetupMenuInfo.defaults.generic.callback\t\t\t= UI_SetupMenu_Event; \n\t\tsetupMenuInfo.defaults.string\t\t\t\t\t= \"DEFAULTS\";\n\t\tsetupMenuInfo.defaults.color\t\t\t\t\t= color_red;\n\t\tsetupMenuInfo.defaults.style\t\t\t\t\t= UI_CENTER;\n\t}\n\n\tsetupMenuInfo.back.generic.type\t\t\t\t\t= MTYPE_BITMAP;\n\tsetupMenuInfo.back.generic.name\t\t\t\t\t= ART_BACK0;\n\tsetupMenuInfo.back.generic.flags\t\t\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tsetupMenuInfo.back.generic.id\t\t\t\t\t= ID_BACK;\n\tsetupMenuInfo.back.generic.callback\t\t\t\t= UI_SetupMenu_Event;\n\tsetupMenuInfo.back.generic.x\t\t\t\t\t= 0;\n\tsetupMenuInfo.back.generic.y\t\t\t\t\t= 480-64;\n\tsetupMenuInfo.back.width\t\t\t\t\t\t= 128;\n\tsetupMenuInfo.back.height\t\t\t\t\t\t= 64;\n\tsetupMenuInfo.back.focuspic\t\t\t\t\t\t= ART_BACK1;\n\n\tMenu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.banner );\n\tMenu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.framel );\n\tMenu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.framer );\n\tMenu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.setupplayer );\n\tMenu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.setupcontrols );\n\tMenu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.setupsystem );\n\tMenu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.game );\n\tMenu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.cdkey );\n//\tMenu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.load );\n//\tMenu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.save );\n\tif( !trap_Cvar_VariableValue( \"cl_paused\" ) ) {\n\t\tMenu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.defaults );\n\t}\n\tMenu_AddItem( &setupMenuInfo.menu, &setupMenuInfo.back );\n}\n\n\n/*\n=================\nUI_SetupMenu_Cache\n=================\n*/\nvoid UI_SetupMenu_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( ART_BACK0 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK1 );\n\ttrap_R_RegisterShaderNoMip( ART_FRAMEL );\n\ttrap_R_RegisterShaderNoMip( ART_FRAMER );\n}\n\n\n/*\n===============\nUI_SetupMenu\n===============\n*/\nvoid UI_SetupMenu( void ) {\n\tUI_SetupMenu_Init();\n\tUI_PushMenu( &setupMenuInfo.menu );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_signup.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n//\n// ui_signup.c\n//\n\n#include \"ui_local.h\"\n\n\n#define SIGNUP_FRAME\t\t\"menu/art/cut_frame\"\n\n#define ID_NAME\t\t\t100\n#define ID_NAME_BOX\t\t101\n#define ID_PASSWORD\t\t102\n#define ID_PASSWORD_BOX\t103\n#define ID_AGAIN\t\t104\n#define ID_AGAIN_BOX\t105\n#define ID_EMAIL\t\t106\n#define ID_EMAIL_BOX\t107\n#define ID_SIGNUP\t\t108\n#define ID_CANCEL\t\t109\n\n\ntypedef struct\n{\n\tmenuframework_s\tmenu;\n\tmenubitmap_s\tframe;\n\tmenutext_s\t\tname;\n\tmenufield_s\t\tname_box;\n\tmenutext_s\t\tpassword;\n\tmenufield_s\t\tpassword_box;\n\tmenutext_s\t\tagain;\n\tmenufield_s\t\tagain_box;\n\tmenutext_s\t\temail;\n\tmenufield_s\t\temail_box;\n\tmenutext_s\t\tsignup;\n\tmenutext_s\t\tcancel;\n} signup_t;\n\nstatic signup_t\ts_signup;\n\nstatic menuframework_s\ts_signup_menu;\nstatic menuaction_s\t\ts_signup_signup;\nstatic menuaction_s\t\ts_signup_cancel;\n\nstatic vec4_t s_signup_color_prompt  = {1.00, 0.43, 0.00, 1.00};\n\n/*\n===============\nSignup_MenuEvent\n===============\n*/\nstatic void Signup_MenuEvent( void* ptr, int event ) {\n\t//char\tcmd[1024];\n\t\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tswitch( ((menucommon_s*)ptr)->id ) {\n\tcase ID_SIGNUP:\n\t\tif( strcmp(s_signup.password_box.field.buffer, \n\t\t\ts_signup.again_box.field.buffer) != 0 )\n\t\t{\n\t\t\t// GRANK_FIXME - password mismatch\n\t\t\tbreak;\n\t\t}\n\t\t// set name\n\t\t//trap_Cvar_Set( \"name\", s_signup.name_box.field.buffer );\n\t\t/*\n\t\ttrap_Cvar_Set( \"rank_name\", s_signup.name_box.field.buffer );\n\t\ttrap_Cvar_Set( \"rank_pwd\", s_signup.password_box.field.buffer );\n\t\t*/\n\n\t\t// create account\n\t\t/*\n\t\tsprintf( cmd, \"cmd rank_create \\\"%s\\\" \\\"%s\\\" \\\"%s\\\"\\n\", \n\t\t\ts_signup.name_box.field.buffer, \n\t\t\ts_signup.password_box.field.buffer, \n\t\t\ts_signup.email_box.field.buffer );\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, cmd );\n\t\t*/\n\t\ttrap_CL_UI_RankUserCreate(\n\t\t\ts_signup.name_box.field.buffer, \n\t\t\ts_signup.password_box.field.buffer, \n\t\t\ts_signup.email_box.field.buffer );\n\n\t\tUI_ForceMenuOff();\n\t\tbreak;\n\t\t\n\tcase ID_CANCEL:\n\t\tUI_PopMenu();\n\t\tbreak;\n\t}\n}\n\n/*\n===============\nSignup_MenuInit\n===============\n*/\nvoid Signup_MenuInit( void ) {\n\tgrank_status_t\tstatus;\n\tint\t\t\t\ty;\n\n\tmemset( &s_signup, 0, sizeof(s_signup) );\n\n\tSignup_Cache();\n\n\ts_signup.menu.wrapAround = qtrue;\n\ts_signup.menu.fullscreen = qfalse;\n\n\ts_signup.frame.generic.type\t\t\t\t= MTYPE_BITMAP;\n\ts_signup.frame.generic.flags\t\t\t= QMF_INACTIVE;\n\ts_signup.frame.generic.name\t\t\t\t= SIGNUP_FRAME;\n\ts_signup.frame.generic.x\t\t\t\t= 142; //320-233;\n\ts_signup.frame.generic.y\t\t\t\t= 118; //240-166;\n\ts_signup.frame.width\t\t\t\t\t= 359; //466;\n\ts_signup.frame.height\t\t\t\t\t= 256; //332;\n\n\ty = 194;\n\n\ts_signup.name.generic.type\t\t\t\t= MTYPE_PTEXT;\n\ts_signup.name.generic.flags\t\t\t\t= QMF_RIGHT_JUSTIFY|QMF_INACTIVE;\n\ts_signup.name.generic.id\t\t\t\t= ID_NAME;\n\ts_signup.name.generic.x\t\t\t\t\t= 310;\n\ts_signup.name.generic.y\t\t\t\t\t= y;\n\ts_signup.name.string\t\t\t\t\t= \"NAME\";\n\ts_signup.name.style\t\t\t\t\t\t= UI_RIGHT|UI_SMALLFONT;\n\ts_signup.name.color\t\t\t\t\t\t= s_signup_color_prompt;\n\n\ts_signup.name_box.generic.type\t\t\t= MTYPE_FIELD;\n\ts_signup.name_box.generic.ownerdraw\t\t= Rankings_DrawName;\n\ts_signup.name_box.generic.name\t\t\t= \"\";\n\ts_signup.name_box.generic.flags\t\t\t= 0;\n\ts_signup.name_box.generic.x\t\t\t\t= 330;\n\ts_signup.name_box.generic.y\t\t\t\t= y;\n\ts_signup.name_box.field.widthInChars\t= 16;\n\ts_signup.name_box.field.maxchars\t\t= 16;\n\ty += 20;\n\t\n\ts_signup.password.generic.type\t\t\t= MTYPE_PTEXT;\n\ts_signup.password.generic.flags\t\t\t= QMF_RIGHT_JUSTIFY|QMF_INACTIVE;\n\ts_signup.password.generic.id\t\t\t= ID_PASSWORD;\n\ts_signup.password.generic.x\t\t\t\t= 310;\n\ts_signup.password.generic.y\t\t\t\t= y;\n\ts_signup.password.string\t\t\t\t= \"PASSWORD\";\n\ts_signup.password.style\t\t\t\t\t= UI_RIGHT|UI_SMALLFONT;\n\ts_signup.password.color\t\t\t\t\t= s_signup_color_prompt;\n\n\ts_signup.password_box.generic.type\t\t\t= MTYPE_FIELD;\n\ts_signup.password_box.generic.ownerdraw\t\t= Rankings_DrawPassword;\n\ts_signup.password_box.generic.name\t\t\t= \"\";\n\ts_signup.password_box.generic.flags\t\t\t= 0;\n\ts_signup.password_box.generic.x\t\t\t\t= 330;\n\ts_signup.password_box.generic.y\t\t\t\t= y;\n\ts_signup.password_box.field.widthInChars\t= 16;\n\ts_signup.password_box.field.maxchars\t\t= 16;\n\ty += 20;\n\n\ts_signup.again.generic.type\t\t\t\t= MTYPE_PTEXT;\n\ts_signup.again.generic.flags\t\t\t= QMF_RIGHT_JUSTIFY|QMF_INACTIVE;\n\ts_signup.again.generic.id\t\t\t\t= ID_AGAIN;\n\ts_signup.again.generic.x\t\t\t\t= 310;\n\ts_signup.again.generic.y\t\t\t\t= y;\n\ts_signup.again.string\t\t\t\t\t= \"(AGAIN)\";\n\ts_signup.again.style\t\t\t\t\t= UI_RIGHT|UI_SMALLFONT;\n\ts_signup.again.color\t\t\t\t\t= s_signup_color_prompt;\n\n\ts_signup.again_box.generic.type\t\t\t= MTYPE_FIELD;\n\ts_signup.again_box.generic.ownerdraw\t= Rankings_DrawPassword;\n\ts_signup.again_box.generic.name\t\t\t= \"\";\n\ts_signup.again_box.generic.flags\t\t= 0;\n\ts_signup.again_box.generic.x\t\t\t= 330;\n\ts_signup.again_box.generic.y\t\t\t= y;\n\ts_signup.again_box.field.widthInChars\t= 16;\n\ts_signup.again_box.field.maxchars\t\t= 16;\n\ty += 20;\n\n\ts_signup.email.generic.type\t\t\t\t= MTYPE_PTEXT;\n\ts_signup.email.generic.flags\t\t\t= QMF_RIGHT_JUSTIFY|QMF_INACTIVE;\n\ts_signup.email.generic.id\t\t\t\t= ID_EMAIL;\n\ts_signup.email.generic.x\t\t\t\t= 310;\n\ts_signup.email.generic.y\t\t\t\t= y;\n\ts_signup.email.string\t\t\t\t\t= \"EMAIL\";\n\ts_signup.email.style\t\t\t\t\t= UI_RIGHT|UI_SMALLFONT;\n\ts_signup.email.color\t\t\t\t\t= s_signup_color_prompt;\n\n\ts_signup.email_box.generic.type\t\t\t= MTYPE_FIELD;\n\ts_signup.email_box.generic.ownerdraw\t= Rankings_DrawText;\n\ts_signup.email_box.generic.name\t\t\t= \"\";\n\ts_signup.email_box.generic.flags\t\t= 0;\n\ts_signup.email_box.generic.x\t\t\t= 330;\n\ts_signup.email_box.generic.y\t\t\t= y;\n\ts_signup.email_box.field.widthInChars\t= 16;\n\ts_signup.email_box.field.maxchars\t\t= MAX_EDIT_LINE;\n\ty += 40;\n\n\ts_signup.signup.generic.type\t\t\t= MTYPE_PTEXT;\n\ts_signup.signup.generic.flags\t\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_signup.signup.generic.id\t\t\t\t= ID_SIGNUP;\n\ts_signup.signup.generic.callback\t\t= Signup_MenuEvent;\n\ts_signup.signup.generic.x\t\t\t\t= 310;\n\ts_signup.signup.generic.y\t\t\t\t= y;\n\ts_signup.signup.string\t\t\t\t\t= \"SIGN UP\";\n\ts_signup.signup.style\t\t\t\t\t= UI_RIGHT|UI_SMALLFONT;\n\ts_signup.signup.color\t\t\t\t\t= colorRed;\n\n\ts_signup.cancel.generic.type\t\t\t= MTYPE_PTEXT;\n\ts_signup.cancel.generic.flags\t\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_signup.cancel.generic.id\t\t\t\t= ID_CANCEL;\n\ts_signup.cancel.generic.callback\t\t= Signup_MenuEvent;\n\ts_signup.cancel.generic.x\t\t\t\t= 330;\n\ts_signup.cancel.generic.y\t\t\t\t= y;\n\ts_signup.cancel.string\t\t\t\t\t= \"CANCEL\";\n\ts_signup.cancel.style\t\t\t\t\t= UI_LEFT|UI_SMALLFONT;\n\ts_signup.cancel.color\t\t\t\t\t= colorRed;\n\ty += 20;\n\n\tstatus = (grank_status_t)trap_Cvar_VariableValue(\"client_status\");\n\tif( (status != QGR_STATUS_NEW) && (status != QGR_STATUS_SPECTATOR) )\n\t{\n\t\ts_signup.name_box.generic.flags |= QMF_INACTIVE;\t\n\t\ts_signup.password_box.generic.flags |= QMF_INACTIVE;\t\n\t\ts_signup.again_box.generic.flags |= QMF_INACTIVE;\t\n\t\ts_signup.email_box.generic.flags |= QMF_INACTIVE;\t\n\t\ts_signup.signup.generic.flags |= QMF_INACTIVE;\n\t\t\n\t\ts_signup.signup.color = colorMdGrey;\n\t}\n\t\n\tMenu_AddItem( &s_signup.menu, (void*) &s_signup.frame );\n\tMenu_AddItem( &s_signup.menu, (void*) &s_signup.name );\n\tMenu_AddItem( &s_signup.menu, (void*) &s_signup.name_box );\n\tMenu_AddItem( &s_signup.menu, (void*) &s_signup.password );\n\tMenu_AddItem( &s_signup.menu, (void*) &s_signup.password_box );\n\tMenu_AddItem( &s_signup.menu, (void*) &s_signup.again );\n\tMenu_AddItem( &s_signup.menu, (void*) &s_signup.again_box );\n\tMenu_AddItem( &s_signup.menu, (void*) &s_signup.email );\n\tMenu_AddItem( &s_signup.menu, (void*) &s_signup.email_box );\n\tMenu_AddItem( &s_signup.menu, (void*) &s_signup.signup );\n\tMenu_AddItem( &s_signup.menu, (void*) &s_signup.cancel );\n}\n\n\n/*\n===============\nSignup_Cache\n===============\n*/\nvoid Signup_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( SIGNUP_FRAME );\n}\n\n\n/*\n===============\nUI_SignupMenu\n===============\n*/\nvoid UI_SignupMenu( void ) {\n\tSignup_MenuInit();\n\tUI_PushMenu ( &s_signup.menu );\n}\n\n\n"
  },
  {
    "path": "code/q3_ui/ui_sound.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=======================================================================\n\nSOUND OPTIONS MENU\n\n=======================================================================\n*/\n\n#include \"ui_local.h\"\n\n\n#define ART_FRAMEL\t\t\t\"menu/art/frame2_l\"\n#define ART_FRAMER\t\t\t\"menu/art/frame1_r\"\n#define ART_BACK0\t\t\t\"menu/art/back_0\"\n#define ART_BACK1\t\t\t\"menu/art/back_1\"\n\n#define ID_GRAPHICS\t\t\t10\n#define ID_DISPLAY\t\t\t11\n#define ID_SOUND\t\t\t12\n#define ID_NETWORK\t\t\t13\n#define ID_EFFECTSVOLUME\t14\n#define ID_MUSICVOLUME\t\t15\n#define ID_QUALITY\t\t\t16\n//#define ID_A3D\t\t\t\t17\n#define ID_BACK\t\t\t\t18\n\n\nstatic const char *quality_items[] = {\n\t\"Low\", \"High\", 0\n};\n\ntypedef struct {\n\tmenuframework_s\t\tmenu;\n\n\tmenutext_s\t\t\tbanner;\n\tmenubitmap_s\t\tframel;\n\tmenubitmap_s\t\tframer;\n\n\tmenutext_s\t\t\tgraphics;\n\tmenutext_s\t\t\tdisplay;\n\tmenutext_s\t\t\tsound;\n\tmenutext_s\t\t\tnetwork;\n\n\tmenuslider_s\t\tsfxvolume;\n\tmenuslider_s\t\tmusicvolume;\n\tmenulist_s\t\t\tquality;\n//\tmenuradiobutton_s\ta3d;\n\n\tmenubitmap_s\t\tback;\n} soundOptionsInfo_t;\n\nstatic soundOptionsInfo_t\tsoundOptionsInfo;\n\n\n/*\n=================\nUI_SoundOptionsMenu_Event\n=================\n*/\nstatic void UI_SoundOptionsMenu_Event( void* ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tswitch( ((menucommon_s*)ptr)->id ) {\n\tcase ID_GRAPHICS:\n\t\tUI_PopMenu();\n\t\tUI_GraphicsOptionsMenu();\n\t\tbreak;\n\n\tcase ID_DISPLAY:\n\t\tUI_PopMenu();\n\t\tUI_DisplayOptionsMenu();\n\t\tbreak;\n\n\tcase ID_SOUND:\n\t\tbreak;\n\n\tcase ID_NETWORK:\n\t\tUI_PopMenu();\n\t\tUI_NetworkOptionsMenu();\n\t\tbreak;\n\n\tcase ID_EFFECTSVOLUME:\n\t\ttrap_Cvar_SetValue( \"s_volume\", soundOptionsInfo.sfxvolume.curvalue / 10 );\n\t\tbreak;\n\n\tcase ID_MUSICVOLUME:\n\t\ttrap_Cvar_SetValue( \"s_musicvolume\", soundOptionsInfo.musicvolume.curvalue / 10 );\n\t\tbreak;\n\n\tcase ID_QUALITY:\n\t\tif( soundOptionsInfo.quality.curvalue ) {\n\t\t\ttrap_Cvar_SetValue( \"s_khz\", 22 );\n\t\t\ttrap_Cvar_SetValue( \"s_compression\", 0 );\n\t\t}\n\t\telse {\n\t\t\ttrap_Cvar_SetValue( \"s_khz\", 11 );\n\t\t\ttrap_Cvar_SetValue( \"s_compression\", 1 );\n\t\t}\n\t\tUI_ForceMenuOff();\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"snd_restart\\n\" );\n\t\tbreak;\n/*\n\tcase ID_A3D:\n\t\tif( soundOptionsInfo.a3d.curvalue ) {\n\t\t\ttrap_Cmd_ExecuteText( EXEC_NOW, \"s_enable_a3d\\n\" );\n\t\t}\n\t\telse {\n\t\t\ttrap_Cmd_ExecuteText( EXEC_NOW, \"s_disable_a3d\\n\" );\n\t\t}\n\t\tsoundOptionsInfo.a3d.curvalue = (int)trap_Cvar_VariableValue( \"s_usingA3D\" );\n\t\tbreak;\n*/\n\tcase ID_BACK:\n\t\tUI_PopMenu();\n\t\tbreak;\n\t}\n}\n\n\n/*\n===============\nUI_SoundOptionsMenu_Init\n===============\n*/\nstatic void UI_SoundOptionsMenu_Init( void ) {\n\tint\t\t\t\ty;\n\n\tmemset( &soundOptionsInfo, 0, sizeof(soundOptionsInfo) );\n\n\tUI_SoundOptionsMenu_Cache();\n\tsoundOptionsInfo.menu.wrapAround = qtrue;\n\tsoundOptionsInfo.menu.fullscreen = qtrue;\n\n\tsoundOptionsInfo.banner.generic.type\t\t= MTYPE_BTEXT;\n\tsoundOptionsInfo.banner.generic.flags\t\t= QMF_CENTER_JUSTIFY;\n\tsoundOptionsInfo.banner.generic.x\t\t\t= 320;\n\tsoundOptionsInfo.banner.generic.y\t\t\t= 16;\n\tsoundOptionsInfo.banner.string\t\t\t\t= \"SYSTEM SETUP\";\n\tsoundOptionsInfo.banner.color\t\t\t\t= color_white;\n\tsoundOptionsInfo.banner.style\t\t\t\t= UI_CENTER;\n\n\tsoundOptionsInfo.framel.generic.type\t\t= MTYPE_BITMAP;\n\tsoundOptionsInfo.framel.generic.name\t\t= ART_FRAMEL;\n\tsoundOptionsInfo.framel.generic.flags\t\t= QMF_INACTIVE;\n\tsoundOptionsInfo.framel.generic.x\t\t\t= 0;  \n\tsoundOptionsInfo.framel.generic.y\t\t\t= 78;\n\tsoundOptionsInfo.framel.width\t\t\t\t= 256;\n\tsoundOptionsInfo.framel.height\t\t\t\t= 329;\n\n\tsoundOptionsInfo.framer.generic.type\t\t= MTYPE_BITMAP;\n\tsoundOptionsInfo.framer.generic.name\t\t= ART_FRAMER;\n\tsoundOptionsInfo.framer.generic.flags\t\t= QMF_INACTIVE;\n\tsoundOptionsInfo.framer.generic.x\t\t\t= 376;\n\tsoundOptionsInfo.framer.generic.y\t\t\t= 76;\n\tsoundOptionsInfo.framer.width\t\t\t\t= 256;\n\tsoundOptionsInfo.framer.height\t\t\t\t= 334;\n\n\tsoundOptionsInfo.graphics.generic.type\t\t= MTYPE_PTEXT;\n\tsoundOptionsInfo.graphics.generic.flags\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tsoundOptionsInfo.graphics.generic.id\t\t= ID_GRAPHICS;\n\tsoundOptionsInfo.graphics.generic.callback\t= UI_SoundOptionsMenu_Event;\n\tsoundOptionsInfo.graphics.generic.x\t\t\t= 216;\n\tsoundOptionsInfo.graphics.generic.y\t\t\t= 240 - 2 * PROP_HEIGHT;\n\tsoundOptionsInfo.graphics.string\t\t\t= \"GRAPHICS\";\n\tsoundOptionsInfo.graphics.style\t\t\t\t= UI_RIGHT;\n\tsoundOptionsInfo.graphics.color\t\t\t\t= color_red;\n\n\tsoundOptionsInfo.display.generic.type\t\t= MTYPE_PTEXT;\n\tsoundOptionsInfo.display.generic.flags\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tsoundOptionsInfo.display.generic.id\t\t\t= ID_DISPLAY;\n\tsoundOptionsInfo.display.generic.callback\t= UI_SoundOptionsMenu_Event;\n\tsoundOptionsInfo.display.generic.x\t\t\t= 216;\n\tsoundOptionsInfo.display.generic.y\t\t\t= 240 - PROP_HEIGHT;\n\tsoundOptionsInfo.display.string\t\t\t\t= \"DISPLAY\";\n\tsoundOptionsInfo.display.style\t\t\t\t= UI_RIGHT;\n\tsoundOptionsInfo.display.color\t\t\t\t= color_red;\n\n\tsoundOptionsInfo.sound.generic.type\t\t\t= MTYPE_PTEXT;\n\tsoundOptionsInfo.sound.generic.flags\t\t= QMF_RIGHT_JUSTIFY;\n\tsoundOptionsInfo.sound.generic.id\t\t\t= ID_SOUND;\n\tsoundOptionsInfo.sound.generic.callback\t\t= UI_SoundOptionsMenu_Event;\n\tsoundOptionsInfo.sound.generic.x\t\t\t= 216;\n\tsoundOptionsInfo.sound.generic.y\t\t\t= 240;\n\tsoundOptionsInfo.sound.string\t\t\t\t= \"SOUND\";\n\tsoundOptionsInfo.sound.style\t\t\t\t= UI_RIGHT;\n\tsoundOptionsInfo.sound.color\t\t\t\t= color_red;\n\n\tsoundOptionsInfo.network.generic.type\t\t= MTYPE_PTEXT;\n\tsoundOptionsInfo.network.generic.flags\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tsoundOptionsInfo.network.generic.id\t\t\t= ID_NETWORK;\n\tsoundOptionsInfo.network.generic.callback\t= UI_SoundOptionsMenu_Event;\n\tsoundOptionsInfo.network.generic.x\t\t\t= 216;\n\tsoundOptionsInfo.network.generic.y\t\t\t= 240 + PROP_HEIGHT;\n\tsoundOptionsInfo.network.string\t\t\t\t= \"NETWORK\";\n\tsoundOptionsInfo.network.style\t\t\t\t= UI_RIGHT;\n\tsoundOptionsInfo.network.color\t\t\t\t= color_red;\n\n\ty = 240 - 1.5 * (BIGCHAR_HEIGHT + 2);\n\tsoundOptionsInfo.sfxvolume.generic.type\t\t= MTYPE_SLIDER;\n\tsoundOptionsInfo.sfxvolume.generic.name\t\t= \"Effects Volume:\";\n\tsoundOptionsInfo.sfxvolume.generic.flags\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\tsoundOptionsInfo.sfxvolume.generic.callback\t= UI_SoundOptionsMenu_Event;\n\tsoundOptionsInfo.sfxvolume.generic.id\t\t= ID_EFFECTSVOLUME;\n\tsoundOptionsInfo.sfxvolume.generic.x\t\t= 400;\n\tsoundOptionsInfo.sfxvolume.generic.y\t\t= y;\n\tsoundOptionsInfo.sfxvolume.minvalue\t\t\t= 0;\n\tsoundOptionsInfo.sfxvolume.maxvalue\t\t\t= 10;\n\n\ty += BIGCHAR_HEIGHT+2;\n\tsoundOptionsInfo.musicvolume.generic.type\t\t= MTYPE_SLIDER;\n\tsoundOptionsInfo.musicvolume.generic.name\t\t= \"Music Volume:\";\n\tsoundOptionsInfo.musicvolume.generic.flags\t\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\tsoundOptionsInfo.musicvolume.generic.callback\t= UI_SoundOptionsMenu_Event;\n\tsoundOptionsInfo.musicvolume.generic.id\t\t\t= ID_MUSICVOLUME;\n\tsoundOptionsInfo.musicvolume.generic.x\t\t\t= 400;\n\tsoundOptionsInfo.musicvolume.generic.y\t\t\t= y;\n\tsoundOptionsInfo.musicvolume.minvalue\t\t\t= 0;\n\tsoundOptionsInfo.musicvolume.maxvalue\t\t\t= 10;\n\n\ty += BIGCHAR_HEIGHT+2;\n\tsoundOptionsInfo.quality.generic.type\t\t= MTYPE_SPINCONTROL;\n\tsoundOptionsInfo.quality.generic.name\t\t= \"Sound Quality:\";\n\tsoundOptionsInfo.quality.generic.flags\t\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\tsoundOptionsInfo.quality.generic.callback\t= UI_SoundOptionsMenu_Event;\n\tsoundOptionsInfo.quality.generic.id\t\t\t= ID_QUALITY;\n\tsoundOptionsInfo.quality.generic.x\t\t\t= 400;\n\tsoundOptionsInfo.quality.generic.y\t\t\t= y;\n\tsoundOptionsInfo.quality.itemnames\t\t\t= quality_items;\n/*\n\ty += BIGCHAR_HEIGHT+2;\n\tsoundOptionsInfo.a3d.generic.type\t\t\t= MTYPE_RADIOBUTTON;\n\tsoundOptionsInfo.a3d.generic.name\t\t\t= \"A3D:\";\n\tsoundOptionsInfo.a3d.generic.flags\t\t\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\tsoundOptionsInfo.a3d.generic.callback\t\t= UI_SoundOptionsMenu_Event;\n\tsoundOptionsInfo.a3d.generic.id\t\t\t\t= ID_A3D;\n\tsoundOptionsInfo.a3d.generic.x\t\t\t\t= 400;\n\tsoundOptionsInfo.a3d.generic.y\t\t\t\t= y;\n*/\n\tsoundOptionsInfo.back.generic.type\t\t\t= MTYPE_BITMAP;\n\tsoundOptionsInfo.back.generic.name\t\t\t= ART_BACK0;\n\tsoundOptionsInfo.back.generic.flags\t\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tsoundOptionsInfo.back.generic.callback\t\t= UI_SoundOptionsMenu_Event;\n\tsoundOptionsInfo.back.generic.id\t\t\t= ID_BACK;\n\tsoundOptionsInfo.back.generic.x\t\t\t\t= 0;\n\tsoundOptionsInfo.back.generic.y\t\t\t\t= 480-64;\n\tsoundOptionsInfo.back.width\t\t\t\t\t= 128;\n\tsoundOptionsInfo.back.height\t\t\t\t= 64;\n\tsoundOptionsInfo.back.focuspic\t\t\t\t= ART_BACK1;\n\n\tMenu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.banner );\n\tMenu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.framel );\n\tMenu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.framer );\n\tMenu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.graphics );\n\tMenu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.display );\n\tMenu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.sound );\n\tMenu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.network );\n\tMenu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.sfxvolume );\n\tMenu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.musicvolume );\n\tMenu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.quality );\n//\tMenu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.a3d );\n\tMenu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.back );\n\n\tsoundOptionsInfo.sfxvolume.curvalue = trap_Cvar_VariableValue( \"s_volume\" ) * 10;\n\tsoundOptionsInfo.musicvolume.curvalue = trap_Cvar_VariableValue( \"s_musicvolume\" ) * 10;\n\tsoundOptionsInfo.quality.curvalue = !trap_Cvar_VariableValue( \"s_compression\" );\n//\tsoundOptionsInfo.a3d.curvalue = (int)trap_Cvar_VariableValue( \"s_usingA3D\" );\n}\n\n\n/*\n===============\nUI_SoundOptionsMenu_Cache\n===============\n*/\nvoid UI_SoundOptionsMenu_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( ART_FRAMEL );\n\ttrap_R_RegisterShaderNoMip( ART_FRAMER );\n\ttrap_R_RegisterShaderNoMip( ART_BACK0 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK1 );\n}\n\n\n/*\n===============\nUI_SoundOptionsMenu\n===============\n*/\nvoid UI_SoundOptionsMenu( void ) {\n\tUI_SoundOptionsMenu_Init();\n\tUI_PushMenu( &soundOptionsInfo.menu );\n\tMenu_SetCursorToItem( &soundOptionsInfo.menu, &soundOptionsInfo.sound );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_sparena.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#include \"ui_local.h\"\n\nvoid UI_SPArena_Start( const char *arenaInfo ) {\n\tchar\t*map;\n\tint\t\tlevel;\n\tint\t\tn;\n\tchar\t*txt;\n\n\tn = (int)trap_Cvar_VariableValue( \"sv_maxclients\" );\n\tif ( n < 8 ) {\n\t\ttrap_Cvar_SetValue( \"sv_maxclients\", 8 );\n\t}\n\n\tlevel = atoi( Info_ValueForKey( arenaInfo, \"num\" ) );\n\ttxt = Info_ValueForKey( arenaInfo, \"special\" );\n\tif( txt[0] ) {\n\t\tif( Q_stricmp( txt, \"training\" ) == 0 ) {\n\t\t\tlevel = -4;\n\t\t}\n\t\telse if( Q_stricmp( txt, \"final\" ) == 0 ) {\n\t\t\tlevel = UI_GetNumSPTiers() * ARENAS_PER_TIER;\n\t\t}\n\t}\n\ttrap_Cvar_SetValue( \"ui_spSelection\", level );\n\n\tmap = Info_ValueForKey( arenaInfo, \"map\" );\n\ttrap_Cmd_ExecuteText( EXEC_APPEND, va( \"spmap %s\\n\", map ) );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_specifyleague.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#include \"ui_local.h\"\n\n/*********************************************************************************\n\tSPECIFY SERVER\n*********************************************************************************/\n\n#define MAX_LISTBOXITEMS\t\t128\n#define MAX_LISTBOXWIDTH\t\t40\n#define MAX_LEAGUENAME\t\t\t80\n\n#define SPECIFYLEAGUE_FRAMEL\t\"menu/art/frame2_l\"\n#define SPECIFYLEAGUE_FRAMER\t\"menu/art/frame1_r\"\n#define SPECIFYLEAGUE_BACK0\t\t\"menu/art/back_0\"\n#define SPECIFYLEAGUE_BACK1\t\t\"menu/art/back_1\"\n#define SPECIFYLEAGUE_ARROWS0\t\"menu/art/arrows_vert_0\"\n#define SPECIFYLEAGUE_UP\t\t\"menu/art/arrows_vert_top\"\n#define SPECIFYLEAGUE_DOWN\t\t\"menu/art/arrows_vert_bot\"\n#define GLOBALRANKINGS_LOGO\t\t\"menu/art/gr/grlogo\"\n#define GLOBALRANKINGS_LETTERS\t\"menu/art/gr/grletters\"\n\n#define ID_SPECIFYLEAGUENAME\t100\n#define ID_SPECIFYLEAGUELIST\t101\n#define ID_SPECIFYLEAGUEUP\t\t102\n#define ID_SPECIFYLEAGUEDOWN\t103\n#define ID_SPECIFYLEAGUEBACK\t104\n\nstatic char* specifyleague_artlist[] =\n{\n\tSPECIFYLEAGUE_FRAMEL,\n\tSPECIFYLEAGUE_FRAMER,\n\tSPECIFYLEAGUE_ARROWS0,\t\n\tSPECIFYLEAGUE_UP,\t\n\tSPECIFYLEAGUE_DOWN,\t\n\tSPECIFYLEAGUE_BACK0,\t\n\tSPECIFYLEAGUE_BACK1,\n\tGLOBALRANKINGS_LOGO,\n\tGLOBALRANKINGS_LETTERS,\n\tNULL\n};\n\nstatic char playername[80];\n\ntypedef struct\n{\n\tmenuframework_s\tmenu;\n\tmenutext_s\t\tbanner;\n\tmenubitmap_s\tframel;\n\tmenubitmap_s\tframer;\n\tmenufield_s\t\trankname;\n\tmenulist_s\t\tlist;\n\tmenubitmap_s\tarrows;\n\tmenubitmap_s\tup;\n\tmenubitmap_s\tdown;\n\tmenubitmap_s\tback;\n\tmenubitmap_s\tgrlogo;\n\tmenubitmap_s\tgrletters;\n} specifyleague_t;\n\nstatic specifyleague_t\ts_specifyleague;\n\n\ntypedef struct {\n\tchar\t\t\tbuff[MAX_LISTBOXWIDTH];\n\tchar\t\t\tleaguename[MAX_LEAGUENAME];\n} table_t;\n\ntable_t league_table[MAX_LISTBOXITEMS];\nchar *leaguename_items[MAX_LISTBOXITEMS];\n\n\nstatic void SpecifyLeague_GetList()\n{\n\tint count = 0;\n\tint i;\n\t/* The Player Name has changed. We need to perform another search */\n\tQ_strncpyz( playername,\n\t\ts_specifyleague.rankname.field.buffer, \n\t\tsizeof(playername) );\n\n\tcount = trap_CL_UI_RankGetLeauges( playername );\n\n\tfor(i = 0; i < count; i++)\n\t{\n\t\tchar\ts[MAX_LEAGUENAME];\n\t\tconst char\t*var;\n\t\tvar = va( \"leaguename%i\", i+1 );\n\t\ttrap_Cvar_VariableStringBuffer( var, s, sizeof(s) );\n\t\tQ_strncpyz(league_table[i].leaguename, s, sizeof(league_table[i].leaguename) );\n\t\tQ_strncpyz(league_table[i].buff, league_table[i].leaguename, sizeof(league_table[i].buff) );\n\t}\n\n\ts_specifyleague.list.numitems = count;\n}\n\n/*\n=================\nSpecifyLeague_Event\n=================\n*/\nstatic void SpecifyLeague_Event( void* ptr, int event )\n{\n\tint\t\tid;\n\tid = ((menucommon_s*)ptr)->id;\n\t//if( event != QM_ACTIVATED && id != ID_SPECIFYLEAGUELIST ) {\n\t//\treturn;\n\t//}\n\n\tswitch (id)\n\t{\n\t\tcase ID_SPECIFYLEAGUELIST:\n\t\t\tif( event == QM_GOTFOCUS ) {\n\t\t\t\t//ArenaServers_UpdatePicture();\n\t\t\t}\n\t\tbreak;\n\n\t\tcase ID_SPECIFYLEAGUEUP:\n\t\t\tif( event == QM_ACTIVATED )\n\t\t\t\tScrollList_Key( &s_specifyleague.list, K_UPARROW );\n\t\tbreak;\t\t\n\t\n\t\tcase ID_SPECIFYLEAGUEDOWN:\n\t\t\tif( event == QM_ACTIVATED )\n\t\t\t\tScrollList_Key( &s_specifyleague.list, K_DOWNARROW );\n\t\tbreak;\n\t\t\t\n\t\tcase ID_SPECIFYLEAGUENAME:\n\t\t\tif( (event == QM_LOSTFOCUS) && \n\t\t\t\t(Q_strncmp(playername, \n\t\t\t\t\ts_specifyleague.rankname.field.buffer, \n\t\t\t\t\tstrlen(s_specifyleague.rankname.field.buffer)) != 0))\n\t\t\t{\n\t\t\t\tSpecifyLeague_GetList();\n\t\t\t}\n\t\tbreak;\n\n\t\tcase ID_SPECIFYLEAGUEBACK:\n\t\t\tif( event == QM_ACTIVATED )\n\t\t\t{\n\t\t\t\ttrap_Cvar_Set( \"sv_leagueName\", league_table[s_specifyleague.list.curvalue].leaguename);\n\t\t\t\tUI_PopMenu();\n\t\t\t}\n\t\tbreak;\n\t}\n}\n\n/*\n=================\nSpecifyLeague_MenuInit\n=================\n*/\nvoid SpecifyLeague_MenuInit( void )\n{\n\tint i;\n\t// zero set all our globals\n\tmemset( &s_specifyleague, 0 ,sizeof(specifyleague_t) );\n\n\tSpecifyLeague_Cache();\n\n\ts_specifyleague.menu.wrapAround = qtrue;\n\ts_specifyleague.menu.fullscreen = qtrue;\n\n\ts_specifyleague.banner.generic.type\t = MTYPE_BTEXT;\n\ts_specifyleague.banner.generic.x     = 320;\n\ts_specifyleague.banner.generic.y     = 16;\n\ts_specifyleague.banner.string\t\t = \"CHOOSE LEAGUE\";\n\ts_specifyleague.banner.color  \t\t = color_white;\n\ts_specifyleague.banner.style  \t\t = UI_CENTER;\n\n\ts_specifyleague.framel.generic.type  = MTYPE_BITMAP;\n\ts_specifyleague.framel.generic.name  = SPECIFYLEAGUE_FRAMEL;\n\ts_specifyleague.framel.generic.flags = QMF_INACTIVE;\n\ts_specifyleague.framel.generic.x\t = 0;  \n\ts_specifyleague.framel.generic.y\t = 78;\n\ts_specifyleague.framel.width  \t     = 256;\n\ts_specifyleague.framel.height  \t     = 334;\n\n\ts_specifyleague.framer.generic.type  = MTYPE_BITMAP;\n\ts_specifyleague.framer.generic.name  = SPECIFYLEAGUE_FRAMER;\n\ts_specifyleague.framer.generic.flags = QMF_INACTIVE;\n\ts_specifyleague.framer.generic.x\t = 376;\n\ts_specifyleague.framer.generic.y\t = 76;\n\ts_specifyleague.framer.width  \t     = 256;\n\ts_specifyleague.framer.height  \t     = 334;\n\n\ts_specifyleague.grlogo.generic.type  = MTYPE_BITMAP;\n\ts_specifyleague.grlogo.generic.name  = GLOBALRANKINGS_LOGO;\n\ts_specifyleague.grlogo.generic.flags = QMF_INACTIVE;\n\ts_specifyleague.grlogo.generic.x\t = 0;\n\ts_specifyleague.grlogo.generic.y\t = 0;\n\ts_specifyleague.grlogo.width\t\t = 64;\n\ts_specifyleague.grlogo.height\t\t = 128;\n\n\ts_specifyleague.rankname.generic.type       = MTYPE_FIELD;\n\ts_specifyleague.rankname.generic.name       = \"Player Name:\";\n\ts_specifyleague.rankname.generic.flags      = QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_specifyleague.rankname.generic.callback   = SpecifyLeague_Event;\n\ts_specifyleague.rankname.generic.id\t        = ID_SPECIFYLEAGUENAME;\n\ts_specifyleague.rankname.generic.x\t        = 226;\n\ts_specifyleague.rankname.generic.y\t        = 128;\n\ts_specifyleague.rankname.field.widthInChars = 32;\n\ts_specifyleague.rankname.field.maxchars     = 80;\n\n\ts_specifyleague.list.generic.type\t\t\t= MTYPE_SCROLLLIST;\n\ts_specifyleague.list.generic.flags\t\t\t= QMF_HIGHLIGHT_IF_FOCUS;\n\ts_specifyleague.list.generic.id\t\t\t\t= ID_SPECIFYLEAGUELIST;\n\ts_specifyleague.list.generic.callback\t\t= SpecifyLeague_Event;\n\ts_specifyleague.list.generic.x\t\t\t\t= 160;\n\ts_specifyleague.list.generic.y\t\t\t\t= 200;\n\ts_specifyleague.list.width\t\t\t\t\t= MAX_LISTBOXWIDTH;\n\ts_specifyleague.list.height\t\t\t\t\t= 8;\n\ts_specifyleague.list.itemnames\t\t\t\t= (const char **)leaguename_items;\n\ts_specifyleague.list.numitems               = 0;\n\tfor( i = 0; i < MAX_LISTBOXITEMS; i++ ) {\n\t\tleague_table[i].buff[0] = 0;\n\t\tleague_table[i].leaguename[0] = 0;\n\t\tleaguename_items[i] = league_table[i].buff;\n\t}\n\t\n\ts_specifyleague.arrows.generic.type\t\t\t= MTYPE_BITMAP;\n\ts_specifyleague.arrows.generic.name\t\t\t= SPECIFYLEAGUE_ARROWS0;\n\ts_specifyleague.arrows.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_INACTIVE;\n\ts_specifyleague.arrows.generic.callback\t\t= SpecifyLeague_Event;\n\ts_specifyleague.arrows.generic.x\t\t\t= 512;\n\ts_specifyleague.arrows.generic.y\t\t\t= 240-64+16;\n\ts_specifyleague.arrows.width\t\t\t\t= 64;\n\ts_specifyleague.arrows.height\t\t\t\t= 128;\n\n\ts_specifyleague.up.generic.type\t\t\t\t= MTYPE_BITMAP;\n\ts_specifyleague.up.generic.flags\t\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;\n\ts_specifyleague.up.generic.callback\t\t\t= SpecifyLeague_Event;\n\ts_specifyleague.up.generic.id\t\t\t\t= ID_SPECIFYLEAGUEUP;\n\ts_specifyleague.up.generic.x\t\t\t\t= 512;\n\ts_specifyleague.up.generic.y\t\t\t\t= 240-64+16;\n\ts_specifyleague.up.width\t\t\t\t\t= 64;\n\ts_specifyleague.up.height\t\t\t\t\t= 64;\n\ts_specifyleague.up.focuspic\t\t\t\t\t= SPECIFYLEAGUE_UP;\n\n\ts_specifyleague.down.generic.type\t\t\t= MTYPE_BITMAP;\n\ts_specifyleague.down.generic.flags\t\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_MOUSEONLY;\n\ts_specifyleague.down.generic.callback\t\t= SpecifyLeague_Event;\n\ts_specifyleague.down.generic.id\t\t\t\t= ID_SPECIFYLEAGUEDOWN;\n\ts_specifyleague.down.generic.x\t\t\t\t= 512;\n\ts_specifyleague.down.generic.y\t\t\t\t= 240+16;\n\ts_specifyleague.down.width\t\t\t\t\t= 64;\n\ts_specifyleague.down.height\t\t\t\t\t= 64;\n\ts_specifyleague.down.focuspic\t\t\t\t= SPECIFYLEAGUE_DOWN;\n\n\ts_specifyleague.back.generic.type\t  = MTYPE_BITMAP;\n\ts_specifyleague.back.generic.name     = SPECIFYLEAGUE_BACK0;\n\ts_specifyleague.back.generic.flags    = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_specifyleague.back.generic.callback = SpecifyLeague_Event;\n\ts_specifyleague.back.generic.id\t      = ID_SPECIFYLEAGUEBACK;\n\ts_specifyleague.back.generic.x\t\t  = 0;\n\ts_specifyleague.back.generic.y\t\t  = 480-64;\n\ts_specifyleague.back.width  \t\t  = 128;\n\ts_specifyleague.back.height  \t\t  = 64;\n\ts_specifyleague.back.focuspic         = SPECIFYLEAGUE_BACK1;\n\n\tMenu_AddItem( &s_specifyleague.menu, &s_specifyleague.banner );\n\tMenu_AddItem( &s_specifyleague.menu, &s_specifyleague.framel );\n\tMenu_AddItem( &s_specifyleague.menu, &s_specifyleague.framer );\n\tMenu_AddItem( &s_specifyleague.menu, &s_specifyleague.grlogo );\n\tMenu_AddItem( &s_specifyleague.menu, &s_specifyleague.rankname );\n\tMenu_AddItem( &s_specifyleague.menu, &s_specifyleague.list );\n\tMenu_AddItem( &s_specifyleague.menu, &s_specifyleague.arrows );\n\tMenu_AddItem( &s_specifyleague.menu, &s_specifyleague.up );\n\tMenu_AddItem( &s_specifyleague.menu, &s_specifyleague.down );\n\tMenu_AddItem( &s_specifyleague.menu, &s_specifyleague.back );\n\n\n\t// initialize any menu variables\n\tQ_strncpyz( s_specifyleague.rankname.field.buffer, \n\t\tUI_Cvar_VariableString(\"name\"), \n\t\tsizeof(s_specifyleague.rankname.field.buffer) );\n\n\tQ_strncpyz( playername,\n\t\tUI_Cvar_VariableString(\"name\"), \n\t\tsizeof(playername) );\n\n\tSpecifyLeague_GetList();\n}\n\n/*\n=================\nSpecifyLeague_Cache\n=================\n*/\nvoid SpecifyLeague_Cache( void )\n{\n\tint\ti;\n\n\t// touch all our pics\n\tfor (i=0; ;i++)\n\t{\n\t\tif (!specifyleague_artlist[i])\n\t\t\tbreak;\n\t\ttrap_R_RegisterShaderNoMip(specifyleague_artlist[i]);\n\t}\n}\n\n/*\n=================\nUI_SpecifyLeagueMenu\n=================\n*/\nvoid UI_SpecifyLeagueMenu( void )\n{\n\tSpecifyLeague_MenuInit();\n\tUI_PushMenu( &s_specifyleague.menu );\n}\n\n"
  },
  {
    "path": "code/q3_ui/ui_specifyserver.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#include \"ui_local.h\"\n\n/*********************************************************************************\n\tSPECIFY SERVER\n*********************************************************************************/\n\n#define SPECIFYSERVER_FRAMEL\t\"menu/art/frame2_l\"\n#define SPECIFYSERVER_FRAMER\t\"menu/art/frame1_r\"\n#define SPECIFYSERVER_BACK0\t\t\"menu/art/back_0\"\n#define SPECIFYSERVER_BACK1\t\t\"menu/art/back_1\"\n#define SPECIFYSERVER_FIGHT0\t\"menu/art/fight_0\"\n#define SPECIFYSERVER_FIGHT1\t\"menu/art/fight_1\"\n\n#define ID_SPECIFYSERVERBACK\t102\n#define ID_SPECIFYSERVERGO\t\t103\n\nstatic char* specifyserver_artlist[] =\n{\n\tSPECIFYSERVER_FRAMEL,\n\tSPECIFYSERVER_FRAMER,\n\tSPECIFYSERVER_BACK0,\t\n\tSPECIFYSERVER_BACK1,\t\n\tSPECIFYSERVER_FIGHT0,\n\tSPECIFYSERVER_FIGHT1,\n\tNULL\n};\n\ntypedef struct\n{\n\tmenuframework_s\tmenu;\n\tmenutext_s\t\tbanner;\n\tmenubitmap_s\tframel;\n\tmenubitmap_s\tframer;\n\tmenufield_s\t\tdomain;\n\tmenufield_s\t\tport;\n\tmenubitmap_s\tgo;\n\tmenubitmap_s\tback;\n} specifyserver_t;\n\nstatic specifyserver_t\ts_specifyserver;\n\n/*\n=================\nSpecifyServer_Event\n=================\n*/\nstatic void SpecifyServer_Event( void* ptr, int event )\n{\n\tchar\tbuff[256];\n\n\tswitch (((menucommon_s*)ptr)->id)\n\t{\n\t\tcase ID_SPECIFYSERVERGO:\n\t\t\tif (event != QM_ACTIVATED)\n\t\t\t\tbreak;\n\n\t\t\tif (s_specifyserver.domain.field.buffer[0])\n\t\t\t{\n\t\t\t\tstrcpy(buff,s_specifyserver.domain.field.buffer);\n\t\t\t\tif (s_specifyserver.port.field.buffer[0])\n\t\t\t\t\tCom_sprintf( buff+strlen(buff), 128, \":%s\", s_specifyserver.port.field.buffer );\n\n\t\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va( \"connect %s\\n\", buff ) );\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase ID_SPECIFYSERVERBACK:\n\t\t\tif (event != QM_ACTIVATED)\n\t\t\t\tbreak;\n\n\t\t\tUI_PopMenu();\n\t\t\tbreak;\n\t}\n}\n\n/*\n=================\nSpecifyServer_MenuInit\n=================\n*/\nvoid SpecifyServer_MenuInit( void )\n{\n\t// zero set all our globals\n\tmemset( &s_specifyserver, 0 ,sizeof(specifyserver_t) );\n\n\tSpecifyServer_Cache();\n\n\ts_specifyserver.menu.wrapAround = qtrue;\n\ts_specifyserver.menu.fullscreen = qtrue;\n\n\ts_specifyserver.banner.generic.type\t = MTYPE_BTEXT;\n\ts_specifyserver.banner.generic.x     = 320;\n\ts_specifyserver.banner.generic.y     = 16;\n\ts_specifyserver.banner.string\t\t = \"SPECIFY SERVER\";\n\ts_specifyserver.banner.color  \t\t = color_white;\n\ts_specifyserver.banner.style  \t\t = UI_CENTER;\n\n\ts_specifyserver.framel.generic.type  = MTYPE_BITMAP;\n\ts_specifyserver.framel.generic.name  = SPECIFYSERVER_FRAMEL;\n\ts_specifyserver.framel.generic.flags = QMF_INACTIVE;\n\ts_specifyserver.framel.generic.x\t = 0;  \n\ts_specifyserver.framel.generic.y\t = 78;\n\ts_specifyserver.framel.width  \t     = 256;\n\ts_specifyserver.framel.height  \t     = 329;\n\n\ts_specifyserver.framer.generic.type  = MTYPE_BITMAP;\n\ts_specifyserver.framer.generic.name  = SPECIFYSERVER_FRAMER;\n\ts_specifyserver.framer.generic.flags = QMF_INACTIVE;\n\ts_specifyserver.framer.generic.x\t = 376;\n\ts_specifyserver.framer.generic.y\t = 76;\n\ts_specifyserver.framer.width  \t     = 256;\n\ts_specifyserver.framer.height  \t     = 334;\n\n\ts_specifyserver.domain.generic.type       = MTYPE_FIELD;\n\ts_specifyserver.domain.generic.name       = \"Address:\";\n\ts_specifyserver.domain.generic.flags      = QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_specifyserver.domain.generic.x\t      = 206;\n\ts_specifyserver.domain.generic.y\t      = 220;\n\ts_specifyserver.domain.field.widthInChars = 38;\n\ts_specifyserver.domain.field.maxchars     = 80;\n\n\ts_specifyserver.port.generic.type       = MTYPE_FIELD;\n\ts_specifyserver.port.generic.name\t    = \"Port:\";\n\ts_specifyserver.port.generic.flags\t    = QMF_PULSEIFFOCUS|QMF_SMALLFONT|QMF_NUMBERSONLY;\n\ts_specifyserver.port.generic.x\t        = 206;\n\ts_specifyserver.port.generic.y\t        = 250;\n\ts_specifyserver.port.field.widthInChars = 6;\n\ts_specifyserver.port.field.maxchars     = 5;\n\n\ts_specifyserver.go.generic.type\t    = MTYPE_BITMAP;\n\ts_specifyserver.go.generic.name     = SPECIFYSERVER_FIGHT0;\n\ts_specifyserver.go.generic.flags    = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_specifyserver.go.generic.callback = SpecifyServer_Event;\n\ts_specifyserver.go.generic.id\t    = ID_SPECIFYSERVERGO;\n\ts_specifyserver.go.generic.x\t\t= 640;\n\ts_specifyserver.go.generic.y\t\t= 480-64;\n\ts_specifyserver.go.width  \t\t    = 128;\n\ts_specifyserver.go.height  \t\t    = 64;\n\ts_specifyserver.go.focuspic         = SPECIFYSERVER_FIGHT1;\n\n\ts_specifyserver.back.generic.type\t  = MTYPE_BITMAP;\n\ts_specifyserver.back.generic.name     = SPECIFYSERVER_BACK0;\n\ts_specifyserver.back.generic.flags    = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_specifyserver.back.generic.callback = SpecifyServer_Event;\n\ts_specifyserver.back.generic.id\t      = ID_SPECIFYSERVERBACK;\n\ts_specifyserver.back.generic.x\t\t  = 0;\n\ts_specifyserver.back.generic.y\t\t  = 480-64;\n\ts_specifyserver.back.width  \t\t  = 128;\n\ts_specifyserver.back.height  \t\t  = 64;\n\ts_specifyserver.back.focuspic         = SPECIFYSERVER_BACK1;\n\n\tMenu_AddItem( &s_specifyserver.menu, &s_specifyserver.banner );\n\tMenu_AddItem( &s_specifyserver.menu, &s_specifyserver.framel );\n\tMenu_AddItem( &s_specifyserver.menu, &s_specifyserver.framer );\n\tMenu_AddItem( &s_specifyserver.menu, &s_specifyserver.domain );\n\tMenu_AddItem( &s_specifyserver.menu, &s_specifyserver.port );\n\tMenu_AddItem( &s_specifyserver.menu, &s_specifyserver.go );\n\tMenu_AddItem( &s_specifyserver.menu, &s_specifyserver.back );\n\n\tCom_sprintf( s_specifyserver.port.field.buffer, 6, \"%i\", 27960 );\n}\n\n/*\n=================\nSpecifyServer_Cache\n=================\n*/\nvoid SpecifyServer_Cache( void )\n{\n\tint\ti;\n\n\t// touch all our pics\n\tfor (i=0; ;i++)\n\t{\n\t\tif (!specifyserver_artlist[i])\n\t\t\tbreak;\n\t\ttrap_R_RegisterShaderNoMip(specifyserver_artlist[i]);\n\t}\n}\n\n/*\n=================\nUI_SpecifyServerMenu\n=================\n*/\nvoid UI_SpecifyServerMenu( void )\n{\n\tSpecifyServer_MenuInit();\n\tUI_PushMenu( &s_specifyserver.menu );\n}\n\n"
  },
  {
    "path": "code/q3_ui/ui_splevel.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=============================================================================\n\nSINGLE PLAYER LEVEL SELECT MENU\n\n=============================================================================\n*/\n\n#include \"ui_local.h\"\n\n\n#define ART_LEVELFRAME_FOCUS\t\t\"menu/art/maps_select\"\n#define ART_LEVELFRAME_SELECTED\t\t\"menu/art/maps_selected\"\n#define ART_ARROW\t\t\t\t\t\"menu/art/narrow_0\"\n#define ART_ARROW_FOCUS\t\t\t\t\"menu/art/narrow_1\"\n#define ART_MAP_UNKNOWN\t\t\t\t\"menu/art/unknownmap\"\n#define ART_MAP_COMPLETE1\t\t\t\"menu/art/level_complete1\"\n#define ART_MAP_COMPLETE2\t\t\t\"menu/art/level_complete2\"\n#define ART_MAP_COMPLETE3\t\t\t\"menu/art/level_complete3\"\n#define ART_MAP_COMPLETE4\t\t\t\"menu/art/level_complete4\"\n#define ART_MAP_COMPLETE5\t\t\t\"menu/art/level_complete5\"\n#define ART_BACK0\t\t\t\t\t\"menu/art/back_0\"\n#define ART_BACK1\t\t\t\t\t\"menu/art/back_1\"\t\n#define ART_FIGHT0\t\t\t\t\t\"menu/art/fight_0\"\n#define ART_FIGHT1\t\t\t\t\t\"menu/art/fight_1\"\n#define ART_RESET0\t\t\t\t\t\"menu/art/reset_0\"\n#define ART_RESET1\t\t\t\t\t\"menu/art/reset_1\"\t\n#define ART_CUSTOM0\t\t\t\t\t\"menu/art/skirmish_0\"\n#define ART_CUSTOM1\t\t\t\t\t\"menu/art/skirmish_1\"\n\n#define ID_LEFTARROW\t\t10\n#define ID_PICTURE0\t\t\t11\n#define ID_PICTURE1\t\t\t12\n#define ID_PICTURE2\t\t\t13\n#define ID_PICTURE3\t\t\t14\n#define ID_RIGHTARROW\t\t15\n#define ID_PLAYERPIC\t\t16\n#define ID_AWARD1\t\t\t17\n#define ID_AWARD2\t\t\t18\n#define ID_AWARD3\t\t\t19\n#define ID_AWARD4\t\t\t20\n#define ID_AWARD5\t\t\t21\n#define ID_AWARD6\t\t\t22\n#define ID_BACK\t\t\t\t23\n#define ID_RESET\t\t\t24\n#define ID_CUSTOM\t\t\t25\n#define ID_NEXT\t\t\t\t26\n\n#define PLAYER_Y\t\t\t314\n#define AWARDS_Y\t\t\t(PLAYER_Y + 26)\n\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n\tmenutext_s\t\titem_banner;\n\tmenubitmap_s\titem_leftarrow;\n\tmenubitmap_s\titem_maps[4];\n\tmenubitmap_s\titem_rightarrow;\n\tmenubitmap_s\titem_player;\n\tmenubitmap_s\titem_awards[6];\n\tmenubitmap_s\titem_back;\n\tmenubitmap_s\titem_reset;\n\tmenubitmap_s\titem_custom;\n\tmenubitmap_s\titem_next;\n\tmenubitmap_s\titem_null;\n\n\tqboolean\t\treinit;\n\n\tconst char *\tselectedArenaInfo;\n\tint\t\t\t\tnumMaps;\n\tchar\t\t\tlevelPicNames[4][MAX_QPATH];\n\tchar\t\t\tlevelNames[4][16];\n\tint\t\t\t\tlevelScores[4];\n\tint\t\t\t\tlevelScoresSkill[4];\n\tqhandle_t\t\tlevelSelectedPic;\n\tqhandle_t\t\tlevelFocusPic;\n\tqhandle_t\t\tlevelCompletePic[5];\n\n\tchar\t\t\tplayerModel[MAX_QPATH];\n\tchar\t\t\tplayerPicName[MAX_QPATH];\n\tint\t\t\t\tawardLevels[6];\n\tsfxHandle_t\t\tawardSounds[6];\n\n\tint\t\t\t\tnumBots;\n\tqhandle_t\t\tbotPics[7];\n\tchar\t\t\tbotNames[7][10];\n} levelMenuInfo_t;\n\nstatic levelMenuInfo_t\tlevelMenuInfo;\n\nstatic int\tselectedArenaSet;\nstatic int\tselectedArena;\nstatic int\tcurrentSet;\nstatic int\tcurrentGame;\nstatic int\ttrainingTier;\nstatic int\tfinalTier;\nstatic int\tminTier;\nstatic int\tmaxTier;\n\n\n/*\n=================\nPlayerIcon\n=================\n*/\nstatic void PlayerIcon( const char *modelAndSkin, char *iconName, int iconNameMaxSize ) {\n\tchar\t*skin;\n\tchar\tmodel[MAX_QPATH];\n\n\tQ_strncpyz( model, modelAndSkin, sizeof(model));\n\tskin = Q_strrchr( model, '/' );\n\tif ( skin ) {\n\t\t*skin++ = '\\0';\n\t}\n\telse {\n\t\tskin = \"default\";\n\t}\n\n\tCom_sprintf(iconName, iconNameMaxSize, \"models/players/%s/icon_%s.tga\", model, skin );\n\n\tif( !trap_R_RegisterShaderNoMip( iconName ) && Q_stricmp( skin, \"default\" ) != 0 ) {\n\t\tCom_sprintf(iconName, iconNameMaxSize, \"models/players/%s/icon_default.tga\", model );\n\t}\n}\n\n\n/*\n=================\nPlayerIconhandle\n=================\n*/\nstatic qhandle_t PlayerIconHandle( const char *modelAndSkin ) {\n\tchar\ticonName[MAX_QPATH];\n\n\tPlayerIcon( modelAndSkin, iconName, sizeof(iconName) );\n\treturn trap_R_RegisterShaderNoMip( iconName );\n}\n\n\n/*\n=================\nUI_SPLevelMenu_SetBots\n=================\n*/\nstatic void UI_SPLevelMenu_SetBots( void ) {\n\tchar\t*p;\n\tchar\t*bot;\n\tchar\t*botInfo;\n\tchar\tbots[MAX_INFO_STRING];\n\n\tlevelMenuInfo.numBots = 0;\n\tif ( selectedArenaSet > currentSet ) {\n\t\treturn;\n\t}\n\n\tQ_strncpyz( bots, Info_ValueForKey( levelMenuInfo.selectedArenaInfo, \"bots\" ), sizeof(bots) );\n\n\tp = &bots[0];\n\twhile( *p && levelMenuInfo.numBots < 7 ) {\n\t\t//skip spaces\n\t\twhile( *p && *p == ' ' ) {\n\t\t\tp++;\n\t\t}\n\t\tif( !p ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// mark start of bot name\n\t\tbot = p;\n\n\t\t// skip until space of null\n\t\twhile( *p && *p != ' ' ) {\n\t\t\tp++;\n\t\t}\n\t\tif( *p ) {\n\t\t\t*p++ = 0;\n\t\t}\n\n\t\tbotInfo = UI_GetBotInfoByName( bot );\n\t\tif( botInfo ) {\n\t\t\tlevelMenuInfo.botPics[levelMenuInfo.numBots] = PlayerIconHandle( Info_ValueForKey( botInfo, \"model\" ) );\n\t\t\tQ_strncpyz( levelMenuInfo.botNames[levelMenuInfo.numBots], Info_ValueForKey( botInfo, \"name\" ), 10 );\n\t\t}\n\t\telse {\n\t\t\tlevelMenuInfo.botPics[levelMenuInfo.numBots] = 0;\n\t\t\tQ_strncpyz( levelMenuInfo.botNames[levelMenuInfo.numBots], bot, 10 );\n\t\t}\n\t\tQ_CleanStr( levelMenuInfo.botNames[levelMenuInfo.numBots] );\n\t\tlevelMenuInfo.numBots++;\n\t}\n}\n\n\n/*\n=================\nUI_SPLevelMenu_SetMenuItems\n=================\n*/\nstatic void UI_SPLevelMenu_SetMenuArena( int n, int level, const char *arenaInfo ) {\n\tchar\t\tmap[MAX_QPATH];\n\n\tQ_strncpyz( map, Info_ValueForKey( arenaInfo, \"map\" ), sizeof(map) );\n\n\tQ_strncpyz( levelMenuInfo.levelNames[n], map, sizeof(levelMenuInfo.levelNames[n]) );\n\tQ_strupr( levelMenuInfo.levelNames[n] );\n\n\tUI_GetBestScore( level, &levelMenuInfo.levelScores[n], &levelMenuInfo.levelScoresSkill[n] );\n\tif( levelMenuInfo.levelScores[n] > 8 ) {\n\t\tlevelMenuInfo.levelScores[n] = 8;\n\t}\n\n\tstrcpy( levelMenuInfo.levelPicNames[n], va( \"levelshots/%s.tga\", map ) );\n\tif( !trap_R_RegisterShaderNoMip( levelMenuInfo.levelPicNames[n] ) ) {\n\t\tstrcpy( levelMenuInfo.levelPicNames[n], ART_MAP_UNKNOWN );\n\t}\n\tlevelMenuInfo.item_maps[n].shader = 0;\n\tif ( selectedArenaSet > currentSet ) {\n\t\tlevelMenuInfo.item_maps[n].generic.flags |= QMF_GRAYED;\n\t}\n\telse {\n\t\tlevelMenuInfo.item_maps[n].generic.flags &= ~QMF_GRAYED;\n\t}\n\n\tlevelMenuInfo.item_maps[n].generic.flags &= ~QMF_INACTIVE;\n}\n\nstatic void UI_SPLevelMenu_SetMenuItems( void ) {\n\tint\t\t\tn;\n\tint\t\t\tlevel;\n\tconst char\t*arenaInfo;\n\n\tif ( selectedArenaSet > currentSet ) {\n\t\tselectedArena = -1;\n\t}\n\telse if ( selectedArena == -1 ) {\n\t\tselectedArena = 0;\n\t}\n\n\tif( selectedArenaSet == trainingTier || selectedArenaSet == finalTier ) {\n\t\tselectedArena = 0;\n\t}\n\n\tif( selectedArena != -1 ) {\n\t\ttrap_Cvar_SetValue( \"ui_spSelection\", selectedArenaSet * ARENAS_PER_TIER + selectedArena );\n\t}\n\n\tif( selectedArenaSet == trainingTier ) {\n\t\tarenaInfo = UI_GetSpecialArenaInfo( \"training\" );\n\t\tlevel = atoi( Info_ValueForKey( arenaInfo, \"num\" ) );\n\t\tUI_SPLevelMenu_SetMenuArena( 0, level, arenaInfo );\n\t\tlevelMenuInfo.selectedArenaInfo = arenaInfo;\n\n\t\tlevelMenuInfo.item_maps[0].generic.x = 256;\n\t\tBitmap_Init( &levelMenuInfo.item_maps[0] );\n\t\tlevelMenuInfo.item_maps[0].generic.bottom += 32;\n\t\tlevelMenuInfo.numMaps = 1;\n\n\t\tlevelMenuInfo.item_maps[1].generic.flags |= QMF_INACTIVE;\n\t\tlevelMenuInfo.item_maps[2].generic.flags |= QMF_INACTIVE;\n\t\tlevelMenuInfo.item_maps[3].generic.flags |= QMF_INACTIVE;\n\t\tlevelMenuInfo.levelPicNames[1][0] = 0;\n\t\tlevelMenuInfo.levelPicNames[2][0] = 0;\n\t\tlevelMenuInfo.levelPicNames[3][0] = 0;\n\t\tlevelMenuInfo.item_maps[1].shader = 0;\n\t\tlevelMenuInfo.item_maps[2].shader = 0;\n\t\tlevelMenuInfo.item_maps[3].shader = 0;\n\t}\n\telse if( selectedArenaSet == finalTier ) {\n\t\tarenaInfo = UI_GetSpecialArenaInfo( \"final\" );\n\t\tlevel = atoi( Info_ValueForKey( arenaInfo, \"num\" ) );\n\t\tUI_SPLevelMenu_SetMenuArena( 0, level, arenaInfo );\n\t\tlevelMenuInfo.selectedArenaInfo = arenaInfo;\n\n\t\tlevelMenuInfo.item_maps[0].generic.x = 256;\n\t\tBitmap_Init( &levelMenuInfo.item_maps[0] );\n\t\tlevelMenuInfo.item_maps[0].generic.bottom += 32;\n\t\tlevelMenuInfo.numMaps = 1;\n\n\t\tlevelMenuInfo.item_maps[1].generic.flags |= QMF_INACTIVE;\n\t\tlevelMenuInfo.item_maps[2].generic.flags |= QMF_INACTIVE;\n\t\tlevelMenuInfo.item_maps[3].generic.flags |= QMF_INACTIVE;\n\t\tlevelMenuInfo.levelPicNames[1][0] = 0;\n\t\tlevelMenuInfo.levelPicNames[2][0] = 0;\n\t\tlevelMenuInfo.levelPicNames[3][0] = 0;\n\t\tlevelMenuInfo.item_maps[1].shader = 0;\n\t\tlevelMenuInfo.item_maps[2].shader = 0;\n\t\tlevelMenuInfo.item_maps[3].shader = 0;\n\t}\n\telse {\n\t\tlevelMenuInfo.item_maps[0].generic.x = 46;\n\t\tBitmap_Init( &levelMenuInfo.item_maps[0] );\n\t\tlevelMenuInfo.item_maps[0].generic.bottom += 18;\n\t\tlevelMenuInfo.numMaps = 4;\n\n\t\tfor ( n = 0; n < 4; n++ ) {\n\t\t\tlevel = selectedArenaSet * ARENAS_PER_TIER + n;\n\t\t\tarenaInfo = UI_GetArenaInfoByNumber( level );\n\t\t\tUI_SPLevelMenu_SetMenuArena( n, level, arenaInfo );\n\t\t}\n\n\t\tif( selectedArena != -1 ) {\n\t\t\tlevelMenuInfo.selectedArenaInfo = UI_GetArenaInfoByNumber( selectedArenaSet * ARENAS_PER_TIER + selectedArena );\n\t\t}\n\t}\n\n\t// enable/disable arrows when they are valid/invalid\n\tif ( selectedArenaSet == minTier ) {\n\t\tlevelMenuInfo.item_leftarrow.generic.flags |= ( QMF_INACTIVE | QMF_HIDDEN );\n\t}\n\telse {\n\t\tlevelMenuInfo.item_leftarrow.generic.flags &= ~( QMF_INACTIVE | QMF_HIDDEN );\n\t}\n\n\tif ( selectedArenaSet == maxTier ) {\n\t\tlevelMenuInfo.item_rightarrow.generic.flags |= ( QMF_INACTIVE | QMF_HIDDEN );\n\t}\n\telse {\n\t\tlevelMenuInfo.item_rightarrow.generic.flags &= ~( QMF_INACTIVE | QMF_HIDDEN );\n\t}\n\n\tUI_SPLevelMenu_SetBots();\n}\n\n\n/*\n=================\nUI_SPLevelMenu_ResetEvent\n=================\n*/\nstatic void UI_SPLevelMenu_ResetDraw( void ) {\n\tUI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 0, \"WARNING: This resets all of the\", UI_CENTER|UI_SMALLFONT, color_yellow );\n\tUI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 1, \"single player game variables.\", UI_CENTER|UI_SMALLFONT, color_yellow );\n\tUI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 2, \"Do this only if you want to\", UI_CENTER|UI_SMALLFONT, color_yellow );\n\tUI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 3, \"start over from the beginning.\", UI_CENTER|UI_SMALLFONT, color_yellow );\n}\n\nstatic void UI_SPLevelMenu_ResetAction( qboolean result ) {\n\tif( !result ) {\n\t\treturn;\n\t}\n\n\t// clear game variables\n\tUI_NewGame();\n\ttrap_Cvar_SetValue( \"ui_spSelection\", -4 );\n\n\t// make the level select menu re-initialize\n\tUI_PopMenu();\n\tUI_SPLevelMenu();\n}\n\nstatic void UI_SPLevelMenu_ResetEvent( void* ptr, int event )\n{\n\tif (event != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\n\tUI_ConfirmMenu( \"RESET GAME?\", UI_SPLevelMenu_ResetDraw, UI_SPLevelMenu_ResetAction );\n}\n\n\n/*\n=================\nUI_SPLevelMenu_LevelEvent\n=================\n*/\nstatic void UI_SPLevelMenu_LevelEvent( void* ptr, int notification ) {\n\tif (notification != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\n\tif ( selectedArenaSet == trainingTier || selectedArenaSet == finalTier ) {\n\t\treturn;\n\t}\n\n\tselectedArena = ((menucommon_s*)ptr)->id - ID_PICTURE0;\n\tlevelMenuInfo.selectedArenaInfo = UI_GetArenaInfoByNumber( selectedArenaSet * ARENAS_PER_TIER + selectedArena );\n\tUI_SPLevelMenu_SetBots();\n\n\ttrap_Cvar_SetValue( \"ui_spSelection\", selectedArenaSet * ARENAS_PER_TIER + selectedArena );\n}\n\n\n/*\n=================\nUI_SPLevelMenu_LeftArrowEvent\n=================\n*/\nstatic void UI_SPLevelMenu_LeftArrowEvent( void* ptr, int notification ) {\n\tif (notification != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\n\tif ( selectedArenaSet == minTier ) {\n\t\treturn;\n\t}\n\n\tselectedArenaSet--;\n\tUI_SPLevelMenu_SetMenuItems();\n}\n\n\n/*\n=================\nUI_SPLevelMenu_RightArrowEvent\n=================\n*/\nstatic void UI_SPLevelMenu_RightArrowEvent( void* ptr, int notification ) {\n\tif (notification != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\n\tif ( selectedArenaSet == maxTier ) {\n\t\treturn;\n\t}\n\n\tselectedArenaSet++;\n\tUI_SPLevelMenu_SetMenuItems();\n}\n\n\n/*\n=================\nUI_SPLevelMenu_PlayerEvent\n=================\n*/\nstatic void UI_SPLevelMenu_PlayerEvent( void* ptr, int notification ) {\n\tif (notification != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\n\tUI_PlayerSettingsMenu();\n}\n\n\n/*\n=================\nUI_SPLevelMenu_AwardEvent\n=================\n*/\nstatic void UI_SPLevelMenu_AwardEvent( void* ptr, int notification ) {\n\tint\t\tn;\n\n\tif (notification != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\n\tn = ((menucommon_s*)ptr)->id - ID_AWARD1;\n\ttrap_S_StartLocalSound( levelMenuInfo.awardSounds[n], CHAN_ANNOUNCER );\n}\n\n\n/*\n=================\nUI_SPLevelMenu_NextEvent\n=================\n*/\nstatic void UI_SPLevelMenu_NextEvent( void* ptr, int notification ) {\n\tif (notification != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\n\tif ( selectedArenaSet > currentSet ) {\n\t\treturn;\n\t}\n\n\tif ( selectedArena == -1 ) {\n\t\tselectedArena = 0;\n\t}\n\n\tUI_SPSkillMenu( levelMenuInfo.selectedArenaInfo );\n}\n\n\n/*\n=================\nUI_SPLevelMenu_BackEvent\n=================\n*/\nstatic void UI_SPLevelMenu_BackEvent( void* ptr, int notification ) {\n\tif (notification != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\n\tif ( selectedArena == -1 ) {\n\t\tselectedArena = 0;\n\t}\n\n\tUI_PopMenu();\n}\n\n\n/*\n=================\nUI_SPLevelMenu_CustomEvent\n=================\n*/\nstatic void UI_SPLevelMenu_CustomEvent( void* ptr, int notification ) {\n\tif (notification != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\n\tUI_StartServerMenu( qfalse );\n}\n\n\n/*\n=================\nUI_SPLevelMenu_MenuDraw\n=================\n*/\n#define LEVEL_DESC_LEFT_MARGIN\t\t332\n\nstatic void UI_SPLevelMenu_MenuDraw( void ) {\n\tint\t\t\t\tn, i;\n\tint\t\t\t\tx, y;\n\tvec4_t\t\t\tcolor;\n\tint\t\t\t\tlevel;\n//\tint\t\t\t\tfraglimit;\n\tint\t\t\t\tpad;\n\tchar\t\t\tbuf[MAX_INFO_VALUE];\n\tchar\t\t\tstring[64];\n\n\tif(\tlevelMenuInfo.reinit ) {\n\t\tUI_PopMenu();\n\t\tUI_SPLevelMenu();\n\t\treturn;\n\t}\n\n\t// draw player name\n\ttrap_Cvar_VariableStringBuffer( \"name\", string, 32 );\n\tQ_CleanStr( string );\n\tUI_DrawProportionalString( 320, PLAYER_Y, string, UI_CENTER|UI_SMALLFONT, color_orange );\n\n\t// check for model changes\n\ttrap_Cvar_VariableStringBuffer( \"model\", buf, sizeof(buf) );\n\tif( Q_stricmp( buf, levelMenuInfo.playerModel ) != 0 ) {\n\t\tQ_strncpyz( levelMenuInfo.playerModel, buf, sizeof(levelMenuInfo.playerModel) );\n\t\tPlayerIcon( levelMenuInfo.playerModel, levelMenuInfo.playerPicName, sizeof(levelMenuInfo.playerPicName) );\n\t\tlevelMenuInfo.item_player.shader = 0;\n\t}\n\n\t// standard menu drawing\n\tMenu_Draw( &levelMenuInfo.menu );\n\n\t// draw player award levels\n\ty = AWARDS_Y;\n\ti = 0;\n\tfor( n = 0; n < 6; n++ ) {\n\t\tlevel = levelMenuInfo.awardLevels[n];\n\t\tif( level > 0 ) {\n\t\t\tif( i & 1 ) {\n\t\t\t\tx = 224 - (i - 1 ) / 2 * (48 + 16);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tx = 368 + i / 2 * (48 + 16);\n\t\t\t}\n\t\t\ti++;\n\n\t\t\tif( level == 1 ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif( level >= 1000000 ) {\n\t\t\t\tCom_sprintf( string, sizeof(string), \"%im\", level / 1000000 );\n\t\t\t}\n\t\t\telse if( level >= 1000 ) {\n\t\t\t\tCom_sprintf( string, sizeof(string), \"%ik\", level / 1000 );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tCom_sprintf( string, sizeof(string), \"%i\", level );\n\t\t\t}\n\n\t\t\tUI_DrawString( x + 24, y + 48, string, UI_CENTER, color_yellow );\n\t\t}\n\t}\n\n\tUI_DrawProportionalString( 18, 38, va( \"Tier %i\", selectedArenaSet + 1 ), UI_LEFT|UI_SMALLFONT, color_orange );\n\n\tfor ( n = 0; n < levelMenuInfo.numMaps; n++ ) {\n\t\tx = levelMenuInfo.item_maps[n].generic.x;\n\t\ty = levelMenuInfo.item_maps[n].generic.y;\n\t\tUI_FillRect( x, y + 96, 128, 18, color_black );\n\t}\n\n\tif ( selectedArenaSet > currentSet ) {\n\t\tUI_DrawProportionalString( 320, 216, \"ACCESS DENIED\", UI_CENTER|UI_BIGFONT, color_red );\n\t\treturn;\n\t}\n\n\t// show levelshots for levels of current tier\n\tVector4Copy( color_white, color );\n\tcolor[3] = 0.5+0.5*sin(uis.realtime/PULSE_DIVISOR);\n\tfor ( n = 0; n < levelMenuInfo.numMaps; n++ ) {\n\t\tx = levelMenuInfo.item_maps[n].generic.x;\n\t\ty = levelMenuInfo.item_maps[n].generic.y;\n\n\t\tUI_DrawString( x + 64, y + 96, levelMenuInfo.levelNames[n], UI_CENTER|UI_SMALLFONT, color_orange );\n\n\t\tif( levelMenuInfo.levelScores[n] == 1 ) {\n\t\t\tUI_DrawHandlePic( x, y, 128, 96, levelMenuInfo.levelCompletePic[levelMenuInfo.levelScoresSkill[n] - 1] ); \n\t\t}\n\n\t\tif ( n == selectedArena ) {\n\t\t\tif( Menu_ItemAtCursor( &levelMenuInfo.menu ) == &levelMenuInfo.item_maps[n] ) {\n\t\t\t\ttrap_R_SetColor( color );\n\t\t\t}\n\t\t\tUI_DrawHandlePic( x-1, y-1, 130, 130 - 14, levelMenuInfo.levelSelectedPic ); \n\t\t\ttrap_R_SetColor( NULL );\n\t\t}\n\t\telse if( Menu_ItemAtCursor( &levelMenuInfo.menu ) == &levelMenuInfo.item_maps[n] ) {\n\t\t\ttrap_R_SetColor( color );\n\t\t\tUI_DrawHandlePic( x-31, y-30, 256, 256-27, levelMenuInfo.levelFocusPic); \n\t\t\ttrap_R_SetColor( NULL );\n\t\t}\n\t}\n\n\t// show map name and long name of selected level\n\ty = 192;\n\tQ_strncpyz( buf, Info_ValueForKey( levelMenuInfo.selectedArenaInfo, \"map\" ), 20 );\n\tQ_strupr( buf );\n\tCom_sprintf( string, sizeof(string), \"%s: %s\", buf, Info_ValueForKey( levelMenuInfo.selectedArenaInfo, \"longname\" ) );\n\tUI_DrawProportionalString( 320, y, string, UI_CENTER|UI_SMALLFONT, color_orange );\n\n//\tfraglimit = atoi( Info_ValueForKey( levelMenuInfo.selectedArenaInfo, \"fraglimit\" ) );\n//\tUI_DrawString( 18, 212, va(\"Frags %i\", fraglimit) , UI_LEFT|UI_SMALLFONT, color_orange );\n\n\t// draw bot opponents\n\ty += 24;\n\tpad = (7 - levelMenuInfo.numBots) * (64 + 26) / 2;\n\tfor( n = 0; n < levelMenuInfo.numBots; n++ ) {\n\t\tx = 18 + pad + (64 + 26) * n;\n\t\tif( levelMenuInfo.botPics[n] ) {\n\t\t\tUI_DrawHandlePic( x, y, 64, 64, levelMenuInfo.botPics[n]);\n\t\t}\n\t\telse {\n\t\t\tUI_FillRect( x, y, 64, 64, color_black );\n\t\t\tUI_DrawProportionalString( x+22, y+18, \"?\", UI_BIGFONT, color_orange );\n\t\t}\n\t\tUI_DrawString( x, y + 64, levelMenuInfo.botNames[n], UI_SMALLFONT|UI_LEFT, color_orange );\n\t}\n}\n\n\n/*\n=================\nUI_SPLevelMenu_Cache\n=================\n*/\nvoid UI_SPLevelMenu_Cache( void ) {\n\tint\t\t\t\tn;\n\n\ttrap_R_RegisterShaderNoMip( ART_LEVELFRAME_FOCUS );\n\ttrap_R_RegisterShaderNoMip( ART_LEVELFRAME_SELECTED );\n\ttrap_R_RegisterShaderNoMip( ART_ARROW );\n\ttrap_R_RegisterShaderNoMip( ART_ARROW_FOCUS );\n\ttrap_R_RegisterShaderNoMip( ART_MAP_UNKNOWN );\n\ttrap_R_RegisterShaderNoMip( ART_MAP_COMPLETE1 );\n\ttrap_R_RegisterShaderNoMip( ART_MAP_COMPLETE2 );\n\ttrap_R_RegisterShaderNoMip( ART_MAP_COMPLETE3 );\n\ttrap_R_RegisterShaderNoMip( ART_MAP_COMPLETE4 );\n\ttrap_R_RegisterShaderNoMip( ART_MAP_COMPLETE5 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK0 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK1 );\n\ttrap_R_RegisterShaderNoMip( ART_FIGHT0 );\n\ttrap_R_RegisterShaderNoMip( ART_FIGHT1 );\n\ttrap_R_RegisterShaderNoMip( ART_RESET0 );\n\ttrap_R_RegisterShaderNoMip( ART_RESET1 );\n\ttrap_R_RegisterShaderNoMip( ART_CUSTOM0 );\n\ttrap_R_RegisterShaderNoMip( ART_CUSTOM1 );\n\n\tfor( n = 0; n < 6; n++ ) {\n\t\ttrap_R_RegisterShaderNoMip( ui_medalPicNames[n] );\n\t\tlevelMenuInfo.awardSounds[n] = trap_S_RegisterSound( ui_medalSounds[n], qfalse );\n\t}\n\n\tlevelMenuInfo.levelSelectedPic = trap_R_RegisterShaderNoMip( ART_LEVELFRAME_SELECTED );\n\tlevelMenuInfo.levelFocusPic = trap_R_RegisterShaderNoMip( ART_LEVELFRAME_FOCUS );\n\tlevelMenuInfo.levelCompletePic[0] = trap_R_RegisterShaderNoMip( ART_MAP_COMPLETE1 );\n\tlevelMenuInfo.levelCompletePic[1] = trap_R_RegisterShaderNoMip( ART_MAP_COMPLETE2 );\n\tlevelMenuInfo.levelCompletePic[2] = trap_R_RegisterShaderNoMip( ART_MAP_COMPLETE3 );\n\tlevelMenuInfo.levelCompletePic[3] = trap_R_RegisterShaderNoMip( ART_MAP_COMPLETE4 );\n\tlevelMenuInfo.levelCompletePic[4] = trap_R_RegisterShaderNoMip( ART_MAP_COMPLETE5 );\n}\n\n\n/*\n=================\nUI_SPLevelMenu_Init\n=================\n*/\nstatic void UI_SPLevelMenu_Init( void ) {\n\tint\t\tskill;\n\tint\t\tn;\n\tint\t\tx, y;\n\tint\t\tcount;\n\tchar\tbuf[MAX_QPATH];\n\n\tskill = (int)trap_Cvar_VariableValue( \"g_spSkill\" );\n\tif( skill < 1 || skill > 5 ) {\n\t\ttrap_Cvar_Set( \"g_spSkill\", \"2\" );\n\t\tskill = 2;\n\t}\n\n\tmemset( &levelMenuInfo, 0, sizeof(levelMenuInfo) );\n\tlevelMenuInfo.menu.fullscreen = qtrue;\n\tlevelMenuInfo.menu.wrapAround = qtrue;\n\tlevelMenuInfo.menu.draw = UI_SPLevelMenu_MenuDraw;\n\n\tUI_SPLevelMenu_Cache();\n\n\tlevelMenuInfo.item_banner.generic.type\t\t\t= MTYPE_BTEXT;\n\tlevelMenuInfo.item_banner.generic.x\t\t\t\t= 320;\n\tlevelMenuInfo.item_banner.generic.y\t\t\t\t= 16;\n\tlevelMenuInfo.item_banner.string\t\t\t\t= \"CHOOSE LEVEL\";\n\tlevelMenuInfo.item_banner.color\t\t\t\t\t= color_red;\n\tlevelMenuInfo.item_banner.style\t\t\t\t\t= UI_CENTER;\n\n\tlevelMenuInfo.item_leftarrow.generic.type\t\t= MTYPE_BITMAP;\n\tlevelMenuInfo.item_leftarrow.generic.name\t\t= ART_ARROW;\n\tlevelMenuInfo.item_leftarrow.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tlevelMenuInfo.item_leftarrow.generic.x\t\t\t= 18;\n\tlevelMenuInfo.item_leftarrow.generic.y\t\t\t= 64;\n\tlevelMenuInfo.item_leftarrow.generic.callback\t= UI_SPLevelMenu_LeftArrowEvent;\n\tlevelMenuInfo.item_leftarrow.generic.id\t\t\t= ID_LEFTARROW;\n\tlevelMenuInfo.item_leftarrow.width\t\t\t\t= 16;\n\tlevelMenuInfo.item_leftarrow.height\t\t\t\t= 114;\n\tlevelMenuInfo.item_leftarrow.focuspic\t\t\t= ART_ARROW_FOCUS;\n\n\tlevelMenuInfo.item_maps[0].generic.type\t\t\t= MTYPE_BITMAP;\n\tlevelMenuInfo.item_maps[0].generic.name\t\t\t= levelMenuInfo.levelPicNames[0];\n\tlevelMenuInfo.item_maps[0].generic.flags\t\t= QMF_LEFT_JUSTIFY;\n\tlevelMenuInfo.item_maps[0].generic.x\t\t\t= 46;\n\tlevelMenuInfo.item_maps[0].generic.y\t\t\t= 64;\n\tlevelMenuInfo.item_maps[0].generic.id\t\t\t= ID_PICTURE0;\n\tlevelMenuInfo.item_maps[0].generic.callback\t\t= UI_SPLevelMenu_LevelEvent;\n\tlevelMenuInfo.item_maps[0].width\t\t\t\t= 128;\n\tlevelMenuInfo.item_maps[0].height\t\t\t\t= 96;\n\n\tlevelMenuInfo.item_maps[1].generic.type\t\t\t= MTYPE_BITMAP;\n\tlevelMenuInfo.item_maps[1].generic.name\t\t\t= levelMenuInfo.levelPicNames[1];\n\tlevelMenuInfo.item_maps[1].generic.flags\t\t= QMF_LEFT_JUSTIFY;\n\tlevelMenuInfo.item_maps[1].generic.x\t\t\t= 186;\n\tlevelMenuInfo.item_maps[1].generic.y\t\t\t= 64;\n\tlevelMenuInfo.item_maps[1].generic.id\t\t\t= ID_PICTURE1;\n\tlevelMenuInfo.item_maps[1].generic.callback\t\t= UI_SPLevelMenu_LevelEvent;\n\tlevelMenuInfo.item_maps[1].width\t\t\t\t= 128;\n\tlevelMenuInfo.item_maps[1].height\t\t\t\t= 96;\n\n\tlevelMenuInfo.item_maps[2].generic.type\t\t\t= MTYPE_BITMAP;\n\tlevelMenuInfo.item_maps[2].generic.name\t\t\t= levelMenuInfo.levelPicNames[2];\n\tlevelMenuInfo.item_maps[2].generic.flags\t\t= QMF_LEFT_JUSTIFY;\n\tlevelMenuInfo.item_maps[2].generic.x\t\t\t= 326;\n\tlevelMenuInfo.item_maps[2].generic.y\t\t\t= 64;\n\tlevelMenuInfo.item_maps[2].generic.id\t\t\t= ID_PICTURE2;\n\tlevelMenuInfo.item_maps[2].generic.callback\t\t= UI_SPLevelMenu_LevelEvent;\n\tlevelMenuInfo.item_maps[2].width\t\t\t\t= 128;\n\tlevelMenuInfo.item_maps[2].height\t\t\t\t= 96;\n\n\tlevelMenuInfo.item_maps[3].generic.type\t\t\t= MTYPE_BITMAP;\n\tlevelMenuInfo.item_maps[3].generic.name\t\t\t= levelMenuInfo.levelPicNames[3];\n\tlevelMenuInfo.item_maps[3].generic.flags\t\t= QMF_LEFT_JUSTIFY;\n\tlevelMenuInfo.item_maps[3].generic.x\t\t\t= 466;\n\tlevelMenuInfo.item_maps[3].generic.y\t\t\t= 64;\n\tlevelMenuInfo.item_maps[3].generic.id\t\t\t= ID_PICTURE3;\n\tlevelMenuInfo.item_maps[3].generic.callback\t\t= UI_SPLevelMenu_LevelEvent;\n\tlevelMenuInfo.item_maps[3].width\t\t\t\t= 128;\n\tlevelMenuInfo.item_maps[3].height\t\t\t\t= 96;\n\n\tlevelMenuInfo.item_rightarrow.generic.type\t\t= MTYPE_BITMAP;\n\tlevelMenuInfo.item_rightarrow.generic.name\t\t= ART_ARROW;\n\tlevelMenuInfo.item_rightarrow.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tlevelMenuInfo.item_rightarrow.generic.x\t\t\t= 606;\n\tlevelMenuInfo.item_rightarrow.generic.y\t\t\t= 64;\n\tlevelMenuInfo.item_rightarrow.generic.callback\t= UI_SPLevelMenu_RightArrowEvent;\n\tlevelMenuInfo.item_rightarrow.generic.id\t\t= ID_RIGHTARROW;\n\tlevelMenuInfo.item_rightarrow.width\t\t\t\t= -16;\n\tlevelMenuInfo.item_rightarrow.height\t\t\t= 114;\n\tlevelMenuInfo.item_rightarrow.focuspic\t\t\t= ART_ARROW_FOCUS;\n\n\ttrap_Cvar_VariableStringBuffer( \"model\", levelMenuInfo.playerModel, sizeof(levelMenuInfo.playerModel) );\n\tPlayerIcon( levelMenuInfo.playerModel, levelMenuInfo.playerPicName, sizeof(levelMenuInfo.playerPicName) );\n\tlevelMenuInfo.item_player.generic.type\t\t\t= MTYPE_BITMAP;\n\tlevelMenuInfo.item_player.generic.name\t\t\t= levelMenuInfo.playerPicName;\n\tlevelMenuInfo.item_player.generic.flags\t\t\t= QMF_LEFT_JUSTIFY|QMF_MOUSEONLY;\n\tlevelMenuInfo.item_player.generic.x\t\t\t\t= 288;\n\tlevelMenuInfo.item_player.generic.y\t\t\t\t= AWARDS_Y;\n\tlevelMenuInfo.item_player.generic.id\t\t\t= ID_PLAYERPIC;\n\tlevelMenuInfo.item_player.generic.callback\t\t= UI_SPLevelMenu_PlayerEvent;\n\tlevelMenuInfo.item_player.width\t\t\t\t\t= 64;\n\tlevelMenuInfo.item_player.height\t\t\t\t= 64;\n\n\tfor( n = 0; n < 6; n++ ) {\n\t\tlevelMenuInfo.awardLevels[n] = UI_GetAwardLevel( n );\n\t}\n\tlevelMenuInfo.awardLevels[AWARD_FRAGS] = 100 * (levelMenuInfo.awardLevels[AWARD_FRAGS] / 100);\n\n\ty = AWARDS_Y;\n\tcount = 0;\n\tfor( n = 0; n < 6; n++ ) {\n\t\tif( levelMenuInfo.awardLevels[n] ) {\n\t\t\tif( count & 1 ) {\n\t\t\t\tx = 224 - (count - 1 ) / 2 * (48 + 16);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tx = 368 + count / 2 * (48 + 16);\n\t\t\t}\n\n\t\t\tlevelMenuInfo.item_awards[count].generic.type\t\t= MTYPE_BITMAP;\n\t\t\tlevelMenuInfo.item_awards[count].generic.name\t\t= ui_medalPicNames[n];\n\t\t\tlevelMenuInfo.item_awards[count].generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_SILENT|QMF_MOUSEONLY;\n\t\t\tlevelMenuInfo.item_awards[count].generic.x\t\t\t= x;\n\t\t\tlevelMenuInfo.item_awards[count].generic.y\t\t\t= y;\n\t\t\tlevelMenuInfo.item_awards[count].generic.id\t\t\t= ID_AWARD1 + n;\n\t\t\tlevelMenuInfo.item_awards[count].generic.callback\t= UI_SPLevelMenu_AwardEvent;\n\t\t\tlevelMenuInfo.item_awards[count].width\t\t\t\t= 48;\n\t\t\tlevelMenuInfo.item_awards[count].height\t\t\t\t= 48;\n\t\t\tcount++;\n\t\t}\n\t}\n\n\tlevelMenuInfo.item_back.generic.type\t\t\t= MTYPE_BITMAP;\n\tlevelMenuInfo.item_back.generic.name\t\t\t= ART_BACK0;\n\tlevelMenuInfo.item_back.generic.flags\t\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tlevelMenuInfo.item_back.generic.x\t\t\t\t= 0;\n\tlevelMenuInfo.item_back.generic.y\t\t\t\t= 480-64;\n\tlevelMenuInfo.item_back.generic.callback\t\t= UI_SPLevelMenu_BackEvent;\n\tlevelMenuInfo.item_back.generic.id\t\t\t\t= ID_BACK;\n\tlevelMenuInfo.item_back.width\t\t\t\t\t= 128;\n\tlevelMenuInfo.item_back.height\t\t\t\t\t= 64;\n\tlevelMenuInfo.item_back.focuspic\t\t\t\t= ART_BACK1;\n\n\tlevelMenuInfo.item_reset.generic.type\t\t\t= MTYPE_BITMAP;\n\tlevelMenuInfo.item_reset.generic.name\t\t\t= ART_RESET0;\n\tlevelMenuInfo.item_reset.generic.flags\t\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tlevelMenuInfo.item_reset.generic.x\t\t\t\t= 170;\n\tlevelMenuInfo.item_reset.generic.y\t\t\t\t= 480-64;\n\tlevelMenuInfo.item_reset.generic.callback\t\t= UI_SPLevelMenu_ResetEvent;\n\tlevelMenuInfo.item_reset.generic.id\t\t\t\t= ID_RESET;\n\tlevelMenuInfo.item_reset.width\t\t\t\t\t= 128;\n\tlevelMenuInfo.item_reset.height\t\t\t\t\t= 64;\n\tlevelMenuInfo.item_reset.focuspic\t\t\t\t= ART_RESET1;\n\n\tlevelMenuInfo.item_custom.generic.type\t\t\t= MTYPE_BITMAP;\n\tlevelMenuInfo.item_custom.generic.name\t\t\t= ART_CUSTOM0;\n\tlevelMenuInfo.item_custom.generic.flags\t\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tlevelMenuInfo.item_custom.generic.x\t\t\t\t= 342;\n\tlevelMenuInfo.item_custom.generic.y\t\t\t\t= 480-64;\n\tlevelMenuInfo.item_custom.generic.callback\t\t= UI_SPLevelMenu_CustomEvent;\n\tlevelMenuInfo.item_custom.generic.id\t\t\t= ID_CUSTOM;\n\tlevelMenuInfo.item_custom.width\t\t\t\t\t= 128;\n\tlevelMenuInfo.item_custom.height\t\t\t\t= 64;\n\tlevelMenuInfo.item_custom.focuspic\t\t\t\t= ART_CUSTOM1;\n\n\tlevelMenuInfo.item_next.generic.type\t\t\t= MTYPE_BITMAP;\n\tlevelMenuInfo.item_next.generic.name\t\t\t= ART_FIGHT0;\n\tlevelMenuInfo.item_next.generic.flags\t\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tlevelMenuInfo.item_next.generic.x\t\t\t\t= 640;\n\tlevelMenuInfo.item_next.generic.y\t\t\t\t= 480-64;\n\tlevelMenuInfo.item_next.generic.callback\t\t= UI_SPLevelMenu_NextEvent;\n\tlevelMenuInfo.item_next.generic.id\t\t\t\t= ID_NEXT;\n\tlevelMenuInfo.item_next.width\t\t\t\t\t= 128;\n\tlevelMenuInfo.item_next.height\t\t\t\t\t= 64;\n\tlevelMenuInfo.item_next.focuspic\t\t\t\t= ART_FIGHT1;\n\n\tlevelMenuInfo.item_null.generic.type\t\t\t= MTYPE_BITMAP;\n\tlevelMenuInfo.item_null.generic.flags\t\t\t= QMF_LEFT_JUSTIFY|QMF_MOUSEONLY|QMF_SILENT;\n\tlevelMenuInfo.item_null.generic.x\t\t\t\t= 0;\n\tlevelMenuInfo.item_null.generic.y\t\t\t\t= 0;\n\tlevelMenuInfo.item_null.width\t\t\t\t\t= 640;\n\tlevelMenuInfo.item_null.height\t\t\t\t\t= 480;\n\n\tMenu_AddItem( &levelMenuInfo.menu, &levelMenuInfo.item_banner );\n\n\tMenu_AddItem( &levelMenuInfo.menu, &levelMenuInfo.item_leftarrow );\n\tMenu_AddItem( &levelMenuInfo.menu, &levelMenuInfo.item_maps[0] );\n\tMenu_AddItem( &levelMenuInfo.menu, &levelMenuInfo.item_maps[1] );\n\tMenu_AddItem( &levelMenuInfo.menu, &levelMenuInfo.item_maps[2] );\n\tMenu_AddItem( &levelMenuInfo.menu, &levelMenuInfo.item_maps[3] );\n\tlevelMenuInfo.item_maps[0].generic.bottom += 18;\n\tlevelMenuInfo.item_maps[1].generic.bottom += 18;\n\tlevelMenuInfo.item_maps[2].generic.bottom += 18;\n\tlevelMenuInfo.item_maps[3].generic.bottom += 18;\n\tMenu_AddItem( &levelMenuInfo.menu, &levelMenuInfo.item_rightarrow );\n\n\tMenu_AddItem( &levelMenuInfo.menu, &levelMenuInfo.item_player );\n\n\tfor( n = 0; n < count; n++ ) {\n\t\tMenu_AddItem( &levelMenuInfo.menu, &levelMenuInfo.item_awards[n] );\n\t}\n\tMenu_AddItem( &levelMenuInfo.menu, &levelMenuInfo.item_back );\n\tMenu_AddItem( &levelMenuInfo.menu, &levelMenuInfo.item_reset );\n\tMenu_AddItem( &levelMenuInfo.menu, &levelMenuInfo.item_custom );\n\tMenu_AddItem( &levelMenuInfo.menu, &levelMenuInfo.item_next );\n\tMenu_AddItem( &levelMenuInfo.menu, &levelMenuInfo.item_null );\n\n\ttrap_Cvar_VariableStringBuffer( \"ui_spSelection\", buf, sizeof(buf) );\n\tif( *buf ) {\n\t\tn = atoi( buf );\n\t\tselectedArenaSet = n / ARENAS_PER_TIER;\n\t\tselectedArena = n % ARENAS_PER_TIER;\n\t}\n\telse {\n\t\tselectedArenaSet = currentSet;\n\t\tselectedArena = currentGame;\n\t}\n\n\tUI_SPLevelMenu_SetMenuItems();\n}\n\n\n/*\n=================\nUI_SPLevelMenu\n=================\n*/\nvoid UI_SPLevelMenu( void ) {\n\tint\t\t\tlevel;\n\tint\t\t\ttrainingLevel;\n\tconst char\t*arenaInfo;\n\n\ttrainingTier = -1;\n\tarenaInfo = UI_GetSpecialArenaInfo( \"training\" );\n\tif( arenaInfo ) {\n\t\tminTier = trainingTier;\n\t\ttrainingLevel = atoi( Info_ValueForKey( arenaInfo, \"num\" ) );\n\t}\n\telse {\n\t\tminTier = 0;\n\t\ttrainingLevel = -2;\n\t}\n\n\tfinalTier = UI_GetNumSPTiers();\n\tarenaInfo = UI_GetSpecialArenaInfo( \"final\" );\n\tif( arenaInfo ) {\n\t\tmaxTier = finalTier;\n\t}\n\telse {\n\t\tmaxTier = finalTier - 1;\n\t\tif( maxTier < minTier ) {\n\t\t\tmaxTier = minTier;\n\t\t}\n\t}\n\n\tlevel = UI_GetCurrentGame();\n\tif ( level == -1 ) {\n\t\tlevel = UI_GetNumSPArenas() - 1;\n\t\tif( maxTier == finalTier ) {\n\t\t\tlevel++;\n\t\t}\n\t}\n\n\tif( level == trainingLevel ) {\n\t\tcurrentSet = -1;\n\t\tcurrentGame = 0;\n\t}\n\telse {\n\t\tcurrentSet = level / ARENAS_PER_TIER;\n\t\tcurrentGame = level % ARENAS_PER_TIER;\n\t}\n\n\tUI_SPLevelMenu_Init();\n\tUI_PushMenu( &levelMenuInfo.menu );\n\tMenu_SetCursorToItem( &levelMenuInfo.menu, &levelMenuInfo.item_next );\n}\n\n\n/*\n=================\nUI_SPLevelMenu_f\n=================\n*/\nvoid UI_SPLevelMenu_f( void ) {\n\ttrap_Key_SetCatcher( KEYCATCH_UI );\n\tuis.menusp = 0;\n\tUI_SPLevelMenu();\n}\n\n\n/*\n=================\nUI_SPLevelMenu_ReInit\n=================\n*/\nvoid UI_SPLevelMenu_ReInit( void ) {\n\tlevelMenuInfo.reinit = qtrue;\n}\n"
  },
  {
    "path": "code/q3_ui/ui_sppostgame.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=============================================================================\n\nSINGLE PLAYER POSTGAME MENU\n\n=============================================================================\n*/\n\n#include \"ui_local.h\"\n\n#define MAX_SCOREBOARD_CLIENTS\t\t8\n\n#define AWARD_PRESENTATION_TIME\t\t2000\n\n#define ART_MENU0\t\t\"menu/art/menu_0\"\n#define ART_MENU1\t\t\"menu/art/menu_1\"\n#define ART_REPLAY0\t\t\"menu/art/replay_0\"\n#define ART_REPLAY1\t\t\"menu/art/replay_1\"\n#define ART_NEXT0\t\t\"menu/art/next_0\"\n#define ART_NEXT1\t\t\"menu/art/next_1\"\n\n#define ID_AGAIN\t\t10\n#define ID_NEXT\t\t\t11\n#define ID_MENU\t\t\t12\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n\tmenubitmap_s\titem_again;\n\tmenubitmap_s\titem_next;\n\tmenubitmap_s\titem_menu;\n\n\tint\t\t\t\tphase;\n\tint\t\t\t\tignoreKeysTime;\n\tint\t\t\t\tstarttime;\n\tint\t\t\t\tscoreboardtime;\n\tint\t\t\t\tserverId;\n\n\tint\t\t\t\tclientNums[MAX_SCOREBOARD_CLIENTS];\n\tint\t\t\t\tranks[MAX_SCOREBOARD_CLIENTS];\n\tint\t\t\t\tscores[MAX_SCOREBOARD_CLIENTS];\n\n\tchar\t\t\tplaceNames[3][64];\n\n\tint\t\t\t\tlevel;\n\tint\t\t\t\tnumClients;\n\tint\t\t\t\twon;\n\tint\t\t\t\tnumAwards;\n\tint\t\t\t\tawardsEarned[6];\n\tint\t\t\t\tawardsLevels[6];\n\tqboolean\t\tplayedSound[6];\n\tint\t\t\t\tlastTier;\n\tsfxHandle_t\t\twinnerSound;\n} postgameMenuInfo_t;\n\nstatic postgameMenuInfo_t\tpostgameMenuInfo;\nstatic char\t\t\t\t\tarenainfo[MAX_INFO_VALUE];\n\nchar\t*ui_medalNames[] = {\"Accuracy\", \"Impressive\", \"Excellent\", \"Gauntlet\", \"Frags\", \"Perfect\"};\nchar\t*ui_medalPicNames[] = {\n\t\"menu/medals/medal_accuracy\",\n\t\"menu/medals/medal_impressive\",\n\t\"menu/medals/medal_excellent\",\n\t\"menu/medals/medal_gauntlet\",\n\t\"menu/medals/medal_frags\",\n\t\"menu/medals/medal_victory\"\n};\nchar\t*ui_medalSounds[] = {\n\t\"sound/feedback/accuracy.wav\",\n\t\"sound/feedback/impressive_a.wav\",\n\t\"sound/feedback/excellent_a.wav\",\n\t\"sound/feedback/gauntlet.wav\",\n\t\"sound/feedback/frags.wav\",\n\t\"sound/feedback/perfect.wav\"\n};\n\n\n/*\n=================\nUI_SPPostgameMenu_AgainEvent\n=================\n*/\nstatic void UI_SPPostgameMenu_AgainEvent( void* ptr, int event )\n{\n\tif (event != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\tUI_PopMenu();\n\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"map_restart 0\\n\" );\n}\n\n\n/*\n=================\nUI_SPPostgameMenu_NextEvent\n=================\n*/\nstatic void UI_SPPostgameMenu_NextEvent( void* ptr, int event ) {\n\tint\t\t\tcurrentSet;\n\tint\t\t\tlevelSet;\n\tint\t\t\tlevel;\n\tint\t\t\tcurrentLevel;\n\tconst char\t*arenaInfo;\n\n\tif (event != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\tUI_PopMenu();\n\n\t// handle specially if we just won the training map\n\tif( postgameMenuInfo.won == 0 ) {\n\t\tlevel = 0;\n\t}\n\telse {\n\t\tlevel = postgameMenuInfo.level + 1;\n\t}\n\tlevelSet = level / ARENAS_PER_TIER;\n\n\tcurrentLevel = UI_GetCurrentGame();\n\tif( currentLevel == -1 ) {\n\t\tcurrentLevel = postgameMenuInfo.level;\n\t}\n\tcurrentSet = currentLevel / ARENAS_PER_TIER;\n\n\tif( levelSet > currentSet || levelSet == UI_GetNumSPTiers() ) {\n\t\tlevel = currentLevel;\n\t}\n\n\tarenaInfo = UI_GetArenaInfoByNumber( level );\n\tif ( !arenaInfo ) {\n\t\treturn;\n\t}\n\n\tUI_SPArena_Start( arenaInfo );\n}\n\n\n/*\n=================\nUI_SPPostgameMenu_MenuEvent\n=================\n*/\nstatic void UI_SPPostgameMenu_MenuEvent( void* ptr, int event )\n{\n\tif (event != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\tUI_PopMenu();\n\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"disconnect; levelselect\\n\" );\n}\n\n\n/*\n=================\nUI_SPPostgameMenu_MenuKey\n=================\n*/\nstatic sfxHandle_t UI_SPPostgameMenu_MenuKey( int key ) {\n\tif ( uis.realtime < postgameMenuInfo.ignoreKeysTime ) {\n\t\treturn 0;\n\t}\n\n\tif( postgameMenuInfo.phase == 1 ) {\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"abort_podium\\n\" );\n\t\tpostgameMenuInfo.phase = 2;\n\t\tpostgameMenuInfo.starttime = uis.realtime;\n\t\tpostgameMenuInfo.ignoreKeysTime\t= uis.realtime + 250;\n\t\treturn 0;\n\t}\n\n\tif( postgameMenuInfo.phase == 2 ) {\n\t\tpostgameMenuInfo.phase = 3;\n\t\tpostgameMenuInfo.starttime = uis.realtime;\n\t\tpostgameMenuInfo.ignoreKeysTime\t= uis.realtime + 250;\n\t\treturn 0;\n\t}\n\n\tif( key == K_ESCAPE || key == K_MOUSE2 ) {\n\t\treturn 0;\n\t}\n\n\treturn Menu_DefaultKey( &postgameMenuInfo.menu, key );\n}\n\n\nstatic int medalLocations[6] = {144, 448, 88, 504, 32, 560};\n\nstatic void UI_SPPostgameMenu_DrawAwardsMedals( int max ) {\n\tint\t\tn;\n\tint\t\tmedal;\n\tint\t\tamount;\n\tint\t\tx, y;\n\tchar\tbuf[16];\n\n\tfor( n = 0; n < max; n++ ) {\n\t\tx = medalLocations[n];\n\t\ty = 64;\n\t\tmedal = postgameMenuInfo.awardsEarned[n];\n\t\tamount = postgameMenuInfo.awardsLevels[n];\n\n\t\tUI_DrawNamedPic( x, y, 48, 48, ui_medalPicNames[medal] );\n\n\t\tif( medal == AWARD_ACCURACY ) {\n\t\t\tCom_sprintf( buf, sizeof(buf), \"%i%%\", amount );\n\t\t}\n\t\telse {\n\t\t\tif( amount == 1 ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tCom_sprintf( buf, sizeof(buf), \"%i\", amount );\n\t\t}\n\n\t\tUI_DrawString( x + 24, y + 52, buf, UI_CENTER, color_yellow );\n\t}\n}\n\n\nstatic void UI_SPPostgameMenu_DrawAwardsPresentation( int timer ) {\n\tint\t\tawardNum;\n\tint\t\tatimer;\n\tvec4_t\tcolor;\n\n\tawardNum = timer / AWARD_PRESENTATION_TIME;\n\tatimer = timer % AWARD_PRESENTATION_TIME;\n\n\tcolor[0] = color[1] = color[2] = 1.0f;\n\tcolor[3] = (float)( AWARD_PRESENTATION_TIME - atimer ) / (float)AWARD_PRESENTATION_TIME;\n\tUI_DrawProportionalString( 320, 64, ui_medalNames[postgameMenuInfo.awardsEarned[awardNum]], UI_CENTER, color );\n\n\tUI_SPPostgameMenu_DrawAwardsMedals( awardNum + 1 );\n\n\tif( !postgameMenuInfo.playedSound[awardNum] ) {\n\t\tpostgameMenuInfo.playedSound[awardNum] = qtrue;\n\t\ttrap_S_StartLocalSound( trap_S_RegisterSound( ui_medalSounds[postgameMenuInfo.awardsEarned[awardNum]], qfalse ), CHAN_ANNOUNCER );\n\t}\n}\n\n\n/*\n=================\nUI_SPPostgameMenu_MenuDrawScoreLine\n=================\n*/\nstatic void UI_SPPostgameMenu_MenuDrawScoreLine( int n, int y ) {\n\tint\t\trank;\n\tchar\tname[64];\n\tchar\tinfo[MAX_INFO_STRING];\n\n\tif( n > (postgameMenuInfo.numClients + 1) ) {\n\t\tn -= (postgameMenuInfo.numClients + 2);\n\t}\n\n\tif( n >= postgameMenuInfo.numClients ) {\n\t\treturn;\n\t}\n\n\trank = postgameMenuInfo.ranks[n];\n\tif( rank & RANK_TIED_FLAG ) {\n\t\tUI_DrawString( 640 - 31 * SMALLCHAR_WIDTH, y, \"(tie)\", UI_LEFT|UI_SMALLFONT, color_white );\n\t\trank &= ~RANK_TIED_FLAG;\n\t}\n\ttrap_GetConfigString( CS_PLAYERS + postgameMenuInfo.clientNums[n], info, MAX_INFO_STRING );\n\tQ_strncpyz( name, Info_ValueForKey( info, \"n\" ), sizeof(name) );\n\tQ_CleanStr( name );\n\n\tUI_DrawString( 640 - 25 * SMALLCHAR_WIDTH, y, va( \"#%i: %-16s %2i\", rank + 1, name, postgameMenuInfo.scores[n] ), UI_LEFT|UI_SMALLFONT, color_white );\n}\n\n\n/*\n=================\nUI_SPPostgameMenu_MenuDraw\n=================\n*/\nstatic void UI_SPPostgameMenu_MenuDraw( void ) {\n\tint\t\ttimer;\n\tint\t\tserverId;\n\tint\t\tn;\n\tchar\tinfo[MAX_INFO_STRING];\n\n\ttrap_GetConfigString( CS_SYSTEMINFO, info, sizeof(info) );\n\tserverId = atoi( Info_ValueForKey( info, \"sv_serverid\" ) );\n\tif( serverId != postgameMenuInfo.serverId ) {\n\t\tUI_PopMenu();\n\t\treturn;\n\t}\n\n\t// phase 1\n\tif ( postgameMenuInfo.numClients > 2 ) {\n\t\tUI_DrawProportionalString( 510, 480 - 64 - PROP_HEIGHT, postgameMenuInfo.placeNames[2], UI_CENTER, color_white );\n\t}\n\tUI_DrawProportionalString( 130, 480 - 64 - PROP_HEIGHT, postgameMenuInfo.placeNames[1], UI_CENTER, color_white );\n\tUI_DrawProportionalString( 320, 480 - 64 - 2 * PROP_HEIGHT, postgameMenuInfo.placeNames[0], UI_CENTER, color_white );\n\n\tif( postgameMenuInfo.phase == 1 ) {\n\t\ttimer = uis.realtime - postgameMenuInfo.starttime;\n\n\t\tif( timer >= 1000 && postgameMenuInfo.winnerSound ) {\n\t\t\ttrap_S_StartLocalSound( postgameMenuInfo.winnerSound, CHAN_ANNOUNCER );\n\t\t\tpostgameMenuInfo.winnerSound = 0;\n\t\t}\n\n\t\tif( timer < 5000 ) {\n\t\t\treturn;\n\t\t}\n\t\tpostgameMenuInfo.phase = 2;\n\t\tpostgameMenuInfo.starttime = uis.realtime;\n\t}\n\n\t// phase 2\n\tif( postgameMenuInfo.phase == 2 ) {\n\t\ttimer = uis.realtime - postgameMenuInfo.starttime;\n\t\tif( timer >= ( postgameMenuInfo.numAwards * AWARD_PRESENTATION_TIME ) ) {\n\n\t\t\tif( timer < 5000 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tpostgameMenuInfo.phase = 3;\n\t\t\tpostgameMenuInfo.starttime = uis.realtime;\n\t\t}\n\t\telse {\n\t\t\tUI_SPPostgameMenu_DrawAwardsPresentation( timer );\n\t\t}\n\t}\n\n\t// phase 3\n\tif( postgameMenuInfo.phase == 3 ) {\n\t\tif( uis.demoversion ) {\n\t\t\tif( postgameMenuInfo.won == 1 && UI_ShowTierVideo( 8 )) {\n\t\t\t\ttrap_Cvar_Set( \"nextmap\", \"\" );\n\t\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"disconnect; cinematic demoEnd.RoQ\\n\" );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\telse if( postgameMenuInfo.won > -1 && UI_ShowTierVideo( postgameMenuInfo.won + 1 )) {\n\t\t\tif( postgameMenuInfo.won == postgameMenuInfo.lastTier ) {\n\t\t\t\ttrap_Cvar_Set( \"nextmap\", \"\" );\n\t\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"disconnect; cinematic end.RoQ\\n\" );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttrap_Cvar_SetValue( \"ui_spSelection\", postgameMenuInfo.won * ARENAS_PER_TIER );\n\t\t\ttrap_Cvar_Set( \"nextmap\", \"levelselect\" );\n\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va( \"disconnect; cinematic tier%i.RoQ\\n\", postgameMenuInfo.won + 1 ) );\n\t\t\treturn;\n\t\t}\n\n\t\tpostgameMenuInfo.item_again.generic.flags &= ~QMF_INACTIVE;\n\t\tpostgameMenuInfo.item_next.generic.flags &= ~QMF_INACTIVE;\n\t\tpostgameMenuInfo.item_menu.generic.flags &= ~QMF_INACTIVE;\n\n\t\tUI_SPPostgameMenu_DrawAwardsMedals( postgameMenuInfo.numAwards );\n\n\t\tMenu_Draw( &postgameMenuInfo.menu );\n\t}\n\n\t// draw the scoreboard\n\tif( !trap_Cvar_VariableValue( \"ui_spScoreboard\" ) ) {\n\t\treturn;\n\t}\n\n\ttimer = uis.realtime - postgameMenuInfo.scoreboardtime;\n\tif( postgameMenuInfo.numClients <= 3 ) {\n\t\tn = 0;\n\t}\n\telse {\n\t\tn = timer / 1500 % (postgameMenuInfo.numClients + 2);\n\t}\n\tUI_SPPostgameMenu_MenuDrawScoreLine( n, 0 );\n\tUI_SPPostgameMenu_MenuDrawScoreLine( n + 1, 0 + SMALLCHAR_HEIGHT );\n\tUI_SPPostgameMenu_MenuDrawScoreLine( n + 2, 0 + 2 * SMALLCHAR_HEIGHT );\n}\n\n\n/*\n=================\nUI_SPPostgameMenu_Cache\n=================\n*/\nvoid UI_SPPostgameMenu_Cache( void ) {\n\tint\t\t\tn;\n\tqboolean\tbuildscript;\n\n\tbuildscript = trap_Cvar_VariableValue(\"com_buildscript\");\n\n\ttrap_R_RegisterShaderNoMip( ART_MENU0 );\n\ttrap_R_RegisterShaderNoMip( ART_MENU1 );\n\ttrap_R_RegisterShaderNoMip( ART_REPLAY0 );\n\ttrap_R_RegisterShaderNoMip( ART_REPLAY1 );\n\ttrap_R_RegisterShaderNoMip( ART_NEXT0 );\n\ttrap_R_RegisterShaderNoMip( ART_NEXT1 );\n\tfor( n = 0; n < 6; n++ ) {\n\t\ttrap_R_RegisterShaderNoMip( ui_medalPicNames[n] );\n\t\ttrap_S_RegisterSound( ui_medalSounds[n], qfalse );\n\t}\n\n\tif( buildscript ) {\n\t\ttrap_S_RegisterSound( \"music/loss.wav\", qfalse );\n\t\ttrap_S_RegisterSound( \"music/win.wav\", qfalse );\n\t\ttrap_S_RegisterSound( \"sound/player/announce/youwin.wav\", qfalse );\n\t}\n}\n\n\n/*\n=================\nUI_SPPostgameMenu_Init\n=================\n*/\nstatic void UI_SPPostgameMenu_Init( void ) {\n\tpostgameMenuInfo.menu.wrapAround\t= qtrue;\n\tpostgameMenuInfo.menu.key\t\t\t= UI_SPPostgameMenu_MenuKey;\n\tpostgameMenuInfo.menu.draw\t\t\t= UI_SPPostgameMenu_MenuDraw;\n\tpostgameMenuInfo.ignoreKeysTime\t\t= uis.realtime + 1500;\n\n\tUI_SPPostgameMenu_Cache();\n\n\tpostgameMenuInfo.item_menu.generic.type\t\t\t= MTYPE_BITMAP;\n\tpostgameMenuInfo.item_menu.generic.name\t\t\t= ART_MENU0;\n\tpostgameMenuInfo.item_menu.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_INACTIVE;\n\tpostgameMenuInfo.item_menu.generic.x\t\t\t= 0;\n\tpostgameMenuInfo.item_menu.generic.y\t\t\t= 480-64;\n\tpostgameMenuInfo.item_menu.generic.callback\t\t= UI_SPPostgameMenu_MenuEvent;\n\tpostgameMenuInfo.item_menu.generic.id\t\t\t= ID_MENU;\n\tpostgameMenuInfo.item_menu.width\t\t\t\t= 128;\n\tpostgameMenuInfo.item_menu.height\t\t\t\t= 64;\n\tpostgameMenuInfo.item_menu.focuspic\t\t\t\t= ART_MENU1;\n\n\tpostgameMenuInfo.item_again.generic.type\t\t= MTYPE_BITMAP;\n\tpostgameMenuInfo.item_again.generic.name\t\t= ART_REPLAY0;\n\tpostgameMenuInfo.item_again.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS|QMF_INACTIVE;\n\tpostgameMenuInfo.item_again.generic.x\t\t\t= 320;\n\tpostgameMenuInfo.item_again.generic.y\t\t\t= 480-64;\n\tpostgameMenuInfo.item_again.generic.callback\t= UI_SPPostgameMenu_AgainEvent;\n\tpostgameMenuInfo.item_again.generic.id\t\t\t= ID_AGAIN;\n\tpostgameMenuInfo.item_again.width\t\t\t\t= 128;\n\tpostgameMenuInfo.item_again.height\t\t\t\t= 64;\n\tpostgameMenuInfo.item_again.focuspic\t\t\t= ART_REPLAY1;\n\n\tpostgameMenuInfo.item_next.generic.type\t\t\t= MTYPE_BITMAP;\n\tpostgameMenuInfo.item_next.generic.name\t\t\t= ART_NEXT0;\n\tpostgameMenuInfo.item_next.generic.flags\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_INACTIVE;\n\tpostgameMenuInfo.item_next.generic.x\t\t\t= 640;\n\tpostgameMenuInfo.item_next.generic.y\t\t\t= 480-64;\n\tpostgameMenuInfo.item_next.generic.callback\t\t= UI_SPPostgameMenu_NextEvent;\n\tpostgameMenuInfo.item_next.generic.id\t\t\t= ID_NEXT;\n\tpostgameMenuInfo.item_next.width\t\t\t\t= 128;\n\tpostgameMenuInfo.item_next.height\t\t\t\t= 64;\n\tpostgameMenuInfo.item_next.focuspic\t\t\t\t= ART_NEXT1;\n\n\tMenu_AddItem( &postgameMenuInfo.menu, ( void * )&postgameMenuInfo.item_menu );\n\tMenu_AddItem( &postgameMenuInfo.menu, ( void * )&postgameMenuInfo.item_again );\n\tMenu_AddItem( &postgameMenuInfo.menu, ( void * )&postgameMenuInfo.item_next );\n}\n\n\nstatic void Prepname( int index ) {\n\tint\t\tlen;\n\tchar\tname[64];\n\tchar\tinfo[MAX_INFO_STRING];\n\n\ttrap_GetConfigString( CS_PLAYERS + postgameMenuInfo.clientNums[index], info, MAX_INFO_STRING );\n\tQ_strncpyz( name, Info_ValueForKey( info, \"n\" ), sizeof(name) );\n\tQ_CleanStr( name );\n\tlen = strlen( name );\n\n\twhile( len && UI_ProportionalStringWidth( name ) > 256 ) {\n\t\tlen--;\n\t\tname[len] = 0;\n\t}\n\n\tQ_strncpyz( postgameMenuInfo.placeNames[index], name, sizeof(postgameMenuInfo.placeNames[index]) );\n}\n\n\n/*\n=================\nUI_SPPostgameMenu_f\n=================\n*/\nvoid UI_SPPostgameMenu_f( void ) {\n\tint\t\t\tplayerGameRank;\n\tint\t\t\tplayerClientNum;\n\tint\t\t\tn;\n\tint\t\t\toldFrags, newFrags;\n\tconst char\t*arena;\n\tint\t\t\tawardValues[6];\n\tchar\t\tmap[MAX_QPATH];\n\tchar\t\tinfo[MAX_INFO_STRING];\n\n\tmemset( &postgameMenuInfo, 0, sizeof(postgameMenuInfo) );\n\n\ttrap_GetConfigString( CS_SYSTEMINFO, info, sizeof(info) );\n\tpostgameMenuInfo.serverId = atoi( Info_ValueForKey( info, \"sv_serverid\" ) );\n\n\ttrap_GetConfigString( CS_SERVERINFO, info, sizeof(info) );\n\tQ_strncpyz( map, Info_ValueForKey( info, \"mapname\" ), sizeof(map) );\n\tarena = UI_GetArenaInfoByMap( map );\n\tif ( !arena ) {\n\t\treturn;\n\t}\n\tQ_strncpyz( arenainfo, arena, sizeof(arenainfo) );\n\n\tpostgameMenuInfo.level = atoi( Info_ValueForKey( arenainfo, \"num\" ) );\n\n\tpostgameMenuInfo.numClients = atoi( UI_Argv( 1 ) );\n\tplayerClientNum = atoi( UI_Argv( 2 ) );\n\tplayerGameRank = 8;\t\t// in case they ended game as a spectator\n\n\tif( postgameMenuInfo.numClients > MAX_SCOREBOARD_CLIENTS ) {\n\t\tpostgameMenuInfo.numClients = MAX_SCOREBOARD_CLIENTS;\n\t}\n\n\tfor( n = 0; n < postgameMenuInfo.numClients; n++ ) {\n\t\tpostgameMenuInfo.clientNums[n] = atoi( UI_Argv( 8 + n * 3 + 1 ) );\n\t\tpostgameMenuInfo.ranks[n] = atoi( UI_Argv( 8 + n * 3 + 2 ) );\n\t\tpostgameMenuInfo.scores[n] = atoi( UI_Argv( 8 + n * 3 + 3 ) );\n\n\t\tif( postgameMenuInfo.clientNums[n] == playerClientNum ) {\n\t\t\tplayerGameRank = (postgameMenuInfo.ranks[n] & ~RANK_TIED_FLAG) + 1;\n\t\t}\n\t}\n\n\tUI_SetBestScore( postgameMenuInfo.level, playerGameRank );\n\n\t// process award stats and prepare presentation data\n\tawardValues[AWARD_ACCURACY] = atoi( UI_Argv( 3 ) );\n\tawardValues[AWARD_IMPRESSIVE] = atoi( UI_Argv( 4 ) );\n\tawardValues[AWARD_EXCELLENT] = atoi( UI_Argv( 5 ) );\n\tawardValues[AWARD_GAUNTLET] = atoi( UI_Argv( 6 ) );\n\tawardValues[AWARD_FRAGS] = atoi( UI_Argv( 7 ) );\n\tawardValues[AWARD_PERFECT] = atoi( UI_Argv( 8 ) );\n\n\tpostgameMenuInfo.numAwards = 0;\n\n\tif( awardValues[AWARD_ACCURACY] >= 50 ) {\n\t\tUI_LogAwardData( AWARD_ACCURACY, 1 );\n\t\tpostgameMenuInfo.awardsEarned[postgameMenuInfo.numAwards] = AWARD_ACCURACY;\n\t\tpostgameMenuInfo.awardsLevels[postgameMenuInfo.numAwards] = awardValues[AWARD_ACCURACY];\n\t\tpostgameMenuInfo.numAwards++;\n\t}\n\n\tif( awardValues[AWARD_IMPRESSIVE] ) {\n\t\tUI_LogAwardData( AWARD_IMPRESSIVE, awardValues[AWARD_IMPRESSIVE] );\n\t\tpostgameMenuInfo.awardsEarned[postgameMenuInfo.numAwards] = AWARD_IMPRESSIVE;\n\t\tpostgameMenuInfo.awardsLevels[postgameMenuInfo.numAwards] = awardValues[AWARD_IMPRESSIVE];\n\t\tpostgameMenuInfo.numAwards++;\n\t}\n\n\tif( awardValues[AWARD_EXCELLENT] ) {\n\t\tUI_LogAwardData( AWARD_EXCELLENT, awardValues[AWARD_EXCELLENT] );\n\t\tpostgameMenuInfo.awardsEarned[postgameMenuInfo.numAwards] = AWARD_EXCELLENT;\n\t\tpostgameMenuInfo.awardsLevels[postgameMenuInfo.numAwards] = awardValues[AWARD_EXCELLENT];\n\t\tpostgameMenuInfo.numAwards++;\n\t}\n\n\tif( awardValues[AWARD_GAUNTLET] ) {\n\t\tUI_LogAwardData( AWARD_GAUNTLET, awardValues[AWARD_GAUNTLET] );\n\t\tpostgameMenuInfo.awardsEarned[postgameMenuInfo.numAwards] = AWARD_GAUNTLET;\n\t\tpostgameMenuInfo.awardsLevels[postgameMenuInfo.numAwards] = awardValues[AWARD_GAUNTLET];\n\t\tpostgameMenuInfo.numAwards++;\n\t}\n\n\toldFrags = UI_GetAwardLevel( AWARD_FRAGS ) / 100;\n\tUI_LogAwardData( AWARD_FRAGS, awardValues[AWARD_FRAGS] );\n\tnewFrags = UI_GetAwardLevel( AWARD_FRAGS ) / 100;\n\tif( newFrags > oldFrags ) {\n\t\tpostgameMenuInfo.awardsEarned[postgameMenuInfo.numAwards] = AWARD_FRAGS;\n\t\tpostgameMenuInfo.awardsLevels[postgameMenuInfo.numAwards] = newFrags * 100;\n\t\tpostgameMenuInfo.numAwards++;\n\t}\n\n\tif( awardValues[AWARD_PERFECT] ) {\n\t\tUI_LogAwardData( AWARD_PERFECT, 1 );\n\t\tpostgameMenuInfo.awardsEarned[postgameMenuInfo.numAwards] = AWARD_PERFECT;\n\t\tpostgameMenuInfo.awardsLevels[postgameMenuInfo.numAwards] = 1;\n\t\tpostgameMenuInfo.numAwards++;\n\t}\n\n\tif ( playerGameRank == 1 ) {\n\t\tpostgameMenuInfo.won = UI_TierCompleted( postgameMenuInfo.level );\n\t}\n\telse {\n\t\tpostgameMenuInfo.won = -1;\n\t}\n\n\tpostgameMenuInfo.starttime = uis.realtime;\n\tpostgameMenuInfo.scoreboardtime = uis.realtime;\n\n\ttrap_Key_SetCatcher( KEYCATCH_UI );\n\tuis.menusp = 0;\n\n\tUI_SPPostgameMenu_Init();\n\tUI_PushMenu( &postgameMenuInfo.menu );\n\n\tif ( playerGameRank == 1 ) {\n\t\tMenu_SetCursorToItem( &postgameMenuInfo.menu, &postgameMenuInfo.item_next );\n\t}\n\telse {\n\t\tMenu_SetCursorToItem( &postgameMenuInfo.menu, &postgameMenuInfo.item_again );\n\t}\n\n\tPrepname( 0 );\n\tPrepname( 1 );\n\tPrepname( 2 );\n\n\tif ( playerGameRank != 1 ) {\n\t\tpostgameMenuInfo.winnerSound = trap_S_RegisterSound( va( \"sound/player/announce/%s_wins.wav\", postgameMenuInfo.placeNames[0] ), qfalse );\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"music music/loss\\n\" );\n\t}\n\telse {\n\t\tpostgameMenuInfo.winnerSound = trap_S_RegisterSound( \"sound/player/announce/youwin.wav\", qfalse );\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"music music/win\\n\" );\n\t}\n\n\tpostgameMenuInfo.phase = 1;\n\n\tpostgameMenuInfo.lastTier = UI_GetNumSPTiers();\n\tif ( UI_GetSpecialArenaInfo( \"final\" ) ) {\n\t\tpostgameMenuInfo.lastTier++;\n\t}\n}\n"
  },
  {
    "path": "code/q3_ui/ui_spreset.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n/*\n=======================================================================\n\nRESET MENU\n\n=======================================================================\n*/\n\n#include \"ui_local.h\"\n\n\n#define ART_FRAME\t\t\t\t\t\"menu/art/cut_frame\"\n\n#define ID_NO\t\t100\n#define ID_YES\t\t101\n\ntypedef struct\n{\n\tmenuframework_s menu;\n\tmenutext_s\t\tno;\n\tmenutext_s\t\tyes;\n\tint\t\t\t\tslashX;\n} resetMenu_t;\n\nstatic resetMenu_t\ts_reset;\n\n\n/*\n=================\nReset_MenuEvent\n=================\n*/\nvoid Reset_MenuEvent(void* ptr, int event) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tUI_PopMenu();\n\n\tif( ((menucommon_s*)ptr)->id == ID_NO ) {\n\t\treturn;\n\t}\n\n\t// reset the game, pop the level menu and restart it so it updates\n\tUI_NewGame();\n\ttrap_Cvar_SetValue( \"ui_spSelection\", 0 );\n\tUI_PopMenu();\n\tUI_SPLevelMenu();\n}\n\n\n/*\n=================\nReset_MenuKey\n=================\n*/\nstatic sfxHandle_t Reset_MenuKey( int key ) {\n\tswitch ( key ) {\n\tcase K_KP_LEFTARROW:\n\tcase K_LEFTARROW:\n\tcase K_KP_RIGHTARROW:\n\tcase K_RIGHTARROW:\n\t\tkey = K_TAB;\n\t\tbreak;\n\n\tcase 'n':\n\tcase 'N':\n\t\tReset_MenuEvent( &s_reset.no, QM_ACTIVATED );\n\t\tbreak;\n\n\tcase 'y':\n\tcase 'Y':\n\t\tReset_MenuEvent( &s_reset.yes, QM_ACTIVATED );\n\t\tbreak;\n\t}\n\n\treturn Menu_DefaultKey( &s_reset.menu, key );\n}\n\n\n/*\n=================\nReset_MenuDraw\n=================\n*/\nstatic void Reset_MenuDraw( void ) {\n\tUI_DrawNamedPic( 142, 118, 359, 256, ART_FRAME );\n\tUI_DrawProportionalString( 320, 194 + 10, \"RESET GAME?\", UI_CENTER|UI_INVERSE, color_red );\n\tUI_DrawProportionalString( s_reset.slashX, 265, \"/\", UI_LEFT|UI_INVERSE, color_red );\n\tMenu_Draw( &s_reset.menu );\n\n\tUI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 0, \"WARNING: This resets all of the\", UI_CENTER|UI_SMALLFONT, color_yellow );\n\tUI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 1, \"single player game variables.\", UI_CENTER|UI_SMALLFONT, color_yellow );\n\tUI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 2, \"Do this only if you want to\", UI_CENTER|UI_SMALLFONT, color_yellow );\n\tUI_DrawProportionalString( SCREEN_WIDTH/2, 356 + PROP_HEIGHT * 3, \"start over from the beginning.\", UI_CENTER|UI_SMALLFONT, color_yellow );\n}\n\n\n/*\n=================\nReset_Cache\n=================\n*/\nvoid Reset_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( ART_FRAME );\n}\n\n\n/*\n=================\nUI_ResetMenu\n=================\n*/\nvoid UI_ResetMenu(void) {\n\tuiClientState_t\tcstate;\n\tint\tn1, n2, n3;\n\tint\tl1, l2, l3;\n\n\t// zero set all our globals\n\tmemset( &s_reset, 0, sizeof(s_reset) );\n\n\tReset_Cache();\n\n\tn1 = UI_ProportionalStringWidth( \"YES/NO\" );\n\tn2 = UI_ProportionalStringWidth( \"YES\" ) + PROP_GAP_WIDTH;\n\tn3 = UI_ProportionalStringWidth( \"/\" )  + PROP_GAP_WIDTH;\n\tl1 = 320 - ( n1 / 2 );\n\tl2 = l1 + n2;\n\tl3 = l2 + n3;\n\ts_reset.slashX = l2;\n\n\ts_reset.menu.draw       = Reset_MenuDraw;\n\ts_reset.menu.key        = Reset_MenuKey;\n\ts_reset.menu.wrapAround = qtrue;\n\n\ttrap_GetClientState( &cstate );\n\n\tif ( cstate.connState >= CA_CONNECTED ) {\n\t\t// float on top of running game\n\t\ts_reset.menu.fullscreen = qfalse;\n\t}\n\telse {\n\t\t// game not running\n\t\ts_reset.menu.fullscreen = qtrue;\n\t}\n\n\ts_reset.yes.generic.type\t\t= MTYPE_PTEXT;      \n\ts_reset.yes.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; \n\ts_reset.yes.generic.callback\t= Reset_MenuEvent;\n\ts_reset.yes.generic.id\t\t\t= ID_YES;\n\ts_reset.yes.generic.x\t\t\t= l1;\n\ts_reset.yes.generic.y\t\t\t= 264;\n\ts_reset.yes.string\t\t\t\t= \"YES\";\n\ts_reset.yes.color\t\t\t\t= color_red;\n\ts_reset.yes.style\t\t\t\t= UI_LEFT;\n\n\ts_reset.no.generic.type\t\t\t= MTYPE_PTEXT;      \n\ts_reset.no.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; \n\ts_reset.no.generic.callback\t\t= Reset_MenuEvent;\n\ts_reset.no.generic.id\t\t\t= ID_NO;\n\ts_reset.no.generic.x\t\t    = l3;\n\ts_reset.no.generic.y\t\t    = 264;\n\ts_reset.no.string\t\t\t\t= \"NO\";\n\ts_reset.no.color\t\t\t    = color_red;\n\ts_reset.no.style\t\t\t    = UI_LEFT;\n\n\tMenu_AddItem( &s_reset.menu,\t&s_reset.yes );             \n\tMenu_AddItem( &s_reset.menu,\t&s_reset.no );\n\n\tUI_PushMenu( &s_reset.menu );\n\n\tMenu_SetCursorToItem( &s_reset.menu, &s_reset.no );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_spskill.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=============================================================================\n\nSINGLE PLAYER SKILL MENU\n\n=============================================================================\n*/\n\n#include \"ui_local.h\"\n\n\n#define ART_FRAME\t\t\t\t\t\"menu/art/cut_frame\"\n#define ART_BACK\t\t\t\t\t\"menu/art/back_0.tga\"\n#define ART_BACK_FOCUS\t\t\t\t\"menu/art/back_1.tga\"\n#define ART_FIGHT\t\t\t\t\t\"menu/art/fight_0\"\n#define ART_FIGHT_FOCUS\t\t\t\t\"menu/art/fight_1\"\n#define ART_MAP_COMPLETE1\t\t\t\"menu/art/level_complete1\"\n#define ART_MAP_COMPLETE2\t\t\t\"menu/art/level_complete2\"\n#define ART_MAP_COMPLETE3\t\t\t\"menu/art/level_complete3\"\n#define ART_MAP_COMPLETE4\t\t\t\"menu/art/level_complete4\"\n#define ART_MAP_COMPLETE5\t\t\t\"menu/art/level_complete5\"\n\n#define ID_BABY\t\t\t\t\t\t10\n#define ID_EASY\t\t\t\t\t\t11\n#define ID_MEDIUM\t\t\t\t\t12\n#define ID_HARD\t\t\t\t\t\t13\n#define ID_NIGHTMARE\t\t\t\t14\n#define ID_BACK\t\t\t\t\t\t15\n#define ID_FIGHT\t\t\t\t\t16\n\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n\n\tmenubitmap_s\tart_frame;\n\tmenutext_s\t\tart_banner;\n\n\tmenutext_s\t\titem_baby;\n\tmenutext_s\t\titem_easy;\n\tmenutext_s\t\titem_medium;\n\tmenutext_s\t\titem_hard;\n\tmenutext_s\t\titem_nightmare;\n\n\tmenubitmap_s\tart_skillPic;\n\tmenubitmap_s\titem_back;\n\tmenubitmap_s\titem_fight;\n\n\tconst char\t\t*arenaInfo;\n\tqhandle_t\t\tskillpics[5];\n\tsfxHandle_t\t\tnightmareSound;\n\tsfxHandle_t\t\tsilenceSound;\n} skillMenuInfo_t;\n\nstatic skillMenuInfo_t\tskillMenuInfo;\n\n\nstatic void SetSkillColor( int skill, vec4_t color ) {\n\tswitch( skill ) {\n\tcase 1:\n\t\tskillMenuInfo.item_baby.color = color;\n\t\tbreak;\n\tcase 2:\n\t\tskillMenuInfo.item_easy.color = color;\n\t\tbreak;\n\tcase 3:\n\t\tskillMenuInfo.item_medium.color = color;\n\t\tbreak;\n\tcase 4:\n\t\tskillMenuInfo.item_hard.color = color;\n\t\tbreak;\n\tcase 5:\n\t\tskillMenuInfo.item_nightmare.color = color;\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n}\n\n\n/*\n=================\nUI_SPSkillMenu_SkillEvent\n=================\n*/\nstatic void UI_SPSkillMenu_SkillEvent( void *ptr, int notification ) {\n\tint\t\tid;\n\tint\t\tskill;\n\n\tif (notification != QM_ACTIVATED)\n\t\treturn;\n\n\tSetSkillColor( (int)trap_Cvar_VariableValue( \"g_spSkill\" ), color_red );\n\n\tid = ((menucommon_s*)ptr)->id;\n\tskill = id - ID_BABY + 1;\n\ttrap_Cvar_SetValue( \"g_spSkill\", skill );\n\n\tSetSkillColor( skill, color_white );\n\tskillMenuInfo.art_skillPic.shader = skillMenuInfo.skillpics[skill - 1];\n\n\tif( id == ID_NIGHTMARE ) {\n\t\ttrap_S_StartLocalSound( skillMenuInfo.nightmareSound, CHAN_ANNOUNCER );\n\t}\n\telse {\n\t\ttrap_S_StartLocalSound( skillMenuInfo.silenceSound, CHAN_ANNOUNCER );\n\t}\n}\n\n\n/*\n=================\nUI_SPSkillMenu_FightEvent\n=================\n*/\nstatic void UI_SPSkillMenu_FightEvent( void *ptr, int notification ) {\n\tif (notification != QM_ACTIVATED)\n\t\treturn;\n\n\tUI_SPArena_Start( skillMenuInfo.arenaInfo );\n}\n\n\n/*\n=================\nUI_SPSkillMenu_BackEvent\n=================\n*/\nstatic void UI_SPSkillMenu_BackEvent( void* ptr, int notification ) {\n\tif (notification != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\n\ttrap_S_StartLocalSound( skillMenuInfo.silenceSound, CHAN_ANNOUNCER );\n\tUI_PopMenu();\n}\n\n\n/*\n=================\nUI_SPSkillMenu_Key\n=================\n*/\nstatic sfxHandle_t UI_SPSkillMenu_Key( int key ) {\n\tif( key == K_MOUSE2 || key == K_ESCAPE ) {\n\t\ttrap_S_StartLocalSound( skillMenuInfo.silenceSound, CHAN_ANNOUNCER );\n\t}\n\treturn Menu_DefaultKey( &skillMenuInfo.menu, key );\n}\n\n\n/*\n=================\nUI_SPSkillMenu_Cache\n=================\n*/\nvoid UI_SPSkillMenu_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( ART_FRAME );\n\ttrap_R_RegisterShaderNoMip( ART_BACK );\n\ttrap_R_RegisterShaderNoMip( ART_BACK_FOCUS );\n\ttrap_R_RegisterShaderNoMip( ART_FIGHT );\n\ttrap_R_RegisterShaderNoMip( ART_FIGHT_FOCUS );\n\tskillMenuInfo.skillpics[0] = trap_R_RegisterShaderNoMip( ART_MAP_COMPLETE1 );\n\tskillMenuInfo.skillpics[1] = trap_R_RegisterShaderNoMip( ART_MAP_COMPLETE2 );\n\tskillMenuInfo.skillpics[2] = trap_R_RegisterShaderNoMip( ART_MAP_COMPLETE3 );\n\tskillMenuInfo.skillpics[3] = trap_R_RegisterShaderNoMip( ART_MAP_COMPLETE4 );\n\tskillMenuInfo.skillpics[4] = trap_R_RegisterShaderNoMip( ART_MAP_COMPLETE5 );\n\n\tskillMenuInfo.nightmareSound = trap_S_RegisterSound( \"sound/misc/nightmare.wav\", qfalse );\n\tskillMenuInfo.silenceSound = trap_S_RegisterSound( \"sound/misc/silence.wav\", qfalse );\n}\n\n\n/*\n=================\nUI_SPSkillMenu_Init\n=================\n*/\nstatic void UI_SPSkillMenu_Init( void ) {\n\tint\t\tskill;\n\n\tmemset( &skillMenuInfo, 0, sizeof(skillMenuInfo) );\n\tskillMenuInfo.menu.fullscreen = qtrue;\n\tskillMenuInfo.menu.key = UI_SPSkillMenu_Key;\n\n\tUI_SPSkillMenu_Cache();\n\n\tskillMenuInfo.art_frame.generic.type\t\t= MTYPE_BITMAP;\n\tskillMenuInfo.art_frame.generic.name\t\t= ART_FRAME;\n\tskillMenuInfo.art_frame.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_INACTIVE;\n\tskillMenuInfo.art_frame.generic.x\t\t\t= 142;\n\tskillMenuInfo.art_frame.generic.y\t\t\t= 118;\n\tskillMenuInfo.art_frame.width\t\t\t\t= 359;\n\tskillMenuInfo.art_frame.height\t\t\t\t= 256;\n\n\tskillMenuInfo.art_banner.generic.type\t\t= MTYPE_BTEXT;\n\tskillMenuInfo.art_banner.generic.flags\t\t= QMF_CENTER_JUSTIFY;\n\tskillMenuInfo.art_banner.generic.x\t\t\t= 320;\n\tskillMenuInfo.art_banner.generic.y\t\t\t= 16;\n\tskillMenuInfo.art_banner.string\t\t\t\t= \"DIFFICULTY\";\n\tskillMenuInfo.art_banner.color\t\t\t\t= color_white;\n\tskillMenuInfo.art_banner.style\t\t\t\t= UI_CENTER;\n\n\tskillMenuInfo.item_baby.generic.type\t\t= MTYPE_PTEXT;\n\tskillMenuInfo.item_baby.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\tskillMenuInfo.item_baby.generic.x\t\t\t= 320;\n\tskillMenuInfo.item_baby.generic.y\t\t\t= 170;\n\tskillMenuInfo.item_baby.generic.callback\t= UI_SPSkillMenu_SkillEvent;\n\tskillMenuInfo.item_baby.generic.id\t\t\t= ID_BABY;\n\tskillMenuInfo.item_baby.string\t\t\t\t= \"I Can Win\";\n\tskillMenuInfo.item_baby.color\t\t\t\t= color_red;\n\tskillMenuInfo.item_baby.style\t\t\t\t= UI_CENTER;\n\n\tskillMenuInfo.item_easy.generic.type\t\t= MTYPE_PTEXT;\n\tskillMenuInfo.item_easy.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\tskillMenuInfo.item_easy.generic.x\t\t\t= 320;\n\tskillMenuInfo.item_easy.generic.y\t\t\t= 198;\n\tskillMenuInfo.item_easy.generic.callback\t= UI_SPSkillMenu_SkillEvent;\n\tskillMenuInfo.item_easy.generic.id\t\t\t= ID_EASY;\n\tskillMenuInfo.item_easy.string\t\t\t\t= \"Bring It On\";\n\tskillMenuInfo.item_easy.color\t\t\t\t= color_red;\n\tskillMenuInfo.item_easy.style\t\t\t\t= UI_CENTER;\n\n\tskillMenuInfo.item_medium.generic.type\t\t= MTYPE_PTEXT;\n\tskillMenuInfo.item_medium.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\tskillMenuInfo.item_medium.generic.x\t\t\t= 320;\n\tskillMenuInfo.item_medium.generic.y\t\t\t= 227;\n\tskillMenuInfo.item_medium.generic.callback\t= UI_SPSkillMenu_SkillEvent;\n\tskillMenuInfo.item_medium.generic.id\t\t= ID_MEDIUM;\n\tskillMenuInfo.item_medium.string\t\t\t= \"Hurt Me Plenty\";\n\tskillMenuInfo.item_medium.color\t\t\t\t= color_red;\n\tskillMenuInfo.item_medium.style\t\t\t\t= UI_CENTER;\n\n\tskillMenuInfo.item_hard.generic.type\t\t= MTYPE_PTEXT;\n\tskillMenuInfo.item_hard.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\tskillMenuInfo.item_hard.generic.x\t\t\t= 320;\n\tskillMenuInfo.item_hard.generic.y\t\t\t= 255;\n\tskillMenuInfo.item_hard.generic.callback\t= UI_SPSkillMenu_SkillEvent;\n\tskillMenuInfo.item_hard.generic.id\t\t\t= ID_HARD;\n\tskillMenuInfo.item_hard.string\t\t\t\t= \"Hardcore\";\n\tskillMenuInfo.item_hard.color\t\t\t\t= color_red;\n\tskillMenuInfo.item_hard.style\t\t\t\t= UI_CENTER;\n\n\tskillMenuInfo.item_nightmare.generic.type\t\t= MTYPE_PTEXT;\n\tskillMenuInfo.item_nightmare.generic.flags\t\t= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\tskillMenuInfo.item_nightmare.generic.x\t\t\t= 320;\n\tskillMenuInfo.item_nightmare.generic.y\t\t\t= 283;\n\tskillMenuInfo.item_nightmare.generic.callback\t= UI_SPSkillMenu_SkillEvent;\n\tskillMenuInfo.item_nightmare.generic.id\t\t\t= ID_NIGHTMARE;\n\tskillMenuInfo.item_nightmare.string\t\t\t\t= \"NIGHTMARE!\";\n\tskillMenuInfo.item_nightmare.color\t\t\t\t= color_red;\n\tskillMenuInfo.item_nightmare.style\t\t\t\t= UI_CENTER;\n\n\tskillMenuInfo.item_back.generic.type\t\t= MTYPE_BITMAP;\n\tskillMenuInfo.item_back.generic.name\t\t= ART_BACK;\n\tskillMenuInfo.item_back.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tskillMenuInfo.item_back.generic.x\t\t\t= 0;\n\tskillMenuInfo.item_back.generic.y\t\t\t= 480-64;\n\tskillMenuInfo.item_back.generic.callback\t= UI_SPSkillMenu_BackEvent;\n\tskillMenuInfo.item_back.generic.id\t\t\t= ID_BACK;\n\tskillMenuInfo.item_back.width\t\t\t\t= 128;\n\tskillMenuInfo.item_back.height\t\t\t\t= 64;\n\tskillMenuInfo.item_back.focuspic\t\t\t= ART_BACK_FOCUS;\n\n\tskillMenuInfo.art_skillPic.generic.type\t\t= MTYPE_BITMAP;\n\tskillMenuInfo.art_skillPic.generic.flags\t= QMF_LEFT_JUSTIFY|QMF_INACTIVE;\n\tskillMenuInfo.art_skillPic.generic.x\t\t= 320-64;\n\tskillMenuInfo.art_skillPic.generic.y\t\t= 368;\n\tskillMenuInfo.art_skillPic.width\t\t\t= 128;\n\tskillMenuInfo.art_skillPic.height\t\t\t= 96;\n\n\tskillMenuInfo.item_fight.generic.type\t\t= MTYPE_BITMAP;\n\tskillMenuInfo.item_fight.generic.name\t\t= ART_FIGHT;\n\tskillMenuInfo.item_fight.generic.flags\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tskillMenuInfo.item_fight.generic.callback\t= UI_SPSkillMenu_FightEvent;\n\tskillMenuInfo.item_fight.generic.id\t\t\t= ID_FIGHT;\n\tskillMenuInfo.item_fight.generic.x\t\t\t= 640;\n\tskillMenuInfo.item_fight.generic.y\t\t\t= 480-64;\n\tskillMenuInfo.item_fight.width\t\t\t\t= 128;\n\tskillMenuInfo.item_fight.height\t\t\t\t= 64;\n\tskillMenuInfo.item_fight.focuspic\t\t\t= ART_FIGHT_FOCUS;\n\n\tMenu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.art_frame );\n\tMenu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.art_banner );\n\tMenu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.item_baby );\n\tMenu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.item_easy );\n\tMenu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.item_medium );\n\tMenu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.item_hard );\n\tMenu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.item_nightmare );\n\tMenu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.art_skillPic );\n\tMenu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.item_back );\n\tMenu_AddItem( &skillMenuInfo.menu, ( void * )&skillMenuInfo.item_fight );\n\n\tskill = (int)Com_Clamp( 1, 5, trap_Cvar_VariableValue( \"g_spSkill\" ) );\n\tSetSkillColor( skill, color_white );\n\tskillMenuInfo.art_skillPic.shader = skillMenuInfo.skillpics[skill - 1];\n\tif( skill == 5 ) {\n\t\ttrap_S_StartLocalSound( skillMenuInfo.nightmareSound, CHAN_ANNOUNCER );\n\t}\n}\n\n\nvoid UI_SPSkillMenu( const char *arenaInfo ) {\n\tUI_SPSkillMenu_Init();\n\tskillMenuInfo.arenaInfo = arenaInfo;\n\tUI_PushMenu( &skillMenuInfo.menu );\n\tMenu_SetCursorToItem( &skillMenuInfo.menu, &skillMenuInfo.item_fight );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_startserver.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=============================================================================\n\nSTART SERVER MENU *****\n\n=============================================================================\n*/\n\n\n#include \"ui_local.h\"\n\n\n#define GAMESERVER_BACK0\t\t\"menu/art/back_0\"\n#define GAMESERVER_BACK1\t\t\"menu/art/back_1\"\n#define GAMESERVER_NEXT0\t\t\"menu/art/next_0\"\n#define GAMESERVER_NEXT1\t\t\"menu/art/next_1\"\n#define GAMESERVER_FRAMEL\t\t\"menu/art/frame2_l\"\n#define GAMESERVER_FRAMER\t\t\"menu/art/frame1_r\"\n#define GAMESERVER_SELECT\t\t\"menu/art/maps_select\"\n#define GAMESERVER_SELECTED\t\t\"menu/art/maps_selected\"\n#define GAMESERVER_FIGHT0\t\t\"menu/art/fight_0\"\n#define GAMESERVER_FIGHT1\t\t\"menu/art/fight_1\"\n#define GAMESERVER_UNKNOWNMAP\t\"menu/art/unknownmap\"\n#define GAMESERVER_ARROWS\t\t\"menu/art/gs_arrows_0\"\n#define GAMESERVER_ARROWSL\t\t\"menu/art/gs_arrows_l\"\n#define GAMESERVER_ARROWSR\t\t\"menu/art/gs_arrows_r\"\n\n#define MAX_MAPROWS\t\t2\n#define MAX_MAPCOLS\t\t2\n#define MAX_MAPSPERPAGE\t4\n\n#define\tMAX_SERVERSTEXT\t8192\n\n#define MAX_SERVERMAPS\t64\n#define MAX_NAMELENGTH\t16\n\n#define ID_GAMETYPE\t\t\t\t10\n#define ID_PICTURES\t\t\t\t11\t// 12, 13, 14\n#define ID_PREVPAGE\t\t\t\t15\n#define ID_NEXTPAGE\t\t\t\t16\n#define ID_STARTSERVERBACK\t\t17\n#define ID_STARTSERVERNEXT\t\t18\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n\n\tmenutext_s\t\tbanner;\n\tmenubitmap_s\tframel;\n\tmenubitmap_s\tframer;\n\n\tmenulist_s\t\tgametype;\n\tmenubitmap_s\tmappics[MAX_MAPSPERPAGE];\n\tmenubitmap_s\tmapbuttons[MAX_MAPSPERPAGE];\n\tmenubitmap_s\tarrows;\n\tmenubitmap_s\tprevpage;\n\tmenubitmap_s\tnextpage;\n\tmenubitmap_s\tback;\n\tmenubitmap_s\tnext;\n\n\tmenutext_s\t\tmapname;\n\tmenubitmap_s\titem_null;\n\n\tqboolean\t\tmultiplayer;\n\tint\t\t\t\tcurrentmap;\n\tint\t\t\t\tnummaps;\n\tint\t\t\t\tpage;\n\tint\t\t\t\tmaxpages;\n\tchar\t\t\tmaplist[MAX_SERVERMAPS][MAX_NAMELENGTH];\n\tint\t\t\t\tmapGamebits[MAX_SERVERMAPS];\n} startserver_t;\n\nstatic startserver_t s_startserver;\n\nstatic const char *gametype_items[] = {\n\t\"Free For All\",\n\t\"Team Deathmatch\",\n\t\"Tournament\",\n\t\"Capture the Flag\",\n\t0\n};\n\nstatic int gametype_remap[] = {GT_FFA, GT_TEAM, GT_TOURNAMENT, GT_CTF};\nstatic int gametype_remap2[] = {0, 2, 0, 1, 3};\n\n// use ui_servers2.c definition\nextern const char* punkbuster_items[];\n\nstatic void UI_ServerOptionsMenu( qboolean multiplayer );\n\n\n/*\n=================\nGametypeBits\n=================\n*/\nstatic int GametypeBits( char *string ) {\n\tint\t\tbits;\n\tchar\t*p;\n\tchar\t*token;\n\n\tbits = 0;\n\tp = string;\n\twhile( 1 ) {\n\t\ttoken = COM_ParseExt( &p, qfalse );\n\t\tif( token[0] == 0 ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif( Q_stricmp( token, \"ffa\" ) == 0 ) {\n\t\t\tbits |= 1 << GT_FFA;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif( Q_stricmp( token, \"tourney\" ) == 0 ) {\n\t\t\tbits |= 1 << GT_TOURNAMENT;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif( Q_stricmp( token, \"single\" ) == 0 ) {\n\t\t\tbits |= 1 << GT_SINGLE_PLAYER;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif( Q_stricmp( token, \"team\" ) == 0 ) {\n\t\t\tbits |= 1 << GT_TEAM;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif( Q_stricmp( token, \"ctf\" ) == 0 ) {\n\t\t\tbits |= 1 << GT_CTF;\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\treturn bits;\n}\n\n\n/*\n=================\nStartServer_Update\n=================\n*/\nstatic void StartServer_Update( void ) {\n\tint\t\t\t\ti;\n\tint\t\t\t\ttop;\n\tstatic\tchar\tpicname[MAX_MAPSPERPAGE][64];\n\n\ttop = s_startserver.page*MAX_MAPSPERPAGE;\n\n\tfor (i=0; i<MAX_MAPSPERPAGE; i++)\n\t{\n\t\tif (top+i >= s_startserver.nummaps)\n\t\t\tbreak;\n\n\t\tCom_sprintf( picname[i], sizeof(picname[i]), \"levelshots/%s\", s_startserver.maplist[top+i] );\n\n\t\ts_startserver.mappics[i].generic.flags &= ~QMF_HIGHLIGHT;\n\t\ts_startserver.mappics[i].generic.name   = picname[i];\n\t\ts_startserver.mappics[i].shader         = 0;\n\n\t\t// reset\n\t\ts_startserver.mapbuttons[i].generic.flags |= QMF_PULSEIFFOCUS;\n\t\ts_startserver.mapbuttons[i].generic.flags &= ~QMF_INACTIVE;\n\t}\n\n\tfor (; i<MAX_MAPSPERPAGE; i++)\n\t{\n\t\ts_startserver.mappics[i].generic.flags &= ~QMF_HIGHLIGHT;\n\t\ts_startserver.mappics[i].generic.name   = NULL;\n\t\ts_startserver.mappics[i].shader         = 0;\n\n\t\t// disable\n\t\ts_startserver.mapbuttons[i].generic.flags &= ~QMF_PULSEIFFOCUS;\n\t\ts_startserver.mapbuttons[i].generic.flags |= QMF_INACTIVE;\n\t}\n\n\n\t// no servers to start\n\tif( !s_startserver.nummaps ) {\n\t\ts_startserver.next.generic.flags |= QMF_INACTIVE;\n\n\t\t// set the map name\n\t\tstrcpy( s_startserver.mapname.string, \"NO MAPS FOUND\" );\n\t}\n\telse {\n\t\t// set the highlight\n\t\ts_startserver.next.generic.flags &= ~QMF_INACTIVE;\n\t\ti = s_startserver.currentmap - top;\n\t\tif ( i >=0 && i < MAX_MAPSPERPAGE ) \n\t\t{\n\t\t\ts_startserver.mappics[i].generic.flags    |= QMF_HIGHLIGHT;\n\t\t\ts_startserver.mapbuttons[i].generic.flags &= ~QMF_PULSEIFFOCUS;\n\t\t}\n\n\t\t// set the map name\n\t\tstrcpy( s_startserver.mapname.string, s_startserver.maplist[s_startserver.currentmap] );\n\t}\n\t\n\tQ_strupr( s_startserver.mapname.string );\n}\n\n\n/*\n=================\nStartServer_MapEvent\n=================\n*/\nstatic void StartServer_MapEvent( void* ptr, int event ) {\n\tif( event != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\n\ts_startserver.currentmap = (s_startserver.page*MAX_MAPSPERPAGE) + (((menucommon_s*)ptr)->id - ID_PICTURES);\n\tStartServer_Update();\n}\n\n\n/*\n=================\nStartServer_GametypeEvent\n=================\n*/\nstatic void StartServer_GametypeEvent( void* ptr, int event ) {\n\tint\t\t\ti;\n\tint\t\t\tcount;\n\tint\t\t\tgamebits;\n\tint\t\t\tmatchbits;\n\tconst char\t*info;\n\n\tif( event != QM_ACTIVATED) {\n\t\treturn;\n\t}\n\n\tcount = UI_GetNumArenas();\n\ts_startserver.nummaps = 0;\n\tmatchbits = 1 << gametype_remap[s_startserver.gametype.curvalue];\n\tif( gametype_remap[s_startserver.gametype.curvalue] == GT_FFA ) {\n\t\tmatchbits |= ( 1 << GT_SINGLE_PLAYER );\n\t}\n\tfor( i = 0; i < count; i++ ) {\n\t\tinfo = UI_GetArenaInfoByNumber( i );\n\n\t\tgamebits = GametypeBits( Info_ValueForKey( info, \"type\") );\n\t\tif( !( gamebits & matchbits ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tQ_strncpyz( s_startserver.maplist[s_startserver.nummaps], Info_ValueForKey( info, \"map\"), MAX_NAMELENGTH );\n\t\tQ_strupr( s_startserver.maplist[s_startserver.nummaps] );\n\t\ts_startserver.mapGamebits[s_startserver.nummaps] = gamebits;\n\t\ts_startserver.nummaps++;\n\t}\n\ts_startserver.maxpages = (s_startserver.nummaps + MAX_MAPSPERPAGE-1)/MAX_MAPSPERPAGE;\n\ts_startserver.page = 0;\n\ts_startserver.currentmap = 0;\n\n\tStartServer_Update();\n}\n\n\n/*\n=================\nStartServer_MenuEvent\n=================\n*/\nstatic void StartServer_MenuEvent( void* ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tswitch( ((menucommon_s*)ptr)->id ) {\n\tcase ID_PREVPAGE:\n\t\tif( s_startserver.page > 0 ) {\n\t\t\ts_startserver.page--;\n\t\t\tStartServer_Update();\n\t\t}\n\t\tbreak;\n\n\tcase ID_NEXTPAGE:\n\t\tif( s_startserver.page < s_startserver.maxpages - 1 ) {\n\t\t\ts_startserver.page++;\n\t\t\tStartServer_Update();\n\t\t}\n\t\tbreak;\n\n\tcase ID_STARTSERVERNEXT:\n\t\ttrap_Cvar_SetValue( \"g_gameType\", gametype_remap[s_startserver.gametype.curvalue] );\n\t\tUI_ServerOptionsMenu( s_startserver.multiplayer );\n\t\tbreak;\n\n\tcase ID_STARTSERVERBACK:\n\t\tUI_PopMenu();\n\t\tbreak;\n\t}\n}\n\n\n/*\n===============\nStartServer_LevelshotDraw\n===============\n*/\nstatic void StartServer_LevelshotDraw( void *self ) {\n\tmenubitmap_s\t*b;\n\tint\t\t\t\tx;\n\tint\t\t\t\ty;\n\tint\t\t\t\tw;\n\tint\t\t\t\th;\n\tint\t\t\t\tn;\n\n\tb = (menubitmap_s *)self;\n\n\tif( !b->generic.name ) {\n\t\treturn;\n\t}\n\n\tif( b->generic.name && !b->shader ) {\n\t\tb->shader = trap_R_RegisterShaderNoMip( b->generic.name );\n\t\tif( !b->shader && b->errorpic ) {\n\t\t\tb->shader = trap_R_RegisterShaderNoMip( b->errorpic );\n\t\t}\n\t}\n\n\tif( b->focuspic && !b->focusshader ) {\n\t\tb->focusshader = trap_R_RegisterShaderNoMip( b->focuspic );\n\t}\n\n\tx = b->generic.x;\n\ty = b->generic.y;\n\tw = b->width;\n\th =\tb->height;\n\tif( b->shader ) {\n\t\tUI_DrawHandlePic( x, y, w, h, b->shader );\n\t}\n\n\tx = b->generic.x;\n\ty = b->generic.y + b->height;\n\tUI_FillRect( x, y, b->width, 28, colorBlack );\n\n\tx += b->width / 2;\n\ty += 4;\n\tn = s_startserver.page * MAX_MAPSPERPAGE + b->generic.id - ID_PICTURES;\n\tUI_DrawString( x, y, s_startserver.maplist[n], UI_CENTER|UI_SMALLFONT, color_orange );\n\n\tx = b->generic.x;\n\ty = b->generic.y;\n\tw = b->width;\n\th =\tb->height + 28;\n\tif( b->generic.flags & QMF_HIGHLIGHT ) {\t\n\t\tUI_DrawHandlePic( x, y, w, h, b->focusshader );\n\t}\n}\n\n\n/*\n=================\nStartServer_MenuInit\n=================\n*/\nstatic void StartServer_MenuInit( void ) {\n\tint\ti;\n\tint\tx;\n\tint\ty;\n\tstatic char mapnamebuffer[64];\n\n\t// zero set all our globals\n\tmemset( &s_startserver, 0 ,sizeof(startserver_t) );\n\n\tStartServer_Cache();\n\n\ts_startserver.menu.wrapAround = qtrue;\n\ts_startserver.menu.fullscreen = qtrue;\n\n\ts_startserver.banner.generic.type  = MTYPE_BTEXT;\n\ts_startserver.banner.generic.x\t   = 320;\n\ts_startserver.banner.generic.y\t   = 16;\n\ts_startserver.banner.string        = \"GAME SERVER\";\n\ts_startserver.banner.color         = color_white;\n\ts_startserver.banner.style         = UI_CENTER;\n\n\ts_startserver.framel.generic.type  = MTYPE_BITMAP;\n\ts_startserver.framel.generic.name  = GAMESERVER_FRAMEL;\n\ts_startserver.framel.generic.flags = QMF_INACTIVE;\n\ts_startserver.framel.generic.x\t   = 0;  \n\ts_startserver.framel.generic.y\t   = 78;\n\ts_startserver.framel.width  \t   = 256;\n\ts_startserver.framel.height  \t   = 329;\n\n\ts_startserver.framer.generic.type  = MTYPE_BITMAP;\n\ts_startserver.framer.generic.name  = GAMESERVER_FRAMER;\n\ts_startserver.framer.generic.flags = QMF_INACTIVE;\n\ts_startserver.framer.generic.x\t   = 376;\n\ts_startserver.framer.generic.y\t   = 76;\n\ts_startserver.framer.width  \t   = 256;\n\ts_startserver.framer.height  \t   = 334;\n\n\ts_startserver.gametype.generic.type\t\t= MTYPE_SPINCONTROL;\n\ts_startserver.gametype.generic.name\t\t= \"Game Type:\";\n\ts_startserver.gametype.generic.flags\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_startserver.gametype.generic.callback\t= StartServer_GametypeEvent;\n\ts_startserver.gametype.generic.id\t\t= ID_GAMETYPE;\n\ts_startserver.gametype.generic.x\t\t= 320 - 24;\n\ts_startserver.gametype.generic.y\t\t= 368;\n\ts_startserver.gametype.itemnames\t\t= gametype_items;\n\n\tfor (i=0; i<MAX_MAPSPERPAGE; i++)\n\t{\n\t\tx =\t(i % MAX_MAPCOLS) * (128+8) + 188;\n\t\ty = (i / MAX_MAPROWS) * (128+8) + 96;\n\n\t\ts_startserver.mappics[i].generic.type   = MTYPE_BITMAP;\n\t\ts_startserver.mappics[i].generic.flags  = QMF_LEFT_JUSTIFY|QMF_INACTIVE;\n\t\ts_startserver.mappics[i].generic.x\t    = x;\n\t\ts_startserver.mappics[i].generic.y\t    = y;\n\t\ts_startserver.mappics[i].generic.id\t\t= ID_PICTURES+i;\n\t\ts_startserver.mappics[i].width  \t\t= 128;\n\t\ts_startserver.mappics[i].height  \t    = 96;\n\t\ts_startserver.mappics[i].focuspic       = GAMESERVER_SELECTED;\n\t\ts_startserver.mappics[i].errorpic       = GAMESERVER_UNKNOWNMAP;\n\t\ts_startserver.mappics[i].generic.ownerdraw = StartServer_LevelshotDraw;\n\n\t\ts_startserver.mapbuttons[i].generic.type     = MTYPE_BITMAP;\n\t\ts_startserver.mapbuttons[i].generic.flags    = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_NODEFAULTINIT;\n\t\ts_startserver.mapbuttons[i].generic.id       = ID_PICTURES+i;\n\t\ts_startserver.mapbuttons[i].generic.callback = StartServer_MapEvent;\n\t\ts_startserver.mapbuttons[i].generic.x\t     = x - 30;\n\t\ts_startserver.mapbuttons[i].generic.y\t     = y - 32;\n\t\ts_startserver.mapbuttons[i].width  \t\t     = 256;\n\t\ts_startserver.mapbuttons[i].height  \t     = 248;\n\t\ts_startserver.mapbuttons[i].generic.left     = x;\n\t\ts_startserver.mapbuttons[i].generic.top  \t = y;\n\t\ts_startserver.mapbuttons[i].generic.right    = x + 128;\n\t\ts_startserver.mapbuttons[i].generic.bottom   = y + 128;\n\t\ts_startserver.mapbuttons[i].focuspic         = GAMESERVER_SELECT;\n\t}\n\n\ts_startserver.arrows.generic.type  = MTYPE_BITMAP;\n\ts_startserver.arrows.generic.name  = GAMESERVER_ARROWS;\n\ts_startserver.arrows.generic.flags = QMF_INACTIVE;\n\ts_startserver.arrows.generic.x\t   = 260;\n\ts_startserver.arrows.generic.y\t   = 400;\n\ts_startserver.arrows.width  \t   = 128;\n\ts_startserver.arrows.height  \t   = 32;\n\n\ts_startserver.prevpage.generic.type\t    = MTYPE_BITMAP;\n\ts_startserver.prevpage.generic.flags    = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_startserver.prevpage.generic.callback = StartServer_MenuEvent;\n\ts_startserver.prevpage.generic.id\t    = ID_PREVPAGE;\n\ts_startserver.prevpage.generic.x\t\t= 260;\n\ts_startserver.prevpage.generic.y\t\t= 400;\n\ts_startserver.prevpage.width  \t\t    = 64;\n\ts_startserver.prevpage.height  \t\t    = 32;\n\ts_startserver.prevpage.focuspic         = GAMESERVER_ARROWSL;\n\n\ts_startserver.nextpage.generic.type\t    = MTYPE_BITMAP;\n\ts_startserver.nextpage.generic.flags    = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_startserver.nextpage.generic.callback = StartServer_MenuEvent;\n\ts_startserver.nextpage.generic.id\t    = ID_NEXTPAGE;\n\ts_startserver.nextpage.generic.x\t\t= 321;\n\ts_startserver.nextpage.generic.y\t\t= 400;\n\ts_startserver.nextpage.width  \t\t    = 64;\n\ts_startserver.nextpage.height  \t\t    = 32;\n\ts_startserver.nextpage.focuspic         = GAMESERVER_ARROWSR;\n\n\ts_startserver.mapname.generic.type  = MTYPE_PTEXT;\n\ts_startserver.mapname.generic.flags = QMF_CENTER_JUSTIFY|QMF_INACTIVE;\n\ts_startserver.mapname.generic.x\t    = 320;\n\ts_startserver.mapname.generic.y\t    = 440;\n\ts_startserver.mapname.string        = mapnamebuffer;\n\ts_startserver.mapname.style         = UI_CENTER|UI_BIGFONT;\n\ts_startserver.mapname.color         = text_color_normal;\n\n\ts_startserver.back.generic.type\t    = MTYPE_BITMAP;\n\ts_startserver.back.generic.name     = GAMESERVER_BACK0;\n\ts_startserver.back.generic.flags    = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_startserver.back.generic.callback = StartServer_MenuEvent;\n\ts_startserver.back.generic.id\t    = ID_STARTSERVERBACK;\n\ts_startserver.back.generic.x\t\t= 0;\n\ts_startserver.back.generic.y\t\t= 480-64;\n\ts_startserver.back.width  \t\t    = 128;\n\ts_startserver.back.height  \t\t    = 64;\n\ts_startserver.back.focuspic         = GAMESERVER_BACK1;\n\n\ts_startserver.next.generic.type\t    = MTYPE_BITMAP;\n\ts_startserver.next.generic.name     = GAMESERVER_NEXT0;\n\ts_startserver.next.generic.flags    = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_startserver.next.generic.callback = StartServer_MenuEvent;\n\ts_startserver.next.generic.id\t    = ID_STARTSERVERNEXT;\n\ts_startserver.next.generic.x\t\t= 640;\n\ts_startserver.next.generic.y\t\t= 480-64;\n\ts_startserver.next.width  \t\t    = 128;\n\ts_startserver.next.height  \t\t    = 64;\n\ts_startserver.next.focuspic         = GAMESERVER_NEXT1;\n\n\ts_startserver.item_null.generic.type\t= MTYPE_BITMAP;\n\ts_startserver.item_null.generic.flags\t= QMF_LEFT_JUSTIFY|QMF_MOUSEONLY|QMF_SILENT;\n\ts_startserver.item_null.generic.x\t\t= 0;\n\ts_startserver.item_null.generic.y\t\t= 0;\n\ts_startserver.item_null.width\t\t\t= 640;\n\ts_startserver.item_null.height\t\t\t= 480;\n\n\tMenu_AddItem( &s_startserver.menu, &s_startserver.banner );\n\tMenu_AddItem( &s_startserver.menu, &s_startserver.framel );\n\tMenu_AddItem( &s_startserver.menu, &s_startserver.framer );\n\n\tMenu_AddItem( &s_startserver.menu, &s_startserver.gametype );\n\tfor (i=0; i<MAX_MAPSPERPAGE; i++)\n\t{\n\t\tMenu_AddItem( &s_startserver.menu, &s_startserver.mappics[i] );\n\t\tMenu_AddItem( &s_startserver.menu, &s_startserver.mapbuttons[i] );\n\t}\n\n\tMenu_AddItem( &s_startserver.menu, &s_startserver.arrows );\n\tMenu_AddItem( &s_startserver.menu, &s_startserver.prevpage );\n\tMenu_AddItem( &s_startserver.menu, &s_startserver.nextpage );\n\tMenu_AddItem( &s_startserver.menu, &s_startserver.back );\n\tMenu_AddItem( &s_startserver.menu, &s_startserver.next );\n\tMenu_AddItem( &s_startserver.menu, &s_startserver.mapname );\n\tMenu_AddItem( &s_startserver.menu, &s_startserver.item_null );\n\n\tStartServer_GametypeEvent( NULL, QM_ACTIVATED );\n}\n\n\n/*\n=================\nStartServer_Cache\n=================\n*/\nvoid StartServer_Cache( void )\n{\n\tint\t\t\t\ti;\n\tconst char\t\t*info;\n\tqboolean\t\tprecache;\n\tchar\t\t\tpicname[64];\n\n\ttrap_R_RegisterShaderNoMip( GAMESERVER_BACK0 );\t\n\ttrap_R_RegisterShaderNoMip( GAMESERVER_BACK1 );\t\n\ttrap_R_RegisterShaderNoMip( GAMESERVER_NEXT0 );\t\n\ttrap_R_RegisterShaderNoMip( GAMESERVER_NEXT1 );\t\n\ttrap_R_RegisterShaderNoMip( GAMESERVER_FRAMEL );\t\n\ttrap_R_RegisterShaderNoMip( GAMESERVER_FRAMER );\t\n\ttrap_R_RegisterShaderNoMip( GAMESERVER_SELECT );\t\n\ttrap_R_RegisterShaderNoMip( GAMESERVER_SELECTED );\t\n\ttrap_R_RegisterShaderNoMip( GAMESERVER_UNKNOWNMAP );\n\ttrap_R_RegisterShaderNoMip( GAMESERVER_ARROWS );\n\ttrap_R_RegisterShaderNoMip( GAMESERVER_ARROWSL );\n\ttrap_R_RegisterShaderNoMip( GAMESERVER_ARROWSR );\n\n\tprecache = trap_Cvar_VariableValue(\"com_buildscript\");\n\n\ts_startserver.nummaps = UI_GetNumArenas();\n\n\tfor( i = 0; i < s_startserver.nummaps; i++ ) {\n\t\tinfo = UI_GetArenaInfoByNumber( i );\n\n\t\tQ_strncpyz( s_startserver.maplist[i], Info_ValueForKey( info, \"map\"), MAX_NAMELENGTH );\n\t\tQ_strupr( s_startserver.maplist[i] );\n\t\ts_startserver.mapGamebits[i] = GametypeBits( Info_ValueForKey( info, \"type\") );\n\n\t\tif( precache ) {\n\t\t\tCom_sprintf( picname, sizeof(picname), \"levelshots/%s\", s_startserver.maplist[i] );\n\t\t\ttrap_R_RegisterShaderNoMip(picname);\n\t\t}\n\t}\n\n\ts_startserver.maxpages = (s_startserver.nummaps + MAX_MAPSPERPAGE-1)/MAX_MAPSPERPAGE;\n}\n\n\n/*\n=================\nUI_StartServerMenu\n=================\n*/\nvoid UI_StartServerMenu( qboolean multiplayer ) {\n\tStartServer_MenuInit();\n\ts_startserver.multiplayer = multiplayer;\n\tUI_PushMenu( &s_startserver.menu );\n}\n\n\n\n/*\n=============================================================================\n\nSERVER OPTIONS MENU *****\n\n=============================================================================\n*/\n\n#define ID_PLAYER_TYPE\t\t\t20\n#define ID_MAXCLIENTS\t\t\t21\n#define ID_DEDICATED\t\t\t22\n#define ID_GO\t\t\t\t\t23\n#define ID_BACK\t\t\t\t\t24\n\n#define PLAYER_SLOTS\t\t\t12\n\n\ntypedef struct {\n\tmenuframework_s\t\tmenu;\n\n\tmenutext_s\t\t\tbanner;\n\n\tmenubitmap_s\t\tmappic;\n\tmenubitmap_s\t\tpicframe;\n\n\tmenulist_s\t\t\tdedicated;\n\tmenufield_s\t\t\ttimelimit;\n\tmenufield_s\t\t\tfraglimit;\n\tmenufield_s\t\t\tflaglimit;\n\tmenuradiobutton_s\tfriendlyfire;\n\tmenufield_s\t\t\thostname;\n\tmenuradiobutton_s\tpure;\n\tmenulist_s\t\t\tbotSkill;\n\n\tmenutext_s\t\t\tplayer0;\n\tmenulist_s\t\t\tplayerType[PLAYER_SLOTS];\n\tmenutext_s\t\t\tplayerName[PLAYER_SLOTS];\n\tmenulist_s\t\t\tplayerTeam[PLAYER_SLOTS];\n\n\tmenubitmap_s\t\tgo;\n\tmenubitmap_s\t\tnext;\n\tmenubitmap_s\t\tback;\n\n\tqboolean\t\t\tmultiplayer;\n\tint\t\t\t\t\tgametype;\n\tchar\t\t\t\tmapnamebuffer[32];\n\tchar\t\t\t\tplayerNameBuffers[PLAYER_SLOTS][16];\n\n\tqboolean\t\t\tnewBot;\n\tint\t\t\t\t\tnewBotIndex;\n\tchar\t\t\t\tnewBotName[16];\n\t\n\tmenulist_s\t\tpunkbuster;\n} serveroptions_t;\n\nstatic serveroptions_t s_serveroptions;\n\nstatic const char *dedicated_list[] = {\n\t\"No\",\n\t\"LAN\",\n\t\"Internet\",\n\t0\n};\n\nstatic const char *playerType_list[] = {\n\t\"Open\",\n\t\"Bot\",\n\t\"----\",\n\t0\n};\n\nstatic const char *playerTeam_list[] = {\n\t\"Blue\",\n\t\"Red\",\n\t0\n};\n\nstatic const char *botSkill_list[] = {\n\t\"I Can Win\",\n\t\"Bring It On\",\n\t\"Hurt Me Plenty\",\n\t\"Hardcore\",\n\t\"Nightmare!\",\n\t0\n};\n\n\n/*\n=================\nBotAlreadySelected\n=================\n*/\nstatic qboolean BotAlreadySelected( const char *checkName ) {\n\tint\t\tn;\n\n\tfor( n = 1; n < PLAYER_SLOTS; n++ ) {\n\t\tif( s_serveroptions.playerType[n].curvalue != 1 ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif( (s_serveroptions.gametype >= GT_TEAM) &&\n\t\t\t(s_serveroptions.playerTeam[n].curvalue != s_serveroptions.playerTeam[s_serveroptions.newBotIndex].curvalue ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif( Q_stricmp( checkName, s_serveroptions.playerNameBuffers[n] ) == 0 ) {\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\n\treturn qfalse;\n}\n\n\n/*\n=================\nServerOptions_Start\n=================\n*/\nstatic void ServerOptions_Start( void ) {\n\tint\t\ttimelimit;\n\tint\t\tfraglimit;\n\tint\t\tmaxclients;\n\tint\t\tdedicated;\n\tint\t\tfriendlyfire;\n\tint\t\tflaglimit;\n\tint\t\tpure;\n\tint\t\tskill;\n\tint\t\tn;\n\tchar\tbuf[64];\n\n\n\ttimelimit\t = atoi( s_serveroptions.timelimit.field.buffer );\n\tfraglimit\t = atoi( s_serveroptions.fraglimit.field.buffer );\n\tflaglimit\t = atoi( s_serveroptions.flaglimit.field.buffer );\n\tdedicated\t = s_serveroptions.dedicated.curvalue;\n\tfriendlyfire = s_serveroptions.friendlyfire.curvalue;\n\tpure\t\t = s_serveroptions.pure.curvalue;\n\tskill\t\t = s_serveroptions.botSkill.curvalue + 1;\n\n\t//set maxclients\n\tfor( n = 0, maxclients = 0; n < PLAYER_SLOTS; n++ ) {\n\t\tif( s_serveroptions.playerType[n].curvalue == 2 ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif( (s_serveroptions.playerType[n].curvalue == 1) && (s_serveroptions.playerNameBuffers[n][0] == 0) ) {\n\t\t\tcontinue;\n\t\t}\n\t\tmaxclients++;\n\t}\n\n\tswitch( s_serveroptions.gametype ) {\n\tcase GT_FFA:\n\tdefault:\n\t\ttrap_Cvar_SetValue( \"ui_ffa_fraglimit\", fraglimit );\n\t\ttrap_Cvar_SetValue( \"ui_ffa_timelimit\", timelimit );\n\t\tbreak;\n\n\tcase GT_TOURNAMENT:\n\t\ttrap_Cvar_SetValue( \"ui_tourney_fraglimit\", fraglimit );\n\t\ttrap_Cvar_SetValue( \"ui_tourney_timelimit\", timelimit );\n\t\tbreak;\n\n\tcase GT_TEAM:\n\t\ttrap_Cvar_SetValue( \"ui_team_fraglimit\", fraglimit );\n\t\ttrap_Cvar_SetValue( \"ui_team_timelimit\", timelimit );\n\t\ttrap_Cvar_SetValue( \"ui_team_friendlt\", friendlyfire );\n\t\tbreak;\n\n\tcase GT_CTF:\n\t\ttrap_Cvar_SetValue( \"ui_ctf_fraglimit\", fraglimit );\n\t\ttrap_Cvar_SetValue( \"ui_ctf_timelimit\", timelimit );\n\t\ttrap_Cvar_SetValue( \"ui_ctf_friendlt\", friendlyfire );\n\t\tbreak;\n\t}\n\n\ttrap_Cvar_SetValue( \"sv_maxclients\", Com_Clamp( 0, 12, maxclients ) );\n\ttrap_Cvar_SetValue( \"dedicated\", Com_Clamp( 0, 2, dedicated ) );\n\ttrap_Cvar_SetValue (\"timelimit\", Com_Clamp( 0, timelimit, timelimit ) );\n\ttrap_Cvar_SetValue (\"fraglimit\", Com_Clamp( 0, fraglimit, fraglimit ) );\n\ttrap_Cvar_SetValue (\"capturelimit\", Com_Clamp( 0, flaglimit, flaglimit ) );\n\ttrap_Cvar_SetValue( \"g_friendlyfire\", friendlyfire );\n\ttrap_Cvar_SetValue( \"sv_pure\", pure );\n\ttrap_Cvar_Set(\"sv_hostname\", s_serveroptions.hostname.field.buffer );\n\t\n\ttrap_Cvar_SetValue( \"sv_punkbuster\", s_serveroptions.punkbuster.curvalue );\n\n\t// the wait commands will allow the dedicated to take effect\n\ttrap_Cmd_ExecuteText( EXEC_APPEND, va( \"wait ; wait ; map %s\\n\", s_startserver.maplist[s_startserver.currentmap] ) );\n\n\t// add bots\n\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"wait 3\\n\" );\n\tfor( n = 1; n < PLAYER_SLOTS; n++ ) {\n\t\tif( s_serveroptions.playerType[n].curvalue != 1 ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif( s_serveroptions.playerNameBuffers[n][0] == 0 ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif( s_serveroptions.playerNameBuffers[n][0] == '-' ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif( s_serveroptions.gametype >= GT_TEAM ) {\n\t\t\tCom_sprintf( buf, sizeof(buf), \"addbot %s %i %s\\n\", s_serveroptions.playerNameBuffers[n], skill,\n\t\t\t\tplayerTeam_list[s_serveroptions.playerTeam[n].curvalue] );\n\t\t}\n\t\telse {\n\t\t\tCom_sprintf( buf, sizeof(buf), \"addbot %s %i\\n\", s_serveroptions.playerNameBuffers[n], skill );\n\t\t}\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, buf );\n\t}\n\n\t// set player's team\n\tif( dedicated == 0 && s_serveroptions.gametype >= GT_TEAM ) {\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va( \"wait 5; team %s\\n\", playerTeam_list[s_serveroptions.playerTeam[0].curvalue] ) );\n\t}\n}\n\n\n/*\n=================\nServerOptions_InitPlayerItems\n=================\n*/\nstatic void ServerOptions_InitPlayerItems( void ) {\n\tint\t\tn;\n\tint\t\tv;\n\n\t// init types\n\tif( s_serveroptions.multiplayer ) {\n\t\tv = 0;\t// open\n\t}\n\telse {\n\t\tv = 1;\t// bot\n\t}\n\t\n\tfor( n = 0; n < PLAYER_SLOTS; n++ ) {\n\t\ts_serveroptions.playerType[n].curvalue = v;\n\t}\n\n\tif( s_serveroptions.multiplayer && (s_serveroptions.gametype < GT_TEAM) ) {\n\t\tfor( n = 8; n < PLAYER_SLOTS; n++ ) {\n\t\t\ts_serveroptions.playerType[n].curvalue = 2;\n\t\t}\n\t}\n\n\t// if not a dedicated server, first slot is reserved for the human on the server\n\tif( s_serveroptions.dedicated.curvalue == 0 ) {\n\t\t// human\n\t\ts_serveroptions.playerType[0].generic.flags |= QMF_INACTIVE;\n\t\ts_serveroptions.playerType[0].curvalue = 0;\n\t\ttrap_Cvar_VariableStringBuffer( \"name\", s_serveroptions.playerNameBuffers[0], sizeof(s_serveroptions.playerNameBuffers[0]) );\n\t\tQ_CleanStr( s_serveroptions.playerNameBuffers[0] );\n\t}\n\n\t// init teams\n\tif( s_serveroptions.gametype >= GT_TEAM ) {\n\t\tfor( n = 0; n < (PLAYER_SLOTS / 2); n++ ) {\n\t\t\ts_serveroptions.playerTeam[n].curvalue = 0;\n\t\t}\n\t\tfor( ; n < PLAYER_SLOTS; n++ ) {\n\t\t\ts_serveroptions.playerTeam[n].curvalue = 1;\n\t\t}\n\t}\n\telse {\n\t\tfor( n = 0; n < PLAYER_SLOTS; n++ ) {\n\t\t\ts_serveroptions.playerTeam[n].generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);\n\t\t}\n\t}\n}\n\n\n/*\n=================\nServerOptions_SetPlayerItems\n=================\n*/\nstatic void ServerOptions_SetPlayerItems( void ) {\n\tint\t\tstart;\n\tint\t\tn;\n\n\t// types\n//\tfor( n = 0; n < PLAYER_SLOTS; n++ ) {\n//\t\tif( (!s_serveroptions.multiplayer) && (n > 0) && (s_serveroptions.playerType[n].curvalue == 0) ) {\n//\t\t\ts_serveroptions.playerType[n].curvalue = 1;\n//\t\t}\n//\t}\n\n\t// names\n\tif( s_serveroptions.dedicated.curvalue == 0 ) {\n\t\ts_serveroptions.player0.string = \"Human\";\n\t\ts_serveroptions.playerName[0].generic.flags &= ~QMF_HIDDEN;\n\n\t\tstart = 1;\n\t}\n\telse {\n\t\ts_serveroptions.player0.string = \"Open\";\n\t\tstart = 0;\n\t}\n\tfor( n = start; n < PLAYER_SLOTS; n++ ) {\n\t\tif( s_serveroptions.playerType[n].curvalue == 1 ) {\n\t\t\ts_serveroptions.playerName[n].generic.flags &= ~(QMF_INACTIVE|QMF_HIDDEN);\n\t\t}\n\t\telse {\n\t\t\ts_serveroptions.playerName[n].generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);\n\t\t}\n\t}\n\n\t// teams\n\tif( s_serveroptions.gametype < GT_TEAM ) {\n\t\treturn;\n\t}\n\tfor( n = start; n < PLAYER_SLOTS; n++ ) {\n\t\tif( s_serveroptions.playerType[n].curvalue == 2 ) {\n\t\t\ts_serveroptions.playerTeam[n].generic.flags |= (QMF_INACTIVE|QMF_HIDDEN);\n\t\t}\n\t\telse {\n\t\t\ts_serveroptions.playerTeam[n].generic.flags &= ~(QMF_INACTIVE|QMF_HIDDEN);\n\t\t}\n\t}\n}\n\n\n/*\n=================\nServerOptions_Event\n=================\n*/\nstatic void ServerOptions_Event( void* ptr, int event ) {\n\tswitch( ((menucommon_s*)ptr)->id ) {\n\t\n\t//if( event != QM_ACTIVATED && event != QM_LOSTFOCUS) {\n\t//\treturn;\n\t//}\n\tcase ID_PLAYER_TYPE:\n\t\tif( event != QM_ACTIVATED ) {\n\t\t\tbreak;\n\t\t}\n\t\tServerOptions_SetPlayerItems();\n\t\tbreak;\n\n\tcase ID_MAXCLIENTS:\n\tcase ID_DEDICATED:\n\t\tServerOptions_SetPlayerItems();\n\t\tbreak;\n\tcase ID_GO:\n\t\tif( event != QM_ACTIVATED ) {\n\t\t\tbreak;\n\t\t}\n\t\tServerOptions_Start();\n\t\tbreak;\n\n\tcase ID_STARTSERVERNEXT:\n\t\tif( event != QM_ACTIVATED ) {\n\t\t\tbreak;\n\t\t}\n\t\tbreak;\n\tcase ID_BACK:\n\t\tif( event != QM_ACTIVATED ) {\n\t\t\tbreak;\n\t\t}\n\t\tUI_PopMenu();\n\t\tbreak;\n\t}\n}\n\n\nstatic void ServerOptions_PlayerNameEvent( void* ptr, int event ) {\n\tint\t\tn;\n\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\tn = ((menutext_s*)ptr)->generic.id;\n\ts_serveroptions.newBotIndex = n;\n\tUI_BotSelectMenu( s_serveroptions.playerNameBuffers[n] );\n}\n\n\n/*\n=================\nServerOptions_StatusBar\n=================\n*/\nstatic void ServerOptions_StatusBar( void* ptr ) {\n\tswitch( ((menucommon_s*)ptr)->id ) {\n\tdefault:\n\t\tUI_DrawString( 320, 440, \"0 = NO LIMIT\", UI_CENTER|UI_SMALLFONT, colorWhite );\n\t\tbreak;\n\t}\n}\n\n\n/*\n===============\nServerOptions_LevelshotDraw\n===============\n*/\nstatic void ServerOptions_LevelshotDraw( void *self ) {\n\tmenubitmap_s\t*b;\n\tint\t\t\t\tx;\n\tint\t\t\t\ty;\n\n\t// strange place for this, but it works\n\tif( s_serveroptions.newBot ) {\n\t\tQ_strncpyz( s_serveroptions.playerNameBuffers[s_serveroptions.newBotIndex], s_serveroptions.newBotName, 16 );\n\t\ts_serveroptions.newBot = qfalse;\n\t}\n\n\tb = (menubitmap_s *)self;\n\n\tBitmap_Draw( b );\n\n\tx = b->generic.x;\n\ty = b->generic.y + b->height;\n\tUI_FillRect( x, y, b->width, 40, colorBlack );\n\n\tx += b->width / 2;\n\ty += 4;\n\tUI_DrawString( x, y, s_serveroptions.mapnamebuffer, UI_CENTER|UI_SMALLFONT, color_orange );\n\n\ty += SMALLCHAR_HEIGHT;\n\tUI_DrawString( x, y, gametype_items[gametype_remap2[s_serveroptions.gametype]], UI_CENTER|UI_SMALLFONT, color_orange );\n}\n\n\nstatic void ServerOptions_InitBotNames( void ) {\n\tint\t\t\tcount;\n\tint\t\t\tn;\n\tconst char\t*arenaInfo;\n\tconst char\t*botInfo;\n\tchar\t\t*p;\n\tchar\t\t*bot;\n\tchar\t\tbots[MAX_INFO_STRING];\n\n\tif( s_serveroptions.gametype >= GT_TEAM ) {\n\t\tQ_strncpyz( s_serveroptions.playerNameBuffers[1], \"grunt\", 16 );\n\t\tQ_strncpyz( s_serveroptions.playerNameBuffers[2], \"major\", 16 );\n\t\tif( s_serveroptions.gametype == GT_TEAM ) {\n\t\t\tQ_strncpyz( s_serveroptions.playerNameBuffers[3], \"visor\", 16 );\n\t\t}\n\t\telse {\n\t\t\ts_serveroptions.playerType[3].curvalue = 2;\n\t\t}\n\t\ts_serveroptions.playerType[4].curvalue = 2;\n\t\ts_serveroptions.playerType[5].curvalue = 2;\n\n\t\tQ_strncpyz( s_serveroptions.playerNameBuffers[6], \"sarge\", 16 );\n\t\tQ_strncpyz( s_serveroptions.playerNameBuffers[7], \"grunt\", 16 );\n\t\tQ_strncpyz( s_serveroptions.playerNameBuffers[8], \"major\", 16 );\n\t\tif( s_serveroptions.gametype == GT_TEAM ) {\n\t\t\tQ_strncpyz( s_serveroptions.playerNameBuffers[9], \"visor\", 16 );\n\t\t}\n\t\telse {\n\t\t\ts_serveroptions.playerType[9].curvalue = 2;\n\t\t}\n\t\ts_serveroptions.playerType[10].curvalue = 2;\n\t\ts_serveroptions.playerType[11].curvalue = 2;\n\n\t\treturn;\n\t}\n\n\tcount = 1;\t// skip the first slot, reserved for a human\n\n\t// get info for this map\n\tarenaInfo = UI_GetArenaInfoByMap( s_serveroptions.mapnamebuffer );\n\n\t// get the bot info - we'll seed with them if any are listed\n\tQ_strncpyz( bots, Info_ValueForKey( arenaInfo, \"bots\" ), sizeof(bots) );\n\tp = &bots[0];\n\twhile( *p && count < PLAYER_SLOTS ) {\n\t\t//skip spaces\n\t\twhile( *p && *p == ' ' ) {\n\t\t\tp++;\n\t\t}\n\t\tif( !p ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// mark start of bot name\n\t\tbot = p;\n\n\t\t// skip until space of null\n\t\twhile( *p && *p != ' ' ) {\n\t\t\tp++;\n\t\t}\n\t\tif( *p ) {\n\t\t\t*p++ = 0;\n\t\t}\n\n\t\tbotInfo = UI_GetBotInfoByName( bot );\n\t\tbot = Info_ValueForKey( botInfo, \"name\" );\n\n\t\tQ_strncpyz( s_serveroptions.playerNameBuffers[count], bot, sizeof(s_serveroptions.playerNameBuffers[count]) );\n\t\tcount++;\n\t}\n\n\t// set the rest of the bot slots to \"---\"\n\tfor( n = count; n < PLAYER_SLOTS; n++ ) {\n\t\tstrcpy( s_serveroptions.playerNameBuffers[n], \"--------\" );\n\t}\n\n\t// pad up to #8 as open slots\n\tfor( ;count < 8; count++ ) {\n\t\ts_serveroptions.playerType[count].curvalue = 0;\n\t}\n\n\t// close off the rest by default\n\tfor( ;count < PLAYER_SLOTS; count++ ) {\n\t\tif( s_serveroptions.playerType[count].curvalue == 1 ) {\n\t\t\ts_serveroptions.playerType[count].curvalue = 2;\n\t\t}\n\t}\n}\n\n\n/*\n=================\nServerOptions_SetMenuItems\n=================\n*/\nstatic void ServerOptions_SetMenuItems( void ) {\n\tstatic char picname[64];\n\n\tswitch( s_serveroptions.gametype ) {\n\tcase GT_FFA:\n\tdefault:\n\t\tCom_sprintf( s_serveroptions.fraglimit.field.buffer, 4, \"%i\", (int)Com_Clamp( 0, 999, trap_Cvar_VariableValue( \"ui_ffa_fraglimit\" ) ) );\n\t\tCom_sprintf( s_serveroptions.timelimit.field.buffer, 4, \"%i\", (int)Com_Clamp( 0, 999, trap_Cvar_VariableValue( \"ui_ffa_timelimit\" ) ) );\n\t\tbreak;\n\n\tcase GT_TOURNAMENT:\n\t\tCom_sprintf( s_serveroptions.fraglimit.field.buffer, 4, \"%i\", (int)Com_Clamp( 0, 999, trap_Cvar_VariableValue( \"ui_tourney_fraglimit\" ) ) );\n\t\tCom_sprintf( s_serveroptions.timelimit.field.buffer, 4, \"%i\", (int)Com_Clamp( 0, 999, trap_Cvar_VariableValue( \"ui_tourney_timelimit\" ) ) );\n\t\tbreak;\n\n\tcase GT_TEAM:\n\t\tCom_sprintf( s_serveroptions.fraglimit.field.buffer, 4, \"%i\", (int)Com_Clamp( 0, 999, trap_Cvar_VariableValue( \"ui_team_fraglimit\" ) ) );\n\t\tCom_sprintf( s_serveroptions.timelimit.field.buffer, 4, \"%i\", (int)Com_Clamp( 0, 999, trap_Cvar_VariableValue( \"ui_team_timelimit\" ) ) );\n\t\ts_serveroptions.friendlyfire.curvalue = (int)Com_Clamp( 0, 1, trap_Cvar_VariableValue( \"ui_team_friendly\" ) );\n\t\tbreak;\n\n\tcase GT_CTF:\n\t\tCom_sprintf( s_serveroptions.flaglimit.field.buffer, 4, \"%i\", (int)Com_Clamp( 0, 100, trap_Cvar_VariableValue( \"ui_ctf_capturelimit\" ) ) );\n\t\tCom_sprintf( s_serveroptions.timelimit.field.buffer, 4, \"%i\", (int)Com_Clamp( 0, 999, trap_Cvar_VariableValue( \"ui_ctf_timelimit\" ) ) );\n\t\ts_serveroptions.friendlyfire.curvalue = (int)Com_Clamp( 0, 1, trap_Cvar_VariableValue( \"ui_ctf_friendly\" ) );\n\t\tbreak;\n\t}\n\n\tQ_strncpyz( s_serveroptions.hostname.field.buffer, UI_Cvar_VariableString( \"sv_hostname\" ), sizeof( s_serveroptions.hostname.field.buffer ) );\n\ts_serveroptions.pure.curvalue = Com_Clamp( 0, 1, trap_Cvar_VariableValue( \"sv_pure\" ) );\n\n\t// set the map pic\n\tCom_sprintf( picname, 64, \"levelshots/%s\", s_startserver.maplist[s_startserver.currentmap] );\n\ts_serveroptions.mappic.generic.name = picname;\n\n\t// set the map name\n\tstrcpy( s_serveroptions.mapnamebuffer, s_startserver.mapname.string );\n\tQ_strupr( s_serveroptions.mapnamebuffer );\n\n\t// get the player selections initialized\n\tServerOptions_InitPlayerItems();\n\tServerOptions_SetPlayerItems();\n\n\t// seed bot names\n\tServerOptions_InitBotNames();\n\tServerOptions_SetPlayerItems();\n}\n\n/*\n=================\nPlayerName_Draw\n=================\n*/\nstatic void PlayerName_Draw( void *item ) {\n\tmenutext_s\t*s;\n\tfloat\t\t*color;\n\tint\t\t\tx, y;\n\tint\t\t\tstyle;\n\tqboolean\tfocus;\n\n\ts = (menutext_s *)item;\n\n\tx = s->generic.x;\n\ty =\ts->generic.y;\n\n\tstyle = UI_SMALLFONT;\n\tfocus = (s->generic.parent->cursor == s->generic.menuPosition);\n\n\tif ( s->generic.flags & QMF_GRAYED )\n\t\tcolor = text_color_disabled;\n\telse if ( focus )\n\t{\n\t\tcolor = text_color_highlight;\n\t\tstyle |= UI_PULSE;\n\t}\n\telse if ( s->generic.flags & QMF_BLINK )\n\t{\n\t\tcolor = text_color_highlight;\n\t\tstyle |= UI_BLINK;\n\t}\n\telse\n\t\tcolor = text_color_normal;\n\n\tif ( focus )\n\t{\n\t\t// draw cursor\n\t\tUI_FillRect( s->generic.left, s->generic.top, s->generic.right-s->generic.left+1, s->generic.bottom-s->generic.top+1, listbar_color ); \n\t\tUI_DrawChar( x, y, 13, UI_CENTER|UI_BLINK|UI_SMALLFONT, color);\n\t}\n\n\tUI_DrawString( x - SMALLCHAR_WIDTH, y, s->generic.name, style|UI_RIGHT, color );\n\tUI_DrawString( x + SMALLCHAR_WIDTH, y, s->string, style|UI_LEFT, color );\n}\n\n\n/*\n=================\nServerOptions_MenuInit\n=================\n*/\n#define OPTIONS_X\t456\n\nstatic void ServerOptions_MenuInit( qboolean multiplayer ) {\n\tint\t\ty;\n\tint\t\tn;\n\n\tmemset( &s_serveroptions, 0 ,sizeof(serveroptions_t) );\n\ts_serveroptions.multiplayer = multiplayer;\n\ts_serveroptions.gametype = (int)Com_Clamp( 0, 5, trap_Cvar_VariableValue( \"g_gameType\" ) );\n\ts_serveroptions.punkbuster.curvalue = Com_Clamp( 0, 1, trap_Cvar_VariableValue( \"sv_punkbuster\" ) );\n\n\tServerOptions_Cache();\n\n\ts_serveroptions.menu.wrapAround = qtrue;\n\ts_serveroptions.menu.fullscreen = qtrue;\n\n\ts_serveroptions.banner.generic.type\t\t\t= MTYPE_BTEXT;\n\ts_serveroptions.banner.generic.x\t\t\t= 320;\n\ts_serveroptions.banner.generic.y\t\t\t= 16;\n\ts_serveroptions.banner.string  \t\t\t\t= \"GAME SERVER\";\n\ts_serveroptions.banner.color  \t\t\t\t= color_white;\n\ts_serveroptions.banner.style  \t\t\t\t= UI_CENTER;\n\n\ts_serveroptions.mappic.generic.type\t\t\t= MTYPE_BITMAP;\n\ts_serveroptions.mappic.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_INACTIVE;\n\ts_serveroptions.mappic.generic.x\t\t\t= 352;\n\ts_serveroptions.mappic.generic.y\t\t\t= 80;\n\ts_serveroptions.mappic.width\t\t\t\t= 160;\n\ts_serveroptions.mappic.height\t\t\t\t= 120;\n\ts_serveroptions.mappic.errorpic\t\t\t\t= GAMESERVER_UNKNOWNMAP;\n\ts_serveroptions.mappic.generic.ownerdraw\t= ServerOptions_LevelshotDraw;\n\n\ts_serveroptions.picframe.generic.type\t\t= MTYPE_BITMAP;\n\ts_serveroptions.picframe.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_INACTIVE|QMF_HIGHLIGHT;\n\ts_serveroptions.picframe.generic.x\t\t\t= 352 - 38;\n\ts_serveroptions.picframe.generic.y\t\t\t= 80 - 40;\n\ts_serveroptions.picframe.width  \t\t\t= 320;\n\ts_serveroptions.picframe.height  \t\t\t= 320;\n\ts_serveroptions.picframe.focuspic\t\t\t= GAMESERVER_SELECT;\n\n\ty = 272;\n\tif( s_serveroptions.gametype != GT_CTF ) {\n\t\ts_serveroptions.fraglimit.generic.type       = MTYPE_FIELD;\n\t\ts_serveroptions.fraglimit.generic.name       = \"Frag Limit:\";\n\t\ts_serveroptions.fraglimit.generic.flags      = QMF_NUMBERSONLY|QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\t\ts_serveroptions.fraglimit.generic.x\t         = OPTIONS_X;\n\t\ts_serveroptions.fraglimit.generic.y\t         = y;\n\t\ts_serveroptions.fraglimit.generic.statusbar  = ServerOptions_StatusBar;\n\t\ts_serveroptions.fraglimit.field.widthInChars = 3;\n\t\ts_serveroptions.fraglimit.field.maxchars     = 3;\n\t}\n\telse {\n\t\ts_serveroptions.flaglimit.generic.type       = MTYPE_FIELD;\n\t\ts_serveroptions.flaglimit.generic.name       = \"Capture Limit:\";\n\t\ts_serveroptions.flaglimit.generic.flags      = QMF_NUMBERSONLY|QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\t\ts_serveroptions.flaglimit.generic.x\t         = OPTIONS_X;\n\t\ts_serveroptions.flaglimit.generic.y\t         = y;\n\t\ts_serveroptions.flaglimit.generic.statusbar  = ServerOptions_StatusBar;\n\t\ts_serveroptions.flaglimit.field.widthInChars = 3;\n\t\ts_serveroptions.flaglimit.field.maxchars     = 3;\n\t}\n\n\ty += BIGCHAR_HEIGHT+2;\n\ts_serveroptions.timelimit.generic.type       = MTYPE_FIELD;\n\ts_serveroptions.timelimit.generic.name       = \"Time Limit:\";\n\ts_serveroptions.timelimit.generic.flags      = QMF_NUMBERSONLY|QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_serveroptions.timelimit.generic.x\t         = OPTIONS_X;\n\ts_serveroptions.timelimit.generic.y\t         = y;\n\ts_serveroptions.timelimit.generic.statusbar  = ServerOptions_StatusBar;\n\ts_serveroptions.timelimit.field.widthInChars = 3;\n\ts_serveroptions.timelimit.field.maxchars     = 3;\n\n\tif( s_serveroptions.gametype >= GT_TEAM ) {\n\t\ty += BIGCHAR_HEIGHT+2;\n\t\ts_serveroptions.friendlyfire.generic.type     = MTYPE_RADIOBUTTON;\n\t\ts_serveroptions.friendlyfire.generic.flags    = QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\t\ts_serveroptions.friendlyfire.generic.x\t      = OPTIONS_X;\n\t\ts_serveroptions.friendlyfire.generic.y\t      = y;\n\t\ts_serveroptions.friendlyfire.generic.name\t  = \"Friendly Fire:\";\n\t}\n\n\ty += BIGCHAR_HEIGHT+2;\n\ts_serveroptions.pure.generic.type\t\t\t= MTYPE_RADIOBUTTON;\n\ts_serveroptions.pure.generic.flags\t\t\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_serveroptions.pure.generic.x\t\t\t\t= OPTIONS_X;\n\ts_serveroptions.pure.generic.y\t\t\t\t= y;\n\ts_serveroptions.pure.generic.name\t\t\t= \"Pure Server:\";\n\n\tif( s_serveroptions.multiplayer ) {\n\t\ty += BIGCHAR_HEIGHT+2;\n\t\ts_serveroptions.dedicated.generic.type\t\t= MTYPE_SPINCONTROL;\n\t\ts_serveroptions.dedicated.generic.id\t\t= ID_DEDICATED;\n\t\ts_serveroptions.dedicated.generic.flags\t\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\t\ts_serveroptions.dedicated.generic.callback\t= ServerOptions_Event;\n\t\ts_serveroptions.dedicated.generic.x\t\t\t= OPTIONS_X;\n\t\ts_serveroptions.dedicated.generic.y\t\t\t= y;\n\t\ts_serveroptions.dedicated.generic.name\t\t= \"Dedicated:\";\n\t\ts_serveroptions.dedicated.itemnames\t\t\t= dedicated_list;\n\t}\n\n\tif( s_serveroptions.multiplayer ) {\n\t\ty += BIGCHAR_HEIGHT+2;\n\t\ts_serveroptions.hostname.generic.type       = MTYPE_FIELD;\n\t\ts_serveroptions.hostname.generic.name       = \"Hostname:\";\n\t\ts_serveroptions.hostname.generic.flags      = QMF_SMALLFONT;\n\t\ts_serveroptions.hostname.generic.x          = OPTIONS_X;\n\t\ts_serveroptions.hostname.generic.y\t        = y;\n\t\ts_serveroptions.hostname.field.widthInChars = 18;\n\t\ts_serveroptions.hostname.field.maxchars     = 64;\n\t}\n\n\ty += BIGCHAR_HEIGHT+2;\n\ts_serveroptions.punkbuster.generic.type\t\t\t= MTYPE_SPINCONTROL;\n\ts_serveroptions.punkbuster.generic.name\t\t\t= \"Punkbuster:\";\n\ts_serveroptions.punkbuster.generic.flags\t\t\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_serveroptions.punkbuster.generic.id\t\t\t= 0;\n\ts_serveroptions.punkbuster.generic.x\t\t\t\t= OPTIONS_X;\n\ts_serveroptions.punkbuster.generic.y\t\t\t\t= y;\n\ts_serveroptions.punkbuster.itemnames\t\t\t\t= punkbuster_items;\n\t\n\ty = 80;\n\ts_serveroptions.botSkill.generic.type\t\t\t= MTYPE_SPINCONTROL;\n\ts_serveroptions.botSkill.generic.flags\t\t\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_serveroptions.botSkill.generic.name\t\t\t= \"Bot Skill:  \";\n\ts_serveroptions.botSkill.generic.x\t\t\t\t= 32 + (strlen(s_serveroptions.botSkill.generic.name) + 2 ) * SMALLCHAR_WIDTH;\n\ts_serveroptions.botSkill.generic.y\t\t\t\t= y;\n\ts_serveroptions.botSkill.itemnames\t\t\t\t= botSkill_list;\n\ts_serveroptions.botSkill.curvalue\t\t\t\t= 1;\n\n\ty += ( 2 * SMALLCHAR_HEIGHT );\n\ts_serveroptions.player0.generic.type\t\t\t= MTYPE_TEXT;\n\ts_serveroptions.player0.generic.flags\t\t\t= QMF_SMALLFONT;\n\ts_serveroptions.player0.generic.x\t\t\t\t= 32 + SMALLCHAR_WIDTH;\n\ts_serveroptions.player0.generic.y\t\t\t\t= y;\n\ts_serveroptions.player0.color\t\t\t\t\t= color_orange;\n\ts_serveroptions.player0.style\t\t\t\t\t= UI_LEFT|UI_SMALLFONT;\n\n\tfor( n = 0; n < PLAYER_SLOTS; n++ ) {\n\t\ts_serveroptions.playerType[n].generic.type\t\t= MTYPE_SPINCONTROL;\n\t\ts_serveroptions.playerType[n].generic.flags\t\t= QMF_SMALLFONT;\n\t\ts_serveroptions.playerType[n].generic.id\t\t= ID_PLAYER_TYPE;\n\t\ts_serveroptions.playerType[n].generic.callback\t= ServerOptions_Event;\n\t\ts_serveroptions.playerType[n].generic.x\t\t\t= 32;\n\t\ts_serveroptions.playerType[n].generic.y\t\t\t= y;\n\t\ts_serveroptions.playerType[n].itemnames\t\t\t= playerType_list;\n\n\t\ts_serveroptions.playerName[n].generic.type\t\t= MTYPE_TEXT;\n\t\ts_serveroptions.playerName[n].generic.flags\t\t= QMF_SMALLFONT;\n\t\ts_serveroptions.playerName[n].generic.x\t\t\t= 96;\n\t\ts_serveroptions.playerName[n].generic.y\t\t\t= y;\n\t\ts_serveroptions.playerName[n].generic.callback\t= ServerOptions_PlayerNameEvent;\n\t\ts_serveroptions.playerName[n].generic.id\t\t= n;\n\t\ts_serveroptions.playerName[n].generic.ownerdraw\t= PlayerName_Draw;\n\t\ts_serveroptions.playerName[n].color\t\t\t\t= color_orange;\n\t\ts_serveroptions.playerName[n].style\t\t\t\t= UI_SMALLFONT;\n\t\ts_serveroptions.playerName[n].string\t\t\t= s_serveroptions.playerNameBuffers[n];\n\t\ts_serveroptions.playerName[n].generic.top\t\t= s_serveroptions.playerName[n].generic.y;\n\t\ts_serveroptions.playerName[n].generic.bottom\t= s_serveroptions.playerName[n].generic.y + SMALLCHAR_HEIGHT;\n\t\ts_serveroptions.playerName[n].generic.left\t\t= s_serveroptions.playerName[n].generic.x - SMALLCHAR_HEIGHT/ 2;\n\t\ts_serveroptions.playerName[n].generic.right\t\t= s_serveroptions.playerName[n].generic.x + 16 * SMALLCHAR_WIDTH;\n\n\t\ts_serveroptions.playerTeam[n].generic.type\t\t= MTYPE_SPINCONTROL;\n\t\ts_serveroptions.playerTeam[n].generic.flags\t\t= QMF_SMALLFONT;\n\t\ts_serveroptions.playerTeam[n].generic.x\t\t\t= 240;\n\t\ts_serveroptions.playerTeam[n].generic.y\t\t\t= y;\n\t\ts_serveroptions.playerTeam[n].itemnames\t\t\t= playerTeam_list;\n\n\t\ty += ( SMALLCHAR_HEIGHT + 4 );\n\t}\n\n\ts_serveroptions.back.generic.type\t  = MTYPE_BITMAP;\n\ts_serveroptions.back.generic.name     = GAMESERVER_BACK0;\n\ts_serveroptions.back.generic.flags    = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_serveroptions.back.generic.callback = ServerOptions_Event;\n\ts_serveroptions.back.generic.id\t      = ID_BACK;\n\ts_serveroptions.back.generic.x\t\t  = 0;\n\ts_serveroptions.back.generic.y\t\t  = 480-64;\n\ts_serveroptions.back.width  \t\t  = 128;\n\ts_serveroptions.back.height  \t\t  = 64;\n\ts_serveroptions.back.focuspic         = GAMESERVER_BACK1;\n\n\ts_serveroptions.next.generic.type\t  = MTYPE_BITMAP;\n\ts_serveroptions.next.generic.name     = GAMESERVER_NEXT0;\n\ts_serveroptions.next.generic.flags    = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_INACTIVE|QMF_GRAYED|QMF_HIDDEN;\n\ts_serveroptions.next.generic.callback = ServerOptions_Event;\n\ts_serveroptions.next.generic.id\t      = ID_STARTSERVERNEXT;\n\ts_serveroptions.next.generic.x\t\t  = 640;\n\ts_serveroptions.next.generic.y\t\t  = 480-64-72;\n\ts_serveroptions.next.generic.statusbar  = ServerOptions_StatusBar;\n\ts_serveroptions.next.width  \t\t  = 128;\n\ts_serveroptions.next.height  \t\t  = 64;\n\ts_serveroptions.next.focuspic         = GAMESERVER_NEXT1;\n\n\ts_serveroptions.go.generic.type\t    = MTYPE_BITMAP;\n\ts_serveroptions.go.generic.name     = GAMESERVER_FIGHT0;\n\ts_serveroptions.go.generic.flags    = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_serveroptions.go.generic.callback = ServerOptions_Event;\n\ts_serveroptions.go.generic.id\t    = ID_GO;\n\ts_serveroptions.go.generic.x\t\t= 640;\n\ts_serveroptions.go.generic.y\t\t= 480-64;\n\ts_serveroptions.go.width  \t\t    = 128;\n\ts_serveroptions.go.height  \t\t    = 64;\n\ts_serveroptions.go.focuspic         = GAMESERVER_FIGHT1;\n\n\tMenu_AddItem( &s_serveroptions.menu, &s_serveroptions.banner );\n\n\tMenu_AddItem( &s_serveroptions.menu, &s_serveroptions.mappic );\n\tMenu_AddItem( &s_serveroptions.menu, &s_serveroptions.picframe );\n\n\tMenu_AddItem( &s_serveroptions.menu, &s_serveroptions.botSkill );\n\tMenu_AddItem( &s_serveroptions.menu, &s_serveroptions.player0 );\n\tfor( n = 0; n < PLAYER_SLOTS; n++ ) {\n\t\tif( n != 0 ) {\n\t\t\tMenu_AddItem( &s_serveroptions.menu, &s_serveroptions.playerType[n] );\n\t\t}\n\t\tMenu_AddItem( &s_serveroptions.menu, &s_serveroptions.playerName[n] );\n\t\tif( s_serveroptions.gametype >= GT_TEAM ) {\n\t\t\tMenu_AddItem( &s_serveroptions.menu, &s_serveroptions.playerTeam[n] );\n\t\t}\n\t}\n\n\tif( s_serveroptions.gametype != GT_CTF ) {\n\t\tMenu_AddItem( &s_serveroptions.menu, &s_serveroptions.fraglimit );\n\t}\n\telse {\n\t\tMenu_AddItem( &s_serveroptions.menu, &s_serveroptions.flaglimit );\n\t}\n\tMenu_AddItem( &s_serveroptions.menu, &s_serveroptions.timelimit );\n\tif( s_serveroptions.gametype >= GT_TEAM ) {\n\t\tMenu_AddItem( &s_serveroptions.menu, &s_serveroptions.friendlyfire );\n\t}\n\tMenu_AddItem( &s_serveroptions.menu, &s_serveroptions.pure );\n\tif( s_serveroptions.multiplayer ) {\n\t\tMenu_AddItem( &s_serveroptions.menu, &s_serveroptions.dedicated );\n\t}\n\tif( s_serveroptions.multiplayer ) {\n\t\tMenu_AddItem( &s_serveroptions.menu, &s_serveroptions.hostname );\n\t}\n\n\tMenu_AddItem( &s_serveroptions.menu, &s_serveroptions.back );\n\tMenu_AddItem( &s_serveroptions.menu, &s_serveroptions.next );\n\tMenu_AddItem( &s_serveroptions.menu, &s_serveroptions.go );\n\n\tMenu_AddItem( &s_serveroptions.menu, (void*) &s_serveroptions.punkbuster );\n\t\n\tServerOptions_SetMenuItems();\n}\n\n/*\n=================\nServerOptions_Cache\n=================\n*/\nvoid ServerOptions_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( GAMESERVER_BACK0 );\n\ttrap_R_RegisterShaderNoMip( GAMESERVER_BACK1 );\n\ttrap_R_RegisterShaderNoMip( GAMESERVER_FIGHT0 );\n\ttrap_R_RegisterShaderNoMip( GAMESERVER_FIGHT1 );\n\ttrap_R_RegisterShaderNoMip( GAMESERVER_SELECT );\n\ttrap_R_RegisterShaderNoMip( GAMESERVER_UNKNOWNMAP );\n}\n\n\n/*\n=================\nUI_ServerOptionsMenu\n=================\n*/\nstatic void UI_ServerOptionsMenu( qboolean multiplayer ) {\n\tServerOptions_MenuInit( multiplayer );\n\tUI_PushMenu( &s_serveroptions.menu );\n}\n\n\n\n/*\n=============================================================================\n\nBOT SELECT MENU *****\n\n=============================================================================\n*/\n\n\n#define BOTSELECT_BACK0\t\t\t\"menu/art/back_0\"\n#define BOTSELECT_BACK1\t\t\t\"menu/art/back_1\"\n#define BOTSELECT_ACCEPT0\t\t\"menu/art/accept_0\"\n#define BOTSELECT_ACCEPT1\t\t\"menu/art/accept_1\"\n#define BOTSELECT_SELECT\t\t\"menu/art/opponents_select\"\n#define BOTSELECT_SELECTED\t\t\"menu/art/opponents_selected\"\n#define BOTSELECT_ARROWS\t\t\"menu/art/gs_arrows_0\"\n#define BOTSELECT_ARROWSL\t\t\"menu/art/gs_arrows_l\"\n#define BOTSELECT_ARROWSR\t\t\"menu/art/gs_arrows_r\"\n\n#define PLAYERGRID_COLS\t\t\t4\n#define PLAYERGRID_ROWS\t\t\t4\n#define MAX_MODELSPERPAGE\t\t(PLAYERGRID_ROWS * PLAYERGRID_COLS)\n\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n\n\tmenutext_s\t\tbanner;\n\n\tmenubitmap_s\tpics[MAX_MODELSPERPAGE];\n\tmenubitmap_s\tpicbuttons[MAX_MODELSPERPAGE];\n\tmenutext_s\t\tpicnames[MAX_MODELSPERPAGE];\n\n\tmenubitmap_s\tarrows;\n\tmenubitmap_s\tleft;\n\tmenubitmap_s\tright;\n\n\tmenubitmap_s\tgo;\n\tmenubitmap_s\tback;\n\n\tint\t\t\t\tnumBots;\n\tint\t\t\t\tmodelpage;\n\tint\t\t\t\tnumpages;\n\tint\t\t\t\tselectedmodel;\n\tint\t\t\t\tsortedBotNums[MAX_BOTS];\n\tchar\t\t\tboticons[MAX_MODELSPERPAGE][MAX_QPATH];\n\tchar\t\t\tbotnames[MAX_MODELSPERPAGE][16];\n} botSelectInfo_t;\n\nstatic botSelectInfo_t\tbotSelectInfo;\n\n\n/*\n=================\nUI_BotSelectMenu_SortCompare\n=================\n*/\nstatic int QDECL UI_BotSelectMenu_SortCompare( const void *arg1, const void *arg2 ) {\n\tint\t\t\tnum1, num2;\n\tconst char\t*info1, *info2;\n\tconst char\t*name1, *name2;\n\n\tnum1 = *(int *)arg1;\n\tnum2 = *(int *)arg2;\n\n\tinfo1 = UI_GetBotInfoByNumber( num1 );\n\tinfo2 = UI_GetBotInfoByNumber( num2 );\n\n\tname1 = Info_ValueForKey( info1, \"name\" );\n\tname2 = Info_ValueForKey( info2, \"name\" );\n\n\treturn Q_stricmp( name1, name2 );\n}\n\n\n/*\n=================\nUI_BotSelectMenu_BuildList\n=================\n*/\nstatic void UI_BotSelectMenu_BuildList( void ) {\n\tint\t\tn;\n\n\tbotSelectInfo.modelpage = 0;\n\tbotSelectInfo.numBots = UI_GetNumBots();\n\tbotSelectInfo.numpages = botSelectInfo.numBots / MAX_MODELSPERPAGE;\n\tif( botSelectInfo.numBots % MAX_MODELSPERPAGE ) {\n\t\tbotSelectInfo.numpages++;\n\t}\n\n\t// initialize the array\n\tfor( n = 0; n < botSelectInfo.numBots; n++ ) {\n\t\tbotSelectInfo.sortedBotNums[n] = n;\n\t}\n\n\t// now sort it\n\tqsort( botSelectInfo.sortedBotNums, botSelectInfo.numBots, sizeof(botSelectInfo.sortedBotNums[0]), UI_BotSelectMenu_SortCompare );\n}\n\n\n/*\n=================\nServerPlayerIcon\n=================\n*/\nstatic void ServerPlayerIcon( const char *modelAndSkin, char *iconName, int iconNameMaxSize ) {\n\tchar\t*skin;\n\tchar\tmodel[MAX_QPATH];\n\n\tQ_strncpyz( model, modelAndSkin, sizeof(model));\n\tskin = Q_strrchr( model, '/' );\n\tif ( skin ) {\n\t\t*skin++ = '\\0';\n\t}\n\telse {\n\t\tskin = \"default\";\n\t}\n\n\tCom_sprintf(iconName, iconNameMaxSize, \"models/players/%s/icon_%s.tga\", model, skin );\n\n\tif( !trap_R_RegisterShaderNoMip( iconName ) && Q_stricmp( skin, \"default\" ) != 0 ) {\n\t\tCom_sprintf(iconName, iconNameMaxSize, \"models/players/%s/icon_default.tga\", model );\n\t}\n}\n\n\n/*\n=================\nUI_BotSelectMenu_UpdateGrid\n=================\n*/\nstatic void UI_BotSelectMenu_UpdateGrid( void ) {\n\tconst char\t*info;\n\tint\t\t\ti;\n    int\t\t\tj;\n\n\tj = botSelectInfo.modelpage * MAX_MODELSPERPAGE;\n\tfor( i = 0; i < (PLAYERGRID_ROWS * PLAYERGRID_COLS); i++, j++) {\n\t\tif( j < botSelectInfo.numBots ) { \n\t\t\tinfo = UI_GetBotInfoByNumber( botSelectInfo.sortedBotNums[j] );\n\t\t\tServerPlayerIcon( Info_ValueForKey( info, \"model\" ), botSelectInfo.boticons[i], MAX_QPATH );\n\t\t\tQ_strncpyz( botSelectInfo.botnames[i], Info_ValueForKey( info, \"name\" ), 16 );\n\t\t\tQ_CleanStr( botSelectInfo.botnames[i] );\n \t\t\tbotSelectInfo.pics[i].generic.name = botSelectInfo.boticons[i];\n\t\t\tif( BotAlreadySelected( botSelectInfo.botnames[i] ) ) {\n\t\t\t\tbotSelectInfo.picnames[i].color = color_red;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tbotSelectInfo.picnames[i].color = color_orange;\n\t\t\t}\n\t\t\tbotSelectInfo.picbuttons[i].generic.flags &= ~QMF_INACTIVE;\n\t\t}\n\t\telse {\n\t\t\t// dead slot\n \t\t\tbotSelectInfo.pics[i].generic.name         = NULL;\n\t\t\tbotSelectInfo.picbuttons[i].generic.flags |= QMF_INACTIVE;\n\t\t\tbotSelectInfo.botnames[i][0] = 0;\n\t\t}\n\n \t\tbotSelectInfo.pics[i].generic.flags       &= ~QMF_HIGHLIGHT;\n \t\tbotSelectInfo.pics[i].shader               = 0;\n \t\tbotSelectInfo.picbuttons[i].generic.flags |= QMF_PULSEIFFOCUS;\n\t}\n\n\t// set selected model\n\ti = botSelectInfo.selectedmodel % MAX_MODELSPERPAGE;\n\tbotSelectInfo.pics[i].generic.flags |= QMF_HIGHLIGHT;\n\tbotSelectInfo.picbuttons[i].generic.flags &= ~QMF_PULSEIFFOCUS;\n\n\tif( botSelectInfo.numpages > 1 ) {\n\t\tif( botSelectInfo.modelpage > 0 ) {\n\t\t\tbotSelectInfo.left.generic.flags &= ~QMF_INACTIVE;\n\t\t}\n\t\telse {\n\t\t\tbotSelectInfo.left.generic.flags |= QMF_INACTIVE;\n\t\t}\n\n\t\tif( botSelectInfo.modelpage < (botSelectInfo.numpages - 1) ) {\n\t\t\tbotSelectInfo.right.generic.flags &= ~QMF_INACTIVE;\n\t\t}\n\t\telse {\n\t\t\tbotSelectInfo.right.generic.flags |= QMF_INACTIVE;\n\t\t}\n\t}\n\telse {\n\t\t// hide left/right markers\n\t\tbotSelectInfo.left.generic.flags |= QMF_INACTIVE;\n\t\tbotSelectInfo.right.generic.flags |= QMF_INACTIVE;\n\t}\n}\n\n\n/*\n=================\nUI_BotSelectMenu_Default\n=================\n*/\nstatic void UI_BotSelectMenu_Default( char *bot ) {\n\tconst char\t*botInfo;\n\tconst char\t*test;\n\tint\t\t\tn;\n\tint\t\t\ti;\n\n\tfor( n = 0; n < botSelectInfo.numBots; n++ ) {\n\t\tbotInfo = UI_GetBotInfoByNumber( n );\n\t\ttest = Info_ValueForKey( botInfo, \"name\" );\n\t\tif( Q_stricmp( bot, test ) == 0 ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif( n == botSelectInfo.numBots ) {\n\t\tbotSelectInfo.selectedmodel = 0;\n\t\treturn;\n\t}\n\n\tfor( i = 0; i < botSelectInfo.numBots; i++ ) {\n\t\tif( botSelectInfo.sortedBotNums[i] == n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif( i == botSelectInfo.numBots ) {\n\t\tbotSelectInfo.selectedmodel = 0;\n\t\treturn;\n\t}\n\n\tbotSelectInfo.selectedmodel = i;\n}\n\n\n/*\n=================\nUI_BotSelectMenu_LeftEvent\n=================\n*/\nstatic void UI_BotSelectMenu_LeftEvent( void* ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\tif( botSelectInfo.modelpage > 0 ) {\n\t\tbotSelectInfo.modelpage--;\n\t\tbotSelectInfo.selectedmodel = botSelectInfo.modelpage * MAX_MODELSPERPAGE;\n\t\tUI_BotSelectMenu_UpdateGrid();\n\t}\n}\n\n\n/*\n=================\nUI_BotSelectMenu_RightEvent\n=================\n*/\nstatic void UI_BotSelectMenu_RightEvent( void* ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\tif( botSelectInfo.modelpage < botSelectInfo.numpages - 1 ) {\n\t\tbotSelectInfo.modelpage++;\n\t\tbotSelectInfo.selectedmodel = botSelectInfo.modelpage * MAX_MODELSPERPAGE;\n\t\tUI_BotSelectMenu_UpdateGrid();\n\t}\n}\n\n\n/*\n=================\nUI_BotSelectMenu_BotEvent\n=================\n*/\nstatic void UI_BotSelectMenu_BotEvent( void* ptr, int event ) {\n\tint\t\ti;\n\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tfor( i = 0; i < (PLAYERGRID_ROWS * PLAYERGRID_COLS); i++ ) {\n \t\tbotSelectInfo.pics[i].generic.flags &= ~QMF_HIGHLIGHT;\n \t\tbotSelectInfo.picbuttons[i].generic.flags |= QMF_PULSEIFFOCUS;\n\t}\n\n\t// set selected\n\ti = ((menucommon_s*)ptr)->id;\n\tbotSelectInfo.pics[i].generic.flags |= QMF_HIGHLIGHT;\n\tbotSelectInfo.picbuttons[i].generic.flags &= ~QMF_PULSEIFFOCUS;\n\tbotSelectInfo.selectedmodel = botSelectInfo.modelpage * MAX_MODELSPERPAGE + i;\n}\n\n\n/*\n=================\nUI_BotSelectMenu_BackEvent\n=================\n*/\nstatic void UI_BotSelectMenu_BackEvent( void* ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\tUI_PopMenu();\n}\n\n\n/*\n=================\nUI_BotSelectMenu_SelectEvent\n=================\n*/\nstatic void UI_BotSelectMenu_SelectEvent( void* ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\tUI_PopMenu();\n\n\ts_serveroptions.newBot = qtrue;\n\tQ_strncpyz( s_serveroptions.newBotName, botSelectInfo.botnames[botSelectInfo.selectedmodel % MAX_MODELSPERPAGE], 16 );\n}\n\n\n/*\n=================\nUI_BotSelectMenu_Cache\n=================\n*/\nvoid UI_BotSelectMenu_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( BOTSELECT_BACK0 );\n\ttrap_R_RegisterShaderNoMip( BOTSELECT_BACK1 );\n\ttrap_R_RegisterShaderNoMip( BOTSELECT_ACCEPT0 );\n\ttrap_R_RegisterShaderNoMip( BOTSELECT_ACCEPT1 );\n\ttrap_R_RegisterShaderNoMip( BOTSELECT_SELECT );\n\ttrap_R_RegisterShaderNoMip( BOTSELECT_SELECTED );\n\ttrap_R_RegisterShaderNoMip( BOTSELECT_ARROWS );\n\ttrap_R_RegisterShaderNoMip( BOTSELECT_ARROWSL );\n\ttrap_R_RegisterShaderNoMip( BOTSELECT_ARROWSR );\n}\n\n\nstatic void UI_BotSelectMenu_Init( char *bot ) {\n\tint\t\ti, j, k;\n\tint\t\tx, y;\n\n\tmemset( &botSelectInfo, 0 ,sizeof(botSelectInfo) );\n\tbotSelectInfo.menu.wrapAround = qtrue;\n\tbotSelectInfo.menu.fullscreen = qtrue;\n\n\tUI_BotSelectMenu_Cache();\n\n\tbotSelectInfo.banner.generic.type\t= MTYPE_BTEXT;\n\tbotSelectInfo.banner.generic.x\t\t= 320;\n\tbotSelectInfo.banner.generic.y\t\t= 16;\n\tbotSelectInfo.banner.string\t\t\t= \"SELECT BOT\";\n\tbotSelectInfo.banner.color\t\t\t= color_white;\n\tbotSelectInfo.banner.style\t\t\t= UI_CENTER;\n\n\ty =\t80;\n\tfor( i = 0, k = 0; i < PLAYERGRID_ROWS; i++) {\n\t\tx =\t180;\n\t\tfor( j = 0; j < PLAYERGRID_COLS; j++, k++ ) {\n\t\t\tbotSelectInfo.pics[k].generic.type\t\t\t\t= MTYPE_BITMAP;\n\t\t\tbotSelectInfo.pics[k].generic.flags\t\t\t\t= QMF_LEFT_JUSTIFY|QMF_INACTIVE;\n\t\t\tbotSelectInfo.pics[k].generic.x\t\t\t\t\t= x;\n\t\t\tbotSelectInfo.pics[k].generic.y\t\t\t\t\t= y;\n \t\t\tbotSelectInfo.pics[k].generic.name\t\t\t\t= botSelectInfo.boticons[k];\n\t\t\tbotSelectInfo.pics[k].width\t\t\t\t\t\t= 64;\n\t\t\tbotSelectInfo.pics[k].height\t\t\t\t\t= 64;\n\t\t\tbotSelectInfo.pics[k].focuspic\t\t\t\t\t= BOTSELECT_SELECTED;\n\t\t\tbotSelectInfo.pics[k].focuscolor\t\t\t\t= colorRed;\n\n\t\t\tbotSelectInfo.picbuttons[k].generic.type\t\t= MTYPE_BITMAP;\n\t\t\tbotSelectInfo.picbuttons[k].generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_NODEFAULTINIT|QMF_PULSEIFFOCUS;\n\t\t\tbotSelectInfo.picbuttons[k].generic.callback\t= UI_BotSelectMenu_BotEvent;\n\t\t\tbotSelectInfo.picbuttons[k].generic.id\t\t\t= k;\n\t\t\tbotSelectInfo.picbuttons[k].generic.x\t\t\t= x - 16;\n\t\t\tbotSelectInfo.picbuttons[k].generic.y\t\t\t= y - 16;\n\t\t\tbotSelectInfo.picbuttons[k].generic.left\t\t= x;\n\t\t\tbotSelectInfo.picbuttons[k].generic.top\t\t\t= y;\n\t\t\tbotSelectInfo.picbuttons[k].generic.right\t\t= x + 64;\n\t\t\tbotSelectInfo.picbuttons[k].generic.bottom\t\t= y + 64;\n\t\t\tbotSelectInfo.picbuttons[k].width\t\t\t\t= 128;\n\t\t\tbotSelectInfo.picbuttons[k].height\t\t\t\t= 128;\n\t\t\tbotSelectInfo.picbuttons[k].focuspic\t\t\t= BOTSELECT_SELECT;\n\t\t\tbotSelectInfo.picbuttons[k].focuscolor\t\t\t= colorRed;\n\n\t\t\tbotSelectInfo.picnames[k].generic.type\t\t\t= MTYPE_TEXT;\n\t\t\tbotSelectInfo.picnames[k].generic.flags\t\t\t= QMF_SMALLFONT;\n\t\t\tbotSelectInfo.picnames[k].generic.x\t\t\t\t= x + 32;\n\t\t\tbotSelectInfo.picnames[k].generic.y\t\t\t\t= y + 64;\n\t\t\tbotSelectInfo.picnames[k].string\t\t\t\t= botSelectInfo.botnames[k];\n\t\t\tbotSelectInfo.picnames[k].color\t\t\t\t\t= color_orange;\n\t\t\tbotSelectInfo.picnames[k].style\t\t\t\t\t= UI_CENTER|UI_SMALLFONT;\n\n\t\t\tx += (64 + 6);\n\t\t}\n\t\ty += (64 + SMALLCHAR_HEIGHT + 6);\n\t}\n\n\tbotSelectInfo.arrows.generic.type\t\t= MTYPE_BITMAP;\n\tbotSelectInfo.arrows.generic.name\t\t= BOTSELECT_ARROWS;\n\tbotSelectInfo.arrows.generic.flags\t\t= QMF_INACTIVE;\n\tbotSelectInfo.arrows.generic.x\t\t\t= 260;\n\tbotSelectInfo.arrows.generic.y\t\t\t= 440;\n\tbotSelectInfo.arrows.width\t\t\t\t= 128;\n\tbotSelectInfo.arrows.height\t\t\t\t= 32;\n\n\tbotSelectInfo.left.generic.type\t\t\t= MTYPE_BITMAP;\n\tbotSelectInfo.left.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tbotSelectInfo.left.generic.callback\t\t= UI_BotSelectMenu_LeftEvent;\n\tbotSelectInfo.left.generic.x\t\t\t= 260;\n\tbotSelectInfo.left.generic.y\t\t\t= 440;\n\tbotSelectInfo.left.width  \t\t\t\t= 64;\n\tbotSelectInfo.left.height  \t\t\t\t= 32;\n\tbotSelectInfo.left.focuspic\t\t\t\t= BOTSELECT_ARROWSL;\n\n\tbotSelectInfo.right.generic.type\t    = MTYPE_BITMAP;\n\tbotSelectInfo.right.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tbotSelectInfo.right.generic.callback\t= UI_BotSelectMenu_RightEvent;\n\tbotSelectInfo.right.generic.x\t\t\t= 321;\n\tbotSelectInfo.right.generic.y\t\t\t= 440;\n\tbotSelectInfo.right.width  \t\t\t\t= 64;\n\tbotSelectInfo.right.height  \t\t    = 32;\n\tbotSelectInfo.right.focuspic\t\t\t= BOTSELECT_ARROWSR;\n\n\tbotSelectInfo.back.generic.type\t\t= MTYPE_BITMAP;\n\tbotSelectInfo.back.generic.name\t\t= BOTSELECT_BACK0;\n\tbotSelectInfo.back.generic.flags\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tbotSelectInfo.back.generic.callback\t= UI_BotSelectMenu_BackEvent;\n\tbotSelectInfo.back.generic.x\t\t= 0;\n\tbotSelectInfo.back.generic.y\t\t= 480-64;\n\tbotSelectInfo.back.width\t\t\t= 128;\n\tbotSelectInfo.back.height\t\t\t= 64;\n\tbotSelectInfo.back.focuspic\t\t\t= BOTSELECT_BACK1;\n\n\tbotSelectInfo.go.generic.type\t\t= MTYPE_BITMAP;\n\tbotSelectInfo.go.generic.name\t\t= BOTSELECT_ACCEPT0;\n\tbotSelectInfo.go.generic.flags\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tbotSelectInfo.go.generic.callback\t= UI_BotSelectMenu_SelectEvent;\n\tbotSelectInfo.go.generic.x\t\t\t= 640;\n\tbotSelectInfo.go.generic.y\t\t\t= 480-64;\n\tbotSelectInfo.go.width\t\t\t\t= 128;\n\tbotSelectInfo.go.height\t\t\t\t= 64;\n\tbotSelectInfo.go.focuspic\t\t\t= BOTSELECT_ACCEPT1;\n\n\tMenu_AddItem( &botSelectInfo.menu, &botSelectInfo.banner );\n\tfor( i = 0; i < MAX_MODELSPERPAGE; i++ ) {\n\t\tMenu_AddItem( &botSelectInfo.menu,\t&botSelectInfo.pics[i] );\n\t\tMenu_AddItem( &botSelectInfo.menu,\t&botSelectInfo.picbuttons[i] );\n\t\tMenu_AddItem( &botSelectInfo.menu,\t&botSelectInfo.picnames[i] );\n\t}\n\tMenu_AddItem( &botSelectInfo.menu, &botSelectInfo.arrows );\n\tMenu_AddItem( &botSelectInfo.menu, &botSelectInfo.left );\n\tMenu_AddItem( &botSelectInfo.menu, &botSelectInfo.right );\n\tMenu_AddItem( &botSelectInfo.menu, &botSelectInfo.back );\n\tMenu_AddItem( &botSelectInfo.menu, &botSelectInfo.go );\n\n\tUI_BotSelectMenu_BuildList();\n\tUI_BotSelectMenu_Default( bot );\n\tbotSelectInfo.modelpage = botSelectInfo.selectedmodel / MAX_MODELSPERPAGE;\n\tUI_BotSelectMenu_UpdateGrid();\n}\n\n\n/*\n=================\nUI_BotSelectMenu\n=================\n*/\nvoid UI_BotSelectMenu( char *bot ) {\n\tUI_BotSelectMenu_Init( bot );\n\tUI_PushMenu( &botSelectInfo.menu );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_team.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n//\n// ui_team.c\n//\n\n#include \"ui_local.h\"\n\n\n#define TEAMMAIN_FRAME\t\"menu/art/cut_frame\"\n\n#define ID_JOINRED\t\t100\n#define ID_JOINBLUE\t\t101\n#define ID_JOINGAME\t\t102\n#define ID_SPECTATE\t\t103\n\n\ntypedef struct\n{\n\tmenuframework_s\tmenu;\n\tmenubitmap_s\tframe;\n\tmenutext_s\t\tjoinred;\n\tmenutext_s\t\tjoinblue;\n\tmenutext_s\t\tjoingame;\n\tmenutext_s\t\tspectate;\n} teammain_t;\n\nstatic teammain_t\ts_teammain;\n\n// bk001204 - unused\n//static menuframework_s\ts_teammain_menu;\n//static menuaction_s\t\ts_teammain_orders;\n//static menuaction_s\t\ts_teammain_voice;\n//static menuaction_s\t\ts_teammain_joinred;\n//static menuaction_s\t\ts_teammain_joinblue;\n//static menuaction_s\t\ts_teammain_joingame;\n//static menuaction_s\t\ts_teammain_spectate;\n\n\n/*\n===============\nTeamMain_MenuEvent\n===============\n*/\nstatic void TeamMain_MenuEvent( void* ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\n\tswitch( ((menucommon_s*)ptr)->id ) {\n\tcase ID_JOINRED:\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"cmd team red\\n\" );\n\t\tUI_ForceMenuOff();\n\t\tbreak;\n\n\tcase ID_JOINBLUE:\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"cmd team blue\\n\" );\n\t\tUI_ForceMenuOff();\n\t\tbreak;\n\n\tcase ID_JOINGAME:\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"cmd team free\\n\" );\n\t\tUI_ForceMenuOff();\n\t\tbreak;\n\n\tcase ID_SPECTATE:\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"cmd team spectator\\n\" );\n\t\tUI_ForceMenuOff();\n\t\tbreak;\n\t}\n}\n\n\n/*\n===============\nTeamMain_MenuInit\n===============\n*/\nvoid TeamMain_MenuInit( void ) {\n\tint\t\ty;\n\tint\t\tgametype;\n\tchar\tinfo[MAX_INFO_STRING];\n\n\tmemset( &s_teammain, 0, sizeof(s_teammain) );\n\n\tTeamMain_Cache();\n\n\ts_teammain.menu.wrapAround = qtrue;\n\ts_teammain.menu.fullscreen = qfalse;\n\n\ts_teammain.frame.generic.type   = MTYPE_BITMAP;\n\ts_teammain.frame.generic.flags\t= QMF_INACTIVE;\n\ts_teammain.frame.generic.name   = TEAMMAIN_FRAME;\n\ts_teammain.frame.generic.x\t\t= 142;\n\ts_teammain.frame.generic.y\t\t= 118;\n\ts_teammain.frame.width\t\t\t= 359;\n\ts_teammain.frame.height\t\t\t= 256;\n\n\ty = 194;\n\n\ts_teammain.joinred.generic.type     = MTYPE_PTEXT;\n\ts_teammain.joinred.generic.flags    = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_teammain.joinred.generic.id       = ID_JOINRED;\n\ts_teammain.joinred.generic.callback = TeamMain_MenuEvent;\n\ts_teammain.joinred.generic.x        = 320;\n\ts_teammain.joinred.generic.y        = y;\n\ts_teammain.joinred.string           = \"JOIN RED\";\n\ts_teammain.joinred.style            = UI_CENTER|UI_SMALLFONT;\n\ts_teammain.joinred.color            = colorRed;\n\ty += 20;\n\n\ts_teammain.joinblue.generic.type     = MTYPE_PTEXT;\n\ts_teammain.joinblue.generic.flags    = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_teammain.joinblue.generic.id       = ID_JOINBLUE;\n\ts_teammain.joinblue.generic.callback = TeamMain_MenuEvent;\n\ts_teammain.joinblue.generic.x        = 320;\n\ts_teammain.joinblue.generic.y        = y;\n\ts_teammain.joinblue.string           = \"JOIN BLUE\";\n\ts_teammain.joinblue.style            = UI_CENTER|UI_SMALLFONT;\n\ts_teammain.joinblue.color            = colorRed;\n\ty += 20;\n\n\ts_teammain.joingame.generic.type     = MTYPE_PTEXT;\n\ts_teammain.joingame.generic.flags    = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_teammain.joingame.generic.id       = ID_JOINGAME;\n\ts_teammain.joingame.generic.callback = TeamMain_MenuEvent;\n\ts_teammain.joingame.generic.x        = 320;\n\ts_teammain.joingame.generic.y        = y;\n\ts_teammain.joingame.string           = \"JOIN GAME\";\n\ts_teammain.joingame.style            = UI_CENTER|UI_SMALLFONT;\n\ts_teammain.joingame.color            = colorRed;\n\ty += 20;\n\n\ts_teammain.spectate.generic.type     = MTYPE_PTEXT;\n\ts_teammain.spectate.generic.flags    = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_teammain.spectate.generic.id       = ID_SPECTATE;\n\ts_teammain.spectate.generic.callback = TeamMain_MenuEvent;\n\ts_teammain.spectate.generic.x        = 320;\n\ts_teammain.spectate.generic.y        = y;\n\ts_teammain.spectate.string           = \"SPECTATE\";\n\ts_teammain.spectate.style            = UI_CENTER|UI_SMALLFONT;\n\ts_teammain.spectate.color            = colorRed;\n\ty += 20;\n\n\ttrap_GetConfigString(CS_SERVERINFO, info, MAX_INFO_STRING);   \n\tgametype = atoi( Info_ValueForKey( info,\"g_gametype\" ) );\n\t\t\t      \n\t// set initial states\n\tswitch( gametype ) {\n\tcase GT_SINGLE_PLAYER:\n\tcase GT_FFA:\n\tcase GT_TOURNAMENT:\n\t\ts_teammain.joinred.generic.flags  |= QMF_GRAYED;\n\t\ts_teammain.joinblue.generic.flags |= QMF_GRAYED;\n\t\tbreak;\n\n\tdefault:\n\tcase GT_TEAM:\n\tcase GT_CTF:\n\t\ts_teammain.joingame.generic.flags |= QMF_GRAYED;\n\t\tbreak;\n\t}\n\n\tMenu_AddItem( &s_teammain.menu, (void*) &s_teammain.frame );\n\tMenu_AddItem( &s_teammain.menu, (void*) &s_teammain.joinred );\n\tMenu_AddItem( &s_teammain.menu, (void*) &s_teammain.joinblue );\n\tMenu_AddItem( &s_teammain.menu, (void*) &s_teammain.joingame );\n\tMenu_AddItem( &s_teammain.menu, (void*) &s_teammain.spectate );\n}\n\n\n/*\n===============\nTeamMain_Cache\n===============\n*/\nvoid TeamMain_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( TEAMMAIN_FRAME );\n}\n\n\n/*\n===============\nUI_TeamMainMenu\n===============\n*/\nvoid UI_TeamMainMenu( void ) {\n\tTeamMain_MenuInit();\n\tUI_PushMenu ( &s_teammain.menu );\n}\n"
  },
  {
    "path": "code/q3_ui/ui_teamorders.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=======================================================================\n\nTEAM ORDERS MENU\n\n=======================================================================\n*/\n\n\n#include \"ui_local.h\"\n\n\n#define ART_FRAME\t\t\"menu/art/addbotframe\"\n#define ART_BACK0\t\t\"menu/art/back_0\"\n#define ART_BACK1\t\t\"menu/art/back_1\"\t\n\n#define ID_LIST_BOTS\t\t10\n#define ID_LIST_CTF_ORDERS\t11\n#define ID_LIST_TEAM_ORDERS\t12\n\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n\n\tmenutext_s\t\tbanner;\n\tmenubitmap_s\tframe;\n\n\tmenulist_s\t\tlist;\n\n\tmenubitmap_s\tback;\n\n\tint\t\t\t\tgametype;\n\tint\t\t\t\tnumBots;\n\tint\t\t\t\tselectedBot;\n\tchar\t\t\t*bots[9];\n\tchar\t\t\tbotNames[9][16];\n} teamOrdersMenuInfo_t;\n\nstatic teamOrdersMenuInfo_t\tteamOrdersMenuInfo;\n\n#define NUM_CTF_ORDERS\t\t7\nstatic const char *ctfOrders[] = {\n\t\"I Am the Leader\",\n\t\"Defend the Base\",\n\t\"Follow Me\",\n\t\"Get Enemy Flag\",\n\t\"Camp Here\",\n\t\"Report\",\n\t\"I Relinquish Command\",\n\tNULL\n};\nstatic const char *ctfMessages[] = {\n\t\"i am the leader\",\n\t\"%s defend the base\",\n\t\"%s follow me\",\n\t\"%s get enemy flag\",\n\t\"%s camp here\",\n\t\"%s report\",\n\t\"i stop being the leader\",\n\tNULL\n};\n\n#define NUM_TEAM_ORDERS\t\t6\nstatic const char *teamOrders[] = {\n\t\"I Am the Leader\",\n\t\"Follow Me\",\n\t\"Roam\",\n\t\"Camp Here\",\n\t\"Report\",\n\t\"I Relinquish Command\",\n\tNULL\n};\nstatic const char *teamMessages[] = {\n\t\"i am the leader\",\n\t\"%s follow me\",\n\t\"%s roam\",\n\t\"%s camp here\",\n\t\"%s report\",\n\t\"i stop being the leader\",\n\tNULL\n};\n\n\n/*\n===============\nUI_TeamOrdersMenu_BackEvent\n===============\n*/\nstatic void UI_TeamOrdersMenu_BackEvent( void *ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t\treturn;\n\t}\n\tUI_PopMenu();\n}\n\n\n/*\n===============\nUI_TeamOrdersMenu_SetList\n===============\n*/\nstatic void UI_TeamOrdersMenu_SetList( int id ) {\n\tswitch( id ) {\n\tdefault:\n\tcase ID_LIST_BOTS:\n\t\tteamOrdersMenuInfo.list.generic.id = id;\n\t\tteamOrdersMenuInfo.list.numitems = teamOrdersMenuInfo.numBots;\n\t\tteamOrdersMenuInfo.list.itemnames = (const char **)teamOrdersMenuInfo.bots;\n\t\t break;\n\n\tcase ID_LIST_CTF_ORDERS:\n\t\tteamOrdersMenuInfo.list.generic.id = id;\n\t\tteamOrdersMenuInfo.list.numitems = NUM_CTF_ORDERS;\n\t\tteamOrdersMenuInfo.list.itemnames = ctfOrders;\n\t\tbreak;\n\n\tcase ID_LIST_TEAM_ORDERS:\n\t\tteamOrdersMenuInfo.list.generic.id = id;\n\t\tteamOrdersMenuInfo.list.numitems = NUM_TEAM_ORDERS;\n\t\tteamOrdersMenuInfo.list.itemnames = teamOrders;\n\t\tbreak;\n\t}\n\n\tteamOrdersMenuInfo.list.generic.bottom = teamOrdersMenuInfo.list.generic.top + teamOrdersMenuInfo.list.numitems * PROP_HEIGHT;\n}\n\n\n/*\n=================\nUI_TeamOrdersMenu_Key\n=================\n*/\nsfxHandle_t UI_TeamOrdersMenu_Key( int key ) {\n\tmenulist_s\t*l;\n\tint\tx;\n\tint\ty;\n\tint\tindex;\n\n\tl = (menulist_s\t*)Menu_ItemAtCursor( &teamOrdersMenuInfo.menu );\n\tif( l != &teamOrdersMenuInfo.list ) {\n\t\treturn Menu_DefaultKey( &teamOrdersMenuInfo.menu, key );\n\t}\n\n\tswitch( key ) {\n\t\tcase K_MOUSE1:\n\t\t\tx = l->generic.left;\n\t\t\ty = l->generic.top;\n\t\t\tif( UI_CursorInRect( x, y, l->generic.right - x, l->generic.bottom - y ) ) {\n\t\t\t\tindex = (uis.cursory - y) / PROP_HEIGHT;\n\t\t\t\tl->oldvalue = l->curvalue;\n\t\t\t\tl->curvalue = index;\n\n\t\t\t\tif( l->generic.callback ) {\n\t\t\t\t\tl->generic.callback( l, QM_ACTIVATED );\n\t\t\t\t\treturn menu_move_sound;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn menu_null_sound;\n\n\t\tcase K_KP_UPARROW:\n\t\tcase K_UPARROW:\n\t\t\tl->oldvalue = l->curvalue;\n\n\t\t\tif( l->curvalue == 0 ) {\n\t\t\t\tl->curvalue = l->numitems - 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tl->curvalue--;\n\t\t\t}\n\t\t\treturn menu_move_sound;\n\n\t\tcase K_KP_DOWNARROW:\n\t\tcase K_DOWNARROW:\n\t\t\tl->oldvalue = l->curvalue;\n\n\t\t\tif( l->curvalue == l->numitems - 1 ) {\n\t\t\t\tl->curvalue = 0;;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tl->curvalue++;\n\t\t\t}\n\t\t\treturn menu_move_sound;\n\t}\n\n\treturn Menu_DefaultKey( &teamOrdersMenuInfo.menu, key );\n}\n\n\n/*\n=================\nUI_TeamOrdersMenu_ListDraw\n=================\n*/\nstatic void UI_TeamOrdersMenu_ListDraw( void *self ) {\n\tmenulist_s\t*l;\n\tint\t\t\tx;\n\tint\t\t\ty;\n\tint\t\t\ti;\n\tfloat\t\t*color;\n\tqboolean\thasfocus;\n\tint\t\t\tstyle;\n\n\tl = (menulist_s *)self;\n\n\thasfocus = (l->generic.parent->cursor == l->generic.menuPosition);\n\n\tx =\t320;//l->generic.x;\n\ty =\tl->generic.y;\n\tfor( i = 0; i < l->numitems; i++ ) {\n\t\tstyle = UI_LEFT|UI_SMALLFONT|UI_CENTER;\n\t\tif( i == l->curvalue ) {\n\t\t\tcolor = color_yellow;\n\t\t\tif( hasfocus ) {\n\t\t\t\tstyle |= UI_PULSE;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tcolor = color_orange;\n\t\t}\n\n\t\tUI_DrawProportionalString( x, y, l->itemnames[i], style, color );\n\t\ty += PROP_HEIGHT;\n\t}\n}\n\n\n/*\n===============\nUI_TeamOrdersMenu_ListEvent\n===============\n*/\nstatic void UI_TeamOrdersMenu_ListEvent( void *ptr, int event ) {\n\tint\t\tid;\n\tint\t\tselection;\n\tchar\tmessage[256];\n\n\tif (event != QM_ACTIVATED)\n\t\treturn;\n\n\tid = ((menulist_s *)ptr)->generic.id;\n\tselection = ((menulist_s *)ptr)->curvalue;\n\n\tif( id == ID_LIST_BOTS ) {\n\t\tteamOrdersMenuInfo.selectedBot = selection;\n\t\tif( teamOrdersMenuInfo.gametype == GT_CTF ) {\n\t\t\tUI_TeamOrdersMenu_SetList( ID_LIST_CTF_ORDERS );\n\t\t}\n\t\telse {\n\t\t\tUI_TeamOrdersMenu_SetList( ID_LIST_TEAM_ORDERS );\n\t\t}\n\t\treturn;\n\t}\n\n\tif( id == ID_LIST_CTF_ORDERS ) {\n\t\tCom_sprintf( message, sizeof(message), ctfMessages[selection], teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.selectedBot] );\n\t}\n\telse {\n\t\tCom_sprintf( message, sizeof(message), teamMessages[selection], teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.selectedBot] );\n\t}\n\n\ttrap_Cmd_ExecuteText( EXEC_APPEND, va( \"say_team \\\"%s\\\"\\n\", message ) );\n\tUI_PopMenu();\n}\n\n\n/*\n===============\nUI_TeamOrdersMenu_BuildBotList\n===============\n*/\nstatic void UI_TeamOrdersMenu_BuildBotList( void ) {\n\tuiClientState_t\tcs;\n\tint\t\tnumPlayers;\n\tint\t\tisBot;\n\tint\t\tn;\n\tchar\tplayerTeam;\n\tchar\tbotTeam;\n\tchar\tinfo[MAX_INFO_STRING];\n\n\tfor( n = 0; n < 9; n++ ) {\n\t\tteamOrdersMenuInfo.bots[n] = teamOrdersMenuInfo.botNames[n];\n\t}\n\n\ttrap_GetClientState( &cs );\n\n\tQ_strncpyz( teamOrdersMenuInfo.botNames[0], \"Everyone\", 16 );\n\tteamOrdersMenuInfo.numBots = 1;\n\n\ttrap_GetConfigString( CS_SERVERINFO, info, sizeof(info) );\n\tnumPlayers = atoi( Info_ValueForKey( info, \"sv_maxclients\" ) );\n\tteamOrdersMenuInfo.gametype = atoi( Info_ValueForKey( info, \"g_gametype\" ) );\n\n\tfor( n = 0; n < numPlayers && teamOrdersMenuInfo.numBots < 9; n++ ) {\n\t\ttrap_GetConfigString( CS_PLAYERS + n, info, MAX_INFO_STRING );\n\n\t\tplayerTeam = TEAM_SPECTATOR; // bk001204 = possible uninit use\n\n\t\tif( n == cs.clientNum ) {\n\t\t\tplayerTeam = *Info_ValueForKey( info, \"t\" );\n\t\t\tcontinue;\n\t\t}\n\n\t\tisBot = atoi( Info_ValueForKey( info, \"skill\" ) );\n\t\tif( !isBot ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tbotTeam = *Info_ValueForKey( info, \"t\" );\n\t\tif( botTeam != playerTeam ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tQ_strncpyz( teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.numBots], Info_ValueForKey( info, \"n\" ), 16 );\n\t\tQ_CleanStr( teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.numBots] );\n\t\tteamOrdersMenuInfo.numBots++;\n\t}\n}\n\n\n/*\n===============\nUI_TeamOrdersMenu_Init\n===============\n*/\nstatic void UI_TeamOrdersMenu_Init( void ) {\n\tUI_TeamOrdersMenu_Cache();\n\n\tmemset( &teamOrdersMenuInfo, 0, sizeof(teamOrdersMenuInfo) );\n\tteamOrdersMenuInfo.menu.fullscreen = qfalse;\n\tteamOrdersMenuInfo.menu.key = UI_TeamOrdersMenu_Key;\n\n\tUI_TeamOrdersMenu_BuildBotList();\n\n\tteamOrdersMenuInfo.banner.generic.type\t\t= MTYPE_BTEXT;\n\tteamOrdersMenuInfo.banner.generic.x\t\t\t= 320;\n\tteamOrdersMenuInfo.banner.generic.y\t\t\t= 16;\n\tteamOrdersMenuInfo.banner.string\t\t\t= \"TEAM ORDERS\";\n\tteamOrdersMenuInfo.banner.color\t\t\t\t= color_white;\n\tteamOrdersMenuInfo.banner.style\t\t\t\t= UI_CENTER;\n\n\tteamOrdersMenuInfo.frame.generic.type\t\t= MTYPE_BITMAP;\n\tteamOrdersMenuInfo.frame.generic.flags\t\t= QMF_INACTIVE;\n\tteamOrdersMenuInfo.frame.generic.name\t\t= ART_FRAME;\n\tteamOrdersMenuInfo.frame.generic.x\t\t\t= 320-233;\n\tteamOrdersMenuInfo.frame.generic.y\t\t\t= 240-166;\n\tteamOrdersMenuInfo.frame.width\t\t\t\t= 466;\n\tteamOrdersMenuInfo.frame.height\t\t\t\t= 332;\n\n\tteamOrdersMenuInfo.list.generic.type\t\t= MTYPE_SCROLLLIST;\n\tteamOrdersMenuInfo.list.generic.flags\t\t= QMF_PULSEIFFOCUS;\n\tteamOrdersMenuInfo.list.generic.ownerdraw\t= UI_TeamOrdersMenu_ListDraw;\n\tteamOrdersMenuInfo.list.generic.callback\t= UI_TeamOrdersMenu_ListEvent;\n\tteamOrdersMenuInfo.list.generic.x\t\t\t= 320-64;\n\tteamOrdersMenuInfo.list.generic.y\t\t\t= 120;\n\n\tteamOrdersMenuInfo.back.generic.type\t\t= MTYPE_BITMAP;\n\tteamOrdersMenuInfo.back.generic.name\t\t= ART_BACK0;\n\tteamOrdersMenuInfo.back.generic.flags\t\t= QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\tteamOrdersMenuInfo.back.generic.callback\t= UI_TeamOrdersMenu_BackEvent;\n\tteamOrdersMenuInfo.back.generic.x\t\t\t= 0;\n\tteamOrdersMenuInfo.back.generic.y\t\t\t= 480-64;\n\tteamOrdersMenuInfo.back.width\t\t\t\t= 128;\n\tteamOrdersMenuInfo.back.height\t\t\t\t= 64;\n\tteamOrdersMenuInfo.back.focuspic\t\t\t= ART_BACK1;\n\n\tMenu_AddItem( &teamOrdersMenuInfo.menu, &teamOrdersMenuInfo.banner );\n\tMenu_AddItem( &teamOrdersMenuInfo.menu, &teamOrdersMenuInfo.frame );\n\tMenu_AddItem( &teamOrdersMenuInfo.menu, &teamOrdersMenuInfo.list );\n\tMenu_AddItem( &teamOrdersMenuInfo.menu, &teamOrdersMenuInfo.back );\n\n\tteamOrdersMenuInfo.list.generic.left = 220;\n\tteamOrdersMenuInfo.list.generic.top = teamOrdersMenuInfo.list.generic.y;\n\tteamOrdersMenuInfo.list.generic.right = 420;\n\tUI_TeamOrdersMenu_SetList( ID_LIST_BOTS );\n}\n\n\n/*\n=================\nUI_TeamOrdersMenu_Cache\n=================\n*/\nvoid UI_TeamOrdersMenu_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( ART_FRAME );\n\ttrap_R_RegisterShaderNoMip( ART_BACK0 );\n\ttrap_R_RegisterShaderNoMip( ART_BACK1 );\n}\n\n\n/*\n===============\nUI_TeamOrdersMenu\n===============\n*/\nvoid UI_TeamOrdersMenu( void ) {\n\tUI_TeamOrdersMenu_Init();\n\tUI_PushMenu( &teamOrdersMenuInfo.menu );\n}\n\n\n/*\n===============\nUI_TeamOrdersMenu_f\n===============\n*/\nvoid UI_TeamOrdersMenu_f( void ) {\n\tuiClientState_t\tcs;\n\tchar\tinfo[MAX_INFO_STRING];\n\tint\t\tteam;\n\n\t// make sure it's a team game\n\ttrap_GetConfigString( CS_SERVERINFO, info, sizeof(info) );\n\tteamOrdersMenuInfo.gametype = atoi( Info_ValueForKey( info, \"g_gametype\" ) );\n\tif( teamOrdersMenuInfo.gametype < GT_TEAM ) {\n\t\treturn;\n\t}\n\n\t// not available to spectators\n\ttrap_GetClientState( &cs );\n\ttrap_GetConfigString( CS_PLAYERS + cs.clientNum, info, MAX_INFO_STRING );\n\tteam = atoi( Info_ValueForKey( info, \"t\" ) );\n\tif( team == TEAM_SPECTATOR ) {\n\t\treturn;\n\t}\n\n\tUI_TeamOrdersMenu();\n}\n"
  },
  {
    "path": "code/q3_ui/ui_video.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#include \"ui_local.h\"\n\nvoid GraphicsOptions_MenuInit( void );\n\n/*\n=======================================================================\n\nDRIVER INFORMATION MENU\n\n=======================================================================\n*/\n\n\n#define DRIVERINFO_FRAMEL\t\"menu/art/frame2_l\"\n#define DRIVERINFO_FRAMER\t\"menu/art/frame1_r\"\n#define DRIVERINFO_BACK0\t\"menu/art/back_0\"\n#define DRIVERINFO_BACK1\t\"menu/art/back_1\"\n\nstatic char* driverinfo_artlist[] = \n{\n\tDRIVERINFO_FRAMEL,\n\tDRIVERINFO_FRAMER,\n\tDRIVERINFO_BACK0,\n\tDRIVERINFO_BACK1,\n\tNULL,\n};\n\n#define ID_DRIVERINFOBACK\t100\n\ntypedef struct\n{\n\tmenuframework_s\tmenu;\n\tmenutext_s\t\tbanner;\n\tmenubitmap_s\tback;\n\tmenubitmap_s\tframel;\n\tmenubitmap_s\tframer;\n\tchar\t\t\tstringbuff[1024];\n\tchar*\t\t\tstrings[64];\n\tint\t\t\t\tnumstrings;\n} driverinfo_t;\n\nstatic driverinfo_t\ts_driverinfo;\n\n/*\n=================\nDriverInfo_Event\n=================\n*/\nstatic void DriverInfo_Event( void* ptr, int event )\n{\n\tif (event != QM_ACTIVATED)\n\t\treturn;\n\n\tswitch (((menucommon_s*)ptr)->id)\n\t{\n\t\tcase ID_DRIVERINFOBACK:\n\t\t\tUI_PopMenu();\n\t\t\tbreak;\n\t}\n}\n\n/*\n=================\nDriverInfo_MenuDraw\n=================\n*/\nstatic void DriverInfo_MenuDraw( void )\n{\n\tint\ti;\n\tint\ty;\n\n\tMenu_Draw( &s_driverinfo.menu );\n\n\tUI_DrawString( 320, 80, \"VENDOR\", UI_CENTER|UI_SMALLFONT, color_red );\n\tUI_DrawString( 320, 152, \"PIXELFORMAT\", UI_CENTER|UI_SMALLFONT, color_red );\n\tUI_DrawString( 320, 192, \"EXTENSIONS\", UI_CENTER|UI_SMALLFONT, color_red );\n\n\tUI_DrawString( 320, 80+16, uis.glconfig.vendor_string, UI_CENTER|UI_SMALLFONT, text_color_normal );\n\tUI_DrawString( 320, 96+16, uis.glconfig.version_string, UI_CENTER|UI_SMALLFONT, text_color_normal );\n\tUI_DrawString( 320, 112+16, uis.glconfig.renderer_string, UI_CENTER|UI_SMALLFONT, text_color_normal );\n\tUI_DrawString( 320, 152+16, va (\"color(%d-bits) Z(%d-bits) stencil(%d-bits)\", uis.glconfig.colorBits, uis.glconfig.depthBits, uis.glconfig.stencilBits), UI_CENTER|UI_SMALLFONT, text_color_normal );\n\n\t// double column\n\ty = 192+16;\n\tfor (i=0; i<s_driverinfo.numstrings/2; i++) {\n\t\tUI_DrawString( 320-4, y, s_driverinfo.strings[i*2], UI_RIGHT|UI_SMALLFONT, text_color_normal );\n\t\tUI_DrawString( 320+4, y, s_driverinfo.strings[i*2+1], UI_LEFT|UI_SMALLFONT, text_color_normal );\n\t\ty += SMALLCHAR_HEIGHT;\n\t}\n\n\tif (s_driverinfo.numstrings & 1)\n\t\tUI_DrawString( 320, y, s_driverinfo.strings[s_driverinfo.numstrings-1], UI_CENTER|UI_SMALLFONT, text_color_normal );\n}\n\n/*\n=================\nDriverInfo_Cache\n=================\n*/\nvoid DriverInfo_Cache( void )\n{\n\tint\ti;\n\n\t// touch all our pics\n\tfor (i=0; ;i++)\n\t{\n\t\tif (!driverinfo_artlist[i])\n\t\t\tbreak;\n\t\ttrap_R_RegisterShaderNoMip(driverinfo_artlist[i]);\n\t}\n}\n\n/*\n=================\nUI_DriverInfo_Menu\n=================\n*/\nstatic void UI_DriverInfo_Menu( void )\n{\n\tchar*\teptr;\n\tint\t\ti;\n\tint\t\tlen;\n\n\t// zero set all our globals\n\tmemset( &s_driverinfo, 0 ,sizeof(driverinfo_t) );\n\n\tDriverInfo_Cache();\n\n\ts_driverinfo.menu.fullscreen = qtrue;\n\ts_driverinfo.menu.draw       = DriverInfo_MenuDraw;\n\n\ts_driverinfo.banner.generic.type  = MTYPE_BTEXT;\n\ts_driverinfo.banner.generic.x\t  = 320;\n\ts_driverinfo.banner.generic.y\t  = 16;\n\ts_driverinfo.banner.string\t\t  = \"DRIVER INFO\";\n\ts_driverinfo.banner.color\t      = color_white;\n\ts_driverinfo.banner.style\t      = UI_CENTER;\n\n\ts_driverinfo.framel.generic.type  = MTYPE_BITMAP;\n\ts_driverinfo.framel.generic.name  = DRIVERINFO_FRAMEL;\n\ts_driverinfo.framel.generic.flags = QMF_INACTIVE;\n\ts_driverinfo.framel.generic.x\t  = 0;\n\ts_driverinfo.framel.generic.y\t  = 78;\n\ts_driverinfo.framel.width  \t      = 256;\n\ts_driverinfo.framel.height  \t  = 329;\n\n\ts_driverinfo.framer.generic.type  = MTYPE_BITMAP;\n\ts_driverinfo.framer.generic.name  = DRIVERINFO_FRAMER;\n\ts_driverinfo.framer.generic.flags = QMF_INACTIVE;\n\ts_driverinfo.framer.generic.x\t  = 376;\n\ts_driverinfo.framer.generic.y\t  = 76;\n\ts_driverinfo.framer.width  \t      = 256;\n\ts_driverinfo.framer.height  \t  = 334;\n\n\ts_driverinfo.back.generic.type\t   = MTYPE_BITMAP;\n\ts_driverinfo.back.generic.name     = DRIVERINFO_BACK0;\n\ts_driverinfo.back.generic.flags    = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_driverinfo.back.generic.callback = DriverInfo_Event;\n\ts_driverinfo.back.generic.id\t   = ID_DRIVERINFOBACK;\n\ts_driverinfo.back.generic.x\t\t   = 0;\n\ts_driverinfo.back.generic.y\t\t   = 480-64;\n\ts_driverinfo.back.width  \t\t   = 128;\n\ts_driverinfo.back.height  \t\t   = 64;\n\ts_driverinfo.back.focuspic         = DRIVERINFO_BACK1;\n\n  // TTimo: overflow with particularly long GL extensions (such as the gf3)\n  // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=399\n  // NOTE: could have pushed the size of stringbuff, but the list is already out of the screen\n  // (no matter what your resolution)\n  Q_strncpyz(s_driverinfo.stringbuff, uis.glconfig.extensions_string, 1024);\n\n\t// build null terminated extension strings\n\teptr = s_driverinfo.stringbuff;\n\twhile ( s_driverinfo.numstrings<40 && *eptr )\n\t{\n\t\twhile ( *eptr && *eptr == ' ' )\n\t\t\t*eptr++ = '\\0';\n\n\t\t// track start of valid string\n\t\tif (*eptr && *eptr != ' ')\n\t\t\ts_driverinfo.strings[s_driverinfo.numstrings++] = eptr;\n\n\t\twhile ( *eptr && *eptr != ' ' )\n\t\t\teptr++;\n\t}\n\n\t// safety length strings for display\n\tfor (i=0; i<s_driverinfo.numstrings; i++) {\n\t\tlen = strlen(s_driverinfo.strings[i]);\n\t\tif (len > 32) {\n\t\t\ts_driverinfo.strings[i][len-1] = '>';\n\t\t\ts_driverinfo.strings[i][len]   = '\\0';\n\t\t}\n\t}\n\n\tMenu_AddItem( &s_driverinfo.menu, &s_driverinfo.banner );\n\tMenu_AddItem( &s_driverinfo.menu, &s_driverinfo.framel );\n\tMenu_AddItem( &s_driverinfo.menu, &s_driverinfo.framer );\n\tMenu_AddItem( &s_driverinfo.menu, &s_driverinfo.back );\n\n\tUI_PushMenu( &s_driverinfo.menu );\n}\n\n/*\n=======================================================================\n\nGRAPHICS OPTIONS MENU\n\n=======================================================================\n*/\n\n#define GRAPHICSOPTIONS_FRAMEL\t\"menu/art/frame2_l\"\n#define GRAPHICSOPTIONS_FRAMER\t\"menu/art/frame1_r\"\n#define GRAPHICSOPTIONS_BACK0\t\"menu/art/back_0\"\n#define GRAPHICSOPTIONS_BACK1\t\"menu/art/back_1\"\n#define GRAPHICSOPTIONS_ACCEPT0\t\"menu/art/accept_0\"\n#define GRAPHICSOPTIONS_ACCEPT1\t\"menu/art/accept_1\"\n\nstatic const char *s_drivers[] =\n{\n\tOPENGL_DRIVER_NAME,\n\t_3DFX_DRIVER_NAME,\n\t0\n};\n\n#define ID_BACK2\t\t101\n#define ID_FULLSCREEN\t102\n#define ID_LIST\t\t\t103\n#define ID_MODE\t\t\t104\n#define ID_DRIVERINFO\t105\n#define ID_GRAPHICS\t\t106\n#define ID_DISPLAY\t\t107\n#define ID_SOUND\t\t108\n#define ID_NETWORK\t\t109\n\ntypedef struct {\n\tmenuframework_s\tmenu;\n\n\tmenutext_s\t\tbanner;\n\tmenubitmap_s\tframel;\n\tmenubitmap_s\tframer;\n\n\tmenutext_s\t\tgraphics;\n\tmenutext_s\t\tdisplay;\n\tmenutext_s\t\tsound;\n\tmenutext_s\t\tnetwork;\n\n\tmenulist_s\t\tlist;\n\tmenulist_s\t\tmode;\n\tmenulist_s\t\tdriver;\n\tmenuslider_s\ttq;\n\tmenulist_s  \tfs;\n\tmenulist_s  \tlighting;\n\tmenulist_s  \tallow_extensions;\n\tmenulist_s  \ttexturebits;\n\tmenulist_s  \tcolordepth;\n\tmenulist_s  \tgeometry;\n\tmenulist_s  \tfilter;\n\tmenutext_s\t\tdriverinfo;\n\n\tmenubitmap_s\tapply;\n\tmenubitmap_s\tback;\n} graphicsoptions_t;\n\ntypedef struct\n{\n\tint mode;\n\tqboolean fullscreen;\n\tint tq;\n\tint lighting;\n\tint colordepth;\n\tint texturebits;\n\tint geometry;\n\tint filter;\n\tint driver;\n\tqboolean extensions;\n} InitialVideoOptions_s;\n\nstatic InitialVideoOptions_s\ts_ivo;\nstatic graphicsoptions_t\t\ts_graphicsoptions;\t\n\nstatic InitialVideoOptions_s s_ivo_templates[] =\n{\n\t{\n\t\t4, qtrue, 2, 0, 2, 2, 1, 1, 0, qtrue\t// JDC: this was tq 3\n\t},\n\t{\n\t\t3, qtrue, 2, 0, 0, 0, 1, 0, 0, qtrue\n\t},\n\t{\n\t\t2, qtrue, 1, 0, 1, 0, 0, 0, 0, qtrue\n\t},\n\t{\n\t\t2, qtrue, 1, 1, 1, 0, 0, 0, 0, qtrue\n\t},\n\t{\n\t\t3, qtrue, 1, 0, 0, 0, 1, 0, 0, qtrue\n\t}\n};\n\n#define NUM_IVO_TEMPLATES ( sizeof( s_ivo_templates ) / sizeof( s_ivo_templates[0] ) )\n\n/*\n=================\nGraphicsOptions_GetInitialVideo\n=================\n*/\nstatic void GraphicsOptions_GetInitialVideo( void )\n{\n\ts_ivo.colordepth  = s_graphicsoptions.colordepth.curvalue;\n\ts_ivo.driver      = s_graphicsoptions.driver.curvalue;\n\ts_ivo.mode        = s_graphicsoptions.mode.curvalue;\n\ts_ivo.fullscreen  = s_graphicsoptions.fs.curvalue;\n\ts_ivo.extensions  = s_graphicsoptions.allow_extensions.curvalue;\n\ts_ivo.tq          = s_graphicsoptions.tq.curvalue;\n\ts_ivo.lighting    = s_graphicsoptions.lighting.curvalue;\n\ts_ivo.geometry    = s_graphicsoptions.geometry.curvalue;\n\ts_ivo.filter      = s_graphicsoptions.filter.curvalue;\n\ts_ivo.texturebits = s_graphicsoptions.texturebits.curvalue;\n}\n\n/*\n=================\nGraphicsOptions_CheckConfig\n=================\n*/\nstatic void GraphicsOptions_CheckConfig( void )\n{\n\tint i;\n\n\tfor ( i = 0; i < NUM_IVO_TEMPLATES; i++ )\n\t{\n\t\tif ( s_ivo_templates[i].colordepth != s_graphicsoptions.colordepth.curvalue )\n\t\t\tcontinue;\n\t\tif ( s_ivo_templates[i].driver != s_graphicsoptions.driver.curvalue )\n\t\t\tcontinue;\n\t\tif ( s_ivo_templates[i].mode != s_graphicsoptions.mode.curvalue )\n\t\t\tcontinue;\n\t\tif ( s_ivo_templates[i].fullscreen != s_graphicsoptions.fs.curvalue )\n\t\t\tcontinue;\n\t\tif ( s_ivo_templates[i].tq != s_graphicsoptions.tq.curvalue )\n\t\t\tcontinue;\n\t\tif ( s_ivo_templates[i].lighting != s_graphicsoptions.lighting.curvalue )\n\t\t\tcontinue;\n\t\tif ( s_ivo_templates[i].geometry != s_graphicsoptions.geometry.curvalue )\n\t\t\tcontinue;\n\t\tif ( s_ivo_templates[i].filter != s_graphicsoptions.filter.curvalue )\n\t\t\tcontinue;\n//\t\tif ( s_ivo_templates[i].texturebits != s_graphicsoptions.texturebits.curvalue )\n//\t\t\tcontinue;\n\t\ts_graphicsoptions.list.curvalue = i;\n\t\treturn;\n\t}\n\ts_graphicsoptions.list.curvalue = 4;\n}\n\n/*\n=================\nGraphicsOptions_UpdateMenuItems\n=================\n*/\nstatic void GraphicsOptions_UpdateMenuItems( void )\n{\n\tif ( s_graphicsoptions.driver.curvalue == 1 )\n\t{\n\t\ts_graphicsoptions.fs.curvalue = 1;\n\t\ts_graphicsoptions.fs.generic.flags |= QMF_GRAYED;\n\t\ts_graphicsoptions.colordepth.curvalue = 1;\n\t}\n\telse\n\t{\n\t\ts_graphicsoptions.fs.generic.flags &= ~QMF_GRAYED;\n\t}\n\n\tif ( s_graphicsoptions.fs.curvalue == 0 || s_graphicsoptions.driver.curvalue == 1 )\n\t{\n\t\ts_graphicsoptions.colordepth.curvalue = 0;\n\t\ts_graphicsoptions.colordepth.generic.flags |= QMF_GRAYED;\n\t}\n\telse\n\t{\n\t\ts_graphicsoptions.colordepth.generic.flags &= ~QMF_GRAYED;\n\t}\n\n\tif ( s_graphicsoptions.allow_extensions.curvalue == 0 )\n\t{\n\t\tif ( s_graphicsoptions.texturebits.curvalue == 0 )\n\t\t{\n\t\t\ts_graphicsoptions.texturebits.curvalue = 1;\n\t\t}\n\t}\n\n\ts_graphicsoptions.apply.generic.flags |= QMF_HIDDEN|QMF_INACTIVE;\n\n\tif ( s_ivo.mode != s_graphicsoptions.mode.curvalue )\n\t{\n\t\ts_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE);\n\t}\n\tif ( s_ivo.fullscreen != s_graphicsoptions.fs.curvalue )\n\t{\n\t\ts_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE);\n\t}\n\tif ( s_ivo.extensions != s_graphicsoptions.allow_extensions.curvalue )\n\t{\n\t\ts_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE);\n\t}\n\tif ( s_ivo.tq != s_graphicsoptions.tq.curvalue )\n\t{\n\t\ts_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE);\n\t}\n\tif ( s_ivo.lighting != s_graphicsoptions.lighting.curvalue )\n\t{\n\t\ts_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE);\n\t}\n\tif ( s_ivo.colordepth != s_graphicsoptions.colordepth.curvalue )\n\t{\n\t\ts_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE);\n\t}\n\tif ( s_ivo.driver != s_graphicsoptions.driver.curvalue )\n\t{\n\t\ts_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE);\n\t}\n\tif ( s_ivo.texturebits != s_graphicsoptions.texturebits.curvalue )\n\t{\n\t\ts_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE);\n\t}\n\tif ( s_ivo.geometry != s_graphicsoptions.geometry.curvalue )\n\t{\n\t\ts_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE);\n\t}\n\tif ( s_ivo.filter != s_graphicsoptions.filter.curvalue )\n\t{\n\t\ts_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE);\n\t}\n\n\tGraphicsOptions_CheckConfig();\n}\t\n\n/*\n=================\nGraphicsOptions_ApplyChanges\n=================\n*/\nstatic void GraphicsOptions_ApplyChanges( void *unused, int notification )\n{\n\tif (notification != QM_ACTIVATED)\n\t\treturn;\n\n\tswitch ( s_graphicsoptions.texturebits.curvalue  )\n\t{\n\tcase 0:\n\t\ttrap_Cvar_SetValue( \"r_texturebits\", 0 );\n\t\tbreak;\n\tcase 1:\n\t\ttrap_Cvar_SetValue( \"r_texturebits\", 16 );\n\t\tbreak;\n\tcase 2:\n\t\ttrap_Cvar_SetValue( \"r_texturebits\", 32 );\n\t\tbreak;\n\t}\n\ttrap_Cvar_SetValue( \"r_picmip\", 3 - s_graphicsoptions.tq.curvalue );\n\ttrap_Cvar_SetValue( \"r_allowExtensions\", s_graphicsoptions.allow_extensions.curvalue );\n\ttrap_Cvar_SetValue( \"r_mode\", s_graphicsoptions.mode.curvalue );\n\ttrap_Cvar_SetValue( \"r_fullscreen\", s_graphicsoptions.fs.curvalue );\n\ttrap_Cvar_Set( \"r_glDriver\", ( char * ) s_drivers[s_graphicsoptions.driver.curvalue] );\n\tswitch ( s_graphicsoptions.colordepth.curvalue )\n\t{\n\tcase 0:\n\t\ttrap_Cvar_SetValue( \"r_colorbits\", 0 );\n\t\ttrap_Cvar_SetValue( \"r_depthbits\", 0 );\n\t\ttrap_Cvar_SetValue( \"r_stencilbits\", 0 );\n\t\tbreak;\n\tcase 1:\n\t\ttrap_Cvar_SetValue( \"r_colorbits\", 16 );\n\t\ttrap_Cvar_SetValue( \"r_depthbits\", 16 );\n\t\ttrap_Cvar_SetValue( \"r_stencilbits\", 0 );\n\t\tbreak;\n\tcase 2:\n\t\ttrap_Cvar_SetValue( \"r_colorbits\", 32 );\n\t\ttrap_Cvar_SetValue( \"r_depthbits\", 24 );\n\t\tbreak;\n\t}\n\ttrap_Cvar_SetValue( \"r_vertexLight\", s_graphicsoptions.lighting.curvalue );\n\n\tif ( s_graphicsoptions.geometry.curvalue == 2 )\n\t{\n\t\ttrap_Cvar_SetValue( \"r_lodBias\", 0 );\n\t\ttrap_Cvar_SetValue( \"r_subdivisions\", 4 );\n\t}\n\telse if ( s_graphicsoptions.geometry.curvalue == 1 )\n\t{\n\t\ttrap_Cvar_SetValue( \"r_lodBias\", 1 );\n\t\ttrap_Cvar_SetValue( \"r_subdivisions\", 12 );\n\t}\n\telse\n\t{\n\t\ttrap_Cvar_SetValue( \"r_lodBias\", 1 );\n\t\ttrap_Cvar_SetValue( \"r_subdivisions\", 20 );\n\t}\n\n\tif ( s_graphicsoptions.filter.curvalue )\n\t{\n\t\ttrap_Cvar_Set( \"r_textureMode\", \"GL_LINEAR_MIPMAP_LINEAR\" );\n\t}\n\telse\n\t{\n\t\ttrap_Cvar_Set( \"r_textureMode\", \"GL_LINEAR_MIPMAP_NEAREST\" );\n\t}\n\n\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"vid_restart\\n\" );\n}\n\n/*\n=================\nGraphicsOptions_Event\n=================\n*/\nstatic void GraphicsOptions_Event( void* ptr, int event ) {\n\tInitialVideoOptions_s *ivo;\n\n\tif( event != QM_ACTIVATED ) {\n\t \treturn;\n\t}\n\n\tswitch( ((menucommon_s*)ptr)->id ) {\n\tcase ID_MODE:\n\t\t// clamp 3dfx video modes\n\t\tif ( s_graphicsoptions.driver.curvalue == 1 )\n\t\t{\n\t\t\tif ( s_graphicsoptions.mode.curvalue < 2 )\n\t\t\t\ts_graphicsoptions.mode.curvalue = 2;\n\t\t\telse if ( s_graphicsoptions.mode.curvalue > 6 )\n\t\t\t\ts_graphicsoptions.mode.curvalue = 6;\n\t\t}\n\t\tbreak;\n\n\tcase ID_LIST:\n\t\tivo = &s_ivo_templates[s_graphicsoptions.list.curvalue];\n\n\t\ts_graphicsoptions.mode.curvalue        = ivo->mode;\n\t\ts_graphicsoptions.tq.curvalue          = ivo->tq;\n\t\ts_graphicsoptions.lighting.curvalue    = ivo->lighting;\n\t\ts_graphicsoptions.colordepth.curvalue  = ivo->colordepth;\n\t\ts_graphicsoptions.texturebits.curvalue = ivo->texturebits;\n\t\ts_graphicsoptions.geometry.curvalue    = ivo->geometry;\n\t\ts_graphicsoptions.filter.curvalue      = ivo->filter;\n\t\ts_graphicsoptions.fs.curvalue          = ivo->fullscreen;\n\t\tbreak;\n\n\tcase ID_DRIVERINFO:\n\t\tUI_DriverInfo_Menu();\n\t\tbreak;\n\n\tcase ID_BACK2:\n\t\tUI_PopMenu();\n\t\tbreak;\n\n\tcase ID_GRAPHICS:\n\t\tbreak;\n\n\tcase ID_DISPLAY:\n\t\tUI_PopMenu();\n\t\tUI_DisplayOptionsMenu();\n\t\tbreak;\n\n\tcase ID_SOUND:\n\t\tUI_PopMenu();\n\t\tUI_SoundOptionsMenu();\n\t\tbreak;\n\n\tcase ID_NETWORK:\n\t\tUI_PopMenu();\n\t\tUI_NetworkOptionsMenu();\n\t\tbreak;\n\t}\n}\n\n\n/*\n================\nGraphicsOptions_TQEvent\n================\n*/\nstatic void GraphicsOptions_TQEvent( void *ptr, int event ) {\n\tif( event != QM_ACTIVATED ) {\n\t \treturn;\n\t}\n\ts_graphicsoptions.tq.curvalue = (int)(s_graphicsoptions.tq.curvalue + 0.5);\n}\n\n\n/*\n================\nGraphicsOptions_MenuDraw\n================\n*/\nvoid GraphicsOptions_MenuDraw (void)\n{\n//APSFIX - rework this\n\tGraphicsOptions_UpdateMenuItems();\n\n\tMenu_Draw( &s_graphicsoptions.menu );\n}\n\n/*\n=================\nGraphicsOptions_SetMenuItems\n=================\n*/\nstatic void GraphicsOptions_SetMenuItems( void )\n{\n\ts_graphicsoptions.mode.curvalue = trap_Cvar_VariableValue( \"r_mode\" );\n\tif ( s_graphicsoptions.mode.curvalue < 0 )\n\t{\n\t\ts_graphicsoptions.mode.curvalue = 3;\n\t}\n\ts_graphicsoptions.fs.curvalue = trap_Cvar_VariableValue(\"r_fullscreen\");\n\ts_graphicsoptions.allow_extensions.curvalue = trap_Cvar_VariableValue(\"r_allowExtensions\");\n\ts_graphicsoptions.tq.curvalue = 3-trap_Cvar_VariableValue( \"r_picmip\");\n\tif ( s_graphicsoptions.tq.curvalue < 0 )\n\t{\n\t\ts_graphicsoptions.tq.curvalue = 0;\n\t}\n\telse if ( s_graphicsoptions.tq.curvalue > 3 )\n\t{\n\t\ts_graphicsoptions.tq.curvalue = 3;\n\t}\n\n\ts_graphicsoptions.lighting.curvalue = trap_Cvar_VariableValue( \"r_vertexLight\" ) != 0;\n\tswitch ( ( int ) trap_Cvar_VariableValue( \"r_texturebits\" ) )\n\t{\n\tdefault:\n\tcase 0:\n\t\ts_graphicsoptions.texturebits.curvalue = 0;\n\t\tbreak;\n\tcase 16:\n\t\ts_graphicsoptions.texturebits.curvalue = 1;\n\t\tbreak;\n\tcase 32:\n\t\ts_graphicsoptions.texturebits.curvalue = 2;\n\t\tbreak;\n\t}\n\n\tif ( !Q_stricmp( UI_Cvar_VariableString( \"r_textureMode\" ), \"GL_LINEAR_MIPMAP_NEAREST\" ) )\n\t{\n\t\ts_graphicsoptions.filter.curvalue = 0;\n\t}\n\telse\n\t{\n\t\ts_graphicsoptions.filter.curvalue = 1;\n\t}\n\n\tif ( trap_Cvar_VariableValue( \"r_lodBias\" ) > 0 )\n\t{\n\t\tif ( trap_Cvar_VariableValue( \"r_subdivisions\" ) >= 20 )\n\t\t{\n\t\t\ts_graphicsoptions.geometry.curvalue = 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\ts_graphicsoptions.geometry.curvalue = 1;\n\t\t}\n\t}\n\telse\n\t{\n\t\ts_graphicsoptions.geometry.curvalue = 2;\n\t}\n\n\tswitch ( ( int ) trap_Cvar_VariableValue( \"r_colorbits\" ) )\n\t{\n\tdefault:\n\tcase 0:\n\t\ts_graphicsoptions.colordepth.curvalue = 0;\n\t\tbreak;\n\tcase 16:\n\t\ts_graphicsoptions.colordepth.curvalue = 1;\n\t\tbreak;\n\tcase 32:\n\t\ts_graphicsoptions.colordepth.curvalue = 2;\n\t\tbreak;\n\t}\n\n\tif ( s_graphicsoptions.fs.curvalue == 0 )\n\t{\n\t\ts_graphicsoptions.colordepth.curvalue = 0;\n\t}\n\tif ( s_graphicsoptions.driver.curvalue == 1 )\n\t{\n\t\ts_graphicsoptions.colordepth.curvalue = 1;\n\t}\n}\n\n/*\n================\nGraphicsOptions_MenuInit\n================\n*/\nvoid GraphicsOptions_MenuInit( void )\n{\n\tstatic const char *s_driver_names[] =\n\t{\n\t\t\"Default\",\n\t\t\"Voodoo\",\n\t\t0\n\t};\n\n\tstatic const char *tq_names[] =\n\t{\n\t\t\"Default\",\n\t\t\"16 bit\",\n\t\t\"32 bit\",\n\t\t0\n\t};\n\n\tstatic const char *s_graphics_options_names[] =\n\t{\n\t\t\"High Quality\",\n\t\t\"Normal\",\n\t\t\"Fast\",\n\t\t\"Fastest\",\n\t\t\"Custom\",\n\t\t0\n\t};\n\n\tstatic const char *lighting_names[] =\n\t{\n\t\t\"Lightmap\",\n\t\t\"Vertex\",\n\t\t0\n\t};\n\n\tstatic const char *colordepth_names[] =\n\t{\n\t\t\"Default\",\n\t\t\"16 bit\",\n\t\t\"32 bit\",\n\t\t0\n\t};\n\n\tstatic const char *resolutions[] = \n\t{\n\t\t\"320x240\",\n\t\t\"400x300\",\n\t\t\"512x384\",\n\t\t\"640x480\",\n\t\t\"800x600\",\n\t\t\"960x720\",\n\t\t\"1024x768\",\n\t\t\"1152x864\",\n\t\t\"1280x1024\",\n\t\t\"1600x1200\",\n\t\t\"2048x1536\",\n\t\t\"856x480 wide screen\",\n\t\t0\n\t};\n\tstatic const char *filter_names[] =\n\t{\n\t\t\"Bilinear\",\n\t\t\"Trilinear\",\n\t\t0\n\t};\n\tstatic const char *quality_names[] =\n\t{\n\t\t\"Low\",\n\t\t\"Medium\",\n\t\t\"High\",\n\t\t0\n\t};\n\tstatic const char *enabled_names[] =\n\t{\n\t\t\"Off\",\n\t\t\"On\",\n\t\t0\n\t};\n\n\tint y;\n\n\t// zero set all our globals\n\tmemset( &s_graphicsoptions, 0 ,sizeof(graphicsoptions_t) );\n\n\tGraphicsOptions_Cache();\n\n\ts_graphicsoptions.menu.wrapAround = qtrue;\n\ts_graphicsoptions.menu.fullscreen = qtrue;\n\ts_graphicsoptions.menu.draw       = GraphicsOptions_MenuDraw;\n\n\ts_graphicsoptions.banner.generic.type  = MTYPE_BTEXT;\n\ts_graphicsoptions.banner.generic.x\t   = 320;\n\ts_graphicsoptions.banner.generic.y\t   = 16;\n\ts_graphicsoptions.banner.string  \t   = \"SYSTEM SETUP\";\n\ts_graphicsoptions.banner.color         = color_white;\n\ts_graphicsoptions.banner.style         = UI_CENTER;\n\n\ts_graphicsoptions.framel.generic.type  = MTYPE_BITMAP;\n\ts_graphicsoptions.framel.generic.name  = GRAPHICSOPTIONS_FRAMEL;\n\ts_graphicsoptions.framel.generic.flags = QMF_INACTIVE;\n\ts_graphicsoptions.framel.generic.x\t   = 0;\n\ts_graphicsoptions.framel.generic.y\t   = 78;\n\ts_graphicsoptions.framel.width  \t   = 256;\n\ts_graphicsoptions.framel.height  \t   = 329;\n\n\ts_graphicsoptions.framer.generic.type  = MTYPE_BITMAP;\n\ts_graphicsoptions.framer.generic.name  = GRAPHICSOPTIONS_FRAMER;\n\ts_graphicsoptions.framer.generic.flags = QMF_INACTIVE;\n\ts_graphicsoptions.framer.generic.x\t   = 376;\n\ts_graphicsoptions.framer.generic.y\t   = 76;\n\ts_graphicsoptions.framer.width  \t   = 256;\n\ts_graphicsoptions.framer.height  \t   = 334;\n\n\ts_graphicsoptions.graphics.generic.type\t\t= MTYPE_PTEXT;\n\ts_graphicsoptions.graphics.generic.flags\t= QMF_RIGHT_JUSTIFY;\n\ts_graphicsoptions.graphics.generic.id\t\t= ID_GRAPHICS;\n\ts_graphicsoptions.graphics.generic.callback\t= GraphicsOptions_Event;\n\ts_graphicsoptions.graphics.generic.x\t\t= 216;\n\ts_graphicsoptions.graphics.generic.y\t\t= 240 - 2 * PROP_HEIGHT;\n\ts_graphicsoptions.graphics.string\t\t\t= \"GRAPHICS\";\n\ts_graphicsoptions.graphics.style\t\t\t= UI_RIGHT;\n\ts_graphicsoptions.graphics.color\t\t\t= color_red;\n\n\ts_graphicsoptions.display.generic.type\t\t= MTYPE_PTEXT;\n\ts_graphicsoptions.display.generic.flags\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_graphicsoptions.display.generic.id\t\t= ID_DISPLAY;\n\ts_graphicsoptions.display.generic.callback\t= GraphicsOptions_Event;\n\ts_graphicsoptions.display.generic.x\t\t\t= 216;\n\ts_graphicsoptions.display.generic.y\t\t\t= 240 - PROP_HEIGHT;\n\ts_graphicsoptions.display.string\t\t\t= \"DISPLAY\";\n\ts_graphicsoptions.display.style\t\t\t\t= UI_RIGHT;\n\ts_graphicsoptions.display.color\t\t\t\t= color_red;\n\n\ts_graphicsoptions.sound.generic.type\t\t= MTYPE_PTEXT;\n\ts_graphicsoptions.sound.generic.flags\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_graphicsoptions.sound.generic.id\t\t\t= ID_SOUND;\n\ts_graphicsoptions.sound.generic.callback\t= GraphicsOptions_Event;\n\ts_graphicsoptions.sound.generic.x\t\t\t= 216;\n\ts_graphicsoptions.sound.generic.y\t\t\t= 240;\n\ts_graphicsoptions.sound.string\t\t\t\t= \"SOUND\";\n\ts_graphicsoptions.sound.style\t\t\t\t= UI_RIGHT;\n\ts_graphicsoptions.sound.color\t\t\t\t= color_red;\n\n\ts_graphicsoptions.network.generic.type\t\t= MTYPE_PTEXT;\n\ts_graphicsoptions.network.generic.flags\t\t= QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_graphicsoptions.network.generic.id\t\t= ID_NETWORK;\n\ts_graphicsoptions.network.generic.callback\t= GraphicsOptions_Event;\n\ts_graphicsoptions.network.generic.x\t\t\t= 216;\n\ts_graphicsoptions.network.generic.y\t\t\t= 240 + PROP_HEIGHT;\n\ts_graphicsoptions.network.string\t\t\t= \"NETWORK\";\n\ts_graphicsoptions.network.style\t\t\t\t= UI_RIGHT;\n\ts_graphicsoptions.network.color\t\t\t\t= color_red;\n\n\ty = 240 - 6 * (BIGCHAR_HEIGHT + 2);\n\ts_graphicsoptions.list.generic.type     = MTYPE_SPINCONTROL;\n\ts_graphicsoptions.list.generic.name     = \"Graphics Settings:\";\n\ts_graphicsoptions.list.generic.flags    = QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_graphicsoptions.list.generic.x        = 400;\n\ts_graphicsoptions.list.generic.y        = y;\n\ts_graphicsoptions.list.generic.callback = GraphicsOptions_Event;\n\ts_graphicsoptions.list.generic.id       = ID_LIST;\n\ts_graphicsoptions.list.itemnames        = s_graphics_options_names;\n\ty += 2 * ( BIGCHAR_HEIGHT + 2 );\n\n\ts_graphicsoptions.driver.generic.type  = MTYPE_SPINCONTROL;\n\ts_graphicsoptions.driver.generic.name  = \"GL Driver:\";\n\ts_graphicsoptions.driver.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_graphicsoptions.driver.generic.x     = 400;\n\ts_graphicsoptions.driver.generic.y     = y;\n\ts_graphicsoptions.driver.itemnames     = s_driver_names;\n\ts_graphicsoptions.driver.curvalue      = (uis.glconfig.driverType == GLDRV_VOODOO);\n\ty += BIGCHAR_HEIGHT+2;\n\n\t// references/modifies \"r_allowExtensions\"\n\ts_graphicsoptions.allow_extensions.generic.type     = MTYPE_SPINCONTROL;\n\ts_graphicsoptions.allow_extensions.generic.name\t    = \"GL Extensions:\";\n\ts_graphicsoptions.allow_extensions.generic.flags\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_graphicsoptions.allow_extensions.generic.x\t    = 400;\n\ts_graphicsoptions.allow_extensions.generic.y\t    = y;\n\ts_graphicsoptions.allow_extensions.itemnames        = enabled_names;\n\ty += BIGCHAR_HEIGHT+2;\n\n\t// references/modifies \"r_mode\"\n\ts_graphicsoptions.mode.generic.type     = MTYPE_SPINCONTROL;\n\ts_graphicsoptions.mode.generic.name     = \"Video Mode:\";\n\ts_graphicsoptions.mode.generic.flags    = QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_graphicsoptions.mode.generic.x        = 400;\n\ts_graphicsoptions.mode.generic.y        = y;\n\ts_graphicsoptions.mode.itemnames        = resolutions;\n\ts_graphicsoptions.mode.generic.callback = GraphicsOptions_Event;\n\ts_graphicsoptions.mode.generic.id       = ID_MODE;\n\ty += BIGCHAR_HEIGHT+2;\n\n\t// references \"r_colorbits\"\n\ts_graphicsoptions.colordepth.generic.type     = MTYPE_SPINCONTROL;\n\ts_graphicsoptions.colordepth.generic.name     = \"Color Depth:\";\n\ts_graphicsoptions.colordepth.generic.flags    = QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_graphicsoptions.colordepth.generic.x        = 400;\n\ts_graphicsoptions.colordepth.generic.y        = y;\n\ts_graphicsoptions.colordepth.itemnames        = colordepth_names;\n\ty += BIGCHAR_HEIGHT+2;\n\n\t// references/modifies \"r_fullscreen\"\n\ts_graphicsoptions.fs.generic.type     = MTYPE_SPINCONTROL;\n\ts_graphicsoptions.fs.generic.name\t  = \"Fullscreen:\";\n\ts_graphicsoptions.fs.generic.flags\t  = QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_graphicsoptions.fs.generic.x\t      = 400;\n\ts_graphicsoptions.fs.generic.y\t      = y;\n\ts_graphicsoptions.fs.itemnames\t      = enabled_names;\n\ty += BIGCHAR_HEIGHT+2;\n\n\t// references/modifies \"r_vertexLight\"\n\ts_graphicsoptions.lighting.generic.type  = MTYPE_SPINCONTROL;\n\ts_graphicsoptions.lighting.generic.name\t = \"Lighting:\";\n\ts_graphicsoptions.lighting.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_graphicsoptions.lighting.generic.x\t = 400;\n\ts_graphicsoptions.lighting.generic.y\t = y;\n\ts_graphicsoptions.lighting.itemnames     = lighting_names;\n\ty += BIGCHAR_HEIGHT+2;\n\n\t// references/modifies \"r_lodBias\" & \"subdivisions\"\n\ts_graphicsoptions.geometry.generic.type  = MTYPE_SPINCONTROL;\n\ts_graphicsoptions.geometry.generic.name\t = \"Geometric Detail:\";\n\ts_graphicsoptions.geometry.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_graphicsoptions.geometry.generic.x\t = 400;\n\ts_graphicsoptions.geometry.generic.y\t = y;\n\ts_graphicsoptions.geometry.itemnames     = quality_names;\n\ty += BIGCHAR_HEIGHT+2;\n\n\t// references/modifies \"r_picmip\"\n\ts_graphicsoptions.tq.generic.type\t= MTYPE_SLIDER;\n\ts_graphicsoptions.tq.generic.name\t= \"Texture Detail:\";\n\ts_graphicsoptions.tq.generic.flags\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_graphicsoptions.tq.generic.x\t\t= 400;\n\ts_graphicsoptions.tq.generic.y\t\t= y;\n\ts_graphicsoptions.tq.minvalue       = 0;\n\ts_graphicsoptions.tq.maxvalue       = 3;\n\ts_graphicsoptions.tq.generic.callback = GraphicsOptions_TQEvent;\n\ty += BIGCHAR_HEIGHT+2;\n\n\t// references/modifies \"r_textureBits\"\n\ts_graphicsoptions.texturebits.generic.type  = MTYPE_SPINCONTROL;\n\ts_graphicsoptions.texturebits.generic.name\t= \"Texture Quality:\";\n\ts_graphicsoptions.texturebits.generic.flags\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_graphicsoptions.texturebits.generic.x\t    = 400;\n\ts_graphicsoptions.texturebits.generic.y\t    = y;\n\ts_graphicsoptions.texturebits.itemnames     = tq_names;\n\ty += BIGCHAR_HEIGHT+2;\n\n\t// references/modifies \"r_textureMode\"\n\ts_graphicsoptions.filter.generic.type   = MTYPE_SPINCONTROL;\n\ts_graphicsoptions.filter.generic.name\t= \"Texture Filter:\";\n\ts_graphicsoptions.filter.generic.flags\t= QMF_PULSEIFFOCUS|QMF_SMALLFONT;\n\ts_graphicsoptions.filter.generic.x\t    = 400;\n\ts_graphicsoptions.filter.generic.y\t    = y;\n\ts_graphicsoptions.filter.itemnames      = filter_names;\n\ty += 2*BIGCHAR_HEIGHT;\n\n\ts_graphicsoptions.driverinfo.generic.type     = MTYPE_PTEXT;\n\ts_graphicsoptions.driverinfo.generic.flags    = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_graphicsoptions.driverinfo.generic.callback = GraphicsOptions_Event;\n\ts_graphicsoptions.driverinfo.generic.id       = ID_DRIVERINFO;\n\ts_graphicsoptions.driverinfo.generic.x        = 320;\n\ts_graphicsoptions.driverinfo.generic.y        = y;\n\ts_graphicsoptions.driverinfo.string           = \"Driver Info\";\n\ts_graphicsoptions.driverinfo.style            = UI_CENTER|UI_SMALLFONT;\n\ts_graphicsoptions.driverinfo.color            = color_red;\n\ty += BIGCHAR_HEIGHT+2;\n\n\ts_graphicsoptions.back.generic.type\t    = MTYPE_BITMAP;\n\ts_graphicsoptions.back.generic.name     = GRAPHICSOPTIONS_BACK0;\n\ts_graphicsoptions.back.generic.flags    = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;\n\ts_graphicsoptions.back.generic.callback = GraphicsOptions_Event;\n\ts_graphicsoptions.back.generic.id\t    = ID_BACK2;\n\ts_graphicsoptions.back.generic.x\t\t= 0;\n\ts_graphicsoptions.back.generic.y\t\t= 480-64;\n\ts_graphicsoptions.back.width  \t\t    = 128;\n\ts_graphicsoptions.back.height  \t\t    = 64;\n\ts_graphicsoptions.back.focuspic         = GRAPHICSOPTIONS_BACK1;\n\n\ts_graphicsoptions.apply.generic.type     = MTYPE_BITMAP;\n\ts_graphicsoptions.apply.generic.name     = GRAPHICSOPTIONS_ACCEPT0;\n\ts_graphicsoptions.apply.generic.flags    = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_HIDDEN|QMF_INACTIVE;\n\ts_graphicsoptions.apply.generic.callback = GraphicsOptions_ApplyChanges;\n\ts_graphicsoptions.apply.generic.x        = 640;\n\ts_graphicsoptions.apply.generic.y        = 480-64;\n\ts_graphicsoptions.apply.width  \t\t     = 128;\n\ts_graphicsoptions.apply.height  \t\t = 64;\n\ts_graphicsoptions.apply.focuspic         = GRAPHICSOPTIONS_ACCEPT1;\n\n\tMenu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.banner );\n\tMenu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.framel );\n\tMenu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.framer );\n\n\tMenu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.graphics );\n\tMenu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.display );\n\tMenu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.sound );\n\tMenu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.network );\n\n\tMenu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.list );\n\tMenu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.driver );\n\tMenu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.allow_extensions );\n\tMenu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.mode );\n\tMenu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.colordepth );\n\tMenu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.fs );\n\tMenu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.lighting );\n\tMenu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.geometry );\n\tMenu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.tq );\n\tMenu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.texturebits );\n\tMenu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.filter );\n\tMenu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.driverinfo );\n\n\tMenu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.back );\n\tMenu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.apply );\n\n\tGraphicsOptions_SetMenuItems();\n\tGraphicsOptions_GetInitialVideo();\n\n\tif ( uis.glconfig.driverType == GLDRV_ICD &&\n\t\t uis.glconfig.hardwareType == GLHW_3DFX_2D3D )\n\t{\n\t\ts_graphicsoptions.driver.generic.flags |= QMF_HIDDEN|QMF_INACTIVE;\n\t}\n}\n\n\n/*\n=================\nGraphicsOptions_Cache\n=================\n*/\nvoid GraphicsOptions_Cache( void ) {\n\ttrap_R_RegisterShaderNoMip( GRAPHICSOPTIONS_FRAMEL );\n\ttrap_R_RegisterShaderNoMip( GRAPHICSOPTIONS_FRAMER );\n\ttrap_R_RegisterShaderNoMip( GRAPHICSOPTIONS_BACK0 );\n\ttrap_R_RegisterShaderNoMip( GRAPHICSOPTIONS_BACK1 );\n\ttrap_R_RegisterShaderNoMip( GRAPHICSOPTIONS_ACCEPT0 );\n\ttrap_R_RegisterShaderNoMip( GRAPHICSOPTIONS_ACCEPT1 );\n}\n\n\n/*\n=================\nUI_GraphicsOptionsMenu\n=================\n*/\nvoid UI_GraphicsOptionsMenu( void ) {\n\tGraphicsOptions_MenuInit();\n\tUI_PushMenu( &s_graphicsoptions.menu );\n\tMenu_SetCursorToItem( &s_graphicsoptions.menu, &s_graphicsoptions.graphics );\n}\n\n"
  },
  {
    "path": "code/qcommon/cm_load.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// cmodel.c -- model loading\n\n#include \"cm_local.h\"\n\n#ifdef BSPC\n\n#include \"../bspc/l_qfiles.h\"\n\nvoid SetPlaneSignbits (cplane_t *out) {\n\tint\tbits, j;\n\n\t// for fast box on planeside test\n\tbits = 0;\n\tfor (j=0 ; j<3 ; j++) {\n\t\tif (out->normal[j] < 0) {\n\t\t\tbits |= 1<<j;\n\t\t}\n\t}\n\tout->signbits = bits;\n}\n#endif //BSPC\n\n// to allow boxes to be treated as brush models, we allocate\n// some extra indexes along with those needed by the map\n#define\tBOX_BRUSHES\t\t1\n#define\tBOX_SIDES\t\t6\n#define\tBOX_LEAFS\t\t2\n#define\tBOX_PLANES\t\t12\n\n#define\tLL(x) x=LittleLong(x)\n\n\nclipMap_t\tcm;\nint\t\t\tc_pointcontents;\nint\t\t\tc_traces, c_brush_traces, c_patch_traces;\n\n\nbyte\t\t*cmod_base;\n\n#ifndef BSPC\ncvar_t\t\t*cm_noAreas;\ncvar_t\t\t*cm_noCurves;\ncvar_t\t\t*cm_playerCurveClip;\n#endif\n\ncmodel_t\tbox_model;\ncplane_t\t*box_planes;\ncbrush_t\t*box_brush;\n\n\n\nvoid\tCM_InitBoxHull (void);\nvoid\tCM_FloodAreaConnections (void);\n\n\n/*\n===============================================================================\n\n\t\t\t\t\tMAP LOADING\n\n===============================================================================\n*/\n\n/*\n=================\nCMod_LoadShaders\n=================\n*/\nvoid CMod_LoadShaders( lump_t *l ) {\n\tdshader_t\t*in, *out;\n\tint\t\t\ti, count;\n\n\tin = (void *)(cmod_base + l->fileofs);\n\tif (l->filelen % sizeof(*in)) {\n\t\tCom_Error (ERR_DROP, \"CMod_LoadShaders: funny lump size\");\n\t}\n\tcount = l->filelen / sizeof(*in);\n\n\tif (count < 1) {\n\t\tCom_Error (ERR_DROP, \"Map with no shaders\");\n\t}\n\tcm.shaders = Hunk_Alloc( count * sizeof( *cm.shaders ), h_high );\n\tcm.numShaders = count;\n\n\tCom_Memcpy( cm.shaders, in, count * sizeof( *cm.shaders ) );\n\n\tout = cm.shaders;\n\tfor ( i=0 ; i<count ; i++, in++, out++ ) {\n\t\tout->contentFlags = LittleLong( out->contentFlags );\n\t\tout->surfaceFlags = LittleLong( out->surfaceFlags );\n\t}\n}\n\n\n/*\n=================\nCMod_LoadSubmodels\n=================\n*/\nvoid CMod_LoadSubmodels( lump_t *l ) {\n\tdmodel_t\t*in;\n\tcmodel_t\t*out;\n\tint\t\t\ti, j, count;\n\tint\t\t\t*indexes;\n\n\tin = (void *)(cmod_base + l->fileofs);\n\tif (l->filelen % sizeof(*in))\n\t\tCom_Error (ERR_DROP, \"CMod_LoadSubmodels: funny lump size\");\n\tcount = l->filelen / sizeof(*in);\n\n\tif (count < 1)\n\t\tCom_Error (ERR_DROP, \"Map with no models\");\n\tcm.cmodels = Hunk_Alloc( count * sizeof( *cm.cmodels ), h_high );\n\tcm.numSubModels = count;\n\n\tif ( count > MAX_SUBMODELS ) {\n\t\tCom_Error( ERR_DROP, \"MAX_SUBMODELS exceeded\" );\n\t}\n\n\tfor ( i=0 ; i<count ; i++, in++, out++)\n\t{\n\t\tout = &cm.cmodels[i];\n\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\t// spread the mins / maxs by a pixel\n\t\t\tout->mins[j] = LittleFloat (in->mins[j]) - 1;\n\t\t\tout->maxs[j] = LittleFloat (in->maxs[j]) + 1;\n\t\t}\n\n\t\tif ( i == 0 ) {\n\t\t\tcontinue;\t// world model doesn't need other info\n\t\t}\n\n\t\t// make a \"leaf\" just to hold the model's brushes and surfaces\n\t\tout->leaf.numLeafBrushes = LittleLong( in->numBrushes );\n\t\tindexes = Hunk_Alloc( out->leaf.numLeafBrushes * 4, h_high );\n\t\tout->leaf.firstLeafBrush = indexes - cm.leafbrushes;\n\t\tfor ( j = 0 ; j < out->leaf.numLeafBrushes ; j++ ) {\n\t\t\tindexes[j] = LittleLong( in->firstBrush ) + j;\n\t\t}\n\n\t\tout->leaf.numLeafSurfaces = LittleLong( in->numSurfaces );\n\t\tindexes = Hunk_Alloc( out->leaf.numLeafSurfaces * 4, h_high );\n\t\tout->leaf.firstLeafSurface = indexes - cm.leafsurfaces;\n\t\tfor ( j = 0 ; j < out->leaf.numLeafSurfaces ; j++ ) {\n\t\t\tindexes[j] = LittleLong( in->firstSurface ) + j;\n\t\t}\n\t}\n}\n\n\n/*\n=================\nCMod_LoadNodes\n\n=================\n*/\nvoid CMod_LoadNodes( lump_t *l ) {\n\tdnode_t\t\t*in;\n\tint\t\t\tchild;\n\tcNode_t\t\t*out;\n\tint\t\t\ti, j, count;\n\t\n\tin = (void *)(cmod_base + l->fileofs);\n\tif (l->filelen % sizeof(*in))\n\t\tCom_Error (ERR_DROP, \"MOD_LoadBmodel: funny lump size\");\n\tcount = l->filelen / sizeof(*in);\n\n\tif (count < 1)\n\t\tCom_Error (ERR_DROP, \"Map has no nodes\");\n\tcm.nodes = Hunk_Alloc( count * sizeof( *cm.nodes ), h_high );\n\tcm.numNodes = count;\n\n\tout = cm.nodes;\n\n\tfor (i=0 ; i<count ; i++, out++, in++)\n\t{\n\t\tout->plane = cm.planes + LittleLong( in->planeNum );\n\t\tfor (j=0 ; j<2 ; j++)\n\t\t{\n\t\t\tchild = LittleLong (in->children[j]);\n\t\t\tout->children[j] = child;\n\t\t}\n\t}\n\n}\n\n/*\n=================\nCM_BoundBrush\n\n=================\n*/\nvoid CM_BoundBrush( cbrush_t *b ) {\n\tb->bounds[0][0] = -b->sides[0].plane->dist;\n\tb->bounds[1][0] = b->sides[1].plane->dist;\n\n\tb->bounds[0][1] = -b->sides[2].plane->dist;\n\tb->bounds[1][1] = b->sides[3].plane->dist;\n\n\tb->bounds[0][2] = -b->sides[4].plane->dist;\n\tb->bounds[1][2] = b->sides[5].plane->dist;\n}\n\n\n/*\n=================\nCMod_LoadBrushes\n\n=================\n*/\nvoid CMod_LoadBrushes( lump_t *l ) {\n\tdbrush_t\t*in;\n\tcbrush_t\t*out;\n\tint\t\t\ti, count;\n\n\tin = (void *)(cmod_base + l->fileofs);\n\tif (l->filelen % sizeof(*in)) {\n\t\tCom_Error (ERR_DROP, \"MOD_LoadBmodel: funny lump size\");\n\t}\n\tcount = l->filelen / sizeof(*in);\n\n\tcm.brushes = Hunk_Alloc( ( BOX_BRUSHES + count ) * sizeof( *cm.brushes ), h_high );\n\tcm.numBrushes = count;\n\n\tout = cm.brushes;\n\n\tfor ( i=0 ; i<count ; i++, out++, in++ ) {\n\t\tout->sides = cm.brushsides + LittleLong(in->firstSide);\n\t\tout->numsides = LittleLong(in->numSides);\n\n\t\tout->shaderNum = LittleLong( in->shaderNum );\n\t\tif ( out->shaderNum < 0 || out->shaderNum >= cm.numShaders ) {\n\t\t\tCom_Error( ERR_DROP, \"CMod_LoadBrushes: bad shaderNum: %i\", out->shaderNum );\n\t\t}\n\t\tout->contents = cm.shaders[out->shaderNum].contentFlags;\n\n\t\tCM_BoundBrush( out );\n\t}\n\n}\n\n/*\n=================\nCMod_LoadLeafs\n=================\n*/\nvoid CMod_LoadLeafs (lump_t *l)\n{\n\tint\t\t\ti;\n\tcLeaf_t\t\t*out;\n\tdleaf_t \t*in;\n\tint\t\t\tcount;\n\t\n\tin = (void *)(cmod_base + l->fileofs);\n\tif (l->filelen % sizeof(*in))\n\t\tCom_Error (ERR_DROP, \"MOD_LoadBmodel: funny lump size\");\n\tcount = l->filelen / sizeof(*in);\n\n\tif (count < 1)\n\t\tCom_Error (ERR_DROP, \"Map with no leafs\");\n\n\tcm.leafs = Hunk_Alloc( ( BOX_LEAFS + count ) * sizeof( *cm.leafs ), h_high );\n\tcm.numLeafs = count;\n\n\tout = cm.leafs;\t\n\tfor ( i=0 ; i<count ; i++, in++, out++)\n\t{\n\t\tout->cluster = LittleLong (in->cluster);\n\t\tout->area = LittleLong (in->area);\n\t\tout->firstLeafBrush = LittleLong (in->firstLeafBrush);\n\t\tout->numLeafBrushes = LittleLong (in->numLeafBrushes);\n\t\tout->firstLeafSurface = LittleLong (in->firstLeafSurface);\n\t\tout->numLeafSurfaces = LittleLong (in->numLeafSurfaces);\n\n\t\tif (out->cluster >= cm.numClusters)\n\t\t\tcm.numClusters = out->cluster + 1;\n\t\tif (out->area >= cm.numAreas)\n\t\t\tcm.numAreas = out->area + 1;\n\t}\n\n\tcm.areas = Hunk_Alloc( cm.numAreas * sizeof( *cm.areas ), h_high );\n\tcm.areaPortals = Hunk_Alloc( cm.numAreas * cm.numAreas * sizeof( *cm.areaPortals ), h_high );\n}\n\n/*\n=================\nCMod_LoadPlanes\n=================\n*/\nvoid CMod_LoadPlanes (lump_t *l)\n{\n\tint\t\t\ti, j;\n\tcplane_t\t*out;\n\tdplane_t \t*in;\n\tint\t\t\tcount;\n\tint\t\t\tbits;\n\t\n\tin = (void *)(cmod_base + l->fileofs);\n\tif (l->filelen % sizeof(*in))\n\t\tCom_Error (ERR_DROP, \"MOD_LoadBmodel: funny lump size\");\n\tcount = l->filelen / sizeof(*in);\n\n\tif (count < 1)\n\t\tCom_Error (ERR_DROP, \"Map with no planes\");\n\tcm.planes = Hunk_Alloc( ( BOX_PLANES + count ) * sizeof( *cm.planes ), h_high );\n\tcm.numPlanes = count;\n\n\tout = cm.planes;\t\n\n\tfor ( i=0 ; i<count ; i++, in++, out++)\n\t{\n\t\tbits = 0;\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\tout->normal[j] = LittleFloat (in->normal[j]);\n\t\t\tif (out->normal[j] < 0)\n\t\t\t\tbits |= 1<<j;\n\t\t}\n\n\t\tout->dist = LittleFloat (in->dist);\n\t\tout->type = PlaneTypeForNormal( out->normal );\n\t\tout->signbits = bits;\n\t}\n}\n\n/*\n=================\nCMod_LoadLeafBrushes\n=================\n*/\nvoid CMod_LoadLeafBrushes (lump_t *l)\n{\n\tint\t\t\ti;\n\tint\t\t\t*out;\n\tint\t\t \t*in;\n\tint\t\t\tcount;\n\t\n\tin = (void *)(cmod_base + l->fileofs);\n\tif (l->filelen % sizeof(*in))\n\t\tCom_Error (ERR_DROP, \"MOD_LoadBmodel: funny lump size\");\n\tcount = l->filelen / sizeof(*in);\n\n\tcm.leafbrushes = Hunk_Alloc( (count + BOX_BRUSHES) * sizeof( *cm.leafbrushes ), h_high );\n\tcm.numLeafBrushes = count;\n\n\tout = cm.leafbrushes;\n\n\tfor ( i=0 ; i<count ; i++, in++, out++) {\n\t\t*out = LittleLong (*in);\n\t}\n}\n\n/*\n=================\nCMod_LoadLeafSurfaces\n=================\n*/\nvoid CMod_LoadLeafSurfaces( lump_t *l )\n{\n\tint\t\t\ti;\n\tint\t\t\t*out;\n\tint\t\t \t*in;\n\tint\t\t\tcount;\n\t\n\tin = (void *)(cmod_base + l->fileofs);\n\tif (l->filelen % sizeof(*in))\n\t\tCom_Error (ERR_DROP, \"MOD_LoadBmodel: funny lump size\");\n\tcount = l->filelen / sizeof(*in);\n\n\tcm.leafsurfaces = Hunk_Alloc( count * sizeof( *cm.leafsurfaces ), h_high );\n\tcm.numLeafSurfaces = count;\n\n\tout = cm.leafsurfaces;\n\n\tfor ( i=0 ; i<count ; i++, in++, out++) {\n\t\t*out = LittleLong (*in);\n\t}\n}\n\n/*\n=================\nCMod_LoadBrushSides\n=================\n*/\nvoid CMod_LoadBrushSides (lump_t *l)\n{\n\tint\t\t\t\ti;\n\tcbrushside_t\t*out;\n\tdbrushside_t \t*in;\n\tint\t\t\t\tcount;\n\tint\t\t\t\tnum;\n\n\tin = (void *)(cmod_base + l->fileofs);\n\tif ( l->filelen % sizeof(*in) ) {\n\t\tCom_Error (ERR_DROP, \"MOD_LoadBmodel: funny lump size\");\n\t}\n\tcount = l->filelen / sizeof(*in);\n\n\tcm.brushsides = Hunk_Alloc( ( BOX_SIDES + count ) * sizeof( *cm.brushsides ), h_high );\n\tcm.numBrushSides = count;\n\n\tout = cm.brushsides;\t\n\n\tfor ( i=0 ; i<count ; i++, in++, out++) {\n\t\tnum = LittleLong( in->planeNum );\n\t\tout->plane = &cm.planes[num];\n\t\tout->shaderNum = LittleLong( in->shaderNum );\n\t\tif ( out->shaderNum < 0 || out->shaderNum >= cm.numShaders ) {\n\t\t\tCom_Error( ERR_DROP, \"CMod_LoadBrushSides: bad shaderNum: %i\", out->shaderNum );\n\t\t}\n\t\tout->surfaceFlags = cm.shaders[out->shaderNum].surfaceFlags;\n\t}\n}\n\n\n/*\n=================\nCMod_LoadEntityString\n=================\n*/\nvoid CMod_LoadEntityString( lump_t *l ) {\n\tcm.entityString = Hunk_Alloc( l->filelen, h_high );\n\tcm.numEntityChars = l->filelen;\n\tCom_Memcpy (cm.entityString, cmod_base + l->fileofs, l->filelen);\n}\n\n/*\n=================\nCMod_LoadVisibility\n=================\n*/\n#define\tVIS_HEADER\t8\nvoid CMod_LoadVisibility( lump_t *l ) {\n\tint\t\tlen;\n\tbyte\t*buf;\n\n    len = l->filelen;\n\tif ( !len ) {\n\t\tcm.clusterBytes = ( cm.numClusters + 31 ) & ~31;\n\t\tcm.visibility = Hunk_Alloc( cm.clusterBytes, h_high );\n\t\tCom_Memset( cm.visibility, 255, cm.clusterBytes );\n\t\treturn;\n\t}\n\tbuf = cmod_base + l->fileofs;\n\n\tcm.vised = qtrue;\n\tcm.visibility = Hunk_Alloc( len, h_high );\n\tcm.numClusters = LittleLong( ((int *)buf)[0] );\n\tcm.clusterBytes = LittleLong( ((int *)buf)[1] );\n\tCom_Memcpy (cm.visibility, buf + VIS_HEADER, len - VIS_HEADER );\n}\n\n//==================================================================\n\n\n/*\n=================\nCMod_LoadPatches\n=================\n*/\n#define\tMAX_PATCH_VERTS\t\t1024\nvoid CMod_LoadPatches( lump_t *surfs, lump_t *verts ) {\n\tdrawVert_t\t*dv, *dv_p;\n\tdsurface_t\t*in;\n\tint\t\t\tcount;\n\tint\t\t\ti, j;\n\tint\t\t\tc;\n\tcPatch_t\t*patch;\n\tvec3_t\t\tpoints[MAX_PATCH_VERTS];\n\tint\t\t\twidth, height;\n\tint\t\t\tshaderNum;\n\n\tin = (void *)(cmod_base + surfs->fileofs);\n\tif (surfs->filelen % sizeof(*in))\n\t\tCom_Error (ERR_DROP, \"MOD_LoadBmodel: funny lump size\");\n\tcm.numSurfaces = count = surfs->filelen / sizeof(*in);\n\tcm.surfaces = Hunk_Alloc( cm.numSurfaces * sizeof( cm.surfaces[0] ), h_high );\n\n\tdv = (void *)(cmod_base + verts->fileofs);\n\tif (verts->filelen % sizeof(*dv))\n\t\tCom_Error (ERR_DROP, \"MOD_LoadBmodel: funny lump size\");\n\n\t// scan through all the surfaces, but only load patches,\n\t// not planar faces\n\tfor ( i = 0 ; i < count ; i++, in++ ) {\n\t\tif ( LittleLong( in->surfaceType ) != MST_PATCH ) {\n\t\t\tcontinue;\t\t// ignore other surfaces\n\t\t}\n\t\t// FIXME: check for non-colliding patches\n\n\t\tcm.surfaces[ i ] = patch = Hunk_Alloc( sizeof( *patch ), h_high );\n\n\t\t// load the full drawverts onto the stack\n\t\twidth = LittleLong( in->patchWidth );\n\t\theight = LittleLong( in->patchHeight );\n\t\tc = width * height;\n\t\tif ( c > MAX_PATCH_VERTS ) {\n\t\t\tCom_Error( ERR_DROP, \"ParseMesh: MAX_PATCH_VERTS\" );\n\t\t}\n\n\t\tdv_p = dv + LittleLong( in->firstVert );\n\t\tfor ( j = 0 ; j < c ; j++, dv_p++ ) {\n\t\t\tpoints[j][0] = LittleFloat( dv_p->xyz[0] );\n\t\t\tpoints[j][1] = LittleFloat( dv_p->xyz[1] );\n\t\t\tpoints[j][2] = LittleFloat( dv_p->xyz[2] );\n\t\t}\n\n\t\tshaderNum = LittleLong( in->shaderNum );\n\t\tpatch->contents = cm.shaders[shaderNum].contentFlags;\n\t\tpatch->surfaceFlags = cm.shaders[shaderNum].surfaceFlags;\n\n\t\t// create the internal facet structure\n\t\tpatch->pc = CM_GeneratePatchCollide( width, height, points );\n\t}\n}\n\n//==================================================================\n\nunsigned CM_LumpChecksum(lump_t *lump) {\n\treturn LittleLong (Com_BlockChecksum (cmod_base + lump->fileofs, lump->filelen));\n}\n\nunsigned CM_Checksum(dheader_t *header) {\n\tunsigned checksums[16];\n\tchecksums[0] = CM_LumpChecksum(&header->lumps[LUMP_SHADERS]);\n\tchecksums[1] = CM_LumpChecksum(&header->lumps[LUMP_LEAFS]);\n\tchecksums[2] = CM_LumpChecksum(&header->lumps[LUMP_LEAFBRUSHES]);\n\tchecksums[3] = CM_LumpChecksum(&header->lumps[LUMP_LEAFSURFACES]);\n\tchecksums[4] = CM_LumpChecksum(&header->lumps[LUMP_PLANES]);\n\tchecksums[5] = CM_LumpChecksum(&header->lumps[LUMP_BRUSHSIDES]);\n\tchecksums[6] = CM_LumpChecksum(&header->lumps[LUMP_BRUSHES]);\n\tchecksums[7] = CM_LumpChecksum(&header->lumps[LUMP_MODELS]);\n\tchecksums[8] = CM_LumpChecksum(&header->lumps[LUMP_NODES]);\n\tchecksums[9] = CM_LumpChecksum(&header->lumps[LUMP_SURFACES]);\n\tchecksums[10] = CM_LumpChecksum(&header->lumps[LUMP_DRAWVERTS]);\n\n\treturn LittleLong(Com_BlockChecksum(checksums, 11 * 4));\n}\n\n/*\n==================\nCM_LoadMap\n\nLoads in the map and all submodels\n==================\n*/\nvoid CM_LoadMap( const char *name, qboolean clientload, int *checksum ) {\n\tint\t\t\t\t*buf;\n\tint\t\t\t\ti;\n\tdheader_t\t\theader;\n\tint\t\t\t\tlength;\n\tstatic unsigned\tlast_checksum;\n\n\tif ( !name || !name[0] ) {\n\t\tCom_Error( ERR_DROP, \"CM_LoadMap: NULL name\" );\n\t}\n\n#ifndef BSPC\n\tcm_noAreas = Cvar_Get (\"cm_noAreas\", \"0\", CVAR_CHEAT);\n\tcm_noCurves = Cvar_Get (\"cm_noCurves\", \"0\", CVAR_CHEAT);\n\tcm_playerCurveClip = Cvar_Get (\"cm_playerCurveClip\", \"1\", CVAR_ARCHIVE|CVAR_CHEAT );\n#endif\n\tCom_DPrintf( \"CM_LoadMap( %s, %i )\\n\", name, clientload );\n\n\tif ( !strcmp( cm.name, name ) && clientload ) {\n\t\t*checksum = last_checksum;\n\t\treturn;\n\t}\n\n\t// free old stuff\n\tCom_Memset( &cm, 0, sizeof( cm ) );\n\tCM_ClearLevelPatches();\n\n\tif ( !name[0] ) {\n\t\tcm.numLeafs = 1;\n\t\tcm.numClusters = 1;\n\t\tcm.numAreas = 1;\n\t\tcm.cmodels = Hunk_Alloc( sizeof( *cm.cmodels ), h_high );\n\t\t*checksum = 0;\n\t\treturn;\n\t}\n\n\t//\n\t// load the file\n\t//\n#ifndef BSPC\n\tlength = FS_ReadFile( name, (void **)&buf );\n#else\n\tlength = LoadQuakeFile((quakefile_t *) name, (void **)&buf);\n#endif\n\n\tif ( !buf ) {\n\t\tCom_Error (ERR_DROP, \"Couldn't load %s\", name);\n\t}\n\n\tlast_checksum = LittleLong (Com_BlockChecksum (buf, length));\n\t*checksum = last_checksum;\n\n\theader = *(dheader_t *)buf;\n\tfor (i=0 ; i<sizeof(dheader_t)/4 ; i++) {\n\t\t((int *)&header)[i] = LittleLong ( ((int *)&header)[i]);\n\t}\n\n\tif ( header.version != BSP_VERSION ) {\n\t\tCom_Error (ERR_DROP, \"CM_LoadMap: %s has wrong version number (%i should be %i)\"\n\t\t, name, header.version, BSP_VERSION );\n\t}\n\n\tcmod_base = (byte *)buf;\n\n\t// load into heap\n\tCMod_LoadShaders( &header.lumps[LUMP_SHADERS] );\n\tCMod_LoadLeafs (&header.lumps[LUMP_LEAFS]);\n\tCMod_LoadLeafBrushes (&header.lumps[LUMP_LEAFBRUSHES]);\n\tCMod_LoadLeafSurfaces (&header.lumps[LUMP_LEAFSURFACES]);\n\tCMod_LoadPlanes (&header.lumps[LUMP_PLANES]);\n\tCMod_LoadBrushSides (&header.lumps[LUMP_BRUSHSIDES]);\n\tCMod_LoadBrushes (&header.lumps[LUMP_BRUSHES]);\n\tCMod_LoadSubmodels (&header.lumps[LUMP_MODELS]);\n\tCMod_LoadNodes (&header.lumps[LUMP_NODES]);\n\tCMod_LoadEntityString (&header.lumps[LUMP_ENTITIES]);\n\tCMod_LoadVisibility( &header.lumps[LUMP_VISIBILITY] );\n\tCMod_LoadPatches( &header.lumps[LUMP_SURFACES], &header.lumps[LUMP_DRAWVERTS] );\n\n\t// we are NOT freeing the file, because it is cached for the ref\n\tFS_FreeFile (buf);\n\n\tCM_InitBoxHull ();\n\n\tCM_FloodAreaConnections ();\n\n\t// allow this to be cached if it is loaded by the server\n\tif ( !clientload ) {\n\t\tQ_strncpyz( cm.name, name, sizeof( cm.name ) );\n\t}\n}\n\n/*\n==================\nCM_ClearMap\n==================\n*/\nvoid CM_ClearMap( void ) {\n\tCom_Memset( &cm, 0, sizeof( cm ) );\n\tCM_ClearLevelPatches();\n}\n\n/*\n==================\nCM_ClipHandleToModel\n==================\n*/\ncmodel_t\t*CM_ClipHandleToModel( clipHandle_t handle ) {\n\tif ( handle < 0 ) {\n\t\tCom_Error( ERR_DROP, \"CM_ClipHandleToModel: bad handle %i\", handle );\n\t}\n\tif ( handle < cm.numSubModels ) {\n\t\treturn &cm.cmodels[handle];\n\t}\n\tif ( handle == BOX_MODEL_HANDLE ) {\n\t\treturn &box_model;\n\t}\n\tif ( handle < MAX_SUBMODELS ) {\n\t\tCom_Error( ERR_DROP, \"CM_ClipHandleToModel: bad handle %i < %i < %i\", \n\t\t\tcm.numSubModels, handle, MAX_SUBMODELS );\n\t}\n\tCom_Error( ERR_DROP, \"CM_ClipHandleToModel: bad handle %i\", handle + MAX_SUBMODELS );\n\n\treturn NULL;\n\n}\n\n/*\n==================\nCM_InlineModel\n==================\n*/\nclipHandle_t\tCM_InlineModel( int index ) {\n\tif ( index < 0 || index >= cm.numSubModels ) {\n\t\tCom_Error (ERR_DROP, \"CM_InlineModel: bad number\");\n\t}\n\treturn index;\n}\n\nint\t\tCM_NumClusters( void ) {\n\treturn cm.numClusters;\n}\n\nint\t\tCM_NumInlineModels( void ) {\n\treturn cm.numSubModels;\n}\n\nchar\t*CM_EntityString( void ) {\n\treturn cm.entityString;\n}\n\nint\t\tCM_LeafCluster( int leafnum ) {\n\tif (leafnum < 0 || leafnum >= cm.numLeafs) {\n\t\tCom_Error (ERR_DROP, \"CM_LeafCluster: bad number\");\n\t}\n\treturn cm.leafs[leafnum].cluster;\n}\n\nint\t\tCM_LeafArea( int leafnum ) {\n\tif ( leafnum < 0 || leafnum >= cm.numLeafs ) {\n\t\tCom_Error (ERR_DROP, \"CM_LeafArea: bad number\");\n\t}\n\treturn cm.leafs[leafnum].area;\n}\n\n//=======================================================================\n\n\n/*\n===================\nCM_InitBoxHull\n\nSet up the planes and nodes so that the six floats of a bounding box\ncan just be stored out and get a proper clipping hull structure.\n===================\n*/\nvoid CM_InitBoxHull (void)\n{\n\tint\t\t\ti;\n\tint\t\t\tside;\n\tcplane_t\t*p;\n\tcbrushside_t\t*s;\n\n\tbox_planes = &cm.planes[cm.numPlanes];\n\n\tbox_brush = &cm.brushes[cm.numBrushes];\n\tbox_brush->numsides = 6;\n\tbox_brush->sides = cm.brushsides + cm.numBrushSides;\n\tbox_brush->contents = CONTENTS_BODY;\n\n\tbox_model.leaf.numLeafBrushes = 1;\n//\tbox_model.leaf.firstLeafBrush = cm.numBrushes;\n\tbox_model.leaf.firstLeafBrush = cm.numLeafBrushes;\n\tcm.leafbrushes[cm.numLeafBrushes] = cm.numBrushes;\n\n\tfor (i=0 ; i<6 ; i++)\n\t{\n\t\tside = i&1;\n\n\t\t// brush sides\n\t\ts = &cm.brushsides[cm.numBrushSides+i];\n\t\ts->plane = \tcm.planes + (cm.numPlanes+i*2+side);\n\t\ts->surfaceFlags = 0;\n\n\t\t// planes\n\t\tp = &box_planes[i*2];\n\t\tp->type = i>>1;\n\t\tp->signbits = 0;\n\t\tVectorClear (p->normal);\n\t\tp->normal[i>>1] = 1;\n\n\t\tp = &box_planes[i*2+1];\n\t\tp->type = 3 + (i>>1);\n\t\tp->signbits = 0;\n\t\tVectorClear (p->normal);\n\t\tp->normal[i>>1] = -1;\n\n\t\tSetPlaneSignbits( p );\n\t}\t\n}\n\n/*\n===================\nCM_TempBoxModel\n\nTo keep everything totally uniform, bounding boxes are turned into small\nBSP trees instead of being compared directly.\nCapsules are handled differently though.\n===================\n*/\nclipHandle_t CM_TempBoxModel( const vec3_t mins, const vec3_t maxs, int capsule ) {\n\n\tVectorCopy( mins, box_model.mins );\n\tVectorCopy( maxs, box_model.maxs );\n\n\tif ( capsule ) {\n\t\treturn CAPSULE_MODEL_HANDLE;\n\t}\n\n\tbox_planes[0].dist = maxs[0];\n\tbox_planes[1].dist = -maxs[0];\n\tbox_planes[2].dist = mins[0];\n\tbox_planes[3].dist = -mins[0];\n\tbox_planes[4].dist = maxs[1];\n\tbox_planes[5].dist = -maxs[1];\n\tbox_planes[6].dist = mins[1];\n\tbox_planes[7].dist = -mins[1];\n\tbox_planes[8].dist = maxs[2];\n\tbox_planes[9].dist = -maxs[2];\n\tbox_planes[10].dist = mins[2];\n\tbox_planes[11].dist = -mins[2];\n\n\tVectorCopy( mins, box_brush->bounds[0] );\n\tVectorCopy( maxs, box_brush->bounds[1] );\n\n\treturn BOX_MODEL_HANDLE;\n}\n\n/*\n===================\nCM_ModelBounds\n===================\n*/\nvoid CM_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs ) {\n\tcmodel_t\t*cmod;\n\n\tcmod = CM_ClipHandleToModel( model );\n\tVectorCopy( cmod->mins, mins );\n\tVectorCopy( cmod->maxs, maxs );\n}\n\n\n"
  },
  {
    "path": "code/qcommon/cm_local.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"../game/q_shared.h\"\n#include \"qcommon.h\"\n#include \"cm_polylib.h\"\n\n#define\tMAX_SUBMODELS\t\t\t256\n#define\tBOX_MODEL_HANDLE\t\t255\n#define CAPSULE_MODEL_HANDLE\t254\n\n\ntypedef struct {\n\tcplane_t\t*plane;\n\tint\t\t\tchildren[2];\t\t// negative numbers are leafs\n} cNode_t;\n\ntypedef struct {\n\tint\t\t\tcluster;\n\tint\t\t\tarea;\n\n\tint\t\t\tfirstLeafBrush;\n\tint\t\t\tnumLeafBrushes;\n\n\tint\t\t\tfirstLeafSurface;\n\tint\t\t\tnumLeafSurfaces;\n} cLeaf_t;\n\ntypedef struct cmodel_s {\n\tvec3_t\t\tmins, maxs;\n\tcLeaf_t\t\tleaf;\t\t\t// submodels don't reference the main tree\n} cmodel_t;\n\ntypedef struct {\n\tcplane_t\t*plane;\n\tint\t\t\tsurfaceFlags;\n\tint\t\t\tshaderNum;\n} cbrushside_t;\n\ntypedef struct {\n\tint\t\t\tshaderNum;\t\t// the shader that determined the contents\n\tint\t\t\tcontents;\n\tvec3_t\t\tbounds[2];\n\tint\t\t\tnumsides;\n\tcbrushside_t\t*sides;\n\tint\t\t\tcheckcount;\t\t// to avoid repeated testings\n} cbrush_t;\n\n\ntypedef struct {\n\tint\t\t\tcheckcount;\t\t\t\t// to avoid repeated testings\n\tint\t\t\tsurfaceFlags;\n\tint\t\t\tcontents;\n\tstruct patchCollide_s\t*pc;\n} cPatch_t;\n\n\ntypedef struct {\n\tint\t\t\tfloodnum;\n\tint\t\t\tfloodvalid;\n} cArea_t;\n\ntypedef struct {\n\tchar\t\tname[MAX_QPATH];\n\n\tint\t\t\tnumShaders;\n\tdshader_t\t*shaders;\n\n\tint\t\t\tnumBrushSides;\n\tcbrushside_t *brushsides;\n\n\tint\t\t\tnumPlanes;\n\tcplane_t\t*planes;\n\n\tint\t\t\tnumNodes;\n\tcNode_t\t\t*nodes;\n\n\tint\t\t\tnumLeafs;\n\tcLeaf_t\t\t*leafs;\n\n\tint\t\t\tnumLeafBrushes;\n\tint\t\t\t*leafbrushes;\n\n\tint\t\t\tnumLeafSurfaces;\n\tint\t\t\t*leafsurfaces;\n\n\tint\t\t\tnumSubModels;\n\tcmodel_t\t*cmodels;\n\n\tint\t\t\tnumBrushes;\n\tcbrush_t\t*brushes;\n\n\tint\t\t\tnumClusters;\n\tint\t\t\tclusterBytes;\n\tbyte\t\t*visibility;\n\tqboolean\tvised;\t\t\t// if false, visibility is just a single cluster of ffs\n\n\tint\t\t\tnumEntityChars;\n\tchar\t\t*entityString;\n\n\tint\t\t\tnumAreas;\n\tcArea_t\t\t*areas;\n\tint\t\t\t*areaPortals;\t// [ numAreas*numAreas ] reference counts\n\n\tint\t\t\tnumSurfaces;\n\tcPatch_t\t**surfaces;\t\t\t// non-patches will be NULL\n\n\tint\t\t\tfloodvalid;\n\tint\t\t\tcheckcount;\t\t\t\t\t// incremented on each trace\n} clipMap_t;\n\n\n// keep 1/8 unit away to keep the position valid before network snapping\n// and to avoid various numeric issues\n#define\tSURFACE_CLIP_EPSILON\t(0.125)\n\nextern\tclipMap_t\tcm;\nextern\tint\t\t\tc_pointcontents;\nextern\tint\t\t\tc_traces, c_brush_traces, c_patch_traces;\nextern\tcvar_t\t\t*cm_noAreas;\nextern\tcvar_t\t\t*cm_noCurves;\nextern\tcvar_t\t\t*cm_playerCurveClip;\n\n// cm_test.c\n\n// Used for oriented capsule collision detection\ntypedef struct\n{\n\tqboolean\tuse;\n\tfloat\t\tradius;\n\tfloat\t\thalfheight;\n\tvec3_t\t\toffset;\n} sphere_t;\n\ntypedef struct {\n\tvec3_t\t\tstart;\n\tvec3_t\t\tend;\n\tvec3_t\t\tsize[2];\t// size of the box being swept through the model\n\tvec3_t\t\toffsets[8];\t// [signbits][x] = either size[0][x] or size[1][x]\n\tfloat\t\tmaxOffset;\t// longest corner length from origin\n\tvec3_t\t\textents;\t// greatest of abs(size[0]) and abs(size[1])\n\tvec3_t\t\tbounds[2];\t// enclosing box of start and end surrounding by size\n\tvec3_t\t\tmodelOrigin;// origin of the model tracing through\n\tint\t\t\tcontents;\t// ored contents of the model tracing through\n\tqboolean\tisPoint;\t// optimized case\n\ttrace_t\t\ttrace;\t\t// returned from trace call\n\tsphere_t\tsphere;\t\t// sphere for oriendted capsule collision\n} traceWork_t;\n\ntypedef struct leafList_s {\n\tint\t\tcount;\n\tint\t\tmaxcount;\n\tqboolean\toverflowed;\n\tint\t\t*list;\n\tvec3_t\tbounds[2];\n\tint\t\tlastLeaf;\t\t// for overflows where each leaf can't be stored individually\n\tvoid\t(*storeLeafs)( struct leafList_s *ll, int nodenum );\n} leafList_t;\n\n\nint CM_BoxBrushes( const vec3_t mins, const vec3_t maxs, cbrush_t **list, int listsize );\n\nvoid CM_StoreLeafs( leafList_t *ll, int nodenum );\nvoid CM_StoreBrushes( leafList_t *ll, int nodenum );\n\nvoid CM_BoxLeafnums_r( leafList_t *ll, int nodenum );\n\ncmodel_t\t*CM_ClipHandleToModel( clipHandle_t handle );\n\n// cm_patch.c\n\nstruct patchCollide_s\t*CM_GeneratePatchCollide( int width, int height, vec3_t *points );\nvoid CM_TraceThroughPatchCollide( traceWork_t *tw, const struct patchCollide_s *pc );\nqboolean CM_PositionTestInPatchCollide( traceWork_t *tw, const struct patchCollide_s *pc );\nvoid CM_ClearLevelPatches( void );\n"
  },
  {
    "path": "code/qcommon/cm_patch.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"cm_local.h\"\n#include \"cm_patch.h\"\n\n/*\n\nThis file does not reference any globals, and has these entry points:\n\nvoid CM_ClearLevelPatches( void );\nstruct patchCollide_s\t*CM_GeneratePatchCollide( int width, int height, const vec3_t *points );\nvoid CM_TraceThroughPatchCollide( traceWork_t *tw, const struct patchCollide_s *pc );\nqboolean CM_PositionTestInPatchCollide( traceWork_t *tw, const struct patchCollide_s *pc );\nvoid CM_DrawDebugSurface( void (*drawPoly)(int color, int numPoints, flaot *points) );\n\n\nWARNING: this may misbehave with meshes that have rows or columns that only\ndegenerate a few triangles.  Completely degenerate rows and columns are handled\nproperly.\n*/\n\n/*\n#define\tMAX_FACETS\t\t\t1024\n#define\tMAX_PATCH_PLANES\t2048\n\ntypedef struct {\n\tfloat\tplane[4];\n\tint\t\tsignbits;\t\t// signx + (signy<<1) + (signz<<2), used as lookup during collision\n} patchPlane_t;\n\ntypedef struct {\n\tint\t\t\tsurfacePlane;\n\tint\t\t\tnumBorders;\t\t// 3 or four + 6 axial bevels + 4 or 3 * 4 edge bevels\n\tint\t\t\tborderPlanes[4+6+16];\n\tint\t\t\tborderInward[4+6+16];\n\tqboolean\tborderNoAdjust[4+6+16];\n} facet_t;\n\ntypedef struct patchCollide_s {\n\tvec3_t\tbounds[2];\n\tint\t\tnumPlanes;\t\t\t// surface planes plus edge planes\n\tpatchPlane_t\t*planes;\n\tint\t\tnumFacets;\n\tfacet_t\t*facets;\n} patchCollide_t;\n\n\n#define\tMAX_GRID_SIZE\t129\n\ntypedef struct {\n\tint\t\t\twidth;\n\tint\t\t\theight;\n\tqboolean\twrapWidth;\n\tqboolean\twrapHeight;\n\tvec3_t\tpoints[MAX_GRID_SIZE][MAX_GRID_SIZE];\t// [width][height]\n} cGrid_t;\n\n#define\tSUBDIVIDE_DISTANCE\t16\t//4\t// never more than this units away from curve\n#define\tPLANE_TRI_EPSILON\t0.1\n#define\tWRAP_POINT_EPSILON\t0.1\n*/\n\nint\tc_totalPatchBlocks;\nint\tc_totalPatchSurfaces;\nint\tc_totalPatchEdges;\n\nstatic const patchCollide_t\t*debugPatchCollide;\nstatic const facet_t\t\t*debugFacet;\nstatic qboolean\t\tdebugBlock;\nstatic vec3_t\t\tdebugBlockPoints[4];\n\n/*\n=================\nCM_ClearLevelPatches\n=================\n*/\nvoid CM_ClearLevelPatches( void ) {\n\tdebugPatchCollide = NULL;\n\tdebugFacet = NULL;\n}\n\n/*\n=================\nCM_SignbitsForNormal\n=================\n*/\nstatic int CM_SignbitsForNormal( vec3_t normal ) {\n\tint\tbits, j;\n\n\tbits = 0;\n\tfor (j=0 ; j<3 ; j++) {\n\t\tif ( normal[j] < 0 ) {\n\t\t\tbits |= 1<<j;\n\t\t}\n\t}\n\treturn bits;\n}\n\n/*\n=====================\nCM_PlaneFromPoints\n\nReturns false if the triangle is degenrate.\nThe normal will point out of the clock for clockwise ordered points\n=====================\n*/\nstatic qboolean CM_PlaneFromPoints( vec4_t plane, vec3_t a, vec3_t b, vec3_t c ) {\n\tvec3_t\td1, d2;\n\n\tVectorSubtract( b, a, d1 );\n\tVectorSubtract( c, a, d2 );\n\tCrossProduct( d2, d1, plane );\n\tif ( VectorNormalize( plane ) == 0 ) {\n\t\treturn qfalse;\n\t}\n\n\tplane[3] = DotProduct( a, plane );\n\treturn qtrue;\n}\n\n\n/*\n================================================================================\n\nGRID SUBDIVISION\n\n================================================================================\n*/\n\n/*\n=================\nCM_NeedsSubdivision\n\nReturns true if the given quadratic curve is not flat enough for our\ncollision detection purposes\n=================\n*/\nstatic qboolean\tCM_NeedsSubdivision( vec3_t a, vec3_t b, vec3_t c ) {\n\tvec3_t\t\tcmid;\n\tvec3_t\t\tlmid;\n\tvec3_t\t\tdelta;\n\tfloat\t\tdist;\n\tint\t\t\ti;\n\n\t// calculate the linear midpoint\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tlmid[i] = 0.5*(a[i] + c[i]);\n\t}\n\n\t// calculate the exact curve midpoint\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tcmid[i] = 0.5 * ( 0.5*(a[i] + b[i]) + 0.5*(b[i] + c[i]) );\n\t}\n\n\t// see if the curve is far enough away from the linear mid\n\tVectorSubtract( cmid, lmid, delta );\n\tdist = VectorLength( delta );\n\t\n\treturn dist >= SUBDIVIDE_DISTANCE;\n}\n\n/*\n===============\nCM_Subdivide\n\na, b, and c are control points.\nthe subdivided sequence will be: a, out1, out2, out3, c\n===============\n*/\nstatic void CM_Subdivide( vec3_t a, vec3_t b, vec3_t c, vec3_t out1, vec3_t out2, vec3_t out3 ) {\n\tint\t\ti;\n\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tout1[i] = 0.5 * (a[i] + b[i]);\n\t\tout3[i] = 0.5 * (b[i] + c[i]);\n\t\tout2[i] = 0.5 * (out1[i] + out3[i]);\n\t}\n}\n\n/*\n=================\nCM_TransposeGrid\n\nSwaps the rows and columns in place\n=================\n*/\nstatic void CM_TransposeGrid( cGrid_t *grid ) {\n\tint\t\t\ti, j, l;\n\tvec3_t\t\ttemp;\n\tqboolean\ttempWrap;\n\n\tif ( grid->width > grid->height ) {\n\t\tfor ( i = 0 ; i < grid->height ; i++ ) {\n\t\t\tfor ( j = i + 1 ; j < grid->width ; j++ ) {\n\t\t\t\tif ( j < grid->height ) {\n\t\t\t\t\t// swap the value\n\t\t\t\t\tVectorCopy( grid->points[i][j], temp );\n\t\t\t\t\tVectorCopy( grid->points[j][i], grid->points[i][j] );\n\t\t\t\t\tVectorCopy( temp, grid->points[j][i] );\n\t\t\t\t} else {\n\t\t\t\t\t// just copy\n\t\t\t\t\tVectorCopy( grid->points[j][i], grid->points[i][j] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor ( i = 0 ; i < grid->width ; i++ ) {\n\t\t\tfor ( j = i + 1 ; j < grid->height ; j++ ) {\n\t\t\t\tif ( j < grid->width ) {\n\t\t\t\t\t// swap the value\n\t\t\t\t\tVectorCopy( grid->points[j][i], temp );\n\t\t\t\t\tVectorCopy( grid->points[i][j], grid->points[j][i] );\n\t\t\t\t\tVectorCopy( temp, grid->points[i][j] );\n\t\t\t\t} else {\n\t\t\t\t\t// just copy\n\t\t\t\t\tVectorCopy( grid->points[i][j], grid->points[j][i] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tl = grid->width;\n\tgrid->width = grid->height;\n\tgrid->height = l;\n\n\ttempWrap = grid->wrapWidth;\n\tgrid->wrapWidth = grid->wrapHeight;\n\tgrid->wrapHeight = tempWrap;\n}\n\n/*\n===================\nCM_SetGridWrapWidth\n\nIf the left and right columns are exactly equal, set grid->wrapWidth qtrue\n===================\n*/\nstatic void CM_SetGridWrapWidth( cGrid_t *grid ) {\n\tint\t\ti, j;\n\tfloat\td;\n\n\tfor ( i = 0 ; i < grid->height ; i++ ) {\n\t\tfor ( j = 0 ; j < 3 ; j++ ) {\n\t\t\td = grid->points[0][i][j] - grid->points[grid->width-1][i][j];\n\t\t\tif ( d < -WRAP_POINT_EPSILON || d > WRAP_POINT_EPSILON ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif ( j != 3 ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif ( i == grid->height ) {\n\t\tgrid->wrapWidth = qtrue;\n\t} else {\n\t\tgrid->wrapWidth = qfalse;\n\t}\n}\n\n/*\n=================\nCM_SubdivideGridColumns\n\nAdds columns as necessary to the grid until\nall the aproximating points are within SUBDIVIDE_DISTANCE\nfrom the true curve\n=================\n*/\nstatic void CM_SubdivideGridColumns( cGrid_t *grid ) {\n\tint\t\ti, j, k;\n\n\tfor ( i = 0 ; i < grid->width - 2 ;  ) {\n\t\t// grid->points[i][x] is an interpolating control point\n\t\t// grid->points[i+1][x] is an aproximating control point\n\t\t// grid->points[i+2][x] is an interpolating control point\n\n\t\t//\n\t\t// first see if we can collapse the aproximating collumn away\n\t\t//\n\t\tfor ( j = 0 ; j < grid->height ; j++ ) {\n\t\t\tif ( CM_NeedsSubdivision( grid->points[i][j], grid->points[i+1][j], grid->points[i+2][j] ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif ( j == grid->height ) {\n\t\t\t// all of the points were close enough to the linear midpoints\n\t\t\t// that we can collapse the entire column away\n\t\t\tfor ( j = 0 ; j < grid->height ; j++ ) {\n\t\t\t\t// remove the column\n\t\t\t\tfor ( k = i + 2 ; k < grid->width ; k++ ) {\n\t\t\t\t\tVectorCopy( grid->points[k][j], grid->points[k-1][j] );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tgrid->width--;\n\n\t\t\t// go to the next curve segment\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\n\t\t//\n\t\t// we need to subdivide the curve\n\t\t//\n\t\tfor ( j = 0 ; j < grid->height ; j++ ) {\n\t\t\tvec3_t\tprev, mid, next;\n\n\t\t\t// save the control points now\n\t\t\tVectorCopy( grid->points[i][j], prev );\n\t\t\tVectorCopy( grid->points[i+1][j], mid );\n\t\t\tVectorCopy( grid->points[i+2][j], next );\n\n\t\t\t// make room for two additional columns in the grid\n\t\t\t// columns i+1 will be replaced, column i+2 will become i+4\n\t\t\t// i+1, i+2, and i+3 will be generated\n\t\t\tfor ( k = grid->width - 1 ; k > i + 1 ; k-- ) {\n\t\t\t\tVectorCopy( grid->points[k][j], grid->points[k+2][j] );\n\t\t\t}\n\n\t\t\t// generate the subdivided points\n\t\t\tCM_Subdivide( prev, mid, next, grid->points[i+1][j], grid->points[i+2][j], grid->points[i+3][j] );\n\t\t}\n\n\t\tgrid->width += 2;\n\n\t\t// the new aproximating point at i+1 may need to be removed\n\t\t// or subdivided farther, so don't advance i\n\t}\n}\n\n/*\n======================\nCM_ComparePoints\n======================\n*/\n#define\tPOINT_EPSILON\t0.1\nstatic qboolean CM_ComparePoints( float *a, float *b ) {\n\tfloat\t\td;\n\n\td = a[0] - b[0];\n\tif ( d < -POINT_EPSILON || d > POINT_EPSILON ) {\n\t\treturn qfalse;\n\t}\n\td = a[1] - b[1];\n\tif ( d < -POINT_EPSILON || d > POINT_EPSILON ) {\n\t\treturn qfalse;\n\t}\n\td = a[2] - b[2];\n\tif ( d < -POINT_EPSILON || d > POINT_EPSILON ) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n/*\n=================\nCM_RemoveDegenerateColumns\n\nIf there are any identical columns, remove them\n=================\n*/\nstatic void CM_RemoveDegenerateColumns( cGrid_t *grid ) {\n\tint\t\ti, j, k;\n\n\tfor ( i = 0 ; i < grid->width - 1 ; i++ ) {\n\t\tfor ( j = 0 ; j < grid->height ; j++ ) {\n\t\t\tif ( !CM_ComparePoints( grid->points[i][j], grid->points[i+1][j] ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif ( j != grid->height ) {\n\t\t\tcontinue;\t// not degenerate\n\t\t}\n\n\t\tfor ( j = 0 ; j < grid->height ; j++ ) {\n\t\t\t// remove the column\n\t\t\tfor ( k = i + 2 ; k < grid->width ; k++ ) {\n\t\t\t\tVectorCopy( grid->points[k][j], grid->points[k-1][j] );\n\t\t\t}\n\t\t}\n\t\tgrid->width--;\n\n\t\t// check against the next column\n\t\ti--;\n\t}\n}\n\n/*\n================================================================================\n\nPATCH COLLIDE GENERATION\n\n================================================================================\n*/\n\nstatic\tint\t\t\t\tnumPlanes;\nstatic\tpatchPlane_t\tplanes[MAX_PATCH_PLANES];\n\nstatic\tint\t\t\t\tnumFacets;\nstatic\tfacet_t\t\t\tfacets[MAX_PATCH_PLANES]; //maybe MAX_FACETS ??\n\n#define\tNORMAL_EPSILON\t0.0001\n#define\tDIST_EPSILON\t0.02\n\n/*\n==================\nCM_PlaneEqual\n==================\n*/\nint CM_PlaneEqual(patchPlane_t *p, float plane[4], int *flipped) {\n\tfloat invplane[4];\n\n\tif (\n\t   fabs(p->plane[0] - plane[0]) < NORMAL_EPSILON\n\t&& fabs(p->plane[1] - plane[1]) < NORMAL_EPSILON\n\t&& fabs(p->plane[2] - plane[2]) < NORMAL_EPSILON\n\t&& fabs(p->plane[3] - plane[3]) < DIST_EPSILON )\n\t{\n\t\t*flipped = qfalse;\n\t\treturn qtrue;\n\t}\n\n\tVectorNegate(plane, invplane);\n\tinvplane[3] = -plane[3];\n\n\tif (\n\t   fabs(p->plane[0] - invplane[0]) < NORMAL_EPSILON\n\t&& fabs(p->plane[1] - invplane[1]) < NORMAL_EPSILON\n\t&& fabs(p->plane[2] - invplane[2]) < NORMAL_EPSILON\n\t&& fabs(p->plane[3] - invplane[3]) < DIST_EPSILON )\n\t{\n\t\t*flipped = qtrue;\n\t\treturn qtrue;\n\t}\n\n\treturn qfalse;\n}\n\n/*\n==================\nCM_SnapVector\n==================\n*/\nvoid CM_SnapVector(vec3_t normal) {\n\tint\t\ti;\n\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tif ( fabs(normal[i] - 1) < NORMAL_EPSILON )\n\t\t{\n\t\t\tVectorClear (normal);\n\t\t\tnormal[i] = 1;\n\t\t\tbreak;\n\t\t}\n\t\tif ( fabs(normal[i] - -1) < NORMAL_EPSILON )\n\t\t{\n\t\t\tVectorClear (normal);\n\t\t\tnormal[i] = -1;\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/*\n==================\nCM_FindPlane2\n==================\n*/\nint CM_FindPlane2(float plane[4], int *flipped) {\n\tint i;\n\n\t// see if the points are close enough to an existing plane\n\tfor ( i = 0 ; i < numPlanes ; i++ ) {\n\t\tif (CM_PlaneEqual(&planes[i], plane, flipped)) return i;\n\t}\n\n\t// add a new plane\n\tif ( numPlanes == MAX_PATCH_PLANES ) {\n\t\tCom_Error( ERR_DROP, \"MAX_PATCH_PLANES\" );\n\t}\n\n\tVector4Copy( plane, planes[numPlanes].plane );\n\tplanes[numPlanes].signbits = CM_SignbitsForNormal( plane );\n\n\tnumPlanes++;\n\n\t*flipped = qfalse;\n\n\treturn numPlanes-1;\n}\n\n/*\n==================\nCM_FindPlane\n==================\n*/\nstatic int CM_FindPlane( float *p1, float *p2, float *p3 ) {\n\tfloat\tplane[4];\n\tint\t\ti;\n\tfloat\td;\n\n\tif ( !CM_PlaneFromPoints( plane, p1, p2, p3 ) ) {\n\t\treturn -1;\n\t}\n\n\t// see if the points are close enough to an existing plane\n\tfor ( i = 0 ; i < numPlanes ; i++ ) {\n\t\tif ( DotProduct( plane, planes[i].plane ) < 0 ) {\n\t\t\tcontinue;\t// allow backwards planes?\n\t\t}\n\n\t\td = DotProduct( p1, planes[i].plane ) - planes[i].plane[3];\n\t\tif ( d < -PLANE_TRI_EPSILON || d > PLANE_TRI_EPSILON ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\td = DotProduct( p2, planes[i].plane ) - planes[i].plane[3];\n\t\tif ( d < -PLANE_TRI_EPSILON || d > PLANE_TRI_EPSILON ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\td = DotProduct( p3, planes[i].plane ) - planes[i].plane[3];\n\t\tif ( d < -PLANE_TRI_EPSILON || d > PLANE_TRI_EPSILON ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// found it\n\t\treturn i;\n\t}\n\n\t// add a new plane\n\tif ( numPlanes == MAX_PATCH_PLANES ) {\n\t\tCom_Error( ERR_DROP, \"MAX_PATCH_PLANES\" );\n\t}\n\n\tVector4Copy( plane, planes[numPlanes].plane );\n\tplanes[numPlanes].signbits = CM_SignbitsForNormal( plane );\n\n\tnumPlanes++;\n\n\treturn numPlanes-1;\n}\n\n/*\n==================\nCM_PointOnPlaneSide\n==================\n*/\nstatic int CM_PointOnPlaneSide( float *p, int planeNum ) {\n\tfloat\t*plane;\n\tfloat\td;\n\n\tif ( planeNum == -1 ) {\n\t\treturn SIDE_ON;\n\t}\n\tplane = planes[ planeNum ].plane;\n\n\td = DotProduct( p, plane ) - plane[3];\n\n\tif ( d > PLANE_TRI_EPSILON ) {\n\t\treturn SIDE_FRONT;\n\t}\n\n\tif ( d < -PLANE_TRI_EPSILON ) {\n\t\treturn SIDE_BACK;\n\t}\n\n\treturn SIDE_ON;\n}\n\n/*\n==================\nCM_GridPlane\n==================\n*/\nstatic int\tCM_GridPlane( int gridPlanes[MAX_GRID_SIZE][MAX_GRID_SIZE][2], int i, int j, int tri ) {\n\tint\t\tp;\n\n\tp = gridPlanes[i][j][tri];\n\tif ( p != -1 ) {\n\t\treturn p;\n\t}\n\tp = gridPlanes[i][j][!tri];\n\tif ( p != -1 ) {\n\t\treturn p;\n\t}\n\n\t// should never happen\n\tCom_Printf( \"WARNING: CM_GridPlane unresolvable\\n\" );\n\treturn -1;\n}\n\n/*\n==================\nCM_EdgePlaneNum\n==================\n*/\nstatic int CM_EdgePlaneNum( cGrid_t *grid, int gridPlanes[MAX_GRID_SIZE][MAX_GRID_SIZE][2], int i, int j, int k ) {\n\tfloat\t*p1, *p2;\n\tvec3_t\t\tup;\n\tint\t\t\tp;\n\n\tswitch ( k ) {\n\tcase 0:\t// top border\n\t\tp1 = grid->points[i][j];\n\t\tp2 = grid->points[i+1][j];\n\t\tp = CM_GridPlane( gridPlanes, i, j, 0 );\n\t\tVectorMA( p1, 4, planes[ p ].plane, up );\n\t\treturn CM_FindPlane( p1, p2, up );\n\n\tcase 2:\t// bottom border\n\t\tp1 = grid->points[i][j+1];\n\t\tp2 = grid->points[i+1][j+1];\n\t\tp = CM_GridPlane( gridPlanes, i, j, 1 );\n\t\tVectorMA( p1, 4, planes[ p ].plane, up );\n\t\treturn CM_FindPlane( p2, p1, up );\n\n\tcase 3: // left border\n\t\tp1 = grid->points[i][j];\n\t\tp2 = grid->points[i][j+1];\n\t\tp = CM_GridPlane( gridPlanes, i, j, 1 );\n\t\tVectorMA( p1, 4, planes[ p ].plane, up );\n\t\treturn CM_FindPlane( p2, p1, up );\n\n\tcase 1:\t// right border\n\t\tp1 = grid->points[i+1][j];\n\t\tp2 = grid->points[i+1][j+1];\n\t\tp = CM_GridPlane( gridPlanes, i, j, 0 );\n\t\tVectorMA( p1, 4, planes[ p ].plane, up );\n\t\treturn CM_FindPlane( p1, p2, up );\n\n\tcase 4:\t// diagonal out of triangle 0\n\t\tp1 = grid->points[i+1][j+1];\n\t\tp2 = grid->points[i][j];\n\t\tp = CM_GridPlane( gridPlanes, i, j, 0 );\n\t\tVectorMA( p1, 4, planes[ p ].plane, up );\n\t\treturn CM_FindPlane( p1, p2, up );\n\n\tcase 5:\t// diagonal out of triangle 1\n\t\tp1 = grid->points[i][j];\n\t\tp2 = grid->points[i+1][j+1];\n\t\tp = CM_GridPlane( gridPlanes, i, j, 1 );\n\t\tVectorMA( p1, 4, planes[ p ].plane, up );\n\t\treturn CM_FindPlane( p1, p2, up );\n\n\t}\n\n\tCom_Error( ERR_DROP, \"CM_EdgePlaneNum: bad k\" );\n\treturn -1;\n}\n\n/*\n===================\nCM_SetBorderInward\n===================\n*/\nstatic void CM_SetBorderInward( facet_t *facet, cGrid_t *grid, int gridPlanes[MAX_GRID_SIZE][MAX_GRID_SIZE][2],\n\t\t\t\t\t\t  int i, int j, int which ) {\n\tint\t\tk, l;\n\tfloat\t*points[4];\n\tint\t\tnumPoints;\n\n\tswitch ( which ) {\n\tcase -1:\n\t\tpoints[0] = grid->points[i][j];\n\t\tpoints[1] = grid->points[i+1][j];\n\t\tpoints[2] = grid->points[i+1][j+1];\n\t\tpoints[3] = grid->points[i][j+1];\n\t\tnumPoints = 4;\n\t\tbreak;\n\tcase 0:\n\t\tpoints[0] = grid->points[i][j];\n\t\tpoints[1] = grid->points[i+1][j];\n\t\tpoints[2] = grid->points[i+1][j+1];\n\t\tnumPoints = 3;\n\t\tbreak;\n\tcase 1:\n\t\tpoints[0] = grid->points[i+1][j+1];\n\t\tpoints[1] = grid->points[i][j+1];\n\t\tpoints[2] = grid->points[i][j];\n\t\tnumPoints = 3;\n\t\tbreak;\n\tdefault:\n\t\tCom_Error( ERR_FATAL, \"CM_SetBorderInward: bad parameter\" );\n\t\tnumPoints = 0;\n\t\tbreak;\n\t}\n\n\tfor ( k = 0 ; k < facet->numBorders ; k++ ) {\n\t\tint\t\tfront, back;\n\n\t\tfront = 0;\n\t\tback = 0;\n\n\t\tfor ( l = 0 ; l < numPoints ; l++ ) {\n\t\t\tint\t\tside;\n\n\t\t\tside = CM_PointOnPlaneSide( points[l], facet->borderPlanes[k] );\n\t\t\tif ( side == SIDE_FRONT ) {\n\t\t\t\tfront++;\n\t\t\t} if ( side == SIDE_BACK ) {\n\t\t\t\tback++;\n\t\t\t}\n\t\t}\n\n\t\tif ( front && !back ) {\n\t\t\tfacet->borderInward[k] = qtrue;\n\t\t} else if ( back && !front ) {\n\t\t\tfacet->borderInward[k] = qfalse;\n\t\t} else if ( !front && !back ) {\n\t\t\t// flat side border\n\t\t\tfacet->borderPlanes[k] = -1;\n\t\t} else {\n\t\t\t// bisecting side border\n\t\t\tCom_DPrintf( \"WARNING: CM_SetBorderInward: mixed plane sides\\n\" );\n\t\t\tfacet->borderInward[k] = qfalse;\n\t\t\tif ( !debugBlock ) {\n\t\t\t\tdebugBlock = qtrue;\n\t\t\t\tVectorCopy( grid->points[i][j], debugBlockPoints[0] );\n\t\t\t\tVectorCopy( grid->points[i+1][j], debugBlockPoints[1] );\n\t\t\t\tVectorCopy( grid->points[i+1][j+1], debugBlockPoints[2] );\n\t\t\t\tVectorCopy( grid->points[i][j+1], debugBlockPoints[3] );\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n==================\nCM_ValidateFacet\n\nIf the facet isn't bounded by its borders, we screwed up.\n==================\n*/\nstatic qboolean CM_ValidateFacet( facet_t *facet ) {\n\tfloat\t\tplane[4];\n\tint\t\t\tj;\n\twinding_t\t*w;\n\tvec3_t\t\tbounds[2];\n\n\tif ( facet->surfacePlane == -1 ) {\n\t\treturn qfalse;\n\t}\n\n\tVector4Copy( planes[ facet->surfacePlane ].plane, plane );\n\tw = BaseWindingForPlane( plane,  plane[3] );\n\tfor ( j = 0 ; j < facet->numBorders && w ; j++ ) {\n\t\tif ( facet->borderPlanes[j] == -1 ) {\n\t\t\treturn qfalse;\n\t\t}\n\t\tVector4Copy( planes[ facet->borderPlanes[j] ].plane, plane );\n\t\tif ( !facet->borderInward[j] ) {\n\t\t\tVectorSubtract( vec3_origin, plane, plane );\n\t\t\tplane[3] = -plane[3];\n\t\t}\n\t\tChopWindingInPlace( &w, plane, plane[3], 0.1f );\n\t}\n\n\tif ( !w ) {\n\t\treturn qfalse;\t\t// winding was completely chopped away\n\t}\n\n\t// see if the facet is unreasonably large\n\tWindingBounds( w, bounds[0], bounds[1] );\n\tFreeWinding( w );\n\t\n\tfor ( j = 0 ; j < 3 ; j++ ) {\n\t\tif ( bounds[1][j] - bounds[0][j] > MAX_MAP_BOUNDS ) {\n\t\t\treturn qfalse;\t\t// we must be missing a plane\n\t\t}\n\t\tif ( bounds[0][j] >= MAX_MAP_BOUNDS ) {\n\t\t\treturn qfalse;\n\t\t}\n\t\tif ( bounds[1][j] <= -MAX_MAP_BOUNDS ) {\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\treturn qtrue;\t\t// winding is fine\n}\n\n/*\n==================\nCM_AddFacetBevels\n==================\n*/\nvoid CM_AddFacetBevels( facet_t *facet ) {\n\n\tint i, j, k, l;\n\tint axis, dir, order, flipped;\n\tfloat plane[4], d, newplane[4];\n\twinding_t *w, *w2;\n\tvec3_t mins, maxs, vec, vec2;\n\n\tVector4Copy( planes[ facet->surfacePlane ].plane, plane );\n\n\tw = BaseWindingForPlane( plane,  plane[3] );\n\tfor ( j = 0 ; j < facet->numBorders && w ; j++ ) {\n\t\tif (facet->borderPlanes[j] == facet->surfacePlane) continue;\n\t\tVector4Copy( planes[ facet->borderPlanes[j] ].plane, plane );\n\n\t\tif ( !facet->borderInward[j] ) {\n\t\t\tVectorSubtract( vec3_origin, plane, plane );\n\t\t\tplane[3] = -plane[3];\n\t\t}\n\n\t\tChopWindingInPlace( &w, plane, plane[3], 0.1f );\n\t}\n\tif ( !w ) {\n\t\treturn;\n\t}\n\n\tWindingBounds(w, mins, maxs);\n\n\t// add the axial planes\n\torder = 0;\n\tfor ( axis = 0 ; axis < 3 ; axis++ )\n\t{\n\t\tfor ( dir = -1 ; dir <= 1 ; dir += 2, order++ )\n\t\t{\n\t\t\tVectorClear(plane);\n\t\t\tplane[axis] = dir;\n\t\t\tif (dir == 1) {\n\t\t\t\tplane[3] = maxs[axis];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tplane[3] = -mins[axis];\n\t\t\t}\n\t\t\t//if it's the surface plane\n\t\t\tif (CM_PlaneEqual(&planes[facet->surfacePlane], plane, &flipped)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// see if the plane is allready present\n\t\t\tfor ( i = 0 ; i < facet->numBorders ; i++ ) {\n\t\t\t\tif (CM_PlaneEqual(&planes[facet->borderPlanes[i]], plane, &flipped))\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif ( i == facet->numBorders ) {\n\t\t\t\tif (facet->numBorders > 4 + 6 + 16) Com_Printf(\"ERROR: too many bevels\\n\");\n\t\t\t\tfacet->borderPlanes[facet->numBorders] = CM_FindPlane2(plane, &flipped);\n\t\t\t\tfacet->borderNoAdjust[facet->numBorders] = 0;\n\t\t\t\tfacet->borderInward[facet->numBorders] = flipped;\n\t\t\t\tfacet->numBorders++;\n\t\t\t}\n\t\t}\n\t}\n\t//\n\t// add the edge bevels\n\t//\n\t// test the non-axial plane edges\n\tfor ( j = 0 ; j < w->numpoints ; j++ )\n\t{\n\t\tk = (j+1)%w->numpoints;\n\t\tVectorSubtract (w->p[j], w->p[k], vec);\n\t\t//if it's a degenerate edge\n\t\tif (VectorNormalize (vec) < 0.5)\n\t\t\tcontinue;\n\t\tCM_SnapVector(vec);\n\t\tfor ( k = 0; k < 3 ; k++ )\n\t\t\tif ( vec[k] == -1 || vec[k] == 1 )\n\t\t\t\tbreak;\t// axial\n\t\tif ( k < 3 )\n\t\t\tcontinue;\t// only test non-axial edges\n\n\t\t// try the six possible slanted axials from this edge\n\t\tfor ( axis = 0 ; axis < 3 ; axis++ )\n\t\t{\n\t\t\tfor ( dir = -1 ; dir <= 1 ; dir += 2 )\n\t\t\t{\n\t\t\t\t// construct a plane\n\t\t\t\tVectorClear (vec2);\n\t\t\t\tvec2[axis] = dir;\n\t\t\t\tCrossProduct (vec, vec2, plane);\n\t\t\t\tif (VectorNormalize (plane) < 0.5)\n\t\t\t\t\tcontinue;\n\t\t\t\tplane[3] = DotProduct (w->p[j], plane);\n\n\t\t\t\t// if all the points of the facet winding are\n\t\t\t\t// behind this plane, it is a proper edge bevel\n\t\t\t\tfor ( l = 0 ; l < w->numpoints ; l++ )\n\t\t\t\t{\n\t\t\t\t\td = DotProduct (w->p[l], plane) - plane[3];\n\t\t\t\t\tif (d > 0.1)\n\t\t\t\t\t\tbreak;\t// point in front\n\t\t\t\t}\n\t\t\t\tif ( l < w->numpoints )\n\t\t\t\t\tcontinue;\n\n\t\t\t\t//if it's the surface plane\n\t\t\t\tif (CM_PlaneEqual(&planes[facet->surfacePlane], plane, &flipped)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// see if the plane is allready present\n\t\t\t\tfor ( i = 0 ; i < facet->numBorders ; i++ ) {\n\t\t\t\t\tif (CM_PlaneEqual(&planes[facet->borderPlanes[i]], plane, &flipped)) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( i == facet->numBorders ) {\n\t\t\t\t\tif (facet->numBorders > 4 + 6 + 16) Com_Printf(\"ERROR: too many bevels\\n\");\n\t\t\t\t\tfacet->borderPlanes[facet->numBorders] = CM_FindPlane2(plane, &flipped);\n\n\t\t\t\t\tfor ( k = 0 ; k < facet->numBorders ; k++ ) {\n\t\t\t\t\t\tif (facet->borderPlanes[facet->numBorders] ==\n\t\t\t\t\t\t\tfacet->borderPlanes[k]) Com_Printf(\"WARNING: bevel plane already used\\n\");\n\t\t\t\t\t}\n\n\t\t\t\t\tfacet->borderNoAdjust[facet->numBorders] = 0;\n\t\t\t\t\tfacet->borderInward[facet->numBorders] = flipped;\n\t\t\t\t\t//\n\t\t\t\t\tw2 = CopyWinding(w);\n\t\t\t\t\tVector4Copy(planes[facet->borderPlanes[facet->numBorders]].plane, newplane);\n\t\t\t\t\tif (!facet->borderInward[facet->numBorders])\n\t\t\t\t\t{\n\t\t\t\t\t\tVectorNegate(newplane, newplane);\n\t\t\t\t\t\tnewplane[3] = -newplane[3];\n\t\t\t\t\t} //end if\n\t\t\t\t\tChopWindingInPlace( &w2, newplane, newplane[3], 0.1f );\n\t\t\t\t\tif (!w2) {\n\t\t\t\t\t\tCom_DPrintf(\"WARNING: CM_AddFacetBevels... invalid bevel\\n\");\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tFreeWinding(w2);\n\t\t\t\t\t}\n\t\t\t\t\t//\n\t\t\t\t\tfacet->numBorders++;\n\t\t\t\t\t//already got a bevel\n//\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tFreeWinding( w );\n\n#ifndef BSPC\n\t//add opposite plane\n\tfacet->borderPlanes[facet->numBorders] = facet->surfacePlane;\n\tfacet->borderNoAdjust[facet->numBorders] = 0;\n\tfacet->borderInward[facet->numBorders] = qtrue;\n\tfacet->numBorders++;\n#endif //BSPC\n\n}\n\ntypedef enum {\n\tEN_TOP,\n\tEN_RIGHT,\n\tEN_BOTTOM,\n\tEN_LEFT\n} edgeName_t;\n\n/*\n==================\nCM_PatchCollideFromGrid\n==================\n*/\nstatic void CM_PatchCollideFromGrid( cGrid_t *grid, patchCollide_t *pf ) {\n\tint\t\t\t\ti, j;\n\tfloat\t\t\t*p1, *p2, *p3;\n\tMAC_STATIC int\t\t\t\tgridPlanes[MAX_GRID_SIZE][MAX_GRID_SIZE][2];\n\tfacet_t\t\t\t*facet;\n\tint\t\t\t\tborders[4];\n\tint\t\t\t\tnoAdjust[4];\n\n\tnumPlanes = 0;\n\tnumFacets = 0;\n\n\t// find the planes for each triangle of the grid\n\tfor ( i = 0 ; i < grid->width - 1 ; i++ ) {\n\t\tfor ( j = 0 ; j < grid->height - 1 ; j++ ) {\n\t\t\tp1 = grid->points[i][j];\n\t\t\tp2 = grid->points[i+1][j];\n\t\t\tp3 = grid->points[i+1][j+1];\n\t\t\tgridPlanes[i][j][0] = CM_FindPlane( p1, p2, p3 );\n\n\t\t\tp1 = grid->points[i+1][j+1];\n\t\t\tp2 = grid->points[i][j+1];\n\t\t\tp3 = grid->points[i][j];\n\t\t\tgridPlanes[i][j][1] = CM_FindPlane( p1, p2, p3 );\n\t\t}\n\t}\n\n\t// create the borders for each facet\n\tfor ( i = 0 ; i < grid->width - 1 ; i++ ) {\n\t\tfor ( j = 0 ; j < grid->height - 1 ; j++ ) {\n\t\t\t \n\t\t\tborders[EN_TOP] = -1;\n\t\t\tif ( j > 0 ) {\n\t\t\t\tborders[EN_TOP] = gridPlanes[i][j-1][1];\n\t\t\t} else if ( grid->wrapHeight ) {\n\t\t\t\tborders[EN_TOP] = gridPlanes[i][grid->height-2][1];\n\t\t\t} \n\t\t\tnoAdjust[EN_TOP] = ( borders[EN_TOP] == gridPlanes[i][j][0] );\n\t\t\tif ( borders[EN_TOP] == -1 || noAdjust[EN_TOP] ) {\n\t\t\t\tborders[EN_TOP] = CM_EdgePlaneNum( grid, gridPlanes, i, j, 0 );\n\t\t\t}\n\n\t\t\tborders[EN_BOTTOM] = -1;\n\t\t\tif ( j < grid->height - 2 ) {\n\t\t\t\tborders[EN_BOTTOM] = gridPlanes[i][j+1][0];\n\t\t\t} else if ( grid->wrapHeight ) {\n\t\t\t\tborders[EN_BOTTOM] = gridPlanes[i][0][0];\n\t\t\t}\n\t\t\tnoAdjust[EN_BOTTOM] = ( borders[EN_BOTTOM] == gridPlanes[i][j][1] );\n\t\t\tif ( borders[EN_BOTTOM] == -1 || noAdjust[EN_BOTTOM] ) {\n\t\t\t\tborders[EN_BOTTOM] = CM_EdgePlaneNum( grid, gridPlanes, i, j, 2 );\n\t\t\t}\n\n\t\t\tborders[EN_LEFT] = -1;\n\t\t\tif ( i > 0 ) {\n\t\t\t\tborders[EN_LEFT] = gridPlanes[i-1][j][0];\n\t\t\t} else if ( grid->wrapWidth ) {\n\t\t\t\tborders[EN_LEFT] = gridPlanes[grid->width-2][j][0];\n\t\t\t}\n\t\t\tnoAdjust[EN_LEFT] = ( borders[EN_LEFT] == gridPlanes[i][j][1] );\n\t\t\tif ( borders[EN_LEFT] == -1 || noAdjust[EN_LEFT] ) {\n\t\t\t\tborders[EN_LEFT] = CM_EdgePlaneNum( grid, gridPlanes, i, j, 3 );\n\t\t\t}\n\n\t\t\tborders[EN_RIGHT] = -1;\n\t\t\tif ( i < grid->width - 2 ) {\n\t\t\t\tborders[EN_RIGHT] = gridPlanes[i+1][j][1];\n\t\t\t} else if ( grid->wrapWidth ) {\n\t\t\t\tborders[EN_RIGHT] = gridPlanes[0][j][1];\n\t\t\t}\n\t\t\tnoAdjust[EN_RIGHT] = ( borders[EN_RIGHT] == gridPlanes[i][j][0] );\n\t\t\tif ( borders[EN_RIGHT] == -1 || noAdjust[EN_RIGHT] ) {\n\t\t\t\tborders[EN_RIGHT] = CM_EdgePlaneNum( grid, gridPlanes, i, j, 1 );\n\t\t\t}\n\n\t\t\tif ( numFacets == MAX_FACETS ) {\n\t\t\t\tCom_Error( ERR_DROP, \"MAX_FACETS\" );\n\t\t\t}\n\t\t\tfacet = &facets[numFacets];\n\t\t\tCom_Memset( facet, 0, sizeof( *facet ) );\n\n\t\t\tif ( gridPlanes[i][j][0] == gridPlanes[i][j][1] ) {\n\t\t\t\tif ( gridPlanes[i][j][0] == -1 ) {\n\t\t\t\t\tcontinue;\t\t// degenrate\n\t\t\t\t}\n\t\t\t\tfacet->surfacePlane = gridPlanes[i][j][0];\n\t\t\t\tfacet->numBorders = 4;\n\t\t\t\tfacet->borderPlanes[0] = borders[EN_TOP];\n\t\t\t\tfacet->borderNoAdjust[0] = noAdjust[EN_TOP];\n\t\t\t\tfacet->borderPlanes[1] = borders[EN_RIGHT];\n\t\t\t\tfacet->borderNoAdjust[1] = noAdjust[EN_RIGHT];\n\t\t\t\tfacet->borderPlanes[2] = borders[EN_BOTTOM];\n\t\t\t\tfacet->borderNoAdjust[2] = noAdjust[EN_BOTTOM];\n\t\t\t\tfacet->borderPlanes[3] = borders[EN_LEFT];\n\t\t\t\tfacet->borderNoAdjust[3] = noAdjust[EN_LEFT];\n\t\t\t\tCM_SetBorderInward( facet, grid, gridPlanes, i, j, -1 );\n\t\t\t\tif ( CM_ValidateFacet( facet ) ) {\n\t\t\t\t\tCM_AddFacetBevels( facet );\n\t\t\t\t\tnumFacets++;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// two seperate triangles\n\t\t\t\tfacet->surfacePlane = gridPlanes[i][j][0];\n\t\t\t\tfacet->numBorders = 3;\n\t\t\t\tfacet->borderPlanes[0] = borders[EN_TOP];\n\t\t\t\tfacet->borderNoAdjust[0] = noAdjust[EN_TOP];\n\t\t\t\tfacet->borderPlanes[1] = borders[EN_RIGHT];\n\t\t\t\tfacet->borderNoAdjust[1] = noAdjust[EN_RIGHT];\n\t\t\t\tfacet->borderPlanes[2] = gridPlanes[i][j][1];\n\t\t\t\tif ( facet->borderPlanes[2] == -1 ) {\n\t\t\t\t\tfacet->borderPlanes[2] = borders[EN_BOTTOM];\n\t\t\t\t\tif ( facet->borderPlanes[2] == -1 ) {\n\t\t\t\t\t\tfacet->borderPlanes[2] = CM_EdgePlaneNum( grid, gridPlanes, i, j, 4 );\n\t\t\t\t\t}\n\t\t\t\t}\n \t\t\t\tCM_SetBorderInward( facet, grid, gridPlanes, i, j, 0 );\n\t\t\t\tif ( CM_ValidateFacet( facet ) ) {\n\t\t\t\t\tCM_AddFacetBevels( facet );\n\t\t\t\t\tnumFacets++;\n\t\t\t\t}\n\n\t\t\t\tif ( numFacets == MAX_FACETS ) {\n\t\t\t\t\tCom_Error( ERR_DROP, \"MAX_FACETS\" );\n\t\t\t\t}\n\t\t\t\tfacet = &facets[numFacets];\n\t\t\t\tCom_Memset( facet, 0, sizeof( *facet ) );\n\n\t\t\t\tfacet->surfacePlane = gridPlanes[i][j][1];\n\t\t\t\tfacet->numBorders = 3;\n\t\t\t\tfacet->borderPlanes[0] = borders[EN_BOTTOM];\n\t\t\t\tfacet->borderNoAdjust[0] = noAdjust[EN_BOTTOM];\n\t\t\t\tfacet->borderPlanes[1] = borders[EN_LEFT];\n\t\t\t\tfacet->borderNoAdjust[1] = noAdjust[EN_LEFT];\n\t\t\t\tfacet->borderPlanes[2] = gridPlanes[i][j][0];\n\t\t\t\tif ( facet->borderPlanes[2] == -1 ) {\n\t\t\t\t\tfacet->borderPlanes[2] = borders[EN_TOP];\n\t\t\t\t\tif ( facet->borderPlanes[2] == -1 ) {\n\t\t\t\t\t\tfacet->borderPlanes[2] = CM_EdgePlaneNum( grid, gridPlanes, i, j, 5 );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tCM_SetBorderInward( facet, grid, gridPlanes, i, j, 1 );\n\t\t\t\tif ( CM_ValidateFacet( facet ) ) {\n\t\t\t\t\tCM_AddFacetBevels( facet );\n\t\t\t\t\tnumFacets++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// copy the results out\n\tpf->numPlanes = numPlanes;\n\tpf->numFacets = numFacets;\n\tpf->facets = Hunk_Alloc( numFacets * sizeof( *pf->facets ), h_high );\n\tCom_Memcpy( pf->facets, facets, numFacets * sizeof( *pf->facets ) );\n\tpf->planes = Hunk_Alloc( numPlanes * sizeof( *pf->planes ), h_high );\n\tCom_Memcpy( pf->planes, planes, numPlanes * sizeof( *pf->planes ) );\n}\n\n\n/*\n===================\nCM_GeneratePatchCollide\n\nCreates an internal structure that will be used to perform\ncollision detection with a patch mesh.\n\nPoints is packed as concatenated rows.\n===================\n*/\nstruct patchCollide_s\t*CM_GeneratePatchCollide( int width, int height, vec3_t *points ) {\n\tpatchCollide_t\t*pf;\n\tMAC_STATIC cGrid_t\t\t\tgrid;\n\tint\t\t\t\ti, j;\n\n\tif ( width <= 2 || height <= 2 || !points ) {\n\t\tCom_Error( ERR_DROP, \"CM_GeneratePatchFacets: bad parameters: (%i, %i, %p)\",\n\t\t\twidth, height, points );\n\t}\n\n\tif ( !(width & 1) || !(height & 1) ) {\n\t\tCom_Error( ERR_DROP, \"CM_GeneratePatchFacets: even sizes are invalid for quadratic meshes\" );\n\t}\n\n\tif ( width > MAX_GRID_SIZE || height > MAX_GRID_SIZE ) {\n\t\tCom_Error( ERR_DROP, \"CM_GeneratePatchFacets: source is > MAX_GRID_SIZE\" );\n\t}\n\n\t// build a grid\n\tgrid.width = width;\n\tgrid.height = height;\n\tgrid.wrapWidth = qfalse;\n\tgrid.wrapHeight = qfalse;\n\tfor ( i = 0 ; i < width ; i++ ) {\n\t\tfor ( j = 0 ; j < height ; j++ ) {\n\t\t\tVectorCopy( points[j*width + i], grid.points[i][j] );\n\t\t}\n\t}\n\n\t// subdivide the grid\n\tCM_SetGridWrapWidth( &grid );\n\tCM_SubdivideGridColumns( &grid );\n\tCM_RemoveDegenerateColumns( &grid );\n\n\tCM_TransposeGrid( &grid );\n\n\tCM_SetGridWrapWidth( &grid );\n\tCM_SubdivideGridColumns( &grid );\n\tCM_RemoveDegenerateColumns( &grid );\n\n\t// we now have a grid of points exactly on the curve\n\t// the aproximate surface defined by these points will be\n\t// collided against\n\tpf = Hunk_Alloc( sizeof( *pf ), h_high );\n\tClearBounds( pf->bounds[0], pf->bounds[1] );\n\tfor ( i = 0 ; i < grid.width ; i++ ) {\n\t\tfor ( j = 0 ; j < grid.height ; j++ ) {\n\t\t\tAddPointToBounds( grid.points[i][j], pf->bounds[0], pf->bounds[1] );\n\t\t}\n\t}\n\n\tc_totalPatchBlocks += ( grid.width - 1 ) * ( grid.height - 1 );\n\n\t// generate a bsp tree for the surface\n\tCM_PatchCollideFromGrid( &grid, pf );\n\n\t// expand by one unit for epsilon purposes\n\tpf->bounds[0][0] -= 1;\n\tpf->bounds[0][1] -= 1;\n\tpf->bounds[0][2] -= 1;\n\n\tpf->bounds[1][0] += 1;\n\tpf->bounds[1][1] += 1;\n\tpf->bounds[1][2] += 1;\n\n\treturn pf;\n}\n\n/*\n================================================================================\n\nTRACE TESTING\n\n================================================================================\n*/\n\n/*\n====================\nCM_TracePointThroughPatchCollide\n\n  special case for point traces because the patch collide \"brushes\" have no volume\n====================\n*/\nvoid CM_TracePointThroughPatchCollide( traceWork_t *tw, const struct patchCollide_s *pc ) {\n\tqboolean\tfrontFacing[MAX_PATCH_PLANES];\n\tfloat\t\tintersection[MAX_PATCH_PLANES];\n\tfloat\t\tintersect;\n\tconst patchPlane_t\t*planes;\n\tconst facet_t\t*facet;\n\tint\t\t\ti, j, k;\n\tfloat\t\toffset;\n\tfloat\t\td1, d2;\n#ifndef BSPC\n\tstatic cvar_t *cv;\n#endif //BSPC\n\n#ifndef BSPC\n\tif ( !cm_playerCurveClip->integer || !tw->isPoint ) {\n\t\treturn;\n\t}\n#endif\n\n\t// determine the trace's relationship to all planes\n\tplanes = pc->planes;\n\tfor ( i = 0 ; i < pc->numPlanes ; i++, planes++ ) {\n\t\toffset = DotProduct( tw->offsets[ planes->signbits ], planes->plane );\n\t\td1 = DotProduct( tw->start, planes->plane ) - planes->plane[3] + offset;\n\t\td2 = DotProduct( tw->end, planes->plane ) - planes->plane[3] + offset;\n\t\tif ( d1 <= 0 ) {\n\t\t\tfrontFacing[i] = qfalse;\n\t\t} else {\n\t\t\tfrontFacing[i] = qtrue;\n\t\t}\n\t\tif ( d1 == d2 ) {\n\t\t\tintersection[i] = 99999;\n\t\t} else {\n\t\t\tintersection[i] = d1 / ( d1 - d2 );\n\t\t\tif ( intersection[i] <= 0 ) {\n\t\t\t\tintersection[i] = 99999;\n\t\t\t}\n\t\t}\n\t}\n\n\n\t// see if any of the surface planes are intersected\n\tfacet = pc->facets;\n\tfor ( i = 0 ; i < pc->numFacets ; i++, facet++ ) {\n\t\tif ( !frontFacing[facet->surfacePlane] ) {\n\t\t\tcontinue;\n\t\t}\n\t\tintersect = intersection[facet->surfacePlane];\n\t\tif ( intersect < 0 ) {\n\t\t\tcontinue;\t\t// surface is behind the starting point\n\t\t}\n\t\tif ( intersect > tw->trace.fraction ) {\n\t\t\tcontinue;\t\t// already hit something closer\n\t\t}\n\t\tfor ( j = 0 ; j < facet->numBorders ; j++ ) {\n\t\t\tk = facet->borderPlanes[j];\n\t\t\tif ( frontFacing[k] ^ facet->borderInward[j] ) {\n\t\t\t\tif ( intersection[k] > intersect ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( intersection[k] < intersect ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif ( j == facet->numBorders ) {\n\t\t\t// we hit this facet\n#ifndef BSPC\n\t\t\tif (!cv) {\n\t\t\t\tcv = Cvar_Get( \"r_debugSurfaceUpdate\", \"1\", 0 );\n\t\t\t}\n\t\t\tif (cv->integer) {\n\t\t\t\tdebugPatchCollide = pc;\n\t\t\t\tdebugFacet = facet;\n\t\t\t}\n#endif //BSPC\n\t\t\tplanes = &pc->planes[facet->surfacePlane];\n\n\t\t\t// calculate intersection with a slight pushoff\n\t\t\toffset = DotProduct( tw->offsets[ planes->signbits ], planes->plane );\n\t\t\td1 = DotProduct( tw->start, planes->plane ) - planes->plane[3] + offset;\n\t\t\td2 = DotProduct( tw->end, planes->plane ) - planes->plane[3] + offset;\n\t\t\ttw->trace.fraction = ( d1 - SURFACE_CLIP_EPSILON ) / ( d1 - d2 );\n\n\t\t\tif ( tw->trace.fraction < 0 ) {\n\t\t\t\ttw->trace.fraction = 0;\n\t\t\t}\n\n\t\t\tVectorCopy( planes->plane,  tw->trace.plane.normal );\n\t\t\ttw->trace.plane.dist = planes->plane[3];\n\t\t}\n\t}\n}\n\n/*\n====================\nCM_CheckFacetPlane\n====================\n*/\nint CM_CheckFacetPlane(float *plane, vec3_t start, vec3_t end, float *enterFrac, float *leaveFrac, int *hit) {\n\tfloat d1, d2, f;\n\n\t*hit = qfalse;\n\n\td1 = DotProduct( start, plane ) - plane[3];\n\td2 = DotProduct( end, plane ) - plane[3];\n\n\t// if completely in front of face, no intersection with the entire facet\n\tif (d1 > 0 && ( d2 >= SURFACE_CLIP_EPSILON || d2 >= d1 )  ) {\n\t\treturn qfalse;\n\t}\n\n\t// if it doesn't cross the plane, the plane isn't relevent\n\tif (d1 <= 0 && d2 <= 0 ) {\n\t\treturn qtrue;\n\t}\n\n\t// crosses face\n\tif (d1 > d2) {\t// enter\n\t\tf = (d1-SURFACE_CLIP_EPSILON) / (d1-d2);\n\t\tif ( f < 0 ) {\n\t\t\tf = 0;\n\t\t}\n\t\t//always favor previous plane hits and thus also the surface plane hit\n\t\tif (f > *enterFrac) {\n\t\t\t*enterFrac = f;\n\t\t\t*hit = qtrue;\n\t\t}\n\t} else {\t// leave\n\t\tf = (d1+SURFACE_CLIP_EPSILON) / (d1-d2);\n\t\tif ( f > 1 ) {\n\t\t\tf = 1;\n\t\t}\n\t\tif (f < *leaveFrac) {\n\t\t\t*leaveFrac = f;\n\t\t}\n\t}\n\treturn qtrue;\n}\n\n/*\n====================\nCM_TraceThroughPatchCollide\n====================\n*/\nvoid CM_TraceThroughPatchCollide( traceWork_t *tw, const struct patchCollide_s *pc ) {\n\tint i, j, hit, hitnum;\n\tfloat offset, enterFrac, leaveFrac, t;\n\tpatchPlane_t *planes;\n\tfacet_t\t*facet;\n\tfloat plane[4], bestplane[4];\n\tvec3_t startp, endp;\n#ifndef BSPC\n\tstatic cvar_t *cv;\n#endif //BSPC\n\n\tif (tw->isPoint) {\n\t\tCM_TracePointThroughPatchCollide( tw, pc );\n\t\treturn;\n\t}\n\n\tfacet = pc->facets;\n\tfor ( i = 0 ; i < pc->numFacets ; i++, facet++ ) {\n\t\tenterFrac = -1.0;\n\t\tleaveFrac = 1.0;\n\t\thitnum = -1;\n\t\t//\n\t\tplanes = &pc->planes[ facet->surfacePlane ];\n\t\tVectorCopy(planes->plane, plane);\n\t\tplane[3] = planes->plane[3];\n\t\tif ( tw->sphere.use ) {\n\t\t\t// adjust the plane distance apropriately for radius\n\t\t\tplane[3] += tw->sphere.radius;\n\n\t\t\t// find the closest point on the capsule to the plane\n\t\t\tt = DotProduct( plane, tw->sphere.offset );\n\t\t\tif ( t > 0.0f ) {\n\t\t\t\tVectorSubtract( tw->start, tw->sphere.offset, startp );\n\t\t\t\tVectorSubtract( tw->end, tw->sphere.offset, endp );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tVectorAdd( tw->start, tw->sphere.offset, startp );\n\t\t\t\tVectorAdd( tw->end, tw->sphere.offset, endp );\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\toffset = DotProduct( tw->offsets[ planes->signbits ], plane);\n\t\t\tplane[3] -= offset;\n\t\t\tVectorCopy( tw->start, startp );\n\t\t\tVectorCopy( tw->end, endp );\n\t\t}\n\n\t\tif (!CM_CheckFacetPlane(plane, startp, endp, &enterFrac, &leaveFrac, &hit)) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (hit) {\n\t\t\tVector4Copy(plane, bestplane);\n\t\t}\n\n\t\tfor ( j = 0; j < facet->numBorders; j++ ) {\n\t\t\tplanes = &pc->planes[ facet->borderPlanes[j] ];\n\t\t\tif (facet->borderInward[j]) {\n\t\t\t\tVectorNegate(planes->plane, plane);\n\t\t\t\tplane[3] = -planes->plane[3];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tVectorCopy(planes->plane, plane);\n\t\t\t\tplane[3] = planes->plane[3];\n\t\t\t}\n\t\t\tif ( tw->sphere.use ) {\n\t\t\t\t// adjust the plane distance apropriately for radius\n\t\t\t\tplane[3] += tw->sphere.radius;\n\n\t\t\t\t// find the closest point on the capsule to the plane\n\t\t\t\tt = DotProduct( plane, tw->sphere.offset );\n\t\t\t\tif ( t > 0.0f ) {\n\t\t\t\t\tVectorSubtract( tw->start, tw->sphere.offset, startp );\n\t\t\t\t\tVectorSubtract( tw->end, tw->sphere.offset, endp );\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tVectorAdd( tw->start, tw->sphere.offset, startp );\n\t\t\t\t\tVectorAdd( tw->end, tw->sphere.offset, endp );\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// NOTE: this works even though the plane might be flipped because the bbox is centered\n\t\t\t\toffset = DotProduct( tw->offsets[ planes->signbits ], plane);\n\t\t\t\tplane[3] += fabs(offset);\n\t\t\t\tVectorCopy( tw->start, startp );\n\t\t\t\tVectorCopy( tw->end, endp );\n\t\t\t}\n\n\t\t\tif (!CM_CheckFacetPlane(plane, startp, endp, &enterFrac, &leaveFrac, &hit)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (hit) {\n\t\t\t\thitnum = j;\n\t\t\t\tVector4Copy(plane, bestplane);\n\t\t\t}\n\t\t}\n\t\tif (j < facet->numBorders) continue;\n\t\t//never clip against the back side\n\t\tif (hitnum == facet->numBorders - 1) continue;\n\n\t\tif (enterFrac < leaveFrac && enterFrac >= 0) {\n\t\t\tif (enterFrac < tw->trace.fraction) {\n\t\t\t\tif (enterFrac < 0) {\n\t\t\t\t\tenterFrac = 0;\n\t\t\t\t}\n#ifndef BSPC\n\t\t\t\tif (!cv) {\n\t\t\t\t\tcv = Cvar_Get( \"r_debugSurfaceUpdate\", \"1\", 0 );\n\t\t\t\t}\n\t\t\t\tif (cv && cv->integer) {\n\t\t\t\t\tdebugPatchCollide = pc;\n\t\t\t\t\tdebugFacet = facet;\n\t\t\t\t}\n#endif //BSPC\n\n\t\t\t\ttw->trace.fraction = enterFrac;\n\t\t\t\tVectorCopy( bestplane, tw->trace.plane.normal );\n\t\t\t\ttw->trace.plane.dist = bestplane[3];\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n/*\n=======================================================================\n\nPOSITION TEST\n\n=======================================================================\n*/\n\n/*\n====================\nCM_PositionTestInPatchCollide\n====================\n*/\nqboolean CM_PositionTestInPatchCollide( traceWork_t *tw, const struct patchCollide_s *pc ) {\n\tint i, j;\n\tfloat offset, t;\n\tpatchPlane_t *planes;\n\tfacet_t\t*facet;\n\tfloat plane[4];\n\tvec3_t startp;\n\n\tif (tw->isPoint) {\n\t\treturn qfalse;\n\t}\n\t//\n\tfacet = pc->facets;\n\tfor ( i = 0 ; i < pc->numFacets ; i++, facet++ ) {\n\t\tplanes = &pc->planes[ facet->surfacePlane ];\n\t\tVectorCopy(planes->plane, plane);\n\t\tplane[3] = planes->plane[3];\n\t\tif ( tw->sphere.use ) {\n\t\t\t// adjust the plane distance apropriately for radius\n\t\t\tplane[3] += tw->sphere.radius;\n\n\t\t\t// find the closest point on the capsule to the plane\n\t\t\tt = DotProduct( plane, tw->sphere.offset );\n\t\t\tif ( t > 0 ) {\n\t\t\t\tVectorSubtract( tw->start, tw->sphere.offset, startp );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tVectorAdd( tw->start, tw->sphere.offset, startp );\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\toffset = DotProduct( tw->offsets[ planes->signbits ], plane);\n\t\t\tplane[3] -= offset;\n\t\t\tVectorCopy( tw->start, startp );\n\t\t}\n\n\t\tif ( DotProduct( plane, startp ) - plane[3] > 0.0f ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor ( j = 0; j < facet->numBorders; j++ ) {\n\t\t\tplanes = &pc->planes[ facet->borderPlanes[j] ];\n\t\t\tif (facet->borderInward[j]) {\n\t\t\t\tVectorNegate(planes->plane, plane);\n\t\t\t\tplane[3] = -planes->plane[3];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tVectorCopy(planes->plane, plane);\n\t\t\t\tplane[3] = planes->plane[3];\n\t\t\t}\n\t\t\tif ( tw->sphere.use ) {\n\t\t\t\t// adjust the plane distance apropriately for radius\n\t\t\t\tplane[3] += tw->sphere.radius;\n\n\t\t\t\t// find the closest point on the capsule to the plane\n\t\t\t\tt = DotProduct( plane, tw->sphere.offset );\n\t\t\t\tif ( t > 0.0f ) {\n\t\t\t\t\tVectorSubtract( tw->start, tw->sphere.offset, startp );\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tVectorAdd( tw->start, tw->sphere.offset, startp );\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// NOTE: this works even though the plane might be flipped because the bbox is centered\n\t\t\t\toffset = DotProduct( tw->offsets[ planes->signbits ], plane);\n\t\t\t\tplane[3] += fabs(offset);\n\t\t\t\tVectorCopy( tw->start, startp );\n\t\t\t}\n\n\t\t\tif ( DotProduct( plane, startp ) - plane[3] > 0.0f ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (j < facet->numBorders) {\n\t\t\tcontinue;\n\t\t}\n\t\t// inside this patch facet\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n=======================================================================\n\nDEBUGGING\n\n=======================================================================\n*/\n\n\n/*\n==================\nCM_DrawDebugSurface\n\nCalled from the renderer\n==================\n*/\n#ifndef BSPC\nvoid BotDrawDebugPolygons(void (*drawPoly)(int color, int numPoints, float *points), int value);\n#endif\n\nvoid CM_DrawDebugSurface( void (*drawPoly)(int color, int numPoints, float *points) ) {\n\tstatic cvar_t\t*cv;\n#ifndef BSPC\n\tstatic cvar_t\t*cv2;\n#endif\n\tconst patchCollide_t\t*pc;\n\tfacet_t\t\t\t*facet;\n\twinding_t\t\t*w;\n\tint\t\t\t\ti, j, k, n;\n\tint\t\t\t\tcurplanenum, planenum, curinward, inward;\n\tfloat\t\t\tplane[4];\n\tvec3_t mins = {-15, -15, -28}, maxs = {15, 15, 28};\n\t//vec3_t mins = {0, 0, 0}, maxs = {0, 0, 0};\n\tvec3_t v1, v2;\n\n#ifndef BSPC\n\tif ( !cv2 )\n\t{\n\t\tcv2 = Cvar_Get( \"r_debugSurface\", \"0\", 0 );\n\t}\n\n\tif (cv2->integer != 1)\n\t{\n\t\tBotDrawDebugPolygons(drawPoly, cv2->integer);\n\t\treturn;\n\t}\n#endif\n\n\tif ( !debugPatchCollide ) {\n\t\treturn;\n\t}\n\n#ifndef BSPC\n\tif ( !cv ) {\n\t\tcv = Cvar_Get( \"cm_debugSize\", \"2\", 0 );\n\t}\n#endif\n\tpc = debugPatchCollide;\n\n\tfor ( i = 0, facet = pc->facets ; i < pc->numFacets ; i++, facet++ ) {\n\n\t\tfor ( k = 0 ; k < facet->numBorders + 1; k++ ) {\n\t\t\t//\n\t\t\tif (k < facet->numBorders) {\n\t\t\t\tplanenum = facet->borderPlanes[k];\n\t\t\t\tinward = facet->borderInward[k];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tplanenum = facet->surfacePlane;\n\t\t\t\tinward = qfalse;\n\t\t\t\t//continue;\n\t\t\t}\n\n\t\t\tVector4Copy( pc->planes[ planenum ].plane, plane );\n\n\t\t\t//planenum = facet->surfacePlane;\n\t\t\tif ( inward ) {\n\t\t\t\tVectorSubtract( vec3_origin, plane, plane );\n\t\t\t\tplane[3] = -plane[3];\n\t\t\t}\n\n\t\t\tplane[3] += cv->value;\n\t\t\t//*\n\t\t\tfor (n = 0; n < 3; n++)\n\t\t\t{\n\t\t\t\tif (plane[n] > 0) v1[n] = maxs[n];\n\t\t\t\telse v1[n] = mins[n];\n\t\t\t} //end for\n\t\t\tVectorNegate(plane, v2);\n\t\t\tplane[3] += fabs(DotProduct(v1, v2));\n\t\t\t//*/\n\n\t\t\tw = BaseWindingForPlane( plane,  plane[3] );\n\t\t\tfor ( j = 0 ; j < facet->numBorders + 1 && w; j++ ) {\n\t\t\t\t//\n\t\t\t\tif (j < facet->numBorders) {\n\t\t\t\t\tcurplanenum = facet->borderPlanes[j];\n\t\t\t\t\tcurinward = facet->borderInward[j];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tcurplanenum = facet->surfacePlane;\n\t\t\t\t\tcurinward = qfalse;\n\t\t\t\t\t//continue;\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tif (curplanenum == planenum) continue;\n\n\t\t\t\tVector4Copy( pc->planes[ curplanenum ].plane, plane );\n\t\t\t\tif ( !curinward ) {\n\t\t\t\t\tVectorSubtract( vec3_origin, plane, plane );\n\t\t\t\t\tplane[3] = -plane[3];\n\t\t\t\t}\n\t\t//\t\t\tif ( !facet->borderNoAdjust[j] ) {\n\t\t\t\t\tplane[3] -= cv->value;\n\t\t//\t\t\t}\n\t\t\t\tfor (n = 0; n < 3; n++)\n\t\t\t\t{\n\t\t\t\t\tif (plane[n] > 0) v1[n] = maxs[n];\n\t\t\t\t\telse v1[n] = mins[n];\n\t\t\t\t} //end for\n\t\t\t\tVectorNegate(plane, v2);\n\t\t\t\tplane[3] -= fabs(DotProduct(v1, v2));\n\n\t\t\t\tChopWindingInPlace( &w, plane, plane[3], 0.1f );\n\t\t\t}\n\t\t\tif ( w ) {\n\t\t\t\tif ( facet == debugFacet ) {\n\t\t\t\t\tdrawPoly( 4, w->numpoints, w->p[0] );\n\t\t\t\t\t//Com_Printf(\"blue facet has %d border planes\\n\", facet->numBorders);\n\t\t\t\t} else {\n\t\t\t\t\tdrawPoly( 1, w->numpoints, w->p[0] );\n\t\t\t\t}\n\t\t\t\tFreeWinding( w );\n\t\t\t}\n\t\t\telse\n\t\t\t\tCom_Printf(\"winding chopped away by border planes\\n\");\n\t\t}\n\t}\n\n\t// draw the debug block\n\t{\n\t\tvec3_t\t\t\tv[3];\n\n\t\tVectorCopy( debugBlockPoints[0], v[0] );\n\t\tVectorCopy( debugBlockPoints[1], v[1] );\n\t\tVectorCopy( debugBlockPoints[2], v[2] );\n\t\tdrawPoly( 2, 3, v[0] );\n\n\t\tVectorCopy( debugBlockPoints[2], v[0] );\n\t\tVectorCopy( debugBlockPoints[3], v[1] );\n\t\tVectorCopy( debugBlockPoints[0], v[2] );\n\t\tdrawPoly( 2, 3, v[0] );\n\t}\n\n#if 0\n\tvec3_t\t\t\tv[4];\n\n\tv[0][0] = pc->bounds[1][0];\n\tv[0][1] = pc->bounds[1][1];\n\tv[0][2] = pc->bounds[1][2];\n\n\tv[1][0] = pc->bounds[1][0];\n\tv[1][1] = pc->bounds[0][1];\n\tv[1][2] = pc->bounds[1][2];\n\n\tv[2][0] = pc->bounds[0][0];\n\tv[2][1] = pc->bounds[0][1];\n\tv[2][2] = pc->bounds[1][2];\n\n\tv[3][0] = pc->bounds[0][0];\n\tv[3][1] = pc->bounds[1][1];\n\tv[3][2] = pc->bounds[1][2];\n\n\tdrawPoly( 4, v[0] );\n#endif\n}\n"
  },
  {
    "path": "code/qcommon/cm_patch.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n//#define\tCULL_BBOX\n\n/*\n\nThis file does not reference any globals, and has these entry points:\n\nvoid CM_ClearLevelPatches( void );\nstruct patchCollide_s\t*CM_GeneratePatchCollide( int width, int height, const vec3_t *points );\nvoid CM_TraceThroughPatchCollide( traceWork_t *tw, const struct patchCollide_s *pc );\nqboolean CM_PositionTestInPatchCollide( traceWork_t *tw, const struct patchCollide_s *pc );\nvoid CM_DrawDebugSurface( void (*drawPoly)(int color, int numPoints, flaot *points) );\n\n\nIssues for collision against curved surfaces:\n\nSurface edges need to be handled differently than surface planes\n\nPlane expansion causes raw surfaces to expand past expanded bounding box\n\nPosition test of a volume against a surface is tricky.\n\nPosition test of a point against a surface is not well defined, because the surface has no volume.\n\n\nTracing leading edge points instead of volumes?\nPosition test by tracing corner to corner? (8*7 traces -- ouch)\n\ncoplanar edges\ntriangulated patches\ndegenerate patches\n\n  endcaps\n  degenerate\n\nWARNING: this may misbehave with meshes that have rows or columns that only\ndegenerate a few triangles.  Completely degenerate rows and columns are handled\nproperly.\n*/\n\n\n#define\tMAX_FACETS\t\t\t1024\n#define\tMAX_PATCH_PLANES\t2048\n\ntypedef struct {\n\tfloat\tplane[4];\n\tint\t\tsignbits;\t\t// signx + (signy<<1) + (signz<<2), used as lookup during collision\n} patchPlane_t;\n\ntypedef struct {\n\tint\t\t\tsurfacePlane;\n\tint\t\t\tnumBorders;\t\t// 3 or four + 6 axial bevels + 4 or 3 * 4 edge bevels\n\tint\t\t\tborderPlanes[4+6+16];\n\tint\t\t\tborderInward[4+6+16];\n\tqboolean\tborderNoAdjust[4+6+16];\n} facet_t;\n\ntypedef struct patchCollide_s {\n\tvec3_t\tbounds[2];\n\tint\t\tnumPlanes;\t\t\t// surface planes plus edge planes\n\tpatchPlane_t\t*planes;\n\tint\t\tnumFacets;\n\tfacet_t\t*facets;\n} patchCollide_t;\n\n\n#define\tMAX_GRID_SIZE\t129\n\ntypedef struct {\n\tint\t\t\twidth;\n\tint\t\t\theight;\n\tqboolean\twrapWidth;\n\tqboolean\twrapHeight;\n\tvec3_t\tpoints[MAX_GRID_SIZE][MAX_GRID_SIZE];\t// [width][height]\n} cGrid_t;\n\n#define\tSUBDIVIDE_DISTANCE\t16\t//4\t// never more than this units away from curve\n#define\tPLANE_TRI_EPSILON\t0.1\n#define\tWRAP_POINT_EPSILON\t0.1\n\n\nstruct patchCollide_s\t*CM_GeneratePatchCollide( int width, int height, vec3_t *points );\n"
  },
  {
    "path": "code/qcommon/cm_polylib.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n// this is only used for visualization tools in cm_ debug functions\n\n\n#include \"cm_local.h\"\n\n\n// counters are only bumped when running single threaded,\n// because they are an awefull coherence problem\nint\tc_active_windings;\nint\tc_peak_windings;\nint\tc_winding_allocs;\nint\tc_winding_points;\n\nvoid pw(winding_t *w)\n{\n\tint\t\ti;\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\tprintf (\"(%5.1f, %5.1f, %5.1f)\\n\",w->p[i][0], w->p[i][1],w->p[i][2]);\n}\n\n\n/*\n=============\nAllocWinding\n=============\n*/\nwinding_t\t*AllocWinding (int points)\n{\n\twinding_t\t*w;\n\tint\t\t\ts;\n\n\tc_winding_allocs++;\n\tc_winding_points += points;\n\tc_active_windings++;\n\tif (c_active_windings > c_peak_windings)\n\t\tc_peak_windings = c_active_windings;\n\n\ts = sizeof(vec_t)*3*points + sizeof(int);\n\tw = Z_Malloc (s);\n\tCom_Memset (w, 0, s); \n\treturn w;\n}\n\nvoid FreeWinding (winding_t *w)\n{\n\tif (*(unsigned *)w == 0xdeaddead)\n\t\tCom_Error (ERR_FATAL, \"FreeWinding: freed a freed winding\");\n\t*(unsigned *)w = 0xdeaddead;\n\n\tc_active_windings--;\n\tZ_Free (w);\n}\n\n/*\n============\nRemoveColinearPoints\n============\n*/\nint\tc_removed;\n\nvoid\tRemoveColinearPoints (winding_t *w)\n{\n\tint\t\ti, j, k;\n\tvec3_t\tv1, v2;\n\tint\t\tnump;\n\tvec3_t\tp[MAX_POINTS_ON_WINDING];\n\n\tnump = 0;\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tj = (i+1)%w->numpoints;\n\t\tk = (i+w->numpoints-1)%w->numpoints;\n\t\tVectorSubtract (w->p[j], w->p[i], v1);\n\t\tVectorSubtract (w->p[i], w->p[k], v2);\n\t\tVectorNormalize2(v1,v1);\n\t\tVectorNormalize2(v2,v2);\n\t\tif (DotProduct(v1, v2) < 0.999)\n\t\t{\n\t\t\tVectorCopy (w->p[i], p[nump]);\n\t\t\tnump++;\n\t\t}\n\t}\n\n\tif (nump == w->numpoints)\n\t\treturn;\n\n\tc_removed += w->numpoints - nump;\n\tw->numpoints = nump;\n\tCom_Memcpy (w->p, p, nump*sizeof(p[0]));\n}\n\n/*\n============\nWindingPlane\n============\n*/\nvoid WindingPlane (winding_t *w, vec3_t normal, vec_t *dist)\n{\n\tvec3_t\tv1, v2;\n\n\tVectorSubtract (w->p[1], w->p[0], v1);\n\tVectorSubtract (w->p[2], w->p[0], v2);\n\tCrossProduct (v2, v1, normal);\n\tVectorNormalize2(normal, normal);\n\t*dist = DotProduct (w->p[0], normal);\n\n}\n\n/*\n=============\nWindingArea\n=============\n*/\nvec_t\tWindingArea (winding_t *w)\n{\n\tint\t\ti;\n\tvec3_t\td1, d2, cross;\n\tvec_t\ttotal;\n\n\ttotal = 0;\n\tfor (i=2 ; i<w->numpoints ; i++)\n\t{\n\t\tVectorSubtract (w->p[i-1], w->p[0], d1);\n\t\tVectorSubtract (w->p[i], w->p[0], d2);\n\t\tCrossProduct (d1, d2, cross);\n\t\ttotal += 0.5 * VectorLength ( cross );\n\t}\n\treturn total;\n}\n\n/*\n=============\nWindingBounds\n=============\n*/\nvoid\tWindingBounds (winding_t *w, vec3_t mins, vec3_t maxs)\n{\n\tvec_t\tv;\n\tint\t\ti,j;\n\n\tmins[0] = mins[1] = mins[2] = MAX_MAP_BOUNDS;\n\tmaxs[0] = maxs[1] = maxs[2] = -MAX_MAP_BOUNDS;\n\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\tv = w->p[i][j];\n\t\t\tif (v < mins[j])\n\t\t\t\tmins[j] = v;\n\t\t\tif (v > maxs[j])\n\t\t\t\tmaxs[j] = v;\n\t\t}\n\t}\n}\n\n/*\n=============\nWindingCenter\n=============\n*/\nvoid\tWindingCenter (winding_t *w, vec3_t center)\n{\n\tint\t\ti;\n\tfloat\tscale;\n\n\tVectorCopy (vec3_origin, center);\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\tVectorAdd (w->p[i], center, center);\n\n\tscale = 1.0/w->numpoints;\n\tVectorScale (center, scale, center);\n}\n\n/*\n=================\nBaseWindingForPlane\n=================\n*/\nwinding_t *BaseWindingForPlane (vec3_t normal, vec_t dist)\n{\n\tint\t\ti, x;\n\tvec_t\tmax, v;\n\tvec3_t\torg, vright, vup;\n\twinding_t\t*w;\n\t\n// find the major axis\n\n\tmax = -MAX_MAP_BOUNDS;\n\tx = -1;\n\tfor (i=0 ; i<3; i++)\n\t{\n\t\tv = fabs(normal[i]);\n\t\tif (v > max)\n\t\t{\n\t\t\tx = i;\n\t\t\tmax = v;\n\t\t}\n\t}\n\tif (x==-1)\n\t\tCom_Error (ERR_DROP, \"BaseWindingForPlane: no axis found\");\n\t\t\n\tVectorCopy (vec3_origin, vup);\t\n\tswitch (x)\n\t{\n\tcase 0:\n\tcase 1:\n\t\tvup[2] = 1;\n\t\tbreak;\t\t\n\tcase 2:\n\t\tvup[0] = 1;\n\t\tbreak;\t\t\n\t}\n\n\tv = DotProduct (vup, normal);\n\tVectorMA (vup, -v, normal, vup);\n\tVectorNormalize2(vup, vup);\n\t\t\n\tVectorScale (normal, dist, org);\n\t\n\tCrossProduct (vup, normal, vright);\n\t\n\tVectorScale (vup, MAX_MAP_BOUNDS, vup);\n\tVectorScale (vright, MAX_MAP_BOUNDS, vright);\n\n// project a really big\taxis aligned box onto the plane\n\tw = AllocWinding (4);\n\t\n\tVectorSubtract (org, vright, w->p[0]);\n\tVectorAdd (w->p[0], vup, w->p[0]);\n\t\n\tVectorAdd (org, vright, w->p[1]);\n\tVectorAdd (w->p[1], vup, w->p[1]);\n\t\n\tVectorAdd (org, vright, w->p[2]);\n\tVectorSubtract (w->p[2], vup, w->p[2]);\n\t\n\tVectorSubtract (org, vright, w->p[3]);\n\tVectorSubtract (w->p[3], vup, w->p[3]);\n\t\n\tw->numpoints = 4;\n\t\n\treturn w;\t\n}\n\n/*\n==================\nCopyWinding\n==================\n*/\nwinding_t\t*CopyWinding (winding_t *w)\n{\n\tint\t\t\tsize;\n\twinding_t\t*c;\n\n\tc = AllocWinding (w->numpoints);\n\tsize = (int)((winding_t *)0)->p[w->numpoints];\n\tCom_Memcpy (c, w, size);\n\treturn c;\n}\n\n/*\n==================\nReverseWinding\n==================\n*/\nwinding_t\t*ReverseWinding (winding_t *w)\n{\n\tint\t\t\ti;\n\twinding_t\t*c;\n\n\tc = AllocWinding (w->numpoints);\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tVectorCopy (w->p[w->numpoints-1-i], c->p[i]);\n\t}\n\tc->numpoints = w->numpoints;\n\treturn c;\n}\n\n\n/*\n=============\nClipWindingEpsilon\n=============\n*/\nvoid\tClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist, \n\t\t\t\tvec_t epsilon, winding_t **front, winding_t **back)\n{\n\tvec_t\tdists[MAX_POINTS_ON_WINDING+4];\n\tint\t\tsides[MAX_POINTS_ON_WINDING+4];\n\tint\t\tcounts[3];\n\tstatic\tvec_t\tdot;\t\t// VC 4.2 optimizer bug if not static\n\tint\t\ti, j;\n\tvec_t\t*p1, *p2;\n\tvec3_t\tmid;\n\twinding_t\t*f, *b;\n\tint\t\tmaxpts;\n\t\n\tcounts[0] = counts[1] = counts[2] = 0;\n\n// determine sides for each point\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tdot = DotProduct (in->p[i], normal);\n\t\tdot -= dist;\n\t\tdists[i] = dot;\n\t\tif (dot > epsilon)\n\t\t\tsides[i] = SIDE_FRONT;\n\t\telse if (dot < -epsilon)\n\t\t\tsides[i] = SIDE_BACK;\n\t\telse\n\t\t{\n\t\t\tsides[i] = SIDE_ON;\n\t\t}\n\t\tcounts[sides[i]]++;\n\t}\n\tsides[i] = sides[0];\n\tdists[i] = dists[0];\n\t\n\t*front = *back = NULL;\n\n\tif (!counts[0])\n\t{\n\t\t*back = CopyWinding (in);\n\t\treturn;\n\t}\n\tif (!counts[1])\n\t{\n\t\t*front = CopyWinding (in);\n\t\treturn;\n\t}\n\n\tmaxpts = in->numpoints+4;\t// cant use counts[0]+2 because\n\t\t\t\t\t\t\t\t// of fp grouping errors\n\n\t*front = f = AllocWinding (maxpts);\n\t*back = b = AllocWinding (maxpts);\n\t\t\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tp1 = in->p[i];\n\t\t\n\t\tif (sides[i] == SIDE_ON)\n\t\t{\n\t\t\tVectorCopy (p1, f->p[f->numpoints]);\n\t\t\tf->numpoints++;\n\t\t\tVectorCopy (p1, b->p[b->numpoints]);\n\t\t\tb->numpoints++;\n\t\t\tcontinue;\n\t\t}\n\t\n\t\tif (sides[i] == SIDE_FRONT)\n\t\t{\n\t\t\tVectorCopy (p1, f->p[f->numpoints]);\n\t\t\tf->numpoints++;\n\t\t}\n\t\tif (sides[i] == SIDE_BACK)\n\t\t{\n\t\t\tVectorCopy (p1, b->p[b->numpoints]);\n\t\t\tb->numpoints++;\n\t\t}\n\n\t\tif (sides[i+1] == SIDE_ON || sides[i+1] == sides[i])\n\t\t\tcontinue;\n\t\t\t\n\t// generate a split point\n\t\tp2 = in->p[(i+1)%in->numpoints];\n\t\t\n\t\tdot = dists[i] / (dists[i]-dists[i+1]);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\t// avoid round off error when possible\n\t\t\tif (normal[j] == 1)\n\t\t\t\tmid[j] = dist;\n\t\t\telse if (normal[j] == -1)\n\t\t\t\tmid[j] = -dist;\n\t\t\telse\n\t\t\t\tmid[j] = p1[j] + dot*(p2[j]-p1[j]);\n\t\t}\n\t\t\t\n\t\tVectorCopy (mid, f->p[f->numpoints]);\n\t\tf->numpoints++;\n\t\tVectorCopy (mid, b->p[b->numpoints]);\n\t\tb->numpoints++;\n\t}\n\t\n\tif (f->numpoints > maxpts || b->numpoints > maxpts)\n\t\tCom_Error (ERR_DROP, \"ClipWinding: points exceeded estimate\");\n\tif (f->numpoints > MAX_POINTS_ON_WINDING || b->numpoints > MAX_POINTS_ON_WINDING)\n\t\tCom_Error (ERR_DROP, \"ClipWinding: MAX_POINTS_ON_WINDING\");\n}\n\n\n/*\n=============\nChopWindingInPlace\n=============\n*/\nvoid ChopWindingInPlace (winding_t **inout, vec3_t normal, vec_t dist, vec_t epsilon)\n{\n\twinding_t\t*in;\n\tvec_t\tdists[MAX_POINTS_ON_WINDING+4];\n\tint\t\tsides[MAX_POINTS_ON_WINDING+4];\n\tint\t\tcounts[3];\n\tstatic\tvec_t\tdot;\t\t// VC 4.2 optimizer bug if not static\n\tint\t\ti, j;\n\tvec_t\t*p1, *p2;\n\tvec3_t\tmid;\n\twinding_t\t*f;\n\tint\t\tmaxpts;\n\n\tin = *inout;\n\tcounts[0] = counts[1] = counts[2] = 0;\n\n// determine sides for each point\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tdot = DotProduct (in->p[i], normal);\n\t\tdot -= dist;\n\t\tdists[i] = dot;\n\t\tif (dot > epsilon)\n\t\t\tsides[i] = SIDE_FRONT;\n\t\telse if (dot < -epsilon)\n\t\t\tsides[i] = SIDE_BACK;\n\t\telse\n\t\t{\n\t\t\tsides[i] = SIDE_ON;\n\t\t}\n\t\tcounts[sides[i]]++;\n\t}\n\tsides[i] = sides[0];\n\tdists[i] = dists[0];\n\t\n\tif (!counts[0])\n\t{\n\t\tFreeWinding (in);\n\t\t*inout = NULL;\n\t\treturn;\n\t}\n\tif (!counts[1])\n\t\treturn;\t\t// inout stays the same\n\n\tmaxpts = in->numpoints+4;\t// cant use counts[0]+2 because\n\t\t\t\t\t\t\t\t// of fp grouping errors\n\n\tf = AllocWinding (maxpts);\n\t\t\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tp1 = in->p[i];\n\t\t\n\t\tif (sides[i] == SIDE_ON)\n\t\t{\n\t\t\tVectorCopy (p1, f->p[f->numpoints]);\n\t\t\tf->numpoints++;\n\t\t\tcontinue;\n\t\t}\n\t\n\t\tif (sides[i] == SIDE_FRONT)\n\t\t{\n\t\t\tVectorCopy (p1, f->p[f->numpoints]);\n\t\t\tf->numpoints++;\n\t\t}\n\n\t\tif (sides[i+1] == SIDE_ON || sides[i+1] == sides[i])\n\t\t\tcontinue;\n\t\t\t\n\t// generate a split point\n\t\tp2 = in->p[(i+1)%in->numpoints];\n\t\t\n\t\tdot = dists[i] / (dists[i]-dists[i+1]);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\t// avoid round off error when possible\n\t\t\tif (normal[j] == 1)\n\t\t\t\tmid[j] = dist;\n\t\t\telse if (normal[j] == -1)\n\t\t\t\tmid[j] = -dist;\n\t\t\telse\n\t\t\t\tmid[j] = p1[j] + dot*(p2[j]-p1[j]);\n\t\t}\n\t\t\t\n\t\tVectorCopy (mid, f->p[f->numpoints]);\n\t\tf->numpoints++;\n\t}\n\t\n\tif (f->numpoints > maxpts)\n\t\tCom_Error (ERR_DROP, \"ClipWinding: points exceeded estimate\");\n\tif (f->numpoints > MAX_POINTS_ON_WINDING)\n\t\tCom_Error (ERR_DROP, \"ClipWinding: MAX_POINTS_ON_WINDING\");\n\n\tFreeWinding (in);\n\t*inout = f;\n}\n\n\n/*\n=================\nChopWinding\n\nReturns the fragment of in that is on the front side\nof the cliping plane.  The original is freed.\n=================\n*/\nwinding_t\t*ChopWinding (winding_t *in, vec3_t normal, vec_t dist)\n{\n\twinding_t\t*f, *b;\n\n\tClipWindingEpsilon (in, normal, dist, ON_EPSILON, &f, &b);\n\tFreeWinding (in);\n\tif (b)\n\t\tFreeWinding (b);\n\treturn f;\n}\n\n\n/*\n=================\nCheckWinding\n\n=================\n*/\nvoid CheckWinding (winding_t *w)\n{\n\tint\t\ti, j;\n\tvec_t\t*p1, *p2;\n\tvec_t\td, edgedist;\n\tvec3_t\tdir, edgenormal, facenormal;\n\tvec_t\tarea;\n\tvec_t\tfacedist;\n\n\tif (w->numpoints < 3)\n\t\tCom_Error (ERR_DROP, \"CheckWinding: %i points\",w->numpoints);\n\t\n\tarea = WindingArea(w);\n\tif (area < 1)\n\t\tCom_Error (ERR_DROP, \"CheckWinding: %f area\", area);\n\n\tWindingPlane (w, facenormal, &facedist);\n\t\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tp1 = w->p[i];\n\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t\tif (p1[j] > MAX_MAP_BOUNDS || p1[j] < -MAX_MAP_BOUNDS)\n\t\t\t\tCom_Error (ERR_DROP, \"CheckFace: BUGUS_RANGE: %f\",p1[j]);\n\n\t\tj = i+1 == w->numpoints ? 0 : i+1;\n\t\t\n\t// check the point is on the face plane\n\t\td = DotProduct (p1, facenormal) - facedist;\n\t\tif (d < -ON_EPSILON || d > ON_EPSILON)\n\t\t\tCom_Error (ERR_DROP, \"CheckWinding: point off plane\");\n\t\n\t// check the edge isnt degenerate\n\t\tp2 = w->p[j];\n\t\tVectorSubtract (p2, p1, dir);\n\t\t\n\t\tif (VectorLength (dir) < ON_EPSILON)\n\t\t\tCom_Error (ERR_DROP, \"CheckWinding: degenerate edge\");\n\t\t\t\n\t\tCrossProduct (facenormal, dir, edgenormal);\n\t\tVectorNormalize2 (edgenormal, edgenormal);\n\t\tedgedist = DotProduct (p1, edgenormal);\n\t\tedgedist += ON_EPSILON;\n\t\t\n\t// all other points must be on front side\n\t\tfor (j=0 ; j<w->numpoints ; j++)\n\t\t{\n\t\t\tif (j == i)\n\t\t\t\tcontinue;\n\t\t\td = DotProduct (w->p[j], edgenormal);\n\t\t\tif (d > edgedist)\n\t\t\t\tCom_Error (ERR_DROP, \"CheckWinding: non-convex\");\n\t\t}\n\t}\n}\n\n\n/*\n============\nWindingOnPlaneSide\n============\n*/\nint\t\tWindingOnPlaneSide (winding_t *w, vec3_t normal, vec_t dist)\n{\n\tqboolean\tfront, back;\n\tint\t\t\ti;\n\tvec_t\t\td;\n\n\tfront = qfalse;\n\tback = qfalse;\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\td = DotProduct (w->p[i], normal) - dist;\n\t\tif (d < -ON_EPSILON)\n\t\t{\n\t\t\tif (front)\n\t\t\t\treturn SIDE_CROSS;\n\t\t\tback = qtrue;\n\t\t\tcontinue;\n\t\t}\n\t\tif (d > ON_EPSILON)\n\t\t{\n\t\t\tif (back)\n\t\t\t\treturn SIDE_CROSS;\n\t\t\tfront = qtrue;\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\tif (back)\n\t\treturn SIDE_BACK;\n\tif (front)\n\t\treturn SIDE_FRONT;\n\treturn SIDE_ON;\n}\n\n\n/*\n=================\nAddWindingToConvexHull\n\nBoth w and *hull are on the same plane\n=================\n*/\n#define\tMAX_HULL_POINTS\t\t128\nvoid\tAddWindingToConvexHull( winding_t *w, winding_t **hull, vec3_t normal ) {\n\tint\t\t\ti, j, k;\n\tfloat\t\t*p, *copy;\n\tvec3_t\t\tdir;\n\tfloat\t\td;\n\tint\t\t\tnumHullPoints, numNew;\n\tvec3_t\t\thullPoints[MAX_HULL_POINTS];\n\tvec3_t\t\tnewHullPoints[MAX_HULL_POINTS];\n\tvec3_t\t\thullDirs[MAX_HULL_POINTS];\n\tqboolean\thullSide[MAX_HULL_POINTS];\n\tqboolean\toutside;\n\n\tif ( !*hull ) {\n\t\t*hull = CopyWinding( w );\n\t\treturn;\n\t}\n\n\tnumHullPoints = (*hull)->numpoints;\n\tCom_Memcpy( hullPoints, (*hull)->p, numHullPoints * sizeof(vec3_t) );\n\n\tfor ( i = 0 ; i < w->numpoints ; i++ ) {\n\t\tp = w->p[i];\n\n\t\t// calculate hull side vectors\n\t\tfor ( j = 0 ; j < numHullPoints ; j++ ) {\n\t\t\tk = ( j + 1 ) % numHullPoints;\n\n\t\t\tVectorSubtract( hullPoints[k], hullPoints[j], dir );\n\t\t\tVectorNormalize2( dir, dir );\n\t\t\tCrossProduct( normal, dir, hullDirs[j] );\n\t\t}\n\n\t\toutside = qfalse;\n\t\tfor ( j = 0 ; j < numHullPoints ; j++ ) {\n\t\t\tVectorSubtract( p, hullPoints[j], dir );\n\t\t\td = DotProduct( dir, hullDirs[j] );\n\t\t\tif ( d >= ON_EPSILON ) {\n\t\t\t\toutside = qtrue;\n\t\t\t}\n\t\t\tif ( d >= -ON_EPSILON ) {\n\t\t\t\thullSide[j] = qtrue;\n\t\t\t} else {\n\t\t\t\thullSide[j] = qfalse;\n\t\t\t}\n\t\t}\n\n\t\t// if the point is effectively inside, do nothing\n\t\tif ( !outside ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// find the back side to front side transition\n\t\tfor ( j = 0 ; j < numHullPoints ; j++ ) {\n\t\t\tif ( !hullSide[ j % numHullPoints ] && hullSide[ (j + 1) % numHullPoints ] ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif ( j == numHullPoints ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// insert the point here\n\t\tVectorCopy( p, newHullPoints[0] );\n\t\tnumNew = 1;\n\n\t\t// copy over all points that aren't double fronts\n\t\tj = (j+1)%numHullPoints;\n\t\tfor ( k = 0 ; k < numHullPoints ; k++ ) {\n\t\t\tif ( hullSide[ (j+k) % numHullPoints ] && hullSide[ (j+k+1) % numHullPoints ] ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tcopy = hullPoints[ (j+k+1) % numHullPoints ];\n\t\t\tVectorCopy( copy, newHullPoints[numNew] );\n\t\t\tnumNew++;\n\t\t}\n\n\t\tnumHullPoints = numNew;\n\t\tCom_Memcpy( hullPoints, newHullPoints, numHullPoints * sizeof(vec3_t) );\n\t}\n\n\tFreeWinding( *hull );\n\tw = AllocWinding( numHullPoints );\n\tw->numpoints = numHullPoints;\n\t*hull = w;\n\tCom_Memcpy( w->p, hullPoints, numHullPoints * sizeof(vec3_t) );\n}\n\n\n"
  },
  {
    "path": "code/qcommon/cm_polylib.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n// this is only used for visualization tools in cm_ debug functions\n\ntypedef struct\n{\n\tint\t\tnumpoints;\n\tvec3_t\tp[4];\t\t// variable sized\n} winding_t;\n\n#define\tMAX_POINTS_ON_WINDING\t64\n\n#define\tSIDE_FRONT\t0\n#define\tSIDE_BACK\t1\n#define\tSIDE_ON\t\t2\n#define\tSIDE_CROSS\t3\n\n#define\tCLIP_EPSILON\t0.1f\n\n#define MAX_MAP_BOUNDS\t\t\t65535\n\n// you can define on_epsilon in the makefile as tighter\n#ifndef\tON_EPSILON\n#define\tON_EPSILON\t0.1f\n#endif\n\nwinding_t\t*AllocWinding (int points);\nvec_t\tWindingArea (winding_t *w);\nvoid\tWindingCenter (winding_t *w, vec3_t center);\nvoid\tClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist, \n\t\t\t\tvec_t epsilon, winding_t **front, winding_t **back);\nwinding_t\t*ChopWinding (winding_t *in, vec3_t normal, vec_t dist);\nwinding_t\t*CopyWinding (winding_t *w);\nwinding_t\t*ReverseWinding (winding_t *w);\nwinding_t\t*BaseWindingForPlane (vec3_t normal, vec_t dist);\nvoid\tCheckWinding (winding_t *w);\nvoid\tWindingPlane (winding_t *w, vec3_t normal, vec_t *dist);\nvoid\tRemoveColinearPoints (winding_t *w);\nint\t\tWindingOnPlaneSide (winding_t *w, vec3_t normal, vec_t dist);\nvoid\tFreeWinding (winding_t *w);\nvoid\tWindingBounds (winding_t *w, vec3_t mins, vec3_t maxs);\n\nvoid\tAddWindingToConvexHull( winding_t *w, winding_t **hull, vec3_t normal );\n\nvoid\tChopWindingInPlace (winding_t **w, vec3_t normal, vec_t dist, vec_t epsilon);\n// frees the original if clipped\n\nvoid pw(winding_t *w);\n"
  },
  {
    "path": "code/qcommon/cm_public.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qfiles.h\"\n\n\nvoid\t\tCM_LoadMap( const char *name, qboolean clientload, int *checksum);\nvoid\t\tCM_ClearMap( void );\nclipHandle_t CM_InlineModel( int index );\t\t// 0 = world, 1 + are bmodels\nclipHandle_t CM_TempBoxModel( const vec3_t mins, const vec3_t maxs, int capsule );\n\nvoid\t\tCM_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs );\n\nint\t\t\tCM_NumClusters (void);\nint\t\t\tCM_NumInlineModels( void );\nchar\t\t*CM_EntityString (void);\n\n// returns an ORed contents mask\nint\t\t\tCM_PointContents( const vec3_t p, clipHandle_t model );\nint\t\t\tCM_TransformedPointContents( const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles );\n\nvoid\t\tCM_BoxTrace ( trace_t *results, const vec3_t start, const vec3_t end,\n\t\t\t\t\t\t  vec3_t mins, vec3_t maxs,\n\t\t\t\t\t\t  clipHandle_t model, int brushmask, int capsule );\nvoid\t\tCM_TransformedBoxTrace( trace_t *results, const vec3_t start, const vec3_t end,\n\t\t\t\t\t\t  vec3_t mins, vec3_t maxs,\n\t\t\t\t\t\t  clipHandle_t model, int brushmask,\n\t\t\t\t\t\t  const vec3_t origin, const vec3_t angles, int capsule );\n\nbyte\t\t*CM_ClusterPVS (int cluster);\n\nint\t\t\tCM_PointLeafnum( const vec3_t p );\n\n// only returns non-solid leafs\n// overflow if return listsize and if *lastLeaf != list[listsize-1]\nint\t\t\tCM_BoxLeafnums( const vec3_t mins, const vec3_t maxs, int *list,\n\t\t \t\t\t\t\tint listsize, int *lastLeaf );\n\nint\t\t\tCM_LeafCluster (int leafnum);\nint\t\t\tCM_LeafArea (int leafnum);\n\nvoid\t\tCM_AdjustAreaPortalState( int area1, int area2, qboolean open );\nqboolean\tCM_AreasConnected( int area1, int area2 );\n\nint\t\t\tCM_WriteAreaBits( byte *buffer, int area );\n\n// cm_tag.c\nint\t\t\tCM_LerpTag( orientation_t *tag,  clipHandle_t model, int startFrame, int endFrame, \n\t\t\t\t\t float frac, const char *tagName );\n\n\n// cm_marks.c\nint\tCM_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projection,\n\t\t\t\t   int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer );\n\n// cm_patch.c\nvoid CM_DrawDebugSurface( void (*drawPoly)(int color, int numPoints, float *points) );\n"
  },
  {
    "path": "code/qcommon/cm_test.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"cm_local.h\"\n\n\n/*\n==================\nCM_PointLeafnum_r\n\n==================\n*/\nint CM_PointLeafnum_r( const vec3_t p, int num ) {\n\tfloat\t\td;\n\tcNode_t\t\t*node;\n\tcplane_t\t*plane;\n\n\twhile (num >= 0)\n\t{\n\t\tnode = cm.nodes + num;\n\t\tplane = node->plane;\n\t\t\n\t\tif (plane->type < 3)\n\t\t\td = p[plane->type] - plane->dist;\n\t\telse\n\t\t\td = DotProduct (plane->normal, p) - plane->dist;\n\t\tif (d < 0)\n\t\t\tnum = node->children[1];\n\t\telse\n\t\t\tnum = node->children[0];\n\t}\n\n\tc_pointcontents++;\t\t// optimize counter\n\n\treturn -1 - num;\n}\n\nint CM_PointLeafnum( const vec3_t p ) {\n\tif ( !cm.numNodes ) {\t// map not loaded\n\t\treturn 0;\n\t}\n\treturn CM_PointLeafnum_r (p, 0);\n}\n\n\n/*\n======================================================================\n\nLEAF LISTING\n\n======================================================================\n*/\n\n\nvoid CM_StoreLeafs( leafList_t *ll, int nodenum ) {\n\tint\t\tleafNum;\n\n\tleafNum = -1 - nodenum;\n\n\t// store the lastLeaf even if the list is overflowed\n\tif ( cm.leafs[ leafNum ].cluster != -1 ) {\n\t\tll->lastLeaf = leafNum;\n\t}\n\n\tif ( ll->count >= ll->maxcount) {\n\t\tll->overflowed = qtrue;\n\t\treturn;\n\t}\n\tll->list[ ll->count++ ] = leafNum;\n}\n\nvoid CM_StoreBrushes( leafList_t *ll, int nodenum ) {\n\tint\t\t\ti, k;\n\tint\t\t\tleafnum;\n\tint\t\t\tbrushnum;\n\tcLeaf_t\t\t*leaf;\n\tcbrush_t\t*b;\n\n\tleafnum = -1 - nodenum;\n\n\tleaf = &cm.leafs[leafnum];\n\n\tfor ( k = 0 ; k < leaf->numLeafBrushes ; k++ ) {\n\t\tbrushnum = cm.leafbrushes[leaf->firstLeafBrush+k];\n\t\tb = &cm.brushes[brushnum];\n\t\tif ( b->checkcount == cm.checkcount ) {\n\t\t\tcontinue;\t// already checked this brush in another leaf\n\t\t}\n\t\tb->checkcount = cm.checkcount;\n\t\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\t\tif ( b->bounds[0][i] >= ll->bounds[1][i] || b->bounds[1][i] <= ll->bounds[0][i] ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif ( i != 3 ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( ll->count >= ll->maxcount) {\n\t\t\tll->overflowed = qtrue;\n\t\t\treturn;\n\t\t}\n\t\t((cbrush_t **)ll->list)[ ll->count++ ] = b;\n\t}\n#if 0\n\t// store patches?\n\tfor ( k = 0 ; k < leaf->numLeafSurfaces ; k++ ) {\n\t\tpatch = cm.surfaces[ cm.leafsurfaces[ leaf->firstleafsurface + k ] ];\n\t\tif ( !patch ) {\n\t\t\tcontinue;\n\t\t}\n\t}\n#endif\n}\n\n/*\n=============\nCM_BoxLeafnums\n\nFills in a list of all the leafs touched\n=============\n*/\nvoid CM_BoxLeafnums_r( leafList_t *ll, int nodenum ) {\n\tcplane_t\t*plane;\n\tcNode_t\t\t*node;\n\tint\t\t\ts;\n\n\twhile (1) {\n\t\tif (nodenum < 0) {\n\t\t\tll->storeLeafs( ll, nodenum );\n\t\t\treturn;\n\t\t}\n\t\n\t\tnode = &cm.nodes[nodenum];\n\t\tplane = node->plane;\n\t\ts = BoxOnPlaneSide( ll->bounds[0], ll->bounds[1], plane );\n\t\tif (s == 1) {\n\t\t\tnodenum = node->children[0];\n\t\t} else if (s == 2) {\n\t\t\tnodenum = node->children[1];\n\t\t} else {\n\t\t\t// go down both\n\t\t\tCM_BoxLeafnums_r( ll, node->children[0] );\n\t\t\tnodenum = node->children[1];\n\t\t}\n\n\t}\n}\n\n/*\n==================\nCM_BoxLeafnums\n==================\n*/\nint\tCM_BoxLeafnums( const vec3_t mins, const vec3_t maxs, int *list, int listsize, int *lastLeaf) {\n\tleafList_t\tll;\n\n\tcm.checkcount++;\n\n\tVectorCopy( mins, ll.bounds[0] );\n\tVectorCopy( maxs, ll.bounds[1] );\n\tll.count = 0;\n\tll.maxcount = listsize;\n\tll.list = list;\n\tll.storeLeafs = CM_StoreLeafs;\n\tll.lastLeaf = 0;\n\tll.overflowed = qfalse;\n\n\tCM_BoxLeafnums_r( &ll, 0 );\n\n\t*lastLeaf = ll.lastLeaf;\n\treturn ll.count;\n}\n\n/*\n==================\nCM_BoxBrushes\n==================\n*/\nint CM_BoxBrushes( const vec3_t mins, const vec3_t maxs, cbrush_t **list, int listsize ) {\n\tleafList_t\tll;\n\n\tcm.checkcount++;\n\n\tVectorCopy( mins, ll.bounds[0] );\n\tVectorCopy( maxs, ll.bounds[1] );\n\tll.count = 0;\n\tll.maxcount = listsize;\n\tll.list = (void *)list;\n\tll.storeLeafs = CM_StoreBrushes;\n\tll.lastLeaf = 0;\n\tll.overflowed = qfalse;\n\t\n\tCM_BoxLeafnums_r( &ll, 0 );\n\n\treturn ll.count;\n}\n\n\n//====================================================================\n\n\n/*\n==================\nCM_PointContents\n\n==================\n*/\nint CM_PointContents( const vec3_t p, clipHandle_t model ) {\n\tint\t\t\tleafnum;\n\tint\t\t\ti, k;\n\tint\t\t\tbrushnum;\n\tcLeaf_t\t\t*leaf;\n\tcbrush_t\t*b;\n\tint\t\t\tcontents;\n\tfloat\t\td;\n\tcmodel_t\t*clipm;\n\n\tif (!cm.numNodes) {\t// map not loaded\n\t\treturn 0;\n\t}\n\n\tif ( model ) {\n\t\tclipm = CM_ClipHandleToModel( model );\n\t\tleaf = &clipm->leaf;\n\t} else {\n\t\tleafnum = CM_PointLeafnum_r (p, 0);\n\t\tleaf = &cm.leafs[leafnum];\n\t}\n\n\tcontents = 0;\n\tfor (k=0 ; k<leaf->numLeafBrushes ; k++) {\n\t\tbrushnum = cm.leafbrushes[leaf->firstLeafBrush+k];\n\t\tb = &cm.brushes[brushnum];\n\n\t\t// see if the point is in the brush\n\t\tfor ( i = 0 ; i < b->numsides ; i++ ) {\n\t\t\td = DotProduct( p, b->sides[i].plane->normal );\n// FIXME test for Cash\n//\t\t\tif ( d >= b->sides[i].plane->dist ) {\n\t\t\tif ( d > b->sides[i].plane->dist ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif ( i == b->numsides ) {\n\t\t\tcontents |= b->contents;\n\t\t}\n\t}\n\n\treturn contents;\n}\n\n/*\n==================\nCM_TransformedPointContents\n\nHandles offseting and rotation of the end points for moving and\nrotating entities\n==================\n*/\nint\tCM_TransformedPointContents( const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles) {\n\tvec3_t\t\tp_l;\n\tvec3_t\t\ttemp;\n\tvec3_t\t\tforward, right, up;\n\n\t// subtract origin offset\n\tVectorSubtract (p, origin, p_l);\n\n\t// rotate start and end into the models frame of reference\n\tif ( model != BOX_MODEL_HANDLE && \n\t(angles[0] || angles[1] || angles[2]) )\n\t{\n\t\tAngleVectors (angles, forward, right, up);\n\n\t\tVectorCopy (p_l, temp);\n\t\tp_l[0] = DotProduct (temp, forward);\n\t\tp_l[1] = -DotProduct (temp, right);\n\t\tp_l[2] = DotProduct (temp, up);\n\t}\n\n\treturn CM_PointContents( p_l, model );\n}\n\n\n\n/*\n===============================================================================\n\nPVS\n\n===============================================================================\n*/\n\nbyte\t*CM_ClusterPVS (int cluster) {\n\tif (cluster < 0 || cluster >= cm.numClusters || !cm.vised ) {\n\t\treturn cm.visibility;\n\t}\n\n\treturn cm.visibility + cluster * cm.clusterBytes;\n}\n\n\n\n/*\n===============================================================================\n\nAREAPORTALS\n\n===============================================================================\n*/\n\nvoid CM_FloodArea_r( int areaNum, int floodnum) {\n\tint\t\ti;\n\tcArea_t *area;\n\tint\t\t*con;\n\n\tarea = &cm.areas[ areaNum ];\n\n\tif ( area->floodvalid == cm.floodvalid ) {\n\t\tif (area->floodnum == floodnum)\n\t\t\treturn;\n\t\tCom_Error (ERR_DROP, \"FloodArea_r: reflooded\");\n\t}\n\n\tarea->floodnum = floodnum;\n\tarea->floodvalid = cm.floodvalid;\n\tcon = cm.areaPortals + areaNum * cm.numAreas;\n\tfor ( i=0 ; i < cm.numAreas  ; i++ ) {\n\t\tif ( con[i] > 0 ) {\n\t\t\tCM_FloodArea_r( i, floodnum );\n\t\t}\n\t}\n}\n\n/*\n====================\nCM_FloodAreaConnections\n\n====================\n*/\nvoid\tCM_FloodAreaConnections( void ) {\n\tint\t\ti;\n\tcArea_t\t*area;\n\tint\t\tfloodnum;\n\n\t// all current floods are now invalid\n\tcm.floodvalid++;\n\tfloodnum = 0;\n\n\tfor (i = 0 ; i < cm.numAreas ; i++) {\n\t\tarea = &cm.areas[i];\n\t\tif (area->floodvalid == cm.floodvalid) {\n\t\t\tcontinue;\t\t// already flooded into\n\t\t}\n\t\tfloodnum++;\n\t\tCM_FloodArea_r (i, floodnum);\n\t}\n\n}\n\n/*\n====================\nCM_AdjustAreaPortalState\n\n====================\n*/\nvoid\tCM_AdjustAreaPortalState( int area1, int area2, qboolean open ) {\n\tif ( area1 < 0 || area2 < 0 ) {\n\t\treturn;\n\t}\n\n\tif ( area1 >= cm.numAreas || area2 >= cm.numAreas ) {\n\t\tCom_Error (ERR_DROP, \"CM_ChangeAreaPortalState: bad area number\");\n\t}\n\n\tif ( open ) {\n\t\tcm.areaPortals[ area1 * cm.numAreas + area2 ]++;\n\t\tcm.areaPortals[ area2 * cm.numAreas + area1 ]++;\n\t} else {\n\t\tcm.areaPortals[ area1 * cm.numAreas + area2 ]--;\n\t\tcm.areaPortals[ area2 * cm.numAreas + area1 ]--;\n\t\tif ( cm.areaPortals[ area2 * cm.numAreas + area1 ] < 0 ) {\n\t\t\tCom_Error (ERR_DROP, \"CM_AdjustAreaPortalState: negative reference count\");\n\t\t}\n\t}\n\n\tCM_FloodAreaConnections ();\n}\n\n/*\n====================\nCM_AreasConnected\n\n====================\n*/\nqboolean\tCM_AreasConnected( int area1, int area2 ) {\n#ifndef BSPC\n\tif ( cm_noAreas->integer ) {\n\t\treturn qtrue;\n\t}\n#endif\n\n\tif ( area1 < 0 || area2 < 0 ) {\n\t\treturn qfalse;\n\t}\n\n\tif (area1 >= cm.numAreas || area2 >= cm.numAreas) {\n\t\tCom_Error (ERR_DROP, \"area >= cm.numAreas\");\n\t}\n\n\tif (cm.areas[area1].floodnum == cm.areas[area2].floodnum) {\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n\n/*\n=================\nCM_WriteAreaBits\n\nWrites a bit vector of all the areas\nthat are in the same flood as the area parameter\nReturns the number of bytes needed to hold all the bits.\n\nThe bits are OR'd in, so you can CM_WriteAreaBits from multiple\nviewpoints and get the union of all visible areas.\n\nThis is used to cull non-visible entities from snapshots\n=================\n*/\nint CM_WriteAreaBits (byte *buffer, int area)\n{\n\tint\t\ti;\n\tint\t\tfloodnum;\n\tint\t\tbytes;\n\n\tbytes = (cm.numAreas+7)>>3;\n\n#ifndef BSPC\n\tif (cm_noAreas->integer || area == -1)\n#else\n\tif ( area == -1)\n#endif\n\t{\t// for debugging, send everything\n\t\tCom_Memset (buffer, 255, bytes);\n\t}\n\telse\n\t{\n\t\tfloodnum = cm.areas[area].floodnum;\n\t\tfor (i=0 ; i<cm.numAreas ; i++)\n\t\t{\n\t\t\tif (cm.areas[i].floodnum == floodnum || area == -1)\n\t\t\t\tbuffer[i>>3] |= 1<<(i&7);\n\t\t}\n\t}\n\n\treturn bytes;\n}\n\n"
  },
  {
    "path": "code/qcommon/cm_trace.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"cm_local.h\"\n\n// always use bbox vs. bbox collision and never capsule vs. bbox or vice versa\n//#define ALWAYS_BBOX_VS_BBOX\n// always use capsule vs. capsule collision and never capsule vs. bbox or vice versa\n//#define ALWAYS_CAPSULE_VS_CAPSULE\n\n//#define CAPSULE_DEBUG\n\n/*\n===============================================================================\n\nBASIC MATH\n\n===============================================================================\n*/\n\n/*\n================\nRotatePoint\n================\n*/\nvoid RotatePoint(vec3_t point, /*const*/ vec3_t matrix[3]) { // bk: FIXME \n\tvec3_t tvec;\n\n\tVectorCopy(point, tvec);\n\tpoint[0] = DotProduct(matrix[0], tvec);\n\tpoint[1] = DotProduct(matrix[1], tvec);\n\tpoint[2] = DotProduct(matrix[2], tvec);\n}\n\n/*\n================\nTransposeMatrix\n================\n*/\nvoid TransposeMatrix(/*const*/ vec3_t matrix[3], vec3_t transpose[3]) { // bk: FIXME\n\tint i, j;\n\tfor (i = 0; i < 3; i++) {\n\t\tfor (j = 0; j < 3; j++) {\n\t\t\ttranspose[i][j] = matrix[j][i];\n\t\t}\n\t}\n}\n\n/*\n================\nCreateRotationMatrix\n================\n*/\nvoid CreateRotationMatrix(const vec3_t angles, vec3_t matrix[3]) {\n\tAngleVectors(angles, matrix[0], matrix[1], matrix[2]);\n\tVectorInverse(matrix[1]);\n}\n\n/*\n================\nCM_ProjectPointOntoVector\n================\n*/\nvoid CM_ProjectPointOntoVector( vec3_t point, vec3_t vStart, vec3_t vDir, vec3_t vProj )\n{\n\tvec3_t pVec;\n\n\tVectorSubtract( point, vStart, pVec );\n\t// project onto the directional vector for this segment\n\tVectorMA( vStart, DotProduct( pVec, vDir ), vDir, vProj );\n}\n\n/*\n================\nCM_DistanceFromLineSquared\n================\n*/\nfloat CM_DistanceFromLineSquared(vec3_t p, vec3_t lp1, vec3_t lp2, vec3_t dir) {\n\tvec3_t proj, t;\n\tint j;\n\n\tCM_ProjectPointOntoVector(p, lp1, dir, proj);\n\tfor (j = 0; j < 3; j++) \n\t\tif ((proj[j] > lp1[j] && proj[j] > lp2[j]) ||\n\t\t\t(proj[j] < lp1[j] && proj[j] < lp2[j]))\n\t\t\tbreak;\n\tif (j < 3) {\n\t\tif (fabs(proj[j] - lp1[j]) < fabs(proj[j] - lp2[j]))\n\t\t\tVectorSubtract(p, lp1, t);\n\t\telse\n\t\t\tVectorSubtract(p, lp2, t);\n\t\treturn VectorLengthSquared(t);\n\t}\n\tVectorSubtract(p, proj, t);\n\treturn VectorLengthSquared(t);\n}\n\n/*\n================\nCM_VectorDistanceSquared\n================\n*/\nfloat CM_VectorDistanceSquared(vec3_t p1, vec3_t p2) {\n\tvec3_t dir;\n\n\tVectorSubtract(p2, p1, dir);\n\treturn VectorLengthSquared(dir);\n}\n\n/*\n================\nSquareRootFloat\n================\n*/\nfloat SquareRootFloat(float number) {\n\tlong i;\n\tfloat x, y;\n\tconst float f = 1.5F;\n\n\tx = number * 0.5F;\n\ty  = number;\n\ti  = * ( long * ) &y;\n\ti  = 0x5f3759df - ( i >> 1 );\n\ty  = * ( float * ) &i;\n\ty  = y * ( f - ( x * y * y ) );\n\ty  = y * ( f - ( x * y * y ) );\n\treturn number * y;\n}\n\n\n/*\n===============================================================================\n\nPOSITION TESTING\n\n===============================================================================\n*/\n\n/*\n================\nCM_TestBoxInBrush\n================\n*/\nvoid CM_TestBoxInBrush( traceWork_t *tw, cbrush_t *brush ) {\n\tint\t\t\ti;\n\tcplane_t\t*plane;\n\tfloat\t\tdist;\n\tfloat\t\td1;\n\tcbrushside_t\t*side;\n\tfloat\t\tt;\n\tvec3_t\t\tstartp;\n\n\tif (!brush->numsides) {\n\t\treturn;\n\t}\n\n\t// special test for axial\n\tif ( tw->bounds[0][0] > brush->bounds[1][0]\n\t\t|| tw->bounds[0][1] > brush->bounds[1][1]\n\t\t|| tw->bounds[0][2] > brush->bounds[1][2]\n\t\t|| tw->bounds[1][0] < brush->bounds[0][0]\n\t\t|| tw->bounds[1][1] < brush->bounds[0][1]\n\t\t|| tw->bounds[1][2] < brush->bounds[0][2]\n\t\t) {\n\t\treturn;\n\t}\n\n   if ( tw->sphere.use ) {\n\t\t// the first six planes are the axial planes, so we only\n\t\t// need to test the remainder\n\t\tfor ( i = 6 ; i < brush->numsides ; i++ ) {\n\t\t\tside = brush->sides + i;\n\t\t\tplane = side->plane;\n\n\t\t\t// adjust the plane distance apropriately for radius\n\t\t\tdist = plane->dist + tw->sphere.radius;\n\t\t\t// find the closest point on the capsule to the plane\n\t\t\tt = DotProduct( plane->normal, tw->sphere.offset );\n\t\t\tif ( t > 0 )\n\t\t\t{\n\t\t\t\tVectorSubtract( tw->start, tw->sphere.offset, startp );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tVectorAdd( tw->start, tw->sphere.offset, startp );\n\t\t\t}\n\t\t\td1 = DotProduct( startp, plane->normal ) - dist;\n\t\t\t// if completely in front of face, no intersection\n\t\t\tif ( d1 > 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// the first six planes are the axial planes, so we only\n\t\t// need to test the remainder\n\t\tfor ( i = 6 ; i < brush->numsides ; i++ ) {\n\t\t\tside = brush->sides + i;\n\t\t\tplane = side->plane;\n\n\t\t\t// adjust the plane distance apropriately for mins/maxs\n\t\t\tdist = plane->dist - DotProduct( tw->offsets[ plane->signbits ], plane->normal );\n\n\t\t\td1 = DotProduct( tw->start, plane->normal ) - dist;\n\n\t\t\t// if completely in front of face, no intersection\n\t\t\tif ( d1 > 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\t// inside this brush\n\ttw->trace.startsolid = tw->trace.allsolid = qtrue;\n\ttw->trace.fraction = 0;\n\ttw->trace.contents = brush->contents;\n}\n\n\n\n/*\n================\nCM_TestInLeaf\n================\n*/\nvoid CM_TestInLeaf( traceWork_t *tw, cLeaf_t *leaf ) {\n\tint\t\t\tk;\n\tint\t\t\tbrushnum;\n\tcbrush_t\t*b;\n\tcPatch_t\t*patch;\n\n\t// test box position against all brushes in the leaf\n\tfor (k=0 ; k<leaf->numLeafBrushes ; k++) {\n\t\tbrushnum = cm.leafbrushes[leaf->firstLeafBrush+k];\n\t\tb = &cm.brushes[brushnum];\n\t\tif (b->checkcount == cm.checkcount) {\n\t\t\tcontinue;\t// already checked this brush in another leaf\n\t\t}\n\t\tb->checkcount = cm.checkcount;\n\n\t\tif ( !(b->contents & tw->contents)) {\n\t\t\tcontinue;\n\t\t}\n\t\t\n\t\tCM_TestBoxInBrush( tw, b );\n\t\tif ( tw->trace.allsolid ) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// test against all patches\n#ifdef BSPC\n\tif (1) {\n#else\n\tif ( !cm_noCurves->integer ) {\n#endif //BSPC\n\t\tfor ( k = 0 ; k < leaf->numLeafSurfaces ; k++ ) {\n\t\t\tpatch = cm.surfaces[ cm.leafsurfaces[ leaf->firstLeafSurface + k ] ];\n\t\t\tif ( !patch ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( patch->checkcount == cm.checkcount ) {\n\t\t\t\tcontinue;\t// already checked this brush in another leaf\n\t\t\t}\n\t\t\tpatch->checkcount = cm.checkcount;\n\n\t\t\tif ( !(patch->contents & tw->contents)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\n\t\t\tif ( CM_PositionTestInPatchCollide( tw, patch->pc ) ) {\n\t\t\t\ttw->trace.startsolid = tw->trace.allsolid = qtrue;\n\t\t\t\ttw->trace.fraction = 0;\n\t\t\t\ttw->trace.contents = patch->contents;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n==================\nCM_TestCapsuleInCapsule\n\ncapsule inside capsule check\n==================\n*/\nvoid CM_TestCapsuleInCapsule( traceWork_t *tw, clipHandle_t model ) {\n\tint i;\n\tvec3_t mins, maxs;\n\tvec3_t top, bottom;\n\tvec3_t p1, p2, tmp;\n\tvec3_t offset, symetricSize[2];\n\tfloat radius, halfwidth, halfheight, offs, r;\n\n\tCM_ModelBounds(model, mins, maxs);\n\n\tVectorAdd(tw->start, tw->sphere.offset, top);\n\tVectorSubtract(tw->start, tw->sphere.offset, bottom);\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\toffset[i] = ( mins[i] + maxs[i] ) * 0.5;\n\t\tsymetricSize[0][i] = mins[i] - offset[i];\n\t\tsymetricSize[1][i] = maxs[i] - offset[i];\n\t}\n\thalfwidth = symetricSize[ 1 ][ 0 ];\n\thalfheight = symetricSize[ 1 ][ 2 ];\n\tradius = ( halfwidth > halfheight ) ? halfheight : halfwidth;\n\toffs = halfheight - radius;\n\n\tr = Square(tw->sphere.radius + radius);\n\t// check if any of the spheres overlap\n\tVectorCopy(offset, p1);\n\tp1[2] += offs;\n\tVectorSubtract(p1, top, tmp);\n\tif ( VectorLengthSquared(tmp) < r ) {\n\t\ttw->trace.startsolid = tw->trace.allsolid = qtrue;\n\t\ttw->trace.fraction = 0;\n\t}\n\tVectorSubtract(p1, bottom, tmp);\n\tif ( VectorLengthSquared(tmp) < r ) {\n\t\ttw->trace.startsolid = tw->trace.allsolid = qtrue;\n\t\ttw->trace.fraction = 0;\n\t}\n\tVectorCopy(offset, p2);\n\tp2[2] -= offs;\n\tVectorSubtract(p2, top, tmp);\n\tif ( VectorLengthSquared(tmp) < r ) {\n\t\ttw->trace.startsolid = tw->trace.allsolid = qtrue;\n\t\ttw->trace.fraction = 0;\n\t}\n\tVectorSubtract(p2, bottom, tmp);\n\tif ( VectorLengthSquared(tmp) < r ) {\n\t\ttw->trace.startsolid = tw->trace.allsolid = qtrue;\n\t\ttw->trace.fraction = 0;\n\t}\n\t// if between cylinder up and lower bounds\n\tif ( (top[2] >= p1[2] && top[2] <= p2[2]) ||\n\t\t(bottom[2] >= p1[2] && bottom[2] <= p2[2]) ) {\n\t\t// 2d coordinates\n\t\ttop[2] = p1[2] = 0;\n\t\t// if the cylinders overlap\n\t\tVectorSubtract(top, p1, tmp);\n\t\tif ( VectorLengthSquared(tmp) < r ) {\n\t\t\ttw->trace.startsolid = tw->trace.allsolid = qtrue;\n\t\t\ttw->trace.fraction = 0;\n\t\t}\n\t}\n}\n\n/*\n==================\nCM_TestBoundingBoxInCapsule\n\nbounding box inside capsule check\n==================\n*/\nvoid CM_TestBoundingBoxInCapsule( traceWork_t *tw, clipHandle_t model ) {\n\tvec3_t mins, maxs, offset, size[2];\n\tclipHandle_t h;\n\tcmodel_t *cmod;\n\tint i;\n\n\t// mins maxs of the capsule\n\tCM_ModelBounds(model, mins, maxs);\n\n\t// offset for capsule center\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\toffset[i] = ( mins[i] + maxs[i] ) * 0.5;\n\t\tsize[0][i] = mins[i] - offset[i];\n\t\tsize[1][i] = maxs[i] - offset[i];\n\t\ttw->start[i] -= offset[i];\n\t\ttw->end[i] -= offset[i];\n\t}\n\n\t// replace the bounding box with the capsule\n\ttw->sphere.use = qtrue;\n\ttw->sphere.radius = ( size[1][0] > size[1][2] ) ? size[1][2]: size[1][0];\n\ttw->sphere.halfheight = size[1][2];\n\tVectorSet( tw->sphere.offset, 0, 0, size[1][2] - tw->sphere.radius );\n\n\t// replace the capsule with the bounding box\n\th = CM_TempBoxModel(tw->size[0], tw->size[1], qfalse);\n\t// calculate collision\n\tcmod = CM_ClipHandleToModel( h );\n\tCM_TestInLeaf( tw, &cmod->leaf );\n}\n\n/*\n==================\nCM_PositionTest\n==================\n*/\n#define\tMAX_POSITION_LEAFS\t1024\nvoid CM_PositionTest( traceWork_t *tw ) {\n\tint\t\tleafs[MAX_POSITION_LEAFS];\n\tint\t\ti;\n\tleafList_t\tll;\n\n\t// identify the leafs we are touching\n\tVectorAdd( tw->start, tw->size[0], ll.bounds[0] );\n\tVectorAdd( tw->start, tw->size[1], ll.bounds[1] );\n\n\tfor (i=0 ; i<3 ; i++) {\n\t\tll.bounds[0][i] -= 1;\n\t\tll.bounds[1][i] += 1;\n\t}\n\n\tll.count = 0;\n\tll.maxcount = MAX_POSITION_LEAFS;\n\tll.list = leafs;\n\tll.storeLeafs = CM_StoreLeafs;\n\tll.lastLeaf = 0;\n\tll.overflowed = qfalse;\n\n\tcm.checkcount++;\n\n\tCM_BoxLeafnums_r( &ll, 0 );\n\n\n\tcm.checkcount++;\n\n\t// test the contents of the leafs\n\tfor (i=0 ; i < ll.count ; i++) {\n\t\tCM_TestInLeaf( tw, &cm.leafs[leafs[i]] );\n\t\tif ( tw->trace.allsolid ) {\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/*\n===============================================================================\n\nTRACING\n\n===============================================================================\n*/\n\n\n/*\n================\nCM_TraceThroughPatch\n================\n*/\n\nvoid CM_TraceThroughPatch( traceWork_t *tw, cPatch_t *patch ) {\n\tfloat\t\toldFrac;\n\n\tc_patch_traces++;\n\n\toldFrac = tw->trace.fraction;\n\n\tCM_TraceThroughPatchCollide( tw, patch->pc );\n\n\tif ( tw->trace.fraction < oldFrac ) {\n\t\ttw->trace.surfaceFlags = patch->surfaceFlags;\n\t\ttw->trace.contents = patch->contents;\n\t}\n}\n\n/*\n================\nCM_TraceThroughBrush\n================\n*/\nvoid CM_TraceThroughBrush( traceWork_t *tw, cbrush_t *brush ) {\n\tint\t\t\ti;\n\tcplane_t\t*plane, *clipplane;\n\tfloat\t\tdist;\n\tfloat\t\tenterFrac, leaveFrac;\n\tfloat\t\td1, d2;\n\tqboolean\tgetout, startout;\n\tfloat\t\tf;\n\tcbrushside_t\t*side, *leadside;\n\tfloat\t\tt;\n\tvec3_t\t\tstartp;\n\tvec3_t\t\tendp;\n\n\tenterFrac = -1.0;\n\tleaveFrac = 1.0;\n\tclipplane = NULL;\n\n\tif ( !brush->numsides ) {\n\t\treturn;\n\t}\n\n\tc_brush_traces++;\n\n\tgetout = qfalse;\n\tstartout = qfalse;\n\n\tleadside = NULL;\n\n\tif ( tw->sphere.use ) {\n\t\t//\n\t\t// compare the trace against all planes of the brush\n\t\t// find the latest time the trace crosses a plane towards the interior\n\t\t// and the earliest time the trace crosses a plane towards the exterior\n\t\t//\n\t\tfor (i = 0; i < brush->numsides; i++) {\n\t\t\tside = brush->sides + i;\n\t\t\tplane = side->plane;\n\n\t\t\t// adjust the plane distance apropriately for radius\n\t\t\tdist = plane->dist + tw->sphere.radius;\n\n\t\t\t// find the closest point on the capsule to the plane\n\t\t\tt = DotProduct( plane->normal, tw->sphere.offset );\n\t\t\tif ( t > 0 )\n\t\t\t{\n\t\t\t\tVectorSubtract( tw->start, tw->sphere.offset, startp );\n\t\t\t\tVectorSubtract( tw->end, tw->sphere.offset, endp );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tVectorAdd( tw->start, tw->sphere.offset, startp );\n\t\t\t\tVectorAdd( tw->end, tw->sphere.offset, endp );\n\t\t\t}\n\n\t\t\td1 = DotProduct( startp, plane->normal ) - dist;\n\t\t\td2 = DotProduct( endp, plane->normal ) - dist;\n\n\t\t\tif (d2 > 0) {\n\t\t\t\tgetout = qtrue;\t// endpoint is not in solid\n\t\t\t}\n\t\t\tif (d1 > 0) {\n\t\t\t\tstartout = qtrue;\n\t\t\t}\n\n\t\t\t// if completely in front of face, no intersection with the entire brush\n\t\t\tif (d1 > 0 && ( d2 >= SURFACE_CLIP_EPSILON || d2 >= d1 )  ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// if it doesn't cross the plane, the plane isn't relevent\n\t\t\tif (d1 <= 0 && d2 <= 0 ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// crosses face\n\t\t\tif (d1 > d2) {\t// enter\n\t\t\t\tf = (d1-SURFACE_CLIP_EPSILON) / (d1-d2);\n\t\t\t\tif ( f < 0 ) {\n\t\t\t\t\tf = 0;\n\t\t\t\t}\n\t\t\t\tif (f > enterFrac) {\n\t\t\t\t\tenterFrac = f;\n\t\t\t\t\tclipplane = plane;\n\t\t\t\t\tleadside = side;\n\t\t\t\t}\n\t\t\t} else {\t// leave\n\t\t\t\tf = (d1+SURFACE_CLIP_EPSILON) / (d1-d2);\n\t\t\t\tif ( f > 1 ) {\n\t\t\t\t\tf = 1;\n\t\t\t\t}\n\t\t\t\tif (f < leaveFrac) {\n\t\t\t\t\tleaveFrac = f;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t//\n\t\t// compare the trace against all planes of the brush\n\t\t// find the latest time the trace crosses a plane towards the interior\n\t\t// and the earliest time the trace crosses a plane towards the exterior\n\t\t//\n\t\tfor (i = 0; i < brush->numsides; i++) {\n\t\t\tside = brush->sides + i;\n\t\t\tplane = side->plane;\n\n\t\t\t// adjust the plane distance apropriately for mins/maxs\n\t\t\tdist = plane->dist - DotProduct( tw->offsets[ plane->signbits ], plane->normal );\n\n\t\t\td1 = DotProduct( tw->start, plane->normal ) - dist;\n\t\t\td2 = DotProduct( tw->end, plane->normal ) - dist;\n\n\t\t\tif (d2 > 0) {\n\t\t\t\tgetout = qtrue;\t// endpoint is not in solid\n\t\t\t}\n\t\t\tif (d1 > 0) {\n\t\t\t\tstartout = qtrue;\n\t\t\t}\n\n\t\t\t// if completely in front of face, no intersection with the entire brush\n\t\t\tif (d1 > 0 && ( d2 >= SURFACE_CLIP_EPSILON || d2 >= d1 )  ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// if it doesn't cross the plane, the plane isn't relevent\n\t\t\tif (d1 <= 0 && d2 <= 0 ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// crosses face\n\t\t\tif (d1 > d2) {\t// enter\n\t\t\t\tf = (d1-SURFACE_CLIP_EPSILON) / (d1-d2);\n\t\t\t\tif ( f < 0 ) {\n\t\t\t\t\tf = 0;\n\t\t\t\t}\n\t\t\t\tif (f > enterFrac) {\n\t\t\t\t\tenterFrac = f;\n\t\t\t\t\tclipplane = plane;\n\t\t\t\t\tleadside = side;\n\t\t\t\t}\n\t\t\t} else {\t// leave\n\t\t\t\tf = (d1+SURFACE_CLIP_EPSILON) / (d1-d2);\n\t\t\t\tif ( f > 1 ) {\n\t\t\t\t\tf = 1;\n\t\t\t\t}\n\t\t\t\tif (f < leaveFrac) {\n\t\t\t\t\tleaveFrac = f;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t//\n\t// all planes have been checked, and the trace was not\n\t// completely outside the brush\n\t//\n\tif (!startout) {\t// original point was inside brush\n\t\ttw->trace.startsolid = qtrue;\n\t\tif (!getout) {\n\t\t\ttw->trace.allsolid = qtrue;\n\t\t\ttw->trace.fraction = 0;\n\t\t\ttw->trace.contents = brush->contents;\n\t\t}\n\t\treturn;\n\t}\n\t\n\tif (enterFrac < leaveFrac) {\n\t\tif (enterFrac > -1 && enterFrac < tw->trace.fraction) {\n\t\t\tif (enterFrac < 0) {\n\t\t\t\tenterFrac = 0;\n\t\t\t}\n\t\t\ttw->trace.fraction = enterFrac;\n\t\t\ttw->trace.plane = *clipplane;\n\t\t\ttw->trace.surfaceFlags = leadside->surfaceFlags;\n\t\t\ttw->trace.contents = brush->contents;\n\t\t}\n\t}\n}\n\n/*\n================\nCM_TraceThroughLeaf\n================\n*/\nvoid CM_TraceThroughLeaf( traceWork_t *tw, cLeaf_t *leaf ) {\n\tint\t\t\tk;\n\tint\t\t\tbrushnum;\n\tcbrush_t\t*b;\n\tcPatch_t\t*patch;\n\n\t// trace line against all brushes in the leaf\n\tfor ( k = 0 ; k < leaf->numLeafBrushes ; k++ ) {\n\t\tbrushnum = cm.leafbrushes[leaf->firstLeafBrush+k];\n\n\t\tb = &cm.brushes[brushnum];\n\t\tif ( b->checkcount == cm.checkcount ) {\n\t\t\tcontinue;\t// already checked this brush in another leaf\n\t\t}\n\t\tb->checkcount = cm.checkcount;\n\n\t\tif ( !(b->contents & tw->contents) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tCM_TraceThroughBrush( tw, b );\n\t\tif ( !tw->trace.fraction ) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// trace line against all patches in the leaf\n#ifdef BSPC\n\tif (1) {\n#else\n\tif ( !cm_noCurves->integer ) {\n#endif\n\t\tfor ( k = 0 ; k < leaf->numLeafSurfaces ; k++ ) {\n\t\t\tpatch = cm.surfaces[ cm.leafsurfaces[ leaf->firstLeafSurface + k ] ];\n\t\t\tif ( !patch ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( patch->checkcount == cm.checkcount ) {\n\t\t\t\tcontinue;\t// already checked this patch in another leaf\n\t\t\t}\n\t\t\tpatch->checkcount = cm.checkcount;\n\n\t\t\tif ( !(patch->contents & tw->contents) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\n\t\t\tCM_TraceThroughPatch( tw, patch );\n\t\t\tif ( !tw->trace.fraction ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n}\n\n#define RADIUS_EPSILON\t\t1.0f\n\n/*\n================\nCM_TraceThroughSphere\n\nget the first intersection of the ray with the sphere\n================\n*/\nvoid CM_TraceThroughSphere( traceWork_t *tw, vec3_t origin, float radius, vec3_t start, vec3_t end ) {\n\tfloat l1, l2, length, scale, fraction;\n\tfloat a, b, c, d, sqrtd;\n\tvec3_t v1, dir, intersection;\n\n\t// if inside the sphere\n\tVectorSubtract(start, origin, dir);\n\tl1 = VectorLengthSquared(dir);\n\tif (l1 < Square(radius)) {\n\t\ttw->trace.fraction = 0;\n\t\ttw->trace.startsolid = qtrue;\n\t\t// test for allsolid\n\t\tVectorSubtract(end, origin, dir);\n\t\tl1 = VectorLengthSquared(dir);\n\t\tif (l1 < Square(radius)) {\n\t\t\ttw->trace.allsolid = qtrue;\n\t\t}\n\t\treturn;\n\t}\n\t//\n\tVectorSubtract(end, start, dir);\n\tlength = VectorNormalize(dir);\n\t//\n\tl1 = CM_DistanceFromLineSquared(origin, start, end, dir);\n\tVectorSubtract(end, origin, v1);\n\tl2 = VectorLengthSquared(v1);\n\t// if no intersection with the sphere and the end point is at least an epsilon away\n\tif (l1 >= Square(radius) && l2 > Square(radius+SURFACE_CLIP_EPSILON)) {\n\t\treturn;\n\t}\n\t//\n\t//\t| origin - (start + t * dir) | = radius\n\t//\ta = dir[0]^2 + dir[1]^2 + dir[2]^2;\n\t//\tb = 2 * (dir[0] * (start[0] - origin[0]) + dir[1] * (start[1] - origin[1]) + dir[2] * (start[2] - origin[2]));\n\t//\tc = (start[0] - origin[0])^2 + (start[1] - origin[1])^2 + (start[2] - origin[2])^2 - radius^2;\n\t//\n\tVectorSubtract(start, origin, v1);\n\t// dir is normalized so a = 1\n\ta = 1.0f;//dir[0] * dir[0] + dir[1] * dir[1] + dir[2] * dir[2];\n\tb = 2.0f * (dir[0] * v1[0] + dir[1] * v1[1] + dir[2] * v1[2]);\n\tc = v1[0] * v1[0] + v1[1] * v1[1] + v1[2] * v1[2] - (radius+RADIUS_EPSILON) * (radius+RADIUS_EPSILON);\n\n\td = b * b - 4.0f * c;// * a;\n\tif (d > 0) {\n\t\tsqrtd = SquareRootFloat(d);\n\t\t// = (- b + sqrtd) * 0.5f; // / (2.0f * a);\n\t\tfraction = (- b - sqrtd) * 0.5f; // / (2.0f * a);\n\t\t//\n\t\tif (fraction < 0) {\n\t\t\tfraction = 0;\n\t\t}\n\t\telse {\n\t\t\tfraction /= length;\n\t\t}\n\t\tif ( fraction < tw->trace.fraction ) {\n\t\t\ttw->trace.fraction = fraction;\n\t\t\tVectorSubtract(end, start, dir);\n\t\t\tVectorMA(start, fraction, dir, intersection);\n\t\t\tVectorSubtract(intersection, origin, dir);\n\t\t\t#ifdef CAPSULE_DEBUG\n\t\t\t\tl2 = VectorLength(dir);\n\t\t\t\tif (l2 < radius) {\n\t\t\t\t\tint bah = 1;\n\t\t\t\t}\n\t\t\t#endif\n\t\t\tscale = 1 / (radius+RADIUS_EPSILON);\n\t\t\tVectorScale(dir, scale, dir);\n\t\t\tVectorCopy(dir, tw->trace.plane.normal);\n\t\t\tVectorAdd( tw->modelOrigin, intersection, intersection);\n\t\t\ttw->trace.plane.dist = DotProduct(tw->trace.plane.normal, intersection);\n\t\t\ttw->trace.contents = CONTENTS_BODY;\n\t\t}\n\t}\n\telse if (d == 0) {\n\t\t//t1 = (- b ) / 2;\n\t\t// slide along the sphere\n\t}\n\t// no intersection at all\n}\n\n/*\n================\nCM_TraceThroughVerticalCylinder\n\nget the first intersection of the ray with the cylinder\nthe cylinder extends halfheight above and below the origin\n================\n*/\nvoid CM_TraceThroughVerticalCylinder( traceWork_t *tw, vec3_t origin, float radius, float halfheight, vec3_t start, vec3_t end) {\n\tfloat length, scale, fraction, l1, l2;\n\tfloat a, b, c, d, sqrtd;\n\tvec3_t v1, dir, start2d, end2d, org2d, intersection;\n\n\t// 2d coordinates\n\tVectorSet(start2d, start[0], start[1], 0);\n\tVectorSet(end2d, end[0], end[1], 0);\n\tVectorSet(org2d, origin[0], origin[1], 0);\n\t// if between lower and upper cylinder bounds\n\tif (start[2] <= origin[2] + halfheight &&\n\t\t\t\tstart[2] >= origin[2] - halfheight) {\n\t\t// if inside the cylinder\n\t\tVectorSubtract(start2d, org2d, dir);\n\t\tl1 = VectorLengthSquared(dir);\n\t\tif (l1 < Square(radius)) {\n\t\t\ttw->trace.fraction = 0;\n\t\t\ttw->trace.startsolid = qtrue;\n\t\t\tVectorSubtract(end2d, org2d, dir);\n\t\t\tl1 = VectorLengthSquared(dir);\n\t\t\tif (l1 < Square(radius)) {\n\t\t\t\ttw->trace.allsolid = qtrue;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t}\n\t//\n\tVectorSubtract(end2d, start2d, dir);\n\tlength = VectorNormalize(dir);\n\t//\n\tl1 = CM_DistanceFromLineSquared(org2d, start2d, end2d, dir);\n\tVectorSubtract(end2d, org2d, v1);\n\tl2 = VectorLengthSquared(v1);\n\t// if no intersection with the cylinder and the end point is at least an epsilon away\n\tif (l1 >= Square(radius) && l2 > Square(radius+SURFACE_CLIP_EPSILON)) {\n\t\treturn;\n\t}\n\t//\n\t//\n\t// (start[0] - origin[0] - t * dir[0]) ^ 2 + (start[1] - origin[1] - t * dir[1]) ^ 2 = radius ^ 2\n\t// (v1[0] + t * dir[0]) ^ 2 + (v1[1] + t * dir[1]) ^ 2 = radius ^ 2;\n\t// v1[0] ^ 2 + 2 * v1[0] * t * dir[0] + (t * dir[0]) ^ 2 +\n\t//\t\t\t\t\t\tv1[1] ^ 2 + 2 * v1[1] * t * dir[1] + (t * dir[1]) ^ 2 = radius ^ 2\n\t// t ^ 2 * (dir[0] ^ 2 + dir[1] ^ 2) + t * (2 * v1[0] * dir[0] + 2 * v1[1] * dir[1]) +\n\t//\t\t\t\t\t\tv1[0] ^ 2 + v1[1] ^ 2 - radius ^ 2 = 0\n\t//\n\tVectorSubtract(start, origin, v1);\n\t// dir is normalized so we can use a = 1\n\ta = 1.0f;// * (dir[0] * dir[0] + dir[1] * dir[1]);\n\tb = 2.0f * (v1[0] * dir[0] + v1[1] * dir[1]);\n\tc = v1[0] * v1[0] + v1[1] * v1[1] - (radius+RADIUS_EPSILON) * (radius+RADIUS_EPSILON);\n\n\td = b * b - 4.0f * c;// * a;\n\tif (d > 0) {\n\t\tsqrtd = SquareRootFloat(d);\n\t\t// = (- b + sqrtd) * 0.5f;// / (2.0f * a);\n\t\tfraction = (- b - sqrtd) * 0.5f;// / (2.0f * a);\n\t\t//\n\t\tif (fraction < 0) {\n\t\t\tfraction = 0;\n\t\t}\n\t\telse {\n\t\t\tfraction /= length;\n\t\t}\n\t\tif ( fraction < tw->trace.fraction ) {\n\t\t\tVectorSubtract(end, start, dir);\n\t\t\tVectorMA(start, fraction, dir, intersection);\n\t\t\t// if the intersection is between the cylinder lower and upper bound\n\t\t\tif (intersection[2] <= origin[2] + halfheight &&\n\t\t\t\t\t\tintersection[2] >= origin[2] - halfheight) {\n\t\t\t\t//\n\t\t\t\ttw->trace.fraction = fraction;\n\t\t\t\tVectorSubtract(intersection, origin, dir);\n\t\t\t\tdir[2] = 0;\n\t\t\t\t#ifdef CAPSULE_DEBUG\n\t\t\t\t\tl2 = VectorLength(dir);\n\t\t\t\t\tif (l2 <= radius) {\n\t\t\t\t\t\tint bah = 1;\n\t\t\t\t\t}\n\t\t\t\t#endif\n\t\t\t\tscale = 1 / (radius+RADIUS_EPSILON);\n\t\t\t\tVectorScale(dir, scale, dir);\n\t\t\t\tVectorCopy(dir, tw->trace.plane.normal);\n\t\t\t\tVectorAdd( tw->modelOrigin, intersection, intersection);\n\t\t\t\ttw->trace.plane.dist = DotProduct(tw->trace.plane.normal, intersection);\n\t\t\t\ttw->trace.contents = CONTENTS_BODY;\n\t\t\t}\n\t\t}\n\t}\n\telse if (d == 0) {\n\t\t//t[0] = (- b ) / 2 * a;\n\t\t// slide along the cylinder\n\t}\n\t// no intersection at all\n}\n\n/*\n================\nCM_TraceCapsuleThroughCapsule\n\ncapsule vs. capsule collision (not rotated)\n================\n*/\nvoid CM_TraceCapsuleThroughCapsule( traceWork_t *tw, clipHandle_t model ) {\n\tint i;\n\tvec3_t mins, maxs;\n\tvec3_t top, bottom, starttop, startbottom, endtop, endbottom;\n\tvec3_t offset, symetricSize[2];\n\tfloat radius, halfwidth, halfheight, offs, h;\n\n\tCM_ModelBounds(model, mins, maxs);\n\t// test trace bounds vs. capsule bounds\n\tif ( tw->bounds[0][0] > maxs[0] + RADIUS_EPSILON\n\t\t|| tw->bounds[0][1] > maxs[1] + RADIUS_EPSILON\n\t\t|| tw->bounds[0][2] > maxs[2] + RADIUS_EPSILON\n\t\t|| tw->bounds[1][0] < mins[0] - RADIUS_EPSILON\n\t\t|| tw->bounds[1][1] < mins[1] - RADIUS_EPSILON\n\t\t|| tw->bounds[1][2] < mins[2] - RADIUS_EPSILON\n\t\t) {\n\t\treturn;\n\t}\n\t// top origin and bottom origin of each sphere at start and end of trace\n\tVectorAdd(tw->start, tw->sphere.offset, starttop);\n\tVectorSubtract(tw->start, tw->sphere.offset, startbottom);\n\tVectorAdd(tw->end, tw->sphere.offset, endtop);\n\tVectorSubtract(tw->end, tw->sphere.offset, endbottom);\n\n\t// calculate top and bottom of the capsule spheres to collide with\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\toffset[i] = ( mins[i] + maxs[i] ) * 0.5;\n\t\tsymetricSize[0][i] = mins[i] - offset[i];\n\t\tsymetricSize[1][i] = maxs[i] - offset[i];\n\t}\n\thalfwidth = symetricSize[ 1 ][ 0 ];\n\thalfheight = symetricSize[ 1 ][ 2 ];\n\tradius = ( halfwidth > halfheight ) ? halfheight : halfwidth;\n\toffs = halfheight - radius;\n\tVectorCopy(offset, top);\n\ttop[2] += offs;\n\tVectorCopy(offset, bottom);\n\tbottom[2] -= offs;\n\t// expand radius of spheres\n\tradius += tw->sphere.radius;\n\t// if there is horizontal movement\n\tif ( tw->start[0] != tw->end[0] || tw->start[1] != tw->end[1] ) {\n\t\t// height of the expanded cylinder is the height of both cylinders minus the radius of both spheres\n\t\th = halfheight + tw->sphere.halfheight - radius;\n\t\t// if the cylinder has a height\n\t\tif ( h > 0 ) {\n\t\t\t// test for collisions between the cylinders\n\t\t\tCM_TraceThroughVerticalCylinder(tw, offset, radius, h, tw->start, tw->end);\n\t\t}\n\t}\n\t// test for collision between the spheres\n\tCM_TraceThroughSphere(tw, top, radius, startbottom, endbottom);\n\tCM_TraceThroughSphere(tw, bottom, radius, starttop, endtop);\n}\n\n/*\n================\nCM_TraceBoundingBoxThroughCapsule\n\nbounding box vs. capsule collision\n================\n*/\nvoid CM_TraceBoundingBoxThroughCapsule( traceWork_t *tw, clipHandle_t model ) {\n\tvec3_t mins, maxs, offset, size[2];\n\tclipHandle_t h;\n\tcmodel_t *cmod;\n\tint i;\n\n\t// mins maxs of the capsule\n\tCM_ModelBounds(model, mins, maxs);\n\n\t// offset for capsule center\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\toffset[i] = ( mins[i] + maxs[i] ) * 0.5;\n\t\tsize[0][i] = mins[i] - offset[i];\n\t\tsize[1][i] = maxs[i] - offset[i];\n\t\ttw->start[i] -= offset[i];\n\t\ttw->end[i] -= offset[i];\n\t}\n\n\t// replace the bounding box with the capsule\n\ttw->sphere.use = qtrue;\n\ttw->sphere.radius = ( size[1][0] > size[1][2] ) ? size[1][2]: size[1][0];\n\ttw->sphere.halfheight = size[1][2];\n\tVectorSet( tw->sphere.offset, 0, 0, size[1][2] - tw->sphere.radius );\n\n\t// replace the capsule with the bounding box\n\th = CM_TempBoxModel(tw->size[0], tw->size[1], qfalse);\n\t// calculate collision\n\tcmod = CM_ClipHandleToModel( h );\n\tCM_TraceThroughLeaf( tw, &cmod->leaf );\n}\n\n//=========================================================================================\n\n/*\n==================\nCM_TraceThroughTree\n\nTraverse all the contacted leafs from the start to the end position.\nIf the trace is a point, they will be exactly in order, but for larger\ntrace volumes it is possible to hit something in a later leaf with\na smaller intercept fraction.\n==================\n*/\nvoid CM_TraceThroughTree( traceWork_t *tw, int num, float p1f, float p2f, vec3_t p1, vec3_t p2) {\n\tcNode_t\t\t*node;\n\tcplane_t\t*plane;\n\tfloat\t\tt1, t2, offset;\n\tfloat\t\tfrac, frac2;\n\tfloat\t\tidist;\n\tvec3_t\t\tmid;\n\tint\t\t\tside;\n\tfloat\t\tmidf;\n\n\tif (tw->trace.fraction <= p1f) {\n\t\treturn;\t\t// already hit something nearer\n\t}\n\n\t// if < 0, we are in a leaf node\n\tif (num < 0) {\n\t\tCM_TraceThroughLeaf( tw, &cm.leafs[-1-num] );\n\t\treturn;\n\t}\n\n\t//\n\t// find the point distances to the seperating plane\n\t// and the offset for the size of the box\n\t//\n\tnode = cm.nodes + num;\n\tplane = node->plane;\n\n\t// adjust the plane distance apropriately for mins/maxs\n\tif ( plane->type < 3 ) {\n\t\tt1 = p1[plane->type] - plane->dist;\n\t\tt2 = p2[plane->type] - plane->dist;\n\t\toffset = tw->extents[plane->type];\n\t} else {\n\t\tt1 = DotProduct (plane->normal, p1) - plane->dist;\n\t\tt2 = DotProduct (plane->normal, p2) - plane->dist;\n\t\tif ( tw->isPoint ) {\n\t\t\toffset = 0;\n\t\t} else {\n#if 0 // bk010201 - DEAD\n\t\t\t// an axial brush right behind a slanted bsp plane\n\t\t\t// will poke through when expanded, so adjust\n\t\t\t// by sqrt(3)\n\t\t\toffset = fabs(tw->extents[0]*plane->normal[0]) +\n\t\t\t\tfabs(tw->extents[1]*plane->normal[1]) +\n\t\t\t\tfabs(tw->extents[2]*plane->normal[2]);\n\n\t\t\toffset *= 2;\n\t\t\toffset = tw->maxOffset;\n#endif\n\t\t\t// this is silly\n\t\t\toffset = 2048;\n\t\t}\n\t}\n\n\t// see which sides we need to consider\n\tif ( t1 >= offset + 1 && t2 >= offset + 1 ) {\n\t\tCM_TraceThroughTree( tw, node->children[0], p1f, p2f, p1, p2 );\n\t\treturn;\n\t}\n\tif ( t1 < -offset - 1 && t2 < -offset - 1 ) {\n\t\tCM_TraceThroughTree( tw, node->children[1], p1f, p2f, p1, p2 );\n\t\treturn;\n\t}\n\n\t// put the crosspoint SURFACE_CLIP_EPSILON pixels on the near side\n\tif ( t1 < t2 ) {\n\t\tidist = 1.0/(t1-t2);\n\t\tside = 1;\n\t\tfrac2 = (t1 + offset + SURFACE_CLIP_EPSILON)*idist;\n\t\tfrac = (t1 - offset + SURFACE_CLIP_EPSILON)*idist;\n\t} else if (t1 > t2) {\n\t\tidist = 1.0/(t1-t2);\n\t\tside = 0;\n\t\tfrac2 = (t1 - offset - SURFACE_CLIP_EPSILON)*idist;\n\t\tfrac = (t1 + offset + SURFACE_CLIP_EPSILON)*idist;\n\t} else {\n\t\tside = 0;\n\t\tfrac = 1;\n\t\tfrac2 = 0;\n\t}\n\n\t// move up to the node\n\tif ( frac < 0 ) {\n\t\tfrac = 0;\n\t}\n\tif ( frac > 1 ) {\n\t\tfrac = 1;\n\t}\n\t\t\n\tmidf = p1f + (p2f - p1f)*frac;\n\n\tmid[0] = p1[0] + frac*(p2[0] - p1[0]);\n\tmid[1] = p1[1] + frac*(p2[1] - p1[1]);\n\tmid[2] = p1[2] + frac*(p2[2] - p1[2]);\n\n\tCM_TraceThroughTree( tw, node->children[side], p1f, midf, p1, mid );\n\n\n\t// go past the node\n\tif ( frac2 < 0 ) {\n\t\tfrac2 = 0;\n\t}\n\tif ( frac2 > 1 ) {\n\t\tfrac2 = 1;\n\t}\n\t\t\n\tmidf = p1f + (p2f - p1f)*frac2;\n\n\tmid[0] = p1[0] + frac2*(p2[0] - p1[0]);\n\tmid[1] = p1[1] + frac2*(p2[1] - p1[1]);\n\tmid[2] = p1[2] + frac2*(p2[2] - p1[2]);\n\n\tCM_TraceThroughTree( tw, node->children[side^1], midf, p2f, mid, p2 );\n}\n\n\n//======================================================================\n\n\n/*\n==================\nCM_Trace\n==================\n*/\nvoid CM_Trace( trace_t *results, const vec3_t start, const vec3_t end, vec3_t mins, vec3_t maxs,\n\t\t\t\t\t\t  clipHandle_t model, const vec3_t origin, int brushmask, int capsule, sphere_t *sphere ) {\n\tint\t\t\ti;\n\ttraceWork_t\ttw;\n\tvec3_t\t\toffset;\n\tcmodel_t\t*cmod;\n\n\tcmod = CM_ClipHandleToModel( model );\n\n\tcm.checkcount++;\t\t// for multi-check avoidance\n\n\tc_traces++;\t\t\t\t// for statistics, may be zeroed\n\n\t// fill in a default trace\n\tCom_Memset( &tw, 0, sizeof(tw) );\n\ttw.trace.fraction = 1;\t// assume it goes the entire distance until shown otherwise\n\tVectorCopy(origin, tw.modelOrigin);\n\n\tif (!cm.numNodes) {\n\t\t*results = tw.trace;\n\n\t\treturn;\t// map not loaded, shouldn't happen\n\t}\n\n\t// allow NULL to be passed in for 0,0,0\n\tif ( !mins ) {\n\t\tmins = vec3_origin;\n\t}\n\tif ( !maxs ) {\n\t\tmaxs = vec3_origin;\n\t}\n\n\t// set basic parms\n\ttw.contents = brushmask;\n\n\t// adjust so that mins and maxs are always symetric, which\n\t// avoids some complications with plane expanding of rotated\n\t// bmodels\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\toffset[i] = ( mins[i] + maxs[i] ) * 0.5;\n\t\ttw.size[0][i] = mins[i] - offset[i];\n\t\ttw.size[1][i] = maxs[i] - offset[i];\n\t\ttw.start[i] = start[i] + offset[i];\n\t\ttw.end[i] = end[i] + offset[i];\n\t}\n\n\t// if a sphere is already specified\n\tif ( sphere ) {\n\t\ttw.sphere = *sphere;\n\t}\n\telse {\n\t\ttw.sphere.use = capsule;\n\t\ttw.sphere.radius = ( tw.size[1][0] > tw.size[1][2] ) ? tw.size[1][2]: tw.size[1][0];\n\t\ttw.sphere.halfheight = tw.size[1][2];\n\t\tVectorSet( tw.sphere.offset, 0, 0, tw.size[1][2] - tw.sphere.radius );\n\t}\n\n\ttw.maxOffset = tw.size[1][0] + tw.size[1][1] + tw.size[1][2];\n\n\t// tw.offsets[signbits] = vector to apropriate corner from origin\n\ttw.offsets[0][0] = tw.size[0][0];\n\ttw.offsets[0][1] = tw.size[0][1];\n\ttw.offsets[0][2] = tw.size[0][2];\n\n\ttw.offsets[1][0] = tw.size[1][0];\n\ttw.offsets[1][1] = tw.size[0][1];\n\ttw.offsets[1][2] = tw.size[0][2];\n\n\ttw.offsets[2][0] = tw.size[0][0];\n\ttw.offsets[2][1] = tw.size[1][1];\n\ttw.offsets[2][2] = tw.size[0][2];\n\n\ttw.offsets[3][0] = tw.size[1][0];\n\ttw.offsets[3][1] = tw.size[1][1];\n\ttw.offsets[3][2] = tw.size[0][2];\n\n\ttw.offsets[4][0] = tw.size[0][0];\n\ttw.offsets[4][1] = tw.size[0][1];\n\ttw.offsets[4][2] = tw.size[1][2];\n\n\ttw.offsets[5][0] = tw.size[1][0];\n\ttw.offsets[5][1] = tw.size[0][1];\n\ttw.offsets[5][2] = tw.size[1][2];\n\n\ttw.offsets[6][0] = tw.size[0][0];\n\ttw.offsets[6][1] = tw.size[1][1];\n\ttw.offsets[6][2] = tw.size[1][2];\n\n\ttw.offsets[7][0] = tw.size[1][0];\n\ttw.offsets[7][1] = tw.size[1][1];\n\ttw.offsets[7][2] = tw.size[1][2];\n\n\t//\n\t// calculate bounds\n\t//\n\tif ( tw.sphere.use ) {\n\t\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\t\tif ( tw.start[i] < tw.end[i] ) {\n\t\t\t\ttw.bounds[0][i] = tw.start[i] - fabs(tw.sphere.offset[i]) - tw.sphere.radius;\n\t\t\t\ttw.bounds[1][i] = tw.end[i] + fabs(tw.sphere.offset[i]) + tw.sphere.radius;\n\t\t\t} else {\n\t\t\t\ttw.bounds[0][i] = tw.end[i] - fabs(tw.sphere.offset[i]) - tw.sphere.radius;\n\t\t\t\ttw.bounds[1][i] = tw.start[i] + fabs(tw.sphere.offset[i]) + tw.sphere.radius;\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\t\tif ( tw.start[i] < tw.end[i] ) {\n\t\t\t\ttw.bounds[0][i] = tw.start[i] + tw.size[0][i];\n\t\t\t\ttw.bounds[1][i] = tw.end[i] + tw.size[1][i];\n\t\t\t} else {\n\t\t\t\ttw.bounds[0][i] = tw.end[i] + tw.size[0][i];\n\t\t\t\ttw.bounds[1][i] = tw.start[i] + tw.size[1][i];\n\t\t\t}\n\t\t}\n\t}\n\n\t//\n\t// check for position test special case\n\t//\n\tif (start[0] == end[0] && start[1] == end[1] && start[2] == end[2]) {\n\t\tif ( model ) {\n#ifdef ALWAYS_BBOX_VS_BBOX // bk010201 - FIXME - compile time flag?\n\t\t\tif ( model == BOX_MODEL_HANDLE || model == CAPSULE_MODEL_HANDLE) {\n\t\t\t\ttw.sphere.use = qfalse;\n\t\t\t\tCM_TestInLeaf( &tw, &cmod->leaf );\n\t\t\t}\n\t\t\telse\n#elif defined(ALWAYS_CAPSULE_VS_CAPSULE)\n\t\t\tif ( model == BOX_MODEL_HANDLE || model == CAPSULE_MODEL_HANDLE) {\n\t\t\t\tCM_TestCapsuleInCapsule( &tw, model );\n\t\t\t}\n\t\t\telse\n#endif\n\t\t\tif ( model == CAPSULE_MODEL_HANDLE ) {\n\t\t\t\tif ( tw.sphere.use ) {\n\t\t\t\t\tCM_TestCapsuleInCapsule( &tw, model );\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tCM_TestBoundingBoxInCapsule( &tw, model );\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tCM_TestInLeaf( &tw, &cmod->leaf );\n\t\t\t}\n\t\t} else {\n\t\t\tCM_PositionTest( &tw );\n\t\t}\n\t} else {\n\t\t//\n\t\t// check for point special case\n\t\t//\n\t\tif ( tw.size[0][0] == 0 && tw.size[0][1] == 0 && tw.size[0][2] == 0 ) {\n\t\t\ttw.isPoint = qtrue;\n\t\t\tVectorClear( tw.extents );\n\t\t} else {\n\t\t\ttw.isPoint = qfalse;\n\t\t\ttw.extents[0] = tw.size[1][0];\n\t\t\ttw.extents[1] = tw.size[1][1];\n\t\t\ttw.extents[2] = tw.size[1][2];\n\t\t}\n\n\t\t//\n\t\t// general sweeping through world\n\t\t//\n\t\tif ( model ) {\n#ifdef ALWAYS_BBOX_VS_BBOX\n\t\t\tif ( model == BOX_MODEL_HANDLE || model == CAPSULE_MODEL_HANDLE) {\n\t\t\t\ttw.sphere.use = qfalse;\n\t\t\t\tCM_TraceThroughLeaf( &tw, &cmod->leaf );\n\t\t\t}\n\t\t\telse\n#elif defined(ALWAYS_CAPSULE_VS_CAPSULE)\n\t\t\tif ( model == BOX_MODEL_HANDLE || model == CAPSULE_MODEL_HANDLE) {\n\t\t\t\tCM_TraceCapsuleThroughCapsule( &tw, model );\n\t\t\t}\n\t\t\telse\n#endif\n\t\t\tif ( model == CAPSULE_MODEL_HANDLE ) {\n\t\t\t\tif ( tw.sphere.use ) {\n\t\t\t\t\tCM_TraceCapsuleThroughCapsule( &tw, model );\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tCM_TraceBoundingBoxThroughCapsule( &tw, model );\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tCM_TraceThroughLeaf( &tw, &cmod->leaf );\n\t\t\t}\n\t\t} else {\n\t\t\tCM_TraceThroughTree( &tw, 0, 0, 1, tw.start, tw.end );\n\t\t}\n\t}\n\n\t// generate endpos from the original, unmodified start/end\n\tif ( tw.trace.fraction == 1 ) {\n\t\tVectorCopy (end, tw.trace.endpos);\n\t} else {\n\t\tfor ( i=0 ; i<3 ; i++ ) {\n\t\t\ttw.trace.endpos[i] = start[i] + tw.trace.fraction * (end[i] - start[i]);\n\t\t}\n\t}\n\n        // If allsolid is set (was entirely inside something solid), the plane is not valid.\n        // If fraction == 1.0, we never hit anything, and thus the plane is not valid.\n        // Otherwise, the normal on the plane should have unit length\n        assert(tw.trace.allsolid ||\n               tw.trace.fraction == 1.0 ||\n               VectorLengthSquared(tw.trace.plane.normal) > 0.9999);\n\t*results = tw.trace;\n}\n\n/*\n==================\nCM_BoxTrace\n==================\n*/\nvoid CM_BoxTrace( trace_t *results, const vec3_t start, const vec3_t end,\n\t\t\t\t\t\t  vec3_t mins, vec3_t maxs,\n\t\t\t\t\t\t  clipHandle_t model, int brushmask, int capsule ) {\n\tCM_Trace( results, start, end, mins, maxs, model, vec3_origin, brushmask, capsule, NULL );\n}\n\n/*\n==================\nCM_TransformedBoxTrace\n\nHandles offseting and rotation of the end points for moving and\nrotating entities\n==================\n*/\nvoid CM_TransformedBoxTrace( trace_t *results, const vec3_t start, const vec3_t end,\n\t\t\t\t\t\t  vec3_t mins, vec3_t maxs,\n\t\t\t\t\t\t  clipHandle_t model, int brushmask,\n\t\t\t\t\t\t  const vec3_t origin, const vec3_t angles, int capsule ) {\n\ttrace_t\t\ttrace;\n\tvec3_t\t\tstart_l, end_l;\n\tqboolean\trotated;\n\tvec3_t\t\toffset;\n\tvec3_t\t\tsymetricSize[2];\n\tvec3_t\t\tmatrix[3], transpose[3];\n\tint\t\t\ti;\n\tfloat\t\thalfwidth;\n\tfloat\t\thalfheight;\n\tfloat\t\tt;\n\tsphere_t\tsphere;\n\n\tif ( !mins ) {\n\t\tmins = vec3_origin;\n\t}\n\tif ( !maxs ) {\n\t\tmaxs = vec3_origin;\n\t}\n\n\t// adjust so that mins and maxs are always symetric, which\n\t// avoids some complications with plane expanding of rotated\n\t// bmodels\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\toffset[i] = ( mins[i] + maxs[i] ) * 0.5;\n\t\tsymetricSize[0][i] = mins[i] - offset[i];\n\t\tsymetricSize[1][i] = maxs[i] - offset[i];\n\t\tstart_l[i] = start[i] + offset[i];\n\t\tend_l[i] = end[i] + offset[i];\n\t}\n\n\t// subtract origin offset\n\tVectorSubtract( start_l, origin, start_l );\n\tVectorSubtract( end_l, origin, end_l );\n\n\t// rotate start and end into the models frame of reference\n\tif ( model != BOX_MODEL_HANDLE && \n\t\t(angles[0] || angles[1] || angles[2]) ) {\n\t\trotated = qtrue;\n\t} else {\n\t\trotated = qfalse;\n\t}\n\n\thalfwidth = symetricSize[ 1 ][ 0 ];\n\thalfheight = symetricSize[ 1 ][ 2 ];\n\n\tsphere.use = capsule;\n\tsphere.radius = ( halfwidth > halfheight ) ? halfheight : halfwidth;\n\tsphere.halfheight = halfheight;\n\tt = halfheight - sphere.radius;\n\n\tif (rotated) {\n\t\t// rotation on trace line (start-end) instead of rotating the bmodel\n\t\t// NOTE: This is still incorrect for bounding boxes because the actual bounding\n\t\t//\t\t box that is swept through the model is not rotated. We cannot rotate\n\t\t//\t\t the bounding box or the bmodel because that would make all the brush\n\t\t//\t\t bevels invalid.\n\t\t//\t\t However this is correct for capsules since a capsule itself is rotated too.\n\t\tCreateRotationMatrix(angles, matrix);\n\t\tRotatePoint(start_l, matrix);\n\t\tRotatePoint(end_l, matrix);\n\t\t// rotated sphere offset for capsule\n\t\tsphere.offset[0] = matrix[0][ 2 ] * t;\n\t\tsphere.offset[1] = -matrix[1][ 2 ] * t;\n\t\tsphere.offset[2] = matrix[2][ 2 ] * t;\n\t}\n\telse {\n\t\tVectorSet( sphere.offset, 0, 0, t );\n\t}\n\n\t// sweep the box through the model\n\tCM_Trace( &trace, start_l, end_l, symetricSize[0], symetricSize[1], model, origin, brushmask, capsule, &sphere );\n\n\t// if the bmodel was rotated and there was a collision\n\tif ( rotated && trace.fraction != 1.0 ) {\n\t\t// rotation of bmodel collision plane\n\t\tTransposeMatrix(matrix, transpose);\n\t\tRotatePoint(trace.plane.normal, transpose);\n\t}\n\n\t// re-calculate the end position of the trace because the trace.endpos\n\t// calculated by CM_Trace could be rotated and have an offset\n\ttrace.endpos[0] = start[0] + trace.fraction * (end[0] - start[0]);\n\ttrace.endpos[1] = start[1] + trace.fraction * (end[1] - start[1]);\n\ttrace.endpos[2] = start[2] + trace.fraction * (end[2] - start[2]);\n\n\t*results = trace;\n}\n"
  },
  {
    "path": "code/qcommon/cmd.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// cmd.c -- Quake script command processing module\n\n#include \"../game/q_shared.h\"\n#include \"qcommon.h\"\n\n#define\tMAX_CMD_BUFFER\t16384\n#define\tMAX_CMD_LINE\t1024\n\ntypedef struct {\n\tbyte\t*data;\n\tint\t\tmaxsize;\n\tint\t\tcursize;\n} cmd_t;\n\nint\t\t\tcmd_wait;\ncmd_t\t\tcmd_text;\nbyte\t\tcmd_text_buf[MAX_CMD_BUFFER];\n\n\n//=============================================================================\n\n/*\n============\nCmd_Wait_f\n\nCauses execution of the remainder of the command buffer to be delayed until\nnext frame.  This allows commands like:\nbind g \"cmd use rocket ; +attack ; wait ; -attack ; cmd use blaster\"\n============\n*/\nvoid Cmd_Wait_f( void ) {\n\tif ( Cmd_Argc() == 2 ) {\n\t\tcmd_wait = atoi( Cmd_Argv( 1 ) );\n\t} else {\n\t\tcmd_wait = 1;\n\t}\n}\n\n\n/*\n=============================================================================\n\n\t\t\t\t\t\tCOMMAND BUFFER\n\n=============================================================================\n*/\n\n/*\n============\nCbuf_Init\n============\n*/\nvoid Cbuf_Init (void)\n{\n\tcmd_text.data = cmd_text_buf;\n\tcmd_text.maxsize = MAX_CMD_BUFFER;\n\tcmd_text.cursize = 0;\n}\n\n/*\n============\nCbuf_AddText\n\nAdds command text at the end of the buffer, does NOT add a final \\n\n============\n*/\nvoid Cbuf_AddText( const char *text ) {\n\tint\t\tl;\n\t\n\tl = strlen (text);\n\n\tif (cmd_text.cursize + l >= cmd_text.maxsize)\n\t{\n\t\tCom_Printf (\"Cbuf_AddText: overflow\\n\");\n\t\treturn;\n\t}\n\tCom_Memcpy(&cmd_text.data[cmd_text.cursize], text, l);\n\tcmd_text.cursize += l;\n}\n\n\n/*\n============\nCbuf_InsertText\n\nAdds command text immediately after the current command\nAdds a \\n to the text\n============\n*/\nvoid Cbuf_InsertText( const char *text ) {\n\tint\t\tlen;\n\tint\t\ti;\n\n\tlen = strlen( text ) + 1;\n\tif ( len + cmd_text.cursize > cmd_text.maxsize ) {\n\t\tCom_Printf( \"Cbuf_InsertText overflowed\\n\" );\n\t\treturn;\n\t}\n\n\t// move the existing command text\n\tfor ( i = cmd_text.cursize - 1 ; i >= 0 ; i-- ) {\n\t\tcmd_text.data[ i + len ] = cmd_text.data[ i ];\n\t}\n\n\t// copy the new text in\n\tCom_Memcpy( cmd_text.data, text, len - 1 );\n\n\t// add a \\n\n\tcmd_text.data[ len - 1 ] = '\\n';\n\n\tcmd_text.cursize += len;\n}\n\n\n/*\n============\nCbuf_ExecuteText\n============\n*/\nvoid Cbuf_ExecuteText (int exec_when, const char *text)\n{\n\tswitch (exec_when)\n\t{\n\tcase EXEC_NOW:\n\t\tif (text && strlen(text) > 0) {\n\t\t\tCmd_ExecuteString (text);\n\t\t} else {\n\t\t\tCbuf_Execute();\n\t\t}\n\t\tbreak;\n\tcase EXEC_INSERT:\n\t\tCbuf_InsertText (text);\n\t\tbreak;\n\tcase EXEC_APPEND:\n\t\tCbuf_AddText (text);\n\t\tbreak;\n\tdefault:\n\t\tCom_Error (ERR_FATAL, \"Cbuf_ExecuteText: bad exec_when\");\n\t}\n}\n\n/*\n============\nCbuf_Execute\n============\n*/\nvoid Cbuf_Execute (void)\n{\n\tint\t\ti;\n\tchar\t*text;\n\tchar\tline[MAX_CMD_LINE];\n\tint\t\tquotes;\n\n\twhile (cmd_text.cursize)\n\t{\n\t\tif ( cmd_wait )\t{\n\t\t\t// skip out while text still remains in buffer, leaving it\n\t\t\t// for next frame\n\t\t\tcmd_wait--;\n\t\t\tbreak;\n\t\t}\n\n\t\t// find a \\n or ; line break\n\t\ttext = (char *)cmd_text.data;\n\n\t\tquotes = 0;\n\t\tfor (i=0 ; i< cmd_text.cursize ; i++)\n\t\t{\n\t\t\tif (text[i] == '\"')\n\t\t\t\tquotes++;\n\t\t\tif ( !(quotes&1) &&  text[i] == ';')\n\t\t\t\tbreak;\t// don't break if inside a quoted string\n\t\t\tif (text[i] == '\\n' || text[i] == '\\r' )\n\t\t\t\tbreak;\n\t\t}\n\n\t\tif( i >= (MAX_CMD_LINE - 1)) {\n\t\t\ti = MAX_CMD_LINE - 1;\n\t\t}\n\t\t\t\t\n\t\tCom_Memcpy (line, text, i);\n\t\tline[i] = 0;\n\t\t\n// delete the text from the command buffer and move remaining commands down\n// this is necessary because commands (exec) can insert data at the\n// beginning of the text buffer\n\n\t\tif (i == cmd_text.cursize)\n\t\t\tcmd_text.cursize = 0;\n\t\telse\n\t\t{\n\t\t\ti++;\n\t\t\tcmd_text.cursize -= i;\n\t\t\tmemmove (text, text+i, cmd_text.cursize);\n\t\t}\n\n// execute the command line\n\n\t\tCmd_ExecuteString (line);\t\t\n\t}\n}\n\n\n/*\n==============================================================================\n\n\t\t\t\t\t\tSCRIPT COMMANDS\n\n==============================================================================\n*/\n\n\n/*\n===============\nCmd_Exec_f\n===============\n*/\nvoid Cmd_Exec_f( void ) {\n\tchar\t*f;\n\tint\t\tlen;\n\tchar\tfilename[MAX_QPATH];\n\n\tif (Cmd_Argc () != 2) {\n\t\tCom_Printf (\"exec <filename> : execute a script file\\n\");\n\t\treturn;\n\t}\n\n\tQ_strncpyz( filename, Cmd_Argv(1), sizeof( filename ) );\n\tCOM_DefaultExtension( filename, sizeof( filename ), \".cfg\" ); \n\tlen = FS_ReadFile( filename, (void **)&f);\n\tif (!f) {\n\t\tCom_Printf (\"couldn't exec %s\\n\",Cmd_Argv(1));\n\t\treturn;\n\t}\n\tCom_Printf (\"execing %s\\n\",Cmd_Argv(1));\n\t\n\tCbuf_InsertText (f);\n\n\tFS_FreeFile (f);\n}\n\n\n/*\n===============\nCmd_Vstr_f\n\nInserts the current value of a variable as command text\n===============\n*/\nvoid Cmd_Vstr_f( void ) {\n\tchar\t*v;\n\n\tif (Cmd_Argc () != 2) {\n\t\tCom_Printf (\"vstr <variablename> : execute a variable command\\n\");\n\t\treturn;\n\t}\n\n\tv = Cvar_VariableString( Cmd_Argv( 1 ) );\n\tCbuf_InsertText( va(\"%s\\n\", v ) );\n}\n\n\n/*\n===============\nCmd_Echo_f\n\nJust prints the rest of the line to the console\n===============\n*/\nvoid Cmd_Echo_f (void)\n{\n\tint\t\ti;\n\t\n\tfor (i=1 ; i<Cmd_Argc() ; i++)\n\t\tCom_Printf (\"%s \",Cmd_Argv(i));\n\tCom_Printf (\"\\n\");\n}\n\n\n/*\n=============================================================================\n\n\t\t\t\t\tCOMMAND EXECUTION\n\n=============================================================================\n*/\n\ntypedef struct cmd_function_s\n{\n\tstruct cmd_function_s\t*next;\n\tchar\t\t\t\t\t*name;\n\txcommand_t\t\t\t\tfunction;\n} cmd_function_t;\n\n\nstatic\tint\t\t\tcmd_argc;\nstatic\tchar\t\t*cmd_argv[MAX_STRING_TOKENS];\t\t// points into cmd_tokenized\nstatic\tchar\t\tcmd_tokenized[BIG_INFO_STRING+MAX_STRING_TOKENS];\t// will have 0 bytes inserted\nstatic\tchar\t\tcmd_cmd[BIG_INFO_STRING]; // the original command we received (no token processing)\n\nstatic\tcmd_function_t\t*cmd_functions;\t\t// possible commands to execute\n\n/*\n============\nCmd_Argc\n============\n*/\nint\t\tCmd_Argc( void ) {\n\treturn cmd_argc;\n}\n\n/*\n============\nCmd_Argv\n============\n*/\nchar\t*Cmd_Argv( int arg ) {\n\tif ( (unsigned)arg >= cmd_argc ) {\n\t\treturn \"\";\n\t}\n\treturn cmd_argv[arg];\t\n}\n\n/*\n============\nCmd_ArgvBuffer\n\nThe interpreted versions use this because\nthey can't have pointers returned to them\n============\n*/\nvoid\tCmd_ArgvBuffer( int arg, char *buffer, int bufferLength ) {\n\tQ_strncpyz( buffer, Cmd_Argv( arg ), bufferLength );\n}\n\n\n/*\n============\nCmd_Args\n\nReturns a single string containing argv(1) to argv(argc()-1)\n============\n*/\nchar\t*Cmd_Args( void ) {\n\tstatic\tchar\t\tcmd_args[MAX_STRING_CHARS];\n\tint\t\ti;\n\n\tcmd_args[0] = 0;\n\tfor ( i = 1 ; i < cmd_argc ; i++ ) {\n\t\tstrcat( cmd_args, cmd_argv[i] );\n\t\tif ( i != cmd_argc-1 ) {\n\t\t\tstrcat( cmd_args, \" \" );\n\t\t}\n\t}\n\n\treturn cmd_args;\n}\n\n/*\n============\nCmd_Args\n\nReturns a single string containing argv(arg) to argv(argc()-1)\n============\n*/\nchar *Cmd_ArgsFrom( int arg ) {\n\tstatic\tchar\t\tcmd_args[BIG_INFO_STRING];\n\tint\t\ti;\n\n\tcmd_args[0] = 0;\n\tif (arg < 0)\n\t\targ = 0;\n\tfor ( i = arg ; i < cmd_argc ; i++ ) {\n\t\tstrcat( cmd_args, cmd_argv[i] );\n\t\tif ( i != cmd_argc-1 ) {\n\t\t\tstrcat( cmd_args, \" \" );\n\t\t}\n\t}\n\n\treturn cmd_args;\n}\n\n/*\n============\nCmd_ArgsBuffer\n\nThe interpreted versions use this because\nthey can't have pointers returned to them\n============\n*/\nvoid\tCmd_ArgsBuffer( char *buffer, int bufferLength ) {\n\tQ_strncpyz( buffer, Cmd_Args(), bufferLength );\n}\n\n/*\n============\nCmd_Cmd\n\nRetrieve the unmodified command string\nFor rcon use when you want to transmit without altering quoting\nhttps://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=543\n============\n*/\nchar *Cmd_Cmd()\n{\n\treturn cmd_cmd;\n}\n\n/*\n============\nCmd_TokenizeString\n\nParses the given string into command line tokens.\nThe text is copied to a seperate buffer and 0 characters\nare inserted in the apropriate place, The argv array\nwill point into this temporary buffer.\n============\n*/\n// NOTE TTimo define that to track tokenization issues\n//#define TKN_DBG\nvoid Cmd_TokenizeString( const char *text_in ) {\n\tconst char\t*text;\n\tchar\t*textOut;\n\n#ifdef TKN_DBG\n  // FIXME TTimo blunt hook to try to find the tokenization of userinfo\n  Com_DPrintf(\"Cmd_TokenizeString: %s\\n\", text_in);\n#endif\n\n\t// clear previous args\n\tcmd_argc = 0;\n\n\tif ( !text_in ) {\n\t\treturn;\n\t}\n\t\n\tQ_strncpyz( cmd_cmd, text_in, sizeof(cmd_cmd) );\n\n\ttext = text_in;\n\ttextOut = cmd_tokenized;\n\n\twhile ( 1 ) {\n\t\tif ( cmd_argc == MAX_STRING_TOKENS ) {\n\t\t\treturn;\t\t\t// this is usually something malicious\n\t\t}\n\n\t\twhile ( 1 ) {\n\t\t\t// skip whitespace\n\t\t\twhile ( *text && *text <= ' ' ) {\n\t\t\t\ttext++;\n\t\t\t}\n\t\t\tif ( !*text ) {\n\t\t\t\treturn;\t\t\t// all tokens parsed\n\t\t\t}\n\n\t\t\t// skip // comments\n\t\t\tif ( text[0] == '/' && text[1] == '/' ) {\n\t\t\t\treturn;\t\t\t// all tokens parsed\n\t\t\t}\n\n\t\t\t// skip /* */ comments\n\t\t\tif ( text[0] == '/' && text[1] =='*' ) {\n\t\t\t\twhile ( *text && ( text[0] != '*' || text[1] != '/' ) ) {\n\t\t\t\t\ttext++;\n\t\t\t\t}\n\t\t\t\tif ( !*text ) {\n\t\t\t\t\treturn;\t\t// all tokens parsed\n\t\t\t\t}\n\t\t\t\ttext += 2;\n\t\t\t} else {\n\t\t\t\tbreak;\t\t\t// we are ready to parse a token\n\t\t\t}\n\t\t}\n\n\t\t// handle quoted strings\n    // NOTE TTimo this doesn't handle \\\" escaping\n\t\tif ( *text == '\"' ) {\n\t\t\tcmd_argv[cmd_argc] = textOut;\n\t\t\tcmd_argc++;\n\t\t\ttext++;\n\t\t\twhile ( *text && *text != '\"' ) {\n\t\t\t\t*textOut++ = *text++;\n\t\t\t}\n\t\t\t*textOut++ = 0;\n\t\t\tif ( !*text ) {\n\t\t\t\treturn;\t\t// all tokens parsed\n\t\t\t}\n\t\t\ttext++;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// regular token\n\t\tcmd_argv[cmd_argc] = textOut;\n\t\tcmd_argc++;\n\n\t\t// skip until whitespace, quote, or command\n\t\twhile ( *text > ' ' ) {\n\t\t\tif ( text[0] == '\"' ) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif ( text[0] == '/' && text[1] == '/' ) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// skip /* */ comments\n\t\t\tif ( text[0] == '/' && text[1] =='*' ) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t*textOut++ = *text++;\n\t\t}\n\n\t\t*textOut++ = 0;\n\n\t\tif ( !*text ) {\n\t\t\treturn;\t\t// all tokens parsed\n\t\t}\n\t}\n\t\n}\n\n\n/*\n============\nCmd_AddCommand\n============\n*/\nvoid\tCmd_AddCommand( const char *cmd_name, xcommand_t function ) {\n\tcmd_function_t\t*cmd;\n\t\n\t// fail if the command already exists\n\tfor ( cmd = cmd_functions ; cmd ; cmd=cmd->next ) {\n\t\tif ( !strcmp( cmd_name, cmd->name ) ) {\n\t\t\t// allow completion-only commands to be silently doubled\n\t\t\tif ( function != NULL ) {\n\t\t\t\tCom_Printf (\"Cmd_AddCommand: %s already defined\\n\", cmd_name);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// use a small malloc to avoid zone fragmentation\n\tcmd = S_Malloc (sizeof(cmd_function_t));\n\tcmd->name = CopyString( cmd_name );\n\tcmd->function = function;\n\tcmd->next = cmd_functions;\n\tcmd_functions = cmd;\n}\n\n/*\n============\nCmd_RemoveCommand\n============\n*/\nvoid\tCmd_RemoveCommand( const char *cmd_name ) {\n\tcmd_function_t\t*cmd, **back;\n\n\tback = &cmd_functions;\n\twhile( 1 ) {\n\t\tcmd = *back;\n\t\tif ( !cmd ) {\n\t\t\t// command wasn't active\n\t\t\treturn;\n\t\t}\n\t\tif ( !strcmp( cmd_name, cmd->name ) ) {\n\t\t\t*back = cmd->next;\n\t\t\tif (cmd->name) {\n\t\t\t\tZ_Free(cmd->name);\n\t\t\t}\n\t\t\tZ_Free (cmd);\n\t\t\treturn;\n\t\t}\n\t\tback = &cmd->next;\n\t}\n}\n\n\n/*\n============\nCmd_CommandCompletion\n============\n*/\nvoid\tCmd_CommandCompletion( void(*callback)(const char *s) ) {\n\tcmd_function_t\t*cmd;\n\t\n\tfor (cmd=cmd_functions ; cmd ; cmd=cmd->next) {\n\t\tcallback( cmd->name );\n\t}\n}\n\n\n/*\n============\nCmd_ExecuteString\n\nA complete command line has been parsed, so try to execute it\n============\n*/\nvoid\tCmd_ExecuteString( const char *text ) {\t\n\tcmd_function_t\t*cmd, **prev;\n\n\t// execute the command line\n\tCmd_TokenizeString( text );\t\t\n\tif ( !Cmd_Argc() ) {\n\t\treturn;\t\t// no tokens\n\t}\n\n\t// check registered command functions\t\n\tfor ( prev = &cmd_functions ; *prev ; prev = &cmd->next ) {\n\t\tcmd = *prev;\n\t\tif ( !Q_stricmp( cmd_argv[0],cmd->name ) ) {\n\t\t\t// rearrange the links so that the command will be\n\t\t\t// near the head of the list next time it is used\n\t\t\t*prev = cmd->next;\n\t\t\tcmd->next = cmd_functions;\n\t\t\tcmd_functions = cmd;\n\n\t\t\t// perform the action\n\t\t\tif ( !cmd->function ) {\n\t\t\t\t// let the cgame or game handle it\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tcmd->function ();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t}\n\t\n\t// check cvars\n\tif ( Cvar_Command() ) {\n\t\treturn;\n\t}\n\n\t// check client game commands\n\tif ( com_cl_running && com_cl_running->integer && CL_GameCommand() ) {\n\t\treturn;\n\t}\n\n\t// check server game commands\n\tif ( com_sv_running && com_sv_running->integer && SV_GameCommand() ) {\n\t\treturn;\n\t}\n\n\t// check ui commands\n\tif ( com_cl_running && com_cl_running->integer && UI_GameCommand() ) {\n\t\treturn;\n\t}\n\n\t// send it as a server command if we are connected\n\t// this will usually result in a chat message\n\tCL_ForwardCommandToServer ( text );\n}\n\n/*\n============\nCmd_List_f\n============\n*/\nvoid Cmd_List_f (void)\n{\n\tcmd_function_t\t*cmd;\n\tint\t\t\t\ti;\n\tchar\t\t\t*match;\n\n\tif ( Cmd_Argc() > 1 ) {\n\t\tmatch = Cmd_Argv( 1 );\n\t} else {\n\t\tmatch = NULL;\n\t}\n\n\ti = 0;\n\tfor (cmd=cmd_functions ; cmd ; cmd=cmd->next) {\n\t\tif (match && !Com_Filter(match, cmd->name, qfalse)) continue;\n\n\t\tCom_Printf (\"%s\\n\", cmd->name);\n\t\ti++;\n\t}\n\tCom_Printf (\"%i commands\\n\", i);\n}\n\n/*\n============\nCmd_Init\n============\n*/\nvoid Cmd_Init (void) {\n\tCmd_AddCommand (\"cmdlist\",Cmd_List_f);\n\tCmd_AddCommand (\"exec\",Cmd_Exec_f);\n\tCmd_AddCommand (\"vstr\",Cmd_Vstr_f);\n\tCmd_AddCommand (\"echo\",Cmd_Echo_f);\n\tCmd_AddCommand (\"wait\", Cmd_Wait_f);\n}\n\n"
  },
  {
    "path": "code/qcommon/cmd.c.save",
    "content": "// cmd.c -- Quake script command processing module\n\n#include \"../game/q_shared.h\"\n#include \"qcommon.h\"\n\n#define\tMAX_CMD_BUFFER\t8192\nint\t\t\tcmd_wait;\nmsg_t\t\tcmd_text;\nbyte\t\tcmd_text_buf[MAX_CMD_BUFFER];\nchar\t\tcmd_defer_text_buf[MAX_CMD_BUFFER];\n\n\n//=============================================================================\n\n/*\n============\nCmd_Wait_f\n\nCauses execution of the remainder of the command buffer to be delayed until\nnext frame.  This allows commands like:\nbind g \"cmd use rocket ; +attack ; wait ; -attack ; cmd use blaster\"\n============\n*/\nvoid Cmd_Wait_f( void ) {\n\tif ( Cmd_Argc() == 2 ) {\n\t\tcmd_wait = atoi( Cmd_Argv( 1 ) );\n\t} else {\n\t\tcmd_wait = 1;\n\t}\n}\n\n\n/*\n=============================================================================\n\n\t\t\t\t\t\tCOMMAND BUFFER\n\n=============================================================================\n*/\n\n/*\n============\nCbuf_Init\n============\n*/\nvoid Cbuf_Init (void)\n{\n\tMSG_Init (&cmd_text, cmd_text_buf, sizeof(cmd_text_buf));\n}\n\n/*\n============\nCbuf_AddText\n\nAdds command text at the end of the buffer, does NOT add a final \\n\n============\n*/\nvoid Cbuf_AddText( const char *text ) {\n\tint\t\tl;\n\t\n\tl = strlen (text);\n\n\tif (cmd_text.cursize + l >= cmd_text.maxsize)\n\t{\n\t\tCom_Printf (\"Cbuf_AddText: overflow\\n\");\n\t\treturn;\n\t}\n\tMSG_WriteData (&cmd_text, text, strlen (text));\n}\n\n\n/*\n============\nCbuf_InsertText\n\nAdds command text immediately after the current command\nAdds a \\n to the text\n============\n*/\nvoid Cbuf_InsertText( const char *text ) {\n\tint\t\tlen;\n\tint\t\ti;\n\n\tlen = strlen( text ) + 1;\n\tif ( len + cmd_text.cursize > cmd_text.maxsize ) {\n\t\tCom_Printf( \"Cbuf_InsertText overflowed\\n\" );\n\t\treturn;\n\t}\n\n\t// move the existing command text\n\tfor ( i = cmd_text.cursize - 1 ; i >= 0 ; i-- ) {\n\t\tcmd_text.data[ i + len ] = cmd_text.data[ i ];\n\t}\n\n\t// copy the new text in\n\tmemcpy( cmd_text.data, text, len - 1 );\n\n\t// add a \\n\n\tcmd_text.data[ len - 1 ] = '\\n';\n\n\tcmd_text.cursize += len;\n}\n\n\n/*\n============\nCbuf_ExecuteText\n============\n*/\nvoid Cbuf_ExecuteText (int exec_when, const char *text)\n{\n\tswitch (exec_when)\n\t{\n\tcase EXEC_NOW:\n\t\tCmd_ExecuteString (text);\n\t\tbreak;\n\tcase EXEC_INSERT:\n\t\tCbuf_InsertText (text);\n\t\tbreak;\n\tcase EXEC_APPEND:\n\t\tCbuf_AddText (text);\n\t\tbreak;\n\tdefault:\n\t\tCom_Error (ERR_FATAL, \"Cbuf_ExecuteText: bad exec_when\");\n\t}\n}\n\n/*\n============\nCbuf_Execute\n============\n*/\nvoid Cbuf_Execute (void)\n{\n\tint\t\ti;\n\tchar\t*text;\n\tchar\tline[MAX_CMD_BUFFER];\n\tint\t\tquotes;\n\n\twhile (cmd_text.cursize)\n\t{\n\t\tif ( cmd_wait )\t{\n\t\t\t// skip out while text still remains in buffer, leaving it\n\t\t\t// for next frame\n\t\t\tcmd_wait--;\n\t\t\tbreak;\n\t\t}\n\n\t\t// find a \\n or ; line break\n\t\ttext = (char *)cmd_text.data;\n\n\t\tquotes = 0;\n\t\tfor (i=0 ; i< cmd_text.cursize ; i++)\n\t\t{\n\t\t\tif (text[i] == '\"')\n\t\t\t\tquotes++;\n\t\t\tif ( !(quotes&1) &&  text[i] == ';')\n\t\t\t\tbreak;\t// don't break if inside a quoted string\n\t\t\tif (text[i] == '\\n' || text[i] == '\\r' )\n\t\t\t\tbreak;\n\t\t}\n\t\t\t\n\t\t\t\t\n\t\tmemcpy (line, text, i);\n\t\tline[i] = 0;\n\t\t\n// delete the text from the command buffer and move remaining commands down\n// this is necessary because commands (exec) can insert data at the\n// beginning of the text buffer\n\n\t\tif (i == cmd_text.cursize)\n\t\t\tcmd_text.cursize = 0;\n\t\telse\n\t\t{\n\t\t\ti++;\n\t\t\tcmd_text.cursize -= i;\n\t\t\tmemmove (text, text+i, cmd_text.cursize);\n      text[cmd_text.cursize] = 0;\n\t\t}\n\n// execute the command line\n\t\tCmd_ExecuteString (line);\t\t\n\t}\n}\n\n\n/*\n==============================================================================\n\n\t\t\t\t\t\tSCRIPT COMMANDS\n\n==============================================================================\n*/\n\n\n/*\n===============\nCmd_Exec_f\n===============\n*/\nvoid Cmd_Exec_f( void ) {\n\tfileHandle_t\tf;\n\tint\t\tlen;\n\tchar\tfilename[MAX_QPATH];\n  char *buffer;\n\n\tif (Cmd_Argc () != 2) {\n\t\tCom_Printf (\"exec <filename> : execute a script file\\n\");\n\t\treturn;\n\t}\n\n\tQ_strncpyz( filename, Cmd_Argv(1), sizeof( filename ) );\n\tCOM_DefaultExtension( filename, sizeof( filename ), \".cfg\" ); \n\tlen = FS_FOpenFileRead( filename, &f, qfalse );\n\tif ( len <= 0 ) {\n\t\tCom_Printf (\"Couldn't read %s.\\n\", filename );\n\t\treturn;\n\t}\n\n  buffer = Z_Malloc(len+1);\n\n  if (FS_Read(buffer, len, f) == len) {\n\t  FS_FCloseFile( f );\n    buffer[len] = 0;\n\t  Com_Printf (\"execing %s\\n\",Cmd_Argv(1));\n\t  Cbuf_InsertText (buffer);\n  }\n  else {\n\t\tCom_Printf (\"couldn't exec %s\\n\",Cmd_Argv(1));\n  }\n\n  Z_Free(buffer);\n}\n\n\n/*\n===============\nCmd_Vstr_f\n\nInserts the current value of a variable as command text\n===============\n*/\nvoid Cmd_Vstr_f( void ) {\n\tchar\t*v;\n\n\tif (Cmd_Argc () != 2) {\n\t\tCom_Printf (\"vstr <variablename> : execute a variable command\\n\");\n\t\treturn;\n\t}\n\n\tv = Cvar_VariableString( Cmd_Argv( 1 ) );\n\tCbuf_InsertText( va(\"%s\\n\", v ) );\n}\n\n\n/*\n===============\nCmd_Echo_f\n\nJust prints the rest of the line to the console\n===============\n*/\nvoid Cmd_Echo_f (void)\n{\n\tint\t\ti;\n\t\n\tfor (i=1 ; i<Cmd_Argc() ; i++)\n\t\tCom_Printf (\"%s \",Cmd_Argv(i));\n\tCom_Printf (\"\\n\");\n}\n\n\n/*\n=============================================================================\n\n\t\t\t\t\tCOMMAND EXECUTION\n\n=============================================================================\n*/\n\ntypedef struct cmd_function_s\n{\n\tstruct cmd_function_s\t*next;\n\tchar\t\t\t\t\t*name;\n\txcommand_t\t\t\t\tfunction;\n} cmd_function_t;\n\n\nstatic\tint\t\t\tcmd_argc;\nstatic\tchar\t\t*cmd_argv[MAX_STRING_TOKENS];\t\t// points into cmd_tokenized\nstatic\tchar\t\tcmd_tokenized[MAX_STRING_CHARS+MAX_STRING_TOKENS];\t// will have 0 bytes inserted\n\nstatic\tcmd_function_t\t*cmd_functions;\t\t// possible commands to execute\n\n/*\n============\nCmd_Argc\n============\n*/\nint\t\tCmd_Argc( void ) {\n\treturn cmd_argc;\n}\n\n/*\n============\nCmd_Argv\n============\n*/\nchar\t*Cmd_Argv( int arg ) {\n\tif ( (unsigned)arg >= cmd_argc ) {\n\t\treturn \"\";\n\t}\n\treturn cmd_argv[arg];\t\n}\n\n/*\n============\nCmd_ArgvBuffer\n\nThe interpreted versions use this because\nthey can't have pointers returned to them\n============\n*/\nvoid\tCmd_ArgvBuffer( int arg, char *buffer, int bufferLength ) {\n\tQ_strncpyz( buffer, Cmd_Argv( arg ), bufferLength );\n}\n\n\n/*\n============\nCmd_Args\n\nReturns a single string containing argv(1) to argv(argc()-1)\n============\n*/\nchar\t*Cmd_Args( void ) {\n\tstatic\tchar\t\tcmd_args[MAX_STRING_CHARS];\n\tint\t\ti;\n\n\tcmd_args[0] = 0;\n\tfor ( i = 1 ; i < cmd_argc ; i++ ) {\n\t\tstrcat( cmd_args, cmd_argv[i] );\n\t\tif ( i != cmd_argc ) {\n\t\t\tstrcat( cmd_args, \" \" );\n\t\t}\n\t}\n\n\treturn cmd_args;\n}\n\n\n/*\n============\nCmd_ArgsBuffer\n\nThe interpreted versions use this because\nthey can't have pointers returned to them\n============\n*/\nvoid\tCmd_ArgsBuffer( char *buffer, int bufferLength ) {\n\tQ_strncpyz( buffer, Cmd_Args(), bufferLength );\n}\n\n\n/*\n============\nCmd_TokenizeString\n\nParses the given string into command line tokens.\nThe text is copied to a seperate buffer and 0 characters\nare inserted in the apropriate place, The argv array\nwill point into this temporary buffer.\n============\n*/\nvoid Cmd_TokenizeString( const char *text_in ) {\n\tconst char\t*text;\n\tchar\t*textOut;\n\n\t// clear previous args\n\tcmd_argc = 0;\n\n\tif ( !text_in ) {\n\t\treturn;\n\t}\n\n\ttext = text_in;\n\ttextOut = cmd_tokenized;\n\n\twhile ( 1 ) {\n\t\tif ( cmd_argc == MAX_STRING_TOKENS ) {\n\t\t\treturn;\t\t\t// this is usually something malicious\n\t\t}\n\n\t\twhile ( 1 ) {\n\t\t\t// skip whitespace\n\t\t\twhile ( *text && *text <= ' ' ) {\n\t\t\t\ttext++;\n\t\t\t}\n\t\t\tif ( !*text ) {\n\t\t\t\treturn;\t\t\t// all tokens parsed\n\t\t\t}\n\n\t\t\t// skip // comments\n\t\t\tif ( text[0] == '/' && text[1] == '/' ) {\n\t\t\t\treturn;\t\t\t// all tokens parsed\n\t\t\t}\n\n\t\t\t// skip /* */ comments\n\t\t\tif ( text[0] == '/' && text[1] =='*' ) {\n\t\t\t\twhile ( *text && ( text[0] != '*' || text[1] != '/' ) ) {\n\t\t\t\t\ttext++;\n\t\t\t\t}\n\t\t\t\tif ( !*text ) {\n\t\t\t\t\treturn;\t\t// all tokens parsed\n\t\t\t\t}\n\t\t\t\ttext += 2;\n\t\t\t} else {\n\t\t\t\tbreak;\t\t\t// we are ready to parse a token\n\t\t\t}\n\t\t}\n\n\t\t// handle quoted strings\n\t\tif ( *text == '\"' ) {\n\t\t\tcmd_argv[cmd_argc] = textOut;\n\t\t\tcmd_argc++;\n\t\t\ttext++;\n\t\t\twhile ( *text && *text != '\"' ) {\n\t\t\t\t*textOut++ = *text++;\n\t\t\t}\n\t\t\t*textOut++ = 0;\n\t\t\tif ( !*text ) {\n\t\t\t\treturn;\t\t// all tokens parsed\n\t\t\t}\n\t\t\ttext++;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// regular token\n\t\tcmd_argv[cmd_argc] = textOut;\n\t\tcmd_argc++;\n\n\t\t// skip until whitespace, quote, or command\n\t\twhile ( *text > ' ' ) {\n\t\t\tif ( text[0] == '\"' ) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif ( text[0] == '/' && text[1] == '/' ) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// skip /* */ comments\n\t\t\tif ( text[0] == '/' && text[1] =='*' ) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t*textOut++ = *text++;\n\t\t}\n\n\t\t*textOut++ = 0;\n\n\t\tif ( !*text ) {\n\t\t\treturn;\t\t// all tokens parsed\n\t\t}\n\t}\n\t\n}\n\n\n/*\n============\nCmd_AddCommand\n============\n*/\nvoid\tCmd_AddCommand( const char *cmd_name, xcommand_t function ) {\n\tcmd_function_t\t*cmd;\n\t\n\t// fail if the command already exists\n\tfor ( cmd = cmd_functions ; cmd ; cmd=cmd->next ) {\n\t\tif ( !strcmp( cmd_name, cmd->name ) ) {\n\t\t\t// allow completion-only commands to be silently doubled\n\t\t\tif ( function != NULL ) {\n\t\t\t\tCom_Printf (\"Cmd_AddCommand: %s already defined\\n\", cmd_name);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t}\n\n\tcmd = Z_Malloc (sizeof(cmd_function_t));\n\tcmd->name = CopyString( cmd_name );\n\tcmd->function = function;\n\tcmd->next = cmd_functions;\n\tcmd_functions = cmd;\n}\n\n/*\n============\nCmd_RemoveCommand\n============\n*/\nvoid\tCmd_RemoveCommand( const char *cmd_name ) {\n\tcmd_function_t\t*cmd, **back;\n\n\tback = &cmd_functions;\n\twhile( 1 ) {\n\t\tcmd = *back;\n\t\tif ( !cmd ) {\n\t\t\t// command wasn't active\n\t\t\treturn;\n\t\t}\n\t\tif ( !strcmp( cmd_name, cmd->name ) ) {\n\t\t\t*back = cmd->next;\n\t\t\tZ_Free (cmd);\n\t\t\treturn;\n\t\t}\n\t\tback = &cmd->next;\n\t}\n}\n\n\n/*\n============\nCmd_CommandCompletion\n============\n*/\nvoid\tCmd_CommandCompletion( void(*callback)(const char *s) ) {\n\tcmd_function_t\t*cmd;\n\t\n\tfor (cmd=cmd_functions ; cmd ; cmd=cmd->next) {\n\t\tcallback( cmd->name );\n\t}\n}\n\n\n/*\n============\nCmd_ExecuteString\n\nA complete command line has been parsed, so try to execute it\n============\n*/\nvoid\tCmd_ExecuteString( const char *text ) {\t\n\tcmd_function_t\t*cmd, **prev;\n\n\t// execute the command line\n\tCmd_TokenizeString( text );\t\t\n\tif ( !Cmd_Argc() ) {\n\t\treturn;\t\t// no tokens\n\t}\n\n\t// check registered command functions\t\n\tfor ( prev = &cmd_functions ; *prev ; prev = &cmd->next ) {\n\t\tcmd = *prev;\n\t\tif ( !Q_stricmp( cmd_argv[0],cmd->name ) ) {\n\t\t\t// rearrange the links so that the command will be\n\t\t\t// near the head of the list next time it is used\n\t\t\t*prev = cmd->next;\n\t\t\tcmd->next = cmd_functions;\n\t\t\tcmd_functions = cmd;\n\n\t\t\t// perform the action\n\t\t\tif ( !cmd->function ) {\n\t\t\t\t// let the cgame or game handle it\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tcmd->function ();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t}\n\t\n\t// check cvars\n\tif ( Cvar_Command() ) {\n\t\treturn;\n\t}\n\n\t// check client game commands\n\tif ( com_cl_running && com_cl_running->integer && CL_GameCommand() ) {\n\t\treturn;\n\t}\n\n\t// check server game commands\n\tif ( com_sv_running && com_sv_running->integer && SV_GameCommand() ) {\n\t\treturn;\n\t}\n\n\t// check ui commands\n\tif ( com_cl_running && com_cl_running->integer && UI_GameCommand() ) {\n\t\treturn;\n\t}\n\n\t// send it as a server command if we are connected\n\t// this will usually result in a chat message\n\tCL_ForwardCommandToServer ();\n}\n\n/*\n============\nCmd_List_f\n============\n*/\nvoid Cmd_List_f (void)\n{\n\tcmd_function_t\t*cmd;\n\tint\t\t\t\ti;\n\tchar\t\t\t*match;\n\n\tif ( Cmd_Argc() > 1 ) {\n\t\tmatch = Cmd_Argv( 1 );\n\t} else {\n\t\tmatch = NULL;\n\t}\n\n\ti = 0;\n\tfor (cmd=cmd_functions ; cmd ; cmd=cmd->next) {\n\t\tif (match && !Com_Filter(match, cmd->name, qfalse)) continue;\n\n\t\tCom_Printf (\"%s\\n\", cmd->name);\n\t\ti++;\n\t}\n\tCom_Printf (\"%i commands\\n\", i);\n}\n\n/*\n============\nCmd_Init\n============\n*/\nvoid Cmd_Init (void) {\n\tCmd_AddCommand (\"cmdlist\",Cmd_List_f);\n\tCmd_AddCommand (\"exec\",Cmd_Exec_f);\n\tCmd_AddCommand (\"vstr\",Cmd_Vstr_f);\n\tCmd_AddCommand (\"echo\",Cmd_Echo_f);\n\tCmd_AddCommand (\"wait\", Cmd_Wait_f);\n}\n\n"
  },
  {
    "path": "code/qcommon/common.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// common.c -- misc functions used in client and server\n\n#include \"../game/q_shared.h\"\n#include \"qcommon.h\"\n#include <setjmp.h>\n#ifdef __linux__\n#include <netinet/in.h>\n#else\n#if defined(MACOS_X)\n#include <netinet/in.h>\n#else\n#include <winsock.h>\n#endif\n#endif\n\nint demo_protocols[] =\n{ 66, 67, 68, 0 };\n\n#define MAX_NUM_ARGVS\t50\n\n#define MIN_DEDICATED_COMHUNKMEGS 1\n#define MIN_COMHUNKMEGS 56\n#ifdef MACOS_X\n#define DEF_COMHUNKMEGS \"64\"\n#define DEF_COMZONEMEGS \"24\"\n#else\n#define DEF_COMHUNKMEGS \"56\"\n#define DEF_COMZONEMEGS \"16\"\n#endif\n\nint\t\tcom_argc;\nchar\t*com_argv[MAX_NUM_ARGVS+1];\n\njmp_buf abortframe;\t\t// an ERR_DROP occured, exit the entire frame\n\n\nFILE *debuglogfile;\nstatic fileHandle_t logfile;\nfileHandle_t\tcom_journalFile;\t\t\t// events are written here\nfileHandle_t\tcom_journalDataFile;\t\t// config files are written here\n\ncvar_t\t*com_viewlog;\ncvar_t\t*com_speeds;\ncvar_t\t*com_developer;\ncvar_t\t*com_dedicated;\ncvar_t\t*com_timescale;\ncvar_t\t*com_fixedtime;\ncvar_t\t*com_dropsim;\t\t// 0.0 to 1.0, simulated packet drops\ncvar_t\t*com_journal;\ncvar_t\t*com_maxfps;\ncvar_t\t*com_timedemo;\ncvar_t\t*com_sv_running;\ncvar_t\t*com_cl_running;\ncvar_t\t*com_logfile;\t\t// 1 = buffer log, 2 = flush after each print\ncvar_t\t*com_showtrace;\ncvar_t\t*com_version;\ncvar_t\t*com_blood;\ncvar_t\t*com_buildScript;\t// for automated data building scripts\ncvar_t\t*com_introPlayed;\ncvar_t\t*cl_paused;\ncvar_t\t*sv_paused;\ncvar_t\t*com_cameraMode;\n#if defined(_WIN32) && defined(_DEBUG)\ncvar_t\t*com_noErrorInterrupt;\n#endif\n\n// com_speeds times\nint\t\ttime_game;\nint\t\ttime_frontend;\t\t// renderer frontend time\nint\t\ttime_backend;\t\t// renderer backend time\n\nint\t\t\tcom_frameTime;\nint\t\t\tcom_frameMsec;\nint\t\t\tcom_frameNumber;\n\nqboolean\tcom_errorEntered;\nqboolean\tcom_fullyInitialized;\n\nchar\tcom_errorMessage[MAXPRINTMSG];\n\nvoid Com_WriteConfig_f( void );\nvoid CIN_CloseAllVideos();\n\n//============================================================================\n\nstatic char\t*rd_buffer;\nstatic int\trd_buffersize;\nstatic void\t(*rd_flush)( char *buffer );\n\nvoid Com_BeginRedirect (char *buffer, int buffersize, void (*flush)( char *) )\n{\n\tif (!buffer || !buffersize || !flush)\n\t\treturn;\n\trd_buffer = buffer;\n\trd_buffersize = buffersize;\n\trd_flush = flush;\n\n\t*rd_buffer = 0;\n}\n\nvoid Com_EndRedirect (void)\n{\n\tif ( rd_flush ) {\n\t\trd_flush(rd_buffer);\n\t}\n\n\trd_buffer = NULL;\n\trd_buffersize = 0;\n\trd_flush = NULL;\n}\n\n/*\n=============\nCom_Printf\n\nBoth client and server can use this, and it will output\nto the apropriate place.\n\nA raw string should NEVER be passed as fmt, because of \"%f\" type crashers.\n=============\n*/\nvoid QDECL Com_Printf( const char *fmt, ... ) {\n\tva_list\t\targptr;\n\tchar\t\tmsg[MAXPRINTMSG];\n  static qboolean opening_qconsole = qfalse;\n\n\tva_start (argptr,fmt);\n\tQ_vsnprintf (msg, sizeof(msg), fmt, argptr);\n\tva_end (argptr);\n\n\tif ( rd_buffer ) {\n\t\tif ((strlen (msg) + strlen(rd_buffer)) > (rd_buffersize - 1)) {\n\t\t\trd_flush(rd_buffer);\n\t\t\t*rd_buffer = 0;\n\t\t}\n\t\tQ_strcat(rd_buffer, rd_buffersize, msg);\n    // TTimo nooo .. that would defeat the purpose\n\t\t//rd_flush(rd_buffer);\t\t\t\n\t\t//*rd_buffer = 0;\n\t\treturn;\n\t}\n\n\t// echo to console if we're not a dedicated server\n\tif ( com_dedicated && !com_dedicated->integer ) {\n\t\tCL_ConsolePrint( msg );\n\t}\n\n\t// echo to dedicated console and early console\n\tSys_Print( msg );\n\n\t// logfile\n\tif ( com_logfile && com_logfile->integer ) {\n    // TTimo: only open the qconsole.log if the filesystem is in an initialized state\n    //   also, avoid recursing in the qconsole.log opening (i.e. if fs_debug is on)\n\t\tif ( !logfile && FS_Initialized() && !opening_qconsole) {\n\t\t\tstruct tm *newtime;\n\t\t\ttime_t aclock;\n\n      opening_qconsole = qtrue;\n\n\t\t\ttime( &aclock );\n\t\t\tnewtime = localtime( &aclock );\n\n\t\t\tlogfile = FS_FOpenFileWrite( \"qconsole.log\" );\n\t\t\tCom_Printf( \"logfile opened on %s\\n\", asctime( newtime ) );\n\t\t\tif ( com_logfile->integer > 1 ) {\n\t\t\t\t// force it to not buffer so we get valid\n\t\t\t\t// data even if we are crashing\n\t\t\t\tFS_ForceFlush(logfile);\n\t\t\t}\n\n      opening_qconsole = qfalse;\n\t\t}\n\t\tif ( logfile && FS_Initialized()) {\n\t\t\tFS_Write(msg, strlen(msg), logfile);\n\t\t}\n\t}\n}\n\n\n/*\n================\nCom_DPrintf\n\nA Com_Printf that only shows up if the \"developer\" cvar is set\n================\n*/\nvoid QDECL Com_DPrintf( const char *fmt, ...) {\n\tva_list\t\targptr;\n\tchar\t\tmsg[MAXPRINTMSG];\n\t\t\n\tif ( !com_developer || !com_developer->integer ) {\n\t\treturn;\t\t\t// don't confuse non-developers with techie stuff...\n\t}\n\n\tva_start (argptr,fmt);\t\n\tQ_vsnprintf (msg, sizeof(msg), fmt, argptr);\n\tva_end (argptr);\n\t\n\tCom_Printf (\"%s\", msg);\n}\n\n/*\n=============\nCom_Error\n\nBoth client and server can use this, and it will\ndo the apropriate things.\n=============\n*/\nvoid QDECL Com_Error( int code, const char *fmt, ... ) {\n\tva_list\t\targptr;\n\tstatic int\tlastErrorTime;\n\tstatic int\terrorCount;\n\tint\t\t\tcurrentTime;\n\n#if defined(_WIN32) && defined(_DEBUG)\n\tif ( code != ERR_DISCONNECT && code != ERR_NEED_CD ) {\n\t\tif (!com_noErrorInterrupt->integer) {\n\t\t\t__asm {\n\t\t\t\tint 0x03\n\t\t\t}\n\t\t}\n\t}\n#endif\n\n\t// when we are running automated scripts, make sure we\n\t// know if anything failed\n\tif ( com_buildScript && com_buildScript->integer ) {\n\t\tcode = ERR_FATAL;\n\t}\n\n\t// make sure we can get at our local stuff\n\tFS_PureServerSetLoadedPaks( \"\", \"\" );\n\n\t// if we are getting a solid stream of ERR_DROP, do an ERR_FATAL\n\tcurrentTime = Sys_Milliseconds();\n\tif ( currentTime - lastErrorTime < 100 ) {\n\t\tif ( ++errorCount > 3 ) {\n\t\t\tcode = ERR_FATAL;\n\t\t}\n\t} else {\n\t\terrorCount = 0;\n\t}\n\tlastErrorTime = currentTime;\n\n\tif ( com_errorEntered ) {\n\t\tSys_Error( \"recursive error after: %s\", com_errorMessage );\n\t}\n\tcom_errorEntered = qtrue;\n\n\tva_start (argptr,fmt);\n\tvsprintf (com_errorMessage,fmt,argptr);\n\tva_end (argptr);\n\n\tif ( code != ERR_DISCONNECT && code != ERR_NEED_CD ) {\n\t\tCvar_Set(\"com_errorMessage\", com_errorMessage);\n\t}\n\n\tif ( code == ERR_SERVERDISCONNECT ) {\n\t\tCL_Disconnect( qtrue );\n\t\tCL_FlushMemory( );\n\t\tcom_errorEntered = qfalse;\n\t\tlongjmp (abortframe, -1);\n\t} else if ( code == ERR_DROP || code == ERR_DISCONNECT ) {\n\t\tCom_Printf (\"********************\\nERROR: %s\\n********************\\n\", com_errorMessage);\n\t\tSV_Shutdown (va(\"Server crashed: %s\\n\",  com_errorMessage));\n\t\tCL_Disconnect( qtrue );\n\t\tCL_FlushMemory( );\n\t\tcom_errorEntered = qfalse;\n\t\tlongjmp (abortframe, -1);\n\t} else if ( code == ERR_NEED_CD ) {\n\t\tSV_Shutdown( \"Server didn't have CD\\n\" );\n\t\tif ( com_cl_running && com_cl_running->integer ) {\n\t\t\tCL_Disconnect( qtrue );\n\t\t\tCL_FlushMemory( );\n\t\t\tcom_errorEntered = qfalse;\n\t\t\tCL_CDDialog();\n\t\t} else {\n\t\t\tCom_Printf(\"Server didn't have CD\\n\" );\n\t\t}\n\t\tlongjmp (abortframe, -1);\n\t} else {\n\t\tCL_Shutdown ();\n\t\tSV_Shutdown (va(\"Server fatal crashed: %s\\n\", com_errorMessage));\n\t}\n\n\tCom_Shutdown ();\n\n\tSys_Error (\"%s\", com_errorMessage);\n}\n\n\n/*\n=============\nCom_Quit_f\n\nBoth client and server can use this, and it will\ndo the apropriate things.\n=============\n*/\nvoid Com_Quit_f( void ) {\n\t// don't try to shutdown if we are in a recursive error\n\tif ( !com_errorEntered ) {\n\t\tSV_Shutdown (\"Server quit\\n\");\n\t\tCL_Shutdown ();\n\t\tCom_Shutdown ();\n\t\tFS_Shutdown(qtrue);\n\t}\n\tSys_Quit ();\n}\n\n\n\n/*\n============================================================================\n\nCOMMAND LINE FUNCTIONS\n\n+ characters seperate the commandLine string into multiple console\ncommand lines.\n\nAll of these are valid:\n\nquake3 +set test blah +map test\nquake3 set test blah+map test\nquake3 set test blah + map test\n\n============================================================================\n*/\n\n#define\tMAX_CONSOLE_LINES\t32\nint\t\tcom_numConsoleLines;\nchar\t*com_consoleLines[MAX_CONSOLE_LINES];\n\n/*\n==================\nCom_ParseCommandLine\n\nBreak it up into multiple console lines\n==================\n*/\nvoid Com_ParseCommandLine( char *commandLine ) {\n    int inq = 0;\n    com_consoleLines[0] = commandLine;\n    com_numConsoleLines = 1;\n\n    while ( *commandLine ) {\n        if (*commandLine == '\"') {\n            inq = !inq;\n        }\n        // look for a + seperating character\n        // if commandLine came from a file, we might have real line seperators\n        if ( (*commandLine == '+' && !inq) || *commandLine == '\\n'  || *commandLine == '\\r' ) {\n            if ( com_numConsoleLines == MAX_CONSOLE_LINES ) {\n                return;\n            }\n            com_consoleLines[com_numConsoleLines] = commandLine + 1;\n            com_numConsoleLines++;\n            *commandLine = 0;\n        }\n        commandLine++;\n    }\n}\n\n\n/*\n===================\nCom_SafeMode\n\nCheck for \"safe\" on the command line, which will\nskip loading of q3config.cfg\n===================\n*/\nqboolean Com_SafeMode( void ) {\n\tint\t\ti;\n\n\tfor ( i = 0 ; i < com_numConsoleLines ; i++ ) {\n\t\tCmd_TokenizeString( com_consoleLines[i] );\n\t\tif ( !Q_stricmp( Cmd_Argv(0), \"safe\" )\n\t\t\t|| !Q_stricmp( Cmd_Argv(0), \"cvar_restart\" ) ) {\n\t\t\tcom_consoleLines[i][0] = 0;\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n\n/*\n===============\nCom_StartupVariable\n\nSearches for command line parameters that are set commands.\nIf match is not NULL, only that cvar will be looked for.\nThat is necessary because cddir and basedir need to be set\nbefore the filesystem is started, but all other sets shouls\nbe after execing the config and default.\n===============\n*/\nvoid Com_StartupVariable( const char *match ) {\n\tint\t\ti;\n\tchar\t*s;\n\tcvar_t\t*cv;\n\n\tfor (i=0 ; i < com_numConsoleLines ; i++) {\n\t\tCmd_TokenizeString( com_consoleLines[i] );\n\t\tif ( strcmp( Cmd_Argv(0), \"set\" ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\ts = Cmd_Argv(1);\n\t\tif ( !match || !strcmp( s, match ) ) {\n\t\t\tCvar_Set( s, Cmd_Argv(2) );\n\t\t\tcv = Cvar_Get( s, \"\", 0 );\n\t\t\tcv->flags |= CVAR_USER_CREATED;\n//\t\t\tcom_consoleLines[i] = 0;\n\t\t}\n\t}\n}\n\n\n/*\n=================\nCom_AddStartupCommands\n\nAdds command line parameters as script statements\nCommands are seperated by + signs\n\nReturns qtrue if any late commands were added, which\nwill keep the demoloop from immediately starting\n=================\n*/\nqboolean Com_AddStartupCommands( void ) {\n\tint\t\ti;\n\tqboolean\tadded;\n\n\tadded = qfalse;\n\t// quote every token, so args with semicolons can work\n\tfor (i=0 ; i < com_numConsoleLines ; i++) {\n\t\tif ( !com_consoleLines[i] || !com_consoleLines[i][0] ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// set commands won't override menu startup\n\t\tif ( Q_stricmpn( com_consoleLines[i], \"set\", 3 ) ) {\n\t\t\tadded = qtrue;\n\t\t}\n\t\tCbuf_AddText( com_consoleLines[i] );\n\t\tCbuf_AddText( \"\\n\" );\n\t}\n\n\treturn added;\n}\n\n\n//============================================================================\n\nvoid Info_Print( const char *s ) {\n\tchar\tkey[512];\n\tchar\tvalue[512];\n\tchar\t*o;\n\tint\t\tl;\n\n\tif (*s == '\\\\')\n\t\ts++;\n\twhile (*s)\n\t{\n\t\to = key;\n\t\twhile (*s && *s != '\\\\')\n\t\t\t*o++ = *s++;\n\n\t\tl = o - key;\n\t\tif (l < 20)\n\t\t{\n\t\t\tCom_Memset (o, ' ', 20-l);\n\t\t\tkey[20] = 0;\n\t\t}\n\t\telse\n\t\t\t*o = 0;\n\t\tCom_Printf (\"%s\", key);\n\n\t\tif (!*s)\n\t\t{\n\t\t\tCom_Printf (\"MISSING VALUE\\n\");\n\t\t\treturn;\n\t\t}\n\n\t\to = value;\n\t\ts++;\n\t\twhile (*s && *s != '\\\\')\n\t\t\t*o++ = *s++;\n\t\t*o = 0;\n\n\t\tif (*s)\n\t\t\ts++;\n\t\tCom_Printf (\"%s\\n\", value);\n\t}\n}\n\n/*\n============\nCom_StringContains\n============\n*/\nchar *Com_StringContains(char *str1, char *str2, int casesensitive) {\n\tint len, i, j;\n\n\tlen = strlen(str1) - strlen(str2);\n\tfor (i = 0; i <= len; i++, str1++) {\n\t\tfor (j = 0; str2[j]; j++) {\n\t\t\tif (casesensitive) {\n\t\t\t\tif (str1[j] != str2[j]) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (toupper(str1[j]) != toupper(str2[j])) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!str2[j]) {\n\t\t\treturn str1;\n\t\t}\n\t}\n\treturn NULL;\n}\n\n/*\n============\nCom_Filter\n============\n*/\nint Com_Filter(char *filter, char *name, int casesensitive)\n{\n\tchar buf[MAX_TOKEN_CHARS];\n\tchar *ptr;\n\tint i, found;\n\n\twhile(*filter) {\n\t\tif (*filter == '*') {\n\t\t\tfilter++;\n\t\t\tfor (i = 0; *filter; i++) {\n\t\t\t\tif (*filter == '*' || *filter == '?') break;\n\t\t\t\tbuf[i] = *filter;\n\t\t\t\tfilter++;\n\t\t\t}\n\t\t\tbuf[i] = '\\0';\n\t\t\tif (strlen(buf)) {\n\t\t\t\tptr = Com_StringContains(name, buf, casesensitive);\n\t\t\t\tif (!ptr) return qfalse;\n\t\t\t\tname = ptr + strlen(buf);\n\t\t\t}\n\t\t}\n\t\telse if (*filter == '?') {\n\t\t\tfilter++;\n\t\t\tname++;\n\t\t}\n\t\telse if (*filter == '[' && *(filter+1) == '[') {\n\t\t\tfilter++;\n\t\t}\n\t\telse if (*filter == '[') {\n\t\t\tfilter++;\n\t\t\tfound = qfalse;\n\t\t\twhile(*filter && !found) {\n\t\t\t\tif (*filter == ']' && *(filter+1) != ']') break;\n\t\t\t\tif (*(filter+1) == '-' && *(filter+2) && (*(filter+2) != ']' || *(filter+3) == ']')) {\n\t\t\t\t\tif (casesensitive) {\n\t\t\t\t\t\tif (*name >= *filter && *name <= *(filter+2)) found = qtrue;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (toupper(*name) >= toupper(*filter) &&\n\t\t\t\t\t\t\ttoupper(*name) <= toupper(*(filter+2))) found = qtrue;\n\t\t\t\t\t}\n\t\t\t\t\tfilter += 3;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (casesensitive) {\n\t\t\t\t\t\tif (*filter == *name) found = qtrue;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (toupper(*filter) == toupper(*name)) found = qtrue;\n\t\t\t\t\t}\n\t\t\t\t\tfilter++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!found) return qfalse;\n\t\t\twhile(*filter) {\n\t\t\t\tif (*filter == ']' && *(filter+1) != ']') break;\n\t\t\t\tfilter++;\n\t\t\t}\n\t\t\tfilter++;\n\t\t\tname++;\n\t\t}\n\t\telse {\n\t\t\tif (casesensitive) {\n\t\t\t\tif (*filter != *name) return qfalse;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (toupper(*filter) != toupper(*name)) return qfalse;\n\t\t\t}\n\t\t\tfilter++;\n\t\t\tname++;\n\t\t}\n\t}\n\treturn qtrue;\n}\n\n/*\n============\nCom_FilterPath\n============\n*/\nint Com_FilterPath(char *filter, char *name, int casesensitive)\n{\n\tint i;\n\tchar new_filter[MAX_QPATH];\n\tchar new_name[MAX_QPATH];\n\n\tfor (i = 0; i < MAX_QPATH-1 && filter[i]; i++) {\n\t\tif ( filter[i] == '\\\\' || filter[i] == ':' ) {\n\t\t\tnew_filter[i] = '/';\n\t\t}\n\t\telse {\n\t\t\tnew_filter[i] = filter[i];\n\t\t}\n\t}\n\tnew_filter[i] = '\\0';\n\tfor (i = 0; i < MAX_QPATH-1 && name[i]; i++) {\n\t\tif ( name[i] == '\\\\' || name[i] == ':' ) {\n\t\t\tnew_name[i] = '/';\n\t\t}\n\t\telse {\n\t\t\tnew_name[i] = name[i];\n\t\t}\n\t}\n\tnew_name[i] = '\\0';\n\treturn Com_Filter(new_filter, new_name, casesensitive);\n}\n\n/*\n============\nCom_HashKey\n============\n*/\nint Com_HashKey(char *string, int maxlen) {\n\tint register hash, i;\n\n\thash = 0;\n\tfor (i = 0; i < maxlen && string[i] != '\\0'; i++) {\n\t\thash += string[i] * (119 + i);\n\t}\n\thash = (hash ^ (hash >> 10) ^ (hash >> 20));\n\treturn hash;\n}\n\n/*\n================\nCom_RealTime\n================\n*/\nint Com_RealTime(qtime_t *qtime) {\n\ttime_t t;\n\tstruct tm *tms;\n\n\tt = time(NULL);\n\tif (!qtime)\n\t\treturn t;\n\ttms = localtime(&t);\n\tif (tms) {\n\t\tqtime->tm_sec = tms->tm_sec;\n\t\tqtime->tm_min = tms->tm_min;\n\t\tqtime->tm_hour = tms->tm_hour;\n\t\tqtime->tm_mday = tms->tm_mday;\n\t\tqtime->tm_mon = tms->tm_mon;\n\t\tqtime->tm_year = tms->tm_year;\n\t\tqtime->tm_wday = tms->tm_wday;\n\t\tqtime->tm_yday = tms->tm_yday;\n\t\tqtime->tm_isdst = tms->tm_isdst;\n\t}\n\treturn t;\n}\n\n\n/*\n==============================================================================\n\n\t\t\t\t\t\tZONE MEMORY ALLOCATION\n\nThere is never any space between memblocks, and there will never be two\ncontiguous free memblocks.\n\nThe rover can be left pointing at a non-empty block\n\nThe zone calls are pretty much only used for small strings and structures,\nall big things are allocated on the hunk.\n==============================================================================\n*/\n\n#define\tZONEID\t0x1d4a11\n#define MINFRAGMENT\t64\n\ntypedef struct zonedebug_s {\n\tchar *label;\n\tchar *file;\n\tint line;\n\tint allocSize;\n} zonedebug_t;\n\ntypedef struct memblock_s {\n\tint\t\tsize;           // including the header and possibly tiny fragments\n\tint     tag;            // a tag of 0 is a free block\n\tstruct memblock_s       *next, *prev;\n\tint     id;        \t\t// should be ZONEID\n#ifdef ZONE_DEBUG\n\tzonedebug_t d;\n#endif\n} memblock_t;\n\ntypedef struct {\n\tint\t\tsize;\t\t\t// total bytes malloced, including header\n\tint\t\tused;\t\t\t// total bytes used\n\tmemblock_t\tblocklist;\t// start / end cap for linked list\n\tmemblock_t\t*rover;\n} memzone_t;\n\n// main zone for all \"dynamic\" memory allocation\nmemzone_t\t*mainzone;\n// we also have a small zone for small allocations that would only\n// fragment the main zone (think of cvar and cmd strings)\nmemzone_t\t*smallzone;\n\nvoid Z_CheckHeap( void );\n\n/*\n========================\nZ_ClearZone\n========================\n*/\nvoid Z_ClearZone( memzone_t *zone, int size ) {\n\tmemblock_t\t*block;\n\t\n\t// set the entire zone to one free block\n\n\tzone->blocklist.next = zone->blocklist.prev = block =\n\t\t(memblock_t *)( (byte *)zone + sizeof(memzone_t) );\n\tzone->blocklist.tag = 1;\t// in use block\n\tzone->blocklist.id = 0;\n\tzone->blocklist.size = 0;\n\tzone->rover = block;\n\tzone->size = size;\n\tzone->used = 0;\n\t\n\tblock->prev = block->next = &zone->blocklist;\n\tblock->tag = 0;\t\t\t// free block\n\tblock->id = ZONEID;\n\tblock->size = size - sizeof(memzone_t);\n}\n\n/*\n========================\nZ_AvailableZoneMemory\n========================\n*/\nint Z_AvailableZoneMemory( memzone_t *zone ) {\n\treturn zone->size - zone->used;\n}\n\n/*\n========================\nZ_AvailableMemory\n========================\n*/\nint Z_AvailableMemory( void ) {\n\treturn Z_AvailableZoneMemory( mainzone );\n}\n\n/*\n========================\nZ_Free\n========================\n*/\nvoid Z_Free( void *ptr ) {\n\tmemblock_t\t*block, *other;\n\tmemzone_t *zone;\n\t\n\tif (!ptr) {\n\t\tCom_Error( ERR_DROP, \"Z_Free: NULL pointer\" );\n\t}\n\n\tblock = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t));\n\tif (block->id != ZONEID) {\n\t\tCom_Error( ERR_FATAL, \"Z_Free: freed a pointer without ZONEID\" );\n\t}\n\tif (block->tag == 0) {\n\t\tCom_Error( ERR_FATAL, \"Z_Free: freed a freed pointer\" );\n\t}\n\t// if static memory\n\tif (block->tag == TAG_STATIC) {\n\t\treturn;\n\t}\n\n\t// check the memory trash tester\n\tif ( *(int *)((byte *)block + block->size - 4 ) != ZONEID ) {\n\t\tCom_Error( ERR_FATAL, \"Z_Free: memory block wrote past end\" );\n\t}\n\n\tif (block->tag == TAG_SMALL) {\n\t\tzone = smallzone;\n\t}\n\telse {\n\t\tzone = mainzone;\n\t}\n\n\tzone->used -= block->size;\n\t// set the block to something that should cause problems\n\t// if it is referenced...\n\tCom_Memset( ptr, 0xaa, block->size - sizeof( *block ) );\n\n\tblock->tag = 0;\t\t// mark as free\n\t\n\tother = block->prev;\n\tif (!other->tag) {\n\t\t// merge with previous free block\n\t\tother->size += block->size;\n\t\tother->next = block->next;\n\t\tother->next->prev = other;\n\t\tif (block == zone->rover) {\n\t\t\tzone->rover = other;\n\t\t}\n\t\tblock = other;\n\t}\n\n\tzone->rover = block;\n\n\tother = block->next;\n\tif ( !other->tag ) {\n\t\t// merge the next free block onto the end\n\t\tblock->size += other->size;\n\t\tblock->next = other->next;\n\t\tblock->next->prev = block;\n\t\tif (other == zone->rover) {\n\t\t\tzone->rover = block;\n\t\t}\n\t}\n}\n\n\n/*\n================\nZ_FreeTags\n================\n*/\nvoid Z_FreeTags( int tag ) {\n\tint\t\t\tcount;\n\tmemzone_t\t*zone;\n\n\tif ( tag == TAG_SMALL ) {\n\t\tzone = smallzone;\n\t}\n\telse {\n\t\tzone = mainzone;\n\t}\n\tcount = 0;\n\t// use the rover as our pointer, because\n\t// Z_Free automatically adjusts it\n\tzone->rover = zone->blocklist.next;\n\tdo {\n\t\tif ( zone->rover->tag == tag ) {\n\t\t\tcount++;\n\t\t\tZ_Free( (void *)(zone->rover + 1) );\n\t\t\tcontinue;\n\t\t}\n\t\tzone->rover = zone->rover->next;\n\t} while ( zone->rover != &zone->blocklist );\n}\n\n\n/*\n================\nZ_TagMalloc\n================\n*/\n#ifdef ZONE_DEBUG\nvoid *Z_TagMallocDebug( int size, int tag, char *label, char *file, int line ) {\n#else\nvoid *Z_TagMalloc( int size, int tag ) {\n#endif\n\tint\t\textra, allocSize;\n\tmemblock_t\t*start, *rover, *new, *base;\n\tmemzone_t *zone;\n\n\tif (!tag) {\n\t\tCom_Error( ERR_FATAL, \"Z_TagMalloc: tried to use a 0 tag\" );\n\t}\n\n\tif ( tag == TAG_SMALL ) {\n\t\tzone = smallzone;\n\t}\n\telse {\n\t\tzone = mainzone;\n\t}\n\n\tallocSize = size;\n\t//\n\t// scan through the block list looking for the first free block\n\t// of sufficient size\n\t//\n\tsize += sizeof(memblock_t);\t// account for size of block header\n\tsize += 4;\t\t\t\t\t// space for memory trash tester\n\tsize = (size + 3) & ~3;\t\t// align to 32 bit boundary\n\t\n\tbase = rover = zone->rover;\n\tstart = base->prev;\n\t\n\tdo {\n\t\tif (rover == start)\t{\n#ifdef ZONE_DEBUG\n\t\t\tZ_LogHeap();\n#endif\n\t\t\t// scaned all the way around the list\n\t\t\tCom_Error( ERR_FATAL, \"Z_Malloc: failed on allocation of %i bytes from the %s zone\",\n\t\t\t\t\t\t\t\tsize, zone == smallzone ? \"small\" : \"main\");\n\t\t\treturn NULL;\n\t\t}\n\t\tif (rover->tag) {\n\t\t\tbase = rover = rover->next;\n\t\t} else {\n\t\t\trover = rover->next;\n\t\t}\n\t} while (base->tag || base->size < size);\n\t\n\t//\n\t// found a block big enough\n\t//\n\textra = base->size - size;\n\tif (extra > MINFRAGMENT) {\n\t\t// there will be a free fragment after the allocated block\n\t\tnew = (memblock_t *) ((byte *)base + size );\n\t\tnew->size = extra;\n\t\tnew->tag = 0;\t\t\t// free block\n\t\tnew->prev = base;\n\t\tnew->id = ZONEID;\n\t\tnew->next = base->next;\n\t\tnew->next->prev = new;\n\t\tbase->next = new;\n\t\tbase->size = size;\n\t}\n\t\n\tbase->tag = tag;\t\t\t// no longer a free block\n\t\n\tzone->rover = base->next;\t// next allocation will start looking here\n\tzone->used += base->size;\t//\n\t\n\tbase->id = ZONEID;\n\n#ifdef ZONE_DEBUG\n\tbase->d.label = label;\n\tbase->d.file = file;\n\tbase->d.line = line;\n\tbase->d.allocSize = allocSize;\n#endif\n\n\t// marker for memory trash testing\n\t*(int *)((byte *)base + base->size - 4) = ZONEID;\n\n\treturn (void *) ((byte *)base + sizeof(memblock_t));\n}\n\n/*\n========================\nZ_Malloc\n========================\n*/\n#ifdef ZONE_DEBUG\nvoid *Z_MallocDebug( int size, char *label, char *file, int line ) {\n#else\nvoid *Z_Malloc( int size ) {\n#endif\n\tvoid\t*buf;\n\t\n  //Z_CheckHeap ();\t// DEBUG\n\n#ifdef ZONE_DEBUG\n\tbuf = Z_TagMallocDebug( size, TAG_GENERAL, label, file, line );\n#else\n\tbuf = Z_TagMalloc( size, TAG_GENERAL );\n#endif\n\tCom_Memset( buf, 0, size );\n\n\treturn buf;\n}\n\n#ifdef ZONE_DEBUG\nvoid *S_MallocDebug( int size, char *label, char *file, int line ) {\n\treturn Z_TagMallocDebug( size, TAG_SMALL, label, file, line );\n}\n#else\nvoid *S_Malloc( int size ) {\n\treturn Z_TagMalloc( size, TAG_SMALL );\n}\n#endif\n\n/*\n========================\nZ_CheckHeap\n========================\n*/\nvoid Z_CheckHeap( void ) {\n\tmemblock_t\t*block;\n\t\n\tfor (block = mainzone->blocklist.next ; ; block = block->next) {\n\t\tif (block->next == &mainzone->blocklist) {\n\t\t\tbreak;\t\t\t// all blocks have been hit\n\t\t}\n\t\tif ( (byte *)block + block->size != (byte *)block->next)\n\t\t\tCom_Error( ERR_FATAL, \"Z_CheckHeap: block size does not touch the next block\\n\" );\n\t\tif ( block->next->prev != block) {\n\t\t\tCom_Error( ERR_FATAL, \"Z_CheckHeap: next block doesn't have proper back link\\n\" );\n\t\t}\n\t\tif ( !block->tag && !block->next->tag ) {\n\t\t\tCom_Error( ERR_FATAL, \"Z_CheckHeap: two consecutive free blocks\\n\" );\n\t\t}\n\t}\n}\n\n/*\n========================\nZ_LogZoneHeap\n========================\n*/\nvoid Z_LogZoneHeap( memzone_t *zone, char *name ) {\n#ifdef ZONE_DEBUG\n\tchar dump[32], *ptr;\n\tint  i, j;\n#endif\n\tmemblock_t\t*block;\n\tchar\t\tbuf[4096];\n\tint size, allocSize, numBlocks;\n\n\tif (!logfile || !FS_Initialized())\n\t\treturn;\n\tsize = allocSize = numBlocks = 0;\n\tCom_sprintf(buf, sizeof(buf), \"\\r\\n================\\r\\n%s log\\r\\n================\\r\\n\", name);\n\tFS_Write(buf, strlen(buf), logfile);\n\tfor (block = zone->blocklist.next ; block->next != &zone->blocklist; block = block->next) {\n\t\tif (block->tag) {\n#ifdef ZONE_DEBUG\n\t\t\tptr = ((char *) block) + sizeof(memblock_t);\n\t\t\tj = 0;\n\t\t\tfor (i = 0; i < 20 && i < block->d.allocSize; i++) {\n\t\t\t\tif (ptr[i] >= 32 && ptr[i] < 127) {\n\t\t\t\t\tdump[j++] = ptr[i];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdump[j++] = '_';\n\t\t\t\t}\n\t\t\t}\n\t\t\tdump[j] = '\\0';\n\t\t\tCom_sprintf(buf, sizeof(buf), \"size = %8d: %s, line: %d (%s) [%s]\\r\\n\", block->d.allocSize, block->d.file, block->d.line, block->d.label, dump);\n\t\t\tFS_Write(buf, strlen(buf), logfile);\n\t\t\tallocSize += block->d.allocSize;\n#endif\n\t\t\tsize += block->size;\n\t\t\tnumBlocks++;\n\t\t}\n\t}\n#ifdef ZONE_DEBUG\n\t// subtract debug memory\n\tsize -= numBlocks * sizeof(zonedebug_t);\n#else\n\tallocSize = numBlocks * sizeof(memblock_t); // + 32 bit alignment\n#endif\n\tCom_sprintf(buf, sizeof(buf), \"%d %s memory in %d blocks\\r\\n\", size, name, numBlocks);\n\tFS_Write(buf, strlen(buf), logfile);\n\tCom_sprintf(buf, sizeof(buf), \"%d %s memory overhead\\r\\n\", size - allocSize, name);\n\tFS_Write(buf, strlen(buf), logfile);\n}\n\n/*\n========================\nZ_LogHeap\n========================\n*/\nvoid Z_LogHeap( void ) {\n\tZ_LogZoneHeap( mainzone, \"MAIN\" );\n\tZ_LogZoneHeap( smallzone, \"SMALL\" );\n}\n\n// static mem blocks to reduce a lot of small zone overhead\ntypedef struct memstatic_s {\n\tmemblock_t b;\n\tbyte mem[2];\n} memstatic_t;\n\n// bk001204 - initializer brackets\nmemstatic_t emptystring =\n\t{ {(sizeof(memblock_t)+2 + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'\\0', '\\0'} };\nmemstatic_t numberstring[] = {\n\t{ {(sizeof(memstatic_t) + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'0', '\\0'} },\n\t{ {(sizeof(memstatic_t) + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'1', '\\0'} },\n\t{ {(sizeof(memstatic_t) + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'2', '\\0'} },\n\t{ {(sizeof(memstatic_t) + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'3', '\\0'} },\n\t{ {(sizeof(memstatic_t) + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'4', '\\0'} },\n\t{ {(sizeof(memstatic_t) + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'5', '\\0'} },\n\t{ {(sizeof(memstatic_t) + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'6', '\\0'} },\n\t{ {(sizeof(memstatic_t) + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'7', '\\0'} },\n\t{ {(sizeof(memstatic_t) + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'8', '\\0'} }, \n\t{ {(sizeof(memstatic_t) + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'9', '\\0'} }\n};\n\n/*\n========================\nCopyString\n\n NOTE:\tnever write over the memory CopyString returns because\n\t\tmemory from a memstatic_t might be returned\n========================\n*/\nchar *CopyString( const char *in ) {\n\tchar\t*out;\n\n\tif (!in[0]) {\n\t\treturn ((char *)&emptystring) + sizeof(memblock_t);\n\t}\n\telse if (!in[1]) {\n\t\tif (in[0] >= '0' && in[0] <= '9') {\n\t\t\treturn ((char *)&numberstring[in[0]-'0']) + sizeof(memblock_t);\n\t\t}\n\t}\n\tout = S_Malloc (strlen(in)+1);\n\tstrcpy (out, in);\n\treturn out;\n}\n\n/*\n==============================================================================\n\nGoals:\n\treproducable without history effects -- no out of memory errors on weird map to map changes\n\tallow restarting of the client without fragmentation\n\tminimize total pages in use at run time\n\tminimize total pages needed during load time\n\n  Single block of memory with stack allocators coming from both ends towards the middle.\n\n  One side is designated the temporary memory allocator.\n\n  Temporary memory can be allocated and freed in any order.\n\n  A highwater mark is kept of the most in use at any time.\n\n  When there is no temporary memory allocated, the permanent and temp sides\n  can be switched, allowing the already touched temp memory to be used for\n  permanent storage.\n\n  Temp memory must never be allocated on two ends at once, or fragmentation\n  could occur.\n\n  If we have any in-use temp memory, additional temp allocations must come from\n  that side.\n\n  If not, we can choose to make either side the new temp side and push future\n  permanent allocations to the other side.  Permanent allocations should be\n  kept on the side that has the current greatest wasted highwater mark.\n\n==============================================================================\n*/\n\n\n#define\tHUNK_MAGIC\t0x89537892\n#define\tHUNK_FREE_MAGIC\t0x89537893\n\ntypedef struct {\n\tint\t\tmagic;\n\tint\t\tsize;\n} hunkHeader_t;\n\ntypedef struct {\n\tint\t\tmark;\n\tint\t\tpermanent;\n\tint\t\ttemp;\n\tint\t\ttempHighwater;\n} hunkUsed_t;\n\ntypedef struct hunkblock_s {\n\tint size;\n\tbyte printed;\n\tstruct hunkblock_s *next;\n\tchar *label;\n\tchar *file;\n\tint line;\n} hunkblock_t;\n\nstatic\thunkblock_t *hunkblocks;\n\nstatic\thunkUsed_t\thunk_low, hunk_high;\nstatic\thunkUsed_t\t*hunk_permanent, *hunk_temp;\n\nstatic\tbyte\t*s_hunkData = NULL;\nstatic\tint\t\ts_hunkTotal;\n\nstatic\tint\t\ts_zoneTotal;\nstatic\tint\t\ts_smallZoneTotal;\n\n\n/*\n=================\nCom_Meminfo_f\n=================\n*/\nvoid Com_Meminfo_f( void ) {\n\tmemblock_t\t*block;\n\tint\t\t\tzoneBytes, zoneBlocks;\n\tint\t\t\tsmallZoneBytes, smallZoneBlocks;\n\tint\t\t\tbotlibBytes, rendererBytes;\n\tint\t\t\tunused;\n\n\tzoneBytes = 0;\n\tbotlibBytes = 0;\n\trendererBytes = 0;\n\tzoneBlocks = 0;\n\tfor (block = mainzone->blocklist.next ; ; block = block->next) {\n\t\tif ( Cmd_Argc() != 1 ) {\n\t\t\tCom_Printf (\"block:%p    size:%7i    tag:%3i\\n\",\n\t\t\t\tblock, block->size, block->tag);\n\t\t}\n\t\tif ( block->tag ) {\n\t\t\tzoneBytes += block->size;\n\t\t\tzoneBlocks++;\n\t\t\tif ( block->tag == TAG_BOTLIB ) {\n\t\t\t\tbotlibBytes += block->size;\n\t\t\t} else if ( block->tag == TAG_RENDERER ) {\n\t\t\t\trendererBytes += block->size;\n\t\t\t}\n\t\t}\n\n\t\tif (block->next == &mainzone->blocklist) {\n\t\t\tbreak;\t\t\t// all blocks have been hit\t\n\t\t}\n\t\tif ( (byte *)block + block->size != (byte *)block->next) {\n\t\t\tCom_Printf (\"ERROR: block size does not touch the next block\\n\");\n\t\t}\n\t\tif ( block->next->prev != block) {\n\t\t\tCom_Printf (\"ERROR: next block doesn't have proper back link\\n\");\n\t\t}\n\t\tif ( !block->tag && !block->next->tag ) {\n\t\t\tCom_Printf (\"ERROR: two consecutive free blocks\\n\");\n\t\t}\n\t}\n\n\tsmallZoneBytes = 0;\n\tsmallZoneBlocks = 0;\n\tfor (block = smallzone->blocklist.next ; ; block = block->next) {\n\t\tif ( block->tag ) {\n\t\t\tsmallZoneBytes += block->size;\n\t\t\tsmallZoneBlocks++;\n\t\t}\n\n\t\tif (block->next == &smallzone->blocklist) {\n\t\t\tbreak;\t\t\t// all blocks have been hit\t\n\t\t}\n\t}\n\n\tCom_Printf( \"%8i bytes total hunk\\n\", s_hunkTotal );\n\tCom_Printf( \"%8i bytes total zone\\n\", s_zoneTotal );\n\tCom_Printf( \"\\n\" );\n\tCom_Printf( \"%8i low mark\\n\", hunk_low.mark );\n\tCom_Printf( \"%8i low permanent\\n\", hunk_low.permanent );\n\tif ( hunk_low.temp != hunk_low.permanent ) {\n\t\tCom_Printf( \"%8i low temp\\n\", hunk_low.temp );\n\t}\n\tCom_Printf( \"%8i low tempHighwater\\n\", hunk_low.tempHighwater );\n\tCom_Printf( \"\\n\" );\n\tCom_Printf( \"%8i high mark\\n\", hunk_high.mark );\n\tCom_Printf( \"%8i high permanent\\n\", hunk_high.permanent );\n\tif ( hunk_high.temp != hunk_high.permanent ) {\n\t\tCom_Printf( \"%8i high temp\\n\", hunk_high.temp );\n\t}\n\tCom_Printf( \"%8i high tempHighwater\\n\", hunk_high.tempHighwater );\n\tCom_Printf( \"\\n\" );\n\tCom_Printf( \"%8i total hunk in use\\n\", hunk_low.permanent + hunk_high.permanent );\n\tunused = 0;\n\tif ( hunk_low.tempHighwater > hunk_low.permanent ) {\n\t\tunused += hunk_low.tempHighwater - hunk_low.permanent;\n\t}\n\tif ( hunk_high.tempHighwater > hunk_high.permanent ) {\n\t\tunused += hunk_high.tempHighwater - hunk_high.permanent;\n\t}\n\tCom_Printf( \"%8i unused highwater\\n\", unused );\n\tCom_Printf( \"\\n\" );\n\tCom_Printf( \"%8i bytes in %i zone blocks\\n\", zoneBytes, zoneBlocks\t);\n\tCom_Printf( \"        %8i bytes in dynamic botlib\\n\", botlibBytes );\n\tCom_Printf( \"        %8i bytes in dynamic renderer\\n\", rendererBytes );\n\tCom_Printf( \"        %8i bytes in dynamic other\\n\", zoneBytes - ( botlibBytes + rendererBytes ) );\n\tCom_Printf( \"        %8i bytes in small Zone memory\\n\", smallZoneBytes );\n}\n\n/*\n===============\nCom_TouchMemory\n\nTouch all known used data to make sure it is paged in\n===============\n*/\nvoid Com_TouchMemory( void ) {\n\tint\t\tstart, end;\n\tint\t\ti, j;\n\tint\t\tsum;\n\tmemblock_t\t*block;\n\n\tZ_CheckHeap();\n\n\tstart = Sys_Milliseconds();\n\n\tsum = 0;\n\n\tj = hunk_low.permanent >> 2;\n\tfor ( i = 0 ; i < j ; i+=64 ) {\t\t\t// only need to touch each page\n\t\tsum += ((int *)s_hunkData)[i];\n\t}\n\n\ti = ( s_hunkTotal - hunk_high.permanent ) >> 2;\n\tj = hunk_high.permanent >> 2;\n\tfor (  ; i < j ; i+=64 ) {\t\t\t// only need to touch each page\n\t\tsum += ((int *)s_hunkData)[i];\n\t}\n\n\tfor (block = mainzone->blocklist.next ; ; block = block->next) {\n\t\tif ( block->tag ) {\n\t\t\tj = block->size >> 2;\n\t\t\tfor ( i = 0 ; i < j ; i+=64 ) {\t\t\t\t// only need to touch each page\n\t\t\t\tsum += ((int *)block)[i];\n\t\t\t}\n\t\t}\n\t\tif ( block->next == &mainzone->blocklist ) {\n\t\t\tbreak;\t\t\t// all blocks have been hit\t\n\t\t}\n\t}\n\n\tend = Sys_Milliseconds();\n\n\tCom_Printf( \"Com_TouchMemory: %i msec\\n\", end - start );\n}\n\n\n\n/*\n=================\nCom_InitZoneMemory\n=================\n*/\nvoid Com_InitSmallZoneMemory( void ) {\n\ts_smallZoneTotal = 512 * 1024;\n\t// bk001205 - was malloc\n\tsmallzone = calloc( s_smallZoneTotal, 1 );\n\tif ( !smallzone ) {\n\t\tCom_Error( ERR_FATAL, \"Small zone data failed to allocate %1.1f megs\", (float)s_smallZoneTotal / (1024*1024) );\n\t}\n\tZ_ClearZone( smallzone, s_smallZoneTotal );\n\t\n\treturn;\n}\n\nvoid Com_InitZoneMemory( void ) {\n\tcvar_t\t*cv;\n\t// allocate the random block zone\n\tcv = Cvar_Get( \"com_zoneMegs\", DEF_COMZONEMEGS, CVAR_LATCH | CVAR_ARCHIVE );\n\n\tif ( cv->integer < 20 ) {\n\t\ts_zoneTotal = 1024 * 1024 * 16;\n\t} else {\n\t\ts_zoneTotal = cv->integer * 1024 * 1024;\n\t}\n\n\t// bk001205 - was malloc\n\tmainzone = calloc( s_zoneTotal, 1 );\n\tif ( !mainzone ) {\n\t\tCom_Error( ERR_FATAL, \"Zone data failed to allocate %i megs\", s_zoneTotal / (1024*1024) );\n\t}\n\tZ_ClearZone( mainzone, s_zoneTotal );\n\n}\n\n/*\n=================\nHunk_Log\n=================\n*/\nvoid Hunk_Log( void) {\n\thunkblock_t\t*block;\n\tchar\t\tbuf[4096];\n\tint size, numBlocks;\n\n\tif (!logfile || !FS_Initialized())\n\t\treturn;\n\tsize = 0;\n\tnumBlocks = 0;\n\tCom_sprintf(buf, sizeof(buf), \"\\r\\n================\\r\\nHunk log\\r\\n================\\r\\n\");\n\tFS_Write(buf, strlen(buf), logfile);\n\tfor (block = hunkblocks ; block; block = block->next) {\n#ifdef HUNK_DEBUG\n\t\tCom_sprintf(buf, sizeof(buf), \"size = %8d: %s, line: %d (%s)\\r\\n\", block->size, block->file, block->line, block->label);\n\t\tFS_Write(buf, strlen(buf), logfile);\n#endif\n\t\tsize += block->size;\n\t\tnumBlocks++;\n\t}\n\tCom_sprintf(buf, sizeof(buf), \"%d Hunk memory\\r\\n\", size);\n\tFS_Write(buf, strlen(buf), logfile);\n\tCom_sprintf(buf, sizeof(buf), \"%d hunk blocks\\r\\n\", numBlocks);\n\tFS_Write(buf, strlen(buf), logfile);\n}\n\n/*\n=================\nHunk_SmallLog\n=================\n*/\nvoid Hunk_SmallLog( void) {\n\thunkblock_t\t*block, *block2;\n\tchar\t\tbuf[4096];\n\tint size, locsize, numBlocks;\n\n\tif (!logfile || !FS_Initialized())\n\t\treturn;\n\tfor (block = hunkblocks ; block; block = block->next) {\n\t\tblock->printed = qfalse;\n\t}\n\tsize = 0;\n\tnumBlocks = 0;\n\tCom_sprintf(buf, sizeof(buf), \"\\r\\n================\\r\\nHunk Small log\\r\\n================\\r\\n\");\n\tFS_Write(buf, strlen(buf), logfile);\n\tfor (block = hunkblocks; block; block = block->next) {\n\t\tif (block->printed) {\n\t\t\tcontinue;\n\t\t}\n\t\tlocsize = block->size;\n\t\tfor (block2 = block->next; block2; block2 = block2->next) {\n\t\t\tif (block->line != block2->line) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (Q_stricmp(block->file, block2->file)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tsize += block2->size;\n\t\t\tlocsize += block2->size;\n\t\t\tblock2->printed = qtrue;\n\t\t}\n#ifdef HUNK_DEBUG\n\t\tCom_sprintf(buf, sizeof(buf), \"size = %8d: %s, line: %d (%s)\\r\\n\", locsize, block->file, block->line, block->label);\n\t\tFS_Write(buf, strlen(buf), logfile);\n#endif\n\t\tsize += block->size;\n\t\tnumBlocks++;\n\t}\n\tCom_sprintf(buf, sizeof(buf), \"%d Hunk memory\\r\\n\", size);\n\tFS_Write(buf, strlen(buf), logfile);\n\tCom_sprintf(buf, sizeof(buf), \"%d hunk blocks\\r\\n\", numBlocks);\n\tFS_Write(buf, strlen(buf), logfile);\n}\n\n/*\n=================\nCom_InitZoneMemory\n=================\n*/\nvoid Com_InitHunkMemory( void ) {\n\tcvar_t\t*cv;\n\tint nMinAlloc;\n\tchar *pMsg = NULL;\n\n\t// make sure the file system has allocated and \"not\" freed any temp blocks\n\t// this allows the config and product id files ( journal files too ) to be loaded\n\t// by the file system without redunant routines in the file system utilizing different \n\t// memory systems\n\tif (FS_LoadStack() != 0) {\n\t\tCom_Error( ERR_FATAL, \"Hunk initialization failed. File system load stack not zero\");\n\t}\n\n\t// allocate the stack based hunk allocator\n\tcv = Cvar_Get( \"com_hunkMegs\", DEF_COMHUNKMEGS, CVAR_LATCH | CVAR_ARCHIVE );\n\n\t// if we are not dedicated min allocation is 56, otherwise min is 1\n\tif (com_dedicated && com_dedicated->integer) {\n\t\tnMinAlloc = MIN_DEDICATED_COMHUNKMEGS;\n\t\tpMsg = \"Minimum com_hunkMegs for a dedicated server is %i, allocating %i megs.\\n\";\n\t}\n\telse {\n\t\tnMinAlloc = MIN_COMHUNKMEGS;\n\t\tpMsg = \"Minimum com_hunkMegs is %i, allocating %i megs.\\n\";\n\t}\n\n\tif ( cv->integer < nMinAlloc ) {\n\t\ts_hunkTotal = 1024 * 1024 * nMinAlloc;\n\t    Com_Printf(pMsg, nMinAlloc, s_hunkTotal / (1024 * 1024));\n\t} else {\n\t\ts_hunkTotal = cv->integer * 1024 * 1024;\n\t}\n\n\n\t// bk001205 - was malloc\n\ts_hunkData = calloc( s_hunkTotal + 31, 1 );\n\tif ( !s_hunkData ) {\n\t\tCom_Error( ERR_FATAL, \"Hunk data failed to allocate %i megs\", s_hunkTotal / (1024*1024) );\n\t}\n\t// cacheline align\n\ts_hunkData = (byte *) ( ( (int)s_hunkData + 31 ) & ~31 );\n\tHunk_Clear();\n\n\tCmd_AddCommand( \"meminfo\", Com_Meminfo_f );\n#ifdef ZONE_DEBUG\n\tCmd_AddCommand( \"zonelog\", Z_LogHeap );\n#endif\n#ifdef HUNK_DEBUG\n\tCmd_AddCommand( \"hunklog\", Hunk_Log );\n\tCmd_AddCommand( \"hunksmalllog\", Hunk_SmallLog );\n#endif\n}\n\n/*\n====================\nHunk_MemoryRemaining\n====================\n*/\nint\tHunk_MemoryRemaining( void ) {\n\tint\t\tlow, high;\n\n\tlow = hunk_low.permanent > hunk_low.temp ? hunk_low.permanent : hunk_low.temp;\n\thigh = hunk_high.permanent > hunk_high.temp ? hunk_high.permanent : hunk_high.temp;\n\n\treturn s_hunkTotal - ( low + high );\n}\n\n/*\n===================\nHunk_SetMark\n\nThe server calls this after the level and game VM have been loaded\n===================\n*/\nvoid Hunk_SetMark( void ) {\n\thunk_low.mark = hunk_low.permanent;\n\thunk_high.mark = hunk_high.permanent;\n}\n\n/*\n=================\nHunk_ClearToMark\n\nThe client calls this before starting a vid_restart or snd_restart\n=================\n*/\nvoid Hunk_ClearToMark( void ) {\n\thunk_low.permanent = hunk_low.temp = hunk_low.mark;\n\thunk_high.permanent = hunk_high.temp = hunk_high.mark;\n}\n\n/*\n=================\nHunk_CheckMark\n=================\n*/\nqboolean Hunk_CheckMark( void ) {\n\tif( hunk_low.mark || hunk_high.mark ) {\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\nvoid CL_ShutdownCGame( void );\nvoid CL_ShutdownUI( void );\nvoid SV_ShutdownGameProgs( void );\n\n/*\n=================\nHunk_Clear\n\nThe server calls this before shutting down or loading a new map\n=================\n*/\nvoid Hunk_Clear( void ) {\n\n#ifndef DEDICATED\n\tCL_ShutdownCGame();\n\tCL_ShutdownUI();\n#endif\n\tSV_ShutdownGameProgs();\n#ifndef DEDICATED\n\tCIN_CloseAllVideos();\n#endif\n\thunk_low.mark = 0;\n\thunk_low.permanent = 0;\n\thunk_low.temp = 0;\n\thunk_low.tempHighwater = 0;\n\n\thunk_high.mark = 0;\n\thunk_high.permanent = 0;\n\thunk_high.temp = 0;\n\thunk_high.tempHighwater = 0;\n\n\thunk_permanent = &hunk_low;\n\thunk_temp = &hunk_high;\n\n\tCom_Printf( \"Hunk_Clear: reset the hunk ok\\n\" );\n\tVM_Clear();\n#ifdef HUNK_DEBUG\n\thunkblocks = NULL;\n#endif\n}\n\nstatic void Hunk_SwapBanks( void ) {\n\thunkUsed_t\t*swap;\n\n\t// can't swap banks if there is any temp already allocated\n\tif ( hunk_temp->temp != hunk_temp->permanent ) {\n\t\treturn;\n\t}\n\n\t// if we have a larger highwater mark on this side, start making\n\t// our permanent allocations here and use the other side for temp\n\tif ( hunk_temp->tempHighwater - hunk_temp->permanent >\n\t\thunk_permanent->tempHighwater - hunk_permanent->permanent ) {\n\t\tswap = hunk_temp;\n\t\thunk_temp = hunk_permanent;\n\t\thunk_permanent = swap;\n\t}\n}\n\n/*\n=================\nHunk_Alloc\n\nAllocate permanent (until the hunk is cleared) memory\n=================\n*/\n#ifdef HUNK_DEBUG\nvoid *Hunk_AllocDebug( int size, ha_pref preference, char *label, char *file, int line ) {\n#else\nvoid *Hunk_Alloc( int size, ha_pref preference ) {\n#endif\n\tvoid\t*buf;\n\n\tif ( s_hunkData == NULL)\n\t{\n\t\tCom_Error( ERR_FATAL, \"Hunk_Alloc: Hunk memory system not initialized\" );\n\t}\n\n\t// can't do preference if there is any temp allocated\n\tif (preference == h_dontcare || hunk_temp->temp != hunk_temp->permanent) {\n\t\tHunk_SwapBanks();\n\t} else {\n\t\tif (preference == h_low && hunk_permanent != &hunk_low) {\n\t\t\tHunk_SwapBanks();\n\t\t} else if (preference == h_high && hunk_permanent != &hunk_high) {\n\t\t\tHunk_SwapBanks();\n\t\t}\n\t}\n\n#ifdef HUNK_DEBUG\n\tsize += sizeof(hunkblock_t);\n#endif\n\n\t// round to cacheline\n\tsize = (size+31)&~31;\n\n\tif ( hunk_low.temp + hunk_high.temp + size > s_hunkTotal ) {\n#ifdef HUNK_DEBUG\n\t\tHunk_Log();\n\t\tHunk_SmallLog();\n#endif\n\t\tCom_Error( ERR_DROP, \"Hunk_Alloc failed on %i\", size );\n\t}\n\n\tif ( hunk_permanent == &hunk_low ) {\n\t\tbuf = (void *)(s_hunkData + hunk_permanent->permanent);\n\t\thunk_permanent->permanent += size;\n\t} else {\n\t\thunk_permanent->permanent += size;\n\t\tbuf = (void *)(s_hunkData + s_hunkTotal - hunk_permanent->permanent );\n\t}\n\n\thunk_permanent->temp = hunk_permanent->permanent;\n\n\tCom_Memset( buf, 0, size );\n\n#ifdef HUNK_DEBUG\n\t{\n\t\thunkblock_t *block;\n\n\t\tblock = (hunkblock_t *) buf;\n\t\tblock->size = size - sizeof(hunkblock_t);\n\t\tblock->file = file;\n\t\tblock->label = label;\n\t\tblock->line = line;\n\t\tblock->next = hunkblocks;\n\t\thunkblocks = block;\n\t\tbuf = ((byte *) buf) + sizeof(hunkblock_t);\n\t}\n#endif\n\treturn buf;\n}\n\n/*\n=================\nHunk_AllocateTempMemory\n\nThis is used by the file loading system.\nMultiple files can be loaded in temporary memory.\nWhen the files-in-use count reaches zero, all temp memory will be deleted\n=================\n*/\nvoid *Hunk_AllocateTempMemory( int size ) {\n\tvoid\t\t*buf;\n\thunkHeader_t\t*hdr;\n\n\t// return a Z_Malloc'd block if the hunk has not been initialized\n\t// this allows the config and product id files ( journal files too ) to be loaded\n\t// by the file system without redunant routines in the file system utilizing different \n\t// memory systems\n\tif ( s_hunkData == NULL )\n\t{\n\t\treturn Z_Malloc(size);\n\t}\n\n\tHunk_SwapBanks();\n\n\tsize = ( (size+3)&~3 ) + sizeof( hunkHeader_t );\n\n\tif ( hunk_temp->temp + hunk_permanent->permanent + size > s_hunkTotal ) {\n\t\tCom_Error( ERR_DROP, \"Hunk_AllocateTempMemory: failed on %i\", size );\n\t}\n\n\tif ( hunk_temp == &hunk_low ) {\n\t\tbuf = (void *)(s_hunkData + hunk_temp->temp);\n\t\thunk_temp->temp += size;\n\t} else {\n\t\thunk_temp->temp += size;\n\t\tbuf = (void *)(s_hunkData + s_hunkTotal - hunk_temp->temp );\n\t}\n\n\tif ( hunk_temp->temp > hunk_temp->tempHighwater ) {\n\t\thunk_temp->tempHighwater = hunk_temp->temp;\n\t}\n\n\thdr = (hunkHeader_t *)buf;\n\tbuf = (void *)(hdr+1);\n\n\thdr->magic = HUNK_MAGIC;\n\thdr->size = size;\n\n\t// don't bother clearing, because we are going to load a file over it\n\treturn buf;\n}\n\n\n/*\n==================\nHunk_FreeTempMemory\n==================\n*/\nvoid Hunk_FreeTempMemory( void *buf ) {\n\thunkHeader_t\t*hdr;\n\n\t  // free with Z_Free if the hunk has not been initialized\n\t  // this allows the config and product id files ( journal files too ) to be loaded\n\t  // by the file system without redunant routines in the file system utilizing different \n\t  // memory systems\n\tif ( s_hunkData == NULL )\n\t{\n\t\tZ_Free(buf);\n\t\treturn;\n\t}\n\n\n\thdr = ( (hunkHeader_t *)buf ) - 1;\n\tif ( hdr->magic != HUNK_MAGIC ) {\n\t\tCom_Error( ERR_FATAL, \"Hunk_FreeTempMemory: bad magic\" );\n\t}\n\n\thdr->magic = HUNK_FREE_MAGIC;\n\n\t// this only works if the files are freed in stack order,\n\t// otherwise the memory will stay around until Hunk_ClearTempMemory\n\tif ( hunk_temp == &hunk_low ) {\n\t\tif ( hdr == (void *)(s_hunkData + hunk_temp->temp - hdr->size ) ) {\n\t\t\thunk_temp->temp -= hdr->size;\n\t\t} else {\n\t\t\tCom_Printf( \"Hunk_FreeTempMemory: not the final block\\n\" );\n\t\t}\n\t} else {\n\t\tif ( hdr == (void *)(s_hunkData + s_hunkTotal - hunk_temp->temp ) ) {\n\t\t\thunk_temp->temp -= hdr->size;\n\t\t} else {\n\t\t\tCom_Printf( \"Hunk_FreeTempMemory: not the final block\\n\" );\n\t\t}\n\t}\n}\n\n\n/*\n=================\nHunk_ClearTempMemory\n\nThe temp space is no longer needed.  If we have left more\ntouched but unused memory on this side, have future\npermanent allocs use this side.\n=================\n*/\nvoid Hunk_ClearTempMemory( void ) {\n\tif ( s_hunkData != NULL ) {\n\t\thunk_temp->temp = hunk_temp->permanent;\n\t}\n}\n\n/*\n=================\nHunk_Trash\n=================\n*/\nvoid Hunk_Trash( void ) {\n\tint length, i, rnd;\n\tchar *buf, value;\n\n\treturn;\n\n\tif ( s_hunkData == NULL )\n\t\treturn;\n\n#ifdef _DEBUG\n\tCom_Error(ERR_DROP, \"hunk trashed\\n\");\n\treturn;\n#endif\n\n\tCvar_Set(\"com_jp\", \"1\");\n\tHunk_SwapBanks();\n\n\tif ( hunk_permanent == &hunk_low ) {\n\t\tbuf = (void *)(s_hunkData + hunk_permanent->permanent);\n\t} else {\n\t\tbuf = (void *)(s_hunkData + s_hunkTotal - hunk_permanent->permanent );\n\t}\n\tlength = hunk_permanent->permanent;\n\n\tif (length > 0x7FFFF) {\n\t\t//randomly trash data within buf\n\t\trnd = random() * (length - 0x7FFFF);\n\t\tvalue = 31;\n\t\tfor (i = 0; i < 0x7FFFF; i++) {\n\t\t\tvalue *= 109;\n\t\t\tbuf[rnd+i] ^= value;\n\t\t}\n\t}\n}\n\n/*\n===================================================================\n\nEVENTS AND JOURNALING\n\nIn addition to these events, .cfg files are also copied to the\njournaled file\n===================================================================\n*/\n\n// bk001129 - here we go again: upped from 64\n// FIXME TTimo blunt upping from 256 to 1024\n// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=5\n#define\tMAX_PUSHED_EVENTS\t            1024\n// bk001129 - init, also static\nstatic int com_pushedEventsHead = 0;\nstatic int com_pushedEventsTail = 0;\n// bk001129 - static\nstatic sysEvent_t\tcom_pushedEvents[MAX_PUSHED_EVENTS];\n\n/*\n=================\nCom_InitJournaling\n=================\n*/\nvoid Com_InitJournaling( void ) {\n\tCom_StartupVariable( \"journal\" );\n\tcom_journal = Cvar_Get (\"journal\", \"0\", CVAR_INIT);\n\tif ( !com_journal->integer ) {\n\t\treturn;\n\t}\n\n\tif ( com_journal->integer == 1 ) {\n\t\tCom_Printf( \"Journaling events\\n\");\n\t\tcom_journalFile = FS_FOpenFileWrite( \"journal.dat\" );\n\t\tcom_journalDataFile = FS_FOpenFileWrite( \"journaldata.dat\" );\n\t} else if ( com_journal->integer == 2 ) {\n\t\tCom_Printf( \"Replaying journaled events\\n\");\n\t\tFS_FOpenFileRead( \"journal.dat\", &com_journalFile, qtrue );\n\t\tFS_FOpenFileRead( \"journaldata.dat\", &com_journalDataFile, qtrue );\n\t}\n\n\tif ( !com_journalFile || !com_journalDataFile ) {\n\t\tCvar_Set( \"com_journal\", \"0\" );\n\t\tcom_journalFile = 0;\n\t\tcom_journalDataFile = 0;\n\t\tCom_Printf( \"Couldn't open journal files\\n\" );\n\t}\n}\n\n/*\n=================\nCom_GetRealEvent\n=================\n*/\nsysEvent_t\tCom_GetRealEvent( void ) {\n\tint\t\t\tr;\n\tsysEvent_t\tev;\n\n\t// either get an event from the system or the journal file\n\tif ( com_journal->integer == 2 ) {\n\t\tr = FS_Read( &ev, sizeof(ev), com_journalFile );\n\t\tif ( r != sizeof(ev) ) {\n\t\t\tCom_Error( ERR_FATAL, \"Error reading from journal file\" );\n\t\t}\n\t\tif ( ev.evPtrLength ) {\n\t\t\tev.evPtr = Z_Malloc( ev.evPtrLength );\n\t\t\tr = FS_Read( ev.evPtr, ev.evPtrLength, com_journalFile );\n\t\t\tif ( r != ev.evPtrLength ) {\n\t\t\t\tCom_Error( ERR_FATAL, \"Error reading from journal file\" );\n\t\t\t}\n\t\t}\n\t} else {\n\t\tev = Sys_GetEvent();\n\n\t\t// write the journal value out if needed\n\t\tif ( com_journal->integer == 1 ) {\n\t\t\tr = FS_Write( &ev, sizeof(ev), com_journalFile );\n\t\t\tif ( r != sizeof(ev) ) {\n\t\t\t\tCom_Error( ERR_FATAL, \"Error writing to journal file\" );\n\t\t\t}\n\t\t\tif ( ev.evPtrLength ) {\n\t\t\t\tr = FS_Write( ev.evPtr, ev.evPtrLength, com_journalFile );\n\t\t\t\tif ( r != ev.evPtrLength ) {\n\t\t\t\t\tCom_Error( ERR_FATAL, \"Error writing to journal file\" );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn ev;\n}\n\n\n/*\n=================\nCom_InitPushEvent\n=================\n*/\n// bk001129 - added\nvoid Com_InitPushEvent( void ) {\n  // clear the static buffer array\n  // this requires SE_NONE to be accepted as a valid but NOP event\n  memset( com_pushedEvents, 0, sizeof(com_pushedEvents) );\n  // reset counters while we are at it\n  // beware: GetEvent might still return an SE_NONE from the buffer\n  com_pushedEventsHead = 0;\n  com_pushedEventsTail = 0;\n}\n\n\n/*\n=================\nCom_PushEvent\n=================\n*/\nvoid Com_PushEvent( sysEvent_t *event ) {\n\tsysEvent_t\t\t*ev;\n\tstatic int printedWarning = 0; // bk001129 - init, bk001204 - explicit int\n\n\tev = &com_pushedEvents[ com_pushedEventsHead & (MAX_PUSHED_EVENTS-1) ];\n\n\tif ( com_pushedEventsHead - com_pushedEventsTail >= MAX_PUSHED_EVENTS ) {\n\n\t\t// don't print the warning constantly, or it can give time for more...\n\t\tif ( !printedWarning ) {\n\t\t\tprintedWarning = qtrue;\n\t\t\tCom_Printf( \"WARNING: Com_PushEvent overflow\\n\" );\n\t\t}\n\n\t\tif ( ev->evPtr ) {\n\t\t\tZ_Free( ev->evPtr );\n\t\t}\n\t\tcom_pushedEventsTail++;\n\t} else {\n\t\tprintedWarning = qfalse;\n\t}\n\n\t*ev = *event;\n\tcom_pushedEventsHead++;\n}\n\n/*\n=================\nCom_GetEvent\n=================\n*/\nsysEvent_t\tCom_GetEvent( void ) {\n\tif ( com_pushedEventsHead > com_pushedEventsTail ) {\n\t\tcom_pushedEventsTail++;\n\t\treturn com_pushedEvents[ (com_pushedEventsTail-1) & (MAX_PUSHED_EVENTS-1) ];\n\t}\n\treturn Com_GetRealEvent();\n}\n\n/*\n=================\nCom_RunAndTimeServerPacket\n=================\n*/\nvoid Com_RunAndTimeServerPacket( netadr_t *evFrom, msg_t *buf ) {\n\tint\t\tt1, t2, msec;\n\n\tt1 = 0;\n\n\tif ( com_speeds->integer ) {\n\t\tt1 = Sys_Milliseconds ();\n\t}\n\n\tSV_PacketEvent( *evFrom, buf );\n\n\tif ( com_speeds->integer ) {\n\t\tt2 = Sys_Milliseconds ();\n\t\tmsec = t2 - t1;\n\t\tif ( com_speeds->integer == 3 ) {\n\t\t\tCom_Printf( \"SV_PacketEvent time: %i\\n\", msec );\n\t\t}\n\t}\n}\n\n/*\n=================\nCom_EventLoop\n\nReturns last event time\n=================\n*/\nint Com_EventLoop( void ) {\n\tsysEvent_t\tev;\n\tnetadr_t\tevFrom;\n\tbyte\t\tbufData[MAX_MSGLEN];\n\tmsg_t\t\tbuf;\n\n\tMSG_Init( &buf, bufData, sizeof( bufData ) );\n\n\twhile ( 1 ) {\n\t\tev = Com_GetEvent();\n\n\t\t// if no more events are available\n\t\tif ( ev.evType == SE_NONE ) {\n\t\t\t// manually send packet events for the loopback channel\n\t\t\twhile ( NET_GetLoopPacket( NS_CLIENT, &evFrom, &buf ) ) {\n\t\t\t\tCL_PacketEvent( evFrom, &buf );\n\t\t\t}\n\n\t\t\twhile ( NET_GetLoopPacket( NS_SERVER, &evFrom, &buf ) ) {\n\t\t\t\t// if the server just shut down, flush the events\n\t\t\t\tif ( com_sv_running->integer ) {\n\t\t\t\t\tCom_RunAndTimeServerPacket( &evFrom, &buf );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn ev.evTime;\n\t\t}\n\n\n\t\tswitch ( ev.evType ) {\n\t\tdefault:\n\t\t  // bk001129 - was ev.evTime\n\t\t\tCom_Error( ERR_FATAL, \"Com_EventLoop: bad event type %i\", ev.evType );\n\t\t\tbreak;\n        case SE_NONE:\n            break;\n\t\tcase SE_KEY:\n\t\t\tCL_KeyEvent( ev.evValue, ev.evValue2, ev.evTime );\n\t\t\tbreak;\n\t\tcase SE_CHAR:\n\t\t\tCL_CharEvent( ev.evValue );\n\t\t\tbreak;\n\t\tcase SE_MOUSE:\n\t\t\tCL_MouseEvent( ev.evValue, ev.evValue2, ev.evTime );\n\t\t\tbreak;\n\t\tcase SE_JOYSTICK_AXIS:\n\t\t\tCL_JoystickEvent( ev.evValue, ev.evValue2, ev.evTime );\n\t\t\tbreak;\n\t\tcase SE_CONSOLE:\n\t\t\tCbuf_AddText( (char *)ev.evPtr );\n\t\t\tCbuf_AddText( \"\\n\" );\n\t\t\tbreak;\n\t\tcase SE_PACKET:\n\t\t\t// this cvar allows simulation of connections that\n\t\t\t// drop a lot of packets.  Note that loopback connections\n\t\t\t// don't go through here at all.\n\t\t\tif ( com_dropsim->value > 0 ) {\n\t\t\t\tstatic int seed;\n\n\t\t\t\tif ( Q_random( &seed ) < com_dropsim->value ) {\n\t\t\t\t\tbreak;\t\t// drop this packet\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tevFrom = *(netadr_t *)ev.evPtr;\n\t\t\tbuf.cursize = ev.evPtrLength - sizeof( evFrom );\n\n\t\t\t// we must copy the contents of the message out, because\n\t\t\t// the event buffers are only large enough to hold the\n\t\t\t// exact payload, but channel messages need to be large\n\t\t\t// enough to hold fragment reassembly\n\t\t\tif ( (unsigned)buf.cursize > buf.maxsize ) {\n\t\t\t\tCom_Printf(\"Com_EventLoop: oversize packet\\n\");\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tCom_Memcpy( buf.data, (byte *)((netadr_t *)ev.evPtr + 1), buf.cursize );\n\t\t\tif ( com_sv_running->integer ) {\n\t\t\t\tCom_RunAndTimeServerPacket( &evFrom, &buf );\n\t\t\t} else {\n\t\t\t\tCL_PacketEvent( evFrom, &buf );\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\t// free any block data\n\t\tif ( ev.evPtr ) {\n\t\t\tZ_Free( ev.evPtr );\n\t\t}\n\t}\n\n\treturn 0;\t// never reached\n}\n\n/*\n================\nCom_Milliseconds\n\nCan be used for profiling, but will be journaled accurately\n================\n*/\nint Com_Milliseconds (void) {\n\tsysEvent_t\tev;\n\n\t// get events and push them until we get a null event with the current time\n\tdo {\n\n\t\tev = Com_GetRealEvent();\n\t\tif ( ev.evType != SE_NONE ) {\n\t\t\tCom_PushEvent( &ev );\n\t\t}\n\t} while ( ev.evType != SE_NONE );\n\t\n\treturn ev.evTime;\n}\n\n//============================================================================\n\n/*\n=============\nCom_Error_f\n\nJust throw a fatal error to\ntest error shutdown procedures\n=============\n*/\nstatic void Com_Error_f (void) {\n\tif ( Cmd_Argc() > 1 ) {\n\t\tCom_Error( ERR_DROP, \"Testing drop error\" );\n\t} else {\n\t\tCom_Error( ERR_FATAL, \"Testing fatal error\" );\n\t}\n}\n\n\n/*\n=============\nCom_Freeze_f\n\nJust freeze in place for a given number of seconds to test\nerror recovery\n=============\n*/\nstatic void Com_Freeze_f (void) {\n\tfloat\ts;\n\tint\t\tstart, now;\n\n\tif ( Cmd_Argc() != 2 ) {\n\t\tCom_Printf( \"freeze <seconds>\\n\" );\n\t\treturn;\n\t}\n\ts = atof( Cmd_Argv(1) );\n\n\tstart = Com_Milliseconds();\n\n\twhile ( 1 ) {\n\t\tnow = Com_Milliseconds();\n\t\tif ( ( now - start ) * 0.001 > s ) {\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/*\n=================\nCom_Crash_f\n\nA way to force a bus error for development reasons\n=================\n*/\nstatic void Com_Crash_f( void ) {\n\t* ( int * ) 0 = 0x12345678;\n}\n\n// TTimo: centralizing the cl_cdkey stuff after I discovered a buffer overflow problem with the dedicated server version\n//   not sure it's necessary to have different defaults for regular and dedicated, but I don't want to risk it\n//   https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=470\n#ifndef DEDICATED\nchar\tcl_cdkey[34] = \"                                \";\n#else\nchar\tcl_cdkey[34] = \"123456789\";\n#endif\n\n/*\n=================\nCom_ReadCDKey\n=================\n*/\nqboolean CL_CDKeyValidate( const char *key, const char *checksum );\nvoid Com_ReadCDKey( const char *filename ) {\n\tfileHandle_t\tf;\n\tchar\t\t\tbuffer[33];\n\tchar\t\t\tfbuffer[MAX_OSPATH];\n\n\tsprintf(fbuffer, \"%s/q3key\", filename);\n\n\tFS_SV_FOpenFileRead( fbuffer, &f );\n\tif ( !f ) {\n\t\tQ_strncpyz( cl_cdkey, \"                \", 17 );\n\t\treturn;\n\t}\n\n\tCom_Memset( buffer, 0, sizeof(buffer) );\n\n\tFS_Read( buffer, 16, f );\n\tFS_FCloseFile( f );\n\n\tif (CL_CDKeyValidate(buffer, NULL)) {\n\t\tQ_strncpyz( cl_cdkey, buffer, 17 );\n\t} else {\n\t\tQ_strncpyz( cl_cdkey, \"                \", 17 );\n\t}\n}\n\n/*\n=================\nCom_AppendCDKey\n=================\n*/\nvoid Com_AppendCDKey( const char *filename ) {\n\tfileHandle_t\tf;\n\tchar\t\t\tbuffer[33];\n\tchar\t\t\tfbuffer[MAX_OSPATH];\n\n\tsprintf(fbuffer, \"%s/q3key\", filename);\n\n\tFS_SV_FOpenFileRead( fbuffer, &f );\n\tif (!f) {\n\t\tQ_strncpyz( &cl_cdkey[16], \"                \", 17 );\n\t\treturn;\n\t}\n\n\tCom_Memset( buffer, 0, sizeof(buffer) );\n\n\tFS_Read( buffer, 16, f );\n\tFS_FCloseFile( f );\n\n\tif (CL_CDKeyValidate(buffer, NULL)) {\n\t\tstrcat( &cl_cdkey[16], buffer );\n\t} else {\n\t\tQ_strncpyz( &cl_cdkey[16], \"                \", 17 );\n\t}\n}\n\n#ifndef DEDICATED // bk001204\n/*\n=================\nCom_WriteCDKey\n=================\n*/\nstatic void Com_WriteCDKey( const char *filename, const char *ikey ) {\n\tfileHandle_t\tf;\n\tchar\t\t\tfbuffer[MAX_OSPATH];\n\tchar\t\t\tkey[17];\n\n\n\tsprintf(fbuffer, \"%s/q3key\", filename);\n\n\n\tQ_strncpyz( key, ikey, 17 );\n\n\tif(!CL_CDKeyValidate(key, NULL) ) {\n\t\treturn;\n\t}\n\n\tf = FS_SV_FOpenFileWrite( fbuffer );\n\tif ( !f ) {\n\t\tCom_Printf (\"Couldn't write %s.\\n\", filename );\n\t\treturn;\n\t}\n\n\tFS_Write( key, 16, f );\n\n\tFS_Printf( f, \"\\n// generated by quake, do not modify\\r\\n\" );\n\tFS_Printf( f, \"// Do not give this file to ANYONE.\\r\\n\" );\n\tFS_Printf( f, \"// id Software and Activision will NOT ask you to send this file to them.\\r\\n\");\n\n\tFS_FCloseFile( f );\n}\n#endif\n\n\n/*\n=================\nCom_Init\n=================\n*/\nvoid Com_Init( char *commandLine ) {\n\tchar\t*s;\n\n\tCom_Printf( \"%s %s %s\\n\", Q3_VERSION, CPUSTRING, __DATE__ );\n\n\tif ( setjmp (abortframe) ) {\n\t\tSys_Error (\"Error during initialization\");\n\t}\n\n  // bk001129 - do this before anything else decides to push events\n  Com_InitPushEvent();\n\n\tCom_InitSmallZoneMemory();\n\tCvar_Init ();\n\n\t// prepare enough of the subsystems to handle\n\t// cvar and command buffer management\n\tCom_ParseCommandLine( commandLine );\n\n//\tSwap_Init ();\n\tCbuf_Init ();\n\n\tCom_InitZoneMemory();\n\tCmd_Init ();\n\n\t// override anything from the config files with command line args\n\tCom_StartupVariable( NULL );\n\n\t// get the developer cvar set as early as possible\n\tCom_StartupVariable( \"developer\" );\n\n\t// done early so bind command exists\n\tCL_InitKeyCommands();\n\n\tFS_InitFilesystem ();\n\n\tCom_InitJournaling();\n\n\tCbuf_AddText (\"exec default.cfg\\n\");\n\n\t// skip the q3config.cfg if \"safe\" is on the command line\n\tif ( !Com_SafeMode() ) {\n\t\tCbuf_AddText (\"exec q3config.cfg\\n\");\n\t}\n\n\tCbuf_AddText (\"exec autoexec.cfg\\n\");\n\n\tCbuf_Execute ();\n\n\t// override anything from the config files with command line args\n\tCom_StartupVariable( NULL );\n\n  // get dedicated here for proper hunk megs initialization\n#ifdef DEDICATED\n\tcom_dedicated = Cvar_Get (\"dedicated\", \"1\", CVAR_ROM);\n#else\n\tcom_dedicated = Cvar_Get (\"dedicated\", \"0\", CVAR_LATCH);\n#endif\n\t// allocate the stack based hunk allocator\n\tCom_InitHunkMemory();\n\n\t// if any archived cvars are modified after this, we will trigger a writing\n\t// of the config file\n\tcvar_modifiedFlags &= ~CVAR_ARCHIVE;\n\n\t//\n\t// init commands and vars\n\t//\n\tcom_maxfps = Cvar_Get (\"com_maxfps\", \"85\", CVAR_ARCHIVE);\n\tcom_blood = Cvar_Get (\"com_blood\", \"1\", CVAR_ARCHIVE);\n\n\tcom_developer = Cvar_Get (\"developer\", \"0\", CVAR_TEMP );\n\tcom_logfile = Cvar_Get (\"logfile\", \"0\", CVAR_TEMP );\n\n\tcom_timescale = Cvar_Get (\"timescale\", \"1\", CVAR_CHEAT | CVAR_SYSTEMINFO );\n\tcom_fixedtime = Cvar_Get (\"fixedtime\", \"0\", CVAR_CHEAT);\n\tcom_showtrace = Cvar_Get (\"com_showtrace\", \"0\", CVAR_CHEAT);\n\tcom_dropsim = Cvar_Get (\"com_dropsim\", \"0\", CVAR_CHEAT);\n\tcom_viewlog = Cvar_Get( \"viewlog\", \"0\", CVAR_CHEAT );\n\tcom_speeds = Cvar_Get (\"com_speeds\", \"0\", 0);\n\tcom_timedemo = Cvar_Get (\"timedemo\", \"0\", CVAR_CHEAT);\n\tcom_cameraMode = Cvar_Get (\"com_cameraMode\", \"0\", CVAR_CHEAT);\n\n\tcl_paused = Cvar_Get (\"cl_paused\", \"0\", CVAR_ROM);\n\tsv_paused = Cvar_Get (\"sv_paused\", \"0\", CVAR_ROM);\n\tcom_sv_running = Cvar_Get (\"sv_running\", \"0\", CVAR_ROM);\n\tcom_cl_running = Cvar_Get (\"cl_running\", \"0\", CVAR_ROM);\n\tcom_buildScript = Cvar_Get( \"com_buildScript\", \"0\", 0 );\n\n\tcom_introPlayed = Cvar_Get( \"com_introplayed\", \"0\", CVAR_ARCHIVE);\n\n#if defined(_WIN32) && defined(_DEBUG)\n\tcom_noErrorInterrupt = Cvar_Get( \"com_noErrorInterrupt\", \"0\", 0 );\n#endif\n\n\tif ( com_dedicated->integer ) {\n\t\tif ( !com_viewlog->integer ) {\n\t\t\tCvar_Set( \"viewlog\", \"1\" );\n\t\t}\n\t}\n\n\tif ( com_developer && com_developer->integer ) {\n\t\tCmd_AddCommand (\"error\", Com_Error_f);\n\t\tCmd_AddCommand (\"crash\", Com_Crash_f );\n\t\tCmd_AddCommand (\"freeze\", Com_Freeze_f);\n\t}\n\tCmd_AddCommand (\"quit\", Com_Quit_f);\n\tCmd_AddCommand (\"changeVectors\", MSG_ReportChangeVectors_f );\n\tCmd_AddCommand (\"writeconfig\", Com_WriteConfig_f );\n\n\ts = va(\"%s %s %s\", Q3_VERSION, CPUSTRING, __DATE__ );\n\tcom_version = Cvar_Get (\"version\", s, CVAR_ROM | CVAR_SERVERINFO );\n\n\tSys_Init();\n\tNetchan_Init( Com_Milliseconds() & 0xffff );\t// pick a port value that should be nice and random\n\tVM_Init();\n\tSV_Init();\n\n\tcom_dedicated->modified = qfalse;\n\tif ( !com_dedicated->integer ) {\n\t\tCL_Init();\n\t\tSys_ShowConsole( com_viewlog->integer, qfalse );\n\t}\n\n\t// set com_frameTime so that if a map is started on the\n\t// command line it will still be able to count on com_frameTime\n\t// being random enough for a serverid\n\tcom_frameTime = Com_Milliseconds();\n\n\t// add + commands from command line\n\tif ( !Com_AddStartupCommands() ) {\n\t\t// if the user didn't give any commands, run default action\n\t\tif ( !com_dedicated->integer ) {\n\t\t\tCbuf_AddText (\"cinematic idlogo.RoQ\\n\");\n\t\t\tif( !com_introPlayed->integer ) {\n\t\t\t\tCvar_Set( com_introPlayed->name, \"1\" );\n\t\t\t\tCvar_Set( \"nextmap\", \"cinematic intro.RoQ\" );\n\t\t\t}\n\t\t}\n\t}\n\n\t// start in full screen ui mode\n\tCvar_Set(\"r_uiFullScreen\", \"1\");\n\n\tCL_StartHunkUsers();\n\n\t// make sure single player is off by default\n\tCvar_Set(\"ui_singlePlayerActive\", \"0\");\n\n\tcom_fullyInitialized = qtrue;\n\tCom_Printf (\"--- Common Initialization Complete ---\\n\");\t\n}\n\n//==================================================================\n\nvoid Com_WriteConfigToFile( const char *filename ) {\n\tfileHandle_t\tf;\n\n\tf = FS_FOpenFileWrite( filename );\n\tif ( !f ) {\n\t\tCom_Printf (\"Couldn't write %s.\\n\", filename );\n\t\treturn;\n\t}\n\n\tFS_Printf (f, \"// generated by quake, do not modify\\n\");\n\tKey_WriteBindings (f);\n\tCvar_WriteVariables (f);\n\tFS_FCloseFile( f );\n}\n\n\n/*\n===============\nCom_WriteConfiguration\n\nWrites key bindings and archived cvars to config file if modified\n===============\n*/\nvoid Com_WriteConfiguration( void ) {\n#ifndef DEDICATED // bk001204\n\tcvar_t\t*fs;\n#endif\n\t// if we are quiting without fully initializing, make sure\n\t// we don't write out anything\n\tif ( !com_fullyInitialized ) {\n\t\treturn;\n\t}\n\n\tif ( !(cvar_modifiedFlags & CVAR_ARCHIVE ) ) {\n\t\treturn;\n\t}\n\tcvar_modifiedFlags &= ~CVAR_ARCHIVE;\n\n\tCom_WriteConfigToFile( \"q3config.cfg\" );\n\n\t// bk001119 - tentative \"not needed for dedicated\"\n#ifndef DEDICATED\n\tfs = Cvar_Get (\"fs_game\", \"\", CVAR_INIT|CVAR_SYSTEMINFO );\n\tif (UI_usesUniqueCDKey() && fs && fs->string[0] != 0) {\n\t\tCom_WriteCDKey( fs->string, &cl_cdkey[16] );\n\t} else {\n\t\tCom_WriteCDKey( \"baseq3\", cl_cdkey );\n\t}\n#endif\n}\n\n\n/*\n===============\nCom_WriteConfig_f\n\nWrite the config file to a specific name\n===============\n*/\nvoid Com_WriteConfig_f( void ) {\n\tchar\tfilename[MAX_QPATH];\n\n\tif ( Cmd_Argc() != 2 ) {\n\t\tCom_Printf( \"Usage: writeconfig <filename>\\n\" );\n\t\treturn;\n\t}\n\n\tQ_strncpyz( filename, Cmd_Argv(1), sizeof( filename ) );\n\tCOM_DefaultExtension( filename, sizeof( filename ), \".cfg\" );\n\tCom_Printf( \"Writing %s.\\n\", filename );\n\tCom_WriteConfigToFile( filename );\n}\n\n/*\n================\nCom_ModifyMsec\n================\n*/\nint Com_ModifyMsec( int msec ) {\n\tint\t\tclampTime;\n\n\t//\n\t// modify time for debugging values\n\t//\n\tif ( com_fixedtime->integer ) {\n\t\tmsec = com_fixedtime->integer;\n\t} else if ( com_timescale->value ) {\n\t\tmsec *= com_timescale->value;\n\t} else if (com_cameraMode->integer) {\n\t\tmsec *= com_timescale->value;\n\t}\n\t\n\t// don't let it scale below 1 msec\n\tif ( msec < 1 && com_timescale->value) {\n\t\tmsec = 1;\n\t}\n\n\tif ( com_dedicated->integer ) {\n\t\t// dedicated servers don't want to clamp for a much longer\n\t\t// period, because it would mess up all the client's views\n\t\t// of time.\n\t\tif ( msec > 500 ) {\n\t\t\tCom_Printf( \"Hitch warning: %i msec frame time\\n\", msec );\n\t\t}\n\t\tclampTime = 5000;\n\t} else \n\tif ( !com_sv_running->integer ) {\n\t\t// clients of remote servers do not want to clamp time, because\n\t\t// it would skew their view of the server's time temporarily\n\t\tclampTime = 5000;\n\t} else {\n\t\t// for local single player gaming\n\t\t// we may want to clamp the time to prevent players from\n\t\t// flying off edges when something hitches.\n\t\tclampTime = 200;\n\t}\n\n\tif ( msec > clampTime ) {\n\t\tmsec = clampTime;\n\t}\n\n\treturn msec;\n}\n\n/*\n=================\nCom_Frame\n=================\n*/\nvoid Com_Frame( void ) {\n\n\tint\t\tmsec, minMsec;\n\tstatic int\tlastTime;\n\tint key;\n \n\tint\t\ttimeBeforeFirstEvents;\n\tint           timeBeforeServer;\n\tint           timeBeforeEvents;\n\tint           timeBeforeClient;\n\tint           timeAfter;\n  \n\n\n\n\n\tif ( setjmp (abortframe) ) {\n\t\treturn;\t\t\t// an ERR_DROP was thrown\n\t}\n\n\t// bk001204 - init to zero.\n\t//  also:  might be clobbered by `longjmp' or `vfork'\n\ttimeBeforeFirstEvents =0;\n\ttimeBeforeServer =0;\n\ttimeBeforeEvents =0;\n\ttimeBeforeClient = 0;\n\ttimeAfter = 0;\n\n\n\t// old net chan encryption key\n\tkey = 0x87243987;\n\n\t// write config file if anything changed\n\tCom_WriteConfiguration(); \n\n\t// if \"viewlog\" has been modified, show or hide the log console\n\tif ( com_viewlog->modified ) {\n\t\tif ( !com_dedicated->value ) {\n\t\t\tSys_ShowConsole( com_viewlog->integer, qfalse );\n\t\t}\n\t\tcom_viewlog->modified = qfalse;\n\t}\n\n\t//\n\t// main event loop\n\t//\n\tif ( com_speeds->integer ) {\n\t\ttimeBeforeFirstEvents = Sys_Milliseconds ();\n\t}\n\n\t// we may want to spin here if things are going too fast\n\tif ( !com_dedicated->integer && com_maxfps->integer > 0 && !com_timedemo->integer ) {\n\t\tminMsec = 1000 / com_maxfps->integer;\n\t} else {\n\t\tminMsec = 1;\n\t}\n\tdo {\n\t\tcom_frameTime = Com_EventLoop();\n\t\tif ( lastTime > com_frameTime ) {\n\t\t\tlastTime = com_frameTime;\t\t// possible on first frame\n\t\t}\n\t\tmsec = com_frameTime - lastTime;\n\t} while ( msec < minMsec );\n\tCbuf_Execute ();\n\n\tlastTime = com_frameTime;\n\n\t// mess with msec if needed\n\tcom_frameMsec = msec;\n\tmsec = Com_ModifyMsec( msec );\n\n\t//\n\t// server side\n\t//\n\tif ( com_speeds->integer ) {\n\t\ttimeBeforeServer = Sys_Milliseconds ();\n\t}\n\n\tSV_Frame( msec );\n\n\t// if \"dedicated\" has been modified, start up\n\t// or shut down the client system.\n\t// Do this after the server may have started,\n\t// but before the client tries to auto-connect\n\tif ( com_dedicated->modified ) {\n\t\t// get the latched value\n\t\tCvar_Get( \"dedicated\", \"0\", 0 );\n\t\tcom_dedicated->modified = qfalse;\n\t\tif ( !com_dedicated->integer ) {\n\t\t\tCL_Init();\n\t\t\tSys_ShowConsole( com_viewlog->integer, qfalse );\n\t\t} else {\n\t\t\tCL_Shutdown();\n\t\t\tSys_ShowConsole( 1, qtrue );\n\t\t}\n\t}\n\n\t//\n\t// client system\n\t//\n\tif ( !com_dedicated->integer ) {\n\t\t//\n\t\t// run event loop a second time to get server to client packets\n\t\t// without a frame of latency\n\t\t//\n\t\tif ( com_speeds->integer ) {\n\t\t\ttimeBeforeEvents = Sys_Milliseconds ();\n\t\t}\n\t\tCom_EventLoop();\n\t\tCbuf_Execute ();\n\n\n\t\t//\n\t\t// client side\n\t\t//\n\t\tif ( com_speeds->integer ) {\n\t\t\ttimeBeforeClient = Sys_Milliseconds ();\n\t\t}\n\n\t\tCL_Frame( msec );\n\n\t\tif ( com_speeds->integer ) {\n\t\t\ttimeAfter = Sys_Milliseconds ();\n\t\t}\n\t}\n\n\t//\n\t// report timing information\n\t//\n\tif ( com_speeds->integer ) {\n\t\tint\t\t\tall, sv, ev, cl;\n\n\t\tall = timeAfter - timeBeforeServer;\n\t\tsv = timeBeforeEvents - timeBeforeServer;\n\t\tev = timeBeforeServer - timeBeforeFirstEvents + timeBeforeClient - timeBeforeEvents;\n\t\tcl = timeAfter - timeBeforeClient;\n\t\tsv -= time_game;\n\t\tcl -= time_frontend + time_backend;\n\n\t\tCom_Printf (\"frame:%i all:%3i sv:%3i ev:%3i cl:%3i gm:%3i rf:%3i bk:%3i\\n\", \n\t\t\t\t\t com_frameNumber, all, sv, ev, cl, time_game, time_frontend, time_backend );\n\t}\t\n\n\t//\n\t// trace optimization tracking\n\t//\n\tif ( com_showtrace->integer ) {\n\t\n\t\textern\tint c_traces, c_brush_traces, c_patch_traces;\n\t\textern\tint\tc_pointcontents;\n\n\t\tCom_Printf (\"%4i traces  (%ib %ip) %4i points\\n\", c_traces,\n\t\t\tc_brush_traces, c_patch_traces, c_pointcontents);\n\t\tc_traces = 0;\n\t\tc_brush_traces = 0;\n\t\tc_patch_traces = 0;\n\t\tc_pointcontents = 0;\n\t}\n\n\t// old net chan encryption key\n\tkey = lastTime * 0x87243987;\n\n\tcom_frameNumber++;\n}\n\n/*\n=================\nCom_Shutdown\n=================\n*/\nvoid Com_Shutdown (void) {\n\tif (logfile) {\n\t\tFS_FCloseFile (logfile);\n\t\tlogfile = 0;\n\t}\n\n\tif ( com_journalFile ) {\n\t\tFS_FCloseFile( com_journalFile );\n\t\tcom_journalFile = 0;\n\t}\n\n}\n\n#if !( defined __VECTORC )\n#if !( defined __linux__ || defined __FreeBSD__ )  // r010123 - include FreeBSD \n#if ((!id386) && (!defined __i386__)) // rcg010212 - for PPC\n\nvoid Com_Memcpy (void* dest, const void* src, const size_t count)\n{\n\tmemcpy(dest, src, count);\n}\n\nvoid Com_Memset (void* dest, const int val, const size_t count)\n{\n\tmemset(dest, val, count);\n}\n\n#else\n\ntypedef enum\n{\n\tPRE_READ,\t\t\t\t\t\t\t\t\t// prefetch assuming that buffer is used for reading only\n\tPRE_WRITE,\t\t\t\t\t\t\t\t\t// prefetch assuming that buffer is used for writing only\n\tPRE_READ_WRITE\t\t\t\t\t\t\t\t// prefetch assuming that buffer is used for both reading and writing\n} e_prefetch;\n\nvoid Com_Prefetch (const void *s, const unsigned int bytes, e_prefetch type);\n\n#define EMMS_INSTRUCTION\t__asm emms\n\nvoid _copyDWord (unsigned int* dest, const unsigned int constant, const unsigned int count) {\n\t__asm\n\t{\n\t\t\tmov\t\tedx,dest\n\t\t\tmov\t\teax,constant\n\t\t\tmov\t\tecx,count\n\t\t\tand\t\tecx,~7\n\t\t\tjz\t\tpadding\n\t\t\tsub\t\tecx,8\n\t\t\tjmp\t\tloopu\n\t\t\talign\t16\nloopu:\t\t\n\t\t\ttest\t[edx+ecx*4 + 28],ebx\t\t// fetch next block destination to L1 cache\n\t\t\tmov\t\t[edx+ecx*4 + 0],eax\n\t\t\tmov\t\t[edx+ecx*4 + 4],eax\n\t\t\tmov\t\t[edx+ecx*4 + 8],eax\n\t\t\tmov\t\t[edx+ecx*4 + 12],eax\n\t\t\tmov\t\t[edx+ecx*4 + 16],eax\n\t\t\tmov\t\t[edx+ecx*4 + 20],eax\n\t\t\tmov\t\t[edx+ecx*4 + 24],eax\n\t\t\tmov\t\t[edx+ecx*4 + 28],eax\n\t\t\tsub\t\tecx,8\n\t\t\tjge\t\tloopu\npadding:\tmov\t\tecx,count\n\t\t\tmov\t\tebx,ecx\n\t\t\tand\t\tecx,7\n\t\t\tjz\t\toutta\n\t\t\tand\t\tebx,~7\n\t\t\tlea\t\tedx,[edx+ebx*4]\t\t\t\t// advance dest pointer\n\t\t\ttest\t[edx+0],eax\t\t\t\t\t// fetch destination to L1 cache\n\t\t\tcmp\t\tecx,4\n\t\t\tjl\t\tskip4\n\t\t\tmov\t\t[edx+0],eax\n\t\t\tmov\t\t[edx+4],eax\n\t\t\tmov\t\t[edx+8],eax\n\t\t\tmov\t\t[edx+12],eax\n\t\t\tadd\t\tedx,16\n\t\t\tsub\t\tecx,4\nskip4:\t\tcmp\t\tecx,2\n\t\t\tjl\t\tskip2\n\t\t\tmov\t\t[edx+0],eax\n\t\t\tmov\t\t[edx+4],eax\n\t\t\tadd\t\tedx,8\n\t\t\tsub\t\tecx,2\nskip2:\t\tcmp\t\tecx,1\n\t\t\tjl\t\toutta\n\t\t\tmov\t\t[edx+0],eax\noutta:\n\t}\n}\n\n// optimized memory copy routine that handles all alignment\n// cases and block sizes efficiently\nvoid Com_Memcpy (void* dest, const void* src, const size_t count) {\n\tCom_Prefetch (src, count, PRE_READ);\n\t__asm\n\t{\n\t\tpush\tedi\n\t\tpush\tesi\n\t\tmov\t\tecx,count\n\t\tcmp\t\tecx,0\t\t\t\t\t\t// count = 0 check (just to be on the safe side)\n\t\tje\t\toutta\n\t\tmov\t\tedx,dest\n\t\tmov\t\tebx,src\n\t\tcmp\t\tecx,32\t\t\t\t\t\t// padding only?\n\t\tjl\t\tpadding\n\n\t\tmov\t\tedi,ecx\t\t\t\t\t\n\t\tand\t\tedi,~31\t\t\t\t\t// edi = count&~31\n\t\tsub\t\tedi,32\n\n\t\talign 16\nloopMisAligned:\n\t\tmov\t\teax,[ebx + edi + 0 + 0*8]\n\t\tmov\t\tesi,[ebx + edi + 4 + 0*8]\n\t\tmov\t\t[edx+edi+0 + 0*8],eax\n\t\tmov\t\t[edx+edi+4 + 0*8],esi\n\t\tmov\t\teax,[ebx + edi + 0 + 1*8]\n\t\tmov\t\tesi,[ebx + edi + 4 + 1*8]\n\t\tmov\t\t[edx+edi+0 + 1*8],eax\n\t\tmov\t\t[edx+edi+4 + 1*8],esi\n\t\tmov\t\teax,[ebx + edi + 0 + 2*8]\n\t\tmov\t\tesi,[ebx + edi + 4 + 2*8]\n\t\tmov\t\t[edx+edi+0 + 2*8],eax\n\t\tmov\t\t[edx+edi+4 + 2*8],esi\n\t\tmov\t\teax,[ebx + edi + 0 + 3*8]\n\t\tmov\t\tesi,[ebx + edi + 4 + 3*8]\n\t\tmov\t\t[edx+edi+0 + 3*8],eax\n\t\tmov\t\t[edx+edi+4 + 3*8],esi\n\t\tsub\t\tedi,32\n\t\tjge\t\tloopMisAligned\n\t\t\n\t\tmov\t\tedi,ecx\n\t\tand\t\tedi,~31\n\t\tadd\t\tebx,edi\t\t\t\t\t// increase src pointer\n\t\tadd\t\tedx,edi\t\t\t\t\t// increase dst pointer\n\t\tand\t\tecx,31\t\t\t\t\t// new count\n\t\tjz\t\toutta\t\t\t\t\t// if count = 0, get outta here\n\npadding:\n\t\tcmp\t\tecx,16\n\t\tjl\t\tskip16\n\t\tmov\t\teax,dword ptr [ebx]\n\t\tmov\t\tdword ptr [edx],eax\n\t\tmov\t\teax,dword ptr [ebx+4]\n\t\tmov\t\tdword ptr [edx+4],eax\n\t\tmov\t\teax,dword ptr [ebx+8]\n\t\tmov\t\tdword ptr [edx+8],eax\n\t\tmov\t\teax,dword ptr [ebx+12]\n\t\tmov\t\tdword ptr [edx+12],eax\n\t\tsub\t\tecx,16\n\t\tadd\t\tebx,16\n\t\tadd\t\tedx,16\nskip16:\n\t\tcmp\t\tecx,8\n\t\tjl\t\tskip8\n\t\tmov\t\teax,dword ptr [ebx]\n\t\tmov\t\tdword ptr [edx],eax\n\t\tmov\t\teax,dword ptr [ebx+4]\n\t\tsub\t\tecx,8\n\t\tmov\t\tdword ptr [edx+4],eax\n\t\tadd\t\tebx,8\n\t\tadd\t\tedx,8\nskip8:\n\t\tcmp\t\tecx,4\n\t\tjl\t\tskip4\n\t\tmov\t\teax,dword ptr [ebx]\t// here 4-7 bytes\n\t\tadd\t\tebx,4\n\t\tsub\t\tecx,4\n\t\tmov\t\tdword ptr [edx],eax\n\t\tadd\t\tedx,4\nskip4:\t\t\t\t\t\t\t// 0-3 remaining bytes\n\t\tcmp\t\tecx,2\n\t\tjl\t\tskip2\n\t\tmov\t\tax,word ptr [ebx]\t// two bytes\n\t\tcmp\t\tecx,3\t\t\t\t// less than 3?\n\t\tmov\t\tword ptr [edx],ax\n\t\tjl\t\toutta\n\t\tmov\t\tal,byte ptr [ebx+2]\t// last byte\n\t\tmov\t\tbyte ptr [edx+2],al\n\t\tjmp\t\toutta\nskip2:\n\t\tcmp\t\tecx,1\n\t\tjl\t\toutta\n\t\tmov\t\tal,byte ptr [ebx]\n\t\tmov\t\tbyte ptr [edx],al\noutta:\n\t\tpop\t\tesi\n\t\tpop\t\tedi\n\t}\n}\n\nvoid Com_Memset (void* dest, const int val, const size_t count)\n{\n\tunsigned int fillval;\n\n\tif (count < 8)\n\t{\n\t\t__asm\n\t\t{\n\t\t\tmov\t\tedx,dest\n\t\t\tmov\t\teax, val\n\t\t\tmov\t\tah,al\n\t\t\tmov\t\tebx,eax\n\t\t\tand\t\tebx, 0xffff\n\t\t\tshl\t\teax,16\n\t\t\tadd\t\teax,ebx\t\t\t\t// eax now contains pattern\n\t\t\tmov\t\tecx,count\n\t\t\tcmp\t\tecx,4\n\t\t\tjl\t\tskip4\n\t\t\tmov\t\t[edx],eax\t\t\t// copy first dword\n\t\t\tadd\t\tedx,4\n\t\t\tsub\t\tecx,4\n\tskip4:\tcmp\t\tecx,2\n\t\t\tjl\t\tskip2\n\t\t\tmov\t\tword ptr [edx],ax\t// copy 2 bytes\n\t\t\tadd\t\tedx,2\n\t\t\tsub\t\tecx,2\n\tskip2:\tcmp\t\tecx,0\n\t\t\tje\t\tskip1\n\t\t\tmov\t\tbyte ptr [edx],al\t// copy single byte\n\tskip1:\n\t\t}\n\t\treturn;\n\t}\n\n\tfillval = val;\n\t\n\tfillval = fillval|(fillval<<8);\n\tfillval = fillval|(fillval<<16);\t\t// fill dword with 8-bit pattern\n\n\t_copyDWord ((unsigned int*)(dest),fillval, count/4);\n\t\n\t__asm\t\t\t\t\t\t\t\t\t// padding of 0-3 bytes\n\t{\n\t\tmov\t\tecx,count\n\t\tmov\t\teax,ecx\n\t\tand\t\tecx,3\n\t\tjz\t\tskipA\n\t\tand\t\teax,~3\n\t\tmov\t\tebx,dest\n\t\tadd\t\tebx,eax\n\t\tmov\t\teax,fillval\n\t\tcmp\t\tecx,2\n\t\tjl\t\tskipB\n\t\tmov\t\tword ptr [ebx],ax\n\t\tcmp\t\tecx,2\n\t\tje\t\tskipA\t\t\t\t\t\n\t\tmov\t\tbyte ptr [ebx+2],al\t\t\n\t\tjmp\t\tskipA\nskipB:\t\t\n\t\tcmp\t\tecx,0\n\t\tje\t\tskipA\n\t\tmov\t\tbyte ptr [ebx],al\nskipA:\n\t}\n}\n\nqboolean Com_Memcmp (const void *src0, const void *src1, const unsigned int count)\n{\n\tunsigned int i;\n\t// MMX version anyone?\n\n\tif (count >= 16)\n\t{\n\t\tunsigned int *dw = (unsigned int*)(src0);\n\t\tunsigned int *sw = (unsigned int*)(src1);\n\n\t\tunsigned int nm2 = count/16;\n\t\tfor (i = 0; i < nm2; i+=4)\n\t\t{\n\t\t\tunsigned int tmp = (dw[i+0]-sw[i+0])|(dw[i+1]-sw[i+1])|\n\t\t\t\t\t\t  (dw[i+2]-sw[i+2])|(dw[i+3]-sw[i+3]);\n\t\t\tif (tmp)\n\t\t\t\treturn qfalse;\n\t\t}\n\t}\n\tif (count & 15)\n\t{\n\t\tbyte *d = (byte*)src0;\n\t\tbyte *s = (byte*)src1;\n\t\tfor (i = count & 0xfffffff0; i < count; i++)\n\t\tif (d[i]!=s[i])\n\t\t\treturn qfalse;\n\t}\n\n\treturn qtrue;\n}\n\nvoid Com_Prefetch (const void *s, const unsigned int bytes, e_prefetch type)\n{\n\t// write buffer prefetching is performed only if\n\t// the processor benefits from it. Read and read/write\n\t// prefetching is always performed.\n\n\tswitch (type)\n\t{\n\t\tcase PRE_WRITE : break;\n\t\tcase PRE_READ:\n\t\tcase PRE_READ_WRITE:\n\n\t\t__asm\n\t\t{\n\t\t\tmov\t\tebx,s\n\t\t\tmov\t\tecx,bytes\n\t\t\tcmp\t\tecx,4096\t\t\t\t// clamp to 4kB\n\t\t\tjle\t\tskipClamp\n\t\t\tmov\t\tecx,4096\nskipClamp:\n\t\t\tadd\t\tecx,0x1f\n\t\t\tshr\t\tecx,5\t\t\t\t\t// number of cache lines\n\t\t\tjz\t\tskip\n\t\t\tjmp\t\tloopie\n\n\t\t\talign 16\n\tloopie:\ttest\tbyte ptr [ebx],al\n\t\t\tadd\t\tebx,32\n\t\t\tdec\t\tecx\n\t\t\tjnz\t\tloopie\n\tskip:\n\t\t}\n\n\t\tbreak;\n\t}\n}\n#endif\n#endif \n#endif // bk001208 - memset/memcpy assembly, Q_acos needed (RC4)\n//------------------------------------------------------------------------\n\n\n/*\n=====================\nQ_acos\n\nthe msvc acos doesn't always return a value between -PI and PI:\n\nint i;\ni = 1065353246;\nacos(*(float*) &i) == -1.#IND0\n\n\tThis should go in q_math but it is too late to add new traps\n\tto game and ui\n=====================\n*/\nfloat Q_acos(float c) {\n\tfloat angle;\n\n\tangle = acos(c);\n\n\tif (angle > M_PI) {\n\t\treturn (float)M_PI;\n\t}\n\tif (angle < -M_PI) {\n\t\treturn (float)M_PI;\n\t}\n\treturn angle;\n}\n\n/*\n===========================================\ncommand line completion\n===========================================\n*/\n\n/*\n==================\nField_Clear\n==================\n*/\nvoid Field_Clear( field_t *edit ) {\n  memset(edit->buffer, 0, MAX_EDIT_LINE);\n\tedit->cursor = 0;\n\tedit->scroll = 0;\n}\n\nstatic const char *completionString;\nstatic char shortestMatch[MAX_TOKEN_CHARS];\nstatic int\tmatchCount;\n// field we are working on, passed to Field_CompleteCommand (&g_consoleCommand for instance)\nstatic field_t *completionField;\n\n/*\n===============\nFindMatches\n\n===============\n*/\nstatic void FindMatches( const char *s ) {\n\tint\t\ti;\n\n\tif ( Q_stricmpn( s, completionString, strlen( completionString ) ) ) {\n\t\treturn;\n\t}\n\tmatchCount++;\n\tif ( matchCount == 1 ) {\n\t\tQ_strncpyz( shortestMatch, s, sizeof( shortestMatch ) );\n\t\treturn;\n\t}\n\n\t// cut shortestMatch to the amount common with s\n\tfor ( i = 0 ; s[i] ; i++ ) {\n\t\tif ( tolower(shortestMatch[i]) != tolower(s[i]) ) {\n\t\t\tshortestMatch[i] = 0;\n\t\t}\n\t}\n}\n\n/*\n===============\nPrintMatches\n\n===============\n*/\nstatic void PrintMatches( const char *s ) {\n\tif ( !Q_stricmpn( s, shortestMatch, strlen( shortestMatch ) ) ) {\n\t\tCom_Printf( \"    %s\\n\", s );\n\t}\n}\n\nstatic void keyConcatArgs( void ) {\n\tint\t\ti;\n\tchar\t*arg;\n\n\tfor ( i = 1 ; i < Cmd_Argc() ; i++ ) {\n\t\tQ_strcat( completionField->buffer, sizeof( completionField->buffer ), \" \" );\n\t\targ = Cmd_Argv( i );\n\t\twhile (*arg) {\n\t\t\tif (*arg == ' ') {\n\t\t\t\tQ_strcat( completionField->buffer, sizeof( completionField->buffer ),  \"\\\"\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\targ++;\n\t\t}\n\t\tQ_strcat( completionField->buffer, sizeof( completionField->buffer ),  Cmd_Argv( i ) );\n\t\tif (*arg == ' ') {\n\t\t\tQ_strcat( completionField->buffer, sizeof( completionField->buffer ),  \"\\\"\");\n\t\t}\n\t}\n}\n\nstatic void ConcatRemaining( const char *src, const char *start ) {\n\tchar *str;\n\n\tstr = strstr(src, start);\n\tif (!str) {\n\t\tkeyConcatArgs();\n\t\treturn;\n\t}\n\n\tstr += strlen(start);\n\tQ_strcat( completionField->buffer, sizeof( completionField->buffer ), str);\n}\n\n/*\n===============\nField_CompleteCommand\n\nperform Tab expansion\nNOTE TTimo this was originally client code only\n  moved to common code when writing tty console for *nix dedicated server\n===============\n*/\nvoid Field_CompleteCommand( field_t *field ) {\n\tfield_t\t\ttemp;\n\n\tcompletionField = field;\n\n\t// only look at the first token for completion purposes\n\tCmd_TokenizeString( completionField->buffer );\n\n\tcompletionString = Cmd_Argv(0);\n\tif ( completionString[0] == '\\\\' || completionString[0] == '/' ) {\n\t\tcompletionString++;\n\t}\n\tmatchCount = 0;\n\tshortestMatch[0] = 0;\n\n\tif ( strlen( completionString ) == 0 ) {\n\t\treturn;\n\t}\n\n\tCmd_CommandCompletion( FindMatches );\n\tCvar_CommandCompletion( FindMatches );\n\n\tif ( matchCount == 0 ) {\n\t\treturn;\t// no matches\n\t}\n\n\tCom_Memcpy(&temp, completionField, sizeof(field_t));\n\n\tif ( matchCount == 1 ) {\n\t\tCom_sprintf( completionField->buffer, sizeof( completionField->buffer ), \"\\\\%s\", shortestMatch );\n\t\tif ( Cmd_Argc() == 1 ) {\n\t\t\tQ_strcat( completionField->buffer, sizeof( completionField->buffer ), \" \" );\n\t\t} else {\n\t\t\tConcatRemaining( temp.buffer, completionString );\n\t\t}\n\t\tcompletionField->cursor = strlen( completionField->buffer );\n\t\treturn;\n\t}\n\n\t// multiple matches, complete to shortest\n\tCom_sprintf( completionField->buffer, sizeof( completionField->buffer ), \"\\\\%s\", shortestMatch );\n\tcompletionField->cursor = strlen( completionField->buffer );\n\tConcatRemaining( temp.buffer, completionString );\n\n\tCom_Printf( \"]%s\\n\", completionField->buffer );\n\n\t// run through again, printing matches\n\tCmd_CommandCompletion( PrintMatches );\n\tCvar_CommandCompletion( PrintMatches );\n}\n"
  },
  {
    "path": "code/qcommon/cvar.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// cvar.c -- dynamic variable tracking\n\n#include \"../game/q_shared.h\"\n#include \"qcommon.h\"\n\ncvar_t\t\t*cvar_vars;\ncvar_t\t\t*cvar_cheats;\nint\t\t\tcvar_modifiedFlags;\n\n#define\tMAX_CVARS\t1024\ncvar_t\t\tcvar_indexes[MAX_CVARS];\nint\t\t\tcvar_numIndexes;\n\n#define FILE_HASH_SIZE\t\t256\nstatic\tcvar_t*\t\thashTable[FILE_HASH_SIZE];\n\ncvar_t *Cvar_Set2( const char *var_name, const char *value, qboolean force);\n\n/*\n================\nreturn a hash value for the filename\n================\n*/\nstatic long generateHashValue( const char *fname ) {\n\tint\t\ti;\n\tlong\thash;\n\tchar\tletter;\n\n\thash = 0;\n\ti = 0;\n\twhile (fname[i] != '\\0') {\n\t\tletter = tolower(fname[i]);\n\t\thash+=(long)(letter)*(i+119);\n\t\ti++;\n\t}\n\thash &= (FILE_HASH_SIZE-1);\n\treturn hash;\n}\n\n/*\n============\nCvar_ValidateString\n============\n*/\nstatic qboolean Cvar_ValidateString( const char *s ) {\n\tif ( !s ) {\n\t\treturn qfalse;\n\t}\n\tif ( strchr( s, '\\\\' ) ) {\n\t\treturn qfalse;\n\t}\n\tif ( strchr( s, '\\\"' ) ) {\n\t\treturn qfalse;\n\t}\n\tif ( strchr( s, ';' ) ) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n/*\n============\nCvar_FindVar\n============\n*/\nstatic cvar_t *Cvar_FindVar( const char *var_name ) {\n\tcvar_t\t*var;\n\tlong hash;\n\n\thash = generateHashValue(var_name);\n\t\n\tfor (var=hashTable[hash] ; var ; var=var->hashNext) {\n\t\tif (!Q_stricmp(var_name, var->name)) {\n\t\t\treturn var;\n\t\t}\n\t}\n\n\treturn NULL;\n}\n\n/*\n============\nCvar_VariableValue\n============\n*/\nfloat Cvar_VariableValue( const char *var_name ) {\n\tcvar_t\t*var;\n\t\n\tvar = Cvar_FindVar (var_name);\n\tif (!var)\n\t\treturn 0;\n\treturn var->value;\n}\n\n\n/*\n============\nCvar_VariableIntegerValue\n============\n*/\nint Cvar_VariableIntegerValue( const char *var_name ) {\n\tcvar_t\t*var;\n\t\n\tvar = Cvar_FindVar (var_name);\n\tif (!var)\n\t\treturn 0;\n\treturn var->integer;\n}\n\n\n/*\n============\nCvar_VariableString\n============\n*/\nchar *Cvar_VariableString( const char *var_name ) {\n\tcvar_t *var;\n\t\n\tvar = Cvar_FindVar (var_name);\n\tif (!var)\n\t\treturn \"\";\n\treturn var->string;\n}\n\n\n/*\n============\nCvar_VariableStringBuffer\n============\n*/\nvoid Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize ) {\n\tcvar_t *var;\n\t\n\tvar = Cvar_FindVar (var_name);\n\tif (!var) {\n\t\t*buffer = 0;\n\t}\n\telse {\n\t\tQ_strncpyz( buffer, var->string, bufsize );\n\t}\n}\n\n\n/*\n============\nCvar_CommandCompletion\n============\n*/\nvoid\tCvar_CommandCompletion( void(*callback)(const char *s) ) {\n\tcvar_t\t\t*cvar;\n\t\n\tfor ( cvar = cvar_vars ; cvar ; cvar = cvar->next ) {\n\t\tcallback( cvar->name );\n\t}\n}\n\n\n/*\n============\nCvar_Get\n\nIf the variable already exists, the value will not be set unless CVAR_ROM\nThe flags will be or'ed in if the variable exists.\n============\n*/\ncvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) {\n\tcvar_t\t*var;\n\tlong\thash;\n\n  if ( !var_name || ! var_value ) {\n\t\tCom_Error( ERR_FATAL, \"Cvar_Get: NULL parameter\" );\n  }\n\n\tif ( !Cvar_ValidateString( var_name ) ) {\n\t\tCom_Printf(\"invalid cvar name string: %s\\n\", var_name );\n\t\tvar_name = \"BADNAME\";\n\t}\n\n#if 0\t\t// FIXME: values with backslash happen\n\tif ( !Cvar_ValidateString( var_value ) ) {\n\t\tCom_Printf(\"invalid cvar value string: %s\\n\", var_value );\n\t\tvar_value = \"BADVALUE\";\n\t}\n#endif\n\n\tvar = Cvar_FindVar (var_name);\n\tif ( var ) {\n\t\t// if the C code is now specifying a variable that the user already\n\t\t// set a value for, take the new value as the reset value\n\t\tif ( ( var->flags & CVAR_USER_CREATED ) && !( flags & CVAR_USER_CREATED )\n\t\t\t&& var_value[0] ) {\n\t\t\tvar->flags &= ~CVAR_USER_CREATED;\n\t\t\tZ_Free( var->resetString );\n\t\t\tvar->resetString = CopyString( var_value );\n\n\t\t\t// ZOID--needs to be set so that cvars the game sets as \n\t\t\t// SERVERINFO get sent to clients\n\t\t\tcvar_modifiedFlags |= flags;\n\t\t}\n\n\t\tvar->flags |= flags;\n\t\t// only allow one non-empty reset string without a warning\n\t\tif ( !var->resetString[0] ) {\n\t\t\t// we don't have a reset string yet\n\t\t\tZ_Free( var->resetString );\n\t\t\tvar->resetString = CopyString( var_value );\n\t\t} else if ( var_value[0] && strcmp( var->resetString, var_value ) ) {\n\t\t\tCom_DPrintf( \"Warning: cvar \\\"%s\\\" given initial values: \\\"%s\\\" and \\\"%s\\\"\\n\",\n\t\t\t\tvar_name, var->resetString, var_value );\n\t\t}\n\t\t// if we have a latched string, take that value now\n\t\tif ( var->latchedString ) {\n\t\t\tchar *s;\n\n\t\t\ts = var->latchedString;\n\t\t\tvar->latchedString = NULL;\t// otherwise cvar_set2 would free it\n\t\t\tCvar_Set2( var_name, s, qtrue );\n\t\t\tZ_Free( s );\n\t\t}\n\n// use a CVAR_SET for rom sets, get won't override\n#if 0\n\t\t// CVAR_ROM always overrides\n\t\tif ( flags & CVAR_ROM ) {\n\t\t\tCvar_Set2( var_name, var_value, qtrue );\n\t\t}\n#endif\n\t\treturn var;\n\t}\n\n\t//\n\t// allocate a new cvar\n\t//\n\tif ( cvar_numIndexes >= MAX_CVARS ) {\n\t\tCom_Error( ERR_FATAL, \"MAX_CVARS\" );\n\t}\n\tvar = &cvar_indexes[cvar_numIndexes];\n\tcvar_numIndexes++;\n\tvar->name = CopyString (var_name);\n\tvar->string = CopyString (var_value);\n\tvar->modified = qtrue;\n\tvar->modificationCount = 1;\n\tvar->value = atof (var->string);\n\tvar->integer = atoi(var->string);\n\tvar->resetString = CopyString( var_value );\n\n\t// link the variable in\n\tvar->next = cvar_vars;\n\tcvar_vars = var;\n\n\tvar->flags = flags;\n\n\thash = generateHashValue(var_name);\n\tvar->hashNext = hashTable[hash];\n\thashTable[hash] = var;\n\n\treturn var;\n}\n\n/*\n============\nCvar_Set2\n============\n*/\ncvar_t *Cvar_Set2( const char *var_name, const char *value, qboolean force ) {\n\tcvar_t\t*var;\n\n\tCom_DPrintf( \"Cvar_Set2: %s %s\\n\", var_name, value );\n\n\tif ( !Cvar_ValidateString( var_name ) ) {\n\t\tCom_Printf(\"invalid cvar name string: %s\\n\", var_name );\n\t\tvar_name = \"BADNAME\";\n\t}\n\n#if 0\t// FIXME\n\tif ( value && !Cvar_ValidateString( value ) ) {\n\t\tCom_Printf(\"invalid cvar value string: %s\\n\", value );\n\t\tvar_value = \"BADVALUE\";\n\t}\n#endif\n\n\tvar = Cvar_FindVar (var_name);\n\tif (!var) {\n\t\tif ( !value ) {\n\t\t\treturn NULL;\n\t\t}\n\t\t// create it\n\t\tif ( !force ) {\n\t\t\treturn Cvar_Get( var_name, value, CVAR_USER_CREATED );\n\t\t} else {\n\t\t\treturn Cvar_Get (var_name, value, 0);\n\t\t}\n\t}\n\n\tif (!value ) {\n\t\tvalue = var->resetString;\n\t}\n\n\tif (!strcmp(value,var->string)) {\n\t\treturn var;\n\t}\n\t// note what types of cvars have been modified (userinfo, archive, serverinfo, systeminfo)\n\tcvar_modifiedFlags |= var->flags;\n\n\tif (!force)\n\t{\n\t\tif (var->flags & CVAR_ROM)\n\t\t{\n\t\t\tCom_Printf (\"%s is read only.\\n\", var_name);\n\t\t\treturn var;\n\t\t}\n\n\t\tif (var->flags & CVAR_INIT)\n\t\t{\n\t\t\tCom_Printf (\"%s is write protected.\\n\", var_name);\n\t\t\treturn var;\n\t\t}\n\n\t\tif (var->flags & CVAR_LATCH)\n\t\t{\n\t\t\tif (var->latchedString)\n\t\t\t{\n\t\t\t\tif (strcmp(value, var->latchedString) == 0)\n\t\t\t\t\treturn var;\n\t\t\t\tZ_Free (var->latchedString);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (strcmp(value, var->string) == 0)\n\t\t\t\t\treturn var;\n\t\t\t}\n\n\t\t\tCom_Printf (\"%s will be changed upon restarting.\\n\", var_name);\n\t\t\tvar->latchedString = CopyString(value);\n\t\t\tvar->modified = qtrue;\n\t\t\tvar->modificationCount++;\n\t\t\treturn var;\n\t\t}\n\n\t\tif ( (var->flags & CVAR_CHEAT) && !cvar_cheats->integer )\n\t\t{\n\t\t\tCom_Printf (\"%s is cheat protected.\\n\", var_name);\n\t\t\treturn var;\n\t\t}\n\n\t}\n\telse\n\t{\n\t\tif (var->latchedString)\n\t\t{\n\t\t\tZ_Free (var->latchedString);\n\t\t\tvar->latchedString = NULL;\n\t\t}\n\t}\n\n\tif (!strcmp(value, var->string))\n\t\treturn var;\t\t// not changed\n\n\tvar->modified = qtrue;\n\tvar->modificationCount++;\n\t\n\tZ_Free (var->string);\t// free the old value string\n\t\n\tvar->string = CopyString(value);\n\tvar->value = atof (var->string);\n\tvar->integer = atoi (var->string);\n\n\treturn var;\n}\n\n/*\n============\nCvar_Set\n============\n*/\nvoid Cvar_Set( const char *var_name, const char *value) {\n\tCvar_Set2 (var_name, value, qtrue);\n}\n\n/*\n============\nCvar_SetLatched\n============\n*/\nvoid Cvar_SetLatched( const char *var_name, const char *value) {\n\tCvar_Set2 (var_name, value, qfalse);\n}\n\n/*\n============\nCvar_SetValue\n============\n*/\nvoid Cvar_SetValue( const char *var_name, float value) {\n\tchar\tval[32];\n\n\tif ( value == (int)value ) {\n\t\tCom_sprintf (val, sizeof(val), \"%i\",(int)value);\n\t} else {\n\t\tCom_sprintf (val, sizeof(val), \"%f\",value);\n\t}\n\tCvar_Set (var_name, val);\n}\n\n\n/*\n============\nCvar_Reset\n============\n*/\nvoid Cvar_Reset( const char *var_name ) {\n\tCvar_Set2( var_name, NULL, qfalse );\n}\n\n\n/*\n============\nCvar_SetCheatState\n\nAny testing variables will be reset to the safe values\n============\n*/\nvoid Cvar_SetCheatState( void ) {\n\tcvar_t\t*var;\n\n\t// set all default vars to the safe value\n\tfor ( var = cvar_vars ; var ; var = var->next ) {\n\t\tif ( var->flags & CVAR_CHEAT ) {\n      // the CVAR_LATCHED|CVAR_CHEAT vars might escape the reset here \n      // because of a different var->latchedString\n      if (var->latchedString)\n      {\n        Z_Free(var->latchedString);\n        var->latchedString = NULL;\n      }\n\t\t\tif (strcmp(var->resetString,var->string)) {\n        Cvar_Set( var->name, var->resetString );\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n============\nCvar_Command\n\nHandles variable inspection and changing from the console\n============\n*/\nqboolean Cvar_Command( void ) {\n\tcvar_t\t\t\t*v;\n\n\t// check variables\n\tv = Cvar_FindVar (Cmd_Argv(0));\n\tif (!v) {\n\t\treturn qfalse;\n\t}\n\n\t// perform a variable print or set\n\tif ( Cmd_Argc() == 1 ) {\n\t\tCom_Printf (\"\\\"%s\\\" is:\\\"%s\" S_COLOR_WHITE \"\\\" default:\\\"%s\" S_COLOR_WHITE \"\\\"\\n\", v->name, v->string, v->resetString );\n\t\tif ( v->latchedString ) {\n\t\t\tCom_Printf( \"latched: \\\"%s\\\"\\n\", v->latchedString );\n\t\t}\n\t\treturn qtrue;\n\t}\n\n\t// set the value if forcing isn't required\n\tCvar_Set2 (v->name, Cmd_Argv(1), qfalse);\n\treturn qtrue;\n}\n\n\n/*\n============\nCvar_Toggle_f\n\nToggles a cvar for easy single key binding\n============\n*/\nvoid Cvar_Toggle_f( void ) {\n\tint\t\tv;\n\n\tif ( Cmd_Argc() != 2 ) {\n\t\tCom_Printf (\"usage: toggle <variable>\\n\");\n\t\treturn;\n\t}\n\n\tv = Cvar_VariableValue( Cmd_Argv( 1 ) );\n\tv = !v;\n\n\tCvar_Set2 (Cmd_Argv(1), va(\"%i\", v), qfalse);\n}\n\n/*\n============\nCvar_Set_f\n\nAllows setting and defining of arbitrary cvars from console, even if they\nweren't declared in C code.\n============\n*/\nvoid Cvar_Set_f( void ) {\n\tint\t\ti, c, l, len;\n\tchar\tcombined[MAX_STRING_TOKENS];\n\n\tc = Cmd_Argc();\n\tif ( c < 3 ) {\n\t\tCom_Printf (\"usage: set <variable> <value>\\n\");\n\t\treturn;\n\t}\n\n\tcombined[0] = 0;\n\tl = 0;\n\tfor ( i = 2 ; i < c ; i++ ) {\n\t\tlen = strlen ( Cmd_Argv( i ) + 1 );\n\t\tif ( l + len >= MAX_STRING_TOKENS - 2 ) {\n\t\t\tbreak;\n\t\t}\n\t\tstrcat( combined, Cmd_Argv( i ) );\n\t\tif ( i != c-1 ) {\n\t\t\tstrcat( combined, \" \" );\n\t\t}\n\t\tl += len;\n\t}\n\tCvar_Set2 (Cmd_Argv(1), combined, qfalse);\n}\n\n/*\n============\nCvar_SetU_f\n\nAs Cvar_Set, but also flags it as userinfo\n============\n*/\nvoid Cvar_SetU_f( void ) {\n\tcvar_t\t*v;\n\n\tif ( Cmd_Argc() != 3 ) {\n\t\tCom_Printf (\"usage: setu <variable> <value>\\n\");\n\t\treturn;\n\t}\n\tCvar_Set_f();\n\tv = Cvar_FindVar( Cmd_Argv( 1 ) );\n\tif ( !v ) {\n\t\treturn;\n\t}\n\tv->flags |= CVAR_USERINFO;\n}\n\n/*\n============\nCvar_SetS_f\n\nAs Cvar_Set, but also flags it as userinfo\n============\n*/\nvoid Cvar_SetS_f( void ) {\n\tcvar_t\t*v;\n\n\tif ( Cmd_Argc() != 3 ) {\n\t\tCom_Printf (\"usage: sets <variable> <value>\\n\");\n\t\treturn;\n\t}\n\tCvar_Set_f();\n\tv = Cvar_FindVar( Cmd_Argv( 1 ) );\n\tif ( !v ) {\n\t\treturn;\n\t}\n\tv->flags |= CVAR_SERVERINFO;\n}\n\n/*\n============\nCvar_SetA_f\n\nAs Cvar_Set, but also flags it as archived\n============\n*/\nvoid Cvar_SetA_f( void ) {\n\tcvar_t\t*v;\n\n\tif ( Cmd_Argc() != 3 ) {\n\t\tCom_Printf (\"usage: seta <variable> <value>\\n\");\n\t\treturn;\n\t}\n\tCvar_Set_f();\n\tv = Cvar_FindVar( Cmd_Argv( 1 ) );\n\tif ( !v ) {\n\t\treturn;\n\t}\n\tv->flags |= CVAR_ARCHIVE;\n}\n\n/*\n============\nCvar_Reset_f\n============\n*/\nvoid Cvar_Reset_f( void ) {\n\tif ( Cmd_Argc() != 2 ) {\n\t\tCom_Printf (\"usage: reset <variable>\\n\");\n\t\treturn;\n\t}\n\tCvar_Reset( Cmd_Argv( 1 ) );\n}\n\n/*\n============\nCvar_WriteVariables\n\nAppends lines containing \"set variable value\" for all variables\nwith the archive flag set to qtrue.\n============\n*/\nvoid Cvar_WriteVariables( fileHandle_t f ) {\n\tcvar_t\t*var;\n\tchar\tbuffer[1024];\n\n\tfor (var = cvar_vars ; var ; var = var->next) {\n\t\tif( Q_stricmp( var->name, \"cl_cdkey\" ) == 0 ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif( var->flags & CVAR_ARCHIVE ) {\n\t\t\t// write the latched value, even if it hasn't taken effect yet\n\t\t\tif ( var->latchedString ) {\n\t\t\t\tCom_sprintf (buffer, sizeof(buffer), \"seta %s \\\"%s\\\"\\n\", var->name, var->latchedString);\n\t\t\t} else {\n\t\t\t\tCom_sprintf (buffer, sizeof(buffer), \"seta %s \\\"%s\\\"\\n\", var->name, var->string);\n\t\t\t}\n\t\t\tFS_Printf (f, \"%s\", buffer);\n\t\t}\n\t}\n}\n\n/*\n============\nCvar_List_f\n============\n*/\nvoid Cvar_List_f( void ) {\n\tcvar_t\t*var;\n\tint\t\ti;\n\tchar\t*match;\n\n\tif ( Cmd_Argc() > 1 ) {\n\t\tmatch = Cmd_Argv( 1 );\n\t} else {\n\t\tmatch = NULL;\n\t}\n\n\ti = 0;\n\tfor (var = cvar_vars ; var ; var = var->next, i++)\n\t{\n\t\tif (match && !Com_Filter(match, var->name, qfalse)) continue;\n\n\t\tif (var->flags & CVAR_SERVERINFO) {\n\t\t\tCom_Printf(\"S\");\n\t\t} else {\n\t\t\tCom_Printf(\" \");\n\t\t}\n\t\tif (var->flags & CVAR_USERINFO) {\n\t\t\tCom_Printf(\"U\");\n\t\t} else {\n\t\t\tCom_Printf(\" \");\n\t\t}\n\t\tif (var->flags & CVAR_ROM) {\n\t\t\tCom_Printf(\"R\");\n\t\t} else {\n\t\t\tCom_Printf(\" \");\n\t\t}\n\t\tif (var->flags & CVAR_INIT) {\n\t\t\tCom_Printf(\"I\");\n\t\t} else {\n\t\t\tCom_Printf(\" \");\n\t\t}\n\t\tif (var->flags & CVAR_ARCHIVE) {\n\t\t\tCom_Printf(\"A\");\n\t\t} else {\n\t\t\tCom_Printf(\" \");\n\t\t}\n\t\tif (var->flags & CVAR_LATCH) {\n\t\t\tCom_Printf(\"L\");\n\t\t} else {\n\t\t\tCom_Printf(\" \");\n\t\t}\n\t\tif (var->flags & CVAR_CHEAT) {\n\t\t\tCom_Printf(\"C\");\n\t\t} else {\n\t\t\tCom_Printf(\" \");\n\t\t}\n\n\t\tCom_Printf (\" %s \\\"%s\\\"\\n\", var->name, var->string);\n\t}\n\n\tCom_Printf (\"\\n%i total cvars\\n\", i);\n\tCom_Printf (\"%i cvar indexes\\n\", cvar_numIndexes);\n}\n\n/*\n============\nCvar_Restart_f\n\nResets all cvars to their hardcoded values\n============\n*/\nvoid Cvar_Restart_f( void ) {\n\tcvar_t\t*var;\n\tcvar_t\t**prev;\n\n\tprev = &cvar_vars;\n\twhile ( 1 ) {\n\t\tvar = *prev;\n\t\tif ( !var ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// don't mess with rom values, or some inter-module\n\t\t// communication will get broken (com_cl_running, etc)\n\t\tif ( var->flags & ( CVAR_ROM | CVAR_INIT | CVAR_NORESTART ) ) {\n\t\t\tprev = &var->next;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// throw out any variables the user created\n\t\tif ( var->flags & CVAR_USER_CREATED ) {\n\t\t\t*prev = var->next;\n\t\t\tif ( var->name ) {\n\t\t\t\tZ_Free( var->name );\n\t\t\t}\n\t\t\tif ( var->string ) {\n\t\t\t\tZ_Free( var->string );\n\t\t\t}\n\t\t\tif ( var->latchedString ) {\n\t\t\t\tZ_Free( var->latchedString );\n\t\t\t}\n\t\t\tif ( var->resetString ) {\n\t\t\t\tZ_Free( var->resetString );\n\t\t\t}\n\t\t\t// clear the var completely, since we\n\t\t\t// can't remove the index from the list\n\t\t\tCom_Memset( var, 0, sizeof( var ) );\n\t\t\tcontinue;\n\t\t}\n\n\t\tCvar_Set( var->name, var->resetString );\n\n\t\tprev = &var->next;\n\t}\n}\n\n\n\n/*\n=====================\nCvar_InfoString\n=====================\n*/\nchar\t*Cvar_InfoString( int bit ) {\n\tstatic char\tinfo[MAX_INFO_STRING];\n\tcvar_t\t*var;\n\n\tinfo[0] = 0;\n\n\tfor (var = cvar_vars ; var ; var = var->next) {\n\t\tif (var->flags & bit) {\n\t\t\tInfo_SetValueForKey (info, var->name, var->string);\n\t\t}\n\t}\n\treturn info;\n}\n\n/*\n=====================\nCvar_InfoString_Big\n\n  handles large info strings ( CS_SYSTEMINFO )\n=====================\n*/\nchar\t*Cvar_InfoString_Big( int bit ) {\n\tstatic char\tinfo[BIG_INFO_STRING];\n\tcvar_t\t*var;\n\n\tinfo[0] = 0;\n\n\tfor (var = cvar_vars ; var ; var = var->next) {\n\t\tif (var->flags & bit) {\n\t\t\tInfo_SetValueForKey_Big (info, var->name, var->string);\n\t\t}\n\t}\n\treturn info;\n}\n\n\n\n/*\n=====================\nCvar_InfoStringBuffer\n=====================\n*/\nvoid Cvar_InfoStringBuffer( int bit, char* buff, int buffsize ) {\n\tQ_strncpyz(buff,Cvar_InfoString(bit),buffsize);\n}\n\n/*\n=====================\nCvar_Register\n\nbasically a slightly modified Cvar_Get for the interpreted modules\n=====================\n*/\nvoid\tCvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags ) {\n\tcvar_t\t*cv;\n\n\tcv = Cvar_Get( varName, defaultValue, flags );\n\tif ( !vmCvar ) {\n\t\treturn;\n\t}\n\tvmCvar->handle = cv - cvar_indexes;\n\tvmCvar->modificationCount = -1;\n\tCvar_Update( vmCvar );\n}\n\n\n/*\n=====================\nCvar_Register\n\nupdates an interpreted modules' version of a cvar\n=====================\n*/\nvoid\tCvar_Update( vmCvar_t *vmCvar ) {\n\tcvar_t\t*cv = NULL; // bk001129\n\tassert(vmCvar); // bk\n\n\tif ( (unsigned)vmCvar->handle >= cvar_numIndexes ) {\n\t\tCom_Error( ERR_DROP, \"Cvar_Update: handle out of range\" );\n\t}\n\n\tcv = cvar_indexes + vmCvar->handle;\n\n\tif ( cv->modificationCount == vmCvar->modificationCount ) {\n\t\treturn;\n\t}\n\tif ( !cv->string ) {\n\t\treturn;\t\t// variable might have been cleared by a cvar_restart\n\t}\n\tvmCvar->modificationCount = cv->modificationCount;\n\t// bk001129 - mismatches.\n\tif ( strlen(cv->string)+1 > MAX_CVAR_VALUE_STRING ) \n\t  Com_Error( ERR_DROP, \"Cvar_Update: src %s length %d exceeds MAX_CVAR_VALUE_STRING\",\n\t\t     cv->string, \n\t\t     strlen(cv->string), \n\t\t     sizeof(vmCvar->string) );\n\t// bk001212 - Q_strncpyz guarantees zero padding and dest[MAX_CVAR_VALUE_STRING-1]==0 \n\t// bk001129 - paranoia. Never trust the destination string.\n\t// bk001129 - beware, sizeof(char*) is always 4 (for cv->string). \n\t//            sizeof(vmCvar->string) always MAX_CVAR_VALUE_STRING\n\t//Q_strncpyz( vmCvar->string, cv->string, sizeof( vmCvar->string ) ); // id\n\tQ_strncpyz( vmCvar->string, cv->string,  MAX_CVAR_VALUE_STRING ); \n\n\tvmCvar->value = cv->value;\n\tvmCvar->integer = cv->integer;\n}\n\n\n/*\n============\nCvar_Init\n\nReads in all archived cvars\n============\n*/\nvoid Cvar_Init (void) {\n\tcvar_cheats = Cvar_Get(\"sv_cheats\", \"1\", CVAR_ROM | CVAR_SYSTEMINFO );\n\n\tCmd_AddCommand (\"toggle\", Cvar_Toggle_f);\n\tCmd_AddCommand (\"set\", Cvar_Set_f);\n\tCmd_AddCommand (\"sets\", Cvar_SetS_f);\n\tCmd_AddCommand (\"setu\", Cvar_SetU_f);\n\tCmd_AddCommand (\"seta\", Cvar_SetA_f);\n\tCmd_AddCommand (\"reset\", Cvar_Reset_f);\n\tCmd_AddCommand (\"cvarlist\", Cvar_List_f);\n\tCmd_AddCommand (\"cvar_restart\", Cvar_Restart_f);\n}\n"
  },
  {
    "path": "code/qcommon/files.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n/*****************************************************************************\n * name:\t\tfiles.c\n *\n * desc:\t\thandle based filesystem for Quake III Arena \n *\n * $Archive: /MissionPack/code/qcommon/files.c $\n *\n *****************************************************************************/\n\n\n#include \"../game/q_shared.h\"\n#include \"qcommon.h\"\n#include \"unzip.h\"\n\n/*\n=============================================================================\n\nQUAKE3 FILESYSTEM\n\nAll of Quake's data access is through a hierarchical file system, but the contents of \nthe file system can be transparently merged from several sources.\n\nA \"qpath\" is a reference to game file data.  MAX_ZPATH is 256 characters, which must include\na terminating zero. \"..\", \"\\\\\", and \":\" are explicitly illegal in qpaths to prevent any\nreferences outside the quake directory system.\n\nThe \"base path\" is the path to the directory holding all the game directories and usually\nthe executable.  It defaults to \".\", but can be overridden with a \"+set fs_basepath c:\\quake3\"\ncommand line to allow code debugging in a different directory.  Basepath cannot\nbe modified at all after startup.  Any files that are created (demos, screenshots,\netc) will be created reletive to the base path, so base path should usually be writable.\n\nThe \"cd path\" is the path to an alternate hierarchy that will be searched if a file\nis not located in the base path.  A user can do a partial install that copies some\ndata to a base path created on their hard drive and leave the rest on the cd.  Files\nare never writen to the cd path.  It defaults to a value set by the installer, like\n\"e:\\quake3\", but it can be overridden with \"+set ds_cdpath g:\\quake3\".\n\nIf a user runs the game directly from a CD, the base path would be on the CD.  This\nshould still function correctly, but all file writes will fail (harmlessly).\n\nThe \"home path\" is the path used for all write access. On win32 systems we have \"base path\"\n== \"home path\", but on *nix systems the base installation is usually readonly, and\n\"home path\" points to ~/.q3a or similar\n\nThe user can also install custom mods and content in \"home path\", so it should be searched\nalong with \"home path\" and \"cd path\" for game content.\n\n\nThe \"base game\" is the directory under the paths where data comes from by default, and\ncan be either \"baseq3\" or \"demoq3\".\n\nThe \"current game\" may be the same as the base game, or it may be the name of another\ndirectory under the paths that should be searched for files before looking in the base game.\nThis is the basis for addons.\n\nClients automatically set the game directory after receiving a gamestate from a server,\nso only servers need to worry about +set fs_game.\n\nNo other directories outside of the base game and current game will ever be referenced by\nfilesystem functions.\n\nTo save disk space and speed loading, directory trees can be collapsed into zip files.\nThe files use a \".pk3\" extension to prevent users from unzipping them accidentally, but\notherwise the are simply normal uncompressed zip files.  A game directory can have multiple\nzip files of the form \"pak0.pk3\", \"pak1.pk3\", etc.  Zip files are searched in decending order\nfrom the highest number to the lowest, and will always take precedence over the filesystem.\nThis allows a pk3 distributed as a patch to override all existing data.\n\nBecause we will have updated executables freely available online, there is no point to\ntrying to restrict demo / oem versions of the game with code changes.  Demo / oem versions\nshould be exactly the same executables as release versions, but with different data that\nautomatically restricts where game media can come from to prevent add-ons from working.\n\nAfter the paths are initialized, quake will look for the product.txt file.  If not\nfound and verified, the game will run in restricted mode.  In restricted mode, only \nfiles contained in demoq3/pak0.pk3 will be available for loading, and only if the zip header is\nverified to not have been modified.  A single exception is made for q3config.cfg.  Files\ncan still be written out in restricted mode, so screenshots and demos are allowed.\nRestricted mode can be tested by setting \"+set fs_restrict 1\" on the command line, even\nif there is a valid product.txt under the basepath or cdpath.\n\nIf not running in restricted mode, and a file is not found in any local filesystem,\nan attempt will be made to download it and save it under the base path.\n\nIf the \"fs_copyfiles\" cvar is set to 1, then every time a file is sourced from the cd\npath, it will be copied over to the base path.  This is a development aid to help build\ntest releases and to copy working sets over slow network links.\n\nFile search order: when FS_FOpenFileRead gets called it will go through the fs_searchpaths\nstructure and stop on the first successful hit. fs_searchpaths is built with successive\ncalls to FS_AddGameDirectory\n\nAdditionaly, we search in several subdirectories:\ncurrent game is the current mode\nbase game is a variable to allow mods based on other mods\n(such as baseq3 + missionpack content combination in a mod for instance)\nBASEGAME is the hardcoded base game (\"baseq3\")\n\ne.g. the qpath \"sound/newstuff/test.wav\" would be searched for in the following places:\n\nhome path + current game's zip files\nhome path + current game's directory\nbase path + current game's zip files\nbase path + current game's directory\ncd path + current game's zip files\ncd path + current game's directory\n\nhome path + base game's zip file\nhome path + base game's directory\nbase path + base game's zip file\nbase path + base game's directory\ncd path + base game's zip file\ncd path + base game's directory\n\nhome path + BASEGAME's zip file\nhome path + BASEGAME's directory\nbase path + BASEGAME's zip file\nbase path + BASEGAME's directory\ncd path + BASEGAME's zip file\ncd path + BASEGAME's directory\n\nserver download, to be written to home path + current game's directory\n\n\nThe filesystem can be safely shutdown and reinitialized with different\nbasedir / cddir / game combinations, but all other subsystems that rely on it\n(sound, video) must also be forced to restart.\n\nBecause the same files are loaded by both the clip model (CM_) and renderer (TR_)\nsubsystems, a simple single-file caching scheme is used.  The CM_ subsystems will\nload the file with a request to cache.  Only one file will be kept cached at a time,\nso any models that are going to be referenced by both subsystems should alternate\nbetween the CM_ load function and the ref load function.\n\nTODO: A qpath that starts with a leading slash will always refer to the base game, even if another\ngame is currently active.  This allows character models, skins, and sounds to be downloaded\nto a common directory no matter which game is active.\n\nHow to prevent downloading zip files?\nPass pk3 file names in systeminfo, and download before FS_Restart()?\n\nAborting a download disconnects the client from the server.\n\nHow to mark files as downloadable?  Commercial add-ons won't be downloadable.\n\nNon-commercial downloads will want to download the entire zip file.\nthe game would have to be reset to actually read the zip in\n\nAuto-update information\n\nPath separators\n\nCasing\n\n  separate server gamedir and client gamedir, so if the user starts\n  a local game after having connected to a network game, it won't stick\n  with the network game.\n\n  allow menu options for game selection?\n\nRead / write config to floppy option.\n\nDifferent version coexistance?\n\nWhen building a pak file, make sure a q3config.cfg isn't present in it,\nor configs will never get loaded from disk!\n\n  todo:\n\n  downloading (outside fs?)\n  game directory passing and restarting\n\n=============================================================================\n\n*/\n\n#define\tDEMOGAME\t\t\t\"demota\"\n\n// every time a new demo pk3 file is built, this checksum must be updated.\n// the easiest way to get it is to just run the game and see what it spits out\n#define\tDEMO_PAK_CHECKSUM\t437558517u\n\n// if this is defined, the executable positively won't work with any paks other\n// than the demo pak, even if productid is present.  This is only used for our\n// last demo release to prevent the mac and linux users from using the demo\n// executable with the production windows pak before the mac/linux products\n// hit the shelves a little later\n// NOW defined in build files\n//#define PRE_RELEASE_TADEMO\n\n#define MAX_ZPATH\t\t\t256\n#define\tMAX_SEARCH_PATHS\t4096\n#define MAX_FILEHASH_SIZE\t1024\n\ntypedef struct fileInPack_s {\n\tchar\t\t\t\t\t*name;\t\t// name of the file\n\tunsigned long\t\t\tpos;\t\t// file info position in zip\n\tstruct\tfileInPack_s*\tnext;\t\t// next file in the hash\n} fileInPack_t;\n\ntypedef struct {\n\tchar\t\t\tpakFilename[MAX_OSPATH];\t// c:\\quake3\\baseq3\\pak0.pk3\n\tchar\t\t\tpakBasename[MAX_OSPATH];\t// pak0\n\tchar\t\t\tpakGamename[MAX_OSPATH];\t// baseq3\n\tunzFile\t\t\thandle;\t\t\t\t\t\t// handle to zip file\n\tint\t\t\t\tchecksum;\t\t\t\t\t// regular checksum\n\tint\t\t\t\tpure_checksum;\t\t\t\t// checksum for pure\n\tint\t\t\t\tnumfiles;\t\t\t\t\t// number of files in pk3\n\tint\t\t\t\treferenced;\t\t\t\t\t// referenced file flags\n\tint\t\t\t\thashSize;\t\t\t\t\t// hash table size (power of 2)\n\tfileInPack_t*\t*hashTable;\t\t\t\t\t// hash table\n\tfileInPack_t*\tbuildBuffer;\t\t\t\t// buffer with the filenames etc.\n} pack_t;\n\ntypedef struct {\n\tchar\t\tpath[MAX_OSPATH];\t\t// c:\\quake3\n\tchar\t\tgamedir[MAX_OSPATH];\t// baseq3\n} directory_t;\n\ntypedef struct searchpath_s {\n\tstruct searchpath_s *next;\n\n\tpack_t\t\t*pack;\t\t// only one of pack / dir will be non NULL\n\tdirectory_t\t*dir;\n} searchpath_t;\n\nstatic\tchar\t\tfs_gamedir[MAX_OSPATH];\t// this will be a single file name with no separators\nstatic\tcvar_t\t\t*fs_debug;\nstatic\tcvar_t\t\t*fs_homepath;\nstatic\tcvar_t\t\t*fs_basepath;\nstatic\tcvar_t\t\t*fs_basegame;\nstatic\tcvar_t\t\t*fs_cdpath;\nstatic\tcvar_t\t\t*fs_copyfiles;\nstatic\tcvar_t\t\t*fs_gamedirvar;\nstatic\tcvar_t\t\t*fs_restrict;\nstatic\tsearchpath_t\t*fs_searchpaths;\nstatic\tint\t\t\tfs_readCount;\t\t\t// total bytes read\nstatic\tint\t\t\tfs_loadCount;\t\t\t// total files read\nstatic\tint\t\t\tfs_loadStack;\t\t\t// total files in memory\nstatic\tint\t\t\tfs_packFiles;\t\t\t// total number of files in packs\n\nstatic int fs_fakeChkSum;\nstatic int fs_checksumFeed;\n\ntypedef union qfile_gus {\n\tFILE*\t\to;\n\tunzFile\t\tz;\n} qfile_gut;\n\ntypedef struct qfile_us {\n\tqfile_gut\tfile;\n\tqboolean\tunique;\n} qfile_ut;\n\ntypedef struct {\n\tqfile_ut\thandleFiles;\n\tqboolean\thandleSync;\n\tint\t\t\tbaseOffset;\n\tint\t\t\tfileSize;\n\tint\t\t\tzipFilePos;\n\tqboolean\tzipFile;\n\tqboolean\tstreamed;\n\tchar\t\tname[MAX_ZPATH];\n} fileHandleData_t;\n\nstatic fileHandleData_t\tfsh[MAX_FILE_HANDLES];\n\n// TTimo - https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=540\n// wether we did a reorder on the current search path when joining the server\nstatic qboolean fs_reordered;\n\n// never load anything from pk3 files that are not present at the server when pure\nstatic int\t\tfs_numServerPaks;\nstatic int\t\tfs_serverPaks[MAX_SEARCH_PATHS];\t\t\t\t// checksums\nstatic char\t\t*fs_serverPakNames[MAX_SEARCH_PATHS];\t\t\t// pk3 names\n\n// only used for autodownload, to make sure the client has at least\n// all the pk3 files that are referenced at the server side\nstatic int\t\tfs_numServerReferencedPaks;\nstatic int\t\tfs_serverReferencedPaks[MAX_SEARCH_PATHS];\t\t\t// checksums\nstatic char\t\t*fs_serverReferencedPakNames[MAX_SEARCH_PATHS];\t\t// pk3 names\n\n// last valid game folder used\nchar lastValidBase[MAX_OSPATH];\nchar lastValidGame[MAX_OSPATH];\n\n// productId: This file is copyright 1999 Id Software, and may not be duplicated except during a licensed installation of the full commercial version of Quake 3:Arena\nstatic byte fs_scrambledProductId[152] = {\n220, 129, 255, 108, 244, 163, 171, 55, 133, 65, 199, 36, 140, 222, 53, 99, 65, 171, 175, 232, 236, 193, 210, 250, 169, 104, 231, 231, 21, 201, 170, 208, 135, 175, 130, 136, 85, 215, 71, 23, 96, 32, 96, 83, 44, 240, 219, 138, 184, 215, 73, 27, 196, 247, 55, 139, 148, 68, 78, 203, 213, 238, 139, 23, 45, 205, 118, 186, 236, 230, 231, 107, 212, 1, 10, 98, 30, 20, 116, 180, 216, 248, 166, 35, 45, 22, 215, 229, 35, 116, 250, 167, 117, 3, 57, 55, 201, 229, 218, 222, 128, 12, 141, 149, 32, 110, 168, 215, 184, 53, 31, 147, 62, 12, 138, 67, 132, 54, 125, 6, 221, 148, 140, 4, 21, 44, 198, 3, 126, 12, 100, 236, 61, 42, 44, 251, 15, 135, 14, 134, 89, 92, 177, 246, 152, 106, 124, 78, 118, 80, 28, 42\n};\n\n#ifdef FS_MISSING\nFILE*\t\tmissingFiles = NULL;\n#endif\n\n/*\n==============\nFS_Initialized\n==============\n*/\n\nqboolean FS_Initialized() {\n\treturn (fs_searchpaths != NULL);\n}\n\n/*\n=================\nFS_PakIsPure\n=================\n*/\nqboolean FS_PakIsPure( pack_t *pack ) {\n\tint i;\n\n\tif ( fs_numServerPaks ) {\n\t\tfor ( i = 0 ; i < fs_numServerPaks ; i++ ) {\n\t\t\t// FIXME: also use hashed file names\n\t\t\t// NOTE TTimo: a pk3 with same checksum but different name would be validated too\n\t\t\t//   I don't see this as allowing for any exploit, it would only happen if the client does manips of it's file names 'not a bug'\n\t\t\tif ( pack->checksum == fs_serverPaks[i] ) {\n\t\t\t\treturn qtrue;\t\t// on the aproved list\n\t\t\t}\n\t\t}\n\t\treturn qfalse;\t// not on the pure server pak list\n\t}\n\treturn qtrue;\n}\n\n\n/*\n=================\nFS_LoadStack\nreturn load stack\n=================\n*/\nint FS_LoadStack()\n{\n\treturn fs_loadStack;\n}\n                      \n/*\n================\nreturn a hash value for the filename\n================\n*/\nstatic long FS_HashFileName( const char *fname, int hashSize ) {\n\tint\t\ti;\n\tlong\thash;\n\tchar\tletter;\n\n\thash = 0;\n\ti = 0;\n\twhile (fname[i] != '\\0') {\n\t\tletter = tolower(fname[i]);\n\t\tif (letter =='.') break;\t\t\t\t// don't include extension\n\t\tif (letter =='\\\\') letter = '/';\t\t// damn path names\n\t\tif (letter == PATH_SEP) letter = '/';\t\t// damn path names\n\t\thash+=(long)(letter)*(i+119);\n\t\ti++;\n\t}\n\thash = (hash ^ (hash >> 10) ^ (hash >> 20));\n\thash &= (hashSize-1);\n\treturn hash;\n}\n\nstatic fileHandle_t\tFS_HandleForFile(void) {\n\tint\t\ti;\n\n\tfor ( i = 1 ; i < MAX_FILE_HANDLES ; i++ ) {\n\t\tif ( fsh[i].handleFiles.file.o == NULL ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\tCom_Error( ERR_DROP, \"FS_HandleForFile: none free\" );\n\treturn 0;\n}\n\nstatic FILE\t*FS_FileForHandle( fileHandle_t f ) {\n\tif ( f < 0 || f > MAX_FILE_HANDLES ) {\n\t\tCom_Error( ERR_DROP, \"FS_FileForHandle: out of reange\" );\n\t}\n\tif (fsh[f].zipFile == qtrue) {\n\t\tCom_Error( ERR_DROP, \"FS_FileForHandle: can't get FILE on zip file\" );\n\t}\n\tif ( ! fsh[f].handleFiles.file.o ) {\n\t\tCom_Error( ERR_DROP, \"FS_FileForHandle: NULL\" );\n\t}\n\t\n\treturn fsh[f].handleFiles.file.o;\n}\n\nvoid\tFS_ForceFlush( fileHandle_t f ) {\n\tFILE *file;\n\n\tfile = FS_FileForHandle(f);\n\tsetvbuf( file, NULL, _IONBF, 0 );\n}\n\n/*\n================\nFS_filelength\n\nIf this is called on a non-unique FILE (from a pak file),\nit will return the size of the pak file, not the expected\nsize of the file.\n================\n*/\nint FS_filelength( fileHandle_t f ) {\n\tint\t\tpos;\n\tint\t\tend;\n\tFILE*\th;\n\n\th = FS_FileForHandle(f);\n\tpos = ftell (h);\n\tfseek (h, 0, SEEK_END);\n\tend = ftell (h);\n\tfseek (h, pos, SEEK_SET);\n\n\treturn end;\n}\n\n/*\n====================\nFS_ReplaceSeparators\n\nFix things up differently for win/unix/mac\n====================\n*/\nstatic void FS_ReplaceSeparators( char *path ) {\n\tchar\t*s;\n\n\tfor ( s = path ; *s ; s++ ) {\n\t\tif ( *s == '/' || *s == '\\\\' ) {\n\t\t\t*s = PATH_SEP;\n\t\t}\n\t}\n}\n\n/*\n===================\nFS_BuildOSPath\n\nQpath may have either forward or backwards slashes\n===================\n*/\nchar *FS_BuildOSPath( const char *base, const char *game, const char *qpath ) {\n\tchar\ttemp[MAX_OSPATH];\n\tstatic char ospath[2][MAX_OSPATH];\n\tstatic int toggle;\n\t\n\ttoggle ^= 1;\t\t// flip-flop to allow two returns without clash\n\n\tif( !game || !game[0] ) {\n\t\tgame = fs_gamedir;\n\t}\n\n\tCom_sprintf( temp, sizeof(temp), \"/%s/%s\", game, qpath );\n\tFS_ReplaceSeparators( temp );\t\n\tCom_sprintf( ospath[toggle], sizeof( ospath[0] ), \"%s%s\", base, temp );\n\t\n\treturn ospath[toggle];\n}\n\n\n/*\n============\nFS_CreatePath\n\nCreates any directories needed to store the given filename\n============\n*/\nstatic qboolean FS_CreatePath (char *OSPath) {\n\tchar\t*ofs;\n\t\n\t// make absolutely sure that it can't back up the path\n\t// FIXME: is c: allowed???\n\tif ( strstr( OSPath, \"..\" ) || strstr( OSPath, \"::\" ) ) {\n\t\tCom_Printf( \"WARNING: refusing to create relative path \\\"%s\\\"\\n\", OSPath );\n\t\treturn qtrue;\n\t}\n\n\tfor (ofs = OSPath+1 ; *ofs ; ofs++) {\n\t\tif (*ofs == PATH_SEP) {\t\n\t\t\t// create the directory\n\t\t\t*ofs = 0;\n\t\t\tSys_Mkdir (OSPath);\n\t\t\t*ofs = PATH_SEP;\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n/*\n=================\nFS_CopyFile\n\nCopy a fully specified file from one place to another\n=================\n*/\nstatic void FS_CopyFile( char *fromOSPath, char *toOSPath ) {\n\tFILE\t*f;\n\tint\t\tlen;\n\tbyte\t*buf;\n\n\tCom_Printf( \"copy %s to %s\\n\", fromOSPath, toOSPath );\n\n\tif (strstr(fromOSPath, \"journal.dat\") || strstr(fromOSPath, \"journaldata.dat\")) {\n\t\tCom_Printf( \"Ignoring journal files\\n\");\n\t\treturn;\n\t}\n\n\tf = fopen( fromOSPath, \"rb\" );\n\tif ( !f ) {\n\t\treturn;\n\t}\n\tfseek (f, 0, SEEK_END);\n\tlen = ftell (f);\n\tfseek (f, 0, SEEK_SET);\n\n\t// we are using direct malloc instead of Z_Malloc here, so it\n\t// probably won't work on a mac... Its only for developers anyway...\n\tbuf = malloc( len );\n\tif (fread( buf, 1, len, f ) != len)\n\t\tCom_Error( ERR_FATAL, \"Short read in FS_Copyfiles()\\n\" );\n\tfclose( f );\n\n\tif( FS_CreatePath( toOSPath ) ) {\n\t\treturn;\n\t}\n\n\tf = fopen( toOSPath, \"wb\" );\n\tif ( !f ) {\n\t\treturn;\n\t}\n\tif (fwrite( buf, 1, len, f ) != len)\n\t\tCom_Error( ERR_FATAL, \"Short write in FS_Copyfiles()\\n\" );\n\tfclose( f );\n\tfree( buf );\n}\n\n/*\n===========\nFS_Remove\n\n===========\n*/\nstatic void FS_Remove( const char *osPath ) {\n\tremove( osPath );\n}\n\n/*\n================\nFS_FileExists\n\nTests if the file exists in the current gamedir, this DOES NOT\nsearch the paths.  This is to determine if opening a file to write\n(which always goes into the current gamedir) will cause any overwrites.\nNOTE TTimo: this goes with FS_FOpenFileWrite for opening the file afterwards\n================\n*/\nqboolean FS_FileExists( const char *file )\n{\n\tFILE *f;\n\tchar *testpath;\n\n\ttestpath = FS_BuildOSPath( fs_homepath->string, fs_gamedir, file );\n\n\tf = fopen( testpath, \"rb\" );\n\tif (f) {\n\t\tfclose( f );\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n================\nFS_SV_FileExists\n\nTests if the file exists \n================\n*/\nqboolean FS_SV_FileExists( const char *file )\n{\n\tFILE *f;\n\tchar *testpath;\n\n\ttestpath = FS_BuildOSPath( fs_homepath->string, file, \"\");\n\ttestpath[strlen(testpath)-1] = '\\0';\n\n\tf = fopen( testpath, \"rb\" );\n\tif (f) {\n\t\tfclose( f );\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n\n/*\n===========\nFS_SV_FOpenFileWrite\n\n===========\n*/\nfileHandle_t FS_SV_FOpenFileWrite( const char *filename ) {\n\tchar *ospath;\n\tfileHandle_t\tf;\n\n\tif ( !fs_searchpaths ) {\n\t\tCom_Error( ERR_FATAL, \"Filesystem call made without initialization\\n\" );\n\t}\n\n\tospath = FS_BuildOSPath( fs_homepath->string, filename, \"\" );\n\tospath[strlen(ospath)-1] = '\\0';\n\n\tf = FS_HandleForFile();\n\tfsh[f].zipFile = qfalse;\n\n\tif ( fs_debug->integer ) {\n\t\tCom_Printf( \"FS_SV_FOpenFileWrite: %s\\n\", ospath );\n\t}\n\n\tif( FS_CreatePath( ospath ) ) {\n\t\treturn 0;\n\t}\n\n\tCom_DPrintf( \"writing to: %s\\n\", ospath );\n\tfsh[f].handleFiles.file.o = fopen( ospath, \"wb\" );\n\n\tQ_strncpyz( fsh[f].name, filename, sizeof( fsh[f].name ) );\n\n\tfsh[f].handleSync = qfalse;\n\tif (!fsh[f].handleFiles.file.o) {\n\t\tf = 0;\n\t}\n\treturn f;\n}\n\n/*\n===========\nFS_SV_FOpenFileRead\nsearch for a file somewhere below the home path, base path or cd path\nwe search in that order, matching FS_SV_FOpenFileRead order\n===========\n*/\nint FS_SV_FOpenFileRead( const char *filename, fileHandle_t *fp ) {\n\tchar *ospath;\n\tfileHandle_t\tf = 0;\n\n\tif ( !fs_searchpaths ) {\n\t\tCom_Error( ERR_FATAL, \"Filesystem call made without initialization\\n\" );\n\t}\n\n\tf = FS_HandleForFile();\n\tfsh[f].zipFile = qfalse;\n\n\tQ_strncpyz( fsh[f].name, filename, sizeof( fsh[f].name ) );\n\n\t// don't let sound stutter\n\tS_ClearSoundBuffer();\n\n  // search homepath\n\tospath = FS_BuildOSPath( fs_homepath->string, filename, \"\" );\n\t// remove trailing slash\n\tospath[strlen(ospath)-1] = '\\0';\n\n\tif ( fs_debug->integer ) {\n\t\tCom_Printf( \"FS_SV_FOpenFileRead (fs_homepath): %s\\n\", ospath );\n\t}\n\n\tfsh[f].handleFiles.file.o = fopen( ospath, \"rb\" );\n\tfsh[f].handleSync = qfalse;\n  if (!fsh[f].handleFiles.file.o)\n  {\n    // NOTE TTimo on non *nix systems, fs_homepath == fs_basepath, might want to avoid\n    if (Q_stricmp(fs_homepath->string,fs_basepath->string))\n    {\n      // search basepath\n      ospath = FS_BuildOSPath( fs_basepath->string, filename, \"\" );\n      ospath[strlen(ospath)-1] = '\\0';\n\n      if ( fs_debug->integer )\n      {\n        Com_Printf( \"FS_SV_FOpenFileRead (fs_basepath): %s\\n\", ospath );\n      }\n\n      fsh[f].handleFiles.file.o = fopen( ospath, \"rb\" );\n      fsh[f].handleSync = qfalse;\n\n      if ( !fsh[f].handleFiles.file.o )\n      {\n        f = 0;\n      }\n    }\n  }\n\n\tif (!fsh[f].handleFiles.file.o) {\n    // search cd path\n    ospath = FS_BuildOSPath( fs_cdpath->string, filename, \"\" );\n    ospath[strlen(ospath)-1] = '\\0';\n\n    if (fs_debug->integer)\n    {\n      Com_Printf( \"FS_SV_FOpenFileRead (fs_cdpath) : %s\\n\", ospath );\n    }\n\n\t  fsh[f].handleFiles.file.o = fopen( ospath, \"rb\" );\n\t  fsh[f].handleSync = qfalse;\n\n\t  if( !fsh[f].handleFiles.file.o ) {\n\t    f = 0;\n\t  }\n  }\n  \n\t*fp = f;\n\tif (f) {\n\t\treturn FS_filelength(f);\n\t}\n\treturn 0;\n}\n\n\n/*\n===========\nFS_SV_Rename\n\n===========\n*/\nvoid FS_SV_Rename( const char *from, const char *to ) {\n\tchar\t\t\t*from_ospath, *to_ospath;\n\n\tif ( !fs_searchpaths ) {\n\t\tCom_Error( ERR_FATAL, \"Filesystem call made without initialization\\n\" );\n\t}\n\n\t// don't let sound stutter\n\tS_ClearSoundBuffer();\n\n\tfrom_ospath = FS_BuildOSPath( fs_homepath->string, from, \"\" );\n\tto_ospath = FS_BuildOSPath( fs_homepath->string, to, \"\" );\n\tfrom_ospath[strlen(from_ospath)-1] = '\\0';\n\tto_ospath[strlen(to_ospath)-1] = '\\0';\n\n\tif ( fs_debug->integer ) {\n\t\tCom_Printf( \"FS_SV_Rename: %s --> %s\\n\", from_ospath, to_ospath );\n\t}\n\n\tif (rename( from_ospath, to_ospath )) {\n\t\t// Failed, try copying it and deleting the original\n\t\tFS_CopyFile ( from_ospath, to_ospath );\n\t\tFS_Remove ( from_ospath );\n\t}\n}\n\n\n\n/*\n===========\nFS_Rename\n\n===========\n*/\nvoid FS_Rename( const char *from, const char *to ) {\n\tchar\t\t\t*from_ospath, *to_ospath;\n\n\tif ( !fs_searchpaths ) {\n\t\tCom_Error( ERR_FATAL, \"Filesystem call made without initialization\\n\" );\n\t}\n\n\t// don't let sound stutter\n\tS_ClearSoundBuffer();\n\n\tfrom_ospath = FS_BuildOSPath( fs_homepath->string, fs_gamedir, from );\n\tto_ospath = FS_BuildOSPath( fs_homepath->string, fs_gamedir, to );\n\n\tif ( fs_debug->integer ) {\n\t\tCom_Printf( \"FS_Rename: %s --> %s\\n\", from_ospath, to_ospath );\n\t}\n\n\tif (rename( from_ospath, to_ospath )) {\n\t\t// Failed, try copying it and deleting the original\n\t\tFS_CopyFile ( from_ospath, to_ospath );\n\t\tFS_Remove ( from_ospath );\n\t}\n}\n\n/*\n==============\nFS_FCloseFile\n\nIf the FILE pointer is an open pak file, leave it open.\n\nFor some reason, other dll's can't just cal fclose()\non files returned by FS_FOpenFile...\n==============\n*/\nvoid FS_FCloseFile( fileHandle_t f ) {\n\tif ( !fs_searchpaths ) {\n\t\tCom_Error( ERR_FATAL, \"Filesystem call made without initialization\\n\" );\n\t}\n\n\tif (fsh[f].streamed) {\n\t\tSys_EndStreamedFile(f);\n\t}\n\tif (fsh[f].zipFile == qtrue) {\n\t\tunzCloseCurrentFile( fsh[f].handleFiles.file.z );\n\t\tif ( fsh[f].handleFiles.unique ) {\n\t\t\tunzClose( fsh[f].handleFiles.file.z );\n\t\t}\n\t\tCom_Memset( &fsh[f], 0, sizeof( fsh[f] ) );\n\t\treturn;\n\t}\n\n\t// we didn't find it as a pak, so close it as a unique file\n\tif (fsh[f].handleFiles.file.o) {\n\t\tfclose (fsh[f].handleFiles.file.o);\n\t}\n\tCom_Memset( &fsh[f], 0, sizeof( fsh[f] ) );\n}\n\n/*\n===========\nFS_FOpenFileWrite\n\n===========\n*/\nfileHandle_t FS_FOpenFileWrite( const char *filename ) {\n\tchar\t\t\t*ospath;\n\tfileHandle_t\tf;\n\n\tif ( !fs_searchpaths ) {\n\t\tCom_Error( ERR_FATAL, \"Filesystem call made without initialization\\n\" );\n\t}\n\n\tf = FS_HandleForFile();\n\tfsh[f].zipFile = qfalse;\n\n\tospath = FS_BuildOSPath( fs_homepath->string, fs_gamedir, filename );\n\n\tif ( fs_debug->integer ) {\n\t\tCom_Printf( \"FS_FOpenFileWrite: %s\\n\", ospath );\n\t}\n\n\tif( FS_CreatePath( ospath ) ) {\n\t\treturn 0;\n\t}\n\n\t// enabling the following line causes a recursive function call loop\n\t// when running with +set logfile 1 +set developer 1\n\t//Com_DPrintf( \"writing to: %s\\n\", ospath );\n\tfsh[f].handleFiles.file.o = fopen( ospath, \"wb\" );\n\n\tQ_strncpyz( fsh[f].name, filename, sizeof( fsh[f].name ) );\n\n\tfsh[f].handleSync = qfalse;\n\tif (!fsh[f].handleFiles.file.o) {\n\t\tf = 0;\n\t}\n\treturn f;\n}\n\n/*\n===========\nFS_FOpenFileAppend\n\n===========\n*/\nfileHandle_t FS_FOpenFileAppend( const char *filename ) {\n\tchar\t\t\t*ospath;\n\tfileHandle_t\tf;\n\n\tif ( !fs_searchpaths ) {\n\t\tCom_Error( ERR_FATAL, \"Filesystem call made without initialization\\n\" );\n\t}\n\n\tf = FS_HandleForFile();\n\tfsh[f].zipFile = qfalse;\n\n\tQ_strncpyz( fsh[f].name, filename, sizeof( fsh[f].name ) );\n\n\t// don't let sound stutter\n\tS_ClearSoundBuffer();\n\n\tospath = FS_BuildOSPath( fs_homepath->string, fs_gamedir, filename );\n\n\tif ( fs_debug->integer ) {\n\t\tCom_Printf( \"FS_FOpenFileAppend: %s\\n\", ospath );\n\t}\n\n\tif( FS_CreatePath( ospath ) ) {\n\t\treturn 0;\n\t}\n\n\tfsh[f].handleFiles.file.o = fopen( ospath, \"ab\" );\n\tfsh[f].handleSync = qfalse;\n\tif (!fsh[f].handleFiles.file.o) {\n\t\tf = 0;\n\t}\n\treturn f;\n}\n\n/*\n===========\nFS_FilenameCompare\n\nIgnore case and seprator char distinctions\n===========\n*/\nqboolean FS_FilenameCompare( const char *s1, const char *s2 ) {\n\tint\t\tc1, c2;\n\t\n\tdo {\n\t\tc1 = *s1++;\n\t\tc2 = *s2++;\n\n\t\tif (c1 >= 'a' && c1 <= 'z') {\n\t\t\tc1 -= ('a' - 'A');\n\t\t}\n\t\tif (c2 >= 'a' && c2 <= 'z') {\n\t\t\tc2 -= ('a' - 'A');\n\t\t}\n\n\t\tif ( c1 == '\\\\' || c1 == ':' ) {\n\t\t\tc1 = '/';\n\t\t}\n\t\tif ( c2 == '\\\\' || c2 == ':' ) {\n\t\t\tc2 = '/';\n\t\t}\n\t\t\n\t\tif (c1 != c2) {\n\t\t\treturn -1;\t\t// strings not equal\n\t\t}\n\t} while (c1);\n\t\n\treturn 0;\t\t// strings are equal\n}\n\n/*\n===========\nFS_ShiftedStrStr\n===========\n*/\nchar *FS_ShiftedStrStr(const char *string, const char *substring, int shift) {\n\tchar buf[MAX_STRING_TOKENS];\n\tint i;\n\n\tfor (i = 0; substring[i]; i++) {\n\t\tbuf[i] = substring[i] + shift;\n\t}\n\tbuf[i] = '\\0';\n\treturn strstr(string, buf);\n}\n\n/*\n===========\nFS_FOpenFileRead\n\nFinds the file in the search path.\nReturns filesize and an open FILE pointer.\nUsed for streaming data out of either a\nseparate file or a ZIP file.\n===========\n*/\nextern qboolean\t\tcom_fullyInitialized;\n\nint FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean uniqueFILE ) {\n\tsearchpath_t\t*search;\n\tchar\t\t\t*netpath;\n\tpack_t\t\t\t*pak;\n\tfileInPack_t\t*pakFile;\n\tdirectory_t\t\t*dir;\n\tlong\t\t\thash;\n\tunz_s\t\t\t*zfi;\n\tFILE\t\t\t*temp;\n\tint\t\t\t\tl;\n\tchar demoExt[16];\n\n\thash = 0;\n\n\tif ( !fs_searchpaths ) {\n\t\tCom_Error( ERR_FATAL, \"Filesystem call made without initialization\\n\" );\n\t}\n\n\tif ( file == NULL ) {\n\t\t// just wants to see if file is there\n\t\tfor ( search = fs_searchpaths ; search ; search = search->next ) {\n\t\t\t//\n\t\t\tif ( search->pack ) {\n\t\t\t\thash = FS_HashFileName(filename, search->pack->hashSize);\n\t\t\t}\n\t\t\t// is the element a pak file?\n\t\t\tif ( search->pack && search->pack->hashTable[hash] ) {\n\t\t\t\t// look through all the pak file elements\n\t\t\t\tpak = search->pack;\n\t\t\t\tpakFile = pak->hashTable[hash];\n\t\t\t\tdo {\n\t\t\t\t\t// case and separator insensitive comparisons\n\t\t\t\t\tif ( !FS_FilenameCompare( pakFile->name, filename ) ) {\n\t\t\t\t\t\t// found it!\n\t\t\t\t\t\treturn qtrue;\n\t\t\t\t\t}\n\t\t\t\t\tpakFile = pakFile->next;\n\t\t\t\t} while(pakFile != NULL);\n\t\t\t} else if ( search->dir ) {\n\t\t\t\tdir = search->dir;\n\t\t\t\n\t\t\t\tnetpath = FS_BuildOSPath( dir->path, dir->gamedir, filename );\n\t\t\t\ttemp = fopen (netpath, \"rb\");\n\t\t\t\tif ( !temp ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tfclose(temp);\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t}\n\t\treturn qfalse;\n\t}\n\n\tif ( !filename ) {\n\t\tCom_Error( ERR_FATAL, \"FS_FOpenFileRead: NULL 'filename' parameter passed\\n\" );\n\t}\n\n\tCom_sprintf (demoExt, sizeof(demoExt), \".dm_%d\",PROTOCOL_VERSION );\n\t// qpaths are not supposed to have a leading slash\n\tif ( filename[0] == '/' || filename[0] == '\\\\' ) {\n\t\tfilename++;\n\t}\n\n\t// make absolutely sure that it can't back up the path.\n\t// The searchpaths do guarantee that something will always\n\t// be prepended, so we don't need to worry about \"c:\" or \"//limbo\" \n\tif ( strstr( filename, \"..\" ) || strstr( filename, \"::\" ) ) {\n\t\t*file = 0;\n\t\treturn -1;\n\t}\n\n\t// make sure the q3key file is only readable by the quake3.exe at initialization\n\t// any other time the key should only be accessed in memory using the provided functions\n\tif( com_fullyInitialized && strstr( filename, \"q3key\" ) ) {\n\t\t*file = 0;\n\t\treturn -1;\n\t}\n\n\t//\n\t// search through the path, one element at a time\n\t//\n\n\t*file = FS_HandleForFile();\n\tfsh[*file].handleFiles.unique = uniqueFILE;\n\n\tfor ( search = fs_searchpaths ; search ; search = search->next ) {\n\t\t//\n\t\tif ( search->pack ) {\n\t\t\thash = FS_HashFileName(filename, search->pack->hashSize);\n\t\t}\n\t\t// is the element a pak file?\n\t\tif ( search->pack && search->pack->hashTable[hash] ) {\n\t\t\t// disregard if it doesn't match one of the allowed pure pak files\n\t\t\tif ( !FS_PakIsPure(search->pack) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// look through all the pak file elements\n\t\t\tpak = search->pack;\n\t\t\tpakFile = pak->hashTable[hash];\n\t\t\tdo {\n\t\t\t\t// case and separator insensitive comparisons\n\t\t\t\tif ( !FS_FilenameCompare( pakFile->name, filename ) ) {\n\t\t\t\t\t// found it!\n\n\t\t\t\t\t// mark the pak as having been referenced and mark specifics on cgame and ui\n\t\t\t\t\t// shaders, txt, arena files  by themselves do not count as a reference as \n\t\t\t\t\t// these are loaded from all pk3s \n\t\t\t\t\t// from every pk3 file.. \n\t\t\t\t\tl = strlen( filename );\n\t\t\t\t\tif ( !(pak->referenced & FS_GENERAL_REF)) {\n\t\t\t\t\t\tif ( Q_stricmp(filename + l - 7, \".shader\") != 0 &&\n\t\t\t\t\t\t\tQ_stricmp(filename + l - 4, \".txt\") != 0 &&\n\t\t\t\t\t\t\tQ_stricmp(filename + l - 4, \".cfg\") != 0 &&\n\t\t\t\t\t\t\tQ_stricmp(filename + l - 7, \".config\") != 0 &&\n\t\t\t\t\t\t\tstrstr(filename, \"levelshots\") == NULL &&\n\t\t\t\t\t\t\tQ_stricmp(filename + l - 4, \".bot\") != 0 &&\n\t\t\t\t\t\t\tQ_stricmp(filename + l - 6, \".arena\") != 0 &&\n\t\t\t\t\t\t\tQ_stricmp(filename + l - 5, \".menu\") != 0) {\n\t\t\t\t\t\t\tpak->referenced |= FS_GENERAL_REF;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// qagame.qvm\t- 13\n\t\t\t\t\t// dTZT`X!di`\n\t\t\t\t\tif (!(pak->referenced & FS_QAGAME_REF) && FS_ShiftedStrStr(filename, \"dTZT`X!di`\", 13)) {\n\t\t\t\t\t\tpak->referenced |= FS_QAGAME_REF;\n\t\t\t\t\t}\n\t\t\t\t\t// cgame.qvm\t- 7\n\t\t\t\t\t// \\`Zf^'jof\n\t\t\t\t\tif (!(pak->referenced & FS_CGAME_REF) && FS_ShiftedStrStr(filename , \"\\\\`Zf^'jof\", 7)) {\n\t\t\t\t\t\tpak->referenced |= FS_CGAME_REF;\n\t\t\t\t\t}\n\t\t\t\t\t// ui.qvm\t\t- 5\n\t\t\t\t\t// pd)lqh\n\t\t\t\t\tif (!(pak->referenced & FS_UI_REF) && FS_ShiftedStrStr(filename , \"pd)lqh\", 5)) {\n\t\t\t\t\t\tpak->referenced |= FS_UI_REF;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( uniqueFILE ) {\n\t\t\t\t\t\t// open a new file on the pakfile\n\t\t\t\t\t\tfsh[*file].handleFiles.file.z = unzReOpen (pak->pakFilename, pak->handle);\n\t\t\t\t\t\tif (fsh[*file].handleFiles.file.z == NULL) {\n\t\t\t\t\t\t\tCom_Error (ERR_FATAL, \"Couldn't reopen %s\", pak->pakFilename);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfsh[*file].handleFiles.file.z = pak->handle;\n\t\t\t\t\t}\n\t\t\t\t\tQ_strncpyz( fsh[*file].name, filename, sizeof( fsh[*file].name ) );\n\t\t\t\t\tfsh[*file].zipFile = qtrue;\n\t\t\t\t\tzfi = (unz_s *)fsh[*file].handleFiles.file.z;\n\t\t\t\t\t// in case the file was new\n\t\t\t\t\ttemp = zfi->file;\n\t\t\t\t\t// set the file position in the zip file (also sets the current file info)\n\t\t\t\t\tunzSetCurrentFileInfoPosition(pak->handle, pakFile->pos);\n\t\t\t\t\t// copy the file info into the unzip structure\n\t\t\t\t\tCom_Memcpy( zfi, pak->handle, sizeof(unz_s) );\n\t\t\t\t\t// we copy this back into the structure\n\t\t\t\t\tzfi->file = temp;\n\t\t\t\t\t// open the file in the zip\n\t\t\t\t\tunzOpenCurrentFile( fsh[*file].handleFiles.file.z );\n\t\t\t\t\tfsh[*file].zipFilePos = pakFile->pos;\n\n\t\t\t\t\tif ( fs_debug->integer ) {\n\t\t\t\t\t\tCom_Printf( \"FS_FOpenFileRead: %s (found in '%s')\\n\", \n\t\t\t\t\t\t\tfilename, pak->pakFilename );\n\t\t\t\t\t}\n\t\t\t\t\treturn zfi->cur_file_info.uncompressed_size;\n\t\t\t\t}\n\t\t\t\tpakFile = pakFile->next;\n\t\t\t} while(pakFile != NULL);\n\t\t} else if ( search->dir ) {\n\t\t\t// check a file in the directory tree\n\n\t\t\t// if we are running restricted, the only files we\n\t\t\t// will allow to come from the directory are .cfg files\n\t\t\tl = strlen( filename );\n      // FIXME TTimo I'm not sure about the fs_numServerPaks test\n      // if you are using FS_ReadFile to find out if a file exists,\n      //   this test can make the search fail although the file is in the directory\n      // I had the problem on https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=8\n      // turned out I used FS_FileExists instead\n\t\t\tif ( fs_restrict->integer || fs_numServerPaks ) {\n\n\t\t\t\tif ( Q_stricmp( filename + l - 4, \".cfg\" )\t\t// for config files\n\t\t\t\t\t&& Q_stricmp( filename + l - 5, \".menu\" )\t// menu files\n\t\t\t\t\t&& Q_stricmp( filename + l - 5, \".game\" )\t// menu files\n\t\t\t\t\t&& Q_stricmp( filename + l - strlen(demoExt), demoExt )\t// menu files\n\t\t\t\t\t&& Q_stricmp( filename + l - 4, \".dat\" ) ) {\t// for journal files\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tdir = search->dir;\n\t\t\t\n\t\t\tnetpath = FS_BuildOSPath( dir->path, dir->gamedir, filename );\n\t\t\tfsh[*file].handleFiles.file.o = fopen (netpath, \"rb\");\n\t\t\tif ( !fsh[*file].handleFiles.file.o ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif ( Q_stricmp( filename + l - 4, \".cfg\" )\t\t// for config files\n\t\t\t\t&& Q_stricmp( filename + l - 5, \".menu\" )\t// menu files\n\t\t\t\t&& Q_stricmp( filename + l - 5, \".game\" )\t// menu files\n\t\t\t\t&& Q_stricmp( filename + l - strlen(demoExt), demoExt )\t// menu files\n\t\t\t\t&& Q_stricmp( filename + l - 4, \".dat\" ) ) {\t// for journal files\n\t\t\t\tfs_fakeChkSum = random();\n\t\t\t}\n      \n\t\t\tQ_strncpyz( fsh[*file].name, filename, sizeof( fsh[*file].name ) );\n\t\t\tfsh[*file].zipFile = qfalse;\n\t\t\tif ( fs_debug->integer ) {\n\t\t\t\tCom_Printf( \"FS_FOpenFileRead: %s (found in '%s/%s')\\n\", filename,\n\t\t\t\t\tdir->path, dir->gamedir );\n\t\t\t}\n\n\t\t\t// if we are getting it from the cdpath, optionally copy it\n\t\t\t//  to the basepath\n\t\t\tif ( fs_copyfiles->integer && !Q_stricmp( dir->path, fs_cdpath->string ) ) {\n\t\t\t\tchar\t*copypath;\n\n\t\t\t\tcopypath = FS_BuildOSPath( fs_basepath->string, dir->gamedir, filename );\n\t\t\t\tFS_CopyFile( netpath, copypath );\n\t\t\t}\n\n\t\t\treturn FS_filelength (*file);\n\t\t}\t\t\n\t}\n\t\n\tCom_DPrintf (\"Can't find %s\\n\", filename);\n#ifdef FS_MISSING\n\tif (missingFiles) {\n\t\tfprintf(missingFiles, \"%s\\n\", filename);\n\t}\n#endif\n\t*file = 0;\n\treturn -1;\n}\n\n\n/*\n=================\nFS_Read\n\nProperly handles partial reads\n=================\n*/\nint FS_Read2( void *buffer, int len, fileHandle_t f ) {\n\tif ( !fs_searchpaths ) {\n\t\tCom_Error( ERR_FATAL, \"Filesystem call made without initialization\\n\" );\n\t}\n\n\tif ( !f ) {\n\t\treturn 0;\n\t}\n\tif (fsh[f].streamed) {\n\t\tint r;\n\t\tfsh[f].streamed = qfalse;\n\t\tr = Sys_StreamedRead( buffer, len, 1, f);\n\t\tfsh[f].streamed = qtrue;\n\t\treturn r;\n\t} else {\n\t\treturn FS_Read( buffer, len, f);\n\t}\n}\n\nint FS_Read( void *buffer, int len, fileHandle_t f ) {\n\tint\t\tblock, remaining;\n\tint\t\tread;\n\tbyte\t*buf;\n\tint\t\ttries;\n\n\tif ( !fs_searchpaths ) {\n\t\tCom_Error( ERR_FATAL, \"Filesystem call made without initialization\\n\" );\n\t}\n\n\tif ( !f ) {\n\t\treturn 0;\n\t}\n\n\tbuf = (byte *)buffer;\n\tfs_readCount += len;\n\n\tif (fsh[f].zipFile == qfalse) {\n\t\tremaining = len;\n\t\ttries = 0;\n\t\twhile (remaining) {\n\t\t\tblock = remaining;\n\t\t\tread = fread (buf, 1, block, fsh[f].handleFiles.file.o);\n\t\t\tif (read == 0) {\n\t\t\t\t// we might have been trying to read from a CD, which\n\t\t\t\t// sometimes returns a 0 read on windows\n\t\t\t\tif (!tries) {\n\t\t\t\t\ttries = 1;\n\t\t\t\t} else {\n\t\t\t\t\treturn len-remaining;\t//Com_Error (ERR_FATAL, \"FS_Read: 0 bytes read\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (read == -1) {\n\t\t\t\tCom_Error (ERR_FATAL, \"FS_Read: -1 bytes read\");\n\t\t\t}\n\n\t\t\tremaining -= read;\n\t\t\tbuf += read;\n\t\t}\n\t\treturn len;\n\t} else {\n\t\treturn unzReadCurrentFile(fsh[f].handleFiles.file.z, buffer, len);\n\t}\n}\n\n/*\n=================\nFS_Write\n\nProperly handles partial writes\n=================\n*/\nint FS_Write( const void *buffer, int len, fileHandle_t h ) {\n\tint\t\tblock, remaining;\n\tint\t\twritten;\n\tbyte\t*buf;\n\tint\t\ttries;\n\tFILE\t*f;\n\n\tif ( !fs_searchpaths ) {\n\t\tCom_Error( ERR_FATAL, \"Filesystem call made without initialization\\n\" );\n\t}\n\n\tif ( !h ) {\n\t\treturn 0;\n\t}\n\n\tf = FS_FileForHandle(h);\n\tbuf = (byte *)buffer;\n\n\tremaining = len;\n\ttries = 0;\n\twhile (remaining) {\n\t\tblock = remaining;\n\t\twritten = fwrite (buf, 1, block, f);\n\t\tif (written == 0) {\n\t\t\tif (!tries) {\n\t\t\t\ttries = 1;\n\t\t\t} else {\n\t\t\t\tCom_Printf( \"FS_Write: 0 bytes written\\n\" );\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\n\t\tif (written == -1) {\n\t\t\tCom_Printf( \"FS_Write: -1 bytes written\\n\" );\n\t\t\treturn 0;\n\t\t}\n\n\t\tremaining -= written;\n\t\tbuf += written;\n\t}\n\tif ( fsh[h].handleSync ) {\n\t\tfflush( f );\n\t}\n\treturn len;\n}\n\nvoid QDECL FS_Printf( fileHandle_t h, const char *fmt, ... ) {\n\tva_list\t\targptr;\n\tchar\t\tmsg[MAXPRINTMSG];\n\n\tva_start (argptr,fmt);\n\tQ_vsnprintf (msg, sizeof(msg), fmt, argptr);\n\tva_end (argptr);\n\n\tFS_Write(msg, strlen(msg), h);\n}\n\n/*\n=================\nFS_Seek\n\n=================\n*/\nint FS_Seek( fileHandle_t f, long offset, int origin ) {\n\tint\t\t_origin;\n\tchar\tfoo[65536];\n\n\tif ( !fs_searchpaths ) {\n\t\tCom_Error( ERR_FATAL, \"Filesystem call made without initialization\\n\" );\n\t\treturn -1;\n\t}\n\n\tif (fsh[f].streamed) {\n\t\tfsh[f].streamed = qfalse;\n\t\tSys_StreamSeek( f, offset, origin );\n\t\tfsh[f].streamed = qtrue;\n\t}\n\n\tif (fsh[f].zipFile == qtrue) {\n\t\tif (offset == 0 && origin == FS_SEEK_SET) {\n\t\t\t// set the file position in the zip file (also sets the current file info)\n\t\t\tunzSetCurrentFileInfoPosition(fsh[f].handleFiles.file.z, fsh[f].zipFilePos);\n\t\t\treturn unzOpenCurrentFile(fsh[f].handleFiles.file.z);\n\t\t} else if (offset<65536) {\n\t\t\t// set the file position in the zip file (also sets the current file info)\n\t\t\tunzSetCurrentFileInfoPosition(fsh[f].handleFiles.file.z, fsh[f].zipFilePos);\n\t\t\tunzOpenCurrentFile(fsh[f].handleFiles.file.z);\n\t\t\treturn FS_Read(foo, offset, f);\n\t\t} else {\n\t\t\tCom_Error( ERR_FATAL, \"ZIP FILE FSEEK NOT YET IMPLEMENTED\\n\" );\n\t\t\treturn -1;\n\t\t}\n\t} else {\n\t\tFILE *file;\n\t\tfile = FS_FileForHandle(f);\n\t\tswitch( origin ) {\n\t\tcase FS_SEEK_CUR:\n\t\t\t_origin = SEEK_CUR;\n\t\t\tbreak;\n\t\tcase FS_SEEK_END:\n\t\t\t_origin = SEEK_END;\n\t\t\tbreak;\n\t\tcase FS_SEEK_SET:\n\t\t\t_origin = SEEK_SET;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t_origin = SEEK_CUR;\n\t\t\tCom_Error( ERR_FATAL, \"Bad origin in FS_Seek\\n\" );\n\t\t\tbreak;\n\t\t}\n\n\t\treturn fseek( file, offset, _origin );\n\t}\n}\n\n\n/*\n======================================================================================\n\nCONVENIENCE FUNCTIONS FOR ENTIRE FILES\n\n======================================================================================\n*/\n\nint\tFS_FileIsInPAK(const char *filename, int *pChecksum ) {\n\tsearchpath_t\t*search;\n\tpack_t\t\t\t*pak;\n\tfileInPack_t\t*pakFile;\n\tlong\t\t\thash = 0;\n\n\tif ( !fs_searchpaths ) {\n\t\tCom_Error( ERR_FATAL, \"Filesystem call made without initialization\\n\" );\n\t}\n\n\tif ( !filename ) {\n\t\tCom_Error( ERR_FATAL, \"FS_FOpenFileRead: NULL 'filename' parameter passed\\n\" );\n\t}\n\n\t// qpaths are not supposed to have a leading slash\n\tif ( filename[0] == '/' || filename[0] == '\\\\' ) {\n\t\tfilename++;\n\t}\n\n\t// make absolutely sure that it can't back up the path.\n\t// The searchpaths do guarantee that something will always\n\t// be prepended, so we don't need to worry about \"c:\" or \"//limbo\" \n\tif ( strstr( filename, \"..\" ) || strstr( filename, \"::\" ) ) {\n\t\treturn -1;\n\t}\n\n\t//\n\t// search through the path, one element at a time\n\t//\n\n\tfor ( search = fs_searchpaths ; search ; search = search->next ) {\n\t\t//\n\t\tif (search->pack) {\n\t\t\thash = FS_HashFileName(filename, search->pack->hashSize);\n\t\t}\n\t\t// is the element a pak file?\n\t\tif ( search->pack && search->pack->hashTable[hash] ) {\n\t\t\t// disregard if it doesn't match one of the allowed pure pak files\n\t\t\tif ( !FS_PakIsPure(search->pack) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// look through all the pak file elements\n\t\t\tpak = search->pack;\n\t\t\tpakFile = pak->hashTable[hash];\n\t\t\tdo {\n\t\t\t\t// case and separator insensitive comparisons\n\t\t\t\tif ( !FS_FilenameCompare( pakFile->name, filename ) ) {\n\t\t\t\t\tif (pChecksum) {\n\t\t\t\t\t\t*pChecksum = pak->pure_checksum;\n\t\t\t\t\t}\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t\tpakFile = pakFile->next;\n\t\t\t} while(pakFile != NULL);\n\t\t}\n\t}\n\treturn -1;\n}\n\n/*\n============\nFS_ReadFile\n\nFilename are relative to the quake search path\na null buffer will just return the file length without loading\n============\n*/\nint FS_ReadFile( const char *qpath, void **buffer ) {\n\tfileHandle_t\th;\n\tbyte*\t\t\tbuf;\n\tqboolean\t\tisConfig;\n\tint\t\t\t\tlen;\n\n\tif ( !fs_searchpaths ) {\n\t\tCom_Error( ERR_FATAL, \"Filesystem call made without initialization\\n\" );\n\t}\n\n\tif ( !qpath || !qpath[0] ) {\n\t\tCom_Error( ERR_FATAL, \"FS_ReadFile with empty name\\n\" );\n\t}\n\n\tbuf = NULL;\t// quiet compiler warning\n\n\t// if this is a .cfg file and we are playing back a journal, read\n\t// it from the journal file\n\tif ( strstr( qpath, \".cfg\" ) ) {\n\t\tisConfig = qtrue;\n\t\tif ( com_journal && com_journal->integer == 2 ) {\n\t\t\tint\t\tr;\n\n\t\t\tCom_DPrintf( \"Loading %s from journal file.\\n\", qpath );\n\t\t\tr = FS_Read( &len, sizeof( len ), com_journalDataFile );\n\t\t\tif ( r != sizeof( len ) ) {\n\t\t\t\tif (buffer != NULL) *buffer = NULL;\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\t// if the file didn't exist when the journal was created\n\t\t\tif (!len) {\n\t\t\t\tif (buffer == NULL) {\n\t\t\t\t\treturn 1;\t\t\t// hack for old journal files\n\t\t\t\t}\n\t\t\t\t*buffer = NULL;\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tif (buffer == NULL) {\n\t\t\t\treturn len;\n\t\t\t}\n\n\t\t\tbuf = Hunk_AllocateTempMemory(len+1);\n\t\t\t*buffer = buf;\n\n\t\t\tr = FS_Read( buf, len, com_journalDataFile );\n\t\t\tif ( r != len ) {\n\t\t\t\tCom_Error( ERR_FATAL, \"Read from journalDataFile failed\" );\n\t\t\t}\n\n\t\t\tfs_loadCount++;\n\t\t\tfs_loadStack++;\n\n\t\t\t// guarantee that it will have a trailing 0 for string operations\n\t\t\tbuf[len] = 0;\n\n\t\t\treturn len;\n\t\t}\n\t} else {\n\t\tisConfig = qfalse;\n\t}\n\n\t// look for it in the filesystem or pack files\n\tlen = FS_FOpenFileRead( qpath, &h, qfalse );\n\tif ( h == 0 ) {\n\t\tif ( buffer ) {\n\t\t\t*buffer = NULL;\n\t\t}\n\t\t// if we are journalling and it is a config file, write a zero to the journal file\n\t\tif ( isConfig && com_journal && com_journal->integer == 1 ) {\n\t\t\tCom_DPrintf( \"Writing zero for %s to journal file.\\n\", qpath );\n\t\t\tlen = 0;\n\t\t\tFS_Write( &len, sizeof( len ), com_journalDataFile );\n\t\t\tFS_Flush( com_journalDataFile );\n\t\t}\n\t\treturn -1;\n\t}\n\t\n\tif ( !buffer ) {\n\t\tif ( isConfig && com_journal && com_journal->integer == 1 ) {\n\t\t\tCom_DPrintf( \"Writing len for %s to journal file.\\n\", qpath );\n\t\t\tFS_Write( &len, sizeof( len ), com_journalDataFile );\n\t\t\tFS_Flush( com_journalDataFile );\n\t\t}\n\t\tFS_FCloseFile( h);\n\t\treturn len;\n\t}\n\n\tfs_loadCount++;\n\tfs_loadStack++;\n\n\tbuf = Hunk_AllocateTempMemory(len+1);\n\t*buffer = buf;\n\n\tFS_Read (buf, len, h);\n\n\t// guarantee that it will have a trailing 0 for string operations\n\tbuf[len] = 0;\n\tFS_FCloseFile( h );\n\n\t// if we are journalling and it is a config file, write it to the journal file\n\tif ( isConfig && com_journal && com_journal->integer == 1 ) {\n\t\tCom_DPrintf( \"Writing %s to journal file.\\n\", qpath );\n\t\tFS_Write( &len, sizeof( len ), com_journalDataFile );\n\t\tFS_Write( buf, len, com_journalDataFile );\n\t\tFS_Flush( com_journalDataFile );\n\t}\n\treturn len;\n}\n\n/*\n=============\nFS_FreeFile\n=============\n*/\nvoid FS_FreeFile( void *buffer ) {\n\tif ( !fs_searchpaths ) {\n\t\tCom_Error( ERR_FATAL, \"Filesystem call made without initialization\\n\" );\n\t}\n\tif ( !buffer ) {\n\t\tCom_Error( ERR_FATAL, \"FS_FreeFile( NULL )\" );\n\t}\n\tfs_loadStack--;\n\n\tHunk_FreeTempMemory( buffer );\n\n\t// if all of our temp files are free, clear all of our space\n\tif ( fs_loadStack == 0 ) {\n\t\tHunk_ClearTempMemory();\n\t}\n}\n\n/*\n============\nFS_WriteFile\n\nFilename are reletive to the quake search path\n============\n*/\nvoid FS_WriteFile( const char *qpath, const void *buffer, int size ) {\n\tfileHandle_t f;\n\n\tif ( !fs_searchpaths ) {\n\t\tCom_Error( ERR_FATAL, \"Filesystem call made without initialization\\n\" );\n\t}\n\n\tif ( !qpath || !buffer ) {\n\t\tCom_Error( ERR_FATAL, \"FS_WriteFile: NULL parameter\" );\n\t}\n\n\tf = FS_FOpenFileWrite( qpath );\n\tif ( !f ) {\n\t\tCom_Printf( \"Failed to open %s\\n\", qpath );\n\t\treturn;\n\t}\n\n\tFS_Write( buffer, size, f );\n\n\tFS_FCloseFile( f );\n}\n\n\n\n/*\n==========================================================================\n\nZIP FILE LOADING\n\n==========================================================================\n*/\n\n/*\n=================\nFS_LoadZipFile\n\nCreates a new pak_t in the search chain for the contents\nof a zip file.\n=================\n*/\nstatic pack_t *FS_LoadZipFile( char *zipfile, const char *basename )\n{\n\tfileInPack_t\t*buildBuffer;\n\tpack_t\t\t\t*pack;\n\tunzFile\t\t\tuf;\n\tint\t\t\t\terr;\n\tunz_global_info gi;\n\tchar\t\t\tfilename_inzip[MAX_ZPATH];\n\tunz_file_info\tfile_info;\n\tint\t\t\t\ti, len;\n\tlong\t\t\thash;\n\tint\t\t\t\tfs_numHeaderLongs;\n\tint\t\t\t\t*fs_headerLongs;\n\tchar\t\t\t*namePtr;\n\n\tfs_numHeaderLongs = 0;\n\n\tuf = unzOpen(zipfile);\n\terr = unzGetGlobalInfo (uf,&gi);\n\n\tif (err != UNZ_OK)\n\t\treturn NULL;\n\n\tfs_packFiles += gi.number_entry;\n\n\tlen = 0;\n\tunzGoToFirstFile(uf);\n\tfor (i = 0; i < gi.number_entry; i++)\n\t{\n\t\terr = unzGetCurrentFileInfo(uf, &file_info, filename_inzip, sizeof(filename_inzip), NULL, 0, NULL, 0);\n\t\tif (err != UNZ_OK) {\n\t\t\tbreak;\n\t\t}\n\t\tlen += strlen(filename_inzip) + 1;\n\t\tunzGoToNextFile(uf);\n\t}\n\n\tbuildBuffer = Z_Malloc( (gi.number_entry * sizeof( fileInPack_t )) + len );\n\tnamePtr = ((char *) buildBuffer) + gi.number_entry * sizeof( fileInPack_t );\n\tfs_headerLongs = Z_Malloc( gi.number_entry * sizeof(int) );\n\n\t// get the hash table size from the number of files in the zip\n\t// because lots of custom pk3 files have less than 32 or 64 files\n\tfor (i = 1; i <= MAX_FILEHASH_SIZE; i <<= 1) {\n\t\tif (i > gi.number_entry) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tpack = Z_Malloc( sizeof( pack_t ) + i * sizeof(fileInPack_t *) );\n\tpack->hashSize = i;\n\tpack->hashTable = (fileInPack_t **) (((char *) pack) + sizeof( pack_t ));\n\tfor(i = 0; i < pack->hashSize; i++) {\n\t\tpack->hashTable[i] = NULL;\n\t}\n\n\tQ_strncpyz( pack->pakFilename, zipfile, sizeof( pack->pakFilename ) );\n\tQ_strncpyz( pack->pakBasename, basename, sizeof( pack->pakBasename ) );\n\n\t// strip .pk3 if needed\n\tif ( strlen( pack->pakBasename ) > 4 && !Q_stricmp( pack->pakBasename + strlen( pack->pakBasename ) - 4, \".pk3\" ) ) {\n\t\tpack->pakBasename[strlen( pack->pakBasename ) - 4] = 0;\n\t}\n\n\tpack->handle = uf;\n\tpack->numfiles = gi.number_entry;\n\tunzGoToFirstFile(uf);\n\n\tfor (i = 0; i < gi.number_entry; i++)\n\t{\n\t\terr = unzGetCurrentFileInfo(uf, &file_info, filename_inzip, sizeof(filename_inzip), NULL, 0, NULL, 0);\n\t\tif (err != UNZ_OK) {\n\t\t\tbreak;\n\t\t}\n\t\tif (file_info.uncompressed_size > 0) {\n\t\t\tfs_headerLongs[fs_numHeaderLongs++] = LittleLong(file_info.crc);\n\t\t}\n\t\tQ_strlwr( filename_inzip );\n\t\thash = FS_HashFileName(filename_inzip, pack->hashSize);\n\t\tbuildBuffer[i].name = namePtr;\n\t\tstrcpy( buildBuffer[i].name, filename_inzip );\n\t\tnamePtr += strlen(filename_inzip) + 1;\n\t\t// store the file position in the zip\n\t\tunzGetCurrentFileInfoPosition(uf, &buildBuffer[i].pos);\n\t\t//\n\t\tbuildBuffer[i].next = pack->hashTable[hash];\n\t\tpack->hashTable[hash] = &buildBuffer[i];\n\t\tunzGoToNextFile(uf);\n\t}\n\n\tpack->checksum = Com_BlockChecksum( fs_headerLongs, 4 * fs_numHeaderLongs );\n\tpack->pure_checksum = Com_BlockChecksumKey( fs_headerLongs, 4 * fs_numHeaderLongs, LittleLong(fs_checksumFeed) );\n\tpack->checksum = LittleLong( pack->checksum );\n\tpack->pure_checksum = LittleLong( pack->pure_checksum );\n\n\tZ_Free(fs_headerLongs);\n\n\tpack->buildBuffer = buildBuffer;\n\treturn pack;\n}\n\n/*\n=================================================================================\n\nDIRECTORY SCANNING FUNCTIONS\n\n=================================================================================\n*/\n\n#define\tMAX_FOUND_FILES\t0x1000\n\nstatic int FS_ReturnPath( const char *zname, char *zpath, int *depth ) {\n\tint len, at, newdep;\n\n\tnewdep = 0;\n\tzpath[0] = 0;\n\tlen = 0;\n\tat = 0;\n\n\twhile(zname[at] != 0)\n\t{\n\t\tif (zname[at]=='/' || zname[at]=='\\\\') {\n\t\t\tlen = at;\n\t\t\tnewdep++;\n\t\t}\n\t\tat++;\n\t}\n\tstrcpy(zpath, zname);\n\tzpath[len] = 0;\n\t*depth = newdep;\n\n\treturn len;\n}\n\n/*\n==================\nFS_AddFileToList\n==================\n*/\nstatic int FS_AddFileToList( char *name, char *list[MAX_FOUND_FILES], int nfiles ) {\n\tint\t\ti;\n\n\tif ( nfiles == MAX_FOUND_FILES - 1 ) {\n\t\treturn nfiles;\n\t}\n\tfor ( i = 0 ; i < nfiles ; i++ ) {\n\t\tif ( !Q_stricmp( name, list[i] ) ) {\n\t\t\treturn nfiles;\t\t// allready in list\n\t\t}\n\t}\n\tlist[nfiles] = CopyString( name );\n\tnfiles++;\n\n\treturn nfiles;\n}\n\n/*\n===============\nFS_ListFilteredFiles\n\nReturns a uniqued list of files that match the given criteria\nfrom all search paths\n===============\n*/\nchar **FS_ListFilteredFiles( const char *path, const char *extension, char *filter, int *numfiles ) {\n\tint\t\t\t\tnfiles;\n\tchar\t\t\t**listCopy;\n\tchar\t\t\t*list[MAX_FOUND_FILES];\n\tsearchpath_t\t*search;\n\tint\t\t\t\ti;\n\tint\t\t\t\tpathLength;\n\tint\t\t\t\textensionLength;\n\tint\t\t\t\tlength, pathDepth, temp;\n\tpack_t\t\t\t*pak;\n\tfileInPack_t\t*buildBuffer;\n\tchar\t\t\tzpath[MAX_ZPATH];\n\n\tif ( !fs_searchpaths ) {\n\t\tCom_Error( ERR_FATAL, \"Filesystem call made without initialization\\n\" );\n\t}\n\n\tif ( !path ) {\n\t\t*numfiles = 0;\n\t\treturn NULL;\n\t}\n\tif ( !extension ) {\n\t\textension = \"\";\n\t}\n\n\tpathLength = strlen( path );\n\tif ( path[pathLength-1] == '\\\\' || path[pathLength-1] == '/' ) {\n\t\tpathLength--;\n\t}\n\textensionLength = strlen( extension );\n\tnfiles = 0;\n\tFS_ReturnPath(path, zpath, &pathDepth);\n\n\t//\n\t// search through the path, one element at a time, adding to list\n\t//\n\tfor (search = fs_searchpaths ; search ; search = search->next) {\n\t\t// is the element a pak file?\n\t\tif (search->pack) {\n\n\t\t\t//ZOID:  If we are pure, don't search for files on paks that\n\t\t\t// aren't on the pure list\n\t\t\tif ( !FS_PakIsPure(search->pack) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// look through all the pak file elements\n\t\t\tpak = search->pack;\n\t\t\tbuildBuffer = pak->buildBuffer;\n\t\t\tfor (i = 0; i < pak->numfiles; i++) {\n\t\t\t\tchar\t*name;\n\t\t\t\tint\t\tzpathLen, depth;\n\n\t\t\t\t// check for directory match\n\t\t\t\tname = buildBuffer[i].name;\n\t\t\t\t//\n\t\t\t\tif (filter) {\n\t\t\t\t\t// case insensitive\n\t\t\t\t\tif (!Com_FilterPath( filter, name, qfalse ))\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t// unique the match\n\t\t\t\t\tnfiles = FS_AddFileToList( name, list, nfiles );\n\t\t\t\t}\n\t\t\t\telse {\n\n\t\t\t\t\tzpathLen = FS_ReturnPath(name, zpath, &depth);\n\n\t\t\t\t\tif ( (depth-pathDepth)>2 || pathLength > zpathLen || Q_stricmpn( name, path, pathLength ) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\t// check for extension match\n\t\t\t\t\tlength = strlen( name );\n\t\t\t\t\tif ( length < extensionLength ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( Q_stricmp( name + length - extensionLength, extension ) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t// unique the match\n\n\t\t\t\t\ttemp = pathLength;\n\t\t\t\t\tif (pathLength) {\n\t\t\t\t\t\ttemp++;\t\t// include the '/'\n\t\t\t\t\t}\n\t\t\t\t\tnfiles = FS_AddFileToList( name + temp, list, nfiles );\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (search->dir) { // scan for files in the filesystem\n\t\t\tchar\t*netpath;\n\t\t\tint\t\tnumSysFiles;\n\t\t\tchar\t**sysFiles;\n\t\t\tchar\t*name;\n\n\t\t\t// don't scan directories for files if we are pure or restricted\n\t\t\tif ( fs_restrict->integer || fs_numServerPaks ) {\n\t\t        continue;\n\t\t    } else {\n\t\t\t\tnetpath = FS_BuildOSPath( search->dir->path, search->dir->gamedir, path );\n\t\t\t\tsysFiles = Sys_ListFiles( netpath, extension, filter, &numSysFiles, qfalse );\n\t\t\t\tfor ( i = 0 ; i < numSysFiles ; i++ ) {\n\t\t\t\t\t// unique the match\n\t\t\t\t\tname = sysFiles[i];\n\t\t\t\t\tnfiles = FS_AddFileToList( name, list, nfiles );\n\t\t\t\t}\n\t\t\t\tSys_FreeFileList( sysFiles );\n\t\t\t}\n\t\t}\t\t\n\t}\n\n\t// return a copy of the list\n\t*numfiles = nfiles;\n\n\tif ( !nfiles ) {\n\t\treturn NULL;\n\t}\n\n\tlistCopy = Z_Malloc( ( nfiles + 1 ) * sizeof( *listCopy ) );\n\tfor ( i = 0 ; i < nfiles ; i++ ) {\n\t\tlistCopy[i] = list[i];\n\t}\n\tlistCopy[i] = NULL;\n\n\treturn listCopy;\n}\n\n/*\n=================\nFS_ListFiles\n=================\n*/\nchar **FS_ListFiles( const char *path, const char *extension, int *numfiles ) {\n\treturn FS_ListFilteredFiles( path, extension, NULL, numfiles );\n}\n\n/*\n=================\nFS_FreeFileList\n=================\n*/\nvoid FS_FreeFileList( char **list ) {\n\tint\t\ti;\n\n\tif ( !fs_searchpaths ) {\n\t\tCom_Error( ERR_FATAL, \"Filesystem call made without initialization\\n\" );\n\t}\n\n\tif ( !list ) {\n\t\treturn;\n\t}\n\n\tfor ( i = 0 ; list[i] ; i++ ) {\n\t\tZ_Free( list[i] );\n\t}\n\n\tZ_Free( list );\n}\n\n\n/*\n================\nFS_GetFileList\n================\n*/\nint\tFS_GetFileList(  const char *path, const char *extension, char *listbuf, int bufsize ) {\n\tint\t\tnFiles, i, nTotal, nLen;\n\tchar **pFiles = NULL;\n\n\t*listbuf = 0;\n\tnFiles = 0;\n\tnTotal = 0;\n\n\tif (Q_stricmp(path, \"$modlist\") == 0) {\n\t\treturn FS_GetModList(listbuf, bufsize);\n\t}\n\n\tpFiles = FS_ListFiles(path, extension, &nFiles);\n\n\tfor (i =0; i < nFiles; i++) {\n\t\tnLen = strlen(pFiles[i]) + 1;\n\t\tif (nTotal + nLen + 1 < bufsize) {\n\t\t\tstrcpy(listbuf, pFiles[i]);\n\t\t\tlistbuf += nLen;\n\t\t\tnTotal += nLen;\n\t\t}\n\t\telse {\n\t\t\tnFiles = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tFS_FreeFileList(pFiles);\n\n\treturn nFiles;\n}\n\n/*\n=======================\nSys_ConcatenateFileLists\n\nmkv: Naive implementation. Concatenates three lists into a\n     new list, and frees the old lists from the heap.\nbk001129 - from cvs1.17 (mkv)\n\nFIXME TTimo those two should move to common.c next to Sys_ListFiles\n=======================\n */\nstatic unsigned int Sys_CountFileList(char **list)\n{\n  int i = 0;\n\n  if (list)\n  {\n    while (*list)\n    {\n      list++;\n      i++;\n    }\n  }\n  return i;\n}\n\nstatic char** Sys_ConcatenateFileLists( char **list0, char **list1, char **list2 )\n{\n  int totalLength = 0;\n  char** cat = NULL, **dst, **src;\n\n  totalLength += Sys_CountFileList(list0);\n  totalLength += Sys_CountFileList(list1);\n  totalLength += Sys_CountFileList(list2);\n\n  /* Create new list. */\n  dst = cat = Z_Malloc( ( totalLength + 1 ) * sizeof( char* ) );\n\n  /* Copy over lists. */\n  if (list0)\n  {\n    for (src = list0; *src; src++, dst++)\n      *dst = *src;\n  }\n  if (list1)\n  {\n    for (src = list1; *src; src++, dst++)\n      *dst = *src;\n  }\n  if (list2)\n  {\n    for (src = list2; *src; src++, dst++)\n      *dst = *src;\n  }\n\n  // Terminate the list\n  *dst = NULL;\n\n  // Free our old lists.\n  // NOTE: not freeing their content, it's been merged in dst and still being used\n  if (list0) Z_Free( list0 );\n  if (list1) Z_Free( list1 );\n  if (list2) Z_Free( list2 );\n\n  return cat;\n}\n\n/*\n================\nFS_GetModList\n\nReturns a list of mod directory names\nA mod directory is a peer to baseq3 with a pk3 in it\nThe directories are searched in base path, cd path and home path\n================\n*/\nint\tFS_GetModList( char *listbuf, int bufsize ) {\n  int\t\tnMods, i, j, nTotal, nLen, nPaks, nPotential, nDescLen;\n  char **pFiles = NULL;\n  char **pPaks = NULL;\n  char *name, *path;\n  char descPath[MAX_OSPATH];\n  fileHandle_t descHandle;\n\n  int dummy;\n  char **pFiles0 = NULL;\n  char **pFiles1 = NULL;\n  char **pFiles2 = NULL;\n  qboolean bDrop = qfalse;\n\n  *listbuf = 0;\n  nMods = nPotential = nTotal = 0;\n\n  pFiles0 = Sys_ListFiles( fs_homepath->string, NULL, NULL, &dummy, qtrue );\n  pFiles1 = Sys_ListFiles( fs_basepath->string, NULL, NULL, &dummy, qtrue );\n  pFiles2 = Sys_ListFiles( fs_cdpath->string, NULL, NULL, &dummy, qtrue );\n  // we searched for mods in the three paths\n  // it is likely that we have duplicate names now, which we will cleanup below\n  pFiles = Sys_ConcatenateFileLists( pFiles0, pFiles1, pFiles2 );\n  nPotential = Sys_CountFileList(pFiles);\n\n  for ( i = 0 ; i < nPotential ; i++ ) {\n    name = pFiles[i];\n    // NOTE: cleaner would involve more changes\n    // ignore duplicate mod directories\n    if (i!=0) {\n      bDrop = qfalse;\n      for(j=0; j<i; j++)\n      {\n        if (Q_stricmp(pFiles[j],name)==0) {\n          // this one can be dropped\n          bDrop = qtrue;\n          break;\n        }\n      }\n    }\n    if (bDrop) {\n      continue;\n    }\n    // we drop \"baseq3\" \".\" and \"..\"\n    if (Q_stricmp(name, \"baseq3\") && Q_stricmpn(name, \".\", 1)) {\n      // now we need to find some .pk3 files to validate the mod\n      // NOTE TTimo: (actually I'm not sure why .. what if it's a mod under developement with no .pk3?)\n      // we didn't keep the information when we merged the directory names, as to what OS Path it was found under\n      //   so it could be in base path, cd path or home path\n      //   we will try each three of them here (yes, it's a bit messy)\n      path = FS_BuildOSPath( fs_basepath->string, name, \"\" );\n      nPaks = 0;\n      pPaks = Sys_ListFiles(path, \".pk3\", NULL, &nPaks, qfalse); \n      Sys_FreeFileList( pPaks ); // we only use Sys_ListFiles to check wether .pk3 files are present\n\n      /* Try on cd path */\n      if( nPaks <= 0 ) {\n        path = FS_BuildOSPath( fs_cdpath->string, name, \"\" );\n        nPaks = 0;\n        pPaks = Sys_ListFiles( path, \".pk3\", NULL, &nPaks, qfalse );\n        Sys_FreeFileList( pPaks );\n      }\n\n      /* try on home path */\n      if ( nPaks <= 0 )\n      {\n        path = FS_BuildOSPath( fs_homepath->string, name, \"\" );\n        nPaks = 0;\n        pPaks = Sys_ListFiles( path, \".pk3\", NULL, &nPaks, qfalse );\n        Sys_FreeFileList( pPaks );\n      }\n\n      if (nPaks > 0) {\n        nLen = strlen(name) + 1;\n        // nLen is the length of the mod path\n        // we need to see if there is a description available\n        descPath[0] = '\\0';\n        strcpy(descPath, name);\n        strcat(descPath, \"/description.txt\");\n        nDescLen = FS_SV_FOpenFileRead( descPath, &descHandle );\n        if ( nDescLen > 0 && descHandle) {\n          FILE *file;\n          file = FS_FileForHandle(descHandle);\n          Com_Memset( descPath, 0, sizeof( descPath ) );\n          nDescLen = fread(descPath, 1, 48, file);\n          if (nDescLen >= 0) {\n            descPath[nDescLen] = '\\0';\n          }\n          FS_FCloseFile(descHandle);\n        } else {\n          strcpy(descPath, name);\n        }\n        nDescLen = strlen(descPath) + 1;\n\n        if (nTotal + nLen + 1 + nDescLen + 1 < bufsize) {\n          strcpy(listbuf, name);\n          listbuf += nLen;\n          strcpy(listbuf, descPath);\n          listbuf += nDescLen;\n          nTotal += nLen + nDescLen;\n          nMods++;\n        }\n        else {\n          break;\n        }\n      }\n    }\n  }\n  Sys_FreeFileList( pFiles );\n\n  return nMods;\n}\n\n\n\n\n//============================================================================\n\n/*\n================\nFS_Dir_f\n================\n*/\nvoid FS_Dir_f( void ) {\n\tchar\t*path;\n\tchar\t*extension;\n\tchar\t**dirnames;\n\tint\t\tndirs;\n\tint\t\ti;\n\n\tif ( Cmd_Argc() < 2 || Cmd_Argc() > 3 ) {\n\t\tCom_Printf( \"usage: dir <directory> [extension]\\n\" );\n\t\treturn;\n\t}\n\n\tif ( Cmd_Argc() == 2 ) {\n\t\tpath = Cmd_Argv( 1 );\n\t\textension = \"\";\n\t} else {\n\t\tpath = Cmd_Argv( 1 );\n\t\textension = Cmd_Argv( 2 );\n\t}\n\n\tCom_Printf( \"Directory of %s %s\\n\", path, extension );\n\tCom_Printf( \"---------------\\n\" );\n\n\tdirnames = FS_ListFiles( path, extension, &ndirs );\n\n\tfor ( i = 0; i < ndirs; i++ ) {\n\t\tCom_Printf( \"%s\\n\", dirnames[i] );\n\t}\n\tFS_FreeFileList( dirnames );\n}\n\n/*\n===========\nFS_ConvertPath\n===========\n*/\nvoid FS_ConvertPath( char *s ) {\n\twhile (*s) {\n\t\tif ( *s == '\\\\' || *s == ':' ) {\n\t\t\t*s = '/';\n\t\t}\n\t\ts++;\n\t}\n}\n\n/*\n===========\nFS_PathCmp\n\nIgnore case and seprator char distinctions\n===========\n*/\nint FS_PathCmp( const char *s1, const char *s2 ) {\n\tint\t\tc1, c2;\n\t\n\tdo {\n\t\tc1 = *s1++;\n\t\tc2 = *s2++;\n\n\t\tif (c1 >= 'a' && c1 <= 'z') {\n\t\t\tc1 -= ('a' - 'A');\n\t\t}\n\t\tif (c2 >= 'a' && c2 <= 'z') {\n\t\t\tc2 -= ('a' - 'A');\n\t\t}\n\n\t\tif ( c1 == '\\\\' || c1 == ':' ) {\n\t\t\tc1 = '/';\n\t\t}\n\t\tif ( c2 == '\\\\' || c2 == ':' ) {\n\t\t\tc2 = '/';\n\t\t}\n\t\t\n\t\tif (c1 < c2) {\n\t\t\treturn -1;\t\t// strings not equal\n\t\t}\n\t\tif (c1 > c2) {\n\t\t\treturn 1;\n\t\t}\n\t} while (c1);\n\t\n\treturn 0;\t\t// strings are equal\n}\n\n/*\n================\nFS_SortFileList\n================\n*/\nvoid FS_SortFileList(char **filelist, int numfiles) {\n\tint i, j, k, numsortedfiles;\n\tchar **sortedlist;\n\n\tsortedlist = Z_Malloc( ( numfiles + 1 ) * sizeof( *sortedlist ) );\n\tsortedlist[0] = NULL;\n\tnumsortedfiles = 0;\n\tfor (i = 0; i < numfiles; i++) {\n\t\tfor (j = 0; j < numsortedfiles; j++) {\n\t\t\tif (FS_PathCmp(filelist[i], sortedlist[j]) < 0) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tfor (k = numsortedfiles; k > j; k--) {\n\t\t\tsortedlist[k] = sortedlist[k-1];\n\t\t}\n\t\tsortedlist[j] = filelist[i];\n\t\tnumsortedfiles++;\n\t}\n\tCom_Memcpy(filelist, sortedlist, numfiles * sizeof( *filelist ) );\n\tZ_Free(sortedlist);\n}\n\n/*\n================\nFS_NewDir_f\n================\n*/\nvoid FS_NewDir_f( void ) {\n\tchar\t*filter;\n\tchar\t**dirnames;\n\tint\t\tndirs;\n\tint\t\ti;\n\n\tif ( Cmd_Argc() < 2 ) {\n\t\tCom_Printf( \"usage: fdir <filter>\\n\" );\n\t\tCom_Printf( \"example: fdir *q3dm*.bsp\\n\");\n\t\treturn;\n\t}\n\n\tfilter = Cmd_Argv( 1 );\n\n\tCom_Printf( \"---------------\\n\" );\n\n\tdirnames = FS_ListFilteredFiles( \"\", \"\", filter, &ndirs );\n\n\tFS_SortFileList(dirnames, ndirs);\n\n\tfor ( i = 0; i < ndirs; i++ ) {\n\t\tFS_ConvertPath(dirnames[i]);\n\t\tCom_Printf( \"%s\\n\", dirnames[i] );\n\t}\n\tCom_Printf( \"%d files listed\\n\", ndirs );\n\tFS_FreeFileList( dirnames );\n}\n\n/*\n============\nFS_Path_f\n\n============\n*/\nvoid FS_Path_f( void ) {\n\tsearchpath_t\t*s;\n\tint\t\t\t\ti;\n\n\tCom_Printf (\"Current search path:\\n\");\n\tfor (s = fs_searchpaths; s; s = s->next) {\n\t\tif (s->pack) {\n\t\t\tCom_Printf (\"%s (%i files)\\n\", s->pack->pakFilename, s->pack->numfiles);\n\t\t\tif ( fs_numServerPaks ) {\n\t\t\t\tif ( !FS_PakIsPure(s->pack) ) {\n\t\t\t\t\tCom_Printf( \"    not on the pure list\\n\" );\n\t\t\t\t} else {\n\t\t\t\t\tCom_Printf( \"    on the pure list\\n\" );\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tCom_Printf (\"%s/%s\\n\", s->dir->path, s->dir->gamedir );\n\t\t}\n\t}\n\n\n\tCom_Printf( \"\\n\" );\n\tfor ( i = 1 ; i < MAX_FILE_HANDLES ; i++ ) {\n\t\tif ( fsh[i].handleFiles.file.o ) {\n\t\t\tCom_Printf( \"handle %i: %s\\n\", i, fsh[i].name );\n\t\t}\n\t}\n}\n\n/*\n============\nFS_TouchFile_f\n\nThe only purpose of this function is to allow game script files to copy\narbitrary files furing an \"fs_copyfiles 1\" run.\n============\n*/\nvoid FS_TouchFile_f( void ) {\n\tfileHandle_t\tf;\n\n\tif ( Cmd_Argc() != 2 ) {\n\t\tCom_Printf( \"Usage: touchFile <file>\\n\" );\n\t\treturn;\n\t}\n\n\tFS_FOpenFileRead( Cmd_Argv( 1 ), &f, qfalse );\n\tif ( f ) {\n\t\tFS_FCloseFile( f );\n\t}\n}\n\n//===========================================================================\n\n\nstatic int QDECL paksort( const void *a, const void *b ) {\n\tchar\t*aa, *bb;\n\n\taa = *(char **)a;\n\tbb = *(char **)b;\n\n\treturn FS_PathCmp( aa, bb );\n}\n\n/*\n================\nFS_AddGameDirectory\n\nSets fs_gamedir, adds the directory to the head of the path,\nthen loads the zip headers\n================\n*/\n#define\tMAX_PAKFILES\t1024\nstatic void FS_AddGameDirectory( const char *path, const char *dir ) {\n\tsearchpath_t\t*sp;\n\tint\t\t\t\ti;\n\tsearchpath_t\t*search;\n\tpack_t\t\t\t*pak;\n\tchar\t\t\t*pakfile;\n\tint\t\t\t\tnumfiles;\n\tchar\t\t\t**pakfiles;\n\tchar\t\t\t*sorted[MAX_PAKFILES];\n\n\t// this fixes the case where fs_basepath is the same as fs_cdpath\n\t// which happens on full installs\n\tfor ( sp = fs_searchpaths ; sp ; sp = sp->next ) {\n\t\tif ( sp->dir && !Q_stricmp(sp->dir->path, path) && !Q_stricmp(sp->dir->gamedir, dir)) {\n\t\t\treturn;\t\t\t// we've already got this one\n\t\t}\n\t}\n\t\n\tQ_strncpyz( fs_gamedir, dir, sizeof( fs_gamedir ) );\n\n\t//\n\t// add the directory to the search path\n\t//\n\tsearch = Z_Malloc (sizeof(searchpath_t));\n\tsearch->dir = Z_Malloc( sizeof( *search->dir ) );\n\n\tQ_strncpyz( search->dir->path, path, sizeof( search->dir->path ) );\n\tQ_strncpyz( search->dir->gamedir, dir, sizeof( search->dir->gamedir ) );\n\tsearch->next = fs_searchpaths;\n\tfs_searchpaths = search;\n\n\t// find all pak files in this directory\n\tpakfile = FS_BuildOSPath( path, dir, \"\" );\n\tpakfile[ strlen(pakfile) - 1 ] = 0;\t// strip the trailing slash\n\n\tpakfiles = Sys_ListFiles( pakfile, \".pk3\", NULL, &numfiles, qfalse );\n\n\t// sort them so that later alphabetic matches override\n\t// earlier ones.  This makes pak1.pk3 override pak0.pk3\n\tif ( numfiles > MAX_PAKFILES ) {\n\t\tnumfiles = MAX_PAKFILES;\n\t}\n\tfor ( i = 0 ; i < numfiles ; i++ ) {\n\t\tsorted[i] = pakfiles[i];\n\t}\n\n\tqsort( sorted, numfiles, 4, paksort );\n\n\tfor ( i = 0 ; i < numfiles ; i++ ) {\n\t\tpakfile = FS_BuildOSPath( path, dir, sorted[i] );\n\t\tif ( ( pak = FS_LoadZipFile( pakfile, sorted[i] ) ) == 0 )\n\t\t\tcontinue;\n\t\t// store the game name for downloading\n\t\tstrcpy(pak->pakGamename, dir);\n\n\t\tsearch = Z_Malloc (sizeof(searchpath_t));\n\t\tsearch->pack = pak;\n\t\tsearch->next = fs_searchpaths;\n\t\tfs_searchpaths = search;\n\t}\n\n\t// done\n\tSys_FreeFileList( pakfiles );\n}\n\n/*\n================\nFS_idPak\n================\n*/\nqboolean FS_idPak( char *pak, char *base ) {\n\tint i;\n\n\tfor (i = 0; i < NUM_ID_PAKS; i++) {\n\t\tif ( !FS_FilenameCompare(pak, va(\"%s/pak%d\", base, i)) ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (i < NUM_ID_PAKS) {\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n================\nFS_ComparePaks\n\n----------------\ndlstring == qtrue\n\nReturns a list of pak files that we should download from the server. They all get stored\nin the current gamedir and an FS_Restart will be fired up after we download them all.\n\nThe string is the format:\n\n@remotename@localname [repeat]\n\nstatic int\t\tfs_numServerReferencedPaks;\nstatic int\t\tfs_serverReferencedPaks[MAX_SEARCH_PATHS];\nstatic char\t\t*fs_serverReferencedPakNames[MAX_SEARCH_PATHS];\n\n----------------\ndlstring == qfalse\n\nwe are not interested in a download string format, we want something human-readable\n(this is used for diagnostics while connecting to a pure server)\n\n================\n*/\nqboolean FS_ComparePaks( char *neededpaks, int len, qboolean dlstring ) {\n\tsearchpath_t\t*sp;\n\tqboolean havepak, badchecksum;\n\tint i;\n\n\tif ( !fs_numServerReferencedPaks ) {\n\t\treturn qfalse; // Server didn't send any pack information along\n\t}\n\n\t*neededpaks = 0;\n\n\tfor ( i = 0 ; i < fs_numServerReferencedPaks ; i++ ) {\n\t\t// Ok, see if we have this pak file\n\t\tbadchecksum = qfalse;\n\t\thavepak = qfalse;\n\n\t\t// never autodownload any of the id paks\n\t\tif ( FS_idPak(fs_serverReferencedPakNames[i], \"baseq3\") || FS_idPak(fs_serverReferencedPakNames[i], \"missionpack\") ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor ( sp = fs_searchpaths ; sp ; sp = sp->next ) {\n\t\t\tif ( sp->pack && sp->pack->checksum == fs_serverReferencedPaks[i] ) {\n\t\t\t\thavepak = qtrue; // This is it!\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif ( !havepak && fs_serverReferencedPakNames[i] && *fs_serverReferencedPakNames[i] ) { \n\t\t\t// Don't got it\n\n      if (dlstring)\n      {\n        // Remote name\n        Q_strcat( neededpaks, len, \"@\");\n        Q_strcat( neededpaks, len, fs_serverReferencedPakNames[i] );\n        Q_strcat( neededpaks, len, \".pk3\" );\n\n        // Local name\n        Q_strcat( neededpaks, len, \"@\");\n        // Do we have one with the same name?\n        if ( FS_SV_FileExists( va( \"%s.pk3\", fs_serverReferencedPakNames[i] ) ) )\n        {\n          char st[MAX_ZPATH];\n          // We already have one called this, we need to download it to another name\n          // Make something up with the checksum in it\n          Com_sprintf( st, sizeof( st ), \"%s.%08x.pk3\", fs_serverReferencedPakNames[i], fs_serverReferencedPaks[i] );\n          Q_strcat( neededpaks, len, st );\n        } else\n        {\n          Q_strcat( neededpaks, len, fs_serverReferencedPakNames[i] );\n          Q_strcat( neededpaks, len, \".pk3\" );\n        }\n      }\n      else\n      {\n        Q_strcat( neededpaks, len, fs_serverReferencedPakNames[i] );\n\t\t\t  Q_strcat( neededpaks, len, \".pk3\" );\n        // Do we have one with the same name?\n        if ( FS_SV_FileExists( va( \"%s.pk3\", fs_serverReferencedPakNames[i] ) ) )\n        {\n          Q_strcat( neededpaks, len, \" (local file exists with wrong checksum)\");\n        }\n        Q_strcat( neededpaks, len, \"\\n\");\n      }\n\t\t}\n\t}\n\n\tif ( *neededpaks ) {\n\t\treturn qtrue;\n\t}\n\n\treturn qfalse; // We have them all\n}\n\n/*\n================\nFS_Shutdown\n\nFrees all resources and closes all files\n================\n*/\nvoid FS_Shutdown( qboolean closemfp ) {\n\tsearchpath_t\t*p, *next;\n\tint\ti;\n\n\tfor(i = 0; i < MAX_FILE_HANDLES; i++) {\n\t\tif (fsh[i].fileSize) {\n\t\t\tFS_FCloseFile(i);\n\t\t}\n\t}\n\n\t// free everything\n\tfor ( p = fs_searchpaths ; p ; p = next ) {\n\t\tnext = p->next;\n\n\t\tif ( p->pack ) {\n\t\t\tunzClose(p->pack->handle);\n\t\t\tZ_Free( p->pack->buildBuffer );\n\t\t\tZ_Free( p->pack );\n\t\t}\n\t\tif ( p->dir ) {\n\t\t\tZ_Free( p->dir );\n\t\t}\n\t\tZ_Free( p );\n\t}\n\n\t// any FS_ calls will now be an error until reinitialized\n\tfs_searchpaths = NULL;\n\n\tCmd_RemoveCommand( \"path\" );\n\tCmd_RemoveCommand( \"dir\" );\n\tCmd_RemoveCommand( \"fdir\" );\n\tCmd_RemoveCommand( \"touchFile\" );\n\n#ifdef FS_MISSING\n\tif (closemfp) {\n\t\tfclose(missingFiles);\n\t}\n#endif\n}\n\nvoid Com_AppendCDKey( const char *filename );\nvoid Com_ReadCDKey( const char *filename );\n \n/*\n================\nFS_ReorderPurePaks\nNOTE TTimo: the reordering that happens here is not reflected in the cvars (\\cvarlist *pak*)\n  this can lead to misleading situations, see https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=540\n================\n*/\nstatic void FS_ReorderPurePaks()\n{\n\tsearchpath_t *s;\n\tint i;\n\tsearchpath_t **p_insert_index, // for linked list reordering\n\t\t**p_previous; // when doing the scan\n\t\n\t// only relevant when connected to pure server\n\tif ( !fs_numServerPaks )\n\t\treturn;\n\t\n\tfs_reordered = qfalse;\n\t\n\tp_insert_index = &fs_searchpaths; // we insert in order at the beginning of the list \n\tfor ( i = 0 ; i < fs_numServerPaks ; i++ ) {\n\t\tp_previous = p_insert_index; // track the pointer-to-current-item\n\t\tfor (s = *p_insert_index; s; s = s->next) {\n\t\t\t// the part of the list before p_insert_index has been sorted already\n\t\t\tif (s->pack && fs_serverPaks[i] == s->pack->checksum) {\n\t\t\t\tfs_reordered = qtrue;\n\t\t\t\t// move this element to the insert list\n\t\t\t\t*p_previous = s->next;\n\t\t\t\ts->next = *p_insert_index;\n\t\t\t\t*p_insert_index = s;\n\t\t\t\t// increment insert list\n\t\t\t\tp_insert_index = &s->next;\n\t\t\t\tbreak; // iterate to next server pack\n\t\t\t}\n\t\t\tp_previous = &s->next; \n\t\t}\n\t}\n}\n\n/*\n================\nFS_Startup\n================\n*/\nstatic void FS_Startup( const char *gameName ) {\n        const char *homePath;\n\tcvar_t\t*fs;\n\n\tCom_Printf( \"----- FS_Startup -----\\n\" );\n\n\tfs_debug = Cvar_Get( \"fs_debug\", \"0\", 0 );\n\tfs_copyfiles = Cvar_Get( \"fs_copyfiles\", \"0\", CVAR_INIT );\n\tfs_cdpath = Cvar_Get (\"fs_cdpath\", Sys_DefaultCDPath(), CVAR_INIT );\n\tfs_basepath = Cvar_Get (\"fs_basepath\", Sys_DefaultInstallPath(), CVAR_INIT );\n\tfs_basegame = Cvar_Get (\"fs_basegame\", \"\", CVAR_INIT );\n  homePath = Sys_DefaultHomePath();\n  if (!homePath || !homePath[0]) {\n\t\thomePath = fs_basepath->string;\n\t}\n\tfs_homepath = Cvar_Get (\"fs_homepath\", homePath, CVAR_INIT );\n\tfs_gamedirvar = Cvar_Get (\"fs_game\", \"\", CVAR_INIT|CVAR_SYSTEMINFO );\n\tfs_restrict = Cvar_Get (\"fs_restrict\", \"\", CVAR_INIT );\n\n\t// add search path elements in reverse priority order\n\tif (fs_cdpath->string[0]) {\n\t\tFS_AddGameDirectory( fs_cdpath->string, gameName );\n\t}\n\tif (fs_basepath->string[0]) {\n\t\tFS_AddGameDirectory( fs_basepath->string, gameName );\n\t}\n  // fs_homepath is somewhat particular to *nix systems, only add if relevant\n  // NOTE: same filtering below for mods and basegame\n\tif (fs_basepath->string[0] && Q_stricmp(fs_homepath->string,fs_basepath->string)) {\n\t\tFS_AddGameDirectory ( fs_homepath->string, gameName );\n\t}\n        \n\t// check for additional base game so mods can be based upon other mods\n\tif ( fs_basegame->string[0] && !Q_stricmp( gameName, BASEGAME ) && Q_stricmp( fs_basegame->string, gameName ) ) {\n\t\tif (fs_cdpath->string[0]) {\n\t\t\tFS_AddGameDirectory(fs_cdpath->string, fs_basegame->string);\n\t\t}\n\t\tif (fs_basepath->string[0]) {\n\t\t\tFS_AddGameDirectory(fs_basepath->string, fs_basegame->string);\n\t\t}\n\t\tif (fs_homepath->string[0] && Q_stricmp(fs_homepath->string,fs_basepath->string)) {\n\t\t\tFS_AddGameDirectory(fs_homepath->string, fs_basegame->string);\n\t\t}\n\t}\n\n\t// check for additional game folder for mods\n\tif ( fs_gamedirvar->string[0] && !Q_stricmp( gameName, BASEGAME ) && Q_stricmp( fs_gamedirvar->string, gameName ) ) {\n\t\tif (fs_cdpath->string[0]) {\n\t\t\tFS_AddGameDirectory(fs_cdpath->string, fs_gamedirvar->string);\n\t\t}\n\t\tif (fs_basepath->string[0]) {\n\t\t\tFS_AddGameDirectory(fs_basepath->string, fs_gamedirvar->string);\n\t\t}\n\t\tif (fs_homepath->string[0] && Q_stricmp(fs_homepath->string,fs_basepath->string)) {\n\t\t\tFS_AddGameDirectory(fs_homepath->string, fs_gamedirvar->string);\n\t\t}\n\t}\n\n\tCom_ReadCDKey( \"baseq3\" );\n\tfs = Cvar_Get (\"fs_game\", \"\", CVAR_INIT|CVAR_SYSTEMINFO );\n\tif (fs && fs->string[0] != 0) {\n\t\tCom_AppendCDKey( fs->string );\n\t}\n\n\t// add our commands\n\tCmd_AddCommand (\"path\", FS_Path_f);\n\tCmd_AddCommand (\"dir\", FS_Dir_f );\n\tCmd_AddCommand (\"fdir\", FS_NewDir_f );\n\tCmd_AddCommand (\"touchFile\", FS_TouchFile_f );\n\n\t// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=506\n\t// reorder the pure pk3 files according to server order\n\tFS_ReorderPurePaks();\n\t\n\t// print the current search paths\n\tFS_Path_f();\n\n\tfs_gamedirvar->modified = qfalse; // We just loaded, it's not modified\n\n\tCom_Printf( \"----------------------\\n\" );\n\n#ifdef FS_MISSING\n\tif (missingFiles == NULL) {\n\t\tmissingFiles = fopen( \"\\\\missing.txt\", \"ab\" );\n\t}\n#endif\n\tCom_Printf( \"%d files in pk3 files\\n\", fs_packFiles );\n}\n\n\n/*\n===================\nFS_SetRestrictions\n\nLooks for product keys and restricts media add on ability\nif the full version is not found\n===================\n*/\nstatic void FS_SetRestrictions( void ) {\n\tsearchpath_t\t*path;\n\n#ifndef PRE_RELEASE_DEMO\n\tchar\t*productId;\n\n\t// if fs_restrict is set, don't even look for the id file,\n\t// which allows the demo release to be tested even if\n\t// the full game is present\n\tif ( !fs_restrict->integer ) {\n\t\t// look for the full game id\n\t\tFS_ReadFile( \"productid.txt\", (void **)&productId );\n\t\tif ( productId ) {\n\t\t\t// check against the hardcoded string\n\t\t\tint\t\tseed, i;\n\n\t\t\tseed = 5000;\n\t\t\tfor ( i = 0 ; i < sizeof( fs_scrambledProductId ) ; i++ ) {\n\t\t\t\tif ( ( fs_scrambledProductId[i] ^ (seed&255) ) != productId[i] ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tseed = (69069 * seed + 1);\n\t\t\t}\n\n\t\t\tFS_FreeFile( productId );\n\n\t\t\tif ( i == sizeof( fs_scrambledProductId ) ) {\n\t\t\t\treturn;\t// no restrictions\n\t\t\t}\n\t\t\tCom_Error( ERR_FATAL, \"Invalid product identification\" );\n\t\t}\n\t}\n#endif\n\tCvar_Set( \"fs_restrict\", \"1\" );\n\n\tCom_Printf( \"\\nRunning in restricted demo mode.\\n\\n\" );\n\n\t// restart the filesystem with just the demo directory\n\tFS_Shutdown(qfalse);\n\tFS_Startup( DEMOGAME );\n\n\t// make sure that the pak file has the header checksum we expect\n\tfor ( path = fs_searchpaths ; path ; path = path->next ) {\n\t\tif ( path->pack ) {\n\t\t\t// a tiny attempt to keep the checksum from being scannable from the exe\n\t\t\tif ( (path->pack->checksum ^ 0x02261994u) != (DEMO_PAK_CHECKSUM ^ 0x02261994u) ) {\n\t\t\t\tCom_Error( ERR_FATAL, \"Corrupted pak0.pk3: %u\", path->pack->checksum );\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n=====================\nFS_GamePureChecksum\n\nReturns the checksum of the pk3 from which the server loaded the qagame.qvm\n=====================\n*/\nconst char *FS_GamePureChecksum( void ) {\n\tstatic char\tinfo[MAX_STRING_TOKENS];\n\tsearchpath_t *search;\n\n\tinfo[0] = 0;\n\n\tfor ( search = fs_searchpaths ; search ; search = search->next ) {\n\t\t// is the element a pak file?\n\t\tif ( search->pack ) {\n\t\t\tif (search->pack->referenced & FS_QAGAME_REF) {\n\t\t\t\tCom_sprintf(info, sizeof(info), \"%d\", search->pack->checksum);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn info;\n}\n\n/*\n=====================\nFS_LoadedPakChecksums\n\nReturns a space separated string containing the checksums of all loaded pk3 files.\nServers with sv_pure set will get this string and pass it to clients.\n=====================\n*/\nconst char *FS_LoadedPakChecksums( void ) {\n\tstatic char\tinfo[BIG_INFO_STRING];\n\tsearchpath_t\t*search;\n\n\tinfo[0] = 0;\n\n\tfor ( search = fs_searchpaths ; search ; search = search->next ) {\n\t\t// is the element a pak file? \n\t\tif ( !search->pack ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tQ_strcat( info, sizeof( info ), va(\"%i \", search->pack->checksum ) );\n\t}\n\n\treturn info;\n}\n\n/*\n=====================\nFS_LoadedPakNames\n\nReturns a space separated string containing the names of all loaded pk3 files.\nServers with sv_pure set will get this string and pass it to clients.\n=====================\n*/\nconst char *FS_LoadedPakNames( void ) {\n\tstatic char\tinfo[BIG_INFO_STRING];\n\tsearchpath_t\t*search;\n\n\tinfo[0] = 0;\n\n\tfor ( search = fs_searchpaths ; search ; search = search->next ) {\n\t\t// is the element a pak file?\n\t\tif ( !search->pack ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (*info) {\n\t\t\tQ_strcat(info, sizeof( info ), \" \" );\n\t\t}\n\t\tQ_strcat( info, sizeof( info ), search->pack->pakBasename );\n\t}\n\n\treturn info;\n}\n\n/*\n=====================\nFS_LoadedPakPureChecksums\n\nReturns a space separated string containing the pure checksums of all loaded pk3 files.\nServers with sv_pure use these checksums to compare with the checksums the clients send\nback to the server.\n=====================\n*/\nconst char *FS_LoadedPakPureChecksums( void ) {\n\tstatic char\tinfo[BIG_INFO_STRING];\n\tsearchpath_t\t*search;\n\n\tinfo[0] = 0;\n\n\tfor ( search = fs_searchpaths ; search ; search = search->next ) {\n\t\t// is the element a pak file? \n\t\tif ( !search->pack ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tQ_strcat( info, sizeof( info ), va(\"%i \", search->pack->pure_checksum ) );\n\t}\n\n\treturn info;\n}\n\n/*\n=====================\nFS_ReferencedPakChecksums\n\nReturns a space separated string containing the checksums of all referenced pk3 files.\nThe server will send this to the clients so they can check which files should be auto-downloaded. \n=====================\n*/\nconst char *FS_ReferencedPakChecksums( void ) {\n\tstatic char\tinfo[BIG_INFO_STRING];\n\tsearchpath_t *search;\n\n\tinfo[0] = 0;\n\n\n\tfor ( search = fs_searchpaths ; search ; search = search->next ) {\n\t\t// is the element a pak file?\n\t\tif ( search->pack ) {\n\t\t\tif (search->pack->referenced || Q_stricmpn(search->pack->pakGamename, BASEGAME, strlen(BASEGAME))) {\n\t\t\t\tQ_strcat( info, sizeof( info ), va(\"%i \", search->pack->checksum ) );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn info;\n}\n\n/*\n=====================\nFS_ReferencedPakPureChecksums\n\nReturns a space separated string containing the pure checksums of all referenced pk3 files.\nServers with sv_pure set will get this string back from clients for pure validation \n\nThe string has a specific order, \"cgame ui @ ref1 ref2 ref3 ...\"\n=====================\n*/\nconst char *FS_ReferencedPakPureChecksums( void ) {\n\tstatic char\tinfo[BIG_INFO_STRING];\n\tsearchpath_t\t*search;\n\tint nFlags, numPaks, checksum;\n\n\tinfo[0] = 0;\n\n\tchecksum = fs_checksumFeed;\n\tnumPaks = 0;\n\tfor (nFlags = FS_CGAME_REF; nFlags; nFlags = nFlags >> 1) {\n\t\tif (nFlags & FS_GENERAL_REF) {\n\t\t\t// add a delimter between must haves and general refs\n\t\t\t//Q_strcat(info, sizeof(info), \"@ \");\n\t\t\tinfo[strlen(info)+1] = '\\0';\n\t\t\tinfo[strlen(info)+2] = '\\0';\n\t\t\tinfo[strlen(info)] = '@';\n\t\t\tinfo[strlen(info)] = ' ';\n\t\t}\n\t\tfor ( search = fs_searchpaths ; search ; search = search->next ) {\n\t\t\t// is the element a pak file and has it been referenced based on flag?\n\t\t\tif ( search->pack && (search->pack->referenced & nFlags)) {\n\t\t\t\tQ_strcat( info, sizeof( info ), va(\"%i \", search->pack->pure_checksum ) );\n\t\t\t\tif (nFlags & (FS_CGAME_REF | FS_UI_REF)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tchecksum ^= search->pack->pure_checksum;\n\t\t\t\tnumPaks++;\n\t\t\t}\n\t\t}\n\t\tif (fs_fakeChkSum != 0) {\n\t\t\t// only added if a non-pure file is referenced\n\t\t\tQ_strcat( info, sizeof( info ), va(\"%i \", fs_fakeChkSum ) );\n\t\t}\n\t}\n\t// last checksum is the encoded number of referenced pk3s\n\tchecksum ^= numPaks;\n\tQ_strcat( info, sizeof( info ), va(\"%i \", checksum ) );\n\n\treturn info;\n}\n\n/*\n=====================\nFS_ReferencedPakNames\n\nReturns a space separated string containing the names of all referenced pk3 files.\nThe server will send this to the clients so they can check which files should be auto-downloaded. \n=====================\n*/\nconst char *FS_ReferencedPakNames( void ) {\n\tstatic char\tinfo[BIG_INFO_STRING];\n\tsearchpath_t\t*search;\n\n\tinfo[0] = 0;\n\n\t// we want to return ALL pk3's from the fs_game path\n\t// and referenced one's from baseq3\n\tfor ( search = fs_searchpaths ; search ; search = search->next ) {\n\t\t// is the element a pak file?\n\t\tif ( search->pack ) {\n\t\t\tif (*info) {\n\t\t\t\tQ_strcat(info, sizeof( info ), \" \" );\n\t\t\t}\n\t\t\tif (search->pack->referenced || Q_stricmpn(search->pack->pakGamename, BASEGAME, strlen(BASEGAME))) {\n\t\t\t\tQ_strcat( info, sizeof( info ), search->pack->pakGamename );\n\t\t\t\tQ_strcat( info, sizeof( info ), \"/\" );\n\t\t\t\tQ_strcat( info, sizeof( info ), search->pack->pakBasename );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn info;\n}\n\n/*\n=====================\nFS_ClearPakReferences\n=====================\n*/\nvoid FS_ClearPakReferences( int flags ) {\n\tsearchpath_t *search;\n\n\tif ( !flags ) {\n\t\tflags = -1;\n\t}\n\tfor ( search = fs_searchpaths; search; search = search->next ) {\n\t\t// is the element a pak file and has it been referenced?\n\t\tif ( search->pack ) {\n\t\t\tsearch->pack->referenced &= ~flags;\n\t\t}\n\t}\n}\n\n\n/*\n=====================\nFS_PureServerSetLoadedPaks\n\nIf the string is empty, all data sources will be allowed.\nIf not empty, only pk3 files that match one of the space\nseparated checksums will be checked for files, with the\nexception of .cfg and .dat files.\n=====================\n*/\nvoid FS_PureServerSetLoadedPaks( const char *pakSums, const char *pakNames ) {\n\tint\t\ti, c, d;\n\n\tCmd_TokenizeString( pakSums );\n\n\tc = Cmd_Argc();\n\tif ( c > MAX_SEARCH_PATHS ) {\n\t\tc = MAX_SEARCH_PATHS;\n\t}\n\n\tfs_numServerPaks = c;\n\n\tfor ( i = 0 ; i < c ; i++ ) {\n\t\tfs_serverPaks[i] = atoi( Cmd_Argv( i ) );\n\t}\n\n\tif (fs_numServerPaks) {\n\t\tCom_DPrintf( \"Connected to a pure server.\\n\" );\n\t}\n\telse\n\t{\n\t\tif (fs_reordered)\n\t\t{\n\t\t\t// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=540\n\t\t\t// force a restart to make sure the search order will be correct\n\t\t\tCom_DPrintf( \"FS search reorder is required\\n\" );\n\t\t\tFS_Restart(fs_checksumFeed);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tfor ( i = 0 ; i < c ; i++ ) {\n\t\tif (fs_serverPakNames[i]) {\n\t\t\tZ_Free(fs_serverPakNames[i]);\n\t\t}\n\t\tfs_serverPakNames[i] = NULL;\n\t}\n\tif ( pakNames && *pakNames ) {\n\t\tCmd_TokenizeString( pakNames );\n\n\t\td = Cmd_Argc();\n\t\tif ( d > MAX_SEARCH_PATHS ) {\n\t\t\td = MAX_SEARCH_PATHS;\n\t\t}\n\n\t\tfor ( i = 0 ; i < d ; i++ ) {\n\t\t\tfs_serverPakNames[i] = CopyString( Cmd_Argv( i ) );\n\t\t}\n\t}\n}\n\n/*\n=====================\nFS_PureServerSetReferencedPaks\n\nThe checksums and names of the pk3 files referenced at the server\nare sent to the client and stored here. The client will use these\nchecksums to see if any pk3 files need to be auto-downloaded. \n=====================\n*/\nvoid FS_PureServerSetReferencedPaks( const char *pakSums, const char *pakNames ) {\n\tint\t\ti, c, d;\n\n\tCmd_TokenizeString( pakSums );\n\n\tc = Cmd_Argc();\n\tif ( c > MAX_SEARCH_PATHS ) {\n\t\tc = MAX_SEARCH_PATHS;\n\t}\n\n\tfs_numServerReferencedPaks = c;\n\n\tfor ( i = 0 ; i < c ; i++ ) {\n\t\tfs_serverReferencedPaks[i] = atoi( Cmd_Argv( i ) );\n\t}\n\n\tfor ( i = 0 ; i < c ; i++ ) {\n\t\tif (fs_serverReferencedPakNames[i]) {\n\t\t\tZ_Free(fs_serverReferencedPakNames[i]);\n\t\t}\n\t\tfs_serverReferencedPakNames[i] = NULL;\n\t}\n\tif ( pakNames && *pakNames ) {\n\t\tCmd_TokenizeString( pakNames );\n\n\t\td = Cmd_Argc();\n\t\tif ( d > MAX_SEARCH_PATHS ) {\n\t\t\td = MAX_SEARCH_PATHS;\n\t\t}\n\n\t\tfor ( i = 0 ; i < d ; i++ ) {\n\t\t\tfs_serverReferencedPakNames[i] = CopyString( Cmd_Argv( i ) );\n\t\t}\n\t}\n}\n\n/*\n================\nFS_InitFilesystem\n\nCalled only at inital startup, not when the filesystem\nis resetting due to a game change\n================\n*/\nvoid FS_InitFilesystem( void ) {\n\t// allow command line parms to override our defaults\n\t// we have to specially handle this, because normal command\n\t// line variable sets don't happen until after the filesystem\n\t// has already been initialized\n\tCom_StartupVariable( \"fs_cdpath\" );\n\tCom_StartupVariable( \"fs_basepath\" );\n\tCom_StartupVariable( \"fs_homepath\" );\n\tCom_StartupVariable( \"fs_game\" );\n\tCom_StartupVariable( \"fs_copyfiles\" );\n\tCom_StartupVariable( \"fs_restrict\" );\n\n\t// try to start up normally\n\tFS_Startup( BASEGAME );\n\n\t// see if we are going to allow add-ons\n\tFS_SetRestrictions();\n\n\t// if we can't find default.cfg, assume that the paths are\n\t// busted and error out now, rather than getting an unreadable\n\t// graphics screen when the font fails to load\n\tif ( FS_ReadFile( \"default.cfg\", NULL ) <= 0 ) {\n\t\tCom_Error( ERR_FATAL, \"Couldn't load default.cfg\" );\n\t\t// bk001208 - SafeMode see below, FIXME?\n\t}\n\n\tQ_strncpyz(lastValidBase, fs_basepath->string, sizeof(lastValidBase));\n\tQ_strncpyz(lastValidGame, fs_gamedirvar->string, sizeof(lastValidGame));\n\n  // bk001208 - SafeMode see below, FIXME?\n}\n\n\n/*\n================\nFS_Restart\n================\n*/\nvoid FS_Restart( int checksumFeed ) {\n\n\t// free anything we currently have loaded\n\tFS_Shutdown(qfalse);\n\n\t// set the checksum feed\n\tfs_checksumFeed = checksumFeed;\n\n\t// clear pak references\n\tFS_ClearPakReferences(0);\n\n\t// try to start up normally\n\tFS_Startup( BASEGAME );\n\n\t// see if we are going to allow add-ons\n\tFS_SetRestrictions();\n\n\t// if we can't find default.cfg, assume that the paths are\n\t// busted and error out now, rather than getting an unreadable\n\t// graphics screen when the font fails to load\n\tif ( FS_ReadFile( \"default.cfg\", NULL ) <= 0 ) {\n\t\t// this might happen when connecting to a pure server not using BASEGAME/pak0.pk3\n\t\t// (for instance a TA demo server)\n\t\tif (lastValidBase[0]) {\n\t\t\tFS_PureServerSetLoadedPaks(\"\", \"\");\n\t\t\tCvar_Set(\"fs_basepath\", lastValidBase);\n\t\t\tCvar_Set(\"fs_gamedirvar\", lastValidGame);\n\t\t\tlastValidBase[0] = '\\0';\n\t\t\tlastValidGame[0] = '\\0';\n\t\t\tCvar_Set( \"fs_restrict\", \"0\" );\n\t\t\tFS_Restart(checksumFeed);\n\t\t\tCom_Error( ERR_DROP, \"Invalid game folder\\n\" );\n\t\t\treturn;\n\t\t}\n\t\tCom_Error( ERR_FATAL, \"Couldn't load default.cfg\" );\n\t}\n\n\t// bk010116 - new check before safeMode\n\tif ( Q_stricmp(fs_gamedirvar->string, lastValidGame) ) {\n\t\t// skip the q3config.cfg if \"safe\" is on the command line\n\t\tif ( !Com_SafeMode() ) {\n\t\t\tCbuf_AddText (\"exec q3config.cfg\\n\");\n\t\t}\n\t}\n\n\tQ_strncpyz(lastValidBase, fs_basepath->string, sizeof(lastValidBase));\n\tQ_strncpyz(lastValidGame, fs_gamedirvar->string, sizeof(lastValidGame));\n\n}\n\n/*\n=================\nFS_ConditionalRestart\nrestart if necessary\n=================\n*/\nqboolean FS_ConditionalRestart( int checksumFeed ) {\n\tif( fs_gamedirvar->modified || checksumFeed != fs_checksumFeed ) {\n\t\tFS_Restart( checksumFeed );\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n========================================================================================\n\nHandle based file calls for virtual machines\n\n========================================================================================\n*/\n\nint\t\tFS_FOpenFileByMode( const char *qpath, fileHandle_t *f, fsMode_t mode ) {\n\tint\t\tr;\n\tqboolean\tsync;\n\n\tsync = qfalse;\n\n\tswitch( mode ) {\n\tcase FS_READ:\n\t\tr = FS_FOpenFileRead( qpath, f, qtrue );\n\t\tbreak;\n\tcase FS_WRITE:\n\t\t*f = FS_FOpenFileWrite( qpath );\n\t\tr = 0;\n\t\tif (*f == 0) {\n\t\t\tr = -1;\n\t\t}\n\t\tbreak;\n\tcase FS_APPEND_SYNC:\n\t\tsync = qtrue;\n\tcase FS_APPEND:\n\t\t*f = FS_FOpenFileAppend( qpath );\n\t\tr = 0;\n\t\tif (*f == 0) {\n\t\t\tr = -1;\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tCom_Error( ERR_FATAL, \"FSH_FOpenFile: bad mode\" );\n\t\treturn -1;\n\t}\n\n\tif (!f) {\n\t\treturn r;\n\t}\n\n\tif ( *f ) {\n\t\tif (fsh[*f].zipFile == qtrue) {\n\t\t\tfsh[*f].baseOffset = unztell(fsh[*f].handleFiles.file.z);\n\t\t} else {\n\t\t\tfsh[*f].baseOffset = ftell(fsh[*f].handleFiles.file.o);\n\t\t}\n\t\tfsh[*f].fileSize = r;\n\t\tfsh[*f].streamed = qfalse;\n\n\t\tif (mode == FS_READ) {\n\t\t\tSys_BeginStreamedFile( *f, 0x4000 );\n\t\t\tfsh[*f].streamed = qtrue;\n\t\t}\n\t}\n\tfsh[*f].handleSync = sync;\n\n\treturn r;\n}\n\nint\t\tFS_FTell( fileHandle_t f ) {\n\tint pos;\n\tif (fsh[f].zipFile == qtrue) {\n\t\tpos = unztell(fsh[f].handleFiles.file.z);\n\t} else {\n\t\tpos = ftell(fsh[f].handleFiles.file.o);\n\t}\n\treturn pos;\n}\n\nvoid\tFS_Flush( fileHandle_t f ) {\n\tfflush(fsh[f].handleFiles.file.o);\n}\n\n"
  },
  {
    "path": "code/qcommon/huffman.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/* This is based on the Adaptive Huffman algorithm described in Sayood's Data\n * Compression book.  The ranks are not actually stored, but implicitly defined\n * by the location of a node within a doubly-linked list */\n\n#include \"../game/q_shared.h\"\n#include \"qcommon.h\"\n\nstatic int\t\t\tbloc = 0;\n\nvoid\tHuff_putBit( int bit, byte *fout, int *offset) {\n\tbloc = *offset;\n\tif ((bloc&7) == 0) {\n\t\tfout[(bloc>>3)] = 0;\n\t}\n\tfout[(bloc>>3)] |= bit << (bloc&7);\n\tbloc++;\n\t*offset = bloc;\n}\n\nint\t\tHuff_getBit( byte *fin, int *offset) {\n\tint t;\n\tbloc = *offset;\n\tt = (fin[(bloc>>3)] >> (bloc&7)) & 0x1;\n\tbloc++;\n\t*offset = bloc;\n\treturn t;\n}\n\n/* Add a bit to the output file (buffered) */\nstatic void add_bit (char bit, byte *fout) {\n\tif ((bloc&7) == 0) {\n\t\tfout[(bloc>>3)] = 0;\n\t}\n\tfout[(bloc>>3)] |= bit << (bloc&7);\n\tbloc++;\n}\n\n/* Receive one bit from the input file (buffered) */\nstatic int get_bit (byte *fin) {\n\tint t;\n\tt = (fin[(bloc>>3)] >> (bloc&7)) & 0x1;\n\tbloc++;\n\treturn t;\n}\n\nstatic node_t **get_ppnode(huff_t* huff) {\n\tnode_t **tppnode;\n\tif (!huff->freelist) {\n\t\treturn &(huff->nodePtrs[huff->blocPtrs++]);\n\t} else {\n\t\ttppnode = huff->freelist;\n\t\thuff->freelist = (node_t **)*tppnode;\n\t\treturn tppnode;\n\t}\n}\n\nstatic void free_ppnode(huff_t* huff, node_t **ppnode) {\n\t*ppnode = (node_t *)huff->freelist;\n\thuff->freelist = ppnode;\n}\n\n/* Swap the location of these two nodes in the tree */\nstatic void swap (huff_t* huff, node_t *node1, node_t *node2) { \n\tnode_t *par1, *par2;\n\n\tpar1 = node1->parent;\n\tpar2 = node2->parent;\n\n\tif (par1) {\n\t\tif (par1->left == node1) {\n\t\t\tpar1->left = node2;\n\t\t} else {\n\t      par1->right = node2;\n\t\t}\n\t} else {\n\t\thuff->tree = node2;\n\t}\n\n\tif (par2) {\n\t\tif (par2->left == node2) {\n\t\t\tpar2->left = node1;\n\t\t} else {\n\t\t\tpar2->right = node1;\n\t\t}\n\t} else {\n\t\thuff->tree = node1;\n\t}\n  \n\tnode1->parent = par2;\n\tnode2->parent = par1;\n}\n\n/* Swap these two nodes in the linked list (update ranks) */\nstatic void swaplist(node_t *node1, node_t *node2) {\n\tnode_t *par1;\n\n\tpar1 = node1->next;\n\tnode1->next = node2->next;\n\tnode2->next = par1;\n\n\tpar1 = node1->prev;\n\tnode1->prev = node2->prev;\n\tnode2->prev = par1;\n\n\tif (node1->next == node1) {\n\t\tnode1->next = node2;\n\t}\n\tif (node2->next == node2) {\n\t\tnode2->next = node1;\n\t}\n\tif (node1->next) {\n\t\tnode1->next->prev = node1;\n\t}\n\tif (node2->next) {\n\t\tnode2->next->prev = node2;\n\t}\n\tif (node1->prev) {\n\t\tnode1->prev->next = node1;\n\t}\n\tif (node2->prev) {\n\t\tnode2->prev->next = node2;\n\t}\n}\n\n/* Do the increments */\nstatic void increment(huff_t* huff, node_t *node) {\n\tnode_t *lnode;\n\n\tif (!node) {\n\t\treturn;\n\t}\n\n\tif (node->next != NULL && node->next->weight == node->weight) {\n\t    lnode = *node->head;\n\t\tif (lnode != node->parent) {\n\t\t\tswap(huff, lnode, node);\n\t\t}\n\t\tswaplist(lnode, node);\n\t}\n\tif (node->prev && node->prev->weight == node->weight) {\n\t\t*node->head = node->prev;\n\t} else {\n\t    *node->head = NULL;\n\t\tfree_ppnode(huff, node->head);\n\t}\n\tnode->weight++;\n\tif (node->next && node->next->weight == node->weight) {\n\t\tnode->head = node->next->head;\n\t} else { \n\t\tnode->head = get_ppnode(huff);\n\t\t*node->head = node;\n\t}\n\tif (node->parent) {\n\t\tincrement(huff, node->parent);\n\t\tif (node->prev == node->parent) {\n\t\t\tswaplist(node, node->parent);\n\t\t\tif (*node->head == node) {\n\t\t\t\t*node->head = node->parent;\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid Huff_addRef(huff_t* huff, byte ch) {\n\tnode_t *tnode, *tnode2;\n\tif (huff->loc[ch] == NULL) { /* if this is the first transmission of this node */\n\t\ttnode = &(huff->nodeList[huff->blocNode++]);\n\t\ttnode2 = &(huff->nodeList[huff->blocNode++]);\n\n\t\ttnode2->symbol = INTERNAL_NODE;\n\t\ttnode2->weight = 1;\n\t\ttnode2->next = huff->lhead->next;\n\t\tif (huff->lhead->next) {\n\t\t\thuff->lhead->next->prev = tnode2;\n\t\t\tif (huff->lhead->next->weight == 1) {\n\t\t\t\ttnode2->head = huff->lhead->next->head;\n\t\t\t} else {\n\t\t\t\ttnode2->head = get_ppnode(huff);\n\t\t\t\t*tnode2->head = tnode2;\n\t\t\t}\n\t\t} else {\n\t\t\ttnode2->head = get_ppnode(huff);\n\t\t\t*tnode2->head = tnode2;\n\t\t}\n\t\thuff->lhead->next = tnode2;\n\t\ttnode2->prev = huff->lhead;\n \n\t\ttnode->symbol = ch;\n\t\ttnode->weight = 1;\n\t\ttnode->next = huff->lhead->next;\n\t\tif (huff->lhead->next) {\n\t\t\thuff->lhead->next->prev = tnode;\n\t\t\tif (huff->lhead->next->weight == 1) {\n\t\t\t\ttnode->head = huff->lhead->next->head;\n\t\t\t} else {\n\t\t\t\t/* this should never happen */\n\t\t\t\ttnode->head = get_ppnode(huff);\n\t\t\t\t*tnode->head = tnode2;\n\t\t    }\n\t\t} else {\n\t\t\t/* this should never happen */\n\t\t\ttnode->head = get_ppnode(huff);\n\t\t\t*tnode->head = tnode;\n\t\t}\n\t\thuff->lhead->next = tnode;\n\t\ttnode->prev = huff->lhead;\n\t\ttnode->left = tnode->right = NULL;\n \n\t\tif (huff->lhead->parent) {\n\t\t\tif (huff->lhead->parent->left == huff->lhead) { /* lhead is guaranteed to by the NYT */\n\t\t\t\thuff->lhead->parent->left = tnode2;\n\t\t\t} else {\n\t\t\t\thuff->lhead->parent->right = tnode2;\n\t\t\t}\n\t\t} else {\n\t\t\thuff->tree = tnode2; \n\t\t}\n \n\t\ttnode2->right = tnode;\n\t\ttnode2->left = huff->lhead;\n \n\t\ttnode2->parent = huff->lhead->parent;\n\t\thuff->lhead->parent = tnode->parent = tnode2;\n     \n\t\thuff->loc[ch] = tnode;\n \n\t\tincrement(huff, tnode2->parent);\n\t} else {\n\t\tincrement(huff, huff->loc[ch]);\n\t}\n}\n\n/* Get a symbol */\nint Huff_Receive (node_t *node, int *ch, byte *fin) {\n\twhile (node && node->symbol == INTERNAL_NODE) {\n\t\tif (get_bit(fin)) {\n\t\t\tnode = node->right;\n\t\t} else {\n\t\t\tnode = node->left;\n\t\t}\n\t}\n\tif (!node) {\n\t\treturn 0;\n//\t\tCom_Error(ERR_DROP, \"Illegal tree!\\n\");\n\t}\n\treturn (*ch = node->symbol);\n}\n\n/* Get a symbol */\nvoid Huff_offsetReceive (node_t *node, int *ch, byte *fin, int *offset) {\n\tbloc = *offset;\n\twhile (node && node->symbol == INTERNAL_NODE) {\n\t\tif (get_bit(fin)) {\n\t\t\tnode = node->right;\n\t\t} else {\n\t\t\tnode = node->left;\n\t\t}\n\t}\n\tif (!node) {\n\t\t*ch = 0;\n\t\treturn;\n//\t\tCom_Error(ERR_DROP, \"Illegal tree!\\n\");\n\t}\n\t*ch = node->symbol;\n\t*offset = bloc;\n}\n\n/* Send the prefix code for this node */\nstatic void send(node_t *node, node_t *child, byte *fout) {\n\tif (node->parent) {\n\t\tsend(node->parent, node, fout);\n\t}\n\tif (child) {\n\t\tif (node->right == child) {\n\t\t\tadd_bit(1, fout);\n\t\t} else {\n\t\t\tadd_bit(0, fout);\n\t\t}\n\t}\n}\n\n/* Send a symbol */\nvoid Huff_transmit (huff_t *huff, int ch, byte *fout) {\n\tint i;\n\tif (huff->loc[ch] == NULL) { \n\t\t/* node_t hasn't been transmitted, send a NYT, then the symbol */\n\t\tHuff_transmit(huff, NYT, fout);\n\t\tfor (i = 7; i >= 0; i--) {\n\t\t\tadd_bit((char)((ch >> i) & 0x1), fout);\n\t\t}\n\t} else {\n\t\tsend(huff->loc[ch], NULL, fout);\n\t}\n}\n\nvoid Huff_offsetTransmit (huff_t *huff, int ch, byte *fout, int *offset) {\n\tbloc = *offset;\n\tsend(huff->loc[ch], NULL, fout);\n\t*offset = bloc;\n}\n\nvoid Huff_Decompress(msg_t *mbuf, int offset) {\n\tint\t\t\tch, cch, i, j, size;\n\tbyte\t\tseq[65536];\n\tbyte*\t\tbuffer;\n\thuff_t\t\thuff;\n\n\tsize = mbuf->cursize - offset;\n\tbuffer = mbuf->data + offset;\n\n\tif ( size <= 0 ) {\n\t\treturn;\n\t}\n\n\tCom_Memset(&huff, 0, sizeof(huff_t));\n\t// Initialize the tree & list with the NYT node \n\thuff.tree = huff.lhead = huff.ltail = huff.loc[NYT] = &(huff.nodeList[huff.blocNode++]);\n\thuff.tree->symbol = NYT;\n\thuff.tree->weight = 0;\n\thuff.lhead->next = huff.lhead->prev = NULL;\n\thuff.tree->parent = huff.tree->left = huff.tree->right = NULL;\n\n\tcch = buffer[0]*256 + buffer[1];\n\t// don't overflow with bad messages\n\tif ( cch > mbuf->maxsize - offset ) {\n\t\tcch = mbuf->maxsize - offset;\n\t}\n\tbloc = 16;\n\n\tfor ( j = 0; j < cch; j++ ) {\n\t\tch = 0;\n\t\t// don't overflow reading from the messages\n\t\t// FIXME: would it be better to have a overflow check in get_bit ?\n\t\tif ( (bloc >> 3) > size ) {\n\t\t\tseq[j] = 0;\n\t\t\tbreak;\n\t\t}\n\t\tHuff_Receive(huff.tree, &ch, buffer);\t\t\t\t/* Get a character */\n\t\tif ( ch == NYT ) {\t\t\t\t\t\t\t\t/* We got a NYT, get the symbol associated with it */\n\t\t\tch = 0;\n\t\t\tfor ( i = 0; i < 8; i++ ) {\n\t\t\t\tch = (ch<<1) + get_bit(buffer);\n\t\t\t}\n\t\t}\n    \n\t\tseq[j] = ch;\t\t\t\t\t\t\t\t\t/* Write symbol */\n\n\t\tHuff_addRef(&huff, (byte)ch);\t\t\t\t\t\t\t\t/* Increment node */\n\t}\n\tmbuf->cursize = cch + offset;\n\tCom_Memcpy(mbuf->data + offset, seq, cch);\n}\n\nextern \tint oldsize;\n\nvoid Huff_Compress(msg_t *mbuf, int offset) {\n\tint\t\t\ti, ch, size;\n\tbyte\t\tseq[65536];\n\tbyte*\t\tbuffer;\n\thuff_t\t\thuff;\n\n\tsize = mbuf->cursize - offset;\n\tbuffer = mbuf->data+ + offset;\n\n\tif (size<=0) {\n\t\treturn;\n\t}\n\n\tCom_Memset(&huff, 0, sizeof(huff_t));\n\t// Add the NYT (not yet transmitted) node into the tree/list */\n\thuff.tree = huff.lhead = huff.loc[NYT] =  &(huff.nodeList[huff.blocNode++]);\n\thuff.tree->symbol = NYT;\n\thuff.tree->weight = 0;\n\thuff.lhead->next = huff.lhead->prev = NULL;\n\thuff.tree->parent = huff.tree->left = huff.tree->right = NULL;\n\thuff.loc[NYT] = huff.tree;\n\n\tseq[0] = (size>>8);\n\tseq[1] = size&0xff;\n\n\tbloc = 16;\n\n\tfor (i=0; i<size; i++ ) {\n\t\tch = buffer[i];\n\t\tHuff_transmit(&huff, ch, seq);\t\t\t\t\t\t/* Transmit symbol */\n\t\tHuff_addRef(&huff, (byte)ch);\t\t\t\t\t\t\t\t/* Do update */\n\t}\n\n\tbloc += 8;\t\t\t\t\t\t\t\t\t\t\t\t// next byte\n\n\tmbuf->cursize = (bloc>>3) + offset;\n\tCom_Memcpy(mbuf->data+offset, seq, (bloc>>3));\n}\n\nvoid Huff_Init(huffman_t *huff) {\n\n\tCom_Memset(&huff->compressor, 0, sizeof(huff_t));\n\tCom_Memset(&huff->decompressor, 0, sizeof(huff_t));\n\n\t// Initialize the tree & list with the NYT node \n\thuff->decompressor.tree = huff->decompressor.lhead = huff->decompressor.ltail = huff->decompressor.loc[NYT] = &(huff->decompressor.nodeList[huff->decompressor.blocNode++]);\n\thuff->decompressor.tree->symbol = NYT;\n\thuff->decompressor.tree->weight = 0;\n\thuff->decompressor.lhead->next = huff->decompressor.lhead->prev = NULL;\n\thuff->decompressor.tree->parent = huff->decompressor.tree->left = huff->decompressor.tree->right = NULL;\n\n\t// Add the NYT (not yet transmitted) node into the tree/list */\n\thuff->compressor.tree = huff->compressor.lhead = huff->compressor.loc[NYT] =  &(huff->compressor.nodeList[huff->compressor.blocNode++]);\n\thuff->compressor.tree->symbol = NYT;\n\thuff->compressor.tree->weight = 0;\n\thuff->compressor.lhead->next = huff->compressor.lhead->prev = NULL;\n\thuff->compressor.tree->parent = huff->compressor.tree->left = huff->compressor.tree->right = NULL;\n\thuff->compressor.loc[NYT] = huff->compressor.tree;\n}\n\n"
  },
  {
    "path": "code/qcommon/md4.c",
    "content": "/* GLOBAL.H - RSAREF types and constants */\n\n#include <string.h>\n#if defined(_WIN32)\n#pragma warning(disable : 4711)\t\t// selected for automatic inline expansion\n#endif\n\n/* POINTER defines a generic pointer type */\ntypedef unsigned char *POINTER;\n\n/* UINT2 defines a two byte word */\ntypedef unsigned short int UINT2;\n\n/* UINT4 defines a four byte word */\ntypedef unsigned long int UINT4;\n\n  \n/* MD4.H - header file for MD4C.C */\n\n/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. \n\nAll rights reserved.\n  \nLicense to copy and use this software is granted provided that it is identified as the RSA Data Security, Inc. MD4 Message-Digest Algorithm in all material mentioning or referencing this software or this function.\nLicense is also granted to make and use derivative works provided that such works are identified as derived from the RSA Data Security, Inc. MD4 Message-Digest Algorithm in all material mentioning or referencing the derived work.\nRSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided as is without express or implied warranty of any kind.\n  \nThese notices must be retained in any copies of any part of this documentation and/or software. */\n\n/* MD4 context. */\ntypedef struct {\n\tUINT4 state[4];\t\t\t\t/* state (ABCD) */\n\tUINT4 count[2];\t\t\t\t/* number of bits, modulo 2^64 (lsb first) */\n\tunsigned char buffer[64]; \t\t\t/* input buffer */\n} MD4_CTX;\n\nvoid MD4Init (MD4_CTX *);\nvoid MD4Update (MD4_CTX *, const unsigned char *, unsigned int);\nvoid MD4Final (unsigned char [16], MD4_CTX *);\n\n#ifndef __VECTORC  \nvoid Com_Memset (void* dest, const int val, const size_t count);\nvoid Com_Memcpy (void* dest, const void* src, const size_t count);\n#else\n#define Com_Memset memset\n#define Com_Memcpy memcpy\n#endif\n\n/* MD4C.C - RSA Data Security, Inc., MD4 message-digest algorithm */\n/* Copyright (C) 1990-2, RSA Data Security, Inc. All rights reserved.\n  \nLicense to copy and use this software is granted provided that it is identified as the\nRSA Data Security, Inc. MD4 Message-Digest Algorithm\n in all material mentioning or referencing this software or this function.\nLicense is also granted to make and use derivative works provided that such works are identified as \nderived from the RSA Data Security, Inc. MD4 Message-Digest Algorithm\nin all material mentioning or referencing the derived work.\nRSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided\nas is without express or implied warranty of any kind.\n  \nThese notices must be retained in any copies of any part of this documentation and/or software. */\n\n/* Constants for MD4Transform routine.  */\n#define S11 3\n#define S12 7\n#define S13 11\n#define S14 19\n#define S21 3\n#define S22 5\n#define S23 9\n#define S24 13\n#define S31 3\n#define S32 9\n#define S33 11\n#define S34 15\n\nstatic void MD4Transform (UINT4 [4], const unsigned char [64]);\nstatic void Encode (unsigned char *, UINT4 *, unsigned int);\nstatic void Decode (UINT4 *, const unsigned char *, unsigned int);\n\nstatic unsigned char PADDING[64] = {\n0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\n};\n\n/* F, G and H are basic MD4 functions. */\n#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))\n#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))\n#define H(x, y, z) ((x) ^ (y) ^ (z))\n\n/* ROTATE_LEFT rotates x left n bits. */\n#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))\n\n/* FF, GG and HH are transformations for rounds 1, 2 and 3 */\n/* Rotation is separate from addition to prevent recomputation */\n#define FF(a, b, c, d, x, s) {(a) += F ((b), (c), (d)) + (x); (a) = ROTATE_LEFT ((a), (s));}\n\n#define GG(a, b, c, d, x, s) {(a) += G ((b), (c), (d)) + (x) + (UINT4)0x5a827999; (a) = ROTATE_LEFT ((a), (s));}\n\n#define HH(a, b, c, d, x, s) {(a) += H ((b), (c), (d)) + (x) + (UINT4)0x6ed9eba1; (a) = ROTATE_LEFT ((a), (s));}\n\n\n/* MD4 initialization. Begins an MD4 operation, writing a new context. */\nvoid MD4Init (MD4_CTX *context)\n{\n\tcontext->count[0] = context->count[1] = 0;\n\n/* Load magic initialization constants.*/\ncontext->state[0] = 0x67452301;\ncontext->state[1] = 0xefcdab89;\ncontext->state[2] = 0x98badcfe;\ncontext->state[3] = 0x10325476;\n}\n\n/* MD4 block update operation. Continues an MD4 message-digest operation, processing another message block, and updating the context. */\nvoid MD4Update (MD4_CTX *context, const unsigned char *input, unsigned int inputLen)\n{\n\tunsigned int i, index, partLen;\n\n\t/* Compute number of bytes mod 64 */\n\tindex = (unsigned int)((context->count[0] >> 3) & 0x3F);\n\n\t/* Update number of bits */\n\tif ((context->count[0] += ((UINT4)inputLen << 3))< ((UINT4)inputLen << 3))\n\t\tcontext->count[1]++;\n\n\tcontext->count[1] += ((UINT4)inputLen >> 29);\n\n\tpartLen = 64 - index;\n\n\t/* Transform as many times as possible.*/\n\tif (inputLen >= partLen)\n\t{\n \t\tCom_Memcpy((POINTER)&context->buffer[index], (POINTER)input, partLen);\n \t\tMD4Transform (context->state, context->buffer);\n\n \t\tfor (i = partLen; i + 63 < inputLen; i += 64)\n \t\t\tMD4Transform (context->state, &input[i]);\n\n \t\tindex = 0;\n\t}\n\telse\n \t\ti = 0;\n\n\t/* Buffer remaining input */\n\tCom_Memcpy ((POINTER)&context->buffer[index], (POINTER)&input[i], inputLen-i);\n}\n\n\n/* MD4 finalization. Ends an MD4 message-digest operation, writing the the message digest and zeroizing the context. */\nvoid MD4Final (unsigned char digest[16], MD4_CTX *context)\n{\n\tunsigned char bits[8];\n\tunsigned int index, padLen;\n\n\t/* Save number of bits */\n\tEncode (bits, context->count, 8);\n\n\t/* Pad out to 56 mod 64.*/\n\tindex = (unsigned int)((context->count[0] >> 3) & 0x3f);\n\tpadLen = (index < 56) ? (56 - index) : (120 - index);\n\tMD4Update (context, PADDING, padLen);\n\n\t/* Append length (before padding) */\n\tMD4Update (context, bits, 8);\n\t\n\t/* Store state in digest */\n\tEncode (digest, context->state, 16);\n\n\t/* Zeroize sensitive information.*/\n\tCom_Memset ((POINTER)context, 0, sizeof (*context));\n}\n\n\n/* MD4 basic transformation. Transforms state based on block. */\nstatic void MD4Transform (UINT4 state[4], const unsigned char block[64])\n{\n\tUINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];\n\n\tDecode (x, block, 64);\n\n/* Round 1 */\nFF (a, b, c, d, x[ 0], S11); \t\t\t\t/* 1 */\nFF (d, a, b, c, x[ 1], S12); \t\t\t\t/* 2 */\nFF (c, d, a, b, x[ 2], S13); \t\t\t\t/* 3 */\nFF (b, c, d, a, x[ 3], S14); \t\t\t\t/* 4 */\nFF (a, b, c, d, x[ 4], S11); \t\t\t\t/* 5 */\nFF (d, a, b, c, x[ 5], S12); \t\t\t\t/* 6 */\nFF (c, d, a, b, x[ 6], S13); \t\t\t\t/* 7 */\nFF (b, c, d, a, x[ 7], S14); \t\t\t\t/* 8 */\nFF (a, b, c, d, x[ 8], S11); \t\t\t\t/* 9 */\nFF (d, a, b, c, x[ 9], S12); \t\t\t\t/* 10 */\nFF (c, d, a, b, x[10], S13); \t\t\t/* 11 */\nFF (b, c, d, a, x[11], S14); \t\t\t/* 12 */\nFF (a, b, c, d, x[12], S11); \t\t\t/* 13 */\nFF (d, a, b, c, x[13], S12); \t\t\t/* 14 */\nFF (c, d, a, b, x[14], S13); \t\t\t/* 15 */\nFF (b, c, d, a, x[15], S14); \t\t\t/* 16 */\n\n/* Round 2 */\nGG (a, b, c, d, x[ 0], S21); \t\t\t/* 17 */\nGG (d, a, b, c, x[ 4], S22); \t\t\t/* 18 */\nGG (c, d, a, b, x[ 8], S23); \t\t\t/* 19 */\nGG (b, c, d, a, x[12], S24); \t\t\t/* 20 */\nGG (a, b, c, d, x[ 1], S21); \t\t\t/* 21 */\nGG (d, a, b, c, x[ 5], S22); \t\t\t/* 22 */\nGG (c, d, a, b, x[ 9], S23); \t\t\t/* 23 */\nGG (b, c, d, a, x[13], S24); \t\t\t/* 24 */\nGG (a, b, c, d, x[ 2], S21); \t\t\t/* 25 */\nGG (d, a, b, c, x[ 6], S22); \t\t\t/* 26 */\nGG (c, d, a, b, x[10], S23); \t\t\t/* 27 */\nGG (b, c, d, a, x[14], S24); \t\t\t/* 28 */\nGG (a, b, c, d, x[ 3], S21); \t\t\t/* 29 */\nGG (d, a, b, c, x[ 7], S22); \t\t\t/* 30 */\nGG (c, d, a, b, x[11], S23); \t\t\t/* 31 */\nGG (b, c, d, a, x[15], S24); \t\t\t/* 32 */\n\n/* Round 3 */\nHH (a, b, c, d, x[ 0], S31);\t\t\t\t/* 33 */\nHH (d, a, b, c, x[ 8], S32); \t\t\t/* 34 */\nHH (c, d, a, b, x[ 4], S33); \t\t\t/* 35 */\nHH (b, c, d, a, x[12], S34); \t\t\t/* 36 */\nHH (a, b, c, d, x[ 2], S31); \t\t\t/* 37 */\nHH (d, a, b, c, x[10], S32); \t\t\t/* 38 */\nHH (c, d, a, b, x[ 6], S33); \t\t\t/* 39 */\nHH (b, c, d, a, x[14], S34); \t\t\t/* 40 */\nHH (a, b, c, d, x[ 1], S31); \t\t\t/* 41 */\nHH (d, a, b, c, x[ 9], S32); \t\t\t/* 42 */\nHH (c, d, a, b, x[ 5], S33); \t\t\t/* 43 */\nHH (b, c, d, a, x[13], S34); \t\t\t/* 44 */\nHH (a, b, c, d, x[ 3], S31); \t\t\t/* 45 */\nHH (d, a, b, c, x[11], S32); \t\t\t/* 46 */\nHH (c, d, a, b, x[ 7], S33); \t\t\t/* 47 */\nHH (b, c, d, a, x[15], S34);\t\t\t/* 48 */\n\nstate[0] += a;\nstate[1] += b;\nstate[2] += c;\nstate[3] += d;\n\n\t/* Zeroize sensitive information.*/\n\tCom_Memset ((POINTER)x, 0, sizeof (x));\n}\n\n\n/* Encodes input (UINT4) into output (unsigned char). Assumes len is a multiple of 4. */\nstatic void Encode (unsigned char *output, UINT4 *input, unsigned int len)\n{\n\tunsigned int i, j;\n\n\tfor (i = 0, j = 0; j < len; i++, j += 4) {\n \t\toutput[j] = (unsigned char)(input[i] & 0xff);\n \t\toutput[j+1] = (unsigned char)((input[i] >> 8) & 0xff);\n \t\toutput[j+2] = (unsigned char)((input[i] >> 16) & 0xff);\n \t\toutput[j+3] = (unsigned char)((input[i] >> 24) & 0xff);\n\t}\n}\n\n\n/* Decodes input (unsigned char) into output (UINT4). Assumes len is a multiple of 4. */\nstatic void Decode (UINT4 *output, const unsigned char *input, unsigned int len)\n{\nunsigned int i, j;\n\nfor (i = 0, j = 0; j < len; i++, j += 4)\n \toutput[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);\n}\n\n//===================================================================\n\nunsigned Com_BlockChecksum (void *buffer, int length)\n{\n\tint\t\t\tdigest[4];\n\tunsigned\tval;\n\tMD4_CTX\t\tctx;\n\n\tMD4Init (&ctx);\n\tMD4Update (&ctx, (unsigned char *)buffer, length);\n\tMD4Final ( (unsigned char *)digest, &ctx);\n\t\n\tval = digest[0] ^ digest[1] ^ digest[2] ^ digest[3];\n\n\treturn val;\n}\n\nunsigned Com_BlockChecksumKey (void *buffer, int length, int key)\n{\n\tint\t\t\tdigest[4];\n\tunsigned\tval;\n\tMD4_CTX\t\tctx;\n\n\tMD4Init (&ctx);\n\tMD4Update (&ctx, (unsigned char *)&key, 4);\n\tMD4Update (&ctx, (unsigned char *)buffer, length);\n\tMD4Final ( (unsigned char *)digest, &ctx);\n\t\n\tval = digest[0] ^ digest[1] ^ digest[2] ^ digest[3];\n\n\treturn val;\n}\n"
  },
  {
    "path": "code/qcommon/msg.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"../game/q_shared.h\"\n#include \"qcommon.h\"\n\nstatic huffman_t\t\tmsgHuff;\n\nstatic qboolean\t\t\tmsgInit = qfalse;\n\nint pcount[256];\n\n/*\n==============================================================================\n\n\t\t\tMESSAGE IO FUNCTIONS\n\nHandles byte ordering and avoids alignment errors\n==============================================================================\n*/\n\nint oldsize = 0;\n\nvoid MSG_initHuffman();\n\nvoid MSG_Init( msg_t *buf, byte *data, int length ) {\n\tif (!msgInit) {\n\t\tMSG_initHuffman();\n\t}\n\tCom_Memset (buf, 0, sizeof(*buf));\n\tbuf->data = data;\n\tbuf->maxsize = length;\n}\n\nvoid MSG_InitOOB( msg_t *buf, byte *data, int length ) {\n\tif (!msgInit) {\n\t\tMSG_initHuffman();\n\t}\n\tCom_Memset (buf, 0, sizeof(*buf));\n\tbuf->data = data;\n\tbuf->maxsize = length;\n\tbuf->oob = qtrue;\n}\n\nvoid MSG_Clear( msg_t *buf ) {\n\tbuf->cursize = 0;\n\tbuf->overflowed = qfalse;\n\tbuf->bit = 0;\t\t\t\t\t//<- in bits\n}\n\n\nvoid MSG_Bitstream( msg_t *buf ) {\n\tbuf->oob = qfalse;\n}\n\nvoid MSG_BeginReading( msg_t *msg ) {\n\tmsg->readcount = 0;\n\tmsg->bit = 0;\n\tmsg->oob = qfalse;\n}\n\nvoid MSG_BeginReadingOOB( msg_t *msg ) {\n\tmsg->readcount = 0;\n\tmsg->bit = 0;\n\tmsg->oob = qtrue;\n}\n\nvoid MSG_Copy(msg_t *buf, byte *data, int length, msg_t *src)\n{\n\tif (length<src->cursize) {\n\t\tCom_Error( ERR_DROP, \"MSG_Copy: can't copy into a smaller msg_t buffer\");\n\t}\n\tCom_Memcpy(buf, src, sizeof(msg_t));\n\tbuf->data = data;\n\tCom_Memcpy(buf->data, src->data, src->cursize);\n}\n\n/*\n=============================================================================\n\nbit functions\n  \n=============================================================================\n*/\n\nint\toverflows;\n\n// negative bit values include signs\nvoid MSG_WriteBits( msg_t *msg, int value, int bits ) {\n\tint\ti;\n//\tFILE*\tfp;\n\n\toldsize += bits;\n\n\t// this isn't an exact overflow check, but close enough\n\tif ( msg->maxsize - msg->cursize < 4 ) {\n\t\tmsg->overflowed = qtrue;\n\t\treturn;\n\t}\n\n\tif ( bits == 0 || bits < -31 || bits > 32 ) {\n\t\tCom_Error( ERR_DROP, \"MSG_WriteBits: bad bits %i\", bits );\n\t}\n\n\t// check for overflows\n\tif ( bits != 32 ) {\n\t\tif ( bits > 0 ) {\n\t\t\tif ( value > ( ( 1 << bits ) - 1 ) || value < 0 ) {\n\t\t\t\toverflows++;\n\t\t\t}\n\t\t} else {\n\t\t\tint\tr;\n\n\t\t\tr = 1 << (bits-1);\n\n\t\t\tif ( value >  r - 1 || value < -r ) {\n\t\t\t\toverflows++;\n\t\t\t}\n\t\t}\n\t}\n\tif ( bits < 0 ) {\n\t\tbits = -bits;\n\t}\n\tif (msg->oob) {\n\t\tif (bits==8) {\n\t\t\tmsg->data[msg->cursize] = value;\n\t\t\tmsg->cursize += 1;\n\t\t\tmsg->bit += 8;\n\t\t} else if (bits==16) {\n\t\t\tunsigned short *sp = (unsigned short *)&msg->data[msg->cursize];\n\t\t\t*sp = LittleShort(value);\n\t\t\tmsg->cursize += 2;\n\t\t\tmsg->bit += 16;\n\t\t} else if (bits==32) {\n\t\t\tunsigned int *ip = (unsigned int *)&msg->data[msg->cursize];\n\t\t\t*ip = LittleLong(value);\n\t\t\tmsg->cursize += 4;\n\t\t\tmsg->bit += 8;\n\t\t} else {\n\t\t\tCom_Error(ERR_DROP, \"can't read %d bits\\n\", bits);\n\t\t}\n\t} else {\n//\t\tfp = fopen(\"c:\\\\netchan.bin\", \"a\");\n\t\tvalue &= (0xffffffff>>(32-bits));\n\t\tif (bits&7) {\n\t\t\tint nbits;\n\t\t\tnbits = bits&7;\n\t\t\tfor(i=0;i<nbits;i++) {\n\t\t\t\tHuff_putBit((value&1), msg->data, &msg->bit);\n\t\t\t\tvalue = (value>>1);\n\t\t\t}\n\t\t\tbits = bits - nbits;\n\t\t}\n\t\tif (bits) {\n\t\t\tfor(i=0;i<bits;i+=8) {\n//\t\t\t\tfwrite(bp, 1, 1, fp);\n\t\t\t\tHuff_offsetTransmit (&msgHuff.compressor, (value&0xff), msg->data, &msg->bit);\n\t\t\t\tvalue = (value>>8);\n\t\t\t}\n\t\t}\n\t\tmsg->cursize = (msg->bit>>3)+1;\n//\t\tfclose(fp);\n\t}\n}\n\nint MSG_ReadBits( msg_t *msg, int bits ) {\n\tint\t\t\tvalue;\n\tint\t\t\tget;\n\tqboolean\tsgn;\n\tint\t\t\ti, nbits;\n//\tFILE*\tfp;\n\n\tvalue = 0;\n\n\tif ( bits < 0 ) {\n\t\tbits = -bits;\n\t\tsgn = qtrue;\n\t} else {\n\t\tsgn = qfalse;\n\t}\n\n\tif (msg->oob) {\n\t\tif (bits==8) {\n\t\t\tvalue = msg->data[msg->readcount];\n\t\t\tmsg->readcount += 1;\n\t\t\tmsg->bit += 8;\n\t\t} else if (bits==16) {\n\t\t\tunsigned short *sp = (unsigned short *)&msg->data[msg->readcount];\n\t\t\tvalue = LittleShort(*sp);\n\t\t\tmsg->readcount += 2;\n\t\t\tmsg->bit += 16;\n\t\t} else if (bits==32) {\n\t\t\tunsigned int *ip = (unsigned int *)&msg->data[msg->readcount];\n\t\t\tvalue = LittleLong(*ip);\n\t\t\tmsg->readcount += 4;\n\t\t\tmsg->bit += 32;\n\t\t} else {\n\t\t\tCom_Error(ERR_DROP, \"can't read %d bits\\n\", bits);\n\t\t}\n\t} else {\n\t\tnbits = 0;\n\t\tif (bits&7) {\n\t\t\tnbits = bits&7;\n\t\t\tfor(i=0;i<nbits;i++) {\n\t\t\t\tvalue |= (Huff_getBit(msg->data, &msg->bit)<<i);\n\t\t\t}\n\t\t\tbits = bits - nbits;\n\t\t}\n\t\tif (bits) {\n//\t\t\tfp = fopen(\"c:\\\\netchan.bin\", \"a\");\n\t\t\tfor(i=0;i<bits;i+=8) {\n\t\t\t\tHuff_offsetReceive (msgHuff.decompressor.tree, &get, msg->data, &msg->bit);\n//\t\t\t\tfwrite(&get, 1, 1, fp);\n\t\t\t\tvalue |= (get<<(i+nbits));\n\t\t\t}\n//\t\t\tfclose(fp);\n\t\t}\n\t\tmsg->readcount = (msg->bit>>3)+1;\n\t}\n\tif ( sgn ) {\n\t\tif ( value & ( 1 << ( bits - 1 ) ) ) {\n\t\t\tvalue |= -1 ^ ( ( 1 << bits ) - 1 );\n\t\t}\n\t}\n\n\treturn value;\n}\n\n\n\n//================================================================================\n\n//\n// writing functions\n//\n\nvoid MSG_WriteChar( msg_t *sb, int c ) {\n#ifdef PARANOID\n\tif (c < -128 || c > 127)\n\t\tCom_Error (ERR_FATAL, \"MSG_WriteChar: range error\");\n#endif\n\n\tMSG_WriteBits( sb, c, 8 );\n}\n\nvoid MSG_WriteByte( msg_t *sb, int c ) {\n#ifdef PARANOID\n\tif (c < 0 || c > 255)\n\t\tCom_Error (ERR_FATAL, \"MSG_WriteByte: range error\");\n#endif\n\n\tMSG_WriteBits( sb, c, 8 );\n}\n\nvoid MSG_WriteData( msg_t *buf, const void *data, int length ) {\n\tint i;\n\tfor(i=0;i<length;i++) {\n\t\tMSG_WriteByte(buf, ((byte *)data)[i]);\n\t}\n}\n\nvoid MSG_WriteShort( msg_t *sb, int c ) {\n#ifdef PARANOID\n\tif (c < ((short)0x8000) || c > (short)0x7fff)\n\t\tCom_Error (ERR_FATAL, \"MSG_WriteShort: range error\");\n#endif\n\n\tMSG_WriteBits( sb, c, 16 );\n}\n\nvoid MSG_WriteLong( msg_t *sb, int c ) {\n\tMSG_WriteBits( sb, c, 32 );\n}\n\nvoid MSG_WriteFloat( msg_t *sb, float f ) {\n\tunion {\n\t\tfloat\tf;\n\t\tint\tl;\n\t} dat;\n\t\n\tdat.f = f;\n\tMSG_WriteBits( sb, dat.l, 32 );\n}\n\nvoid MSG_WriteString( msg_t *sb, const char *s ) {\n\tif ( !s ) {\n\t\tMSG_WriteData (sb, \"\", 1);\n\t} else {\n\t\tint\t\tl,i;\n\t\tchar\tstring[MAX_STRING_CHARS];\n\n\t\tl = strlen( s );\n\t\tif ( l >= MAX_STRING_CHARS ) {\n\t\t\tCom_Printf( \"MSG_WriteString: MAX_STRING_CHARS\" );\n\t\t\tMSG_WriteData (sb, \"\", 1);\n\t\t\treturn;\n\t\t}\n\t\tQ_strncpyz( string, s, sizeof( string ) );\n\n\t\t// get rid of 0xff chars, because old clients don't like them\n\t\tfor ( i = 0 ; i < l ; i++ ) {\n\t\t\tif ( ((byte *)string)[i] > 127 ) {\n\t\t\t\tstring[i] = '.';\n\t\t\t}\n\t\t}\n\n\t\tMSG_WriteData (sb, string, l+1);\n\t}\n}\n\nvoid MSG_WriteBigString( msg_t *sb, const char *s ) {\n\tif ( !s ) {\n\t\tMSG_WriteData (sb, \"\", 1);\n\t} else {\n\t\tint\t\tl,i;\n\t\tchar\tstring[BIG_INFO_STRING];\n\n\t\tl = strlen( s );\n\t\tif ( l >= BIG_INFO_STRING ) {\n\t\t\tCom_Printf( \"MSG_WriteString: BIG_INFO_STRING\" );\n\t\t\tMSG_WriteData (sb, \"\", 1);\n\t\t\treturn;\n\t\t}\n\t\tQ_strncpyz( string, s, sizeof( string ) );\n\n\t\t// get rid of 0xff chars, because old clients don't like them\n\t\tfor ( i = 0 ; i < l ; i++ ) {\n\t\t\tif ( ((byte *)string)[i] > 127 ) {\n\t\t\t\tstring[i] = '.';\n\t\t\t}\n\t\t}\n\n\t\tMSG_WriteData (sb, string, l+1);\n\t}\n}\n\nvoid MSG_WriteAngle( msg_t *sb, float f ) {\n\tMSG_WriteByte (sb, (int)(f*256/360) & 255);\n}\n\nvoid MSG_WriteAngle16( msg_t *sb, float f ) {\n\tMSG_WriteShort (sb, ANGLE2SHORT(f));\n}\n\n\n//============================================================\n\n//\n// reading functions\n//\n\n// returns -1 if no more characters are available\nint MSG_ReadChar (msg_t *msg ) {\n\tint\tc;\n\t\n\tc = (signed char)MSG_ReadBits( msg, 8 );\n\tif ( msg->readcount > msg->cursize ) {\n\t\tc = -1;\n\t}\t\n\t\n\treturn c;\n}\n\nint MSG_ReadByte( msg_t *msg ) {\n\tint\tc;\n\t\n\tc = (unsigned char)MSG_ReadBits( msg, 8 );\n\tif ( msg->readcount > msg->cursize ) {\n\t\tc = -1;\n\t}\t\n\treturn c;\n}\n\nint MSG_ReadShort( msg_t *msg ) {\n\tint\tc;\n\t\n\tc = (short)MSG_ReadBits( msg, 16 );\n\tif ( msg->readcount > msg->cursize ) {\n\t\tc = -1;\n\t}\t\n\n\treturn c;\n}\n\nint MSG_ReadLong( msg_t *msg ) {\n\tint\tc;\n\t\n\tc = MSG_ReadBits( msg, 32 );\n\tif ( msg->readcount > msg->cursize ) {\n\t\tc = -1;\n\t}\t\n\t\n\treturn c;\n}\n\nfloat MSG_ReadFloat( msg_t *msg ) {\n\tunion {\n\t\tbyte\tb[4];\n\t\tfloat\tf;\n\t\tint\tl;\n\t} dat;\n\t\n\tdat.l = MSG_ReadBits( msg, 32 );\n\tif ( msg->readcount > msg->cursize ) {\n\t\tdat.f = -1;\n\t}\t\n\t\n\treturn dat.f;\t\n}\n\nchar *MSG_ReadString( msg_t *msg ) {\n\tstatic char\tstring[MAX_STRING_CHARS];\n\tint\t\tl,c;\n\t\n\tl = 0;\n\tdo {\n\t\tc = MSG_ReadByte(msg);\t\t// use ReadByte so -1 is out of bounds\n\t\tif ( c == -1 || c == 0 ) {\n\t\t\tbreak;\n\t\t}\n\t\t// translate all fmt spec to avoid crash bugs\n\t\tif ( c == '%' ) {\n\t\t\tc = '.';\n\t\t}\n\t\t// don't allow higher ascii values\n\t\tif ( c > 127 ) {\n\t\t\tc = '.';\n\t\t}\n\n\t\tstring[l] = c;\n\t\tl++;\n\t} while (l < sizeof(string)-1);\n\t\n\tstring[l] = 0;\n\t\n\treturn string;\n}\n\nchar *MSG_ReadBigString( msg_t *msg ) {\n\tstatic char\tstring[BIG_INFO_STRING];\n\tint\t\tl,c;\n\t\n\tl = 0;\n\tdo {\n\t\tc = MSG_ReadByte(msg);\t\t// use ReadByte so -1 is out of bounds\n\t\tif ( c == -1 || c == 0 ) {\n\t\t\tbreak;\n\t\t}\n\t\t// translate all fmt spec to avoid crash bugs\n\t\tif ( c == '%' ) {\n\t\t\tc = '.';\n\t\t}\n\n\t\tstring[l] = c;\n\t\tl++;\n\t} while (l < sizeof(string)-1);\n\t\n\tstring[l] = 0;\n\t\n\treturn string;\n}\n\nchar *MSG_ReadStringLine( msg_t *msg ) {\n\tstatic char\tstring[MAX_STRING_CHARS];\n\tint\t\tl,c;\n\n\tl = 0;\n\tdo {\n\t\tc = MSG_ReadByte(msg);\t\t// use ReadByte so -1 is out of bounds\n\t\tif (c == -1 || c == 0 || c == '\\n') {\n\t\t\tbreak;\n\t\t}\n\t\t// translate all fmt spec to avoid crash bugs\n\t\tif ( c == '%' ) {\n\t\t\tc = '.';\n\t\t}\n\t\tstring[l] = c;\n\t\tl++;\n\t} while (l < sizeof(string)-1);\n\t\n\tstring[l] = 0;\n\t\n\treturn string;\n}\n\nfloat MSG_ReadAngle16( msg_t *msg ) {\n\treturn SHORT2ANGLE(MSG_ReadShort(msg));\n}\n\nvoid MSG_ReadData( msg_t *msg, void *data, int len ) {\n\tint\t\ti;\n\n\tfor (i=0 ; i<len ; i++) {\n\t\t((byte *)data)[i] = MSG_ReadByte (msg);\n\t}\n}\n\n\n/*\n=============================================================================\n\ndelta functions\n  \n=============================================================================\n*/\n\nextern cvar_t *cl_shownet;\n\n#define\tLOG(x) if( cl_shownet->integer == 4 ) { Com_Printf(\"%s \", x ); };\n\nvoid MSG_WriteDelta( msg_t *msg, int oldV, int newV, int bits ) {\n\tif ( oldV == newV ) {\n\t\tMSG_WriteBits( msg, 0, 1 );\n\t\treturn;\n\t}\n\tMSG_WriteBits( msg, 1, 1 );\n\tMSG_WriteBits( msg, newV, bits );\n}\n\nint\tMSG_ReadDelta( msg_t *msg, int oldV, int bits ) {\n\tif ( MSG_ReadBits( msg, 1 ) ) {\n\t\treturn MSG_ReadBits( msg, bits );\n\t}\n\treturn oldV;\n}\n\nvoid MSG_WriteDeltaFloat( msg_t *msg, float oldV, float newV ) {\n\tif ( oldV == newV ) {\n\t\tMSG_WriteBits( msg, 0, 1 );\n\t\treturn;\n\t}\n\tMSG_WriteBits( msg, 1, 1 );\n\tMSG_WriteBits( msg, *(int *)&newV, 32 );\n}\n\nfloat MSG_ReadDeltaFloat( msg_t *msg, float oldV ) {\n\tif ( MSG_ReadBits( msg, 1 ) ) {\n\t\tfloat\tnewV;\n\n\t\t*(int *)&newV = MSG_ReadBits( msg, 32 );\n\t\treturn newV;\n\t}\n\treturn oldV;\n}\n\n/*\n=============================================================================\n\ndelta functions with keys\n  \n=============================================================================\n*/\n\nint kbitmask[32] = {\n\t0x00000001, 0x00000003, 0x00000007, 0x0000000F,\n\t0x0000001F,\t0x0000003F,\t0x0000007F,\t0x000000FF,\n\t0x000001FF,\t0x000003FF,\t0x000007FF,\t0x00000FFF,\n\t0x00001FFF,\t0x00003FFF,\t0x00007FFF,\t0x0000FFFF,\n\t0x0001FFFF,\t0x0003FFFF,\t0x0007FFFF,\t0x000FFFFF,\n\t0x001FFFFf,\t0x003FFFFF,\t0x007FFFFF,\t0x00FFFFFF,\n\t0x01FFFFFF,\t0x03FFFFFF,\t0x07FFFFFF,\t0x0FFFFFFF,\n\t0x1FFFFFFF,\t0x3FFFFFFF,\t0x7FFFFFFF,\t0xFFFFFFFF,\n};\n\nvoid MSG_WriteDeltaKey( msg_t *msg, int key, int oldV, int newV, int bits ) {\n\tif ( oldV == newV ) {\n\t\tMSG_WriteBits( msg, 0, 1 );\n\t\treturn;\n\t}\n\tMSG_WriteBits( msg, 1, 1 );\n\tMSG_WriteBits( msg, newV ^ key, bits );\n}\n\nint\tMSG_ReadDeltaKey( msg_t *msg, int key, int oldV, int bits ) {\n\tif ( MSG_ReadBits( msg, 1 ) ) {\n\t\treturn MSG_ReadBits( msg, bits ) ^ (key & kbitmask[bits]);\n\t}\n\treturn oldV;\n}\n\nvoid MSG_WriteDeltaKeyFloat( msg_t *msg, int key, float oldV, float newV ) {\n\tif ( oldV == newV ) {\n\t\tMSG_WriteBits( msg, 0, 1 );\n\t\treturn;\n\t}\n\tMSG_WriteBits( msg, 1, 1 );\n\tMSG_WriteBits( msg, (*(int *)&newV) ^ key, 32 );\n}\n\nfloat MSG_ReadDeltaKeyFloat( msg_t *msg, int key, float oldV ) {\n\tif ( MSG_ReadBits( msg, 1 ) ) {\n\t\tfloat\tnewV;\n\n\t\t*(int *)&newV = MSG_ReadBits( msg, 32 ) ^ key;\n\t\treturn newV;\n\t}\n\treturn oldV;\n}\n\n\n/*\n============================================================================\n\nusercmd_t communication\n\n============================================================================\n*/\n\n// ms is allways sent, the others are optional\n#define\tCM_ANGLE1 \t(1<<0)\n#define\tCM_ANGLE2 \t(1<<1)\n#define\tCM_ANGLE3 \t(1<<2)\n#define\tCM_FORWARD\t(1<<3)\n#define\tCM_SIDE\t\t(1<<4)\n#define\tCM_UP\t\t(1<<5)\n#define\tCM_BUTTONS\t(1<<6)\n#define CM_WEAPON\t(1<<7)\n\n/*\n=====================\nMSG_WriteDeltaUsercmd\n=====================\n*/\nvoid MSG_WriteDeltaUsercmd( msg_t *msg, usercmd_t *from, usercmd_t *to ) {\n\tif ( to->serverTime - from->serverTime < 256 ) {\n\t\tMSG_WriteBits( msg, 1, 1 );\n\t\tMSG_WriteBits( msg, to->serverTime - from->serverTime, 8 );\n\t} else {\n\t\tMSG_WriteBits( msg, 0, 1 );\n\t\tMSG_WriteBits( msg, to->serverTime, 32 );\n\t}\n\tMSG_WriteDelta( msg, from->angles[0], to->angles[0], 16 );\n\tMSG_WriteDelta( msg, from->angles[1], to->angles[1], 16 );\n\tMSG_WriteDelta( msg, from->angles[2], to->angles[2], 16 );\n\tMSG_WriteDelta( msg, from->forwardmove, to->forwardmove, 8 );\n\tMSG_WriteDelta( msg, from->rightmove, to->rightmove, 8 );\n\tMSG_WriteDelta( msg, from->upmove, to->upmove, 8 );\n\tMSG_WriteDelta( msg, from->buttons, to->buttons, 16 );\n\tMSG_WriteDelta( msg, from->weapon, to->weapon, 8 );\n}\n\n\n/*\n=====================\nMSG_ReadDeltaUsercmd\n=====================\n*/\nvoid MSG_ReadDeltaUsercmd( msg_t *msg, usercmd_t *from, usercmd_t *to ) {\n\tif ( MSG_ReadBits( msg, 1 ) ) {\n\t\tto->serverTime = from->serverTime + MSG_ReadBits( msg, 8 );\n\t} else {\n\t\tto->serverTime = MSG_ReadBits( msg, 32 );\n\t}\n\tto->angles[0] = MSG_ReadDelta( msg, from->angles[0], 16);\n\tto->angles[1] = MSG_ReadDelta( msg, from->angles[1], 16);\n\tto->angles[2] = MSG_ReadDelta( msg, from->angles[2], 16);\n\tto->forwardmove = MSG_ReadDelta( msg, from->forwardmove, 8);\n\tto->rightmove = MSG_ReadDelta( msg, from->rightmove, 8);\n\tto->upmove = MSG_ReadDelta( msg, from->upmove, 8);\n\tto->buttons = MSG_ReadDelta( msg, from->buttons, 16);\n\tto->weapon = MSG_ReadDelta( msg, from->weapon, 8);\n}\n\n/*\n=====================\nMSG_WriteDeltaUsercmd\n=====================\n*/\nvoid MSG_WriteDeltaUsercmdKey( msg_t *msg, int key, usercmd_t *from, usercmd_t *to ) {\n\tif ( to->serverTime - from->serverTime < 256 ) {\n\t\tMSG_WriteBits( msg, 1, 1 );\n\t\tMSG_WriteBits( msg, to->serverTime - from->serverTime, 8 );\n\t} else {\n\t\tMSG_WriteBits( msg, 0, 1 );\n\t\tMSG_WriteBits( msg, to->serverTime, 32 );\n\t}\n\tif (from->angles[0] == to->angles[0] &&\n\t\tfrom->angles[1] == to->angles[1] &&\n\t\tfrom->angles[2] == to->angles[2] &&\n\t\tfrom->forwardmove == to->forwardmove &&\n\t\tfrom->rightmove == to->rightmove &&\n\t\tfrom->upmove == to->upmove &&\n\t\tfrom->buttons == to->buttons &&\n\t\tfrom->weapon == to->weapon) {\n\t\t\tMSG_WriteBits( msg, 0, 1 );\t\t\t\t// no change\n\t\t\toldsize += 7;\n\t\t\treturn;\n\t}\n\tkey ^= to->serverTime;\n\tMSG_WriteBits( msg, 1, 1 );\n\tMSG_WriteDeltaKey( msg, key, from->angles[0], to->angles[0], 16 );\n\tMSG_WriteDeltaKey( msg, key, from->angles[1], to->angles[1], 16 );\n\tMSG_WriteDeltaKey( msg, key, from->angles[2], to->angles[2], 16 );\n\tMSG_WriteDeltaKey( msg, key, from->forwardmove, to->forwardmove, 8 );\n\tMSG_WriteDeltaKey( msg, key, from->rightmove, to->rightmove, 8 );\n\tMSG_WriteDeltaKey( msg, key, from->upmove, to->upmove, 8 );\n\tMSG_WriteDeltaKey( msg, key, from->buttons, to->buttons, 16 );\n\tMSG_WriteDeltaKey( msg, key, from->weapon, to->weapon, 8 );\n}\n\n\n/*\n=====================\nMSG_ReadDeltaUsercmd\n=====================\n*/\nvoid MSG_ReadDeltaUsercmdKey( msg_t *msg, int key, usercmd_t *from, usercmd_t *to ) {\n\tif ( MSG_ReadBits( msg, 1 ) ) {\n\t\tto->serverTime = from->serverTime + MSG_ReadBits( msg, 8 );\n\t} else {\n\t\tto->serverTime = MSG_ReadBits( msg, 32 );\n\t}\n\tif ( MSG_ReadBits( msg, 1 ) ) {\n\t\tkey ^= to->serverTime;\n\t\tto->angles[0] = MSG_ReadDeltaKey( msg, key, from->angles[0], 16);\n\t\tto->angles[1] = MSG_ReadDeltaKey( msg, key, from->angles[1], 16);\n\t\tto->angles[2] = MSG_ReadDeltaKey( msg, key, from->angles[2], 16);\n\t\tto->forwardmove = MSG_ReadDeltaKey( msg, key, from->forwardmove, 8);\n\t\tto->rightmove = MSG_ReadDeltaKey( msg, key, from->rightmove, 8);\n\t\tto->upmove = MSG_ReadDeltaKey( msg, key, from->upmove, 8);\n\t\tto->buttons = MSG_ReadDeltaKey( msg, key, from->buttons, 16);\n\t\tto->weapon = MSG_ReadDeltaKey( msg, key, from->weapon, 8);\n\t} else {\n\t\tto->angles[0] = from->angles[0];\n\t\tto->angles[1] = from->angles[1];\n\t\tto->angles[2] = from->angles[2];\n\t\tto->forwardmove = from->forwardmove;\n\t\tto->rightmove = from->rightmove;\n\t\tto->upmove = from->upmove;\n\t\tto->buttons = from->buttons;\n\t\tto->weapon = from->weapon;\n\t}\n}\n\n/*\n=============================================================================\n\nentityState_t communication\n  \n=============================================================================\n*/\n\n/*\n=================\nMSG_ReportChangeVectors_f\n\nPrints out a table from the current statistics for copying to code\n=================\n*/\nvoid MSG_ReportChangeVectors_f( void ) {\n\tint i;\n\tfor(i=0;i<256;i++) {\n\t\tif (pcount[i]) {\n\t\t\tCom_Printf(\"%d used %d\\n\", i, pcount[i]);\n\t\t}\n\t}\n}\n\ntypedef struct {\n\tchar\t*name;\n\tint\t\toffset;\n\tint\t\tbits;\t\t// 0 = float\n} netField_t;\n\n// using the stringizing operator to save typing...\n#define\tNETF(x) #x,(int)&((entityState_t*)0)->x\n\nnetField_t\tentityStateFields[] = \n{\n{ NETF(pos.trTime), 32 },\n{ NETF(pos.trBase[0]), 0 },\n{ NETF(pos.trBase[1]), 0 },\n{ NETF(pos.trDelta[0]), 0 },\n{ NETF(pos.trDelta[1]), 0 },\n{ NETF(pos.trBase[2]), 0 },\n{ NETF(apos.trBase[1]), 0 },\n{ NETF(pos.trDelta[2]), 0 },\n{ NETF(apos.trBase[0]), 0 },\n{ NETF(event), 10 },\n{ NETF(angles2[1]), 0 },\n{ NETF(eType), 8 },\n{ NETF(torsoAnim), 8 },\n{ NETF(eventParm), 8 },\n{ NETF(legsAnim), 8 },\n{ NETF(groundEntityNum), GENTITYNUM_BITS },\n{ NETF(pos.trType), 8 },\n{ NETF(eFlags), 19 },\n{ NETF(otherEntityNum), GENTITYNUM_BITS },\n{ NETF(weapon), 8 },\n{ NETF(clientNum), 8 },\n{ NETF(angles[1]), 0 },\n{ NETF(pos.trDuration), 32 },\n{ NETF(apos.trType), 8 },\n{ NETF(origin[0]), 0 },\n{ NETF(origin[1]), 0 },\n{ NETF(origin[2]), 0 },\n{ NETF(solid), 24 },\n{ NETF(powerups), 16 },\n{ NETF(modelindex), 8 },\n{ NETF(otherEntityNum2), GENTITYNUM_BITS },\n{ NETF(loopSound), 8 },\n{ NETF(generic1), 8 },\n{ NETF(origin2[2]), 0 },\n{ NETF(origin2[0]), 0 },\n{ NETF(origin2[1]), 0 },\n{ NETF(modelindex2), 8 },\n{ NETF(angles[0]), 0 },\n{ NETF(time), 32 },\n{ NETF(apos.trTime), 32 },\n{ NETF(apos.trDuration), 32 },\n{ NETF(apos.trBase[2]), 0 },\n{ NETF(apos.trDelta[0]), 0 },\n{ NETF(apos.trDelta[1]), 0 },\n{ NETF(apos.trDelta[2]), 0 },\n{ NETF(time2), 32 },\n{ NETF(angles[2]), 0 },\n{ NETF(angles2[0]), 0 },\n{ NETF(angles2[2]), 0 },\n{ NETF(constantLight), 32 },\n{ NETF(frame), 16 }\n};\n\n\n// if (int)f == f and (int)f + ( 1<<(FLOAT_INT_BITS-1) ) < ( 1 << FLOAT_INT_BITS )\n// the float will be sent with FLOAT_INT_BITS, otherwise all 32 bits will be sent\n#define\tFLOAT_INT_BITS\t13\n#define\tFLOAT_INT_BIAS\t(1<<(FLOAT_INT_BITS-1))\n\n/*\n==================\nMSG_WriteDeltaEntity\n\nWrites part of a packetentities message, including the entity number.\nCan delta from either a baseline or a previous packet_entity\nIf to is NULL, a remove entity update will be sent\nIf force is not set, then nothing at all will be generated if the entity is\nidentical, under the assumption that the in-order delta code will catch it.\n==================\n*/\nvoid MSG_WriteDeltaEntity( msg_t *msg, struct entityState_s *from, struct entityState_s *to, \n\t\t\t\t\t\t   qboolean force ) {\n\tint\t\t\ti, lc;\n\tint\t\t\tnumFields;\n\tnetField_t\t*field;\n\tint\t\t\ttrunc;\n\tfloat\t\tfullFloat;\n\tint\t\t\t*fromF, *toF;\n\n\tnumFields = sizeof(entityStateFields)/sizeof(entityStateFields[0]);\n\n\t// all fields should be 32 bits to avoid any compiler packing issues\n\t// the \"number\" field is not part of the field list\n\t// if this assert fails, someone added a field to the entityState_t\n\t// struct without updating the message fields\n\tassert( numFields + 1 == sizeof( *from )/4 );\n\n\t// a NULL to is a delta remove message\n\tif ( to == NULL ) {\n\t\tif ( from == NULL ) {\n\t\t\treturn;\n\t\t}\n\t\tMSG_WriteBits( msg, from->number, GENTITYNUM_BITS );\n\t\tMSG_WriteBits( msg, 1, 1 );\n\t\treturn;\n\t}\n\n\tif ( to->number < 0 || to->number >= MAX_GENTITIES ) {\n\t\tCom_Error (ERR_FATAL, \"MSG_WriteDeltaEntity: Bad entity number: %i\", to->number );\n\t}\n\n\tlc = 0;\n\t// build the change vector as bytes so it is endien independent\n\tfor ( i = 0, field = entityStateFields ; i < numFields ; i++, field++ ) {\n\t\tfromF = (int *)( (byte *)from + field->offset );\n\t\ttoF = (int *)( (byte *)to + field->offset );\n\t\tif ( *fromF != *toF ) {\n\t\t\tlc = i+1;\n\t\t}\n\t}\n\n\tif ( lc == 0 ) {\n\t\t// nothing at all changed\n\t\tif ( !force ) {\n\t\t\treturn;\t\t// nothing at all\n\t\t}\n\t\t// write two bits for no change\n\t\tMSG_WriteBits( msg, to->number, GENTITYNUM_BITS );\n\t\tMSG_WriteBits( msg, 0, 1 );\t\t// not removed\n\t\tMSG_WriteBits( msg, 0, 1 );\t\t// no delta\n\t\treturn;\n\t}\n\n\tMSG_WriteBits( msg, to->number, GENTITYNUM_BITS );\n\tMSG_WriteBits( msg, 0, 1 );\t\t\t// not removed\n\tMSG_WriteBits( msg, 1, 1 );\t\t\t// we have a delta\n\n\tMSG_WriteByte( msg, lc );\t// # of changes\n\n\toldsize += numFields;\n\n\tfor ( i = 0, field = entityStateFields ; i < lc ; i++, field++ ) {\n\t\tfromF = (int *)( (byte *)from + field->offset );\n\t\ttoF = (int *)( (byte *)to + field->offset );\n\n\t\tif ( *fromF == *toF ) {\n\t\t\tMSG_WriteBits( msg, 0, 1 );\t// no change\n\t\t\tcontinue;\n\t\t}\n\n\t\tMSG_WriteBits( msg, 1, 1 );\t// changed\n\n\t\tif ( field->bits == 0 ) {\n\t\t\t// float\n\t\t\tfullFloat = *(float *)toF;\n\t\t\ttrunc = (int)fullFloat;\n\n\t\t\tif (fullFloat == 0.0f) {\n\t\t\t\t\tMSG_WriteBits( msg, 0, 1 );\n\t\t\t\t\toldsize += FLOAT_INT_BITS;\n\t\t\t} else {\n\t\t\t\tMSG_WriteBits( msg, 1, 1 );\n\t\t\t\tif ( trunc == fullFloat && trunc + FLOAT_INT_BIAS >= 0 && \n\t\t\t\t\ttrunc + FLOAT_INT_BIAS < ( 1 << FLOAT_INT_BITS ) ) {\n\t\t\t\t\t// send as small integer\n\t\t\t\t\tMSG_WriteBits( msg, 0, 1 );\n\t\t\t\t\tMSG_WriteBits( msg, trunc + FLOAT_INT_BIAS, FLOAT_INT_BITS );\n\t\t\t\t} else {\n\t\t\t\t\t// send as full floating point value\n\t\t\t\t\tMSG_WriteBits( msg, 1, 1 );\n\t\t\t\t\tMSG_WriteBits( msg, *toF, 32 );\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (*toF == 0) {\n\t\t\t\tMSG_WriteBits( msg, 0, 1 );\n\t\t\t} else {\n\t\t\t\tMSG_WriteBits( msg, 1, 1 );\n\t\t\t\t// integer\n\t\t\t\tMSG_WriteBits( msg, *toF, field->bits );\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n==================\nMSG_ReadDeltaEntity\n\nThe entity number has already been read from the message, which\nis how the from state is identified.\n\nIf the delta removes the entity, entityState_t->number will be set to MAX_GENTITIES-1\n\nCan go from either a baseline or a previous packet_entity\n==================\n*/\nextern\tcvar_t\t*cl_shownet;\n\nvoid MSG_ReadDeltaEntity( msg_t *msg, entityState_t *from, entityState_t *to, \n\t\t\t\t\t\t int number) {\n\tint\t\t\ti, lc;\n\tint\t\t\tnumFields;\n\tnetField_t\t*field;\n\tint\t\t\t*fromF, *toF;\n\tint\t\t\tprint;\n\tint\t\t\ttrunc;\n\tint\t\t\tstartBit, endBit;\n\n\tif ( number < 0 || number >= MAX_GENTITIES) {\n\t\tCom_Error( ERR_DROP, \"Bad delta entity number: %i\", number );\n\t}\n\n\tif ( msg->bit == 0 ) {\n\t\tstartBit = msg->readcount * 8 - GENTITYNUM_BITS;\n\t} else {\n\t\tstartBit = ( msg->readcount - 1 ) * 8 + msg->bit - GENTITYNUM_BITS;\n\t}\n\n\t// check for a remove\n\tif ( MSG_ReadBits( msg, 1 ) == 1 ) {\n\t\tCom_Memset( to, 0, sizeof( *to ) );\t\n\t\tto->number = MAX_GENTITIES - 1;\n\t\tif ( cl_shownet->integer >= 2 || cl_shownet->integer == -1 ) {\n\t\t\tCom_Printf( \"%3i: #%-3i remove\\n\", msg->readcount, number );\n\t\t}\n\t\treturn;\n\t}\n\n\t// check for no delta\n\tif ( MSG_ReadBits( msg, 1 ) == 0 ) {\n\t\t*to = *from;\n\t\tto->number = number;\n\t\treturn;\n\t}\n\n\tnumFields = sizeof(entityStateFields)/sizeof(entityStateFields[0]);\n\tlc = MSG_ReadByte(msg);\n\n\t// shownet 2/3 will interleave with other printed info, -1 will\n\t// just print the delta records`\n\tif ( cl_shownet->integer >= 2 || cl_shownet->integer == -1 ) {\n\t\tprint = 1;\n\t\tCom_Printf( \"%3i: #%-3i \", msg->readcount, to->number );\n\t} else {\n\t\tprint = 0;\n\t}\n\n\tto->number = number;\n\n\tfor ( i = 0, field = entityStateFields ; i < lc ; i++, field++ ) {\n\t\tfromF = (int *)( (byte *)from + field->offset );\n\t\ttoF = (int *)( (byte *)to + field->offset );\n\n\t\tif ( ! MSG_ReadBits( msg, 1 ) ) {\n\t\t\t// no change\n\t\t\t*toF = *fromF;\n\t\t} else {\n\t\t\tif ( field->bits == 0 ) {\n\t\t\t\t// float\n\t\t\t\tif ( MSG_ReadBits( msg, 1 ) == 0 ) {\n\t\t\t\t\t\t*(float *)toF = 0.0f; \n\t\t\t\t} else {\n\t\t\t\t\tif ( MSG_ReadBits( msg, 1 ) == 0 ) {\n\t\t\t\t\t\t// integral float\n\t\t\t\t\t\ttrunc = MSG_ReadBits( msg, FLOAT_INT_BITS );\n\t\t\t\t\t\t// bias to allow equal parts positive and negative\n\t\t\t\t\t\ttrunc -= FLOAT_INT_BIAS;\n\t\t\t\t\t\t*(float *)toF = trunc; \n\t\t\t\t\t\tif ( print ) {\n\t\t\t\t\t\t\tCom_Printf( \"%s:%i \", field->name, trunc );\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// full floating point value\n\t\t\t\t\t\t*toF = MSG_ReadBits( msg, 32 );\n\t\t\t\t\t\tif ( print ) {\n\t\t\t\t\t\t\tCom_Printf( \"%s:%f \", field->name, *(float *)toF );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( MSG_ReadBits( msg, 1 ) == 0 ) {\n\t\t\t\t\t*toF = 0;\n\t\t\t\t} else {\n\t\t\t\t\t// integer\n\t\t\t\t\t*toF = MSG_ReadBits( msg, field->bits );\n\t\t\t\t\tif ( print ) {\n\t\t\t\t\t\tCom_Printf( \"%s:%i \", field->name, *toF );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n//\t\t\tpcount[i]++;\n\t\t}\n\t}\n\tfor ( i = lc, field = &entityStateFields[lc] ; i < numFields ; i++, field++ ) {\n\t\tfromF = (int *)( (byte *)from + field->offset );\n\t\ttoF = (int *)( (byte *)to + field->offset );\n\t\t// no change\n\t\t*toF = *fromF;\n\t}\n\n\tif ( print ) {\n\t\tif ( msg->bit == 0 ) {\n\t\t\tendBit = msg->readcount * 8 - GENTITYNUM_BITS;\n\t\t} else {\n\t\t\tendBit = ( msg->readcount - 1 ) * 8 + msg->bit - GENTITYNUM_BITS;\n\t\t}\n\t\tCom_Printf( \" (%i bits)\\n\", endBit - startBit  );\n\t}\n}\n\n\n/*\n============================================================================\n\nplyer_state_t communication\n\n============================================================================\n*/\n\n// using the stringizing operator to save typing...\n#define\tPSF(x) #x,(int)&((playerState_t*)0)->x\n\nnetField_t\tplayerStateFields[] = \n{\n{ PSF(commandTime), 32 },\t\t\t\t\n{ PSF(origin[0]), 0 },\n{ PSF(origin[1]), 0 },\n{ PSF(bobCycle), 8 },\n{ PSF(velocity[0]), 0 },\n{ PSF(velocity[1]), 0 },\n{ PSF(viewangles[1]), 0 },\n{ PSF(viewangles[0]), 0 },\n{ PSF(weaponTime), -16 },\n{ PSF(origin[2]), 0 },\n{ PSF(velocity[2]), 0 },\n{ PSF(legsTimer), 8 },\n{ PSF(pm_time), -16 },\n{ PSF(eventSequence), 16 },\n{ PSF(torsoAnim), 8 },\n{ PSF(movementDir), 4 },\n{ PSF(events[0]), 8 },\n{ PSF(legsAnim), 8 },\n{ PSF(events[1]), 8 },\n{ PSF(pm_flags), 16 },\n{ PSF(groundEntityNum), GENTITYNUM_BITS },\n{ PSF(weaponstate), 4 },\n{ PSF(eFlags), 16 },\n{ PSF(externalEvent), 10 },\n{ PSF(gravity), 16 },\n{ PSF(speed), 16 },\n{ PSF(delta_angles[1]), 16 },\n{ PSF(externalEventParm), 8 },\n{ PSF(viewheight), -8 },\n{ PSF(damageEvent), 8 },\n{ PSF(damageYaw), 8 },\n{ PSF(damagePitch), 8 },\n{ PSF(damageCount), 8 },\n{ PSF(generic1), 8 },\n{ PSF(pm_type), 8 },\t\t\t\t\t\n{ PSF(delta_angles[0]), 16 },\n{ PSF(delta_angles[2]), 16 },\n{ PSF(torsoTimer), 12 },\n{ PSF(eventParms[0]), 8 },\n{ PSF(eventParms[1]), 8 },\n{ PSF(clientNum), 8 },\n{ PSF(weapon), 5 },\n{ PSF(viewangles[2]), 0 },\n{ PSF(grapplePoint[0]), 0 },\n{ PSF(grapplePoint[1]), 0 },\n{ PSF(grapplePoint[2]), 0 },\n{ PSF(jumppad_ent), 10 },\n{ PSF(loopSound), 16 }\n};\n\n/*\n=============\nMSG_WriteDeltaPlayerstate\n\n=============\n*/\nvoid MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct playerState_s *to ) {\n\tint\t\t\t\ti;\n\tplayerState_t\tdummy;\n\tint\t\t\t\tstatsbits;\n\tint\t\t\t\tpersistantbits;\n\tint\t\t\t\tammobits;\n\tint\t\t\t\tpowerupbits;\n\tint\t\t\t\tnumFields;\n\tint\t\t\t\tc;\n\tnetField_t\t\t*field;\n\tint\t\t\t\t*fromF, *toF;\n\tfloat\t\t\tfullFloat;\n\tint\t\t\t\ttrunc, lc;\n\n\tif (!from) {\n\t\tfrom = &dummy;\n\t\tCom_Memset (&dummy, 0, sizeof(dummy));\n\t}\n\n\tc = msg->cursize;\n\n\tnumFields = sizeof( playerStateFields ) / sizeof( playerStateFields[0] );\n\n\tlc = 0;\n\tfor ( i = 0, field = playerStateFields ; i < numFields ; i++, field++ ) {\n\t\tfromF = (int *)( (byte *)from + field->offset );\n\t\ttoF = (int *)( (byte *)to + field->offset );\n\t\tif ( *fromF != *toF ) {\n\t\t\tlc = i+1;\n\t\t}\n\t}\n\n\tMSG_WriteByte( msg, lc );\t// # of changes\n\n\toldsize += numFields - lc;\n\n\tfor ( i = 0, field = playerStateFields ; i < lc ; i++, field++ ) {\n\t\tfromF = (int *)( (byte *)from + field->offset );\n\t\ttoF = (int *)( (byte *)to + field->offset );\n\n\t\tif ( *fromF == *toF ) {\n\t\t\tMSG_WriteBits( msg, 0, 1 );\t// no change\n\t\t\tcontinue;\n\t\t}\n\n\t\tMSG_WriteBits( msg, 1, 1 );\t// changed\n//\t\tpcount[i]++;\n\n\t\tif ( field->bits == 0 ) {\n\t\t\t// float\n\t\t\tfullFloat = *(float *)toF;\n\t\t\ttrunc = (int)fullFloat;\n\n\t\t\tif ( trunc == fullFloat && trunc + FLOAT_INT_BIAS >= 0 && \n\t\t\t\ttrunc + FLOAT_INT_BIAS < ( 1 << FLOAT_INT_BITS ) ) {\n\t\t\t\t// send as small integer\n\t\t\t\tMSG_WriteBits( msg, 0, 1 );\n\t\t\t\tMSG_WriteBits( msg, trunc + FLOAT_INT_BIAS, FLOAT_INT_BITS );\n\t\t\t} else {\n\t\t\t\t// send as full floating point value\n\t\t\t\tMSG_WriteBits( msg, 1, 1 );\n\t\t\t\tMSG_WriteBits( msg, *toF, 32 );\n\t\t\t}\n\t\t} else {\n\t\t\t// integer\n\t\t\tMSG_WriteBits( msg, *toF, field->bits );\n\t\t}\n\t}\n\tc = msg->cursize - c;\n\n\n\t//\n\t// send the arrays\n\t//\n\tstatsbits = 0;\n\tfor (i=0 ; i<16 ; i++) {\n\t\tif (to->stats[i] != from->stats[i]) {\n\t\t\tstatsbits |= 1<<i;\n\t\t}\n\t}\n\tpersistantbits = 0;\n\tfor (i=0 ; i<16 ; i++) {\n\t\tif (to->persistant[i] != from->persistant[i]) {\n\t\t\tpersistantbits |= 1<<i;\n\t\t}\n\t}\n\tammobits = 0;\n\tfor (i=0 ; i<16 ; i++) {\n\t\tif (to->ammo[i] != from->ammo[i]) {\n\t\t\tammobits |= 1<<i;\n\t\t}\n\t}\n\tpowerupbits = 0;\n\tfor (i=0 ; i<16 ; i++) {\n\t\tif (to->powerups[i] != from->powerups[i]) {\n\t\t\tpowerupbits |= 1<<i;\n\t\t}\n\t}\n\n\tif (!statsbits && !persistantbits && !ammobits && !powerupbits) {\n\t\tMSG_WriteBits( msg, 0, 1 );\t// no change\n\t\toldsize += 4;\n\t\treturn;\n\t}\n\tMSG_WriteBits( msg, 1, 1 );\t// changed\n\n\tif ( statsbits ) {\n\t\tMSG_WriteBits( msg, 1, 1 );\t// changed\n\t\tMSG_WriteShort( msg, statsbits );\n\t\tfor (i=0 ; i<16 ; i++)\n\t\t\tif (statsbits & (1<<i) )\n\t\t\t\tMSG_WriteShort (msg, to->stats[i]);\n\t} else {\n\t\tMSG_WriteBits( msg, 0, 1 );\t// no change\n\t}\n\n\n\tif ( persistantbits ) {\n\t\tMSG_WriteBits( msg, 1, 1 );\t// changed\n\t\tMSG_WriteShort( msg, persistantbits );\n\t\tfor (i=0 ; i<16 ; i++)\n\t\t\tif (persistantbits & (1<<i) )\n\t\t\t\tMSG_WriteShort (msg, to->persistant[i]);\n\t} else {\n\t\tMSG_WriteBits( msg, 0, 1 );\t// no change\n\t}\n\n\n\tif ( ammobits ) {\n\t\tMSG_WriteBits( msg, 1, 1 );\t// changed\n\t\tMSG_WriteShort( msg, ammobits );\n\t\tfor (i=0 ; i<16 ; i++)\n\t\t\tif (ammobits & (1<<i) )\n\t\t\t\tMSG_WriteShort (msg, to->ammo[i]);\n\t} else {\n\t\tMSG_WriteBits( msg, 0, 1 );\t// no change\n\t}\n\n\n\tif ( powerupbits ) {\n\t\tMSG_WriteBits( msg, 1, 1 );\t// changed\n\t\tMSG_WriteShort( msg, powerupbits );\n\t\tfor (i=0 ; i<16 ; i++)\n\t\t\tif (powerupbits & (1<<i) )\n\t\t\t\tMSG_WriteLong( msg, to->powerups[i] );\n\t} else {\n\t\tMSG_WriteBits( msg, 0, 1 );\t// no change\n\t}\n}\n\n\n/*\n===================\nMSG_ReadDeltaPlayerstate\n===================\n*/\nvoid MSG_ReadDeltaPlayerstate (msg_t *msg, playerState_t *from, playerState_t *to ) {\n\tint\t\t\ti, lc;\n\tint\t\t\tbits;\n\tnetField_t\t*field;\n\tint\t\t\tnumFields;\n\tint\t\t\tstartBit, endBit;\n\tint\t\t\tprint;\n\tint\t\t\t*fromF, *toF;\n\tint\t\t\ttrunc;\n\tplayerState_t\tdummy;\n\n\tif ( !from ) {\n\t\tfrom = &dummy;\n\t\tCom_Memset( &dummy, 0, sizeof( dummy ) );\n\t}\n\t*to = *from;\n\n\tif ( msg->bit == 0 ) {\n\t\tstartBit = msg->readcount * 8 - GENTITYNUM_BITS;\n\t} else {\n\t\tstartBit = ( msg->readcount - 1 ) * 8 + msg->bit - GENTITYNUM_BITS;\n\t}\n\n\t// shownet 2/3 will interleave with other printed info, -2 will\n\t// just print the delta records\n\tif ( cl_shownet->integer >= 2 || cl_shownet->integer == -2 ) {\n\t\tprint = 1;\n\t\tCom_Printf( \"%3i: playerstate \", msg->readcount );\n\t} else {\n\t\tprint = 0;\n\t}\n\n\tnumFields = sizeof( playerStateFields ) / sizeof( playerStateFields[0] );\n\tlc = MSG_ReadByte(msg);\n\n\tfor ( i = 0, field = playerStateFields ; i < lc ; i++, field++ ) {\n\t\tfromF = (int *)( (byte *)from + field->offset );\n\t\ttoF = (int *)( (byte *)to + field->offset );\n\n\t\tif ( ! MSG_ReadBits( msg, 1 ) ) {\n\t\t\t// no change\n\t\t\t*toF = *fromF;\n\t\t} else {\n\t\t\tif ( field->bits == 0 ) {\n\t\t\t\t// float\n\t\t\t\tif ( MSG_ReadBits( msg, 1 ) == 0 ) {\n\t\t\t\t\t// integral float\n\t\t\t\t\ttrunc = MSG_ReadBits( msg, FLOAT_INT_BITS );\n\t\t\t\t\t// bias to allow equal parts positive and negative\n\t\t\t\t\ttrunc -= FLOAT_INT_BIAS;\n\t\t\t\t\t*(float *)toF = trunc; \n\t\t\t\t\tif ( print ) {\n\t\t\t\t\t\tCom_Printf( \"%s:%i \", field->name, trunc );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// full floating point value\n\t\t\t\t\t*toF = MSG_ReadBits( msg, 32 );\n\t\t\t\t\tif ( print ) {\n\t\t\t\t\t\tCom_Printf( \"%s:%f \", field->name, *(float *)toF );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// integer\n\t\t\t\t*toF = MSG_ReadBits( msg, field->bits );\n\t\t\t\tif ( print ) {\n\t\t\t\t\tCom_Printf( \"%s:%i \", field->name, *toF );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor ( i=lc,field = &playerStateFields[lc];i<numFields; i++, field++) {\n\t\tfromF = (int *)( (byte *)from + field->offset );\n\t\ttoF = (int *)( (byte *)to + field->offset );\n\t\t// no change\n\t\t*toF = *fromF;\n\t}\n\n\n\t// read the arrays\n\tif (MSG_ReadBits( msg, 1 ) ) {\n\t\t// parse stats\n\t\tif ( MSG_ReadBits( msg, 1 ) ) {\n\t\t\tLOG(\"PS_STATS\");\n\t\t\tbits = MSG_ReadShort (msg);\n\t\t\tfor (i=0 ; i<16 ; i++) {\n\t\t\t\tif (bits & (1<<i) ) {\n\t\t\t\t\tto->stats[i] = MSG_ReadShort(msg);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// parse persistant stats\n\t\tif ( MSG_ReadBits( msg, 1 ) ) {\n\t\t\tLOG(\"PS_PERSISTANT\");\n\t\t\tbits = MSG_ReadShort (msg);\n\t\t\tfor (i=0 ; i<16 ; i++) {\n\t\t\t\tif (bits & (1<<i) ) {\n\t\t\t\t\tto->persistant[i] = MSG_ReadShort(msg);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// parse ammo\n\t\tif ( MSG_ReadBits( msg, 1 ) ) {\n\t\t\tLOG(\"PS_AMMO\");\n\t\t\tbits = MSG_ReadShort (msg);\n\t\t\tfor (i=0 ; i<16 ; i++) {\n\t\t\t\tif (bits & (1<<i) ) {\n\t\t\t\t\tto->ammo[i] = MSG_ReadShort(msg);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// parse powerups\n\t\tif ( MSG_ReadBits( msg, 1 ) ) {\n\t\t\tLOG(\"PS_POWERUPS\");\n\t\t\tbits = MSG_ReadShort (msg);\n\t\t\tfor (i=0 ; i<16 ; i++) {\n\t\t\t\tif (bits & (1<<i) ) {\n\t\t\t\t\tto->powerups[i] = MSG_ReadLong(msg);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( print ) {\n\t\tif ( msg->bit == 0 ) {\n\t\t\tendBit = msg->readcount * 8 - GENTITYNUM_BITS;\n\t\t} else {\n\t\t\tendBit = ( msg->readcount - 1 ) * 8 + msg->bit - GENTITYNUM_BITS;\n\t\t}\n\t\tCom_Printf( \" (%i bits)\\n\", endBit - startBit  );\n\t}\n}\n\nint msg_hData[256] = {\n250315,\t\t\t// 0\n41193,\t\t\t// 1\n6292,\t\t\t// 2\n7106,\t\t\t// 3\n3730,\t\t\t// 4\n3750,\t\t\t// 5\n6110,\t\t\t// 6\n23283,\t\t\t// 7\n33317,\t\t\t// 8\n6950,\t\t\t// 9\n7838,\t\t\t// 10\n9714,\t\t\t// 11\n9257,\t\t\t// 12\n17259,\t\t\t// 13\n3949,\t\t\t// 14\n1778,\t\t\t// 15\n8288,\t\t\t// 16\n1604,\t\t\t// 17\n1590,\t\t\t// 18\n1663,\t\t\t// 19\n1100,\t\t\t// 20\n1213,\t\t\t// 21\n1238,\t\t\t// 22\n1134,\t\t\t// 23\n1749,\t\t\t// 24\n1059,\t\t\t// 25\n1246,\t\t\t// 26\n1149,\t\t\t// 27\n1273,\t\t\t// 28\n4486,\t\t\t// 29\n2805,\t\t\t// 30\n3472,\t\t\t// 31\n21819,\t\t\t// 32\n1159,\t\t\t// 33\n1670,\t\t\t// 34\n1066,\t\t\t// 35\n1043,\t\t\t// 36\n1012,\t\t\t// 37\n1053,\t\t\t// 38\n1070,\t\t\t// 39\n1726,\t\t\t// 40\n888,\t\t\t// 41\n1180,\t\t\t// 42\n850,\t\t\t// 43\n960,\t\t\t// 44\n780,\t\t\t// 45\n1752,\t\t\t// 46\n3296,\t\t\t// 47\n10630,\t\t\t// 48\n4514,\t\t\t// 49\n5881,\t\t\t// 50\n2685,\t\t\t// 51\n4650,\t\t\t// 52\n3837,\t\t\t// 53\n2093,\t\t\t// 54\n1867,\t\t\t// 55\n2584,\t\t\t// 56\n1949,\t\t\t// 57\n1972,\t\t\t// 58\n940,\t\t\t// 59\n1134,\t\t\t// 60\n1788,\t\t\t// 61\n1670,\t\t\t// 62\n1206,\t\t\t// 63\n5719,\t\t\t// 64\n6128,\t\t\t// 65\n7222,\t\t\t// 66\n6654,\t\t\t// 67\n3710,\t\t\t// 68\n3795,\t\t\t// 69\n1492,\t\t\t// 70\n1524,\t\t\t// 71\n2215,\t\t\t// 72\n1140,\t\t\t// 73\n1355,\t\t\t// 74\n971,\t\t\t// 75\n2180,\t\t\t// 76\n1248,\t\t\t// 77\n1328,\t\t\t// 78\n1195,\t\t\t// 79\n1770,\t\t\t// 80\n1078,\t\t\t// 81\n1264,\t\t\t// 82\n1266,\t\t\t// 83\n1168,\t\t\t// 84\n965,\t\t\t// 85\n1155,\t\t\t// 86\n1186,\t\t\t// 87\n1347,\t\t\t// 88\n1228,\t\t\t// 89\n1529,\t\t\t// 90\n1600,\t\t\t// 91\n2617,\t\t\t// 92\n2048,\t\t\t// 93\n2546,\t\t\t// 94\n3275,\t\t\t// 95\n2410,\t\t\t// 96\n3585,\t\t\t// 97\n2504,\t\t\t// 98\n2800,\t\t\t// 99\n2675,\t\t\t// 100\n6146,\t\t\t// 101\n3663,\t\t\t// 102\n2840,\t\t\t// 103\n14253,\t\t\t// 104\n3164,\t\t\t// 105\n2221,\t\t\t// 106\n1687,\t\t\t// 107\n3208,\t\t\t// 108\n2739,\t\t\t// 109\n3512,\t\t\t// 110\n4796,\t\t\t// 111\n4091,\t\t\t// 112\n3515,\t\t\t// 113\n5288,\t\t\t// 114\n4016,\t\t\t// 115\n7937,\t\t\t// 116\n6031,\t\t\t// 117\n5360,\t\t\t// 118\n3924,\t\t\t// 119\n4892,\t\t\t// 120\n3743,\t\t\t// 121\n4566,\t\t\t// 122\n4807,\t\t\t// 123\n5852,\t\t\t// 124\n6400,\t\t\t// 125\n6225,\t\t\t// 126\n8291,\t\t\t// 127\n23243,\t\t\t// 128\n7838,\t\t\t// 129\n7073,\t\t\t// 130\n8935,\t\t\t// 131\n5437,\t\t\t// 132\n4483,\t\t\t// 133\n3641,\t\t\t// 134\n5256,\t\t\t// 135\n5312,\t\t\t// 136\n5328,\t\t\t// 137\n5370,\t\t\t// 138\n3492,\t\t\t// 139\n2458,\t\t\t// 140\n1694,\t\t\t// 141\n1821,\t\t\t// 142\n2121,\t\t\t// 143\n1916,\t\t\t// 144\n1149,\t\t\t// 145\n1516,\t\t\t// 146\n1367,\t\t\t// 147\n1236,\t\t\t// 148\n1029,\t\t\t// 149\n1258,\t\t\t// 150\n1104,\t\t\t// 151\n1245,\t\t\t// 152\n1006,\t\t\t// 153\n1149,\t\t\t// 154\n1025,\t\t\t// 155\n1241,\t\t\t// 156\n952,\t\t\t// 157\n1287,\t\t\t// 158\n997,\t\t\t// 159\n1713,\t\t\t// 160\n1009,\t\t\t// 161\n1187,\t\t\t// 162\n879,\t\t\t// 163\n1099,\t\t\t// 164\n929,\t\t\t// 165\n1078,\t\t\t// 166\n951,\t\t\t// 167\n1656,\t\t\t// 168\n930,\t\t\t// 169\n1153,\t\t\t// 170\n1030,\t\t\t// 171\n1262,\t\t\t// 172\n1062,\t\t\t// 173\n1214,\t\t\t// 174\n1060,\t\t\t// 175\n1621,\t\t\t// 176\n930,\t\t\t// 177\n1106,\t\t\t// 178\n912,\t\t\t// 179\n1034,\t\t\t// 180\n892,\t\t\t// 181\n1158,\t\t\t// 182\n990,\t\t\t// 183\n1175,\t\t\t// 184\n850,\t\t\t// 185\n1121,\t\t\t// 186\n903,\t\t\t// 187\n1087,\t\t\t// 188\n920,\t\t\t// 189\n1144,\t\t\t// 190\n1056,\t\t\t// 191\n3462,\t\t\t// 192\n2240,\t\t\t// 193\n4397,\t\t\t// 194\n12136,\t\t\t// 195\n7758,\t\t\t// 196\n1345,\t\t\t// 197\n1307,\t\t\t// 198\n3278,\t\t\t// 199\n1950,\t\t\t// 200\n886,\t\t\t// 201\n1023,\t\t\t// 202\n1112,\t\t\t// 203\n1077,\t\t\t// 204\n1042,\t\t\t// 205\n1061,\t\t\t// 206\n1071,\t\t\t// 207\n1484,\t\t\t// 208\n1001,\t\t\t// 209\n1096,\t\t\t// 210\n915,\t\t\t// 211\n1052,\t\t\t// 212\n995,\t\t\t// 213\n1070,\t\t\t// 214\n876,\t\t\t// 215\n1111,\t\t\t// 216\n851,\t\t\t// 217\n1059,\t\t\t// 218\n805,\t\t\t// 219\n1112,\t\t\t// 220\n923,\t\t\t// 221\n1103,\t\t\t// 222\n817,\t\t\t// 223\n1899,\t\t\t// 224\n1872,\t\t\t// 225\n976,\t\t\t// 226\n841,\t\t\t// 227\n1127,\t\t\t// 228\n956,\t\t\t// 229\n1159,\t\t\t// 230\n950,\t\t\t// 231\n7791,\t\t\t// 232\n954,\t\t\t// 233\n1289,\t\t\t// 234\n933,\t\t\t// 235\n1127,\t\t\t// 236\n3207,\t\t\t// 237\n1020,\t\t\t// 238\n927,\t\t\t// 239\n1355,\t\t\t// 240\n768,\t\t\t// 241\n1040,\t\t\t// 242\n745,\t\t\t// 243\n952,\t\t\t// 244\n805,\t\t\t// 245\n1073,\t\t\t// 246\n740,\t\t\t// 247\n1013,\t\t\t// 248\n805,\t\t\t// 249\n1008,\t\t\t// 250\n796,\t\t\t// 251\n996,\t\t\t// 252\n1057,\t\t\t// 253\n11457,\t\t\t// 254\n13504,\t\t\t// 255\n};\n\nvoid MSG_initHuffman() {\n\tint i,j;\n\n\tmsgInit = qtrue;\n\tHuff_Init(&msgHuff);\n\tfor(i=0;i<256;i++) {\n\t\tfor (j=0;j<msg_hData[i];j++) {\n\t\t\tHuff_addRef(&msgHuff.compressor,\t(byte)i);\t\t\t// Do update\n\t\t\tHuff_addRef(&msgHuff.decompressor,\t(byte)i);\t\t\t// Do update\n\t\t}\n\t}\n}\n\n/*\nvoid MSG_NUinitHuffman() {\n\tbyte\t*data;\n\tint\t\tsize, i, ch;\n\tint\t\tarray[256];\n\n\tmsgInit = qtrue;\n\n\tHuff_Init(&msgHuff);\n\t// load it in\n\tsize = FS_ReadFile( \"netchan/netchan.bin\", (void **)&data );\n\n\tfor(i=0;i<256;i++) {\n\t\tarray[i] = 0;\n\t}\n\tfor(i=0;i<size;i++) {\n\t\tch = data[i];\n\t\tHuff_addRef(&msgHuff.compressor,\tch);\t\t\t// Do update\n\t\tHuff_addRef(&msgHuff.decompressor,\tch);\t\t\t// Do update\n\t\tarray[ch]++;\n\t}\n\tCom_Printf(\"msg_hData {\\n\");\n\tfor(i=0;i<256;i++) {\n\t\tif (array[i] == 0) {\n\t\t\tHuff_addRef(&msgHuff.compressor,\ti);\t\t\t// Do update\n\t\t\tHuff_addRef(&msgHuff.decompressor,\ti);\t\t\t// Do update\n\t\t}\n\t\tCom_Printf(\"%d,\t\t\t// %d\\n\", array[i], i);\n\t}\n\tCom_Printf(\"};\\n\");\n\tFS_FreeFile( data );\n\tCbuf_AddText( \"condump dump.txt\\n\" );\n}\n*/\n\n//===========================================================================\n"
  },
  {
    "path": "code/qcommon/net_chan.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"../game/q_shared.h\"\n#include \"qcommon.h\"\n\n/*\n\npacket header\n-------------\n4\toutgoing sequence.  high bit will be set if this is a fragmented message\n[2\tqport (only for client to server)]\n[2\tfragment start byte]\n[2\tfragment length. if < FRAGMENT_SIZE, this is the last fragment]\n\nif the sequence number is -1, the packet should be handled as an out-of-band\nmessage instead of as part of a netcon.\n\nAll fragments will have the same sequence numbers.\n\nThe qport field is a workaround for bad address translating routers that\nsometimes remap the client's source port on a packet during gameplay.\n\nIf the base part of the net address matches and the qport matches, then the\nchannel matches even if the IP port differs.  The IP port should be updated\nto the new value before sending out any replies.\n\n*/\n\n\n#define\tMAX_PACKETLEN\t\t\t1400\t\t// max size of a network packet\n\n#define\tFRAGMENT_SIZE\t\t\t(MAX_PACKETLEN - 100)\n#define\tPACKET_HEADER\t\t\t10\t\t\t// two ints and a short\n\n#define\tFRAGMENT_BIT\t(1<<31)\n\ncvar_t\t\t*showpackets;\ncvar_t\t\t*showdrop;\ncvar_t\t\t*qport;\n\nstatic char *netsrcString[2] = {\n\t\"client\",\n\t\"server\"\n};\n\n/*\n===============\nNetchan_Init\n\n===============\n*/\nvoid Netchan_Init( int port ) {\n\tport &= 0xffff;\n\tshowpackets = Cvar_Get (\"showpackets\", \"0\", CVAR_TEMP );\n\tshowdrop = Cvar_Get (\"showdrop\", \"0\", CVAR_TEMP );\n\tqport = Cvar_Get (\"net_qport\", va(\"%i\", port), CVAR_INIT );\n}\n\n/*\n==============\nNetchan_Setup\n\ncalled to open a channel to a remote system\n==============\n*/\nvoid Netchan_Setup( netsrc_t sock, netchan_t *chan, netadr_t adr, int qport ) {\n\tCom_Memset (chan, 0, sizeof(*chan));\n\t\n\tchan->sock = sock;\n\tchan->remoteAddress = adr;\n\tchan->qport = qport;\n\tchan->incomingSequence = 0;\n\tchan->outgoingSequence = 1;\n}\n\n// TTimo: unused, commenting out to make gcc happy\n#if 0\n/*\n==============\nNetchan_ScramblePacket\n\nA probably futile attempt to make proxy hacking somewhat\nmore difficult.\n==============\n*/\n#define\tSCRAMBLE_START\t6\nstatic void Netchan_ScramblePacket( msg_t *buf ) {\n\tunsigned\tseed;\n\tint\t\t\ti, j, c, mask, temp;\n\tint\t\t\tseq[MAX_PACKETLEN];\n\n\tseed = ( LittleLong( *(unsigned *)buf->data ) * 3 ) ^ ( buf->cursize * 123 );\n\tc = buf->cursize;\n\tif ( c <= SCRAMBLE_START ) {\n\t\treturn;\n\t}\n\tif ( c > MAX_PACKETLEN ) {\n\t\tCom_Error( ERR_DROP, \"MAX_PACKETLEN\" );\n\t}\n\n\t// generate a sequence of \"random\" numbers\n\tfor (i = 0 ; i < c ; i++) {\n\t\tseed = (119 * seed + 1);\n\t\tseq[i] = seed;\n\t}\n\n\t// transpose each character\n\tfor ( mask = 1 ; mask < c-SCRAMBLE_START ; mask = ( mask << 1 ) + 1 ) {\n\t}\n\tmask >>= 1;\n\tfor (i = SCRAMBLE_START ; i < c ; i++) {\n\t\tj = SCRAMBLE_START + ( seq[i] & mask );\n\t\ttemp = buf->data[j];\n\t\tbuf->data[j] = buf->data[i];\n\t\tbuf->data[i] = temp;\n\t}\n\n\t// byte xor the data after the header\n\tfor (i = SCRAMBLE_START ; i < c ; i++) {\n\t\tbuf->data[i] ^= seq[i];\n\t}\n}\n\nstatic void Netchan_UnScramblePacket( msg_t *buf ) {\n\tunsigned\tseed;\n\tint\t\t\ti, j, c, mask, temp;\n\tint\t\t\tseq[MAX_PACKETLEN];\n\n\tseed = ( LittleLong( *(unsigned *)buf->data ) * 3 ) ^ ( buf->cursize * 123 );\n\tc = buf->cursize;\n\tif ( c <= SCRAMBLE_START ) {\n\t\treturn;\n\t}\n\tif ( c > MAX_PACKETLEN ) {\n\t\tCom_Error( ERR_DROP, \"MAX_PACKETLEN\" );\n\t}\n\n\t// generate a sequence of \"random\" numbers\n\tfor (i = 0 ; i < c ; i++) {\n\t\tseed = (119 * seed + 1);\n\t\tseq[i] = seed;\n\t}\n\n\t// byte xor the data after the header\n\tfor (i = SCRAMBLE_START ; i < c ; i++) {\n\t\tbuf->data[i] ^= seq[i];\n\t}\n\n\t// transpose each character in reverse order\n\tfor ( mask = 1 ; mask < c-SCRAMBLE_START ; mask = ( mask << 1 ) + 1 ) {\n\t}\n\tmask >>= 1;\n\tfor (i = c-1 ; i >= SCRAMBLE_START ; i--) {\n\t\tj = SCRAMBLE_START + ( seq[i] & mask );\n\t\ttemp = buf->data[j];\n\t\tbuf->data[j] = buf->data[i];\n\t\tbuf->data[i] = temp;\n\t}\n}\n#endif\n\n/*\n=================\nNetchan_TransmitNextFragment\n\nSend one fragment of the current message\n=================\n*/\nvoid Netchan_TransmitNextFragment( netchan_t *chan ) {\n\tmsg_t\t\tsend;\n\tbyte\t\tsend_buf[MAX_PACKETLEN];\n\tint\t\t\tfragmentLength;\n\n\t// write the packet header\n\tMSG_InitOOB (&send, send_buf, sizeof(send_buf));\t\t\t\t// <-- only do the oob here\n\n\tMSG_WriteLong( &send, chan->outgoingSequence | FRAGMENT_BIT );\n\n\t// send the qport if we are a client\n\tif ( chan->sock == NS_CLIENT ) {\n\t\tMSG_WriteShort( &send, qport->integer );\n\t}\n\n\t// copy the reliable message to the packet first\n\tfragmentLength = FRAGMENT_SIZE;\n\tif ( chan->unsentFragmentStart  + fragmentLength > chan->unsentLength ) {\n\t\tfragmentLength = chan->unsentLength - chan->unsentFragmentStart;\n\t}\n\n\tMSG_WriteShort( &send, chan->unsentFragmentStart );\n\tMSG_WriteShort( &send, fragmentLength );\n\tMSG_WriteData( &send, chan->unsentBuffer + chan->unsentFragmentStart, fragmentLength );\n\n\t// send the datagram\n\tNET_SendPacket( chan->sock, send.cursize, send.data, chan->remoteAddress );\n\n\tif ( showpackets->integer ) {\n\t\tCom_Printf (\"%s send %4i : s=%i fragment=%i,%i\\n\"\n\t\t\t, netsrcString[ chan->sock ]\n\t\t\t, send.cursize\n\t\t\t, chan->outgoingSequence\n\t\t\t, chan->unsentFragmentStart, fragmentLength);\n\t}\n\n\tchan->unsentFragmentStart += fragmentLength;\n\n\t// this exit condition is a little tricky, because a packet\n\t// that is exactly the fragment length still needs to send\n\t// a second packet of zero length so that the other side\n\t// can tell there aren't more to follow\n\tif ( chan->unsentFragmentStart == chan->unsentLength && fragmentLength != FRAGMENT_SIZE ) {\n\t\tchan->outgoingSequence++;\n\t\tchan->unsentFragments = qfalse;\n\t}\n}\n\n\n/*\n===============\nNetchan_Transmit\n\nSends a message to a connection, fragmenting if necessary\nA 0 length will still generate a packet.\n================\n*/\nvoid Netchan_Transmit( netchan_t *chan, int length, const byte *data ) {\n\tmsg_t\t\tsend;\n\tbyte\t\tsend_buf[MAX_PACKETLEN];\n\n\tif ( length > MAX_MSGLEN ) {\n\t\tCom_Error( ERR_DROP, \"Netchan_Transmit: length = %i\", length );\n\t}\n\tchan->unsentFragmentStart = 0;\n\n\t// fragment large reliable messages\n\tif ( length >= FRAGMENT_SIZE ) {\n\t\tchan->unsentFragments = qtrue;\n\t\tchan->unsentLength = length;\n\t\tCom_Memcpy( chan->unsentBuffer, data, length );\n\n\t\t// only send the first fragment now\n\t\tNetchan_TransmitNextFragment( chan );\n\n\t\treturn;\n\t}\n\n\t// write the packet header\n\tMSG_InitOOB (&send, send_buf, sizeof(send_buf));\n\n\tMSG_WriteLong( &send, chan->outgoingSequence );\n\tchan->outgoingSequence++;\n\n\t// send the qport if we are a client\n\tif ( chan->sock == NS_CLIENT ) {\n\t\tMSG_WriteShort( &send, qport->integer );\n\t}\n\n\tMSG_WriteData( &send, data, length );\n\n\t// send the datagram\n\tNET_SendPacket( chan->sock, send.cursize, send.data, chan->remoteAddress );\n\n\tif ( showpackets->integer ) {\n\t\tCom_Printf( \"%s send %4i : s=%i ack=%i\\n\"\n\t\t\t, netsrcString[ chan->sock ]\n\t\t\t, send.cursize\n\t\t\t, chan->outgoingSequence - 1\n\t\t\t, chan->incomingSequence );\n\t}\n}\n\n/*\n=================\nNetchan_Process\n\nReturns qfalse if the message should not be processed due to being\nout of order or a fragment.\n\nMsg must be large enough to hold MAX_MSGLEN, because if this is the\nfinal fragment of a multi-part message, the entire thing will be\ncopied out.\n=================\n*/\nqboolean Netchan_Process( netchan_t *chan, msg_t *msg ) {\n\tint\t\t\tsequence;\n\tint\t\t\tqport;\n\tint\t\t\tfragmentStart, fragmentLength;\n\tqboolean\tfragmented;\n\n\t// XOR unscramble all data in the packet after the header\n//\tNetchan_UnScramblePacket( msg );\n\n\t// get sequence numbers\t\t\n\tMSG_BeginReadingOOB( msg );\n\tsequence = MSG_ReadLong( msg );\n\n\t// check for fragment information\n\tif ( sequence & FRAGMENT_BIT ) {\n\t\tsequence &= ~FRAGMENT_BIT;\n\t\tfragmented = qtrue;\n\t} else {\n\t\tfragmented = qfalse;\n\t}\n\n\t// read the qport if we are a server\n\tif ( chan->sock == NS_SERVER ) {\n\t\tqport = MSG_ReadShort( msg );\n\t}\n\n\t// read the fragment information\n\tif ( fragmented ) {\n\t\tfragmentStart = MSG_ReadShort( msg );\n\t\tfragmentLength = MSG_ReadShort( msg );\n\t} else {\n\t\tfragmentStart = 0;\t\t// stop warning message\n\t\tfragmentLength = 0;\n\t}\n\n\tif ( showpackets->integer ) {\n\t\tif ( fragmented ) {\n\t\t\tCom_Printf( \"%s recv %4i : s=%i fragment=%i,%i\\n\"\n\t\t\t\t, netsrcString[ chan->sock ]\n\t\t\t\t, msg->cursize\n\t\t\t\t, sequence\n\t\t\t\t, fragmentStart, fragmentLength );\n\t\t} else {\n\t\t\tCom_Printf( \"%s recv %4i : s=%i\\n\"\n\t\t\t\t, netsrcString[ chan->sock ]\n\t\t\t\t, msg->cursize\n\t\t\t\t, sequence );\n\t\t}\n\t}\n\n\t//\n\t// discard out of order or duplicated packets\n\t//\n\tif ( sequence <= chan->incomingSequence ) {\n\t\tif ( showdrop->integer || showpackets->integer ) {\n\t\t\tCom_Printf( \"%s:Out of order packet %i at %i\\n\"\n\t\t\t\t, NET_AdrToString( chan->remoteAddress )\n\t\t\t\t,  sequence\n\t\t\t\t, chan->incomingSequence );\n\t\t}\n\t\treturn qfalse;\n\t}\n\n\t//\n\t// dropped packets don't keep the message from being used\n\t//\n\tchan->dropped = sequence - (chan->incomingSequence+1);\n\tif ( chan->dropped > 0 ) {\n\t\tif ( showdrop->integer || showpackets->integer ) {\n\t\t\tCom_Printf( \"%s:Dropped %i packets at %i\\n\"\n\t\t\t, NET_AdrToString( chan->remoteAddress )\n\t\t\t, chan->dropped\n\t\t\t, sequence );\n\t\t}\n\t}\n\t\n\n\t//\n\t// if this is the final framgent of a reliable message,\n\t// bump incoming_reliable_sequence \n\t//\n\tif ( fragmented ) {\n\t\t// TTimo\n\t\t// make sure we add the fragments in correct order\n\t\t// either a packet was dropped, or we received this one too soon\n\t\t// we don't reconstruct the fragments. we will wait till this fragment gets to us again\n\t\t// (NOTE: we could probably try to rebuild by out of order chunks if needed)\n\t\tif ( sequence != chan->fragmentSequence ) {\n\t\t\tchan->fragmentSequence = sequence;\n\t\t\tchan->fragmentLength = 0;\n\t\t}\n\n\t\t// if we missed a fragment, dump the message\n\t\tif ( fragmentStart != chan->fragmentLength ) {\n\t\t\tif ( showdrop->integer || showpackets->integer ) {\n\t\t\t\tCom_Printf( \"%s:Dropped a message fragment\\n\"\n\t\t\t\t, NET_AdrToString( chan->remoteAddress )\n\t\t\t\t, sequence);\n\t\t\t}\n\t\t\t// we can still keep the part that we have so far,\n\t\t\t// so we don't need to clear chan->fragmentLength\n\t\t\treturn qfalse;\n\t\t}\n\n\t\t// copy the fragment to the fragment buffer\n\t\tif ( fragmentLength < 0 || msg->readcount + fragmentLength > msg->cursize ||\n\t\t\tchan->fragmentLength + fragmentLength > sizeof( chan->fragmentBuffer ) ) {\n\t\t\tif ( showdrop->integer || showpackets->integer ) {\n\t\t\t\tCom_Printf (\"%s:illegal fragment length\\n\"\n\t\t\t\t, NET_AdrToString (chan->remoteAddress ) );\n\t\t\t}\n\t\t\treturn qfalse;\n\t\t}\n\n\t\tCom_Memcpy( chan->fragmentBuffer + chan->fragmentLength, \n\t\t\tmsg->data + msg->readcount, fragmentLength );\n\n\t\tchan->fragmentLength += fragmentLength;\n\n\t\t// if this wasn't the last fragment, don't process anything\n\t\tif ( fragmentLength == FRAGMENT_SIZE ) {\n\t\t\treturn qfalse;\n\t\t}\n\n\t\tif ( chan->fragmentLength > msg->maxsize ) {\n\t\t\tCom_Printf( \"%s:fragmentLength %i > msg->maxsize\\n\"\n\t\t\t\t, NET_AdrToString (chan->remoteAddress ),\n\t\t\t\tchan->fragmentLength );\n\t\t\treturn qfalse;\n\t\t}\n\n\t\t// copy the full message over the partial fragment\n\n\t\t// make sure the sequence number is still there\n\t\t*(int *)msg->data = LittleLong( sequence );\n\n\t\tCom_Memcpy( msg->data + 4, chan->fragmentBuffer, chan->fragmentLength );\n\t\tmsg->cursize = chan->fragmentLength + 4;\n\t\tchan->fragmentLength = 0;\n\t\tmsg->readcount = 4;\t// past the sequence number\n\t\tmsg->bit = 32;\t// past the sequence number\n\n\t\t// TTimo\n\t\t// clients were not acking fragmented messages\n\t\tchan->incomingSequence = sequence;\n\t\t\n\t\treturn qtrue;\n\t}\n\n\t//\n\t// the message can now be read from the current message pointer\n\t//\n\tchan->incomingSequence = sequence;\n\n\treturn qtrue;\n}\n\n\n//==============================================================================\n\n/*\n===================\nNET_CompareBaseAdr\n\nCompares without the port\n===================\n*/\nqboolean\tNET_CompareBaseAdr (netadr_t a, netadr_t b)\n{\n\tif (a.type != b.type)\n\t\treturn qfalse;\n\n\tif (a.type == NA_LOOPBACK)\n\t\treturn qtrue;\n\n\tif (a.type == NA_IP)\n\t{\n\t\tif (a.ip[0] == b.ip[0] && a.ip[1] == b.ip[1] && a.ip[2] == b.ip[2] && a.ip[3] == b.ip[3])\n\t\t\treturn qtrue;\n\t\treturn qfalse;\n\t}\n\n\tif (a.type == NA_IPX)\n\t{\n\t\tif ((memcmp(a.ipx, b.ipx, 10) == 0))\n\t\t\treturn qtrue;\n\t\treturn qfalse;\n\t}\n\n\n\tCom_Printf (\"NET_CompareBaseAdr: bad address type\\n\");\n\treturn qfalse;\n}\n\nconst char\t*NET_AdrToString (netadr_t a)\n{\n\tstatic\tchar\ts[64];\n\n\tif (a.type == NA_LOOPBACK) {\n\t\tCom_sprintf (s, sizeof(s), \"loopback\");\n\t} else if (a.type == NA_BOT) {\n\t\tCom_sprintf (s, sizeof(s), \"bot\");\n\t} else if (a.type == NA_IP) {\n\t\tCom_sprintf (s, sizeof(s), \"%i.%i.%i.%i:%hu\",\n\t\t\ta.ip[0], a.ip[1], a.ip[2], a.ip[3], BigShort(a.port));\n\t} else {\n\t\tCom_sprintf (s, sizeof(s), \"%02x%02x%02x%02x.%02x%02x%02x%02x%02x%02x:%hu\",\n\t\ta.ipx[0], a.ipx[1], a.ipx[2], a.ipx[3], a.ipx[4], a.ipx[5], a.ipx[6], a.ipx[7], a.ipx[8], a.ipx[9], \n\t\tBigShort(a.port));\n\t}\n\n\treturn s;\n}\n\n\nqboolean\tNET_CompareAdr (netadr_t a, netadr_t b)\n{\n\tif (a.type != b.type)\n\t\treturn qfalse;\n\n\tif (a.type == NA_LOOPBACK)\n\t\treturn qtrue;\n\n\tif (a.type == NA_IP)\n\t{\n\t\tif (a.ip[0] == b.ip[0] && a.ip[1] == b.ip[1] && a.ip[2] == b.ip[2] && a.ip[3] == b.ip[3] && a.port == b.port)\n\t\t\treturn qtrue;\n\t\treturn qfalse;\n\t}\n\n\tif (a.type == NA_IPX)\n\t{\n\t\tif ((memcmp(a.ipx, b.ipx, 10) == 0) && a.port == b.port)\n\t\t\treturn qtrue;\n\t\treturn qfalse;\n\t}\n\n\tCom_Printf (\"NET_CompareAdr: bad address type\\n\");\n\treturn qfalse;\n}\n\n\nqboolean\tNET_IsLocalAddress( netadr_t adr ) {\n\treturn adr.type == NA_LOOPBACK;\n}\n\n\n\n/*\n=============================================================================\n\nLOOPBACK BUFFERS FOR LOCAL PLAYER\n\n=============================================================================\n*/\n\n// there needs to be enough loopback messages to hold a complete\n// gamestate of maximum size\n#define\tMAX_LOOPBACK\t16\n\ntypedef struct {\n\tbyte\tdata[MAX_PACKETLEN];\n\tint\t\tdatalen;\n} loopmsg_t;\n\ntypedef struct {\n\tloopmsg_t\tmsgs[MAX_LOOPBACK];\n\tint\t\t\tget, send;\n} loopback_t;\n\nloopback_t\tloopbacks[2];\n\n\nqboolean\tNET_GetLoopPacket (netsrc_t sock, netadr_t *net_from, msg_t *net_message)\n{\n\tint\t\ti;\n\tloopback_t\t*loop;\n\n\tloop = &loopbacks[sock];\n\n\tif (loop->send - loop->get > MAX_LOOPBACK)\n\t\tloop->get = loop->send - MAX_LOOPBACK;\n\n\tif (loop->get >= loop->send)\n\t\treturn qfalse;\n\n\ti = loop->get & (MAX_LOOPBACK-1);\n\tloop->get++;\n\n\tCom_Memcpy (net_message->data, loop->msgs[i].data, loop->msgs[i].datalen);\n\tnet_message->cursize = loop->msgs[i].datalen;\n\tCom_Memset (net_from, 0, sizeof(*net_from));\n\tnet_from->type = NA_LOOPBACK;\n\treturn qtrue;\n\n}\n\n\nvoid NET_SendLoopPacket (netsrc_t sock, int length, const void *data, netadr_t to)\n{\n\tint\t\ti;\n\tloopback_t\t*loop;\n\n\tloop = &loopbacks[sock^1];\n\n\ti = loop->send & (MAX_LOOPBACK-1);\n\tloop->send++;\n\n\tCom_Memcpy (loop->msgs[i].data, data, length);\n\tloop->msgs[i].datalen = length;\n}\n\n//=============================================================================\n\n\nvoid NET_SendPacket( netsrc_t sock, int length, const void *data, netadr_t to ) {\n\n\t// sequenced packets are shown in netchan, so just show oob\n\tif ( showpackets->integer && *(int *)data == -1 )\t{\n\t\tCom_Printf (\"send packet %4i\\n\", length);\n\t}\n\n\tif ( to.type == NA_LOOPBACK ) {\n\t\tNET_SendLoopPacket (sock, length, data, to);\n\t\treturn;\n\t}\n\tif ( to.type == NA_BOT ) {\n\t\treturn;\n\t}\n\tif ( to.type == NA_BAD ) {\n\t\treturn;\n\t}\n\n\tSys_SendPacket( length, data, to );\n}\n\n/*\n===============\nNET_OutOfBandPrint\n\nSends a text message in an out-of-band datagram\n================\n*/\nvoid QDECL NET_OutOfBandPrint( netsrc_t sock, netadr_t adr, const char *format, ... ) {\n\tva_list\t\targptr;\n\tchar\t\tstring[MAX_MSGLEN];\n\n\n\t// set the header\n\tstring[0] = -1;\n\tstring[1] = -1;\n\tstring[2] = -1;\n\tstring[3] = -1;\n\n\tva_start( argptr, format );\n\tvsprintf( string+4, format, argptr );\n\tva_end( argptr );\n\n\t// send the datagram\n\tNET_SendPacket( sock, strlen( string ), string, adr );\n}\n\n/*\n===============\nNET_OutOfBandPrint\n\nSends a data message in an out-of-band datagram (only used for \"connect\")\n================\n*/\nvoid QDECL NET_OutOfBandData( netsrc_t sock, netadr_t adr, byte *format, int len ) {\n\tbyte\t\tstring[MAX_MSGLEN*2];\n\tint\t\t\ti;\n\tmsg_t\t\tmbuf;\n\n\t// set the header\n\tstring[0] = 0xff;\n\tstring[1] = 0xff;\n\tstring[2] = 0xff;\n\tstring[3] = 0xff;\n\n\tfor(i=0;i<len;i++) {\n\t\tstring[i+4] = format[i];\n\t}\n\n\tmbuf.data = string;\n\tmbuf.cursize = len+4;\n\tHuff_Compress( &mbuf, 12);\n\t// send the datagram\n\tNET_SendPacket( sock, mbuf.cursize, mbuf.data, adr );\n}\n\n/*\n=============\nNET_StringToAdr\n\nTraps \"localhost\" for loopback, passes everything else to system\n=============\n*/\nqboolean\tNET_StringToAdr( const char *s, netadr_t *a ) {\n\tqboolean\tr;\n\tchar\tbase[MAX_STRING_CHARS];\n\tchar\t*port;\n\n\tif (!strcmp (s, \"localhost\")) {\n\t\tCom_Memset (a, 0, sizeof(*a));\n\t\ta->type = NA_LOOPBACK;\n\t\treturn qtrue;\n\t}\n\n\t// look for a port number\n\tQ_strncpyz( base, s, sizeof( base ) );\n\tport = strstr( base, \":\" );\n\tif ( port ) {\n\t\t*port = 0;\n\t\tport++;\n\t}\n\n\tr = Sys_StringToAdr( base, a );\n\n\tif ( !r ) {\n\t\ta->type = NA_BAD;\n\t\treturn qfalse;\n\t}\n\n\t// inet_addr returns this if out of range\n\tif ( a->ip[0] == 255 && a->ip[1] == 255 && a->ip[2] == 255 && a->ip[3] == 255 ) {\n\t\ta->type = NA_BAD;\n\t\treturn qfalse;\n\t}\n\n\tif ( port ) {\n\t\ta->port = BigShort( (short)atoi( port ) );\n\t} else {\n\t\ta->port = BigShort( PORT_SERVER );\n\t}\n\n\treturn qtrue;\n}\n\n"
  },
  {
    "path": "code/qcommon/qcommon.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// qcommon.h -- definitions common between client and server, but not game.or ref modules\n#ifndef _QCOMMON_H_\n#define _QCOMMON_H_\n\n#include \"../qcommon/cm_public.h\"\n\n//#define\tPRE_RELEASE_DEMO\n\n//============================================================================\n\n//\n// msg.c\n//\ntypedef struct {\n\tqboolean\tallowoverflow;\t// if false, do a Com_Error\n\tqboolean\toverflowed;\t\t// set to true if the buffer size failed (with allowoverflow set)\n\tqboolean\toob;\t\t\t// set to true if the buffer size failed (with allowoverflow set)\n\tbyte\t*data;\n\tint\t\tmaxsize;\n\tint\t\tcursize;\n\tint\t\treadcount;\n\tint\t\tbit;\t\t\t\t// for bitwise reads and writes\n} msg_t;\n\nvoid MSG_Init (msg_t *buf, byte *data, int length);\nvoid MSG_InitOOB( msg_t *buf, byte *data, int length );\nvoid MSG_Clear (msg_t *buf);\nvoid MSG_WriteData (msg_t *buf, const void *data, int length);\nvoid MSG_Bitstream( msg_t *buf );\n\n// TTimo\n// copy a msg_t in case we need to store it as is for a bit\n// (as I needed this to keep an msg_t from a static var for later use)\n// sets data buffer as MSG_Init does prior to do the copy\nvoid MSG_Copy(msg_t *buf, byte *data, int length, msg_t *src);\n\nstruct usercmd_s;\nstruct entityState_s;\nstruct playerState_s;\n\nvoid MSG_WriteBits( msg_t *msg, int value, int bits );\n\nvoid MSG_WriteChar (msg_t *sb, int c);\nvoid MSG_WriteByte (msg_t *sb, int c);\nvoid MSG_WriteShort (msg_t *sb, int c);\nvoid MSG_WriteLong (msg_t *sb, int c);\nvoid MSG_WriteFloat (msg_t *sb, float f);\nvoid MSG_WriteString (msg_t *sb, const char *s);\nvoid MSG_WriteBigString (msg_t *sb, const char *s);\nvoid MSG_WriteAngle16 (msg_t *sb, float f);\n\nvoid\tMSG_BeginReading (msg_t *sb);\nvoid\tMSG_BeginReadingOOB(msg_t *sb);\n\nint\t\tMSG_ReadBits( msg_t *msg, int bits );\n\nint\t\tMSG_ReadChar (msg_t *sb);\nint\t\tMSG_ReadByte (msg_t *sb);\nint\t\tMSG_ReadShort (msg_t *sb);\nint\t\tMSG_ReadLong (msg_t *sb);\nfloat\tMSG_ReadFloat (msg_t *sb);\nchar\t*MSG_ReadString (msg_t *sb);\nchar\t*MSG_ReadBigString (msg_t *sb);\nchar\t*MSG_ReadStringLine (msg_t *sb);\nfloat\tMSG_ReadAngle16 (msg_t *sb);\nvoid\tMSG_ReadData (msg_t *sb, void *buffer, int size);\n\n\nvoid MSG_WriteDeltaUsercmd( msg_t *msg, struct usercmd_s *from, struct usercmd_s *to );\nvoid MSG_ReadDeltaUsercmd( msg_t *msg, struct usercmd_s *from, struct usercmd_s *to );\n\nvoid MSG_WriteDeltaUsercmdKey( msg_t *msg, int key, usercmd_t *from, usercmd_t *to );\nvoid MSG_ReadDeltaUsercmdKey( msg_t *msg, int key, usercmd_t *from, usercmd_t *to );\n\nvoid MSG_WriteDeltaEntity( msg_t *msg, struct entityState_s *from, struct entityState_s *to\n\t\t\t\t\t\t   , qboolean force );\nvoid MSG_ReadDeltaEntity( msg_t *msg, entityState_t *from, entityState_t *to, \n\t\t\t\t\t\t int number );\n\nvoid MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct playerState_s *to );\nvoid MSG_ReadDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct playerState_s *to );\n\n\nvoid MSG_ReportChangeVectors_f( void );\n\n//============================================================================\n\n/*\n==============================================================\n\nNET\n\n==============================================================\n*/\n\n#define\tPACKET_BACKUP\t32\t// number of old messages that must be kept on client and\n\t\t\t\t\t\t\t// server for delta comrpession and ping estimation\n#define\tPACKET_MASK\t\t(PACKET_BACKUP-1)\n\n#define\tMAX_PACKET_USERCMDS\t\t32\t\t// max number of usercmd_t in a packet\n\n#define\tPORT_ANY\t\t\t-1\n\n#define\tMAX_RELIABLE_COMMANDS\t64\t\t\t// max string commands buffered for restransmit\n\ntypedef enum {\n\tNA_BOT,\n\tNA_BAD,\t\t\t\t\t// an address lookup failed\n\tNA_LOOPBACK,\n\tNA_BROADCAST,\n\tNA_IP,\n\tNA_IPX,\n\tNA_BROADCAST_IPX\n} netadrtype_t;\n\ntypedef enum {\n\tNS_CLIENT,\n\tNS_SERVER\n} netsrc_t;\n\ntypedef struct {\n\tnetadrtype_t\ttype;\n\n\tbyte\tip[4];\n\tbyte\tipx[10];\n\n\tunsigned short\tport;\n} netadr_t;\n\nvoid\t\tNET_Init( void );\nvoid\t\tNET_Shutdown( void );\nvoid\t\tNET_Restart( void );\nvoid\t\tNET_Config( qboolean enableNetworking );\n\nvoid\t\tNET_SendPacket (netsrc_t sock, int length, const void *data, netadr_t to);\nvoid\t\tQDECL NET_OutOfBandPrint( netsrc_t net_socket, netadr_t adr, const char *format, ...);\nvoid\t\tQDECL NET_OutOfBandData( netsrc_t sock, netadr_t adr, byte *format, int len );\n\nqboolean\tNET_CompareAdr (netadr_t a, netadr_t b);\nqboolean\tNET_CompareBaseAdr (netadr_t a, netadr_t b);\nqboolean\tNET_IsLocalAddress (netadr_t adr);\nconst char\t*NET_AdrToString (netadr_t a);\nqboolean\tNET_StringToAdr ( const char *s, netadr_t *a);\nqboolean\tNET_GetLoopPacket (netsrc_t sock, netadr_t *net_from, msg_t *net_message);\nvoid\t\tNET_Sleep(int msec);\n\n\n#define\tMAX_MSGLEN\t\t\t\t16384\t\t// max length of a message, which may\n\t\t\t\t\t\t\t\t\t\t\t// be fragmented into multiple packets\n\n#define MAX_DOWNLOAD_WINDOW\t\t\t8\t\t// max of eight download frames\n#define MAX_DOWNLOAD_BLKSIZE\t\t2048\t// 2048 byte block chunks\n \n\n/*\nNetchan handles packet fragmentation and out of order / duplicate suppression\n*/\n\ntypedef struct {\n\tnetsrc_t\tsock;\n\n\tint\t\t\tdropped;\t\t\t// between last packet and previous\n\n\tnetadr_t\tremoteAddress;\n\tint\t\t\tqport;\t\t\t\t// qport value to write when transmitting\n\n\t// sequencing variables\n\tint\t\t\tincomingSequence;\n\tint\t\t\toutgoingSequence;\n\n\t// incoming fragment assembly buffer\n\tint\t\t\tfragmentSequence;\n\tint\t\t\tfragmentLength;\t\n\tbyte\t\tfragmentBuffer[MAX_MSGLEN];\n\n\t// outgoing fragment buffer\n\t// we need to space out the sending of large fragmented messages\n\tqboolean\tunsentFragments;\n\tint\t\t\tunsentFragmentStart;\n\tint\t\t\tunsentLength;\n\tbyte\t\tunsentBuffer[MAX_MSGLEN];\n} netchan_t;\n\nvoid Netchan_Init( int qport );\nvoid Netchan_Setup( netsrc_t sock, netchan_t *chan, netadr_t adr, int qport );\n\nvoid Netchan_Transmit( netchan_t *chan, int length, const byte *data );\nvoid Netchan_TransmitNextFragment( netchan_t *chan );\n\nqboolean Netchan_Process( netchan_t *chan, msg_t *msg );\n\n\n/*\n==============================================================\n\nPROTOCOL\n\n==============================================================\n*/\n\n#define\tPROTOCOL_VERSION\t68\n// 1.31 - 67\n\n// maintain a list of compatible protocols for demo playing\n// NOTE: that stuff only works with two digits protocols\nextern int demo_protocols[];\n\n#define\tUPDATE_SERVER_NAME\t\"update.quake3arena.com\"\n// override on command line, config files etc.\n#ifndef MASTER_SERVER_NAME\n#define MASTER_SERVER_NAME\t\"master.quake3arena.com\"\n#endif\n#ifndef AUTHORIZE_SERVER_NAME\n#define\tAUTHORIZE_SERVER_NAME\t\"authorize.quake3arena.com\"\n#endif\n\n#define\tPORT_MASTER\t\t\t27950\n#define\tPORT_UPDATE\t\t\t27951\n#ifndef PORT_AUTHORIZE\n#define\tPORT_AUTHORIZE\t\t27952\n#endif\n#define\tPORT_SERVER\t\t\t27960\n#define\tNUM_SERVER_PORTS\t4\t\t// broadcast scan this many ports after\n\t\t\t\t\t\t\t\t\t// PORT_SERVER so a single machine can\n\t\t\t\t\t\t\t\t\t// run multiple servers\n\n\n// the svc_strings[] array in cl_parse.c should mirror this\n//\n// server to client\n//\nenum svc_ops_e {\n\tsvc_bad,\n\tsvc_nop,\n\tsvc_gamestate,\n\tsvc_configstring,\t\t\t// [short] [string] only in gamestate messages\n\tsvc_baseline,\t\t\t\t// only in gamestate messages\n\tsvc_serverCommand,\t\t\t// [string] to be executed by client game module\n\tsvc_download,\t\t\t\t// [short] size [size bytes]\n\tsvc_snapshot,\n\tsvc_EOF\n};\n\n\n//\n// client to server\n//\nenum clc_ops_e {\n\tclc_bad,\n\tclc_nop, \t\t\n\tclc_move,\t\t\t\t// [[usercmd_t]\n\tclc_moveNoDelta,\t\t// [[usercmd_t]\n\tclc_clientCommand,\t\t// [string] message\n\tclc_EOF\n};\n\n/*\n==============================================================\n\nVIRTUAL MACHINE\n\n==============================================================\n*/\n\ntypedef struct vm_s vm_t;\n\ntypedef enum {\n\tVMI_NATIVE,\n\tVMI_BYTECODE,\n\tVMI_COMPILED\n} vmInterpret_t;\n\ntypedef enum {\n\tTRAP_MEMSET = 100,\n\tTRAP_MEMCPY,\n\tTRAP_STRNCPY,\n\tTRAP_SIN,\n\tTRAP_COS,\n\tTRAP_ATAN2,\n\tTRAP_SQRT,\n\tTRAP_MATRIXMULTIPLY,\n\tTRAP_ANGLEVECTORS,\n\tTRAP_PERPENDICULARVECTOR,\n\tTRAP_FLOOR,\n\tTRAP_CEIL,\n\n\tTRAP_TESTPRINTINT,\n\tTRAP_TESTPRINTFLOAT\n} sharedTraps_t;\n\nvoid\tVM_Init( void );\nvm_t\t*VM_Create( const char *module, int (*systemCalls)(int *), \n\t\t\t\t   vmInterpret_t interpret );\n// module should be bare: \"cgame\", not \"cgame.dll\" or \"vm/cgame.qvm\"\n\nvoid\tVM_Free( vm_t *vm );\nvoid\tVM_Clear(void);\nvm_t\t*VM_Restart( vm_t *vm );\n\nint\t\tQDECL VM_Call( vm_t *vm, int callNum, ... );\n\nvoid\tVM_Debug( int level );\n\nvoid\t*VM_ArgPtr( int intValue );\nvoid\t*VM_ExplicitArgPtr( vm_t *vm, int intValue );\n\n/*\n==============================================================\n\nCMD\n\nCommand text buffering and command execution\n\n==============================================================\n*/\n\n/*\n\nAny number of commands can be added in a frame, from several different sources.\nMost commands come from either keybindings or console line input, but entire text\nfiles can be execed.\n\n*/\n\nvoid Cbuf_Init (void);\n// allocates an initial text buffer that will grow as needed\n\nvoid Cbuf_AddText( const char *text );\n// Adds command text at the end of the buffer, does NOT add a final \\n\n\nvoid Cbuf_ExecuteText( int exec_when, const char *text );\n// this can be used in place of either Cbuf_AddText or Cbuf_InsertText\n\nvoid Cbuf_Execute (void);\n// Pulls off \\n terminated lines of text from the command buffer and sends\n// them through Cmd_ExecuteString.  Stops when the buffer is empty.\n// Normally called once per frame, but may be explicitly invoked.\n// Do not call inside a command function, or current args will be destroyed.\n\n//===========================================================================\n\n/*\n\nCommand execution takes a null terminated string, breaks it into tokens,\nthen searches for a command or variable that matches the first token.\n\n*/\n\ntypedef void (*xcommand_t) (void);\n\nvoid\tCmd_Init (void);\n\nvoid\tCmd_AddCommand( const char *cmd_name, xcommand_t function );\n// called by the init functions of other parts of the program to\n// register commands and functions to call for them.\n// The cmd_name is referenced later, so it should not be in temp memory\n// if function is NULL, the command will be forwarded to the server\n// as a clc_clientCommand instead of executed locally\n\nvoid\tCmd_RemoveCommand( const char *cmd_name );\n\nvoid\tCmd_CommandCompletion( void(*callback)(const char *s) );\n// callback with each valid string\n\nint\t\tCmd_Argc (void);\nchar\t*Cmd_Argv (int arg);\nvoid\tCmd_ArgvBuffer( int arg, char *buffer, int bufferLength );\nchar\t*Cmd_Args (void);\nchar\t*Cmd_ArgsFrom( int arg );\nvoid\tCmd_ArgsBuffer( char *buffer, int bufferLength );\nchar\t*Cmd_Cmd (void);\n// The functions that execute commands get their parameters with these\n// functions. Cmd_Argv () will return an empty string, not a NULL\n// if arg > argc, so string operations are allways safe.\n\nvoid\tCmd_TokenizeString( const char *text );\n// Takes a null terminated string.  Does not need to be /n terminated.\n// breaks the string up into arg tokens.\n\nvoid\tCmd_ExecuteString( const char *text );\n// Parses a single line of text into arguments and tries to execute it\n// as if it was typed at the console\n\n\n/*\n==============================================================\n\nCVAR\n\n==============================================================\n*/\n\n/*\n\ncvar_t variables are used to hold scalar or string variables that can be changed\nor displayed at the console or prog code as well as accessed directly\nin C code.\n\nThe user can access cvars from the console in three ways:\nr_draworder\t\t\tprints the current value\nr_draworder 0\t\tsets the current value to 0\nset r_draworder 0\tas above, but creates the cvar if not present\n\nCvars are restricted from having the same names as commands to keep this\ninterface from being ambiguous.\n\nThe are also occasionally used to communicated information between different\nmodules of the program.\n\n*/\n\ncvar_t *Cvar_Get( const char *var_name, const char *value, int flags );\n// creates the variable if it doesn't exist, or returns the existing one\n// if it exists, the value will not be changed, but flags will be ORed in\n// that allows variables to be unarchived without needing bitflags\n// if value is \"\", the value will not override a previously set value.\n\nvoid\tCvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags );\n// basically a slightly modified Cvar_Get for the interpreted modules\n\nvoid\tCvar_Update( vmCvar_t *vmCvar );\n// updates an interpreted modules' version of a cvar\n\nvoid \tCvar_Set( const char *var_name, const char *value );\n// will create the variable with no flags if it doesn't exist\n\nvoid Cvar_SetLatched( const char *var_name, const char *value);\n// don't set the cvar immediately\n\nvoid\tCvar_SetValue( const char *var_name, float value );\n// expands value to a string and calls Cvar_Set\n\nfloat\tCvar_VariableValue( const char *var_name );\nint\t\tCvar_VariableIntegerValue( const char *var_name );\n// returns 0 if not defined or non numeric\n\nchar\t*Cvar_VariableString( const char *var_name );\nvoid\tCvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize );\n// returns an empty string if not defined\n\nvoid\tCvar_CommandCompletion( void(*callback)(const char *s) );\n// callback with each valid string\n\nvoid \tCvar_Reset( const char *var_name );\n\nvoid\tCvar_SetCheatState( void );\n// reset all testing vars to a safe value\n\nqboolean Cvar_Command( void );\n// called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known\n// command.  Returns true if the command was a variable reference that\n// was handled. (print or change)\n\nvoid \tCvar_WriteVariables( fileHandle_t f );\n// writes lines containing \"set variable value\" for all variables\n// with the archive flag set to true.\n\nvoid\tCvar_Init( void );\n\nchar\t*Cvar_InfoString( int bit );\nchar\t*Cvar_InfoString_Big( int bit );\n// returns an info string containing all the cvars that have the given bit set\n// in their flags ( CVAR_USERINFO, CVAR_SERVERINFO, CVAR_SYSTEMINFO, etc )\nvoid\tCvar_InfoStringBuffer( int bit, char *buff, int buffsize );\n\nvoid\tCvar_Restart_f( void );\n\nextern\tint\t\t\tcvar_modifiedFlags;\n// whenever a cvar is modifed, its flags will be OR'd into this, so\n// a single check can determine if any CVAR_USERINFO, CVAR_SERVERINFO,\n// etc, variables have been modified since the last check.  The bit\n// can then be cleared to allow another change detection.\n\n/*\n==============================================================\n\nFILESYSTEM\n\nNo stdio calls should be used by any part of the game, because\nwe need to deal with all sorts of directory and seperator char\nissues.\n==============================================================\n*/\n\n// referenced flags\n// these are in loop specific order so don't change the order\n#define FS_GENERAL_REF\t0x01\n#define FS_UI_REF\t\t0x02\n#define FS_CGAME_REF\t0x04\n#define FS_QAGAME_REF\t0x08\n// number of id paks that will never be autodownloaded from baseq3\n#define NUM_ID_PAKS\t\t9\n\n#define\tMAX_FILE_HANDLES\t64\n\n#define BASEGAME \"baseq3\"\n\nqboolean FS_Initialized();\n\nvoid\tFS_InitFilesystem (void);\nvoid\tFS_Shutdown( qboolean closemfp );\n\nqboolean\tFS_ConditionalRestart( int checksumFeed );\nvoid\tFS_Restart( int checksumFeed );\n// shutdown and restart the filesystem so changes to fs_gamedir can take effect\n\nchar\t**FS_ListFiles( const char *directory, const char *extension, int *numfiles );\n// directory should not have either a leading or trailing /\n// if extension is \"/\", only subdirectories will be returned\n// the returned files will not include any directories or /\n\nvoid\tFS_FreeFileList( char **list );\n\nqboolean FS_FileExists( const char *file );\n\nint\t\tFS_LoadStack();\n\nint\t\tFS_GetFileList(  const char *path, const char *extension, char *listbuf, int bufsize );\nint\t\tFS_GetModList(  char *listbuf, int bufsize );\n\nfileHandle_t\tFS_FOpenFileWrite( const char *qpath );\n// will properly create any needed paths and deal with seperater character issues\n\nint\t\tFS_filelength( fileHandle_t f );\nfileHandle_t FS_SV_FOpenFileWrite( const char *filename );\nint\t\tFS_SV_FOpenFileRead( const char *filename, fileHandle_t *fp );\nvoid\tFS_SV_Rename( const char *from, const char *to );\nint\t\tFS_FOpenFileRead( const char *qpath, fileHandle_t *file, qboolean uniqueFILE );\n// if uniqueFILE is true, then a new FILE will be fopened even if the file\n// is found in an already open pak file.  If uniqueFILE is false, you must call\n// FS_FCloseFile instead of fclose, otherwise the pak FILE would be improperly closed\n// It is generally safe to always set uniqueFILE to true, because the majority of\n// file IO goes through FS_ReadFile, which Does The Right Thing already.\n\nint\t\tFS_FileIsInPAK(const char *filename, int *pChecksum );\n// returns 1 if a file is in the PAK file, otherwise -1\n\nint\t\tFS_Write( const void *buffer, int len, fileHandle_t f );\n\nint\t\tFS_Read2( void *buffer, int len, fileHandle_t f );\nint\t\tFS_Read( void *buffer, int len, fileHandle_t f );\n// properly handles partial reads and reads from other dlls\n\nvoid\tFS_FCloseFile( fileHandle_t f );\n// note: you can't just fclose from another DLL, due to MS libc issues\n\nint\t\tFS_ReadFile( const char *qpath, void **buffer );\n// returns the length of the file\n// a null buffer will just return the file length without loading\n// as a quick check for existance. -1 length == not present\n// A 0 byte will always be appended at the end, so string ops are safe.\n// the buffer should be considered read-only, because it may be cached\n// for other uses.\n\nvoid\tFS_ForceFlush( fileHandle_t f );\n// forces flush on files we're writing to.\n\nvoid\tFS_FreeFile( void *buffer );\n// frees the memory returned by FS_ReadFile\n\nvoid\tFS_WriteFile( const char *qpath, const void *buffer, int size );\n// writes a complete file, creating any subdirectories needed\n\nint\t\tFS_filelength( fileHandle_t f );\n// doesn't work for files that are opened from a pack file\n\nint\t\tFS_FTell( fileHandle_t f );\n// where are we?\n\nvoid\tFS_Flush( fileHandle_t f );\n\nvoid \tQDECL FS_Printf( fileHandle_t f, const char *fmt, ... );\n// like fprintf\n\nint\t\tFS_FOpenFileByMode( const char *qpath, fileHandle_t *f, fsMode_t mode );\n// opens a file for reading, writing, or appending depending on the value of mode\n\nint\t\tFS_Seek( fileHandle_t f, long offset, int origin );\n// seek on a file (doesn't work for zip files!!!!!!!!)\n\nqboolean FS_FilenameCompare( const char *s1, const char *s2 );\n\nconst char *FS_GamePureChecksum( void );\n// Returns the checksum of the pk3 from which the server loaded the qagame.qvm\n\nconst char *FS_LoadedPakNames( void );\nconst char *FS_LoadedPakChecksums( void );\nconst char *FS_LoadedPakPureChecksums( void );\n// Returns a space separated string containing the checksums of all loaded pk3 files.\n// Servers with sv_pure set will get this string and pass it to clients.\n\nconst char *FS_ReferencedPakNames( void );\nconst char *FS_ReferencedPakChecksums( void );\nconst char *FS_ReferencedPakPureChecksums( void );\n// Returns a space separated string containing the checksums of all loaded \n// AND referenced pk3 files. Servers with sv_pure set will get this string \n// back from clients for pure validation \n\nvoid FS_ClearPakReferences( int flags );\n// clears referenced booleans on loaded pk3s\n\nvoid FS_PureServerSetReferencedPaks( const char *pakSums, const char *pakNames );\nvoid FS_PureServerSetLoadedPaks( const char *pakSums, const char *pakNames );\n// If the string is empty, all data sources will be allowed.\n// If not empty, only pk3 files that match one of the space\n// separated checksums will be checked for files, with the\n// sole exception of .cfg files.\n\nqboolean FS_idPak( char *pak, char *base );\nqboolean FS_ComparePaks( char *neededpaks, int len, qboolean dlstring );\n\nvoid FS_Rename( const char *from, const char *to );\n\n/*\n==============================================================\n\nEdit fields and command line history/completion\n\n==============================================================\n*/\n\n#define\tMAX_EDIT_LINE\t256\ntypedef struct {\n\tint\t\tcursor;\n\tint\t\tscroll;\n\tint\t\twidthInChars;\n\tchar\tbuffer[MAX_EDIT_LINE];\n} field_t;\n\nvoid Field_Clear( field_t *edit );\nvoid Field_CompleteCommand( field_t *edit );\n\n/*\n==============================================================\n\nMISC\n\n==============================================================\n*/\n\n// TTimo\n// vsnprintf is ISO/IEC 9899:1999\n// abstracting this to make it portable\n#ifdef WIN32\n#define Q_vsnprintf _vsnprintf\n#else\n// TODO: do we need Mac define?\n#define Q_vsnprintf vsnprintf\n#endif\n\n// centralizing the declarations for cl_cdkey\n// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=470\nextern char cl_cdkey[34];\n\n// returnbed by Sys_GetProcessorId\n#define CPUID_GENERIC\t\t\t0\t\t\t// any unrecognized processor\n\n#define CPUID_AXP\t\t\t\t0x10\n\n#define CPUID_INTEL_UNSUPPORTED\t0x20\t\t\t// Intel 386/486\n#define CPUID_INTEL_PENTIUM\t\t0x21\t\t\t// Intel Pentium or PPro\n#define CPUID_INTEL_MMX\t\t\t0x22\t\t\t// Intel Pentium/MMX or P2/MMX\n#define CPUID_INTEL_KATMAI\t\t0x23\t\t\t// Intel Katmai\n\n#define CPUID_AMD_3DNOW\t\t\t0x30\t\t\t// AMD K6 3DNOW!\n\n// TTimo\n// centralized and cleaned, that's the max string you can send to a Com_Printf / Com_DPrintf (above gets truncated)\n#define\tMAXPRINTMSG\t4096\n\nchar\t\t*CopyString( const char *in );\nvoid\t\tInfo_Print( const char *s );\n\nvoid\t\tCom_BeginRedirect (char *buffer, int buffersize, void (*flush)(char *));\nvoid\t\tCom_EndRedirect( void );\nvoid \t\tQDECL Com_Printf( const char *fmt, ... );\nvoid \t\tQDECL Com_DPrintf( const char *fmt, ... );\nvoid \t\tQDECL Com_Error( int code, const char *fmt, ... );\nvoid \t\tCom_Quit_f( void );\nint\t\t\tCom_EventLoop( void );\nint\t\t\tCom_Milliseconds( void );\t// will be journaled properly\nunsigned\tCom_BlockChecksum( const void *buffer, int length );\nunsigned\tCom_BlockChecksumKey (void *buffer, int length, int key);\nint\t\t\tCom_HashKey(char *string, int maxlen);\nint\t\t\tCom_Filter(char *filter, char *name, int casesensitive);\nint\t\t\tCom_FilterPath(char *filter, char *name, int casesensitive);\nint\t\t\tCom_RealTime(qtime_t *qtime);\nqboolean\tCom_SafeMode( void );\n\nvoid\t\tCom_StartupVariable( const char *match );\n// checks for and removes command line \"+set var arg\" constructs\n// if match is NULL, all set commands will be executed, otherwise\n// only a set with the exact name.  Only used during startup.\n\n\nextern\tcvar_t\t*com_developer;\nextern\tcvar_t\t*com_dedicated;\nextern\tcvar_t\t*com_speeds;\nextern\tcvar_t\t*com_timescale;\nextern\tcvar_t\t*com_sv_running;\nextern\tcvar_t\t*com_cl_running;\nextern\tcvar_t\t*com_viewlog;\t\t\t// 0 = hidden, 1 = visible, 2 = minimized\nextern\tcvar_t\t*com_version;\nextern\tcvar_t\t*com_blood;\nextern\tcvar_t\t*com_buildScript;\t\t// for building release pak files\nextern\tcvar_t\t*com_journal;\nextern\tcvar_t\t*com_cameraMode;\n\n// both client and server must agree to pause\nextern\tcvar_t\t*cl_paused;\nextern\tcvar_t\t*sv_paused;\n\n// com_speeds times\nextern\tint\t\ttime_game;\nextern\tint\t\ttime_frontend;\nextern\tint\t\ttime_backend;\t\t// renderer backend time\n\nextern\tint\t\tcom_frameTime;\nextern\tint\t\tcom_frameMsec;\n\nextern\tqboolean\tcom_errorEntered;\n\nextern\tfileHandle_t\tcom_journalFile;\nextern\tfileHandle_t\tcom_journalDataFile;\n\ntypedef enum {\n\tTAG_FREE,\n\tTAG_GENERAL,\n\tTAG_BOTLIB,\n\tTAG_RENDERER,\n\tTAG_SMALL,\n\tTAG_STATIC\n} memtag_t;\n\n/*\n\n--- low memory ----\nserver vm\nserver clipmap\n---mark---\nrenderer initialization (shaders, etc)\nUI vm\ncgame vm\nrenderer map\nrenderer models\n\n---free---\n\ntemp file loading\n--- high memory ---\n\n*/\n\n#if defined(_DEBUG) && !defined(BSPC)\n\t#define ZONE_DEBUG\n#endif\n\n#ifdef ZONE_DEBUG\n#define Z_TagMalloc(size, tag)\t\t\tZ_TagMallocDebug(size, tag, #size, __FILE__, __LINE__)\n#define Z_Malloc(size)\t\t\t\t\tZ_MallocDebug(size, #size, __FILE__, __LINE__)\n#define S_Malloc(size)\t\t\t\t\tS_MallocDebug(size, #size, __FILE__, __LINE__)\nvoid *Z_TagMallocDebug( int size, int tag, char *label, char *file, int line );\t// NOT 0 filled memory\nvoid *Z_MallocDebug( int size, char *label, char *file, int line );\t\t\t// returns 0 filled memory\nvoid *S_MallocDebug( int size, char *label, char *file, int line );\t\t\t// returns 0 filled memory\n#else\nvoid *Z_TagMalloc( int size, int tag );\t// NOT 0 filled memory\nvoid *Z_Malloc( int size );\t\t\t// returns 0 filled memory\nvoid *S_Malloc( int size );\t\t\t// NOT 0 filled memory only for small allocations\n#endif\nvoid Z_Free( void *ptr );\nvoid Z_FreeTags( int tag );\nint Z_AvailableMemory( void );\nvoid Z_LogHeap( void );\n\nvoid Hunk_Clear( void );\nvoid Hunk_ClearToMark( void );\nvoid Hunk_SetMark( void );\nqboolean Hunk_CheckMark( void );\nvoid Hunk_ClearTempMemory( void );\nvoid *Hunk_AllocateTempMemory( int size );\nvoid Hunk_FreeTempMemory( void *buf );\nint\tHunk_MemoryRemaining( void );\nvoid Hunk_Log( void);\nvoid Hunk_Trash( void );\n\nvoid Com_TouchMemory( void );\n\n// commandLine should not include the executable name (argv[0])\nvoid Com_Init( char *commandLine );\nvoid Com_Frame( void );\nvoid Com_Shutdown( void );\n\n\n/*\n==============================================================\n\nCLIENT / SERVER SYSTEMS\n\n==============================================================\n*/\n\n//\n// client interface\n//\nvoid CL_InitKeyCommands( void );\n// the keyboard binding interface must be setup before execing\n// config files, but the rest of client startup will happen later\n\nvoid CL_Init( void );\nvoid CL_Disconnect( qboolean showMainMenu );\nvoid CL_Shutdown( void );\nvoid CL_Frame( int msec );\nqboolean CL_GameCommand( void );\nvoid CL_KeyEvent (int key, qboolean down, unsigned time);\n\nvoid CL_CharEvent( int key );\n// char events are for field typing, not game control\n\nvoid CL_MouseEvent( int dx, int dy, int time );\n\nvoid CL_JoystickEvent( int axis, int value, int time );\n\nvoid CL_PacketEvent( netadr_t from, msg_t *msg );\n\nvoid CL_ConsolePrint( char *text );\n\nvoid CL_MapLoading( void );\n// do a screen update before starting to load a map\n// when the server is going to load a new map, the entire hunk\n// will be cleared, so the client must shutdown cgame, ui, and\n// the renderer\n\nvoid\tCL_ForwardCommandToServer( const char *string );\n// adds the current command line as a clc_clientCommand to the client message.\n// things like godmode, noclip, etc, are commands directed to the server,\n// so when they are typed in at the console, they will need to be forwarded.\n\nvoid CL_CDDialog( void );\n// bring up the \"need a cd to play\" dialog\n\nvoid CL_ShutdownAll( void );\n// shutdown all the client stuff\n\nvoid CL_FlushMemory( void );\n// dump all memory on an error\n\nvoid CL_StartHunkUsers( void );\n// start all the client stuff using the hunk\n\nvoid Key_WriteBindings( fileHandle_t f );\n// for writing the config files\n\nvoid S_ClearSoundBuffer( void );\n// call before filesystem access\n\nvoid SCR_DebugGraph (float value, int color);\t// FIXME: move logging to common?\n\n\n//\n// server interface\n//\nvoid SV_Init( void );\nvoid SV_Shutdown( char *finalmsg );\nvoid SV_Frame( int msec );\nvoid SV_PacketEvent( netadr_t from, msg_t *msg );\nqboolean SV_GameCommand( void );\n\n\n//\n// UI interface\n//\nqboolean UI_GameCommand( void );\nqboolean UI_usesUniqueCDKey();\n\n/*\n==============================================================\n\nNON-PORTABLE SYSTEM SERVICES\n\n==============================================================\n*/\n\ntypedef enum {\n\tAXIS_SIDE,\n\tAXIS_FORWARD,\n\tAXIS_UP,\n\tAXIS_ROLL,\n\tAXIS_YAW,\n\tAXIS_PITCH,\n\tMAX_JOYSTICK_AXIS\n} joystickAxis_t;\n\ntypedef enum {\n  // bk001129 - make sure SE_NONE is zero\n\tSE_NONE = 0,\t// evTime is still valid\n\tSE_KEY,\t\t// evValue is a key code, evValue2 is the down flag\n\tSE_CHAR,\t// evValue is an ascii char\n\tSE_MOUSE,\t// evValue and evValue2 are reletive signed x / y moves\n\tSE_JOYSTICK_AXIS,\t// evValue is an axis number and evValue2 is the current state (-127 to 127)\n\tSE_CONSOLE,\t// evPtr is a char*\n\tSE_PACKET\t// evPtr is a netadr_t followed by data bytes to evPtrLength\n} sysEventType_t;\n\ntypedef struct {\n\tint\t\t\t\tevTime;\n\tsysEventType_t\tevType;\n\tint\t\t\t\tevValue, evValue2;\n\tint\t\t\t\tevPtrLength;\t// bytes of data pointed to by evPtr, for journaling\n\tvoid\t\t\t*evPtr;\t\t\t// this must be manually freed if not NULL\n} sysEvent_t;\n\nsysEvent_t\tSys_GetEvent( void );\n\nvoid\tSys_Init (void);\n\n// general development dll loading for virtual machine testing\n// fqpath param added 7/20/02 by T.Ray - Sys_LoadDll is only called in vm.c at this time\nvoid\t* QDECL Sys_LoadDll( const char *name, char *fqpath , int (QDECL **entryPoint)(int, ...),\n\t\t\t\t  int (QDECL *systemcalls)(int, ...) );\nvoid\tSys_UnloadDll( void *dllHandle );\n\nvoid\tSys_UnloadGame( void );\nvoid\t*Sys_GetGameAPI( void *parms );\n\nvoid\tSys_UnloadCGame( void );\nvoid\t*Sys_GetCGameAPI( void );\n\nvoid\tSys_UnloadUI( void );\nvoid\t*Sys_GetUIAPI( void );\n\n//bot libraries\nvoid\tSys_UnloadBotLib( void );\nvoid\t*Sys_GetBotLibAPI( void *parms );\n\nchar\t*Sys_GetCurrentUser( void );\n\nvoid\tQDECL Sys_Error( const char *error, ...);\nvoid\tSys_Quit (void);\nchar\t*Sys_GetClipboardData( void );\t// note that this isn't journaled...\n\nvoid\tSys_Print( const char *msg );\n\n// Sys_Milliseconds should only be used for profiling purposes,\n// any game related timing information should come from event timestamps\nint\t\tSys_Milliseconds (void);\n\nvoid\tSys_SnapVector( float *v );\n\n// the system console is shown when a dedicated server is running\nvoid\tSys_DisplaySystemConsole( qboolean show );\n\nint\t\tSys_GetProcessorId( void );\n\nvoid\tSys_BeginStreamedFile( fileHandle_t f, int readahead );\nvoid\tSys_EndStreamedFile( fileHandle_t f );\nint\t\tSys_StreamedRead( void *buffer, int size, int count, fileHandle_t f );\nvoid\tSys_StreamSeek( fileHandle_t f, int offset, int origin );\n\nvoid\tSys_ShowConsole( int level, qboolean quitOnClose );\nvoid\tSys_SetErrorText( const char *text );\n\nvoid\tSys_SendPacket( int length, const void *data, netadr_t to );\n\nqboolean\tSys_StringToAdr( const char *s, netadr_t *a );\n//Does NOT parse port numbers, only base addresses.\n\nqboolean\tSys_IsLANAddress (netadr_t adr);\nvoid\t\tSys_ShowIP(void);\n\nqboolean\tSys_CheckCD( void );\n\nvoid\tSys_Mkdir( const char *path );\nchar\t*Sys_Cwd( void );\nvoid\tSys_SetDefaultCDPath(const char *path);\nchar\t*Sys_DefaultCDPath(void);\nvoid\tSys_SetDefaultInstallPath(const char *path);\nchar\t*Sys_DefaultInstallPath(void);\nvoid  Sys_SetDefaultHomePath(const char *path);\nchar\t*Sys_DefaultHomePath(void);\n\nchar **Sys_ListFiles( const char *directory, const char *extension, char *filter, int *numfiles, qboolean wantsubs );\nvoid\tSys_FreeFileList( char **list );\n\nvoid\tSys_BeginProfiling( void );\nvoid\tSys_EndProfiling( void );\n\nqboolean Sys_LowPhysicalMemory();\nunsigned int Sys_ProcessorCount();\n\nint Sys_MonkeyShouldBeSpanked( void );\n\n/* This is based on the Adaptive Huffman algorithm described in Sayood's Data\n * Compression book.  The ranks are not actually stored, but implicitly defined\n * by the location of a node within a doubly-linked list */\n\n#define NYT HMAX\t\t\t\t\t/* NYT = Not Yet Transmitted */\n#define INTERNAL_NODE (HMAX+1)\n\ntypedef struct nodetype {\n\tstruct\tnodetype *left, *right, *parent; /* tree structure */ \n\tstruct\tnodetype *next, *prev; /* doubly-linked list */\n\tstruct\tnodetype **head; /* highest ranked node in block */\n\tint\t\tweight;\n\tint\t\tsymbol;\n} node_t;\n\n#define HMAX 256 /* Maximum symbol */\n\ntypedef struct {\n\tint\t\t\tblocNode;\n\tint\t\t\tblocPtrs;\n\n\tnode_t*\t\ttree;\n\tnode_t*\t\tlhead;\n\tnode_t*\t\tltail;\n\tnode_t*\t\tloc[HMAX+1];\n\tnode_t**\tfreelist;\n\n\tnode_t\t\tnodeList[768];\n\tnode_t*\t\tnodePtrs[768];\n} huff_t;\n\ntypedef struct {\n\thuff_t\t\tcompressor;\n\thuff_t\t\tdecompressor;\n} huffman_t;\n\nvoid\tHuff_Compress(msg_t *buf, int offset);\nvoid\tHuff_Decompress(msg_t *buf, int offset);\nvoid\tHuff_Init(huffman_t *huff);\nvoid\tHuff_addRef(huff_t* huff, byte ch);\nint\t\tHuff_Receive (node_t *node, int *ch, byte *fin);\nvoid\tHuff_transmit (huff_t *huff, int ch, byte *fout);\nvoid\tHuff_offsetReceive (node_t *node, int *ch, byte *fin, int *offset);\nvoid\tHuff_offsetTransmit (huff_t *huff, int ch, byte *fout, int *offset);\nvoid\tHuff_putBit( int bit, byte *fout, int *offset);\nint\t\tHuff_getBit( byte *fout, int *offset);\n\nextern huffman_t clientHuffTables;\n\n#define\tSV_ENCODE_START\t\t4\n#define SV_DECODE_START\t\t12\n#define\tCL_ENCODE_START\t\t12\n#define CL_DECODE_START\t\t4\n\n#endif // _QCOMMON_H_\n"
  },
  {
    "path": "code/qcommon/qfiles.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __QFILES_H__\n#define __QFILES_H__\n\n//\n// qfiles.h: quake file formats\n// This file must be identical in the quake and utils directories\n//\n\n// surface geometry should not exceed these limits\n#define\tSHADER_MAX_VERTEXES\t1000\n#define\tSHADER_MAX_INDEXES\t(6*SHADER_MAX_VERTEXES)\n\n\n// the maximum size of game relative pathnames\n#define\tMAX_QPATH\t\t64\n\n/*\n========================================================================\n\nQVM files\n\n========================================================================\n*/\n\n#define\tVM_MAGIC\t0x12721444\ntypedef struct {\n\tint\t\tvmMagic;\n\n\tint\t\tinstructionCount;\n\n\tint\t\tcodeOffset;\n\tint\t\tcodeLength;\n\n\tint\t\tdataOffset;\n\tint\t\tdataLength;\n\tint\t\tlitLength;\t\t\t// ( dataLength - litLength ) should be byteswapped on load\n\tint\t\tbssLength;\t\t\t// zero filled memory appended to datalength\n} vmHeader_t;\n\n\n/*\n========================================================================\n\nPCX files are used for 8 bit images\n\n========================================================================\n*/\n\ntypedef struct {\n    char\tmanufacturer;\n    char\tversion;\n    char\tencoding;\n    char\tbits_per_pixel;\n    unsigned short\txmin,ymin,xmax,ymax;\n    unsigned short\thres,vres;\n    unsigned char\tpalette[48];\n    char\treserved;\n    char\tcolor_planes;\n    unsigned short\tbytes_per_line;\n    unsigned short\tpalette_type;\n    char\tfiller[58];\n    unsigned char\tdata;\t\t\t// unbounded\n} pcx_t;\n\n\n/*\n========================================================================\n\nTGA files are used for 24/32 bit images\n\n========================================================================\n*/\n\ntypedef struct _TargaHeader {\n\tunsigned char \tid_length, colormap_type, image_type;\n\tunsigned short\tcolormap_index, colormap_length;\n\tunsigned char\tcolormap_size;\n\tunsigned short\tx_origin, y_origin, width, height;\n\tunsigned char\tpixel_size, attributes;\n} TargaHeader;\n\n\n\n/*\n========================================================================\n\n.MD3 triangle model file format\n\n========================================================================\n*/\n\n#define MD3_IDENT\t\t\t(('3'<<24)+('P'<<16)+('D'<<8)+'I')\n#define MD3_VERSION\t\t\t15\n\n// limits\n#define MD3_MAX_LODS\t\t3\n#define\tMD3_MAX_TRIANGLES\t8192\t// per surface\n#define MD3_MAX_VERTS\t\t4096\t// per surface\n#define MD3_MAX_SHADERS\t\t256\t\t// per surface\n#define MD3_MAX_FRAMES\t\t1024\t// per model\n#define\tMD3_MAX_SURFACES\t32\t\t// per model\n#define MD3_MAX_TAGS\t\t16\t\t// per frame\n\n// vertex scales\n#define\tMD3_XYZ_SCALE\t\t(1.0/64)\n\ntypedef struct md3Frame_s {\n\tvec3_t\t\tbounds[2];\n\tvec3_t\t\tlocalOrigin;\n\tfloat\t\tradius;\n\tchar\t\tname[16];\n} md3Frame_t;\n\ntypedef struct md3Tag_s {\n\tchar\t\tname[MAX_QPATH];\t// tag name\n\tvec3_t\t\torigin;\n\tvec3_t\t\taxis[3];\n} md3Tag_t;\n\n/*\n** md3Surface_t\n**\n** CHUNK\t\t\tSIZE\n** header\t\t\tsizeof( md3Surface_t )\n** shaders\t\t\tsizeof( md3Shader_t ) * numShaders\n** triangles[0]\t\tsizeof( md3Triangle_t ) * numTriangles\n** st\t\t\t\tsizeof( md3St_t ) * numVerts\n** XyzNormals\t\tsizeof( md3XyzNormal_t ) * numVerts * numFrames\n*/\ntypedef struct {\n\tint\t\tident;\t\t\t\t// \n\n\tchar\tname[MAX_QPATH];\t// polyset name\n\n\tint\t\tflags;\n\tint\t\tnumFrames;\t\t\t// all surfaces in a model should have the same\n\n\tint\t\tnumShaders;\t\t\t// all surfaces in a model should have the same\n\tint\t\tnumVerts;\n\n\tint\t\tnumTriangles;\n\tint\t\tofsTriangles;\n\n\tint\t\tofsShaders;\t\t\t// offset from start of md3Surface_t\n\tint\t\tofsSt;\t\t\t\t// texture coords are common for all frames\n\tint\t\tofsXyzNormals;\t\t// numVerts * numFrames\n\n\tint\t\tofsEnd;\t\t\t\t// next surface follows\n} md3Surface_t;\n\ntypedef struct {\n\tchar\t\t\tname[MAX_QPATH];\n\tint\t\t\t\tshaderIndex;\t// for in-game use\n} md3Shader_t;\n\ntypedef struct {\n\tint\t\t\tindexes[3];\n} md3Triangle_t;\n\ntypedef struct {\n\tfloat\t\tst[2];\n} md3St_t;\n\ntypedef struct {\n\tshort\t\txyz[3];\n\tshort\t\tnormal;\n} md3XyzNormal_t;\n\ntypedef struct {\n\tint\t\t\tident;\n\tint\t\t\tversion;\n\n\tchar\t\tname[MAX_QPATH];\t// model name\n\n\tint\t\t\tflags;\n\n\tint\t\t\tnumFrames;\n\tint\t\t\tnumTags;\t\t\t\n\tint\t\t\tnumSurfaces;\n\n\tint\t\t\tnumSkins;\n\n\tint\t\t\tofsFrames;\t\t\t// offset for first frame\n\tint\t\t\tofsTags;\t\t\t// numFrames * numTags\n\tint\t\t\tofsSurfaces;\t\t// first surface, others follow\n\n\tint\t\t\tofsEnd;\t\t\t\t// end of file\n} md3Header_t;\n\n/*\n==============================================================================\n\nMD4 file format\n\n==============================================================================\n*/\n\n#define MD4_IDENT\t\t\t(('4'<<24)+('P'<<16)+('D'<<8)+'I')\n#define MD4_VERSION\t\t\t1\n#define\tMD4_MAX_BONES\t\t128\n\ntypedef struct {\n\tint\t\t\tboneIndex;\t\t// these are indexes into the boneReferences,\n\tfloat\t\t   boneWeight;\t\t// not the global per-frame bone list\n\tvec3_t\t\toffset;\n} md4Weight_t;\n\ntypedef struct {\n\tvec3_t\t\tnormal;\n\tvec2_t\t\ttexCoords;\n\tint\t\t\tnumWeights;\n\tmd4Weight_t\tweights[1];\t\t// variable sized\n} md4Vertex_t;\n\ntypedef struct {\n\tint\t\t\tindexes[3];\n} md4Triangle_t;\n\ntypedef struct {\n\tint\t\t\tident;\n\n\tchar\t\tname[MAX_QPATH];\t// polyset name\n\tchar\t\tshader[MAX_QPATH];\n\tint\t\t\tshaderIndex;\t\t// for in-game use\n\n\tint\t\t\tofsHeader;\t\t\t// this will be a negative number\n\n\tint\t\t\tnumVerts;\n\tint\t\t\tofsVerts;\n\n\tint\t\t\tnumTriangles;\n\tint\t\t\tofsTriangles;\n\n\t// Bone references are a set of ints representing all the bones\n\t// present in any vertex weights for this surface.  This is\n\t// needed because a model may have surfaces that need to be\n\t// drawn at different sort times, and we don't want to have\n\t// to re-interpolate all the bones for each surface.\n\tint\t\t\tnumBoneReferences;\n\tint\t\t\tofsBoneReferences;\n\n\tint\t\t\tofsEnd;\t\t\t\t// next surface follows\n} md4Surface_t;\n\ntypedef struct {\n\tfloat\t\tmatrix[3][4];\n} md4Bone_t;\n\ntypedef struct {\n\tvec3_t\t\tbounds[2];\t\t\t// bounds of all surfaces of all LOD's for this frame\n\tvec3_t\t\tlocalOrigin;\t\t// midpoint of bounds, used for sphere cull\n\tfloat\t\tradius;\t\t\t\t// dist from localOrigin to corner\n\tmd4Bone_t\tbones[1];\t\t\t// [numBones]\n} md4Frame_t;\n\ntypedef struct {\n\tint\t\t\tnumSurfaces;\n\tint\t\t\tofsSurfaces;\t\t// first surface, others follow\n\tint\t\t\tofsEnd;\t\t\t\t// next lod follows\n} md4LOD_t;\n\ntypedef struct {\n\tint\t\t\tident;\n\tint\t\t\tversion;\n\n\tchar\t\tname[MAX_QPATH];\t// model name\n\n\t// frames and bones are shared by all levels of detail\n\tint\t\t\tnumFrames;\n\tint\t\t\tnumBones;\n\tint\t\t\tofsBoneNames;\t\t// char\tname[ MAX_QPATH ]\n\tint\t\t\tofsFrames;\t\t\t// md4Frame_t[numFrames]\n\n\t// each level of detail has completely separate sets of surfaces\n\tint\t\t\tnumLODs;\n\tint\t\t\tofsLODs;\n\n\tint\t\t\tofsEnd;\t\t\t\t// end of file\n} md4Header_t;\n\n\n/*\n==============================================================================\n\n  .BSP file format\n\n==============================================================================\n*/\n\n\n#define BSP_IDENT\t(('P'<<24)+('S'<<16)+('B'<<8)+'I')\n\t\t// little-endian \"IBSP\"\n\n#define BSP_VERSION\t\t\t46\n\n\n// there shouldn't be any problem with increasing these values at the\n// expense of more memory allocation in the utilities\n#define\tMAX_MAP_MODELS\t\t0x400\n#define\tMAX_MAP_BRUSHES\t\t0x8000\n#define\tMAX_MAP_ENTITIES\t0x800\n#define\tMAX_MAP_ENTSTRING\t0x40000\n#define\tMAX_MAP_SHADERS\t\t0x400\n\n#define\tMAX_MAP_AREAS\t\t0x100\t// MAX_MAP_AREA_BYTES in q_shared must match!\n#define\tMAX_MAP_FOGS\t\t0x100\n#define\tMAX_MAP_PLANES\t\t0x20000\n#define\tMAX_MAP_NODES\t\t0x20000\n#define\tMAX_MAP_BRUSHSIDES\t0x20000\n#define\tMAX_MAP_LEAFS\t\t0x20000\n#define\tMAX_MAP_LEAFFACES\t0x20000\n#define\tMAX_MAP_LEAFBRUSHES 0x40000\n#define\tMAX_MAP_PORTALS\t\t0x20000\n#define\tMAX_MAP_LIGHTING\t0x800000\n#define\tMAX_MAP_LIGHTGRID\t0x800000\n#define\tMAX_MAP_VISIBILITY\t0x200000\n\n#define\tMAX_MAP_DRAW_SURFS\t0x20000\n#define\tMAX_MAP_DRAW_VERTS\t0x80000\n#define\tMAX_MAP_DRAW_INDEXES\t0x80000\n\n\n// key / value pair sizes in the entities lump\n#define\tMAX_KEY\t\t\t\t32\n#define\tMAX_VALUE\t\t\t1024\n\n// the editor uses these predefined yaw angles to orient entities up or down\n#define\tANGLE_UP\t\t\t-1\n#define\tANGLE_DOWN\t\t\t-2\n\n#define\tLIGHTMAP_WIDTH\t\t128\n#define\tLIGHTMAP_HEIGHT\t\t128\n\n#define MAX_WORLD_COORD\t\t( 128*1024 )\n#define MIN_WORLD_COORD\t\t( -128*1024 )\n#define WORLD_SIZE\t\t\t( MAX_WORLD_COORD - MIN_WORLD_COORD )\n\n//=============================================================================\n\n\ntypedef struct {\n\tint\t\tfileofs, filelen;\n} lump_t;\n\n#define\tLUMP_ENTITIES\t\t0\n#define\tLUMP_SHADERS\t\t1\n#define\tLUMP_PLANES\t\t\t2\n#define\tLUMP_NODES\t\t\t3\n#define\tLUMP_LEAFS\t\t\t4\n#define\tLUMP_LEAFSURFACES\t5\n#define\tLUMP_LEAFBRUSHES\t6\n#define\tLUMP_MODELS\t\t\t7\n#define\tLUMP_BRUSHES\t\t8\n#define\tLUMP_BRUSHSIDES\t\t9\n#define\tLUMP_DRAWVERTS\t\t10\n#define\tLUMP_DRAWINDEXES\t11\n#define\tLUMP_FOGS\t\t\t12\n#define\tLUMP_SURFACES\t\t13\n#define\tLUMP_LIGHTMAPS\t\t14\n#define\tLUMP_LIGHTGRID\t\t15\n#define\tLUMP_VISIBILITY\t\t16\n#define\tHEADER_LUMPS\t\t17\n\ntypedef struct {\n\tint\t\t\tident;\n\tint\t\t\tversion;\n\n\tlump_t\t\tlumps[HEADER_LUMPS];\n} dheader_t;\n\ntypedef struct {\n\tfloat\t\tmins[3], maxs[3];\n\tint\t\t\tfirstSurface, numSurfaces;\n\tint\t\t\tfirstBrush, numBrushes;\n} dmodel_t;\n\ntypedef struct {\n\tchar\t\tshader[MAX_QPATH];\n\tint\t\t\tsurfaceFlags;\n\tint\t\t\tcontentFlags;\n} dshader_t;\n\n// planes x^1 is allways the opposite of plane x\n\ntypedef struct {\n\tfloat\t\tnormal[3];\n\tfloat\t\tdist;\n} dplane_t;\n\ntypedef struct {\n\tint\t\t\tplaneNum;\n\tint\t\t\tchildren[2];\t// negative numbers are -(leafs+1), not nodes\n\tint\t\t\tmins[3];\t\t// for frustom culling\n\tint\t\t\tmaxs[3];\n} dnode_t;\n\ntypedef struct {\n\tint\t\t\tcluster;\t\t\t// -1 = opaque cluster (do I still store these?)\n\tint\t\t\tarea;\n\n\tint\t\t\tmins[3];\t\t\t// for frustum culling\n\tint\t\t\tmaxs[3];\n\n\tint\t\t\tfirstLeafSurface;\n\tint\t\t\tnumLeafSurfaces;\n\n\tint\t\t\tfirstLeafBrush;\n\tint\t\t\tnumLeafBrushes;\n} dleaf_t;\n\ntypedef struct {\n\tint\t\t\tplaneNum;\t\t\t// positive plane side faces out of the leaf\n\tint\t\t\tshaderNum;\n} dbrushside_t;\n\ntypedef struct {\n\tint\t\t\tfirstSide;\n\tint\t\t\tnumSides;\n\tint\t\t\tshaderNum;\t\t// the shader that determines the contents flags\n} dbrush_t;\n\ntypedef struct {\n\tchar\t\tshader[MAX_QPATH];\n\tint\t\t\tbrushNum;\n\tint\t\t\tvisibleSide;\t// the brush side that ray tests need to clip against (-1 == none)\n} dfog_t;\n\ntypedef struct {\n\tvec3_t\t\txyz;\n\tfloat\t\tst[2];\n\tfloat\t\tlightmap[2];\n\tvec3_t\t\tnormal;\n\tbyte\t\tcolor[4];\n} drawVert_t;\n\ntypedef enum {\n\tMST_BAD,\n\tMST_PLANAR,\n\tMST_PATCH,\n\tMST_TRIANGLE_SOUP,\n\tMST_FLARE\n} mapSurfaceType_t;\n\ntypedef struct {\n\tint\t\t\tshaderNum;\n\tint\t\t\tfogNum;\n\tint\t\t\tsurfaceType;\n\n\tint\t\t\tfirstVert;\n\tint\t\t\tnumVerts;\n\n\tint\t\t\tfirstIndex;\n\tint\t\t\tnumIndexes;\n\n\tint\t\t\tlightmapNum;\n\tint\t\t\tlightmapX, lightmapY;\n\tint\t\t\tlightmapWidth, lightmapHeight;\n\n\tvec3_t\t\tlightmapOrigin;\n\tvec3_t\t\tlightmapVecs[3];\t// for patches, [0] and [1] are lodbounds\n\n\tint\t\t\tpatchWidth;\n\tint\t\t\tpatchHeight;\n} dsurface_t;\n\n\n#endif\n"
  },
  {
    "path": "code/qcommon/unzip.c",
    "content": "/*****************************************************************************\n * name:\t\tunzip.c\n *\n * desc:\t\tIO on .zip files using portions of zlib \n *\n * $Archive: /MissionPack/code/qcommon/unzip.c $\n *\n *****************************************************************************/\n\n#include \"../client/client.h\"\n#include \"unzip.h\"\n\n/* unzip.h -- IO for uncompress .zip files using zlib \n   Version 0.15 beta, Mar 19th, 1998,\n\n   Copyright (C) 1998 Gilles Vollant\n\n   This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g\n     WinZip, InfoZip tools and compatible.\n   Encryption and multi volume ZipFile (span) are not supported.\n   Old compressions used by old PKZip 1.x are not supported\n\n   THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE\n   CAN CHANGE IN FUTURE VERSION !!\n   I WAIT FEEDBACK at mail info@winimage.com\n   Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution\n\n   Condition of use and distribution are the same than zlib :\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n\n*/\n/* for more info about .ZIP format, see \n      ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip\n   PkWare has also a specification at :\n      ftp://ftp.pkware.com/probdesc.zip */\n\n/* zlib.h -- interface of the 'zlib' general purpose compression library\n  version 1.1.3, July 9th, 1998\n\n  Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n  Jean-loup Gailly        Mark Adler\n  jloup@gzip.org          madler@alumni.caltech.edu\n\n\n  The data format used by the zlib library is described by RFCs (Request for\n  Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt\n  (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).\n*/\n\n/* zconf.h -- configuration of the zlib compression library\n * Copyright (C) 1995-1998 Jean-loup Gailly.\n * For conditions of distribution and use, see copyright notice in zlib.h \n */\n\n\n#ifndef _ZCONF_H\n#define _ZCONF_H\n\n/* Maximum value for memLevel in deflateInit2 */\n#ifndef MAX_MEM_LEVEL\n#  ifdef MAXSEG_64K\n#    define MAX_MEM_LEVEL 8\n#  else\n#    define MAX_MEM_LEVEL 9\n#  endif\n#endif\n\n/* Maximum value for windowBits in deflateInit2 and inflateInit2.\n * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files\n * created by gzip. (Files created by minigzip can still be extracted by\n * gzip.)\n */\n#ifndef MAX_WBITS\n#  define MAX_WBITS   15 /* 32K LZ77 window */\n#endif\n\n/* The memory requirements for deflate are (in bytes):\n            (1 << (windowBits+2)) +  (1 << (memLevel+9))\n that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)\n plus a few kilobytes for small objects. For example, if you want to reduce\n the default memory requirements from 256K to 128K, compile with\n     make CFLAGS=\"-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7\"\n Of course this will generally degrade compression (there's no free lunch).\n\n   The memory requirements for inflate are (in bytes) 1 << windowBits\n that is, 32K for windowBits=15 (default value) plus a few kilobytes\n for small objects.\n*/\n\n                        /* Type declarations */\n\n#ifndef OF /* function prototypes */\n#define OF(args)  args\n#endif\n\ntypedef unsigned char  Byte;  /* 8 bits */\ntypedef unsigned int   uInt;  /* 16 bits or more */\ntypedef unsigned long  uLong; /* 32 bits or more */\ntypedef Byte    *voidp;\n\n#ifndef SEEK_SET\n#  define SEEK_SET        0       /* Seek from beginning of file.  */\n#  define SEEK_CUR        1       /* Seek from current position.  */\n#  define SEEK_END        2       /* Set file pointer to EOF plus \"offset\" */\n#endif\n\n#endif /* _ZCONF_H */\n\n#define ZLIB_VERSION \"1.1.3\"\n\n/* \n     The 'zlib' compression library provides in-memory compression and\n  decompression functions, including integrity checks of the uncompressed\n  data.  This version of the library supports only one compression method\n  (deflation) but other algorithms will be added later and will have the same\n  stream interface.\n\n     Compression can be done in a single step if the buffers are large\n  enough (for example if an input file is mmap'ed), or can be done by\n  repeated calls of the compression function.  In the latter case, the\n  application must provide more input and/or consume the output\n  (providing more output space) before each call.\n\n     The library also supports reading and writing files in gzip (.gz) format\n  with an interface similar to that of stdio.\n\n     The library does not install any signal handler. The decoder checks\n  the consistency of the compressed data, so the library should never\n  crash even in case of corrupted input.\n*/\n\n/*\n   The application must update next_in and avail_in when avail_in has\n   dropped to zero. It must update next_out and avail_out when avail_out\n   has dropped to zero. The application must initialize zalloc, zfree and\n   opaque before calling the init function. All other fields are set by the\n   compression library and must not be updated by the application.\n\n   The opaque value provided by the application will be passed as the first\n   parameter for calls of zalloc and zfree. This can be useful for custom\n   memory management. The compression library attaches no meaning to the\n   opaque value.\n\n   zalloc must return Z_NULL if there is not enough memory for the object.\n   If zlib is used in a multi-threaded application, zalloc and zfree must be\n   thread safe.\n\n   On 16-bit systems, the functions zalloc and zfree must be able to allocate\n   exactly 65536 bytes, but will not be required to allocate more than this\n   if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,\n   pointers returned by zalloc for objects of exactly 65536 bytes *must*\n   have their offset normalized to zero. The default allocation function\n   provided by this library ensures this (see zutil.c). To reduce memory\n   requirements and avoid any allocation of 64K objects, at the expense of\n   compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).\n\n   The fields total_in and total_out can be used for statistics or\n   progress reports. After compression, total_in holds the total size of\n   the uncompressed data and may be saved for use in the decompressor\n   (particularly if the decompressor wants to decompress everything in\n   a single step).\n*/\n\n                        /* constants */\n\n#define Z_NO_FLUSH      0\n#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */\n#define Z_SYNC_FLUSH    2\n#define Z_FULL_FLUSH    3\n#define Z_FINISH        4\n/* Allowed flush values; see deflate() below for details */\n\n#define Z_OK            0\n#define Z_STREAM_END    1\n#define Z_NEED_DICT     2\n#define Z_ERRNO        (-1)\n#define Z_STREAM_ERROR (-2)\n#define Z_DATA_ERROR   (-3)\n#define Z_MEM_ERROR    (-4)\n#define Z_BUF_ERROR    (-5)\n#define Z_VERSION_ERROR (-6)\n/* Return codes for the compression/decompression functions. Negative\n * values are errors, positive values are used for special but normal events.\n */\n\n#define Z_NO_COMPRESSION         0\n#define Z_BEST_SPEED             1\n#define Z_BEST_COMPRESSION       9\n#define Z_DEFAULT_COMPRESSION  (-1)\n/* compression levels */\n\n#define Z_FILTERED            1\n#define Z_HUFFMAN_ONLY        2\n#define Z_DEFAULT_STRATEGY    0\n/* compression strategy; see deflateInit2() below for details */\n\n#define Z_BINARY   0\n#define Z_ASCII    1\n#define Z_UNKNOWN  2\n/* Possible values of the data_type field */\n\n#define Z_DEFLATED   8\n/* The deflate compression method (the only one supported in this version) */\n\n#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */\n\n#define zlib_version zlibVersion()\n/* for compatibility with versions < 1.0.2 */\n\n                        /* basic functions */\n\n// static const char * zlibVersion OF((void));\n/* The application can compare zlibVersion and ZLIB_VERSION for consistency.\n   If the first character differs, the library code actually used is\n   not compatible with the zlib.h header file used by the application.\n   This check is automatically made by deflateInit and inflateInit.\n */\n\n/* \nint deflateInit OF((z_streamp strm, int level));\n\n     Initializes the internal stream state for compression. The fields\n   zalloc, zfree and opaque must be initialized before by the caller.\n   If zalloc and zfree are set to Z_NULL, deflateInit updates them to\n   use default allocation functions.\n\n     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:\n   1 gives best speed, 9 gives best compression, 0 gives no compression at\n   all (the input data is simply copied a block at a time).\n   Z_DEFAULT_COMPRESSION requests a default compromise between speed and\n   compression (currently equivalent to level 6).\n\n     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if level is not a valid compression level,\n   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible\n   with the version assumed by the caller (ZLIB_VERSION).\n   msg is set to null if there is no error message.  deflateInit does not\n   perform any compression: this will be done by deflate().\n*/\n\n\n// static int deflate OF((z_streamp strm, int flush));\n/*\n    deflate compresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full. It may introduce some\n  output latency (reading input without producing any output) except when\n  forced to flush.\n\n    The detailed semantics are as follows. deflate performs one or both of the\n  following actions:\n\n  - Compress more input starting at next_in and update next_in and avail_in\n    accordingly. If not all input can be processed (because there is not\n    enough room in the output buffer), next_in and avail_in are updated and\n    processing will resume at this point for the next call of deflate().\n\n  - Provide more output starting at next_out and update next_out and avail_out\n    accordingly. This action is forced if the parameter flush is non zero.\n    Forcing flush frequently degrades the compression ratio, so this parameter\n    should be set only when necessary (in interactive applications).\n    Some output may be provided even if flush is not set.\n\n  Before the call of deflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming\n  more output, and updating avail_in or avail_out accordingly; avail_out\n  should never be zero before the call. The application can consume the\n  compressed output when it wants, for example when the output buffer is full\n  (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK\n  and with zero avail_out, it must be called again after making room in the\n  output buffer because there might be more output pending.\n\n    If the parameter flush is set to Z_SYNC_FLUSH, all pending output is\n  flushed to the output buffer and the output is aligned on a byte boundary, so\n  that the decompressor can get all input data available so far. (In particular\n  avail_in is zero after the call if enough output space has been provided\n  before the call.)  Flushing may degrade compression for some compression\n  algorithms and so it should be used only when necessary.\n\n    If flush is set to Z_FULL_FLUSH, all output is flushed as with\n  Z_SYNC_FLUSH, and the compression state is reset so that decompression can\n  restart from this point if previous compressed data has been damaged or if\n  random access is desired. Using Z_FULL_FLUSH too often can seriously degrade\n  the compression.\n\n    If deflate returns with avail_out == 0, this function must be called again\n  with the same value of the flush parameter and more output space (updated\n  avail_out), until the flush is complete (deflate returns with non-zero\n  avail_out).\n\n    If the parameter flush is set to Z_FINISH, pending input is processed,\n  pending output is flushed and deflate returns with Z_STREAM_END if there\n  was enough output space; if deflate returns with Z_OK, this function must be\n  called again with Z_FINISH and more output space (updated avail_out) but no\n  more input data, until it returns with Z_STREAM_END or an error. After\n  deflate has returned Z_STREAM_END, the only possible operations on the\n  stream are deflateReset or deflateEnd.\n  \n    Z_FINISH can be used immediately after deflateInit if all the compression\n  is to be done in a single step. In this case, avail_out must be at least\n  0.1% larger than avail_in plus 12 bytes.  If deflate does not return\n  Z_STREAM_END, then it must be called again as described above.\n\n    deflate() sets strm->adler to the adler32 checksum of all input read\n  so (that is, total_in bytes).\n\n    deflate() may update data_type if it can make a good guess about\n  the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered\n  binary. This field is only for information purposes and does not affect\n  the compression algorithm in any manner.\n\n    deflate() returns Z_OK if some progress has been made (more input\n  processed or more output produced), Z_STREAM_END if all input has been\n  consumed and all output has been produced (only when flush is set to\n  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example\n  if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible\n  (for example avail_in or avail_out was zero).\n*/\n\n\n// static int deflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any\n   pending output.\n\n     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the\n   stream state was inconsistent, Z_DATA_ERROR if the stream was freed\n   prematurely (some input or output was discarded). In the error case,\n   msg may be set but then points to a static string (which must not be\n   deallocated).\n*/\n\n\n/* \nint inflateInit OF((z_streamp strm));\n\n     Initializes the internal stream state for decompression. The fields\n   next_in, avail_in, zalloc, zfree and opaque must be initialized before by\n   the caller. If next_in is not Z_NULL and avail_in is large enough (the exact\n   value depends on the compression method), inflateInit determines the\n   compression method from the zlib header and allocates all data structures\n   accordingly; otherwise the allocation will be deferred to the first call of\n   inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to\n   use default allocation functions.\n\n     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller.  msg is set to null if there is no error\n   message. inflateInit does not perform any decompression apart from reading\n   the zlib header if present: this will be done by inflate().  (So next_in and\n   avail_in may be modified, but next_out and avail_out are unchanged.)\n*/\n\n\nstatic int inflate OF((z_streamp strm, int flush));\n/*\n    inflate decompresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full. It may some\n  introduce some output latency (reading input without producing any output)\n  except when forced to flush.\n\n  The detailed semantics are as follows. inflate performs one or both of the\n  following actions:\n\n  - Decompress more input starting at next_in and update next_in and avail_in\n    accordingly. If not all input can be processed (because there is not\n    enough room in the output buffer), next_in is updated and processing\n    will resume at this point for the next call of inflate().\n\n  - Provide more output starting at next_out and update next_out and avail_out\n    accordingly.  inflate() provides as much output as possible, until there\n    is no more input data or no more space in the output buffer (see below\n    about the flush parameter).\n\n  Before the call of inflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming\n  more output, and updating the next_* and avail_* values accordingly.\n  The application can consume the uncompressed output when it wants, for\n  example when the output buffer is full (avail_out == 0), or after each\n  call of inflate(). If inflate returns Z_OK and with zero avail_out, it\n  must be called again after making room in the output buffer because there\n  might be more output pending.\n\n    If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much\n  output as possible to the output buffer. The flushing behavior of inflate is\n  not specified for values of the flush parameter other than Z_SYNC_FLUSH\n  and Z_FINISH, but the current implementation actually flushes as much output\n  as possible anyway.\n\n    inflate() should normally be called until it returns Z_STREAM_END or an\n  error. However if all decompression is to be performed in a single step\n  (a single call of inflate), the parameter flush should be set to\n  Z_FINISH. In this case all pending input is processed and all pending\n  output is flushed; avail_out must be large enough to hold all the\n  uncompressed data. (The size of the uncompressed data may have been saved\n  by the compressor for this purpose.) The next operation on this stream must\n  be inflateEnd to deallocate the decompression state. The use of Z_FINISH\n  is never required, but can be used to inform inflate that a faster routine\n  may be used for the single inflate() call.\n\n     If a preset dictionary is needed at this point (see inflateSetDictionary\n  below), inflate sets strm-adler to the adler32 checksum of the\n  dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise \n  it sets strm->adler to the adler32 checksum of all output produced\n  so (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or\n  an error code as described below. At the end of the stream, inflate()\n  checks that its computed adler32 checksum is equal to that saved by the\n  compressor and returns Z_STREAM_END only if the checksum is correct.\n\n    inflate() returns Z_OK if some progress has been made (more input processed\n  or more output produced), Z_STREAM_END if the end of the compressed data has\n  been reached and all uncompressed output has been produced, Z_NEED_DICT if a\n  preset dictionary is needed at this point, Z_DATA_ERROR if the input data was\n  corrupted (input stream not conforming to the zlib format or incorrect\n  adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent\n  (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not\n  enough memory, Z_BUF_ERROR if no progress is possible or if there was not\n  enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR\n  case, the application may then call inflateSync to look for a good\n  compression block.\n*/\n\n\nstatic int inflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any\n   pending output.\n\n     inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state\n   was inconsistent. In the error case, msg may be set but then points to a\n   static string (which must not be deallocated).\n*/\n\n                        /* Advanced functions */\n\n/*\n    The following functions are needed only in some special applications.\n*/\n\n/*   \nint deflateInit2 OF((z_streamp strm,\n                                     int  level,\n                                     int  method,\n                                     int  windowBits,\n                                     int  memLevel,\n                                     int  strategy));\n\n     This is another version of deflateInit with more compression options. The\n   fields next_in, zalloc, zfree and opaque must be initialized before by\n   the caller.\n\n     The method parameter is the compression method. It must be Z_DEFLATED in\n   this version of the library.\n\n     The windowBits parameter is the base two logarithm of the window size\n   (the size of the history buffer).  It should be in the range 8..15 for this\n   version of the library. Larger values of this parameter result in better\n   compression at the expense of memory usage. The default value is 15 if\n   deflateInit is used instead.\n\n     The memLevel parameter specifies how much memory should be allocated\n   for the internal compression state. memLevel=1 uses minimum memory but\n   is slow and reduces compression ratio; memLevel=9 uses maximum memory\n   for optimal speed. The default value is 8. See zconf.h for total memory\n   usage as a function of windowBits and memLevel.\n\n     The strategy parameter is used to tune the compression algorithm. Use the\n   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a\n   filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no\n   string match).  Filtered data consists mostly of small values with a\n   somewhat random distribution. In this case, the compression algorithm is\n   tuned to compress them better. The effect of Z_FILTERED is to force more\n   Huffman coding and less string matching; it is somewhat intermediate\n   between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects\n   the compression ratio but not the correctness of the compressed output even\n   if it is not set appropriately.\n\n      deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid\n   method). msg is set to null if there is no error message.  deflateInit2 does\n   not perform any compression: this will be done by deflate().\n*/\n                            \n/*\nstatic int deflateSetDictionary OF((z_streamp strm,\n                                             const Byte *dictionary,\n                                             uInt  dictLength));\n*/\n/*\n     Initializes the compression dictionary from the given byte sequence\n   without producing any compressed output. This function must be called\n   immediately after deflateInit, deflateInit2 or deflateReset, before any\n   call of deflate. The compressor and decompressor must use exactly the same\n   dictionary (see inflateSetDictionary).\n\n     The dictionary should consist of strings (byte sequences) that are likely\n   to be encountered later in the data to be compressed, with the most commonly\n   used strings preferably put towards the end of the dictionary. Using a\n   dictionary is most useful when the data to be compressed is short and can be\n   predicted with good accuracy; the data can then be compressed better than\n   with the default empty dictionary.\n\n     Depending on the size of the compression data structures selected by\n   deflateInit or deflateInit2, a part of the dictionary may in effect be\n   discarded, for example if the dictionary is larger than the window size in\n   deflate or deflate2. Thus the strings most likely to be useful should be\n   put at the end of the dictionary, not at the front.\n\n     Upon return of this function, strm->adler is set to the Adler32 value\n   of the dictionary; the decompressor may later use this value to determine\n   which dictionary has been used by the compressor. (The Adler32 value\n   applies to the whole dictionary even if only a subset of the dictionary is\n   actually used by the compressor.)\n\n     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a\n   parameter is invalid (such as NULL dictionary) or the stream state is\n   inconsistent (for example if deflate has already been called for this stream\n   or if the compression method is bsort). deflateSetDictionary does not\n   perform any compression: this will be done by deflate().\n*/\n\n/*\nstatic int deflateCopy OF((z_streamp dest,\n                                    z_streamp source));\n*/\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when several compression strategies will be\n   tried, for example when there are several ways of pre-processing the input\n   data with a filter. The streams that will be discarded should then be freed\n   by calling deflateEnd.  Note that deflateCopy duplicates the internal\n   compression state which can be quite large, so this strategy is slow and\n   can consume lots of memory.\n\n     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being NULL). msg is left unchanged in both source and\n   destination.\n*/\n\n// static int deflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to deflateEnd followed by deflateInit,\n   but does not free and reallocate all the internal compression state.\n   The stream will keep the same compression level and any other attributes\n   that may have been set by deflateInit2.\n\n      deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being NULL).\n*/\n\n/*\nstatic int deflateParams OF((z_streamp strm,\n\t\t\t\t      int level,\n\t\t\t\t      int strategy));\n*/\n/*\n     Dynamically update the compression level and compression strategy.  The\n   interpretation of level and strategy is as in deflateInit2.  This can be\n   used to switch between compression and straight copy of the input data, or\n   to switch to a different kind of input data requiring a different\n   strategy. If the compression level is changed, the input available so far\n   is compressed with the old level (and may be flushed); the new level will\n   take effect only at the next call of deflate().\n\n     Before the call of deflateParams, the stream state must be set as for\n   a call of deflate(), since the currently available input may have to\n   be compressed and flushed. In particular, strm->avail_out must be non-zero.\n\n     deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source\n   stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR\n   if strm->avail_out was zero.\n*/\n\n/*   \nint inflateInit2 OF((z_streamp strm,\n                                     int  windowBits));\n\n     This is another version of inflateInit with an extra parameter. The\n   fields next_in, avail_in, zalloc, zfree and opaque must be initialized\n   before by the caller.\n\n     The windowBits parameter is the base two logarithm of the maximum window\n   size (the size of the history buffer).  It should be in the range 8..15 for\n   this version of the library. The default value is 15 if inflateInit is used\n   instead. If a compressed stream with a larger window size is given as\n   input, inflate() will return with the error code Z_DATA_ERROR instead of\n   trying to allocate a larger window.\n\n      inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative\n   memLevel). msg is set to null if there is no error message.  inflateInit2\n   does not perform any decompression apart from reading the zlib header if\n   present: this will be done by inflate(). (So next_in and avail_in may be\n   modified, but next_out and avail_out are unchanged.)\n*/\n\n/*\nstatic int inflateSetDictionary OF((z_streamp strm,\n                                             const Byte *dictionary,\n                                             uInt  dictLength));\n*/\n/*\n     Initializes the decompression dictionary from the given uncompressed byte\n   sequence. This function must be called immediately after a call of inflate\n   if this call returned Z_NEED_DICT. The dictionary chosen by the compressor\n   can be determined from the Adler32 value returned by this call of\n   inflate. The compressor and decompressor must use exactly the same\n   dictionary (see deflateSetDictionary).\n\n     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a\n   parameter is invalid (such as NULL dictionary) or the stream state is\n   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the\n   expected one (incorrect Adler32 value). inflateSetDictionary does not\n   perform any decompression: this will be done by subsequent calls of\n   inflate().\n*/\n\n// static int inflateSync OF((z_streamp strm));\n/* \n    Skips invalid compressed data until a full flush point (see above the\n  description of deflate with Z_FULL_FLUSH) can be found, or until all\n  available input is skipped. No output is provided.\n\n    inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR\n  if no more input was provided, Z_DATA_ERROR if no flush point has been found,\n  or Z_STREAM_ERROR if the stream structure was inconsistent. In the success\n  case, the application may save the current current value of total_in which\n  indicates where valid compressed data was found. In the error case, the\n  application may repeatedly call inflateSync, providing more input each time,\n  until success or end of the input data.\n*/\n\nstatic int inflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to inflateEnd followed by inflateInit,\n   but does not free and reallocate all the internal decompression state.\n   The stream will keep attributes that may have been set by inflateInit2.\n\n      inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being NULL).\n*/\n\n\n                        /* utility functions */\n\n/*\n     The following utility functions are implemented on top of the\n   basic stream-oriented functions. To simplify the interface, some\n   default options are assumed (compression level and memory usage,\n   standard memory allocation functions). The source code of these\n   utility functions can easily be modified if you need special options.\n*/\n\n/*\nstatic int compress OF((Byte *dest,   uLong *destLen,\n                                 const Byte *source, uLong sourceLen));\n*/\n/*\n     Compresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer. Upon entry, destLen is the total\n   size of the destination buffer, which must be at least 0.1% larger than\n   sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the\n   compressed buffer.\n     This function can be used to compress a whole file at once if the\n   input file is mmap'ed.\n     compress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer.\n*/\n\n/*\nstatic int compress2 OF((Byte *dest,   uLong *destLen,\n                                  const Byte *source, uLong sourceLen,\n                                  int level));\n*/\n/*\n     Compresses the source buffer into the destination buffer. The level\n   parameter has the same meaning as in deflateInit.  sourceLen is the byte\n   length of the source buffer. Upon entry, destLen is the total size of the\n   destination buffer, which must be at least 0.1% larger than sourceLen plus\n   12 bytes. Upon exit, destLen is the actual size of the compressed buffer.\n\n     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_BUF_ERROR if there was not enough room in the output buffer,\n   Z_STREAM_ERROR if the level parameter is invalid.\n*/\n\n/*\nstatic int uncompress OF((Byte *dest,   uLong *destLen,\n                                   const Byte *source, uLong sourceLen));\n*/                                   \n/*\n     Decompresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer. Upon entry, destLen is the total\n   size of the destination buffer, which must be large enough to hold the\n   entire uncompressed data. (The size of the uncompressed data must have\n   been saved previously by the compressor and transmitted to the decompressor\n   by some mechanism outside the scope of this compression library.)\n   Upon exit, destLen is the actual size of the compressed buffer.\n     This function can be used to decompress a whole file at once if the\n   input file is mmap'ed.\n\n     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer, or Z_DATA_ERROR if the input data was corrupted.\n*/\n\n\ntypedef voidp gzFile;\n\ngzFile gzopen  OF((const char *path, const char *mode));\n/*\n     Opens a gzip (.gz) file for reading or writing. The mode parameter\n   is as in fopen (\"rb\" or \"wb\") but can also include a compression level\n   (\"wb9\") or a strategy: 'f' for filtered data as in \"wb6f\", 'h' for\n   Huffman only compression as in \"wb1h\". (See the description\n   of deflateInit2 for more information about the strategy parameter.)\n\n     gzopen can be used to read a file which is not in gzip format; in this\n   case gzread will directly read from the file without decompression.\n\n     gzopen returns NULL if the file could not be opened or if there was\n   insufficient memory to allocate the (de)compression state; errno\n   can be checked to distinguish the two cases (if errno is zero, the\n   zlib error is Z_MEM_ERROR).  */\n\ngzFile gzdopen  OF((int fd, const char *mode));\n/*\n     gzdopen() associates a gzFile with the file descriptor fd.  File\n   descriptors are obtained from calls like open, dup, creat, pipe or\n   fileno (in the file has been previously opened with fopen).\n   The mode parameter is as in gzopen.\n     The next call of gzclose on the returned gzFile will also close the\n   file descriptor fd, just like fclose(fdopen(fd), mode) closes the file\n   descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).\n     gzdopen returns NULL if there was insufficient memory to allocate\n   the (de)compression state.\n*/\n\nint gzsetparams OF((gzFile file, int level, int strategy));\n/*\n     Dynamically update the compression level or strategy. See the description\n   of deflateInit2 for the meaning of these parameters.\n     gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not\n   opened for writing.\n*/\n\nint    gzread  OF((gzFile file, voidp buf, unsigned len));\n/*\n     Reads the given number of uncompressed bytes from the compressed file.\n   If the input file was not in gzip format, gzread copies the given number\n   of bytes into the buffer.\n     gzread returns the number of uncompressed bytes actually read (0 for\n   end of file, -1 for error). */\n\nint    gzwrite OF((gzFile file, \n\t\t\t\t   const voidp buf, unsigned len));\n/*\n     Writes the given number of uncompressed bytes into the compressed file.\n   gzwrite returns the number of uncompressed bytes actually written\n   (0 in case of error).\n*/\n\nint    QDECL gzprintf OF((gzFile file, const char *format, ...));\n/*\n     Converts, formats, and writes the args to the compressed file under\n   control of the format string, as in fprintf. gzprintf returns the number of\n   uncompressed bytes actually written (0 in case of error).\n*/\n\nint gzputs OF((gzFile file, const char *s));\n/*\n      Writes the given null-terminated string to the compressed file, excluding\n   the terminating null character.\n      gzputs returns the number of characters written, or -1 in case of error.\n*/\n\nchar * gzgets OF((gzFile file, char *buf, int len));\n/*\n      Reads bytes from the compressed file until len-1 characters are read, or\n   a newline character is read and transferred to buf, or an end-of-file\n   condition is encountered.  The string is then terminated with a null\n   character.\n      gzgets returns buf, or Z_NULL in case of error.\n*/\n\nint    gzputc OF((gzFile file, int c));\n/*\n      Writes c, converted to an unsigned char, into the compressed file.\n   gzputc returns the value that was written, or -1 in case of error.\n*/\n\nint    gzgetc OF((gzFile file));\n/*\n      Reads one byte from the compressed file. gzgetc returns this byte\n   or -1 in case of end of file or error.\n*/\n\nint    gzflush OF((gzFile file, int flush));\n/*\n     Flushes all pending output into the compressed file. The parameter\n   flush is as in the deflate() function. The return value is the zlib\n   error number (see function gzerror below). gzflush returns Z_OK if\n   the flush parameter is Z_FINISH and all output could be flushed.\n     gzflush should be called only when strictly necessary because it can\n   degrade compression.\n*/\n\nlong gzseek OF((gzFile file,\n\t\t\t\t      long offset, int whence));\n/* \n      Sets the starting position for the next gzread or gzwrite on the\n   given compressed file. The offset represents a number of bytes in the\n   uncompressed data stream. The whence parameter is defined as in lseek(2);\n   the value SEEK_END is not supported.\n     If the file is opened for reading, this function is emulated but can be\n   extremely slow. If the file is opened for writing, only forward seeks are\n   supported; gzseek then compresses a sequence of zeroes up to the new\n   starting position.\n\n      gzseek returns the resulting offset location as measured in bytes from\n   the beginning of the uncompressed stream, or -1 in case of error, in\n   particular if the file is opened for writing and the new starting position\n   would be before the current position.\n*/\n\nint    gzrewind OF((gzFile file));\n/*\n     Rewinds the given file. This function is supported only for reading.\n\n   gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)\n*/\n\nlong    gztell OF((gzFile file));\n/*\n     Returns the starting position for the next gzread or gzwrite on the\n   given compressed file. This position represents a number of bytes in the\n   uncompressed data stream.\n\n   gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)\n*/\n\nint gzeof OF((gzFile file));\n/*\n     Returns 1 when EOF has previously been detected reading the given\n   input stream, otherwise zero.\n*/\n\nint    gzclose OF((gzFile file));\n/*\n     Flushes all pending output if necessary, closes the compressed file\n   and deallocates all the (de)compression state. The return value is the zlib\n   error number (see function gzerror below).\n*/\n\n// static const char * gzerror OF((gzFile file, int *errnum));\n/*\n     Returns the error message for the last error which occurred on the\n   given compressed file. errnum is set to zlib error number. If an\n   error occurred in the file system and not in the compression library,\n   errnum is set to Z_ERRNO and the application may consult errno\n   to get the exact error code.\n*/\n\n                        /* checksum functions */\n\n/*\n     These functions are not related to compression but are exported\n   anyway because they might be useful in applications using the\n   compression library.\n*/\n\nstatic uLong adler32 OF((uLong adler, const Byte *buf, uInt len));\n\n/*\n     Update a running Adler-32 checksum with the bytes buf[0..len-1] and\n   return the updated checksum. If buf is NULL, this function returns\n   the required initial value for the checksum.\n   An Adler-32 checksum is almost as reliable as a CRC32 but can be computed\n   much faster. Usage example:\n\n     uLong adler = adler32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       adler = adler32(adler, buffer, length);\n     }\n     if (adler != original_adler) error();\n*/\n\n                        /* various hacks, don't look :) */\n\n/* deflateInit and inflateInit are macros to allow checking the zlib version\n * and the compiler's view of z_stream:\n */\n/*\nstatic int deflateInit_ OF((z_streamp strm, int level,\n                                     const char *version, int stream_size));\nstatic int inflateInit_ OF((z_streamp strm,\n                                     const char *version, int stream_size));\nstatic int deflateInit2_ OF((z_streamp strm, int  level, int  method,\n                                      int windowBits, int memLevel,\n                                      int strategy, const char *version,\n                                      int stream_size));\n*/\nstatic int inflateInit2_ OF((z_streamp strm, int  windowBits,\n                                      const char *version, int stream_size));\n\n#define deflateInit(strm, level) \\\n        deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream))\n#define inflateInit(strm) \\\n        inflateInit_((strm),                ZLIB_VERSION, sizeof(z_stream))\n#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \\\n        deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\\\n                      (strategy),           ZLIB_VERSION, sizeof(z_stream))\n#define inflateInit2(strm, windowBits) \\\n        inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))\n\n\n// static const char   * zError           OF((int err));\n// static int            inflateSyncPoint OF((z_streamp z));\n// static const uLong * get_crc_table    OF((void));\n\ntypedef unsigned char  uch;\ntypedef unsigned short ush;\ntypedef unsigned long  ulg;\n\n// static const char *z_errmsg[10]; /* indexed by 2-zlib_error */\n/* (size given to avoid silly warnings with Visual C++) */\n\n#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]\n\n#define ERR_RETURN(strm,err) \\\n  return (strm->msg = (char*)ERR_MSG(err), (err))\n/* To be used only when the state is known to be valid */\n\n        /* common constants */\n\n#ifndef DEF_WBITS\n#  define DEF_WBITS MAX_WBITS\n#endif\n/* default windowBits for decompression. MAX_WBITS is for compression only */\n\n#if MAX_MEM_LEVEL >= 8\n#  define DEF_MEM_LEVEL 8\n#else\n#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL\n#endif\n/* default memLevel */\n\n#define STORED_BLOCK 0\n#define STATIC_TREES 1\n#define DYN_TREES    2\n/* The three kinds of block type */\n\n#define MIN_MATCH  3\n#define MAX_MATCH  258\n/* The minimum and maximum match lengths */\n\n#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */\n\n        /* target dependencies */\n\n        /* Common defaults */\n\n#ifndef OS_CODE\n#  define OS_CODE  0x03  /* assume Unix */\n#endif\n\n#ifndef F_OPEN\n#  define F_OPEN(name, mode) fopen((name), (mode))\n#endif\n\n         /* functions */\n\n#ifdef HAVE_STRERROR\n   extern char *strerror OF((int));\n#  define zstrerror(errnum) strerror(errnum)\n#else\n#  define zstrerror(errnum) \"\"\n#endif\n\n#define zmemcpy Com_Memcpy\n#define zmemcmp memcmp\n#define zmemzero(dest, len) Com_Memset(dest, 0, len)\n\n/* Diagnostic functions */\n#ifdef _ZIP_DEBUG_\n   int z_verbose = 0;\n#  define Assert(cond,msg) assert(cond);\n   //{if(!(cond)) Sys_Error(msg);}\n#  define Trace(x) {if (z_verbose>=0) Sys_Error x ;}\n#  define Tracev(x) {if (z_verbose>0) Sys_Error x ;}\n#  define Tracevv(x) {if (z_verbose>1) Sys_Error x ;}\n#  define Tracec(c,x) {if (z_verbose>0 && (c)) Sys_Error x ;}\n#  define Tracecv(c,x) {if (z_verbose>1 && (c)) Sys_Error x ;}\n#else\n#  define Assert(cond,msg)\n#  define Trace(x)\n#  define Tracev(x)\n#  define Tracevv(x)\n#  define Tracec(c,x)\n#  define Tracecv(c,x)\n#endif\n\n\ntypedef uLong (*check_func) OF((uLong check, const Byte *buf, uInt len));\nstatic voidp zcalloc OF((voidp opaque, unsigned items, unsigned size));\nstatic void   zcfree  OF((voidp opaque, voidp ptr));\n\n#define ZALLOC(strm, items, size) \\\n           (*((strm)->zalloc))((strm)->opaque, (items), (size))\n#define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidp)(addr))\n#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}\n\n\n#if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \\\n                      !defined(CASESENSITIVITYDEFAULT_NO)\n#define CASESENSITIVITYDEFAULT_NO\n#endif\n\n\n#ifndef UNZ_BUFSIZE\n#define UNZ_BUFSIZE (65536)\n#endif\n\n#ifndef UNZ_MAXFILENAMEINZIP\n#define UNZ_MAXFILENAMEINZIP (256)\n#endif\n\n#ifndef ALLOC\n# define ALLOC(size) (Z_Malloc(size))\n#endif\n#ifndef TRYFREE\n# define TRYFREE(p) {if (p) Z_Free(p);}\n#endif\n\n#define SIZECENTRALDIRITEM (0x2e)\n#define SIZEZIPLOCALHEADER (0x1e)\n\n\n\n/* ===========================================================================\n     Read a byte from a gz_stream; update next_in and avail_in. Return EOF\n   for end of file.\n   IN assertion: the stream s has been sucessfully opened for reading.\n*/\n\n/*\nstatic int unzlocal_getByte(FILE *fin,int *pi)\n{\n    unsigned char c;\n\tint err = fread(&c, 1, 1, fin);\n    if (err==1)\n    {\n        *pi = (int)c;\n        return UNZ_OK;\n    }\n    else\n    {\n        if (ferror(fin)) \n            return UNZ_ERRNO;\n        else\n            return UNZ_EOF;\n    }\n}\n*/\n\n/* ===========================================================================\n   Reads a long in LSB order from the given gz_stream. Sets \n*/\nstatic int unzlocal_getShort (FILE* fin, uLong *pX)\n{\n\tshort\tv;\n\n\tfread( &v, sizeof(v), 1, fin );\n\n\t*pX = LittleShort( v);\n\treturn UNZ_OK;\n\n/*\n    uLong x ;\n    int i;\n    int err;\n\n    err = unzlocal_getByte(fin,&i);\n    x = (uLong)i;\n    \n    if (err==UNZ_OK)\n        err = unzlocal_getByte(fin,&i);\n    x += ((uLong)i)<<8;\n   \n    if (err==UNZ_OK)\n        *pX = x;\n    else\n        *pX = 0;\n    return err;\n*/\n}\n\nstatic int unzlocal_getLong (FILE *fin, uLong *pX)\n{\n\tint\t\tv;\n\n\tfread( &v, sizeof(v), 1, fin );\n\n\t*pX = LittleLong( v);\n\treturn UNZ_OK;\n\n/*\n    uLong x ;\n    int i;\n    int err;\n\n    err = unzlocal_getByte(fin,&i);\n    x = (uLong)i;\n    \n    if (err==UNZ_OK)\n        err = unzlocal_getByte(fin,&i);\n    x += ((uLong)i)<<8;\n\n    if (err==UNZ_OK)\n        err = unzlocal_getByte(fin,&i);\n    x += ((uLong)i)<<16;\n\n    if (err==UNZ_OK)\n        err = unzlocal_getByte(fin,&i);\n    x += ((uLong)i)<<24;\n   \n    if (err==UNZ_OK)\n        *pX = x;\n    else\n        *pX = 0;\n    return err;\n*/\n}\n\n\n/* My own strcmpi / strcasecmp */\nstatic int strcmpcasenosensitive_internal (const char* fileName1,const char* fileName2)\n{\n\tfor (;;)\n\t{\n\t\tchar c1=*(fileName1++);\n\t\tchar c2=*(fileName2++);\n\t\tif ((c1>='a') && (c1<='z'))\n\t\t\tc1 -= 0x20;\n\t\tif ((c2>='a') && (c2<='z'))\n\t\t\tc2 -= 0x20;\n\t\tif (c1=='\\0')\n\t\t\treturn ((c2=='\\0') ? 0 : -1);\n\t\tif (c2=='\\0')\n\t\t\treturn 1;\n\t\tif (c1<c2)\n\t\t\treturn -1;\n\t\tif (c1>c2)\n\t\t\treturn 1;\n\t}\n}\n\n\n#ifdef  CASESENSITIVITYDEFAULT_NO\n#define CASESENSITIVITYDEFAULTVALUE 2\n#else\n#define CASESENSITIVITYDEFAULTVALUE 1\n#endif\n\n#ifndef STRCMPCASENOSENTIVEFUNCTION\n#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal\n#endif\n\n/* \n   Compare two filename (fileName1,fileName2).\n   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)\n   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi\n                                                                or strcasecmp)\n   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system\n        (like 1 on Unix, 2 on Windows)\n\n*/\nextern  int unzStringFileNameCompare (const char* fileName1,const char* fileName2,int iCaseSensitivity)\n{\n\tif (iCaseSensitivity==0)\n\t\tiCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;\n\n\tif (iCaseSensitivity==1)\n\t\treturn strcmp(fileName1,fileName2);\n\n\treturn STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);\n} \n\n#define BUFREADCOMMENT (0x400)\n\n/*\n  Locate the Central directory of a zipfile (at the end, just before\n    the global comment)\n*/\nextern uLong unzlocal_SearchCentralDir(FILE *fin)\n{\n\tunsigned char* buf;\n\tuLong uSizeFile;\n\tuLong uBackRead;\n\tuLong uMaxBack=0xffff; /* maximum size of global comment */\n\tuLong uPosFound=0;\n\t\n\tif (fseek(fin,0,SEEK_END) != 0)\n\t\treturn 0;\n\n\n\tuSizeFile = ftell( fin );\n\t\n\tif (uMaxBack>uSizeFile)\n\t\tuMaxBack = uSizeFile;\n\n\tbuf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);\n\tif (buf==NULL)\n\t\treturn 0;\n\n\tuBackRead = 4;\n\twhile (uBackRead<uMaxBack)\n\t{\n\t\tuLong uReadSize,uReadPos ;\n\t\tint i;\n\t\tif (uBackRead+BUFREADCOMMENT>uMaxBack) \n\t\t\tuBackRead = uMaxBack;\n\t\telse\n\t\t\tuBackRead+=BUFREADCOMMENT;\n\t\tuReadPos = uSizeFile-uBackRead ;\n\t\t\n\t\tuReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? \n                     (BUFREADCOMMENT+4) : (uSizeFile-uReadPos);\n\t\tif (fseek(fin,uReadPos,SEEK_SET)!=0)\n\t\t\tbreak;\n\n\t\tif (fread(buf,(uInt)uReadSize,1,fin)!=1)\n\t\t\tbreak;\n\n                for (i=(int)uReadSize-3; (i--)>0;)\n\t\t\tif (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && \n\t\t\t\t((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))\n\t\t\t{\n\t\t\t\tuPosFound = uReadPos+i;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\tif (uPosFound!=0)\n\t\t\tbreak;\n\t}\n\tTRYFREE(buf);\n\treturn uPosFound;\n}\n\nextern unzFile unzReOpen (const char* path, unzFile file)\n{\n\tunz_s *s;\n\tFILE * fin;\n\n    fin=fopen(path,\"rb\");\n\tif (fin==NULL)\n\t\treturn NULL;\n\n\ts=(unz_s*)ALLOC(sizeof(unz_s));\n\tCom_Memcpy(s, (unz_s*)file, sizeof(unz_s));\n\n\ts->file = fin;\n\treturn (unzFile)s;\t\n}\n\n/*\n  Open a Zip file. path contain the full pathname (by example,\n     on a Windows NT computer \"c:\\\\test\\\\zlib109.zip\" or on an Unix computer\n\t \"zlib/zlib109.zip\".\n\t If the zipfile cannot be opened (file don't exist or in not valid), the\n\t   return value is NULL.\n     Else, the return value is a unzFile Handle, usable with other function\n\t   of this unzip package.\n*/\nextern unzFile unzOpen (const char* path)\n{\n\tunz_s us;\n\tunz_s *s;\n\tuLong central_pos,uL;\n\tFILE * fin ;\n\n\tuLong number_disk;          /* number of the current dist, used for \n\t\t\t\t\t\t\t\t   spaning ZIP, unsupported, always 0*/\n\tuLong number_disk_with_CD;  /* number the the disk with central dir, used\n\t\t\t\t\t\t\t\t   for spaning ZIP, unsupported, always 0*/\n\tuLong number_entry_CD;      /* total number of entries in\n\t                               the central dir \n\t                               (same than number_entry on nospan) */\n\n\tint err=UNZ_OK;\n\n    fin=fopen(path,\"rb\");\n\tif (fin==NULL)\n\t\treturn NULL;\n\n\tcentral_pos = unzlocal_SearchCentralDir(fin);\n\tif (central_pos==0)\n\t\terr=UNZ_ERRNO;\n\n\tif (fseek(fin,central_pos,SEEK_SET)!=0)\n\t\terr=UNZ_ERRNO;\n\n\t/* the signature, already checked */\n\tif (unzlocal_getLong(fin,&uL)!=UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\t/* number of this disk */\n\tif (unzlocal_getShort(fin,&number_disk)!=UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\t/* number of the disk with the start of the central directory */\n\tif (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\t/* total number of entries in the central dir on this disk */\n\tif (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\t/* total number of entries in the central dir */\n\tif (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif ((number_entry_CD!=us.gi.number_entry) ||\n\t\t(number_disk_with_CD!=0) ||\n\t\t(number_disk!=0))\n\t\terr=UNZ_BADZIPFILE;\n\n\t/* size of the central directory */\n\tif (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\t/* offset of start of central directory with respect to the \n\t      starting disk number */\n\tif (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\t/* zipfile comment length */\n\tif (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif ((central_pos<us.offset_central_dir+us.size_central_dir) && \n\t\t(err==UNZ_OK))\n\t\terr=UNZ_BADZIPFILE;\n\n\tif (err!=UNZ_OK)\n\t{\n\t\tfclose(fin);\n\t\treturn NULL;\n\t}\n\n\tus.file=fin;\n\tus.byte_before_the_zipfile = central_pos -\n\t\t                    (us.offset_central_dir+us.size_central_dir);\n\tus.central_pos = central_pos;\n    us.pfile_in_zip_read = NULL;\n\t\n\n\ts=(unz_s*)ALLOC(sizeof(unz_s));\n\t*s=us;\n//\tunzGoToFirstFile((unzFile)s);\t\n\treturn (unzFile)s;\t\n}\n\n\n/*\n  Close a ZipFile opened with unzipOpen.\n  If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),\n    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.\n  return UNZ_OK if there is no problem. */\nextern int unzClose (unzFile file)\n{\n\tunz_s* s;\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n\n    if (s->pfile_in_zip_read!=NULL)\n        unzCloseCurrentFile(file);\n\n\tfclose(s->file);\n\tTRYFREE(s);\n\treturn UNZ_OK;\n}\n\n\n/*\n  Write info about the ZipFile in the *pglobal_info structure.\n  No preparation of the structure is needed\n  return UNZ_OK if there is no problem. */\nextern int unzGetGlobalInfo (unzFile file,unz_global_info *pglobal_info)\n{\n\tunz_s* s;\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n\t*pglobal_info=s->gi;\n\treturn UNZ_OK;\n}\n\n\n/*\n   Translate date/time from Dos format to tm_unz (readable more easilty)\n*/\nstatic void unzlocal_DosDateToTmuDate (uLong ulDosDate, tm_unz* ptm)\n{\n    uLong uDate;\n    uDate = (uLong)(ulDosDate>>16);\n    ptm->tm_mday = (uInt)(uDate&0x1f) ;\n    ptm->tm_mon =  (uInt)((((uDate)&0x1E0)/0x20)-1) ;\n    ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;\n\n    ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);\n    ptm->tm_min =  (uInt) ((ulDosDate&0x7E0)/0x20) ;\n    ptm->tm_sec =  (uInt) (2*(ulDosDate&0x1f)) ;\n}\n\n/*\n  Get Info about the current file in the zipfile, with internal only info\n*/\nstatic int unzlocal_GetCurrentFileInfoInternal (unzFile file,\n                                                  unz_file_info *pfile_info,\n                                                  unz_file_info_internal \n                                                  *pfile_info_internal,\n                                                  char *szFileName,\n\t\t\t\t\t\t\t\t\t\t\t\t  uLong fileNameBufferSize,\n                                                  void *extraField,\n\t\t\t\t\t\t\t\t\t\t\t\t  uLong extraFieldBufferSize,\n                                                  char *szComment,\n\t\t\t\t\t\t\t\t\t\t\t\t  uLong commentBufferSize)\n{\n\tunz_s* s;\n\tunz_file_info file_info;\n\tunz_file_info_internal file_info_internal;\n\tint err=UNZ_OK;\n\tuLong uMagic;\n\tlong lSeek=0;\n\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n\tif (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0)\n\t\terr=UNZ_ERRNO;\n\n\n\t/* we check the magic */\n\tif (err==UNZ_OK) {\n\t\tif (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)\n\t\t\terr=UNZ_ERRNO;\n\t\telse if (uMagic!=0x02014b50)\n\t\t\terr=UNZ_BADZIPFILE;\n\t}\n\tif (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n    unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);\n\n\tif (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tlSeek+=file_info.size_filename;\n\tif ((err==UNZ_OK) && (szFileName!=NULL))\n\t{\n\t\tuLong uSizeRead ;\n\t\tif (file_info.size_filename<fileNameBufferSize)\n\t\t{\n\t\t\t*(szFileName+file_info.size_filename)='\\0';\n\t\t\tuSizeRead = file_info.size_filename;\n\t\t}\n\t\telse\n\t\t\tuSizeRead = fileNameBufferSize;\n\n\t\tif ((file_info.size_filename>0) && (fileNameBufferSize>0))\n\t\t\tif (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1)\n\t\t\t\terr=UNZ_ERRNO;\n\t\tlSeek -= uSizeRead;\n\t}\n\n\t\n\tif ((err==UNZ_OK) && (extraField!=NULL))\n\t{\n\t\tuLong uSizeRead ;\n\t\tif (file_info.size_file_extra<extraFieldBufferSize)\n\t\t\tuSizeRead = file_info.size_file_extra;\n\t\telse\n\t\t\tuSizeRead = extraFieldBufferSize;\n\n\t\tif (lSeek!=0) {\n\t\t\tif (fseek(s->file,lSeek,SEEK_CUR)==0)\n\t\t\t\tlSeek=0;\n\t\t\telse\n\t\t\t\terr=UNZ_ERRNO;\n\t\t}\n\t\tif ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) {\n\t\t\tif (fread(extraField,(uInt)uSizeRead,1,s->file)!=1)\n\t\t\t\terr=UNZ_ERRNO;\n\t\t}\n\t\tlSeek += file_info.size_file_extra - uSizeRead;\n\t}\n\telse\n\t\tlSeek+=file_info.size_file_extra; \n\n\t\n\tif ((err==UNZ_OK) && (szComment!=NULL))\n\t{\n\t\tuLong uSizeRead ;\n\t\tif (file_info.size_file_comment<commentBufferSize)\n\t\t{\n\t\t\t*(szComment+file_info.size_file_comment)='\\0';\n\t\t\tuSizeRead = file_info.size_file_comment;\n\t\t}\n\t\telse\n\t\t\tuSizeRead = commentBufferSize;\n\n\t\tif (lSeek!=0) {\n\t\t\tif (fseek(s->file,lSeek,SEEK_CUR)==0)\n\t\t\t\tlSeek=0;\n\t\t\telse\n\t\t\t\terr=UNZ_ERRNO;\n\t\t}\n\t\tif ((file_info.size_file_comment>0) && (commentBufferSize>0)) {\n\t\t\tif (fread(szComment,(uInt)uSizeRead,1,s->file)!=1)\n\t\t\t\terr=UNZ_ERRNO;\n\t\t}\n\t\tlSeek+=file_info.size_file_comment - uSizeRead;\n\t}\n\telse\n\t\tlSeek+=file_info.size_file_comment;\n\n\tif ((err==UNZ_OK) && (pfile_info!=NULL))\n\t\t*pfile_info=file_info;\n\n\tif ((err==UNZ_OK) && (pfile_info_internal!=NULL))\n\t\t*pfile_info_internal=file_info_internal;\n\n\treturn err;\n}\n\n\n\n/*\n  Write info about the ZipFile in the *pglobal_info structure.\n  No preparation of the structure is needed\n  return UNZ_OK if there is no problem.\n*/\nextern int unzGetCurrentFileInfo (\tunzFile file, unz_file_info *pfile_info,\n\t\t\t\t\t\t\t\t\tchar *szFileName, uLong fileNameBufferSize,\n\t\t\t\t\t\t\t\t\tvoid *extraField, uLong extraFieldBufferSize,\n\t\t\t\t\t\t\t\t\tchar *szComment, uLong commentBufferSize)\n{\n\treturn unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,\n\t\t\t\t\t\t\t\t\t\t\t\tszFileName,fileNameBufferSize,\n\t\t\t\t\t\t\t\t\t\t\t\textraField,extraFieldBufferSize,\n\t\t\t\t\t\t\t\t\t\t\t\tszComment,commentBufferSize);\n}\n\n/*\n  Set the current file of the zipfile to the first file.\n  return UNZ_OK if there is no problem\n*/\nextern int unzGoToFirstFile (unzFile file)\n{\n\tint err=UNZ_OK;\n\tunz_s* s;\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n\ts->pos_in_central_dir=s->offset_central_dir;\n\ts->num_file=0;\n\terr=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,\n\t\t\t\t\t\t\t\t\t\t\t &s->cur_file_info_internal,\n\t\t\t\t\t\t\t\t\t\t\t NULL,0,NULL,0,NULL,0);\n\ts->current_file_ok = (err == UNZ_OK);\n\treturn err;\n}\n\n\n/*\n  Set the current file of the zipfile to the next file.\n  return UNZ_OK if there is no problem\n  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.\n*/\nextern int unzGoToNextFile (unzFile file)\n{\n\tunz_s* s;\t\n\tint err;\n\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n\tif (!s->current_file_ok)\n\t\treturn UNZ_END_OF_LIST_OF_FILE;\n\tif (s->num_file+1==s->gi.number_entry)\n\t\treturn UNZ_END_OF_LIST_OF_FILE;\n\n\ts->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +\n\t\t\ts->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;\n\ts->num_file++;\n\terr = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,\n\t\t\t\t\t\t\t\t\t\t\t   &s->cur_file_info_internal,\n\t\t\t\t\t\t\t\t\t\t\t   NULL,0,NULL,0,NULL,0);\n\ts->current_file_ok = (err == UNZ_OK);\n\treturn err;\n}\n\n/*\n  Get the position of the info of the current file in the zip.\n  return UNZ_OK if there is no problem\n*/\nextern int unzGetCurrentFileInfoPosition (unzFile file, unsigned long *pos )\n{\n\tunz_s* s;\t\n\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n\n\t*pos = s->pos_in_central_dir;\n\treturn UNZ_OK;\n}\n\n/*\n  Set the position of the info of the current file in the zip.\n  return UNZ_OK if there is no problem\n*/\nextern int unzSetCurrentFileInfoPosition (unzFile file, unsigned long pos )\n{\n\tunz_s* s;\t\n\tint err;\n\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n\n\ts->pos_in_central_dir = pos;\n\terr = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,\n\t\t\t\t\t\t\t\t\t\t\t   &s->cur_file_info_internal,\n\t\t\t\t\t\t\t\t\t\t\t   NULL,0,NULL,0,NULL,0);\n\ts->current_file_ok = (err == UNZ_OK);\n\treturn UNZ_OK;\n}\n\n/*\n  Try locate the file szFileName in the zipfile.\n  For the iCaseSensitivity signification, see unzipStringFileNameCompare\n\n  return value :\n  UNZ_OK if the file is found. It becomes the current file.\n  UNZ_END_OF_LIST_OF_FILE if the file is not found\n*/\nextern int unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity)\n{\n\tunz_s* s;\t\n\tint err;\n\n\t\n\tuLong num_fileSaved;\n\tuLong pos_in_central_dirSaved;\n\n\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\n    if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)\n        return UNZ_PARAMERROR;\n\n\ts=(unz_s*)file;\n\tif (!s->current_file_ok)\n\t\treturn UNZ_END_OF_LIST_OF_FILE;\n\n\tnum_fileSaved = s->num_file;\n\tpos_in_central_dirSaved = s->pos_in_central_dir;\n\n\terr = unzGoToFirstFile(file);\n\n\twhile (err == UNZ_OK)\n\t{\n\t\tchar szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];\n\t\tunzGetCurrentFileInfo(file,NULL,\n\t\t\t\t\t\t\t\tszCurrentFileName,sizeof(szCurrentFileName)-1,\n\t\t\t\t\t\t\t\tNULL,0,NULL,0);\n\t\tif (unzStringFileNameCompare(szCurrentFileName,\n\t\t\t\t\t\t\t\t\t\tszFileName,iCaseSensitivity)==0)\n\t\t\treturn UNZ_OK;\n\t\terr = unzGoToNextFile(file);\n\t}\n\n\ts->num_file = num_fileSaved ;\n\ts->pos_in_central_dir = pos_in_central_dirSaved ;\n\treturn err;\n}\n\n\n/*\n  Read the static header of the current zipfile\n  Check the coherency of the static header and info in the end of central\n        directory about this file\n  store in *piSizeVar the size of extra info in static header\n        (filename and size of extra field data)\n*/\nstatic int unzlocal_CheckCurrentFileCoherencyHeader (unz_s* s, uInt* piSizeVar,\n\t\t\t\t\t\t\t\t\t\t\t\t\tuLong *poffset_local_extrafield,\n\t\t\t\t\t\t\t\t\t\t\t\t\tuInt *psize_local_extrafield)\n{\n\tuLong uMagic,uData,uFlags;\n\tuLong size_filename;\n\tuLong size_extra_field;\n\tint err=UNZ_OK;\n\n\t*piSizeVar = 0;\n\t*poffset_local_extrafield = 0;\n\t*psize_local_extrafield = 0;\n\n\tif (fseek(s->file,s->cur_file_info_internal.offset_curfile +\n\t\t\t\t\t\t\t\ts->byte_before_the_zipfile,SEEK_SET)!=0)\n\t\treturn UNZ_ERRNO;\n\n\n\tif (err==UNZ_OK) {\n\t\tif (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)\n\t\t\terr=UNZ_ERRNO;\n\t\telse if (uMagic!=0x04034b50)\n\t\t\terr=UNZ_BADZIPFILE;\n\t}\n\tif (unzlocal_getShort(s->file,&uData) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n/*\n\telse if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))\n\t\terr=UNZ_BADZIPFILE;\n*/\n\tif (unzlocal_getShort(s->file,&uFlags) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getShort(s->file,&uData) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\telse if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))\n\t\terr=UNZ_BADZIPFILE;\n\n    if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&\n                         (s->cur_file_info.compression_method!=Z_DEFLATED))\n        err=UNZ_BADZIPFILE;\n\n\tif (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */\n\t\terr=UNZ_ERRNO;\n\telse if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) &&\n\t\t                      ((uFlags & 8)==0))\n\t\terr=UNZ_BADZIPFILE;\n\n\tif (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */\n\t\terr=UNZ_ERRNO;\n\telse if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) &&\n\t\t\t\t\t\t\t  ((uFlags & 8)==0))\n\t\terr=UNZ_BADZIPFILE;\n\n\tif (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */\n\t\terr=UNZ_ERRNO;\n\telse if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && \n\t\t\t\t\t\t\t  ((uFlags & 8)==0))\n\t\terr=UNZ_BADZIPFILE;\n\n\n\tif (unzlocal_getShort(s->file,&size_filename) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\telse if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))\n\t\terr=UNZ_BADZIPFILE;\n\n\t*piSizeVar += (uInt)size_filename;\n\n\tif (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\t*poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +\n\t\t\t\t\t\t\t\t\tSIZEZIPLOCALHEADER + size_filename;\n\t*psize_local_extrafield = (uInt)size_extra_field;\n\n\t*piSizeVar += (uInt)size_extra_field;\n\n\treturn err;\n}\n\t\t\t\t\t\t\t\t\t\t\t\t\n/*\n  Open for reading data the current file in the zipfile.\n  If there is no error and the file is opened, the return value is UNZ_OK.\n*/\nextern int unzOpenCurrentFile (unzFile file)\n{\n\tint err=UNZ_OK;\n\tint Store;\n\tuInt iSizeVar;\n\tunz_s* s;\n\tfile_in_zip_read_info_s* pfile_in_zip_read_info;\n\tuLong offset_local_extrafield;  /* offset of the static extra field */\n\tuInt  size_local_extrafield;    /* size of the static extra field */\n\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n\tif (!s->current_file_ok)\n\t\treturn UNZ_PARAMERROR;\n\n    if (s->pfile_in_zip_read != NULL)\n        unzCloseCurrentFile(file);\n\n\tif (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar,\n\t\t\t\t&offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)\n\t\treturn UNZ_BADZIPFILE;\n\n\tpfile_in_zip_read_info = (file_in_zip_read_info_s*)\n\t\t\t\t\t\t\t\t\t    ALLOC(sizeof(file_in_zip_read_info_s));\n\tif (pfile_in_zip_read_info==NULL)\n\t\treturn UNZ_INTERNALERROR;\n\n\tpfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);\n\tpfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;\n\tpfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;\n\tpfile_in_zip_read_info->pos_local_extrafield=0;\n\n\tif (pfile_in_zip_read_info->read_buffer==NULL)\n\t{\n\t\tTRYFREE(pfile_in_zip_read_info);\n\t\treturn UNZ_INTERNALERROR;\n\t}\n\n\tpfile_in_zip_read_info->stream_initialised=0;\n\t\n\tif ((s->cur_file_info.compression_method!=0) &&\n        (s->cur_file_info.compression_method!=Z_DEFLATED))\n\t\terr=UNZ_BADZIPFILE;\n\tStore = s->cur_file_info.compression_method==0;\n\n\tpfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;\n\tpfile_in_zip_read_info->crc32=0;\n\tpfile_in_zip_read_info->compression_method =\n            s->cur_file_info.compression_method;\n\tpfile_in_zip_read_info->file=s->file;\n\tpfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;\n\n    pfile_in_zip_read_info->stream.total_out = 0;\n\n\tif (!Store)\n\t{\n\t  pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;\n\t  pfile_in_zip_read_info->stream.zfree = (free_func)0;\n\t  pfile_in_zip_read_info->stream.opaque = (voidp)0; \n      \n\t  err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);\n\t  if (err == Z_OK)\n\t    pfile_in_zip_read_info->stream_initialised=1;\n        /* windowBits is passed < 0 to tell that there is no zlib header.\n         * Note that in this case inflate *requires* an extra \"dummy\" byte\n         * after the compressed stream in order to complete decompression and\n         * return Z_STREAM_END. \n         * In unzip, i don't wait absolutely Z_STREAM_END because I known the \n         * size of both compressed and uncompressed data\n         */\n\t}\n\tpfile_in_zip_read_info->rest_read_compressed = \n            s->cur_file_info.compressed_size ;\n\tpfile_in_zip_read_info->rest_read_uncompressed = \n            s->cur_file_info.uncompressed_size ;\n\n\t\n\tpfile_in_zip_read_info->pos_in_zipfile = \n            s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + \n\t\t\t  iSizeVar;\n\t\n\tpfile_in_zip_read_info->stream.avail_in = (uInt)0;\n\n\n\ts->pfile_in_zip_read = pfile_in_zip_read_info;\n    return UNZ_OK;\n}\n\n\n/*\n  Read bytes from the current file.\n  buf contain buffer where data must be copied\n  len the size of buf.\n\n  return the number of byte copied if somes bytes are copied\n  return 0 if the end of file was reached\n  return <0 with error code if there is an error\n    (UNZ_ERRNO for IO error, or zLib error for uncompress error)\n*/\nextern int unzReadCurrentFile  (unzFile file, void *buf, unsigned len)\n{\n\tint err=UNZ_OK;\n\tuInt iRead = 0;\n\tunz_s* s;\n\tfile_in_zip_read_info_s* pfile_in_zip_read_info;\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n    pfile_in_zip_read_info=s->pfile_in_zip_read;\n\n\tif (pfile_in_zip_read_info==NULL)\n\t\treturn UNZ_PARAMERROR;\n\n\n\tif ((pfile_in_zip_read_info->read_buffer == NULL))\n\t\treturn UNZ_END_OF_LIST_OF_FILE;\n\tif (len==0)\n\t\treturn 0;\n\n\tpfile_in_zip_read_info->stream.next_out = (Byte*)buf;\n\n\tpfile_in_zip_read_info->stream.avail_out = (uInt)len;\n\t\n\tif (len>pfile_in_zip_read_info->rest_read_uncompressed)\n\t\tpfile_in_zip_read_info->stream.avail_out = \n\t\t  (uInt)pfile_in_zip_read_info->rest_read_uncompressed;\n\n\twhile (pfile_in_zip_read_info->stream.avail_out>0)\n\t{\n\t\tif ((pfile_in_zip_read_info->stream.avail_in==0) &&\n            (pfile_in_zip_read_info->rest_read_compressed>0))\n\t\t{\n\t\t\tuInt uReadThis = UNZ_BUFSIZE;\n\t\t\tif (pfile_in_zip_read_info->rest_read_compressed<uReadThis)\n\t\t\t\tuReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;\n\t\t\tif (uReadThis == 0)\n\t\t\t\treturn UNZ_EOF;\n\t\t\tif (s->cur_file_info.compressed_size == pfile_in_zip_read_info->rest_read_compressed)\n\t\t\t\tif (fseek(pfile_in_zip_read_info->file,\n\t\t\t\t\t\t  pfile_in_zip_read_info->pos_in_zipfile + \n\t\t\t\t\t\t\t pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0)\n\t\t\t\t\treturn UNZ_ERRNO;\n\t\t\tif (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1,\n                         pfile_in_zip_read_info->file)!=1)\n\t\t\t\treturn UNZ_ERRNO;\n\t\t\tpfile_in_zip_read_info->pos_in_zipfile += uReadThis;\n\n\t\t\tpfile_in_zip_read_info->rest_read_compressed-=uReadThis;\n\t\t\t\n\t\t\tpfile_in_zip_read_info->stream.next_in = \n                (Byte*)pfile_in_zip_read_info->read_buffer;\n\t\t\tpfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;\n\t\t}\n\n\t\tif (pfile_in_zip_read_info->compression_method==0)\n\t\t{\n\t\t\tuInt uDoCopy,i ;\n\t\t\tif (pfile_in_zip_read_info->stream.avail_out < \n                            pfile_in_zip_read_info->stream.avail_in)\n\t\t\t\tuDoCopy = pfile_in_zip_read_info->stream.avail_out ;\n\t\t\telse\n\t\t\t\tuDoCopy = pfile_in_zip_read_info->stream.avail_in ;\n\t\t\t\t\n\t\t\tfor (i=0;i<uDoCopy;i++)\n\t\t\t\t*(pfile_in_zip_read_info->stream.next_out+i) =\n                        *(pfile_in_zip_read_info->stream.next_in+i);\n\t\t\t\t\t\n//\t\t\tpfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,\n//\t\t\t\t\t\t\t\tpfile_in_zip_read_info->stream.next_out,\n//\t\t\t\t\t\t\t\tuDoCopy);\n\t\t\tpfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;\n\t\t\tpfile_in_zip_read_info->stream.avail_in -= uDoCopy;\n\t\t\tpfile_in_zip_read_info->stream.avail_out -= uDoCopy;\n\t\t\tpfile_in_zip_read_info->stream.next_out += uDoCopy;\n\t\t\tpfile_in_zip_read_info->stream.next_in += uDoCopy;\n            pfile_in_zip_read_info->stream.total_out += uDoCopy;\n\t\t\tiRead += uDoCopy;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tuLong uTotalOutBefore,uTotalOutAfter;\n\t\t\tconst Byte *bufBefore;\n\t\t\tuLong uOutThis;\n\t\t\tint flush=Z_SYNC_FLUSH;\n\n\t\t\tuTotalOutBefore = pfile_in_zip_read_info->stream.total_out;\n\t\t\tbufBefore = pfile_in_zip_read_info->stream.next_out;\n\n\t\t\t/*\n\t\t\tif ((pfile_in_zip_read_info->rest_read_uncompressed ==\n\t\t\t         pfile_in_zip_read_info->stream.avail_out) &&\n\t\t\t\t(pfile_in_zip_read_info->rest_read_compressed == 0))\n\t\t\t\tflush = Z_FINISH;\n\t\t\t*/\n\t\t\terr=inflate(&pfile_in_zip_read_info->stream,flush);\n\n\t\t\tuTotalOutAfter = pfile_in_zip_read_info->stream.total_out;\n\t\t\tuOutThis = uTotalOutAfter-uTotalOutBefore;\n\t\t\t\n//\t\t\tpfile_in_zip_read_info->crc32 = \n//                crc32(pfile_in_zip_read_info->crc32,bufBefore,\n//                        (uInt)(uOutThis));\n\n\t\t\tpfile_in_zip_read_info->rest_read_uncompressed -=\n                uOutThis;\n\n\t\t\tiRead += (uInt)(uTotalOutAfter - uTotalOutBefore);\n            \n\t\t\tif (err==Z_STREAM_END)\n\t\t\t\treturn (iRead==0) ? UNZ_EOF : iRead;\n\t\t\tif (err!=Z_OK) \n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (err==Z_OK)\n\t\treturn iRead;\n\treturn err;\n}\n\n\n/*\n  Give the current position in uncompressed data\n*/\nextern long unztell (unzFile file)\n{\n\tunz_s* s;\n\tfile_in_zip_read_info_s* pfile_in_zip_read_info;\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n    pfile_in_zip_read_info=s->pfile_in_zip_read;\n\n\tif (pfile_in_zip_read_info==NULL)\n\t\treturn UNZ_PARAMERROR;\n\n\treturn (long)pfile_in_zip_read_info->stream.total_out;\n}\n\n\n/*\n  return 1 if the end of file was reached, 0 elsewhere \n*/\nextern int unzeof (unzFile file)\n{\n\tunz_s* s;\n\tfile_in_zip_read_info_s* pfile_in_zip_read_info;\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n    pfile_in_zip_read_info=s->pfile_in_zip_read;\n\n\tif (pfile_in_zip_read_info==NULL)\n\t\treturn UNZ_PARAMERROR;\n\t\n\tif (pfile_in_zip_read_info->rest_read_uncompressed == 0)\n\t\treturn 1;\n\telse\n\t\treturn 0;\n}\n\n\n\n/*\n  Read extra field from the current file (opened by unzOpenCurrentFile)\n  This is the static-header version of the extra field (sometimes, there is\n    more info in the static-header version than in the central-header)\n\n  if buf==NULL, it return the size of the static extra field that can be read\n\n  if buf!=NULL, len is the size of the buffer, the extra header is copied in\n\tbuf.\n  the return value is the number of bytes copied in buf, or (if <0) \n\tthe error code\n*/\nextern int unzGetLocalExtrafield (unzFile file,void *buf,unsigned len)\n{\n\tunz_s* s;\n\tfile_in_zip_read_info_s* pfile_in_zip_read_info;\n\tuInt read_now;\n\tuLong size_to_read;\n\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n    pfile_in_zip_read_info=s->pfile_in_zip_read;\n\n\tif (pfile_in_zip_read_info==NULL)\n\t\treturn UNZ_PARAMERROR;\n\n\tsize_to_read = (pfile_in_zip_read_info->size_local_extrafield - \n\t\t\t\tpfile_in_zip_read_info->pos_local_extrafield);\n\n\tif (buf==NULL)\n\t\treturn (int)size_to_read;\n\t\n\tif (len>size_to_read)\n\t\tread_now = (uInt)size_to_read;\n\telse\n\t\tread_now = (uInt)len ;\n\n\tif (read_now==0)\n\t\treturn 0;\n\t\n\tif (fseek(pfile_in_zip_read_info->file,\n              pfile_in_zip_read_info->offset_local_extrafield + \n\t\t\t  pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0)\n\t\treturn UNZ_ERRNO;\n\n\tif (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1)\n\t\treturn UNZ_ERRNO;\n\n\treturn (int)read_now;\n}\n\n/*\n  Close the file in zip opened with unzipOpenCurrentFile\n  Return UNZ_CRCERROR if all the file was read but the CRC is not good\n*/\nextern int unzCloseCurrentFile (unzFile file)\n{\n\tint err=UNZ_OK;\n\n\tunz_s* s;\n\tfile_in_zip_read_info_s* pfile_in_zip_read_info;\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n    pfile_in_zip_read_info=s->pfile_in_zip_read;\n\n\tif (pfile_in_zip_read_info==NULL)\n\t\treturn UNZ_PARAMERROR;\n\n/*\n\tif (pfile_in_zip_read_info->rest_read_uncompressed == 0)\n\t{\n\t\tif (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)\n\t\t\terr=UNZ_CRCERROR;\n\t}\n*/\n\n\tTRYFREE(pfile_in_zip_read_info->read_buffer);\n\tpfile_in_zip_read_info->read_buffer = NULL;\n\tif (pfile_in_zip_read_info->stream_initialised)\n\t\tinflateEnd(&pfile_in_zip_read_info->stream);\n\n\tpfile_in_zip_read_info->stream_initialised = 0;\n\tTRYFREE(pfile_in_zip_read_info);\n\n    s->pfile_in_zip_read=NULL;\n\n\treturn err;\n}\n\n\n/*\n  Get the global comment string of the ZipFile, in the szComment buffer.\n  uSizeBuf is the size of the szComment buffer.\n  return the number of byte copied or an error code <0\n*/\nextern int unzGetGlobalComment (unzFile file, char *szComment, uLong uSizeBuf)\n{\n\tunz_s* s;\n\tuLong uReadThis ;\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n\n\tuReadThis = uSizeBuf;\n\tif (uReadThis>s->gi.size_comment)\n\t\tuReadThis = s->gi.size_comment;\n\n\tif (fseek(s->file,s->central_pos+22,SEEK_SET)!=0)\n\t\treturn UNZ_ERRNO;\n\n\tif (uReadThis>0)\n    {\n      *szComment='\\0';\n\t  if (fread(szComment,(uInt)uReadThis,1,s->file)!=1)\n\t\treturn UNZ_ERRNO;\n    }\n\n\tif ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))\n\t\t*(szComment+s->gi.size_comment)='\\0';\n\treturn (int)uReadThis;\n}\n\n/* infblock.h -- header to use infblock.c\n * Copyright (C) 1995-1998 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h \n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\nstruct inflate_blocks_state;\ntypedef struct inflate_blocks_state inflate_blocks_statef;\n\nstatic inflate_blocks_statef * inflate_blocks_new OF((\n    z_streamp z,\n    check_func c,               /* check function */\n    uInt w));                   /* window size */\n\nstatic int inflate_blocks OF((\n    inflate_blocks_statef *,\n    z_streamp ,\n    int));                      /* initial return code */\n\nstatic void inflate_blocks_reset OF((\n    inflate_blocks_statef *,\n    z_streamp ,\n    uLong *));                  /* check value on output */\n\nstatic int inflate_blocks_free OF((\n    inflate_blocks_statef *,\n    z_streamp));\n\n#if 0\nstatic void inflate_set_dictionary OF((\n    inflate_blocks_statef *s,\n    const Byte *d,  /* dictionary */\n    uInt  n));       /* dictionary length */\n\nstatic int inflate_blocks_sync_point OF((\n    inflate_blocks_statef *s));\n#endif\n\n/* simplify the use of the inflate_huft type with some defines */\n#define exop word.what.Exop\n#define bits word.what.Bits\n\n/* Table for deflate from PKZIP's appnote.txt. */\nstatic const uInt border[] = { /* Order of the bit length code lengths */\n        16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};\n\n/* inftrees.h -- header to use inftrees.c\n * Copyright (C) 1995-1998 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h \n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\n/* Huffman code lookup table entry--this entry is four bytes for machines\n   that have 16-bit pointers (e.g. PC's in the small or medium model). */\n\ntypedef struct inflate_huft_s inflate_huft;\n\nstruct inflate_huft_s {\n  union {\n    struct {\n      Byte Exop;        /* number of extra bits or operation */\n      Byte Bits;        /* number of bits in this code or subcode */\n    } what;\n    uInt pad;           /* pad structure to a power of 2 (4 bytes for */\n  } word;               /*  16-bit, 8 bytes for 32-bit int's) */\n  uInt base;            /* literal, length base, distance base,\n                           or table offset */\n};\n\n/* Maximum size of dynamic tree.  The maximum found in a long but non-\n   exhaustive search was 1004 huft structures (850 for length/literals\n   and 154 for distances, the latter actually the result of an\n   exhaustive search).  The actual maximum is not known, but the\n   value below is more than safe. */\n#define MANY 1440\n\nstatic  int inflate_trees_bits OF((\n    uInt *,                    /* 19 code lengths */\n    uInt *,                    /* bits tree desired/actual depth */\n    inflate_huft * *,       /* bits tree result */\n    inflate_huft *,             /* space for trees */\n    z_streamp));                /* for messages */\n\nstatic  int inflate_trees_dynamic OF((\n    uInt,                       /* number of literal/length codes */\n    uInt,                       /* number of distance codes */\n    uInt *,                    /* that many (total) code lengths */\n    uInt *,                    /* literal desired/actual bit depth */\n    uInt *,                    /* distance desired/actual bit depth */\n    inflate_huft * *,       /* literal/length tree result */\n    inflate_huft * *,       /* distance tree result */\n    inflate_huft *,             /* space for trees */\n    z_streamp));                /* for messages */\n\nstatic  int inflate_trees_fixed OF((\n    uInt *,                    /* literal desired/actual bit depth */\n    uInt *,                    /* distance desired/actual bit depth */\n    inflate_huft * *,       /* literal/length tree result */\n    inflate_huft * *,       /* distance tree result */\n    z_streamp));                /* for memory allocation */\n\n\n/* infcodes.h -- header to use infcodes.c\n * Copyright (C) 1995-1998 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h \n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\nstruct inflate_codes_state;\ntypedef struct inflate_codes_state inflate_codes_statef;\n\nstatic inflate_codes_statef *inflate_codes_new OF((\n    uInt, uInt,\n    inflate_huft *, inflate_huft *,\n    z_streamp ));\n\nstatic  int inflate_codes OF((\n    inflate_blocks_statef *,\n    z_streamp ,\n    int));\n\nstatic  void inflate_codes_free OF((\n    inflate_codes_statef *,\n    z_streamp ));\n\n/* infutil.h -- types and macros common to blocks and codes\n * Copyright (C) 1995-1998 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h \n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\n#ifndef _INFUTIL_H\n#define _INFUTIL_H\n\ntypedef enum {\n      TYPE,     /* get type bits (3, including end bit) */\n      LENS,     /* get lengths for stored */\n      STORED,   /* processing stored block */\n      TABLE,    /* get table lengths */\n      BTREE,    /* get bit lengths tree for a dynamic block */\n      DTREE,    /* get length, distance trees for a dynamic block */\n      CODES,    /* processing fixed or dynamic block */\n      DRY,      /* output remaining window bytes */\n      DONE,     /* finished last block, done */\n      BAD}      /* got a data error--stuck here */\ninflate_block_mode;\n\n/* inflate blocks semi-private state */\nstruct inflate_blocks_state {\n\n  /* mode */\n  inflate_block_mode  mode;     /* current inflate_block mode */\n\n  /* mode dependent information */\n  union {\n    uInt left;          /* if STORED, bytes left to copy */\n    struct {\n      uInt table;               /* table lengths (14 bits) */\n      uInt index;               /* index into blens (or border) */\n      uInt *blens;             /* bit lengths of codes */\n      uInt bb;                  /* bit length tree depth */\n      inflate_huft *tb;         /* bit length decoding tree */\n    } trees;            /* if DTREE, decoding info for trees */\n    struct {\n      inflate_codes_statef \n         *codes;\n    } decode;           /* if CODES, current state */\n  } sub;                /* submode */\n  uInt last;            /* true if this block is the last block */\n\n  /* mode independent information */\n  uInt bitk;            /* bits in bit buffer */\n  uLong bitb;           /* bit buffer */\n  inflate_huft *hufts;  /* single malloc for tree space */\n  Byte *window;        /* sliding window */\n  Byte *end;           /* one byte after sliding window */\n  Byte *read;          /* window read pointer */\n  Byte *write;         /* window write pointer */\n  check_func checkfn;   /* check function */\n  uLong check;          /* check on output */\n\n};\n\n\n/* defines for inflate input/output */\n/*   update pointers and return */\n#define UPDBITS {s->bitb=b;s->bitk=k;}\n#define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;}\n#define UPDOUT {s->write=q;}\n#define UPDATE {UPDBITS UPDIN UPDOUT}\n#define LEAVE {UPDATE return inflate_flush(s,z,r);}\n/*   get bytes and bits */\n#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}\n#define NEEDBYTE {if(n)r=Z_OK;else LEAVE}\n#define NEXTBYTE (n--,*p++)\n#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}}\n#define DUMPBITS(j) {b>>=(j);k-=(j);}\n/*   output bytes */\n#define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q)\n#define LOADOUT {q=s->write;m=(uInt)WAVAIL;}\n#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}}\n#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT}\n#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;}\n#define OUTBYTE(a) {*q++=(Byte)(a);m--;}\n/*   load static pointers */\n#define LOAD {LOADIN LOADOUT}\n\n/* masks for lower bits (size given to avoid silly warnings with Visual C++) */\nstatic  uInt inflate_mask[17];\n\n/* copy as much as possible from the sliding window to the output area */\nstatic  int inflate_flush OF((\n    inflate_blocks_statef *,\n    z_streamp ,\n    int));\n\n#endif\n\n\t\t\t\t\t\t\t\t\n/*\n   Notes beyond the 1.93a appnote.txt:\n\n   1. Distance pointers never point before the beginning of the output\n      stream.\n   2. Distance pointers can point back across blocks, up to 32k away.\n   3. There is an implied maximum of 7 bits for the bit length table and\n      15 bits for the actual data.\n   4. If only one code exists, then it is encoded using one bit.  (Zero\n      would be more efficient, but perhaps a little confusing.)  If two\n      codes exist, they are coded using one bit each (0 and 1).\n   5. There is no way of sending zero distance codes--a dummy must be\n      sent if there are none.  (History: a pre 2.0 version of PKZIP would\n      store blocks with no distance codes, but this was discovered to be\n      too harsh a criterion.)  Valid only for 1.93a.  2.04c does allow\n      zero distance codes, which is sent as one code of zero bits in\n      length.\n   6. There are up to 286 literal/length codes.  Code 256 represents the\n      end-of-block.  Note however that the static length tree defines\n      288 codes just to fill out the Huffman codes.  Codes 286 and 287\n      cannot be used though, since there is no length base or extra bits\n      defined for them.  Similarily, there are up to 30 distance codes.\n      However, static trees define 32 codes (all 5 bits) to fill out the\n      Huffman codes, but the last two had better not show up in the data.\n   7. Unzip can check dynamic Huffman blocks for complete code sets.\n      The exception is that a single code would not be complete (see #4).\n   8. The five bits following the block type is really the number of\n      literal codes sent minus 257.\n   9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits\n      (1+6+6).  Therefore, to output three times the length, you output\n      three codes (1+1+1), whereas to output four times the same length,\n      you only need two codes (1+3).  Hmm.\n  10. In the tree reconstruction algorithm, Code = Code + Increment\n      only if BitLength(i) is not zero.  (Pretty obvious.)\n  11. Correction: 4 Bits: # of Bit Length codes - 4     (4 - 19)\n  12. Note: length code 284 can represent 227-258, but length code 285\n      really is 258.  The last length deserves its own, short code\n      since it gets used a lot in very redundant files.  The length\n      258 is special since 258 - 3 (the min match length) is 255.\n  13. The literal/length and distance code bit lengths are read as a\n      single stream of lengths.  It is possible (and advantageous) for\n      a repeat code (16, 17, or 18) to go across the boundary between\n      the two sets of lengths.\n */\n\n\nvoid inflate_blocks_reset(inflate_blocks_statef *s, z_streamp z, uLong *c)\n{\n  if (c != Z_NULL)\n    *c = s->check;\n  if (s->mode == BTREE || s->mode == DTREE)\n    ZFREE(z, s->sub.trees.blens);\n  if (s->mode == CODES)\n    inflate_codes_free(s->sub.decode.codes, z);\n  s->mode = TYPE;\n  s->bitk = 0;\n  s->bitb = 0;\n  s->read = s->write = s->window;\n  if (s->checkfn != Z_NULL)\n    z->adler = s->check = (*s->checkfn)(0L, (const Byte *)Z_NULL, 0);\n  Tracev((\"inflate:   blocks reset\\n\"));\n}\n\n\ninflate_blocks_statef *inflate_blocks_new(z_streamp z, check_func c, uInt w)\n{\n  inflate_blocks_statef *s;\n\n  if ((s = (inflate_blocks_statef *)ZALLOC\n       (z,1,sizeof(struct inflate_blocks_state))) == Z_NULL)\n    return s;\n  if ((s->hufts =\n       (inflate_huft *)ZALLOC(z, sizeof(inflate_huft), MANY)) == Z_NULL)\n  {\n    ZFREE(z, s);\n    return Z_NULL;\n  }\n  if ((s->window = (Byte *)ZALLOC(z, 1, w)) == Z_NULL)\n  {\n    ZFREE(z, s->hufts);\n    ZFREE(z, s);\n    return Z_NULL;\n  }\n  s->end = s->window + w;\n  s->checkfn = c;\n  s->mode = TYPE;\n  Tracev((\"inflate:   blocks allocated\\n\"));\n  inflate_blocks_reset(s, z, Z_NULL);\n  return s;\n}\n\n\nint inflate_blocks(inflate_blocks_statef *s, z_streamp z, int r)\n{\n  uInt t;               /* temporary storage */\n  uLong b;              /* bit buffer */\n  uInt k;               /* bits in bit buffer */\n  Byte *p;             /* input data pointer */\n  uInt n;               /* bytes available there */\n  Byte *q;             /* output window write pointer */\n  uInt m;               /* bytes to end of window or read pointer */\n\n  /* copy input/output information to locals (UPDATE macro restores) */\n  LOAD\n\n  /* process input based on current state */\n  while (1) switch (s->mode)\n  {\n    case TYPE:\n      NEEDBITS(3)\n      t = (uInt)b & 7;\n      s->last = t & 1;\n      switch (t >> 1)\n      {\n        case 0:                         /* stored */\n          Tracev((\"inflate:     stored block%s\\n\",\n                 s->last ? \" (last)\" : \"\"));\n          DUMPBITS(3)\n          t = k & 7;                    /* go to byte boundary */\n          DUMPBITS(t)\n          s->mode = LENS;               /* get length of stored block */\n          break;\n        case 1:                         /* fixed */\n          Tracev((\"inflate:     fixed codes block%s\\n\",\n                 s->last ? \" (last)\" : \"\"));\n          {\n            uInt bl, bd;\n            inflate_huft *tl, *td;\n            inflate_trees_fixed(&bl, &bd, &tl, &td, z);\n            s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z);\n            if (s->sub.decode.codes == Z_NULL)\n            {\n              r = Z_MEM_ERROR;\n              LEAVE\n            }\n          }\n          DUMPBITS(3)\n          s->mode = CODES;\n          break;\n        case 2:                         /* dynamic */\n          Tracev((\"inflate:     dynamic codes block%s\\n\",\n                 s->last ? \" (last)\" : \"\"));\n          DUMPBITS(3)\n          s->mode = TABLE;\n          break;\n        case 3:                         /* illegal */\n          DUMPBITS(3)\n          s->mode = BAD;\n          z->msg = (char*)\"invalid block type\";\n          r = Z_DATA_ERROR;\n          LEAVE\n      }\n      break;\n    case LENS:\n      NEEDBITS(32)\n      if ((((~b) >> 16) & 0xffff) != (b & 0xffff))\n      {\n        s->mode = BAD;\n        z->msg = (char*)\"invalid stored block lengths\";\n        r = Z_DATA_ERROR;\n        LEAVE\n      }\n      s->sub.left = (uInt)b & 0xffff;\n      b = k = 0;                      /* dump bits */\n      Tracev((\"inflate:       stored length %u\\n\", s->sub.left));\n      s->mode = s->sub.left ? STORED : (s->last ? DRY : TYPE);\n      break;\n    case STORED:\n      if (n == 0)\n        LEAVE\n      NEEDOUT\n      t = s->sub.left;\n      if (t > n) t = n;\n      if (t > m) t = m;\n      zmemcpy(q, p, t);\n      p += t;  n -= t;\n      q += t;  m -= t;\n      if ((s->sub.left -= t) != 0)\n        break;\n      Tracev((\"inflate:       stored end, %lu total out\\n\",\n              z->total_out + (q >= s->read ? q - s->read :\n              (s->end - s->read) + (q - s->window))));\n      s->mode = s->last ? DRY : TYPE;\n      break;\n    case TABLE:\n      NEEDBITS(14)\n      s->sub.trees.table = t = (uInt)b & 0x3fff;\n#ifndef PKZIP_BUG_WORKAROUND\n      if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)\n      {\n        s->mode = BAD;\n        z->msg = (char*)\"too many length or distance symbols\";\n        r = Z_DATA_ERROR;\n        LEAVE\n      }\n#endif\n      t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f);\n      if ((s->sub.trees.blens = (uInt*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL)\n      {\n        r = Z_MEM_ERROR;\n        LEAVE\n      }\n      DUMPBITS(14)\n      s->sub.trees.index = 0;\n      Tracev((\"inflate:       table sizes ok\\n\"));\n      s->mode = BTREE;\n    case BTREE:\n      while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10))\n      {\n        NEEDBITS(3)\n        s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7;\n        DUMPBITS(3)\n      }\n      while (s->sub.trees.index < 19)\n        s->sub.trees.blens[border[s->sub.trees.index++]] = 0;\n      s->sub.trees.bb = 7;\n      t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb,\n                             &s->sub.trees.tb, s->hufts, z);\n      if (t != Z_OK)\n      {\n        ZFREE(z, s->sub.trees.blens);\n        r = t;\n        if (r == Z_DATA_ERROR)\n          s->mode = BAD;\n        LEAVE\n      }\n      s->sub.trees.index = 0;\n      Tracev((\"inflate:       bits tree ok\\n\"));\n      s->mode = DTREE;\n    case DTREE:\n      while (t = s->sub.trees.table,\n             s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))\n      {\n        inflate_huft *h;\n        uInt i, j, c;\n\n        t = s->sub.trees.bb;\n        NEEDBITS(t)\n        h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]);\n        t = h->bits;\n        c = h->base;\n        if (c < 16)\n        {\n          DUMPBITS(t)\n          s->sub.trees.blens[s->sub.trees.index++] = c;\n        }\n        else /* c == 16..18 */\n        {\n          i = c == 18 ? 7 : c - 14;\n          j = c == 18 ? 11 : 3;\n          NEEDBITS(t + i)\n          DUMPBITS(t)\n          j += (uInt)b & inflate_mask[i];\n          DUMPBITS(i)\n          i = s->sub.trees.index;\n          t = s->sub.trees.table;\n          if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||\n              (c == 16 && i < 1))\n          {\n            ZFREE(z, s->sub.trees.blens);\n            s->mode = BAD;\n            z->msg = (char*)\"invalid bit length repeat\";\n            r = Z_DATA_ERROR;\n            LEAVE\n          }\n          c = c == 16 ? s->sub.trees.blens[i - 1] : 0;\n          do {\n            s->sub.trees.blens[i++] = c;\n          } while (--j);\n          s->sub.trees.index = i;\n        }\n      }\n      s->sub.trees.tb = Z_NULL;\n      {\n        uInt bl, bd;\n        inflate_huft *tl, *td;\n        inflate_codes_statef *c;\n\n        tl = NULL;\n        td = NULL;\n        bl = 9;         /* must be <= 9 for lookahead assumptions */\n        bd = 6;         /* must be <= 9 for lookahead assumptions */\n        t = s->sub.trees.table;\n        t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f),\n                                  s->sub.trees.blens, &bl, &bd, &tl, &td,\n                                  s->hufts, z);\n        ZFREE(z, s->sub.trees.blens);\n        if (t != Z_OK)\n        {\n          if (t == (uInt)Z_DATA_ERROR)\n            s->mode = BAD;\n          r = t;\n          LEAVE\n        }\n        Tracev((\"inflate:       trees ok\\n\"));\n        if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL)\n        {\n          r = Z_MEM_ERROR;\n          LEAVE\n        }\n        s->sub.decode.codes = c;\n      }\n      s->mode = CODES;\n    case CODES:\n      UPDATE\n      if ((r = inflate_codes(s, z, r)) != Z_STREAM_END)\n        return inflate_flush(s, z, r);\n      r = Z_OK;\n      inflate_codes_free(s->sub.decode.codes, z);\n      LOAD\n      Tracev((\"inflate:       codes end, %lu total out\\n\",\n              z->total_out + (q >= s->read ? q - s->read :\n              (s->end - s->read) + (q - s->window))));\n      if (!s->last)\n      {\n        s->mode = TYPE;\n        break;\n      }\n      s->mode = DRY;\n    case DRY:\n      FLUSH\n      if (s->read != s->write)\n        LEAVE\n      s->mode = DONE;\n    case DONE:\n      r = Z_STREAM_END;\n      LEAVE\n    case BAD:\n      r = Z_DATA_ERROR;\n      LEAVE\n    default:\n      r = Z_STREAM_ERROR;\n      LEAVE\n  }\n}\n\n\nint inflate_blocks_free(inflate_blocks_statef *s, z_streamp z)\n{\n  inflate_blocks_reset(s, z, Z_NULL);\n  ZFREE(z, s->window);\n  ZFREE(z, s->hufts);\n  ZFREE(z, s);\n  Tracev((\"inflate:   blocks freed\\n\"));\n  return Z_OK;\n}\n\n#if 0\nvoid inflate_set_dictionary(inflate_blocks_statef *s, const Byte *d, uInt n)\n{\n  zmemcpy(s->window, d, n);\n  s->read = s->write = s->window + n;\n}\n\n/* Returns true if inflate is currently at the end of a block generated\n * by Z_SYNC_FLUSH or Z_FULL_FLUSH. \n * IN assertion: s != Z_NULL\n */\nint inflate_blocks_sync_point(inflate_blocks_statef *s)\n{\n  return s->mode == LENS;\n}\n#endif\n\n\n/* And'ing with mask[n] masks the lower n bits */\nstatic uInt inflate_mask[17] = {\n    0x0000,\n    0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,\n    0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff\n};\n\n\n/* copy as much as possible from the sliding window to the output area */\nint inflate_flush(inflate_blocks_statef *s, z_streamp z, int r)\n{\n  uInt n;\n  Byte *p;\n  Byte *q;\n\n  /* static copies of source and destination pointers */\n  p = z->next_out;\n  q = s->read;\n\n  /* compute number of bytes to copy as as end of window */\n  n = (uInt)((q <= s->write ? s->write : s->end) - q);\n  if (n > z->avail_out) n = z->avail_out;\n  if (n && r == Z_BUF_ERROR) r = Z_OK;\n\n  /* update counters */\n  z->avail_out -= n;\n  z->total_out += n;\n\n  /* update check information */\n  if (s->checkfn != Z_NULL)\n    z->adler = s->check = (*s->checkfn)(s->check, q, n);\n\n  /* copy as as end of window */\n  zmemcpy(p, q, n);\n  p += n;\n  q += n;\n\n  /* see if more to copy at beginning of window */\n  if (q == s->end)\n  {\n    /* wrap pointers */\n    q = s->window;\n    if (s->write == s->end)\n      s->write = s->window;\n\n    /* compute bytes to copy */\n    n = (uInt)(s->write - q);\n    if (n > z->avail_out) n = z->avail_out;\n    if (n && r == Z_BUF_ERROR) r = Z_OK;\n\n    /* update counters */\n    z->avail_out -= n;\n    z->total_out += n;\n\n    /* update check information */\n    if (s->checkfn != Z_NULL)\n      z->adler = s->check = (*s->checkfn)(s->check, q, n);\n\n    /* copy */\n    zmemcpy(p, q, n);\n    p += n;\n    q += n;\n  }\n\n  /* update pointers */\n  z->next_out = p;\n  s->read = q;\n\n  /* done */\n  return r;\n}\n\n/* inftrees.c -- generate Huffman trees for efficient decoding\n * Copyright (C) 1995-1998 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h \n */\n\nstatic const char inflate_copyright[] =\n   \" inflate 1.1.3 Copyright 1995-1998 Mark Adler \";\n/*\n  If you use the zlib library in a product, an acknowledgment is welcome\n  in the documentation of your product. If for some reason you cannot\n  include such an acknowledgment, I would appreciate that you keep this\n  copyright string in the executable of your product.\n */\n\n/* simplify the use of the inflate_huft type with some defines */\n#define exop word.what.Exop\n#define bits word.what.Bits\n\n\nstatic int huft_build OF((\n    uInt *,\t\t\t\t/* code lengths in bits */\n    uInt,               /* number of codes */\n    uInt,               /* number of \"simple\" codes */\n    const uInt *,\t\t/* list of base values for non-simple codes */\n    const uInt *,\t\t/* list of extra bits for non-simple codes */\n    inflate_huft **,\t/* result: starting table */\n    uInt *,\t\t\t\t/* maximum lookup bits (returns actual) */\n    inflate_huft *,     /* space for trees */\n    uInt *,             /* hufts used in space */\n    uInt * ));\t\t\t/* space for values */\n\n/* Tables for deflate from PKZIP's appnote.txt. */\nstatic const uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */\n        3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n        35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};\n        /* see note #13 above about 258 */\nstatic const uInt cplext[31] = { /* Extra bits for literal codes 257..285 */\n        0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,\n        3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112}; /* 112==invalid */\nstatic const uInt cpdist[30] = { /* Copy offsets for distance codes 0..29 */\n        1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n        257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n        8193, 12289, 16385, 24577};\nstatic const uInt cpdext[30] = { /* Extra bits for distance codes */\n        0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,\n        7, 7, 8, 8, 9, 9, 10, 10, 11, 11,\n        12, 12, 13, 13};\n\n/*\n   Huffman code decoding is performed using a multi-level table lookup.\n   The fastest way to decode is to simply build a lookup table whose\n   size is determined by the longest code.  However, the time it takes\n   to build this table can also be a factor if the data being decoded\n   is not very long.  The most common codes are necessarily the\n   shortest codes, so those codes dominate the decoding time, and hence\n   the speed.  The idea is you can have a shorter table that decodes the\n   shorter, more probable codes, and then point to subsidiary tables for\n   the longer codes.  The time it costs to decode the longer codes is\n   then traded against the time it takes to make longer tables.\n\n   This results of this trade are in the variables lbits and dbits\n   below.  lbits is the number of bits the first level table for literal/\n   length codes can decode in one step, and dbits is the same thing for\n   the distance codes.  Subsequent tables are also less than or equal to\n   those sizes.  These values may be adjusted either when all of the\n   codes are shorter than that, in which case the longest code length in\n   bits is used, or when the shortest code is *longer* than the requested\n   table size, in which case the length of the shortest code in bits is\n   used.\n\n   There are two different values for the two tables, since they code a\n   different number of possibilities each.  The literal/length table\n   codes 286 possible values, or in a flat code, a little over eight\n   bits.  The distance table codes 30 possible values, or a little less\n   than five bits, flat.  The optimum values for speed end up being\n   about one bit more than those, so lbits is 8+1 and dbits is 5+1.\n   The optimum values may differ though from machine to machine, and\n   possibly even between compilers.  Your mileage may vary.\n */\n\n\n/* If BMAX needs to be larger than 16, then h and x[] should be uLong. */\n#define BMAX 15         /* maximum bit length of any code */\n\nstatic int huft_build(uInt *b, uInt n, uInt s, const uInt *d, const uInt *e, inflate_huft ** t, uInt *m, inflate_huft *hp, uInt *hn, uInt *v)\n//uInt *b;               /* code lengths in bits (all assumed <= BMAX) */\n//uInt n;                 /* number of codes (assumed <= 288) */\n//uInt s;                 /* number of simple-valued codes (0..s-1) */\n//const uInt *d;         /* list of base values for non-simple codes */\n//const uInt *e;         /* list of extra bits for non-simple codes */\n//inflate_huft ** t;\t\t/* result: starting table */\n//uInt *m;               /* maximum lookup bits, returns actual */\n//inflate_huft *hp;       /* space for trees */\n//uInt *hn;               /* hufts used in space */\n//uInt *v;               /* working area: values in order of bit length */\n/* Given a list of code lengths and a maximum table size, make a set of\n   tables to decode that set of codes.  Return Z_OK on success, Z_BUF_ERROR\n   if the given code set is incomplete (the tables are still built in this\n   case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of\n   lengths), or Z_MEM_ERROR if not enough memory. */\n{\n\n  uInt a;                       /* counter for codes of length k */\n  uInt c[BMAX+1];               /* bit length count table */\n  uInt f;                       /* i repeats in table every f entries */\n  int g;                        /* maximum code length */\n  int h;                        /* table level */\n  register uInt i;              /* counter, current code */\n  register uInt j;              /* counter */\n  register int k;               /* number of bits in current code */\n  int l;                        /* bits per table (returned in m) */\n  uInt mask;                    /* (1 << w) - 1, to avoid cc -O bug on HP */\n  register uInt *p;            /* pointer into c[], b[], or v[] */\n  inflate_huft *q;              /* points to current table */\n  struct inflate_huft_s r;      /* table entry for structure assignment */\n  inflate_huft *u[BMAX];        /* table stack */\n  register int w;               /* bits before this table == (l * h) */\n  uInt x[BMAX+1];               /* bit offsets, then code stack */\n  uInt *xp;                    /* pointer into x */\n  int y;                        /* number of dummy codes added */\n  uInt z;                       /* number of entries in current table */\n\n\n  /* Generate counts for each bit length */\n  p = c;\n#define C0 *p++ = 0;\n#define C2 C0 C0 C0 C0\n#define C4 C2 C2 C2 C2\n  C4                            /* clear c[]--assume BMAX+1 is 16 */\n  p = b;  i = n;\n  do {\n    c[*p++]++;                  /* assume all entries <= BMAX */\n  } while (--i);\n  if (c[0] == n)                /* null input--all zero length codes */\n  {\n    *t = (inflate_huft *)Z_NULL;\n    *m = 0;\n    return Z_OK;\n  }\n\n\n  /* Find minimum and maximum length, bound *m by those */\n  l = *m;\n  for (j = 1; j <= BMAX; j++)\n    if (c[j])\n      break;\n  k = j;                        /* minimum code length */\n  if ((uInt)l < j)\n    l = j;\n  for (i = BMAX; i; i--)\n    if (c[i])\n      break;\n  g = i;                        /* maximum code length */\n  if ((uInt)l > i)\n    l = i;\n  *m = l;\n\n\n  /* Adjust last length count to fill out codes, if needed */\n  for (y = 1 << j; j < i; j++, y <<= 1)\n    if ((y -= c[j]) < 0)\n      return Z_DATA_ERROR;\n  if ((y -= c[i]) < 0)\n    return Z_DATA_ERROR;\n  c[i] += y;\n\n\n  /* Generate starting offsets into the value table for each length */\n  x[1] = j = 0;\n  p = c + 1;  xp = x + 2;\n  while (--i) {                 /* note that i == g from above */\n    *xp++ = (j += *p++);\n  }\n\n\n  /* Make a table of values in order of bit lengths */\n  p = b;  i = 0;\n  do {\n    if ((j = *p++) != 0)\n      v[x[j]++] = i;\n  } while (++i < n);\n  n = x[g];                     /* set n to length of v */\n\n\n  /* Generate the Huffman codes and for each, make the table entries */\n  x[0] = i = 0;                 /* first Huffman code is zero */\n  p = v;                        /* grab values in bit order */\n  h = -1;                       /* no tables yet--level -1 */\n  w = -l;                       /* bits decoded == (l * h) */\n  u[0] = (inflate_huft *)Z_NULL;        /* just to keep compilers happy */\n  q = (inflate_huft *)Z_NULL;   /* ditto */\n  z = 0;                        /* ditto */\n\n  /* go through the bit lengths (k already is bits in shortest code) */\n  for (; k <= g; k++)\n  {\n    a = c[k];\n    while (a--)\n    {\n      /* here i is the Huffman code of length k bits for value *p */\n      /* make tables up to required level */\n      while (k > w + l)\n      {\n        h++;\n        w += l;                 /* previous table always l bits */\n\n        /* compute minimum size table less than or equal to l bits */\n        z = g - w;\n        z = z > (uInt)l ? l : z;        /* table size upper limit */\n        if ((f = 1 << (j = k - w)) > a + 1)     /* try a k-w bit table */\n        {                       /* too few codes for k-w bit table */\n          f -= a + 1;           /* deduct codes from patterns left */\n          xp = c + k;\n          if (j < z)\n            while (++j < z)     /* try smaller tables up to z bits */\n            {\n              if ((f <<= 1) <= *++xp)\n                break;          /* enough codes to use up j bits */\n              f -= *xp;         /* else deduct codes from patterns */\n            }\n        }\n        z = 1 << j;             /* table entries for j-bit table */\n\n        /* allocate new table */\n        if (*hn + z > MANY)     /* (note: doesn't matter for fixed) */\n          return Z_MEM_ERROR;   /* not enough memory */\n        u[h] = q = hp + *hn;\n        *hn += z;\n\n        /* connect to last table, if there is one */\n        if (h)\n        {\n          x[h] = i;             /* save pattern for backing up */\n          r.bits = (Byte)l;     /* bits to dump before this table */\n          r.exop = (Byte)j;     /* bits in this table */\n          j = i >> (w - l);\n          r.base = (uInt)(q - u[h-1] - j);   /* offset to this table */\n          u[h-1][j] = r;        /* connect to last table */\n        }\n        else\n          *t = q;               /* first table is returned result */\n      }\n\n      /* set up table entry in r */\n      r.bits = (Byte)(k - w);\n      if (p >= v + n)\n        r.exop = 128 + 64;      /* out of values--invalid code */\n      else if (*p < s)\n      {\n        r.exop = (Byte)(*p < 256 ? 0 : 32 + 64);     /* 256 is end-of-block */\n        r.base = *p++;          /* simple code is just the value */\n      }\n      else\n      {\n        r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */\n        r.base = d[*p++ - s];\n      }\n\n      /* fill code-like entries with r */\n      f = 1 << (k - w);\n      for (j = i >> w; j < z; j += f)\n        q[j] = r;\n\n      /* backwards increment the k-bit code i */\n      for (j = 1 << (k - 1); i & j; j >>= 1)\n        i ^= j;\n      i ^= j;\n\n      /* backup over finished tables */\n      mask = (1 << w) - 1;      /* needed on HP, cc -O bug */\n      while ((i & mask) != x[h])\n      {\n        h--;                    /* don't need to update q */\n        w -= l;\n        mask = (1 << w) - 1;\n      }\n    }\n  }\n\n\n  /* Return Z_BUF_ERROR if we were given an incomplete table */\n  return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK;\n}\n\n\nint inflate_trees_bits(uInt *c, uInt *bb, inflate_huft * *tb, inflate_huft *hp, z_streamp z)\n//uInt *c;               /* 19 code lengths */\n//uInt *bb;              /* bits tree desired/actual depth */\n//inflate_huft * *tb; /* bits tree result */\n//inflate_huft *hp;       /* space for trees */\n//z_streamp z;            /* for messages */\n{\n  int r;\n  uInt hn = 0;          /* hufts used in space */\n  uInt *v;             /* work area for huft_build */\n\n  if ((v = (uInt*)ZALLOC(z, 19, sizeof(uInt))) == Z_NULL)\n    return Z_MEM_ERROR;\n  r = huft_build(c, 19, 19, (uInt*)Z_NULL, (uInt*)Z_NULL,\n                 tb, bb, hp, &hn, v);\n  if (r == Z_DATA_ERROR)\n    z->msg = (char*)\"oversubscribed dynamic bit lengths tree\";\n  else if (r == Z_BUF_ERROR || *bb == 0)\n  {\n    z->msg = (char*)\"incomplete dynamic bit lengths tree\";\n    r = Z_DATA_ERROR;\n  }\n  ZFREE(z, v);\n  return r;\n}\n\n\nint inflate_trees_dynamic(uInt nl, uInt nd, uInt *c, uInt *bl, uInt *bd, inflate_huft * *tl, inflate_huft * *td, inflate_huft *hp, z_streamp z)\n//uInt nl;                /* number of literal/length codes */\n//uInt nd;                /* number of distance codes */\n//uInt *c;               /* that many (total) code lengths */\n//uInt *bl;              /* literal desired/actual bit depth */\n//uInt *bd;              /* distance desired/actual bit depth */\n//inflate_huft * *tl; /* literal/length tree result */\n//inflate_huft * *td; /* distance tree result */\n//inflate_huft *hp;       /* space for trees */\n//z_streamp z;            /* for messages */\n{\n  int r;\n  uInt hn = 0;          /* hufts used in space */\n  uInt *v;             /* work area for huft_build */\n\n  /* allocate work area */\n  if ((v = (uInt*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)\n    return Z_MEM_ERROR;\n\n  /* build literal/length tree */\n  r = huft_build(c, nl, 257, cplens, cplext, tl, bl, hp, &hn, v);\n  if (r != Z_OK || *bl == 0)\n  {\n    if (r == Z_DATA_ERROR)\n      z->msg = (char*)\"oversubscribed literal/length tree\";\n    else if (r != Z_MEM_ERROR)\n    {\n      z->msg = (char*)\"incomplete literal/length tree\";\n      r = Z_DATA_ERROR;\n    }\n    ZFREE(z, v);\n    return r;\n  }\n\n  /* build distance tree */\n  r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, hp, &hn, v);\n  if (r != Z_OK || (*bd == 0 && nl > 257))\n  {\n    if (r == Z_DATA_ERROR)\n      z->msg = (char*)\"oversubscribed distance tree\";\n    else if (r == Z_BUF_ERROR) {\n#ifdef PKZIP_BUG_WORKAROUND\n      r = Z_OK;\n    }\n#else\n      z->msg = (char*)\"incomplete distance tree\";\n      r = Z_DATA_ERROR;\n    }\n    else if (r != Z_MEM_ERROR)\n    {\n      z->msg = (char*)\"empty distance tree with lengths\";\n      r = Z_DATA_ERROR;\n    }\n    ZFREE(z, v);\n    return r;\n#endif\n  }\n\n  /* done */\n  ZFREE(z, v);\n  return Z_OK;\n}\n\n/* inffixed.h -- table for decoding fixed codes\n * Generated automatically by the maketree.c program\n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\nstatic uInt fixed_bl = 9;\nstatic uInt fixed_bd = 5;\nstatic inflate_huft fixed_tl[] = {\n    {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},\n    {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192},\n    {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160},\n    {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},224},\n    {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},144},\n    {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},208},\n    {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},176},\n    {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},240},\n    {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},\n    {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},200},\n    {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},168},\n    {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},232},\n    {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},152},\n    {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},216},\n    {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},184},\n    {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},248},\n    {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},\n    {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},196},\n    {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},164},\n    {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},228},\n    {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},148},\n    {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},212},\n    {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},180},\n    {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},244},\n    {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},\n    {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},204},\n    {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},172},\n    {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},236},\n    {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},156},\n    {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},220},\n    {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},188},\n    {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},252},\n    {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},\n    {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},194},\n    {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},162},\n    {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},226},\n    {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},146},\n    {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},210},\n    {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},178},\n    {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},242},\n    {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},\n    {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},202},\n    {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},170},\n    {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},234},\n    {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},154},\n    {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},218},\n    {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},186},\n    {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},250},\n    {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},\n    {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},198},\n    {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},166},\n    {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},230},\n    {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},150},\n    {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},214},\n    {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},182},\n    {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},246},\n    {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},\n    {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},206},\n    {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},174},\n    {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},238},\n    {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},158},\n    {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},222},\n    {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},190},\n    {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},254},\n    {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},\n    {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},193},\n    {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},161},\n    {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},225},\n    {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},145},\n    {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},209},\n    {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},177},\n    {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},241},\n    {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},\n    {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},201},\n    {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},169},\n    {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},233},\n    {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},153},\n    {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},217},\n    {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},185},\n    {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},249},\n    {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},\n    {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},197},\n    {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},165},\n    {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},229},\n    {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},149},\n    {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},213},\n    {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},181},\n    {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},245},\n    {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},\n    {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},205},\n    {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},173},\n    {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},237},\n    {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},157},\n    {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},221},\n    {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},189},\n    {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},253},\n    {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},\n    {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},195},\n    {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},163},\n    {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},227},\n    {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},147},\n    {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},211},\n    {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},179},\n    {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},243},\n    {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},\n    {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},203},\n    {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},171},\n    {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},235},\n    {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},155},\n    {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},219},\n    {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},187},\n    {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},251},\n    {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},\n    {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},199},\n    {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},167},\n    {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},231},\n    {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},151},\n    {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},215},\n    {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},183},\n    {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},247},\n    {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},\n    {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},207},\n    {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},175},\n    {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},239},\n    {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},159},\n    {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},223},\n    {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191},\n    {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255}\n  };\nstatic inflate_huft fixed_td[] = {\n    {{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097},\n    {{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385},\n    {{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193},\n    {{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577},\n    {{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145},\n    {{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577},\n    {{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289},\n    {{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577}\n  };\n\nint inflate_trees_fixed(uInt *bl, uInt *bd, inflate_huft * *tl, inflate_huft * *td, z_streamp z)\n//uInt *bl;               /* literal desired/actual bit depth */\n//uInt *bd;               /* distance desired/actual bit depth */\n//inflate_huft * *tl;  /* literal/length tree result */\n//inflate_huft * *td;  /* distance tree result */\n//z_streamp z;             /* for memory allocation */\n{\n  *bl = fixed_bl;\n  *bd = fixed_bd;\n  *tl = fixed_tl;\n  *td = fixed_td;\n  return Z_OK;\n}\n\n/* simplify the use of the inflate_huft type with some defines */\n#define exop word.what.Exop\n#define bits word.what.Bits\n\n/* macros for bit input with no checking and for returning unused bytes */\n#define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}}\n#define UNGRAB {c=z->avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;}\n\n/* Called with number of bytes left to write in window at least 258\n   (the maximum string length) and number of input bytes available\n   at least ten.  The ten bytes are six bytes for the longest length/\n   distance pair plus four bytes for overloading the bit buffer. */\n\nstatic int inflate_fast(uInt bl, uInt bd, inflate_huft *tl, inflate_huft *td, inflate_blocks_statef *s, z_streamp z)\n{\n  inflate_huft *t;      /* temporary pointer */\n  uInt e;               /* extra bits or operation */\n  uLong b;              /* bit buffer */\n  uInt k;               /* bits in bit buffer */\n  Byte *p;             /* input data pointer */\n  uInt n;               /* bytes available there */\n  Byte *q;             /* output window write pointer */\n  uInt m;               /* bytes to end of window or read pointer */\n  uInt ml;              /* mask for literal/length tree */\n  uInt md;              /* mask for distance tree */\n  uInt c;               /* bytes to copy */\n  uInt d;               /* distance back to copy from */\n  Byte *r;             /* copy source pointer */\n\n  /* load input, output, bit values */\n  LOAD\n\n  /* initialize masks */\n  ml = inflate_mask[bl];\n  md = inflate_mask[bd];\n\n  /* do until not enough input or output space for fast loop */\n  do {                          /* assume called with m >= 258 && n >= 10 */\n    /* get literal/length code */\n    GRABBITS(20)                /* max bits for literal/length code */\n    if ((e = (t = tl + ((uInt)b & ml))->exop) == 0)\n    {\n      DUMPBITS(t->bits)\n      Tracevv((t->base >= 0x20 && t->base < 0x7f ?\n                \"inflate:         * literal '%c'\\n\" :\n                \"inflate:         * literal 0x%02x\\n\", t->base));\n      *q++ = (Byte)t->base;\n      m--;\n      continue;\n    }\n    do {\n      DUMPBITS(t->bits)\n      if (e & 16)\n      {\n        /* get extra bits for length */\n        e &= 15;\n        c = t->base + ((uInt)b & inflate_mask[e]);\n        DUMPBITS(e)\n        Tracevv((\"inflate:         * length %u\\n\", c));\n\n        /* decode distance base of block to copy */\n        GRABBITS(15);           /* max bits for distance code */\n        e = (t = td + ((uInt)b & md))->exop;\n        do {\n          DUMPBITS(t->bits)\n          if (e & 16)\n          {\n            /* get extra bits to add to distance base */\n            e &= 15;\n            GRABBITS(e)         /* get extra bits (up to 13) */\n            d = t->base + ((uInt)b & inflate_mask[e]);\n            DUMPBITS(e)\n            Tracevv((\"inflate:         * distance %u\\n\", d));\n\n            /* do the copy */\n            m -= c;\n            if ((uInt)(q - s->window) >= d)     /* offset before dest */\n            {                                   /*  just copy */\n              r = q - d;\n              *q++ = *r++;  c--;        /* minimum count is three, */\n              *q++ = *r++;  c--;        /*  so unroll loop a little */\n            }\n            else                        /* else offset after destination */\n            {\n              e = d - (uInt)(q - s->window); /* bytes from offset to end */\n              r = s->end - e;           /* pointer to offset */\n              if (c > e)                /* if source crosses, */\n              {\n                c -= e;                 /* copy to end of window */\n                do {\n                  *q++ = *r++;\n                } while (--e);\n                r = s->window;          /* copy rest from start of window */\n              }\n            }\n            do {                        /* copy all or what's left */\n              *q++ = *r++;\n            } while (--c);\n            break;\n          }\n          else if ((e & 64) == 0)\n          {\n            t += t->base;\n            e = (t += ((uInt)b & inflate_mask[e]))->exop;\n          }\n          else\n          {\n            z->msg = (char*)\"invalid distance code\";\n            UNGRAB\n            UPDATE\n            return Z_DATA_ERROR;\n          }\n        } while (1);\n        break;\n      }\n      if ((e & 64) == 0)\n      {\n        t += t->base;\n        if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0)\n        {\n          DUMPBITS(t->bits)\n          Tracevv((t->base >= 0x20 && t->base < 0x7f ?\n                    \"inflate:         * literal '%c'\\n\" :\n                    \"inflate:         * literal 0x%02x\\n\", t->base));\n          *q++ = (Byte)t->base;\n          m--;\n          break;\n        }\n      }\n      else if (e & 32)\n      {\n        Tracevv((\"inflate:         * end of block\\n\"));\n        UNGRAB\n        UPDATE\n        return Z_STREAM_END;\n      }\n      else\n      {\n        z->msg = (char*)\"invalid literal/length code\";\n        UNGRAB\n        UPDATE\n        return Z_DATA_ERROR;\n      }\n    } while (1);\n  } while (m >= 258 && n >= 10);\n\n  /* not enough input or output--restore pointers and return */\n  UNGRAB\n  UPDATE\n  return Z_OK;\n}\n\n/* infcodes.c -- process literals and length/distance pairs\n * Copyright (C) 1995-1998 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h \n */\n\n/* simplify the use of the inflate_huft type with some defines */\n#define exop word.what.Exop\n#define bits word.what.Bits\n\ntypedef enum {        /* waiting for \"i:\"=input, \"o:\"=output, \"x:\"=nothing */\n      START,    /* x: set up for LEN */\n      LEN,      /* i: get length/literal/eob next */\n      LENEXT,   /* i: getting length extra (have base) */\n      DIST,     /* i: get distance next */\n      DISTEXT,  /* i: getting distance extra */\n      COPY,     /* o: copying bytes in window, waiting for space */\n      LIT,      /* o: got literal, waiting for output space */\n      WASH,     /* o: got eob, possibly still output waiting */\n      END,      /* x: got eob and all data flushed */\n      BADCODE}  /* x: got error */\ninflate_codes_mode;\n\n/* inflate codes private state */\nstruct inflate_codes_state {\n\n  /* mode */\n  inflate_codes_mode mode;      /* current inflate_codes mode */\n\n  /* mode dependent information */\n  uInt len;\n  union {\n    struct {\n      inflate_huft *tree;       /* pointer into tree */\n      uInt need;                /* bits needed */\n    } code;             /* if LEN or DIST, where in tree */\n    uInt lit;           /* if LIT, literal */\n    struct {\n      uInt get;                 /* bits to get for extra */\n      uInt dist;                /* distance back to copy from */\n    } copy;             /* if EXT or COPY, where and how much */\n  } sub;                /* submode */\n\n  /* mode independent information */\n  Byte lbits;           /* ltree bits decoded per branch */\n  Byte dbits;           /* dtree bits decoder per branch */\n  inflate_huft *ltree;          /* literal/length/eob tree */\n  inflate_huft *dtree;          /* distance tree */\n\n};\n\n\ninflate_codes_statef *inflate_codes_new(uInt bl, uInt bd, inflate_huft *tl, inflate_huft *td, z_streamp z)\n{\n  inflate_codes_statef *c;\n\n  if ((c = (inflate_codes_statef *)\n       ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL)\n  {\n    c->mode = START;\n    c->lbits = (Byte)bl;\n    c->dbits = (Byte)bd;\n    c->ltree = tl;\n    c->dtree = td;\n    Tracev((\"inflate:       codes new\\n\"));\n  }\n  return c;\n}\n\n\nint inflate_codes(inflate_blocks_statef *s, z_streamp z, int r)\n{\n  uInt j;               /* temporary storage */\n  inflate_huft *t;      /* temporary pointer */\n  uInt e;               /* extra bits or operation */\n  uLong b;              /* bit buffer */\n  uInt k;               /* bits in bit buffer */\n  Byte *p;             /* input data pointer */\n  uInt n;               /* bytes available there */\n  Byte *q;             /* output window write pointer */\n  uInt m;               /* bytes to end of window or read pointer */\n  Byte *f;             /* pointer to copy strings from */\n  inflate_codes_statef *c = s->sub.decode.codes;  /* codes state */\n\n  /* copy input/output information to locals (UPDATE macro restores) */\n  LOAD\n\n  /* process input and output based on current state */\n  while (1) switch (c->mode)\n  {             /* waiting for \"i:\"=input, \"o:\"=output, \"x:\"=nothing */\n    case START:         /* x: set up for LEN */\n#ifndef SLOW\n      if (m >= 258 && n >= 10)\n      {\n        UPDATE\n        r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z);\n        LOAD\n        if (r != Z_OK)\n        {\n          c->mode = r == Z_STREAM_END ? WASH : BADCODE;\n          break;\n        }\n      }\n#endif /* !SLOW */\n      c->sub.code.need = c->lbits;\n      c->sub.code.tree = c->ltree;\n      c->mode = LEN;\n    case LEN:           /* i: get length/literal/eob next */\n      j = c->sub.code.need;\n      NEEDBITS(j)\n      t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);\n      DUMPBITS(t->bits)\n      e = (uInt)(t->exop);\n      if (e == 0)               /* literal */\n      {\n        c->sub.lit = t->base;\n        Tracevv((t->base >= 0x20 && t->base < 0x7f ?\n                 \"inflate:         literal '%c'\\n\" :\n                 \"inflate:         literal 0x%02x\\n\", t->base));\n        c->mode = LIT;\n        break;\n      }\n      if (e & 16)               /* length */\n      {\n        c->sub.copy.get = e & 15;\n        c->len = t->base;\n        c->mode = LENEXT;\n        break;\n      }\n      if ((e & 64) == 0)        /* next table */\n      {\n        c->sub.code.need = e;\n        c->sub.code.tree = t + t->base;\n        break;\n      }\n      if (e & 32)               /* end of block */\n      {\n        Tracevv((\"inflate:         end of block\\n\"));\n        c->mode = WASH;\n        break;\n      }\n      c->mode = BADCODE;        /* invalid code */\n      z->msg = (char*)\"invalid literal/length code\";\n      r = Z_DATA_ERROR;\n      LEAVE\n    case LENEXT:        /* i: getting length extra (have base) */\n      j = c->sub.copy.get;\n      NEEDBITS(j)\n      c->len += (uInt)b & inflate_mask[j];\n      DUMPBITS(j)\n      c->sub.code.need = c->dbits;\n      c->sub.code.tree = c->dtree;\n      Tracevv((\"inflate:         length %u\\n\", c->len));\n      c->mode = DIST;\n    case DIST:          /* i: get distance next */\n      j = c->sub.code.need;\n      NEEDBITS(j)\n      t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);\n      DUMPBITS(t->bits)\n      e = (uInt)(t->exop);\n      if (e & 16)               /* distance */\n      {\n        c->sub.copy.get = e & 15;\n        c->sub.copy.dist = t->base;\n        c->mode = DISTEXT;\n        break;\n      }\n      if ((e & 64) == 0)        /* next table */\n      {\n        c->sub.code.need = e;\n        c->sub.code.tree = t + t->base;\n        break;\n      }\n      c->mode = BADCODE;        /* invalid code */\n      z->msg = (char*)\"invalid distance code\";\n      r = Z_DATA_ERROR;\n      LEAVE\n    case DISTEXT:       /* i: getting distance extra */\n      j = c->sub.copy.get;\n      NEEDBITS(j)\n      c->sub.copy.dist += (uInt)b & inflate_mask[j];\n      DUMPBITS(j)\n      Tracevv((\"inflate:         distance %u\\n\", c->sub.copy.dist));\n      c->mode = COPY;\n    case COPY:          /* o: copying bytes in window, waiting for space */\n#ifndef __TURBOC__ /* Turbo C bug for following expression */\n      f = (uInt)(q - s->window) < c->sub.copy.dist ?\n          s->end - (c->sub.copy.dist - (q - s->window)) :\n          q - c->sub.copy.dist;\n#else\n      f = q - c->sub.copy.dist;\n      if ((uInt)(q - s->window) < c->sub.copy.dist)\n        f = s->end - (c->sub.copy.dist - (uInt)(q - s->window));\n#endif\n      while (c->len)\n      {\n        NEEDOUT\n        OUTBYTE(*f++)\n        if (f == s->end)\n          f = s->window;\n        c->len--;\n      }\n      c->mode = START;\n      break;\n    case LIT:           /* o: got literal, waiting for output space */\n      NEEDOUT\n      OUTBYTE(c->sub.lit)\n      c->mode = START;\n      break;\n    case WASH:          /* o: got eob, possibly more output */\n      if (k > 7)        /* return unused byte, if any */\n      {\n        Assert(k < 16, \"inflate_codes grabbed too many bytes\")\n        k -= 8;\n        n++;\n        p--;            /* can always return one */\n      }\n      FLUSH\n      if (s->read != s->write)\n        LEAVE\n      c->mode = END;\n    case END:\n      r = Z_STREAM_END;\n      LEAVE\n    case BADCODE:       /* x: got error */\n      r = Z_DATA_ERROR;\n      LEAVE\n    default:\n      r = Z_STREAM_ERROR;\n      LEAVE\n  }\n#ifdef NEED_DUMMY_RETURN\n  return Z_STREAM_ERROR;  /* Some dumb compilers complain without this */\n#endif\n}\n\n\nvoid inflate_codes_free(inflate_codes_statef *c, z_streamp z)\n{\n  ZFREE(z, c);\n  Tracev((\"inflate:       codes free\\n\"));\n}\n\n/* adler32.c -- compute the Adler-32 checksum of a data stream\n * Copyright (C) 1995-1998 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h \n */\n\n#define BASE 65521L /* largest prime smaller than 65536 */\n#define NMAX 5552\n/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */\n\n#undef DO1\n#undef DO2\n#undef DO4\n#undef DO8\n\n#define DO1(buf,i)  {s1 += buf[i]; s2 += s1;}\n#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);\n#define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);\n#define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);\n#define DO16(buf)   DO8(buf,0); DO8(buf,8);\n\n/* ========================================================================= */\nstatic uLong adler32(uLong adler, const Byte *buf, uInt len)\n{\n    unsigned long s1 = adler & 0xffff;\n    unsigned long s2 = (adler >> 16) & 0xffff;\n    int k;\n\n    if (buf == Z_NULL) return 1L;\n\n    while (len > 0) {\n        k = len < NMAX ? len : NMAX;\n        len -= k;\n        while (k >= 16) {\n            DO16(buf);\n\t    buf += 16;\n            k -= 16;\n        }\n        if (k != 0) do {\n            s1 += *buf++;\n\t    s2 += s1;\n        } while (--k);\n        s1 %= BASE;\n        s2 %= BASE;\n    }\n    return (s2 << 16) | s1;\n}\n\n\n/* infblock.h -- header to use infblock.c\n * Copyright (C) 1995-1998 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h \n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\nstatic inflate_blocks_statef * inflate_blocks_new OF((\n    z_streamp z,\n    check_func c,               /* check function */\n    uInt w));                   /* window size */\n\nstatic int inflate_blocks OF((\n    inflate_blocks_statef *,\n    z_streamp ,\n    int));                      /* initial return code */\n\nstatic void inflate_blocks_reset OF((\n    inflate_blocks_statef *,\n    z_streamp ,\n    uLong *));                  /* check value on output */\n\nstatic int inflate_blocks_free OF((\n    inflate_blocks_statef *,\n    z_streamp));\n\n#if 0\nstatic void inflate_set_dictionary OF((\n    inflate_blocks_statef *s,\n    const Byte *d,  /* dictionary */\n    uInt  n));       /* dictionary length */\n\nstatic int inflate_blocks_sync_point OF((\n    inflate_blocks_statef *s));\n#endif\n\ntypedef enum {\n      imMETHOD,   /* waiting for method byte */\n      imFLAG,     /* waiting for flag byte */\n      imDICT4,    /* four dictionary check bytes to go */\n      imDICT3,    /* three dictionary check bytes to go */\n      imDICT2,    /* two dictionary check bytes to go */\n      imDICT1,    /* one dictionary check byte to go */\n      imDICT0,    /* waiting for inflateSetDictionary */\n      imBLOCKS,   /* decompressing blocks */\n      imCHECK4,   /* four check bytes to go */\n      imCHECK3,   /* three check bytes to go */\n      imCHECK2,   /* two check bytes to go */\n      imCHECK1,   /* one check byte to go */\n      imDONE,     /* finished check, done */\n      imBAD}      /* got an error--stay here */\ninflate_mode;\n\n/* inflate private state */\nstruct internal_state {\n\n  /* mode */\n  inflate_mode  mode;   /* current inflate mode */\n\n  /* mode dependent information */\n  union {\n    uInt method;        /* if FLAGS, method byte */\n    struct {\n      uLong was;                /* computed check value */\n      uLong need;               /* stream check value */\n    } check;            /* if CHECK, check values to compare */\n    uInt marker;        /* if BAD, inflateSync's marker bytes count */\n  } sub;        /* submode */\n\n  /* mode independent information */\n  int  nowrap;          /* flag for no wrapper */\n  uInt wbits;           /* log2(window size)  (8..15, defaults to 15) */\n  inflate_blocks_statef \n    *blocks;            /* current inflate_blocks state */\n\n};\n\n\nint inflateReset(z_streamp z)\n{\n  if (z == Z_NULL || z->state == Z_NULL)\n    return Z_STREAM_ERROR;\n  z->total_in = z->total_out = 0;\n  z->msg = Z_NULL;\n  z->state->mode = z->state->nowrap ? imBLOCKS : imMETHOD;\n  inflate_blocks_reset(z->state->blocks, z, Z_NULL);\n  Tracev((\"inflate: reset\\n\"));\n  return Z_OK;\n}\n\n\nint inflateEnd(z_streamp z)\n{\n  if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL)\n    return Z_STREAM_ERROR;\n  if (z->state->blocks != Z_NULL)\n    inflate_blocks_free(z->state->blocks, z);\n  ZFREE(z, z->state);\n  z->state = Z_NULL;\n  Tracev((\"inflate: end\\n\"));\n  return Z_OK;\n}\n\n\n\nint inflateInit2_(z_streamp z, int w, const char *version, int stream_size)\n{\n  if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||\n      stream_size != sizeof(z_stream))\n      return Z_VERSION_ERROR;\n\n  /* initialize state */\n  if (z == Z_NULL)\n    return Z_STREAM_ERROR;\n  z->msg = Z_NULL;\n  if (z->zalloc == Z_NULL)\n  {\n    z->zalloc = (void *(*)(void *, unsigned, unsigned))zcalloc;\n    z->opaque = (voidp)0;\n  }\n  if (z->zfree == Z_NULL) z->zfree = (void (*)(void *, void *))zcfree;\n  if ((z->state = (struct internal_state *)\n       ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL)\n    return Z_MEM_ERROR;\n  z->state->blocks = Z_NULL;\n\n  /* handle undocumented nowrap option (no zlib header or check) */\n  z->state->nowrap = 0;\n  if (w < 0)\n  {\n    w = - w;\n    z->state->nowrap = 1;\n  }\n\n  /* set window size */\n  if (w < 8 || w > 15)\n  {\n    inflateEnd(z);\n    return Z_STREAM_ERROR;\n  }\n  z->state->wbits = (uInt)w;\n\n  /* create inflate_blocks state */\n  if ((z->state->blocks =\n      inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w))\n      == Z_NULL)\n  {\n    inflateEnd(z);\n    return Z_MEM_ERROR;\n  }\n  Tracev((\"inflate: allocated\\n\"));\n\n  /* reset state */\n  inflateReset(z);\n  return Z_OK;\n}\n\n#if 0\nint inflateInit_(z_streamp z, const char *version, int stream_size)\n{\n  return inflateInit2_(z, DEF_WBITS, version, stream_size);\n}\n#endif\n\n#define iNEEDBYTE {if(z->avail_in==0)return r;r=f;}\n#define iNEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++)\n\nint inflate(z_streamp z, int f)\n{\n  int r;\n  uInt b;\n\n  if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL)\n    return Z_STREAM_ERROR;\n  f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK;\n  r = Z_BUF_ERROR;\n  while (1) switch (z->state->mode)\n  {\n    case imMETHOD:\n      iNEEDBYTE\n      if (((z->state->sub.method = iNEXTBYTE) & 0xf) != Z_DEFLATED)\n      {\n        z->state->mode = imBAD;\n        z->msg = (char*)\"unknown compression method\";\n        z->state->sub.marker = 5;       /* can't try inflateSync */\n        break;\n      }\n      if ((z->state->sub.method >> 4) + 8 > z->state->wbits)\n      {\n        z->state->mode = imBAD;\n        z->msg = (char*)\"invalid window size\";\n        z->state->sub.marker = 5;       /* can't try inflateSync */\n        break;\n      }\n      z->state->mode = imFLAG;\n    case imFLAG:\n      iNEEDBYTE\n      b = iNEXTBYTE;\n      if (((z->state->sub.method << 8) + b) % 31)\n      {\n        z->state->mode = imBAD;\n        z->msg = (char*)\"incorrect header check\";\n        z->state->sub.marker = 5;       /* can't try inflateSync */\n        break;\n      }\n      Tracev((\"inflate: zlib header ok\\n\"));\n      if (!(b & PRESET_DICT))\n      {\n        z->state->mode = imBLOCKS;\n        break;\n      }\n      z->state->mode = imDICT4;\n    case imDICT4:\n      iNEEDBYTE\n      z->state->sub.check.need = (uLong)iNEXTBYTE << 24;\n      z->state->mode = imDICT3;\n    case imDICT3:\n      iNEEDBYTE\n      z->state->sub.check.need += (uLong)iNEXTBYTE << 16;\n      z->state->mode = imDICT2;\n    case imDICT2:\n      iNEEDBYTE\n      z->state->sub.check.need += (uLong)iNEXTBYTE << 8;\n      z->state->mode = imDICT1;\n    case imDICT1:\n      iNEEDBYTE\n      z->state->sub.check.need += (uLong)iNEXTBYTE;\n      z->adler = z->state->sub.check.need;\n      z->state->mode = imDICT0;\n      return Z_NEED_DICT;\n    case imDICT0:\n      z->state->mode = imBAD;\n      z->msg = (char*)\"need dictionary\";\n      z->state->sub.marker = 0;       /* can try inflateSync */\n      return Z_STREAM_ERROR;\n    case imBLOCKS:\n      r = inflate_blocks(z->state->blocks, z, r);\n      if (r == Z_DATA_ERROR)\n      {\n        z->state->mode = imBAD;\n        z->state->sub.marker = 0;       /* can try inflateSync */\n        break;\n      }\n      if (r == Z_OK)\n        r = f;\n      if (r != Z_STREAM_END)\n        return r;\n      r = f;\n      inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was);\n      if (z->state->nowrap)\n      {\n        z->state->mode = imDONE;\n        break;\n      }\n      z->state->mode = imCHECK4;\n    case imCHECK4:\n      iNEEDBYTE\n      z->state->sub.check.need = (uLong)iNEXTBYTE << 24;\n      z->state->mode = imCHECK3;\n    case imCHECK3:\n      iNEEDBYTE\n      z->state->sub.check.need += (uLong)iNEXTBYTE << 16;\n      z->state->mode = imCHECK2;\n    case imCHECK2:\n      iNEEDBYTE\n      z->state->sub.check.need += (uLong)iNEXTBYTE << 8;\n      z->state->mode = imCHECK1;\n    case imCHECK1:\n      iNEEDBYTE\n      z->state->sub.check.need += (uLong)iNEXTBYTE;\n\n      if (z->state->sub.check.was != z->state->sub.check.need)\n      {\n        z->state->mode = imBAD;\n        z->msg = (char*)\"incorrect data check\";\n        z->state->sub.marker = 5;       /* can't try inflateSync */\n        break;\n      }\n      Tracev((\"inflate: zlib check ok\\n\"));\n      z->state->mode = imDONE;\n    case imDONE:\n      return Z_STREAM_END;\n    case imBAD:\n      return Z_DATA_ERROR;\n    default:\n      return Z_STREAM_ERROR;\n  }\n#ifdef NEED_DUMMY_RETURN\n  return Z_STREAM_ERROR;  /* Some dumb compilers complain without this */\n#endif\n}\n\n// defined but not used\n#if 0\nint inflateSetDictionary(z_streamp z, const Byte *dictionary, uInt dictLength)\n{\n  uInt length = dictLength;\n\n  if (z == Z_NULL || z->state == Z_NULL || z->state->mode != imDICT0)\n    return Z_STREAM_ERROR;\n\n  if (adler32(1L, dictionary, dictLength) != z->adler) return Z_DATA_ERROR;\n  z->adler = 1L;\n\n  if (length >= ((uInt)1<<z->state->wbits))\n  {\n    length = (1<<z->state->wbits)-1;\n    dictionary += dictLength - length;\n  }\n  inflate_set_dictionary(z->state->blocks, dictionary, length);\n  z->state->mode = imBLOCKS;\n  return Z_OK;\n}\n\nint inflateSync(z_streamp z)\n{\n  uInt n;       /* number of bytes to look at */\n  Byte *p;     /* pointer to bytes */\n  uInt m;       /* number of marker bytes found in a row */\n  uLong r, w;   /* temporaries to save total_in and total_out */\n\n  /* set up */\n  if (z == Z_NULL || z->state == Z_NULL)\n    return Z_STREAM_ERROR;\n  if (z->state->mode != imBAD)\n  {\n    z->state->mode = imBAD;\n    z->state->sub.marker = 0;\n  }\n  if ((n = z->avail_in) == 0)\n    return Z_BUF_ERROR;\n  p = z->next_in;\n  m = z->state->sub.marker;\n\n  /* search */\n  while (n && m < 4)\n  {\n    static const Byte mark[4] = {0, 0, 0xff, 0xff};\n    if (*p == mark[m])\n      m++;\n    else if (*p)\n      m = 0;\n    else\n      m = 4 - m;\n    p++, n--;\n  }\n\n  /* restore */\n  z->total_in += p - z->next_in;\n  z->next_in = p;\n  z->avail_in = n;\n  z->state->sub.marker = m;\n\n  /* return no joy or set up to restart on a new block */\n  if (m != 4)\n    return Z_DATA_ERROR;\n  r = z->total_in;  w = z->total_out;\n  inflateReset(z);\n  z->total_in = r;  z->total_out = w;\n  z->state->mode = imBLOCKS;\n  return Z_OK;\n}\n\n/* Returns true if inflate is currently at the end of a block generated\n * by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP\n * implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH\n * but removes the length bytes of the resulting empty stored block. When\n * decompressing, PPP checks that at the end of input packet, inflate is\n * waiting for these length bytes.\n */\nint inflateSyncPoint(z_streamp z)\n{\n  if (z == Z_NULL || z->state == Z_NULL || z->state->blocks == Z_NULL)\n    return Z_STREAM_ERROR;\n  return inflate_blocks_sync_point(z->state->blocks);\n}\n#endif\n\nvoidp zcalloc (voidp opaque, unsigned items, unsigned size)\n{\n    if (opaque) items += size - size; /* make compiler happy */\n    return (voidp)Z_Malloc(items*size);\n}\n\nvoid  zcfree (voidp opaque, voidp ptr)\n{\n    Z_Free(ptr);\n    if (opaque) return; /* make compiler happy */\n}\n\n\n"
  },
  {
    "path": "code/qcommon/unzip.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)\n/* like the STRICT of WIN32, we define a pointer that cannot be converted\n    from (void*) without cast */\ntypedef struct TagunzFile__ { int unused; } unzFile__; \ntypedef unzFile__ *unzFile;\n#else\ntypedef void* unzFile;\n#endif\n\n/* tm_unz contain date/time info */\ntypedef struct tm_unz_s \n{\n\tunsigned int tm_sec;            /* seconds after the minute - [0,59] */\n\tunsigned int tm_min;            /* minutes after the hour - [0,59] */\n\tunsigned int tm_hour;           /* hours since midnight - [0,23] */\n\tunsigned int tm_mday;           /* day of the month - [1,31] */\n\tunsigned int tm_mon;            /* months since January - [0,11] */\n\tunsigned int tm_year;           /* years - [1980..2044] */\n} tm_unz;\n\n/* unz_global_info structure contain global data about the ZIPfile\n   These data comes from the end of central dir */\ntypedef struct unz_global_info_s\n{\n\tunsigned long number_entry;         /* total number of entries in the central dir on this disk */\n\tunsigned long size_comment;         /* size of the global comment of the zipfile */\n} unz_global_info;\n\n\n/* unz_file_info contain information about a file in the zipfile */\ntypedef struct unz_file_info_s\n{\n    unsigned long version;              /* version made by                 2 unsigned chars */\n    unsigned long version_needed;       /* version needed to extract       2 unsigned chars */\n    unsigned long flag;                 /* general purpose bit flag        2 unsigned chars */\n    unsigned long compression_method;   /* compression method              2 unsigned chars */\n    unsigned long dosDate;              /* last mod file date in Dos fmt   4 unsigned chars */\n    unsigned long crc;                  /* crc-32                          4 unsigned chars */\n    unsigned long compressed_size;      /* compressed size                 4 unsigned chars */ \n    unsigned long uncompressed_size;    /* uncompressed size               4 unsigned chars */ \n    unsigned long size_filename;        /* filename length                 2 unsigned chars */\n    unsigned long size_file_extra;      /* extra field length              2 unsigned chars */\n    unsigned long size_file_comment;    /* file comment length             2 unsigned chars */\n\n    unsigned long disk_num_start;       /* disk number start               2 unsigned chars */\n    unsigned long internal_fa;          /* internal file attributes        2 unsigned chars */\n    unsigned long external_fa;          /* external file attributes        4 unsigned chars */\n\n    tm_unz tmu_date;\n} unz_file_info;\n\n/* unz_file_info_interntal contain internal info about a file in zipfile*/\ntypedef struct unz_file_info_internal_s\n{\n    unsigned long offset_curfile;/* relative offset of static header 4 unsigned chars */\n} unz_file_info_internal;\n\ntypedef void* (*alloc_func) (void* opaque, unsigned int items, unsigned int size);\ntypedef void   (*free_func) (void* opaque, void* address);\n\nstruct internal_state;\n\ntypedef struct z_stream_s {\n    unsigned char    *next_in;  /* next input unsigned char */\n    unsigned int     avail_in;  /* number of unsigned chars available at next_in */\n    unsigned long    total_in;  /* total nb of input unsigned chars read so */\n\n    unsigned char    *next_out; /* next output unsigned char should be put there */\n    unsigned int     avail_out; /* remaining free space at next_out */\n    unsigned long    total_out; /* total nb of unsigned chars output so */\n\n    char     *msg;      /* last error message, NULL if no error */\n    struct internal_state *state; /* not visible by applications */\n\n    alloc_func zalloc;  /* used to allocate the internal state */\n    free_func  zfree;   /* used to free the internal state */\n    unsigned char*     opaque;  /* private data object passed to zalloc and zfree */\n\n    int     data_type;  /* best guess about the data type: ascii or binary */\n    unsigned long   adler;      /* adler32 value of the uncompressed data */\n    unsigned long   reserved;   /* reserved for future use */\n} z_stream;\n\ntypedef z_stream *z_streamp;\n\n\n/* file_in_zip_read_info_s contain internal information about a file in zipfile,\n    when reading and decompress it */\ntypedef struct\n{\n\tchar  *read_buffer;         /* internal buffer for compressed data */\n\tz_stream stream;            /* zLib stream structure for inflate */\n\n\tunsigned long pos_in_zipfile;       /* position in unsigned char on the zipfile, for fseek*/\n\tunsigned long stream_initialised;   /* flag set if stream structure is initialised*/\n\n\tunsigned long offset_local_extrafield;/* offset of the static extra field */\n\tunsigned int  size_local_extrafield;/* size of the static extra field */\n\tunsigned long pos_local_extrafield;   /* position in the static extra field in read*/\n\n\tunsigned long crc32;                /* crc32 of all data uncompressed */\n\tunsigned long crc32_wait;           /* crc32 we must obtain after decompress all */\n\tunsigned long rest_read_compressed; /* number of unsigned char to be decompressed */\n\tunsigned long rest_read_uncompressed;/*number of unsigned char to be obtained after decomp*/\n\tFILE* file;                 /* io structore of the zipfile */\n\tunsigned long compression_method;   /* compression method (0==store) */\n\tunsigned long byte_before_the_zipfile;/* unsigned char before the zipfile, (>0 for sfx)*/\n} file_in_zip_read_info_s;\n\n\n/* unz_s contain internal information about the zipfile\n*/\ntypedef struct\n{\n\tFILE* file;                 /* io structore of the zipfile */\n\tunz_global_info gi;       /* public global information */\n\tunsigned long byte_before_the_zipfile;/* unsigned char before the zipfile, (>0 for sfx)*/\n\tunsigned long num_file;             /* number of the current file in the zipfile*/\n\tunsigned long pos_in_central_dir;   /* pos of the current file in the central dir*/\n\tunsigned long current_file_ok;      /* flag about the usability of the current file*/\n\tunsigned long central_pos;          /* position of the beginning of the central dir*/\n\n\tunsigned long size_central_dir;     /* size of the central directory  */\n\tunsigned long offset_central_dir;   /* offset of start of central directory with\n\t\t\t\t\t\t\t\t   respect to the starting disk number */\n\n\tunz_file_info cur_file_info; /* public info about the current file in zip*/\n\tunz_file_info_internal cur_file_info_internal; /* private info about it*/\n    file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current\n\t                                    file if we are decompressing it */\n\tunsigned char*\ttmpFile;\n\tint\ttmpPos,tmpSize;\n} unz_s;\n\n#define UNZ_OK                                  (0)\n#define UNZ_END_OF_LIST_OF_FILE (-100)\n#define UNZ_ERRNO               (Z_ERRNO)\n#define UNZ_EOF                 (0)\n#define UNZ_PARAMERROR                  (-102)\n#define UNZ_BADZIPFILE                  (-103)\n#define UNZ_INTERNALERROR               (-104)\n#define UNZ_CRCERROR                    (-105)\n\n#define UNZ_CASESENSITIVE\t\t1\n#define UNZ_NOTCASESENSITIVE\t2\n#define UNZ_OSDEFAULTCASE\t\t0\n\nextern int unzStringFileNameCompare (const char* fileName1, const char* fileName2, int iCaseSensitivity);\n\n/*\n   Compare two filename (fileName1,fileName2).\n   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)\n   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi\n\t\t\t\t\t\t\t\tor strcasecmp)\n   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system\n\t(like 1 on Unix, 2 on Windows)\n*/\n\nextern unzFile unzOpen (const char *path);\nextern unzFile unzReOpen (const char* path, unzFile file);\n\n/*\n  Open a Zip file. path contain the full pathname (by example,\n     on a Windows NT computer \"c:\\\\zlib\\\\zlib111.zip\" or on an Unix computer\n\t \"zlib/zlib111.zip\".\n\t If the zipfile cannot be opened (file don't exist or in not valid), the\n\t   return value is NULL.\n     Else, the return value is a unzFile Handle, usable with other function\n\t   of this unzip package.\n*/\n\nextern int unzClose (unzFile file);\n\n/*\n  Close a ZipFile opened with unzipOpen.\n  If there is files inside the .Zip opened with unzOpenCurrentFile (see later),\n    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.\n  return UNZ_OK if there is no problem. */\n\nextern int unzGetGlobalInfo (unzFile file, unz_global_info *pglobal_info);\n\n/*\n  Write info about the ZipFile in the *pglobal_info structure.\n  No preparation of the structure is needed\n  return UNZ_OK if there is no problem. */\n\n\nextern int unzGetGlobalComment (unzFile file, char *szComment, unsigned long uSizeBuf);\n\n/*\n  Get the global comment string of the ZipFile, in the szComment buffer.\n  uSizeBuf is the size of the szComment buffer.\n  return the number of unsigned char copied or an error code <0\n*/\n\n\n/***************************************************************************/\n/* Unzip package allow you browse the directory of the zipfile */\n\nextern int unzGoToFirstFile (unzFile file);\n\n/*\n  Set the current file of the zipfile to the first file.\n  return UNZ_OK if there is no problem\n*/\n\nextern int unzGoToNextFile (unzFile file);\n\n/*\n  Set the current file of the zipfile to the next file.\n  return UNZ_OK if there is no problem\n  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.\n*/\n\nextern int unzGetCurrentFileInfoPosition (unzFile file, unsigned long *pos );\n\n/*\n  Get the position of the info of the current file in the zip.\n  return UNZ_OK if there is no problem\n*/\n\nextern int unzSetCurrentFileInfoPosition (unzFile file, unsigned long pos );\n\n/*\n  Set the position of the info of the current file in the zip.\n  return UNZ_OK if there is no problem\n*/\n\nextern int unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity);\n\n/*\n  Try locate the file szFileName in the zipfile.\n  For the iCaseSensitivity signification, see unzStringFileNameCompare\n\n  return value :\n  UNZ_OK if the file is found. It becomes the current file.\n  UNZ_END_OF_LIST_OF_FILE if the file is not found\n*/\n\n\nextern int unzGetCurrentFileInfo (unzFile file, unz_file_info *pfile_info, char *szFileName, unsigned long fileNameBufferSize, void *extraField, unsigned long extraFieldBufferSize, char *szComment, unsigned long commentBufferSize);\n\n/*\n  Get Info about the current file\n  if pfile_info!=NULL, the *pfile_info structure will contain somes info about\n\t    the current file\n  if szFileName!=NULL, the filemane string will be copied in szFileName\n\t\t\t(fileNameBufferSize is the size of the buffer)\n  if extraField!=NULL, the extra field information will be copied in extraField\n\t\t\t(extraFieldBufferSize is the size of the buffer).\n\t\t\tThis is the Central-header version of the extra field\n  if szComment!=NULL, the comment string of the file will be copied in szComment\n\t\t\t(commentBufferSize is the size of the buffer)\n*/\n\n/***************************************************************************/\n/* for reading the content of the current zipfile, you can open it, read data\n   from it, and close it (you can close it before reading all the file)\n   */\n\nextern int unzOpenCurrentFile (unzFile file);\n\n/*\n  Open for reading data the current file in the zipfile.\n  If there is no error, the return value is UNZ_OK.\n*/\n\nextern int unzCloseCurrentFile (unzFile file);\n\n/*\n  Close the file in zip opened with unzOpenCurrentFile\n  Return UNZ_CRCERROR if all the file was read but the CRC is not good\n*/\n\n\t\t\t\t\t\t\t\t\t\t\t\t\nextern int unzReadCurrentFile (unzFile file, void* buf, unsigned len);\n\n/*\n  Read unsigned chars from the current file (opened by unzOpenCurrentFile)\n  buf contain buffer where data must be copied\n  len the size of buf.\n\n  return the number of unsigned char copied if somes unsigned chars are copied\n  return 0 if the end of file was reached\n  return <0 with error code if there is an error\n    (UNZ_ERRNO for IO error, or zLib error for uncompress error)\n*/\n\nextern long unztell(unzFile file);\n\n/*\n  Give the current position in uncompressed data\n*/\n\nextern int unzeof (unzFile file);\n\n/*\n  return 1 if the end of file was reached, 0 elsewhere \n*/\n\nextern int unzGetLocalExtrafield (unzFile file, void* buf, unsigned len);\n\n/*\n  Read extra field from the current file (opened by unzOpenCurrentFile)\n  This is the local-header version of the extra field (sometimes, there is\n    more info in the local-header version than in the central-header)\n\n  if buf==NULL, it return the size of the local extra field\n\n  if buf!=NULL, len is the size of the buffer, the extra header is copied in\n\tbuf.\n  the return value is the number of unsigned chars copied in buf, or (if <0) \n\tthe error code\n*/\n"
  },
  {
    "path": "code/qcommon/vm.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// vm.c -- virtual machine\n\n/*\n\n\nintermix code and data\nsymbol table\n\na dll has one imported function: VM_SystemCall\nand one exported function: Perform\n\n\n*/\n\n#include \"vm_local.h\"\n\n\nvm_t\t*currentVM = NULL; // bk001212\nvm_t\t*lastVM    = NULL; // bk001212\nint\t\tvm_debugLevel;\n\n#define\tMAX_VM\t\t3\nvm_t\tvmTable[MAX_VM];\n\n\nvoid VM_VmInfo_f( void );\nvoid VM_VmProfile_f( void );\n\n\n// converts a VM pointer to a C pointer and\n// checks to make sure that the range is acceptable\nvoid\t*VM_VM2C( vmptr_t p, int length ) {\n\treturn (void *)p;\n}\n\nvoid VM_Debug( int level ) {\n\tvm_debugLevel = level;\n}\n\n/*\n==============\nVM_Init\n==============\n*/\nvoid VM_Init( void ) {\n\tCvar_Get( \"vm_cgame\", \"2\", CVAR_ARCHIVE );\t// !@# SHIP WITH SET TO 2\n\tCvar_Get( \"vm_game\", \"2\", CVAR_ARCHIVE );\t// !@# SHIP WITH SET TO 2\n\tCvar_Get( \"vm_ui\", \"2\", CVAR_ARCHIVE );\t\t// !@# SHIP WITH SET TO 2\n\n\tCmd_AddCommand (\"vmprofile\", VM_VmProfile_f );\n\tCmd_AddCommand (\"vminfo\", VM_VmInfo_f );\n\n\tCom_Memset( vmTable, 0, sizeof( vmTable ) );\n}\n\n\n/*\n===============\nVM_ValueToSymbol\n\nAssumes a program counter value\n===============\n*/\nconst char *VM_ValueToSymbol( vm_t *vm, int value ) {\n\tvmSymbol_t\t*sym;\n\tstatic char\t\ttext[MAX_TOKEN_CHARS];\n\n\tsym = vm->symbols;\n\tif ( !sym ) {\n\t\treturn \"NO SYMBOLS\";\n\t}\n\n\t// find the symbol\n\twhile ( sym->next && sym->next->symValue <= value ) {\n\t\tsym = sym->next;\n\t}\n\n\tif ( value == sym->symValue ) {\n\t\treturn sym->symName;\n\t}\n\n\tCom_sprintf( text, sizeof( text ), \"%s+%i\", sym->symName, value - sym->symValue );\n\n\treturn text;\n}\n\n/*\n===============\nVM_ValueToFunctionSymbol\n\nFor profiling, find the symbol behind this value\n===============\n*/\nvmSymbol_t *VM_ValueToFunctionSymbol( vm_t *vm, int value ) {\n\tvmSymbol_t\t*sym;\n\tstatic vmSymbol_t\tnullSym;\n\n\tsym = vm->symbols;\n\tif ( !sym ) {\n\t\treturn &nullSym;\n\t}\n\n\twhile ( sym->next && sym->next->symValue <= value ) {\n\t\tsym = sym->next;\n\t}\n\n\treturn sym;\n}\n\n\n/*\n===============\nVM_SymbolToValue\n===============\n*/\nint VM_SymbolToValue( vm_t *vm, const char *symbol ) {\n\tvmSymbol_t\t*sym;\n\n\tfor ( sym = vm->symbols ; sym ; sym = sym->next ) {\n\t\tif ( !strcmp( symbol, sym->symName ) ) {\n\t\t\treturn sym->symValue;\n\t\t}\n\t}\n\treturn 0;\n}\n\n\n/*\n=====================\nVM_SymbolForCompiledPointer\n=====================\n*/\nconst char *VM_SymbolForCompiledPointer( vm_t *vm, void *code ) {\n\tint\t\t\ti;\n\n\tif ( code < (void *)vm->codeBase ) {\n\t\treturn \"Before code block\";\n\t}\n\tif ( code >= (void *)(vm->codeBase + vm->codeLength) ) {\n\t\treturn \"After code block\";\n\t}\n\n\t// find which original instruction it is after\n\tfor ( i = 0 ; i < vm->codeLength ; i++ ) {\n\t\tif ( (void *)vm->instructionPointers[i] > code ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\ti--;\n\n\t// now look up the bytecode instruction pointer\n\treturn VM_ValueToSymbol( vm, i );\n}\n\n\n\n/*\n===============\nParseHex\n===============\n*/\nint\tParseHex( const char *text ) {\n\tint\t\tvalue;\n\tint\t\tc;\n\n\tvalue = 0;\n\twhile ( ( c = *text++ ) != 0 ) {\n\t\tif ( c >= '0' && c <= '9' ) {\n\t\t\tvalue = value * 16 + c - '0';\n\t\t\tcontinue;\n\t\t}\n\t\tif ( c >= 'a' && c <= 'f' ) {\n\t\t\tvalue = value * 16 + 10 + c - 'a';\n\t\t\tcontinue;\n\t\t}\n\t\tif ( c >= 'A' && c <= 'F' ) {\n\t\t\tvalue = value * 16 + 10 + c - 'A';\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\treturn value;\n}\n\n/*\n===============\nVM_LoadSymbols\n===============\n*/\nvoid VM_LoadSymbols( vm_t *vm ) {\n\tint\t\tlen;\n\tchar\t*mapfile, *text_p, *token;\n\tchar\tname[MAX_QPATH];\n\tchar\tsymbols[MAX_QPATH];\n\tvmSymbol_t\t**prev, *sym;\n\tint\t\tcount;\n\tint\t\tvalue;\n\tint\t\tchars;\n\tint\t\tsegment;\n\tint\t\tnumInstructions;\n\n\t// don't load symbols if not developer\n\tif ( !com_developer->integer ) {\n\t\treturn;\n\t}\n\n\tCOM_StripExtension( vm->name, name );\n\tCom_sprintf( symbols, sizeof( symbols ), \"vm/%s.map\", name );\n\tlen = FS_ReadFile( symbols, (void **)&mapfile );\n\tif ( !mapfile ) {\n\t\tCom_Printf( \"Couldn't load symbol file: %s\\n\", symbols );\n\t\treturn;\n\t}\n\n\tnumInstructions = vm->instructionPointersLength >> 2;\n\n\t// parse the symbols\n\ttext_p = mapfile;\n\tprev = &vm->symbols;\n\tcount = 0;\n\n\twhile ( 1 ) {\n\t\ttoken = COM_Parse( &text_p );\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tsegment = ParseHex( token );\n\t\tif ( segment ) {\n\t\t\tCOM_Parse( &text_p );\n\t\t\tCOM_Parse( &text_p );\n\t\t\tcontinue;\t\t// only load code segment values\n\t\t}\n\n\t\ttoken = COM_Parse( &text_p );\n\t\tif ( !token[0] ) {\n\t\t\tCom_Printf( \"WARNING: incomplete line at end of file\\n\" );\n\t\t\tbreak;\n\t\t}\n\t\tvalue = ParseHex( token );\n\n\t\ttoken = COM_Parse( &text_p );\n\t\tif ( !token[0] ) {\n\t\t\tCom_Printf( \"WARNING: incomplete line at end of file\\n\" );\n\t\t\tbreak;\n\t\t}\n\t\tchars = strlen( token );\n\t\tsym = Hunk_Alloc( sizeof( *sym ) + chars, h_high );\n\t\t*prev = sym;\n\t\tprev = &sym->next;\n\t\tsym->next = NULL;\n\n\t\t// convert value from an instruction number to a code offset\n\t\tif ( value >= 0 && value < numInstructions ) {\n\t\t\tvalue = vm->instructionPointers[value];\n\t\t}\n\n\t\tsym->symValue = value;\n\t\tQ_strncpyz( sym->symName, token, chars + 1 );\n\n\t\tcount++;\n\t}\n\n\tvm->numSymbols = count;\n\tCom_Printf( \"%i symbols parsed from %s\\n\", count, symbols );\n\tFS_FreeFile( mapfile );\n}\n\n/*\n============\nVM_DllSyscall\n\nDlls will call this directly\n\n rcg010206 The horror; the horror.\n\n  The syscall mechanism relies on stack manipulation to get it's args.\n   This is likely due to C's inability to pass \"...\" parameters to\n   a function in one clean chunk. On PowerPC Linux, these parameters\n   are not necessarily passed on the stack, so while (&arg[0] == arg)\n   is true, (&arg[1] == 2nd function parameter) is not necessarily\n   accurate, as arg's value might have been stored to the stack or\n   other piece of scratch memory to give it a valid address, but the\n   next parameter might still be sitting in a register.\n\n  Quake's syscall system also assumes that the stack grows downward,\n   and that any needed types can be squeezed, safely, into a signed int.\n\n  This hack below copies all needed values for an argument to a\n   array in memory, so that Quake can get the correct values. This can\n   also be used on systems where the stack grows upwards, as the\n   presumably standard and safe stdargs.h macros are used.\n\n  As for having enough space in a signed int for your datatypes, well,\n   it might be better to wait for DOOM 3 before you start porting.  :)\n\n  The original code, while probably still inherently dangerous, seems\n   to work well enough for the platforms it already works on. Rather\n   than add the performance hit for those platforms, the original code\n   is still in use there.\n\n  For speed, we just grab 15 arguments, and don't worry about exactly\n   how many the syscall actually needs; the extra is thrown away.\n \n============\n*/\nint QDECL VM_DllSyscall( int arg, ... ) {\n#if ((defined __linux__) && (defined __powerpc__))\n  // rcg010206 - see commentary above\n  int args[16];\n  int i;\n  va_list ap;\n  \n  args[0] = arg;\n  \n  va_start(ap, arg);\n  for (i = 1; i < sizeof (args) / sizeof (args[i]); i++)\n    args[i] = va_arg(ap, int);\n  va_end(ap);\n  \n  return currentVM->systemCall( args );\n#else // original id code\n\treturn currentVM->systemCall( &arg );\n#endif\n}\n\n/*\n=================\nVM_Restart\n\nReload the data, but leave everything else in place\nThis allows a server to do a map_restart without changing memory allocation\n=================\n*/\nvm_t *VM_Restart( vm_t *vm ) {\n\tvmHeader_t\t*header;\n\tint\t\t\tlength;\n\tint\t\t\tdataLength;\n\tint\t\t\ti;\n\tchar\t\tfilename[MAX_QPATH];\n\n\t// DLL's can't be restarted in place\n\tif ( vm->dllHandle ) {\n\t\tchar\tname[MAX_QPATH];\n\t    int\t\t\t(*systemCall)( int *parms );\n\t\t\n\t\tsystemCall = vm->systemCall;\t\n\t\tQ_strncpyz( name, vm->name, sizeof( name ) );\n\n\t\tVM_Free( vm );\n\n\t\tvm = VM_Create( name, systemCall, VMI_NATIVE );\n\t\treturn vm;\n\t}\n\n\t// load the image\n\tCom_Printf( \"VM_Restart()\\n\", filename );\n\tCom_sprintf( filename, sizeof(filename), \"vm/%s.qvm\", vm->name );\n\tCom_Printf( \"Loading vm file %s.\\n\", filename );\n\tlength = FS_ReadFile( filename, (void **)&header );\n\tif ( !header ) {\n\t\tCom_Error( ERR_DROP, \"VM_Restart failed.\\n\" );\n\t}\n\n\t// byte swap the header\n\tfor ( i = 0 ; i < sizeof( *header ) / 4 ; i++ ) {\n\t\t((int *)header)[i] = LittleLong( ((int *)header)[i] );\n\t}\n\n\t// validate\n\tif ( header->vmMagic != VM_MAGIC\n\t\t|| header->bssLength < 0 \n\t\t|| header->dataLength < 0 \n\t\t|| header->litLength < 0 \n\t\t|| header->codeLength <= 0 ) {\n\t\tVM_Free( vm );\n\t\tCom_Error( ERR_FATAL, \"%s has bad header\", filename );\n\t}\n\n\t// round up to next power of 2 so all data operations can\n\t// be mask protected\n\tdataLength = header->dataLength + header->litLength + header->bssLength;\n\tfor ( i = 0 ; dataLength > ( 1 << i ) ; i++ ) {\n\t}\n\tdataLength = 1 << i;\n\n\t// clear the data\n\tCom_Memset( vm->dataBase, 0, dataLength );\n\n\t// copy the intialized data\n\tCom_Memcpy( vm->dataBase, (byte *)header + header->dataOffset, header->dataLength + header->litLength );\n\n\t// byte swap the longs\n\tfor ( i = 0 ; i < header->dataLength ; i += 4 ) {\n\t\t*(int *)(vm->dataBase + i) = LittleLong( *(int *)(vm->dataBase + i ) );\n\t}\n\n\t// free the original file\n\tFS_FreeFile( header );\n\n\treturn vm;\n}\n\n/*\n================\nVM_Create\n\nIf image ends in .qvm it will be interpreted, otherwise\nit will attempt to load as a system dll\n================\n*/\n\n#define\tSTACK_SIZE\t0x20000\n\nvm_t *VM_Create( const char *module, int (*systemCalls)(int *), \n\t\t\t\tvmInterpret_t interpret ) {\n\tvm_t\t\t*vm;\n\tvmHeader_t\t*header;\n\tint\t\t\tlength;\n\tint\t\t\tdataLength;\n\tint\t\t\ti, remaining;\n\tchar\t\tfilename[MAX_QPATH];\n\n\tif ( !module || !module[0] || !systemCalls ) {\n\t\tCom_Error( ERR_FATAL, \"VM_Create: bad parms\" );\n\t}\n\n\tremaining = Hunk_MemoryRemaining();\n\n\t// see if we already have the VM\n\tfor ( i = 0 ; i < MAX_VM ; i++ ) {\n\t\tif (!Q_stricmp(vmTable[i].name, module)) {\n\t\t\tvm = &vmTable[i];\n\t\t\treturn vm;\n\t\t}\n\t}\n\n\t// find a free vm\n\tfor ( i = 0 ; i < MAX_VM ; i++ ) {\n\t\tif ( !vmTable[i].name[0] ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif ( i == MAX_VM ) {\n\t\tCom_Error( ERR_FATAL, \"VM_Create: no free vm_t\" );\n\t}\n\n\tvm = &vmTable[i];\n\n\tQ_strncpyz( vm->name, module, sizeof( vm->name ) );\n\tvm->systemCall = systemCalls;\n\n\t// never allow dll loading with a demo\n\tif ( interpret == VMI_NATIVE ) {\n\t\tif ( Cvar_VariableValue( \"fs_restrict\" ) ) {\n\t\t\tinterpret = VMI_COMPILED;\n\t\t}\n\t}\n\n\tif ( interpret == VMI_NATIVE ) {\n\t\t// try to load as a system dll\n\t\tCom_Printf( \"Loading dll file %s.\\n\", vm->name );\n\t\tvm->dllHandle = Sys_LoadDll( module, vm->fqpath , &vm->entryPoint, VM_DllSyscall );\n\t\tif ( vm->dllHandle ) {\n\t\t\treturn vm;\n\t\t}\n\n\t\tCom_Printf( \"Failed to load dll, looking for qvm.\\n\" );\n\t\tinterpret = VMI_COMPILED;\n\t}\n\n\t// load the image\n\tCom_sprintf( filename, sizeof(filename), \"vm/%s.qvm\", vm->name );\n\tCom_Printf( \"Loading vm file %s.\\n\", filename );\n\tlength = FS_ReadFile( filename, (void **)&header );\n\tif ( !header ) {\n\t\tCom_Printf( \"Failed.\\n\" );\n\t\tVM_Free( vm );\n\t\treturn NULL;\n\t}\n\n\t// byte swap the header\n\tfor ( i = 0 ; i < sizeof( *header ) / 4 ; i++ ) {\n\t\t((int *)header)[i] = LittleLong( ((int *)header)[i] );\n\t}\n\n\t// validate\n\tif ( header->vmMagic != VM_MAGIC\n\t\t|| header->bssLength < 0 \n\t\t|| header->dataLength < 0 \n\t\t|| header->litLength < 0 \n\t\t|| header->codeLength <= 0 ) {\n\t\tVM_Free( vm );\n\t\tCom_Error( ERR_FATAL, \"%s has bad header\", filename );\n\t}\n\n\t// round up to next power of 2 so all data operations can\n\t// be mask protected\n\tdataLength = header->dataLength + header->litLength + header->bssLength;\n\tfor ( i = 0 ; dataLength > ( 1 << i ) ; i++ ) {\n\t}\n\tdataLength = 1 << i;\n\n\t// allocate zero filled space for initialized and uninitialized data\n\tvm->dataBase = Hunk_Alloc( dataLength, h_high );\n\tvm->dataMask = dataLength - 1;\n\n\t// copy the intialized data\n\tCom_Memcpy( vm->dataBase, (byte *)header + header->dataOffset, header->dataLength + header->litLength );\n\n\t// byte swap the longs\n\tfor ( i = 0 ; i < header->dataLength ; i += 4 ) {\n\t\t*(int *)(vm->dataBase + i) = LittleLong( *(int *)(vm->dataBase + i ) );\n\t}\n\n\t// allocate space for the jump targets, which will be filled in by the compile/prep functions\n\tvm->instructionPointersLength = header->instructionCount * 4;\n\tvm->instructionPointers = Hunk_Alloc( vm->instructionPointersLength, h_high );\n\n\t// copy or compile the instructions\n\tvm->codeLength = header->codeLength;\n\n\tif ( interpret >= VMI_COMPILED ) {\n\t\tvm->compiled = qtrue;\n\t\tVM_Compile( vm, header );\n\t} else {\n\t\tvm->compiled = qfalse;\n\t\tVM_PrepareInterpreter( vm, header );\n\t}\n\n\t// free the original file\n\tFS_FreeFile( header );\n\n\t// load the map file\n\tVM_LoadSymbols( vm );\n\n\t// the stack is implicitly at the end of the image\n\tvm->programStack = vm->dataMask + 1;\n\tvm->stackBottom = vm->programStack - STACK_SIZE;\n\n\tCom_Printf(\"%s loaded in %d bytes on the hunk\\n\", module, remaining - Hunk_MemoryRemaining());\n\n\treturn vm;\n}\n\n/*\n==============\nVM_Free\n==============\n*/\nvoid VM_Free( vm_t *vm ) {\n\n\tif ( vm->dllHandle ) {\n\t\tSys_UnloadDll( vm->dllHandle );\n\t\tCom_Memset( vm, 0, sizeof( *vm ) );\n\t}\n#if 0\t// now automatically freed by hunk\n\tif ( vm->codeBase ) {\n\t\tZ_Free( vm->codeBase );\n\t}\n\tif ( vm->dataBase ) {\n\t\tZ_Free( vm->dataBase );\n\t}\n\tif ( vm->instructionPointers ) {\n\t\tZ_Free( vm->instructionPointers );\n\t}\n#endif\n\tCom_Memset( vm, 0, sizeof( *vm ) );\n\n\tcurrentVM = NULL;\n\tlastVM = NULL;\n}\n\nvoid VM_Clear(void) {\n\tint i;\n\tfor (i=0;i<MAX_VM; i++) {\n\t\tif ( vmTable[i].dllHandle ) {\n\t\t\tSys_UnloadDll( vmTable[i].dllHandle );\n\t\t}\n\t\tCom_Memset( &vmTable[i], 0, sizeof( vm_t ) );\n\t}\n\tcurrentVM = NULL;\n\tlastVM = NULL;\n}\n\nvoid *VM_ArgPtr( int intValue ) {\n\tif ( !intValue ) {\n\t\treturn NULL;\n\t}\n\t// bk001220 - currentVM is missing on reconnect\n\tif ( currentVM==NULL )\n\t  return NULL;\n\n\tif ( currentVM->entryPoint ) {\n\t\treturn (void *)(currentVM->dataBase + intValue);\n\t}\n\telse {\n\t\treturn (void *)(currentVM->dataBase + (intValue & currentVM->dataMask));\n\t}\n}\n\nvoid *VM_ExplicitArgPtr( vm_t *vm, int intValue ) {\n\tif ( !intValue ) {\n\t\treturn NULL;\n\t}\n\n\t// bk010124 - currentVM is missing on reconnect here as well?\n\tif ( currentVM==NULL )\n\t  return NULL;\n\n\t//\n\tif ( vm->entryPoint ) {\n\t\treturn (void *)(vm->dataBase + intValue);\n\t}\n\telse {\n\t\treturn (void *)(vm->dataBase + (intValue & vm->dataMask));\n\t}\n}\n\n\n/*\n==============\nVM_Call\n\n\nUpon a system call, the stack will look like:\n\nsp+32\tparm1\nsp+28\tparm0\nsp+24\treturn value\nsp+20\treturn address\nsp+16\tlocal1\nsp+14\tlocal0\nsp+12\targ1\nsp+8\targ0\nsp+4\treturn stack\nsp\t\treturn address\n\nAn interpreted function will immediately execute\nan OP_ENTER instruction, which will subtract space for\nlocals from sp\n==============\n*/\n#define\tMAX_STACK\t256\n#define\tSTACK_MASK\t(MAX_STACK-1)\n\nint\tQDECL VM_Call( vm_t *vm, int callnum, ... ) {\n\tvm_t\t*oldVM;\n\tint\t\tr;\n\tint i;\n\tint args[16];\n\tva_list ap;\n\n\n\tif ( !vm ) {\n\t\tCom_Error( ERR_FATAL, \"VM_Call with NULL vm\" );\n\t}\n\n\toldVM = currentVM;\n\tcurrentVM = vm;\n\tlastVM = vm;\n\n\tif ( vm_debugLevel ) {\n\t  Com_Printf( \"VM_Call( %i )\\n\", callnum );\n\t}\n\n\t// if we have a dll loaded, call it directly\n\tif ( vm->entryPoint ) {\n\t\t//rcg010207 -  see dissertation at top of VM_DllSyscall() in this file.\n\t\tva_start(ap, callnum);\n\t\tfor (i = 0; i < sizeof (args) / sizeof (args[i]); i++) {\n\t\t\targs[i] = va_arg(ap, int);\n\t\t}\n\t\tva_end(ap);\n\n\t\tr = vm->entryPoint( callnum,  args[0],  args[1],  args[2], args[3],\n                            args[4],  args[5],  args[6], args[7],\n                            args[8],  args[9], args[10], args[11],\n                            args[12], args[13], args[14], args[15]);\n\t} else if ( vm->compiled ) {\n\t\tr = VM_CallCompiled( vm, &callnum );\n\t} else {\n\t\tr = VM_CallInterpreted( vm, &callnum );\n\t}\n\n\tif ( oldVM != NULL ) // bk001220 - assert(currentVM!=NULL) for oldVM==NULL\n\t  currentVM = oldVM;\n\treturn r;\n}\n\n//=================================================================\n\nstatic int QDECL VM_ProfileSort( const void *a, const void *b ) {\n\tvmSymbol_t\t*sa, *sb;\n\n\tsa = *(vmSymbol_t **)a;\n\tsb = *(vmSymbol_t **)b;\n\n\tif ( sa->profileCount < sb->profileCount ) {\n\t\treturn -1;\n\t}\n\tif ( sa->profileCount > sb->profileCount ) {\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\n/*\n==============\nVM_VmProfile_f\n\n==============\n*/\nvoid VM_VmProfile_f( void ) {\n\tvm_t\t\t*vm;\n\tvmSymbol_t\t**sorted, *sym;\n\tint\t\t\ti;\n\tdouble\t\ttotal;\n\n\tif ( !lastVM ) {\n\t\treturn;\n\t}\n\n\tvm = lastVM;\n\n\tif ( !vm->numSymbols ) {\n\t\treturn;\n\t}\n\n\tsorted = Z_Malloc( vm->numSymbols * sizeof( *sorted ) );\n\tsorted[0] = vm->symbols;\n\ttotal = sorted[0]->profileCount;\n\tfor ( i = 1 ; i < vm->numSymbols ; i++ ) {\n\t\tsorted[i] = sorted[i-1]->next;\n\t\ttotal += sorted[i]->profileCount;\n\t}\n\n\tqsort( sorted, vm->numSymbols, sizeof( *sorted ), VM_ProfileSort );\n\n\tfor ( i = 0 ; i < vm->numSymbols ; i++ ) {\n\t\tint\t\tperc;\n\n\t\tsym = sorted[i];\n\n\t\tperc = 100 * (float) sym->profileCount / total;\n\t\tCom_Printf( \"%2i%% %9i %s\\n\", perc, sym->profileCount, sym->symName );\n\t\tsym->profileCount = 0;\n\t}\n\n\tCom_Printf(\"    %9.0f total\\n\", total );\n\n\tZ_Free( sorted );\n}\n\n/*\n==============\nVM_VmInfo_f\n\n==============\n*/\nvoid VM_VmInfo_f( void ) {\n\tvm_t\t*vm;\n\tint\t\ti;\n\n\tCom_Printf( \"Registered virtual machines:\\n\" );\n\tfor ( i = 0 ; i < MAX_VM ; i++ ) {\n\t\tvm = &vmTable[i];\n\t\tif ( !vm->name[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tCom_Printf( \"%s : \", vm->name );\n\t\tif ( vm->dllHandle ) {\n\t\t\tCom_Printf( \"native\\n\" );\n\t\t\tcontinue;\n\t\t}\n\t\tif ( vm->compiled ) {\n\t\t\tCom_Printf( \"compiled on load\\n\" );\n\t\t} else {\n\t\t\tCom_Printf( \"interpreted\\n\" );\n\t\t}\n\t\tCom_Printf( \"    code length : %7i\\n\", vm->codeLength );\n\t\tCom_Printf( \"    table length: %7i\\n\", vm->instructionPointersLength );\n\t\tCom_Printf( \"    data length : %7i\\n\", vm->dataMask + 1 );\n\t}\n}\n\n/*\n===============\nVM_LogSyscalls\n\nInsert calls to this while debugging the vm compiler\n===============\n*/\nvoid VM_LogSyscalls( int *args ) {\n\tstatic\tint\t\tcallnum;\n\tstatic\tFILE\t*f;\n\n\tif ( !f ) {\n\t\tf = fopen(\"syscalls.log\", \"w\" );\n\t}\n\tcallnum++;\n\tfprintf(f, \"%i: %i (%i) = %i %i %i %i\\n\", callnum, args - (int *)currentVM->dataBase,\n\t\targs[0], args[1], args[2], args[3], args[4] );\n}\n\n\n\n#ifdef oDLL_ONLY // bk010215 - for DLL_ONLY dedicated servers/builds w/o VM\nint\tVM_CallCompiled( vm_t *vm, int *args ) {\n  return(0); \n}\n\nvoid VM_Compile( vm_t *vm, vmHeader_t *header ) {}\n#endif // DLL_ONLY\n"
  },
  {
    "path": "code/qcommon/vm_interpreted.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"vm_local.h\"\n\n#ifdef DEBUG_VM // bk001204\nstatic char\t*opnames[256] = {\n\t\"OP_UNDEF\", \n\n\t\"OP_IGNORE\", \n\n\t\"OP_BREAK\",\n\n\t\"OP_ENTER\",\n\t\"OP_LEAVE\",\n\t\"OP_CALL\",\n\t\"OP_PUSH\",\n\t\"OP_POP\",\n\n\t\"OP_CONST\",\n\n\t\"OP_LOCAL\",\n\n\t\"OP_JUMP\",\n\n\t//-------------------\n\n\t\"OP_EQ\",\n\t\"OP_NE\",\n\n\t\"OP_LTI\",\n\t\"OP_LEI\",\n\t\"OP_GTI\",\n\t\"OP_GEI\",\n\n\t\"OP_LTU\",\n\t\"OP_LEU\",\n\t\"OP_GTU\",\n\t\"OP_GEU\",\n\n\t\"OP_EQF\",\n\t\"OP_NEF\",\n\n\t\"OP_LTF\",\n\t\"OP_LEF\",\n\t\"OP_GTF\",\n\t\"OP_GEF\",\n\n\t//-------------------\n\n\t\"OP_LOAD1\",\n\t\"OP_LOAD2\",\n\t\"OP_LOAD4\",\n\t\"OP_STORE1\",\n\t\"OP_STORE2\",\n\t\"OP_STORE4\",\n\t\"OP_ARG\",\n\n\t\"OP_BLOCK_COPY\",\n\n\t//-------------------\n\n\t\"OP_SEX8\",\n\t\"OP_SEX16\",\n\n\t\"OP_NEGI\",\n\t\"OP_ADD\",\n\t\"OP_SUB\",\n\t\"OP_DIVI\",\n\t\"OP_DIVU\",\n\t\"OP_MODI\",\n\t\"OP_MODU\",\n\t\"OP_MULI\",\n\t\"OP_MULU\",\n\n\t\"OP_BAND\",\n\t\"OP_BOR\",\n\t\"OP_BXOR\",\n\t\"OP_BCOM\",\n\n\t\"OP_LSH\",\n\t\"OP_RSHI\",\n\t\"OP_RSHU\",\n\n\t\"OP_NEGF\",\n\t\"OP_ADDF\",\n\t\"OP_SUBF\",\n\t\"OP_DIVF\",\n\t\"OP_MULF\",\n\n\t\"OP_CVIF\",\n\t\"OP_CVFI\"\n};\n#endif\n\n#if idppc\n    #if defined(__GNUC__)\n        static inline unsigned int loadWord(void *addr) {\n            unsigned int word;\n            \n            asm(\"lwbrx %0,0,%1\" : \"=r\" (word) : \"r\" (addr));\n            return word;\n        }\n    #else\n\t#define loadWord(addr) __lwbrx(addr,0)\n    #endif\n#else\n\t#define\tloadWord(addr) *((int *)addr)\n#endif\n\nchar *VM_Indent( vm_t *vm ) {\n\tstatic char\t*string = \"                                        \";\n\tif ( vm->callLevel > 20 ) {\n\t\treturn string;\n\t}\n\treturn string + 2 * ( 20 - vm->callLevel );\n}\n\nvoid VM_StackTrace( vm_t *vm, int programCounter, int programStack ) {\n\tint\t\tcount;\n\n\tcount = 0;\n\tdo {\n\t\tCom_Printf( \"%s\\n\", VM_ValueToSymbol( vm, programCounter ) );\n\t\tprogramStack =  *(int *)&vm->dataBase[programStack+4];\n\t\tprogramCounter = *(int *)&vm->dataBase[programStack];\n\t} while ( programCounter != -1 && ++count < 32 );\n\n}\n\n\n/*\n====================\nVM_PrepareInterpreter\n====================\n*/\nvoid VM_PrepareInterpreter( vm_t *vm, vmHeader_t *header ) {\n\tint\t\top;\n\tint\t\tpc;\n\tbyte\t*code;\n\tint\t\tinstruction;\n\tint\t\t*codeBase;\n\n\tvm->codeBase = Hunk_Alloc( vm->codeLength*4, h_high );\t\t\t// we're now int aligned\n//\tmemcpy( vm->codeBase, (byte *)header + header->codeOffset, vm->codeLength );\n\n\t// we don't need to translate the instructions, but we still need\n\t// to find each instructions starting point for jumps\n\tpc = 0;\n\tinstruction = 0;\n\tcode = (byte *)header + header->codeOffset;\n\tcodeBase = (int *)vm->codeBase;\n\n\twhile ( instruction < header->instructionCount ) {\n\t\tvm->instructionPointers[ instruction ] = pc;\n\t\tinstruction++;\n\n\t\top = code[ pc ];\n\t\tcodeBase[pc] = op;\n\t\tif ( pc > header->codeLength ) {\n\t\t\tCom_Error( ERR_FATAL, \"VM_PrepareInterpreter: pc > header->codeLength\" );\n\t\t}\n\n\t\tpc++;\n\n\t\t// these are the only opcodes that aren't a single byte\n\t\tswitch ( op ) {\n\t\tcase OP_ENTER:\n\t\tcase OP_CONST:\n\t\tcase OP_LOCAL:\n\t\tcase OP_LEAVE:\n\t\tcase OP_EQ:\n\t\tcase OP_NE:\n\t\tcase OP_LTI:\n\t\tcase OP_LEI:\n\t\tcase OP_GTI:\n\t\tcase OP_GEI:\n\t\tcase OP_LTU:\n\t\tcase OP_LEU:\n\t\tcase OP_GTU:\n\t\tcase OP_GEU:\n\t\tcase OP_EQF:\n\t\tcase OP_NEF:\n\t\tcase OP_LTF:\n\t\tcase OP_LEF:\n\t\tcase OP_GTF:\n\t\tcase OP_GEF:\n\t\tcase OP_BLOCK_COPY:\n\t\t\tcodeBase[pc+0] = loadWord(&code[pc]);\n\t\t\tpc += 4;\n\t\t\tbreak;\n\t\tcase OP_ARG:\n\t\t\tcodeBase[pc+0] = code[pc];\n\t\t\tpc += 1;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\n\t}\n\tpc = 0;\n\tinstruction = 0;\n\tcode = (byte *)header + header->codeOffset;\n\tcodeBase = (int *)vm->codeBase;\n\n\twhile ( instruction < header->instructionCount ) {\n\t\top = code[ pc ];\n\t\tinstruction++;\n\t\tpc++;\n\t\tswitch ( op ) {\n\t\tcase OP_ENTER:\n\t\tcase OP_CONST:\n\t\tcase OP_LOCAL:\n\t\tcase OP_LEAVE:\n\t\tcase OP_EQ:\n\t\tcase OP_NE:\n\t\tcase OP_LTI:\n\t\tcase OP_LEI:\n\t\tcase OP_GTI:\n\t\tcase OP_GEI:\n\t\tcase OP_LTU:\n\t\tcase OP_LEU:\n\t\tcase OP_GTU:\n\t\tcase OP_GEU:\n\t\tcase OP_EQF:\n\t\tcase OP_NEF:\n\t\tcase OP_LTF:\n\t\tcase OP_LEF:\n\t\tcase OP_GTF:\n\t\tcase OP_GEF:\n\t\tcase OP_BLOCK_COPY:\n\t\t\tswitch(op) {\n\t\t\t\tcase OP_EQ:\n\t\t\t\tcase OP_NE:\n\t\t\t\tcase OP_LTI:\n\t\t\t\tcase OP_LEI:\n\t\t\t\tcase OP_GTI:\n\t\t\t\tcase OP_GEI:\n\t\t\t\tcase OP_LTU:\n\t\t\t\tcase OP_LEU:\n\t\t\t\tcase OP_GTU:\n\t\t\t\tcase OP_GEU:\n\t\t\t\tcase OP_EQF:\n\t\t\t\tcase OP_NEF:\n\t\t\t\tcase OP_LTF:\n\t\t\t\tcase OP_LEF:\n\t\t\t\tcase OP_GTF:\n\t\t\t\tcase OP_GEF:\n\t\t\t\tcodeBase[pc] = vm->instructionPointers[codeBase[pc]];\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tpc += 4;\n\t\t\tbreak;\n\t\tcase OP_ARG:\n\t\t\tpc += 1;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\n\t}\n}\n\n/*\n==============\nVM_Call\n\n\nUpon a system call, the stack will look like:\n\nsp+32\tparm1\nsp+28\tparm0\nsp+24\treturn stack\nsp+20\treturn address\nsp+16\tlocal1\nsp+14\tlocal0\nsp+12\targ1\nsp+8\targ0\nsp+4\treturn stack\nsp\t\treturn address\n\nAn interpreted function will immediately execute\nan OP_ENTER instruction, which will subtract space for\nlocals from sp\n==============\n*/\n#define\tMAX_STACK\t256\n#define\tSTACK_MASK\t(MAX_STACK-1)\n//#define\tDEBUG_VM\n\n#define\tDEBUGSTR va(\"%s%i\", VM_Indent(vm), opStack-stack )\n\nint\tVM_CallInterpreted( vm_t *vm, int *args ) {\n\tint\t\tstack[MAX_STACK];\n\tint\t\t*opStack;\n\tint\t\tprogramCounter;\n\tint\t\tprogramStack;\n\tint\t\tstackOnEntry;\n\tbyte\t*image;\n\tint\t\t*codeImage;\n\tint\t\tv1;\n\tint\t\tdataMask;\n#ifdef DEBUG_VM\n\tvmSymbol_t\t*profileSymbol;\n#endif\n\n\t// interpret the code\n\tvm->currentlyInterpreting = qtrue;\n\n\t// we might be called recursively, so this might not be the very top\n\tprogramStack = stackOnEntry = vm->programStack;\n\n#ifdef DEBUG_VM\n\tprofileSymbol = VM_ValueToFunctionSymbol( vm, 0 );\n\t// uncomment this for debugging breakpoints\n\tvm->breakFunction = 0;\n#endif\n\t// set up the stack frame \n\n\timage = vm->dataBase;\n\tcodeImage = (int *)vm->codeBase;\n\tdataMask = vm->dataMask;\n\t\n\t// leave a free spot at start of stack so\n\t// that as long as opStack is valid, opStack-1 will\n\t// not corrupt anything\n\topStack = stack;\n\tprogramCounter = 0;\n\n\tprogramStack -= 48;\n\n\t*(int *)&image[ programStack + 44] = args[9];\n\t*(int *)&image[ programStack + 40] = args[8];\n\t*(int *)&image[ programStack + 36] = args[7];\n\t*(int *)&image[ programStack + 32] = args[6];\n\t*(int *)&image[ programStack + 28] = args[5];\n\t*(int *)&image[ programStack + 24] = args[4];\n\t*(int *)&image[ programStack + 20] = args[3];\n\t*(int *)&image[ programStack + 16] = args[2];\n\t*(int *)&image[ programStack + 12] = args[1];\n\t*(int *)&image[ programStack + 8 ] = args[0];\n\t*(int *)&image[ programStack + 4 ] = 0;\t// return stack\n\t*(int *)&image[ programStack ] = -1;\t// will terminate the loop on return\n\n\tvm->callLevel = 0;\n\t\n\tVM_Debug(0);\n\n//\tvm_debugLevel=2;\n\t// main interpreter loop, will exit when a LEAVE instruction\n\t// grabs the -1 program counter\n\n#define r2 codeImage[programCounter]\n\n\twhile ( 1 ) {\n\t\tint\t\topcode,\tr0, r1;\n//\t\tunsigned int\tr2;\n\nnextInstruction:\n\t\tr0 = ((int *)opStack)[0];\n\t\tr1 = ((int *)opStack)[-1];\nnextInstruction2:\n\t\topcode = codeImage[ programCounter++ ];\n#ifdef DEBUG_VM\n\t\tif ( (unsigned)programCounter > vm->codeLength ) {\n\t\t\tCom_Error( ERR_DROP, \"VM pc out of range\" );\n\t\t}\n\n\t\tif ( opStack < stack ) {\n\t\t\tCom_Error( ERR_DROP, \"VM opStack underflow\" );\n\t\t}\n\t\tif ( opStack >= stack+MAX_STACK ) {\n\t\t\tCom_Error( ERR_DROP, \"VM opStack overflow\" );\n\t\t}\n\n\t\tif ( programStack <= vm->stackBottom ) {\n\t\t\tCom_Error( ERR_DROP, \"VM stack overflow\" );\n\t\t}\n\n\t\tif ( programStack & 3 ) {\n\t\t\tCom_Error( ERR_DROP, \"VM program stack misaligned\" );\n\t\t}\n\n\t\tif ( vm_debugLevel > 1 ) {\n\t\t\tCom_Printf( \"%s %s\\n\", DEBUGSTR, opnames[opcode] );\n\t\t}\n\t\tprofileSymbol->profileCount++;\n#endif\n\n\t\tswitch ( opcode ) {\n#ifdef DEBUG_VM\n\t\tdefault:\n\t\t\tCom_Error( ERR_DROP, \"Bad VM instruction\" );  // this should be scanned on load!\n#endif\n\t\tcase OP_BREAK:\n\t\t\tvm->breakCount++;\n\t\t\tgoto nextInstruction2;\n\t\tcase OP_CONST:\n\t\t\topStack++;\n\t\t\tr1 = r0;\n\t\t\tr0 = *opStack = r2;\n\t\t\t\n\t\t\tprogramCounter += 4;\n\t\t\tgoto nextInstruction2;\n\t\tcase OP_LOCAL:\n\t\t\topStack++;\n\t\t\tr1 = r0;\n\t\t\tr0 = *opStack = r2+programStack;\n\n\t\t\tprogramCounter += 4;\n\t\t\tgoto nextInstruction2;\n\n\t\tcase OP_LOAD4:\n#ifdef DEBUG_VM\n\t\t\tif ( *opStack & 3 ) {\n\t\t\t\tCom_Error( ERR_DROP, \"OP_LOAD4 misaligned\" );\n\t\t\t}\n#endif\n\t\t\tr0 = *opStack = *(int *)&image[ r0&dataMask ];\n\t\t\tgoto nextInstruction2;\n\t\tcase OP_LOAD2:\n\t\t\tr0 = *opStack = *(unsigned short *)&image[ r0&dataMask ];\n\t\t\tgoto nextInstruction2;\n\t\tcase OP_LOAD1:\n\t\t\tr0 = *opStack = image[ r0&dataMask ];\n\t\t\tgoto nextInstruction2;\n\n\t\tcase OP_STORE4:\n\t\t\t*(int *)&image[ r1&(dataMask & ~3) ] = r0;\n\t\t\topStack -= 2;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_STORE2:\n\t\t\t*(short *)&image[ r1&(dataMask & ~1) ] = r0;\n\t\t\topStack -= 2;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_STORE1:\n\t\t\timage[ r1&dataMask ] = r0;\n\t\t\topStack -= 2;\n\t\t\tgoto nextInstruction;\n\n\t\tcase OP_ARG:\n\t\t\t// single byte offset from programStack\n\t\t\t*(int *)&image[ codeImage[programCounter] + programStack ] = r0;\n\t\t\topStack--;\n\t\t\tprogramCounter += 1;\n\t\t\tgoto nextInstruction;\n\n\t\tcase OP_BLOCK_COPY:\n\t\t\t{\n\t\t\t\tint\t\t*src, *dest;\n\t\t\t\tint\t\ti, count, srci, desti;\n\n\t\t\t\tcount = r2;\n\t\t\t\t// MrE: copy range check\n\t\t\t\tsrci = r0 & dataMask;\n\t\t\t\tdesti = r1 & dataMask;\n\t\t\t\tcount = ((srci + count) & dataMask) - srci;\n\t\t\t\tcount = ((desti + count) & dataMask) - desti;\n\n\t\t\t\tsrc = (int *)&image[ r0&dataMask ];\n\t\t\t\tdest = (int *)&image[ r1&dataMask ];\n\t\t\t\tif ( ( (int)src | (int)dest | count ) & 3 ) {\n\t\t\t\t\tCom_Error( ERR_DROP, \"OP_BLOCK_COPY not dword aligned\" );\n\t\t\t\t}\n\t\t\t\tcount >>= 2;\n\t\t\t\tfor ( i = count-1 ; i>= 0 ; i-- ) {\n\t\t\t\t\tdest[i] = src[i];\n\t\t\t\t}\n\t\t\t\tprogramCounter += 4;\n\t\t\t\topStack -= 2;\n\t\t\t}\n\t\t\tgoto nextInstruction;\n\n\t\tcase OP_CALL:\n\t\t\t// save current program counter\n\t\t\t*(int *)&image[ programStack ] = programCounter;\n\t\t\t\n\t\t\t// jump to the location on the stack\n\t\t\tprogramCounter = r0;\n\t\t\topStack--;\n\t\t\tif ( programCounter < 0 ) {\n\t\t\t\t// system call\n\t\t\t\tint\t\tr;\n\t\t\t\tint\t\ttemp;\n#ifdef DEBUG_VM\n\t\t\t\tint\t\tstomped;\n\n\t\t\t\tif ( vm_debugLevel ) {\n\t\t\t\t\tCom_Printf( \"%s---> systemcall(%i)\\n\", DEBUGSTR, -1 - programCounter );\n\t\t\t\t}\n#endif\n\t\t\t\t// save the stack to allow recursive VM entry\n\t\t\t\ttemp = vm->callLevel;\n\t\t\t\tvm->programStack = programStack - 4;\n#ifdef DEBUG_VM\n\t\t\t\tstomped = *(int *)&image[ programStack + 4 ];\n#endif\n\t\t\t\t*(int *)&image[ programStack + 4 ] = -1 - programCounter;\n\n//VM_LogSyscalls( (int *)&image[ programStack + 4 ] );\n\t\t\t\tr = vm->systemCall( (int *)&image[ programStack + 4 ] );\n\n#ifdef DEBUG_VM\n\t\t\t\t// this is just our stack frame pointer, only needed\n\t\t\t\t// for debugging\n\t\t\t\t*(int *)&image[ programStack + 4 ] = stomped;\n#endif\n\n\t\t\t\t// save return value\n\t\t\t\topStack++;\n\t\t\t\t*opStack = r;\n\t\t\t\tprogramCounter = *(int *)&image[ programStack ];\n\t\t\t\tvm->callLevel = temp;\n#ifdef DEBUG_VM\n\t\t\t\tif ( vm_debugLevel ) {\n\t\t\t\t\tCom_Printf( \"%s<--- %s\\n\", DEBUGSTR, VM_ValueToSymbol( vm, programCounter ) );\n\t\t\t\t}\n#endif\n\t\t\t} else {\n\t\t\t\tprogramCounter = vm->instructionPointers[ programCounter ];\n\t\t\t}\n\t\t\tgoto nextInstruction;\n\n\t\t// push and pop are only needed for discarded or bad function return values\n\t\tcase OP_PUSH:\n\t\t\topStack++;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_POP:\n\t\t\topStack--;\n\t\t\tgoto nextInstruction;\n\n\t\tcase OP_ENTER:\n#ifdef DEBUG_VM\n\t\t\tprofileSymbol = VM_ValueToFunctionSymbol( vm, programCounter );\n#endif\n\t\t\t// get size of stack frame\n\t\t\tv1 = r2;\n\n\t\t\tprogramCounter += 4;\n\t\t\tprogramStack -= v1;\n#ifdef DEBUG_VM\n\t\t\t// save old stack frame for debugging traces\n\t\t\t*(int *)&image[programStack+4] = programStack + v1;\n\t\t\tif ( vm_debugLevel ) {\n\t\t\t\tCom_Printf( \"%s---> %s\\n\", DEBUGSTR, VM_ValueToSymbol( vm, programCounter - 5 ) );\n\t\t\t\tif ( vm->breakFunction && programCounter - 5 == vm->breakFunction ) {\n\t\t\t\t\t// this is to allow setting breakpoints here in the debugger\n\t\t\t\t\tvm->breakCount++;\n//\t\t\t\t\tvm_debugLevel = 2;\n//\t\t\t\t\tVM_StackTrace( vm, programCounter, programStack );\n\t\t\t\t}\n\t\t\t\tvm->callLevel++;\n\t\t\t}\n#endif\n\t\t\tgoto nextInstruction;\n\t\tcase OP_LEAVE:\n\t\t\t// remove our stack frame\n\t\t\tv1 = r2;\n\n\t\t\tprogramStack += v1;\n\n\t\t\t// grab the saved program counter\n\t\t\tprogramCounter = *(int *)&image[ programStack ];\n#ifdef DEBUG_VM\n\t\t\tprofileSymbol = VM_ValueToFunctionSymbol( vm, programCounter );\n\t\t\tif ( vm_debugLevel ) {\n\t\t\t\tvm->callLevel--;\n\t\t\t\tCom_Printf( \"%s<--- %s\\n\", DEBUGSTR, VM_ValueToSymbol( vm, programCounter ) );\n\t\t\t}\n#endif\n\t\t\t// check for leaving the VM\n\t\t\tif ( programCounter == -1 ) {\n\t\t\t\tgoto done;\n\t\t\t}\n\t\t\tgoto nextInstruction;\n\n\t\t/*\n\t\t===================================================================\n\t\tBRANCHES\n\t\t===================================================================\n\t\t*/\n\n\t\tcase OP_JUMP:\n\t\t\tprogramCounter = r0;\n\t\t\tprogramCounter = vm->instructionPointers[ programCounter ];\n\t\t\topStack--;\n\t\t\tgoto nextInstruction;\n\n\t\tcase OP_EQ:\n\t\t\topStack -= 2;\n\t\t\tif ( r1 == r0 ) {\n\t\t\t\tprogramCounter = r2;\t//vm->instructionPointers[r2];\n\t\t\t\tgoto nextInstruction;\n\t\t\t} else {\n\t\t\t\tprogramCounter += 4;\n\t\t\t\tgoto nextInstruction;\n\t\t\t}\n\n\t\tcase OP_NE:\n\t\t\topStack -= 2;\n\t\t\tif ( r1 != r0 ) {\n\t\t\t\tprogramCounter = r2;\t//vm->instructionPointers[r2];\n\t\t\t\tgoto nextInstruction;\n\t\t\t} else {\n\t\t\t\tprogramCounter += 4;\n\t\t\t\tgoto nextInstruction;\n\t\t\t}\n\n\t\tcase OP_LTI:\n\t\t\topStack -= 2;\n\t\t\tif ( r1 < r0 ) {\n\t\t\t\tprogramCounter = r2;\t//vm->instructionPointers[r2];\n\t\t\t\tgoto nextInstruction;\n\t\t\t} else {\n\t\t\t\tprogramCounter += 4;\n\t\t\t\tgoto nextInstruction;\n\t\t\t}\n\n\t\tcase OP_LEI:\n\t\t\topStack -= 2;\n\t\t\tif ( r1 <= r0 ) {\n\t\t\t\tprogramCounter = r2;\t//vm->instructionPointers[r2];\n\t\t\t\tgoto nextInstruction;\n\t\t\t} else {\n\t\t\t\tprogramCounter += 4;\n\t\t\t\tgoto nextInstruction;\n\t\t\t}\n\n\t\tcase OP_GTI:\n\t\t\topStack -= 2;\n\t\t\tif ( r1 > r0 ) {\n\t\t\t\tprogramCounter = r2;\t//vm->instructionPointers[r2];\n\t\t\t\tgoto nextInstruction;\n\t\t\t} else {\n\t\t\t\tprogramCounter += 4;\n\t\t\t\tgoto nextInstruction;\n\t\t\t}\n\n\t\tcase OP_GEI:\n\t\t\topStack -= 2;\n\t\t\tif ( r1 >= r0 ) {\n\t\t\t\tprogramCounter = r2;\t//vm->instructionPointers[r2];\n\t\t\t\tgoto nextInstruction;\n\t\t\t} else {\n\t\t\t\tprogramCounter += 4;\n\t\t\t\tgoto nextInstruction;\n\t\t\t}\n\n\t\tcase OP_LTU:\n\t\t\topStack -= 2;\n\t\t\tif ( ((unsigned)r1) < ((unsigned)r0) ) {\n\t\t\t\tprogramCounter = r2;\t//vm->instructionPointers[r2];\n\t\t\t\tgoto nextInstruction;\n\t\t\t} else {\n\t\t\t\tprogramCounter += 4;\n\t\t\t\tgoto nextInstruction;\n\t\t\t}\n\n\t\tcase OP_LEU:\n\t\t\topStack -= 2;\n\t\t\tif ( ((unsigned)r1) <= ((unsigned)r0) ) {\n\t\t\t\tprogramCounter = r2;\t//vm->instructionPointers[r2];\n\t\t\t\tgoto nextInstruction;\n\t\t\t} else {\n\t\t\t\tprogramCounter += 4;\n\t\t\t\tgoto nextInstruction;\n\t\t\t}\n\n\t\tcase OP_GTU:\n\t\t\topStack -= 2;\n\t\t\tif ( ((unsigned)r1) > ((unsigned)r0) ) {\n\t\t\t\tprogramCounter = r2;\t//vm->instructionPointers[r2];\n\t\t\t\tgoto nextInstruction;\n\t\t\t} else {\n\t\t\t\tprogramCounter += 4;\n\t\t\t\tgoto nextInstruction;\n\t\t\t}\n\n\t\tcase OP_GEU:\n\t\t\topStack -= 2;\n\t\t\tif ( ((unsigned)r1) >= ((unsigned)r0) ) {\n\t\t\t\tprogramCounter = r2;\t//vm->instructionPointers[r2];\n\t\t\t\tgoto nextInstruction;\n\t\t\t} else {\n\t\t\t\tprogramCounter += 4;\n\t\t\t\tgoto nextInstruction;\n\t\t\t}\n\n\t\tcase OP_EQF:\n\t\t\tif ( ((float *)opStack)[-1] == *(float *)opStack ) {\n\t\t\t\tprogramCounter = r2;\t//vm->instructionPointers[r2];\n\t\t\t\topStack -= 2;\n\t\t\t\tgoto nextInstruction;\n\t\t\t} else {\n\t\t\t\tprogramCounter += 4;\n\t\t\t\topStack -= 2;\n\t\t\t\tgoto nextInstruction;\n\t\t\t}\n\n\t\tcase OP_NEF:\n\t\t\tif ( ((float *)opStack)[-1] != *(float *)opStack ) {\n\t\t\t\tprogramCounter = r2;\t//vm->instructionPointers[r2];\n\t\t\t\topStack -= 2;\n\t\t\t\tgoto nextInstruction;\n\t\t\t} else {\n\t\t\t\tprogramCounter += 4;\n\t\t\t\topStack -= 2;\n\t\t\t\tgoto nextInstruction;\n\t\t\t}\n\n\t\tcase OP_LTF:\n\t\t\tif ( ((float *)opStack)[-1] < *(float *)opStack ) {\n\t\t\t\tprogramCounter = r2;\t//vm->instructionPointers[r2];\n\t\t\t\topStack -= 2;\n\t\t\t\tgoto nextInstruction;\n\t\t\t} else {\n\t\t\t\tprogramCounter += 4;\n\t\t\t\topStack -= 2;\n\t\t\t\tgoto nextInstruction;\n\t\t\t}\n\n\t\tcase OP_LEF:\n\t\t\tif ( ((float *)opStack)[-1] <= *(float *)opStack ) {\n\t\t\t\tprogramCounter = r2;\t//vm->instructionPointers[r2];\n\t\t\t\topStack -= 2;\n\t\t\t\tgoto nextInstruction;\n\t\t\t} else {\n\t\t\t\tprogramCounter += 4;\n\t\t\t\topStack -= 2;\n\t\t\t\tgoto nextInstruction;\n\t\t\t}\n\n\t\tcase OP_GTF:\n\t\t\tif ( ((float *)opStack)[-1] > *(float *)opStack ) {\n\t\t\t\tprogramCounter = r2;\t//vm->instructionPointers[r2];\n\t\t\t\topStack -= 2;\n\t\t\t\tgoto nextInstruction;\n\t\t\t} else {\n\t\t\t\tprogramCounter += 4;\n\t\t\t\topStack -= 2;\n\t\t\t\tgoto nextInstruction;\n\t\t\t}\n\n\t\tcase OP_GEF:\n\t\t\tif ( ((float *)opStack)[-1] >= *(float *)opStack ) {\n\t\t\t\tprogramCounter = r2;\t//vm->instructionPointers[r2];\n\t\t\t\topStack -= 2;\n\t\t\t\tgoto nextInstruction;\n\t\t\t} else {\n\t\t\t\tprogramCounter += 4;\n\t\t\t\topStack -= 2;\n\t\t\t\tgoto nextInstruction;\n\t\t\t}\n\n\n\t\t//===================================================================\n\n\t\tcase OP_NEGI:\n\t\t\t*opStack = -r0;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_ADD:\n\t\t\topStack[-1] = r1 + r0;\n\t\t\topStack--;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_SUB:\n\t\t\topStack[-1] = r1 - r0;\n\t\t\topStack--;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_DIVI:\n\t\t\topStack[-1] = r1 / r0;\n\t\t\topStack--;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_DIVU:\n\t\t\topStack[-1] = ((unsigned)r1) / ((unsigned)r0);\n\t\t\topStack--;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_MODI:\n\t\t\topStack[-1] = r1 % r0;\n\t\t\topStack--;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_MODU:\n\t\t\topStack[-1] = ((unsigned)r1) % (unsigned)r0;\n\t\t\topStack--;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_MULI:\n\t\t\topStack[-1] = r1 * r0;\n\t\t\topStack--;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_MULU:\n\t\t\topStack[-1] = ((unsigned)r1) * ((unsigned)r0);\n\t\t\topStack--;\n\t\t\tgoto nextInstruction;\n\n\t\tcase OP_BAND:\n\t\t\topStack[-1] = ((unsigned)r1) & ((unsigned)r0);\n\t\t\topStack--;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_BOR:\n\t\t\topStack[-1] = ((unsigned)r1) | ((unsigned)r0);\n\t\t\topStack--;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_BXOR:\n\t\t\topStack[-1] = ((unsigned)r1) ^ ((unsigned)r0);\n\t\t\topStack--;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_BCOM:\n\t\t\topStack[-1] = ~ ((unsigned)r0);\n\t\t\tgoto nextInstruction;\n\n\t\tcase OP_LSH:\n\t\t\topStack[-1] = r1 << r0;\n\t\t\topStack--;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_RSHI:\n\t\t\topStack[-1] = r1 >> r0;\n\t\t\topStack--;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_RSHU:\n\t\t\topStack[-1] = ((unsigned)r1) >> r0;\n\t\t\topStack--;\n\t\t\tgoto nextInstruction;\n\n\t\tcase OP_NEGF:\n\t\t\t*(float *)opStack =  -*(float *)opStack;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_ADDF:\n\t\t\t*(float *)(opStack-1) = *(float *)(opStack-1) + *(float *)opStack;\n\t\t\topStack--;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_SUBF:\n\t\t\t*(float *)(opStack-1) = *(float *)(opStack-1) - *(float *)opStack;\n\t\t\topStack--;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_DIVF:\n\t\t\t*(float *)(opStack-1) = *(float *)(opStack-1) / *(float *)opStack;\n\t\t\topStack--;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_MULF:\n\t\t\t*(float *)(opStack-1) = *(float *)(opStack-1) * *(float *)opStack;\n\t\t\topStack--;\n\t\t\tgoto nextInstruction;\n\n\t\tcase OP_CVIF:\n\t\t\t*(float *)opStack =  (float)*opStack;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_CVFI:\n\t\t\t*opStack = (int) *(float *)opStack;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_SEX8:\n\t\t\t*opStack = (signed char)*opStack;\n\t\t\tgoto nextInstruction;\n\t\tcase OP_SEX16:\n\t\t\t*opStack = (short)*opStack;\n\t\t\tgoto nextInstruction;\n\t\t}\n\t}\n\ndone:\n\tvm->currentlyInterpreting = qfalse;\n\n\tif ( opStack != &stack[1] ) {\n\t\tCom_Error( ERR_DROP, \"Interpreter error: opStack = %i\", opStack - stack );\n\t}\n\n\tvm->programStack = stackOnEntry;\n\n\t// return the result\n\treturn *opStack;\n}\n"
  },
  {
    "path": "code/qcommon/vm_local.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"../game/q_shared.h\"\n#include \"qcommon.h\"\n\ntypedef enum {\n\tOP_UNDEF, \n\n\tOP_IGNORE, \n\n\tOP_BREAK,\n\n\tOP_ENTER,\n\tOP_LEAVE,\n\tOP_CALL,\n\tOP_PUSH,\n\tOP_POP,\n\n\tOP_CONST,\n\tOP_LOCAL,\n\n\tOP_JUMP,\n\n\t//-------------------\n\n\tOP_EQ,\n\tOP_NE,\n\n\tOP_LTI,\n\tOP_LEI,\n\tOP_GTI,\n\tOP_GEI,\n\n\tOP_LTU,\n\tOP_LEU,\n\tOP_GTU,\n\tOP_GEU,\n\n\tOP_EQF,\n\tOP_NEF,\n\n\tOP_LTF,\n\tOP_LEF,\n\tOP_GTF,\n\tOP_GEF,\n\n\t//-------------------\n\n\tOP_LOAD1,\n\tOP_LOAD2,\n\tOP_LOAD4,\n\tOP_STORE1,\n\tOP_STORE2,\n\tOP_STORE4,\t\t\t\t// *(stack[top-1]) = stack[top]\n\tOP_ARG,\n\n\tOP_BLOCK_COPY,\n\n\t//-------------------\n\n\tOP_SEX8,\n\tOP_SEX16,\n\n\tOP_NEGI,\n\tOP_ADD,\n\tOP_SUB,\n\tOP_DIVI,\n\tOP_DIVU,\n\tOP_MODI,\n\tOP_MODU,\n\tOP_MULI,\n\tOP_MULU,\n\n\tOP_BAND,\n\tOP_BOR,\n\tOP_BXOR,\n\tOP_BCOM,\n\n\tOP_LSH,\n\tOP_RSHI,\n\tOP_RSHU,\n\n\tOP_NEGF,\n\tOP_ADDF,\n\tOP_SUBF,\n\tOP_DIVF,\n\tOP_MULF,\n\n\tOP_CVIF,\n\tOP_CVFI\n} opcode_t;\n\n\n\ntypedef int\tvmptr_t;\n\ntypedef struct vmSymbol_s {\n\tstruct vmSymbol_s\t*next;\n\tint\t\tsymValue;\n\tint\t\tprofileCount;\n\tchar\tsymName[1];\t\t// variable sized\n} vmSymbol_t;\n\n#define\tVM_OFFSET_PROGRAM_STACK\t\t0\n#define\tVM_OFFSET_SYSTEM_CALL\t\t4\n\nstruct vm_s {\n    // DO NOT MOVE OR CHANGE THESE WITHOUT CHANGING THE VM_OFFSET_* DEFINES\n    // USED BY THE ASM CODE\n    int\t\t\tprogramStack;\t\t// the vm may be recursively entered\n    int\t\t\t(*systemCall)( int *parms );\n\n\t//------------------------------------\n   \n    char\t\tname[MAX_QPATH];\n\n\t// for dynamic linked modules\n\tvoid\t\t*dllHandle;\n\tint\t\t\t(QDECL *entryPoint)( int callNum, ... );\n\n\t// for interpreted modules\n\tqboolean\tcurrentlyInterpreting;\n\n\tqboolean\tcompiled;\n\tbyte\t\t*codeBase;\n\tint\t\t\tcodeLength;\n\n\tint\t\t\t*instructionPointers;\n\tint\t\t\tinstructionPointersLength;\n\n\tbyte\t\t*dataBase;\n\tint\t\t\tdataMask;\n\n\tint\t\t\tstackBottom;\t\t// if programStack < stackBottom, error\n\n\tint\t\t\tnumSymbols;\n\tstruct vmSymbol_s\t*symbols;\n\n\tint\t\t\tcallLevel;\t\t\t// for debug indenting\n\tint\t\t\tbreakFunction;\t\t// increment breakCount on function entry to this\n\tint\t\t\tbreakCount;\n\n// fqpath member added 7/20/02 by T.Ray\n\tchar\t\tfqpath[MAX_QPATH+1] ;\n};\n\n\nextern\tvm_t\t*currentVM;\nextern\tint\t\tvm_debugLevel;\n\nvoid VM_Compile( vm_t *vm, vmHeader_t *header );\nint\tVM_CallCompiled( vm_t *vm, int *args );\n\nvoid VM_PrepareInterpreter( vm_t *vm, vmHeader_t *header );\nint\tVM_CallInterpreted( vm_t *vm, int *args );\n\nvmSymbol_t *VM_ValueToFunctionSymbol( vm_t *vm, int value );\nint VM_SymbolToValue( vm_t *vm, const char *symbol );\nconst char *VM_ValueToSymbol( vm_t *vm, int value );\nvoid VM_LogSyscalls( int *args );\n\n"
  },
  {
    "path": "code/qcommon/vm_ppc.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// vm_ppc.c\n// ppc dynamic compiler\n\n#include \"vm_local.h\"\n\n#pragma opt_pointer_analysis off\n\n\ntypedef enum {\n    R_REAL_STACK = 1,\n\t// registers 3-11 are the parameter passing registers\n\t\n\t// state\n\tR_STACK = 3,\t\t\t// local\n\tR_OPSTACK,\t\t\t\t// global\n\n\t// constants\t\n\tR_MEMBASE,\t\t\t// global\n\tR_MEMMASK,\n\tR_ASMCALL,\t\t\t// global\n    R_INSTRUCTIONS,\t\t// global\n    R_NUM_INSTRUCTIONS,\t// global\n    R_CVM,\t\t\t\t// currentVM\n    \n\t// temps\n\tR_TOP = 11,\n\tR_SECOND = 12,\n\tR_EA = 2\t\t\t\t// effective address calculation\n\t \n} regNums_t;\n\n#define\tRG_REAL_STACK\t\tr1\n#define\tRG_STACK\t\t\tr3\n#define\tRG_OPSTACK\t\t\tr4\n#define\tRG_MEMBASE\t\t\tr5\n#define\tRG_MEMMASK\t\t\tr6\n#define\tRG_ASMCALL\t\t\tr7\n#define\tRG_INSTRUCTIONS\t\tr8\n#define\tRG_NUM_INSTRUCTIONS\tr9\n#define\tRG_CVM\t\t\t\tr10\n#define\tRG_TOP\t\t\t\tr12\n#define\tRG_SECOND\t\t\tr13\n#define\tRG_EA \t\t\t\tr14\n\n// this doesn't have the low order bits set for instructions i'm not using...\ntypedef enum {\n\tPPC_TDI\t\t= 0x08000000,\n\tPPC_TWI\t\t= 0x0c000000,\n\tPPC_MULLI\t= 0x1c000000,\n\tPPC_SUBFIC\t= 0x20000000,\n\tPPC_CMPI\t= 0x28000000,\n\tPPC_CMPLI\t= 0x2c000000,\n\tPPC_ADDIC\t= 0x30000000,\n\tPPC_ADDIC_\t= 0x34000000,\n\tPPC_ADDI\t= 0x38000000,\n\tPPC_ADDIS\t= 0x3c000000,\n\tPPC_BC\t\t= 0x40000000,\n\tPPC_SC\t\t= 0x44000000,\n\tPPC_B\t\t= 0x48000000,\n\n\tPPC_MCRF\t= 0x4c000000,\n\tPPC_BCLR\t= 0x4c000020,\n\tPPC_RFID\t= 0x4c000000,\n\tPPC_CRNOR\t= 0x4c000000,\n\tPPC_RFI\t\t= 0x4c000000,\n\tPPC_CRANDC\t= 0x4c000000,\n\tPPC_ISYNC\t= 0x4c000000,\n\tPPC_CRXOR\t= 0x4c000000,\n\tPPC_CRNAND\t= 0x4c000000,\n\tPPC_CREQV\t= 0x4c000000,\n\tPPC_CRORC\t= 0x4c000000,\n\tPPC_CROR\t= 0x4c000000,\n//------------\n\tPPC_BCCTR\t= 0x4c000420,\n\tPPC_RLWIMI\t= 0x50000000,\n\tPPC_RLWINM\t= 0x54000000,\n\tPPC_RLWNM\t= 0x5c000000,\n\tPPC_ORI\t\t= 0x60000000,\n\tPPC_ORIS\t= 0x64000000,\n\tPPC_XORI\t= 0x68000000,\n\tPPC_XORIS\t= 0x6c000000,\n\tPPC_ANDI_\t= 0x70000000,\n\tPPC_ANDIS_\t= 0x74000000,\n\tPPC_RLDICL\t= 0x78000000,\n\tPPC_RLDICR\t= 0x78000000,\n\tPPC_RLDIC\t= 0x78000000,\n\tPPC_RLDIMI\t= 0x78000000,\n\tPPC_RLDCL\t= 0x78000000,\n\tPPC_RLDCR\t= 0x78000000,\n\tPPC_CMP\t\t= 0x7c000000,\n\tPPC_TW\t\t= 0x7c000000,\n\tPPC_SUBFC\t= 0x7c000010,\n\tPPC_MULHDU\t= 0x7c000000,\n\tPPC_ADDC\t= 0x7c000014,\n\tPPC_MULHWU\t= 0x7c000000,\n\tPPC_MFCR\t= 0x7c000000,\n\tPPC_LWAR\t= 0x7c000000,\n\tPPC_LDX\t\t= 0x7c000000,\n\tPPC_LWZX\t= 0x7c00002e,\n\tPPC_SLW\t\t= 0x7c000030,\n\tPPC_CNTLZW\t= 0x7c000000,\n\tPPC_SLD\t\t= 0x7c000000,\n\tPPC_AND\t\t= 0x7c000038,\n\tPPC_CMPL\t= 0x7c000040,\n\tPPC_SUBF\t= 0x7c000050,\n\tPPC_LDUX\t= 0x7c000000,\n//------------\n\tPPC_DCBST\t= 0x7c000000,\n\tPPC_LWZUX\t= 0x7c00006c,\n\tPPC_CNTLZD\t= 0x7c000000,\n\tPPC_ANDC\t= 0x7c000000,\n\tPPC_TD\t\t= 0x7c000000,\n\tPPC_MULHD\t= 0x7c000000,\n\tPPC_MULHW\t= 0x7c000000,\n\tPPC_MTSRD\t= 0x7c000000,\n\tPPC_MFMSR\t= 0x7c000000,\n\tPPC_LDARX\t= 0x7c000000,\n\tPPC_DCBF\t= 0x7c000000,\n\tPPC_LBZX\t= 0x7c0000ae,\n\tPPC_NEG\t\t= 0x7c000000,\n\tPPC_MTSRDIN\t= 0x7c000000,\n\tPPC_LBZUX\t= 0x7c000000,\n\tPPC_NOR\t\t= 0x7c0000f8,\n\tPPC_SUBFE\t= 0x7c000000,\n\tPPC_ADDE\t= 0x7c000000,\n\tPPC_MTCRF\t= 0x7c000000,\n\tPPC_MTMSR\t= 0x7c000000,\n\tPPC_STDX\t= 0x7c000000,\n\tPPC_STWCX_\t= 0x7c000000,\n\tPPC_STWX\t= 0x7c00012e,\n\tPPC_MTMSRD\t= 0x7c000000,\n\tPPC_STDUX\t= 0x7c000000,\n\tPPC_STWUX\t= 0x7c00016e,\n\tPPC_SUBFZE\t= 0x7c000000,\n\tPPC_ADDZE\t= 0x7c000000,\n\tPPC_MTSR\t= 0x7c000000,\n\tPPC_STDCX_\t= 0x7c000000,\n\tPPC_STBX\t= 0x7c0001ae,\n\tPPC_SUBFME\t= 0x7c000000,\n\tPPC_MULLD\t= 0x7c000000,\n//------------\n\tPPC_ADDME\t= 0x7c000000,\n\tPPC_MULLW\t= 0x7c0001d6,\n\tPPC_MTSRIN\t= 0x7c000000,\n\tPPC_DCBTST\t= 0x7c000000,\n\tPPC_STBUX\t= 0x7c000000,\n\tPPC_ADD\t\t= 0x7c000214,\n\tPPC_DCBT\t= 0x7c000000,\n\tPPC_LHZX\t= 0x7c00022e,\n\tPPC_EQV\t\t= 0x7c000000,\n\tPPC_TLBIE\t= 0x7c000000,\n\tPPC_ECIWX\t= 0x7c000000,\n\tPPC_LHZUX\t= 0x7c000000,\n\tPPC_XOR\t\t= 0x7c000278,\n\tPPC_MFSPR\t= 0x7c0002a6,\n\tPPC_LWAX\t= 0x7c000000,\n\tPPC_LHAX\t= 0x7c000000,\n\tPPC_TLBIA\t= 0x7c000000,\n\tPPC_MFTB\t= 0x7c000000,\n\tPPC_LWAUX\t= 0x7c000000,\n\tPPC_LHAUX\t= 0x7c000000,\n\tPPC_STHX\t= 0x7c00032e,\n\tPPC_ORC\t\t= 0x7c000338,\n\tPPC_SRADI\t= 0x7c000000,\n\tPPC_SLBIE\t= 0x7c000000,\n\tPPC_ECOWX\t= 0x7c000000,\n\tPPC_STHUX\t= 0x7c000000,\n\tPPC_OR\t\t= 0x7c000378,\n\tPPC_DIVDU\t= 0x7c000000,\n\tPPC_DIVWU\t= 0x7c000396,\n\tPPC_MTSPR\t= 0x7c0003a6,\n\tPPC_DCBI\t= 0x7c000000,\n\tPPC_NAND\t= 0x7c000000,\n\tPPC_DIVD\t= 0x7c000000,\n//------------\n\tPPC_DIVW\t= 0x7c0003d6,\n\tPPC_SLBIA\t= 0x7c000000,\n\tPPC_MCRXR\t= 0x7c000000,\n\tPPC_LSWX\t= 0x7c000000,\n\tPPC_LWBRX\t= 0x7c000000,\n\tPPC_LFSX\t= 0x7c000000,\n\tPPC_SRW\t\t= 0x7c000430,\n\tPPC_SRD\t\t= 0x7c000000,\n\tPPC_TLBSYNC\t= 0x7c000000,\n\tPPC_LFSUX\t= 0x7c000000,\n\tPPC_MFSR\t= 0x7c000000,\n\tPPC_LSWI\t= 0x7c000000,\n\tPPC_SYNC\t= 0x7c000000,\n\tPPC_LFDX\t= 0x7c000000,\n\tPPC_LFDUX\t= 0x7c000000,\n\tPPC_MFSRIN\t= 0x7c000000,\n\tPPC_STSWX\t= 0x7c000000,\n\tPPC_STWBRX\t= 0x7c000000,\n\tPPC_STFSX\t= 0x7c000000,\n\tPPC_STFSUX\t= 0x7c000000,\n\tPPC_STSWI\t= 0x7c000000,\n\tPPC_STFDX\t= 0x7c000000,\n\tPPC_DCBA\t= 0x7c000000,\n\tPPC_STFDUX\t= 0x7c000000,\n\tPPC_LHBRX\t= 0x7c000000,\n\tPPC_SRAW\t= 0x7c000630,\n\tPPC_SRAD\t= 0x7c000000,\n\tPPC_SRAWI\t= 0x7c000000,\n\tPPC_EIEIO\t= 0x7c000000,\n\tPPC_STHBRX\t= 0x7c000000,\n\tPPC_EXTSH\t= 0x7c000734,\n\tPPC_EXTSB\t= 0x7c000774,\n\tPPC_ICBI\t= 0x7c000000,\n//------------\n\tPPC_STFIWX\t= 0x7c0007ae,\n\tPPC_EXTSW\t= 0x7c000000,\n\tPPC_DCBZ\t= 0x7c000000,\n\tPPC_LWZ\t\t= 0x80000000,\n\tPPC_LWZU\t= 0x84000000,\n\tPPC_LBZ\t\t= 0x88000000,\n\tPPC_LBZU\t= 0x8c000000,\n\tPPC_STW\t\t= 0x90000000,\n\tPPC_STWU\t= 0x94000000,\n\tPPC_STB\t\t= 0x98000000,\n\tPPC_STBU\t= 0x9c000000,\n\tPPC_LHZ\t\t= 0xa0000000,\n\tPPC_LHZU\t= 0xa4000000,\n\tPPC_LHA\t\t= 0xa8000000,\n\tPPC_LHAU\t= 0xac000000,\n\tPPC_STH\t\t= 0xb0000000,\n\tPPC_STHU\t= 0xb4000000,\n\tPPC_LMW\t\t= 0xb8000000,\n\tPPC_STMW\t= 0xbc000000,\n\tPPC_LFS\t\t= 0xc0000000,\n\tPPC_LFSU\t= 0xc4000000,\n\tPPC_LFD\t\t= 0xc8000000,\n\tPPC_LFDU\t= 0xcc000000,\n\tPPC_STFS\t= 0xd0000000,\n\tPPC_STFSU\t= 0xd4000000,\n\tPPC_STFD\t= 0xd8000000,\n\tPPC_STFDU\t= 0xdc000000,\n\tPPC_LD\t\t= 0xe8000000,\n\tPPC_LDU\t\t= 0xe8000001,\n\tPPC_LWA\t\t= 0xe8000002,\n\tPPC_FDIVS\t= 0xec000024,\n\tPPC_FSUBS\t= 0xec000028,\n\tPPC_FADDS\t= 0xec00002a,\n//------------\n\tPPC_FSQRTS\t= 0xec000000,\n\tPPC_FRES\t= 0xec000000,\n\tPPC_FMULS\t= 0xec000032,\n\tPPC_FMSUBS\t= 0xec000000,\n\tPPC_FMADDS\t= 0xec000000,\n\tPPC_FNMSUBS\t= 0xec000000,\n\tPPC_FNMADDS\t= 0xec000000,\n\tPPC_STD\t\t= 0xf8000000,\n\tPPC_STDU\t= 0xf8000001,\n\tPPC_FCMPU\t= 0xfc000000,\n\tPPC_FRSP\t= 0xfc000018,\n\tPPC_FCTIW\t= 0xfc000000,\n\tPPC_FCTIWZ\t= 0xfc00001e,\n\tPPC_FDIV\t= 0xfc000000,\n\tPPC_FSUB\t= 0xfc000028,\n\tPPC_FADD\t= 0xfc000000,\n\tPPC_FSQRT\t= 0xfc000000,\n\tPPC_FSEL\t= 0xfc000000,\n\tPPC_FMUL\t= 0xfc000000,\n\tPPC_FRSQRTE\t= 0xfc000000,\n\tPPC_FMSUB\t= 0xfc000000,\n\tPPC_FMADD\t= 0xfc000000,\n\tPPC_FNMSUB\t= 0xfc000000,\n\tPPC_FNMADD\t= 0xfc000000,\n\tPPC_FCMPO\t= 0xfc000000,\n\tPPC_MTFSB1\t= 0xfc000000,\n\tPPC_FNEG\t= 0xfc000050,\n\tPPC_MCRFS\t= 0xfc000000,\n\tPPC_MTFSB0\t= 0xfc000000,\n\tPPC_FMR\t\t= 0xfc000000,\n\tPPC_MTFSFI\t= 0xfc000000,\n\tPPC_FNABS\t= 0xfc000000,\n\tPPC_FABS\t= 0xfc000000,\n//------------\n\tPPC_MFFS\t= 0xfc000000,\n\tPPC_MTFSF\t= 0xfc000000,\n\tPPC_FCTID\t= 0xfc000000,\n\tPPC_FCTIDZ\t= 0xfc000000,\n\tPPC_FCFID\t= 0xfc000000\n\t\n} ppcOpcodes_t;\n\n\n// the newly generated code\nstatic\tunsigned\t*buf;\nstatic\tint\t\tcompiledOfs;\t// in dwords\n\n// fromt the original bytecode\nstatic\tbyte\t*code;\nstatic\tint\t\tpc;\n\nvoid AsmCall( void );\n\ndouble\titofConvert[2];\n\nstatic int\tConstant4( void ) {\n\tint\t\tv;\n\n\tv = code[pc] | (code[pc+1]<<8) | (code[pc+2]<<16) | (code[pc+3]<<24);\n\tpc += 4;\n\treturn v;\n}\n\nstatic int\tConstant1( void ) {\n\tint\t\tv;\n\n\tv = code[pc];\n\tpc += 1;\n\treturn v;\n}\n\nstatic void Emit4( int i ) {\n\tbuf[ compiledOfs ] = i;\n\tcompiledOfs++;\n}\n\nstatic void Inst( int opcode, int destReg, int aReg, int bReg ) {\n    unsigned\t\tr;\n\n    r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( bReg << 11 ) ;\n    buf[ compiledOfs ] = r;\n    compiledOfs++;\n}\n\nstatic void Inst4( int opcode, int destReg, int aReg, int bReg, int cReg ) {\n    unsigned\t\tr;\n\n    r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( bReg << 11 ) | ( cReg << 6 );\n    buf[ compiledOfs ] = r;\n    compiledOfs++;\n}\n\nstatic void InstImm( int opcode, int destReg, int aReg, int immediate ) {\n\tunsigned\t\tr;\n\t\n\tif ( immediate > 32767 || immediate < -32768 ) {\n\t    Com_Error( ERR_FATAL, \"VM_Compile: immediate value %i out of range, opcode %x,%d,%d\", immediate, opcode, destReg, aReg );\n\t}\n\tr = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( immediate & 0xffff );\n\tbuf[ compiledOfs ] = r;\n\tcompiledOfs++;\n}\n\nstatic void InstImmU( int opcode, int destReg, int aReg, int immediate ) {\n\tunsigned\t\tr;\n\t\n\tif ( immediate > 0xffff || immediate < 0 ) {\n\t\tCom_Error( ERR_FATAL, \"VM_Compile: immediate value %i out of range\", immediate );\n\t}\n    r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( immediate & 0xffff );\n\tbuf[ compiledOfs ] = r;\n\tcompiledOfs++;\n}\n\nstatic qboolean\trtopped;\nstatic int pop0, pop1, oc0, oc1;\nstatic vm_t *tvm;\nstatic int instruction;\nstatic byte *jused;\nstatic int pass;\n\nstatic void ltop() {\n    if (rtopped == qfalse) {\n\tInstImm( PPC_LWZ, R_TOP, R_OPSTACK, 0 );\t\t// get value from opstack\n    }\n}\n\nstatic void ltopandsecond() {\n    if (pass>=0 && buf[compiledOfs-1] == (PPC_STWU |  R_TOP<<21 | R_OPSTACK<<16 | 4 ) && jused[instruction]==0 ) {\n\tcompiledOfs--;\n\tif (!pass) {\n\t    tvm->instructionPointers[instruction] = compiledOfs * 4;\n\t}\n\tInstImm( PPC_LWZ, R_SECOND, R_OPSTACK, 0 );\t// get value from opstack\n\tInstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );\n    } else if (pass>=0 && buf[compiledOfs-1] == (PPC_STW |  R_TOP<<21 | R_OPSTACK<<16 | 0 )  && jused[instruction]==0 ) {\n\tcompiledOfs--;\n\tif (!pass) {\n\t    tvm->instructionPointers[instruction] = compiledOfs * 4;\n\t}\n\tInstImm( PPC_LWZ, R_SECOND, R_OPSTACK, -4 );\t// get value from opstack\n\tInstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -8 );\n    } else {\n\tltop();\t\t// get value from opstack\n\tInstImm( PPC_LWZ, R_SECOND, R_OPSTACK, -4 );\t// get value from opstack\n\tInstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -8 );\n    }\n    rtopped = qfalse;\n}\n\n// TJW: Unused\n#if 0\nstatic void fltop() {\n    if (rtopped == qfalse) {\n\tInstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 );\t\t// get value from opstack\n    }\n}\n#endif\n\nstatic void fltopandsecond() {\n\tInstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 );\t\t// get value from opstack\n\tInstImm( PPC_LFS, R_SECOND, R_OPSTACK, -4 );\t// get value from opstack\n\tInstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -8 );\n    rtopped = qfalse;\n\treturn;\n}\n\n/*\n=================\nVM_Compile\n=================\n*/\nvoid VM_Compile( vm_t *vm, vmHeader_t *header ) {\n\tint\t\top;\n\tint\t\tmaxLength;\n\tint\t\tv;\n\tint\t\ti;\n        \n\t// set up the into-to-float variables\n   \t((int *)itofConvert)[0] = 0x43300000;\n   \t((int *)itofConvert)[1] = 0x80000000;\n   \t((int *)itofConvert)[2] = 0x43300000;\n\n\t// allocate a very large temp buffer, we will shrink it later\n\tmaxLength = header->codeLength * 8;\n\tbuf = Z_Malloc( maxLength );\n\tjused = Z_Malloc(header->instructionCount + 2);\n\tCom_Memset(jused, 0, header->instructionCount+2);\n\t\n    // compile everything twice, so the second pass will have valid instruction\n    // pointers for branches\n    for ( pass = -1 ; pass < 2 ; pass++ ) {\n\n\trtopped = qfalse;\n        // translate all instructions\n        pc = 0;\n\t\n\tpop0 = 343545;\n\tpop1 = 2443545;\n\toc0 = -2343535;\n\toc1 = 24353454;\n\ttvm = vm;\n        code = (byte *)header + header->codeOffset;\n        compiledOfs = 0;\n#ifndef __GNUC__\n\t\t// metrowerks seems to require this header in front of functions\n\t\tEmit4( (int)(buf+2) );\n\t\tEmit4( 0 );\n#endif\n\n\t\tfor ( instruction = 0 ; instruction < header->instructionCount ; instruction++ ) {\n            if ( compiledOfs*4 > maxLength - 16 ) {\n                Com_Error( ERR_DROP, \"VM_Compile: maxLength exceeded\" );\n            }\n\n            op = code[ pc ];\n            if ( !pass ) {\n                vm->instructionPointers[ instruction ] = compiledOfs * 4;\n            }\n            pc++;\n            switch ( op ) {\n            case 0:\n                break;\n            case OP_BREAK:\n                InstImmU( PPC_ADDI, R_TOP, 0, 0 );\n                InstImm( PPC_LWZ, R_TOP, R_TOP, 0 );\t\t\t// *(int *)0 to crash to debugger\n\t\trtopped = qfalse;\n                break;\n            case OP_ENTER:\n                InstImm( PPC_ADDI, R_STACK, R_STACK, -Constant4() );\t// sub R_STACK, R_STACK, imm\n\t\trtopped = qfalse;\n                break;\n            case OP_CONST:\n                v = Constant4();\n\t\tif (code[pc] == OP_LOAD4 || code[pc] == OP_LOAD2 || code[pc] == OP_LOAD1) {\n\t\t    v &= vm->dataMask;\n\t\t}\n                if ( v < 32768 && v >= -32768 ) {\n                    InstImmU( PPC_ADDI, R_TOP, 0, v & 0xffff );\n                } else {\n                    InstImmU( PPC_ADDIS, R_TOP, 0, (v >> 16)&0xffff );\n                    if ( v & 0xffff ) {\n                        InstImmU( PPC_ORI, R_TOP, R_TOP, v & 0xffff );\n                    }\n                }\n\t\tif (code[pc] == OP_LOAD4) {\n\t\t    Inst( PPC_LWZX, R_TOP, R_TOP, R_MEMBASE );\t\t// load from memory base\n\t\t    pc++;\n\t\t    instruction++;\n\t\t} else if (code[pc] == OP_LOAD2) {\n\t\t    Inst( PPC_LHZX, R_TOP, R_TOP, R_MEMBASE );\t\t// load from memory base\n\t\t    pc++;\n\t\t    instruction++;\n\t\t} else if (code[pc] == OP_LOAD1) {\n\t\t    Inst( PPC_LBZX, R_TOP, R_TOP, R_MEMBASE );\t\t// load from memory base\n\t\t    pc++;\n\t\t    instruction++;\n\t\t}\n\t\tif (code[pc] == OP_STORE4) {\n\t\t    InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, 0 );\t// get value from opstack\n\t\t    InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );\n\t\t    //Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND );\t// mask it\n\t\t    Inst( PPC_STWX, R_TOP, R_SECOND, R_MEMBASE );\t// store from memory base\n\t\t    pc++;\n\t\t    instruction++;\n\t\t    rtopped = qfalse;\n\t\t    break;\n\t\t} else if (code[pc] == OP_STORE2) {\n\t\t    InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, 0 );\t// get value from opstack\n\t\t    InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );\n\t\t    //Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND );\t// mask it\n\t\t    Inst( PPC_STHX, R_TOP, R_SECOND, R_MEMBASE );\t// store from memory base\n\t\t    pc++;\n\t\t    instruction++;\n\t\t    rtopped = qfalse;\n\t\t    break;\n\t\t} else if (code[pc] == OP_STORE1) {\n\t\t    InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, 0 );\t// get value from opstack\n\t\t    InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );\n\t\t    //Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND );\t// mask it\n\t\t    Inst( PPC_STBX, R_TOP, R_SECOND, R_MEMBASE );\t// store from memory base\n\t\t    pc++;\n\t\t    instruction++;\n\t\t    rtopped = qfalse;\n\t\t    break;\n\t\t}\n\t\tif (code[pc] == OP_JUMP) {\n\t\t    jused[v] = 1;\n\t\t}\n\t\tInstImm( PPC_STWU, R_TOP, R_OPSTACK, 4 );\n\t\trtopped = qtrue;\n\t\tbreak;\n            case OP_LOCAL:\n\t\toc0 = oc1;\n\t\toc1 = Constant4();\n\t\tif (code[pc] == OP_LOAD4 || code[pc] == OP_LOAD2 || code[pc] == OP_LOAD1) {\n\t\t    oc1 &= vm->dataMask;\n\t\t}\n                InstImm( PPC_ADDI, R_TOP, R_STACK, oc1 );\n\t\tif (code[pc] == OP_LOAD4) {\n\t\t    Inst( PPC_LWZX, R_TOP, R_TOP, R_MEMBASE );\t\t// load from memory base\n\t\t    pc++;\n\t\t    instruction++;\n\t\t} else if (code[pc] == OP_LOAD2) {\n\t\t    Inst( PPC_LHZX, R_TOP, R_TOP, R_MEMBASE );\t\t// load from memory base\n\t\t    pc++;\n\t\t    instruction++;\n\t\t} else if (code[pc] == OP_LOAD1) {\n\t\t    Inst( PPC_LBZX, R_TOP, R_TOP, R_MEMBASE );\t\t// load from memory base\n\t\t    pc++;\n\t\t    instruction++;\n\t\t}\n\t\tif (code[pc] == OP_STORE4) {\n\t\t    InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, 0 );\t\t// get value from opstack\n\t\t    InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );\n\t\t    //Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND );\t// mask it\n\t\t    Inst( PPC_STWX, R_TOP, R_SECOND, R_MEMBASE );\t// store from memory base\n\t\t    pc++;\n\t\t    instruction++;\n\t\t    rtopped = qfalse;\n\t\t    break;\n\t\t} else if (code[pc] == OP_STORE2) {\n\t\t    InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, 0 );\t\t// get value from opstack\n\t\t    InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );\n\t\t    //Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND );\t// mask it\n\t\t    Inst( PPC_STHX, R_TOP, R_SECOND, R_MEMBASE );\t// store from memory base\n\t\t    pc++;\n\t\t    instruction++;\n\t\t    rtopped = qfalse;\n\t\t    break;\n\t\t} else if (code[pc] == OP_STORE1) {\n\t\t    InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, 0 );\t\t// get value from opstack\n\t\t    InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );\n\t\t    //Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND );\t// mask it\n\t\t    Inst( PPC_STBX, R_TOP, R_SECOND, R_MEMBASE );\t// store from memory base\n\t\t    pc++;\n\t\t    instruction++;\n\t\t    rtopped = qfalse;\n\t\t    break;\n\t\t}\n                InstImm( PPC_STWU, R_TOP, R_OPSTACK, 4 );\n\t\trtopped = qtrue;\n                break;\n            case OP_ARG:\n                ltop();\t\t\t\t\t\t\t// get value from opstack\n                InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );\n                InstImm( PPC_ADDI, R_EA, R_STACK, Constant1() );\t// location to put it\n                Inst( PPC_STWX, R_TOP, R_EA, R_MEMBASE );\n\t\trtopped = qfalse;\n                break;\n            case OP_CALL:\n                Inst( PPC_MFSPR, R_SECOND, 8, 0 );\t\t\t// move from link register\n                InstImm( PPC_STWU, R_SECOND, R_REAL_STACK, -16 );\t// save off the old return address\n\n                Inst( PPC_MTSPR, R_ASMCALL, 9, 0 );\t\t\t// move to count register\n                Inst( PPC_BCCTR | 1, 20, 0, 0 );\t\t\t// jump and link to the count register\n\n                InstImm( PPC_LWZ, R_SECOND, R_REAL_STACK, 0 );\t\t// fetch the old return address\n                InstImm( PPC_ADDI, R_REAL_STACK, R_REAL_STACK, 16 );\n                Inst( PPC_MTSPR, R_SECOND, 8, 0 );\t\t\t// move to link register\n\t\trtopped = qfalse;\n                break;\n            case OP_PUSH:\n                InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, 4 );\n\t\trtopped = qfalse;\n                break;\n            case OP_POP:\n                InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );\n\t\trtopped = qfalse;\n                break;\n            case OP_LEAVE:\n                InstImm( PPC_ADDI, R_STACK, R_STACK, Constant4() );\t// add R_STACK, R_STACK, imm\n                Inst( PPC_BCLR, 20, 0, 0 );\t\t\t\t\t\t\t// branch unconditionally to link register\n\t\trtopped = qfalse;\n                break;\n            case OP_LOAD4:\n                ltop();\t\t\t\t\t\t\t// get value from opstack\n\t\t//Inst( PPC_AND, R_MEMMASK, R_TOP, R_TOP );\t\t// mask it\n                Inst( PPC_LWZX, R_TOP, R_TOP, R_MEMBASE );\t\t// load from memory base\n                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );\n\t\trtopped = qtrue;\n                break;\n            case OP_LOAD2:\n                ltop();\t\t\t\t\t\t\t// get value from opstack\n\t\t//Inst( PPC_AND, R_MEMMASK, R_TOP, R_TOP );\t\t// mask it\n                Inst( PPC_LHZX, R_TOP, R_TOP, R_MEMBASE );\t\t// load from memory base\n                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );\n\t\trtopped = qtrue;\n                break;\n            case OP_LOAD1:\n                ltop();\t\t\t\t\t\t\t// get value from opstack\n\t\t//Inst( PPC_AND, R_MEMMASK, R_TOP, R_TOP );\t\t// mask it\n                Inst( PPC_LBZX, R_TOP, R_TOP, R_MEMBASE );\t\t// load from memory base\n                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );\n\t\trtopped = qtrue;\n                break;\n            case OP_STORE4:\n                ltopandsecond();\t\t\t\t\t// get value from opstack\n\t\t//Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND );\t\t// mask it\n                Inst( PPC_STWX, R_TOP, R_SECOND, R_MEMBASE );\t\t// store from memory base\n\t\trtopped = qfalse;\n                break;\n            case OP_STORE2:\n                ltopandsecond();\t\t\t\t\t// get value from opstack\n\t\t//Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND );\t\t// mask it\n                Inst( PPC_STHX, R_TOP, R_SECOND, R_MEMBASE );\t\t// store from memory base\n\t\trtopped = qfalse;\n                break;\n            case OP_STORE1:\n                ltopandsecond();\t\t\t\t\t// get value from opstack\n\t\t//Inst( PPC_AND, R_MEMMASK, R_SECOND, R_SECOND );\t\t// mask it\n                Inst( PPC_STBX, R_TOP, R_SECOND, R_MEMBASE );\t\t// store from memory base\n\t\trtopped = qfalse;\n                break;\n\n            case OP_EQ:\n                ltopandsecond();\t\t\t\t\t// get value from opstack\n                Inst( PPC_CMP, 0, R_SECOND, R_TOP );\n                i = Constant4();\n\t\t\t\tjused[i] = 1;\n                InstImm( PPC_BC, 4, 2, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];                    \n                } else {\n                    v = 0;             \n                }\n                Emit4(PPC_B | (v&0x3ffffff) );\n\t\t\t\trtopped = qfalse;\n                break;\n            case OP_NE:\n                ltopandsecond();\t\t\t\t\t// get value from opstack\n                Inst( PPC_CMP, 0, R_SECOND, R_TOP );\n                i = Constant4();\n\t\t\t\tjused[i] = 1;\n                InstImm( PPC_BC, 12, 2, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];                    \n                } else {\n                    v = 0;\n                }\n                Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( PPC_BC, 4, 2, v );\n\n\t\t\t\trtopped = qfalse;\n                break;\n            case OP_LTI:\n                ltopandsecond();\t\t\t\t\t// get value from opstack\n                Inst( PPC_CMP, 0, R_SECOND, R_TOP );\n                i = Constant4();\n\t\t\t\tjused[i] = 1;\n                InstImm( PPC_BC, 4, 0, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( PPC_BC, 12, 0, v );\n\t\t\t\trtopped = qfalse;\n                break;\n            case OP_LEI:\n                ltopandsecond();\t\t\t\t\t// get value from opstack\n                Inst( PPC_CMP, 0, R_SECOND, R_TOP );\n                i = Constant4();\n\t\t\t\tjused[i] = 1;\n                InstImm( PPC_BC, 12, 1, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( PPC_BC, 4, 1, v );\n\t\t\t\trtopped = qfalse;\n                break;\n            case OP_GTI:\n                ltopandsecond();\t\t// get value from opstack\n                Inst( PPC_CMP, 0, R_SECOND, R_TOP );\n                i = Constant4();\n\t\t\t\tjused[i] = 1;\n                InstImm( PPC_BC, 4, 1, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( PPC_BC, 12, 1, v );\n\t\t\t\trtopped = qfalse;\n                break;\n            case OP_GEI:\n                ltopandsecond();\t\t// get value from opstack\n                Inst( PPC_CMP, 0, R_SECOND, R_TOP );\n                i = Constant4();\n\t\t\t\tjused[i] = 1;\n                InstImm( PPC_BC, 12, 0, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( PPC_BC, 4, 0, v );\n\t\t\t\trtopped = qfalse;\n                break;\n            case OP_LTU:\n                ltopandsecond();\t\t// get value from opstack\n                Inst( PPC_CMPL, 0, R_SECOND, R_TOP );\n                i = Constant4();\n\t\tjused[i] = 1;\n                InstImm( PPC_BC, 4, 0, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( PPC_BC, 12, 0, v );\n\t\trtopped = qfalse;\n                break;\n            case OP_LEU:\n                ltopandsecond();\t\t// get value from opstack\n                Inst( PPC_CMPL, 0, R_SECOND, R_TOP );\n                i = Constant4();\n\t\tjused[i] = 1;\n                InstImm( PPC_BC, 12, 1, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( PPC_BC, 4, 1, v );\n\t\trtopped = qfalse;\n                break;\n            case OP_GTU:\n                ltopandsecond();\t\t// get value from opstack\n                Inst( PPC_CMPL, 0, R_SECOND, R_TOP );\n                i = Constant4();\n\t\tjused[i] = 1;\n                InstImm( PPC_BC, 4, 1, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( PPC_BC, 12, 1, v );\n\t\trtopped = qfalse;\n                break;\n            case OP_GEU:\n                ltopandsecond();\t\t// get value from opstack\n                Inst( PPC_CMPL, 0, R_SECOND, R_TOP );\n                i = Constant4();\n\t\tjused[i] = 1;\n                InstImm( PPC_BC, 12, 0, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( PPC_BC, 4, 0, v );\n\t\trtopped = qfalse;\n                break;\n                \n            case OP_EQF:\n                fltopandsecond();\t\t// get value from opstack\n                Inst( PPC_FCMPU, 0, R_TOP, R_SECOND );\n                i = Constant4();\n\t\tjused[i] = 1;\n                InstImm( PPC_BC, 4, 2, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( PPC_BC, 12, 2, v );\n\t\trtopped = qfalse;\n                break;\t\t\t\n            case OP_NEF:\n                fltopandsecond();\t\t// get value from opstack\n                Inst( PPC_FCMPU, 0, R_TOP, R_SECOND );\n                i = Constant4();\n\t\tjused[i] = 1;\n                InstImm( PPC_BC, 12, 2, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( PPC_BC, 4, 2, v );\n\t\trtopped = qfalse;\n                break;\t\t\t\n            case OP_LTF:\n                fltopandsecond();\t\t// get value from opstack\n                Inst( PPC_FCMPU, 0, R_SECOND, R_TOP );\n                i = Constant4();\n\t\tjused[i] = 1;\n                InstImm( PPC_BC, 4, 0, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( PPC_BC, 12, 0, v );\n\t\trtopped = qfalse;\n                break;\t\t\t\n            case OP_LEF:\n                fltopandsecond();\t\t// get value from opstack\n                Inst( PPC_FCMPU, 0, R_SECOND, R_TOP );\n                i = Constant4();\n\t\tjused[i] = 1;\n                InstImm( PPC_BC, 12, 1, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( PPC_BC, 4, 1, v );\n\t\trtopped = qfalse;\n                break;\t\t\t\n            case OP_GTF:\n                fltopandsecond();\t\t// get value from opstack\n                Inst( PPC_FCMPU, 0, R_SECOND, R_TOP );\n                i = Constant4();\n\t\tjused[i] = 1;\n                InstImm( PPC_BC, 4, 1, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( PPC_BC, 12, 1, v );\n\t\trtopped = qfalse;\n                break;\t\t\t\n            case OP_GEF:\n                fltopandsecond();\t\t// get value from opstack\n                Inst( PPC_FCMPU, 0, R_SECOND, R_TOP );\n                i = Constant4();\n\t\tjused[i] = 1;\n                InstImm( PPC_BC, 12, 0, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( PPC_BC, 4, 0, v );\n\t\trtopped = qfalse;\n                break;\n\n            case OP_NEGI:\n                ltop();\t\t// get value from opstack\n                InstImm( PPC_SUBFIC, R_TOP, R_TOP, 0 );\n                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );\t\t// save value to opstack\n\t\trtopped = qtrue;\n                break;\n            case OP_ADD:\n                ltop();\t\t// get value from opstack\n                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );\t\t// get value from opstack\n                Inst( PPC_ADD, R_TOP, R_TOP, R_SECOND );\n                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );\t\t// save value to opstack\n\t\trtopped = qtrue;\n                break;\n            case OP_SUB:\n                ltop();\t\t// get value from opstack\n                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );\t\t// get value from opstack\n                Inst( PPC_SUBF, R_TOP, R_TOP, R_SECOND );\n                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );\t\t// save value to opstack\n\t\trtopped = qtrue;\n                break;\n            case OP_DIVI:\n                ltop();\t\t// get value from opstack\n                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );\t\t// get value from opstack\n                Inst( PPC_DIVW, R_TOP, R_SECOND, R_TOP );\n                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );\t\t// save value to opstack\n\t\trtopped = qtrue;\n                break;\n            case OP_DIVU:\n                ltop();\t\t// get value from opstack\n                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );\t\t// get value from opstack\n                Inst( PPC_DIVWU, R_TOP, R_SECOND, R_TOP );\n                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );\t\t// save value to opstack\n\t\trtopped = qtrue;\n                break;\n            case OP_MODI:\n                ltop();\t\t// get value from opstack\n                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );\t\t// get value from opstack\n                Inst( PPC_DIVW, R_EA, R_SECOND, R_TOP );\n                Inst( PPC_MULLW, R_EA, R_TOP, R_EA );\n                Inst( PPC_SUBF, R_TOP, R_EA, R_SECOND );\n                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );\t\t// save value to opstack\n\t\trtopped = qtrue;\n                break;\n            case OP_MODU:\n                ltop();\t\t// get value from opstack\n                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );\t\t// get value from opstack\n                Inst( PPC_DIVWU, R_EA, R_SECOND, R_TOP );\n                Inst( PPC_MULLW, R_EA, R_TOP, R_EA );\n                Inst( PPC_SUBF, R_TOP, R_EA, R_SECOND );\n                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );\t\t// save value to opstack\n\t\trtopped = qtrue;\n                break;\n            case OP_MULI:\n            case OP_MULU:\n                ltop();\t\t// get value from opstack\n                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );\t\t// get value from opstack\n                Inst( PPC_MULLW, R_TOP, R_SECOND, R_TOP );\n                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );\t\t// save value to opstack\n\t\trtopped = qtrue;\n                break;\n            case OP_BAND:\n                ltop();\t\t// get value from opstack\n                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );\t\t// get value from opstack\n                Inst( PPC_AND, R_SECOND, R_TOP, R_TOP );\n                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );\t\t// save value to opstack\n\t\trtopped = qtrue;\n                break;\n            case OP_BOR:\n                ltop();\t\t// get value from opstack\n                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );\t\t// get value from opstack\n                Inst( PPC_OR, R_SECOND, R_TOP, R_TOP );\n                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );\t\t// save value to opstack\n\t\trtopped = qtrue;\n                break;\n            case OP_BXOR:\n                ltop();\t\t// get value from opstack\n                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );\t\t// get value from opstack\n                Inst( PPC_XOR, R_SECOND, R_TOP, R_TOP );\n                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );\t\t// save value to opstack\n\t\trtopped = qtrue;\n                break;\n            case OP_BCOM:\n                ltop();\t\t// get value from opstack\n                Inst( PPC_NOR, R_TOP, R_TOP, R_TOP );\n                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );\t\t// save value to opstack\n\t\trtopped = qtrue;\n                break;\n            case OP_LSH:\n                ltop();\t\t// get value from opstack\n                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );\t\t// get value from opstack\n                Inst( PPC_SLW, R_SECOND, R_TOP, R_TOP );\n                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );\t\t// save value to opstack\n\t\trtopped = qtrue;\n                break;\n            case OP_RSHI:\n                ltop();\t\t// get value from opstack\n                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );\t\t// get value from opstack\n                Inst( PPC_SRAW, R_SECOND, R_TOP, R_TOP );\n                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );\t\t// save value to opstack\n\t\trtopped = qtrue;\n                break;\n            case OP_RSHU:\n                ltop();\t\t// get value from opstack\n                InstImm( PPC_LWZU, R_SECOND, R_OPSTACK, -4 );\t\t// get value from opstack\n                Inst( PPC_SRW, R_SECOND, R_TOP, R_TOP );\n                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );\t\t// save value to opstack\n\t\trtopped = qtrue;\n                break;\n\n            case OP_NEGF:\n                InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 );\t\t// get value from opstack\n                Inst( PPC_FNEG, R_TOP, 0, R_TOP );\n                InstImm( PPC_STFS, R_TOP, R_OPSTACK, 0 );\t\t// save value to opstack\n\t\trtopped = qfalse;\n                break;\n            case OP_ADDF:\n                InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 );\t\t// get value from opstack\n                InstImm( PPC_LFSU, R_SECOND, R_OPSTACK, -4 );\t\t// get value from opstack\n                Inst( PPC_FADDS, R_TOP, R_SECOND, R_TOP );\n                InstImm( PPC_STFS, R_TOP, R_OPSTACK, 0 );\t\t// save value to opstack\n\t\trtopped = qfalse;\n                break;\n            case OP_SUBF:\n                InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 );\t\t// get value from opstack\n                InstImm( PPC_LFSU, R_SECOND, R_OPSTACK, -4 );\t\t// get value from opstack\n                Inst( PPC_FSUBS, R_TOP, R_SECOND, R_TOP );\n                InstImm( PPC_STFS, R_TOP, R_OPSTACK, 0 );\t\t// save value to opstack\n\t\trtopped = qfalse;\n                break;\n            case OP_DIVF:\n                InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 );\t\t// get value from opstack\n                InstImm( PPC_LFSU, R_SECOND, R_OPSTACK, -4 );\t\t// get value from opstack\n                Inst( PPC_FDIVS, R_TOP, R_SECOND, R_TOP );\n                InstImm( PPC_STFS, R_TOP, R_OPSTACK, 0 );\t\t// save value to opstack\n\t\trtopped = qfalse;\n                break;\n            case OP_MULF:\n                InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 );\t\t// get value from opstack\n                InstImm( PPC_LFSU, R_SECOND, R_OPSTACK, -4 );\t\t// get value from opstack\n                Inst4( PPC_FMULS, R_TOP, R_SECOND, 0, R_TOP );\n                InstImm( PPC_STFS, R_TOP, R_OPSTACK, 0 );\t\t// save value to opstack\n\t\trtopped = qfalse;\n                break;\n\n            case OP_CVIF:\n                v = (int)&itofConvert;\n                InstImmU( PPC_ADDIS, R_EA, 0, (v >> 16)&0xffff );\n                InstImmU( PPC_ORI, R_EA, R_EA, v & 0xffff );\n\t\tInstImm( PPC_LWZ, R_TOP, R_OPSTACK, 0 );\t\t// get value from opstack\n                InstImmU( PPC_XORIS, R_TOP, R_TOP, 0x8000 );\n                InstImm( PPC_STW, R_TOP, R_EA, 12 );\n                InstImm( PPC_LFD, R_TOP, R_EA, 0 );\n                InstImm( PPC_LFD, R_SECOND, R_EA, 8 );\n                Inst( PPC_FSUB, R_TOP, R_SECOND, R_TOP );\n    //            Inst( PPC_FRSP, R_TOP, 0, R_TOP );\n                InstImm( PPC_STFS, R_TOP, R_OPSTACK, 0 );\t\t// save value to opstack\n\t\trtopped = qfalse;\n                break;\n            case OP_CVFI:\n                InstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 );\t\t// get value from opstack\n                Inst( PPC_FCTIWZ, R_TOP, 0, R_TOP );\n                Inst( PPC_STFIWX, R_TOP, 0, R_OPSTACK );\t\t// save value to opstack\n\t\trtopped = qfalse;\n                break;\n            case OP_SEX8:\n                ltop();\t// get value from opstack\n                Inst( PPC_EXTSB, R_TOP, R_TOP, 0 );\n                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );\n\t\trtopped = qtrue;\n                break;\n            case OP_SEX16:\n                ltop();\t// get value from opstack\n                Inst( PPC_EXTSH, R_TOP, R_TOP, 0 );\n                InstImm( PPC_STW, R_TOP, R_OPSTACK, 0 );\n\t\trtopped = qtrue;\n                break;\n\n            case OP_BLOCK_COPY:\n                v = Constant4() >> 2;\n                ltop();\t\t// source\n                InstImm( PPC_LWZ, R_SECOND, R_OPSTACK, -4 );\t// dest\n                InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -8 );\n                InstImmU( PPC_ADDI, R_EA, 0, v );\t\t\t\t// count\n\t\t\t\t// FIXME: range check\n              \tInst( PPC_MTSPR, R_EA, 9, 0 );\t\t\t\t\t// move to count register\n\n                Inst( PPC_ADD, R_TOP, R_TOP, R_MEMBASE );\n                InstImm( PPC_ADDI, R_TOP, R_TOP, -4 );\n                Inst( PPC_ADD, R_SECOND, R_SECOND, R_MEMBASE );\n                InstImm( PPC_ADDI, R_SECOND, R_SECOND, -4 );\n\n                InstImm( PPC_LWZU, R_EA, R_TOP, 4 );\t\t// source\n                InstImm( PPC_STWU, R_EA, R_SECOND, 4 );\t// dest\n                Inst( PPC_BC | 0xfff8 , 16, 0, 0 );\t\t\t\t\t// loop\n\t\trtopped = qfalse;\n                break;\n\n            case OP_JUMP:\n                ltop();\t// get value from opstack\n                InstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );\n                Inst( PPC_RLWINM | ( 29 << 1 ), R_TOP, R_TOP, 2 );\n\t\t// FIXME: range check\n\t\tInst( PPC_LWZX, R_TOP, R_TOP, R_INSTRUCTIONS );\n                Inst( PPC_MTSPR, R_TOP, 9, 0 );\t\t// move to count register\n                Inst( PPC_BCCTR, 20, 0, 0 );\t\t// jump to the count register\n\t\trtopped = qfalse;\n                break;\n            default:\n                Com_Error( ERR_DROP, \"VM_CompilePPC: bad opcode %i at instruction %i, offset %i\", op, instruction, pc );\n            }\n\t    pop0 = pop1;\n\t    pop1 = op;\n        }\n\n\tCom_Printf( \"VM file %s pass %d compiled to %i bytes of code\\n\", vm->name, (pass+1), compiledOfs*4 );\n\n    \tif ( pass == 0 ) {\n\t    // copy to an exact size buffer on the hunk\n\t    vm->codeLength = compiledOfs * 4;\n\t    vm->codeBase = Hunk_Alloc( vm->codeLength, h_low );\n\t    Com_Memcpy( vm->codeBase, buf, vm->codeLength );\n\t    Z_Free( buf );\n\t\n\t    // offset all the instruction pointers for the new location\n\t    for ( i = 0 ; i < header->instructionCount ; i++ ) {\n\t\tvm->instructionPointers[i] += (int)vm->codeBase;\n\t    }\n\n\t    // go back over it in place now to fixup reletive jump targets\n\t    buf = (unsigned *)vm->codeBase;\n\t}\n    }\n    Z_Free( jused );\n}\n\n/*\n==============\nVM_CallCompiled\n\nThis function is called directly by the generated code\n==============\n*/\nint\tVM_CallCompiled( vm_t *vm, int *args ) {\n\tint\t\tstack[1024];\n\tint\t\tprogramStack;\n\tint\t\tstackOnEntry;\n\tbyte\t*image;\n\n\tcurrentVM = vm;\n\n\t// interpret the code\n\tvm->currentlyInterpreting = qtrue;\n\n\t// we might be called recursively, so this might not be the very top\n\tprogramStack = vm->programStack;\n\tstackOnEntry = programStack;\n\timage = vm->dataBase;\n\t\n\t// set up the stack frame \n\tprogramStack -= 48;\n\n\t*(int *)&image[ programStack + 44] = args[9];\n\t*(int *)&image[ programStack + 40] = args[8];\n\t*(int *)&image[ programStack + 36] = args[7];\n\t*(int *)&image[ programStack + 32] = args[6];\n\t*(int *)&image[ programStack + 28] = args[5];\n\t*(int *)&image[ programStack + 24] = args[4];\n\t*(int *)&image[ programStack + 20] = args[3];\n\t*(int *)&image[ programStack + 16] = args[2];\n\t*(int *)&image[ programStack + 12] = args[1];\n\t*(int *)&image[ programStack + 8 ] = args[0];\n\t*(int *)&image[ programStack + 4 ] = 0;\t// return stack\n\t*(int *)&image[ programStack ] = -1;\t// will terminate the loop on return\n\n\t// off we go into generated code...\n\t// the PPC calling standard says the parms will all go into R3 - R11, so \n\t// no special asm code is needed here\n#ifdef __GNUC__\n\t((void(*)(int, int, int, int, int, int, int, int))(vm->codeBase))( \n\t\tprogramStack, (int)&stack, \n\t\t(int)image, vm->dataMask, (int)&AsmCall, \n\t\t(int)vm->instructionPointers, vm->instructionPointersLength,\n        (int)vm );\n#else\n\t((void(*)(int, int, int, int, int, int, int, int))(vm->codeBase))( \n\t\tprogramStack, (int)&stack, \n\t\t(int)image, vm->dataMask, *(int *)&AsmCall /* skip function pointer header */, \n\t\t(int)vm->instructionPointers, vm->instructionPointersLength,\n        (int)vm );\n#endif\n\tvm->programStack = stackOnEntry;\n\n    vm->currentlyInterpreting = qfalse;\n\n\treturn stack[1];\n}\n\n\n/*\n==================\nAsmCall\n\nPut this at end of file because gcc messes up debug line numbers \n==================\n*/\n#ifdef __GNUC__\n\nvoid AsmCall( void ) {\nasm (\n     // pop off the destination instruction\n\"    lwz\t\tr12,0(r4)\t\\n\"\t// RG_TOP, 0(RG_OPSTACK)\n\"    addi\tr4,r4,-4\t\t\\n\"\t// RG_OPSTACK, RG_OPSTACK, -4 \\n\"\n\n    // see if it is a system trap\n\"    cmpwi\tr12,0\t\t\t\\n\"\t// RG_TOP, 0 \\n\"\n\"    bc\t\t12,0, systemTrap\t\\n\"\n\n    // calling another VM function, so lookup in instructionPointers\n\"    slwi\tr12,r12,2\t\t\\n\"\t// RG_TOP,RG_TOP,2\n                        // FIXME: range check\n\"    lwzx\tr12, r8, r12\t\t\\n\"\t// RG_TOP, RG_INSTRUCTIONS(RG_TOP)\t\n\"    mtctr\tr12\t\t\t\\n\"\t// RG_TOP\n);\n\n#if defined(MACOS_X) && defined(__OPTIMIZE__)\n    // On Mac OS X, gcc doesn't push a frame when we are optimized, so trying to tear it down results in grave disorder.\n#warning Mac OS X optimization on, not popping GCC AsmCall frame\n#else\n    // Mac OS X Server and unoptimized compiles include a GCC AsmCall frame\n    asm (\n\"\tlwz\t\tr1,0(r1)\t\\n\"\t// pop off the GCC AsmCall frame\n\"\tlmw\t\tr30,-8(r1)\t\\n\"\n);\n#endif\n\nasm (\n\"\t    bcctr\t20,0\t\t\\n\" // when it hits a leave, it will branch to the current link register\n\n    // calling a system trap\n\"systemTrap:\t\t\t\t\\n\"\n\t// convert to positive system call number\n\"\tsubfic\tr12,r12,-1\t\t\\n\"\n\n    // save all our registers, including the current link register\n\"    mflr\tr13\t\t\t\\n\"\t// RG_SECOND\t\t// copy off our link register\n\"\taddi\tr1,r1,-92\t\t\\n\"\t// required 24 byets of linkage, 32 bytes of parameter, plus our saves\n\"    stw\t\tr3,56(r1)\t\\n\"\t// RG_STACK, -36(REAL_STACK)\n\"    stw\t\tr4,60(r1)\t\\n\"\t// RG_OPSTACK, 4(RG_REAL_STACK)\n\"    stw\t\tr5,64(r1)\t\\n\"\t// RG_MEMBASE, 8(RG_REAL_STACK)\n\"    stw\t\tr6,68(r1)\t\\n\"\t// RG_MEMMASK, 12(RG_REAL_STACK)\n\"    stw\t\tr7,72(r1)\t\\n\"\t// RG_ASMCALL, 16(RG_REAL_STACK)\n\"    stw\t\tr8,76(r1)\t\\n\"\t// RG_INSTRUCTIONS, 20(RG_REAL_STACK)\n\"    stw\t\tr9,80(r1)\t\\n\"\t// RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)\n\"    stw\t\tr10,84(r1)\t\\n\"\t// RG_VM, 28(RG_REAL_STACK)\n\"    stw\t\tr13,88(r1)\t\\n\"\t// RG_SECOND, 32(RG_REAL_STACK)\t// link register\n\n    // save the vm stack position to allow recursive VM entry\n\"    addi\tr13,r3,-4\t\t\\n\"\t// RG_TOP, RG_STACK, -4\n\"    stw\t\tr13,0(r10)\t\\n\"\t//RG_TOP, VM_OFFSET_PROGRAM_STACK(RG_VM)\n\n    // save the system call number as the 0th parameter\n\"    add\t\tr3,r3,r5\t\\n\"\t// r3,  RG_STACK, RG_MEMBASE\t\t// r3 is the first parameter to vm->systemCalls\n\"    stwu\tr12,4(r3)\t\t\\n\"\t// RG_TOP, 4(r3)\n\n    // make the system call with the address of all the VM parms as a parameter\n    // vm->systemCalls( &parms )\n\"    lwz\t\tr12,4(r10)\t\\n\"\t// RG_TOP, VM_OFFSET_SYSTEM_CALL(RG_VM)\n\"    mtctr\tr12\t\t\t\\n\"\t// RG_TOP\n\"    bcctrl\t20,0\t\t\t\\n\"\n\"    mr\t\tr12,r3\t\t\t\\n\"\t// RG_TOP, r3\n\n    // pop our saved registers\n\"   \tlwz\t\tr3,56(r1)\t\\n\"\t// RG_STACK, 0(RG_REAL_STACK)\n\"   \tlwz\t\tr4,60(r1)\t\\n\"\t// RG_OPSTACK, 4(RG_REAL_STACK)\n\"   \tlwz\t\tr5,64(r1)\t\\n\"\t// RG_MEMBASE, 8(RG_REAL_STACK)\n\"   \tlwz\t\tr6,68(r1)\t\\n\"\t// RG_MEMMASK, 12(RG_REAL_STACK)\n\"   \tlwz\t\tr7,72(r1)\t\\n\"\t// RG_ASMCALL, 16(RG_REAL_STACK)\n\"   \tlwz\t\tr8,76(r1)\t\\n\"\t// RG_INSTRUCTIONS, 20(RG_REAL_STACK)\n\"   \tlwz\t\tr9,80(r1)\t\\n\"\t// RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)\n\"   \tlwz\t\tr10,84(r1)\t\\n\"\t// RG_VM, 28(RG_REAL_STACK)\n\"   \tlwz\t\tr13,88(r1)\t\\n\"\t// RG_SECOND, 32(RG_REAL_STACK)\n\"    addi\tr1,r1,92\t\t\\n\"\t// RG_REAL_STACK, RG_REAL_STACK, 36\n\n    // restore the old link register\n\"    mtlr\tr13\t\t\t\\n\"\t// RG_SECOND\n\n    // save off the return value\n\"    stwu\tr12,4(r4)\t\t\\n\"\t// RG_TOP, 0(RG_OPSTACK)\n\n\t// GCC adds its own prolog / epilog code\n );\n}\n#else\n\n// codewarrior version\n\nvoid asm AsmCall( void ) {\n\n    // pop off the destination instruction\n\n    lwz\t\tr12,0(r4)\t// RG_TOP, 0(RG_OPSTACK)\n\n    addi\tr4,r4,-4\t// RG_OPSTACK, RG_OPSTACK, -4\n\n\n\n    // see if it is a system trap\n\n    cmpwi\tr12,0\t\t// RG_TOP, 0\n\n    bc\t\t12,0, systemTrap\n\n\n\n    // calling another VM function, so lookup in instructionPointers\n\n    slwi\tr12,r12,2\t\t// RG_TOP,RG_TOP,2\n\n                        // FIXME: range check\n\n    lwzx\tr12, r8, r12\t// RG_TOP, RG_INSTRUCTIONS(RG_TOP)\t\n\n    mtctr\tr12\t\t\t// RG_TOP\n\n\n\n    bcctr\t20,0\t\t// when it hits a leave, it will branch to the current link register\n\n\n\n    // calling a system trap\n\nsystemTrap:\n\n\t// convert to positive system call number\n\n\tsubfic\tr12,r12,-1\n\n\n\n    // save all our registers, including the current link register\n\n    mflr\tr13\t\t\t// RG_SECOND\t\t// copy off our link register\n\n\taddi\tr1,r1,-92\t// required 24 byets of linkage, 32 bytes of parameter, plus our saves\n\n    stw\t\tr3,56(r1)\t// RG_STACK, -36(REAL_STACK)\n\n    stw\t\tr4,60(r1)\t// RG_OPSTACK, 4(RG_REAL_STACK)\n\n    stw\t\tr5,64(r1)\t// RG_MEMBASE, 8(RG_REAL_STACK)\n\n    stw\t\tr6,68(r1)\t// RG_MEMMASK, 12(RG_REAL_STACK)\n\n    stw\t\tr7,72(r1)\t// RG_ASMCALL, 16(RG_REAL_STACK)\n\n    stw\t\tr8,76(r1)\t// RG_INSTRUCTIONS, 20(RG_REAL_STACK)\n\n    stw\t\tr9,80(r1)\t// RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)\n\n    stw\t\tr10,84(r1)\t// RG_VM, 28(RG_REAL_STACK)\n\n    stw\t\tr13,88(r1)\t// RG_SECOND, 32(RG_REAL_STACK)\t// link register\n\n\n\n    // save the vm stack position to allow recursive VM entry\n\n    addi\tr13,r3,-4\t// RG_TOP, RG_STACK, -4\n\n    stw\t\tr13,0(r10)\t//RG_TOP, VM_OFFSET_PROGRAM_STACK(RG_VM)\n\n\n\n    // save the system call number as the 0th parameter\n\n    add\t\tr3,r3,r5\t// r3,  RG_STACK, RG_MEMBASE\t\t// r3 is the first parameter to vm->systemCalls\n\n    stwu\tr12,4(r3)\t// RG_TOP, 4(r3)\n\n\n\n    // make the system call with the address of all the VM parms as a parameter\n\n    // vm->systemCalls( &parms )\n\n    lwz\t\tr12,4(r10)\t// RG_TOP, VM_OFFSET_SYSTEM_CALL(RG_VM)\n\n    \n\n    // perform macos cross fragment fixup crap\n\n    lwz\t\tr9,0(r12)\n\n    stw\t\tr2,52(r1)\t// save old TOC\n\n\tlwz\t\tr2,4(r12)\n\n\t    \n\n    mtctr\tr9\t\t\t// RG_TOP\n\n    bcctrl\t20,0\n\n    \n\n    lwz\t\tr2,52(r1)\t// restore TOC\n\n    \n\n    mr\t\tr12,r3\t\t// RG_TOP, r3\n\n\n\n    // pop our saved registers\n\n   \tlwz\t\tr3,56(r1)\t// RG_STACK, 0(RG_REAL_STACK)\n\n   \tlwz\t\tr4,60(r1)\t// RG_OPSTACK, 4(RG_REAL_STACK)\n\n   \tlwz\t\tr5,64(r1)\t// RG_MEMBASE, 8(RG_REAL_STACK)\n\n   \tlwz\t\tr6,68(r1)\t// RG_MEMMASK, 12(RG_REAL_STACK)\n\n   \tlwz\t\tr7,72(r1)\t// RG_ASMCALL, 16(RG_REAL_STACK)\n\n   \tlwz\t\tr8,76(r1)\t// RG_INSTRUCTIONS, 20(RG_REAL_STACK)\n\n   \tlwz\t\tr9,80(r1)\t// RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)\n\n   \tlwz\t\tr10,84(r1)\t// RG_VM, 28(RG_REAL_STACK)\n\n   \tlwz\t\tr13,88(r1)\t// RG_SECOND, 32(RG_REAL_STACK)\n\n    addi\tr1,r1,92\t// RG_REAL_STACK, RG_REAL_STACK, 36\n\n\n\n    // restore the old link register\n\n    mtlr\tr13\t\t\t// RG_SECOND\n\n\n\n    // save off the return value\n\n    stwu\tr12,4(r4)\t// RG_TOP, 0(RG_OPSTACK)\n\n\n\n\tblr\n\n}\n\n\n\n\n#endif\n"
  },
  {
    "path": "code/qcommon/vm_ppc_new.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// vm_ppc.c\n// ppc dynamic compiler\n\n#include \"vm_local.h\"\n\n#pragma opt_pointer_analysis off\n\n#define DEBUG_VM 0\n\n#if DEBUG_VM\nstatic char\t*opnames[256] = {\n\t\"OP_UNDEF\", \n\n\t\"OP_IGNORE\", \n\n\t\"OP_BREAK\",\n\n\t\"OP_ENTER\",\n\t\"OP_LEAVE\",\n\t\"OP_CALL\",\n\t\"OP_PUSH\",\n\t\"OP_POP\",\n\n\t\"OP_CONST\",\n\n\t\"OP_LOCAL\",\n\n\t\"OP_JUMP\",\n\n\t//-------------------\n\n\t\"OP_EQ\",\n\t\"OP_NE\",\n\n\t\"OP_LTI\",\n\t\"OP_LEI\",\n\t\"OP_GTI\",\n\t\"OP_GEI\",\n\n\t\"OP_LTU\",\n\t\"OP_LEU\",\n\t\"OP_GTU\",\n\t\"OP_GEU\",\n\n\t\"OP_EQF\",\n\t\"OP_NEF\",\n\n\t\"OP_LTF\",\n\t\"OP_LEF\",\n\t\"OP_GTF\",\n\t\"OP_GEF\",\n\n\t//-------------------\n\n\t\"OP_LOAD1\",\n\t\"OP_LOAD2\",\n\t\"OP_LOAD4\",\n\t\"OP_STORE1\",\n\t\"OP_STORE2\",\n\t\"OP_STORE4\",\n\t\"OP_ARG\",\n\n\t\"OP_BLOCK_COPY\",\n\n\t//-------------------\n\n\t\"OP_SEX8\",\n\t\"OP_SEX16\",\n\n\t\"OP_NEGI\",\n\t\"OP_ADD\",\n\t\"OP_SUB\",\n\t\"OP_DIVI\",\n\t\"OP_DIVU\",\n\t\"OP_MODI\",\n\t\"OP_MODU\",\n\t\"OP_MULI\",\n\t\"OP_MULU\",\n\n\t\"OP_BAND\",\n\t\"OP_BOR\",\n\t\"OP_BXOR\",\n\t\"OP_BCOM\",\n\n\t\"OP_LSH\",\n\t\"OP_RSHI\",\n\t\"OP_RSHU\",\n\n\t\"OP_NEGF\",\n\t\"OP_ADDF\",\n\t\"OP_SUBF\",\n\t\"OP_DIVF\",\n\t\"OP_MULF\",\n\n\t\"OP_CVIF\",\n\t\"OP_CVFI\"\n};\n#endif\n\ntypedef enum {\n    R_REAL_STACK = 1,\n\t// registers 3-11 are the parameter passing registers\n\t\n\t// state\n\tR_STACK = 3,\t\t\t// local\n\tR_OPSTACK,\t\t\t\t// global\n\n\t// constants\t\n\tR_MEMBASE,\t\t\t// global\n\tR_MEMMASK,\n\tR_ASMCALL,\t\t\t// global\n    R_INSTRUCTIONS,\t\t// global\n    R_NUM_INSTRUCTIONS,\t// global\n    R_CVM,\t\t\t\t// currentVM\n    \n\t// temps\n\tR_TOP = 11,\n\tR_SECOND = 12,\n\tR_EA = 2\t\t\t\t// effective address calculation\n\t \n} regNums_t;\n\n#define\tRG_REAL_STACK\t\tr1\n#define\tRG_STACK\t\t\tr3\n#define\tRG_OPSTACK\t\t\tr4\n#define\tRG_MEMBASE\t\t\tr5\n#define\tRG_MEMMASK\t\t\tr6\n#define\tRG_ASMCALL\t\t\tr7\n#define\tRG_INSTRUCTIONS\t\tr8\n#define\tRG_NUM_INSTRUCTIONS\tr9\n#define\tRG_CVM\t\t\t\tr10\n#define\tRG_TOP\t\t\t\tr12\n#define\tRG_SECOND\t\t\tr13\n#define\tRG_EA \t\t\t\tr14\n\n// The deepest value I saw in the Quake3 games was 9.\n#define OP_STACK_MAX_DEPTH\t12\n\n// These are all volatile and thus must be saved\n// upon entry to the VM code.\nstatic int opStackIntRegisters[OP_STACK_MAX_DEPTH] =\n{\n\t16, 17, 18, 19,\n\t20, 21, 22, 23,\n\t24, 25, 26, 27\n};\n\nstatic unsigned int *opStackLoadInstructionAddr[OP_STACK_MAX_DEPTH];\n\n// We use different registers for the floating point\n// operand stack (these are volatile in the PPC ABI)\nstatic int opStackFloatRegisters[OP_STACK_MAX_DEPTH] =\n{\n\t0, 1, 2, 3,\n\t4, 5, 6, 7,\n\t8, 9, 10, 11\n};\n\nstatic int opStackRegType[OP_STACK_MAX_DEPTH] =\n{\n\t0, 0, 0, 0,\n\t0, 0, 0, 0,\n\t0, 0, 0, 0\n};\n\n// this doesn't have the low order bits set for instructions i'm not using...\ntypedef enum {\n\tPPC_TDI\t\t= 0x08000000,\n\tPPC_TWI\t\t= 0x0c000000,\n\tPPC_MULLI\t= 0x1c000000,\n\tPPC_SUBFIC\t= 0x20000000,\n\tPPC_CMPI\t= 0x28000000,\n\tPPC_CMPLI\t= 0x2c000000,\n\tPPC_ADDIC\t= 0x30000000,\n\tPPC_ADDIC_\t= 0x34000000,\n\tPPC_ADDI\t= 0x38000000,\n\tPPC_ADDIS\t= 0x3c000000,\n\tPPC_BC\t\t= 0x40000000,\n\tPPC_SC\t\t= 0x44000000,\n\tPPC_B\t\t= 0x48000000,\n\n\tPPC_MCRF\t= 0x4c000000,\n\tPPC_BCLR\t= 0x4c000020,\n\tPPC_RFID\t= 0x4c000000,\n\tPPC_CRNOR\t= 0x4c000000,\n\tPPC_RFI\t\t= 0x4c000000,\n\tPPC_CRANDC\t= 0x4c000000,\n\tPPC_ISYNC\t= 0x4c000000,\n\tPPC_CRXOR\t= 0x4c000000,\n\tPPC_CRNAND\t= 0x4c000000,\n\tPPC_CREQV\t= 0x4c000000,\n\tPPC_CRORC\t= 0x4c000000,\n\tPPC_CROR\t= 0x4c000000,\n//------------\n\tPPC_BCCTR\t= 0x4c000420,\n\tPPC_RLWIMI\t= 0x50000000,\n\tPPC_RLWINM\t= 0x54000000,\n\tPPC_RLWNM\t= 0x5c000000,\n\tPPC_ORI\t\t= 0x60000000,\n\tPPC_ORIS\t= 0x64000000,\n\tPPC_XORI\t= 0x68000000,\n\tPPC_XORIS\t= 0x6c000000,\n\tPPC_ANDI_\t= 0x70000000,\n\tPPC_ANDIS_\t= 0x74000000,\n\tPPC_RLDICL\t= 0x78000000,\n\tPPC_RLDICR\t= 0x78000000,\n\tPPC_RLDIC\t= 0x78000000,\n\tPPC_RLDIMI\t= 0x78000000,\n\tPPC_RLDCL\t= 0x78000000,\n\tPPC_RLDCR\t= 0x78000000,\n\tPPC_CMP\t\t= 0x7c000000,\n\tPPC_TW\t\t= 0x7c000000,\n\tPPC_SUBFC\t= 0x7c000010,\n\tPPC_MULHDU\t= 0x7c000000,\n\tPPC_ADDC\t= 0x7c000014,\n\tPPC_MULHWU\t= 0x7c000000,\n\tPPC_MFCR\t= 0x7c000000,\n\tPPC_LWAR\t= 0x7c000000,\n\tPPC_LDX\t\t= 0x7c000000,\n\tPPC_LWZX\t= 0x7c00002e,\n\tPPC_SLW\t\t= 0x7c000030,\n\tPPC_CNTLZW\t= 0x7c000000,\n\tPPC_SLD\t\t= 0x7c000000,\n\tPPC_AND\t\t= 0x7c000038,\n\tPPC_CMPL\t= 0x7c000040,\n\tPPC_SUBF\t= 0x7c000050,\n\tPPC_LDUX\t= 0x7c000000,\n//------------\n\tPPC_DCBST\t= 0x7c000000,\n\tPPC_LWZUX\t= 0x7c00006c,\n\tPPC_CNTLZD\t= 0x7c000000,\n\tPPC_ANDC\t= 0x7c000000,\n\tPPC_TD\t\t= 0x7c000000,\n\tPPC_MULHD\t= 0x7c000000,\n\tPPC_MULHW\t= 0x7c000000,\n\tPPC_MTSRD\t= 0x7c000000,\n\tPPC_MFMSR\t= 0x7c000000,\n\tPPC_LDARX\t= 0x7c000000,\n\tPPC_DCBF\t= 0x7c000000,\n\tPPC_LBZX\t= 0x7c0000ae,\n\tPPC_NEG\t\t= 0x7c000000,\n\tPPC_MTSRDIN\t= 0x7c000000,\n\tPPC_LBZUX\t= 0x7c000000,\n\tPPC_NOR\t\t= 0x7c0000f8,\n\tPPC_SUBFE\t= 0x7c000000,\n\tPPC_ADDE\t= 0x7c000000,\n\tPPC_MTCRF\t= 0x7c000000,\n\tPPC_MTMSR\t= 0x7c000000,\n\tPPC_STDX\t= 0x7c000000,\n\tPPC_STWCX_\t= 0x7c000000,\n\tPPC_STWX\t= 0x7c00012e,\n\tPPC_MTMSRD\t= 0x7c000000,\n\tPPC_STDUX\t= 0x7c000000,\n\tPPC_STWUX\t= 0x7c00016e,\n\tPPC_SUBFZE\t= 0x7c000000,\n\tPPC_ADDZE\t= 0x7c000000,\n\tPPC_MTSR\t= 0x7c000000,\n\tPPC_STDCX_\t= 0x7c000000,\n\tPPC_STBX\t= 0x7c0001ae,\n\tPPC_SUBFME\t= 0x7c000000,\n\tPPC_MULLD\t= 0x7c000000,\n//------------\n\tPPC_ADDME\t= 0x7c000000,\n\tPPC_MULLW\t= 0x7c0001d6,\n\tPPC_MTSRIN\t= 0x7c000000,\n\tPPC_DCBTST\t= 0x7c000000,\n\tPPC_STBUX\t= 0x7c000000,\n\tPPC_ADD\t\t= 0x7c000214,\n\tPPC_DCBT\t= 0x7c000000,\n\tPPC_LHZX\t= 0x7c00022e,\n\tPPC_EQV\t\t= 0x7c000000,\n\tPPC_TLBIE\t= 0x7c000000,\n\tPPC_ECIWX\t= 0x7c000000,\n\tPPC_LHZUX\t= 0x7c000000,\n\tPPC_XOR\t\t= 0x7c000278,\n\tPPC_MFSPR\t= 0x7c0002a6,\n\tPPC_LWAX\t= 0x7c000000,\n\tPPC_LHAX\t= 0x7c000000,\n\tPPC_TLBIA\t= 0x7c000000,\n\tPPC_MFTB\t= 0x7c000000,\n\tPPC_LWAUX\t= 0x7c000000,\n\tPPC_LHAUX\t= 0x7c000000,\n\tPPC_STHX\t= 0x7c00032e,\n\tPPC_ORC\t\t= 0x7c000338,\n\tPPC_SRADI\t= 0x7c000000,\n\tPPC_SLBIE\t= 0x7c000000,\n\tPPC_ECOWX\t= 0x7c000000,\n\tPPC_STHUX\t= 0x7c000000,\n\tPPC_OR\t\t= 0x7c000378,\n\tPPC_DIVDU\t= 0x7c000000,\n\tPPC_DIVWU\t= 0x7c000396,\n\tPPC_MTSPR\t= 0x7c0003a6,\n\tPPC_DCBI\t= 0x7c000000,\n\tPPC_NAND\t= 0x7c000000,\n\tPPC_DIVD\t= 0x7c000000,\n//------------\n\tPPC_DIVW\t= 0x7c0003d6,\n\tPPC_SLBIA\t= 0x7c000000,\n\tPPC_MCRXR\t= 0x7c000000,\n\tPPC_LSWX\t= 0x7c000000,\n\tPPC_LWBRX\t= 0x7c000000,\n\tPPC_LFSX\t= 0x7c00042e,\n\tPPC_SRW\t\t= 0x7c000430,\n\tPPC_SRD\t\t= 0x7c000000,\n\tPPC_TLBSYNC\t= 0x7c000000,\n\tPPC_LFSUX\t= 0x7c000000,\n\tPPC_MFSR\t= 0x7c000000,\n\tPPC_LSWI\t= 0x7c000000,\n\tPPC_SYNC\t= 0x7c000000,\n\tPPC_LFDX\t= 0x7c000000,\n\tPPC_LFDUX\t= 0x7c000000,\n\tPPC_MFSRIN\t= 0x7c000000,\n\tPPC_STSWX\t= 0x7c000000,\n\tPPC_STWBRX\t= 0x7c000000,\n\tPPC_STFSX\t= 0x7c00052e,\n\tPPC_STFSUX\t= 0x7c000000,\n\tPPC_STSWI\t= 0x7c000000,\n\tPPC_STFDX\t= 0x7c000000,\n\tPPC_DCBA\t= 0x7c000000,\n\tPPC_STFDUX\t= 0x7c000000,\n\tPPC_LHBRX\t= 0x7c000000,\n\tPPC_SRAW\t= 0x7c000630,\n\tPPC_SRAD\t= 0x7c000000,\n\tPPC_SRAWI\t= 0x7c000000,\n\tPPC_EIEIO\t= 0x7c000000,\n\tPPC_STHBRX\t= 0x7c000000,\n\tPPC_EXTSH\t= 0x7c000734,\n\tPPC_EXTSB\t= 0x7c000774,\n\tPPC_ICBI\t= 0x7c000000,\n//------------\n\tPPC_STFIWX\t= 0x7c0007ae,\n\tPPC_EXTSW\t= 0x7c000000,\n\tPPC_DCBZ\t= 0x7c000000,\n\tPPC_LWZ\t\t= 0x80000000,\n\tPPC_LWZU\t= 0x84000000,\n\tPPC_LBZ\t\t= 0x88000000,\n\tPPC_LBZU\t= 0x8c000000,\n\tPPC_STW\t\t= 0x90000000,\n\tPPC_STWU\t= 0x94000000,\n\tPPC_STB\t\t= 0x98000000,\n\tPPC_STBU\t= 0x9c000000,\n\tPPC_LHZ\t\t= 0xa0000000,\n\tPPC_LHZU\t= 0xa4000000,\n\tPPC_LHA\t\t= 0xa8000000,\n\tPPC_LHAU\t= 0xac000000,\n\tPPC_STH\t\t= 0xb0000000,\n\tPPC_STHU\t= 0xb4000000,\n\tPPC_LMW\t\t= 0xb8000000,\n\tPPC_STMW\t= 0xbc000000,\n\tPPC_LFS\t\t= 0xc0000000,\n\tPPC_LFSU\t= 0xc4000000,\n\tPPC_LFD\t\t= 0xc8000000,\n\tPPC_LFDU\t= 0xcc000000,\n\tPPC_STFS\t= 0xd0000000,\n\tPPC_STFSU\t= 0xd4000000,\n\tPPC_STFD\t= 0xd8000000,\n\tPPC_STFDU\t= 0xdc000000,\n\tPPC_LD\t\t= 0xe8000000,\n\tPPC_LDU\t\t= 0xe8000001,\n\tPPC_LWA\t\t= 0xe8000002,\n\tPPC_FDIVS\t= 0xec000024,\n\tPPC_FSUBS\t= 0xec000028,\n\tPPC_FADDS\t= 0xec00002a,\n//------------\n\tPPC_FSQRTS\t= 0xec000000,\n\tPPC_FRES\t= 0xec000000,\n\tPPC_FMULS\t= 0xec000032,\n\tPPC_FMSUBS\t= 0xec000000,\n\tPPC_FMADDS\t= 0xec000000,\n\tPPC_FNMSUBS\t= 0xec000000,\n\tPPC_FNMADDS\t= 0xec000000,\n\tPPC_STD\t\t= 0xf8000000,\n\tPPC_STDU\t= 0xf8000001,\n\tPPC_FCMPU\t= 0xfc000000,\n\tPPC_FRSP\t= 0xfc000018,\n\tPPC_FCTIW\t= 0xfc000000,\n\tPPC_FCTIWZ\t= 0xfc00001e,\n\tPPC_FDIV\t= 0xfc000000,\n\tPPC_FSUB\t= 0xfc000028,\n\tPPC_FADD\t= 0xfc000000,\n\tPPC_FSQRT\t= 0xfc000000,\n\tPPC_FSEL\t= 0xfc000000,\n\tPPC_FMUL\t= 0xfc000000,\n\tPPC_FRSQRTE\t= 0xfc000000,\n\tPPC_FMSUB\t= 0xfc000000,\n\tPPC_FMADD\t= 0xfc000000,\n\tPPC_FNMSUB\t= 0xfc000000,\n\tPPC_FNMADD\t= 0xfc000000,\n\tPPC_FCMPO\t= 0xfc000000,\n\tPPC_MTFSB1\t= 0xfc000000,\n\tPPC_FNEG\t= 0xfc000050,\n\tPPC_MCRFS\t= 0xfc000000,\n\tPPC_MTFSB0\t= 0xfc000000,\n\tPPC_FMR\t\t= 0xfc000000,\n\tPPC_MTFSFI\t= 0xfc000000,\n\tPPC_FNABS\t= 0xfc000000,\n\tPPC_FABS\t= 0xfc000000,\n//------------\n\tPPC_MFFS\t= 0xfc000000,\n\tPPC_MTFSF\t= 0xfc000000,\n\tPPC_FCTID\t= 0xfc000000,\n\tPPC_FCTIDZ\t= 0xfc000000,\n\tPPC_FCFID\t= 0xfc000000\n\t\n} ppcOpcodes_t;\n\n\n// the newly generated code\nstatic\tunsigned\t*buf;\nstatic\tint\t\tcompiledOfs;\t// in dwords\nstatic int pass;\n\n// fromt the original bytecode\nstatic\tbyte\t*code;\nstatic\tint\t\tpc;\n\nvoid AsmCall( void );\n\ndouble\titofConvert[2];\n\nstatic int\tConstant4( void ) {\n\tint\t\tv;\n\n\tv = code[pc] | (code[pc+1]<<8) | (code[pc+2]<<16) | (code[pc+3]<<24);\n\tpc += 4;\n\treturn v;\n}\n\nstatic int\tConstant1( void ) {\n\tint\t\tv;\n\n\tv = code[pc];\n\tpc += 1;\n\treturn v;\n}\n\nstatic void Emit4( char *opname, int i ) {\n\t#if DEBUG_VM\n\tif(pass == 1)\n\t\tprintf(\"\\t\\t\\t%p %s\\t%08lx\\n\",&buf[compiledOfs],opname,i&0x3ffffff);\n\t#endif\n\tbuf[ compiledOfs ] = i;\n\tcompiledOfs++;\n}\n\nstatic void Inst( char *opname, int opcode, int destReg, int aReg, int bReg ) {\n    unsigned\t\tr;\n\n\t#if DEBUG_VM\n\tif(pass == 1)\n\t\tprintf(\"\\t\\t\\t%p %s\\tr%d,r%d,r%d\\n\",&buf[compiledOfs],opname,destReg,aReg,bReg);\n\t#endif\n    r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( bReg << 11 ) ;\n    buf[ compiledOfs ] = r;\n    compiledOfs++;\n}\n\nstatic void Inst4( char *opname, int opcode, int destReg, int aReg, int bReg, int cReg ) {\n    unsigned\t\tr;\n\n\t#if DEBUG_VM\n\tif(pass == 1)\n\t\tprintf(\"\\t\\t\\t%p %s\\tr%d,r%d,r%d,r%d\\n\",&buf[compiledOfs],opname,destReg,aReg,bReg,cReg);\n\t#endif\n    r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( bReg << 11 ) | ( cReg << 6 );\n    buf[ compiledOfs ] = r;\n    compiledOfs++;\n}\n\nstatic void InstImm( char *opname, int opcode, int destReg, int aReg, int immediate ) {\n\tunsigned\t\tr;\n\t\n\tif ( immediate > 32767 || immediate < -32768 ) {\n\t    Com_Error( ERR_FATAL, \"VM_Compile: immediate value %i out of range, opcode %x,%d,%d\", immediate, opcode, destReg, aReg );\n\t}\n\t#if DEBUG_VM\n\tif(pass == 1)\n\t\tprintf(\"\\t\\t\\t%p %s\\tr%d,r%d,0x%x\\n\",&buf[compiledOfs],opname,destReg,aReg,immediate);\n\t#endif\n\tr = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( immediate & 0xffff );\n\tbuf[ compiledOfs ] = r;\n\tcompiledOfs++;\n}\n\nstatic void InstImmU( char *opname, int opcode, int destReg, int aReg, int immediate ) {\n\tunsigned\t\tr;\n\t\n\tif ( immediate > 0xffff || immediate < 0 ) {\n\t\tCom_Error( ERR_FATAL, \"VM_Compile: immediate value %i out of range\", immediate );\n\t}\n\t#if DEBUG_VM\n\tif(pass == 1)\n\t\tprintf(\"\\t\\t\\t%p %s\\tr%d,r%d,0x%x\\n\",&buf[compiledOfs],opname,destReg,aReg,immediate);\n\t#endif\n    r = opcode | ( destReg << 21 ) | ( aReg << 16 ) | ( immediate & 0xffff );\n\tbuf[ compiledOfs ] = r;\n\tcompiledOfs++;\n}\n\nstatic int pop0, pop1, oc0, oc1;\nstatic vm_t *tvm;\nstatic int instruction;\nstatic byte *jused;\n\nstatic void ltop() {\n//    if (rtopped == qfalse) {\n//\tInstImm( PPC_LWZ, R_TOP, R_OPSTACK, 0 );\t\t// get value from opstack\n//    }\n}\n\nstatic void ltopandsecond() {\n#if 0\n    if (pass>=0 && buf[compiledOfs-1] == (PPC_STWU |  R_TOP<<21 | R_OPSTACK<<16 | 4 ) && jused[instruction]==0 ) {\n\tcompiledOfs--;\n\tif (!pass) {\n\t    tvm->instructionPointers[instruction] = compiledOfs * 4;\n\t}\n\tInstImm( PPC_LWZ, R_SECOND, R_OPSTACK, 0 );\t// get value from opstack\n\tInstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -4 );\n    } else if (pass>=0 && buf[compiledOfs-1] == (PPC_STW |  R_TOP<<21 | R_OPSTACK<<16 | 0 )  && jused[instruction]==0 ) {\n\tcompiledOfs--;\n\tif (!pass) {\n\t    tvm->instructionPointers[instruction] = compiledOfs * 4;\n\t}\n\tInstImm( PPC_LWZ, R_SECOND, R_OPSTACK, -4 );\t// get value from opstack\n\tInstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -8 );\n    } else {\n\tltop();\t\t// get value from opstack\n\tInstImm( PPC_LWZ, R_SECOND, R_OPSTACK, -4 );\t// get value from opstack\n\tInstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -8 );\n    }\n    rtopped = qfalse;\n#endif\n}\n\nstatic void spillOpStack(int depth)\n{\n\t// Store out each register on the operand stack to it's correct location.\n\tint i;\n\t\n\tfor(i = 0; i < depth; i++)\n\t{\n\t\tassert(opStackRegType[i]);\n\t\tassert(opStackRegType[i] == 1);\n\t\tswitch(opStackRegType[i])\n\t\t{\n\t\t\tcase 1:\t// Integer register\n\t\t\t\tInstImm( \"stw\", PPC_STW, opStackIntRegisters[i], R_OPSTACK, i*4+4);\n\t\t\t\tbreak;\n\t\t\tcase 2: // Float register\n\t\t\t\tInstImm( \"stfs\", PPC_STFS, opStackFloatRegisters[i], R_OPSTACK, i*4+4);\n\t\t\t\tbreak;\n\t\t}\n\t\topStackRegType[i] = 0;\n\t}\n}\n\nstatic void loadOpStack(int depth)\n{\n\t// Back off operand stack pointer and reload all operands.\n//\tInstImm( \"addi\", PPC_ADDI, R_OPSTACK, R_OPSTACK, -(depth)*4 );\n\n\tint i;\n\t\n\tfor(i = 0; i < depth; i++)\n\t{\n\t\tassert(opStackRegType[i] == 0);\n\t\t// For now we're stuck reloading everything as an integer.\n\t\topStackLoadInstructionAddr[i] = &buf[compiledOfs];\n\t\tInstImm( \"lwz\", PPC_LWZ, opStackIntRegisters[i], R_OPSTACK, i*4+4);\n\t\topStackRegType[i] = 1;\n\t}\t\n}\n\nstatic void makeInteger(int depth)\n{\n\t// This should really never be necessary...\n\tassert(opStackRegType[depth] == 1);\n\t//assert(opStackRegType[depth] == 2);\n\tif(opStackRegType[depth] == 2)\n\t{\n\t\tunsigned instruction;\n\t\tassert(opStackLoadInstructionAddr[depth]);\n\t\t\n\t\tprintf(\"patching float load at %p to int load\\n\",opStackLoadInstructionAddr[depth]);\n\t\t// Repatch load instruction to use LFS instead of LWZ\n\t\tinstruction = *opStackLoadInstructionAddr[depth];\n\t\tinstruction &= ~PPC_LFSX;\n\t\tinstruction |=  PPC_LWZX;\n\t\t*opStackLoadInstructionAddr[depth] = instruction;\n\t\topStackLoadInstructionAddr[depth] = 0;\n\t\topStackRegType[depth] = 1;\n\t\t#if 0\n\t\tInstImm( \"stfs\", PPC_STFS, opStackFloatRegisters[depth], R_OPSTACK, depth*4+4);\n\t\t// For XXX make sure we force enough NOPs to get the load into\n\t\t// another dispatch group to avoid pipeline flush.\n\t\tInst( \"ori\", PPC_ORI,  0, 0, 0 );\n\t\tInst( \"ori\", PPC_ORI,  0, 0, 0 );\n\t\tInst( \"ori\", PPC_ORI,  0, 0, 0 );\n\t\tInst( \"ori\", PPC_ORI,  0, 0, 0 );\n\t\tInstImm( \"lwz\", PPC_LWZ, opStackIntRegisters[depth], R_OPSTACK, depth*4+4);\n\t\topStackRegType[depth] = 1;\n\t\t#endif\n\t}\n}\n\nstatic void makeFloat(int depth)\n{\n\t//assert(opStackRegType[depth] == 1);\n\tif(opStackRegType[depth] == 1)\n\t{\n\t\tunsigned instruction;\n\t\tunsigned destReg, aReg, bReg, imm;\n\t\t\n\t\tif(opStackLoadInstructionAddr[depth])\n\t\t{\n\t\t\t// Repatch load instruction to use LFS instead of LWZ\n\t\t\tinstruction = *opStackLoadInstructionAddr[depth];\n\t\t\t// Figure out if it's LWZ or LWZX\n\t\t\tif((instruction & 0xfc000000) == PPC_LWZ)\n\t\t\t{\n\t\t\t\t//printf(\"patching LWZ at %p to LFS at depth %ld\\n\",opStackLoadInstructionAddr[depth],depth);\n\t\t\t\t//printf(\"old instruction: %08lx\\n\",instruction);\n\t\t\t\t// Extract registers\n\t\t\t\tdestReg = (instruction >> 21) & 31;\n\t\t\t\taReg    = (instruction >> 16) & 31;\n\t\t\t\timm     = instruction & 0xffff;\n\t\t\t\t\n\t\t\t\t// Calculate correct FP register to use.\n\t\t\t\t// THIS ASSUMES REGISTER USAGE FOR THE STACK IS n, n+1, n+2, etc!\n\t\t\t\t//printf(\"old dest: %ld\\n\",destReg);\n\t\t\t\tdestReg = (destReg - opStackIntRegisters[0]) + opStackFloatRegisters[0];\n\t\t\t\tinstruction = PPC_LFS | ( destReg << 21 ) | ( aReg << 16 ) | imm ;\t\t\t\n\t\t\t\t//printf(\"new dest: %ld\\n\",destReg);\n\t\t\t\t//printf(\"new instruction: %08lx\\n\",instruction);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t//printf(\"patching LWZX at %p to LFSX at depth %ld\\n\",opStackLoadInstructionAddr[depth],depth);\n\t\t\t\t//printf(\"old instruction: %08lx\\n\",instruction);\n\t\t\t\t// Extract registers\n\t\t\t\tdestReg = (instruction >> 21) & 31;\n\t\t\t\taReg    = (instruction >> 16) & 31;\n\t\t\t\tbReg    = (instruction >> 11) & 31;\n\t\t\t\t// Calculate correct FP register to use.\n\t\t\t\t// THIS ASSUMES REGISTER USAGE FOR THE STACK IS n, n+1, n+2, etc!\n\t\t\t\t//printf(\"old dest: %ld\\n\",destReg);\n\t\t\t\tdestReg = (destReg - opStackIntRegisters[0]) + opStackFloatRegisters[0];\n\t\t\t\tinstruction = PPC_LFSX | ( destReg << 21 ) | ( aReg << 16 ) | ( bReg << 11 ) ;\t\t\t\n\t\t\t\t//printf(\"new dest: %ld\\n\",destReg);\n\t\t\t\t//printf(\"new instruction: %08lx\\n\",instruction);\n\t\t\t}\n\t\t\t*opStackLoadInstructionAddr[depth] = instruction;\n\t\t\topStackLoadInstructionAddr[depth] = 0;\n\t\t}\n\t\telse\n\t\t{\t\n\t\t\t//printf(\"doing float constant load at %p for depth %ld\\n\",&buf[compiledOfs],depth);\n\t\t\t// It was likely loaded as a constant so we have to save/load it.  A more\n\t\t\t// interesting implementation might be to generate code to do a \"PC relative\"\n\t\t\t// load from the VM code region.\n\t\t\tInstImm( \"stw\", PPC_STW, opStackIntRegisters[depth], R_OPSTACK, depth*4+4);\n\t\t\t// For XXX make sure we force enough NOPs to get the load into\n\t\t\t// another dispatch group to avoid pipeline flush.\n\t\t\tInst( \"ori\", PPC_ORI,  0, 0, 0 );\n\t\t\tInst( \"ori\", PPC_ORI,  0, 0, 0 );\n\t\t\tInst( \"ori\", PPC_ORI,  0, 0, 0 );\n\t\t\tInst( \"ori\", PPC_ORI,  0, 0, 0 );\n\t\t\tInstImm( \"lfs\", PPC_LFS, opStackFloatRegisters[depth], R_OPSTACK, depth*4+4);\n\t\t}\n\t\topStackRegType[depth] = 2;\n\t}\n}\n\n// TJW: Unused\n#if 0\nstatic void fltop() {\n    if (rtopped == qfalse) {\n\tInstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 );\t\t// get value from opstack\n    }\n}\n#endif\n\n#if 0\nstatic void fltopandsecond() {\n\tInstImm( PPC_LFS, R_TOP, R_OPSTACK, 0 );\t\t// get value from opstack\n\tInstImm( PPC_LFS, R_SECOND, R_OPSTACK, -4 );\t// get value from opstack\n\tInstImm( PPC_ADDI, R_OPSTACK, R_OPSTACK, -8 );\n    rtopped = qfalse;\n\treturn;\n}\n#endif\n\n#define assertInteger(depth)\tassert(opStackRegType[depth] == 1)\n\n/*\n=================\nVM_Compile\n=================\n*/\nvoid VM_Compile( vm_t *vm, vmHeader_t *header ) {\n\tint\t\top;\n\tint\t\tmaxLength;\n\tint\t\tv;\n\tint\t\ti;\n        int\t\topStackDepth;\n\t\n\tint\t\tmainFunction;\n\t\n\t// set up the into-to-float variables\n   \t((int *)itofConvert)[0] = 0x43300000;\n   \t((int *)itofConvert)[1] = 0x80000000;\n   \t((int *)itofConvert)[2] = 0x43300000;\n\n\t// allocate a very large temp buffer, we will shrink it later\n\tmaxLength = header->codeLength * 8;\n\tbuf = Z_Malloc( maxLength );\n\tjused = Z_Malloc(header->instructionCount + 2);\n\tCom_Memset(jused, 0, header->instructionCount+2);\n\t\n    // compile everything twice, so the second pass will have valid instruction\n    // pointers for branches\n    for ( pass = -1 ; pass < 2 ; pass++ ) {\n\n        // translate all instructions\n        pc = 0;\n\tmainFunction = 0;\n\topStackDepth = 0;\n\t\n\tpop0 = 343545;\n\tpop1 = 2443545;\n\toc0 = -2343535;\n\toc1 = 24353454;\n\ttvm = vm;\n        code = (byte *)header + header->codeOffset;\n        compiledOfs = 0;\n#ifndef __GNUC__\n\t\t// metrowerks seems to require this header in front of functions\n\t\tEmit4( (int)(buf+2) );\n\t\tEmit4( 0 );\n#endif\n\n\tfor ( instruction = 0 ; instruction < header->instructionCount ; instruction++ ) {\n            if ( compiledOfs*4 > maxLength - 16 ) {\n                Com_Error( ERR_DROP, \"VM_Compile: maxLength exceeded\" );\n            }\n\n            op = code[ pc ];\n            if ( !pass ) {\n                vm->instructionPointers[ instruction ] = compiledOfs * 4;\n            }\n            pc++;\n            switch ( op ) {\n            case 0:\n                break;\n            case OP_BREAK:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\t\tprintf(\"%08lx BREAK\\n\",instruction);\n\t\t#endif\n                InstImmU( \"addi\", PPC_ADDI, R_TOP, 0, 0 );\n                InstImm( \"lwz\", PPC_LWZ, R_TOP, R_TOP, 0 );\t\t\t// *(int *)0 to crash to debugger\n                break;\n            case OP_ENTER:\n\t\topStackDepth = 0;\n\t\tv = Constant4();\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\t\tprintf(\"%08x ENTER\\t%04x\\n\",instruction,v);\n\t\t#endif\n\t\topStackRegType[opStackDepth] = 0;\n\t\tmainFunction++;\n\t\tif(mainFunction == 1)\n\t\t{\n\t\t\t// Main VM entry point is the first thing we compile, so save off operand stack\n\t\t\t// registers here.  This avoids issues with trying to trick the native compiler\n\t\t\t// into doing it, and properly matches the PowerPC ABI\n\t\t\tInstImm( \"addi\", PPC_ADDI, R_REAL_STACK, R_REAL_STACK, -OP_STACK_MAX_DEPTH*4 );\t// sub R_STACK, R_STACK, imm\n\t\t\tfor(i = 0; i < OP_STACK_MAX_DEPTH; i++)\n\t\t\t\tInstImm( \"stw\", PPC_STW, opStackIntRegisters[i], R_REAL_STACK, i*4);\n\t\t}\n                InstImm( \"addi\", PPC_ADDI, R_STACK, R_STACK, -v );\t// sub R_STACK, R_STACK, imm\n                break;\n            case OP_CONST:\n                v = Constant4();\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\t\tprintf(\"%08x CONST\\t%08x\\n\",instruction,v);\n\t\t#endif\n\t\topStackLoadInstructionAddr[opStackDepth] = 0;\n                if ( v < 32768 && v >= -32768 ) {\n                    InstImmU( \"addi\", PPC_ADDI, opStackIntRegisters[opStackDepth], 0, v & 0xffff );\n                } else {\n                    InstImmU( \"addis\", PPC_ADDIS, opStackIntRegisters[opStackDepth], 0, (v >> 16)&0xffff );\n                    if ( v & 0xffff ) {\n                        InstImmU( \"ori\", PPC_ORI, opStackIntRegisters[opStackDepth], opStackIntRegisters[opStackDepth], v & 0xffff );\n                    }\n                }\n\t\topStackRegType[opStackDepth] = 1;\n\t\topStackDepth += 1;\n\t\tif (code[pc] == OP_JUMP) {\n\t\t    jused[v] = 1;\n\t\t}\n\t\tbreak;\n            case OP_LOCAL:\n\t\toc1 = Constant4();\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\t\tprintf(\"%08x LOCAL\\t%08x\\n\",instruction,oc1);\n\t\t#endif\n\t\tif (code[pc] == OP_LOAD4 || code[pc] == OP_LOAD2 || code[pc] == OP_LOAD1) {\n\t\t    oc1 &= vm->dataMask;\n\t\t}\n                InstImm( \"addi\", PPC_ADDI, opStackIntRegisters[opStackDepth], R_STACK, oc1 );\n\t\topStackRegType[opStackDepth] = 1;\n\t\topStackLoadInstructionAddr[opStackDepth] = 0;\n\t\topStackDepth += 1;\n                break;\n            case OP_ARG:\n\t\tv = Constant1();\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\t\tprintf(\"%08x ARG \\t%08x\\n\",instruction,v);\n\t\t#endif\n                InstImm( \"addi\", PPC_ADDI, R_EA, R_STACK, v );\t// location to put it\n\t\tif(opStackRegType[opStackDepth-1] == 1)\n\t\t\tInst( \"stwx\", PPC_STWX, opStackIntRegisters[opStackDepth-1], R_EA, R_MEMBASE );\n\t\telse\n\t\t\tInst( \"stfsx\", PPC_STFSX, opStackFloatRegisters[opStackDepth-1], R_EA, R_MEMBASE );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackDepth -= 1;\n\t\t\n                break;\n            case OP_CALL:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\t\tprintf(\"%08x CALL\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassert(opStackDepth > 0);\n                Inst( \"mflr\", PPC_MFSPR, R_SECOND, 8, 0 );\t\t\t// move from link register\n                InstImm( \"stwu\", PPC_STWU, R_SECOND, R_REAL_STACK, -16 );\t// save off the old return address\n\n\t\t// Spill operand stack registers.\n\t\tspillOpStack(opStackDepth);\n\t\t\n\t\t// We need to leave R_OPSTACK pointing to the top entry on the stack, which is the call address.\n\t\t// It will be consumed (and R4 decremented) by the AsmCall code.\n\t\tInstImm( \"addi\", PPC_ADDI, R_OPSTACK, R_OPSTACK, opStackDepth*4);\n\n                Inst( \"mtctr\", PPC_MTSPR, R_ASMCALL, 9, 0 );\t\t\t// move to count register\n                Inst( \"bctrl\", PPC_BCCTR | 1, 20, 0, 0 );\t\t\t// jump and link to the count register\n\n\t\t// R4 now points to the top of the operand stack, which has the return value in it.  We want to\n\t\t// back off the pointer to point to the base of our local operand stack and then reload the stack.\n\t\t\n\t\tInstImm(\"addi\", PPC_ADDI, R_OPSTACK, R_OPSTACK, -opStackDepth*4);\n\t\t\n\t\t// Reload operand stack.\n\t\tloadOpStack(opStackDepth);\n\n                InstImm( \"lwz\", PPC_LWZ, R_SECOND, R_REAL_STACK, 0 );\t\t// fetch the old return address\n                InstImm( \"addi\", PPC_ADDI, R_REAL_STACK, R_REAL_STACK, 16 );\n                Inst( \"mtlr\", PPC_MTSPR, R_SECOND, 8, 0 );\t\t\t// move to link register\n                break;\n            case OP_PUSH:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\t\tprintf(\"%08x PUSH\\n\",instruction);\n\t\t#endif\n\t\topStackRegType[opStackDepth] = 1; \t// Garbage int value.\n\t\topStackDepth += 1;\n                break;\n            case OP_POP:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\t\tprintf(\"%08x POP\\n\",instruction);\n\t\t#endif\n\t\topStackDepth -= 1;\n\t\topStackRegType[opStackDepth] = 0; \t// ??\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n                break;\n            case OP_LEAVE:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\t\tprintf(\"%08x LEAVE\\n\",instruction);\n\t\t#endif\n\t\tassert(opStackDepth == 1);\n\t\tassert(opStackRegType[0] != 0);\n\t\t// Save return value onto top of op stack.  We also have to increment R_OPSTACK\n\t\tswitch(opStackRegType[0])\n\t\t{\n\t\t\tcase 1:\t// Integer register\n\t\t\t\tInstImm( \"stw\", PPC_STWU, opStackIntRegisters[0], R_OPSTACK, 4);\n\t\t\t\tbreak;\n\t\t\tcase 2: // Float register\n\t\t\t\tInstImm( \"stfs\", PPC_STFSU, opStackFloatRegisters[0], R_OPSTACK, 4);\n\t\t\t\tbreak;\n\t\t}\n                InstImm( \"addi\", PPC_ADDI, R_STACK, R_STACK, Constant4() );\t// add R_STACK, R_STACK, imm\n\t\tif(mainFunction == 1)\n\t\t{\n\t\t\tfor(i = 0; i < OP_STACK_MAX_DEPTH; i++)\n\t\t\t\tInstImm( \"lwz\", PPC_LWZ,  opStackIntRegisters[i], R_REAL_STACK, i*4);\n\t\t\tInstImm( \"addi\", PPC_ADDI, R_REAL_STACK, R_REAL_STACK, OP_STACK_MAX_DEPTH*4 );\t\n\t\t}\n\t\topStackDepth--;\n\t\topStackRegType[opStackDepth] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth] = 0;\n                Inst( \"blr\", PPC_BCLR, 20, 0, 0 );\t\t\t\t\t\t\t// branch unconditionally to link register\n                break;\n            case OP_LOAD4:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\t\tprintf(\"%08x LOAD4\\n\",instruction);\n\t\t#endif\n\t\t// We should try to figure out whether to use LWZX or LFSX based\n\t\t// on some kind of code analysis after subsequent passes.  I think what\n\t\t// we could do is store the compiled load instruction address along with\n\t\t// the register type.  When we hit the first mismatched operator, we go back\n\t\t// and patch the load.  Since LCC's operand stack should be at 0 depth by the\n\t\t// time we hit a branch, this should work fairly well.  FIXME FIXME FIXME.\n\t\tassertInteger(opStackDepth-1);\n\t\topStackLoadInstructionAddr[opStackDepth-1] = &buf[ compiledOfs ];\n                Inst( \"lwzx\", PPC_LWZX, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], R_MEMBASE );// load from memory base\n\t\topStackRegType[opStackDepth-1] = 1;\n                break;\n            case OP_LOAD2:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\t\tprintf(\"%08x LOAD2\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n                Inst( \"lhzx\", PPC_LHZX, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], R_MEMBASE );// load from memory base\n\t\topStackRegType[opStackDepth-1] = 1;\n                break;\n            case OP_LOAD1:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\t\tprintf(\"%08x LOAD1\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n                Inst( \"lbzx\", PPC_LBZX, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], R_MEMBASE );// load from memory base\n\t\topStackRegType[opStackDepth-1] = 1;\n                break;\n            case OP_STORE4:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\t\tprintf(\"%08x STORE4\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-2);\n\t\tif(opStackRegType[opStackDepth-1] == 1)\n\t\t\tInst( \"stwx\", PPC_STWX, opStackIntRegisters[opStackDepth-1], \n\t\t\t\t\topStackIntRegisters[opStackDepth-2], R_MEMBASE );\t\t// store from memory base\n\t\telse\n\t\t\tInst( \"stfsx\", PPC_STFSX, opStackFloatRegisters[opStackDepth-1], \n\t\t\t\t\topStackIntRegisters[opStackDepth-2], R_MEMBASE );\t\t// store from memory base\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackRegType[opStackDepth-2] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-2] = 0;\n\t\topStackDepth -= 2;\n                break;\n            case OP_STORE2:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\t\tprintf(\"%08x STORE2\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"sthx\", PPC_STHX, opStackIntRegisters[opStackDepth-1],\n\t\t\t\topStackIntRegisters[opStackDepth-2], R_MEMBASE );\t\t// store from memory base\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackRegType[opStackDepth-2] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-2] = 0;\n\t\topStackDepth -= 2;\n                break;\n            case OP_STORE1:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\t\tprintf(\"%08x STORE1\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"stbx\", PPC_STBX, opStackIntRegisters[opStackDepth-1],\n\t\t\t\topStackIntRegisters[opStackDepth-2], R_MEMBASE );\t\t// store from memory base\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackRegType[opStackDepth-2] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-2] = 0;\n\t\topStackDepth -= 2;\n                break;\n\n            case OP_EQ:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\t\tprintf(\"%08x EQ\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"cmp\", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackRegType[opStackDepth-2] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-2] = 0;\n\t\topStackDepth -= 2;\n                i = Constant4();\n\t\t\t\tjused[i] = 1;\n                InstImm( \"bc\", PPC_BC, 4, 2, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];                    \n                } else {\n                    v = 0;             \n                }\n                Emit4(\"b\", PPC_B | (v&0x3ffffff) );\n                break;\n            case OP_NE:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\t\tprintf(\"%08x NE\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"cmp\", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackRegType[opStackDepth-2] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-2] = 0;\n\t\topStackDepth -= 2;\n                i = Constant4();\n\t\t\t\tjused[i] = 1;\n                InstImm( \"bc\", PPC_BC, 12, 2, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];                    \n                } else {\n                    v = 0;\n                }\n                Emit4(\"b\", PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( \"bc\", PPC_BC, 4, 2, v );\n\n                break;\n            case OP_LTI:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x LTI\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"cmp\", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackRegType[opStackDepth-2] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-2] = 0;\n\t\topStackDepth -= 2;\n                i = Constant4();\n\t\t\t\tjused[i] = 1;\n                InstImm( \"bc\", PPC_BC, 4, 0, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(\"b\", PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( \"bc\", PPC_BC, 12, 0, v );\n                break;\n            case OP_LEI:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x LEI\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"cmp\", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackRegType[opStackDepth-2] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-2] = 0;\n\t\topStackDepth -= 2;\n                i = Constant4();\n\t\t\t\tjused[i] = 1;\n                InstImm( \"bc\", PPC_BC, 12, 1, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(\"b\", PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( \"bc\", PPC_BC, 4, 1, v );\n                break;\n            case OP_GTI:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x GTI\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"cmp\", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackRegType[opStackDepth-2] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-2] = 0;\n\t\topStackDepth -= 2;\n                i = Constant4();\n\t\t\t\tjused[i] = 1;\n                InstImm( \"bc\", PPC_BC, 4, 1, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(\"b\", PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( \"bc\", PPC_BC, 12, 1, v );\n                break;\n            case OP_GEI:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x GEI\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"cmp\", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackRegType[opStackDepth-2] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-2] = 0;\n\t\topStackDepth -= 2;\n                i = Constant4();\n\t\t\t\tjused[i] = 1;\n                InstImm( \"bc\", PPC_BC, 12, 0, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(\"b\", PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( \"bc\", PPC_BC, 4, 0, v );\n                break;\n            case OP_LTU:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x LTU\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"cmp\", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackRegType[opStackDepth-2] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-2] = 0;\n\t\topStackDepth -= 2;\n                i = Constant4();\n\t\tjused[i] = 1;\n                InstImm( \"bc\", PPC_BC, 4, 0, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(\"b\", PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( \"bc\", PPC_BC, 12, 0, v );\n                break;\n            case OP_LEU:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x LEU\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"cmp\", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackRegType[opStackDepth-2] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-2] = 0;\n\t\topStackDepth -= 2;\n                i = Constant4();\n\t\tjused[i] = 1;\n                InstImm( \"bc\", PPC_BC, 12, 1, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(\"b\", PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( \"bc\", PPC_BC, 4, 1, v );\n                break;\n            case OP_GTU:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x GTU\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"cmp\", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackRegType[opStackDepth-2] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-2] = 0;\n\t\topStackDepth -= 2;\n                i = Constant4();\n\t\tjused[i] = 1;\n                InstImm( \"bc\", PPC_BC, 4, 1, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(\"b\", PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( \"bc\", PPC_BC, 12, 1, v );\n                break;\n            case OP_GEU:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x GEU\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"cmp\", PPC_CMP, 0, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackRegType[opStackDepth-2] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-2] = 0;\n\t\topStackDepth -= 2;\n                i = Constant4();\n\t\tjused[i] = 1;\n                InstImm( \"bc\", PPC_BC, 12, 0, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(\"b\", PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( \"bc\", PPC_BC, 4, 0, v );\n                break;\n                \n            case OP_EQF:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x EQF\\n\",instruction);\n\t\t#endif\n\t\tmakeFloat(opStackDepth-1);\n\t\tmakeFloat(opStackDepth-2);\n                Inst( \"fcmpu\", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackRegType[opStackDepth-2] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-2] = 0;\n\t\topStackDepth -= 2;\n                i = Constant4();\n\t\tjused[i] = 1;\n                InstImm( \"bc\", PPC_BC, 4, 2, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(\"b\", PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( \"bc\", PPC_BC, 12, 2, v );\n                break;\t\t\t\n            case OP_NEF:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x NEF\\n\",instruction);\n\t\t#endif\n\t\tmakeFloat(opStackDepth-1);\n\t\tmakeFloat(opStackDepth-2);\n                Inst( \"fcmpu\", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackRegType[opStackDepth-2] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-2] = 0;\n\t\topStackDepth -= 2;\n                i = Constant4();\n\t\tjused[i] = 1;\n                InstImm( \"bc\", PPC_BC, 12, 2, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(\"b\", PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( \"bc\", PPC_BC, 4, 2, v );\n                break;\t\t\t\n            case OP_LTF:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x LTF\\n\",instruction);\n\t\t#endif\n\t\tmakeFloat(opStackDepth-1);\n\t\tmakeFloat(opStackDepth-2);\n                Inst( \"fcmpu\", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackRegType[opStackDepth-2] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-2] = 0;\n\t\topStackDepth -= 2;\n                i = Constant4();\n\t\tjused[i] = 1;\n                InstImm( \"bc\", PPC_BC, 4, 0, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(\"b\", PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( \"bc\", PPC_BC, 12, 0, v );\n                break;\t\t\t\n            case OP_LEF:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x LEF\\n\",instruction);\n\t\t#endif\n\t\tmakeFloat(opStackDepth-1);\n\t\tmakeFloat(opStackDepth-2);\n                Inst( \"fcmpu\", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackRegType[opStackDepth-2] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-2] = 0;\n\t\topStackDepth -= 2;\n                i = Constant4();\n\t\tjused[i] = 1;\n                InstImm( \"bc\", PPC_BC, 12, 1, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(\"b\", PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( \"bc\", PPC_BC, 4, 1, v );\n                break;\t\t\t\n            case OP_GTF:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x GTF\\n\",instruction);\n\t\t#endif\n\t\tmakeFloat(opStackDepth-1);\n\t\tmakeFloat(opStackDepth-2);\n                Inst( \"fcmpu\", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackRegType[opStackDepth-2] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-2] = 0;\n\t\topStackDepth -= 2;\n                i = Constant4();\n\t\tjused[i] = 1;\n                InstImm( \"bc\", PPC_BC, 4, 1, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(\"b\", PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( \"bc\", PPC_BC, 12, 1, v );\n                break;\t\t\t\n            case OP_GEF:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x GEF\\n\",instruction);\n\t\t#endif\n\t\tmakeFloat(opStackDepth-1);\n\t\tmakeFloat(opStackDepth-2);\n                Inst( \"fcmpu\", PPC_FCMPU, 0, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackRegType[opStackDepth-2] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-2] = 0;\n\t\topStackDepth -= 2;\n                i = Constant4();\n\t\tjused[i] = 1;\n                InstImm( \"bc\", PPC_BC, 12, 0, 8 );\n                if ( pass==1 ) {\n                    v = vm->instructionPointers[ i ] - (int)&buf[compiledOfs];\n                } else {\n                    v = 0;\n                }\n                Emit4(\"b\", PPC_B | (unsigned int)(v&0x3ffffff) );\n//                InstImm( \"bc\", PPC_BC, 4, 0, v );\n                break;\n\n            case OP_NEGI:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x NEGI\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n                InstImm( \"subfic\", PPC_SUBFIC, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], 0 );\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n                break;\n            case OP_ADD:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x ADD\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"add\", PPC_ADD, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-2] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackDepth -= 1;\n                break;\n            case OP_SUB:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x SUB\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"subf\", PPC_SUBF, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-2] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackDepth -= 1;\n                break;\n            case OP_DIVI:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x DIVI\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"divw\", PPC_DIVW, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackDepth -= 1;\n                break;\n            case OP_DIVU:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x DIVU\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"divwu\", PPC_DIVWU, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackDepth -= 1;\n                break;\n            case OP_MODI:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x MODI\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"divw\", PPC_DIVW, R_EA, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );\n                Inst( \"mullw\", PPC_MULLW, R_EA, opStackIntRegisters[opStackDepth-1], R_EA );\n                Inst( \"subf\", PPC_SUBF, opStackIntRegisters[opStackDepth-2], R_EA, opStackIntRegisters[opStackDepth-2] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackDepth -= 1;\n                break;\n            case OP_MODU:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x MODU\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"divwu\", PPC_DIVWU, R_EA, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );\n                Inst( \"mullw\", PPC_MULLW, R_EA, opStackIntRegisters[opStackDepth-1], R_EA );\n                Inst( \"subf\", PPC_SUBF, opStackIntRegisters[opStackDepth-2], R_EA, opStackIntRegisters[opStackDepth-2] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackDepth -= 1;\n                break;\n            case OP_MULI:\n            case OP_MULU:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x MULI\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"mullw\", PPC_MULLW, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-2] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackDepth -= 1;\n                break;\n            case OP_BAND:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x BAND\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"and\", PPC_AND, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackDepth -= 1;\n                break;\n            case OP_BOR:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x BOR\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"or\", PPC_OR, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackDepth -= 1;\n                break;\n            case OP_BXOR:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x BXOR\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"xor\", PPC_XOR, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackDepth -= 1;\n                break;\n            case OP_BCOM:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x BCOM\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n                Inst( \"nor\", PPC_NOR, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1] );\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n                break;\n            case OP_LSH:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x LSH\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"slw\", PPC_SLW, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackDepth -= 1;\n                break;\n            case OP_RSHI:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x RSHI\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"sraw\", PPC_SRAW, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackDepth -= 1;\n                break;\n            case OP_RSHU:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x RSHU\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                Inst( \"srw\", PPC_SRW, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackDepth -= 1;\n                break;\n\n            case OP_NEGF:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x NEGF\\n\",instruction);\n\t\t#endif\n\t\tmakeFloat(opStackDepth-1);\n                Inst( \"fneg\", PPC_FNEG, opStackFloatRegisters[opStackDepth-1], 0, opStackFloatRegisters[opStackDepth-1] );\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n                break;\n            case OP_ADDF:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x ADDF\\n\",instruction);\n\t\t#endif\n\t\tmakeFloat(opStackDepth-1);\n\t\tmakeFloat(opStackDepth-2);\n                Inst( \"fadds\", PPC_FADDS, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackDepth -= 1;\n                break;\n            case OP_SUBF:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x SUBF\\n\",instruction);\n\t\t#endif\n\t\tmakeFloat(opStackDepth-1);\n\t\tmakeFloat(opStackDepth-2);\n                Inst( \"fsubs\", PPC_FSUBS, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackDepth -= 1;\n                break;\n            case OP_DIVF:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x DIVF\\n\",instruction);\n\t\t#endif\n\t\tmakeFloat(opStackDepth-1);\n\t\tmakeFloat(opStackDepth-2);\n                Inst( \"fdivs\", PPC_FDIVS, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackDepth -= 1;\n                break;\n            case OP_MULF:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x MULF\\n\",instruction);\n\t\t#endif\n\t\tmakeFloat(opStackDepth-1);\n\t\tmakeFloat(opStackDepth-2);\n                Inst4( \"fmuls\", PPC_FMULS, opStackFloatRegisters[opStackDepth-2], opStackFloatRegisters[opStackDepth-2], 0, opStackFloatRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackDepth -= 1;\n                break;\n\n            case OP_CVIF:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x CVIF\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n\t\t//makeInteger(opStackDepth-1);\n                v = (int)&itofConvert;\n                InstImmU( \"addis\", PPC_ADDIS, R_EA, 0, (v >> 16)&0xffff );\n                InstImmU( \"ori\", PPC_ORI, R_EA, R_EA, v & 0xffff );\n                InstImmU( \"xoris\", PPC_XORIS, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], 0x8000 );\n                InstImm( \"stw\", PPC_STW, opStackIntRegisters[opStackDepth-1], R_EA, 12 );\n                InstImm( \"lfd\", PPC_LFD, opStackFloatRegisters[opStackDepth-1], R_EA, 0 );\n\t\tInst( \"ori\", PPC_ORI, 0, 0, 0);\n\t\tInst( \"ori\", PPC_ORI, 0, 0, 0);\n\t\tInst( \"ori\", PPC_ORI, 0, 0, 0);\n                InstImm( \"lfd\", PPC_LFD, 13, R_EA, 8 );\n                Inst( \"fsub\", PPC_FSUB, opStackFloatRegisters[opStackDepth-1], 13, opStackFloatRegisters[opStackDepth-1] );\n\t\topStackRegType[opStackDepth-1] = 2;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n    //            Inst( PPC_FRSP, R_TOP, 0, R_TOP );\n                break;\n            case OP_CVFI:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x CVFI\\n\",instruction);\n\t\t#endif\n\t\tmakeFloat(opStackDepth-1);\n\n\t\tInstImm( \"addi\", PPC_ADDI, R_OPSTACK, R_OPSTACK, opStackDepth*4);\n\n                Inst( \"fctiwz\", PPC_FCTIWZ, opStackFloatRegisters[opStackDepth-1], 0, opStackFloatRegisters[opStackDepth-1] );\n                Inst( \"stfiwx\", PPC_STFIWX, opStackFloatRegisters[opStackDepth-1], 0, R_OPSTACK );\t\t// save value to opstack (dummy area now)\n\t\tInst( \"ori\", PPC_ORI, 0, 0, 0);\n\t\tInst( \"ori\", PPC_ORI, 0, 0, 0);\n\t\tInst( \"ori\", PPC_ORI, 0, 0, 0);\n\t\tInst( \"ori\", PPC_ORI, 0, 0, 0);\n                InstImm( \"lwz\", PPC_LWZ, opStackIntRegisters[opStackDepth-1], R_OPSTACK, 0 );\n\t\t\n\t\tInstImm( \"addi\", PPC_ADDI, R_OPSTACK, R_OPSTACK, -opStackDepth*4);\n\t\t\n\t\topStackRegType[opStackDepth-1] = 1;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n                break;\n            case OP_SEX8:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x SEX8\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n                Inst( \"extsb\", PPC_EXTSB, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], 0 );\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n                break;\n            case OP_SEX16:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x SEX16\\n\",instruction);\n\t\t#endif\n\t\tassertInteger(opStackDepth-1);\n                Inst( \"extsh\", PPC_EXTSH, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], 0 );\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n                break;\n\n            case OP_BLOCK_COPY:\n                v = Constant4() >> 2;\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x BLOCK_COPY\\t%08lx\\n\",instruction,v<<2);\n\t\t#endif\n\t\tassert(opStackDepth >= 2);\n\t\tassertInteger(opStackDepth-1);\n\t\tassertInteger(opStackDepth-2);\n                InstImmU( \"addi\", PPC_ADDI, R_EA, 0, v );\t\t\t\t// count\n\t\t\t\t// FIXME: range check\n              \tInst( \"mtctr\", PPC_MTSPR, R_EA, 9, 0 );\t\t\t\t\t// move to count register\n\n                Inst( \"add\", PPC_ADD, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], R_MEMBASE );\n                InstImm( \"addi\", PPC_ADDI, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], -4 );\n                Inst( \"add\", PPC_ADD, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], R_MEMBASE );\n                InstImm( \"addi\", PPC_ADDI, opStackIntRegisters[opStackDepth-2], opStackIntRegisters[opStackDepth-2], -4 );\n\n                InstImm( \"lwzu\", PPC_LWZU, R_EA, opStackIntRegisters[opStackDepth-1], 4 );\t\t// source\n                InstImm( \"stwu\", PPC_STWU, R_EA, opStackIntRegisters[opStackDepth-2], 4 );\t// dest\n                Inst( \"b\", PPC_BC | 0xfff8 , 16, 0, 0 );\t\t\t\t\t// loop\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackRegType[opStackDepth-2] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-2] = 0;\n\t\topStackDepth -= 2;\n                break;\n\n            case OP_JUMP:\n\t\t#if DEBUG_VM\n\t\tif(pass == 1)\n\t\tprintf(\"%08x JUMP\\n\",instruction);\n\t\t#endif\n\t\tassert(opStackDepth == 1);\n\t\tassertInteger(opStackDepth-1);\n\n                Inst( \"rlwinm\", PPC_RLWINM | ( 29 << 1 ), opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], 2 );\n\t\t// FIXME: range check\n\t\tInst( \"lwzx\", PPC_LWZX, opStackIntRegisters[opStackDepth-1], opStackIntRegisters[opStackDepth-1], R_INSTRUCTIONS );\n                Inst( \"mtctr\", PPC_MTSPR, opStackIntRegisters[opStackDepth-1], 9, 0 );\t\t// move to count register\n                Inst( \"bctr\", PPC_BCCTR, 20, 0, 0 );\t\t// jump to the count register\n\t\topStackRegType[opStackDepth-1] = 0;\n\t\topStackLoadInstructionAddr[opStackDepth-1] = 0;\n\t\topStackDepth -= 1;\n                break;\n            default:\n                Com_Error( ERR_DROP, \"VM_CompilePPC: bad opcode %i at instruction %i, offset %i\", op, instruction, pc );\n            }\n\t    pop0 = pop1;\n\t    pop1 = op;\n\t\tassert(opStackDepth >= 0);\n\t\tassert(opStackDepth < OP_STACK_MAX_DEPTH);\n\t\t\n\t\t//printf(\"%4d\\t%s\\n\",opStackDepth,opnames[op]);\n        }\n\n\tCom_Printf( \"VM file %s pass %d compiled to %i bytes of code\\n\", vm->name, (pass+1), compiledOfs*4 );\n\n    \tif ( pass == 0 ) {\n\t    // copy to an exact size buffer on the hunk\n\t    vm->codeLength = compiledOfs * 4;\n\t    vm->codeBase = Hunk_Alloc( vm->codeLength, h_low );\n\t    Com_Memcpy( vm->codeBase, buf, vm->codeLength );\n\t    \n\t    //printf(\"codeBase: %p\\n\",vm->codeBase);\n\t    \n\t    Z_Free( buf );\n\t\n\t    // offset all the instruction pointers for the new location\n\t    for ( i = 0 ; i < header->instructionCount ; i++ ) {\n\t\tvm->instructionPointers[i] += (int)vm->codeBase;\n\t\t//printf(\"%08x %08lx\\n\",i,vm->instructionPointers[i]);\n\t    }\n\n\t    // go back over it in place now to fixup reletive jump targets\n\t    buf = (unsigned *)vm->codeBase;\n\t}\n    }\n    if(0)\n    {\n\tchar buf[256];\n\tprintf(\"wait..\\n\");\n\tgets(buf);\n    }\n    Z_Free( jused );\n}\n\n/*\n==============\nVM_CallCompiled\n\nThis function is called directly by the generated code\n==============\n*/\nint\tVM_CallCompiled( vm_t *vm, int *args ) {\n\tint\t\tstack[1024];\n\tint\t\tprogramStack;\n\tint\t\tstackOnEntry;\n\tbyte\t*image;\n\n\tcurrentVM = vm;\n\n\t//printf(\"VM_CallCompiled: %p   %08lx %08lx %08lx\\n\",\n\t//\tvm, args[0],args[1],args[2]);\n\t\t\n\t// interpret the code\n\tvm->currentlyInterpreting = qtrue;\n\n\t// we might be called recursively, so this might not be the very top\n\tprogramStack = vm->programStack;\n\tstackOnEntry = programStack;\n\timage = vm->dataBase;\n\t\n\t// set up the stack frame \n\tprogramStack -= 48;\n\n\t*(int *)&image[ programStack + 44] = args[9];\n\t*(int *)&image[ programStack + 40] = args[8];\n\t*(int *)&image[ programStack + 36] = args[7];\n\t*(int *)&image[ programStack + 32] = args[6];\n\t*(int *)&image[ programStack + 28] = args[5];\n\t*(int *)&image[ programStack + 24] = args[4];\n\t*(int *)&image[ programStack + 20] = args[3];\n\t*(int *)&image[ programStack + 16] = args[2];\n\t*(int *)&image[ programStack + 12] = args[1];\n\t*(int *)&image[ programStack + 8 ] = args[0];\n\t*(int *)&image[ programStack + 4 ] = 0;\t// return stack\n\t*(int *)&image[ programStack ] = -1;\t// will terminate the loop on return\n\n\t// Cheesy... manually save registers used by VM call...\n\t// off we go into generated code...\n\t// the PPC calling standard says the parms will all go into R3 - R11, so \n\t// no special asm code is needed here\n#ifdef __GNUC__\n\t((void(*)(int, int, int, int, int, int, int, int))(vm->codeBase))( \n\t\tprogramStack, (int)&stack, \n\t\t(int)image, vm->dataMask, (int)&AsmCall, \n\t\t(int)vm->instructionPointers, vm->instructionPointersLength,\n        (int)vm );\n#else\n\t((void(*)(int, int, int, int, int, int, int, int))(vm->codeBase))( \n\t\tprogramStack, (int)&stack, \n\t\t(int)image, vm->dataMask, *(int *)&AsmCall /* skip function pointer header */, \n\t\t(int)vm->instructionPointers, vm->instructionPointersLength,\n        (int)vm );\n#endif\n\tvm->programStack = stackOnEntry;\n\n    vm->currentlyInterpreting = qfalse;\n\n\treturn stack[1];\n}\n\n\n/*\n==================\nAsmCall\n\nPut this at end of file because gcc messes up debug line numbers \n==================\n*/\n#ifdef __GNUC__\n\nvoid AsmCall( void ) {\nasm (\n     // pop off the destination instruction\n\"    lwz\t\tr12,0(r4)\t\\n\"\t// RG_TOP, 0(RG_OPSTACK)\n\"    addi\tr4,r4,-4\t\t\\n\"\t// RG_OPSTACK, RG_OPSTACK, -4 \\n\"\n\n    // see if it is a system trap\n\"    cmpwi\tr12,0\t\t\t\\n\"\t// RG_TOP, 0 \\n\"\n\"    bc\t\t12,0, systemTrap\t\\n\"\n\n    // calling another VM function, so lookup in instructionPointers\n\"    slwi\tr12,r12,2\t\t\\n\"\t// RG_TOP,RG_TOP,2\n                        // FIXME: range check\n\"    lwzx\tr12, r8, r12\t\t\\n\"\t// RG_TOP, RG_INSTRUCTIONS(RG_TOP)\t\n\"    mtctr\tr12\t\t\t\\n\"\t// RG_TOP\n);\n\n#if defined(MACOS_X) && defined(__OPTIMIZE__)\n    // On Mac OS X, gcc doesn't push a frame when we are optimized, so trying to tear it down results in grave disorder.\n#warning Mac OS X optimization on, not popping GCC AsmCall frame\n#else\n    // Mac OS X Server and unoptimized compiles include a GCC AsmCall frame\n    asm (\n\"\tlwz\t\tr1,0(r1)\t\\n\"\t// pop off the GCC AsmCall frame\n\"\tlmw\t\tr30,-8(r1)\t\\n\"\n);\n#endif\n\nasm (\n\"\t    bcctr\t20,0\t\t\\n\" // when it hits a leave, it will branch to the current link register\n\n    // calling a system trap\n\"systemTrap:\t\t\t\t\\n\"\n\t// convert to positive system call number\n\"\tsubfic\tr12,r12,-1\t\t\\n\"\n\n    // save all our registers, including the current link register\n\"    mflr\tr13\t\t\t\\n\"\t// RG_SECOND\t\t// copy off our link register\n\"\taddi\tr1,r1,-92\t\t\\n\"\t// required 24 byets of linkage, 32 bytes of parameter, plus our saves\n\"    stw\t\tr3,56(r1)\t\\n\"\t// RG_STACK, -36(REAL_STACK)\n\"    stw\t\tr4,60(r1)\t\\n\"\t// RG_OPSTACK, 4(RG_REAL_STACK)\n\"    stw\t\tr5,64(r1)\t\\n\"\t// RG_MEMBASE, 8(RG_REAL_STACK)\n\"    stw\t\tr6,68(r1)\t\\n\"\t// RG_MEMMASK, 12(RG_REAL_STACK)\n\"    stw\t\tr7,72(r1)\t\\n\"\t// RG_ASMCALL, 16(RG_REAL_STACK)\n\"    stw\t\tr8,76(r1)\t\\n\"\t// RG_INSTRUCTIONS, 20(RG_REAL_STACK)\n\"    stw\t\tr9,80(r1)\t\\n\"\t// RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)\n\"    stw\t\tr10,84(r1)\t\\n\"\t// RG_VM, 28(RG_REAL_STACK)\n\"    stw\t\tr13,88(r1)\t\\n\"\t// RG_SECOND, 32(RG_REAL_STACK)\t// link register\n\n    // save the vm stack position to allow recursive VM entry\n\"    addi\tr13,r3,-4\t\t\\n\"\t// RG_TOP, RG_STACK, -4\n\"    stw\t\tr13,0(r10)\t\\n\"\t//RG_TOP, VM_OFFSET_PROGRAM_STACK(RG_VM)\n\n    // save the system call number as the 0th parameter\n\"    add\t\tr3,r3,r5\t\\n\"\t// r3,  RG_STACK, RG_MEMBASE\t\t// r3 is the first parameter to vm->systemCalls\n\"    stwu\tr12,4(r3)\t\t\\n\"\t// RG_TOP, 4(r3)\n\n    // make the system call with the address of all the VM parms as a parameter\n    // vm->systemCalls( &parms )\n\"    lwz\t\tr12,4(r10)\t\\n\"\t// RG_TOP, VM_OFFSET_SYSTEM_CALL(RG_VM)\n\"    mtctr\tr12\t\t\t\\n\"\t// RG_TOP\n\"    bcctrl\t20,0\t\t\t\\n\"\n\"    mr\t\tr12,r3\t\t\t\\n\"\t// RG_TOP, r3\n\n    // pop our saved registers\n\"   \tlwz\t\tr3,56(r1)\t\\n\"\t// RG_STACK, 0(RG_REAL_STACK)\n\"   \tlwz\t\tr4,60(r1)\t\\n\"\t// RG_OPSTACK, 4(RG_REAL_STACK)\n\"   \tlwz\t\tr5,64(r1)\t\\n\"\t// RG_MEMBASE, 8(RG_REAL_STACK)\n\"   \tlwz\t\tr6,68(r1)\t\\n\"\t// RG_MEMMASK, 12(RG_REAL_STACK)\n\"   \tlwz\t\tr7,72(r1)\t\\n\"\t// RG_ASMCALL, 16(RG_REAL_STACK)\n\"   \tlwz\t\tr8,76(r1)\t\\n\"\t// RG_INSTRUCTIONS, 20(RG_REAL_STACK)\n\"   \tlwz\t\tr9,80(r1)\t\\n\"\t// RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)\n\"   \tlwz\t\tr10,84(r1)\t\\n\"\t// RG_VM, 28(RG_REAL_STACK)\n\"   \tlwz\t\tr13,88(r1)\t\\n\"\t// RG_SECOND, 32(RG_REAL_STACK)\n\"    addi\tr1,r1,92\t\t\\n\"\t// RG_REAL_STACK, RG_REAL_STACK, 36\n\n    // restore the old link register\n\"    mtlr\tr13\t\t\t\\n\"\t// RG_SECOND\n\n    // save off the return value\n\"    stwu\tr12,4(r4)\t\t\\n\"\t// RG_TOP, 0(RG_OPSTACK)\n\n\t// GCC adds its own prolog / epliog code\n );\n}\n#else\n\n// codewarrior version\n\nvoid asm AsmCall( void ) {\n\n    // pop off the destination instruction\n\n    lwz\t\tr12,0(r4)\t// RG_TOP, 0(RG_OPSTACK)\n\n    addi\tr4,r4,-4\t// RG_OPSTACK, RG_OPSTACK, -4\n\n\n\n    // see if it is a system trap\n\n    cmpwi\tr12,0\t\t// RG_TOP, 0\n\n    bc\t\t12,0, systemTrap\n\n\n\n    // calling another VM function, so lookup in instructionPointers\n\n    slwi\tr12,r12,2\t\t// RG_TOP,RG_TOP,2\n\n                        // FIXME: range check\n\n    lwzx\tr12, r8, r12\t// RG_TOP, RG_INSTRUCTIONS(RG_TOP)\t\n\n    mtctr\tr12\t\t\t// RG_TOP\n\n\n\n    bcctr\t20,0\t\t// when it hits a leave, it will branch to the current link register\n\n\n\n    // calling a system trap\n\nsystemTrap:\n\n\t// convert to positive system call number\n\n\tsubfic\tr12,r12,-1\n\n\n\n    // save all our registers, including the current link register\n\n    mflr\tr13\t\t\t// RG_SECOND\t\t// copy off our link register\n\n\taddi\tr1,r1,-92\t// required 24 byets of linkage, 32 bytes of parameter, plus our saves\n\n    stw\t\tr3,56(r1)\t// RG_STACK, -36(REAL_STACK)\n\n    stw\t\tr4,60(r1)\t// RG_OPSTACK, 4(RG_REAL_STACK)\n\n    stw\t\tr5,64(r1)\t// RG_MEMBASE, 8(RG_REAL_STACK)\n\n    stw\t\tr6,68(r1)\t// RG_MEMMASK, 12(RG_REAL_STACK)\n\n    stw\t\tr7,72(r1)\t// RG_ASMCALL, 16(RG_REAL_STACK)\n\n    stw\t\tr8,76(r1)\t// RG_INSTRUCTIONS, 20(RG_REAL_STACK)\n\n    stw\t\tr9,80(r1)\t// RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)\n\n    stw\t\tr10,84(r1)\t// RG_VM, 28(RG_REAL_STACK)\n\n    stw\t\tr13,88(r1)\t// RG_SECOND, 32(RG_REAL_STACK)\t// link register\n\n\n\n    // save the vm stack position to allow recursive VM entry\n\n    addi\tr13,r3,-4\t// RG_TOP, RG_STACK, -4\n\n    stw\t\tr13,0(r10)\t//RG_TOP, VM_OFFSET_PROGRAM_STACK(RG_VM)\n\n\n\n    // save the system call number as the 0th parameter\n\n    add\t\tr3,r3,r5\t// r3,  RG_STACK, RG_MEMBASE\t\t// r3 is the first parameter to vm->systemCalls\n\n    stwu\tr12,4(r3)\t// RG_TOP, 4(r3)\n\n\n\n    // make the system call with the address of all the VM parms as a parameter\n\n    // vm->systemCalls( &parms )\n\n    lwz\t\tr12,4(r10)\t// RG_TOP, VM_OFFSET_SYSTEM_CALL(RG_VM)\n\n    \n\n    // perform macos cross fragment fixup crap\n\n    lwz\t\tr9,0(r12)\n\n    stw\t\tr2,52(r1)\t// save old TOC\n\n\tlwz\t\tr2,4(r12)\n\n\t    \n\n    mtctr\tr9\t\t\t// RG_TOP\n\n    bcctrl\t20,0\n\n    \n\n    lwz\t\tr2,52(r1)\t// restore TOC\n\n    \n\n    mr\t\tr12,r3\t\t// RG_TOP, r3\n\n\n\n    // pop our saved registers\n\n   \tlwz\t\tr3,56(r1)\t// RG_STACK, 0(RG_REAL_STACK)\n\n   \tlwz\t\tr4,60(r1)\t// RG_OPSTACK, 4(RG_REAL_STACK)\n\n   \tlwz\t\tr5,64(r1)\t// RG_MEMBASE, 8(RG_REAL_STACK)\n\n   \tlwz\t\tr6,68(r1)\t// RG_MEMMASK, 12(RG_REAL_STACK)\n\n   \tlwz\t\tr7,72(r1)\t// RG_ASMCALL, 16(RG_REAL_STACK)\n\n   \tlwz\t\tr8,76(r1)\t// RG_INSTRUCTIONS, 20(RG_REAL_STACK)\n\n   \tlwz\t\tr9,80(r1)\t// RG_NUM_INSTRUCTIONS, 24(RG_REAL_STACK)\n\n   \tlwz\t\tr10,84(r1)\t// RG_VM, 28(RG_REAL_STACK)\n\n   \tlwz\t\tr13,88(r1)\t// RG_SECOND, 32(RG_REAL_STACK)\n\n    addi\tr1,r1,92\t// RG_REAL_STACK, RG_REAL_STACK, 36\n\n\n\n    // restore the old link register\n\n    mtlr\tr13\t\t\t// RG_SECOND\n\n\n\n    // save off the return value\n\n    stwu\tr12,4(r4)\t// RG_TOP, 0(RG_OPSTACK)\n\n\n\n\tblr\n\n}\n\n\n\n\n#endif\n"
  },
  {
    "path": "code/qcommon/vm_x86.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// vm_x86.c -- load time compiler and execution environment for x86\n\n#include \"vm_local.h\"\n\n#ifdef __FreeBSD__ // rb0101023\n#include <sys/types.h>\n#endif\n\n#ifndef _WIN32\n#include <sys/mman.h> // for PROT_ stuff\n#endif\n\n/*\n\n  eax\tscratch\n  ebx\tscratch\n  ecx\tscratch (required for shifts)\n  edx\tscratch (required for divisions)\n  esi\tprogram stack\n  edi\topstack\n\n*/\n\n// TTimo: initialised the statics, this fixes a crash when entering a compiled VM \nstatic\tbyte\t*buf = NULL;\nstatic\tbyte\t*jused = NULL;\nstatic\tint\t\tcompiledOfs = 0;\nstatic\tbyte\t*code = NULL;\nstatic\tint\t\tpc = 0;\n\nstatic\tint\t\t*instructionPointers = NULL;\n\n#define FTOL_PTR\n\n#ifdef _WIN32\n\n#if defined( FTOL_PTR )\nint _ftol( float );\nstatic\tint\t\tftolPtr = (int)_ftol;\n#endif\n\nvoid AsmCall( void );\nstatic\tint\t\tasmCallPtr = (int)AsmCall;\n\n#else // _WIN32\n\n#if defined( FTOL_PTR )\n// bk001213 - BEWARE: does not work! UI menu etc. broken - stack!\n// bk001119 - added: int gftol( float x ) { return (int)x; }\n\nint qftol( void );     // bk001213 - label, see unix/ftol.nasm\nint qftol027F( void ); // bk001215 - fixed FPU control variants\nint qftol037F( void );\nint qftol0E7F( void ); // bk010102 - fixed bogus bits (duh)\nint qftol0F7F( void );\n\n\nstatic\tint\t\tftolPtr = (int)qftol0F7F;\n#endif // FTOL_PTR\n\nvoid doAsmCall( void );\nstatic\tint\t\tasmCallPtr = (int)doAsmCall;\n#endif // !_WIN32\n\n\nstatic\tint\t\tcallMask = 0; // bk001213 - init\n\nstatic\tint\tinstruction, pass;\nstatic\tint\tlastConst = 0;\nstatic\tint\toc0, oc1, pop0, pop1;\n\ntypedef enum \n{\n\tLAST_COMMAND_NONE\t= 0,\n\tLAST_COMMAND_MOV_EDI_EAX,\n\tLAST_COMMAND_SUB_DI_4,\n\tLAST_COMMAND_SUB_DI_8,\n} ELastCommand;\n\nstatic\tELastCommand\tLastCommand;\n\n/*\n=================\nAsmCall\n=================\n*/\n#ifdef _WIN32\n__declspec( naked ) void AsmCall( void ) {\nint\t\tprogramStack;\nint\t\t*opStack;\nint\t\tsyscallNum;\nvm_t*\tsavedVM;\n\n__asm {\n\tmov\t\teax, dword ptr [edi]\n\tsub\t\tedi, 4\n\tor\t\teax,eax\n\tjl\t\tsystemCall\n\t// calling another vm function\n\tshl\t\teax,2\n\tadd\t\teax, dword ptr [instructionPointers]\n\tcall\tdword ptr [eax]\n\tmov\t\teax, dword ptr [edi]\n\tand\t\teax, [callMask]\n\tret\nsystemCall:\n\n\t// convert negative num to system call number\n\t// and store right before the first arg\n\tneg\t\teax\n\tdec\t\teax\n\n\tpush    ebp\n\tmov     ebp, esp\n\tsub     esp, __LOCAL_SIZE\n\n\tmov\t\tdword ptr syscallNum, eax\t// so C code can get at it\n\tmov\t\tdword ptr programStack, esi\t// so C code can get at it\n\tmov\t\tdword ptr opStack, edi\n\n\tpush\tecx\n\tpush\tesi\t\t\t\t\t\t\t// we may call recursively, so the\n\tpush\tedi\t\t\t\t\t\t\t// statics aren't guaranteed to be around\n}\n\n\tsavedVM = currentVM;\n\n\t// save the stack to allow recursive VM entry\n\tcurrentVM->programStack = programStack - 4;\n\t*(int *)((byte *)currentVM->dataBase + programStack + 4) = syscallNum;\n//VM_LogSyscalls(  (int *)((byte *)currentVM->dataBase + programStack + 4) );\n\t*(opStack+1) = currentVM->systemCall( (int *)((byte *)currentVM->dataBase + programStack + 4) );\n\n\tcurrentVM = savedVM;\n\n_asm {\n\tpop\t\tedi\n\tpop\t\tesi\n\tpop\t\tecx\n\tadd\t\tedi, 4\t\t// we added the return value\n\n\tmov     esp, ebp\n\tpop     ebp\n\n\tret\n}\n\n}\n\n#else //!_WIN32\n\nstatic\tint\t\tcallProgramStack;\nstatic\tint\t\t*callOpStack;\nstatic\tint\t\tcallSyscallNum;\n\nvoid callAsmCall(void)\n{\n\tvm_t\t*savedVM;\n\tint\t\t*callOpStack2;\n\n\tsavedVM = currentVM;\n\tcallOpStack2 = callOpStack;\n\n\t// save the stack to allow recursive VM entry\n\tcurrentVM->programStack = callProgramStack - 4;\n\t*(int *)((byte *)currentVM->dataBase + callProgramStack + 4) = callSyscallNum;\n//VM_LogSyscalls(  (int *)((byte *)currentVM->dataBase + programStack + 4) );\n\t*(callOpStack2+1) = currentVM->systemCall( (int *)((byte *)currentVM->dataBase + callProgramStack + 4) );\n\n \tcurrentVM = savedVM;\n}\n\nvoid AsmCall( void ) {\n\t__asm__(\"doAsmCall:      \t\t\t\\n\\t\" \\\n\t\t\t\"\tmovl (%%edi),%%eax\t\t\t\\n\\t\" \\\n\t\t\t\"\tsubl $4,%%edi\t\t\t\t\\n\\t\" \\\n\t\t\t\"   orl %%eax,%%eax\t\t\t\t\\n\\t\" \\\n\t\t\t\"\tjl systemCall\t\t\t\t\\n\\t\" \\\n\t\t\t\"\tshll $2,%%eax\t\t\t\t\\n\\t\" \\\n\t\t\t\"\taddl %3,%%eax\t\t\t\t\\n\\t\" \\\n\t\t\t\"\tcall *(%%eax)\t\t\t\t\\n\\t\" \\\n\t\t  \" movl (%%edi),%%eax   \\n\\t\" \\\n\t    \" andl callMask, %%eax \\n\\t\" \\\n\t\t\t\"\tjmp doret\t\t\t\t\t   \\n\\t\" \\\n\t\t\t\"systemCall:\t\t\t\t\t\\n\\t\" \\\n\t\t\t\"\tnegl %%eax\t\t\t\t\t\\n\\t\" \\\n\t\t\t\"\tdecl %%eax\t\t\t\t\t\\n\\t\" \\\n\t\t\t\"\tmovl %%eax,%0\t\t\t\t\\n\\t\" \\\n\t\t\t\"\tmovl %%esi,%1\t\t\t\t\\n\\t\" \\\n\t\t\t\"\tmovl %%edi,%2\t\t\t\t\\n\\t\" \\\n\t\t\t\"\tpushl %%ecx\t\t\t\t\t\\n\\t\" \\\n\t\t\t\"\tpushl %%esi\t\t\t\t\t\\n\\t\" \\\n\t\t\t\"\tpushl %%edi\t\t\t\t\t\\n\\t\" \\\n\t\t\t\"\tcall callAsmCall\t\t\t\\n\\t\" \\\n\t\t\t\"\tpopl %%edi\t\t\t\t\t\\n\\t\" \\\n\t\t\t\"\tpopl %%esi\t\t\t\t\t\\n\\t\" \\\n\t\t\t\"\tpopl %%ecx\t\t\t\t\t\\n\\t\" \\\n\t\t\t\"\taddl $4,%%edi\t\t\t\t\\n\\t\" \\\n\t\t\t\"doret:\t\t\t\t\t\t\t\\n\\t\" \\\n\t\t\t\"\tret\t\t\t\t\t\t\t\\n\\t\" \\\n\t\t\t: \"=rm\" (callSyscallNum), \"=rm\" (callProgramStack), \"=rm\" (callOpStack) \\\n\t\t\t: \"rm\" (instructionPointers) \\\n\t\t\t: \"ax\", \"di\", \"si\", \"cx\" \\\n\t);\n}\n#endif\n\nstatic int\tConstant4( void ) {\n\tint\t\tv;\n\n\tv = code[pc] | (code[pc+1]<<8) | (code[pc+2]<<16) | (code[pc+3]<<24);\n\tpc += 4;\n\treturn v;\n}\n\nstatic int\tConstant1( void ) {\n\tint\t\tv;\n\n\tv = code[pc];\n\tpc += 1;\n\treturn v;\n}\n\nstatic void Emit1( int v ) \n{\n\tbuf[ compiledOfs ] = v;\n\tcompiledOfs++;\n\n\tLastCommand = LAST_COMMAND_NONE;\n}\n\n#if 0\nstatic void Emit2( int v ) {\n\tEmit1( v & 255 );\n\tEmit1( ( v >> 8 ) & 255 );\n}\n#endif\n\nstatic void Emit4( int v ) {\n\tEmit1( v & 255 );\n\tEmit1( ( v >> 8 ) & 255 );\n\tEmit1( ( v >> 16 ) & 255 );\n\tEmit1( ( v >> 24 ) & 255 );\n}\n\nstatic int Hex( int c ) {\n\tif ( c >= 'a' && c <= 'f' ) {\n\t\treturn 10 + c - 'a';\n\t}\n\tif ( c >= 'A' && c <= 'F' ) {\n\t\treturn 10 + c - 'A';\n\t}\n\tif ( c >= '0' && c <= '9' ) {\n\t\treturn c - '0';\n\t}\n\n\tCom_Error( ERR_DROP, \"Hex: bad char '%c'\", c );\n\n\treturn 0;\n}\nstatic void EmitString( const char *string ) {\n\tint\t\tc1, c2;\n\tint\t\tv;\n\n\twhile ( 1 ) {\n\t\tc1 = string[0];\n\t\tc2 = string[1];\n\n\t\tv = ( Hex( c1 ) << 4 ) | Hex( c2 );\n\t\tEmit1( v );\n\n\t\tif ( !string[2] ) {\n\t\t\tbreak;\n\t\t}\n\t\tstring += 3;\n\t}\n}\n\n\n\nstatic void EmitCommand(ELastCommand command)\n{\n\tswitch(command)\n\t{\n\t\tcase LAST_COMMAND_MOV_EDI_EAX:\n\t\t\tEmitString( \"89 07\" );\t\t// mov dword ptr [edi], eax\n\t\t\tbreak;\n\n\t\tcase LAST_COMMAND_SUB_DI_4:\n\t\t\tEmitString( \"83 EF 04\" );\t// sub edi, 4\n\t\t\tbreak;\n\n\t\tcase LAST_COMMAND_SUB_DI_8:\n\t\t\tEmitString( \"83 EF 08\" );\t// sub edi, 8\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\tLastCommand = command;\n}\n\nstatic void EmitAddEDI4(vm_t *vm) {\n\tif (LastCommand == LAST_COMMAND_SUB_DI_4 && jused[instruction-1] == 0) \n\t{\t\t// sub di,4\n\t\tcompiledOfs -= 3;\n\t\tvm->instructionPointers[ instruction-1 ] = compiledOfs;\n\t\treturn;\n\t}\n\tif (LastCommand == LAST_COMMAND_SUB_DI_8 && jused[instruction-1] == 0) \n\t{\t\t// sub di,8\n\t\tcompiledOfs -= 3;\n\t\tvm->instructionPointers[ instruction-1 ] = compiledOfs;\n\t\tEmitString( \"83 EF 04\" );\t//\tsub edi,4\n\t\treturn;\n\t}\n\tEmitString( \"83 C7 04\" );\t//\tadd edi,4\n}\n\nstatic void EmitMovEAXEDI(vm_t *vm) {\n\tif (LastCommand == LAST_COMMAND_MOV_EDI_EAX) \n\t{\t// mov [edi], eax\n\t\tcompiledOfs -= 2;\n\t\tvm->instructionPointers[ instruction-1 ] = compiledOfs;\n\t\treturn;\n\t}\n\tif (pop1 == OP_DIVI || pop1 == OP_DIVU || pop1 == OP_MULI || pop1 == OP_MULU ||\n\t\tpop1 == OP_STORE4 || pop1 == OP_STORE2 || pop1 == OP_STORE1 ) \n\t{\t\n\t\treturn;\n\t}\n\tif (pop1 == OP_CONST && buf[compiledOfs-6] == 0xC7 && buf[compiledOfs-5] == 0x07 ) \n\t{\t// mov edi, 0x123456\n\t\tcompiledOfs -= 6;\n\t\tvm->instructionPointers[ instruction-1 ] = compiledOfs;\n\t\tEmitString( \"B8\" );\t\t\t// mov\teax, 0x12345678\n\t\tEmit4( lastConst );\n\t\treturn;\n\t}\n\tEmitString( \"8B 07\" );\t\t// mov eax, dword ptr [edi]\n}\n\nqboolean EmitMovEBXEDI(vm_t *vm, int andit) {\n\tif (LastCommand == LAST_COMMAND_MOV_EDI_EAX) \n\t{\t// mov [edi], eax\n\t\tcompiledOfs -= 2;\n\t\tvm->instructionPointers[ instruction-1 ] = compiledOfs;\n\t\tEmitString( \"8B D8\");\t\t// mov bx, eax\n\t\treturn qfalse;\n\t}\n\tif (pop1 == OP_DIVI || pop1 == OP_DIVU || pop1 == OP_MULI || pop1 == OP_MULU ||\n\t\tpop1 == OP_STORE4 || pop1 == OP_STORE2 || pop1 == OP_STORE1 ) \n\t{\t\n\t\tEmitString( \"8B D8\");\t\t// mov bx, eax\n\t\treturn qfalse;\n\t}\n\tif (pop1 == OP_CONST && buf[compiledOfs-6] == 0xC7 && buf[compiledOfs-5] == 0x07 ) \n\t{\t\t// mov edi, 0x123456\n\t\tcompiledOfs -= 6;\n\t\tvm->instructionPointers[ instruction-1 ] = compiledOfs;\n\t\tEmitString( \"BB\" );\t\t\t// mov\tebx, 0x12345678\n\t\tif (andit) {\n\t\t\tEmit4( lastConst & andit );\n\t\t} else {\n\t\t\tEmit4( lastConst );\n\t\t}\n\t\treturn qtrue;\n\t}\n\n\tEmitString( \"8B 1F\" );\t\t// mov ebx, dword ptr [edi]\n\treturn qfalse;\n}\n\n/*\n=================\nVM_Compile\n=================\n*/\nvoid VM_Compile( vm_t *vm, vmHeader_t *header ) {\n\tint\t\top;\n\tint\t\tmaxLength;\n\tint\t\tv;\n\tint\t\ti;\n\tqboolean opt;\n\n\t// allocate a very large temp buffer, we will shrink it later\n\tmaxLength = header->codeLength * 8;\n\tbuf = Z_Malloc( maxLength );\n\tjused = Z_Malloc(header->instructionCount + 2 );\n\t\n\tCom_Memset(jused, 0, header->instructionCount+2);\n\n\tfor(pass=0;pass<2;pass++) {\n\toc0 = -23423;\n\toc1 = -234354;\n\tpop0 = -43435;\n\tpop1 = -545455;\n\n\t// translate all instructions\n\tpc = 0;\n\tinstruction = 0;\n\tcode = (byte *)header + header->codeOffset;\n\tcompiledOfs = 0;\n\n\tLastCommand = LAST_COMMAND_NONE;\n\n\twhile ( instruction < header->instructionCount ) {\n\t\tif ( compiledOfs > maxLength - 16 ) {\n\t\t\tCom_Error( ERR_FATAL, \"VM_CompileX86: maxLength exceeded\" );\n\t\t}\n\n\t\tvm->instructionPointers[ instruction ] = compiledOfs;\n\t\tinstruction++;\n\n\t\tif ( pc > header->codeLength ) {\n\t\t\tCom_Error( ERR_FATAL, \"VM_CompileX86: pc > header->codeLength\" );\n\t\t}\n\n\t\top = code[ pc ];\n\t\tpc++;\n\t\tswitch ( op ) {\n\t\tcase 0:\n\t\t\tbreak;\n\t\tcase OP_BREAK:\n\t\t\tEmitString( \"CC\" );\t\t\t// int 3\n\t\t\tbreak;\n\t\tcase OP_ENTER:\n\t\t\tEmitString( \"81 EE\" );\t\t// sub\tesi, 0x12345678\n\t\t\tEmit4( Constant4() );\n\t\t\tbreak;\n\t\tcase OP_CONST:\n\t\t\tif (code[pc+4] == OP_LOAD4) {\n\t\t\t\tEmitAddEDI4(vm);\n\t\t\t\tEmitString( \"BB\" );\t\t// mov\tebx, 0x12345678\n\t\t\t\tEmit4( (Constant4()&vm->dataMask) + (int)vm->dataBase);\n\t\t\t\tEmitString( \"8B 03\" );\t\t// mov\teax, dword ptr [ebx]\n\t\t\t\tEmitCommand(LAST_COMMAND_MOV_EDI_EAX);\t\t// mov dword ptr [edi], eax\n\t\t\t\tpc++;\t\t\t\t\t\t// OP_LOAD4\n\t\t\t\tinstruction += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (code[pc+4] == OP_LOAD2) {\n\t\t\t\tEmitAddEDI4(vm);\n\t\t\t\tEmitString( \"BB\" );\t\t// mov\tebx, 0x12345678\n\t\t\t\tEmit4( (Constant4()&vm->dataMask) + (int)vm->dataBase);\n\t\t\t\tEmitString( \"0F B7 03\" );\t// movzx\teax, word ptr [ebx]\n\t\t\t\tEmitCommand(LAST_COMMAND_MOV_EDI_EAX);\t\t// mov dword ptr [edi], eax\n\t\t\t\tpc++;\t\t\t\t\t\t// OP_LOAD4\n\t\t\t\tinstruction += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (code[pc+4] == OP_LOAD1) {\n\t\t\t\tEmitAddEDI4(vm);\n\t\t\t\tEmitString( \"BB\" );\t\t// mov\tebx, 0x12345678\n\t\t\t\tEmit4( (Constant4()&vm->dataMask) + (int)vm->dataBase);\n\t\t\t\tEmitString( \"0F B6 03\" );\t// movzx\teax, byte ptr [ebx]\n\t\t\t\tEmitCommand(LAST_COMMAND_MOV_EDI_EAX);\t\t// mov dword ptr [edi], eax\n\t\t\t\tpc++;\t\t\t\t\t\t// OP_LOAD4\n\t\t\t\tinstruction += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (code[pc+4] == OP_STORE4) {\n\t\t\t\topt = EmitMovEBXEDI(vm, (vm->dataMask & ~3));\n\t\t\t\tEmitString( \"B8\" );\t\t\t// mov\teax, 0x12345678\n\t\t\t\tEmit4( Constant4() );\n//\t\t\t\tif (!opt) {\n//\t\t\t\t\tEmitString( \"81 E3\" );\t\t// and ebx, 0x12345678\n//\t\t\t\t\tEmit4( vm->dataMask & ~3 );\n//\t\t\t\t}\n\t\t\t\tEmitString( \"89 83\" );\t\t// mov dword ptr [ebx+0x12345678], eax\n\t\t\t\tEmit4( (int)vm->dataBase );\n\t\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\t\tpc++;\t\t\t\t\t\t// OP_STORE4\n\t\t\t\tinstruction += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (code[pc+4] == OP_STORE2) {\n\t\t\t\topt = EmitMovEBXEDI(vm, (vm->dataMask & ~1));\n\t\t\t\tEmitString( \"B8\" );\t\t\t// mov\teax, 0x12345678\n\t\t\t\tEmit4( Constant4() );\n//\t\t\t\tif (!opt) {\n//\t\t\t\t\tEmitString( \"81 E3\" );\t\t// and ebx, 0x12345678\n//\t\t\t\t\tEmit4( vm->dataMask & ~1 );\n//\t\t\t\t}\n\t\t\t\tEmitString( \"66 89 83\" );\t// mov word ptr [ebx+0x12345678], eax\n\t\t\t\tEmit4( (int)vm->dataBase );\n\t\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\t\tpc++;\t\t\t\t\t\t// OP_STORE4\n\t\t\t\tinstruction += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (code[pc+4] == OP_STORE1) {\n\t\t\t\topt = EmitMovEBXEDI(vm, vm->dataMask);\n\t\t\t\tEmitString( \"B8\" );\t\t\t// mov\teax, 0x12345678\n\t\t\t\tEmit4( Constant4() );\n//\t\t\t\tif (!opt) {\n//\t\t\t\t\tEmitString( \"81 E3\" );\t// and ebx, 0x12345678\n//\t\t\t\t\tEmit4( vm->dataMask );\n//\t\t\t\t}\n\t\t\t\tEmitString( \"88 83\" );\t\t// mov byte ptr [ebx+0x12345678], eax\n\t\t\t\tEmit4( (int)vm->dataBase );\n\t\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\t\tpc++;\t\t\t\t\t\t// OP_STORE4\n\t\t\t\tinstruction += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (code[pc+4] == OP_ADD) {\n\t\t\t\tEmitString( \"81 07\" );\t\t// add dword ptr [edi], 0x1234567\n\t\t\t\tEmit4( Constant4() );\n\t\t\t\tpc++;\t\t\t\t\t\t// OP_ADD\n\t\t\t\tinstruction += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (code[pc+4] == OP_SUB) {\n\t\t\t\tEmitString( \"81 2F\" );\t\t// sub dword ptr [edi], 0x1234567\n\t\t\t\tEmit4( Constant4() );\n\t\t\t\tpc++;\t\t\t\t\t\t// OP_ADD\n\t\t\t\tinstruction += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tEmitAddEDI4(vm);\n\t\t\tEmitString( \"C7 07\" );\t\t// mov\tdword ptr [edi], 0x12345678\n\t\t\tlastConst = Constant4();\n\t\t\tEmit4( lastConst );\n\t\t\tif (code[pc] == OP_JUMP) {\n\t\t\t\tjused[lastConst] = 1;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase OP_LOCAL:\n\t\t\tEmitAddEDI4(vm);\n\t\t\tEmitString( \"8D 86\" );\t\t// lea eax, [0x12345678 + esi]\n\t\t\toc0 = oc1;\n\t\t\toc1 = Constant4();\n\t\t\tEmit4( oc1 );\n\t\t\tEmitCommand(LAST_COMMAND_MOV_EDI_EAX);\t\t// mov dword ptr [edi], eax\n\t\t\tbreak;\n\t\tcase OP_ARG:\n\t\t\tEmitMovEAXEDI(vm);\t\t\t// mov\teax,dword ptr [edi]\n\t\t\tEmitString( \"89 86\" );\t\t// mov\tdword ptr [esi+database],eax\n\t\t\t// FIXME: range check\n\t\t\tEmit4( Constant1() + (int)vm->dataBase );\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\tbreak;\n\t\tcase OP_CALL:\n\t\t\tEmitString( \"C7 86\" );\t\t// mov dword ptr [esi+database],0x12345678\n\t\t\tEmit4( (int)vm->dataBase );\n\t\t\tEmit4( pc );\n\t\t\tEmitString( \"FF 15\" );\t\t// call asmCallPtr\n\t\t\tEmit4( (int)&asmCallPtr );\n\t\t\tbreak;\n\t\tcase OP_PUSH:\n\t\t\tEmitAddEDI4(vm);\n\t\t\tbreak;\n\t\tcase OP_POP:\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\tbreak;\n\t\tcase OP_LEAVE:\n\t\t\tv = Constant4();\n\t\t\tEmitString( \"81 C6\" );\t\t// add\tesi, 0x12345678\n\t\t\tEmit4( v );\n\t\t\tEmitString( \"C3\" );\t\t\t// ret\n\t\t\tbreak;\n\t\tcase OP_LOAD4:\n\t\t\tif (code[pc] == OP_CONST && code[pc+5] == OP_ADD && code[pc+6] == OP_STORE4) {\n\t\t\t\tif (oc0 == oc1 && pop0 == OP_LOCAL && pop1 == OP_LOCAL) {\n\t\t\t\t\tcompiledOfs -= 11;\n\t\t\t\t\tvm->instructionPointers[ instruction-1 ] = compiledOfs;\n\t\t\t\t}\n\t\t\t\tpc++;\t\t\t\t\t\t// OP_CONST\n\t\t\t\tv = Constant4();\n\t\t\t\tEmitMovEBXEDI(vm, vm->dataMask);\n\t\t\t\tif (v == 1 && oc0 == oc1 && pop0 == OP_LOCAL && pop1 == OP_LOCAL) {\n\t\t\t\t\tEmitString( \"FF 83\");\t\t// inc dword ptr [ebx + 0x12345678]\n\t\t\t\t\tEmit4( (int)vm->dataBase );\n\t\t\t\t} else {\n\t\t\t\t\tEmitString( \"8B 83\" );\t\t// mov\teax, dword ptr [ebx + 0x12345678]\n\t\t\t\t\tEmit4( (int)vm->dataBase );\n\t\t\t\t\tEmitString( \"05\"  );\t\t// add eax, const\n\t\t\t\t\tEmit4( v );\n\t\t\t\t\tif (oc0 == oc1 && pop0 == OP_LOCAL && pop1 == OP_LOCAL) {\n\t\t\t\t\t\tEmitString( \"89 83\" );\t\t// mov dword ptr [ebx+0x12345678], eax\n\t\t\t\t\t\tEmit4( (int)vm->dataBase );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\t\t\t\tEmitString( \"8B 1F\" );\t\t// mov\tebx, dword ptr [edi]\n\t\t\t\t\t\tEmitString( \"89 83\" );\t\t// mov dword ptr [ebx+0x12345678], eax\n\t\t\t\t\t\tEmit4( (int)vm->dataBase );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\t\tpc++;\t\t\t\t\t\t// OP_ADD\n\t\t\t\tpc++;\t\t\t\t\t\t// OP_STORE\n\t\t\t\tinstruction += 3;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (code[pc] == OP_CONST && code[pc+5] == OP_SUB && code[pc+6] == OP_STORE4) {\n\t\t\t\tif (oc0 == oc1 && pop0 == OP_LOCAL && pop1 == OP_LOCAL) {\n\t\t\t\t\tcompiledOfs -= 11;\n\t\t\t\t\tvm->instructionPointers[ instruction-1 ] = compiledOfs;\n\t\t\t\t}\n\t\t\t\tEmitMovEBXEDI(vm, vm->dataMask);\n\t\t\t\tEmitString( \"8B 83\" );\t\t// mov\teax, dword ptr [ebx + 0x12345678]\n\t\t\t\tEmit4( (int)vm->dataBase );\n\t\t\t\tpc++;\t\t\t\t\t\t// OP_CONST\n\t\t\t\tv = Constant4();\n\t\t\t\tif (v == 1 && oc0 == oc1 && pop0 == OP_LOCAL && pop1 == OP_LOCAL) {\n\t\t\t\t\tEmitString( \"FF 8B\");\t\t// dec dword ptr [ebx + 0x12345678]\n\t\t\t\t\tEmit4( (int)vm->dataBase );\n\t\t\t\t} else {\n\t\t\t\t\tEmitString( \"2D\"  );\t\t// sub eax, const\n\t\t\t\t\tEmit4( v );\n\t\t\t\t\tif (oc0 == oc1 && pop0 == OP_LOCAL && pop1 == OP_LOCAL) {\n\t\t\t\t\t\tEmitString( \"89 83\" );\t\t// mov dword ptr [ebx+0x12345678], eax\n\t\t\t\t\t\tEmit4( (int)vm->dataBase );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\t\t\t\tEmitString( \"8B 1F\" );\t\t// mov\tebx, dword ptr [edi]\n\t\t\t\t\t\tEmitString( \"89 83\" );\t\t// mov dword ptr [ebx+0x12345678], eax\n\t\t\t\t\t\tEmit4( (int)vm->dataBase );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\t\tpc++;\t\t\t\t\t\t// OP_SUB\n\t\t\t\tpc++;\t\t\t\t\t\t// OP_STORE\n\t\t\t\tinstruction += 3;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (buf[compiledOfs-2] == 0x89 && buf[compiledOfs-1] == 0x07) {\n\t\t\t\tcompiledOfs -= 2;\n\t\t\t\tvm->instructionPointers[ instruction-1 ] = compiledOfs;\n\t\t\t\tEmitString( \"8B 80\");\t// mov eax, dword ptr [eax + 0x1234567]\n\t\t\t\tEmit4( (int)vm->dataBase );\n\t\t\t\tEmitCommand(LAST_COMMAND_MOV_EDI_EAX);\t\t// mov dword ptr [edi], eax\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tEmitMovEBXEDI(vm, vm->dataMask);\n\t\t\tEmitString( \"8B 83\" );\t\t// mov\teax, dword ptr [ebx + 0x12345678]\n\t\t\tEmit4( (int)vm->dataBase );\n\t\t\tEmitCommand(LAST_COMMAND_MOV_EDI_EAX);\t\t// mov dword ptr [edi], eax\n\t\t\tbreak;\n\t\tcase OP_LOAD2:\n\t\t\tEmitMovEBXEDI(vm, vm->dataMask);\n\t\t\tEmitString( \"0F B7 83\" );\t// movzx\teax, word ptr [ebx + 0x12345678]\n\t\t\tEmit4( (int)vm->dataBase );\n\t\t\tEmitCommand(LAST_COMMAND_MOV_EDI_EAX);\t\t// mov dword ptr [edi], eax\n\t\t\tbreak;\n\t\tcase OP_LOAD1:\n\t\t\tEmitMovEBXEDI(vm, vm->dataMask);\n\t\t\tEmitString( \"0F B6 83\" );\t// movzx eax, byte ptr [ebx + 0x12345678]\n\t\t\tEmit4( (int)vm->dataBase );\n\t\t\tEmitCommand(LAST_COMMAND_MOV_EDI_EAX);\t\t// mov dword ptr [edi], eax\n\t\t\tbreak;\n\t\tcase OP_STORE4:\n\t\t\tEmitMovEAXEDI(vm);\t\n\t\t\tEmitString( \"8B 5F FC\" );\t// mov\tebx, dword ptr [edi-4]\n//\t\t\tif (pop1 != OP_CALL) {\n//\t\t\t\tEmitString( \"81 E3\" );\t\t// and ebx, 0x12345678\n//\t\t\t\tEmit4( vm->dataMask & ~3 );\n//\t\t\t}\n\t\t\tEmitString( \"89 83\" );\t\t// mov dword ptr [ebx+0x12345678], eax\n\t\t\tEmit4( (int)vm->dataBase );\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_8);\t\t// sub edi, 8\n\t\t\tbreak;\n\t\tcase OP_STORE2:\n\t\t\tEmitMovEAXEDI(vm);\t\n\t\t\tEmitString( \"8B 5F FC\" );\t// mov\tebx, dword ptr [edi-4]\n//\t\t\tEmitString( \"81 E3\" );\t\t// and ebx, 0x12345678\n//\t\t\tEmit4( vm->dataMask & ~1 );\n\t\t\tEmitString( \"66 89 83\" );\t// mov word ptr [ebx+0x12345678], eax\n\t\t\tEmit4( (int)vm->dataBase );\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_8);\t\t// sub edi, 8\n\t\t\tbreak;\n\t\tcase OP_STORE1:\n\t\t\tEmitMovEAXEDI(vm);\t\n\t\t\tEmitString( \"8B 5F FC\" );\t// mov\tebx, dword ptr [edi-4]\n//\t\t\tEmitString( \"81 E3\" );\t\t// and ebx, 0x12345678\n//\t\t\tEmit4( vm->dataMask );\n\t\t\tEmitString( \"88 83\" );\t\t// mov byte ptr [ebx+0x12345678], eax\n\t\t\tEmit4( (int)vm->dataBase );\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_8);\t\t// sub edi, 8\n\t\t\tbreak;\n\n\t\tcase OP_EQ:\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_8);\t\t// sub edi, 8\n\t\t\tEmitString( \"8B 47 04\" );\t// mov\teax, dword ptr [edi+4]\n\t\t\tEmitString( \"3B 47 08\" );\t// cmp\teax, dword ptr [edi+8]\n\t\t\tEmitString( \"75 06\" );\t\t// jne +6\n\t\t\tEmitString( \"FF 25\" );\t\t// jmp\t[0x12345678]\n\t\t\tv = Constant4();\n\t\t\tjused[v] = 1;\n\t\t\tEmit4( (int)vm->instructionPointers + v*4 );\n\t\t\tbreak;\n\t\tcase OP_NE:\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_8);\t\t// sub edi, 8\n\t\t\tEmitString( \"8B 47 04\" );\t// mov\teax, dword ptr [edi+4]\n\t\t\tEmitString( \"3B 47 08\" );\t// cmp\teax, dword ptr [edi+8]\n\t\t\tEmitString( \"74 06\" );\t\t// je +6\n\t\t\tEmitString( \"FF 25\" );\t\t// jmp\t[0x12345678]\n\t\t\tv = Constant4();\n\t\t\tjused[v] = 1;\n\t\t\tEmit4( (int)vm->instructionPointers + v*4 );\n\t\t\tbreak;\n\t\tcase OP_LTI:\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_8);\t\t// sub edi, 8\n\t\t\tEmitString( \"8B 47 04\" );\t// mov\teax, dword ptr [edi+4]\n\t\t\tEmitString( \"3B 47 08\" );\t// cmp\teax, dword ptr [edi+8]\n\t\t\tEmitString( \"7D 06\" );\t\t// jnl +6\n\t\t\tEmitString( \"FF 25\" );\t\t// jmp\t[0x12345678]\n\t\t\tv = Constant4();\n\t\t\tjused[v] = 1;\n\t\t\tEmit4( (int)vm->instructionPointers + v*4 );\n\t\t\tbreak;\n\t\tcase OP_LEI:\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_8);\t\t// sub edi, 8\n\t\t\tEmitString( \"8B 47 04\" );\t// mov\teax, dword ptr [edi+4]\n\t\t\tEmitString( \"3B 47 08\" );\t// cmp\teax, dword ptr [edi+8]\n\t\t\tEmitString( \"7F 06\" );\t\t// jnle +6\n\t\t\tEmitString( \"FF 25\" );\t\t// jmp\t[0x12345678]\n\t\t\tv = Constant4();\n\t\t\tjused[v] = 1;\n\t\t\tEmit4( (int)vm->instructionPointers + v*4 );\n\t\t\tbreak;\n\t\tcase OP_GTI:\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_8);\t\t// sub edi, 8\n\t\t\tEmitString( \"8B 47 04\" );\t// mov\teax, dword ptr [edi+4]\n\t\t\tEmitString( \"3B 47 08\" );\t// cmp\teax, dword ptr [edi+8]\n\t\t\tEmitString( \"7E 06\" );\t\t// jng +6\n\t\t\tEmitString( \"FF 25\" );\t\t// jmp\t[0x12345678]\n\t\t\tv = Constant4();\n\t\t\tjused[v] = 1;\n\t\t\tEmit4( (int)vm->instructionPointers + v*4 );\n\t\t\tbreak;\n\t\tcase OP_GEI:\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_8);\t\t// sub edi, 8\n\t\t\tEmitString( \"8B 47 04\" );\t// mov\teax, dword ptr [edi+4]\n\t\t\tEmitString( \"3B 47 08\" );\t// cmp\teax, dword ptr [edi+8]\n\t\t\tEmitString( \"7C 06\" );\t\t// jnge +6\n\t\t\tEmitString( \"FF 25\" );\t\t// jmp\t[0x12345678]\n\t\t\tv = Constant4();\n\t\t\tjused[v] = 1;\n\t\t\tEmit4( (int)vm->instructionPointers + v*4 );\n\t\t\tbreak;\n\t\tcase OP_LTU:\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_8);\t\t// sub edi, 8\n\t\t\tEmitString( \"8B 47 04\" );\t// mov\teax, dword ptr [edi+4]\n\t\t\tEmitString( \"3B 47 08\" );\t// cmp\teax, dword ptr [edi+8]\n\t\t\tEmitString( \"73 06\" );\t\t// jnb +6\n\t\t\tEmitString( \"FF 25\" );\t\t// jmp\t[0x12345678]\n\t\t\tv = Constant4();\n\t\t\tjused[v] = 1;\n\t\t\tEmit4( (int)vm->instructionPointers + v*4 );\n\t\t\tbreak;\n\t\tcase OP_LEU:\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_8);\t\t// sub edi, 8\n\t\t\tEmitString( \"8B 47 04\" );\t// mov\teax, dword ptr [edi+4]\n\t\t\tEmitString( \"3B 47 08\" );\t// cmp\teax, dword ptr [edi+8]\n\t\t\tEmitString( \"77 06\" );\t\t// jnbe +6\n\t\t\tEmitString( \"FF 25\" );\t\t// jmp\t[0x12345678]\n\t\t\tv = Constant4();\n\t\t\tjused[v] = 1;\n\t\t\tEmit4( (int)vm->instructionPointers + v*4 );\n\t\t\tbreak;\n\t\tcase OP_GTU:\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_8);\t\t// sub edi, 8\n\t\t\tEmitString( \"8B 47 04\" );\t// mov\teax, dword ptr [edi+4]\n\t\t\tEmitString( \"3B 47 08\" );\t// cmp\teax, dword ptr [edi+8]\n\t\t\tEmitString( \"76 06\" );\t\t// jna +6\n\t\t\tEmitString( \"FF 25\" );\t\t// jmp\t[0x12345678]\n\t\t\tv = Constant4();\n\t\t\tjused[v] = 1;\n\t\t\tEmit4( (int)vm->instructionPointers + v*4 );\n\t\t\tbreak;\n\t\tcase OP_GEU:\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_8);\t\t// sub edi, 8\n\t\t\tEmitString( \"8B 47 04\" );\t// mov\teax, dword ptr [edi+4]\n\t\t\tEmitString( \"3B 47 08\" );\t// cmp\teax, dword ptr [edi+8]\n\t\t\tEmitString( \"72 06\" );\t\t// jnae +6\n\t\t\tEmitString( \"FF 25\" );\t\t// jmp\t[0x12345678]\n\t\t\tv = Constant4();\n\t\t\tjused[v] = 1;\n\t\t\tEmit4( (int)vm->instructionPointers + v*4 );\n\t\t\tbreak;\n\t\tcase OP_EQF:\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_8);\t\t// sub edi, 8\n\t\t\tEmitString( \"D9 47 04\" );\t// fld dword ptr [edi+4]\n\t\t\tEmitString( \"D8 5F 08\" );\t// fcomp dword ptr [edi+8]\n\t\t\tEmitString( \"DF E0\" );\t\t// fnstsw ax\n\t\t\tEmitString( \"F6 C4 40\" );\t// test\tah,0x40\n\t\t\tEmitString( \"74 06\" );\t\t// je +6\n\t\t\tEmitString( \"FF 25\" );\t\t// jmp\t[0x12345678]\n\t\t\tv = Constant4();\n\t\t\tjused[v] = 1;\n\t\t\tEmit4( (int)vm->instructionPointers + v*4 );\n\t\t\tbreak;\t\t\t\n\t\tcase OP_NEF:\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_8);\t\t// sub edi, 8\n\t\t\tEmitString( \"D9 47 04\" );\t// fld dword ptr [edi+4]\n\t\t\tEmitString( \"D8 5F 08\" );\t// fcomp dword ptr [edi+8]\n\t\t\tEmitString( \"DF E0\" );\t\t// fnstsw ax\n\t\t\tEmitString( \"F6 C4 40\" );\t// test\tah,0x40\n\t\t\tEmitString( \"75 06\" );\t\t// jne +6\n\t\t\tEmitString( \"FF 25\" );\t\t// jmp\t[0x12345678]\n\t\t\tv = Constant4();\n\t\t\tjused[v] = 1;\n\t\t\tEmit4( (int)vm->instructionPointers + v*4 );\n\t\t\tbreak;\t\t\t\n\t\tcase OP_LTF:\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_8);\t\t// sub edi, 8\n\t\t\tEmitString( \"D9 47 04\" );\t// fld dword ptr [edi+4]\n\t\t\tEmitString( \"D8 5F 08\" );\t// fcomp dword ptr [edi+8]\n\t\t\tEmitString( \"DF E0\" );\t\t// fnstsw ax\n\t\t\tEmitString( \"F6 C4 01\" );\t// test\tah,0x01\n\t\t\tEmitString( \"74 06\" );\t\t// je +6\n\t\t\tEmitString( \"FF 25\" );\t\t// jmp\t[0x12345678]\n\t\t\tv = Constant4();\n\t\t\tjused[v] = 1;\n\t\t\tEmit4( (int)vm->instructionPointers + v*4 );\n\t\t\tbreak;\t\t\t\n\t\tcase OP_LEF:\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_8);\t\t// sub edi, 8\n\t\t\tEmitString( \"D9 47 04\" );\t// fld dword ptr [edi+4]\n\t\t\tEmitString( \"D8 5F 08\" );\t// fcomp dword ptr [edi+8]\n\t\t\tEmitString( \"DF E0\" );\t\t// fnstsw ax\n\t\t\tEmitString( \"F6 C4 41\" );\t// test\tah,0x41\n\t\t\tEmitString( \"74 06\" );\t\t// je +6\n\t\t\tEmitString( \"FF 25\" );\t\t// jmp\t[0x12345678]\n\t\t\tv = Constant4();\n\t\t\tjused[v] = 1;\n\t\t\tEmit4( (int)vm->instructionPointers + v*4 );\n\t\t\tbreak;\t\t\t\n\t\tcase OP_GTF:\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_8);\t\t// sub edi, 8\n\t\t\tEmitString( \"D9 47 04\" );\t// fld dword ptr [edi+4]\n\t\t\tEmitString( \"D8 5F 08\" );\t// fcomp dword ptr [edi+8]\n\t\t\tEmitString( \"DF E0\" );\t\t// fnstsw ax\n\t\t\tEmitString( \"F6 C4 41\" );\t// test\tah,0x41\n\t\t\tEmitString( \"75 06\" );\t\t// jne +6\n\t\t\tEmitString( \"FF 25\" );\t\t// jmp\t[0x12345678]\n\t\t\tv = Constant4();\n\t\t\tjused[v] = 1;\n\t\t\tEmit4( (int)vm->instructionPointers + v*4 );\n\t\t\tbreak;\t\t\t\n\t\tcase OP_GEF:\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_8);\t\t// sub edi, 8\n\t\t\tEmitString( \"D9 47 04\" );\t// fld dword ptr [edi+4]\n\t\t\tEmitString( \"D8 5F 08\" );\t// fcomp dword ptr [edi+8]\n\t\t\tEmitString( \"DF E0\" );\t\t// fnstsw ax\n\t\t\tEmitString( \"F6 C4 01\" );\t// test\tah,0x01\n\t\t\tEmitString( \"75 06\" );\t\t// jne +6\n\t\t\tEmitString( \"FF 25\" );\t\t// jmp\t[0x12345678]\n\t\t\tv = Constant4();\n\t\t\tjused[v] = 1;\n\t\t\tEmit4( (int)vm->instructionPointers + v*4 );\n\t\t\tbreak;\t\t\t\n\t\tcase OP_NEGI:\n\t\t\tEmitString( \"F7 1F\" );\t\t// neg dword ptr [edi]\n\t\t\tbreak;\n\t\tcase OP_ADD:\n\t\t\tEmitMovEAXEDI(vm);\t\t\t// mov eax, dword ptr [edi]\n\t\t\tEmitString( \"01 47 FC\" );\t// add dword ptr [edi-4],eax\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\tbreak;\n\t\tcase OP_SUB:\n\t\t\tEmitMovEAXEDI(vm);\t\t\t// mov eax, dword ptr [edi]\n\t\t\tEmitString( \"29 47 FC\" );\t// sub dword ptr [edi-4],eax\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\tbreak;\n\t\tcase OP_DIVI:\n\t\t\tEmitString( \"8B 47 FC\" );\t// mov eax,dword ptr [edi-4]\n\t\t\tEmitString( \"99\" );\t\t\t// cdq\n\t\t\tEmitString( \"F7 3F\" );\t\t// idiv dword ptr [edi]\n\t\t\tEmitString( \"89 47 FC\" );\t// mov dword ptr [edi-4],eax\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\tbreak;\n\t\tcase OP_DIVU:\n\t\t\tEmitString( \"8B 47 FC\" );\t// mov eax,dword ptr [edi-4]\n\t\t\tEmitString( \"33 D2\" );\t\t// xor edx, edx\n\t\t\tEmitString( \"F7 37\" );\t\t// div dword ptr [edi]\n\t\t\tEmitString( \"89 47 FC\" );\t// mov dword ptr [edi-4],eax\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\tbreak;\n\t\tcase OP_MODI:\n\t\t\tEmitString( \"8B 47 FC\" );\t// mov eax,dword ptr [edi-4]\n\t\t\tEmitString( \"99\" );\t\t\t// cdq\n\t\t\tEmitString( \"F7 3F\" );\t\t// idiv dword ptr [edi]\n\t\t\tEmitString( \"89 57 FC\" );\t// mov dword ptr [edi-4],edx\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\tbreak;\n\t\tcase OP_MODU:\n\t\t\tEmitString( \"8B 47 FC\" );\t// mov eax,dword ptr [edi-4]\n\t\t\tEmitString( \"33 D2\" );\t\t// xor edx, edx\n\t\t\tEmitString( \"F7 37\" );\t\t// div dword ptr [edi]\n\t\t\tEmitString( \"89 57 FC\" );\t// mov dword ptr [edi-4],edx\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\tbreak;\n\t\tcase OP_MULI:\n\t\t\tEmitString( \"8B 47 FC\" );\t// mov eax,dword ptr [edi-4]\n\t\t\tEmitString( \"F7 2F\" );\t\t// imul dword ptr [edi]\n\t\t\tEmitString( \"89 47 FC\" );\t// mov dword ptr [edi-4],eax\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\tbreak;\n\t\tcase OP_MULU:\n\t\t\tEmitString( \"8B 47 FC\" );\t// mov eax,dword ptr [edi-4]\n\t\t\tEmitString( \"F7 27\" );\t\t// mul dword ptr [edi]\n\t\t\tEmitString( \"89 47 FC\" );\t// mov dword ptr [edi-4],eax\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\tbreak;\n\t\tcase OP_BAND:\n\t\t\tEmitMovEAXEDI(vm);\t\t\t// mov eax, dword ptr [edi]\n\t\t\tEmitString( \"21 47 FC\" );\t// and dword ptr [edi-4],eax\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\tbreak;\n\t\tcase OP_BOR:\n\t\t\tEmitMovEAXEDI(vm);\t\t\t// mov eax, dword ptr [edi]\n\t\t\tEmitString( \"09 47 FC\" );\t// or dword ptr [edi-4],eax\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\tbreak;\n\t\tcase OP_BXOR:\n\t\t\tEmitMovEAXEDI(vm);\t\t\t// mov eax, dword ptr [edi]\n\t\t\tEmitString( \"31 47 FC\" );\t// xor dword ptr [edi-4],eax\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\tbreak;\n\t\tcase OP_BCOM:\n\t\t\tEmitString( \"F7 17\" );\t\t// not dword ptr [edi]\n\t\t\tbreak;\n\t\tcase OP_LSH:\n\t\t\tEmitString( \"8B 0F\" );\t\t// mov ecx, dword ptr [edi]\n\t\t\tEmitString( \"D3 67 FC\" );\t// shl dword ptr [edi-4], cl\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\tbreak;\n\t\tcase OP_RSHI:\n\t\t\tEmitString( \"8B 0F\" );\t\t// mov ecx, dword ptr [edi]\n\t\t\tEmitString( \"D3 7F FC\" );\t// sar dword ptr [edi-4], cl\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\tbreak;\n\t\tcase OP_RSHU:\n\t\t\tEmitString( \"8B 0F\" );\t\t// mov ecx, dword ptr [edi]\n\t\t\tEmitString( \"D3 6F FC\" );\t// shr dword ptr [edi-4], cl\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\tbreak;\n\t\tcase OP_NEGF:\n\t\t\tEmitString( \"D9 07\" );\t\t// fld dword ptr [edi]\n\t\t\tEmitString( \"D9 E0\" );\t\t// fchs\n\t\t\tEmitString( \"D9 1F\" );\t\t// fstp dword ptr [edi]\n\t\t\tbreak;\n\t\tcase OP_ADDF:\n\t\t\tEmitString( \"D9 47 FC\" );\t// fld dword ptr [edi-4]\n\t\t\tEmitString( \"D8 07\" );\t\t// fadd dword ptr [edi]\n\t\t\tEmitString( \"D9 5F FC\" );\t// fstp dword ptr [edi-4]\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\tbreak;\n\t\tcase OP_SUBF:\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\tEmitString( \"D9 07\" );\t\t// fld dword ptr [edi]\n\t\t\tEmitString( \"D8 67 04\" );\t// fsub dword ptr [edi+4]\n\t\t\tEmitString( \"D9 1F\" );\t\t// fstp dword ptr [edi]\n\t\t\tbreak;\n\t\tcase OP_DIVF:\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\tEmitString( \"D9 07\" );\t\t// fld dword ptr [edi]\n\t\t\tEmitString( \"D8 77 04\" );\t// fdiv dword ptr [edi+4]\n\t\t\tEmitString( \"D9 1F\" );\t\t// fstp dword ptr [edi]\n\t\t\tbreak;\n\t\tcase OP_MULF:\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\tEmitString( \"D9 07\" );\t\t// fld dword ptr [edi]\n\t\t\tEmitString( \"D8 4f 04\" );\t// fmul dword ptr [edi+4]\n\t\t\tEmitString( \"D9 1F\" );\t\t// fstp dword ptr [edi]\n\t\t\tbreak;\n\t\tcase OP_CVIF:\n\t\t\tEmitString( \"DB 07\" );\t\t// fild dword ptr [edi]\n\t\t\tEmitString( \"D9 1F\" );\t\t// fstp dword ptr [edi]\n\t\t\tbreak;\n\t\tcase OP_CVFI:\n#ifndef FTOL_PTR // WHENHELLISFROZENOVER  // bk001213 - was used in 1.17\n\t\t\t// not IEEE complient, but simple and fast\n\t\t  EmitString( \"D9 07\" );\t\t// fld dword ptr [edi]\n\t\t\tEmitString( \"DB 1F\" );\t\t// fistp dword ptr [edi]\n#else // FTOL_PTR\n\t\t\t// call the library conversion function\n\t\t\tEmitString( \"D9 07\" );\t\t// fld dword ptr [edi]\n\t\t\tEmitString( \"FF 15\" );\t\t// call ftolPtr\n\t\t\tEmit4( (int)&ftolPtr );\n\t\t\tEmitCommand(LAST_COMMAND_MOV_EDI_EAX);\t\t// mov dword ptr [edi], eax\n#endif\n\t\t\tbreak;\n\t\tcase OP_SEX8:\n\t\t\tEmitString( \"0F BE 07\" );\t// movsx eax, byte ptr [edi]\n\t\t\tEmitCommand(LAST_COMMAND_MOV_EDI_EAX);\t\t// mov dword ptr [edi], eax\n\t\t\tbreak;\n\t\tcase OP_SEX16:\n\t\t\tEmitString( \"0F BF 07\" );\t// movsx eax, word ptr [edi]\n\t\t\tEmitCommand(LAST_COMMAND_MOV_EDI_EAX);\t\t// mov dword ptr [edi], eax\n\t\t\tbreak;\n\n\t\tcase OP_BLOCK_COPY:\n\t\t\t// FIXME: range check\n\t\t\tEmitString( \"56\" );\t\t\t// push esi\n\t\t\tEmitString( \"57\" );\t\t\t// push edi\n\t\t\tEmitString( \"8B 37\" );\t\t// mov esi,[edi] \n\t\t\tEmitString( \"8B 7F FC\" );\t// mov edi,[edi-4] \n\t\t\tEmitString( \"B9\" );\t\t\t// mov ecx,0x12345678\n\t\t\tEmit4( Constant4() >> 2 );\n\t\t\tEmitString( \"B8\" );\t\t\t// mov eax, datamask\n\t\t\tEmit4( vm->dataMask );\n\t\t\tEmitString( \"BB\" );\t\t\t// mov ebx, database\n\t\t\tEmit4( (int)vm->dataBase );\n\t\t\tEmitString( \"23 F0\" );\t\t// and esi, eax\n\t\t\tEmitString( \"03 F3\" );\t\t// add esi, ebx\n\t\t\tEmitString( \"23 F8\" );\t\t// and edi, eax\n\t\t\tEmitString( \"03 FB\" );\t\t// add edi, ebx\n\t\t\tEmitString( \"F3 A5\" );\t\t// rep movsd\n\t\t\tEmitString( \"5F\" );\t\t\t// pop edi\n\t\t\tEmitString( \"5E\" );\t\t\t// pop esi\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_8);\t\t// sub edi, 8\n\t\t\tbreak;\n\n\t\tcase OP_JUMP:\n\t\t\tEmitCommand(LAST_COMMAND_SUB_DI_4);\t\t// sub edi, 4\n\t\t\tEmitString( \"8B 47 04\" );\t// mov eax,dword ptr [edi+4]\n\t\t\t// FIXME: range check\n\t\t\tEmitString( \"FF 24 85\" );\t// jmp dword ptr [instructionPointers + eax * 4]\n\t\t\tEmit4( (int)vm->instructionPointers );\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tCom_Error( ERR_DROP, \"VM_CompileX86: bad opcode %i at offset %i\", op, pc );\n\t\t}\n\t\tpop0 = pop1;\n\t\tpop1 = op;\n\t}\n\t}\n\n\t// copy to an exact size buffer on the hunk\n\tvm->codeLength = compiledOfs;\n\tvm->codeBase = Hunk_Alloc( compiledOfs, h_low );\n\tCom_Memcpy( vm->codeBase, buf, compiledOfs );\n\tZ_Free( buf );\n\tZ_Free( jused );\n\tCom_Printf( \"VM file %s compiled to %i bytes of code\\n\", vm->name, compiledOfs );\n\n\t// offset all the instruction pointers for the new location\n\tfor ( i = 0 ; i < header->instructionCount ; i++ ) {\n\t\tvm->instructionPointers[i] += (int)vm->codeBase;\n\t}\n\n#if 0 // ndef _WIN32\n\t// Must make the newly generated code executable\n\t{\n\t\tint r;\n\t\tunsigned long addr;\n\t\tint psize = getpagesize();\n\n\t\taddr = ((int)vm->codeBase & ~(psize-1)) - psize;\n\n\t\tr = mprotect((char*)addr, vm->codeLength + (int)vm->codeBase - addr + psize, \n\t\t\tPROT_READ | PROT_WRITE | PROT_EXEC );\n\n\t\tif (r < 0)\n\t\t\tCom_Error( ERR_FATAL, \"mprotect failed to change PROT_EXEC\" );\n\t}\n#endif\n\n}\n\n/*\n==============\nVM_CallCompiled\n\nThis function is called directly by the generated code\n==============\n*/\n#ifndef DLL_ONLY // bk010215 - for DLL_ONLY dedicated servers/builds w/o VM\nint\tVM_CallCompiled( vm_t *vm, int *args ) {\n\tint\t\tstack[1024];\n\tint\t\tprogramCounter;\n\tint\t\tprogramStack;\n\tint\t\tstackOnEntry;\n\tbyte\t*image;\n\tvoid\t*entryPoint;\n\tvoid\t*opStack;\n\tint\t\t*oldInstructionPointers;\n\n\toldInstructionPointers = instructionPointers;\n\n\tcurrentVM = vm;\n\tinstructionPointers = vm->instructionPointers;\n\n\t// interpret the code\n\tvm->currentlyInterpreting = qtrue;\n\n\tcallMask = vm->dataMask;\n\n\t// we might be called recursively, so this might not be the very top\n\tprogramStack = vm->programStack;\n\tstackOnEntry = programStack;\n\n\t// set up the stack frame \n\timage = vm->dataBase;\n\n\tprogramCounter = 0;\n\n\tprogramStack -= 48;\n\n\t*(int *)&image[ programStack + 44] = args[9];\n\t*(int *)&image[ programStack + 40] = args[8];\n\t*(int *)&image[ programStack + 36] = args[7];\n\t*(int *)&image[ programStack + 32] = args[6];\n\t*(int *)&image[ programStack + 28] = args[5];\n\t*(int *)&image[ programStack + 24] = args[4];\n\t*(int *)&image[ programStack + 20] = args[3];\n\t*(int *)&image[ programStack + 16] = args[2];\n\t*(int *)&image[ programStack + 12] = args[1];\n\t*(int *)&image[ programStack + 8 ] = args[0];\n\t*(int *)&image[ programStack + 4 ] = 0;\t// return stack\n\t*(int *)&image[ programStack ] = -1;\t// will terminate the loop on return\n\n\t// off we go into generated code...\n\tentryPoint = vm->codeBase;\n\topStack = &stack;\n\n#ifdef _WIN32\n\t__asm  {\n\t\tpushad\n\t\tmov\t\tesi, programStack;\n\t\tmov\t\tedi, opStack\n\t\tcall\tentryPoint\n\t\tmov\t\tprogramStack, esi\n\t\tmov\t\topStack, edi\n\t\tpopad\n\t}\n#else\n\t{\n\t\tstatic int memProgramStack;\n\t\tstatic void *memOpStack;\n\t\tstatic void *memEntryPoint;\n\n\t\tmemProgramStack\t= programStack;\n\t\tmemOpStack      = opStack;     \n\t\tmemEntryPoint   = entryPoint;  \n\t\t\n\t\t__asm__(\"\tpushal\t\t\t\t\\r\\n\" \\\n\t\t\t\t\"\tmovl %0,%%esi\t\t\\r\\n\" \\\n\t\t\t\t\"\tmovl %1,%%edi\t\t\\r\\n\" \\\n\t\t\t\t\"\tcall *%2\t\t\t\\r\\n\" \\\n\t\t\t\t\"\tmovl %%esi,%0\t\t\\r\\n\" \\\n\t\t\t\t\"\tmovl %%edi,%1\t\t\\r\\n\" \\\n\t\t\t\t\"\tpopal\t\t\t\t\\r\\n\" \\\n\t\t\t\t: \"=m\" (memProgramStack), \"=m\" (memOpStack) \\\n\t\t\t\t: \"m\" (memEntryPoint), \"0\" (memProgramStack), \"1\" (memOpStack) \\\n\t\t\t\t: \"si\", \"di\" \\\n\t\t);\n\n\t\tprogramStack = memProgramStack;\n\t\topStack      = memOpStack;\n\t}\n#endif\n\n\tif ( opStack != &stack[1] ) {\n\t\tCom_Error( ERR_DROP, \"opStack corrupted in compiled code\" );\n\t}\n\tif ( programStack != stackOnEntry - 48 ) {\n\t\tCom_Error( ERR_DROP, \"programStack corrupted in compiled code\" );\n\t}\n\n\tvm->programStack = stackOnEntry;\n\n\t// in case we were recursively called by another vm\n\tinstructionPointers = oldInstructionPointers;\n\n\treturn *(int *)opStack;\n}\n#endif // !DLL_ONLY\n\n\n"
  },
  {
    "path": "code/quake3.sln",
    "content": "Microsoft Visual Studio Solution File, Format Version 8.00\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"Splines\", \"splines\\Splines.vcproj\", \"{DBAF2C53-3858-455D-A1AE-3FC093515314}\"\n\tProjectSection(ProjectDependencies) = postProject\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"botlib\", \"botlib\\botlib.vcproj\", \"{A410161F-AE9F-485D-A01F-5294891430A6}\"\n\tProjectSection(ProjectDependencies) = postProject\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"cgame\", \"cgame\\cgame.vcproj\", \"{C878E295-CB82-4B40-8ECF-5CE5525466FA}\"\n\tProjectSection(ProjectDependencies) = postProject\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"game\", \"game\\game.vcproj\", \"{F9EE10DA-2404-4154-B904-F93C936C040A}\"\n\tProjectSection(ProjectDependencies) = postProject\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"q3_ui\", \"q3_ui\\q3_ui.vcproj\", \"{D454C4C7-7765-4149-ABAD-05FDEB9D94F8}\"\n\tProjectSection(ProjectDependencies) = postProject\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"quake3\", \"quake3.vcproj\", \"{81CB51C4-B434-4E12-B69B-BAEE102F2852}\"\n\tProjectSection(ProjectDependencies) = postProject\n\t\t{A410161F-AE9F-485D-A01F-5294891430A6} = {A410161F-AE9F-485D-A01F-5294891430A6}\n\t\t{DBAF2C53-3858-455D-A1AE-3FC093515314} = {DBAF2C53-3858-455D-A1AE-3FC093515314}\n\t\t{AB424155-FBED-4D8D-B007-5B6CF93EA395} = {AB424155-FBED-4D8D-B007-5B6CF93EA395}\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"renderer\", \"renderer\\renderer.vcproj\", \"{AB424155-FBED-4D8D-B007-5B6CF93EA395}\"\n\tProjectSection(ProjectDependencies) = postProject\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"ui\", \"ui\\ui.vcproj\", \"{A8EAC38E-C7DA-42F8-811D-77FD092B9D19}\"\n\tProjectSection(ProjectDependencies) = postProject\n\tEndProjectSection\nEndProject\nGlobal\n\tGlobalSection(SourceCodeControl) = preSolution\n\t\tSccNumberOfProjects = 8\n\t\tSccProjectUniqueName0 = splines\\\\Splines.vcproj\n\t\tSccProjectName0 = \\u0022$/MissionPack/code/Splines\\u0022,\\u0020WJNAAAAA\n\t\tSccLocalPath0 = splines\n\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM\n\t\tSccProjectUniqueName1 = botlib\\\\botlib.vcproj\n\t\tSccProjectName1 = \\u0022$/MissionPack/code/botlib\\u0022,\\u0020HBAAAAAA\n\t\tSccLocalPath1 = botlib\n\t\tSccProvider1 = MSSCCI:Perforce\\u0020SCM\n\t\tSccProjectUniqueName2 = cgame\\\\cgame.vcproj\n\t\tSccProjectName2 = \\u0022$/MissionPack/code/cgame\\u0022,\\u0020NPAAAAAA\n\t\tSccLocalPath2 = cgame\n\t\tSccProvider2 = MSSCCI:Perforce\\u0020SCM\n\t\tSccProjectUniqueName3 = game\\\\game.vcproj\n\t\tSccProjectName3 = \\u0022$/MissionPack/code/game\\u0022,\\u0020CYAAAAAA\n\t\tSccLocalPath3 = game\n\t\tSccProvider3 = MSSCCI:Perforce\\u0020SCM\n\t\tSccProjectUniqueName4 = q3_ui\\\\q3_ui.vcproj\n\t\tSccProjectName4 = \\u0022$/MissionPack/code/q3_ui\\u0022,\\u0020VFLAAAAA\n\t\tSccLocalPath4 = q3_ui\n\t\tSccProvider4 = MSSCCI:Perforce\\u0020SCM\n\t\tSccProjectUniqueName5 = quake3.vcproj\n\t\tSccProjectName5 = \\u0022$/MissionPack/code\\u0022,\\u0020CAAAAAAA\n\t\tSccLocalPath5 = .\n\t\tSccProvider5 = MSSCCI:Perforce\\u0020SCM\n\t\tSccProjectUniqueName6 = renderer\\\\renderer.vcproj\n\t\tSccProjectName6 = \\u0022$/MissionPack/code/renderer\\u0022,\\u0020EJBAAAAA\n\t\tSccLocalPath6 = renderer\n\t\tSccProvider6 = MSSCCI:Perforce\\u0020SCM\n\t\tSccProjectUniqueName7 = ui\\\\ui.vcproj\n\t\tSccProjectName7 = \\u0022$/MissionPack/code/ui\\u0022,\\u0020AOBAAAAA\n\t\tSccLocalPath7 = ui\n\t\tSccProvider7 = MSSCCI:Perforce\\u0020SCM\n\tEndGlobalSection\n\tGlobalSection(SolutionConfiguration) = preSolution\n\t\tDebug = Debug\n\t\tDebug TA = Debug TA\n\t\tRelease = Release\n\t\tRelease TA = Release TA\n\tEndGlobalSection\n\tGlobalSection(ProjectConfiguration) = postSolution\n\t\t{DBAF2C53-3858-455D-A1AE-3FC093515314}.Debug.ActiveCfg = Debug|Win32\n\t\t{DBAF2C53-3858-455D-A1AE-3FC093515314}.Debug.Build.0 = Debug|Win32\n\t\t{DBAF2C53-3858-455D-A1AE-3FC093515314}.Debug TA.ActiveCfg = Debug|Win32\n\t\t{DBAF2C53-3858-455D-A1AE-3FC093515314}.Debug TA.Build.0 = Debug|Win32\n\t\t{DBAF2C53-3858-455D-A1AE-3FC093515314}.Release.ActiveCfg = Release|Win32\n\t\t{DBAF2C53-3858-455D-A1AE-3FC093515314}.Release.Build.0 = Release|Win32\n\t\t{DBAF2C53-3858-455D-A1AE-3FC093515314}.Release TA.ActiveCfg = Release|Win32\n\t\t{DBAF2C53-3858-455D-A1AE-3FC093515314}.Release TA.Build.0 = Release|Win32\n\t\t{A410161F-AE9F-485D-A01F-5294891430A6}.Debug.ActiveCfg = Debug|Win32\n\t\t{A410161F-AE9F-485D-A01F-5294891430A6}.Debug.Build.0 = Debug|Win32\n\t\t{A410161F-AE9F-485D-A01F-5294891430A6}.Debug TA.ActiveCfg = Debug TA|Win32\n\t\t{A410161F-AE9F-485D-A01F-5294891430A6}.Debug TA.Build.0 = Debug TA|Win32\n\t\t{A410161F-AE9F-485D-A01F-5294891430A6}.Release.ActiveCfg = Release|Win32\n\t\t{A410161F-AE9F-485D-A01F-5294891430A6}.Release.Build.0 = Release|Win32\n\t\t{A410161F-AE9F-485D-A01F-5294891430A6}.Release TA.ActiveCfg = Release TA|Win32\n\t\t{A410161F-AE9F-485D-A01F-5294891430A6}.Release TA.Build.0 = Release TA|Win32\n\t\t{C878E295-CB82-4B40-8ECF-5CE5525466FA}.Debug.ActiveCfg = Debug|Win32\n\t\t{C878E295-CB82-4B40-8ECF-5CE5525466FA}.Debug.Build.0 = Debug|Win32\n\t\t{C878E295-CB82-4B40-8ECF-5CE5525466FA}.Debug TA.ActiveCfg = Debug TA|Win32\n\t\t{C878E295-CB82-4B40-8ECF-5CE5525466FA}.Debug TA.Build.0 = Debug TA|Win32\n\t\t{C878E295-CB82-4B40-8ECF-5CE5525466FA}.Release.ActiveCfg = Release|Win32\n\t\t{C878E295-CB82-4B40-8ECF-5CE5525466FA}.Release.Build.0 = Release|Win32\n\t\t{C878E295-CB82-4B40-8ECF-5CE5525466FA}.Release TA.ActiveCfg = Release TA|Win32\n\t\t{C878E295-CB82-4B40-8ECF-5CE5525466FA}.Release TA.Build.0 = Release TA|Win32\n\t\t{F9EE10DA-2404-4154-B904-F93C936C040A}.Debug.ActiveCfg = Debug|Win32\n\t\t{F9EE10DA-2404-4154-B904-F93C936C040A}.Debug.Build.0 = Debug|Win32\n\t\t{F9EE10DA-2404-4154-B904-F93C936C040A}.Debug TA.ActiveCfg = Debug TA|Win32\n\t\t{F9EE10DA-2404-4154-B904-F93C936C040A}.Debug TA.Build.0 = Debug TA|Win32\n\t\t{F9EE10DA-2404-4154-B904-F93C936C040A}.Release.ActiveCfg = Release|Win32\n\t\t{F9EE10DA-2404-4154-B904-F93C936C040A}.Release.Build.0 = Release|Win32\n\t\t{F9EE10DA-2404-4154-B904-F93C936C040A}.Release TA.ActiveCfg = Release TA|Win32\n\t\t{F9EE10DA-2404-4154-B904-F93C936C040A}.Release TA.Build.0 = Release TA|Win32\n\t\t{D454C4C7-7765-4149-ABAD-05FDEB9D94F8}.Debug.ActiveCfg = Debug|Win32\n\t\t{D454C4C7-7765-4149-ABAD-05FDEB9D94F8}.Debug.Build.0 = Debug|Win32\n\t\t{D454C4C7-7765-4149-ABAD-05FDEB9D94F8}.Debug TA.ActiveCfg = Debug TA|Win32\n\t\t{D454C4C7-7765-4149-ABAD-05FDEB9D94F8}.Release.ActiveCfg = Release|Win32\n\t\t{D454C4C7-7765-4149-ABAD-05FDEB9D94F8}.Release.Build.0 = Release|Win32\n\t\t{D454C4C7-7765-4149-ABAD-05FDEB9D94F8}.Release TA.ActiveCfg = Release TA|Win32\n\t\t{81CB51C4-B434-4E12-B69B-BAEE102F2852}.Debug.ActiveCfg = Debug|Win32\n\t\t{81CB51C4-B434-4E12-B69B-BAEE102F2852}.Debug.Build.0 = Debug|Win32\n\t\t{81CB51C4-B434-4E12-B69B-BAEE102F2852}.Debug TA.ActiveCfg = Debug TA|Win32\n\t\t{81CB51C4-B434-4E12-B69B-BAEE102F2852}.Debug TA.Build.0 = Debug TA|Win32\n\t\t{81CB51C4-B434-4E12-B69B-BAEE102F2852}.Release.ActiveCfg = Release|Win32\n\t\t{81CB51C4-B434-4E12-B69B-BAEE102F2852}.Release.Build.0 = Release|Win32\n\t\t{81CB51C4-B434-4E12-B69B-BAEE102F2852}.Release TA.ActiveCfg = Release TA|Win32\n\t\t{81CB51C4-B434-4E12-B69B-BAEE102F2852}.Release TA.Build.0 = Release TA|Win32\n\t\t{AB424155-FBED-4D8D-B007-5B6CF93EA395}.Debug.ActiveCfg = Debug|Win32\n\t\t{AB424155-FBED-4D8D-B007-5B6CF93EA395}.Debug.Build.0 = Debug|Win32\n\t\t{AB424155-FBED-4D8D-B007-5B6CF93EA395}.Debug TA.ActiveCfg = Debug TA|Win32\n\t\t{AB424155-FBED-4D8D-B007-5B6CF93EA395}.Debug TA.Build.0 = Debug TA|Win32\n\t\t{AB424155-FBED-4D8D-B007-5B6CF93EA395}.Release.ActiveCfg = Release|Win32\n\t\t{AB424155-FBED-4D8D-B007-5B6CF93EA395}.Release.Build.0 = Release|Win32\n\t\t{AB424155-FBED-4D8D-B007-5B6CF93EA395}.Release TA.ActiveCfg = Release TA|Win32\n\t\t{AB424155-FBED-4D8D-B007-5B6CF93EA395}.Release TA.Build.0 = Release TA|Win32\n\t\t{A8EAC38E-C7DA-42F8-811D-77FD092B9D19}.Debug.ActiveCfg = Debug|Win32\n\t\t{A8EAC38E-C7DA-42F8-811D-77FD092B9D19}.Debug TA.ActiveCfg = Debug TA|Win32\n\t\t{A8EAC38E-C7DA-42F8-811D-77FD092B9D19}.Debug TA.Build.0 = Debug TA|Win32\n\t\t{A8EAC38E-C7DA-42F8-811D-77FD092B9D19}.Release.ActiveCfg = Release|Win32\n\t\t{A8EAC38E-C7DA-42F8-811D-77FD092B9D19}.Release TA.ActiveCfg = Release TA|Win32\n\t\t{A8EAC38E-C7DA-42F8-811D-77FD092B9D19}.Release TA.Build.0 = Release TA|Win32\n\tEndGlobalSection\n\tGlobalSection(ExtensibilityGlobals) = postSolution\n\tEndGlobalSection\n\tGlobalSection(ExtensibilityAddIns) = postSolution\n\tEndGlobalSection\nEndGlobal\n"
  },
  {
    "path": "code/quake3.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<VisualStudioProject\n\tProjectType=\"Visual C++\"\n\tVersion=\"7.10\"\n\tName=\"quake3\"\n\tSccProjectName=\"&quot;$/MissionPack/code&quot;, CAAAAAAA\"\n\tSccAuxPath=\"\"\n\tSccLocalPath=\".\"\n\tSccProvider=\"MSSCCI:Perforce SCM\">\n\t<Platforms>\n\t\t<Platform\n\t\t\tName=\"Win32\"/>\n\t</Platforms>\n\t<Configurations>\n\t\t<Configuration\n\t\t\tName=\"Release TA|Win32\"\n\t\t\tOutputDirectory=\".\\Release_TA\"\n\t\t\tIntermediateDirectory=\".\\Release_TA\"\n\t\t\tConfigurationType=\"1\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"2\"\n\t\t\t\tOptimizeForProcessor=\"2\"\n\t\t\t\tPreprocessorDefinitions=\"_WIN32;WIN32;NDEBUG;_WINDOWS\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"4\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release_TA/quake3.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release_TA/\"\n\t\t\t\tObjectFile=\".\\Release_TA/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release_TA/\"\n\t\t\t\tBrowseInformation=\"1\"\n\t\t\t\tWarningLevel=\"4\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"winmm.lib wsock32.lib\"\n\t\t\t\tOutputFile=\".\\Release_TA/quake3.exe\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\"Release_TA/quake3.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\"Release_TA/quake3.map\"\n\t\t\t\tSubSystem=\"2\"\n\t\t\t\tStackReserveSize=\"8388608\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Release_TA/quake3.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"\n\t\t\t\tDescription=\"Post build processing..\"\n\t\t\t\tCommandLine=\"rem bash -c &quot;perl ./unix/cons -- release-TA&quot;\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Debug|Win32\"\n\t\t\tOutputDirectory=\".\\Debug\"\n\t\t\tIntermediateDirectory=\".\\Debug\"\n\t\t\tConfigurationType=\"1\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tOptimizeForProcessor=\"1\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Debug/quake3.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug/\"\n\t\t\t\tObjectFile=\".\\Debug/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Debug/\"\n\t\t\t\tBrowseInformation=\"1\"\n\t\t\t\tBrowseInformationFile=\".\\Debug/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"winmm.lib wsock32.lib\"\n\t\t\t\tOutputFile=\".\\Debug/quake3.exe\"\n\t\t\t\tLinkIncremental=\"2\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\Debug/quake3.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\".\\Debug/quake3.map\"\n\t\t\t\tSubSystem=\"2\"\n\t\t\t\tStackReserveSize=\"8388608\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Debug/quake3.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"\n\t\t\t\tDescription=\"Post build processing..\"\n\t\t\t\tCommandLine=\"rem bash -c &quot;perl ./unix/cons -- debug&quot;\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"\n\t\t\t\tResourceOutputFileName=\"win32\\winquake.res\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Release TA DEMO|Win32\"\n\t\t\tOutputDirectory=\".\\quake3___Win32_Release_TA_DEMO\"\n\t\t\tIntermediateDirectory=\".\\quake3___Win32_Release_TA_DEMO\"\n\t\t\tConfigurationType=\"1\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"2\"\n\t\t\t\tOptimizeForProcessor=\"2\"\n\t\t\t\tPreprocessorDefinitions=\"_WIN32;WIN32;NDEBUG;_WINDOWS;PRE_RELEASE_TADEMO;PRE_RELEASE_DEMO\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"4\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\quake3___Win32_Release_TA_DEMO/quake3.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\quake3___Win32_Release_TA_DEMO/\"\n\t\t\t\tObjectFile=\".\\quake3___Win32_Release_TA_DEMO/\"\n\t\t\t\tProgramDataBaseFileName=\".\\quake3___Win32_Release_TA_DEMO/\"\n\t\t\t\tWarningLevel=\"4\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"2\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"winmm.lib wsock32.lib\"\n\t\t\t\tOutputFile=\".\\quake3___Win32_Release_TA_DEMO/quake3.exe\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\"Release_TA/quake3.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\"Release_TA/quake3.map\"\n\t\t\t\tSubSystem=\"2\"\n\t\t\t\tStackReserveSize=\"8388608\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\quake3___Win32_Release_TA_DEMO/quake3.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Release|Win32\"\n\t\t\tOutputDirectory=\".\\Release\"\n\t\t\tIntermediateDirectory=\".\\Release\"\n\t\t\tConfigurationType=\"1\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"2\"\n\t\t\t\tOptimizeForProcessor=\"2\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"4\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release/quake3.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release/\"\n\t\t\t\tObjectFile=\".\\Release/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release/\"\n\t\t\t\tWarningLevel=\"4\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"winmm.lib wsock32.lib\"\n\t\t\t\tOutputFile=\".\\Release/quake3.exe\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\Release/quake3.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\".\\Release/quake3.map\"\n\t\t\t\tSubSystem=\"2\"\n\t\t\t\tStackReserveSize=\"8388608\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Release/quake3.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Debug TA DEMO|Win32\"\n\t\t\tOutputDirectory=\".\\quake3___Win32_Debug_TA_DEMO\"\n\t\t\tIntermediateDirectory=\".\\quake3___Win32_Debug_TA_DEMO\"\n\t\t\tConfigurationType=\"1\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tOptimizeForProcessor=\"1\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;PRE_RELEASE_TADEMO;PRE_RELEASE_DEMO\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\quake3___Win32_Debug_TA_DEMO/quake3.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\quake3___Win32_Debug_TA_DEMO/\"\n\t\t\t\tObjectFile=\".\\quake3___Win32_Debug_TA_DEMO/\"\n\t\t\t\tProgramDataBaseFileName=\".\\quake3___Win32_Debug_TA_DEMO/\"\n\t\t\t\tBrowseInformation=\"1\"\n\t\t\t\tBrowseInformationFile=\".\\quake3___Win32_Debug_TA_DEMO/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"winmm.lib wsock32.lib\"\n\t\t\t\tOutputFile=\".\\quake3___Win32_Debug_TA_DEMO/quake3.exe\"\n\t\t\t\tLinkIncremental=\"2\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\quake3___Win32_Debug_TA_DEMO/quake3.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\"Debug_TA/quake3.map\"\n\t\t\t\tSubSystem=\"2\"\n\t\t\t\tStackReserveSize=\"8388608\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\quake3___Win32_Debug_TA_DEMO/quake3.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"\n\t\t\t\tResourceOutputFileName=\"win32\\winquake.res\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"vector|Win32\"\n\t\t\tOutputDirectory=\".\\quake3___Win32_vector0\"\n\t\t\tIntermediateDirectory=\".\\quake3___Win32_vector0\"\n\t\t\tConfigurationType=\"1\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tAdditionalOptions=\"/vec /vec:stats /vec:pii /vec:o10 /vec:yes \"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"2\"\n\t\t\t\tOptimizeForProcessor=\"2\"\n\t\t\t\tPreprocessorDefinitions=\"_WIN32;WIN32;NDEBUG;_WINDOWS\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"4\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\quake3___Win32_vector0/quake3.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\quake3___Win32_vector0/\"\n\t\t\t\tObjectFile=\".\\quake3___Win32_vector0/\"\n\t\t\t\tProgramDataBaseFileName=\".\\quake3___Win32_vector0/\"\n\t\t\t\tWarningLevel=\"4\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"3\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"winmm.lib wsock32.lib\"\n\t\t\t\tOutputFile=\".\\quake3___Win32_vector0/quake3.exe\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\"Release_TA/quake3.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\"Release_TA/quake3.map\"\n\t\t\t\tSubSystem=\"2\"\n\t\t\t\tStackReserveSize=\"8388608\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\quake3___Win32_vector0/quake3.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Debug TA|Win32\"\n\t\t\tOutputDirectory=\".\\Debug_TA\"\n\t\t\tIntermediateDirectory=\".\\Debug_TA\"\n\t\t\tConfigurationType=\"1\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tOptimizeForProcessor=\"1\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Debug_TA/quake3.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug_TA/\"\n\t\t\t\tObjectFile=\".\\Debug_TA/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Debug_TA/\"\n\t\t\t\tBrowseInformation=\"1\"\n\t\t\t\tBrowseInformationFile=\".\\Debug_TA/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"winmm.lib wsock32.lib\"\n\t\t\t\tOutputFile=\".\\Debug_TA/quake3.exe\"\n\t\t\t\tLinkIncremental=\"2\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\Debug_TA/quake3.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\"Debug_TA/quake3.map\"\n\t\t\t\tSubSystem=\"2\"\n\t\t\t\tStackReserveSize=\"8388608\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Debug_TA/quake3.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"\n\t\t\t\tDescription=\"Post build processing..\"\n\t\t\t\tCommandLine=\"rem bash -c &quot;perl ./unix/cons -- debug-TA&quot;\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"\n\t\t\t\tResourceOutputFileName=\"win32\\winquake.res\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t</Configurations>\n\t<References>\n\t</References>\n\t<Files>\n\t\t<Filter\n\t\t\tName=\"Source Files\"\n\t\t\tFilter=\"cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"client\\cl_cgame.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"client\\cl_cin.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"client\\cl_console.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"client\\cl_input.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"client\\cl_keys.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"client\\cl_main.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"client\\cl_net_chan.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"client\\cl_parse.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"client\\cl_scrn.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"client\\cl_ui.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\cm_load.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\cm_patch.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\cm_polylib.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\cm_test.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\cm_trace.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\cmd.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\common.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\cvar.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\files.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\huffman.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\md4.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\msg.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\net_chan.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"game\\q_math.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"game\\q_shared.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"client\\snd_adpcm.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"client\\snd_dma.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"client\\snd_mem.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"client\\snd_mix.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"client\\snd_wavelet.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"server\\sv_bot.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"server\\sv_ccmds.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"server\\sv_client.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"server\\sv_game.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"server\\sv_init.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"server\\sv_main.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"server\\sv_net_chan.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"server\\sv_snapshot.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"server\\sv_world.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\unzip.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\vm.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\vm_interpreted.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\vm_x86.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"win32\\win_input.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"win32\\win_main.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"win32\\win_net.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"win32\\win_shared.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"win32\\win_snd.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"win32\\win_syscon.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"win32\\win_wndproc.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Header Files\"\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;fi;fd\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"game\\bg_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cgame\\cg_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"client\\client.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\cm_local.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\cm_patch.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\cm_polylib.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\cm_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"game\\g_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui\\keycodes.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"client\\keys.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"game\\q_shared.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\qcommon.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\qfiles.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"renderer\\qgl.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"win32\\resource.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"server\\server.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"client\\snd_local.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"client\\snd_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"game\\surfaceflags.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"renderer\\tr_local.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"renderer\\tr_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cgame\\tr_types.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui\\ui_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\unzip.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qcommon\\vm_local.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"win32\\win_local.h\">\n\t\t\t</File>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Resource Files\"\n\t\t\tFilter=\"ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"win32\\cursor2.cur\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"win32\\cursor3.cur\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"win32\\qe3.ico\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"win32\\winquake.rc\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"win32\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"win32\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"win32\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"win32\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA DEMO|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"win32\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"win32\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"win32\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t</Filter>\n\t\t<File\n\t\t\tRelativePath=\"unix\\ChangeLog\">\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"unix\\Conscript-pk3\">\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"Construct\">\n\t\t</File>\n\t</Files>\n\t<Globals>\n\t</Globals>\n</VisualStudioProject>\n"
  },
  {
    "path": "code/renderer/qgl.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n/*\n** QGL.H\n*/\n\n#ifndef __QGL_H__\n#define __QGL_H__\n\n#if defined( __LINT__ )\n\n#include <GL/gl.h>\n\n#elif defined( _WIN32 )\n\n#pragma warning (disable: 4201)\n#pragma warning (disable: 4214)\n#pragma warning (disable: 4514)\n#pragma warning (disable: 4032)\n#pragma warning (disable: 4201)\n#pragma warning (disable: 4214)\n#include <windows.h>\n#include <gl/gl.h>\n\n#elif defined(MACOS_X)\n\n#include \"macosx_glimp.h\"\n\n#elif defined( __linux__ )\n\n#include <GL/gl.h>\n#include <GL/glx.h>\n// bk001129 - from cvs1.17 (mkv)\n#if defined(__FX__)\n#include <GL/fxmesa.h>\n#endif\n\n#elif defined( __FreeBSD__ ) // rb010123\n\n#include <GL/gl.h>\n#include <GL/glx.h>\n#if defined(__FX__)\n#include <GL/fxmesa.h>\n#endif\n\n#else\n\n#include <gl.h>\n\n#endif\n\n#ifndef APIENTRY\n#define APIENTRY\n#endif\n#ifndef WINAPI\n#define WINAPI\n#endif\n\n\n//===========================================================================\n\n/*\n** multitexture extension definitions\n*/\n#define GL_ACTIVE_TEXTURE_ARB               0x84E0\n#define GL_CLIENT_ACTIVE_TEXTURE_ARB        0x84E1\n#define GL_MAX_ACTIVE_TEXTURES_ARB          0x84E2\n\n#define GL_TEXTURE0_ARB                     0x84C0\n#define GL_TEXTURE1_ARB                     0x84C1\n#define GL_TEXTURE2_ARB                     0x84C2\n#define GL_TEXTURE3_ARB                     0x84C3\n\n// NOTE: some Linux platforms would need those prototypes\n#if defined(MACOS_X)\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v);\ntypedef void (APIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum target);\ntypedef void (APIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum target);\n#endif\n\n// TTimo - VC7 / XP ?\n#ifdef WIN32\ntypedef void (APIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);\ntypedef void (APIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum target);\ntypedef void (APIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum target);\n#endif\n\n/*\n** extension constants\n*/\n\n\n// S3TC compression constants\n#define GL_RGB_S3TC\t\t\t\t\t\t\t0x83A0\n#define GL_RGB4_S3TC\t\t\t\t\t\t0x83A1\n\n\n// extensions will be function pointers on all platforms\n\nextern\tvoid ( APIENTRY * qglMultiTexCoord2fARB )( GLenum texture, GLfloat s, GLfloat t );\nextern\tvoid ( APIENTRY * qglActiveTextureARB )( GLenum texture );\nextern\tvoid ( APIENTRY * qglClientActiveTextureARB )( GLenum texture );\n\nextern\tvoid ( APIENTRY * qglLockArraysEXT) (GLint, GLint);\nextern\tvoid ( APIENTRY * qglUnlockArraysEXT) (void);\n\n//===========================================================================\n\n// non-windows systems will just redefine qgl* to gl*\n#if !defined( _WIN32 ) && !defined(MACOS_X) && !defined( __linux__ ) && !defined( __FreeBSD__ ) // rb010123\n\n#include \"qgl_linked.h\"\n\n#elif defined(MACOS_X)\n// This includes #ifdefs for optional logging and GL error checking after every GL call as well as #defines to prevent incorrect usage of the non-'qgl' versions of the GL API.\n#include \"macosx_qgl.h\"\n\n#else\n\n// windows systems use a function pointer for each call so we can load minidrivers\n\nextern  void ( APIENTRY * qglAccum )(GLenum op, GLfloat value);\nextern  void ( APIENTRY * qglAlphaFunc )(GLenum func, GLclampf ref);\nextern  GLboolean ( APIENTRY * qglAreTexturesResident )(GLsizei n, const GLuint *textures, GLboolean *residences);\nextern  void ( APIENTRY * qglArrayElement )(GLint i);\nextern  void ( APIENTRY * qglBegin )(GLenum mode);\nextern  void ( APIENTRY * qglBindTexture )(GLenum target, GLuint texture);\nextern  void ( APIENTRY * qglBitmap )(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);\nextern  void ( APIENTRY * qglBlendFunc )(GLenum sfactor, GLenum dfactor);\nextern  void ( APIENTRY * qglCallList )(GLuint list);\nextern  void ( APIENTRY * qglCallLists )(GLsizei n, GLenum type, const GLvoid *lists);\nextern  void ( APIENTRY * qglClear )(GLbitfield mask);\nextern  void ( APIENTRY * qglClearAccum )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nextern  void ( APIENTRY * qglClearColor )(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);\nextern  void ( APIENTRY * qglClearDepth )(GLclampd depth);\nextern  void ( APIENTRY * qglClearIndex )(GLfloat c);\nextern  void ( APIENTRY * qglClearStencil )(GLint s);\nextern  void ( APIENTRY * qglClipPlane )(GLenum plane, const GLdouble *equation);\nextern  void ( APIENTRY * qglColor3b )(GLbyte red, GLbyte green, GLbyte blue);\nextern  void ( APIENTRY * qglColor3bv )(const GLbyte *v);\nextern  void ( APIENTRY * qglColor3d )(GLdouble red, GLdouble green, GLdouble blue);\nextern  void ( APIENTRY * qglColor3dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglColor3f )(GLfloat red, GLfloat green, GLfloat blue);\nextern  void ( APIENTRY * qglColor3fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglColor3i )(GLint red, GLint green, GLint blue);\nextern  void ( APIENTRY * qglColor3iv )(const GLint *v);\nextern  void ( APIENTRY * qglColor3s )(GLshort red, GLshort green, GLshort blue);\nextern  void ( APIENTRY * qglColor3sv )(const GLshort *v);\nextern  void ( APIENTRY * qglColor3ub )(GLubyte red, GLubyte green, GLubyte blue);\nextern  void ( APIENTRY * qglColor3ubv )(const GLubyte *v);\nextern  void ( APIENTRY * qglColor3ui )(GLuint red, GLuint green, GLuint blue);\nextern  void ( APIENTRY * qglColor3uiv )(const GLuint *v);\nextern  void ( APIENTRY * qglColor3us )(GLushort red, GLushort green, GLushort blue);\nextern  void ( APIENTRY * qglColor3usv )(const GLushort *v);\nextern  void ( APIENTRY * qglColor4b )(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha);\nextern  void ( APIENTRY * qglColor4bv )(const GLbyte *v);\nextern  void ( APIENTRY * qglColor4d )(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);\nextern  void ( APIENTRY * qglColor4dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglColor4f )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nextern  void ( APIENTRY * qglColor4fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglColor4i )(GLint red, GLint green, GLint blue, GLint alpha);\nextern  void ( APIENTRY * qglColor4iv )(const GLint *v);\nextern  void ( APIENTRY * qglColor4s )(GLshort red, GLshort green, GLshort blue, GLshort alpha);\nextern  void ( APIENTRY * qglColor4sv )(const GLshort *v);\nextern  void ( APIENTRY * qglColor4ub )(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);\nextern  void ( APIENTRY * qglColor4ubv )(const GLubyte *v);\nextern  void ( APIENTRY * qglColor4ui )(GLuint red, GLuint green, GLuint blue, GLuint alpha);\nextern  void ( APIENTRY * qglColor4uiv )(const GLuint *v);\nextern  void ( APIENTRY * qglColor4us )(GLushort red, GLushort green, GLushort blue, GLushort alpha);\nextern  void ( APIENTRY * qglColor4usv )(const GLushort *v);\nextern  void ( APIENTRY * qglColorMask )(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);\nextern  void ( APIENTRY * qglColorMaterial )(GLenum face, GLenum mode);\nextern  void ( APIENTRY * qglColorPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nextern  void ( APIENTRY * qglCopyPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);\nextern  void ( APIENTRY * qglCopyTexImage1D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border);\nextern  void ( APIENTRY * qglCopyTexImage2D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\nextern  void ( APIENTRY * qglCopyTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\nextern  void ( APIENTRY * qglCopyTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nextern  void ( APIENTRY * qglCullFace )(GLenum mode);\nextern  void ( APIENTRY * qglDeleteLists )(GLuint list, GLsizei range);\nextern  void ( APIENTRY * qglDeleteTextures )(GLsizei n, const GLuint *textures);\nextern  void ( APIENTRY * qglDepthFunc )(GLenum func);\nextern  void ( APIENTRY * qglDepthMask )(GLboolean flag);\nextern  void ( APIENTRY * qglDepthRange )(GLclampd zNear, GLclampd zFar);\nextern  void ( APIENTRY * qglDisable )(GLenum cap);\nextern  void ( APIENTRY * qglDisableClientState )(GLenum array);\nextern  void ( APIENTRY * qglDrawArrays )(GLenum mode, GLint first, GLsizei count);\nextern  void ( APIENTRY * qglDrawBuffer )(GLenum mode);\nextern  void ( APIENTRY * qglDrawElements )(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);\nextern  void ( APIENTRY * qglDrawPixels )(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nextern  void ( APIENTRY * qglEdgeFlag )(GLboolean flag);\nextern  void ( APIENTRY * qglEdgeFlagPointer )(GLsizei stride, const GLvoid *pointer);\nextern  void ( APIENTRY * qglEdgeFlagv )(const GLboolean *flag);\nextern  void ( APIENTRY * qglEnable )(GLenum cap);\nextern  void ( APIENTRY * qglEnableClientState )(GLenum array);\nextern  void ( APIENTRY * qglEnd )(void);\nextern  void ( APIENTRY * qglEndList )(void);\nextern  void ( APIENTRY * qglEvalCoord1d )(GLdouble u);\nextern  void ( APIENTRY * qglEvalCoord1dv )(const GLdouble *u);\nextern  void ( APIENTRY * qglEvalCoord1f )(GLfloat u);\nextern  void ( APIENTRY * qglEvalCoord1fv )(const GLfloat *u);\nextern  void ( APIENTRY * qglEvalCoord2d )(GLdouble u, GLdouble v);\nextern  void ( APIENTRY * qglEvalCoord2dv )(const GLdouble *u);\nextern  void ( APIENTRY * qglEvalCoord2f )(GLfloat u, GLfloat v);\nextern  void ( APIENTRY * qglEvalCoord2fv )(const GLfloat *u);\nextern  void ( APIENTRY * qglEvalMesh1 )(GLenum mode, GLint i1, GLint i2);\nextern  void ( APIENTRY * qglEvalMesh2 )(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);\nextern  void ( APIENTRY * qglEvalPoint1 )(GLint i);\nextern  void ( APIENTRY * qglEvalPoint2 )(GLint i, GLint j);\nextern  void ( APIENTRY * qglFeedbackBuffer )(GLsizei size, GLenum type, GLfloat *buffer);\nextern  void ( APIENTRY * qglFinish )(void);\nextern  void ( APIENTRY * qglFlush )(void);\nextern  void ( APIENTRY * qglFogf )(GLenum pname, GLfloat param);\nextern  void ( APIENTRY * qglFogfv )(GLenum pname, const GLfloat *params);\nextern  void ( APIENTRY * qglFogi )(GLenum pname, GLint param);\nextern  void ( APIENTRY * qglFogiv )(GLenum pname, const GLint *params);\nextern  void ( APIENTRY * qglFrontFace )(GLenum mode);\nextern  void ( APIENTRY * qglFrustum )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nextern  GLuint ( APIENTRY * qglGenLists )(GLsizei range);\nextern  void ( APIENTRY * qglGenTextures )(GLsizei n, GLuint *textures);\nextern  void ( APIENTRY * qglGetBooleanv )(GLenum pname, GLboolean *params);\nextern  void ( APIENTRY * qglGetClipPlane )(GLenum plane, GLdouble *equation);\nextern  void ( APIENTRY * qglGetDoublev )(GLenum pname, GLdouble *params);\nextern  GLenum ( APIENTRY * qglGetError )(void);\nextern  void ( APIENTRY * qglGetFloatv )(GLenum pname, GLfloat *params);\nextern  void ( APIENTRY * qglGetIntegerv )(GLenum pname, GLint *params);\nextern  void ( APIENTRY * qglGetLightfv )(GLenum light, GLenum pname, GLfloat *params);\nextern  void ( APIENTRY * qglGetLightiv )(GLenum light, GLenum pname, GLint *params);\nextern  void ( APIENTRY * qglGetMapdv )(GLenum target, GLenum query, GLdouble *v);\nextern  void ( APIENTRY * qglGetMapfv )(GLenum target, GLenum query, GLfloat *v);\nextern  void ( APIENTRY * qglGetMapiv )(GLenum target, GLenum query, GLint *v);\nextern  void ( APIENTRY * qglGetMaterialfv )(GLenum face, GLenum pname, GLfloat *params);\nextern  void ( APIENTRY * qglGetMaterialiv )(GLenum face, GLenum pname, GLint *params);\nextern  void ( APIENTRY * qglGetPixelMapfv )(GLenum map, GLfloat *values);\nextern  void ( APIENTRY * qglGetPixelMapuiv )(GLenum map, GLuint *values);\nextern  void ( APIENTRY * qglGetPixelMapusv )(GLenum map, GLushort *values);\nextern  void ( APIENTRY * qglGetPointerv )(GLenum pname, GLvoid* *params);\nextern  void ( APIENTRY * qglGetPolygonStipple )(GLubyte *mask);\nextern  const GLubyte * ( APIENTRY * qglGetString )(GLenum name);\nextern  void ( APIENTRY * qglGetTexEnvfv )(GLenum target, GLenum pname, GLfloat *params);\nextern  void ( APIENTRY * qglGetTexEnviv )(GLenum target, GLenum pname, GLint *params);\nextern  void ( APIENTRY * qglGetTexGendv )(GLenum coord, GLenum pname, GLdouble *params);\nextern  void ( APIENTRY * qglGetTexGenfv )(GLenum coord, GLenum pname, GLfloat *params);\nextern  void ( APIENTRY * qglGetTexGeniv )(GLenum coord, GLenum pname, GLint *params);\nextern  void ( APIENTRY * qglGetTexImage )(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);\nextern  void ( APIENTRY * qglGetTexLevelParameterfv )(GLenum target, GLint level, GLenum pname, GLfloat *params);\nextern  void ( APIENTRY * qglGetTexLevelParameteriv )(GLenum target, GLint level, GLenum pname, GLint *params);\nextern  void ( APIENTRY * qglGetTexParameterfv )(GLenum target, GLenum pname, GLfloat *params);\nextern  void ( APIENTRY * qglGetTexParameteriv )(GLenum target, GLenum pname, GLint *params);\nextern  void ( APIENTRY * qglHint )(GLenum target, GLenum mode);\nextern  void ( APIENTRY * qglIndexMask )(GLuint mask);\nextern  void ( APIENTRY * qglIndexPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);\nextern  void ( APIENTRY * qglIndexd )(GLdouble c);\nextern  void ( APIENTRY * qglIndexdv )(const GLdouble *c);\nextern  void ( APIENTRY * qglIndexf )(GLfloat c);\nextern  void ( APIENTRY * qglIndexfv )(const GLfloat *c);\nextern  void ( APIENTRY * qglIndexi )(GLint c);\nextern  void ( APIENTRY * qglIndexiv )(const GLint *c);\nextern  void ( APIENTRY * qglIndexs )(GLshort c);\nextern  void ( APIENTRY * qglIndexsv )(const GLshort *c);\nextern  void ( APIENTRY * qglIndexub )(GLubyte c);\nextern  void ( APIENTRY * qglIndexubv )(const GLubyte *c);\nextern  void ( APIENTRY * qglInitNames )(void);\nextern  void ( APIENTRY * qglInterleavedArrays )(GLenum format, GLsizei stride, const GLvoid *pointer);\nextern  GLboolean ( APIENTRY * qglIsEnabled )(GLenum cap);\nextern  GLboolean ( APIENTRY * qglIsList )(GLuint list);\nextern  GLboolean ( APIENTRY * qglIsTexture )(GLuint texture);\nextern  void ( APIENTRY * qglLightModelf )(GLenum pname, GLfloat param);\nextern  void ( APIENTRY * qglLightModelfv )(GLenum pname, const GLfloat *params);\nextern  void ( APIENTRY * qglLightModeli )(GLenum pname, GLint param);\nextern  void ( APIENTRY * qglLightModeliv )(GLenum pname, const GLint *params);\nextern  void ( APIENTRY * qglLightf )(GLenum light, GLenum pname, GLfloat param);\nextern  void ( APIENTRY * qglLightfv )(GLenum light, GLenum pname, const GLfloat *params);\nextern  void ( APIENTRY * qglLighti )(GLenum light, GLenum pname, GLint param);\nextern  void ( APIENTRY * qglLightiv )(GLenum light, GLenum pname, const GLint *params);\nextern  void ( APIENTRY * qglLineStipple )(GLint factor, GLushort pattern);\nextern  void ( APIENTRY * qglLineWidth )(GLfloat width);\nextern  void ( APIENTRY * qglListBase )(GLuint base);\nextern  void ( APIENTRY * qglLoadIdentity )(void);\nextern  void ( APIENTRY * qglLoadMatrixd )(const GLdouble *m);\nextern  void ( APIENTRY * qglLoadMatrixf )(const GLfloat *m);\nextern  void ( APIENTRY * qglLoadName )(GLuint name);\nextern  void ( APIENTRY * qglLogicOp )(GLenum opcode);\nextern  void ( APIENTRY * qglMap1d )(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);\nextern  void ( APIENTRY * qglMap1f )(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);\nextern  void ( APIENTRY * qglMap2d )(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);\nextern  void ( APIENTRY * qglMap2f )(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);\nextern  void ( APIENTRY * qglMapGrid1d )(GLint un, GLdouble u1, GLdouble u2);\nextern  void ( APIENTRY * qglMapGrid1f )(GLint un, GLfloat u1, GLfloat u2);\nextern  void ( APIENTRY * qglMapGrid2d )(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);\nextern  void ( APIENTRY * qglMapGrid2f )(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);\nextern  void ( APIENTRY * qglMaterialf )(GLenum face, GLenum pname, GLfloat param);\nextern  void ( APIENTRY * qglMaterialfv )(GLenum face, GLenum pname, const GLfloat *params);\nextern  void ( APIENTRY * qglMateriali )(GLenum face, GLenum pname, GLint param);\nextern  void ( APIENTRY * qglMaterialiv )(GLenum face, GLenum pname, const GLint *params);\nextern  void ( APIENTRY * qglMatrixMode )(GLenum mode);\nextern  void ( APIENTRY * qglMultMatrixd )(const GLdouble *m);\nextern  void ( APIENTRY * qglMultMatrixf )(const GLfloat *m);\nextern  void ( APIENTRY * qglNewList )(GLuint list, GLenum mode);\nextern  void ( APIENTRY * qglNormal3b )(GLbyte nx, GLbyte ny, GLbyte nz);\nextern  void ( APIENTRY * qglNormal3bv )(const GLbyte *v);\nextern  void ( APIENTRY * qglNormal3d )(GLdouble nx, GLdouble ny, GLdouble nz);\nextern  void ( APIENTRY * qglNormal3dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglNormal3f )(GLfloat nx, GLfloat ny, GLfloat nz);\nextern  void ( APIENTRY * qglNormal3fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglNormal3i )(GLint nx, GLint ny, GLint nz);\nextern  void ( APIENTRY * qglNormal3iv )(const GLint *v);\nextern  void ( APIENTRY * qglNormal3s )(GLshort nx, GLshort ny, GLshort nz);\nextern  void ( APIENTRY * qglNormal3sv )(const GLshort *v);\nextern  void ( APIENTRY * qglNormalPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);\nextern  void ( APIENTRY * qglOrtho )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nextern  void ( APIENTRY * qglPassThrough )(GLfloat token);\nextern  void ( APIENTRY * qglPixelMapfv )(GLenum map, GLsizei mapsize, const GLfloat *values);\nextern  void ( APIENTRY * qglPixelMapuiv )(GLenum map, GLsizei mapsize, const GLuint *values);\nextern  void ( APIENTRY * qglPixelMapusv )(GLenum map, GLsizei mapsize, const GLushort *values);\nextern  void ( APIENTRY * qglPixelStoref )(GLenum pname, GLfloat param);\nextern  void ( APIENTRY * qglPixelStorei )(GLenum pname, GLint param);\nextern  void ( APIENTRY * qglPixelTransferf )(GLenum pname, GLfloat param);\nextern  void ( APIENTRY * qglPixelTransferi )(GLenum pname, GLint param);\nextern  void ( APIENTRY * qglPixelZoom )(GLfloat xfactor, GLfloat yfactor);\nextern  void ( APIENTRY * qglPointSize )(GLfloat size);\nextern  void ( APIENTRY * qglPolygonMode )(GLenum face, GLenum mode);\nextern  void ( APIENTRY * qglPolygonOffset )(GLfloat factor, GLfloat units);\nextern  void ( APIENTRY * qglPolygonStipple )(const GLubyte *mask);\nextern  void ( APIENTRY * qglPopAttrib )(void);\nextern  void ( APIENTRY * qglPopClientAttrib )(void);\nextern  void ( APIENTRY * qglPopMatrix )(void);\nextern  void ( APIENTRY * qglPopName )(void);\nextern  void ( APIENTRY * qglPrioritizeTextures )(GLsizei n, const GLuint *textures, const GLclampf *priorities);\nextern  void ( APIENTRY * qglPushAttrib )(GLbitfield mask);\nextern  void ( APIENTRY * qglPushClientAttrib )(GLbitfield mask);\nextern  void ( APIENTRY * qglPushMatrix )(void);\nextern  void ( APIENTRY * qglPushName )(GLuint name);\nextern  void ( APIENTRY * qglRasterPos2d )(GLdouble x, GLdouble y);\nextern  void ( APIENTRY * qglRasterPos2dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglRasterPos2f )(GLfloat x, GLfloat y);\nextern  void ( APIENTRY * qglRasterPos2fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglRasterPos2i )(GLint x, GLint y);\nextern  void ( APIENTRY * qglRasterPos2iv )(const GLint *v);\nextern  void ( APIENTRY * qglRasterPos2s )(GLshort x, GLshort y);\nextern  void ( APIENTRY * qglRasterPos2sv )(const GLshort *v);\nextern  void ( APIENTRY * qglRasterPos3d )(GLdouble x, GLdouble y, GLdouble z);\nextern  void ( APIENTRY * qglRasterPos3dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglRasterPos3f )(GLfloat x, GLfloat y, GLfloat z);\nextern  void ( APIENTRY * qglRasterPos3fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglRasterPos3i )(GLint x, GLint y, GLint z);\nextern  void ( APIENTRY * qglRasterPos3iv )(const GLint *v);\nextern  void ( APIENTRY * qglRasterPos3s )(GLshort x, GLshort y, GLshort z);\nextern  void ( APIENTRY * qglRasterPos3sv )(const GLshort *v);\nextern  void ( APIENTRY * qglRasterPos4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nextern  void ( APIENTRY * qglRasterPos4dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglRasterPos4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nextern  void ( APIENTRY * qglRasterPos4fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglRasterPos4i )(GLint x, GLint y, GLint z, GLint w);\nextern  void ( APIENTRY * qglRasterPos4iv )(const GLint *v);\nextern  void ( APIENTRY * qglRasterPos4s )(GLshort x, GLshort y, GLshort z, GLshort w);\nextern  void ( APIENTRY * qglRasterPos4sv )(const GLshort *v);\nextern  void ( APIENTRY * qglReadBuffer )(GLenum mode);\nextern  void ( APIENTRY * qglReadPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);\nextern  void ( APIENTRY * qglRectd )(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);\nextern  void ( APIENTRY * qglRectdv )(const GLdouble *v1, const GLdouble *v2);\nextern  void ( APIENTRY * qglRectf )(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);\nextern  void ( APIENTRY * qglRectfv )(const GLfloat *v1, const GLfloat *v2);\nextern  void ( APIENTRY * qglRecti )(GLint x1, GLint y1, GLint x2, GLint y2);\nextern  void ( APIENTRY * qglRectiv )(const GLint *v1, const GLint *v2);\nextern  void ( APIENTRY * qglRects )(GLshort x1, GLshort y1, GLshort x2, GLshort y2);\nextern  void ( APIENTRY * qglRectsv )(const GLshort *v1, const GLshort *v2);\nextern  GLint ( APIENTRY * qglRenderMode )(GLenum mode);\nextern  void ( APIENTRY * qglRotated )(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);\nextern  void ( APIENTRY * qglRotatef )(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);\nextern  void ( APIENTRY * qglScaled )(GLdouble x, GLdouble y, GLdouble z);\nextern  void ( APIENTRY * qglScalef )(GLfloat x, GLfloat y, GLfloat z);\nextern  void ( APIENTRY * qglScissor )(GLint x, GLint y, GLsizei width, GLsizei height);\nextern  void ( APIENTRY * qglSelectBuffer )(GLsizei size, GLuint *buffer);\nextern  void ( APIENTRY * qglShadeModel )(GLenum mode);\nextern  void ( APIENTRY * qglStencilFunc )(GLenum func, GLint ref, GLuint mask);\nextern  void ( APIENTRY * qglStencilMask )(GLuint mask);\nextern  void ( APIENTRY * qglStencilOp )(GLenum fail, GLenum zfail, GLenum zpass);\nextern  void ( APIENTRY * qglTexCoord1d )(GLdouble s);\nextern  void ( APIENTRY * qglTexCoord1dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglTexCoord1f )(GLfloat s);\nextern  void ( APIENTRY * qglTexCoord1fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglTexCoord1i )(GLint s);\nextern  void ( APIENTRY * qglTexCoord1iv )(const GLint *v);\nextern  void ( APIENTRY * qglTexCoord1s )(GLshort s);\nextern  void ( APIENTRY * qglTexCoord1sv )(const GLshort *v);\nextern  void ( APIENTRY * qglTexCoord2d )(GLdouble s, GLdouble t);\nextern  void ( APIENTRY * qglTexCoord2dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglTexCoord2f )(GLfloat s, GLfloat t);\nextern  void ( APIENTRY * qglTexCoord2fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglTexCoord2i )(GLint s, GLint t);\nextern  void ( APIENTRY * qglTexCoord2iv )(const GLint *v);\nextern  void ( APIENTRY * qglTexCoord2s )(GLshort s, GLshort t);\nextern  void ( APIENTRY * qglTexCoord2sv )(const GLshort *v);\nextern  void ( APIENTRY * qglTexCoord3d )(GLdouble s, GLdouble t, GLdouble r);\nextern  void ( APIENTRY * qglTexCoord3dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglTexCoord3f )(GLfloat s, GLfloat t, GLfloat r);\nextern  void ( APIENTRY * qglTexCoord3fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglTexCoord3i )(GLint s, GLint t, GLint r);\nextern  void ( APIENTRY * qglTexCoord3iv )(const GLint *v);\nextern  void ( APIENTRY * qglTexCoord3s )(GLshort s, GLshort t, GLshort r);\nextern  void ( APIENTRY * qglTexCoord3sv )(const GLshort *v);\nextern  void ( APIENTRY * qglTexCoord4d )(GLdouble s, GLdouble t, GLdouble r, GLdouble q);\nextern  void ( APIENTRY * qglTexCoord4dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglTexCoord4f )(GLfloat s, GLfloat t, GLfloat r, GLfloat q);\nextern  void ( APIENTRY * qglTexCoord4fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglTexCoord4i )(GLint s, GLint t, GLint r, GLint q);\nextern  void ( APIENTRY * qglTexCoord4iv )(const GLint *v);\nextern  void ( APIENTRY * qglTexCoord4s )(GLshort s, GLshort t, GLshort r, GLshort q);\nextern  void ( APIENTRY * qglTexCoord4sv )(const GLshort *v);\nextern  void ( APIENTRY * qglTexCoordPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nextern  void ( APIENTRY * qglTexEnvf )(GLenum target, GLenum pname, GLfloat param);\nextern  void ( APIENTRY * qglTexEnvfv )(GLenum target, GLenum pname, const GLfloat *params);\nextern  void ( APIENTRY * qglTexEnvi )(GLenum target, GLenum pname, GLint param);\nextern  void ( APIENTRY * qglTexEnviv )(GLenum target, GLenum pname, const GLint *params);\nextern  void ( APIENTRY * qglTexGend )(GLenum coord, GLenum pname, GLdouble param);\nextern  void ( APIENTRY * qglTexGendv )(GLenum coord, GLenum pname, const GLdouble *params);\nextern  void ( APIENTRY * qglTexGenf )(GLenum coord, GLenum pname, GLfloat param);\nextern  void ( APIENTRY * qglTexGenfv )(GLenum coord, GLenum pname, const GLfloat *params);\nextern  void ( APIENTRY * qglTexGeni )(GLenum coord, GLenum pname, GLint param);\nextern  void ( APIENTRY * qglTexGeniv )(GLenum coord, GLenum pname, const GLint *params);\nextern  void ( APIENTRY * qglTexImage1D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nextern  void ( APIENTRY * qglTexImage2D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nextern  void ( APIENTRY * qglTexParameterf )(GLenum target, GLenum pname, GLfloat param);\nextern  void ( APIENTRY * qglTexParameterfv )(GLenum target, GLenum pname, const GLfloat *params);\nextern  void ( APIENTRY * qglTexParameteri )(GLenum target, GLenum pname, GLint param);\nextern  void ( APIENTRY * qglTexParameteriv )(GLenum target, GLenum pname, const GLint *params);\nextern  void ( APIENTRY * qglTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);\nextern  void ( APIENTRY * qglTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nextern  void ( APIENTRY * qglTranslated )(GLdouble x, GLdouble y, GLdouble z);\nextern  void ( APIENTRY * qglTranslatef )(GLfloat x, GLfloat y, GLfloat z);\nextern  void ( APIENTRY * qglVertex2d )(GLdouble x, GLdouble y);\nextern  void ( APIENTRY * qglVertex2dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglVertex2f )(GLfloat x, GLfloat y);\nextern  void ( APIENTRY * qglVertex2fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglVertex2i )(GLint x, GLint y);\nextern  void ( APIENTRY * qglVertex2iv )(const GLint *v);\nextern  void ( APIENTRY * qglVertex2s )(GLshort x, GLshort y);\nextern  void ( APIENTRY * qglVertex2sv )(const GLshort *v);\nextern  void ( APIENTRY * qglVertex3d )(GLdouble x, GLdouble y, GLdouble z);\nextern  void ( APIENTRY * qglVertex3dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglVertex3f )(GLfloat x, GLfloat y, GLfloat z);\nextern  void ( APIENTRY * qglVertex3fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglVertex3i )(GLint x, GLint y, GLint z);\nextern  void ( APIENTRY * qglVertex3iv )(const GLint *v);\nextern  void ( APIENTRY * qglVertex3s )(GLshort x, GLshort y, GLshort z);\nextern  void ( APIENTRY * qglVertex3sv )(const GLshort *v);\nextern  void ( APIENTRY * qglVertex4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nextern  void ( APIENTRY * qglVertex4dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglVertex4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nextern  void ( APIENTRY * qglVertex4fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglVertex4i )(GLint x, GLint y, GLint z, GLint w);\nextern  void ( APIENTRY * qglVertex4iv )(const GLint *v);\nextern  void ( APIENTRY * qglVertex4s )(GLshort x, GLshort y, GLshort z, GLshort w);\nextern  void ( APIENTRY * qglVertex4sv )(const GLshort *v);\nextern  void ( APIENTRY * qglVertexPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nextern  void ( APIENTRY * qglViewport )(GLint x, GLint y, GLsizei width, GLsizei height);\n\n#if defined( _WIN32 )\n\nextern  int   ( WINAPI * qwglChoosePixelFormat )(HDC, CONST PIXELFORMATDESCRIPTOR *);\nextern  int   ( WINAPI * qwglDescribePixelFormat) (HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);\nextern  int   ( WINAPI * qwglGetPixelFormat)(HDC);\nextern  BOOL  ( WINAPI * qwglSetPixelFormat)(HDC, int, CONST PIXELFORMATDESCRIPTOR *);\nextern  BOOL  ( WINAPI * qwglSwapBuffers)(HDC);\n\nextern\tBOOL  ( WINAPI * qwglGetDeviceGammaRamp3DFX)( HDC, LPVOID );\nextern\tBOOL  ( WINAPI * qwglSetDeviceGammaRamp3DFX)( HDC, LPVOID );\n\nextern BOOL  ( WINAPI * qwglCopyContext)(HGLRC, HGLRC, UINT);\nextern HGLRC ( WINAPI * qwglCreateContext)(HDC);\nextern HGLRC ( WINAPI * qwglCreateLayerContext)(HDC, int);\nextern BOOL  ( WINAPI * qwglDeleteContext)(HGLRC);\nextern HGLRC ( WINAPI * qwglGetCurrentContext)(VOID);\nextern HDC   ( WINAPI * qwglGetCurrentDC)(VOID);\nextern PROC  ( WINAPI * qwglGetProcAddress)(LPCSTR);\nextern BOOL  ( WINAPI * qwglMakeCurrent)(HDC, HGLRC);\nextern BOOL  ( WINAPI * qwglShareLists)(HGLRC, HGLRC);\nextern BOOL  ( WINAPI * qwglUseFontBitmaps)(HDC, DWORD, DWORD, DWORD);\n\nextern BOOL  ( WINAPI * qwglUseFontOutlines)(HDC, DWORD, DWORD, DWORD, FLOAT,\n                                           FLOAT, int, LPGLYPHMETRICSFLOAT);\n\nextern BOOL ( WINAPI * qwglDescribeLayerPlane)(HDC, int, int, UINT,\n                                            LPLAYERPLANEDESCRIPTOR);\nextern int  ( WINAPI * qwglSetLayerPaletteEntries)(HDC, int, int, int,\n                                                CONST COLORREF *);\nextern int  ( WINAPI * qwglGetLayerPaletteEntries)(HDC, int, int, int,\n                                                COLORREF *);\nextern BOOL ( WINAPI * qwglRealizeLayerPalette)(HDC, int, BOOL);\nextern BOOL ( WINAPI * qwglSwapLayerBuffers)(HDC, UINT);\n\nextern BOOL ( WINAPI * qwglSwapIntervalEXT)( int interval );\n\n#endif\t// _WIN32\n\n#if ( (defined __linux__ )  || (defined __FreeBSD__ ) ) // rb010123\n\n//FX Mesa Functions\n// bk001129 - from cvs1.17 (mkv)\n#if defined (__FX__)\nextern fxMesaContext (*qfxMesaCreateContext)(GLuint win, GrScreenResolution_t, GrScreenRefresh_t, const GLint attribList[]);\nextern fxMesaContext (*qfxMesaCreateBestContext)(GLuint win, GLint width, GLint height, const GLint attribList[]);\nextern void (*qfxMesaDestroyContext)(fxMesaContext ctx);\nextern void (*qfxMesaMakeCurrent)(fxMesaContext ctx);\nextern fxMesaContext (*qfxMesaGetCurrentContext)(void);\nextern void (*qfxMesaSwapBuffers)(void);\n#endif\n\n//GLX Functions\nextern XVisualInfo * (*qglXChooseVisual)( Display *dpy, int screen, int *attribList );\nextern GLXContext (*qglXCreateContext)( Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct );\nextern void (*qglXDestroyContext)( Display *dpy, GLXContext ctx );\nextern Bool (*qglXMakeCurrent)( Display *dpy, GLXDrawable drawable, GLXContext ctx);\nextern void (*qglXCopyContext)( Display *dpy, GLXContext src, GLXContext dst, GLuint mask );\nextern void (*qglXSwapBuffers)( Display *dpy, GLXDrawable drawable );\n\n#endif // __linux__ || __FreeBSD__ // rb010123\n\n#endif\t// _WIN32 && __linux__\n\n#endif\n"
  },
  {
    "path": "code/renderer/qgl_linked.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#define qglAccum glAccum\n#define qglAlphaFunc glAlphaFunc\n#define qglAreTexturesResident glAreTexturesResident\n#define qglArrayElement glArrayElement\n#define qglBegin glBegin\n#define qglBindTexture glBindTexture\n#define qglBitmap glBitmap\n#define qglBlendFunc glBlendFunc\n#define qglCallList glCallList\n#define qglCallLists glCallLists\n#define qglClear glClear\n#define qglClearAccum glClearAccum\n#define qglClearColor glClearColor\n#define qglClearDepth glClearDepth\n#define qglClearIndex glClearIndex\n#define qglClearStencil glClearStencil\n#define qglClipPlane glClipPlane\n#define qglColor3b glColor3b\n#define qglColor3bv glColor3bv\n#define qglColor3d glColor3d\n#define qglColor3dv glColor3dv\n#define qglColor3f glColor3f\n#define qglColor3fv glColor3fv\n#define qglColor3i glColor3i\n#define qglColor3iv glColor3iv\n#define qglColor3s glColor3s\n#define qglColor3sv glColor3sv\n#define qglColor3ub glColor3ub\n#define qglColor3ubv glColor3ubv\n#define qglColor3ui glColor3ui\n#define qglColor3uiv glColor3uiv\n#define qglColor3us glColor3us\n#define qglColor3usv glColor3usv\n#define qglColor4b glColor4b\n#define qglColor4bv glColor4bv\n#define qglColor4d glColor4d\n#define qglColor4dv glColor4dv\n#define qglColor4f glColor4f\n#define qglColor4fv glColor4fv\n#define qglColor4i glColor4i\n#define qglColor4iv glColor4iv\n#define qglColor4s glColor4s\n#define qglColor4sv glColor4sv\n#define qglColor4ub glColor4ub\n#define qglColor4ubv glColor4ubv\n#define qglColor4ui glColor4ui\n#define qglColor4uiv glColor4uiv\n#define qglColor4us glColor4us\n#define qglColor4usv glColor4usv\n#define qglColorMask glColorMask\n#define qglColorMaterial glColorMaterial\n#define qglColorPointer glColorPointer\n#define qglCopyPixels glCopyPixels\n#define qglCopyTexImage1D glCopyTexImage1D\n#define qglCopyTexImage2D glCopyTexImage2D\n#define qglCopyTexSubImage1D glCopyTexSubImage1D\n#define qglCopyTexSubImage2D glCopyTexSubImage2D\n#define qglCullFace glCullFace\n#define qglDeleteLists glDeleteLists\n#define qglDeleteTextures glDeleteTextures\n#define qglDepthFunc glDepthFunc\n#define qglDepthMask glDepthMask\n#define qglDepthRange glDepthRange\n#define qglDisable glDisable\n#define qglDisableClientState glDisableClientState\n#define qglDrawArrays glDrawArrays\n#define qglDrawBuffer glDrawBuffer\n#define qglDrawElements glDrawElements\n#define qglDrawPixels glDrawPixels\n#define qglEdgeFlag glEdgeFlag\n#define qglEdgeFlagPointer glEdgeFlagPointer\n#define qglEdgeFlagv glEdgeFlagv\n#define qglEnable glEnable\n#define qglEnableClientState glEnableClientState\n#define qglEnd glEnd\n#define qglEndList glEndList\n#define qglEvalCoord1d glEvalCoord1d\n#define qglEvalCoord1dv glEvalCoord1dv\n#define qglEvalCoord1f glEvalCoord1f\n#define qglEvalCoord1fv glEvalCoord1fv\n#define qglEvalCoord2d glEvalCoord2d\n#define qglEvalCoord2dv glEvalCoord2dv\n#define qglEvalCoord2f glEvalCoord2f\n#define qglEvalCoord2fv glEvalCoord2fv\n#define qglEvalMesh1 glEvalMesh1\n#define qglEvalMesh2 glEvalMesh2\n#define qglEvalPoint1 glEvalPoint1\n#define qglEvalPoint2 glEvalPoint2\n#define qglFeedbackBuffer glFeedbackBuffer\n#define qglFinish glFinish\n#define qglFlush glFlush\n#define qglFogf glFogf\n#define qglFogfv glFogfv\n#define qglFogi glFogi\n#define qglFogiv glFogiv\n#define qglFrontFace glFrontFace\n#define qglFrustum glFrustum\n#define qglGenLists glGenLists\n#define qglGenTextures glGenTextures\n#define qglGetBooleanv glGetBooleanv\n#define qglGetClipPlane glGetClipPlane\n#define qglGetDoublev glGetDoublev\n#define qglGetError glGetError\n#define qglGetFloatv glGetFloatv\n#define qglGetIntegerv glGetIntegerv\n#define qglGetLightfv glGetLightfv\n#define qglGetLightiv glGetLightiv\n#define qglGetMapdv glGetMapdv\n#define qglGetMapfv glGetMapfv\n#define qglGetMapiv glGetMapiv\n#define qglGetMaterialfv glGetMaterialfv\n#define qglGetMaterialiv glGetMaterialiv\n#define qglGetPixelMapfv glGetPixelMapfv\n#define qglGetPixelMapuiv glGetPixelMapuiv\n#define qglGetPixelMapusv glGetPixelMapusv\n#define qglGetPointerv glGetPointerv\n#define qglGetPolygonStipple glGetPolygonStipple\n#define qglGetString glGetString\n#define qglGetTexGendv glGetTexGendv\n#define qglGetTexGenfv glGetTexGenfv\n#define qglGetTexGeniv glGetTexGeniv\n#define qglGetTexImage glGetTexImage\n#define qglGetTexLevelParameterfv glGetTexLevelParameterfv\n#define qglGetTexLevelParameteriv glGetTexLevelParameteriv\n#define qglGetTexParameterfv glGetTexParameterfv\n#define qglGetTexParameteriv glGetTexParameteriv\n#define qglHint glHint\n#define qglIndexMask glIndexMask\n#define qglIndexPointer glIndexPointer\n#define qglIndexd glIndexd\n#define qglIndexdv glIndexdv\n#define qglIndexf glIndexf\n#define qglIndexfv glIndexfv\n#define qglIndexi glIndexi\n#define qglIndexiv glIndexiv\n#define qglIndexs glIndexs\n#define qglIndexsv glIndexsv\n#define qglIndexub glIndexub\n#define qglIndexubv glIndexubv\n#define qglInitNames glInitNames\n#define qglInterleavedArrays glInterleavedArrays\n#define qglIsEnabled glIsEnabled\n#define qglIsList glIsList\n#define qglIsTexture glIsTexture\n#define qglLightModelf glLightModelf\n#define qglLightModelfv glLightModelfv\n#define qglLightModeli glLightModeli\n#define qglLightModeliv glLightModeliv\n#define qglLightf glLightf\n#define qglLightfv glLightfv\n#define qglLighti glLighti\n#define qglLightiv glLightiv\n#define qglLineStipple glLineStipple\n#define qglLineWidth glLineWidth\n#define qglListBase glListBase\n#define qglLoadIdentity glLoadIdentity\n#define qglLoadMatrixd glLoadMatrixd\n#define qglLoadMatrixf glLoadMatrixf\n#define qglLoadName glLoadName\n#define qglLogicOp glLogicOp\n#define qglMap1d glMap1d\n#define qglMap1f glMap1f\n#define qglMap2d glMap2d\n#define qglMap2f glMap2f\n#define qglMapGrid1d glMapGrid1d\n#define qglMapGrid1f glMapGrid1f\n#define qglMapGrid2d glMapGrid2d\n#define qglMapGrid2f glMapGrid2f\n#define qglMaterialf glMaterialf\n#define qglMaterialfv glMaterialfv\n#define qglMateriali glMateriali\n#define qglMaterialiv glMaterialiv\n#define qglMatrixMode glMatrixMode\n#define qglMultMatrixd glMultMatrixd\n#define qglMultMatrixf glMultMatrixf\n#define qglNewList glNewList\n#define qglNormal3b glNormal3b\n#define qglNormal3bv glNormal3bv\n#define qglNormal3d glNormal3d\n#define qglNormal3dv glNormal3dv\n#define qglNormal3f glNormal3f\n#define qglNormal3fv glNormal3fv\n#define qglNormal3i glNormal3i\n#define qglNormal3iv glNormal3iv\n#define qglNormal3s glNormal3s\n#define qglNormal3sv glNormal3sv\n#define qglNormalPointer glNormalPointer\n#define qglOrtho glOrtho\n#define qglPassThrough glPassThrough\n#define qglPixelMapfv glPixelMapfv\n#define qglPixelMapuiv glPixelMapuiv\n#define qglPixelMapusv glPixelMapusv\n#define qglPixelStoref glPixelStoref\n#define qglPixelStorei glPixelStorei\n#define qglPixelTransferf glPixelTransferf\n#define qglPixelTransferi glPixelTransferi\n#define qglPixelZoom glPixelZoom\n#define qglPointSize glPointSize\n#define qglPolygonMode glPolygonMode\n#define qglPolygonOffset glPolygonOffset\n#define qglPolygonStipple glPolygonStipple\n#define qglPopAttrib glPopAttrib\n#define qglPopClientAttrib glPopClientAttrib\n#define qglPopMatrix glPopMatrix\n#define qglPopName glPopName\n#define qglPrioritizeTextures glPrioritizeTextures\n#define qglPushAttrib glPushAttrib\n#define qglPushClientAttrib glPushClientAttrib\n#define qglPushMatrix glPushMatrix\n#define qglPushName glPushName\n#define qglRasterPos2d glRasterPos2d\n#define qglRasterPos2dv glRasterPos2dv\n#define qglRasterPos2f glRasterPos2f\n#define qglRasterPos2fv glRasterPos2fv\n#define qglRasterPos2i glRasterPos2i\n#define qglRasterPos2iv glRasterPos2iv\n#define qglRasterPos2s glRasterPos2s\n#define qglRasterPos2sv glRasterPos2sv\n#define qglRasterPos3d glRasterPos3d\n#define qglRasterPos3dv glRasterPos3dv\n#define qglRasterPos3f glRasterPos3f\n#define qglRasterPos3fv glRasterPos3fv\n#define qglRasterPos3i glRasterPos3i\n#define qglRasterPos3iv glRasterPos3iv\n#define qglRasterPos3s glRasterPos3s\n#define qglRasterPos3sv glRasterPos3sv\n#define qglRasterPos4d glRasterPos4d\n#define qglRasterPos4dv glRasterPos4dv\n#define qglRasterPos4f glRasterPos4f\n#define qglRasterPos4fv glRasterPos4fv\n#define qglRasterPos4i glRasterPos4i\n#define qglRasterPos4iv glRasterPos4iv\n#define qglRasterPos4s glRasterPos4s\n#define qglRasterPos4sv glRasterPos4sv\n#define qglReadBuffer glReadBuffer\n#define qglReadPixels glReadPixels\n#define qglRectd glRectd\n#define qglRectdv glRectdv\n#define qglRectf glRectf\n#define qglRectfv glRectfv\n#define qglRecti glRecti\n#define qglRectiv glRectiv\n#define qglRects glRects\n#define qglRectsv glRectsv\n#define qglRenderMode glRenderMode\n#define qglRotated glRotated\n#define qglRotatef glRotatef\n#define qglScaled glScaled\n#define qglScalef glScalef\n#define qglScissor glScissor\n#define qglSelectBuffer glSelectBuffer\n#define qglShadeModel glShadeModel\n#define qglStencilFunc glStencilFunc\n#define qglStencilMask glStencilMask\n#define qglStencilOp glStencilOp\n#define qglTexCoord1d glTexCoord1d\n#define qglTexCoord1dv glTexCoord1dv\n#define qglTexCoord1f glTexCoord1f\n#define qglTexCoord1fv glTexCoord1fv\n#define qglTexCoord1i glTexCoord1i\n#define qglTexCoord1iv glTexCoord1iv\n#define qglTexCoord1s glTexCoord1s\n#define qglTexCoord1sv glTexCoord1sv\n#define qglTexCoord2d glTexCoord2d\n#define qglTexCoord2dv glTexCoord2dv\n#define qglTexCoord2f glTexCoord2f\n#define qglTexCoord2fv glTexCoord2fv\n#define qglTexCoord2i glTexCoord2i\n#define qglTexCoord2iv glTexCoord2iv\n#define qglTexCoord2s glTexCoord2s\n#define qglTexCoord2sv glTexCoord2sv\n#define qglTexCoord3d glTexCoord3d\n#define qglTexCoord3dv glTexCoord3dv\n#define qglTexCoord3f glTexCoord3f\n#define qglTexCoord3fv glTexCoord3fv\n#define qglTexCoord3i glTexCoord3i\n#define qglTexCoord3iv glTexCoord3iv\n#define qglTexCoord3s glTexCoord3s\n#define qglTexCoord3sv glTexCoord3sv\n#define qglTexCoord4d glTexCoord4d\n#define qglTexCoord4dv glTexCoord4dv\n#define qglTexCoord4f glTexCoord4f\n#define qglTexCoord4fv glTexCoord4fv\n#define qglTexCoord4i glTexCoord4i\n#define qglTexCoord4iv glTexCoord4iv\n#define qglTexCoord4s glTexCoord4s\n#define qglTexCoord4sv glTexCoord4sv\n#define qglTexCoordPointer glTexCoordPointer\n#define\tqglTexEnvf glTexEnvf\n#define\tqglTexEnvfv glTexEnvfv\n#define\tqglTexEnvi glTexEnvi\n#define\tqglTexEnviv glTexEnviv\n#define qglTexGend glTexGend\n#define qglTexGendv glTexGendv\n#define qglTexGenf glTexGenf\n#define qglTexGenfv glTexGenfv\n#define qglTexGeni glTexGeni\n#define qglTexGeniv glTexGeniv\n#define qglTexImage1D glTexImage1D\n#define qglTexImage2D glTexImage2D\n#define qglTexParameterf glTexParameterf\n#define qglTexParameterfv glTexParameterfv\n#define qglTexParameteri glTexParameteri\n#define qglTexParameteriv glTexParameteriv\n#define qglTexSubImage1D glTexSubImage1D\n#define qglTexSubImage2D glTexSubImage2D\n#define qglTranslated glTranslated\n#define qglTranslatef glTranslatef\n#define qglVertex2d glVertex2d\n#define qglVertex2dv glVertex2dv\n#define qglVertex2f glVertex2f\n#define qglVertex2fv glVertex2fv\n#define qglVertex2i glVertex2i\n#define qglVertex2iv glVertex2iv\n#define qglVertex2s glVertex2s\n#define qglVertex2sv glVertex2sv\n#define qglVertex3d glVertex3d\n#define qglVertex3dv glVertex3dv\n#define qglVertex3f glVertex3f\n#define qglVertex3fv glVertex3fv\n#define qglVertex3i glVertex3i\n#define qglVertex3iv glVertex3iv\n#define qglVertex3s glVertex3s\n#define qglVertex3sv glVertex3sv\n#define qglVertex4d glVertex4d\n#define qglVertex4dv glVertex4dv\n#define qglVertex4f glVertex4f\n#define qglVertex4fv glVertex4fv\n#define qglVertex4i glVertex4i\n#define qglVertex4iv glVertex4iv\n#define qglVertex4s glVertex4s\n#define qglVertex4sv glVertex4sv\n#define qglVertexPointer glVertexPointer\n#define qglViewport glViewport\n\n"
  },
  {
    "path": "code/renderer/ref_trin.def",
    "content": "EXPORTS\n\tGetRefAPI\n"
  },
  {
    "path": "code/renderer/renderer.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<VisualStudioProject\n\tProjectType=\"Visual C++\"\n\tVersion=\"7.10\"\n\tName=\"renderer\"\n\tSccProjectName=\"&quot;$/MissionPack/code/renderer&quot;, EJBAAAAA\"\n\tSccLocalPath=\".\">\n\t<Platforms>\n\t\t<Platform\n\t\t\tName=\"Win32\"/>\n\t</Platforms>\n\t<Configurations>\n\t\t<Configuration\n\t\t\tName=\"Debug TA|Win32\"\n\t\t\tOutputDirectory=\".\\Debug_TA\"\n\t\t\tIntermediateDirectory=\".\\Debug_TA\"\n\t\t\tConfigurationType=\"4\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tOptimizeForProcessor=\"1\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_LIB\"\n\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Debug_TA/renderer.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug_TA/\"\n\t\t\t\tObjectFile=\".\\Debug_TA/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Debug_TA/\"\n\t\t\t\tBrowseInformation=\"1\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLibrarianTool\"\n\t\t\t\tOutputFile=\".\\Debug_TA\\renderer.lib\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Release|Win32\"\n\t\t\tOutputDirectory=\".\\Release\"\n\t\t\tIntermediateDirectory=\".\\Release\"\n\t\t\tConfigurationType=\"4\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"2\"\n\t\t\t\tOptimizeForProcessor=\"2\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_LIB\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"4\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release/renderer.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release/\"\n\t\t\t\tObjectFile=\".\\Release/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release/\"\n\t\t\t\tWarningLevel=\"4\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLibrarianTool\"\n\t\t\t\tOutputFile=\".\\Release\\renderer.lib\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Debug|Win32\"\n\t\t\tOutputDirectory=\".\\Debug\"\n\t\t\tIntermediateDirectory=\".\\Debug\"\n\t\t\tConfigurationType=\"4\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tOptimizeForProcessor=\"1\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_LIB\"\n\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Debug/renderer.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug/\"\n\t\t\t\tObjectFile=\".\\Debug/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Debug/\"\n\t\t\t\tBrowseInformation=\"1\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLibrarianTool\"\n\t\t\t\tOutputFile=\".\\Debug\\renderer.lib\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Release TA|Win32\"\n\t\t\tOutputDirectory=\".\\Release_TA\"\n\t\t\tIntermediateDirectory=\".\\Release_TA\"\n\t\t\tConfigurationType=\"4\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"2\"\n\t\t\t\tOptimizeForProcessor=\"2\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_LIB\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"4\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release_TA/renderer.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release_TA/\"\n\t\t\t\tObjectFile=\".\\Release_TA/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release_TA/\"\n\t\t\t\tWarningLevel=\"4\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLibrarianTool\"\n\t\t\t\tOutputFile=\".\\Release_TA\\renderer.lib\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"vector|Win32\"\n\t\t\tOutputDirectory=\".\\renderer___Win32_vector0\"\n\t\t\tIntermediateDirectory=\".\\renderer___Win32_vector0\"\n\t\t\tConfigurationType=\"4\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tAdditionalOptions=\"/vec /vec:stats /vec:pii /vec:o10 /vec:yes \"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"2\"\n\t\t\t\tOptimizeForProcessor=\"2\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_LIB\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"4\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\renderer___Win32_vector0/renderer.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\renderer___Win32_vector0/\"\n\t\t\t\tObjectFile=\".\\renderer___Win32_vector0/\"\n\t\t\t\tProgramDataBaseFileName=\".\\renderer___Win32_vector0/\"\n\t\t\t\tWarningLevel=\"4\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLibrarianTool\"\n\t\t\t\tOutputFile=\".\\renderer___Win32_vector0\\renderer.lib\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t</Configurations>\n\t<References>\n\t</References>\n\t<Files>\n\t\t<Filter\n\t\t\tName=\"Source Files\"\n\t\t\tFilter=\"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"ref_trin.def\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_animation.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_backend.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_bsp.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_cmds.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_curve.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_flares.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_font.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_image.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_init.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_light.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_main.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_marks.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_mesh.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_model.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_noise.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_scene.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_shade.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_shade_calc.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_shader.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_shadows.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_sky.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_surface.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_world.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\win32\\win_gamma.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\win32\\win_glimp.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\win32\\win_qgl.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Header Files\"\n\t\t\tFilter=\"h;hpp;hxx;hm;inl\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\qcommon\\cm_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\win32\\glw_win.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\q_shared.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\qcommon\\qcommon.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\qcommon\\qfiles.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qgl.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\surfaceflags.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_local.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"tr_public.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\cgame\\tr_types.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\win32\\win_local.h\">\n\t\t\t</File>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"jpeg\"\n\t\t\tFilter=\"\">\n\t\t\t<Filter\n\t\t\t\tName=\"Source Files No. 1\"\n\t\t\t\tFilter=\"\">\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jcapimin.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jccoefct.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jccolor.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jcdctmgr.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jchuff.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jcinit.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jcmainct.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jcmarker.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jcmaster.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jcomapi.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jcparam.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jcphuff.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jcprepct.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jcsample.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jctrans.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jdapimin.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jdapistd.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jdatadst.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jdatasrc.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jdcoefct.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jdcolor.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jddctmgr.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jdhuff.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jdinput.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jdmainct.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jdmarker.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jdmaster.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jdpostct.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jdsample.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jdtrans.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jerror.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jfdctflt.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jidctflt.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jmemmgr.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jmemnobs.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jutils.c\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t</Filter>\n\t\t\t<Filter\n\t\t\t\tName=\"Header Files No. 1\"\n\t\t\t\tFilter=\"\">\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jchuff.h\">\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jconfig.h\">\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jdct.h\">\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jdhuff.h\">\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jerror.h\">\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jinclude.h\">\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jmemsys.h\">\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jmorecfg.h\">\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jpegint.h\">\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jpeglib.h\">\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\jpeg-6\\jversion.h\">\n\t\t\t\t</File>\n\t\t\t</Filter>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"FreeType2\"\n\t\t\tFilter=\"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ahangles.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ahglobal.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ahglyph.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ahhint.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ahmodule.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ahoptim.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ftcalc.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ftdebug.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ftextend.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ftglyph.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ftgrays.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ftinit.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ftlist.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ftmm.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ftnames.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ftobjs.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ftoutln.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ftraster.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ftrend1.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ftsmooth.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ftstream.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ftsystem.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\sfdriver.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\sfobjs.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ttcmap.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ttdriver.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ttgload.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ttinterp.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ttload.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ttobjs.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ttpload.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ttpost.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\ft2\\ttsbit.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<Filter\n\t\t\t\tName=\"Include files\"\n\t\t\t\tFilter=\"*.h\">\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ahangles.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ahglobal.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ahglyph.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ahhint.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ahloader.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ahmodule.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ahoptim.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ahtypes.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\autohint.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\freetype.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ftbbox.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ftcalc.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ftconfig.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ftdebug.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ftdriver.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\fterrors.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ftextend.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ftglyph.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ftimage.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ftlist.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ftmemory.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ftmm.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ftmodule.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ftnames.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ftobjs.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ftoption.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ftoutln.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ftrender.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ftstream.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ftsystem.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\fttypes.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\psnames.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\sfnt.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\t1errors.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\t1tables.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\t1types.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\t2errors.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\t2types.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ttdriver.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\tterrors.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ttgload.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ttinterp.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ttnameid.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ttobjs.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\ttpload.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\tttables.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\tttags.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"..\\ft2\\tttypes.h\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t</Filter>\n\t\t</Filter>\n\t</Files>\n\t<Globals>\n\t</Globals>\n</VisualStudioProject>\n"
  },
  {
    "path": "code/renderer/tr_animation.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"tr_local.h\"\n\n/*\n\nAll bones should be an identity orientation to display the mesh exactly\nas it is specified.\n\nFor all other frames, the bones represent the transformation from the \norientation of the bone in the base frame to the orientation in this\nframe.\n\n*/\n\n/*\n==============\nR_AddAnimSurfaces\n==============\n*/\nvoid R_AddAnimSurfaces( trRefEntity_t *ent ) {\n\tmd4Header_t\t\t*header;\n\tmd4Surface_t\t*surface;\n\tmd4LOD_t\t\t*lod;\n\tshader_t\t\t*shader;\n\tint\t\t\t\ti;\n\n\theader = tr.currentModel->md4;\n\tlod = (md4LOD_t *)( (byte *)header + header->ofsLODs );\n\n\tsurface = (md4Surface_t *)( (byte *)lod + lod->ofsSurfaces );\n\tfor ( i = 0 ; i < lod->numSurfaces ; i++ ) {\n\t\tshader = R_GetShaderByHandle( surface->shaderIndex );\n\t\tR_AddDrawSurf( (void *)surface, shader, 0 /*fogNum*/, qfalse );\n\t\tsurface = (md4Surface_t *)( (byte *)surface + surface->ofsEnd );\n\t}\n}\n\n\n/*\n==============\nRB_SurfaceAnim\n==============\n*/\nvoid RB_SurfaceAnim( md4Surface_t *surface ) {\n\tint\t\t\t\ti, j, k;\n\tfloat\t\t\tfrontlerp, backlerp;\n\tint\t\t\t\t*triangles;\n\tint\t\t\t\tindexes;\n\tint\t\t\t\tbaseIndex, baseVertex;\n\tint\t\t\t\tnumVerts;\n\tmd4Vertex_t\t\t*v;\n\tmd4Bone_t\t\tbones[MD4_MAX_BONES];\n\tmd4Bone_t\t\t*bonePtr, *bone;\n\tmd4Header_t\t\t*header;\n\tmd4Frame_t\t\t*frame;\n\tmd4Frame_t\t\t*oldFrame;\n\tint\t\t\t\tframeSize;\n\n\n\tif (  backEnd.currentEntity->e.oldframe == backEnd.currentEntity->e.frame ) {\n\t\tbacklerp = 0;\n\t\tfrontlerp = 1;\n\t} else  {\n\t\tbacklerp = backEnd.currentEntity->e.backlerp;\n\t\tfrontlerp = 1.0f - backlerp;\n\t}\n\theader = (md4Header_t *)((byte *)surface + surface->ofsHeader);\n\n\tframeSize = (int)( &((md4Frame_t *)0)->bones[ header->numBones ] );\n\n\tframe = (md4Frame_t *)((byte *)header + header->ofsFrames + \n\t\tbackEnd.currentEntity->e.frame * frameSize );\n\toldFrame = (md4Frame_t *)((byte *)header + header->ofsFrames + \n\t\tbackEnd.currentEntity->e.oldframe * frameSize );\n\n\tRB_CheckOverflow( surface->numVerts, surface->numTriangles * 3 );\n\n\ttriangles = (int *) ((byte *)surface + surface->ofsTriangles);\n\tindexes = surface->numTriangles * 3;\n\tbaseIndex = tess.numIndexes;\n\tbaseVertex = tess.numVertexes;\n\tfor (j = 0 ; j < indexes ; j++) {\n\t\ttess.indexes[baseIndex + j] = baseIndex + triangles[j];\n\t}\n\ttess.numIndexes += indexes;\n\n\t//\n\t// lerp all the needed bones\n\t//\n\tif ( !backlerp ) {\n\t\t// no lerping needed\n\t\tbonePtr = frame->bones;\n\t} else {\n\t\tbonePtr = bones;\n\t\tfor ( i = 0 ; i < header->numBones*12 ; i++ ) {\n\t\t\t((float *)bonePtr)[i] = frontlerp * ((float *)frame->bones)[i]\n\t\t\t\t+ backlerp * ((float *)oldFrame->bones)[i];\n\t\t}\n\t}\n\n\t//\n\t// deform the vertexes by the lerped bones\n\t//\n\tnumVerts = surface->numVerts;\n\t// FIXME\n\t// This makes TFC's skeletons work.  Shouldn't be necessary anymore, but left\n\t// in for reference.\n\t//v = (md4Vertex_t *) ((byte *)surface + surface->ofsVerts + 12);\n\tv = (md4Vertex_t *) ((byte *)surface + surface->ofsVerts);\n\tfor ( j = 0; j < numVerts; j++ ) {\n\t\tvec3_t\ttempVert, tempNormal;\n\t\tmd4Weight_t\t*w;\n\n\t\tVectorClear( tempVert );\n\t\tVectorClear( tempNormal );\n\t\tw = v->weights;\n\t\tfor ( k = 0 ; k < v->numWeights ; k++, w++ ) {\n\t\t\tbone = bonePtr + w->boneIndex;\n\n\t\t\ttempVert[0] += w->boneWeight * ( DotProduct( bone->matrix[0], w->offset ) + bone->matrix[0][3] );\n\t\t\ttempVert[1] += w->boneWeight * ( DotProduct( bone->matrix[1], w->offset ) + bone->matrix[1][3] );\n\t\t\ttempVert[2] += w->boneWeight * ( DotProduct( bone->matrix[2], w->offset ) + bone->matrix[2][3] );\n\n\t\t\ttempNormal[0] += w->boneWeight * DotProduct( bone->matrix[0], v->normal );\n\t\t\ttempNormal[1] += w->boneWeight * DotProduct( bone->matrix[1], v->normal );\n\t\t\ttempNormal[2] += w->boneWeight * DotProduct( bone->matrix[2], v->normal );\n\t\t}\n\n\t\ttess.xyz[baseVertex + j][0] = tempVert[0];\n\t\ttess.xyz[baseVertex + j][1] = tempVert[1];\n\t\ttess.xyz[baseVertex + j][2] = tempVert[2];\n\n\t\ttess.normal[baseVertex + j][0] = tempNormal[0];\n\t\ttess.normal[baseVertex + j][1] = tempNormal[1];\n\t\ttess.normal[baseVertex + j][2] = tempNormal[2];\n\n\t\ttess.texCoords[baseVertex + j][0][0] = v->texCoords[0];\n\t\ttess.texCoords[baseVertex + j][0][1] = v->texCoords[1];\n\n\t\t// FIXME\n\t\t// This makes TFC's skeletons work.  Shouldn't be necessary anymore, but left\n\t\t// in for reference.\n\t\t//v = (md4Vertex_t *)( ( byte * )&v->weights[v->numWeights] + 12 );\n\t\tv = (md4Vertex_t *)&v->weights[v->numWeights];\n\t}\n\n\ttess.numVertexes += surface->numVerts;\n}\n\n\n"
  },
  {
    "path": "code/renderer/tr_backend.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"tr_local.h\"\n\nbackEndData_t\t*backEndData[SMP_FRAMES];\nbackEndState_t\tbackEnd;\n\n\nstatic float\ts_flipMatrix[16] = {\n\t// convert from our coordinate system (looking down X)\n\t// to OpenGL's coordinate system (looking down -Z)\n\t0, 0, -1, 0,\n\t-1, 0, 0, 0,\n\t0, 1, 0, 0,\n\t0, 0, 0, 1\n};\n\n\n/*\n** GL_Bind\n*/\nvoid GL_Bind( image_t *image ) {\n\tint texnum;\n\n\tif ( !image ) {\n\t\tri.Printf( PRINT_WARNING, \"GL_Bind: NULL image\\n\" );\n\t\ttexnum = tr.defaultImage->texnum;\n\t} else {\n\t\ttexnum = image->texnum;\n\t}\n\n\tif ( r_nobind->integer && tr.dlightImage ) {\t\t// performance evaluation option\n\t\ttexnum = tr.dlightImage->texnum;\n\t}\n\n\tif ( glState.currenttextures[glState.currenttmu] != texnum ) {\n\t\timage->frameUsed = tr.frameCount;\n\t\tglState.currenttextures[glState.currenttmu] = texnum;\n\t\tqglBindTexture (GL_TEXTURE_2D, texnum);\n\t}\n}\n\n/*\n** GL_SelectTexture\n*/\nvoid GL_SelectTexture( int unit )\n{\n\tif ( glState.currenttmu == unit )\n\t{\n\t\treturn;\n\t}\n\n\tif ( unit == 0 )\n\t{\n\t\tqglActiveTextureARB( GL_TEXTURE0_ARB );\n\t\tGLimp_LogComment( \"glActiveTextureARB( GL_TEXTURE0_ARB )\\n\" );\n\t\tqglClientActiveTextureARB( GL_TEXTURE0_ARB );\n\t\tGLimp_LogComment( \"glClientActiveTextureARB( GL_TEXTURE0_ARB )\\n\" );\n\t}\n\telse if ( unit == 1 )\n\t{\n\t\tqglActiveTextureARB( GL_TEXTURE1_ARB );\n\t\tGLimp_LogComment( \"glActiveTextureARB( GL_TEXTURE1_ARB )\\n\" );\n\t\tqglClientActiveTextureARB( GL_TEXTURE1_ARB );\n\t\tGLimp_LogComment( \"glClientActiveTextureARB( GL_TEXTURE1_ARB )\\n\" );\n\t} else {\n\t\tri.Error( ERR_DROP, \"GL_SelectTexture: unit = %i\", unit );\n\t}\n\n\tglState.currenttmu = unit;\n}\n\n\n/*\n** GL_BindMultitexture\n*/\nvoid GL_BindMultitexture( image_t *image0, GLuint env0, image_t *image1, GLuint env1 ) {\n\tint\t\ttexnum0, texnum1;\n\n\ttexnum0 = image0->texnum;\n\ttexnum1 = image1->texnum;\n\n\tif ( r_nobind->integer && tr.dlightImage ) {\t\t// performance evaluation option\n\t\ttexnum0 = texnum1 = tr.dlightImage->texnum;\n\t}\n\n\tif ( glState.currenttextures[1] != texnum1 ) {\n\t\tGL_SelectTexture( 1 );\n\t\timage1->frameUsed = tr.frameCount;\n\t\tglState.currenttextures[1] = texnum1;\n\t\tqglBindTexture( GL_TEXTURE_2D, texnum1 );\n\t}\n\tif ( glState.currenttextures[0] != texnum0 ) {\n\t\tGL_SelectTexture( 0 );\n\t\timage0->frameUsed = tr.frameCount;\n\t\tglState.currenttextures[0] = texnum0;\n\t\tqglBindTexture( GL_TEXTURE_2D, texnum0 );\n\t}\n}\n\n\n/*\n** GL_Cull\n*/\nvoid GL_Cull( int cullType ) {\n\tif ( glState.faceCulling == cullType ) {\n\t\treturn;\n\t}\n\n\tglState.faceCulling = cullType;\n\n\tif ( cullType == CT_TWO_SIDED ) \n\t{\n\t\tqglDisable( GL_CULL_FACE );\n\t} \n\telse \n\t{\n\t\tqglEnable( GL_CULL_FACE );\n\n\t\tif ( cullType == CT_BACK_SIDED )\n\t\t{\n\t\t\tif ( backEnd.viewParms.isMirror )\n\t\t\t{\n\t\t\t\tqglCullFace( GL_FRONT );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tqglCullFace( GL_BACK );\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif ( backEnd.viewParms.isMirror )\n\t\t\t{\n\t\t\t\tqglCullFace( GL_BACK );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tqglCullFace( GL_FRONT );\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n** GL_TexEnv\n*/\nvoid GL_TexEnv( int env )\n{\n\tif ( env == glState.texEnv[glState.currenttmu] )\n\t{\n\t\treturn;\n\t}\n\n\tglState.texEnv[glState.currenttmu] = env;\n\n\n\tswitch ( env )\n\t{\n\tcase GL_MODULATE:\n\t\tqglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );\n\t\tbreak;\n\tcase GL_REPLACE:\n\t\tqglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );\n\t\tbreak;\n\tcase GL_DECAL:\n\t\tqglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );\n\t\tbreak;\n\tcase GL_ADD:\n\t\tqglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD );\n\t\tbreak;\n\tdefault:\n\t\tri.Error( ERR_DROP, \"GL_TexEnv: invalid env '%d' passed\\n\", env );\n\t\tbreak;\n\t}\n}\n\n/*\n** GL_State\n**\n** This routine is responsible for setting the most commonly changed state\n** in Q3.\n*/\nvoid GL_State( unsigned long stateBits )\n{\n\tunsigned long diff = stateBits ^ glState.glStateBits;\n\n\tif ( !diff )\n\t{\n\t\treturn;\n\t}\n\n\t//\n\t// check depthFunc bits\n\t//\n\tif ( diff & GLS_DEPTHFUNC_EQUAL )\n\t{\n\t\tif ( stateBits & GLS_DEPTHFUNC_EQUAL )\n\t\t{\n\t\t\tqglDepthFunc( GL_EQUAL );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tqglDepthFunc( GL_LEQUAL );\n\t\t}\n\t}\n\n\t//\n\t// check blend bits\n\t//\n\tif ( diff & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) )\n\t{\n\t\tGLenum srcFactor, dstFactor;\n\n\t\tif ( stateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) )\n\t\t{\n\t\t\tswitch ( stateBits & GLS_SRCBLEND_BITS )\n\t\t\t{\n\t\t\tcase GLS_SRCBLEND_ZERO:\n\t\t\t\tsrcFactor = GL_ZERO;\n\t\t\t\tbreak;\n\t\t\tcase GLS_SRCBLEND_ONE:\n\t\t\t\tsrcFactor = GL_ONE;\n\t\t\t\tbreak;\n\t\t\tcase GLS_SRCBLEND_DST_COLOR:\n\t\t\t\tsrcFactor = GL_DST_COLOR;\n\t\t\t\tbreak;\n\t\t\tcase GLS_SRCBLEND_ONE_MINUS_DST_COLOR:\n\t\t\t\tsrcFactor = GL_ONE_MINUS_DST_COLOR;\n\t\t\t\tbreak;\n\t\t\tcase GLS_SRCBLEND_SRC_ALPHA:\n\t\t\t\tsrcFactor = GL_SRC_ALPHA;\n\t\t\t\tbreak;\n\t\t\tcase GLS_SRCBLEND_ONE_MINUS_SRC_ALPHA:\n\t\t\t\tsrcFactor = GL_ONE_MINUS_SRC_ALPHA;\n\t\t\t\tbreak;\n\t\t\tcase GLS_SRCBLEND_DST_ALPHA:\n\t\t\t\tsrcFactor = GL_DST_ALPHA;\n\t\t\t\tbreak;\n\t\t\tcase GLS_SRCBLEND_ONE_MINUS_DST_ALPHA:\n\t\t\t\tsrcFactor = GL_ONE_MINUS_DST_ALPHA;\n\t\t\t\tbreak;\n\t\t\tcase GLS_SRCBLEND_ALPHA_SATURATE:\n\t\t\t\tsrcFactor = GL_SRC_ALPHA_SATURATE;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tsrcFactor = GL_ONE;\t\t// to get warning to shut up\n\t\t\t\tri.Error( ERR_DROP, \"GL_State: invalid src blend state bits\\n\" );\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tswitch ( stateBits & GLS_DSTBLEND_BITS )\n\t\t\t{\n\t\t\tcase GLS_DSTBLEND_ZERO:\n\t\t\t\tdstFactor = GL_ZERO;\n\t\t\t\tbreak;\n\t\t\tcase GLS_DSTBLEND_ONE:\n\t\t\t\tdstFactor = GL_ONE;\n\t\t\t\tbreak;\n\t\t\tcase GLS_DSTBLEND_SRC_COLOR:\n\t\t\t\tdstFactor = GL_SRC_COLOR;\n\t\t\t\tbreak;\n\t\t\tcase GLS_DSTBLEND_ONE_MINUS_SRC_COLOR:\n\t\t\t\tdstFactor = GL_ONE_MINUS_SRC_COLOR;\n\t\t\t\tbreak;\n\t\t\tcase GLS_DSTBLEND_SRC_ALPHA:\n\t\t\t\tdstFactor = GL_SRC_ALPHA;\n\t\t\t\tbreak;\n\t\t\tcase GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA:\n\t\t\t\tdstFactor = GL_ONE_MINUS_SRC_ALPHA;\n\t\t\t\tbreak;\n\t\t\tcase GLS_DSTBLEND_DST_ALPHA:\n\t\t\t\tdstFactor = GL_DST_ALPHA;\n\t\t\t\tbreak;\n\t\t\tcase GLS_DSTBLEND_ONE_MINUS_DST_ALPHA:\n\t\t\t\tdstFactor = GL_ONE_MINUS_DST_ALPHA;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tdstFactor = GL_ONE;\t\t// to get warning to shut up\n\t\t\t\tri.Error( ERR_DROP, \"GL_State: invalid dst blend state bits\\n\" );\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tqglEnable( GL_BLEND );\n\t\t\tqglBlendFunc( srcFactor, dstFactor );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tqglDisable( GL_BLEND );\n\t\t}\n\t}\n\n\t//\n\t// check depthmask\n\t//\n\tif ( diff & GLS_DEPTHMASK_TRUE )\n\t{\n\t\tif ( stateBits & GLS_DEPTHMASK_TRUE )\n\t\t{\n\t\t\tqglDepthMask( GL_TRUE );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tqglDepthMask( GL_FALSE );\n\t\t}\n\t}\n\n\t//\n\t// fill/line mode\n\t//\n\tif ( diff & GLS_POLYMODE_LINE )\n\t{\n\t\tif ( stateBits & GLS_POLYMODE_LINE )\n\t\t{\n\t\t\tqglPolygonMode( GL_FRONT_AND_BACK, GL_LINE );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tqglPolygonMode( GL_FRONT_AND_BACK, GL_FILL );\n\t\t}\n\t}\n\n\t//\n\t// depthtest\n\t//\n\tif ( diff & GLS_DEPTHTEST_DISABLE )\n\t{\n\t\tif ( stateBits & GLS_DEPTHTEST_DISABLE )\n\t\t{\n\t\t\tqglDisable( GL_DEPTH_TEST );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tqglEnable( GL_DEPTH_TEST );\n\t\t}\n\t}\n\n\t//\n\t// alpha test\n\t//\n\tif ( diff & GLS_ATEST_BITS )\n\t{\n\t\tswitch ( stateBits & GLS_ATEST_BITS )\n\t\t{\n\t\tcase 0:\n\t\t\tqglDisable( GL_ALPHA_TEST );\n\t\t\tbreak;\n\t\tcase GLS_ATEST_GT_0:\n\t\t\tqglEnable( GL_ALPHA_TEST );\n\t\t\tqglAlphaFunc( GL_GREATER, 0.0f );\n\t\t\tbreak;\n\t\tcase GLS_ATEST_LT_80:\n\t\t\tqglEnable( GL_ALPHA_TEST );\n\t\t\tqglAlphaFunc( GL_LESS, 0.5f );\n\t\t\tbreak;\n\t\tcase GLS_ATEST_GE_80:\n\t\t\tqglEnable( GL_ALPHA_TEST );\n\t\t\tqglAlphaFunc( GL_GEQUAL, 0.5f );\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tassert( 0 );\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tglState.glStateBits = stateBits;\n}\n\n\n\n/*\n================\nRB_Hyperspace\n\nA player has predicted a teleport, but hasn't arrived yet\n================\n*/\nstatic void RB_Hyperspace( void ) {\n\tfloat\t\tc;\n\n\tif ( !backEnd.isHyperspace ) {\n\t\t// do initialization shit\n\t}\n\n\tc = ( backEnd.refdef.time & 255 ) / 255.0f;\n\tqglClearColor( c, c, c, 1 );\n\tqglClear( GL_COLOR_BUFFER_BIT );\n\n\tbackEnd.isHyperspace = qtrue;\n}\n\n\nstatic void SetViewportAndScissor( void ) {\n\tqglMatrixMode(GL_PROJECTION);\n\tqglLoadMatrixf( backEnd.viewParms.projectionMatrix );\n\tqglMatrixMode(GL_MODELVIEW);\n\n\t// set the window clipping\n\tqglViewport( backEnd.viewParms.viewportX, backEnd.viewParms.viewportY, \n\t\tbackEnd.viewParms.viewportWidth, backEnd.viewParms.viewportHeight );\n\tqglScissor( backEnd.viewParms.viewportX, backEnd.viewParms.viewportY, \n\t\tbackEnd.viewParms.viewportWidth, backEnd.viewParms.viewportHeight );\n}\n\n/*\n=================\nRB_BeginDrawingView\n\nAny mirrored or portaled views have already been drawn, so prepare\nto actually render the visible surfaces for this view\n=================\n*/\nvoid RB_BeginDrawingView (void) {\n\tint clearBits = 0;\n\n\t// sync with gl if needed\n\tif ( r_finish->integer == 1 && !glState.finishCalled ) {\n\t\tqglFinish ();\n\t\tglState.finishCalled = qtrue;\n\t}\n\tif ( r_finish->integer == 0 ) {\n\t\tglState.finishCalled = qtrue;\n\t}\n\n\t// we will need to change the projection matrix before drawing\n\t// 2D images again\n\tbackEnd.projection2D = qfalse;\n\n\t//\n\t// set the modelview matrix for the viewer\n\t//\n\tSetViewportAndScissor();\n\n\t// ensures that depth writes are enabled for the depth clear\n\tGL_State( GLS_DEFAULT );\n\t// clear relevant buffers\n\tclearBits = GL_DEPTH_BUFFER_BIT;\n\n\tif ( r_measureOverdraw->integer || r_shadows->integer == 2 )\n\t{\n\t\tclearBits |= GL_STENCIL_BUFFER_BIT;\n\t}\n\tif ( r_fastsky->integer && !( backEnd.refdef.rdflags & RDF_NOWORLDMODEL ) )\n\t{\n\t\tclearBits |= GL_COLOR_BUFFER_BIT;\t// FIXME: only if sky shaders have been used\n#ifdef _DEBUG\n\t\tqglClearColor( 0.8f, 0.7f, 0.4f, 1.0f );\t// FIXME: get color of sky\n#else\n\t\tqglClearColor( 0.0f, 0.0f, 0.0f, 1.0f );\t// FIXME: get color of sky\n#endif\n\t}\n\tqglClear( clearBits );\n\n\tif ( ( backEnd.refdef.rdflags & RDF_HYPERSPACE ) )\n\t{\n\t\tRB_Hyperspace();\n\t\treturn;\n\t}\n\telse\n\t{\n\t\tbackEnd.isHyperspace = qfalse;\n\t}\n\n\tglState.faceCulling = -1;\t\t// force face culling to set next time\n\n\t// we will only draw a sun if there was sky rendered in this view\n\tbackEnd.skyRenderedThisView = qfalse;\n\n\t// clip to the plane of the portal\n\tif ( backEnd.viewParms.isPortal ) {\n\t\tfloat\tplane[4];\n\t\tdouble\tplane2[4];\n\n\t\tplane[0] = backEnd.viewParms.portalPlane.normal[0];\n\t\tplane[1] = backEnd.viewParms.portalPlane.normal[1];\n\t\tplane[2] = backEnd.viewParms.portalPlane.normal[2];\n\t\tplane[3] = backEnd.viewParms.portalPlane.dist;\n\n\t\tplane2[0] = DotProduct (backEnd.viewParms.or.axis[0], plane);\n\t\tplane2[1] = DotProduct (backEnd.viewParms.or.axis[1], plane);\n\t\tplane2[2] = DotProduct (backEnd.viewParms.or.axis[2], plane);\n\t\tplane2[3] = DotProduct (plane, backEnd.viewParms.or.origin) - plane[3];\n\n\t\tqglLoadMatrixf( s_flipMatrix );\n\t\tqglClipPlane (GL_CLIP_PLANE0, plane2);\n\t\tqglEnable (GL_CLIP_PLANE0);\n\t} else {\n\t\tqglDisable (GL_CLIP_PLANE0);\n\t}\n}\n\n\n#define\tMAC_EVENT_PUMP_MSEC\t\t5\n\n/*\n==================\nRB_RenderDrawSurfList\n==================\n*/\nvoid RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {\n\tshader_t\t\t*shader, *oldShader;\n\tint\t\t\t\tfogNum, oldFogNum;\n\tint\t\t\t\tentityNum, oldEntityNum;\n\tint\t\t\t\tdlighted, oldDlighted;\n\tqboolean\t\tdepthRange, oldDepthRange;\n\tint\t\t\t\ti;\n\tdrawSurf_t\t\t*drawSurf;\n\tint\t\t\t\toldSort;\n\tfloat\t\t\toriginalTime;\n#ifdef __MACOS__\n\tint\t\t\t\tmacEventTime;\n\n\tSys_PumpEvents();\t\t// crutch up the mac's limited buffer queue size\n\n\t// we don't want to pump the event loop too often and waste time, so\n\t// we are going to check every shader change\n\tmacEventTime = ri.Milliseconds() + MAC_EVENT_PUMP_MSEC;\n#endif\n\n\t// save original time for entity shader offsets\n\toriginalTime = backEnd.refdef.floatTime;\n\n\t// clear the z buffer, set the modelview, etc\n\tRB_BeginDrawingView ();\n\n\t// draw everything\n\toldEntityNum = -1;\n\tbackEnd.currentEntity = &tr.worldEntity;\n\toldShader = NULL;\n\toldFogNum = -1;\n\toldDepthRange = qfalse;\n\toldDlighted = qfalse;\n\toldSort = -1;\n\tdepthRange = qfalse;\n\n\tbackEnd.pc.c_surfaces += numDrawSurfs;\n\n\tfor (i = 0, drawSurf = drawSurfs ; i < numDrawSurfs ; i++, drawSurf++) {\n\t\tif ( drawSurf->sort == oldSort ) {\n\t\t\t// fast path, same as previous sort\n\t\t\trb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface );\n\t\t\tcontinue;\n\t\t}\n\t\toldSort = drawSurf->sort;\n\t\tR_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlighted );\n\n\t\t//\n\t\t// change the tess parameters if needed\n\t\t// a \"entityMergable\" shader is a shader that can have surfaces from seperate\n\t\t// entities merged into a single batch, like smoke and blood puff sprites\n\t\tif (shader != oldShader || fogNum != oldFogNum || dlighted != oldDlighted \n\t\t\t|| ( entityNum != oldEntityNum && !shader->entityMergable ) ) {\n\t\t\tif (oldShader != NULL) {\n#ifdef __MACOS__\t// crutch up the mac's limited buffer queue size\n\t\t\t\tint\t\tt;\n\n\t\t\t\tt = ri.Milliseconds();\n\t\t\t\tif ( t > macEventTime ) {\n\t\t\t\t\tmacEventTime = t + MAC_EVENT_PUMP_MSEC;\n\t\t\t\t\tSys_PumpEvents();\n\t\t\t\t}\n#endif\n\t\t\t\tRB_EndSurface();\n\t\t\t}\n\t\t\tRB_BeginSurface( shader, fogNum );\n\t\t\toldShader = shader;\n\t\t\toldFogNum = fogNum;\n\t\t\toldDlighted = dlighted;\n\t\t}\n\n\t\t//\n\t\t// change the modelview matrix if needed\n\t\t//\n\t\tif ( entityNum != oldEntityNum ) {\n\t\t\tdepthRange = qfalse;\n\n\t\t\tif ( entityNum != ENTITYNUM_WORLD ) {\n\t\t\t\tbackEnd.currentEntity = &backEnd.refdef.entities[entityNum];\n\t\t\t\tbackEnd.refdef.floatTime = originalTime - backEnd.currentEntity->e.shaderTime;\n\t\t\t\t// we have to reset the shaderTime as well otherwise image animations start\n\t\t\t\t// from the wrong frame\n\t\t\t\ttess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset;\n\n\t\t\t\t// set up the transformation matrix\n\t\t\t\tR_RotateForEntity( backEnd.currentEntity, &backEnd.viewParms, &backEnd.or );\n\n\t\t\t\t// set up the dynamic lighting if needed\n\t\t\t\tif ( backEnd.currentEntity->needDlights ) {\n\t\t\t\t\tR_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.or );\n\t\t\t\t}\n\n\t\t\t\tif ( backEnd.currentEntity->e.renderfx & RF_DEPTHHACK ) {\n\t\t\t\t\t// hack the depth range to prevent view model from poking into walls\n\t\t\t\t\tdepthRange = qtrue;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tbackEnd.currentEntity = &tr.worldEntity;\n\t\t\t\tbackEnd.refdef.floatTime = originalTime;\n\t\t\t\tbackEnd.or = backEnd.viewParms.world;\n\t\t\t\t// we have to reset the shaderTime as well otherwise image animations on\n\t\t\t\t// the world (like water) continue with the wrong frame\n\t\t\t\ttess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset;\n\t\t\t\tR_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.or );\n\t\t\t}\n\n\t\t\tqglLoadMatrixf( backEnd.or.modelMatrix );\n\n\t\t\t//\n\t\t\t// change depthrange if needed\n\t\t\t//\n\t\t\tif ( oldDepthRange != depthRange ) {\n\t\t\t\tif ( depthRange ) {\n\t\t\t\t\tqglDepthRange (0, 0.3);\n\t\t\t\t} else {\n\t\t\t\t\tqglDepthRange (0, 1);\n\t\t\t\t}\n\t\t\t\toldDepthRange = depthRange;\n\t\t\t}\n\n\t\t\toldEntityNum = entityNum;\n\t\t}\n\n\t\t// add the triangles for this surface\n\t\trb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface );\n\t}\n\n\tbackEnd.refdef.floatTime = originalTime;\n\n\t// draw the contents of the last shader batch\n\tif (oldShader != NULL) {\n\t\tRB_EndSurface();\n\t}\n\n\t// go back to the world modelview matrix\n\tqglLoadMatrixf( backEnd.viewParms.world.modelMatrix );\n\tif ( depthRange ) {\n\t\tqglDepthRange (0, 1);\n\t}\n\n#if 0\n\tRB_DrawSun();\n#endif\n\t// darken down any stencil shadows\n\tRB_ShadowFinish();\t\t\n\n\t// add light flares on lights that aren't obscured\n\tRB_RenderFlares();\n\n#ifdef __MACOS__\n\tSys_PumpEvents();\t\t// crutch up the mac's limited buffer queue size\n#endif\n}\n\n\n/*\n============================================================================\n\nRENDER BACK END THREAD FUNCTIONS\n\n============================================================================\n*/\n\n/*\n================\nRB_SetGL2D\n\n================\n*/\nvoid\tRB_SetGL2D (void) {\n\tbackEnd.projection2D = qtrue;\n\n\t// set 2D virtual screen size\n\tqglViewport( 0, 0, glConfig.vidWidth, glConfig.vidHeight );\n\tqglScissor( 0, 0, glConfig.vidWidth, glConfig.vidHeight );\n\tqglMatrixMode(GL_PROJECTION);\n    qglLoadIdentity ();\n\tqglOrtho (0, glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1);\n\tqglMatrixMode(GL_MODELVIEW);\n    qglLoadIdentity ();\n\n\tGL_State( GLS_DEPTHTEST_DISABLE |\n\t\t\t  GLS_SRCBLEND_SRC_ALPHA |\n\t\t\t  GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );\n\n\tqglDisable( GL_CULL_FACE );\n\tqglDisable( GL_CLIP_PLANE0 );\n\n\t// set time for 2D shaders\n\tbackEnd.refdef.time = ri.Milliseconds();\n\tbackEnd.refdef.floatTime = backEnd.refdef.time * 0.001f;\n}\n\n\n/*\n=============\nRE_StretchRaw\n\nFIXME: not exactly backend\nStretches a raw 32 bit power of 2 bitmap image over the given screen rectangle.\nUsed for cinematics.\n=============\n*/\nvoid RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty) {\n\tint\t\t\ti, j;\n\tint\t\t\tstart, end;\n\n\tif ( !tr.registered ) {\n\t\treturn;\n\t}\n\tR_SyncRenderThread();\n\n\t// we definately want to sync every frame for the cinematics\n\tqglFinish();\n\n\tstart = end = 0;\n\tif ( r_speeds->integer ) {\n\t\tstart = ri.Milliseconds();\n\t}\n\n\t// make sure rows and cols are powers of 2\n\tfor ( i = 0 ; ( 1 << i ) < cols ; i++ ) {\n\t}\n\tfor ( j = 0 ; ( 1 << j ) < rows ; j++ ) {\n\t}\n\tif ( ( 1 << i ) != cols || ( 1 << j ) != rows) {\n\t\tri.Error (ERR_DROP, \"Draw_StretchRaw: size not a power of 2: %i by %i\", cols, rows);\n\t}\n\n\tGL_Bind( tr.scratchImage[client] );\n\n\t// if the scratchImage isn't in the format we want, specify it as a new texture\n\tif ( cols != tr.scratchImage[client]->width || rows != tr.scratchImage[client]->height ) {\n\t\ttr.scratchImage[client]->width = tr.scratchImage[client]->uploadWidth = cols;\n\t\ttr.scratchImage[client]->height = tr.scratchImage[client]->uploadHeight = rows;\n\t\tqglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB8, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );\n\t\tqglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );\n\t\tqglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );\n\t\tqglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );\n\t\tqglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );\t\n\t} else {\n\t\tif (dirty) {\n\t\t\t// otherwise, just subimage upload it so that drivers can tell we are going to be changing\n\t\t\t// it and don't try and do a texture compression\n\t\t\tqglTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, cols, rows, GL_RGBA, GL_UNSIGNED_BYTE, data );\n\t\t}\n\t}\n\n\tif ( r_speeds->integer ) {\n\t\tend = ri.Milliseconds();\n\t\tri.Printf( PRINT_ALL, \"qglTexSubImage2D %i, %i: %i msec\\n\", cols, rows, end - start );\n\t}\n\n\tRB_SetGL2D();\n\n\tqglColor3f( tr.identityLight, tr.identityLight, tr.identityLight );\n\n\tqglBegin (GL_QUADS);\n\tqglTexCoord2f ( 0.5f / cols,  0.5f / rows );\n\tqglVertex2f (x, y);\n\tqglTexCoord2f ( ( cols - 0.5f ) / cols ,  0.5f / rows );\n\tqglVertex2f (x+w, y);\n\tqglTexCoord2f ( ( cols - 0.5f ) / cols, ( rows - 0.5f ) / rows );\n\tqglVertex2f (x+w, y+h);\n\tqglTexCoord2f ( 0.5f / cols, ( rows - 0.5f ) / rows );\n\tqglVertex2f (x, y+h);\n\tqglEnd ();\n}\n\nvoid RE_UploadCinematic (int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty) {\n\n\tGL_Bind( tr.scratchImage[client] );\n\n\t// if the scratchImage isn't in the format we want, specify it as a new texture\n\tif ( cols != tr.scratchImage[client]->width || rows != tr.scratchImage[client]->height ) {\n\t\ttr.scratchImage[client]->width = tr.scratchImage[client]->uploadWidth = cols;\n\t\ttr.scratchImage[client]->height = tr.scratchImage[client]->uploadHeight = rows;\n\t\tqglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB8, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );\n\t\tqglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );\n\t\tqglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );\n\t\tqglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );\n\t\tqglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );\t\n\t} else {\n\t\tif (dirty) {\n\t\t\t// otherwise, just subimage upload it so that drivers can tell we are going to be changing\n\t\t\t// it and don't try and do a texture compression\n\t\t\tqglTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, cols, rows, GL_RGBA, GL_UNSIGNED_BYTE, data );\n\t\t}\n\t}\n}\n\n\n/*\n=============\nRB_SetColor\n\n=============\n*/\nconst void\t*RB_SetColor( const void *data ) {\n\tconst setColorCommand_t\t*cmd;\n\n\tcmd = (const setColorCommand_t *)data;\n\n\tbackEnd.color2D[0] = cmd->color[0] * 255;\n\tbackEnd.color2D[1] = cmd->color[1] * 255;\n\tbackEnd.color2D[2] = cmd->color[2] * 255;\n\tbackEnd.color2D[3] = cmd->color[3] * 255;\n\n\treturn (const void *)(cmd + 1);\n}\n\n/*\n=============\nRB_StretchPic\n=============\n*/\nconst void *RB_StretchPic ( const void *data ) {\n\tconst stretchPicCommand_t\t*cmd;\n\tshader_t *shader;\n\tint\t\tnumVerts, numIndexes;\n\n\tcmd = (const stretchPicCommand_t *)data;\n\n\tif ( !backEnd.projection2D ) {\n\t\tRB_SetGL2D();\n\t}\n\n\tshader = cmd->shader;\n\tif ( shader != tess.shader ) {\n\t\tif ( tess.numIndexes ) {\n\t\t\tRB_EndSurface();\n\t\t}\n\t\tbackEnd.currentEntity = &backEnd.entity2D;\n\t\tRB_BeginSurface( shader, 0 );\n\t}\n\n\tRB_CHECKOVERFLOW( 4, 6 );\n\tnumVerts = tess.numVertexes;\n\tnumIndexes = tess.numIndexes;\n\n\ttess.numVertexes += 4;\n\ttess.numIndexes += 6;\n\n\ttess.indexes[ numIndexes ] = numVerts + 3;\n\ttess.indexes[ numIndexes + 1 ] = numVerts + 0;\n\ttess.indexes[ numIndexes + 2 ] = numVerts + 2;\n\ttess.indexes[ numIndexes + 3 ] = numVerts + 2;\n\ttess.indexes[ numIndexes + 4 ] = numVerts + 0;\n\ttess.indexes[ numIndexes + 5 ] = numVerts + 1;\n\n\t*(int *)tess.vertexColors[ numVerts ] =\n\t\t*(int *)tess.vertexColors[ numVerts + 1 ] =\n\t\t*(int *)tess.vertexColors[ numVerts + 2 ] =\n\t\t*(int *)tess.vertexColors[ numVerts + 3 ] = *(int *)backEnd.color2D;\n\n\ttess.xyz[ numVerts ][0] = cmd->x;\n\ttess.xyz[ numVerts ][1] = cmd->y;\n\ttess.xyz[ numVerts ][2] = 0;\n\n\ttess.texCoords[ numVerts ][0][0] = cmd->s1;\n\ttess.texCoords[ numVerts ][0][1] = cmd->t1;\n\n\ttess.xyz[ numVerts + 1 ][0] = cmd->x + cmd->w;\n\ttess.xyz[ numVerts + 1 ][1] = cmd->y;\n\ttess.xyz[ numVerts + 1 ][2] = 0;\n\n\ttess.texCoords[ numVerts + 1 ][0][0] = cmd->s2;\n\ttess.texCoords[ numVerts + 1 ][0][1] = cmd->t1;\n\n\ttess.xyz[ numVerts + 2 ][0] = cmd->x + cmd->w;\n\ttess.xyz[ numVerts + 2 ][1] = cmd->y + cmd->h;\n\ttess.xyz[ numVerts + 2 ][2] = 0;\n\n\ttess.texCoords[ numVerts + 2 ][0][0] = cmd->s2;\n\ttess.texCoords[ numVerts + 2 ][0][1] = cmd->t2;\n\n\ttess.xyz[ numVerts + 3 ][0] = cmd->x;\n\ttess.xyz[ numVerts + 3 ][1] = cmd->y + cmd->h;\n\ttess.xyz[ numVerts + 3 ][2] = 0;\n\n\ttess.texCoords[ numVerts + 3 ][0][0] = cmd->s1;\n\ttess.texCoords[ numVerts + 3 ][0][1] = cmd->t2;\n\n\treturn (const void *)(cmd + 1);\n}\n\n\n/*\n=============\nRB_DrawSurfs\n\n=============\n*/\nconst void\t*RB_DrawSurfs( const void *data ) {\n\tconst drawSurfsCommand_t\t*cmd;\n\n\t// finish any 2D drawing if needed\n\tif ( tess.numIndexes ) {\n\t\tRB_EndSurface();\n\t}\n\n\tcmd = (const drawSurfsCommand_t *)data;\n\n\tbackEnd.refdef = cmd->refdef;\n\tbackEnd.viewParms = cmd->viewParms;\n\n\tRB_RenderDrawSurfList( cmd->drawSurfs, cmd->numDrawSurfs );\n\n\treturn (const void *)(cmd + 1);\n}\n\n\n/*\n=============\nRB_DrawBuffer\n\n=============\n*/\nconst void\t*RB_DrawBuffer( const void *data ) {\n\tconst drawBufferCommand_t\t*cmd;\n\n\tcmd = (const drawBufferCommand_t *)data;\n\n\tqglDrawBuffer( cmd->buffer );\n\n\t// clear screen for debugging\n\tif ( r_clear->integer ) {\n\t\tqglClearColor( 1, 0, 0.5, 1 );\n\t\tqglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );\n\t}\n\n\treturn (const void *)(cmd + 1);\n}\n\n/*\n===============\nRB_ShowImages\n\nDraw all the images to the screen, on top of whatever\nwas there.  This is used to test for texture thrashing.\n\nAlso called by RE_EndRegistration\n===============\n*/\nvoid RB_ShowImages( void ) {\n\tint\t\ti;\n\timage_t\t*image;\n\tfloat\tx, y, w, h;\n\tint\t\tstart, end;\n\n\tif ( !backEnd.projection2D ) {\n\t\tRB_SetGL2D();\n\t}\n\n\tqglClear( GL_COLOR_BUFFER_BIT );\n\n\tqglFinish();\n\n\tstart = ri.Milliseconds();\n\n\tfor ( i=0 ; i<tr.numImages ; i++ ) {\n\t\timage = tr.images[i];\n\n\t\tw = glConfig.vidWidth / 20;\n\t\th = glConfig.vidHeight / 15;\n\t\tx = i % 20 * w;\n\t\ty = i / 20 * h;\n\n\t\t// show in proportional size in mode 2\n\t\tif ( r_showImages->integer == 2 ) {\n\t\t\tw *= image->uploadWidth / 512.0f;\n\t\t\th *= image->uploadHeight / 512.0f;\n\t\t}\n\n\t\tGL_Bind( image );\n\t\tqglBegin (GL_QUADS);\n\t\tqglTexCoord2f( 0, 0 );\n\t\tqglVertex2f( x, y );\n\t\tqglTexCoord2f( 1, 0 );\n\t\tqglVertex2f( x + w, y );\n\t\tqglTexCoord2f( 1, 1 );\n\t\tqglVertex2f( x + w, y + h );\n\t\tqglTexCoord2f( 0, 1 );\n\t\tqglVertex2f( x, y + h );\n\t\tqglEnd();\n\t}\n\n\tqglFinish();\n\n\tend = ri.Milliseconds();\n\tri.Printf( PRINT_ALL, \"%i msec to draw all images\\n\", end - start );\n\n}\n\n\n/*\n=============\nRB_SwapBuffers\n\n=============\n*/\nconst void\t*RB_SwapBuffers( const void *data ) {\n\tconst swapBuffersCommand_t\t*cmd;\n\n\t// finish any 2D drawing if needed\n\tif ( tess.numIndexes ) {\n\t\tRB_EndSurface();\n\t}\n\n\t// texture swapping test\n\tif ( r_showImages->integer ) {\n\t\tRB_ShowImages();\n\t}\n\n\tcmd = (const swapBuffersCommand_t *)data;\n\n\t// we measure overdraw by reading back the stencil buffer and\n\t// counting up the number of increments that have happened\n\tif ( r_measureOverdraw->integer ) {\n\t\tint i;\n\t\tlong sum = 0;\n\t\tunsigned char *stencilReadback;\n\n\t\tstencilReadback = ri.Hunk_AllocateTempMemory( glConfig.vidWidth * glConfig.vidHeight );\n\t\tqglReadPixels( 0, 0, glConfig.vidWidth, glConfig.vidHeight, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, stencilReadback );\n\n\t\tfor ( i = 0; i < glConfig.vidWidth * glConfig.vidHeight; i++ ) {\n\t\t\tsum += stencilReadback[i];\n\t\t}\n\n\t\tbackEnd.pc.c_overDraw += sum;\n\t\tri.Hunk_FreeTempMemory( stencilReadback );\n\t}\n\n\n\tif ( !glState.finishCalled ) {\n\t\tqglFinish();\n\t}\n\n\tGLimp_LogComment( \"***************** RB_SwapBuffers *****************\\n\\n\\n\" );\n\n\tGLimp_EndFrame();\n\n\tbackEnd.projection2D = qfalse;\n\n\treturn (const void *)(cmd + 1);\n}\n\n/*\n====================\nRB_ExecuteRenderCommands\n\nThis function will be called synchronously if running without\nsmp extensions, or asynchronously by another thread.\n====================\n*/\nvoid RB_ExecuteRenderCommands( const void *data ) {\n\tint\t\tt1, t2;\n\n\tt1 = ri.Milliseconds ();\n\n\tif ( !r_smp->integer || data == backEndData[0]->commands.cmds ) {\n\t\tbackEnd.smpFrame = 0;\n\t} else {\n\t\tbackEnd.smpFrame = 1;\n\t}\n\n\twhile ( 1 ) {\n\t\tswitch ( *(const int *)data ) {\n\t\tcase RC_SET_COLOR:\n\t\t\tdata = RB_SetColor( data );\n\t\t\tbreak;\n\t\tcase RC_STRETCH_PIC:\n\t\t\tdata = RB_StretchPic( data );\n\t\t\tbreak;\n\t\tcase RC_DRAW_SURFS:\n\t\t\tdata = RB_DrawSurfs( data );\n\t\t\tbreak;\n\t\tcase RC_DRAW_BUFFER:\n\t\t\tdata = RB_DrawBuffer( data );\n\t\t\tbreak;\n\t\tcase RC_SWAP_BUFFERS:\n\t\t\tdata = RB_SwapBuffers( data );\n\t\t\tbreak;\n\t\tcase RC_SCREENSHOT:\n\t\t\tdata = RB_TakeScreenshotCmd( data );\n\t\t\tbreak;\n\n\t\tcase RC_END_OF_LIST:\n\t\tdefault:\n\t\t\t// stop rendering on this thread\n\t\t\tt2 = ri.Milliseconds ();\n\t\t\tbackEnd.pc.msec = t2 - t1;\n\t\t\treturn;\n\t\t}\n\t}\n\n}\n\n\n/*\n================\nRB_RenderThread\n================\n*/\nvoid RB_RenderThread( void ) {\n\tconst void\t*data;\n\n\t// wait for either a rendering command or a quit command\n\twhile ( 1 ) {\n\t\t// sleep until we have work to do\n\t\tdata = GLimp_RendererSleep();\n\n\t\tif ( !data ) {\n\t\t\treturn;\t// all done, renderer is shutting down\n\t\t}\n\n\t\trenderThreadActive = qtrue;\n\n\t\tRB_ExecuteRenderCommands( data );\n\n\t\trenderThreadActive = qfalse;\n\t}\n}\n\n"
  },
  {
    "path": "code/renderer/tr_bsp.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// tr_map.c\n\n#include \"tr_local.h\"\n\n/*\n\nLoads and prepares a map file for scene rendering.\n\nA single entry point:\n\nvoid RE_LoadWorldMap( const char *name );\n\n*/\n\nstatic\tworld_t\t\ts_worldData;\nstatic\tbyte\t\t*fileBase;\n\nint\t\t\tc_subdivisions;\nint\t\t\tc_gridVerts;\n\n//===============================================================================\n\nstatic void HSVtoRGB( float h, float s, float v, float rgb[3] )\n{\n\tint i;\n\tfloat f;\n\tfloat p, q, t;\n\n\th *= 5;\n\n\ti = floor( h );\n\tf = h - i;\n\n\tp = v * ( 1 - s );\n\tq = v * ( 1 - s * f );\n\tt = v * ( 1 - s * ( 1 - f ) );\n\n\tswitch ( i )\n\t{\n\tcase 0:\n\t\trgb[0] = v;\n\t\trgb[1] = t;\n\t\trgb[2] = p;\n\t\tbreak;\n\tcase 1:\n\t\trgb[0] = q;\n\t\trgb[1] = v;\n\t\trgb[2] = p;\n\t\tbreak;\n\tcase 2:\n\t\trgb[0] = p;\n\t\trgb[1] = v;\n\t\trgb[2] = t;\n\t\tbreak;\n\tcase 3:\n\t\trgb[0] = p;\n\t\trgb[1] = q;\n\t\trgb[2] = v;\n\t\tbreak;\n\tcase 4:\n\t\trgb[0] = t;\n\t\trgb[1] = p;\n\t\trgb[2] = v;\n\t\tbreak;\n\tcase 5:\n\t\trgb[0] = v;\n\t\trgb[1] = p;\n\t\trgb[2] = q;\n\t\tbreak;\n\t}\n}\n\n/*\n===============\nR_ColorShiftLightingBytes\n\n===============\n*/\nstatic\tvoid R_ColorShiftLightingBytes( byte in[4], byte out[4] ) {\n\tint\t\tshift, r, g, b;\n\n\t// shift the color data based on overbright range\n\tshift = r_mapOverBrightBits->integer - tr.overbrightBits;\n\n\t// shift the data based on overbright range\n\tr = in[0] << shift;\n\tg = in[1] << shift;\n\tb = in[2] << shift;\n\t\n\t// normalize by color instead of saturating to white\n\tif ( ( r | g | b ) > 255 ) {\n\t\tint\t\tmax;\n\n\t\tmax = r > g ? r : g;\n\t\tmax = max > b ? max : b;\n\t\tr = r * 255 / max;\n\t\tg = g * 255 / max;\n\t\tb = b * 255 / max;\n\t}\n\n\tout[0] = r;\n\tout[1] = g;\n\tout[2] = b;\n\tout[3] = in[3];\n}\n\n/*\n===============\nR_LoadLightmaps\n\n===============\n*/\n#define\tLIGHTMAP_SIZE\t128\nstatic\tvoid R_LoadLightmaps( lump_t *l ) {\n\tbyte\t\t*buf, *buf_p;\n\tint\t\t\tlen;\n\tMAC_STATIC byte\t\timage[LIGHTMAP_SIZE*LIGHTMAP_SIZE*4];\n\tint\t\t\ti, j;\n\tfloat maxIntensity = 0;\n\tdouble sumIntensity = 0;\n\n    len = l->filelen;\n\tif ( !len ) {\n\t\treturn;\n\t}\n\tbuf = fileBase + l->fileofs;\n\n\t// we are about to upload textures\n\tR_SyncRenderThread();\n\n\t// create all the lightmaps\n\ttr.numLightmaps = len / (LIGHTMAP_SIZE * LIGHTMAP_SIZE * 3);\n\tif ( tr.numLightmaps == 1 ) {\n\t\t//FIXME: HACK: maps with only one lightmap turn up fullbright for some reason.\n\t\t//this avoids this, but isn't the correct solution.\n\t\ttr.numLightmaps++;\n\t}\n\n\t// if we are in r_vertexLight mode, we don't need the lightmaps at all\n\tif ( r_vertexLight->integer || glConfig.hardwareType == GLHW_PERMEDIA2 ) {\n\t\treturn;\n\t}\n\n\tfor ( i = 0 ; i < tr.numLightmaps ; i++ ) {\n\t\t// expand the 24 bit on-disk to 32 bit\n\t\tbuf_p = buf + i * LIGHTMAP_SIZE*LIGHTMAP_SIZE * 3;\n\n\t\tif ( r_lightmap->integer == 2 )\n\t\t{\t// color code by intensity as development tool\t(FIXME: check range)\n\t\t\tfor ( j = 0; j < LIGHTMAP_SIZE * LIGHTMAP_SIZE; j++ )\n\t\t\t{\n\t\t\t\tfloat r = buf_p[j*3+0];\n\t\t\t\tfloat g = buf_p[j*3+1];\n\t\t\t\tfloat b = buf_p[j*3+2];\n\t\t\t\tfloat intensity;\n\t\t\t\tfloat out[3];\n\n\t\t\t\tintensity = 0.33f * r + 0.685f * g + 0.063f * b;\n\n\t\t\t\tif ( intensity > 255 )\n\t\t\t\t\tintensity = 1.0f;\n\t\t\t\telse\n\t\t\t\t\tintensity /= 255.0f;\n\n\t\t\t\tif ( intensity > maxIntensity )\n\t\t\t\t\tmaxIntensity = intensity;\n\n\t\t\t\tHSVtoRGB( intensity, 1.00, 0.50, out );\n\n\t\t\t\timage[j*4+0] = out[0] * 255;\n\t\t\t\timage[j*4+1] = out[1] * 255;\n\t\t\t\timage[j*4+2] = out[2] * 255;\n\t\t\t\timage[j*4+3] = 255;\n\n\t\t\t\tsumIntensity += intensity;\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( j = 0 ; j < LIGHTMAP_SIZE * LIGHTMAP_SIZE; j++ ) {\n\t\t\t\tR_ColorShiftLightingBytes( &buf_p[j*3], &image[j*4] );\n\t\t\t\timage[j*4+3] = 255;\n\t\t\t}\n\t\t}\n\t\ttr.lightmaps[i] = R_CreateImage( va(\"*lightmap%d\",i), image, \n\t\t\tLIGHTMAP_SIZE, LIGHTMAP_SIZE, qfalse, qfalse, GL_CLAMP );\n\t}\n\n\tif ( r_lightmap->integer == 2 )\t{\n\t\tri.Printf( PRINT_ALL, \"Brightest lightmap value: %d\\n\", ( int ) ( maxIntensity * 255 ) );\n\t}\n}\n\n\n/*\n=================\nRE_SetWorldVisData\n\nThis is called by the clipmodel subsystem so we can share the 1.8 megs of\nspace in big maps...\n=================\n*/\nvoid\t\tRE_SetWorldVisData( const byte *vis ) {\n\ttr.externalVisData = vis;\n}\n\n\n/*\n=================\nR_LoadVisibility\n=================\n*/\nstatic\tvoid R_LoadVisibility( lump_t *l ) {\n\tint\t\tlen;\n\tbyte\t*buf;\n\n\tlen = ( s_worldData.numClusters + 63 ) & ~63;\n\ts_worldData.novis = ri.Hunk_Alloc( len, h_low );\n\tCom_Memset( s_worldData.novis, 0xff, len );\n\n    len = l->filelen;\n\tif ( !len ) {\n\t\treturn;\n\t}\n\tbuf = fileBase + l->fileofs;\n\n\ts_worldData.numClusters = LittleLong( ((int *)buf)[0] );\n\ts_worldData.clusterBytes = LittleLong( ((int *)buf)[1] );\n\n\t// CM_Load should have given us the vis data to share, so\n\t// we don't need to allocate another copy\n\tif ( tr.externalVisData ) {\n\t\ts_worldData.vis = tr.externalVisData;\n\t} else {\n\t\tbyte\t*dest;\n\n\t\tdest = ri.Hunk_Alloc( len - 8, h_low );\n\t\tCom_Memcpy( dest, buf + 8, len - 8 );\n\t\ts_worldData.vis = dest;\n\t}\n}\n\n//===============================================================================\n\n\n/*\n===============\nShaderForShaderNum\n===============\n*/\nstatic shader_t *ShaderForShaderNum( int shaderNum, int lightmapNum ) {\n\tshader_t\t*shader;\n\tdshader_t\t*dsh;\n\n\tshaderNum = LittleLong( shaderNum );\n\tif ( shaderNum < 0 || shaderNum >= s_worldData.numShaders ) {\n\t\tri.Error( ERR_DROP, \"ShaderForShaderNum: bad num %i\", shaderNum );\n\t}\n\tdsh = &s_worldData.shaders[ shaderNum ];\n\n\tif ( r_vertexLight->integer || glConfig.hardwareType == GLHW_PERMEDIA2 ) {\n\t\tlightmapNum = LIGHTMAP_BY_VERTEX;\n\t}\n\n\tif ( r_fullbright->integer ) {\n\t\tlightmapNum = LIGHTMAP_WHITEIMAGE;\n\t}\n\n\tshader = R_FindShader( dsh->shader, lightmapNum, qtrue );\n\n\t// if the shader had errors, just use default shader\n\tif ( shader->defaultShader ) {\n\t\treturn tr.defaultShader;\n\t}\n\n\treturn shader;\n}\n\n/*\n===============\nParseFace\n===============\n*/\nstatic void ParseFace( dsurface_t *ds, drawVert_t *verts, msurface_t *surf, int *indexes  ) {\n\tint\t\t\ti, j;\n\tsrfSurfaceFace_t\t*cv;\n\tint\t\t\tnumPoints, numIndexes;\n\tint\t\t\tlightmapNum;\n\tint\t\t\tsfaceSize, ofsIndexes;\n\n\tlightmapNum = LittleLong( ds->lightmapNum );\n\n\t// get fog volume\n\tsurf->fogIndex = LittleLong( ds->fogNum ) + 1;\n\n\t// get shader value\n\tsurf->shader = ShaderForShaderNum( ds->shaderNum, lightmapNum );\n\tif ( r_singleShader->integer && !surf->shader->isSky ) {\n\t\tsurf->shader = tr.defaultShader;\n\t}\n\n\tnumPoints = LittleLong( ds->numVerts );\n\tif (numPoints > MAX_FACE_POINTS) {\n\t\tri.Printf( PRINT_WARNING, \"WARNING: MAX_FACE_POINTS exceeded: %i\\n\", numPoints);\n    numPoints = MAX_FACE_POINTS;\n    surf->shader = tr.defaultShader;\n\t}\n\n\tnumIndexes = LittleLong( ds->numIndexes );\n\n\t// create the srfSurfaceFace_t\n\tsfaceSize = ( int ) &((srfSurfaceFace_t *)0)->points[numPoints];\n\tofsIndexes = sfaceSize;\n\tsfaceSize += sizeof( int ) * numIndexes;\n\n\tcv = ri.Hunk_Alloc( sfaceSize, h_low );\n\tcv->surfaceType = SF_FACE;\n\tcv->numPoints = numPoints;\n\tcv->numIndices = numIndexes;\n\tcv->ofsIndices = ofsIndexes;\n\n\tverts += LittleLong( ds->firstVert );\n\tfor ( i = 0 ; i < numPoints ; i++ ) {\n\t\tfor ( j = 0 ; j < 3 ; j++ ) {\n\t\t\tcv->points[i][j] = LittleFloat( verts[i].xyz[j] );\n\t\t}\n\t\tfor ( j = 0 ; j < 2 ; j++ ) {\n\t\t\tcv->points[i][3+j] = LittleFloat( verts[i].st[j] );\n\t\t\tcv->points[i][5+j] = LittleFloat( verts[i].lightmap[j] );\n\t\t}\n\t\tR_ColorShiftLightingBytes( verts[i].color, (byte *)&cv->points[i][7] );\n\t}\n\n\tindexes += LittleLong( ds->firstIndex );\n\tfor ( i = 0 ; i < numIndexes ; i++ ) {\n\t\t((int *)((byte *)cv + cv->ofsIndices ))[i] = LittleLong( indexes[ i ] );\n\t}\n\n\t// take the plane information from the lightmap vector\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tcv->plane.normal[i] = LittleFloat( ds->lightmapVecs[2][i] );\n\t}\n\tcv->plane.dist = DotProduct( cv->points[0], cv->plane.normal );\n\tSetPlaneSignbits( &cv->plane );\n\tcv->plane.type = PlaneTypeForNormal( cv->plane.normal );\n\n\tsurf->data = (surfaceType_t *)cv;\n}\n\n\n/*\n===============\nParseMesh\n===============\n*/\nstatic void ParseMesh ( dsurface_t *ds, drawVert_t *verts, msurface_t *surf ) {\n\tsrfGridMesh_t\t*grid;\n\tint\t\t\t\ti, j;\n\tint\t\t\t\twidth, height, numPoints;\n\tMAC_STATIC drawVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE];\n\tint\t\t\t\tlightmapNum;\n\tvec3_t\t\t\tbounds[2];\n\tvec3_t\t\t\ttmpVec;\n\tstatic surfaceType_t\tskipData = SF_SKIP;\n\n\tlightmapNum = LittleLong( ds->lightmapNum );\n\n\t// get fog volume\n\tsurf->fogIndex = LittleLong( ds->fogNum ) + 1;\n\n\t// get shader value\n\tsurf->shader = ShaderForShaderNum( ds->shaderNum, lightmapNum );\n\tif ( r_singleShader->integer && !surf->shader->isSky ) {\n\t\tsurf->shader = tr.defaultShader;\n\t}\n\n\t// we may have a nodraw surface, because they might still need to\n\t// be around for movement clipping\n\tif ( s_worldData.shaders[ LittleLong( ds->shaderNum ) ].surfaceFlags & SURF_NODRAW ) {\n\t\tsurf->data = &skipData;\n\t\treturn;\n\t}\n\n\twidth = LittleLong( ds->patchWidth );\n\theight = LittleLong( ds->patchHeight );\n\n\tverts += LittleLong( ds->firstVert );\n\tnumPoints = width * height;\n\tfor ( i = 0 ; i < numPoints ; i++ ) {\n\t\tfor ( j = 0 ; j < 3 ; j++ ) {\n\t\t\tpoints[i].xyz[j] = LittleFloat( verts[i].xyz[j] );\n\t\t\tpoints[i].normal[j] = LittleFloat( verts[i].normal[j] );\n\t\t}\n\t\tfor ( j = 0 ; j < 2 ; j++ ) {\n\t\t\tpoints[i].st[j] = LittleFloat( verts[i].st[j] );\n\t\t\tpoints[i].lightmap[j] = LittleFloat( verts[i].lightmap[j] );\n\t\t}\n\t\tR_ColorShiftLightingBytes( verts[i].color, points[i].color );\n\t}\n\n\t// pre-tesseleate\n\tgrid = R_SubdividePatchToGrid( width, height, points );\n\tsurf->data = (surfaceType_t *)grid;\n\n\t// copy the level of detail origin, which is the center\n\t// of the group of all curves that must subdivide the same\n\t// to avoid cracking\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tbounds[0][i] = LittleFloat( ds->lightmapVecs[0][i] );\n\t\tbounds[1][i] = LittleFloat( ds->lightmapVecs[1][i] );\n\t}\n\tVectorAdd( bounds[0], bounds[1], bounds[1] );\n\tVectorScale( bounds[1], 0.5f, grid->lodOrigin );\n\tVectorSubtract( bounds[0], grid->lodOrigin, tmpVec );\n\tgrid->lodRadius = VectorLength( tmpVec );\n}\n\n/*\n===============\nParseTriSurf\n===============\n*/\nstatic void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, msurface_t *surf, int *indexes ) {\n\tsrfTriangles_t\t*tri;\n\tint\t\t\t\ti, j;\n\tint\t\t\t\tnumVerts, numIndexes;\n\n\t// get fog volume\n\tsurf->fogIndex = LittleLong( ds->fogNum ) + 1;\n\n\t// get shader\n\tsurf->shader = ShaderForShaderNum( ds->shaderNum, LIGHTMAP_BY_VERTEX );\n\tif ( r_singleShader->integer && !surf->shader->isSky ) {\n\t\tsurf->shader = tr.defaultShader;\n\t}\n\n\tnumVerts = LittleLong( ds->numVerts );\n\tnumIndexes = LittleLong( ds->numIndexes );\n\n\ttri = ri.Hunk_Alloc( sizeof( *tri ) + numVerts * sizeof( tri->verts[0] ) \n\t\t+ numIndexes * sizeof( tri->indexes[0] ), h_low );\n\ttri->surfaceType = SF_TRIANGLES;\n\ttri->numVerts = numVerts;\n\ttri->numIndexes = numIndexes;\n\ttri->verts = (drawVert_t *)(tri + 1);\n\ttri->indexes = (int *)(tri->verts + tri->numVerts );\n\n\tsurf->data = (surfaceType_t *)tri;\n\n\t// copy vertexes\n\tClearBounds( tri->bounds[0], tri->bounds[1] );\n\tverts += LittleLong( ds->firstVert );\n\tfor ( i = 0 ; i < numVerts ; i++ ) {\n\t\tfor ( j = 0 ; j < 3 ; j++ ) {\n\t\t\ttri->verts[i].xyz[j] = LittleFloat( verts[i].xyz[j] );\n\t\t\ttri->verts[i].normal[j] = LittleFloat( verts[i].normal[j] );\n\t\t}\n\t\tAddPointToBounds( tri->verts[i].xyz, tri->bounds[0], tri->bounds[1] );\n\t\tfor ( j = 0 ; j < 2 ; j++ ) {\n\t\t\ttri->verts[i].st[j] = LittleFloat( verts[i].st[j] );\n\t\t\ttri->verts[i].lightmap[j] = LittleFloat( verts[i].lightmap[j] );\n\t\t}\n\n\t\tR_ColorShiftLightingBytes( verts[i].color, tri->verts[i].color );\n\t}\n\n\t// copy indexes\n\tindexes += LittleLong( ds->firstIndex );\n\tfor ( i = 0 ; i < numIndexes ; i++ ) {\n\t\ttri->indexes[i] = LittleLong( indexes[i] );\n\t\tif ( tri->indexes[i] < 0 || tri->indexes[i] >= numVerts ) {\n\t\t\tri.Error( ERR_DROP, \"Bad index in triangle surface\" );\n\t\t}\n\t}\n}\n\n/*\n===============\nParseFlare\n===============\n*/\nstatic void ParseFlare( dsurface_t *ds, drawVert_t *verts, msurface_t *surf, int *indexes ) {\n\tsrfFlare_t\t\t*flare;\n\tint\t\t\t\ti;\n\n\t// get fog volume\n\tsurf->fogIndex = LittleLong( ds->fogNum ) + 1;\n\n\t// get shader\n\tsurf->shader = ShaderForShaderNum( ds->shaderNum, LIGHTMAP_BY_VERTEX );\n\tif ( r_singleShader->integer && !surf->shader->isSky ) {\n\t\tsurf->shader = tr.defaultShader;\n\t}\n\n\tflare = ri.Hunk_Alloc( sizeof( *flare ), h_low );\n\tflare->surfaceType = SF_FLARE;\n\n\tsurf->data = (surfaceType_t *)flare;\n\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tflare->origin[i] = LittleFloat( ds->lightmapOrigin[i] );\n\t\tflare->color[i] = LittleFloat( ds->lightmapVecs[0][i] );\n\t\tflare->normal[i] = LittleFloat( ds->lightmapVecs[2][i] );\n\t}\n}\n\n\n/*\n=================\nR_MergedWidthPoints\n\nreturns true if there are grid points merged on a width edge\n=================\n*/\nint R_MergedWidthPoints(srfGridMesh_t *grid, int offset) {\n\tint i, j;\n\n\tfor (i = 1; i < grid->width-1; i++) {\n\t\tfor (j = i + 1; j < grid->width-1; j++) {\n\t\t\tif ( fabs(grid->verts[i + offset].xyz[0] - grid->verts[j + offset].xyz[0]) > .1) continue;\n\t\t\tif ( fabs(grid->verts[i + offset].xyz[1] - grid->verts[j + offset].xyz[1]) > .1) continue;\n\t\t\tif ( fabs(grid->verts[i + offset].xyz[2] - grid->verts[j + offset].xyz[2]) > .1) continue;\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n/*\n=================\nR_MergedHeightPoints\n\nreturns true if there are grid points merged on a height edge\n=================\n*/\nint R_MergedHeightPoints(srfGridMesh_t *grid, int offset) {\n\tint i, j;\n\n\tfor (i = 1; i < grid->height-1; i++) {\n\t\tfor (j = i + 1; j < grid->height-1; j++) {\n\t\t\tif ( fabs(grid->verts[grid->width * i + offset].xyz[0] - grid->verts[grid->width * j + offset].xyz[0]) > .1) continue;\n\t\t\tif ( fabs(grid->verts[grid->width * i + offset].xyz[1] - grid->verts[grid->width * j + offset].xyz[1]) > .1) continue;\n\t\t\tif ( fabs(grid->verts[grid->width * i + offset].xyz[2] - grid->verts[grid->width * j + offset].xyz[2]) > .1) continue;\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n/*\n=================\nR_FixSharedVertexLodError_r\n\nNOTE: never sync LoD through grid edges with merged points!\n\nFIXME: write generalized version that also avoids cracks between a patch and one that meets half way?\n=================\n*/\nvoid R_FixSharedVertexLodError_r( int start, srfGridMesh_t *grid1 ) {\n\tint j, k, l, m, n, offset1, offset2, touch;\n\tsrfGridMesh_t *grid2;\n\n\tfor ( j = start; j < s_worldData.numsurfaces; j++ ) {\n\t\t//\n\t\tgrid2 = (srfGridMesh_t *) s_worldData.surfaces[j].data;\n\t\t// if this surface is not a grid\n\t\tif ( grid2->surfaceType != SF_GRID ) continue;\n\t\t// if the LOD errors are already fixed for this patch\n\t\tif ( grid2->lodFixed == 2 ) continue;\n\t\t// grids in the same LOD group should have the exact same lod radius\n\t\tif ( grid1->lodRadius != grid2->lodRadius ) continue;\n\t\t// grids in the same LOD group should have the exact same lod origin\n\t\tif ( grid1->lodOrigin[0] != grid2->lodOrigin[0] ) continue;\n\t\tif ( grid1->lodOrigin[1] != grid2->lodOrigin[1] ) continue;\n\t\tif ( grid1->lodOrigin[2] != grid2->lodOrigin[2] ) continue;\n\t\t//\n\t\ttouch = qfalse;\n\t\tfor (n = 0; n < 2; n++) {\n\t\t\t//\n\t\t\tif (n) offset1 = (grid1->height-1) * grid1->width;\n\t\t\telse offset1 = 0;\n\t\t\tif (R_MergedWidthPoints(grid1, offset1)) continue;\n\t\t\tfor (k = 1; k < grid1->width-1; k++) {\n\t\t\t\tfor (m = 0; m < 2; m++) {\n\n\t\t\t\t\tif (m) offset2 = (grid2->height-1) * grid2->width;\n\t\t\t\t\telse offset2 = 0;\n\t\t\t\t\tif (R_MergedWidthPoints(grid2, offset2)) continue;\n\t\t\t\t\tfor ( l = 1; l < grid2->width-1; l++) {\n\t\t\t\t\t//\n\t\t\t\t\t\tif ( fabs(grid1->verts[k + offset1].xyz[0] - grid2->verts[l + offset2].xyz[0]) > .1) continue;\n\t\t\t\t\t\tif ( fabs(grid1->verts[k + offset1].xyz[1] - grid2->verts[l + offset2].xyz[1]) > .1) continue;\n\t\t\t\t\t\tif ( fabs(grid1->verts[k + offset1].xyz[2] - grid2->verts[l + offset2].xyz[2]) > .1) continue;\n\t\t\t\t\t\t// ok the points are equal and should have the same lod error\n\t\t\t\t\t\tgrid2->widthLodError[l] = grid1->widthLodError[k];\n\t\t\t\t\t\ttouch = qtrue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (m = 0; m < 2; m++) {\n\n\t\t\t\t\tif (m) offset2 = grid2->width-1;\n\t\t\t\t\telse offset2 = 0;\n\t\t\t\t\tif (R_MergedHeightPoints(grid2, offset2)) continue;\n\t\t\t\t\tfor ( l = 1; l < grid2->height-1; l++) {\n\t\t\t\t\t//\n\t\t\t\t\t\tif ( fabs(grid1->verts[k + offset1].xyz[0] - grid2->verts[grid2->width * l + offset2].xyz[0]) > .1) continue;\n\t\t\t\t\t\tif ( fabs(grid1->verts[k + offset1].xyz[1] - grid2->verts[grid2->width * l + offset2].xyz[1]) > .1) continue;\n\t\t\t\t\t\tif ( fabs(grid1->verts[k + offset1].xyz[2] - grid2->verts[grid2->width * l + offset2].xyz[2]) > .1) continue;\n\t\t\t\t\t\t// ok the points are equal and should have the same lod error\n\t\t\t\t\t\tgrid2->heightLodError[l] = grid1->widthLodError[k];\n\t\t\t\t\t\ttouch = qtrue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (n = 0; n < 2; n++) {\n\t\t\t//\n\t\t\tif (n) offset1 = grid1->width-1;\n\t\t\telse offset1 = 0;\n\t\t\tif (R_MergedHeightPoints(grid1, offset1)) continue;\n\t\t\tfor (k = 1; k < grid1->height-1; k++) {\n\t\t\t\tfor (m = 0; m < 2; m++) {\n\n\t\t\t\t\tif (m) offset2 = (grid2->height-1) * grid2->width;\n\t\t\t\t\telse offset2 = 0;\n\t\t\t\t\tif (R_MergedWidthPoints(grid2, offset2)) continue;\n\t\t\t\t\tfor ( l = 1; l < grid2->width-1; l++) {\n\t\t\t\t\t//\n\t\t\t\t\t\tif ( fabs(grid1->verts[grid1->width * k + offset1].xyz[0] - grid2->verts[l + offset2].xyz[0]) > .1) continue;\n\t\t\t\t\t\tif ( fabs(grid1->verts[grid1->width * k + offset1].xyz[1] - grid2->verts[l + offset2].xyz[1]) > .1) continue;\n\t\t\t\t\t\tif ( fabs(grid1->verts[grid1->width * k + offset1].xyz[2] - grid2->verts[l + offset2].xyz[2]) > .1) continue;\n\t\t\t\t\t\t// ok the points are equal and should have the same lod error\n\t\t\t\t\t\tgrid2->widthLodError[l] = grid1->heightLodError[k];\n\t\t\t\t\t\ttouch = qtrue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (m = 0; m < 2; m++) {\n\n\t\t\t\t\tif (m) offset2 = grid2->width-1;\n\t\t\t\t\telse offset2 = 0;\n\t\t\t\t\tif (R_MergedHeightPoints(grid2, offset2)) continue;\n\t\t\t\t\tfor ( l = 1; l < grid2->height-1; l++) {\n\t\t\t\t\t//\n\t\t\t\t\t\tif ( fabs(grid1->verts[grid1->width * k + offset1].xyz[0] - grid2->verts[grid2->width * l + offset2].xyz[0]) > .1) continue;\n\t\t\t\t\t\tif ( fabs(grid1->verts[grid1->width * k + offset1].xyz[1] - grid2->verts[grid2->width * l + offset2].xyz[1]) > .1) continue;\n\t\t\t\t\t\tif ( fabs(grid1->verts[grid1->width * k + offset1].xyz[2] - grid2->verts[grid2->width * l + offset2].xyz[2]) > .1) continue;\n\t\t\t\t\t\t// ok the points are equal and should have the same lod error\n\t\t\t\t\t\tgrid2->heightLodError[l] = grid1->heightLodError[k];\n\t\t\t\t\t\ttouch = qtrue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (touch) {\n\t\t\tgrid2->lodFixed = 2;\n\t\t\tR_FixSharedVertexLodError_r ( start, grid2 );\n\t\t\t//NOTE: this would be correct but makes things really slow\n\t\t\t//grid2->lodFixed = 1;\n\t\t}\n\t}\n}\n\n/*\n=================\nR_FixSharedVertexLodError\n\nThis function assumes that all patches in one group are nicely stitched together for the highest LoD.\nIf this is not the case this function will still do its job but won't fix the highest LoD cracks.\n=================\n*/\nvoid R_FixSharedVertexLodError( void ) {\n\tint i;\n\tsrfGridMesh_t *grid1;\n\n\tfor ( i = 0; i < s_worldData.numsurfaces; i++ ) {\n\t\t//\n\t\tgrid1 = (srfGridMesh_t *) s_worldData.surfaces[i].data;\n\t\t// if this surface is not a grid\n\t\tif ( grid1->surfaceType != SF_GRID )\n\t\t\tcontinue;\n\t\t//\n\t\tif ( grid1->lodFixed )\n\t\t\tcontinue;\n\t\t//\n\t\tgrid1->lodFixed = 2;\n\t\t// recursively fix other patches in the same LOD group\n\t\tR_FixSharedVertexLodError_r( i + 1, grid1);\n\t}\n}\n\n\n/*\n===============\nR_StitchPatches\n===============\n*/\nint R_StitchPatches( int grid1num, int grid2num ) {\n\tfloat *v1, *v2;\n\tsrfGridMesh_t *grid1, *grid2;\n\tint k, l, m, n, offset1, offset2, row, column;\n\n\tgrid1 = (srfGridMesh_t *) s_worldData.surfaces[grid1num].data;\n\tgrid2 = (srfGridMesh_t *) s_worldData.surfaces[grid2num].data;\n\tfor (n = 0; n < 2; n++) {\n\t\t//\n\t\tif (n) offset1 = (grid1->height-1) * grid1->width;\n\t\telse offset1 = 0;\n\t\tif (R_MergedWidthPoints(grid1, offset1))\n\t\t\tcontinue;\n\t\tfor (k = 0; k < grid1->width-2; k += 2) {\n\n\t\t\tfor (m = 0; m < 2; m++) {\n\n\t\t\t\tif ( grid2->width >= MAX_GRID_SIZE )\n\t\t\t\t\tbreak;\n\t\t\t\tif (m) offset2 = (grid2->height-1) * grid2->width;\n\t\t\t\telse offset2 = 0;\n\t\t\t\tfor ( l = 0; l < grid2->width-1; l++) {\n\t\t\t\t//\n\t\t\t\t\tv1 = grid1->verts[k + offset1].xyz;\n\t\t\t\t\tv2 = grid2->verts[l + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[1] - v2[1]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[2] - v2[2]) > .1)\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tv1 = grid1->verts[k + 2 + offset1].xyz;\n\t\t\t\t\tv2 = grid2->verts[l + 1 + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[1] - v2[1]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[2] - v2[2]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t//\n\t\t\t\t\tv1 = grid2->verts[l + offset2].xyz;\n\t\t\t\t\tv2 = grid2->verts[l + 1 + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) < .01 &&\n\t\t\t\t\t\t\tfabs(v1[1] - v2[1]) < .01 &&\n\t\t\t\t\t\t\tfabs(v1[2] - v2[2]) < .01)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t//\n\t\t\t\t\t//ri.Printf( PRINT_ALL, \"found highest LoD crack between two patches\\n\" );\n\t\t\t\t\t// insert column into grid2 right after after column l\n\t\t\t\t\tif (m) row = grid2->height-1;\n\t\t\t\t\telse row = 0;\n\t\t\t\t\tgrid2 = R_GridInsertColumn( grid2, l+1, row,\n\t\t\t\t\t\t\t\t\tgrid1->verts[k + 1 + offset1].xyz, grid1->widthLodError[k+1]);\n\t\t\t\t\tgrid2->lodStitched = qfalse;\n\t\t\t\t\ts_worldData.surfaces[grid2num].data = (void *) grid2;\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (m = 0; m < 2; m++) {\n\n\t\t\t\tif (grid2->height >= MAX_GRID_SIZE)\n\t\t\t\t\tbreak;\n\t\t\t\tif (m) offset2 = grid2->width-1;\n\t\t\t\telse offset2 = 0;\n\t\t\t\tfor ( l = 0; l < grid2->height-1; l++) {\n\t\t\t\t\t//\n\t\t\t\t\tv1 = grid1->verts[k + offset1].xyz;\n\t\t\t\t\tv2 = grid2->verts[grid2->width * l + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[1] - v2[1]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[2] - v2[2]) > .1)\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tv1 = grid1->verts[k + 2 + offset1].xyz;\n\t\t\t\t\tv2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[1] - v2[1]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[2] - v2[2]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t//\n\t\t\t\t\tv1 = grid2->verts[grid2->width * l + offset2].xyz;\n\t\t\t\t\tv2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) < .01 &&\n\t\t\t\t\t\t\tfabs(v1[1] - v2[1]) < .01 &&\n\t\t\t\t\t\t\tfabs(v1[2] - v2[2]) < .01)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t//\n\t\t\t\t\t//ri.Printf( PRINT_ALL, \"found highest LoD crack between two patches\\n\" );\n\t\t\t\t\t// insert row into grid2 right after after row l\n\t\t\t\t\tif (m) column = grid2->width-1;\n\t\t\t\t\telse column = 0;\n\t\t\t\t\tgrid2 = R_GridInsertRow( grid2, l+1, column,\n\t\t\t\t\t\t\t\t\t\tgrid1->verts[k + 1 + offset1].xyz, grid1->widthLodError[k+1]);\n\t\t\t\t\tgrid2->lodStitched = qfalse;\n\t\t\t\t\ts_worldData.surfaces[grid2num].data = (void *) grid2;\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor (n = 0; n < 2; n++) {\n\t\t//\n\t\tif (n) offset1 = grid1->width-1;\n\t\telse offset1 = 0;\n\t\tif (R_MergedHeightPoints(grid1, offset1))\n\t\t\tcontinue;\n\t\tfor (k = 0; k < grid1->height-2; k += 2) {\n\t\t\tfor (m = 0; m < 2; m++) {\n\n\t\t\t\tif ( grid2->width >= MAX_GRID_SIZE )\n\t\t\t\t\tbreak;\n\t\t\t\tif (m) offset2 = (grid2->height-1) * grid2->width;\n\t\t\t\telse offset2 = 0;\n\t\t\t\tfor ( l = 0; l < grid2->width-1; l++) {\n\t\t\t\t//\n\t\t\t\t\tv1 = grid1->verts[grid1->width * k + offset1].xyz;\n\t\t\t\t\tv2 = grid2->verts[l + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[1] - v2[1]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[2] - v2[2]) > .1)\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tv1 = grid1->verts[grid1->width * (k + 2) + offset1].xyz;\n\t\t\t\t\tv2 = grid2->verts[l + 1 + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[1] - v2[1]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[2] - v2[2]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t//\n\t\t\t\t\tv1 = grid2->verts[l + offset2].xyz;\n\t\t\t\t\tv2 = grid2->verts[(l + 1) + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) < .01 &&\n\t\t\t\t\t\t\tfabs(v1[1] - v2[1]) < .01 &&\n\t\t\t\t\t\t\tfabs(v1[2] - v2[2]) < .01)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t//\n\t\t\t\t\t//ri.Printf( PRINT_ALL, \"found highest LoD crack between two patches\\n\" );\n\t\t\t\t\t// insert column into grid2 right after after column l\n\t\t\t\t\tif (m) row = grid2->height-1;\n\t\t\t\t\telse row = 0;\n\t\t\t\t\tgrid2 = R_GridInsertColumn( grid2, l+1, row,\n\t\t\t\t\t\t\t\t\tgrid1->verts[grid1->width * (k + 1) + offset1].xyz, grid1->heightLodError[k+1]);\n\t\t\t\t\tgrid2->lodStitched = qfalse;\n\t\t\t\t\ts_worldData.surfaces[grid2num].data = (void *) grid2;\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (m = 0; m < 2; m++) {\n\n\t\t\t\tif (grid2->height >= MAX_GRID_SIZE)\n\t\t\t\t\tbreak;\n\t\t\t\tif (m) offset2 = grid2->width-1;\n\t\t\t\telse offset2 = 0;\n\t\t\t\tfor ( l = 0; l < grid2->height-1; l++) {\n\t\t\t\t//\n\t\t\t\t\tv1 = grid1->verts[grid1->width * k + offset1].xyz;\n\t\t\t\t\tv2 = grid2->verts[grid2->width * l + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[1] - v2[1]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[2] - v2[2]) > .1)\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tv1 = grid1->verts[grid1->width * (k + 2) + offset1].xyz;\n\t\t\t\t\tv2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[1] - v2[1]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[2] - v2[2]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t//\n\t\t\t\t\tv1 = grid2->verts[grid2->width * l + offset2].xyz;\n\t\t\t\t\tv2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) < .01 &&\n\t\t\t\t\t\t\tfabs(v1[1] - v2[1]) < .01 &&\n\t\t\t\t\t\t\tfabs(v1[2] - v2[2]) < .01)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t//\n\t\t\t\t\t//ri.Printf( PRINT_ALL, \"found highest LoD crack between two patches\\n\" );\n\t\t\t\t\t// insert row into grid2 right after after row l\n\t\t\t\t\tif (m) column = grid2->width-1;\n\t\t\t\t\telse column = 0;\n\t\t\t\t\tgrid2 = R_GridInsertRow( grid2, l+1, column,\n\t\t\t\t\t\t\t\t\tgrid1->verts[grid1->width * (k + 1) + offset1].xyz, grid1->heightLodError[k+1]);\n\t\t\t\t\tgrid2->lodStitched = qfalse;\n\t\t\t\t\ts_worldData.surfaces[grid2num].data = (void *) grid2;\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor (n = 0; n < 2; n++) {\n\t\t//\n\t\tif (n) offset1 = (grid1->height-1) * grid1->width;\n\t\telse offset1 = 0;\n\t\tif (R_MergedWidthPoints(grid1, offset1))\n\t\t\tcontinue;\n\t\tfor (k = grid1->width-1; k > 1; k -= 2) {\n\n\t\t\tfor (m = 0; m < 2; m++) {\n\n\t\t\t\tif ( grid2->width >= MAX_GRID_SIZE )\n\t\t\t\t\tbreak;\n\t\t\t\tif (m) offset2 = (grid2->height-1) * grid2->width;\n\t\t\t\telse offset2 = 0;\n\t\t\t\tfor ( l = 0; l < grid2->width-1; l++) {\n\t\t\t\t//\n\t\t\t\t\tv1 = grid1->verts[k + offset1].xyz;\n\t\t\t\t\tv2 = grid2->verts[l + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[1] - v2[1]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[2] - v2[2]) > .1)\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tv1 = grid1->verts[k - 2 + offset1].xyz;\n\t\t\t\t\tv2 = grid2->verts[l + 1 + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[1] - v2[1]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[2] - v2[2]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t//\n\t\t\t\t\tv1 = grid2->verts[l + offset2].xyz;\n\t\t\t\t\tv2 = grid2->verts[(l + 1) + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) < .01 &&\n\t\t\t\t\t\t\tfabs(v1[1] - v2[1]) < .01 &&\n\t\t\t\t\t\t\tfabs(v1[2] - v2[2]) < .01)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t//\n\t\t\t\t\t//ri.Printf( PRINT_ALL, \"found highest LoD crack between two patches\\n\" );\n\t\t\t\t\t// insert column into grid2 right after after column l\n\t\t\t\t\tif (m) row = grid2->height-1;\n\t\t\t\t\telse row = 0;\n\t\t\t\t\tgrid2 = R_GridInsertColumn( grid2, l+1, row,\n\t\t\t\t\t\t\t\t\t\tgrid1->verts[k - 1 + offset1].xyz, grid1->widthLodError[k+1]);\n\t\t\t\t\tgrid2->lodStitched = qfalse;\n\t\t\t\t\ts_worldData.surfaces[grid2num].data = (void *) grid2;\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (m = 0; m < 2; m++) {\n\n\t\t\t\tif (grid2->height >= MAX_GRID_SIZE)\n\t\t\t\t\tbreak;\n\t\t\t\tif (m) offset2 = grid2->width-1;\n\t\t\t\telse offset2 = 0;\n\t\t\t\tfor ( l = 0; l < grid2->height-1; l++) {\n\t\t\t\t//\n\t\t\t\t\tv1 = grid1->verts[k + offset1].xyz;\n\t\t\t\t\tv2 = grid2->verts[grid2->width * l + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[1] - v2[1]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[2] - v2[2]) > .1)\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tv1 = grid1->verts[k - 2 + offset1].xyz;\n\t\t\t\t\tv2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[1] - v2[1]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[2] - v2[2]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t//\n\t\t\t\t\tv1 = grid2->verts[grid2->width * l + offset2].xyz;\n\t\t\t\t\tv2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) < .01 &&\n\t\t\t\t\t\t\tfabs(v1[1] - v2[1]) < .01 &&\n\t\t\t\t\t\t\tfabs(v1[2] - v2[2]) < .01)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t//\n\t\t\t\t\t//ri.Printf( PRINT_ALL, \"found highest LoD crack between two patches\\n\" );\n\t\t\t\t\t// insert row into grid2 right after after row l\n\t\t\t\t\tif (m) column = grid2->width-1;\n\t\t\t\t\telse column = 0;\n\t\t\t\t\tgrid2 = R_GridInsertRow( grid2, l+1, column,\n\t\t\t\t\t\t\t\t\t\tgrid1->verts[k - 1 + offset1].xyz, grid1->widthLodError[k+1]);\n\t\t\t\t\tif (!grid2)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tgrid2->lodStitched = qfalse;\n\t\t\t\t\ts_worldData.surfaces[grid2num].data = (void *) grid2;\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor (n = 0; n < 2; n++) {\n\t\t//\n\t\tif (n) offset1 = grid1->width-1;\n\t\telse offset1 = 0;\n\t\tif (R_MergedHeightPoints(grid1, offset1))\n\t\t\tcontinue;\n\t\tfor (k = grid1->height-1; k > 1; k -= 2) {\n\t\t\tfor (m = 0; m < 2; m++) {\n\n\t\t\t\tif ( grid2->width >= MAX_GRID_SIZE )\n\t\t\t\t\tbreak;\n\t\t\t\tif (m) offset2 = (grid2->height-1) * grid2->width;\n\t\t\t\telse offset2 = 0;\n\t\t\t\tfor ( l = 0; l < grid2->width-1; l++) {\n\t\t\t\t//\n\t\t\t\t\tv1 = grid1->verts[grid1->width * k + offset1].xyz;\n\t\t\t\t\tv2 = grid2->verts[l + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[1] - v2[1]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[2] - v2[2]) > .1)\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tv1 = grid1->verts[grid1->width * (k - 2) + offset1].xyz;\n\t\t\t\t\tv2 = grid2->verts[l + 1 + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[1] - v2[1]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[2] - v2[2]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t//\n\t\t\t\t\tv1 = grid2->verts[l + offset2].xyz;\n\t\t\t\t\tv2 = grid2->verts[(l + 1) + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) < .01 &&\n\t\t\t\t\t\t\tfabs(v1[1] - v2[1]) < .01 &&\n\t\t\t\t\t\t\tfabs(v1[2] - v2[2]) < .01)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t//\n\t\t\t\t\t//ri.Printf( PRINT_ALL, \"found highest LoD crack between two patches\\n\" );\n\t\t\t\t\t// insert column into grid2 right after after column l\n\t\t\t\t\tif (m) row = grid2->height-1;\n\t\t\t\t\telse row = 0;\n\t\t\t\t\tgrid2 = R_GridInsertColumn( grid2, l+1, row,\n\t\t\t\t\t\t\t\t\t\tgrid1->verts[grid1->width * (k - 1) + offset1].xyz, grid1->heightLodError[k+1]);\n\t\t\t\t\tgrid2->lodStitched = qfalse;\n\t\t\t\t\ts_worldData.surfaces[grid2num].data = (void *) grid2;\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (m = 0; m < 2; m++) {\n\n\t\t\t\tif (grid2->height >= MAX_GRID_SIZE)\n\t\t\t\t\tbreak;\n\t\t\t\tif (m) offset2 = grid2->width-1;\n\t\t\t\telse offset2 = 0;\n\t\t\t\tfor ( l = 0; l < grid2->height-1; l++) {\n\t\t\t\t//\n\t\t\t\t\tv1 = grid1->verts[grid1->width * k + offset1].xyz;\n\t\t\t\t\tv2 = grid2->verts[grid2->width * l + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[1] - v2[1]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[2] - v2[2]) > .1)\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tv1 = grid1->verts[grid1->width * (k - 2) + offset1].xyz;\n\t\t\t\t\tv2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[1] - v2[1]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ( fabs(v1[2] - v2[2]) > .1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t//\n\t\t\t\t\tv1 = grid2->verts[grid2->width * l + offset2].xyz;\n\t\t\t\t\tv2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz;\n\t\t\t\t\tif ( fabs(v1[0] - v2[0]) < .01 &&\n\t\t\t\t\t\t\tfabs(v1[1] - v2[1]) < .01 &&\n\t\t\t\t\t\t\tfabs(v1[2] - v2[2]) < .01)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t//\n\t\t\t\t\t//ri.Printf( PRINT_ALL, \"found highest LoD crack between two patches\\n\" );\n\t\t\t\t\t// insert row into grid2 right after after row l\n\t\t\t\t\tif (m) column = grid2->width-1;\n\t\t\t\t\telse column = 0;\n\t\t\t\t\tgrid2 = R_GridInsertRow( grid2, l+1, column,\n\t\t\t\t\t\t\t\t\t\tgrid1->verts[grid1->width * (k - 1) + offset1].xyz, grid1->heightLodError[k+1]);\n\t\t\t\t\tgrid2->lodStitched = qfalse;\n\t\t\t\t\ts_worldData.surfaces[grid2num].data = (void *) grid2;\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n/*\n===============\nR_TryStitchPatch\n\nThis function will try to stitch patches in the same LoD group together for the highest LoD.\n\nOnly single missing vertice cracks will be fixed.\n\nVertices will be joined at the patch side a crack is first found, at the other side\nof the patch (on the same row or column) the vertices will not be joined and cracks\nmight still appear at that side.\n===============\n*/\nint R_TryStitchingPatch( int grid1num ) {\n\tint j, numstitches;\n\tsrfGridMesh_t *grid1, *grid2;\n\n\tnumstitches = 0;\n\tgrid1 = (srfGridMesh_t *) s_worldData.surfaces[grid1num].data;\n\tfor ( j = 0; j < s_worldData.numsurfaces; j++ ) {\n\t\t//\n\t\tgrid2 = (srfGridMesh_t *) s_worldData.surfaces[j].data;\n\t\t// if this surface is not a grid\n\t\tif ( grid2->surfaceType != SF_GRID ) continue;\n\t\t// grids in the same LOD group should have the exact same lod radius\n\t\tif ( grid1->lodRadius != grid2->lodRadius ) continue;\n\t\t// grids in the same LOD group should have the exact same lod origin\n\t\tif ( grid1->lodOrigin[0] != grid2->lodOrigin[0] ) continue;\n\t\tif ( grid1->lodOrigin[1] != grid2->lodOrigin[1] ) continue;\n\t\tif ( grid1->lodOrigin[2] != grid2->lodOrigin[2] ) continue;\n\t\t//\n\t\twhile (R_StitchPatches(grid1num, j))\n\t\t{\n\t\t\tnumstitches++;\n\t\t}\n\t}\n\treturn numstitches;\n}\n\n/*\n===============\nR_StitchAllPatches\n===============\n*/\nvoid R_StitchAllPatches( void ) {\n\tint i, stitched, numstitches;\n\tsrfGridMesh_t *grid1;\n\n\tnumstitches = 0;\n\tdo\n\t{\n\t\tstitched = qfalse;\n\t\tfor ( i = 0; i < s_worldData.numsurfaces; i++ ) {\n\t\t\t//\n\t\t\tgrid1 = (srfGridMesh_t *) s_worldData.surfaces[i].data;\n\t\t\t// if this surface is not a grid\n\t\t\tif ( grid1->surfaceType != SF_GRID )\n\t\t\t\tcontinue;\n\t\t\t//\n\t\t\tif ( grid1->lodStitched )\n\t\t\t\tcontinue;\n\t\t\t//\n\t\t\tgrid1->lodStitched = qtrue;\n\t\t\tstitched = qtrue;\n\t\t\t//\n\t\t\tnumstitches += R_TryStitchingPatch( i );\n\t\t}\n\t}\n\twhile (stitched);\n\tri.Printf( PRINT_ALL, \"stitched %d LoD cracks\\n\", numstitches );\n}\n\n/*\n===============\nR_MovePatchSurfacesToHunk\n===============\n*/\nvoid R_MovePatchSurfacesToHunk(void) {\n\tint i, size;\n\tsrfGridMesh_t *grid, *hunkgrid;\n\n\tfor ( i = 0; i < s_worldData.numsurfaces; i++ ) {\n\t\t//\n\t\tgrid = (srfGridMesh_t *) s_worldData.surfaces[i].data;\n\t\t// if this surface is not a grid\n\t\tif ( grid->surfaceType != SF_GRID )\n\t\t\tcontinue;\n\t\t//\n\t\tsize = (grid->width * grid->height - 1) * sizeof( drawVert_t ) + sizeof( *grid );\n\t\thunkgrid = ri.Hunk_Alloc( size, h_low );\n\t\tCom_Memcpy(hunkgrid, grid, size);\n\n\t\thunkgrid->widthLodError = ri.Hunk_Alloc( grid->width * 4, h_low );\n\t\tCom_Memcpy( hunkgrid->widthLodError, grid->widthLodError, grid->width * 4 );\n\n\t\thunkgrid->heightLodError = ri.Hunk_Alloc( grid->height * 4, h_low );\n\t\tCom_Memcpy( grid->heightLodError, grid->heightLodError, grid->height * 4 );\n\n\t\tR_FreeSurfaceGridMesh( grid );\n\n\t\ts_worldData.surfaces[i].data = (void *) hunkgrid;\n\t}\n}\n\n/*\n===============\nR_LoadSurfaces\n===============\n*/\nstatic\tvoid R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) {\n\tdsurface_t\t*in;\n\tmsurface_t\t*out;\n\tdrawVert_t\t*dv;\n\tint\t\t\t*indexes;\n\tint\t\t\tcount;\n\tint\t\t\tnumFaces, numMeshes, numTriSurfs, numFlares;\n\tint\t\t\ti;\n\n\tnumFaces = 0;\n\tnumMeshes = 0;\n\tnumTriSurfs = 0;\n\tnumFlares = 0;\n\n\tin = (void *)(fileBase + surfs->fileofs);\n\tif (surfs->filelen % sizeof(*in))\n\t\tri.Error (ERR_DROP, \"LoadMap: funny lump size in %s\",s_worldData.name);\n\tcount = surfs->filelen / sizeof(*in);\n\n\tdv = (void *)(fileBase + verts->fileofs);\n\tif (verts->filelen % sizeof(*dv))\n\t\tri.Error (ERR_DROP, \"LoadMap: funny lump size in %s\",s_worldData.name);\n\n\tindexes = (void *)(fileBase + indexLump->fileofs);\n\tif ( indexLump->filelen % sizeof(*indexes))\n\t\tri.Error (ERR_DROP, \"LoadMap: funny lump size in %s\",s_worldData.name);\n\n\tout = ri.Hunk_Alloc ( count * sizeof(*out), h_low );\t\n\n\ts_worldData.surfaces = out;\n\ts_worldData.numsurfaces = count;\n\n\tfor ( i = 0 ; i < count ; i++, in++, out++ ) {\n\t\tswitch ( LittleLong( in->surfaceType ) ) {\n\t\tcase MST_PATCH:\n\t\t\tParseMesh ( in, dv, out );\n\t\t\tnumMeshes++;\n\t\t\tbreak;\n\t\tcase MST_TRIANGLE_SOUP:\n\t\t\tParseTriSurf( in, dv, out, indexes );\n\t\t\tnumTriSurfs++;\n\t\t\tbreak;\n\t\tcase MST_PLANAR:\n\t\t\tParseFace( in, dv, out, indexes );\n\t\t\tnumFaces++;\n\t\t\tbreak;\n\t\tcase MST_FLARE:\n\t\t\tParseFlare( in, dv, out, indexes );\n\t\t\tnumFlares++;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tri.Error( ERR_DROP, \"Bad surfaceType\" );\n\t\t}\n\t}\n\n#ifdef PATCH_STITCHING\n\tR_StitchAllPatches();\n#endif\n\n\tR_FixSharedVertexLodError();\n\n#ifdef PATCH_STITCHING\n\tR_MovePatchSurfacesToHunk();\n#endif\n\n\tri.Printf( PRINT_ALL, \"...loaded %d faces, %i meshes, %i trisurfs, %i flares\\n\", \n\t\tnumFaces, numMeshes, numTriSurfs, numFlares );\n}\n\n\n\n/*\n=================\nR_LoadSubmodels\n=================\n*/\nstatic\tvoid R_LoadSubmodels( lump_t *l ) {\n\tdmodel_t\t*in;\n\tbmodel_t\t*out;\n\tint\t\t\ti, j, count;\n\n\tin = (void *)(fileBase + l->fileofs);\n\tif (l->filelen % sizeof(*in))\n\t\tri.Error (ERR_DROP, \"LoadMap: funny lump size in %s\",s_worldData.name);\n\tcount = l->filelen / sizeof(*in);\n\n\ts_worldData.bmodels = out = ri.Hunk_Alloc( count * sizeof(*out), h_low );\n\n\tfor ( i=0 ; i<count ; i++, in++, out++ ) {\n\t\tmodel_t *model;\n\n\t\tmodel = R_AllocModel();\n\n\t\tassert( model != NULL );\t\t\t// this should never happen\n\n\t\tmodel->type = MOD_BRUSH;\n\t\tmodel->bmodel = out;\n\t\tCom_sprintf( model->name, sizeof( model->name ), \"*%d\", i );\n\n\t\tfor (j=0 ; j<3 ; j++) {\n\t\t\tout->bounds[0][j] = LittleFloat (in->mins[j]);\n\t\t\tout->bounds[1][j] = LittleFloat (in->maxs[j]);\n\t\t}\n\n\t\tout->firstSurface = s_worldData.surfaces + LittleLong( in->firstSurface );\n\t\tout->numSurfaces = LittleLong( in->numSurfaces );\n\t}\n}\n\n\n\n//==================================================================\n\n/*\n=================\nR_SetParent\n=================\n*/\nstatic\tvoid R_SetParent (mnode_t *node, mnode_t *parent)\n{\n\tnode->parent = parent;\n\tif (node->contents != -1)\n\t\treturn;\n\tR_SetParent (node->children[0], node);\n\tR_SetParent (node->children[1], node);\n}\n\n/*\n=================\nR_LoadNodesAndLeafs\n=================\n*/\nstatic\tvoid R_LoadNodesAndLeafs (lump_t *nodeLump, lump_t *leafLump) {\n\tint\t\t\ti, j, p;\n\tdnode_t\t\t*in;\n\tdleaf_t\t\t*inLeaf;\n\tmnode_t \t*out;\n\tint\t\t\tnumNodes, numLeafs;\n\n\tin = (void *)(fileBase + nodeLump->fileofs);\n\tif (nodeLump->filelen % sizeof(dnode_t) ||\n\t\tleafLump->filelen % sizeof(dleaf_t) ) {\n\t\tri.Error (ERR_DROP, \"LoadMap: funny lump size in %s\",s_worldData.name);\n\t}\n\tnumNodes = nodeLump->filelen / sizeof(dnode_t);\n\tnumLeafs = leafLump->filelen / sizeof(dleaf_t);\n\n\tout = ri.Hunk_Alloc ( (numNodes + numLeafs) * sizeof(*out), h_low);\t\n\n\ts_worldData.nodes = out;\n\ts_worldData.numnodes = numNodes + numLeafs;\n\ts_worldData.numDecisionNodes = numNodes;\n\n\t// load nodes\n\tfor ( i=0 ; i<numNodes; i++, in++, out++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\tout->mins[j] = LittleLong (in->mins[j]);\n\t\t\tout->maxs[j] = LittleLong (in->maxs[j]);\n\t\t}\n\t\n\t\tp = LittleLong(in->planeNum);\n\t\tout->plane = s_worldData.planes + p;\n\n\t\tout->contents = CONTENTS_NODE;\t// differentiate from leafs\n\n\t\tfor (j=0 ; j<2 ; j++)\n\t\t{\n\t\t\tp = LittleLong (in->children[j]);\n\t\t\tif (p >= 0)\n\t\t\t\tout->children[j] = s_worldData.nodes + p;\n\t\t\telse\n\t\t\t\tout->children[j] = s_worldData.nodes + numNodes + (-1 - p);\n\t\t}\n\t}\n\t\n\t// load leafs\n\tinLeaf = (void *)(fileBase + leafLump->fileofs);\n\tfor ( i=0 ; i<numLeafs ; i++, inLeaf++, out++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\tout->mins[j] = LittleLong (inLeaf->mins[j]);\n\t\t\tout->maxs[j] = LittleLong (inLeaf->maxs[j]);\n\t\t}\n\n\t\tout->cluster = LittleLong(inLeaf->cluster);\n\t\tout->area = LittleLong(inLeaf->area);\n\n\t\tif ( out->cluster >= s_worldData.numClusters ) {\n\t\t\ts_worldData.numClusters = out->cluster + 1;\n\t\t}\n\n\t\tout->firstmarksurface = s_worldData.marksurfaces +\n\t\t\tLittleLong(inLeaf->firstLeafSurface);\n\t\tout->nummarksurfaces = LittleLong(inLeaf->numLeafSurfaces);\n\t}\t\n\n\t// chain decendants\n\tR_SetParent (s_worldData.nodes, NULL);\n}\n\n//=============================================================================\n\n/*\n=================\nR_LoadShaders\n=================\n*/\nstatic\tvoid R_LoadShaders( lump_t *l ) {\t\n\tint\t\ti, count;\n\tdshader_t\t*in, *out;\n\t\n\tin = (void *)(fileBase + l->fileofs);\n\tif (l->filelen % sizeof(*in))\n\t\tri.Error (ERR_DROP, \"LoadMap: funny lump size in %s\",s_worldData.name);\n\tcount = l->filelen / sizeof(*in);\n\tout = ri.Hunk_Alloc ( count*sizeof(*out), h_low );\n\n\ts_worldData.shaders = out;\n\ts_worldData.numShaders = count;\n\n\tCom_Memcpy( out, in, count*sizeof(*out) );\n\n\tfor ( i=0 ; i<count ; i++ ) {\n\t\tout[i].surfaceFlags = LittleLong( out[i].surfaceFlags );\n\t\tout[i].contentFlags = LittleLong( out[i].contentFlags );\n\t}\n}\n\n\n/*\n=================\nR_LoadMarksurfaces\n=================\n*/\nstatic\tvoid R_LoadMarksurfaces (lump_t *l)\n{\t\n\tint\t\ti, j, count;\n\tint\t\t*in;\n\tmsurface_t **out;\n\t\n\tin = (void *)(fileBase + l->fileofs);\n\tif (l->filelen % sizeof(*in))\n\t\tri.Error (ERR_DROP, \"LoadMap: funny lump size in %s\",s_worldData.name);\n\tcount = l->filelen / sizeof(*in);\n\tout = ri.Hunk_Alloc ( count*sizeof(*out), h_low);\t\n\n\ts_worldData.marksurfaces = out;\n\ts_worldData.nummarksurfaces = count;\n\n\tfor ( i=0 ; i<count ; i++)\n\t{\n\t\tj = LittleLong(in[i]);\n\t\tout[i] = s_worldData.surfaces + j;\n\t}\n}\n\n\n/*\n=================\nR_LoadPlanes\n=================\n*/\nstatic\tvoid R_LoadPlanes( lump_t *l ) {\n\tint\t\t\ti, j;\n\tcplane_t\t*out;\n\tdplane_t \t*in;\n\tint\t\t\tcount;\n\tint\t\t\tbits;\n\t\n\tin = (void *)(fileBase + l->fileofs);\n\tif (l->filelen % sizeof(*in))\n\t\tri.Error (ERR_DROP, \"LoadMap: funny lump size in %s\",s_worldData.name);\n\tcount = l->filelen / sizeof(*in);\n\tout = ri.Hunk_Alloc ( count*2*sizeof(*out), h_low);\t\n\t\n\ts_worldData.planes = out;\n\ts_worldData.numplanes = count;\n\n\tfor ( i=0 ; i<count ; i++, in++, out++) {\n\t\tbits = 0;\n\t\tfor (j=0 ; j<3 ; j++) {\n\t\t\tout->normal[j] = LittleFloat (in->normal[j]);\n\t\t\tif (out->normal[j] < 0) {\n\t\t\t\tbits |= 1<<j;\n\t\t\t}\n\t\t}\n\n\t\tout->dist = LittleFloat (in->dist);\n\t\tout->type = PlaneTypeForNormal( out->normal );\n\t\tout->signbits = bits;\n\t}\n}\n\n/*\n=================\nR_LoadFogs\n\n=================\n*/\nstatic\tvoid R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump ) {\n\tint\t\t\ti;\n\tfog_t\t\t*out;\n\tdfog_t\t\t*fogs;\n\tdbrush_t \t*brushes, *brush;\n\tdbrushside_t\t*sides;\n\tint\t\t\tcount, brushesCount, sidesCount;\n\tint\t\t\tsideNum;\n\tint\t\t\tplaneNum;\n\tshader_t\t*shader;\n\tfloat\t\td;\n\tint\t\t\tfirstSide;\n\n\tfogs = (void *)(fileBase + l->fileofs);\n\tif (l->filelen % sizeof(*fogs)) {\n\t\tri.Error (ERR_DROP, \"LoadMap: funny lump size in %s\",s_worldData.name);\n\t}\n\tcount = l->filelen / sizeof(*fogs);\n\n\t// create fog strucutres for them\n\ts_worldData.numfogs = count + 1;\n\ts_worldData.fogs = ri.Hunk_Alloc ( s_worldData.numfogs*sizeof(*out), h_low);\n\tout = s_worldData.fogs + 1;\n\n\tif ( !count ) {\n\t\treturn;\n\t}\n\n\tbrushes = (void *)(fileBase + brushesLump->fileofs);\n\tif (brushesLump->filelen % sizeof(*brushes)) {\n\t\tri.Error (ERR_DROP, \"LoadMap: funny lump size in %s\",s_worldData.name);\n\t}\n\tbrushesCount = brushesLump->filelen / sizeof(*brushes);\n\n\tsides = (void *)(fileBase + sidesLump->fileofs);\n\tif (sidesLump->filelen % sizeof(*sides)) {\n\t\tri.Error (ERR_DROP, \"LoadMap: funny lump size in %s\",s_worldData.name);\n\t}\n\tsidesCount = sidesLump->filelen / sizeof(*sides);\n\n\tfor ( i=0 ; i<count ; i++, fogs++) {\n\t\tout->originalBrushNumber = LittleLong( fogs->brushNum );\n\n\t\tif ( (unsigned)out->originalBrushNumber >= brushesCount ) {\n\t\t\tri.Error( ERR_DROP, \"fog brushNumber out of range\" );\n\t\t}\n\t\tbrush = brushes + out->originalBrushNumber;\n\n\t\tfirstSide = LittleLong( brush->firstSide );\n\n\t\t\tif ( (unsigned)firstSide > sidesCount - 6 ) {\n\t\t\tri.Error( ERR_DROP, \"fog brush sideNumber out of range\" );\n\t\t}\n\n\t\t// brushes are always sorted with the axial sides first\n\t\tsideNum = firstSide + 0;\n\t\tplaneNum = LittleLong( sides[ sideNum ].planeNum );\n\t\tout->bounds[0][0] = -s_worldData.planes[ planeNum ].dist;\n\n\t\tsideNum = firstSide + 1;\n\t\tplaneNum = LittleLong( sides[ sideNum ].planeNum );\n\t\tout->bounds[1][0] = s_worldData.planes[ planeNum ].dist;\n\n\t\tsideNum = firstSide + 2;\n\t\tplaneNum = LittleLong( sides[ sideNum ].planeNum );\n\t\tout->bounds[0][1] = -s_worldData.planes[ planeNum ].dist;\n\n\t\tsideNum = firstSide + 3;\n\t\tplaneNum = LittleLong( sides[ sideNum ].planeNum );\n\t\tout->bounds[1][1] = s_worldData.planes[ planeNum ].dist;\n\n\t\tsideNum = firstSide + 4;\n\t\tplaneNum = LittleLong( sides[ sideNum ].planeNum );\n\t\tout->bounds[0][2] = -s_worldData.planes[ planeNum ].dist;\n\n\t\tsideNum = firstSide + 5;\n\t\tplaneNum = LittleLong( sides[ sideNum ].planeNum );\n\t\tout->bounds[1][2] = s_worldData.planes[ planeNum ].dist;\n\n\t\t// get information from the shader for fog parameters\n\t\tshader = R_FindShader( fogs->shader, LIGHTMAP_NONE, qtrue );\n\n\t\tout->parms = shader->fogParms;\n\n\t\tout->colorInt = ColorBytes4 ( shader->fogParms.color[0] * tr.identityLight, \n\t\t\t                          shader->fogParms.color[1] * tr.identityLight, \n\t\t\t                          shader->fogParms.color[2] * tr.identityLight, 1.0 );\n\n\t\td = shader->fogParms.depthForOpaque < 1 ? 1 : shader->fogParms.depthForOpaque;\n\t\tout->tcScale = 1.0f / ( d * 8 );\n\n\t\t// set the gradient vector\n\t\tsideNum = LittleLong( fogs->visibleSide );\n\n\t\tif ( sideNum == -1 ) {\n\t\t\tout->hasSurface = qfalse;\n\t\t} else {\n\t\t\tout->hasSurface = qtrue;\n\t\t\tplaneNum = LittleLong( sides[ firstSide + sideNum ].planeNum );\n\t\t\tVectorSubtract( vec3_origin, s_worldData.planes[ planeNum ].normal, out->surface );\n\t\t\tout->surface[3] = -s_worldData.planes[ planeNum ].dist;\n\t\t}\n\n\t\tout++;\n\t}\n\n}\n\n\n/*\n================\nR_LoadLightGrid\n\n================\n*/\nvoid R_LoadLightGrid( lump_t *l ) {\n\tint\t\ti;\n\tvec3_t\tmaxs;\n\tint\t\tnumGridPoints;\n\tworld_t\t*w;\n\tfloat\t*wMins, *wMaxs;\n\n\tw = &s_worldData;\n\n\tw->lightGridInverseSize[0] = 1.0f / w->lightGridSize[0];\n\tw->lightGridInverseSize[1] = 1.0f / w->lightGridSize[1];\n\tw->lightGridInverseSize[2] = 1.0f / w->lightGridSize[2];\n\n\twMins = w->bmodels[0].bounds[0];\n\twMaxs = w->bmodels[0].bounds[1];\n\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tw->lightGridOrigin[i] = w->lightGridSize[i] * ceil( wMins[i] / w->lightGridSize[i] );\n\t\tmaxs[i] = w->lightGridSize[i] * floor( wMaxs[i] / w->lightGridSize[i] );\n\t\tw->lightGridBounds[i] = (maxs[i] - w->lightGridOrigin[i])/w->lightGridSize[i] + 1;\n\t}\n\n\tnumGridPoints = w->lightGridBounds[0] * w->lightGridBounds[1] * w->lightGridBounds[2];\n\n\tif ( l->filelen != numGridPoints * 8 ) {\n\t\tri.Printf( PRINT_WARNING, \"WARNING: light grid mismatch\\n\" );\n\t\tw->lightGridData = NULL;\n\t\treturn;\n\t}\n\n\tw->lightGridData = ri.Hunk_Alloc( l->filelen, h_low );\n\tCom_Memcpy( w->lightGridData, (void *)(fileBase + l->fileofs), l->filelen );\n\n\t// deal with overbright bits\n\tfor ( i = 0 ; i < numGridPoints ; i++ ) {\n\t\tR_ColorShiftLightingBytes( &w->lightGridData[i*8], &w->lightGridData[i*8] );\n\t\tR_ColorShiftLightingBytes( &w->lightGridData[i*8+3], &w->lightGridData[i*8+3] );\n\t}\n}\n\n/*\n================\nR_LoadEntities\n================\n*/\nvoid R_LoadEntities( lump_t *l ) {\n\tchar *p, *token, *s;\n\tchar keyname[MAX_TOKEN_CHARS];\n\tchar value[MAX_TOKEN_CHARS];\n\tworld_t\t*w;\n\n\tw = &s_worldData;\n\tw->lightGridSize[0] = 64;\n\tw->lightGridSize[1] = 64;\n\tw->lightGridSize[2] = 128;\n\n\tp = (char *)(fileBase + l->fileofs);\n\n\t// store for reference by the cgame\n\tw->entityString = ri.Hunk_Alloc( l->filelen + 1, h_low );\n\tstrcpy( w->entityString, p );\n\tw->entityParsePoint = w->entityString;\n\n\ttoken = COM_ParseExt( &p, qtrue );\n\tif (!*token || *token != '{') {\n\t\treturn;\n\t}\n\n\t// only parse the world spawn\n\twhile ( 1 ) {\t\n\t\t// parse key\n\t\ttoken = COM_ParseExt( &p, qtrue );\n\n\t\tif ( !*token || *token == '}' ) {\n\t\t\tbreak;\n\t\t}\n\t\tQ_strncpyz(keyname, token, sizeof(keyname));\n\n\t\t// parse value\n\t\ttoken = COM_ParseExt( &p, qtrue );\n\n\t\tif ( !*token || *token == '}' ) {\n\t\t\tbreak;\n\t\t}\n\t\tQ_strncpyz(value, token, sizeof(value));\n\n\t\t// check for remapping of shaders for vertex lighting\n\t\ts = \"vertexremapshader\";\n\t\tif (!Q_strncmp(keyname, s, strlen(s)) ) {\n\t\t\ts = strchr(value, ';');\n\t\t\tif (!s) {\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: no semi colon in vertexshaderremap '%s'\\n\", value );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t*s++ = 0;\n\t\t\tif (r_vertexLight->integer) {\n\t\t\t\tR_RemapShader(value, s, \"0\");\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\t// check for remapping of shaders\n\t\ts = \"remapshader\";\n\t\tif (!Q_strncmp(keyname, s, strlen(s)) ) {\n\t\t\ts = strchr(value, ';');\n\t\t\tif (!s) {\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: no semi colon in shaderremap '%s'\\n\", value );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t*s++ = 0;\n\t\t\tR_RemapShader(value, s, \"0\");\n\t\t\tcontinue;\n\t\t}\n\t\t// check for a different grid size\n\t\tif (!Q_stricmp(keyname, \"gridsize\")) {\n\t\t\tsscanf(value, \"%f %f %f\", &w->lightGridSize[0], &w->lightGridSize[1], &w->lightGridSize[2] );\n\t\t\tcontinue;\n\t\t}\n\t}\n}\n\n/*\n=================\nR_GetEntityToken\n=================\n*/\nqboolean R_GetEntityToken( char *buffer, int size ) {\n\tconst char\t*s;\n\n\ts = COM_Parse( &s_worldData.entityParsePoint );\n\tQ_strncpyz( buffer, s, size );\n\tif ( !s_worldData.entityParsePoint || !s[0] ) {\n\t\ts_worldData.entityParsePoint = s_worldData.entityString;\n\t\treturn qfalse;\n\t} else {\n\t\treturn qtrue;\n\t}\n}\n\n/*\n=================\nRE_LoadWorldMap\n\nCalled directly from cgame\n=================\n*/\nvoid RE_LoadWorldMap( const char *name ) {\n\tint\t\t\ti;\n\tdheader_t\t*header;\n\tbyte\t\t*buffer;\n\tbyte\t\t*startMarker;\n\n\tif ( tr.worldMapLoaded ) {\n\t\tri.Error( ERR_DROP, \"ERROR: attempted to redundantly load world map\\n\" );\n\t}\n\n\t// set default sun direction to be used if it isn't\n\t// overridden by a shader\n\ttr.sunDirection[0] = 0.45f;\n\ttr.sunDirection[1] = 0.3f;\n\ttr.sunDirection[2] = 0.9f;\n\n\tVectorNormalize( tr.sunDirection );\n\n\ttr.worldMapLoaded = qtrue;\n\n\t// load it\n    ri.FS_ReadFile( name, (void **)&buffer );\n\tif ( !buffer ) {\n\t\tri.Error (ERR_DROP, \"RE_LoadWorldMap: %s not found\", name);\n\t}\n\n\t// clear tr.world so if the level fails to load, the next\n\t// try will not look at the partially loaded version\n\ttr.world = NULL;\n\n\tCom_Memset( &s_worldData, 0, sizeof( s_worldData ) );\n\tQ_strncpyz( s_worldData.name, name, sizeof( s_worldData.name ) );\n\n\tQ_strncpyz( s_worldData.baseName, COM_SkipPath( s_worldData.name ), sizeof( s_worldData.name ) );\n\tCOM_StripExtension( s_worldData.baseName, s_worldData.baseName );\n\n\tstartMarker = ri.Hunk_Alloc(0, h_low);\n\tc_gridVerts = 0;\n\n\theader = (dheader_t *)buffer;\n\tfileBase = (byte *)header;\n\n\ti = LittleLong (header->version);\n\tif ( i != BSP_VERSION ) {\n\t\tri.Error (ERR_DROP, \"RE_LoadWorldMap: %s has wrong version number (%i should be %i)\", \n\t\t\tname, i, BSP_VERSION);\n\t}\n\n\t// swap all the lumps\n\tfor (i=0 ; i<sizeof(dheader_t)/4 ; i++) {\n\t\t((int *)header)[i] = LittleLong ( ((int *)header)[i]);\n\t}\n\n\t// load into heap\n\tR_LoadShaders( &header->lumps[LUMP_SHADERS] );\n\tR_LoadLightmaps( &header->lumps[LUMP_LIGHTMAPS] );\n\tR_LoadPlanes (&header->lumps[LUMP_PLANES]);\n\tR_LoadFogs( &header->lumps[LUMP_FOGS], &header->lumps[LUMP_BRUSHES], &header->lumps[LUMP_BRUSHSIDES] );\n\tR_LoadSurfaces( &header->lumps[LUMP_SURFACES], &header->lumps[LUMP_DRAWVERTS], &header->lumps[LUMP_DRAWINDEXES] );\n\tR_LoadMarksurfaces (&header->lumps[LUMP_LEAFSURFACES]);\n\tR_LoadNodesAndLeafs (&header->lumps[LUMP_NODES], &header->lumps[LUMP_LEAFS]);\n\tR_LoadSubmodels (&header->lumps[LUMP_MODELS]);\n\tR_LoadVisibility( &header->lumps[LUMP_VISIBILITY] );\n\tR_LoadEntities( &header->lumps[LUMP_ENTITIES] );\n\tR_LoadLightGrid( &header->lumps[LUMP_LIGHTGRID] );\n\n\ts_worldData.dataSize = (byte *)ri.Hunk_Alloc(0, h_low) - startMarker;\n\n\t// only set tr.world now that we know the entire level has loaded properly\n\ttr.world = &s_worldData;\n\n    ri.FS_FreeFile( buffer );\n}\n\n"
  },
  {
    "path": "code/renderer/tr_cmds.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"tr_local.h\"\n\nvolatile renderCommandList_t\t*renderCommandList;\n\nvolatile qboolean\trenderThreadActive;\n\n\n/*\n=====================\nR_PerformanceCounters\n=====================\n*/\nvoid R_PerformanceCounters( void ) {\n\tif ( !r_speeds->integer ) {\n\t\t// clear the counters even if we aren't printing\n\t\tCom_Memset( &tr.pc, 0, sizeof( tr.pc ) );\n\t\tCom_Memset( &backEnd.pc, 0, sizeof( backEnd.pc ) );\n\t\treturn;\n\t}\n\n\tif (r_speeds->integer == 1) {\n\t\tri.Printf (PRINT_ALL, \"%i/%i shaders/surfs %i leafs %i verts %i/%i tris %.2f mtex %.2f dc\\n\",\n\t\t\tbackEnd.pc.c_shaders, backEnd.pc.c_surfaces, tr.pc.c_leafs, backEnd.pc.c_vertexes, \n\t\t\tbackEnd.pc.c_indexes/3, backEnd.pc.c_totalIndexes/3, \n\t\t\tR_SumOfUsedImages()/(1000000.0f), backEnd.pc.c_overDraw / (float)(glConfig.vidWidth * glConfig.vidHeight) ); \n\t} else if (r_speeds->integer == 2) {\n\t\tri.Printf (PRINT_ALL, \"(patch) %i sin %i sclip  %i sout %i bin %i bclip %i bout\\n\",\n\t\t\ttr.pc.c_sphere_cull_patch_in, tr.pc.c_sphere_cull_patch_clip, tr.pc.c_sphere_cull_patch_out, \n\t\t\ttr.pc.c_box_cull_patch_in, tr.pc.c_box_cull_patch_clip, tr.pc.c_box_cull_patch_out );\n\t\tri.Printf (PRINT_ALL, \"(md3) %i sin %i sclip  %i sout %i bin %i bclip %i bout\\n\",\n\t\t\ttr.pc.c_sphere_cull_md3_in, tr.pc.c_sphere_cull_md3_clip, tr.pc.c_sphere_cull_md3_out, \n\t\t\ttr.pc.c_box_cull_md3_in, tr.pc.c_box_cull_md3_clip, tr.pc.c_box_cull_md3_out );\n\t} else if (r_speeds->integer == 3) {\n\t\tri.Printf (PRINT_ALL, \"viewcluster: %i\\n\", tr.viewCluster );\n\t} else if (r_speeds->integer == 4) {\n\t\tif ( backEnd.pc.c_dlightVertexes ) {\n\t\t\tri.Printf (PRINT_ALL, \"dlight srf:%i  culled:%i  verts:%i  tris:%i\\n\", \n\t\t\t\ttr.pc.c_dlightSurfaces, tr.pc.c_dlightSurfacesCulled,\n\t\t\t\tbackEnd.pc.c_dlightVertexes, backEnd.pc.c_dlightIndexes / 3 );\n\t\t}\n\t} \n\telse if (r_speeds->integer == 5 )\n\t{\n\t\tri.Printf( PRINT_ALL, \"zFar: %.0f\\n\", tr.viewParms.zFar );\n\t}\n\telse if (r_speeds->integer == 6 )\n\t{\n\t\tri.Printf( PRINT_ALL, \"flare adds:%i tests:%i renders:%i\\n\", \n\t\t\tbackEnd.pc.c_flareAdds, backEnd.pc.c_flareTests, backEnd.pc.c_flareRenders );\n\t}\n\n\tCom_Memset( &tr.pc, 0, sizeof( tr.pc ) );\n\tCom_Memset( &backEnd.pc, 0, sizeof( backEnd.pc ) );\n}\n\n\n/*\n====================\nR_InitCommandBuffers\n====================\n*/\nvoid R_InitCommandBuffers( void ) {\n\tglConfig.smpActive = qfalse;\n\tif ( r_smp->integer ) {\n\t\tri.Printf( PRINT_ALL, \"Trying SMP acceleration...\\n\" );\n\t\tif ( GLimp_SpawnRenderThread( RB_RenderThread ) ) {\n\t\t\tri.Printf( PRINT_ALL, \"...succeeded.\\n\" );\n\t\t\tglConfig.smpActive = qtrue;\n\t\t} else {\n\t\t\tri.Printf( PRINT_ALL, \"...failed.\\n\" );\n\t\t}\n\t}\n}\n\n/*\n====================\nR_ShutdownCommandBuffers\n====================\n*/\nvoid R_ShutdownCommandBuffers( void ) {\n\t// kill the rendering thread\n\tif ( glConfig.smpActive ) {\n\t\tGLimp_WakeRenderer( NULL );\n\t\tglConfig.smpActive = qfalse;\n\t}\n}\n\n/*\n====================\nR_IssueRenderCommands\n====================\n*/\nint\tc_blockedOnRender;\nint\tc_blockedOnMain;\n\nvoid R_IssueRenderCommands( qboolean runPerformanceCounters ) {\n\trenderCommandList_t\t*cmdList;\n\n\tcmdList = &backEndData[tr.smpFrame]->commands;\n\tassert(cmdList); // bk001205\n\t// add an end-of-list command\n\t*(int *)(cmdList->cmds + cmdList->used) = RC_END_OF_LIST;\n\n\t// clear it out, in case this is a sync and not a buffer flip\n\tcmdList->used = 0;\n\n\tif ( glConfig.smpActive ) {\n\t\t// if the render thread is not idle, wait for it\n\t\tif ( renderThreadActive ) {\n\t\t\tc_blockedOnRender++;\n\t\t\tif ( r_showSmp->integer ) {\n\t\t\t\tri.Printf( PRINT_ALL, \"R\" );\n\t\t\t}\n\t\t} else {\n\t\t\tc_blockedOnMain++;\n\t\t\tif ( r_showSmp->integer ) {\n\t\t\t\tri.Printf( PRINT_ALL, \".\" );\n\t\t\t}\n\t\t}\n\n\t\t// sleep until the renderer has completed\n\t\tGLimp_FrontEndSleep();\n\t}\n\n\t// at this point, the back end thread is idle, so it is ok\n\t// to look at it's performance counters\n\tif ( runPerformanceCounters ) {\n\t\tR_PerformanceCounters();\n\t}\n\n\t// actually start the commands going\n\tif ( !r_skipBackEnd->integer ) {\n\t\t// let it start on the new batch\n\t\tif ( !glConfig.smpActive ) {\n\t\t\tRB_ExecuteRenderCommands( cmdList->cmds );\n\t\t} else {\n\t\t\tGLimp_WakeRenderer( cmdList );\n\t\t}\n\t}\n}\n\n\n/*\n====================\nR_SyncRenderThread\n\nIssue any pending commands and wait for them to complete.\nAfter exiting, the render thread will have completed its work\nand will remain idle and the main thread is free to issue\nOpenGL calls until R_IssueRenderCommands is called.\n====================\n*/\nvoid R_SyncRenderThread( void ) {\n\tif ( !tr.registered ) {\n\t\treturn;\n\t}\n\tR_IssueRenderCommands( qfalse );\n\n\tif ( !glConfig.smpActive ) {\n\t\treturn;\n\t}\n\tGLimp_FrontEndSleep();\n}\n\n/*\n============\nR_GetCommandBuffer\n\nmake sure there is enough command space, waiting on the\nrender thread if needed.\n============\n*/\nvoid *R_GetCommandBuffer( int bytes ) {\n\trenderCommandList_t\t*cmdList;\n\n\tcmdList = &backEndData[tr.smpFrame]->commands;\n\n\t// always leave room for the end of list command\n\tif ( cmdList->used + bytes + 4 > MAX_RENDER_COMMANDS ) {\n\t\tif ( bytes > MAX_RENDER_COMMANDS - 4 ) {\n\t\t\tri.Error( ERR_FATAL, \"R_GetCommandBuffer: bad size %i\", bytes );\n\t\t}\n\t\t// if we run out of room, just start dropping commands\n\t\treturn NULL;\n\t}\n\n\tcmdList->used += bytes;\n\n\treturn cmdList->cmds + cmdList->used - bytes;\n}\n\n\n/*\n=============\nR_AddDrawSurfCmd\n\n=============\n*/\nvoid\tR_AddDrawSurfCmd( drawSurf_t *drawSurfs, int numDrawSurfs ) {\n\tdrawSurfsCommand_t\t*cmd;\n\n\tcmd = R_GetCommandBuffer( sizeof( *cmd ) );\n\tif ( !cmd ) {\n\t\treturn;\n\t}\n\tcmd->commandId = RC_DRAW_SURFS;\n\n\tcmd->drawSurfs = drawSurfs;\n\tcmd->numDrawSurfs = numDrawSurfs;\n\n\tcmd->refdef = tr.refdef;\n\tcmd->viewParms = tr.viewParms;\n}\n\n\n/*\n=============\nRE_SetColor\n\nPassing NULL will set the color to white\n=============\n*/\nvoid\tRE_SetColor( const float *rgba ) {\n\tsetColorCommand_t\t*cmd;\n\n  if ( !tr.registered ) {\n    return;\n  }\n\tcmd = R_GetCommandBuffer( sizeof( *cmd ) );\n\tif ( !cmd ) {\n\t\treturn;\n\t}\n\tcmd->commandId = RC_SET_COLOR;\n\tif ( !rgba ) {\n\t\tstatic float colorWhite[4] = { 1, 1, 1, 1 };\n\n\t\trgba = colorWhite;\n\t}\n\n\tcmd->color[0] = rgba[0];\n\tcmd->color[1] = rgba[1];\n\tcmd->color[2] = rgba[2];\n\tcmd->color[3] = rgba[3];\n}\n\n\n/*\n=============\nRE_StretchPic\n=============\n*/\nvoid RE_StretchPic ( float x, float y, float w, float h, \n\t\t\t\t\t  float s1, float t1, float s2, float t2, qhandle_t hShader ) {\n\tstretchPicCommand_t\t*cmd;\n\n  if (!tr.registered) {\n    return;\n  }\n\tcmd = R_GetCommandBuffer( sizeof( *cmd ) );\n\tif ( !cmd ) {\n\t\treturn;\n\t}\n\tcmd->commandId = RC_STRETCH_PIC;\n\tcmd->shader = R_GetShaderByHandle( hShader );\n\tcmd->x = x;\n\tcmd->y = y;\n\tcmd->w = w;\n\tcmd->h = h;\n\tcmd->s1 = s1;\n\tcmd->t1 = t1;\n\tcmd->s2 = s2;\n\tcmd->t2 = t2;\n}\n\n\n/*\n====================\nRE_BeginFrame\n\nIf running in stereo, RE_BeginFrame will be called twice\nfor each RE_EndFrame\n====================\n*/\nvoid RE_BeginFrame( stereoFrame_t stereoFrame ) {\n\tdrawBufferCommand_t\t*cmd;\n\n\tif ( !tr.registered ) {\n\t\treturn;\n\t}\n\tglState.finishCalled = qfalse;\n\n\ttr.frameCount++;\n\ttr.frameSceneNum = 0;\n\n\t//\n\t// do overdraw measurement\n\t//\n\tif ( r_measureOverdraw->integer )\n\t{\n\t\tif ( glConfig.stencilBits < 4 )\n\t\t{\n\t\t\tri.Printf( PRINT_ALL, \"Warning: not enough stencil bits to measure overdraw: %d\\n\", glConfig.stencilBits );\n\t\t\tri.Cvar_Set( \"r_measureOverdraw\", \"0\" );\n\t\t\tr_measureOverdraw->modified = qfalse;\n\t\t}\n\t\telse if ( r_shadows->integer == 2 )\n\t\t{\n\t\t\tri.Printf( PRINT_ALL, \"Warning: stencil shadows and overdraw measurement are mutually exclusive\\n\" );\n\t\t\tri.Cvar_Set( \"r_measureOverdraw\", \"0\" );\n\t\t\tr_measureOverdraw->modified = qfalse;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tR_SyncRenderThread();\n\t\t\tqglEnable( GL_STENCIL_TEST );\n\t\t\tqglStencilMask( ~0U );\n\t\t\tqglClearStencil( 0U );\n\t\t\tqglStencilFunc( GL_ALWAYS, 0U, ~0U );\n\t\t\tqglStencilOp( GL_KEEP, GL_INCR, GL_INCR );\n\t\t}\n\t\tr_measureOverdraw->modified = qfalse;\n\t}\n\telse\n\t{\n\t\t// this is only reached if it was on and is now off\n\t\tif ( r_measureOverdraw->modified ) {\n\t\t\tR_SyncRenderThread();\n\t\t\tqglDisable( GL_STENCIL_TEST );\n\t\t}\n\t\tr_measureOverdraw->modified = qfalse;\n\t}\n\n\t//\n\t// texturemode stuff\n\t//\n\tif ( r_textureMode->modified ) {\n\t\tR_SyncRenderThread();\n\t\tGL_TextureMode( r_textureMode->string );\n\t\tr_textureMode->modified = qfalse;\n\t}\n\n\t//\n\t// gamma stuff\n\t//\n\tif ( r_gamma->modified ) {\n\t\tr_gamma->modified = qfalse;\n\n\t\tR_SyncRenderThread();\n\t\tR_SetColorMappings();\n\t}\n\n    // check for errors\n    if ( !r_ignoreGLErrors->integer ) {\n        int\terr;\n\n\t\tR_SyncRenderThread();\n        if ( ( err = qglGetError() ) != GL_NO_ERROR ) {\n            ri.Error( ERR_FATAL, \"RE_BeginFrame() - glGetError() failed (0x%x)!\\n\", err );\n        }\n    }\n\n\t//\n\t// draw buffer stuff\n\t//\n\tcmd = R_GetCommandBuffer( sizeof( *cmd ) );\n\tif ( !cmd ) {\n\t\treturn;\n\t}\n\tcmd->commandId = RC_DRAW_BUFFER;\n\n\tif ( glConfig.stereoEnabled ) {\n\t\tif ( stereoFrame == STEREO_LEFT ) {\n\t\t\tcmd->buffer = (int)GL_BACK_LEFT;\n\t\t} else if ( stereoFrame == STEREO_RIGHT ) {\n\t\t\tcmd->buffer = (int)GL_BACK_RIGHT;\n\t\t} else {\n\t\t\tri.Error( ERR_FATAL, \"RE_BeginFrame: Stereo is enabled, but stereoFrame was %i\", stereoFrame );\n\t\t}\n\t} else {\n\t\tif ( stereoFrame != STEREO_CENTER ) {\n\t\t\tri.Error( ERR_FATAL, \"RE_BeginFrame: Stereo is disabled, but stereoFrame was %i\", stereoFrame );\n\t\t}\n\t\tif ( !Q_stricmp( r_drawBuffer->string, \"GL_FRONT\" ) ) {\n\t\t\tcmd->buffer = (int)GL_FRONT;\n\t\t} else {\n\t\t\tcmd->buffer = (int)GL_BACK;\n\t\t}\n\t}\n}\n\n\n/*\n=============\nRE_EndFrame\n\nReturns the number of msec spent in the back end\n=============\n*/\nvoid RE_EndFrame( int *frontEndMsec, int *backEndMsec ) {\n\tswapBuffersCommand_t\t*cmd;\n\n\tif ( !tr.registered ) {\n\t\treturn;\n\t}\n\tcmd = R_GetCommandBuffer( sizeof( *cmd ) );\n\tif ( !cmd ) {\n\t\treturn;\n\t}\n\tcmd->commandId = RC_SWAP_BUFFERS;\n\n\tR_IssueRenderCommands( qtrue );\n\n\t// use the other buffers next frame, because another CPU\n\t// may still be rendering into the current ones\n\tR_ToggleSmpFrame();\n\n\tif ( frontEndMsec ) {\n\t\t*frontEndMsec = tr.frontEndMsec;\n\t}\n\ttr.frontEndMsec = 0;\n\tif ( backEndMsec ) {\n\t\t*backEndMsec = backEnd.pc.msec;\n\t}\n\tbackEnd.pc.msec = 0;\n}\n\n"
  },
  {
    "path": "code/renderer/tr_curve.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"tr_local.h\"\n\n/*\n\nThis file does all of the processing necessary to turn a raw grid of points\nread from the map file into a srfGridMesh_t ready for rendering.\n\nThe level of detail solution is direction independent, based only on subdivided\ndistance from the true curve.\n\nOnly a single entry point:\n\nsrfGridMesh_t *R_SubdividePatchToGrid( int width, int height,\n\t\t\t\t\t\t\t\tdrawVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] ) {\n\n*/\n\n\n/*\n============\nLerpDrawVert\n============\n*/\nstatic void LerpDrawVert( drawVert_t *a, drawVert_t *b, drawVert_t *out ) {\n\tout->xyz[0] = 0.5f * (a->xyz[0] + b->xyz[0]);\n\tout->xyz[1] = 0.5f * (a->xyz[1] + b->xyz[1]);\n\tout->xyz[2] = 0.5f * (a->xyz[2] + b->xyz[2]);\n\n\tout->st[0] = 0.5f * (a->st[0] + b->st[0]);\n\tout->st[1] = 0.5f * (a->st[1] + b->st[1]);\n\n\tout->lightmap[0] = 0.5f * (a->lightmap[0] + b->lightmap[0]);\n\tout->lightmap[1] = 0.5f * (a->lightmap[1] + b->lightmap[1]);\n\n\tout->color[0] = (a->color[0] + b->color[0]) >> 1;\n\tout->color[1] = (a->color[1] + b->color[1]) >> 1;\n\tout->color[2] = (a->color[2] + b->color[2]) >> 1;\n\tout->color[3] = (a->color[3] + b->color[3]) >> 1;\n}\n\n/*\n============\nTranspose\n============\n*/\nstatic void Transpose( int width, int height, drawVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE] ) {\n\tint\t\ti, j;\n\tdrawVert_t\ttemp;\n\n\tif ( width > height ) {\n\t\tfor ( i = 0 ; i < height ; i++ ) {\n\t\t\tfor ( j = i + 1 ; j < width ; j++ ) {\n\t\t\t\tif ( j < height ) {\n\t\t\t\t\t// swap the value\n\t\t\t\t\ttemp = ctrl[j][i];\n\t\t\t\t\tctrl[j][i] = ctrl[i][j];\n\t\t\t\t\tctrl[i][j] = temp;\n\t\t\t\t} else {\n\t\t\t\t\t// just copy\n\t\t\t\t\tctrl[j][i] = ctrl[i][j];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor ( i = 0 ; i < width ; i++ ) {\n\t\t\tfor ( j = i + 1 ; j < height ; j++ ) {\n\t\t\t\tif ( j < width ) {\n\t\t\t\t\t// swap the value\n\t\t\t\t\ttemp = ctrl[i][j];\n\t\t\t\t\tctrl[i][j] = ctrl[j][i];\n\t\t\t\t\tctrl[j][i] = temp;\n\t\t\t\t} else {\n\t\t\t\t\t// just copy\n\t\t\t\t\tctrl[i][j] = ctrl[j][i];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n}\n\n\n/*\n=================\nMakeMeshNormals\n\nHandles all the complicated wrapping and degenerate cases\n=================\n*/\nstatic void MakeMeshNormals( int width, int height, drawVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE] ) {\n\tint\t\ti, j, k, dist;\n\tvec3_t\tnormal;\n\tvec3_t\tsum;\n\tint\t\tcount;\n\tvec3_t\tbase;\n\tvec3_t\tdelta;\n\tint\t\tx, y;\n\tdrawVert_t\t*dv;\n\tvec3_t\t\taround[8], temp;\n\tqboolean\tgood[8];\n\tqboolean\twrapWidth, wrapHeight;\n\tfloat\t\tlen;\nstatic\tint\tneighbors[8][2] = {\n\t{0,1}, {1,1}, {1,0}, {1,-1}, {0,-1}, {-1,-1}, {-1,0}, {-1,1}\n\t};\n\n\twrapWidth = qfalse;\n\tfor ( i = 0 ; i < height ; i++ ) {\n\t\tVectorSubtract( ctrl[i][0].xyz, ctrl[i][width-1].xyz, delta );\n\t\tlen = VectorLengthSquared( delta );\n\t\tif ( len > 1.0 ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif ( i == height ) {\n\t\twrapWidth = qtrue;\n\t}\n\n\twrapHeight = qfalse;\n\tfor ( i = 0 ; i < width ; i++ ) {\n\t\tVectorSubtract( ctrl[0][i].xyz, ctrl[height-1][i].xyz, delta );\n\t\tlen = VectorLengthSquared( delta );\n\t\tif ( len > 1.0 ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif ( i == width) {\n\t\twrapHeight = qtrue;\n\t}\n\n\n\tfor ( i = 0 ; i < width ; i++ ) {\n\t\tfor ( j = 0 ; j < height ; j++ ) {\n\t\t\tcount = 0;\n\t\t\tdv = &ctrl[j][i];\n\t\t\tVectorCopy( dv->xyz, base );\n\t\t\tfor ( k = 0 ; k < 8 ; k++ ) {\n\t\t\t\tVectorClear( around[k] );\n\t\t\t\tgood[k] = qfalse;\n\n\t\t\t\tfor ( dist = 1 ; dist <= 3 ; dist++ ) {\n\t\t\t\t\tx = i + neighbors[k][0] * dist;\n\t\t\t\t\ty = j + neighbors[k][1] * dist;\n\t\t\t\t\tif ( wrapWidth ) {\n\t\t\t\t\t\tif ( x < 0 ) {\n\t\t\t\t\t\t\tx = width - 1 + x;\n\t\t\t\t\t\t} else if ( x >= width ) {\n\t\t\t\t\t\t\tx = 1 + x - width;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif ( wrapHeight ) {\n\t\t\t\t\t\tif ( y < 0 ) {\n\t\t\t\t\t\t\ty = height - 1 + y;\n\t\t\t\t\t\t} else if ( y >= height ) {\n\t\t\t\t\t\t\ty = 1 + y - height;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( x < 0 || x >= width || y < 0 || y >= height ) {\n\t\t\t\t\t\tbreak;\t\t\t\t\t// edge of patch\n\t\t\t\t\t}\n\t\t\t\t\tVectorSubtract( ctrl[y][x].xyz, base, temp );\n\t\t\t\t\tif ( VectorNormalize2( temp, temp ) == 0 ) {\n\t\t\t\t\t\tcontinue;\t\t\t\t// degenerate edge, get more dist\n\t\t\t\t\t} else {\n\t\t\t\t\t\tgood[k] = qtrue;\n\t\t\t\t\t\tVectorCopy( temp, around[k] );\n\t\t\t\t\t\tbreak;\t\t\t\t\t// good edge\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tVectorClear( sum );\n\t\t\tfor ( k = 0 ; k < 8 ; k++ ) {\n\t\t\t\tif ( !good[k] || !good[(k+1)&7] ) {\n\t\t\t\t\tcontinue;\t// didn't get two points\n\t\t\t\t}\n\t\t\t\tCrossProduct( around[(k+1)&7], around[k], normal );\n\t\t\t\tif ( VectorNormalize2( normal, normal ) == 0 ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tVectorAdd( normal, sum, sum );\n\t\t\t\tcount++;\n\t\t\t}\n\t\t\tif ( count == 0 ) {\n//printf(\"bad normal\\n\");\n\t\t\t\tcount = 1;\n\t\t\t}\n\t\t\tVectorNormalize2( sum, dv->normal );\n\t\t}\n\t}\n}\n\n\n/*\n============\nInvertCtrl\n============\n*/\nstatic void InvertCtrl( int width, int height, drawVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE] ) {\n\tint\t\ti, j;\n\tdrawVert_t\ttemp;\n\n\tfor ( i = 0 ; i < height ; i++ ) {\n\t\tfor ( j = 0 ; j < width/2 ; j++ ) {\n\t\t\ttemp = ctrl[i][j];\n\t\t\tctrl[i][j] = ctrl[i][width-1-j];\n\t\t\tctrl[i][width-1-j] = temp;\n\t\t}\n\t}\n}\n\n\n/*\n=================\nInvertErrorTable\n=================\n*/\nstatic void InvertErrorTable( float errorTable[2][MAX_GRID_SIZE], int width, int height ) {\n\tint\t\ti;\n\tfloat\tcopy[2][MAX_GRID_SIZE];\n\n\tCom_Memcpy( copy, errorTable, sizeof( copy ) );\n\n\tfor ( i = 0 ; i < width ; i++ ) {\n\t\terrorTable[1][i] = copy[0][i];\t//[width-1-i];\n\t}\n\n\tfor ( i = 0 ; i < height ; i++ ) {\n\t\terrorTable[0][i] = copy[1][height-1-i];\n\t}\n\n}\n\n/*\n==================\nPutPointsOnCurve\n==================\n*/\nstatic void PutPointsOnCurve( drawVert_t\tctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], \n\t\t\t\t\t\t\t int width, int height ) {\n\tint\t\t\ti, j;\n\tdrawVert_t\tprev, next;\n\n\tfor ( i = 0 ; i < width ; i++ ) {\n\t\tfor ( j = 1 ; j < height ; j += 2 ) {\n\t\t\tLerpDrawVert( &ctrl[j][i], &ctrl[j+1][i], &prev );\n\t\t\tLerpDrawVert( &ctrl[j][i], &ctrl[j-1][i], &next );\n\t\t\tLerpDrawVert( &prev, &next, &ctrl[j][i] );\n\t\t}\n\t}\n\n\n\tfor ( j = 0 ; j < height ; j++ ) {\n\t\tfor ( i = 1 ; i < width ; i += 2 ) {\n\t\t\tLerpDrawVert( &ctrl[j][i], &ctrl[j][i+1], &prev );\n\t\t\tLerpDrawVert( &ctrl[j][i], &ctrl[j][i-1], &next );\n\t\t\tLerpDrawVert( &prev, &next, &ctrl[j][i] );\n\t\t}\n\t}\n}\n\n/*\n=================\nR_CreateSurfaceGridMesh\n=================\n*/\nsrfGridMesh_t *R_CreateSurfaceGridMesh(int width, int height,\n\t\t\t\t\t\t\t\tdrawVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], float errorTable[2][MAX_GRID_SIZE] ) {\n\tint i, j, size;\n\tdrawVert_t\t*vert;\n\tvec3_t\t\ttmpVec;\n\tsrfGridMesh_t *grid;\n\n\t// copy the results out to a grid\n\tsize = (width * height - 1) * sizeof( drawVert_t ) + sizeof( *grid );\n\n#ifdef PATCH_STITCHING\n\tgrid = /*ri.Hunk_Alloc*/ ri.Malloc( size );\n\tCom_Memset(grid, 0, size);\n\n\tgrid->widthLodError = /*ri.Hunk_Alloc*/ ri.Malloc( width * 4 );\n\tCom_Memcpy( grid->widthLodError, errorTable[0], width * 4 );\n\n\tgrid->heightLodError = /*ri.Hunk_Alloc*/ ri.Malloc( height * 4 );\n\tCom_Memcpy( grid->heightLodError, errorTable[1], height * 4 );\n#else\n\tgrid = ri.Hunk_Alloc( size );\n\tCom_Memset(grid, 0, size);\n\n\tgrid->widthLodError = ri.Hunk_Alloc( width * 4 );\n\tCom_Memcpy( grid->widthLodError, errorTable[0], width * 4 );\n\n\tgrid->heightLodError = ri.Hunk_Alloc( height * 4 );\n\tCom_Memcpy( grid->heightLodError, errorTable[1], height * 4 );\n#endif\n\n\tgrid->width = width;\n\tgrid->height = height;\n\tgrid->surfaceType = SF_GRID;\n\tClearBounds( grid->meshBounds[0], grid->meshBounds[1] );\n\tfor ( i = 0 ; i < width ; i++ ) {\n\t\tfor ( j = 0 ; j < height ; j++ ) {\n\t\t\tvert = &grid->verts[j*width+i];\n\t\t\t*vert = ctrl[j][i];\n\t\t\tAddPointToBounds( vert->xyz, grid->meshBounds[0], grid->meshBounds[1] );\n\t\t}\n\t}\n\n\t// compute local origin and bounds\n\tVectorAdd( grid->meshBounds[0], grid->meshBounds[1], grid->localOrigin );\n\tVectorScale( grid->localOrigin, 0.5f, grid->localOrigin );\n\tVectorSubtract( grid->meshBounds[0], grid->localOrigin, tmpVec );\n\tgrid->meshRadius = VectorLength( tmpVec );\n\n\tVectorCopy( grid->localOrigin, grid->lodOrigin );\n\tgrid->lodRadius = grid->meshRadius;\n\t//\n\treturn grid;\n}\n\n/*\n=================\nR_FreeSurfaceGridMesh\n=================\n*/\nvoid R_FreeSurfaceGridMesh( srfGridMesh_t *grid ) {\n\tri.Free(grid->widthLodError);\n\tri.Free(grid->heightLodError);\n\tri.Free(grid);\n}\n\n/*\n=================\nR_SubdividePatchToGrid\n=================\n*/\nsrfGridMesh_t *R_SubdividePatchToGrid( int width, int height,\n\t\t\t\t\t\t\t\tdrawVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] ) {\n\tint\t\t\ti, j, k, l;\n\tdrawVert_t\tprev, next, mid;\n\tfloat\t\tlen, maxLen;\n\tint\t\t\tdir;\n\tint\t\t\tt;\n\tMAC_STATIC drawVert_t\tctrl[MAX_GRID_SIZE][MAX_GRID_SIZE];\n\tfloat\t\terrorTable[2][MAX_GRID_SIZE];\n\n\tfor ( i = 0 ; i < width ; i++ ) {\n\t\tfor ( j = 0 ; j < height ; j++ ) {\n\t\t\tctrl[j][i] = points[j*width+i];\n\t\t}\n\t}\n\n\tfor ( dir = 0 ; dir < 2 ; dir++ ) {\n\n\t\tfor ( j = 0 ; j < MAX_GRID_SIZE ; j++ ) {\n\t\t\terrorTable[dir][j] = 0;\n\t\t}\n\n\t\t// horizontal subdivisions\n\t\tfor ( j = 0 ; j + 2 < width ; j += 2 ) {\n\t\t\t// check subdivided midpoints against control points\n\n\t\t\t// FIXME: also check midpoints of adjacent patches against the control points\n\t\t\t// this would basically stitch all patches in the same LOD group together.\n\n\t\t\tmaxLen = 0;\n\t\t\tfor ( i = 0 ; i < height ; i++ ) {\n\t\t\t\tvec3_t\t\tmidxyz;\n\t\t\t\tvec3_t\t\tmidxyz2;\n\t\t\t\tvec3_t\t\tdir;\n\t\t\t\tvec3_t\t\tprojected;\n\t\t\t\tfloat\t\td;\n\n\t\t\t\t// calculate the point on the curve\n\t\t\t\tfor ( l = 0 ; l < 3 ; l++ ) {\n\t\t\t\t\tmidxyz[l] = (ctrl[i][j].xyz[l] + ctrl[i][j+1].xyz[l] * 2\n\t\t\t\t\t\t\t+ ctrl[i][j+2].xyz[l] ) * 0.25f;\n\t\t\t\t}\n\n\t\t\t\t// see how far off the line it is\n\t\t\t\t// using dist-from-line will not account for internal\n\t\t\t\t// texture warping, but it gives a lot less polygons than\n\t\t\t\t// dist-from-midpoint\n\t\t\t\tVectorSubtract( midxyz, ctrl[i][j].xyz, midxyz );\n\t\t\t\tVectorSubtract( ctrl[i][j+2].xyz, ctrl[i][j].xyz, dir );\n\t\t\t\tVectorNormalize( dir );\n\n\t\t\t\td = DotProduct( midxyz, dir );\n\t\t\t\tVectorScale( dir, d, projected );\n\t\t\t\tVectorSubtract( midxyz, projected, midxyz2);\n\t\t\t\tlen = VectorLengthSquared( midxyz2 );\t\t\t// we will do the sqrt later\n\t\t\t\tif ( len > maxLen ) {\n\t\t\t\t\tmaxLen = len;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tmaxLen = sqrt(maxLen);\n\n\t\t\t// if all the points are on the lines, remove the entire columns\n\t\t\tif ( maxLen < 0.1f ) {\n\t\t\t\terrorTable[dir][j+1] = 999;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// see if we want to insert subdivided columns\n\t\t\tif ( width + 2 > MAX_GRID_SIZE ) {\n\t\t\t\terrorTable[dir][j+1] = 1.0f/maxLen;\n\t\t\t\tcontinue;\t// can't subdivide any more\n\t\t\t}\n\n\t\t\tif ( maxLen <= r_subdivisions->value ) {\n\t\t\t\terrorTable[dir][j+1] = 1.0f/maxLen;\n\t\t\t\tcontinue;\t// didn't need subdivision\n\t\t\t}\n\n\t\t\terrorTable[dir][j+2] = 1.0f/maxLen;\n\n\t\t\t// insert two columns and replace the peak\n\t\t\twidth += 2;\n\t\t\tfor ( i = 0 ; i < height ; i++ ) {\n\t\t\t\tLerpDrawVert( &ctrl[i][j], &ctrl[i][j+1], &prev );\n\t\t\t\tLerpDrawVert( &ctrl[i][j+1], &ctrl[i][j+2], &next );\n\t\t\t\tLerpDrawVert( &prev, &next, &mid );\n\n\t\t\t\tfor ( k = width - 1 ; k > j + 3 ; k-- ) {\n\t\t\t\t\tctrl[i][k] = ctrl[i][k-2];\n\t\t\t\t}\n\t\t\t\tctrl[i][j + 1] = prev;\n\t\t\t\tctrl[i][j + 2] = mid;\n\t\t\t\tctrl[i][j + 3] = next;\n\t\t\t}\n\n\t\t\t// back up and recheck this set again, it may need more subdivision\n\t\t\tj -= 2;\n\n\t\t}\n\n\t\tTranspose( width, height, ctrl );\n\t\tt = width;\n\t\twidth = height;\n\t\theight = t;\n\t}\n\n\n\t// put all the aproximating points on the curve\n\tPutPointsOnCurve( ctrl, width, height );\n\n\t// cull out any rows or columns that are colinear\n\tfor ( i = 1 ; i < width-1 ; i++ ) {\n\t\tif ( errorTable[0][i] != 999 ) {\n\t\t\tcontinue;\n\t\t}\n\t\tfor ( j = i+1 ; j < width ; j++ ) {\n\t\t\tfor ( k = 0 ; k < height ; k++ ) {\n\t\t\t\tctrl[k][j-1] = ctrl[k][j];\n\t\t\t}\n\t\t\terrorTable[0][j-1] = errorTable[0][j];\n\t\t}\n\t\twidth--;\n\t}\n\n\tfor ( i = 1 ; i < height-1 ; i++ ) {\n\t\tif ( errorTable[1][i] != 999 ) {\n\t\t\tcontinue;\n\t\t}\n\t\tfor ( j = i+1 ; j < height ; j++ ) {\n\t\t\tfor ( k = 0 ; k < width ; k++ ) {\n\t\t\t\tctrl[j-1][k] = ctrl[j][k];\n\t\t\t}\n\t\t\terrorTable[1][j-1] = errorTable[1][j];\n\t\t}\n\t\theight--;\n\t}\n\n#if 1\n\t// flip for longest tristrips as an optimization\n\t// the results should be visually identical with or\n\t// without this step\n\tif ( height > width ) {\n\t\tTranspose( width, height, ctrl );\n\t\tInvertErrorTable( errorTable, width, height );\n\t\tt = width;\n\t\twidth = height;\n\t\theight = t;\n\t\tInvertCtrl( width, height, ctrl );\n\t}\n#endif\n\n\t// calculate normals\n\tMakeMeshNormals( width, height, ctrl );\n\n\treturn R_CreateSurfaceGridMesh( width, height, ctrl, errorTable );\n}\n\n/*\n===============\nR_GridInsertColumn\n===============\n*/\nsrfGridMesh_t *R_GridInsertColumn( srfGridMesh_t *grid, int column, int row, vec3_t point, float loderror ) {\n\tint i, j;\n\tint width, height, oldwidth;\n\tMAC_STATIC drawVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE];\n\tfloat errorTable[2][MAX_GRID_SIZE];\n\tfloat lodRadius;\n\tvec3_t lodOrigin;\n\n\toldwidth = 0;\n\twidth = grid->width + 1;\n\tif (width > MAX_GRID_SIZE)\n\t\treturn NULL;\n\theight = grid->height;\n\tfor (i = 0; i < width; i++) {\n\t\tif (i == column) {\n\t\t\t//insert new column\n\t\t\tfor (j = 0; j < grid->height; j++) {\n\t\t\t\tLerpDrawVert( &grid->verts[j * grid->width + i-1], &grid->verts[j * grid->width + i], &ctrl[j][i] );\n\t\t\t\tif (j == row)\n\t\t\t\t\tVectorCopy(point, ctrl[j][i].xyz);\n\t\t\t}\n\t\t\terrorTable[0][i] = loderror;\n\t\t\tcontinue;\n\t\t}\n\t\terrorTable[0][i] = grid->widthLodError[oldwidth];\n\t\tfor (j = 0; j < grid->height; j++) {\n\t\t\tctrl[j][i] = grid->verts[j * grid->width + oldwidth];\n\t\t}\n\t\toldwidth++;\n\t}\n\tfor (j = 0; j < grid->height; j++) {\n\t\terrorTable[1][j] = grid->heightLodError[j];\n\t}\n\t// put all the aproximating points on the curve\n\t//PutPointsOnCurve( ctrl, width, height );\n\t// calculate normals\n\tMakeMeshNormals( width, height, ctrl );\n\n\tVectorCopy(grid->lodOrigin, lodOrigin);\n\tlodRadius = grid->lodRadius;\n\t// free the old grid\n\tR_FreeSurfaceGridMesh(grid);\n\t// create a new grid\n\tgrid = R_CreateSurfaceGridMesh( width, height, ctrl, errorTable );\n\tgrid->lodRadius = lodRadius;\n\tVectorCopy(lodOrigin, grid->lodOrigin);\n\treturn grid;\n}\n\n/*\n===============\nR_GridInsertRow\n===============\n*/\nsrfGridMesh_t *R_GridInsertRow( srfGridMesh_t *grid, int row, int column, vec3_t point, float loderror ) {\n\tint i, j;\n\tint width, height, oldheight;\n\tMAC_STATIC drawVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE];\n\tfloat errorTable[2][MAX_GRID_SIZE];\n\tfloat lodRadius;\n\tvec3_t lodOrigin;\n\n\toldheight = 0;\n\twidth = grid->width;\n\theight = grid->height + 1;\n\tif (height > MAX_GRID_SIZE)\n\t\treturn NULL;\n\tfor (i = 0; i < height; i++) {\n\t\tif (i == row) {\n\t\t\t//insert new row\n\t\t\tfor (j = 0; j < grid->width; j++) {\n\t\t\t\tLerpDrawVert( &grid->verts[(i-1) * grid->width + j], &grid->verts[i * grid->width + j], &ctrl[i][j] );\n\t\t\t\tif (j == column)\n\t\t\t\t\tVectorCopy(point, ctrl[i][j].xyz);\n\t\t\t}\n\t\t\terrorTable[1][i] = loderror;\n\t\t\tcontinue;\n\t\t}\n\t\terrorTable[1][i] = grid->heightLodError[oldheight];\n\t\tfor (j = 0; j < grid->width; j++) {\n\t\t\tctrl[i][j] = grid->verts[oldheight * grid->width + j];\n\t\t}\n\t\toldheight++;\n\t}\n\tfor (j = 0; j < grid->width; j++) {\n\t\terrorTable[0][j] = grid->widthLodError[j];\n\t}\n\t// put all the aproximating points on the curve\n\t//PutPointsOnCurve( ctrl, width, height );\n\t// calculate normals\n\tMakeMeshNormals( width, height, ctrl );\n\n\tVectorCopy(grid->lodOrigin, lodOrigin);\n\tlodRadius = grid->lodRadius;\n\t// free the old grid\n\tR_FreeSurfaceGridMesh(grid);\n\t// create a new grid\n\tgrid = R_CreateSurfaceGridMesh( width, height, ctrl, errorTable );\n\tgrid->lodRadius = lodRadius;\n\tVectorCopy(lodOrigin, grid->lodOrigin);\n\treturn grid;\n}\n"
  },
  {
    "path": "code/renderer/tr_flares.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// tr_flares.c\n\n#include \"tr_local.h\"\n\n/*\n=============================================================================\n\nLIGHT FLARES\n\nA light flare is an effect that takes place inside the eye when bright light\nsources are visible.  The size of the flare reletive to the screen is nearly\nconstant, irrespective of distance, but the intensity should be proportional to the\nprojected area of the light source.\n\nA surface that has been flagged as having a light flare will calculate the depth\nbuffer value that it's midpoint should have when the surface is added.\n\nAfter all opaque surfaces have been rendered, the depth buffer is read back for\neach flare in view.  If the point has not been obscured by a closer surface, the\nflare should be drawn.\n\nSurfaces that have a repeated texture should never be flagged as flaring, because\nthere will only be a single flare added at the midpoint of the polygon.\n\nTo prevent abrupt popping, the intensity of the flare is interpolated up and\ndown as it changes visibility.  This involves scene to scene state, unlike almost\nall other aspects of the renderer, and is complicated by the fact that a single\nframe may have multiple scenes.\n\nRB_RenderFlares() will be called once per view (twice in a mirrored scene, potentially\nup to five or more times in a frame with 3D status bar icons).\n\n=============================================================================\n*/\n\n\n// flare states maintain visibility over multiple frames for fading\n// layers: view, mirror, menu\ntypedef struct flare_s {\n\tstruct\t\tflare_s\t*next;\t\t// for active chain\n\n\tint\t\t\taddedFrame;\n\n\tqboolean\tinPortal;\t\t\t\t// true if in a portal view of the scene\n\tint\t\t\tframeSceneNum;\n\tvoid\t\t*surface;\n\tint\t\t\tfogNum;\n\n\tint\t\t\tfadeTime;\n\n\tqboolean\tvisible;\t\t\t// state of last test\n\tfloat\t\tdrawIntensity;\t\t// may be non 0 even if !visible due to fading\n\n\tint\t\t\twindowX, windowY;\n\tfloat\t\teyeZ;\n\n\tvec3_t\t\tcolor;\n} flare_t;\n\n#define\t\tMAX_FLARES\t\t128\n\nflare_t\t\tr_flareStructs[MAX_FLARES];\nflare_t\t\t*r_activeFlares, *r_inactiveFlares;\n\n/*\n==================\nR_ClearFlares\n==================\n*/\nvoid R_ClearFlares( void ) {\n\tint\t\ti;\n\n\tCom_Memset( r_flareStructs, 0, sizeof( r_flareStructs ) );\n\tr_activeFlares = NULL;\n\tr_inactiveFlares = NULL;\n\n\tfor ( i = 0 ; i < MAX_FLARES ; i++ ) {\n\t\tr_flareStructs[i].next = r_inactiveFlares;\n\t\tr_inactiveFlares = &r_flareStructs[i];\n\t}\n}\n\n\n/*\n==================\nRB_AddFlare\n\nThis is called at surface tesselation time\n==================\n*/\nvoid RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t normal ) {\n\tint\t\t\t\ti;\n\tflare_t\t\t\t*f, *oldest;\n\tvec3_t\t\t\tlocal;\n\tfloat\t\t\td;\n\tvec4_t\t\t\teye, clip, normalized, window;\n\n\tbackEnd.pc.c_flareAdds++;\n\n\t// if the point is off the screen, don't bother adding it\n\t// calculate screen coordinates and depth\n\tR_TransformModelToClip( point, backEnd.or.modelMatrix, \n\t\tbackEnd.viewParms.projectionMatrix, eye, clip );\n\n\t// check to see if the point is completely off screen\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tif ( clip[i] >= clip[3] || clip[i] <= -clip[3] ) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\tR_TransformClipToWindow( clip, &backEnd.viewParms, normalized, window );\n\n\tif ( window[0] < 0 || window[0] >= backEnd.viewParms.viewportWidth\n\t\t|| window[1] < 0 || window[1] >= backEnd.viewParms.viewportHeight ) {\n\t\treturn;\t// shouldn't happen, since we check the clip[] above, except for FP rounding\n\t}\n\n\t// see if a flare with a matching surface, scene, and view exists\n\toldest = r_flareStructs;\n\tfor ( f = r_activeFlares ; f ; f = f->next ) {\n\t\tif ( f->surface == surface && f->frameSceneNum == backEnd.viewParms.frameSceneNum\n\t\t\t&& f->inPortal == backEnd.viewParms.isPortal ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// allocate a new one\n\tif (!f ) {\n\t\tif ( !r_inactiveFlares ) {\n\t\t\t// the list is completely full\n\t\t\treturn;\n\t\t}\n\t\tf = r_inactiveFlares;\n\t\tr_inactiveFlares = r_inactiveFlares->next;\n\t\tf->next = r_activeFlares;\n\t\tr_activeFlares = f;\n\n\t\tf->surface = surface;\n\t\tf->frameSceneNum = backEnd.viewParms.frameSceneNum;\n\t\tf->inPortal = backEnd.viewParms.isPortal;\n\t\tf->addedFrame = -1;\n\t}\n\n\tif ( f->addedFrame != backEnd.viewParms.frameCount - 1 ) {\n\t\tf->visible = qfalse;\n\t\tf->fadeTime = backEnd.refdef.time - 2000;\n\t}\n\n\tf->addedFrame = backEnd.viewParms.frameCount;\n\tf->fogNum = fogNum;\n\n\tVectorCopy( color, f->color );\n\n\t// fade the intensity of the flare down as the\n\t// light surface turns away from the viewer\n\tif ( normal ) {\n\t\tVectorSubtract( backEnd.viewParms.or.origin, point, local );\n\t\tVectorNormalizeFast( local );\n\t\td = DotProduct( local, normal );\n\t\tVectorScale( f->color, d, f->color ); \n\t}\n\n\t// save info needed to test\n\tf->windowX = backEnd.viewParms.viewportX + window[0];\n\tf->windowY = backEnd.viewParms.viewportY + window[1];\n\n\tf->eyeZ = eye[2];\n}\n\n/*\n==================\nRB_AddDlightFlares\n==================\n*/\nvoid RB_AddDlightFlares( void ) {\n\tdlight_t\t\t*l;\n\tint\t\t\t\ti, j, k;\n\tfog_t\t\t\t*fog;\n\n\tif ( !r_flares->integer ) {\n\t\treturn;\n\t}\n\n\tl = backEnd.refdef.dlights;\n\tfog = tr.world->fogs;\n\tfor (i=0 ; i<backEnd.refdef.num_dlights ; i++, l++) {\n\n\t\t// find which fog volume the light is in \n\t\tfor ( j = 1 ; j < tr.world->numfogs ; j++ ) {\n\t\t\tfog = &tr.world->fogs[j];\n\t\t\tfor ( k = 0 ; k < 3 ; k++ ) {\n\t\t\t\tif ( l->origin[k] < fog->bounds[0][k] || l->origin[k] > fog->bounds[1][k] ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( k == 3 ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif ( j == tr.world->numfogs ) {\n\t\t\tj = 0;\n\t\t}\n\n\t\tRB_AddFlare( (void *)l, j, l->origin, l->color, NULL );\n\t}\n}\n\n/*\n===============================================================================\n\nFLARE BACK END\n\n===============================================================================\n*/\n\n/*\n==================\nRB_TestFlare\n==================\n*/\nvoid RB_TestFlare( flare_t *f ) {\n\tfloat\t\t\tdepth;\n\tqboolean\t\tvisible;\n\tfloat\t\t\tfade;\n\tfloat\t\t\tscreenZ;\n\n\tbackEnd.pc.c_flareTests++;\n\n\t// doing a readpixels is as good as doing a glFinish(), so\n\t// don't bother with another sync\n\tglState.finishCalled = qfalse;\n\n\t// read back the z buffer contents\n\tqglReadPixels( f->windowX, f->windowY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth );\n\n\tscreenZ = backEnd.viewParms.projectionMatrix[14] / \n\t\t( ( 2*depth - 1 ) * backEnd.viewParms.projectionMatrix[11] - backEnd.viewParms.projectionMatrix[10] );\n\n\tvisible = ( -f->eyeZ - -screenZ ) < 24;\n\n\tif ( visible ) {\n\t\tif ( !f->visible ) {\n\t\t\tf->visible = qtrue;\n\t\t\tf->fadeTime = backEnd.refdef.time - 1;\n\t\t}\n\t\tfade = ( ( backEnd.refdef.time - f->fadeTime ) /1000.0f ) * r_flareFade->value;\n\t} else {\n\t\tif ( f->visible ) {\n\t\t\tf->visible = qfalse;\n\t\t\tf->fadeTime = backEnd.refdef.time - 1;\n\t\t}\n\t\tfade = 1.0f - ( ( backEnd.refdef.time - f->fadeTime ) / 1000.0f ) * r_flareFade->value;\n\t}\n\n\tif ( fade < 0 ) {\n\t\tfade = 0;\n\t}\n\tif ( fade > 1 ) {\n\t\tfade = 1;\n\t}\n\n\tf->drawIntensity = fade;\n}\n\n\n/*\n==================\nRB_RenderFlare\n==================\n*/\nvoid RB_RenderFlare( flare_t *f ) {\n\tfloat\t\t\tsize;\n\tvec3_t\t\t\tcolor;\n\tint\t\t\t\tiColor[3];\n\n\tbackEnd.pc.c_flareRenders++;\n\n\tVectorScale( f->color, f->drawIntensity*tr.identityLight, color );\n\tiColor[0] = color[0] * 255;\n\tiColor[1] = color[1] * 255;\n\tiColor[2] = color[2] * 255;\n\n\tsize = backEnd.viewParms.viewportWidth * ( r_flareSize->value/640.0f + 8 / -f->eyeZ );\n\n\tRB_BeginSurface( tr.flareShader, f->fogNum );\n\n\t// FIXME: use quadstamp?\n\ttess.xyz[tess.numVertexes][0] = f->windowX - size;\n\ttess.xyz[tess.numVertexes][1] = f->windowY - size;\n\ttess.texCoords[tess.numVertexes][0][0] = 0;\n\ttess.texCoords[tess.numVertexes][0][1] = 0;\n\ttess.vertexColors[tess.numVertexes][0] = iColor[0];\n\ttess.vertexColors[tess.numVertexes][1] = iColor[1];\n\ttess.vertexColors[tess.numVertexes][2] = iColor[2];\n\ttess.vertexColors[tess.numVertexes][3] = 255;\n\ttess.numVertexes++;\n\n\ttess.xyz[tess.numVertexes][0] = f->windowX - size;\n\ttess.xyz[tess.numVertexes][1] = f->windowY + size;\n\ttess.texCoords[tess.numVertexes][0][0] = 0;\n\ttess.texCoords[tess.numVertexes][0][1] = 1;\n\ttess.vertexColors[tess.numVertexes][0] = iColor[0];\n\ttess.vertexColors[tess.numVertexes][1] = iColor[1];\n\ttess.vertexColors[tess.numVertexes][2] = iColor[2];\n\ttess.vertexColors[tess.numVertexes][3] = 255;\n\ttess.numVertexes++;\n\n\ttess.xyz[tess.numVertexes][0] = f->windowX + size;\n\ttess.xyz[tess.numVertexes][1] = f->windowY + size;\n\ttess.texCoords[tess.numVertexes][0][0] = 1;\n\ttess.texCoords[tess.numVertexes][0][1] = 1;\n\ttess.vertexColors[tess.numVertexes][0] = iColor[0];\n\ttess.vertexColors[tess.numVertexes][1] = iColor[1];\n\ttess.vertexColors[tess.numVertexes][2] = iColor[2];\n\ttess.vertexColors[tess.numVertexes][3] = 255;\n\ttess.numVertexes++;\n\n\ttess.xyz[tess.numVertexes][0] = f->windowX + size;\n\ttess.xyz[tess.numVertexes][1] = f->windowY - size;\n\ttess.texCoords[tess.numVertexes][0][0] = 1;\n\ttess.texCoords[tess.numVertexes][0][1] = 0;\n\ttess.vertexColors[tess.numVertexes][0] = iColor[0];\n\ttess.vertexColors[tess.numVertexes][1] = iColor[1];\n\ttess.vertexColors[tess.numVertexes][2] = iColor[2];\n\ttess.vertexColors[tess.numVertexes][3] = 255;\n\ttess.numVertexes++;\n\n\ttess.indexes[tess.numIndexes++] = 0;\n\ttess.indexes[tess.numIndexes++] = 1;\n\ttess.indexes[tess.numIndexes++] = 2;\n\ttess.indexes[tess.numIndexes++] = 0;\n\ttess.indexes[tess.numIndexes++] = 2;\n\ttess.indexes[tess.numIndexes++] = 3;\n\n\tRB_EndSurface();\n}\n\n/*\n==================\nRB_RenderFlares\n\nBecause flares are simulating an occular effect, they should be drawn after\neverything (all views) in the entire frame has been drawn.\n\nBecause of the way portals use the depth buffer to mark off areas, the\nneeded information would be lost after each view, so we are forced to draw\nflares after each view.\n\nThe resulting artifact is that flares in mirrors or portals don't dim properly\nwhen occluded by something in the main view, and portal flares that should\nextend past the portal edge will be overwritten.\n==================\n*/\nvoid RB_RenderFlares (void) {\n\tflare_t\t\t*f;\n\tflare_t\t\t**prev;\n\tqboolean\tdraw;\n\n\tif ( !r_flares->integer ) {\n\t\treturn;\n\t}\n\n//\tRB_AddDlightFlares();\n\n\t// perform z buffer readback on each flare in this view\n\tdraw = qfalse;\n\tprev = &r_activeFlares;\n\twhile ( ( f = *prev ) != NULL ) {\n\t\t// throw out any flares that weren't added last frame\n\t\tif ( f->addedFrame < backEnd.viewParms.frameCount - 1 ) {\n\t\t\t*prev = f->next;\n\t\t\tf->next = r_inactiveFlares;\n\t\t\tr_inactiveFlares = f;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// don't draw any here that aren't from this scene / portal\n\t\tf->drawIntensity = 0;\n\t\tif ( f->frameSceneNum == backEnd.viewParms.frameSceneNum\n\t\t\t&& f->inPortal == backEnd.viewParms.isPortal ) {\n\t\t\tRB_TestFlare( f );\n\t\t\tif ( f->drawIntensity ) {\n\t\t\t\tdraw = qtrue;\n\t\t\t} else {\n\t\t\t\t// this flare has completely faded out, so remove it from the chain\n\t\t\t\t*prev = f->next;\n\t\t\t\tf->next = r_inactiveFlares;\n\t\t\t\tr_inactiveFlares = f;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tprev = &f->next;\n\t}\n\n\tif ( !draw ) {\n\t\treturn;\t\t// none visible\n\t}\n\n\tif ( backEnd.viewParms.isPortal ) {\n\t\tqglDisable (GL_CLIP_PLANE0);\n\t}\n\n\tqglPushMatrix();\n    qglLoadIdentity();\n\tqglMatrixMode( GL_PROJECTION );\n\tqglPushMatrix();\n    qglLoadIdentity();\n\tqglOrtho( backEnd.viewParms.viewportX, backEnd.viewParms.viewportX + backEnd.viewParms.viewportWidth,\n\t\t\t  backEnd.viewParms.viewportY, backEnd.viewParms.viewportY + backEnd.viewParms.viewportHeight,\n\t\t\t  -99999, 99999 );\n\n\tfor ( f = r_activeFlares ; f ; f = f->next ) {\n\t\tif ( f->frameSceneNum == backEnd.viewParms.frameSceneNum\n\t\t\t&& f->inPortal == backEnd.viewParms.isPortal\n\t\t\t&& f->drawIntensity ) {\n\t\t\tRB_RenderFlare( f );\n\t\t}\n\t}\n\n\tqglPopMatrix();\n\tqglMatrixMode( GL_MODELVIEW );\n\tqglPopMatrix();\n}\n\n"
  },
  {
    "path": "code/renderer/tr_font.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// tr_font.c\n// \n//\n// The font system uses FreeType 2.x to render TrueType fonts for use within the game.\n// As of this writing ( Nov, 2000 ) Team Arena uses these fonts for all of the ui and \n// about 90% of the cgame presentation. A few areas of the CGAME were left uses the old \n// fonts since the code is shared with standard Q3A.\n//\n// If you include this font rendering code in a commercial product you MUST include the\n// following somewhere with your product, see www.freetype.org for specifics or changes.\n// The Freetype code also uses some hinting techniques that MIGHT infringe on patents \n// held by apple so be aware of that also.\n//\n// As of Q3A 1.25+ and Team Arena, we are shipping the game with the font rendering code\n// disabled. This removes any potential patent issues and it keeps us from having to \n// distribute an actual TrueTrype font which is 1. expensive to do and 2. seems to require\n// an act of god to accomplish. \n//\n// What we did was pre-render the fonts using FreeType ( which is why we leave the FreeType\n// credit in the credits ) and then saved off the glyph data and then hand touched up the \n// font bitmaps so they scale a bit better in GL.\n//\n// There are limitations in the way fonts are saved and reloaded in that it is based on \n// point size and not name. So if you pre-render Helvetica in 18 point and Impact in 18 point\n// you will end up with a single 18 point data file and image set. Typically you will want to \n// choose 3 sizes to best approximate the scaling you will be doing in the ui scripting system\n// \n// In the UI Scripting code, a scale of 1.0 is equal to a 48 point font. In Team Arena, we\n// use three or four scales, most of them exactly equaling the specific rendered size. We \n// rendered three sizes in Team Arena, 12, 16, and 20. \n//\n// To generate new font data you need to go through the following steps.\n// 1. delete the fontImage_x_xx.tga files and fontImage_xx.dat files from the fonts path.\n// 2. in a ui script, specificy a font, smallFont, and bigFont keyword with font name and \n//    point size. the original TrueType fonts must exist in fonts at this point.\n// 3. run the game, you should see things normally.\n// 4. Exit the game and there will be three dat files and at least three tga files. The \n//    tga's are in 256x256 pages so if it takes three images to render a 24 point font you \n//    will end up with fontImage_0_24.tga through fontImage_2_24.tga\n// 5. You will need to flip the tga's in Photoshop as the tga output code writes them upside\n//    down.\n// 6. In future runs of the game, the system looks for these images and data files when a s\n//    specific point sized font is rendered and loads them for use. \n// 7. Because of the original beta nature of the FreeType code you will probably want to hand\n//    touch the font bitmaps.\n// \n// Currently a define in the project turns on or off the FreeType code which is currently \n// defined out. To pre-render new fonts you need enable the define ( BUILD_FREETYPE ) and \n// uncheck the exclude from build check box in the FreeType2 area of the Renderer project. \n\n\n#include \"tr_local.h\"\n#include \"../qcommon/qcommon.h\"\n\n#ifdef BUILD_FREETYPE\n#include \"../ft2/fterrors.h\"\n#include \"../ft2/ftsystem.h\"\n#include \"../ft2/ftimage.h\"\n#include \"../ft2/freetype.h\"\n#include \"../ft2/ftoutln.h\"\n\n#define _FLOOR(x)  ((x) & -64)\n#define _CEIL(x)   (((x)+63) & -64)\n#define _TRUNC(x)  ((x) >> 6)\n\nFT_Library ftLibrary = NULL;  \n#endif\n\n#define MAX_FONTS 6\nstatic int registeredFontCount = 0;\nstatic fontInfo_t registeredFont[MAX_FONTS];\n\n#ifdef BUILD_FREETYPE\nvoid R_GetGlyphInfo(FT_GlyphSlot glyph, int *left, int *right, int *width, int *top, int *bottom, int *height, int *pitch) {\n\n  *left  = _FLOOR( glyph->metrics.horiBearingX );\n  *right = _CEIL( glyph->metrics.horiBearingX + glyph->metrics.width );\n  *width = _TRUNC(*right - *left);\n    \n  *top    = _CEIL( glyph->metrics.horiBearingY );\n  *bottom = _FLOOR( glyph->metrics.horiBearingY - glyph->metrics.height );\n  *height = _TRUNC( *top - *bottom );\n  *pitch  = ( qtrue ? (*width+3) & -4 : (*width+7) >> 3 );\n}\n\n\nFT_Bitmap *R_RenderGlyph(FT_GlyphSlot glyph, glyphInfo_t* glyphOut) {\n\n  FT_Bitmap  *bit2;\n  int left, right, width, top, bottom, height, pitch, size;\n\n  R_GetGlyphInfo(glyph, &left, &right, &width, &top, &bottom, &height, &pitch);\n\n  if ( glyph->format == ft_glyph_format_outline ) {\n    size   = pitch*height; \n\n    bit2 = Z_Malloc(sizeof(FT_Bitmap));\n\n    bit2->width      = width;\n    bit2->rows       = height;\n    bit2->pitch      = pitch;\n    bit2->pixel_mode = ft_pixel_mode_grays;\n    //bit2->pixel_mode = ft_pixel_mode_mono;\n    bit2->buffer     = Z_Malloc(pitch*height);\n    bit2->num_grays = 256;\n\n    Com_Memset( bit2->buffer, 0, size );\n\n    FT_Outline_Translate( &glyph->outline, -left, -bottom );\n\n    FT_Outline_Get_Bitmap( ftLibrary, &glyph->outline, bit2 );\n\n    glyphOut->height = height;\n    glyphOut->pitch = pitch;\n    glyphOut->top = (glyph->metrics.horiBearingY >> 6) + 1;\n    glyphOut->bottom = bottom;\n    \n    return bit2;\n  }\n  else {\n    ri.Printf(PRINT_ALL, \"Non-outline fonts are not supported\\n\");\n  }\n  return NULL;\n}\n\nvoid WriteTGA (char *filename, byte *data, int width, int height) {\n\tbyte\t*buffer;\n\tint\t\ti, c;\n\n\tbuffer = Z_Malloc(width*height*4 + 18);\n\tCom_Memset (buffer, 0, 18);\n\tbuffer[2] = 2;\t\t// uncompressed type\n\tbuffer[12] = width&255;\n\tbuffer[13] = width>>8;\n\tbuffer[14] = height&255;\n\tbuffer[15] = height>>8;\n\tbuffer[16] = 32;\t// pixel size\n\n\t// swap rgb to bgr\n\tc = 18 + width * height * 4;\n\tfor (i=18 ; i<c ; i+=4)\n\t{\n\t\tbuffer[i] = data[i-18+2];\t\t// blue\n\t\tbuffer[i+1] = data[i-18+1];\t\t// green\n\t\tbuffer[i+2] = data[i-18+0];\t\t// red\n\t\tbuffer[i+3] = data[i-18+3];\t\t// alpha\n\t}\n\n\tri.FS_WriteFile(filename, buffer, c);\n\n\t//f = fopen (filename, \"wb\");\n\t//fwrite (buffer, 1, c, f);\n\t//fclose (f);\n\n\tZ_Free (buffer);\n}\n\nstatic glyphInfo_t *RE_ConstructGlyphInfo(unsigned char *imageOut, int *xOut, int *yOut, int *maxHeight, FT_Face face, const unsigned char c, qboolean calcHeight) {\n  int i;\n  static glyphInfo_t glyph;\n  unsigned char *src, *dst;\n  float scaled_width, scaled_height;\n  FT_Bitmap *bitmap = NULL;\n\n  Com_Memset(&glyph, 0, sizeof(glyphInfo_t));\n  // make sure everything is here\n  if (face != NULL) {\n    FT_Load_Glyph(face, FT_Get_Char_Index( face, c), FT_LOAD_DEFAULT );\n    bitmap = R_RenderGlyph(face->glyph, &glyph);\n    if (bitmap) {\n      glyph.xSkip = (face->glyph->metrics.horiAdvance >> 6) + 1;\n    } else {\n      return &glyph;\n    }\n\n    if (glyph.height > *maxHeight) {\n      *maxHeight = glyph.height;\n    }\n\n    if (calcHeight) {\n      Z_Free(bitmap->buffer);\n      Z_Free(bitmap);\n      return &glyph;\n    }\n\n/*\n    // need to convert to power of 2 sizes so we do not get \n    // any scaling from the gl upload\n  \tfor (scaled_width = 1 ; scaled_width < glyph.pitch ; scaled_width<<=1)\n\t  \t;\n  \tfor (scaled_height = 1 ; scaled_height < glyph.height ; scaled_height<<=1)\n\t  \t;\n*/\n\n    scaled_width = glyph.pitch;\n    scaled_height = glyph.height;\n\n    // we need to make sure we fit\n    if (*xOut + scaled_width + 1 >= 255) {\n      if (*yOut + *maxHeight + 1 >= 255) {\n        *yOut = -1;\n        *xOut = -1;\n        Z_Free(bitmap->buffer);\n        Z_Free(bitmap);\n        return &glyph;\n      } else {\n        *xOut = 0;\n        *yOut += *maxHeight + 1;\n      }\n    } else if (*yOut + *maxHeight + 1 >= 255) {\n      *yOut = -1;\n      *xOut = -1;\n      Z_Free(bitmap->buffer);\n      Z_Free(bitmap);\n      return &glyph;\n    }\n\n\n    src = bitmap->buffer;\n    dst = imageOut + (*yOut * 256) + *xOut;\n\n\t\tif (bitmap->pixel_mode == ft_pixel_mode_mono) {\n\t\t\tfor (i = 0; i < glyph.height; i++) {\n\t\t\t\tint j;\n\t\t\t\tunsigned char *_src = src;\n\t\t\t\tunsigned char *_dst = dst;\n\t\t\t\tunsigned char mask = 0x80;\n\t\t\t\tunsigned char val = *_src;\n\t\t\t\tfor (j = 0; j < glyph.pitch; j++) {\n\t\t\t\t\tif (mask == 0x80) {\n\t\t\t\t\t\tval = *_src++;\n\t\t\t\t\t}\n\t\t\t\t\tif (val & mask) {\n\t\t\t\t\t\t*_dst = 0xff;\n\t\t\t\t\t}\n\t\t\t\t\tmask >>= 1;\n        \n\t\t\t\t\tif ( mask == 0 ) {\n\t\t\t\t\t\tmask = 0x80;\n\t\t\t\t\t}\n\t\t\t\t\t_dst++;\n\t\t\t\t}\n\n\t\t\t\tsrc += glyph.pitch;\n\t\t\t\tdst += 256;\n\n\t\t\t}\n\t\t} else {\n\t    for (i = 0; i < glyph.height; i++) {\n\t\t    Com_Memcpy(dst, src, glyph.pitch);\n\t\t\t  src += glyph.pitch;\n\t\t\t\tdst += 256;\n\t    }\n\t\t}\n\n    // we now have an 8 bit per pixel grey scale bitmap \n    // that is width wide and pf->ftSize->metrics.y_ppem tall\n\n    glyph.imageHeight = scaled_height;\n    glyph.imageWidth = scaled_width;\n    glyph.s = (float)*xOut / 256;\n    glyph.t = (float)*yOut / 256;\n    glyph.s2 = glyph.s + (float)scaled_width / 256;\n    glyph.t2 = glyph.t + (float)scaled_height / 256;\n\n    *xOut += scaled_width + 1;\n  }\n\n  Z_Free(bitmap->buffer);\n  Z_Free(bitmap);\n\n  return &glyph;\n}\n#endif\n\nstatic int fdOffset;\nstatic byte\t*fdFile;\n\nint readInt() {\n\tint i = fdFile[fdOffset]+(fdFile[fdOffset+1]<<8)+(fdFile[fdOffset+2]<<16)+(fdFile[fdOffset+3]<<24);\n\tfdOffset += 4;\n\treturn i;\n}\n\ntypedef union {\n\tbyte\tfred[4];\n\tfloat\tffred;\n} poor;\n\nfloat readFloat() {\n\tpoor\tme;\n#if idppc\n\tme.fred[0] = fdFile[fdOffset+3];\n\tme.fred[1] = fdFile[fdOffset+2];\n\tme.fred[2] = fdFile[fdOffset+1];\n\tme.fred[3] = fdFile[fdOffset+0];\n#else\n\tme.fred[0] = fdFile[fdOffset+0];\n\tme.fred[1] = fdFile[fdOffset+1];\n\tme.fred[2] = fdFile[fdOffset+2];\n\tme.fred[3] = fdFile[fdOffset+3];\n#endif\n\tfdOffset += 4;\n\treturn me.ffred;\n}\n\nvoid RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {\n#ifdef BUILD_FREETYPE\n  FT_Face face;\n  int j, k, xOut, yOut, lastStart, imageNumber;\n  int scaledSize, newSize, maxHeight, left, satLevels;\n  unsigned char *out, *imageBuff;\n  glyphInfo_t *glyph;\n  image_t *image;\n  qhandle_t h;\n\tfloat max;\n#endif\n  void *faceData;\n\tint i, len;\n  char name[1024];\n\tfloat dpi = 72;\t\t\t\t\t\t\t\t\t\t\t//\n\tfloat glyphScale =  72.0f / dpi; \t\t// change the scale to be relative to 1 based on 72 dpi ( so dpi of 144 means a scale of .5 )\n\n\tif (pointSize <= 0) {\n\t\tpointSize = 12;\n\t}\n\t// we also need to adjust the scale based on point size relative to 48 points as the ui scaling is based on a 48 point font\n\tglyphScale *= 48.0f / pointSize;\n\n\t// make sure the render thread is stopped\n\tR_SyncRenderThread();\n\n  if (registeredFontCount >= MAX_FONTS) {\n    ri.Printf(PRINT_ALL, \"RE_RegisterFont: Too many fonts registered already.\\n\");\n    return;\n  }\n\n\tCom_sprintf(name, sizeof(name), \"fonts/fontImage_%i.dat\",pointSize);\n\tfor (i = 0; i < registeredFontCount; i++) {\n\t\tif (Q_stricmp(name, registeredFont[i].name) == 0) {\n\t\t\tCom_Memcpy(font, &registeredFont[i], sizeof(fontInfo_t));\n\t\t\treturn;\n\t\t}\n\t}\n\n\tlen = ri.FS_ReadFile(name, NULL);\n\tif (len == sizeof(fontInfo_t)) {\n\t\tri.FS_ReadFile(name, &faceData);\n\t\tfdOffset = 0;\n\t\tfdFile = faceData;\n\t\tfor(i=0; i<GLYPHS_PER_FONT; i++) {\n\t\t\tfont->glyphs[i].height\t\t= readInt();\n\t\t\tfont->glyphs[i].top\t\t\t= readInt();\n\t\t\tfont->glyphs[i].bottom\t\t= readInt();\n\t\t\tfont->glyphs[i].pitch\t\t= readInt();\n\t\t\tfont->glyphs[i].xSkip\t\t= readInt();\n\t\t\tfont->glyphs[i].imageWidth\t= readInt();\n\t\t\tfont->glyphs[i].imageHeight = readInt();\n\t\t\tfont->glyphs[i].s\t\t\t= readFloat();\n\t\t\tfont->glyphs[i].t\t\t\t= readFloat();\n\t\t\tfont->glyphs[i].s2\t\t\t= readFloat();\n\t\t\tfont->glyphs[i].t2\t\t\t= readFloat();\n\t\t\tfont->glyphs[i].glyph\t\t= readInt();\n\t\t\tCom_Memcpy(font->glyphs[i].shaderName, &fdFile[fdOffset], 32);\n\t\t\tfdOffset += 32;\n\t\t}\n\t\tfont->glyphScale = readFloat();\n\t\tCom_Memcpy(font->name, &fdFile[fdOffset], MAX_QPATH);\n\n//\t\tCom_Memcpy(font, faceData, sizeof(fontInfo_t));\n\t\tQ_strncpyz(font->name, name, sizeof(font->name));\n\t\tfor (i = GLYPH_START; i < GLYPH_END; i++) {\n\t\t\tfont->glyphs[i].glyph = RE_RegisterShaderNoMip(font->glyphs[i].shaderName);\n\t\t}\n\t  Com_Memcpy(&registeredFont[registeredFontCount++], font, sizeof(fontInfo_t));\n\t\treturn;\n\t}\n\n#ifndef BUILD_FREETYPE\n    ri.Printf(PRINT_ALL, \"RE_RegisterFont: FreeType code not available\\n\");\n#else\n  if (ftLibrary == NULL) {\n    ri.Printf(PRINT_ALL, \"RE_RegisterFont: FreeType not initialized.\\n\");\n    return;\n  }\n\n  len = ri.FS_ReadFile(fontName, &faceData);\n  if (len <= 0) {\n    ri.Printf(PRINT_ALL, \"RE_RegisterFont: Unable to read font file\\n\");\n    return;\n  }\n\n  // allocate on the stack first in case we fail\n  if (FT_New_Memory_Face( ftLibrary, faceData, len, 0, &face )) {\n    ri.Printf(PRINT_ALL, \"RE_RegisterFont: FreeType2, unable to allocate new face.\\n\");\n    return;\n  }\n\n\n  if (FT_Set_Char_Size( face, pointSize << 6, pointSize << 6, dpi, dpi)) {\n    ri.Printf(PRINT_ALL, \"RE_RegisterFont: FreeType2, Unable to set face char size.\\n\");\n    return;\n  }\n\n  //*font = &registeredFonts[registeredFontCount++];\n\n  // make a 256x256 image buffer, once it is full, register it, clean it and keep going \n  // until all glyphs are rendered\n\n  out = Z_Malloc(1024*1024);\n  if (out == NULL) {\n    ri.Printf(PRINT_ALL, \"RE_RegisterFont: Z_Malloc failure during output image creation.\\n\");\n    return;\n  }\n  Com_Memset(out, 0, 1024*1024);\n\n  maxHeight = 0;\n\n  for (i = GLYPH_START; i < GLYPH_END; i++) {\n    glyph = RE_ConstructGlyphInfo(out, &xOut, &yOut, &maxHeight, face, (unsigned char)i, qtrue);\n  }\n\n  xOut = 0;\n  yOut = 0;\n  i = GLYPH_START;\n  lastStart = i;\n  imageNumber = 0;\n\n  while ( i <= GLYPH_END ) {\n\n    glyph = RE_ConstructGlyphInfo(out, &xOut, &yOut, &maxHeight, face, (unsigned char)i, qfalse);\n\n    if (xOut == -1 || yOut == -1 || i == GLYPH_END)  {\n      // ran out of room\n      // we need to create an image from the bitmap, set all the handles in the glyphs to this point\n      // \n\n      scaledSize = 256*256;\n      newSize = scaledSize * 4;\n      imageBuff = Z_Malloc(newSize);\n      left = 0;\n      max = 0;\n      satLevels = 255;\n      for ( k = 0; k < (scaledSize) ; k++ ) {\n        if (max < out[k]) {\n          max = out[k];\n        }\n      }\n\n\t\t\tif (max > 0) {\n\t\t\t\tmax = 255/max;\n\t\t\t}\n\n      for ( k = 0; k < (scaledSize) ; k++ ) {\n        imageBuff[left++] = 255;\n        imageBuff[left++] = 255;\n        imageBuff[left++] = 255;\n\n        imageBuff[left++] = ((float)out[k] * max);\n      }\n\n\t\t\tCom_sprintf (name, sizeof(name), \"fonts/fontImage_%i_%i.tga\", imageNumber++, pointSize);\n\t\t\tif (r_saveFontData->integer) { \n\t\t\t  WriteTGA(name, imageBuff, 256, 256);\n\t\t\t}\n\n    \t//Com_sprintf (name, sizeof(name), \"fonts/fontImage_%i_%i\", imageNumber++, pointSize);\n      image = R_CreateImage(name, imageBuff, 256, 256, qfalse, qfalse, GL_CLAMP);\n      h = RE_RegisterShaderFromImage(name, LIGHTMAP_2D, image, qfalse);\n      for (j = lastStart; j < i; j++) {\n        font->glyphs[j].glyph = h;\n\t\t\t\tQ_strncpyz(font->glyphs[j].shaderName, name, sizeof(font->glyphs[j].shaderName));\n      }\n      lastStart = i;\n\t\t  Com_Memset(out, 0, 1024*1024);\n      xOut = 0;\n      yOut = 0;\n      Z_Free(imageBuff);\n\t\t\ti++;\n    } else {\n      Com_Memcpy(&font->glyphs[i], glyph, sizeof(glyphInfo_t));\n      i++;\n    }\n  }\n\n\tregisteredFont[registeredFontCount].glyphScale = glyphScale;\n\tfont->glyphScale = glyphScale;\n  Com_Memcpy(&registeredFont[registeredFontCount++], font, sizeof(fontInfo_t));\n\n\tif (r_saveFontData->integer) { \n\t\tri.FS_WriteFile(va(\"fonts/fontImage_%i.dat\", pointSize), font, sizeof(fontInfo_t));\n\t}\n\n  Z_Free(out);\n  \n  ri.FS_FreeFile(faceData);\n#endif\n}\n\n\n\nvoid R_InitFreeType() {\n#ifdef BUILD_FREETYPE\n  if (FT_Init_FreeType( &ftLibrary )) {\n    ri.Printf(PRINT_ALL, \"R_InitFreeType: Unable to initialize FreeType.\\n\");\n  }\n#endif\n  registeredFontCount = 0;\n}\n\n\nvoid R_DoneFreeType() {\n#ifdef BUILD_FREETYPE\n  if (ftLibrary) {\n    FT_Done_FreeType( ftLibrary );\n    ftLibrary = NULL;\n  }\n#endif\n\tregisteredFontCount = 0;\n}\n\n"
  },
  {
    "path": "code/renderer/tr_image.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// tr_image.c\n#include \"tr_local.h\"\n\n/*\n * Include file for users of JPEG library.\n * You will need to have included system headers that define at least\n * the typedefs FILE and size_t before you can include jpeglib.h.\n * (stdio.h is sufficient on ANSI-conforming systems.)\n * You may also wish to include \"jerror.h\".\n */\n\n#define JPEG_INTERNALS\n#include \"../jpeg-6/jpeglib.h\"\n\n\nstatic void LoadBMP( const char *name, byte **pic, int *width, int *height );\nstatic void LoadTGA( const char *name, byte **pic, int *width, int *height );\nstatic void LoadJPG( const char *name, byte **pic, int *width, int *height );\n\nstatic byte\t\t\t s_intensitytable[256];\nstatic unsigned char s_gammatable[256];\n\nint\t\tgl_filter_min = GL_LINEAR_MIPMAP_NEAREST;\nint\t\tgl_filter_max = GL_LINEAR;\n\n#define FILE_HASH_SIZE\t\t1024\nstatic\timage_t*\t\thashTable[FILE_HASH_SIZE];\n\n/*\n** R_GammaCorrect\n*/\nvoid R_GammaCorrect( byte *buffer, int bufSize ) {\n\tint i;\n\n\tfor ( i = 0; i < bufSize; i++ ) {\n\t\tbuffer[i] = s_gammatable[buffer[i]];\n\t}\n}\n\ntypedef struct {\n\tchar *name;\n\tint\tminimize, maximize;\n} textureMode_t;\n\ntextureMode_t modes[] = {\n\t{\"GL_NEAREST\", GL_NEAREST, GL_NEAREST},\n\t{\"GL_LINEAR\", GL_LINEAR, GL_LINEAR},\n\t{\"GL_NEAREST_MIPMAP_NEAREST\", GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST},\n\t{\"GL_LINEAR_MIPMAP_NEAREST\", GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR},\n\t{\"GL_NEAREST_MIPMAP_LINEAR\", GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST},\n\t{\"GL_LINEAR_MIPMAP_LINEAR\", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR}\n};\n\n/*\n================\nreturn a hash value for the filename\n================\n*/\nstatic long generateHashValue( const char *fname ) {\n\tint\t\ti;\n\tlong\thash;\n\tchar\tletter;\n\n\thash = 0;\n\ti = 0;\n\twhile (fname[i] != '\\0') {\n\t\tletter = tolower(fname[i]);\n\t\tif (letter =='.') break;\t\t\t\t// don't include extension\n\t\tif (letter =='\\\\') letter = '/';\t\t// damn path names\n\t\thash+=(long)(letter)*(i+119);\n\t\ti++;\n\t}\n\thash &= (FILE_HASH_SIZE-1);\n\treturn hash;\n}\n\n/*\n===============\nGL_TextureMode\n===============\n*/\nvoid GL_TextureMode( const char *string ) {\n\tint\t\ti;\n\timage_t\t*glt;\n\n\tfor ( i=0 ; i< 6 ; i++ ) {\n\t\tif ( !Q_stricmp( modes[i].name, string ) ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// hack to prevent trilinear from being set on voodoo,\n\t// because their driver freaks...\n\tif ( i == 5 && glConfig.hardwareType == GLHW_3DFX_2D3D ) {\n\t\tri.Printf( PRINT_ALL, \"Refusing to set trilinear on a voodoo.\\n\" );\n\t\ti = 3;\n\t}\n\n\n\tif ( i == 6 ) {\n\t\tri.Printf (PRINT_ALL, \"bad filter name\\n\");\n\t\treturn;\n\t}\n\n\tgl_filter_min = modes[i].minimize;\n\tgl_filter_max = modes[i].maximize;\n\n\t// change all the existing mipmap texture objects\n\tfor ( i = 0 ; i < tr.numImages ; i++ ) {\n\t\tglt = tr.images[ i ];\n\t\tif ( glt->mipmap ) {\n\t\t\tGL_Bind (glt);\n\t\t\tqglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);\n\t\t\tqglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);\n\t\t}\n\t}\n}\n\n/*\n===============\nR_SumOfUsedImages\n===============\n*/\nint R_SumOfUsedImages( void ) {\n\tint\ttotal;\n\tint i;\n\n\ttotal = 0;\n\tfor ( i = 0; i < tr.numImages; i++ ) {\n\t\tif ( tr.images[i]->frameUsed == tr.frameCount ) {\n\t\t\ttotal += tr.images[i]->uploadWidth * tr.images[i]->uploadHeight;\n\t\t}\n\t}\n\n\treturn total;\n}\n\n/*\n===============\nR_ImageList_f\n===============\n*/\nvoid R_ImageList_f( void ) {\n\tint\t\ti;\n\timage_t\t*image;\n\tint\t\ttexels;\n\tconst char *yesno[] = {\n\t\t\"no \", \"yes\"\n\t};\n\n\tri.Printf (PRINT_ALL, \"\\n      -w-- -h-- -mm- -TMU- -if-- wrap --name-------\\n\");\n\ttexels = 0;\n\n\tfor ( i = 0 ; i < tr.numImages ; i++ ) {\n\t\timage = tr.images[ i ];\n\n\t\ttexels += image->uploadWidth*image->uploadHeight;\n\t\tri.Printf (PRINT_ALL,  \"%4i: %4i %4i  %s   %d   \",\n\t\t\ti, image->uploadWidth, image->uploadHeight, yesno[image->mipmap], image->TMU );\n\t\tswitch ( image->internalFormat ) {\n\t\tcase 1:\n\t\t\tri.Printf( PRINT_ALL, \"I    \" );\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tri.Printf( PRINT_ALL, \"IA   \" );\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tri.Printf( PRINT_ALL, \"RGB  \" );\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tri.Printf( PRINT_ALL, \"RGBA \" );\n\t\t\tbreak;\n\t\tcase GL_RGBA8:\n\t\t\tri.Printf( PRINT_ALL, \"RGBA8\" );\n\t\t\tbreak;\n\t\tcase GL_RGB8:\n\t\t\tri.Printf( PRINT_ALL, \"RGB8\" );\n\t\t\tbreak;\n\t\tcase GL_RGB4_S3TC:\n\t\t\tri.Printf( PRINT_ALL, \"S3TC \" );\n\t\t\tbreak;\n\t\tcase GL_RGBA4:\n\t\t\tri.Printf( PRINT_ALL, \"RGBA4\" );\n\t\t\tbreak;\n\t\tcase GL_RGB5:\n\t\t\tri.Printf( PRINT_ALL, \"RGB5 \" );\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tri.Printf( PRINT_ALL, \"???? \" );\n\t\t}\n\n\t\tswitch ( image->wrapClampMode ) {\n\t\tcase GL_REPEAT:\n\t\t\tri.Printf( PRINT_ALL, \"rept \" );\n\t\t\tbreak;\n\t\tcase GL_CLAMP:\n\t\t\tri.Printf( PRINT_ALL, \"clmp \" );\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tri.Printf( PRINT_ALL, \"%4i \", image->wrapClampMode );\n\t\t\tbreak;\n\t\t}\n\t\t\n\t\tri.Printf( PRINT_ALL, \" %s\\n\", image->imgName );\n\t}\n\tri.Printf (PRINT_ALL, \" ---------\\n\");\n\tri.Printf (PRINT_ALL, \" %i total texels (not including mipmaps)\\n\", texels);\n\tri.Printf (PRINT_ALL, \" %i total images\\n\\n\", tr.numImages );\n}\n\n//=======================================================================\n\n/*\n================\nResampleTexture\n\nUsed to resample images in a more general than quartering fashion.\n\nThis will only be filtered properly if the resampled size\nis greater than half the original size.\n\nIf a larger shrinking is needed, use the mipmap function \nbefore or after.\n================\n*/\nstatic void ResampleTexture( unsigned *in, int inwidth, int inheight, unsigned *out,  \n\t\t\t\t\t\t\tint outwidth, int outheight ) {\n\tint\t\ti, j;\n\tunsigned\t*inrow, *inrow2;\n\tunsigned\tfrac, fracstep;\n\tunsigned\tp1[2048], p2[2048];\n\tbyte\t\t*pix1, *pix2, *pix3, *pix4;\n\n\tif (outwidth>2048)\n\t\tri.Error(ERR_DROP, \"ResampleTexture: max width\");\n\t\t\t\t\t\t\t\t\n\tfracstep = inwidth*0x10000/outwidth;\n\n\tfrac = fracstep>>2;\n\tfor ( i=0 ; i<outwidth ; i++ ) {\n\t\tp1[i] = 4*(frac>>16);\n\t\tfrac += fracstep;\n\t}\n\tfrac = 3*(fracstep>>2);\n\tfor ( i=0 ; i<outwidth ; i++ ) {\n\t\tp2[i] = 4*(frac>>16);\n\t\tfrac += fracstep;\n\t}\n\n\tfor (i=0 ; i<outheight ; i++, out += outwidth) {\n\t\tinrow = in + inwidth*(int)((i+0.25)*inheight/outheight);\n\t\tinrow2 = in + inwidth*(int)((i+0.75)*inheight/outheight);\n\t\tfrac = fracstep >> 1;\n\t\tfor (j=0 ; j<outwidth ; j++) {\n\t\t\tpix1 = (byte *)inrow + p1[j];\n\t\t\tpix2 = (byte *)inrow + p2[j];\n\t\t\tpix3 = (byte *)inrow2 + p1[j];\n\t\t\tpix4 = (byte *)inrow2 + p2[j];\n\t\t\t((byte *)(out+j))[0] = (pix1[0] + pix2[0] + pix3[0] + pix4[0])>>2;\n\t\t\t((byte *)(out+j))[1] = (pix1[1] + pix2[1] + pix3[1] + pix4[1])>>2;\n\t\t\t((byte *)(out+j))[2] = (pix1[2] + pix2[2] + pix3[2] + pix4[2])>>2;\n\t\t\t((byte *)(out+j))[3] = (pix1[3] + pix2[3] + pix3[3] + pix4[3])>>2;\n\t\t}\n\t}\n}\n\n/*\n================\nR_LightScaleTexture\n\nScale up the pixel values in a texture to increase the\nlighting range\n================\n*/\nvoid R_LightScaleTexture (unsigned *in, int inwidth, int inheight, qboolean only_gamma )\n{\n\tif ( only_gamma )\n\t{\n\t\tif ( !glConfig.deviceSupportsGamma )\n\t\t{\n\t\t\tint\t\ti, c;\n\t\t\tbyte\t*p;\n\n\t\t\tp = (byte *)in;\n\n\t\t\tc = inwidth*inheight;\n\t\t\tfor (i=0 ; i<c ; i++, p+=4)\n\t\t\t{\n\t\t\t\tp[0] = s_gammatable[p[0]];\n\t\t\t\tp[1] = s_gammatable[p[1]];\n\t\t\t\tp[2] = s_gammatable[p[2]];\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tint\t\ti, c;\n\t\tbyte\t*p;\n\n\t\tp = (byte *)in;\n\n\t\tc = inwidth*inheight;\n\n\t\tif ( glConfig.deviceSupportsGamma )\n\t\t{\n\t\t\tfor (i=0 ; i<c ; i++, p+=4)\n\t\t\t{\n\t\t\t\tp[0] = s_intensitytable[p[0]];\n\t\t\t\tp[1] = s_intensitytable[p[1]];\n\t\t\t\tp[2] = s_intensitytable[p[2]];\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfor (i=0 ; i<c ; i++, p+=4)\n\t\t\t{\n\t\t\t\tp[0] = s_gammatable[s_intensitytable[p[0]]];\n\t\t\t\tp[1] = s_gammatable[s_intensitytable[p[1]]];\n\t\t\t\tp[2] = s_gammatable[s_intensitytable[p[2]]];\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n/*\n================\nR_MipMap2\n\nOperates in place, quartering the size of the texture\nProper linear filter\n================\n*/\nstatic void R_MipMap2( unsigned *in, int inWidth, int inHeight ) {\n\tint\t\t\ti, j, k;\n\tbyte\t\t*outpix;\n\tint\t\t\tinWidthMask, inHeightMask;\n\tint\t\t\ttotal;\n\tint\t\t\toutWidth, outHeight;\n\tunsigned\t*temp;\n\n\toutWidth = inWidth >> 1;\n\toutHeight = inHeight >> 1;\n\ttemp = ri.Hunk_AllocateTempMemory( outWidth * outHeight * 4 );\n\n\tinWidthMask = inWidth - 1;\n\tinHeightMask = inHeight - 1;\n\n\tfor ( i = 0 ; i < outHeight ; i++ ) {\n\t\tfor ( j = 0 ; j < outWidth ; j++ ) {\n\t\t\toutpix = (byte *) ( temp + i * outWidth + j );\n\t\t\tfor ( k = 0 ; k < 4 ; k++ ) {\n\t\t\t\ttotal = \n\t\t\t\t\t1 * ((byte *)&in[ ((i*2-1)&inHeightMask)*inWidth + ((j*2-1)&inWidthMask) ])[k] +\n\t\t\t\t\t2 * ((byte *)&in[ ((i*2-1)&inHeightMask)*inWidth + ((j*2)&inWidthMask) ])[k] +\n\t\t\t\t\t2 * ((byte *)&in[ ((i*2-1)&inHeightMask)*inWidth + ((j*2+1)&inWidthMask) ])[k] +\n\t\t\t\t\t1 * ((byte *)&in[ ((i*2-1)&inHeightMask)*inWidth + ((j*2+2)&inWidthMask) ])[k] +\n\n\t\t\t\t\t2 * ((byte *)&in[ ((i*2)&inHeightMask)*inWidth + ((j*2-1)&inWidthMask) ])[k] +\n\t\t\t\t\t4 * ((byte *)&in[ ((i*2)&inHeightMask)*inWidth + ((j*2)&inWidthMask) ])[k] +\n\t\t\t\t\t4 * ((byte *)&in[ ((i*2)&inHeightMask)*inWidth + ((j*2+1)&inWidthMask) ])[k] +\n\t\t\t\t\t2 * ((byte *)&in[ ((i*2)&inHeightMask)*inWidth + ((j*2+2)&inWidthMask) ])[k] +\n\n\t\t\t\t\t2 * ((byte *)&in[ ((i*2+1)&inHeightMask)*inWidth + ((j*2-1)&inWidthMask) ])[k] +\n\t\t\t\t\t4 * ((byte *)&in[ ((i*2+1)&inHeightMask)*inWidth + ((j*2)&inWidthMask) ])[k] +\n\t\t\t\t\t4 * ((byte *)&in[ ((i*2+1)&inHeightMask)*inWidth + ((j*2+1)&inWidthMask) ])[k] +\n\t\t\t\t\t2 * ((byte *)&in[ ((i*2+1)&inHeightMask)*inWidth + ((j*2+2)&inWidthMask) ])[k] +\n\n\t\t\t\t\t1 * ((byte *)&in[ ((i*2+2)&inHeightMask)*inWidth + ((j*2-1)&inWidthMask) ])[k] +\n\t\t\t\t\t2 * ((byte *)&in[ ((i*2+2)&inHeightMask)*inWidth + ((j*2)&inWidthMask) ])[k] +\n\t\t\t\t\t2 * ((byte *)&in[ ((i*2+2)&inHeightMask)*inWidth + ((j*2+1)&inWidthMask) ])[k] +\n\t\t\t\t\t1 * ((byte *)&in[ ((i*2+2)&inHeightMask)*inWidth + ((j*2+2)&inWidthMask) ])[k];\n\t\t\t\toutpix[k] = total / 36;\n\t\t\t}\n\t\t}\n\t}\n\n\tCom_Memcpy( in, temp, outWidth * outHeight * 4 );\n\tri.Hunk_FreeTempMemory( temp );\n}\n\n/*\n================\nR_MipMap\n\nOperates in place, quartering the size of the texture\n================\n*/\nstatic void R_MipMap (byte *in, int width, int height) {\n\tint\t\ti, j;\n\tbyte\t*out;\n\tint\t\trow;\n\n\tif ( !r_simpleMipMaps->integer ) {\n\t\tR_MipMap2( (unsigned *)in, width, height );\n\t\treturn;\n\t}\n\n\tif ( width == 1 && height == 1 ) {\n\t\treturn;\n\t}\n\n\trow = width * 4;\n\tout = in;\n\twidth >>= 1;\n\theight >>= 1;\n\n\tif ( width == 0 || height == 0 ) {\n\t\twidth += height;\t// get largest\n\t\tfor (i=0 ; i<width ; i++, out+=4, in+=8 ) {\n\t\t\tout[0] = ( in[0] + in[4] )>>1;\n\t\t\tout[1] = ( in[1] + in[5] )>>1;\n\t\t\tout[2] = ( in[2] + in[6] )>>1;\n\t\t\tout[3] = ( in[3] + in[7] )>>1;\n\t\t}\n\t\treturn;\n\t}\n\n\tfor (i=0 ; i<height ; i++, in+=row) {\n\t\tfor (j=0 ; j<width ; j++, out+=4, in+=8) {\n\t\t\tout[0] = (in[0] + in[4] + in[row+0] + in[row+4])>>2;\n\t\t\tout[1] = (in[1] + in[5] + in[row+1] + in[row+5])>>2;\n\t\t\tout[2] = (in[2] + in[6] + in[row+2] + in[row+6])>>2;\n\t\t\tout[3] = (in[3] + in[7] + in[row+3] + in[row+7])>>2;\n\t\t}\n\t}\n}\n\n\n/*\n==================\nR_BlendOverTexture\n\nApply a color blend over a set of pixels\n==================\n*/\nstatic void R_BlendOverTexture( byte *data, int pixelCount, byte blend[4] ) {\n\tint\t\ti;\n\tint\t\tinverseAlpha;\n\tint\t\tpremult[3];\n\n\tinverseAlpha = 255 - blend[3];\n\tpremult[0] = blend[0] * blend[3];\n\tpremult[1] = blend[1] * blend[3];\n\tpremult[2] = blend[2] * blend[3];\n\n\tfor ( i = 0 ; i < pixelCount ; i++, data+=4 ) {\n\t\tdata[0] = ( data[0] * inverseAlpha + premult[0] ) >> 9;\n\t\tdata[1] = ( data[1] * inverseAlpha + premult[1] ) >> 9;\n\t\tdata[2] = ( data[2] * inverseAlpha + premult[2] ) >> 9;\n\t}\n}\n\nbyte\tmipBlendColors[16][4] = {\n\t{0,0,0,0},\n\t{255,0,0,128},\n\t{0,255,0,128},\n\t{0,0,255,128},\n\t{255,0,0,128},\n\t{0,255,0,128},\n\t{0,0,255,128},\n\t{255,0,0,128},\n\t{0,255,0,128},\n\t{0,0,255,128},\n\t{255,0,0,128},\n\t{0,255,0,128},\n\t{0,0,255,128},\n\t{255,0,0,128},\n\t{0,255,0,128},\n\t{0,0,255,128},\n};\n\n\n/*\n===============\nUpload32\n\n===============\n*/\nextern qboolean charSet;\nstatic void Upload32( unsigned *data, \n\t\t\t\t\t\t  int width, int height, \n\t\t\t\t\t\t  qboolean mipmap, \n\t\t\t\t\t\t  qboolean picmip, \n\t\t\t\t\t\t\tqboolean lightMap,\n\t\t\t\t\t\t  int *format, \n\t\t\t\t\t\t  int *pUploadWidth, int *pUploadHeight )\n{\n\tint\t\t\tsamples;\n\tunsigned\t*scaledBuffer = NULL;\n\tunsigned\t*resampledBuffer = NULL;\n\tint\t\t\tscaled_width, scaled_height;\n\tint\t\t\ti, c;\n\tbyte\t\t*scan;\n\tGLenum\t\tinternalFormat = GL_RGB;\n\tfloat\t\trMax = 0, gMax = 0, bMax = 0;\n\n\t//\n\t// convert to exact power of 2 sizes\n\t//\n\tfor (scaled_width = 1 ; scaled_width < width ; scaled_width<<=1)\n\t\t;\n\tfor (scaled_height = 1 ; scaled_height < height ; scaled_height<<=1)\n\t\t;\n\tif ( r_roundImagesDown->integer && scaled_width > width )\n\t\tscaled_width >>= 1;\n\tif ( r_roundImagesDown->integer && scaled_height > height )\n\t\tscaled_height >>= 1;\n\n\tif ( scaled_width != width || scaled_height != height ) {\n\t\tresampledBuffer = ri.Hunk_AllocateTempMemory( scaled_width * scaled_height * 4 );\n\t\tResampleTexture (data, width, height, resampledBuffer, scaled_width, scaled_height);\n\t\tdata = resampledBuffer;\n\t\twidth = scaled_width;\n\t\theight = scaled_height;\n\t}\n\n\t//\n\t// perform optional picmip operation\n\t//\n\tif ( picmip ) {\n\t\tscaled_width >>= r_picmip->integer;\n\t\tscaled_height >>= r_picmip->integer;\n\t}\n\n\t//\n\t// clamp to minimum size\n\t//\n\tif (scaled_width < 1) {\n\t\tscaled_width = 1;\n\t}\n\tif (scaled_height < 1) {\n\t\tscaled_height = 1;\n\t}\n\n\t//\n\t// clamp to the current upper OpenGL limit\n\t// scale both axis down equally so we don't have to\n\t// deal with a half mip resampling\n\t//\n\twhile ( scaled_width > glConfig.maxTextureSize\n\t\t|| scaled_height > glConfig.maxTextureSize ) {\n\t\tscaled_width >>= 1;\n\t\tscaled_height >>= 1;\n\t}\n\n\tscaledBuffer = ri.Hunk_AllocateTempMemory( sizeof( unsigned ) * scaled_width * scaled_height );\n\n\t//\n\t// scan the texture for each channel's max values\n\t// and verify if the alpha channel is being used or not\n\t//\n\tc = width*height;\n\tscan = ((byte *)data);\n\tsamples = 3;\n\tif (!lightMap) {\n\t\tfor ( i = 0; i < c; i++ )\n\t\t{\n\t\t\tif ( scan[i*4+0] > rMax )\n\t\t\t{\n\t\t\t\trMax = scan[i*4+0];\n\t\t\t}\n\t\t\tif ( scan[i*4+1] > gMax )\n\t\t\t{\n\t\t\t\tgMax = scan[i*4+1];\n\t\t\t}\n\t\t\tif ( scan[i*4+2] > bMax )\n\t\t\t{\n\t\t\t\tbMax = scan[i*4+2];\n\t\t\t}\n\t\t\tif ( scan[i*4 + 3] != 255 ) \n\t\t\t{\n\t\t\t\tsamples = 4;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t// select proper internal format\n\t\tif ( samples == 3 )\n\t\t{\n\t\t\tif ( glConfig.textureCompression == TC_S3TC )\n\t\t\t{\n\t\t\t\tinternalFormat = GL_RGB4_S3TC;\n\t\t\t}\n\t\t\telse if ( r_texturebits->integer == 16 )\n\t\t\t{\n\t\t\t\tinternalFormat = GL_RGB5;\n\t\t\t}\n\t\t\telse if ( r_texturebits->integer == 32 )\n\t\t\t{\n\t\t\t\tinternalFormat = GL_RGB8;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tinternalFormat = 3;\n\t\t\t}\n\t\t}\n\t\telse if ( samples == 4 )\n\t\t{\n\t\t\tif ( r_texturebits->integer == 16 )\n\t\t\t{\n\t\t\t\tinternalFormat = GL_RGBA4;\n\t\t\t}\n\t\t\telse if ( r_texturebits->integer == 32 )\n\t\t\t{\n\t\t\t\tinternalFormat = GL_RGBA8;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tinternalFormat = 4;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tinternalFormat = 3;\n\t}\n\t// copy or resample data as appropriate for first MIP level\n\tif ( ( scaled_width == width ) && \n\t\t( scaled_height == height ) ) {\n\t\tif (!mipmap)\n\t\t{\n\t\t\tqglTexImage2D (GL_TEXTURE_2D, 0, internalFormat, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);\n\t\t\t*pUploadWidth = scaled_width;\n\t\t\t*pUploadHeight = scaled_height;\n\t\t\t*format = internalFormat;\n\n\t\t\tgoto done;\n\t\t}\n\t\tCom_Memcpy (scaledBuffer, data, width*height*4);\n\t}\n\telse\n\t{\n\t\t// use the normal mip-mapping function to go down from here\n\t\twhile ( width > scaled_width || height > scaled_height ) {\n\t\t\tR_MipMap( (byte *)data, width, height );\n\t\t\twidth >>= 1;\n\t\t\theight >>= 1;\n\t\t\tif ( width < 1 ) {\n\t\t\t\twidth = 1;\n\t\t\t}\n\t\t\tif ( height < 1 ) {\n\t\t\t\theight = 1;\n\t\t\t}\n\t\t}\n\t\tCom_Memcpy( scaledBuffer, data, width * height * 4 );\n\t}\n\n\tR_LightScaleTexture (scaledBuffer, scaled_width, scaled_height, !mipmap );\n\n\t*pUploadWidth = scaled_width;\n\t*pUploadHeight = scaled_height;\n\t*format = internalFormat;\n\n\tqglTexImage2D (GL_TEXTURE_2D, 0, internalFormat, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, scaledBuffer );\n\n\tif (mipmap)\n\t{\n\t\tint\t\tmiplevel;\n\n\t\tmiplevel = 0;\n\t\twhile (scaled_width > 1 || scaled_height > 1)\n\t\t{\n\t\t\tR_MipMap( (byte *)scaledBuffer, scaled_width, scaled_height );\n\t\t\tscaled_width >>= 1;\n\t\t\tscaled_height >>= 1;\n\t\t\tif (scaled_width < 1)\n\t\t\t\tscaled_width = 1;\n\t\t\tif (scaled_height < 1)\n\t\t\t\tscaled_height = 1;\n\t\t\tmiplevel++;\n\n\t\t\tif ( r_colorMipLevels->integer ) {\n\t\t\t\tR_BlendOverTexture( (byte *)scaledBuffer, scaled_width * scaled_height, mipBlendColors[miplevel] );\n\t\t\t}\n\n\t\t\tqglTexImage2D (GL_TEXTURE_2D, miplevel, internalFormat, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, scaledBuffer );\n\t\t}\n\t}\ndone:\n\n\tif (mipmap)\n\t{\n\t\tqglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);\n\t\tqglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);\n\t}\n\telse\n\t{\n\t\tqglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );\n\t\tqglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );\n\t}\n\n\tGL_CheckErrors();\n\n\tif ( scaledBuffer != 0 )\n\t\tri.Hunk_FreeTempMemory( scaledBuffer );\n\tif ( resampledBuffer != 0 )\n\t\tri.Hunk_FreeTempMemory( resampledBuffer );\n}\n\n\n/*\n================\nR_CreateImage\n\nThis is the only way any image_t are created\n================\n*/\nimage_t *R_CreateImage( const char *name, const byte *pic, int width, int height, \n\t\t\t\t\t   qboolean mipmap, qboolean allowPicmip, int glWrapClampMode ) {\n\timage_t\t\t*image;\n\tqboolean\tisLightmap = qfalse;\n\tlong\t\thash;\n\n\tif (strlen(name) >= MAX_QPATH ) {\n\t\tri.Error (ERR_DROP, \"R_CreateImage: \\\"%s\\\" is too long\\n\", name);\n\t}\n\tif ( !strncmp( name, \"*lightmap\", 9 ) ) {\n\t\tisLightmap = qtrue;\n\t}\n\n\tif ( tr.numImages == MAX_DRAWIMAGES ) {\n\t\tri.Error( ERR_DROP, \"R_CreateImage: MAX_DRAWIMAGES hit\\n\");\n\t}\n\n\timage = tr.images[tr.numImages] = ri.Hunk_Alloc( sizeof( image_t ), h_low );\n\timage->texnum = 1024 + tr.numImages;\n\ttr.numImages++;\n\n\timage->mipmap = mipmap;\n\timage->allowPicmip = allowPicmip;\n\n\tstrcpy (image->imgName, name);\n\n\timage->width = width;\n\timage->height = height;\n\timage->wrapClampMode = glWrapClampMode;\n\n\t// lightmaps are always allocated on TMU 1\n\tif ( qglActiveTextureARB && isLightmap ) {\n\t\timage->TMU = 1;\n\t} else {\n\t\timage->TMU = 0;\n\t}\n\n\tif ( qglActiveTextureARB ) {\n\t\tGL_SelectTexture( image->TMU );\n\t}\n\n\tGL_Bind(image);\n\n\tUpload32( (unsigned *)pic, image->width, image->height, \n\t\t\t\t\t\t\t\timage->mipmap,\n\t\t\t\t\t\t\t\tallowPicmip,\n\t\t\t\t\t\t\t\tisLightmap,\n\t\t\t\t\t\t\t\t&image->internalFormat,\n\t\t\t\t\t\t\t\t&image->uploadWidth,\n\t\t\t\t\t\t\t\t&image->uploadHeight );\n\n\tqglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, glWrapClampMode );\n\tqglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, glWrapClampMode );\n\n\tqglBindTexture( GL_TEXTURE_2D, 0 );\n\n\tif ( image->TMU == 1 ) {\n\t\tGL_SelectTexture( 0 );\n\t}\n\n\thash = generateHashValue(name);\n\timage->next = hashTable[hash];\n\thashTable[hash] = image;\n\n\treturn image;\n}\n\n\n/*\n=========================================================\n\nBMP LOADING\n\n=========================================================\n*/\ntypedef struct\n{\n\tchar id[2];\n\tunsigned long fileSize;\n\tunsigned long reserved0;\n\tunsigned long bitmapDataOffset;\n\tunsigned long bitmapHeaderSize;\n\tunsigned long width;\n\tunsigned long height;\n\tunsigned short planes;\n\tunsigned short bitsPerPixel;\n\tunsigned long compression;\n\tunsigned long bitmapDataSize;\n\tunsigned long hRes;\n\tunsigned long vRes;\n\tunsigned long colors;\n\tunsigned long importantColors;\n\tunsigned char palette[256][4];\n} BMPHeader_t;\n\nstatic void LoadBMP( const char *name, byte **pic, int *width, int *height )\n{\n\tint\t\tcolumns, rows, numPixels;\n\tbyte\t*pixbuf;\n\tint\t\trow, column;\n\tbyte\t*buf_p;\n\tbyte\t*buffer;\n\tint\t\tlength;\n\tBMPHeader_t bmpHeader;\n\tbyte\t\t*bmpRGBA;\n\n\t*pic = NULL;\n\n\t//\n\t// load the file\n\t//\n\tlength = ri.FS_ReadFile( ( char * ) name, (void **)&buffer);\n\tif (!buffer) {\n\t\treturn;\n\t}\n\n\tbuf_p = buffer;\n\n\tbmpHeader.id[0] = *buf_p++;\n\tbmpHeader.id[1] = *buf_p++;\n\tbmpHeader.fileSize = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.reserved0 = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.bitmapDataOffset = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.bitmapHeaderSize = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.width = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.height = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.planes = LittleShort( * ( short * ) buf_p );\n\tbuf_p += 2;\n\tbmpHeader.bitsPerPixel = LittleShort( * ( short * ) buf_p );\n\tbuf_p += 2;\n\tbmpHeader.compression = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.bitmapDataSize = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.hRes = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.vRes = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.colors = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.importantColors = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\n\tCom_Memcpy( bmpHeader.palette, buf_p, sizeof( bmpHeader.palette ) );\n\n\tif ( bmpHeader.bitsPerPixel == 8 )\n\t\tbuf_p += 1024;\n\n\tif ( bmpHeader.id[0] != 'B' && bmpHeader.id[1] != 'M' ) \n\t{\n\t\tri.Error( ERR_DROP, \"LoadBMP: only Windows-style BMP files supported (%s)\\n\", name );\n\t}\n\tif ( bmpHeader.fileSize != length )\n\t{\n\t\tri.Error( ERR_DROP, \"LoadBMP: header size does not match file size (%d vs. %d) (%s)\\n\", bmpHeader.fileSize, length, name );\n\t}\n\tif ( bmpHeader.compression != 0 )\n\t{\n\t\tri.Error( ERR_DROP, \"LoadBMP: only uncompressed BMP files supported (%s)\\n\", name );\n\t}\n\tif ( bmpHeader.bitsPerPixel < 8 )\n\t{\n\t\tri.Error( ERR_DROP, \"LoadBMP: monochrome and 4-bit BMP files not supported (%s)\\n\", name );\n\t}\n\n\tcolumns = bmpHeader.width;\n\trows = bmpHeader.height;\n\tif ( rows < 0 )\n\t\trows = -rows;\n\tnumPixels = columns * rows;\n\n\tif ( width ) \n\t\t*width = columns;\n\tif ( height )\n\t\t*height = rows;\n\n\tbmpRGBA = ri.Malloc( numPixels * 4 );\n\t*pic = bmpRGBA;\n\n\n\tfor ( row = rows-1; row >= 0; row-- )\n\t{\n\t\tpixbuf = bmpRGBA + row*columns*4;\n\n\t\tfor ( column = 0; column < columns; column++ )\n\t\t{\n\t\t\tunsigned char red, green, blue, alpha;\n\t\t\tint palIndex;\n\t\t\tunsigned short shortPixel;\n\n\t\t\tswitch ( bmpHeader.bitsPerPixel )\n\t\t\t{\n\t\t\tcase 8:\n\t\t\t\tpalIndex = *buf_p++;\n\t\t\t\t*pixbuf++ = bmpHeader.palette[palIndex][2];\n\t\t\t\t*pixbuf++ = bmpHeader.palette[palIndex][1];\n\t\t\t\t*pixbuf++ = bmpHeader.palette[palIndex][0];\n\t\t\t\t*pixbuf++ = 0xff;\n\t\t\t\tbreak;\n\t\t\tcase 16:\n\t\t\t\tshortPixel = * ( unsigned short * ) pixbuf;\n\t\t\t\tpixbuf += 2;\n\t\t\t\t*pixbuf++ = ( shortPixel & ( 31 << 10 ) ) >> 7;\n\t\t\t\t*pixbuf++ = ( shortPixel & ( 31 << 5 ) ) >> 2;\n\t\t\t\t*pixbuf++ = ( shortPixel & ( 31 ) ) << 3;\n\t\t\t\t*pixbuf++ = 0xff;\n\t\t\t\tbreak;\n\n\t\t\tcase 24:\n\t\t\t\tblue = *buf_p++;\n\t\t\t\tgreen = *buf_p++;\n\t\t\t\tred = *buf_p++;\n\t\t\t\t*pixbuf++ = red;\n\t\t\t\t*pixbuf++ = green;\n\t\t\t\t*pixbuf++ = blue;\n\t\t\t\t*pixbuf++ = 255;\n\t\t\t\tbreak;\n\t\t\tcase 32:\n\t\t\t\tblue = *buf_p++;\n\t\t\t\tgreen = *buf_p++;\n\t\t\t\tred = *buf_p++;\n\t\t\t\talpha = *buf_p++;\n\t\t\t\t*pixbuf++ = red;\n\t\t\t\t*pixbuf++ = green;\n\t\t\t\t*pixbuf++ = blue;\n\t\t\t\t*pixbuf++ = alpha;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tri.Error( ERR_DROP, \"LoadBMP: illegal pixel_size '%d' in file '%s'\\n\", bmpHeader.bitsPerPixel, name );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tri.FS_FreeFile( buffer );\n\n}\n\n\n/*\n=================================================================\n\nPCX LOADING\n\n=================================================================\n*/\n\n\n/*\n==============\nLoadPCX\n==============\n*/\nstatic void LoadPCX ( const char *filename, byte **pic, byte **palette, int *width, int *height)\n{\n\tbyte\t*raw;\n\tpcx_t\t*pcx;\n\tint\t\tx, y;\n\tint\t\tlen;\n\tint\t\tdataByte, runLength;\n\tbyte\t*out, *pix;\n\tint\t\txmax, ymax;\n\n\t*pic = NULL;\n\t*palette = NULL;\n\n\t//\n\t// load the file\n\t//\n\tlen = ri.FS_ReadFile( ( char * ) filename, (void **)&raw);\n\tif (!raw) {\n\t\treturn;\n\t}\n\n\t//\n\t// parse the PCX file\n\t//\n\tpcx = (pcx_t *)raw;\n\traw = &pcx->data;\n\n  \txmax = LittleShort(pcx->xmax);\n    ymax = LittleShort(pcx->ymax);\n\n\tif (pcx->manufacturer != 0x0a\n\t\t|| pcx->version != 5\n\t\t|| pcx->encoding != 1\n\t\t|| pcx->bits_per_pixel != 8\n\t\t|| xmax >= 1024\n\t\t|| ymax >= 1024)\n\t{\n\t\tri.Printf (PRINT_ALL, \"Bad pcx file %s (%i x %i) (%i x %i)\\n\", filename, xmax+1, ymax+1, pcx->xmax, pcx->ymax);\n\t\treturn;\n\t}\n\n\tout = ri.Malloc ( (ymax+1) * (xmax+1) );\n\n\t*pic = out;\n\n\tpix = out;\n\n\tif (palette)\n\t{\n\t\t*palette = ri.Malloc(768);\n\t\tCom_Memcpy (*palette, (byte *)pcx + len - 768, 768);\n\t}\n\n\tif (width)\n\t\t*width = xmax+1;\n\tif (height)\n\t\t*height = ymax+1;\n// FIXME: use bytes_per_line here?\n\n\tfor (y=0 ; y<=ymax ; y++, pix += xmax+1)\n\t{\n\t\tfor (x=0 ; x<=xmax ; )\n\t\t{\n\t\t\tdataByte = *raw++;\n\n\t\t\tif((dataByte & 0xC0) == 0xC0)\n\t\t\t{\n\t\t\t\trunLength = dataByte & 0x3F;\n\t\t\t\tdataByte = *raw++;\n\t\t\t}\n\t\t\telse\n\t\t\t\trunLength = 1;\n\n\t\t\twhile(runLength-- > 0)\n\t\t\t\tpix[x++] = dataByte;\n\t\t}\n\n\t}\n\n\tif ( raw - (byte *)pcx > len)\n\t{\n\t\tri.Printf (PRINT_DEVELOPER, \"PCX file %s was malformed\", filename);\n\t\tri.Free (*pic);\n\t\t*pic = NULL;\n\t}\n\n\tri.FS_FreeFile (pcx);\n}\n\n\n/*\n==============\nLoadPCX32\n==============\n*/\nstatic void LoadPCX32 ( const char *filename, byte **pic, int *width, int *height) {\n\tbyte\t*palette;\n\tbyte\t*pic8;\n\tint\t\ti, c, p;\n\tbyte\t*pic32;\n\n\tLoadPCX (filename, &pic8, &palette, width, height);\n\tif (!pic8) {\n\t\t*pic = NULL;\n\t\treturn;\n\t}\n\n\tc = (*width) * (*height);\n\tpic32 = *pic = ri.Malloc(4 * c );\n\tfor (i = 0 ; i < c ; i++) {\n\t\tp = pic8[i];\n\t\tpic32[0] = palette[p*3];\n\t\tpic32[1] = palette[p*3 + 1];\n\t\tpic32[2] = palette[p*3 + 2];\n\t\tpic32[3] = 255;\n\t\tpic32 += 4;\n\t}\n\n\tri.Free (pic8);\n\tri.Free (palette);\n}\n\n/*\n=========================================================\n\nTARGA LOADING\n\n=========================================================\n*/\n\n/*\n=============\nLoadTGA\n=============\n*/\nstatic void LoadTGA ( const char *name, byte **pic, int *width, int *height)\n{\n\tint\t\tcolumns, rows, numPixels;\n\tbyte\t*pixbuf;\n\tint\t\trow, column;\n\tbyte\t*buf_p;\n\tbyte\t*buffer;\n\tTargaHeader\ttarga_header;\n\tbyte\t\t*targa_rgba;\n\n\t*pic = NULL;\n\n\t//\n\t// load the file\n\t//\n\tri.FS_ReadFile ( ( char * ) name, (void **)&buffer);\n\tif (!buffer) {\n\t\treturn;\n\t}\n\n\tbuf_p = buffer;\n\n\ttarga_header.id_length = *buf_p++;\n\ttarga_header.colormap_type = *buf_p++;\n\ttarga_header.image_type = *buf_p++;\n\t\n\ttarga_header.colormap_index = LittleShort ( *(short *)buf_p );\n\tbuf_p += 2;\n\ttarga_header.colormap_length = LittleShort ( *(short *)buf_p );\n\tbuf_p += 2;\n\ttarga_header.colormap_size = *buf_p++;\n\ttarga_header.x_origin = LittleShort ( *(short *)buf_p );\n\tbuf_p += 2;\n\ttarga_header.y_origin = LittleShort ( *(short *)buf_p );\n\tbuf_p += 2;\n\ttarga_header.width = LittleShort ( *(short *)buf_p );\n\tbuf_p += 2;\n\ttarga_header.height = LittleShort ( *(short *)buf_p );\n\tbuf_p += 2;\n\ttarga_header.pixel_size = *buf_p++;\n\ttarga_header.attributes = *buf_p++;\n\n\tif (targa_header.image_type!=2 \n\t\t&& targa_header.image_type!=10\n\t\t&& targa_header.image_type != 3 ) \n\t{\n\t\tri.Error (ERR_DROP, \"LoadTGA: Only type 2 (RGB), 3 (gray), and 10 (RGB) TGA images supported\\n\");\n\t}\n\n\tif ( targa_header.colormap_type != 0 )\n\t{\n\t\tri.Error( ERR_DROP, \"LoadTGA: colormaps not supported\\n\" );\n\t}\n\n\tif ( ( targa_header.pixel_size != 32 && targa_header.pixel_size != 24 ) && targa_header.image_type != 3 )\n\t{\n\t\tri.Error (ERR_DROP, \"LoadTGA: Only 32 or 24 bit images supported (no colormaps)\\n\");\n\t}\n\n\tcolumns = targa_header.width;\n\trows = targa_header.height;\n\tnumPixels = columns * rows;\n\n\tif (width)\n\t\t*width = columns;\n\tif (height)\n\t\t*height = rows;\n\n\ttarga_rgba = ri.Malloc (numPixels*4);\n\t*pic = targa_rgba;\n\n\tif (targa_header.id_length != 0)\n\t\tbuf_p += targa_header.id_length;  // skip TARGA image comment\n\t\n\tif ( targa_header.image_type==2 || targa_header.image_type == 3 )\n\t{ \n\t\t// Uncompressed RGB or gray scale image\n\t\tfor(row=rows-1; row>=0; row--) \n\t\t{\n\t\t\tpixbuf = targa_rgba + row*columns*4;\n\t\t\tfor(column=0; column<columns; column++) \n\t\t\t{\n\t\t\t\tunsigned char red,green,blue,alphabyte;\n\t\t\t\tswitch (targa_header.pixel_size) \n\t\t\t\t{\n\t\t\t\t\t\n\t\t\t\tcase 8:\n\t\t\t\t\tblue = *buf_p++;\n\t\t\t\t\tgreen = blue;\n\t\t\t\t\tred = blue;\n\t\t\t\t\t*pixbuf++ = red;\n\t\t\t\t\t*pixbuf++ = green;\n\t\t\t\t\t*pixbuf++ = blue;\n\t\t\t\t\t*pixbuf++ = 255;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 24:\n\t\t\t\t\tblue = *buf_p++;\n\t\t\t\t\tgreen = *buf_p++;\n\t\t\t\t\tred = *buf_p++;\n\t\t\t\t\t*pixbuf++ = red;\n\t\t\t\t\t*pixbuf++ = green;\n\t\t\t\t\t*pixbuf++ = blue;\n\t\t\t\t\t*pixbuf++ = 255;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 32:\n\t\t\t\t\tblue = *buf_p++;\n\t\t\t\t\tgreen = *buf_p++;\n\t\t\t\t\tred = *buf_p++;\n\t\t\t\t\talphabyte = *buf_p++;\n\t\t\t\t\t*pixbuf++ = red;\n\t\t\t\t\t*pixbuf++ = green;\n\t\t\t\t\t*pixbuf++ = blue;\n\t\t\t\t\t*pixbuf++ = alphabyte;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tri.Error( ERR_DROP, \"LoadTGA: illegal pixel_size '%d' in file '%s'\\n\", targa_header.pixel_size, name );\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\telse if (targa_header.image_type==10) {   // Runlength encoded RGB images\n\t\tunsigned char red,green,blue,alphabyte,packetHeader,packetSize,j;\n\n\t\tred = 0;\n\t\tgreen = 0;\n\t\tblue = 0;\n\t\talphabyte = 0xff;\n\n\t\tfor(row=rows-1; row>=0; row--) {\n\t\t\tpixbuf = targa_rgba + row*columns*4;\n\t\t\tfor(column=0; column<columns; ) {\n\t\t\t\tpacketHeader= *buf_p++;\n\t\t\t\tpacketSize = 1 + (packetHeader & 0x7f);\n\t\t\t\tif (packetHeader & 0x80) {        // run-length packet\n\t\t\t\t\tswitch (targa_header.pixel_size) {\n\t\t\t\t\t\tcase 24:\n\t\t\t\t\t\t\t\tblue = *buf_p++;\n\t\t\t\t\t\t\t\tgreen = *buf_p++;\n\t\t\t\t\t\t\t\tred = *buf_p++;\n\t\t\t\t\t\t\t\talphabyte = 255;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 32:\n\t\t\t\t\t\t\t\tblue = *buf_p++;\n\t\t\t\t\t\t\t\tgreen = *buf_p++;\n\t\t\t\t\t\t\t\tred = *buf_p++;\n\t\t\t\t\t\t\t\talphabyte = *buf_p++;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tri.Error( ERR_DROP, \"LoadTGA: illegal pixel_size '%d' in file '%s'\\n\", targa_header.pixel_size, name );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\n\t\t\t\t\tfor(j=0;j<packetSize;j++) {\n\t\t\t\t\t\t*pixbuf++=red;\n\t\t\t\t\t\t*pixbuf++=green;\n\t\t\t\t\t\t*pixbuf++=blue;\n\t\t\t\t\t\t*pixbuf++=alphabyte;\n\t\t\t\t\t\tcolumn++;\n\t\t\t\t\t\tif (column==columns) { // run spans across rows\n\t\t\t\t\t\t\tcolumn=0;\n\t\t\t\t\t\t\tif (row>0)\n\t\t\t\t\t\t\t\trow--;\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tgoto breakOut;\n\t\t\t\t\t\t\tpixbuf = targa_rgba + row*columns*4;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {                            // non run-length packet\n\t\t\t\t\tfor(j=0;j<packetSize;j++) {\n\t\t\t\t\t\tswitch (targa_header.pixel_size) {\n\t\t\t\t\t\t\tcase 24:\n\t\t\t\t\t\t\t\t\tblue = *buf_p++;\n\t\t\t\t\t\t\t\t\tgreen = *buf_p++;\n\t\t\t\t\t\t\t\t\tred = *buf_p++;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = red;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = green;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = blue;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = 255;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 32:\n\t\t\t\t\t\t\t\t\tblue = *buf_p++;\n\t\t\t\t\t\t\t\t\tgreen = *buf_p++;\n\t\t\t\t\t\t\t\t\tred = *buf_p++;\n\t\t\t\t\t\t\t\t\talphabyte = *buf_p++;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = red;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = green;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = blue;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = alphabyte;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tri.Error( ERR_DROP, \"LoadTGA: illegal pixel_size '%d' in file '%s'\\n\", targa_header.pixel_size, name );\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcolumn++;\n\t\t\t\t\t\tif (column==columns) { // pixel packet run spans across rows\n\t\t\t\t\t\t\tcolumn=0;\n\t\t\t\t\t\t\tif (row>0)\n\t\t\t\t\t\t\t\trow--;\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tgoto breakOut;\n\t\t\t\t\t\t\tpixbuf = targa_rgba + row*columns*4;\n\t\t\t\t\t\t}\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreakOut:;\n\t\t}\n\t}\n\n#if 0 \n  // TTimo: this is the chunk of code to ensure a behavior that meets TGA specs \n  // bk0101024 - fix from Leonardo\n  // bit 5 set => top-down\n  if (targa_header.attributes & 0x20) {\n    unsigned char *flip = (unsigned char*)malloc (columns*4);\n    unsigned char *src, *dst;\n\n    for (row = 0; row < rows/2; row++) {\n      src = targa_rgba + row * 4 * columns;\n      dst = targa_rgba + (rows - row - 1) * 4 * columns;\n\n      memcpy (flip, src, columns*4);\n      memcpy (src, dst, columns*4);\n      memcpy (dst, flip, columns*4);\n    }\n    free (flip);\n  }\n#endif\n  // instead we just print a warning\n  if (targa_header.attributes & 0x20) {\n    ri.Printf( PRINT_WARNING, \"WARNING: '%s' TGA file header declares top-down image, ignoring\\n\", name);\n  }\n\n  ri.FS_FreeFile (buffer);\n}\n\nstatic void LoadJPG( const char *filename, unsigned char **pic, int *width, int *height ) {\n  /* This struct contains the JPEG decompression parameters and pointers to\n   * working space (which is allocated as needed by the JPEG library).\n   */\n  struct jpeg_decompress_struct cinfo;\n  /* We use our private extension JPEG error handler.\n   * Note that this struct must live as long as the main JPEG parameter\n   * struct, to avoid dangling-pointer problems.\n   */\n  /* This struct represents a JPEG error handler.  It is declared separately\n   * because applications often want to supply a specialized error handler\n   * (see the second half of this file for an example).  But here we just\n   * take the easy way out and use the standard error handler, which will\n   * print a message on stderr and call exit() if compression fails.\n   * Note that this struct must live as long as the main JPEG parameter\n   * struct, to avoid dangling-pointer problems.\n   */\n  struct jpeg_error_mgr jerr;\n  /* More stuff */\n  JSAMPARRAY buffer;\t\t/* Output row buffer */\n  int row_stride;\t\t/* physical row width in output buffer */\n  unsigned char *out;\n  byte\t*fbuffer;\n  byte  *bbuf;\n\n  /* In this example we want to open the input file before doing anything else,\n   * so that the setjmp() error recovery below can assume the file is open.\n   * VERY IMPORTANT: use \"b\" option to fopen() if you are on a machine that\n   * requires it in order to read binary files.\n   */\n\n  ri.FS_ReadFile ( ( char * ) filename, (void **)&fbuffer);\n  if (!fbuffer) {\n\treturn;\n  }\n\n  /* Step 1: allocate and initialize JPEG decompression object */\n\n  /* We have to set up the error handler first, in case the initialization\n   * step fails.  (Unlikely, but it could happen if you are out of memory.)\n   * This routine fills in the contents of struct jerr, and returns jerr's\n   * address which we place into the link field in cinfo.\n   */\n  cinfo.err = jpeg_std_error(&jerr);\n\n  /* Now we can initialize the JPEG decompression object. */\n  jpeg_create_decompress(&cinfo);\n\n  /* Step 2: specify data source (eg, a file) */\n\n  jpeg_stdio_src(&cinfo, fbuffer);\n\n  /* Step 3: read file parameters with jpeg_read_header() */\n\n  (void) jpeg_read_header(&cinfo, TRUE);\n  /* We can ignore the return value from jpeg_read_header since\n   *   (a) suspension is not possible with the stdio data source, and\n   *   (b) we passed TRUE to reject a tables-only JPEG file as an error.\n   * See libjpeg.doc for more info.\n   */\n\n  /* Step 4: set parameters for decompression */\n\n  /* In this example, we don't need to change any of the defaults set by\n   * jpeg_read_header(), so we do nothing here.\n   */\n\n  /* Step 5: Start decompressor */\n\n  (void) jpeg_start_decompress(&cinfo);\n  /* We can ignore the return value since suspension is not possible\n   * with the stdio data source.\n   */\n\n  /* We may need to do some setup of our own at this point before reading\n   * the data.  After jpeg_start_decompress() we have the correct scaled\n   * output image dimensions available, as well as the output colormap\n   * if we asked for color quantization.\n   * In this example, we need to make an output work buffer of the right size.\n   */ \n  /* JSAMPLEs per row in output buffer */\n  row_stride = cinfo.output_width * cinfo.output_components;\n\n  out = ri.Malloc(cinfo.output_width*cinfo.output_height*cinfo.output_components);\n\n  *pic = out;\n  *width = cinfo.output_width;\n  *height = cinfo.output_height;\n\n  /* Step 6: while (scan lines remain to be read) */\n  /*           jpeg_read_scanlines(...); */\n\n  /* Here we use the library's state variable cinfo.output_scanline as the\n   * loop counter, so that we don't have to keep track ourselves.\n   */\n  while (cinfo.output_scanline < cinfo.output_height) {\n    /* jpeg_read_scanlines expects an array of pointers to scanlines.\n     * Here the array is only one element long, but you could ask for\n     * more than one scanline at a time if that's more convenient.\n     */\n\tbbuf = ((out+(row_stride*cinfo.output_scanline)));\n\tbuffer = &bbuf;\n    (void) jpeg_read_scanlines(&cinfo, buffer, 1);\n  }\n\n  // clear all the alphas to 255\n  {\n\t  int\ti, j;\n\t\tbyte\t*buf;\n\n\t\tbuf = *pic;\n\n\t  j = cinfo.output_width * cinfo.output_height * 4;\n\t  for ( i = 3 ; i < j ; i+=4 ) {\n\t\t  buf[i] = 255;\n\t  }\n  }\n\n  /* Step 7: Finish decompression */\n\n  (void) jpeg_finish_decompress(&cinfo);\n  /* We can ignore the return value since suspension is not possible\n   * with the stdio data source.\n   */\n\n  /* Step 8: Release JPEG decompression object */\n\n  /* This is an important step since it will release a good deal of memory. */\n  jpeg_destroy_decompress(&cinfo);\n\n  /* After finish_decompress, we can close the input file.\n   * Here we postpone it until after no more JPEG errors are possible,\n   * so as to simplify the setjmp error logic above.  (Actually, I don't\n   * think that jpeg_destroy can do an error exit, but why assume anything...)\n   */\n  ri.FS_FreeFile (fbuffer);\n\n  /* At this point you may want to check to see whether any corrupt-data\n   * warnings occurred (test whether jerr.pub.num_warnings is nonzero).\n   */\n\n  /* And we're done! */\n}\n\n\n/* Expanded data destination object for stdio output */\n\ntypedef struct {\n  struct jpeg_destination_mgr pub; /* public fields */\n\n  byte* outfile;\t\t/* target stream */\n  int\tsize;\n} my_destination_mgr;\n\ntypedef my_destination_mgr * my_dest_ptr;\n\n\n/*\n * Initialize destination --- called by jpeg_start_compress\n * before any data is actually written.\n */\n\nvoid init_destination (j_compress_ptr cinfo)\n{\n  my_dest_ptr dest = (my_dest_ptr) cinfo->dest;\n\n  dest->pub.next_output_byte = dest->outfile;\n  dest->pub.free_in_buffer = dest->size;\n}\n\n\n/*\n * Empty the output buffer --- called whenever buffer fills up.\n *\n * In typical applications, this should write the entire output buffer\n * (ignoring the current state of next_output_byte & free_in_buffer),\n * reset the pointer & count to the start of the buffer, and return TRUE\n * indicating that the buffer has been dumped.\n *\n * In applications that need to be able to suspend compression due to output\n * overrun, a FALSE return indicates that the buffer cannot be emptied now.\n * In this situation, the compressor will return to its caller (possibly with\n * an indication that it has not accepted all the supplied scanlines).  The\n * application should resume compression after it has made more room in the\n * output buffer.  Note that there are substantial restrictions on the use of\n * suspension --- see the documentation.\n *\n * When suspending, the compressor will back up to a convenient restart point\n * (typically the start of the current MCU). next_output_byte & free_in_buffer\n * indicate where the restart point will be if the current call returns FALSE.\n * Data beyond this point will be regenerated after resumption, so do not\n * write it out when emptying the buffer externally.\n */\n\nboolean empty_output_buffer (j_compress_ptr cinfo)\n{\n  return TRUE;\n}\n\n\n/*\n * Compression initialization.\n * Before calling this, all parameters and a data destination must be set up.\n *\n * We require a write_all_tables parameter as a failsafe check when writing\n * multiple datastreams from the same compression object.  Since prior runs\n * will have left all the tables marked sent_table=TRUE, a subsequent run\n * would emit an abbreviated stream (no tables) by default.  This may be what\n * is wanted, but for safety's sake it should not be the default behavior:\n * programmers should have to make a deliberate choice to emit abbreviated\n * images.  Therefore the documentation and examples should encourage people\n * to pass write_all_tables=TRUE; then it will take active thought to do the\n * wrong thing.\n */\n\nGLOBAL void\njpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables)\n{\n  if (cinfo->global_state != CSTATE_START)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n\n  if (write_all_tables)\n    jpeg_suppress_tables(cinfo, FALSE);\t/* mark all tables to be written */\n\n  /* (Re)initialize error mgr and destination modules */\n  (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);\n  (*cinfo->dest->init_destination) (cinfo);\n  /* Perform master selection of active modules */\n  jinit_compress_master(cinfo);\n  /* Set up for the first pass */\n  (*cinfo->master->prepare_for_pass) (cinfo);\n  /* Ready for application to drive first pass through jpeg_write_scanlines\n   * or jpeg_write_raw_data.\n   */\n  cinfo->next_scanline = 0;\n  cinfo->global_state = (cinfo->raw_data_in ? CSTATE_RAW_OK : CSTATE_SCANNING);\n}\n\n\n/*\n * Write some scanlines of data to the JPEG compressor.\n *\n * The return value will be the number of lines actually written.\n * This should be less than the supplied num_lines only in case that\n * the data destination module has requested suspension of the compressor,\n * or if more than image_height scanlines are passed in.\n *\n * Note: we warn about excess calls to jpeg_write_scanlines() since\n * this likely signals an application programmer error.  However,\n * excess scanlines passed in the last valid call are *silently* ignored,\n * so that the application need not adjust num_lines for end-of-image\n * when using a multiple-scanline buffer.\n */\n\nGLOBAL JDIMENSION\njpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines,\n\t\t      JDIMENSION num_lines)\n{\n  JDIMENSION row_ctr, rows_left;\n\n  if (cinfo->global_state != CSTATE_SCANNING)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  if (cinfo->next_scanline >= cinfo->image_height)\n    WARNMS(cinfo, JWRN_TOO_MUCH_DATA);\n\n  /* Call progress monitor hook if present */\n  if (cinfo->progress != NULL) {\n    cinfo->progress->pass_counter = (long) cinfo->next_scanline;\n    cinfo->progress->pass_limit = (long) cinfo->image_height;\n    (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);\n  }\n\n  /* Give master control module another chance if this is first call to\n   * jpeg_write_scanlines.  This lets output of the frame/scan headers be\n   * delayed so that application can write COM, etc, markers between\n   * jpeg_start_compress and jpeg_write_scanlines.\n   */\n  if (cinfo->master->call_pass_startup)\n    (*cinfo->master->pass_startup) (cinfo);\n\n  /* Ignore any extra scanlines at bottom of image. */\n  rows_left = cinfo->image_height - cinfo->next_scanline;\n  if (num_lines > rows_left)\n    num_lines = rows_left;\n\n  row_ctr = 0;\n  (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, num_lines);\n  cinfo->next_scanline += row_ctr;\n  return row_ctr;\n}\n\n/*\n * Terminate destination --- called by jpeg_finish_compress\n * after all data has been written.  Usually needs to flush buffer.\n *\n * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding\n * application must deal with any cleanup that should happen even\n * for error exit.\n */\n\nstatic int hackSize;\n\nvoid term_destination (j_compress_ptr cinfo)\n{\n  my_dest_ptr dest = (my_dest_ptr) cinfo->dest;\n  size_t datacount = dest->size - dest->pub.free_in_buffer;\n  hackSize = datacount;\n}\n\n\n/*\n * Prepare for output to a stdio stream.\n * The caller must have already opened the stream, and is responsible\n * for closing it after finishing compression.\n */\n\nvoid jpegDest (j_compress_ptr cinfo, byte* outfile, int size)\n{\n  my_dest_ptr dest;\n\n  /* The destination object is made permanent so that multiple JPEG images\n   * can be written to the same file without re-executing jpeg_stdio_dest.\n   * This makes it dangerous to use this manager and a different destination\n   * manager serially with the same JPEG object, because their private object\n   * sizes may be different.  Caveat programmer.\n   */\n  if (cinfo->dest == NULL) {\t/* first time for this JPEG object? */\n    cinfo->dest = (struct jpeg_destination_mgr *)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,\n\t\t\t\t  sizeof(my_destination_mgr));\n  }\n\n  dest = (my_dest_ptr) cinfo->dest;\n  dest->pub.init_destination = init_destination;\n  dest->pub.empty_output_buffer = empty_output_buffer;\n  dest->pub.term_destination = term_destination;\n  dest->outfile = outfile;\n  dest->size = size;\n}\n\nvoid SaveJPG(char * filename, int quality, int image_width, int image_height, unsigned char *image_buffer) {\n  /* This struct contains the JPEG compression parameters and pointers to\n   * working space (which is allocated as needed by the JPEG library).\n   * It is possible to have several such structures, representing multiple\n   * compression/decompression processes, in existence at once.  We refer\n   * to any one struct (and its associated working data) as a \"JPEG object\".\n   */\n  struct jpeg_compress_struct cinfo;\n  /* This struct represents a JPEG error handler.  It is declared separately\n   * because applications often want to supply a specialized error handler\n   * (see the second half of this file for an example).  But here we just\n   * take the easy way out and use the standard error handler, which will\n   * print a message on stderr and call exit() if compression fails.\n   * Note that this struct must live as long as the main JPEG parameter\n   * struct, to avoid dangling-pointer problems.\n   */\n  struct jpeg_error_mgr jerr;\n  /* More stuff */\n  JSAMPROW row_pointer[1];\t/* pointer to JSAMPLE row[s] */\n  int row_stride;\t\t/* physical row width in image buffer */\n  unsigned char *out;\n\n  /* Step 1: allocate and initialize JPEG compression object */\n\n  /* We have to set up the error handler first, in case the initialization\n   * step fails.  (Unlikely, but it could happen if you are out of memory.)\n   * This routine fills in the contents of struct jerr, and returns jerr's\n   * address which we place into the link field in cinfo.\n   */\n  cinfo.err = jpeg_std_error(&jerr);\n  /* Now we can initialize the JPEG compression object. */\n  jpeg_create_compress(&cinfo);\n\n  /* Step 2: specify data destination (eg, a file) */\n  /* Note: steps 2 and 3 can be done in either order. */\n\n  /* Here we use the library-supplied code to send compressed data to a\n   * stdio stream.  You can also write your own code to do something else.\n   * VERY IMPORTANT: use \"b\" option to fopen() if you are on a machine that\n   * requires it in order to write binary files.\n   */\n  out = ri.Hunk_AllocateTempMemory(image_width*image_height*4);\n  jpegDest(&cinfo, out, image_width*image_height*4);\n\n  /* Step 3: set parameters for compression */\n\n  /* First we supply a description of the input image.\n   * Four fields of the cinfo struct must be filled in:\n   */\n  cinfo.image_width = image_width; \t/* image width and height, in pixels */\n  cinfo.image_height = image_height;\n  cinfo.input_components = 4;\t\t/* # of color components per pixel */\n  cinfo.in_color_space = JCS_RGB; \t/* colorspace of input image */\n  /* Now use the library's routine to set default compression parameters.\n   * (You must set at least cinfo.in_color_space before calling this,\n   * since the defaults depend on the source color space.)\n   */\n  jpeg_set_defaults(&cinfo);\n  /* Now you can set any non-default parameters you wish to.\n   * Here we just illustrate the use of quality (quantization table) scaling:\n   */\n  jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */);\n\n  /* Step 4: Start compressor */\n\n  /* TRUE ensures that we will write a complete interchange-JPEG file.\n   * Pass TRUE unless you are very sure of what you're doing.\n   */\n  jpeg_start_compress(&cinfo, TRUE);\n\n  /* Step 5: while (scan lines remain to be written) */\n  /*           jpeg_write_scanlines(...); */\n\n  /* Here we use the library's state variable cinfo.next_scanline as the\n   * loop counter, so that we don't have to keep track ourselves.\n   * To keep things simple, we pass one scanline per call; you can pass\n   * more if you wish, though.\n   */\n  row_stride = image_width * 4;\t/* JSAMPLEs per row in image_buffer */\n\n  while (cinfo.next_scanline < cinfo.image_height) {\n    /* jpeg_write_scanlines expects an array of pointers to scanlines.\n     * Here the array is only one element long, but you could pass\n     * more than one scanline at a time if that's more convenient.\n     */\n    row_pointer[0] = & image_buffer[((cinfo.image_height-1)*row_stride)-cinfo.next_scanline * row_stride];\n    (void) jpeg_write_scanlines(&cinfo, row_pointer, 1);\n  }\n\n  /* Step 6: Finish compression */\n\n  jpeg_finish_compress(&cinfo);\n  /* After finish_compress, we can close the output file. */\n  ri.FS_WriteFile( filename, out, hackSize );\n\n  ri.Hunk_FreeTempMemory(out);\n\n  /* Step 7: release JPEG compression object */\n\n  /* This is an important step since it will release a good deal of memory. */\n  jpeg_destroy_compress(&cinfo);\n\n  /* And we're done! */\n}\n\n//===================================================================\n\n/*\n=================\nR_LoadImage\n\nLoads any of the supported image types into a cannonical\n32 bit format.\n=================\n*/\nvoid R_LoadImage( const char *name, byte **pic, int *width, int *height ) {\n\tint\t\tlen;\n\n\t*pic = NULL;\n\t*width = 0;\n\t*height = 0;\n\n\tlen = strlen(name);\n\tif (len<5) {\n\t\treturn;\n\t}\n\n\tif ( !Q_stricmp( name+len-4, \".tga\" ) ) {\n\t  LoadTGA( name, pic, width, height );            // try tga first\n    if (!*pic) {                                    //\n\t\t  char altname[MAX_QPATH];                      // try jpg in place of tga \n      strcpy( altname, name );                      \n      len = strlen( altname );                  \n      altname[len-3] = 'j';\n      altname[len-2] = 'p';\n      altname[len-1] = 'g';\n\t\t\tLoadJPG( altname, pic, width, height );\n\t\t}\n  } else if ( !Q_stricmp(name+len-4, \".pcx\") ) {\n    LoadPCX32( name, pic, width, height );\n\t} else if ( !Q_stricmp( name+len-4, \".bmp\" ) ) {\n\t\tLoadBMP( name, pic, width, height );\n\t} else if ( !Q_stricmp( name+len-4, \".jpg\" ) ) {\n\t\tLoadJPG( name, pic, width, height );\n\t}\n}\n\n\n/*\n===============\nR_FindImageFile\n\nFinds or loads the given image.\nReturns NULL if it fails, not a default image.\n==============\n*/\nimage_t\t*R_FindImageFile( const char *name, qboolean mipmap, qboolean allowPicmip, int glWrapClampMode ) {\n\timage_t\t*image;\n\tint\t\twidth, height;\n\tbyte\t*pic;\n\tlong\thash;\n\n\tif (!name) {\n\t\treturn NULL;\n\t}\n\n\thash = generateHashValue(name);\n\n\t//\n\t// see if the image is already loaded\n\t//\n\tfor (image=hashTable[hash]; image; image=image->next) {\n\t\tif ( !strcmp( name, image->imgName ) ) {\n\t\t\t// the white image can be used with any set of parms, but other mismatches are errors\n\t\t\tif ( strcmp( name, \"*white\" ) ) {\n\t\t\t\tif ( image->mipmap != mipmap ) {\n\t\t\t\t\tri.Printf( PRINT_DEVELOPER, \"WARNING: reused image %s with mixed mipmap parm\\n\", name );\n\t\t\t\t}\n\t\t\t\tif ( image->allowPicmip != allowPicmip ) {\n\t\t\t\t\tri.Printf( PRINT_DEVELOPER, \"WARNING: reused image %s with mixed allowPicmip parm\\n\", name );\n\t\t\t\t}\n\t\t\t\tif ( image->wrapClampMode != glWrapClampMode ) {\n\t\t\t\t\tri.Printf( PRINT_ALL, \"WARNING: reused image %s with mixed glWrapClampMode parm\\n\", name );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn image;\n\t\t}\n\t}\n\n\t//\n\t// load the pic from disk\n\t//\n\tR_LoadImage( name, &pic, &width, &height );\n\tif ( pic == NULL ) {                                    // if we dont get a successful load\n\t  char altname[MAX_QPATH];                              // copy the name\n    int len;                                              //  \n    strcpy( altname, name );                              //\n    len = strlen( altname );                              // \n    altname[len-3] = toupper(altname[len-3]);             // and try upper case extension for unix systems\n    altname[len-2] = toupper(altname[len-2]);             //\n    altname[len-1] = toupper(altname[len-1]);             //\n\t\tri.Printf( PRINT_ALL, \"trying %s...\\n\", altname );    // \n\t  R_LoadImage( altname, &pic, &width, &height );        //\n    if (pic == NULL) {                                    // if that fails\n      return NULL;                                        // bail\n    }\n\t}\n\n\timage = R_CreateImage( ( char * ) name, pic, width, height, mipmap, allowPicmip, glWrapClampMode );\n\tri.Free( pic );\n\treturn image;\n}\n\n\n/*\n================\nR_CreateDlightImage\n================\n*/\n#define\tDLIGHT_SIZE\t16\nstatic void R_CreateDlightImage( void ) {\n\tint\t\tx,y;\n\tbyte\tdata[DLIGHT_SIZE][DLIGHT_SIZE][4];\n\tint\t\tb;\n\n\t// make a centered inverse-square falloff blob for dynamic lighting\n\tfor (x=0 ; x<DLIGHT_SIZE ; x++) {\n\t\tfor (y=0 ; y<DLIGHT_SIZE ; y++) {\n\t\t\tfloat\td;\n\n\t\t\td = ( DLIGHT_SIZE/2 - 0.5f - x ) * ( DLIGHT_SIZE/2 - 0.5f - x ) +\n\t\t\t\t( DLIGHT_SIZE/2 - 0.5f - y ) * ( DLIGHT_SIZE/2 - 0.5f - y );\n\t\t\tb = 4000 / d;\n\t\t\tif (b > 255) {\n\t\t\t\tb = 255;\n\t\t\t} else if ( b < 75 ) {\n\t\t\t\tb = 0;\n\t\t\t}\n\t\t\tdata[y][x][0] = \n\t\t\tdata[y][x][1] = \n\t\t\tdata[y][x][2] = b;\n\t\t\tdata[y][x][3] = 255;\t\t\t\n\t\t}\n\t}\n\ttr.dlightImage = R_CreateImage(\"*dlight\", (byte *)data, DLIGHT_SIZE, DLIGHT_SIZE, qfalse, qfalse, GL_CLAMP );\n}\n\n\n/*\n=================\nR_InitFogTable\n=================\n*/\nvoid R_InitFogTable( void ) {\n\tint\t\ti;\n\tfloat\td;\n\tfloat\texp;\n\t\n\texp = 0.5;\n\n\tfor ( i = 0 ; i < FOG_TABLE_SIZE ; i++ ) {\n\t\td = pow ( (float)i/(FOG_TABLE_SIZE-1), exp );\n\n\t\ttr.fogTable[i] = d;\n\t}\n}\n\n/*\n================\nR_FogFactor\n\nReturns a 0.0 to 1.0 fog density value\nThis is called for each texel of the fog texture on startup\nand for each vertex of transparent shaders in fog dynamically\n================\n*/\nfloat\tR_FogFactor( float s, float t ) {\n\tfloat\td;\n\n\ts -= 1.0/512;\n\tif ( s < 0 ) {\n\t\treturn 0;\n\t}\n\tif ( t < 1.0/32 ) {\n\t\treturn 0;\n\t}\n\tif ( t < 31.0/32 ) {\n\t\ts *= (t - 1.0f/32.0f) / (30.0f/32.0f);\n\t}\n\n\t// we need to leave a lot of clamp range\n\ts *= 8;\n\n\tif ( s > 1.0 ) {\n\t\ts = 1.0;\n\t}\n\n\td = tr.fogTable[ (int)(s * (FOG_TABLE_SIZE-1)) ];\n\n\treturn d;\n}\n\n/*\n================\nR_CreateFogImage\n================\n*/\n#define\tFOG_S\t256\n#define\tFOG_T\t32\nstatic void R_CreateFogImage( void ) {\n\tint\t\tx,y;\n\tbyte\t*data;\n\tfloat\tg;\n\tfloat\td;\n\tfloat\tborderColor[4];\n\n\tdata = ri.Hunk_AllocateTempMemory( FOG_S * FOG_T * 4 );\n\n\tg = 2.0;\n\n\t// S is distance, T is depth\n\tfor (x=0 ; x<FOG_S ; x++) {\n\t\tfor (y=0 ; y<FOG_T ; y++) {\n\t\t\td = R_FogFactor( ( x + 0.5f ) / FOG_S, ( y + 0.5f ) / FOG_T );\n\n\t\t\tdata[(y*FOG_S+x)*4+0] = \n\t\t\tdata[(y*FOG_S+x)*4+1] = \n\t\t\tdata[(y*FOG_S+x)*4+2] = 255;\n\t\t\tdata[(y*FOG_S+x)*4+3] = 255*d;\n\t\t}\n\t}\n\t// standard openGL clamping doesn't really do what we want -- it includes\n\t// the border color at the edges.  OpenGL 1.2 has clamp-to-edge, which does\n\t// what we want.\n\ttr.fogImage = R_CreateImage(\"*fog\", (byte *)data, FOG_S, FOG_T, qfalse, qfalse, GL_CLAMP );\n\tri.Hunk_FreeTempMemory( data );\n\n\tborderColor[0] = 1.0;\n\tborderColor[1] = 1.0;\n\tborderColor[2] = 1.0;\n\tborderColor[3] = 1;\n\n\tqglTexParameterfv( GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor );\n}\n\n/*\n==================\nR_CreateDefaultImage\n==================\n*/\n#define\tDEFAULT_SIZE\t16\nstatic void R_CreateDefaultImage( void ) {\n\tint\t\tx;\n\tbyte\tdata[DEFAULT_SIZE][DEFAULT_SIZE][4];\n\n\t// the default image will be a box, to allow you to see the mapping coordinates\n\tCom_Memset( data, 32, sizeof( data ) );\n\tfor ( x = 0 ; x < DEFAULT_SIZE ; x++ ) {\n\t\tdata[0][x][0] =\n\t\tdata[0][x][1] =\n\t\tdata[0][x][2] =\n\t\tdata[0][x][3] = 255;\n\n\t\tdata[x][0][0] =\n\t\tdata[x][0][1] =\n\t\tdata[x][0][2] =\n\t\tdata[x][0][3] = 255;\n\n\t\tdata[DEFAULT_SIZE-1][x][0] =\n\t\tdata[DEFAULT_SIZE-1][x][1] =\n\t\tdata[DEFAULT_SIZE-1][x][2] =\n\t\tdata[DEFAULT_SIZE-1][x][3] = 255;\n\n\t\tdata[x][DEFAULT_SIZE-1][0] =\n\t\tdata[x][DEFAULT_SIZE-1][1] =\n\t\tdata[x][DEFAULT_SIZE-1][2] =\n\t\tdata[x][DEFAULT_SIZE-1][3] = 255;\n\t}\n\ttr.defaultImage = R_CreateImage(\"*default\", (byte *)data, DEFAULT_SIZE, DEFAULT_SIZE, qtrue, qfalse, GL_REPEAT );\n}\n\n/*\n==================\nR_CreateBuiltinImages\n==================\n*/\nvoid R_CreateBuiltinImages( void ) {\n\tint\t\tx,y;\n\tbyte\tdata[DEFAULT_SIZE][DEFAULT_SIZE][4];\n\n\tR_CreateDefaultImage();\n\n\t// we use a solid white image instead of disabling texturing\n\tCom_Memset( data, 255, sizeof( data ) );\n\ttr.whiteImage = R_CreateImage(\"*white\", (byte *)data, 8, 8, qfalse, qfalse, GL_REPEAT );\n\n\t// with overbright bits active, we need an image which is some fraction of full color,\n\t// for default lightmaps, etc\n\tfor (x=0 ; x<DEFAULT_SIZE ; x++) {\n\t\tfor (y=0 ; y<DEFAULT_SIZE ; y++) {\n\t\t\tdata[y][x][0] = \n\t\t\tdata[y][x][1] = \n\t\t\tdata[y][x][2] = tr.identityLightByte;\n\t\t\tdata[y][x][3] = 255;\t\t\t\n\t\t}\n\t}\n\n\ttr.identityLightImage = R_CreateImage(\"*identityLight\", (byte *)data, 8, 8, qfalse, qfalse, GL_REPEAT );\n\n\n\tfor(x=0;x<32;x++) {\n\t\t// scratchimage is usually used for cinematic drawing\n\t\ttr.scratchImage[x] = R_CreateImage(\"*scratch\", (byte *)data, DEFAULT_SIZE, DEFAULT_SIZE, qfalse, qtrue, GL_CLAMP );\n\t}\n\n\tR_CreateDlightImage();\n\tR_CreateFogImage();\n}\n\n\n/*\n===============\nR_SetColorMappings\n===============\n*/\nvoid R_SetColorMappings( void ) {\n\tint\t\ti, j;\n\tfloat\tg;\n\tint\t\tinf;\n\tint\t\tshift;\n\n\t// setup the overbright lighting\n\ttr.overbrightBits = r_overBrightBits->integer;\n\tif ( !glConfig.deviceSupportsGamma ) {\n\t\ttr.overbrightBits = 0;\t\t// need hardware gamma for overbright\n\t}\n\n\t// never overbright in windowed mode\n\tif ( !glConfig.isFullscreen ) \n\t{\n\t\ttr.overbrightBits = 0;\n\t}\n\n\t// allow 2 overbright bits in 24 bit, but only 1 in 16 bit\n\tif ( glConfig.colorBits > 16 ) {\n\t\tif ( tr.overbrightBits > 2 ) {\n\t\t\ttr.overbrightBits = 2;\n\t\t}\n\t} else {\n\t\tif ( tr.overbrightBits > 1 ) {\n\t\t\ttr.overbrightBits = 1;\n\t\t}\n\t}\n\tif ( tr.overbrightBits < 0 ) {\n\t\ttr.overbrightBits = 0;\n\t}\n\n\ttr.identityLight = 1.0f / ( 1 << tr.overbrightBits );\n\ttr.identityLightByte = 255 * tr.identityLight;\n\n\n\tif ( r_intensity->value <= 1 ) {\n\t\tri.Cvar_Set( \"r_intensity\", \"1\" );\n\t}\n\n\tif ( r_gamma->value < 0.5f ) {\n\t\tri.Cvar_Set( \"r_gamma\", \"0.5\" );\n\t} else if ( r_gamma->value > 3.0f ) {\n\t\tri.Cvar_Set( \"r_gamma\", \"3.0\" );\n\t}\n\n\tg = r_gamma->value;\n\n\tshift = tr.overbrightBits;\n\n\tfor ( i = 0; i < 256; i++ ) {\n\t\tif ( g == 1 ) {\n\t\t\tinf = i;\n\t\t} else {\n\t\t\tinf = 255 * pow ( i/255.0f, 1.0f / g ) + 0.5f;\n\t\t}\n\t\tinf <<= shift;\n\t\tif (inf < 0) {\n\t\t\tinf = 0;\n\t\t}\n\t\tif (inf > 255) {\n\t\t\tinf = 255;\n\t\t}\n\t\ts_gammatable[i] = inf;\n\t}\n\n\tfor (i=0 ; i<256 ; i++) {\n\t\tj = i * r_intensity->value;\n\t\tif (j > 255) {\n\t\t\tj = 255;\n\t\t}\n\t\ts_intensitytable[i] = j;\n\t}\n\n\tif ( glConfig.deviceSupportsGamma )\n\t{\n\t\tGLimp_SetGamma( s_gammatable, s_gammatable, s_gammatable );\n\t}\n}\n\n/*\n===============\nR_InitImages\n===============\n*/\nvoid\tR_InitImages( void ) {\n\tCom_Memset(hashTable, 0, sizeof(hashTable));\n\t// build brightness translation tables\n\tR_SetColorMappings();\n\n\t// create default texture and white texture\n\tR_CreateBuiltinImages();\n}\n\n/*\n===============\nR_DeleteTextures\n===============\n*/\nvoid R_DeleteTextures( void ) {\n\tint\t\ti;\n\n\tfor ( i=0; i<tr.numImages ; i++ ) {\n\t\tqglDeleteTextures( 1, &tr.images[i]->texnum );\n\t}\n\tCom_Memset( tr.images, 0, sizeof( tr.images ) );\n\n\ttr.numImages = 0;\n\n\tCom_Memset( glState.currenttextures, 0, sizeof( glState.currenttextures ) );\n\tif ( qglBindTexture ) {\n\t\tif ( qglActiveTextureARB ) {\n\t\t\tGL_SelectTexture( 1 );\n\t\t\tqglBindTexture( GL_TEXTURE_2D, 0 );\n\t\t\tGL_SelectTexture( 0 );\n\t\t\tqglBindTexture( GL_TEXTURE_2D, 0 );\n\t\t} else {\n\t\t\tqglBindTexture( GL_TEXTURE_2D, 0 );\n\t\t}\n\t}\n}\n\n/*\n============================================================================\n\nSKINS\n\n============================================================================\n*/\n\n/*\n==================\nCommaParse\n\nThis is unfortunate, but the skin files aren't\ncompatable with our normal parsing rules.\n==================\n*/\nstatic char *CommaParse( char **data_p ) {\n\tint c = 0, len;\n\tchar *data;\n\tstatic\tchar\tcom_token[MAX_TOKEN_CHARS];\n\n\tdata = *data_p;\n\tlen = 0;\n\tcom_token[0] = 0;\n\n\t// make sure incoming data is valid\n\tif ( !data ) {\n\t\t*data_p = NULL;\n\t\treturn com_token;\n\t}\n\n\twhile ( 1 ) {\n\t\t// skip whitespace\n\t\twhile( (c = *data) <= ' ') {\n\t\t\tif( !c ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdata++;\n\t\t}\n\n\n\t\tc = *data;\n\n\t\t// skip double slash comments\n\t\tif ( c == '/' && data[1] == '/' )\n\t\t{\n\t\t\twhile (*data && *data != '\\n')\n\t\t\t\tdata++;\n\t\t}\n\t\t// skip /* */ comments\n\t\telse if ( c=='/' && data[1] == '*' ) \n\t\t{\n\t\t\twhile ( *data && ( *data != '*' || data[1] != '/' ) ) \n\t\t\t{\n\t\t\t\tdata++;\n\t\t\t}\n\t\t\tif ( *data ) \n\t\t\t{\n\t\t\t\tdata += 2;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif ( c == 0 ) {\n\t\treturn \"\";\n\t}\n\n\t// handle quoted strings\n\tif (c == '\\\"')\n\t{\n\t\tdata++;\n\t\twhile (1)\n\t\t{\n\t\t\tc = *data++;\n\t\t\tif (c=='\\\"' || !c)\n\t\t\t{\n\t\t\t\tcom_token[len] = 0;\n\t\t\t\t*data_p = ( char * ) data;\n\t\t\t\treturn com_token;\n\t\t\t}\n\t\t\tif (len < MAX_TOKEN_CHARS)\n\t\t\t{\n\t\t\t\tcom_token[len] = c;\n\t\t\t\tlen++;\n\t\t\t}\n\t\t}\n\t}\n\n\t// parse a regular word\n\tdo\n\t{\n\t\tif (len < MAX_TOKEN_CHARS)\n\t\t{\n\t\t\tcom_token[len] = c;\n\t\t\tlen++;\n\t\t}\n\t\tdata++;\n\t\tc = *data;\n\t} while (c>32 && c != ',' );\n\n\tif (len == MAX_TOKEN_CHARS)\n\t{\n//\t\tCom_Printf (\"Token exceeded %i chars, discarded.\\n\", MAX_TOKEN_CHARS);\n\t\tlen = 0;\n\t}\n\tcom_token[len] = 0;\n\n\t*data_p = ( char * ) data;\n\treturn com_token;\n}\n\n\n/*\n===============\nRE_RegisterSkin\n\n===============\n*/\nqhandle_t RE_RegisterSkin( const char *name ) {\n\tqhandle_t\thSkin;\n\tskin_t\t\t*skin;\n\tskinSurface_t\t*surf;\n\tchar\t\t*text, *text_p;\n\tchar\t\t*token;\n\tchar\t\tsurfName[MAX_QPATH];\n\n\tif ( !name || !name[0] ) {\n\t\tCom_Printf( \"Empty name passed to RE_RegisterSkin\\n\" );\n\t\treturn 0;\n\t}\n\n\tif ( strlen( name ) >= MAX_QPATH ) {\n\t\tCom_Printf( \"Skin name exceeds MAX_QPATH\\n\" );\n\t\treturn 0;\n\t}\n\n\n\t// see if the skin is already loaded\n\tfor ( hSkin = 1; hSkin < tr.numSkins ; hSkin++ ) {\n\t\tskin = tr.skins[hSkin];\n\t\tif ( !Q_stricmp( skin->name, name ) ) {\n\t\t\tif( skin->numSurfaces == 0 ) {\n\t\t\t\treturn 0;\t\t// default skin\n\t\t\t}\n\t\t\treturn hSkin;\n\t\t}\n\t}\n\n\t// allocate a new skin\n\tif ( tr.numSkins == MAX_SKINS ) {\n\t\tri.Printf( PRINT_WARNING, \"WARNING: RE_RegisterSkin( '%s' ) MAX_SKINS hit\\n\", name );\n\t\treturn 0;\n\t}\n\ttr.numSkins++;\n\tskin = ri.Hunk_Alloc( sizeof( skin_t ), h_low );\n\ttr.skins[hSkin] = skin;\n\tQ_strncpyz( skin->name, name, sizeof( skin->name ) );\n\tskin->numSurfaces = 0;\n\n\t// make sure the render thread is stopped\n\tR_SyncRenderThread();\n\n\t// If not a .skin file, load as a single shader\n\tif ( strcmp( name + strlen( name ) - 5, \".skin\" ) ) {\n\t\tskin->numSurfaces = 1;\n\t\tskin->surfaces[0] = ri.Hunk_Alloc( sizeof(skin->surfaces[0]), h_low );\n\t\tskin->surfaces[0]->shader = R_FindShader( name, LIGHTMAP_NONE, qtrue );\n\t\treturn hSkin;\n\t}\n\n\t// load and parse the skin file\n    ri.FS_ReadFile( name, (void **)&text );\n\tif ( !text ) {\n\t\treturn 0;\n\t}\n\n\ttext_p = text;\n\twhile ( text_p && *text_p ) {\n\t\t// get surface name\n\t\ttoken = CommaParse( &text_p );\n\t\tQ_strncpyz( surfName, token, sizeof( surfName ) );\n\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\t// lowercase the surface name so skin compares are faster\n\t\tQ_strlwr( surfName );\n\n\t\tif ( *text_p == ',' ) {\n\t\t\ttext_p++;\n\t\t}\n\n\t\tif ( strstr( token, \"tag_\" ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t\n\t\t// parse the shader name\n\t\ttoken = CommaParse( &text_p );\n\n\t\tsurf = skin->surfaces[ skin->numSurfaces ] = ri.Hunk_Alloc( sizeof( *skin->surfaces[0] ), h_low );\n\t\tQ_strncpyz( surf->name, surfName, sizeof( surf->name ) );\n\t\tsurf->shader = R_FindShader( token, LIGHTMAP_NONE, qtrue );\n\t\tskin->numSurfaces++;\n\t}\n\n\tri.FS_FreeFile( text );\n\n\n\t// never let a skin have 0 shaders\n\tif ( skin->numSurfaces == 0 ) {\n\t\treturn 0;\t\t// use default skin\n\t}\n\n\treturn hSkin;\n}\n\n\n/*\n===============\nR_InitSkins\n===============\n*/\nvoid\tR_InitSkins( void ) {\n\tskin_t\t\t*skin;\n\n\ttr.numSkins = 1;\n\n\t// make the default skin have all default shaders\n\tskin = tr.skins[0] = ri.Hunk_Alloc( sizeof( skin_t ), h_low );\n\tQ_strncpyz( skin->name, \"<default skin>\", sizeof( skin->name )  );\n\tskin->numSurfaces = 1;\n\tskin->surfaces[0] = ri.Hunk_Alloc( sizeof( *skin->surfaces ), h_low );\n\tskin->surfaces[0]->shader = tr.defaultShader;\n}\n\n/*\n===============\nR_GetSkinByHandle\n===============\n*/\nskin_t\t*R_GetSkinByHandle( qhandle_t hSkin ) {\n\tif ( hSkin < 1 || hSkin >= tr.numSkins ) {\n\t\treturn tr.skins[0];\n\t}\n\treturn tr.skins[ hSkin ];\n}\n\n/*\n===============\nR_SkinList_f\n===============\n*/\nvoid\tR_SkinList_f( void ) {\n\tint\t\t\ti, j;\n\tskin_t\t\t*skin;\n\n\tri.Printf (PRINT_ALL, \"------------------\\n\");\n\n\tfor ( i = 0 ; i < tr.numSkins ; i++ ) {\n\t\tskin = tr.skins[i];\n\n\t\tri.Printf( PRINT_ALL, \"%3i:%s\\n\", i, skin->name );\n\t\tfor ( j = 0 ; j < skin->numSurfaces ; j++ ) {\n\t\t\tri.Printf( PRINT_ALL, \"       %s = %s\\n\", \n\t\t\t\tskin->surfaces[j]->name, skin->surfaces[j]->shader->name );\n\t\t}\n\t}\n\tri.Printf (PRINT_ALL, \"------------------\\n\");\n}\n\n"
  },
  {
    "path": "code/renderer/tr_init.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// tr_init.c -- functions that are not called every frame\n\n#include \"tr_local.h\"\n\nglconfig_t\tglConfig;\nglstate_t\tglState;\n\nstatic void GfxInfo_f( void );\n\ncvar_t\t*r_flareSize;\ncvar_t\t*r_flareFade;\n\ncvar_t\t*r_railWidth;\ncvar_t\t*r_railCoreWidth;\ncvar_t\t*r_railSegmentLength;\n\ncvar_t\t*r_ignoreFastPath;\n\ncvar_t\t*r_verbose;\ncvar_t\t*r_ignore;\n\ncvar_t\t*r_displayRefresh;\n\ncvar_t\t*r_detailTextures;\n\ncvar_t\t*r_znear;\n\ncvar_t\t*r_smp;\ncvar_t\t*r_showSmp;\ncvar_t\t*r_skipBackEnd;\n\ncvar_t\t*r_ignorehwgamma;\ncvar_t\t*r_measureOverdraw;\n\ncvar_t\t*r_inGameVideo;\ncvar_t\t*r_fastsky;\ncvar_t\t*r_drawSun;\ncvar_t\t*r_dynamiclight;\ncvar_t\t*r_dlightBacks;\n\ncvar_t\t*r_lodbias;\ncvar_t\t*r_lodscale;\n\ncvar_t\t*r_norefresh;\ncvar_t\t*r_drawentities;\ncvar_t\t*r_drawworld;\ncvar_t\t*r_speeds;\ncvar_t\t*r_fullbright;\ncvar_t\t*r_novis;\ncvar_t\t*r_nocull;\ncvar_t\t*r_facePlaneCull;\ncvar_t\t*r_showcluster;\ncvar_t\t*r_nocurves;\n\ncvar_t\t*r_allowExtensions;\n\ncvar_t\t*r_ext_compressed_textures;\ncvar_t\t*r_ext_gamma_control;\ncvar_t\t*r_ext_multitexture;\ncvar_t\t*r_ext_compiled_vertex_array;\ncvar_t\t*r_ext_texture_env_add;\n\ncvar_t\t*r_ignoreGLErrors;\ncvar_t\t*r_logFile;\n\ncvar_t\t*r_stencilbits;\ncvar_t\t*r_depthbits;\ncvar_t\t*r_colorbits;\ncvar_t\t*r_stereo;\ncvar_t\t*r_primitives;\ncvar_t\t*r_texturebits;\n\ncvar_t\t*r_drawBuffer;\ncvar_t  *r_glDriver;\ncvar_t\t*r_lightmap;\ncvar_t\t*r_vertexLight;\ncvar_t\t*r_uiFullScreen;\ncvar_t\t*r_shadows;\ncvar_t\t*r_flares;\ncvar_t\t*r_mode;\ncvar_t\t*r_nobind;\ncvar_t\t*r_singleShader;\ncvar_t\t*r_roundImagesDown;\ncvar_t\t*r_colorMipLevels;\ncvar_t\t*r_picmip;\ncvar_t\t*r_showtris;\ncvar_t\t*r_showsky;\ncvar_t\t*r_shownormals;\ncvar_t\t*r_finish;\ncvar_t\t*r_clear;\ncvar_t\t*r_swapInterval;\ncvar_t\t*r_textureMode;\ncvar_t\t*r_offsetFactor;\ncvar_t\t*r_offsetUnits;\ncvar_t\t*r_gamma;\ncvar_t\t*r_intensity;\ncvar_t\t*r_lockpvs;\ncvar_t\t*r_noportals;\ncvar_t\t*r_portalOnly;\n\ncvar_t\t*r_subdivisions;\ncvar_t\t*r_lodCurveError;\n\ncvar_t\t*r_fullscreen;\n\ncvar_t\t*r_customwidth;\ncvar_t\t*r_customheight;\ncvar_t\t*r_customaspect;\n\ncvar_t\t*r_overBrightBits;\ncvar_t\t*r_mapOverBrightBits;\n\ncvar_t\t*r_debugSurface;\ncvar_t\t*r_simpleMipMaps;\n\ncvar_t\t*r_showImages;\n\ncvar_t\t*r_ambientScale;\ncvar_t\t*r_directedScale;\ncvar_t\t*r_debugLight;\ncvar_t\t*r_debugSort;\ncvar_t\t*r_printShaders;\ncvar_t\t*r_saveFontData;\n\ncvar_t\t*r_maxpolys;\nint\t\tmax_polys;\ncvar_t\t*r_maxpolyverts;\nint\t\tmax_polyverts;\n\nvoid ( APIENTRY * qglMultiTexCoord2fARB )( GLenum texture, GLfloat s, GLfloat t );\nvoid ( APIENTRY * qglActiveTextureARB )( GLenum texture );\nvoid ( APIENTRY * qglClientActiveTextureARB )( GLenum texture );\n\nvoid ( APIENTRY * qglLockArraysEXT)( GLint, GLint);\nvoid ( APIENTRY * qglUnlockArraysEXT) ( void );\n\nstatic void AssertCvarRange( cvar_t *cv, float minVal, float maxVal, qboolean shouldBeIntegral )\n{\n\tif ( shouldBeIntegral )\n\t{\n\t\tif ( ( int ) cv->value != cv->integer )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: cvar '%s' must be integral (%f)\\n\", cv->name, cv->value );\n\t\t\tri.Cvar_Set( cv->name, va( \"%d\", cv->integer ) );\n\t\t}\n\t}\n\n\tif ( cv->value < minVal )\n\t{\n\t\tri.Printf( PRINT_WARNING, \"WARNING: cvar '%s' out of range (%f < %f)\\n\", cv->name, cv->value, minVal );\n\t\tri.Cvar_Set( cv->name, va( \"%f\", minVal ) );\n\t}\n\telse if ( cv->value > maxVal )\n\t{\n\t\tri.Printf( PRINT_WARNING, \"WARNING: cvar '%s' out of range (%f > %f)\\n\", cv->name, cv->value, maxVal );\n\t\tri.Cvar_Set( cv->name, va( \"%f\", maxVal ) );\n\t}\n}\n\n\n/*\n** InitOpenGL\n**\n** This function is responsible for initializing a valid OpenGL subsystem.  This\n** is done by calling GLimp_Init (which gives us a working OGL subsystem) then\n** setting variables, checking GL constants, and reporting the gfx system config\n** to the user.\n*/\nstatic void InitOpenGL( void )\n{\n\tchar renderer_buffer[1024];\n\n\t//\n\t// initialize OS specific portions of the renderer\n\t//\n\t// GLimp_Init directly or indirectly references the following cvars:\n\t//\t\t- r_fullscreen\n\t//\t\t- r_glDriver\n\t//\t\t- r_mode\n\t//\t\t- r_(color|depth|stencil)bits\n\t//\t\t- r_ignorehwgamma\n\t//\t\t- r_gamma\n\t//\n\t\n\tif ( glConfig.vidWidth == 0 )\n\t{\n\t\tGLint\t\ttemp;\n\t\t\n\t\tGLimp_Init();\n\n\t\tstrcpy( renderer_buffer, glConfig.renderer_string );\n\t\tQ_strlwr( renderer_buffer );\n\n\t\t// OpenGL driver constants\n\t\tqglGetIntegerv( GL_MAX_TEXTURE_SIZE, &temp );\n\t\tglConfig.maxTextureSize = temp;\n\n\t\t// stubbed or broken drivers may have reported 0...\n\t\tif ( glConfig.maxTextureSize <= 0 ) \n\t\t{\n\t\t\tglConfig.maxTextureSize = 0;\n\t\t}\n\t}\n\n\t// init command buffers and SMP\n\tR_InitCommandBuffers();\n\n\t// print info\n\tGfxInfo_f();\n\n\t// set default state\n\tGL_SetDefaultState();\n}\n\n/*\n==================\nGL_CheckErrors\n==================\n*/\nvoid GL_CheckErrors( void ) {\n    int\t\terr;\n    char\ts[64];\n\n    err = qglGetError();\n    if ( err == GL_NO_ERROR ) {\n        return;\n    }\n    if ( r_ignoreGLErrors->integer ) {\n        return;\n    }\n    switch( err ) {\n        case GL_INVALID_ENUM:\n            strcpy( s, \"GL_INVALID_ENUM\" );\n            break;\n        case GL_INVALID_VALUE:\n            strcpy( s, \"GL_INVALID_VALUE\" );\n            break;\n        case GL_INVALID_OPERATION:\n            strcpy( s, \"GL_INVALID_OPERATION\" );\n            break;\n        case GL_STACK_OVERFLOW:\n            strcpy( s, \"GL_STACK_OVERFLOW\" );\n            break;\n        case GL_STACK_UNDERFLOW:\n            strcpy( s, \"GL_STACK_UNDERFLOW\" );\n            break;\n        case GL_OUT_OF_MEMORY:\n            strcpy( s, \"GL_OUT_OF_MEMORY\" );\n            break;\n        default:\n            Com_sprintf( s, sizeof(s), \"%i\", err);\n            break;\n    }\n\n    ri.Error( ERR_FATAL, \"GL_CheckErrors: %s\", s );\n}\n\n\n/*\n** R_GetModeInfo\n*/\ntypedef struct vidmode_s\n{\n    const char *description;\n    int         width, height;\n\tfloat\t\tpixelAspect;\t\t// pixel width / height\n} vidmode_t;\n\nvidmode_t r_vidModes[] =\n{\n    { \"Mode  0: 320x240\",\t\t320,\t240,\t1 },\n    { \"Mode  1: 400x300\",\t\t400,\t300,\t1 },\n    { \"Mode  2: 512x384\",\t\t512,\t384,\t1 },\n    { \"Mode  3: 640x480\",\t\t640,\t480,\t1 },\n    { \"Mode  4: 800x600\",\t\t800,\t600,\t1 },\n    { \"Mode  5: 960x720\",\t\t960,\t720,\t1 },\n    { \"Mode  6: 1024x768\",\t\t1024,\t768,\t1 },\n    { \"Mode  7: 1152x864\",\t\t1152,\t864,\t1 },\n    { \"Mode  8: 1280x1024\",\t\t1280,\t1024,\t1 },\n    { \"Mode  9: 1600x1200\",\t\t1600,\t1200,\t1 },\n    { \"Mode 10: 2048x1536\",\t\t2048,\t1536,\t1 },\n    { \"Mode 11: 856x480 (wide)\",856,\t480,\t1 }\n};\nstatic int\ts_numVidModes = ( sizeof( r_vidModes ) / sizeof( r_vidModes[0] ) );\n\nqboolean R_GetModeInfo( int *width, int *height, float *windowAspect, int mode ) {\n\tvidmode_t\t*vm;\n\n    if ( mode < -1 ) {\n        return qfalse;\n\t}\n\tif ( mode >= s_numVidModes ) {\n\t\treturn qfalse;\n\t}\n\n\tif ( mode == -1 ) {\n\t\t*width = r_customwidth->integer;\n\t\t*height = r_customheight->integer;\n\t\t*windowAspect = r_customaspect->value;\n\t\treturn qtrue;\n\t}\n\n\tvm = &r_vidModes[mode];\n\n    *width  = vm->width;\n    *height = vm->height;\n    *windowAspect = (float)vm->width / ( vm->height * vm->pixelAspect );\n\n    return qtrue;\n}\n\n/*\n** R_ModeList_f\n*/\nstatic void R_ModeList_f( void )\n{\n\tint i;\n\n\tri.Printf( PRINT_ALL, \"\\n\" );\n\tfor ( i = 0; i < s_numVidModes; i++ )\n\t{\n\t\tri.Printf( PRINT_ALL, \"%s\\n\", r_vidModes[i].description );\n\t}\n\tri.Printf( PRINT_ALL, \"\\n\" );\n}\n\n\n/* \n============================================================================== \n \n\t\t\t\t\t\tSCREEN SHOTS \n\nNOTE TTimo\nsome thoughts about the screenshots system:\nscreenshots get written in fs_homepath + fs_gamedir\nvanilla q3 .. baseq3/screenshots/ *.tga\nteam arena .. missionpack/screenshots/ *.tga\n\ntwo commands: \"screenshot\" and \"screenshotJPEG\"\nwe use statics to store a count and start writing the first screenshot/screenshot????.tga (.jpg) available\n(with FS_FileExists / FS_FOpenFileWrite calls)\nFIXME: the statics don't get a reinit between fs_game changes\n\n============================================================================== \n*/ \n\n/* \n================== \nRB_TakeScreenshot\n================== \n*/  \nvoid RB_TakeScreenshot( int x, int y, int width, int height, char *fileName ) {\n\tbyte\t\t*buffer;\n\tint\t\t\ti, c, temp;\n\t\t\n\tbuffer = ri.Hunk_AllocateTempMemory(glConfig.vidWidth*glConfig.vidHeight*3+18);\n\n\tCom_Memset (buffer, 0, 18);\n\tbuffer[2] = 2;\t\t// uncompressed type\n\tbuffer[12] = width & 255;\n\tbuffer[13] = width >> 8;\n\tbuffer[14] = height & 255;\n\tbuffer[15] = height >> 8;\n\tbuffer[16] = 24;\t// pixel size\n\n\tqglReadPixels( x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, buffer+18 ); \n\n\t// swap rgb to bgr\n\tc = 18 + width * height * 3;\n\tfor (i=18 ; i<c ; i+=3) {\n\t\ttemp = buffer[i];\n\t\tbuffer[i] = buffer[i+2];\n\t\tbuffer[i+2] = temp;\n\t}\n\n\t// gamma correct\n\tif ( ( tr.overbrightBits > 0 ) && glConfig.deviceSupportsGamma ) {\n\t\tR_GammaCorrect( buffer + 18, glConfig.vidWidth * glConfig.vidHeight * 3 );\n\t}\n\n\tri.FS_WriteFile( fileName, buffer, c );\n\n\tri.Hunk_FreeTempMemory( buffer );\n}\n\n/* \n================== \nRB_TakeScreenshotJPEG\n================== \n*/  \nvoid RB_TakeScreenshotJPEG( int x, int y, int width, int height, char *fileName ) {\n\tbyte\t\t*buffer;\n\n\tbuffer = ri.Hunk_AllocateTempMemory(glConfig.vidWidth*glConfig.vidHeight*4);\n\n\tqglReadPixels( x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer ); \n\n\t// gamma correct\n\tif ( ( tr.overbrightBits > 0 ) && glConfig.deviceSupportsGamma ) {\n\t\tR_GammaCorrect( buffer, glConfig.vidWidth * glConfig.vidHeight * 4 );\n\t}\n\n\tri.FS_WriteFile( fileName, buffer, 1 );\t\t// create path\n\tSaveJPG( fileName, 95, glConfig.vidWidth, glConfig.vidHeight, buffer);\n\n\tri.Hunk_FreeTempMemory( buffer );\n}\n\n/*\n==================\nRB_TakeScreenshotCmd\n==================\n*/\nconst void *RB_TakeScreenshotCmd( const void *data ) {\n\tconst screenshotCommand_t\t*cmd;\n\t\n\tcmd = (const screenshotCommand_t *)data;\n\t\n\tif (cmd->jpeg)\n\t\tRB_TakeScreenshotJPEG( cmd->x, cmd->y, cmd->width, cmd->height, cmd->fileName);\n\telse\n\t\tRB_TakeScreenshot( cmd->x, cmd->y, cmd->width, cmd->height, cmd->fileName);\n\t\n\treturn (const void *)(cmd + 1);\t\n}\n\n/*\n==================\nR_TakeScreenshot\n==================\n*/\nvoid R_TakeScreenshot( int x, int y, int width, int height, char *name, qboolean jpeg ) {\n\tstatic char\tfileName[MAX_OSPATH]; // bad things if two screenshots per frame?\n\tscreenshotCommand_t\t*cmd;\n\n\tcmd = R_GetCommandBuffer( sizeof( *cmd ) );\n\tif ( !cmd ) {\n\t\treturn;\n\t}\n\tcmd->commandId = RC_SCREENSHOT;\n\n\tcmd->x = x;\n\tcmd->y = y;\n\tcmd->width = width;\n\tcmd->height = height;\n\tQ_strncpyz( fileName, name, sizeof(fileName) );\n\tcmd->fileName = fileName;\n\tcmd->jpeg = jpeg;\n}\n\n/* \n================== \nR_ScreenshotFilename\n================== \n*/  \nvoid R_ScreenshotFilename( int lastNumber, char *fileName ) {\n\tint\t\ta,b,c,d;\n\n\tif ( lastNumber < 0 || lastNumber > 9999 ) {\n\t\tCom_sprintf( fileName, MAX_OSPATH, \"screenshots/shot9999.tga\" );\n\t\treturn;\n\t}\n\n\ta = lastNumber / 1000;\n\tlastNumber -= a*1000;\n\tb = lastNumber / 100;\n\tlastNumber -= b*100;\n\tc = lastNumber / 10;\n\tlastNumber -= c*10;\n\td = lastNumber;\n\n\tCom_sprintf( fileName, MAX_OSPATH, \"screenshots/shot%i%i%i%i.tga\"\n\t\t, a, b, c, d );\n}\n\n/* \n================== \nR_ScreenshotFilename\n================== \n*/  \nvoid R_ScreenshotFilenameJPEG( int lastNumber, char *fileName ) {\n\tint\t\ta,b,c,d;\n\n\tif ( lastNumber < 0 || lastNumber > 9999 ) {\n\t\tCom_sprintf( fileName, MAX_OSPATH, \"screenshots/shot9999.jpg\" );\n\t\treturn;\n\t}\n\n\ta = lastNumber / 1000;\n\tlastNumber -= a*1000;\n\tb = lastNumber / 100;\n\tlastNumber -= b*100;\n\tc = lastNumber / 10;\n\tlastNumber -= c*10;\n\td = lastNumber;\n\n\tCom_sprintf( fileName, MAX_OSPATH, \"screenshots/shot%i%i%i%i.jpg\"\n\t\t, a, b, c, d );\n}\n\n/*\n====================\nR_LevelShot\n\nlevelshots are specialized 128*128 thumbnails for\nthe menu system, sampled down from full screen distorted images\n====================\n*/\nvoid R_LevelShot( void ) {\n\tchar\t\tcheckname[MAX_OSPATH];\n\tbyte\t\t*buffer;\n\tbyte\t\t*source;\n\tbyte\t\t*src, *dst;\n\tint\t\t\tx, y;\n\tint\t\t\tr, g, b;\n\tfloat\t\txScale, yScale;\n\tint\t\t\txx, yy;\n\n\tsprintf( checkname, \"levelshots/%s.tga\", tr.world->baseName );\n\n\tsource = ri.Hunk_AllocateTempMemory( glConfig.vidWidth * glConfig.vidHeight * 3 );\n\n\tbuffer = ri.Hunk_AllocateTempMemory( 128 * 128*3 + 18);\n\tCom_Memset (buffer, 0, 18);\n\tbuffer[2] = 2;\t\t// uncompressed type\n\tbuffer[12] = 128;\n\tbuffer[14] = 128;\n\tbuffer[16] = 24;\t// pixel size\n\n\tqglReadPixels( 0, 0, glConfig.vidWidth, glConfig.vidHeight, GL_RGB, GL_UNSIGNED_BYTE, source ); \n\n\t// resample from source\n\txScale = glConfig.vidWidth / 512.0f;\n\tyScale = glConfig.vidHeight / 384.0f;\n\tfor ( y = 0 ; y < 128 ; y++ ) {\n\t\tfor ( x = 0 ; x < 128 ; x++ ) {\n\t\t\tr = g = b = 0;\n\t\t\tfor ( yy = 0 ; yy < 3 ; yy++ ) {\n\t\t\t\tfor ( xx = 0 ; xx < 4 ; xx++ ) {\n\t\t\t\t\tsrc = source + 3 * ( glConfig.vidWidth * (int)( (y*3+yy)*yScale ) + (int)( (x*4+xx)*xScale ) );\n\t\t\t\t\tr += src[0];\n\t\t\t\t\tg += src[1];\n\t\t\t\t\tb += src[2];\n\t\t\t\t}\n\t\t\t}\n\t\t\tdst = buffer + 18 + 3 * ( y * 128 + x );\n\t\t\tdst[0] = b / 12;\n\t\t\tdst[1] = g / 12;\n\t\t\tdst[2] = r / 12;\n\t\t}\n\t}\n\n\t// gamma correct\n\tif ( ( tr.overbrightBits > 0 ) && glConfig.deviceSupportsGamma ) {\n\t\tR_GammaCorrect( buffer + 18, 128 * 128 * 3 );\n\t}\n\n\tri.FS_WriteFile( checkname, buffer, 128 * 128*3 + 18 );\n\n\tri.Hunk_FreeTempMemory( buffer );\n\tri.Hunk_FreeTempMemory( source );\n\n\tri.Printf( PRINT_ALL, \"Wrote %s\\n\", checkname );\n}\n\n/* \n================== \nR_ScreenShot_f\n\nscreenshot\nscreenshot [silent]\nscreenshot [levelshot]\nscreenshot [filename]\n\nDoesn't print the pacifier message if there is a second arg\n================== \n*/  \nvoid R_ScreenShot_f (void) {\n\tchar\tcheckname[MAX_OSPATH];\n\tstatic\tint\tlastNumber = -1;\n\tqboolean\tsilent;\n\n\tif ( !strcmp( ri.Cmd_Argv(1), \"levelshot\" ) ) {\n\t\tR_LevelShot();\n\t\treturn;\n\t}\n\n\tif ( !strcmp( ri.Cmd_Argv(1), \"silent\" ) ) {\n\t\tsilent = qtrue;\n\t} else {\n\t\tsilent = qfalse;\n\t}\n\n\tif ( ri.Cmd_Argc() == 2 && !silent ) {\n\t\t// explicit filename\n\t\tCom_sprintf( checkname, MAX_OSPATH, \"screenshots/%s.tga\", ri.Cmd_Argv( 1 ) );\n\t} else {\n\t\t// scan for a free filename\n\n\t\t// if we have saved a previous screenshot, don't scan\n\t\t// again, because recording demo avis can involve\n\t\t// thousands of shots\n\t\tif ( lastNumber == -1 ) {\n\t\t\tlastNumber = 0;\n\t\t}\n\t\t// scan for a free number\n\t\tfor ( ; lastNumber <= 9999 ; lastNumber++ ) {\n\t\t\tR_ScreenshotFilename( lastNumber, checkname );\n\n      if (!ri.FS_FileExists( checkname ))\n      {\n        break; // file doesn't exist\n      }\n\t\t}\n\n\t\tif ( lastNumber >= 9999 ) {\n\t\t\tri.Printf (PRINT_ALL, \"ScreenShot: Couldn't create a file\\n\"); \n\t\t\treturn;\n \t\t}\n\n\t\tlastNumber++;\n\t}\n\n\tR_TakeScreenshot( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname, qfalse );\n\n\tif ( !silent ) {\n\t\tri.Printf (PRINT_ALL, \"Wrote %s\\n\", checkname);\n\t}\n} \n\nvoid R_ScreenShotJPEG_f (void) {\n\tchar\t\tcheckname[MAX_OSPATH];\n\tstatic\tint\tlastNumber = -1;\n\tqboolean\tsilent;\n\n\tif ( !strcmp( ri.Cmd_Argv(1), \"levelshot\" ) ) {\n\t\tR_LevelShot();\n\t\treturn;\n\t}\n\n\tif ( !strcmp( ri.Cmd_Argv(1), \"silent\" ) ) {\n\t\tsilent = qtrue;\n\t} else {\n\t\tsilent = qfalse;\n\t}\n\n\tif ( ri.Cmd_Argc() == 2 && !silent ) {\n\t\t// explicit filename\n\t\tCom_sprintf( checkname, MAX_OSPATH, \"screenshots/%s.jpg\", ri.Cmd_Argv( 1 ) );\n\t} else {\n\t\t// scan for a free filename\n\n\t\t// if we have saved a previous screenshot, don't scan\n\t\t// again, because recording demo avis can involve\n\t\t// thousands of shots\n\t\tif ( lastNumber == -1 ) {\n\t\t\tlastNumber = 0;\n\t\t}\n\t\t// scan for a free number\n\t\tfor ( ; lastNumber <= 9999 ; lastNumber++ ) {\n\t\t\tR_ScreenshotFilenameJPEG( lastNumber, checkname );\n\n      if (!ri.FS_FileExists( checkname ))\n      {\n        break; // file doesn't exist\n      }\n\t\t}\n\n\t\tif ( lastNumber == 10000 ) {\n\t\t\tri.Printf (PRINT_ALL, \"ScreenShot: Couldn't create a file\\n\"); \n\t\t\treturn;\n \t\t}\n\n\t\tlastNumber++;\n\t}\n\n\tR_TakeScreenshot( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname, qtrue );\n\n\tif ( !silent ) {\n\t\tri.Printf (PRINT_ALL, \"Wrote %s\\n\", checkname);\n\t}\n} \n\n//============================================================================\n\n/*\n** GL_SetDefaultState\n*/\nvoid GL_SetDefaultState( void )\n{\n\tqglClearDepth( 1.0f );\n\n\tqglCullFace(GL_FRONT);\n\n\tqglColor4f (1,1,1,1);\n\n\t// initialize downstream texture unit if we're running\n\t// in a multitexture environment\n\tif ( qglActiveTextureARB ) {\n\t\tGL_SelectTexture( 1 );\n\t\tGL_TextureMode( r_textureMode->string );\n\t\tGL_TexEnv( GL_MODULATE );\n\t\tqglDisable( GL_TEXTURE_2D );\n\t\tGL_SelectTexture( 0 );\n\t}\n\n\tqglEnable(GL_TEXTURE_2D);\n\tGL_TextureMode( r_textureMode->string );\n\tGL_TexEnv( GL_MODULATE );\n\n\tqglShadeModel( GL_SMOOTH );\n\tqglDepthFunc( GL_LEQUAL );\n\n\t// the vertex array is always enabled, but the color and texture\n\t// arrays are enabled and disabled around the compiled vertex array call\n\tqglEnableClientState (GL_VERTEX_ARRAY);\n\n\t//\n\t// make sure our GL state vector is set correctly\n\t//\n\tglState.glStateBits = GLS_DEPTHTEST_DISABLE | GLS_DEPTHMASK_TRUE;\n\n\tqglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);\n\tqglDepthMask( GL_TRUE );\n\tqglDisable( GL_DEPTH_TEST );\n\tqglEnable( GL_SCISSOR_TEST );\n\tqglDisable( GL_CULL_FACE );\n\tqglDisable( GL_BLEND );\n}\n\n\n/*\n================\nGfxInfo_f\n================\n*/\nvoid GfxInfo_f( void ) \n{\n\tcvar_t *sys_cpustring = ri.Cvar_Get( \"sys_cpustring\", \"\", 0 );\n\tconst char *enablestrings[] =\n\t{\n\t\t\"disabled\",\n\t\t\"enabled\"\n\t};\n\tconst char *fsstrings[] =\n\t{\n\t\t\"windowed\",\n\t\t\"fullscreen\"\n\t};\n\n\tri.Printf( PRINT_ALL, \"\\nGL_VENDOR: %s\\n\", glConfig.vendor_string );\n\tri.Printf( PRINT_ALL, \"GL_RENDERER: %s\\n\", glConfig.renderer_string );\n\tri.Printf( PRINT_ALL, \"GL_VERSION: %s\\n\", glConfig.version_string );\n\tri.Printf( PRINT_ALL, \"GL_EXTENSIONS: %s\\n\", glConfig.extensions_string );\n\tri.Printf( PRINT_ALL, \"GL_MAX_TEXTURE_SIZE: %d\\n\", glConfig.maxTextureSize );\n\tri.Printf( PRINT_ALL, \"GL_MAX_ACTIVE_TEXTURES_ARB: %d\\n\", glConfig.maxActiveTextures );\n\tri.Printf( PRINT_ALL, \"\\nPIXELFORMAT: color(%d-bits) Z(%d-bit) stencil(%d-bits)\\n\", glConfig.colorBits, glConfig.depthBits, glConfig.stencilBits );\n\tri.Printf( PRINT_ALL, \"MODE: %d, %d x %d %s hz:\", r_mode->integer, glConfig.vidWidth, glConfig.vidHeight, fsstrings[r_fullscreen->integer == 1] );\n\tif ( glConfig.displayFrequency )\n\t{\n\t\tri.Printf( PRINT_ALL, \"%d\\n\", glConfig.displayFrequency );\n\t}\n\telse\n\t{\n\t\tri.Printf( PRINT_ALL, \"N/A\\n\" );\n\t}\n\tif ( glConfig.deviceSupportsGamma )\n\t{\n\t\tri.Printf( PRINT_ALL, \"GAMMA: hardware w/ %d overbright bits\\n\", tr.overbrightBits );\n\t}\n\telse\n\t{\n\t\tri.Printf( PRINT_ALL, \"GAMMA: software w/ %d overbright bits\\n\", tr.overbrightBits );\n\t}\n\tri.Printf( PRINT_ALL, \"CPU: %s\\n\", sys_cpustring->string );\n\n\t// rendering primitives\n\t{\n\t\tint\t\tprimitives;\n\n\t\t// default is to use triangles if compiled vertex arrays are present\n\t\tri.Printf( PRINT_ALL, \"rendering primitives: \" );\n\t\tprimitives = r_primitives->integer;\n\t\tif ( primitives == 0 ) {\n\t\t\tif ( qglLockArraysEXT ) {\n\t\t\t\tprimitives = 2;\n\t\t\t} else {\n\t\t\t\tprimitives = 1;\n\t\t\t}\n\t\t}\n\t\tif ( primitives == -1 ) {\n\t\t\tri.Printf( PRINT_ALL, \"none\\n\" );\n\t\t} else if ( primitives == 2 ) {\n\t\t\tri.Printf( PRINT_ALL, \"single glDrawElements\\n\" );\n\t\t} else if ( primitives == 1 ) {\n\t\t\tri.Printf( PRINT_ALL, \"multiple glArrayElement\\n\" );\n\t\t} else if ( primitives == 3 ) {\n\t\t\tri.Printf( PRINT_ALL, \"multiple glColor4ubv + glTexCoord2fv + glVertex3fv\\n\" );\n\t\t}\n\t}\n\n\tri.Printf( PRINT_ALL, \"texturemode: %s\\n\", r_textureMode->string );\n\tri.Printf( PRINT_ALL, \"picmip: %d\\n\", r_picmip->integer );\n\tri.Printf( PRINT_ALL, \"texture bits: %d\\n\", r_texturebits->integer );\n\tri.Printf( PRINT_ALL, \"multitexture: %s\\n\", enablestrings[qglActiveTextureARB != 0] );\n\tri.Printf( PRINT_ALL, \"compiled vertex arrays: %s\\n\", enablestrings[qglLockArraysEXT != 0 ] );\n\tri.Printf( PRINT_ALL, \"texenv add: %s\\n\", enablestrings[glConfig.textureEnvAddAvailable != 0] );\n\tri.Printf( PRINT_ALL, \"compressed textures: %s\\n\", enablestrings[glConfig.textureCompression!=TC_NONE] );\n\tif ( r_vertexLight->integer || glConfig.hardwareType == GLHW_PERMEDIA2 )\n\t{\n\t\tri.Printf( PRINT_ALL, \"HACK: using vertex lightmap approximation\\n\" );\n\t}\n\tif ( glConfig.hardwareType == GLHW_RAGEPRO )\n\t{\n\t\tri.Printf( PRINT_ALL, \"HACK: ragePro approximations\\n\" );\n\t}\n\tif ( glConfig.hardwareType == GLHW_RIVA128 )\n\t{\n\t\tri.Printf( PRINT_ALL, \"HACK: riva128 approximations\\n\" );\n\t}\n\tif ( glConfig.smpActive ) {\n\t\tri.Printf( PRINT_ALL, \"Using dual processor acceleration\\n\" );\n\t}\n\tif ( r_finish->integer ) {\n\t\tri.Printf( PRINT_ALL, \"Forcing glFinish\\n\" );\n\t}\n}\n\n/*\n===============\nR_Register\n===============\n*/\nvoid R_Register( void ) \n{\n\t//\n\t// latched and archived variables\n\t//\n\tr_glDriver = ri.Cvar_Get( \"r_glDriver\", OPENGL_DRIVER_NAME, CVAR_ARCHIVE | CVAR_LATCH );\n\tr_allowExtensions = ri.Cvar_Get( \"r_allowExtensions\", \"1\", CVAR_ARCHIVE | CVAR_LATCH );\n\tr_ext_compressed_textures = ri.Cvar_Get( \"r_ext_compressed_textures\", \"0\", CVAR_ARCHIVE | CVAR_LATCH );\n\tr_ext_gamma_control = ri.Cvar_Get( \"r_ext_gamma_control\", \"1\", CVAR_ARCHIVE | CVAR_LATCH );\n\tr_ext_multitexture = ri.Cvar_Get( \"r_ext_multitexture\", \"1\", CVAR_ARCHIVE | CVAR_LATCH );\n\tr_ext_compiled_vertex_array = ri.Cvar_Get( \"r_ext_compiled_vertex_array\", \"1\", CVAR_ARCHIVE | CVAR_LATCH);\n#ifdef __linux__ // broken on linux\n\tr_ext_texture_env_add = ri.Cvar_Get( \"r_ext_texture_env_add\", \"0\", CVAR_ARCHIVE | CVAR_LATCH);\n#else\n\tr_ext_texture_env_add = ri.Cvar_Get( \"r_ext_texture_env_add\", \"1\", CVAR_ARCHIVE | CVAR_LATCH);\n#endif\n\n\tr_picmip = ri.Cvar_Get (\"r_picmip\", \"1\", CVAR_ARCHIVE | CVAR_LATCH );\n\tr_roundImagesDown = ri.Cvar_Get (\"r_roundImagesDown\", \"1\", CVAR_ARCHIVE | CVAR_LATCH );\n\tr_colorMipLevels = ri.Cvar_Get (\"r_colorMipLevels\", \"0\", CVAR_LATCH );\n\tAssertCvarRange( r_picmip, 0, 16, qtrue );\n\tr_detailTextures = ri.Cvar_Get( \"r_detailtextures\", \"1\", CVAR_ARCHIVE | CVAR_LATCH );\n\tr_texturebits = ri.Cvar_Get( \"r_texturebits\", \"0\", CVAR_ARCHIVE | CVAR_LATCH );\n\tr_colorbits = ri.Cvar_Get( \"r_colorbits\", \"0\", CVAR_ARCHIVE | CVAR_LATCH );\n\tr_stereo = ri.Cvar_Get( \"r_stereo\", \"0\", CVAR_ARCHIVE | CVAR_LATCH );\n#ifdef __linux__\n\tr_stencilbits = ri.Cvar_Get( \"r_stencilbits\", \"0\", CVAR_ARCHIVE | CVAR_LATCH );\n#else\n\tr_stencilbits = ri.Cvar_Get( \"r_stencilbits\", \"8\", CVAR_ARCHIVE | CVAR_LATCH );\n#endif\n\tr_depthbits = ri.Cvar_Get( \"r_depthbits\", \"0\", CVAR_ARCHIVE | CVAR_LATCH );\n\tr_overBrightBits = ri.Cvar_Get (\"r_overBrightBits\", \"1\", CVAR_ARCHIVE | CVAR_LATCH );\n\tr_ignorehwgamma = ri.Cvar_Get( \"r_ignorehwgamma\", \"0\", CVAR_ARCHIVE | CVAR_LATCH);\n\tr_mode = ri.Cvar_Get( \"r_mode\", \"3\", CVAR_ARCHIVE | CVAR_LATCH );\n\tr_fullscreen = ri.Cvar_Get( \"r_fullscreen\", \"1\", CVAR_ARCHIVE | CVAR_LATCH );\n\tr_customwidth = ri.Cvar_Get( \"r_customwidth\", \"1600\", CVAR_ARCHIVE | CVAR_LATCH );\n\tr_customheight = ri.Cvar_Get( \"r_customheight\", \"1024\", CVAR_ARCHIVE | CVAR_LATCH );\n\tr_customaspect = ri.Cvar_Get( \"r_customaspect\", \"1\", CVAR_ARCHIVE | CVAR_LATCH );\n\tr_simpleMipMaps = ri.Cvar_Get( \"r_simpleMipMaps\", \"1\", CVAR_ARCHIVE | CVAR_LATCH );\n\tr_vertexLight = ri.Cvar_Get( \"r_vertexLight\", \"0\", CVAR_ARCHIVE | CVAR_LATCH );\n\tr_uiFullScreen = ri.Cvar_Get( \"r_uifullscreen\", \"0\", 0);\n\tr_subdivisions = ri.Cvar_Get (\"r_subdivisions\", \"4\", CVAR_ARCHIVE | CVAR_LATCH);\n#if (defined(MACOS_X) || defined(__linux__)) && defined(SMP)\n  // Default to using SMP on Mac OS X or Linux if we have multiple processors\n\tr_smp = ri.Cvar_Get( \"r_smp\", Sys_ProcessorCount() > 1 ? \"1\" : \"0\", CVAR_ARCHIVE | CVAR_LATCH);\n#else        \n\tr_smp = ri.Cvar_Get( \"r_smp\", \"0\", CVAR_ARCHIVE | CVAR_LATCH);\n#endif\n\tr_ignoreFastPath = ri.Cvar_Get( \"r_ignoreFastPath\", \"1\", CVAR_ARCHIVE | CVAR_LATCH );\n\n\t//\n\t// temporary latched variables that can only change over a restart\n\t//\n\tr_displayRefresh = ri.Cvar_Get( \"r_displayRefresh\", \"0\", CVAR_LATCH );\n\tAssertCvarRange( r_displayRefresh, 0, 200, qtrue );\n\tr_fullbright = ri.Cvar_Get (\"r_fullbright\", \"0\", CVAR_LATCH|CVAR_CHEAT );\n\tr_mapOverBrightBits = ri.Cvar_Get (\"r_mapOverBrightBits\", \"2\", CVAR_LATCH );\n\tr_intensity = ri.Cvar_Get (\"r_intensity\", \"1\", CVAR_LATCH );\n\tr_singleShader = ri.Cvar_Get (\"r_singleShader\", \"0\", CVAR_CHEAT | CVAR_LATCH );\n\n\t//\n\t// archived variables that can change at any time\n\t//\n\tr_lodCurveError = ri.Cvar_Get( \"r_lodCurveError\", \"250\", CVAR_ARCHIVE|CVAR_CHEAT );\n\tr_lodbias = ri.Cvar_Get( \"r_lodbias\", \"0\", CVAR_ARCHIVE );\n\tr_flares = ri.Cvar_Get (\"r_flares\", \"0\", CVAR_ARCHIVE );\n\tr_znear = ri.Cvar_Get( \"r_znear\", \"4\", CVAR_CHEAT );\n\tAssertCvarRange( r_znear, 0.001f, 200, qtrue );\n\tr_ignoreGLErrors = ri.Cvar_Get( \"r_ignoreGLErrors\", \"1\", CVAR_ARCHIVE );\n\tr_fastsky = ri.Cvar_Get( \"r_fastsky\", \"0\", CVAR_ARCHIVE );\n\tr_inGameVideo = ri.Cvar_Get( \"r_inGameVideo\", \"1\", CVAR_ARCHIVE );\n\tr_drawSun = ri.Cvar_Get( \"r_drawSun\", \"0\", CVAR_ARCHIVE );\n\tr_dynamiclight = ri.Cvar_Get( \"r_dynamiclight\", \"1\", CVAR_ARCHIVE );\n\tr_dlightBacks = ri.Cvar_Get( \"r_dlightBacks\", \"1\", CVAR_ARCHIVE );\n\tr_finish = ri.Cvar_Get (\"r_finish\", \"0\", CVAR_ARCHIVE);\n\tr_textureMode = ri.Cvar_Get( \"r_textureMode\", \"GL_LINEAR_MIPMAP_NEAREST\", CVAR_ARCHIVE );\n\tr_swapInterval = ri.Cvar_Get( \"r_swapInterval\", \"0\", CVAR_ARCHIVE );\n#ifdef __MACOS__\n\tr_gamma = ri.Cvar_Get( \"r_gamma\", \"1.2\", CVAR_ARCHIVE );\n#else\n\tr_gamma = ri.Cvar_Get( \"r_gamma\", \"1\", CVAR_ARCHIVE );\n#endif\n\tr_facePlaneCull = ri.Cvar_Get (\"r_facePlaneCull\", \"1\", CVAR_ARCHIVE );\n\n\tr_railWidth = ri.Cvar_Get( \"r_railWidth\", \"16\", CVAR_ARCHIVE );\n\tr_railCoreWidth = ri.Cvar_Get( \"r_railCoreWidth\", \"6\", CVAR_ARCHIVE );\n\tr_railSegmentLength = ri.Cvar_Get( \"r_railSegmentLength\", \"32\", CVAR_ARCHIVE );\n\n\tr_primitives = ri.Cvar_Get( \"r_primitives\", \"0\", CVAR_ARCHIVE );\n\n\tr_ambientScale = ri.Cvar_Get( \"r_ambientScale\", \"0.6\", CVAR_CHEAT );\n\tr_directedScale = ri.Cvar_Get( \"r_directedScale\", \"1\", CVAR_CHEAT );\n\n\t//\n\t// temporary variables that can change at any time\n\t//\n\tr_showImages = ri.Cvar_Get( \"r_showImages\", \"0\", CVAR_TEMP );\n\n\tr_debugLight = ri.Cvar_Get( \"r_debuglight\", \"0\", CVAR_TEMP );\n\tr_debugSort = ri.Cvar_Get( \"r_debugSort\", \"0\", CVAR_CHEAT );\n\tr_printShaders = ri.Cvar_Get( \"r_printShaders\", \"0\", 0 );\n\tr_saveFontData = ri.Cvar_Get( \"r_saveFontData\", \"0\", 0 );\n\n\tr_nocurves = ri.Cvar_Get (\"r_nocurves\", \"0\", CVAR_CHEAT );\n\tr_drawworld = ri.Cvar_Get (\"r_drawworld\", \"1\", CVAR_CHEAT );\n\tr_lightmap = ri.Cvar_Get (\"r_lightmap\", \"0\", 0 );\n\tr_portalOnly = ri.Cvar_Get (\"r_portalOnly\", \"0\", CVAR_CHEAT );\n\n\tr_flareSize = ri.Cvar_Get (\"r_flareSize\", \"40\", CVAR_CHEAT);\n\tr_flareFade = ri.Cvar_Get (\"r_flareFade\", \"7\", CVAR_CHEAT);\n\n\tr_showSmp = ri.Cvar_Get (\"r_showSmp\", \"0\", CVAR_CHEAT);\n\tr_skipBackEnd = ri.Cvar_Get (\"r_skipBackEnd\", \"0\", CVAR_CHEAT);\n\n\tr_measureOverdraw = ri.Cvar_Get( \"r_measureOverdraw\", \"0\", CVAR_CHEAT );\n\tr_lodscale = ri.Cvar_Get( \"r_lodscale\", \"5\", CVAR_CHEAT );\n\tr_norefresh = ri.Cvar_Get (\"r_norefresh\", \"0\", CVAR_CHEAT);\n\tr_drawentities = ri.Cvar_Get (\"r_drawentities\", \"1\", CVAR_CHEAT );\n\tr_ignore = ri.Cvar_Get( \"r_ignore\", \"1\", CVAR_CHEAT );\n\tr_nocull = ri.Cvar_Get (\"r_nocull\", \"0\", CVAR_CHEAT);\n\tr_novis = ri.Cvar_Get (\"r_novis\", \"0\", CVAR_CHEAT);\n\tr_showcluster = ri.Cvar_Get (\"r_showcluster\", \"0\", CVAR_CHEAT);\n\tr_speeds = ri.Cvar_Get (\"r_speeds\", \"0\", CVAR_CHEAT);\n\tr_verbose = ri.Cvar_Get( \"r_verbose\", \"0\", CVAR_CHEAT );\n\tr_logFile = ri.Cvar_Get( \"r_logFile\", \"0\", CVAR_CHEAT );\n\tr_debugSurface = ri.Cvar_Get (\"r_debugSurface\", \"0\", CVAR_CHEAT);\n\tr_nobind = ri.Cvar_Get (\"r_nobind\", \"0\", CVAR_CHEAT);\n\tr_showtris = ri.Cvar_Get (\"r_showtris\", \"0\", CVAR_CHEAT);\n\tr_showsky = ri.Cvar_Get (\"r_showsky\", \"0\", CVAR_CHEAT);\n\tr_shownormals = ri.Cvar_Get (\"r_shownormals\", \"0\", CVAR_CHEAT);\n\tr_clear = ri.Cvar_Get (\"r_clear\", \"0\", CVAR_CHEAT);\n\tr_offsetFactor = ri.Cvar_Get( \"r_offsetfactor\", \"-1\", CVAR_CHEAT );\n\tr_offsetUnits = ri.Cvar_Get( \"r_offsetunits\", \"-2\", CVAR_CHEAT );\n\tr_drawBuffer = ri.Cvar_Get( \"r_drawBuffer\", \"GL_BACK\", CVAR_CHEAT );\n\tr_lockpvs = ri.Cvar_Get (\"r_lockpvs\", \"0\", CVAR_CHEAT);\n\tr_noportals = ri.Cvar_Get (\"r_noportals\", \"0\", CVAR_CHEAT);\n\tr_shadows = ri.Cvar_Get( \"cg_shadows\", \"1\", 0 );\n\n\tr_maxpolys = ri.Cvar_Get( \"r_maxpolys\", va(\"%d\", MAX_POLYS), 0);\n\tr_maxpolyverts = ri.Cvar_Get( \"r_maxpolyverts\", va(\"%d\", MAX_POLYVERTS), 0);\n\n\t// make sure all the commands added here are also\n\t// removed in R_Shutdown\n\tri.Cmd_AddCommand( \"imagelist\", R_ImageList_f );\n\tri.Cmd_AddCommand( \"shaderlist\", R_ShaderList_f );\n\tri.Cmd_AddCommand( \"skinlist\", R_SkinList_f );\n\tri.Cmd_AddCommand( \"modellist\", R_Modellist_f );\n\tri.Cmd_AddCommand( \"modelist\", R_ModeList_f );\n\tri.Cmd_AddCommand( \"screenshot\", R_ScreenShot_f );\n\tri.Cmd_AddCommand( \"screenshotJPEG\", R_ScreenShotJPEG_f );\n\tri.Cmd_AddCommand( \"gfxinfo\", GfxInfo_f );\n}\n\n/*\n===============\nR_Init\n===============\n*/\nvoid R_Init( void ) {\t\n\tint\terr;\n\tint i;\n\tbyte *ptr;\n\n\tri.Printf( PRINT_ALL, \"----- R_Init -----\\n\" );\n\n\t// clear all our internal state\n\tCom_Memset( &tr, 0, sizeof( tr ) );\n\tCom_Memset( &backEnd, 0, sizeof( backEnd ) );\n\tCom_Memset( &tess, 0, sizeof( tess ) );\n\n//\tSwap_Init();\n\n\tif ( (int)tess.xyz & 15 ) {\n\t\tCom_Printf( \"WARNING: tess.xyz not 16 byte aligned\\n\" );\n\t}\n\tCom_Memset( tess.constantColor255, 255, sizeof( tess.constantColor255 ) );\n\n\t//\n\t// init function tables\n\t//\n\tfor ( i = 0; i < FUNCTABLE_SIZE; i++ )\n\t{\n\t\ttr.sinTable[i]\t\t= sin( DEG2RAD( i * 360.0f / ( ( float ) ( FUNCTABLE_SIZE - 1 ) ) ) );\n\t\ttr.squareTable[i]\t= ( i < FUNCTABLE_SIZE/2 ) ? 1.0f : -1.0f;\n\t\ttr.sawToothTable[i] = (float)i / FUNCTABLE_SIZE;\n\t\ttr.inverseSawToothTable[i] = 1.0f - tr.sawToothTable[i];\n\n\t\tif ( i < FUNCTABLE_SIZE / 2 )\n\t\t{\n\t\t\tif ( i < FUNCTABLE_SIZE / 4 )\n\t\t\t{\n\t\t\t\ttr.triangleTable[i] = ( float ) i / ( FUNCTABLE_SIZE / 4 );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttr.triangleTable[i] = 1.0f - tr.triangleTable[i-FUNCTABLE_SIZE / 4];\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\ttr.triangleTable[i] = -tr.triangleTable[i-FUNCTABLE_SIZE/2];\n\t\t}\n\t}\n\n\tR_InitFogTable();\n\n\tR_NoiseInit();\n\n\tR_Register();\n\n\tmax_polys = r_maxpolys->integer;\n\tif (max_polys < MAX_POLYS)\n\t\tmax_polys = MAX_POLYS;\n\n\tmax_polyverts = r_maxpolyverts->integer;\n\tif (max_polyverts < MAX_POLYVERTS)\n\t\tmax_polyverts = MAX_POLYVERTS;\n\n\tptr = ri.Hunk_Alloc( sizeof( *backEndData[0] ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low);\n\tbackEndData[0] = (backEndData_t *) ptr;\n\tbackEndData[0]->polys = (srfPoly_t *) ((char *) ptr + sizeof( *backEndData[0] ));\n\tbackEndData[0]->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData[0] ) + sizeof(srfPoly_t) * max_polys);\n\tif ( r_smp->integer ) {\n\t\tptr = ri.Hunk_Alloc( sizeof( *backEndData[1] ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low);\n\t\tbackEndData[1] = (backEndData_t *) ptr;\n\t\tbackEndData[1]->polys = (srfPoly_t *) ((char *) ptr + sizeof( *backEndData[1] ));\n\t\tbackEndData[1]->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData[1] ) + sizeof(srfPoly_t) * max_polys);\n\t} else {\n\t\tbackEndData[1] = NULL;\n\t}\n\tR_ToggleSmpFrame();\n\n\tInitOpenGL();\n\n\tR_InitImages();\n\n\tR_InitShaders();\n\n\tR_InitSkins();\n\n\tR_ModelInit();\n\n\tR_InitFreeType();\n\n\n\terr = qglGetError();\n\tif ( err != GL_NO_ERROR )\n\t\tri.Printf (PRINT_ALL, \"glGetError() = 0x%x\\n\", err);\n\n\tri.Printf( PRINT_ALL, \"----- finished R_Init -----\\n\" );\n}\n\n/*\n===============\nRE_Shutdown\n===============\n*/\nvoid RE_Shutdown( qboolean destroyWindow ) {\t\n\n\tri.Printf( PRINT_ALL, \"RE_Shutdown( %i )\\n\", destroyWindow );\n\n\tri.Cmd_RemoveCommand (\"modellist\");\n\tri.Cmd_RemoveCommand (\"screenshotJPEG\");\n\tri.Cmd_RemoveCommand (\"screenshot\");\n\tri.Cmd_RemoveCommand (\"imagelist\");\n\tri.Cmd_RemoveCommand (\"shaderlist\");\n\tri.Cmd_RemoveCommand (\"skinlist\");\n\tri.Cmd_RemoveCommand (\"gfxinfo\");\n\tri.Cmd_RemoveCommand( \"modelist\" );\n\tri.Cmd_RemoveCommand( \"shaderstate\" );\n\n\n\tif ( tr.registered ) {\n\t\tR_SyncRenderThread();\n\t\tR_ShutdownCommandBuffers();\n\t\tR_DeleteTextures();\n\t}\n\n\tR_DoneFreeType();\n\n\t// shut down platform specific OpenGL stuff\n\tif ( destroyWindow ) {\n\t\tGLimp_Shutdown();\n\t}\n\n\ttr.registered = qfalse;\n}\n\n\n/*\n=============\nRE_EndRegistration\n\nTouch all images to make sure they are resident\n=============\n*/\nvoid RE_EndRegistration( void ) {\n\tR_SyncRenderThread();\n\tif (!Sys_LowPhysicalMemory()) {\n\t\tRB_ShowImages();\n\t}\n}\n\n\n/*\n@@@@@@@@@@@@@@@@@@@@@\nGetRefAPI\n\n@@@@@@@@@@@@@@@@@@@@@\n*/\nrefexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp ) {\n\tstatic refexport_t\tre;\n\n\tri = *rimp;\n\n\tCom_Memset( &re, 0, sizeof( re ) );\n\n\tif ( apiVersion != REF_API_VERSION ) {\n\t\tri.Printf(PRINT_ALL, \"Mismatched REF_API_VERSION: expected %i, got %i\\n\", \n\t\t\tREF_API_VERSION, apiVersion );\n\t\treturn NULL;\n\t}\n\n\t// the RE_ functions are Renderer Entry points\n\n\tre.Shutdown = RE_Shutdown;\n\n\tre.BeginRegistration = RE_BeginRegistration;\n\tre.RegisterModel = RE_RegisterModel;\n\tre.RegisterSkin = RE_RegisterSkin;\n\tre.RegisterShader = RE_RegisterShader;\n\tre.RegisterShaderNoMip = RE_RegisterShaderNoMip;\n\tre.LoadWorld = RE_LoadWorldMap;\n\tre.SetWorldVisData = RE_SetWorldVisData;\n\tre.EndRegistration = RE_EndRegistration;\n\n\tre.BeginFrame = RE_BeginFrame;\n\tre.EndFrame = RE_EndFrame;\n\n\tre.MarkFragments = R_MarkFragments;\n\tre.LerpTag = R_LerpTag;\n\tre.ModelBounds = R_ModelBounds;\n\n\tre.ClearScene = RE_ClearScene;\n\tre.AddRefEntityToScene = RE_AddRefEntityToScene;\n\tre.AddPolyToScene = RE_AddPolyToScene;\n\tre.LightForPoint = R_LightForPoint;\n\tre.AddLightToScene = RE_AddLightToScene;\n\tre.AddAdditiveLightToScene = RE_AddAdditiveLightToScene;\n\tre.RenderScene = RE_RenderScene;\n\n\tre.SetColor = RE_SetColor;\n\tre.DrawStretchPic = RE_StretchPic;\n\tre.DrawStretchRaw = RE_StretchRaw;\n\tre.UploadCinematic = RE_UploadCinematic;\n\n\tre.RegisterFont = RE_RegisterFont;\n\tre.RemapShader = R_RemapShader;\n\tre.GetEntityToken = R_GetEntityToken;\n\tre.inPVS = R_inPVS;\n\n\treturn &re;\n}\n"
  },
  {
    "path": "code/renderer/tr_light.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// tr_light.c\n\n#include \"tr_local.h\"\n\n#define\tDLIGHT_AT_RADIUS\t\t16\n// at the edge of a dlight's influence, this amount of light will be added\n\n#define\tDLIGHT_MINIMUM_RADIUS\t16\t\t\n// never calculate a range less than this to prevent huge light numbers\n\n\n/*\n===============\nR_TransformDlights\n\nTransforms the origins of an array of dlights.\nUsed by both the front end (for DlightBmodel) and\nthe back end (before doing the lighting calculation)\n===============\n*/\nvoid R_TransformDlights( int count, dlight_t *dl, orientationr_t *or) {\n\tint\t\ti;\n\tvec3_t\ttemp;\n\n\tfor ( i = 0 ; i < count ; i++, dl++ ) {\n\t\tVectorSubtract( dl->origin, or->origin, temp );\n\t\tdl->transformed[0] = DotProduct( temp, or->axis[0] );\n\t\tdl->transformed[1] = DotProduct( temp, or->axis[1] );\n\t\tdl->transformed[2] = DotProduct( temp, or->axis[2] );\n\t}\n}\n\n/*\n=============\nR_DlightBmodel\n\nDetermine which dynamic lights may effect this bmodel\n=============\n*/\nvoid R_DlightBmodel( bmodel_t *bmodel ) {\n\tint\t\t\ti, j;\n\tdlight_t\t*dl;\n\tint\t\t\tmask;\n\tmsurface_t\t*surf;\n\n\t// transform all the lights\n\tR_TransformDlights( tr.refdef.num_dlights, tr.refdef.dlights, &tr.or );\n\n\tmask = 0;\n\tfor ( i=0 ; i<tr.refdef.num_dlights ; i++ ) {\n\t\tdl = &tr.refdef.dlights[i];\n\n\t\t// see if the point is close enough to the bounds to matter\n\t\tfor ( j = 0 ; j < 3 ; j++ ) {\n\t\t\tif ( dl->transformed[j] - bmodel->bounds[1][j] > dl->radius ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( bmodel->bounds[0][j] - dl->transformed[j] > dl->radius ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif ( j < 3 ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// we need to check this light\n\t\tmask |= 1 << i;\n\t}\n\n\ttr.currentEntity->needDlights = (mask != 0);\n\n\t// set the dlight bits in all the surfaces\n\tfor ( i = 0 ; i < bmodel->numSurfaces ; i++ ) {\n\t\tsurf = bmodel->firstSurface + i;\n\n\t\tif ( *surf->data == SF_FACE ) {\n\t\t\t((srfSurfaceFace_t *)surf->data)->dlightBits[ tr.smpFrame ] = mask;\n\t\t} else if ( *surf->data == SF_GRID ) {\n\t\t\t((srfGridMesh_t *)surf->data)->dlightBits[ tr.smpFrame ] = mask;\n\t\t} else if ( *surf->data == SF_TRIANGLES ) {\n\t\t\t((srfTriangles_t *)surf->data)->dlightBits[ tr.smpFrame ] = mask;\n\t\t}\n\t}\n}\n\n\n/*\n=============================================================================\n\nLIGHT SAMPLING\n\n=============================================================================\n*/\n\nextern\tcvar_t\t*r_ambientScale;\nextern\tcvar_t\t*r_directedScale;\nextern\tcvar_t\t*r_debugLight;\n\n/*\n=================\nR_SetupEntityLightingGrid\n\n=================\n*/\nstatic void R_SetupEntityLightingGrid( trRefEntity_t *ent ) {\n\tvec3_t\tlightOrigin;\n\tint\t\tpos[3];\n\tint\t\ti, j;\n\tbyte\t*gridData;\n\tfloat\tfrac[3];\n\tint\t\tgridStep[3];\n\tvec3_t\tdirection;\n\tfloat\ttotalFactor;\n\n\tif ( ent->e.renderfx & RF_LIGHTING_ORIGIN ) {\n\t\t// seperate lightOrigins are needed so an object that is\n\t\t// sinking into the ground can still be lit, and so\n\t\t// multi-part models can be lit identically\n\t\tVectorCopy( ent->e.lightingOrigin, lightOrigin );\n\t} else {\n\t\tVectorCopy( ent->e.origin, lightOrigin );\n\t}\n\n\tVectorSubtract( lightOrigin, tr.world->lightGridOrigin, lightOrigin );\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tfloat\tv;\n\n\t\tv = lightOrigin[i]*tr.world->lightGridInverseSize[i];\n\t\tpos[i] = floor( v );\n\t\tfrac[i] = v - pos[i];\n\t\tif ( pos[i] < 0 ) {\n\t\t\tpos[i] = 0;\n\t\t} else if ( pos[i] >= tr.world->lightGridBounds[i] - 1 ) {\n\t\t\tpos[i] = tr.world->lightGridBounds[i] - 1;\n\t\t}\n\t}\n\n\tVectorClear( ent->ambientLight );\n\tVectorClear( ent->directedLight );\n\tVectorClear( direction );\n\n\tassert( tr.world->lightGridData ); // bk010103 - NULL with -nolight maps\n\n\t// trilerp the light value\n\tgridStep[0] = 8;\n\tgridStep[1] = 8 * tr.world->lightGridBounds[0];\n\tgridStep[2] = 8 * tr.world->lightGridBounds[0] * tr.world->lightGridBounds[1];\n\tgridData = tr.world->lightGridData + pos[0] * gridStep[0]\n\t\t+ pos[1] * gridStep[1] + pos[2] * gridStep[2];\n\n\ttotalFactor = 0;\n\tfor ( i = 0 ; i < 8 ; i++ ) {\n\t\tfloat\tfactor;\n\t\tbyte\t*data;\n\t\tint\t\tlat, lng;\n\t\tvec3_t\tnormal;\n\t\t#if idppc\n\t\tfloat d0, d1, d2, d3, d4, d5;\n\t\t#endif\n\t\tfactor = 1.0;\n\t\tdata = gridData;\n\t\tfor ( j = 0 ; j < 3 ; j++ ) {\n\t\t\tif ( i & (1<<j) ) {\n\t\t\t\tfactor *= frac[j];\n\t\t\t\tdata += gridStep[j];\n\t\t\t} else {\n\t\t\t\tfactor *= (1.0f - frac[j]);\n\t\t\t}\n\t\t}\n\n\t\tif ( !(data[0]+data[1]+data[2]) ) {\n\t\t\tcontinue;\t// ignore samples in walls\n\t\t}\n\t\ttotalFactor += factor;\n\t\t#if idppc\n\t\td0 = data[0]; d1 = data[1]; d2 = data[2];\n\t\td3 = data[3]; d4 = data[4]; d5 = data[5];\n\n\t\tent->ambientLight[0] += factor * d0;\n\t\tent->ambientLight[1] += factor * d1;\n\t\tent->ambientLight[2] += factor * d2;\n\n\t\tent->directedLight[0] += factor * d3;\n\t\tent->directedLight[1] += factor * d4;\n\t\tent->directedLight[2] += factor * d5;\n\t\t#else\n\t\tent->ambientLight[0] += factor * data[0];\n\t\tent->ambientLight[1] += factor * data[1];\n\t\tent->ambientLight[2] += factor * data[2];\n\n\t\tent->directedLight[0] += factor * data[3];\n\t\tent->directedLight[1] += factor * data[4];\n\t\tent->directedLight[2] += factor * data[5];\n\t\t#endif\n\t\tlat = data[7];\n\t\tlng = data[6];\n\t\tlat *= (FUNCTABLE_SIZE/256);\n\t\tlng *= (FUNCTABLE_SIZE/256);\n\n\t\t// decode X as cos( lat ) * sin( long )\n\t\t// decode Y as sin( lat ) * sin( long )\n\t\t// decode Z as cos( long )\n\n\t\tnormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng];\n\t\tnormal[1] = tr.sinTable[lat] * tr.sinTable[lng];\n\t\tnormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK];\n\n\t\tVectorMA( direction, factor, normal, direction );\n\t}\n\n\tif ( totalFactor > 0 && totalFactor < 0.99 ) {\n\t\ttotalFactor = 1.0f / totalFactor;\n\t\tVectorScale( ent->ambientLight, totalFactor, ent->ambientLight );\n\t\tVectorScale( ent->directedLight, totalFactor, ent->directedLight );\n\t}\n\n\tVectorScale( ent->ambientLight, r_ambientScale->value, ent->ambientLight );\n\tVectorScale( ent->directedLight, r_directedScale->value, ent->directedLight );\n\n\tVectorNormalize2( direction, ent->lightDir );\n}\n\n\n/*\n===============\nLogLight\n===============\n*/\nstatic void LogLight( trRefEntity_t *ent ) {\n\tint\tmax1, max2;\n\n\tif ( !(ent->e.renderfx & RF_FIRST_PERSON ) ) {\n\t\treturn;\n\t}\n\n\tmax1 = ent->ambientLight[0];\n\tif ( ent->ambientLight[1] > max1 ) {\n\t\tmax1 = ent->ambientLight[1];\n\t} else if ( ent->ambientLight[2] > max1 ) {\n\t\tmax1 = ent->ambientLight[2];\n\t}\n\n\tmax2 = ent->directedLight[0];\n\tif ( ent->directedLight[1] > max2 ) {\n\t\tmax2 = ent->directedLight[1];\n\t} else if ( ent->directedLight[2] > max2 ) {\n\t\tmax2 = ent->directedLight[2];\n\t}\n\n\tri.Printf( PRINT_ALL, \"amb:%i  dir:%i\\n\", max1, max2 );\n}\n\n/*\n=================\nR_SetupEntityLighting\n\nCalculates all the lighting values that will be used\nby the Calc_* functions\n=================\n*/\nvoid R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) {\n\tint\t\t\t\ti;\n\tdlight_t\t\t*dl;\n\tfloat\t\t\tpower;\n\tvec3_t\t\t\tdir;\n\tfloat\t\t\td;\n\tvec3_t\t\t\tlightDir;\n\tvec3_t\t\t\tlightOrigin;\n\n\t// lighting calculations \n\tif ( ent->lightingCalculated ) {\n\t\treturn;\n\t}\n\tent->lightingCalculated = qtrue;\n\n\t//\n\t// trace a sample point down to find ambient light\n\t//\n\tif ( ent->e.renderfx & RF_LIGHTING_ORIGIN ) {\n\t\t// seperate lightOrigins are needed so an object that is\n\t\t// sinking into the ground can still be lit, and so\n\t\t// multi-part models can be lit identically\n\t\tVectorCopy( ent->e.lightingOrigin, lightOrigin );\n\t} else {\n\t\tVectorCopy( ent->e.origin, lightOrigin );\n\t}\n\n\t// if NOWORLDMODEL, only use dynamic lights (menu system, etc)\n\tif ( !(refdef->rdflags & RDF_NOWORLDMODEL ) \n\t\t&& tr.world->lightGridData ) {\n\t\tR_SetupEntityLightingGrid( ent );\n\t} else {\n\t\tent->ambientLight[0] = ent->ambientLight[1] = \n\t\t\tent->ambientLight[2] = tr.identityLight * 150;\n\t\tent->directedLight[0] = ent->directedLight[1] = \n\t\t\tent->directedLight[2] = tr.identityLight * 150;\n\t\tVectorCopy( tr.sunDirection, ent->lightDir );\n\t}\n\n\t// bonus items and view weapons have a fixed minimum add\n\tif ( 1 /* ent->e.renderfx & RF_MINLIGHT */ ) {\n\t\t// give everything a minimum light add\n\t\tent->ambientLight[0] += tr.identityLight * 32;\n\t\tent->ambientLight[1] += tr.identityLight * 32;\n\t\tent->ambientLight[2] += tr.identityLight * 32;\n\t}\n\n\t//\n\t// modify the light by dynamic lights\n\t//\n\td = VectorLength( ent->directedLight );\n\tVectorScale( ent->lightDir, d, lightDir );\n\n\tfor ( i = 0 ; i < refdef->num_dlights ; i++ ) {\n\t\tdl = &refdef->dlights[i];\n\t\tVectorSubtract( dl->origin, lightOrigin, dir );\n\t\td = VectorNormalize( dir );\n\n\t\tpower = DLIGHT_AT_RADIUS * ( dl->radius * dl->radius );\n\t\tif ( d < DLIGHT_MINIMUM_RADIUS ) {\n\t\t\td = DLIGHT_MINIMUM_RADIUS;\n\t\t}\n\t\td = power / ( d * d );\n\n\t\tVectorMA( ent->directedLight, d, dl->color, ent->directedLight );\n\t\tVectorMA( lightDir, d, dir, lightDir );\n\t}\n\n\t// clamp ambient\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tif ( ent->ambientLight[i] > tr.identityLightByte ) {\n\t\t\tent->ambientLight[i] = tr.identityLightByte;\n\t\t}\n\t}\n\n\tif ( r_debugLight->integer ) {\n\t\tLogLight( ent );\n\t}\n\n\t// save out the byte packet version\n\t((byte *)&ent->ambientLightInt)[0] = myftol( ent->ambientLight[0] );\n\t((byte *)&ent->ambientLightInt)[1] = myftol( ent->ambientLight[1] );\n\t((byte *)&ent->ambientLightInt)[2] = myftol( ent->ambientLight[2] );\n\t((byte *)&ent->ambientLightInt)[3] = 0xff;\n\t\n\t// transform the direction to local space\n\tVectorNormalize( lightDir );\n\tent->lightDir[0] = DotProduct( lightDir, ent->e.axis[0] );\n\tent->lightDir[1] = DotProduct( lightDir, ent->e.axis[1] );\n\tent->lightDir[2] = DotProduct( lightDir, ent->e.axis[2] );\n}\n\n/*\n=================\nR_LightForPoint\n=================\n*/\nint R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir )\n{\n\ttrRefEntity_t ent;\n\t\n\t// bk010103 - this segfaults with -nolight maps\n\tif ( tr.world->lightGridData == NULL )\n\t  return qfalse;\n\n\tCom_Memset(&ent, 0, sizeof(ent));\n\tVectorCopy( point, ent.e.origin );\n\tR_SetupEntityLightingGrid( &ent );\n\tVectorCopy(ent.ambientLight, ambientLight);\n\tVectorCopy(ent.directedLight, directedLight);\n\tVectorCopy(ent.lightDir, lightDir);\n\n\treturn qtrue;\n}\n"
  },
  {
    "path": "code/renderer/tr_local.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n\n#ifndef TR_LOCAL_H\n#define TR_LOCAL_H\n\n#include \"../game/q_shared.h\"\n#include \"../qcommon/qfiles.h\"\n#include \"../qcommon/qcommon.h\"\n#include \"tr_public.h\"\n#include \"qgl.h\"\n\n#define GL_INDEX_TYPE\t\tGL_UNSIGNED_INT\ntypedef unsigned int glIndex_t;\n\n// fast float to int conversion\n#if id386 && !( (defined __linux__ || defined __FreeBSD__ ) && (defined __i386__ ) ) // rb010123\nlong myftol( float f );\n#else\n#define\tmyftol(x) ((int)(x))\n#endif\n\n\n// everything that is needed by the backend needs\n// to be double buffered to allow it to run in\n// parallel on a dual cpu machine\n#define\tSMP_FRAMES\t\t2\n\n// 12 bits\n// see QSORT_SHADERNUM_SHIFT\n#define\tMAX_SHADERS\t\t\t\t16384\n\n//#define MAX_SHADER_STATES 2048\n#define MAX_STATES_PER_SHADER 32\n#define MAX_STATE_NAME 32\n\n// can't be increased without changing bit packing for drawsurfs\n\n\ntypedef struct dlight_s {\n\tvec3_t\torigin;\n\tvec3_t\tcolor;\t\t\t\t// range from 0.0 to 1.0, should be color normalized\n\tfloat\tradius;\n\n\tvec3_t\ttransformed;\t\t// origin in local coordinate system\n\tint\t\tadditive;\t\t\t// texture detail is lost tho when the lightmap is dark\n} dlight_t;\n\n\n// a trRefEntity_t has all the information passed in by\n// the client game, as well as some locally derived info\ntypedef struct {\n\trefEntity_t\te;\n\n\tfloat\t\taxisLength;\t\t// compensate for non-normalized axis\n\n\tqboolean\tneedDlights;\t// true for bmodels that touch a dlight\n\tqboolean\tlightingCalculated;\n\tvec3_t\t\tlightDir;\t\t// normalized direction towards light\n\tvec3_t\t\tambientLight;\t// color normalized to 0-255\n\tint\t\t\tambientLightInt;\t// 32 bit rgba packed\n\tvec3_t\t\tdirectedLight;\n} trRefEntity_t;\n\n\ntypedef struct {\n\tvec3_t\t\torigin;\t\t\t// in world coordinates\n\tvec3_t\t\taxis[3];\t\t// orientation in world\n\tvec3_t\t\tviewOrigin;\t\t// viewParms->or.origin in local coordinates\n\tfloat\t\tmodelMatrix[16];\n} orientationr_t;\n\ntypedef struct image_s {\n\tchar\t\timgName[MAX_QPATH];\t\t// game path, including extension\n\tint\t\t\twidth, height;\t\t\t\t// source image\n\tint\t\t\tuploadWidth, uploadHeight;\t// after power of two and picmip but not including clamp to MAX_TEXTURE_SIZE\n\tGLuint\t\ttexnum;\t\t\t\t\t// gl texture binding\n\n\tint\t\t\tframeUsed;\t\t\t// for texture usage in frame statistics\n\n\tint\t\t\tinternalFormat;\n\tint\t\t\tTMU;\t\t\t\t// only needed for voodoo2\n\n\tqboolean\tmipmap;\n\tqboolean\tallowPicmip;\n\tint\t\t\twrapClampMode;\t\t// GL_CLAMP or GL_REPEAT\n\n\tstruct image_s*\tnext;\n} image_t;\n\n//===============================================================================\n\ntypedef enum {\n\tSS_BAD,\n\tSS_PORTAL,\t\t\t// mirrors, portals, viewscreens\n\tSS_ENVIRONMENT,\t\t// sky box\n\tSS_OPAQUE,\t\t\t// opaque\n\n\tSS_DECAL,\t\t\t// scorch marks, etc.\n\tSS_SEE_THROUGH,\t\t// ladders, grates, grills that may have small blended edges\n\t\t\t\t\t\t// in addition to alpha test\n\tSS_BANNER,\n\n\tSS_FOG,\n\n\tSS_UNDERWATER,\t\t// for items that should be drawn in front of the water plane\n\n\tSS_BLEND0,\t\t\t// regular transparency and filters\n\tSS_BLEND1,\t\t\t// generally only used for additive type effects\n\tSS_BLEND2,\n\tSS_BLEND3,\n\n\tSS_BLEND6,\n\tSS_STENCIL_SHADOW,\n\tSS_ALMOST_NEAREST,\t// gun smoke puffs\n\n\tSS_NEAREST\t\t\t// blood blobs\n} shaderSort_t;\n\n\n#define MAX_SHADER_STAGES 8\n\ntypedef enum {\n\tGF_NONE,\n\n\tGF_SIN,\n\tGF_SQUARE,\n\tGF_TRIANGLE,\n\tGF_SAWTOOTH, \n\tGF_INVERSE_SAWTOOTH, \n\n\tGF_NOISE\n\n} genFunc_t;\n\n\ntypedef enum {\n\tDEFORM_NONE,\n\tDEFORM_WAVE,\n\tDEFORM_NORMALS,\n\tDEFORM_BULGE,\n\tDEFORM_MOVE,\n\tDEFORM_PROJECTION_SHADOW,\n\tDEFORM_AUTOSPRITE,\n\tDEFORM_AUTOSPRITE2,\n\tDEFORM_TEXT0,\n\tDEFORM_TEXT1,\n\tDEFORM_TEXT2,\n\tDEFORM_TEXT3,\n\tDEFORM_TEXT4,\n\tDEFORM_TEXT5,\n\tDEFORM_TEXT6,\n\tDEFORM_TEXT7\n} deform_t;\n\ntypedef enum {\n\tAGEN_IDENTITY,\n\tAGEN_SKIP,\n\tAGEN_ENTITY,\n\tAGEN_ONE_MINUS_ENTITY,\n\tAGEN_VERTEX,\n\tAGEN_ONE_MINUS_VERTEX,\n\tAGEN_LIGHTING_SPECULAR,\n\tAGEN_WAVEFORM,\n\tAGEN_PORTAL,\n\tAGEN_CONST\n} alphaGen_t;\n\ntypedef enum {\n\tCGEN_BAD,\n\tCGEN_IDENTITY_LIGHTING,\t// tr.identityLight\n\tCGEN_IDENTITY,\t\t\t// always (1,1,1,1)\n\tCGEN_ENTITY,\t\t\t// grabbed from entity's modulate field\n\tCGEN_ONE_MINUS_ENTITY,\t// grabbed from 1 - entity.modulate\n\tCGEN_EXACT_VERTEX,\t\t// tess.vertexColors\n\tCGEN_VERTEX,\t\t\t// tess.vertexColors * tr.identityLight\n\tCGEN_ONE_MINUS_VERTEX,\n\tCGEN_WAVEFORM,\t\t\t// programmatically generated\n\tCGEN_LIGHTING_DIFFUSE,\n\tCGEN_FOG,\t\t\t\t// standard fog\n\tCGEN_CONST\t\t\t\t// fixed color\n} colorGen_t;\n\ntypedef enum {\n\tTCGEN_BAD,\n\tTCGEN_IDENTITY,\t\t\t// clear to 0,0\n\tTCGEN_LIGHTMAP,\n\tTCGEN_TEXTURE,\n\tTCGEN_ENVIRONMENT_MAPPED,\n\tTCGEN_FOG,\n\tTCGEN_VECTOR\t\t\t// S and T from world coordinates\n} texCoordGen_t;\n\ntypedef enum {\n\tACFF_NONE,\n\tACFF_MODULATE_RGB,\n\tACFF_MODULATE_RGBA,\n\tACFF_MODULATE_ALPHA\n} acff_t;\n\ntypedef struct {\n\tgenFunc_t\tfunc;\n\n\tfloat base;\n\tfloat amplitude;\n\tfloat phase;\n\tfloat frequency;\n} waveForm_t;\n\n#define TR_MAX_TEXMODS 4\n\ntypedef enum {\n\tTMOD_NONE,\n\tTMOD_TRANSFORM,\n\tTMOD_TURBULENT,\n\tTMOD_SCROLL,\n\tTMOD_SCALE,\n\tTMOD_STRETCH,\n\tTMOD_ROTATE,\n\tTMOD_ENTITY_TRANSLATE\n} texMod_t;\n\n#define\tMAX_SHADER_DEFORMS\t3\ntypedef struct {\n\tdeform_t\tdeformation;\t\t\t// vertex coordinate modification type\n\n\tvec3_t\t\tmoveVector;\n\twaveForm_t\tdeformationWave;\n\tfloat\t\tdeformationSpread;\n\n\tfloat\t\tbulgeWidth;\n\tfloat\t\tbulgeHeight;\n\tfloat\t\tbulgeSpeed;\n} deformStage_t;\n\n\ntypedef struct {\n\ttexMod_t\t\ttype;\n\n\t// used for TMOD_TURBULENT and TMOD_STRETCH\n\twaveForm_t\t\twave;\n\n\t// used for TMOD_TRANSFORM\n\tfloat\t\t\tmatrix[2][2];\t\t// s' = s * m[0][0] + t * m[1][0] + trans[0]\n\tfloat\t\t\ttranslate[2];\t\t// t' = s * m[0][1] + t * m[0][1] + trans[1]\n\n\t// used for TMOD_SCALE\n\tfloat\t\t\tscale[2];\t\t\t// s *= scale[0]\n\t                                    // t *= scale[1]\n\n\t// used for TMOD_SCROLL\n\tfloat\t\t\tscroll[2];\t\t\t// s' = s + scroll[0] * time\n\t\t\t\t\t\t\t\t\t\t// t' = t + scroll[1] * time\n\n\t// + = clockwise\n\t// - = counterclockwise\n\tfloat\t\t\trotateSpeed;\n\n} texModInfo_t;\n\n\n#define\tMAX_IMAGE_ANIMATIONS\t8\n\ntypedef struct {\n\timage_t\t\t\t*image[MAX_IMAGE_ANIMATIONS];\n\tint\t\t\t\tnumImageAnimations;\n\tfloat\t\t\timageAnimationSpeed;\n\n\ttexCoordGen_t\ttcGen;\n\tvec3_t\t\t\ttcGenVectors[2];\n\n\tint\t\t\t\tnumTexMods;\n\ttexModInfo_t\t*texMods;\n\n\tint\t\t\t\tvideoMapHandle;\n\tqboolean\t\tisLightmap;\n\tqboolean\t\tvertexLightmap;\n\tqboolean\t\tisVideoMap;\n} textureBundle_t;\n\n#define NUM_TEXTURE_BUNDLES 2\n\ntypedef struct {\n\tqboolean\t\tactive;\n\t\n\ttextureBundle_t\tbundle[NUM_TEXTURE_BUNDLES];\n\n\twaveForm_t\t\trgbWave;\n\tcolorGen_t\t\trgbGen;\n\n\twaveForm_t\t\talphaWave;\n\talphaGen_t\t\talphaGen;\n\n\tbyte\t\t\tconstantColor[4];\t\t\t// for CGEN_CONST and AGEN_CONST\n\n\tunsigned\t\tstateBits;\t\t\t\t\t// GLS_xxxx mask\n\n\tacff_t\t\t\tadjustColorsForFog;\n\n\tqboolean\t\tisDetail;\n} shaderStage_t;\n\nstruct shaderCommands_s;\n\n#define LIGHTMAP_2D\t\t\t-4\t\t// shader is for 2D rendering\n#define LIGHTMAP_BY_VERTEX\t-3\t\t// pre-lit triangle models\n#define LIGHTMAP_WHITEIMAGE\t-2\n#define\tLIGHTMAP_NONE\t\t-1\n\ntypedef enum {\n\tCT_FRONT_SIDED,\n\tCT_BACK_SIDED,\n\tCT_TWO_SIDED\n} cullType_t;\n\ntypedef enum {\n\tFP_NONE,\t\t// surface is translucent and will just be adjusted properly\n\tFP_EQUAL,\t\t// surface is opaque but possibly alpha tested\n\tFP_LE\t\t\t// surface is trnaslucent, but still needs a fog pass (fog surface)\n} fogPass_t;\n\ntypedef struct {\n\tfloat\t\tcloudHeight;\n\timage_t\t\t*outerbox[6], *innerbox[6];\n} skyParms_t;\n\ntypedef struct {\n\tvec3_t\tcolor;\n\tfloat\tdepthForOpaque;\n} fogParms_t;\n\n\ntypedef struct shader_s {\n\tchar\t\tname[MAX_QPATH];\t\t// game path, including extension\n\tint\t\t\tlightmapIndex;\t\t\t// for a shader to match, both name and lightmapIndex must match\n\n\tint\t\t\tindex;\t\t\t\t\t// this shader == tr.shaders[index]\n\tint\t\t\tsortedIndex;\t\t\t// this shader == tr.sortedShaders[sortedIndex]\n\n\tfloat\t\tsort;\t\t\t\t\t// lower numbered shaders draw before higher numbered\n\n\tqboolean\tdefaultShader;\t\t\t// we want to return index 0 if the shader failed to\n\t\t\t\t\t\t\t\t\t\t// load for some reason, but R_FindShader should\n\t\t\t\t\t\t\t\t\t\t// still keep a name allocated for it, so if\n\t\t\t\t\t\t\t\t\t\t// something calls RE_RegisterShader again with\n\t\t\t\t\t\t\t\t\t\t// the same name, we don't try looking for it again\n\n\tqboolean\texplicitlyDefined;\t\t// found in a .shader file\n\n\tint\t\t\tsurfaceFlags;\t\t\t// if explicitlyDefined, this will have SURF_* flags\n\tint\t\t\tcontentFlags;\n\n\tqboolean\tentityMergable;\t\t\t// merge across entites optimizable (smoke, blood)\n\n\tqboolean\tisSky;\n\tskyParms_t\tsky;\n\tfogParms_t\tfogParms;\n\n\tfloat\t\tportalRange;\t\t\t// distance to fog out at\n\n\tint\t\t\tmultitextureEnv;\t\t// 0, GL_MODULATE, GL_ADD (FIXME: put in stage)\n\n\tcullType_t\tcullType;\t\t\t\t// CT_FRONT_SIDED, CT_BACK_SIDED, or CT_TWO_SIDED\n\tqboolean\tpolygonOffset;\t\t\t// set for decals and other items that must be offset \n\tqboolean\tnoMipMaps;\t\t\t\t// for console fonts, 2D elements, etc.\n\tqboolean\tnoPicMip;\t\t\t\t// for images that must always be full resolution\n\n\tfogPass_t\tfogPass;\t\t\t\t// draw a blended pass, possibly with depth test equals\n\n\tqboolean\tneedsNormal;\t\t\t// not all shaders will need all data to be gathered\n\tqboolean\tneedsST1;\n\tqboolean\tneedsST2;\n\tqboolean\tneedsColor;\n\n\tint\t\t\tnumDeforms;\n\tdeformStage_t\tdeforms[MAX_SHADER_DEFORMS];\n\n\tint\t\t\tnumUnfoggedPasses;\n\tshaderStage_t\t*stages[MAX_SHADER_STAGES];\t\t\n\n\tvoid\t\t(*optimalStageIteratorFunc)( void );\n\n  float clampTime;                                  // time this shader is clamped to\n  float timeOffset;                                 // current time offset for this shader\n\n  int numStates;                                    // if non-zero this is a state shader\n  struct shader_s *currentShader;                   // current state if this is a state shader\n  struct shader_s *parentShader;                    // current state if this is a state shader\n  int currentState;                                 // current state index for cycle purposes\n  long expireTime;                                  // time in milliseconds this expires\n\n  struct shader_s *remappedShader;                  // current shader this one is remapped too\n\n  int shaderStates[MAX_STATES_PER_SHADER];          // index to valid shader states\n\n\tstruct\tshader_s\t*next;\n} shader_t;\n\ntypedef struct shaderState_s {\n  char shaderName[MAX_QPATH];     // name of shader this state belongs to\n  char name[MAX_STATE_NAME];      // name of this state\n  char stateShader[MAX_QPATH];    // shader this name invokes\n  int cycleTime;                  // time this cycle lasts, <= 0 is forever\n  shader_t *shader;\n} shaderState_t;\n\n\n// trRefdef_t holds everything that comes in refdef_t,\n// as well as the locally generated scene information\ntypedef struct {\n\tint\t\t\tx, y, width, height;\n\tfloat\t\tfov_x, fov_y;\n\tvec3_t\t\tvieworg;\n\tvec3_t\t\tviewaxis[3];\t\t// transformation matrix\n\n\tint\t\t\ttime;\t\t\t\t// time in milliseconds for shader effects and other time dependent rendering issues\n\tint\t\t\trdflags;\t\t\t// RDF_NOWORLDMODEL, etc\n\n\t// 1 bits will prevent the associated area from rendering at all\n\tbyte\t\tareamask[MAX_MAP_AREA_BYTES];\n\tqboolean\tareamaskModified;\t// qtrue if areamask changed since last scene\n\n\tfloat\t\tfloatTime;\t\t\t// tr.refdef.time / 1000.0\n\n\t// text messages for deform text shaders\n\tchar\t\ttext[MAX_RENDER_STRINGS][MAX_RENDER_STRING_LENGTH];\n\n\tint\t\t\tnum_entities;\n\ttrRefEntity_t\t*entities;\n\n\tint\t\t\tnum_dlights;\n\tstruct dlight_s\t*dlights;\n\n\tint\t\t\tnumPolys;\n\tstruct srfPoly_s\t*polys;\n\n\tint\t\t\tnumDrawSurfs;\n\tstruct drawSurf_s\t*drawSurfs;\n\n\n} trRefdef_t;\n\n\n//=================================================================================\n\n// skins allow models to be retextured without modifying the model file\ntypedef struct {\n\tchar\t\tname[MAX_QPATH];\n\tshader_t\t*shader;\n} skinSurface_t;\n\ntypedef struct skin_s {\n\tchar\t\tname[MAX_QPATH];\t\t// game path, including extension\n\tint\t\t\tnumSurfaces;\n\tskinSurface_t\t*surfaces[MD3_MAX_SURFACES];\n} skin_t;\n\n\ntypedef struct {\n\tint\t\t\toriginalBrushNumber;\n\tvec3_t\t\tbounds[2];\n\n\tunsigned\tcolorInt;\t\t\t\t// in packed byte format\n\tfloat\t\ttcScale;\t\t\t\t// texture coordinate vector scales\n\tfogParms_t\tparms;\n\n\t// for clipping distance in fog when outside\n\tqboolean\thasSurface;\n\tfloat\t\tsurface[4];\n} fog_t;\n\ntypedef struct {\n\torientationr_t\tor;\n\torientationr_t\tworld;\n\tvec3_t\t\tpvsOrigin;\t\t\t// may be different than or.origin for portals\n\tqboolean\tisPortal;\t\t\t// true if this view is through a portal\n\tqboolean\tisMirror;\t\t\t// the portal is a mirror, invert the face culling\n\tint\t\t\tframeSceneNum;\t\t// copied from tr.frameSceneNum\n\tint\t\t\tframeCount;\t\t\t// copied from tr.frameCount\n\tcplane_t\tportalPlane;\t\t// clip anything behind this if mirroring\n\tint\t\t\tviewportX, viewportY, viewportWidth, viewportHeight;\n\tfloat\t\tfovX, fovY;\n\tfloat\t\tprojectionMatrix[16];\n\tcplane_t\tfrustum[4];\n\tvec3_t\t\tvisBounds[2];\n\tfloat\t\tzFar;\n} viewParms_t;\n\n\n/*\n==============================================================================\n\nSURFACES\n\n==============================================================================\n*/\n\n// any changes in surfaceType must be mirrored in rb_surfaceTable[]\ntypedef enum {\n\tSF_BAD,\n\tSF_SKIP,\t\t\t\t// ignore\n\tSF_FACE,\n\tSF_GRID,\n\tSF_TRIANGLES,\n\tSF_POLY,\n\tSF_MD3,\n\tSF_MD4,\n\tSF_FLARE,\n\tSF_ENTITY,\t\t\t\t// beams, rails, lightning, etc that can be determined by entity\n\tSF_DISPLAY_LIST,\n\n\tSF_NUM_SURFACE_TYPES,\n\tSF_MAX = 0x7fffffff\t\t\t// ensures that sizeof( surfaceType_t ) == sizeof( int )\n} surfaceType_t;\n\ntypedef struct drawSurf_s {\n\tunsigned\t\t\tsort;\t\t\t// bit combination for fast compares\n\tsurfaceType_t\t\t*surface;\t\t// any of surface*_t\n} drawSurf_t;\n\n#define\tMAX_FACE_POINTS\t\t64\n\n#define\tMAX_PATCH_SIZE\t\t32\t\t\t// max dimensions of a patch mesh in map file\n#define\tMAX_GRID_SIZE\t\t65\t\t\t// max dimensions of a grid mesh in memory\n\n// when cgame directly specifies a polygon, it becomes a srfPoly_t\n// as soon as it is called\ntypedef struct srfPoly_s {\n\tsurfaceType_t\tsurfaceType;\n\tqhandle_t\t\thShader;\n\tint\t\t\t\tfogIndex;\n\tint\t\t\t\tnumVerts;\n\tpolyVert_t\t\t*verts;\n} srfPoly_t;\n\ntypedef struct srfDisplayList_s {\n\tsurfaceType_t\tsurfaceType;\n\tint\t\t\t\tlistNum;\n} srfDisplayList_t;\n\n\ntypedef struct srfFlare_s {\n\tsurfaceType_t\tsurfaceType;\n\tvec3_t\t\t\torigin;\n\tvec3_t\t\t\tnormal;\n\tvec3_t\t\t\tcolor;\n} srfFlare_t;\n\ntypedef struct srfGridMesh_s {\n\tsurfaceType_t\tsurfaceType;\n\n\t// dynamic lighting information\n\tint\t\t\t\tdlightBits[SMP_FRAMES];\n\n\t// culling information\n\tvec3_t\t\t\tmeshBounds[2];\n\tvec3_t\t\t\tlocalOrigin;\n\tfloat\t\t\tmeshRadius;\n\n\t// lod information, which may be different\n\t// than the culling information to allow for\n\t// groups of curves that LOD as a unit\n\tvec3_t\t\t\tlodOrigin;\n\tfloat\t\t\tlodRadius;\n\tint\t\t\t\tlodFixed;\n\tint\t\t\t\tlodStitched;\n\n\t// vertexes\n\tint\t\t\t\twidth, height;\n\tfloat\t\t\t*widthLodError;\n\tfloat\t\t\t*heightLodError;\n\tdrawVert_t\t\tverts[1];\t\t// variable sized\n} srfGridMesh_t;\n\n\n\n#define\tVERTEXSIZE\t8\ntypedef struct {\n\tsurfaceType_t\tsurfaceType;\n\tcplane_t\tplane;\n\n\t// dynamic lighting information\n\tint\t\t\tdlightBits[SMP_FRAMES];\n\n\t// triangle definitions (no normals at points)\n\tint\t\t\tnumPoints;\n\tint\t\t\tnumIndices;\n\tint\t\t\tofsIndices;\n\tfloat\t\tpoints[1][VERTEXSIZE];\t// variable sized\n\t\t\t\t\t\t\t\t\t\t// there is a variable length list of indices here also\n} srfSurfaceFace_t;\n\n\n// misc_models in maps are turned into direct geometry by q3map\ntypedef struct {\n\tsurfaceType_t\tsurfaceType;\n\n\t// dynamic lighting information\n\tint\t\t\t\tdlightBits[SMP_FRAMES];\n\n\t// culling information (FIXME: use this!)\n\tvec3_t\t\t\tbounds[2];\n\tvec3_t\t\t\tlocalOrigin;\n\tfloat\t\t\tradius;\n\n\t// triangle definitions\n\tint\t\t\t\tnumIndexes;\n\tint\t\t\t\t*indexes;\n\n\tint\t\t\t\tnumVerts;\n\tdrawVert_t\t\t*verts;\n} srfTriangles_t;\n\n\nextern\tvoid (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])(void *);\n\n/*\n==============================================================================\n\nBRUSH MODELS\n\n==============================================================================\n*/\n\n\n//\n// in memory representation\n//\n\n#define\tSIDE_FRONT\t0\n#define\tSIDE_BACK\t1\n#define\tSIDE_ON\t\t2\n\ntypedef struct msurface_s {\n\tint\t\t\t\t\tviewCount;\t\t// if == tr.viewCount, already added\n\tstruct shader_s\t\t*shader;\n\tint\t\t\t\t\tfogIndex;\n\n\tsurfaceType_t\t\t*data;\t\t\t// any of srf*_t\n} msurface_t;\n\n\n\n#define\tCONTENTS_NODE\t\t-1\ntypedef struct mnode_s {\n\t// common with leaf and node\n\tint\t\t\tcontents;\t\t// -1 for nodes, to differentiate from leafs\n\tint\t\t\tvisframe;\t\t// node needs to be traversed if current\n\tvec3_t\t\tmins, maxs;\t\t// for bounding box culling\n\tstruct mnode_s\t*parent;\n\n\t// node specific\n\tcplane_t\t*plane;\n\tstruct mnode_s\t*children[2];\t\n\n\t// leaf specific\n\tint\t\t\tcluster;\n\tint\t\t\tarea;\n\n\tmsurface_t\t**firstmarksurface;\n\tint\t\t\tnummarksurfaces;\n} mnode_t;\n\ntypedef struct {\n\tvec3_t\t\tbounds[2];\t\t// for culling\n\tmsurface_t\t*firstSurface;\n\tint\t\t\tnumSurfaces;\n} bmodel_t;\n\ntypedef struct {\n\tchar\t\tname[MAX_QPATH];\t\t// ie: maps/tim_dm2.bsp\n\tchar\t\tbaseName[MAX_QPATH];\t// ie: tim_dm2\n\n\tint\t\t\tdataSize;\n\n\tint\t\t\tnumShaders;\n\tdshader_t\t*shaders;\n\n\tbmodel_t\t*bmodels;\n\n\tint\t\t\tnumplanes;\n\tcplane_t\t*planes;\n\n\tint\t\t\tnumnodes;\t\t// includes leafs\n\tint\t\t\tnumDecisionNodes;\n\tmnode_t\t\t*nodes;\n\n\tint\t\t\tnumsurfaces;\n\tmsurface_t\t*surfaces;\n\n\tint\t\t\tnummarksurfaces;\n\tmsurface_t\t**marksurfaces;\n\n\tint\t\t\tnumfogs;\n\tfog_t\t\t*fogs;\n\n\tvec3_t\t\tlightGridOrigin;\n\tvec3_t\t\tlightGridSize;\n\tvec3_t\t\tlightGridInverseSize;\n\tint\t\t\tlightGridBounds[3];\n\tbyte\t\t*lightGridData;\n\n\n\tint\t\t\tnumClusters;\n\tint\t\t\tclusterBytes;\n\tconst byte\t*vis;\t\t\t// may be passed in by CM_LoadMap to save space\n\n\tbyte\t\t*novis;\t\t\t// clusterBytes of 0xff\n\n\tchar\t\t*entityString;\n\tchar\t\t*entityParsePoint;\n} world_t;\n\n//======================================================================\n\ntypedef enum {\n\tMOD_BAD,\n\tMOD_BRUSH,\n\tMOD_MESH,\n\tMOD_MD4\n} modtype_t;\n\ntypedef struct model_s {\n\tchar\t\tname[MAX_QPATH];\n\tmodtype_t\ttype;\n\tint\t\t\tindex;\t\t\t\t// model = tr.models[model->index]\n\n\tint\t\t\tdataSize;\t\t\t// just for listing purposes\n\tbmodel_t\t*bmodel;\t\t\t// only if type == MOD_BRUSH\n\tmd3Header_t\t*md3[MD3_MAX_LODS];\t// only if type == MOD_MESH\n\tmd4Header_t\t*md4;\t\t\t\t// only if type == MOD_MD4\n\n\tint\t\t\t numLods;\n} model_t;\n\n\n#define\tMAX_MOD_KNOWN\t1024\n\nvoid\t\tR_ModelInit (void);\nmodel_t\t\t*R_GetModelByHandle( qhandle_t hModel );\nint\t\t\tR_LerpTag( orientation_t *tag, qhandle_t handle, int startFrame, int endFrame, \n\t\t\t\t\t float frac, const char *tagName );\nvoid\t\tR_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs );\n\nvoid\t\tR_Modellist_f (void);\n\n//====================================================\nextern\trefimport_t\t\tri;\n\n#define\tMAX_DRAWIMAGES\t\t\t2048\n#define\tMAX_LIGHTMAPS\t\t\t256\n#define\tMAX_SKINS\t\t\t\t1024\n\n\n#define\tMAX_DRAWSURFS\t\t\t0x10000\n#define\tDRAWSURF_MASK\t\t\t(MAX_DRAWSURFS-1)\n\n/*\n\nthe drawsurf sort data is packed into a single 32 bit value so it can be\ncompared quickly during the qsorting process\n\nthe bits are allocated as follows:\n\n21 - 31\t: sorted shader index\n11 - 20\t: entity index\n2 - 6\t: fog index\n//2\t\t: used to be clipped flag REMOVED - 03.21.00 rad\n0 - 1\t: dlightmap index\n\n\tTTimo - 1.32\n17-31 : sorted shader index\n7-16  : entity index\n2-6   : fog index\n0-1   : dlightmap index\n*/\n#define\tQSORT_SHADERNUM_SHIFT\t17\n#define\tQSORT_ENTITYNUM_SHIFT\t7\n#define\tQSORT_FOGNUM_SHIFT\t\t2\n\nextern\tint\t\t\tgl_filter_min, gl_filter_max;\n\n/*\n** performanceCounters_t\n*/\ntypedef struct {\n\tint\t\tc_sphere_cull_patch_in, c_sphere_cull_patch_clip, c_sphere_cull_patch_out;\n\tint\t\tc_box_cull_patch_in, c_box_cull_patch_clip, c_box_cull_patch_out;\n\tint\t\tc_sphere_cull_md3_in, c_sphere_cull_md3_clip, c_sphere_cull_md3_out;\n\tint\t\tc_box_cull_md3_in, c_box_cull_md3_clip, c_box_cull_md3_out;\n\n\tint\t\tc_leafs;\n\tint\t\tc_dlightSurfaces;\n\tint\t\tc_dlightSurfacesCulled;\n} frontEndCounters_t;\n\n#define\tFOG_TABLE_SIZE\t\t256\n#define FUNCTABLE_SIZE\t\t1024\n#define FUNCTABLE_SIZE2\t\t10\n#define FUNCTABLE_MASK\t\t(FUNCTABLE_SIZE-1)\n\n\n// the renderer front end should never modify glstate_t\ntypedef struct {\n\tint\t\t\tcurrenttextures[2];\n\tint\t\t\tcurrenttmu;\n\tqboolean\tfinishCalled;\n\tint\t\t\ttexEnv[2];\n\tint\t\t\tfaceCulling;\n\tunsigned long\tglStateBits;\n} glstate_t;\n\n\ntypedef struct {\n\tint\t\tc_surfaces, c_shaders, c_vertexes, c_indexes, c_totalIndexes;\n\tfloat\tc_overDraw;\n\t\n\tint\t\tc_dlightVertexes;\n\tint\t\tc_dlightIndexes;\n\n\tint\t\tc_flareAdds;\n\tint\t\tc_flareTests;\n\tint\t\tc_flareRenders;\n\n\tint\t\tmsec;\t\t\t// total msec for backend run\n} backEndCounters_t;\n\n// all state modified by the back end is seperated\n// from the front end state\ntypedef struct {\n\tint\t\t\tsmpFrame;\n\ttrRefdef_t\trefdef;\n\tviewParms_t\tviewParms;\n\torientationr_t\tor;\n\tbackEndCounters_t\tpc;\n\tqboolean\tisHyperspace;\n\ttrRefEntity_t\t*currentEntity;\n\tqboolean\tskyRenderedThisView;\t// flag for drawing sun\n\n\tqboolean\tprojection2D;\t// if qtrue, drawstretchpic doesn't need to change modes\n\tbyte\t\tcolor2D[4];\n\tqboolean\tvertexes2D;\t\t// shader needs to be finished\n\ttrRefEntity_t\tentity2D;\t// currentEntity will point at this when doing 2D rendering\n} backEndState_t;\n\n/*\n** trGlobals_t \n**\n** Most renderer globals are defined here.\n** backend functions should never modify any of these fields,\n** but may read fields that aren't dynamically modified\n** by the frontend.\n*/\ntypedef struct {\n\tqboolean\t\t\t\tregistered;\t\t// cleared at shutdown, set at beginRegistration\n\n\tint\t\t\t\t\t\tvisCount;\t\t// incremented every time a new vis cluster is entered\n\tint\t\t\t\t\t\tframeCount;\t\t// incremented every frame\n\tint\t\t\t\t\t\tsceneCount;\t\t// incremented every scene\n\tint\t\t\t\t\t\tviewCount;\t\t// incremented every view (twice a scene if portaled)\n\t\t\t\t\t\t\t\t\t\t\t// and every R_MarkFragments call\n\n\tint\t\t\t\t\t\tsmpFrame;\t\t// toggles from 0 to 1 every endFrame\n\n\tint\t\t\t\t\t\tframeSceneNum;\t// zeroed at RE_BeginFrame\n\n\tqboolean\t\t\t\tworldMapLoaded;\n\tworld_t\t\t\t\t\t*world;\n\n\tconst byte\t\t\t\t*externalVisData;\t// from RE_SetWorldVisData, shared with CM_Load\n\n\timage_t\t\t\t\t\t*defaultImage;\n\timage_t\t\t\t\t\t*scratchImage[32];\n\timage_t\t\t\t\t\t*fogImage;\n\timage_t\t\t\t\t\t*dlightImage;\t// inverse-quare highlight for projective adding\n\timage_t\t\t\t\t\t*flareImage;\n\timage_t\t\t\t\t\t*whiteImage;\t\t\t// full of 0xff\n\timage_t\t\t\t\t\t*identityLightImage;\t// full of tr.identityLightByte\n\n\tshader_t\t\t\t\t*defaultShader;\n\tshader_t\t\t\t\t*shadowShader;\n\tshader_t\t\t\t\t*projectionShadowShader;\n\n\tshader_t\t\t\t\t*flareShader;\n\tshader_t\t\t\t\t*sunShader;\n\n\tint\t\t\t\t\t\tnumLightmaps;\n\timage_t\t\t\t\t\t*lightmaps[MAX_LIGHTMAPS];\n\n\ttrRefEntity_t\t\t\t*currentEntity;\n\ttrRefEntity_t\t\t\tworldEntity;\t\t// point currentEntity at this when rendering world\n\tint\t\t\t\t\t\tcurrentEntityNum;\n\tint\t\t\t\t\t\tshiftedEntityNum;\t// currentEntityNum << QSORT_ENTITYNUM_SHIFT\n\tmodel_t\t\t\t\t\t*currentModel;\n\n\tviewParms_t\t\t\t\tviewParms;\n\n\tfloat\t\t\t\t\tidentityLight;\t\t// 1.0 / ( 1 << overbrightBits )\n\tint\t\t\t\t\t\tidentityLightByte;\t// identityLight * 255\n\tint\t\t\t\t\t\toverbrightBits;\t\t// r_overbrightBits->integer, but set to 0 if no hw gamma\n\n\torientationr_t\t\t\tor;\t\t\t\t\t// for current entity\n\n\ttrRefdef_t\t\t\t\trefdef;\n\n\tint\t\t\t\t\t\tviewCluster;\n\n\tvec3_t\t\t\t\t\tsunLight;\t\t\t// from the sky shader for this level\n\tvec3_t\t\t\t\t\tsunDirection;\n\n\tfrontEndCounters_t\t\tpc;\n\tint\t\t\t\t\t\tfrontEndMsec;\t\t// not in pc due to clearing issue\n\n\t//\n\t// put large tables at the end, so most elements will be\n\t// within the +/32K indexed range on risc processors\n\t//\n\tmodel_t\t\t\t\t\t*models[MAX_MOD_KNOWN];\n\tint\t\t\t\t\t\tnumModels;\n\n\tint\t\t\t\t\t\tnumImages;\n\timage_t\t\t\t\t\t*images[MAX_DRAWIMAGES];\n\n\t// shader indexes from other modules will be looked up in tr.shaders[]\n\t// shader indexes from drawsurfs will be looked up in sortedShaders[]\n\t// lower indexed sortedShaders must be rendered first (opaque surfaces before translucent)\n\tint\t\t\t\t\t\tnumShaders;\n\tshader_t\t\t\t\t*shaders[MAX_SHADERS];\n\tshader_t\t\t\t\t*sortedShaders[MAX_SHADERS];\n\n\tint\t\t\t\t\t\tnumSkins;\n\tskin_t\t\t\t\t\t*skins[MAX_SKINS];\n\n\tfloat\t\t\t\t\tsinTable[FUNCTABLE_SIZE];\n\tfloat\t\t\t\t\tsquareTable[FUNCTABLE_SIZE];\n\tfloat\t\t\t\t\ttriangleTable[FUNCTABLE_SIZE];\n\tfloat\t\t\t\t\tsawToothTable[FUNCTABLE_SIZE];\n\tfloat\t\t\t\t\tinverseSawToothTable[FUNCTABLE_SIZE];\n\tfloat\t\t\t\t\tfogTable[FOG_TABLE_SIZE];\n} trGlobals_t;\n\nextern backEndState_t\tbackEnd;\nextern trGlobals_t\ttr;\nextern glconfig_t\tglConfig;\t\t// outside of TR since it shouldn't be cleared during ref re-init\nextern glstate_t\tglState;\t\t// outside of TR since it shouldn't be cleared during ref re-init\n\n\n//\n// cvars\n//\nextern cvar_t\t*r_flareSize;\nextern cvar_t\t*r_flareFade;\n\nextern cvar_t\t*r_railWidth;\nextern cvar_t\t*r_railCoreWidth;\nextern cvar_t\t*r_railSegmentLength;\n\nextern cvar_t\t*r_ignore;\t\t\t\t// used for debugging anything\nextern cvar_t\t*r_verbose;\t\t\t\t// used for verbose debug spew\nextern cvar_t\t*r_ignoreFastPath;\t\t// allows us to ignore our Tess fast paths\n\nextern cvar_t\t*r_znear;\t\t\t\t// near Z clip plane\n\nextern cvar_t\t*r_stencilbits;\t\t\t// number of desired stencil bits\nextern cvar_t\t*r_depthbits;\t\t\t// number of desired depth bits\nextern cvar_t\t*r_colorbits;\t\t\t// number of desired color bits, only relevant for fullscreen\nextern cvar_t\t*r_stereo;\t\t\t\t// desired pixelformat stereo flag\nextern cvar_t\t*r_texturebits;\t\t\t// number of desired texture bits\n\t\t\t\t\t\t\t\t\t\t// 0 = use framebuffer depth\n\t\t\t\t\t\t\t\t\t\t// 16 = use 16-bit textures\n\t\t\t\t\t\t\t\t\t\t// 32 = use 32-bit textures\n\t\t\t\t\t\t\t\t\t\t// all else = error\n\nextern cvar_t\t*r_measureOverdraw;\t\t// enables stencil buffer overdraw measurement\n\nextern cvar_t\t*r_lodbias;\t\t\t\t// push/pull LOD transitions\nextern cvar_t\t*r_lodscale;\n\nextern cvar_t\t*r_primitives;\t\t\t// \"0\" = based on compiled vertex array existance\n\t\t\t\t\t\t\t\t\t\t// \"1\" = glDrawElemet tristrips\n\t\t\t\t\t\t\t\t\t\t// \"2\" = glDrawElements triangles\n\t\t\t\t\t\t\t\t\t\t// \"-1\" = no drawing\n\nextern cvar_t\t*r_inGameVideo;\t\t\t\t// controls whether in game video should be draw\nextern cvar_t\t*r_fastsky;\t\t\t\t// controls whether sky should be cleared or drawn\nextern cvar_t\t*r_drawSun;\t\t\t\t// controls drawing of sun quad\nextern cvar_t\t*r_dynamiclight;\t\t// dynamic lights enabled/disabled\nextern cvar_t\t*r_dlightBacks;\t\t\t// dlight non-facing surfaces for continuity\n\nextern\tcvar_t\t*r_norefresh;\t\t\t// bypasses the ref rendering\nextern\tcvar_t\t*r_drawentities;\t\t// disable/enable entity rendering\nextern\tcvar_t\t*r_drawworld;\t\t\t// disable/enable world rendering\nextern\tcvar_t\t*r_speeds;\t\t\t\t// various levels of information display\nextern  cvar_t\t*r_detailTextures;\t\t// enables/disables detail texturing stages\nextern\tcvar_t\t*r_novis;\t\t\t\t// disable/enable usage of PVS\nextern\tcvar_t\t*r_nocull;\nextern\tcvar_t\t*r_facePlaneCull;\t\t// enables culling of planar surfaces with back side test\nextern\tcvar_t\t*r_nocurves;\nextern\tcvar_t\t*r_showcluster;\n\nextern cvar_t\t*r_mode;\t\t\t\t// video mode\nextern cvar_t\t*r_fullscreen;\nextern cvar_t\t*r_gamma;\nextern cvar_t\t*r_displayRefresh;\t\t// optional display refresh option\nextern cvar_t\t*r_ignorehwgamma;\t\t// overrides hardware gamma capabilities\n\nextern cvar_t\t*r_allowExtensions;\t\t\t\t// global enable/disable of OpenGL extensions\nextern cvar_t\t*r_ext_compressed_textures;\t\t// these control use of specific extensions\nextern cvar_t\t*r_ext_gamma_control;\nextern cvar_t\t*r_ext_texenv_op;\nextern cvar_t\t*r_ext_multitexture;\nextern cvar_t\t*r_ext_compiled_vertex_array;\nextern cvar_t\t*r_ext_texture_env_add;\n\nextern\tcvar_t\t*r_nobind;\t\t\t\t\t\t// turns off binding to appropriate textures\nextern\tcvar_t\t*r_singleShader;\t\t\t\t// make most world faces use default shader\nextern\tcvar_t\t*r_roundImagesDown;\nextern\tcvar_t\t*r_colorMipLevels;\t\t\t\t// development aid to see texture mip usage\nextern\tcvar_t\t*r_picmip;\t\t\t\t\t\t// controls picmip values\nextern\tcvar_t\t*r_finish;\nextern\tcvar_t\t*r_drawBuffer;\nextern  cvar_t  *r_glDriver;\nextern\tcvar_t\t*r_swapInterval;\nextern\tcvar_t\t*r_textureMode;\nextern\tcvar_t\t*r_offsetFactor;\nextern\tcvar_t\t*r_offsetUnits;\n\nextern\tcvar_t\t*r_fullbright;\t\t\t\t\t// avoid lightmap pass\nextern\tcvar_t\t*r_lightmap;\t\t\t\t\t// render lightmaps only\nextern\tcvar_t\t*r_vertexLight;\t\t\t\t\t// vertex lighting mode for better performance\nextern\tcvar_t\t*r_uiFullScreen;\t\t\t\t// ui is running fullscreen\n\nextern\tcvar_t\t*r_logFile;\t\t\t\t\t\t// number of frames to emit GL logs\nextern\tcvar_t\t*r_showtris;\t\t\t\t\t// enables wireframe rendering of the world\nextern\tcvar_t\t*r_showsky;\t\t\t\t\t\t// forces sky in front of all surfaces\nextern\tcvar_t\t*r_shownormals;\t\t\t\t\t// draws wireframe normals\nextern\tcvar_t\t*r_clear;\t\t\t\t\t\t// force screen clear every frame\n\nextern\tcvar_t\t*r_shadows;\t\t\t\t\t\t// controls shadows: 0 = none, 1 = blur, 2 = stencil, 3 = black planar projection\nextern\tcvar_t\t*r_flares;\t\t\t\t\t\t// light flares\n\nextern\tcvar_t\t*r_intensity;\n\nextern\tcvar_t\t*r_lockpvs;\nextern\tcvar_t\t*r_noportals;\nextern\tcvar_t\t*r_portalOnly;\n\nextern\tcvar_t\t*r_subdivisions;\nextern\tcvar_t\t*r_lodCurveError;\nextern\tcvar_t\t*r_smp;\nextern\tcvar_t\t*r_showSmp;\nextern\tcvar_t\t*r_skipBackEnd;\n\nextern\tcvar_t\t*r_ignoreGLErrors;\n\nextern\tcvar_t\t*r_overBrightBits;\nextern\tcvar_t\t*r_mapOverBrightBits;\n\nextern\tcvar_t\t*r_debugSurface;\nextern\tcvar_t\t*r_simpleMipMaps;\n\nextern\tcvar_t\t*r_showImages;\nextern\tcvar_t\t*r_debugSort;\n\nextern\tcvar_t\t*r_printShaders;\nextern\tcvar_t\t*r_saveFontData;\n\n//====================================================================\n\nfloat R_NoiseGet4f( float x, float y, float z, float t );\nvoid  R_NoiseInit( void );\n\nvoid R_SwapBuffers( int );\n\nvoid R_RenderView( viewParms_t *parms );\n\nvoid R_AddMD3Surfaces( trRefEntity_t *e );\nvoid R_AddNullModelSurfaces( trRefEntity_t *e );\nvoid R_AddBeamSurfaces( trRefEntity_t *e );\nvoid R_AddRailSurfaces( trRefEntity_t *e, qboolean isUnderwater );\nvoid R_AddLightningBoltSurfaces( trRefEntity_t *e );\n\nvoid R_AddPolygonSurfaces( void );\n\nvoid R_DecomposeSort( unsigned sort, int *entityNum, shader_t **shader, \n\t\t\t\t\t int *fogNum, int *dlightMap );\n\nvoid R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, int fogIndex, int dlightMap );\n\n\n#define\tCULL_IN\t\t0\t\t// completely unclipped\n#define\tCULL_CLIP\t1\t\t// clipped by one or more planes\n#define\tCULL_OUT\t2\t\t// completely outside the clipping planes\nvoid R_LocalNormalToWorld (vec3_t local, vec3_t world);\nvoid R_LocalPointToWorld (vec3_t local, vec3_t world);\nint R_CullLocalBox (vec3_t bounds[2]);\nint R_CullPointAndRadius( vec3_t origin, float radius );\nint R_CullLocalPointAndRadius( vec3_t origin, float radius );\n\nvoid R_RotateForEntity( const trRefEntity_t *ent, const viewParms_t *viewParms, orientationr_t *or );\n\n/*\n** GL wrapper/helper functions\n*/\nvoid\tGL_Bind( image_t *image );\nvoid\tGL_SetDefaultState (void);\nvoid\tGL_SelectTexture( int unit );\nvoid\tGL_TextureMode( const char *string );\nvoid\tGL_CheckErrors( void );\nvoid\tGL_State( unsigned long stateVector );\nvoid\tGL_TexEnv( int env );\nvoid\tGL_Cull( int cullType );\n\n#define GLS_SRCBLEND_ZERO\t\t\t\t\t\t0x00000001\n#define GLS_SRCBLEND_ONE\t\t\t\t\t\t0x00000002\n#define GLS_SRCBLEND_DST_COLOR\t\t\t\t\t0x00000003\n#define GLS_SRCBLEND_ONE_MINUS_DST_COLOR\t\t0x00000004\n#define GLS_SRCBLEND_SRC_ALPHA\t\t\t\t\t0x00000005\n#define GLS_SRCBLEND_ONE_MINUS_SRC_ALPHA\t\t0x00000006\n#define GLS_SRCBLEND_DST_ALPHA\t\t\t\t\t0x00000007\n#define GLS_SRCBLEND_ONE_MINUS_DST_ALPHA\t\t0x00000008\n#define GLS_SRCBLEND_ALPHA_SATURATE\t\t\t\t0x00000009\n#define\t\tGLS_SRCBLEND_BITS\t\t\t\t\t0x0000000f\n\n#define GLS_DSTBLEND_ZERO\t\t\t\t\t\t0x00000010\n#define GLS_DSTBLEND_ONE\t\t\t\t\t\t0x00000020\n#define GLS_DSTBLEND_SRC_COLOR\t\t\t\t\t0x00000030\n#define GLS_DSTBLEND_ONE_MINUS_SRC_COLOR\t\t0x00000040\n#define GLS_DSTBLEND_SRC_ALPHA\t\t\t\t\t0x00000050\n#define GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA\t\t0x00000060\n#define GLS_DSTBLEND_DST_ALPHA\t\t\t\t\t0x00000070\n#define GLS_DSTBLEND_ONE_MINUS_DST_ALPHA\t\t0x00000080\n#define\t\tGLS_DSTBLEND_BITS\t\t\t\t\t0x000000f0\n\n#define GLS_DEPTHMASK_TRUE\t\t\t\t\t\t0x00000100\n\n#define GLS_POLYMODE_LINE\t\t\t\t\t\t0x00001000\n\n#define GLS_DEPTHTEST_DISABLE\t\t\t\t\t0x00010000\n#define GLS_DEPTHFUNC_EQUAL\t\t\t\t\t\t0x00020000\n\n#define GLS_ATEST_GT_0\t\t\t\t\t\t\t0x10000000\n#define GLS_ATEST_LT_80\t\t\t\t\t\t\t0x20000000\n#define GLS_ATEST_GE_80\t\t\t\t\t\t\t0x40000000\n#define\t\tGLS_ATEST_BITS\t\t\t\t\t\t0x70000000\n\n#define GLS_DEFAULT\t\t\tGLS_DEPTHMASK_TRUE\n\nvoid\tRE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty);\nvoid\tRE_UploadCinematic (int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty);\n\nvoid\t\tRE_BeginFrame( stereoFrame_t stereoFrame );\nvoid\t\tRE_BeginRegistration( glconfig_t *glconfig );\nvoid\t\tRE_LoadWorldMap( const char *mapname );\nvoid\t\tRE_SetWorldVisData( const byte *vis );\nqhandle_t\tRE_RegisterModel( const char *name );\nqhandle_t\tRE_RegisterSkin( const char *name );\nvoid\t\tRE_Shutdown( qboolean destroyWindow );\n\nqboolean\tR_GetEntityToken( char *buffer, int size );\n\nmodel_t\t\t*R_AllocModel( void );\n\nvoid    \tR_Init( void );\nimage_t\t\t*R_FindImageFile( const char *name, qboolean mipmap, qboolean allowPicmip, int glWrapClampMode );\n\nimage_t\t\t*R_CreateImage( const char *name, const byte *pic, int width, int height, qboolean mipmap\n\t\t\t\t\t, qboolean allowPicmip, int wrapClampMode );\nqboolean\tR_GetModeInfo( int *width, int *height, float *windowAspect, int mode );\n\nvoid\t\tR_SetColorMappings( void );\nvoid\t\tR_GammaCorrect( byte *buffer, int bufSize );\n\nvoid\tR_ImageList_f( void );\nvoid\tR_SkinList_f( void );\n// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=516\nconst void *RB_TakeScreenshotCmd( const void *data );\nvoid\tR_ScreenShot_f( void );\n\nvoid\tR_InitFogTable( void );\nfloat\tR_FogFactor( float s, float t );\nvoid\tR_InitImages( void );\nvoid\tR_DeleteTextures( void );\nint\t\tR_SumOfUsedImages( void );\nvoid\tR_InitSkins( void );\nskin_t\t*R_GetSkinByHandle( qhandle_t hSkin );\n\n\n//\n// tr_shader.c\n//\nqhandle_t\t\t RE_RegisterShaderLightMap( const char *name, int lightmapIndex );\nqhandle_t\t\t RE_RegisterShader( const char *name );\nqhandle_t\t\t RE_RegisterShaderNoMip( const char *name );\nqhandle_t RE_RegisterShaderFromImage(const char *name, int lightmapIndex, image_t *image, qboolean mipRawImage);\n\nshader_t\t*R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImage );\nshader_t\t*R_GetShaderByHandle( qhandle_t hShader );\nshader_t\t*R_GetShaderByState( int index, long *cycleTime );\nshader_t *R_FindShaderByName( const char *name );\nvoid\t\tR_InitShaders( void );\nvoid\t\tR_ShaderList_f( void );\nvoid    R_RemapShader(const char *oldShader, const char *newShader, const char *timeOffset);\n\n/*\n====================================================================\n\nIMPLEMENTATION SPECIFIC FUNCTIONS\n\n====================================================================\n*/\n\nvoid\t\tGLimp_Init( void );\nvoid\t\tGLimp_Shutdown( void );\nvoid\t\tGLimp_EndFrame( void );\n\nqboolean\tGLimp_SpawnRenderThread( void (*function)( void ) );\nvoid\t\t*GLimp_RendererSleep( void );\nvoid\t\tGLimp_FrontEndSleep( void );\nvoid\t\tGLimp_WakeRenderer( void *data );\n\nvoid\t\tGLimp_LogComment( char *comment );\n\n// NOTE TTimo linux works with float gamma value, not the gamma table\n//   the params won't be used, getting the r_gamma cvar directly\nvoid\t\tGLimp_SetGamma( unsigned char red[256], \n\t\t\t\t\t\t    unsigned char green[256],\n\t\t\t\t\t\t\tunsigned char blue[256] );\n\n\n/*\n====================================================================\n\nTESSELATOR/SHADER DECLARATIONS\n\n====================================================================\n*/\ntypedef byte color4ub_t[4];\n\ntypedef struct stageVars\n{\n\tcolor4ub_t\tcolors[SHADER_MAX_VERTEXES];\n\tvec2_t\t\ttexcoords[NUM_TEXTURE_BUNDLES][SHADER_MAX_VERTEXES];\n} stageVars_t;\n\ntypedef struct shaderCommands_s \n{\n\tglIndex_t\tindexes[SHADER_MAX_INDEXES];\n\tvec4_t\t\txyz[SHADER_MAX_VERTEXES];\n\tvec4_t\t\tnormal[SHADER_MAX_VERTEXES];\n\tvec2_t\t\ttexCoords[SHADER_MAX_VERTEXES][2];\n\tcolor4ub_t\tvertexColors[SHADER_MAX_VERTEXES];\n\tint\t\t\tvertexDlightBits[SHADER_MAX_VERTEXES];\n\n\tstageVars_t\tsvars;\n\n\tcolor4ub_t\tconstantColor255[SHADER_MAX_VERTEXES];\n\n\tshader_t\t*shader;\n  float   shaderTime;\n\tint\t\t\tfogNum;\n\n\tint\t\t\tdlightBits;\t// or together of all vertexDlightBits\n\n\tint\t\t\tnumIndexes;\n\tint\t\t\tnumVertexes;\n\n\t// info extracted from current shader\n\tint\t\t\tnumPasses;\n\tvoid\t\t(*currentStageIteratorFunc)( void );\n\tshaderStage_t\t**xstages;\n} shaderCommands_t;\n\nextern\tshaderCommands_t\ttess;\n\nvoid RB_BeginSurface(shader_t *shader, int fogNum );\nvoid RB_EndSurface(void);\nvoid RB_CheckOverflow( int verts, int indexes );\n#define RB_CHECKOVERFLOW(v,i) if (tess.numVertexes + (v) >= SHADER_MAX_VERTEXES || tess.numIndexes + (i) >= SHADER_MAX_INDEXES ) {RB_CheckOverflow(v,i);}\n\nvoid RB_StageIteratorGeneric( void );\nvoid RB_StageIteratorSky( void );\nvoid RB_StageIteratorVertexLitTexture( void );\nvoid RB_StageIteratorLightmappedMultitexture( void );\n\nvoid RB_AddQuadStamp( vec3_t origin, vec3_t left, vec3_t up, byte *color );\nvoid RB_AddQuadStampExt( vec3_t origin, vec3_t left, vec3_t up, byte *color, float s1, float t1, float s2, float t2 );\n\nvoid RB_ShowImages( void );\n\n\n/*\n============================================================\n\nWORLD MAP\n\n============================================================\n*/\n\nvoid R_AddBrushModelSurfaces( trRefEntity_t *e );\nvoid R_AddWorldSurfaces( void );\nqboolean R_inPVS( const vec3_t p1, const vec3_t p2 );\n\n\n/*\n============================================================\n\nFLARES\n\n============================================================\n*/\n\nvoid R_ClearFlares( void );\n\nvoid RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t normal );\nvoid RB_AddDlightFlares( void );\nvoid RB_RenderFlares (void);\n\n/*\n============================================================\n\nLIGHTS\n\n============================================================\n*/\n\nvoid R_DlightBmodel( bmodel_t *bmodel );\nvoid R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent );\nvoid R_TransformDlights( int count, dlight_t *dl, orientationr_t *or );\nint R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir );\n\n\n/*\n============================================================\n\nSHADOWS\n\n============================================================\n*/\n\nvoid RB_ShadowTessEnd( void );\nvoid RB_ShadowFinish( void );\nvoid RB_ProjectionShadowDeform( void );\n\n/*\n============================================================\n\nSKIES\n\n============================================================\n*/\n\nvoid R_BuildCloudData( shaderCommands_t *shader );\nvoid R_InitSkyTexCoords( float cloudLayerHeight );\nvoid R_DrawSkyBox( shaderCommands_t *shader );\nvoid RB_DrawSun( void );\nvoid RB_ClipSkyPolygons( shaderCommands_t *shader );\n\n/*\n============================================================\n\nCURVE TESSELATION\n\n============================================================\n*/\n\n#define PATCH_STITCHING\n\nsrfGridMesh_t *R_SubdividePatchToGrid( int width, int height,\n\t\t\t\t\t\t\t\tdrawVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] );\nsrfGridMesh_t *R_GridInsertColumn( srfGridMesh_t *grid, int column, int row, vec3_t point, float loderror );\nsrfGridMesh_t *R_GridInsertRow( srfGridMesh_t *grid, int row, int column, vec3_t point, float loderror );\nvoid R_FreeSurfaceGridMesh( srfGridMesh_t *grid );\n\n/*\n============================================================\n\nMARKERS, POLYGON PROJECTION ON WORLD POLYGONS\n\n============================================================\n*/\n\nint R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projection,\n\t\t\t\t   int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer );\n\n\n/*\n============================================================\n\nSCENE GENERATION\n\n============================================================\n*/\n\nvoid R_ToggleSmpFrame( void );\n\nvoid RE_ClearScene( void );\nvoid RE_AddRefEntityToScene( const refEntity_t *ent );\nvoid RE_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts, int num );\nvoid RE_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b );\nvoid RE_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b );\nvoid RE_RenderScene( const refdef_t *fd );\n\n/*\n=============================================================\n\nANIMATED MODELS\n\n=============================================================\n*/\n\nvoid R_MakeAnimModel( model_t *model );\nvoid R_AddAnimSurfaces( trRefEntity_t *ent );\nvoid RB_SurfaceAnim( md4Surface_t *surfType );\n\n/*\n=============================================================\n=============================================================\n*/\nvoid\tR_TransformModelToClip( const vec3_t src, const float *modelMatrix, const float *projectionMatrix,\n\t\t\t\t\t\t\tvec4_t eye, vec4_t dst );\nvoid\tR_TransformClipToWindow( const vec4_t clip, const viewParms_t *view, vec4_t normalized, vec4_t window );\n\nvoid\tRB_DeformTessGeometry( void );\n\nvoid\tRB_CalcEnvironmentTexCoords( float *dstTexCoords );\nvoid\tRB_CalcFogTexCoords( float *dstTexCoords );\nvoid\tRB_CalcScrollTexCoords( const float scroll[2], float *dstTexCoords );\nvoid\tRB_CalcRotateTexCoords( float rotSpeed, float *dstTexCoords );\nvoid\tRB_CalcScaleTexCoords( const float scale[2], float *dstTexCoords );\nvoid\tRB_CalcTurbulentTexCoords( const waveForm_t *wf, float *dstTexCoords );\nvoid\tRB_CalcTransformTexCoords( const texModInfo_t *tmi, float *dstTexCoords );\nvoid\tRB_CalcModulateColorsByFog( unsigned char *dstColors );\nvoid\tRB_CalcModulateAlphasByFog( unsigned char *dstColors );\nvoid\tRB_CalcModulateRGBAsByFog( unsigned char *dstColors );\nvoid\tRB_CalcWaveAlpha( const waveForm_t *wf, unsigned char *dstColors );\nvoid\tRB_CalcWaveColor( const waveForm_t *wf, unsigned char *dstColors );\nvoid\tRB_CalcAlphaFromEntity( unsigned char *dstColors );\nvoid\tRB_CalcAlphaFromOneMinusEntity( unsigned char *dstColors );\nvoid\tRB_CalcStretchTexCoords( const waveForm_t *wf, float *texCoords );\nvoid\tRB_CalcColorFromEntity( unsigned char *dstColors );\nvoid\tRB_CalcColorFromOneMinusEntity( unsigned char *dstColors );\nvoid\tRB_CalcSpecularAlpha( unsigned char *alphas );\nvoid\tRB_CalcDiffuseColor( unsigned char *colors );\n\n/*\n=============================================================\n\nRENDERER BACK END FUNCTIONS\n\n=============================================================\n*/\n\nvoid RB_RenderThread( void );\nvoid RB_ExecuteRenderCommands( const void *data );\n\n/*\n=============================================================\n\nRENDERER BACK END COMMAND QUEUE\n\n=============================================================\n*/\n\n#define\tMAX_RENDER_COMMANDS\t0x40000\n\ntypedef struct {\n\tbyte\tcmds[MAX_RENDER_COMMANDS];\n\tint\t\tused;\n} renderCommandList_t;\n\ntypedef struct {\n\tint\t\tcommandId;\n\tfloat\tcolor[4];\n} setColorCommand_t;\n\ntypedef struct {\n\tint\t\tcommandId;\n\tint\t\tbuffer;\n} drawBufferCommand_t;\n\ntypedef struct {\n\tint\t\tcommandId;\n\timage_t\t*image;\n\tint\t\twidth;\n\tint\t\theight;\n\tvoid\t*data;\n} subImageCommand_t;\n\ntypedef struct {\n\tint\t\tcommandId;\n} swapBuffersCommand_t;\n\ntypedef struct {\n\tint\t\tcommandId;\n\tint\t\tbuffer;\n} endFrameCommand_t;\n\ntypedef struct {\n\tint\t\tcommandId;\n\tshader_t\t*shader;\n\tfloat\tx, y;\n\tfloat\tw, h;\n\tfloat\ts1, t1;\n\tfloat\ts2, t2;\n} stretchPicCommand_t;\n\ntypedef struct {\n\tint\t\tcommandId;\n\ttrRefdef_t\trefdef;\n\tviewParms_t\tviewParms;\n\tdrawSurf_t *drawSurfs;\n\tint\t\tnumDrawSurfs;\n} drawSurfsCommand_t;\n\ntypedef struct {\n\tint commandId;\n\tint x;\n\tint y;\n\tint width;\n\tint height;\n\tchar *fileName;\n\tqboolean jpeg;\n} screenshotCommand_t;\n\ntypedef enum {\n\tRC_END_OF_LIST,\n\tRC_SET_COLOR,\n\tRC_STRETCH_PIC,\n\tRC_DRAW_SURFS,\n\tRC_DRAW_BUFFER,\n\tRC_SWAP_BUFFERS,\n\tRC_SCREENSHOT\n} renderCommand_t;\n\n\n// these are sort of arbitrary limits.\n// the limits apply to the sum of all scenes in a frame --\n// the main view, all the 3D icons, etc\n#define\tMAX_POLYS\t\t600\n#define\tMAX_POLYVERTS\t3000\n\n// all of the information needed by the back end must be\n// contained in a backEndData_t.  This entire structure is\n// duplicated so the front and back end can run in parallel\n// on an SMP machine\ntypedef struct {\n\tdrawSurf_t\tdrawSurfs[MAX_DRAWSURFS];\n\tdlight_t\tdlights[MAX_DLIGHTS];\n\ttrRefEntity_t\tentities[MAX_ENTITIES];\n\tsrfPoly_t\t*polys;//[MAX_POLYS];\n\tpolyVert_t\t*polyVerts;//[MAX_POLYVERTS];\n\trenderCommandList_t\tcommands;\n} backEndData_t;\n\nextern\tint\t\tmax_polys;\nextern\tint\t\tmax_polyverts;\n\nextern\tbackEndData_t\t*backEndData[SMP_FRAMES];\t// the second one may not be allocated\n\nextern\tvolatile renderCommandList_t\t*renderCommandList;\n\nextern\tvolatile qboolean\trenderThreadActive;\n\n\nvoid *R_GetCommandBuffer( int bytes );\nvoid RB_ExecuteRenderCommands( const void *data );\n\nvoid R_InitCommandBuffers( void );\nvoid R_ShutdownCommandBuffers( void );\n\nvoid R_SyncRenderThread( void );\n\nvoid R_AddDrawSurfCmd( drawSurf_t *drawSurfs, int numDrawSurfs );\n\nvoid RE_SetColor( const float *rgba );\nvoid RE_StretchPic ( float x, float y, float w, float h, \n\t\t\t\t\t  float s1, float t1, float s2, float t2, qhandle_t hShader );\nvoid RE_BeginFrame( stereoFrame_t stereoFrame );\nvoid RE_EndFrame( int *frontEndMsec, int *backEndMsec );\nvoid SaveJPG(char * filename, int quality, int image_width, int image_height, unsigned char *image_buffer);\n\n// font stuff\nvoid R_InitFreeType();\nvoid R_DoneFreeType();\nvoid RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font);\n\n\n#endif //TR_LOCAL_H\n"
  },
  {
    "path": "code/renderer/tr_main.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// tr_main.c -- main control flow for each frame\n\n#include \"tr_local.h\"\n\ntrGlobals_t\t\ttr;\n\nstatic float\ts_flipMatrix[16] = {\n\t// convert from our coordinate system (looking down X)\n\t// to OpenGL's coordinate system (looking down -Z)\n\t0, 0, -1, 0,\n\t-1, 0, 0, 0,\n\t0, 1, 0, 0,\n\t0, 0, 0, 1\n};\n\n\nrefimport_t\tri;\n\n// entities that will have procedurally generated surfaces will just\n// point at this for their sorting surface\nsurfaceType_t\tentitySurface = SF_ENTITY;\n\n/*\n=================\nR_CullLocalBox\n\nReturns CULL_IN, CULL_CLIP, or CULL_OUT\n=================\n*/\nint R_CullLocalBox (vec3_t bounds[2]) {\n\tint\t\ti, j;\n\tvec3_t\ttransformed[8];\n\tfloat\tdists[8];\n\tvec3_t\tv;\n\tcplane_t\t*frust;\n\tint\t\t\tanyBack;\n\tint\t\t\tfront, back;\n\n\tif ( r_nocull->integer ) {\n\t\treturn CULL_CLIP;\n\t}\n\n\t// transform into world space\n\tfor (i = 0 ; i < 8 ; i++) {\n\t\tv[0] = bounds[i&1][0];\n\t\tv[1] = bounds[(i>>1)&1][1];\n\t\tv[2] = bounds[(i>>2)&1][2];\n\n\t\tVectorCopy( tr.or.origin, transformed[i] );\n\t\tVectorMA( transformed[i], v[0], tr.or.axis[0], transformed[i] );\n\t\tVectorMA( transformed[i], v[1], tr.or.axis[1], transformed[i] );\n\t\tVectorMA( transformed[i], v[2], tr.or.axis[2], transformed[i] );\n\t}\n\n\t// check against frustum planes\n\tanyBack = 0;\n\tfor (i = 0 ; i < 4 ; i++) {\n\t\tfrust = &tr.viewParms.frustum[i];\n\n\t\tfront = back = 0;\n\t\tfor (j = 0 ; j < 8 ; j++) {\n\t\t\tdists[j] = DotProduct(transformed[j], frust->normal);\n\t\t\tif ( dists[j] > frust->dist ) {\n\t\t\t\tfront = 1;\n\t\t\t\tif ( back ) {\n\t\t\t\t\tbreak;\t\t// a point is in front\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tback = 1;\n\t\t\t}\n\t\t}\n\t\tif ( !front ) {\n\t\t\t// all points were behind one of the planes\n\t\t\treturn CULL_OUT;\n\t\t}\n\t\tanyBack |= back;\n\t}\n\n\tif ( !anyBack ) {\n\t\treturn CULL_IN;\t\t// completely inside frustum\n\t}\n\n\treturn CULL_CLIP;\t\t// partially clipped\n}\n\n/*\n** R_CullLocalPointAndRadius\n*/\nint R_CullLocalPointAndRadius( vec3_t pt, float radius )\n{\n\tvec3_t transformed;\n\n\tR_LocalPointToWorld( pt, transformed );\n\n\treturn R_CullPointAndRadius( transformed, radius );\n}\n\n/*\n** R_CullPointAndRadius\n*/\nint R_CullPointAndRadius( vec3_t pt, float radius )\n{\n\tint\t\ti;\n\tfloat\tdist;\n\tcplane_t\t*frust;\n\tqboolean mightBeClipped = qfalse;\n\n\tif ( r_nocull->integer ) {\n\t\treturn CULL_CLIP;\n\t}\n\n\t// check against frustum planes\n\tfor (i = 0 ; i < 4 ; i++) \n\t{\n\t\tfrust = &tr.viewParms.frustum[i];\n\n\t\tdist = DotProduct( pt, frust->normal) - frust->dist;\n\t\tif ( dist < -radius )\n\t\t{\n\t\t\treturn CULL_OUT;\n\t\t}\n\t\telse if ( dist <= radius ) \n\t\t{\n\t\t\tmightBeClipped = qtrue;\n\t\t}\n\t}\n\n\tif ( mightBeClipped )\n\t{\n\t\treturn CULL_CLIP;\n\t}\n\n\treturn CULL_IN;\t\t// completely inside frustum\n}\n\n\n/*\n=================\nR_LocalNormalToWorld\n\n=================\n*/\nvoid R_LocalNormalToWorld (vec3_t local, vec3_t world) {\n\tworld[0] = local[0] * tr.or.axis[0][0] + local[1] * tr.or.axis[1][0] + local[2] * tr.or.axis[2][0];\n\tworld[1] = local[0] * tr.or.axis[0][1] + local[1] * tr.or.axis[1][1] + local[2] * tr.or.axis[2][1];\n\tworld[2] = local[0] * tr.or.axis[0][2] + local[1] * tr.or.axis[1][2] + local[2] * tr.or.axis[2][2];\n}\n\n/*\n=================\nR_LocalPointToWorld\n\n=================\n*/\nvoid R_LocalPointToWorld (vec3_t local, vec3_t world) {\n\tworld[0] = local[0] * tr.or.axis[0][0] + local[1] * tr.or.axis[1][0] + local[2] * tr.or.axis[2][0] + tr.or.origin[0];\n\tworld[1] = local[0] * tr.or.axis[0][1] + local[1] * tr.or.axis[1][1] + local[2] * tr.or.axis[2][1] + tr.or.origin[1];\n\tworld[2] = local[0] * tr.or.axis[0][2] + local[1] * tr.or.axis[1][2] + local[2] * tr.or.axis[2][2] + tr.or.origin[2];\n}\n\n/*\n=================\nR_WorldToLocal\n\n=================\n*/\nvoid R_WorldToLocal (vec3_t world, vec3_t local) {\n\tlocal[0] = DotProduct(world, tr.or.axis[0]);\n\tlocal[1] = DotProduct(world, tr.or.axis[1]);\n\tlocal[2] = DotProduct(world, tr.or.axis[2]);\n}\n\n/*\n==========================\nR_TransformModelToClip\n\n==========================\n*/\nvoid R_TransformModelToClip( const vec3_t src, const float *modelMatrix, const float *projectionMatrix,\n\t\t\t\t\t\t\tvec4_t eye, vec4_t dst ) {\n\tint i;\n\n\tfor ( i = 0 ; i < 4 ; i++ ) {\n\t\teye[i] = \n\t\t\tsrc[0] * modelMatrix[ i + 0 * 4 ] +\n\t\t\tsrc[1] * modelMatrix[ i + 1 * 4 ] +\n\t\t\tsrc[2] * modelMatrix[ i + 2 * 4 ] +\n\t\t\t1 * modelMatrix[ i + 3 * 4 ];\n\t}\n\n\tfor ( i = 0 ; i < 4 ; i++ ) {\n\t\tdst[i] = \n\t\t\teye[0] * projectionMatrix[ i + 0 * 4 ] +\n\t\t\teye[1] * projectionMatrix[ i + 1 * 4 ] +\n\t\t\teye[2] * projectionMatrix[ i + 2 * 4 ] +\n\t\t\teye[3] * projectionMatrix[ i + 3 * 4 ];\n\t}\n}\n\n/*\n==========================\nR_TransformClipToWindow\n\n==========================\n*/\nvoid R_TransformClipToWindow( const vec4_t clip, const viewParms_t *view, vec4_t normalized, vec4_t window ) {\n\tnormalized[0] = clip[0] / clip[3];\n\tnormalized[1] = clip[1] / clip[3];\n\tnormalized[2] = ( clip[2] + clip[3] ) / ( 2 * clip[3] );\n\n\twindow[0] = 0.5f * ( 1.0f + normalized[0] ) * view->viewportWidth;\n\twindow[1] = 0.5f * ( 1.0f + normalized[1] ) * view->viewportHeight;\n\twindow[2] = normalized[2];\n\n\twindow[0] = (int) ( window[0] + 0.5 );\n\twindow[1] = (int) ( window[1] + 0.5 );\n}\n\n\n/*\n==========================\nmyGlMultMatrix\n\n==========================\n*/\nvoid myGlMultMatrix( const float *a, const float *b, float *out ) {\n\tint\t\ti, j;\n\n\tfor ( i = 0 ; i < 4 ; i++ ) {\n\t\tfor ( j = 0 ; j < 4 ; j++ ) {\n\t\t\tout[ i * 4 + j ] =\n\t\t\t\ta [ i * 4 + 0 ] * b [ 0 * 4 + j ]\n\t\t\t\t+ a [ i * 4 + 1 ] * b [ 1 * 4 + j ]\n\t\t\t\t+ a [ i * 4 + 2 ] * b [ 2 * 4 + j ]\n\t\t\t\t+ a [ i * 4 + 3 ] * b [ 3 * 4 + j ];\n\t\t}\n\t}\n}\n\n/*\n=================\nR_RotateForEntity\n\nGenerates an orientation for an entity and viewParms\nDoes NOT produce any GL calls\nCalled by both the front end and the back end\n=================\n*/\nvoid R_RotateForEntity( const trRefEntity_t *ent, const viewParms_t *viewParms,\n\t\t\t\t\t   orientationr_t *or ) {\n\tfloat\tglMatrix[16];\n\tvec3_t\tdelta;\n\tfloat\taxisLength;\n\n\tif ( ent->e.reType != RT_MODEL ) {\n\t\t*or = viewParms->world;\n\t\treturn;\n\t}\n\n\tVectorCopy( ent->e.origin, or->origin );\n\n\tVectorCopy( ent->e.axis[0], or->axis[0] );\n\tVectorCopy( ent->e.axis[1], or->axis[1] );\n\tVectorCopy( ent->e.axis[2], or->axis[2] );\n\n\tglMatrix[0] = or->axis[0][0];\n\tglMatrix[4] = or->axis[1][0];\n\tglMatrix[8] = or->axis[2][0];\n\tglMatrix[12] = or->origin[0];\n\n\tglMatrix[1] = or->axis[0][1];\n\tglMatrix[5] = or->axis[1][1];\n\tglMatrix[9] = or->axis[2][1];\n\tglMatrix[13] = or->origin[1];\n\n\tglMatrix[2] = or->axis[0][2];\n\tglMatrix[6] = or->axis[1][2];\n\tglMatrix[10] = or->axis[2][2];\n\tglMatrix[14] = or->origin[2];\n\n\tglMatrix[3] = 0;\n\tglMatrix[7] = 0;\n\tglMatrix[11] = 0;\n\tglMatrix[15] = 1;\n\n\tmyGlMultMatrix( glMatrix, viewParms->world.modelMatrix, or->modelMatrix );\n\n\t// calculate the viewer origin in the model's space\n\t// needed for fog, specular, and environment mapping\n\tVectorSubtract( viewParms->or.origin, or->origin, delta );\n\n\t// compensate for scale in the axes if necessary\n\tif ( ent->e.nonNormalizedAxes ) {\n\t\taxisLength = VectorLength( ent->e.axis[0] );\n\t\tif ( !axisLength ) {\n\t\t\taxisLength = 0;\n\t\t} else {\n\t\t\taxisLength = 1.0f / axisLength;\n\t\t}\n\t} else {\n\t\taxisLength = 1.0f;\n\t}\n\n\tor->viewOrigin[0] = DotProduct( delta, or->axis[0] ) * axisLength;\n\tor->viewOrigin[1] = DotProduct( delta, or->axis[1] ) * axisLength;\n\tor->viewOrigin[2] = DotProduct( delta, or->axis[2] ) * axisLength;\n}\n\n/*\n=================\nR_RotateForViewer\n\nSets up the modelview matrix for a given viewParm\n=================\n*/\nvoid R_RotateForViewer (void) \n{\n\tfloat\tviewerMatrix[16];\n\tvec3_t\torigin;\n\n\tCom_Memset (&tr.or, 0, sizeof(tr.or));\n\ttr.or.axis[0][0] = 1;\n\ttr.or.axis[1][1] = 1;\n\ttr.or.axis[2][2] = 1;\n\tVectorCopy (tr.viewParms.or.origin, tr.or.viewOrigin);\n\n\t// transform by the camera placement\n\tVectorCopy( tr.viewParms.or.origin, origin );\n\n\tviewerMatrix[0] = tr.viewParms.or.axis[0][0];\n\tviewerMatrix[4] = tr.viewParms.or.axis[0][1];\n\tviewerMatrix[8] = tr.viewParms.or.axis[0][2];\n\tviewerMatrix[12] = -origin[0] * viewerMatrix[0] + -origin[1] * viewerMatrix[4] + -origin[2] * viewerMatrix[8];\n\n\tviewerMatrix[1] = tr.viewParms.or.axis[1][0];\n\tviewerMatrix[5] = tr.viewParms.or.axis[1][1];\n\tviewerMatrix[9] = tr.viewParms.or.axis[1][2];\n\tviewerMatrix[13] = -origin[0] * viewerMatrix[1] + -origin[1] * viewerMatrix[5] + -origin[2] * viewerMatrix[9];\n\n\tviewerMatrix[2] = tr.viewParms.or.axis[2][0];\n\tviewerMatrix[6] = tr.viewParms.or.axis[2][1];\n\tviewerMatrix[10] = tr.viewParms.or.axis[2][2];\n\tviewerMatrix[14] = -origin[0] * viewerMatrix[2] + -origin[1] * viewerMatrix[6] + -origin[2] * viewerMatrix[10];\n\n\tviewerMatrix[3] = 0;\n\tviewerMatrix[7] = 0;\n\tviewerMatrix[11] = 0;\n\tviewerMatrix[15] = 1;\n\n\t// convert from our coordinate system (looking down X)\n\t// to OpenGL's coordinate system (looking down -Z)\n\tmyGlMultMatrix( viewerMatrix, s_flipMatrix, tr.or.modelMatrix );\n\n\ttr.viewParms.world = tr.or;\n\n}\n\n/*\n** SetFarClip\n*/\nstatic void SetFarClip( void )\n{\n\tfloat\tfarthestCornerDistance = 0;\n\tint\t\ti;\n\n\t// if not rendering the world (icons, menus, etc)\n\t// set a 2k far clip plane\n\tif ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) {\n\t\ttr.viewParms.zFar = 2048;\n\t\treturn;\n\t}\n\n\t//\n\t// set far clipping planes dynamically\n\t//\n\tfarthestCornerDistance = 0;\n\tfor ( i = 0; i < 8; i++ )\n\t{\n\t\tvec3_t v;\n\t\tvec3_t vecTo;\n\t\tfloat distance;\n\n\t\tif ( i & 1 )\n\t\t{\n\t\t\tv[0] = tr.viewParms.visBounds[0][0];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tv[0] = tr.viewParms.visBounds[1][0];\n\t\t}\n\n\t\tif ( i & 2 )\n\t\t{\n\t\t\tv[1] = tr.viewParms.visBounds[0][1];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tv[1] = tr.viewParms.visBounds[1][1];\n\t\t}\n\n\t\tif ( i & 4 )\n\t\t{\n\t\t\tv[2] = tr.viewParms.visBounds[0][2];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tv[2] = tr.viewParms.visBounds[1][2];\n\t\t}\n\n\t\tVectorSubtract( v, tr.viewParms.or.origin, vecTo );\n\n\t\tdistance = vecTo[0] * vecTo[0] + vecTo[1] * vecTo[1] + vecTo[2] * vecTo[2];\n\n\t\tif ( distance > farthestCornerDistance )\n\t\t{\n\t\t\tfarthestCornerDistance = distance;\n\t\t}\n\t}\n\ttr.viewParms.zFar = sqrt( farthestCornerDistance );\n}\n\n\n/*\n===============\nR_SetupProjection\n===============\n*/\nvoid R_SetupProjection( void ) {\n\tfloat\txmin, xmax, ymin, ymax;\n\tfloat\twidth, height, depth;\n\tfloat\tzNear, zFar;\n\n\t// dynamically compute far clip plane distance\n\tSetFarClip();\n\n\t//\n\t// set up projection matrix\n\t//\n\tzNear\t= r_znear->value;\n\tzFar\t= tr.viewParms.zFar;\n\n\tymax = zNear * tan( tr.refdef.fov_y * M_PI / 360.0f );\n\tymin = -ymax;\n\n\txmax = zNear * tan( tr.refdef.fov_x * M_PI / 360.0f );\n\txmin = -xmax;\n\n\twidth = xmax - xmin;\n\theight = ymax - ymin;\n\tdepth = zFar - zNear;\n\n\ttr.viewParms.projectionMatrix[0] = 2 * zNear / width;\n\ttr.viewParms.projectionMatrix[4] = 0;\n\ttr.viewParms.projectionMatrix[8] = ( xmax + xmin ) / width;\t// normally 0\n\ttr.viewParms.projectionMatrix[12] = 0;\n\n\ttr.viewParms.projectionMatrix[1] = 0;\n\ttr.viewParms.projectionMatrix[5] = 2 * zNear / height;\n\ttr.viewParms.projectionMatrix[9] = ( ymax + ymin ) / height;\t// normally 0\n\ttr.viewParms.projectionMatrix[13] = 0;\n\n\ttr.viewParms.projectionMatrix[2] = 0;\n\ttr.viewParms.projectionMatrix[6] = 0;\n\ttr.viewParms.projectionMatrix[10] = -( zFar + zNear ) / depth;\n\ttr.viewParms.projectionMatrix[14] = -2 * zFar * zNear / depth;\n\n\ttr.viewParms.projectionMatrix[3] = 0;\n\ttr.viewParms.projectionMatrix[7] = 0;\n\ttr.viewParms.projectionMatrix[11] = -1;\n\ttr.viewParms.projectionMatrix[15] = 0;\n}\n\n/*\n=================\nR_SetupFrustum\n\nSetup that culling frustum planes for the current view\n=================\n*/\nvoid R_SetupFrustum (void) {\n\tint\t\ti;\n\tfloat\txs, xc;\n\tfloat\tang;\n\n\tang = tr.viewParms.fovX / 180 * M_PI * 0.5f;\n\txs = sin( ang );\n\txc = cos( ang );\n\n\tVectorScale( tr.viewParms.or.axis[0], xs, tr.viewParms.frustum[0].normal );\n\tVectorMA( tr.viewParms.frustum[0].normal, xc, tr.viewParms.or.axis[1], tr.viewParms.frustum[0].normal );\n\n\tVectorScale( tr.viewParms.or.axis[0], xs, tr.viewParms.frustum[1].normal );\n\tVectorMA( tr.viewParms.frustum[1].normal, -xc, tr.viewParms.or.axis[1], tr.viewParms.frustum[1].normal );\n\n\tang = tr.viewParms.fovY / 180 * M_PI * 0.5f;\n\txs = sin( ang );\n\txc = cos( ang );\n\n\tVectorScale( tr.viewParms.or.axis[0], xs, tr.viewParms.frustum[2].normal );\n\tVectorMA( tr.viewParms.frustum[2].normal, xc, tr.viewParms.or.axis[2], tr.viewParms.frustum[2].normal );\n\n\tVectorScale( tr.viewParms.or.axis[0], xs, tr.viewParms.frustum[3].normal );\n\tVectorMA( tr.viewParms.frustum[3].normal, -xc, tr.viewParms.or.axis[2], tr.viewParms.frustum[3].normal );\n\n\tfor (i=0 ; i<4 ; i++) {\n\t\ttr.viewParms.frustum[i].type = PLANE_NON_AXIAL;\n\t\ttr.viewParms.frustum[i].dist = DotProduct (tr.viewParms.or.origin, tr.viewParms.frustum[i].normal);\n\t\tSetPlaneSignbits( &tr.viewParms.frustum[i] );\n\t}\n}\n\n\n/*\n=================\nR_MirrorPoint\n=================\n*/\nvoid R_MirrorPoint (vec3_t in, orientation_t *surface, orientation_t *camera, vec3_t out) {\n\tint\t\ti;\n\tvec3_t\tlocal;\n\tvec3_t\ttransformed;\n\tfloat\td;\n\n\tVectorSubtract( in, surface->origin, local );\n\n\tVectorClear( transformed );\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\td = DotProduct(local, surface->axis[i]);\n\t\tVectorMA( transformed, d, camera->axis[i], transformed );\n\t}\n\n\tVectorAdd( transformed, camera->origin, out );\n}\n\nvoid R_MirrorVector (vec3_t in, orientation_t *surface, orientation_t *camera, vec3_t out) {\n\tint\t\ti;\n\tfloat\td;\n\n\tVectorClear( out );\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\td = DotProduct(in, surface->axis[i]);\n\t\tVectorMA( out, d, camera->axis[i], out );\n\t}\n}\n\n\n/*\n=============\nR_PlaneForSurface\n=============\n*/\nvoid R_PlaneForSurface (surfaceType_t *surfType, cplane_t *plane) {\n\tsrfTriangles_t\t*tri;\n\tsrfPoly_t\t\t*poly;\n\tdrawVert_t\t\t*v1, *v2, *v3;\n\tvec4_t\t\t\tplane4;\n\n\tif (!surfType) {\n\t\tCom_Memset (plane, 0, sizeof(*plane));\n\t\tplane->normal[0] = 1;\n\t\treturn;\n\t}\n\tswitch (*surfType) {\n\tcase SF_FACE:\n\t\t*plane = ((srfSurfaceFace_t *)surfType)->plane;\n\t\treturn;\n\tcase SF_TRIANGLES:\n\t\ttri = (srfTriangles_t *)surfType;\n\t\tv1 = tri->verts + tri->indexes[0];\n\t\tv2 = tri->verts + tri->indexes[1];\n\t\tv3 = tri->verts + tri->indexes[2];\n\t\tPlaneFromPoints( plane4, v1->xyz, v2->xyz, v3->xyz );\n\t\tVectorCopy( plane4, plane->normal ); \n\t\tplane->dist = plane4[3];\n\t\treturn;\n\tcase SF_POLY:\n\t\tpoly = (srfPoly_t *)surfType;\n\t\tPlaneFromPoints( plane4, poly->verts[0].xyz, poly->verts[1].xyz, poly->verts[2].xyz );\n\t\tVectorCopy( plane4, plane->normal ); \n\t\tplane->dist = plane4[3];\n\t\treturn;\n\tdefault:\n\t\tCom_Memset (plane, 0, sizeof(*plane));\n\t\tplane->normal[0] = 1;\t\t\n\t\treturn;\n\t}\n}\n\n/*\n=================\nR_GetPortalOrientation\n\nentityNum is the entity that the portal surface is a part of, which may\nbe moving and rotating.\n\nReturns qtrue if it should be mirrored\n=================\n*/\nqboolean R_GetPortalOrientations( drawSurf_t *drawSurf, int entityNum, \n\t\t\t\t\t\t\t orientation_t *surface, orientation_t *camera,\n\t\t\t\t\t\t\t vec3_t pvsOrigin, qboolean *mirror ) {\n\tint\t\t\ti;\n\tcplane_t\toriginalPlane, plane;\n\ttrRefEntity_t\t*e;\n\tfloat\t\td;\n\tvec3_t\t\ttransformed;\n\n\t// create plane axis for the portal we are seeing\n\tR_PlaneForSurface( drawSurf->surface, &originalPlane );\n\n\t// rotate the plane if necessary\n\tif ( entityNum != ENTITYNUM_WORLD ) {\n\t\ttr.currentEntityNum = entityNum;\n\t\ttr.currentEntity = &tr.refdef.entities[entityNum];\n\n\t\t// get the orientation of the entity\n\t\tR_RotateForEntity( tr.currentEntity, &tr.viewParms, &tr.or );\n\n\t\t// rotate the plane, but keep the non-rotated version for matching\n\t\t// against the portalSurface entities\n\t\tR_LocalNormalToWorld( originalPlane.normal, plane.normal );\n\t\tplane.dist = originalPlane.dist + DotProduct( plane.normal, tr.or.origin );\n\n\t\t// translate the original plane\n\t\toriginalPlane.dist = originalPlane.dist + DotProduct( originalPlane.normal, tr.or.origin );\n\t} else {\n\t\tplane = originalPlane;\n\t}\n\n\tVectorCopy( plane.normal, surface->axis[0] );\n\tPerpendicularVector( surface->axis[1], surface->axis[0] );\n\tCrossProduct( surface->axis[0], surface->axis[1], surface->axis[2] );\n\n\t// locate the portal entity closest to this plane.\n\t// origin will be the origin of the portal, origin2 will be\n\t// the origin of the camera\n\tfor ( i = 0 ; i < tr.refdef.num_entities ; i++ ) {\n\t\te = &tr.refdef.entities[i];\n\t\tif ( e->e.reType != RT_PORTALSURFACE ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\td = DotProduct( e->e.origin, originalPlane.normal ) - originalPlane.dist;\n\t\tif ( d > 64 || d < -64) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// get the pvsOrigin from the entity\n\t\tVectorCopy( e->e.oldorigin, pvsOrigin );\n\n\t\t// if the entity is just a mirror, don't use as a camera point\n\t\tif ( e->e.oldorigin[0] == e->e.origin[0] && \n\t\t\te->e.oldorigin[1] == e->e.origin[1] && \n\t\t\te->e.oldorigin[2] == e->e.origin[2] ) {\n\t\t\tVectorScale( plane.normal, plane.dist, surface->origin );\n\t\t\tVectorCopy( surface->origin, camera->origin );\n\t\t\tVectorSubtract( vec3_origin, surface->axis[0], camera->axis[0] );\n\t\t\tVectorCopy( surface->axis[1], camera->axis[1] );\n\t\t\tVectorCopy( surface->axis[2], camera->axis[2] );\n\n\t\t\t*mirror = qtrue;\n\t\t\treturn qtrue;\n\t\t}\n\n\t\t// project the origin onto the surface plane to get\n\t\t// an origin point we can rotate around\n\t\td = DotProduct( e->e.origin, plane.normal ) - plane.dist;\n\t\tVectorMA( e->e.origin, -d, surface->axis[0], surface->origin );\n\t\t\t\n\t\t// now get the camera origin and orientation\n\t\tVectorCopy( e->e.oldorigin, camera->origin );\n\t\tAxisCopy( e->e.axis, camera->axis );\n\t\tVectorSubtract( vec3_origin, camera->axis[0], camera->axis[0] );\n\t\tVectorSubtract( vec3_origin, camera->axis[1], camera->axis[1] );\n\n\t\t// optionally rotate\n\t\tif ( e->e.oldframe ) {\n\t\t\t// if a speed is specified\n\t\t\tif ( e->e.frame ) {\n\t\t\t\t// continuous rotate\n\t\t\t\td = (tr.refdef.time/1000.0f) * e->e.frame;\n\t\t\t\tVectorCopy( camera->axis[1], transformed );\n\t\t\t\tRotatePointAroundVector( camera->axis[1], camera->axis[0], transformed, d );\n\t\t\t\tCrossProduct( camera->axis[0], camera->axis[1], camera->axis[2] );\n\t\t\t} else {\n\t\t\t\t// bobbing rotate, with skinNum being the rotation offset\n\t\t\t\td = sin( tr.refdef.time * 0.003f );\n\t\t\t\td = e->e.skinNum + d * 4;\n\t\t\t\tVectorCopy( camera->axis[1], transformed );\n\t\t\t\tRotatePointAroundVector( camera->axis[1], camera->axis[0], transformed, d );\n\t\t\t\tCrossProduct( camera->axis[0], camera->axis[1], camera->axis[2] );\n\t\t\t}\n\t\t}\n\t\telse if ( e->e.skinNum ) {\n\t\t\td = e->e.skinNum;\n\t\t\tVectorCopy( camera->axis[1], transformed );\n\t\t\tRotatePointAroundVector( camera->axis[1], camera->axis[0], transformed, d );\n\t\t\tCrossProduct( camera->axis[0], camera->axis[1], camera->axis[2] );\n\t\t}\n\t\t*mirror = qfalse;\n\t\treturn qtrue;\n\t}\n\n\t// if we didn't locate a portal entity, don't render anything.\n\t// We don't want to just treat it as a mirror, because without a\n\t// portal entity the server won't have communicated a proper entity set\n\t// in the snapshot\n\n\t// unfortunately, with local movement prediction it is easily possible\n\t// to see a surface before the server has communicated the matching\n\t// portal surface entity, so we don't want to print anything here...\n\n\t//ri.Printf( PRINT_ALL, \"Portal surface without a portal entity\\n\" );\n\n\treturn qfalse;\n}\n\nstatic qboolean IsMirror( const drawSurf_t *drawSurf, int entityNum )\n{\n\tint\t\t\ti;\n\tcplane_t\toriginalPlane, plane;\n\ttrRefEntity_t\t*e;\n\tfloat\t\td;\n\n\t// create plane axis for the portal we are seeing\n\tR_PlaneForSurface( drawSurf->surface, &originalPlane );\n\n\t// rotate the plane if necessary\n\tif ( entityNum != ENTITYNUM_WORLD ) \n\t{\n\t\ttr.currentEntityNum = entityNum;\n\t\ttr.currentEntity = &tr.refdef.entities[entityNum];\n\n\t\t// get the orientation of the entity\n\t\tR_RotateForEntity( tr.currentEntity, &tr.viewParms, &tr.or );\n\n\t\t// rotate the plane, but keep the non-rotated version for matching\n\t\t// against the portalSurface entities\n\t\tR_LocalNormalToWorld( originalPlane.normal, plane.normal );\n\t\tplane.dist = originalPlane.dist + DotProduct( plane.normal, tr.or.origin );\n\n\t\t// translate the original plane\n\t\toriginalPlane.dist = originalPlane.dist + DotProduct( originalPlane.normal, tr.or.origin );\n\t} \n\telse \n\t{\n\t\tplane = originalPlane;\n\t}\n\n\t// locate the portal entity closest to this plane.\n\t// origin will be the origin of the portal, origin2 will be\n\t// the origin of the camera\n\tfor ( i = 0 ; i < tr.refdef.num_entities ; i++ ) \n\t{\n\t\te = &tr.refdef.entities[i];\n\t\tif ( e->e.reType != RT_PORTALSURFACE ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\td = DotProduct( e->e.origin, originalPlane.normal ) - originalPlane.dist;\n\t\tif ( d > 64 || d < -64) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// if the entity is just a mirror, don't use as a camera point\n\t\tif ( e->e.oldorigin[0] == e->e.origin[0] && \n\t\t\te->e.oldorigin[1] == e->e.origin[1] && \n\t\t\te->e.oldorigin[2] == e->e.origin[2] ) \n\t\t{\n\t\t\treturn qtrue;\n\t\t}\n\n\t\treturn qfalse;\n\t}\n\treturn qfalse;\n}\n\n/*\n** SurfIsOffscreen\n**\n** Determines if a surface is completely offscreen.\n*/\nstatic qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128] ) {\n\tfloat shortest = 100000000;\n\tint entityNum;\n\tint numTriangles;\n\tshader_t *shader;\n\tint\t\tfogNum;\n\tint dlighted;\n\tvec4_t clip, eye;\n\tint i;\n\tunsigned int pointOr = 0;\n\tunsigned int pointAnd = (unsigned int)~0;\n\n\tif ( glConfig.smpActive ) {\t\t// FIXME!  we can't do RB_BeginSurface/RB_EndSurface stuff with smp!\n\t\treturn qfalse;\n\t}\n\n\tR_RotateForViewer();\n\n\tR_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlighted );\n\tRB_BeginSurface( shader, fogNum );\n\trb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface );\n\n\tassert( tess.numVertexes < 128 );\n\n\tfor ( i = 0; i < tess.numVertexes; i++ )\n\t{\n\t\tint j;\n\t\tunsigned int pointFlags = 0;\n\n\t\tR_TransformModelToClip( tess.xyz[i], tr.or.modelMatrix, tr.viewParms.projectionMatrix, eye, clip );\n\n\t\tfor ( j = 0; j < 3; j++ )\n\t\t{\n\t\t\tif ( clip[j] >= clip[3] )\n\t\t\t{\n\t\t\t\tpointFlags |= (1 << (j*2));\n\t\t\t}\n\t\t\telse if ( clip[j] <= -clip[3] )\n\t\t\t{\n\t\t\t\tpointFlags |= ( 1 << (j*2+1));\n\t\t\t}\n\t\t}\n\t\tpointAnd &= pointFlags;\n\t\tpointOr |= pointFlags;\n\t}\n\n\t// trivially reject\n\tif ( pointAnd )\n\t{\n\t\treturn qtrue;\n\t}\n\n\t// determine if this surface is backfaced and also determine the distance\n\t// to the nearest vertex so we can cull based on portal range.  Culling\n\t// based on vertex distance isn't 100% correct (we should be checking for\n\t// range to the surface), but it's good enough for the types of portals\n\t// we have in the game right now.\n\tnumTriangles = tess.numIndexes / 3;\n\n\tfor ( i = 0; i < tess.numIndexes; i += 3 )\n\t{\n\t\tvec3_t normal;\n\t\tfloat dot;\n\t\tfloat len;\n\n\t\tVectorSubtract( tess.xyz[tess.indexes[i]], tr.viewParms.or.origin, normal );\n\n\t\tlen = VectorLengthSquared( normal );\t\t\t// lose the sqrt\n\t\tif ( len < shortest )\n\t\t{\n\t\t\tshortest = len;\n\t\t}\n\n\t\tif ( ( dot = DotProduct( normal, tess.normal[tess.indexes[i]] ) ) >= 0 )\n\t\t{\n\t\t\tnumTriangles--;\n\t\t}\n\t}\n\tif ( !numTriangles )\n\t{\n\t\treturn qtrue;\n\t}\n\n\t// mirrors can early out at this point, since we don't do a fade over distance\n\t// with them (although we could)\n\tif ( IsMirror( drawSurf, entityNum ) )\n\t{\n\t\treturn qfalse;\n\t}\n\n\tif ( shortest > (tess.shader->portalRange*tess.shader->portalRange) )\n\t{\n\t\treturn qtrue;\n\t}\n\n\treturn qfalse;\n}\n\n/*\n========================\nR_MirrorViewBySurface\n\nReturns qtrue if another view has been rendered\n========================\n*/\nqboolean R_MirrorViewBySurface (drawSurf_t *drawSurf, int entityNum) {\n\tvec4_t\t\t\tclipDest[128];\n\tviewParms_t\t\tnewParms;\n\tviewParms_t\t\toldParms;\n\torientation_t\tsurface, camera;\n\n\t// don't recursively mirror\n\tif (tr.viewParms.isPortal) {\n\t\tri.Printf( PRINT_DEVELOPER, \"WARNING: recursive mirror/portal found\\n\" );\n\t\treturn qfalse;\n\t}\n\n\tif ( r_noportals->integer || (r_fastsky->integer == 1) ) {\n\t\treturn qfalse;\n\t}\n\n\t// trivially reject portal/mirror\n\tif ( SurfIsOffscreen( drawSurf, clipDest ) ) {\n\t\treturn qfalse;\n\t}\n\n\t// save old viewParms so we can return to it after the mirror view\n\toldParms = tr.viewParms;\n\n\tnewParms = tr.viewParms;\n\tnewParms.isPortal = qtrue;\n\tif ( !R_GetPortalOrientations( drawSurf, entityNum, &surface, &camera, \n\t\tnewParms.pvsOrigin, &newParms.isMirror ) ) {\n\t\treturn qfalse;\t\t// bad portal, no portalentity\n\t}\n\n\tR_MirrorPoint (oldParms.or.origin, &surface, &camera, newParms.or.origin );\n\n\tVectorSubtract( vec3_origin, camera.axis[0], newParms.portalPlane.normal );\n\tnewParms.portalPlane.dist = DotProduct( camera.origin, newParms.portalPlane.normal );\n\t\n\tR_MirrorVector (oldParms.or.axis[0], &surface, &camera, newParms.or.axis[0]);\n\tR_MirrorVector (oldParms.or.axis[1], &surface, &camera, newParms.or.axis[1]);\n\tR_MirrorVector (oldParms.or.axis[2], &surface, &camera, newParms.or.axis[2]);\n\n\t// OPTIMIZE: restrict the viewport on the mirrored view\n\n\t// render the mirror view\n\tR_RenderView (&newParms);\n\n\ttr.viewParms = oldParms;\n\n\treturn qtrue;\n}\n\n/*\n=================\nR_SpriteFogNum\n\nSee if a sprite is inside a fog volume\n=================\n*/\nint R_SpriteFogNum( trRefEntity_t *ent ) {\n\tint\t\t\t\ti, j;\n\tfog_t\t\t\t*fog;\n\n\tif ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) {\n\t\treturn 0;\n\t}\n\n\tfor ( i = 1 ; i < tr.world->numfogs ; i++ ) {\n\t\tfog = &tr.world->fogs[i];\n\t\tfor ( j = 0 ; j < 3 ; j++ ) {\n\t\t\tif ( ent->e.origin[j] - ent->e.radius >= fog->bounds[1][j] ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( ent->e.origin[j] + ent->e.radius <= fog->bounds[0][j] ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif ( j == 3 ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\n/*\n==========================================================================================\n\nDRAWSURF SORTING\n\n==========================================================================================\n*/\n\n/*\n=================\nqsort replacement\n\n=================\n*/\n#define\tSWAP_DRAW_SURF(a,b) temp=((int *)a)[0];((int *)a)[0]=((int *)b)[0];((int *)b)[0]=temp; temp=((int *)a)[1];((int *)a)[1]=((int *)b)[1];((int *)b)[1]=temp;\n\n/* this parameter defines the cutoff between using quick sort and\n   insertion sort for arrays; arrays with lengths shorter or equal to the\n   below value use insertion sort */\n\n#define CUTOFF 8            /* testing shows that this is good value */\n\nstatic void shortsort( drawSurf_t *lo, drawSurf_t *hi ) {\n    drawSurf_t\t*p, *max;\n\tint\t\t\ttemp;\n\n    while (hi > lo) {\n        max = lo;\n        for (p = lo + 1; p <= hi; p++ ) {\n            if ( p->sort > max->sort ) {\n                max = p;\n            }\n        }\n        SWAP_DRAW_SURF(max, hi);\n        hi--;\n    }\n}\n\n\n/* sort the array between lo and hi (inclusive)\nFIXME: this was lifted and modified from the microsoft lib source...\n */\n\nvoid qsortFast (\n    void *base,\n    unsigned num,\n    unsigned width\n    )\n{\n    char *lo, *hi;              /* ends of sub-array currently sorting */\n    char *mid;                  /* points to middle of subarray */\n    char *loguy, *higuy;        /* traveling pointers for partition step */\n    unsigned size;              /* size of the sub-array */\n    char *lostk[30], *histk[30];\n    int stkptr;                 /* stack for saving sub-array to be processed */\n\tint\ttemp;\n\n\tif ( sizeof(drawSurf_t) != 8 ) {\n\t\tri.Error( ERR_DROP, \"change SWAP_DRAW_SURF macro\" );\n\t}\n\n    /* Note: the number of stack entries required is no more than\n       1 + log2(size), so 30 is sufficient for any array */\n\n    if (num < 2 || width == 0)\n        return;                 /* nothing to do */\n\n    stkptr = 0;                 /* initialize stack */\n\n    lo = base;\n    hi = (char *)base + width * (num-1);        /* initialize limits */\n\n    /* this entry point is for pseudo-recursion calling: setting\n       lo and hi and jumping to here is like recursion, but stkptr is\n       prserved, locals aren't, so we preserve stuff on the stack */\nrecurse:\n\n    size = (hi - lo) / width + 1;        /* number of el's to sort */\n\n    /* below a certain size, it is faster to use a O(n^2) sorting method */\n    if (size <= CUTOFF) {\n         shortsort((drawSurf_t *)lo, (drawSurf_t *)hi);\n    }\n    else {\n        /* First we pick a partititioning element.  The efficiency of the\n           algorithm demands that we find one that is approximately the\n           median of the values, but also that we select one fast.  Using\n           the first one produces bad performace if the array is already\n           sorted, so we use the middle one, which would require a very\n           wierdly arranged array for worst case performance.  Testing shows\n           that a median-of-three algorithm does not, in general, increase\n           performance. */\n\n        mid = lo + (size / 2) * width;      /* find middle element */\n        SWAP_DRAW_SURF(mid, lo);               /* swap it to beginning of array */\n\n        /* We now wish to partition the array into three pieces, one\n           consisiting of elements <= partition element, one of elements\n           equal to the parition element, and one of element >= to it.  This\n           is done below; comments indicate conditions established at every\n           step. */\n\n        loguy = lo;\n        higuy = hi + width;\n\n        /* Note that higuy decreases and loguy increases on every iteration,\n           so loop must terminate. */\n        for (;;) {\n            /* lo <= loguy < hi, lo < higuy <= hi + 1,\n               A[i] <= A[lo] for lo <= i <= loguy,\n               A[i] >= A[lo] for higuy <= i <= hi */\n\n            do  {\n                loguy += width;\n            } while (loguy <= hi &&  \n\t\t\t\t( ((drawSurf_t *)loguy)->sort <= ((drawSurf_t *)lo)->sort ) );\n\n            /* lo < loguy <= hi+1, A[i] <= A[lo] for lo <= i < loguy,\n               either loguy > hi or A[loguy] > A[lo] */\n\n            do  {\n                higuy -= width;\n            } while (higuy > lo && \n\t\t\t\t( ((drawSurf_t *)higuy)->sort >= ((drawSurf_t *)lo)->sort ) );\n\n            /* lo-1 <= higuy <= hi, A[i] >= A[lo] for higuy < i <= hi,\n               either higuy <= lo or A[higuy] < A[lo] */\n\n            if (higuy < loguy)\n                break;\n\n            /* if loguy > hi or higuy <= lo, then we would have exited, so\n               A[loguy] > A[lo], A[higuy] < A[lo],\n               loguy < hi, highy > lo */\n\n            SWAP_DRAW_SURF(loguy, higuy);\n\n            /* A[loguy] < A[lo], A[higuy] > A[lo]; so condition at top\n               of loop is re-established */\n        }\n\n        /*     A[i] >= A[lo] for higuy < i <= hi,\n               A[i] <= A[lo] for lo <= i < loguy,\n               higuy < loguy, lo <= higuy <= hi\n           implying:\n               A[i] >= A[lo] for loguy <= i <= hi,\n               A[i] <= A[lo] for lo <= i <= higuy,\n               A[i] = A[lo] for higuy < i < loguy */\n\n        SWAP_DRAW_SURF(lo, higuy);     /* put partition element in place */\n\n        /* OK, now we have the following:\n              A[i] >= A[higuy] for loguy <= i <= hi,\n              A[i] <= A[higuy] for lo <= i < higuy\n              A[i] = A[lo] for higuy <= i < loguy    */\n\n        /* We've finished the partition, now we want to sort the subarrays\n           [lo, higuy-1] and [loguy, hi].\n           We do the smaller one first to minimize stack usage.\n           We only sort arrays of length 2 or more.*/\n\n        if ( higuy - 1 - lo >= hi - loguy ) {\n            if (lo + width < higuy) {\n                lostk[stkptr] = lo;\n                histk[stkptr] = higuy - width;\n                ++stkptr;\n            }                           /* save big recursion for later */\n\n            if (loguy < hi) {\n                lo = loguy;\n                goto recurse;           /* do small recursion */\n            }\n        }\n        else {\n            if (loguy < hi) {\n                lostk[stkptr] = loguy;\n                histk[stkptr] = hi;\n                ++stkptr;               /* save big recursion for later */\n            }\n\n            if (lo + width < higuy) {\n                hi = higuy - width;\n                goto recurse;           /* do small recursion */\n            }\n        }\n    }\n\n    /* We have sorted the array, except for any pending sorts on the stack.\n       Check if there are any, and do them. */\n\n    --stkptr;\n    if (stkptr >= 0) {\n        lo = lostk[stkptr];\n        hi = histk[stkptr];\n        goto recurse;           /* pop subarray from stack */\n    }\n    else\n        return;                 /* all subarrays done */\n}\n\n\n//==========================================================================================\n\n/*\n=================\nR_AddDrawSurf\n=================\n*/\nvoid R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, \n\t\t\t\t   int fogIndex, int dlightMap ) {\n\tint\t\t\tindex;\n\n\t// instead of checking for overflow, we just mask the index\n\t// so it wraps around\n\tindex = tr.refdef.numDrawSurfs & DRAWSURF_MASK;\n\t// the sort data is packed into a single 32 bit value so it can be\n\t// compared quickly during the qsorting process\n\ttr.refdef.drawSurfs[index].sort = (shader->sortedIndex << QSORT_SHADERNUM_SHIFT) \n\t\t| tr.shiftedEntityNum | ( fogIndex << QSORT_FOGNUM_SHIFT ) | (int)dlightMap;\n\ttr.refdef.drawSurfs[index].surface = surface;\n\ttr.refdef.numDrawSurfs++;\n}\n\n/*\n=================\nR_DecomposeSort\n=================\n*/\nvoid R_DecomposeSort( unsigned sort, int *entityNum, shader_t **shader, \n\t\t\t\t\t int *fogNum, int *dlightMap ) {\n\t*fogNum = ( sort >> QSORT_FOGNUM_SHIFT ) & 31;\n\t*shader = tr.sortedShaders[ ( sort >> QSORT_SHADERNUM_SHIFT ) & (MAX_SHADERS-1) ];\n\t*entityNum = ( sort >> QSORT_ENTITYNUM_SHIFT ) & 1023;\n\t*dlightMap = sort & 3;\n}\n\n/*\n=================\nR_SortDrawSurfs\n=================\n*/\nvoid R_SortDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) {\n\tshader_t\t\t*shader;\n\tint\t\t\t\tfogNum;\n\tint\t\t\t\tentityNum;\n\tint\t\t\t\tdlighted;\n\tint\t\t\t\ti;\n\n\t// it is possible for some views to not have any surfaces\n\tif ( numDrawSurfs < 1 ) {\n\t\t// we still need to add it for hyperspace cases\n\t\tR_AddDrawSurfCmd( drawSurfs, numDrawSurfs );\n\t\treturn;\n\t}\n\n\t// if we overflowed MAX_DRAWSURFS, the drawsurfs\n\t// wrapped around in the buffer and we will be missing\n\t// the first surfaces, not the last ones\n\tif ( numDrawSurfs > MAX_DRAWSURFS ) {\n\t\tnumDrawSurfs = MAX_DRAWSURFS;\n\t}\n\n\t// sort the drawsurfs by sort type, then orientation, then shader\n\tqsortFast (drawSurfs, numDrawSurfs, sizeof(drawSurf_t) );\n\n\t// check for any pass through drawing, which\n\t// may cause another view to be rendered first\n\tfor ( i = 0 ; i < numDrawSurfs ; i++ ) {\n\t\tR_DecomposeSort( (drawSurfs+i)->sort, &entityNum, &shader, &fogNum, &dlighted );\n\n\t\tif ( shader->sort > SS_PORTAL ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// no shader should ever have this sort type\n\t\tif ( shader->sort == SS_BAD ) {\n\t\t\tri.Error (ERR_DROP, \"Shader '%s'with sort == SS_BAD\", shader->name );\n\t\t}\n\n\t\t// if the mirror was completely clipped away, we may need to check another surface\n\t\tif ( R_MirrorViewBySurface( (drawSurfs+i), entityNum) ) {\n\t\t\t// this is a debug option to see exactly what is being mirrored\n\t\t\tif ( r_portalOnly->integer ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbreak;\t\t// only one mirror view at a time\n\t\t}\n\t}\n\n\tR_AddDrawSurfCmd( drawSurfs, numDrawSurfs );\n}\n\n/*\n=============\nR_AddEntitySurfaces\n=============\n*/\nvoid R_AddEntitySurfaces (void) {\n\ttrRefEntity_t\t*ent;\n\tshader_t\t\t*shader;\n\n\tif ( !r_drawentities->integer ) {\n\t\treturn;\n\t}\n\n\tfor ( tr.currentEntityNum = 0; \n\t      tr.currentEntityNum < tr.refdef.num_entities; \n\t\t  tr.currentEntityNum++ ) {\n\t\tent = tr.currentEntity = &tr.refdef.entities[tr.currentEntityNum];\n\n\t\tent->needDlights = qfalse;\n\n\t\t// preshift the value we are going to OR into the drawsurf sort\n\t\ttr.shiftedEntityNum = tr.currentEntityNum << QSORT_ENTITYNUM_SHIFT;\n\n\t\t//\n\t\t// the weapon model must be handled special --\n\t\t// we don't want the hacked weapon position showing in \n\t\t// mirrors, because the true body position will already be drawn\n\t\t//\n\t\tif ( (ent->e.renderfx & RF_FIRST_PERSON) && tr.viewParms.isPortal) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// simple generated models, like sprites and beams, are not culled\n\t\tswitch ( ent->e.reType ) {\n\t\tcase RT_PORTALSURFACE:\n\t\t\tbreak;\t\t// don't draw anything\n\t\tcase RT_SPRITE:\n\t\tcase RT_BEAM:\n\t\tcase RT_LIGHTNING:\n\t\tcase RT_RAIL_CORE:\n\t\tcase RT_RAIL_RINGS:\n\t\t\t// self blood sprites, talk balloons, etc should not be drawn in the primary\n\t\t\t// view.  We can't just do this check for all entities, because md3\n\t\t\t// entities may still want to cast shadows from them\n\t\t\tif ( (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tshader = R_GetShaderByHandle( ent->e.customShader );\n\t\t\tR_AddDrawSurf( &entitySurface, shader, R_SpriteFogNum( ent ), 0 );\n\t\t\tbreak;\n\n\t\tcase RT_MODEL:\n\t\t\t// we must set up parts of tr.or for model culling\n\t\t\tR_RotateForEntity( ent, &tr.viewParms, &tr.or );\n\n\t\t\ttr.currentModel = R_GetModelByHandle( ent->e.hModel );\n\t\t\tif (!tr.currentModel) {\n\t\t\t\tR_AddDrawSurf( &entitySurface, tr.defaultShader, 0, 0 );\n\t\t\t} else {\n\t\t\t\tswitch ( tr.currentModel->type ) {\n\t\t\t\tcase MOD_MESH:\n\t\t\t\t\tR_AddMD3Surfaces( ent );\n\t\t\t\t\tbreak;\n\t\t\t\tcase MOD_MD4:\n\t\t\t\t\tR_AddAnimSurfaces( ent );\n\t\t\t\t\tbreak;\n\t\t\t\tcase MOD_BRUSH:\n\t\t\t\t\tR_AddBrushModelSurfaces( ent );\n\t\t\t\t\tbreak;\n\t\t\t\tcase MOD_BAD:\t\t// null model axis\n\t\t\t\t\tif ( (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tshader = R_GetShaderByHandle( ent->e.customShader );\n\t\t\t\t\tR_AddDrawSurf( &entitySurface, tr.defaultShader, 0, 0 );\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tri.Error( ERR_DROP, \"R_AddEntitySurfaces: Bad modeltype\" );\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tri.Error( ERR_DROP, \"R_AddEntitySurfaces: Bad reType\" );\n\t\t}\n\t}\n\n}\n\n\n/*\n====================\nR_GenerateDrawSurfs\n====================\n*/\nvoid R_GenerateDrawSurfs( void ) {\n\tR_AddWorldSurfaces ();\n\n\tR_AddPolygonSurfaces();\n\n\t// set the projection matrix with the minimum zfar\n\t// now that we have the world bounded\n\t// this needs to be done before entities are\n\t// added, because they use the projection\n\t// matrix for lod calculation\n\tR_SetupProjection ();\n\n\tR_AddEntitySurfaces ();\n}\n\n/*\n================\nR_DebugPolygon\n================\n*/\nvoid R_DebugPolygon( int color, int numPoints, float *points ) {\n\tint\t\ti;\n\n\tGL_State( GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE );\n\n\t// draw solid shade\n\n\tqglColor3f( color&1, (color>>1)&1, (color>>2)&1 );\n\tqglBegin( GL_POLYGON );\n\tfor ( i = 0 ; i < numPoints ; i++ ) {\n\t\tqglVertex3fv( points + i * 3 );\n\t}\n\tqglEnd();\n\n\t// draw wireframe outline\n\tGL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE );\n\tqglDepthRange( 0, 0 );\n\tqglColor3f( 1, 1, 1 );\n\tqglBegin( GL_POLYGON );\n\tfor ( i = 0 ; i < numPoints ; i++ ) {\n\t\tqglVertex3fv( points + i * 3 );\n\t}\n\tqglEnd();\n\tqglDepthRange( 0, 1 );\n}\n\n/*\n====================\nR_DebugGraphics\n\nVisualization aid for movement clipping debugging\n====================\n*/\nvoid R_DebugGraphics( void ) {\n\tif ( !r_debugSurface->integer ) {\n\t\treturn;\n\t}\n\n\t// the render thread can't make callbacks to the main thread\n\tR_SyncRenderThread();\n\n\tGL_Bind( tr.whiteImage);\n\tGL_Cull( CT_FRONT_SIDED );\n\tri.CM_DrawDebugSurface( R_DebugPolygon );\n}\n\n\n/*\n================\nR_RenderView\n\nA view may be either the actual camera view,\nor a mirror / remote location\n================\n*/\nvoid R_RenderView (viewParms_t *parms) {\n\tint\t\tfirstDrawSurf;\n\n\tif ( parms->viewportWidth <= 0 || parms->viewportHeight <= 0 ) {\n\t\treturn;\n\t}\n\n\ttr.viewCount++;\n\n\ttr.viewParms = *parms;\n\ttr.viewParms.frameSceneNum = tr.frameSceneNum;\n\ttr.viewParms.frameCount = tr.frameCount;\n\n\tfirstDrawSurf = tr.refdef.numDrawSurfs;\n\n\ttr.viewCount++;\n\n\t// set viewParms.world\n\tR_RotateForViewer ();\n\n\tR_SetupFrustum ();\n\n\tR_GenerateDrawSurfs();\n\n\tR_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf );\n\n\t// draw main system development information (surface outlines, etc)\n\tR_DebugGraphics();\n}\n\n\n\n"
  },
  {
    "path": "code/renderer/tr_marks.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// tr_marks.c -- polygon projection on the world polygons\n\n#include \"tr_local.h\"\n//#include \"assert.h\"\n\n#define MAX_VERTS_ON_POLY\t\t64\n\n#define MARKER_OFFSET\t\t\t0\t// 1\n\n/*\n=============\nR_ChopPolyBehindPlane\n\nOut must have space for two more vertexes than in\n=============\n*/\n#define\tSIDE_FRONT\t0\n#define\tSIDE_BACK\t1\n#define\tSIDE_ON\t\t2\nstatic void R_ChopPolyBehindPlane( int numInPoints, vec3_t inPoints[MAX_VERTS_ON_POLY],\n\t\t\t\t\t\t\t\t   int *numOutPoints, vec3_t outPoints[MAX_VERTS_ON_POLY], \n\t\t\t\t\t\t\tvec3_t normal, vec_t dist, vec_t epsilon) {\n\tfloat\t\tdists[MAX_VERTS_ON_POLY+4];\n\tint\t\t\tsides[MAX_VERTS_ON_POLY+4];\n\tint\t\t\tcounts[3];\n\tfloat\t\tdot;\n\tint\t\t\ti, j;\n\tfloat\t\t*p1, *p2, *clip;\n\tfloat\t\td;\n\n\t// don't clip if it might overflow\n\tif ( numInPoints >= MAX_VERTS_ON_POLY - 2 ) {\n\t\t*numOutPoints = 0;\n\t\treturn;\n\t}\n\n\tcounts[0] = counts[1] = counts[2] = 0;\n\n\t// determine sides for each point\n\tfor ( i = 0 ; i < numInPoints ; i++ ) {\n\t\tdot = DotProduct( inPoints[i], normal );\n\t\tdot -= dist;\n\t\tdists[i] = dot;\n\t\tif ( dot > epsilon ) {\n\t\t\tsides[i] = SIDE_FRONT;\n\t\t} else if ( dot < -epsilon ) {\n\t\t\tsides[i] = SIDE_BACK;\n\t\t} else {\n\t\t\tsides[i] = SIDE_ON;\n\t\t}\n\t\tcounts[sides[i]]++;\n\t}\n\tsides[i] = sides[0];\n\tdists[i] = dists[0];\n\n\t*numOutPoints = 0;\n\n\tif ( !counts[0] ) {\n\t\treturn;\n\t}\n\tif ( !counts[1] ) {\n\t\t*numOutPoints = numInPoints;\n\t\tCom_Memcpy( outPoints, inPoints, numInPoints * sizeof(vec3_t) );\n\t\treturn;\n\t}\n\n\tfor ( i = 0 ; i < numInPoints ; i++ ) {\n\t\tp1 = inPoints[i];\n\t\tclip = outPoints[ *numOutPoints ];\n\t\t\n\t\tif ( sides[i] == SIDE_ON ) {\n\t\t\tVectorCopy( p1, clip );\n\t\t\t(*numOutPoints)++;\n\t\t\tcontinue;\n\t\t}\n\t\n\t\tif ( sides[i] == SIDE_FRONT ) {\n\t\t\tVectorCopy( p1, clip );\n\t\t\t(*numOutPoints)++;\n\t\t\tclip = outPoints[ *numOutPoints ];\n\t\t}\n\n\t\tif ( sides[i+1] == SIDE_ON || sides[i+1] == sides[i] ) {\n\t\t\tcontinue;\n\t\t}\n\t\t\t\n\t\t// generate a split point\n\t\tp2 = inPoints[ (i+1) % numInPoints ];\n\n\t\td = dists[i] - dists[i+1];\n\t\tif ( d == 0 ) {\n\t\t\tdot = 0;\n\t\t} else {\n\t\t\tdot = dists[i] / d;\n\t\t}\n\n\t\t// clip xyz\n\n\t\tfor (j=0 ; j<3 ; j++) {\n\t\t\tclip[j] = p1[j] + dot * ( p2[j] - p1[j] );\n\t\t}\n\n\t\t(*numOutPoints)++;\n\t}\n}\n\n/*\n=================\nR_BoxSurfaces_r\n\n=================\n*/\nvoid R_BoxSurfaces_r(mnode_t *node, vec3_t mins, vec3_t maxs, surfaceType_t **list, int listsize, int *listlength, vec3_t dir) {\n\n\tint\t\t\ts, c;\n\tmsurface_t\t*surf, **mark;\n\n\t// do the tail recursion in a loop\n\twhile ( node->contents == -1 ) {\n\t\ts = BoxOnPlaneSide( mins, maxs, node->plane );\n\t\tif (s == 1) {\n\t\t\tnode = node->children[0];\n\t\t} else if (s == 2) {\n\t\t\tnode = node->children[1];\n\t\t} else {\n\t\t\tR_BoxSurfaces_r(node->children[0], mins, maxs, list, listsize, listlength, dir);\n\t\t\tnode = node->children[1];\n\t\t}\n\t}\n\n\t// add the individual surfaces\n\tmark = node->firstmarksurface;\n\tc = node->nummarksurfaces;\n\twhile (c--) {\n\t\t//\n\t\tif (*listlength >= listsize) break;\n\t\t//\n\t\tsurf = *mark;\n\t\t// check if the surface has NOIMPACT or NOMARKS set\n\t\tif ( ( surf->shader->surfaceFlags & ( SURF_NOIMPACT | SURF_NOMARKS ) )\n\t\t\t|| ( surf->shader->contentFlags & CONTENTS_FOG ) ) {\n\t\t\tsurf->viewCount = tr.viewCount;\n\t\t}\n\t\t// extra check for surfaces to avoid list overflows\n\t\telse if (*(surf->data) == SF_FACE) {\n\t\t\t// the face plane should go through the box\n\t\t\ts = BoxOnPlaneSide( mins, maxs, &(( srfSurfaceFace_t * ) surf->data)->plane );\n\t\t\tif (s == 1 || s == 2) {\n\t\t\t\tsurf->viewCount = tr.viewCount;\n\t\t\t} else if (DotProduct((( srfSurfaceFace_t * ) surf->data)->plane.normal, dir) > -0.5) {\n\t\t\t// don't add faces that make sharp angles with the projection direction\n\t\t\t\tsurf->viewCount = tr.viewCount;\n\t\t\t}\n\t\t}\n\t\telse if (*(surfaceType_t *) (surf->data) != SF_GRID) surf->viewCount = tr.viewCount;\n\t\t// check the viewCount because the surface may have\n\t\t// already been added if it spans multiple leafs\n\t\tif (surf->viewCount != tr.viewCount) {\n\t\t\tsurf->viewCount = tr.viewCount;\n\t\t\tlist[*listlength] = (surfaceType_t *) surf->data;\n\t\t\t(*listlength)++;\n\t\t}\n\t\tmark++;\n\t}\n}\n\n/*\n=================\nR_AddMarkFragments\n\n=================\n*/\nvoid R_AddMarkFragments(int numClipPoints, vec3_t clipPoints[2][MAX_VERTS_ON_POLY],\n\t\t\t\t   int numPlanes, vec3_t *normals, float *dists,\n\t\t\t\t   int maxPoints, vec3_t pointBuffer,\n\t\t\t\t   int maxFragments, markFragment_t *fragmentBuffer,\n\t\t\t\t   int *returnedPoints, int *returnedFragments,\n\t\t\t\t   vec3_t mins, vec3_t maxs) {\n\tint pingPong, i;\n\tmarkFragment_t\t*mf;\n\n\t// chop the surface by all the bounding planes of the to be projected polygon\n\tpingPong = 0;\n\n\tfor ( i = 0 ; i < numPlanes ; i++ ) {\n\n\t\tR_ChopPolyBehindPlane( numClipPoints, clipPoints[pingPong],\n\t\t\t\t\t\t   &numClipPoints, clipPoints[!pingPong],\n\t\t\t\t\t\t\tnormals[i], dists[i], 0.5 );\n\t\tpingPong ^= 1;\n\t\tif ( numClipPoints == 0 ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\t// completely clipped away?\n\tif ( numClipPoints == 0 ) {\n\t\treturn;\n\t}\n\n\t// add this fragment to the returned list\n\tif ( numClipPoints + (*returnedPoints) > maxPoints ) {\n\t\treturn;\t// not enough space for this polygon\n\t}\n\t/*\n\t// all the clip points should be within the bounding box\n\tfor ( i = 0 ; i < numClipPoints ; i++ ) {\n\t\tint j;\n\t\tfor ( j = 0 ; j < 3 ; j++ ) {\n\t\t\tif (clipPoints[pingPong][i][j] < mins[j] - 0.5) break;\n\t\t\tif (clipPoints[pingPong][i][j] > maxs[j] + 0.5) break;\n\t\t}\n\t\tif (j < 3) break;\n\t}\n\tif (i < numClipPoints) return;\n\t*/\n\n\tmf = fragmentBuffer + (*returnedFragments);\n\tmf->firstPoint = (*returnedPoints);\n\tmf->numPoints = numClipPoints;\n\tCom_Memcpy( pointBuffer + (*returnedPoints) * 3, clipPoints[pingPong], numClipPoints * sizeof(vec3_t) );\n\n\t(*returnedPoints) += numClipPoints;\n\t(*returnedFragments)++;\n}\n\n/*\n=================\nR_MarkFragments\n\n=================\n*/\nint R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projection,\n\t\t\t\t   int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer ) {\n\tint\t\t\t\tnumsurfaces, numPlanes;\n\tint\t\t\t\ti, j, k, m, n;\n\tsurfaceType_t\t*surfaces[64];\n\tvec3_t\t\t\tmins, maxs;\n\tint\t\t\t\treturnedFragments;\n\tint\t\t\t\treturnedPoints;\n\tvec3_t\t\t\tnormals[MAX_VERTS_ON_POLY+2];\n\tfloat\t\t\tdists[MAX_VERTS_ON_POLY+2];\n\tvec3_t\t\t\tclipPoints[2][MAX_VERTS_ON_POLY];\n\tint\t\t\t\tnumClipPoints;\n\tfloat\t\t\t*v;\n\tsrfSurfaceFace_t *surf;\n\tsrfGridMesh_t\t*cv;\n\tdrawVert_t\t\t*dv;\n\tvec3_t\t\t\tnormal;\n\tvec3_t\t\t\tprojectionDir;\n\tvec3_t\t\t\tv1, v2;\n\tint\t\t\t\t*indexes;\n\n\t//increment view count for double check prevention\n\ttr.viewCount++;\n\n\t//\n\tVectorNormalize2( projection, projectionDir );\n\t// find all the brushes that are to be considered\n\tClearBounds( mins, maxs );\n\tfor ( i = 0 ; i < numPoints ; i++ ) {\n\t\tvec3_t\ttemp;\n\n\t\tAddPointToBounds( points[i], mins, maxs );\n\t\tVectorAdd( points[i], projection, temp );\n\t\tAddPointToBounds( temp, mins, maxs );\n\t\t// make sure we get all the leafs (also the one(s) in front of the hit surface)\n\t\tVectorMA( points[i], -20, projectionDir, temp );\n\t\tAddPointToBounds( temp, mins, maxs );\n\t}\n\n\tif (numPoints > MAX_VERTS_ON_POLY) numPoints = MAX_VERTS_ON_POLY;\n\t// create the bounding planes for the to be projected polygon\n\tfor ( i = 0 ; i < numPoints ; i++ ) {\n\t\tVectorSubtract(points[(i+1)%numPoints], points[i], v1);\n\t\tVectorAdd(points[i], projection, v2);\n\t\tVectorSubtract(points[i], v2, v2);\n\t\tCrossProduct(v1, v2, normals[i]);\n\t\tVectorNormalizeFast(normals[i]);\n\t\tdists[i] = DotProduct(normals[i], points[i]);\n\t}\n\t// add near and far clipping planes for projection\n\tVectorCopy(projectionDir, normals[numPoints]);\n\tdists[numPoints] = DotProduct(normals[numPoints], points[0]) - 32;\n\tVectorCopy(projectionDir, normals[numPoints+1]);\n\tVectorInverse(normals[numPoints+1]);\n\tdists[numPoints+1] = DotProduct(normals[numPoints+1], points[0]) - 20;\n\tnumPlanes = numPoints + 2;\n\n\tnumsurfaces = 0;\n\tR_BoxSurfaces_r(tr.world->nodes, mins, maxs, surfaces, 64, &numsurfaces, projectionDir);\n\t//assert(numsurfaces <= 64);\n\t//assert(numsurfaces != 64);\n\n\treturnedPoints = 0;\n\treturnedFragments = 0;\n\n\tfor ( i = 0 ; i < numsurfaces ; i++ ) {\n\n\t\tif (*surfaces[i] == SF_GRID) {\n\n\t\t\tcv = (srfGridMesh_t *) surfaces[i];\n\t\t\tfor ( m = 0 ; m < cv->height - 1 ; m++ ) {\n\t\t\t\tfor ( n = 0 ; n < cv->width - 1 ; n++ ) {\n\t\t\t\t\t// We triangulate the grid and chop all triangles within\n\t\t\t\t\t// the bounding planes of the to be projected polygon.\n\t\t\t\t\t// LOD is not taken into account, not such a big deal though.\n\t\t\t\t\t//\n\t\t\t\t\t// It's probably much nicer to chop the grid itself and deal\n\t\t\t\t\t// with this grid as a normal SF_GRID surface so LOD will\n\t\t\t\t\t// be applied. However the LOD of that chopped grid must\n\t\t\t\t\t// be synced with the LOD of the original curve.\n\t\t\t\t\t// One way to do this; the chopped grid shares vertices with\n\t\t\t\t\t// the original curve. When LOD is applied to the original\n\t\t\t\t\t// curve the unused vertices are flagged. Now the chopped curve\n\t\t\t\t\t// should skip the flagged vertices. This still leaves the\n\t\t\t\t\t// problems with the vertices at the chopped grid edges.\n\t\t\t\t\t//\n\t\t\t\t\t// To avoid issues when LOD applied to \"hollow curves\" (like\n\t\t\t\t\t// the ones around many jump pads) we now just add a 2 unit\n\t\t\t\t\t// offset to the triangle vertices.\n\t\t\t\t\t// The offset is added in the vertex normal vector direction\n\t\t\t\t\t// so all triangles will still fit together.\n\t\t\t\t\t// The 2 unit offset should avoid pretty much all LOD problems.\n\n\t\t\t\t\tnumClipPoints = 3;\n\n\t\t\t\t\tdv = cv->verts + m * cv->width + n;\n\n\t\t\t\t\tVectorCopy(dv[0].xyz, clipPoints[0][0]);\n\t\t\t\t\tVectorMA(clipPoints[0][0], MARKER_OFFSET, dv[0].normal, clipPoints[0][0]);\n\t\t\t\t\tVectorCopy(dv[cv->width].xyz, clipPoints[0][1]);\n\t\t\t\t\tVectorMA(clipPoints[0][1], MARKER_OFFSET, dv[cv->width].normal, clipPoints[0][1]);\n\t\t\t\t\tVectorCopy(dv[1].xyz, clipPoints[0][2]);\n\t\t\t\t\tVectorMA(clipPoints[0][2], MARKER_OFFSET, dv[1].normal, clipPoints[0][2]);\n\t\t\t\t\t// check the normal of this triangle\n\t\t\t\t\tVectorSubtract(clipPoints[0][0], clipPoints[0][1], v1);\n\t\t\t\t\tVectorSubtract(clipPoints[0][2], clipPoints[0][1], v2);\n\t\t\t\t\tCrossProduct(v1, v2, normal);\n\t\t\t\t\tVectorNormalizeFast(normal);\n\t\t\t\t\tif (DotProduct(normal, projectionDir) < -0.1) {\n\t\t\t\t\t\t// add the fragments of this triangle\n\t\t\t\t\t\tR_AddMarkFragments(numClipPoints, clipPoints,\n\t\t\t\t\t\t\t\t\t\t   numPlanes, normals, dists,\n\t\t\t\t\t\t\t\t\t\t   maxPoints, pointBuffer,\n\t\t\t\t\t\t\t\t\t\t   maxFragments, fragmentBuffer,\n\t\t\t\t\t\t\t\t\t\t   &returnedPoints, &returnedFragments, mins, maxs);\n\n\t\t\t\t\t\tif ( returnedFragments == maxFragments ) {\n\t\t\t\t\t\t\treturn returnedFragments;\t// not enough space for more fragments\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tVectorCopy(dv[1].xyz, clipPoints[0][0]);\n\t\t\t\t\tVectorMA(clipPoints[0][0], MARKER_OFFSET, dv[1].normal, clipPoints[0][0]);\n\t\t\t\t\tVectorCopy(dv[cv->width].xyz, clipPoints[0][1]);\n\t\t\t\t\tVectorMA(clipPoints[0][1], MARKER_OFFSET, dv[cv->width].normal, clipPoints[0][1]);\n\t\t\t\t\tVectorCopy(dv[cv->width+1].xyz, clipPoints[0][2]);\n\t\t\t\t\tVectorMA(clipPoints[0][2], MARKER_OFFSET, dv[cv->width+1].normal, clipPoints[0][2]);\n\t\t\t\t\t// check the normal of this triangle\n\t\t\t\t\tVectorSubtract(clipPoints[0][0], clipPoints[0][1], v1);\n\t\t\t\t\tVectorSubtract(clipPoints[0][2], clipPoints[0][1], v2);\n\t\t\t\t\tCrossProduct(v1, v2, normal);\n\t\t\t\t\tVectorNormalizeFast(normal);\n\t\t\t\t\tif (DotProduct(normal, projectionDir) < -0.05) {\n\t\t\t\t\t\t// add the fragments of this triangle\n\t\t\t\t\t\tR_AddMarkFragments(numClipPoints, clipPoints,\n\t\t\t\t\t\t\t\t\t\t   numPlanes, normals, dists,\n\t\t\t\t\t\t\t\t\t\t   maxPoints, pointBuffer,\n\t\t\t\t\t\t\t\t\t\t   maxFragments, fragmentBuffer,\n\t\t\t\t\t\t\t\t\t\t   &returnedPoints, &returnedFragments, mins, maxs);\n\n\t\t\t\t\t\tif ( returnedFragments == maxFragments ) {\n\t\t\t\t\t\t\treturn returnedFragments;\t// not enough space for more fragments\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if (*surfaces[i] == SF_FACE) {\n\n\t\t\tsurf = ( srfSurfaceFace_t * ) surfaces[i];\n\t\t\t// check the normal of this face\n\t\t\tif (DotProduct(surf->plane.normal, projectionDir) > -0.5) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t/*\n\t\t\tVectorSubtract(clipPoints[0][0], clipPoints[0][1], v1);\n\t\t\tVectorSubtract(clipPoints[0][2], clipPoints[0][1], v2);\n\t\t\tCrossProduct(v1, v2, normal);\n\t\t\tVectorNormalize(normal);\n\t\t\tif (DotProduct(normal, projectionDir) > -0.5) continue;\n\t\t\t*/\n\t\t\tindexes = (int *)( (byte *)surf + surf->ofsIndices );\n\t\t\tfor ( k = 0 ; k < surf->numIndices ; k += 3 ) {\n\t\t\t\tfor ( j = 0 ; j < 3 ; j++ ) {\n\t\t\t\t\tv = surf->points[0] + VERTEXSIZE * indexes[k+j];;\n\t\t\t\t\tVectorMA( v, MARKER_OFFSET, surf->plane.normal, clipPoints[0][j] );\n\t\t\t\t}\n\t\t\t\t// add the fragments of this face\n\t\t\t\tR_AddMarkFragments( 3 , clipPoints,\n\t\t\t\t\t\t\t\t   numPlanes, normals, dists,\n\t\t\t\t\t\t\t\t   maxPoints, pointBuffer,\n\t\t\t\t\t\t\t\t   maxFragments, fragmentBuffer,\n\t\t\t\t\t\t\t\t   &returnedPoints, &returnedFragments, mins, maxs);\n\t\t\t\tif ( returnedFragments == maxFragments ) {\n\t\t\t\t\treturn returnedFragments;\t// not enough space for more fragments\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\telse {\n\t\t\t// ignore all other world surfaces\n\t\t\t// might be cool to also project polygons on a triangle soup\n\t\t\t// however this will probably create huge amounts of extra polys\n\t\t\t// even more than the projection onto curves\n\t\t\tcontinue;\n\t\t}\n\t}\n\treturn returnedFragments;\n}\n\n"
  },
  {
    "path": "code/renderer/tr_mesh.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// tr_mesh.c: triangle model functions\n\n#include \"tr_local.h\"\n\nstatic float ProjectRadius( float r, vec3_t location )\n{\n\tfloat pr;\n\tfloat dist;\n\tfloat c;\n\tvec3_t\tp;\n\tfloat\tprojected[4];\n\n\tc = DotProduct( tr.viewParms.or.axis[0], tr.viewParms.or.origin );\n\tdist = DotProduct( tr.viewParms.or.axis[0], location ) - c;\n\n\tif ( dist <= 0 )\n\t\treturn 0;\n\n\tp[0] = 0;\n\tp[1] = fabs( r );\n\tp[2] = -dist;\n\n\tprojected[0] = p[0] * tr.viewParms.projectionMatrix[0] + \n\t\t           p[1] * tr.viewParms.projectionMatrix[4] +\n\t\t\t\t   p[2] * tr.viewParms.projectionMatrix[8] +\n\t\t\t\t   tr.viewParms.projectionMatrix[12];\n\n\tprojected[1] = p[0] * tr.viewParms.projectionMatrix[1] + \n\t\t           p[1] * tr.viewParms.projectionMatrix[5] +\n\t\t\t\t   p[2] * tr.viewParms.projectionMatrix[9] +\n\t\t\t\t   tr.viewParms.projectionMatrix[13];\n\n\tprojected[2] = p[0] * tr.viewParms.projectionMatrix[2] + \n\t\t           p[1] * tr.viewParms.projectionMatrix[6] +\n\t\t\t\t   p[2] * tr.viewParms.projectionMatrix[10] +\n\t\t\t\t   tr.viewParms.projectionMatrix[14];\n\n\tprojected[3] = p[0] * tr.viewParms.projectionMatrix[3] + \n\t\t           p[1] * tr.viewParms.projectionMatrix[7] +\n\t\t\t\t   p[2] * tr.viewParms.projectionMatrix[11] +\n\t\t\t\t   tr.viewParms.projectionMatrix[15];\n\n\n\tpr = projected[1] / projected[3];\n\n\tif ( pr > 1.0f )\n\t\tpr = 1.0f;\n\n\treturn pr;\n}\n\n/*\n=============\nR_CullModel\n=============\n*/\nstatic int R_CullModel( md3Header_t *header, trRefEntity_t *ent ) {\n\tvec3_t\t\tbounds[2];\n\tmd3Frame_t\t*oldFrame, *newFrame;\n\tint\t\t\ti;\n\n\t// compute frame pointers\n\tnewFrame = ( md3Frame_t * ) ( ( byte * ) header + header->ofsFrames ) + ent->e.frame;\n\toldFrame = ( md3Frame_t * ) ( ( byte * ) header + header->ofsFrames ) + ent->e.oldframe;\n\n\t// cull bounding sphere ONLY if this is not an upscaled entity\n\tif ( !ent->e.nonNormalizedAxes )\n\t{\n\t\tif ( ent->e.frame == ent->e.oldframe )\n\t\t{\n\t\t\tswitch ( R_CullLocalPointAndRadius( newFrame->localOrigin, newFrame->radius ) )\n\t\t\t{\n\t\t\tcase CULL_OUT:\n\t\t\t\ttr.pc.c_sphere_cull_md3_out++;\n\t\t\t\treturn CULL_OUT;\n\n\t\t\tcase CULL_IN:\n\t\t\t\ttr.pc.c_sphere_cull_md3_in++;\n\t\t\t\treturn CULL_IN;\n\n\t\t\tcase CULL_CLIP:\n\t\t\t\ttr.pc.c_sphere_cull_md3_clip++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tint sphereCull, sphereCullB;\n\n\t\t\tsphereCull  = R_CullLocalPointAndRadius( newFrame->localOrigin, newFrame->radius );\n\t\t\tif ( newFrame == oldFrame ) {\n\t\t\t\tsphereCullB = sphereCull;\n\t\t\t} else {\n\t\t\t\tsphereCullB = R_CullLocalPointAndRadius( oldFrame->localOrigin, oldFrame->radius );\n\t\t\t}\n\n\t\t\tif ( sphereCull == sphereCullB )\n\t\t\t{\n\t\t\t\tif ( sphereCull == CULL_OUT )\n\t\t\t\t{\n\t\t\t\t\ttr.pc.c_sphere_cull_md3_out++;\n\t\t\t\t\treturn CULL_OUT;\n\t\t\t\t}\n\t\t\t\telse if ( sphereCull == CULL_IN )\n\t\t\t\t{\n\t\t\t\t\ttr.pc.c_sphere_cull_md3_in++;\n\t\t\t\t\treturn CULL_IN;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\ttr.pc.c_sphere_cull_md3_clip++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\t// calculate a bounding box in the current coordinate system\n\tfor (i = 0 ; i < 3 ; i++) {\n\t\tbounds[0][i] = oldFrame->bounds[0][i] < newFrame->bounds[0][i] ? oldFrame->bounds[0][i] : newFrame->bounds[0][i];\n\t\tbounds[1][i] = oldFrame->bounds[1][i] > newFrame->bounds[1][i] ? oldFrame->bounds[1][i] : newFrame->bounds[1][i];\n\t}\n\n\tswitch ( R_CullLocalBox( bounds ) )\n\t{\n\tcase CULL_IN:\n\t\ttr.pc.c_box_cull_md3_in++;\n\t\treturn CULL_IN;\n\tcase CULL_CLIP:\n\t\ttr.pc.c_box_cull_md3_clip++;\n\t\treturn CULL_CLIP;\n\tcase CULL_OUT:\n\tdefault:\n\t\ttr.pc.c_box_cull_md3_out++;\n\t\treturn CULL_OUT;\n\t}\n}\n\n\n/*\n=================\nR_ComputeLOD\n\n=================\n*/\nint R_ComputeLOD( trRefEntity_t *ent ) {\n\tfloat radius;\n\tfloat flod, lodscale;\n\tfloat projectedRadius;\n\tmd3Frame_t *frame;\n\tint lod;\n\n\tif ( tr.currentModel->numLods < 2 )\n\t{\n\t\t// model has only 1 LOD level, skip computations and bias\n\t\tlod = 0;\n\t}\n\telse\n\t{\n\t\t// multiple LODs exist, so compute projected bounding sphere\n\t\t// and use that as a criteria for selecting LOD\n\n\t\tframe = ( md3Frame_t * ) ( ( ( unsigned char * ) tr.currentModel->md3[0] ) + tr.currentModel->md3[0]->ofsFrames );\n\n\t\tframe += ent->e.frame;\n\n\t\tradius = RadiusFromBounds( frame->bounds[0], frame->bounds[1] );\n\n\t\tif ( ( projectedRadius = ProjectRadius( radius, ent->e.origin ) ) != 0 )\n\t\t{\n\t\t\tlodscale = r_lodscale->value;\n\t\t\tif (lodscale > 20) lodscale = 20;\n\t\t\tflod = 1.0f - projectedRadius * lodscale;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// object intersects near view plane, e.g. view weapon\n\t\t\tflod = 0;\n\t\t}\n\n\t\tflod *= tr.currentModel->numLods;\n\t\tlod = myftol( flod );\n\n\t\tif ( lod < 0 )\n\t\t{\n\t\t\tlod = 0;\n\t\t}\n\t\telse if ( lod >= tr.currentModel->numLods )\n\t\t{\n\t\t\tlod = tr.currentModel->numLods - 1;\n\t\t}\n\t}\n\n\tlod += r_lodbias->integer;\n\t\n\tif ( lod >= tr.currentModel->numLods )\n\t\tlod = tr.currentModel->numLods - 1;\n\tif ( lod < 0 )\n\t\tlod = 0;\n\n\treturn lod;\n}\n\n/*\n=================\nR_ComputeFogNum\n\n=================\n*/\nint R_ComputeFogNum( md3Header_t *header, trRefEntity_t *ent ) {\n\tint\t\t\t\ti, j;\n\tfog_t\t\t\t*fog;\n\tmd3Frame_t\t\t*md3Frame;\n\tvec3_t\t\t\tlocalOrigin;\n\n\tif ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) {\n\t\treturn 0;\n\t}\n\n\t// FIXME: non-normalized axis issues\n\tmd3Frame = ( md3Frame_t * ) ( ( byte * ) header + header->ofsFrames ) + ent->e.frame;\n\tVectorAdd( ent->e.origin, md3Frame->localOrigin, localOrigin );\n\tfor ( i = 1 ; i < tr.world->numfogs ; i++ ) {\n\t\tfog = &tr.world->fogs[i];\n\t\tfor ( j = 0 ; j < 3 ; j++ ) {\n\t\t\tif ( localOrigin[j] - md3Frame->radius >= fog->bounds[1][j] ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( localOrigin[j] + md3Frame->radius <= fog->bounds[0][j] ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif ( j == 3 ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\n/*\n=================\nR_AddMD3Surfaces\n\n=================\n*/\nvoid R_AddMD3Surfaces( trRefEntity_t *ent ) {\n\tint\t\t\t\ti;\n\tmd3Header_t\t\t*header = 0;\n\tmd3Surface_t\t*surface = 0;\n\tmd3Shader_t\t\t*md3Shader = 0;\n\tshader_t\t\t*shader = 0;\n\tint\t\t\t\tcull;\n\tint\t\t\t\tlod;\n\tint\t\t\t\tfogNum;\n\tqboolean\t\tpersonalModel;\n\n\t// don't add third_person objects if not in a portal\n\tpersonalModel = (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal;\n\n\tif ( ent->e.renderfx & RF_WRAP_FRAMES ) {\n\t\tent->e.frame %= tr.currentModel->md3[0]->numFrames;\n\t\tent->e.oldframe %= tr.currentModel->md3[0]->numFrames;\n\t}\n\n\t//\n\t// Validate the frames so there is no chance of a crash.\n\t// This will write directly into the entity structure, so\n\t// when the surfaces are rendered, they don't need to be\n\t// range checked again.\n\t//\n\tif ( (ent->e.frame >= tr.currentModel->md3[0]->numFrames) \n\t\t|| (ent->e.frame < 0)\n\t\t|| (ent->e.oldframe >= tr.currentModel->md3[0]->numFrames)\n\t\t|| (ent->e.oldframe < 0) ) {\n\t\t\tri.Printf( PRINT_DEVELOPER, \"R_AddMD3Surfaces: no such frame %d to %d for '%s'\\n\",\n\t\t\t\tent->e.oldframe, ent->e.frame,\n\t\t\t\ttr.currentModel->name );\n\t\t\tent->e.frame = 0;\n\t\t\tent->e.oldframe = 0;\n\t}\n\n\t//\n\t// compute LOD\n\t//\n\tlod = R_ComputeLOD( ent );\n\n\theader = tr.currentModel->md3[lod];\n\n\t//\n\t// cull the entire model if merged bounding box of both frames\n\t// is outside the view frustum.\n\t//\n\tcull = R_CullModel ( header, ent );\n\tif ( cull == CULL_OUT ) {\n\t\treturn;\n\t}\n\n\t//\n\t// set up lighting now that we know we aren't culled\n\t//\n\tif ( !personalModel || r_shadows->integer > 1 ) {\n\t\tR_SetupEntityLighting( &tr.refdef, ent );\n\t}\n\n\t//\n\t// see if we are in a fog volume\n\t//\n\tfogNum = R_ComputeFogNum( header, ent );\n\n\t//\n\t// draw all surfaces\n\t//\n\tsurface = (md3Surface_t *)( (byte *)header + header->ofsSurfaces );\n\tfor ( i = 0 ; i < header->numSurfaces ; i++ ) {\n\n\t\tif ( ent->e.customShader ) {\n\t\t\tshader = R_GetShaderByHandle( ent->e.customShader );\n\t\t} else if ( ent->e.customSkin > 0 && ent->e.customSkin < tr.numSkins ) {\n\t\t\tskin_t *skin;\n\t\t\tint\t\tj;\n\n\t\t\tskin = R_GetSkinByHandle( ent->e.customSkin );\n\n\t\t\t// match the surface name to something in the skin file\n\t\t\tshader = tr.defaultShader;\n\t\t\tfor ( j = 0 ; j < skin->numSurfaces ; j++ ) {\n\t\t\t\t// the names have both been lowercased\n\t\t\t\tif ( !strcmp( skin->surfaces[j]->name, surface->name ) ) {\n\t\t\t\t\tshader = skin->surfaces[j]->shader;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (shader == tr.defaultShader) {\n\t\t\t\tri.Printf( PRINT_DEVELOPER, \"WARNING: no shader for surface %s in skin %s\\n\", surface->name, skin->name);\n\t\t\t}\n\t\t\telse if (shader->defaultShader) {\n\t\t\t\tri.Printf( PRINT_DEVELOPER, \"WARNING: shader %s in skin %s not found\\n\", shader->name, skin->name);\n\t\t\t}\n\t\t} else if ( surface->numShaders <= 0 ) {\n\t\t\tshader = tr.defaultShader;\n\t\t} else {\n\t\t\tmd3Shader = (md3Shader_t *) ( (byte *)surface + surface->ofsShaders );\n\t\t\tmd3Shader += ent->e.skinNum % surface->numShaders;\n\t\t\tshader = tr.shaders[ md3Shader->shaderIndex ];\n\t\t}\n\n\n\t\t// we will add shadows even if the main object isn't visible in the view\n\n\t\t// stencil shadows can't do personal models unless I polyhedron clip\n\t\tif ( !personalModel\n\t\t\t&& r_shadows->integer == 2 \n\t\t\t&& fogNum == 0\n\t\t\t&& !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) \n\t\t\t&& shader->sort == SS_OPAQUE ) {\n\t\t\tR_AddDrawSurf( (void *)surface, tr.shadowShader, 0, qfalse );\n\t\t}\n\n\t\t// projection shadows work fine with personal models\n\t\tif ( r_shadows->integer == 3\n\t\t\t&& fogNum == 0\n\t\t\t&& (ent->e.renderfx & RF_SHADOW_PLANE )\n\t\t\t&& shader->sort == SS_OPAQUE ) {\n\t\t\tR_AddDrawSurf( (void *)surface, tr.projectionShadowShader, 0, qfalse );\n\t\t}\n\n\t\t// don't add third_person objects if not viewing through a portal\n\t\tif ( !personalModel ) {\n\t\t\tR_AddDrawSurf( (void *)surface, shader, fogNum, qfalse );\n\t\t}\n\n\t\tsurface = (md3Surface_t *)( (byte *)surface + surface->ofsEnd );\n\t}\n\n}\n\n"
  },
  {
    "path": "code/renderer/tr_model.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// tr_models.c -- model loading and caching\n\n#include \"tr_local.h\"\n\n#define\tLL(x) x=LittleLong(x)\n\nstatic qboolean R_LoadMD3 (model_t *mod, int lod, void *buffer, const char *name );\nstatic qboolean R_LoadMD4 (model_t *mod, void *buffer, const char *name );\n\nmodel_t\t*loadmodel;\n\n/*\n** R_GetModelByHandle\n*/\nmodel_t\t*R_GetModelByHandle( qhandle_t index ) {\n\tmodel_t\t\t*mod;\n\n\t// out of range gets the defualt model\n\tif ( index < 1 || index >= tr.numModels ) {\n\t\treturn tr.models[0];\n\t}\n\n\tmod = tr.models[index];\n\n\treturn mod;\n}\n\n//===============================================================================\n\n/*\n** R_AllocModel\n*/\nmodel_t *R_AllocModel( void ) {\n\tmodel_t\t\t*mod;\n\n\tif ( tr.numModels == MAX_MOD_KNOWN ) {\n\t\treturn NULL;\n\t}\n\n\tmod = ri.Hunk_Alloc( sizeof( *tr.models[tr.numModels] ), h_low );\n\tmod->index = tr.numModels;\n\ttr.models[tr.numModels] = mod;\n\ttr.numModels++;\n\n\treturn mod;\n}\n\n/*\n====================\nRE_RegisterModel\n\nLoads in a model for the given name\n\nZero will be returned if the model fails to load.\nAn entry will be retained for failed models as an\noptimization to prevent disk rescanning if they are\nasked for again.\n====================\n*/\nqhandle_t RE_RegisterModel( const char *name ) {\n\tmodel_t\t\t*mod;\n\tunsigned\t*buf;\n\tint\t\t\tlod;\n\tint\t\t\tident;\n\tqboolean\tloaded;\n\tqhandle_t\thModel;\n\tint\t\t\tnumLoaded;\n\n\tif ( !name || !name[0] ) {\n\t\tri.Printf( PRINT_ALL, \"RE_RegisterModel: NULL name\\n\" );\n\t\treturn 0;\n\t}\n\n\tif ( strlen( name ) >= MAX_QPATH ) {\n\t\tCom_Printf( \"Model name exceeds MAX_QPATH\\n\" );\n\t\treturn 0;\n\t}\n\n\t//\n\t// search the currently loaded models\n\t//\n\tfor ( hModel = 1 ; hModel < tr.numModels; hModel++ ) {\n\t\tmod = tr.models[hModel];\n\t\tif ( !strcmp( mod->name, name ) ) {\n\t\t\tif( mod->type == MOD_BAD ) {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\treturn hModel;\n\t\t}\n\t}\n\n\t// allocate a new model_t\n\n\tif ( ( mod = R_AllocModel() ) == NULL ) {\n\t\tri.Printf( PRINT_WARNING, \"RE_RegisterModel: R_AllocModel() failed for '%s'\\n\", name);\n\t\treturn 0;\n\t}\n\n\t// only set the name after the model has been successfully loaded\n\tQ_strncpyz( mod->name, name, sizeof( mod->name ) );\n\n\n\t// make sure the render thread is stopped\n\tR_SyncRenderThread();\n\n\tmod->numLods = 0;\n\n\t//\n\t// load the files\n\t//\n\tnumLoaded = 0;\n\n\tfor ( lod = MD3_MAX_LODS - 1 ; lod >= 0 ; lod-- ) {\n\t\tchar filename[1024];\n\n\t\tstrcpy( filename, name );\n\n\t\tif ( lod != 0 ) {\n\t\t\tchar namebuf[80];\n\n\t\t\tif ( strrchr( filename, '.' ) ) {\n\t\t\t\t*strrchr( filename, '.' ) = 0;\n\t\t\t}\n\t\t\tsprintf( namebuf, \"_%d.md3\", lod );\n\t\t\tstrcat( filename, namebuf );\n\t\t}\n\n\t\tri.FS_ReadFile( filename, (void **)&buf );\n\t\tif ( !buf ) {\n\t\t\tcontinue;\n\t\t}\n\t\t\n\t\tloadmodel = mod;\n\t\t\n\t\tident = LittleLong(*(unsigned *)buf);\n\t\tif ( ident == MD4_IDENT ) {\n\t\t\tloaded = R_LoadMD4( mod, buf, name );\n\t\t} else {\n\t\t\tif ( ident != MD3_IDENT ) {\n\t\t\t\tri.Printf (PRINT_WARNING,\"RE_RegisterModel: unknown fileid for %s\\n\", name);\n\t\t\t\tgoto fail;\n\t\t\t}\n\n\t\t\tloaded = R_LoadMD3( mod, lod, buf, name );\n\t\t}\n\t\t\n\t\tri.FS_FreeFile (buf);\n\n\t\tif ( !loaded ) {\n\t\t\tif ( lod == 0 ) {\n\t\t\t\tgoto fail;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else {\n\t\t\tmod->numLods++;\n\t\t\tnumLoaded++;\n\t\t\t// if we have a valid model and are biased\n\t\t\t// so that we won't see any higher detail ones,\n\t\t\t// stop loading them\n//\t\t\tif ( lod <= r_lodbias->integer ) {\n//\t\t\t\tbreak;\n//\t\t\t}\n\t\t}\n\t}\n\n\tif ( numLoaded ) {\n\t\t// duplicate into higher lod spots that weren't\n\t\t// loaded, in case the user changes r_lodbias on the fly\n\t\tfor ( lod-- ; lod >= 0 ; lod-- ) {\n\t\t\tmod->numLods++;\n\t\t\tmod->md3[lod] = mod->md3[lod+1];\n\t\t}\n\n\t\treturn mod->index;\n\t}\n#ifdef _DEBUG\n\telse {\n\t\tri.Printf (PRINT_WARNING,\"RE_RegisterModel: couldn't load %s\\n\", name);\n\t}\n#endif\n\nfail:\n\t// we still keep the model_t around, so if the model name is asked for\n\t// again, we won't bother scanning the filesystem\n\tmod->type = MOD_BAD;\n\treturn 0;\n}\n\n\n/*\n=================\nR_LoadMD3\n=================\n*/\nstatic qboolean R_LoadMD3 (model_t *mod, int lod, void *buffer, const char *mod_name ) {\n\tint\t\t\t\t\ti, j;\n\tmd3Header_t\t\t\t*pinmodel;\n    md3Frame_t\t\t\t*frame;\n\tmd3Surface_t\t\t*surf;\n\tmd3Shader_t\t\t\t*shader;\n\tmd3Triangle_t\t\t*tri;\n\tmd3St_t\t\t\t\t*st;\n\tmd3XyzNormal_t\t\t*xyz;\n\tmd3Tag_t\t\t\t*tag;\n\tint\t\t\t\t\tversion;\n\tint\t\t\t\t\tsize;\n\n\tpinmodel = (md3Header_t *)buffer;\n\n\tversion = LittleLong (pinmodel->version);\n\tif (version != MD3_VERSION) {\n\t\tri.Printf( PRINT_WARNING, \"R_LoadMD3: %s has wrong version (%i should be %i)\\n\",\n\t\t\t\t mod_name, version, MD3_VERSION);\n\t\treturn qfalse;\n\t}\n\n\tmod->type = MOD_MESH;\n\tsize = LittleLong(pinmodel->ofsEnd);\n\tmod->dataSize += size;\n\tmod->md3[lod] = ri.Hunk_Alloc( size, h_low );\n\n\tCom_Memcpy (mod->md3[lod], buffer, LittleLong(pinmodel->ofsEnd) );\n\n    LL(mod->md3[lod]->ident);\n    LL(mod->md3[lod]->version);\n    LL(mod->md3[lod]->numFrames);\n    LL(mod->md3[lod]->numTags);\n    LL(mod->md3[lod]->numSurfaces);\n    LL(mod->md3[lod]->ofsFrames);\n    LL(mod->md3[lod]->ofsTags);\n    LL(mod->md3[lod]->ofsSurfaces);\n    LL(mod->md3[lod]->ofsEnd);\n\n\tif ( mod->md3[lod]->numFrames < 1 ) {\n\t\tri.Printf( PRINT_WARNING, \"R_LoadMD3: %s has no frames\\n\", mod_name );\n\t\treturn qfalse;\n\t}\n    \n\t// swap all the frames\n    frame = (md3Frame_t *) ( (byte *)mod->md3[lod] + mod->md3[lod]->ofsFrames );\n    for ( i = 0 ; i < mod->md3[lod]->numFrames ; i++, frame++) {\n    \tframe->radius = LittleFloat( frame->radius );\n        for ( j = 0 ; j < 3 ; j++ ) {\n            frame->bounds[0][j] = LittleFloat( frame->bounds[0][j] );\n            frame->bounds[1][j] = LittleFloat( frame->bounds[1][j] );\n\t    \tframe->localOrigin[j] = LittleFloat( frame->localOrigin[j] );\n        }\n\t}\n\n\t// swap all the tags\n    tag = (md3Tag_t *) ( (byte *)mod->md3[lod] + mod->md3[lod]->ofsTags );\n    for ( i = 0 ; i < mod->md3[lod]->numTags * mod->md3[lod]->numFrames ; i++, tag++) {\n        for ( j = 0 ; j < 3 ; j++ ) {\n\t\t\ttag->origin[j] = LittleFloat( tag->origin[j] );\n\t\t\ttag->axis[0][j] = LittleFloat( tag->axis[0][j] );\n\t\t\ttag->axis[1][j] = LittleFloat( tag->axis[1][j] );\n\t\t\ttag->axis[2][j] = LittleFloat( tag->axis[2][j] );\n        }\n\t}\n\n\t// swap all the surfaces\n\tsurf = (md3Surface_t *) ( (byte *)mod->md3[lod] + mod->md3[lod]->ofsSurfaces );\n\tfor ( i = 0 ; i < mod->md3[lod]->numSurfaces ; i++) {\n\n        LL(surf->ident);\n        LL(surf->flags);\n        LL(surf->numFrames);\n        LL(surf->numShaders);\n        LL(surf->numTriangles);\n        LL(surf->ofsTriangles);\n        LL(surf->numVerts);\n        LL(surf->ofsShaders);\n        LL(surf->ofsSt);\n        LL(surf->ofsXyzNormals);\n        LL(surf->ofsEnd);\n\t\t\n\t\tif ( surf->numVerts > SHADER_MAX_VERTEXES ) {\n\t\t\tri.Error (ERR_DROP, \"R_LoadMD3: %s has more than %i verts on a surface (%i)\",\n\t\t\t\tmod_name, SHADER_MAX_VERTEXES, surf->numVerts );\n\t\t}\n\t\tif ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) {\n\t\t\tri.Error (ERR_DROP, \"R_LoadMD3: %s has more than %i triangles on a surface (%i)\",\n\t\t\t\tmod_name, SHADER_MAX_INDEXES / 3, surf->numTriangles );\n\t\t}\n\t\n\t\t// change to surface identifier\n\t\tsurf->ident = SF_MD3;\n\n\t\t// lowercase the surface name so skin compares are faster\n\t\tQ_strlwr( surf->name );\n\n\t\t// strip off a trailing _1 or _2\n\t\t// this is a crutch for q3data being a mess\n\t\tj = strlen( surf->name );\n\t\tif ( j > 2 && surf->name[j-2] == '_' ) {\n\t\t\tsurf->name[j-2] = 0;\n\t\t}\n\n        // register the shaders\n        shader = (md3Shader_t *) ( (byte *)surf + surf->ofsShaders );\n        for ( j = 0 ; j < surf->numShaders ; j++, shader++ ) {\n            shader_t\t*sh;\n\n            sh = R_FindShader( shader->name, LIGHTMAP_NONE, qtrue );\n\t\t\tif ( sh->defaultShader ) {\n\t\t\t\tshader->shaderIndex = 0;\n\t\t\t} else {\n\t\t\t\tshader->shaderIndex = sh->index;\n\t\t\t}\n        }\n\n\t\t// swap all the triangles\n\t\ttri = (md3Triangle_t *) ( (byte *)surf + surf->ofsTriangles );\n\t\tfor ( j = 0 ; j < surf->numTriangles ; j++, tri++ ) {\n\t\t\tLL(tri->indexes[0]);\n\t\t\tLL(tri->indexes[1]);\n\t\t\tLL(tri->indexes[2]);\n\t\t}\n\n\t\t// swap all the ST\n        st = (md3St_t *) ( (byte *)surf + surf->ofsSt );\n        for ( j = 0 ; j < surf->numVerts ; j++, st++ ) {\n            st->st[0] = LittleFloat( st->st[0] );\n            st->st[1] = LittleFloat( st->st[1] );\n        }\n\n\t\t// swap all the XyzNormals\n        xyz = (md3XyzNormal_t *) ( (byte *)surf + surf->ofsXyzNormals );\n        for ( j = 0 ; j < surf->numVerts * surf->numFrames ; j++, xyz++ ) \n\t\t{\n            xyz->xyz[0] = LittleShort( xyz->xyz[0] );\n            xyz->xyz[1] = LittleShort( xyz->xyz[1] );\n            xyz->xyz[2] = LittleShort( xyz->xyz[2] );\n\n            xyz->normal = LittleShort( xyz->normal );\n        }\n\n\n\t\t// find the next surface\n\t\tsurf = (md3Surface_t *)( (byte *)surf + surf->ofsEnd );\n\t}\n    \n\treturn qtrue;\n}\n\n\n\n/*\n=================\nR_LoadMD4\n=================\n*/\nstatic qboolean R_LoadMD4( model_t *mod, void *buffer, const char *mod_name ) {\n\tint\t\t\t\t\ti, j, k, lodindex;\n\tmd4Header_t\t\t\t*pinmodel, *md4;\n    md4Frame_t\t\t\t*frame;\n\tmd4LOD_t\t\t\t*lod;\n\tmd4Surface_t\t\t*surf;\n\tmd4Triangle_t\t\t*tri;\n\tmd4Vertex_t\t\t\t*v;\n\tint\t\t\t\t\tversion;\n\tint\t\t\t\t\tsize;\n\tshader_t\t\t\t*sh;\n\tint\t\t\t\t\tframeSize;\n\n\tpinmodel = (md4Header_t *)buffer;\n\n\tversion = LittleLong (pinmodel->version);\n\tif (version != MD4_VERSION) {\n\t\tri.Printf( PRINT_WARNING, \"R_LoadMD4: %s has wrong version (%i should be %i)\\n\",\n\t\t\t\t mod_name, version, MD4_VERSION);\n\t\treturn qfalse;\n\t}\n\n\tmod->type = MOD_MD4;\n\tsize = LittleLong(pinmodel->ofsEnd);\n\tmod->dataSize += size;\n\tmd4 = mod->md4 = ri.Hunk_Alloc( size, h_low );\n\n\tCom_Memcpy( md4, buffer, LittleLong(pinmodel->ofsEnd) );\n\n    LL(md4->ident);\n    LL(md4->version);\n    LL(md4->numFrames);\n    LL(md4->numBones);\n    LL(md4->numLODs);\n    LL(md4->ofsFrames);\n    LL(md4->ofsLODs);\n    LL(md4->ofsEnd);\n\n\tif ( md4->numFrames < 1 ) {\n\t\tri.Printf( PRINT_WARNING, \"R_LoadMD4: %s has no frames\\n\", mod_name );\n\t\treturn qfalse;\n\t}\n\n    // we don't need to swap tags in the renderer, they aren't used\n    \n\t// swap all the frames\n\tframeSize = (int)( &((md4Frame_t *)0)->bones[ md4->numBones ] );\n    for ( i = 0 ; i < md4->numFrames ; i++, frame++) {\n\t    frame = (md4Frame_t *) ( (byte *)md4 + md4->ofsFrames + i * frameSize );\n    \tframe->radius = LittleFloat( frame->radius );\n        for ( j = 0 ; j < 3 ; j++ ) {\n            frame->bounds[0][j] = LittleFloat( frame->bounds[0][j] );\n            frame->bounds[1][j] = LittleFloat( frame->bounds[1][j] );\n\t    \tframe->localOrigin[j] = LittleFloat( frame->localOrigin[j] );\n        }\n\t\tfor ( j = 0 ; j < md4->numBones * sizeof( md4Bone_t ) / 4 ; j++ ) {\n\t\t\t((float *)frame->bones)[j] = LittleFloat( ((float *)frame->bones)[j] );\n\t\t}\n\t}\n\n\t// swap all the LOD's\n\tlod = (md4LOD_t *) ( (byte *)md4 + md4->ofsLODs );\n\tfor ( lodindex = 0 ; lodindex < md4->numLODs ; lodindex++ ) {\n\n\t\t// swap all the surfaces\n\t\tsurf = (md4Surface_t *) ( (byte *)lod + lod->ofsSurfaces );\n\t\tfor ( i = 0 ; i < lod->numSurfaces ; i++) {\n\t\t\tLL(surf->ident);\n\t\t\tLL(surf->numTriangles);\n\t\t\tLL(surf->ofsTriangles);\n\t\t\tLL(surf->numVerts);\n\t\t\tLL(surf->ofsVerts);\n\t\t\tLL(surf->ofsEnd);\n\t\t\t\n\t\t\tif ( surf->numVerts > SHADER_MAX_VERTEXES ) {\n\t\t\t\tri.Error (ERR_DROP, \"R_LoadMD3: %s has more than %i verts on a surface (%i)\",\n\t\t\t\t\tmod_name, SHADER_MAX_VERTEXES, surf->numVerts );\n\t\t\t}\n\t\t\tif ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) {\n\t\t\t\tri.Error (ERR_DROP, \"R_LoadMD3: %s has more than %i triangles on a surface (%i)\",\n\t\t\t\t\tmod_name, SHADER_MAX_INDEXES / 3, surf->numTriangles );\n\t\t\t}\n\n\t\t\t// change to surface identifier\n\t\t\tsurf->ident = SF_MD4;\n\n\t\t\t// lowercase the surface name so skin compares are faster\n\t\t\tQ_strlwr( surf->name );\n\t\t\n\t\t\t// register the shaders\n\t\t\tsh = R_FindShader( surf->shader, LIGHTMAP_NONE, qtrue );\n\t\t\tif ( sh->defaultShader ) {\n\t\t\t\tsurf->shaderIndex = 0;\n\t\t\t} else {\n\t\t\t\tsurf->shaderIndex = sh->index;\n\t\t\t}\n\n\t\t\t// swap all the triangles\n\t\t\ttri = (md4Triangle_t *) ( (byte *)surf + surf->ofsTriangles );\n\t\t\tfor ( j = 0 ; j < surf->numTriangles ; j++, tri++ ) {\n\t\t\t\tLL(tri->indexes[0]);\n\t\t\t\tLL(tri->indexes[1]);\n\t\t\t\tLL(tri->indexes[2]);\n\t\t\t}\n\n\t\t\t// swap all the vertexes\n\t\t\t// FIXME\n\t\t\t// This makes TFC's skeletons work.  Shouldn't be necessary anymore, but left\n\t\t\t// in for reference.\n\t\t\t//v = (md4Vertex_t *) ( (byte *)surf + surf->ofsVerts + 12);\n\t\t\tv = (md4Vertex_t *) ( (byte *)surf + surf->ofsVerts);\n\t\t\tfor ( j = 0 ; j < surf->numVerts ; j++ ) {\n\t\t\t\tv->normal[0] = LittleFloat( v->normal[0] );\n\t\t\t\tv->normal[1] = LittleFloat( v->normal[1] );\n\t\t\t\tv->normal[2] = LittleFloat( v->normal[2] );\n\n\t\t\t\tv->texCoords[0] = LittleFloat( v->texCoords[0] );\n\t\t\t\tv->texCoords[1] = LittleFloat( v->texCoords[1] );\n\n\t\t\t\tv->numWeights = LittleLong( v->numWeights );\n\n\t\t\t\tfor ( k = 0 ; k < v->numWeights ; k++ ) {\n\t\t\t\t\tv->weights[k].boneIndex = LittleLong( v->weights[k].boneIndex );\n\t\t\t\t\tv->weights[k].boneWeight = LittleFloat( v->weights[k].boneWeight );\n\t\t\t\t   v->weights[k].offset[0] = LittleFloat( v->weights[k].offset[0] );\n\t\t\t\t   v->weights[k].offset[1] = LittleFloat( v->weights[k].offset[1] );\n\t\t\t\t   v->weights[k].offset[2] = LittleFloat( v->weights[k].offset[2] );\n\t\t\t\t}\n\t\t\t\t// FIXME\n\t\t\t\t// This makes TFC's skeletons work.  Shouldn't be necessary anymore, but left\n\t\t\t\t// in for reference.\n\t\t\t\t//v = (md4Vertex_t *)( ( byte * )&v->weights[v->numWeights] + 12 );\n\t\t\t\tv = (md4Vertex_t *)( ( byte * )&v->weights[v->numWeights]);\n\t\t\t}\n\n\t\t\t// find the next surface\n\t\t\tsurf = (md4Surface_t *)( (byte *)surf + surf->ofsEnd );\n\t\t}\n\n\t\t// find the next LOD\n\t\tlod = (md4LOD_t *)( (byte *)lod + lod->ofsEnd );\n\t}\n\n\treturn qtrue;\n}\n\n\n\n\n//=============================================================================\n\n/*\n** RE_BeginRegistration\n*/\nvoid RE_BeginRegistration( glconfig_t *glconfigOut ) {\n\n\tR_Init();\n\n\t*glconfigOut = glConfig;\n\n\tR_SyncRenderThread();\n\n\ttr.viewCluster = -1;\t\t// force markleafs to regenerate\n\tR_ClearFlares();\n\tRE_ClearScene();\n\n\ttr.registered = qtrue;\n\n\t// NOTE: this sucks, for some reason the first stretch pic is never drawn\n\t// without this we'd see a white flash on a level load because the very\n\t// first time the level shot would not be drawn\n\tRE_StretchPic(0, 0, 0, 0, 0, 0, 1, 1, 0);\n}\n\n//=============================================================================\n\n/*\n===============\nR_ModelInit\n===============\n*/\nvoid R_ModelInit( void ) {\n\tmodel_t\t\t*mod;\n\n\t// leave a space for NULL model\n\ttr.numModels = 0;\n\n\tmod = R_AllocModel();\n\tmod->type = MOD_BAD;\n}\n\n\n/*\n================\nR_Modellist_f\n================\n*/\nvoid R_Modellist_f( void ) {\n\tint\t\ti, j;\n\tmodel_t\t*mod;\n\tint\t\ttotal;\n\tint\t\tlods;\n\n\ttotal = 0;\n\tfor ( i = 1 ; i < tr.numModels; i++ ) {\n\t\tmod = tr.models[i];\n\t\tlods = 1;\n\t\tfor ( j = 1 ; j < MD3_MAX_LODS ; j++ ) {\n\t\t\tif ( mod->md3[j] && mod->md3[j] != mod->md3[j-1] ) {\n\t\t\t\tlods++;\n\t\t\t}\n\t\t}\n\t\tri.Printf( PRINT_ALL, \"%8i : (%i) %s\\n\",mod->dataSize, lods, mod->name );\n\t\ttotal += mod->dataSize;\n\t}\n\tri.Printf( PRINT_ALL, \"%8i : Total models\\n\", total );\n\n#if\t0\t\t// not working right with new hunk\n\tif ( tr.world ) {\n\t\tri.Printf( PRINT_ALL, \"\\n%8i : %s\\n\", tr.world->dataSize, tr.world->name );\n\t}\n#endif\n}\n\n\n//=============================================================================\n\n\n/*\n================\nR_GetTag\n================\n*/\nstatic md3Tag_t *R_GetTag( md3Header_t *mod, int frame, const char *tagName ) {\n\tmd3Tag_t\t\t*tag;\n\tint\t\t\t\ti;\n\n\tif ( frame >= mod->numFrames ) {\n\t\t// it is possible to have a bad frame while changing models, so don't error\n\t\tframe = mod->numFrames - 1;\n\t}\n\n\ttag = (md3Tag_t *)((byte *)mod + mod->ofsTags) + frame * mod->numTags;\n\tfor ( i = 0 ; i < mod->numTags ; i++, tag++ ) {\n\t\tif ( !strcmp( tag->name, tagName ) ) {\n\t\t\treturn tag;\t// found it\n\t\t}\n\t}\n\n\treturn NULL;\n}\n\n/*\n================\nR_LerpTag\n================\n*/\nint R_LerpTag( orientation_t *tag, qhandle_t handle, int startFrame, int endFrame, \n\t\t\t\t\t float frac, const char *tagName ) {\n\tmd3Tag_t\t*start, *end;\n\tint\t\ti;\n\tfloat\t\tfrontLerp, backLerp;\n\tmodel_t\t\t*model;\n\n\tmodel = R_GetModelByHandle( handle );\n\tif ( !model->md3[0] ) {\n\t\tAxisClear( tag->axis );\n\t\tVectorClear( tag->origin );\n\t\treturn qfalse;\n\t}\n\n\tstart = R_GetTag( model->md3[0], startFrame, tagName );\n\tend = R_GetTag( model->md3[0], endFrame, tagName );\n\tif ( !start || !end ) {\n\t\tAxisClear( tag->axis );\n\t\tVectorClear( tag->origin );\n\t\treturn qfalse;\n\t}\n\n\tfrontLerp = frac;\n\tbackLerp = 1.0f - frac;\n\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\ttag->origin[i] = start->origin[i] * backLerp +  end->origin[i] * frontLerp;\n\t\ttag->axis[0][i] = start->axis[0][i] * backLerp +  end->axis[0][i] * frontLerp;\n\t\ttag->axis[1][i] = start->axis[1][i] * backLerp +  end->axis[1][i] * frontLerp;\n\t\ttag->axis[2][i] = start->axis[2][i] * backLerp +  end->axis[2][i] * frontLerp;\n\t}\n\tVectorNormalize( tag->axis[0] );\n\tVectorNormalize( tag->axis[1] );\n\tVectorNormalize( tag->axis[2] );\n\treturn qtrue;\n}\n\n\n/*\n====================\nR_ModelBounds\n====================\n*/\nvoid R_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs ) {\n\tmodel_t\t\t*model;\n\tmd3Header_t\t*header;\n\tmd3Frame_t\t*frame;\n\n\tmodel = R_GetModelByHandle( handle );\n\n\tif ( model->bmodel ) {\n\t\tVectorCopy( model->bmodel->bounds[0], mins );\n\t\tVectorCopy( model->bmodel->bounds[1], maxs );\n\t\treturn;\n\t}\n\n\tif ( !model->md3[0] ) {\n\t\tVectorClear( mins );\n\t\tVectorClear( maxs );\n\t\treturn;\n\t}\n\n\theader = model->md3[0];\n\n\tframe = (md3Frame_t *)( (byte *)header + header->ofsFrames );\n\n\tVectorCopy( frame->bounds[0], mins );\n\tVectorCopy( frame->bounds[1], maxs );\n}\n"
  },
  {
    "path": "code/renderer/tr_noise.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// tr_noise.c\n#include \"tr_local.h\"\n\n#define NOISE_SIZE 256\n#define NOISE_MASK ( NOISE_SIZE - 1 )\n\n#define VAL( a ) s_noise_perm[ ( a ) & ( NOISE_MASK )]\n#define INDEX( x, y, z, t ) VAL( x + VAL( y + VAL( z + VAL( t ) ) ) )\n\nstatic float s_noise_table[NOISE_SIZE];\nstatic int s_noise_perm[NOISE_SIZE];\n\n#define LERP( a, b, w ) ( a * ( 1.0f - w ) + b * w )\n\nstatic float GetNoiseValue( int x, int y, int z, int t )\n{\n\tint index = INDEX( ( int ) x, ( int ) y, ( int ) z, ( int ) t );\n\n\treturn s_noise_table[index];\n}\n\nvoid R_NoiseInit( void )\n{\n\tint i;\n\n\tsrand( 1001 );\n\n\tfor ( i = 0; i < NOISE_SIZE; i++ )\n\t{\n\t\ts_noise_table[i] = ( float ) ( ( ( rand() / ( float ) RAND_MAX ) * 2.0 - 1.0 ) );\n\t\ts_noise_perm[i] = ( unsigned char ) ( rand() / ( float ) RAND_MAX * 255 );\n\t}\n}\n\nfloat R_NoiseGet4f( float x, float y, float z, float t )\n{\n\tint i;\n\tint ix, iy, iz, it;\n\tfloat fx, fy, fz, ft;\n\tfloat front[4];\n\tfloat back[4];\n\tfloat fvalue, bvalue, value[2], finalvalue;\n\n\tix = ( int ) floor( x );\n\tfx = x - ix;\n\tiy = ( int ) floor( y );\n\tfy = y - iy;\n\tiz = ( int ) floor( z );\n\tfz = z - iz;\n\tit = ( int ) floor( t );\n\tft = t - it;\n\n\tfor ( i = 0; i < 2; i++ )\n\t{\n\t\tfront[0] = GetNoiseValue( ix, iy, iz, it + i );\n\t\tfront[1] = GetNoiseValue( ix+1, iy, iz, it + i );\n\t\tfront[2] = GetNoiseValue( ix, iy+1, iz, it + i );\n\t\tfront[3] = GetNoiseValue( ix+1, iy+1, iz, it + i );\n\n\t\tback[0] = GetNoiseValue( ix, iy, iz + 1, it + i );\n\t\tback[1] = GetNoiseValue( ix+1, iy, iz + 1, it + i );\n\t\tback[2] = GetNoiseValue( ix, iy+1, iz + 1, it + i );\n\t\tback[3] = GetNoiseValue( ix+1, iy+1, iz + 1, it + i );\n\n\t\tfvalue = LERP( LERP( front[0], front[1], fx ), LERP( front[2], front[3], fx ), fy );\n\t\tbvalue = LERP( LERP( back[0], back[1], fx ), LERP( back[2], back[3], fx ), fy );\n\n\t\tvalue[i] = LERP( fvalue, bvalue, fz );\n\t}\n\n\tfinalvalue = LERP( value[0], value[1], ft );\n\n\treturn finalvalue;\n}\n"
  },
  {
    "path": "code/renderer/tr_public.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __TR_PUBLIC_H\n#define __TR_PUBLIC_H\n\n#include \"../cgame/tr_types.h\"\n\n#define\tREF_API_VERSION\t\t8\n\n//\n// these are the functions exported by the refresh module\n//\ntypedef struct {\n\t// called before the library is unloaded\n\t// if the system is just reconfiguring, pass destroyWindow = qfalse,\n\t// which will keep the screen from flashing to the desktop.\n\tvoid\t(*Shutdown)( qboolean destroyWindow );\n\n\t// All data that will be used in a level should be\n\t// registered before rendering any frames to prevent disk hits,\n\t// but they can still be registered at a later time\n\t// if necessary.\n\t//\n\t// BeginRegistration makes any existing media pointers invalid\n\t// and returns the current gl configuration, including screen width\n\t// and height, which can be used by the client to intelligently\n\t// size display elements\n\tvoid\t(*BeginRegistration)( glconfig_t *config );\n\tqhandle_t (*RegisterModel)( const char *name );\n\tqhandle_t (*RegisterSkin)( const char *name );\n\tqhandle_t (*RegisterShader)( const char *name );\n\tqhandle_t (*RegisterShaderNoMip)( const char *name );\n\tvoid\t(*LoadWorld)( const char *name );\n\n\t// the vis data is a large enough block of data that we go to the trouble\n\t// of sharing it with the clipmodel subsystem\n\tvoid\t(*SetWorldVisData)( const byte *vis );\n\n\t// EndRegistration will draw a tiny polygon with each texture, forcing\n\t// them to be loaded into card memory\n\tvoid\t(*EndRegistration)( void );\n\n\t// a scene is built up by calls to R_ClearScene and the various R_Add functions.\n\t// Nothing is drawn until R_RenderScene is called.\n\tvoid\t(*ClearScene)( void );\n\tvoid\t(*AddRefEntityToScene)( const refEntity_t *re );\n\tvoid\t(*AddPolyToScene)( qhandle_t hShader , int numVerts, const polyVert_t *verts, int num );\n\tint\t\t(*LightForPoint)( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir );\n\tvoid\t(*AddLightToScene)( const vec3_t org, float intensity, float r, float g, float b );\n\tvoid\t(*AddAdditiveLightToScene)( const vec3_t org, float intensity, float r, float g, float b );\n\tvoid\t(*RenderScene)( const refdef_t *fd );\n\n\tvoid\t(*SetColor)( const float *rgba );\t// NULL = 1,1,1,1\n\tvoid\t(*DrawStretchPic) ( float x, float y, float w, float h, \n\t\tfloat s1, float t1, float s2, float t2, qhandle_t hShader );\t// 0 = white\n\n\t// Draw images for cinematic rendering, pass as 32 bit rgba\n\tvoid\t(*DrawStretchRaw) (int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty);\n\tvoid\t(*UploadCinematic) (int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty);\n\n\tvoid\t(*BeginFrame)( stereoFrame_t stereoFrame );\n\n\t// if the pointers are not NULL, timing info will be returned\n\tvoid\t(*EndFrame)( int *frontEndMsec, int *backEndMsec );\n\n\n\tint\t\t(*MarkFragments)( int numPoints, const vec3_t *points, const vec3_t projection,\n\t\t\t\t   int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer );\n\n\tint\t\t(*LerpTag)( orientation_t *tag,  qhandle_t model, int startFrame, int endFrame, \n\t\t\t\t\t float frac, const char *tagName );\n\tvoid\t(*ModelBounds)( qhandle_t model, vec3_t mins, vec3_t maxs );\n\n#ifdef __USEA3D\n\tvoid    (*A3D_RenderGeometry) (void *pVoidA3D, void *pVoidGeom, void *pVoidMat, void *pVoidGeomStatus);\n#endif\n\tvoid\t(*RegisterFont)(const char *fontName, int pointSize, fontInfo_t *font);\n\tvoid\t(*RemapShader)(const char *oldShader, const char *newShader, const char *offsetTime);\n\tqboolean (*GetEntityToken)( char *buffer, int size );\n\tqboolean (*inPVS)( const vec3_t p1, const vec3_t p2 );\n} refexport_t;\n\n//\n// these are the functions imported by the refresh module\n//\ntypedef struct {\n\t// print message on the local console\n\tvoid\t(QDECL *Printf)( int printLevel, const char *fmt, ...);\n\n\t// abort the game\n\tvoid\t(QDECL *Error)( int errorLevel, const char *fmt, ...);\n\n\t// milliseconds should only be used for profiling, never\n\t// for anything game related.  Get time from the refdef\n\tint\t\t(*Milliseconds)( void );\n\n\t// stack based memory allocation for per-level things that\n\t// won't be freed\n#ifdef HUNK_DEBUG\n\tvoid\t*(*Hunk_AllocDebug)( int size, ha_pref pref, char *label, char *file, int line );\n#else\n\tvoid\t*(*Hunk_Alloc)( int size, ha_pref pref );\n#endif\n\tvoid\t*(*Hunk_AllocateTempMemory)( int size );\n\tvoid\t(*Hunk_FreeTempMemory)( void *block );\n\n\t// dynamic memory allocator for things that need to be freed\n\tvoid\t*(*Malloc)( int bytes );\n\tvoid\t(*Free)( void *buf );\n\n\tcvar_t\t*(*Cvar_Get)( const char *name, const char *value, int flags );\n\tvoid\t(*Cvar_Set)( const char *name, const char *value );\n\n\tvoid\t(*Cmd_AddCommand)( const char *name, void(*cmd)(void) );\n\tvoid\t(*Cmd_RemoveCommand)( const char *name );\n\n\tint\t\t(*Cmd_Argc) (void);\n\tchar\t*(*Cmd_Argv) (int i);\n\n\tvoid\t(*Cmd_ExecuteText) (int exec_when, const char *text);\n\n\t// visualization for debugging collision detection\n\tvoid\t(*CM_DrawDebugSurface)( void (*drawPoly)(int color, int numPoints, float *points) );\n\n\t// a -1 return means the file does not exist\n\t// NULL can be passed for buf to just determine existance\n\tint\t\t(*FS_FileIsInPAK)( const char *name, int *pCheckSum );\n\tint\t\t(*FS_ReadFile)( const char *name, void **buf );\n\tvoid\t(*FS_FreeFile)( void *buf );\n\tchar **\t(*FS_ListFiles)( const char *name, const char *extension, int *numfilesfound );\n\tvoid\t(*FS_FreeFileList)( char **filelist );\n\tvoid\t(*FS_WriteFile)( const char *qpath, const void *buffer, int size );\n\tqboolean (*FS_FileExists)( const char *file );\n\n\t// cinematic stuff\n\tvoid\t(*CIN_UploadCinematic)(int handle);\n\tint\t\t(*CIN_PlayCinematic)( const char *arg0, int xpos, int ypos, int width, int height, int bits);\n\te_status (*CIN_RunCinematic) (int handle);\n\n} refimport_t;\n\n\n// this is the only function actually exported at the linker level\n// If the module can't init to a valid rendering state, NULL will be\n// returned.\nrefexport_t*GetRefAPI( int apiVersion, refimport_t *rimp );\n\n#endif\t// __TR_PUBLIC_H\n"
  },
  {
    "path": "code/renderer/tr_scene.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"tr_local.h\"\n\nint\t\t\tr_firstSceneDrawSurf;\n\nint\t\t\tr_numdlights;\nint\t\t\tr_firstSceneDlight;\n\nint\t\t\tr_numentities;\nint\t\t\tr_firstSceneEntity;\n\nint\t\t\tr_numpolys;\nint\t\t\tr_firstScenePoly;\n\nint\t\t\tr_numpolyverts;\n\n\n/*\n====================\nR_ToggleSmpFrame\n\n====================\n*/\nvoid R_ToggleSmpFrame( void ) {\n\tif ( r_smp->integer ) {\n\t\t// use the other buffers next frame, because another CPU\n\t\t// may still be rendering into the current ones\n\t\ttr.smpFrame ^= 1;\n\t} else {\n\t\ttr.smpFrame = 0;\n\t}\n\n\tbackEndData[tr.smpFrame]->commands.used = 0;\n\n\tr_firstSceneDrawSurf = 0;\n\n\tr_numdlights = 0;\n\tr_firstSceneDlight = 0;\n\n\tr_numentities = 0;\n\tr_firstSceneEntity = 0;\n\n\tr_numpolys = 0;\n\tr_firstScenePoly = 0;\n\n\tr_numpolyverts = 0;\n}\n\n\n/*\n====================\nRE_ClearScene\n\n====================\n*/\nvoid RE_ClearScene( void ) {\n\tr_firstSceneDlight = r_numdlights;\n\tr_firstSceneEntity = r_numentities;\n\tr_firstScenePoly = r_numpolys;\n}\n\n/*\n===========================================================================\n\nDISCRETE POLYS\n\n===========================================================================\n*/\n\n/*\n=====================\nR_AddPolygonSurfaces\n\nAdds all the scene's polys into this view's drawsurf list\n=====================\n*/\nvoid R_AddPolygonSurfaces( void ) {\n\tint\t\t\ti;\n\tshader_t\t*sh;\n\tsrfPoly_t\t*poly;\n\n\ttr.currentEntityNum = ENTITYNUM_WORLD;\n\ttr.shiftedEntityNum = tr.currentEntityNum << QSORT_ENTITYNUM_SHIFT;\n\n\tfor ( i = 0, poly = tr.refdef.polys; i < tr.refdef.numPolys ; i++, poly++ ) {\n\t\tsh = R_GetShaderByHandle( poly->hShader );\n\t\tR_AddDrawSurf( ( void * )poly, sh, poly->fogIndex, qfalse );\n\t}\n}\n\n/*\n=====================\nRE_AddPolyToScene\n\n=====================\n*/\nvoid RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys ) {\n\tsrfPoly_t\t*poly;\n\tint\t\t\ti, j;\n\tint\t\t\tfogIndex;\n\tfog_t\t\t*fog;\n\tvec3_t\t\tbounds[2];\n\n\tif ( !tr.registered ) {\n\t\treturn;\n\t}\n\n\tif ( !hShader ) {\n\t\tri.Printf( PRINT_WARNING, \"WARNING: RE_AddPolyToScene: NULL poly shader\\n\");\n\t\treturn;\n\t}\n\n\tfor ( j = 0; j < numPolys; j++ ) {\n\t\tif ( r_numpolyverts + numVerts > max_polyverts || r_numpolys >= max_polys ) {\n      /*\n      NOTE TTimo this was initially a PRINT_WARNING\n      but it happens a lot with high fighting scenes and particles\n      since we don't plan on changing the const and making for room for those effects\n      simply cut this message to developer only\n      */\n\t\t\tri.Printf( PRINT_DEVELOPER, \"WARNING: RE_AddPolyToScene: r_max_polys or r_max_polyverts reached\\n\");\n\t\t\treturn;\n\t\t}\n\n\t\tpoly = &backEndData[tr.smpFrame]->polys[r_numpolys];\n\t\tpoly->surfaceType = SF_POLY;\n\t\tpoly->hShader = hShader;\n\t\tpoly->numVerts = numVerts;\n\t\tpoly->verts = &backEndData[tr.smpFrame]->polyVerts[r_numpolyverts];\n\t\t\n\t\tCom_Memcpy( poly->verts, &verts[numVerts*j], numVerts * sizeof( *verts ) );\n\n\t\tif ( glConfig.hardwareType == GLHW_RAGEPRO ) {\n\t\t\tpoly->verts->modulate[0] = 255;\n\t\t\tpoly->verts->modulate[1] = 255;\n\t\t\tpoly->verts->modulate[2] = 255;\n\t\t\tpoly->verts->modulate[3] = 255;\n\t\t}\n\t\t// done.\n\t\tr_numpolys++;\n\t\tr_numpolyverts += numVerts;\n\n\t\t// if no world is loaded\n\t\tif ( tr.world == NULL ) {\n\t\t\tfogIndex = 0;\n\t\t}\n\t\t// see if it is in a fog volume\n\t\telse if ( tr.world->numfogs == 1 ) {\n\t\t\tfogIndex = 0;\n\t\t} else {\n\t\t\t// find which fog volume the poly is in\n\t\t\tVectorCopy( poly->verts[0].xyz, bounds[0] );\n\t\t\tVectorCopy( poly->verts[0].xyz, bounds[1] );\n\t\t\tfor ( i = 1 ; i < poly->numVerts ; i++ ) {\n\t\t\t\tAddPointToBounds( poly->verts[i].xyz, bounds[0], bounds[1] );\n\t\t\t}\n\t\t\tfor ( fogIndex = 1 ; fogIndex < tr.world->numfogs ; fogIndex++ ) {\n\t\t\t\tfog = &tr.world->fogs[fogIndex]; \n\t\t\t\tif ( bounds[1][0] >= fog->bounds[0][0]\n\t\t\t\t\t&& bounds[1][1] >= fog->bounds[0][1]\n\t\t\t\t\t&& bounds[1][2] >= fog->bounds[0][2]\n\t\t\t\t\t&& bounds[0][0] <= fog->bounds[1][0]\n\t\t\t\t\t&& bounds[0][1] <= fog->bounds[1][1]\n\t\t\t\t\t&& bounds[0][2] <= fog->bounds[1][2] ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( fogIndex == tr.world->numfogs ) {\n\t\t\t\tfogIndex = 0;\n\t\t\t}\n\t\t}\n\t\tpoly->fogIndex = fogIndex;\n\t}\n}\n\n\n//=================================================================================\n\n\n/*\n=====================\nRE_AddRefEntityToScene\n\n=====================\n*/\nvoid RE_AddRefEntityToScene( const refEntity_t *ent ) {\n\tif ( !tr.registered ) {\n\t\treturn;\n\t}\n  // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=402\n\tif ( r_numentities >= ENTITYNUM_WORLD ) {\n\t\treturn;\n\t}\n\tif ( ent->reType < 0 || ent->reType >= RT_MAX_REF_ENTITY_TYPE ) {\n\t\tri.Error( ERR_DROP, \"RE_AddRefEntityToScene: bad reType %i\", ent->reType );\n\t}\n\n\tbackEndData[tr.smpFrame]->entities[r_numentities].e = *ent;\n\tbackEndData[tr.smpFrame]->entities[r_numentities].lightingCalculated = qfalse;\n\n\tr_numentities++;\n}\n\n\n/*\n=====================\nRE_AddDynamicLightToScene\n\n=====================\n*/\nvoid RE_AddDynamicLightToScene( const vec3_t org, float intensity, float r, float g, float b, int additive ) {\n\tdlight_t\t*dl;\n\n\tif ( !tr.registered ) {\n\t\treturn;\n\t}\n\tif ( r_numdlights >= MAX_DLIGHTS ) {\n\t\treturn;\n\t}\n\tif ( intensity <= 0 ) {\n\t\treturn;\n\t}\n\t// these cards don't have the correct blend mode\n\tif ( glConfig.hardwareType == GLHW_RIVA128 || glConfig.hardwareType == GLHW_PERMEDIA2 ) {\n\t\treturn;\n\t}\n\tdl = &backEndData[tr.smpFrame]->dlights[r_numdlights++];\n\tVectorCopy (org, dl->origin);\n\tdl->radius = intensity;\n\tdl->color[0] = r;\n\tdl->color[1] = g;\n\tdl->color[2] = b;\n\tdl->additive = additive;\n}\n\n/*\n=====================\nRE_AddLightToScene\n\n=====================\n*/\nvoid RE_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ) {\n\tRE_AddDynamicLightToScene( org, intensity, r, g, b, qfalse );\n}\n\n/*\n=====================\nRE_AddAdditiveLightToScene\n\n=====================\n*/\nvoid RE_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b ) {\n\tRE_AddDynamicLightToScene( org, intensity, r, g, b, qtrue );\n}\n\n/*\n@@@@@@@@@@@@@@@@@@@@@\nRE_RenderScene\n\nDraw a 3D view into a part of the window, then return\nto 2D drawing.\n\nRendering a scene may require multiple views to be rendered\nto handle mirrors,\n@@@@@@@@@@@@@@@@@@@@@\n*/\nvoid RE_RenderScene( const refdef_t *fd ) {\n\tviewParms_t\t\tparms;\n\tint\t\t\t\tstartTime;\n\n\tif ( !tr.registered ) {\n\t\treturn;\n\t}\n\tGLimp_LogComment( \"====== RE_RenderScene =====\\n\" );\n\n\tif ( r_norefresh->integer ) {\n\t\treturn;\n\t}\n\n\tstartTime = ri.Milliseconds();\n\n\tif (!tr.world && !( fd->rdflags & RDF_NOWORLDMODEL ) ) {\n\t\tri.Error (ERR_DROP, \"R_RenderScene: NULL worldmodel\");\n\t}\n\n\tCom_Memcpy( tr.refdef.text, fd->text, sizeof( tr.refdef.text ) );\n\n\ttr.refdef.x = fd->x;\n\ttr.refdef.y = fd->y;\n\ttr.refdef.width = fd->width;\n\ttr.refdef.height = fd->height;\n\ttr.refdef.fov_x = fd->fov_x;\n\ttr.refdef.fov_y = fd->fov_y;\n\n\tVectorCopy( fd->vieworg, tr.refdef.vieworg );\n\tVectorCopy( fd->viewaxis[0], tr.refdef.viewaxis[0] );\n\tVectorCopy( fd->viewaxis[1], tr.refdef.viewaxis[1] );\n\tVectorCopy( fd->viewaxis[2], tr.refdef.viewaxis[2] );\n\n\ttr.refdef.time = fd->time;\n\ttr.refdef.rdflags = fd->rdflags;\n\n\t// copy the areamask data over and note if it has changed, which\n\t// will force a reset of the visible leafs even if the view hasn't moved\n\ttr.refdef.areamaskModified = qfalse;\n\tif ( ! (tr.refdef.rdflags & RDF_NOWORLDMODEL) ) {\n\t\tint\t\tareaDiff;\n\t\tint\t\ti;\n\n\t\t// compare the area bits\n\t\tareaDiff = 0;\n\t\tfor (i = 0 ; i < MAX_MAP_AREA_BYTES/4 ; i++) {\n\t\t\tareaDiff |= ((int *)tr.refdef.areamask)[i] ^ ((int *)fd->areamask)[i];\n\t\t\t((int *)tr.refdef.areamask)[i] = ((int *)fd->areamask)[i];\n\t\t}\n\n\t\tif ( areaDiff ) {\n\t\t\t// a door just opened or something\n\t\t\ttr.refdef.areamaskModified = qtrue;\n\t\t}\n\t}\n\n\n\t// derived info\n\n\ttr.refdef.floatTime = tr.refdef.time * 0.001f;\n\n\ttr.refdef.numDrawSurfs = r_firstSceneDrawSurf;\n\ttr.refdef.drawSurfs = backEndData[tr.smpFrame]->drawSurfs;\n\n\ttr.refdef.num_entities = r_numentities - r_firstSceneEntity;\n\ttr.refdef.entities = &backEndData[tr.smpFrame]->entities[r_firstSceneEntity];\n\n\ttr.refdef.num_dlights = r_numdlights - r_firstSceneDlight;\n\ttr.refdef.dlights = &backEndData[tr.smpFrame]->dlights[r_firstSceneDlight];\n\n\ttr.refdef.numPolys = r_numpolys - r_firstScenePoly;\n\ttr.refdef.polys = &backEndData[tr.smpFrame]->polys[r_firstScenePoly];\n\n\t// turn off dynamic lighting globally by clearing all the\n\t// dlights if it needs to be disabled or if vertex lighting is enabled\n\tif ( r_dynamiclight->integer == 0 ||\n\t\t r_vertexLight->integer == 1 ||\n\t\t glConfig.hardwareType == GLHW_PERMEDIA2 ) {\n\t\ttr.refdef.num_dlights = 0;\n\t}\n\n\t// a single frame may have multiple scenes draw inside it --\n\t// a 3D game view, 3D status bar renderings, 3D menus, etc.\n\t// They need to be distinguished by the light flare code, because\n\t// the visibility state for a given surface may be different in\n\t// each scene / view.\n\ttr.frameSceneNum++;\n\ttr.sceneCount++;\n\n\t// setup view parms for the initial view\n\t//\n\t// set up viewport\n\t// The refdef takes 0-at-the-top y coordinates, so\n\t// convert to GL's 0-at-the-bottom space\n\t//\n\tCom_Memset( &parms, 0, sizeof( parms ) );\n\tparms.viewportX = tr.refdef.x;\n\tparms.viewportY = glConfig.vidHeight - ( tr.refdef.y + tr.refdef.height );\n\tparms.viewportWidth = tr.refdef.width;\n\tparms.viewportHeight = tr.refdef.height;\n\tparms.isPortal = qfalse;\n\n\tparms.fovX = tr.refdef.fov_x;\n\tparms.fovY = tr.refdef.fov_y;\n\n\tVectorCopy( fd->vieworg, parms.or.origin );\n\tVectorCopy( fd->viewaxis[0], parms.or.axis[0] );\n\tVectorCopy( fd->viewaxis[1], parms.or.axis[1] );\n\tVectorCopy( fd->viewaxis[2], parms.or.axis[2] );\n\n\tVectorCopy( fd->vieworg, parms.pvsOrigin );\n\n\tR_RenderView( &parms );\n\n\t// the next scene rendered in this frame will tack on after this one\n\tr_firstSceneDrawSurf = tr.refdef.numDrawSurfs;\n\tr_firstSceneEntity = r_numentities;\n\tr_firstSceneDlight = r_numdlights;\n\tr_firstScenePoly = r_numpolys;\n\n\ttr.frontEndMsec += ri.Milliseconds() - startTime;\n}\n"
  },
  {
    "path": "code/renderer/tr_shade.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// tr_shade.c\n\n#include \"tr_local.h\"\n\n/*\n\n  THIS ENTIRE FILE IS BACK END\n\n  This file deals with applying shaders to surface data in the tess struct.\n*/\n\n/*\n================\nR_ArrayElementDiscrete\n\nThis is just for OpenGL conformance testing, it should never be the fastest\n================\n*/\nstatic void APIENTRY R_ArrayElementDiscrete( GLint index ) {\n\tqglColor4ubv( tess.svars.colors[ index ] );\n\tif ( glState.currenttmu ) {\n\t\tqglMultiTexCoord2fARB( 0, tess.svars.texcoords[ 0 ][ index ][0], tess.svars.texcoords[ 0 ][ index ][1] );\n\t\tqglMultiTexCoord2fARB( 1, tess.svars.texcoords[ 1 ][ index ][0], tess.svars.texcoords[ 1 ][ index ][1] );\n\t} else {\n\t\tqglTexCoord2fv( tess.svars.texcoords[ 0 ][ index ] );\n\t}\n\tqglVertex3fv( tess.xyz[ index ] );\n}\n\n/*\n===================\nR_DrawStripElements\n\n===================\n*/\nstatic int\t\tc_vertexes;\t\t// for seeing how long our average strips are\nstatic int\t\tc_begins;\nstatic void R_DrawStripElements( int numIndexes, const glIndex_t *indexes, void ( APIENTRY *element )(GLint) ) {\n\tint i;\n\tint last[3] = { -1, -1, -1 };\n\tqboolean even;\n\n\tc_begins++;\n\n\tif ( numIndexes <= 0 ) {\n\t\treturn;\n\t}\n\n\tqglBegin( GL_TRIANGLE_STRIP );\n\n\t// prime the strip\n\telement( indexes[0] );\n\telement( indexes[1] );\n\telement( indexes[2] );\n\tc_vertexes += 3;\n\n\tlast[0] = indexes[0];\n\tlast[1] = indexes[1];\n\tlast[2] = indexes[2];\n\n\teven = qfalse;\n\n\tfor ( i = 3; i < numIndexes; i += 3 )\n\t{\n\t\t// odd numbered triangle in potential strip\n\t\tif ( !even )\n\t\t{\n\t\t\t// check previous triangle to see if we're continuing a strip\n\t\t\tif ( ( indexes[i+0] == last[2] ) && ( indexes[i+1] == last[1] ) )\n\t\t\t{\n\t\t\t\telement( indexes[i+2] );\n\t\t\t\tc_vertexes++;\n\t\t\t\tassert( indexes[i+2] < tess.numVertexes );\n\t\t\t\teven = qtrue;\n\t\t\t}\n\t\t\t// otherwise we're done with this strip so finish it and start\n\t\t\t// a new one\n\t\t\telse\n\t\t\t{\n\t\t\t\tqglEnd();\n\n\t\t\t\tqglBegin( GL_TRIANGLE_STRIP );\n\t\t\t\tc_begins++;\n\n\t\t\t\telement( indexes[i+0] );\n\t\t\t\telement( indexes[i+1] );\n\t\t\t\telement( indexes[i+2] );\n\n\t\t\t\tc_vertexes += 3;\n\n\t\t\t\teven = qfalse;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// check previous triangle to see if we're continuing a strip\n\t\t\tif ( ( last[2] == indexes[i+1] ) && ( last[0] == indexes[i+0] ) )\n\t\t\t{\n\t\t\t\telement( indexes[i+2] );\n\t\t\t\tc_vertexes++;\n\n\t\t\t\teven = qfalse;\n\t\t\t}\n\t\t\t// otherwise we're done with this strip so finish it and start\n\t\t\t// a new one\n\t\t\telse\n\t\t\t{\n\t\t\t\tqglEnd();\n\n\t\t\t\tqglBegin( GL_TRIANGLE_STRIP );\n\t\t\t\tc_begins++;\n\n\t\t\t\telement( indexes[i+0] );\n\t\t\t\telement( indexes[i+1] );\n\t\t\t\telement( indexes[i+2] );\n\t\t\t\tc_vertexes += 3;\n\n\t\t\t\teven = qfalse;\n\t\t\t}\n\t\t}\n\n\t\t// cache the last three vertices\n\t\tlast[0] = indexes[i+0];\n\t\tlast[1] = indexes[i+1];\n\t\tlast[2] = indexes[i+2];\n\t}\n\n\tqglEnd();\n}\n\n\n\n/*\n==================\nR_DrawElements\n\nOptionally performs our own glDrawElements that looks for strip conditions\ninstead of using the single glDrawElements call that may be inefficient\nwithout compiled vertex arrays.\n==================\n*/\nstatic void R_DrawElements( int numIndexes, const glIndex_t *indexes ) {\n\tint\t\tprimitives;\n\n\tprimitives = r_primitives->integer;\n\n\t// default is to use triangles if compiled vertex arrays are present\n\tif ( primitives == 0 ) {\n\t\tif ( qglLockArraysEXT ) {\n\t\t\tprimitives = 2;\n\t\t} else {\n\t\t\tprimitives = 1;\n\t\t}\n\t}\n\n\n\tif ( primitives == 2 ) {\n\t\tqglDrawElements( GL_TRIANGLES, \n\t\t\t\t\t\tnumIndexes,\n\t\t\t\t\t\tGL_INDEX_TYPE,\n\t\t\t\t\t\tindexes );\n\t\treturn;\n\t}\n\n\tif ( primitives == 1 ) {\n\t\tR_DrawStripElements( numIndexes,  indexes, qglArrayElement );\n\t\treturn;\n\t}\n\t\n\tif ( primitives == 3 ) {\n\t\tR_DrawStripElements( numIndexes,  indexes, R_ArrayElementDiscrete );\n\t\treturn;\n\t}\n\n\t// anything else will cause no drawing\n}\n\n\n/*\n=============================================================\n\nSURFACE SHADERS\n\n=============================================================\n*/\n\nshaderCommands_t\ttess;\nstatic qboolean\tsetArraysOnce;\n\n/*\n=================\nR_BindAnimatedImage\n\n=================\n*/\nstatic void R_BindAnimatedImage( textureBundle_t *bundle ) {\n\tint\t\tindex;\n\n\tif ( bundle->isVideoMap ) {\n\t\tri.CIN_RunCinematic(bundle->videoMapHandle);\n\t\tri.CIN_UploadCinematic(bundle->videoMapHandle);\n\t\treturn;\n\t}\n\n\tif ( bundle->numImageAnimations <= 1 ) {\n\t\tGL_Bind( bundle->image[0] );\n\t\treturn;\n\t}\n\n\t// it is necessary to do this messy calc to make sure animations line up\n\t// exactly with waveforms of the same frequency\n\tindex = myftol( tess.shaderTime * bundle->imageAnimationSpeed * FUNCTABLE_SIZE );\n\tindex >>= FUNCTABLE_SIZE2;\n\n\tif ( index < 0 ) {\n\t\tindex = 0;\t// may happen with shader time offsets\n\t}\n\tindex %= bundle->numImageAnimations;\n\n\tGL_Bind( bundle->image[ index ] );\n}\n\n/*\n================\nDrawTris\n\nDraws triangle outlines for debugging\n================\n*/\nstatic void DrawTris (shaderCommands_t *input) {\n\tGL_Bind( tr.whiteImage );\n\tqglColor3f (1,1,1);\n\n\tGL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE );\n\tqglDepthRange( 0, 0 );\n\n\tqglDisableClientState (GL_COLOR_ARRAY);\n\tqglDisableClientState (GL_TEXTURE_COORD_ARRAY);\n\n\tqglVertexPointer (3, GL_FLOAT, 16, input->xyz);\t// padded for SIMD\n\n\tif (qglLockArraysEXT) {\n\t\tqglLockArraysEXT(0, input->numVertexes);\n\t\tGLimp_LogComment( \"glLockArraysEXT\\n\" );\n\t}\n\n\tR_DrawElements( input->numIndexes, input->indexes );\n\n\tif (qglUnlockArraysEXT) {\n\t\tqglUnlockArraysEXT();\n\t\tGLimp_LogComment( \"glUnlockArraysEXT\\n\" );\n\t}\n\tqglDepthRange( 0, 1 );\n}\n\n\n/*\n================\nDrawNormals\n\nDraws vertex normals for debugging\n================\n*/\nstatic void DrawNormals (shaderCommands_t *input) {\n\tint\t\ti;\n\tvec3_t\ttemp;\n\n\tGL_Bind( tr.whiteImage );\n\tqglColor3f (1,1,1);\n\tqglDepthRange( 0, 0 );\t// never occluded\n\tGL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE );\n\n\tqglBegin (GL_LINES);\n\tfor (i = 0 ; i < input->numVertexes ; i++) {\n\t\tqglVertex3fv (input->xyz[i]);\n\t\tVectorMA (input->xyz[i], 2, input->normal[i], temp);\n\t\tqglVertex3fv (temp);\n\t}\n\tqglEnd ();\n\n\tqglDepthRange( 0, 1 );\n}\n\n/*\n==============\nRB_BeginSurface\n\nWe must set some things up before beginning any tesselation,\nbecause a surface may be forced to perform a RB_End due\nto overflow.\n==============\n*/\nvoid RB_BeginSurface( shader_t *shader, int fogNum ) {\n\n\tshader_t *state = (shader->remappedShader) ? shader->remappedShader : shader;\n\n\ttess.numIndexes = 0;\n\ttess.numVertexes = 0;\n\ttess.shader = state;\n\ttess.fogNum = fogNum;\n\ttess.dlightBits = 0;\t\t// will be OR'd in by surface functions\n\ttess.xstages = state->stages;\n\ttess.numPasses = state->numUnfoggedPasses;\n\ttess.currentStageIteratorFunc = state->optimalStageIteratorFunc;\n\n\ttess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset;\n\tif (tess.shader->clampTime && tess.shaderTime >= tess.shader->clampTime) {\n\t\ttess.shaderTime = tess.shader->clampTime;\n\t}\n\n\n}\n\n/*\n===================\nDrawMultitextured\n\noutput = t0 * t1 or t0 + t1\n\nt0 = most upstream according to spec\nt1 = most downstream according to spec\n===================\n*/\nstatic void DrawMultitextured( shaderCommands_t *input, int stage ) {\n\tshaderStage_t\t*pStage;\n\n\tpStage = tess.xstages[stage];\n\n\tGL_State( pStage->stateBits );\n\n\t// this is an ugly hack to work around a GeForce driver\n\t// bug with multitexture and clip planes\n\tif ( backEnd.viewParms.isPortal ) {\n\t\tqglPolygonMode( GL_FRONT_AND_BACK, GL_FILL );\n\t}\n\n\t//\n\t// base\n\t//\n\tGL_SelectTexture( 0 );\n\tqglTexCoordPointer( 2, GL_FLOAT, 0, input->svars.texcoords[0] );\n\tR_BindAnimatedImage( &pStage->bundle[0] );\n\n\t//\n\t// lightmap/secondary pass\n\t//\n\tGL_SelectTexture( 1 );\n\tqglEnable( GL_TEXTURE_2D );\n\tqglEnableClientState( GL_TEXTURE_COORD_ARRAY );\n\n\tif ( r_lightmap->integer ) {\n\t\tGL_TexEnv( GL_REPLACE );\n\t} else {\n\t\tGL_TexEnv( tess.shader->multitextureEnv );\n\t}\n\n\tqglTexCoordPointer( 2, GL_FLOAT, 0, input->svars.texcoords[1] );\n\n\tR_BindAnimatedImage( &pStage->bundle[1] );\n\n\tR_DrawElements( input->numIndexes, input->indexes );\n\n\t//\n\t// disable texturing on TEXTURE1, then select TEXTURE0\n\t//\n\t//qglDisableClientState( GL_TEXTURE_COORD_ARRAY );\n\tqglDisable( GL_TEXTURE_2D );\n\n\tGL_SelectTexture( 0 );\n}\n\n\n\n/*\n===================\nProjectDlightTexture\n\nPerform dynamic lighting with another rendering pass\n===================\n*/\nstatic void ProjectDlightTexture( void ) {\n\tint\t\ti, l;\n#if idppc_altivec\n\tvec_t\torigin0, origin1, origin2;\n\tfloat   texCoords0, texCoords1;\n\tvector float floatColorVec0, floatColorVec1;\n\tvector float modulateVec, colorVec, zero;\n\tvector short colorShort;\n\tvector signed int colorInt;\n\tvector unsigned char floatColorVecPerm, modulatePerm, colorChar;\n\tvector unsigned char vSel = (vector unsigned char)(0x00, 0x00, 0x00, 0xff,\n\t\t\t\t\t\t\t   0x00, 0x00, 0x00, 0xff,\n\t\t\t\t\t\t\t   0x00, 0x00, 0x00, 0xff,\n\t\t\t\t\t\t\t   0x00, 0x00, 0x00, 0xff);\n#else\n\tvec3_t\torigin;\n#endif\n\tfloat\t*texCoords;\n\tbyte\t*colors;\n\tbyte\tclipBits[SHADER_MAX_VERTEXES];\n\tMAC_STATIC float\ttexCoordsArray[SHADER_MAX_VERTEXES][2];\n\tbyte\tcolorArray[SHADER_MAX_VERTEXES][4];\n\tunsigned\thitIndexes[SHADER_MAX_INDEXES];\n\tint\t\tnumIndexes;\n\tfloat\tscale;\n\tfloat\tradius;\n\tvec3_t\tfloatColor;\n\tfloat\tmodulate;\n\n\tif ( !backEnd.refdef.num_dlights ) {\n\t\treturn;\n\t}\n\n#if idppc_altivec\n\t// There has to be a better way to do this so that floatColor \n\t// and/or modulate are already 16-byte aligned.\n\tfloatColorVecPerm = vec_lvsl(0,(float *)floatColor);\n\tmodulatePerm = vec_lvsl(0,(float *)&modulate);\n\tmodulatePerm = (vector unsigned char)vec_splat((vector unsigned int)modulatePerm,0);\n\tzero = (vector float)vec_splat_s8(0);\n#endif\n\n\tfor ( l = 0 ; l < backEnd.refdef.num_dlights ; l++ ) {\n\t\tdlight_t\t*dl;\n\n\t\tif ( !( tess.dlightBits & ( 1 << l ) ) ) {\n\t\t\tcontinue;\t// this surface definately doesn't have any of this light\n\t\t}\n\t\ttexCoords = texCoordsArray[0];\n\t\tcolors = colorArray[0];\n\n\t\tdl = &backEnd.refdef.dlights[l];\n#if idppc_altivec\n\t\torigin0 = dl->transformed[0];\n\t\torigin1 = dl->transformed[1];\n\t\torigin2 = dl->transformed[2];\n#else\n\t\tVectorCopy( dl->transformed, origin );\n#endif\n\t\tradius = dl->radius;\n\t\tscale = 1.0f / radius;\n\n\t\tfloatColor[0] = dl->color[0] * 255.0f;\n\t\tfloatColor[1] = dl->color[1] * 255.0f;\n\t\tfloatColor[2] = dl->color[2] * 255.0f;\n#if idppc_altivec\n\t\tfloatColorVec0 = vec_ld(0, floatColor);\n\t\tfloatColorVec1 = vec_ld(11, floatColor);\n\t\tfloatColorVec0 = vec_perm(floatColorVec0,floatColorVec0,floatColorVecPerm);\n#endif\n\t\tfor ( i = 0 ; i < tess.numVertexes ; i++, texCoords += 2, colors += 4 ) {\n#if idppc_altivec\n\t\t\tvec_t dist0, dist1, dist2;\n#else\n\t\t\tvec3_t\tdist;\n#endif\n\t\t\tint\t\tclip;\n\n\t\t\tbackEnd.pc.c_dlightVertexes++;\n\n#if idppc_altivec\n\t\t\t//VectorSubtract( origin, tess.xyz[i], dist );\n\t\t\tdist0 = origin0 - tess.xyz[i][0];\n\t\t\tdist1 = origin1 - tess.xyz[i][1];\n\t\t\tdist2 = origin2 - tess.xyz[i][2];\n\t\t\ttexCoords0 = 0.5f + dist0 * scale;\n\t\t\ttexCoords1 = 0.5f + dist1 * scale;\n\n\t\t\tclip = 0;\n\t\t\tif ( texCoords0 < 0.0f ) {\n\t\t\t\tclip |= 1;\n\t\t\t} else if ( texCoords0 > 1.0f ) {\n\t\t\t\tclip |= 2;\n\t\t\t}\n\t\t\tif ( texCoords1 < 0.0f ) {\n\t\t\t\tclip |= 4;\n\t\t\t} else if ( texCoords1 > 1.0f ) {\n\t\t\t\tclip |= 8;\n\t\t\t}\n\t\t\ttexCoords[0] = texCoords0;\n\t\t\ttexCoords[1] = texCoords1;\n\t\t\t\n\t\t\t// modulate the strength based on the height and color\n\t\t\tif ( dist2 > radius ) {\n\t\t\t\tclip |= 16;\n\t\t\t\tmodulate = 0.0f;\n\t\t\t} else if ( dist2 < -radius ) {\n\t\t\t\tclip |= 32;\n\t\t\t\tmodulate = 0.0f;\n\t\t\t} else {\n\t\t\t\tdist2 = Q_fabs(dist2);\n\t\t\t\tif ( dist2 < radius * 0.5f ) {\n\t\t\t\t\tmodulate = 1.0f;\n\t\t\t\t} else {\n\t\t\t\t\tmodulate = 2.0f * (radius - dist2) * scale;\n\t\t\t\t}\n\t\t\t}\n\t\t\tclipBits[i] = clip;\n\n\t\t\tmodulateVec = vec_ld(0,(float *)&modulate);\n\t\t\tmodulateVec = vec_perm(modulateVec,modulateVec,modulatePerm);\n\t\t\tcolorVec = vec_madd(floatColorVec0,modulateVec,zero);\n\t\t\tcolorInt = vec_cts(colorVec,0);\t// RGBx\n\t\t\tcolorShort = vec_pack(colorInt,colorInt);\t\t// RGBxRGBx\n\t\t\tcolorChar = vec_packsu(colorShort,colorShort);\t// RGBxRGBxRGBxRGBx\n\t\t\tcolorChar = vec_sel(colorChar,vSel,vSel);\t\t// RGBARGBARGBARGBA replace alpha with 255\n\t\t\tvec_ste((vector unsigned int)colorChar,0,(unsigned int *)colors);\t// store color\n#else\n\t\t\tVectorSubtract( origin, tess.xyz[i], dist );\n\t\t\ttexCoords[0] = 0.5f + dist[0] * scale;\n\t\t\ttexCoords[1] = 0.5f + dist[1] * scale;\n\n\t\t\tclip = 0;\n\t\t\tif ( texCoords[0] < 0.0f ) {\n\t\t\t\tclip |= 1;\n\t\t\t} else if ( texCoords[0] > 1.0f ) {\n\t\t\t\tclip |= 2;\n\t\t\t}\n\t\t\tif ( texCoords[1] < 0.0f ) {\n\t\t\t\tclip |= 4;\n\t\t\t} else if ( texCoords[1] > 1.0f ) {\n\t\t\t\tclip |= 8;\n\t\t\t}\n\t\t\t// modulate the strength based on the height and color\n\t\t\tif ( dist[2] > radius ) {\n\t\t\t\tclip |= 16;\n\t\t\t\tmodulate = 0.0f;\n\t\t\t} else if ( dist[2] < -radius ) {\n\t\t\t\tclip |= 32;\n\t\t\t\tmodulate = 0.0f;\n\t\t\t} else {\n\t\t\t\tdist[2] = Q_fabs(dist[2]);\n\t\t\t\tif ( dist[2] < radius * 0.5f ) {\n\t\t\t\t\tmodulate = 1.0f;\n\t\t\t\t} else {\n\t\t\t\t\tmodulate = 2.0f * (radius - dist[2]) * scale;\n\t\t\t\t}\n\t\t\t}\n\t\t\tclipBits[i] = clip;\n\n\t\t\tcolors[0] = myftol(floatColor[0] * modulate);\n\t\t\tcolors[1] = myftol(floatColor[1] * modulate);\n\t\t\tcolors[2] = myftol(floatColor[2] * modulate);\n\t\t\tcolors[3] = 255;\n#endif\n\t\t}\n\n\t\t// build a list of triangles that need light\n\t\tnumIndexes = 0;\n\t\tfor ( i = 0 ; i < tess.numIndexes ; i += 3 ) {\n\t\t\tint\t\ta, b, c;\n\n\t\t\ta = tess.indexes[i];\n\t\t\tb = tess.indexes[i+1];\n\t\t\tc = tess.indexes[i+2];\n\t\t\tif ( clipBits[a] & clipBits[b] & clipBits[c] ) {\n\t\t\t\tcontinue;\t// not lighted\n\t\t\t}\n\t\t\thitIndexes[numIndexes] = a;\n\t\t\thitIndexes[numIndexes+1] = b;\n\t\t\thitIndexes[numIndexes+2] = c;\n\t\t\tnumIndexes += 3;\n\t\t}\n\n\t\tif ( !numIndexes ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tqglEnableClientState( GL_TEXTURE_COORD_ARRAY );\n\t\tqglTexCoordPointer( 2, GL_FLOAT, 0, texCoordsArray[0] );\n\n\t\tqglEnableClientState( GL_COLOR_ARRAY );\n\t\tqglColorPointer( 4, GL_UNSIGNED_BYTE, 0, colorArray );\n\n\t\tGL_Bind( tr.dlightImage );\n\t\t// include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light\n\t\t// where they aren't rendered\n\t\tif ( dl->additive ) {\n\t\t\tGL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL );\n\t\t}\n\t\telse {\n\t\t\tGL_State( GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL );\n\t\t}\n\t\tR_DrawElements( numIndexes, hitIndexes );\n\t\tbackEnd.pc.c_totalIndexes += numIndexes;\n\t\tbackEnd.pc.c_dlightIndexes += numIndexes;\n\t}\n}\n\n\n/*\n===================\nRB_FogPass\n\nBlends a fog texture on top of everything else\n===================\n*/\nstatic void RB_FogPass( void ) {\n\tfog_t\t\t*fog;\n\tint\t\t\ti;\n\n\tqglEnableClientState( GL_COLOR_ARRAY );\n\tqglColorPointer( 4, GL_UNSIGNED_BYTE, 0, tess.svars.colors );\n\n\tqglEnableClientState( GL_TEXTURE_COORD_ARRAY);\n\tqglTexCoordPointer( 2, GL_FLOAT, 0, tess.svars.texcoords[0] );\n\n\tfog = tr.world->fogs + tess.fogNum;\n\n\tfor ( i = 0; i < tess.numVertexes; i++ ) {\n\t\t* ( int * )&tess.svars.colors[i] = fog->colorInt;\n\t}\n\n\tRB_CalcFogTexCoords( ( float * ) tess.svars.texcoords[0] );\n\n\tGL_Bind( tr.fogImage );\n\n\tif ( tess.shader->fogPass == FP_EQUAL ) {\n\t\tGL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL );\n\t} else {\n\t\tGL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );\n\t}\n\n\tR_DrawElements( tess.numIndexes, tess.indexes );\n}\n\n/*\n===============\nComputeColors\n===============\n*/\nstatic void ComputeColors( shaderStage_t *pStage )\n{\n\tint\t\ti;\n\n\t//\n\t// rgbGen\n\t//\n\tswitch ( pStage->rgbGen )\n\t{\n\t\tcase CGEN_IDENTITY:\n\t\t\tCom_Memset( tess.svars.colors, 0xff, tess.numVertexes * 4 );\n\t\t\tbreak;\n\t\tdefault:\n\t\tcase CGEN_IDENTITY_LIGHTING:\n\t\t\tCom_Memset( tess.svars.colors, tr.identityLightByte, tess.numVertexes * 4 );\n\t\t\tbreak;\n\t\tcase CGEN_LIGHTING_DIFFUSE:\n\t\t\tRB_CalcDiffuseColor( ( unsigned char * ) tess.svars.colors );\n\t\t\tbreak;\n\t\tcase CGEN_EXACT_VERTEX:\n\t\t\tCom_Memcpy( tess.svars.colors, tess.vertexColors, tess.numVertexes * sizeof( tess.vertexColors[0] ) );\n\t\t\tbreak;\n\t\tcase CGEN_CONST:\n\t\t\tfor ( i = 0; i < tess.numVertexes; i++ ) {\n\t\t\t\t*(int *)tess.svars.colors[i] = *(int *)pStage->constantColor;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase CGEN_VERTEX:\n\t\t\tif ( tr.identityLight == 1 )\n\t\t\t{\n\t\t\t\tCom_Memcpy( tess.svars.colors, tess.vertexColors, tess.numVertexes * sizeof( tess.vertexColors[0] ) );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfor ( i = 0; i < tess.numVertexes; i++ )\n\t\t\t\t{\n\t\t\t\t\ttess.svars.colors[i][0] = tess.vertexColors[i][0] * tr.identityLight;\n\t\t\t\t\ttess.svars.colors[i][1] = tess.vertexColors[i][1] * tr.identityLight;\n\t\t\t\t\ttess.svars.colors[i][2] = tess.vertexColors[i][2] * tr.identityLight;\n\t\t\t\t\ttess.svars.colors[i][3] = tess.vertexColors[i][3];\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\tcase CGEN_ONE_MINUS_VERTEX:\n\t\t\tif ( tr.identityLight == 1 )\n\t\t\t{\n\t\t\t\tfor ( i = 0; i < tess.numVertexes; i++ )\n\t\t\t\t{\n\t\t\t\t\ttess.svars.colors[i][0] = 255 - tess.vertexColors[i][0];\n\t\t\t\t\ttess.svars.colors[i][1] = 255 - tess.vertexColors[i][1];\n\t\t\t\t\ttess.svars.colors[i][2] = 255 - tess.vertexColors[i][2];\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfor ( i = 0; i < tess.numVertexes; i++ )\n\t\t\t\t{\n\t\t\t\t\ttess.svars.colors[i][0] = ( 255 - tess.vertexColors[i][0] ) * tr.identityLight;\n\t\t\t\t\ttess.svars.colors[i][1] = ( 255 - tess.vertexColors[i][1] ) * tr.identityLight;\n\t\t\t\t\ttess.svars.colors[i][2] = ( 255 - tess.vertexColors[i][2] ) * tr.identityLight;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\tcase CGEN_FOG:\n\t\t\t{\n\t\t\t\tfog_t\t\t*fog;\n\n\t\t\t\tfog = tr.world->fogs + tess.fogNum;\n\n\t\t\t\tfor ( i = 0; i < tess.numVertexes; i++ ) {\n\t\t\t\t\t* ( int * )&tess.svars.colors[i] = fog->colorInt;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\tcase CGEN_WAVEFORM:\n\t\t\tRB_CalcWaveColor( &pStage->rgbWave, ( unsigned char * ) tess.svars.colors );\n\t\t\tbreak;\n\t\tcase CGEN_ENTITY:\n\t\t\tRB_CalcColorFromEntity( ( unsigned char * ) tess.svars.colors );\n\t\t\tbreak;\n\t\tcase CGEN_ONE_MINUS_ENTITY:\n\t\t\tRB_CalcColorFromOneMinusEntity( ( unsigned char * ) tess.svars.colors );\n\t\t\tbreak;\n\t}\n\n\t//\n\t// alphaGen\n\t//\n\tswitch ( pStage->alphaGen )\n\t{\n\tcase AGEN_SKIP:\n\t\tbreak;\n\tcase AGEN_IDENTITY:\n\t\tif ( pStage->rgbGen != CGEN_IDENTITY ) {\n\t\t\tif ( ( pStage->rgbGen == CGEN_VERTEX && tr.identityLight != 1 ) ||\n\t\t\t\t pStage->rgbGen != CGEN_VERTEX ) {\n\t\t\t\tfor ( i = 0; i < tess.numVertexes; i++ ) {\n\t\t\t\t\ttess.svars.colors[i][3] = 0xff;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbreak;\n\tcase AGEN_CONST:\n\t\tif ( pStage->rgbGen != CGEN_CONST ) {\n\t\t\tfor ( i = 0; i < tess.numVertexes; i++ ) {\n\t\t\t\ttess.svars.colors[i][3] = pStage->constantColor[3];\n\t\t\t}\n\t\t}\n\t\tbreak;\n\tcase AGEN_WAVEFORM:\n\t\tRB_CalcWaveAlpha( &pStage->alphaWave, ( unsigned char * ) tess.svars.colors );\n\t\tbreak;\n\tcase AGEN_LIGHTING_SPECULAR:\n\t\tRB_CalcSpecularAlpha( ( unsigned char * ) tess.svars.colors );\n\t\tbreak;\n\tcase AGEN_ENTITY:\n\t\tRB_CalcAlphaFromEntity( ( unsigned char * ) tess.svars.colors );\n\t\tbreak;\n\tcase AGEN_ONE_MINUS_ENTITY:\n\t\tRB_CalcAlphaFromOneMinusEntity( ( unsigned char * ) tess.svars.colors );\n\t\tbreak;\n    case AGEN_VERTEX:\n\t\tif ( pStage->rgbGen != CGEN_VERTEX ) {\n\t\t\tfor ( i = 0; i < tess.numVertexes; i++ ) {\n\t\t\t\ttess.svars.colors[i][3] = tess.vertexColors[i][3];\n\t\t\t}\n\t\t}\n        break;\n    case AGEN_ONE_MINUS_VERTEX:\n        for ( i = 0; i < tess.numVertexes; i++ )\n        {\n\t\t\ttess.svars.colors[i][3] = 255 - tess.vertexColors[i][3];\n        }\n        break;\n\tcase AGEN_PORTAL:\n\t\t{\n\t\t\tunsigned char alpha;\n\n\t\t\tfor ( i = 0; i < tess.numVertexes; i++ )\n\t\t\t{\n\t\t\t\tfloat len;\n\t\t\t\tvec3_t v;\n\n\t\t\t\tVectorSubtract( tess.xyz[i], backEnd.viewParms.or.origin, v );\n\t\t\t\tlen = VectorLength( v );\n\n\t\t\t\tlen /= tess.shader->portalRange;\n\n\t\t\t\tif ( len < 0 )\n\t\t\t\t{\n\t\t\t\t\talpha = 0;\n\t\t\t\t}\n\t\t\t\telse if ( len > 1 )\n\t\t\t\t{\n\t\t\t\t\talpha = 0xff;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\talpha = len * 0xff;\n\t\t\t\t}\n\n\t\t\t\ttess.svars.colors[i][3] = alpha;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\t}\n\n\t//\n\t// fog adjustment for colors to fade out as fog increases\n\t//\n\tif ( tess.fogNum )\n\t{\n\t\tswitch ( pStage->adjustColorsForFog )\n\t\t{\n\t\tcase ACFF_MODULATE_RGB:\n\t\t\tRB_CalcModulateColorsByFog( ( unsigned char * ) tess.svars.colors );\n\t\t\tbreak;\n\t\tcase ACFF_MODULATE_ALPHA:\n\t\t\tRB_CalcModulateAlphasByFog( ( unsigned char * ) tess.svars.colors );\n\t\t\tbreak;\n\t\tcase ACFF_MODULATE_RGBA:\n\t\t\tRB_CalcModulateRGBAsByFog( ( unsigned char * ) tess.svars.colors );\n\t\t\tbreak;\n\t\tcase ACFF_NONE:\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/*\n===============\nComputeTexCoords\n===============\n*/\nstatic void ComputeTexCoords( shaderStage_t *pStage ) {\n\tint\t\ti;\n\tint\t\tb;\n\n\tfor ( b = 0; b < NUM_TEXTURE_BUNDLES; b++ ) {\n\t\tint tm;\n\n\t\t//\n\t\t// generate the texture coordinates\n\t\t//\n\t\tswitch ( pStage->bundle[b].tcGen )\n\t\t{\n\t\tcase TCGEN_IDENTITY:\n\t\t\tCom_Memset( tess.svars.texcoords[b], 0, sizeof( float ) * 2 * tess.numVertexes );\n\t\t\tbreak;\n\t\tcase TCGEN_TEXTURE:\n\t\t\tfor ( i = 0 ; i < tess.numVertexes ; i++ ) {\n\t\t\t\ttess.svars.texcoords[b][i][0] = tess.texCoords[i][0][0];\n\t\t\t\ttess.svars.texcoords[b][i][1] = tess.texCoords[i][0][1];\n\t\t\t}\n\t\t\tbreak;\n\t\tcase TCGEN_LIGHTMAP:\n\t\t\tfor ( i = 0 ; i < tess.numVertexes ; i++ ) {\n\t\t\t\ttess.svars.texcoords[b][i][0] = tess.texCoords[i][1][0];\n\t\t\t\ttess.svars.texcoords[b][i][1] = tess.texCoords[i][1][1];\n\t\t\t}\n\t\t\tbreak;\n\t\tcase TCGEN_VECTOR:\n\t\t\tfor ( i = 0 ; i < tess.numVertexes ; i++ ) {\n\t\t\t\ttess.svars.texcoords[b][i][0] = DotProduct( tess.xyz[i], pStage->bundle[b].tcGenVectors[0] );\n\t\t\t\ttess.svars.texcoords[b][i][1] = DotProduct( tess.xyz[i], pStage->bundle[b].tcGenVectors[1] );\n\t\t\t}\n\t\t\tbreak;\n\t\tcase TCGEN_FOG:\n\t\t\tRB_CalcFogTexCoords( ( float * ) tess.svars.texcoords[b] );\n\t\t\tbreak;\n\t\tcase TCGEN_ENVIRONMENT_MAPPED:\n\t\t\tRB_CalcEnvironmentTexCoords( ( float * ) tess.svars.texcoords[b] );\n\t\t\tbreak;\n\t\tcase TCGEN_BAD:\n\t\t\treturn;\n\t\t}\n\n\t\t//\n\t\t// alter texture coordinates\n\t\t//\n\t\tfor ( tm = 0; tm < pStage->bundle[b].numTexMods ; tm++ ) {\n\t\t\tswitch ( pStage->bundle[b].texMods[tm].type )\n\t\t\t{\n\t\t\tcase TMOD_NONE:\n\t\t\t\ttm = TR_MAX_TEXMODS;\t\t// break out of for loop\n\t\t\t\tbreak;\n\n\t\t\tcase TMOD_TURBULENT:\n\t\t\t\tRB_CalcTurbulentTexCoords( &pStage->bundle[b].texMods[tm].wave, \n\t\t\t\t\t\t                 ( float * ) tess.svars.texcoords[b] );\n\t\t\t\tbreak;\n\n\t\t\tcase TMOD_ENTITY_TRANSLATE:\n\t\t\t\tRB_CalcScrollTexCoords( backEnd.currentEntity->e.shaderTexCoord,\n\t\t\t\t\t\t\t\t\t ( float * ) tess.svars.texcoords[b] );\n\t\t\t\tbreak;\n\n\t\t\tcase TMOD_SCROLL:\n\t\t\t\tRB_CalcScrollTexCoords( pStage->bundle[b].texMods[tm].scroll,\n\t\t\t\t\t\t\t\t\t\t ( float * ) tess.svars.texcoords[b] );\n\t\t\t\tbreak;\n\n\t\t\tcase TMOD_SCALE:\n\t\t\t\tRB_CalcScaleTexCoords( pStage->bundle[b].texMods[tm].scale,\n\t\t\t\t\t\t\t\t\t ( float * ) tess.svars.texcoords[b] );\n\t\t\t\tbreak;\n\t\t\t\n\t\t\tcase TMOD_STRETCH:\n\t\t\t\tRB_CalcStretchTexCoords( &pStage->bundle[b].texMods[tm].wave, \n\t\t\t\t\t\t               ( float * ) tess.svars.texcoords[b] );\n\t\t\t\tbreak;\n\n\t\t\tcase TMOD_TRANSFORM:\n\t\t\t\tRB_CalcTransformTexCoords( &pStage->bundle[b].texMods[tm],\n\t\t\t\t\t\t                 ( float * ) tess.svars.texcoords[b] );\n\t\t\t\tbreak;\n\n\t\t\tcase TMOD_ROTATE:\n\t\t\t\tRB_CalcRotateTexCoords( pStage->bundle[b].texMods[tm].rotateSpeed,\n\t\t\t\t\t\t\t\t\t\t( float * ) tess.svars.texcoords[b] );\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tri.Error( ERR_DROP, \"ERROR: unknown texmod '%d' in shader '%s'\\n\", pStage->bundle[b].texMods[tm].type, tess.shader->name );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n** RB_IterateStagesGeneric\n*/\nstatic void RB_IterateStagesGeneric( shaderCommands_t *input )\n{\n\tint stage;\n\n\tfor ( stage = 0; stage < MAX_SHADER_STAGES; stage++ )\n\t{\n\t\tshaderStage_t *pStage = tess.xstages[stage];\n\n\t\tif ( !pStage )\n\t\t{\n\t\t\tbreak;\n\t\t}\n\n\t\tComputeColors( pStage );\n\t\tComputeTexCoords( pStage );\n\n\t\tif ( !setArraysOnce )\n\t\t{\n\t\t\tqglEnableClientState( GL_COLOR_ARRAY );\n\t\t\tqglColorPointer( 4, GL_UNSIGNED_BYTE, 0, input->svars.colors );\n\t\t}\n\n\t\t//\n\t\t// do multitexture\n\t\t//\n\t\tif ( pStage->bundle[1].image[0] != 0 )\n\t\t{\n\t\t\tDrawMultitextured( input, stage );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif ( !setArraysOnce )\n\t\t\t{\n\t\t\t\tqglTexCoordPointer( 2, GL_FLOAT, 0, input->svars.texcoords[0] );\n\t\t\t}\n\n\t\t\t//\n\t\t\t// set state\n\t\t\t//\n\t\t\tif ( pStage->bundle[0].vertexLightmap && ( (r_vertexLight->integer && !r_uiFullScreen->integer) || glConfig.hardwareType == GLHW_PERMEDIA2 ) && r_lightmap->integer )\n\t\t\t{\n\t\t\t\tGL_Bind( tr.whiteImage );\n\t\t\t}\n\t\t\telse \n\t\t\t\tR_BindAnimatedImage( &pStage->bundle[0] );\n\n\t\t\tGL_State( pStage->stateBits );\n\n\t\t\t//\n\t\t\t// draw\n\t\t\t//\n\t\t\tR_DrawElements( input->numIndexes, input->indexes );\n\t\t}\n\t\t// allow skipping out to show just lightmaps during development\n\t\tif ( r_lightmap->integer && ( pStage->bundle[0].isLightmap || pStage->bundle[1].isLightmap || pStage->bundle[0].vertexLightmap ) )\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n\n/*\n** RB_StageIteratorGeneric\n*/\nvoid RB_StageIteratorGeneric( void )\n{\n\tshaderCommands_t *input;\n\n\tinput = &tess;\n\n\tRB_DeformTessGeometry();\n\n\t//\n\t// log this call\n\t//\n\tif ( r_logFile->integer ) \n\t{\n\t\t// don't just call LogComment, or we will get\n\t\t// a call to va() every frame!\n\t\tGLimp_LogComment( va(\"--- RB_StageIteratorGeneric( %s ) ---\\n\", tess.shader->name) );\n\t}\n\n\t//\n\t// set face culling appropriately\n\t//\n\tGL_Cull( input->shader->cullType );\n\n\t// set polygon offset if necessary\n\tif ( input->shader->polygonOffset )\n\t{\n\t\tqglEnable( GL_POLYGON_OFFSET_FILL );\n\t\tqglPolygonOffset( r_offsetFactor->value, r_offsetUnits->value );\n\t}\n\n\t//\n\t// if there is only a single pass then we can enable color\n\t// and texture arrays before we compile, otherwise we need\n\t// to avoid compiling those arrays since they will change\n\t// during multipass rendering\n\t//\n\tif ( tess.numPasses > 1 || input->shader->multitextureEnv )\n\t{\n\t\tsetArraysOnce = qfalse;\n\t\tqglDisableClientState (GL_COLOR_ARRAY);\n\t\tqglDisableClientState (GL_TEXTURE_COORD_ARRAY);\n\t}\n\telse\n\t{\n\t\tsetArraysOnce = qtrue;\n\n\t\tqglEnableClientState( GL_COLOR_ARRAY);\n\t\tqglColorPointer( 4, GL_UNSIGNED_BYTE, 0, tess.svars.colors );\n\n\t\tqglEnableClientState( GL_TEXTURE_COORD_ARRAY);\n\t\tqglTexCoordPointer( 2, GL_FLOAT, 0, tess.svars.texcoords[0] );\n\t}\n\n\t//\n\t// lock XYZ\n\t//\n\tqglVertexPointer (3, GL_FLOAT, 16, input->xyz);\t// padded for SIMD\n\tif (qglLockArraysEXT)\n\t{\n\t\tqglLockArraysEXT(0, input->numVertexes);\n\t\tGLimp_LogComment( \"glLockArraysEXT\\n\" );\n\t}\n\n\t//\n\t// enable color and texcoord arrays after the lock if necessary\n\t//\n\tif ( !setArraysOnce )\n\t{\n\t\tqglEnableClientState( GL_TEXTURE_COORD_ARRAY );\n\t\tqglEnableClientState( GL_COLOR_ARRAY );\n\t}\n\n\t//\n\t// call shader function\n\t//\n\tRB_IterateStagesGeneric( input );\n\n\t// \n\t// now do any dynamic lighting needed\n\t//\n\tif ( tess.dlightBits && tess.shader->sort <= SS_OPAQUE\n\t\t&& !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) ) {\n\t\tProjectDlightTexture();\n\t}\n\n\t//\n\t// now do fog\n\t//\n\tif ( tess.fogNum && tess.shader->fogPass ) {\n\t\tRB_FogPass();\n\t}\n\n\t// \n\t// unlock arrays\n\t//\n\tif (qglUnlockArraysEXT) \n\t{\n\t\tqglUnlockArraysEXT();\n\t\tGLimp_LogComment( \"glUnlockArraysEXT\\n\" );\n\t}\n\n\t//\n\t// reset polygon offset\n\t//\n\tif ( input->shader->polygonOffset )\n\t{\n\t\tqglDisable( GL_POLYGON_OFFSET_FILL );\n\t}\n}\n\n\n/*\n** RB_StageIteratorVertexLitTexture\n*/\nvoid RB_StageIteratorVertexLitTexture( void )\n{\n\tshaderCommands_t *input;\n\tshader_t\t\t*shader;\n\n\tinput = &tess;\n\n\tshader = input->shader;\n\n\t//\n\t// compute colors\n\t//\n\tRB_CalcDiffuseColor( ( unsigned char * ) tess.svars.colors );\n\n\t//\n\t// log this call\n\t//\n\tif ( r_logFile->integer ) \n\t{\n\t\t// don't just call LogComment, or we will get\n\t\t// a call to va() every frame!\n\t\tGLimp_LogComment( va(\"--- RB_StageIteratorVertexLitTexturedUnfogged( %s ) ---\\n\", tess.shader->name) );\n\t}\n\n\t//\n\t// set face culling appropriately\n\t//\n\tGL_Cull( input->shader->cullType );\n\n\t//\n\t// set arrays and lock\n\t//\n\tqglEnableClientState( GL_COLOR_ARRAY);\n\tqglEnableClientState( GL_TEXTURE_COORD_ARRAY);\n\n\tqglColorPointer( 4, GL_UNSIGNED_BYTE, 0, tess.svars.colors );\n\tqglTexCoordPointer( 2, GL_FLOAT, 16, tess.texCoords[0][0] );\n\tqglVertexPointer (3, GL_FLOAT, 16, input->xyz);\n\n\tif ( qglLockArraysEXT )\n\t{\n\t\tqglLockArraysEXT(0, input->numVertexes);\n\t\tGLimp_LogComment( \"glLockArraysEXT\\n\" );\n\t}\n\n\t//\n\t// call special shade routine\n\t//\n\tR_BindAnimatedImage( &tess.xstages[0]->bundle[0] );\n\tGL_State( tess.xstages[0]->stateBits );\n\tR_DrawElements( input->numIndexes, input->indexes );\n\n\t// \n\t// now do any dynamic lighting needed\n\t//\n\tif ( tess.dlightBits && tess.shader->sort <= SS_OPAQUE ) {\n\t\tProjectDlightTexture();\n\t}\n\n\t//\n\t// now do fog\n\t//\n\tif ( tess.fogNum && tess.shader->fogPass ) {\n\t\tRB_FogPass();\n\t}\n\n\t// \n\t// unlock arrays\n\t//\n\tif (qglUnlockArraysEXT) \n\t{\n\t\tqglUnlockArraysEXT();\n\t\tGLimp_LogComment( \"glUnlockArraysEXT\\n\" );\n\t}\n}\n\n//define\tREPLACE_MODE\n\nvoid RB_StageIteratorLightmappedMultitexture( void ) {\n\tshaderCommands_t *input;\n\n\tinput = &tess;\n\n\t//\n\t// log this call\n\t//\n\tif ( r_logFile->integer ) {\n\t\t// don't just call LogComment, or we will get\n\t\t// a call to va() every frame!\n\t\tGLimp_LogComment( va(\"--- RB_StageIteratorLightmappedMultitexture( %s ) ---\\n\", tess.shader->name) );\n\t}\n\n\t//\n\t// set face culling appropriately\n\t//\n\tGL_Cull( input->shader->cullType );\n\n\t//\n\t// set color, pointers, and lock\n\t//\n\tGL_State( GLS_DEFAULT );\n\tqglVertexPointer( 3, GL_FLOAT, 16, input->xyz );\n\n#ifdef REPLACE_MODE\n\tqglDisableClientState( GL_COLOR_ARRAY );\n\tqglColor3f( 1, 1, 1 );\n\tqglShadeModel( GL_FLAT );\n#else\n\tqglEnableClientState( GL_COLOR_ARRAY );\n\tqglColorPointer( 4, GL_UNSIGNED_BYTE, 0, tess.constantColor255 );\n#endif\n\n\t//\n\t// select base stage\n\t//\n\tGL_SelectTexture( 0 );\n\n\tqglEnableClientState( GL_TEXTURE_COORD_ARRAY );\n\tR_BindAnimatedImage( &tess.xstages[0]->bundle[0] );\n\tqglTexCoordPointer( 2, GL_FLOAT, 16, tess.texCoords[0][0] );\n\n\t//\n\t// configure second stage\n\t//\n\tGL_SelectTexture( 1 );\n\tqglEnable( GL_TEXTURE_2D );\n\tif ( r_lightmap->integer ) {\n\t\tGL_TexEnv( GL_REPLACE );\n\t} else {\n\t\tGL_TexEnv( GL_MODULATE );\n\t}\n\tR_BindAnimatedImage( &tess.xstages[0]->bundle[1] );\n\tqglEnableClientState( GL_TEXTURE_COORD_ARRAY );\n\tqglTexCoordPointer( 2, GL_FLOAT, 16, tess.texCoords[0][1] );\n\n\t//\n\t// lock arrays\n\t//\n\tif ( qglLockArraysEXT ) {\n\t\tqglLockArraysEXT(0, input->numVertexes);\n\t\tGLimp_LogComment( \"glLockArraysEXT\\n\" );\n\t}\n\n\tR_DrawElements( input->numIndexes, input->indexes );\n\n\t//\n\t// disable texturing on TEXTURE1, then select TEXTURE0\n\t//\n\tqglDisable( GL_TEXTURE_2D );\n\tqglDisableClientState( GL_TEXTURE_COORD_ARRAY );\n\n\tGL_SelectTexture( 0 );\n#ifdef REPLACE_MODE\n\tGL_TexEnv( GL_MODULATE );\n\tqglShadeModel( GL_SMOOTH );\n#endif\n\n\t// \n\t// now do any dynamic lighting needed\n\t//\n\tif ( tess.dlightBits && tess.shader->sort <= SS_OPAQUE ) {\n\t\tProjectDlightTexture();\n\t}\n\n\t//\n\t// now do fog\n\t//\n\tif ( tess.fogNum && tess.shader->fogPass ) {\n\t\tRB_FogPass();\n\t}\n\n\t//\n\t// unlock arrays\n\t//\n\tif ( qglUnlockArraysEXT ) {\n\t\tqglUnlockArraysEXT();\n\t\tGLimp_LogComment( \"glUnlockArraysEXT\\n\" );\n\t}\n}\n\n/*\n** RB_EndSurface\n*/\nvoid RB_EndSurface( void ) {\n\tshaderCommands_t *input;\n\n\tinput = &tess;\n\n\tif (input->numIndexes == 0) {\n\t\treturn;\n\t}\n\n\tif (input->indexes[SHADER_MAX_INDEXES-1] != 0) {\n\t\tri.Error (ERR_DROP, \"RB_EndSurface() - SHADER_MAX_INDEXES hit\");\n\t}\t\n\tif (input->xyz[SHADER_MAX_VERTEXES-1][0] != 0) {\n\t\tri.Error (ERR_DROP, \"RB_EndSurface() - SHADER_MAX_VERTEXES hit\");\n\t}\n\n\tif ( tess.shader == tr.shadowShader ) {\n\t\tRB_ShadowTessEnd();\n\t\treturn;\n\t}\n\n\t// for debugging of sort order issues, stop rendering after a given sort value\n\tif ( r_debugSort->integer && r_debugSort->integer < tess.shader->sort ) {\n\t\treturn;\n\t}\n\n\t//\n\t// update performance counters\n\t//\n\tbackEnd.pc.c_shaders++;\n\tbackEnd.pc.c_vertexes += tess.numVertexes;\n\tbackEnd.pc.c_indexes += tess.numIndexes;\n\tbackEnd.pc.c_totalIndexes += tess.numIndexes * tess.numPasses;\n\n\t//\n\t// call off to shader specific tess end function\n\t//\n\ttess.currentStageIteratorFunc();\n\n\t//\n\t// draw debugging stuff\n\t//\n\tif ( r_showtris->integer ) {\n\t\tDrawTris (input);\n\t}\n\tif ( r_shownormals->integer ) {\n\t\tDrawNormals (input);\n\t}\n\t// clear shader so we can tell we don't have any unclosed surfaces\n\ttess.numIndexes = 0;\n\n\tGLimp_LogComment( \"----------\\n\" );\n}\n\n"
  },
  {
    "path": "code/renderer/tr_shade_calc.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// tr_shade_calc.c\n\n#include \"tr_local.h\"\n\n\n#define\tWAVEVALUE( table, base, amplitude, phase, freq )  ((base) + table[ myftol( ( ( (phase) + tess.shaderTime * (freq) ) * FUNCTABLE_SIZE ) ) & FUNCTABLE_MASK ] * (amplitude))\n\nstatic float *TableForFunc( genFunc_t func ) \n{\n\tswitch ( func )\n\t{\n\tcase GF_SIN:\n\t\treturn tr.sinTable;\n\tcase GF_TRIANGLE:\n\t\treturn tr.triangleTable;\n\tcase GF_SQUARE:\n\t\treturn tr.squareTable;\n\tcase GF_SAWTOOTH:\n\t\treturn tr.sawToothTable;\n\tcase GF_INVERSE_SAWTOOTH:\n\t\treturn tr.inverseSawToothTable;\n\tcase GF_NONE:\n\tdefault:\n\t\tbreak;\n\t}\n\n\tri.Error( ERR_DROP, \"TableForFunc called with invalid function '%d' in shader '%s'\\n\", func, tess.shader->name );\n\treturn NULL;\n}\n\n/*\n** EvalWaveForm\n**\n** Evaluates a given waveForm_t, referencing backEnd.refdef.time directly\n*/\nstatic float EvalWaveForm( const waveForm_t *wf ) \n{\n\tfloat\t*table;\n\n\ttable = TableForFunc( wf->func );\n\n\treturn WAVEVALUE( table, wf->base, wf->amplitude, wf->phase, wf->frequency );\n}\n\nstatic float EvalWaveFormClamped( const waveForm_t *wf )\n{\n\tfloat glow  = EvalWaveForm( wf );\n\n\tif ( glow < 0 )\n\t{\n\t\treturn 0;\n\t}\n\n\tif ( glow > 1 )\n\t{\n\t\treturn 1;\n\t}\n\n\treturn glow;\n}\n\n/*\n** RB_CalcStretchTexCoords\n*/\nvoid RB_CalcStretchTexCoords( const waveForm_t *wf, float *st )\n{\n\tfloat p;\n\ttexModInfo_t tmi;\n\n\tp = 1.0f / EvalWaveForm( wf );\n\n\ttmi.matrix[0][0] = p;\n\ttmi.matrix[1][0] = 0;\n\ttmi.translate[0] = 0.5f - 0.5f * p;\n\n\ttmi.matrix[0][1] = 0;\n\ttmi.matrix[1][1] = p;\n\ttmi.translate[1] = 0.5f - 0.5f * p;\n\n\tRB_CalcTransformTexCoords( &tmi, st );\n}\n\n/*\n====================================================================\n\nDEFORMATIONS\n\n====================================================================\n*/\n\n/*\n========================\nRB_CalcDeformVertexes\n\n========================\n*/\nvoid RB_CalcDeformVertexes( deformStage_t *ds )\n{\n\tint i;\n\tvec3_t\toffset;\n\tfloat\tscale;\n\tfloat\t*xyz = ( float * ) tess.xyz;\n\tfloat\t*normal = ( float * ) tess.normal;\n\tfloat\t*table;\n\n\tif ( ds->deformationWave.frequency == 0 )\n\t{\n\t\tscale = EvalWaveForm( &ds->deformationWave );\n\n\t\tfor ( i = 0; i < tess.numVertexes; i++, xyz += 4, normal += 4 )\n\t\t{\n\t\t\tVectorScale( normal, scale, offset );\n\t\t\t\n\t\t\txyz[0] += offset[0];\n\t\t\txyz[1] += offset[1];\n\t\t\txyz[2] += offset[2];\n\t\t}\n\t}\n\telse\n\t{\n\t\ttable = TableForFunc( ds->deformationWave.func );\n\n\t\tfor ( i = 0; i < tess.numVertexes; i++, xyz += 4, normal += 4 )\n\t\t{\n\t\t\tfloat off = ( xyz[0] + xyz[1] + xyz[2] ) * ds->deformationSpread;\n\n\t\t\tscale = WAVEVALUE( table, ds->deformationWave.base, \n\t\t\t\tds->deformationWave.amplitude,\n\t\t\t\tds->deformationWave.phase + off,\n\t\t\t\tds->deformationWave.frequency );\n\n\t\t\tVectorScale( normal, scale, offset );\n\t\t\t\n\t\t\txyz[0] += offset[0];\n\t\t\txyz[1] += offset[1];\n\t\t\txyz[2] += offset[2];\n\t\t}\n\t}\n}\n\n/*\n=========================\nRB_CalcDeformNormals\n\nWiggle the normals for wavy environment mapping\n=========================\n*/\nvoid RB_CalcDeformNormals( deformStage_t *ds ) {\n\tint i;\n\tfloat\tscale;\n\tfloat\t*xyz = ( float * ) tess.xyz;\n\tfloat\t*normal = ( float * ) tess.normal;\n\n\tfor ( i = 0; i < tess.numVertexes; i++, xyz += 4, normal += 4 ) {\n\t\tscale = 0.98f;\n\t\tscale = R_NoiseGet4f( xyz[0] * scale, xyz[1] * scale, xyz[2] * scale,\n\t\t\ttess.shaderTime * ds->deformationWave.frequency );\n\t\tnormal[ 0 ] += ds->deformationWave.amplitude * scale;\n\n\t\tscale = 0.98f;\n\t\tscale = R_NoiseGet4f( 100 + xyz[0] * scale, xyz[1] * scale, xyz[2] * scale,\n\t\t\ttess.shaderTime * ds->deformationWave.frequency );\n\t\tnormal[ 1 ] += ds->deformationWave.amplitude * scale;\n\n\t\tscale = 0.98f;\n\t\tscale = R_NoiseGet4f( 200 + xyz[0] * scale, xyz[1] * scale, xyz[2] * scale,\n\t\t\ttess.shaderTime * ds->deformationWave.frequency );\n\t\tnormal[ 2 ] += ds->deformationWave.amplitude * scale;\n\n\t\tVectorNormalizeFast( normal );\n\t}\n}\n\n/*\n========================\nRB_CalcBulgeVertexes\n\n========================\n*/\nvoid RB_CalcBulgeVertexes( deformStage_t *ds ) {\n\tint i;\n\tconst float *st = ( const float * ) tess.texCoords[0];\n\tfloat\t\t*xyz = ( float * ) tess.xyz;\n\tfloat\t\t*normal = ( float * ) tess.normal;\n\tfloat\t\tnow;\n\n\tnow = backEnd.refdef.time * ds->bulgeSpeed * 0.001f;\n\n\tfor ( i = 0; i < tess.numVertexes; i++, xyz += 4, st += 4, normal += 4 ) {\n\t\tint\t\toff;\n\t\tfloat scale;\n\n\t\toff = (float)( FUNCTABLE_SIZE / (M_PI*2) ) * ( st[0] * ds->bulgeWidth + now );\n\n\t\tscale = tr.sinTable[ off & FUNCTABLE_MASK ] * ds->bulgeHeight;\n\t\t\t\n\t\txyz[0] += normal[0] * scale;\n\t\txyz[1] += normal[1] * scale;\n\t\txyz[2] += normal[2] * scale;\n\t}\n}\n\n\n/*\n======================\nRB_CalcMoveVertexes\n\nA deformation that can move an entire surface along a wave path\n======================\n*/\nvoid RB_CalcMoveVertexes( deformStage_t *ds ) {\n\tint\t\t\ti;\n\tfloat\t\t*xyz;\n\tfloat\t\t*table;\n\tfloat\t\tscale;\n\tvec3_t\t\toffset;\n\n\ttable = TableForFunc( ds->deformationWave.func );\n\n\tscale = WAVEVALUE( table, ds->deformationWave.base, \n\t\tds->deformationWave.amplitude,\n\t\tds->deformationWave.phase,\n\t\tds->deformationWave.frequency );\n\n\tVectorScale( ds->moveVector, scale, offset );\n\n\txyz = ( float * ) tess.xyz;\n\tfor ( i = 0; i < tess.numVertexes; i++, xyz += 4 ) {\n\t\tVectorAdd( xyz, offset, xyz );\n\t}\n}\n\n\n/*\n=============\nDeformText\n\nChange a polygon into a bunch of text polygons\n=============\n*/\nvoid DeformText( const char *text ) {\n\tint\t\ti;\n\tvec3_t\torigin, width, height;\n\tint\t\tlen;\n\tint\t\tch;\n\tbyte\tcolor[4];\n\tfloat\tbottom, top;\n\tvec3_t\tmid;\n\n\theight[0] = 0;\n\theight[1] = 0;\n\theight[2] = -1;\n\tCrossProduct( tess.normal[0], height, width );\n\n\t// find the midpoint of the box\n\tVectorClear( mid );\n\tbottom = 999999;\n\ttop = -999999;\n\tfor ( i = 0 ; i < 4 ; i++ ) {\n\t\tVectorAdd( tess.xyz[i], mid, mid );\n\t\tif ( tess.xyz[i][2] < bottom ) {\n\t\t\tbottom = tess.xyz[i][2];\n\t\t}\n\t\tif ( tess.xyz[i][2] > top ) {\n\t\t\ttop = tess.xyz[i][2];\n\t\t}\n\t}\n\tVectorScale( mid, 0.25f, origin );\n\n\t// determine the individual character size\n\theight[0] = 0;\n\theight[1] = 0;\n\theight[2] = ( top - bottom ) * 0.5f;\n\n\tVectorScale( width, height[2] * -0.75f, width );\n\n\t// determine the starting position\n\tlen = strlen( text );\n\tVectorMA( origin, (len-1), width, origin );\n\n\t// clear the shader indexes\n\ttess.numIndexes = 0;\n\ttess.numVertexes = 0;\n\n\tcolor[0] = color[1] = color[2] = color[3] = 255;\n\n\t// draw each character\n\tfor ( i = 0 ; i < len ; i++ ) {\n\t\tch = text[i];\n\t\tch &= 255;\n\n\t\tif ( ch != ' ' ) {\n\t\t\tint\t\trow, col;\n\t\t\tfloat\tfrow, fcol, size;\n\n\t\t\trow = ch>>4;\n\t\t\tcol = ch&15;\n\n\t\t\tfrow = row*0.0625f;\n\t\t\tfcol = col*0.0625f;\n\t\t\tsize = 0.0625f;\n\n\t\t\tRB_AddQuadStampExt( origin, width, height, color, fcol, frow, fcol + size, frow + size );\n\t\t}\n\t\tVectorMA( origin, -2, width, origin );\n\t}\n}\n\n/*\n==================\nGlobalVectorToLocal\n==================\n*/\nstatic void GlobalVectorToLocal( const vec3_t in, vec3_t out ) {\n\tout[0] = DotProduct( in, backEnd.or.axis[0] );\n\tout[1] = DotProduct( in, backEnd.or.axis[1] );\n\tout[2] = DotProduct( in, backEnd.or.axis[2] );\n}\n\n/*\n=====================\nAutospriteDeform\n\nAssuming all the triangles for this shader are independant\nquads, rebuild them as forward facing sprites\n=====================\n*/\nstatic void AutospriteDeform( void ) {\n\tint\t\ti;\n\tint\t\toldVerts;\n\tfloat\t*xyz;\n\tvec3_t\tmid, delta;\n\tfloat\tradius;\n\tvec3_t\tleft, up;\n\tvec3_t\tleftDir, upDir;\n\n\tif ( tess.numVertexes & 3 ) {\n\t\tri.Printf( PRINT_WARNING, \"Autosprite shader %s had odd vertex count\", tess.shader->name );\n\t}\n\tif ( tess.numIndexes != ( tess.numVertexes >> 2 ) * 6 ) {\n\t\tri.Printf( PRINT_WARNING, \"Autosprite shader %s had odd index count\", tess.shader->name );\n\t}\n\n\toldVerts = tess.numVertexes;\n\ttess.numVertexes = 0;\n\ttess.numIndexes = 0;\n\n\tif ( backEnd.currentEntity != &tr.worldEntity ) {\n\t\tGlobalVectorToLocal( backEnd.viewParms.or.axis[1], leftDir );\n\t\tGlobalVectorToLocal( backEnd.viewParms.or.axis[2], upDir );\n\t} else {\n\t\tVectorCopy( backEnd.viewParms.or.axis[1], leftDir );\n\t\tVectorCopy( backEnd.viewParms.or.axis[2], upDir );\n\t}\n\n\tfor ( i = 0 ; i < oldVerts ; i+=4 ) {\n\t\t// find the midpoint\n\t\txyz = tess.xyz[i];\n\n\t\tmid[0] = 0.25f * (xyz[0] + xyz[4] + xyz[8] + xyz[12]);\n\t\tmid[1] = 0.25f * (xyz[1] + xyz[5] + xyz[9] + xyz[13]);\n\t\tmid[2] = 0.25f * (xyz[2] + xyz[6] + xyz[10] + xyz[14]);\n\n\t\tVectorSubtract( xyz, mid, delta );\n\t\tradius = VectorLength( delta ) * 0.707f;\t\t// / sqrt(2)\n\n\t\tVectorScale( leftDir, radius, left );\n\t\tVectorScale( upDir, radius, up );\n\n\t\tif ( backEnd.viewParms.isMirror ) {\n\t\t\tVectorSubtract( vec3_origin, left, left );\n\t\t}\n\n\t  // compensate for scale in the axes if necessary\n  \tif ( backEnd.currentEntity->e.nonNormalizedAxes ) {\n      float axisLength;\n\t\t  axisLength = VectorLength( backEnd.currentEntity->e.axis[0] );\n  \t\tif ( !axisLength ) {\n\t  \t\taxisLength = 0;\n  \t\t} else {\n\t  \t\taxisLength = 1.0f / axisLength;\n  \t\t}\n      VectorScale(left, axisLength, left);\n      VectorScale(up, axisLength, up);\n    }\n\n\t\tRB_AddQuadStamp( mid, left, up, tess.vertexColors[i] );\n\t}\n}\n\n\n/*\n=====================\nAutosprite2Deform\n\nAutosprite2 will pivot a rectangular quad along the center of its long axis\n=====================\n*/\nint edgeVerts[6][2] = {\n\t{ 0, 1 },\n\t{ 0, 2 },\n\t{ 0, 3 },\n\t{ 1, 2 },\n\t{ 1, 3 },\n\t{ 2, 3 }\n};\n\nstatic void Autosprite2Deform( void ) {\n\tint\t\ti, j, k;\n\tint\t\tindexes;\n\tfloat\t*xyz;\n\tvec3_t\tforward;\n\n\tif ( tess.numVertexes & 3 ) {\n\t\tri.Printf( PRINT_WARNING, \"Autosprite2 shader %s had odd vertex count\", tess.shader->name );\n\t}\n\tif ( tess.numIndexes != ( tess.numVertexes >> 2 ) * 6 ) {\n\t\tri.Printf( PRINT_WARNING, \"Autosprite2 shader %s had odd index count\", tess.shader->name );\n\t}\n\n\tif ( backEnd.currentEntity != &tr.worldEntity ) {\n\t\tGlobalVectorToLocal( backEnd.viewParms.or.axis[0], forward );\n\t} else {\n\t\tVectorCopy( backEnd.viewParms.or.axis[0], forward );\n\t}\n\n\t// this is a lot of work for two triangles...\n\t// we could precalculate a lot of it is an issue, but it would mess up\n\t// the shader abstraction\n\tfor ( i = 0, indexes = 0 ; i < tess.numVertexes ; i+=4, indexes+=6 ) {\n\t\tfloat\tlengths[2];\n\t\tint\t\tnums[2];\n\t\tvec3_t\tmid[2];\n\t\tvec3_t\tmajor, minor;\n\t\tfloat\t*v1, *v2;\n\n\t\t// find the midpoint\n\t\txyz = tess.xyz[i];\n\n\t\t// identify the two shortest edges\n\t\tnums[0] = nums[1] = 0;\n\t\tlengths[0] = lengths[1] = 999999;\n\n\t\tfor ( j = 0 ; j < 6 ; j++ ) {\n\t\t\tfloat\tl;\n\t\t\tvec3_t\ttemp;\n\n\t\t\tv1 = xyz + 4 * edgeVerts[j][0];\n\t\t\tv2 = xyz + 4 * edgeVerts[j][1];\n\n\t\t\tVectorSubtract( v1, v2, temp );\n\t\t\t\n\t\t\tl = DotProduct( temp, temp );\n\t\t\tif ( l < lengths[0] ) {\n\t\t\t\tnums[1] = nums[0];\n\t\t\t\tlengths[1] = lengths[0];\n\t\t\t\tnums[0] = j;\n\t\t\t\tlengths[0] = l;\n\t\t\t} else if ( l < lengths[1] ) {\n\t\t\t\tnums[1] = j;\n\t\t\t\tlengths[1] = l;\n\t\t\t}\n\t\t}\n\n\t\tfor ( j = 0 ; j < 2 ; j++ ) {\n\t\t\tv1 = xyz + 4 * edgeVerts[nums[j]][0];\n\t\t\tv2 = xyz + 4 * edgeVerts[nums[j]][1];\n\n\t\t\tmid[j][0] = 0.5f * (v1[0] + v2[0]);\n\t\t\tmid[j][1] = 0.5f * (v1[1] + v2[1]);\n\t\t\tmid[j][2] = 0.5f * (v1[2] + v2[2]);\n\t\t}\n\n\t\t// find the vector of the major axis\n\t\tVectorSubtract( mid[1], mid[0], major );\n\n\t\t// cross this with the view direction to get minor axis\n\t\tCrossProduct( major, forward, minor );\n\t\tVectorNormalize( minor );\n\t\t\n\t\t// re-project the points\n\t\tfor ( j = 0 ; j < 2 ; j++ ) {\n\t\t\tfloat\tl;\n\n\t\t\tv1 = xyz + 4 * edgeVerts[nums[j]][0];\n\t\t\tv2 = xyz + 4 * edgeVerts[nums[j]][1];\n\n\t\t\tl = 0.5 * sqrt( lengths[j] );\n\t\t\t\n\t\t\t// we need to see which direction this edge\n\t\t\t// is used to determine direction of projection\n\t\t\tfor ( k = 0 ; k < 5 ; k++ ) {\n\t\t\t\tif ( tess.indexes[ indexes + k ] == i + edgeVerts[nums[j]][0]\n\t\t\t\t\t&& tess.indexes[ indexes + k + 1 ] == i + edgeVerts[nums[j]][1] ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( k == 5 ) {\n\t\t\t\tVectorMA( mid[j], l, minor, v1 );\n\t\t\t\tVectorMA( mid[j], -l, minor, v2 );\n\t\t\t} else {\n\t\t\t\tVectorMA( mid[j], -l, minor, v1 );\n\t\t\t\tVectorMA( mid[j], l, minor, v2 );\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n/*\n=====================\nRB_DeformTessGeometry\n\n=====================\n*/\nvoid RB_DeformTessGeometry( void ) {\n\tint\t\ti;\n\tdeformStage_t\t*ds;\n\n\tfor ( i = 0 ; i < tess.shader->numDeforms ; i++ ) {\n\t\tds = &tess.shader->deforms[ i ];\n\n\t\tswitch ( ds->deformation ) {\n        case DEFORM_NONE:\n            break;\n\t\tcase DEFORM_NORMALS:\n\t\t\tRB_CalcDeformNormals( ds );\n\t\t\tbreak;\n\t\tcase DEFORM_WAVE:\n\t\t\tRB_CalcDeformVertexes( ds );\n\t\t\tbreak;\n\t\tcase DEFORM_BULGE:\n\t\t\tRB_CalcBulgeVertexes( ds );\n\t\t\tbreak;\n\t\tcase DEFORM_MOVE:\n\t\t\tRB_CalcMoveVertexes( ds );\n\t\t\tbreak;\n\t\tcase DEFORM_PROJECTION_SHADOW:\n\t\t\tRB_ProjectionShadowDeform();\n\t\t\tbreak;\n\t\tcase DEFORM_AUTOSPRITE:\n\t\t\tAutospriteDeform();\n\t\t\tbreak;\n\t\tcase DEFORM_AUTOSPRITE2:\n\t\t\tAutosprite2Deform();\n\t\t\tbreak;\n\t\tcase DEFORM_TEXT0:\n\t\tcase DEFORM_TEXT1:\n\t\tcase DEFORM_TEXT2:\n\t\tcase DEFORM_TEXT3:\n\t\tcase DEFORM_TEXT4:\n\t\tcase DEFORM_TEXT5:\n\t\tcase DEFORM_TEXT6:\n\t\tcase DEFORM_TEXT7:\n\t\t\tDeformText( backEnd.refdef.text[ds->deformation - DEFORM_TEXT0] );\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/*\n====================================================================\n\nCOLORS\n\n====================================================================\n*/\n\n\n/*\n** RB_CalcColorFromEntity\n*/\nvoid RB_CalcColorFromEntity( unsigned char *dstColors )\n{\n\tint\ti;\n\tint *pColors = ( int * ) dstColors;\n\tint c;\n\n\tif ( !backEnd.currentEntity )\n\t\treturn;\n\n\tc = * ( int * ) backEnd.currentEntity->e.shaderRGBA;\n\n\tfor ( i = 0; i < tess.numVertexes; i++, pColors++ )\n\t{\n\t\t*pColors = c;\n\t}\n}\n\n/*\n** RB_CalcColorFromOneMinusEntity\n*/\nvoid RB_CalcColorFromOneMinusEntity( unsigned char *dstColors )\n{\n\tint\ti;\n\tint *pColors = ( int * ) dstColors;\n\tunsigned char invModulate[3];\n\tint c;\n\n\tif ( !backEnd.currentEntity )\n\t\treturn;\n\n\tinvModulate[0] = 255 - backEnd.currentEntity->e.shaderRGBA[0];\n\tinvModulate[1] = 255 - backEnd.currentEntity->e.shaderRGBA[1];\n\tinvModulate[2] = 255 - backEnd.currentEntity->e.shaderRGBA[2];\n\tinvModulate[3] = 255 - backEnd.currentEntity->e.shaderRGBA[3];\t// this trashes alpha, but the AGEN block fixes it\n\n\tc = * ( int * ) invModulate;\n\n\tfor ( i = 0; i < tess.numVertexes; i++, pColors++ )\n\t{\n\t\t*pColors = * ( int * ) invModulate;\n\t}\n}\n\n/*\n** RB_CalcAlphaFromEntity\n*/\nvoid RB_CalcAlphaFromEntity( unsigned char *dstColors )\n{\n\tint\ti;\n\n\tif ( !backEnd.currentEntity )\n\t\treturn;\n\n\tdstColors += 3;\n\n\tfor ( i = 0; i < tess.numVertexes; i++, dstColors += 4 )\n\t{\n\t\t*dstColors = backEnd.currentEntity->e.shaderRGBA[3];\n\t}\n}\n\n/*\n** RB_CalcAlphaFromOneMinusEntity\n*/\nvoid RB_CalcAlphaFromOneMinusEntity( unsigned char *dstColors )\n{\n\tint\ti;\n\n\tif ( !backEnd.currentEntity )\n\t\treturn;\n\n\tdstColors += 3;\n\n\tfor ( i = 0; i < tess.numVertexes; i++, dstColors += 4 )\n\t{\n\t\t*dstColors = 0xff - backEnd.currentEntity->e.shaderRGBA[3];\n\t}\n}\n\n/*\n** RB_CalcWaveColor\n*/\nvoid RB_CalcWaveColor( const waveForm_t *wf, unsigned char *dstColors )\n{\n\tint i;\n\tint v;\n\tfloat glow;\n\tint *colors = ( int * ) dstColors;\n\tbyte\tcolor[4];\n\n\n  if ( wf->func == GF_NOISE ) {\n\t\tglow = wf->base + R_NoiseGet4f( 0, 0, 0, ( tess.shaderTime + wf->phase ) * wf->frequency ) * wf->amplitude;\n\t} else {\n\t\tglow = EvalWaveForm( wf ) * tr.identityLight;\n\t}\n\t\n\tif ( glow < 0 ) {\n\t\tglow = 0;\n\t}\n\telse if ( glow > 1 ) {\n\t\tglow = 1;\n\t}\n\n\tv = myftol( 255 * glow );\n\tcolor[0] = color[1] = color[2] = v;\n\tcolor[3] = 255;\n\tv = *(int *)color;\n\t\n\tfor ( i = 0; i < tess.numVertexes; i++, colors++ ) {\n\t\t*colors = v;\n\t}\n}\n\n/*\n** RB_CalcWaveAlpha\n*/\nvoid RB_CalcWaveAlpha( const waveForm_t *wf, unsigned char *dstColors )\n{\n\tint i;\n\tint v;\n\tfloat glow;\n\n\tglow = EvalWaveFormClamped( wf );\n\n\tv = 255 * glow;\n\n\tfor ( i = 0; i < tess.numVertexes; i++, dstColors += 4 )\n\t{\n\t\tdstColors[3] = v;\n\t}\n}\n\n/*\n** RB_CalcModulateColorsByFog\n*/\nvoid RB_CalcModulateColorsByFog( unsigned char *colors ) {\n\tint\t\ti;\n\tfloat\ttexCoords[SHADER_MAX_VERTEXES][2];\n\n\t// calculate texcoords so we can derive density\n\t// this is not wasted, because it would only have\n\t// been previously called if the surface was opaque\n\tRB_CalcFogTexCoords( texCoords[0] );\n\n\tfor ( i = 0; i < tess.numVertexes; i++, colors += 4 ) {\n\t\tfloat f = 1.0 - R_FogFactor( texCoords[i][0], texCoords[i][1] );\n\t\tcolors[0] *= f;\n\t\tcolors[1] *= f;\n\t\tcolors[2] *= f;\n\t}\n}\n\n/*\n** RB_CalcModulateAlphasByFog\n*/\nvoid RB_CalcModulateAlphasByFog( unsigned char *colors ) {\n\tint\t\ti;\n\tfloat\ttexCoords[SHADER_MAX_VERTEXES][2];\n\n\t// calculate texcoords so we can derive density\n\t// this is not wasted, because it would only have\n\t// been previously called if the surface was opaque\n\tRB_CalcFogTexCoords( texCoords[0] );\n\n\tfor ( i = 0; i < tess.numVertexes; i++, colors += 4 ) {\n\t\tfloat f = 1.0 - R_FogFactor( texCoords[i][0], texCoords[i][1] );\n\t\tcolors[3] *= f;\n\t}\n}\n\n/*\n** RB_CalcModulateRGBAsByFog\n*/\nvoid RB_CalcModulateRGBAsByFog( unsigned char *colors ) {\n\tint\t\ti;\n\tfloat\ttexCoords[SHADER_MAX_VERTEXES][2];\n\n\t// calculate texcoords so we can derive density\n\t// this is not wasted, because it would only have\n\t// been previously called if the surface was opaque\n\tRB_CalcFogTexCoords( texCoords[0] );\n\n\tfor ( i = 0; i < tess.numVertexes; i++, colors += 4 ) {\n\t\tfloat f = 1.0 - R_FogFactor( texCoords[i][0], texCoords[i][1] );\n\t\tcolors[0] *= f;\n\t\tcolors[1] *= f;\n\t\tcolors[2] *= f;\n\t\tcolors[3] *= f;\n\t}\n}\n\n\n/*\n====================================================================\n\nTEX COORDS\n\n====================================================================\n*/\n\n/*\n========================\nRB_CalcFogTexCoords\n\nTo do the clipped fog plane really correctly, we should use\nprojected textures, but I don't trust the drivers and it\ndoesn't fit our shader data.\n========================\n*/\nvoid RB_CalcFogTexCoords( float *st ) {\n\tint\t\t\ti;\n\tfloat\t\t*v;\n\tfloat\t\ts, t;\n\tfloat\t\teyeT;\n\tqboolean\teyeOutside;\n\tfog_t\t\t*fog;\n\tvec3_t\t\tlocal;\n\tvec4_t\t\tfogDistanceVector, fogDepthVector;\n\n\tfog = tr.world->fogs + tess.fogNum;\n\n\t// all fogging distance is based on world Z units\n\tVectorSubtract( backEnd.or.origin, backEnd.viewParms.or.origin, local );\n\tfogDistanceVector[0] = -backEnd.or.modelMatrix[2];\n\tfogDistanceVector[1] = -backEnd.or.modelMatrix[6];\n\tfogDistanceVector[2] = -backEnd.or.modelMatrix[10];\n\tfogDistanceVector[3] = DotProduct( local, backEnd.viewParms.or.axis[0] );\n\n\t// scale the fog vectors based on the fog's thickness\n\tfogDistanceVector[0] *= fog->tcScale;\n\tfogDistanceVector[1] *= fog->tcScale;\n\tfogDistanceVector[2] *= fog->tcScale;\n\tfogDistanceVector[3] *= fog->tcScale;\n\n\t// rotate the gradient vector for this orientation\n\tif ( fog->hasSurface ) {\n\t\tfogDepthVector[0] = fog->surface[0] * backEnd.or.axis[0][0] + \n\t\t\tfog->surface[1] * backEnd.or.axis[0][1] + fog->surface[2] * backEnd.or.axis[0][2];\n\t\tfogDepthVector[1] = fog->surface[0] * backEnd.or.axis[1][0] + \n\t\t\tfog->surface[1] * backEnd.or.axis[1][1] + fog->surface[2] * backEnd.or.axis[1][2];\n\t\tfogDepthVector[2] = fog->surface[0] * backEnd.or.axis[2][0] + \n\t\t\tfog->surface[1] * backEnd.or.axis[2][1] + fog->surface[2] * backEnd.or.axis[2][2];\n\t\tfogDepthVector[3] = -fog->surface[3] + DotProduct( backEnd.or.origin, fog->surface );\n\n\t\teyeT = DotProduct( backEnd.or.viewOrigin, fogDepthVector ) + fogDepthVector[3];\n\t} else {\n\t\teyeT = 1;\t// non-surface fog always has eye inside\n\t}\n\n\t// see if the viewpoint is outside\n\t// this is needed for clipping distance even for constant fog\n\n\tif ( eyeT < 0 ) {\n\t\teyeOutside = qtrue;\n\t} else {\n\t\teyeOutside = qfalse;\n\t}\n\n\tfogDistanceVector[3] += 1.0/512;\n\n\t// calculate density for each point\n\tfor (i = 0, v = tess.xyz[0] ; i < tess.numVertexes ; i++, v += 4) {\n\t\t// calculate the length in fog\n\t\ts = DotProduct( v, fogDistanceVector ) + fogDistanceVector[3];\n\t\tt = DotProduct( v, fogDepthVector ) + fogDepthVector[3];\n\n\t\t// partially clipped fogs use the T axis\t\t\n\t\tif ( eyeOutside ) {\n\t\t\tif ( t < 1.0 ) {\n\t\t\t\tt = 1.0/32;\t// point is outside, so no fogging\n\t\t\t} else {\n\t\t\t\tt = 1.0/32 + 30.0/32 * t / ( t - eyeT );\t// cut the distance at the fog plane\n\t\t\t}\n\t\t} else {\n\t\t\tif ( t < 0 ) {\n\t\t\t\tt = 1.0/32;\t// point is outside, so no fogging\n\t\t\t} else {\n\t\t\t\tt = 31.0/32;\n\t\t\t}\n\t\t}\n\n\t\tst[0] = s;\n\t\tst[1] = t;\n\t\tst += 2;\n\t}\n}\n\n\n\n/*\n** RB_CalcEnvironmentTexCoords\n*/\nvoid RB_CalcEnvironmentTexCoords( float *st ) \n{\n\tint\t\t\ti;\n\tfloat\t\t*v, *normal;\n\tvec3_t\t\tviewer, reflected;\n\tfloat\t\td;\n\n\tv = tess.xyz[0];\n\tnormal = tess.normal[0];\n\n\tfor (i = 0 ; i < tess.numVertexes ; i++, v += 4, normal += 4, st += 2 ) \n\t{\n\t\tVectorSubtract (backEnd.or.viewOrigin, v, viewer);\n\t\tVectorNormalizeFast (viewer);\n\n\t\td = DotProduct (normal, viewer);\n\n\t\treflected[0] = normal[0]*2*d - viewer[0];\n\t\treflected[1] = normal[1]*2*d - viewer[1];\n\t\treflected[2] = normal[2]*2*d - viewer[2];\n\n\t\tst[0] = 0.5 + reflected[1] * 0.5;\n\t\tst[1] = 0.5 - reflected[2] * 0.5;\n\t}\n}\n\n/*\n** RB_CalcTurbulentTexCoords\n*/\nvoid RB_CalcTurbulentTexCoords( const waveForm_t *wf, float *st )\n{\n\tint i;\n\tfloat now;\n\n\tnow = ( wf->phase + tess.shaderTime * wf->frequency );\n\n\tfor ( i = 0; i < tess.numVertexes; i++, st += 2 )\n\t{\n\t\tfloat s = st[0];\n\t\tfloat t = st[1];\n\n\t\tst[0] = s + tr.sinTable[ ( ( int ) ( ( ( tess.xyz[i][0] + tess.xyz[i][2] )* 1.0/128 * 0.125 + now ) * FUNCTABLE_SIZE ) ) & ( FUNCTABLE_MASK ) ] * wf->amplitude;\n\t\tst[1] = t + tr.sinTable[ ( ( int ) ( ( tess.xyz[i][1] * 1.0/128 * 0.125 + now ) * FUNCTABLE_SIZE ) ) & ( FUNCTABLE_MASK ) ] * wf->amplitude;\n\t}\n}\n\n/*\n** RB_CalcScaleTexCoords\n*/\nvoid RB_CalcScaleTexCoords( const float scale[2], float *st )\n{\n\tint i;\n\n\tfor ( i = 0; i < tess.numVertexes; i++, st += 2 )\n\t{\n\t\tst[0] *= scale[0];\n\t\tst[1] *= scale[1];\n\t}\n}\n\n/*\n** RB_CalcScrollTexCoords\n*/\nvoid RB_CalcScrollTexCoords( const float scrollSpeed[2], float *st )\n{\n\tint i;\n\tfloat timeScale = tess.shaderTime;\n\tfloat adjustedScrollS, adjustedScrollT;\n\n\tadjustedScrollS = scrollSpeed[0] * timeScale;\n\tadjustedScrollT = scrollSpeed[1] * timeScale;\n\n\t// clamp so coordinates don't continuously get larger, causing problems\n\t// with hardware limits\n\tadjustedScrollS = adjustedScrollS - floor( adjustedScrollS );\n\tadjustedScrollT = adjustedScrollT - floor( adjustedScrollT );\n\n\tfor ( i = 0; i < tess.numVertexes; i++, st += 2 )\n\t{\n\t\tst[0] += adjustedScrollS;\n\t\tst[1] += adjustedScrollT;\n\t}\n}\n\n/*\n** RB_CalcTransformTexCoords\n*/\nvoid RB_CalcTransformTexCoords( const texModInfo_t *tmi, float *st  )\n{\n\tint i;\n\n\tfor ( i = 0; i < tess.numVertexes; i++, st += 2 )\n\t{\n\t\tfloat s = st[0];\n\t\tfloat t = st[1];\n\n\t\tst[0] = s * tmi->matrix[0][0] + t * tmi->matrix[1][0] + tmi->translate[0];\n\t\tst[1] = s * tmi->matrix[0][1] + t * tmi->matrix[1][1] + tmi->translate[1];\n\t}\n}\n\n/*\n** RB_CalcRotateTexCoords\n*/\nvoid RB_CalcRotateTexCoords( float degsPerSecond, float *st )\n{\n\tfloat timeScale = tess.shaderTime;\n\tfloat degs;\n\tint index;\n\tfloat sinValue, cosValue;\n\ttexModInfo_t tmi;\n\n\tdegs = -degsPerSecond * timeScale;\n\tindex = degs * ( FUNCTABLE_SIZE / 360.0f );\n\n\tsinValue = tr.sinTable[ index & FUNCTABLE_MASK ];\n\tcosValue = tr.sinTable[ ( index + FUNCTABLE_SIZE / 4 ) & FUNCTABLE_MASK ];\n\n\ttmi.matrix[0][0] = cosValue;\n\ttmi.matrix[1][0] = -sinValue;\n\ttmi.translate[0] = 0.5 - 0.5 * cosValue + 0.5 * sinValue;\n\n\ttmi.matrix[0][1] = sinValue;\n\ttmi.matrix[1][1] = cosValue;\n\ttmi.translate[1] = 0.5 - 0.5 * sinValue - 0.5 * cosValue;\n\n\tRB_CalcTransformTexCoords( &tmi, st );\n}\n\n\n\n\n\n\n#if id386 && !( (defined __linux__ || defined __FreeBSD__ ) && (defined __i386__ ) ) // rb010123\n\nlong myftol( float f ) {\n\tstatic int tmp;\n\t__asm fld f\n\t__asm fistp tmp\n\t__asm mov eax, tmp\n}\n\n#endif\n\n/*\n** RB_CalcSpecularAlpha\n**\n** Calculates specular coefficient and places it in the alpha channel\n*/\nvec3_t lightOrigin = { -960, 1980, 96 };\t\t// FIXME: track dynamically\n\nvoid RB_CalcSpecularAlpha( unsigned char *alphas ) {\n\tint\t\t\ti;\n\tfloat\t\t*v, *normal;\n\tvec3_t\t\tviewer,  reflected;\n\tfloat\t\tl, d;\n\tint\t\t\tb;\n\tvec3_t\t\tlightDir;\n\tint\t\t\tnumVertexes;\n\n\tv = tess.xyz[0];\n\tnormal = tess.normal[0];\n\n\talphas += 3;\n\n\tnumVertexes = tess.numVertexes;\n\tfor (i = 0 ; i < numVertexes ; i++, v += 4, normal += 4, alphas += 4) {\n\t\tfloat ilength;\n\n\t\tVectorSubtract( lightOrigin, v, lightDir );\n//\t\tilength = Q_rsqrt( DotProduct( lightDir, lightDir ) );\n\t\tVectorNormalizeFast( lightDir );\n\n\t\t// calculate the specular color\n\t\td = DotProduct (normal, lightDir);\n//\t\td *= ilength;\n\n\t\t// we don't optimize for the d < 0 case since this tends to\n\t\t// cause visual artifacts such as faceted \"snapping\"\n\t\treflected[0] = normal[0]*2*d - lightDir[0];\n\t\treflected[1] = normal[1]*2*d - lightDir[1];\n\t\treflected[2] = normal[2]*2*d - lightDir[2];\n\n\t\tVectorSubtract (backEnd.or.viewOrigin, v, viewer);\n\t\tilength = Q_rsqrt( DotProduct( viewer, viewer ) );\n\t\tl = DotProduct (reflected, viewer);\n\t\tl *= ilength;\n\n\t\tif (l < 0) {\n\t\t\tb = 0;\n\t\t} else {\n\t\t\tl = l*l;\n\t\t\tl = l*l;\n\t\t\tb = l * 255;\n\t\t\tif (b > 255) {\n\t\t\t\tb = 255;\n\t\t\t}\n\t\t}\n\n\t\t*alphas = b;\n\t}\n}\n\n/*\n** RB_CalcDiffuseColor\n**\n** The basic vertex lighting calc\n*/\nvoid RB_CalcDiffuseColor( unsigned char *colors )\n{\n\tint\t\t\t\ti, j;\n\tfloat\t\t\t*v, *normal;\n\tfloat\t\t\tincoming;\n\ttrRefEntity_t\t*ent;\n\tint\t\t\t\tambientLightInt;\n\tvec3_t\t\t\tambientLight;\n\tvec3_t\t\t\tlightDir;\n\tvec3_t\t\t\tdirectedLight;\n\tint\t\t\t\tnumVertexes;\n#if idppc_altivec\n\tvector unsigned char vSel = (vector unsigned char)(0x00, 0x00, 0x00, 0xff,\n\t\t\t\t\t\t\t   0x00, 0x00, 0x00, 0xff,\n\t\t\t\t\t\t\t   0x00, 0x00, 0x00, 0xff,\n\t\t\t\t\t\t\t   0x00, 0x00, 0x00, 0xff);\n\tvector float ambientLightVec;\n\tvector float directedLightVec;\n\tvector float lightDirVec;\n\tvector float normalVec0, normalVec1;\n\tvector float incomingVec0, incomingVec1, incomingVec2;\n\tvector float zero, jVec;\n\tvector signed int jVecInt;\n\tvector signed short jVecShort;\n\tvector unsigned char jVecChar, normalPerm;\n#endif\n\tent = backEnd.currentEntity;\n\tambientLightInt = ent->ambientLightInt;\n#if idppc_altivec\n\t// A lot of this could be simplified if we made sure\n\t// entities light info was 16-byte aligned.\n\tjVecChar = vec_lvsl(0, ent->ambientLight);\n\tambientLightVec = vec_ld(0, (vector float *)ent->ambientLight);\n\tjVec = vec_ld(11, (vector float *)ent->ambientLight);\n\tambientLightVec = vec_perm(ambientLightVec,jVec,jVecChar);\n\n\tjVecChar = vec_lvsl(0, ent->directedLight);\n\tdirectedLightVec = vec_ld(0,(vector float *)ent->directedLight);\n\tjVec = vec_ld(11,(vector float *)ent->directedLight);\n\tdirectedLightVec = vec_perm(directedLightVec,jVec,jVecChar);\t \n\n\tjVecChar = vec_lvsl(0, ent->lightDir);\n\tlightDirVec = vec_ld(0,(vector float *)ent->lightDir);\n\tjVec = vec_ld(11,(vector float *)ent->lightDir);\n\tlightDirVec = vec_perm(lightDirVec,jVec,jVecChar);\t \n\n\tzero = (vector float)vec_splat_s8(0);\n\tVectorCopy( ent->lightDir, lightDir );\n#else\n\tVectorCopy( ent->ambientLight, ambientLight );\n\tVectorCopy( ent->directedLight, directedLight );\n\tVectorCopy( ent->lightDir, lightDir );\n#endif\n\n\tv = tess.xyz[0];\n\tnormal = tess.normal[0];\n\n#if idppc_altivec\n\tnormalPerm = vec_lvsl(0,normal);\n#endif\n\tnumVertexes = tess.numVertexes;\n\tfor (i = 0 ; i < numVertexes ; i++, v += 4, normal += 4) {\n#if idppc_altivec\n\t\tnormalVec0 = vec_ld(0,(vector float *)normal);\n\t\tnormalVec1 = vec_ld(11,(vector float *)normal);\n\t\tnormalVec0 = vec_perm(normalVec0,normalVec1,normalPerm);\n\t\tincomingVec0 = vec_madd(normalVec0, lightDirVec, zero);\n\t\tincomingVec1 = vec_sld(incomingVec0,incomingVec0,4);\n\t\tincomingVec2 = vec_add(incomingVec0,incomingVec1);\n\t\tincomingVec1 = vec_sld(incomingVec1,incomingVec1,4);\n\t\tincomingVec2 = vec_add(incomingVec2,incomingVec1);\n\t\tincomingVec0 = vec_splat(incomingVec2,0);\n\t\tincomingVec0 = vec_max(incomingVec0,zero);\n\t\tnormalPerm = vec_lvsl(12,normal);\n\t\tjVec = vec_madd(incomingVec0, directedLightVec, ambientLightVec);\n\t\tjVecInt = vec_cts(jVec,0);\t// RGBx\n\t\tjVecShort = vec_pack(jVecInt,jVecInt);\t\t// RGBxRGBx\n\t\tjVecChar = vec_packsu(jVecShort,jVecShort);\t// RGBxRGBxRGBxRGBx\n\t\tjVecChar = vec_sel(jVecChar,vSel,vSel);\t\t// RGBARGBARGBARGBA replace alpha with 255\n\t\tvec_ste((vector unsigned int)jVecChar,0,(unsigned int *)&colors[i*4]);\t// store color\n#else\n\t\tincoming = DotProduct (normal, lightDir);\n\t\tif ( incoming <= 0 ) {\n\t\t\t*(int *)&colors[i*4] = ambientLightInt;\n\t\t\tcontinue;\n\t\t} \n\t\tj = myftol( ambientLight[0] + incoming * directedLight[0] );\n\t\tif ( j > 255 ) {\n\t\t\tj = 255;\n\t\t}\n\t\tcolors[i*4+0] = j;\n\n\t\tj = myftol( ambientLight[1] + incoming * directedLight[1] );\n\t\tif ( j > 255 ) {\n\t\t\tj = 255;\n\t\t}\n\t\tcolors[i*4+1] = j;\n\n\t\tj = myftol( ambientLight[2] + incoming * directedLight[2] );\n\t\tif ( j > 255 ) {\n\t\t\tj = 255;\n\t\t}\n\t\tcolors[i*4+2] = j;\n\n\t\tcolors[i*4+3] = 255;\n#endif\n\t}\n}\n\n"
  },
  {
    "path": "code/renderer/tr_shader.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"tr_local.h\"\n\n// tr_shader.c -- this file deals with the parsing and definition of shaders\n\nstatic char *s_shaderText;\n\n// the shader is parsed into these global variables, then copied into\n// dynamically allocated memory if it is valid.\nstatic\tshaderStage_t\tstages[MAX_SHADER_STAGES];\t\t\nstatic\tshader_t\t\tshader;\nstatic\ttexModInfo_t\ttexMods[MAX_SHADER_STAGES][TR_MAX_TEXMODS];\nstatic\tqboolean\t\tdeferLoad;\n\n#define FILE_HASH_SIZE\t\t1024\nstatic\tshader_t*\t\thashTable[FILE_HASH_SIZE];\n\n#define MAX_SHADERTEXT_HASH\t\t2048\nstatic char **shaderTextHashTable[MAX_SHADERTEXT_HASH];\n\n/*\n================\nreturn a hash value for the filename\n================\n*/\nstatic long generateHashValue( const char *fname, const int size ) {\n\tint\t\ti;\n\tlong\thash;\n\tchar\tletter;\n\n\thash = 0;\n\ti = 0;\n\twhile (fname[i] != '\\0') {\n\t\tletter = tolower(fname[i]);\n\t\tif (letter =='.') break;\t\t\t\t// don't include extension\n\t\tif (letter =='\\\\') letter = '/';\t\t// damn path names\n\t\tif (letter == PATH_SEP) letter = '/';\t\t// damn path names\n\t\thash+=(long)(letter)*(i+119);\n\t\ti++;\n\t}\n\thash = (hash ^ (hash >> 10) ^ (hash >> 20));\n\thash &= (size-1);\n\treturn hash;\n}\n\nvoid R_RemapShader(const char *shaderName, const char *newShaderName, const char *timeOffset) {\n\tchar\t\tstrippedName[MAX_QPATH];\n\tint\t\t\thash;\n\tshader_t\t*sh, *sh2;\n\tqhandle_t\th;\n\n\tsh = R_FindShaderByName( shaderName );\n\tif (sh == NULL || sh == tr.defaultShader) {\n\t\th = RE_RegisterShaderLightMap(shaderName, 0);\n\t\tsh = R_GetShaderByHandle(h);\n\t}\n\tif (sh == NULL || sh == tr.defaultShader) {\n\t\tri.Printf( PRINT_WARNING, \"WARNING: R_RemapShader: shader %s not found\\n\", shaderName );\n\t\treturn;\n\t}\n\n\tsh2 = R_FindShaderByName( newShaderName );\n\tif (sh2 == NULL || sh2 == tr.defaultShader) {\n\t\th = RE_RegisterShaderLightMap(newShaderName, 0);\n\t\tsh2 = R_GetShaderByHandle(h);\n\t}\n\n\tif (sh2 == NULL || sh2 == tr.defaultShader) {\n\t\tri.Printf( PRINT_WARNING, \"WARNING: R_RemapShader: new shader %s not found\\n\", newShaderName );\n\t\treturn;\n\t}\n\n\t// remap all the shaders with the given name\n\t// even tho they might have different lightmaps\n\tCOM_StripExtension( shaderName, strippedName );\n\thash = generateHashValue(strippedName, FILE_HASH_SIZE);\n\tfor (sh = hashTable[hash]; sh; sh = sh->next) {\n\t\tif (Q_stricmp(sh->name, strippedName) == 0) {\n\t\t\tif (sh != sh2) {\n\t\t\t\tsh->remappedShader = sh2;\n\t\t\t} else {\n\t\t\t\tsh->remappedShader = NULL;\n\t\t\t}\n\t\t}\n\t}\n\tif (timeOffset) {\n\t\tsh2->timeOffset = atof(timeOffset);\n\t}\n}\n\n/*\n===============\nParseVector\n===============\n*/\nstatic qboolean ParseVector( char **text, int count, float *v ) {\n\tchar\t*token;\n\tint\t\ti;\n\n\t// FIXME: spaces are currently required after parens, should change parseext...\n\ttoken = COM_ParseExt( text, qfalse );\n\tif ( strcmp( token, \"(\" ) ) {\n\t\tri.Printf( PRINT_WARNING, \"WARNING: missing parenthesis in shader '%s'\\n\", shader.name );\n\t\treturn qfalse;\n\t}\n\n\tfor ( i = 0 ; i < count ; i++ ) {\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( !token[0] ) {\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing vector element in shader '%s'\\n\", shader.name );\n\t\t\treturn qfalse;\n\t\t}\n\t\tv[i] = atof( token );\n\t}\n\n\ttoken = COM_ParseExt( text, qfalse );\n\tif ( strcmp( token, \")\" ) ) {\n\t\tri.Printf( PRINT_WARNING, \"WARNING: missing parenthesis in shader '%s'\\n\", shader.name );\n\t\treturn qfalse;\n\t}\n\n\treturn qtrue;\n}\n\n\n/*\n===============\nNameToAFunc\n===============\n*/\nstatic unsigned NameToAFunc( const char *funcname )\n{\t\n\tif ( !Q_stricmp( funcname, \"GT0\" ) )\n\t{\n\t\treturn GLS_ATEST_GT_0;\n\t}\n\telse if ( !Q_stricmp( funcname, \"LT128\" ) )\n\t{\n\t\treturn GLS_ATEST_LT_80;\n\t}\n\telse if ( !Q_stricmp( funcname, \"GE128\" ) )\n\t{\n\t\treturn GLS_ATEST_GE_80;\n\t}\n\n\tri.Printf( PRINT_WARNING, \"WARNING: invalid alphaFunc name '%s' in shader '%s'\\n\", funcname, shader.name );\n\treturn 0;\n}\n\n\n/*\n===============\nNameToSrcBlendMode\n===============\n*/\nstatic int NameToSrcBlendMode( const char *name )\n{\n\tif ( !Q_stricmp( name, \"GL_ONE\" ) )\n\t{\n\t\treturn GLS_SRCBLEND_ONE;\n\t}\n\telse if ( !Q_stricmp( name, \"GL_ZERO\" ) )\n\t{\n\t\treturn GLS_SRCBLEND_ZERO;\n\t}\n\telse if ( !Q_stricmp( name, \"GL_DST_COLOR\" ) )\n\t{\n\t\treturn GLS_SRCBLEND_DST_COLOR;\n\t}\n\telse if ( !Q_stricmp( name, \"GL_ONE_MINUS_DST_COLOR\" ) )\n\t{\n\t\treturn GLS_SRCBLEND_ONE_MINUS_DST_COLOR;\n\t}\n\telse if ( !Q_stricmp( name, \"GL_SRC_ALPHA\" ) )\n\t{\n\t\treturn GLS_SRCBLEND_SRC_ALPHA;\n\t}\n\telse if ( !Q_stricmp( name, \"GL_ONE_MINUS_SRC_ALPHA\" ) )\n\t{\n\t\treturn GLS_SRCBLEND_ONE_MINUS_SRC_ALPHA;\n\t}\n\telse if ( !Q_stricmp( name, \"GL_DST_ALPHA\" ) )\n\t{\n\t\treturn GLS_SRCBLEND_DST_ALPHA;\n\t}\n\telse if ( !Q_stricmp( name, \"GL_ONE_MINUS_DST_ALPHA\" ) )\n\t{\n\t\treturn GLS_SRCBLEND_ONE_MINUS_DST_ALPHA;\n\t}\n\telse if ( !Q_stricmp( name, \"GL_SRC_ALPHA_SATURATE\" ) )\n\t{\n\t\treturn GLS_SRCBLEND_ALPHA_SATURATE;\n\t}\n\n\tri.Printf( PRINT_WARNING, \"WARNING: unknown blend mode '%s' in shader '%s', substituting GL_ONE\\n\", name, shader.name );\n\treturn GLS_SRCBLEND_ONE;\n}\n\n/*\n===============\nNameToDstBlendMode\n===============\n*/\nstatic int NameToDstBlendMode( const char *name )\n{\n\tif ( !Q_stricmp( name, \"GL_ONE\" ) )\n\t{\n\t\treturn GLS_DSTBLEND_ONE;\n\t}\n\telse if ( !Q_stricmp( name, \"GL_ZERO\" ) )\n\t{\n\t\treturn GLS_DSTBLEND_ZERO;\n\t}\n\telse if ( !Q_stricmp( name, \"GL_SRC_ALPHA\" ) )\n\t{\n\t\treturn GLS_DSTBLEND_SRC_ALPHA;\n\t}\n\telse if ( !Q_stricmp( name, \"GL_ONE_MINUS_SRC_ALPHA\" ) )\n\t{\n\t\treturn GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA;\n\t}\n\telse if ( !Q_stricmp( name, \"GL_DST_ALPHA\" ) )\n\t{\n\t\treturn GLS_DSTBLEND_DST_ALPHA;\n\t}\n\telse if ( !Q_stricmp( name, \"GL_ONE_MINUS_DST_ALPHA\" ) )\n\t{\n\t\treturn GLS_DSTBLEND_ONE_MINUS_DST_ALPHA;\n\t}\n\telse if ( !Q_stricmp( name, \"GL_SRC_COLOR\" ) )\n\t{\n\t\treturn GLS_DSTBLEND_SRC_COLOR;\n\t}\n\telse if ( !Q_stricmp( name, \"GL_ONE_MINUS_SRC_COLOR\" ) )\n\t{\n\t\treturn GLS_DSTBLEND_ONE_MINUS_SRC_COLOR;\n\t}\n\n\tri.Printf( PRINT_WARNING, \"WARNING: unknown blend mode '%s' in shader '%s', substituting GL_ONE\\n\", name, shader.name );\n\treturn GLS_DSTBLEND_ONE;\n}\n\n/*\n===============\nNameToGenFunc\n===============\n*/\nstatic genFunc_t NameToGenFunc( const char *funcname )\n{\n\tif ( !Q_stricmp( funcname, \"sin\" ) )\n\t{\n\t\treturn GF_SIN;\n\t}\n\telse if ( !Q_stricmp( funcname, \"square\" ) )\n\t{\n\t\treturn GF_SQUARE;\n\t}\n\telse if ( !Q_stricmp( funcname, \"triangle\" ) )\n\t{\n\t\treturn GF_TRIANGLE;\n\t}\n\telse if ( !Q_stricmp( funcname, \"sawtooth\" ) )\n\t{\n\t\treturn GF_SAWTOOTH;\n\t}\n\telse if ( !Q_stricmp( funcname, \"inversesawtooth\" ) )\n\t{\n\t\treturn GF_INVERSE_SAWTOOTH;\n\t}\n\telse if ( !Q_stricmp( funcname, \"noise\" ) )\n\t{\n\t\treturn GF_NOISE;\n\t}\n\n\tri.Printf( PRINT_WARNING, \"WARNING: invalid genfunc name '%s' in shader '%s'\\n\", funcname, shader.name );\n\treturn GF_SIN;\n}\n\n\n/*\n===================\nParseWaveForm\n===================\n*/\nstatic void ParseWaveForm( char **text, waveForm_t *wave )\n{\n\tchar *token;\n\n\ttoken = COM_ParseExt( text, qfalse );\n\tif ( token[0] == 0 )\n\t{\n\t\tri.Printf( PRINT_WARNING, \"WARNING: missing waveform parm in shader '%s'\\n\", shader.name );\n\t\treturn;\n\t}\n\twave->func = NameToGenFunc( token );\n\n\t// BASE, AMP, PHASE, FREQ\n\ttoken = COM_ParseExt( text, qfalse );\n\tif ( token[0] == 0 )\n\t{\n\t\tri.Printf( PRINT_WARNING, \"WARNING: missing waveform parm in shader '%s'\\n\", shader.name );\n\t\treturn;\n\t}\n\twave->base = atof( token );\n\n\ttoken = COM_ParseExt( text, qfalse );\n\tif ( token[0] == 0 )\n\t{\n\t\tri.Printf( PRINT_WARNING, \"WARNING: missing waveform parm in shader '%s'\\n\", shader.name );\n\t\treturn;\n\t}\n\twave->amplitude = atof( token );\n\n\ttoken = COM_ParseExt( text, qfalse );\n\tif ( token[0] == 0 )\n\t{\n\t\tri.Printf( PRINT_WARNING, \"WARNING: missing waveform parm in shader '%s'\\n\", shader.name );\n\t\treturn;\n\t}\n\twave->phase = atof( token );\n\n\ttoken = COM_ParseExt( text, qfalse );\n\tif ( token[0] == 0 )\n\t{\n\t\tri.Printf( PRINT_WARNING, \"WARNING: missing waveform parm in shader '%s'\\n\", shader.name );\n\t\treturn;\n\t}\n\twave->frequency = atof( token );\n}\n\n\n/*\n===================\nParseTexMod\n===================\n*/\nstatic void ParseTexMod( char *_text, shaderStage_t *stage )\n{\n\tconst char *token;\n\tchar **text = &_text;\n\ttexModInfo_t *tmi;\n\n\tif ( stage->bundle[0].numTexMods == TR_MAX_TEXMODS ) {\n\t\tri.Error( ERR_DROP, \"ERROR: too many tcMod stages in shader '%s'\\n\", shader.name );\n\t\treturn;\n\t}\n\n\ttmi = &stage->bundle[0].texMods[stage->bundle[0].numTexMods];\n\tstage->bundle[0].numTexMods++;\n\n\ttoken = COM_ParseExt( text, qfalse );\n\n\t//\n\t// turb\n\t//\n\tif ( !Q_stricmp( token, \"turb\" ) )\n\t{\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing tcMod turb parms in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\ttmi->wave.base = atof( token );\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing tcMod turb in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\ttmi->wave.amplitude = atof( token );\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing tcMod turb in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\ttmi->wave.phase = atof( token );\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing tcMod turb in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\ttmi->wave.frequency = atof( token );\n\n\t\ttmi->type = TMOD_TURBULENT;\n\t}\n\t//\n\t// scale\n\t//\n\telse if ( !Q_stricmp( token, \"scale\" ) )\n\t{\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing scale parms in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\ttmi->scale[0] = atof( token );\n\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing scale parms in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\ttmi->scale[1] = atof( token );\n\t\ttmi->type = TMOD_SCALE;\n\t}\n\t//\n\t// scroll\n\t//\n\telse if ( !Q_stricmp( token, \"scroll\" ) )\n\t{\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing scale scroll parms in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\ttmi->scroll[0] = atof( token );\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing scale scroll parms in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\ttmi->scroll[1] = atof( token );\n\t\ttmi->type = TMOD_SCROLL;\n\t}\n\t//\n\t// stretch\n\t//\n\telse if ( !Q_stricmp( token, \"stretch\" ) )\n\t{\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing stretch parms in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\ttmi->wave.func = NameToGenFunc( token );\n\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing stretch parms in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\ttmi->wave.base = atof( token );\n\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing stretch parms in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\ttmi->wave.amplitude = atof( token );\n\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing stretch parms in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\ttmi->wave.phase = atof( token );\n\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing stretch parms in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\ttmi->wave.frequency = atof( token );\n\t\t\n\t\ttmi->type = TMOD_STRETCH;\n\t}\n\t//\n\t// transform\n\t//\n\telse if ( !Q_stricmp( token, \"transform\" ) )\n\t{\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing transform parms in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\ttmi->matrix[0][0] = atof( token );\n\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing transform parms in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\ttmi->matrix[0][1] = atof( token );\n\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing transform parms in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\ttmi->matrix[1][0] = atof( token );\n\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing transform parms in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\ttmi->matrix[1][1] = atof( token );\n\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing transform parms in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\ttmi->translate[0] = atof( token );\n\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing transform parms in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\ttmi->translate[1] = atof( token );\n\n\t\ttmi->type = TMOD_TRANSFORM;\n\t}\n\t//\n\t// rotate\n\t//\n\telse if ( !Q_stricmp( token, \"rotate\" ) )\n\t{\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing tcMod rotate parms in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\ttmi->rotateSpeed = atof( token );\n\t\ttmi->type = TMOD_ROTATE;\n\t}\n\t//\n\t// entityTranslate\n\t//\n\telse if ( !Q_stricmp( token, \"entityTranslate\" ) )\n\t{\n\t\ttmi->type = TMOD_ENTITY_TRANSLATE;\n\t}\n\telse\n\t{\n\t\tri.Printf( PRINT_WARNING, \"WARNING: unknown tcMod '%s' in shader '%s'\\n\", token, shader.name );\n\t}\n}\n\n\n/*\n===================\nParseStage\n===================\n*/\nstatic qboolean ParseStage( shaderStage_t *stage, char **text )\n{\n\tchar *token;\n\tint depthMaskBits = GLS_DEPTHMASK_TRUE, blendSrcBits = 0, blendDstBits = 0, atestBits = 0, depthFuncBits = 0;\n\tqboolean depthMaskExplicit = qfalse;\n\n\tstage->active = qtrue;\n\n\twhile ( 1 )\n\t{\n\t\ttoken = COM_ParseExt( text, qtrue );\n\t\tif ( !token[0] )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: no matching '}' found\\n\" );\n\t\t\treturn qfalse;\n\t\t}\n\n\t\tif ( token[0] == '}' )\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t\t//\n\t\t// map <name>\n\t\t//\n\t\telse if ( !Q_stricmp( token, \"map\" ) )\n\t\t{\n\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\tif ( !token[0] )\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing parameter for 'map' keyword in shader '%s'\\n\", shader.name );\n\t\t\t\treturn qfalse;\n\t\t\t}\n\n\t\t\tif ( !Q_stricmp( token, \"$whiteimage\" ) )\n\t\t\t{\n\t\t\t\tstage->bundle[0].image[0] = tr.whiteImage;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"$lightmap\" ) )\n\t\t\t{\n\t\t\t\tstage->bundle[0].isLightmap = qtrue;\n\t\t\t\tif ( shader.lightmapIndex < 0 ) {\n\t\t\t\t\tstage->bundle[0].image[0] = tr.whiteImage;\n\t\t\t\t} else {\n\t\t\t\t\tstage->bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex];\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tstage->bundle[0].image[0] = R_FindImageFile( token, !shader.noMipMaps, !shader.noPicMip, GL_REPEAT );\n\t\t\t\tif ( !stage->bundle[0].image[0] )\n\t\t\t\t{\n\t\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: R_FindImageFile could not find '%s' in shader '%s'\\n\", token, shader.name );\n\t\t\t\t\treturn qfalse;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t//\n\t\t// clampmap <name>\n\t\t//\n\t\telse if ( !Q_stricmp( token, \"clampmap\" ) )\n\t\t{\n\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\tif ( !token[0] )\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing parameter for 'clampmap' keyword in shader '%s'\\n\", shader.name );\n\t\t\t\treturn qfalse;\n\t\t\t}\n\n\t\t\tstage->bundle[0].image[0] = R_FindImageFile( token, !shader.noMipMaps, !shader.noPicMip, GL_CLAMP );\n\t\t\tif ( !stage->bundle[0].image[0] )\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: R_FindImageFile could not find '%s' in shader '%s'\\n\", token, shader.name );\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t}\n\t\t//\n\t\t// animMap <frequency> <image1> .... <imageN>\n\t\t//\n\t\telse if ( !Q_stricmp( token, \"animMap\" ) )\n\t\t{\n\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\tif ( !token[0] )\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing parameter for 'animMmap' keyword in shader '%s'\\n\", shader.name );\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tstage->bundle[0].imageAnimationSpeed = atof( token );\n\n\t\t\t// parse up to MAX_IMAGE_ANIMATIONS animations\n\t\t\twhile ( 1 ) {\n\t\t\t\tint\t\tnum;\n\n\t\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\t\tif ( !token[0] ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tnum = stage->bundle[0].numImageAnimations;\n\t\t\t\tif ( num < MAX_IMAGE_ANIMATIONS ) {\n\t\t\t\t\tstage->bundle[0].image[num] = R_FindImageFile( token, !shader.noMipMaps, !shader.noPicMip, GL_REPEAT );\n\t\t\t\t\tif ( !stage->bundle[0].image[num] )\n\t\t\t\t\t{\n\t\t\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: R_FindImageFile could not find '%s' in shader '%s'\\n\", token, shader.name );\n\t\t\t\t\t\treturn qfalse;\n\t\t\t\t\t}\n\t\t\t\t\tstage->bundle[0].numImageAnimations++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if ( !Q_stricmp( token, \"videoMap\" ) )\n\t\t{\n\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\tif ( !token[0] )\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing parameter for 'videoMmap' keyword in shader '%s'\\n\", shader.name );\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tstage->bundle[0].videoMapHandle = ri.CIN_PlayCinematic( token, 0, 0, 256, 256, (CIN_loop | CIN_silent | CIN_shader));\n\t\t\tif (stage->bundle[0].videoMapHandle != -1) {\n\t\t\t\tstage->bundle[0].isVideoMap = qtrue;\n\t\t\t\tstage->bundle[0].image[0] = tr.scratchImage[stage->bundle[0].videoMapHandle];\n\t\t\t}\n\t\t}\n\t\t//\n\t\t// alphafunc <func>\n\t\t//\n\t\telse if ( !Q_stricmp( token, \"alphaFunc\" ) )\n\t\t{\n\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\tif ( !token[0] )\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing parameter for 'alphaFunc' keyword in shader '%s'\\n\", shader.name );\n\t\t\t\treturn qfalse;\n\t\t\t}\n\n\t\t\tatestBits = NameToAFunc( token );\n\t\t}\n\t\t//\n\t\t// depthFunc <func>\n\t\t//\n\t\telse if ( !Q_stricmp( token, \"depthfunc\" ) )\n\t\t{\n\t\t\ttoken = COM_ParseExt( text, qfalse );\n\n\t\t\tif ( !token[0] )\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing parameter for 'depthfunc' keyword in shader '%s'\\n\", shader.name );\n\t\t\t\treturn qfalse;\n\t\t\t}\n\n\t\t\tif ( !Q_stricmp( token, \"lequal\" ) )\n\t\t\t{\n\t\t\t\tdepthFuncBits = 0;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"equal\" ) )\n\t\t\t{\n\t\t\t\tdepthFuncBits = GLS_DEPTHFUNC_EQUAL;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: unknown depthfunc '%s' in shader '%s'\\n\", token, shader.name );\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\t//\n\t\t// detail\n\t\t//\n\t\telse if ( !Q_stricmp( token, \"detail\" ) )\n\t\t{\n\t\t\tstage->isDetail = qtrue;\n\t\t}\n\t\t//\n\t\t// blendfunc <srcFactor> <dstFactor>\n\t\t// or blendfunc <add|filter|blend>\n\t\t//\n\t\telse if ( !Q_stricmp( token, \"blendfunc\" ) )\n\t\t{\n\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\tif ( token[0] == 0 )\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing parm for blendFunc in shader '%s'\\n\", shader.name );\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// check for \"simple\" blends first\n\t\t\tif ( !Q_stricmp( token, \"add\" ) ) {\n\t\t\t\tblendSrcBits = GLS_SRCBLEND_ONE;\n\t\t\t\tblendDstBits = GLS_DSTBLEND_ONE;\n\t\t\t} else if ( !Q_stricmp( token, \"filter\" ) ) {\n\t\t\t\tblendSrcBits = GLS_SRCBLEND_DST_COLOR;\n\t\t\t\tblendDstBits = GLS_DSTBLEND_ZERO;\n\t\t\t} else if ( !Q_stricmp( token, \"blend\" ) ) {\n\t\t\t\tblendSrcBits = GLS_SRCBLEND_SRC_ALPHA;\n\t\t\t\tblendDstBits = GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA;\n\t\t\t} else {\n\t\t\t\t// complex double blends\n\t\t\t\tblendSrcBits = NameToSrcBlendMode( token );\n\n\t\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\t\tif ( token[0] == 0 )\n\t\t\t\t{\n\t\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing parm for blendFunc in shader '%s'\\n\", shader.name );\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tblendDstBits = NameToDstBlendMode( token );\n\t\t\t}\n\n\t\t\t// clear depth mask for blended surfaces\n\t\t\tif ( !depthMaskExplicit )\n\t\t\t{\n\t\t\t\tdepthMaskBits = 0;\n\t\t\t}\n\t\t}\n\t\t//\n\t\t// rgbGen\n\t\t//\n\t\telse if ( !Q_stricmp( token, \"rgbGen\" ) )\n\t\t{\n\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\tif ( token[0] == 0 )\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing parameters for rgbGen in shader '%s'\\n\", shader.name );\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif ( !Q_stricmp( token, \"wave\" ) )\n\t\t\t{\n\t\t\t\tParseWaveForm( text, &stage->rgbWave );\n\t\t\t\tstage->rgbGen = CGEN_WAVEFORM;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"const\" ) )\n\t\t\t{\n\t\t\t\tvec3_t\tcolor;\n\n\t\t\t\tParseVector( text, 3, color );\n\t\t\t\tstage->constantColor[0] = 255 * color[0];\n\t\t\t\tstage->constantColor[1] = 255 * color[1];\n\t\t\t\tstage->constantColor[2] = 255 * color[2];\n\n\t\t\t\tstage->rgbGen = CGEN_CONST;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"identity\" ) )\n\t\t\t{\n\t\t\t\tstage->rgbGen = CGEN_IDENTITY;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"identityLighting\" ) )\n\t\t\t{\n\t\t\t\tstage->rgbGen = CGEN_IDENTITY_LIGHTING;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"entity\" ) )\n\t\t\t{\n\t\t\t\tstage->rgbGen = CGEN_ENTITY;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"oneMinusEntity\" ) )\n\t\t\t{\n\t\t\t\tstage->rgbGen = CGEN_ONE_MINUS_ENTITY;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"vertex\" ) )\n\t\t\t{\n\t\t\t\tstage->rgbGen = CGEN_VERTEX;\n\t\t\t\tif ( stage->alphaGen == 0 ) {\n\t\t\t\t\tstage->alphaGen = AGEN_VERTEX;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"exactVertex\" ) )\n\t\t\t{\n\t\t\t\tstage->rgbGen = CGEN_EXACT_VERTEX;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"lightingDiffuse\" ) )\n\t\t\t{\n\t\t\t\tstage->rgbGen = CGEN_LIGHTING_DIFFUSE;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"oneMinusVertex\" ) )\n\t\t\t{\n\t\t\t\tstage->rgbGen = CGEN_ONE_MINUS_VERTEX;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: unknown rgbGen parameter '%s' in shader '%s'\\n\", token, shader.name );\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\t//\n\t\t// alphaGen \n\t\t//\n\t\telse if ( !Q_stricmp( token, \"alphaGen\" ) )\n\t\t{\n\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\tif ( token[0] == 0 )\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing parameters for alphaGen in shader '%s'\\n\", shader.name );\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif ( !Q_stricmp( token, \"wave\" ) )\n\t\t\t{\n\t\t\t\tParseWaveForm( text, &stage->alphaWave );\n\t\t\t\tstage->alphaGen = AGEN_WAVEFORM;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"const\" ) )\n\t\t\t{\n\t\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\t\tstage->constantColor[3] = 255 * atof( token );\n\t\t\t\tstage->alphaGen = AGEN_CONST;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"identity\" ) )\n\t\t\t{\n\t\t\t\tstage->alphaGen = AGEN_IDENTITY;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"entity\" ) )\n\t\t\t{\n\t\t\t\tstage->alphaGen = AGEN_ENTITY;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"oneMinusEntity\" ) )\n\t\t\t{\n\t\t\t\tstage->alphaGen = AGEN_ONE_MINUS_ENTITY;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"vertex\" ) )\n\t\t\t{\n\t\t\t\tstage->alphaGen = AGEN_VERTEX;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"lightingSpecular\" ) )\n\t\t\t{\n\t\t\t\tstage->alphaGen = AGEN_LIGHTING_SPECULAR;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"oneMinusVertex\" ) )\n\t\t\t{\n\t\t\t\tstage->alphaGen = AGEN_ONE_MINUS_VERTEX;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"portal\" ) )\n\t\t\t{\n\t\t\t\tstage->alphaGen = AGEN_PORTAL;\n\t\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\t\tif ( token[0] == 0 )\n\t\t\t\t{\n\t\t\t\t\tshader.portalRange = 256;\n\t\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing range parameter for alphaGen portal in shader '%s', defaulting to 256\\n\", shader.name );\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tshader.portalRange = atof( token );\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: unknown alphaGen parameter '%s' in shader '%s'\\n\", token, shader.name );\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\t//\n\t\t// tcGen <function>\n\t\t//\n\t\telse if ( !Q_stricmp(token, \"texgen\") || !Q_stricmp( token, \"tcGen\" ) ) \n\t\t{\n\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\tif ( token[0] == 0 )\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing texgen parm in shader '%s'\\n\", shader.name );\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif ( !Q_stricmp( token, \"environment\" ) )\n\t\t\t{\n\t\t\t\tstage->bundle[0].tcGen = TCGEN_ENVIRONMENT_MAPPED;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"lightmap\" ) )\n\t\t\t{\n\t\t\t\tstage->bundle[0].tcGen = TCGEN_LIGHTMAP;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"texture\" ) || !Q_stricmp( token, \"base\" ) )\n\t\t\t{\n\t\t\t\tstage->bundle[0].tcGen = TCGEN_TEXTURE;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"vector\" ) )\n\t\t\t{\n\t\t\t\tParseVector( text, 3, stage->bundle[0].tcGenVectors[0] );\n\t\t\t\tParseVector( text, 3, stage->bundle[0].tcGenVectors[1] );\n\n\t\t\t\tstage->bundle[0].tcGen = TCGEN_VECTOR;\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: unknown texgen parm in shader '%s'\\n\", shader.name );\n\t\t\t}\n\t\t}\n\t\t//\n\t\t// tcMod <type> <...>\n\t\t//\n\t\telse if ( !Q_stricmp( token, \"tcMod\" ) )\n\t\t{\n\t\t\tchar buffer[1024] = \"\";\n\n\t\t\twhile ( 1 )\n\t\t\t{\n\t\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\t\tif ( token[0] == 0 )\n\t\t\t\t\tbreak;\n\t\t\t\tstrcat( buffer, token );\n\t\t\t\tstrcat( buffer, \" \" );\n\t\t\t}\n\n\t\t\tParseTexMod( buffer, stage );\n\n\t\t\tcontinue;\n\t\t}\n\t\t//\n\t\t// depthmask\n\t\t//\n\t\telse if ( !Q_stricmp( token, \"depthwrite\" ) )\n\t\t{\n\t\t\tdepthMaskBits = GLS_DEPTHMASK_TRUE;\n\t\t\tdepthMaskExplicit = qtrue;\n\n\t\t\tcontinue;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: unknown parameter '%s' in shader '%s'\\n\", token, shader.name );\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\t//\n\t// if cgen isn't explicitly specified, use either identity or identitylighting\n\t//\n\tif ( stage->rgbGen == CGEN_BAD ) {\n\t\tif ( blendSrcBits == 0 ||\n\t\t\tblendSrcBits == GLS_SRCBLEND_ONE || \n\t\t\tblendSrcBits == GLS_SRCBLEND_SRC_ALPHA ) {\n\t\t\tstage->rgbGen = CGEN_IDENTITY_LIGHTING;\n\t\t} else {\n\t\t\tstage->rgbGen = CGEN_IDENTITY;\n\t\t}\n\t}\n\n\n\t//\n\t// implicitly assume that a GL_ONE GL_ZERO blend mask disables blending\n\t//\n\tif ( ( blendSrcBits == GLS_SRCBLEND_ONE ) && \n\t\t ( blendDstBits == GLS_DSTBLEND_ZERO ) )\n\t{\n\t\tblendDstBits = blendSrcBits = 0;\n\t\tdepthMaskBits = GLS_DEPTHMASK_TRUE;\n\t}\n\n\t// decide which agens we can skip\n\tif ( stage->alphaGen == CGEN_IDENTITY ) {\n\t\tif ( stage->rgbGen == CGEN_IDENTITY\n\t\t\t|| stage->rgbGen == CGEN_LIGHTING_DIFFUSE ) {\n\t\t\tstage->alphaGen = AGEN_SKIP;\n\t\t}\n\t}\n\n\t//\n\t// compute state bits\n\t//\n\tstage->stateBits = depthMaskBits | \n\t\t               blendSrcBits | blendDstBits | \n\t\t\t\t\t   atestBits | \n\t\t\t\t\t   depthFuncBits;\n\n\treturn qtrue;\n}\n\n/*\n===============\nParseDeform\n\ndeformVertexes wave <spread> <waveform> <base> <amplitude> <phase> <frequency>\ndeformVertexes normal <frequency> <amplitude>\ndeformVertexes move <vector> <waveform> <base> <amplitude> <phase> <frequency>\ndeformVertexes bulge <bulgeWidth> <bulgeHeight> <bulgeSpeed>\ndeformVertexes projectionShadow\ndeformVertexes autoSprite\ndeformVertexes autoSprite2\ndeformVertexes text[0-7]\n===============\n*/\nstatic void ParseDeform( char **text ) {\n\tchar\t*token;\n\tdeformStage_t\t*ds;\n\n\ttoken = COM_ParseExt( text, qfalse );\n\tif ( token[0] == 0 )\n\t{\n\t\tri.Printf( PRINT_WARNING, \"WARNING: missing deform parm in shader '%s'\\n\", shader.name );\n\t\treturn;\n\t}\n\n\tif ( shader.numDeforms == MAX_SHADER_DEFORMS ) {\n\t\tri.Printf( PRINT_WARNING, \"WARNING: MAX_SHADER_DEFORMS in '%s'\\n\", shader.name );\n\t\treturn;\n\t}\n\n\tds = &shader.deforms[ shader.numDeforms ];\n\tshader.numDeforms++;\n\n\tif ( !Q_stricmp( token, \"projectionShadow\" ) ) {\n\t\tds->deformation = DEFORM_PROJECTION_SHADOW;\n\t\treturn;\n\t}\n\n\tif ( !Q_stricmp( token, \"autosprite\" ) ) {\n\t\tds->deformation = DEFORM_AUTOSPRITE;\n\t\treturn;\n\t}\n\n\tif ( !Q_stricmp( token, \"autosprite2\" ) ) {\n\t\tds->deformation = DEFORM_AUTOSPRITE2;\n\t\treturn;\n\t}\n\n\tif ( !Q_stricmpn( token, \"text\", 4 ) ) {\n\t\tint\t\tn;\n\t\t\n\t\tn = token[4] - '0';\n\t\tif ( n < 0 || n > 7 ) {\n\t\t\tn = 0;\n\t\t}\n\t\tds->deformation = DEFORM_TEXT0 + n;\n\t\treturn;\n\t}\n\n\tif ( !Q_stricmp( token, \"bulge\" ) )\t{\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing deformVertexes bulge parm in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\tds->bulgeWidth = atof( token );\n\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing deformVertexes bulge parm in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\tds->bulgeHeight = atof( token );\n\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing deformVertexes bulge parm in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\tds->bulgeSpeed = atof( token );\n\n\t\tds->deformation = DEFORM_BULGE;\n\t\treturn;\n\t}\n\n\tif ( !Q_stricmp( token, \"wave\" ) )\n\t{\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing deformVertexes parm in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( atof( token ) != 0 )\n\t\t{\n\t\t\tds->deformationSpread = 1.0f / atof( token );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tds->deformationSpread = 100.0f;\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: illegal div value of 0 in deformVertexes command for shader '%s'\\n\", shader.name );\n\t\t}\n\n\t\tParseWaveForm( text, &ds->deformationWave );\n\t\tds->deformation = DEFORM_WAVE;\n\t\treturn;\n\t}\n\n\tif ( !Q_stricmp( token, \"normal\" ) )\n\t{\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing deformVertexes parm in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\tds->deformationWave.amplitude = atof( token );\n\n\t\ttoken = COM_ParseExt( text, qfalse );\n\t\tif ( token[0] == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing deformVertexes parm in shader '%s'\\n\", shader.name );\n\t\t\treturn;\n\t\t}\n\t\tds->deformationWave.frequency = atof( token );\n\n\t\tds->deformation = DEFORM_NORMALS;\n\t\treturn;\n\t}\n\n\tif ( !Q_stricmp( token, \"move\" ) ) {\n\t\tint\t\ti;\n\n\t\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\tif ( token[0] == 0 ) {\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing deformVertexes parm in shader '%s'\\n\", shader.name );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tds->moveVector[i] = atof( token );\n\t\t}\n\n\t\tParseWaveForm( text, &ds->deformationWave );\n\t\tds->deformation = DEFORM_MOVE;\n\t\treturn;\n\t}\n\n\tri.Printf( PRINT_WARNING, \"WARNING: unknown deformVertexes subtype '%s' found in shader '%s'\\n\", token, shader.name );\n}\n\n\n/*\n===============\nParseSkyParms\n\nskyParms <outerbox> <cloudheight> <innerbox>\n===============\n*/\nstatic void ParseSkyParms( char **text ) {\n\tchar\t\t*token;\n\tstatic char\t*suf[6] = {\"rt\", \"bk\", \"lf\", \"ft\", \"up\", \"dn\"};\n\tchar\t\tpathname[MAX_QPATH];\n\tint\t\t\ti;\n\n\t// outerbox\n\ttoken = COM_ParseExt( text, qfalse );\n\tif ( token[0] == 0 ) {\n\t\tri.Printf( PRINT_WARNING, \"WARNING: 'skyParms' missing parameter in shader '%s'\\n\", shader.name );\n\t\treturn;\n\t}\n\tif ( strcmp( token, \"-\" ) ) {\n\t\tfor (i=0 ; i<6 ; i++) {\n\t\t\tCom_sprintf( pathname, sizeof(pathname), \"%s_%s.tga\"\n\t\t\t\t, token, suf[i] );\n\t\t\tshader.sky.outerbox[i] = R_FindImageFile( ( char * ) pathname, qtrue, qtrue, GL_CLAMP );\n\t\t\tif ( !shader.sky.outerbox[i] ) {\n\t\t\t\tshader.sky.outerbox[i] = tr.defaultImage;\n\t\t\t}\n\t\t}\n\t}\n\n\t// cloudheight\n\ttoken = COM_ParseExt( text, qfalse );\n\tif ( token[0] == 0 ) {\n\t\tri.Printf( PRINT_WARNING, \"WARNING: 'skyParms' missing parameter in shader '%s'\\n\", shader.name );\n\t\treturn;\n\t}\n\tshader.sky.cloudHeight = atof( token );\n\tif ( !shader.sky.cloudHeight ) {\n\t\tshader.sky.cloudHeight = 512;\n\t}\n\tR_InitSkyTexCoords( shader.sky.cloudHeight );\n\n\n\t// innerbox\n\ttoken = COM_ParseExt( text, qfalse );\n\tif ( token[0] == 0 ) {\n\t\tri.Printf( PRINT_WARNING, \"WARNING: 'skyParms' missing parameter in shader '%s'\\n\", shader.name );\n\t\treturn;\n\t}\n\tif ( strcmp( token, \"-\" ) ) {\n\t\tfor (i=0 ; i<6 ; i++) {\n\t\t\tCom_sprintf( pathname, sizeof(pathname), \"%s_%s.tga\"\n\t\t\t\t, token, suf[i] );\n\t\t\tshader.sky.innerbox[i] = R_FindImageFile( ( char * ) pathname, qtrue, qtrue, GL_REPEAT );\n\t\t\tif ( !shader.sky.innerbox[i] ) {\n\t\t\t\tshader.sky.innerbox[i] = tr.defaultImage;\n\t\t\t}\n\t\t}\n\t}\n\n\tshader.isSky = qtrue;\n}\n\n\n/*\n=================\nParseSort\n=================\n*/\nvoid ParseSort( char **text ) {\n\tchar\t*token;\n\n\ttoken = COM_ParseExt( text, qfalse );\n\tif ( token[0] == 0 ) {\n\t\tri.Printf( PRINT_WARNING, \"WARNING: missing sort parameter in shader '%s'\\n\", shader.name );\n\t\treturn;\n\t}\n\n\tif ( !Q_stricmp( token, \"portal\" ) ) {\n\t\tshader.sort = SS_PORTAL;\n\t} else if ( !Q_stricmp( token, \"sky\" ) ) {\n\t\tshader.sort = SS_ENVIRONMENT;\n\t} else if ( !Q_stricmp( token, \"opaque\" ) ) {\n\t\tshader.sort = SS_OPAQUE;\n\t}else if ( !Q_stricmp( token, \"decal\" ) ) {\n\t\tshader.sort = SS_DECAL;\n\t} else if ( !Q_stricmp( token, \"seeThrough\" ) ) {\n\t\tshader.sort = SS_SEE_THROUGH;\n\t} else if ( !Q_stricmp( token, \"banner\" ) ) {\n\t\tshader.sort = SS_BANNER;\n\t} else if ( !Q_stricmp( token, \"additive\" ) ) {\n\t\tshader.sort = SS_BLEND1;\n\t} else if ( !Q_stricmp( token, \"nearest\" ) ) {\n\t\tshader.sort = SS_NEAREST;\n\t} else if ( !Q_stricmp( token, \"underwater\" ) ) {\n\t\tshader.sort = SS_UNDERWATER;\n\t} else {\n\t\tshader.sort = atof( token );\n\t}\n}\n\n\n\n// this table is also present in q3map\n\ntypedef struct {\n\tchar\t*name;\n\tint\t\tclearSolid, surfaceFlags, contents;\n} infoParm_t;\n\ninfoParm_t\tinfoParms[] = {\n\t// server relevant contents\n\t{\"water\",\t\t1,\t0,\tCONTENTS_WATER },\n\t{\"slime\",\t\t1,\t0,\tCONTENTS_SLIME },\t\t// mildly damaging\n\t{\"lava\",\t\t1,\t0,\tCONTENTS_LAVA },\t\t// very damaging\n\t{\"playerclip\",\t1,\t0,\tCONTENTS_PLAYERCLIP },\n\t{\"monsterclip\",\t1,\t0,\tCONTENTS_MONSTERCLIP },\n\t{\"nodrop\",\t\t1,\t0,\tCONTENTS_NODROP },\t\t// don't drop items or leave bodies (death fog, lava, etc)\n\t{\"nonsolid\",\t1,\tSURF_NONSOLID,\t0},\t\t\t\t\t\t// clears the solid flag\n\n\t// utility relevant attributes\n\t{\"origin\",\t\t1,\t0,\tCONTENTS_ORIGIN },\t\t// center of rotating brushes\n\t{\"trans\",\t\t0,\t0,\tCONTENTS_TRANSLUCENT },\t// don't eat contained surfaces\n\t{\"detail\",\t\t0,\t0,\tCONTENTS_DETAIL },\t\t// don't include in structural bsp\n\t{\"structural\",\t0,\t0,\tCONTENTS_STRUCTURAL },\t// force into structural bsp even if trnas\n\t{\"areaportal\",\t1,\t0,\tCONTENTS_AREAPORTAL },\t// divides areas\n\t{\"clusterportal\", 1,0,  CONTENTS_CLUSTERPORTAL },\t// for bots\n\t{\"donotenter\",  1,  0,  CONTENTS_DONOTENTER },\t\t// for bots\n\n\t{\"fog\",\t\t\t1,\t0,\tCONTENTS_FOG},\t\t\t// carves surfaces entering\n\t{\"sky\",\t\t\t0,\tSURF_SKY,\t\t0 },\t\t// emit light from an environment map\n\t{\"lightfilter\",\t0,\tSURF_LIGHTFILTER, 0 },\t\t// filter light going through it\n\t{\"alphashadow\",\t0,\tSURF_ALPHASHADOW, 0 },\t\t// test light on a per-pixel basis\n\t{\"hint\",\t\t0,\tSURF_HINT,\t\t0 },\t\t// use as a primary splitter\n\n\t// server attributes\n\t{\"slick\",\t\t0,\tSURF_SLICK,\t\t0 },\n\t{\"noimpact\",\t0,\tSURF_NOIMPACT,\t0 },\t\t// don't make impact explosions or marks\n\t{\"nomarks\",\t\t0,\tSURF_NOMARKS,\t0 },\t\t// don't make impact marks, but still explode\n\t{\"ladder\",\t\t0,\tSURF_LADDER,\t0 },\n\t{\"nodamage\",\t0,\tSURF_NODAMAGE,\t0 },\n\t{\"metalsteps\",\t0,\tSURF_METALSTEPS,0 },\n\t{\"flesh\",\t\t0,\tSURF_FLESH,\t\t0 },\n\t{\"nosteps\",\t\t0,\tSURF_NOSTEPS,\t0 },\n\n\t// drawsurf attributes\n\t{\"nodraw\",\t\t0,\tSURF_NODRAW,\t0 },\t// don't generate a drawsurface (or a lightmap)\n\t{\"pointlight\",\t0,\tSURF_POINTLIGHT, 0 },\t// sample lighting at vertexes\n\t{\"nolightmap\",\t0,\tSURF_NOLIGHTMAP,0 },\t// don't generate a lightmap\n\t{\"nodlight\",\t0,\tSURF_NODLIGHT, 0 },\t\t// don't ever add dynamic lights\n\t{\"dust\",\t\t0,\tSURF_DUST, 0}\t\t\t// leave a dust trail when walking on this surface\n};\n\n\n/*\n===============\nParseSurfaceParm\n\nsurfaceparm <name>\n===============\n*/\nstatic void ParseSurfaceParm( char **text ) {\n\tchar\t*token;\n\tint\t\tnumInfoParms = sizeof(infoParms) / sizeof(infoParms[0]);\n\tint\t\ti;\n\n\ttoken = COM_ParseExt( text, qfalse );\n\tfor ( i = 0 ; i < numInfoParms ; i++ ) {\n\t\tif ( !Q_stricmp( token, infoParms[i].name ) ) {\n\t\t\tshader.surfaceFlags |= infoParms[i].surfaceFlags;\n\t\t\tshader.contentFlags |= infoParms[i].contents;\n#if 0\n\t\t\tif ( infoParms[i].clearSolid ) {\n\t\t\t\tsi->contents &= ~CONTENTS_SOLID;\n\t\t\t}\n#endif\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/*\n=================\nParseShader\n\nThe current text pointer is at the explicit text definition of the\nshader.  Parse it into the global shader variable.  Later functions\nwill optimize it.\n=================\n*/\nstatic qboolean ParseShader( char **text )\n{\n\tchar *token;\n\tint s;\n\n\ts = 0;\n\n\ttoken = COM_ParseExt( text, qtrue );\n\tif ( token[0] != '{' )\n\t{\n\t\tri.Printf( PRINT_WARNING, \"WARNING: expecting '{', found '%s' instead in shader '%s'\\n\", token, shader.name );\n\t\treturn qfalse;\n\t}\n\n\twhile ( 1 )\n\t{\n\t\ttoken = COM_ParseExt( text, qtrue );\n\t\tif ( !token[0] )\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: no concluding '}' in shader %s\\n\", shader.name );\n\t\t\treturn qfalse;\n\t\t}\n\n\t\t// end of shader definition\n\t\tif ( token[0] == '}' )\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t\t// stage definition\n\t\telse if ( token[0] == '{' )\n\t\t{\n\t\t\tif ( !ParseStage( &stages[s], text ) )\n\t\t\t{\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tstages[s].active = qtrue;\n\t\t\ts++;\n\t\t\tcontinue;\n\t\t}\n\t\t// skip stuff that only the QuakeEdRadient needs\n\t\telse if ( !Q_stricmpn( token, \"qer\", 3 ) ) {\n\t\t\tSkipRestOfLine( text );\n\t\t\tcontinue;\n\t\t}\n\t\t// sun parms\n\t\telse if ( !Q_stricmp( token, \"q3map_sun\" ) ) {\n\t\t\tfloat\ta, b;\n\n\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\ttr.sunLight[0] = atof( token );\n\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\ttr.sunLight[1] = atof( token );\n\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\ttr.sunLight[2] = atof( token );\n\t\t\t\n\t\t\tVectorNormalize( tr.sunLight );\n\n\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\ta = atof( token );\n\t\t\tVectorScale( tr.sunLight, a, tr.sunLight);\n\n\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\ta = atof( token );\n\t\t\ta = a / 180 * M_PI;\n\n\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\tb = atof( token );\n\t\t\tb = b / 180 * M_PI;\n\n\t\t\ttr.sunDirection[0] = cos( a ) * cos( b );\n\t\t\ttr.sunDirection[1] = sin( a ) * cos( b );\n\t\t\ttr.sunDirection[2] = sin( b );\n\t\t}\n\t\telse if ( !Q_stricmp( token, \"deformVertexes\" ) ) {\n\t\t\tParseDeform( text );\n\t\t\tcontinue;\n\t\t}\n\t\telse if ( !Q_stricmp( token, \"tesssize\" ) ) {\n\t\t\tSkipRestOfLine( text );\n\t\t\tcontinue;\n\t\t}\n\t\telse if ( !Q_stricmp( token, \"clampTime\" ) ) {\n\t\t\ttoken = COM_ParseExt( text, qfalse );\n      if (token[0]) {\n        shader.clampTime = atof(token);\n      }\n    }\n\t\t// skip stuff that only the q3map needs\n\t\telse if ( !Q_stricmpn( token, \"q3map\", 5 ) ) {\n\t\t\tSkipRestOfLine( text );\n\t\t\tcontinue;\n\t\t}\n\t\t// skip stuff that only q3map or the server needs\n\t\telse if ( !Q_stricmp( token, \"surfaceParm\" ) ) {\n\t\t\tParseSurfaceParm( text );\n\t\t\tcontinue;\n\t\t}\n\t\t// no mip maps\n\t\telse if ( !Q_stricmp( token, \"nomipmaps\" ) )\n\t\t{\n\t\t\tshader.noMipMaps = qtrue;\n\t\t\tshader.noPicMip = qtrue;\n\t\t\tcontinue;\n\t\t}\n\t\t// no picmip adjustment\n\t\telse if ( !Q_stricmp( token, \"nopicmip\" ) )\n\t\t{\n\t\t\tshader.noPicMip = qtrue;\n\t\t\tcontinue;\n\t\t}\n\t\t// polygonOffset\n\t\telse if ( !Q_stricmp( token, \"polygonOffset\" ) )\n\t\t{\n\t\t\tshader.polygonOffset = qtrue;\n\t\t\tcontinue;\n\t\t}\n\t\t// entityMergable, allowing sprite surfaces from multiple entities\n\t\t// to be merged into one batch.  This is a savings for smoke\n\t\t// puffs and blood, but can't be used for anything where the\n\t\t// shader calcs (not the surface function) reference the entity color or scroll\n\t\telse if ( !Q_stricmp( token, \"entityMergable\" ) )\n\t\t{\n\t\t\tshader.entityMergable = qtrue;\n\t\t\tcontinue;\n\t\t}\n\t\t// fogParms\n\t\telse if ( !Q_stricmp( token, \"fogParms\" ) ) \n\t\t{\n\t\t\tif ( !ParseVector( text, 3, shader.fogParms.color ) ) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\n\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\tif ( !token[0] ) \n\t\t\t{\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing parm for 'fogParms' keyword in shader '%s'\\n\", shader.name );\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tshader.fogParms.depthForOpaque = atof( token );\n\n\t\t\t// skip any old gradient directions\n\t\t\tSkipRestOfLine( text );\n\t\t\tcontinue;\n\t\t}\n\t\t// portal\n\t\telse if ( !Q_stricmp(token, \"portal\") )\n\t\t{\n\t\t\tshader.sort = SS_PORTAL;\n\t\t\tcontinue;\n\t\t}\n\t\t// skyparms <cloudheight> <outerbox> <innerbox>\n\t\telse if ( !Q_stricmp( token, \"skyparms\" ) )\n\t\t{\n\t\t\tParseSkyParms( text );\n\t\t\tcontinue;\n\t\t}\n\t\t// light <value> determines flaring in q3map, not needed here\n\t\telse if ( !Q_stricmp(token, \"light\") ) \n\t\t{\n\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\tcontinue;\n\t\t}\n\t\t// cull <face>\n\t\telse if ( !Q_stricmp( token, \"cull\") ) \n\t\t{\n\t\t\ttoken = COM_ParseExt( text, qfalse );\n\t\t\tif ( token[0] == 0 )\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: missing cull parms in shader '%s'\\n\", shader.name );\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif ( !Q_stricmp( token, \"none\" ) || !Q_stricmp( token, \"twosided\" ) || !Q_stricmp( token, \"disable\" ) )\n\t\t\t{\n\t\t\t\tshader.cullType = CT_TWO_SIDED;\n\t\t\t}\n\t\t\telse if ( !Q_stricmp( token, \"back\" ) || !Q_stricmp( token, \"backside\" ) || !Q_stricmp( token, \"backsided\" ) )\n\t\t\t{\n\t\t\t\tshader.cullType = CT_BACK_SIDED;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: invalid cull parm '%s' in shader '%s'\\n\", token, shader.name );\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\t// sort\n\t\telse if ( !Q_stricmp( token, \"sort\" ) )\n\t\t{\n\t\t\tParseSort( text );\n\t\t\tcontinue;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: unknown general shader parameter '%s' in '%s'\\n\", token, shader.name );\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\t//\n\t// ignore shaders that don't have any stages, unless it is a sky or fog\n\t//\n\tif ( s == 0 && !shader.isSky && !(shader.contentFlags & CONTENTS_FOG ) ) {\n\t\treturn qfalse;\n\t}\n\n\tshader.explicitlyDefined = qtrue;\n\n\treturn qtrue;\n}\n\n/*\n========================================================================================\n\nSHADER OPTIMIZATION AND FOGGING\n\n========================================================================================\n*/\n\n/*\n===================\nComputeStageIteratorFunc\n\nSee if we can use on of the simple fastpath stage functions,\notherwise set to the generic stage function\n===================\n*/\nstatic void ComputeStageIteratorFunc( void )\n{\n\tshader.optimalStageIteratorFunc = RB_StageIteratorGeneric;\n\n\t//\n\t// see if this should go into the sky path\n\t//\n\tif ( shader.isSky )\n\t{\n\t\tshader.optimalStageIteratorFunc = RB_StageIteratorSky;\n\t\tgoto done;\n\t}\n\n\tif ( r_ignoreFastPath->integer )\n\t{\n\t\treturn;\n\t}\n\n\t//\n\t// see if this can go into the vertex lit fast path\n\t//\n\tif ( shader.numUnfoggedPasses == 1 )\n\t{\n\t\tif ( stages[0].rgbGen == CGEN_LIGHTING_DIFFUSE )\n\t\t{\n\t\t\tif ( stages[0].alphaGen == AGEN_IDENTITY )\n\t\t\t{\n\t\t\t\tif ( stages[0].bundle[0].tcGen == TCGEN_TEXTURE )\n\t\t\t\t{\n\t\t\t\t\tif ( !shader.polygonOffset )\n\t\t\t\t\t{\n\t\t\t\t\t\tif ( !shader.multitextureEnv )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif ( !shader.numDeforms )\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tshader.optimalStageIteratorFunc = RB_StageIteratorVertexLitTexture;\n\t\t\t\t\t\t\t\tgoto done;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t//\n\t// see if this can go into an optimized LM, multitextured path\n\t//\n\tif ( shader.numUnfoggedPasses == 1 )\n\t{\n\t\tif ( ( stages[0].rgbGen == CGEN_IDENTITY ) && ( stages[0].alphaGen == AGEN_IDENTITY ) )\n\t\t{\n\t\t\tif ( stages[0].bundle[0].tcGen == TCGEN_TEXTURE && \n\t\t\t\tstages[0].bundle[1].tcGen == TCGEN_LIGHTMAP )\n\t\t\t{\n\t\t\t\tif ( !shader.polygonOffset )\n\t\t\t\t{\n\t\t\t\t\tif ( !shader.numDeforms )\n\t\t\t\t\t{\n\t\t\t\t\t\tif ( shader.multitextureEnv )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tshader.optimalStageIteratorFunc = RB_StageIteratorLightmappedMultitexture;\n\t\t\t\t\t\t\tgoto done;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\ndone:\n\treturn;\n}\n\ntypedef struct {\n\tint\t\tblendA;\n\tint\t\tblendB;\n\n\tint\t\tmultitextureEnv;\n\tint\t\tmultitextureBlend;\n} collapse_t;\n\nstatic collapse_t\tcollapse[] = {\n\t{ 0, GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO,\t\n\t\tGL_MODULATE, 0 },\n\n\t{ 0, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR,\n\t\tGL_MODULATE, 0 },\n\n\t{ GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR,\n\t\tGL_MODULATE, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR },\n\n\t{ GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR,\n\t\tGL_MODULATE, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR },\n\n\t{ GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR, GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO,\n\t\tGL_MODULATE, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR },\n\n\t{ GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO, GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO,\n\t\tGL_MODULATE, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR },\n\n\t{ 0, GLS_DSTBLEND_ONE | GLS_SRCBLEND_ONE,\n\t\tGL_ADD, 0 },\n\n\t{ GLS_DSTBLEND_ONE | GLS_SRCBLEND_ONE, GLS_DSTBLEND_ONE | GLS_SRCBLEND_ONE,\n\t\tGL_ADD, GLS_DSTBLEND_ONE | GLS_SRCBLEND_ONE },\n#if 0\n\t{ 0, GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_SRCBLEND_SRC_ALPHA,\n\t\tGL_DECAL, 0 },\n#endif\n\t{ -1 }\n};\n\n/*\n================\nCollapseMultitexture\n\nAttempt to combine two stages into a single multitexture stage\nFIXME: I think modulated add + modulated add collapses incorrectly\n=================\n*/\nstatic qboolean CollapseMultitexture( void ) {\n\tint abits, bbits;\n\tint i;\n\ttextureBundle_t tmpBundle;\n\n\tif ( !qglActiveTextureARB ) {\n\t\treturn qfalse;\n\t}\n\n\t// make sure both stages are active\n\tif ( !stages[0].active || !stages[1].active ) {\n\t\treturn qfalse;\n\t}\n\n\t// on voodoo2, don't combine different tmus\n\tif ( glConfig.driverType == GLDRV_VOODOO ) {\n\t\tif ( stages[0].bundle[0].image[0]->TMU ==\n\t\t\t stages[1].bundle[0].image[0]->TMU ) {\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\tabits = stages[0].stateBits;\n\tbbits = stages[1].stateBits;\n\n\t// make sure that both stages have identical state other than blend modes\n\tif ( ( abits & ~( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS | GLS_DEPTHMASK_TRUE ) ) !=\n\t\t( bbits & ~( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS | GLS_DEPTHMASK_TRUE ) ) ) {\n\t\treturn qfalse;\n\t}\n\n\tabits &= ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS );\n\tbbits &= ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS );\n\n\t// search for a valid multitexture blend function\n\tfor ( i = 0; collapse[i].blendA != -1 ; i++ ) {\n\t\tif ( abits == collapse[i].blendA\n\t\t\t&& bbits == collapse[i].blendB ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// nothing found\n\tif ( collapse[i].blendA == -1 ) {\n\t\treturn qfalse;\n\t}\n\n\t// GL_ADD is a separate extension\n\tif ( collapse[i].multitextureEnv == GL_ADD && !glConfig.textureEnvAddAvailable ) {\n\t\treturn qfalse;\n\t}\n\n\t// make sure waveforms have identical parameters\n\tif ( ( stages[0].rgbGen != stages[1].rgbGen ) ||\n\t\t( stages[0].alphaGen != stages[1].alphaGen ) )  {\n\t\treturn qfalse;\n\t}\n\n\t// an add collapse can only have identity colors\n\tif ( collapse[i].multitextureEnv == GL_ADD && stages[0].rgbGen != CGEN_IDENTITY ) {\n\t\treturn qfalse;\n\t}\n\n\tif ( stages[0].rgbGen == CGEN_WAVEFORM )\n\t{\n\t\tif ( memcmp( &stages[0].rgbWave,\n\t\t\t\t\t &stages[1].rgbWave,\n\t\t\t\t\t sizeof( stages[0].rgbWave ) ) )\n\t\t{\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\tif ( stages[0].alphaGen == CGEN_WAVEFORM )\n\t{\n\t\tif ( memcmp( &stages[0].alphaWave,\n\t\t\t\t\t &stages[1].alphaWave,\n\t\t\t\t\t sizeof( stages[0].alphaWave ) ) )\n\t\t{\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\n\t// make sure that lightmaps are in bundle 1 for 3dfx\n\tif ( stages[0].bundle[0].isLightmap )\n\t{\n\t\ttmpBundle = stages[0].bundle[0];\n\t\tstages[0].bundle[0] = stages[1].bundle[0];\n\t\tstages[0].bundle[1] = tmpBundle;\n\t}\n\telse\n\t{\n\t\tstages[0].bundle[1] = stages[1].bundle[0];\n\t}\n\n\t// set the new blend state bits\n\tshader.multitextureEnv = collapse[i].multitextureEnv;\n\tstages[0].stateBits &= ~( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS );\n\tstages[0].stateBits |= collapse[i].multitextureBlend;\n\n\t//\n\t// move down subsequent shaders\n\t//\n\tmemmove( &stages[1], &stages[2], sizeof( stages[0] ) * ( MAX_SHADER_STAGES - 2 ) );\n\tCom_Memset( &stages[MAX_SHADER_STAGES-1], 0, sizeof( stages[0] ) );\n\n\treturn qtrue;\n}\n\n/*\n=============\n\nFixRenderCommandList\nhttps://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=493\nArnout: this is a nasty issue. Shaders can be registered after drawsurfaces are generated\nbut before the frame is rendered. This will, for the duration of one frame, cause drawsurfaces\nto be rendered with bad shaders. To fix this, need to go through all render commands and fix\nsortedIndex.\n==============\n*/\nstatic void FixRenderCommandList( int newShader ) {\n\trenderCommandList_t\t*cmdList = &backEndData[tr.smpFrame]->commands;\n\n\tif( cmdList ) {\n\t\tconst void *curCmd = cmdList->cmds;\n\n\t\twhile ( 1 ) {\n\t\t\tswitch ( *(const int *)curCmd ) {\n\t\t\tcase RC_SET_COLOR:\n\t\t\t\t{\n\t\t\t\tconst setColorCommand_t *sc_cmd = (const setColorCommand_t *)curCmd;\n\t\t\t\tcurCmd = (const void *)(sc_cmd + 1);\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\tcase RC_STRETCH_PIC:\n\t\t\t\t{\n\t\t\t\tconst stretchPicCommand_t *sp_cmd = (const stretchPicCommand_t *)curCmd;\n\t\t\t\tcurCmd = (const void *)(sp_cmd + 1);\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\tcase RC_DRAW_SURFS:\n\t\t\t\t{\n\t\t\t\tint i;\n\t\t\t\tdrawSurf_t\t*drawSurf;\n\t\t\t\tshader_t\t*shader;\n\t\t\t\tint\t\t\tfogNum;\n\t\t\t\tint\t\t\tentityNum;\n\t\t\t\tint\t\t\tdlightMap;\n\t\t\t\tint\t\t\tsortedIndex;\n\t\t\t\tconst drawSurfsCommand_t *ds_cmd =  (const drawSurfsCommand_t *)curCmd;\n\n\t\t\t\tfor( i = 0, drawSurf = ds_cmd->drawSurfs; i < ds_cmd->numDrawSurfs; i++, drawSurf++ ) {\n\t\t\t\t\tR_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlightMap );\n                    sortedIndex = (( drawSurf->sort >> QSORT_SHADERNUM_SHIFT ) & (MAX_SHADERS-1));\n\t\t\t\t\tif( sortedIndex >= newShader ) {\n\t\t\t\t\t\tsortedIndex++;\n\t\t\t\t\t\tdrawSurf->sort = (sortedIndex << QSORT_SHADERNUM_SHIFT) | entityNum | ( fogNum << QSORT_FOGNUM_SHIFT ) | (int)dlightMap;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcurCmd = (const void *)(ds_cmd + 1);\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\tcase RC_DRAW_BUFFER:\n\t\t\t\t{\n\t\t\t\tconst drawBufferCommand_t *db_cmd = (const drawBufferCommand_t *)curCmd;\n\t\t\t\tcurCmd = (const void *)(db_cmd + 1);\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\tcase RC_SWAP_BUFFERS:\n\t\t\t\t{\n\t\t\t\tconst swapBuffersCommand_t *sb_cmd = (const swapBuffersCommand_t *)curCmd;\n\t\t\t\tcurCmd = (const void *)(sb_cmd + 1);\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\tcase RC_END_OF_LIST:\n\t\t\tdefault:\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n==============\nSortNewShader\n\nPositions the most recently created shader in the tr.sortedShaders[]\narray so that the shader->sort key is sorted reletive to the other\nshaders.\n\nSets shader->sortedIndex\n==============\n*/\nstatic void SortNewShader( void ) {\n\tint\t\ti;\n\tfloat\tsort;\n\tshader_t\t*newShader;\n\n\tnewShader = tr.shaders[ tr.numShaders - 1 ];\n\tsort = newShader->sort;\n\n\tfor ( i = tr.numShaders - 2 ; i >= 0 ; i-- ) {\n\t\tif ( tr.sortedShaders[ i ]->sort <= sort ) {\n\t\t\tbreak;\n\t\t}\n\t\ttr.sortedShaders[i+1] = tr.sortedShaders[i];\n\t\ttr.sortedShaders[i+1]->sortedIndex++;\n\t}\n\n\t// Arnout: fix rendercommandlist\n\t// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=493\n\tFixRenderCommandList( i+1 );\n\n\tnewShader->sortedIndex = i+1;\n\ttr.sortedShaders[i+1] = newShader;\n}\n\n\n/*\n====================\nGeneratePermanentShader\n====================\n*/\nstatic shader_t *GeneratePermanentShader( void ) {\n\tshader_t\t*newShader;\n\tint\t\t\ti, b;\n\tint\t\t\tsize, hash;\n\n\tif ( tr.numShaders == MAX_SHADERS ) {\n\t\tri.Printf( PRINT_WARNING, \"WARNING: GeneratePermanentShader - MAX_SHADERS hit\\n\");\n\t\treturn tr.defaultShader;\n\t}\n\n\tnewShader = ri.Hunk_Alloc( sizeof( shader_t ), h_low );\n\n\t*newShader = shader;\n\n\tif ( shader.sort <= SS_OPAQUE ) {\n\t\tnewShader->fogPass = FP_EQUAL;\n\t} else if ( shader.contentFlags & CONTENTS_FOG ) {\n\t\tnewShader->fogPass = FP_LE;\n\t}\n\n\ttr.shaders[ tr.numShaders ] = newShader;\n\tnewShader->index = tr.numShaders;\n\t\n\ttr.sortedShaders[ tr.numShaders ] = newShader;\n\tnewShader->sortedIndex = tr.numShaders;\n\n\ttr.numShaders++;\n\n\tfor ( i = 0 ; i < newShader->numUnfoggedPasses ; i++ ) {\n\t\tif ( !stages[i].active ) {\n\t\t\tbreak;\n\t\t}\n\t\tnewShader->stages[i] = ri.Hunk_Alloc( sizeof( stages[i] ), h_low );\n\t\t*newShader->stages[i] = stages[i];\n\n\t\tfor ( b = 0 ; b < NUM_TEXTURE_BUNDLES ; b++ ) {\n\t\t\tsize = newShader->stages[i]->bundle[b].numTexMods * sizeof( texModInfo_t );\n\t\t\tnewShader->stages[i]->bundle[b].texMods = ri.Hunk_Alloc( size, h_low );\n\t\t\tCom_Memcpy( newShader->stages[i]->bundle[b].texMods, stages[i].bundle[b].texMods, size );\n\t\t}\n\t}\n\n\tSortNewShader();\n\n\thash = generateHashValue(newShader->name, FILE_HASH_SIZE);\n\tnewShader->next = hashTable[hash];\n\thashTable[hash] = newShader;\n\n\treturn newShader;\n}\n\n/*\n=================\nVertexLightingCollapse\n\nIf vertex lighting is enabled, only render a single\npass, trying to guess which is the correct one to best aproximate\nwhat it is supposed to look like.\n=================\n*/\nstatic void VertexLightingCollapse( void ) {\n\tint\t\tstage;\n\tshaderStage_t\t*bestStage;\n\tint\t\tbestImageRank;\n\tint\t\trank;\n\n\t// if we aren't opaque, just use the first pass\n\tif ( shader.sort == SS_OPAQUE ) {\n\n\t\t// pick the best texture for the single pass\n\t\tbestStage = &stages[0];\n\t\tbestImageRank = -999999;\n\n\t\tfor ( stage = 0; stage < MAX_SHADER_STAGES; stage++ ) {\n\t\t\tshaderStage_t *pStage = &stages[stage];\n\n\t\t\tif ( !pStage->active ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\trank = 0;\n\n\t\t\tif ( pStage->bundle[0].isLightmap ) {\n\t\t\t\trank -= 100;\n\t\t\t}\n\t\t\tif ( pStage->bundle[0].tcGen != TCGEN_TEXTURE ) {\n\t\t\t\trank -= 5;\n\t\t\t}\n\t\t\tif ( pStage->bundle[0].numTexMods ) {\n\t\t\t\trank -= 5;\n\t\t\t}\n\t\t\tif ( pStage->rgbGen != CGEN_IDENTITY && pStage->rgbGen != CGEN_IDENTITY_LIGHTING ) {\n\t\t\t\trank -= 3;\n\t\t\t}\n\n\t\t\tif ( rank > bestImageRank  ) {\n\t\t\t\tbestImageRank = rank;\n\t\t\t\tbestStage = pStage;\n\t\t\t}\n\t\t}\n\n\t\tstages[0].bundle[0] = bestStage->bundle[0];\n\t\tstages[0].stateBits &= ~( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS );\n\t\tstages[0].stateBits |= GLS_DEPTHMASK_TRUE;\n\t\tif ( shader.lightmapIndex == LIGHTMAP_NONE ) {\n\t\t\tstages[0].rgbGen = CGEN_LIGHTING_DIFFUSE;\n\t\t} else {\n\t\t\tstages[0].rgbGen = CGEN_EXACT_VERTEX;\n\t\t}\n\t\tstages[0].alphaGen = AGEN_SKIP;\t\t\n\t} else {\n\t\t// don't use a lightmap (tesla coils)\n\t\tif ( stages[0].bundle[0].isLightmap ) {\n\t\t\tstages[0] = stages[1];\n\t\t}\n\n\t\t// if we were in a cross-fade cgen, hack it to normal\n\t\tif ( stages[0].rgbGen == CGEN_ONE_MINUS_ENTITY || stages[1].rgbGen == CGEN_ONE_MINUS_ENTITY ) {\n\t\t\tstages[0].rgbGen = CGEN_IDENTITY_LIGHTING;\n\t\t}\n\t\tif ( ( stages[0].rgbGen == CGEN_WAVEFORM && stages[0].rgbWave.func == GF_SAWTOOTH )\n\t\t\t&& ( stages[1].rgbGen == CGEN_WAVEFORM && stages[1].rgbWave.func == GF_INVERSE_SAWTOOTH ) ) {\n\t\t\tstages[0].rgbGen = CGEN_IDENTITY_LIGHTING;\n\t\t}\n\t\tif ( ( stages[0].rgbGen == CGEN_WAVEFORM && stages[0].rgbWave.func == GF_INVERSE_SAWTOOTH )\n\t\t\t&& ( stages[1].rgbGen == CGEN_WAVEFORM && stages[1].rgbWave.func == GF_SAWTOOTH ) ) {\n\t\t\tstages[0].rgbGen = CGEN_IDENTITY_LIGHTING;\n\t\t}\n\t}\n\n\tfor ( stage = 1; stage < MAX_SHADER_STAGES; stage++ ) {\n\t\tshaderStage_t *pStage = &stages[stage];\n\n\t\tif ( !pStage->active ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tCom_Memset( pStage, 0, sizeof( *pStage ) );\n\t}\n}\n\n/*\n=========================\nFinishShader\n\nReturns a freshly allocated shader with all the needed info\nfrom the current global working shader\n=========================\n*/\nstatic shader_t *FinishShader( void ) {\n\tint stage;\n\tqboolean\t\thasLightmapStage;\n\tqboolean\t\tvertexLightmap;\n\n\thasLightmapStage = qfalse;\n\tvertexLightmap = qfalse;\n\n\t//\n\t// set sky stuff appropriate\n\t//\n\tif ( shader.isSky ) {\n\t\tshader.sort = SS_ENVIRONMENT;\n\t}\n\n\t//\n\t// set polygon offset\n\t//\n\tif ( shader.polygonOffset && !shader.sort ) {\n\t\tshader.sort = SS_DECAL;\n\t}\n\n\t//\n\t// set appropriate stage information\n\t//\n\tfor ( stage = 0; stage < MAX_SHADER_STAGES; stage++ ) {\n\t\tshaderStage_t *pStage = &stages[stage];\n\n\t\tif ( !pStage->active ) {\n\t\t\tbreak;\n\t\t}\n\n    // check for a missing texture\n\t\tif ( !pStage->bundle[0].image[0] ) {\n\t\t\tri.Printf( PRINT_WARNING, \"Shader %s has a stage with no image\\n\", shader.name );\n\t\t\tpStage->active = qfalse;\n\t\t\tcontinue;\n\t\t}\n\n\t\t//\n\t\t// ditch this stage if it's detail and detail textures are disabled\n\t\t//\n\t\tif ( pStage->isDetail && !r_detailTextures->integer ) {\n\t\t\tif ( stage < ( MAX_SHADER_STAGES - 1 ) ) {\n\t\t\t\tmemmove( pStage, pStage + 1, sizeof( *pStage ) * ( MAX_SHADER_STAGES - stage - 1 ) );\n\t\t\t\tCom_Memset(  pStage + 1, 0, sizeof( *pStage ) );\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t//\n\t\t// default texture coordinate generation\n\t\t//\n\t\tif ( pStage->bundle[0].isLightmap ) {\n\t\t\tif ( pStage->bundle[0].tcGen == TCGEN_BAD ) {\n\t\t\t\tpStage->bundle[0].tcGen = TCGEN_LIGHTMAP;\n\t\t\t}\n\t\t\thasLightmapStage = qtrue;\n\t\t} else {\n\t\t\tif ( pStage->bundle[0].tcGen == TCGEN_BAD ) {\n\t\t\t\tpStage->bundle[0].tcGen = TCGEN_TEXTURE;\n\t\t\t}\n\t\t}\n\n\n    // not a true lightmap but we want to leave existing \n    // behaviour in place and not print out a warning\n    //if (pStage->rgbGen == CGEN_VERTEX) {\n    //  vertexLightmap = qtrue;\n    //}\n\n\n\n\t\t//\n\t\t// determine sort order and fog color adjustment\n\t\t//\n\t\tif ( ( pStage->stateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) ) &&\n\t\t\t ( stages[0].stateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) ) ) {\n\t\t\tint blendSrcBits = pStage->stateBits & GLS_SRCBLEND_BITS;\n\t\t\tint blendDstBits = pStage->stateBits & GLS_DSTBLEND_BITS;\n\n\t\t\t// fog color adjustment only works for blend modes that have a contribution\n\t\t\t// that aproaches 0 as the modulate values aproach 0 --\n\t\t\t// GL_ONE, GL_ONE\n\t\t\t// GL_ZERO, GL_ONE_MINUS_SRC_COLOR\n\t\t\t// GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA\n\n\t\t\t// modulate, additive\n\t\t\tif ( ( ( blendSrcBits == GLS_SRCBLEND_ONE ) && ( blendDstBits == GLS_DSTBLEND_ONE ) ) ||\n\t\t\t\t( ( blendSrcBits == GLS_SRCBLEND_ZERO ) && ( blendDstBits == GLS_DSTBLEND_ONE_MINUS_SRC_COLOR ) ) ) {\n\t\t\t\tpStage->adjustColorsForFog = ACFF_MODULATE_RGB;\n\t\t\t}\n\t\t\t// strict blend\n\t\t\telse if ( ( blendSrcBits == GLS_SRCBLEND_SRC_ALPHA ) && ( blendDstBits == GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ) )\n\t\t\t{\n\t\t\t\tpStage->adjustColorsForFog = ACFF_MODULATE_ALPHA;\n\t\t\t}\n\t\t\t// premultiplied alpha\n\t\t\telse if ( ( blendSrcBits == GLS_SRCBLEND_ONE ) && ( blendDstBits == GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ) )\n\t\t\t{\n\t\t\t\tpStage->adjustColorsForFog = ACFF_MODULATE_RGBA;\n\t\t\t} else {\n\t\t\t\t// we can't adjust this one correctly, so it won't be exactly correct in fog\n\t\t\t}\n\n\t\t\t// don't screw with sort order if this is a portal or environment\n\t\t\tif ( !shader.sort ) {\n\t\t\t\t// see through item, like a grill or grate\n\t\t\t\tif ( pStage->stateBits & GLS_DEPTHMASK_TRUE ) {\n\t\t\t\t\tshader.sort = SS_SEE_THROUGH;\n\t\t\t\t} else {\n\t\t\t\t\tshader.sort = SS_BLEND0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// there are times when you will need to manually apply a sort to\n\t// opaque alpha tested shaders that have later blend passes\n\tif ( !shader.sort ) {\n\t\tshader.sort = SS_OPAQUE;\n\t}\n\n\t//\n\t// if we are in r_vertexLight mode, never use a lightmap texture\n\t//\n\tif ( stage > 1 && ( (r_vertexLight->integer && !r_uiFullScreen->integer) || glConfig.hardwareType == GLHW_PERMEDIA2 ) ) {\n\t\tVertexLightingCollapse();\n\t\tstage = 1;\n\t\thasLightmapStage = qfalse;\n\t}\n\n\t//\n\t// look for multitexture potential\n\t//\n\tif ( stage > 1 && CollapseMultitexture() ) {\n\t\tstage--;\n\t}\n\n\tif ( shader.lightmapIndex >= 0 && !hasLightmapStage ) {\n\t\tif (vertexLightmap) {\n\t\t\tri.Printf( PRINT_DEVELOPER, \"WARNING: shader '%s' has VERTEX forced lightmap!\\n\", shader.name );\n\t\t} else {\n\t\t\tri.Printf( PRINT_DEVELOPER, \"WARNING: shader '%s' has lightmap but no lightmap stage!\\n\", shader.name );\n  \t\t\tshader.lightmapIndex = LIGHTMAP_NONE;\n\t\t}\n\t}\n\n\n\t//\n\t// compute number of passes\n\t//\n\tshader.numUnfoggedPasses = stage;\n\n\t// fogonly shaders don't have any normal passes\n\tif ( stage == 0 ) {\n\t\tshader.sort = SS_FOG;\n\t}\n\n\t// determine which stage iterator function is appropriate\n\tComputeStageIteratorFunc();\n\n\treturn GeneratePermanentShader();\n}\n\n//========================================================================================\n\n/*\n====================\nFindShaderInShaderText\n\nScans the combined text description of all the shader files for\nthe given shader name.\n\nreturn NULL if not found\n\nIf found, it will return a valid shader\n=====================\n*/\nstatic char *FindShaderInShaderText( const char *shadername ) {\n\n\tchar *token, *p;\n\n\tint i, hash;\n\n\thash = generateHashValue(shadername, MAX_SHADERTEXT_HASH);\n\n\tfor (i = 0; shaderTextHashTable[hash][i]; i++) {\n\t\tp = shaderTextHashTable[hash][i];\n\t\ttoken = COM_ParseExt(&p, qtrue);\n\t\tif ( !Q_stricmp( token, shadername ) ) {\n\t\t\treturn p;\n\t\t}\n\t}\n\n\tp = s_shaderText;\n\n\tif ( !p ) {\n\t\treturn NULL;\n\t}\n\n\t// look for label\n\twhile ( 1 ) {\n\t\ttoken = COM_ParseExt( &p, qtrue );\n\t\tif ( token[0] == 0 ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif ( !Q_stricmp( token, shadername ) ) {\n\t\t\treturn p;\n\t\t}\n\t\telse {\n\t\t\t// skip the definition\n\t\t\tSkipBracedSection( &p );\n\t\t}\n\t}\n\n\treturn NULL;\n}\n\n\n/*\n==================\nR_FindShaderByName\n\nWill always return a valid shader, but it might be the\ndefault shader if the real one can't be found.\n==================\n*/\nshader_t *R_FindShaderByName( const char *name ) {\n\tchar\t\tstrippedName[MAX_QPATH];\n\tint\t\t\thash;\n\tshader_t\t*sh;\n\n\tif ( (name==NULL) || (name[0] == 0) ) {  // bk001205\n\t\treturn tr.defaultShader;\n\t}\n\n\tCOM_StripExtension( name, strippedName );\n\n\thash = generateHashValue(strippedName, FILE_HASH_SIZE);\n\n\t//\n\t// see if the shader is already loaded\n\t//\n\tfor (sh=hashTable[hash]; sh; sh=sh->next) {\n\t\t// NOTE: if there was no shader or image available with the name strippedName\n\t\t// then a default shader is created with lightmapIndex == LIGHTMAP_NONE, so we\n\t\t// have to check all default shaders otherwise for every call to R_FindShader\n\t\t// with that same strippedName a new default shader is created.\n\t\tif (Q_stricmp(sh->name, strippedName) == 0) {\n\t\t\t// match found\n\t\t\treturn sh;\n\t\t}\n\t}\n\n\treturn tr.defaultShader;\n}\n\n\n/*\n===============\nR_FindShader\n\nWill always return a valid shader, but it might be the\ndefault shader if the real one can't be found.\n\nIn the interest of not requiring an explicit shader text entry to\nbe defined for every single image used in the game, three default\nshader behaviors can be auto-created for any image:\n\nIf lightmapIndex == LIGHTMAP_NONE, then the image will have\ndynamic diffuse lighting applied to it, as apropriate for most\nentity skin surfaces.\n\nIf lightmapIndex == LIGHTMAP_2D, then the image will be used\nfor 2D rendering unless an explicit shader is found\n\nIf lightmapIndex == LIGHTMAP_BY_VERTEX, then the image will use\nthe vertex rgba modulate values, as apropriate for misc_model\npre-lit surfaces.\n\nOther lightmapIndex values will have a lightmap stage created\nand src*dest blending applied with the texture, as apropriate for\nmost world construction surfaces.\n\n===============\n*/\nshader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImage ) {\n\tchar\t\tstrippedName[MAX_QPATH];\n\tchar\t\tfileName[MAX_QPATH];\n\tint\t\t\ti, hash;\n\tchar\t\t*shaderText;\n\timage_t\t\t*image;\n\tshader_t\t*sh;\n\n\tif ( name[0] == 0 ) {\n\t\treturn tr.defaultShader;\n\t}\n\n\t// use (fullbright) vertex lighting if the bsp file doesn't have\n\t// lightmaps\n\tif ( lightmapIndex >= 0 && lightmapIndex >= tr.numLightmaps ) {\n\t\tlightmapIndex = LIGHTMAP_BY_VERTEX;\n\t}\n\n\tCOM_StripExtension( name, strippedName );\n\n\thash = generateHashValue(strippedName, FILE_HASH_SIZE);\n\n\t//\n\t// see if the shader is already loaded\n\t//\n\tfor (sh = hashTable[hash]; sh; sh = sh->next) {\n\t\t// NOTE: if there was no shader or image available with the name strippedName\n\t\t// then a default shader is created with lightmapIndex == LIGHTMAP_NONE, so we\n\t\t// have to check all default shaders otherwise for every call to R_FindShader\n\t\t// with that same strippedName a new default shader is created.\n\t\tif ( (sh->lightmapIndex == lightmapIndex || sh->defaultShader) &&\n\t\t     !Q_stricmp(sh->name, strippedName)) {\n\t\t\t// match found\n\t\t\treturn sh;\n\t\t}\n\t}\n\n\t// make sure the render thread is stopped, because we are probably\n\t// going to have to upload an image\n\tif (r_smp->integer) {\n\t\tR_SyncRenderThread();\n\t}\n\n\t// clear the global shader\n\tCom_Memset( &shader, 0, sizeof( shader ) );\n\tCom_Memset( &stages, 0, sizeof( stages ) );\n\tQ_strncpyz(shader.name, strippedName, sizeof(shader.name));\n\tshader.lightmapIndex = lightmapIndex;\n\tfor ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) {\n\t\tstages[i].bundle[0].texMods = texMods[i];\n\t}\n\n\t// FIXME: set these \"need\" values apropriately\n\tshader.needsNormal = qtrue;\n\tshader.needsST1 = qtrue;\n\tshader.needsST2 = qtrue;\n\tshader.needsColor = qtrue;\n\n\t//\n\t// attempt to define shader from an explicit parameter file\n\t//\n\tshaderText = FindShaderInShaderText( strippedName );\n\tif ( shaderText ) {\n\t\t// enable this when building a pak file to get a global list\n\t\t// of all explicit shaders\n\t\tif ( r_printShaders->integer ) {\n\t\t\tri.Printf( PRINT_ALL, \"*SHADER* %s\\n\", name );\n\t\t}\n\n\t\tif ( !ParseShader( &shaderText ) ) {\n\t\t\t// had errors, so use default shader\n\t\t\tshader.defaultShader = qtrue;\n\t\t}\n\t\tsh = FinishShader();\n\t\treturn sh;\n\t}\n\n\n\t//\n\t// if not defined in the in-memory shader descriptions,\n\t// look for a single TGA, BMP, or PCX\n\t//\n\tQ_strncpyz( fileName, name, sizeof( fileName ) );\n\tCOM_DefaultExtension( fileName, sizeof( fileName ), \".tga\" );\n\timage = R_FindImageFile( fileName, mipRawImage, mipRawImage, mipRawImage ? GL_REPEAT : GL_CLAMP );\n\tif ( !image ) {\n\t\tri.Printf( PRINT_DEVELOPER, \"Couldn't find image for shader %s\\n\", name );\n\t\tshader.defaultShader = qtrue;\n\t\treturn FinishShader();\n\t}\n\n\t//\n\t// create the default shading commands\n\t//\n\tif ( shader.lightmapIndex == LIGHTMAP_NONE ) {\n\t\t// dynamic colors at vertexes\n\t\tstages[0].bundle[0].image[0] = image;\n\t\tstages[0].active = qtrue;\n\t\tstages[0].rgbGen = CGEN_LIGHTING_DIFFUSE;\n\t\tstages[0].stateBits = GLS_DEFAULT;\n\t} else if ( shader.lightmapIndex == LIGHTMAP_BY_VERTEX ) {\n\t\t// explicit colors at vertexes\n\t\tstages[0].bundle[0].image[0] = image;\n\t\tstages[0].active = qtrue;\n\t\tstages[0].rgbGen = CGEN_EXACT_VERTEX;\n\t\tstages[0].alphaGen = AGEN_SKIP;\n\t\tstages[0].stateBits = GLS_DEFAULT;\n\t} else if ( shader.lightmapIndex == LIGHTMAP_2D ) {\n\t\t// GUI elements\n\t\tstages[0].bundle[0].image[0] = image;\n\t\tstages[0].active = qtrue;\n\t\tstages[0].rgbGen = CGEN_VERTEX;\n\t\tstages[0].alphaGen = AGEN_VERTEX;\n\t\tstages[0].stateBits = GLS_DEPTHTEST_DISABLE |\n\t\t\t  GLS_SRCBLEND_SRC_ALPHA |\n\t\t\t  GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA;\n\t} else if ( shader.lightmapIndex == LIGHTMAP_WHITEIMAGE ) {\n\t\t// fullbright level\n\t\tstages[0].bundle[0].image[0] = tr.whiteImage;\n\t\tstages[0].active = qtrue;\n\t\tstages[0].rgbGen = CGEN_IDENTITY_LIGHTING;\n\t\tstages[0].stateBits = GLS_DEFAULT;\n\n\t\tstages[1].bundle[0].image[0] = image;\n\t\tstages[1].active = qtrue;\n\t\tstages[1].rgbGen = CGEN_IDENTITY;\n\t\tstages[1].stateBits |= GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO;\n\t} else {\n\t\t// two pass lightmap\n\t\tstages[0].bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex];\n\t\tstages[0].bundle[0].isLightmap = qtrue;\n\t\tstages[0].active = qtrue;\n\t\tstages[0].rgbGen = CGEN_IDENTITY;\t// lightmaps are scaled on creation\n\t\t\t\t\t\t\t\t\t\t\t\t\t// for identitylight\n\t\tstages[0].stateBits = GLS_DEFAULT;\n\n\t\tstages[1].bundle[0].image[0] = image;\n\t\tstages[1].active = qtrue;\n\t\tstages[1].rgbGen = CGEN_IDENTITY;\n\t\tstages[1].stateBits |= GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO;\n\t}\n\n\treturn FinishShader();\n}\n\n\nqhandle_t RE_RegisterShaderFromImage(const char *name, int lightmapIndex, image_t *image, qboolean mipRawImage) {\n\tint\t\t\ti, hash;\n\tshader_t\t*sh;\n\n\thash = generateHashValue(name, FILE_HASH_SIZE);\n\t\n\t//\n\t// see if the shader is already loaded\n\t//\n\tfor (sh=hashTable[hash]; sh; sh=sh->next) {\n\t\t// NOTE: if there was no shader or image available with the name strippedName\n\t\t// then a default shader is created with lightmapIndex == LIGHTMAP_NONE, so we\n\t\t// have to check all default shaders otherwise for every call to R_FindShader\n\t\t// with that same strippedName a new default shader is created.\n\t\tif ( (sh->lightmapIndex == lightmapIndex || sh->defaultShader) &&\n\t\t\t// index by name\n\t\t\t!Q_stricmp(sh->name, name)) {\n\t\t\t// match found\n\t\t\treturn sh->index;\n\t\t}\n\t}\n\n\t// make sure the render thread is stopped, because we are probably\n\t// going to have to upload an image\n\tif (r_smp->integer) {\n\t\tR_SyncRenderThread();\n\t}\n\n\t// clear the global shader\n\tCom_Memset( &shader, 0, sizeof( shader ) );\n\tCom_Memset( &stages, 0, sizeof( stages ) );\n\tQ_strncpyz(shader.name, name, sizeof(shader.name));\n\tshader.lightmapIndex = lightmapIndex;\n\tfor ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) {\n\t\tstages[i].bundle[0].texMods = texMods[i];\n\t}\n\n\t// FIXME: set these \"need\" values apropriately\n\tshader.needsNormal = qtrue;\n\tshader.needsST1 = qtrue;\n\tshader.needsST2 = qtrue;\n\tshader.needsColor = qtrue;\n\n\t//\n\t// create the default shading commands\n\t//\n\tif ( shader.lightmapIndex == LIGHTMAP_NONE ) {\n\t\t// dynamic colors at vertexes\n\t\tstages[0].bundle[0].image[0] = image;\n\t\tstages[0].active = qtrue;\n\t\tstages[0].rgbGen = CGEN_LIGHTING_DIFFUSE;\n\t\tstages[0].stateBits = GLS_DEFAULT;\n\t} else if ( shader.lightmapIndex == LIGHTMAP_BY_VERTEX ) {\n\t\t// explicit colors at vertexes\n\t\tstages[0].bundle[0].image[0] = image;\n\t\tstages[0].active = qtrue;\n\t\tstages[0].rgbGen = CGEN_EXACT_VERTEX;\n\t\tstages[0].alphaGen = AGEN_SKIP;\n\t\tstages[0].stateBits = GLS_DEFAULT;\n\t} else if ( shader.lightmapIndex == LIGHTMAP_2D ) {\n\t\t// GUI elements\n\t\tstages[0].bundle[0].image[0] = image;\n\t\tstages[0].active = qtrue;\n\t\tstages[0].rgbGen = CGEN_VERTEX;\n\t\tstages[0].alphaGen = AGEN_VERTEX;\n\t\tstages[0].stateBits = GLS_DEPTHTEST_DISABLE |\n\t\t\t  GLS_SRCBLEND_SRC_ALPHA |\n\t\t\t  GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA;\n\t} else if ( shader.lightmapIndex == LIGHTMAP_WHITEIMAGE ) {\n\t\t// fullbright level\n\t\tstages[0].bundle[0].image[0] = tr.whiteImage;\n\t\tstages[0].active = qtrue;\n\t\tstages[0].rgbGen = CGEN_IDENTITY_LIGHTING;\n\t\tstages[0].stateBits = GLS_DEFAULT;\n\n\t\tstages[1].bundle[0].image[0] = image;\n\t\tstages[1].active = qtrue;\n\t\tstages[1].rgbGen = CGEN_IDENTITY;\n\t\tstages[1].stateBits |= GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO;\n\t} else {\n\t\t// two pass lightmap\n\t\tstages[0].bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex];\n\t\tstages[0].bundle[0].isLightmap = qtrue;\n\t\tstages[0].active = qtrue;\n\t\tstages[0].rgbGen = CGEN_IDENTITY;\t// lightmaps are scaled on creation\n\t\t\t\t\t\t\t\t\t\t\t\t\t// for identitylight\n\t\tstages[0].stateBits = GLS_DEFAULT;\n\n\t\tstages[1].bundle[0].image[0] = image;\n\t\tstages[1].active = qtrue;\n\t\tstages[1].rgbGen = CGEN_IDENTITY;\n\t\tstages[1].stateBits |= GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO;\n\t}\n\n\tsh = FinishShader();\n  return sh->index; \n}\n\n\n/* \n====================\nRE_RegisterShader\n\nThis is the exported shader entry point for the rest of the system\nIt will always return an index that will be valid.\n\nThis should really only be used for explicit shaders, because there is no\nway to ask for different implicit lighting modes (vertex, lightmap, etc)\n====================\n*/\nqhandle_t RE_RegisterShaderLightMap( const char *name, int lightmapIndex ) {\n\tshader_t\t*sh;\n\n\tif ( strlen( name ) >= MAX_QPATH ) {\n\t\tCom_Printf( \"Shader name exceeds MAX_QPATH\\n\" );\n\t\treturn 0;\n\t}\n\n\tsh = R_FindShader( name, lightmapIndex, qtrue );\n\n\t// we want to return 0 if the shader failed to\n\t// load for some reason, but R_FindShader should\n\t// still keep a name allocated for it, so if\n\t// something calls RE_RegisterShader again with\n\t// the same name, we don't try looking for it again\n\tif ( sh->defaultShader ) {\n\t\treturn 0;\n\t}\n\n\treturn sh->index;\n}\n\n\n/* \n====================\nRE_RegisterShader\n\nThis is the exported shader entry point for the rest of the system\nIt will always return an index that will be valid.\n\nThis should really only be used for explicit shaders, because there is no\nway to ask for different implicit lighting modes (vertex, lightmap, etc)\n====================\n*/\nqhandle_t RE_RegisterShader( const char *name ) {\n\tshader_t\t*sh;\n\n\tif ( strlen( name ) >= MAX_QPATH ) {\n\t\tCom_Printf( \"Shader name exceeds MAX_QPATH\\n\" );\n\t\treturn 0;\n\t}\n\n\tsh = R_FindShader( name, LIGHTMAP_2D, qtrue );\n\n\t// we want to return 0 if the shader failed to\n\t// load for some reason, but R_FindShader should\n\t// still keep a name allocated for it, so if\n\t// something calls RE_RegisterShader again with\n\t// the same name, we don't try looking for it again\n\tif ( sh->defaultShader ) {\n\t\treturn 0;\n\t}\n\n\treturn sh->index;\n}\n\n\n/*\n====================\nRE_RegisterShaderNoMip\n\nFor menu graphics that should never be picmiped\n====================\n*/\nqhandle_t RE_RegisterShaderNoMip( const char *name ) {\n\tshader_t\t*sh;\n\n\tif ( strlen( name ) >= MAX_QPATH ) {\n\t\tCom_Printf( \"Shader name exceeds MAX_QPATH\\n\" );\n\t\treturn 0;\n\t}\n\n\tsh = R_FindShader( name, LIGHTMAP_2D, qfalse );\n\n\t// we want to return 0 if the shader failed to\n\t// load for some reason, but R_FindShader should\n\t// still keep a name allocated for it, so if\n\t// something calls RE_RegisterShader again with\n\t// the same name, we don't try looking for it again\n\tif ( sh->defaultShader ) {\n\t\treturn 0;\n\t}\n\n\treturn sh->index;\n}\n\n\n/*\n====================\nR_GetShaderByHandle\n\nWhen a handle is passed in by another module, this range checks\nit and returns a valid (possibly default) shader_t to be used internally.\n====================\n*/\nshader_t *R_GetShaderByHandle( qhandle_t hShader ) {\n\tif ( hShader < 0 ) {\n\t  ri.Printf( PRINT_WARNING, \"R_GetShaderByHandle: out of range hShader '%d'\\n\", hShader ); // bk: FIXME name\n\t\treturn tr.defaultShader;\n\t}\n\tif ( hShader >= tr.numShaders ) {\n\t\tri.Printf( PRINT_WARNING, \"R_GetShaderByHandle: out of range hShader '%d'\\n\", hShader );\n\t\treturn tr.defaultShader;\n\t}\n\treturn tr.shaders[hShader];\n}\n\n/*\n===============\nR_ShaderList_f\n\nDump information on all valid shaders to the console\nA second parameter will cause it to print in sorted order\n===============\n*/\nvoid\tR_ShaderList_f (void) {\n\tint\t\t\ti;\n\tint\t\t\tcount;\n\tshader_t\t*shader;\n\n\tri.Printf (PRINT_ALL, \"-----------------------\\n\");\n\n\tcount = 0;\n\tfor ( i = 0 ; i < tr.numShaders ; i++ ) {\n\t\tif ( ri.Cmd_Argc() > 1 ) {\n\t\t\tshader = tr.sortedShaders[i];\n\t\t} else {\n\t\t\tshader = tr.shaders[i];\n\t\t}\n\n\t\tri.Printf( PRINT_ALL, \"%i \", shader->numUnfoggedPasses );\n\n\t\tif (shader->lightmapIndex >= 0 ) {\n\t\t\tri.Printf (PRINT_ALL, \"L \");\n\t\t} else {\n\t\t\tri.Printf (PRINT_ALL, \"  \");\n\t\t}\n\t\tif ( shader->multitextureEnv == GL_ADD ) {\n\t\t\tri.Printf( PRINT_ALL, \"MT(a) \" );\n\t\t} else if ( shader->multitextureEnv == GL_MODULATE ) {\n\t\t\tri.Printf( PRINT_ALL, \"MT(m) \" );\n\t\t} else if ( shader->multitextureEnv == GL_DECAL ) {\n\t\t\tri.Printf( PRINT_ALL, \"MT(d) \" );\n\t\t} else {\n\t\t\tri.Printf( PRINT_ALL, \"      \" );\n\t\t}\n\t\tif ( shader->explicitlyDefined ) {\n\t\t\tri.Printf( PRINT_ALL, \"E \" );\n\t\t} else {\n\t\t\tri.Printf( PRINT_ALL, \"  \" );\n\t\t}\n\n\t\tif ( shader->optimalStageIteratorFunc == RB_StageIteratorGeneric ) {\n\t\t\tri.Printf( PRINT_ALL, \"gen \" );\n\t\t} else if ( shader->optimalStageIteratorFunc == RB_StageIteratorSky ) {\n\t\t\tri.Printf( PRINT_ALL, \"sky \" );\n\t\t} else if ( shader->optimalStageIteratorFunc == RB_StageIteratorLightmappedMultitexture ) {\n\t\t\tri.Printf( PRINT_ALL, \"lmmt\" );\n\t\t} else if ( shader->optimalStageIteratorFunc == RB_StageIteratorVertexLitTexture ) {\n\t\t\tri.Printf( PRINT_ALL, \"vlt \" );\n\t\t} else {\n\t\t\tri.Printf( PRINT_ALL, \"    \" );\n\t\t}\n\n\t\tif ( shader->defaultShader ) {\n\t\t\tri.Printf (PRINT_ALL,  \": %s (DEFAULTED)\\n\", shader->name);\n\t\t} else {\n\t\t\tri.Printf (PRINT_ALL,  \": %s\\n\", shader->name);\n\t\t}\n\t\tcount++;\n\t}\n\tri.Printf (PRINT_ALL, \"%i total shaders\\n\", count);\n\tri.Printf (PRINT_ALL, \"------------------\\n\");\n}\n\n\n/*\n====================\nScanAndLoadShaderFiles\n\nFinds and loads all .shader files, combining them into\na single large text block that can be scanned for shader names\n=====================\n*/\n#define\tMAX_SHADER_FILES\t4096\nstatic void ScanAndLoadShaderFiles( void )\n{\n\tchar **shaderFiles;\n\tchar *buffers[MAX_SHADER_FILES];\n\tchar *p;\n\tint numShaders;\n\tint i;\n\tchar *oldp, *token, *hashMem;\n\tint shaderTextHashTableSizes[MAX_SHADERTEXT_HASH], hash, size;\n\n\tlong sum = 0;\n\t// scan for shader files\n\tshaderFiles = ri.FS_ListFiles( \"scripts\", \".shader\", &numShaders );\n\n\tif ( !shaderFiles || !numShaders )\n\t{\n\t\tri.Printf( PRINT_WARNING, \"WARNING: no shader files found\\n\" );\n\t\treturn;\n\t}\n\n\tif ( numShaders > MAX_SHADER_FILES ) {\n\t\tnumShaders = MAX_SHADER_FILES;\n\t}\n\n\t// load and parse shader files\n\tfor ( i = 0; i < numShaders; i++ )\n\t{\n\t\tchar filename[MAX_QPATH];\n\n\t\tCom_sprintf( filename, sizeof( filename ), \"scripts/%s\", shaderFiles[i] );\n\t\tri.Printf( PRINT_ALL, \"...loading '%s'\\n\", filename );\n\t\tsum += ri.FS_ReadFile( filename, (void **)&buffers[i] );\n\t\tif ( !buffers[i] ) {\n\t\t\tri.Error( ERR_DROP, \"Couldn't load %s\", filename );\n\t\t}\n\t}\n\n\t// build single large buffer\n\ts_shaderText = ri.Hunk_Alloc( sum + numShaders*2, h_low );\n\n\t// free in reverse order, so the temp files are all dumped\n\tfor ( i = numShaders - 1; i >= 0 ; i-- ) {\n\t\tstrcat( s_shaderText, \"\\n\" );\n\t\tp = &s_shaderText[strlen(s_shaderText)];\n\t\tstrcat( s_shaderText, buffers[i] );\n\t\tri.FS_FreeFile( buffers[i] );\n\t\tbuffers[i] = p;\n\t\tCOM_Compress(p);\n\t}\n\n\t// free up memory\n\tri.FS_FreeFileList( shaderFiles );\n\n\tCom_Memset(shaderTextHashTableSizes, 0, sizeof(shaderTextHashTableSizes));\n\tsize = 0;\n\t//\n\tfor ( i = 0; i < numShaders; i++ ) {\n\t\t// pointer to the first shader file\n\t\tp = buffers[i];\n\t\t// look for label\n\t\twhile ( 1 ) {\n\t\t\ttoken = COM_ParseExt( &p, qtrue );\n\t\t\tif ( token[0] == 0 ) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\thash = generateHashValue(token, MAX_SHADERTEXT_HASH);\n\t\t\tshaderTextHashTableSizes[hash]++;\n\t\t\tsize++;\n\t\t\tSkipBracedSection(&p);\n\t\t\t// if we passed the pointer to the next shader file\n\t\t\tif ( i < numShaders - 1 ) {\n\t\t\t\tif ( p > buffers[i+1] ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tsize += MAX_SHADERTEXT_HASH;\n\n\thashMem = ri.Hunk_Alloc( size * sizeof(char *), h_low );\n\n\tfor (i = 0; i < MAX_SHADERTEXT_HASH; i++) {\n\t\tshaderTextHashTable[i] = (char **) hashMem;\n\t\thashMem = ((char *) hashMem) + ((shaderTextHashTableSizes[i] + 1) * sizeof(char *));\n\t}\n\n\tCom_Memset(shaderTextHashTableSizes, 0, sizeof(shaderTextHashTableSizes));\n\t//\n\tfor ( i = 0; i < numShaders; i++ ) {\n\t\t// pointer to the first shader file\n\t\tp = buffers[i];\n\t\t// look for label\n\t\twhile ( 1 ) {\n\t\t\toldp = p;\n\t\t\ttoken = COM_ParseExt( &p, qtrue );\n\t\t\tif ( token[0] == 0 ) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\thash = generateHashValue(token, MAX_SHADERTEXT_HASH);\n\t\t\tshaderTextHashTable[hash][shaderTextHashTableSizes[hash]++] = oldp;\n\n\t\t\tSkipBracedSection(&p);\n\t\t\t// if we passed the pointer to the next shader file\n\t\t\tif ( i < numShaders - 1 ) {\n\t\t\t\tif ( p > buffers[i+1] ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn;\n\n}\n\n\n/*\n====================\nCreateInternalShaders\n====================\n*/\nstatic void CreateInternalShaders( void ) {\n\ttr.numShaders = 0;\n\n\t// init the default shader\n\tCom_Memset( &shader, 0, sizeof( shader ) );\n\tCom_Memset( &stages, 0, sizeof( stages ) );\n\n\tQ_strncpyz( shader.name, \"<default>\", sizeof( shader.name ) );\n\n\tshader.lightmapIndex = LIGHTMAP_NONE;\n\tstages[0].bundle[0].image[0] = tr.defaultImage;\n\tstages[0].active = qtrue;\n\tstages[0].stateBits = GLS_DEFAULT;\n\ttr.defaultShader = FinishShader();\n\n\t// shadow shader is just a marker\n\tQ_strncpyz( shader.name, \"<stencil shadow>\", sizeof( shader.name ) );\n\tshader.sort = SS_STENCIL_SHADOW;\n\ttr.shadowShader = FinishShader();\n}\n\nstatic void CreateExternalShaders( void ) {\n\ttr.projectionShadowShader = R_FindShader( \"projectionShadow\", LIGHTMAP_NONE, qtrue );\n\ttr.flareShader = R_FindShader( \"flareShader\", LIGHTMAP_NONE, qtrue );\n\ttr.sunShader = R_FindShader( \"sun\", LIGHTMAP_NONE, qtrue );\n}\n\n/*\n==================\nR_InitShaders\n==================\n*/\nvoid R_InitShaders( void ) {\n\tri.Printf( PRINT_ALL, \"Initializing Shaders\\n\" );\n\n\tCom_Memset(hashTable, 0, sizeof(hashTable));\n\n\tdeferLoad = qfalse;\n\n\tCreateInternalShaders();\n\n\tScanAndLoadShaderFiles();\n\n\tCreateExternalShaders();\n}\n"
  },
  {
    "path": "code/renderer/tr_shadows.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"tr_local.h\"\n\n\n/*\n\n  for a projection shadow:\n\n  point[x] += light vector * ( z - shadow plane )\n  point[y] +=\n  point[z] = shadow plane\n\n  1 0 light[x] / light[z]\n\n*/\n\ntypedef struct {\n\tint\t\ti2;\n\tint\t\tfacing;\n} edgeDef_t;\n\n#define\tMAX_EDGE_DEFS\t32\n\nstatic\tedgeDef_t\tedgeDefs[SHADER_MAX_VERTEXES][MAX_EDGE_DEFS];\nstatic\tint\t\t\tnumEdgeDefs[SHADER_MAX_VERTEXES];\nstatic\tint\t\t\tfacing[SHADER_MAX_INDEXES/3];\n\nvoid R_AddEdgeDef( int i1, int i2, int facing ) {\n\tint\t\tc;\n\n\tc = numEdgeDefs[ i1 ];\n\tif ( c == MAX_EDGE_DEFS ) {\n\t\treturn;\t\t// overflow\n\t}\n\tedgeDefs[ i1 ][ c ].i2 = i2;\n\tedgeDefs[ i1 ][ c ].facing = facing;\n\n\tnumEdgeDefs[ i1 ]++;\n}\n\nvoid R_RenderShadowEdges( void ) {\n\tint\t\ti;\n\n#if 0\n\tint\t\tnumTris;\n\n\t// dumb way -- render every triangle's edges\n\tnumTris = tess.numIndexes / 3;\n\n\tfor ( i = 0 ; i < numTris ; i++ ) {\n\t\tint\t\ti1, i2, i3;\n\n\t\tif ( !facing[i] ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\ti1 = tess.indexes[ i*3 + 0 ];\n\t\ti2 = tess.indexes[ i*3 + 1 ];\n\t\ti3 = tess.indexes[ i*3 + 2 ];\n\n\t\tqglBegin( GL_TRIANGLE_STRIP );\n\t\tqglVertex3fv( tess.xyz[ i1 ] );\n\t\tqglVertex3fv( tess.xyz[ i1 + tess.numVertexes ] );\n\t\tqglVertex3fv( tess.xyz[ i2 ] );\n\t\tqglVertex3fv( tess.xyz[ i2 + tess.numVertexes ] );\n\t\tqglVertex3fv( tess.xyz[ i3 ] );\n\t\tqglVertex3fv( tess.xyz[ i3 + tess.numVertexes ] );\n\t\tqglVertex3fv( tess.xyz[ i1 ] );\n\t\tqglVertex3fv( tess.xyz[ i1 + tess.numVertexes ] );\n\t\tqglEnd();\n\t}\n#else\n\tint\t\tc, c2;\n\tint\t\tj, k;\n\tint\t\ti2;\n\tint\t\tc_edges, c_rejected;\n\tint\t\thit[2];\n\n\t// an edge is NOT a silhouette edge if its face doesn't face the light,\n\t// or if it has a reverse paired edge that also faces the light.\n\t// A well behaved polyhedron would have exactly two faces for each edge,\n\t// but lots of models have dangling edges or overfanned edges\n\tc_edges = 0;\n\tc_rejected = 0;\n\n\tfor ( i = 0 ; i < tess.numVertexes ; i++ ) {\n\t\tc = numEdgeDefs[ i ];\n\t\tfor ( j = 0 ; j < c ; j++ ) {\n\t\t\tif ( !edgeDefs[ i ][ j ].facing ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\thit[0] = 0;\n\t\t\thit[1] = 0;\n\n\t\t\ti2 = edgeDefs[ i ][ j ].i2;\n\t\t\tc2 = numEdgeDefs[ i2 ];\n\t\t\tfor ( k = 0 ; k < c2 ; k++ ) {\n\t\t\t\tif ( edgeDefs[ i2 ][ k ].i2 == i ) {\n\t\t\t\t\thit[ edgeDefs[ i2 ][ k ].facing ]++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// if it doesn't share the edge with another front facing\n\t\t\t// triangle, it is a sil edge\n\t\t\tif ( hit[ 1 ] == 0 ) {\n\t\t\t\tqglBegin( GL_TRIANGLE_STRIP );\n\t\t\t\tqglVertex3fv( tess.xyz[ i ] );\n\t\t\t\tqglVertex3fv( tess.xyz[ i + tess.numVertexes ] );\n\t\t\t\tqglVertex3fv( tess.xyz[ i2 ] );\n\t\t\t\tqglVertex3fv( tess.xyz[ i2 + tess.numVertexes ] );\n\t\t\t\tqglEnd();\n\t\t\t\tc_edges++;\n\t\t\t} else {\n\t\t\t\tc_rejected++;\n\t\t\t}\n\t\t}\n\t}\n#endif\n}\n\n/*\n=================\nRB_ShadowTessEnd\n\ntriangleFromEdge[ v1 ][ v2 ]\n\n\n  set triangle from edge( v1, v2, tri )\n  if ( facing[ triangleFromEdge[ v1 ][ v2 ] ] && !facing[ triangleFromEdge[ v2 ][ v1 ] ) {\n  }\n=================\n*/\nvoid RB_ShadowTessEnd( void ) {\n\tint\t\ti;\n\tint\t\tnumTris;\n\tvec3_t\tlightDir;\n\n\t// we can only do this if we have enough space in the vertex buffers\n\tif ( tess.numVertexes >= SHADER_MAX_VERTEXES / 2 ) {\n\t\treturn;\n\t}\n\n\tif ( glConfig.stencilBits < 4 ) {\n\t\treturn;\n\t}\n\n\tVectorCopy( backEnd.currentEntity->lightDir, lightDir );\n\n\t// project vertexes away from light direction\n\tfor ( i = 0 ; i < tess.numVertexes ; i++ ) {\n\t\tVectorMA( tess.xyz[i], -512, lightDir, tess.xyz[i+tess.numVertexes] );\n\t}\n\n\t// decide which triangles face the light\n\tCom_Memset( numEdgeDefs, 0, 4 * tess.numVertexes );\n\n\tnumTris = tess.numIndexes / 3;\n\tfor ( i = 0 ; i < numTris ; i++ ) {\n\t\tint\t\ti1, i2, i3;\n\t\tvec3_t\td1, d2, normal;\n\t\tfloat\t*v1, *v2, *v3;\n\t\tfloat\td;\n\n\t\ti1 = tess.indexes[ i*3 + 0 ];\n\t\ti2 = tess.indexes[ i*3 + 1 ];\n\t\ti3 = tess.indexes[ i*3 + 2 ];\n\n\t\tv1 = tess.xyz[ i1 ];\n\t\tv2 = tess.xyz[ i2 ];\n\t\tv3 = tess.xyz[ i3 ];\n\n\t\tVectorSubtract( v2, v1, d1 );\n\t\tVectorSubtract( v3, v1, d2 );\n\t\tCrossProduct( d1, d2, normal );\n\n\t\td = DotProduct( normal, lightDir );\n\t\tif ( d > 0 ) {\n\t\t\tfacing[ i ] = 1;\n\t\t} else {\n\t\t\tfacing[ i ] = 0;\n\t\t}\n\n\t\t// create the edges\n\t\tR_AddEdgeDef( i1, i2, facing[ i ] );\n\t\tR_AddEdgeDef( i2, i3, facing[ i ] );\n\t\tR_AddEdgeDef( i3, i1, facing[ i ] );\n\t}\n\n\t// draw the silhouette edges\n\n\tGL_Bind( tr.whiteImage );\n\tqglEnable( GL_CULL_FACE );\n\tGL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO );\n\tqglColor3f( 0.2f, 0.2f, 0.2f );\n\n\t// don't write to the color buffer\n\tqglColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );\n\n\tqglEnable( GL_STENCIL_TEST );\n\tqglStencilFunc( GL_ALWAYS, 1, 255 );\n\n\t// mirrors have the culling order reversed\n\tif ( backEnd.viewParms.isMirror ) {\n\t\tqglCullFace( GL_FRONT );\n\t\tqglStencilOp( GL_KEEP, GL_KEEP, GL_INCR );\n\n\t\tR_RenderShadowEdges();\n\n\t\tqglCullFace( GL_BACK );\n\t\tqglStencilOp( GL_KEEP, GL_KEEP, GL_DECR );\n\n\t\tR_RenderShadowEdges();\n\t} else {\n\t\tqglCullFace( GL_BACK );\n\t\tqglStencilOp( GL_KEEP, GL_KEEP, GL_INCR );\n\n\t\tR_RenderShadowEdges();\n\n\t\tqglCullFace( GL_FRONT );\n\t\tqglStencilOp( GL_KEEP, GL_KEEP, GL_DECR );\n\n\t\tR_RenderShadowEdges();\n\t}\n\n\n\t// reenable writing to the color buffer\n\tqglColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );\n}\n\n\n/*\n=================\nRB_ShadowFinish\n\nDarken everything that is is a shadow volume.\nWe have to delay this until everything has been shadowed,\nbecause otherwise shadows from different body parts would\noverlap and double darken.\n=================\n*/\nvoid RB_ShadowFinish( void ) {\n\tif ( r_shadows->integer != 2 ) {\n\t\treturn;\n\t}\n\tif ( glConfig.stencilBits < 4 ) {\n\t\treturn;\n\t}\n\tqglEnable( GL_STENCIL_TEST );\n\tqglStencilFunc( GL_NOTEQUAL, 0, 255 );\n\n\tqglDisable (GL_CLIP_PLANE0);\n\tqglDisable (GL_CULL_FACE);\n\n\tGL_Bind( tr.whiteImage );\n\n    qglLoadIdentity ();\n\n\tqglColor3f( 0.6f, 0.6f, 0.6f );\n\tGL_State( GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO );\n\n//\tqglColor3f( 1, 0, 0 );\n//\tGL_State( GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO );\n\n\tqglBegin( GL_QUADS );\n\tqglVertex3f( -100, 100, -10 );\n\tqglVertex3f( 100, 100, -10 );\n\tqglVertex3f( 100, -100, -10 );\n\tqglVertex3f( -100, -100, -10 );\n\tqglEnd ();\n\n\tqglColor4f(1,1,1,1);\n\tqglDisable( GL_STENCIL_TEST );\n}\n\n\n/*\n=================\nRB_ProjectionShadowDeform\n\n=================\n*/\nvoid RB_ProjectionShadowDeform( void ) {\n\tfloat\t*xyz;\n\tint\t\ti;\n\tfloat\th;\n\tvec3_t\tground;\n\tvec3_t\tlight;\n\tfloat\tgroundDist;\n\tfloat\td;\n\tvec3_t\tlightDir;\n\n\txyz = ( float * ) tess.xyz;\n\n\tground[0] = backEnd.or.axis[0][2];\n\tground[1] = backEnd.or.axis[1][2];\n\tground[2] = backEnd.or.axis[2][2];\n\n\tgroundDist = backEnd.or.origin[2] - backEnd.currentEntity->e.shadowPlane;\n\n\tVectorCopy( backEnd.currentEntity->lightDir, lightDir );\n\td = DotProduct( lightDir, ground );\n\t// don't let the shadows get too long or go negative\n\tif ( d < 0.5 ) {\n\t\tVectorMA( lightDir, (0.5 - d), ground, lightDir );\n\t\td = DotProduct( lightDir, ground );\n\t}\n\td = 1.0 / d;\n\n\tlight[0] = lightDir[0] * d;\n\tlight[1] = lightDir[1] * d;\n\tlight[2] = lightDir[2] * d;\n\n\tfor ( i = 0; i < tess.numVertexes; i++, xyz += 4 ) {\n\t\th = DotProduct( xyz, ground ) + groundDist;\n\n\t\txyz[0] -= light[0] * h;\n\t\txyz[1] -= light[1] * h;\n\t\txyz[2] -= light[2] * h;\n\t}\n}\n"
  },
  {
    "path": "code/renderer/tr_sky.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// tr_sky.c\n#include \"tr_local.h\"\n\n#define SKY_SUBDIVISIONS\t\t8\n#define HALF_SKY_SUBDIVISIONS\t(SKY_SUBDIVISIONS/2)\n\nstatic float s_cloudTexCoords[6][SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1][2];\nstatic float s_cloudTexP[6][SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1];\n\n/*\n===================================================================================\n\nPOLYGON TO BOX SIDE PROJECTION\n\n===================================================================================\n*/\n\nstatic vec3_t sky_clip[6] = \n{\n\t{1,1,0},\n\t{1,-1,0},\n\t{0,-1,1},\n\t{0,1,1},\n\t{1,0,1},\n\t{-1,0,1} \n};\n\nstatic float\tsky_mins[2][6], sky_maxs[2][6];\nstatic float\tsky_min, sky_max;\n\n/*\n================\nAddSkyPolygon\n================\n*/\nstatic void AddSkyPolygon (int nump, vec3_t vecs) \n{\n\tint\t\ti,j;\n\tvec3_t\tv, av;\n\tfloat\ts, t, dv;\n\tint\t\taxis;\n\tfloat\t*vp;\n\t// s = [0]/[2], t = [1]/[2]\n\tstatic int\tvec_to_st[6][3] =\n\t{\n\t\t{-2,3,1},\n\t\t{2,3,-1},\n\n\t\t{1,3,2},\n\t\t{-1,3,-2},\n\n\t\t{-2,-1,3},\n\t\t{-2,1,-3}\n\n\t//\t{-1,2,3},\n\t//\t{1,2,-3}\n\t};\n\n\t// decide which face it maps to\n\tVectorCopy (vec3_origin, v);\n\tfor (i=0, vp=vecs ; i<nump ; i++, vp+=3)\n\t{\n\t\tVectorAdd (vp, v, v);\n\t}\n\tav[0] = fabs(v[0]);\n\tav[1] = fabs(v[1]);\n\tav[2] = fabs(v[2]);\n\tif (av[0] > av[1] && av[0] > av[2])\n\t{\n\t\tif (v[0] < 0)\n\t\t\taxis = 1;\n\t\telse\n\t\t\taxis = 0;\n\t}\n\telse if (av[1] > av[2] && av[1] > av[0])\n\t{\n\t\tif (v[1] < 0)\n\t\t\taxis = 3;\n\t\telse\n\t\t\taxis = 2;\n\t}\n\telse\n\t{\n\t\tif (v[2] < 0)\n\t\t\taxis = 5;\n\t\telse\n\t\t\taxis = 4;\n\t}\n\n\t// project new texture coords\n\tfor (i=0 ; i<nump ; i++, vecs+=3)\n\t{\n\t\tj = vec_to_st[axis][2];\n\t\tif (j > 0)\n\t\t\tdv = vecs[j - 1];\n\t\telse\n\t\t\tdv = -vecs[-j - 1];\n\t\tif (dv < 0.001)\n\t\t\tcontinue;\t// don't divide by zero\n\t\tj = vec_to_st[axis][0];\n\t\tif (j < 0)\n\t\t\ts = -vecs[-j -1] / dv;\n\t\telse\n\t\t\ts = vecs[j-1] / dv;\n\t\tj = vec_to_st[axis][1];\n\t\tif (j < 0)\n\t\t\tt = -vecs[-j -1] / dv;\n\t\telse\n\t\t\tt = vecs[j-1] / dv;\n\n\t\tif (s < sky_mins[0][axis])\n\t\t\tsky_mins[0][axis] = s;\n\t\tif (t < sky_mins[1][axis])\n\t\t\tsky_mins[1][axis] = t;\n\t\tif (s > sky_maxs[0][axis])\n\t\t\tsky_maxs[0][axis] = s;\n\t\tif (t > sky_maxs[1][axis])\n\t\t\tsky_maxs[1][axis] = t;\n\t}\n}\n\n#define\tON_EPSILON\t\t0.1f\t\t\t// point on plane side epsilon\n#define\tMAX_CLIP_VERTS\t64\n/*\n================\nClipSkyPolygon\n================\n*/\nstatic void ClipSkyPolygon (int nump, vec3_t vecs, int stage) \n{\n\tfloat\t*norm;\n\tfloat\t*v;\n\tqboolean\tfront, back;\n\tfloat\td, e;\n\tfloat\tdists[MAX_CLIP_VERTS];\n\tint\t\tsides[MAX_CLIP_VERTS];\n\tvec3_t\tnewv[2][MAX_CLIP_VERTS];\n\tint\t\tnewc[2];\n\tint\t\ti, j;\n\n\tif (nump > MAX_CLIP_VERTS-2)\n\t\tri.Error (ERR_DROP, \"ClipSkyPolygon: MAX_CLIP_VERTS\");\n\tif (stage == 6)\n\t{\t// fully clipped, so draw it\n\t\tAddSkyPolygon (nump, vecs);\n\t\treturn;\n\t}\n\n\tfront = back = qfalse;\n\tnorm = sky_clip[stage];\n\tfor (i=0, v = vecs ; i<nump ; i++, v+=3)\n\t{\n\t\td = DotProduct (v, norm);\n\t\tif (d > ON_EPSILON)\n\t\t{\n\t\t\tfront = qtrue;\n\t\t\tsides[i] = SIDE_FRONT;\n\t\t}\n\t\telse if (d < -ON_EPSILON)\n\t\t{\n\t\t\tback = qtrue;\n\t\t\tsides[i] = SIDE_BACK;\n\t\t}\n\t\telse\n\t\t\tsides[i] = SIDE_ON;\n\t\tdists[i] = d;\n\t}\n\n\tif (!front || !back)\n\t{\t// not clipped\n\t\tClipSkyPolygon (nump, vecs, stage+1);\n\t\treturn;\n\t}\n\n\t// clip it\n\tsides[i] = sides[0];\n\tdists[i] = dists[0];\n\tVectorCopy (vecs, (vecs+(i*3)) );\n\tnewc[0] = newc[1] = 0;\n\n\tfor (i=0, v = vecs ; i<nump ; i++, v+=3)\n\t{\n\t\tswitch (sides[i])\n\t\t{\n\t\tcase SIDE_FRONT:\n\t\t\tVectorCopy (v, newv[0][newc[0]]);\n\t\t\tnewc[0]++;\n\t\t\tbreak;\n\t\tcase SIDE_BACK:\n\t\t\tVectorCopy (v, newv[1][newc[1]]);\n\t\t\tnewc[1]++;\n\t\t\tbreak;\n\t\tcase SIDE_ON:\n\t\t\tVectorCopy (v, newv[0][newc[0]]);\n\t\t\tnewc[0]++;\n\t\t\tVectorCopy (v, newv[1][newc[1]]);\n\t\t\tnewc[1]++;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (sides[i] == SIDE_ON || sides[i+1] == SIDE_ON || sides[i+1] == sides[i])\n\t\t\tcontinue;\n\n\t\td = dists[i] / (dists[i] - dists[i+1]);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\te = v[j] + d*(v[j+3] - v[j]);\n\t\t\tnewv[0][newc[0]][j] = e;\n\t\t\tnewv[1][newc[1]][j] = e;\n\t\t}\n\t\tnewc[0]++;\n\t\tnewc[1]++;\n\t}\n\n\t// continue\n\tClipSkyPolygon (newc[0], newv[0][0], stage+1);\n\tClipSkyPolygon (newc[1], newv[1][0], stage+1);\n}\n\n/*\n==============\nClearSkyBox\n==============\n*/\nstatic void ClearSkyBox (void) {\n\tint\t\ti;\n\n\tfor (i=0 ; i<6 ; i++) {\n\t\tsky_mins[0][i] = sky_mins[1][i] = 9999;\n\t\tsky_maxs[0][i] = sky_maxs[1][i] = -9999;\n\t}\n}\n\n/*\n================\nRB_ClipSkyPolygons\n================\n*/\nvoid RB_ClipSkyPolygons( shaderCommands_t *input )\n{\n\tvec3_t\t\tp[5];\t// need one extra point for clipping\n\tint\t\t\ti, j;\n\n\tClearSkyBox();\n\n\tfor ( i = 0; i < input->numIndexes; i += 3 )\n\t{\n\t\tfor (j = 0 ; j < 3 ; j++) \n\t\t{\n\t\t\tVectorSubtract( input->xyz[input->indexes[i+j]],\n\t\t\t\t\t\t\tbackEnd.viewParms.or.origin, \n\t\t\t\t\t\t\tp[j] );\n\t\t}\n\t\tClipSkyPolygon( 3, p[0], 0 );\n\t}\n}\n\n/*\n===================================================================================\n\nCLOUD VERTEX GENERATION\n\n===================================================================================\n*/\n\n/*\n** MakeSkyVec\n**\n** Parms: s, t range from -1 to 1\n*/\nstatic void MakeSkyVec( float s, float t, int axis, float outSt[2], vec3_t outXYZ )\n{\n\t// 1 = s, 2 = t, 3 = 2048\n\tstatic int\tst_to_vec[6][3] =\n\t{\n\t\t{3,-1,2},\n\t\t{-3,1,2},\n\n\t\t{1,3,2},\n\t\t{-1,-3,2},\n\n\t\t{-2,-1,3},\t\t// 0 degrees yaw, look straight up\n\t\t{2,-1,-3}\t\t// look straight down\n\t};\n\n\tvec3_t\t\tb;\n\tint\t\t\tj, k;\n\tfloat\tboxSize;\n\n\tboxSize = backEnd.viewParms.zFar / 1.75;\t\t// div sqrt(3)\n\tb[0] = s*boxSize;\n\tb[1] = t*boxSize;\n\tb[2] = boxSize;\n\n\tfor (j=0 ; j<3 ; j++)\n\t{\n\t\tk = st_to_vec[axis][j];\n\t\tif (k < 0)\n\t\t{\n\t\t\toutXYZ[j] = -b[-k - 1];\n\t\t}\n\t\telse\n\t\t{\n\t\t\toutXYZ[j] = b[k - 1];\n\t\t}\n\t}\n\n\t// avoid bilerp seam\n\ts = (s+1)*0.5;\n\tt = (t+1)*0.5;\n\tif (s < sky_min)\n\t{\n\t\ts = sky_min;\n\t}\n\telse if (s > sky_max)\n\t{\n\t\ts = sky_max;\n\t}\n\n\tif (t < sky_min)\n\t{\n\t\tt = sky_min;\n\t}\n\telse if (t > sky_max)\n\t{\n\t\tt = sky_max;\n\t}\n\n\tt = 1.0 - t;\n\n\n\tif ( outSt )\n\t{\n\t\toutSt[0] = s;\n\t\toutSt[1] = t;\n\t}\n}\n\nstatic int\tsky_texorder[6] = {0,2,1,3,4,5};\nstatic vec3_t\ts_skyPoints[SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1];\nstatic float\ts_skyTexCoords[SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1][2];\n\nstatic void DrawSkySide( struct image_s *image, const int mins[2], const int maxs[2] )\n{\n\tint s, t;\n\n\tGL_Bind( image );\n\n\tfor ( t = mins[1]+HALF_SKY_SUBDIVISIONS; t < maxs[1]+HALF_SKY_SUBDIVISIONS; t++ )\n\t{\n\t\tqglBegin( GL_TRIANGLE_STRIP );\n\n\t\tfor ( s = mins[0]+HALF_SKY_SUBDIVISIONS; s <= maxs[0]+HALF_SKY_SUBDIVISIONS; s++ )\n\t\t{\n\t\t\tqglTexCoord2fv( s_skyTexCoords[t][s] );\n\t\t\tqglVertex3fv( s_skyPoints[t][s] );\n\n\t\t\tqglTexCoord2fv( s_skyTexCoords[t+1][s] );\n\t\t\tqglVertex3fv( s_skyPoints[t+1][s] );\n\t\t}\n\n\t\tqglEnd();\n\t}\n}\n\nstatic void DrawSkyBox( shader_t *shader )\n{\n\tint\t\ti;\n\n\tsky_min = 0;\n\tsky_max = 1;\n\n\tCom_Memset( s_skyTexCoords, 0, sizeof( s_skyTexCoords ) );\n\n\tfor (i=0 ; i<6 ; i++)\n\t{\n\t\tint sky_mins_subd[2], sky_maxs_subd[2];\n\t\tint s, t;\n\n\t\tsky_mins[0][i] = floor( sky_mins[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;\n\t\tsky_mins[1][i] = floor( sky_mins[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;\n\t\tsky_maxs[0][i] = ceil( sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;\n\t\tsky_maxs[1][i] = ceil( sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;\n\n\t\tif ( ( sky_mins[0][i] >= sky_maxs[0][i] ) ||\n\t\t\t ( sky_mins[1][i] >= sky_maxs[1][i] ) )\n\t\t{\n\t\t\tcontinue;\n\t\t}\n\n\t\tsky_mins_subd[0] = sky_mins[0][i] * HALF_SKY_SUBDIVISIONS;\n\t\tsky_mins_subd[1] = sky_mins[1][i] * HALF_SKY_SUBDIVISIONS;\n\t\tsky_maxs_subd[0] = sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS;\n\t\tsky_maxs_subd[1] = sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS;\n\n\t\tif ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS ) \n\t\t\tsky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS;\n\t\telse if ( sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS ) \n\t\t\tsky_mins_subd[0] = HALF_SKY_SUBDIVISIONS;\n\t\tif ( sky_mins_subd[1] < -HALF_SKY_SUBDIVISIONS )\n\t\t\tsky_mins_subd[1] = -HALF_SKY_SUBDIVISIONS;\n\t\telse if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS ) \n\t\t\tsky_mins_subd[1] = HALF_SKY_SUBDIVISIONS;\n\n\t\tif ( sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS ) \n\t\t\tsky_maxs_subd[0] = -HALF_SKY_SUBDIVISIONS;\n\t\telse if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS ) \n\t\t\tsky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS;\n\t\tif ( sky_maxs_subd[1] < -HALF_SKY_SUBDIVISIONS ) \n\t\t\tsky_maxs_subd[1] = -HALF_SKY_SUBDIVISIONS;\n\t\telse if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS ) \n\t\t\tsky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS;\n\n\t\t//\n\t\t// iterate through the subdivisions\n\t\t//\n\t\tfor ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ )\n\t\t{\n\t\t\tfor ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ )\n\t\t\t{\n\t\t\t\tMakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, \n\t\t\t\t\t\t\t( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, \n\t\t\t\t\t\t\ti, \n\t\t\t\t\t\t\ts_skyTexCoords[t][s], \n\t\t\t\t\t\t\ts_skyPoints[t][s] );\n\t\t\t}\n\t\t}\n\n\t\tDrawSkySide( shader->sky.outerbox[sky_texorder[i]],\n\t\t\t         sky_mins_subd,\n\t\t\t\t\t sky_maxs_subd );\n\t}\n\n}\n\nstatic void FillCloudySkySide( const int mins[2], const int maxs[2], qboolean addIndexes )\n{\n\tint s, t;\n\tint vertexStart = tess.numVertexes;\n\tint tHeight, sWidth;\n\n\ttHeight = maxs[1] - mins[1] + 1;\n\tsWidth = maxs[0] - mins[0] + 1;\n\n\tfor ( t = mins[1]+HALF_SKY_SUBDIVISIONS; t <= maxs[1]+HALF_SKY_SUBDIVISIONS; t++ )\n\t{\n\t\tfor ( s = mins[0]+HALF_SKY_SUBDIVISIONS; s <= maxs[0]+HALF_SKY_SUBDIVISIONS; s++ )\n\t\t{\n\t\t\tVectorAdd( s_skyPoints[t][s], backEnd.viewParms.or.origin, tess.xyz[tess.numVertexes] );\n\t\t\ttess.texCoords[tess.numVertexes][0][0] = s_skyTexCoords[t][s][0];\n\t\t\ttess.texCoords[tess.numVertexes][0][1] = s_skyTexCoords[t][s][1];\n\n\t\t\ttess.numVertexes++;\n\n\t\t\tif ( tess.numVertexes >= SHADER_MAX_VERTEXES )\n\t\t\t{\n\t\t\t\tri.Error( ERR_DROP, \"SHADER_MAX_VERTEXES hit in FillCloudySkySide()\\n\" );\n\t\t\t}\n\t\t}\n\t}\n\n\t// only add indexes for one pass, otherwise it would draw multiple times for each pass\n\tif ( addIndexes ) {\n\t\tfor ( t = 0; t < tHeight-1; t++ )\n\t\t{\t\n\t\t\tfor ( s = 0; s < sWidth-1; s++ )\n\t\t\t{\n\t\t\t\ttess.indexes[tess.numIndexes] = vertexStart + s + t * ( sWidth );\n\t\t\t\ttess.numIndexes++;\n\t\t\t\ttess.indexes[tess.numIndexes] = vertexStart + s + ( t + 1 ) * ( sWidth );\n\t\t\t\ttess.numIndexes++;\n\t\t\t\ttess.indexes[tess.numIndexes] = vertexStart + s + 1 + t * ( sWidth );\n\t\t\t\ttess.numIndexes++;\n\n\t\t\t\ttess.indexes[tess.numIndexes] = vertexStart + s + ( t + 1 ) * ( sWidth );\n\t\t\t\ttess.numIndexes++;\n\t\t\t\ttess.indexes[tess.numIndexes] = vertexStart + s + 1 + ( t + 1 ) * ( sWidth );\n\t\t\t\ttess.numIndexes++;\n\t\t\t\ttess.indexes[tess.numIndexes] = vertexStart + s + 1 + t * ( sWidth );\n\t\t\t\ttess.numIndexes++;\n\t\t\t}\n\t\t}\n\t}\n}\n\nstatic void FillCloudBox( const shader_t *shader, int stage )\n{\n\tint i;\n\n\tfor ( i =0; i < 6; i++ )\n\t{\n\t\tint sky_mins_subd[2], sky_maxs_subd[2];\n\t\tint s, t;\n\t\tfloat MIN_T;\n\n\t\tif ( 1 ) // FIXME? shader->sky.fullClouds )\n\t\t{\n\t\t\tMIN_T = -HALF_SKY_SUBDIVISIONS;\n\n\t\t\t// still don't want to draw the bottom, even if fullClouds\n\t\t\tif ( i == 5 )\n\t\t\t\tcontinue;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tswitch( i )\n\t\t\t{\n\t\t\tcase 0:\n\t\t\tcase 1:\n\t\t\tcase 2:\n\t\t\tcase 3:\n\t\t\t\tMIN_T = -1;\n\t\t\t\tbreak;\n\t\t\tcase 5:\n\t\t\t\t// don't draw clouds beneath you\n\t\t\t\tcontinue;\n\t\t\tcase 4:\t\t// top\n\t\t\tdefault:\n\t\t\t\tMIN_T = -HALF_SKY_SUBDIVISIONS;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tsky_mins[0][i] = floor( sky_mins[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;\n\t\tsky_mins[1][i] = floor( sky_mins[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;\n\t\tsky_maxs[0][i] = ceil( sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;\n\t\tsky_maxs[1][i] = ceil( sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;\n\n\t\tif ( ( sky_mins[0][i] >= sky_maxs[0][i] ) ||\n\t\t\t ( sky_mins[1][i] >= sky_maxs[1][i] ) )\n\t\t{\n\t\t\tcontinue;\n\t\t}\n\n\t\tsky_mins_subd[0] = myftol( sky_mins[0][i] * HALF_SKY_SUBDIVISIONS );\n\t\tsky_mins_subd[1] = myftol( sky_mins[1][i] * HALF_SKY_SUBDIVISIONS );\n\t\tsky_maxs_subd[0] = myftol( sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS );\n\t\tsky_maxs_subd[1] = myftol( sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS );\n\n\t\tif ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS ) \n\t\t\tsky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS;\n\t\telse if ( sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS ) \n\t\t\tsky_mins_subd[0] = HALF_SKY_SUBDIVISIONS;\n\t\tif ( sky_mins_subd[1] < MIN_T )\n\t\t\tsky_mins_subd[1] = MIN_T;\n\t\telse if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS ) \n\t\t\tsky_mins_subd[1] = HALF_SKY_SUBDIVISIONS;\n\n\t\tif ( sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS ) \n\t\t\tsky_maxs_subd[0] = -HALF_SKY_SUBDIVISIONS;\n\t\telse if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS ) \n\t\t\tsky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS;\n\t\tif ( sky_maxs_subd[1] < MIN_T )\n\t\t\tsky_maxs_subd[1] = MIN_T;\n\t\telse if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS ) \n\t\t\tsky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS;\n\n\t\t//\n\t\t// iterate through the subdivisions\n\t\t//\n\t\tfor ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ )\n\t\t{\n\t\t\tfor ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ )\n\t\t\t{\n\t\t\t\tMakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, \n\t\t\t\t\t\t\t( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, \n\t\t\t\t\t\t\ti, \n\t\t\t\t\t\t\tNULL,\n\t\t\t\t\t\t\ts_skyPoints[t][s] );\n\n\t\t\t\ts_skyTexCoords[t][s][0] = s_cloudTexCoords[i][t][s][0];\n\t\t\t\ts_skyTexCoords[t][s][1] = s_cloudTexCoords[i][t][s][1];\n\t\t\t}\n\t\t}\n\n\t\t// only add indexes for first stage\n\t\tFillCloudySkySide( sky_mins_subd, sky_maxs_subd, ( stage == 0 ) );\n\t}\n}\n\n/*\n** R_BuildCloudData\n*/\nvoid R_BuildCloudData( shaderCommands_t *input )\n{\n\tint\t\t\ti;\n\tshader_t\t*shader;\n\n\tshader = input->shader;\n\n\tassert( shader->isSky );\n\n\tsky_min = 1.0 / 256.0f;\t\t// FIXME: not correct?\n\tsky_max = 255.0 / 256.0f;\n\n\t// set up for drawing\n\ttess.numIndexes = 0;\n\ttess.numVertexes = 0;\n\n\tif ( input->shader->sky.cloudHeight )\n\t{\n\t\tfor ( i = 0; i < MAX_SHADER_STAGES; i++ )\n\t\t{\n\t\t\tif ( !tess.xstages[i] ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tFillCloudBox( input->shader, i );\n\t\t}\n\t}\n}\n\n/*\n** R_InitSkyTexCoords\n** Called when a sky shader is parsed\n*/\n#define SQR( a ) ((a)*(a))\nvoid R_InitSkyTexCoords( float heightCloud )\n{\n\tint i, s, t;\n\tfloat radiusWorld = 4096;\n\tfloat p;\n\tfloat sRad, tRad;\n\tvec3_t skyVec;\n\tvec3_t v;\n\n\t// init zfar so MakeSkyVec works even though\n\t// a world hasn't been bounded\n\tbackEnd.viewParms.zFar = 1024;\n\n\tfor ( i = 0; i < 6; i++ )\n\t{\n\t\tfor ( t = 0; t <= SKY_SUBDIVISIONS; t++ )\n\t\t{\n\t\t\tfor ( s = 0; s <= SKY_SUBDIVISIONS; s++ )\n\t\t\t{\n\t\t\t\t// compute vector from view origin to sky side integral point\n\t\t\t\tMakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, \n\t\t\t\t\t\t\t( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, \n\t\t\t\t\t\t\ti, \n\t\t\t\t\t\t\tNULL,\n\t\t\t\t\t\t\tskyVec );\n\n\t\t\t\t// compute parametric value 'p' that intersects with cloud layer\n\t\t\t\tp = ( 1.0f / ( 2 * DotProduct( skyVec, skyVec ) ) ) *\n\t\t\t\t\t( -2 * skyVec[2] * radiusWorld + \n\t\t\t\t\t   2 * sqrt( SQR( skyVec[2] ) * SQR( radiusWorld ) + \n\t\t\t\t\t             2 * SQR( skyVec[0] ) * radiusWorld * heightCloud +\n\t\t\t\t\t\t\t\t SQR( skyVec[0] ) * SQR( heightCloud ) + \n\t\t\t\t\t\t\t\t 2 * SQR( skyVec[1] ) * radiusWorld * heightCloud +\n\t\t\t\t\t\t\t\t SQR( skyVec[1] ) * SQR( heightCloud ) + \n\t\t\t\t\t\t\t\t 2 * SQR( skyVec[2] ) * radiusWorld * heightCloud +\n\t\t\t\t\t\t\t\t SQR( skyVec[2] ) * SQR( heightCloud ) ) );\n\n\t\t\t\ts_cloudTexP[i][t][s] = p;\n\n\t\t\t\t// compute intersection point based on p\n\t\t\t\tVectorScale( skyVec, p, v );\n\t\t\t\tv[2] += radiusWorld;\n\n\t\t\t\t// compute vector from world origin to intersection point 'v'\n\t\t\t\tVectorNormalize( v );\n\n\t\t\t\tsRad = Q_acos( v[0] );\n\t\t\t\ttRad = Q_acos( v[1] );\n\n\t\t\t\ts_cloudTexCoords[i][t][s][0] = sRad;\n\t\t\t\ts_cloudTexCoords[i][t][s][1] = tRad;\n\t\t\t}\n\t\t}\n\t}\n}\n\n//======================================================================================\n\n/*\n** RB_DrawSun\n*/\nvoid RB_DrawSun( void ) {\n\tfloat\t\tsize;\n\tfloat\t\tdist;\n\tvec3_t\t\torigin, vec1, vec2;\n\tvec3_t\t\ttemp;\n\n\tif ( !backEnd.skyRenderedThisView ) {\n\t\treturn;\n\t}\n\tif ( !r_drawSun->integer ) {\n\t\treturn;\n\t}\n\tqglLoadMatrixf( backEnd.viewParms.world.modelMatrix );\n\tqglTranslatef (backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1], backEnd.viewParms.or.origin[2]);\n\n\tdist = \tbackEnd.viewParms.zFar / 1.75;\t\t// div sqrt(3)\n\tsize = dist * 0.4;\n\n\tVectorScale( tr.sunDirection, dist, origin );\n\tPerpendicularVector( vec1, tr.sunDirection );\n\tCrossProduct( tr.sunDirection, vec1, vec2 );\n\n\tVectorScale( vec1, size, vec1 );\n\tVectorScale( vec2, size, vec2 );\n\n\t// farthest depth range\n\tqglDepthRange( 1.0, 1.0 );\n\n\t// FIXME: use quad stamp\n\tRB_BeginSurface( tr.sunShader, tess.fogNum );\n\t\tVectorCopy( origin, temp );\n\t\tVectorSubtract( temp, vec1, temp );\n\t\tVectorSubtract( temp, vec2, temp );\n\t\tVectorCopy( temp, tess.xyz[tess.numVertexes] );\n\t\ttess.texCoords[tess.numVertexes][0][0] = 0;\n\t\ttess.texCoords[tess.numVertexes][0][1] = 0;\n\t\ttess.vertexColors[tess.numVertexes][0] = 255;\n\t\ttess.vertexColors[tess.numVertexes][1] = 255;\n\t\ttess.vertexColors[tess.numVertexes][2] = 255;\n\t\ttess.numVertexes++;\n\n\t\tVectorCopy( origin, temp );\n\t\tVectorAdd( temp, vec1, temp );\n\t\tVectorSubtract( temp, vec2, temp );\n\t\tVectorCopy( temp, tess.xyz[tess.numVertexes] );\n\t\ttess.texCoords[tess.numVertexes][0][0] = 0;\n\t\ttess.texCoords[tess.numVertexes][0][1] = 1;\n\t\ttess.vertexColors[tess.numVertexes][0] = 255;\n\t\ttess.vertexColors[tess.numVertexes][1] = 255;\n\t\ttess.vertexColors[tess.numVertexes][2] = 255;\n\t\ttess.numVertexes++;\n\n\t\tVectorCopy( origin, temp );\n\t\tVectorAdd( temp, vec1, temp );\n\t\tVectorAdd( temp, vec2, temp );\n\t\tVectorCopy( temp, tess.xyz[tess.numVertexes] );\n\t\ttess.texCoords[tess.numVertexes][0][0] = 1;\n\t\ttess.texCoords[tess.numVertexes][0][1] = 1;\n\t\ttess.vertexColors[tess.numVertexes][0] = 255;\n\t\ttess.vertexColors[tess.numVertexes][1] = 255;\n\t\ttess.vertexColors[tess.numVertexes][2] = 255;\n\t\ttess.numVertexes++;\n\n\t\tVectorCopy( origin, temp );\n\t\tVectorSubtract( temp, vec1, temp );\n\t\tVectorAdd( temp, vec2, temp );\n\t\tVectorCopy( temp, tess.xyz[tess.numVertexes] );\n\t\ttess.texCoords[tess.numVertexes][0][0] = 1;\n\t\ttess.texCoords[tess.numVertexes][0][1] = 0;\n\t\ttess.vertexColors[tess.numVertexes][0] = 255;\n\t\ttess.vertexColors[tess.numVertexes][1] = 255;\n\t\ttess.vertexColors[tess.numVertexes][2] = 255;\n\t\ttess.numVertexes++;\n\n\t\ttess.indexes[tess.numIndexes++] = 0;\n\t\ttess.indexes[tess.numIndexes++] = 1;\n\t\ttess.indexes[tess.numIndexes++] = 2;\n\t\ttess.indexes[tess.numIndexes++] = 0;\n\t\ttess.indexes[tess.numIndexes++] = 2;\n\t\ttess.indexes[tess.numIndexes++] = 3;\n\n\tRB_EndSurface();\n\n\t// back to normal depth range\n\tqglDepthRange( 0.0, 1.0 );\n}\n\n\n\n\n/*\n================\nRB_StageIteratorSky\n\nAll of the visible sky triangles are in tess\n\nOther things could be stuck in here, like birds in the sky, etc\n================\n*/\nvoid RB_StageIteratorSky( void ) {\n\tif ( r_fastsky->integer ) {\n\t\treturn;\n\t}\n\n\t// go through all the polygons and project them onto\n\t// the sky box to see which blocks on each side need\n\t// to be drawn\n\tRB_ClipSkyPolygons( &tess );\n\n\t// r_showsky will let all the sky blocks be drawn in\n\t// front of everything to allow developers to see how\n\t// much sky is getting sucked in\n\tif ( r_showsky->integer ) {\n\t\tqglDepthRange( 0.0, 0.0 );\n\t} else {\n\t\tqglDepthRange( 1.0, 1.0 );\n\t}\n\n\t// draw the outer skybox\n\tif ( tess.shader->sky.outerbox[0] && tess.shader->sky.outerbox[0] != tr.defaultImage ) {\n\t\tqglColor3f( tr.identityLight, tr.identityLight, tr.identityLight );\n\t\t\n\t\tqglPushMatrix ();\n\t\tGL_State( 0 );\n\t\tqglTranslatef (backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1], backEnd.viewParms.or.origin[2]);\n\n\t\tDrawSkyBox( tess.shader );\n\n\t\tqglPopMatrix();\n\t}\n\n\t// generate the vertexes for all the clouds, which will be drawn\n\t// by the generic shader routine\n\tR_BuildCloudData( &tess );\n\n\tRB_StageIteratorGeneric();\n\n\t// draw the inner skybox\n\n\n\t// back to normal depth range\n\tqglDepthRange( 0.0, 1.0 );\n\n\t// note that sky was drawn so we will draw a sun later\n\tbackEnd.skyRenderedThisView = qtrue;\n}\n\n"
  },
  {
    "path": "code/renderer/tr_surface.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// tr_surf.c\n#include \"tr_local.h\"\n\n/*\n\n  THIS ENTIRE FILE IS BACK END\n\nbackEnd.currentEntity will be valid.\n\nTess_Begin has already been called for the surface's shader.\n\nThe modelview matrix will be set.\n\nIt is safe to actually issue drawing commands here if you don't want to\nuse the shader system.\n*/\n\n\n//============================================================================\n\n\n/*\n==============\nRB_CheckOverflow\n==============\n*/\nvoid RB_CheckOverflow( int verts, int indexes ) {\n\tif (tess.numVertexes + verts < SHADER_MAX_VERTEXES\n\t\t&& tess.numIndexes + indexes < SHADER_MAX_INDEXES) {\n\t\treturn;\n\t}\n\n\tRB_EndSurface();\n\n\tif ( verts >= SHADER_MAX_VERTEXES ) {\n\t\tri.Error(ERR_DROP, \"RB_CheckOverflow: verts > MAX (%d > %d)\", verts, SHADER_MAX_VERTEXES );\n\t}\n\tif ( indexes >= SHADER_MAX_INDEXES ) {\n\t\tri.Error(ERR_DROP, \"RB_CheckOverflow: indices > MAX (%d > %d)\", indexes, SHADER_MAX_INDEXES );\n\t}\n\n\tRB_BeginSurface(tess.shader, tess.fogNum );\n}\n\n\n/*\n==============\nRB_AddQuadStampExt\n==============\n*/\nvoid RB_AddQuadStampExt( vec3_t origin, vec3_t left, vec3_t up, byte *color, float s1, float t1, float s2, float t2 ) {\n\tvec3_t\t\tnormal;\n\tint\t\t\tndx;\n\n\tRB_CHECKOVERFLOW( 4, 6 );\n\n\tndx = tess.numVertexes;\n\n\t// triangle indexes for a simple quad\n\ttess.indexes[ tess.numIndexes ] = ndx;\n\ttess.indexes[ tess.numIndexes + 1 ] = ndx + 1;\n\ttess.indexes[ tess.numIndexes + 2 ] = ndx + 3;\n\n\ttess.indexes[ tess.numIndexes + 3 ] = ndx + 3;\n\ttess.indexes[ tess.numIndexes + 4 ] = ndx + 1;\n\ttess.indexes[ tess.numIndexes + 5 ] = ndx + 2;\n\n\ttess.xyz[ndx][0] = origin[0] + left[0] + up[0];\n\ttess.xyz[ndx][1] = origin[1] + left[1] + up[1];\n\ttess.xyz[ndx][2] = origin[2] + left[2] + up[2];\n\n\ttess.xyz[ndx+1][0] = origin[0] - left[0] + up[0];\n\ttess.xyz[ndx+1][1] = origin[1] - left[1] + up[1];\n\ttess.xyz[ndx+1][2] = origin[2] - left[2] + up[2];\n\n\ttess.xyz[ndx+2][0] = origin[0] - left[0] - up[0];\n\ttess.xyz[ndx+2][1] = origin[1] - left[1] - up[1];\n\ttess.xyz[ndx+2][2] = origin[2] - left[2] - up[2];\n\n\ttess.xyz[ndx+3][0] = origin[0] + left[0] - up[0];\n\ttess.xyz[ndx+3][1] = origin[1] + left[1] - up[1];\n\ttess.xyz[ndx+3][2] = origin[2] + left[2] - up[2];\n\n\n\t// constant normal all the way around\n\tVectorSubtract( vec3_origin, backEnd.viewParms.or.axis[0], normal );\n\n\ttess.normal[ndx][0] = tess.normal[ndx+1][0] = tess.normal[ndx+2][0] = tess.normal[ndx+3][0] = normal[0];\n\ttess.normal[ndx][1] = tess.normal[ndx+1][1] = tess.normal[ndx+2][1] = tess.normal[ndx+3][1] = normal[1];\n\ttess.normal[ndx][2] = tess.normal[ndx+1][2] = tess.normal[ndx+2][2] = tess.normal[ndx+3][2] = normal[2];\n\t\n\t// standard square texture coordinates\n\ttess.texCoords[ndx][0][0] = tess.texCoords[ndx][1][0] = s1;\n\ttess.texCoords[ndx][0][1] = tess.texCoords[ndx][1][1] = t1;\n\n\ttess.texCoords[ndx+1][0][0] = tess.texCoords[ndx+1][1][0] = s2;\n\ttess.texCoords[ndx+1][0][1] = tess.texCoords[ndx+1][1][1] = t1;\n\n\ttess.texCoords[ndx+2][0][0] = tess.texCoords[ndx+2][1][0] = s2;\n\ttess.texCoords[ndx+2][0][1] = tess.texCoords[ndx+2][1][1] = t2;\n\n\ttess.texCoords[ndx+3][0][0] = tess.texCoords[ndx+3][1][0] = s1;\n\ttess.texCoords[ndx+3][0][1] = tess.texCoords[ndx+3][1][1] = t2;\n\n\t// constant color all the way around\n\t// should this be identity and let the shader specify from entity?\n\t* ( unsigned int * ) &tess.vertexColors[ndx] = \n\t* ( unsigned int * ) &tess.vertexColors[ndx+1] = \n\t* ( unsigned int * ) &tess.vertexColors[ndx+2] = \n\t* ( unsigned int * ) &tess.vertexColors[ndx+3] = \n\t\t* ( unsigned int * )color;\n\n\n\ttess.numVertexes += 4;\n\ttess.numIndexes += 6;\n}\n\n/*\n==============\nRB_AddQuadStamp\n==============\n*/\nvoid RB_AddQuadStamp( vec3_t origin, vec3_t left, vec3_t up, byte *color ) {\n\tRB_AddQuadStampExt( origin, left, up, color, 0, 0, 1, 1 );\n}\n\n/*\n==============\nRB_SurfaceSprite\n==============\n*/\nstatic void RB_SurfaceSprite( void ) {\n\tvec3_t\t\tleft, up;\n\tfloat\t\tradius;\n\n\t// calculate the xyz locations for the four corners\n\tradius = backEnd.currentEntity->e.radius;\n\tif ( backEnd.currentEntity->e.rotation == 0 ) {\n\t\tVectorScale( backEnd.viewParms.or.axis[1], radius, left );\n\t\tVectorScale( backEnd.viewParms.or.axis[2], radius, up );\n\t} else {\n\t\tfloat\ts, c;\n\t\tfloat\tang;\n\t\t\n\t\tang = M_PI * backEnd.currentEntity->e.rotation / 180;\n\t\ts = sin( ang );\n\t\tc = cos( ang );\n\n\t\tVectorScale( backEnd.viewParms.or.axis[1], c * radius, left );\n\t\tVectorMA( left, -s * radius, backEnd.viewParms.or.axis[2], left );\n\n\t\tVectorScale( backEnd.viewParms.or.axis[2], c * radius, up );\n\t\tVectorMA( up, s * radius, backEnd.viewParms.or.axis[1], up );\n\t}\n\tif ( backEnd.viewParms.isMirror ) {\n\t\tVectorSubtract( vec3_origin, left, left );\n\t}\n\n\tRB_AddQuadStamp( backEnd.currentEntity->e.origin, left, up, backEnd.currentEntity->e.shaderRGBA );\n}\n\n\n/*\n=============\nRB_SurfacePolychain\n=============\n*/\nvoid RB_SurfacePolychain( srfPoly_t *p ) {\n\tint\t\ti;\n\tint\t\tnumv;\n\n\tRB_CHECKOVERFLOW( p->numVerts, 3*(p->numVerts - 2) );\n\n\t// fan triangles into the tess array\n\tnumv = tess.numVertexes;\n\tfor ( i = 0; i < p->numVerts; i++ ) {\n\t\tVectorCopy( p->verts[i].xyz, tess.xyz[numv] );\n\t\ttess.texCoords[numv][0][0] = p->verts[i].st[0];\n\t\ttess.texCoords[numv][0][1] = p->verts[i].st[1];\n\t\t*(int *)&tess.vertexColors[numv] = *(int *)p->verts[ i ].modulate;\n\n\t\tnumv++;\n\t}\n\n\t// generate fan indexes into the tess array\n\tfor ( i = 0; i < p->numVerts-2; i++ ) {\n\t\ttess.indexes[tess.numIndexes + 0] = tess.numVertexes;\n\t\ttess.indexes[tess.numIndexes + 1] = tess.numVertexes + i + 1;\n\t\ttess.indexes[tess.numIndexes + 2] = tess.numVertexes + i + 2;\n\t\ttess.numIndexes += 3;\n\t}\n\n\ttess.numVertexes = numv;\n}\n\n\n/*\n=============\nRB_SurfaceTriangles\n=============\n*/\nvoid RB_SurfaceTriangles( srfTriangles_t *srf ) {\n\tint\t\t\ti;\n\tdrawVert_t\t*dv;\n\tfloat\t\t*xyz, *normal, *texCoords;\n\tbyte\t\t*color;\n\tint\t\t\tdlightBits;\n\tqboolean\tneedsNormal;\n\n\tdlightBits = srf->dlightBits[backEnd.smpFrame];\n\ttess.dlightBits |= dlightBits;\n\n\tRB_CHECKOVERFLOW( srf->numVerts, srf->numIndexes );\n\n\tfor ( i = 0 ; i < srf->numIndexes ; i += 3 ) {\n\t\ttess.indexes[ tess.numIndexes + i + 0 ] = tess.numVertexes + srf->indexes[ i + 0 ];\n\t\ttess.indexes[ tess.numIndexes + i + 1 ] = tess.numVertexes + srf->indexes[ i + 1 ];\n\t\ttess.indexes[ tess.numIndexes + i + 2 ] = tess.numVertexes + srf->indexes[ i + 2 ];\n\t}\n\ttess.numIndexes += srf->numIndexes;\n\n\tdv = srf->verts;\n\txyz = tess.xyz[ tess.numVertexes ];\n\tnormal = tess.normal[ tess.numVertexes ];\n\ttexCoords = tess.texCoords[ tess.numVertexes ][0];\n\tcolor = tess.vertexColors[ tess.numVertexes ];\n\tneedsNormal = tess.shader->needsNormal;\n\n\tfor ( i = 0 ; i < srf->numVerts ; i++, dv++, xyz += 4, normal += 4, texCoords += 4, color += 4 ) {\n\t\txyz[0] = dv->xyz[0];\n\t\txyz[1] = dv->xyz[1];\n\t\txyz[2] = dv->xyz[2];\n\n\t\tif ( needsNormal ) {\n\t\t\tnormal[0] = dv->normal[0];\n\t\t\tnormal[1] = dv->normal[1];\n\t\t\tnormal[2] = dv->normal[2];\n\t\t}\n\n\t\ttexCoords[0] = dv->st[0];\n\t\ttexCoords[1] = dv->st[1];\n\n\t\ttexCoords[2] = dv->lightmap[0];\n\t\ttexCoords[3] = dv->lightmap[1];\n\n\t\t*(int *)color = *(int *)dv->color;\n\t}\n\n\tfor ( i = 0 ; i < srf->numVerts ; i++ ) {\n\t\ttess.vertexDlightBits[ tess.numVertexes + i] = dlightBits;\n\t}\n\n\ttess.numVertexes += srf->numVerts;\n}\n\n\n\n/*\n==============\nRB_SurfaceBeam\n==============\n*/\nvoid RB_SurfaceBeam( void ) \n{\n#define NUM_BEAM_SEGS 6\n\trefEntity_t *e;\n\tint\ti;\n\tvec3_t perpvec;\n\tvec3_t direction, normalized_direction;\n\tvec3_t\tstart_points[NUM_BEAM_SEGS], end_points[NUM_BEAM_SEGS];\n\tvec3_t oldorigin, origin;\n\n\te = &backEnd.currentEntity->e;\n\n\toldorigin[0] = e->oldorigin[0];\n\toldorigin[1] = e->oldorigin[1];\n\toldorigin[2] = e->oldorigin[2];\n\n\torigin[0] = e->origin[0];\n\torigin[1] = e->origin[1];\n\torigin[2] = e->origin[2];\n\n\tnormalized_direction[0] = direction[0] = oldorigin[0] - origin[0];\n\tnormalized_direction[1] = direction[1] = oldorigin[1] - origin[1];\n\tnormalized_direction[2] = direction[2] = oldorigin[2] - origin[2];\n\n\tif ( VectorNormalize( normalized_direction ) == 0 )\n\t\treturn;\n\n\tPerpendicularVector( perpvec, normalized_direction );\n\n\tVectorScale( perpvec, 4, perpvec );\n\n\tfor ( i = 0; i < NUM_BEAM_SEGS ; i++ )\n\t{\n\t\tRotatePointAroundVector( start_points[i], normalized_direction, perpvec, (360.0/NUM_BEAM_SEGS)*i );\n//\t\tVectorAdd( start_points[i], origin, start_points[i] );\n\t\tVectorAdd( start_points[i], direction, end_points[i] );\n\t}\n\n\tGL_Bind( tr.whiteImage );\n\n\tGL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE );\n\n\tqglColor3f( 1, 0, 0 );\n\n\tqglBegin( GL_TRIANGLE_STRIP );\n\tfor ( i = 0; i <= NUM_BEAM_SEGS; i++ ) {\n\t\tqglVertex3fv( start_points[ i % NUM_BEAM_SEGS] );\n\t\tqglVertex3fv( end_points[ i % NUM_BEAM_SEGS] );\n\t}\n\tqglEnd();\n}\n\n//================================================================================\n\nstatic void DoRailCore( const vec3_t start, const vec3_t end, const vec3_t up, float len, float spanWidth )\n{\n\tfloat\t\tspanWidth2;\n\tint\t\t\tvbase;\n\tfloat\t\tt = len / 256.0f;\n\n\tvbase = tess.numVertexes;\n\n\tspanWidth2 = -spanWidth;\n\n\t// FIXME: use quad stamp?\n\tVectorMA( start, spanWidth, up, tess.xyz[tess.numVertexes] );\n\ttess.texCoords[tess.numVertexes][0][0] = 0;\n\ttess.texCoords[tess.numVertexes][0][1] = 0;\n\ttess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] * 0.25;\n\ttess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] * 0.25;\n\ttess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] * 0.25;\n\ttess.numVertexes++;\n\n\tVectorMA( start, spanWidth2, up, tess.xyz[tess.numVertexes] );\n\ttess.texCoords[tess.numVertexes][0][0] = 0;\n\ttess.texCoords[tess.numVertexes][0][1] = 1;\n\ttess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];\n\ttess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];\n\ttess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];\n\ttess.numVertexes++;\n\n\tVectorMA( end, spanWidth, up, tess.xyz[tess.numVertexes] );\n\n\ttess.texCoords[tess.numVertexes][0][0] = t;\n\ttess.texCoords[tess.numVertexes][0][1] = 0;\n\ttess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];\n\ttess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];\n\ttess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];\n\ttess.numVertexes++;\n\n\tVectorMA( end, spanWidth2, up, tess.xyz[tess.numVertexes] );\n\ttess.texCoords[tess.numVertexes][0][0] = t;\n\ttess.texCoords[tess.numVertexes][0][1] = 1;\n\ttess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];\n\ttess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];\n\ttess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];\n\ttess.numVertexes++;\n\n\ttess.indexes[tess.numIndexes++] = vbase;\n\ttess.indexes[tess.numIndexes++] = vbase + 1;\n\ttess.indexes[tess.numIndexes++] = vbase + 2;\n\n\ttess.indexes[tess.numIndexes++] = vbase + 2;\n\ttess.indexes[tess.numIndexes++] = vbase + 1;\n\ttess.indexes[tess.numIndexes++] = vbase + 3;\n}\n\nstatic void DoRailDiscs( int numSegs, const vec3_t start, const vec3_t dir, const vec3_t right, const vec3_t up )\n{\n\tint i;\n\tvec3_t\tpos[4];\n\tvec3_t\tv;\n\tint\t\tspanWidth = r_railWidth->integer;\n\tfloat c, s;\n\tfloat\t\tscale;\n\n\tif ( numSegs > 1 )\n\t\tnumSegs--;\n\tif ( !numSegs )\n\t\treturn;\n\n\tscale = 0.25;\n\n\tfor ( i = 0; i < 4; i++ )\n\t{\n\t\tc = cos( DEG2RAD( 45 + i * 90 ) );\n\t\ts = sin( DEG2RAD( 45 + i * 90 ) );\n\t\tv[0] = ( right[0] * c + up[0] * s ) * scale * spanWidth;\n\t\tv[1] = ( right[1] * c + up[1] * s ) * scale * spanWidth;\n\t\tv[2] = ( right[2] * c + up[2] * s ) * scale * spanWidth;\n\t\tVectorAdd( start, v, pos[i] );\n\n\t\tif ( numSegs > 1 )\n\t\t{\n\t\t\t// offset by 1 segment if we're doing a long distance shot\n\t\t\tVectorAdd( pos[i], dir, pos[i] );\n\t\t}\n\t}\n\n\tfor ( i = 0; i < numSegs; i++ )\n\t{\n\t\tint j;\n\n\t\tRB_CHECKOVERFLOW( 4, 6 );\n\n\t\tfor ( j = 0; j < 4; j++ )\n\t\t{\n\t\t\tVectorCopy( pos[j], tess.xyz[tess.numVertexes] );\n\t\t\ttess.texCoords[tess.numVertexes][0][0] = ( j < 2 );\n\t\t\ttess.texCoords[tess.numVertexes][0][1] = ( j && j != 3 );\n\t\t\ttess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];\n\t\t\ttess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];\n\t\t\ttess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];\n\t\t\ttess.numVertexes++;\n\n\t\t\tVectorAdd( pos[j], dir, pos[j] );\n\t\t}\n\n\t\ttess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 0;\n\t\ttess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 1;\n\t\ttess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 3;\n\t\ttess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 3;\n\t\ttess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 1;\n\t\ttess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 2;\n\t}\n}\n\n/*\n** RB_SurfaceRailRinges\n*/\nvoid RB_SurfaceRailRings( void ) {\n\trefEntity_t *e;\n\tint\t\t\tnumSegs;\n\tint\t\t\tlen;\n\tvec3_t\t\tvec;\n\tvec3_t\t\tright, up;\n\tvec3_t\t\tstart, end;\n\n\te = &backEnd.currentEntity->e;\n\n\tVectorCopy( e->oldorigin, start );\n\tVectorCopy( e->origin, end );\n\n\t// compute variables\n\tVectorSubtract( end, start, vec );\n\tlen = VectorNormalize( vec );\n\tMakeNormalVectors( vec, right, up );\n\tnumSegs = ( len ) / r_railSegmentLength->value;\n\tif ( numSegs <= 0 ) {\n\t\tnumSegs = 1;\n\t}\n\n\tVectorScale( vec, r_railSegmentLength->value, vec );\n\n\tDoRailDiscs( numSegs, start, vec, right, up );\n}\n\n/*\n** RB_SurfaceRailCore\n*/\nvoid RB_SurfaceRailCore( void ) {\n\trefEntity_t *e;\n\tint\t\t\tlen;\n\tvec3_t\t\tright;\n\tvec3_t\t\tvec;\n\tvec3_t\t\tstart, end;\n\tvec3_t\t\tv1, v2;\n\n\te = &backEnd.currentEntity->e;\n\n\tVectorCopy( e->oldorigin, start );\n\tVectorCopy( e->origin, end );\n\n\tVectorSubtract( end, start, vec );\n\tlen = VectorNormalize( vec );\n\n\t// compute side vector\n\tVectorSubtract( start, backEnd.viewParms.or.origin, v1 );\n\tVectorNormalize( v1 );\n\tVectorSubtract( end, backEnd.viewParms.or.origin, v2 );\n\tVectorNormalize( v2 );\n\tCrossProduct( v1, v2, right );\n\tVectorNormalize( right );\n\n\tDoRailCore( start, end, right, len, r_railCoreWidth->integer );\n}\n\n/*\n** RB_SurfaceLightningBolt\n*/\nvoid RB_SurfaceLightningBolt( void ) {\n\trefEntity_t *e;\n\tint\t\t\tlen;\n\tvec3_t\t\tright;\n\tvec3_t\t\tvec;\n\tvec3_t\t\tstart, end;\n\tvec3_t\t\tv1, v2;\n\tint\t\t\ti;\n\n\te = &backEnd.currentEntity->e;\n\n\tVectorCopy( e->oldorigin, end );\n\tVectorCopy( e->origin, start );\n\n\t// compute variables\n\tVectorSubtract( end, start, vec );\n\tlen = VectorNormalize( vec );\n\n\t// compute side vector\n\tVectorSubtract( start, backEnd.viewParms.or.origin, v1 );\n\tVectorNormalize( v1 );\n\tVectorSubtract( end, backEnd.viewParms.or.origin, v2 );\n\tVectorNormalize( v2 );\n\tCrossProduct( v1, v2, right );\n\tVectorNormalize( right );\n\n\tfor ( i = 0 ; i < 4 ; i++ ) {\n\t\tvec3_t\ttemp;\n\n\t\tDoRailCore( start, end, right, len, 8 );\n\t\tRotatePointAroundVector( temp, vec, right, 45 );\n\t\tVectorCopy( temp, right );\n\t}\n}\n\n/*\n** VectorArrayNormalize\n*\n* The inputs to this routing seem to always be close to length = 1.0 (about 0.6 to 2.0)\n* This means that we don't have to worry about zero length or enormously long vectors.\n*/\nstatic void VectorArrayNormalize(vec4_t *normals, unsigned int count)\n{\n//    assert(count);\n        \n#if idppc\n    {\n        register float half = 0.5;\n        register float one  = 1.0;\n        float *components = (float *)normals;\n        \n        // Vanilla PPC code, but since PPC has a reciprocal square root estimate instruction,\n        // runs *much* faster than calling sqrt().  We'll use a single Newton-Raphson\n        // refinement step to get a little more precision.  This seems to yeild results\n        // that are correct to 3 decimal places and usually correct to at least 4 (sometimes 5).\n        // (That is, for the given input range of about 0.6 to 2.0).\n        do {\n            float x, y, z;\n            float B, y0, y1;\n            \n            x = components[0];\n            y = components[1];\n            z = components[2];\n            components += 4;\n            B = x*x + y*y + z*z;\n\n#ifdef __GNUC__            \n            asm(\"frsqrte %0,%1\" : \"=f\" (y0) : \"f\" (B));\n#else\n\t\t\ty0 = __frsqrte(B);\n#endif\n            y1 = y0 + half*y0*(one - B*y0*y0);\n\n            x = x * y1;\n            y = y * y1;\n            components[-4] = x;\n            z = z * y1;\n            components[-3] = y;\n            components[-2] = z;\n        } while(count--);\n    }\n#else // No assembly version for this architecture, or C_ONLY defined\n\t// given the input, it's safe to call VectorNormalizeFast\n    while (count--) {\n        VectorNormalizeFast(normals[0]);\n        normals++;\n    }\n#endif\n\n}\n\n\n\n/*\n** LerpMeshVertexes\n*/\nstatic void LerpMeshVertexes (md3Surface_t *surf, float backlerp) \n{\n\tshort\t*oldXyz, *newXyz, *oldNormals, *newNormals;\n\tfloat\t*outXyz, *outNormal;\n\tfloat\toldXyzScale, newXyzScale;\n\tfloat\toldNormalScale, newNormalScale;\n\tint\t\tvertNum;\n\tunsigned lat, lng;\n\tint\t\tnumVerts;\n\n\toutXyz = tess.xyz[tess.numVertexes];\n\toutNormal = tess.normal[tess.numVertexes];\n\n\tnewXyz = (short *)((byte *)surf + surf->ofsXyzNormals)\n\t\t+ (backEnd.currentEntity->e.frame * surf->numVerts * 4);\n\tnewNormals = newXyz + 3;\n\n\tnewXyzScale = MD3_XYZ_SCALE * (1.0 - backlerp);\n\tnewNormalScale = 1.0 - backlerp;\n\n\tnumVerts = surf->numVerts;\n\n\tif ( backlerp == 0 ) {\n#if idppc_altivec\n\t\tvector signed short newNormalsVec0;\n\t\tvector signed short newNormalsVec1;\n\t\tvector signed int newNormalsIntVec;\n\t\tvector float newNormalsFloatVec;\n\t\tvector float newXyzScaleVec;\n\t\tvector unsigned char newNormalsLoadPermute;\n\t\tvector unsigned char newNormalsStorePermute;\n\t\tvector float zero;\n\t\t\n\t\tnewNormalsStorePermute = vec_lvsl(0,(float *)&newXyzScaleVec);\n\t\tnewXyzScaleVec = *(vector float *)&newXyzScale;\n\t\tnewXyzScaleVec = vec_perm(newXyzScaleVec,newXyzScaleVec,newNormalsStorePermute);\n\t\tnewXyzScaleVec = vec_splat(newXyzScaleVec,0);\t\t\n\t\tnewNormalsLoadPermute = vec_lvsl(0,newXyz);\n\t\tnewNormalsStorePermute = vec_lvsr(0,outXyz);\n\t\tzero = (vector float)vec_splat_s8(0);\n\t\t//\n\t\t// just copy the vertexes\n\t\t//\n\t\tfor (vertNum=0 ; vertNum < numVerts ; vertNum++,\n\t\t\tnewXyz += 4, newNormals += 4,\n\t\t\toutXyz += 4, outNormal += 4) \n\t\t{\n\t\t\tnewNormalsLoadPermute = vec_lvsl(0,newXyz);\n\t\t\tnewNormalsStorePermute = vec_lvsr(0,outXyz);\n\t\t\tnewNormalsVec0 = vec_ld(0,newXyz);\n\t\t\tnewNormalsVec1 = vec_ld(16,newXyz);\n\t\t\tnewNormalsVec0 = vec_perm(newNormalsVec0,newNormalsVec1,newNormalsLoadPermute);\n\t\t\tnewNormalsIntVec = vec_unpackh(newNormalsVec0);\n\t\t\tnewNormalsFloatVec = vec_ctf(newNormalsIntVec,0);\n\t\t\tnewNormalsFloatVec = vec_madd(newNormalsFloatVec,newXyzScaleVec,zero);\n\t\t\tnewNormalsFloatVec = vec_perm(newNormalsFloatVec,newNormalsFloatVec,newNormalsStorePermute);\n\t\t\t//outXyz[0] = newXyz[0] * newXyzScale;\n\t\t\t//outXyz[1] = newXyz[1] * newXyzScale;\n\t\t\t//outXyz[2] = newXyz[2] * newXyzScale;\n\n\t\t\tlat = ( newNormals[0] >> 8 ) & 0xff;\n\t\t\tlng = ( newNormals[0] & 0xff );\n\t\t\tlat *= (FUNCTABLE_SIZE/256);\n\t\t\tlng *= (FUNCTABLE_SIZE/256);\n\n\t\t\t// decode X as cos( lat ) * sin( long )\n\t\t\t// decode Y as sin( lat ) * sin( long )\n\t\t\t// decode Z as cos( long )\n\n\t\t\toutNormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng];\n\t\t\toutNormal[1] = tr.sinTable[lat] * tr.sinTable[lng];\n\t\t\toutNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK];\n\n\t\t\tvec_ste(newNormalsFloatVec,0,outXyz);\n\t\t\tvec_ste(newNormalsFloatVec,4,outXyz);\n\t\t\tvec_ste(newNormalsFloatVec,8,outXyz);\n\t\t}\n\t\t\n#else\n\t\t//\n\t\t// just copy the vertexes\n\t\t//\n\t\tfor (vertNum=0 ; vertNum < numVerts ; vertNum++,\n\t\t\tnewXyz += 4, newNormals += 4,\n\t\t\toutXyz += 4, outNormal += 4) \n\t\t{\n\n\t\t\toutXyz[0] = newXyz[0] * newXyzScale;\n\t\t\toutXyz[1] = newXyz[1] * newXyzScale;\n\t\t\toutXyz[2] = newXyz[2] * newXyzScale;\n\n\t\t\tlat = ( newNormals[0] >> 8 ) & 0xff;\n\t\t\tlng = ( newNormals[0] & 0xff );\n\t\t\tlat *= (FUNCTABLE_SIZE/256);\n\t\t\tlng *= (FUNCTABLE_SIZE/256);\n\n\t\t\t// decode X as cos( lat ) * sin( long )\n\t\t\t// decode Y as sin( lat ) * sin( long )\n\t\t\t// decode Z as cos( long )\n\n\t\t\toutNormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng];\n\t\t\toutNormal[1] = tr.sinTable[lat] * tr.sinTable[lng];\n\t\t\toutNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK];\n\t\t}\n#endif\n\t} else {\n\t\t//\n\t\t// interpolate and copy the vertex and normal\n\t\t//\n\t\toldXyz = (short *)((byte *)surf + surf->ofsXyzNormals)\n\t\t\t+ (backEnd.currentEntity->e.oldframe * surf->numVerts * 4);\n\t\toldNormals = oldXyz + 3;\n\n\t\toldXyzScale = MD3_XYZ_SCALE * backlerp;\n\t\toldNormalScale = backlerp;\n\n\t\tfor (vertNum=0 ; vertNum < numVerts ; vertNum++,\n\t\t\toldXyz += 4, newXyz += 4, oldNormals += 4, newNormals += 4,\n\t\t\toutXyz += 4, outNormal += 4) \n\t\t{\n\t\t\tvec3_t uncompressedOldNormal, uncompressedNewNormal;\n\n\t\t\t// interpolate the xyz\n\t\t\toutXyz[0] = oldXyz[0] * oldXyzScale + newXyz[0] * newXyzScale;\n\t\t\toutXyz[1] = oldXyz[1] * oldXyzScale + newXyz[1] * newXyzScale;\n\t\t\toutXyz[2] = oldXyz[2] * oldXyzScale + newXyz[2] * newXyzScale;\n\n\t\t\t// FIXME: interpolate lat/long instead?\n\t\t\tlat = ( newNormals[0] >> 8 ) & 0xff;\n\t\t\tlng = ( newNormals[0] & 0xff );\n\t\t\tlat *= 4;\n\t\t\tlng *= 4;\n\t\t\tuncompressedNewNormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng];\n\t\t\tuncompressedNewNormal[1] = tr.sinTable[lat] * tr.sinTable[lng];\n\t\t\tuncompressedNewNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK];\n\n\t\t\tlat = ( oldNormals[0] >> 8 ) & 0xff;\n\t\t\tlng = ( oldNormals[0] & 0xff );\n\t\t\tlat *= 4;\n\t\t\tlng *= 4;\n\n\t\t\tuncompressedOldNormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng];\n\t\t\tuncompressedOldNormal[1] = tr.sinTable[lat] * tr.sinTable[lng];\n\t\t\tuncompressedOldNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK];\n\n\t\t\toutNormal[0] = uncompressedOldNormal[0] * oldNormalScale + uncompressedNewNormal[0] * newNormalScale;\n\t\t\toutNormal[1] = uncompressedOldNormal[1] * oldNormalScale + uncompressedNewNormal[1] * newNormalScale;\n\t\t\toutNormal[2] = uncompressedOldNormal[2] * oldNormalScale + uncompressedNewNormal[2] * newNormalScale;\n\n//\t\t\tVectorNormalize (outNormal);\n\t\t}\n    \tVectorArrayNormalize((vec4_t *)tess.normal[tess.numVertexes], numVerts);\n   \t}\n}\n\n/*\n=============\nRB_SurfaceMesh\n=============\n*/\nvoid RB_SurfaceMesh(md3Surface_t *surface) {\n\tint\t\t\t\tj;\n\tfloat\t\t\tbacklerp;\n\tint\t\t\t\t*triangles;\n\tfloat\t\t\t*texCoords;\n\tint\t\t\t\tindexes;\n\tint\t\t\t\tBob, Doug;\n\tint\t\t\t\tnumVerts;\n\n\tif (  backEnd.currentEntity->e.oldframe == backEnd.currentEntity->e.frame ) {\n\t\tbacklerp = 0;\n\t} else  {\n\t\tbacklerp = backEnd.currentEntity->e.backlerp;\n\t}\n\n\tRB_CHECKOVERFLOW( surface->numVerts, surface->numTriangles*3 );\n\n\tLerpMeshVertexes (surface, backlerp);\n\n\ttriangles = (int *) ((byte *)surface + surface->ofsTriangles);\n\tindexes = surface->numTriangles * 3;\n\tBob = tess.numIndexes;\n\tDoug = tess.numVertexes;\n\tfor (j = 0 ; j < indexes ; j++) {\n\t\ttess.indexes[Bob + j] = Doug + triangles[j];\n\t}\n\ttess.numIndexes += indexes;\n\n\ttexCoords = (float *) ((byte *)surface + surface->ofsSt);\n\n\tnumVerts = surface->numVerts;\n\tfor ( j = 0; j < numVerts; j++ ) {\n\t\ttess.texCoords[Doug + j][0][0] = texCoords[j*2+0];\n\t\ttess.texCoords[Doug + j][0][1] = texCoords[j*2+1];\n\t\t// FIXME: fill in lightmapST for completeness?\n\t}\n\n\ttess.numVertexes += surface->numVerts;\n\n}\n\n\n/*\n==============\nRB_SurfaceFace\n==============\n*/\nvoid RB_SurfaceFace( srfSurfaceFace_t *surf ) {\n\tint\t\t\ti;\n\tunsigned\t*indices, *tessIndexes;\n\tfloat\t\t*v;\n\tfloat\t\t*normal;\n\tint\t\t\tndx;\n\tint\t\t\tBob;\n\tint\t\t\tnumPoints;\n\tint\t\t\tdlightBits;\n\n\tRB_CHECKOVERFLOW( surf->numPoints, surf->numIndices );\n\n\tdlightBits = surf->dlightBits[backEnd.smpFrame];\n\ttess.dlightBits |= dlightBits;\n\n\tindices = ( unsigned * ) ( ( ( char  * ) surf ) + surf->ofsIndices );\n\n\tBob = tess.numVertexes;\n\ttessIndexes = tess.indexes + tess.numIndexes;\n\tfor ( i = surf->numIndices-1 ; i >= 0  ; i-- ) {\n\t\ttessIndexes[i] = indices[i] + Bob;\n\t}\n\n\ttess.numIndexes += surf->numIndices;\n\n\tv = surf->points[0];\n\n\tndx = tess.numVertexes;\n\n\tnumPoints = surf->numPoints;\n\n\tif ( tess.shader->needsNormal ) {\n\t\tnormal = surf->plane.normal;\n\t\tfor ( i = 0, ndx = tess.numVertexes; i < numPoints; i++, ndx++ ) {\n\t\t\tVectorCopy( normal, tess.normal[ndx] );\n\t\t}\n\t}\n\n\tfor ( i = 0, v = surf->points[0], ndx = tess.numVertexes; i < numPoints; i++, v += VERTEXSIZE, ndx++ ) {\n\t\tVectorCopy( v, tess.xyz[ndx]);\n\t\ttess.texCoords[ndx][0][0] = v[3];\n\t\ttess.texCoords[ndx][0][1] = v[4];\n\t\ttess.texCoords[ndx][1][0] = v[5];\n\t\ttess.texCoords[ndx][1][1] = v[6];\n\t\t* ( unsigned int * ) &tess.vertexColors[ndx] = * ( unsigned int * ) &v[7];\n\t\ttess.vertexDlightBits[ndx] = dlightBits;\n\t}\n\n\n\ttess.numVertexes += surf->numPoints;\n}\n\n\nstatic float\tLodErrorForVolume( vec3_t local, float radius ) {\n\tvec3_t\t\tworld;\n\tfloat\t\td;\n\n\t// never let it go negative\n\tif ( r_lodCurveError->value < 0 ) {\n\t\treturn 0;\n\t}\n\n\tworld[0] = local[0] * backEnd.or.axis[0][0] + local[1] * backEnd.or.axis[1][0] + \n\t\tlocal[2] * backEnd.or.axis[2][0] + backEnd.or.origin[0];\n\tworld[1] = local[0] * backEnd.or.axis[0][1] + local[1] * backEnd.or.axis[1][1] + \n\t\tlocal[2] * backEnd.or.axis[2][1] + backEnd.or.origin[1];\n\tworld[2] = local[0] * backEnd.or.axis[0][2] + local[1] * backEnd.or.axis[1][2] + \n\t\tlocal[2] * backEnd.or.axis[2][2] + backEnd.or.origin[2];\n\n\tVectorSubtract( world, backEnd.viewParms.or.origin, world );\n\td = DotProduct( world, backEnd.viewParms.or.axis[0] );\n\n\tif ( d < 0 ) {\n\t\td = -d;\n\t}\n\td -= radius;\n\tif ( d < 1 ) {\n\t\td = 1;\n\t}\n\n\treturn r_lodCurveError->value / d;\n}\n\n/*\n=============\nRB_SurfaceGrid\n\nJust copy the grid of points and triangulate\n=============\n*/\nvoid RB_SurfaceGrid( srfGridMesh_t *cv ) {\n\tint\t\ti, j;\n\tfloat\t*xyz;\n\tfloat\t*texCoords;\n\tfloat\t*normal;\n\tunsigned char *color;\n\tdrawVert_t\t*dv;\n\tint\t\trows, irows, vrows;\n\tint\t\tused;\n\tint\t\twidthTable[MAX_GRID_SIZE];\n\tint\t\theightTable[MAX_GRID_SIZE];\n\tfloat\tlodError;\n\tint\t\tlodWidth, lodHeight;\n\tint\t\tnumVertexes;\n\tint\t\tdlightBits;\n\tint\t\t*vDlightBits;\n\tqboolean\tneedsNormal;\n\n\tdlightBits = cv->dlightBits[backEnd.smpFrame];\n\ttess.dlightBits |= dlightBits;\n\n\t// determine the allowable discrepance\n\tlodError = LodErrorForVolume( cv->lodOrigin, cv->lodRadius );\n\n\t// determine which rows and columns of the subdivision\n\t// we are actually going to use\n\twidthTable[0] = 0;\n\tlodWidth = 1;\n\tfor ( i = 1 ; i < cv->width-1 ; i++ ) {\n\t\tif ( cv->widthLodError[i] <= lodError ) {\n\t\t\twidthTable[lodWidth] = i;\n\t\t\tlodWidth++;\n\t\t}\n\t}\n\twidthTable[lodWidth] = cv->width-1;\n\tlodWidth++;\n\n\theightTable[0] = 0;\n\tlodHeight = 1;\n\tfor ( i = 1 ; i < cv->height-1 ; i++ ) {\n\t\tif ( cv->heightLodError[i] <= lodError ) {\n\t\t\theightTable[lodHeight] = i;\n\t\t\tlodHeight++;\n\t\t}\n\t}\n\theightTable[lodHeight] = cv->height-1;\n\tlodHeight++;\n\n\n\t// very large grids may have more points or indexes than can be fit\n\t// in the tess structure, so we may have to issue it in multiple passes\n\n\tused = 0;\n\trows = 0;\n\twhile ( used < lodHeight - 1 ) {\n\t\t// see how many rows of both verts and indexes we can add without overflowing\n\t\tdo {\n\t\t\tvrows = ( SHADER_MAX_VERTEXES - tess.numVertexes ) / lodWidth;\n\t\t\tirows = ( SHADER_MAX_INDEXES - tess.numIndexes ) / ( lodWidth * 6 );\n\n\t\t\t// if we don't have enough space for at least one strip, flush the buffer\n\t\t\tif ( vrows < 2 || irows < 1 ) {\n\t\t\t\tRB_EndSurface();\n\t\t\t\tRB_BeginSurface(tess.shader, tess.fogNum );\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} while ( 1 );\n\t\t\n\t\trows = irows;\n\t\tif ( vrows < irows + 1 ) {\n\t\t\trows = vrows - 1;\n\t\t}\n\t\tif ( used + rows > lodHeight ) {\n\t\t\trows = lodHeight - used;\n\t\t}\n\n\t\tnumVertexes = tess.numVertexes;\n\n\t\txyz = tess.xyz[numVertexes];\n\t\tnormal = tess.normal[numVertexes];\n\t\ttexCoords = tess.texCoords[numVertexes][0];\n\t\tcolor = ( unsigned char * ) &tess.vertexColors[numVertexes];\n\t\tvDlightBits = &tess.vertexDlightBits[numVertexes];\n\t\tneedsNormal = tess.shader->needsNormal;\n\n\t\tfor ( i = 0 ; i < rows ; i++ ) {\n\t\t\tfor ( j = 0 ; j < lodWidth ; j++ ) {\n\t\t\t\tdv = cv->verts + heightTable[ used + i ] * cv->width\n\t\t\t\t\t+ widthTable[ j ];\n\n\t\t\t\txyz[0] = dv->xyz[0];\n\t\t\t\txyz[1] = dv->xyz[1];\n\t\t\t\txyz[2] = dv->xyz[2];\n\t\t\t\ttexCoords[0] = dv->st[0];\n\t\t\t\ttexCoords[1] = dv->st[1];\n\t\t\t\ttexCoords[2] = dv->lightmap[0];\n\t\t\t\ttexCoords[3] = dv->lightmap[1];\n\t\t\t\tif ( needsNormal ) {\n\t\t\t\t\tnormal[0] = dv->normal[0];\n\t\t\t\t\tnormal[1] = dv->normal[1];\n\t\t\t\t\tnormal[2] = dv->normal[2];\n\t\t\t\t}\n\t\t\t\t* ( unsigned int * ) color = * ( unsigned int * ) dv->color;\n\t\t\t\t*vDlightBits++ = dlightBits;\n\t\t\t\txyz += 4;\n\t\t\t\tnormal += 4;\n\t\t\t\ttexCoords += 4;\n\t\t\t\tcolor += 4;\n\t\t\t}\n\t\t}\n\n\n\t\t// add the indexes\n\t\t{\n\t\t\tint\t\tnumIndexes;\n\t\t\tint\t\tw, h;\n\n\t\t\th = rows - 1;\n\t\t\tw = lodWidth - 1;\n\t\t\tnumIndexes = tess.numIndexes;\n\t\t\tfor (i = 0 ; i < h ; i++) {\n\t\t\t\tfor (j = 0 ; j < w ; j++) {\n\t\t\t\t\tint\t\tv1, v2, v3, v4;\n\t\t\t\n\t\t\t\t\t// vertex order to be reckognized as tristrips\n\t\t\t\t\tv1 = numVertexes + i*lodWidth + j + 1;\n\t\t\t\t\tv2 = v1 - 1;\n\t\t\t\t\tv3 = v2 + lodWidth;\n\t\t\t\t\tv4 = v3 + 1;\n\n\t\t\t\t\ttess.indexes[numIndexes] = v2;\n\t\t\t\t\ttess.indexes[numIndexes+1] = v3;\n\t\t\t\t\ttess.indexes[numIndexes+2] = v1;\n\t\t\t\t\t\n\t\t\t\t\ttess.indexes[numIndexes+3] = v1;\n\t\t\t\t\ttess.indexes[numIndexes+4] = v3;\n\t\t\t\t\ttess.indexes[numIndexes+5] = v4;\n\t\t\t\t\tnumIndexes += 6;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttess.numIndexes = numIndexes;\n\t\t}\n\n\t\ttess.numVertexes += rows * lodWidth;\n\n\t\tused += rows - 1;\n\t}\n}\n\n\n/*\n===========================================================================\n\nNULL MODEL\n\n===========================================================================\n*/\n\n/*\n===================\nRB_SurfaceAxis\n\nDraws x/y/z lines from the origin for orientation debugging\n===================\n*/\nvoid RB_SurfaceAxis( void ) {\n\tGL_Bind( tr.whiteImage );\n\tqglLineWidth( 3 );\n\tqglBegin( GL_LINES );\n\tqglColor3f( 1,0,0 );\n\tqglVertex3f( 0,0,0 );\n\tqglVertex3f( 16,0,0 );\n\tqglColor3f( 0,1,0 );\n\tqglVertex3f( 0,0,0 );\n\tqglVertex3f( 0,16,0 );\n\tqglColor3f( 0,0,1 );\n\tqglVertex3f( 0,0,0 );\n\tqglVertex3f( 0,0,16 );\n\tqglEnd();\n\tqglLineWidth( 1 );\n}\n\n//===========================================================================\n\n/*\n====================\nRB_SurfaceEntity\n\nEntities that have a single procedurally generated surface\n====================\n*/\nvoid RB_SurfaceEntity( surfaceType_t *surfType ) {\n\tswitch( backEnd.currentEntity->e.reType ) {\n\tcase RT_SPRITE:\n\t\tRB_SurfaceSprite();\n\t\tbreak;\n\tcase RT_BEAM:\n\t\tRB_SurfaceBeam();\n\t\tbreak;\n\tcase RT_RAIL_CORE:\n\t\tRB_SurfaceRailCore();\n\t\tbreak;\n\tcase RT_RAIL_RINGS:\n\t\tRB_SurfaceRailRings();\n\t\tbreak;\n\tcase RT_LIGHTNING:\n\t\tRB_SurfaceLightningBolt();\n\t\tbreak;\n\tdefault:\n\t\tRB_SurfaceAxis();\n\t\tbreak;\n\t}\n\treturn;\n}\n\nvoid RB_SurfaceBad( surfaceType_t *surfType ) {\n\tri.Printf( PRINT_ALL, \"Bad surface tesselated.\\n\" );\n}\n\n#if 0\n\nvoid RB_SurfaceFlare( srfFlare_t *surf ) {\n\tvec3_t\t\tleft, up;\n\tfloat\t\tradius;\n\tbyte\t\tcolor[4];\n\tvec3_t\t\tdir;\n\tvec3_t\t\torigin;\n\tfloat\t\td;\n\n\t// calculate the xyz locations for the four corners\n\tradius = 30;\n\tVectorScale( backEnd.viewParms.or.axis[1], radius, left );\n\tVectorScale( backEnd.viewParms.or.axis[2], radius, up );\n\tif ( backEnd.viewParms.isMirror ) {\n\t\tVectorSubtract( vec3_origin, left, left );\n\t}\n\n\tcolor[0] = color[1] = color[2] = color[3] = 255;\n\n\tVectorMA( surf->origin, 3, surf->normal, origin );\n\tVectorSubtract( origin, backEnd.viewParms.or.origin, dir );\n\tVectorNormalize( dir );\n\tVectorMA( origin, r_ignore->value, dir, origin );\n\n\td = -DotProduct( dir, surf->normal );\n\tif ( d < 0 ) {\n\t\treturn;\n\t}\n#if 0\n\tcolor[0] *= d;\n\tcolor[1] *= d;\n\tcolor[2] *= d;\n#endif\n\n\tRB_AddQuadStamp( origin, left, up, color );\n}\n\n#else\n\nvoid RB_SurfaceFlare( srfFlare_t *surf ) {\n#if 0\n\tvec3_t\t\tleft, up;\n\tbyte\t\tcolor[4];\n\n\tcolor[0] = surf->color[0] * 255;\n\tcolor[1] = surf->color[1] * 255;\n\tcolor[2] = surf->color[2] * 255;\n\tcolor[3] = 255;\n\n\tVectorClear( left );\n\tVectorClear( up );\n\n\tleft[0] = r_ignore->value;\n\n\tup[1] = r_ignore->value;\n\t\n\tRB_AddQuadStampExt( surf->origin, left, up, color, 0, 0, 1, 1 );\n#endif\n}\n\n#endif\n\n\n\nvoid RB_SurfaceDisplayList( srfDisplayList_t *surf ) {\n\t// all apropriate state must be set in RB_BeginSurface\n\t// this isn't implemented yet...\n\tqglCallList( surf->listNum );\n}\n\nvoid RB_SurfaceSkip( void *surf ) {\n}\n\n\nvoid (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( void *) = {\n\t(void(*)(void*))RB_SurfaceBad,\t\t\t// SF_BAD, \n\t(void(*)(void*))RB_SurfaceSkip,\t\t\t// SF_SKIP, \n\t(void(*)(void*))RB_SurfaceFace,\t\t\t// SF_FACE,\n\t(void(*)(void*))RB_SurfaceGrid,\t\t\t// SF_GRID,\n\t(void(*)(void*))RB_SurfaceTriangles,\t// SF_TRIANGLES,\n\t(void(*)(void*))RB_SurfacePolychain,\t// SF_POLY,\n\t(void(*)(void*))RB_SurfaceMesh,\t\t\t// SF_MD3,\n\t(void(*)(void*))RB_SurfaceAnim,\t\t\t// SF_MD4,\n\t(void(*)(void*))RB_SurfaceFlare,\t\t// SF_FLARE,\n\t(void(*)(void*))RB_SurfaceEntity,\t\t// SF_ENTITY\n\t(void(*)(void*))RB_SurfaceDisplayList\t// SF_DISPLAY_LIST\n};\n"
  },
  {
    "path": "code/renderer/tr_world.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"tr_local.h\"\n\n\n\n/*\n=================\nR_CullTriSurf\n\nReturns true if the grid is completely culled away.\nAlso sets the clipped hint bit in tess\n=================\n*/\nstatic qboolean\tR_CullTriSurf( srfTriangles_t *cv ) {\n\tint \tboxCull;\n\n\tboxCull = R_CullLocalBox( cv->bounds );\n\n\tif ( boxCull == CULL_OUT ) {\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n=================\nR_CullGrid\n\nReturns true if the grid is completely culled away.\nAlso sets the clipped hint bit in tess\n=================\n*/\nstatic qboolean\tR_CullGrid( srfGridMesh_t *cv ) {\n\tint \tboxCull;\n\tint \tsphereCull;\n\n\tif ( r_nocurves->integer ) {\n\t\treturn qtrue;\n\t}\n\n\tif ( tr.currentEntityNum != ENTITYNUM_WORLD ) {\n\t\tsphereCull = R_CullLocalPointAndRadius( cv->localOrigin, cv->meshRadius );\n\t} else {\n\t\tsphereCull = R_CullPointAndRadius( cv->localOrigin, cv->meshRadius );\n\t}\n\tboxCull = CULL_OUT;\n\t\n\t// check for trivial reject\n\tif ( sphereCull == CULL_OUT )\n\t{\n\t\ttr.pc.c_sphere_cull_patch_out++;\n\t\treturn qtrue;\n\t}\n\t// check bounding box if necessary\n\telse if ( sphereCull == CULL_CLIP )\n\t{\n\t\ttr.pc.c_sphere_cull_patch_clip++;\n\n\t\tboxCull = R_CullLocalBox( cv->meshBounds );\n\n\t\tif ( boxCull == CULL_OUT ) \n\t\t{\n\t\t\ttr.pc.c_box_cull_patch_out++;\n\t\t\treturn qtrue;\n\t\t}\n\t\telse if ( boxCull == CULL_IN )\n\t\t{\n\t\t\ttr.pc.c_box_cull_patch_in++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\ttr.pc.c_box_cull_patch_clip++;\n\t\t}\n\t}\n\telse\n\t{\n\t\ttr.pc.c_sphere_cull_patch_in++;\n\t}\n\n\treturn qfalse;\n}\n\n\n/*\n================\nR_CullSurface\n\nTries to back face cull surfaces before they are lighted or\nadded to the sorting list.\n\nThis will also allow mirrors on both sides of a model without recursion.\n================\n*/\nstatic qboolean\tR_CullSurface( surfaceType_t *surface, shader_t *shader ) {\n\tsrfSurfaceFace_t *sface;\n\tfloat\t\t\td;\n\n\tif ( r_nocull->integer ) {\n\t\treturn qfalse;\n\t}\n\n\tif ( *surface == SF_GRID ) {\n\t\treturn R_CullGrid( (srfGridMesh_t *)surface );\n\t}\n\n\tif ( *surface == SF_TRIANGLES ) {\n\t\treturn R_CullTriSurf( (srfTriangles_t *)surface );\n\t}\n\n\tif ( *surface != SF_FACE ) {\n\t\treturn qfalse;\n\t}\n\n\tif ( shader->cullType == CT_TWO_SIDED ) {\n\t\treturn qfalse;\n\t}\n\n\t// face culling\n\tif ( !r_facePlaneCull->integer ) {\n\t\treturn qfalse;\n\t}\n\n\tsface = ( srfSurfaceFace_t * ) surface;\n\td = DotProduct (tr.or.viewOrigin, sface->plane.normal);\n\n\t// don't cull exactly on the plane, because there are levels of rounding\n\t// through the BSP, ICD, and hardware that may cause pixel gaps if an\n\t// epsilon isn't allowed here \n\tif ( shader->cullType == CT_FRONT_SIDED ) {\n\t\tif ( d < sface->plane.dist - 8 ) {\n\t\t\treturn qtrue;\n\t\t}\n\t} else {\n\t\tif ( d > sface->plane.dist + 8 ) {\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\n\treturn qfalse;\n}\n\n\nstatic int R_DlightFace( srfSurfaceFace_t *face, int dlightBits ) {\n\tfloat\t\td;\n\tint\t\t\ti;\n\tdlight_t\t*dl;\n\n\tfor ( i = 0 ; i < tr.refdef.num_dlights ; i++ ) {\n\t\tif ( ! ( dlightBits & ( 1 << i ) ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\tdl = &tr.refdef.dlights[i];\n\t\td = DotProduct( dl->origin, face->plane.normal ) - face->plane.dist;\n\t\tif ( d < -dl->radius || d > dl->radius ) {\n\t\t\t// dlight doesn't reach the plane\n\t\t\tdlightBits &= ~( 1 << i );\n\t\t}\n\t}\n\n\tif ( !dlightBits ) {\n\t\ttr.pc.c_dlightSurfacesCulled++;\n\t}\n\n\tface->dlightBits[ tr.smpFrame ] = dlightBits;\n\treturn dlightBits;\n}\n\nstatic int R_DlightGrid( srfGridMesh_t *grid, int dlightBits ) {\n\tint\t\t\ti;\n\tdlight_t\t*dl;\n\n\tfor ( i = 0 ; i < tr.refdef.num_dlights ; i++ ) {\n\t\tif ( ! ( dlightBits & ( 1 << i ) ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\tdl = &tr.refdef.dlights[i];\n\t\tif ( dl->origin[0] - dl->radius > grid->meshBounds[1][0]\n\t\t\t|| dl->origin[0] + dl->radius < grid->meshBounds[0][0]\n\t\t\t|| dl->origin[1] - dl->radius > grid->meshBounds[1][1]\n\t\t\t|| dl->origin[1] + dl->radius < grid->meshBounds[0][1]\n\t\t\t|| dl->origin[2] - dl->radius > grid->meshBounds[1][2]\n\t\t\t|| dl->origin[2] + dl->radius < grid->meshBounds[0][2] ) {\n\t\t\t// dlight doesn't reach the bounds\n\t\t\tdlightBits &= ~( 1 << i );\n\t\t}\n\t}\n\n\tif ( !dlightBits ) {\n\t\ttr.pc.c_dlightSurfacesCulled++;\n\t}\n\n\tgrid->dlightBits[ tr.smpFrame ] = dlightBits;\n\treturn dlightBits;\n}\n\n\nstatic int R_DlightTrisurf( srfTriangles_t *surf, int dlightBits ) {\n\t// FIXME: more dlight culling to trisurfs...\n\tsurf->dlightBits[ tr.smpFrame ] = dlightBits;\n\treturn dlightBits;\n#if 0\n\tint\t\t\ti;\n\tdlight_t\t*dl;\n\n\tfor ( i = 0 ; i < tr.refdef.num_dlights ; i++ ) {\n\t\tif ( ! ( dlightBits & ( 1 << i ) ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\tdl = &tr.refdef.dlights[i];\n\t\tif ( dl->origin[0] - dl->radius > grid->meshBounds[1][0]\n\t\t\t|| dl->origin[0] + dl->radius < grid->meshBounds[0][0]\n\t\t\t|| dl->origin[1] - dl->radius > grid->meshBounds[1][1]\n\t\t\t|| dl->origin[1] + dl->radius < grid->meshBounds[0][1]\n\t\t\t|| dl->origin[2] - dl->radius > grid->meshBounds[1][2]\n\t\t\t|| dl->origin[2] + dl->radius < grid->meshBounds[0][2] ) {\n\t\t\t// dlight doesn't reach the bounds\n\t\t\tdlightBits &= ~( 1 << i );\n\t\t}\n\t}\n\n\tif ( !dlightBits ) {\n\t\ttr.pc.c_dlightSurfacesCulled++;\n\t}\n\n\tgrid->dlightBits[ tr.smpFrame ] = dlightBits;\n\treturn dlightBits;\n#endif\n}\n\n/*\n====================\nR_DlightSurface\n\nThe given surface is going to be drawn, and it touches a leaf\nthat is touched by one or more dlights, so try to throw out\nmore dlights if possible.\n====================\n*/\nstatic int R_DlightSurface( msurface_t *surf, int dlightBits ) {\n\tif ( *surf->data == SF_FACE ) {\n\t\tdlightBits = R_DlightFace( (srfSurfaceFace_t *)surf->data, dlightBits );\n\t} else if ( *surf->data == SF_GRID ) {\n\t\tdlightBits = R_DlightGrid( (srfGridMesh_t *)surf->data, dlightBits );\n\t} else if ( *surf->data == SF_TRIANGLES ) {\n\t\tdlightBits = R_DlightTrisurf( (srfTriangles_t *)surf->data, dlightBits );\n\t} else {\n\t\tdlightBits = 0;\n\t}\n\n\tif ( dlightBits ) {\n\t\ttr.pc.c_dlightSurfaces++;\n\t}\n\n\treturn dlightBits;\n}\n\n\n\n/*\n======================\nR_AddWorldSurface\n======================\n*/\nstatic void R_AddWorldSurface( msurface_t *surf, int dlightBits ) {\n\tif ( surf->viewCount == tr.viewCount ) {\n\t\treturn;\t\t// already in this view\n\t}\n\n\tsurf->viewCount = tr.viewCount;\n\t// FIXME: bmodel fog?\n\n\t// try to cull before dlighting or adding\n\tif ( R_CullSurface( surf->data, surf->shader ) ) {\n\t\treturn;\n\t}\n\n\t// check for dlighting\n\tif ( dlightBits ) {\n\t\tdlightBits = R_DlightSurface( surf, dlightBits );\n\t\tdlightBits = ( dlightBits != 0 );\n\t}\n\n\tR_AddDrawSurf( surf->data, surf->shader, surf->fogIndex, dlightBits );\n}\n\n/*\n=============================================================\n\n\tBRUSH MODELS\n\n=============================================================\n*/\n\n/*\n=================\nR_AddBrushModelSurfaces\n=================\n*/\nvoid R_AddBrushModelSurfaces ( trRefEntity_t *ent ) {\n\tbmodel_t\t*bmodel;\n\tint\t\t\tclip;\n\tmodel_t\t\t*pModel;\n\tint\t\t\ti;\n\n\tpModel = R_GetModelByHandle( ent->e.hModel );\n\n\tbmodel = pModel->bmodel;\n\n\tclip = R_CullLocalBox( bmodel->bounds );\n\tif ( clip == CULL_OUT ) {\n\t\treturn;\n\t}\n\t\n\tR_DlightBmodel( bmodel );\n\n\tfor ( i = 0 ; i < bmodel->numSurfaces ; i++ ) {\n\t\tR_AddWorldSurface( bmodel->firstSurface + i, tr.currentEntity->needDlights );\n\t}\n}\n\n\n/*\n=============================================================\n\n\tWORLD MODEL\n\n=============================================================\n*/\n\n\n/*\n================\nR_RecursiveWorldNode\n================\n*/\nstatic void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits ) {\n\n\tdo {\n\t\tint\t\t\tnewDlights[2];\n\n\t\t// if the node wasn't marked as potentially visible, exit\n\t\tif (node->visframe != tr.visCount) {\n\t\t\treturn;\n\t\t}\n\n\t\t// if the bounding volume is outside the frustum, nothing\n\t\t// inside can be visible OPTIMIZE: don't do this all the way to leafs?\n\n\t\tif ( !r_nocull->integer ) {\n\t\t\tint\t\tr;\n\n\t\t\tif ( planeBits & 1 ) {\n\t\t\t\tr = BoxOnPlaneSide(node->mins, node->maxs, &tr.viewParms.frustum[0]);\n\t\t\t\tif (r == 2) {\n\t\t\t\t\treturn;\t\t\t\t\t\t// culled\n\t\t\t\t}\n\t\t\t\tif ( r == 1 ) {\n\t\t\t\t\tplaneBits &= ~1;\t\t\t// all descendants will also be in front\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( planeBits & 2 ) {\n\t\t\t\tr = BoxOnPlaneSide(node->mins, node->maxs, &tr.viewParms.frustum[1]);\n\t\t\t\tif (r == 2) {\n\t\t\t\t\treturn;\t\t\t\t\t\t// culled\n\t\t\t\t}\n\t\t\t\tif ( r == 1 ) {\n\t\t\t\t\tplaneBits &= ~2;\t\t\t// all descendants will also be in front\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( planeBits & 4 ) {\n\t\t\t\tr = BoxOnPlaneSide(node->mins, node->maxs, &tr.viewParms.frustum[2]);\n\t\t\t\tif (r == 2) {\n\t\t\t\t\treturn;\t\t\t\t\t\t// culled\n\t\t\t\t}\n\t\t\t\tif ( r == 1 ) {\n\t\t\t\t\tplaneBits &= ~4;\t\t\t// all descendants will also be in front\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( planeBits & 8 ) {\n\t\t\t\tr = BoxOnPlaneSide(node->mins, node->maxs, &tr.viewParms.frustum[3]);\n\t\t\t\tif (r == 2) {\n\t\t\t\t\treturn;\t\t\t\t\t\t// culled\n\t\t\t\t}\n\t\t\t\tif ( r == 1 ) {\n\t\t\t\t\tplaneBits &= ~8;\t\t\t// all descendants will also be in front\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif ( node->contents != -1 ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// node is just a decision point, so go down both sides\n\t\t// since we don't care about sort orders, just go positive to negative\n\n\t\t// determine which dlights are needed\n\t\tnewDlights[0] = 0;\n\t\tnewDlights[1] = 0;\n\t\tif ( dlightBits ) {\n\t\t\tint\ti;\n\n\t\t\tfor ( i = 0 ; i < tr.refdef.num_dlights ; i++ ) {\n\t\t\t\tdlight_t\t*dl;\n\t\t\t\tfloat\t\tdist;\n\n\t\t\t\tif ( dlightBits & ( 1 << i ) ) {\n\t\t\t\t\tdl = &tr.refdef.dlights[i];\n\t\t\t\t\tdist = DotProduct( dl->origin, node->plane->normal ) - node->plane->dist;\n\t\t\t\t\t\n\t\t\t\t\tif ( dist > -dl->radius ) {\n\t\t\t\t\t\tnewDlights[0] |= ( 1 << i );\n\t\t\t\t\t}\n\t\t\t\t\tif ( dist < dl->radius ) {\n\t\t\t\t\t\tnewDlights[1] |= ( 1 << i );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// recurse down the children, front side first\n\t\tR_RecursiveWorldNode (node->children[0], planeBits, newDlights[0] );\n\n\t\t// tail recurse\n\t\tnode = node->children[1];\n\t\tdlightBits = newDlights[1];\n\t} while ( 1 );\n\n\t{\n\t\t// leaf node, so add mark surfaces\n\t\tint\t\t\tc;\n\t\tmsurface_t\t*surf, **mark;\n\n\t\ttr.pc.c_leafs++;\n\n\t\t// add to z buffer bounds\n\t\tif ( node->mins[0] < tr.viewParms.visBounds[0][0] ) {\n\t\t\ttr.viewParms.visBounds[0][0] = node->mins[0];\n\t\t}\n\t\tif ( node->mins[1] < tr.viewParms.visBounds[0][1] ) {\n\t\t\ttr.viewParms.visBounds[0][1] = node->mins[1];\n\t\t}\n\t\tif ( node->mins[2] < tr.viewParms.visBounds[0][2] ) {\n\t\t\ttr.viewParms.visBounds[0][2] = node->mins[2];\n\t\t}\n\n\t\tif ( node->maxs[0] > tr.viewParms.visBounds[1][0] ) {\n\t\t\ttr.viewParms.visBounds[1][0] = node->maxs[0];\n\t\t}\n\t\tif ( node->maxs[1] > tr.viewParms.visBounds[1][1] ) {\n\t\t\ttr.viewParms.visBounds[1][1] = node->maxs[1];\n\t\t}\n\t\tif ( node->maxs[2] > tr.viewParms.visBounds[1][2] ) {\n\t\t\ttr.viewParms.visBounds[1][2] = node->maxs[2];\n\t\t}\n\n\t\t// add the individual surfaces\n\t\tmark = node->firstmarksurface;\n\t\tc = node->nummarksurfaces;\n\t\twhile (c--) {\n\t\t\t// the surface may have already been added if it\n\t\t\t// spans multiple leafs\n\t\t\tsurf = *mark;\n\t\t\tR_AddWorldSurface( surf, dlightBits );\n\t\t\tmark++;\n\t\t}\n\t}\n\n}\n\n\n/*\n===============\nR_PointInLeaf\n===============\n*/\nstatic mnode_t *R_PointInLeaf( const vec3_t p ) {\n\tmnode_t\t\t*node;\n\tfloat\t\td;\n\tcplane_t\t*plane;\n\t\n\tif ( !tr.world ) {\n\t\tri.Error (ERR_DROP, \"R_PointInLeaf: bad model\");\n\t}\n\n\tnode = tr.world->nodes;\n\twhile( 1 ) {\n\t\tif (node->contents != -1) {\n\t\t\tbreak;\n\t\t}\n\t\tplane = node->plane;\n\t\td = DotProduct (p,plane->normal) - plane->dist;\n\t\tif (d > 0) {\n\t\t\tnode = node->children[0];\n\t\t} else {\n\t\t\tnode = node->children[1];\n\t\t}\n\t}\n\t\n\treturn node;\n}\n\n/*\n==============\nR_ClusterPVS\n==============\n*/\nstatic const byte *R_ClusterPVS (int cluster) {\n\tif (!tr.world || !tr.world->vis || cluster < 0 || cluster >= tr.world->numClusters ) {\n\t\treturn tr.world->novis;\n\t}\n\n\treturn tr.world->vis + cluster * tr.world->clusterBytes;\n}\n\n/*\n=================\nR_inPVS\n=================\n*/\nqboolean R_inPVS( const vec3_t p1, const vec3_t p2 ) {\n\tmnode_t *leaf;\n\tbyte\t*vis;\n\n\tleaf = R_PointInLeaf( p1 );\n\tvis = CM_ClusterPVS( leaf->cluster );\n\tleaf = R_PointInLeaf( p2 );\n\n\tif ( !(vis[leaf->cluster>>3] & (1<<(leaf->cluster&7))) ) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n/*\n===============\nR_MarkLeaves\n\nMark the leaves and nodes that are in the PVS for the current\ncluster\n===============\n*/\nstatic void R_MarkLeaves (void) {\n\tconst byte\t*vis;\n\tmnode_t\t*leaf, *parent;\n\tint\t\ti;\n\tint\t\tcluster;\n\n\t// lockpvs lets designers walk around to determine the\n\t// extent of the current pvs\n\tif ( r_lockpvs->integer ) {\n\t\treturn;\n\t}\n\n\t// current viewcluster\n\tleaf = R_PointInLeaf( tr.viewParms.pvsOrigin );\n\tcluster = leaf->cluster;\n\n\t// if the cluster is the same and the area visibility matrix\n\t// hasn't changed, we don't need to mark everything again\n\n\t// if r_showcluster was just turned on, remark everything \n\tif ( tr.viewCluster == cluster && !tr.refdef.areamaskModified \n\t\t&& !r_showcluster->modified ) {\n\t\treturn;\n\t}\n\n\tif ( r_showcluster->modified || r_showcluster->integer ) {\n\t\tr_showcluster->modified = qfalse;\n\t\tif ( r_showcluster->integer ) {\n\t\t\tri.Printf( PRINT_ALL, \"cluster:%i  area:%i\\n\", cluster, leaf->area );\n\t\t}\n\t}\n\n\ttr.visCount++;\n\ttr.viewCluster = cluster;\n\n\tif ( r_novis->integer || tr.viewCluster == -1 ) {\n\t\tfor (i=0 ; i<tr.world->numnodes ; i++) {\n\t\t\tif (tr.world->nodes[i].contents != CONTENTS_SOLID) {\n\t\t\t\ttr.world->nodes[i].visframe = tr.visCount;\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\n\tvis = R_ClusterPVS (tr.viewCluster);\n\t\n\tfor (i=0,leaf=tr.world->nodes ; i<tr.world->numnodes ; i++, leaf++) {\n\t\tcluster = leaf->cluster;\n\t\tif ( cluster < 0 || cluster >= tr.world->numClusters ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// check general pvs\n\t\tif ( !(vis[cluster>>3] & (1<<(cluster&7))) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// check for door connection\n\t\tif ( (tr.refdef.areamask[leaf->area>>3] & (1<<(leaf->area&7)) ) ) {\n\t\t\tcontinue;\t\t// not visible\n\t\t}\n\n\t\tparent = leaf;\n\t\tdo {\n\t\t\tif (parent->visframe == tr.visCount)\n\t\t\t\tbreak;\n\t\t\tparent->visframe = tr.visCount;\n\t\t\tparent = parent->parent;\n\t\t} while (parent);\n\t}\n}\n\n\n/*\n=============\nR_AddWorldSurfaces\n=============\n*/\nvoid R_AddWorldSurfaces (void) {\n\tif ( !r_drawworld->integer ) {\n\t\treturn;\n\t}\n\n\tif ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) {\n\t\treturn;\n\t}\n\n\ttr.currentEntityNum = ENTITYNUM_WORLD;\n\ttr.shiftedEntityNum = tr.currentEntityNum << QSORT_ENTITYNUM_SHIFT;\n\n\t// determine which leaves are in the PVS / areamask\n\tR_MarkLeaves ();\n\n\t// clear out the visible min/max\n\tClearBounds( tr.viewParms.visBounds[0], tr.viewParms.visBounds[1] );\n\n\t// perform frustum culling and add all the potentially visible surfaces\n\tif ( tr.refdef.num_dlights > 32 ) {\n\t\ttr.refdef.num_dlights = 32 ;\n\t}\n\tR_RecursiveWorldNode( tr.world->nodes, 15, ( 1 << tr.refdef.num_dlights ) - 1 );\n}\n"
  },
  {
    "path": "code/renderer.lnt",
    "content": "opts.lnt\n\nrenderer\\tr_bsp.c\nrenderer\\tr_calc.c\nrenderer\\tr_calc_c.c\nrenderer\\tr_curve.c\nrenderer\\tr_draw.c\nrenderer\\tr_image.c\nrenderer\\tr_init.c\nrenderer\\tr_light.c\nrenderer\\tr_main.c\nrenderer\\tr_mesh.c\nrenderer\\tr_misc.c\nrenderer\\tr_model.c\nrenderer\\tr_noise.c\nrenderer\\tr_shade.c\nrenderer\\tr_shader.c\nrenderer\\tr_sky.c\nrenderer\\tr_stripify.c\nrenderer\\tr_subdivide.c\nrenderer\\tr_surf.c\nrenderer\\tr_world.c\n\ngame\\q_math.c\ngame\\q_shared.c\n\nnull\\null_glimp.c\n"
  },
  {
    "path": "code/run.bat",
    "content": "debug\\quake3 +set fs_basepath \\quake3 +set fs_cdpath g:\\quake3 + %1 %2 %3 %4 %5 %6 %7 %8 %9\n"
  },
  {
    "path": "code/runrelease.bat",
    "content": "release\\quake3 +set fs_basepath \\quake3 +set fs_cdpath g:\\quake3 + %1 %2 %3 %4 %5 %6 %7 %8 %9\n"
  },
  {
    "path": "code/server/server.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// server.h\n\n#include \"../game/q_shared.h\"\n#include \"../qcommon/qcommon.h\"\n#include \"../game/g_public.h\"\n#include \"../game/bg_public.h\"\n\n//=============================================================================\n\n#define\tPERS_SCORE\t\t\t\t0\t\t// !!! MUST NOT CHANGE, SERVER AND\n\t\t\t\t\t\t\t\t\t\t// GAME BOTH REFERENCE !!!\n\n#define\tMAX_ENT_CLUSTERS\t16\n\ntypedef struct svEntity_s {\n\tstruct worldSector_s *worldSector;\n\tstruct svEntity_s *nextEntityInWorldSector;\n\t\n\tentityState_t\tbaseline;\t\t// for delta compression of initial sighting\n\tint\t\t\tnumClusters;\t\t// if -1, use headnode instead\n\tint\t\t\tclusternums[MAX_ENT_CLUSTERS];\n\tint\t\t\tlastCluster;\t\t// if all the clusters don't fit in clusternums\n\tint\t\t\tareanum, areanum2;\n\tint\t\t\tsnapshotCounter;\t// used to prevent double adding from portal views\n} svEntity_t;\n\ntypedef enum {\n\tSS_DEAD,\t\t\t// no map loaded\n\tSS_LOADING,\t\t\t// spawning level entities\n\tSS_GAME\t\t\t\t// actively running\n} serverState_t;\n\ntypedef struct {\n\tserverState_t\tstate;\n\tqboolean\t\trestarting;\t\t\t// if true, send configstring changes during SS_LOADING\n\tint\t\t\t\tserverId;\t\t\t// changes each server start\n\tint\t\t\t\trestartedServerId;\t// serverId before a map_restart\n\tint\t\t\t\tchecksumFeed;\t\t// the feed key that we use to compute the pure checksum strings\n\t// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=475\n\t// the serverId associated with the current checksumFeed (always <= serverId)\n\tint       checksumFeedServerId;\t\n\tint\t\t\t\tsnapshotCounter;\t// incremented for each snapshot built\n\tint\t\t\t\ttimeResidual;\t\t// <= 1000 / sv_frame->value\n\tint\t\t\t\tnextFrameTime;\t\t// when time > nextFrameTime, process world\n\tstruct cmodel_s\t*models[MAX_MODELS];\n\tchar\t\t\t*configstrings[MAX_CONFIGSTRINGS];\n\tsvEntity_t\t\tsvEntities[MAX_GENTITIES];\n\n\tchar\t\t\t*entityParsePoint;\t// used during game VM init\n\n\t// the game virtual machine will update these on init and changes\n\tsharedEntity_t\t*gentities;\n\tint\t\t\t\tgentitySize;\n\tint\t\t\t\tnum_entities;\t\t// current number, <= MAX_GENTITIES\n\n\tplayerState_t\t*gameClients;\n\tint\t\t\t\tgameClientSize;\t\t// will be > sizeof(playerState_t) due to game private data\n\n\tint\t\t\t\trestartTime;\n} server_t;\n\n\n\n\n\ntypedef struct {\n\tint\t\t\t\tareabytes;\n\tbyte\t\t\tareabits[MAX_MAP_AREA_BYTES];\t\t// portalarea visibility bits\n\tplayerState_t\tps;\n\tint\t\t\t\tnum_entities;\n\tint\t\t\t\tfirst_entity;\t\t// into the circular sv_packet_entities[]\n\t\t\t\t\t\t\t\t\t\t// the entities MUST be in increasing state number\n\t\t\t\t\t\t\t\t\t\t// order, otherwise the delta compression will fail\n\tint\t\t\t\tmessageSent;\t\t// time the message was transmitted\n\tint\t\t\t\tmessageAcked;\t\t// time the message was acked\n\tint\t\t\t\tmessageSize;\t\t// used to rate drop packets\n} clientSnapshot_t;\n\ntypedef enum {\n\tCS_FREE,\t\t// can be reused for a new connection\n\tCS_ZOMBIE,\t\t// client has been disconnected, but don't reuse\n\t\t\t\t\t// connection for a couple seconds\n\tCS_CONNECTED,\t// has been assigned to a client_t, but no gamestate yet\n\tCS_PRIMED,\t\t// gamestate has been sent, but client hasn't sent a usercmd\n\tCS_ACTIVE\t\t// client is fully in game\n} clientState_t;\n\ntypedef struct netchan_buffer_s {\n\tmsg_t           msg;\n\tbyte            msgBuffer[MAX_MSGLEN];\n\tstruct netchan_buffer_s *next;\n} netchan_buffer_t;\n\ntypedef struct client_s {\n\tclientState_t\tstate;\n\tchar\t\t\tuserinfo[MAX_INFO_STRING];\t\t// name, etc\n\n\tchar\t\t\treliableCommands[MAX_RELIABLE_COMMANDS][MAX_STRING_CHARS];\n\tint\t\t\t\treliableSequence;\t\t// last added reliable message, not necesarily sent or acknowledged yet\n\tint\t\t\t\treliableAcknowledge;\t// last acknowledged reliable message\n\tint\t\t\t\treliableSent;\t\t\t// last sent reliable message, not necesarily acknowledged yet\n\tint\t\t\t\tmessageAcknowledge;\n\n\tint\t\t\t\tgamestateMessageNum;\t// netchan->outgoingSequence of gamestate\n\tint\t\t\t\tchallenge;\n\n\tusercmd_t\t\tlastUsercmd;\n\tint\t\t\t\tlastMessageNum;\t\t// for delta compression\n\tint\t\t\t\tlastClientCommand;\t// reliable client message sequence\n\tchar\t\t\tlastClientCommandString[MAX_STRING_CHARS];\n\tsharedEntity_t\t*gentity;\t\t\t// SV_GentityNum(clientnum)\n\tchar\t\t\tname[MAX_NAME_LENGTH];\t\t\t// extracted from userinfo, high bits masked\n\n\t// downloading\n\tchar\t\t\tdownloadName[MAX_QPATH]; // if not empty string, we are downloading\n\tfileHandle_t\tdownload;\t\t\t// file being downloaded\n \tint\t\t\t\tdownloadSize;\t\t// total bytes (can't use EOF because of paks)\n \tint\t\t\t\tdownloadCount;\t\t// bytes sent\n\tint\t\t\t\tdownloadClientBlock;\t// last block we sent to the client, awaiting ack\n\tint\t\t\t\tdownloadCurrentBlock;\t// current block number\n\tint\t\t\t\tdownloadXmitBlock;\t// last block we xmited\n\tunsigned char\t*downloadBlocks[MAX_DOWNLOAD_WINDOW];\t// the buffers for the download blocks\n\tint\t\t\t\tdownloadBlockSize[MAX_DOWNLOAD_WINDOW];\n\tqboolean\t\tdownloadEOF;\t\t// We have sent the EOF block\n\tint\t\t\t\tdownloadSendTime;\t// time we last got an ack from the client\n\n\tint\t\t\t\tdeltaMessage;\t\t// frame last client usercmd message\n\tint\t\t\t\tnextReliableTime;\t// svs.time when another reliable command will be allowed\n\tint\t\t\t\tlastPacketTime;\t\t// svs.time when packet was last received\n\tint\t\t\t\tlastConnectTime;\t// svs.time when connection started\n\tint\t\t\t\tnextSnapshotTime;\t// send another snapshot when svs.time >= nextSnapshotTime\n\tqboolean\t\trateDelayed;\t\t// true if nextSnapshotTime was set based on rate instead of snapshotMsec\n\tint\t\t\t\ttimeoutCount;\t\t// must timeout a few frames in a row so debugging doesn't break\n\tclientSnapshot_t\tframes[PACKET_BACKUP];\t// updates can be delta'd from here\n\tint\t\t\t\tping;\n\tint\t\t\t\trate;\t\t\t\t// bytes / second\n\tint\t\t\t\tsnapshotMsec;\t\t// requests a snapshot every snapshotMsec unless rate choked\n\tint\t\t\t\tpureAuthentic;\n\tqboolean  gotCP; // TTimo - additional flag to distinguish between a bad pure checksum, and no cp command at all\n\tnetchan_t\t\tnetchan;\n\t// TTimo\n\t// queuing outgoing fragmented messages to send them properly, without udp packet bursts\n\t// in case large fragmented messages are stacking up\n\t// buffer them into this queue, and hand them out to netchan as needed\n\tnetchan_buffer_t *netchan_start_queue;\n\tnetchan_buffer_t **netchan_end_queue;\n} client_t;\n\n//=============================================================================\n\n\n// MAX_CHALLENGES is made large to prevent a denial\n// of service attack that could cycle all of them\n// out before legitimate users connected\n#define\tMAX_CHALLENGES\t1024\n\n#define\tAUTHORIZE_TIMEOUT\t5000\n\ntypedef struct {\n\tnetadr_t\tadr;\n\tint\t\t\tchallenge;\n\tint\t\t\ttime;\t\t\t\t// time the last packet was sent to the autherize server\n\tint\t\t\tpingTime;\t\t\t// time the challenge response was sent to client\n\tint\t\t\tfirstTime;\t\t\t// time the adr was first used, for authorize timeout checks\n\tqboolean\tconnected;\n} challenge_t;\n\n\n#define\tMAX_MASTERS\t8\t\t\t\t// max recipients for heartbeat packets\n\n\n// this structure will be cleared only when the game dll changes\ntypedef struct {\n\tqboolean\tinitialized;\t\t\t\t// sv_init has completed\n\n\tint\t\t\ttime;\t\t\t\t\t\t// will be strictly increasing across level changes\n\n\tint\t\t\tsnapFlagServerBit;\t\t\t// ^= SNAPFLAG_SERVERCOUNT every SV_SpawnServer()\n\n\tclient_t\t*clients;\t\t\t\t\t// [sv_maxclients->integer];\n\tint\t\t\tnumSnapshotEntities;\t\t// sv_maxclients->integer*PACKET_BACKUP*MAX_PACKET_ENTITIES\n\tint\t\t\tnextSnapshotEntities;\t\t// next snapshotEntities to use\n\tentityState_t\t*snapshotEntities;\t\t// [numSnapshotEntities]\n\tint\t\t\tnextHeartbeatTime;\n\tchallenge_t\tchallenges[MAX_CHALLENGES];\t// to prevent invalid IPs from connecting\n\tnetadr_t\tredirectAddress;\t\t\t// for rcon return messages\n\n\tnetadr_t\tauthorizeAddress;\t\t\t// for rcon return messages\n} serverStatic_t;\n\n//=============================================================================\n\nextern\tserverStatic_t\tsvs;\t\t\t\t// persistant server info across maps\nextern\tserver_t\t\tsv;\t\t\t\t\t// cleared each map\nextern\tvm_t\t\t\t*gvm;\t\t\t\t// game virtual machine\n\n#define\tMAX_MASTER_SERVERS\t5\n\nextern\tcvar_t\t*sv_fps;\nextern\tcvar_t\t*sv_timeout;\nextern\tcvar_t\t*sv_zombietime;\nextern\tcvar_t\t*sv_rconPassword;\nextern\tcvar_t\t*sv_privatePassword;\nextern\tcvar_t\t*sv_allowDownload;\nextern\tcvar_t\t*sv_maxclients;\n\nextern\tcvar_t\t*sv_privateClients;\nextern\tcvar_t\t*sv_hostname;\nextern\tcvar_t\t*sv_master[MAX_MASTER_SERVERS];\nextern\tcvar_t\t*sv_reconnectlimit;\nextern\tcvar_t\t*sv_showloss;\nextern\tcvar_t\t*sv_padPackets;\nextern\tcvar_t\t*sv_killserver;\nextern\tcvar_t\t*sv_mapname;\nextern\tcvar_t\t*sv_mapChecksum;\nextern\tcvar_t\t*sv_serverid;\nextern\tcvar_t\t*sv_maxRate;\nextern\tcvar_t\t*sv_minPing;\nextern\tcvar_t\t*sv_maxPing;\nextern\tcvar_t\t*sv_gametype;\nextern\tcvar_t\t*sv_pure;\nextern\tcvar_t\t*sv_floodProtect;\nextern\tcvar_t\t*sv_lanForceRate;\nextern\tcvar_t\t*sv_strictAuth;\n\n//===========================================================\n\n//\n// sv_main.c\n//\nvoid SV_FinalMessage (char *message);\nvoid QDECL SV_SendServerCommand( client_t *cl, const char *fmt, ...);\n\n\nvoid SV_AddOperatorCommands (void);\nvoid SV_RemoveOperatorCommands (void);\n\n\nvoid SV_MasterHeartbeat (void);\nvoid SV_MasterShutdown (void);\n\n\n\n\n//\n// sv_init.c\n//\nvoid SV_SetConfigstring( int index, const char *val );\nvoid SV_GetConfigstring( int index, char *buffer, int bufferSize );\n\nvoid SV_SetUserinfo( int index, const char *val );\nvoid SV_GetUserinfo( int index, char *buffer, int bufferSize );\n\nvoid SV_ChangeMaxClients( void );\nvoid SV_SpawnServer( char *server, qboolean killBots );\n\n\n\n//\n// sv_client.c\n//\nvoid SV_GetChallenge( netadr_t from );\n\nvoid SV_DirectConnect( netadr_t from );\n\nvoid SV_AuthorizeIpPacket( netadr_t from );\n\nvoid SV_ExecuteClientMessage( client_t *cl, msg_t *msg );\nvoid SV_UserinfoChanged( client_t *cl );\n\nvoid SV_ClientEnterWorld( client_t *client, usercmd_t *cmd );\nvoid SV_DropClient( client_t *drop, const char *reason );\n\nvoid SV_ExecuteClientCommand( client_t *cl, const char *s, qboolean clientOK );\nvoid SV_ClientThink (client_t *cl, usercmd_t *cmd);\n\nvoid SV_WriteDownloadToClient( client_t *cl , msg_t *msg );\n\n//\n// sv_ccmds.c\n//\nvoid SV_Heartbeat_f( void );\n\n//\n// sv_snapshot.c\n//\nvoid SV_AddServerCommand( client_t *client, const char *cmd );\nvoid SV_UpdateServerCommandsToClient( client_t *client, msg_t *msg );\nvoid SV_WriteFrameToClient (client_t *client, msg_t *msg);\nvoid SV_SendMessageToClient( msg_t *msg, client_t *client );\nvoid SV_SendClientMessages( void );\nvoid SV_SendClientSnapshot( client_t *client );\n\n//\n// sv_game.c\n//\nint\tSV_NumForGentity( sharedEntity_t *ent );\nsharedEntity_t *SV_GentityNum( int num );\nplayerState_t *SV_GameClientNum( int num );\nsvEntity_t\t*SV_SvEntityForGentity( sharedEntity_t *gEnt );\nsharedEntity_t *SV_GEntityForSvEntity( svEntity_t *svEnt );\nvoid\t\tSV_InitGameProgs ( void );\nvoid\t\tSV_ShutdownGameProgs ( void );\nvoid\t\tSV_RestartGameProgs( void );\nqboolean\tSV_inPVS (const vec3_t p1, const vec3_t p2);\n\n//\n// sv_bot.c\n//\nvoid\t\tSV_BotFrame( int time );\nint\t\t\tSV_BotAllocateClient(void);\nvoid\t\tSV_BotFreeClient( int clientNum );\n\nvoid\t\tSV_BotInitCvars(void);\nint\t\t\tSV_BotLibSetup( void );\nint\t\t\tSV_BotLibShutdown( void );\nint\t\t\tSV_BotGetSnapshotEntity( int client, int ent );\nint\t\t\tSV_BotGetConsoleMessage( int client, char *buf, int size );\n\nint BotImport_DebugPolygonCreate(int color, int numPoints, vec3_t *points);\nvoid BotImport_DebugPolygonDelete(int id);\n\n//============================================================\n//\n// high level object sorting to reduce interaction tests\n//\n\nvoid SV_ClearWorld (void);\n// called after the world model has been loaded, before linking any entities\n\nvoid SV_UnlinkEntity( sharedEntity_t *ent );\n// call before removing an entity, and before trying to move one,\n// so it doesn't clip against itself\n\nvoid SV_LinkEntity( sharedEntity_t *ent );\n// Needs to be called any time an entity changes origin, mins, maxs,\n// or solid.  Automatically unlinks if needed.\n// sets ent->v.absmin and ent->v.absmax\n// sets ent->leafnums[] for pvs determination even if the entity\n// is not solid\n\n\nclipHandle_t SV_ClipHandleForEntity( const sharedEntity_t *ent );\n\n\nvoid SV_SectorList_f( void );\n\n\nint SV_AreaEntities( const vec3_t mins, const vec3_t maxs, int *entityList, int maxcount );\n// fills in a table of entity numbers with entities that have bounding boxes\n// that intersect the given area.  It is possible for a non-axial bmodel\n// to be returned that doesn't actually intersect the area on an exact\n// test.\n// returns the number of pointers filled in\n// The world entity is never returned in this list.\n\n\nint SV_PointContents( const vec3_t p, int passEntityNum );\n// returns the CONTENTS_* value from the world and all entities at the given point.\n\n\nvoid SV_Trace( trace_t *results, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask, int capsule );\n// mins and maxs are relative\n\n// if the entire move stays in a solid volume, trace.allsolid will be set,\n// trace.startsolid will be set, and trace.fraction will be 0\n\n// if the starting point is in a solid, it will be allowed to move out\n// to an open area\n\n// passEntityNum is explicitly excluded from clipping checks (normally ENTITYNUM_NONE)\n\n\nvoid SV_ClipToEntity( trace_t *trace, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int entityNum, int contentmask, int capsule );\n// clip to a specific entity\n\n//\n// sv_net_chan.c\n//\nvoid SV_Netchan_Transmit( client_t *client, msg_t *msg);\nvoid SV_Netchan_TransmitNextFragment( client_t *client );\nqboolean SV_Netchan_Process( client_t *client, msg_t *msg );\n\n"
  },
  {
    "path": "code/server/sv_bot.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// sv_bot.c\n\n#include \"server.h\"\n#include \"../game/botlib.h\"\n\ntypedef struct bot_debugpoly_s\n{\n\tint inuse;\n\tint color;\n\tint numPoints;\n\tvec3_t points[128];\n} bot_debugpoly_t;\n\nstatic bot_debugpoly_t *debugpolygons;\nint bot_maxdebugpolys;\n\nextern botlib_export_t\t*botlib_export;\nint\tbot_enable;\n\n\n/*\n==================\nSV_BotAllocateClient\n==================\n*/\nint SV_BotAllocateClient(void) {\n\tint\t\t\ti;\n\tclient_t\t*cl;\n\n\t// find a client slot\n\tfor ( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ ) {\n\t\tif ( cl->state == CS_FREE ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif ( i == sv_maxclients->integer ) {\n\t\treturn -1;\n\t}\n\n\tcl->gentity = SV_GentityNum( i );\n\tcl->gentity->s.number = i;\n\tcl->state = CS_ACTIVE;\n\tcl->lastPacketTime = svs.time;\n\tcl->netchan.remoteAddress.type = NA_BOT;\n\tcl->rate = 16384;\n\n\treturn i;\n}\n\n/*\n==================\nSV_BotFreeClient\n==================\n*/\nvoid SV_BotFreeClient( int clientNum ) {\n\tclient_t\t*cl;\n\n\tif ( clientNum < 0 || clientNum >= sv_maxclients->integer ) {\n\t\tCom_Error( ERR_DROP, \"SV_BotFreeClient: bad clientNum: %i\", clientNum );\n\t}\n\tcl = &svs.clients[clientNum];\n\tcl->state = CS_FREE;\n\tcl->name[0] = 0;\n\tif ( cl->gentity ) {\n\t\tcl->gentity->r.svFlags &= ~SVF_BOT;\n\t}\n}\n\n/*\n==================\nBotDrawDebugPolygons\n==================\n*/\nvoid BotDrawDebugPolygons(void (*drawPoly)(int color, int numPoints, float *points), int value) {\n\tstatic cvar_t *bot_debug, *bot_groundonly, *bot_reachability, *bot_highlightarea;\n\tbot_debugpoly_t *poly;\n\tint i, parm0;\n\n\tif (!debugpolygons)\n\t\treturn;\n\t//bot debugging\n\tif (!bot_debug) bot_debug = Cvar_Get(\"bot_debug\", \"0\", 0);\n\t//\n\tif (bot_enable && bot_debug->integer) {\n\t\t//show reachabilities\n\t\tif (!bot_reachability) bot_reachability = Cvar_Get(\"bot_reachability\", \"0\", 0);\n\t\t//show ground faces only\n\t\tif (!bot_groundonly) bot_groundonly = Cvar_Get(\"bot_groundonly\", \"1\", 0);\n\t\t//get the hightlight area\n\t\tif (!bot_highlightarea) bot_highlightarea = Cvar_Get(\"bot_highlightarea\", \"0\", 0);\n\t\t//\n\t\tparm0 = 0;\n\t\tif (svs.clients[0].lastUsercmd.buttons & BUTTON_ATTACK) parm0 |= 1;\n\t\tif (bot_reachability->integer) parm0 |= 2;\n\t\tif (bot_groundonly->integer) parm0 |= 4;\n\t\tbotlib_export->BotLibVarSet(\"bot_highlightarea\", bot_highlightarea->string);\n\t\tbotlib_export->Test(parm0, NULL, svs.clients[0].gentity->r.currentOrigin, \n\t\t\tsvs.clients[0].gentity->r.currentAngles);\n\t} //end if\n\t//draw all debug polys\n\tfor (i = 0; i < bot_maxdebugpolys; i++) {\n\t\tpoly = &debugpolygons[i];\n\t\tif (!poly->inuse) continue;\n\t\tdrawPoly(poly->color, poly->numPoints, (float *) poly->points);\n\t\t//Com_Printf(\"poly %i, numpoints = %d\\n\", i, poly->numPoints);\n\t}\n}\n\n/*\n==================\nBotImport_Print\n==================\n*/\nvoid QDECL BotImport_Print(int type, char *fmt, ...)\n{\n\tchar str[2048];\n\tva_list ap;\n\n\tva_start(ap, fmt);\n\tvsprintf(str, fmt, ap);\n\tva_end(ap);\n\n\tswitch(type) {\n\t\tcase PRT_MESSAGE: {\n\t\t\tCom_Printf(\"%s\", str);\n\t\t\tbreak;\n\t\t}\n\t\tcase PRT_WARNING: {\n\t\t\tCom_Printf(S_COLOR_YELLOW \"Warning: %s\", str);\n\t\t\tbreak;\n\t\t}\n\t\tcase PRT_ERROR: {\n\t\t\tCom_Printf(S_COLOR_RED \"Error: %s\", str);\n\t\t\tbreak;\n\t\t}\n\t\tcase PRT_FATAL: {\n\t\t\tCom_Printf(S_COLOR_RED \"Fatal: %s\", str);\n\t\t\tbreak;\n\t\t}\n\t\tcase PRT_EXIT: {\n\t\t\tCom_Error(ERR_DROP, S_COLOR_RED \"Exit: %s\", str);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tCom_Printf(\"unknown print type\\n\");\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/*\n==================\nBotImport_Trace\n==================\n*/\nvoid BotImport_Trace(bsp_trace_t *bsptrace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask) {\n\ttrace_t trace;\n\n\tSV_Trace(&trace, start, mins, maxs, end, passent, contentmask, qfalse);\n\t//copy the trace information\n\tbsptrace->allsolid = trace.allsolid;\n\tbsptrace->startsolid = trace.startsolid;\n\tbsptrace->fraction = trace.fraction;\n\tVectorCopy(trace.endpos, bsptrace->endpos);\n\tbsptrace->plane.dist = trace.plane.dist;\n\tVectorCopy(trace.plane.normal, bsptrace->plane.normal);\n\tbsptrace->plane.signbits = trace.plane.signbits;\n\tbsptrace->plane.type = trace.plane.type;\n\tbsptrace->surface.value = trace.surfaceFlags;\n\tbsptrace->ent = trace.entityNum;\n\tbsptrace->exp_dist = 0;\n\tbsptrace->sidenum = 0;\n\tbsptrace->contents = 0;\n}\n\n/*\n==================\nBotImport_EntityTrace\n==================\n*/\nvoid BotImport_EntityTrace(bsp_trace_t *bsptrace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int entnum, int contentmask) {\n\ttrace_t trace;\n\n\tSV_ClipToEntity(&trace, start, mins, maxs, end, entnum, contentmask, qfalse);\n\t//copy the trace information\n\tbsptrace->allsolid = trace.allsolid;\n\tbsptrace->startsolid = trace.startsolid;\n\tbsptrace->fraction = trace.fraction;\n\tVectorCopy(trace.endpos, bsptrace->endpos);\n\tbsptrace->plane.dist = trace.plane.dist;\n\tVectorCopy(trace.plane.normal, bsptrace->plane.normal);\n\tbsptrace->plane.signbits = trace.plane.signbits;\n\tbsptrace->plane.type = trace.plane.type;\n\tbsptrace->surface.value = trace.surfaceFlags;\n\tbsptrace->ent = trace.entityNum;\n\tbsptrace->exp_dist = 0;\n\tbsptrace->sidenum = 0;\n\tbsptrace->contents = 0;\n}\n\n\n/*\n==================\nBotImport_PointContents\n==================\n*/\nint BotImport_PointContents(vec3_t point) {\n\treturn SV_PointContents(point, -1);\n}\n\n/*\n==================\nBotImport_inPVS\n==================\n*/\nint BotImport_inPVS(vec3_t p1, vec3_t p2) {\n\treturn SV_inPVS (p1, p2);\n}\n\n/*\n==================\nBotImport_BSPEntityData\n==================\n*/\nchar *BotImport_BSPEntityData(void) {\n\treturn CM_EntityString();\n}\n\n/*\n==================\nBotImport_BSPModelMinsMaxsOrigin\n==================\n*/\nvoid BotImport_BSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t outmins, vec3_t outmaxs, vec3_t origin) {\n\tclipHandle_t h;\n\tvec3_t mins, maxs;\n\tfloat max;\n\tint\ti;\n\n\th = CM_InlineModel(modelnum);\n\tCM_ModelBounds(h, mins, maxs);\n\t//if the model is rotated\n\tif ((angles[0] || angles[1] || angles[2])) {\n\t\t// expand for rotation\n\n\t\tmax = RadiusFromBounds(mins, maxs);\n\t\tfor (i = 0; i < 3; i++) {\n\t\t\tmins[i] = -max;\n\t\t\tmaxs[i] = max;\n\t\t}\n\t}\n\tif (outmins) VectorCopy(mins, outmins);\n\tif (outmaxs) VectorCopy(maxs, outmaxs);\n\tif (origin) VectorClear(origin);\n}\n\n/*\n==================\nBotImport_GetMemory\n==================\n*/\nvoid *BotImport_GetMemory(int size) {\n\tvoid *ptr;\n\n\tptr = Z_TagMalloc( size, TAG_BOTLIB );\n\treturn ptr;\n}\n\n/*\n==================\nBotImport_FreeMemory\n==================\n*/\nvoid BotImport_FreeMemory(void *ptr) {\n\tZ_Free(ptr);\n}\n\n/*\n=================\nBotImport_HunkAlloc\n=================\n*/\nvoid *BotImport_HunkAlloc( int size ) {\n\tif( Hunk_CheckMark() ) {\n\t\tCom_Error( ERR_DROP, \"SV_Bot_HunkAlloc: Alloc with marks already set\\n\" );\n\t}\n\treturn Hunk_Alloc( size, h_high );\n}\n\n/*\n==================\nBotImport_DebugPolygonCreate\n==================\n*/\nint BotImport_DebugPolygonCreate(int color, int numPoints, vec3_t *points) {\n\tbot_debugpoly_t *poly;\n\tint i;\n\n\tif (!debugpolygons)\n\t\treturn 0;\n\n\tfor (i = 1; i < bot_maxdebugpolys; i++) \t{\n\t\tif (!debugpolygons[i].inuse)\n\t\t\tbreak;\n\t}\n\tif (i >= bot_maxdebugpolys)\n\t\treturn 0;\n\tpoly = &debugpolygons[i];\n\tpoly->inuse = qtrue;\n\tpoly->color = color;\n\tpoly->numPoints = numPoints;\n\tCom_Memcpy(poly->points, points, numPoints * sizeof(vec3_t));\n\t//\n\treturn i;\n}\n\n/*\n==================\nBotImport_DebugPolygonShow\n==================\n*/\nvoid BotImport_DebugPolygonShow(int id, int color, int numPoints, vec3_t *points) {\n\tbot_debugpoly_t *poly;\n\n\tif (!debugpolygons) return;\n\tpoly = &debugpolygons[id];\n\tpoly->inuse = qtrue;\n\tpoly->color = color;\n\tpoly->numPoints = numPoints;\n\tCom_Memcpy(poly->points, points, numPoints * sizeof(vec3_t));\n}\n\n/*\n==================\nBotImport_DebugPolygonDelete\n==================\n*/\nvoid BotImport_DebugPolygonDelete(int id)\n{\n\tif (!debugpolygons) return;\n\tdebugpolygons[id].inuse = qfalse;\n}\n\n/*\n==================\nBotImport_DebugLineCreate\n==================\n*/\nint BotImport_DebugLineCreate(void) {\n\tvec3_t points[1];\n\treturn BotImport_DebugPolygonCreate(0, 0, points);\n}\n\n/*\n==================\nBotImport_DebugLineDelete\n==================\n*/\nvoid BotImport_DebugLineDelete(int line) {\n\tBotImport_DebugPolygonDelete(line);\n}\n\n/*\n==================\nBotImport_DebugLineShow\n==================\n*/\nvoid BotImport_DebugLineShow(int line, vec3_t start, vec3_t end, int color) {\n\tvec3_t points[4], dir, cross, up = {0, 0, 1};\n\tfloat dot;\n\n\tVectorCopy(start, points[0]);\n\tVectorCopy(start, points[1]);\n\t//points[1][2] -= 2;\n\tVectorCopy(end, points[2]);\n\t//points[2][2] -= 2;\n\tVectorCopy(end, points[3]);\n\n\n\tVectorSubtract(end, start, dir);\n\tVectorNormalize(dir);\n\tdot = DotProduct(dir, up);\n\tif (dot > 0.99 || dot < -0.99) VectorSet(cross, 1, 0, 0);\n\telse CrossProduct(dir, up, cross);\n\n\tVectorNormalize(cross);\n\n\tVectorMA(points[0], 2, cross, points[0]);\n\tVectorMA(points[1], -2, cross, points[1]);\n\tVectorMA(points[2], -2, cross, points[2]);\n\tVectorMA(points[3], 2, cross, points[3]);\n\n\tBotImport_DebugPolygonShow(line, color, 4, points);\n}\n\n/*\n==================\nSV_BotClientCommand\n==================\n*/\nvoid BotClientCommand( int client, char *command ) {\n\tSV_ExecuteClientCommand( &svs.clients[client], command, qtrue );\n}\n\n/*\n==================\nSV_BotFrame\n==================\n*/\nvoid SV_BotFrame( int time ) {\n\tif (!bot_enable) return;\n\t//NOTE: maybe the game is already shutdown\n\tif (!gvm) return;\n\tVM_Call( gvm, BOTAI_START_FRAME, time );\n}\n\n/*\n===============\nSV_BotLibSetup\n===============\n*/\nint SV_BotLibSetup( void ) {\n\tif (!bot_enable) {\n\t\treturn 0;\n\t}\n\n\tif ( !botlib_export ) {\n\t\tCom_Printf( S_COLOR_RED \"Error: SV_BotLibSetup without SV_BotInitBotLib\\n\" );\n\t\treturn -1;\n\t}\n\n\treturn botlib_export->BotLibSetup();\n}\n\n/*\n===============\nSV_ShutdownBotLib\n\nCalled when either the entire server is being killed, or\nit is changing to a different game directory.\n===============\n*/\nint SV_BotLibShutdown( void ) {\n\n\tif ( !botlib_export ) {\n\t\treturn -1;\n\t}\n\n\treturn botlib_export->BotLibShutdown();\n}\n\n/*\n==================\nSV_BotInitCvars\n==================\n*/\nvoid SV_BotInitCvars(void) {\n\n\tCvar_Get(\"bot_enable\", \"1\", 0);\t\t\t\t\t\t//enable the bot\n\tCvar_Get(\"bot_developer\", \"0\", CVAR_CHEAT);\t\t\t//bot developer mode\n\tCvar_Get(\"bot_debug\", \"0\", CVAR_CHEAT);\t\t\t\t//enable bot debugging\n\tCvar_Get(\"bot_maxdebugpolys\", \"2\", 0);\t\t\t\t//maximum number of debug polys\n\tCvar_Get(\"bot_groundonly\", \"1\", 0);\t\t\t\t\t//only show ground faces of areas\n\tCvar_Get(\"bot_reachability\", \"0\", 0);\t\t\t\t//show all reachabilities to other areas\n\tCvar_Get(\"bot_visualizejumppads\", \"0\", CVAR_CHEAT);\t//show jumppads\n\tCvar_Get(\"bot_forceclustering\", \"0\", 0);\t\t\t//force cluster calculations\n\tCvar_Get(\"bot_forcereachability\", \"0\", 0);\t\t\t//force reachability calculations\n\tCvar_Get(\"bot_forcewrite\", \"0\", 0);\t\t\t\t\t//force writing aas file\n\tCvar_Get(\"bot_aasoptimize\", \"0\", 0);\t\t\t\t//no aas file optimisation\n\tCvar_Get(\"bot_saveroutingcache\", \"0\", 0);\t\t\t//save routing cache\n\tCvar_Get(\"bot_thinktime\", \"100\", CVAR_CHEAT);\t\t//msec the bots thinks\n\tCvar_Get(\"bot_reloadcharacters\", \"0\", 0);\t\t\t//reload the bot characters each time\n\tCvar_Get(\"bot_testichat\", \"0\", 0);\t\t\t\t\t//test ichats\n\tCvar_Get(\"bot_testrchat\", \"0\", 0);\t\t\t\t\t//test rchats\n\tCvar_Get(\"bot_testsolid\", \"0\", CVAR_CHEAT);\t\t\t//test for solid areas\n\tCvar_Get(\"bot_testclusters\", \"0\", CVAR_CHEAT);\t\t//test the AAS clusters\n\tCvar_Get(\"bot_fastchat\", \"0\", 0);\t\t\t\t\t//fast chatting bots\n\tCvar_Get(\"bot_nochat\", \"0\", 0);\t\t\t\t\t\t//disable chats\n\tCvar_Get(\"bot_pause\", \"0\", CVAR_CHEAT);\t\t\t\t//pause the bots thinking\n\tCvar_Get(\"bot_report\", \"0\", CVAR_CHEAT);\t\t\t//get a full report in ctf\n\tCvar_Get(\"bot_grapple\", \"0\", 0);\t\t\t\t\t//enable grapple\n\tCvar_Get(\"bot_rocketjump\", \"1\", 0);\t\t\t\t\t//enable rocket jumping\n\tCvar_Get(\"bot_challenge\", \"0\", 0);\t\t\t\t\t//challenging bot\n\tCvar_Get(\"bot_minplayers\", \"0\", 0);\t\t\t\t\t//minimum players in a team or the game\n\tCvar_Get(\"bot_interbreedchar\", \"\", CVAR_CHEAT);\t\t//bot character used for interbreeding\n\tCvar_Get(\"bot_interbreedbots\", \"10\", CVAR_CHEAT);\t//number of bots used for interbreeding\n\tCvar_Get(\"bot_interbreedcycle\", \"20\", CVAR_CHEAT);\t//bot interbreeding cycle\n\tCvar_Get(\"bot_interbreedwrite\", \"\", CVAR_CHEAT);\t//write interbreeded bots to this file\n}\n\n/*\n==================\nSV_BotInitBotLib\n==================\n*/\nvoid SV_BotInitBotLib(void) {\n\tbotlib_import_t\tbotlib_import;\n\n\tif ( !Cvar_VariableValue(\"fs_restrict\") && !Sys_CheckCD() ) {\n\t\tCom_Error( ERR_NEED_CD, \"Game CD not in drive\" );\n\t}\n\n\tif (debugpolygons) Z_Free(debugpolygons);\n\tbot_maxdebugpolys = Cvar_VariableIntegerValue(\"bot_maxdebugpolys\");\n\tdebugpolygons = Z_Malloc(sizeof(bot_debugpoly_t) * bot_maxdebugpolys);\n\n\tbotlib_import.Print = BotImport_Print;\n\tbotlib_import.Trace = BotImport_Trace;\n\tbotlib_import.EntityTrace = BotImport_EntityTrace;\n\tbotlib_import.PointContents = BotImport_PointContents;\n\tbotlib_import.inPVS = BotImport_inPVS;\n\tbotlib_import.BSPEntityData = BotImport_BSPEntityData;\n\tbotlib_import.BSPModelMinsMaxsOrigin = BotImport_BSPModelMinsMaxsOrigin;\n\tbotlib_import.BotClientCommand = BotClientCommand;\n\n\t//memory management\n\tbotlib_import.GetMemory = BotImport_GetMemory;\n\tbotlib_import.FreeMemory = BotImport_FreeMemory;\n\tbotlib_import.AvailableMemory = Z_AvailableMemory;\n\tbotlib_import.HunkAlloc = BotImport_HunkAlloc;\n\n\t// file system access\n\tbotlib_import.FS_FOpenFile = FS_FOpenFileByMode;\n\tbotlib_import.FS_Read = FS_Read2;\n\tbotlib_import.FS_Write = FS_Write;\n\tbotlib_import.FS_FCloseFile = FS_FCloseFile;\n\tbotlib_import.FS_Seek = FS_Seek;\n\n\t//debug lines\n\tbotlib_import.DebugLineCreate = BotImport_DebugLineCreate;\n\tbotlib_import.DebugLineDelete = BotImport_DebugLineDelete;\n\tbotlib_import.DebugLineShow = BotImport_DebugLineShow;\n\n\t//debug polygons\n\tbotlib_import.DebugPolygonCreate = BotImport_DebugPolygonCreate;\n\tbotlib_import.DebugPolygonDelete = BotImport_DebugPolygonDelete;\n\n\tbotlib_export = (botlib_export_t *)GetBotLibAPI( BOTLIB_API_VERSION, &botlib_import );\n\tassert(botlib_export); \t// bk001129 - somehow we end up with a zero import.\n}\n\n\n//\n//  * * * BOT AI CODE IS BELOW THIS POINT * * *\n//\n\n/*\n==================\nSV_BotGetConsoleMessage\n==================\n*/\nint SV_BotGetConsoleMessage( int client, char *buf, int size )\n{\n\tclient_t\t*cl;\n\tint\t\t\tindex;\n\n\tcl = &svs.clients[client];\n\tcl->lastPacketTime = svs.time;\n\n\tif ( cl->reliableAcknowledge == cl->reliableSequence ) {\n\t\treturn qfalse;\n\t}\n\n\tcl->reliableAcknowledge++;\n\tindex = cl->reliableAcknowledge & ( MAX_RELIABLE_COMMANDS - 1 );\n\n\tif ( !cl->reliableCommands[index][0] ) {\n\t\treturn qfalse;\n\t}\n\n\tQ_strncpyz( buf, cl->reliableCommands[index], size );\n\treturn qtrue;\n}\n\n#if 0\n/*\n==================\nEntityInPVS\n==================\n*/\nint EntityInPVS( int client, int entityNum ) {\n\tclient_t\t\t\t*cl;\n\tclientSnapshot_t\t*frame;\n\tint\t\t\t\t\ti;\n\n\tcl = &svs.clients[client];\n\tframe = &cl->frames[cl->netchan.outgoingSequence & PACKET_MASK];\n\tfor ( i = 0; i < frame->num_entities; i++ )\t{\n\t\tif ( svs.snapshotEntities[(frame->first_entity + i) % svs.numSnapshotEntities].number == entityNum ) {\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\treturn qfalse;\n}\n#endif\n\n/*\n==================\nSV_BotGetSnapshotEntity\n==================\n*/\nint SV_BotGetSnapshotEntity( int client, int sequence ) {\n\tclient_t\t\t\t*cl;\n\tclientSnapshot_t\t*frame;\n\n\tcl = &svs.clients[client];\n\tframe = &cl->frames[cl->netchan.outgoingSequence & PACKET_MASK];\n\tif (sequence < 0 || sequence >= frame->num_entities) {\n\t\treturn -1;\n\t}\n\treturn svs.snapshotEntities[(frame->first_entity + sequence) % svs.numSnapshotEntities].number;\n}\n\n"
  },
  {
    "path": "code/server/sv_ccmds.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"server.h\"\n\n/*\n===============================================================================\n\nOPERATOR CONSOLE ONLY COMMANDS\n\nThese commands can only be entered from stdin or by a remote operator datagram\n===============================================================================\n*/\n\n\n/*\n==================\nSV_GetPlayerByName\n\nReturns the player with name from Cmd_Argv(1)\n==================\n*/\nstatic client_t *SV_GetPlayerByName( void ) {\n\tclient_t\t*cl;\n\tint\t\t\ti;\n\tchar\t\t*s;\n\tchar\t\tcleanName[64];\n\n\t// make sure server is running\n\tif ( !com_sv_running->integer ) {\n\t\treturn NULL;\n\t}\n\n\tif ( Cmd_Argc() < 2 ) {\n\t\tCom_Printf( \"No player specified.\\n\" );\n\t\treturn NULL;\n\t}\n\n\ts = Cmd_Argv(1);\n\n\t// check for a name match\n\tfor ( i=0, cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++ ) {\n\t\tif ( !cl->state ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( !Q_stricmp( cl->name, s ) ) {\n\t\t\treturn cl;\n\t\t}\n\n\t\tQ_strncpyz( cleanName, cl->name, sizeof(cleanName) );\n\t\tQ_CleanStr( cleanName );\n\t\tif ( !Q_stricmp( cleanName, s ) ) {\n\t\t\treturn cl;\n\t\t}\n\t}\n\n\tCom_Printf( \"Player %s is not on the server\\n\", s );\n\n\treturn NULL;\n}\n\n/*\n==================\nSV_GetPlayerByNum\n\nReturns the player with idnum from Cmd_Argv(1)\n==================\n*/\nstatic client_t *SV_GetPlayerByNum( void ) {\n\tclient_t\t*cl;\n\tint\t\t\ti;\n\tint\t\t\tidnum;\n\tchar\t\t*s;\n\n\t// make sure server is running\n\tif ( !com_sv_running->integer ) {\n\t\treturn NULL;\n\t}\n\n\tif ( Cmd_Argc() < 2 ) {\n\t\tCom_Printf( \"No player specified.\\n\" );\n\t\treturn NULL;\n\t}\n\n\ts = Cmd_Argv(1);\n\n\tfor (i = 0; s[i]; i++) {\n\t\tif (s[i] < '0' || s[i] > '9') {\n\t\t\tCom_Printf( \"Bad slot number: %s\\n\", s);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\tidnum = atoi( s );\n\tif ( idnum < 0 || idnum >= sv_maxclients->integer ) {\n\t\tCom_Printf( \"Bad client slot: %i\\n\", idnum );\n\t\treturn NULL;\n\t}\n\n\tcl = &svs.clients[idnum];\n\tif ( !cl->state ) {\n\t\tCom_Printf( \"Client %i is not active\\n\", idnum );\n\t\treturn NULL;\n\t}\n\treturn cl;\n\n\treturn NULL;\n}\n\n//=========================================================\n\n\n/*\n==================\nSV_Map_f\n\nRestart the server on a different map\n==================\n*/\nstatic void SV_Map_f( void ) {\n\tchar\t\t*cmd;\n\tchar\t\t*map;\n\tqboolean\tkillBots, cheat;\n\tchar\t\texpanded[MAX_QPATH];\n\tchar\t\tmapname[MAX_QPATH];\n\n\tmap = Cmd_Argv(1);\n\tif ( !map ) {\n\t\treturn;\n\t}\n\n\t// make sure the level exists before trying to change, so that\n\t// a typo at the server console won't end the game\n\tCom_sprintf (expanded, sizeof(expanded), \"maps/%s.bsp\", map);\n\tif ( FS_ReadFile (expanded, NULL) == -1 ) {\n\t\tCom_Printf (\"Can't find map %s\\n\", expanded);\n\t\treturn;\n\t}\n\n\t// force latched values to get set\n\tCvar_Get (\"g_gametype\", \"0\", CVAR_SERVERINFO | CVAR_USERINFO | CVAR_LATCH );\n\n\tcmd = Cmd_Argv(0);\n\tif( Q_stricmpn( cmd, \"sp\", 2 ) == 0 ) {\n\t\tCvar_SetValue( \"g_gametype\", GT_SINGLE_PLAYER );\n\t\tCvar_SetValue( \"g_doWarmup\", 0 );\n\t\t// may not set sv_maxclients directly, always set latched\n\t\tCvar_SetLatched( \"sv_maxclients\", \"8\" );\n\t\tcmd += 2;\n\t\tcheat = qfalse;\n\t\tkillBots = qtrue;\n\t}\n\telse {\n\t\tif ( !Q_stricmp( cmd, \"devmap\" ) || !Q_stricmp( cmd, \"spdevmap\" ) ) {\n\t\t\tcheat = qtrue;\n\t\t\tkillBots = qtrue;\n\t\t} else {\n\t\t\tcheat = qfalse;\n\t\t\tkillBots = qfalse;\n\t\t}\n\t\tif( sv_gametype->integer == GT_SINGLE_PLAYER ) {\n\t\t\tCvar_SetValue( \"g_gametype\", GT_FFA );\n\t\t}\n\t}\n\n\t// save the map name here cause on a map restart we reload the q3config.cfg\n\t// and thus nuke the arguments of the map command\n\tQ_strncpyz(mapname, map, sizeof(mapname));\n\n\t// start up the map\n\tSV_SpawnServer( mapname, killBots );\n\n\t// set the cheat value\n\t// if the level was started with \"map <levelname>\", then\n\t// cheats will not be allowed.  If started with \"devmap <levelname>\"\n\t// then cheats will be allowed\n\tif ( cheat ) {\n\t\tCvar_Set( \"sv_cheats\", \"1\" );\n\t} else {\n\t\tCvar_Set( \"sv_cheats\", \"0\" );\n\t}\n}\n\n/*\n================\nSV_MapRestart_f\n\nCompletely restarts a level, but doesn't send a new gamestate to the clients.\nThis allows fair starts with variable load times.\n================\n*/\nstatic void SV_MapRestart_f( void ) {\n\tint\t\t\ti;\n\tclient_t\t*client;\n\tchar\t\t*denied;\n\tqboolean\tisBot;\n\tint\t\t\tdelay;\n\n\t// make sure we aren't restarting twice in the same frame\n\tif ( com_frameTime == sv.serverId ) {\n\t\treturn;\n\t}\n\n\t// make sure server is running\n\tif ( !com_sv_running->integer ) {\n\t\tCom_Printf( \"Server is not running.\\n\" );\n\t\treturn;\n\t}\n\n\tif ( sv.restartTime ) {\n\t\treturn;\n\t}\n\n\tif (Cmd_Argc() > 1 ) {\n\t\tdelay = atoi( Cmd_Argv(1) );\n\t}\n\telse {\n\t\tdelay = 5;\n\t}\n\tif( delay && !Cvar_VariableValue(\"g_doWarmup\") ) {\n\t\tsv.restartTime = svs.time + delay * 1000;\n\t\tSV_SetConfigstring( CS_WARMUP, va(\"%i\", sv.restartTime) );\n\t\treturn;\n\t}\n\n\t// check for changes in variables that can't just be restarted\n\t// check for maxclients change\n\tif ( sv_maxclients->modified || sv_gametype->modified ) {\n\t\tchar\tmapname[MAX_QPATH];\n\n\t\tCom_Printf( \"variable change -- restarting.\\n\" );\n\t\t// restart the map the slow way\n\t\tQ_strncpyz( mapname, Cvar_VariableString( \"mapname\" ), sizeof( mapname ) );\n\n\t\tSV_SpawnServer( mapname, qfalse );\n\t\treturn;\n\t}\n\n\t// toggle the server bit so clients can detect that a\n\t// map_restart has happened\n\tsvs.snapFlagServerBit ^= SNAPFLAG_SERVERCOUNT;\n\n\t// generate a new serverid\t\n\t// TTimo - don't update restartedserverId there, otherwise we won't deal correctly with multiple map_restart\n\tsv.serverId = com_frameTime;\n\tCvar_Set( \"sv_serverid\", va(\"%i\", sv.serverId ) );\n\n\t// reset all the vm data in place without changing memory allocation\n\t// note that we do NOT set sv.state = SS_LOADING, so configstrings that\n\t// had been changed from their default values will generate broadcast updates\n\tsv.state = SS_LOADING;\n\tsv.restarting = qtrue;\n\n\tSV_RestartGameProgs();\n\n\t// run a few frames to allow everything to settle\n\tfor ( i = 0 ;i < 3 ; i++ ) {\n\t\tVM_Call( gvm, GAME_RUN_FRAME, svs.time );\n\t\tsvs.time += 100;\n\t}\n\n\tsv.state = SS_GAME;\n\tsv.restarting = qfalse;\n\n\t// connect and begin all the clients\n\tfor (i=0 ; i<sv_maxclients->integer ; i++) {\n\t\tclient = &svs.clients[i];\n\n\t\t// send the new gamestate to all connected clients\n\t\tif ( client->state < CS_CONNECTED) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( client->netchan.remoteAddress.type == NA_BOT ) {\n\t\t\tisBot = qtrue;\n\t\t} else {\n\t\t\tisBot = qfalse;\n\t\t}\n\n\t\t// add the map_restart command\n\t\tSV_AddServerCommand( client, \"map_restart\\n\" );\n\n\t\t// connect the client again, without the firstTime flag\n\t\tdenied = VM_ExplicitArgPtr( gvm, VM_Call( gvm, GAME_CLIENT_CONNECT, i, qfalse, isBot ) );\n\t\tif ( denied ) {\n\t\t\t// this generally shouldn't happen, because the client\n\t\t\t// was connected before the level change\n\t\t\tSV_DropClient( client, denied );\n\t\t\tCom_Printf( \"SV_MapRestart_f(%d): dropped client %i - denied!\\n\", delay, i ); // bk010125\n\t\t\tcontinue;\n\t\t}\n\n\t\tclient->state = CS_ACTIVE;\n\n\t\tSV_ClientEnterWorld( client, &client->lastUsercmd );\n\t}\t\n\n\t// run another frame to allow things to look at all the players\n\tVM_Call( gvm, GAME_RUN_FRAME, svs.time );\n\tsvs.time += 100;\n}\n\n//===============================================================\n\n/*\n==================\nSV_Kick_f\n\nKick a user off of the server  FIXME: move to game\n==================\n*/\nstatic void SV_Kick_f( void ) {\n\tclient_t\t*cl;\n\tint\t\t\ti;\n\n\t// make sure server is running\n\tif ( !com_sv_running->integer ) {\n\t\tCom_Printf( \"Server is not running.\\n\" );\n\t\treturn;\n\t}\n\n\tif ( Cmd_Argc() != 2 ) {\n\t\tCom_Printf (\"Usage: kick <player name>\\nkick all = kick everyone\\nkick allbots = kick all bots\\n\");\n\t\treturn;\n\t}\n\n\tcl = SV_GetPlayerByName();\n\tif ( !cl ) {\n\t\tif ( !Q_stricmp(Cmd_Argv(1), \"all\") ) {\n\t\t\tfor ( i=0, cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++ ) {\n\t\t\t\tif ( !cl->state ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif( cl->netchan.remoteAddress.type == NA_LOOPBACK ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tSV_DropClient( cl, \"was kicked\" );\n\t\t\t\tcl->lastPacketTime = svs.time;\t// in case there is a funny zombie\n\t\t\t}\n\t\t}\n\t\telse if ( !Q_stricmp(Cmd_Argv(1), \"allbots\") ) {\n\t\t\tfor ( i=0, cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++ ) {\n\t\t\t\tif ( !cl->state ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif( cl->netchan.remoteAddress.type != NA_BOT ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tSV_DropClient( cl, \"was kicked\" );\n\t\t\t\tcl->lastPacketTime = svs.time;\t// in case there is a funny zombie\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\tif( cl->netchan.remoteAddress.type == NA_LOOPBACK ) {\n\t\tSV_SendServerCommand(NULL, \"print \\\"%s\\\"\", \"Cannot kick host player\\n\");\n\t\treturn;\n\t}\n\n\tSV_DropClient( cl, \"was kicked\" );\n\tcl->lastPacketTime = svs.time;\t// in case there is a funny zombie\n}\n\n/*\n==================\nSV_Ban_f\n\nBan a user from being able to play on this server through the auth\nserver\n==================\n*/\nstatic void SV_Ban_f( void ) {\n\tclient_t\t*cl;\n\n\t// make sure server is running\n\tif ( !com_sv_running->integer ) {\n\t\tCom_Printf( \"Server is not running.\\n\" );\n\t\treturn;\n\t}\n\n\tif ( Cmd_Argc() != 2 ) {\n\t\tCom_Printf (\"Usage: banUser <player name>\\n\");\n\t\treturn;\n\t}\n\n\tcl = SV_GetPlayerByName();\n\n\tif (!cl) {\n\t\treturn;\n\t}\n\n\tif( cl->netchan.remoteAddress.type == NA_LOOPBACK ) {\n\t\tSV_SendServerCommand(NULL, \"print \\\"%s\\\"\", \"Cannot kick host player\\n\");\n\t\treturn;\n\t}\n\n\t// look up the authorize server's IP\n\tif ( !svs.authorizeAddress.ip[0] && svs.authorizeAddress.type != NA_BAD ) {\n\t\tCom_Printf( \"Resolving %s\\n\", AUTHORIZE_SERVER_NAME );\n\t\tif ( !NET_StringToAdr( AUTHORIZE_SERVER_NAME, &svs.authorizeAddress ) ) {\n\t\t\tCom_Printf( \"Couldn't resolve address\\n\" );\n\t\t\treturn;\n\t\t}\n\t\tsvs.authorizeAddress.port = BigShort( PORT_AUTHORIZE );\n\t\tCom_Printf( \"%s resolved to %i.%i.%i.%i:%i\\n\", AUTHORIZE_SERVER_NAME,\n\t\t\tsvs.authorizeAddress.ip[0], svs.authorizeAddress.ip[1],\n\t\t\tsvs.authorizeAddress.ip[2], svs.authorizeAddress.ip[3],\n\t\t\tBigShort( svs.authorizeAddress.port ) );\n\t}\n\n\t// otherwise send their ip to the authorize server\n\tif ( svs.authorizeAddress.type != NA_BAD ) {\n\t\tNET_OutOfBandPrint( NS_SERVER, svs.authorizeAddress,\n\t\t\t\"banUser %i.%i.%i.%i\", cl->netchan.remoteAddress.ip[0], cl->netchan.remoteAddress.ip[1], \n\t\t\t\t\t\t\t\t   cl->netchan.remoteAddress.ip[2], cl->netchan.remoteAddress.ip[3] );\n\t\tCom_Printf(\"%s was banned from coming back\\n\", cl->name);\n\t}\n}\n\n/*\n==================\nSV_BanNum_f\n\nBan a user from being able to play on this server through the auth\nserver\n==================\n*/\nstatic void SV_BanNum_f( void ) {\n\tclient_t\t*cl;\n\n\t// make sure server is running\n\tif ( !com_sv_running->integer ) {\n\t\tCom_Printf( \"Server is not running.\\n\" );\n\t\treturn;\n\t}\n\n\tif ( Cmd_Argc() != 2 ) {\n\t\tCom_Printf (\"Usage: banClient <client number>\\n\");\n\t\treturn;\n\t}\n\n\tcl = SV_GetPlayerByNum();\n\tif ( !cl ) {\n\t\treturn;\n\t}\n\tif( cl->netchan.remoteAddress.type == NA_LOOPBACK ) {\n\t\tSV_SendServerCommand(NULL, \"print \\\"%s\\\"\", \"Cannot kick host player\\n\");\n\t\treturn;\n\t}\n\n\t// look up the authorize server's IP\n\tif ( !svs.authorizeAddress.ip[0] && svs.authorizeAddress.type != NA_BAD ) {\n\t\tCom_Printf( \"Resolving %s\\n\", AUTHORIZE_SERVER_NAME );\n\t\tif ( !NET_StringToAdr( AUTHORIZE_SERVER_NAME, &svs.authorizeAddress ) ) {\n\t\t\tCom_Printf( \"Couldn't resolve address\\n\" );\n\t\t\treturn;\n\t\t}\n\t\tsvs.authorizeAddress.port = BigShort( PORT_AUTHORIZE );\n\t\tCom_Printf( \"%s resolved to %i.%i.%i.%i:%i\\n\", AUTHORIZE_SERVER_NAME,\n\t\t\tsvs.authorizeAddress.ip[0], svs.authorizeAddress.ip[1],\n\t\t\tsvs.authorizeAddress.ip[2], svs.authorizeAddress.ip[3],\n\t\t\tBigShort( svs.authorizeAddress.port ) );\n\t}\n\n\t// otherwise send their ip to the authorize server\n\tif ( svs.authorizeAddress.type != NA_BAD ) {\n\t\tNET_OutOfBandPrint( NS_SERVER, svs.authorizeAddress,\n\t\t\t\"banUser %i.%i.%i.%i\", cl->netchan.remoteAddress.ip[0], cl->netchan.remoteAddress.ip[1], \n\t\t\t\t\t\t\t\t   cl->netchan.remoteAddress.ip[2], cl->netchan.remoteAddress.ip[3] );\n\t\tCom_Printf(\"%s was banned from coming back\\n\", cl->name);\n\t}\n}\n\n/*\n==================\nSV_KickNum_f\n\nKick a user off of the server  FIXME: move to game\n==================\n*/\nstatic void SV_KickNum_f( void ) {\n\tclient_t\t*cl;\n\n\t// make sure server is running\n\tif ( !com_sv_running->integer ) {\n\t\tCom_Printf( \"Server is not running.\\n\" );\n\t\treturn;\n\t}\n\n\tif ( Cmd_Argc() != 2 ) {\n\t\tCom_Printf (\"Usage: kicknum <client number>\\n\");\n\t\treturn;\n\t}\n\n\tcl = SV_GetPlayerByNum();\n\tif ( !cl ) {\n\t\treturn;\n\t}\n\tif( cl->netchan.remoteAddress.type == NA_LOOPBACK ) {\n\t\tSV_SendServerCommand(NULL, \"print \\\"%s\\\"\", \"Cannot kick host player\\n\");\n\t\treturn;\n\t}\n\n\tSV_DropClient( cl, \"was kicked\" );\n\tcl->lastPacketTime = svs.time;\t// in case there is a funny zombie\n}\n\n/*\n================\nSV_Status_f\n================\n*/\nstatic void SV_Status_f( void ) {\n\tint\t\t\ti, j, l;\n\tclient_t\t*cl;\n\tplayerState_t\t*ps;\n\tconst char\t\t*s;\n\tint\t\t\tping;\n\n\t// make sure server is running\n\tif ( !com_sv_running->integer ) {\n\t\tCom_Printf( \"Server is not running.\\n\" );\n\t\treturn;\n\t}\n\n\tCom_Printf (\"map: %s\\n\", sv_mapname->string );\n\n\tCom_Printf (\"num score ping name            lastmsg address               qport rate\\n\");\n\tCom_Printf (\"--- ----- ---- --------------- ------- --------------------- ----- -----\\n\");\n\tfor (i=0,cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++)\n\t{\n\t\tif (!cl->state)\n\t\t\tcontinue;\n\t\tCom_Printf (\"%3i \", i);\n\t\tps = SV_GameClientNum( i );\n\t\tCom_Printf (\"%5i \", ps->persistant[PERS_SCORE]);\n\n\t\tif (cl->state == CS_CONNECTED)\n\t\t\tCom_Printf (\"CNCT \");\n\t\telse if (cl->state == CS_ZOMBIE)\n\t\t\tCom_Printf (\"ZMBI \");\n\t\telse\n\t\t{\n\t\t\tping = cl->ping < 9999 ? cl->ping : 9999;\n\t\t\tCom_Printf (\"%4i \", ping);\n\t\t}\n\n\t\tCom_Printf (\"%s\", cl->name);\n    // TTimo adding a ^7 to reset the color\n    // NOTE: colored names in status breaks the padding (WONTFIX)\n    Com_Printf (\"^7\");\n\t\tl = 16 - strlen(cl->name);\n\t\tfor (j=0 ; j<l ; j++)\n\t\t\tCom_Printf (\" \");\n\n\t\tCom_Printf (\"%7i \", svs.time - cl->lastPacketTime );\n\n\t\ts = NET_AdrToString( cl->netchan.remoteAddress );\n\t\tCom_Printf (\"%s\", s);\n\t\tl = 22 - strlen(s);\n\t\tfor (j=0 ; j<l ; j++)\n\t\t\tCom_Printf (\" \");\n\t\t\n\t\tCom_Printf (\"%5i\", cl->netchan.qport);\n\n\t\tCom_Printf (\" %5i\", cl->rate);\n\n\t\tCom_Printf (\"\\n\");\n\t}\n\tCom_Printf (\"\\n\");\n}\n\n/*\n==================\nSV_ConSay_f\n==================\n*/\nstatic void SV_ConSay_f(void) {\n\tchar\t*p;\n\tchar\ttext[1024];\n\n\t// make sure server is running\n\tif ( !com_sv_running->integer ) {\n\t\tCom_Printf( \"Server is not running.\\n\" );\n\t\treturn;\n\t}\n\n\tif ( Cmd_Argc () < 2 ) {\n\t\treturn;\n\t}\n\n\tstrcpy (text, \"console: \");\n\tp = Cmd_Args();\n\n\tif ( *p == '\"' ) {\n\t\tp++;\n\t\tp[strlen(p)-1] = 0;\n\t}\n\n\tstrcat(text, p);\n\n\tSV_SendServerCommand(NULL, \"chat \\\"%s\\n\\\"\", text);\n}\n\n\n/*\n==================\nSV_Heartbeat_f\n\nAlso called by SV_DropClient, SV_DirectConnect, and SV_SpawnServer\n==================\n*/\nvoid SV_Heartbeat_f( void ) {\n\tsvs.nextHeartbeatTime = -9999999;\n}\n\n\n/*\n===========\nSV_Serverinfo_f\n\nExamine the serverinfo string\n===========\n*/\nstatic void SV_Serverinfo_f( void ) {\n\tCom_Printf (\"Server info settings:\\n\");\n\tInfo_Print ( Cvar_InfoString( CVAR_SERVERINFO ) );\n}\n\n\n/*\n===========\nSV_Systeminfo_f\n\nExamine or change the serverinfo string\n===========\n*/\nstatic void SV_Systeminfo_f( void ) {\n\tCom_Printf (\"System info settings:\\n\");\n\tInfo_Print ( Cvar_InfoString( CVAR_SYSTEMINFO ) );\n}\n\n\n/*\n===========\nSV_DumpUser_f\n\nExamine all a users info strings FIXME: move to game\n===========\n*/\nstatic void SV_DumpUser_f( void ) {\n\tclient_t\t*cl;\n\n\t// make sure server is running\n\tif ( !com_sv_running->integer ) {\n\t\tCom_Printf( \"Server is not running.\\n\" );\n\t\treturn;\n\t}\n\n\tif ( Cmd_Argc() != 2 ) {\n\t\tCom_Printf (\"Usage: info <userid>\\n\");\n\t\treturn;\n\t}\n\n\tcl = SV_GetPlayerByName();\n\tif ( !cl ) {\n\t\treturn;\n\t}\n\n\tCom_Printf( \"userinfo\\n\" );\n\tCom_Printf( \"--------\\n\" );\n\tInfo_Print( cl->userinfo );\n}\n\n\n/*\n=================\nSV_KillServer\n=================\n*/\nstatic void SV_KillServer_f( void ) {\n\tSV_Shutdown( \"killserver\" );\n}\n\n//===========================================================\n\n/*\n==================\nSV_AddOperatorCommands\n==================\n*/\nvoid SV_AddOperatorCommands( void ) {\n\tstatic qboolean\tinitialized;\n\n\tif ( initialized ) {\n\t\treturn;\n\t}\n\tinitialized = qtrue;\n\n\tCmd_AddCommand (\"heartbeat\", SV_Heartbeat_f);\n\tCmd_AddCommand (\"kick\", SV_Kick_f);\n\tCmd_AddCommand (\"banUser\", SV_Ban_f);\n\tCmd_AddCommand (\"banClient\", SV_BanNum_f);\n\tCmd_AddCommand (\"clientkick\", SV_KickNum_f);\n\tCmd_AddCommand (\"status\", SV_Status_f);\n\tCmd_AddCommand (\"serverinfo\", SV_Serverinfo_f);\n\tCmd_AddCommand (\"systeminfo\", SV_Systeminfo_f);\n\tCmd_AddCommand (\"dumpuser\", SV_DumpUser_f);\n\tCmd_AddCommand (\"map_restart\", SV_MapRestart_f);\n\tCmd_AddCommand (\"sectorlist\", SV_SectorList_f);\n\tCmd_AddCommand (\"map\", SV_Map_f);\n#ifndef PRE_RELEASE_DEMO\n\tCmd_AddCommand (\"devmap\", SV_Map_f);\n\tCmd_AddCommand (\"spmap\", SV_Map_f);\n\tCmd_AddCommand (\"spdevmap\", SV_Map_f);\n#endif\n\tCmd_AddCommand (\"killserver\", SV_KillServer_f);\n\tif( com_dedicated->integer ) {\n\t\tCmd_AddCommand (\"say\", SV_ConSay_f);\n\t}\n}\n\n/*\n==================\nSV_RemoveOperatorCommands\n==================\n*/\nvoid SV_RemoveOperatorCommands( void ) {\n#if 0\n\t// removing these won't let the server start again\n\tCmd_RemoveCommand (\"heartbeat\");\n\tCmd_RemoveCommand (\"kick\");\n\tCmd_RemoveCommand (\"banUser\");\n\tCmd_RemoveCommand (\"banClient\");\n\tCmd_RemoveCommand (\"status\");\n\tCmd_RemoveCommand (\"serverinfo\");\n\tCmd_RemoveCommand (\"systeminfo\");\n\tCmd_RemoveCommand (\"dumpuser\");\n\tCmd_RemoveCommand (\"map_restart\");\n\tCmd_RemoveCommand (\"sectorlist\");\n\tCmd_RemoveCommand (\"say\");\n#endif\n}\n\n"
  },
  {
    "path": "code/server/sv_client.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// sv_client.c -- server code for dealing with clients\n\n#include \"server.h\"\n\nstatic void SV_CloseDownload( client_t *cl );\n\n/*\n=================\nSV_GetChallenge\n\nA \"getchallenge\" OOB command has been received\nReturns a challenge number that can be used\nin a subsequent connectResponse command.\nWe do this to prevent denial of service attacks that\nflood the server with invalid connection IPs.  With a\nchallenge, they must give a valid IP address.\n\nIf we are authorizing, a challenge request will cause a packet\nto be sent to the authorize server.\n\nWhen an authorizeip is returned, a challenge response will be\nsent to that ip.\n=================\n*/\nvoid SV_GetChallenge( netadr_t from ) {\n\tint\t\ti;\n\tint\t\toldest;\n\tint\t\toldestTime;\n\tchallenge_t\t*challenge;\n\n\t// ignore if we are in single player\n\tif ( Cvar_VariableValue( \"g_gametype\" ) == GT_SINGLE_PLAYER || Cvar_VariableValue(\"ui_singlePlayerActive\")) {\n\t\treturn;\n\t}\n\n\toldest = 0;\n\toldestTime = 0x7fffffff;\n\n\t// see if we already have a challenge for this ip\n\tchallenge = &svs.challenges[0];\n\tfor (i = 0 ; i < MAX_CHALLENGES ; i++, challenge++) {\n\t\tif ( !challenge->connected && NET_CompareAdr( from, challenge->adr ) ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( challenge->time < oldestTime ) {\n\t\t\toldestTime = challenge->time;\n\t\t\toldest = i;\n\t\t}\n\t}\n\n\tif (i == MAX_CHALLENGES) {\n\t\t// this is the first time this client has asked for a challenge\n\t\tchallenge = &svs.challenges[oldest];\n\n\t\tchallenge->challenge = ( (rand() << 16) ^ rand() ) ^ svs.time;\n\t\tchallenge->adr = from;\n\t\tchallenge->firstTime = svs.time;\n\t\tchallenge->time = svs.time;\n\t\tchallenge->connected = qfalse;\n\t\ti = oldest;\n\t}\n\n\t// if they are on a lan address, send the challengeResponse immediately\n\tif ( Sys_IsLANAddress( from ) ) {\n\t\tchallenge->pingTime = svs.time;\n\t\tNET_OutOfBandPrint( NS_SERVER, from, \"challengeResponse %i\", challenge->challenge );\n\t\treturn;\n\t}\n\n\t// look up the authorize server's IP\n\tif ( !svs.authorizeAddress.ip[0] && svs.authorizeAddress.type != NA_BAD ) {\n\t\tCom_Printf( \"Resolving %s\\n\", AUTHORIZE_SERVER_NAME );\n\t\tif ( !NET_StringToAdr( AUTHORIZE_SERVER_NAME, &svs.authorizeAddress ) ) {\n\t\t\tCom_Printf( \"Couldn't resolve address\\n\" );\n\t\t\treturn;\n\t\t}\n\t\tsvs.authorizeAddress.port = BigShort( PORT_AUTHORIZE );\n\t\tCom_Printf( \"%s resolved to %i.%i.%i.%i:%i\\n\", AUTHORIZE_SERVER_NAME,\n\t\t\tsvs.authorizeAddress.ip[0], svs.authorizeAddress.ip[1],\n\t\t\tsvs.authorizeAddress.ip[2], svs.authorizeAddress.ip[3],\n\t\t\tBigShort( svs.authorizeAddress.port ) );\n\t}\n\n\t// if they have been challenging for a long time and we\n\t// haven't heard anything from the authorize server, go ahead and\n\t// let them in, assuming the id server is down\n\tif ( svs.time - challenge->firstTime > AUTHORIZE_TIMEOUT ) {\n\t\tCom_DPrintf( \"authorize server timed out\\n\" );\n\n\t\tchallenge->pingTime = svs.time;\n\t\tNET_OutOfBandPrint( NS_SERVER, challenge->adr, \n\t\t\t\"challengeResponse %i\", challenge->challenge );\n\t\treturn;\n\t}\n\n\t// otherwise send their ip to the authorize server\n\tif ( svs.authorizeAddress.type != NA_BAD ) {\n\t\tcvar_t\t*fs;\n\t\tchar\tgame[1024];\n\n\t\tCom_DPrintf( \"sending getIpAuthorize for %s\\n\", NET_AdrToString( from ));\n\t\t\n\t\tstrcpy(game, BASEGAME);\n\t\tfs = Cvar_Get (\"fs_game\", \"\", CVAR_INIT|CVAR_SYSTEMINFO );\n\t\tif (fs && fs->string[0] != 0) {\n\t\t\tstrcpy(game, fs->string);\n\t\t}\n\t\t\n\t\t// the 0 is for backwards compatibility with obsolete sv_allowanonymous flags\n\t\t// getIpAuthorize <challenge> <IP> <game> 0 <auth-flag>\n\t\tNET_OutOfBandPrint( NS_SERVER, svs.authorizeAddress,\n\t\t\t\"getIpAuthorize %i %i.%i.%i.%i %s 0 %s\",  svs.challenges[i].challenge,\n\t\t\tfrom.ip[0], from.ip[1], from.ip[2], from.ip[3], game, sv_strictAuth->string );\n\t}\n}\n\n/*\n====================\nSV_AuthorizeIpPacket\n\nA packet has been returned from the authorize server.\nIf we have a challenge adr for that ip, send the\nchallengeResponse to it\n====================\n*/\nvoid SV_AuthorizeIpPacket( netadr_t from ) {\n\tint\t\tchallenge;\n\tint\t\ti;\n\tchar\t*s;\n\tchar\t*r;\n\tchar\tret[1024];\n\n\tif ( !NET_CompareBaseAdr( from, svs.authorizeAddress ) ) {\n\t\tCom_Printf( \"SV_AuthorizeIpPacket: not from authorize server\\n\" );\n\t\treturn;\n\t}\n\n\tchallenge = atoi( Cmd_Argv( 1 ) );\n\n\tfor (i = 0 ; i < MAX_CHALLENGES ; i++) {\n\t\tif ( svs.challenges[i].challenge == challenge ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif ( i == MAX_CHALLENGES ) {\n\t\tCom_Printf( \"SV_AuthorizeIpPacket: challenge not found\\n\" );\n\t\treturn;\n\t}\n\n\t// send a packet back to the original client\n\tsvs.challenges[i].pingTime = svs.time;\n\ts = Cmd_Argv( 2 );\n\tr = Cmd_Argv( 3 );\t\t\t// reason\n\n\tif ( !Q_stricmp( s, \"demo\" ) ) {\n\t\tif ( Cvar_VariableValue( \"fs_restrict\" ) ) {\n\t\t\t// a demo client connecting to a demo server\n\t\t\tNET_OutOfBandPrint( NS_SERVER, svs.challenges[i].adr, \n\t\t\t\t\"challengeResponse %i\", svs.challenges[i].challenge );\n\t\t\treturn;\n\t\t}\n\t\t// they are a demo client trying to connect to a real server\n\t\tNET_OutOfBandPrint( NS_SERVER, svs.challenges[i].adr, \"print\\nServer is not a demo server\\n\" );\n\t\t// clear the challenge record so it won't timeout and let them through\n\t\tCom_Memset( &svs.challenges[i], 0, sizeof( svs.challenges[i] ) );\n\t\treturn;\n\t}\n\tif ( !Q_stricmp( s, \"accept\" ) ) {\n\t\tNET_OutOfBandPrint( NS_SERVER, svs.challenges[i].adr, \n\t\t\t\"challengeResponse %i\", svs.challenges[i].challenge );\n\t\treturn;\n\t}\n\tif ( !Q_stricmp( s, \"unknown\" ) ) {\n\t\tif (!r) {\n\t\t\tNET_OutOfBandPrint( NS_SERVER, svs.challenges[i].adr, \"print\\nAwaiting CD key authorization\\n\" );\n\t\t} else {\n\t\t\tsprintf(ret, \"print\\n%s\\n\", r);\n\t\t\tNET_OutOfBandPrint( NS_SERVER, svs.challenges[i].adr, ret );\n\t\t}\n\t\t// clear the challenge record so it won't timeout and let them through\n\t\tCom_Memset( &svs.challenges[i], 0, sizeof( svs.challenges[i] ) );\n\t\treturn;\n\t}\n\n\t// authorization failed\n\tif (!r) {\n\t\tNET_OutOfBandPrint( NS_SERVER, svs.challenges[i].adr, \"print\\nSomeone is using this CD Key\\n\" );\n\t} else {\n\t\tsprintf(ret, \"print\\n%s\\n\", r);\n\t\tNET_OutOfBandPrint( NS_SERVER, svs.challenges[i].adr, ret );\n\t}\n\n\t// clear the challenge record so it won't timeout and let them through\n\tCom_Memset( &svs.challenges[i], 0, sizeof( svs.challenges[i] ) );\n}\n\n/*\n==================\nSV_DirectConnect\n\nA \"connect\" OOB command has been received\n==================\n*/\n\n#define PB_MESSAGE \"PunkBuster Anti-Cheat software must be installed \" \\\n\t\t\t\t\"and Enabled in order to join this server. An updated game patch can be downloaded from \" \\\n\t\t\t\t\"www.idsoftware.com\"\n\nvoid SV_DirectConnect( netadr_t from ) {\n\tchar\t\tuserinfo[MAX_INFO_STRING];\n\tint\t\t\ti;\n\tclient_t\t*cl, *newcl;\n\tMAC_STATIC client_t\ttemp;\n\tsharedEntity_t *ent;\n\tint\t\t\tclientNum;\n\tint\t\t\tversion;\n\tint\t\t\tqport;\n\tint\t\t\tchallenge;\n\tchar\t\t*password;\n\tint\t\t\tstartIndex;\n\tchar\t\t*denied;\n\tint\t\t\tcount;\n\n\tCom_DPrintf (\"SVC_DirectConnect ()\\n\");\n\n\tQ_strncpyz( userinfo, Cmd_Argv(1), sizeof(userinfo) );\n\n\tversion = atoi( Info_ValueForKey( userinfo, \"protocol\" ) );\n\tif ( version != PROTOCOL_VERSION ) {\n\t\tNET_OutOfBandPrint( NS_SERVER, from, \"print\\nServer uses protocol version %i.\\n\", PROTOCOL_VERSION );\n\t\tCom_DPrintf (\"    rejected connect from version %i\\n\", version);\n\t\treturn;\n\t}\n\n\tchallenge = atoi( Info_ValueForKey( userinfo, \"challenge\" ) );\n\tqport = atoi( Info_ValueForKey( userinfo, \"qport\" ) );\n\n\t// quick reject\n\tfor (i=0,cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++) {\n\t\tif ( cl->state == CS_FREE ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( NET_CompareBaseAdr( from, cl->netchan.remoteAddress )\n\t\t\t&& ( cl->netchan.qport == qport \n\t\t\t|| from.port == cl->netchan.remoteAddress.port ) ) {\n\t\t\tif (( svs.time - cl->lastConnectTime) \n\t\t\t\t< (sv_reconnectlimit->integer * 1000)) {\n\t\t\t\tCom_DPrintf (\"%s:reconnect rejected : too soon\\n\", NET_AdrToString (from));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// see if the challenge is valid (LAN clients don't need to challenge)\n\tif ( !NET_IsLocalAddress (from) ) {\n\t\tint\t\tping;\n\n\t\tfor (i=0 ; i<MAX_CHALLENGES ; i++) {\n\t\t\tif (NET_CompareAdr(from, svs.challenges[i].adr)) {\n\t\t\t\tif ( challenge == svs.challenges[i].challenge ) {\n\t\t\t\t\tbreak;\t\t// good\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (i == MAX_CHALLENGES) {\n\t\t\tNET_OutOfBandPrint( NS_SERVER, from, \"print\\nNo or bad challenge for address.\\n\" );\n\t\t\treturn;\n\t\t}\n\t\t// force the IP key/value pair so the game can filter based on ip\n\t\tInfo_SetValueForKey( userinfo, \"ip\", NET_AdrToString( from ) );\n\n\t\tping = svs.time - svs.challenges[i].pingTime;\n\t\tCom_Printf( \"Client %i connecting with %i challenge ping\\n\", i, ping );\n\t\tsvs.challenges[i].connected = qtrue;\n\n\t\t// never reject a LAN client based on ping\n\t\tif ( !Sys_IsLANAddress( from ) ) {\n\t\t\tif ( sv_minPing->value && ping < sv_minPing->value ) {\n\t\t\t\t// don't let them keep trying until they get a big delay\n\t\t\t\tNET_OutOfBandPrint( NS_SERVER, from, \"print\\nServer is for high pings only\\n\" );\n\t\t\t\tCom_DPrintf (\"Client %i rejected on a too low ping\\n\", i);\n\t\t\t\t// reset the address otherwise their ping will keep increasing\n\t\t\t\t// with each connect message and they'd eventually be able to connect\n\t\t\t\tsvs.challenges[i].adr.port = 0;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( sv_maxPing->value && ping > sv_maxPing->value ) {\n\t\t\t\tNET_OutOfBandPrint( NS_SERVER, from, \"print\\nServer is for low pings only\\n\" );\n\t\t\t\tCom_DPrintf (\"Client %i rejected on a too high ping\\n\", i);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// force the \"ip\" info key to \"localhost\"\n\t\tInfo_SetValueForKey( userinfo, \"ip\", \"localhost\" );\n\t}\n\n\tnewcl = &temp;\n\tCom_Memset (newcl, 0, sizeof(client_t));\n\n\t// if there is already a slot for this ip, reuse it\n\tfor (i=0,cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++) {\n\t\tif ( cl->state == CS_FREE ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( NET_CompareBaseAdr( from, cl->netchan.remoteAddress )\n\t\t\t&& ( cl->netchan.qport == qport \n\t\t\t|| from.port == cl->netchan.remoteAddress.port ) ) {\n\t\t\tCom_Printf (\"%s:reconnect\\n\", NET_AdrToString (from));\n\t\t\tnewcl = cl;\n\n\t\t\t// this doesn't work because it nukes the players userinfo\n\n//\t\t\t// disconnect the client from the game first so any flags the\n//\t\t\t// player might have are dropped\n//\t\t\tVM_Call( gvm, GAME_CLIENT_DISCONNECT, newcl - svs.clients );\n\t\t\t//\n\t\t\tgoto gotnewcl;\n\t\t}\n\t}\n\n\t// find a client slot\n\t// if \"sv_privateClients\" is set > 0, then that number\n\t// of client slots will be reserved for connections that\n\t// have \"password\" set to the value of \"sv_privatePassword\"\n\t// Info requests will report the maxclients as if the private\n\t// slots didn't exist, to prevent people from trying to connect\n\t// to a full server.\n\t// This is to allow us to reserve a couple slots here on our\n\t// servers so we can play without having to kick people.\n\n\t// check for privateClient password\n\tpassword = Info_ValueForKey( userinfo, \"password\" );\n\tif ( !strcmp( password, sv_privatePassword->string ) ) {\n\t\tstartIndex = 0;\n\t} else {\n\t\t// skip past the reserved slots\n\t\tstartIndex = sv_privateClients->integer;\n\t}\n\n\tnewcl = NULL;\n\tfor ( i = startIndex; i < sv_maxclients->integer ; i++ ) {\n\t\tcl = &svs.clients[i];\n\t\tif (cl->state == CS_FREE) {\n\t\t\tnewcl = cl;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif ( !newcl ) {\n\t\tif ( NET_IsLocalAddress( from ) ) {\n\t\t\tcount = 0;\n\t\t\tfor ( i = startIndex; i < sv_maxclients->integer ; i++ ) {\n\t\t\t\tcl = &svs.clients[i];\n\t\t\t\tif (cl->netchan.remoteAddress.type == NA_BOT) {\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// if they're all bots\n\t\t\tif (count >= sv_maxclients->integer - startIndex) {\n\t\t\t\tSV_DropClient(&svs.clients[sv_maxclients->integer - 1], \"only bots on server\");\n\t\t\t\tnewcl = &svs.clients[sv_maxclients->integer - 1];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tCom_Error( ERR_FATAL, \"server is full on local connect\\n\" );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tNET_OutOfBandPrint( NS_SERVER, from, \"print\\nServer is full.\\n\" );\n\t\t\tCom_DPrintf (\"Rejected a connection.\\n\");\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// we got a newcl, so reset the reliableSequence and reliableAcknowledge\n\tcl->reliableAcknowledge = 0;\n\tcl->reliableSequence = 0;\n\ngotnewcl:\t\n\t// build a new connection\n\t// accept the new client\n\t// this is the only place a client_t is ever initialized\n\t*newcl = temp;\n\tclientNum = newcl - svs.clients;\n\tent = SV_GentityNum( clientNum );\n\tnewcl->gentity = ent;\n\n\t// save the challenge\n\tnewcl->challenge = challenge;\n\n\t// save the address\n\tNetchan_Setup (NS_SERVER, &newcl->netchan , from, qport);\n\t// init the netchan queue\n\tnewcl->netchan_end_queue = &newcl->netchan_start_queue;\n\n\t// save the userinfo\n\tQ_strncpyz( newcl->userinfo, userinfo, sizeof(newcl->userinfo) );\n\n\t// get the game a chance to reject this connection or modify the userinfo\n\tdenied = (char *)VM_Call( gvm, GAME_CLIENT_CONNECT, clientNum, qtrue, qfalse ); // firstTime = qtrue\n\tif ( denied ) {\n\t\t// we can't just use VM_ArgPtr, because that is only valid inside a VM_Call\n\t\tdenied = VM_ExplicitArgPtr( gvm, (int)denied );\n\n\t\tNET_OutOfBandPrint( NS_SERVER, from, \"print\\n%s\\n\", denied );\n\t\tCom_DPrintf (\"Game rejected a connection: %s.\\n\", denied);\n\t\treturn;\n\t}\n\n\tSV_UserinfoChanged( newcl );\n\n\t// send the connect packet to the client\n\tNET_OutOfBandPrint( NS_SERVER, from, \"connectResponse\" );\n\n\tCom_DPrintf( \"Going from CS_FREE to CS_CONNECTED for %s\\n\", newcl->name );\n\n\tnewcl->state = CS_CONNECTED;\n\tnewcl->nextSnapshotTime = svs.time;\n\tnewcl->lastPacketTime = svs.time;\n\tnewcl->lastConnectTime = svs.time;\n\t\n\t// when we receive the first packet from the client, we will\n\t// notice that it is from a different serverid and that the\n\t// gamestate message was not just sent, forcing a retransmit\n\tnewcl->gamestateMessageNum = -1;\n\n\t// if this was the first client on the server, or the last client\n\t// the server can hold, send a heartbeat to the master.\n\tcount = 0;\n\tfor (i=0,cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++) {\n\t\tif ( svs.clients[i].state >= CS_CONNECTED ) {\n\t\t\tcount++;\n\t\t}\n\t}\n\tif ( count == 1 || count == sv_maxclients->integer ) {\n\t\tSV_Heartbeat_f();\n\t}\n}\n\n\n/*\n=====================\nSV_DropClient\n\nCalled when the player is totally leaving the server, either willingly\nor unwillingly.  This is NOT called if the entire server is quiting\nor crashing -- SV_FinalMessage() will handle that\n=====================\n*/\nvoid SV_DropClient( client_t *drop, const char *reason ) {\n\tint\t\ti;\n\tchallenge_t\t*challenge;\n\n\tif ( drop->state == CS_ZOMBIE ) {\n\t\treturn;\t\t// already dropped\n\t}\n\n\tif ( !drop->gentity || !(drop->gentity->r.svFlags & SVF_BOT) ) {\n\t\t// see if we already have a challenge for this ip\n\t\tchallenge = &svs.challenges[0];\n\n\t\tfor (i = 0 ; i < MAX_CHALLENGES ; i++, challenge++) {\n\t\t\tif ( NET_CompareAdr( drop->netchan.remoteAddress, challenge->adr ) ) {\n\t\t\t\tchallenge->connected = qfalse;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Kill any download\n\tSV_CloseDownload( drop );\n\n\t// tell everyone why they got dropped\n\tSV_SendServerCommand( NULL, \"print \\\"%s\" S_COLOR_WHITE \" %s\\n\\\"\", drop->name, reason );\n\n\tCom_DPrintf( \"Going to CS_ZOMBIE for %s\\n\", drop->name );\n\tdrop->state = CS_ZOMBIE;\t\t// become free in a few seconds\n\n\tif (drop->download)\t{\n\t\tFS_FCloseFile( drop->download );\n\t\tdrop->download = 0;\n\t}\n\n\t// call the prog function for removing a client\n\t// this will remove the body, among other things\n\tVM_Call( gvm, GAME_CLIENT_DISCONNECT, drop - svs.clients );\n\n\t// add the disconnect command\n\tSV_SendServerCommand( drop, \"disconnect \\\"%s\\\"\", reason);\n\n\tif ( drop->netchan.remoteAddress.type == NA_BOT ) {\n\t\tSV_BotFreeClient( drop - svs.clients );\n\t}\n\n\t// nuke user info\n\tSV_SetUserinfo( drop - svs.clients, \"\" );\n\n\t// if this was the last client on the server, send a heartbeat\n\t// to the master so it is known the server is empty\n\t// send a heartbeat now so the master will get up to date info\n\t// if there is already a slot for this ip, reuse it\n\tfor (i=0 ; i < sv_maxclients->integer ; i++ ) {\n\t\tif ( svs.clients[i].state >= CS_CONNECTED ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif ( i == sv_maxclients->integer ) {\n\t\tSV_Heartbeat_f();\n\t}\n}\n\n/*\n================\nSV_SendClientGameState\n\nSends the first message from the server to a connected client.\nThis will be sent on the initial connection and upon each new map load.\n\nIt will be resent if the client acknowledges a later message but has\nthe wrong gamestate.\n================\n*/\nvoid SV_SendClientGameState( client_t *client ) {\n\tint\t\t\tstart;\n\tentityState_t\t*base, nullstate;\n\tmsg_t\t\tmsg;\n\tbyte\t\tmsgBuffer[MAX_MSGLEN];\n\n \tCom_DPrintf (\"SV_SendClientGameState() for %s\\n\", client->name);\n\tCom_DPrintf( \"Going from CS_CONNECTED to CS_PRIMED for %s\\n\", client->name );\n\tclient->state = CS_PRIMED;\n\tclient->pureAuthentic = 0;\n\tclient->gotCP = qfalse;\n\n\t// when we receive the first packet from the client, we will\n\t// notice that it is from a different serverid and that the\n\t// gamestate message was not just sent, forcing a retransmit\n\tclient->gamestateMessageNum = client->netchan.outgoingSequence;\n\n\tMSG_Init( &msg, msgBuffer, sizeof( msgBuffer ) );\n\n\t// NOTE, MRE: all server->client messages now acknowledge\n\t// let the client know which reliable clientCommands we have received\n\tMSG_WriteLong( &msg, client->lastClientCommand );\n\n\t// send any server commands waiting to be sent first.\n\t// we have to do this cause we send the client->reliableSequence\n\t// with a gamestate and it sets the clc.serverCommandSequence at\n\t// the client side\n\tSV_UpdateServerCommandsToClient( client, &msg );\n\n\t// send the gamestate\n\tMSG_WriteByte( &msg, svc_gamestate );\n\tMSG_WriteLong( &msg, client->reliableSequence );\n\n\t// write the configstrings\n\tfor ( start = 0 ; start < MAX_CONFIGSTRINGS ; start++ ) {\n\t\tif (sv.configstrings[start][0]) {\n\t\t\tMSG_WriteByte( &msg, svc_configstring );\n\t\t\tMSG_WriteShort( &msg, start );\n\t\t\tMSG_WriteBigString( &msg, sv.configstrings[start] );\n\t\t}\n\t}\n\n\t// write the baselines\n\tCom_Memset( &nullstate, 0, sizeof( nullstate ) );\n\tfor ( start = 0 ; start < MAX_GENTITIES; start++ ) {\n\t\tbase = &sv.svEntities[start].baseline;\n\t\tif ( !base->number ) {\n\t\t\tcontinue;\n\t\t}\n\t\tMSG_WriteByte( &msg, svc_baseline );\n\t\tMSG_WriteDeltaEntity( &msg, &nullstate, base, qtrue );\n\t}\n\n\tMSG_WriteByte( &msg, svc_EOF );\n\n\tMSG_WriteLong( &msg, client - svs.clients);\n\n\t// write the checksum feed\n\tMSG_WriteLong( &msg, sv.checksumFeed);\n\n\t// deliver this to the client\n\tSV_SendMessageToClient( &msg, client );\n}\n\n\n/*\n==================\nSV_ClientEnterWorld\n==================\n*/\nvoid SV_ClientEnterWorld( client_t *client, usercmd_t *cmd ) {\n\tint\t\tclientNum;\n\tsharedEntity_t *ent;\n\n\tCom_DPrintf( \"Going from CS_PRIMED to CS_ACTIVE for %s\\n\", client->name );\n\tclient->state = CS_ACTIVE;\n\n\t// set up the entity for the client\n\tclientNum = client - svs.clients;\n\tent = SV_GentityNum( clientNum );\n\tent->s.number = clientNum;\n\tclient->gentity = ent;\n\n\tclient->deltaMessage = -1;\n\tclient->nextSnapshotTime = svs.time;\t// generate a snapshot immediately\n\tclient->lastUsercmd = *cmd;\n\n\t// call the game begin function\n\tVM_Call( gvm, GAME_CLIENT_BEGIN, client - svs.clients );\n}\n\n/*\n============================================================\n\nCLIENT COMMAND EXECUTION\n\n============================================================\n*/\n\n/*\n==================\nSV_CloseDownload\n\nclear/free any download vars\n==================\n*/\nstatic void SV_CloseDownload( client_t *cl ) {\n\tint i;\n\n\t// EOF\n\tif (cl->download) {\n\t\tFS_FCloseFile( cl->download );\n\t}\n\tcl->download = 0;\n\t*cl->downloadName = 0;\n\n\t// Free the temporary buffer space\n\tfor (i = 0; i < MAX_DOWNLOAD_WINDOW; i++) {\n\t\tif (cl->downloadBlocks[i]) {\n\t\t\tZ_Free( cl->downloadBlocks[i] );\n\t\t\tcl->downloadBlocks[i] = NULL;\n\t\t}\n\t}\n\n}\n\n/*\n==================\nSV_StopDownload_f\n\nAbort a download if in progress\n==================\n*/\nvoid SV_StopDownload_f( client_t *cl ) {\n\tif (*cl->downloadName)\n\t\tCom_DPrintf( \"clientDownload: %d : file \\\"%s\\\" aborted\\n\", cl - svs.clients, cl->downloadName );\n\n\tSV_CloseDownload( cl );\n}\n\n/*\n==================\nSV_DoneDownload_f\n\nDownloads are finished\n==================\n*/\nvoid SV_DoneDownload_f( client_t *cl ) {\n\tCom_DPrintf( \"clientDownload: %s Done\\n\", cl->name);\n\t// resend the game state to update any clients that entered during the download\n\tSV_SendClientGameState(cl);\n}\n\n/*\n==================\nSV_NextDownload_f\n\nThe argument will be the last acknowledged block from the client, it should be\nthe same as cl->downloadClientBlock\n==================\n*/\nvoid SV_NextDownload_f( client_t *cl )\n{\n\tint block = atoi( Cmd_Argv(1) );\n\n\tif (block == cl->downloadClientBlock) {\n\t\tCom_DPrintf( \"clientDownload: %d : client acknowledge of block %d\\n\", cl - svs.clients, block );\n\n\t\t// Find out if we are done.  A zero-length block indicates EOF\n\t\tif (cl->downloadBlockSize[cl->downloadClientBlock % MAX_DOWNLOAD_WINDOW] == 0) {\n\t\t\tCom_Printf( \"clientDownload: %d : file \\\"%s\\\" completed\\n\", cl - svs.clients, cl->downloadName );\n\t\t\tSV_CloseDownload( cl );\n\t\t\treturn;\n\t\t}\n\n\t\tcl->downloadSendTime = svs.time;\n\t\tcl->downloadClientBlock++;\n\t\treturn;\n\t}\n\t// We aren't getting an acknowledge for the correct block, drop the client\n\t// FIXME: this is bad... the client will never parse the disconnect message\n\t//\t\t\tbecause the cgame isn't loaded yet\n\tSV_DropClient( cl, \"broken download\" );\n}\n\n/*\n==================\nSV_BeginDownload_f\n==================\n*/\nvoid SV_BeginDownload_f( client_t *cl ) {\n\n\t// Kill any existing download\n\tSV_CloseDownload( cl );\n\n\t// cl->downloadName is non-zero now, SV_WriteDownloadToClient will see this and open\n\t// the file itself\n\tQ_strncpyz( cl->downloadName, Cmd_Argv(1), sizeof(cl->downloadName) );\n}\n\n/*\n==================\nSV_WriteDownloadToClient\n\nCheck to see if the client wants a file, open it if needed and start pumping the client\nFill up msg with data \n==================\n*/\nvoid SV_WriteDownloadToClient( client_t *cl , msg_t *msg )\n{\n\tint curindex;\n\tint rate;\n\tint blockspersnap;\n\tint idPack, missionPack;\n\tchar errorMessage[1024];\n\n\tif (!*cl->downloadName)\n\t\treturn;\t// Nothing being downloaded\n\n\tif (!cl->download) {\n\t\t// We open the file here\n\n\t\tCom_Printf( \"clientDownload: %d : begining \\\"%s\\\"\\n\", cl - svs.clients, cl->downloadName );\n\n\t\tmissionPack = FS_idPak(cl->downloadName, \"missionpack\");\n\t\tidPack = missionPack || FS_idPak(cl->downloadName, \"baseq3\");\n\n\t\tif ( !sv_allowDownload->integer || idPack ||\n\t\t\t( cl->downloadSize = FS_SV_FOpenFileRead( cl->downloadName, &cl->download ) ) <= 0 ) {\n\t\t\t// cannot auto-download file\n\t\t\tif (idPack) {\n\t\t\t\tCom_Printf(\"clientDownload: %d : \\\"%s\\\" cannot download id pk3 files\\n\", cl - svs.clients, cl->downloadName);\n\t\t\t\tif (missionPack) {\n\t\t\t\t\tCom_sprintf(errorMessage, sizeof(errorMessage), \"Cannot autodownload Team Arena file \\\"%s\\\"\\n\"\n\t\t\t\t\t\t\t\t\t\"The Team Arena mission pack can be found in your local game store.\", cl->downloadName);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tCom_sprintf(errorMessage, sizeof(errorMessage), \"Cannot autodownload id pk3 file \\\"%s\\\"\", cl->downloadName);\n\t\t\t\t}\n\t\t\t} else if ( !sv_allowDownload->integer ) {\n\t\t\t\tCom_Printf(\"clientDownload: %d : \\\"%s\\\" download disabled\", cl - svs.clients, cl->downloadName);\n\t\t\t\tif (sv_pure->integer) {\n\t\t\t\t\tCom_sprintf(errorMessage, sizeof(errorMessage), \"Could not download \\\"%s\\\" because autodownloading is disabled on the server.\\n\\n\"\n\t\t\t\t\t\t\t\t\t\t\"You will need to get this file elsewhere before you \"\n\t\t\t\t\t\t\t\t\t\t\"can connect to this pure server.\\n\", cl->downloadName);\n\t\t\t\t} else {\n\t\t\t\t\tCom_sprintf(errorMessage, sizeof(errorMessage), \"Could not download \\\"%s\\\" because autodownloading is disabled on the server.\\n\\n\"\n                    \"The server you are connecting to is not a pure server, \"\n                    \"set autodownload to No in your settings and you might be \"\n                    \"able to join the game anyway.\\n\", cl->downloadName);\n\t\t\t\t}\n\t\t\t} else {\n        // NOTE TTimo this is NOT supposed to happen unless bug in our filesystem scheme?\n        //   if the pk3 is referenced, it must have been found somewhere in the filesystem\n\t\t\t\tCom_Printf(\"clientDownload: %d : \\\"%s\\\" file not found on server\\n\", cl - svs.clients, cl->downloadName);\n\t\t\t\tCom_sprintf(errorMessage, sizeof(errorMessage), \"File \\\"%s\\\" not found on server for autodownloading.\\n\", cl->downloadName);\n\t\t\t}\n\t\t\tMSG_WriteByte( msg, svc_download );\n\t\t\tMSG_WriteShort( msg, 0 ); // client is expecting block zero\n\t\t\tMSG_WriteLong( msg, -1 ); // illegal file size\n\t\t\tMSG_WriteString( msg, errorMessage );\n\n\t\t\t*cl->downloadName = 0;\n\t\t\treturn;\n\t\t}\n \n\t\t// Init\n\t\tcl->downloadCurrentBlock = cl->downloadClientBlock = cl->downloadXmitBlock = 0;\n\t\tcl->downloadCount = 0;\n\t\tcl->downloadEOF = qfalse;\n\t}\n\n\t// Perform any reads that we need to\n\twhile (cl->downloadCurrentBlock - cl->downloadClientBlock < MAX_DOWNLOAD_WINDOW &&\n\t\tcl->downloadSize != cl->downloadCount) {\n\n\t\tcurindex = (cl->downloadCurrentBlock % MAX_DOWNLOAD_WINDOW);\n\n\t\tif (!cl->downloadBlocks[curindex])\n\t\t\tcl->downloadBlocks[curindex] = Z_Malloc( MAX_DOWNLOAD_BLKSIZE );\n\n\t\tcl->downloadBlockSize[curindex] = FS_Read( cl->downloadBlocks[curindex], MAX_DOWNLOAD_BLKSIZE, cl->download );\n\n\t\tif (cl->downloadBlockSize[curindex] < 0) {\n\t\t\t// EOF right now\n\t\t\tcl->downloadCount = cl->downloadSize;\n\t\t\tbreak;\n\t\t}\n\n\t\tcl->downloadCount += cl->downloadBlockSize[curindex];\n\n\t\t// Load in next block\n\t\tcl->downloadCurrentBlock++;\n\t}\n\n\t// Check to see if we have eof condition and add the EOF block\n\tif (cl->downloadCount == cl->downloadSize &&\n\t\t!cl->downloadEOF &&\n\t\tcl->downloadCurrentBlock - cl->downloadClientBlock < MAX_DOWNLOAD_WINDOW) {\n\n\t\tcl->downloadBlockSize[cl->downloadCurrentBlock % MAX_DOWNLOAD_WINDOW] = 0;\n\t\tcl->downloadCurrentBlock++;\n\n\t\tcl->downloadEOF = qtrue;  // We have added the EOF block\n\t}\n\n\t// Loop up to window size times based on how many blocks we can fit in the\n\t// client snapMsec and rate\n\n\t// based on the rate, how many bytes can we fit in the snapMsec time of the client\n\t// normal rate / snapshotMsec calculation\n\trate = cl->rate;\n\tif ( sv_maxRate->integer ) {\n\t\tif ( sv_maxRate->integer < 1000 ) {\n\t\t\tCvar_Set( \"sv_MaxRate\", \"1000\" );\n\t\t}\n\t\tif ( sv_maxRate->integer < rate ) {\n\t\t\trate = sv_maxRate->integer;\n\t\t}\n\t}\n\n\tif (!rate) {\n\t\tblockspersnap = 1;\n\t} else {\n\t\tblockspersnap = ( (rate * cl->snapshotMsec) / 1000 + MAX_DOWNLOAD_BLKSIZE ) /\n\t\t\tMAX_DOWNLOAD_BLKSIZE;\n\t}\n\n\tif (blockspersnap < 0)\n\t\tblockspersnap = 1;\n\n\twhile (blockspersnap--) {\n\n\t\t// Write out the next section of the file, if we have already reached our window,\n\t\t// automatically start retransmitting\n\n\t\tif (cl->downloadClientBlock == cl->downloadCurrentBlock)\n\t\t\treturn; // Nothing to transmit\n\n\t\tif (cl->downloadXmitBlock == cl->downloadCurrentBlock) {\n\t\t\t// We have transmitted the complete window, should we start resending?\n\n\t\t\t//FIXME:  This uses a hardcoded one second timeout for lost blocks\n\t\t\t//the timeout should be based on client rate somehow\n\t\t\tif (svs.time - cl->downloadSendTime > 1000)\n\t\t\t\tcl->downloadXmitBlock = cl->downloadClientBlock;\n\t\t\telse\n\t\t\t\treturn;\n\t\t}\n\n\t\t// Send current block\n\t\tcurindex = (cl->downloadXmitBlock % MAX_DOWNLOAD_WINDOW);\n\n\t\tMSG_WriteByte( msg, svc_download );\n\t\tMSG_WriteShort( msg, cl->downloadXmitBlock );\n\n\t\t// block zero is special, contains file size\n\t\tif ( cl->downloadXmitBlock == 0 )\n\t\t\tMSG_WriteLong( msg, cl->downloadSize );\n \n\t\tMSG_WriteShort( msg, cl->downloadBlockSize[curindex] );\n\n\t\t// Write the block\n\t\tif ( cl->downloadBlockSize[curindex] ) {\n\t\t\tMSG_WriteData( msg, cl->downloadBlocks[curindex], cl->downloadBlockSize[curindex] );\n\t\t}\n\n\t\tCom_DPrintf( \"clientDownload: %d : writing block %d\\n\", cl - svs.clients, cl->downloadXmitBlock );\n\n\t\t// Move on to the next block\n\t\t// It will get sent with next snap shot.  The rate will keep us in line.\n\t\tcl->downloadXmitBlock++;\n\n\t\tcl->downloadSendTime = svs.time;\n\t}\n}\n\n/*\n=================\nSV_Disconnect_f\n\nThe client is going to disconnect, so remove the connection immediately  FIXME: move to game?\n=================\n*/\nstatic void SV_Disconnect_f( client_t *cl ) {\n\tSV_DropClient( cl, \"disconnected\" );\n}\n\n/*\n=================\nSV_VerifyPaks_f\n\nIf we are pure, disconnect the client if they do no meet the following conditions:\n\n1. the first two checksums match our view of cgame and ui\n2. there are no any additional checksums that we do not have\n\nThis routine would be a bit simpler with a goto but i abstained\n\n=================\n*/\nstatic void SV_VerifyPaks_f( client_t *cl ) {\n\tint nChkSum1, nChkSum2, nClientPaks, nServerPaks, i, j, nCurArg;\n\tint nClientChkSum[1024];\n\tint nServerChkSum[1024];\n\tconst char *pPaks, *pArg;\n\tqboolean bGood = qtrue;\n\n\t// if we are pure, we \"expect\" the client to load certain things from \n\t// certain pk3 files, namely we want the client to have loaded the\n\t// ui and cgame that we think should be loaded based on the pure setting\n\t//\n\tif ( sv_pure->integer != 0 ) {\n\n\t\tbGood = qtrue;\n\t\tnChkSum1 = nChkSum2 = 0;\n\t\t// we run the game, so determine which cgame and ui the client \"should\" be running\n\t\tbGood = (FS_FileIsInPAK(\"vm/cgame.qvm\", &nChkSum1) == 1);\n\t\tif (bGood)\n\t\t\tbGood = (FS_FileIsInPAK(\"vm/ui.qvm\", &nChkSum2) == 1);\n\n\t\tnClientPaks = Cmd_Argc();\n\n\t\t// start at arg 2 ( skip serverId cl_paks )\n\t\tnCurArg = 1;\n\n\t\tpArg = Cmd_Argv(nCurArg++);\n\t\tif(!pArg) {\n\t\t\tbGood = qfalse;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=475\n\t\t\t// we may get incoming cp sequences from a previous checksumFeed, which we need to ignore\n\t\t\t// since serverId is a frame count, it always goes up\n\t\t\tif (atoi(pArg) < sv.checksumFeedServerId)\n\t\t\t{\n\t\t\t\tCom_DPrintf(\"ignoring outdated cp command from client %s\\n\", cl->name);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\n\t\t// we basically use this while loop to avoid using 'goto' :)\n\t\twhile (bGood) {\n\n\t\t\t// must be at least 6: \"cl_paks cgame ui @ firstref ... numChecksums\"\n\t\t\t// numChecksums is encoded\n\t\t\tif (nClientPaks < 6) {\n\t\t\t\tbGood = qfalse;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// verify first to be the cgame checksum\n\t\t\tpArg = Cmd_Argv(nCurArg++);\n\t\t\tif (!pArg || *pArg == '@' || atoi(pArg) != nChkSum1 ) {\n\t\t\t\tbGood = qfalse;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// verify the second to be the ui checksum\n\t\t\tpArg = Cmd_Argv(nCurArg++);\n\t\t\tif (!pArg || *pArg == '@' || atoi(pArg) != nChkSum2 ) {\n\t\t\t\tbGood = qfalse;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// should be sitting at the delimeter now\n\t\t\tpArg = Cmd_Argv(nCurArg++);\n\t\t\tif (*pArg != '@') {\n\t\t\t\tbGood = qfalse;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// store checksums since tokenization is not re-entrant\n\t\t\tfor (i = 0; nCurArg < nClientPaks; i++) {\n\t\t\t\tnClientChkSum[i] = atoi(Cmd_Argv(nCurArg++));\n\t\t\t}\n\n\t\t\t// store number to compare against (minus one cause the last is the number of checksums)\n\t\t\tnClientPaks = i - 1;\n\n\t\t\t// make sure none of the client check sums are the same\n\t\t\t// so the client can't send 5 the same checksums\n\t\t\tfor (i = 0; i < nClientPaks; i++) {\n\t\t\t\tfor (j = 0; j < nClientPaks; j++) {\n\t\t\t\t\tif (i == j)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif (nClientChkSum[i] == nClientChkSum[j]) {\n\t\t\t\t\t\tbGood = qfalse;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (bGood == qfalse)\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (bGood == qfalse)\n\t\t\t\tbreak;\n\n\t\t\t// get the pure checksums of the pk3 files loaded by the server\n\t\t\tpPaks = FS_LoadedPakPureChecksums();\n\t\t\tCmd_TokenizeString( pPaks );\n\t\t\tnServerPaks = Cmd_Argc();\n\t\t\tif (nServerPaks > 1024)\n\t\t\t\tnServerPaks = 1024;\n\n\t\t\tfor (i = 0; i < nServerPaks; i++) {\n\t\t\t\tnServerChkSum[i] = atoi(Cmd_Argv(i));\n\t\t\t}\n\n\t\t\t// check if the client has provided any pure checksums of pk3 files not loaded by the server\n\t\t\tfor (i = 0; i < nClientPaks; i++) {\n\t\t\t\tfor (j = 0; j < nServerPaks; j++) {\n\t\t\t\t\tif (nClientChkSum[i] == nServerChkSum[j]) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (j >= nServerPaks) {\n\t\t\t\t\tbGood = qfalse;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( bGood == qfalse ) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// check if the number of checksums was correct\n\t\t\tnChkSum1 = sv.checksumFeed;\n\t\t\tfor (i = 0; i < nClientPaks; i++) {\n\t\t\t\tnChkSum1 ^= nClientChkSum[i];\n\t\t\t}\n\t\t\tnChkSum1 ^= nClientPaks;\n\t\t\tif (nChkSum1 != nClientChkSum[nClientPaks]) {\n\t\t\t\tbGood = qfalse;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// break out\n\t\t\tbreak;\n\t\t}\n\n\t\tcl->gotCP = qtrue;\n\n\t\tif (bGood) {\n\t\t\tcl->pureAuthentic = 1;\n\t\t} \n\t\telse {\n\t\t\tcl->pureAuthentic = 0;\n\t\t\tcl->nextSnapshotTime = -1;\n\t\t\tcl->state = CS_ACTIVE;\n\t\t\tSV_SendClientSnapshot( cl );\n\t\t\tSV_DropClient( cl, \"Unpure client detected. Invalid .PK3 files referenced!\" );\n\t\t}\n\t}\n}\n\n/*\n=================\nSV_ResetPureClient_f\n=================\n*/\nstatic void SV_ResetPureClient_f( client_t *cl ) {\n\tcl->pureAuthentic = 0;\n\tcl->gotCP = qfalse;\n}\n\n/*\n=================\nSV_UserinfoChanged\n\nPull specific info from a newly changed userinfo string\ninto a more C friendly form.\n=================\n*/\nvoid SV_UserinfoChanged( client_t *cl ) {\n\tchar\t*val;\n\tint\t\ti;\n\n\t// name for C code\n\tQ_strncpyz( cl->name, Info_ValueForKey (cl->userinfo, \"name\"), sizeof(cl->name) );\n\n\t// rate command\n\n\t// if the client is on the same subnet as the server and we aren't running an\n\t// internet public server, assume they don't need a rate choke\n\tif ( Sys_IsLANAddress( cl->netchan.remoteAddress ) && com_dedicated->integer != 2 && sv_lanForceRate->integer == 1) {\n\t\tcl->rate = 99999;\t// lans should not rate limit\n\t} else {\n\t\tval = Info_ValueForKey (cl->userinfo, \"rate\");\n\t\tif (strlen(val)) {\n\t\t\ti = atoi(val);\n\t\t\tcl->rate = i;\n\t\t\tif (cl->rate < 1000) {\n\t\t\t\tcl->rate = 1000;\n\t\t\t} else if (cl->rate > 90000) {\n\t\t\t\tcl->rate = 90000;\n\t\t\t}\n\t\t} else {\n\t\t\tcl->rate = 3000;\n\t\t}\n\t}\n\tval = Info_ValueForKey (cl->userinfo, \"handicap\");\n\tif (strlen(val)) {\n\t\ti = atoi(val);\n\t\tif (i<=0 || i>100 || strlen(val) > 4) {\n\t\t\tInfo_SetValueForKey( cl->userinfo, \"handicap\", \"100\" );\n\t\t}\n\t}\n\n\t// snaps command\n\tval = Info_ValueForKey (cl->userinfo, \"snaps\");\n\tif (strlen(val)) {\n\t\ti = atoi(val);\n\t\tif ( i < 1 ) {\n\t\t\ti = 1;\n\t\t} else if ( i > 30 ) {\n\t\t\ti = 30;\n\t\t}\n\t\tcl->snapshotMsec = 1000/i;\n\t} else {\n\t\tcl->snapshotMsec = 50;\n\t}\n\t\n\t// TTimo\n\t// maintain the IP information\n\t// this is set in SV_DirectConnect (directly on the server, not transmitted), may be lost when client updates it's userinfo\n\t// the banning code relies on this being consistently present\n\tval = Info_ValueForKey (cl->userinfo, \"ip\");\n\tif (!val[0])\n\t{\n\t\t//Com_DPrintf(\"Maintain IP in userinfo for '%s'\\n\", cl->name);\n\t\tif ( !NET_IsLocalAddress(cl->netchan.remoteAddress) )\n\t\t\tInfo_SetValueForKey( cl->userinfo, \"ip\", NET_AdrToString( cl->netchan.remoteAddress ) );\n\t\telse\n\t\t\t// force the \"ip\" info key to \"localhost\" for local clients\n\t\t\tInfo_SetValueForKey( cl->userinfo, \"ip\", \"localhost\" );\n\t}\n}\n\n\n/*\n==================\nSV_UpdateUserinfo_f\n==================\n*/\nstatic void SV_UpdateUserinfo_f( client_t *cl ) {\n\tQ_strncpyz( cl->userinfo, Cmd_Argv(1), sizeof(cl->userinfo) );\n\n\tSV_UserinfoChanged( cl );\n\t// call prog code to allow overrides\n\tVM_Call( gvm, GAME_CLIENT_USERINFO_CHANGED, cl - svs.clients );\n}\n\ntypedef struct {\n\tchar\t*name;\n\tvoid\t(*func)( client_t *cl );\n} ucmd_t;\n\nstatic ucmd_t ucmds[] = {\n\t{\"userinfo\", SV_UpdateUserinfo_f},\n\t{\"disconnect\", SV_Disconnect_f},\n\t{\"cp\", SV_VerifyPaks_f},\n\t{\"vdr\", SV_ResetPureClient_f},\n\t{\"download\", SV_BeginDownload_f},\n\t{\"nextdl\", SV_NextDownload_f},\n\t{\"stopdl\", SV_StopDownload_f},\n\t{\"donedl\", SV_DoneDownload_f},\n\n\t{NULL, NULL}\n};\n\n/*\n==================\nSV_ExecuteClientCommand\n\nAlso called by bot code\n==================\n*/\nvoid SV_ExecuteClientCommand( client_t *cl, const char *s, qboolean clientOK ) {\n\tucmd_t\t*u;\n\tqboolean bProcessed = qfalse;\n\t\n\tCmd_TokenizeString( s );\n\n\t// see if it is a server level command\n\tfor (u=ucmds ; u->name ; u++) {\n\t\tif (!strcmp (Cmd_Argv(0), u->name) ) {\n\t\t\tu->func( cl );\n\t\t\tbProcessed = qtrue;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (clientOK) {\n\t\t// pass unknown strings to the game\n\t\tif (!u->name && sv.state == SS_GAME) {\n\t\t\tVM_Call( gvm, GAME_CLIENT_COMMAND, cl - svs.clients );\n\t\t}\n\t}\n\telse if (!bProcessed)\n\t\tCom_DPrintf( \"client text ignored for %s: %s\\n\", cl->name, Cmd_Argv(0) );\n}\n\n/*\n===============\nSV_ClientCommand\n===============\n*/\nstatic qboolean SV_ClientCommand( client_t *cl, msg_t *msg ) {\n\tint\t\tseq;\n\tconst char\t*s;\n\tqboolean clientOk = qtrue;\n\n\tseq = MSG_ReadLong( msg );\n\ts = MSG_ReadString( msg );\n\n\t// see if we have already executed it\n\tif ( cl->lastClientCommand >= seq ) {\n\t\treturn qtrue;\n\t}\n\n\tCom_DPrintf( \"clientCommand: %s : %i : %s\\n\", cl->name, seq, s );\n\n\t// drop the connection if we have somehow lost commands\n\tif ( seq > cl->lastClientCommand + 1 ) {\n\t\tCom_Printf( \"Client %s lost %i clientCommands\\n\", cl->name, \n\t\t\tseq - cl->lastClientCommand + 1 );\n\t\tSV_DropClient( cl, \"Lost reliable commands\" );\n\t\treturn qfalse;\n\t}\n\n\t// malicious users may try using too many string commands\n\t// to lag other players.  If we decide that we want to stall\n\t// the command, we will stop processing the rest of the packet,\n\t// including the usercmd.  This causes flooders to lag themselves\n\t// but not other people\n\t// We don't do this when the client hasn't been active yet since its\n\t// normal to spam a lot of commands when downloading\n\tif ( !com_cl_running->integer && \n\t\tcl->state >= CS_ACTIVE &&\n\t\tsv_floodProtect->integer && \n\t\tsvs.time < cl->nextReliableTime ) {\n\t\t// ignore any other text messages from this client but let them keep playing\n\t\t// TTimo - moved the ignored verbose to the actual processing in SV_ExecuteClientCommand, only printing if the core doesn't intercept\n\t\tclientOk = qfalse;\n\t} \n\n\t// don't allow another command for one second\n\tcl->nextReliableTime = svs.time + 1000;\n\n\tSV_ExecuteClientCommand( cl, s, clientOk );\n\n\tcl->lastClientCommand = seq;\n\tCom_sprintf(cl->lastClientCommandString, sizeof(cl->lastClientCommandString), \"%s\", s);\n\n\treturn qtrue;\t\t// continue procesing\n}\n\n\n//==================================================================================\n\n\n/*\n==================\nSV_ClientThink\n\nAlso called by bot code\n==================\n*/\nvoid SV_ClientThink (client_t *cl, usercmd_t *cmd) {\n\tcl->lastUsercmd = *cmd;\n\n\tif ( cl->state != CS_ACTIVE ) {\n\t\treturn;\t\t// may have been kicked during the last usercmd\n\t}\n\n\tVM_Call( gvm, GAME_CLIENT_THINK, cl - svs.clients );\n}\n\n/*\n==================\nSV_UserMove\n\nThe message usually contains all the movement commands \nthat were in the last three packets, so that the information\nin dropped packets can be recovered.\n\nOn very fast clients, there may be multiple usercmd packed into\neach of the backup packets.\n==================\n*/\nstatic void SV_UserMove( client_t *cl, msg_t *msg, qboolean delta ) {\n\tint\t\t\ti, key;\n\tint\t\t\tcmdCount;\n\tusercmd_t\tnullcmd;\n\tusercmd_t\tcmds[MAX_PACKET_USERCMDS];\n\tusercmd_t\t*cmd, *oldcmd;\n\n\tif ( delta ) {\n\t\tcl->deltaMessage = cl->messageAcknowledge;\n\t} else {\n\t\tcl->deltaMessage = -1;\n\t}\n\n\tcmdCount = MSG_ReadByte( msg );\n\n\tif ( cmdCount < 1 ) {\n\t\tCom_Printf( \"cmdCount < 1\\n\" );\n\t\treturn;\n\t}\n\n\tif ( cmdCount > MAX_PACKET_USERCMDS ) {\n\t\tCom_Printf( \"cmdCount > MAX_PACKET_USERCMDS\\n\" );\n\t\treturn;\n\t}\n\n\t// use the checksum feed in the key\n\tkey = sv.checksumFeed;\n\t// also use the message acknowledge\n\tkey ^= cl->messageAcknowledge;\n\t// also use the last acknowledged server command in the key\n\tkey ^= Com_HashKey(cl->reliableCommands[ cl->reliableAcknowledge & (MAX_RELIABLE_COMMANDS-1) ], 32);\n\n\tCom_Memset( &nullcmd, 0, sizeof(nullcmd) );\n\toldcmd = &nullcmd;\n\tfor ( i = 0 ; i < cmdCount ; i++ ) {\n\t\tcmd = &cmds[i];\n\t\tMSG_ReadDeltaUsercmdKey( msg, key, oldcmd, cmd );\n\t\toldcmd = cmd;\n\t}\n\n\t// save time for ping calculation\n\tcl->frames[ cl->messageAcknowledge & PACKET_MASK ].messageAcked = svs.time;\n\n\t// TTimo\n\t// catch the no-cp-yet situation before SV_ClientEnterWorld\n\t// if CS_ACTIVE, then it's time to trigger a new gamestate emission\n\t// if not, then we are getting remaining parasite usermove commands, which we should ignore\n\tif (sv_pure->integer != 0 && cl->pureAuthentic == 0 && !cl->gotCP) {\n\t\tif (cl->state == CS_ACTIVE)\n\t\t{\n\t\t\t// we didn't get a cp yet, don't assume anything and just send the gamestate all over again\n\t\t\tCom_DPrintf( \"%s: didn't get cp command, resending gamestate\\n\", cl->name, cl->state );\n\t\t\tSV_SendClientGameState( cl );\n\t\t}\n\t\treturn;\n\t}\t\t\t\n\t\n\t// if this is the first usercmd we have received\n\t// this gamestate, put the client into the world\n\tif ( cl->state == CS_PRIMED ) {\n\t\tSV_ClientEnterWorld( cl, &cmds[0] );\n\t\t// the moves can be processed normaly\n\t}\n\t\n\t// a bad cp command was sent, drop the client\n\tif (sv_pure->integer != 0 && cl->pureAuthentic == 0) {\t\t\n\t\tSV_DropClient( cl, \"Cannot validate pure client!\");\n\t\treturn;\n\t}\n\n\tif ( cl->state != CS_ACTIVE ) {\n\t\tcl->deltaMessage = -1;\n\t\treturn;\n\t}\n\n\t// usually, the first couple commands will be duplicates\n\t// of ones we have previously received, but the servertimes\n\t// in the commands will cause them to be immediately discarded\n\tfor ( i =  0 ; i < cmdCount ; i++ ) {\n\t\t// if this is a cmd from before a map_restart ignore it\n\t\tif ( cmds[i].serverTime > cmds[cmdCount-1].serverTime ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// extremely lagged or cmd from before a map_restart\n\t\t//if ( cmds[i].serverTime > svs.time + 3000 ) {\n\t\t//\tcontinue;\n\t\t//}\n\t\t// don't execute if this is an old cmd which is already executed\n\t\t// these old cmds are included when cl_packetdup > 0\n\t\tif ( cmds[i].serverTime <= cl->lastUsercmd.serverTime ) {\n\t\t\tcontinue;\n\t\t}\n\t\tSV_ClientThink (cl, &cmds[ i ]);\n\t}\n}\n\n\n/*\n===========================================================================\n\nUSER CMD EXECUTION\n\n===========================================================================\n*/\n\n/*\n===================\nSV_ExecuteClientMessage\n\nParse a client packet\n===================\n*/\nvoid SV_ExecuteClientMessage( client_t *cl, msg_t *msg ) {\n\tint\t\t\tc;\n\tint\t\t\tserverId;\n\n\tMSG_Bitstream(msg);\n\n\tserverId = MSG_ReadLong( msg );\n\tcl->messageAcknowledge = MSG_ReadLong( msg );\n\n\tif (cl->messageAcknowledge < 0) {\n\t\t// usually only hackers create messages like this\n\t\t// it is more annoying for them to let them hanging\n#ifndef NDEBUG\n\t\tSV_DropClient( cl, \"DEBUG: illegible client message\" );\n#endif\n\t\treturn;\n\t}\n\n\tcl->reliableAcknowledge = MSG_ReadLong( msg );\n\n\t// NOTE: when the client message is fux0red the acknowledgement numbers\n\t// can be out of range, this could cause the server to send thousands of server\n\t// commands which the server thinks are not yet acknowledged in SV_UpdateServerCommandsToClient\n\tif (cl->reliableAcknowledge < cl->reliableSequence - MAX_RELIABLE_COMMANDS) {\n\t\t// usually only hackers create messages like this\n\t\t// it is more annoying for them to let them hanging\n#ifndef NDEBUG\n\t\tSV_DropClient( cl, \"DEBUG: illegible client message\" );\n#endif\n\t\tcl->reliableAcknowledge = cl->reliableSequence;\n\t\treturn;\n\t}\n\t// if this is a usercmd from a previous gamestate,\n\t// ignore it or retransmit the current gamestate\n\t// \n\t// if the client was downloading, let it stay at whatever serverId and\n\t// gamestate it was at.  This allows it to keep downloading even when\n\t// the gamestate changes.  After the download is finished, we'll\n\t// notice and send it a new game state\n\t//\n\t// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=536\n\t// don't drop as long as previous command was a nextdl, after a dl is done, downloadName is set back to \"\"\n\t// but we still need to read the next message to move to next download or send gamestate\n\t// I don't like this hack though, it must have been working fine at some point, suspecting the fix is somewhere else\n\tif ( serverId != sv.serverId && !*cl->downloadName && !strstr(cl->lastClientCommandString, \"nextdl\") ) {\n\t\tif ( serverId >= sv.restartedServerId && serverId < sv.serverId ) { // TTimo - use a comparison here to catch multiple map_restart\n\t\t\t// they just haven't caught the map_restart yet\n\t\t\tCom_DPrintf(\"%s : ignoring pre map_restart / outdated client message\\n\", cl->name);\n\t\t\treturn;\n\t\t}\n\t\t// if we can tell that the client has dropped the last\n\t\t// gamestate we sent them, resend it\n\t\tif ( cl->messageAcknowledge > cl->gamestateMessageNum ) {\n\t\t\tCom_DPrintf( \"%s : dropped gamestate, resending\\n\", cl->name );\n\t\t\tSV_SendClientGameState( cl );\n\t\t}\n\t\treturn;\n\t}\n\n\t// read optional clientCommand strings\n\tdo {\n\t\tc = MSG_ReadByte( msg );\n\t\tif ( c == clc_EOF ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( c != clc_clientCommand ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( !SV_ClientCommand( cl, msg ) ) {\n\t\t\treturn;\t// we couldn't execute it because of the flood protection\n\t\t}\n\t\tif (cl->state == CS_ZOMBIE) {\n\t\t\treturn;\t// disconnect command\n\t\t}\n\t} while ( 1 );\n\n\t// read the usercmd_t\n\tif ( c == clc_move ) {\n\t\tSV_UserMove( cl, msg, qtrue );\n\t} else if ( c == clc_moveNoDelta ) {\n\t\tSV_UserMove( cl, msg, qfalse );\n\t} else if ( c != clc_EOF ) {\n\t\tCom_Printf( \"WARNING: bad command byte for client %i\\n\", cl - svs.clients );\n\t}\n//\tif ( msg->readcount != msg->cursize ) {\n//\t\tCom_Printf( \"WARNING: Junk at end of packet for client %i\\n\", cl - svs.clients );\n//\t}\n}\n"
  },
  {
    "path": "code/server/sv_game.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// sv_game.c -- interface to the game dll\n\n#include \"server.h\"\n\n#include \"../game/botlib.h\"\n\nbotlib_export_t\t*botlib_export;\n\nvoid SV_GameError( const char *string ) {\n\tCom_Error( ERR_DROP, \"%s\", string );\n}\n\nvoid SV_GamePrint( const char *string ) {\n\tCom_Printf( \"%s\", string );\n}\n\n// these functions must be used instead of pointer arithmetic, because\n// the game allocates gentities with private information after the server shared part\nint\tSV_NumForGentity( sharedEntity_t *ent ) {\n\tint\t\tnum;\n\n\tnum = ( (byte *)ent - (byte *)sv.gentities ) / sv.gentitySize;\n\n\treturn num;\n}\n\nsharedEntity_t *SV_GentityNum( int num ) {\n\tsharedEntity_t *ent;\n\n\tent = (sharedEntity_t *)((byte *)sv.gentities + sv.gentitySize*(num));\n\n\treturn ent;\n}\n\nplayerState_t *SV_GameClientNum( int num ) {\n\tplayerState_t\t*ps;\n\n\tps = (playerState_t *)((byte *)sv.gameClients + sv.gameClientSize*(num));\n\n\treturn ps;\n}\n\nsvEntity_t\t*SV_SvEntityForGentity( sharedEntity_t *gEnt ) {\n\tif ( !gEnt || gEnt->s.number < 0 || gEnt->s.number >= MAX_GENTITIES ) {\n\t\tCom_Error( ERR_DROP, \"SV_SvEntityForGentity: bad gEnt\" );\n\t}\n\treturn &sv.svEntities[ gEnt->s.number ];\n}\n\nsharedEntity_t *SV_GEntityForSvEntity( svEntity_t *svEnt ) {\n\tint\t\tnum;\n\n\tnum = svEnt - sv.svEntities;\n\treturn SV_GentityNum( num );\n}\n\n/*\n===============\nSV_GameSendServerCommand\n\nSends a command string to a client\n===============\n*/\nvoid SV_GameSendServerCommand( int clientNum, const char *text ) {\n\tif ( clientNum == -1 ) {\n\t\tSV_SendServerCommand( NULL, \"%s\", text );\n\t} else {\n\t\tif ( clientNum < 0 || clientNum >= sv_maxclients->integer ) {\n\t\t\treturn;\n\t\t}\n\t\tSV_SendServerCommand( svs.clients + clientNum, \"%s\", text );\t\n\t}\n}\n\n\n/*\n===============\nSV_GameDropClient\n\nDisconnects the client with a message\n===============\n*/\nvoid SV_GameDropClient( int clientNum, const char *reason ) {\n\tif ( clientNum < 0 || clientNum >= sv_maxclients->integer ) {\n\t\treturn;\n\t}\n\tSV_DropClient( svs.clients + clientNum, reason );\t\n}\n\n\n/*\n=================\nSV_SetBrushModel\n\nsets mins and maxs for inline bmodels\n=================\n*/\nvoid SV_SetBrushModel( sharedEntity_t *ent, const char *name ) {\n\tclipHandle_t\th;\n\tvec3_t\t\t\tmins, maxs;\n\n\tif (!name) {\n\t\tCom_Error( ERR_DROP, \"SV_SetBrushModel: NULL\" );\n\t}\n\n\tif (name[0] != '*') {\n\t\tCom_Error( ERR_DROP, \"SV_SetBrushModel: %s isn't a brush model\", name );\n\t}\n\n\n\tent->s.modelindex = atoi( name + 1 );\n\n\th = CM_InlineModel( ent->s.modelindex );\n\tCM_ModelBounds( h, mins, maxs );\n\tVectorCopy (mins, ent->r.mins);\n\tVectorCopy (maxs, ent->r.maxs);\n\tent->r.bmodel = qtrue;\n\n\tent->r.contents = -1;\t\t// we don't know exactly what is in the brushes\n\n\tSV_LinkEntity( ent );\t\t// FIXME: remove\n}\n\n\n\n/*\n=================\nSV_inPVS\n\nAlso checks portalareas so that doors block sight\n=================\n*/\nqboolean SV_inPVS (const vec3_t p1, const vec3_t p2)\n{\n\tint\t\tleafnum;\n\tint\t\tcluster;\n\tint\t\tarea1, area2;\n\tbyte\t*mask;\n\n\tleafnum = CM_PointLeafnum (p1);\n\tcluster = CM_LeafCluster (leafnum);\n\tarea1 = CM_LeafArea (leafnum);\n\tmask = CM_ClusterPVS (cluster);\n\n\tleafnum = CM_PointLeafnum (p2);\n\tcluster = CM_LeafCluster (leafnum);\n\tarea2 = CM_LeafArea (leafnum);\n\tif ( mask && (!(mask[cluster>>3] & (1<<(cluster&7)) ) ) )\n\t\treturn qfalse;\n\tif (!CM_AreasConnected (area1, area2))\n\t\treturn qfalse;\t\t// a door blocks sight\n\treturn qtrue;\n}\n\n\n/*\n=================\nSV_inPVSIgnorePortals\n\nDoes NOT check portalareas\n=================\n*/\nqboolean SV_inPVSIgnorePortals( const vec3_t p1, const vec3_t p2)\n{\n\tint\t\tleafnum;\n\tint\t\tcluster;\n\tint\t\tarea1, area2;\n\tbyte\t*mask;\n\n\tleafnum = CM_PointLeafnum (p1);\n\tcluster = CM_LeafCluster (leafnum);\n\tarea1 = CM_LeafArea (leafnum);\n\tmask = CM_ClusterPVS (cluster);\n\n\tleafnum = CM_PointLeafnum (p2);\n\tcluster = CM_LeafCluster (leafnum);\n\tarea2 = CM_LeafArea (leafnum);\n\n\tif ( mask && (!(mask[cluster>>3] & (1<<(cluster&7)) ) ) )\n\t\treturn qfalse;\n\n\treturn qtrue;\n}\n\n\n/*\n========================\nSV_AdjustAreaPortalState\n========================\n*/\nvoid SV_AdjustAreaPortalState( sharedEntity_t *ent, qboolean open ) {\n\tsvEntity_t\t*svEnt;\n\n\tsvEnt = SV_SvEntityForGentity( ent );\n\tif ( svEnt->areanum2 == -1 ) {\n\t\treturn;\n\t}\n\tCM_AdjustAreaPortalState( svEnt->areanum, svEnt->areanum2, open );\n}\n\n\n/*\n==================\nSV_GameAreaEntities\n==================\n*/\nqboolean\tSV_EntityContact( vec3_t mins, vec3_t maxs, const sharedEntity_t *gEnt, int capsule ) {\n\tconst float\t*origin, *angles;\n\tclipHandle_t\tch;\n\ttrace_t\t\t\ttrace;\n\n\t// check for exact collision\n\torigin = gEnt->r.currentOrigin;\n\tangles = gEnt->r.currentAngles;\n\n\tch = SV_ClipHandleForEntity( gEnt );\n\tCM_TransformedBoxTrace ( &trace, vec3_origin, vec3_origin, mins, maxs,\n\t\tch, -1, origin, angles, capsule );\n\n\treturn trace.startsolid;\n}\n\n\n/*\n===============\nSV_GetServerinfo\n\n===============\n*/\nvoid SV_GetServerinfo( char *buffer, int bufferSize ) {\n\tif ( bufferSize < 1 ) {\n\t\tCom_Error( ERR_DROP, \"SV_GetServerinfo: bufferSize == %i\", bufferSize );\n\t}\n\tQ_strncpyz( buffer, Cvar_InfoString( CVAR_SERVERINFO ), bufferSize );\n}\n\n/*\n===============\nSV_LocateGameData\n\n===============\n*/\nvoid SV_LocateGameData( sharedEntity_t *gEnts, int numGEntities, int sizeofGEntity_t,\n\t\t\t\t\t   playerState_t *clients, int sizeofGameClient ) {\n\tsv.gentities = gEnts;\n\tsv.gentitySize = sizeofGEntity_t;\n\tsv.num_entities = numGEntities;\n\n\tsv.gameClients = clients;\n\tsv.gameClientSize = sizeofGameClient;\n}\n\n\n/*\n===============\nSV_GetUsercmd\n\n===============\n*/\nvoid SV_GetUsercmd( int clientNum, usercmd_t *cmd ) {\n\tif ( clientNum < 0 || clientNum >= sv_maxclients->integer ) {\n\t\tCom_Error( ERR_DROP, \"SV_GetUsercmd: bad clientNum:%i\", clientNum );\n\t}\n\t*cmd = svs.clients[clientNum].lastUsercmd;\n}\n\n//==============================================\n\nstatic int\tFloatAsInt( float f ) {\n\tunion\n\t{\n\t    int i;\n\t    float f;\n\t} temp;\n\t\n\ttemp.f = f;\n\treturn temp.i;\n}\n\n/*\n====================\nSV_GameSystemCalls\n\nThe module is making a system call\n====================\n*/\n//rcg010207 - see my comments in VM_DllSyscall(), in qcommon/vm.c ...\n#if ((defined __linux__) && (defined __powerpc__))\n#define VMA(x) ((void *) args[x])\n#else\n#define\tVMA(x) VM_ArgPtr(args[x])\n#endif\n\n#define\tVMF(x)\t((float *)args)[x]\n\nint SV_GameSystemCalls( int *args ) {\n\tswitch( args[0] ) {\n\tcase G_PRINT:\n\t\tCom_Printf( \"%s\", VMA(1) );\n\t\treturn 0;\n\tcase G_ERROR:\n\t\tCom_Error( ERR_DROP, \"%s\", VMA(1) );\n\t\treturn 0;\n\tcase G_MILLISECONDS:\n\t\treturn Sys_Milliseconds();\n\tcase G_CVAR_REGISTER:\n\t\tCvar_Register( VMA(1), VMA(2), VMA(3), args[4] ); \n\t\treturn 0;\n\tcase G_CVAR_UPDATE:\n\t\tCvar_Update( VMA(1) );\n\t\treturn 0;\n\tcase G_CVAR_SET:\n\t\tCvar_Set( (const char *)VMA(1), (const char *)VMA(2) );\n\t\treturn 0;\n\tcase G_CVAR_VARIABLE_INTEGER_VALUE:\n\t\treturn Cvar_VariableIntegerValue( (const char *)VMA(1) );\n\tcase G_CVAR_VARIABLE_STRING_BUFFER:\n\t\tCvar_VariableStringBuffer( VMA(1), VMA(2), args[3] );\n\t\treturn 0;\n\tcase G_ARGC:\n\t\treturn Cmd_Argc();\n\tcase G_ARGV:\n\t\tCmd_ArgvBuffer( args[1], VMA(2), args[3] );\n\t\treturn 0;\n\tcase G_SEND_CONSOLE_COMMAND:\n\t\tCbuf_ExecuteText( args[1], VMA(2) );\n\t\treturn 0;\n\n\tcase G_FS_FOPEN_FILE:\n\t\treturn FS_FOpenFileByMode( VMA(1), VMA(2), args[3] );\n\tcase G_FS_READ:\n\t\tFS_Read2( VMA(1), args[2], args[3] );\n\t\treturn 0;\n\tcase G_FS_WRITE:\n\t\tFS_Write( VMA(1), args[2], args[3] );\n\t\treturn 0;\n\tcase G_FS_FCLOSE_FILE:\n\t\tFS_FCloseFile( args[1] );\n\t\treturn 0;\n\tcase G_FS_GETFILELIST:\n\t\treturn FS_GetFileList( VMA(1), VMA(2), VMA(3), args[4] );\n\tcase G_FS_SEEK:\n\t\treturn FS_Seek( args[1], args[2], args[3] );\n\n\tcase G_LOCATE_GAME_DATA:\n\t\tSV_LocateGameData( VMA(1), args[2], args[3], VMA(4), args[5] );\n\t\treturn 0;\n\tcase G_DROP_CLIENT:\n\t\tSV_GameDropClient( args[1], VMA(2) );\n\t\treturn 0;\n\tcase G_SEND_SERVER_COMMAND:\n\t\tSV_GameSendServerCommand( args[1], VMA(2) );\n\t\treturn 0;\n\tcase G_LINKENTITY:\n\t\tSV_LinkEntity( VMA(1) );\n\t\treturn 0;\n\tcase G_UNLINKENTITY:\n\t\tSV_UnlinkEntity( VMA(1) );\n\t\treturn 0;\n\tcase G_ENTITIES_IN_BOX:\n\t\treturn SV_AreaEntities( VMA(1), VMA(2), VMA(3), args[4] );\n\tcase G_ENTITY_CONTACT:\n\t\treturn SV_EntityContact( VMA(1), VMA(2), VMA(3), /*int capsule*/ qfalse );\n\tcase G_ENTITY_CONTACTCAPSULE:\n\t\treturn SV_EntityContact( VMA(1), VMA(2), VMA(3), /*int capsule*/ qtrue );\n\tcase G_TRACE:\n\t\tSV_Trace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule*/ qfalse );\n\t\treturn 0;\n\tcase G_TRACECAPSULE:\n\t\tSV_Trace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule*/ qtrue );\n\t\treturn 0;\n\tcase G_POINT_CONTENTS:\n\t\treturn SV_PointContents( VMA(1), args[2] );\n\tcase G_SET_BRUSH_MODEL:\n\t\tSV_SetBrushModel( VMA(1), VMA(2) );\n\t\treturn 0;\n\tcase G_IN_PVS:\n\t\treturn SV_inPVS( VMA(1), VMA(2) );\n\tcase G_IN_PVS_IGNORE_PORTALS:\n\t\treturn SV_inPVSIgnorePortals( VMA(1), VMA(2) );\n\n\tcase G_SET_CONFIGSTRING:\n\t\tSV_SetConfigstring( args[1], VMA(2) );\n\t\treturn 0;\n\tcase G_GET_CONFIGSTRING:\n\t\tSV_GetConfigstring( args[1], VMA(2), args[3] );\n\t\treturn 0;\n\tcase G_SET_USERINFO:\n\t\tSV_SetUserinfo( args[1], VMA(2) );\n\t\treturn 0;\n\tcase G_GET_USERINFO:\n\t\tSV_GetUserinfo( args[1], VMA(2), args[3] );\n\t\treturn 0;\n\tcase G_GET_SERVERINFO:\n\t\tSV_GetServerinfo( VMA(1), args[2] );\n\t\treturn 0;\n\tcase G_ADJUST_AREA_PORTAL_STATE:\n\t\tSV_AdjustAreaPortalState( VMA(1), args[2] );\n\t\treturn 0;\n\tcase G_AREAS_CONNECTED:\n\t\treturn CM_AreasConnected( args[1], args[2] );\n\n\tcase G_BOT_ALLOCATE_CLIENT:\n\t\treturn SV_BotAllocateClient();\n\tcase G_BOT_FREE_CLIENT:\n\t\tSV_BotFreeClient( args[1] );\n\t\treturn 0;\n\n\tcase G_GET_USERCMD:\n\t\tSV_GetUsercmd( args[1], VMA(2) );\n\t\treturn 0;\n\tcase G_GET_ENTITY_TOKEN:\n\t\t{\n\t\t\tconst char\t*s;\n\n\t\t\ts = COM_Parse( &sv.entityParsePoint );\n\t\t\tQ_strncpyz( VMA(1), s, args[2] );\n\t\t\tif ( !sv.entityParsePoint && !s[0] ) {\n\t\t\t\treturn qfalse;\n\t\t\t} else {\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t}\n\n\tcase G_DEBUG_POLYGON_CREATE:\n\t\treturn BotImport_DebugPolygonCreate( args[1], args[2], VMA(3) );\n\tcase G_DEBUG_POLYGON_DELETE:\n\t\tBotImport_DebugPolygonDelete( args[1] );\n\t\treturn 0;\n\tcase G_REAL_TIME:\n\t\treturn Com_RealTime( VMA(1) );\n\tcase G_SNAPVECTOR:\n\t\tSys_SnapVector( VMA(1) );\n\t\treturn 0;\n\n\t\t//====================================\n\n\tcase BOTLIB_SETUP:\n\t\treturn SV_BotLibSetup();\n\tcase BOTLIB_SHUTDOWN:\n\t\treturn SV_BotLibShutdown();\n\tcase BOTLIB_LIBVAR_SET:\n\t\treturn botlib_export->BotLibVarSet( VMA(1), VMA(2) );\n\tcase BOTLIB_LIBVAR_GET:\n\t\treturn botlib_export->BotLibVarGet( VMA(1), VMA(2), args[3] );\n\n\tcase BOTLIB_PC_ADD_GLOBAL_DEFINE:\n\t\treturn botlib_export->PC_AddGlobalDefine( VMA(1) );\n\tcase BOTLIB_PC_LOAD_SOURCE:\n\t\treturn botlib_export->PC_LoadSourceHandle( VMA(1) );\n\tcase BOTLIB_PC_FREE_SOURCE:\n\t\treturn botlib_export->PC_FreeSourceHandle( args[1] );\n\tcase BOTLIB_PC_READ_TOKEN:\n\t\treturn botlib_export->PC_ReadTokenHandle( args[1], VMA(2) );\n\tcase BOTLIB_PC_SOURCE_FILE_AND_LINE:\n\t\treturn botlib_export->PC_SourceFileAndLine( args[1], VMA(2), VMA(3) );\n\n\tcase BOTLIB_START_FRAME:\n\t\treturn botlib_export->BotLibStartFrame( VMF(1) );\n\tcase BOTLIB_LOAD_MAP:\n\t\treturn botlib_export->BotLibLoadMap( VMA(1) );\n\tcase BOTLIB_UPDATENTITY:\n\t\treturn botlib_export->BotLibUpdateEntity( args[1], VMA(2) );\n\tcase BOTLIB_TEST:\n\t\treturn botlib_export->Test( args[1], VMA(2), VMA(3), VMA(4) );\n\n\tcase BOTLIB_GET_SNAPSHOT_ENTITY:\n\t\treturn SV_BotGetSnapshotEntity( args[1], args[2] );\n\tcase BOTLIB_GET_CONSOLE_MESSAGE:\n\t\treturn SV_BotGetConsoleMessage( args[1], VMA(2), args[3] );\n\tcase BOTLIB_USER_COMMAND:\n\t\tSV_ClientThink( &svs.clients[args[1]], VMA(2) );\n\t\treturn 0;\n\n\tcase BOTLIB_AAS_BBOX_AREAS:\n\t\treturn botlib_export->aas.AAS_BBoxAreas( VMA(1), VMA(2), VMA(3), args[4] );\n\tcase BOTLIB_AAS_AREA_INFO:\n\t\treturn botlib_export->aas.AAS_AreaInfo( args[1], VMA(2) );\n\tcase BOTLIB_AAS_ALTERNATIVE_ROUTE_GOAL:\n\t\treturn botlib_export->aas.AAS_AlternativeRouteGoals( VMA(1), args[2], VMA(3), args[4], args[5], VMA(6), args[7], args[8] );\n\tcase BOTLIB_AAS_ENTITY_INFO:\n\t\tbotlib_export->aas.AAS_EntityInfo( args[1], VMA(2) );\n\t\treturn 0;\n\n\tcase BOTLIB_AAS_INITIALIZED:\n\t\treturn botlib_export->aas.AAS_Initialized();\n\tcase BOTLIB_AAS_PRESENCE_TYPE_BOUNDING_BOX:\n\t\tbotlib_export->aas.AAS_PresenceTypeBoundingBox( args[1], VMA(2), VMA(3) );\n\t\treturn 0;\n\tcase BOTLIB_AAS_TIME:\n\t\treturn FloatAsInt( botlib_export->aas.AAS_Time() );\n\n\tcase BOTLIB_AAS_POINT_AREA_NUM:\n\t\treturn botlib_export->aas.AAS_PointAreaNum( VMA(1) );\n\tcase BOTLIB_AAS_POINT_REACHABILITY_AREA_INDEX:\n\t\treturn botlib_export->aas.AAS_PointReachabilityAreaIndex( VMA(1) );\n\tcase BOTLIB_AAS_TRACE_AREAS:\n\t\treturn botlib_export->aas.AAS_TraceAreas( VMA(1), VMA(2), VMA(3), VMA(4), args[5] );\n\n\tcase BOTLIB_AAS_POINT_CONTENTS:\n\t\treturn botlib_export->aas.AAS_PointContents( VMA(1) );\n\tcase BOTLIB_AAS_NEXT_BSP_ENTITY:\n\t\treturn botlib_export->aas.AAS_NextBSPEntity( args[1] );\n\tcase BOTLIB_AAS_VALUE_FOR_BSP_EPAIR_KEY:\n\t\treturn botlib_export->aas.AAS_ValueForBSPEpairKey( args[1], VMA(2), VMA(3), args[4] );\n\tcase BOTLIB_AAS_VECTOR_FOR_BSP_EPAIR_KEY:\n\t\treturn botlib_export->aas.AAS_VectorForBSPEpairKey( args[1], VMA(2), VMA(3) );\n\tcase BOTLIB_AAS_FLOAT_FOR_BSP_EPAIR_KEY:\n\t\treturn botlib_export->aas.AAS_FloatForBSPEpairKey( args[1], VMA(2), VMA(3) );\n\tcase BOTLIB_AAS_INT_FOR_BSP_EPAIR_KEY:\n\t\treturn botlib_export->aas.AAS_IntForBSPEpairKey( args[1], VMA(2), VMA(3) );\n\n\tcase BOTLIB_AAS_AREA_REACHABILITY:\n\t\treturn botlib_export->aas.AAS_AreaReachability( args[1] );\n\n\tcase BOTLIB_AAS_AREA_TRAVEL_TIME_TO_GOAL_AREA:\n\t\treturn botlib_export->aas.AAS_AreaTravelTimeToGoalArea( args[1], VMA(2), args[3], args[4] );\n\tcase BOTLIB_AAS_ENABLE_ROUTING_AREA:\n\t\treturn botlib_export->aas.AAS_EnableRoutingArea( args[1], args[2] );\n\tcase BOTLIB_AAS_PREDICT_ROUTE:\n\t\treturn botlib_export->aas.AAS_PredictRoute( VMA(1), args[2], VMA(3), args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11] );\n\n\tcase BOTLIB_AAS_SWIMMING:\n\t\treturn botlib_export->aas.AAS_Swimming( VMA(1) );\n\tcase BOTLIB_AAS_PREDICT_CLIENT_MOVEMENT:\n\t\treturn botlib_export->aas.AAS_PredictClientMovement( VMA(1), args[2], VMA(3), args[4], args[5],\n\t\t\tVMA(6), VMA(7), args[8], args[9], VMF(10), args[11], args[12], args[13] );\n\n\tcase BOTLIB_EA_SAY:\n\t\tbotlib_export->ea.EA_Say( args[1], VMA(2) );\n\t\treturn 0;\n\tcase BOTLIB_EA_SAY_TEAM:\n\t\tbotlib_export->ea.EA_SayTeam( args[1], VMA(2) );\n\t\treturn 0;\n\tcase BOTLIB_EA_COMMAND:\n\t\tbotlib_export->ea.EA_Command( args[1], VMA(2) );\n\t\treturn 0;\n\n\tcase BOTLIB_EA_ACTION:\n\t\tbotlib_export->ea.EA_Action( args[1], args[2] );\n\t\tbreak;\n\tcase BOTLIB_EA_GESTURE:\n\t\tbotlib_export->ea.EA_Gesture( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_EA_TALK:\n\t\tbotlib_export->ea.EA_Talk( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_EA_ATTACK:\n\t\tbotlib_export->ea.EA_Attack( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_EA_USE:\n\t\tbotlib_export->ea.EA_Use( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_EA_RESPAWN:\n\t\tbotlib_export->ea.EA_Respawn( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_EA_CROUCH:\n\t\tbotlib_export->ea.EA_Crouch( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_EA_MOVE_UP:\n\t\tbotlib_export->ea.EA_MoveUp( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_EA_MOVE_DOWN:\n\t\tbotlib_export->ea.EA_MoveDown( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_EA_MOVE_FORWARD:\n\t\tbotlib_export->ea.EA_MoveForward( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_EA_MOVE_BACK:\n\t\tbotlib_export->ea.EA_MoveBack( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_EA_MOVE_LEFT:\n\t\tbotlib_export->ea.EA_MoveLeft( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_EA_MOVE_RIGHT:\n\t\tbotlib_export->ea.EA_MoveRight( args[1] );\n\t\treturn 0;\n\n\tcase BOTLIB_EA_SELECT_WEAPON:\n\t\tbotlib_export->ea.EA_SelectWeapon( args[1], args[2] );\n\t\treturn 0;\n\tcase BOTLIB_EA_JUMP:\n\t\tbotlib_export->ea.EA_Jump( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_EA_DELAYED_JUMP:\n\t\tbotlib_export->ea.EA_DelayedJump( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_EA_MOVE:\n\t\tbotlib_export->ea.EA_Move( args[1], VMA(2), VMF(3) );\n\t\treturn 0;\n\tcase BOTLIB_EA_VIEW:\n\t\tbotlib_export->ea.EA_View( args[1], VMA(2) );\n\t\treturn 0;\n\n\tcase BOTLIB_EA_END_REGULAR:\n\t\tbotlib_export->ea.EA_EndRegular( args[1], VMF(2) );\n\t\treturn 0;\n\tcase BOTLIB_EA_GET_INPUT:\n\t\tbotlib_export->ea.EA_GetInput( args[1], VMF(2), VMA(3) );\n\t\treturn 0;\n\tcase BOTLIB_EA_RESET_INPUT:\n\t\tbotlib_export->ea.EA_ResetInput( args[1] );\n\t\treturn 0;\n\n\tcase BOTLIB_AI_LOAD_CHARACTER:\n\t\treturn botlib_export->ai.BotLoadCharacter( VMA(1), VMF(2) );\n\tcase BOTLIB_AI_FREE_CHARACTER:\n\t\tbotlib_export->ai.BotFreeCharacter( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_AI_CHARACTERISTIC_FLOAT:\n\t\treturn FloatAsInt( botlib_export->ai.Characteristic_Float( args[1], args[2] ) );\n\tcase BOTLIB_AI_CHARACTERISTIC_BFLOAT:\n\t\treturn FloatAsInt( botlib_export->ai.Characteristic_BFloat( args[1], args[2], VMF(3), VMF(4) ) );\n\tcase BOTLIB_AI_CHARACTERISTIC_INTEGER:\n\t\treturn botlib_export->ai.Characteristic_Integer( args[1], args[2] );\n\tcase BOTLIB_AI_CHARACTERISTIC_BINTEGER:\n\t\treturn botlib_export->ai.Characteristic_BInteger( args[1], args[2], args[3], args[4] );\n\tcase BOTLIB_AI_CHARACTERISTIC_STRING:\n\t\tbotlib_export->ai.Characteristic_String( args[1], args[2], VMA(3), args[4] );\n\t\treturn 0;\n\n\tcase BOTLIB_AI_ALLOC_CHAT_STATE:\n\t\treturn botlib_export->ai.BotAllocChatState();\n\tcase BOTLIB_AI_FREE_CHAT_STATE:\n\t\tbotlib_export->ai.BotFreeChatState( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_AI_QUEUE_CONSOLE_MESSAGE:\n\t\tbotlib_export->ai.BotQueueConsoleMessage( args[1], args[2], VMA(3) );\n\t\treturn 0;\n\tcase BOTLIB_AI_REMOVE_CONSOLE_MESSAGE:\n\t\tbotlib_export->ai.BotRemoveConsoleMessage( args[1], args[2] );\n\t\treturn 0;\n\tcase BOTLIB_AI_NEXT_CONSOLE_MESSAGE:\n\t\treturn botlib_export->ai.BotNextConsoleMessage( args[1], VMA(2) );\n\tcase BOTLIB_AI_NUM_CONSOLE_MESSAGE:\n\t\treturn botlib_export->ai.BotNumConsoleMessages( args[1] );\n\tcase BOTLIB_AI_INITIAL_CHAT:\n\t\tbotlib_export->ai.BotInitialChat( args[1], VMA(2), args[3], VMA(4), VMA(5), VMA(6), VMA(7), VMA(8), VMA(9), VMA(10), VMA(11) );\n\t\treturn 0;\n\tcase BOTLIB_AI_NUM_INITIAL_CHATS:\n\t\treturn botlib_export->ai.BotNumInitialChats( args[1], VMA(2) );\n\tcase BOTLIB_AI_REPLY_CHAT:\n\t\treturn botlib_export->ai.BotReplyChat( args[1], VMA(2), args[3], args[4], VMA(5), VMA(6), VMA(7), VMA(8), VMA(9), VMA(10), VMA(11), VMA(12) );\n\tcase BOTLIB_AI_CHAT_LENGTH:\n\t\treturn botlib_export->ai.BotChatLength( args[1] );\n\tcase BOTLIB_AI_ENTER_CHAT:\n\t\tbotlib_export->ai.BotEnterChat( args[1], args[2], args[3] );\n\t\treturn 0;\n\tcase BOTLIB_AI_GET_CHAT_MESSAGE:\n\t\tbotlib_export->ai.BotGetChatMessage( args[1], VMA(2), args[3] );\n\t\treturn 0;\n\tcase BOTLIB_AI_STRING_CONTAINS:\n\t\treturn botlib_export->ai.StringContains( VMA(1), VMA(2), args[3] );\n\tcase BOTLIB_AI_FIND_MATCH:\n\t\treturn botlib_export->ai.BotFindMatch( VMA(1), VMA(2), args[3] );\n\tcase BOTLIB_AI_MATCH_VARIABLE:\n\t\tbotlib_export->ai.BotMatchVariable( VMA(1), args[2], VMA(3), args[4] );\n\t\treturn 0;\n\tcase BOTLIB_AI_UNIFY_WHITE_SPACES:\n\t\tbotlib_export->ai.UnifyWhiteSpaces( VMA(1) );\n\t\treturn 0;\n\tcase BOTLIB_AI_REPLACE_SYNONYMS:\n\t\tbotlib_export->ai.BotReplaceSynonyms( VMA(1), args[2] );\n\t\treturn 0;\n\tcase BOTLIB_AI_LOAD_CHAT_FILE:\n\t\treturn botlib_export->ai.BotLoadChatFile( args[1], VMA(2), VMA(3) );\n\tcase BOTLIB_AI_SET_CHAT_GENDER:\n\t\tbotlib_export->ai.BotSetChatGender( args[1], args[2] );\n\t\treturn 0;\n\tcase BOTLIB_AI_SET_CHAT_NAME:\n\t\tbotlib_export->ai.BotSetChatName( args[1], VMA(2), args[3] );\n\t\treturn 0;\n\n\tcase BOTLIB_AI_RESET_GOAL_STATE:\n\t\tbotlib_export->ai.BotResetGoalState( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_AI_RESET_AVOID_GOALS:\n\t\tbotlib_export->ai.BotResetAvoidGoals( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_AI_REMOVE_FROM_AVOID_GOALS:\n\t\tbotlib_export->ai.BotRemoveFromAvoidGoals( args[1], args[2] );\n\t\treturn 0;\n\tcase BOTLIB_AI_PUSH_GOAL:\n\t\tbotlib_export->ai.BotPushGoal( args[1], VMA(2) );\n\t\treturn 0;\n\tcase BOTLIB_AI_POP_GOAL:\n\t\tbotlib_export->ai.BotPopGoal( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_AI_EMPTY_GOAL_STACK:\n\t\tbotlib_export->ai.BotEmptyGoalStack( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_AI_DUMP_AVOID_GOALS:\n\t\tbotlib_export->ai.BotDumpAvoidGoals( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_AI_DUMP_GOAL_STACK:\n\t\tbotlib_export->ai.BotDumpGoalStack( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_AI_GOAL_NAME:\n\t\tbotlib_export->ai.BotGoalName( args[1], VMA(2), args[3] );\n\t\treturn 0;\n\tcase BOTLIB_AI_GET_TOP_GOAL:\n\t\treturn botlib_export->ai.BotGetTopGoal( args[1], VMA(2) );\n\tcase BOTLIB_AI_GET_SECOND_GOAL:\n\t\treturn botlib_export->ai.BotGetSecondGoal( args[1], VMA(2) );\n\tcase BOTLIB_AI_CHOOSE_LTG_ITEM:\n\t\treturn botlib_export->ai.BotChooseLTGItem( args[1], VMA(2), VMA(3), args[4] );\n\tcase BOTLIB_AI_CHOOSE_NBG_ITEM:\n\t\treturn botlib_export->ai.BotChooseNBGItem( args[1], VMA(2), VMA(3), args[4], VMA(5), VMF(6) );\n\tcase BOTLIB_AI_TOUCHING_GOAL:\n\t\treturn botlib_export->ai.BotTouchingGoal( VMA(1), VMA(2) );\n\tcase BOTLIB_AI_ITEM_GOAL_IN_VIS_BUT_NOT_VISIBLE:\n\t\treturn botlib_export->ai.BotItemGoalInVisButNotVisible( args[1], VMA(2), VMA(3), VMA(4) );\n\tcase BOTLIB_AI_GET_LEVEL_ITEM_GOAL:\n\t\treturn botlib_export->ai.BotGetLevelItemGoal( args[1], VMA(2), VMA(3) );\n\tcase BOTLIB_AI_GET_NEXT_CAMP_SPOT_GOAL:\n\t\treturn botlib_export->ai.BotGetNextCampSpotGoal( args[1], VMA(2) );\n\tcase BOTLIB_AI_GET_MAP_LOCATION_GOAL:\n\t\treturn botlib_export->ai.BotGetMapLocationGoal( VMA(1), VMA(2) );\n\tcase BOTLIB_AI_AVOID_GOAL_TIME:\n\t\treturn FloatAsInt( botlib_export->ai.BotAvoidGoalTime( args[1], args[2] ) );\n\tcase BOTLIB_AI_SET_AVOID_GOAL_TIME:\n\t\tbotlib_export->ai.BotSetAvoidGoalTime( args[1], args[2], VMF(3));\n\t\treturn 0;\n\tcase BOTLIB_AI_INIT_LEVEL_ITEMS:\n\t\tbotlib_export->ai.BotInitLevelItems();\n\t\treturn 0;\n\tcase BOTLIB_AI_UPDATE_ENTITY_ITEMS:\n\t\tbotlib_export->ai.BotUpdateEntityItems();\n\t\treturn 0;\n\tcase BOTLIB_AI_LOAD_ITEM_WEIGHTS:\n\t\treturn botlib_export->ai.BotLoadItemWeights( args[1], VMA(2) );\n\tcase BOTLIB_AI_FREE_ITEM_WEIGHTS:\n\t\tbotlib_export->ai.BotFreeItemWeights( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_AI_INTERBREED_GOAL_FUZZY_LOGIC:\n\t\tbotlib_export->ai.BotInterbreedGoalFuzzyLogic( args[1], args[2], args[3] );\n\t\treturn 0;\n\tcase BOTLIB_AI_SAVE_GOAL_FUZZY_LOGIC:\n\t\tbotlib_export->ai.BotSaveGoalFuzzyLogic( args[1], VMA(2) );\n\t\treturn 0;\n\tcase BOTLIB_AI_MUTATE_GOAL_FUZZY_LOGIC:\n\t\tbotlib_export->ai.BotMutateGoalFuzzyLogic( args[1], VMF(2) );\n\t\treturn 0;\n\tcase BOTLIB_AI_ALLOC_GOAL_STATE:\n\t\treturn botlib_export->ai.BotAllocGoalState( args[1] );\n\tcase BOTLIB_AI_FREE_GOAL_STATE:\n\t\tbotlib_export->ai.BotFreeGoalState( args[1] );\n\t\treturn 0;\n\n\tcase BOTLIB_AI_RESET_MOVE_STATE:\n\t\tbotlib_export->ai.BotResetMoveState( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_AI_ADD_AVOID_SPOT:\n\t\tbotlib_export->ai.BotAddAvoidSpot( args[1], VMA(2), VMF(3), args[4] );\n\t\treturn 0;\n\tcase BOTLIB_AI_MOVE_TO_GOAL:\n\t\tbotlib_export->ai.BotMoveToGoal( VMA(1), args[2], VMA(3), args[4] );\n\t\treturn 0;\n\tcase BOTLIB_AI_MOVE_IN_DIRECTION:\n\t\treturn botlib_export->ai.BotMoveInDirection( args[1], VMA(2), VMF(3), args[4] );\n\tcase BOTLIB_AI_RESET_AVOID_REACH:\n\t\tbotlib_export->ai.BotResetAvoidReach( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_AI_RESET_LAST_AVOID_REACH:\n\t\tbotlib_export->ai.BotResetLastAvoidReach( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_AI_REACHABILITY_AREA:\n\t\treturn botlib_export->ai.BotReachabilityArea( VMA(1), args[2] );\n\tcase BOTLIB_AI_MOVEMENT_VIEW_TARGET:\n\t\treturn botlib_export->ai.BotMovementViewTarget( args[1], VMA(2), args[3], VMF(4), VMA(5) );\n\tcase BOTLIB_AI_PREDICT_VISIBLE_POSITION:\n\t\treturn botlib_export->ai.BotPredictVisiblePosition( VMA(1), args[2], VMA(3), args[4], VMA(5) );\n\tcase BOTLIB_AI_ALLOC_MOVE_STATE:\n\t\treturn botlib_export->ai.BotAllocMoveState();\n\tcase BOTLIB_AI_FREE_MOVE_STATE:\n\t\tbotlib_export->ai.BotFreeMoveState( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_AI_INIT_MOVE_STATE:\n\t\tbotlib_export->ai.BotInitMoveState( args[1], VMA(2) );\n\t\treturn 0;\n\n\tcase BOTLIB_AI_CHOOSE_BEST_FIGHT_WEAPON:\n\t\treturn botlib_export->ai.BotChooseBestFightWeapon( args[1], VMA(2) );\n\tcase BOTLIB_AI_GET_WEAPON_INFO:\n\t\tbotlib_export->ai.BotGetWeaponInfo( args[1], args[2], VMA(3) );\n\t\treturn 0;\n\tcase BOTLIB_AI_LOAD_WEAPON_WEIGHTS:\n\t\treturn botlib_export->ai.BotLoadWeaponWeights( args[1], VMA(2) );\n\tcase BOTLIB_AI_ALLOC_WEAPON_STATE:\n\t\treturn botlib_export->ai.BotAllocWeaponState();\n\tcase BOTLIB_AI_FREE_WEAPON_STATE:\n\t\tbotlib_export->ai.BotFreeWeaponState( args[1] );\n\t\treturn 0;\n\tcase BOTLIB_AI_RESET_WEAPON_STATE:\n\t\tbotlib_export->ai.BotResetWeaponState( args[1] );\n\t\treturn 0;\n\n\tcase BOTLIB_AI_GENETIC_PARENTS_AND_CHILD_SELECTION:\n\t\treturn botlib_export->ai.GeneticParentsAndChildSelection(args[1], VMA(2), VMA(3), VMA(4), VMA(5));\n\n\tcase TRAP_MEMSET:\n\t\tCom_Memset( VMA(1), args[2], args[3] );\n\t\treturn 0;\n\n\tcase TRAP_MEMCPY:\n\t\tCom_Memcpy( VMA(1), VMA(2), args[3] );\n\t\treturn 0;\n\n\tcase TRAP_STRNCPY:\n\t\treturn (int)strncpy( VMA(1), VMA(2), args[3] );\n\n\tcase TRAP_SIN:\n\t\treturn FloatAsInt( sin( VMF(1) ) );\n\n\tcase TRAP_COS:\n\t\treturn FloatAsInt( cos( VMF(1) ) );\n\n\tcase TRAP_ATAN2:\n\t\treturn FloatAsInt( atan2( VMF(1), VMF(2) ) );\n\n\tcase TRAP_SQRT:\n\t\treturn FloatAsInt( sqrt( VMF(1) ) );\n\n\tcase TRAP_MATRIXMULTIPLY:\n\t\tMatrixMultiply( VMA(1), VMA(2), VMA(3) );\n\t\treturn 0;\n\n\tcase TRAP_ANGLEVECTORS:\n\t\tAngleVectors( VMA(1), VMA(2), VMA(3), VMA(4) );\n\t\treturn 0;\n\n\tcase TRAP_PERPENDICULARVECTOR:\n\t\tPerpendicularVector( VMA(1), VMA(2) );\n\t\treturn 0;\n\n\tcase TRAP_FLOOR:\n\t\treturn FloatAsInt( floor( VMF(1) ) );\n\n\tcase TRAP_CEIL:\n\t\treturn FloatAsInt( ceil( VMF(1) ) );\n\n\n\tdefault:\n\t\tCom_Error( ERR_DROP, \"Bad game system trap: %i\", args[0] );\n\t}\n\treturn -1;\n}\n\n/*\n===============\nSV_ShutdownGameProgs\n\nCalled every time a map changes\n===============\n*/\nvoid SV_ShutdownGameProgs( void ) {\n\tif ( !gvm ) {\n\t\treturn;\n\t}\n\tVM_Call( gvm, GAME_SHUTDOWN, qfalse );\n\tVM_Free( gvm );\n\tgvm = NULL;\n}\n\n/*\n==================\nSV_InitGameVM\n\nCalled for both a full init and a restart\n==================\n*/\nstatic void SV_InitGameVM( qboolean restart ) {\n\tint\t\ti;\n\n\t// start the entity parsing at the beginning\n\tsv.entityParsePoint = CM_EntityString();\n\n\t// clear all gentity pointers that might still be set from\n\t// a previous level\n\t// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=522\n\t//   now done before GAME_INIT call\n\tfor ( i = 0 ; i < sv_maxclients->integer ; i++ ) {\n\t\tsvs.clients[i].gentity = NULL;\n\t}\n\t\n\t// use the current msec count for a random seed\n\t// init for this gamestate\n\tVM_Call( gvm, GAME_INIT, svs.time, Com_Milliseconds(), restart );\n}\n\n\n\n/*\n===================\nSV_RestartGameProgs\n\nCalled on a map_restart, but not on a normal map change\n===================\n*/\nvoid SV_RestartGameProgs( void ) {\n\tif ( !gvm ) {\n\t\treturn;\n\t}\n\tVM_Call( gvm, GAME_SHUTDOWN, qtrue );\n\n\t// do a restart instead of a free\n\tgvm = VM_Restart( gvm );\n\tif ( !gvm ) { // bk001212 - as done below\n\t\tCom_Error( ERR_FATAL, \"VM_Restart on game failed\" );\n\t}\n\n\tSV_InitGameVM( qtrue );\n}\n\n\n/*\n===============\nSV_InitGameProgs\n\nCalled on a normal map change, not on a map_restart\n===============\n*/\nvoid SV_InitGameProgs( void ) {\n\tcvar_t\t*var;\n\t//FIXME these are temp while I make bots run in vm\n\textern int\tbot_enable;\n\n\tvar = Cvar_Get( \"bot_enable\", \"1\", CVAR_LATCH );\n\tif ( var ) {\n\t\tbot_enable = var->integer;\n\t}\n\telse {\n\t\tbot_enable = 0;\n\t}\n\n\t// load the dll or bytecode\n\tgvm = VM_Create( \"qagame\", SV_GameSystemCalls, Cvar_VariableValue( \"vm_game\" ) );\n\tif ( !gvm ) {\n\t\tCom_Error( ERR_FATAL, \"VM_Create on game failed\" );\n\t}\n\n\tSV_InitGameVM( qfalse );\n}\n\n\n/*\n====================\nSV_GameCommand\n\nSee if the current console command is claimed by the game\n====================\n*/\nqboolean SV_GameCommand( void ) {\n\tif ( sv.state != SS_GAME ) {\n\t\treturn qfalse;\n\t}\n\n\treturn VM_Call( gvm, GAME_CONSOLE_COMMAND );\n}\n\n"
  },
  {
    "path": "code/server/sv_init.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"server.h\"\n\n/*\n===============\nSV_SetConfigstring\n\n===============\n*/\nvoid SV_SetConfigstring (int index, const char *val) {\n\tint\t\tlen, i;\n\tint\t\tmaxChunkSize = MAX_STRING_CHARS - 24;\n\tclient_t\t*client;\n\n\tif ( index < 0 || index >= MAX_CONFIGSTRINGS ) {\n\t\tCom_Error (ERR_DROP, \"SV_SetConfigstring: bad index %i\\n\", index);\n\t}\n\n\tif ( !val ) {\n\t\tval = \"\";\n\t}\n\n\t// don't bother broadcasting an update if no change\n\tif ( !strcmp( val, sv.configstrings[ index ] ) ) {\n\t\treturn;\n\t}\n\n\t// change the string in sv\n\tZ_Free( sv.configstrings[index] );\n\tsv.configstrings[index] = CopyString( val );\n\n\t// send it to all the clients if we aren't\n\t// spawning a new server\n\tif ( sv.state == SS_GAME || sv.restarting ) {\n\n\t\t// send the data to all relevent clients\n\t\tfor (i = 0, client = svs.clients; i < sv_maxclients->integer ; i++, client++) {\n\t\t\tif ( client->state < CS_PRIMED ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// do not always send server info to all clients\n\t\t\tif ( index == CS_SERVERINFO && client->gentity && (client->gentity->r.svFlags & SVF_NOSERVERINFO) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlen = strlen( val );\n\t\t\tif( len >= maxChunkSize ) {\n\t\t\t\tint\t\tsent = 0;\n\t\t\t\tint\t\tremaining = len;\n\t\t\t\tchar\t*cmd;\n\t\t\t\tchar\tbuf[MAX_STRING_CHARS];\n\n\t\t\t\twhile (remaining > 0 ) {\n\t\t\t\t\tif ( sent == 0 ) {\n\t\t\t\t\t\tcmd = \"bcs0\";\n\t\t\t\t\t}\n\t\t\t\t\telse if( remaining < maxChunkSize ) {\n\t\t\t\t\t\tcmd = \"bcs2\";\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tcmd = \"bcs1\";\n\t\t\t\t\t}\n\t\t\t\t\tQ_strncpyz( buf, &val[sent], maxChunkSize );\n\n\t\t\t\t\tSV_SendServerCommand( client, \"%s %i \\\"%s\\\"\\n\", cmd, index, buf );\n\n\t\t\t\t\tsent += (maxChunkSize - 1);\n\t\t\t\t\tremaining -= (maxChunkSize - 1);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// standard cs, just send it\n\t\t\t\tSV_SendServerCommand( client, \"cs %i \\\"%s\\\"\\n\", index, val );\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n\n/*\n===============\nSV_GetConfigstring\n\n===============\n*/\nvoid SV_GetConfigstring( int index, char *buffer, int bufferSize ) {\n\tif ( bufferSize < 1 ) {\n\t\tCom_Error( ERR_DROP, \"SV_GetConfigstring: bufferSize == %i\", bufferSize );\n\t}\n\tif ( index < 0 || index >= MAX_CONFIGSTRINGS ) {\n\t\tCom_Error (ERR_DROP, \"SV_GetConfigstring: bad index %i\\n\", index);\n\t}\n\tif ( !sv.configstrings[index] ) {\n\t\tbuffer[0] = 0;\n\t\treturn;\n\t}\n\n\tQ_strncpyz( buffer, sv.configstrings[index], bufferSize );\n}\n\n\n/*\n===============\nSV_SetUserinfo\n\n===============\n*/\nvoid SV_SetUserinfo( int index, const char *val ) {\n\tif ( index < 0 || index >= sv_maxclients->integer ) {\n\t\tCom_Error (ERR_DROP, \"SV_SetUserinfo: bad index %i\\n\", index);\n\t}\n\n\tif ( !val ) {\n\t\tval = \"\";\n\t}\n\n\tQ_strncpyz( svs.clients[index].userinfo, val, sizeof( svs.clients[ index ].userinfo ) );\n\tQ_strncpyz( svs.clients[index].name, Info_ValueForKey( val, \"name\" ), sizeof(svs.clients[index].name) );\n}\n\n\n\n/*\n===============\nSV_GetUserinfo\n\n===============\n*/\nvoid SV_GetUserinfo( int index, char *buffer, int bufferSize ) {\n\tif ( bufferSize < 1 ) {\n\t\tCom_Error( ERR_DROP, \"SV_GetUserinfo: bufferSize == %i\", bufferSize );\n\t}\n\tif ( index < 0 || index >= sv_maxclients->integer ) {\n\t\tCom_Error (ERR_DROP, \"SV_GetUserinfo: bad index %i\\n\", index);\n\t}\n\tQ_strncpyz( buffer, svs.clients[ index ].userinfo, bufferSize );\n}\n\n\n/*\n================\nSV_CreateBaseline\n\nEntity baselines are used to compress non-delta messages\nto the clients -- only the fields that differ from the\nbaseline will be transmitted\n================\n*/\nvoid SV_CreateBaseline( void ) {\n\tsharedEntity_t *svent;\n\tint\t\t\t\tentnum;\t\n\n\tfor ( entnum = 1; entnum < sv.num_entities ; entnum++ ) {\n\t\tsvent = SV_GentityNum(entnum);\n\t\tif (!svent->r.linked) {\n\t\t\tcontinue;\n\t\t}\n\t\tsvent->s.number = entnum;\n\n\t\t//\n\t\t// take current state as baseline\n\t\t//\n\t\tsv.svEntities[entnum].baseline = svent->s;\n\t}\n}\n\n\n/*\n===============\nSV_BoundMaxClients\n\n===============\n*/\nvoid SV_BoundMaxClients( int minimum ) {\n\t// get the current maxclients value\n\tCvar_Get( \"sv_maxclients\", \"8\", 0 );\n\n\tsv_maxclients->modified = qfalse;\n\n\tif ( sv_maxclients->integer < minimum ) {\n\t\tCvar_Set( \"sv_maxclients\", va(\"%i\", minimum) );\n\t} else if ( sv_maxclients->integer > MAX_CLIENTS ) {\n\t\tCvar_Set( \"sv_maxclients\", va(\"%i\", MAX_CLIENTS) );\n\t}\n}\n\n\n/*\n===============\nSV_Startup\n\nCalled when a host starts a map when it wasn't running\none before.  Successive map or map_restart commands will\nNOT cause this to be called, unless the game is exited to\nthe menu system first.\n===============\n*/\nvoid SV_Startup( void ) {\n\tif ( svs.initialized ) {\n\t\tCom_Error( ERR_FATAL, \"SV_Startup: svs.initialized\" );\n\t}\n\tSV_BoundMaxClients( 1 );\n\n\tsvs.clients = Z_Malloc (sizeof(client_t) * sv_maxclients->integer );\n\tif ( com_dedicated->integer ) {\n\t\tsvs.numSnapshotEntities = sv_maxclients->integer * PACKET_BACKUP * 64;\n\t} else {\n\t\t// we don't need nearly as many when playing locally\n\t\tsvs.numSnapshotEntities = sv_maxclients->integer * 4 * 64;\n\t}\n\tsvs.initialized = qtrue;\n\n\tCvar_Set( \"sv_running\", \"1\" );\n}\n\n\n/*\n==================\nSV_ChangeMaxClients\n==================\n*/\nvoid SV_ChangeMaxClients( void ) {\n\tint\t\toldMaxClients;\n\tint\t\ti;\n\tclient_t\t*oldClients;\n\tint\t\tcount;\n\n\t// get the highest client number in use\n\tcount = 0;\n\tfor ( i = 0 ; i < sv_maxclients->integer ; i++ ) {\n\t\tif ( svs.clients[i].state >= CS_CONNECTED ) {\n\t\t\tif (i > count)\n\t\t\t\tcount = i;\n\t\t}\n\t}\n\tcount++;\n\n\toldMaxClients = sv_maxclients->integer;\n\t// never go below the highest client number in use\n\tSV_BoundMaxClients( count );\n\t// if still the same\n\tif ( sv_maxclients->integer == oldMaxClients ) {\n\t\treturn;\n\t}\n\n\toldClients = Hunk_AllocateTempMemory( count * sizeof(client_t) );\n\t// copy the clients to hunk memory\n\tfor ( i = 0 ; i < count ; i++ ) {\n\t\tif ( svs.clients[i].state >= CS_CONNECTED ) {\n\t\t\toldClients[i] = svs.clients[i];\n\t\t}\n\t\telse {\n\t\t\tCom_Memset(&oldClients[i], 0, sizeof(client_t));\n\t\t}\n\t}\n\n\t// free old clients arrays\n\tZ_Free( svs.clients );\n\n\t// allocate new clients\n\tsvs.clients = Z_Malloc ( sv_maxclients->integer * sizeof(client_t) );\n\tCom_Memset( svs.clients, 0, sv_maxclients->integer * sizeof(client_t) );\n\n\t// copy the clients over\n\tfor ( i = 0 ; i < count ; i++ ) {\n\t\tif ( oldClients[i].state >= CS_CONNECTED ) {\n\t\t\tsvs.clients[i] = oldClients[i];\n\t\t}\n\t}\n\n\t// free the old clients on the hunk\n\tHunk_FreeTempMemory( oldClients );\n\t\n\t// allocate new snapshot entities\n\tif ( com_dedicated->integer ) {\n\t\tsvs.numSnapshotEntities = sv_maxclients->integer * PACKET_BACKUP * 64;\n\t} else {\n\t\t// we don't need nearly as many when playing locally\n\t\tsvs.numSnapshotEntities = sv_maxclients->integer * 4 * 64;\n\t}\n}\n\n/*\n================\nSV_ClearServer\n================\n*/\nvoid SV_ClearServer(void) {\n\tint i;\n\n\tfor ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) {\n\t\tif ( sv.configstrings[i] ) {\n\t\t\tZ_Free( sv.configstrings[i] );\n\t\t}\n\t}\n\tCom_Memset (&sv, 0, sizeof(sv));\n}\n\n/*\n================\nSV_TouchCGame\n\n  touch the cgame.vm so that a pure client can load it if it's in a seperate pk3\n================\n*/\nvoid SV_TouchCGame(void) {\n\tfileHandle_t\tf;\n\tchar filename[MAX_QPATH];\n\n\tCom_sprintf( filename, sizeof(filename), \"vm/%s.qvm\", \"cgame\" );\n\tFS_FOpenFileRead( filename, &f, qfalse );\n\tif ( f ) {\n\t\tFS_FCloseFile( f );\n\t}\n}\n\n/*\n================\nSV_SpawnServer\n\nChange the server to a new map, taking all connected\nclients along with it.\nThis is NOT called for map_restart\n================\n*/\nvoid SV_SpawnServer( char *server, qboolean killBots ) {\n\tint\t\t\ti;\n\tint\t\t\tchecksum;\n\tqboolean\tisBot;\n\tchar\t\tsystemInfo[16384];\n\tconst char\t*p;\n\n\t// shut down the existing game if it is running\n\tSV_ShutdownGameProgs();\n\n\tCom_Printf (\"------ Server Initialization ------\\n\");\n\tCom_Printf (\"Server: %s\\n\",server);\n\n\t// if not running a dedicated server CL_MapLoading will connect the client to the server\n\t// also print some status stuff\n\tCL_MapLoading();\n\n\t// make sure all the client stuff is unloaded\n\tCL_ShutdownAll();\n\n\t// clear the whole hunk because we're (re)loading the server\n\tHunk_Clear();\n\n\t// clear collision map data\n\tCM_ClearMap();\n\n\t// init client structures and svs.numSnapshotEntities \n\tif ( !Cvar_VariableValue(\"sv_running\") ) {\n\t\tSV_Startup();\n\t} else {\n\t\t// check for maxclients change\n\t\tif ( sv_maxclients->modified ) {\n\t\t\tSV_ChangeMaxClients();\n\t\t}\n\t}\n\n\t// clear pak references\n\tFS_ClearPakReferences(0);\n\n\t// allocate the snapshot entities on the hunk\n\tsvs.snapshotEntities = Hunk_Alloc( sizeof(entityState_t)*svs.numSnapshotEntities, h_high );\n\tsvs.nextSnapshotEntities = 0;\n\n\t// toggle the server bit so clients can detect that a\n\t// server has changed\n\tsvs.snapFlagServerBit ^= SNAPFLAG_SERVERCOUNT;\n\n\t// set nextmap to the same map, but it may be overriden\n\t// by the game startup or another console command\n\tCvar_Set( \"nextmap\", \"map_restart 0\");\n//\tCvar_Set( \"nextmap\", va(\"map %s\", server) );\n\n\t// wipe the entire per-level structure\n\tSV_ClearServer();\n\tfor ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) {\n\t\tsv.configstrings[i] = CopyString(\"\");\n\t}\n\n\t// make sure we are not paused\n\tCvar_Set(\"cl_paused\", \"0\");\n\n\t// get a new checksum feed and restart the file system\n\tsrand(Com_Milliseconds());\n\tsv.checksumFeed = ( ((int) rand() << 16) ^ rand() ) ^ Com_Milliseconds();\n\tFS_Restart( sv.checksumFeed );\n\n\tCM_LoadMap( va(\"maps/%s.bsp\", server), qfalse, &checksum );\n\n\t// set serverinfo visible name\n\tCvar_Set( \"mapname\", server );\n\n\tCvar_Set( \"sv_mapChecksum\", va(\"%i\",checksum) );\n\n\t// serverid should be different each time\n\tsv.serverId = com_frameTime;\n\tsv.restartedServerId = sv.serverId; // I suppose the init here is just to be safe\n\tsv.checksumFeedServerId = sv.serverId;\n\tCvar_Set( \"sv_serverid\", va(\"%i\", sv.serverId ) );\n\n\t// clear physics interaction links\n\tSV_ClearWorld ();\n\t\n\t// media configstring setting should be done during\n\t// the loading stage, so connected clients don't have\n\t// to load during actual gameplay\n\tsv.state = SS_LOADING;\n\n\t// load and spawn all other entities\n\tSV_InitGameProgs();\n\n\t// don't allow a map_restart if game is modified\n\tsv_gametype->modified = qfalse;\n\n\t// run a few frames to allow everything to settle\n\tfor ( i = 0 ;i < 3 ; i++ ) {\n\t\tVM_Call( gvm, GAME_RUN_FRAME, svs.time );\n\t\tSV_BotFrame( svs.time );\n\t\tsvs.time += 100;\n\t}\n\n\t// create a baseline for more efficient communications\n\tSV_CreateBaseline ();\n\n\tfor (i=0 ; i<sv_maxclients->integer ; i++) {\n\t\t// send the new gamestate to all connected clients\n\t\tif (svs.clients[i].state >= CS_CONNECTED) {\n\t\t\tchar\t*denied;\n\n\t\t\tif ( svs.clients[i].netchan.remoteAddress.type == NA_BOT ) {\n\t\t\t\tif ( killBots ) {\n\t\t\t\t\tSV_DropClient( &svs.clients[i], \"\" );\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tisBot = qtrue;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tisBot = qfalse;\n\t\t\t}\n\n\t\t\t// connect the client again\n\t\t\tdenied = VM_ExplicitArgPtr( gvm, VM_Call( gvm, GAME_CLIENT_CONNECT, i, qfalse, isBot ) );\t// firstTime = qfalse\n\t\t\tif ( denied ) {\n\t\t\t\t// this generally shouldn't happen, because the client\n\t\t\t\t// was connected before the level change\n\t\t\t\tSV_DropClient( &svs.clients[i], denied );\n\t\t\t} else {\n\t\t\t\tif( !isBot ) {\n\t\t\t\t\t// when we get the next packet from a connected client,\n\t\t\t\t\t// the new gamestate will be sent\n\t\t\t\t\tsvs.clients[i].state = CS_CONNECTED;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tclient_t\t\t*client;\n\t\t\t\t\tsharedEntity_t\t*ent;\n\n\t\t\t\t\tclient = &svs.clients[i];\n\t\t\t\t\tclient->state = CS_ACTIVE;\n\t\t\t\t\tent = SV_GentityNum( i );\n\t\t\t\t\tent->s.number = i;\n\t\t\t\t\tclient->gentity = ent;\n\n\t\t\t\t\tclient->deltaMessage = -1;\n\t\t\t\t\tclient->nextSnapshotTime = svs.time;\t// generate a snapshot immediately\n\n\t\t\t\t\tVM_Call( gvm, GAME_CLIENT_BEGIN, i );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\t\n\n\t// run another frame to allow things to look at all the players\n\tVM_Call( gvm, GAME_RUN_FRAME, svs.time );\n\tSV_BotFrame( svs.time );\n\tsvs.time += 100;\n\n\tif ( sv_pure->integer ) {\n\t\t// the server sends these to the clients so they will only\n\t\t// load pk3s also loaded at the server\n\t\tp = FS_LoadedPakChecksums();\n\t\tCvar_Set( \"sv_paks\", p );\n\t\tif (strlen(p) == 0) {\n\t\t\tCom_Printf( \"WARNING: sv_pure set but no PK3 files loaded\\n\" );\n\t\t}\n\t\tp = FS_LoadedPakNames();\n\t\tCvar_Set( \"sv_pakNames\", p );\n\n\t\t// if a dedicated pure server we need to touch the cgame because it could be in a\n\t\t// seperate pk3 file and the client will need to load the latest cgame.qvm\n\t\tif ( com_dedicated->integer ) {\n\t\t\tSV_TouchCGame();\n\t\t}\n\t}\n\telse {\n\t\tCvar_Set( \"sv_paks\", \"\" );\n\t\tCvar_Set( \"sv_pakNames\", \"\" );\n\t}\n\t// the server sends these to the clients so they can figure\n\t// out which pk3s should be auto-downloaded\n\tp = FS_ReferencedPakChecksums();\n\tCvar_Set( \"sv_referencedPaks\", p );\n\tp = FS_ReferencedPakNames();\n\tCvar_Set( \"sv_referencedPakNames\", p );\n\n\t// save systeminfo and serverinfo strings\n\tQ_strncpyz( systemInfo, Cvar_InfoString_Big( CVAR_SYSTEMINFO ), sizeof( systemInfo ) );\n\tcvar_modifiedFlags &= ~CVAR_SYSTEMINFO;\n\tSV_SetConfigstring( CS_SYSTEMINFO, systemInfo );\n\n\tSV_SetConfigstring( CS_SERVERINFO, Cvar_InfoString( CVAR_SERVERINFO ) );\n\tcvar_modifiedFlags &= ~CVAR_SERVERINFO;\n\n\t// any media configstring setting now should issue a warning\n\t// and any configstring changes should be reliably transmitted\n\t// to all clients\n\tsv.state = SS_GAME;\n\n\t// send a heartbeat now so the master will get up to date info\n\tSV_Heartbeat_f();\n\n\tHunk_SetMark();\n\n\tCom_Printf (\"-----------------------------------\\n\");\n}\n\n/*\n===============\nSV_Init\n\nOnly called at main exe startup, not for each game\n===============\n*/\nvoid SV_BotInitBotLib(void);\n\nvoid SV_Init (void) {\n\tSV_AddOperatorCommands ();\n\n\t// serverinfo vars\n\tCvar_Get (\"dmflags\", \"0\", CVAR_SERVERINFO);\n\tCvar_Get (\"fraglimit\", \"20\", CVAR_SERVERINFO);\n\tCvar_Get (\"timelimit\", \"0\", CVAR_SERVERINFO);\n\tsv_gametype = Cvar_Get (\"g_gametype\", \"0\", CVAR_SERVERINFO | CVAR_LATCH );\n\tCvar_Get (\"sv_keywords\", \"\", CVAR_SERVERINFO);\n\tCvar_Get (\"protocol\", va(\"%i\", PROTOCOL_VERSION), CVAR_SERVERINFO | CVAR_ROM);\n\tsv_mapname = Cvar_Get (\"mapname\", \"nomap\", CVAR_SERVERINFO | CVAR_ROM);\n\tsv_privateClients = Cvar_Get (\"sv_privateClients\", \"0\", CVAR_SERVERINFO);\n\tsv_hostname = Cvar_Get (\"sv_hostname\", \"noname\", CVAR_SERVERINFO | CVAR_ARCHIVE );\n\tsv_maxclients = Cvar_Get (\"sv_maxclients\", \"8\", CVAR_SERVERINFO | CVAR_LATCH);\n\n\tsv_maxRate = Cvar_Get (\"sv_maxRate\", \"0\", CVAR_ARCHIVE | CVAR_SERVERINFO );\n\tsv_minPing = Cvar_Get (\"sv_minPing\", \"0\", CVAR_ARCHIVE | CVAR_SERVERINFO );\n\tsv_maxPing = Cvar_Get (\"sv_maxPing\", \"0\", CVAR_ARCHIVE | CVAR_SERVERINFO );\n\tsv_floodProtect = Cvar_Get (\"sv_floodProtect\", \"1\", CVAR_ARCHIVE | CVAR_SERVERINFO );\n\n\t// systeminfo\n\tCvar_Get (\"sv_cheats\", \"1\", CVAR_SYSTEMINFO | CVAR_ROM );\n\tsv_serverid = Cvar_Get (\"sv_serverid\", \"0\", CVAR_SYSTEMINFO | CVAR_ROM );\n#ifndef DLL_ONLY // bk010216 - for DLL-only servers\n\tsv_pure = Cvar_Get (\"sv_pure\", \"1\", CVAR_SYSTEMINFO );\n#else\n\tsv_pure = Cvar_Get (\"sv_pure\", \"0\", CVAR_SYSTEMINFO | CVAR_INIT | CVAR_ROM );\n#endif\n\tCvar_Get (\"sv_paks\", \"\", CVAR_SYSTEMINFO | CVAR_ROM );\n\tCvar_Get (\"sv_pakNames\", \"\", CVAR_SYSTEMINFO | CVAR_ROM );\n\tCvar_Get (\"sv_referencedPaks\", \"\", CVAR_SYSTEMINFO | CVAR_ROM );\n\tCvar_Get (\"sv_referencedPakNames\", \"\", CVAR_SYSTEMINFO | CVAR_ROM );\n\n\t// server vars\n\tsv_rconPassword = Cvar_Get (\"rconPassword\", \"\", CVAR_TEMP );\n\tsv_privatePassword = Cvar_Get (\"sv_privatePassword\", \"\", CVAR_TEMP );\n\tsv_fps = Cvar_Get (\"sv_fps\", \"20\", CVAR_TEMP );\n\tsv_timeout = Cvar_Get (\"sv_timeout\", \"200\", CVAR_TEMP );\n\tsv_zombietime = Cvar_Get (\"sv_zombietime\", \"2\", CVAR_TEMP );\n\tCvar_Get (\"nextmap\", \"\", CVAR_TEMP );\n\n\tsv_allowDownload = Cvar_Get (\"sv_allowDownload\", \"0\", CVAR_SERVERINFO);\n\tsv_master[0] = Cvar_Get (\"sv_master1\", MASTER_SERVER_NAME, 0 );\n\tsv_master[1] = Cvar_Get (\"sv_master2\", \"\", CVAR_ARCHIVE );\n\tsv_master[2] = Cvar_Get (\"sv_master3\", \"\", CVAR_ARCHIVE );\n\tsv_master[3] = Cvar_Get (\"sv_master4\", \"\", CVAR_ARCHIVE );\n\tsv_master[4] = Cvar_Get (\"sv_master5\", \"\", CVAR_ARCHIVE );\n\tsv_reconnectlimit = Cvar_Get (\"sv_reconnectlimit\", \"3\", 0);\n\tsv_showloss = Cvar_Get (\"sv_showloss\", \"0\", 0);\n\tsv_padPackets = Cvar_Get (\"sv_padPackets\", \"0\", 0);\n\tsv_killserver = Cvar_Get (\"sv_killserver\", \"0\", 0);\n\tsv_mapChecksum = Cvar_Get (\"sv_mapChecksum\", \"\", CVAR_ROM);\n\tsv_lanForceRate = Cvar_Get (\"sv_lanForceRate\", \"1\", CVAR_ARCHIVE );\n\tsv_strictAuth = Cvar_Get (\"sv_strictAuth\", \"1\", CVAR_ARCHIVE );\n\n\t// initialize bot cvars so they are listed and can be set before loading the botlib\n\tSV_BotInitCvars();\n\n\t// init the botlib here because we need the pre-compiler in the UI\n\tSV_BotInitBotLib();\n}\n\n\n/*\n==================\nSV_FinalMessage\n\nUsed by SV_Shutdown to send a final message to all\nconnected clients before the server goes down.  The messages are sent immediately,\nnot just stuck on the outgoing message list, because the server is going\nto totally exit after returning from this function.\n==================\n*/\nvoid SV_FinalMessage( char *message ) {\n\tint\t\t\ti, j;\n\tclient_t\t*cl;\n\t\n\t// send it twice, ignoring rate\n\tfor ( j = 0 ; j < 2 ; j++ ) {\n\t\tfor (i=0, cl = svs.clients ; i < sv_maxclients->integer ; i++, cl++) {\n\t\t\tif (cl->state >= CS_CONNECTED) {\n\t\t\t\t// don't send a disconnect to a local client\n\t\t\t\tif ( cl->netchan.remoteAddress.type != NA_LOOPBACK ) {\n\t\t\t\t\tSV_SendServerCommand( cl, \"print \\\"%s\\\"\", message );\n\t\t\t\t\tSV_SendServerCommand( cl, \"disconnect\" );\n\t\t\t\t}\n\t\t\t\t// force a snapshot to be sent\n\t\t\t\tcl->nextSnapshotTime = -1;\n\t\t\t\tSV_SendClientSnapshot( cl );\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n/*\n================\nSV_Shutdown\n\nCalled when each game quits,\nbefore Sys_Quit or Sys_Error\n================\n*/\nvoid SV_Shutdown( char *finalmsg ) {\n\tif ( !com_sv_running || !com_sv_running->integer ) {\n\t\treturn;\n\t}\n\n\tCom_Printf( \"----- Server Shutdown -----\\n\" );\n\n\tif ( svs.clients && !com_errorEntered ) {\n\t\tSV_FinalMessage( finalmsg );\n\t}\n\n\tSV_RemoveOperatorCommands();\n\tSV_MasterShutdown();\n\tSV_ShutdownGameProgs();\n\n\t// free current level\n\tSV_ClearServer();\n\n\t// free server static data\n\tif ( svs.clients ) {\n\t\tZ_Free( svs.clients );\n\t}\n\tCom_Memset( &svs, 0, sizeof( svs ) );\n\n\tCvar_Set( \"sv_running\", \"0\" );\n\tCvar_Set(\"ui_singlePlayerActive\", \"0\");\n\n\tCom_Printf( \"---------------------------\\n\" );\n\n\t// disconnect any local clients\n\tCL_Disconnect( qfalse );\n}\n\n"
  },
  {
    "path": "code/server/sv_main.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"server.h\"\n\nserverStatic_t\tsvs;\t\t\t\t// persistant server info\nserver_t\t\tsv;\t\t\t\t\t// local server\nvm_t\t\t\t*gvm = NULL;\t\t\t\t// game virtual machine // bk001212 init\n\ncvar_t\t*sv_fps;\t\t\t\t// time rate for running non-clients\ncvar_t\t*sv_timeout;\t\t\t// seconds without any message\ncvar_t\t*sv_zombietime;\t\t\t// seconds to sink messages after disconnect\ncvar_t\t*sv_rconPassword;\t\t// password for remote server commands\ncvar_t\t*sv_privatePassword;\t// password for the privateClient slots\ncvar_t\t*sv_allowDownload;\ncvar_t\t*sv_maxclients;\n\ncvar_t\t*sv_privateClients;\t\t// number of clients reserved for password\ncvar_t\t*sv_hostname;\ncvar_t\t*sv_master[MAX_MASTER_SERVERS];\t\t// master server ip address\ncvar_t\t*sv_reconnectlimit;\t\t// minimum seconds between connect messages\ncvar_t\t*sv_showloss;\t\t\t// report when usercmds are lost\ncvar_t\t*sv_padPackets;\t\t\t// add nop bytes to messages\ncvar_t\t*sv_killserver;\t\t\t// menu system can set to 1 to shut server down\ncvar_t\t*sv_mapname;\ncvar_t\t*sv_mapChecksum;\ncvar_t\t*sv_serverid;\ncvar_t\t*sv_maxRate;\ncvar_t\t*sv_minPing;\ncvar_t\t*sv_maxPing;\ncvar_t\t*sv_gametype;\ncvar_t\t*sv_pure;\ncvar_t\t*sv_floodProtect;\ncvar_t\t*sv_lanForceRate; // dedicated 1 (LAN) server forces local client rates to 99999 (bug #491)\ncvar_t\t*sv_strictAuth;\n\n/*\n=============================================================================\n\nEVENT MESSAGES\n\n=============================================================================\n*/\n\n/*\n===============\nSV_ExpandNewlines\n\nConverts newlines to \"\\n\" so a line prints nicer\n===============\n*/\nchar\t*SV_ExpandNewlines( char *in ) {\n\tstatic\tchar\tstring[1024];\n\tint\t\tl;\n\n\tl = 0;\n\twhile ( *in && l < sizeof(string) - 3 ) {\n\t\tif ( *in == '\\n' ) {\n\t\t\tstring[l++] = '\\\\';\n\t\t\tstring[l++] = 'n';\n\t\t} else {\n\t\t\tstring[l++] = *in;\n\t\t}\n\t\tin++;\n\t}\n\tstring[l] = 0;\n\n\treturn string;\n}\n\n/*\n======================\nSV_ReplacePendingServerCommands\n\n  This is ugly\n======================\n*/\nint SV_ReplacePendingServerCommands( client_t *client, const char *cmd ) {\n\tint i, index, csnum1, csnum2;\n\n\tfor ( i = client->reliableSent+1; i <= client->reliableSequence; i++ ) {\n\t\tindex = i & ( MAX_RELIABLE_COMMANDS - 1 );\n\t\t//\n\t\tif ( !Q_strncmp(cmd, client->reliableCommands[ index ], strlen(\"cs\")) ) {\n\t\t\tsscanf(cmd, \"cs %i\", &csnum1);\n\t\t\tsscanf(client->reliableCommands[ index ], \"cs %i\", &csnum2);\n\t\t\tif ( csnum1 == csnum2 ) {\n\t\t\t\tQ_strncpyz( client->reliableCommands[ index ], cmd, sizeof( client->reliableCommands[ index ] ) );\n\t\t\t\t/*\n\t\t\t\tif ( client->netchan.remoteAddress.type != NA_BOT ) {\n\t\t\t\t\tCom_Printf( \"WARNING: client %i removed double pending config string %i: %s\\n\", client-svs.clients, csnum1, cmd );\n\t\t\t\t}\n\t\t\t\t*/\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n/*\n======================\nSV_AddServerCommand\n\nThe given command will be transmitted to the client, and is guaranteed to\nnot have future snapshot_t executed before it is executed\n======================\n*/\nvoid SV_AddServerCommand( client_t *client, const char *cmd ) {\n\tint\t\tindex, i;\n\n\t// this is very ugly but it's also a waste to for instance send multiple config string updates\n\t// for the same config string index in one snapshot\n//\tif ( SV_ReplacePendingServerCommands( client, cmd ) ) {\n//\t\treturn;\n//\t}\n\n\tclient->reliableSequence++;\n\t// if we would be losing an old command that hasn't been acknowledged,\n\t// we must drop the connection\n\t// we check == instead of >= so a broadcast print added by SV_DropClient()\n\t// doesn't cause a recursive drop client\n\tif ( client->reliableSequence - client->reliableAcknowledge == MAX_RELIABLE_COMMANDS + 1 ) {\n\t\tCom_Printf( \"===== pending server commands =====\\n\" );\n\t\tfor ( i = client->reliableAcknowledge + 1 ; i <= client->reliableSequence ; i++ ) {\n\t\t\tCom_Printf( \"cmd %5d: %s\\n\", i, client->reliableCommands[ i & (MAX_RELIABLE_COMMANDS-1) ] );\n\t\t}\n\t\tCom_Printf( \"cmd %5d: %s\\n\", i, cmd );\n\t\tSV_DropClient( client, \"Server command overflow\" );\n\t\treturn;\n\t}\n\tindex = client->reliableSequence & ( MAX_RELIABLE_COMMANDS - 1 );\n\tQ_strncpyz( client->reliableCommands[ index ], cmd, sizeof( client->reliableCommands[ index ] ) );\n}\n\n\n/*\n=================\nSV_SendServerCommand\n\nSends a reliable command string to be interpreted by \nthe client game module: \"cp\", \"print\", \"chat\", etc\nA NULL client will broadcast to all clients\n=================\n*/\nvoid QDECL SV_SendServerCommand(client_t *cl, const char *fmt, ...) {\n\tva_list\t\targptr;\n\tbyte\t\tmessage[MAX_MSGLEN];\n\tclient_t\t*client;\n\tint\t\t\tj;\n\t\n\tva_start (argptr,fmt);\n\tQ_vsnprintf ((char *)message, sizeof(message), fmt,argptr);\n\tva_end (argptr);\n\n\tif ( cl != NULL ) {\n\t\tSV_AddServerCommand( cl, (char *)message );\n\t\treturn;\n\t}\n\n\t// hack to echo broadcast prints to console\n\tif ( com_dedicated->integer && !strncmp( (char *)message, \"print\", 5) ) {\n\t\tCom_Printf (\"broadcast: %s\\n\", SV_ExpandNewlines((char *)message) );\n\t}\n\n\t// send the data to all relevent clients\n\tfor (j = 0, client = svs.clients; j < sv_maxclients->integer ; j++, client++) {\n\t\tif ( client->state < CS_PRIMED ) {\n\t\t\tcontinue;\n\t\t}\n\t\tSV_AddServerCommand( client, (char *)message );\n\t}\n}\n\n\n/*\n==============================================================================\n\nMASTER SERVER FUNCTIONS\n\n==============================================================================\n*/\n\n/*\n================\nSV_MasterHeartbeat\n\nSend a message to the masters every few minutes to\nlet it know we are alive, and log information.\nWe will also have a heartbeat sent when a server\nchanges from empty to non-empty, and full to non-full,\nbut not on every player enter or exit.\n================\n*/\n#define\tHEARTBEAT_MSEC\t300*1000\n#define\tHEARTBEAT_GAME\t\"QuakeArena-1\"\nvoid SV_MasterHeartbeat( void ) {\n\tstatic netadr_t\tadr[MAX_MASTER_SERVERS];\n\tint\t\t\ti;\n\n\t// \"dedicated 1\" is for lan play, \"dedicated 2\" is for inet public play\n\tif ( !com_dedicated || com_dedicated->integer != 2 ) {\n\t\treturn;\t\t// only dedicated servers send heartbeats\n\t}\n\n\t// if not time yet, don't send anything\n\tif ( svs.time < svs.nextHeartbeatTime ) {\n\t\treturn;\n\t}\n\tsvs.nextHeartbeatTime = svs.time + HEARTBEAT_MSEC;\n\n\n\t// send to group masters\n\tfor ( i = 0 ; i < MAX_MASTER_SERVERS ; i++ ) {\n\t\tif ( !sv_master[i]->string[0] ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// see if we haven't already resolved the name\n\t\t// resolving usually causes hitches on win95, so only\n\t\t// do it when needed\n\t\tif ( sv_master[i]->modified ) {\n\t\t\tsv_master[i]->modified = qfalse;\n\t\n\t\t\tCom_Printf( \"Resolving %s\\n\", sv_master[i]->string );\n\t\t\tif ( !NET_StringToAdr( sv_master[i]->string, &adr[i] ) ) {\n\t\t\t\t// if the address failed to resolve, clear it\n\t\t\t\t// so we don't take repeated dns hits\n\t\t\t\tCom_Printf( \"Couldn't resolve address: %s\\n\", sv_master[i]->string );\n\t\t\t\tCvar_Set( sv_master[i]->name, \"\" );\n\t\t\t\tsv_master[i]->modified = qfalse;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( !strstr( \":\", sv_master[i]->string ) ) {\n\t\t\t\tadr[i].port = BigShort( PORT_MASTER );\n\t\t\t}\n\t\t\tCom_Printf( \"%s resolved to %i.%i.%i.%i:%i\\n\", sv_master[i]->string,\n\t\t\t\tadr[i].ip[0], adr[i].ip[1], adr[i].ip[2], adr[i].ip[3],\n\t\t\t\tBigShort( adr[i].port ) );\n\t\t}\n\n\n\t\tCom_Printf (\"Sending heartbeat to %s\\n\", sv_master[i]->string );\n\t\t// this command should be changed if the server info / status format\n\t\t// ever incompatably changes\n\t\tNET_OutOfBandPrint( NS_SERVER, adr[i], \"heartbeat %s\\n\", HEARTBEAT_GAME );\n\t}\n}\n\n/*\n=================\nSV_MasterShutdown\n\nInforms all masters that this server is going down\n=================\n*/\nvoid SV_MasterShutdown( void ) {\n\t// send a hearbeat right now\n\tsvs.nextHeartbeatTime = -9999;\n\tSV_MasterHeartbeat();\n\n\t// send it again to minimize chance of drops\n\tsvs.nextHeartbeatTime = -9999;\n\tSV_MasterHeartbeat();\n\n\t// when the master tries to poll the server, it won't respond, so\n\t// it will be removed from the list\n}\n\n\n/*\n==============================================================================\n\nCONNECTIONLESS COMMANDS\n\n==============================================================================\n*/\n\n/*\n================\nSVC_Status\n\nResponds with all the info that qplug or qspy can see about the server\nand all connected players.  Used for getting detailed information after\nthe simple info query.\n================\n*/\nvoid SVC_Status( netadr_t from ) {\n\tchar\tplayer[1024];\n\tchar\tstatus[MAX_MSGLEN];\n\tint\t\ti;\n\tclient_t\t*cl;\n\tplayerState_t\t*ps;\n\tint\t\tstatusLength;\n\tint\t\tplayerLength;\n\tchar\tinfostring[MAX_INFO_STRING];\n\n\t// ignore if we are in single player\n\tif ( Cvar_VariableValue( \"g_gametype\" ) == GT_SINGLE_PLAYER ) {\n\t\treturn;\n\t}\n\n\tstrcpy( infostring, Cvar_InfoString( CVAR_SERVERINFO ) );\n\n\t// echo back the parameter to status. so master servers can use it as a challenge\n\t// to prevent timed spoofed reply packets that add ghost servers\n\tInfo_SetValueForKey( infostring, \"challenge\", Cmd_Argv(1) );\n\n\t// add \"demo\" to the sv_keywords if restricted\n\tif ( Cvar_VariableValue( \"fs_restrict\" ) ) {\n\t\tchar\tkeywords[MAX_INFO_STRING];\n\n\t\tCom_sprintf( keywords, sizeof( keywords ), \"demo %s\",\n\t\t\tInfo_ValueForKey( infostring, \"sv_keywords\" ) );\n\t\tInfo_SetValueForKey( infostring, \"sv_keywords\", keywords );\n\t}\n\n\tstatus[0] = 0;\n\tstatusLength = 0;\n\n\tfor (i=0 ; i < sv_maxclients->integer ; i++) {\n\t\tcl = &svs.clients[i];\n\t\tif ( cl->state >= CS_CONNECTED ) {\n\t\t\tps = SV_GameClientNum( i );\n\t\t\tCom_sprintf (player, sizeof(player), \"%i %i \\\"%s\\\"\\n\", \n\t\t\t\tps->persistant[PERS_SCORE], cl->ping, cl->name);\n\t\t\tplayerLength = strlen(player);\n\t\t\tif (statusLength + playerLength >= sizeof(status) ) {\n\t\t\t\tbreak;\t\t// can't hold any more\n\t\t\t}\n\t\t\tstrcpy (status + statusLength, player);\n\t\t\tstatusLength += playerLength;\n\t\t}\n\t}\n\n\tNET_OutOfBandPrint( NS_SERVER, from, \"statusResponse\\n%s\\n%s\", infostring, status );\n}\n\n/*\n================\nSVC_Info\n\nResponds with a short info message that should be enough to determine\nif a user is interested in a server to do a full status\n================\n*/\nvoid SVC_Info( netadr_t from ) {\n\tint\t\ti, count;\n\tchar\t*gamedir;\n\tchar\tinfostring[MAX_INFO_STRING];\n\n\t// ignore if we are in single player\n\tif ( Cvar_VariableValue( \"g_gametype\" ) == GT_SINGLE_PLAYER || Cvar_VariableValue(\"ui_singlePlayerActive\")) {\n\t\treturn;\n\t}\n\n\t// don't count privateclients\n\tcount = 0;\n\tfor ( i = sv_privateClients->integer ; i < sv_maxclients->integer ; i++ ) {\n\t\tif ( svs.clients[i].state >= CS_CONNECTED ) {\n\t\t\tcount++;\n\t\t}\n\t}\n\n\tinfostring[0] = 0;\n\n\t// echo back the parameter to status. so servers can use it as a challenge\n\t// to prevent timed spoofed reply packets that add ghost servers\n\tInfo_SetValueForKey( infostring, \"challenge\", Cmd_Argv(1) );\n\n\tInfo_SetValueForKey( infostring, \"protocol\", va(\"%i\", PROTOCOL_VERSION) );\n\tInfo_SetValueForKey( infostring, \"hostname\", sv_hostname->string );\n\tInfo_SetValueForKey( infostring, \"mapname\", sv_mapname->string );\n\tInfo_SetValueForKey( infostring, \"clients\", va(\"%i\", count) );\n\tInfo_SetValueForKey( infostring, \"sv_maxclients\", \n\t\tva(\"%i\", sv_maxclients->integer - sv_privateClients->integer ) );\n\tInfo_SetValueForKey( infostring, \"gametype\", va(\"%i\", sv_gametype->integer ) );\n\tInfo_SetValueForKey( infostring, \"pure\", va(\"%i\", sv_pure->integer ) );\n\n\tif( sv_minPing->integer ) {\n\t\tInfo_SetValueForKey( infostring, \"minPing\", va(\"%i\", sv_minPing->integer) );\n\t}\n\tif( sv_maxPing->integer ) {\n\t\tInfo_SetValueForKey( infostring, \"maxPing\", va(\"%i\", sv_maxPing->integer) );\n\t}\n\tgamedir = Cvar_VariableString( \"fs_game\" );\n\tif( *gamedir ) {\n\t\tInfo_SetValueForKey( infostring, \"game\", gamedir );\n\t}\n\n\tNET_OutOfBandPrint( NS_SERVER, from, \"infoResponse\\n%s\", infostring );\n}\n\n/*\n================\nSVC_FlushRedirect\n\n================\n*/\nvoid SV_FlushRedirect( char *outputbuf ) {\n\tNET_OutOfBandPrint( NS_SERVER, svs.redirectAddress, \"print\\n%s\", outputbuf );\n}\n\n/*\n===============\nSVC_RemoteCommand\n\nAn rcon packet arrived from the network.\nShift down the remaining args\nRedirect all printfs\n===============\n*/\nvoid SVC_RemoteCommand( netadr_t from, msg_t *msg ) {\n\tqboolean\tvalid;\n\tunsigned int time;\n\tchar\t\tremaining[1024];\n\t// TTimo - scaled down to accumulate, but not overflow anything network wise, print wise etc.\n\t// (OOB messages are the bottleneck here)\n#define SV_OUTPUTBUF_LENGTH (1024 - 16)\n\tchar\t\tsv_outputbuf[SV_OUTPUTBUF_LENGTH];\n\tstatic unsigned int lasttime = 0;\n\tchar *cmd_aux;\n\n\t// TTimo - https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=534\n\ttime = Com_Milliseconds();\n\tif (time<(lasttime+500)) {\n\t\treturn;\n\t}\n\tlasttime = time;\n\n\tif ( !strlen( sv_rconPassword->string ) ||\n\t\tstrcmp (Cmd_Argv(1), sv_rconPassword->string) ) {\n\t\tvalid = qfalse;\n\t\tCom_Printf (\"Bad rcon from %s:\\n%s\\n\", NET_AdrToString (from), Cmd_Argv(2) );\n\t} else {\n\t\tvalid = qtrue;\n\t\tCom_Printf (\"Rcon from %s:\\n%s\\n\", NET_AdrToString (from), Cmd_Argv(2) );\n\t}\n\n\t// start redirecting all print outputs to the packet\n\tsvs.redirectAddress = from;\n\tCom_BeginRedirect (sv_outputbuf, SV_OUTPUTBUF_LENGTH, SV_FlushRedirect);\n\n\tif ( !strlen( sv_rconPassword->string ) ) {\n\t\tCom_Printf (\"No rconpassword set on the server.\\n\");\n\t} else if ( !valid ) {\n\t\tCom_Printf (\"Bad rconpassword.\\n\");\n\t} else {\n\t\tremaining[0] = 0;\n\t\t\n\t\t// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=543\n\t\t// get the command directly, \"rcon <pass> <command>\" to avoid quoting issues\n\t\t// extract the command by walking\n\t\t// since the cmd formatting can fuckup (amount of spaces), using a dumb step by step parsing\n\t\tcmd_aux = Cmd_Cmd();\n\t\tcmd_aux+=4;\n\t\twhile(cmd_aux[0]==' ')\n\t\t\tcmd_aux++;\n\t\twhile(cmd_aux[0] && cmd_aux[0]!=' ') // password\n\t\t\tcmd_aux++;\n\t\twhile(cmd_aux[0]==' ')\n\t\t\tcmd_aux++;\n\t\t\n\t\tQ_strcat( remaining, sizeof(remaining), cmd_aux);\n\t\t\n\t\tCmd_ExecuteString (remaining);\n\n\t}\n\n\tCom_EndRedirect ();\n}\n\n/*\n=================\nSV_ConnectionlessPacket\n\nA connectionless packet has four leading 0xff\ncharacters to distinguish it from a game channel.\nClients that are in the game can still send\nconnectionless packets.\n=================\n*/\nvoid SV_ConnectionlessPacket( netadr_t from, msg_t *msg ) {\n\tchar\t*s;\n\tchar\t*c;\n\n\tMSG_BeginReadingOOB( msg );\n\tMSG_ReadLong( msg );\t\t// skip the -1 marker\n\n\tif (!Q_strncmp(\"connect\", &msg->data[4], 7)) {\n\t\tHuff_Decompress(msg, 12);\n\t}\n\n\ts = MSG_ReadStringLine( msg );\n\tCmd_TokenizeString( s );\n\n\tc = Cmd_Argv(0);\n\tCom_DPrintf (\"SV packet %s : %s\\n\", NET_AdrToString(from), c);\n\n\tif (!Q_stricmp(c, \"getstatus\")) {\n\t\tSVC_Status( from  );\n  } else if (!Q_stricmp(c, \"getinfo\")) {\n\t\tSVC_Info( from );\n\t} else if (!Q_stricmp(c, \"getchallenge\")) {\n\t\tSV_GetChallenge( from );\n\t} else if (!Q_stricmp(c, \"connect\")) {\n\t\tSV_DirectConnect( from );\n\t} else if (!Q_stricmp(c, \"ipAuthorize\")) {\n\t\tSV_AuthorizeIpPacket( from );\n\t} else if (!Q_stricmp(c, \"rcon\")) {\n\t\tSVC_RemoteCommand( from, msg );\n\t} else if (!Q_stricmp(c, \"disconnect\")) {\n\t\t// if a client starts up a local server, we may see some spurious\n\t\t// server disconnect messages when their new server sees our final\n\t\t// sequenced messages to the old client\n\t} else {\n\t\tCom_DPrintf (\"bad connectionless packet from %s:\\n%s\\n\"\n\t\t, NET_AdrToString (from), s);\n\t}\n}\n\n//============================================================================\n\n/*\n=================\nSV_ReadPackets\n=================\n*/\nvoid SV_PacketEvent( netadr_t from, msg_t *msg ) {\n\tint\t\t\ti;\n\tclient_t\t*cl;\n\tint\t\t\tqport;\n\n\t// check for connectionless packet (0xffffffff) first\n\tif ( msg->cursize >= 4 && *(int *)msg->data == -1) {\n\t\tSV_ConnectionlessPacket( from, msg );\n\t\treturn;\n\t}\n\n\t// read the qport out of the message so we can fix up\n\t// stupid address translating routers\n\tMSG_BeginReadingOOB( msg );\n\tMSG_ReadLong( msg );\t\t\t\t// sequence number\n\tqport = MSG_ReadShort( msg ) & 0xffff;\n\n\t// find which client the message is from\n\tfor (i=0, cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++) {\n\t\tif (cl->state == CS_FREE) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( !NET_CompareBaseAdr( from, cl->netchan.remoteAddress ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// it is possible to have multiple clients from a single IP\n\t\t// address, so they are differentiated by the qport variable\n\t\tif (cl->netchan.qport != qport) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// the IP port can't be used to differentiate them, because\n\t\t// some address translating routers periodically change UDP\n\t\t// port assignments\n\t\tif (cl->netchan.remoteAddress.port != from.port) {\n\t\t\tCom_Printf( \"SV_PacketEvent: fixing up a translated port\\n\" );\n\t\t\tcl->netchan.remoteAddress.port = from.port;\n\t\t}\n\n\t\t// make sure it is a valid, in sequence packet\n\t\tif (SV_Netchan_Process(cl, msg)) {\n\t\t\t// zombie clients still need to do the Netchan_Process\n\t\t\t// to make sure they don't need to retransmit the final\n\t\t\t// reliable message, but they don't do any other processing\n\t\t\tif (cl->state != CS_ZOMBIE) {\n\t\t\t\tcl->lastPacketTime = svs.time;\t// don't timeout\n\t\t\t\tSV_ExecuteClientMessage( cl, msg );\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\t\n\t// if we received a sequenced packet from an address we don't recognize,\n\t// send an out of band disconnect packet to it\n\tNET_OutOfBandPrint( NS_SERVER, from, \"disconnect\" );\n}\n\n\n/*\n===================\nSV_CalcPings\n\nUpdates the cl->ping variables\n===================\n*/\nvoid SV_CalcPings( void ) {\n\tint\t\t\ti, j;\n\tclient_t\t*cl;\n\tint\t\t\ttotal, count;\n\tint\t\t\tdelta;\n\tplayerState_t\t*ps;\n\n\tfor (i=0 ; i < sv_maxclients->integer ; i++) {\n\t\tcl = &svs.clients[i];\n\t\tif ( cl->state != CS_ACTIVE ) {\n\t\t\tcl->ping = 999;\n\t\t\tcontinue;\n\t\t}\n\t\tif ( !cl->gentity ) {\n\t\t\tcl->ping = 999;\n\t\t\tcontinue;\n\t\t}\n\t\tif ( cl->gentity->r.svFlags & SVF_BOT ) {\n\t\t\tcl->ping = 0;\n\t\t\tcontinue;\n\t\t}\n\n\t\ttotal = 0;\n\t\tcount = 0;\n\t\tfor ( j = 0 ; j < PACKET_BACKUP ; j++ ) {\n\t\t\tif ( cl->frames[j].messageAcked <= 0 ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tdelta = cl->frames[j].messageAcked - cl->frames[j].messageSent;\n\t\t\tcount++;\n\t\t\ttotal += delta;\n\t\t}\n\t\tif (!count) {\n\t\t\tcl->ping = 999;\n\t\t} else {\n\t\t\tcl->ping = total/count;\n\t\t\tif ( cl->ping > 999 ) {\n\t\t\t\tcl->ping = 999;\n\t\t\t}\n\t\t}\n\n\t\t// let the game dll know about the ping\n\t\tps = SV_GameClientNum( i );\n\t\tps->ping = cl->ping;\n\t}\n}\n\n/*\n==================\nSV_CheckTimeouts\n\nIf a packet has not been received from a client for timeout->integer \nseconds, drop the conneciton.  Server time is used instead of\nrealtime to avoid dropping the local client while debugging.\n\nWhen a client is normally dropped, the client_t goes into a zombie state\nfor a few seconds to make sure any final reliable message gets resent\nif necessary\n==================\n*/\nvoid SV_CheckTimeouts( void ) {\n\tint\t\ti;\n\tclient_t\t*cl;\n\tint\t\t\tdroppoint;\n\tint\t\t\tzombiepoint;\n\n\tdroppoint = svs.time - 1000 * sv_timeout->integer;\n\tzombiepoint = svs.time - 1000 * sv_zombietime->integer;\n\n\tfor (i=0,cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++) {\n\t\t// message times may be wrong across a changelevel\n\t\tif (cl->lastPacketTime > svs.time) {\n\t\t\tcl->lastPacketTime = svs.time;\n\t\t}\n\n\t\tif (cl->state == CS_ZOMBIE\n\t\t&& cl->lastPacketTime < zombiepoint) {\n\t\t\t// using the client id cause the cl->name is empty at this point\n\t\t\tCom_DPrintf( \"Going from CS_ZOMBIE to CS_FREE for client %d\\n\", i );\n\t\t\tcl->state = CS_FREE;\t// can now be reused\n\t\t\tcontinue;\n\t\t}\n\t\tif ( cl->state >= CS_CONNECTED && cl->lastPacketTime < droppoint) {\n\t\t\t// wait several frames so a debugger session doesn't\n\t\t\t// cause a timeout\n\t\t\tif ( ++cl->timeoutCount > 5 ) {\n\t\t\t\tSV_DropClient (cl, \"timed out\"); \n\t\t\t\tcl->state = CS_FREE;\t// don't bother with zombie state\n\t\t\t}\n\t\t} else {\n\t\t\tcl->timeoutCount = 0;\n\t\t}\n\t}\n}\n\n\n/*\n==================\nSV_CheckPaused\n==================\n*/\nqboolean SV_CheckPaused( void ) {\n\tint\t\tcount;\n\tclient_t\t*cl;\n\tint\t\ti;\n\n\tif ( !cl_paused->integer ) {\n\t\treturn qfalse;\n\t}\n\n\t// only pause if there is just a single client connected\n\tcount = 0;\n\tfor (i=0,cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++) {\n\t\tif ( cl->state >= CS_CONNECTED && cl->netchan.remoteAddress.type != NA_BOT ) {\n\t\t\tcount++;\n\t\t}\n\t}\n\n\tif ( count > 1 ) {\n\t\t// don't pause\n\t\tif (sv_paused->integer)\n\t\t\tCvar_Set(\"sv_paused\", \"0\");\n\t\treturn qfalse;\n\t}\n\n\tif (!sv_paused->integer)\n\t\tCvar_Set(\"sv_paused\", \"1\");\n\treturn qtrue;\n}\n\n/*\n==================\nSV_Frame\n\nPlayer movement occurs as a result of packet events, which\nhappen before SV_Frame is called\n==================\n*/\nvoid SV_Frame( int msec ) {\n\tint\t\tframeMsec;\n\tint\t\tstartTime;\n\n\t// the menu kills the server with this cvar\n\tif ( sv_killserver->integer ) {\n\t\tSV_Shutdown (\"Server was killed.\\n\");\n\t\tCvar_Set( \"sv_killserver\", \"0\" );\n\t\treturn;\n\t}\n\n\tif ( !com_sv_running->integer ) {\n\t\treturn;\n\t}\n\n\t// allow pause if only the local client is connected\n\tif ( SV_CheckPaused() ) {\n\t\treturn;\n\t}\n\n\t// if it isn't time for the next frame, do nothing\n\tif ( sv_fps->integer < 1 ) {\n\t\tCvar_Set( \"sv_fps\", \"10\" );\n\t}\n\tframeMsec = 1000 / sv_fps->integer ;\n\n\tsv.timeResidual += msec;\n\n\tif (!com_dedicated->integer) SV_BotFrame( svs.time + sv.timeResidual );\n\n\tif ( com_dedicated->integer && sv.timeResidual < frameMsec ) {\n\t\t// NET_Sleep will give the OS time slices until either get a packet\n\t\t// or time enough for a server frame has gone by\n\t\tNET_Sleep(frameMsec - sv.timeResidual);\n\t\treturn;\n\t}\n\n\t// if time is about to hit the 32nd bit, kick all clients\n\t// and clear sv.time, rather\n\t// than checking for negative time wraparound everywhere.\n\t// 2giga-milliseconds = 23 days, so it won't be too often\n\tif ( svs.time > 0x70000000 ) {\n\t\tSV_Shutdown( \"Restarting server due to time wrapping\" );\n\t\tCbuf_AddText( \"vstr nextmap\\n\" );\n\t\treturn;\n\t}\n\t// this can happen considerably earlier when lots of clients play and the map doesn't change\n\tif ( svs.nextSnapshotEntities >= 0x7FFFFFFE - svs.numSnapshotEntities ) {\n\t\tSV_Shutdown( \"Restarting server due to numSnapshotEntities wrapping\" );\n\t\tCbuf_AddText( \"vstr nextmap\\n\" );\n\t\treturn;\n\t}\n\n\tif( sv.restartTime && svs.time >= sv.restartTime ) {\n\t\tsv.restartTime = 0;\n\t\tCbuf_AddText( \"map_restart 0\\n\" );\n\t\treturn;\n\t}\n\n\t// update infostrings if anything has been changed\n\tif ( cvar_modifiedFlags & CVAR_SERVERINFO ) {\n\t\tSV_SetConfigstring( CS_SERVERINFO, Cvar_InfoString( CVAR_SERVERINFO ) );\n\t\tcvar_modifiedFlags &= ~CVAR_SERVERINFO;\n\t}\n\tif ( cvar_modifiedFlags & CVAR_SYSTEMINFO ) {\n\t\tSV_SetConfigstring( CS_SYSTEMINFO, Cvar_InfoString_Big( CVAR_SYSTEMINFO ) );\n\t\tcvar_modifiedFlags &= ~CVAR_SYSTEMINFO;\n\t}\n\n\tif ( com_speeds->integer ) {\n\t\tstartTime = Sys_Milliseconds ();\n\t} else {\n\t\tstartTime = 0;\t// quite a compiler warning\n\t}\n\n\t// update ping based on the all received frames\n\tSV_CalcPings();\n\n\tif (com_dedicated->integer) SV_BotFrame( svs.time );\n\n\t// run the game simulation in chunks\n\twhile ( sv.timeResidual >= frameMsec ) {\n\t\tsv.timeResidual -= frameMsec;\n\t\tsvs.time += frameMsec;\n\n\t\t// let everything in the world think and move\n\t\tVM_Call( gvm, GAME_RUN_FRAME, svs.time );\n\t}\n\n\tif ( com_speeds->integer ) {\n\t\ttime_game = Sys_Milliseconds () - startTime;\n\t}\n\n\t// check timeouts\n\tSV_CheckTimeouts();\n\n\t// send messages back to the clients\n\tSV_SendClientMessages();\n\n\t// send a heartbeat to the master if needed\n\tSV_MasterHeartbeat();\n}\n\n//============================================================================\n\n"
  },
  {
    "path": "code/server/sv_net_chan.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"../game/q_shared.h\"\n#include \"../qcommon/qcommon.h\"\n#include \"server.h\"\n\n/*\n==============\nSV_Netchan_Encode\n\n\t// first four bytes of the data are always:\n\tlong reliableAcknowledge;\n\n==============\n*/\nstatic void SV_Netchan_Encode( client_t *client, msg_t *msg ) {\n\tlong reliableAcknowledge, i, index;\n\tbyte key, *string;\n        int\tsrdc, sbit, soob;\n        \n\tif ( msg->cursize < SV_ENCODE_START ) {\n\t\treturn;\n\t}\n\n        srdc = msg->readcount;\n        sbit = msg->bit;\n        soob = msg->oob;\n        \n        msg->bit = 0;\n        msg->readcount = 0;\n        msg->oob = 0;\n        \n\treliableAcknowledge = MSG_ReadLong(msg);\n\n        msg->oob = soob;\n        msg->bit = sbit;\n        msg->readcount = srdc;\n        \n\tstring = (byte *)client->lastClientCommandString;\n\tindex = 0;\n\t// xor the client challenge with the netchan sequence number\n\tkey = client->challenge ^ client->netchan.outgoingSequence;\n\tfor (i = SV_ENCODE_START; i < msg->cursize; i++) {\n\t\t// modify the key with the last received and with this message acknowledged client command\n\t\tif (!string[index])\n\t\t\tindex = 0;\n\t\tif (string[index] > 127 || string[index] == '%') {\n\t\t\tkey ^= '.' << (i & 1);\n\t\t}\n\t\telse {\n\t\t\tkey ^= string[index] << (i & 1);\n\t\t}\n\t\tindex++;\n\t\t// encode the data with this key\n\t\t*(msg->data + i) = *(msg->data + i) ^ key;\n\t}\n}\n\n/*\n==============\nSV_Netchan_Decode\n\n\t// first 12 bytes of the data are always:\n\tlong serverId;\n\tlong messageAcknowledge;\n\tlong reliableAcknowledge;\n\n==============\n*/\nstatic void SV_Netchan_Decode( client_t *client, msg_t *msg ) {\n\tint serverId, messageAcknowledge, reliableAcknowledge;\n\tint i, index, srdc, sbit, soob;\n\tbyte key, *string;\n\n        srdc = msg->readcount;\n        sbit = msg->bit;\n        soob = msg->oob;\n        \n        msg->oob = 0;\n        \n        serverId = MSG_ReadLong(msg);\n\tmessageAcknowledge = MSG_ReadLong(msg);\n\treliableAcknowledge = MSG_ReadLong(msg);\n\n        msg->oob = soob;\n        msg->bit = sbit;\n        msg->readcount = srdc;\n        \n\tstring = (byte *)client->reliableCommands[ reliableAcknowledge & (MAX_RELIABLE_COMMANDS-1) ];\n\tindex = 0;\n\t//\n\tkey = client->challenge ^ serverId ^ messageAcknowledge;\n\tfor (i = msg->readcount + SV_DECODE_START; i < msg->cursize; i++) {\n\t\t// modify the key with the last sent and acknowledged server command\n\t\tif (!string[index])\n\t\t\tindex = 0;\n\t\tif (string[index] > 127 || string[index] == '%') {\n\t\t\tkey ^= '.' << (i & 1);\n\t\t}\n\t\telse {\n\t\t\tkey ^= string[index] << (i & 1);\n\t\t}\n\t\tindex++;\n\t\t// decode the data with this key\n\t\t*(msg->data + i) = *(msg->data + i) ^ key;\n\t}\n}\n\n/*\n=================\nSV_Netchan_TransmitNextFragment\n=================\n*/\nvoid SV_Netchan_TransmitNextFragment( client_t *client ) {\n\tNetchan_TransmitNextFragment( &client->netchan );\n\tif (!client->netchan.unsentFragments)\n\t{\n\t\t// make sure the netchan queue has been properly initialized (you never know)\n\t\tif (!client->netchan_end_queue) {\n\t\t\tCom_Error(ERR_DROP, \"netchan queue is not properly initialized in SV_Netchan_TransmitNextFragment\\n\");\n\t\t}\n\t\t// the last fragment was transmitted, check wether we have queued messages\n\t\tif (client->netchan_start_queue) {\n\t\t\tnetchan_buffer_t *netbuf;\n\t\t\tCom_DPrintf(\"#462 Netchan_TransmitNextFragment: popping a queued message for transmit\\n\");\n\t\t\tnetbuf = client->netchan_start_queue;\n\t\t\tSV_Netchan_Encode( client, &netbuf->msg );\n\t\t\tNetchan_Transmit( &client->netchan, netbuf->msg.cursize, netbuf->msg.data );\n\t\t\t// pop from queue\n\t\t\tclient->netchan_start_queue = netbuf->next;\n\t\t\tif (!client->netchan_start_queue) {\n\t\t\t\tCom_DPrintf(\"#462 Netchan_TransmitNextFragment: emptied queue\\n\");\n\t\t\t\tclient->netchan_end_queue = &client->netchan_start_queue;\n\t\t\t}\n\t\t\telse\n\t\t\t\tCom_DPrintf(\"#462 Netchan_TransmitNextFragment: remaining queued message\\n\");\n\t\t\tZ_Free(netbuf);\n\t\t} \n\t}\t\n}\n\n\n/*\n===============\nSV_Netchan_Transmit\nTTimo\nhttps://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=462\nif there are some unsent fragments (which may happen if the snapshots\nand the gamestate are fragmenting, and collide on send for instance)\nthen buffer them and make sure they get sent in correct order\n================\n*/\n\nvoid SV_Netchan_Transmit( client_t *client, msg_t *msg) {\t//int length, const byte *data ) {\n\tMSG_WriteByte( msg, svc_EOF );\n\tif (client->netchan.unsentFragments) {\n\t\tnetchan_buffer_t *netbuf;\n\t\tCom_DPrintf(\"#462 SV_Netchan_Transmit: unsent fragments, stacked\\n\");\n\t\tnetbuf = (netchan_buffer_t *)Z_Malloc(sizeof(netchan_buffer_t));\n\t\t// store the msg, we can't store it encoded, as the encoding depends on stuff we still have to finish sending\n\t\tMSG_Copy(&netbuf->msg, netbuf->msgBuffer, sizeof( netbuf->msgBuffer ), msg);\n\t\tnetbuf->next = NULL;\n\t\t// insert it in the queue, the message will be encoded and sent later\n\t\t*client->netchan_end_queue = netbuf;\n\t\tclient->netchan_end_queue = &(*client->netchan_end_queue)->next;\n\t\t// emit the next fragment of the current message for now\n\t\tNetchan_TransmitNextFragment(&client->netchan);\n\t} else {\n\t\tSV_Netchan_Encode( client, msg );\n\t\tNetchan_Transmit( &client->netchan, msg->cursize, msg->data );\n\t}\n}\n\n/*\n=================\nNetchan_SV_Process\n=================\n*/\nqboolean SV_Netchan_Process( client_t *client, msg_t *msg ) {\n\tint ret;\n\tret = Netchan_Process( &client->netchan, msg );\n\tif (!ret)\n\t\treturn qfalse;\n\tSV_Netchan_Decode( client, msg );\n\treturn qtrue;\n}\n\n"
  },
  {
    "path": "code/server/sv_rankings.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// sv_rankings.c -- global rankings interface\n\n#include \"server.h\"\n#include \"..\\rankings\\1.0\\gr\\grapi.h\"\n#include \"..\\rankings\\1.0\\gr\\grlog.h\"\n\ntypedef struct\n{\n\tGR_CONTEXT\t\tcontext;\n\tuint64_t        game_id;\n\tuint64_t\t\tmatch;\n\tuint64_t\t\tplayer_id;\n\tGR_PLAYER_TOKEN     token;\n\tgrank_status_t\tgrank_status;\n\tgrank_status_t\tfinal_status;\t// status to set after cleanup\n\tuint32_t        grank;          // global rank\n\tchar\t\t\tname[32];\n} ranked_player_t;\n\nstatic int\t\t\t\ts_rankings_contexts = 0;\nstatic qboolean\t\t\ts_rankings_active = qfalse;\nstatic GR_CONTEXT\t\ts_server_context = 0;\nstatic uint64_t\t\t\ts_server_match = 0;\nstatic char*\t\t\ts_rankings_game_key = NULL;\nstatic uint64_t\t\t\ts_rankings_game_id = 0;\nstatic ranked_player_t*\ts_ranked_players = NULL;\nstatic qboolean\t\t\ts_server_quitting = qfalse;\nstatic const char\t\ts_ascii_encoding[] = \n\t\t\t\t\t\t\t\"0123456789abcdef\"\n\t\t\t\t\t\t\t\"ghijklmnopqrstuv\"\n\t\t\t\t\t\t\t\"wxyzABCDEFGHIJKL\"\n\t\t\t\t\t\t\t\"MNOPQRSTUVWXYZ[]\";\n\n// private functions\nstatic void\t\tSV_RankNewGameCBF( GR_NEWGAME* gr_newgame, void* cbf_arg );\nstatic void\t\tSV_RankUserCBF( GR_LOGIN* gr_login, void* cbf_arg );\nstatic void\t\tSV_RankJoinGameCBF( GR_JOINGAME* gr_joingame, void* cbf_arg );\nstatic void\t\tSV_RankSendReportsCBF( GR_STATUS* gr_status, void* cbf_arg );\nstatic void\t\tSV_RankCleanupCBF( GR_STATUS* gr_status, void* cbf_arg );\nstatic void\t\tSV_RankCloseContext( ranked_player_t* ranked_player );\nstatic int\t\tSV_RankAsciiEncode( char* dest, const unsigned char* src, \n\t\t\t\t\tint src_len );\nstatic int\t\tSV_RankAsciiDecode( unsigned char* dest, const char* src, \n\t\t\t\t\tint src_len );\nstatic void\t\tSV_RankEncodeGameID( uint64_t game_id, char* result, \n\t\t\t\t\tint len );\nstatic uint64_t\tSV_RankDecodePlayerID( const char* string );\nstatic void\t\tSV_RankDecodePlayerKey( const char* string, GR_PLAYER_TOKEN key );\nstatic char*\tSV_RankStatusString( GR_STATUS status );\nstatic void\t\tSV_RankError( const char* fmt, ... );\nstatic char     SV_RankGameKey[64];\n\n/*\n================\nSV_RankBegin\n================\n*/\nvoid SV_RankBegin( char *gamekey )\n{\n\tGR_INIT\t\tinit;\n\tGR_STATUS\tstatus;\n\n\tassert( s_rankings_contexts == 0 );\n\tassert( !s_rankings_active );\n\tassert( s_ranked_players == NULL );\n\n\tif( sv_enableRankings->integer == 0 || Cvar_VariableValue( \"g_gametype\" ) == GT_SINGLE_PLAYER )\n\t{\n\t\ts_rankings_active = qfalse;\n\t\tif( sv_rankingsActive->integer == 1 )\n\t\t{\n\t\t\tCvar_Set( \"sv_rankingsActive\", \"0\" );\n\t\t}\n\t\treturn;\n\t}\n\n\t// only allow official game key on pure servers\n\tif( strcmp(gamekey, GR_GAMEKEY) == 0 )\n\t{\n/*\n\t\tif( Cvar_VariableValue(\"sv_pure\") != 1 )\n\t\t{\n\t\t\tCvar_Set( \"sv_enableRankings\", \"0\" );\n\t\t\treturn;\n\t\t}\n*/\n\n\t\t// substitute game-specific game key\n\t\tswitch( (int)Cvar_VariableValue(\"g_gametype\") )\n\t\t{\n\t\tcase GT_FFA:\n\t\t\tgamekey = \"Q3 Free For All\";\n\t\t\tbreak;\n\t\tcase GT_TOURNAMENT:\n\t\t\tgamekey = \"Q3 Tournament\";\n\t\t\tbreak;\n\t\tcase GT_TEAM:\n\t\t\tgamekey = \"Q3 Team Deathmatch\";\n\t\t\tbreak;\n\t\tcase GT_CTF:\n\t\t\tgamekey = \"Q3 Capture the Flag\";\n\t\t\tbreak;\n\t\tcase GT_1FCTF:\n\t\t\tgamekey = \"Q3 One Flag CTF\";\n\t\t\tbreak;\n\t\tcase GT_OBELISK:\n\t\t\tgamekey = \"Q3 Overload\";\n\t\t\tbreak;\n\t\tcase GT_HARVESTER:\n\t\t\tgamekey = \"Q3 Harvester\";\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}\n\ts_rankings_game_key = gamekey;\n\n\t// initialize rankings\n\tGRankLogLevel( GRLOG_OFF );\n\tmemset(SV_RankGameKey,0,sizeof(SV_RankGameKey));\n\tstrncpy(SV_RankGameKey,gamekey,sizeof(SV_RankGameKey)-1);\n\tinit = GRankInit( 1, SV_RankGameKey, GR_OPT_POLL, GR_OPT_END );\n\ts_server_context = init.context;\n\ts_rankings_contexts++;\n\tCom_DPrintf( \"SV_RankBegin(); GR_GAMEKEY is %s\\n\", gamekey );\n\tCom_DPrintf( \"SV_RankBegin(); s_rankings_contexts=%d\\n\",s_rankings_contexts );\n\tCom_DPrintf( \"SV_RankBegin(); s_server_context=%d\\n\",init.context );\n\n\t// new game\n\tif(!strlen(Cvar_VariableString( \"sv_leagueName\" )))\n\t{\n\t\tstatus = GRankNewGameAsync\n\t\t\t( \t\t\t\n\t\t\t\ts_server_context, \n\t\t\t\tSV_RankNewGameCBF, \n\t\t\t\tNULL, \n\t\t\t\tGR_OPT_LEAGUENAME,\n\t\t\t\t(void*)(Cvar_VariableString( \"sv_leagueName\" )),\n\t\t\t\tGR_OPT_END \n\t\t\t);\n\t}\n\telse\n\t{\n\t\tstatus = GRankNewGameAsync\n\t\t\t( \t\t\t\n\t\t\t\ts_server_context, \n\t\t\t\tSV_RankNewGameCBF, \n\t\t\t\tNULL, \n\t\t\t\tGR_OPT_END \n\t\t\t);\n\t}\n\t\t\n\tif( status != GR_STATUS_PENDING )\n\t{\n\t\tSV_RankError( \"SV_RankBegin: Expected GR_STATUS_PENDING, got %s\", \n\t\t\tSV_RankStatusString( status ) );\n\t\treturn;\n\t}\n\n\t// logging\n\tif( com_developer->value )\n\t{\n\t\tGRankLogLevel( GRLOG_TRACE );\n\t}\n\t\n\t// allocate rankings info for each player\n\ts_ranked_players = Z_Malloc( sv_maxclients->value * \n\t\tsizeof(ranked_player_t) );\n\tmemset( (void*)s_ranked_players, 0 ,sv_maxclients->value \n\t\t* sizeof(ranked_player_t));\n}\n\n/*\n================\nSV_RankEnd\n================\n*/\nvoid SV_RankEnd( void )\n{\n\tGR_STATUS\tstatus;\n\tint\t\t\ti;\n\t\n\tCom_DPrintf( \"SV_RankEnd();\\n\" );\n\n\tif( !s_rankings_active )\n\t{\n\t\t// cleanup after error during game\n\t\tif( s_ranked_players != NULL )\n\t\t{\n\t\t\tfor( i = 0; i < sv_maxclients->value; i++ )\n\t\t\t{\n\t\t\t\tif( s_ranked_players[i].context != 0 )\n\t\t\t\t{\n\t\t\t\t\tSV_RankCloseContext( &(s_ranked_players[i]) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif( s_server_context != 0 )\n\t\t{\n\t\t\tSV_RankCloseContext( NULL );\n\t\t}\n\n\t\treturn;\n\t}\n\n\tfor( i = 0; i < sv_maxclients->value; i++ )\n\t{\n\t\tif( s_ranked_players[i].grank_status == QGR_STATUS_ACTIVE )\n\t\t{\n\t\t\tSV_RankUserLogout( i );\n\t\t\tCom_DPrintf( \"SV_RankEnd: SV_RankUserLogout %d\\n\",i );\n\t\t}\n\t}\n\n\tassert( s_server_context != 0 );\n\t\n\t// send match reports, proceed to SV_RankSendReportsCBF\n\tstatus = GRankSendReportsAsync\n\t\t( \n\t\t\ts_server_context,\n\t\t\t0,\n\t\t\tSV_RankSendReportsCBF,\n\t\t\tNULL, \n\t\t\tGR_OPT_END\n\t\t);\n\t\t\t\n\tif( status != GR_STATUS_PENDING )\n\t{\n\t\tSV_RankError( \"SV_RankEnd: Expected GR_STATUS_PENDING, got %s\", \n\t\t\tSV_RankStatusString( status ) );\n\t}\n\n\ts_rankings_active = qfalse;\n\tCvar_Set( \"sv_rankingsActive\", \"0\" );\n}\n\n/*\n================\nSV_RankPoll\n================\n*/\nvoid SV_RankPoll( void )\n{\n\tGRankPoll();\n}\n\n/*\n================\nSV_RankCheckInit\n================\n*/\nqboolean SV_RankCheckInit( void )\n{\n\treturn (s_rankings_contexts > 0);\n}\n\n/*\n================\nSV_RankActive\n================\n*/\nqboolean SV_RankActive( void )\n{\n\treturn s_rankings_active;\n}\n\n/*\n=================\nSV_RankUserStatus\n=================\n*/\ngrank_status_t SV_RankUserStatus( int index )\n{\n\tif( !s_rankings_active )\n\t{\n\t\treturn GR_STATUS_ERROR;\n\t}\n\n\tassert( s_ranked_players != NULL );\n\tassert( index >= 0 );\n\tassert( index < sv_maxclients->value );\n\n\treturn s_ranked_players[index].grank_status;\n}\n\n/*\n================\nSV_RankUserGRank\n================\n*/\nint SV_RankUserGrank( int index )\n{\n\tif( !s_rankings_active )\n\t{\n\t\treturn 0;\n\t}\n\n\tassert( s_ranked_players != NULL );\n\tassert( index >= 0 );\n\tassert( index < sv_maxclients->value );\n\n\treturn s_ranked_players[index].grank;\n}\n\n/*\n================\nSV_RankUserReset\n================\n*/\nvoid SV_RankUserReset( int index )\n{\n\tif( !s_rankings_active )\n\t{\n\t\treturn;\n\t}\n\n\tassert( s_ranked_players != NULL );\n\tassert( index >= 0 );\n\tassert( index < sv_maxclients->value );\n\n\tswitch( s_ranked_players[index].grank_status )\n\t{\n\tcase QGR_STATUS_SPECTATOR:\n\tcase QGR_STATUS_NO_USER:\n\tcase QGR_STATUS_BAD_PASSWORD:\n\tcase QGR_STATUS_USER_EXISTS:\n\tcase QGR_STATUS_NO_MEMBERSHIP:\n\tcase QGR_STATUS_TIMEOUT:\n\tcase QGR_STATUS_ERROR:\n\t\ts_ranked_players[index].grank_status = QGR_STATUS_NEW;\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n}\n\n/*\n================\nSV_RankUserSpectate\n================\n*/\nvoid SV_RankUserSpectate( int index )\n{\n\tif( !s_rankings_active )\n\t{\n\t\treturn;\n\t}\n\n\tassert( s_ranked_players != NULL );\n\tassert( index >= 0 );\n\tassert( index < sv_maxclients->value );\n\n\t// GRANK_FIXME - check current status?\n\ts_ranked_players[index].grank_status = QGR_STATUS_SPECTATOR;\n}\n\n/*\n================\nSV_RankUserCreate\n================\n*/\nvoid SV_RankUserCreate( int index, char* username, char* password, \n\tchar* email )\n{\n\tGR_INIT\t\tinit;\n\tGR_STATUS\tstatus;\n\n\tassert( index >= 0 );\n\tassert( index < sv_maxclients->value );\n\tassert( username != NULL );\n\tassert( password != NULL );\n\tassert( email != NULL );\n\tassert( s_ranked_players );\n\tassert( s_ranked_players[index].grank_status != QGR_STATUS_ACTIVE );\n\t\n\tCom_DPrintf( \"SV_RankUserCreate( %d, %s, \\\"****\\\", %s );\\n\", index, \n\t\tusername, email );\n\n\tif( !s_rankings_active )\n\t{\n\t\tCom_DPrintf( \"SV_RankUserCreate: Not ready to create\\n\" );\n\t\ts_ranked_players[index].grank_status = QGR_STATUS_ERROR;\n\t\treturn;\n\t}\n\t\n\tif( s_ranked_players[index].grank_status == QGR_STATUS_ACTIVE )\n\t{\n\t\tCom_DPrintf( \"SV_RankUserCreate: Got Create from active player\\n\" );\n\t\treturn;\n\t}\n\t\n\t// get a separate context for the new user\n\tinit = GRankInit( 0, SV_RankGameKey, GR_OPT_POLL, GR_OPT_END );\n\ts_ranked_players[index].context = init.context;\n\ts_rankings_contexts++;\n\tCom_DPrintf( \"SV_RankUserCreate(); s_rankings_contexts=%d\\n\",s_rankings_contexts );\n\tCom_DPrintf( \"SV_RankUserCreate(); s_ranked_players[%d].context=%d\\n\",index,init.context );\n\t\n\t// attempt to create a new account, proceed to SV_RankUserCBF\n\tstatus = GRankUserCreateAsync\n\t\t( \n\t\t\ts_ranked_players[index].context, \n\t\t\tusername, \n\t\t\tpassword, \n\t\t\temail, \n\t\t\tSV_RankUserCBF, \n\t\t\t(void*)&s_ranked_players[index], \n\t\t\tGR_OPT_END\n\t\t);\n\n\tif( status == GR_STATUS_PENDING )\n\t{\n\t\ts_ranked_players[index].grank_status = QGR_STATUS_PENDING;\n\t\ts_ranked_players[index].final_status = QGR_STATUS_NEW;\n\t}\n\telse\n\t{\n\t\tSV_RankError( \"SV_RankUserCreate: Expected GR_STATUS_PENDING, got %s\", \n\t\t\tSV_RankStatusString( status ) );\n\t}\n}\n\n/*\n================\nSV_RankUserLogin\n================\n*/\nvoid SV_RankUserLogin( int index, char* username, char* password )\n{\n\tGR_INIT\t\tinit;\n\tGR_STATUS\tstatus;\n\n\tassert( index >= 0 );\n\tassert( index < sv_maxclients->value );\n\tassert( username != NULL );\n\tassert( password != NULL );\n\tassert( s_ranked_players );\n\tassert( s_ranked_players[index].grank_status != QGR_STATUS_ACTIVE );\n\n\tCom_DPrintf( \"SV_RankUserLogin( %d, %s, \\\"****\\\" );\\n\", index, username );\n\n\tif( !s_rankings_active )\n\t{\n\t\tCom_DPrintf( \"SV_RankUserLogin: Not ready for login\\n\" );\n\t\ts_ranked_players[index].grank_status = QGR_STATUS_ERROR;\n\t\treturn;\n\t}\n\t\n\tif( s_ranked_players[index].grank_status == QGR_STATUS_ACTIVE )\n\t{\n\t\tCom_DPrintf( \"SV_RankUserLogin: Got Login from active player\\n\" );\n\t\treturn;\n\t}\n\t\n\t// get a separate context for the new user\n\tinit = GRankInit( 0, SV_RankGameKey, GR_OPT_POLL, GR_OPT_END );\n\ts_ranked_players[index].context = init.context;\n\ts_rankings_contexts++;\n\tCom_DPrintf( \"SV_RankUserLogin(); s_rankings_contexts=%d\\n\",s_rankings_contexts );\n\tCom_DPrintf( \"SV_RankUserLogin(); s_ranked_players[%d].context=%d\\n\",index,init.context );\n\t\n\t// login user, proceed to SV_RankUserCBF\n\tstatus = GRankUserLoginAsync\n\t\t(\n\t\t\ts_ranked_players[index].context, \n\t\t\tusername, \n\t\t\tpassword, \n\t\t\tSV_RankUserCBF, \n\t\t\t(void*)&s_ranked_players[index], \n\t\t\tGR_OPT_END \n\t\t);\n\n\tif( status == GR_STATUS_PENDING )\n\t{\n\t\ts_ranked_players[index].grank_status = QGR_STATUS_PENDING;\n\t\ts_ranked_players[index].final_status = QGR_STATUS_NEW;\n\t}\n\telse\n\t{\n\t\tSV_RankError( \"SV_RankUserLogin: Expected GR_STATUS_PENDING, got %s\", \n\t\t\tSV_RankStatusString( status )  );\n\t}\n}\n\n/*\n===================\nSV_RankUserValidate\n===================\n*/\nqboolean SV_RankUserValidate( int index, const char* player_id, const char* key, int token_len, int rank, char* name )\n{\n\tGR_INIT\t\tinit;\n\tGR_STATUS status;\n\tqboolean rVal;\n\tranked_player_t* ranked_player;\n\tint i;\n\n\tassert( s_ranked_players );\n\tassert( s_ranked_players[index].grank_status != QGR_STATUS_ACTIVE );\n\n\trVal = qfalse;\n\t\n\tif( !s_rankings_active )\n\t{\n\t\tCom_DPrintf( \"SV_RankUserValidate: Not ready to validate\\n\" );\n\t\ts_ranked_players[index].grank_status = QGR_STATUS_ERROR;\n\t\treturn rVal;\n\t}\n\t\n\tranked_player = &(s_ranked_players[index]);\n\t\n\tif ( (player_id != NULL) && (key != NULL))\n\t{\n\t\t// the real player_id and key is set when SV_RankJoinGameCBF\n\t\t// is called we do this so that SV_RankUserValidate\n\t\t// can be shared by both server side login and client side login\n\t\t\n\t\t// for client side logined in players\n\t\t// server is creating GR_OPT_PLAYERCONTEXT\n\t\tinit = GRankInit( 0, SV_RankGameKey, GR_OPT_POLL, GR_OPT_END );\n\t\tranked_player->context   = init.context;\n\t\ts_rankings_contexts++;\n\t\tCom_DPrintf( \"SV_RankUserValidate(); s_rankings_contexts=%d\\n\",s_rankings_contexts );\n\t\tCom_DPrintf( \"SV_RankUserValidate(); s_ranked_players[%d].context=%d\\n\",index,init.context );\n\t\t\n\t\t// uudecode player id and player token\n\t\tranked_player->player_id = SV_RankDecodePlayerID(player_id);\n\t\tCom_DPrintf( \"SV_RankUserValidate(); ranked_player->player_id =%u\\n\", (uint32_t)ranked_player->player_id );\n\t\tSV_RankDecodePlayerKey(key, ranked_player->token);\n\t\t\n\t\t// save name and check for duplicates\n\t\tQ_strncpyz( ranked_player->name, name, sizeof(ranked_player->name) );\n\t\tfor( i = 0; i < sv_maxclients->value; i++ )\n\t\t{\n\t\t\tif( (i != index) && (s_ranked_players[i].grank_status == QGR_STATUS_ACTIVE) && \n\t\t\t\t(strcmp( s_ranked_players[i].name, name ) == 0) )\n\t\t\t{\n\t\t\t\tCom_DPrintf( \"SV_RankUserValidate: Duplicate login\\n\" );\n\t\t\t\tranked_player->grank_status = QGR_STATUS_NO_USER;\n\t\t\t\tranked_player->final_status = QGR_STATUS_NEW;\n\t\t\t\tranked_player->grank = 0;\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t}\n\n\t\t// then validate\n\t\tstatus  = GRankPlayerValidate(\n\t\t\t\t\t\t\ts_server_context,\n\t\t\t\t\t\t\tranked_player->player_id, \n\t\t\t\t\t\t\tranked_player->token,\n\t\t\t\t\t\t\ttoken_len,\n\t\t\t\t\t\t\tGR_OPT_PLAYERCONTEXT,\n\t\t\t\t\t\t\tranked_player->context,\n\t\t\t\t\t\t\tGR_OPT_END);\n\t}\n\telse\n\t{\n\t\t// make server side login (bots) happy\n\t\tstatus = GR_STATUS_OK;\n\t}\n\n\tif (status == GR_STATUS_OK)\n\t{\n \t\tranked_player->grank_status = QGR_STATUS_ACTIVE;\n\t\tranked_player->final_status = QGR_STATUS_NEW;\n\t\tranked_player->grank = rank;\n\t\trVal = qtrue;\n\t}\n\telse if (status == GR_STATUS_INVALIDUSER)\n\t{\n\t\tranked_player->grank_status = QGR_STATUS_INVALIDUSER;\n\t\tranked_player->final_status = QGR_STATUS_NEW;\n\t\tranked_player->grank = 0;\n\t\trVal = qfalse;\n\t}\n\telse\n\t{\n\t\tSV_RankError( \"SV_RankUserValidate: Unexpected status %s\",\n\t\t\tSV_RankStatusString( status ) );\n\t\ts_ranked_players[index].grank_status = QGR_STATUS_ERROR;\n\t\tranked_player->grank = 0;\n\t}\n\t\n\treturn rVal;\n}\n\n/*\n================\nSV_RankUserLogout\n================\n*/\nvoid SV_RankUserLogout( int index )\n{\n\tGR_STATUS\tstatus;\n\tGR_STATUS\tcleanup_status;\n\n\tif( !s_rankings_active )\n\t{\n\t\treturn;\n\t}\n\n\tassert( index >= 0 );\n\tassert( index < sv_maxclients->value );\n\tassert( s_ranked_players );\n\n\tif( s_ranked_players[index].context == 0 ) {\n\t\treturn;\n\t}\n\n\tCom_DPrintf( \"SV_RankUserLogout( %d );\\n\", index );\n\n\t// masqueraded player may not be active yet, if they fail validation, \n\t// but still they have a context needs to be cleaned \n\t// what matters is the s_ranked_players[index].context\n\t\n\t// send reports, proceed to SV_RankSendReportsCBF\n\tstatus = GRankSendReportsAsync\n\t\t( \n\t\t\ts_ranked_players[index].context,\n\t\t\t0,\n\t\t\tSV_RankSendReportsCBF,\n\t\t\t(void*)&s_ranked_players[index], \n\t\t\tGR_OPT_END\n\t\t);\n\t\t\n\tif( status == GR_STATUS_PENDING )\n\t{\n\t\ts_ranked_players[index].grank_status = QGR_STATUS_PENDING;\n\t\ts_ranked_players[index].final_status = QGR_STATUS_NEW;\n\t}\n\telse\n\t{\n\t\tSV_RankError( \"SV_RankUserLogout: Expected GR_STATUS_PENDING, got %s\", \n\t\t\tSV_RankStatusString( status ) );\n\n\t\tcleanup_status = GRankCleanupAsync\n\t\t\t(\n\t\t\t\ts_ranked_players[index].context,\n\t\t\t\t0,\n\t\t\t\tSV_RankCleanupCBF,\n\t\t\t\t(void*)&s_ranked_players[index],\n\t\t\t\tGR_OPT_END\n\t\t\t);\n\t\t\n\t\tif( cleanup_status != GR_STATUS_PENDING )\n\t\t{\n\t\t\tSV_RankError( \"SV_RankUserLogout: Expected \"\n\t\t\t\t\"GR_STATUS_PENDING from GRankCleanupAsync, got %s\", \n\t\t\t\tSV_RankStatusString( cleanup_status ) );\n\t\t\tSV_RankCloseContext( &(s_ranked_players[index]) );\n\t\t}\n\t}\n}\n\n/*\n================\nSV_RankReportInt\n================\n*/\nvoid SV_RankReportInt( int index1, int index2, int key, int value, \n\tqboolean accum )\n{\n\tGR_STATUS\tstatus;\n\tGR_CONTEXT\tcontext;\n\tuint64_t\tmatch;\n\tuint64_t\tuser1;\n\tuint64_t\tuser2;\n\tint\t\t\topt_accum;\n\n\tif( !s_rankings_active )\n\t{\n\t\treturn;\n\t}\n\n\tassert( index1 >= -1 );\n\tassert( index1 < sv_maxclients->value );\n\tassert( index2 >= -1 );\n\tassert( index2 < sv_maxclients->value );\n\tassert( s_ranked_players );\n\n//\tCom_DPrintf( \"SV_RankReportInt( %d, %d, %d, %d, %d );\\n\", index1, index2, \n//\t\tkey, value, accum );\n\n\t// get context, match, and player_id for player index1\n\tif( index1 == -1 )\n\t{\n\t\tcontext = s_server_context;\n\t\tmatch = s_server_match;\n\t\tuser1 = 0;\n\t}\n\telse\n\t{\n\t\tif( s_ranked_players[index1].grank_status != QGR_STATUS_ACTIVE )\n\t\t{\n\t\t\tCom_DPrintf( \"SV_RankReportInt: Expecting QGR_STATUS_ACTIVE\"\n\t\t\t\t\" Got Unexpected status %d for player %d\\n\", \n\t\t\t\ts_ranked_players[index1].grank_status, index1 );\n\t\t\treturn;\n\t\t}\n\t\n\t\tcontext = s_ranked_players[index1].context;\n\t\tmatch = s_ranked_players[index1].match;\n\t\tuser1 = s_ranked_players[index1].player_id;\n\t}\n\n\t// get player_id for player index2\n\tif( index2 == -1 )\n\t{\n\t\tuser2 = 0;\n\t}\n\telse\n\t{\n\t\tif( s_ranked_players[index2].grank_status != QGR_STATUS_ACTIVE )\n\t\t{\n\t\t\tCom_DPrintf( \"SV_RankReportInt: Expecting QGR_STATUS_ACTIVE\"\n\t\t\t\t\" Got Unexpected status %d for player %d\\n\", \n\t\t\t\ts_ranked_players[index2].grank_status, index2 );\n\t\t\treturn;\n\t\t}\n\n\t\tuser2 = s_ranked_players[index2].player_id;\n\t}\n\n\topt_accum = accum ? GR_OPT_ACCUM : GR_OPT_END;\n\t\n\tstatus = GRankReportInt\n\t\t(\n\t\t\tcontext,\n\t\t\tmatch,\n\t\t\tuser1, \n\t\t\tuser2,\n\t\t\tkey,\n\t\t\tvalue,\n\t\t\topt_accum,\n\t\t\tGR_OPT_END\n\t\t);\n\t\t\n\tif( status != GR_STATUS_OK )\n\t{\n\t\tSV_RankError( \"SV_RankReportInt: Unexpected status %s\",\n\t\t\tSV_RankStatusString( status ) );\n\t}\n\n\tif( user2 != 0 )\n\t{\n\t\tcontext = s_ranked_players[index2].context;\n\t\tmatch   = s_ranked_players[index2].match;\n\t\t\n\t\tstatus = GRankReportInt\n\t\t\t(\n\t\t\t\tcontext,\n\t\t\t\tmatch,\n\t\t\t\tuser1, \n\t\t\t\tuser2,\n\t\t\t\tkey,\n\t\t\t\tvalue,\n\t\t\t\topt_accum,\n\t\t\t\tGR_OPT_END\n\t\t\t);\n\t\t\t\n\t\tif( status != GR_STATUS_OK )\n\t\t{\n\t\t\tSV_RankError( \"SV_RankReportInt: Unexpected status %s\",\n\t\t\t\tSV_RankStatusString( status ) );\n\t\t}\n\t}\n}\n\n/*\n================\nSV_RankReportStr\n================\n*/\nvoid SV_RankReportStr( int index1, int index2, int key, char* value )\n{\n\tGR_STATUS\tstatus;\n\tGR_CONTEXT\tcontext;\n\tuint64_t\tmatch;\n\tuint64_t\tuser1;\n\tuint64_t\tuser2;\n\n\tif( !s_rankings_active )\n\t{\n\t\treturn;\n\t}\n\n\tassert( index1 >= -1 );\n\tassert( index1 < sv_maxclients->value );\n\tassert( index2 >= -1 );\n\tassert( index2 < sv_maxclients->value );\n\tassert( s_ranked_players );\n\n//\tCom_DPrintf( \"SV_RankReportStr( %d, %d, %d, \\\"%s\\\" );\\n\", index1, index2, \n//\t\tkey, value );\n\t\n\t// get context, match, and player_id for player index1\n\tif( index1 == -1 )\n\t{\n\t\tcontext = s_server_context;\n\t\tmatch = s_server_match;\n\t\tuser1 = 0;\n\t}\n\telse\n\t{\n\t\tif( s_ranked_players[index1].grank_status != QGR_STATUS_ACTIVE )\n\t\t{\n\t\t\tCom_DPrintf( \"SV_RankReportStr: Unexpected status %d\\n\", \n\t\t\t\ts_ranked_players[index1].grank_status );\n\t\t\treturn;\n\t\t}\n\t\n\t\tcontext = s_ranked_players[index1].context;\n\t\tmatch = s_ranked_players[index1].match;\n\t\tuser1 = s_ranked_players[index1].player_id;\n\t}\n\n\t// get player_id for player index2\n\tif( index2 == -1 )\n\t{\n\t\tuser2 = 0;\n\t}\n\telse\n\t{\n\t\tif( s_ranked_players[index2].grank_status != QGR_STATUS_ACTIVE )\n\t\t{\n\t\t\tCom_DPrintf( \"SV_RankReportStr: Unexpected status %d\\n\", \n\t\t\t\ts_ranked_players[index2].grank_status );\n\t\t\treturn;\n\t\t}\n\n\t\tuser2 = s_ranked_players[index2].player_id;\n\t}\n\n\tstatus = GRankReportStr\n\t\t(\n\t\t\tcontext,\n\t\t\tmatch,\n\t\t\tuser1,\n\t\t\tuser2,\n\t\t\tkey,\n\t\t\tvalue,\n\t\t\tGR_OPT_END\n\t\t);\n\t\t\n\tif( status != GR_STATUS_OK )\n\t{\n\t\tSV_RankError( \"SV_RankReportStr: Unexpected status %s\",\n\t\t\tSV_RankStatusString( status ) );\n\t}\n\t\n\tif( user2 != 0 )\n\t{\n\t\tcontext = s_ranked_players[index2].context;\n\t\tmatch = s_ranked_players[index2].match;\n\t\t\n\t\tstatus = GRankReportStr\n\t\t\t(\n\t\t\t\tcontext,\n\t\t\t\tmatch,\n\t\t\t\tuser1, \n\t\t\t\tuser2,\n\t\t\t\tkey,\n\t\t\t\tvalue,\n\t\t\t\tGR_OPT_END\n\t\t\t);\n\t\t\t\n\t\tif( status != GR_STATUS_OK )\n\t\t{\n\t\t\tSV_RankError( \"SV_RankReportInt: Unexpected status %s\",\n\t\t\t\tSV_RankStatusString( status ) );\n\t\t}\n\t}\n}\n\n/*\n================\nSV_RankQuit\n================\n*/\nvoid SV_RankQuit( void )\n{\n\tint\ti;\n\tint j = 0;\t\n\t// yuck\n\t\n\twhile( s_rankings_contexts > 1 )\n\t{\n\t\tassert(s_ranked_players);\n\t\tif( s_ranked_players != NULL )\n\t\t{\n\t\t\tfor( i = 0; i < sv_maxclients->value; i++ )\n\t\t\t{\n\t\t\t\t// check for players that weren't yet active in SV_RankEnd\n\t\t\t\tif( s_ranked_players[i].grank_status == QGR_STATUS_ACTIVE )\n\t\t\t\t{\n\t\t\t\t\tSV_RankUserLogout( i );\n\t\t\t\t\tCom_DPrintf( \"SV_RankQuit: SV_RankUserLogout %d\\n\",i );\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif( s_ranked_players[i].context )\n\t\t\t\t\t{\n\t\t\t\t\t\tGR_STATUS cleanup_status;\n\t\t\t\t\t\tcleanup_status = GRankCleanupAsync\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\ts_ranked_players[i].context,\n\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\tSV_RankCleanupCBF,\n\t\t\t\t\t\t\t\t(void*)&(s_ranked_players[i]),\n\t\t\t\t\t\t\t\tGR_OPT_END\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\n\t\t\t\t\t\tif( cleanup_status != GR_STATUS_PENDING )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSV_RankError( \"SV_RankQuit: Expected \"\n\t\t\t\t\t\t\t\t\"GR_STATUS_PENDING from GRankCleanupAsync, got %s\", \n\t\t\t\t\t\t\t\tSV_RankStatusString( cleanup_status ) );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSV_RankPoll();\n\t\t\n\t\t// should've finished by now\n\t\tassert( (j++) < 68 );\n\t}\n}\n\n/*\n==============================================================================\n\nPrivate Functions\n\n==============================================================================\n*/\n\n/*\n=================\nSV_RankNewGameCBF\n=================\n*/\nstatic void SV_RankNewGameCBF( GR_NEWGAME* gr_newgame, void* cbf_arg )\n{\n\tGR_MATCH\tmatch;\n\tint\t\t\ti;\n\t\n\tassert( gr_newgame != NULL );\n\tassert( cbf_arg == NULL );\n\n\tCom_DPrintf( \"SV_RankNewGameCBF( %08X, %08X );\\n\", gr_newgame, cbf_arg );\n\t\n\tif( gr_newgame->status == GR_STATUS_OK )\n\t{\n\t\tchar info[MAX_INFO_STRING];\n\t\tchar gameid[sizeof(s_ranked_players[i].game_id) * 4 / 3 + 2];\n\t\t\n\t\t// save game id\n\t\ts_rankings_game_id = gr_newgame->game_id;\n\t\t\n\t\t// encode gameid \n\t\tmemset(gameid,0,sizeof(gameid));\n\t\tSV_RankEncodeGameID(s_rankings_game_id,gameid,sizeof(gameid));\n\t\t\n\t\t// set CS_GRANK rankingsGameID to pass to client\n\t\tmemset(info,0,sizeof(info));\n\t\tInfo_SetValueForKey( info, \"rankingsGameKey\", s_rankings_game_key );\n\t\tInfo_SetValueForKey( info, \"rankingsGameID\", gameid );\n\t\tSV_SetConfigstring( CS_GRANK, info );\n\n\t\t// initialize client status\n\t\tfor( i = 0; i < sv_maxclients->value; i++ )\n\t\t\ts_ranked_players[i].grank_status = QGR_STATUS_NEW;\n\n\t\t// start new match\n\t\tmatch = GRankStartMatch( s_server_context );\n\t\ts_server_match = match.match;\n\n\t\t// ready to go\n\t\ts_rankings_active = qtrue;\n\t\tCvar_Set( \"sv_rankingsActive\", \"1\" );\n\n\t}\n\telse if( gr_newgame->status == GR_STATUS_BADLEAGUE )\n\t{\n\t\tSV_RankError( \"SV_RankNewGameCBF: Invalid League name\\n\" );\n\t}\n\telse\n\t{\n\t\t//GRank handle new game failure\n\t\t// force  SV_RankEnd() to run\n\t\t//SV_RankEnd();\n\t\tSV_RankError( \"SV_RankNewGameCBF: Unexpected status %s\", \n\t\t\tSV_RankStatusString( gr_newgame->status ) );\n\t}\n}\n\n/*\n================\nSV_RankUserCBF\n================\n*/\nstatic void SV_RankUserCBF( GR_LOGIN* gr_login, void* cbf_arg )\n{\n\tranked_player_t*\tranked_player;\n\tGR_STATUS\t\t\tjoin_status;\n\tGR_STATUS\t\t\tcleanup_status;\n\t\n\tassert( gr_login != NULL );\n\tassert( cbf_arg != NULL );\n\n\tCom_DPrintf( \"SV_RankUserCBF( %08X, %08X );\\n\", gr_login, cbf_arg );\n\t\n\tranked_player = (ranked_player_t*)cbf_arg;\n\tassert(ranked_player);\n\tassert( ranked_player->context );\n\t\n\tswitch( gr_login->status )\n\t{\n\t\tcase GR_STATUS_OK:\n\t\t\t// attempt to join the game, proceed to SV_RankJoinGameCBF\n\t\t\tjoin_status = GRankJoinGameAsync\n\t\t\t\t( \n\t\t\t\t\tranked_player->context,\n\t\t\t\t\ts_rankings_game_id,\n\t\t\t\t\tSV_RankJoinGameCBF,\n\t\t\t\t\tcbf_arg,\n\t\t\t\t\tGR_OPT_END\n\t\t\t\t);\n\n\t\t\tif( join_status != GR_STATUS_PENDING )\n\t\t\t{\n\t\t\t\tSV_RankError( \"SV_RankUserCBF: Expected GR_STATUS_PENDING \"\n\t\t\t\t\t\"from GRankJoinGameAsync, got %s\", \n\t\t\t\t\tSV_RankStatusString( join_status ) );\n\t\t\t}\n\t\t\tbreak;\n\t\tcase GR_STATUS_NOUSER:\n\t\t\tCom_DPrintf( \"SV_RankUserCBF: Got status %s\\n\",\n\t\t\t\tSV_RankStatusString( gr_login->status ) );\n\t\t\tranked_player->final_status = QGR_STATUS_NO_USER;\n\t\t\tbreak;\n\t\tcase GR_STATUS_BADPASSWORD:\n\t\t\tCom_DPrintf( \"SV_RankUserCBF: Got status %s\\n\",\n\t\t\t\tSV_RankStatusString( gr_login->status ) );\n\t\t\tranked_player->final_status = QGR_STATUS_BAD_PASSWORD;\n\t\t\tbreak;\n\t\tcase GR_STATUS_TIMEOUT:\n\t\t\tCom_DPrintf( \"SV_RankUserCBF: Got status %s\\n\",\n\t\t\t\tSV_RankStatusString( gr_login->status ) );\n\t\t\tranked_player->final_status = QGR_STATUS_TIMEOUT;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tCom_DPrintf( \"SV_RankUserCBF: Unexpected status %s\\n\",\n\t\t\t\tSV_RankStatusString( gr_login->status ) );\n\t\t\tranked_player->final_status = QGR_STATUS_ERROR;\n\t\t\tbreak;\n\t}\n\n\tif( ranked_player->final_status != QGR_STATUS_NEW )\n\t{\n\t\t// login or create failed, so clean up before the next attempt\n\t\tcleanup_status = GRankCleanupAsync\n\t\t\t(\n\t\t\t\tranked_player->context,\n\t\t\t\t0,\n\t\t\t\tSV_RankCleanupCBF,\n\t\t\t\t(void*)ranked_player,\n\t\t\t\tGR_OPT_END\n\t\t\t);\n\t\t\t\n\t\tif( cleanup_status != GR_STATUS_PENDING )\n\t\t{\n\t\t\tSV_RankError( \"SV_RankUserCBF: Expected GR_STATUS_PENDING \"\n\t\t\t\t\"from GRankCleanupAsync, got %s\", \n\t\t\t\tSV_RankStatusString( cleanup_status ) );\n\t\t\tSV_RankCloseContext( ranked_player );\n\t\t}\n\t}\n}\n\n/*\n================\nSV_RankJoinGameCBF\n================\n*/\nstatic void SV_RankJoinGameCBF( GR_JOINGAME* gr_joingame, void* cbf_arg )\n{\n\tranked_player_t*\tranked_player;\n\tGR_MATCH\t\t\tmatch;\n\tGR_STATUS           cleanup_status;\n\n\tassert( gr_joingame != NULL );\n\tassert( cbf_arg != NULL );\n\t\n\tCom_DPrintf( \"SV_RankJoinGameCBF( %08X, %08X );\\n\", gr_joingame, cbf_arg );\n\t\n\tranked_player = (ranked_player_t*)cbf_arg;\n\n\tassert( ranked_player );\n\tassert( ranked_player->context != 0 );\n\t\n\tif( gr_joingame->status == GR_STATUS_OK )\n\t{\n\t\tint i;\n\t\t// save user id\n\t\tranked_player->player_id = gr_joingame->player_id;\n\t\tmemcpy(ranked_player->token,gr_joingame->token,\n\t\t\tsizeof(GR_PLAYER_TOKEN)) ;\n\t\tmatch = GRankStartMatch( ranked_player->context );\n\t\tranked_player->match = match.match;\n\t\tranked_player->grank = gr_joingame->rank;\n\n\t\t// find the index and call SV_RankUserValidate\n\t\tfor (i=0;i<sv_maxclients->value;i++)\n\t\t\tif ( ranked_player == &s_ranked_players[i] )\n\t\t\t\tSV_RankUserValidate(i,NULL,NULL,0, gr_joingame->rank,ranked_player->name);\n\t}\n\telse\n\t{\n\t\t//GRand handle join game failure\n\t\tSV_RankError( \"SV_RankJoinGameCBF: Unexpected status %s\",\n\t\t\tSV_RankStatusString( gr_joingame->status ) );\n\t\t\n\t\tcleanup_status = GRankCleanupAsync\n\t\t\t(\n\t\t\t\tranked_player->context,\n\t\t\t\t0,\n\t\t\t\tSV_RankCleanupCBF,\n\t\t\t\tcbf_arg,\n\t\t\t\tGR_OPT_END\n\t\t\t);\n\t\t\n\t\tif( cleanup_status != GR_STATUS_PENDING )\n\t\t{\n\t\t\tSV_RankError( \"SV_RankJoinGameCBF: Expected \"\n\t\t\t\t\"GR_STATUS_PENDING from GRankCleanupAsync, got %s\", \n\t\t\t\tSV_RankStatusString( cleanup_status ) );\n\t\t\tSV_RankCloseContext( ranked_player );\n\t\t}\n\t}\t\t\n}\n\n/*\n================\nSV_RankSendReportsCBF\n================\n*/\nstatic void SV_RankSendReportsCBF( GR_STATUS* status, void* cbf_arg )\n{\n\tranked_player_t*\tranked_player;\n\tGR_CONTEXT\t\t\tcontext;\n\tGR_STATUS\t\t\tcleanup_status;\n\n\tassert( status != NULL );\n\t// NULL cbf_arg means server is sending match reports\n\t\n\tCom_DPrintf( \"SV_RankSendReportsCBF( %08X, %08X );\\n\", status, cbf_arg );\n\t\n\tranked_player = (ranked_player_t*)cbf_arg;\n\tif( ranked_player == NULL )\n\t{\n\t\tCom_DPrintf( \"SV_RankSendReportsCBF: server\\n\" );\n\t\tcontext = s_server_context;\n\t}\n\telse\n\t{\n\t\tCom_DPrintf( \"SV_RankSendReportsCBF: player\\n\" );\n\t\tcontext = ranked_player->context;\n\t}\n\n\t//assert( context != 0 );\n\tif( *status != GR_STATUS_OK )\n\t{\n\t\tSV_RankError( \"SV_RankSendReportsCBF: Unexpected status %s\",\n\t\t\tSV_RankStatusString( *status ) );\n\t}\n\t\n\tif( context == 0 )\n\t{\n\t\tCom_DPrintf( \"SV_RankSendReportsCBF: WARNING: context == 0\" );\n\t\tSV_RankCloseContext( ranked_player );\n\t}\n\telse\n\t{\n\t\tcleanup_status = GRankCleanupAsync\n\t\t\t(\n\t\t\t\tcontext,\n\t\t\t\t0,\n\t\t\t\tSV_RankCleanupCBF,\n\t\t\t\tcbf_arg,\n\t\t\t\tGR_OPT_END\n\t\t\t);\n\t\t\n\t\tif( cleanup_status != GR_STATUS_PENDING )\n\t\t{\n\t\t\tSV_RankError( \"SV_RankSendReportsCBF: Expected \"\n\t\t\t\t\"GR_STATUS_PENDING from GRankCleanupAsync, got %s\", \n\t\t\t\tSV_RankStatusString( cleanup_status ) );\n\t\t\tSV_RankCloseContext( ranked_player );\n\t\t}\n\t}\n}\n\n/*\n================\nSV_RankCleanupCBF\n================\n*/\nstatic void SV_RankCleanupCBF( GR_STATUS* status, void* cbf_arg )\n{\n\tranked_player_t*\tranked_player;\n\tranked_player = (ranked_player_t*)cbf_arg;\n\n\tassert( status != NULL );\n\t// NULL cbf_arg means server is cleaning up\n\n\tCom_DPrintf( \"SV_RankCleanupCBF( %08X, %08X );\\n\", status, cbf_arg );\n\t\n\tif( *status != GR_STATUS_OK )\n\t{\n\t\tSV_RankError( \"SV_RankCleanupCBF: Unexpected status %s\",\n\t\t\tSV_RankStatusString( *status ) );\n\t}\n\n\tSV_RankCloseContext( ranked_player );\n}\n\n/*\n================\nSV_RankCloseContext\n================\n*/\nstatic void SV_RankCloseContext( ranked_player_t* ranked_player )\n{\n\tif( ranked_player == NULL )\n\t{\n\t\t// server cleanup\n\t\tif( s_server_context == 0 )\n\t\t{\n\t\t\treturn;\n\t\t}\n\t\ts_server_context = 0;\n\t\ts_server_match = 0;\n\t}\n\telse\n\t{\n\t\t// player cleanup\n\t\tif( s_ranked_players == NULL )\n\t\t{\n\t\t\treturn;\n\t\t}\n\t\tif( ranked_player->context == 0 )\n\t\t{\n\t\t\treturn;\n\t\t}\n\t\tranked_player->context = 0;\n\t\tranked_player->match = 0;\n\t\tranked_player->player_id = 0;\n\t\tmemset( ranked_player->token, 0, sizeof(GR_PLAYER_TOKEN) );\n\t\tranked_player->grank_status = ranked_player->final_status;\n\t\tranked_player->final_status = QGR_STATUS_NEW;\n\t\tranked_player->name[0] = '\\0';\n\t}\n\n\tassert( s_rankings_contexts > 0 );\n\ts_rankings_contexts--;\n\tCom_DPrintf( \"SV_RankCloseContext: s_rankings_contexts = %d\\n\", \n\t\ts_rankings_contexts );\n\n\tif( s_rankings_contexts == 0 )\n\t{\n\t\tGRankLogLevel( GRLOG_OFF );\n\t\t\n\t\tif( s_ranked_players != NULL )\n\t\t{\n\t\t\tZ_Free( s_ranked_players );\n\t\t\ts_ranked_players = NULL;\n\t\t}\n\n\t\ts_rankings_active = qfalse;\n\t\tCvar_Set( \"sv_rankingsActive\", \"0\" );\n\t}\n}\n\n/*\n================\nSV_RankAsciiEncode\n\nEncodes src_len bytes of binary data from the src buffer as ASCII text, \nusing 6 bits per character. The result string is null-terminated and \nstored in the dest buffer.\n\nThe dest buffer must be at least (src_len * 4) / 3 + 2 bytes in length.\n\nReturns the length of the result string, not including the null.\n================\n*/\nstatic int SV_RankAsciiEncode( char* dest, const unsigned char* src, \n\tint src_len )\n{\n\tunsigned char\tbin[3];\n\tunsigned char\ttxt[4];\n\tint\t\t\t\tdest_len = 0;\n\tint\t\t\t\ti;\n\tint\t\t\t\tj;\n\tint\t\t\t\tnum_chars;\n\n\tassert( dest != NULL );\n\tassert( src != NULL );\n\t\n\tfor( i = 0; i < src_len; i += 3 )\n\t{\n\t\t// read three bytes of input\n\t\tfor( j = 0; j < 3; j++ )\n\t\t{\n\t\t\tbin[j] = (i + j < src_len) ? src[i + j] : 0;\n\t\t}\n\n\t\t// get four 6-bit values from three bytes\n\t\ttxt[0] = bin[0] >> 2;\n\t\ttxt[1] = ((bin[0] << 4) | (bin[1] >> 4)) & 63;\n\t\ttxt[2] = ((bin[1] << 2) | (bin[2] >> 6)) & 63;\n\t\ttxt[3] = bin[2] & 63;\n\n\t\t// store ASCII encoding of 6-bit values\n\t\tnum_chars = (i + 2 < src_len) ? 4 : ((src_len - i) * 4) / 3 + 1;\n\t\tfor( j = 0; j < num_chars; j++ )\n\t\t{\n\t\t\tdest[dest_len++] = s_ascii_encoding[txt[j]];\n\t\t}\n\t}\n\t\n\tdest[dest_len] = '\\0';\n\n\treturn dest_len;\n}\n\n/*\n================\nSV_RankAsciiDecode\n\nDecodes src_len characters of ASCII text from the src buffer, stores \nthe binary result in the dest buffer.\n\nThe dest buffer must be at least (src_len * 3) / 4 bytes in length.\n\nReturns the length of the binary result, or zero for invalid input.\n================\n*/\nstatic int SV_RankAsciiDecode( unsigned char* dest, const char* src, \n\tint src_len )\n{\n\tstatic unsigned char\ts_inverse_encoding[256];\n\tstatic char\t\t\t\ts_init = 0;\n\t\n\tunsigned char\tbin[3];\n\tunsigned char\ttxt[4];\n\tint\t\t\t\tdest_len = 0;\n\tint\t\t\t\ti;\n\tint\t\t\t\tj;\n\tint\t\t\t\tnum_bytes;\n\t\n\tassert( dest != NULL );\n\tassert( src != NULL );\n\n\tif( !s_init )\n\t{\n\t\t// initialize lookup table for decoding\n\t\tmemset( s_inverse_encoding, 255, sizeof(s_inverse_encoding) );\n\t\tfor( i = 0; i < 64; i++ )\n\t\t{\n\t\t\ts_inverse_encoding[s_ascii_encoding[i]] = i;\n\t\t}\n\t\ts_init = 1;\n\t}\n\t\n\tfor( i = 0; i < src_len; i += 4 )\n\t{\n\t\t// read four characters of input, decode them to 6-bit values\n\t\tfor( j = 0; j < 4; j++ )\n\t\t{\n\t\t\ttxt[j] = (i + j < src_len) ? s_inverse_encoding[src[i + j]] : 0;\n\t\t\tif (txt[j] == 255)\n\t\t\t{\n\t\t\t\treturn 0; // invalid input character\n\t\t\t}\n\t\t}\n\t\t\n\t\t// get three bytes from four 6-bit values\n\t\tbin[0] = (txt[0] << 2) | (txt[1] >> 4);\n\t\tbin[1] = (txt[1] << 4) | (txt[2] >> 2);\n\t\tbin[2] = (txt[2] << 6) | txt[3];\n\n\t\t// store binary data\n\t\tnum_bytes = (i + 3 < src_len) ? 3 : ((src_len - i) * 3) / 4;\n\t\tfor( j = 0; j < num_bytes; j++ )\n\t\t{\n\t\t\tdest[dest_len++] = bin[j];\n\t\t}\n\t}\n\n\treturn dest_len;\n}\n\n/*\n================\nSV_RankEncodeGameID\n================\n*/\nstatic void SV_RankEncodeGameID( uint64_t game_id, char* result, \n\tint len )\n{\n\tassert( result != NULL );\n\n\tif( len < ( ( sizeof(game_id) * 4) / 3 + 2) )\n\t{\n\t\tCom_DPrintf( \"SV_RankEncodeGameID: result buffer too small\\n\" );\n\t\tresult[0] = '\\0';\n\t}\n\telse\n\t{\n\t\tqint64 gameid = LittleLong64(*(qint64*)&game_id);\n\t\tSV_RankAsciiEncode( result, (unsigned char*)&gameid, \n\t\t\tsizeof(qint64) );\n\t}\n}\n\n/*\n================\nSV_RankDecodePlayerID\n================\n*/\nstatic uint64_t SV_RankDecodePlayerID( const char* string )\n{\n\tunsigned char\tbuffer[9];\n\tint len;\n\tqint64\tplayer_id;\n\n\tassert( string != NULL );\n\t\n\tlen = strlen (string) ;\n\tCom_DPrintf( \"SV_RankDecodePlayerID: string length %d\\n\",len );\n\tSV_RankAsciiDecode( buffer, string, len );\n\tplayer_id = LittleLong64(*(qint64*)buffer);\n\treturn *(uint64_t*)&player_id;\n}\n\n/*\n================\nSV_RankDecodePlayerKey\n================\n*/\nstatic void SV_RankDecodePlayerKey( const char* string, GR_PLAYER_TOKEN key )\n{\n\tunsigned char\tbuffer[1400];\n\tint len;\n\tassert( string != NULL );\n\n\tlen = strlen (string) ;\n\tCom_DPrintf( \"SV_RankDecodePlayerKey: string length %d\\n\",len );\n\t\n\tmemset(key,0,sizeof(GR_PLAYER_TOKEN));\n\tmemset(buffer,0,sizeof(buffer));\n\tmemcpy( key, buffer, SV_RankAsciiDecode( buffer, string, len ) );\n}\n\n/*\n================\nSV_RankStatusString\n================\n*/\nstatic char* SV_RankStatusString( GR_STATUS status )\n{\n\tswitch( status )\n\t{\n\t\tcase GR_STATUS_OK:\t\t\t\treturn \"GR_STATUS_OK\";\n\t\tcase GR_STATUS_ERROR:\t\t\treturn \"GR_STATUS_ERROR\";\n\t\tcase GR_STATUS_BADPARAMS:\t\treturn \"GR_STATUS_BADPARAMS\";\n\t\tcase GR_STATUS_NETWORK:\t\t\treturn \"GR_STATUS_NETWORK\";\n\t\tcase GR_STATUS_NOUSER:\t\t\treturn \"GR_STATUS_NOUSER\";\n\t\tcase GR_STATUS_BADPASSWORD:\t\treturn \"GR_STATUS_BADPASSWORD\";\n\t\tcase GR_STATUS_BADGAME:\t\t\treturn \"GR_STATUS_BADGAME\";\n\t\tcase GR_STATUS_PENDING:\t\t\treturn \"GR_STATUS_PENDING\";\n\t\tcase GR_STATUS_BADDOMAIN:\t\treturn \"GR_STATUS_BADDOMAIN\";\n\t\tcase GR_STATUS_DOMAINLOCK:\t\treturn \"GR_STATUS_DOMAINLOCK\";\n\t\tcase GR_STATUS_TIMEOUT:\t\t\treturn \"GR_STATUS_TIMEOUT\";\n\t\tcase GR_STATUS_INVALIDUSER:\t    return \"GR_STATUS_INVALIDUSER\";\n\t\tcase GR_STATUS_INVALIDCONTEXT:\treturn \"GR_STATUS_INVALIDCONTEXT\";\n\t\tdefault:\t\t\t\t\t\treturn \"(UNKNOWN)\";\n\t}\n}\n\n/*\n================\nSV_RankError\n================\n*/\nstatic void SV_RankError( const char* fmt, ... )\n{\n\tva_list\targ_ptr;\n\tchar\ttext[1024];\n\n\tva_start( arg_ptr, fmt );\n\tvsprintf( text, fmt, arg_ptr );\n\tva_end( arg_ptr );\n\n\tCom_DPrintf( \"****************************************\\n\" );\n\tCom_DPrintf( \"SV_RankError: %s\\n\", text );\n\tCom_DPrintf( \"****************************************\\n\" );\n\n\ts_rankings_active = qfalse;\n\tCvar_Set( \"sv_rankingsActive\", \"0\" );\n\t// FIXME - attempt clean shutdown?\n}\n\n"
  },
  {
    "path": "code/server/sv_snapshot.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"server.h\"\n\n\n/*\n=============================================================================\n\nDelta encode a client frame onto the network channel\n\nA normal server packet will look like:\n\n4\tsequence number (high bit set if an oversize fragment)\n<optional reliable commands>\n1\tsvc_snapshot\n4\tlast client reliable command\n4\tserverTime\n1\tlastframe for delta compression\n1\tsnapFlags\n1\tareaBytes\n<areabytes>\n<playerstate>\n<packetentities>\n\n=============================================================================\n*/\n\n/*\n=============\nSV_EmitPacketEntities\n\nWrites a delta update of an entityState_t list to the message.\n=============\n*/\nstatic void SV_EmitPacketEntities( clientSnapshot_t *from, clientSnapshot_t *to, msg_t *msg ) {\n\tentityState_t\t*oldent, *newent;\n\tint\t\toldindex, newindex;\n\tint\t\toldnum, newnum;\n\tint\t\tfrom_num_entities;\n\n\t// generate the delta update\n\tif ( !from ) {\n\t\tfrom_num_entities = 0;\n\t} else {\n\t\tfrom_num_entities = from->num_entities;\n\t}\n\n\tnewent = NULL;\n\toldent = NULL;\n\tnewindex = 0;\n\toldindex = 0;\n\twhile ( newindex < to->num_entities || oldindex < from_num_entities ) {\n\t\tif ( newindex >= to->num_entities ) {\n\t\t\tnewnum = 9999;\n\t\t} else {\n\t\t\tnewent = &svs.snapshotEntities[(to->first_entity+newindex) % svs.numSnapshotEntities];\n\t\t\tnewnum = newent->number;\n\t\t}\n\n\t\tif ( oldindex >= from_num_entities ) {\n\t\t\toldnum = 9999;\n\t\t} else {\n\t\t\toldent = &svs.snapshotEntities[(from->first_entity+oldindex) % svs.numSnapshotEntities];\n\t\t\toldnum = oldent->number;\n\t\t}\n\n\t\tif ( newnum == oldnum ) {\n\t\t\t// delta update from old position\n\t\t\t// because the force parm is qfalse, this will not result\n\t\t\t// in any bytes being emited if the entity has not changed at all\n\t\t\tMSG_WriteDeltaEntity (msg, oldent, newent, qfalse );\n\t\t\toldindex++;\n\t\t\tnewindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( newnum < oldnum ) {\n\t\t\t// this is a new entity, send it from the baseline\n\t\t\tMSG_WriteDeltaEntity (msg, &sv.svEntities[newnum].baseline, newent, qtrue );\n\t\t\tnewindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( newnum > oldnum ) {\n\t\t\t// the old entity isn't present in the new message\n\t\t\tMSG_WriteDeltaEntity (msg, oldent, NULL, qtrue );\n\t\t\toldindex++;\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\tMSG_WriteBits( msg, (MAX_GENTITIES-1), GENTITYNUM_BITS );\t// end of packetentities\n}\n\n\n\n/*\n==================\nSV_WriteSnapshotToClient\n==================\n*/\nstatic void SV_WriteSnapshotToClient( client_t *client, msg_t *msg ) {\n\tclientSnapshot_t\t*frame, *oldframe;\n\tint\t\t\t\t\tlastframe;\n\tint\t\t\t\t\ti;\n\tint\t\t\t\t\tsnapFlags;\n\n\t// this is the snapshot we are creating\n\tframe = &client->frames[ client->netchan.outgoingSequence & PACKET_MASK ];\n\n\t// try to use a previous frame as the source for delta compressing the snapshot\n\tif ( client->deltaMessage <= 0 || client->state != CS_ACTIVE ) {\n\t\t// client is asking for a retransmit\n\t\toldframe = NULL;\n\t\tlastframe = 0;\n\t} else if ( client->netchan.outgoingSequence - client->deltaMessage \n\t\t>= (PACKET_BACKUP - 3) ) {\n\t\t// client hasn't gotten a good message through in a long time\n\t\tCom_DPrintf (\"%s: Delta request from out of date packet.\\n\", client->name);\n\t\toldframe = NULL;\n\t\tlastframe = 0;\n\t} else {\n\t\t// we have a valid snapshot to delta from\n\t\toldframe = &client->frames[ client->deltaMessage & PACKET_MASK ];\n\t\tlastframe = client->netchan.outgoingSequence - client->deltaMessage;\n\n\t\t// the snapshot's entities may still have rolled off the buffer, though\n\t\tif ( oldframe->first_entity <= svs.nextSnapshotEntities - svs.numSnapshotEntities ) {\n\t\t\tCom_DPrintf (\"%s: Delta request from out of date entities.\\n\", client->name);\n\t\t\toldframe = NULL;\n\t\t\tlastframe = 0;\n\t\t}\n\t}\n\n\tMSG_WriteByte (msg, svc_snapshot);\n\n\t// NOTE, MRE: now sent at the start of every message from server to client\n\t// let the client know which reliable clientCommands we have received\n\t//MSG_WriteLong( msg, client->lastClientCommand );\n\n\t// send over the current server time so the client can drift\n\t// its view of time to try to match\n\tMSG_WriteLong (msg, svs.time);\n\n\t// what we are delta'ing from\n\tMSG_WriteByte (msg, lastframe);\n\n\tsnapFlags = svs.snapFlagServerBit;\n\tif ( client->rateDelayed ) {\n\t\tsnapFlags |= SNAPFLAG_RATE_DELAYED;\n\t}\n\tif ( client->state != CS_ACTIVE ) {\n\t\tsnapFlags |= SNAPFLAG_NOT_ACTIVE;\n\t}\n\n\tMSG_WriteByte (msg, snapFlags);\n\n\t// send over the areabits\n\tMSG_WriteByte (msg, frame->areabytes);\n\tMSG_WriteData (msg, frame->areabits, frame->areabytes);\n\n\t// delta encode the playerstate\n\tif ( oldframe ) {\n\t\tMSG_WriteDeltaPlayerstate( msg, &oldframe->ps, &frame->ps );\n\t} else {\n\t\tMSG_WriteDeltaPlayerstate( msg, NULL, &frame->ps );\n\t}\n\n\t// delta encode the entities\n\tSV_EmitPacketEntities (oldframe, frame, msg);\n\n\t// padding for rate debugging\n\tif ( sv_padPackets->integer ) {\n\t\tfor ( i = 0 ; i < sv_padPackets->integer ; i++ ) {\n\t\t\tMSG_WriteByte (msg, svc_nop);\n\t\t}\n\t}\n}\n\n\n/*\n==================\nSV_UpdateServerCommandsToClient\n\n(re)send all server commands the client hasn't acknowledged yet\n==================\n*/\nvoid SV_UpdateServerCommandsToClient( client_t *client, msg_t *msg ) {\n\tint\t\ti;\n\n\t// write any unacknowledged serverCommands\n\tfor ( i = client->reliableAcknowledge + 1 ; i <= client->reliableSequence ; i++ ) {\n\t\tMSG_WriteByte( msg, svc_serverCommand );\n\t\tMSG_WriteLong( msg, i );\n\t\tMSG_WriteString( msg, client->reliableCommands[ i & (MAX_RELIABLE_COMMANDS-1) ] );\n\t}\n\tclient->reliableSent = client->reliableSequence;\n}\n\n/*\n=============================================================================\n\nBuild a client snapshot structure\n\n=============================================================================\n*/\n\n#define\tMAX_SNAPSHOT_ENTITIES\t1024\ntypedef struct {\n\tint\t\tnumSnapshotEntities;\n\tint\t\tsnapshotEntities[MAX_SNAPSHOT_ENTITIES];\t\n} snapshotEntityNumbers_t;\n\n/*\n=======================\nSV_QsortEntityNumbers\n=======================\n*/\nstatic int QDECL SV_QsortEntityNumbers( const void *a, const void *b ) {\n\tint\t*ea, *eb;\n\n\tea = (int *)a;\n\teb = (int *)b;\n\n\tif ( *ea == *eb ) {\n\t\tCom_Error( ERR_DROP, \"SV_QsortEntityStates: duplicated entity\" );\n\t}\n\n\tif ( *ea < *eb ) {\n\t\treturn -1;\n\t}\n\n\treturn 1;\n}\n\n\n/*\n===============\nSV_AddEntToSnapshot\n===============\n*/\nstatic void SV_AddEntToSnapshot( svEntity_t *svEnt, sharedEntity_t *gEnt, snapshotEntityNumbers_t *eNums ) {\n\t// if we have already added this entity to this snapshot, don't add again\n\tif ( svEnt->snapshotCounter == sv.snapshotCounter ) {\n\t\treturn;\n\t}\n\tsvEnt->snapshotCounter = sv.snapshotCounter;\n\n\t// if we are full, silently discard entities\n\tif ( eNums->numSnapshotEntities == MAX_SNAPSHOT_ENTITIES ) {\n\t\treturn;\n\t}\n\n\teNums->snapshotEntities[ eNums->numSnapshotEntities ] = gEnt->s.number;\n\teNums->numSnapshotEntities++;\n}\n\n/*\n===============\nSV_AddEntitiesVisibleFromPoint\n===============\n*/\nstatic void SV_AddEntitiesVisibleFromPoint( vec3_t origin, clientSnapshot_t *frame, \n\t\t\t\t\t\t\t\t\tsnapshotEntityNumbers_t *eNums, qboolean portal ) {\n\tint\t\te, i;\n\tsharedEntity_t *ent;\n\tsvEntity_t\t*svEnt;\n\tint\t\tl;\n\tint\t\tclientarea, clientcluster;\n\tint\t\tleafnum;\n\tint\t\tc_fullsend;\n\tbyte\t*clientpvs;\n\tbyte\t*bitvector;\n\n\t// during an error shutdown message we may need to transmit\n\t// the shutdown message after the server has shutdown, so\n\t// specfically check for it\n\tif ( !sv.state ) {\n\t\treturn;\n\t}\n\n\tleafnum = CM_PointLeafnum (origin);\n\tclientarea = CM_LeafArea (leafnum);\n\tclientcluster = CM_LeafCluster (leafnum);\n\n\t// calculate the visible areas\n\tframe->areabytes = CM_WriteAreaBits( frame->areabits, clientarea );\n\n\tclientpvs = CM_ClusterPVS (clientcluster);\n\n\tc_fullsend = 0;\n\n\tfor ( e = 0 ; e < sv.num_entities ; e++ ) {\n\t\tent = SV_GentityNum(e);\n\n\t\t// never send entities that aren't linked in\n\t\tif ( !ent->r.linked ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (ent->s.number != e) {\n\t\t\tCom_DPrintf (\"FIXING ENT->S.NUMBER!!!\\n\");\n\t\t\tent->s.number = e;\n\t\t}\n\n\t\t// entities can be flagged to explicitly not be sent to the client\n\t\tif ( ent->r.svFlags & SVF_NOCLIENT ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// entities can be flagged to be sent to only one client\n\t\tif ( ent->r.svFlags & SVF_SINGLECLIENT ) {\n\t\t\tif ( ent->r.singleClient != frame->ps.clientNum ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\t// entities can be flagged to be sent to everyone but one client\n\t\tif ( ent->r.svFlags & SVF_NOTSINGLECLIENT ) {\n\t\t\tif ( ent->r.singleClient == frame->ps.clientNum ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\t// entities can be flagged to be sent to a given mask of clients\n\t\tif ( ent->r.svFlags & SVF_CLIENTMASK ) {\n\t\t\tif (frame->ps.clientNum >= 32)\n\t\t\t\tCom_Error( ERR_DROP, \"SVF_CLIENTMASK: cientNum > 32\\n\" );\n\t\t\tif (~ent->r.singleClient & (1 << frame->ps.clientNum))\n\t\t\t\tcontinue;\n\t\t}\n\n\t\tsvEnt = SV_SvEntityForGentity( ent );\n\n\t\t// don't double add an entity through portals\n\t\tif ( svEnt->snapshotCounter == sv.snapshotCounter ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// broadcast entities are always sent\n\t\tif ( ent->r.svFlags & SVF_BROADCAST ) {\n\t\t\tSV_AddEntToSnapshot( svEnt, ent, eNums );\n\t\t\tcontinue;\n\t\t}\n\n\t\t// ignore if not touching a PV leaf\n\t\t// check area\n\t\tif ( !CM_AreasConnected( clientarea, svEnt->areanum ) ) {\n\t\t\t// doors can legally straddle two areas, so\n\t\t\t// we may need to check another one\n\t\t\tif ( !CM_AreasConnected( clientarea, svEnt->areanum2 ) ) {\n\t\t\t\tcontinue;\t\t// blocked by a door\n\t\t\t}\n\t\t}\n\n\t\tbitvector = clientpvs;\n\n\t\t// check individual leafs\n\t\tif ( !svEnt->numClusters ) {\n\t\t\tcontinue;\n\t\t}\n\t\tl = 0;\n\t\tfor ( i=0 ; i < svEnt->numClusters ; i++ ) {\n\t\t\tl = svEnt->clusternums[i];\n\t\t\tif ( bitvector[l >> 3] & (1 << (l&7) ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// if we haven't found it to be visible,\n\t\t// check overflow clusters that coudln't be stored\n\t\tif ( i == svEnt->numClusters ) {\n\t\t\tif ( svEnt->lastCluster ) {\n\t\t\t\tfor ( ; l <= svEnt->lastCluster ; l++ ) {\n\t\t\t\t\tif ( bitvector[l >> 3] & (1 << (l&7) ) ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( l == svEnt->lastCluster ) {\n\t\t\t\t\tcontinue;\t// not visible\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\t// add it\n\t\tSV_AddEntToSnapshot( svEnt, ent, eNums );\n\n\t\t// if its a portal entity, add everything visible from its camera position\n\t\tif ( ent->r.svFlags & SVF_PORTAL ) {\n\t\t\tif ( ent->s.generic1 ) {\n\t\t\t\tvec3_t dir;\n\t\t\t\tVectorSubtract(ent->s.origin, origin, dir);\n\t\t\t\tif ( VectorLengthSquared(dir) > (float) ent->s.generic1 * ent->s.generic1 ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tSV_AddEntitiesVisibleFromPoint( ent->s.origin2, frame, eNums, qtrue );\n\t\t}\n\n\t}\n}\n\n/*\n=============\nSV_BuildClientSnapshot\n\nDecides which entities are going to be visible to the client, and\ncopies off the playerstate and areabits.\n\nThis properly handles multiple recursive portals, but the render\ncurrently doesn't.\n\nFor viewing through other player's eyes, clent can be something other than client->gentity\n=============\n*/\nstatic void SV_BuildClientSnapshot( client_t *client ) {\n\tvec3_t\t\t\t\t\t\torg;\n\tclientSnapshot_t\t\t\t*frame;\n\tsnapshotEntityNumbers_t\t\tentityNumbers;\n\tint\t\t\t\t\t\t\ti;\n\tsharedEntity_t\t\t\t\t*ent;\n\tentityState_t\t\t\t\t*state;\n\tsvEntity_t\t\t\t\t\t*svEnt;\n\tsharedEntity_t\t\t\t\t*clent;\n\tint\t\t\t\t\t\t\tclientNum;\n\tplayerState_t\t\t\t\t*ps;\n\n\t// bump the counter used to prevent double adding\n\tsv.snapshotCounter++;\n\n\t// this is the frame we are creating\n\tframe = &client->frames[ client->netchan.outgoingSequence & PACKET_MASK ];\n\n\t// clear everything in this snapshot\n\tentityNumbers.numSnapshotEntities = 0;\n\tCom_Memset( frame->areabits, 0, sizeof( frame->areabits ) );\n\n  // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=62\n\tframe->num_entities = 0;\n\t\n\tclent = client->gentity;\n\tif ( !clent || client->state == CS_ZOMBIE ) {\n\t\treturn;\n\t}\n\n\t// grab the current playerState_t\n\tps = SV_GameClientNum( client - svs.clients );\n\tframe->ps = *ps;\n\n\t// never send client's own entity, because it can\n\t// be regenerated from the playerstate\n\tclientNum = frame->ps.clientNum;\n\tif ( clientNum < 0 || clientNum >= MAX_GENTITIES ) {\n\t\tCom_Error( ERR_DROP, \"SV_SvEntityForGentity: bad gEnt\" );\n\t}\n\tsvEnt = &sv.svEntities[ clientNum ];\n\n\tsvEnt->snapshotCounter = sv.snapshotCounter;\n\n\t// find the client's viewpoint\n\tVectorCopy( ps->origin, org );\n\torg[2] += ps->viewheight;\n\n\t// add all the entities directly visible to the eye, which\n\t// may include portal entities that merge other viewpoints\n\tSV_AddEntitiesVisibleFromPoint( org, frame, &entityNumbers, qfalse );\n\n\t// if there were portals visible, there may be out of order entities\n\t// in the list which will need to be resorted for the delta compression\n\t// to work correctly.  This also catches the error condition\n\t// of an entity being included twice.\n\tqsort( entityNumbers.snapshotEntities, entityNumbers.numSnapshotEntities, \n\t\tsizeof( entityNumbers.snapshotEntities[0] ), SV_QsortEntityNumbers );\n\n\t// now that all viewpoint's areabits have been OR'd together, invert\n\t// all of them to make it a mask vector, which is what the renderer wants\n\tfor ( i = 0 ; i < MAX_MAP_AREA_BYTES/4 ; i++ ) {\n\t\t((int *)frame->areabits)[i] = ((int *)frame->areabits)[i] ^ -1;\n\t}\n\n\t// copy the entity states out\n\tframe->num_entities = 0;\n\tframe->first_entity = svs.nextSnapshotEntities;\n\tfor ( i = 0 ; i < entityNumbers.numSnapshotEntities ; i++ ) {\n\t\tent = SV_GentityNum(entityNumbers.snapshotEntities[i]);\n\t\tstate = &svs.snapshotEntities[svs.nextSnapshotEntities % svs.numSnapshotEntities];\n\t\t*state = ent->s;\n\t\tsvs.nextSnapshotEntities++;\n\t\t// this should never hit, map should always be restarted first in SV_Frame\n\t\tif ( svs.nextSnapshotEntities >= 0x7FFFFFFE ) {\n\t\t\tCom_Error(ERR_FATAL, \"svs.nextSnapshotEntities wrapped\");\n\t\t}\n\t\tframe->num_entities++;\n\t}\n}\n\n\n/*\n====================\nSV_RateMsec\n\nReturn the number of msec a given size message is supposed\nto take to clear, based on the current rate\n====================\n*/\n#define\tHEADER_RATE_BYTES\t48\t\t// include our header, IP header, and some overhead\nstatic int SV_RateMsec( client_t *client, int messageSize ) {\n\tint\t\trate;\n\tint\t\trateMsec;\n\n\t// individual messages will never be larger than fragment size\n\tif ( messageSize > 1500 ) {\n\t\tmessageSize = 1500;\n\t}\n\trate = client->rate;\n\tif ( sv_maxRate->integer ) {\n\t\tif ( sv_maxRate->integer < 1000 ) {\n\t\t\tCvar_Set( \"sv_MaxRate\", \"1000\" );\n\t\t}\n\t\tif ( sv_maxRate->integer < rate ) {\n\t\t\trate = sv_maxRate->integer;\n\t\t}\n\t}\n\trateMsec = ( messageSize + HEADER_RATE_BYTES ) * 1000 / rate;\n\n\treturn rateMsec;\n}\n\n/*\n=======================\nSV_SendMessageToClient\n\nCalled by SV_SendClientSnapshot and SV_SendClientGameState\n=======================\n*/\nvoid SV_SendMessageToClient( msg_t *msg, client_t *client ) {\n\tint\t\t\trateMsec;\n\n\t// record information about the message\n\tclient->frames[client->netchan.outgoingSequence & PACKET_MASK].messageSize = msg->cursize;\n\tclient->frames[client->netchan.outgoingSequence & PACKET_MASK].messageSent = svs.time;\n\tclient->frames[client->netchan.outgoingSequence & PACKET_MASK].messageAcked = -1;\n\n\t// send the datagram\n\tSV_Netchan_Transmit( client, msg );\t//msg->cursize, msg->data );\n\n\t// set nextSnapshotTime based on rate and requested number of updates\n\n\t// local clients get snapshots every frame\n\t// TTimo - https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=491\n\t// added sv_lanForceRate check\n\tif ( client->netchan.remoteAddress.type == NA_LOOPBACK || (sv_lanForceRate->integer && Sys_IsLANAddress (client->netchan.remoteAddress)) ) {\n\t\tclient->nextSnapshotTime = svs.time - 1;\n\t\treturn;\n\t}\n\t\n\t// normal rate / snapshotMsec calculation\n\trateMsec = SV_RateMsec( client, msg->cursize );\n\n\tif ( rateMsec < client->snapshotMsec ) {\n\t\t// never send more packets than this, no matter what the rate is at\n\t\trateMsec = client->snapshotMsec;\n\t\tclient->rateDelayed = qfalse;\n\t} else {\n\t\tclient->rateDelayed = qtrue;\n\t}\n\n\tclient->nextSnapshotTime = svs.time + rateMsec;\n\n\t// don't pile up empty snapshots while connecting\n\tif ( client->state != CS_ACTIVE ) {\n\t\t// a gigantic connection message may have already put the nextSnapshotTime\n\t\t// more than a second away, so don't shorten it\n\t\t// do shorten if client is downloading\n\t\tif ( !*client->downloadName && client->nextSnapshotTime < svs.time + 1000 ) {\n\t\t\tclient->nextSnapshotTime = svs.time + 1000;\n\t\t}\n\t}\n}\n\n\n/*\n=======================\nSV_SendClientSnapshot\n\nAlso called by SV_FinalMessage\n\n=======================\n*/\nvoid SV_SendClientSnapshot( client_t *client ) {\n\tbyte\t\tmsg_buf[MAX_MSGLEN];\n\tmsg_t\t\tmsg;\n\n\t// build the snapshot\n\tSV_BuildClientSnapshot( client );\n\n\t// bots need to have their snapshots build, but\n\t// the query them directly without needing to be sent\n\tif ( client->gentity && client->gentity->r.svFlags & SVF_BOT ) {\n\t\treturn;\n\t}\n\n\tMSG_Init (&msg, msg_buf, sizeof(msg_buf));\n\tmsg.allowoverflow = qtrue;\n\n\t// NOTE, MRE: all server->client messages now acknowledge\n\t// let the client know which reliable clientCommands we have received\n\tMSG_WriteLong( &msg, client->lastClientCommand );\n\n\t// (re)send any reliable server commands\n\tSV_UpdateServerCommandsToClient( client, &msg );\n\n\t// send over all the relevant entityState_t\n\t// and the playerState_t\n\tSV_WriteSnapshotToClient( client, &msg );\n\n\t// Add any download data if the client is downloading\n\tSV_WriteDownloadToClient( client, &msg );\n\n\t// check for overflow\n\tif ( msg.overflowed ) {\n\t\tCom_Printf (\"WARNING: msg overflowed for %s\\n\", client->name);\n\t\tMSG_Clear (&msg);\n\t}\n\n\tSV_SendMessageToClient( &msg, client );\n}\n\n\n/*\n=======================\nSV_SendClientMessages\n=======================\n*/\nvoid SV_SendClientMessages( void ) {\n\tint\t\t\ti;\n\tclient_t\t*c;\n\n\t// send a message to each connected client\n\tfor (i=0, c = svs.clients ; i < sv_maxclients->integer ; i++, c++) {\n\t\tif (!c->state) {\n\t\t\tcontinue;\t\t// not connected\n\t\t}\n\n\t\tif ( svs.time < c->nextSnapshotTime ) {\n\t\t\tcontinue;\t\t// not time yet\n\t\t}\n\n\t\t// send additional message fragments if the last message\n\t\t// was too large to send at once\n\t\tif ( c->netchan.unsentFragments ) {\n\t\t\tc->nextSnapshotTime = svs.time + \n\t\t\t\tSV_RateMsec( c, c->netchan.unsentLength - c->netchan.unsentFragmentStart );\n\t\t\tSV_Netchan_TransmitNextFragment( c );\n\t\t\tcontinue;\n\t\t}\n\n\t\t// generate and send a new message\n\t\tSV_SendClientSnapshot( c );\n\t}\n}\n\n"
  },
  {
    "path": "code/server/sv_world.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// world.c -- world query functions\n\n#include \"server.h\"\n\n/*\n================\nSV_ClipHandleForEntity\n\nReturns a headnode that can be used for testing or clipping to a\ngiven entity.  If the entity is a bsp model, the headnode will\nbe returned, otherwise a custom box tree will be constructed.\n================\n*/\nclipHandle_t SV_ClipHandleForEntity( const sharedEntity_t *ent ) {\n\tif ( ent->r.bmodel ) {\n\t\t// explicit hulls in the BSP model\n\t\treturn CM_InlineModel( ent->s.modelindex );\n\t}\n\tif ( ent->r.svFlags & SVF_CAPSULE ) {\n\t\t// create a temp capsule from bounding box sizes\n\t\treturn CM_TempBoxModel( ent->r.mins, ent->r.maxs, qtrue );\n\t}\n\n\t// create a temp tree from bounding box sizes\n\treturn CM_TempBoxModel( ent->r.mins, ent->r.maxs, qfalse );\n}\n\n\n\n/*\n===============================================================================\n\nENTITY CHECKING\n\nTo avoid linearly searching through lists of entities during environment testing,\nthe world is carved up with an evenly spaced, axially aligned bsp tree.  Entities\nare kept in chains either at the final leafs, or at the first node that splits\nthem, which prevents having to deal with multiple fragments of a single entity.\n\n===============================================================================\n*/\n\ntypedef struct worldSector_s {\n\tint\t\taxis;\t\t// -1 = leaf node\n\tfloat\tdist;\n\tstruct worldSector_s\t*children[2];\n\tsvEntity_t\t*entities;\n} worldSector_t;\n\n#define\tAREA_DEPTH\t4\n#define\tAREA_NODES\t64\n\nworldSector_t\tsv_worldSectors[AREA_NODES];\nint\t\t\tsv_numworldSectors;\n\n\n/*\n===============\nSV_SectorList_f\n===============\n*/\nvoid SV_SectorList_f( void ) {\n\tint\t\t\t\ti, c;\n\tworldSector_t\t*sec;\n\tsvEntity_t\t\t*ent;\n\n\tfor ( i = 0 ; i < AREA_NODES ; i++ ) {\n\t\tsec = &sv_worldSectors[i];\n\n\t\tc = 0;\n\t\tfor ( ent = sec->entities ; ent ; ent = ent->nextEntityInWorldSector ) {\n\t\t\tc++;\n\t\t}\n\t\tCom_Printf( \"sector %i: %i entities\\n\", i, c );\n\t}\n}\n\n/*\n===============\nSV_CreateworldSector\n\nBuilds a uniformly subdivided tree for the given world size\n===============\n*/\nworldSector_t *SV_CreateworldSector( int depth, vec3_t mins, vec3_t maxs ) {\n\tworldSector_t\t*anode;\n\tvec3_t\t\tsize;\n\tvec3_t\t\tmins1, maxs1, mins2, maxs2;\n\n\tanode = &sv_worldSectors[sv_numworldSectors];\n\tsv_numworldSectors++;\n\n\tif (depth == AREA_DEPTH) {\n\t\tanode->axis = -1;\n\t\tanode->children[0] = anode->children[1] = NULL;\n\t\treturn anode;\n\t}\n\t\n\tVectorSubtract (maxs, mins, size);\n\tif (size[0] > size[1]) {\n\t\tanode->axis = 0;\n\t} else {\n\t\tanode->axis = 1;\n\t}\n\n\tanode->dist = 0.5 * (maxs[anode->axis] + mins[anode->axis]);\n\tVectorCopy (mins, mins1);\t\n\tVectorCopy (mins, mins2);\t\n\tVectorCopy (maxs, maxs1);\t\n\tVectorCopy (maxs, maxs2);\t\n\t\n\tmaxs1[anode->axis] = mins2[anode->axis] = anode->dist;\n\t\n\tanode->children[0] = SV_CreateworldSector (depth+1, mins2, maxs2);\n\tanode->children[1] = SV_CreateworldSector (depth+1, mins1, maxs1);\n\n\treturn anode;\n}\n\n/*\n===============\nSV_ClearWorld\n\n===============\n*/\nvoid SV_ClearWorld( void ) {\n\tclipHandle_t\th;\n\tvec3_t\t\t\tmins, maxs;\n\n\tCom_Memset( sv_worldSectors, 0, sizeof(sv_worldSectors) );\n\tsv_numworldSectors = 0;\n\n\t// get world map bounds\n\th = CM_InlineModel( 0 );\n\tCM_ModelBounds( h, mins, maxs );\n\tSV_CreateworldSector( 0, mins, maxs );\n}\n\n\n/*\n===============\nSV_UnlinkEntity\n\n===============\n*/\nvoid SV_UnlinkEntity( sharedEntity_t *gEnt ) {\n\tsvEntity_t\t\t*ent;\n\tsvEntity_t\t\t*scan;\n\tworldSector_t\t*ws;\n\n\tent = SV_SvEntityForGentity( gEnt );\n\n\tgEnt->r.linked = qfalse;\n\n\tws = ent->worldSector;\n\tif ( !ws ) {\n\t\treturn;\t\t// not linked in anywhere\n\t}\n\tent->worldSector = NULL;\n\n\tif ( ws->entities == ent ) {\n\t\tws->entities = ent->nextEntityInWorldSector;\n\t\treturn;\n\t}\n\n\tfor ( scan = ws->entities ; scan ; scan = scan->nextEntityInWorldSector ) {\n\t\tif ( scan->nextEntityInWorldSector == ent ) {\n\t\t\tscan->nextEntityInWorldSector = ent->nextEntityInWorldSector;\n\t\t\treturn;\n\t\t}\n\t}\n\n\tCom_Printf( \"WARNING: SV_UnlinkEntity: not found in worldSector\\n\" );\n}\n\n\n/*\n===============\nSV_LinkEntity\n\n===============\n*/\n#define MAX_TOTAL_ENT_LEAFS\t\t128\nvoid SV_LinkEntity( sharedEntity_t *gEnt ) {\n\tworldSector_t\t*node;\n\tint\t\t\tleafs[MAX_TOTAL_ENT_LEAFS];\n\tint\t\t\tcluster;\n\tint\t\t\tnum_leafs;\n\tint\t\t\ti, j, k;\n\tint\t\t\tarea;\n\tint\t\t\tlastLeaf;\n\tfloat\t\t*origin, *angles;\n\tsvEntity_t\t*ent;\n\n\tent = SV_SvEntityForGentity( gEnt );\n\n\tif ( ent->worldSector ) {\n\t\tSV_UnlinkEntity( gEnt );\t// unlink from old position\n\t}\n\n\t// encode the size into the entityState_t for client prediction\n\tif ( gEnt->r.bmodel ) {\n\t\tgEnt->s.solid = SOLID_BMODEL;\t\t// a solid_box will never create this value\n\t} else if ( gEnt->r.contents & ( CONTENTS_SOLID | CONTENTS_BODY ) ) {\n\t\t// assume that x/y are equal and symetric\n\t\ti = gEnt->r.maxs[0];\n\t\tif (i<1)\n\t\t\ti = 1;\n\t\tif (i>255)\n\t\t\ti = 255;\n\n\t\t// z is not symetric\n\t\tj = (-gEnt->r.mins[2]);\n\t\tif (j<1)\n\t\t\tj = 1;\n\t\tif (j>255)\n\t\t\tj = 255;\n\n\t\t// and z maxs can be negative...\n\t\tk = (gEnt->r.maxs[2]+32);\n\t\tif (k<1)\n\t\t\tk = 1;\n\t\tif (k>255)\n\t\t\tk = 255;\n\n\t\tgEnt->s.solid = (k<<16) | (j<<8) | i;\n\t} else {\n\t\tgEnt->s.solid = 0;\n\t}\n\n\t// get the position\n\torigin = gEnt->r.currentOrigin;\n\tangles = gEnt->r.currentAngles;\n\n\t// set the abs box\n\tif ( gEnt->r.bmodel && (angles[0] || angles[1] || angles[2]) ) {\n\t\t// expand for rotation\n\t\tfloat\t\tmax;\n\t\tint\t\t\ti;\n\n\t\tmax = RadiusFromBounds( gEnt->r.mins, gEnt->r.maxs );\n\t\tfor (i=0 ; i<3 ; i++) {\n\t\t\tgEnt->r.absmin[i] = origin[i] - max;\n\t\t\tgEnt->r.absmax[i] = origin[i] + max;\n\t\t}\n\t} else {\n\t\t// normal\n\t\tVectorAdd (origin, gEnt->r.mins, gEnt->r.absmin);\t\n\t\tVectorAdd (origin, gEnt->r.maxs, gEnt->r.absmax);\n\t}\n\n\t// because movement is clipped an epsilon away from an actual edge,\n\t// we must fully check even when bounding boxes don't quite touch\n\tgEnt->r.absmin[0] -= 1;\n\tgEnt->r.absmin[1] -= 1;\n\tgEnt->r.absmin[2] -= 1;\n\tgEnt->r.absmax[0] += 1;\n\tgEnt->r.absmax[1] += 1;\n\tgEnt->r.absmax[2] += 1;\n\n\t// link to PVS leafs\n\tent->numClusters = 0;\n\tent->lastCluster = 0;\n\tent->areanum = -1;\n\tent->areanum2 = -1;\n\n\t//get all leafs, including solids\n\tnum_leafs = CM_BoxLeafnums( gEnt->r.absmin, gEnt->r.absmax,\n\t\tleafs, MAX_TOTAL_ENT_LEAFS, &lastLeaf );\n\n\t// if none of the leafs were inside the map, the\n\t// entity is outside the world and can be considered unlinked\n\tif ( !num_leafs ) {\n\t\treturn;\n\t}\n\n\t// set areas, even from clusters that don't fit in the entity array\n\tfor (i=0 ; i<num_leafs ; i++) {\n\t\tarea = CM_LeafArea (leafs[i]);\n\t\tif (area != -1) {\n\t\t\t// doors may legally straggle two areas,\n\t\t\t// but nothing should evern need more than that\n\t\t\tif (ent->areanum != -1 && ent->areanum != area) {\n\t\t\t\tif (ent->areanum2 != -1 && ent->areanum2 != area && sv.state == SS_LOADING) {\n\t\t\t\t\tCom_DPrintf (\"Object %i touching 3 areas at %f %f %f\\n\",\n\t\t\t\t\tgEnt->s.number,\n\t\t\t\t\tgEnt->r.absmin[0], gEnt->r.absmin[1], gEnt->r.absmin[2]);\n\t\t\t\t}\n\t\t\t\tent->areanum2 = area;\n\t\t\t} else {\n\t\t\t\tent->areanum = area;\n\t\t\t}\n\t\t}\n\t}\n\n\t// store as many explicit clusters as we can\n\tent->numClusters = 0;\n\tfor (i=0 ; i < num_leafs ; i++) {\n\t\tcluster = CM_LeafCluster( leafs[i] );\n\t\tif ( cluster != -1 ) {\n\t\t\tent->clusternums[ent->numClusters++] = cluster;\n\t\t\tif ( ent->numClusters == MAX_ENT_CLUSTERS ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t// store off a last cluster if we need to\n\tif ( i != num_leafs ) {\n\t\tent->lastCluster = CM_LeafCluster( lastLeaf );\n\t}\n\n\tgEnt->r.linkcount++;\n\n\t// find the first world sector node that the ent's box crosses\n\tnode = sv_worldSectors;\n\twhile (1)\n\t{\n\t\tif (node->axis == -1)\n\t\t\tbreak;\n\t\tif ( gEnt->r.absmin[node->axis] > node->dist)\n\t\t\tnode = node->children[0];\n\t\telse if ( gEnt->r.absmax[node->axis] < node->dist)\n\t\t\tnode = node->children[1];\n\t\telse\n\t\t\tbreak;\t\t// crosses the node\n\t}\n\t\n\t// link it in\n\tent->worldSector = node;\n\tent->nextEntityInWorldSector = node->entities;\n\tnode->entities = ent;\n\n\tgEnt->r.linked = qtrue;\n}\n\n/*\n============================================================================\n\nAREA QUERY\n\nFills in a list of all entities who's absmin / absmax intersects the given\nbounds.  This does NOT mean that they actually touch in the case of bmodels.\n============================================================================\n*/\n\ntypedef struct {\n\tconst float\t*mins;\n\tconst float\t*maxs;\n\tint\t\t\t*list;\n\tint\t\t\tcount, maxcount;\n} areaParms_t;\n\n\n/*\n====================\nSV_AreaEntities_r\n\n====================\n*/\nvoid SV_AreaEntities_r( worldSector_t *node, areaParms_t *ap ) {\n\tsvEntity_t\t*check, *next;\n\tsharedEntity_t *gcheck;\n\tint\t\t\tcount;\n\n\tcount = 0;\n\n\tfor ( check = node->entities  ; check ; check = next ) {\n\t\tnext = check->nextEntityInWorldSector;\n\n\t\tgcheck = SV_GEntityForSvEntity( check );\n\n\t\tif ( gcheck->r.absmin[0] > ap->maxs[0]\n\t\t|| gcheck->r.absmin[1] > ap->maxs[1]\n\t\t|| gcheck->r.absmin[2] > ap->maxs[2]\n\t\t|| gcheck->r.absmax[0] < ap->mins[0]\n\t\t|| gcheck->r.absmax[1] < ap->mins[1]\n\t\t|| gcheck->r.absmax[2] < ap->mins[2]) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( ap->count == ap->maxcount ) {\n\t\t\tCom_Printf (\"SV_AreaEntities: MAXCOUNT\\n\");\n\t\t\treturn;\n\t\t}\n\n\t\tap->list[ap->count] = check - sv.svEntities;\n\t\tap->count++;\n\t}\n\t\n\tif (node->axis == -1) {\n\t\treturn;\t\t// terminal node\n\t}\n\n\t// recurse down both sides\n\tif ( ap->maxs[node->axis] > node->dist ) {\n\t\tSV_AreaEntities_r ( node->children[0], ap );\n\t}\n\tif ( ap->mins[node->axis] < node->dist ) {\n\t\tSV_AreaEntities_r ( node->children[1], ap );\n\t}\n}\n\n/*\n================\nSV_AreaEntities\n================\n*/\nint SV_AreaEntities( const vec3_t mins, const vec3_t maxs, int *entityList, int maxcount ) {\n\tareaParms_t\t\tap;\n\n\tap.mins = mins;\n\tap.maxs = maxs;\n\tap.list = entityList;\n\tap.count = 0;\n\tap.maxcount = maxcount;\n\n\tSV_AreaEntities_r( sv_worldSectors, &ap );\n\n\treturn ap.count;\n}\n\n\n\n//===========================================================================\n\n\ntypedef struct {\n\tvec3_t\t\tboxmins, boxmaxs;// enclose the test object along entire move\n\tconst float\t*mins;\n\tconst float *maxs;\t// size of the moving object\n\tconst float\t*start;\n\tvec3_t\t\tend;\n\ttrace_t\t\ttrace;\n\tint\t\t\tpassEntityNum;\n\tint\t\t\tcontentmask;\n\tint\t\t\tcapsule;\n} moveclip_t;\n\n\n/*\n====================\nSV_ClipToEntity\n\n====================\n*/\nvoid SV_ClipToEntity( trace_t *trace, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int entityNum, int contentmask, int capsule ) {\n\tsharedEntity_t\t*touch;\n\tclipHandle_t\tclipHandle;\n\tfloat\t\t\t*origin, *angles;\n\n\ttouch = SV_GentityNum( entityNum );\n\n\tCom_Memset(trace, 0, sizeof(trace_t));\n\n\t// if it doesn't have any brushes of a type we\n\t// are looking for, ignore it\n\tif ( ! ( contentmask & touch->r.contents ) ) {\n\t\ttrace->fraction = 1.0;\n\t\treturn;\n\t}\n\n\t// might intersect, so do an exact clip\n\tclipHandle = SV_ClipHandleForEntity (touch);\n\n\torigin = touch->r.currentOrigin;\n\tangles = touch->r.currentAngles;\n\n\tif ( !touch->r.bmodel ) {\n\t\tangles = vec3_origin;\t// boxes don't rotate\n\t}\n\n\tCM_TransformedBoxTrace ( trace, (float *)start, (float *)end,\n\t\t(float *)mins, (float *)maxs, clipHandle,  contentmask,\n\t\torigin, angles, capsule);\n\n\tif ( trace->fraction < 1 ) {\n\t\ttrace->entityNum = touch->s.number;\n\t}\n}\n\n\n/*\n====================\nSV_ClipMoveToEntities\n\n====================\n*/\nvoid SV_ClipMoveToEntities( moveclip_t *clip ) {\n\tint\t\t\ti, num;\n\tint\t\t\ttouchlist[MAX_GENTITIES];\n\tsharedEntity_t *touch;\n\tint\t\t\tpassOwnerNum;\n\ttrace_t\t\ttrace;\n\tclipHandle_t\tclipHandle;\n\tfloat\t\t*origin, *angles;\n\n\tnum = SV_AreaEntities( clip->boxmins, clip->boxmaxs, touchlist, MAX_GENTITIES);\n\n\tif ( clip->passEntityNum != ENTITYNUM_NONE ) {\n\t\tpassOwnerNum = ( SV_GentityNum( clip->passEntityNum ) )->r.ownerNum;\n\t\tif ( passOwnerNum == ENTITYNUM_NONE ) {\n\t\t\tpassOwnerNum = -1;\n\t\t}\n\t} else {\n\t\tpassOwnerNum = -1;\n\t}\n\n\tfor ( i=0 ; i<num ; i++ ) {\n\t\tif ( clip->trace.allsolid ) {\n\t\t\treturn;\n\t\t}\n\t\ttouch = SV_GentityNum( touchlist[i] );\n\n\t\t// see if we should ignore this entity\n\t\tif ( clip->passEntityNum != ENTITYNUM_NONE ) {\n\t\t\tif ( touchlist[i] == clip->passEntityNum ) {\n\t\t\t\tcontinue;\t// don't clip against the pass entity\n\t\t\t}\n\t\t\tif ( touch->r.ownerNum == clip->passEntityNum ) {\n\t\t\t\tcontinue;\t// don't clip against own missiles\n\t\t\t}\n\t\t\tif ( touch->r.ownerNum == passOwnerNum ) {\n\t\t\t\tcontinue;\t// don't clip against other missiles from our owner\n\t\t\t}\n\t\t}\n\n\t\t// if it doesn't have any brushes of a type we\n\t\t// are looking for, ignore it\n\t\tif ( ! ( clip->contentmask & touch->r.contents ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// might intersect, so do an exact clip\n\t\tclipHandle = SV_ClipHandleForEntity (touch);\n\n\t\torigin = touch->r.currentOrigin;\n\t\tangles = touch->r.currentAngles;\n\n\n\t\tif ( !touch->r.bmodel ) {\n\t\t\tangles = vec3_origin;\t// boxes don't rotate\n\t\t}\n\n\t\tCM_TransformedBoxTrace ( &trace, (float *)clip->start, (float *)clip->end,\n\t\t\t(float *)clip->mins, (float *)clip->maxs, clipHandle,  clip->contentmask,\n\t\t\torigin, angles, clip->capsule);\n\n\t\tif ( trace.allsolid ) {\n\t\t\tclip->trace.allsolid = qtrue;\n\t\t\ttrace.entityNum = touch->s.number;\n\t\t} else if ( trace.startsolid ) {\n\t\t\tclip->trace.startsolid = qtrue;\n\t\t\ttrace.entityNum = touch->s.number;\n\t\t}\n\n\t\tif ( trace.fraction < clip->trace.fraction ) {\n\t\t\tqboolean\toldStart;\n\n\t\t\t// make sure we keep a startsolid from a previous trace\n\t\t\toldStart = clip->trace.startsolid;\n\n\t\t\ttrace.entityNum = touch->s.number;\n\t\t\tclip->trace = trace;\n\t\t\tclip->trace.startsolid |= oldStart;\n\t\t}\n\t}\n}\n\n\n/*\n==================\nSV_Trace\n\nMoves the given mins/maxs volume through the world from start to end.\npassEntityNum and entities owned by passEntityNum are explicitly not checked.\n==================\n*/\nvoid SV_Trace( trace_t *results, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask, int capsule ) {\n\tmoveclip_t\tclip;\n\tint\t\t\ti;\n\n\tif ( !mins ) {\n\t\tmins = vec3_origin;\n\t}\n\tif ( !maxs ) {\n\t\tmaxs = vec3_origin;\n\t}\n\n\tCom_Memset ( &clip, 0, sizeof ( moveclip_t ) );\n\n\t// clip to world\n\tCM_BoxTrace( &clip.trace, start, end, mins, maxs, 0, contentmask, capsule );\n\tclip.trace.entityNum = clip.trace.fraction != 1.0 ? ENTITYNUM_WORLD : ENTITYNUM_NONE;\n\tif ( clip.trace.fraction == 0 ) {\n\t\t*results = clip.trace;\n\t\treturn;\t\t// blocked immediately by the world\n\t}\n\n\tclip.contentmask = contentmask;\n\tclip.start = start;\n//\tVectorCopy( clip.trace.endpos, clip.end );\n\tVectorCopy( end, clip.end );\n\tclip.mins = mins;\n\tclip.maxs = maxs;\n\tclip.passEntityNum = passEntityNum;\n\tclip.capsule = capsule;\n\n\t// create the bounding box of the entire move\n\t// we can limit it to the part of the move not\n\t// already clipped off by the world, which can be\n\t// a significant savings for line of sight and shot traces\n\tfor ( i=0 ; i<3 ; i++ ) {\n\t\tif ( end[i] > start[i] ) {\n\t\t\tclip.boxmins[i] = clip.start[i] + clip.mins[i] - 1;\n\t\t\tclip.boxmaxs[i] = clip.end[i] + clip.maxs[i] + 1;\n\t\t} else {\n\t\t\tclip.boxmins[i] = clip.end[i] + clip.mins[i] - 1;\n\t\t\tclip.boxmaxs[i] = clip.start[i] + clip.maxs[i] + 1;\n\t\t}\n\t}\n\n\t// clip to other solid entities\n\tSV_ClipMoveToEntities ( &clip );\n\n\t*results = clip.trace;\n}\n\n\n\n/*\n=============\nSV_PointContents\n=============\n*/\nint SV_PointContents( const vec3_t p, int passEntityNum ) {\n\tint\t\t\ttouch[MAX_GENTITIES];\n\tsharedEntity_t *hit;\n\tint\t\t\ti, num;\n\tint\t\t\tcontents, c2;\n\tclipHandle_t\tclipHandle;\n\tfloat\t\t*angles;\n\n\t// get base contents from world\n\tcontents = CM_PointContents( p, 0 );\n\n\t// or in contents from all the other entities\n\tnum = SV_AreaEntities( p, p, touch, MAX_GENTITIES );\n\n\tfor ( i=0 ; i<num ; i++ ) {\n\t\tif ( touch[i] == passEntityNum ) {\n\t\t\tcontinue;\n\t\t}\n\t\thit = SV_GentityNum( touch[i] );\n\t\t// might intersect, so do an exact clip\n\t\tclipHandle = SV_ClipHandleForEntity( hit );\n\t\tangles = hit->s.angles;\n\t\tif ( !hit->r.bmodel ) {\n\t\t\tangles = vec3_origin;\t// boxes don't rotate\n\t\t}\n\n\t\tc2 = CM_TransformedPointContents (p, clipHandle, hit->s.origin, hit->s.angles);\n\n\t\tcontents |= c2;\n\t}\n\n\treturn contents;\n}\n\n\n"
  },
  {
    "path": "code/splines/Splines.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<VisualStudioProject\n\tProjectType=\"Visual C++\"\n\tVersion=\"7.10\"\n\tName=\"Splines\"\n\tSccProjectName=\"&quot;$/MissionPack/code/Splines&quot;, WJNAAAAA\"\n\tSccLocalPath=\".\">\n\t<Platforms>\n\t\t<Platform\n\t\t\tName=\"Win32\"/>\n\t</Platforms>\n\t<Configurations>\n\t\t<Configuration\n\t\t\tName=\"Release|Win32\"\n\t\t\tOutputDirectory=\".\\Release\"\n\t\t\tIntermediateDirectory=\".\\Release\"\n\t\t\tConfigurationType=\"4\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_LIB\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"4\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release/Splines.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release/\"\n\t\t\t\tObjectFile=\".\\Release/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLibrarianTool\"\n\t\t\t\tOutputFile=\".\\Release\\Splines.lib\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Debug|Win32\"\n\t\t\tOutputDirectory=\".\\Debug\"\n\t\t\tIntermediateDirectory=\".\\Debug\"\n\t\t\tConfigurationType=\"4\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_LIB\"\n\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tRuntimeTypeInfo=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Debug/Splines.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug/\"\n\t\t\t\tObjectFile=\".\\Debug/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Debug/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLibrarianTool\"\n\t\t\t\tOutputFile=\".\\Debug\\Splines.lib\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t</Configurations>\n\t<References>\n\t</References>\n\t<Files>\n\t\t<Filter\n\t\t\tName=\"Source Files\"\n\t\t\tFilter=\"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"math_angles.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"math_matrix.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"math_quaternion.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"math_vector.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"q_parse.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"q_shared.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"splines.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"util_str.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Header Files\"\n\t\t\tFilter=\"h;hpp;hxx;hm;inl\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"math_angles.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"math_matrix.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"math_quaternion.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"math_vector.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"q_shared.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"splines.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"util_list.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"util_str.h\">\n\t\t\t</File>\n\t\t</Filter>\n\t</Files>\n\t<Globals>\n\t</Globals>\n</VisualStudioProject>\n"
  },
  {
    "path": "code/splines/math_angles.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"q_shared.h\"\n#include <float.h>\n\nangles_t ang_zero( 0.0f, 0.0f, 0.0f );\n\nvoid toAngles( mat3_t &src, angles_t &dst ) {\n\tdouble\t\ttheta;\n\tdouble\t\tcp;\n\tdouble\t\tsp;\n\n\tsp = src[ 0 ][ 2 ];\n\n\t// cap off our sin value so that we don't get any NANs\n\tif ( sp > 1.0 ) {\n\t\tsp = 1.0;\n\t} else if ( sp < -1.0 ) {\n\t\tsp = -1.0;\n\t}\n\n\ttheta = -asin( sp );\n\tcp = cos( theta );\n\n\tif ( cp > 8192 * FLT_EPSILON ) {\n\t\tdst.pitch\t= theta * 180 / M_PI;\n\t\tdst.yaw\t\t= atan2( src[ 0 ][ 1 ], src[ 0 ][ 0 ] ) * 180 / M_PI;\n\t\tdst.roll\t= atan2( src[ 1 ][ 2 ], src[ 2 ][ 2 ] ) * 180 / M_PI;\n\t} else {\n\t\tdst.pitch\t= theta * 180 / M_PI;\n\t\tdst.yaw\t\t= -atan2( src[ 1 ][ 0 ], src[ 1 ][ 1 ] ) * 180 / M_PI;\n\t\tdst.roll\t= 0;\n\t}\n}\n\nvoid toAngles( quat_t &src, angles_t &dst ) {\n\tmat3_t temp;\n\n\ttoMatrix( src, temp );\n\ttoAngles( temp, dst );\n}\n\nvoid toAngles( idVec3_t &src, angles_t &dst ) {\n\tdst.pitch\t= src[ 0 ];\n\tdst.yaw\t\t= src[ 1 ];\n\tdst.roll\t= src[ 2 ];\n}\n\nvoid angles_t::toVectors( idVec3_t *forward, idVec3_t *right, idVec3_t *up ) {\n\tfloat\t\t\tangle;\n\tstatic float\tsr, sp, sy, cr, cp, cy; // static to help MS compiler fp bugs\n\t\n\tangle = yaw * ( M_PI * 2 / 360 );\n\tsy = sin( angle );\n\tcy = cos( angle );\n\n\tangle = pitch * ( M_PI * 2 / 360 );\n\tsp = sin( angle );\n\tcp = cos( angle );\n\n\tangle = roll * ( M_PI * 2 / 360 );\n\tsr = sin( angle );\n\tcr = cos( angle );\n\n\tif ( forward ) {\n\t\tforward->set( cp * cy, cp * sy, -sp );\n\t}\n\n\tif ( right ) {\n\t\tright->set( -sr * sp * cy + cr * sy, -sr * sp * sy + -cr * cy, -sr * cp );\n\t}\n\n\tif ( up ) {\n\t\tup->set( cr * sp * cy + -sr * -sy, cr * sp * sy + -sr * cy, cr * cp );\n\t}\n}\n\nidVec3_t angles_t::toForward( void ) {\n\tfloat\t\t\tangle;\n\tstatic float\tsp, sy, cp, cy; // static to help MS compiler fp bugs\n\t\n\tangle = yaw * ( M_PI * 2 / 360 );\n\tsy = sin( angle );\n\tcy = cos( angle );\n\n\tangle = pitch * ( M_PI * 2 / 360 );\n\tsp = sin( angle );\n\tcp = cos( angle );\n\n\treturn idVec3_t( cp * cy, cp * sy, -sp );\n}\n\n/*\n=================\nNormalize360\n\nreturns angles normalized to the range [0 <= angle < 360]\n=================\n*/\nangles_t& angles_t::Normalize360( void ) {\n\tpitch\t= (360.0 / 65536) * ( ( int )( pitch\t* ( 65536 / 360.0 ) ) & 65535 );\n\tyaw\t\t= (360.0 / 65536) * ( ( int )( yaw\t\t* ( 65536 / 360.0 ) ) & 65535 );\n\troll\t= (360.0 / 65536) * ( ( int )( roll\t\t* ( 65536 / 360.0 ) ) & 65535 );\n\n\treturn *this;\n}\n\n\n/*\n=================\nNormalize180\n\nreturns angles normalized to the range [-180 < angle <= 180]\n=================\n*/\nangles_t& angles_t::Normalize180( void ) {\n\tNormalize360();\n\n\tif ( pitch > 180.0 ) {\n\t\tpitch -= 360.0;\n\t}\n\t\n\tif ( yaw > 180.0 ) {\n\t\tyaw  -= 360.0;\n\t}\n\n\tif ( roll > 180.0 ) {\n\t\troll -= 360.0;\n\t}\n\treturn *this;\n}\n"
  },
  {
    "path": "code/splines/math_angles.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __MATH_ANGLES_H__\n#define __MATH_ANGLES_H__\n\n#include <stdlib.h>\n#include <assert.h>\n\n#include \"math_vector.h\"\n\nclass mat3_t;\nclass quat_t;\nclass idVec3_t;\ntypedef idVec3_t &vec3_p;\n\nclass angles_t {\npublic:\n\tfloat\t\t\tpitch;\n\tfloat\t\t\tyaw;\n\tfloat\t\t\troll;\n\n\t\t\t\t\tangles_t();\n\t\t\t\t\tangles_t( float pitch, float yaw, float roll );\n\t\t\t\t\tangles_t( const idVec3_t &vec );\n\n\tfriend void\t\ttoAngles( idVec3_t &src, angles_t &dst );\n\tfriend void\t\ttoAngles( quat_t &src, angles_t &dst );\n\tfriend void\t\ttoAngles( mat3_t &src, angles_t &dst );\n\n\t\t\t\t\toperator vec3_p();\n\n\tfloat\t\t\toperator[]( int index ) const;\n\tfloat&\t\t\toperator[]( int index );\n\n\tvoid \t\t\tset( float pitch, float yaw, float roll );\n\n\tvoid\t\t\toperator=( angles_t const &a );\n\tvoid\t\t\toperator=( idVec3_t const &a );\n\n\tfriend angles_t\toperator+( const angles_t &a, const angles_t &b );\n\tangles_t\t\t&operator+=( angles_t const &a );\n\tangles_t\t\t&operator+=( idVec3_t const &a );\n\n\tfriend angles_t\toperator-( angles_t &a, angles_t &b );\n\tangles_t\t\t&operator-=( angles_t &a );\n\n\tfriend angles_t\toperator*( const angles_t &a, float b );\n\tfriend angles_t\toperator*( float a, const angles_t &b );\n\tangles_t\t\t&operator*=( float a );\n\n\tfriend int\t\toperator==(\tangles_t &a, angles_t &b );\n\t\t\t\t\t\n\tfriend int\t\toperator!=(\tangles_t &a, angles_t &b );\n\n\tvoid\t\t\ttoVectors( idVec3_t *forward, idVec3_t *right = NULL, idVec3_t *up = NULL );\n\tidVec3_t\t\t\ttoForward( void );\n\n\tangles_t\t\t&Zero( void );\n\n\tangles_t\t\t&Normalize360( void );\n\tangles_t\t\t&Normalize180( void );\n};\n\nextern angles_t ang_zero;\n\ninline angles_t::angles_t() {}\n\ninline angles_t::angles_t( float pitch, float yaw, float roll ) {\n\tthis->pitch = pitch;\n\tthis->yaw\t= yaw;\n\tthis->roll\t= roll;\n}\n\ninline angles_t::angles_t( const idVec3_t &vec ) {\n\tthis->pitch = vec.x;\n\tthis->yaw\t= vec.y;\n\tthis->roll\t= vec.z;\n}\n\ninline float angles_t::operator[]( int index ) const {\n\tassert( ( index >= 0 ) && ( index < 3 ) );\n\treturn ( &pitch )[ index ];\n}\n\ninline float& angles_t::operator[]( int index ) {\n\tassert( ( index >= 0 ) && ( index < 3 ) );\n\treturn ( &pitch )[ index ];\n}\n\ninline angles_t::operator vec3_p( void ) {\n\treturn *( idVec3_t * )&pitch;\n}\n\ninline void angles_t::set( float pitch, float yaw, float roll ) {\n\tthis->pitch = pitch;\n\tthis->yaw\t= yaw;\n\tthis->roll\t= roll;\n}\n\ninline void angles_t::operator=( angles_t const &a ) {\n\tpitch\t= a.pitch;\n\tyaw\t\t= a.yaw;\n\troll\t= a.roll;\n}\n\ninline void angles_t::operator=( idVec3_t const &a ) {\n\tpitch\t= a[ 0 ];\n\tyaw\t\t= a[ 1 ];\n\troll\t= a[ 2 ];\n}\n\ninline angles_t operator+( const angles_t &a, const angles_t &b ) {\n\treturn angles_t( a.pitch + b.pitch, a.yaw + b.yaw, a.roll + b.roll );\n}\n\ninline angles_t& angles_t::operator+=( angles_t const &a ) {\n\tpitch\t+= a.pitch;\n\tyaw\t\t+= a.yaw;\n\troll\t+= a.roll;\n\n\treturn *this;\n}\n\ninline angles_t& angles_t::operator+=( idVec3_t const &a ) {\n\tpitch\t+= a.x;\n\tyaw\t+= a.y;\n\troll\t+= a.z;\n\n\treturn *this;\n}\n\ninline angles_t operator-( angles_t &a, angles_t &b ) {\n\treturn angles_t( a.pitch - b.pitch, a.yaw - b.yaw, a.roll - b.roll );\n}\n\ninline angles_t& angles_t::operator-=( angles_t &a ) {\n\tpitch\t-= a.pitch;\n\tyaw\t\t-= a.yaw;\n\troll\t-= a.roll;\n\n\treturn *this;\n}\n\ninline angles_t operator*( const angles_t &a, float b ) {\n\treturn angles_t( a.pitch * b, a.yaw * b, a.roll * b );\n}\n\ninline angles_t operator*( float a, const angles_t &b ) {\n\treturn angles_t( a * b.pitch, a * b.yaw, a * b.roll );\n}\n\ninline angles_t& angles_t::operator*=( float a ) {\n\tpitch\t*= a;\n\tyaw\t\t*= a;\n\troll\t*= a;\n\n\treturn *this;\n}\n\ninline int operator==( angles_t &a, angles_t &b ) {\n\treturn ( ( a.pitch == b.pitch ) && ( a.yaw == b.yaw ) && ( a.roll == b.roll ) );\n}\n\ninline int operator!=( angles_t &a, angles_t &b ) {\n\treturn ( ( a.pitch != b.pitch ) || ( a.yaw != b.yaw ) || ( a.roll != b.roll ) );\n}\n\ninline angles_t& angles_t::Zero( void ) {\n\tpitch\t= 0.0f;\n\tyaw\t\t= 0.0f;\n\troll\t= 0.0f;\n\n\treturn *this;\n}\n\n#endif /* !__MATH_ANGLES_H__ */\n"
  },
  {
    "path": "code/splines/math_matrix.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"q_shared.h\"\n\nmat3_t mat3_default( idVec3_t( 1, 0, 0 ), idVec3_t( 0, 1, 0 ), idVec3_t( 0, 0, 1 ) );\n\nvoid toMatrix( quat_t const &src, mat3_t &dst ) {\n\tfloat\twx, wy, wz;\n\tfloat\txx, yy, yz;\n\tfloat\txy, xz, zz;\n\tfloat\tx2, y2, z2;\n\n\tx2 = src.x + src.x;\n\ty2 = src.y + src.y;\n\tz2 = src.z + src.z;\n\n\txx = src.x * x2;\n\txy = src.x * y2;\n\txz = src.x * z2;\n\n\tyy = src.y * y2;\n\tyz = src.y * z2;\n\tzz = src.z * z2;\n\n\twx = src.w * x2;\n\twy = src.w * y2;\n\twz = src.w * z2;\n\n\tdst[ 0 ][ 0 ] = 1.0f - ( yy + zz );\n\tdst[ 0 ][ 1 ] = xy - wz;\n\tdst[ 0 ][ 2 ] = xz + wy;\n\n\tdst[ 1 ][ 0 ] = xy + wz;\n\tdst[ 1 ][ 1 ] = 1.0f - ( xx + zz );\n\tdst[ 1 ][ 2 ] = yz - wx;\n\n\tdst[ 2 ][ 0 ] = xz - wy;\n\tdst[ 2 ][ 1 ] = yz + wx;\n\tdst[ 2 ][ 2 ] = 1.0f - ( xx + yy );\n}\n\nvoid toMatrix( angles_t const &src, mat3_t &dst ) {\n\tfloat\t\t\tangle;\n\tstatic float\tsr, sp, sy, cr, cp, cy; // static to help MS compiler fp bugs\n\t\t\n\tangle = src.yaw * ( M_PI * 2.0f / 360.0f );\n\tsy = sin( angle );\n\tcy = cos( angle );\n\n\tangle = src.pitch * ( M_PI * 2.0f / 360.0f );\n\tsp = sin( angle );\n\tcp = cos( angle );\n\n\tangle = src.roll * ( M_PI * 2.0f / 360.0f );\n\tsr = sin( angle );\n\tcr = cos( angle );\n\n\tdst[ 0 ].set( cp * cy, cp * sy, -sp );\n\tdst[ 1 ].set( sr * sp * cy + cr * -sy, sr * sp * sy + cr * cy, sr * cp );\n\tdst[ 2 ].set( cr * sp * cy + -sr * -sy, cr * sp * sy + -sr * cy, cr * cp );\n}\n\nvoid toMatrix( idVec3_t const &src, mat3_t &dst ) {\n        angles_t sup = src;\n        toMatrix(sup, dst);\n}\n\nvoid mat3_t::ProjectVector( const idVec3_t &src, idVec3_t &dst ) const {\n\tdst.x = src * mat[ 0 ];\n\tdst.y = src * mat[ 1 ];\n\tdst.z = src * mat[ 2 ];\n}\n\nvoid mat3_t::UnprojectVector( const idVec3_t &src, idVec3_t &dst ) const {\n\tdst = mat[ 0 ] * src.x + mat[ 1 ] * src.y + mat[ 2 ] * src.z;\n}\n\nvoid mat3_t::Transpose( mat3_t &matrix ) {\n\tint\ti;\n\tint\tj;\n   \n\tfor( i = 0; i < 3; i++ ) {\n\t\tfor( j = 0; j < 3; j++ ) {\n\t\t\tmatrix[ i ][ j ] = mat[ j ][ i ];\n        }\n\t}\n}\n\nvoid mat3_t::Transpose( void ) {\n\tfloat\ttemp;\n\tint\t\ti;\n\tint\t\tj;\n   \n\tfor( i = 0; i < 3; i++ ) {\n\t\tfor( j = i + 1; j < 3; j++ ) {\n\t\t\ttemp = mat[ i ][ j ];\n\t\t\tmat[ i ][ j ] = mat[ j ][ i ];\n\t\t\tmat[ j ][ i ] = temp;\n        }\n\t}\n}\n\nmat3_t mat3_t::Inverse( void ) const {\n\tmat3_t inv( *this );\n\n\tinv.Transpose();\n\n\treturn inv;\n}\n\nvoid mat3_t::Clear( void ) {\n\tmat[0].set( 1, 0, 0 );\n\tmat[1].set( 0, 1, 0 );\n\tmat[2].set( 0, 0, 1 );\n}\n"
  },
  {
    "path": "code/splines/math_matrix.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __MATH_MATRIX_H__\n#define __MATH_MATRIX_H__\n\n#include <string.h>\n#include \"math_vector.h\"\n\n#ifndef ID_INLINE\n#ifdef _WIN32\n#define ID_INLINE __inline \n#else\n#define ID_INLINE inline\n#endif\n#endif\n\nclass quat_t;\nclass angles_t;\n\nclass mat3_t {\npublic:\n\tidVec3_t\t\t\tmat[ 3 ];\n\n\t\t\t\t\tmat3_t();\n\t\t\t\t\tmat3_t( float src[ 3 ][ 3 ] );\n\t\t\t\t\tmat3_t( idVec3_t const &x, idVec3_t const &y, idVec3_t const &z );\n\t\t\t\t\tmat3_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 );\n\n\tfriend void\t\ttoMatrix( quat_t const &src, mat3_t &dst );\n\tfriend void\t\ttoMatrix( angles_t const &src, mat3_t &dst );\n\tfriend void\t\ttoMatrix( idVec3_t const &src, mat3_t &dst );\n\n\tidVec3_t\t\t\toperator[]( int index ) const;\n\tidVec3_t\t\t\t&operator[]( int index );\n\n\tidVec3_t\t\t\toperator*( const idVec3_t &vec ) const;\n\tmat3_t\t\t\toperator*( const mat3_t &a ) const;\n\tmat3_t\t\t\toperator*( float a ) const;\n\tmat3_t\t\t\toperator+( mat3_t const &a ) const;\n\tmat3_t\t\t\toperator-( mat3_t const &a ) const;\n\n\tfriend idVec3_t\toperator*( const idVec3_t &vec, const mat3_t &mat );\n\tfriend mat3_t\toperator*( float a, mat3_t const &b );\n\n\tmat3_t\t\t\t&operator*=( float a );\n\tmat3_t\t\t\t&operator+=( mat3_t const &a );\n\tmat3_t\t\t\t&operator-=( mat3_t const &a );\n\n\tvoid\t\t\tClear( void );\n\n\tvoid\t\t\tProjectVector( const idVec3_t &src, idVec3_t &dst ) const;\n\tvoid\t\t\tUnprojectVector( const idVec3_t &src, idVec3_t &dst ) const;\n\n\tvoid\t\t\tOrthoNormalize( void );\n\tvoid\t\t\tTranspose( mat3_t &matrix );\n\tvoid\t\t\tTranspose( void );\n\tmat3_t\t\t\tInverse( void ) const;\n\tvoid\t\t\tIdentity( void );\n\n\tfriend void\t\tInverseMultiply( const mat3_t &inv, const mat3_t &b, mat3_t &dst );\n\tfriend mat3_t\tSkewSymmetric( idVec3_t const &src );\n};\n\nID_INLINE mat3_t::mat3_t() {\n}\n\nID_INLINE mat3_t::mat3_t( float src[ 3 ][ 3 ] ) {\n\tmemcpy( mat, src, sizeof( src ) );\n}\n\nID_INLINE mat3_t::mat3_t( idVec3_t const &x, idVec3_t const &y, idVec3_t const &z ) {\n\tmat[ 0 ].x = x.x; mat[ 0 ].y = x.y; mat[ 0 ].z = x.z;\n\tmat[ 1 ].x = y.x; mat[ 1 ].y = y.y; mat[ 1 ].z = y.z;\n\tmat[ 2 ].x = z.x; mat[ 2 ].y = z.y; mat[ 2 ].z = z.z;\n}\n\nID_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 ) {\n\tmat[ 0 ].x = xx; mat[ 0 ].y = xy; mat[ 0 ].z = xz;\n\tmat[ 1 ].x = yx; mat[ 1 ].y = yy; mat[ 1 ].z = yz;\n\tmat[ 2 ].x = zx; mat[ 2 ].y = zy; mat[ 2 ].z = zz;\n}\n\nID_INLINE idVec3_t mat3_t::operator[]( int index ) const {\n\tassert( ( index >= 0 ) && ( index < 3 ) );\n\treturn mat[ index ];\n}\n\nID_INLINE idVec3_t& mat3_t::operator[]( int index ) {\n\tassert( ( index >= 0 ) && ( index < 3 ) );\n\treturn mat[ index ];\n}\n\nID_INLINE idVec3_t mat3_t::operator*( const idVec3_t &vec ) const {\n\treturn idVec3_t( \n\t\tmat[ 0 ].x * vec.x + mat[ 1 ].x * vec.y + mat[ 2 ].x * vec.z,\n\t\tmat[ 0 ].y * vec.x + mat[ 1 ].y * vec.y + mat[ 2 ].y * vec.z,\n\t\tmat[ 0 ].z * vec.x + mat[ 1 ].z * vec.y + mat[ 2 ].z * vec.z );\n}\n\nID_INLINE mat3_t mat3_t::operator*( const mat3_t &a ) const {\n\treturn mat3_t( \n\t\tmat[0].x * a[0].x + mat[0].y * a[1].x + mat[0].z * a[2].x,\n\t\tmat[0].x * a[0].y + mat[0].y * a[1].y + mat[0].z * a[2].y,\n\t\tmat[0].x * a[0].z + mat[0].y * a[1].z + mat[0].z * a[2].z,\n\t\tmat[1].x * a[0].x + mat[1].y * a[1].x + mat[1].z * a[2].x,\n\t\tmat[1].x * a[0].y + mat[1].y * a[1].y + mat[1].z * a[2].y,\n\t\tmat[1].x * a[0].z + mat[1].y * a[1].z + mat[1].z * a[2].z,\n\t\tmat[2].x * a[0].x + mat[2].y * a[1].x + mat[2].z * a[2].x,\n\t\tmat[2].x * a[0].y + mat[2].y * a[1].y + mat[2].z * a[2].y,\n\t\tmat[2].x * a[0].z + mat[2].y * a[1].z + mat[2].z * a[2].z );\n}\n\nID_INLINE mat3_t mat3_t::operator*( float a ) const {\n\treturn mat3_t( \n\t\tmat[0].x * a, mat[0].y * a, mat[0].z * a, \n\t\tmat[1].x * a, mat[1].y * a, mat[1].z * a, \n\t\tmat[2].x * a, mat[2].y * a, mat[2].z * a );\n}\n\nID_INLINE mat3_t mat3_t::operator+( mat3_t const &a ) const {\n\treturn mat3_t( \n\t\tmat[0].x + a[0].x, mat[0].y + a[0].y, mat[0].z + a[0].z, \n\t\tmat[1].x + a[1].x, mat[1].y + a[1].y, mat[1].z + a[1].z, \n\t\tmat[2].x + a[2].x, mat[2].y + a[2].y, mat[2].z + a[2].z );\n}\n    \nID_INLINE mat3_t mat3_t::operator-( mat3_t const &a ) const {\n\treturn mat3_t( \n\t\tmat[0].x - a[0].x, mat[0].y - a[0].y, mat[0].z - a[0].z, \n\t\tmat[1].x - a[1].x, mat[1].y - a[1].y, mat[1].z - a[1].z, \n\t\tmat[2].x - a[2].x, mat[2].y - a[2].y, mat[2].z - a[2].z );\n}\n\nID_INLINE idVec3_t operator*( const idVec3_t &vec, const mat3_t &mat ) {\n\treturn idVec3_t( \n\t\tmat[ 0 ].x * vec.x + mat[ 1 ].x * vec.y + mat[ 2 ].x * vec.z,\n\t\tmat[ 0 ].y * vec.x + mat[ 1 ].y * vec.y + mat[ 2 ].y * vec.z,\n\t\tmat[ 0 ].z * vec.x + mat[ 1 ].z * vec.y + mat[ 2 ].z * vec.z );\n}\n\nID_INLINE mat3_t operator*( float a, mat3_t const &b ) {\n\treturn mat3_t( \n\t\tb[0].x * a, b[0].y * a, b[0].z * a, \n\t\tb[1].x * a, b[1].y * a, b[1].z * a, \n\t\tb[2].x * a, b[2].y * a, b[2].z * a );\n}\n\nID_INLINE mat3_t &mat3_t::operator*=( float a ) {\n\tmat[0].x *= a; mat[0].y *= a; mat[0].z *= a;\n\tmat[1].x *= a; mat[1].y *= a; mat[1].z *= a; \n\tmat[2].x *= a; mat[2].y *= a; mat[2].z *= a;\n\n    return *this;\n}\n\nID_INLINE mat3_t &mat3_t::operator+=( mat3_t const &a ) {\n\tmat[0].x += a[0].x; mat[0].y += a[0].y; mat[0].z += a[0].z;\n\tmat[1].x += a[1].x; mat[1].y += a[1].y; mat[1].z += a[1].z;\n\tmat[2].x += a[2].x; mat[2].y += a[2].y; mat[2].z += a[2].z;\n\n    return *this;\n}\n\nID_INLINE mat3_t &mat3_t::operator-=( mat3_t const &a ) {\n\tmat[0].x -= a[0].x; mat[0].y -= a[0].y; mat[0].z -= a[0].z;\n\tmat[1].x -= a[1].x; mat[1].y -= a[1].y; mat[1].z -= a[1].z;\n\tmat[2].x -= a[2].x; mat[2].y -= a[2].y; mat[2].z -= a[2].z;\n\n    return *this;\n}\n\nID_INLINE void mat3_t::OrthoNormalize( void ) {\n\tmat[ 0 ].Normalize();\n\tmat[ 2 ].Cross( mat[ 0 ], mat[ 1 ] );\n\tmat[ 2 ].Normalize();\n\tmat[ 1 ].Cross( mat[ 2 ], mat[ 0 ] );\n\tmat[ 1 ].Normalize();\n}\n\nID_INLINE void mat3_t::Identity( void ) {\n\tmat[ 0 ].x = 1.f; mat[ 0 ].y = 0.f; mat[ 0 ].z = 0.f;\n\tmat[ 1 ].x = 0.f; mat[ 1 ].y = 1.f; mat[ 1 ].z = 0.f;\n\tmat[ 2 ].x = 0.f; mat[ 2 ].y = 0.f; mat[ 2 ].z = 1.f;\n}\n\nID_INLINE void InverseMultiply( const mat3_t &inv, const mat3_t &b, mat3_t &dst ) {\n\tdst[0].x = inv[0].x * b[0].x + inv[1].x * b[1].x + inv[2].x * b[2].x;\n\tdst[0].y = inv[0].x * b[0].y + inv[1].x * b[1].y + inv[2].x * b[2].y;\n\tdst[0].z = inv[0].x * b[0].z + inv[1].x * b[1].z + inv[2].x * b[2].z;\n\tdst[1].x = inv[0].y * b[0].x + inv[1].y * b[1].x + inv[2].y * b[2].x;\n\tdst[1].y = inv[0].y * b[0].y + inv[1].y * b[1].y + inv[2].y * b[2].y;\n\tdst[1].z = inv[0].y * b[0].z + inv[1].y * b[1].z + inv[2].y * b[2].z;\n\tdst[2].x = inv[0].z * b[0].x + inv[1].z * b[1].x + inv[2].z * b[2].x;\n\tdst[2].y = inv[0].z * b[0].y + inv[1].z * b[1].y + inv[2].z * b[2].y;\n\tdst[2].z = inv[0].z * b[0].z + inv[1].z * b[1].z + inv[2].z * b[2].z;\n}\n\nID_INLINE mat3_t SkewSymmetric( idVec3_t const &src ) {\n\treturn mat3_t( 0.0f, -src.z,  src.y, src.z,   0.0f, -src.x, -src.y,  src.x,   0.0f );\n}\n\nextern mat3_t mat3_default;\n\n#endif /* !__MATH_MATRIX_H__ */\n"
  },
  {
    "path": "code/splines/math_quaternion.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"math_quaternion.h\"\n#include \"math_matrix.h\"\n\nvoid toQuat( idVec3_t &src, quat_t &dst ) {\n\tdst.x = src.x;\n\tdst.y = src.y;\n\tdst.z = src.z;\n\tdst.w = 0.0f;\n}\n\nvoid toQuat( angles_t &src, quat_t &dst ) {\n\tmat3_t temp;\n\n\ttoMatrix( src, temp );\n\ttoQuat( temp, dst );\n}\n\nvoid toQuat( mat3_t &src, quat_t &dst ) {\n\tfloat\t\ttrace;\n\tfloat\t\ts;\n\tint     \ti;\n\tint\t\t\tj;\n\tint\t\t\tk;\n\n\tstatic int \tnext[ 3 ] = { 1, 2, 0 };\n\n\ttrace = src[ 0 ][ 0 ] + src[ 1 ][ 1 ] + src[ 2 ][ 2 ];\n\tif ( trace > 0.0f ) {\n\t\ts = ( float )sqrt( trace + 1.0f );\n\t\tdst.w = s * 0.5f;\n\t\ts = 0.5f / s;\n    \n\t\tdst.x = ( src[ 2 ][ 1 ] - src[ 1 ][ 2 ] ) * s;\n\t\tdst.y = ( src[ 0 ][ 2 ] - src[ 2 ][ 0 ] ) * s;\n\t\tdst.z = ( src[ 1 ][ 0 ] - src[ 0 ][ 1 ] ) * s;\n\t} else {\n\t\ti = 0;\n\t\tif ( src[ 1 ][ 1 ] > src[ 0 ][ 0 ] ) {\n\t\t\ti = 1;\n\t\t}\n\t\tif ( src[ 2 ][ 2 ] > src[ i ][ i ] ) {\n\t\t\ti = 2;\n\t\t}\n\n\t\tj = next[ i ];  \n\t\tk = next[ j ];\n    \n\t\ts = ( float )sqrt( ( src[ i ][ i ] - ( src[ j ][ j ] + src[ k ][ k ] ) ) + 1.0f );\n\t\tdst[ i ] = s * 0.5f;\n    \n\t\ts = 0.5f / s;\n    \n\t\tdst.w\t\t= ( src[ k ][ j ] - src[ j ][ k ] ) * s;\n\t\tdst[ j ]\t= ( src[ j ][ i ] + src[ i ][ j ] ) * s;\n\t\tdst[ k ]\t= ( src[ k ][ i ] + src[ i ][ k ] ) * s;\n\t}\n}\n"
  },
  {
    "path": "code/splines/math_quaternion.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __MATH_QUATERNION_H__\n#define __MATH_QUATERNION_H__\n\n#include <assert.h>\n#include <math.h>\n\nclass idVec3_t;\nclass angles_t;\nclass mat3_t;\n\nclass quat_t {\npublic:\n\tfloat\t\t\tx;\n\tfloat\t\t\ty;\n\tfloat\t\t\tz;\n\tfloat\t\t\tw;\n\n\t\t\t\t\tquat_t();\n\t\t\t\t\tquat_t( float x, float y, float z, float w );\n\n\tfriend void\t\ttoQuat( idVec3_t &src, quat_t &dst );\n\tfriend void\t\ttoQuat( angles_t &src, quat_t &dst );\n\tfriend void\t\ttoQuat( mat3_t &src, quat_t &dst );\n\n\tfloat\t\t\t*vec4( void );\n\t\t\t\n\tfloat\t\t\toperator[]( int index ) const;\n\tfloat\t\t\t&operator[]( int index );\n\n\tvoid \t\t\tset( float x, float y, float z, float w );\n\n\tvoid\t\t\toperator=( quat_t a );\n\n\tfriend quat_t\toperator+( quat_t a, quat_t b );\n\tquat_t\t\t\t&operator+=( quat_t a );\n\n\tfriend quat_t\toperator-( quat_t a, quat_t b );\n\tquat_t\t\t\t&operator-=( quat_t a );\n\n\tfriend quat_t\toperator*( quat_t a, float b );\n\tfriend quat_t\toperator*( float a, quat_t b );\n\tquat_t\t\t\t&operator*=( float a );\n\n\tfriend int\t\toperator==(\tquat_t a, quat_t b );\n\tfriend int\t\toperator!=(\tquat_t a, quat_t b );\n\n\tfloat\t\t\tLength( void );\n\tquat_t\t\t\t&Normalize( void );\n\n\tquat_t\t\t\toperator-();\n};\n\ninline quat_t::quat_t() {\n}\n\ninline quat_t::quat_t( float x, float y, float z, float w ) {\n\tthis->x = x;\n\tthis->y = y;\n\tthis->z = z;\n\tthis->w = w;\n}\n\ninline float *quat_t::vec4( void ) {\n\treturn &x;\n}\n\ninline float quat_t::operator[]( int index ) const {\n\tassert( ( index >= 0 ) && ( index < 4 ) );\n\treturn ( &x )[ index ];\n}\n\ninline float& quat_t::operator[]( int index ) {\n\tassert( ( index >= 0 ) && ( index < 4 ) );\n\treturn ( &x )[ index ];\n}\n\ninline void quat_t::set( float x, float y, float z, float w ) {\n\tthis->x = x;\n\tthis->y = y;\n\tthis->z = z;\n\tthis->w = w;\n}\n\ninline void quat_t::operator=( quat_t a ) {\n\tx = a.x;\n\ty = a.y;\n\tz = a.z;\n\tw = a.w;\n}\n\ninline quat_t operator+( quat_t a, quat_t b ) {\n\treturn quat_t( a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w );\n}\n\ninline quat_t& quat_t::operator+=( quat_t a ) {\n\tx += a.x;\n\ty += a.y;\n\tz += a.z;\n\tw += a.w;\n\n\treturn *this;\n}\n\ninline quat_t operator-( quat_t a, quat_t b ) {\n\treturn quat_t( a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w );\n}\n\ninline quat_t& quat_t::operator-=( quat_t a ) {\n\tx -= a.x;\n\ty -= a.y;\n\tz -= a.z;\n\tw -= a.w;\n\n\treturn *this;\n}\n\ninline quat_t operator*( quat_t a, float b ) {\n\treturn quat_t( a.x * b, a.y * b, a.z * b, a.w * b );\n}\n\ninline quat_t operator*( float a, quat_t b ) {\n\treturn b * a;\n}\n\ninline quat_t& quat_t::operator*=( float a ) {\n\tx *= a;\n\ty *= a;\n\tz *= a;\n\tw *= a;\n\n\treturn *this;\n}\n\ninline int operator==( quat_t a, quat_t b ) {\n\treturn ( ( a.x == b.x ) && ( a.y == b.y ) && ( a.z == b.z ) && ( a.w == b.w ) );\n}\n\ninline int operator!=( quat_t a, quat_t b ) {\n\treturn ( ( a.x != b.x ) || ( a.y != b.y ) || ( a.z != b.z ) && ( a.w != b.w ) );\n}\n\ninline float quat_t::Length( void ) {\n\tfloat length;\n\t\n\tlength = x * x + y * y + z * z + w * w;\n\treturn ( float )sqrt( length );\n}\n\ninline quat_t& quat_t::Normalize( void ) {\n\tfloat length;\n\tfloat ilength;\n\n\tlength = this->Length();\n\tif ( length ) {\n\t\tilength = 1 / length;\n\t\tx *= ilength;\n\t\ty *= ilength;\n\t\tz *= ilength;\n\t\tw *= ilength;\n\t}\n\t\t\n\treturn *this;\n}\n\ninline quat_t quat_t::operator-() {\n\treturn quat_t( -x, -y, -z, -w );\n}\n\n#endif /* !__MATH_QUATERNION_H__ */\n"
  },
  {
    "path": "code/splines/math_vector.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//#include \"../game/q_shared.h\"\n#include \"math_vector.h\"\n#include <assert.h>\n#include <math.h>\n#include <stdio.h>\n#include <stdarg.h>\n#include <string.h>\n#include <stdlib.h>\n#include <time.h>\n#include <ctype.h>\n\n#define M_PI\t\t3.14159265358979323846\t// matches value in gcc v2 math.h\n\n#define LERP_DELTA 1e-6\n\nidVec3_t vec_zero( 0.0f, 0.0f, 0.0f );\n\nBounds\tboundsZero;\n\nfloat idVec3_t::toYaw( void ) {\n\tfloat yaw;\n\t\n\tif ( ( y == 0 ) && ( x == 0 ) ) {\n\t\tyaw = 0;\n\t} else {\n\t\tyaw = atan2( y, x ) * 180 / M_PI;\n\t\tif ( yaw < 0 ) {\n\t\t\tyaw += 360;\n\t\t}\n\t}\n\n\treturn yaw;\n}\n\nfloat idVec3_t::toPitch( void ) {\n\tfloat\tforward;\n\tfloat\tpitch;\n\t\n\tif ( ( x == 0 ) && ( y == 0 ) ) {\n\t\tif ( z > 0 ) {\n\t\t\tpitch = 90;\n\t\t} else {\n\t\t\tpitch = 270;\n\t\t}\n\t} else {\n\t\tforward = ( float )idSqrt( x * x + y * y );\n\t\tpitch = atan2( z, forward ) * 180 / M_PI;\n\t\tif ( pitch < 0 ) {\n\t\t\tpitch += 360;\n\t\t}\n\t}\n\n\treturn pitch;\n}\n\n/*\nangles_t idVec3_t::toAngles( void ) {\n\tfloat forward;\n\tfloat yaw;\n\tfloat pitch;\n\t\n\tif ( ( x == 0 ) && ( y == 0 ) ) {\n\t\tyaw = 0;\n\t\tif ( z > 0 ) {\n\t\t\tpitch = 90;\n\t\t} else {\n\t\t\tpitch = 270;\n\t\t}\n\t} else {\n\t\tyaw = atan2( y, x ) * 180 / M_PI;\n\t\tif ( yaw < 0 ) {\n\t\t\tyaw += 360;\n\t\t}\n\n\t\tforward = ( float )idSqrt( x * x + y * y );\n\t\tpitch = atan2( z, forward ) * 180 / M_PI;\n\t\tif ( pitch < 0 ) {\n\t\t\tpitch += 360;\n\t\t}\n\t}\n\n\treturn angles_t( -pitch, yaw, 0 );\n}\n*/\n\nidVec3_t LerpVector( idVec3_t &w1, idVec3_t &w2, const float t ) {\n\tfloat omega, cosom, sinom, scale0, scale1;\n\n\tcosom = w1 * w2;\n\tif ( ( 1.0 - cosom ) > LERP_DELTA ) {\n\t\tomega = acos( cosom );\n\t\tsinom = sin( omega );\n\t\tscale0 = sin( ( 1.0 - t ) * omega ) / sinom;\n\t\tscale1 = sin( t * omega ) / sinom;\n\t} else {\n\t\tscale0 = 1.0 - t;\n\t\tscale1 = t;\n\t}\n\n\treturn ( w1 * scale0 + w2 * scale1 );\n}\n\n/*\n=============\nidVec3_t::string\n\nThis is just a convenience function\nfor printing vectors\n=============\n*/\nchar *idVec3_t::string( void ) {\n\tstatic\tint\t\tindex = 0;\n\tstatic\tchar\tstr[ 8 ][ 36 ];\n\tchar\t*s;\n\n\t// use an array so that multiple toString's won't collide\n\ts = str[ index ];\n\tindex = (index + 1)&7;\n\n\tsprintf( s, \"%.2f %.2f %.2f\", x, y, z );\n\n\treturn s;\n}\n"
  },
  {
    "path": "code/splines/math_vector.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __MATH_VECTOR_H__\n#define __MATH_VECTOR_H__\n\n#if defined(_WIN32)\n#pragma warning(disable : 4244)\n#endif\n\n#include <math.h>\n#include <assert.h>\n\n//#define DotProduct(a,b)\t\t\t((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2])\n//#define VectorSubtract(a,b,c)\t((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2])\n//#define VectorAdd(a,b,c)\t\t((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2])\n//#define VectorCopy(a,b)\t\t\t((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2])\n//#define VectorCopy(a,b)\t\t\t((b).x=(a).x,(b).y=(a).y,(b).z=(a).z])\n\n//#define\tVectorScale(v, s, o)\t((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s))\n#define\t__VectorMA(v, s, b, o)\t((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s))\n//#define CrossProduct(a,b,c)\t\t((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])\n\n#define DotProduct4(x,y)\t\t((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]+(x)[3]*(y)[3])\n#define VectorSubtract4(a,b,c)\t((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2],(c)[3]=(a)[3]-(b)[3])\n#define VectorAdd4(a,b,c)\t\t((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2],(c)[3]=(a)[3]+(b)[3])\n#define VectorCopy4(a,b)\t\t((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])\n#define\tVectorScale4(v, s, o)\t((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s),(o)[3]=(v)[3]*(s))\n#define\tVectorMA4(v, s, b, o)\t((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))\n\n\n//#define VectorClear(a)\t\t\t((a)[0]=(a)[1]=(a)[2]=0)\n#define VectorNegate(a,b)\t\t((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2])\n//#define VectorSet(v, x, y, z)\t((v)[0]=(x), (v)[1]=(y), (v)[2]=(z))\n#define Vector4Copy(a,b)\t\t((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])\n\n#define\tSnapVector(v) {v[0]=(int)v[0];v[1]=(int)v[1];v[2]=(int)v[2];}\n\n\n//#include \"util_heap.h\"\n\n#ifndef EQUAL_EPSILON\n#define EQUAL_EPSILON\t0.001\n#endif\n\nfloat Q_fabs( float f );\n\n#ifndef ID_INLINE\n#ifdef _WIN32\n#define ID_INLINE __inline \n#else\n#define ID_INLINE inline\n#endif\n#endif\n\n// if this is defined, vec3 will take four elements, which may allow\n// easier SIMD optimizations\n//#define\tFAT_VEC3\n//#ifdef __ppc__\n//#pragma align(16)\n//#endif\n\nclass angles_t;\n#ifdef __ppc__\n// Vanilla PPC code, but since PPC has a reciprocal square root estimate instruction, \n// runs *much* faster than calling sqrt(). We'll use two Newton-Raphson \n// refinement steps to get bunch more precision in the 1/sqrt() value for very little cost. \n// We'll then multiply 1/sqrt times the original value to get the sqrt. \n// This is about 12.4 times faster than sqrt() and according to my testing (not exhaustive) \n// it returns fairly accurate results (error below 1.0e-5 up to 100000.0 in 0.1 increments). \n\nstatic inline float idSqrt(float x) {\n    const float half = 0.5;\n    const float one = 1.0;\n    float B, y0, y1;\n\n    // This'll NaN if it hits frsqrte. Handle both +0.0 and -0.0\n    if (fabs(x) == 0.0)\n        return x;\n    B = x;\n    \n#ifdef __GNUC__\n    asm(\"frsqrte %0,%1\" : \"=f\" (y0) : \"f\" (B));\n#else\n    y0 = __frsqrte(B);\n#endif\n    /* First refinement step */\n    \n    y1 = y0 + half*y0*(one - B*y0*y0);\n    \n    /* Second refinement step -- copy the output of the last step to the input of this step */\n    \n    y0 = y1;\n    y1 = y0 + half*y0*(one - B*y0*y0);\n    \n    /* Get sqrt(x) from x * 1/sqrt(x) */\n    return x * y1;\n}\n#else\nstatic inline double idSqrt(double x) {\n    return sqrt(x);\n}\n#endif\n\n\n//class idVec3_t  : public idHeap<idVec3_t> {\nclass idVec3_t {\npublic:\t\n#ifndef\tFAT_VEC3\n\t    float x,y,z;\n#else\n\t    float x,y,z,dist;\n#endif\n\n#ifndef\tFAT_VEC3\n\t\t\t\t\tidVec3_t() {};\n#else\n\t\t\t\t\tidVec3_t() {dist = 0.0f;};\n#endif\n\t\t\t\t\tidVec3_t( const float x, const float y, const float z );\n\n\t\t\t\t\toperator float *();\n\n\tfloat\t\t\toperator[]( const int index ) const;\n\tfloat\t\t\t&operator[]( const int index );\n\n\tvoid \t\t\tset( const float x, const float y, const float z );\n\n\tidVec3_t\t\t\toperator-() const;\n\n\tidVec3_t\t\t\t&operator=( const idVec3_t &a );\n\n\tfloat\t\t\toperator*( const idVec3_t &a ) const;\n\tidVec3_t\t\t\toperator*( const float a ) const;\n\tfriend idVec3_t\toperator*( float a, idVec3_t b );\n\n\tidVec3_t\t\t\toperator+( const idVec3_t &a ) const;\n\tidVec3_t\t\t\toperator-( const idVec3_t &a ) const;\n\t\n\tidVec3_t\t\t\t&operator+=( const idVec3_t &a );\n\tidVec3_t\t\t\t&operator-=( const idVec3_t &a );\n\tidVec3_t\t\t\t&operator*=( const float a );\n\n\tint\t\t\t\toperator==(\tconst idVec3_t &a ) const;\n\tint\t\t\t\toperator!=(\tconst idVec3_t &a ) const;\n\n\tidVec3_t\t\t\tCross( const idVec3_t &a ) const;\n\tidVec3_t\t\t\t&Cross( const idVec3_t &a, const idVec3_t &b );\n\n\tfloat\t\t\tLength( void ) const;\n\tfloat\t\t\tNormalize( void );\n\n\tvoid\t\t\tZero( void );\n\tvoid\t\t\tSnap( void );\n\tvoid\t\t\tSnapTowards( const idVec3_t &to );\n\n\tfloat\t\t\ttoYaw( void );\n\tfloat\t\t\ttoPitch( void );\n\tangles_t\t\ttoAngles( void );\n\tfriend idVec3_t\tLerpVector( const idVec3_t &w1, const idVec3_t &w2, const float t );\n\n\tchar\t\t\t*string( void );\n};\n\nextern idVec3_t vec_zero;\n\nID_INLINE idVec3_t::idVec3_t( const float x, const float y, const float z ) {\n\tthis->x = x;\n\tthis->y = y;\n\tthis->z = z;\n#ifdef\tFAT_VEC3\n\tthis->dist = 0.0f;\n#endif\n}\n\nID_INLINE float idVec3_t::operator[]( const int index ) const {\n\treturn ( &x )[ index ];\n}\n\nID_INLINE float &idVec3_t::operator[]( const int index ) {\n\treturn ( &x )[ index ];\n}\n\nID_INLINE idVec3_t::operator float *( void ) {\n\treturn &x;\n}\n\nID_INLINE idVec3_t idVec3_t::operator-() const {\n\treturn idVec3_t( -x, -y, -z );\n}\n\t\nID_INLINE idVec3_t &idVec3_t::operator=( const idVec3_t &a ) { \n\tx = a.x;\n\ty = a.y;\n\tz = a.z;\n\t\n\treturn *this;\n}\n\nID_INLINE void idVec3_t::set( const float x, const float y, const float z ) {\n\tthis->x = x;\n\tthis->y = y;\n\tthis->z = z;\n}\n\nID_INLINE idVec3_t idVec3_t::operator-( const idVec3_t &a ) const {\n\treturn idVec3_t( x - a.x, y - a.y, z - a.z );\n}\n\nID_INLINE float idVec3_t::operator*( const idVec3_t &a ) const {\n\treturn x * a.x + y * a.y + z * a.z;\n}\n\nID_INLINE idVec3_t idVec3_t::operator*( const float a ) const {\n\treturn idVec3_t( x * a, y * a, z * a );\n}\n\nID_INLINE idVec3_t operator*( const float a, const idVec3_t b ) {\n\treturn idVec3_t( b.x * a, b.y * a, b.z * a );\n}\n\nID_INLINE idVec3_t idVec3_t::operator+( const idVec3_t &a ) const {\n\treturn idVec3_t( x + a.x, y + a.y, z + a.z );\n}\n\nID_INLINE idVec3_t &idVec3_t::operator+=( const idVec3_t &a ) {\n\tx += a.x;\n\ty += a.y;\n\tz += a.z;\n\n\treturn *this;\n}\n\nID_INLINE idVec3_t &idVec3_t::operator-=( const idVec3_t &a ) {\n\tx -= a.x;\n\ty -= a.y;\n\tz -= a.z;\n\n\treturn *this;\n}\n\nID_INLINE idVec3_t &idVec3_t::operator*=( const float a ) {\n\tx *= a;\n\ty *= a;\n\tz *= a;\n\n\treturn *this;\n}\n\nID_INLINE int idVec3_t::operator==( const idVec3_t &a ) const {\n\tif ( Q_fabs( x - a.x ) > EQUAL_EPSILON ) {\n\t\treturn false;\n\t}\n\t\t\t\n\tif ( Q_fabs( y - a.y ) > EQUAL_EPSILON ) {\n\t\treturn false;\n\t}\n\n\tif ( Q_fabs( z - a.z ) > EQUAL_EPSILON ) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\nID_INLINE int idVec3_t::operator!=( const idVec3_t &a ) const {\n\tif ( Q_fabs( x - a.x ) > EQUAL_EPSILON ) {\n\t\treturn true;\n\t}\n\t\t\t\n\tif ( Q_fabs( y - a.y ) > EQUAL_EPSILON ) {\n\t\treturn true;\n\t}\n\n\tif ( Q_fabs( z - a.z ) > EQUAL_EPSILON ) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nID_INLINE idVec3_t idVec3_t::Cross( const idVec3_t &a ) const {\n\treturn idVec3_t( y * a.z - z * a.y, z * a.x - x * a.z, x * a.y - y * a.x );\n}\n\nID_INLINE idVec3_t &idVec3_t::Cross( const idVec3_t &a, const idVec3_t &b ) {\n\tx = a.y * b.z - a.z * b.y;\n\ty = a.z * b.x - a.x * b.z;\n\tz = a.x * b.y - a.y * b.x;\n\n\treturn *this;\n}\n\nID_INLINE float idVec3_t::Length( void ) const {\n\tfloat length;\n\t\n\tlength = x * x + y * y + z * z;\n\treturn ( float )idSqrt( length );\n}\n\nID_INLINE float idVec3_t::Normalize( void ) {\n\tfloat length;\n\tfloat ilength;\n\n\tlength = this->Length();\n\tif ( length ) {\n\t\tilength = 1.0f / length;\n\t\tx *= ilength;\n\t\ty *= ilength;\n\t\tz *= ilength;\n\t}\n\t\t\n\treturn length;\n}\n\nID_INLINE void idVec3_t::Zero( void ) {\n\tx = 0.0f;\n\ty = 0.0f;\n\tz = 0.0f;\n}\n\nID_INLINE void idVec3_t::Snap( void ) {\n\tx = float( int( x ) );\n\ty = float( int( y ) );\n\tz = float( int( z ) );\n}\n\n/*\n======================\nSnapTowards\n\nRound a vector to integers for more efficient network\ntransmission, but make sure that it rounds towards a given point\nrather than blindly truncating.  This prevents it from truncating \ninto a wall.\n======================\n*/\nID_INLINE void idVec3_t::SnapTowards( const idVec3_t &to ) {\n\tif ( to.x <= x ) {\n\t\tx = float( int( x ) );\n\t} else {\n\t\tx = float( int( x ) + 1 );\n\t}\n\n\tif ( to.y <= y ) {\n\t\ty = float( int( y ) );\n\t} else {\n\t\ty = float( int( y ) + 1 );\n\t}\n\n\tif ( to.z <= z ) {\n\t\tz = float( int( z ) );\n\t} else {\n\t\tz = float( int( z ) + 1 );\n\t}\n}\n\n//===============================================================\n\nclass Bounds {\npublic:\n\tidVec3_t\tb[2];\n\n\t\t\tBounds();\n\t\t\tBounds( const idVec3_t &mins, const idVec3_t &maxs );\n\n\tvoid\tClear();\n\tvoid\tZero();\n\tfloat\tRadius();\t\t// radius from origin, not from center\n\tidVec3_t\tCenter();\n\tvoid\tAddPoint( const idVec3_t &v );\n\tvoid\tAddBounds( const Bounds &bb );\n\tbool\tIsCleared();\n\tbool\tContainsPoint( const idVec3_t &p );\n\tbool\tIntersectsBounds( const Bounds &b2 );\t// touching is NOT intersecting\n};\n\nextern Bounds\tboundsZero;\n\nID_INLINE Bounds::Bounds(){\n}\n\nID_INLINE bool Bounds::IsCleared() {\n\treturn b[0][0] > b[1][0];\n}\n\nID_INLINE bool Bounds::ContainsPoint( const idVec3_t &p ) {\n\tif ( p[0] < b[0][0] || p[1] < b[0][1] || p[2] < b[0][2]\n\t\t|| p[0] > b[1][0] || p[1] > b[1][1] || p[2] > b[1][2] ) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\nID_INLINE bool Bounds::IntersectsBounds( const Bounds &b2 ) {\n\tif ( b2.b[1][0] < b[0][0] || b2.b[1][1] < b[0][1] || b2.b[1][2] < b[0][2]\n\t\t|| b2.b[0][0] > b[1][0] || b2.b[0][1] > b[1][1] || b2.b[0][2] > b[1][2] ) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\nID_INLINE Bounds::Bounds( const idVec3_t &mins, const idVec3_t &maxs ) {\n\tb[0] = mins;\n\tb[1] = maxs;\n}\n\nID_INLINE idVec3_t Bounds::Center() {\n\treturn 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 );\n}\n\nID_INLINE void Bounds::Clear() {\n\tb[0][0] = b[0][1] = b[0][2] = 99999;\n\tb[1][0] = b[1][1] = b[1][2] = -99999;\n}\n\nID_INLINE void Bounds::Zero() {\n\tb[0][0] = b[0][1] = b[0][2] =\n\tb[1][0] = b[1][1] = b[1][2] = 0;\n}\n\nID_INLINE void Bounds::AddPoint( const idVec3_t &v ) {\n\tif ( v[0] < b[0][0]) {\n\t\tb[0][0] = v[0];\n\t}\n\tif ( v[0] > b[1][0]) {\n\t\tb[1][0] = v[0];\n\t}\n\tif ( v[1] < b[0][1] ) {\n\t\tb[0][1] = v[1];\n\t}\n\tif ( v[1] > b[1][1]) {\n\t\tb[1][1] = v[1];\n\t}\n\tif ( v[2] < b[0][2] ) {\n\t\tb[0][2] = v[2];\n\t}\n\tif ( v[2] > b[1][2]) {\n\t\tb[1][2] = v[2];\n\t}\n}\n\n\nID_INLINE void Bounds::AddBounds( const Bounds &bb ) {\n\tif ( bb.b[0][0] < b[0][0]) {\n\t\tb[0][0] = bb.b[0][0];\n\t}\n\tif ( bb.b[0][1] < b[0][1]) {\n\t\tb[0][1] = bb.b[0][1];\n\t}\n\tif ( bb.b[0][2] < b[0][2]) {\n\t\tb[0][2] = bb.b[0][2];\n\t}\n\n\tif ( bb.b[1][0] > b[1][0]) {\n\t\tb[1][0] = bb.b[1][0];\n\t}\n\tif ( bb.b[1][1] > b[1][1]) {\n\t\tb[1][1] = bb.b[1][1];\n\t}\n\tif ( bb.b[1][2] > b[1][2]) {\n\t\tb[1][2] = bb.b[1][2];\n\t}\n}\n\nID_INLINE float Bounds::Radius( ) {\n\tint\t\ti;\n\tfloat\ttotal;\n\tfloat\ta, aa;\n\n\ttotal = 0;\n\tfor (i=0 ; i<3 ; i++) {\n\t\ta = (float)fabs( b[0][i] );\n\t\taa = (float)fabs( b[1][i] );\n\t\tif ( aa > a ) {\n\t\t\ta = aa;\n\t\t}\n\t\ttotal += a * a;\n\t}\n\n\treturn (float)idSqrt( total );\n}\n\n//===============================================================\n\n\nclass idVec2_t {\npublic:\n\tfloat\t\t\tx;\n\tfloat\t\t\ty;\n\n\t\t\t\t\toperator float *();\n\tfloat\t\t\toperator[]( int index ) const;\n\tfloat\t\t\t&operator[]( int index );\n};\n\nID_INLINE float idVec2_t::operator[]( int index ) const {\n\treturn ( &x )[ index ];\n}\n\nID_INLINE float& idVec2_t::operator[]( int index ) {\n\treturn ( &x )[ index ];\n}\n\nID_INLINE idVec2_t::operator float *( void ) {\n\treturn &x;\n}\n\nclass vec4_t : public idVec3_t {\npublic:\n#ifndef\tFAT_VEC3\n\tfloat\t\t\tdist;\n#endif\n\tvec4_t();\n\t~vec4_t() {};\n\t\n\tvec4_t( float x, float y, float z, float dist );\n\tfloat\t\t\toperator[]( int index ) const;\n\tfloat\t\t\t&operator[]( int index );\n};\n\nID_INLINE vec4_t::vec4_t() {}\nID_INLINE vec4_t::vec4_t( float x, float y, float z, float dist ) {\n\tthis->x = x;\n\tthis->y = y;\n\tthis->z = z;\n\tthis->dist = dist;\n}\n\nID_INLINE float vec4_t::operator[]( int index ) const {\n\treturn ( &x )[ index ];\n}\n\nID_INLINE float& vec4_t::operator[]( int index ) {\n\treturn ( &x )[ index ];\n}\n\n\nclass idVec5_t : public idVec3_t {\npublic:\n\tfloat\t\t\ts;\n\tfloat\t\t\tt;\n\tfloat\t\t\toperator[]( int index ) const;\n\tfloat\t\t\t&operator[]( int index );\n};\n\n\nID_INLINE float idVec5_t::operator[]( int index ) const {\n\treturn ( &x )[ index ];\n}\n\nID_INLINE float& idVec5_t::operator[]( int index ) {\n\treturn ( &x )[ index ];\n}\n\n#endif /* !__MATH_VECTOR_H__ */\n"
  },
  {
    "path": "code/splines/q_parse.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// q_parse.c -- support for parsing text files\n\n#include \"q_shared.hpp\"\n\n/*\n============================================================================\n\nPARSING\n\n============================================================================\n*/\n\n// multiple character punctuation tokens\nstatic const char *punctuation[] = {\n\t\"+=\", \"-=\",  \"*=\",  \"/=\", \"&=\", \"|=\", \"++\", \"--\",\n\t\t\"&&\", \"||\",  \"<=\",  \">=\", \"==\", \"!=\",\n\tNULL\n};\n\ntypedef struct {\n\tchar\ttoken[MAX_TOKEN_CHARS];\n\tint\t\tlines;\n\tqboolean\tungetToken;\n\tchar\tparseFile[MAX_QPATH];\n} parseInfo_t;\n\n#define\tMAX_PARSE_INFO\t16\nstatic parseInfo_t\tparseInfo[MAX_PARSE_INFO];\nstatic int\t\t\tparseInfoNum;\nstatic parseInfo_t\t*pi = &parseInfo[0];\n\n/*\n===================\nCom_BeginParseSession\n===================\n*/\nvoid Com_BeginParseSession( const char *filename ) {\n\tif ( parseInfoNum == MAX_PARSE_INFO - 1 ) {\n\t\tCom_Error( ERR_FATAL, \"Com_BeginParseSession: session overflow\" );\n\t}\n\tparseInfoNum++;\n\tpi = &parseInfo[parseInfoNum];\n\n\tpi->lines = 1;\n\tQ_strncpyz( pi->parseFile, filename, sizeof( pi->parseFile ) );\n}\n\n/*\n===================\nCom_EndParseSession\n===================\n*/\nvoid Com_EndParseSession( void ) {\n\tif ( parseInfoNum == 0 ) {\n\t\tCom_Error( ERR_FATAL, \"Com_EndParseSession: session underflow\" );\n\t}\n\tparseInfoNum--;\n\tpi = &parseInfo[parseInfoNum];\n}\n\n/*\n===================\nCom_GetCurrentParseLine\n===================\n*/\nint Com_GetCurrentParseLine( void ) {\n\treturn pi->lines;\n}\n\n/*\n===================\nCom_ScriptError\n\nPrints the script name and line number in the message\n===================\n*/\nvoid Com_ScriptError( const char *msg, ... ) {\n\tva_list\t\targptr;\n\tchar\t\tstring[32000];\n\n\tva_start( argptr, msg );\n\tvsprintf( string, msg,argptr );\n\tva_end( argptr );\n\n\tCom_Error( ERR_DROP, \"File %s, line %i: %s\", pi->parseFile, pi->lines, string );\n}\n\nvoid Com_ScriptWarning( const char *msg, ... ) {\n\tva_list\t\targptr;\n\tchar\t\tstring[32000];\n\n\tva_start( argptr, msg );\n\tvsprintf( string, msg,argptr );\n\tva_end( argptr );\n\n\tCom_Printf( \"File %s, line %i: %s\", pi->parseFile, pi->lines, string );\n}\n\n\n/*\n===================\nCom_UngetToken\n\nCalling this will make the next Com_Parse return\nthe current token instead of advancing the pointer\n===================\n*/\nvoid Com_UngetToken( void ) {\n\tif ( pi->ungetToken ) {\n\t\tCom_ScriptError( \"UngetToken called twice\" );\n\t}\n\tpi->ungetToken = qtrue;\n}\n\n\nstatic const char *SkipWhitespace( const char (*data), qboolean *hasNewLines ) {\n\tint c;\n\n\twhile( (c = *data) <= ' ') {\n\t\tif( !c ) {\n\t\t\treturn NULL;\n\t\t}\n\t\tif( c == '\\n' ) {\n\t\t\tpi->lines++;\n\t\t\t*hasNewLines = qtrue;\n\t\t}\n\t\tdata++;\n\t}\n\n\treturn data;\n}\n\n/*\n==============\nCom_ParseExt\n\nParse a token out of a string\nWill never return NULL, just empty strings.\nAn empty string will only be returned at end of file.\n\nIf \"allowLineBreaks\" is qtrue then an empty\nstring will be returned if the next token is\na newline.\n==============\n*/\nstatic char *Com_ParseExt( const char *(*data_p), qboolean allowLineBreaks ) {\n\tint c = 0, len;\n\tqboolean hasNewLines = qfalse;\n\tconst char *data;\n\tconst char **punc;\n\n\tif ( !data_p ) {\n\t\tCom_Error( ERR_FATAL, \"Com_ParseExt: NULL data_p\" );\n\t}\n\n\tdata = *data_p;\n\tlen = 0;\n\tpi->token[0] = 0;\n\n\t// make sure incoming data is valid\n\tif ( !data ) {\n\t\t*data_p = NULL;\n\t\treturn pi->token;\n\t}\n\n\t// skip any leading whitespace\n\twhile ( 1 ) {\n\t\t// skip whitespace\n\t\tdata = SkipWhitespace( data, &hasNewLines );\n\t\tif ( !data ) {\n\t\t\t*data_p = NULL;\n\t\t\treturn pi->token;\n\t\t}\n\t\tif ( hasNewLines && !allowLineBreaks ) {\n\t\t\t*data_p = data;\n\t\t\treturn pi->token;\n\t\t}\n\n\t\tc = *data;\n\n\t\t// skip double slash comments\n\t\tif ( c == '/' && data[1] == '/' ) {\n\t\t\twhile (*data && *data != '\\n') {\n\t\t\t\tdata++;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// skip /* */ comments\n\t\tif ( c=='/' && data[1] == '*' ) {\n\t\t\twhile ( *data && ( *data != '*' || data[1] != '/' ) ) {\n\t\t\t\tif( *data == '\\n' ) {\n\t\t\t\t\tpi->lines++;\n\t\t\t\t}\n\t\t\t\tdata++;\n\t\t\t}\n\t\t\tif ( *data ) {\n\t\t\t\tdata += 2;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// a real token to parse\n\t\tbreak;\n\t}\n\n\t// handle quoted strings\n\tif ( c == '\\\"' ) {\n\t\tdata++;\n\t\twhile( 1 ) {\n\t\t\tc = *data++;\n\t\t\tif ( ( c=='\\\\' ) && ( *data == '\\\"' ) ) {\n\t\t\t\t// allow quoted strings to use \\\" to indicate the \" character\n\t\t\t\tdata++;\n\t\t\t} else if ( c=='\\\"' || !c ) {\n\t\t\t\tpi->token[len] = 0;\n\t\t\t\t*data_p = ( char * ) data;\n\t\t\t\treturn pi->token;\n\t\t\t} else if( *data == '\\n' ) {\n\t\t\t\tpi->lines++;\n\t\t\t}\n\t\t\tif ( len < MAX_TOKEN_CHARS - 1 ) {\n\t\t\t\tpi->token[len] = c;\n\t\t\t\tlen++;\n\t\t\t}\n\t\t}\n\t}\n\n\t// check for a number\n\t// is this parsing of negative numbers going to cause expression problems\n\tif ( ( c >= '0' && c <= '9' ) || ( c == '-' && data[ 1 ] >= '0' && data[ 1 ] <= '9' ) || \n\t\t( c == '.' && data[ 1 ] >= '0' && data[ 1 ] <= '9' ) ) {\n\t\tdo  {\n\n\t\t\tif (len < MAX_TOKEN_CHARS - 1) {\n\t\t\t\tpi->token[len] = c;\n\t\t\t\tlen++;\n\t\t\t}\n\t\t\tdata++;\n\n\t\t\tc = *data;\n\t\t} while ( ( c >= '0' && c <= '9' ) || c == '.' );\n\n\t\t// parse the exponent\n\t\tif ( c == 'e' || c == 'E' ) {\n\t\t\tif (len < MAX_TOKEN_CHARS - 1) {\n\t\t\t\tpi->token[len] = c;\n\t\t\t\tlen++;\n\t\t\t}\n\t\t\tdata++;\n\t\t\tc = *data;\n\n\t\t\tif ( c == '-' || c == '+' ) {\n\t\t\t\tif (len < MAX_TOKEN_CHARS - 1) {\n\t\t\t\t\tpi->token[len] = c;\n\t\t\t\t\tlen++;\n\t\t\t\t}\n\t\t\t\tdata++;\n\t\t\t\tc = *data;\n\t\t\t}\n\n\t\t\tdo  {\n\t\t\t\tif (len < MAX_TOKEN_CHARS - 1) {\n\t\t\t\t\tpi->token[len] = c;\n\t\t\t\t\tlen++;\n\t\t\t\t}\n\t\t\t\tdata++;\n\n\t\t\t\tc = *data;\n\t\t\t} while ( c >= '0' && c <= '9' );\n\t\t}\n\n\t\tif (len == MAX_TOKEN_CHARS) {\n\t\t\tlen = 0;\n\t\t}\n\t\tpi->token[len] = 0;\n\n\t\t*data_p = ( char * ) data;\n\t\treturn pi->token;\n   \t}\n\n\t// check for a regular word\n\t// we still allow forward and back slashes in name tokens for pathnames\n\t// and also colons for drive letters\n\tif ( ( c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z' ) || c == '_' || c == '/' || c == '\\\\' ) {\n\t\tdo  {\n\t\t\tif (len < MAX_TOKEN_CHARS - 1) {\n\t\t\t\tpi->token[len] = c;\n\t\t\t\tlen++;\n\t\t\t}\n\t\t\tdata++;\n\n\t\t\tc = *data;\n\t\t} while ( ( c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z' ) || c == '_' \n\t\t\t|| ( c >= '0' && c <= '9' ) || c == '/' || c == '\\\\' || c == ':' || c == '.' );\n\n\t\tif (len == MAX_TOKEN_CHARS) {\n\t\t\tlen = 0;\n\t\t}\n\t\tpi->token[len] = 0;\n\n\t\t*data_p = ( char * ) data;\n\t\treturn pi->token;\n\t}\n\n\t// check for multi-character punctuation token\n\tfor ( punc = punctuation ; *punc ; punc++ ) {\n\t\tint\t\tl;\n\t\tint\t\tj;\n\n\t\tl = strlen( *punc );\n\t\tfor ( j = 0 ; j < l ; j++ ) {\n\t\t\tif ( data[j] != (*punc)[j] ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif ( j == l ) {\n\t\t\t// a valid multi-character punctuation\n\t\t\tmemcpy( pi->token, *punc, l );\n\t\t\tpi->token[l] = 0;\n\t\t\tdata += l;\n\t\t\t*data_p = (char *)data;\n\t\t\treturn pi->token;\n\t\t}\n\t}\n\n\t// single character punctuation\n\tpi->token[0] = *data;\n\tpi->token[1] = 0;\n\tdata++;\n\t*data_p = (char *)data;\n\n\treturn pi->token;\n}\n\n/*\n===================\nCom_Parse\n===================\n*/\nconst char *Com_Parse( const char *(*data_p) ) {\n\tif ( pi->ungetToken ) {\n\t\tpi->ungetToken = qfalse;\n\t\treturn pi->token;\n\t}\n\treturn Com_ParseExt( data_p, qtrue );\n}\n\n/*\n===================\nCom_ParseOnLine\n===================\n*/\nconst char *Com_ParseOnLine( const char *(*data_p) ) {\n\tif ( pi->ungetToken ) {\n\t\tpi->ungetToken = qfalse;\n\t\treturn pi->token;\n\t}\n\treturn Com_ParseExt( data_p, qfalse );\n}\n\n\n\n/*\n==================\nCom_MatchToken\n==================\n*/\nvoid Com_MatchToken( const char *(*buf_p), const char *match, qboolean warning ) {\n\tconst char\t*token;\n\n\ttoken = Com_Parse( buf_p );\n\tif ( strcmp( token, match ) ) {\n\t\tif (warning) {\n\t\t\tCom_ScriptWarning( \"MatchToken: %s != %s\", token, match );\n\t\t} else {\n\t\t\tCom_ScriptError( \"MatchToken: %s != %s\", token, match );\n\t\t}\n\t}\n}\n\n\n/*\n=================\nCom_SkipBracedSection\n\nThe next token should be an open brace.\nSkips until a matching close brace is found.\nInternal brace depths are properly skipped.\n=================\n*/\nvoid Com_SkipBracedSection( const char *(*program) ) {\n\tconst char\t\t\t*token;\n\tint\t\t\t\tdepth;\n\n\tdepth = 0;\n\tdo {\n\t\ttoken = Com_Parse( program );\n\t\tif( token[1] == 0 ) {\n\t\t\tif( token[0] == '{' ) {\n\t\t\t\tdepth++;\n\t\t\t}\n\t\t\telse if( token[0] == '}' ) {\n\t\t\t\tdepth--;\n\t\t\t}\n\t\t}\n\t} while( depth && *program );\n}\n\n/*\n=================\nCom_SkipRestOfLine\n=================\n*/\nvoid Com_SkipRestOfLine ( const char *(*data) ) {\n\tconst char\t*p;\n\tint\t\tc;\n\n\tp = *data;\n\twhile ( (c = *p++) != 0 ) {\n\t\tif ( c == '\\n' ) {\n\t\t\tpi->lines++;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t*data = p;\n}\n\n/*\n====================\nCom_ParseRestOfLine\n====================\n*/\nconst char *Com_ParseRestOfLine( const char *(*data_p) ) {\n\tstatic char\tline[MAX_TOKEN_CHARS];\n\tconst char *token;\n\n\tline[0] = 0;\n\twhile( 1 ) {\n\t\ttoken = Com_ParseOnLine( data_p );\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( line[0] ) {\n\t\t\tQ_strcat( line, sizeof(line), \" \" );\n\t\t}\n\t\tQ_strcat( line, sizeof(line), token );\n\t}\n\n\treturn line;\n}\n\n\nfloat Com_ParseFloat( const char *(*buf_p) ) {\n\tconst char\t\t*token;\n\n\ttoken = Com_Parse( buf_p );\n\tif ( !token[0] ) {\n\t\treturn 0;\n\t}\n\treturn atof( token );\n}\n\nint Com_ParseInt( const char *(*buf_p) ) {\n\tconst char\t\t*token;\n\n\ttoken = Com_Parse( buf_p );\n\tif ( !token[0] ) {\n\t\treturn 0;\n\t}\n\treturn atoi( token );\n}\n\n\n\nvoid Com_Parse1DMatrix( const char *(*buf_p), int x, float *m ) {\n\tconst char\t*token;\n\tint\t\ti;\n\n\tCom_MatchToken( buf_p, \"(\" );\n\n\tfor (i = 0 ; i < x ; i++) {\n\t\ttoken = Com_Parse(buf_p);\n\t\tm[i] = atof(token);\n\t}\n\n\tCom_MatchToken( buf_p, \")\" );\n}\n\nvoid Com_Parse2DMatrix( const char *(*buf_p), int y, int x, float *m ) {\n\tint\t\ti;\n\n\tCom_MatchToken( buf_p, \"(\" );\n\n\tfor (i = 0 ; i < y ; i++) {\n\t\tCom_Parse1DMatrix (buf_p, x, m + i * x);\n\t}\n\n\tCom_MatchToken( buf_p, \")\" );\n}\n\nvoid Com_Parse3DMatrix( const char *(*buf_p), int z, int y, int x, float *m ) {\n\tint\t\ti;\n\n\tCom_MatchToken( buf_p, \"(\" );\n\n\tfor (i = 0 ; i < z ; i++) {\n\t\tCom_Parse2DMatrix (buf_p, y, x, m + i * x*y);\n\t}\n\n\tCom_MatchToken( buf_p, \")\" );\n}\n\n"
  },
  {
    "path": "code/splines/q_shared.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// q_shared.c -- stateless support routines that are included in each code dll\n#include \"q_shared.hpp\"\n\n/*\n============================================================================\n\nGROWLISTS\n\n============================================================================\n*/\n\n// malloc / free all in one place for debugging\nextern \"C\" void *Com_Allocate( int bytes );\nextern \"C\" void Com_Dealloc( void *ptr );\n\nvoid Com_InitGrowList( growList_t *list, int maxElements ) {\n\tlist->maxElements = maxElements;\n\tlist->currentElements = 0;\n\tlist->elements = (void **)Com_Allocate( list->maxElements * sizeof( void * ) );\n}\n\nint Com_AddToGrowList( growList_t *list, void *data ) {\n\tvoid\t**old;\n\n\tif ( list->currentElements != list->maxElements ) {\n\t\tlist->elements[list->currentElements] = data;\n\t\treturn list->currentElements++;\n\t}\n\n\t// grow, reallocate and move\n\told = list->elements;\n\n\tif ( list->maxElements < 0 ) {\n\t\tCom_Error( ERR_FATAL, \"Com_AddToGrowList: maxElements = %i\", list->maxElements );\n\t}\n\n\tif ( list->maxElements == 0 ) {\n\t\t// initialize the list to hold 100 elements\n\t\tCom_InitGrowList( list, 100 );\n\t\treturn Com_AddToGrowList( list, data );\n\t}\n\n\tlist->maxElements *= 2;\n\n\tCom_DPrintf( \"Resizing growlist to %i maxElements\\n\", list->maxElements );\n\n\tlist->elements = (void **)Com_Allocate( list->maxElements * sizeof( void * ) );\n\n\tif ( !list->elements ) {\n\t\tCom_Error( ERR_DROP, \"Growlist alloc failed\" );\n\t}\n\n\tmemcpy( list->elements, old, list->currentElements * sizeof( void * ) );\n\n\tCom_Dealloc( old );\n\n\treturn Com_AddToGrowList( list, data );\n}\n\nvoid *Com_GrowListElement( const growList_t *list, int index ) {\n\tif ( index < 0 || index >= list->currentElements ) {\n\t\tCom_Error( ERR_DROP, \"Com_GrowListElement: %i out of range of %i\", \n\t\t\tindex, list->currentElements );\n\t}\n\treturn list->elements[index];\n}\n\nint Com_IndexForGrowListElement( const growList_t *list, const void *element ) {\n\tint\t\ti;\n\n\tfor ( i = 0 ; i < list->currentElements ; i++ ) {\n\t\tif ( list->elements[i] == element ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n//============================================================================\n\n\nfloat Com_Clamp( float min, float max, float value ) {\n\tif ( value < min ) {\n\t\treturn min;\n\t}\n\tif ( value > max ) {\n\t\treturn max;\n\t}\n\treturn value;\n}\n\n/*\n============\nCom_StringContains\n============\n*/\nconst char *Com_StringContains( const char *str1, const char *str2, int casesensitive) {\n\tint len, i, j;\n\n\tlen = strlen(str1) - strlen(str2);\n\tfor (i = 0; i <= len; i++, str1++) {\n\t\tfor (j = 0; str2[j]; j++) {\n\t\t\tif (casesensitive) {\n\t\t\t\tif (str1[j] != str2[j]) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (toupper(str1[j]) != toupper(str2[j])) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!str2[j]) {\n\t\t\treturn str1;\n\t\t}\n\t}\n\treturn NULL;\n}\n\n/*\n============\nCom_Filter\n============\n*/\nint Com_Filter( const char *filter, const char *name, int casesensitive)\n{\n\tchar buf[MAX_TOKEN_CHARS];\n\tconst char *ptr;\n\tint i, found;\n\n\twhile(*filter) {\n\t\tif (*filter == '*') {\n\t\t\tfilter++;\n\t\t\tfor (i = 0; *filter; i++) {\n\t\t\t\tif (*filter == '*' || *filter == '?') break;\n\t\t\t\tbuf[i] = *filter;\n\t\t\t\tfilter++;\n\t\t\t}\n\t\t\tbuf[i] = '\\0';\n\t\t\tif (strlen(buf)) {\n\t\t\t\tptr = Com_StringContains(name, buf, casesensitive);\n\t\t\t\tif (!ptr) return qfalse;\n\t\t\t\tname = ptr + strlen(buf);\n\t\t\t}\n\t\t}\n\t\telse if (*filter == '?') {\n\t\t\tfilter++;\n\t\t\tname++;\n\t\t}\n\t\telse if (*filter == '[' && *(filter+1) == '[') {\n\t\t\tfilter++;\n\t\t}\n\t\telse if (*filter == '[') {\n\t\t\tfilter++;\n\t\t\tfound = qfalse;\n\t\t\twhile(*filter && !found) {\n\t\t\t\tif (*filter == ']' && *(filter+1) != ']') break;\n\t\t\t\tif (*(filter+1) == '-' && *(filter+2) && (*(filter+2) != ']' || *(filter+3) == ']')) {\n\t\t\t\t\tif (casesensitive) {\n\t\t\t\t\t\tif (*name >= *filter && *name <= *(filter+2)) found = qtrue;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (toupper(*name) >= toupper(*filter) &&\n\t\t\t\t\t\t\ttoupper(*name) <= toupper(*(filter+2))) found = qtrue;\n\t\t\t\t\t}\n\t\t\t\t\tfilter += 3;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (casesensitive) {\n\t\t\t\t\t\tif (*filter == *name) found = qtrue;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (toupper(*filter) == toupper(*name)) found = qtrue;\n\t\t\t\t\t}\n\t\t\t\t\tfilter++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!found) return qfalse;\n\t\t\twhile(*filter) {\n\t\t\t\tif (*filter == ']' && *(filter+1) != ']') break;\n\t\t\t\tfilter++;\n\t\t\t}\n\t\t\tfilter++;\n\t\t\tname++;\n\t\t}\n\t\telse {\n\t\t\tif (casesensitive) {\n\t\t\t\tif (*filter != *name) return qfalse;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (toupper(*filter) != toupper(*name)) return qfalse;\n\t\t\t}\n\t\t\tfilter++;\n\t\t\tname++;\n\t\t}\n\t}\n\treturn qtrue;\n}\n\n\n/*\n================\nCom_HashString\n\n================\n*/\nint Com_HashString( const char *fname ) {\n\tint\t\ti;\n\tlong\thash;\n\tchar\tletter;\n\n\thash = 0;\n\ti = 0;\n\twhile (fname[i] != '\\0') {\n\t\tletter = tolower(fname[i]);\n\t\tif (letter =='.') break;\t\t\t\t// don't include extension\n\t\tif (letter =='\\\\') letter = '/';\t\t// damn path names\n\t\thash+=(long)(letter)*(i+119);\n\t\ti++;\n\t}\n\thash &= (FILE_HASH_SIZE-1);\n\treturn hash;\n}\n\n\n/*\n============\nCom_SkipPath\n============\n*/\nchar *Com_SkipPath (char *pathname)\n{\n\tchar\t*last;\n\t\n\tlast = pathname;\n\twhile (*pathname)\n\t{\n\t\tif (*pathname=='/')\n\t\t\tlast = pathname+1;\n\t\tpathname++;\n\t}\n\treturn last;\n}\n\n/*\n============\nCom_StripExtension\n============\n*/\nvoid Com_StripExtension( const char *in, char *out ) {\n\twhile ( *in && *in != '.' ) {\n\t\t*out++ = *in++;\n\t}\n\t*out = 0;\n}\n\n\n/*\n==================\nCom_DefaultExtension\n==================\n*/\nvoid Com_DefaultExtension (char *path, int maxSize, const char *extension ) {\n\tchar\toldPath[MAX_QPATH];\n\tchar    *src;\n\n//\n// if path doesn't have a .EXT, append extension\n// (extension should include the .)\n//\n\tsrc = path + strlen(path) - 1;\n\n\twhile (*src != '/' && src != path) {\n\t\tif ( *src == '.' ) {\n\t\t\treturn;                 // it has an extension\n\t\t}\n\t\tsrc--;\n\t}\n\n\tQ_strncpyz( oldPath, path, sizeof( oldPath ) );\n\tCom_sprintf( path, maxSize, \"%s%s\", oldPath, extension );\n}\n\n/*\n============================================================================\n\n\t\t\t\t\tBYTE ORDER FUNCTIONS\n\n============================================================================\n*/\n\n// can't just use function pointers, or dll linkage can\n// mess up when qcommon is included in multiple places\nstatic short\t(*_BigShort) (short l);\nstatic short\t(*_LittleShort) (short l);\nstatic int\t\t(*_BigLong) (int l);\nstatic int\t\t(*_LittleLong) (int l);\nstatic float\t(*_BigFloat) (float l);\nstatic float\t(*_LittleFloat) (float l);\n\nshort\tBigShort(short l){return _BigShort(l);}\nshort\tLittleShort(short l) {return _LittleShort(l);}\nint\t\tBigLong (int l) {return _BigLong(l);}\nint\t\tLittleLong (int l) {return _LittleLong(l);}\nfloat\tBigFloat (float l) {return _BigFloat(l);}\nfloat\tLittleFloat (float l) {return _LittleFloat(l);}\n\nshort   ShortSwap (short l)\n{\n\tbyte    b1,b2;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\n\treturn (b1<<8) + b2;\n}\n\nshort\tShortNoSwap (short l)\n{\n\treturn l;\n}\n\nint    LongSwap (int l)\n{\n\tbyte    b1,b2,b3,b4;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\tb3 = (l>>16)&255;\n\tb4 = (l>>24)&255;\n\n\treturn ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;\n}\n\nint\tLongNoSwap (int l)\n{\n\treturn l;\n}\n\nfloat FloatSwap (float f)\n{\n\tunion\n\t{\n\t\tfloat\tf;\n\t\tbyte\tb[4];\n\t} dat1, dat2;\n\t\n\t\n\tdat1.f = f;\n\tdat2.b[0] = dat1.b[3];\n\tdat2.b[1] = dat1.b[2];\n\tdat2.b[2] = dat1.b[1];\n\tdat2.b[3] = dat1.b[0];\n\treturn dat2.f;\n}\n\nfloat FloatNoSwap (float f)\n{\n\treturn f;\n}\n\n/*\n================\nSwap_Init\n================\n*/\nvoid Swap_Init (void)\n{\n\tbyte\tswaptest[2] = {1,0};\n\n// set the byte swapping variables in a portable manner\t\n\tif ( *(short *)swaptest == 1)\n\t{\n\t\t_BigShort = ShortSwap;\n\t\t_LittleShort = ShortNoSwap;\n\t\t_BigLong = LongSwap;\n\t\t_LittleLong = LongNoSwap;\n\t\t_BigFloat = FloatSwap;\n\t\t_LittleFloat = FloatNoSwap;\n\t}\n\telse\n\t{\n\t\t_BigShort = ShortNoSwap;\n\t\t_LittleShort = ShortSwap;\n\t\t_BigLong = LongNoSwap;\n\t\t_LittleLong = LongSwap;\n\t\t_BigFloat = FloatNoSwap;\n\t\t_LittleFloat = FloatSwap;\n\t}\n\n}\n\n/*\n===============\nCom_ParseInfos\n===============\n*/\nint Com_ParseInfos( const char *buf, int max, char infos[][MAX_INFO_STRING] ) {\n\tconst char\t*token;\n\tint\t\tcount;\n\tchar\tkey[MAX_TOKEN_CHARS];\n\n\tcount = 0;\n\n\twhile ( 1 ) {\n\t\ttoken = Com_Parse( &buf );\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( strcmp( token, \"{\" ) ) {\n\t\t\tCom_Printf( \"Missing { in info file\\n\" );\n\t\t\tbreak;\n\t\t}\n\n\t\tif ( count == max ) {\n\t\t\tCom_Printf( \"Max infos exceeded\\n\" );\n\t\t\tbreak;\n\t\t}\n\n\t\tinfos[count][0] = 0;\n\t\twhile ( 1 ) {\n\t\t\ttoken = Com_Parse( &buf );\n\t\t\tif ( !token[0] ) {\n\t\t\t\tCom_Printf( \"Unexpected end of info file\\n\" );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( !strcmp( token, \"}\" ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tQ_strncpyz( key, token, sizeof( key ) );\n\n\t\t\ttoken = Com_ParseOnLine( &buf );\n\t\t\tif ( !token[0] ) {\n\t\t\t\ttoken = \"<NULL>\";\n\t\t\t}\n\t\t\tInfo_SetValueForKey( infos[count], key, token );\n\t\t}\n\t\tcount++;\n\t}\n\n\treturn count;\n}\n\n\n\n/*\n============================================================================\n\n\t\t\t\t\tLIBRARY REPLACEMENT FUNCTIONS\n\n============================================================================\n*/\n\nint Q_isprint( int c )\n{\n\tif ( c >= 0x20 && c <= 0x7E )\n\t\treturn ( 1 );\n\treturn ( 0 );\n}\n\nint Q_islower( int c )\n{\n\tif (c >= 'a' && c <= 'z')\n\t\treturn ( 1 );\n\treturn ( 0 );\n}\n\nint Q_isupper( int c )\n{\n\tif (c >= 'A' && c <= 'Z')\n\t\treturn ( 1 );\n\treturn ( 0 );\n}\n\nint Q_isalpha( int c )\n{\n\tif ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))\n\t\treturn ( 1 );\n\treturn ( 0 );\n}\n\nchar* Q_strrchr( const char* string, int c )\n{\n\tchar cc = c;\n\tchar *s;\n\tchar *sp=(char *)0;\n\n\ts = (char*)string;\n\n\twhile (*s)\n\t{\n\t\tif (*s == cc)\n\t\t\tsp = s;\n\t\ts++;\n\t}\n\tif (cc == 0)\n\t\tsp = s;\n\n\treturn sp;\n}\n\n/*\n=============\nQ_strncpyz\n \nSafe strncpy that ensures a trailing zero\n=============\n*/\nvoid Q_strncpyz( char *dest, const char *src, int destsize ) {\n\tif ( !src ) {\n\t\tCom_Error( ERR_FATAL, \"Q_strncpyz: NULL src\" );\n\t}\n\tif ( destsize < 1 ) {\n\t\tCom_Error(ERR_FATAL,\"Q_strncpyz: destsize < 1\" ); \n\t}\n\n\tstrncpy( dest, src, destsize-1 );\n    dest[destsize-1] = 0;\n}\n                 \nint Q_stricmpn (const char *s1, const char *s2, int n) {\n\tint\t\tc1, c2;\n\t\n\tdo {\n\t\tc1 = *s1++;\n\t\tc2 = *s2++;\n\n\t\tif (!n--) {\n\t\t\treturn 0;\t\t// strings are equal until end point\n\t\t}\n\t\t\n\t\tif (c1 != c2) {\n\t\t\tif (c1 >= 'a' && c1 <= 'z') {\n\t\t\t\tc1 -= ('a' - 'A');\n\t\t\t}\n\t\t\tif (c2 >= 'a' && c2 <= 'z') {\n\t\t\t\tc2 -= ('a' - 'A');\n\t\t\t}\n\t\t\tif (c1 != c2) {\n\t\t\t\treturn c1 < c2 ? -1 : 1;\n\t\t\t}\n\t\t}\n\t} while (c1);\n\t\n\treturn 0;\t\t// strings are equal\n}\n\nint Q_strncmp (const char *s1, const char *s2, int n) {\n\tint\t\tc1, c2;\n\t\n\tdo {\n\t\tc1 = *s1++;\n\t\tc2 = *s2++;\n\n\t\tif (!n--) {\n\t\t\treturn 0;\t\t// strings are equal until end point\n\t\t}\n\t\t\n\t\tif (c1 != c2) {\n\t\t\treturn c1 < c2 ? -1 : 1;\n\t\t}\n\t} while (c1);\n\t\n\treturn 0;\t\t// strings are equal\n}\n\nint Q_stricmp (const char *s1, const char *s2) {\n\treturn Q_stricmpn (s1, s2, 99999);\n}\n\n\nchar *Q_strlwr( char *s1 ) {\n    char\t*s;\n\n    s = s1;\n\twhile ( *s ) {\n\t\t*s = tolower(*s);\n\t\ts++;\n\t}\n    return s1;\n}\n\nchar *Q_strupr( char *s1 ) {\n    char\t*s;\n\n    s = s1;\n\twhile ( *s ) {\n\t\t*s = toupper(*s);\n\t\ts++;\n\t}\n    return s1;\n}\n\n\n// never goes past bounds or leaves without a terminating 0\nvoid Q_strcat( char *dest, int size, const char *src ) {\n\tint\t\tl1;\n\n\tl1 = strlen( dest );\n\tif ( l1 >= size ) {\n\t\tCom_Error( ERR_FATAL, \"Q_strcat: already overflowed\" );\n\t}\n\tQ_strncpyz( dest + l1, src, size - l1 );\n}\n\n\nint Q_PrintStrlen( const char *string ) {\n\tint\t\t\tlen;\n\tconst char\t*p;\n\n\tif( !string ) {\n\t\treturn 0;\n\t}\n\n\tlen = 0;\n\tp = string;\n\twhile( *p ) {\n\t\tif( Q_IsColorString( p ) ) {\n\t\t\tp += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tp++;\n\t\tlen++;\n\t}\n\n\treturn len;\n}\n\n\nchar *Q_CleanStr( char *string ) {\n\tchar*\td;\n\tchar*\ts;\n\tint\t\tc;\n\n\ts = string;\n\td = string;\n\twhile ((c = *s) != 0 ) {\n\t\tif ( Q_IsColorString( s ) ) {\n\t\t\ts++;\n\t\t}\t\t\n\t\telse if ( c >= 0x20 && c <= 0x7E ) {\n\t\t\t*d++ = c;\n\t\t}\n\t\ts++;\n\t}\n\t*d = '\\0';\n\n\treturn string;\n}\n\n\nvoid QDECL Com_sprintf( char *dest, int size, const char *fmt, ...) {\n\tint\t\tlen;\n\tva_list\t\targptr;\n\tchar\tbigbuffer[32000];\t// big, but small enough to fit in PPC stack\n\n\tva_start (argptr,fmt);\n\tlen = vsprintf (bigbuffer,fmt,argptr);\n\tva_end (argptr);\n\tif ( len >= sizeof( bigbuffer ) ) {\n\t\tCom_Error( ERR_FATAL, \"Com_sprintf: overflowed bigbuffer\" );\n\t}\n\tif (len >= size) {\n\t\tCom_Printf (\"Com_sprintf: overflow of %i in %i\\n\", len, size);\n\t}\n\tQ_strncpyz (dest, bigbuffer, size );\n}\n\n\n/*\n============\nva\n\ndoes a varargs printf into a temp buffer, so I don't need to have\nvarargs versions of all text functions.\nFIXME: make this buffer size safe someday\n============\n*/\nchar\t* QDECL va( char *format, ... ) {\n\tva_list\t\targptr;\n\tstatic char\t\tstring[2][32000];\t// in case va is called by nested functions\n\tstatic int\t\tindex = 0;\n\tchar\t*buf;\n\n\tbuf = string[index & 1];\n\tindex++;\n\n\tva_start (argptr, format);\n\tvsprintf (buf, format,argptr);\n\tva_end (argptr);\n\n\treturn buf;\n}\n\n\n/*\n=====================================================================\n\n  INFO STRINGS\n\n=====================================================================\n*/\n\n/*\n===============\nInfo_ValueForKey\n\nSearches the string for the given\nkey and returns the associated value, or an empty string.\nFIXME: overflow check?\n===============\n*/\nchar *Info_ValueForKey( const char *s, const char *key ) {\n\tchar\tpkey[MAX_INFO_KEY];\n\tstatic\tchar value[2][MAX_INFO_VALUE];\t// use two buffers so compares\n\t\t\t\t\t\t\t\t\t\t\t// work without stomping on each other\n\tstatic\tint\tvalueindex = 0;\n\tchar\t*o;\n\t\n\tif ( !s || !key ) {\n\t\treturn \"\";\n\t}\n\n\tif ( strlen( s ) >= MAX_INFO_STRING ) {\n\t\tCom_Error( ERR_DROP, \"Info_ValueForKey: oversize infostring\" );\n\t}\n\n\tvalueindex ^= 1;\n\tif (*s == '\\\\')\n\t\ts++;\n\twhile (1)\n\t{\n\t\to = pkey;\n\t\twhile (*s != '\\\\')\n\t\t{\n\t\t\tif (!*s)\n\t\t\t\treturn \"\";\n\t\t\t*o++ = *s++;\n\t\t}\n\t\t*o = 0;\n\t\ts++;\n\n\t\to = value[valueindex];\n\n\t\twhile (*s != '\\\\' && *s)\n\t\t{\n\t\t\t*o++ = *s++;\n\t\t}\n\t\t*o = 0;\n\n\t\tif (!Q_stricmp (key, pkey) )\n\t\t\treturn value[valueindex];\n\n\t\tif (!*s)\n\t\t\tbreak;\n\t\ts++;\n\t}\n\n\treturn \"\";\n}\n\n\n/*\n===================\nInfo_NextPair\n\nUsed to itterate through all the key/value pairs in an info string\n===================\n*/\nvoid Info_NextPair( const char *(*head), char key[MAX_INFO_KEY], char value[MAX_INFO_VALUE] ) {\n\tchar\t*o;\n\tconst char\t*s;\n\n\ts = *head;\n\n\tif ( *s == '\\\\' ) {\n\t\ts++;\n\t}\n\tkey[0] = 0;\n\tvalue[0] = 0;\n\n\to = key;\n\twhile ( *s != '\\\\' ) {\n\t\tif ( !*s ) {\n\t\t\t*o = 0;\n\t\t\t*head = s;\n\t\t\treturn;\n\t\t}\n\t\t*o++ = *s++;\n\t}\n\t*o = 0;\n\ts++;\n\n\to = value;\n\twhile ( *s != '\\\\' && *s ) {\n\t\t*o++ = *s++;\n\t}\n\t*o = 0;\n\n\t*head = s;\n}\n\n\n/*\n===================\nInfo_RemoveKey\n===================\n*/\nvoid Info_RemoveKey( char *s, const char *key ) {\n\tchar\t*start;\n\tchar\tpkey[MAX_INFO_KEY];\n\tchar\tvalue[MAX_INFO_VALUE];\n\tchar\t*o;\n\n\tif ( strlen( s ) >= MAX_INFO_STRING ) {\n\t\tCom_Error( ERR_DROP, \"Info_RemoveKey: oversize infostring\" );\n\t}\n\n\tif (strchr (key, '\\\\')) {\n\t\treturn;\n\t}\n\n\twhile (1)\n\t{\n\t\tstart = s;\n\t\tif (*s == '\\\\')\n\t\t\ts++;\n\t\to = pkey;\n\t\twhile (*s != '\\\\')\n\t\t{\n\t\t\tif (!*s)\n\t\t\t\treturn;\n\t\t\t*o++ = *s++;\n\t\t}\n\t\t*o = 0;\n\t\ts++;\n\n\t\to = value;\n\t\twhile (*s != '\\\\' && *s)\n\t\t{\n\t\t\tif (!*s)\n\t\t\t\treturn;\n\t\t\t*o++ = *s++;\n\t\t}\n\t\t*o = 0;\n\n\t\tif (!strcmp (key, pkey) )\n\t\t{\n\t\t\tstrcpy (start, s);\t// remove this part\n\t\t\treturn;\n\t\t}\n\n\t\tif (!*s)\n\t\t\treturn;\n\t}\n\n}\n\n\n/*\n==================\nInfo_Validate\n\nSome characters are illegal in info strings because they\ncan mess up the server's parsing\n==================\n*/\nqboolean Info_Validate( const char *s ) {\n\tif ( strchr( s, '\\\"' ) ) {\n\t\treturn qfalse;\n\t}\n\tif ( strchr( s, ';' ) ) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n/*\n==================\nInfo_SetValueForKey\n\nChanges or adds a key/value pair\n==================\n*/\nvoid Info_SetValueForKey( char *s, const char *key, const char *value ) {\n\tchar\tnewi[MAX_INFO_STRING];\n\n\tif ( strlen( s ) >= MAX_INFO_STRING ) {\n\t\tCom_Error( ERR_DROP, \"Info_SetValueForKey: oversize infostring\" );\n\t}\n\n\tif (strchr (key, '\\\\') || strchr (value, '\\\\'))\n\t{\n\t\tCom_Printf (\"Can't use keys or values with a \\\\\\n\");\n\t\treturn;\n\t}\n\n\tif (strchr (key, ';') || strchr (value, ';'))\n\t{\n\t\tCom_Printf (\"Can't use keys or values with a semicolon\\n\");\n\t\treturn;\n\t}\n\n\tif (strchr (key, '\\\"') || strchr (value, '\\\"'))\n\t{\n\t\tCom_Printf (\"Can't use keys or values with a \\\"\\n\");\n\t\treturn;\n\t}\n\n\tInfo_RemoveKey (s, key);\n\tif (!value || !strlen(value))\n\t\treturn;\n\n\tCom_sprintf (newi, sizeof(newi), \"\\\\%s\\\\%s\", key, value);\n\n\tif (strlen(newi) + strlen(s) > MAX_INFO_STRING)\n\t{\n\t\tCom_Printf (\"Info string length exceeded\\n\");\n\t\treturn;\n\t}\n\n\tstrcat (s, newi);\n}\n\n//====================================================================\n\n\n/*\n===============\nParseHex\n===============\n*/\nint\tParseHex( const char *text ) {\n\tint\t\tvalue;\n\tint\t\tc;\n\n\tvalue = 0;\n\twhile ( ( c = *text++ ) != 0 ) {\n\t\tif ( c >= '0' && c <= '9' ) {\n\t\t\tvalue = value * 16 + c - '0';\n\t\t\tcontinue;\n\t\t}\n\t\tif ( c >= 'a' && c <= 'f' ) {\n\t\t\tvalue = value * 16 + 10 + c - 'a';\n\t\t\tcontinue;\n\t\t}\n\t\tif ( c >= 'A' && c <= 'F' ) {\n\t\t\tvalue = value * 16 + 10 + c - 'A';\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\treturn value;\n}\n"
  },
  {
    "path": "code/splines/q_shared.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __Q_SHARED_H\n#define __Q_SHARED_H\n\n// q_shared.h -- included first by ALL program modules.\n// these are the definitions that have no dependance on\n// central system services, and can be used by any part\n// of the program without any state issues.\n\n// A user mod should never modify this file\n\n// incursion of DOOM code into the Q3A codebase\n//#define\tQ3_VERSION\t\t\"DOOM 0.01\"\n\n// alignment macros for SIMD\n#define\tALIGN_ON\n#define\tALIGN_OFF\n\n#ifdef _WIN32\n\n#pragma warning(disable : 4018)     // signed/unsigned mismatch\n#pragma warning(disable : 4032)\n#pragma warning(disable : 4051)\n#pragma warning(disable : 4057)\t\t// slightly different base types\n#pragma warning(disable : 4100)\t\t// unreferenced formal parameter\n#pragma warning(disable : 4115)\n#pragma warning(disable : 4125)\t\t// decimal digit terminates octal escape sequence\n#pragma warning(disable : 4127)\t\t// conditional expression is constant\n#pragma warning(disable : 4136)\n#pragma warning(disable : 4201)\n#pragma warning(disable : 4214)\n#pragma warning(disable : 4244)\n#pragma warning(disable : 4305)\t\t// truncation from const double to float\n#pragma warning(disable : 4310)\t\t// cast truncates constant value\n#pragma warning(disable : 4514)\n#pragma warning(disable : 4711)\t\t// selected for automatic inline expansion\n#pragma warning(disable : 4220)\t\t// varargs matches remaining parameters\n\n#endif\n\n#include <assert.h>\n#include <math.h>\n#include <stdio.h>\n#include <stdarg.h>\n#include <string.h>\n#include <stdlib.h>\n#include <time.h>\n#include <ctype.h>\n#ifdef WIN32\t\t\t\t// mac doesn't have malloc.h\n#include <malloc.h>\t\t\t// for _alloca()\n#endif\n#ifdef _WIN32\n\n//#pragma intrinsic( memset, memcpy )\n\n#endif\n\n\n// this is the define for determining if we have an asm version of a C function\n#if (defined _M_IX86 || defined __i386__) && !defined __sun__  && !defined __LCC__\n#define id386\t1\n#else\n#define id386\t0\n#endif\n\n// for windows fastcall option\n\n#define\tQDECL\n\n//======================= WIN32 DEFINES =================================\n\n#ifdef WIN32\n\n#define\tMAC_STATIC\n\n#undef QDECL\n#define\tQDECL\t__cdecl\n\n// buildstring will be incorporated into the version string\n#ifdef NDEBUG\n#ifdef _M_IX86\n#define\tCPUSTRING\t\"win-x86\"\n#elif defined _M_ALPHA\n#define\tCPUSTRING\t\"win-AXP\"\n#endif\n#else\n#ifdef _M_IX86\n#define\tCPUSTRING\t\"win-x86-debug\"\n#elif defined _M_ALPHA\n#define\tCPUSTRING\t\"win-AXP-debug\"\n#endif\n#endif\n\n\n#define\tPATH_SEP '\\\\'\n\n#endif\n\n//======================= MAC OS X SERVER DEFINES =====================\n\n#if defined(__MACH__) && defined(__APPLE__)\n\n#define MAC_STATIC\n\n#ifdef __ppc__\n#define CPUSTRING\t\"MacOSXS-ppc\"\n#elif defined __i386__\n#define CPUSTRING\t\"MacOSXS-i386\"\n#else\n#define CPUSTRING\t\"MacOSXS-other\"\n#endif\n\n#define\tPATH_SEP\t'/'\n\n#define\tGAME_HARD_LINKED\n#define\tCGAME_HARD_LINKED\n#define\tUI_HARD_LINKED\n#define _alloca alloca\n\n#undef ALIGN_ON\n#undef ALIGN_OFF\n#define\tALIGN_ON\t\t#pragma align(16)\n#define\tALIGN_OFF\t\t#pragma align()\n\n#ifdef __cplusplus\n\textern \"C\" {\n#endif\n\nvoid *osxAllocateMemory(long size);\nvoid osxFreeMemory(void *pointer);\n\n#ifdef __cplusplus\n        }\n#endif\n\n#endif\n\n//======================= MAC DEFINES =================================\n\n#ifdef __MACOS__\n\n#define\tMAC_STATIC static\n\n#define\tCPUSTRING\t\"MacOS-PPC\"\n\n#define\tPATH_SEP ':'\n\nvoid Sys_PumpEvents( void );\n\n#endif\n\n#ifdef __MRC__\n\n#define\tMAC_STATIC\n\n#define\tCPUSTRING\t\"MacOS-PPC\"\n\n#define\tPATH_SEP ':'\n\nvoid Sys_PumpEvents( void );\n\n#undef QDECL\n#define\tQDECL\t__cdecl\n\n#define _alloca alloca\n#endif\n\n//======================= LINUX DEFINES =================================\n\n// the mac compiler can't handle >32k of locals, so we\n// just waste space and make big arrays static...\n#ifdef __linux__\n\n// bk001205 - from Makefile\n#define stricmp strcasecmp\n\n#define\tMAC_STATIC // bk: FIXME\n\n#ifdef __i386__\n#define\tCPUSTRING\t\"linux-i386\"\n#elif defined __axp__\n#define\tCPUSTRING\t\"linux-alpha\"\n#else\n#define\tCPUSTRING\t\"linux-other\"\n#endif\n\n#define\tPATH_SEP '/'\n\n// bk001205 - try\n#ifdef Q3_STATIC\n#define\tGAME_HARD_LINKED\n#define\tCGAME_HARD_LINKED\n#define\tUI_HARD_LINKED\n#define\tBOTLIB_HARD_LINKED\n#endif\n\n#endif\n\n//=============================================================\n\n\n  \ntypedef enum {qfalse, qtrue}\tqboolean;\n\ntypedef unsigned char \t\tbyte;\n\n#define\tEQUAL_EPSILON\t0.001\n\ntypedef int\t\tqhandle_t;\ntypedef int\t\tsfxHandle_t;\ntypedef int\t\tfileHandle_t;\ntypedef int\t\tclipHandle_t;\n\ntypedef enum {\n\tINVALID_JOINT = -1\n} jointHandle_t;\n\n#ifndef NULL\n#define NULL ((void *)0)\n#endif\n\n#define\tMAX_QINT\t\t\t0x7fffffff\n#define\tMIN_QINT\t\t\t(-MAX_QINT-1)\n\n#ifndef max\n#define max( x, y ) ( ( ( x ) > ( y ) ) ? ( x ) : ( y ) )\n#define min( x, y ) ( ( ( x ) < ( y ) ) ? ( x ) : ( y ) )\n#endif\n\n#ifndef sign\n#define sign( f )\t( ( f > 0 ) ? 1 : ( ( f < 0 ) ? -1 : 0 ) )\n#endif\n\n// angle indexes\n#define\tPITCH\t\t\t\t0\t\t// up / down\n#define\tYAW\t\t\t\t\t1\t\t// left / right\n#define\tROLL\t\t\t\t2\t\t// fall over\n\n// the game guarantees that no string from the network will ever\n// exceed MAX_STRING_CHARS\n#define\tMAX_STRING_CHARS\t1024\t// max length of a string passed to Cmd_TokenizeString\n#define\tMAX_STRING_TOKENS\t256\t\t// max tokens resulting from Cmd_TokenizeString\n#define\tMAX_TOKEN_CHARS\t\t1024\t// max length of an individual token\n\n#define\tMAX_INFO_STRING\t\t1024\n#define\tMAX_INFO_KEY\t\t1024\n#define\tMAX_INFO_VALUE\t\t1024\n\n\n#define\tMAX_QPATH\t\t\t64\t\t// max length of a quake game pathname\n#define\tMAX_OSPATH\t\t\t128\t\t// max length of a filesystem pathname\n\n#define\tMAX_NAME_LENGTH\t\t32\t\t// max length of a client name\n\n// paramters for command buffer stuffing\ntypedef enum {\n\tEXEC_NOW,\t\t\t// don't return until completed, a VM should NEVER use this,\n\t\t\t\t\t\t// because some commands might cause the VM to be unloaded...\n\tEXEC_INSERT,\t\t// insert at current position, but don't run yet\n\tEXEC_APPEND\t\t\t// add to end of the command buffer (normal case)\n} cbufExec_t;\n\n\n//\n// these aren't needed by any of the VMs.  put in another header?\n//\n#define\tMAX_MAP_AREA_BYTES\t\t32\t\t// bit vector of area visibility\n\n#undef ERR_FATAL\t\t\t\t\t\t// malloc.h on unix\n\n// parameters to the main Error routine\ntypedef enum {\n\tERR_NONE,\n\tERR_FATAL,\t\t\t\t\t// exit the entire game with a popup window\n\tERR_DROP,\t\t\t\t\t// print to console and disconnect from game\n\tERR_DISCONNECT,\t\t\t\t// don't kill server\n\tERR_NEED_CD\t\t\t\t\t// pop up the need-cd dialog\n} errorParm_t;\n\n\n// font rendering values used by ui and cgame\n\n#define PROP_GAP_WIDTH\t\t\t3\n#define PROP_SPACE_WIDTH\t\t8\n#define PROP_HEIGHT\t\t\t\t27\n#define PROP_SMALL_SIZE_SCALE\t0.75\n\n#define BLINK_DIVISOR\t\t\t200\n#define PULSE_DIVISOR\t\t\t75\n\n#define UI_LEFT\t\t\t0x00000000\t// default\n#define UI_CENTER\t\t0x00000001\n#define UI_RIGHT\t\t0x00000002\n#define UI_FORMATMASK\t0x00000007\n#define UI_SMALLFONT\t0x00000010\n#define UI_BIGFONT\t\t0x00000020\t// default\n#define UI_GIANTFONT\t0x00000040\n#define UI_DROPSHADOW\t0x00000800\n#define UI_BLINK\t\t0x00001000\n#define UI_INVERSE\t\t0x00002000\n#define UI_PULSE\t\t0x00004000\n\n\n/*\n==============================================================\n\nMATHLIB\n\n==============================================================\n*/\n#ifdef __cplusplus\t\t\t// so we can include this in C code\n#define\tSIDE_FRONT\t\t0\n#define\tSIDE_BACK\t\t1\n#define\tSIDE_ON\t\t\t2\n#define\tSIDE_CROSS\t\t3\n\n#define\tQ_PI\t3.14159265358979323846\n#ifndef M_PI\n#define M_PI\t\t3.14159265358979323846\t// matches value in gcc v2 math.h\n#endif\n\n#include \"math_vector.h\"\n#include \"math_angles.h\"\n#include \"math_matrix.h\"\n#include \"math_quaternion.h\"\n\nclass idVec3_t;\t\t\t\t\t\t// for defining vectors\ntypedef idVec3_t &vec3_p;\t\t\t\t// for passing vectors as function arguments\ntypedef const idVec3_t &vec3_c;\t\t// for passing vectors as const function arguments\n\t\t\t\t\t\t\t\t\t\nclass angles_t;\t\t\t\t\t\t// for defining angle vectors\ntypedef angles_t &angles_p;\t\t\t// for passing angles as function arguments\ntypedef const angles_t &angles_c;\t// for passing angles as const function arguments\n\nclass mat3_t;\t\t\t\t\t\t// for defining matrices\ntypedef mat3_t &mat3_p;\t\t\t\t// for passing matrices as function arguments\ntypedef const mat3_t &mat3_c;\t\t// for passing matrices as const function arguments\n\n\n\n#define NUMVERTEXNORMALS\t162\nextern\tidVec3_t\tbytedirs[NUMVERTEXNORMALS];\n\n// all drawing is done to a 640*480 virtual screen size\n// and will be automatically scaled to the real resolution\n#define\tSCREEN_WIDTH\t\t640\n#define\tSCREEN_HEIGHT\t\t480\n\n#define TINYCHAR_WIDTH\t\t(SMALLCHAR_WIDTH)\n#define TINYCHAR_HEIGHT\t\t(SMALLCHAR_HEIGHT/2)\n\n#define SMALLCHAR_WIDTH\t\t8\n#define SMALLCHAR_HEIGHT\t16\n\n#define BIGCHAR_WIDTH\t\t16\n#define BIGCHAR_HEIGHT\t\t16\n\n#define\tGIANTCHAR_WIDTH\t\t32\n#define\tGIANTCHAR_HEIGHT\t48\n\nextern\tvec4_t\t\tcolorBlack;\nextern\tvec4_t\t\tcolorRed;\nextern\tvec4_t\t\tcolorGreen;\nextern\tvec4_t\t\tcolorBlue;\nextern\tvec4_t\t\tcolorYellow;\nextern\tvec4_t\t\tcolorMagenta;\nextern\tvec4_t\t\tcolorCyan;\nextern\tvec4_t\t\tcolorWhite;\nextern\tvec4_t\t\tcolorLtGrey;\nextern\tvec4_t\t\tcolorMdGrey;\nextern\tvec4_t\t\tcolorDkGrey;\n\n#define Q_COLOR_ESCAPE\t'^'\n#define Q_IsColorString(p)\t( p && *(p) == Q_COLOR_ESCAPE && *((p)+1) && *((p)+1) != Q_COLOR_ESCAPE )\n\n#define COLOR_BLACK\t\t'0'\n#define COLOR_RED\t\t'1'\n#define COLOR_GREEN\t\t'2'\n#define COLOR_YELLOW\t'3'\n#define COLOR_BLUE\t\t'4'\n#define COLOR_CYAN\t\t'5'\n#define COLOR_MAGENTA\t'6'\n#define COLOR_WHITE\t\t'7'\n#define ColorIndex(c)\t( ( (c) - '0' ) & 7 )\n\n#define S_COLOR_BLACK\t\"^0\"\n#define S_COLOR_RED\t\t\"^1\"\n#define S_COLOR_GREEN\t\"^2\"\n#define S_COLOR_YELLOW\t\"^3\"\n#define S_COLOR_BLUE\t\"^4\"\n#define S_COLOR_CYAN\t\"^5\"\n#define S_COLOR_MAGENTA\t\"^6\"\n#define S_COLOR_WHITE\t\"^7\"\n\nextern vec4_t\tg_color_table[8];\n\n#define\tMAKERGB( v, r, g, b ) v[0]=r;v[1]=g;v[2]=b\n#define\tMAKERGBA( v, r, g, b, a ) v[0]=r;v[1]=g;v[2]=b;v[3]=a\n\n#define DEG2RAD( a ) ( ( (a) * M_PI ) / 180.0F )\n#define RAD2DEG( a ) ( ( (a) * 180.0f ) / M_PI )\n\nstruct cplane_s;\n\nextern\tidVec3_t\tvec3_origin;\nextern\tvec4_t\tvec4_origin;\nextern\tmat3_t\taxisDefault;\n\n#define\tnanmask (255<<23)\n\n#define\tIS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)\n\nfloat Q_fabs( float f );\nfloat Q_rsqrt( float f );\t\t// reciprocal square root\n\n#define SQRTFAST( x ) ( 1.0f / Q_rsqrt( x ) )\n\nsigned char ClampChar( int i );\nsigned short ClampShort( int i );\n\n// this isn't a real cheap function to call!\nint DirToByte( const idVec3_t &dir );\nvoid ByteToDir( int b, vec3_p dir );\n\n#define DotProduct(a,b)\t\t\t((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2])\n#define VectorSubtract(a,b,c)\t((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2])\n#define VectorAdd(a,b,c)\t\t((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2])\n#define VectorCopy(a,b)\t\t\t((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2])\n//#define VectorCopy(a,b)\t\t\t((b).x=(a).x,(b).y=(a).y,(b).z=(a).z])\n\n#define\tVectorScale(v, s, o)\t((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s))\n#define\tVectorMA(v, s, b, o)\t((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s))\n#define CrossProduct(a,b,c)\t\t((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])\n\n#define DotProduct4(x,y)\t\t((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]+(x)[3]*(y)[3])\n#define VectorSubtract4(a,b,c)\t((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2],(c)[3]=(a)[3]-(b)[3])\n#define VectorAdd4(a,b,c)\t\t((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2],(c)[3]=(a)[3]+(b)[3])\n#define VectorCopy4(a,b)\t\t((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])\n#define\tVectorScale4(v, s, o)\t((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s),(o)[3]=(v)[3]*(s))\n#define\tVectorMA4(v, s, b, o)\t((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))\n\n\n#define VectorClear(a)\t\t\t((a)[0]=(a)[1]=(a)[2]=0)\n#define VectorNegate(a,b)\t\t((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2])\n#define VectorSet(v, x, y, z)\t((v)[0]=(x), (v)[1]=(y), (v)[2]=(z))\n#define Vector4Copy(a,b)\t\t((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])\n\n#define\tSnapVector(v) {v[0]=(int)v[0];v[1]=(int)v[1];v[2]=(int)v[2];}\n\nfloat NormalizeColor( vec3_c in, vec3_p out );\n\nint VectorCompare( vec3_c v1, vec3_c v2 );\nfloat VectorLength( vec3_c v );\nfloat Distance( vec3_c p1, vec3_c p2 );\nfloat DistanceSquared( vec3_c p1, vec3_c p2 );\nfloat VectorNormalize (vec3_p v);\t\t// returns vector length\nvoid VectorNormalizeFast(vec3_p v);\t\t// does NOT return vector length, uses rsqrt approximation\nfloat VectorNormalize2( vec3_c v, vec3_p out );\nvoid VectorInverse (vec3_p v);\nvoid VectorRotate( vec3_c in, mat3_c matrix, vec3_p out );\nvoid VectorPolar(vec3_p v, float radius, float theta, float phi);\nvoid VectorSnap(vec3_p v);\nvoid Vector53Copy( const idVec5_t &in, vec3_p out);\nvoid Vector5Scale( const idVec5_t &v, float scale, idVec5_t &out);\nvoid Vector5Add( const idVec5_t &va, const idVec5_t &vb, idVec5_t &out);\nvoid VectorRotate3( vec3_c vIn, vec3_c vRotation, vec3_p out);\nvoid VectorRotate3Origin(vec3_c vIn, vec3_c vRotation, vec3_c vOrigin, vec3_p out);\n\n\nint Q_log2(int val);\n\nint\t\tQ_rand( int *seed );\nfloat\tQ_random( int *seed );\nfloat\tQ_crandom( int *seed );\n\n#define random()\t((rand () & 0x7fff) / ((float)0x7fff))\n#define crandom()\t(2.0 * (random() - 0.5))\n\nfloat Q_rint( float in );\n\nvoid vectoangles( vec3_c value1, angles_p angles);\nvoid AnglesToAxis( angles_c angles, mat3_p axis );\n\nvoid AxisCopy( mat3_c in, mat3_p out );\nqboolean AxisRotated( mat3_c in );\t\t\t// assumes a non-degenerate axis\n\nint SignbitsForNormal( vec3_c normal );\nint BoxOnPlaneSide( const Bounds &b, struct cplane_s *p );\n\nfloat\tAngleMod(float a);\nfloat\tLerpAngle (float from, float to, float frac);\nfloat\tAngleSubtract( float a1, float a2 );\nvoid\tAnglesSubtract( angles_c v1, angles_c v2, angles_p v3 );\n\nfloat AngleNormalize360 ( float angle );\nfloat AngleNormalize180 ( float angle );\nfloat AngleDelta ( float angle1, float angle2 );\n\nqboolean PlaneFromPoints( vec4_t &plane, vec3_c a, vec3_c b, vec3_c c );\nvoid ProjectPointOnPlane( vec3_p dst, vec3_c p, vec3_c normal );\nvoid RotatePointAroundVector( vec3_p dst, vec3_c dir, vec3_c point, float degrees );\nvoid RotateAroundDirection( mat3_p axis, float yaw );\nvoid MakeNormalVectors( vec3_c forward, vec3_p right, vec3_p up );\n// perpendicular vector could be replaced by this\n\nint\tPlaneTypeForNormal( vec3_c normal );\n\nvoid MatrixMultiply( mat3_c in1, mat3_c in2, mat3_p out );\nvoid MatrixInverseMultiply( mat3_c in1, mat3_c in2, mat3_p out );\t// in2 is transposed during multiply\nvoid MatrixTransformVector( vec3_c in, mat3_c matrix, vec3_p out );\nvoid MatrixProjectVector( vec3_c in, mat3_c matrix, vec3_p out ); // Places the vector into a new coordinate system.\nvoid AngleVectors( angles_c angles, vec3_p forward, vec3_p right, vec3_p up);\nvoid PerpendicularVector( vec3_p dst, vec3_c src );\n\nfloat TriangleArea( vec3_c a, vec3_c b, vec3_c c );\n#endif\t\t\t\t\t\t\t\t\t\t// __cplusplus\n\n//=============================================\n\nfloat Com_Clamp( float min, float max, float value );\n\n#define FILE_HASH_SIZE\t\t1024\nint Com_HashString( const char *fname );\n\nchar\t*Com_SkipPath( char *pathname );\n\n// it is ok for out == in\nvoid\tCom_StripExtension( const char *in, char *out );\n\n// \"extension\" should include the dot: \".map\"\nvoid\tCom_DefaultExtension( char *path, int maxSize, const char *extension );\n\nint\t\tCom_ParseInfos( const char *buf, int max, char infos[][MAX_INFO_STRING] );\n\n/*\n=====================================================================================\n\nSCRIPT PARSING\n\n=====================================================================================\n*/\n\n// this just controls the comment printing, it doesn't actually load a file\nvoid Com_BeginParseSession( const char *filename );\nvoid Com_EndParseSession( void );\n\nint Com_GetCurrentParseLine( void );\n\n// Will never return NULL, just empty strings.\n// An empty string will only be returned at end of file.\n// ParseOnLine will return empty if there isn't another token on this line\n\n// this funny typedef just means a moving pointer into a const char * buffer\nconst char *Com_Parse( const char *(*data_p) );\nconst char *Com_ParseOnLine( const char *(*data_p) );\nconst char *Com_ParseRestOfLine( const char *(*data_p) );\n\nvoid Com_UngetToken( void );\n\n#ifdef __cplusplus\nvoid Com_MatchToken( const char *(*buf_p), const char *match, qboolean warning = qfalse );\n#else\nvoid Com_MatchToken( const char *(*buf_p), const char *match, qboolean warning );\n#endif\n\nvoid Com_ScriptError( const char *msg, ... );\nvoid Com_ScriptWarning( const char *msg, ... );\n\nvoid Com_SkipBracedSection( const char *(*program) );\nvoid Com_SkipRestOfLine( const char *(*data) );\n\nfloat Com_ParseFloat( const char *(*buf_p) );\nint\tCom_ParseInt( const char *(*buf_p) );\n\nvoid Com_Parse1DMatrix( const char *(*buf_p), int x, float *m );\nvoid Com_Parse2DMatrix( const char *(*buf_p), int y, int x, float *m );\nvoid Com_Parse3DMatrix( const char *(*buf_p), int z, int y, int x, float *m );\n\n//=====================================================================================\n#ifdef __cplusplus\n\textern \"C\" {\n#endif\n\nvoid\tQDECL Com_sprintf (char *dest, int size, const char *fmt, ...);\n\n\n// mode parm for FS_FOpenFile\ntypedef enum {\n\tFS_READ,\n\tFS_WRITE,\n\tFS_APPEND,\n\tFS_APPEND_SYNC\n} fsMode_t;\n\ntypedef enum {\n\tFS_SEEK_CUR,\n\tFS_SEEK_END,\n\tFS_SEEK_SET\n} fsOrigin_t;\n\n//=============================================\n\nint Q_isprint( int c );\nint Q_islower( int c );\nint Q_isupper( int c );\nint Q_isalpha( int c );\n\n// portable case insensitive compare\nint\t\tQ_stricmp (const char *s1, const char *s2);\nint\t\tQ_strncmp (const char *s1, const char *s2, int n);\nint\t\tQ_stricmpn (const char *s1, const char *s2, int n);\nchar\t*Q_strlwr( char *s1 );\nchar\t*Q_strupr( char *s1 );\nchar\t*Q_strrchr( const char* string, int c );\n\n// buffer size safe library replacements\nvoid\tQ_strncpyz( char *dest, const char *src, int destsize );\nvoid\tQ_strcat( char *dest, int size, const char *src );\n\n// strlen that discounts Quake color sequences\nint Q_PrintStrlen( const char *string );\n// removes color sequences from string\nchar *Q_CleanStr( char *string );\n\nint\t\t\tCom_Filter( const char *filter, const char *name, int casesensitive );\nconst char *Com_StringContains( const char *str1, const char *str2, int casesensitive );\n\n\n//=============================================\n\nshort\tBigShort(short l);\nshort\tLittleShort(short l);\nint\t\tBigLong (int l);\nint\t\tLittleLong (int l);\nfloat\tBigFloat (float l);\nfloat\tLittleFloat (float l);\n\nvoid\tSwap_Init (void);\nchar\t* QDECL va(char *format, ...);\n\n#ifdef __cplusplus\n    }\n#endif\n\n\n//=============================================\n#ifdef __cplusplus\n//\n// mapfile parsing\n//\ntypedef struct ePair_s {\n\tchar\t*key;\n\tchar\t*value;\n} ePair_t;\n\ntypedef struct mapSide_s {\n\tchar\t\tmaterial[MAX_QPATH];\n\tvec4_t\t\tplane;\n\tvec4_t\t\ttextureVectors[2];\n} mapSide_t;\n\ntypedef struct {\n\tint\t\t\tnumSides;\n\tmapSide_t\t**sides;\n} mapBrush_t;\n\ntypedef struct {\n\tidVec3_t\t\txyz;\n\tfloat\t\tst[2];\n} patchVertex_t;\n\ntypedef struct {\n\tchar\t\tmaterial[MAX_QPATH];\n\tint\t\t\twidth, height;\n\tpatchVertex_t\t*patchVerts;\n} mapPatch_t;\n\ntypedef struct {\n\tchar\t\tmodelName[MAX_QPATH];\n\tfloat\t\tmatrix[16];\n} mapModel_t;\n\ntypedef struct mapPrimitive_s {\n\tint\t\t\t\tnumEpairs;\n\tePair_t\t\t\t**ePairs;\n\n\t// only one of these will be non-NULL\n\tmapBrush_t\t\t*brush;\n\tmapPatch_t\t\t*patch;\n\tmapModel_t\t\t*model;\n} mapPrimitive_t;\n\ntypedef struct mapEntity_s {\n\tint\t\t\t\tnumPrimitives;\n\tmapPrimitive_t\t**primitives;\n\n\tint\t\t\t\tnumEpairs;\n\tePair_t\t\t\t**ePairs;\n} mapEntity_t;\n\ntypedef struct {\n\tint\t\t\t\tnumEntities;\n\tmapEntity_t\t\t**entities;\n} mapFile_t;\n\n\n// the order of entities, brushes, and sides will be maintained, the\n// lists won't be swapped on each load or save\nmapFile_t *ParseMapFile( const char *text );\nvoid FreeMapFile( mapFile_t *mapFile );\nvoid WriteMapFile( const mapFile_t *mapFile, FILE *f );\n\n// key names are case-insensitive\nconst char \t*ValueForMapEntityKey( const mapEntity_t *ent, const char *key );\nfloat\tFloatForMapEntityKey( const mapEntity_t *ent, const char *key );\nqboolean \tGetVectorForMapEntityKey( const mapEntity_t *ent, const char *key, idVec3_t &vec );\n\ntypedef struct {\n\tidVec3_t\t\txyz;\n\tidVec2_t\t\tst;\n\tidVec3_t\t\tnormal;\n\tidVec3_t\t\ttangents[2];\n\tbyte\t\tsmoothing[4];\t\t// colors for silhouette smoothing\n} drawVert_t;\n\ntypedef struct {\n\tint\t\t\twidth, height;\n\tdrawVert_t\t*verts;\n} drawVertMesh_t;\n\n// Tesselate a map patch into smoothed, drawable vertexes\n// MaxError of around 4 is reasonable\ndrawVertMesh_t *SubdivideMapPatch( const mapPatch_t *patch, float maxError );\n#endif\t\t\t// __cplusplus\n\n//=========================================\n\n#ifdef __cplusplus\n\textern \"C\" {\n#endif\n\nvoid\tQDECL Com_Error( int level, const char *error, ... );\nvoid\tQDECL Com_Printf( const char *msg, ... );\nvoid\tQDECL Com_DPrintf( const char *msg, ... );\n\n#ifdef __cplusplus\n\t}\n#endif\n\n\ntypedef struct {\n\tqboolean\tframeMemory;\n\tint\t\tcurrentElements;\n\tint\t\tmaxElements;\t\t// will reallocate and move when exceeded\n\tvoid\t**elements;\n} growList_t;\n\n// you don't need to init the growlist if you don't mind it growing and moving\n// the list as it expands\nvoid\t\tCom_InitGrowList( growList_t *list, int maxElements );\nint\t\t\tCom_AddToGrowList( growList_t *list, void *data );\nvoid\t\t*Com_GrowListElement( const growList_t *list, int index );\nint\t\t\tCom_IndexForGrowListElement( const growList_t *list, const void *element );\n\n\n//\n// key / value info strings\n//\nchar *Info_ValueForKey( const char *s, const char *key );\nvoid Info_RemoveKey( char *s, const char *key );\nvoid Info_SetValueForKey( char *s, const char *key, const char *value );\nqboolean Info_Validate( const char *s );\nvoid Info_NextPair( const char *(*s), char key[MAX_INFO_KEY], char value[MAX_INFO_VALUE] );\n\n// get cvar defs, collision defs, etc\n//#include \"../shared/interface.h\"\n\n// get key code numbers for events\n//#include \"../shared/keycodes.h\"\n\n#ifdef __cplusplus\n// get the polygon winding functions\n//#include \"../shared/windings.h\"\n\n// get the flags class\n//#include \"../shared/idflags.h\"\n#endif\t// __cplusplus\n\n#endif\t// __Q_SHARED_H\n\n"
  },
  {
    "path": "code/splines/q_shared.hpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __Q_SHARED_H\n#define __Q_SHARED_H\n\n// q_shared.h -- included first by ALL program modules.\n// these are the definitions that have no dependance on\n// central system services, and can be used by any part\n// of the program without any state issues.\n\n// A user mod should never modify this file\n\n// incursion of DOOM code into the Q3A codebase\n//#define\tQ3_VERSION\t\t\"DOOM 0.01\"\n\n// alignment macros for SIMD\n#define\tALIGN_ON\n#define\tALIGN_OFF\n\n#ifdef _WIN32\n\n#pragma warning(disable : 4018)     // signed/unsigned mismatch\n#pragma warning(disable : 4032)\n#pragma warning(disable : 4051)\n#pragma warning(disable : 4057)\t\t// slightly different base types\n#pragma warning(disable : 4100)\t\t// unreferenced formal parameter\n#pragma warning(disable : 4115)\n#pragma warning(disable : 4125)\t\t// decimal digit terminates octal escape sequence\n#pragma warning(disable : 4127)\t\t// conditional expression is constant\n#pragma warning(disable : 4136)\n#pragma warning(disable : 4201)\n#pragma warning(disable : 4214)\n#pragma warning(disable : 4244)\n#pragma warning(disable : 4305)\t\t// truncation from const double to float\n#pragma warning(disable : 4310)\t\t// cast truncates constant value\n#pragma warning(disable : 4514)\n#pragma warning(disable : 4711)\t\t// selected for automatic inline expansion\n#pragma warning(disable : 4220)\t\t// varargs matches remaining parameters\n\n#endif\n\n#include <assert.h>\n#include <math.h>\n#include <stdio.h>\n#include <stdarg.h>\n#include <string.h>\n#include <stdlib.h>\n#include <time.h>\n#include <ctype.h>\n#ifdef WIN32\t\t\t\t// mac doesn't have malloc.h\n#include <malloc.h>\t\t\t// for _alloca()\n#endif\n#ifdef _WIN32\n\n//#pragma intrinsic( memset, memcpy )\n\n#endif\n\n\n// this is the define for determining if we have an asm version of a C function\n#if (defined _M_IX86 || defined __i386__) && !defined __sun__  && !defined __LCC__\n#define id386\t1\n#else\n#define id386\t0\n#endif\n\n// for windows fastcall option\n\n#define\tQDECL\n\n//======================= WIN32 DEFINES =================================\n\n#ifdef WIN32\n\n#define\tMAC_STATIC\n\n#undef QDECL\n#define\tQDECL\t__cdecl\n\n// buildstring will be incorporated into the version string\n#ifdef NDEBUG\n#ifdef _M_IX86\n#define\tCPUSTRING\t\"win-x86\"\n#elif defined _M_ALPHA\n#define\tCPUSTRING\t\"win-AXP\"\n#endif\n#else\n#ifdef _M_IX86\n#define\tCPUSTRING\t\"win-x86-debug\"\n#elif defined _M_ALPHA\n#define\tCPUSTRING\t\"win-AXP-debug\"\n#endif\n#endif\n\n\n#define\tPATH_SEP '\\\\'\n\n#endif\n\n//======================= MAC OS X SERVER DEFINES =====================\n\n#if defined(__MACH__) && defined(__APPLE__)\n\n#define MAC_STATIC\n\n#ifdef __ppc__\n#define CPUSTRING\t\"MacOSXS-ppc\"\n#elif defined __i386__\n#define CPUSTRING\t\"MacOSXS-i386\"\n#else\n#define CPUSTRING\t\"MacOSXS-other\"\n#endif\n\n#define\tPATH_SEP\t'/'\n\n#define\tGAME_HARD_LINKED\n#define\tCGAME_HARD_LINKED\n#define\tUI_HARD_LINKED\n#define _alloca alloca\n\n#undef ALIGN_ON\n#undef ALIGN_OFF\n#define\tALIGN_ON\t\t#pragma align(16)\n#define\tALIGN_OFF\t\t#pragma align()\n\n#ifdef __cplusplus\n\textern \"C\" {\n#endif\n\nvoid *osxAllocateMemory(long size);\nvoid osxFreeMemory(void *pointer);\n\n#ifdef __cplusplus\n        }\n#endif\n\n#endif\n\n//======================= MAC DEFINES =================================\n\n#ifdef __MACOS__\n\n#define\tMAC_STATIC static\n\n#define\tCPUSTRING\t\"MacOS-PPC\"\n\n#define\tPATH_SEP ':'\n\nvoid Sys_PumpEvents( void );\n\n#endif\n\n#ifdef __MRC__\n\n#define\tMAC_STATIC\n\n#define\tCPUSTRING\t\"MacOS-PPC\"\n\n#define\tPATH_SEP ':'\n\nvoid Sys_PumpEvents( void );\n\n#undef QDECL\n#define\tQDECL\t__cdecl\n\n#define _alloca alloca\n#endif\n\n//======================= LINUX DEFINES =================================\n\n// the mac compiler can't handle >32k of locals, so we\n// just waste space and make big arrays static...\n#ifdef __linux__\n\n// bk001205 - from Makefile\n#define stricmp strcasecmp\n\n#define\tMAC_STATIC // bk: FIXME\n\n#ifdef __i386__\n#define\tCPUSTRING\t\"linux-i386\"\n#elif defined __axp__\n#define\tCPUSTRING\t\"linux-alpha\"\n#else\n#define\tCPUSTRING\t\"linux-other\"\n#endif\n\n#define\tPATH_SEP '/'\n\n// bk001205 - try\n#ifdef Q3_STATIC\n#define\tGAME_HARD_LINKED\n#define\tCGAME_HARD_LINKED\n#define\tUI_HARD_LINKED\n#define\tBOTLIB_HARD_LINKED\n#endif\n\n#endif\n\n//=============================================================\n\n\n  \ntypedef enum {qfalse, qtrue}\tqboolean;\n\ntypedef unsigned char \t\tbyte;\n\n#define\tEQUAL_EPSILON\t0.001\n\ntypedef int\t\tqhandle_t;\ntypedef int\t\tsfxHandle_t;\ntypedef int\t\tfileHandle_t;\ntypedef int\t\tclipHandle_t;\n\ntypedef enum {\n\tINVALID_JOINT = -1\n} jointHandle_t;\n\n#ifndef NULL\n#define NULL ((void *)0)\n#endif\n\n#define\tMAX_QINT\t\t\t0x7fffffff\n#define\tMIN_QINT\t\t\t(-MAX_QINT-1)\n\n#ifndef max\n#define max( x, y ) ( ( ( x ) > ( y ) ) ? ( x ) : ( y ) )\n#define min( x, y ) ( ( ( x ) < ( y ) ) ? ( x ) : ( y ) )\n#endif\n\n#ifndef sign\n#define sign( f )\t( ( f > 0 ) ? 1 : ( ( f < 0 ) ? -1 : 0 ) )\n#endif\n\n// angle indexes\n#define\tPITCH\t\t\t\t0\t\t// up / down\n#define\tYAW\t\t\t\t\t1\t\t// left / right\n#define\tROLL\t\t\t\t2\t\t// fall over\n\n// the game guarantees that no string from the network will ever\n// exceed MAX_STRING_CHARS\n#define\tMAX_STRING_CHARS\t1024\t// max length of a string passed to Cmd_TokenizeString\n#define\tMAX_STRING_TOKENS\t256\t\t// max tokens resulting from Cmd_TokenizeString\n#define\tMAX_TOKEN_CHARS\t\t1024\t// max length of an individual token\n\n#define\tMAX_INFO_STRING\t\t1024\n#define\tMAX_INFO_KEY\t\t1024\n#define\tMAX_INFO_VALUE\t\t1024\n\n\n#define\tMAX_QPATH\t\t\t64\t\t// max length of a quake game pathname\n#define\tMAX_OSPATH\t\t\t128\t\t// max length of a filesystem pathname\n\n#define\tMAX_NAME_LENGTH\t\t32\t\t// max length of a client name\n\n// paramters for command buffer stuffing\ntypedef enum {\n\tEXEC_NOW,\t\t\t// don't return until completed, a VM should NEVER use this,\n\t\t\t\t\t\t// because some commands might cause the VM to be unloaded...\n\tEXEC_INSERT,\t\t// insert at current position, but don't run yet\n\tEXEC_APPEND\t\t\t// add to end of the command buffer (normal case)\n} cbufExec_t;\n\n\n//\n// these aren't needed by any of the VMs.  put in another header?\n//\n#define\tMAX_MAP_AREA_BYTES\t\t32\t\t// bit vector of area visibility\n\n#undef ERR_FATAL\t\t\t\t\t\t// malloc.h on unix\n\n// parameters to the main Error routine\ntypedef enum {\n\tERR_NONE,\n\tERR_FATAL,\t\t\t\t\t// exit the entire game with a popup window\n\tERR_DROP,\t\t\t\t\t// print to console and disconnect from game\n\tERR_DISCONNECT,\t\t\t\t// don't kill server\n\tERR_NEED_CD\t\t\t\t\t// pop up the need-cd dialog\n} errorParm_t;\n\n\n// font rendering values used by ui and cgame\n\n#define PROP_GAP_WIDTH\t\t\t3\n#define PROP_SPACE_WIDTH\t\t8\n#define PROP_HEIGHT\t\t\t\t27\n#define PROP_SMALL_SIZE_SCALE\t0.75\n\n#define BLINK_DIVISOR\t\t\t200\n#define PULSE_DIVISOR\t\t\t75\n\n#define UI_LEFT\t\t\t0x00000000\t// default\n#define UI_CENTER\t\t0x00000001\n#define UI_RIGHT\t\t0x00000002\n#define UI_FORMATMASK\t0x00000007\n#define UI_SMALLFONT\t0x00000010\n#define UI_BIGFONT\t\t0x00000020\t// default\n#define UI_GIANTFONT\t0x00000040\n#define UI_DROPSHADOW\t0x00000800\n#define UI_BLINK\t\t0x00001000\n#define UI_INVERSE\t\t0x00002000\n#define UI_PULSE\t\t0x00004000\n\n\n/*\n==============================================================\n\nMATHLIB\n\n==============================================================\n*/\n#ifdef __cplusplus\t\t\t// so we can include this in C code\n#define\tSIDE_FRONT\t\t0\n#define\tSIDE_BACK\t\t1\n#define\tSIDE_ON\t\t\t2\n#define\tSIDE_CROSS\t\t3\n\n#define\tQ_PI\t3.14159265358979323846\n#ifndef M_PI\n#define M_PI\t\t3.14159265358979323846\t// matches value in gcc v2 math.h\n#endif\n\n#include \"math_vector.h\"\n#include \"math_angles.h\"\n#include \"math_matrix.h\"\n#include \"math_quaternion.h\"\n\nclass idVec3_t;\t\t\t\t\t\t// for defining vectors\ntypedef idVec3_t &vec3_p;\t\t\t\t// for passing vectors as function arguments\ntypedef const idVec3_t &vec3_c;\t\t// for passing vectors as const function arguments\n\t\t\t\t\t\t\t\t\t\nclass angles_t;\t\t\t\t\t\t// for defining angle vectors\ntypedef angles_t &angles_p;\t\t\t// for passing angles as function arguments\ntypedef const angles_t &angles_c;\t// for passing angles as const function arguments\n\nclass mat3_t;\t\t\t\t\t\t// for defining matrices\ntypedef mat3_t &mat3_p;\t\t\t\t// for passing matrices as function arguments\ntypedef const mat3_t &mat3_c;\t\t// for passing matrices as const function arguments\n\n\n\n#define NUMVERTEXNORMALS\t162\nextern\tidVec3_t\tbytedirs[NUMVERTEXNORMALS];\n\n// all drawing is done to a 640*480 virtual screen size\n// and will be automatically scaled to the real resolution\n#define\tSCREEN_WIDTH\t\t640\n#define\tSCREEN_HEIGHT\t\t480\n\n#define TINYCHAR_WIDTH\t\t(SMALLCHAR_WIDTH)\n#define TINYCHAR_HEIGHT\t\t(SMALLCHAR_HEIGHT/2)\n\n#define SMALLCHAR_WIDTH\t\t8\n#define SMALLCHAR_HEIGHT\t16\n\n#define BIGCHAR_WIDTH\t\t16\n#define BIGCHAR_HEIGHT\t\t16\n\n#define\tGIANTCHAR_WIDTH\t\t32\n#define\tGIANTCHAR_HEIGHT\t48\n\nextern\tvec4_t\t\tcolorBlack;\nextern\tvec4_t\t\tcolorRed;\nextern\tvec4_t\t\tcolorGreen;\nextern\tvec4_t\t\tcolorBlue;\nextern\tvec4_t\t\tcolorYellow;\nextern\tvec4_t\t\tcolorMagenta;\nextern\tvec4_t\t\tcolorCyan;\nextern\tvec4_t\t\tcolorWhite;\nextern\tvec4_t\t\tcolorLtGrey;\nextern\tvec4_t\t\tcolorMdGrey;\nextern\tvec4_t\t\tcolorDkGrey;\n\n#define Q_COLOR_ESCAPE\t'^'\n#define Q_IsColorString(p)\t( p && *(p) == Q_COLOR_ESCAPE && *((p)+1) && *((p)+1) != Q_COLOR_ESCAPE )\n\n#define COLOR_BLACK\t\t'0'\n#define COLOR_RED\t\t'1'\n#define COLOR_GREEN\t\t'2'\n#define COLOR_YELLOW\t'3'\n#define COLOR_BLUE\t\t'4'\n#define COLOR_CYAN\t\t'5'\n#define COLOR_MAGENTA\t'6'\n#define COLOR_WHITE\t\t'7'\n#define ColorIndex(c)\t( ( (c) - '0' ) & 7 )\n\n#define S_COLOR_BLACK\t\"^0\"\n#define S_COLOR_RED\t\t\"^1\"\n#define S_COLOR_GREEN\t\"^2\"\n#define S_COLOR_YELLOW\t\"^3\"\n#define S_COLOR_BLUE\t\"^4\"\n#define S_COLOR_CYAN\t\"^5\"\n#define S_COLOR_MAGENTA\t\"^6\"\n#define S_COLOR_WHITE\t\"^7\"\n\nextern vec4_t\tg_color_table[8];\n\n#define\tMAKERGB( v, r, g, b ) v[0]=r;v[1]=g;v[2]=b\n#define\tMAKERGBA( v, r, g, b, a ) v[0]=r;v[1]=g;v[2]=b;v[3]=a\n\n#define DEG2RAD( a ) ( ( (a) * M_PI ) / 180.0F )\n#define RAD2DEG( a ) ( ( (a) * 180.0f ) / M_PI )\n\nstruct cplane_s;\n\nextern\tidVec3_t\tvec3_origin;\nextern\tvec4_t\tvec4_origin;\nextern\tmat3_t\taxisDefault;\n\n#define\tnanmask (255<<23)\n\n#define\tIS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)\n\nfloat Q_fabs( float f );\nfloat Q_rsqrt( float f );\t\t// reciprocal square root\n\n#define SQRTFAST( x ) ( 1.0f / Q_rsqrt( x ) )\n\nsigned char ClampChar( int i );\nsigned short ClampShort( int i );\n\n// this isn't a real cheap function to call!\nint DirToByte( const idVec3_t &dir );\nvoid ByteToDir( int b, vec3_p dir );\n\n#define DotProduct(a,b)\t\t\t((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2])\n#define VectorSubtract(a,b,c)\t((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2])\n#define VectorAdd(a,b,c)\t\t((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2])\n#define VectorCopy(a,b)\t\t\t((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2])\n//#define VectorCopy(a,b)\t\t\t((b).x=(a).x,(b).y=(a).y,(b).z=(a).z])\n\n#define\tVectorScale(v, s, o)\t((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s))\n#define\tVectorMA(v, s, b, o)\t((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s))\n#define CrossProduct(a,b,c)\t\t((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])\n\n#define DotProduct4(x,y)\t\t((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]+(x)[3]*(y)[3])\n#define VectorSubtract4(a,b,c)\t((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2],(c)[3]=(a)[3]-(b)[3])\n#define VectorAdd4(a,b,c)\t\t((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2],(c)[3]=(a)[3]+(b)[3])\n#define VectorCopy4(a,b)\t\t((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])\n#define\tVectorScale4(v, s, o)\t((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s),(o)[3]=(v)[3]*(s))\n#define\tVectorMA4(v, s, b, o)\t((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))\n\n\n#define VectorClear(a)\t\t\t((a)[0]=(a)[1]=(a)[2]=0)\n#define VectorNegate(a,b)\t\t((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2])\n#define VectorSet(v, x, y, z)\t((v)[0]=(x), (v)[1]=(y), (v)[2]=(z))\n#define Vector4Copy(a,b)\t\t((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])\n\n#define\tSnapVector(v) {v[0]=(int)v[0];v[1]=(int)v[1];v[2]=(int)v[2];}\n\nfloat NormalizeColor( vec3_c in, vec3_p out );\n\nint VectorCompare( vec3_c v1, vec3_c v2 );\nfloat VectorLength( vec3_c v );\nfloat Distance( vec3_c p1, vec3_c p2 );\nfloat DistanceSquared( vec3_c p1, vec3_c p2 );\nfloat VectorNormalize (vec3_p v);\t\t// returns vector length\nvoid VectorNormalizeFast(vec3_p v);\t\t// does NOT return vector length, uses rsqrt approximation\nfloat VectorNormalize2( vec3_c v, vec3_p out );\nvoid VectorInverse (vec3_p v);\nvoid VectorRotate( vec3_c in, mat3_c matrix, vec3_p out );\nvoid VectorPolar(vec3_p v, float radius, float theta, float phi);\nvoid VectorSnap(vec3_p v);\nvoid Vector53Copy( const idVec5_t &in, vec3_p out);\nvoid Vector5Scale( const idVec5_t &v, float scale, idVec5_t &out);\nvoid Vector5Add( const idVec5_t &va, const idVec5_t &vb, idVec5_t &out);\nvoid VectorRotate3( vec3_c vIn, vec3_c vRotation, vec3_p out);\nvoid VectorRotate3Origin(vec3_c vIn, vec3_c vRotation, vec3_c vOrigin, vec3_p out);\n\n\nint Q_log2(int val);\n\nint\t\tQ_rand( int *seed );\nfloat\tQ_random( int *seed );\nfloat\tQ_crandom( int *seed );\n\n#define random()\t((rand () & 0x7fff) / ((float)0x7fff))\n#define crandom()\t(2.0 * (random() - 0.5))\n\nfloat Q_rint( float in );\n\nvoid vectoangles( vec3_c value1, angles_p angles);\nvoid AnglesToAxis( angles_c angles, mat3_p axis );\n\nvoid AxisCopy( mat3_c in, mat3_p out );\nqboolean AxisRotated( mat3_c in );\t\t\t// assumes a non-degenerate axis\n\nint SignbitsForNormal( vec3_c normal );\nint BoxOnPlaneSide( const Bounds &b, struct cplane_s *p );\n\nfloat\tAngleMod(float a);\nfloat\tLerpAngle (float from, float to, float frac);\nfloat\tAngleSubtract( float a1, float a2 );\nvoid\tAnglesSubtract( angles_c v1, angles_c v2, angles_p v3 );\n\nfloat AngleNormalize360 ( float angle );\nfloat AngleNormalize180 ( float angle );\nfloat AngleDelta ( float angle1, float angle2 );\n\nqboolean PlaneFromPoints( vec4_t &plane, vec3_c a, vec3_c b, vec3_c c );\nvoid ProjectPointOnPlane( vec3_p dst, vec3_c p, vec3_c normal );\nvoid RotatePointAroundVector( vec3_p dst, vec3_c dir, vec3_c point, float degrees );\nvoid RotateAroundDirection( mat3_p axis, float yaw );\nvoid MakeNormalVectors( vec3_c forward, vec3_p right, vec3_p up );\n// perpendicular vector could be replaced by this\n\nint\tPlaneTypeForNormal( vec3_c normal );\n\nvoid MatrixMultiply( mat3_c in1, mat3_c in2, mat3_p out );\nvoid MatrixInverseMultiply( mat3_c in1, mat3_c in2, mat3_p out );\t// in2 is transposed during multiply\nvoid MatrixTransformVector( vec3_c in, mat3_c matrix, vec3_p out );\nvoid MatrixProjectVector( vec3_c in, mat3_c matrix, vec3_p out ); // Places the vector into a new coordinate system.\nvoid AngleVectors( angles_c angles, vec3_p forward, vec3_p right, vec3_p up);\nvoid PerpendicularVector( vec3_p dst, vec3_c src );\n\nfloat TriangleArea( vec3_c a, vec3_c b, vec3_c c );\n#endif\t\t\t\t\t\t\t\t\t\t// __cplusplus\n\n//=============================================\n\nfloat Com_Clamp( float min, float max, float value );\n\n#define FILE_HASH_SIZE\t\t1024\nint Com_HashString( const char *fname );\n\nchar\t*Com_SkipPath( char *pathname );\n\n// it is ok for out == in\nvoid\tCom_StripExtension( const char *in, char *out );\n\n// \"extension\" should include the dot: \".map\"\nvoid\tCom_DefaultExtension( char *path, int maxSize, const char *extension );\n\nint\t\tCom_ParseInfos( const char *buf, int max, char infos[][MAX_INFO_STRING] );\n\n/*\n=====================================================================================\n\nSCRIPT PARSING\n\n=====================================================================================\n*/\n\n// this just controls the comment printing, it doesn't actually load a file\nvoid Com_BeginParseSession( const char *filename );\nvoid Com_EndParseSession( void );\n\nint Com_GetCurrentParseLine( void );\n\n// Will never return NULL, just empty strings.\n// An empty string will only be returned at end of file.\n// ParseOnLine will return empty if there isn't another token on this line\n\n// this funny typedef just means a moving pointer into a const char * buffer\nconst char *Com_Parse( const char *(*data_p) );\nconst char *Com_ParseOnLine( const char *(*data_p) );\nconst char *Com_ParseRestOfLine( const char *(*data_p) );\n\nvoid Com_UngetToken( void );\n\n#ifdef __cplusplus\nvoid Com_MatchToken( const char *(*buf_p), const char *match, qboolean warning = qfalse );\n#else\nvoid Com_MatchToken( const char *(*buf_p), const char *match, qboolean warning );\n#endif\n\nvoid Com_ScriptError( const char *msg, ... );\nvoid Com_ScriptWarning( const char *msg, ... );\n\nvoid Com_SkipBracedSection( const char *(*program) );\nvoid Com_SkipRestOfLine( const char *(*data) );\n\nfloat Com_ParseFloat( const char *(*buf_p) );\nint\tCom_ParseInt( const char *(*buf_p) );\n\nvoid Com_Parse1DMatrix( const char *(*buf_p), int x, float *m );\nvoid Com_Parse2DMatrix( const char *(*buf_p), int y, int x, float *m );\nvoid Com_Parse3DMatrix( const char *(*buf_p), int z, int y, int x, float *m );\n\n//=====================================================================================\n#ifdef __cplusplus\n\textern \"C\" {\n#endif\n\nvoid\tQDECL Com_sprintf (char *dest, int size, const char *fmt, ...);\n\n\n// mode parm for FS_FOpenFile\ntypedef enum {\n\tFS_READ,\n\tFS_WRITE,\n\tFS_APPEND,\n\tFS_APPEND_SYNC\n} fsMode_t;\n\ntypedef enum {\n\tFS_SEEK_CUR,\n\tFS_SEEK_END,\n\tFS_SEEK_SET\n} fsOrigin_t;\n\n//=============================================\n\nint Q_isprint( int c );\nint Q_islower( int c );\nint Q_isupper( int c );\nint Q_isalpha( int c );\n\n// portable case insensitive compare\nint\t\tQ_stricmp (const char *s1, const char *s2);\nint\t\tQ_strncmp (const char *s1, const char *s2, int n);\nint\t\tQ_stricmpn (const char *s1, const char *s2, int n);\nchar\t*Q_strlwr( char *s1 );\nchar\t*Q_strupr( char *s1 );\nchar\t*Q_strrchr( const char* string, int c );\n\n// buffer size safe library replacements\nvoid\tQ_strncpyz( char *dest, const char *src, int destsize );\nvoid\tQ_strcat( char *dest, int size, const char *src );\n\n// strlen that discounts Quake color sequences\nint Q_PrintStrlen( const char *string );\n// removes color sequences from string\nchar *Q_CleanStr( char *string );\n\nint\t\t\tCom_Filter( const char *filter, const char *name, int casesensitive );\nconst char *Com_StringContains( const char *str1, const char *str2, int casesensitive );\n\n\n//=============================================\n\nshort\tBigShort(short l);\nshort\tLittleShort(short l);\nint\t\tBigLong (int l);\nint\t\tLittleLong (int l);\nfloat\tBigFloat (float l);\nfloat\tLittleFloat (float l);\n\nvoid\tSwap_Init (void);\nchar\t* QDECL va(char *format, ...);\n\n#ifdef __cplusplus\n    }\n#endif\n\n\n//=============================================\n#ifdef __cplusplus\n//\n// mapfile parsing\n//\ntypedef struct ePair_s {\n\tchar\t*key;\n\tchar\t*value;\n} ePair_t;\n\ntypedef struct mapSide_s {\n\tchar\t\tmaterial[MAX_QPATH];\n\tvec4_t\t\tplane;\n\tvec4_t\t\ttextureVectors[2];\n} mapSide_t;\n\ntypedef struct {\n\tint\t\t\tnumSides;\n\tmapSide_t\t**sides;\n} mapBrush_t;\n\ntypedef struct {\n\tidVec3_t\t\txyz;\n\tfloat\t\tst[2];\n} patchVertex_t;\n\ntypedef struct {\n\tchar\t\tmaterial[MAX_QPATH];\n\tint\t\t\twidth, height;\n\tpatchVertex_t\t*patchVerts;\n} mapPatch_t;\n\ntypedef struct {\n\tchar\t\tmodelName[MAX_QPATH];\n\tfloat\t\tmatrix[16];\n} mapModel_t;\n\ntypedef struct mapPrimitive_s {\n\tint\t\t\t\tnumEpairs;\n\tePair_t\t\t\t**ePairs;\n\n\t// only one of these will be non-NULL\n\tmapBrush_t\t\t*brush;\n\tmapPatch_t\t\t*patch;\n\tmapModel_t\t\t*model;\n} mapPrimitive_t;\n\ntypedef struct mapEntity_s {\n\tint\t\t\t\tnumPrimitives;\n\tmapPrimitive_t\t**primitives;\n\n\tint\t\t\t\tnumEpairs;\n\tePair_t\t\t\t**ePairs;\n} mapEntity_t;\n\ntypedef struct {\n\tint\t\t\t\tnumEntities;\n\tmapEntity_t\t\t**entities;\n} mapFile_t;\n\n\n// the order of entities, brushes, and sides will be maintained, the\n// lists won't be swapped on each load or save\nmapFile_t *ParseMapFile( const char *text );\nvoid FreeMapFile( mapFile_t *mapFile );\nvoid WriteMapFile( const mapFile_t *mapFile, FILE *f );\n\n// key names are case-insensitive\nconst char \t*ValueForMapEntityKey( const mapEntity_t *ent, const char *key );\nfloat\tFloatForMapEntityKey( const mapEntity_t *ent, const char *key );\nqboolean \tGetVectorForMapEntityKey( const mapEntity_t *ent, const char *key, idVec3_t &vec );\n\ntypedef struct {\n\tidVec3_t\t\txyz;\n\tidVec2_t\t\tst;\n\tidVec3_t\t\tnormal;\n\tidVec3_t\t\ttangents[2];\n\tbyte\t\tsmoothing[4];\t\t// colors for silhouette smoothing\n} drawVert_t;\n\ntypedef struct {\n\tint\t\t\twidth, height;\n\tdrawVert_t\t*verts;\n} drawVertMesh_t;\n\n// Tesselate a map patch into smoothed, drawable vertexes\n// MaxError of around 4 is reasonable\ndrawVertMesh_t *SubdivideMapPatch( const mapPatch_t *patch, float maxError );\n#endif\t\t\t// __cplusplus\n\n//=========================================\n\n#ifdef __cplusplus\n\textern \"C\" {\n#endif\n\nvoid\tQDECL Com_Error( int level, const char *error, ... );\nvoid\tQDECL Com_Printf( const char *msg, ... );\nvoid\tQDECL Com_DPrintf( const char *msg, ... );\n\n#ifdef __cplusplus\n\t}\n#endif\n\n\ntypedef struct {\n\tqboolean\tframeMemory;\n\tint\t\tcurrentElements;\n\tint\t\tmaxElements;\t\t// will reallocate and move when exceeded\n\tvoid\t**elements;\n} growList_t;\n\n// you don't need to init the growlist if you don't mind it growing and moving\n// the list as it expands\nvoid\t\tCom_InitGrowList( growList_t *list, int maxElements );\nint\t\t\tCom_AddToGrowList( growList_t *list, void *data );\nvoid\t\t*Com_GrowListElement( const growList_t *list, int index );\nint\t\t\tCom_IndexForGrowListElement( const growList_t *list, const void *element );\n\n\n//\n// key / value info strings\n//\nchar *Info_ValueForKey( const char *s, const char *key );\nvoid Info_RemoveKey( char *s, const char *key );\nvoid Info_SetValueForKey( char *s, const char *key, const char *value );\nqboolean Info_Validate( const char *s );\nvoid Info_NextPair( const char *(*s), char key[MAX_INFO_KEY], char value[MAX_INFO_VALUE] );\n\n// get cvar defs, collision defs, etc\n//#include \"../shared/interface.h\"\n\n// get key code numbers for events\n//#include \"../shared/keycodes.h\"\n\n#ifdef __cplusplus\n// get the polygon winding functions\n//#include \"../shared/windings.h\"\n\n// get the flags class\n//#include \"../shared/idflags.h\"\n#endif\t// __cplusplus\n\n#endif\t// __Q_SHARED_H\n\n"
  },
  {
    "path": "code/splines/splines.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n//#include \"stdafx.h\"\n//#include \"qe3.h\"\n\n#include \"q_shared.hpp\"\n#include \"splines.h\"\n\nextern \"C\" {\nint FS_Write( const void *buffer, int len, fileHandle_t h );\nint FS_ReadFile( const char *qpath, void **buffer );\nvoid FS_FreeFile( void *buffer );\nfileHandle_t FS_FOpenFileWrite( const char *filename );\nvoid FS_FCloseFile( fileHandle_t f );\n}\n\nfloat Q_fabs( float f ) {\n\tint tmp = * ( int * ) &f;\n\ttmp &= 0x7FFFFFFF;\n\treturn * ( float * ) &tmp;\n}\n\n\n//#include \"../shared/windings.h\"\n//#include \"../qcommon/qcommon.h\"\n//#include \"../sys/sys_public.h\"\n//#include \"../game/game_entity.h\"\n\nidCameraDef splineList;\nidCameraDef *g_splineList = &splineList;\n\nidVec3_t idSplineList::zero(0,0,0);\n/*\nvoid glLabeledPoint(idVec3_t &color, idVec3_t &point, float size, const char *label) {\n\tqglColor3fv(color);\n\tqglPointSize(size);\n\tqglBegin(GL_POINTS);\n\tqglVertex3fv(point);\n\tqglEnd();\n\tidVec3_t v = point;\n\tv.x += 1;\n\tv.y += 1;\n\tv.z += 1;\n\tqglRasterPos3fv (v);\n\tqglCallLists (strlen(label), GL_UNSIGNED_BYTE, label);\n}\n\n\nvoid glBox(idVec3_t &color, idVec3_t &point, float size) {\n\tidVec3_t mins(point);\n\tidVec3_t maxs(point);\n\tmins[0] -= size;\n\tmins[1] += size;\n\tmins[2] -= size;\n\tmaxs[0] += size;\n\tmaxs[1] -= size;\n\tmaxs[2] += size;\n\tqglColor3fv(color);\n\tqglBegin(GL_LINE_LOOP);\n\tqglVertex3f(mins[0],mins[1],mins[2]);\n\tqglVertex3f(maxs[0],mins[1],mins[2]);\n\tqglVertex3f(maxs[0],maxs[1],mins[2]);\n\tqglVertex3f(mins[0],maxs[1],mins[2]);\n\tqglEnd();\n\tqglBegin(GL_LINE_LOOP);\n\tqglVertex3f(mins[0],mins[1],maxs[2]);\n\tqglVertex3f(maxs[0],mins[1],maxs[2]);\n\tqglVertex3f(maxs[0],maxs[1],maxs[2]);\n\tqglVertex3f(mins[0],maxs[1],maxs[2]);\n\tqglEnd();\n\n\tqglBegin(GL_LINES);\n  \tqglVertex3f(mins[0],mins[1],mins[2]);\n\tqglVertex3f(mins[0],mins[1],maxs[2]);\n\tqglVertex3f(mins[0],maxs[1],maxs[2]);\n\tqglVertex3f(mins[0],maxs[1],mins[2]);\n\tqglVertex3f(maxs[0],mins[1],mins[2]);\n\tqglVertex3f(maxs[0],mins[1],maxs[2]);\n\tqglVertex3f(maxs[0],maxs[1],maxs[2]);\n\tqglVertex3f(maxs[0],maxs[1],mins[2]);\n\tqglEnd();\n\n}\n\nvoid splineTest() {\n\t//g_splineList->load(\"p:/doom/base/maps/test_base1.camera\");\n}\n\nvoid splineDraw() {\n\t//g_splineList->addToRenderer();\n}\n\n\n//extern void D_DebugLine( const idVec3_t &color, const idVec3_t &start, const idVec3_t &end );\n\nvoid debugLine(idVec3_t &color, float x, float y, float z, float x2, float y2, float z2) {\n\t//idVec3_t from(x, y, z);\n\t//idVec3_t to(x2, y2, z2);\n\t//D_DebugLine(color, from, to);\n}\n\n\nvoid idSplineList::addToRenderer() {\n\n\tif (controlPoints.Num() == 0) {\n\t\treturn;\n\t}\n\n\tidVec3_t mins, maxs;\n\tidVec3_t yellow(1.0, 1.0, 0);\n\tidVec3_t white(1.0, 1.0, 1.0);\n        int i;\n        \n\tfor(i = 0; i < controlPoints.Num(); i++) {\n\t\tVectorCopy(*controlPoints[i], mins);\n\t\tVectorCopy(mins, maxs);\n\t\tmins[0] -= 8;\n\t\tmins[1] += 8;\n\t\tmins[2] -= 8;\n\t\tmaxs[0] += 8;\n\t\tmaxs[1] -= 8;\n\t\tmaxs[2] += 8;\n\t\tdebugLine( yellow, mins[0], mins[1], mins[2], maxs[0], mins[1], mins[2]);\n\t\tdebugLine( yellow, maxs[0], mins[1], mins[2], maxs[0], maxs[1], mins[2]);\n\t\tdebugLine( yellow, maxs[0], maxs[1], mins[2], mins[0], maxs[1], mins[2]);\n\t\tdebugLine( yellow, mins[0], maxs[1], mins[2], mins[0], mins[1], mins[2]);\n\t\t\n\t\tdebugLine( yellow, mins[0], mins[1], maxs[2], maxs[0], mins[1], maxs[2]);\n\t\tdebugLine( yellow, maxs[0], mins[1], maxs[2], maxs[0], maxs[1], maxs[2]);\n\t\tdebugLine( yellow, maxs[0], maxs[1], maxs[2], mins[0], maxs[1], maxs[2]);\n\t\tdebugLine( yellow, mins[0], maxs[1], maxs[2], mins[0], mins[1], maxs[2]);\n\t    \n\t}\n\n\tint step = 0;\n\tidVec3_t step1;\n\tfor(i = 3; i < controlPoints.Num(); i++) {\n\t\tfor (float tension = 0.0f; tension < 1.001f; tension += 0.1f) {\n\t\t\tfloat x = 0;\n\t\t\tfloat y = 0;\n\t\t\tfloat z = 0;\n\t\t\tfor (int j = 0; j < 4; j++) {\n\t\t\t\tx += controlPoints[i - (3 - j)]->x * calcSpline(j, tension);\n\t\t\t\ty += controlPoints[i - (3 - j)]->y * calcSpline(j, tension);\n\t\t\t\tz += controlPoints[i - (3 - j)]->z * calcSpline(j, tension);\n\t\t\t}\n\t\t\tif (step == 0) {\n\t\t\t\tstep1[0] = x;\n\t\t\t\tstep1[1] = y;\n\t\t\t\tstep1[2] = z;\n\t\t\t\tstep = 1;\n\t\t\t} else {\n\t\t\t\tdebugLine( white, step1[0], step1[1], step1[2], x, y, z);\n\t\t\t\tstep = 0;\n\t\t\t}\n\n\t\t}\n\t}\n}\n*/\n\nvoid idSplineList::buildSpline() {\n\t//int start = Sys_Milliseconds();\n\tclearSpline();\n\tfor(int i = 3; i < controlPoints.Num(); i++) {\n\t\tfor (float tension = 0.0f; tension < 1.001f; tension += granularity) {\n\t\t\tfloat x = 0;\n\t\t\tfloat y = 0;\n\t\t\tfloat z = 0;\n\t\t\tfor (int j = 0; j < 4; j++) {\n\t\t\t\tx += controlPoints[i - (3 - j)]->x * calcSpline(j, tension);\n\t\t\t\ty += controlPoints[i - (3 - j)]->y * calcSpline(j, tension);\n\t\t\t\tz += controlPoints[i - (3 - j)]->z * calcSpline(j, tension);\n\t\t\t}\n\t\t\tsplinePoints.Append(new idVec3_t(x, y, z));\n\t\t}\n\t}\n\tdirty = false;\n\t//Com_Printf(\"Spline build took %f seconds\\n\", (float)(Sys_Milliseconds() - start) / 1000);\n}\n\n/*\nvoid idSplineList::draw(bool editMode) {\n\tint i;\n\tvec4_t yellow(1, 1, 0, 1);\n        \n\tif (controlPoints.Num() == 0) {\n\t\treturn;\n\t}\n\n\tif (dirty) {\n\t\tbuildSpline();\n\t}\n\n\n\tqglColor3fv(controlColor);\n\tqglPointSize(5);\n\t\n\tqglBegin(GL_POINTS);\n\tfor (i = 0; i < controlPoints.Num(); i++) {\n\t\tqglVertex3fv(*controlPoints[i]);\n\t}\n\tqglEnd();\n\t\n\tif (editMode) {\n\t\tfor(i = 0; i < controlPoints.Num(); i++) {\n\t\t\tglBox(activeColor, *controlPoints[i], 4);\n\t\t}\n\t}\n\n\t//Draw the curve\n\tqglColor3fv(pathColor);\n\tqglBegin(GL_LINE_STRIP);\n\tint count = splinePoints.Num();\n\tfor (i = 0; i < count; i++) {\n\t\tqglVertex3fv(*splinePoints[i]);\n\t}\n\tqglEnd();\n\n\tif (editMode) {\n\t\tqglColor3fv(segmentColor);\n\t\tqglPointSize(3);\n\t\tqglBegin(GL_POINTS);\n\t\tfor (i = 0; i < count; i++) {\n\t\t\tqglVertex3fv(*splinePoints[i]);\n\t\t}\n\t\tqglEnd();\n\t}\n\tif (count > 0) {\n\t\t//assert(activeSegment >=0 && activeSegment < count);\n\t\tif (activeSegment >=0 && activeSegment < count) {\n\t\t\tglBox(activeColor, *splinePoints[activeSegment], 6);\n\t\t\tglBox(yellow, *splinePoints[activeSegment], 8);\n\t\t}\n\t}\n\n}\n*/\n\nfloat idSplineList::totalDistance() {\n\n\tif (controlPoints.Num() == 0) {\n\t\treturn 0.0;\n\t}\n\n\tif (dirty) {\n\t\tbuildSpline();\n\t}\n\n\tfloat dist = 0.0;\n\tidVec3_t temp;\n\tint count = splinePoints.Num();\n\tfor(int i = 1; i < count; i++) {\n\t\ttemp = *splinePoints[i-1];\n\t\ttemp -= *splinePoints[i];\n\t\tdist += temp.Length();\n\t}\n\treturn dist;\n}\n\nvoid idSplineList::initPosition(long bt, long totalTime) {\n\n\tif (dirty) {\n\t\tbuildSpline();\n\t}\n\n\tif (splinePoints.Num() == 0) {\n\t\treturn;\n\t}\n\n\tbaseTime = bt;\n\ttime = totalTime;\n\n\t// calc distance to travel ( this will soon be broken into time segments )\n\tsplineTime.Clear();\n\tsplineTime.Append(bt);\n\tdouble dist = totalDistance();\n\tdouble distSoFar = 0.0;\n\tidVec3_t temp;\n\tint count = splinePoints.Num();\n\t//for(int i = 2; i < count - 1; i++) {\n\tfor(int i = 1; i < count; i++) {\n\t\ttemp = *splinePoints[i-1];\n\t\ttemp -= *splinePoints[i];\n\t\tdistSoFar += temp.Length();\n\t\tdouble percent = distSoFar / dist;\n\t\tpercent *= totalTime;\n\t\tsplineTime.Append(percent + bt);\n\t}\n\tassert(splineTime.Num() == splinePoints.Num());\n\tactiveSegment = 0;\n}\n\n\n\nfloat idSplineList::calcSpline(int step, float tension) {\n\tswitch(step) {\n\t\tcase 0:\treturn (pow(1 - tension, 3)) / 6;\n\t\tcase 1:\treturn (3 * pow(tension, 3) - 6 * pow(tension, 2) + 4) / 6;\n\t\tcase 2:\treturn (-3 * pow(tension, 3) + 3 * pow(tension, 2) + 3 * tension + 1) / 6;\n\t\tcase 3:\treturn pow(tension, 3) / 6;\n\t}\n\treturn 0.0;\n}\n\n\n\nvoid idSplineList::updateSelection(const idVec3_t &move) {\n\tif (selected) {\n\t\tdirty = true;\n\t\tVectorAdd(*selected, move, *selected);\n\t}\n}\n\n\nvoid idSplineList::setSelectedPoint(idVec3_t *p) {\n\tif (p) {\n\t\tp->Snap();\n\t\tfor(int i = 0; i < controlPoints.Num(); i++) {\n\t\t\tif (*p == *controlPoints[i]) {\n\t\t\t\tselected = controlPoints[i];\n\t\t\t}\n\t\t}\n\t} else {\n\t\tselected = NULL;\n\t}\n}\n\nconst idVec3_t *idSplineList::getPosition(long t) {\n\tstatic idVec3_t interpolatedPos;\n\t//static long lastTime = -1;\n\n\tint count = splineTime.Num();\n\tif (count == 0) {\n\t\treturn &zero;\n\t}\n\n\tCom_Printf(\"Time: %d\\n\", t);\n\tassert(splineTime.Num() == splinePoints.Num());\n\n\twhile (activeSegment < count) {\n\t\tif (splineTime[activeSegment] >= t) {\n\t\t\tif (activeSegment > 0 && activeSegment < count - 1) {\n\t\t\t\tdouble timeHi = splineTime[activeSegment + 1];\n\t\t\t\tdouble timeLo = splineTime[activeSegment - 1];\n\t\t\t\tdouble percent = (timeHi - t) / (timeHi - timeLo); \n\t\t\t\t// pick two bounding points\n\t\t\t\tidVec3_t v1 = *splinePoints[activeSegment-1];\n\t\t\t\tidVec3_t v2 = *splinePoints[activeSegment+1];\n\t\t\t\tv2 *= (1.0 - percent);\n\t\t\t\tv1 *= percent;\n\t\t\t\tv2 += v1;\n\t\t\t\tinterpolatedPos = v2;\n\t\t\t\treturn &interpolatedPos;\n\t\t\t}\n\t\t\treturn splinePoints[activeSegment];\n\t\t} else {\n\t\t\tactiveSegment++;\n\t\t}\n\t}\n\treturn splinePoints[count-1];\n}\n\nvoid idSplineList::parse(const char *(*text)  ) {\n\tconst char *token;\n\t//Com_MatchToken( text, \"{\" );\n\tdo {\n\t\ttoken = Com_Parse( text );\n\t\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( !Q_stricmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdo {\n\t\t\t// if token is not a brace, it is a key for a key/value pair\n\t\t\tif ( !token[0] || !Q_stricmp (token, \"(\") || !Q_stricmp(token, \"}\")) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tCom_UngetToken();\n\t\t\tidStr key = Com_ParseOnLine(text);\n\t\t\tconst char *token = Com_Parse(text);\n\t\t\tif (Q_stricmp(key.c_str(), \"granularity\") == 0) {\n\t\t\t\tgranularity = atof(token);\n\t\t\t} else if (Q_stricmp(key.c_str(), \"name\") == 0) {\n\t\t\t\tname = token;\n\t\t\t}\n\t\t\ttoken = Com_Parse(text);\n\n\t\t} while (1);\n\n\t\tif ( !Q_stricmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tCom_UngetToken();\n\t\t// read the control point\n\t\tidVec3_t point;\n\t\tCom_Parse1DMatrix( text, 3, point );\n\t\taddPoint(point.x, point.y, point.z);\n\t} while (1);\n \n\t//Com_UngetToken();\n\t//Com_MatchToken( text, \"}\" );\n\tdirty = true;\n}\n\nvoid idSplineList::write(fileHandle_t file, const char *p) {\n\tidStr s = va(\"\\t\\t%s {\\n\", p);\n\tFS_Write(s.c_str(), s.length(), file);\n\t//s = va(\"\\t\\tname %s\\n\", name.c_str());\n\t//FS_Write(s.c_str(), s.length(), file);\n\ts = va(\"\\t\\t\\tgranularity %f\\n\", granularity);\n\tFS_Write(s.c_str(), s.length(), file);\n\tint count = controlPoints.Num();\n\tfor (int i = 0; i < count; i++) {\n\t\ts = va(\"\\t\\t\\t( %f %f %f )\\n\", controlPoints[i]->x, controlPoints[i]->y, controlPoints[i]->z);\n\t\tFS_Write(s.c_str(), s.length(), file);\n\t}\n\ts = \"\\t\\t}\\n\";\n\tFS_Write(s.c_str(), s.length(), file);\n}\n\n\nvoid idCameraDef::getActiveSegmentInfo(int segment, idVec3_t &origin, idVec3_t &direction, float *fov) {\n#if 0\n\tif (!cameraSpline.validTime()) {\n\t\tbuildCamera();\n\t}\n\tdouble d = (double)segment / numSegments();\n\tgetCameraInfo(d * totalTime * 1000, origin, direction, fov);\n#endif\n/*\n\tif (!cameraSpline.validTime()) {\n\t\tbuildCamera();\n\t}\n\torigin = *cameraSpline.getSegmentPoint(segment);\n\t\n\n\tidVec3_t temp;\n\n\tint numTargets = getTargetSpline()->controlPoints.Num();\n\tint count = cameraSpline.splineTime.Num();\n\tif (numTargets == 0) {\n\t\t// follow the path\n\t\tif (cameraSpline.getActiveSegment() < count - 1) {\n\t\t\ttemp = *cameraSpline.splinePoints[cameraSpline.getActiveSegment()+1];\n\t\t}\n\t} else if (numTargets == 1) {\n\t\ttemp = *getTargetSpline()->controlPoints[0];\n\t} else {\n\t\ttemp = *getTargetSpline()->getSegmentPoint(segment);\n\t}\n\n\ttemp -= origin;\n\ttemp.Normalize();\n\tdirection = temp;\n*/\n}\n\nbool idCameraDef::getCameraInfo(long time, idVec3_t &origin, idVec3_t &direction, float *fv) {\n\n\n\tif ((time - startTime) / 1000 > totalTime) {\n\t\treturn false;\n\t}\n\n\n\tfor (int i = 0; i < events.Num(); i++) {\n\t\tif (time >= startTime + events[i]->getTime() && !events[i]->getTriggered()) {\n\t\t\tevents[i]->setTriggered(true);\n\t\t\tif (events[i]->getType() == idCameraEvent::EVENT_TARGET) {\n\t\t\t\tsetActiveTargetByName(events[i]->getParam());\n\t\t\t\tgetActiveTarget()->start(startTime + events[i]->getTime());\n\t\t\t\t//Com_Printf(\"Triggered event switch to target: %s\\n\",events[i]->getParam());\n\t\t\t} else if (events[i]->getType() == idCameraEvent::EVENT_TRIGGER) {\n\t\t\t\t//idEntity *ent = NULL;\n\t\t\t\t//ent = level.FindTarget( ent, events[i]->getParam());\n\t\t\t\t//if (ent) {\n\t\t\t\t//\tent->signal( SIG_TRIGGER );\n\t\t\t\t//\tent->ProcessEvent( &EV_Activate, world );\n\t\t\t\t//}\n\t\t\t} else if (events[i]->getType() == idCameraEvent::EVENT_FOV) {\n\t\t\t\t//*fv = fov = atof(events[i]->getParam());\n\t\t\t} else if (events[i]->getType() == idCameraEvent::EVENT_STOP) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\n\torigin = *cameraPosition->getPosition(time);\n\t\n\t*fv = fov.getFOV(time);\n\n\tidVec3_t temp = origin;\n\n\tint numTargets = targetPositions.Num();\n\tif (numTargets == 0) {\n/*\n\t\t// follow the path\n\t\tif (cameraSpline.getActiveSegment() < count - 1) {\n\t\t\ttemp = *cameraSpline.splinePoints[cameraSpline.getActiveSegment()+1];\n\t\t\tif (temp == origin) {\n\t\t\t\tint index = cameraSpline.getActiveSegment() + 2;\n\t\t\t\twhile (temp == origin && index < count - 1) {\n\t\t\t\t\ttemp = *cameraSpline.splinePoints[index++];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n*/\n\t} else {\n\t\ttemp = *getActiveTarget()->getPosition(time);\n\t}\n\t\n\ttemp -= origin;\n\ttemp.Normalize();\n\tdirection = temp;\n\n\treturn true;\n}\n\nbool idCameraDef::waitEvent(int index) {\n\t//for (int i = 0; i < events.Num(); i++) {\n\t//\tif (events[i]->getSegment() == index && events[i]->getType() == idCameraEvent::EVENT_WAIT) {\n\t//\t\treturn true;\n\t//\t}\n    //}\n\treturn false;\n}\n\n\n#define NUM_CCELERATION_SEGS 10\n#define CELL_AMT 5\n\nvoid idCameraDef::buildCamera() {\n\tint i;\n\t//int lastSwitch = 0;\n\tidList<float> waits;\n\tidList<int> targets;\n\n\ttotalTime = baseTime;\n\tcameraPosition->setTime(totalTime * 1000);\n\t// we have a base time layout for the path and the target path\n\t// now we need to layer on any wait or speed changes\n\tfor (i = 0; i < events.Num(); i++) {\n\t\t//idCameraEvent *ev = events[i];\n\t\tevents[i]->setTriggered(false);\n\t\tswitch (events[i]->getType()) {\n\t\t\tcase idCameraEvent::EVENT_TARGET : {\n\t\t\t\ttargets.Append(i);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase idCameraEvent::EVENT_WAIT : {\n\t\t\t\twaits.Append(atof(events[i]->getParam()));\n\t\t\t\tcameraPosition->addVelocity(events[i]->getTime(), atof(events[i]->getParam()) * 1000, 0);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase idCameraEvent::EVENT_TARGETWAIT : {\n\t\t\t\t//targetWaits.Append(i);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase idCameraEvent::EVENT_SPEED : {\n/*\n\t\t\t\t// take the average delay between up to the next five segments\n\t\t\t\tfloat adjust = atof(events[i]->getParam());\n\t\t\t\tint index = events[i]->getSegment();\n\t\t\t\ttotal = 0;\n\t\t\t\tcount = 0;\n\n\t\t\t\t// get total amount of time over the remainder of the segment\n\t\t\t\tfor (j = index; j < cameraSpline.numSegments() - 1; j++) {\n\t\t\t\t\ttotal += cameraSpline.getSegmentTime(j + 1) - cameraSpline.getSegmentTime(j);\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\n\t\t\t\t// multiply that by the adjustment\n\t\t\t\tdouble newTotal = total * adjust;\n\t\t\t\t// what is the difference.. \n\t\t\t\tnewTotal -= total;\n\t\t\t\ttotalTime += newTotal / 1000;\n\n\t\t\t\t// per segment difference\n\t\t\t\tnewTotal /= count;\n\t\t\t\tint additive = newTotal;\n\n\t\t\t\t// now propogate that difference out to each segment\n\t\t\t\tfor (j = index; j < cameraSpline.numSegments(); j++) {\n\t\t\t\t\tcameraSpline.addSegmentTime(j, additive);\n\t\t\t\t\tadditive += newTotal;\n\t\t\t\t}\n\t\t\t\tbreak;\n*/\n\t\t\t}\n    default: break; // FIXME: what about other idCameraEvent?\n\t\t}\n\t}\n\n\n\tfor (i = 0; i < waits.Num(); i++) {\n\t\ttotalTime += waits[i];\n\t}\n\n\t// on a new target switch, we need to take time to this point ( since last target switch ) \n\t// and allocate it across the active target, then reset time to this point\n\tlong timeSoFar = 0;\n\tlong total = (int)(totalTime * 1000);\n\tfor (i = 0; i < targets.Num(); i++) {\n\t\tlong t;\n\t\tif (i < targets.Num() - 1) {\n\t\t\tt = events[targets[i+1]]->getTime();\n\t\t} else {\n\t\t\tt = total - timeSoFar;\n\t\t}\n\t\t// t is how much time to use for this target\n\t\tsetActiveTargetByName(events[targets[i]]->getParam());\n\t\tgetActiveTarget()->setTime(t);\n\t\ttimeSoFar += t;\n\t}\n\n\t\n}\n\nvoid idCameraDef::startCamera(long t) {\n\tbuildCamera();\n\tcameraPosition->start(t);\n\t//for (int i = 0; i < targetPositions.Num(); i++) {\n\t//\ttargetPositions[i]->\n\t//}\n\tstartTime = t;\n\tcameraRunning = true;\n}\n\n\nvoid idCameraDef::parse(const char *(*text)  ) {\n\n\tconst char\t*token;\n\tdo {\n\t\ttoken = Com_Parse( text );\n\t\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( !Q_stricmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (Q_stricmp(token, \"time\") == 0) {\n\t\t\tbaseTime = Com_ParseFloat(text);\n\t\t}\n\n\t\tif (Q_stricmp(token, \"camera_fixed\") == 0) {\n\t\t\tcameraPosition = new idFixedPosition();\n\t\t\tcameraPosition->parse(text);\n\t\t}\n\n\t\tif (Q_stricmp(token, \"camera_interpolated\") == 0) {\n\t\t\tcameraPosition = new idInterpolatedPosition();\n\t\t\tcameraPosition->parse(text);\n\t\t}\n\n\t\tif (Q_stricmp(token, \"camera_spline\") == 0) {\n\t\t\tcameraPosition = new idSplinePosition();\n\t\t\tcameraPosition->parse(text);\n\t\t}\n\n\t\tif (Q_stricmp(token, \"target_fixed\") == 0) {\n\t\t\tidFixedPosition *pos = new idFixedPosition();\n\t\t\tpos->parse(text);\n\t\t\ttargetPositions.Append(pos);\n\t\t}\n\t\t\n\t\tif (Q_stricmp(token, \"target_interpolated\") == 0) {\n\t\t\tidInterpolatedPosition *pos = new idInterpolatedPosition();\n\t\t\tpos->parse(text);\n\t\t\ttargetPositions.Append(pos);\n\t\t}\n\n\t\tif (Q_stricmp(token, \"target_spline\") == 0) {\n\t\t\tidSplinePosition *pos = new idSplinePosition();\n\t\t\tpos->parse(text);\n\t\t\ttargetPositions.Append(pos);\n\t\t}\n\n\t\tif (Q_stricmp(token, \"fov\") == 0) {\n\t\t\tfov.parse(text);\n\t\t}\n\n\t\tif (Q_stricmp(token, \"event\") == 0) {\n\t\t\tidCameraEvent *event = new idCameraEvent();\n\t\t\tevent->parse(text);\n\t\t\taddEvent(event);\n\t\t}\n\n\n\t} while (1);\n\n\tCom_UngetToken();\n\tCom_MatchToken( text, \"}\" );\n\n}\n\nqboolean idCameraDef::load(const char *filename) {\n\tchar *buf;\n\tconst char *buf_p;\n\t//int length = \n  FS_ReadFile( filename, (void **)&buf );\n\tif ( !buf ) {\n\t\treturn qfalse;\n\t}\n\n\tclear();\n\tCom_BeginParseSession( filename );\n\tbuf_p = buf;\n\tparse(&buf_p);\n\tCom_EndParseSession();\n\tFS_FreeFile( buf );\n\n\treturn qtrue;\n}\n\nvoid idCameraDef::save(const char *filename) {\n\tfileHandle_t file = FS_FOpenFileWrite(filename);\n\tif (file) {\n\t\tint i;\n\t\tidStr s = \"cameraPathDef { \\n\"; \n\t\tFS_Write(s.c_str(), s.length(), file);\n\t\ts = va(\"\\ttime %f\\n\", baseTime);\n\t\tFS_Write(s.c_str(), s.length(), file);\n\n\t\tcameraPosition->write(file, va(\"camera_%s\",cameraPosition->typeStr()));\n\n\t\tfor (i = 0; i < numTargets(); i++) {\n\t\t\ttargetPositions[i]->write(file, va(\"target_%s\", targetPositions[i]->typeStr()));\n\t\t}\n\n\t\tfor (i = 0; i < events.Num(); i++) {\n\t\t\tevents[i]->write(file, \"event\");\n\t\t}\n\n\t\tfov.write(file, \"fov\");\n\n\t\ts = \"}\\n\";\n\t\tFS_Write(s.c_str(), s.length(), file);\n\t}\n\tFS_FCloseFile(file);\n}\n\nint idCameraDef::sortEvents(const void *p1, const void *p2) {\n\tidCameraEvent *ev1 = (idCameraEvent*)(p1);\n\tidCameraEvent *ev2 = (idCameraEvent*)(p2);\n\n\tif (ev1->getTime() > ev2->getTime()) {\n\t\treturn -1;\n\t}\n\tif (ev1->getTime() < ev2->getTime()) {\n\t\treturn 1;\n\t}\n\treturn 0; \n}\n\nvoid idCameraDef::addEvent(idCameraEvent *event) {\n\tevents.Append(event);\n\t//events.Sort(&sortEvents);\n\n}\nvoid idCameraDef::addEvent(idCameraEvent::eventType t, const char *param, long time) {\n\taddEvent(new idCameraEvent(t, param, time));\n\tbuildCamera();\n}\n\n\nconst char *idCameraEvent::eventStr[] = {\n\t\"NA\",\n\t\"WAIT\",\n\t\"TARGETWAIT\",\n\t\"SPEED\",\n\t\"TARGET\",\n\t\"SNAPTARGET\",\n\t\"FOV\",\n\t\"SCRIPT\",\n\t\"TRIGGER\",\n\t\"STOP\"\n};\n\nvoid idCameraEvent::parse(const char *(*text)  ) {\n\tconst char *token;\n\tCom_MatchToken( text, \"{\" );\n\tdo {\n\t\ttoken = Com_Parse( text );\n\t\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( !strcmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// here we may have to jump over brush epairs ( only used in editor )\n\t\tdo {\n\t\t\t// if token is not a brace, it is a key for a key/value pair\n\t\t\tif ( !token[0] || !strcmp (token, \"(\") || !strcmp(token, \"}\")) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tCom_UngetToken();\n\t\t\tidStr key = Com_ParseOnLine(text);\n\t\t\tconst char *token = Com_Parse(text);\n\t\t\tif (Q_stricmp(key.c_str(), \"type\") == 0) {\n\t\t\t\ttype = static_cast<idCameraEvent::eventType>(atoi(token));\n\t\t\t} else if (Q_stricmp(key.c_str(), \"param\") == 0) {\n\t\t\t\tparamStr = token;\n\t\t\t} else if (Q_stricmp(key.c_str(), \"time\") == 0) {\n\t\t\t\ttime = atoi(token);\n\t\t\t}\n\t\t\ttoken = Com_Parse(text);\n\n\t\t} while (1);\n\n\t\tif ( !strcmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t} while (1);\n \n\tCom_UngetToken();\n\tCom_MatchToken( text, \"}\" );\n}\n\nvoid idCameraEvent::write(fileHandle_t file, const char *name) {\n\tidStr s = va(\"\\t%s {\\n\", name);\n\tFS_Write(s.c_str(), s.length(), file);\n\ts = va(\"\\t\\ttype %d\\n\", static_cast<int>(type));\n\tFS_Write(s.c_str(), s.length(), file);\n\ts = va(\"\\t\\tparam %s\\n\", paramStr.c_str());\n\tFS_Write(s.c_str(), s.length(), file);\n\ts = va(\"\\t\\ttime %d\\n\", time);\n\tFS_Write(s.c_str(), s.length(), file);\n\ts = \"\\t}\\n\";\n\tFS_Write(s.c_str(), s.length(), file);\n}\n\n\nconst char *idCameraPosition::positionStr[] = {\n\t\"Fixed\",\n\t\"Interpolated\",\n\t\"Spline\",\n};\n\n\n\nconst idVec3_t *idInterpolatedPosition::getPosition(long t) { \n\tstatic idVec3_t interpolatedPos;\n\n\tfloat velocity = getVelocity(t);\n\tfloat timePassed = t - lastTime;\n\tlastTime = t;\n\n\t// convert to seconds\t\n\ttimePassed /= 1000;\n\n\tfloat distToTravel = timePassed *= velocity;\n\n\tidVec3_t temp = startPos;\n\ttemp -= endPos;\n\tfloat distance = temp.Length();\n\n\tdistSoFar += distToTravel;\n\tfloat percent = (float)(distSoFar) / distance;\n\n\tif (percent > 1.0) {\n\t\tpercent = 1.0;\n\t} else if (percent < 0.0) {\n\t\tpercent = 0.0;\n\t}\n\n\t// the following line does a straigt calc on percentage of time\n\t// float percent = (float)(startTime + time - t) / time;\n\n\tidVec3_t v1 = startPos;\n\tidVec3_t v2 = endPos;\n\tv1 *= (1.0 - percent);\n\tv2 *= percent;\n\tv1 += v2;\n\tinterpolatedPos = v1;\n\treturn &interpolatedPos;\n}\n\n\nvoid idCameraFOV::parse(const char *(*text)  ) {\n\tconst char *token;\n\tCom_MatchToken( text, \"{\" );\n\tdo {\n\t\ttoken = Com_Parse( text );\n\t\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( !strcmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// here we may have to jump over brush epairs ( only used in editor )\n\t\tdo {\n\t\t\t// if token is not a brace, it is a key for a key/value pair\n\t\t\tif ( !token[0] || !strcmp (token, \"(\") || !strcmp(token, \"}\")) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tCom_UngetToken();\n\t\t\tidStr key = Com_ParseOnLine(text);\n\t\t\tconst char *token = Com_Parse(text);\n\t\t\tif (Q_stricmp(key.c_str(), \"fov\") == 0) {\n\t\t\t\tfov = atof(token);\n\t\t\t} else if (Q_stricmp(key.c_str(), \"startFOV\") == 0) {\n\t\t\t\tstartFOV = atof(token);\n\t\t\t} else if (Q_stricmp(key.c_str(), \"endFOV\") == 0) {\n\t\t\t\tendFOV = atof(token);\n\t\t\t} else if (Q_stricmp(key.c_str(), \"time\") == 0) {\n\t\t\t\ttime = atoi(token);\n\t\t\t}\n\t\t\ttoken = Com_Parse(text);\n\n\t\t} while (1);\n\n\t\tif ( !strcmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t} while (1);\n \n\tCom_UngetToken();\n\tCom_MatchToken( text, \"}\" );\n}\n\nbool idCameraPosition::parseToken(const char *key, const char *(*text)) {\n\tconst char *token = Com_Parse(text);\n\tif (Q_stricmp(key, \"time\") == 0) {\n\t\ttime = atol(token);\n\t\treturn true;\n\t} else if (Q_stricmp(key, \"type\") == 0) {\n\t\ttype = static_cast<idCameraPosition::positionType>(atoi(token));\n\t\treturn true;\n\t} else if (Q_stricmp(key, \"velocity\") == 0) {\n\t\tlong t = atol(token);\n\t\ttoken = Com_Parse(text);\n\t\tlong d = atol(token);\n\t\ttoken = Com_Parse(text);\n\t\tfloat s = atof(token);\n\t\taddVelocity(t, d, s);\n\t\treturn true;\n\t} else if (Q_stricmp(key, \"baseVelocity\") == 0) {\n\t\tbaseVelocity = atof(token);\n\t\treturn true;\n\t} else if (Q_stricmp(key, \"name\") == 0) {\n\t\tname = token;\n\t\treturn true;\n\t} else if (Q_stricmp(key, \"time\") == 0) {\n\t\ttime = atoi(token);\n\t\treturn true;\n\t}\n\tCom_UngetToken();\n\treturn false;\n}\n\n\n\nvoid idFixedPosition::parse(const char *(*text)  ) {\n\tconst char *token;\n\tCom_MatchToken( text, \"{\" );\n\tdo {\n\t\ttoken = Com_Parse( text );\n\t\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( !strcmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// here we may have to jump over brush epairs ( only used in editor )\n\t\tdo {\n\t\t\t// if token is not a brace, it is a key for a key/value pair\n\t\t\tif ( !token[0] || !strcmp (token, \"(\") || !strcmp(token, \"}\")) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tCom_UngetToken();\n\t\t\tidStr key = Com_ParseOnLine(text);\n\t\t\t\n\t\t\tconst char *token = Com_Parse(text);\n\t\t\tif (Q_stricmp(key.c_str(), \"pos\") == 0) {\n\t\t\t\tCom_UngetToken();\n\t\t\t\tCom_Parse1DMatrix( text, 3, pos );\n\t\t\t} else {\n\t\t\t\tCom_UngetToken();\n\t\t\t\tidCameraPosition::parseToken(key.c_str(), text);\t\n\t\t\t}\n\t\t\ttoken = Com_Parse(text);\n\n\t\t} while (1);\n\n\t\tif ( !strcmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t} while (1);\n \n\tCom_UngetToken();\n\tCom_MatchToken( text, \"}\" );\n}\n\nvoid idInterpolatedPosition::parse(const char *(*text)  ) {\n\tconst char *token;\n\tCom_MatchToken( text, \"{\" );\n\tdo {\n\t\ttoken = Com_Parse( text );\n\t\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( !strcmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// here we may have to jump over brush epairs ( only used in editor )\n\t\tdo {\n\t\t\t// if token is not a brace, it is a key for a key/value pair\n\t\t\tif ( !token[0] || !strcmp (token, \"(\") || !strcmp(token, \"}\")) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tCom_UngetToken();\n\t\t\tidStr key = Com_ParseOnLine(text);\n\t\t\t\n\t\t\tconst char *token = Com_Parse(text);\n\t\t\tif (Q_stricmp(key.c_str(), \"startPos\") == 0) {\n\t\t\t\tCom_UngetToken();\n\t\t\t\tCom_Parse1DMatrix( text, 3, startPos );\n\t\t\t} else if (Q_stricmp(key.c_str(), \"endPos\") == 0) {\n\t\t\t\tCom_UngetToken();\n\t\t\t\tCom_Parse1DMatrix( text, 3, endPos );\n\t\t\t} else {\n\t\t\t\tCom_UngetToken();\n\t\t\t\tidCameraPosition::parseToken(key.c_str(), text);\t\n\t\t\t}\n\t\t\ttoken = Com_Parse(text);\n\n\t\t} while (1);\n\n\t\tif ( !strcmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t} while (1);\n \n\tCom_UngetToken();\n\tCom_MatchToken( text, \"}\" );\n}\n\n\nvoid idSplinePosition::parse(const char *(*text)  ) {\n\tconst char *token;\n\tCom_MatchToken( text, \"{\" );\n\tdo {\n\t\ttoken = Com_Parse( text );\n\t\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( !strcmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// here we may have to jump over brush epairs ( only used in editor )\n\t\tdo {\n\t\t\t// if token is not a brace, it is a key for a key/value pair\n\t\t\tif ( !token[0] || !strcmp (token, \"(\") || !strcmp(token, \"}\")) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tCom_UngetToken();\n\t\t\tidStr key = Com_ParseOnLine(text);\n\t\t\t\n\t\t\tconst char *token = Com_Parse(text);\n\t\t\tif (Q_stricmp(key.c_str(), \"target\") == 0) {\n\t\t\t\ttarget.parse(text);\n\t\t\t} else {\n\t\t\t\tCom_UngetToken();\n\t\t\t\tidCameraPosition::parseToken(key.c_str(), text);\t\n\t\t\t}\n\t\t\ttoken = Com_Parse(text);\n\n\t\t} while (1);\n\n\t\tif ( !strcmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t} while (1);\n \n\tCom_UngetToken();\n\tCom_MatchToken( text, \"}\" );\n}\n\n\n\nvoid idCameraFOV::write(fileHandle_t file, const char *p) {\n\tidStr s = va(\"\\t%s {\\n\", p);\n\tFS_Write(s.c_str(), s.length(), file);\n\t\n\ts = va(\"\\t\\tfov %f\\n\", fov);\n\tFS_Write(s.c_str(), s.length(), file);\n\n\ts = va(\"\\t\\tstartFOV %f\\n\", startFOV);\n\tFS_Write(s.c_str(), s.length(), file);\n\n\ts = va(\"\\t\\tendFOV %f\\n\", endFOV);\n\tFS_Write(s.c_str(), s.length(), file);\n\n\ts = va(\"\\t\\ttime %i\\n\", time);\n\tFS_Write(s.c_str(), s.length(), file);\n\n\ts = \"\\t}\\n\";\n\tFS_Write(s.c_str(), s.length(), file);\n}\n\n\nvoid idCameraPosition::write(fileHandle_t file, const char *p) {\n\t\n\tidStr s = va(\"\\t\\ttime %i\\n\", time);\n\tFS_Write(s.c_str(), s.length(), file);\n\n\ts = va(\"\\t\\ttype %i\\n\", static_cast<int>(type));\n\tFS_Write(s.c_str(), s.length(), file);\n\n\ts = va(\"\\t\\tname %s\\n\", name.c_str());\n\tFS_Write(s.c_str(), s.length(), file);\n\n\ts = va(\"\\t\\tbaseVelocity %f\\n\", baseVelocity);\n\tFS_Write(s.c_str(), s.length(), file);\n\n\tfor (int i = 0; i < velocities.Num(); i++) {\n\t\ts = va(\"\\t\\tvelocity %i %i %f\\n\", velocities[i]->startTime, velocities[i]->time, velocities[i]->speed);\n\t\tFS_Write(s.c_str(), s.length(), file);\n\t}\n\n}\n\nvoid idFixedPosition::write(fileHandle_t file, const char *p) {\n\tidStr s = va(\"\\t%s {\\n\", p);\n\tFS_Write(s.c_str(), s.length(), file);\n\tidCameraPosition::write(file, p);\n\ts = va(\"\\t\\tpos ( %f %f %f )\\n\", pos.x, pos.y, pos.z);\n\tFS_Write(s.c_str(), s.length(), file);\n\ts = \"\\t}\\n\";\n\tFS_Write(s.c_str(), s.length(), file);\n}\n\nvoid idInterpolatedPosition::write(fileHandle_t file, const char *p) {\n\tidStr s = va(\"\\t%s {\\n\", p);\n\tFS_Write(s.c_str(), s.length(), file);\n\tidCameraPosition::write(file, p);\n\ts = va(\"\\t\\tstartPos ( %f %f %f )\\n\", startPos.x, startPos.y, startPos.z);\n\tFS_Write(s.c_str(), s.length(), file);\n\ts = va(\"\\t\\tendPos ( %f %f %f )\\n\", endPos.x, endPos.y, endPos.z);\n\tFS_Write(s.c_str(), s.length(), file);\n\ts = \"\\t}\\n\";\n\tFS_Write(s.c_str(), s.length(), file);\n}\n\nvoid idSplinePosition::write(fileHandle_t file, const char *p) {\n\tidStr s = va(\"\\t%s {\\n\", p);\n\tFS_Write(s.c_str(), s.length(), file);\n\tidCameraPosition::write(file, p);\n\ttarget.write(file, \"target\");\n\ts = \"\\t}\\n\";\n\tFS_Write(s.c_str(), s.length(), file);\n}\n\nvoid idCameraDef::addTarget(const char *name, idCameraPosition::positionType type) {\n\t//const char *text = (name == NULL) ? va(\"target0%d\", numTargets()+1) : name; // TTimo: unused\n\tidCameraPosition *pos = newFromType(type);\n\tif (pos) {\n\t\tpos->setName(name);\n\t\ttargetPositions.Append(pos);\n\t\tactiveTarget = numTargets()-1;\n\t\tif (activeTarget == 0) {\n\t\t\t// first one\n\t\t\taddEvent(idCameraEvent::EVENT_TARGET, name, 0);\n\t\t}\n\t}\n}\n\n\n\nidCameraDef camera;\n\nextern \"C\" {\nqboolean loadCamera(const char *name) {\n  camera.clear();\n  return static_cast<qboolean>(camera.load(name));\n}\n\nqboolean getCameraInfo(int time, float *origin, float*angles) {\n\tidVec3_t dir, org;\n\torg[0] = origin[0];\n\torg[1] = origin[1];\n\torg[2] = origin[2];\n\tfloat fov = 90;\n\tif (camera.getCameraInfo(time, org, dir, &fov)) {\n\t\torigin[0] = org[0];\n\t\torigin[1] = org[1];\n\t\torigin[2] = org[2];\n\t\tangles[1] = atan2 (dir[1], dir[0])*180/3.14159;\n\t\tangles[0] = asin (dir[2])*180/3.14159;\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\nvoid startCamera(int time) {\n\tcamera.startCamera(time);\n}\n\n}\n\n\n"
  },
  {
    "path": "code/splines/splines.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __SPLINES_H\n#define __SPLINES_H\n\nextern \"C\" {\n#ifdef Q3RADIANT\n#include \"../qgl.h\"\n#else\n//#include \"../renderer/qgl.h\"\n#endif\n}\n#include \"util_list.h\"\n#include \"util_str.h\"\n#include \"math_vector.h\"\n\ntypedef int fileHandle_t;\n\n//extern void glBox(idVec3_t &color, idVec3_t &point, float size);\n//extern void glLabeledPoint(idVec3_t &color, idVec3_t &point, float size, const char *label);\n\nstatic vec4_t blue(0, 0, 1, 1);\nstatic vec4_t red(1, 0, 0, 1);\n\nclass idPointListInterface {\npublic:\n\tidPointListInterface() {\n\t\tselectedPoints.Clear();\n\t}\n\tvirtual ~idPointListInterface() {}\n\t\n\tvirtual int numPoints() {\n\t\treturn 0;\n\t}\n\t\n\tvirtual void addPoint(const float x, const float y, const float z) {}\n\tvirtual void addPoint(const idVec3_t &v) {}\n\tvirtual void removePoint(int index) {}\n\tvirtual idVec3_t *getPoint(int index) { return NULL; }\n\t\n\tint\tselectPointByRay(float ox, float oy, float oz, float dx, float dy, float dz, bool single) {\n\t\tidVec3_t origin(ox, oy, oz);\n\t\tidVec3_t dir(dx, dy, dz);\n\t\treturn selectPointByRay(origin, dir, single);\n\t}\n\n\tint\tselectPointByRay(const idVec3_t origin, const idVec3_t direction, bool single) {\n\t\tint\t\ti, besti, count;\n\t\tfloat\td, bestd;\n\t\tidVec3_t\ttemp, temp2;\n\n\t\t// find the point closest to the ray\n\t\tbesti = -1;\n\t\tbestd = 8;\n\t\tcount = numPoints();\n\n\t\tfor (i=0; i < count; i++) {\n\t\t\ttemp = *getPoint(i);\n\t\t\ttemp2 = temp;\n\t\t\ttemp -= origin;\n\t\t\td = DotProduct(temp, direction);\n\t\t\t__VectorMA (origin, d, direction, temp);\n\t\t\ttemp2 -= temp;\n\t\t\td = temp2.Length();\n\t\t\tif (d <= bestd) {\n\t\t\t\tbestd = d;\n\t\t\t\tbesti = i;\n\t\t\t}\n\t\t}\n\n\t\tif (besti >= 0) {\n\t\t\tselectPoint(besti, single);\n\t\t}\n\n\t\treturn besti;\n\t}\n\n\tint isPointSelected(int index) {\n\t\tint count = selectedPoints.Num();\n\t\tfor (int i = 0; i < count; i++) {\n\t\t\tif (selectedPoints[i] == index) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t}\n\t\n\tint selectPoint(int index, bool single) {\n\t\tif (index >= 0 && index < numPoints()) {\n\t\t\tif (single) {\n\t\t\t\tdeselectAll();\n\t\t\t} else {\n\t\t\t\tif (isPointSelected(index) >= 0) {\n\t\t\t\t\tselectedPoints.Remove(index);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn selectedPoints.Append(index);\n\t\t}\n\t\treturn -1;\n\t}\n\t\n\tvoid selectAll() {\n\t\tselectedPoints.Clear();\n\t\tfor (int i = 0; i < numPoints(); i++) {\n\t\t\tselectedPoints.Append(i);\n\t\t}\n\t}\n\n\tvoid deselectAll() {\n\t\tselectedPoints.Clear();\n\t}\n\n\tvirtual void updateSelection(float x, float y, float z) {\n\t\tidVec3_t move(x, y, z);\n\t\tupdateSelection(move);\n\t}\n\n\tvirtual void updateSelection(const idVec3_t &move) {\n\t\tint count = selectedPoints.Num();\n\t\tfor (int i = 0; i < count; i++) {\n\t\t\t*getPoint(selectedPoints[i]) += move;\n\t\t}\n\t}\n/*\n\tvoid drawSelection() {\n\t\tint count = selectedPoints.Num();\n\t\tfor (int i = 0; i < count; i++) {\n\t\t\tglBox(red, *getPoint(selectedPoints[i]), 4);\n\t\t}\n\t}\n*/\nprotected:\n\tidList<int> selectedPoints;\n\n};\n\n\nclass idSplineList {\n\npublic:\n\n\tidSplineList() {\n\t\tclear();\n\t}\n\n\tidSplineList(const char *p) {\n\t\tclear();\n\t\tname = p;\n\t};\n\n\t~idSplineList() {\n\t\tclear();\n\t};\n\n\tvoid clearControl() {\n\t\tfor (int i = 0; i < controlPoints.Num(); i++) {\n\t\t\tdelete controlPoints[i];\n\t\t}\n\t\tcontrolPoints.Clear();\n\t}\n\n\tvoid clearSpline() {\n\t\tfor (int i = 0; i < splinePoints.Num(); i++) {\n\t\t\tdelete splinePoints[i];\n\t\t}\n\t\tsplinePoints.Clear();\n\t}\n\n\tvoid parse(const char *(*text));\n\tvoid write(fileHandle_t file, const char *name);\n\n\tvoid clear() {\n\t\tclearControl();\n\t\tclearSpline();\n\t\tsplineTime.Clear();\n\t\tselected = NULL;\n\t\tdirty = true;\n\t\tactiveSegment = 0;\n\t\tgranularity = 0.025;\n\t\tpathColor.set(1.0, 0.5, 0.0);\n\t\tcontrolColor.set(0.7, 0.0, 1.0);\n\t\tsegmentColor.set(0.0, 0.0, 1.0);\n\t\tactiveColor.set(1.0, 0.0, 0.0);\n\t}\n\n\tvoid initPosition(long startTime, long totalTime);\n\tconst idVec3_t *getPosition(long time);\n\n\n//\tvoid draw(bool editMode);\n\tvoid addToRenderer();\n\n\tvoid setSelectedPoint(idVec3_t *p);\n\tidVec3_t *getSelectedPoint() {\n\t  return selected;\n\t}\n\n\tvoid addPoint(const idVec3_t &v) {\n\t\tcontrolPoints.Append(new idVec3_t(v));\n\t\tdirty = true;\n\t}\n\n\tvoid addPoint(float x, float y, float z) {\n\t\tcontrolPoints.Append(new idVec3_t(x, y, z));\n\t\tdirty = true;\n\t}\n\n\tvoid updateSelection(const idVec3_t &move);\n\n\tvoid startEdit() {\n\t\teditMode = true;\n\t}\n\t\t\n\tvoid stopEdit() {\n\t\teditMode = false;\n\t}\n\n\tvoid buildSpline();\n\n\tvoid setGranularity(float f) {\n\t\tgranularity = f;\n\t}\n\n\tfloat getGranularity() {\n\t\treturn granularity;\n\t}\n\n\tint numPoints() {\n\t\treturn controlPoints.Num();\n\t}\n\n\tidVec3_t *getPoint(int index) {\n\t\tassert(index >= 0 && index < controlPoints.Num());\n\t\treturn controlPoints[index];\n\t}\n\n\tidVec3_t *getSegmentPoint(int index) {\n\t\tassert(index >= 0 && index < splinePoints.Num());\n\t\treturn splinePoints[index];\n\t}\n\n\n\tvoid setSegmentTime(int index, int time) {\n\t\tassert(index >= 0 && index < splinePoints.Num());\n\t\tsplineTime[index] = time;\n\t}\n\n\tdouble getSegmentTime(int index) {\n\t\tassert(index >= 0 && index < splinePoints.Num());\n\t\treturn splineTime[index];\n\t}\n\tvoid addSegmentTime(int index, int time) {\n\t\tassert(index >= 0 && index < splinePoints.Num());\n\t\tsplineTime[index] += time;\n\t}\n\n\tfloat totalDistance();\n\n\tstatic idVec3_t zero;\n\n\tint getActiveSegment() {\n\t\treturn activeSegment;\n\t}\n\n\tvoid setActiveSegment(int i) {\n\t\t//assert(i >= 0 && (splinePoints.Num() > 0 && i < splinePoints.Num()));\n\t\tactiveSegment = i;\n\t}\n\n\tint numSegments() {\n\t\treturn splinePoints.Num();\n\t}\n\n\tvoid setColors(idVec3_t &path, idVec3_t &segment, idVec3_t &control, idVec3_t &active) {\n\t\tpathColor = path;\n\t\tsegmentColor = segment;\n\t\tcontrolColor = control;\n\t\tactiveColor = active;\n\t}\n\n\tconst char *getName() {\n\t\treturn name.c_str();\n\t}\n\n\tvoid setName(const char *p) {\n\t\tname = p;\n\t}\n\n\tbool validTime() {\n\t\tif (dirty) {\n\t\t\tbuildSpline();\n\t\t}\n\t\t// gcc doesn't allow static casting away from bools\n\t\t// why?  I've no idea...\n\t\treturn (bool)(splineTime.Num() > 0 && splineTime.Num() == splinePoints.Num());\n\t}\n\n\tvoid setTime(long t) {\n\t\ttime = t;\n\t}\n\n\tvoid setBaseTime(long t) {\n\t\tbaseTime = t;\n\t}\n\nprotected:\n\tidStr name;\n\tfloat calcSpline(int step, float tension);\n\tidList<idVec3_t*> controlPoints;\n\tidList<idVec3_t*> splinePoints;\n\tidList<double> splineTime;\n\tidVec3_t *selected;\n\tidVec3_t pathColor, segmentColor, controlColor, activeColor;\n\tfloat granularity;\n\tbool editMode;\n\tbool dirty;\n\tint activeSegment;\n\tlong baseTime;\n\tlong time;\n\tfriend class idCamera;\n};\n\n// time in milliseconds \n// velocity where 1.0 equal rough walking speed\nstruct idVelocity {\n\tidVelocity(long start, long duration, float s) {\n\t\tstartTime = start;\n\t\ttime = duration;\n\t\tspeed = s;\n\t}\n\tlong\tstartTime;\n\tlong\ttime;\n\tfloat\tspeed;\n};\n\n// can either be a look at or origin position for a camera\n// \nclass idCameraPosition : public idPointListInterface {\npublic:\n\t\n\tvirtual void clear() {\n\t\teditMode = false;\n\t\tfor (int i = 0; i < velocities.Num(); i++) {\n\t\t\tdelete velocities[i];\n\t\t\tvelocities[i] = NULL;\n\t\t}\n\t\tvelocities.Clear();\n\t}\n\n\tidCameraPosition(const char *p) {\n\t\tname = p;\n\t}\n\n\tidCameraPosition() {\n\t\ttime = 0;\n\t\tname = \"position\";\n\t}\n\n\tidCameraPosition(long t) {\n\t\ttime = t;\n\t}\n\n\tvirtual ~idCameraPosition() {\n\t\tclear();\n\t}\n\n\t\n\t// this can be done with RTTI syntax but i like the derived classes setting a type\n\t// makes serialization a bit easier to see\n\t//\n\tenum positionType {\n\t\tFIXED = 0x00,\n\t\tINTERPOLATED,\n\t\tSPLINE,\n\t\tPOSITION_COUNT\n\t};\n\n\n\tvirtual void start(long t) {\n\t\tstartTime = t;\n\t}\n\n\tlong getTime() {\n\t\treturn time;\n\t}\n\n\tvirtual void setTime(long t) {\n\t\ttime = t;\n\t}\n\n\tfloat getVelocity(long t) {\n\t\tlong check = t - startTime;\n\t\tfor (int i = 0; i < velocities.Num(); i++) {\n\t\t\tif (check >= velocities[i]->startTime && check <= velocities[i]->startTime + velocities[i]->time) {\n\t\t\t\treturn velocities[i]->speed;\n\t\t\t}\n\t\t}\n\t\treturn baseVelocity;\n\t}\n\n\tvoid addVelocity(long start, long duration, float speed) {\n\t\tvelocities.Append(new idVelocity(start, duration, speed));\n\t}\n\n\tvirtual const idVec3_t *getPosition(long t) { \n\t\tassert(true);\n\t\treturn NULL;\n\t}\n\n//\tvirtual void draw(bool editMode) {};\n\n\tvirtual void parse(const char *(*text)) {};\n\tvirtual void write(fileHandle_t file, const char *name);\n\tvirtual bool parseToken(const char *key, const char *(*text));\n\n\tconst char *getName() {\n\t\treturn name.c_str();\n\t}\n\n\tvoid setName(const char *p) {\n\t\tname = p;\n\t}\n\n\tvirtual void startEdit() {\n\t\teditMode = true;\n\t}\n\n\tvirtual void stopEdit() {\n\t\teditMode = false;\n\t}\n\n//\tvirtual void draw() {};\n\n\tconst char *typeStr() {\n\t\treturn positionStr[static_cast<int>(type)];\n\t}\n\n\tvoid calcVelocity(float distance) {\n\t\tfloat secs = (float)time / 1000;\n\t\tbaseVelocity = distance / secs;\n\t}\n\nprotected:\n\tstatic const char* positionStr[POSITION_COUNT];\n\tlong\t\tstartTime;\n\tlong\t\ttime;\n\tidCameraPosition::positionType type;\n\tidStr\t\tname;\n\tbool\teditMode;\n\tidList<idVelocity*> velocities;\n\tfloat\t\tbaseVelocity;\n};\n\nclass idFixedPosition : public idCameraPosition {\npublic:\n\n\tvoid init() {\n\t\tpos.Zero();\n\t\ttype = idCameraPosition::FIXED;\n\t}\n\t\n\tidFixedPosition() : idCameraPosition() {\n\t\tinit();\n\t}\n\t\n\tidFixedPosition(idVec3_t p) : idCameraPosition() {\n\t\tinit();\n\t\tpos = p;\n\t}\n\n\tvirtual void addPoint(const idVec3_t &v) {\n\t\tpos = v;\n\t}\n\t\n\tvirtual void addPoint(const float x, const float y, const float z) {\n\t\tpos.set(x, y, z);\n\t}\n\n\n\t~idFixedPosition() {\n\t}\n\n\tvirtual const idVec3_t *getPosition(long t) { \n\t\treturn &pos;\n\t}\n\n\tvoid parse(const char *(*text));\n\tvoid write(fileHandle_t file, const char *name);\n\n\tvirtual int numPoints() {\n\t\treturn 1;\n\t}\n\n\tvirtual idVec3_t *getPoint(int index) {\n\t\tif (index != 0) {\n\t\t\tassert(true);\n\t\t};\n\t\treturn &pos;\n\t}\n/*\n\tvirtual void draw(bool editMode) {\n\t\tglLabeledPoint(blue, pos, (editMode) ? 5 : 3, \"Fixed point\");\n\t}\n*/\nprotected:\n\tidVec3_t pos;\n};\n\nclass idInterpolatedPosition : public idCameraPosition {\npublic:\n\n\tvoid init() {\n\t\ttype = idCameraPosition::INTERPOLATED;\n\t\tfirst = true;\n\t\tstartPos.Zero();\n\t\tendPos.Zero();\n\t}\n\t\n\tidInterpolatedPosition() : idCameraPosition() {\n\t\tinit();\n\t}\n\t\n\tidInterpolatedPosition(idVec3_t start, idVec3_t end, long time) : idCameraPosition(time) {\n\t\tinit();\n\t\tstartPos = start;\n\t\tendPos = end;\n\t}\n\n\t~idInterpolatedPosition() {\n\t}\n\n\tvirtual const idVec3_t *getPosition(long t);\n\n\tvoid parse(const char *(*text));\n\tvoid write(fileHandle_t file, const char *name);\n\n\tvirtual int numPoints() {\n\t\treturn 2;\n\t}\n\n\tvirtual idVec3_t *getPoint(int index) {\n\t\tassert(index >= 0 && index < 2);\n\t\tif (index == 0) {\n\t\t\treturn &startPos;\n\t\t}\n\t\treturn &endPos;\n\t}\n\n\tvirtual void addPoint(const float x, const float y, const float z) {\n\t\tif (first) {\n\t\t\tstartPos.set(x, y, z);\n\t\t\tfirst = false;\n\t\t} else {\n\t\t\tendPos.set(x, y, z);\n\t\t\tfirst = true;\n\t\t}\n\t}\n\n\tvirtual void addPoint(const idVec3_t &v) {\n\t\tif (first) {\n\t\t\tstartPos = v;\n\t\t\tfirst = false;\n\t\t} else {\n\t\t\tendPos = v;\n\t\t\tfirst = true;\n\t\t}\n\t}\n/*\n\tvirtual void draw(bool editMode) {\n\t\tglLabeledPoint(blue, startPos, (editMode) ? 5 : 3, \"Start interpolated\");\n\t\tglLabeledPoint(blue, endPos, (editMode) ? 5 : 3, \"End interpolated\");\n\t\tqglBegin(GL_LINES);\n\t\tqglVertex3fv(startPos);\n\t\tqglVertex3fv(endPos);\n\t\tqglEnd();\n\t}\n*/\n\tvirtual void start(long t) {\n\t\tidCameraPosition::start(t);\n\t\tlastTime = startTime;\n\t\tdistSoFar = 0.0;\n\t\tidVec3_t temp = startPos;\n\t\ttemp -= endPos;\n\t\tcalcVelocity(temp.Length());\n\t}\n\nprotected:\n\tbool first;\n\tidVec3_t startPos;\n\tidVec3_t endPos;\n\tlong lastTime;\n\tfloat distSoFar;\n};\n\nclass idSplinePosition : public idCameraPosition {\npublic:\n\n\tvoid init() {\n\t\ttype = idCameraPosition::SPLINE;\n\t}\n\t\n\tidSplinePosition() : idCameraPosition() {\n\t\tinit();\n\t}\n\t\n\tidSplinePosition(long time) : idCameraPosition(time) {\n\t\tinit();\n\t}\n\n\t~idSplinePosition() {\n\t}\n\n\tvirtual void start(long t) {\n\t\tidCameraPosition::start(t);\n\t\ttarget.initPosition(t, time);\n\t\tcalcVelocity(target.totalDistance());\n\t}\n\n\tvirtual const idVec3_t *getPosition(long t) { \n\t\treturn target.getPosition(t);\n\t}\n\n\t//virtual const idVec3_t *getPosition(long t) const { \n\n\tvoid addControlPoint(idVec3_t &v) {\n\t\ttarget.addPoint(v);\n\t}\n\n\tvoid parse(const char *(*text));\n\tvoid write(fileHandle_t file, const char *name);\n\n\tvirtual int numPoints() {\n\t\treturn target.numPoints();\n\t}\n\n\tvirtual idVec3_t *getPoint(int index) {\n\t\treturn target.getPoint(index);\n\t}\n\n\tvirtual void addPoint(const idVec3_t &v) {\n\t\ttarget.addPoint(v);\n\t}\n\n\tvirtual void addPoint(const float x, const float y, const float z) {\n\t\ttarget.addPoint(x, y, z);\n\t}\n\n/*\tvirtual void draw(bool editMode) {\n\t\ttarget.draw(editMode);\n\t}\n*/\n\tvirtual void updateSelection(const idVec3_t &move) {\n\t\tidCameraPosition::updateSelection(move);\n\t\ttarget.buildSpline();\n\t}\n\nprotected:\n\tidSplineList target;\n};\n\nclass idCameraFOV {\npublic:\n\t\n\tidCameraFOV() {\n\t\ttime = 0;\n\t\tfov = 90;\n\t}\n\n\tidCameraFOV(int v) {\n\t\ttime = 0;\n\t\tfov = v;\n\t}\n\n\tidCameraFOV(int s, int e, long t) {\n\t\tstartFOV = s;\n\t\tendFOV = e;\n\t\ttime = t;\n\t}\n\n\n\t~idCameraFOV(){}\n\n\tvoid setFOV(float f) {\n\t\tfov = f;\n\t}\n\n\tfloat getFOV(long t) {\n\t\tif (time) {\n\t\t\tassert(startTime);\n\t\t\tfloat percent = t / startTime;\n\t\t\tfloat temp = startFOV - endFOV;\n\t\t\ttemp *= percent;\n\t\t\tfov = startFOV + temp;\n\t\t}\n\t\treturn fov;\n\t}\n\n\tvoid start(long t) {\n\t\tstartTime = t;\n\t}\n\n\tvoid parse(const char *(*text));\n\tvoid write(fileHandle_t file, const char *name);\n\nprotected:\n\tfloat fov;\n\tfloat startFOV;\n\tfloat endFOV;\n\tint startTime;\n\tint time;\n};\n\n\n\n\nclass idCameraEvent {\npublic:\n\tenum eventType {\n\t\tEVENT_NA = 0x00,\n\t\tEVENT_WAIT,\n\t\tEVENT_TARGETWAIT,\n\t\tEVENT_SPEED,\n\t\tEVENT_TARGET,\n\t\tEVENT_SNAPTARGET,\n\t\tEVENT_FOV,\n\t\tEVENT_SCRIPT,\n\t\tEVENT_TRIGGER,\n\t\tEVENT_STOP,\n\t\tEVENT_COUNT\n\t};\n\n\tstatic const char* eventStr[EVENT_COUNT];\n\n\tidCameraEvent() {\n\t\tparamStr = \"\";\n\t\ttype = EVENT_NA;\n\t\ttime = 0;\n\t}\n\n\tidCameraEvent(eventType t, const char *param, long n) {\n\t\ttype = t;\n\t\tparamStr = param;\n\t\ttime = n;\n\t}\n\n\t~idCameraEvent() {};\n\n\teventType getType() {\n\t\treturn type;\n\t}\n\n\tconst char *typeStr() {\n\t\treturn eventStr[static_cast<int>(type)];\n\t}\n\n\tconst char *getParam() {\n\t\treturn paramStr.c_str();\n\t}\n\n\tlong getTime() {\n\t\treturn time;\n\t}\n\n\tvoid setTime(long n) {\n\t\ttime = n;\n\t}\n\n\tvoid parse(const char *(*text));\n\tvoid write(fileHandle_t file, const char *name);\n\n\tvoid setTriggered(bool b) {\n\t\ttriggered = b;\n\t}\n\n\tbool getTriggered() {\n\t\treturn triggered;\n\t}\n\nprotected:\n\teventType type;\n\tidStr paramStr;\n\tlong time;\n\tbool triggered;\n\n};\n\nclass idCameraDef {\npublic:\n\n\tvoid clear() {\n\t\tcurrentCameraPosition = 0;\n\t\tcameraRunning = false;\n\t\tlastDirection.Zero();\n\t\tbaseTime = 30;\n\t\tactiveTarget = 0;\n\t\tname = \"camera01\";\n\t\tfov.setFOV(90);\n\t\tint i;\n\t\tfor (i = 0; i < targetPositions.Num(); i++) {\n\t\t\tdelete targetPositions[i];\n\t\t}\n\t\tfor (i = 0; i < events.Num(); i++) {\n\t\t\tdelete events[i];\n\t\t}\n\t\tdelete cameraPosition;\n\t\tcameraPosition = NULL;\n\t\tevents.Clear();\n\t\ttargetPositions.Clear();\n\t}\n\n\tidCameraPosition *startNewCamera(idCameraPosition::positionType type) {\n\t\tclear();\n\t\tif (type == idCameraPosition::SPLINE) {\n\t\t\tcameraPosition = new idSplinePosition();\n\t\t} else if (type == idCameraPosition::INTERPOLATED) {\n\t\t\tcameraPosition = new idInterpolatedPosition();\n\t\t} else {\n\t\t\tcameraPosition = new idFixedPosition();\n\t\t}\n\t\treturn cameraPosition;\n\t}\n\n\tidCameraDef() {\n\t\tclear();\n\t}\n\n\t~idCameraDef() {\n\t\tclear();\n\t}\n\n\tvoid addEvent(idCameraEvent::eventType t, const char *param, long time);\n\n\tvoid addEvent(idCameraEvent *event);\n\n\tstatic int sortEvents(const void *p1, const void *p2);\n\n\tint numEvents() {\n\t\treturn events.Num();\n\t}\n\n\tidCameraEvent *getEvent(int index) {\n\t\tassert(index >= 0 && index < events.Num());\n\t\treturn events[index];\n\t}\n\n\tvoid parse(const char *(*text));\n\tqboolean load(const char *filename);\n\tvoid save(const char *filename);\n\n\tvoid buildCamera();\n\n\t//idSplineList *getcameraPosition() {\n\t//\treturn &cameraPosition;\n\t//}\n\n\tstatic idCameraPosition *newFromType(idCameraPosition::positionType t) {\n\t\tswitch (t) {\n\t\t\tcase idCameraPosition::FIXED : return new idFixedPosition();\n\t\t\tcase idCameraPosition::INTERPOLATED : return new idInterpolatedPosition();\n    case idCameraPosition::SPLINE : return new idSplinePosition();\n    default:\n        break;\n\t\t};\n\t\treturn NULL;\n\t}\n\n\tvoid addTarget(const char *name, idCameraPosition::positionType type);\n\n\tidCameraPosition *getActiveTarget() {\n\t\tif (targetPositions.Num() == 0) {\n\t\t\taddTarget(NULL, idCameraPosition::FIXED);\n\t\t}\n\t\treturn targetPositions[activeTarget];\n\t}\n\n\tidCameraPosition *getActiveTarget(int index) {\n\t\tif (targetPositions.Num() == 0) {\n\t\t\taddTarget(NULL, idCameraPosition::FIXED);\n\t\t\treturn targetPositions[0];\n\t\t}\n\t\treturn targetPositions[index];\n\t}\n\n\tint numTargets() {\n\t\treturn targetPositions.Num();\n\t}\n\n\n\tvoid setActiveTargetByName(const char *name) {\n\t\tfor (int i = 0; i < targetPositions.Num(); i++) {\n\t\t\tif (Q_stricmp(name, targetPositions[i]->getName()) == 0) {\n\t\t\t\tsetActiveTarget(i);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\tvoid setActiveTarget(int index) {\n\t\tassert(index >= 0 && index < targetPositions.Num());\n\t\tactiveTarget = index;\n\t}\n\n\tvoid setRunning(bool b) {\n\t\tcameraRunning = b;\n\t}\n\n\tvoid setBaseTime(float f) {\n\t\tbaseTime = f;\n\t}\n\n\tfloat getBaseTime() {\n\t\treturn baseTime;\n\t}\n\n\tfloat getTotalTime() {\n\t\treturn totalTime;\n\t}\n\t\n\tvoid startCamera(long t);\n\tvoid stopCamera() {\n\t\tcameraRunning = true;\n\t}\n\tvoid getActiveSegmentInfo(int segment, idVec3_t &origin, idVec3_t &direction, float *fv);\n\n\tbool getCameraInfo(long time, idVec3_t &origin, idVec3_t &direction, float *fv);\n\tbool getCameraInfo(long time, float *origin, float *direction, float *fv) {\n\t\tidVec3_t org, dir;\n\t\torg[0] = origin[0];\n\t\torg[1] = origin[1];\n\t\torg[2] = origin[2];\n\t\tdir[0] = direction[0];\n\t\tdir[1] = direction[1];\n\t\tdir[2] = direction[2];\n\t\tbool b = getCameraInfo(time, org, dir, fv);\n\t\torigin[0] = org[0];\n\t\torigin[1] = org[1];\n\t\torigin[2] = org[2];\n\t\tdirection[0] = dir[0];\n\t\tdirection[1] = dir[1];\n\t\tdirection[2] = dir[2];\n\t\treturn b;\n\t}\n/*\n\tvoid draw(bool editMode) {\n                // gcc doesn't allow casting away from bools\n                // why?  I've no idea...\n\t\tif (cameraPosition) {\n\t\t\tcameraPosition->draw((bool)((editMode || cameraRunning) && cameraEdit));\n\t\t\tint count = targetPositions.Num();\n\t\t\tfor (int i = 0; i < count; i++) {\n\t\t\t\ttargetPositions[i]->draw((bool)((editMode || cameraRunning) && i == activeTarget && !cameraEdit));\n\t\t\t}\n\t\t}\n\t}\n*/\n/*\n\tint numSegments() {\n\t\tif (cameraEdit) {\n\t\t\treturn cameraPosition.numSegments();\n\t\t}\n\t\treturn getTargetSpline()->numSegments();\n\t}\n\n\tint getActiveSegment() {\n\t\tif (cameraEdit) {\n\t\t\treturn cameraPosition.getActiveSegment();\n\t\t}\n\t\treturn getTargetSpline()->getActiveSegment();\n\t}\n\n\tvoid setActiveSegment(int i) {\n\t\tif (cameraEdit) {\n\t\t\tcameraPosition.setActiveSegment(i);\n\t\t} else {\n\t\t\tgetTargetSpline()->setActiveSegment(i);\n\t\t}\n\t}\n*/\n\tint numPoints() {\n\t\tif (cameraEdit) {\n\t\t\treturn cameraPosition->numPoints();\n\t\t}\n\t\treturn getActiveTarget()->numPoints();\n\t}\n\n\tconst idVec3_t *getPoint(int index) {\n\t\tif (cameraEdit) {\n\t\t\treturn cameraPosition->getPoint(index);\n\t\t}\n\t\treturn getActiveTarget()->getPoint(index);\n\t}\n\n\tvoid stopEdit() {\n\t\teditMode = false;\n\t\tif (cameraEdit) {\n\t\t\tcameraPosition->stopEdit();\n\t\t} else {\n\t\t\tgetActiveTarget()->stopEdit();\n\t\t}\n\t}\n\n\tvoid startEdit(bool camera) {\n\t\tcameraEdit = camera;\n\t\tif (camera) {\n\t\t\tcameraPosition->startEdit();\n\t\t\tfor (int i = 0; i < targetPositions.Num(); i++) {\n\t\t\t\ttargetPositions[i]->stopEdit();\n\t\t\t}\n\t\t} else {\n\t\t\tgetActiveTarget()->startEdit();\n\t\t\tcameraPosition->stopEdit();\n\t\t}\n\t\teditMode = true;\n\t}\n\n\tbool waitEvent(int index);\n\n\tconst char *getName() {\n\t\treturn name.c_str();\n\t}\n\n\tvoid setName(const char *p) {\n\t\tname = p;\n\t}\n\n\tidCameraPosition *getPositionObj() {\n\t\tif (cameraPosition == NULL) {\n\t\t\tcameraPosition = new idFixedPosition();\n\t\t}\n\t\treturn cameraPosition;\n\t}\n\nprotected:\n\tidStr name;\n\tint currentCameraPosition;\n\tidVec3_t lastDirection;\n\tbool cameraRunning;\n\tidCameraPosition *cameraPosition;\n\tidList<idCameraPosition*> targetPositions;\n\tidList<idCameraEvent*> events;\n\tidCameraFOV fov;\n\tint activeTarget;\n\tfloat totalTime;\n\tfloat baseTime;\n\tlong startTime;\n\n\tbool cameraEdit;\n\tbool editMode;\n};\n\nextern bool g_splineMode;\n\nextern idCameraDef *g_splineList;\n\n\n#endif\n"
  },
  {
    "path": "code/splines/util_list.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __UTIL_LIST_H__\n#define __UTIL_LIST_H__\n\n#include <stdlib.h>\n#include <assert.h>\n\ntemplate< class type >\nclass idList {\nprivate:\n\tint\t\t\tm_num;\n\tint\t\t\tm_size;\n\tint\t\t\tm_granularity;\n\ttype\t\t*m_list;\n\npublic:\n\t\t\t\tidList( int granularity = 16 );\n\t\t\t\t~idList<type>();\n\tvoid\t\tClear( void );\n\tint\t\t\tNum( void );\n\tvoid\t\tSetNum( int num );\n\tvoid\t\tSetGranularity( int granularity );\n\tvoid\t\tCondense( void );\n\tint\t\t\tSize( void );\n\tvoid\t\tResize( int size );\n\ttype\t\toperator[]( int index ) const;\n\ttype\t\t&operator[]( int index );\n\tint\t\t\tAppend( type const & obj );\n\tint\t\t\tAddUnique( type const & obj );\n\ttype\t\t*Find( type const & obj, int *index = NULL );\n\tbool\t\tRemoveIndex( int index );\n\tbool\t\tRemove( type const & obj );\n\ttypedef int cmp_t(const void *, const void *);\n\tvoid\t\tSort( cmp_t *compare );\n};\n\n/*\n================\nidList<type>::idList( int )\n================\n*/\ntemplate< class type >\ninline idList<type>::idList( int granularity ) {\n\tassert( granularity > 0 );\n\n\tm_list\t\t\t= NULL;\n\tm_granularity\t= granularity;\n\tClear();\n}\n\n/*\n================\nidList<type>::~idList<type>\n================\n*/\ntemplate< class type >\ninline idList<type>::~idList() {\n\tClear();\n}\n\n/*\n================\nidList<type>::Clear\n================\n*/\ntemplate< class type >\ninline void idList<type>::Clear( void ) {\n\tif ( m_list ) {\n\t\tdelete[] m_list;\n\t}\n\n\tm_list\t= NULL;\n\tm_num\t= 0;\n\tm_size\t= 0;\n}\n\n/*\n================\nidList<type>::Num\n================\n*/\ntemplate< class type >\ninline int idList<type>::Num( void ) {\n\treturn m_num;\n}\n\n/*\n================\nidList<type>::SetNum\n================\n*/\ntemplate< class type >\ninline void idList<type>::SetNum( int num ) {\n\tassert( num >= 0 );\n\tif ( num > m_size ) {\n\t\t// resize it up to the closest level of granularity\n\t\tResize( ( ( num + m_granularity - 1 ) / m_granularity ) * m_granularity );\n\t}\n\tm_num = num;\n}\n\n/*\n================\nidList<type>::SetGranularity\n================\n*/\ntemplate< class type >\ninline void idList<type>::SetGranularity( int granularity ) {\n\tint newsize;\n\n\tassert( granularity > 0 );\n\tm_granularity = granularity;\n\n\tif ( m_list ) {\n\t\t// resize it to the closest level of granularity\n\t\tnewsize = ( ( m_num + m_granularity - 1 ) / m_granularity ) * m_granularity;\n\t\tif ( newsize != m_size ) {\n\t\t\tResize( newsize );\n\t\t}\n\t}\n}\n\n/*\n================\nidList<type>::Condense\n\nResizes the array to exactly the number of elements it contains\n================\n*/\ntemplate< class type >\ninline void idList<type>::Condense( void ) {\n\tif ( m_list ) {\n\t\tif ( m_num ) {\n\t\t\tResize( m_num );\n\t\t} else {\n\t\t\tClear();\n\t\t}\n\t}\n}\n\n/*\n================\nidList<type>::Size\n================\n*/\ntemplate< class type >\ninline int idList<type>::Size( void ) {\n\treturn m_size;\n}\n\n/*\n================\nidList<type>::Resize\n================\n*/\ntemplate< class type >\ninline void idList<type>::Resize( int size ) {\n\ttype\t*temp;\n\tint\t\ti;\n\n\tassert( size > 0 );\n\n\tif ( size <= 0 ) {\n\t\tClear();\n\t\treturn;\n\t}\n\n\ttemp\t= m_list;\n\tm_size\t= size;\n\tif ( m_size < m_num ) {\n\t\tm_num = m_size;\n\t}\n\n\tm_list = new type[ m_size ];\n\tfor( i = 0; i < m_num; i++ ) {\n\t\tm_list[ i ] = temp[ i ];\n\t}\n\n\tif ( temp ) {\n\t\tdelete[] temp;\n\t}\n}\n\n/*\n================\nidList<type>::operator[] const\n================\n*/\ntemplate< class type >\ninline type idList<type>::operator[]( int index ) const {\n\tassert( index >= 0 );\n\tassert( index < m_num );\n\n\treturn m_list[ index ];\n}\n\n/*\n================\nidList<type>::operator[]\n================\n*/\ntemplate< class type >\ninline type &idList<type>::operator[]( int index ) {\n\tassert( index >= 0 );\n\tassert( index < m_num );\n\n\treturn m_list[ index ];\n}\n\n/*\n================\nidList<type>::Append\n================\n*/\ntemplate< class type >\ninline int idList<type>::Append( type const & obj ) {\n\tif ( !m_list ) {\n\t\tResize( m_granularity );\n\t}\n\n\tif ( m_num == m_size ) {\n\t\tResize( m_size + m_granularity );\n\t}\n\n\tm_list[ m_num ] = obj;\n\tm_num++;\n\n\treturn m_num - 1;\n}\n\n/*\n================\nidList<type>::AddUnique\n================\n*/\ntemplate< class type >\ninline int idList<type>::AddUnique( type const & obj ) {\n\tint index;\n\n\tif ( !Find( obj, &index ) ) {\n\t\tindex = Append( obj );\n\t}\n\n\treturn index;\n}\n\n/*\n================\nidList<type>::Find\n================\n*/\ntemplate< class type >\ninline type *idList<type>::Find( type const & obj, int *index ) {\n\tint i;\n\n\tfor( i = 0; i < m_num; i++ ) {\n\t\tif ( m_list[ i ] == obj ) {\n\t\t\tif ( index ) {\n\t\t\t\t*index = i;\n\t\t\t}\n\t\t\treturn &m_list[ i ];\n\t\t}\n\t}\n\n\treturn NULL;\n}\n\n/*\n================\nidList<type>::RemoveIndex\n================\n*/\ntemplate< class type >\ninline bool idList<type>::RemoveIndex( int index ) {\n\tint i;\n\n\tif ( !m_list || !m_num ) {\n\t\treturn false;\n\t}\n\n\tassert( index >= 0 );\n\tassert( index < m_num );\n\n\tif ( ( index < 0 ) || ( index >= m_num ) ) {\n\t\treturn false;\n\t}\n\n\tm_num--;\n\tfor( i = index; i < m_num; i++ ) {\n\t\tm_list[ i ] = m_list[ i + 1 ];\n\t}\n\n\treturn true;\n}\n\n/*\n================\nidList<type>::Remove\n================\n*/\ntemplate< class type >\ninline bool idList<type>::Remove( type const & obj ) {\n\tint index;\n\n\tif ( Find( obj, &index ) ) {\n\t\treturn RemoveIndex( index );\n\t}\n\t\n\treturn false;\n}\n\n/*\n================\nidList<type>::Sort\n================\n*/\ntemplate< class type >\ninline void idList<type>::Sort( cmp_t *compare ) {\n\tif ( !m_list ) {\n\t\treturn;\n\t}\n\n\tqsort( ( void * )m_list, ( size_t )m_num, sizeof( type ), compare );\n}\n\n#endif /* !__UTIL_LIST_H__ */\n"
  },
  {
    "path": "code/splines/util_str.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//need to rewrite this\n\n#include \"util_str.h\"\n#include <stdlib.h>\n#include <ctype.h>\n#include <stdio.h>\n#include <stdarg.h>\n\n#ifdef _WIN32\n#pragma warning(disable : 4244)     // 'conversion' conversion from 'type1' to 'type2', possible loss of data\n#pragma warning(disable : 4710)     // function 'blah' not inlined\n#endif\n\nstatic const int STR_ALLOC_GRAN = 20;\n\nchar *idStr::toLower\n   (\n   char *s1\n   )\n   \n   {\n   char *s;\n\n   s = s1;\n\twhile( *s )\n      {\n      *s = ::tolower( *s );\n\t\ts++;\n\t   }\n   \n   return s1;\n   }\n\nchar *idStr::toUpper\n   (\n   char *s1\n   )\n   \n   {\n   char *s;\n\n   s = s1;\n\twhile( *s )\n      {\n      *s = ::toupper( *s );\n\t\ts++;\n\t   }\n   \n   return s1;\n   }\n\n\nint idStr::icmpn\n   (\n   const char *s1, \n   const char *s2, \n   int n\n   )\n   \n   {\n\tint c1;\n   int c2;\n\t\n\tdo \n      {\n\t\tc1 = *s1++;\n\t\tc2 = *s2++;\n\n\t\tif ( !n-- )\n         {\n         // idStrings are equal until end point\n\t\t\treturn 0;\n\t\t   }\n\t\t\n\t\tif ( c1 != c2 )\n         {\n\t\t\tif ( c1 >= 'a' && c1 <= 'z' )\n            {\n\t\t\t\tc1 -= ( 'a' - 'A' );\n\t\t\t   }\n\n\t\t\tif ( c2 >= 'a' && c2 <= 'z' )\n            {\n\t\t\t\tc2 -= ( 'a' - 'A' );\n\t\t\t   }\n\n\t\t\tif ( c1 < c2 )\n            {\n            // strings less than\n\t\t\t\treturn -1;\n\t\t\t   }\n         else if ( c1 > c2 ) \n            {\n            // strings greater than\n            return 1;\n            }\n\t\t   }\n\t   } \n   while( c1 );\n\t\n   // strings are equal\n\treturn 0;\n   }\n\nint idStr::icmp\n   (\n   const char *s1,\n   const char *s2\n   )\n   \n   {\n\tint c1;\n   int c2;\n\t\n\tdo \n      {\n\t\tc1 = *s1++;\n\t\tc2 = *s2++;\n\n\t\tif ( c1 != c2 )\n         {\n\t\t\tif ( c1 >= 'a' && c1 <= 'z' )\n            {\n\t\t\t\tc1 -= ( 'a' - 'A' );\n\t\t\t   }\n\n\t\t\tif ( c2 >= 'a' && c2 <= 'z' )\n            {\n\t\t\t\tc2 -= ( 'a' - 'A' );\n\t\t\t   }\n\n\t\t\tif ( c1 < c2 )\n            {\n            // strings less than\n\t\t\t\treturn -1;\n\t\t\t   }\n         else if ( c1 > c2 ) \n            {\n            // strings greater than\n            return 1;\n            }\n\t\t   }\n\t   } \n   while( c1 );\n\t\n   // strings are equal\n\treturn 0;\n   }\n\nint idStr::cmpn\n   (\n   const char *s1, \n   const char *s2, \n   int n\n   )\n   \n   {\n\tint c1;\n   int c2;\n\t\n\tdo \n      {\n\t\tc1 = *s1++;\n\t\tc2 = *s2++;\n\n\t\tif ( !n-- )\n         {\n         // strings are equal until end point\n\t\t\treturn 0;\n\t\t   }\n\t\t\n\t\tif ( c1 < c2 )\n         {\n         // strings less than\n\t\t\treturn -1;\n\t\t\t}\n      else if ( c1 > c2 ) \n         {\n         // strings greater than\n         return 1;\n         }\n\t   } \n   while( c1 );\n\t\n   // strings are equal\n\treturn 0;\n   }\n\nint idStr::cmp\n   (\n   const char *s1, \n   const char *s2\n   )\n   \n   {\n\tint c1;\n   int c2;\n\t\n\tdo \n      {\n\t\tc1 = *s1++;\n\t\tc2 = *s2++;\n\n\t\tif ( c1 < c2 )\n         {\n         // strings less than\n\t\t\treturn -1;\n\t\t\t}\n      else if ( c1 > c2 ) \n         {\n         // strings greater than\n         return 1;\n         }\n\t   } \n   while( c1 );\n\t\n   // strings are equal\n\treturn 0;\n   }\n\n/*\n============\nIsNumeric\n\nChecks a string to see if it contains only numerical values.\n============\n*/\nbool idStr::isNumeric\n   (\n   const char *str\n   )\n\n   {\n\tint len;\n\tint i;\n\tbool dot;\n\n\tif ( *str == '-' )\n\t\t{\n\t\tstr++;\n\t\t}\n\n\tdot = false;\n\tlen = strlen( str );\n\tfor( i = 0; i < len; i++ )\n\t\t{\n\t\tif ( !isdigit( str[ i ] ) )\n\t\t\t{\n\t\t\tif ( ( str[ i ] == '.' ) && !dot )\n\t\t\t\t{\n\t\t\t\tdot = true;\n\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\treturn true;\n   }\n\nidStr operator+\n   (\n   const idStr& a,\n   const float b\n   )\n\n   {\n   char text[ 20 ];\n\n\tidStr result( a );\n\n   sprintf( text, \"%f\", b );\n\tresult.append( text );\n\n\treturn result;\n   }\n\nidStr operator+\n   (\n   const idStr& a,\n   const int b\n   )\n\n   {\n   char text[ 20 ];\n\n\tidStr result( a );\n\n   sprintf( text, \"%d\", b );\n\tresult.append( text );\n\n\treturn result;\n   }\n\nidStr operator+\n   (\n   const idStr& a,\n   const unsigned b\n   )\n\n   {\n   char text[ 20 ];\n\n\tidStr result( a );\n\n   sprintf( text, \"%u\", b );\n\tresult.append( text );\n\n\treturn result;\n   }\n\nidStr& idStr::operator+=\n\t(\n\tconst float a\n\t)\n\n\t{\n   char text[ 20 ];\n\n   sprintf( text, \"%f\", a );\n\tappend( text );\n\n   return *this;\n\t}\n\nidStr& idStr::operator+=\n\t(\n\tconst int a\n\t)\n\n\t{\n   char text[ 20 ];\n\n   sprintf( text, \"%d\", a );\n\tappend( text );\n\n   return *this;\n\t}\n\nidStr& idStr::operator+=\n\t(\n\tconst unsigned a\n\t)\n\n\t{\n   char text[ 20 ];\n\n   sprintf( text, \"%u\", a );\n\tappend( text );\n\n   return *this;\n\t}\n\nvoid idStr::CapLength \n   (\n   int newlen \n   )\n\n   {\n   assert ( m_data );\n   \n   if ( length() <= newlen )\n      return;\n\n   EnsureDataWritable ();\n\n   m_data->data[newlen] = 0;\n   m_data->len = newlen;\n   }\n\nvoid idStr::EnsureDataWritable \n   (\n   void\n   )\n\n   {\n   assert ( m_data );\n   strdata *olddata;\n   int len;\n\n   if ( !m_data->refcount )\n      return;\n\n   olddata = m_data;\n   len = length();\n\n   m_data = new strdata;\n\n   EnsureAlloced ( len + 1, false );\n   strncpy ( m_data->data, olddata->data, len+1 );\n   m_data->len = len;\n\n   olddata->DelRef ();\n   }\n\nvoid idStr::EnsureAlloced (int amount, bool keepold) {\n\n\tif ( !m_data ) {\n      m_data = new strdata();\n\t}\n   \n\t// Now, let's make sure it's writable\n\tEnsureDataWritable ();\n\n\tchar *newbuffer;\n\tbool wasalloced = ( m_data->alloced != 0 );\n\n\tif ( amount < m_data->alloced ) {\n\t\treturn;\n\t}\n\n\tassert ( amount );\n\tif ( amount == 1 ) {\n\t\tm_data->alloced = 1;\n\t} else {\n\t\tint newsize, mod;\n\t\tmod = amount % STR_ALLOC_GRAN;\n\t\tif ( !mod ) {\n\t\t\tnewsize = amount;\n\t\t} else {\n         newsize = amount + STR_ALLOC_GRAN - mod;\n\t\t}\n\t\tm_data->alloced = newsize;\n\t}\n\n\tnewbuffer = new char[m_data->alloced];\n\tif ( wasalloced && keepold ) {\n\t\tstrcpy ( newbuffer, m_data->data );\n\t}\n\n\tif ( m_data->data ) {\n\t\tdelete [] m_data->data;\n    }\n\tm_data->data = newbuffer;\n}\n\nvoid idStr::BackSlashesToSlashes\n   (\n   void\n   )\n\n   {\n   int i;\n\n   EnsureDataWritable ();\n\n   for ( i=0; i < m_data->len; i++ )\n      {\n      if ( m_data->data[i] == '\\\\' )\n         m_data->data[i] = '/';\n      }\n   }\n\nvoid idStr::snprintf \n   (\n   char *dst,\n   int size,\n   const char *fmt, \n   ...\n   )\n\n   {\n   char buffer[0x10000];\n\tint\t\tlen;\n\tva_list\t\targptr;\n\n\tva_start (argptr,fmt);\n\tlen = vsprintf (buffer,fmt,argptr);\n\tva_end (argptr);\n\t\n   assert ( len < size );\n\n   strncpy (dst, buffer, size-1);\n   }\n\n#ifdef _WIN32\n#pragma warning(disable : 4189)\t\t// local variable is initialized but not referenced\n#endif\n\n/*\n=================\nTestStringClass\n\nThis is a fairly rigorous test of the idStr class's functionality.\nBecause of the fairly global and subtle ramifications of a bug occuring\nin this class, it should be run after any changes to the class.\nAdd more tests as functionality is changed.  Tests should include\nany possible bounds violation and NULL data tests.\n=================\n*/\nvoid TestStringClass\n\t(\n\tvoid \n\t)\n\n\t{\n\tchar\tch;\t\t\t\t\t\t\t// ch == ?\n\tidStr\t*t;\t\t\t\t\t\t\t// t == ?\n\tidStr\ta;\t\t\t\t\t\t\t\t// a.len == 0, a.data == \"\\0\"\n\tidStr\tb;\t\t\t\t\t\t\t\t// b.len == 0, b.data == \"\\0\"\n\tidStr\tc( \"test\" );\t\t\t\t// c.len == 4, c.data == \"test\\0\"\n\tidStr\td( c );\t\t\t\t\t\t// d.len == 4, d.data == \"test\\0\"\n\tidStr\te( reinterpret_cast<const char *>(NULL) );\t\t\t\t\t\n                                 // e.len == 0, e.data == \"\\0\"\t\t\t\t\tASSERT!\n\tint\ti;\t\t\t\t\t\t\t\t// i == ?\n\n\ti = a.length();\t\t\t\t\t// i == 0\n\ti = c.length();\t\t\t\t\t// i == 4\n\n    // TTimo: not used\n//\tconst char *s1 = a.c_str();\t// s1 == \"\\0\"\n//\tconst char *s2 = c.c_str();\t// s2 == \"test\\0\"\n\n\tt = new idStr();\t\t\t\t\t\t// t->len == 0, t->data == \"\\0\"\n\tdelete t;\t\t\t\t\t\t\t// t == ?\n\n\tb = \"test\";\t\t\t\t\t\t\t// b.len == 4, b.data == \"test\\0\"\n\tt = new idStr( \"test\" );\t\t\t// t->len == 4, t->data == \"test\\0\"\n\tdelete t;\t\t\t\t\t\t\t// t == ?\n\n\ta = c;\t\t\t\t\t\t\t\t// a.len == 4, a.data == \"test\\0\"\n//   a = \"\";\n   a = NULL;\t\t\t\t\t\t\t// a.len == 0, a.data == \"\\0\"\t\t\t\t\tASSERT!\n\ta = c + d;\t\t\t\t\t\t\t// a.len == 8, a.data == \"testtest\\0\"\n\ta = c + \"wow\";\t\t\t\t\t\t// a.len == 7, a.data == \"testwow\\0\"\n\ta = c + reinterpret_cast<const char *>(NULL);\n                                 // a.len == 4, a.data == \"test\\0\"\t\t\tASSERT!\n\ta = \"this\" + d;\t\t\t\t\t// a.len == 8, a.data == \"thistest\\0\"\n\ta = reinterpret_cast<const char *>(NULL) + d;\n                                 // a.len == 4, a.data == \"test\\0\"\t\t\tASSERT!\n\ta += c;\t\t\t\t\t\t\t\t// a.len == 8, a.data == \"testtest\\0\"\n\ta += \"wow\";\t\t\t\t\t\t\t// a.len == 11, a.data == \"testtestwow\\0\"\n\ta += reinterpret_cast<const char *>(NULL);\n                                 // a.len == 11, a.data == \"testtestwow\\0\"\tASSERT!\n\n\ta = \"test\";\t\t\t\t\t\t\t// a.len == 4, a.data == \"test\\0\"\n\tch = a[ 0 ];\t\t\t\t\t\t// ch == 't'\n\tch = a[ -1 ];\t\t\t\t\t\t// ch == 0\t\t\t\t\t\t\t\t\t\t\tASSERT!\n\tch = a[ 1000 ];\t\t\t\t\t// ch == 0\t\t\t\t\t\t\t\t\t\t\tASSERT!\n\tch = a[ 0 ];\t\t\t\t\t\t// ch == 't'\n\tch = a[ 1 ];\t\t\t\t\t\t// ch == 'e'\n\tch = a[ 2 ];\t\t\t\t\t\t// ch == 's'\n\tch = a[ 3 ];\t\t\t\t\t\t// ch == 't'\n\tch = a[ 4 ];\t\t\t\t\t\t// ch == '\\0'\t\t\t\t\t\t\t\t\t\tASSERT!\n\tch = a[ 5 ];\t\t\t\t\t\t// ch == '\\0'\t\t\t\t\t\t\t\t\t\tASSERT!\n\n\ta[ 1 ] = 'b';\t\t\t\t\t\t// a.len == 4, a.data == \"tbst\\0\"\n\ta[ -1 ] = 'b';\t\t\t\t\t\t// a.len == 4, a.data == \"tbst\\0\"\t\t\tASSERT!\n\ta[ 0 ] = '0';\t\t\t\t\t\t// a.len == 4, a.data == \"0bst\\0\"\n\ta[ 1 ] = '1';\t\t\t\t\t\t// a.len == 4, a.data == \"01st\\0\"\n\ta[ 2 ] = '2';\t\t\t\t\t\t// a.len == 4, a.data == \"012t\\0\"\n\ta[ 3 ] = '3';\t\t\t\t\t\t// a.len == 4, a.data == \"0123\\0\"\n\ta[ 4 ] = '4';\t\t\t\t\t\t// a.len == 4, a.data == \"0123\\0\"\t\t\tASSERT!\n\ta[ 5 ] = '5';\t\t\t\t\t\t// a.len == 4, a.data == \"0123\\0\"\t\t\tASSERT!\n\ta[ 7 ] = '7';\t\t\t\t\t\t// a.len == 4, a.data == \"0123\\0\"\t\t\tASSERT!\n\n\ta = \"test\";\t\t\t\t\t\t\t// a.len == 4, a.data == \"test\\0\"\n\tb = \"no\";\t\t\t\t\t\t\t// b.len == 2, b.data == \"no\\0\"\n\n\ti = ( a == b );\t\t\t\t\t// i == 0\n\ti = ( a == c );\t\t\t\t\t// i == 1\n\n\ti = ( a == \"blow\" );\t\t\t\t// i == 0\n\ti = ( a == \"test\" );\t\t\t\t// i == 1\n\ti = ( a == NULL );\t\t\t\t// i == 0\t\t\t\t\t\t\t\t\t\t\tASSERT!\n\n\ti = ( \"test\" == b );\t\t\t\t// i == 0\n\ti = ( \"test\" == a );\t\t\t\t// i == 1\n\ti = ( NULL == a );\t\t\t\t// i == 0\t\t\t\t\t\t\t\t\t\t\tASSERT!\n\n\ti = ( a != b );\t\t\t\t\t// i == 1\n\ti = ( a != c );\t\t\t\t\t// i == 0\n\n\ti = ( a != \"blow\" );\t\t\t\t// i == 1\n\ti = ( a != \"test\" );\t\t\t\t// i == 0\n\ti = ( a != NULL );\t\t\t\t// i == 1\t\t\t\t\t\t\t\t\t\t\tASSERT!\n\n\ti = ( \"test\" != b );\t\t\t\t// i == 1\n\ti = ( \"test\" != a );\t\t\t\t// i == 0\n\ti = ( NULL != a );\t\t\t\t// i == 1\t\t\t\t\t\t\t\t\t\t\tASSERT!\n\n   a = \"test\";                   // a.data == \"test\"\n   b = a;                        // b.data == \"test\"\n\n   a = \"not\";                   // a.data == \"not\", b.data == \"test\"\n\n   a = b;                        // a.data == b.data == \"test\"\n\n   a += b;                       // a.data == \"testtest\", b.data = \"test\"\n\n   a = b;\n\n   a[1] = '1';                   // a.data = \"t1st\", b.data = \"test\"\n\t}\n\n#ifdef _WIN32\n#pragma warning(default : 4189)\t\t// local variable is initialized but not referenced\n#pragma warning(disable : 4514)     // unreferenced inline function has been removed\n#endif\n"
  },
  {
    "path": "code/splines/util_str.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//need to rewrite this\n\n#ifndef __UTIL_STR_H__\n#define __UTIL_STR_H__\n\n#include <assert.h>\n#include <string.h>\n#include <stdio.h>\n\n#ifdef _WIN32\n#pragma warning(disable : 4710)     // function 'blah' not inlined\n#endif\n\nvoid TestStringClass ();\n\nclass strdata\n   {\n   public:\n      strdata () : len( 0 ), refcount ( 0 ), data ( NULL ), alloced ( 0 ) {}\n      ~strdata () \n         {\n         if ( data )\n            delete [] data;\n         }\n\n      void AddRef () { refcount++; }\n      bool DelRef () // True if killed\n         {\n         refcount--;\n         if ( refcount < 0 )\n            {\n            delete this;\n            return true;\n            }\n         \n         return false;\n         }\n\n      int len;\n      int refcount;\n      char *data;\n      int alloced;\n   };\n\nclass idStr {\nprotected:\n\tstrdata\t*m_data;\n\tvoid EnsureAlloced ( int, bool keepold = true );\n\tvoid EnsureDataWritable ();\n\npublic:\n\t~idStr();\n\tidStr();\n\tidStr( const char *text );\n\tidStr( const idStr& string );\n\tidStr( const idStr string, int start, int end );\n\tidStr( const char ch );\n\tidStr( const int num );\n\tidStr( const float num );\n\tidStr( const unsigned num );\n\tint\tlength( void ) const;\n\tint\tallocated( void ) const;\n\tconst char * c_str( void ) const;\n\n\tvoid\t\tappend( const char *text );\n\tvoid\t\tappend( const idStr& text );\n\tchar\t\toperator[]( int index ) const;\n\tchar&\t\toperator[]( int index );\n\n\tvoid\t\toperator=( const idStr& text );\n\tvoid\t\toperator=( const char *text );\n\n\tfriend\tidStr\t\toperator+( const idStr& a, const idStr& b );\n\tfriend\tidStr\t\toperator+( const idStr& a, const char *b );\n\tfriend\tidStr\t\toperator+( const char *a, const idStr& b );\n\n    friend\tidStr\t\toperator+( const idStr& a, const float b );\n    friend\tidStr\t\toperator+( const idStr& a, const int b );\n    friend\tidStr\t\toperator+( const idStr& a, const unsigned b );\n    friend\tidStr\t\toperator+( const idStr& a, const bool b );\n    friend\tidStr\t\toperator+( const idStr& a, const char b );\n\n\tidStr&\t\toperator+=( const idStr& a );\n\tidStr&\t\toperator+=( const char *a );\n\tidStr&\t\toperator+=( const float a );\n\tidStr&\t\toperator+=( const char a );\n\tidStr&\t\toperator+=( const int a );\n\tidStr&\t\toperator+=( const unsigned a );\n\tidStr&\t\toperator+=( const bool a );\n\n\tstatic   char     *toLower( char *s1 );\n\tstatic   char     *toUpper( char *s1 );\n\n\tfriend\tbool\t\toperator==(\tconst idStr& a, const idStr& b );\n\tfriend\tbool\t\toperator==(\tconst idStr& a, const char *b );\n\tfriend\tbool\t\toperator==(\tconst char *a, const idStr& b );\n\n\tfriend\tbool\t\toperator!=(\tconst idStr& a, const idStr& b );\n\tfriend\tbool\t\toperator!=(\tconst idStr& a, const char *b );\n\tfriend\tbool\t\toperator!=(\tconst char *a, const idStr& b );\n\n\toperator const char * () const;\n\toperator const char * ();\n\n    int      icmpn( const char *text, int n ) const;\n\tint      icmpn( const idStr& text, int n ) const;\n\tint      icmp( const char *text ) const;\n\tint      icmp( const idStr& text ) const;\n\tint      cmpn( const char *text, int n ) const;\n\tint      cmpn( const idStr& text, int n ) const;\n\tint      cmp( const char *text ) const;\n\tint      cmp( const idStr& text ) const;\n\n\tvoid     tolower( void );\n\tvoid     toupper( void );\n\n\tstatic   int      icmpn( const char *s1, const char *s2, int n );\n\tstatic   int      icmp( const char *s1, const char *s2 );\n\tstatic   int      cmpn( const char *s1, const char *s2, int n );\n\tstatic   int      cmp( const char *s1, const char *s2 );\n\n\tstatic   void     snprintf ( char *dst, int size, const char *fmt, ... );\n\n\tstatic   bool\t   isNumeric( const char *str );\n    bool    isNumeric( void ) const;\n\n\tvoid     CapLength ( int );\n\n\tvoid     BackSlashesToSlashes ();\n\n};\n\ninline idStr::~idStr()\n\t{\n   if ( m_data )\n      {\n      m_data->DelRef ();\n      m_data = NULL;\n      }\n\t}\n\ninline idStr::idStr() : m_data ( NULL )\n\t{\n   EnsureAlloced ( 1 );\n\tm_data->data[ 0 ] = 0;\n\t}\n\ninline idStr::idStr\n\t(\n\tconst char *text\n   ) : m_data ( NULL )\n\n\t{\n   int len;\n\n\tassert( text );\n\n\tif ( text )\n\t\t{\n      len = strlen( text );\n\t\tEnsureAlloced ( len + 1 );\n\t\tstrcpy( m_data->data, text );\n      m_data->len = len;\n\t\t}\n\telse\n\t\t{\n      EnsureAlloced ( 1 );\n\t\tm_data->data[ 0 ] = 0;\n\t\tm_data->len = 0;\n\t\t}\n\t}\n\ninline idStr::idStr\n\t(\n\tconst idStr& text\n   ) : m_data ( NULL )\n\n\t{\n   m_data = text.m_data;\n   m_data->AddRef ();\n   }\n\ninline idStr::idStr\n\t(\n\tconst idStr text, \n\tint start,\n\tint end\n   ) : m_data ( NULL )\n\n\t{\n\tint i;\n   int len;\n\n\tif ( end > text.length() )\n\t\t{\n\t\tend = text.length();\n\t\t}\n\n\tif ( start > text.length() )\n\t\t{\n\t\tstart = text.length();\n\t\t}\n\n\tlen = end - start;\n\tif ( len < 0 )\n\t\t{\n\t\tlen = 0;\n\t\t}\n\n   EnsureAlloced ( len + 1 );\n\n\tfor( i = 0; i < len; i++ )\n\t\t{\n\t\tm_data->data[ i ] = text[ start + i ];\n\t\t}\n\n\tm_data->data[ len ] = 0;\n   m_data->len = len;\n\t}\n\ninline idStr::idStr\n   (\n   const char ch\n   ) : m_data ( NULL )\n\n   {\n   EnsureAlloced ( 2 );\n\n   m_data->data[ 0 ] = ch;\n   m_data->data[ 1 ] = 0;\n   m_data->len = 1;\n   }\n\ninline idStr::idStr\n   (\n   const float num\n   ) : m_data ( NULL )\n\n   {\n   char text[ 32 ];\n   int len;\n\n   sprintf( text, \"%.3f\", num );\n   len = strlen( text );\n   EnsureAlloced( len + 1 );\n   strcpy( m_data->data, text );\n   m_data->len = len;\n   }\n\ninline idStr::idStr\n   (\n   const int num\n   ) : m_data ( NULL )\n\n   {\n   char text[ 32 ];\n   int len;\n\n   sprintf( text, \"%d\", num );\n   len = strlen( text );\n   EnsureAlloced( len + 1 );\n   strcpy( m_data->data, text );\n   m_data->len = len;\n   }\n\ninline idStr::idStr\n   (\n   const unsigned num\n   ) : m_data ( NULL )\n\n   {\n   char text[ 32 ];\n   int len;\n\n   sprintf( text, \"%u\", num );\n   len = strlen( text );\n   EnsureAlloced( len + 1 );\n   strcpy( m_data->data, text );\n   m_data->len = len;\n   }\n\ninline int idStr::length( void ) const\n\t{\n   return ( m_data != NULL ) ? m_data->len : 0;\n\t}\n\ninline int idStr::allocated( void ) const\n\t{\n   return ( m_data != NULL ) ? m_data->alloced + sizeof( *m_data ) : 0;\n\t}\n\ninline const char *idStr::c_str( void ) const\n\t{\n\tassert( m_data );\n\n\treturn m_data->data;\n\t}\n\ninline void idStr::append\n\t(\n\tconst char *text\n\t)\n\n\t{\n   int len;\n\n\tassert( text );\n\n\tif ( text )\n\t\t{\n\t\tlen = length() + strlen( text );\n\t\tEnsureAlloced( len + 1 );\n\n      strcat( m_data->data, text );\n      m_data->len = len;\n\t\t}\n\t}\n\ninline void idStr::append\n\t(\n\tconst idStr& text\n\t)\n\n\t{\n   int len;\n\n   len = length() + text.length();\n   EnsureAlloced ( len + 1 );\n\n   strcat ( m_data->data, text.c_str () );\n   m_data->len = len;\n\t}\n\ninline char idStr::operator[]( int index ) const\n\t{\n   assert ( m_data );\n   \n   if ( !m_data )\n      return 0;\n\n\t// don't include the '/0' in the test, because technically, it's out of bounds\n\tassert( ( index >= 0 ) && ( index < m_data->len ) );\n\n\t// In release mode, give them a null character\n\t// don't include the '/0' in the test, because technically, it's out of bounds\n\tif ( ( index < 0 ) || ( index >= m_data->len ) )\n\t\t{\n\t\treturn 0;\n\t\t}\n\n\treturn m_data->data[ index ];\n\t}\n\ninline char& idStr::operator[]\n\t(\n\tint index\n\t)\n\n\t{\n\t// Used for result for invalid indices\n\tstatic char dummy = 0;\n   assert ( m_data );\n\n   // We don't know if they'll write to it or not\n   // if it's not a const object\n   EnsureDataWritable ();\n\n   if ( !m_data )\n      return dummy;\n\n\t// don't include the '/0' in the test, because technically, it's out of bounds\n\tassert( ( index >= 0 ) && ( index < m_data->len ) );\n\n\t// In release mode, let them change a safe variable\n\t// don't include the '/0' in the test, because technically, it's out of bounds\n\tif ( ( index < 0 ) || ( index >= m_data->len ) )\n\t\t{\n\t\treturn dummy;\n\t\t}\n\n\treturn m_data->data[ index ];\n\t}\n\ninline void idStr::operator=\n\t(\n\tconst idStr& text\n\t)\n\n\t{\n   // adding the reference before deleting our current reference prevents\n   // us from deleting our string if we are copying from ourself\n   text.m_data->AddRef();\n   m_data->DelRef();\n   m_data = text.m_data;\n   }\n\ninline void idStr::operator=\n\t(\n\tconst char *text\n\t)\n\n\t{\n   int len;\n\n\tassert( text );\n\n\tif ( !text )\n\t\t{\n\t\t// safe behaviour if NULL\n\t\tEnsureAlloced ( 1, false );\n      m_data->data[0] = 0;\n      m_data->len = 0;\n      return;\n\t\t}\n\n   if ( !m_data )\n      {\n      len = strlen ( text );\n      EnsureAlloced( len + 1, false );\n      strcpy ( m_data->data, text );\n      m_data->len = len;\n      return;\n      }\n\n   if ( text == m_data->data )\n      return; // Copying same thing.  Punt.\n\n   // If we alias and I don't do this, I could corrupt other strings...  This \n   // will get called with EnsureAlloced anyway\n   EnsureDataWritable ();\n\n   // Now we need to check if we're aliasing..\n   if ( text >= m_data->data && text <= m_data->data + m_data->len )\n      {\n      // Great, we're aliasing.  We're copying from inside ourselves.\n      // This means that I don't have to ensure that anything is alloced,\n      // though I'll assert just in case.\n      int diff = text - m_data->data;\n      int i;\n\n      assert ( strlen ( text ) < (unsigned) m_data->len );\n      \n      for ( i = 0; text[i]; i++ )\n         {\n         m_data->data[i] = text[i];\n         }\n\n      m_data->data[i] = 0;\n\n      m_data->len -= diff;\n\n      return;\n      }\n\n\tlen = strlen( text );\n   EnsureAlloced ( len + 1, false );\n\tstrcpy( m_data->data, text );\n   m_data->len = len;\n\t}\n\ninline idStr operator+\n\t(\n\tconst idStr& a,\n\tconst idStr& b\n\t)\n\n\t{\n\tidStr result( a );\n\n\tresult.append( b );\n\n\treturn result;\n\t}\n\ninline idStr operator+\n\t(\n\tconst idStr& a,\n\tconst char *b\n\t)\n\n\t{\n\tidStr result( a );\n\n\tresult.append( b );\n\n\treturn result;\n\t}\n\ninline idStr operator+\n\t(\n\tconst char *a,\n\tconst idStr& b\n\t)\n\n\t{\n\tidStr result( a );\n\n\tresult.append( b );\n\n\treturn result;\n\t}\n\ninline idStr operator+\n   (\n   const idStr& a,\n   const bool b\n   )\n\n   {\n\tidStr result( a );\n\n   result.append( b ? \"true\" : \"false\" );\n\n\treturn result;\n   }\n\ninline idStr operator+\n\t(\n   const idStr& a,\n\tconst char b\n\t)\n\n\t{\n   char text[ 2 ];\n\n   text[ 0 ] = b;\n   text[ 1 ] = 0;\n\n\treturn a + text;\n\t}\n\ninline idStr& idStr::operator+=\n\t(\n\tconst idStr& a\n\t)\n\n\t{\n\tappend( a );\n\treturn *this;\n\t}\n\ninline idStr& idStr::operator+=\n\t(\n\tconst char *a\n\t)\n\n\t{\n\tappend( a );\n\treturn *this;\n\t}\n\ninline idStr& idStr::operator+=\n\t(\n\tconst char a\n\t)\n\n\t{\n   char text[ 2 ];\n\n   text[ 0 ] = a;\n   text[ 1 ] = 0;\n\tappend( text );\n\n   return *this;\n\t}\n\ninline idStr& idStr::operator+=\n\t(\n\tconst bool a\n\t)\n\n\t{\n   append( a ? \"true\" : \"false\" );\n\treturn *this;\n\t}\n\ninline bool operator==\n\t(\n\tconst idStr& a,\n\tconst idStr& b\n\t)\n\n\t{\n\treturn ( !strcmp( a.c_str(), b.c_str() ) );\n\t}\n\ninline bool operator==\n\t(\n\tconst idStr& a,\n\tconst char *b\n\t)\n\n\t{\n\tassert( b );\n\tif ( !b )\n\t\t{\n\t\treturn false;\n\t\t}\n\treturn ( !strcmp( a.c_str(), b ) );\n\t}\n\ninline bool operator==\n\t(\n\tconst char *a,\n\tconst idStr& b\n\t)\n\n\t{\n\tassert( a );\n\tif ( !a )\n\t\t{\n\t\treturn false;\n\t\t}\n\treturn ( !strcmp( a, b.c_str() ) );\n\t}\n\ninline bool operator!=\n\t(\n\tconst idStr& a,\n\tconst idStr& b\n\t)\n\n\t{\n\treturn !( a == b );\n\t}\n\ninline bool operator!=\n\t(\n\tconst idStr& a,\n\tconst char *b\n\t)\n\n\t{\n\treturn !( a == b );\n\t}\n\ninline bool operator!=\n\t(\n\tconst char *a,\n\tconst idStr& b\n\t)\n\n\t{\n\treturn !( a == b );\n\t}\n\ninline int idStr::icmpn\n   (\n   const char *text, \n   int n\n   ) const\n\n   {\n\tassert( m_data );\n\tassert( text );\n\n   return idStr::icmpn( m_data->data, text, n );\n   }\n\ninline int idStr::icmpn\n   (\n   const idStr& text, \n   int n\n   ) const\n\n   {\n\tassert( m_data );\n\tassert( text.m_data );\n\n   return idStr::icmpn( m_data->data, text.m_data->data, n );\n   }\n\ninline int idStr::icmp\n   (\n   const char *text\n   ) const\n\n   {\n\tassert( m_data );\n\tassert( text );\n\n   return idStr::icmp( m_data->data, text );\n   }\n\ninline int idStr::icmp\n   (\n   const idStr& text\n   ) const\n\n   {\n\tassert( c_str () );\n\tassert( text.c_str () );\n\n   return idStr::icmp( c_str () , text.c_str () );\n   }\n\ninline int idStr::cmp\n   (\n   const char *text\n   ) const\n\n   {\n\tassert( m_data );\n\tassert( text );\n\n   return idStr::cmp( m_data->data, text );\n   }\n\ninline int idStr::cmp\n   (\n   const idStr& text\n   ) const\n\n   {\n\tassert( c_str () );\n\tassert( text.c_str () );\n\n   return idStr::cmp( c_str () , text.c_str () );\n   }\n\ninline int idStr::cmpn\n   (\n   const char *text, \n   int n\n   ) const\n\n   {\n\tassert( c_str () );\n\tassert( text );\n\n   return idStr::cmpn( c_str () , text, n );\n   }\n\ninline int idStr::cmpn\n   (\n   const idStr& text, \n   int n\n   ) const\n\n   {\n\tassert( c_str () );\n\tassert( text.c_str ()  );\n\n   return idStr::cmpn( c_str () , text.c_str () , n );\n   }\n\ninline void idStr::tolower\n   (\n   void\n   )\n\n   {\n   assert( m_data );\n\n   EnsureDataWritable ();\n\n   idStr::toLower( m_data->data );\n   }\n\ninline void idStr::toupper\n   (\n   void\n   )\n\n   {\n   assert( m_data );\n\n   EnsureDataWritable ();\n\n   idStr::toUpper( m_data->data );\n   }\n\ninline bool idStr::isNumeric\n   (\n   void\n   ) const\n\n   {\n   assert( m_data );\n   return idStr::isNumeric( m_data->data );\n   }\n\ninline idStr::operator const char *() {\n\treturn c_str();\n}\n\ninline idStr::operator const char *\n   (\n   void\n   ) const\n\n   {\n   return c_str ();\n   }\n\n#endif\n"
  },
  {
    "path": "code/ui/Conscript",
    "content": "# TA ui building\n\n# qvm building against native:\n# only native has ui_syscalls.c\n# qvm uses a custom ui_syscalls.asm with equ stubs\n# qvm has additional bg_lib.c\n\nImport qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );\n\n$env = new cons(\n  # the code has the very bad habit of doing things like #include \"../ui/ui_shared.h\"\n  # this seems to confuse the dependency analysis, explicit toplevel includes seem to fix\n  CPPPATH => '#cgame:#game:#ui',\n  CC => $CC,\n  CXX => $CXX,\n  LINK => $LINK,\n\tENV => { PATH => $ENV{PATH}, HOME => $ENV{HOME} },\n  CFLAGS => $BASE_CFLAGS . '-DMISSIONPACK -fPIC',\n  LDFLAGS => '-shared -ldl -lm'\n);\n\n# qvm building\n# we heavily customize the cons environment\n$vm_env = new cons(\n  # the code has the very bad habit of doing things like #include \"../ui/ui_shared.h\"\n  # this seems to confuse the dependency analysis, explicit toplevel includes seem to fix\n  CPPPATH => '#cgame:#game:#ui',\n  CC => 'q3lcc',\n  CCCOM => '%CC %CFLAGS %_IFLAGS -c %< -o %>',\n  SUFOBJ => '.asm',\n  LINK => 'q3asm',\n  CFLAGS => '-DQ3_VM -DMISSIONPACK -S -Wf-target=bytecode -Wf-g',\n  # need to know where to find the compiler tools\n  ENV => { PATH => $ENV{PATH} . \":./qvmtools\", },\n);\n\n# the file with vmMain function MUST be the first one of the list\n@FILES = qw(\n  ui_main.c\n  ui_atoms.c\n  ui_gameinfo.c\n  ui_players.c\n  ui_util.c\n  ui_shared.c\n  ../game/bg_misc.c\n  ../game/q_math.c\n  ../game/q_shared.c\n  );\n$FILESREF = \\@FILES;\n\nif ($NO_SO eq 0)\n{\n\tProgram $env 'uii386.so', @$FILESREF, 'ui_syscalls.c';\n\tInstall $env $INSTALL_DIR, 'uii386.so';\n}\nif ($NO_VM eq 0)\n{\n  Depends $vm_env 'ui.qvm', '#qvmtools/q3lcc';\n  Depends $vm_env 'ui.qvm', '#qvmtools/q3asm';\n\tProgram $vm_env 'ui.qvm', @$FILESREF, '../game/bg_lib.c', 'ui_syscalls.asm';\n\tInstall $vm_env $INSTALL_DIR . '/vm', 'ui.qvm';\n}\n"
  },
  {
    "path": "code/ui/compile.bat",
    "content": "lcc -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\ui %1\n\n"
  },
  {
    "path": "code/ui/keycodes.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#ifndef __KEYCODES_H__\n#define __KEYCODES_H__\n\n//\n// these are the key numbers that should be passed to KeyEvent\n//\n\n// normal keys should be passed as lowercased ascii\n\ntypedef enum {\n\tK_TAB = 9,\n\tK_ENTER = 13,\n\tK_ESCAPE = 27,\n\tK_SPACE = 32,\n\n\tK_BACKSPACE = 127,\n\n\tK_COMMAND = 128,\n\tK_CAPSLOCK,\n\tK_POWER,\n\tK_PAUSE,\n\n\tK_UPARROW,\n\tK_DOWNARROW,\n\tK_LEFTARROW,\n\tK_RIGHTARROW,\n\n\tK_ALT,\n\tK_CTRL,\n\tK_SHIFT,\n\tK_INS,\n\tK_DEL,\n\tK_PGDN,\n\tK_PGUP,\n\tK_HOME,\n\tK_END,\n\n\tK_F1,\n\tK_F2,\n\tK_F3,\n\tK_F4,\n\tK_F5,\n\tK_F6,\n\tK_F7,\n\tK_F8,\n\tK_F9,\n\tK_F10,\n\tK_F11,\n\tK_F12,\n\tK_F13,\n\tK_F14,\n\tK_F15,\n\n\tK_KP_HOME,\n\tK_KP_UPARROW,\n\tK_KP_PGUP,\n\tK_KP_LEFTARROW,\n\tK_KP_5,\n\tK_KP_RIGHTARROW,\n\tK_KP_END,\n\tK_KP_DOWNARROW,\n\tK_KP_PGDN,\n\tK_KP_ENTER,\n\tK_KP_INS,\n\tK_KP_DEL,\n\tK_KP_SLASH,\n\tK_KP_MINUS,\n\tK_KP_PLUS,\n\tK_KP_NUMLOCK,\n\tK_KP_STAR,\n\tK_KP_EQUALS,\n\n\tK_MOUSE1,\n\tK_MOUSE2,\n\tK_MOUSE3,\n\tK_MOUSE4,\n\tK_MOUSE5,\n\n\tK_MWHEELDOWN,\n\tK_MWHEELUP,\n\n\tK_JOY1,\n\tK_JOY2,\n\tK_JOY3,\n\tK_JOY4,\n\tK_JOY5,\n\tK_JOY6,\n\tK_JOY7,\n\tK_JOY8,\n\tK_JOY9,\n\tK_JOY10,\n\tK_JOY11,\n\tK_JOY12,\n\tK_JOY13,\n\tK_JOY14,\n\tK_JOY15,\n\tK_JOY16,\n\tK_JOY17,\n\tK_JOY18,\n\tK_JOY19,\n\tK_JOY20,\n\tK_JOY21,\n\tK_JOY22,\n\tK_JOY23,\n\tK_JOY24,\n\tK_JOY25,\n\tK_JOY26,\n\tK_JOY27,\n\tK_JOY28,\n\tK_JOY29,\n\tK_JOY30,\n\tK_JOY31,\n\tK_JOY32,\n\n\tK_AUX1,\n\tK_AUX2,\n\tK_AUX3,\n\tK_AUX4,\n\tK_AUX5,\n\tK_AUX6,\n\tK_AUX7,\n\tK_AUX8,\n\tK_AUX9,\n\tK_AUX10,\n\tK_AUX11,\n\tK_AUX12,\n\tK_AUX13,\n\tK_AUX14,\n\tK_AUX15,\n\tK_AUX16,\n\n\tK_LAST_KEY\t\t// this had better be <256!\n} keyNum_t;\n\n\n// The menu code needs to get both key and char events, but\n// to avoid duplicating the paths, the char events are just\n// distinguished by or'ing in K_CHAR_FLAG (ugly)\n#define\tK_CHAR_FLAG\t\t1024\n\n#endif\n"
  },
  {
    "path": "code/ui/ui.bat",
    "content": "rem make sure we have a safe environement\nset LIBRARY=\nset INCLUDE=\n\nmkdir vm\ncd vm\n\nset cc=lcc -DMISSIONPACK -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\..\\cgame -I..\\..\\game -I..\\..\\ui %1\n\n%cc% ../ui_main.c\n@if errorlevel 1 goto quit\n%cc% ../../game/bg_misc.c\n@if errorlevel 1 goto quit\n%cc% ../../game/bg_lib.c\n@if errorlevel 1 goto quit\n%cc% ../../game/q_math.c\n@if errorlevel 1 goto quit\n%cc% ../../game/q_shared.c\n@if errorlevel 1 goto quit\n%cc% ../ui_atoms.c\n@if errorlevel 1 goto quit\n%cc% ../ui_players.c\n@if errorlevel 1 goto quit\n%cc% ../ui_util.c\n@if errorlevel 1 goto quit\n%cc% ../ui_shared.c\n@if errorlevel 1 goto quit\n%cc% ../ui_gameinfo.c\n@if errorlevel 1 goto quit\n\nq3asm -f ../ui\n:quit\ncd ..\n"
  },
  {
    "path": "code/ui/ui.def",
    "content": "EXPORTS\n\tvmMain\n\tdllEntry\n"
  },
  {
    "path": "code/ui/ui.q3asm",
    "content": "-o \"\\quake3\\missionpack\\vm\\ui\"\nui_main\n..\\ui_syscalls\nui_atoms\nui_players\nui_util\nui_shared\nui_gameinfo\nbg_misc\nbg_lib\nq_math\nq_shared\n"
  },
  {
    "path": "code/ui/ui.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<VisualStudioProject\n\tProjectType=\"Visual C++\"\n\tVersion=\"7.10\"\n\tName=\"ui\"\n\tSccProjectName=\"&quot;$/MissionPack/code/ui&quot;, AOBAAAAA\"\n\tSccAuxPath=\"\"\n\tSccLocalPath=\".\"\n\tSccProvider=\"MSSCCI:Perforce SCM\">\n\t<Platforms>\n\t\t<Platform\n\t\t\tName=\"Win32\"/>\n\t</Platforms>\n\t<Configurations>\n\t\t<Configuration\n\t\t\tName=\"vector|Win32\"\n\t\t\tOutputDirectory=\".\\ui___Win32_vector\"\n\t\t\tIntermediateDirectory=\".\\ui___Win32_vector\"\n\t\t\tConfigurationType=\"2\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tOptimizeForProcessor=\"2\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_USRDLL;UI_EXPORTS\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"4\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\ui___Win32_vector/ui.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\ui___Win32_vector/\"\n\t\t\t\tObjectFile=\".\\ui___Win32_vector/\"\n\t\t\t\tProgramDataBaseFileName=\".\\ui___Win32_vector/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"odbc32.lib odbccp32.lib\"\n\t\t\t\tOutputFile=\"../Release_TA/uix86.dll\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tModuleDefinitionFile=\".\\ui.def\"\n\t\t\t\tProgramDatabaseFile=\".\\ui___Win32_vector/uix86.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\".\\ui___Win32_vector/uix86.map\"\n\t\t\t\tBaseAddress=\"0x40000000\"\n\t\t\t\tImportLibrary=\".\\ui___Win32_vector/uix86.lib\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\ui___Win32_vector/ui.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Release TA|Win32\"\n\t\t\tOutputDirectory=\".\\Release_TA\"\n\t\t\tIntermediateDirectory=\".\\Release_TA\"\n\t\t\tConfigurationType=\"2\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tOptimizeForProcessor=\"2\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_USRDLL;UI_EXPORTS\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"4\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release_TA/ui.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release_TA/\"\n\t\t\t\tObjectFile=\".\\Release_TA/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release_TA/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"odbc32.lib odbccp32.lib\"\n\t\t\t\tOutputFile=\"../Release_TA/uix86.dll\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tModuleDefinitionFile=\".\\ui.def\"\n\t\t\t\tProgramDatabaseFile=\".\\Release_TA/uix86.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\".\\Release_TA/uix86.map\"\n\t\t\t\tBaseAddress=\"0x40000000\"\n\t\t\t\tImportLibrary=\".\\Release_TA/uix86.lib\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Release_TA/ui.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Debug|Win32\"\n\t\t\tOutputDirectory=\".\\Debug\"\n\t\t\tIntermediateDirectory=\".\\Debug\"\n\t\t\tConfigurationType=\"2\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tOptimizeForProcessor=\"1\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_USRDLL;UI_EXPORTS\"\n\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Debug/ui.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug/\"\n\t\t\t\tObjectFile=\".\\Debug/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Debug/\"\n\t\t\t\tBrowseInformation=\"1\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"odbc32.lib odbccp32.lib\"\n\t\t\t\tOutputFile=\"../Debug/uix86_new.dll\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\"../Debug/ui.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\".\\Debug/uix86_new.map\"\n\t\t\t\tBaseAddress=\"0x40000000\"\n\t\t\t\tImportLibrary=\".\\Debug/uix86_new.lib\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Debug/ui.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Release|Win32\"\n\t\t\tOutputDirectory=\".\\Release\"\n\t\t\tIntermediateDirectory=\".\\Release\"\n\t\t\tConfigurationType=\"2\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tOptimizeForProcessor=\"2\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_USRDLL;UI_EXPORTS\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"4\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release/ui.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release/\"\n\t\t\t\tObjectFile=\".\\Release/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"odbc32.lib odbccp32.lib\"\n\t\t\t\tOutputFile=\"../Release/uix86_new.dll\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\Release/uix86_new.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\".\\Release/uix86_new.map\"\n\t\t\t\tBaseAddress=\"0x40000000\"\n\t\t\t\tImportLibrary=\".\\Release/uix86_new.lib\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Release/ui.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Debug TA|Win32\"\n\t\t\tOutputDirectory=\".\\Debug_TA\"\n\t\t\tIntermediateDirectory=\".\\Debug_TA\"\n\t\t\tConfigurationType=\"2\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tOptimizeForProcessor=\"1\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_USRDLL;UI_EXPORTS;MISSIONPACK\"\n\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Debug_TA/ui.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug_TA/\"\n\t\t\t\tObjectFile=\".\\Debug_TA/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Debug_TA/\"\n\t\t\t\tBrowseInformation=\"1\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"odbc32.lib odbccp32.lib\"\n\t\t\t\tOutputFile=\"../Debug_TA/uix86.dll\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tModuleDefinitionFile=\".\\ui.def\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\"../Debug/ui.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\".\\Debug_TA/uix86.map\"\n\t\t\t\tBaseAddress=\"0x40000000\"\n\t\t\t\tImportLibrary=\".\\Debug_TA/uix86.lib\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Debug_TA/ui.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t</Configurations>\n\t<References>\n\t</References>\n\t<Files>\n\t\t<Filter\n\t\t\tName=\"Source Files\"\n\t\t\tFilter=\"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\bg_lib.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\bg_misc.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\q_math.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\q_shared.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui.def\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_atoms.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_gameinfo.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_main.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_players.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_shared.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_syscalls.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_util.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"vector|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;$(NoInherit)\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug TA|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;UI_EXPORTS;MISSIONPACK;$(NoInherit)\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Header Files\"\n\t\t\tFilter=\"h;hpp;hxx;hm;inl\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\bg_public.h\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"keycodes.h\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\..\\ui\\menudef.h\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\q_shared.h\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\game\\surfaceflags.h\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\cgame\\tr_types.h\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_local.h\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_public.h\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ui_shared.h\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Resource Files\"\n\t\t\tFilter=\"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\">\n\t\t</Filter>\n\t</Files>\n\t<Globals>\n\t</Globals>\n</VisualStudioProject>\n"
  },
  {
    "path": "code/ui/ui_atoms.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/**********************************************************************\n\tUI_ATOMS.C\n\n\tUser interface building blocks and support functions.\n**********************************************************************/\n#include \"ui_local.h\"\n\nqboolean\t\tm_entersound;\t\t// after a frame, so caching won't disrupt the sound\n\n// these are here so the functions in q_shared.c can link\n#ifndef UI_HARD_LINKED\n\nvoid QDECL Com_Error( int level, const char *error, ... ) {\n\tva_list\t\targptr;\n\tchar\t\ttext[1024];\n\n\tva_start (argptr, error);\n\tvsprintf (text, error, argptr);\n\tva_end (argptr);\n\n\ttrap_Error( va(\"%s\", text) );\n}\n\nvoid QDECL Com_Printf( const char *msg, ... ) {\n\tva_list\t\targptr;\n\tchar\t\ttext[1024];\n\n\tva_start (argptr, msg);\n\tvsprintf (text, msg, argptr);\n\tva_end (argptr);\n\n\ttrap_Print( va(\"%s\", text) );\n}\n\n#endif\n\nqboolean newUI = qfalse;\n\n\n/*\n=================\nUI_ClampCvar\n=================\n*/\nfloat UI_ClampCvar( float min, float max, float value )\n{\n\tif ( value < min ) return min;\n\tif ( value > max ) return max;\n\treturn value;\n}\n\n/*\n=================\nUI_StartDemoLoop\n=================\n*/\nvoid UI_StartDemoLoop( void ) {\n\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"d1\\n\" );\n}\n\n\n#ifndef MISSIONPACK // bk001206\nstatic void NeedCDAction( qboolean result ) {\n\tif ( !result ) {\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"quit\\n\" );\n\t}\n}\n#endif // MISSIONPACK\n\n#ifndef MISSIONPACK // bk001206\nstatic void NeedCDKeyAction( qboolean result ) {\n\tif ( !result ) {\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"quit\\n\" );\n\t}\n}\n#endif // MISSIONPACK\n\nchar *UI_Argv( int arg ) {\n\tstatic char\tbuffer[MAX_STRING_CHARS];\n\n\ttrap_Argv( arg, buffer, sizeof( buffer ) );\n\n\treturn buffer;\n}\n\n\nchar *UI_Cvar_VariableString( const char *var_name ) {\n\tstatic char\tbuffer[MAX_STRING_CHARS];\n\n\ttrap_Cvar_VariableStringBuffer( var_name, buffer, sizeof( buffer ) );\n\n\treturn buffer;\n}\n\n\n\nvoid UI_SetBestScores(postGameInfo_t *newInfo, qboolean postGame) {\n\ttrap_Cvar_Set(\"ui_scoreAccuracy\",     va(\"%i%%\", newInfo->accuracy));\n\ttrap_Cvar_Set(\"ui_scoreImpressives\",\tva(\"%i\", newInfo->impressives));\n\ttrap_Cvar_Set(\"ui_scoreExcellents\", \tva(\"%i\", newInfo->excellents));\n\ttrap_Cvar_Set(\"ui_scoreDefends\", \t\t\tva(\"%i\", newInfo->defends));\n\ttrap_Cvar_Set(\"ui_scoreAssists\", \t\t\tva(\"%i\", newInfo->assists));\n\ttrap_Cvar_Set(\"ui_scoreGauntlets\", \t\tva(\"%i\", newInfo->gauntlets));\n\ttrap_Cvar_Set(\"ui_scoreScore\", \t\t\t\tva(\"%i\", newInfo->score));\n\ttrap_Cvar_Set(\"ui_scorePerfect\",\t \t\tva(\"%i\", newInfo->perfects));\n\ttrap_Cvar_Set(\"ui_scoreTeam\",\t\t\t\t\tva(\"%i to %i\", newInfo->redScore, newInfo->blueScore));\n\ttrap_Cvar_Set(\"ui_scoreBase\",\t\t\t\t\tva(\"%i\", newInfo->baseScore));\n\ttrap_Cvar_Set(\"ui_scoreTimeBonus\",\t\tva(\"%i\", newInfo->timeBonus));\n\ttrap_Cvar_Set(\"ui_scoreSkillBonus\",\t\tva(\"%i\", newInfo->skillBonus));\n\ttrap_Cvar_Set(\"ui_scoreShutoutBonus\",\tva(\"%i\", newInfo->shutoutBonus));\n\ttrap_Cvar_Set(\"ui_scoreTime\",\t\t\t\t\tva(\"%02i:%02i\", newInfo->time / 60, newInfo->time % 60));\n\ttrap_Cvar_Set(\"ui_scoreCaptures\",\t\tva(\"%i\", newInfo->captures));\n  if (postGame) {\n\t\ttrap_Cvar_Set(\"ui_scoreAccuracy2\",     va(\"%i%%\", newInfo->accuracy));\n\t\ttrap_Cvar_Set(\"ui_scoreImpressives2\",\tva(\"%i\", newInfo->impressives));\n\t\ttrap_Cvar_Set(\"ui_scoreExcellents2\", \tva(\"%i\", newInfo->excellents));\n\t\ttrap_Cvar_Set(\"ui_scoreDefends2\", \t\t\tva(\"%i\", newInfo->defends));\n\t\ttrap_Cvar_Set(\"ui_scoreAssists2\", \t\t\tva(\"%i\", newInfo->assists));\n\t\ttrap_Cvar_Set(\"ui_scoreGauntlets2\", \t\tva(\"%i\", newInfo->gauntlets));\n\t\ttrap_Cvar_Set(\"ui_scoreScore2\", \t\t\t\tva(\"%i\", newInfo->score));\n\t\ttrap_Cvar_Set(\"ui_scorePerfect2\",\t \t\tva(\"%i\", newInfo->perfects));\n\t\ttrap_Cvar_Set(\"ui_scoreTeam2\",\t\t\t\t\tva(\"%i to %i\", newInfo->redScore, newInfo->blueScore));\n\t\ttrap_Cvar_Set(\"ui_scoreBase2\",\t\t\t\t\tva(\"%i\", newInfo->baseScore));\n\t\ttrap_Cvar_Set(\"ui_scoreTimeBonus2\",\t\tva(\"%i\", newInfo->timeBonus));\n\t\ttrap_Cvar_Set(\"ui_scoreSkillBonus2\",\t\tva(\"%i\", newInfo->skillBonus));\n\t\ttrap_Cvar_Set(\"ui_scoreShutoutBonus2\",\tva(\"%i\", newInfo->shutoutBonus));\n\t\ttrap_Cvar_Set(\"ui_scoreTime2\",\t\t\t\t\tva(\"%02i:%02i\", newInfo->time / 60, newInfo->time % 60));\n\t\ttrap_Cvar_Set(\"ui_scoreCaptures2\",\t\tva(\"%i\", newInfo->captures));\n\t}\n}\n\nvoid UI_LoadBestScores(const char *map, int game) {\n\tchar\t\tfileName[MAX_QPATH];\n\tfileHandle_t f;\n\tpostGameInfo_t newInfo;\n\tmemset(&newInfo, 0, sizeof(postGameInfo_t));\n\tCom_sprintf(fileName, MAX_QPATH, \"games/%s_%i.game\", map, game);\n\tif (trap_FS_FOpenFile(fileName, &f, FS_READ) >= 0) {\n\t\tint size = 0;\n\t\ttrap_FS_Read(&size, sizeof(int), f);\n\t\tif (size == sizeof(postGameInfo_t)) {\n\t\t\ttrap_FS_Read(&newInfo, sizeof(postGameInfo_t), f);\n\t\t}\n\t\ttrap_FS_FCloseFile(f);\n\t}\n\tUI_SetBestScores(&newInfo, qfalse);\n\n\tCom_sprintf(fileName, MAX_QPATH, \"demos/%s_%d.dm_%d\", map, game, (int)trap_Cvar_VariableValue(\"protocol\"));\n\tuiInfo.demoAvailable = qfalse;\n\tif (trap_FS_FOpenFile(fileName, &f, FS_READ) >= 0) {\n\t\tuiInfo.demoAvailable = qtrue;\n\t\ttrap_FS_FCloseFile(f);\n\t} \n}\n\n/*\n===============\nUI_ClearScores\n===============\n*/\nvoid UI_ClearScores() {\n\tchar\tgameList[4096];\n\tchar *gameFile;\n\tint\t\ti, len, count, size;\n\tfileHandle_t f;\n\tpostGameInfo_t newInfo;\n\n\tcount = trap_FS_GetFileList( \"games\", \"game\", gameList, sizeof(gameList) );\n\n\tsize = sizeof(postGameInfo_t);\n\tmemset(&newInfo, 0, size);\n\n\tif (count > 0) {\n\t\tgameFile = gameList;\n\t\tfor ( i = 0; i < count; i++ ) {\n\t\t\tlen = strlen(gameFile);\n\t\t\tif (trap_FS_FOpenFile(va(\"games/%s\",gameFile), &f, FS_WRITE) >= 0) {\n\t\t\t\ttrap_FS_Write(&size, sizeof(int), f);\n\t\t\t\ttrap_FS_Write(&newInfo, size, f);\n\t\t\t\ttrap_FS_FCloseFile(f);\n\t\t\t}\n\t\t\tgameFile += len + 1;\n\t\t}\n\t}\n\t\n\tUI_SetBestScores(&newInfo, qfalse);\n\n}\n\n\n\nstatic void\tUI_Cache_f() {\n\tDisplay_CacheAll();\n}\n\n/*\n=======================\nUI_CalcPostGameStats\n=======================\n*/\nstatic void UI_CalcPostGameStats() {\n\tchar\t\tmap[MAX_QPATH];\n\tchar\t\tfileName[MAX_QPATH];\n\tchar\t\tinfo[MAX_INFO_STRING];\n\tfileHandle_t f;\n\tint size, game, time, adjustedTime;\n\tpostGameInfo_t oldInfo;\n\tpostGameInfo_t newInfo;\n\tqboolean newHigh = qfalse;\n\n\ttrap_GetConfigString( CS_SERVERINFO, info, sizeof(info) );\n\tQ_strncpyz( map, Info_ValueForKey( info, \"mapname\" ), sizeof(map) );\n\tgame = atoi(Info_ValueForKey(info, \"g_gametype\"));\n\n\t// compose file name\n\tCom_sprintf(fileName, MAX_QPATH, \"games/%s_%i.game\", map, game);\n\t// see if we have one already\n\tmemset(&oldInfo, 0, sizeof(postGameInfo_t));\n\tif (trap_FS_FOpenFile(fileName, &f, FS_READ) >= 0) {\n\t// if so load it\n\t\tsize = 0;\n\t\ttrap_FS_Read(&size, sizeof(int), f);\n\t\tif (size == sizeof(postGameInfo_t)) {\n\t\t\ttrap_FS_Read(&oldInfo, sizeof(postGameInfo_t), f);\n\t\t}\n\t\ttrap_FS_FCloseFile(f);\n\t}\t\t\t\t\t \n\n\tnewInfo.accuracy = atoi(UI_Argv(3));\n\tnewInfo.impressives = atoi(UI_Argv(4));\n\tnewInfo.excellents = atoi(UI_Argv(5));\n\tnewInfo.defends = atoi(UI_Argv(6));\n\tnewInfo.assists = atoi(UI_Argv(7));\n\tnewInfo.gauntlets = atoi(UI_Argv(8));\n\tnewInfo.baseScore = atoi(UI_Argv(9));\n\tnewInfo.perfects = atoi(UI_Argv(10));\n\tnewInfo.redScore = atoi(UI_Argv(11));\n\tnewInfo.blueScore = atoi(UI_Argv(12));\n\ttime = atoi(UI_Argv(13));\n\tnewInfo.captures = atoi(UI_Argv(14));\n\n\tnewInfo.time = (time - trap_Cvar_VariableValue(\"ui_matchStartTime\")) / 1000;\n\tadjustedTime = uiInfo.mapList[ui_currentMap.integer].timeToBeat[game];\n\tif (newInfo.time < adjustedTime) { \n\t\tnewInfo.timeBonus = (adjustedTime - newInfo.time) * 10;\n\t} else {\n\t\tnewInfo.timeBonus = 0;\n\t}\n\n\tif (newInfo.redScore > newInfo.blueScore && newInfo.blueScore <= 0) {\n\t\tnewInfo.shutoutBonus = 100;\n\t} else {\n\t\tnewInfo.shutoutBonus = 0;\n\t}\n\n\tnewInfo.skillBonus = trap_Cvar_VariableValue(\"g_spSkill\");\n\tif (newInfo.skillBonus <= 0) {\n\t\tnewInfo.skillBonus = 1;\n\t}\n\tnewInfo.score = newInfo.baseScore + newInfo.shutoutBonus + newInfo.timeBonus;\n\tnewInfo.score *= newInfo.skillBonus;\n\n\t// see if the score is higher for this one\n\tnewHigh = (newInfo.redScore > newInfo.blueScore && newInfo.score > oldInfo.score);\n\n\tif  (newHigh) {\n\t\t// if so write out the new one\n\t\tuiInfo.newHighScoreTime = uiInfo.uiDC.realTime + 20000;\n\t\tif (trap_FS_FOpenFile(fileName, &f, FS_WRITE) >= 0) {\n\t\t\tsize = sizeof(postGameInfo_t);\n\t\t\ttrap_FS_Write(&size, sizeof(int), f);\n\t\t\ttrap_FS_Write(&newInfo, sizeof(postGameInfo_t), f);\n\t\t\ttrap_FS_FCloseFile(f);\n\t\t}\n\t}\n\n\tif (newInfo.time < oldInfo.time) {\n\t\tuiInfo.newBestTime = uiInfo.uiDC.realTime + 20000;\n\t}\n \n\t// put back all the ui overrides\n\ttrap_Cvar_Set(\"capturelimit\", UI_Cvar_VariableString(\"ui_saveCaptureLimit\"));\n\ttrap_Cvar_Set(\"fraglimit\", UI_Cvar_VariableString(\"ui_saveFragLimit\"));\n\ttrap_Cvar_Set(\"cg_drawTimer\", UI_Cvar_VariableString(\"ui_drawTimer\"));\n\ttrap_Cvar_Set(\"g_doWarmup\", UI_Cvar_VariableString(\"ui_doWarmup\"));\n\ttrap_Cvar_Set(\"g_Warmup\", UI_Cvar_VariableString(\"ui_Warmup\"));\n\ttrap_Cvar_Set(\"sv_pure\", UI_Cvar_VariableString(\"ui_pure\"));\n\ttrap_Cvar_Set(\"g_friendlyFire\", UI_Cvar_VariableString(\"ui_friendlyFire\"));\n\n\tUI_SetBestScores(&newInfo, qtrue);\n\tUI_ShowPostGame(newHigh);\n\n\n}\n\n\n/*\n=================\nUI_ConsoleCommand\n=================\n*/\nqboolean UI_ConsoleCommand( int realTime ) {\n\tchar\t*cmd;\n\n\tuiInfo.uiDC.frameTime = realTime - uiInfo.uiDC.realTime;\n\tuiInfo.uiDC.realTime = realTime;\n\n\tcmd = UI_Argv( 0 );\n\n\t// ensure minimum menu data is available\n\t//Menu_Cache();\n\n\tif ( Q_stricmp (cmd, \"ui_test\") == 0 ) {\n\t\tUI_ShowPostGame(qtrue);\n\t}\n\n\tif ( Q_stricmp (cmd, \"ui_report\") == 0 ) {\n\t\tUI_Report();\n\t\treturn qtrue;\n\t}\n\t\n\tif ( Q_stricmp (cmd, \"ui_load\") == 0 ) {\n\t\tUI_Load();\n\t\treturn qtrue;\n\t}\n\n\tif ( Q_stricmp (cmd, \"remapShader\") == 0 ) {\n\t\tif (trap_Argc() == 4) {\n\t\t\tchar shader1[MAX_QPATH];\n\t\t\tchar shader2[MAX_QPATH];\n\t\t\tQ_strncpyz(shader1, UI_Argv(1), sizeof(shader1));\n\t\t\tQ_strncpyz(shader2, UI_Argv(2), sizeof(shader2));\n\t\t\ttrap_R_RemapShader(shader1, shader2, UI_Argv(3));\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\n\tif ( Q_stricmp (cmd, \"postgame\") == 0 ) {\n\t\tUI_CalcPostGameStats();\n\t\treturn qtrue;\n\t}\n\n\tif ( Q_stricmp (cmd, \"ui_cache\") == 0 ) {\n\t\tUI_Cache_f();\n\t\treturn qtrue;\n\t}\n\n\tif ( Q_stricmp (cmd, \"ui_teamOrders\") == 0 ) {\n\t\t//UI_TeamOrdersMenu_f();\n\t\treturn qtrue;\n\t}\n\n\n\tif ( Q_stricmp (cmd, \"ui_cdkey\") == 0 ) {\n\t\t//UI_CDKeyMenu_f();\n\t\treturn qtrue;\n\t}\n\n\treturn qfalse;\n}\n\n/*\n=================\nUI_Shutdown\n=================\n*/\nvoid UI_Shutdown( void ) {\n}\n\n/*\n================\nUI_AdjustFrom640\n\nAdjusted for resolution and screen aspect ratio\n================\n*/\nvoid UI_AdjustFrom640( float *x, float *y, float *w, float *h ) {\n\t// expect valid pointers\n#if 0\n\t*x = *x * uiInfo.uiDC.scale + uiInfo.uiDC.bias;\n\t*y *= uiInfo.uiDC.scale;\n\t*w *= uiInfo.uiDC.scale;\n\t*h *= uiInfo.uiDC.scale;\n#endif\n\n\t*x *= uiInfo.uiDC.xscale;\n\t*y *= uiInfo.uiDC.yscale;\n\t*w *= uiInfo.uiDC.xscale;\n\t*h *= uiInfo.uiDC.yscale;\n\n}\n\nvoid UI_DrawNamedPic( float x, float y, float width, float height, const char *picname ) {\n\tqhandle_t\thShader;\n\n\thShader = trap_R_RegisterShaderNoMip( picname );\n\tUI_AdjustFrom640( &x, &y, &width, &height );\n\ttrap_R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader );\n}\n\nvoid UI_DrawHandlePic( float x, float y, float w, float h, qhandle_t hShader ) {\n\tfloat\ts0;\n\tfloat\ts1;\n\tfloat\tt0;\n\tfloat\tt1;\n\n\tif( w < 0 ) {\t// flip about vertical\n\t\tw  = -w;\n\t\ts0 = 1;\n\t\ts1 = 0;\n\t}\n\telse {\n\t\ts0 = 0;\n\t\ts1 = 1;\n\t}\n\n\tif( h < 0 ) {\t// flip about horizontal\n\t\th  = -h;\n\t\tt0 = 1;\n\t\tt1 = 0;\n\t}\n\telse {\n\t\tt0 = 0;\n\t\tt1 = 1;\n\t}\n\t\n\tUI_AdjustFrom640( &x, &y, &w, &h );\n\ttrap_R_DrawStretchPic( x, y, w, h, s0, t0, s1, t1, hShader );\n}\n\n/*\n================\nUI_FillRect\n\nCoordinates are 640*480 virtual values\n=================\n*/\nvoid UI_FillRect( float x, float y, float width, float height, const float *color ) {\n\ttrap_R_SetColor( color );\n\n\tUI_AdjustFrom640( &x, &y, &width, &height );\n\ttrap_R_DrawStretchPic( x, y, width, height, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );\n\n\ttrap_R_SetColor( NULL );\n}\n\nvoid UI_DrawSides(float x, float y, float w, float h) {\n\tUI_AdjustFrom640( &x, &y, &w, &h );\n\ttrap_R_DrawStretchPic( x, y, 1, h, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );\n\ttrap_R_DrawStretchPic( x + w - 1, y, 1, h, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );\n}\n\nvoid UI_DrawTopBottom(float x, float y, float w, float h) {\n\tUI_AdjustFrom640( &x, &y, &w, &h );\n\ttrap_R_DrawStretchPic( x, y, w, 1, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );\n\ttrap_R_DrawStretchPic( x, y + h - 1, w, 1, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );\n}\n/*\n================\nUI_DrawRect\n\nCoordinates are 640*480 virtual values\n=================\n*/\nvoid UI_DrawRect( float x, float y, float width, float height, const float *color ) {\n\ttrap_R_SetColor( color );\n\n  UI_DrawTopBottom(x, y, width, height);\n  UI_DrawSides(x, y, width, height);\n\n\ttrap_R_SetColor( NULL );\n}\n\nvoid UI_SetColor( const float *rgba ) {\n\ttrap_R_SetColor( rgba );\n}\n\nvoid UI_UpdateScreen( void ) {\n\ttrap_UpdateScreen();\n}\n\n\nvoid UI_DrawTextBox (int x, int y, int width, int lines)\n{\n\tUI_FillRect( x + BIGCHAR_WIDTH/2, y + BIGCHAR_HEIGHT/2, ( width + 1 ) * BIGCHAR_WIDTH, ( lines + 1 ) * BIGCHAR_HEIGHT, colorBlack );\n\tUI_DrawRect( x + BIGCHAR_WIDTH/2, y + BIGCHAR_HEIGHT/2, ( width + 1 ) * BIGCHAR_WIDTH, ( lines + 1 ) * BIGCHAR_HEIGHT, colorWhite );\n}\n\nqboolean UI_CursorInRect (int x, int y, int width, int height)\n{\n\tif (uiInfo.uiDC.cursorx < x ||\n\t\tuiInfo.uiDC.cursory < y ||\n\t\tuiInfo.uiDC.cursorx > x+width ||\n\t\tuiInfo.uiDC.cursory > y+height)\n\t\treturn qfalse;\n\n\treturn qtrue;\n}\n"
  },
  {
    "path": "code/ui/ui_gameinfo.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n//\n// gameinfo.c\n//\n\n#include \"ui_local.h\"\n\n\n//\n// arena and bot info\n//\n\n\nint\t\t\t\tui_numBots;\nstatic char\t\t*ui_botInfos[MAX_BOTS];\n\nstatic int\t\tui_numArenas;\nstatic char\t\t*ui_arenaInfos[MAX_ARENAS];\n\n#ifndef MISSIONPACK // bk001206\nstatic int\t\tui_numSinglePlayerArenas;\nstatic int\t\tui_numSpecialSinglePlayerArenas;\n#endif\n\n/*\n===============\nUI_ParseInfos\n===============\n*/\nint UI_ParseInfos( char *buf, int max, char *infos[] ) {\n\tchar\t*token;\n\tint\t\tcount;\n\tchar\tkey[MAX_TOKEN_CHARS];\n\tchar\tinfo[MAX_INFO_STRING];\n\n\tcount = 0;\n\n\twhile ( 1 ) {\n\t\ttoken = COM_Parse( &buf );\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( strcmp( token, \"{\" ) ) {\n\t\t\tCom_Printf( \"Missing { in info file\\n\" );\n\t\t\tbreak;\n\t\t}\n\n\t\tif ( count == max ) {\n\t\t\tCom_Printf( \"Max infos exceeded\\n\" );\n\t\t\tbreak;\n\t\t}\n\n\t\tinfo[0] = '\\0';\n\t\twhile ( 1 ) {\n\t\t\ttoken = COM_ParseExt( &buf, qtrue );\n\t\t\tif ( !token[0] ) {\n\t\t\t\tCom_Printf( \"Unexpected end of info file\\n\" );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( !strcmp( token, \"}\" ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tQ_strncpyz( key, token, sizeof( key ) );\n\n\t\t\ttoken = COM_ParseExt( &buf, qfalse );\n\t\t\tif ( !token[0] ) {\n\t\t\t\tstrcpy( token, \"<NULL>\" );\n\t\t\t}\n\t\t\tInfo_SetValueForKey( info, key, token );\n\t\t}\n\t\t//NOTE: extra space for arena number\n\t\tinfos[count] = UI_Alloc(strlen(info) + strlen(\"\\\\num\\\\\") + strlen(va(\"%d\", MAX_ARENAS)) + 1);\n\t\tif (infos[count]) {\n\t\t\tstrcpy(infos[count], info);\n\t\t\tcount++;\n\t\t}\n\t}\n\treturn count;\n}\n\n/*\n===============\nUI_LoadArenasFromFile\n===============\n*/\nstatic void UI_LoadArenasFromFile( char *filename ) {\n\tint\t\t\t\tlen;\n\tfileHandle_t\tf;\n\tchar\t\t\tbuf[MAX_ARENAS_TEXT];\n\n\tlen = trap_FS_FOpenFile( filename, &f, FS_READ );\n\tif ( !f ) {\n\t\ttrap_Print( va( S_COLOR_RED \"file not found: %s\\n\", filename ) );\n\t\treturn;\n\t}\n\tif ( len >= MAX_ARENAS_TEXT ) {\n\t\ttrap_Print( va( S_COLOR_RED \"file too large: %s is %i, max allowed is %i\", filename, len, MAX_ARENAS_TEXT ) );\n\t\ttrap_FS_FCloseFile( f );\n\t\treturn;\n\t}\n\n\ttrap_FS_Read( buf, len, f );\n\tbuf[len] = 0;\n\ttrap_FS_FCloseFile( f );\n\n\tui_numArenas += UI_ParseInfos( buf, MAX_ARENAS - ui_numArenas, &ui_arenaInfos[ui_numArenas] );\n}\n\n/*\n===============\nUI_LoadArenas\n===============\n*/\nvoid UI_LoadArenas( void ) {\n\tint\t\t\tnumdirs;\n\tvmCvar_t\tarenasFile;\n\tchar\t\tfilename[128];\n\tchar\t\tdirlist[1024];\n\tchar*\t\tdirptr;\n\tint\t\t\ti, n;\n\tint\t\t\tdirlen;\n\tchar\t\t*type;\n\n\tui_numArenas = 0;\n\tuiInfo.mapCount = 0;\n\n\ttrap_Cvar_Register( &arenasFile, \"g_arenasFile\", \"\", CVAR_INIT|CVAR_ROM );\n\tif( *arenasFile.string ) {\n\t\tUI_LoadArenasFromFile(arenasFile.string);\n\t}\n\telse {\n\t\tUI_LoadArenasFromFile(\"scripts/arenas.txt\");\n\t}\n\n\t// get all arenas from .arena files\n\tnumdirs = trap_FS_GetFileList(\"scripts\", \".arena\", dirlist, 1024 );\n\tdirptr  = dirlist;\n\tfor (i = 0; i < numdirs; i++, dirptr += dirlen+1) {\n\t\tdirlen = strlen(dirptr);\n\t\tstrcpy(filename, \"scripts/\");\n\t\tstrcat(filename, dirptr);\n\t\tUI_LoadArenasFromFile(filename);\n\t}\n\ttrap_Print( va( \"%i arenas parsed\\n\", ui_numArenas ) );\n\tif (UI_OutOfMemory()) {\n\t\ttrap_Print(S_COLOR_YELLOW\"WARNING: not anough memory in pool to load all arenas\\n\");\n\t}\n\n\tfor( n = 0; n < ui_numArenas; n++ ) {\n\t\t// determine type\n\n\t\tuiInfo.mapList[uiInfo.mapCount].cinematic = -1;\n\t\tuiInfo.mapList[uiInfo.mapCount].mapLoadName = String_Alloc(Info_ValueForKey(ui_arenaInfos[n], \"map\"));\n\t\tuiInfo.mapList[uiInfo.mapCount].mapName = String_Alloc(Info_ValueForKey(ui_arenaInfos[n], \"longname\"));\n\t\tuiInfo.mapList[uiInfo.mapCount].levelShot = -1;\n\t\tuiInfo.mapList[uiInfo.mapCount].imageName = String_Alloc(va(\"levelshots/%s\", uiInfo.mapList[uiInfo.mapCount].mapLoadName));\n\t\tuiInfo.mapList[uiInfo.mapCount].typeBits = 0;\n\n\t\ttype = Info_ValueForKey( ui_arenaInfos[n], \"type\" );\n\t\t// if no type specified, it will be treated as \"ffa\"\n\t\tif( *type ) {\n\t\t\tif( strstr( type, \"ffa\" ) ) {\n\t\t\t\tuiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_FFA);\n\t\t\t}\n\t\t\tif( strstr( type, \"tourney\" ) ) {\n\t\t\t\tuiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_TOURNAMENT);\n\t\t\t}\n\t\t\tif( strstr( type, \"ctf\" ) ) {\n\t\t\t\tuiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_CTF);\n\t\t\t}\n\t\t\tif( strstr( type, \"oneflag\" ) ) {\n\t\t\t\tuiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_1FCTF);\n\t\t\t}\n\t\t\tif( strstr( type, \"overload\" ) ) {\n\t\t\t\tuiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_OBELISK);\n\t\t\t}\n\t\t\tif( strstr( type, \"harvester\" ) ) {\n\t\t\t\tuiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_HARVESTER);\n\t\t\t}\n\t\t} else {\n\t\t\tuiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_FFA);\n\t\t}\n\n\t\tuiInfo.mapCount++;\n\t\tif (uiInfo.mapCount >= MAX_MAPS) {\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n\n/*\n===============\nUI_LoadBotsFromFile\n===============\n*/\nstatic void UI_LoadBotsFromFile( char *filename ) {\n\tint\t\t\t\tlen;\n\tfileHandle_t\tf;\n\tchar\t\t\tbuf[MAX_BOTS_TEXT];\n\n\tlen = trap_FS_FOpenFile( filename, &f, FS_READ );\n\tif ( !f ) {\n\t\ttrap_Print( va( S_COLOR_RED \"file not found: %s\\n\", filename ) );\n\t\treturn;\n\t}\n\tif ( len >= MAX_BOTS_TEXT ) {\n\t\ttrap_Print( va( S_COLOR_RED \"file too large: %s is %i, max allowed is %i\", filename, len, MAX_BOTS_TEXT ) );\n\t\ttrap_FS_FCloseFile( f );\n\t\treturn;\n\t}\n\n\ttrap_FS_Read( buf, len, f );\n\tbuf[len] = 0;\n\ttrap_FS_FCloseFile( f );\n\n\tCOM_Compress(buf);\n\n\tui_numBots += UI_ParseInfos( buf, MAX_BOTS - ui_numBots, &ui_botInfos[ui_numBots] );\n}\n\n/*\n===============\nUI_LoadBots\n===============\n*/\nvoid UI_LoadBots( void ) {\n\tvmCvar_t\tbotsFile;\n\tint\t\t\tnumdirs;\n\tchar\t\tfilename[128];\n\tchar\t\tdirlist[1024];\n\tchar*\t\tdirptr;\n\tint\t\t\ti;\n\tint\t\t\tdirlen;\n\n\tui_numBots = 0;\n\n\ttrap_Cvar_Register( &botsFile, \"g_botsFile\", \"\", CVAR_INIT|CVAR_ROM );\n\tif( *botsFile.string ) {\n\t\tUI_LoadBotsFromFile(botsFile.string);\n\t}\n\telse {\n\t\tUI_LoadBotsFromFile(\"scripts/bots.txt\");\n\t}\n\n\t// get all bots from .bot files\n\tnumdirs = trap_FS_GetFileList(\"scripts\", \".bot\", dirlist, 1024 );\n\tdirptr  = dirlist;\n\tfor (i = 0; i < numdirs; i++, dirptr += dirlen+1) {\n\t\tdirlen = strlen(dirptr);\n\t\tstrcpy(filename, \"scripts/\");\n\t\tstrcat(filename, dirptr);\n\t\tUI_LoadBotsFromFile(filename);\n\t}\n\ttrap_Print( va( \"%i bots parsed\\n\", ui_numBots ) );\n}\n\n\n/*\n===============\nUI_GetBotInfoByNumber\n===============\n*/\nchar *UI_GetBotInfoByNumber( int num ) {\n\tif( num < 0 || num >= ui_numBots ) {\n\t\ttrap_Print( va( S_COLOR_RED \"Invalid bot number: %i\\n\", num ) );\n\t\treturn NULL;\n\t}\n\treturn ui_botInfos[num];\n}\n\n\n/*\n===============\nUI_GetBotInfoByName\n===============\n*/\nchar *UI_GetBotInfoByName( const char *name ) {\n\tint\t\tn;\n\tchar\t*value;\n\n\tfor ( n = 0; n < ui_numBots ; n++ ) {\n\t\tvalue = Info_ValueForKey( ui_botInfos[n], \"name\" );\n\t\tif ( !Q_stricmp( value, name ) ) {\n\t\t\treturn ui_botInfos[n];\n\t\t}\n\t}\n\n\treturn NULL;\n}\n\nint UI_GetNumBots() {\n\treturn ui_numBots;\n}\n\n\nchar *UI_GetBotNameByNumber( int num ) {\n\tchar *info = UI_GetBotInfoByNumber(num);\n\tif (info) {\n\t\treturn Info_ValueForKey( info, \"name\" );\n\t}\n\treturn \"Sarge\";\n}\n"
  },
  {
    "path": "code/ui/ui_local.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#ifndef __UI_LOCAL_H__\n#define __UI_LOCAL_H__\n\n#include \"../game/q_shared.h\"\n#include \"../cgame/tr_types.h\"\n#include \"ui_public.h\"\n#include \"keycodes.h\"\n#include \"../game/bg_public.h\"\n#include \"ui_shared.h\"\n\n// global display context\n\nextern vmCvar_t\tui_ffa_fraglimit;\nextern vmCvar_t\tui_ffa_timelimit;\n\nextern vmCvar_t\tui_tourney_fraglimit;\nextern vmCvar_t\tui_tourney_timelimit;\n\nextern vmCvar_t\tui_team_fraglimit;\nextern vmCvar_t\tui_team_timelimit;\nextern vmCvar_t\tui_team_friendly;\n\nextern vmCvar_t\tui_ctf_capturelimit;\nextern vmCvar_t\tui_ctf_timelimit;\nextern vmCvar_t\tui_ctf_friendly;\n\nextern vmCvar_t\tui_arenasFile;\nextern vmCvar_t\tui_botsFile;\nextern vmCvar_t\tui_spScores1;\nextern vmCvar_t\tui_spScores2;\nextern vmCvar_t\tui_spScores3;\nextern vmCvar_t\tui_spScores4;\nextern vmCvar_t\tui_spScores5;\nextern vmCvar_t\tui_spAwards;\nextern vmCvar_t\tui_spVideos;\nextern vmCvar_t\tui_spSkill;\n\nextern vmCvar_t\tui_spSelection;\n\nextern vmCvar_t\tui_browserMaster;\nextern vmCvar_t\tui_browserGameType;\nextern vmCvar_t\tui_browserSortKey;\nextern vmCvar_t\tui_browserShowFull;\nextern vmCvar_t\tui_browserShowEmpty;\n\nextern vmCvar_t\tui_brassTime;\nextern vmCvar_t\tui_drawCrosshair;\nextern vmCvar_t\tui_drawCrosshairNames;\nextern vmCvar_t\tui_marks;\n\nextern vmCvar_t\tui_server1;\nextern vmCvar_t\tui_server2;\nextern vmCvar_t\tui_server3;\nextern vmCvar_t\tui_server4;\nextern vmCvar_t\tui_server5;\nextern vmCvar_t\tui_server6;\nextern vmCvar_t\tui_server7;\nextern vmCvar_t\tui_server8;\nextern vmCvar_t\tui_server9;\nextern vmCvar_t\tui_server10;\nextern vmCvar_t\tui_server11;\nextern vmCvar_t\tui_server12;\nextern vmCvar_t\tui_server13;\nextern vmCvar_t\tui_server14;\nextern vmCvar_t\tui_server15;\nextern vmCvar_t\tui_server16;\n\nextern vmCvar_t\tui_cdkey;\nextern vmCvar_t\tui_cdkeychecked;\n\nextern vmCvar_t\tui_captureLimit;\nextern vmCvar_t\tui_fragLimit;\nextern vmCvar_t\tui_gameType;\nextern vmCvar_t\tui_netGameType;\nextern vmCvar_t\tui_actualNetGameType;\nextern vmCvar_t\tui_joinGameType;\nextern vmCvar_t\tui_netSource;\nextern vmCvar_t\tui_serverFilterType;\nextern vmCvar_t\tui_dedicated;\nextern vmCvar_t\tui_opponentName;\nextern vmCvar_t\tui_menuFiles;\nextern vmCvar_t\tui_currentTier;\nextern vmCvar_t\tui_currentMap;\nextern vmCvar_t\tui_currentNetMap;\nextern vmCvar_t\tui_mapIndex;\nextern vmCvar_t\tui_currentOpponent;\nextern vmCvar_t\tui_selectedPlayer;\nextern vmCvar_t\tui_selectedPlayerName;\nextern vmCvar_t\tui_lastServerRefresh_0;\nextern vmCvar_t\tui_lastServerRefresh_1;\nextern vmCvar_t\tui_lastServerRefresh_2;\nextern vmCvar_t\tui_lastServerRefresh_3;\nextern vmCvar_t\tui_singlePlayerActive;\nextern vmCvar_t\tui_scoreAccuracy;\nextern vmCvar_t\tui_scoreImpressives;\nextern vmCvar_t\tui_scoreExcellents;\nextern vmCvar_t\tui_scoreDefends;\nextern vmCvar_t\tui_scoreAssists;\nextern vmCvar_t\tui_scoreGauntlets;\nextern vmCvar_t\tui_scoreScore;\nextern vmCvar_t\tui_scorePerfect;\nextern vmCvar_t\tui_scoreTeam;\nextern vmCvar_t\tui_scoreBase;\nextern vmCvar_t\tui_scoreTimeBonus;\nextern vmCvar_t\tui_scoreSkillBonus;\nextern vmCvar_t\tui_scoreShutoutBonus;\nextern vmCvar_t\tui_scoreTime;\nextern vmCvar_t\tui_smallFont;\nextern vmCvar_t\tui_bigFont;\nextern vmCvar_t ui_serverStatusTimeOut;\n\n\n\n//\n// ui_qmenu.c\n//\n\n#define RCOLUMN_OFFSET\t\t\t( BIGCHAR_WIDTH )\n#define LCOLUMN_OFFSET\t\t\t(-BIGCHAR_WIDTH )\n\n#define SLIDER_RANGE\t\t\t10\n#define\tMAX_EDIT_LINE\t\t\t256\n\n#define MAX_MENUDEPTH\t\t\t8\n#define MAX_MENUITEMS\t\t\t96\n\n#define MTYPE_NULL\t\t\t\t0\n#define MTYPE_SLIDER\t\t\t1\t\n#define MTYPE_ACTION\t\t\t2\n#define MTYPE_SPINCONTROL\t\t3\n#define MTYPE_FIELD\t\t\t\t4\n#define MTYPE_RADIOBUTTON\t\t5\n#define MTYPE_BITMAP\t\t\t6\t\n#define MTYPE_TEXT\t\t\t\t7\n#define MTYPE_SCROLLLIST\t\t8\n#define MTYPE_PTEXT\t\t\t\t9\n#define MTYPE_BTEXT\t\t\t\t10\n\n#define QMF_BLINK\t\t\t\t0x00000001\n#define QMF_SMALLFONT\t\t\t0x00000002\n#define QMF_LEFT_JUSTIFY\t\t0x00000004\n#define QMF_CENTER_JUSTIFY\t\t0x00000008\n#define QMF_RIGHT_JUSTIFY\t\t0x00000010\n#define QMF_NUMBERSONLY\t\t\t0x00000020\t// edit field is only numbers\n#define QMF_HIGHLIGHT\t\t\t0x00000040\n#define QMF_HIGHLIGHT_IF_FOCUS\t0x00000080\t// steady focus\n#define QMF_PULSEIFFOCUS\t\t0x00000100\t// pulse if focus\n#define QMF_HASMOUSEFOCUS\t\t0x00000200\n#define QMF_NOONOFFTEXT\t\t\t0x00000400\n#define QMF_MOUSEONLY\t\t\t0x00000800\t// only mouse input allowed\n#define QMF_HIDDEN\t\t\t\t0x00001000\t// skips drawing\n#define QMF_GRAYED\t\t\t\t0x00002000\t// grays and disables\n#define QMF_INACTIVE\t\t\t0x00004000\t// disables any input\n#define QMF_NODEFAULTINIT\t\t0x00008000\t// skip default initialization\n#define QMF_OWNERDRAW\t\t\t0x00010000\n#define QMF_PULSE\t\t\t\t0x00020000\n#define QMF_LOWERCASE\t\t\t0x00040000\t// edit field is all lower case\n#define QMF_UPPERCASE\t\t\t0x00080000\t// edit field is all upper case\n#define QMF_SILENT\t\t\t\t0x00100000\n\n// callback notifications\n#define QM_GOTFOCUS\t\t\t\t1\n#define QM_LOSTFOCUS\t\t\t2\n#define QM_ACTIVATED\t\t\t3\n\ntypedef struct _tag_menuframework\n{\n\tint\tcursor;\n\tint cursor_prev;\n\n\tint\tnitems;\n\tvoid *items[MAX_MENUITEMS];\n\n\tvoid (*draw) (void);\n\tsfxHandle_t (*key) (int key);\n\n\tqboolean\twrapAround;\n\tqboolean\tfullscreen;\n\tqboolean\tshowlogo;\n} menuframework_s;\n\ntypedef struct\n{\n\tint type;\n\tconst char *name;\n\tint\tid;\n\tint x, y;\n\tint left;\n\tint\ttop;\n\tint\tright;\n\tint\tbottom;\n\tmenuframework_s *parent;\n\tint menuPosition;\n\tunsigned flags;\n\n\tvoid (*callback)( void *self, int event );\n\tvoid (*statusbar)( void *self );\n\tvoid (*ownerdraw)( void *self );\n} menucommon_s;\n\ntypedef struct {\n\tint\t\tcursor;\n\tint\t\tscroll;\n\tint\t\twidthInChars;\n\tchar\tbuffer[MAX_EDIT_LINE];\n\tint\t\tmaxchars;\n} mfield_t;\n\ntypedef struct\n{\n\tmenucommon_s\tgeneric;\n\tmfield_t\t\tfield;\n} menufield_s;\n\ntypedef struct \n{\n\tmenucommon_s generic;\n\n\tfloat minvalue;\n\tfloat maxvalue;\n\tfloat curvalue;\n\n\tfloat range;\n} menuslider_s;\n\ntypedef struct\n{\n\tmenucommon_s generic;\n\n\tint\toldvalue;\n\tint curvalue;\n\tint\tnumitems;\n\tint\ttop;\n\t\t\n\tconst char **itemnames;\n\n\tint width;\n\tint height;\n\tint\tcolumns;\n\tint\tseperation;\n} menulist_s;\n\ntypedef struct\n{\n\tmenucommon_s generic;\n} menuaction_s;\n\ntypedef struct\n{\n\tmenucommon_s generic;\n\tint curvalue;\n} menuradiobutton_s;\n\ntypedef struct\n{\n\tmenucommon_s\tgeneric;\n\tchar*\t\t\tfocuspic;\t\n\tchar*\t\t\terrorpic;\n\tqhandle_t\t\tshader;\n\tqhandle_t\t\tfocusshader;\n\tint\t\t\t\twidth;\n\tint\t\t\t\theight;\n\tfloat*\t\t\tfocuscolor;\n} menubitmap_s;\n\ntypedef struct\n{\n\tmenucommon_s\tgeneric;\n\tchar*\t\t\tstring;\n\tint\t\t\t\tstyle;\n\tfloat*\t\t\tcolor;\n} menutext_s;\n\nextern void\t\t\tMenu_Cache( void );\nextern void\t\t\tMenu_Focus( menucommon_s *m );\nextern void\t\t\tMenu_AddItem( menuframework_s *menu, void *item );\nextern void\t\t\tMenu_AdjustCursor( menuframework_s *menu, int dir );\nextern void\t\t\tMenu_Draw( menuframework_s *menu );\nextern void\t\t\t*Menu_ItemAtCursor( menuframework_s *m );\nextern sfxHandle_t\tMenu_ActivateItem( menuframework_s *s, menucommon_s* item );\nextern void\t\t\tMenu_SetCursor( menuframework_s *s, int cursor );\nextern void\t\t\tMenu_SetCursorToItem( menuframework_s *m, void* ptr );\nextern sfxHandle_t\tMenu_DefaultKey( menuframework_s *s, int key );\nextern void\t\t\tBitmap_Init( menubitmap_s *b );\nextern void\t\t\tBitmap_Draw( menubitmap_s *b );\nextern void\t\t\tScrollList_Draw( menulist_s *l );\nextern sfxHandle_t\tScrollList_Key( menulist_s *l, int key );\nextern sfxHandle_t\tmenu_in_sound;\nextern sfxHandle_t\tmenu_move_sound;\nextern sfxHandle_t\tmenu_out_sound;\nextern sfxHandle_t\tmenu_buzz_sound;\nextern sfxHandle_t\tmenu_null_sound;\nextern sfxHandle_t\tweaponChangeSound;\nextern vec4_t\t\tmenu_text_color;\nextern vec4_t\t\tmenu_grayed_color;\nextern vec4_t\t\tmenu_dark_color;\nextern vec4_t\t\tmenu_highlight_color;\nextern vec4_t\t\tmenu_red_color;\nextern vec4_t\t\tmenu_black_color;\nextern vec4_t\t\tmenu_dim_color;\nextern vec4_t\t\tcolor_black;\nextern vec4_t\t\tcolor_white;\nextern vec4_t\t\tcolor_yellow;\nextern vec4_t\t\tcolor_blue;\nextern vec4_t\t\tcolor_orange;\nextern vec4_t\t\tcolor_red;\nextern vec4_t\t\tcolor_dim;\nextern vec4_t\t\tname_color;\nextern vec4_t\t\tlist_color;\nextern vec4_t\t\tlistbar_color;\nextern vec4_t\t\ttext_color_disabled; \nextern vec4_t\t\ttext_color_normal;\nextern vec4_t\t\ttext_color_highlight;\n\nextern char\t*ui_medalNames[];\nextern char\t*ui_medalPicNames[];\nextern char\t*ui_medalSounds[];\n\n//\n// ui_mfield.c\n//\nextern void\t\t\tMField_Clear( mfield_t *edit );\nextern void\t\t\tMField_KeyDownEvent( mfield_t *edit, int key );\nextern void\t\t\tMField_CharEvent( mfield_t *edit, int ch );\nextern void\t\t\tMField_Draw( mfield_t *edit, int x, int y, int style, vec4_t color );\nextern void\t\t\tMenuField_Init( menufield_s* m );\nextern void\t\t\tMenuField_Draw( menufield_s *f );\nextern sfxHandle_t\tMenuField_Key( menufield_s* m, int* key );\n\n//\n// ui_main.c\n//\nvoid UI_Report();\nvoid UI_Load();\nvoid UI_LoadMenus(const char *menuFile, qboolean reset);\nvoid _UI_SetActiveMenu( uiMenuCommand_t menu );\nint UI_AdjustTimeByGame(int time);\nvoid UI_ShowPostGame(qboolean newHigh);\nvoid UI_ClearScores();\nvoid UI_LoadArenas(void);\n\n//\n// ui_menu.c\n//\nextern void MainMenu_Cache( void );\nextern void UI_MainMenu(void);\nextern void UI_RegisterCvars( void );\nextern void UI_UpdateCvars( void );\n\n//\n// ui_credits.c\n//\nextern void UI_CreditMenu( void );\n\n//\n// ui_ingame.c\n//\nextern void InGame_Cache( void );\nextern void UI_InGameMenu(void);\n\n//\n// ui_confirm.c\n//\nextern void ConfirmMenu_Cache( void );\nextern void UI_ConfirmMenu( const char *question, void (*draw)( void ), void (*action)( qboolean result ) );\n\n//\n// ui_setup.c\n//\nextern void UI_SetupMenu_Cache( void );\nextern void UI_SetupMenu(void);\n\n//\n// ui_team.c\n//\nextern void UI_TeamMainMenu( void );\nextern void TeamMain_Cache( void );\n\n//\n// ui_connect.c\n//\nextern void UI_DrawConnectScreen( qboolean overlay );\n\n//\n// ui_controls2.c\n//\nextern void UI_ControlsMenu( void );\nextern void Controls_Cache( void );\n\n//\n// ui_demo2.c\n//\nextern void UI_DemosMenu( void );\nextern void Demos_Cache( void );\n\n//\n// ui_cinematics.c\n//\nextern void UI_CinematicsMenu( void );\nextern void UI_CinematicsMenu_f( void );\nextern void UI_CinematicsMenu_Cache( void );\n\n//\n// ui_mods.c\n//\nextern void UI_ModsMenu( void );\nextern void UI_ModsMenu_Cache( void );\n\n//\n// ui_cdkey.c\n//\nextern void UI_CDKeyMenu( void );\nextern void UI_CDKeyMenu_Cache( void );\nextern void UI_CDKeyMenu_f( void );\n\n//\n// ui_playermodel.c\n//\nextern void UI_PlayerModelMenu( void );\nextern void PlayerModel_Cache( void );\n\n//\n// ui_playersettings.c\n//\nextern void UI_PlayerSettingsMenu( void );\nextern void PlayerSettings_Cache( void );\n\n//\n// ui_preferences.c\n//\nextern void UI_PreferencesMenu( void );\nextern void Preferences_Cache( void );\n\n//\n// ui_specifyleague.c\n//\nextern void UI_SpecifyLeagueMenu( void );\nextern void SpecifyLeague_Cache( void );\n\n//\n// ui_specifyserver.c\n//\nextern void UI_SpecifyServerMenu( void );\nextern void SpecifyServer_Cache( void );\n\n//\n// ui_servers2.c\n//\n#define MAX_FAVORITESERVERS 16\n\nextern void UI_ArenaServersMenu( void );\nextern void ArenaServers_Cache( void );\n\n//\n// ui_startserver.c\n//\nextern void UI_StartServerMenu( qboolean multiplayer );\nextern void StartServer_Cache( void );\nextern void ServerOptions_Cache( void );\nextern void UI_BotSelectMenu( char *bot );\nextern void UI_BotSelectMenu_Cache( void );\n\n//\n// ui_serverinfo.c\n//\nextern void UI_ServerInfoMenu( void );\nextern void ServerInfo_Cache( void );\n\n//\n// ui_video.c\n//\nextern void UI_GraphicsOptionsMenu( void );\nextern void GraphicsOptions_Cache( void );\nextern void DriverInfo_Cache( void );\n\n//\n// ui_players.c\n//\n\n//FIXME ripped from cg_local.h\ntypedef struct {\n\tint\t\t\toldFrame;\n\tint\t\t\toldFrameTime;\t\t// time when ->oldFrame was exactly on\n\n\tint\t\t\tframe;\n\tint\t\t\tframeTime;\t\t\t// time when ->frame will be exactly on\n\n\tfloat\t\tbacklerp;\n\n\tfloat\t\tyawAngle;\n\tqboolean\tyawing;\n\tfloat\t\tpitchAngle;\n\tqboolean\tpitching;\n\n\tint\t\t\tanimationNumber;\t// may include ANIM_TOGGLEBIT\n\tanimation_t\t*animation;\n\tint\t\t\tanimationTime;\t\t// time when the first frame of the animation will be exact\n} lerpFrame_t;\n\ntypedef struct {\n\t// model info\n\tqhandle_t\t\tlegsModel;\n\tqhandle_t\t\tlegsSkin;\n\tlerpFrame_t\t\tlegs;\n\n\tqhandle_t\t\ttorsoModel;\n\tqhandle_t\t\ttorsoSkin;\n\tlerpFrame_t\t\ttorso;\n\n\tqhandle_t\t\theadModel;\n\tqhandle_t\t\theadSkin;\n\n\tanimation_t\t\tanimations[MAX_TOTALANIMATIONS];\n\n\tqhandle_t\t\tweaponModel;\n\tqhandle_t\t\tbarrelModel;\n\tqhandle_t\t\tflashModel;\n\tvec3_t\t\t\tflashDlightColor;\n\tint\t\t\t\tmuzzleFlashTime;\n\n\t// currently in use drawing parms\n\tvec3_t\t\t\tviewAngles;\n\tvec3_t\t\t\tmoveAngles;\n\tweapon_t\t\tcurrentWeapon;\n\tint\t\t\t\tlegsAnim;\n\tint\t\t\t\ttorsoAnim;\n\n\t// animation vars\n\tweapon_t\t\tweapon;\n\tweapon_t\t\tlastWeapon;\n\tweapon_t\t\tpendingWeapon;\n\tint\t\t\t\tweaponTimer;\n\tint\t\t\t\tpendingLegsAnim;\n\tint\t\t\t\ttorsoAnimationTimer;\n\n\tint\t\t\t\tpendingTorsoAnim;\n\tint\t\t\t\tlegsAnimationTimer;\n\n\tqboolean\t\tchat;\n\tqboolean\t\tnewModel;\n\n\tqboolean\t\tbarrelSpinning;\n\tfloat\t\t\tbarrelAngle;\n\tint\t\t\t\tbarrelTime;\n\n\tint\t\t\t\trealWeapon;\n} playerInfo_t;\n\nvoid UI_DrawPlayer( float x, float y, float w, float h, playerInfo_t *pi, int time );\nvoid UI_PlayerInfo_SetModel( playerInfo_t *pi, const char *model, const char *headmodel, char *teamName );\nvoid UI_PlayerInfo_SetInfo( playerInfo_t *pi, int legsAnim, int torsoAnim, vec3_t viewAngles, vec3_t moveAngles, weapon_t weaponNum, qboolean chat );\nqboolean UI_RegisterClientModelname( playerInfo_t *pi, const char *modelSkinName , const char *headName, const char *teamName);\n\n//\n// ui_atoms.c\n//\n// this is only used in the old ui, the new ui has it's own version\ntypedef struct {\n\tint\t\t\t\t\tframetime;\n\tint\t\t\t\t\trealtime;\n\tint\t\t\t\t\tcursorx;\n\tint\t\t\t\t\tcursory;\n\tglconfig_t \tglconfig;\n\tqboolean\t\tdebug;\n\tqhandle_t\t\twhiteShader;\n\tqhandle_t\t\tmenuBackShader;\n\tqhandle_t\t\tmenuBackShader2;\n\tqhandle_t\t\tmenuBackNoLogoShader;\n\tqhandle_t\t\tcharset;\n\tqhandle_t\t\tcharsetProp;\n\tqhandle_t\t\tcharsetPropGlow;\n\tqhandle_t\t\tcharsetPropB;\n\tqhandle_t\t\tcursor;\n\tqhandle_t\t\trb_on;\n\tqhandle_t\t\trb_off;\n\tfloat\t\t\t\tscale;\n\tfloat\t\t\t\tbias;\n\tqboolean\t\tdemoversion;\n\tqboolean\t\tfirstdraw;\n} uiStatic_t;\n\n\n// new ui stuff\n#define UI_NUMFX 7\n#define MAX_HEADS 64\n#define MAX_ALIASES 64\n#define MAX_HEADNAME  32\n#define MAX_TEAMS 64\n#define MAX_GAMETYPES 16\n#define MAX_MAPS 128\n#define MAX_SPMAPS 16\n#define PLAYERS_PER_TEAM 5\n#define MAX_PINGREQUESTS\t\t32\n#define MAX_ADDRESSLENGTH\t\t64\n#define MAX_HOSTNAMELENGTH\t\t22\n#define MAX_MAPNAMELENGTH\t\t16\n#define MAX_STATUSLENGTH\t\t64\n#define MAX_LISTBOXWIDTH\t\t59\n#define UI_FONT_THRESHOLD\t\t0.1\n#define MAX_DISPLAY_SERVERS\t\t2048\n#define MAX_SERVERSTATUS_LINES\t128\n#define MAX_SERVERSTATUS_TEXT\t1024\n#define MAX_FOUNDPLAYER_SERVERS\t16\n#define TEAM_MEMBERS 5\n#define GAMES_ALL\t\t\t0\n#define GAMES_FFA\t\t\t1\n#define GAMES_TEAMPLAY\t\t2\n#define GAMES_TOURNEY\t\t3\n#define GAMES_CTF\t\t\t4\n#define MAPS_PER_TIER 3\n#define MAX_TIERS 16\n#define MAX_MODS 64\n#define MAX_DEMOS 256\n#define MAX_MOVIES 256\n#define MAX_PLAYERMODELS 256\n\n\ntypedef struct {\n  const char *name;\n\tconst char *imageName;\n  qhandle_t headImage;\n\tconst char *base;\n\tqboolean active;\n\tint reference;\n} characterInfo;\n\ntypedef struct {\n\tconst char *name;\n\tconst char *ai;\n\tconst char *action;\n} aliasInfo;\n\ntypedef struct {\n  const char *teamName;\n\tconst char *imageName;\n\tconst char *teamMembers[TEAM_MEMBERS];\n  qhandle_t teamIcon;\n  qhandle_t teamIcon_Metal;\n  qhandle_t teamIcon_Name;\n\tint cinematic;\n} teamInfo;\n\ntypedef struct {\n  const char *gameType;\n  int gtEnum;\n} gameTypeInfo;\n\ntypedef struct {\n  const char *mapName;\n  const char *mapLoadName;\n\tconst char *imageName;\n\tconst char *opponentName;\n\tint teamMembers;\n  int typeBits;\n\tint cinematic;\n\tint timeToBeat[MAX_GAMETYPES];\n\tqhandle_t levelShot;\n\tqboolean active;\n} mapInfo;\n\ntypedef struct {\n\tconst char *tierName;\n\tconst char *maps[MAPS_PER_TIER];\n\tint gameTypes[MAPS_PER_TIER];\n\tqhandle_t mapHandles[MAPS_PER_TIER];\n} tierInfo;\n\ntypedef struct serverFilter_s {\n\tconst char *description;\n\tconst char *basedir;\n} serverFilter_t;\n\ntypedef struct {\n\tchar\tadrstr[MAX_ADDRESSLENGTH];\n\tint\t\tstart;\n} pinglist_t;\n\n\ntypedef struct serverStatus_s {\n\tpinglist_t pingList[MAX_PINGREQUESTS];\n\tint\t\tnumqueriedservers;\n\tint\t\tcurrentping;\n\tint\t\tnextpingtime;\n\tint\t\tmaxservers;\n\tint\t\trefreshtime;\n\tint\t\tnumServers;\n\tint\t\tsortKey;\n\tint\t\tsortDir;\n\tint\t\tlastCount;\n\tqboolean refreshActive;\n\tint\t\tcurrentServer;\n\tint\t\tdisplayServers[MAX_DISPLAY_SERVERS];\n\tint\t\tnumDisplayServers;\n\tint\t\tnumPlayersOnServers;\n\tint\t\tnextDisplayRefresh;\n\tint\t\tnextSortTime;\n\tqhandle_t currentServerPreview;\n\tint\t\tcurrentServerCinematic;\n\tint\t\tmotdLen;\n\tint\t\tmotdWidth;\n\tint\t\tmotdPaintX;\n\tint\t\tmotdPaintX2;\n\tint\t\tmotdOffset;\n\tint\t\tmotdTime;\n\tchar\tmotd[MAX_STRING_CHARS];\n} serverStatus_t;\n\n\ntypedef struct {\n\tchar\t\tadrstr[MAX_ADDRESSLENGTH];\n\tchar\t\tname[MAX_ADDRESSLENGTH];\n\tint\t\t\tstartTime;\n\tint\t\t\tserverNum;\n\tqboolean\tvalid;\n} pendingServer_t;\n\ntypedef struct {\n\tint num;\n\tpendingServer_t server[MAX_SERVERSTATUSREQUESTS];\n} pendingServerStatus_t;\n\ntypedef struct {\n\tchar address[MAX_ADDRESSLENGTH];\n\tchar *lines[MAX_SERVERSTATUS_LINES][4];\n\tchar text[MAX_SERVERSTATUS_TEXT];\n\tchar pings[MAX_CLIENTS * 3];\n\tint numLines;\n} serverStatusInfo_t;\n\ntypedef struct {\n\tconst char *modName;\n\tconst char *modDescr;\n} modInfo_t;\n\n\ntypedef struct {\n\tdisplayContextDef_t uiDC;\n\tint newHighScoreTime;\n\tint newBestTime;\n\tint showPostGameTime;\n\tqboolean newHighScore;\n\tqboolean demoAvailable;\n\tqboolean soundHighScore;\n\t\n\tint characterCount;\n\tint botIndex;\n\tcharacterInfo characterList[MAX_HEADS];\n\n\tint aliasCount;\n\taliasInfo aliasList[MAX_ALIASES];\n\n\tint teamCount;\n\tteamInfo teamList[MAX_TEAMS];\n\n\tint numGameTypes;\n\tgameTypeInfo gameTypes[MAX_GAMETYPES];\n\n\tint numJoinGameTypes;\n\tgameTypeInfo joinGameTypes[MAX_GAMETYPES];\n\n\tint redBlue;\n\tint playerCount;\n\tint myTeamCount;\n\tint teamIndex;\n\tint playerRefresh;\n\tint playerIndex;\n\tint playerNumber; \n\tqboolean teamLeader;\n\tchar playerNames[MAX_CLIENTS][MAX_NAME_LENGTH];\n\tchar teamNames[MAX_CLIENTS][MAX_NAME_LENGTH];\n\tint teamClientNums[MAX_CLIENTS];\n\n\tint mapCount;\n\tmapInfo mapList[MAX_MAPS];\n\n\n\tint tierCount;\n\ttierInfo tierList[MAX_TIERS];\n\n\tint skillIndex;\n\n\tmodInfo_t modList[MAX_MODS];\n\tint modCount;\n\tint modIndex;\n\n\tconst char *demoList[MAX_DEMOS];\n\tint demoCount;\n\tint demoIndex;\n\n\tconst char *movieList[MAX_MOVIES];\n\tint movieCount;\n\tint movieIndex;\n\tint previewMovie;\n\n\tserverStatus_t serverStatus;\n\n\t// for the showing the status of a server\n\tchar serverStatusAddress[MAX_ADDRESSLENGTH];\n\tserverStatusInfo_t serverStatusInfo;\n\tint nextServerStatusRefresh;\n\n\t// to retrieve the status of server to find a player\n\tpendingServerStatus_t pendingServerStatus;\n\tchar findPlayerName[MAX_STRING_CHARS];\n\tchar foundPlayerServerAddresses[MAX_FOUNDPLAYER_SERVERS][MAX_ADDRESSLENGTH];\n\tchar foundPlayerServerNames[MAX_FOUNDPLAYER_SERVERS][MAX_ADDRESSLENGTH];\n\tint currentFoundPlayerServer;\n\tint numFoundPlayerServers;\n\tint nextFindPlayerRefresh;\n\n\tint currentCrosshair;\n\tint startPostGameTime;\n\tsfxHandle_t newHighScoreSound;\n\n\tint\t\t\t\tq3HeadCount;\n\tchar\t\t\tq3HeadNames[MAX_PLAYERMODELS][64];\n\tqhandle_t\tq3HeadIcons[MAX_PLAYERMODELS];\n\tint\t\t\t\tq3SelectedHead;\n\n\tint effectsColor;\n\n\tqboolean inGameLoad;\n\n}\tuiInfo_t;\n\nextern uiInfo_t uiInfo;\n\n\nextern void\t\t\tUI_Init( void );\nextern void\t\t\tUI_Shutdown( void );\nextern void\t\t\tUI_KeyEvent( int key );\nextern void\t\t\tUI_MouseEvent( int dx, int dy );\nextern void\t\t\tUI_Refresh( int realtime );\nextern qboolean\t\tUI_ConsoleCommand( int realTime );\nextern float\t\tUI_ClampCvar( float min, float max, float value );\nextern void\t\t\tUI_DrawNamedPic( float x, float y, float width, float height, const char *picname );\nextern void\t\t\tUI_DrawHandlePic( float x, float y, float w, float h, qhandle_t hShader ); \nextern void\t\t\tUI_FillRect( float x, float y, float width, float height, const float *color );\nextern void\t\t\tUI_DrawRect( float x, float y, float width, float height, const float *color );\nextern void     UI_DrawTopBottom(float x, float y, float w, float h);\nextern void     UI_DrawSides(float x, float y, float w, float h);\nextern void\t\t\tUI_UpdateScreen( void );\nextern void\t\t\tUI_SetColor( const float *rgba );\nextern void\t\t\tUI_LerpColor(vec4_t a, vec4_t b, vec4_t c, float t);\nextern void\t\t\tUI_DrawBannerString( int x, int y, const char* str, int style, vec4_t color );\nextern float\t\tUI_ProportionalSizeScale( int style );\nextern void\t\t\tUI_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color );\nextern int\t\t\tUI_ProportionalStringWidth( const char* str );\nextern void\t\t\tUI_DrawString( int x, int y, const char* str, int style, vec4_t color );\nextern void\t\t\tUI_DrawChar( int x, int y, int ch, int style, vec4_t color );\nextern qboolean \tUI_CursorInRect (int x, int y, int width, int height);\nextern void\t\t\tUI_AdjustFrom640( float *x, float *y, float *w, float *h );\nextern void\t\t\tUI_DrawTextBox (int x, int y, int width, int lines);\nextern qboolean\t\tUI_IsFullscreen( void );\nextern void\t\t\tUI_SetActiveMenu( uiMenuCommand_t menu );\nextern void\t\t\tUI_PushMenu ( menuframework_s *menu );\nextern void\t\t\tUI_PopMenu (void);\nextern void\t\t\tUI_ForceMenuOff (void);\nextern char\t\t\t*UI_Argv( int arg );\nextern char\t\t\t*UI_Cvar_VariableString( const char *var_name );\nextern void\t\t\tUI_Refresh( int time );\nextern void\t\t\tUI_KeyEvent( int key );\nextern void\t\t\tUI_StartDemoLoop( void );\nextern qboolean\t\tm_entersound;\nvoid UI_LoadBestScores(const char *map, int game);\nextern uiStatic_t\tuis;\n\n//\n// ui_spLevel.c\n//\nvoid UI_SPLevelMenu_Cache( void );\nvoid UI_SPLevelMenu( void );\nvoid UI_SPLevelMenu_f( void );\nvoid UI_SPLevelMenu_ReInit( void );\n\n//\n// ui_spArena.c\n//\nvoid UI_SPArena_Start( const char *arenaInfo );\n\n//\n// ui_spPostgame.c\n//\nvoid UI_SPPostgameMenu_Cache( void );\nvoid UI_SPPostgameMenu_f( void );\n\n//\n// ui_spSkill.c\n//\nvoid UI_SPSkillMenu( const char *arenaInfo );\nvoid UI_SPSkillMenu_Cache( void );\n\n//\n// ui_syscalls.c\n//\nvoid\t\t\ttrap_Print( const char *string );\nvoid\t\t\ttrap_Error( const char *string );\nint\t\t\t\ttrap_Milliseconds( void );\nvoid\t\t\ttrap_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags );\nvoid\t\t\ttrap_Cvar_Update( vmCvar_t *vmCvar );\nvoid\t\t\ttrap_Cvar_Set( const char *var_name, const char *value );\nfloat\t\t\ttrap_Cvar_VariableValue( const char *var_name );\nvoid\t\t\ttrap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize );\nvoid\t\t\ttrap_Cvar_SetValue( const char *var_name, float value );\nvoid\t\t\ttrap_Cvar_Reset( const char *name );\nvoid\t\t\ttrap_Cvar_Create( const char *var_name, const char *var_value, int flags );\nvoid\t\t\ttrap_Cvar_InfoStringBuffer( int bit, char *buffer, int bufsize );\nint\t\t\t\ttrap_Argc( void );\nvoid\t\t\ttrap_Argv( int n, char *buffer, int bufferLength );\nvoid\t\t\ttrap_Cmd_ExecuteText( int exec_when, const char *text );\t// don't use EXEC_NOW!\nint\t\t\t\ttrap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode );\nvoid\t\t\ttrap_FS_Read( void *buffer, int len, fileHandle_t f );\nvoid\t\t\ttrap_FS_Write( const void *buffer, int len, fileHandle_t f );\nvoid\t\t\ttrap_FS_FCloseFile( fileHandle_t f );\nint\t\t\t\ttrap_FS_GetFileList(  const char *path, const char *extension, char *listbuf, int bufsize );\nint\t\t\t\ttrap_FS_Seek( fileHandle_t f, long offset, int origin ); // fsOrigin_t\nqhandle_t\t\ttrap_R_RegisterModel( const char *name );\nqhandle_t\t\ttrap_R_RegisterSkin( const char *name );\nqhandle_t\t\ttrap_R_RegisterShaderNoMip( const char *name );\nvoid\t\t\ttrap_R_ClearScene( void );\nvoid\t\t\ttrap_R_AddRefEntityToScene( const refEntity_t *re );\nvoid\t\t\ttrap_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts );\nvoid\t\t\ttrap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b );\nvoid\t\t\ttrap_R_RenderScene( const refdef_t *fd );\nvoid\t\t\ttrap_R_SetColor( const float *rgba );\nvoid\t\t\ttrap_R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader );\nvoid\t\t\ttrap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs );\nvoid\t\t\ttrap_UpdateScreen( void );\nint\t\t\t\ttrap_CM_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame, float frac, const char *tagName );\nvoid\t\t\ttrap_S_StartLocalSound( sfxHandle_t sfx, int channelNum );\nsfxHandle_t\t\ttrap_S_RegisterSound( const char *sample, qboolean compressed );\nvoid\t\t\ttrap_Key_KeynumToStringBuf( int keynum, char *buf, int buflen );\nvoid\t\t\ttrap_Key_GetBindingBuf( int keynum, char *buf, int buflen );\nvoid\t\t\ttrap_Key_SetBinding( int keynum, const char *binding );\nqboolean\t\ttrap_Key_IsDown( int keynum );\nqboolean\t\ttrap_Key_GetOverstrikeMode( void );\nvoid\t\t\ttrap_Key_SetOverstrikeMode( qboolean state );\nvoid\t\t\ttrap_Key_ClearStates( void );\nint\t\t\t\ttrap_Key_GetCatcher( void );\nvoid\t\t\ttrap_Key_SetCatcher( int catcher );\nvoid\t\t\ttrap_GetClipboardData( char *buf, int bufsize );\nvoid\t\t\ttrap_GetClientState( uiClientState_t *state );\nvoid\t\t\ttrap_GetGlconfig( glconfig_t *glconfig );\nint\t\t\t\ttrap_GetConfigString( int index, char* buff, int buffsize );\nint\t\t\t\ttrap_LAN_GetServerCount( int source );\nvoid\t\t\ttrap_LAN_GetServerAddressString( int source, int n, char *buf, int buflen );\nvoid\t\t\ttrap_LAN_GetServerInfo( int source, int n, char *buf, int buflen );\nint\t\t\t\ttrap_LAN_GetServerPing( int source, int n );\nint\t\t\t\ttrap_LAN_GetPingQueueCount( void );\nvoid\t\t\ttrap_LAN_ClearPing( int n );\nvoid\t\t\ttrap_LAN_GetPing( int n, char *buf, int buflen, int *pingtime );\nvoid\t\t\ttrap_LAN_GetPingInfo( int n, char *buf, int buflen );\nvoid\t\t\ttrap_LAN_LoadCachedServers();\nvoid\t\t\ttrap_LAN_SaveCachedServers();\nvoid\t\t\ttrap_LAN_MarkServerVisible(int source, int n, qboolean visible);\nint\t\t\t\ttrap_LAN_ServerIsVisible( int source, int n);\nqboolean\t\ttrap_LAN_UpdateVisiblePings( int source );\nint\t\t\t\ttrap_LAN_AddServer(int source, const char *name, const char *addr);\nvoid\t\t\ttrap_LAN_RemoveServer(int source, const char *addr);\nvoid\t\t\ttrap_LAN_ResetPings(int n);\nint\t\t\t\ttrap_LAN_ServerStatus( const char *serverAddress, char *serverStatus, int maxLen );\nint\t\t\t\ttrap_LAN_CompareServers( int source, int sortKey, int sortDir, int s1, int s2 );\nint\t\t\t\ttrap_MemoryRemaining( void );\nvoid\t\t\ttrap_GetCDKey( char *buf, int buflen );\nvoid\t\t\ttrap_SetCDKey( char *buf );\nvoid\t\t\ttrap_R_RegisterFont(const char *pFontname, int pointSize, fontInfo_t *font);\nvoid\t\t\ttrap_S_StopBackgroundTrack( void );\nvoid\t\t\ttrap_S_StartBackgroundTrack( const char *intro, const char *loop);\nint\t\t\t\ttrap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits);\ne_status\t\ttrap_CIN_StopCinematic(int handle);\ne_status\t\ttrap_CIN_RunCinematic (int handle);\nvoid\t\t\ttrap_CIN_DrawCinematic (int handle);\nvoid\t\t\ttrap_CIN_SetExtents (int handle, int x, int y, int w, int h);\nint\t\t\t\ttrap_RealTime(qtime_t *qtime);\nvoid\t\t\ttrap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset );\nqboolean\t\ttrap_VerifyCDKey( const char *key, const char *chksum);\n\nvoid\t\t\ttrap_SetPbClStatus( int status );\n\n//\n// ui_addbots.c\n//\nvoid UI_AddBots_Cache( void );\nvoid UI_AddBotsMenu( void );\n\n//\n// ui_removebots.c\n//\nvoid UI_RemoveBots_Cache( void );\nvoid UI_RemoveBotsMenu( void );\n\n//\n// ui_teamorders.c\n//\nextern void UI_TeamOrdersMenu( void );\nextern void UI_TeamOrdersMenu_f( void );\nextern void UI_TeamOrdersMenu_Cache( void );\n\n//\n// ui_loadconfig.c\n//\nvoid UI_LoadConfig_Cache( void );\nvoid UI_LoadConfigMenu( void );\n\n//\n// ui_saveconfig.c\n//\nvoid UI_SaveConfigMenu_Cache( void );\nvoid UI_SaveConfigMenu( void );\n\n//\n// ui_display.c\n//\nvoid UI_DisplayOptionsMenu_Cache( void );\nvoid UI_DisplayOptionsMenu( void );\n\n//\n// ui_sound.c\n//\nvoid UI_SoundOptionsMenu_Cache( void );\nvoid UI_SoundOptionsMenu( void );\n\n//\n// ui_network.c\n//\nvoid UI_NetworkOptionsMenu_Cache( void );\nvoid UI_NetworkOptionsMenu( void );\n\n//\n// ui_gameinfo.c\n//\ntypedef enum {\n\tAWARD_ACCURACY,\n\tAWARD_IMPRESSIVE,\n\tAWARD_EXCELLENT,\n\tAWARD_GAUNTLET,\n\tAWARD_FRAGS,\n\tAWARD_PERFECT\n} awardType_t;\n\nconst char *UI_GetArenaInfoByNumber( int num );\nconst char *UI_GetArenaInfoByMap( const char *map );\nconst char *UI_GetSpecialArenaInfo( const char *tag );\nint UI_GetNumArenas( void );\nint UI_GetNumSPArenas( void );\nint UI_GetNumSPTiers( void );\n\nchar *UI_GetBotInfoByNumber( int num );\nchar *UI_GetBotInfoByName( const char *name );\nint UI_GetNumBots( void );\nvoid UI_LoadBots( void );\nchar *UI_GetBotNameByNumber( int num );\n\nvoid UI_GetBestScore( int level, int *score, int *skill );\nvoid UI_SetBestScore( int level, int score );\nint UI_TierCompleted( int levelWon );\nqboolean UI_ShowTierVideo( int tier );\nqboolean UI_CanShowTierVideo( int tier );\nint  UI_GetCurrentGame( void );\nvoid UI_NewGame( void );\nvoid UI_LogAwardData( int award, int data );\nint UI_GetAwardLevel( int award );\n\nvoid UI_SPUnlock_f( void );\nvoid UI_SPUnlockMedals_f( void );\n\nvoid UI_InitGameinfo( void );\n\n//\n// ui_login.c\n//\nvoid Login_Cache( void );\nvoid UI_LoginMenu( void );\n\n//\n// ui_signup.c\n//\nvoid Signup_Cache( void );\nvoid UI_SignupMenu( void );\n\n//\n// ui_rankstatus.c\n//\nvoid RankStatus_Cache( void );\nvoid UI_RankStatusMenu( void );\n\n\n// new ui \n\n#define ASSET_BACKGROUND \"uiBackground\"\n\n// for tracking sp game info in Team Arena\ntypedef struct postGameInfo_s {\n\tint score;\n\tint redScore;\n\tint blueScore;\n\tint perfects;\n\tint accuracy;\n\tint impressives;\n\tint excellents;\n\tint defends;\n\tint assists;\n\tint gauntlets;\n\tint\tcaptures;\n\tint time;\n\tint timeBonus;\n\tint shutoutBonus;\n\tint skillBonus;\n\tint baseScore;\n} postGameInfo_t;\n\n\n\n#endif\n"
  },
  {
    "path": "code/ui/ui_main.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n/*\n=======================================================================\n\nUSER INTERFACE MAIN\n\n=======================================================================\n*/\n\n// use this to get a demo build without an explicit demo build, i.e. to get the demo ui files to build\n//#define PRE_RELEASE_TADEMO\n\n#include \"ui_local.h\"\n\nuiInfo_t uiInfo;\n\nstatic const char *MonthAbbrev[] = {\n\t\"Jan\",\"Feb\",\"Mar\",\n\t\"Apr\",\"May\",\"Jun\",\n\t\"Jul\",\"Aug\",\"Sep\",\n\t\"Oct\",\"Nov\",\"Dec\"\n};\n\n\nstatic const char *skillLevels[] = {\n  \"I Can Win\",\n  \"Bring It On\",\n  \"Hurt Me Plenty\",\n  \"Hardcore\",\n  \"Nightmare\"\n};\n\nstatic const int numSkillLevels = sizeof(skillLevels) / sizeof(const char*);\n\n\nstatic const char *netSources[] = {\n\t\"Local\",\n\t\"Mplayer\",\n\t\"Internet\",\n\t\"Favorites\"\n};\nstatic const int numNetSources = sizeof(netSources) / sizeof(const char*);\n\nstatic const serverFilter_t serverFilters[] = {\n\t{\"All\", \"\" },\n\t{\"Quake 3 Arena\", \"\" },\n\t{\"Team Arena\", \"missionpack\" },\n\t{\"Rocket Arena\", \"arena\" },\n\t{\"Alliance\", \"alliance20\" },\n\t{\"Weapons Factory Arena\", \"wfa\" },\n\t{\"OSP\", \"osp\" },\n};\n\nstatic const char *teamArenaGameTypes[] = {\n\t\"FFA\",\n\t\"TOURNAMENT\",\n\t\"SP\",\n\t\"TEAM DM\",\n\t\"CTF\",\n\t\"1FCTF\",\n\t\"OVERLOAD\",\n\t\"HARVESTER\",\n\t\"TEAMTOURNAMENT\"\n};\n\nstatic int const numTeamArenaGameTypes = sizeof(teamArenaGameTypes) / sizeof(const char*);\n\n\nstatic const char *teamArenaGameNames[] = {\n\t\"Free For All\",\n\t\"Tournament\",\n\t\"Single Player\",\n\t\"Team Deathmatch\",\n\t\"Capture the Flag\",\n\t\"One Flag CTF\",\n\t\"Overload\",\n\t\"Harvester\",\n\t\"Team Tournament\",\n};\n\nstatic int const numTeamArenaGameNames = sizeof(teamArenaGameNames) / sizeof(const char*);\n\n\nstatic const int numServerFilters = sizeof(serverFilters) / sizeof(serverFilter_t);\n\nstatic const char *sortKeys[] = {\n\t\"Server Name\",\n\t\"Map Name\",\n\t\"Open Player Spots\",\n\t\"Game Type\",\n\t\"Ping Time\"\n};\nstatic const int numSortKeys = sizeof(sortKeys) / sizeof(const char*);\n\nstatic char* netnames[] = {\n\t\"???\",\n\t\"UDP\",\n\t\"IPX\",\n\tNULL\n};\n\n#ifndef MISSIONPACK // bk001206\nstatic char quake3worldMessage[] = \"Visit www.quake3world.com - News, Community, Events, Files\";\n#endif\n\nstatic int gamecodetoui[] = {4,2,3,0,5,1,6};\nstatic int uitogamecode[] = {4,6,2,3,1,5,7};\n\n\nstatic void UI_StartServerRefresh(qboolean full);\nstatic void UI_StopServerRefresh( void );\nstatic void UI_DoServerRefresh( void );\nstatic void UI_FeederSelection(float feederID, int index);\nstatic void UI_BuildServerDisplayList(qboolean force);\nstatic void UI_BuildServerStatus(qboolean force);\nstatic void UI_BuildFindPlayerList(qboolean force);\nstatic int QDECL UI_ServersQsortCompare( const void *arg1, const void *arg2 );\nstatic int UI_MapCountByGameType(qboolean singlePlayer);\nstatic int UI_HeadCountByTeam( void );\nstatic void UI_ParseGameInfo(const char *teamFile);\nstatic void UI_ParseTeamInfo(const char *teamFile);\nstatic const char *UI_SelectedMap(int index, int *actual);\nstatic const char *UI_SelectedHead(int index, int *actual);\nstatic int UI_GetIndexFromSelection(int actual);\n\nint ProcessNewUI( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6 );\n\n/*\n================\nvmMain\n\nThis is the only way control passes into the module.\nThis must be the very first function compiled into the .qvm file\n================\n*/\nvmCvar_t  ui_new;\nvmCvar_t  ui_debug;\nvmCvar_t  ui_initialized;\nvmCvar_t  ui_teamArenaFirstRun;\n\nvoid _UI_Init( qboolean );\nvoid _UI_Shutdown( void );\nvoid _UI_KeyEvent( int key, qboolean down );\nvoid _UI_MouseEvent( int dx, int dy );\nvoid _UI_Refresh( int realtime );\nqboolean _UI_IsFullscreen( void );\nint vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11  ) {\n  switch ( command ) {\n\t  case UI_GETAPIVERSION:\n\t\t  return UI_API_VERSION;\n\n\t  case UI_INIT:\n\t\t  _UI_Init(arg0);\n\t\t  return 0;\n\n\t  case UI_SHUTDOWN:\n\t\t  _UI_Shutdown();\n\t\t  return 0;\n\n\t  case UI_KEY_EVENT:\n\t\t  _UI_KeyEvent( arg0, arg1 );\n\t\t  return 0;\n\n\t  case UI_MOUSE_EVENT:\n\t\t  _UI_MouseEvent( arg0, arg1 );\n\t\t  return 0;\n\n\t  case UI_REFRESH:\n\t\t  _UI_Refresh( arg0 );\n\t\t  return 0;\n\n\t  case UI_IS_FULLSCREEN:\n\t\t  return _UI_IsFullscreen();\n\n\t  case UI_SET_ACTIVE_MENU:\n\t\t  _UI_SetActiveMenu( arg0 );\n\t\t  return 0;\n\n\t  case UI_CONSOLE_COMMAND:\n\t\t  return UI_ConsoleCommand(arg0);\n\n\t  case UI_DRAW_CONNECT_SCREEN:\n\t\t  UI_DrawConnectScreen( arg0 );\n\t\t  return 0;\n\t  case UI_HASUNIQUECDKEY: // mod authors need to observe this\n\t    return qtrue; // bk010117 - change this to qfalse for mods!\n\n\t}\n\n\treturn -1;\n}\n\n\n\nvoid AssetCache() {\n\tint n;\n\t//if (Assets.textFont == NULL) {\n\t//}\n\t//Assets.background = trap_R_RegisterShaderNoMip( ASSET_BACKGROUND );\n\t//Com_Printf(\"Menu Size: %i bytes\\n\", sizeof(Menus));\n\tuiInfo.uiDC.Assets.gradientBar = trap_R_RegisterShaderNoMip( ASSET_GRADIENTBAR );\n\tuiInfo.uiDC.Assets.fxBasePic = trap_R_RegisterShaderNoMip( ART_FX_BASE );\n\tuiInfo.uiDC.Assets.fxPic[0] = trap_R_RegisterShaderNoMip( ART_FX_RED );\n\tuiInfo.uiDC.Assets.fxPic[1] = trap_R_RegisterShaderNoMip( ART_FX_YELLOW );\n\tuiInfo.uiDC.Assets.fxPic[2] = trap_R_RegisterShaderNoMip( ART_FX_GREEN );\n\tuiInfo.uiDC.Assets.fxPic[3] = trap_R_RegisterShaderNoMip( ART_FX_TEAL );\n\tuiInfo.uiDC.Assets.fxPic[4] = trap_R_RegisterShaderNoMip( ART_FX_BLUE );\n\tuiInfo.uiDC.Assets.fxPic[5] = trap_R_RegisterShaderNoMip( ART_FX_CYAN );\n\tuiInfo.uiDC.Assets.fxPic[6] = trap_R_RegisterShaderNoMip( ART_FX_WHITE );\n\tuiInfo.uiDC.Assets.scrollBar = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR );\n\tuiInfo.uiDC.Assets.scrollBarArrowDown = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWDOWN );\n\tuiInfo.uiDC.Assets.scrollBarArrowUp = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWUP );\n\tuiInfo.uiDC.Assets.scrollBarArrowLeft = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWLEFT );\n\tuiInfo.uiDC.Assets.scrollBarArrowRight = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWRIGHT );\n\tuiInfo.uiDC.Assets.scrollBarThumb = trap_R_RegisterShaderNoMip( ASSET_SCROLL_THUMB );\n\tuiInfo.uiDC.Assets.sliderBar = trap_R_RegisterShaderNoMip( ASSET_SLIDER_BAR );\n\tuiInfo.uiDC.Assets.sliderThumb = trap_R_RegisterShaderNoMip( ASSET_SLIDER_THUMB );\n\n\tfor( n = 0; n < NUM_CROSSHAIRS; n++ ) {\n\t\tuiInfo.uiDC.Assets.crosshairShader[n] = trap_R_RegisterShaderNoMip( va(\"gfx/2d/crosshair%c\", 'a' + n ) );\n\t}\n\n\tuiInfo.newHighScoreSound = trap_S_RegisterSound(\"sound/feedback/voc_newhighscore.wav\", qfalse);\n}\n\nvoid _UI_DrawSides(float x, float y, float w, float h, float size) {\n\tUI_AdjustFrom640( &x, &y, &w, &h );\n\tsize *= uiInfo.uiDC.xscale;\n\ttrap_R_DrawStretchPic( x, y, size, h, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );\n\ttrap_R_DrawStretchPic( x + w - size, y, size, h, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );\n}\n\nvoid _UI_DrawTopBottom(float x, float y, float w, float h, float size) {\n\tUI_AdjustFrom640( &x, &y, &w, &h );\n\tsize *= uiInfo.uiDC.yscale;\n\ttrap_R_DrawStretchPic( x, y, w, size, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );\n\ttrap_R_DrawStretchPic( x, y + h - size, w, size, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );\n}\n/*\n================\nUI_DrawRect\n\nCoordinates are 640*480 virtual values\n=================\n*/\nvoid _UI_DrawRect( float x, float y, float width, float height, float size, const float *color ) {\n\ttrap_R_SetColor( color );\n\n  _UI_DrawTopBottom(x, y, width, height, size);\n  _UI_DrawSides(x, y, width, height, size);\n\n\ttrap_R_SetColor( NULL );\n}\n\nint Text_Width(const char *text, float scale, int limit) {\n  int count,len;\n\tfloat out;\n\tglyphInfo_t *glyph;\n\tfloat useScale;\n\tconst char *s = text;\n\tfontInfo_t *font = &uiInfo.uiDC.Assets.textFont;\n\tif (scale <= ui_smallFont.value) {\n\t\tfont = &uiInfo.uiDC.Assets.smallFont;\n\t} else if (scale >= ui_bigFont.value) {\n\t\tfont = &uiInfo.uiDC.Assets.bigFont;\n\t}\n\tuseScale = scale * font->glyphScale;\n  out = 0;\n  if (text) {\n    len = strlen(text);\n\t\tif (limit > 0 && len > limit) {\n\t\t\tlen = limit;\n\t\t}\n\t\tcount = 0;\n\t\twhile (s && *s && count < len) {\n\t\t\tif ( Q_IsColorString(s) ) {\n\t\t\t\ts += 2;\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\tglyph = &font->glyphs[(int)*s];\n\t\t\t\tout += glyph->xSkip;\n\t\t\t\ts++;\n\t\t\t\tcount++;\n\t\t\t}\n    }\n  }\n  return out * useScale;\n}\n\nint Text_Height(const char *text, float scale, int limit) {\n  int len, count;\n\tfloat max;\n\tglyphInfo_t *glyph;\n\tfloat useScale;\n\tconst char *s = text; // bk001206 - unsigned\n\tfontInfo_t *font = &uiInfo.uiDC.Assets.textFont;\n\tif (scale <= ui_smallFont.value) {\n\t\tfont = &uiInfo.uiDC.Assets.smallFont;\n\t} else if (scale >= ui_bigFont.value) {\n\t\tfont = &uiInfo.uiDC.Assets.bigFont;\n\t}\n\tuseScale = scale * font->glyphScale;\n  max = 0;\n  if (text) {\n    len = strlen(text);\n\t\tif (limit > 0 && len > limit) {\n\t\t\tlen = limit;\n\t\t}\n\t\tcount = 0;\n\t\twhile (s && *s && count < len) {\n\t\t\tif ( Q_IsColorString(s) ) {\n\t\t\t\ts += 2;\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\tglyph = &font->glyphs[(int)*s]; // TTimo: FIXME: getting nasty warnings without the cast, hopefully this doesn't break the VM build\n\t      if (max < glyph->height) {\n\t\t      max = glyph->height;\n\t\t\t  }\n\t\t\t\ts++;\n\t\t\t\tcount++;\n\t\t\t}\n    }\n  }\n  return max * useScale;\n}\n\nvoid Text_PaintChar(float x, float y, float width, float height, float scale, float s, float t, float s2, float t2, qhandle_t hShader) {\n  float w, h;\n  w = width * scale;\n  h = height * scale;\n  UI_AdjustFrom640( &x, &y, &w, &h );\n  trap_R_DrawStretchPic( x, y, w, h, s, t, s2, t2, hShader );\n}\n\nvoid Text_Paint(float x, float y, float scale, vec4_t color, const char *text, float adjust, int limit, int style) {\n  int len, count;\n\tvec4_t newColor;\n\tglyphInfo_t *glyph;\n\tfloat useScale;\n\tfontInfo_t *font = &uiInfo.uiDC.Assets.textFont;\n\tif (scale <= ui_smallFont.value) {\n\t\tfont = &uiInfo.uiDC.Assets.smallFont;\n\t} else if (scale >= ui_bigFont.value) {\n\t\tfont = &uiInfo.uiDC.Assets.bigFont;\n\t}\n\tuseScale = scale * font->glyphScale;\n  if (text) {\n    const char *s = text; // bk001206 - unsigned\n\t\ttrap_R_SetColor( color );\n\t\tmemcpy(&newColor[0], &color[0], sizeof(vec4_t));\n    len = strlen(text);\n\t\tif (limit > 0 && len > limit) {\n\t\t\tlen = limit;\n\t\t}\n\t\tcount = 0;\n\t\twhile (s && *s && count < len) {\n\t\t\tglyph = &font->glyphs[(int)*s]; // TTimo: FIXME: getting nasty warnings without the cast, hopefully this doesn't break the VM build\n      //int yadj = Assets.textFont.glyphs[text[i]].bottom + Assets.textFont.glyphs[text[i]].top;\n      //float yadj = scale * (Assets.textFont.glyphs[text[i]].imageHeight - Assets.textFont.glyphs[text[i]].height);\n\t\t\tif ( Q_IsColorString( s ) ) {\n\t\t\t\tmemcpy( newColor, g_color_table[ColorIndex(*(s+1))], sizeof( newColor ) );\n\t\t\t\tnewColor[3] = color[3];\n\t\t\t\ttrap_R_SetColor( newColor );\n\t\t\t\ts += 2;\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\tfloat yadj = useScale * glyph->top;\n\t\t\t\tif (style == ITEM_TEXTSTYLE_SHADOWED || style == ITEM_TEXTSTYLE_SHADOWEDMORE) {\n\t\t\t\t\tint ofs = style == ITEM_TEXTSTYLE_SHADOWED ? 1 : 2;\n\t\t\t\t\tcolorBlack[3] = newColor[3];\n\t\t\t\t\ttrap_R_SetColor( colorBlack );\n\t\t\t\t\tText_PaintChar(x + ofs, y - yadj + ofs, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->imageWidth,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->imageHeight,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tuseScale, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->s,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->t,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->s2,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->t2,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->glyph);\n\t\t\t\t\ttrap_R_SetColor( newColor );\n\t\t\t\t\tcolorBlack[3] = 1.0;\n\t\t\t\t}\n\t\t\t\tText_PaintChar(x, y - yadj, \n\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->imageWidth,\n\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->imageHeight,\n\t\t\t\t\t\t\t\t\t\t\t\t\tuseScale, \n\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->s,\n\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->t,\n\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->s2,\n\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->t2,\n\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->glyph);\n\n\t\t\t\tx += (glyph->xSkip * useScale) + adjust;\n\t\t\t\ts++;\n\t\t\t\tcount++;\n\t\t\t}\n    }\n\t  trap_R_SetColor( NULL );\n  }\n}\n\nvoid Text_PaintWithCursor(float x, float y, float scale, vec4_t color, const char *text, int cursorPos, char cursor, int limit, int style) {\n  int len, count;\n\tvec4_t newColor;\n\tglyphInfo_t *glyph, *glyph2;\n\tfloat yadj;\n\tfloat useScale;\n\tfontInfo_t *font = &uiInfo.uiDC.Assets.textFont;\n\tif (scale <= ui_smallFont.value) {\n\t\tfont = &uiInfo.uiDC.Assets.smallFont;\n\t} else if (scale >= ui_bigFont.value) {\n\t\tfont = &uiInfo.uiDC.Assets.bigFont;\n\t}\n\tuseScale = scale * font->glyphScale;\n  if (text) {\n    const char *s = text; // bk001206 - unsigned\n\t\ttrap_R_SetColor( color );\n\t\tmemcpy(&newColor[0], &color[0], sizeof(vec4_t));\n    len = strlen(text);\n\t\tif (limit > 0 && len > limit) {\n\t\t\tlen = limit;\n\t\t}\n\t\tcount = 0;\n\t\tglyph2 = &font->glyphs[ (int) cursor]; // bk001206 - possible signed char\n\t\twhile (s && *s && count < len) {\n\t\t\tglyph = &font->glyphs[(int)*s]; // TTimo: FIXME: getting nasty warnings without the cast, hopefully this doesn't break the VM build\n      //int yadj = Assets.textFont.glyphs[text[i]].bottom + Assets.textFont.glyphs[text[i]].top;\n      //float yadj = scale * (Assets.textFont.glyphs[text[i]].imageHeight - Assets.textFont.glyphs[text[i]].height);\n\t\t\tif ( Q_IsColorString( s ) ) {\n\t\t\t\tmemcpy( newColor, g_color_table[ColorIndex(*(s+1))], sizeof( newColor ) );\n\t\t\t\tnewColor[3] = color[3];\n\t\t\t\ttrap_R_SetColor( newColor );\n\t\t\t\ts += 2;\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\tyadj = useScale * glyph->top;\n\t\t\t\tif (style == ITEM_TEXTSTYLE_SHADOWED || style == ITEM_TEXTSTYLE_SHADOWEDMORE) {\n\t\t\t\t\tint ofs = style == ITEM_TEXTSTYLE_SHADOWED ? 1 : 2;\n\t\t\t\t\tcolorBlack[3] = newColor[3];\n\t\t\t\t\ttrap_R_SetColor( colorBlack );\n\t\t\t\t\tText_PaintChar(x + ofs, y - yadj + ofs, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->imageWidth,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->imageHeight,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tuseScale, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->s,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->t,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->s2,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->t2,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->glyph);\n\t\t\t\t\tcolorBlack[3] = 1.0;\n\t\t\t\t\ttrap_R_SetColor( newColor );\n\t\t\t\t}\n\t\t\t\tText_PaintChar(x, y - yadj, \n\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->imageWidth,\n\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->imageHeight,\n\t\t\t\t\t\t\t\t\t\t\t\t\tuseScale, \n\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->s,\n\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->t,\n\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->s2,\n\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->t2,\n\t\t\t\t\t\t\t\t\t\t\t\t\tglyph->glyph);\n\n\t      yadj = useScale * glyph2->top;\n\t\t    if (count == cursorPos && !((uiInfo.uiDC.realTime/BLINK_DIVISOR) & 1)) {\n\t\t\t\t\tText_PaintChar(x, y - yadj, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph2->imageWidth,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph2->imageHeight,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tuseScale, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph2->s,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph2->t,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph2->s2,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph2->t2,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tglyph2->glyph);\n\t\t\t\t}\n\n\t\t\t\tx += (glyph->xSkip * useScale);\n\t\t\t\ts++;\n\t\t\t\tcount++;\n\t\t\t}\n    }\n    // need to paint cursor at end of text\n    if (cursorPos == len && !((uiInfo.uiDC.realTime/BLINK_DIVISOR) & 1)) {\n        yadj = useScale * glyph2->top;\n        Text_PaintChar(x, y - yadj, \n                          glyph2->imageWidth,\n                          glyph2->imageHeight,\n                          useScale, \n                          glyph2->s,\n                          glyph2->t,\n                          glyph2->s2,\n                          glyph2->t2,\n                          glyph2->glyph);\n\n    }\n\n\t  trap_R_SetColor( NULL );\n  }\n}\n\n\nstatic void Text_Paint_Limit(float *maxX, float x, float y, float scale, vec4_t color, const char* text, float adjust, int limit) {\n  int len, count;\n\tvec4_t newColor;\n\tglyphInfo_t *glyph;\n  if (text) {\n    const char *s = text; // bk001206 - unsigned\n\t\tfloat max = *maxX;\n\t\tfloat useScale;\n\t\tfontInfo_t *font = &uiInfo.uiDC.Assets.textFont;\n\t\tif (scale <= ui_smallFont.value) {\n\t\t\tfont = &uiInfo.uiDC.Assets.smallFont;\n\t\t} else if (scale > ui_bigFont.value) {\n\t\t\tfont = &uiInfo.uiDC.Assets.bigFont;\n\t\t}\n\t\tuseScale = scale * font->glyphScale;\n\t\ttrap_R_SetColor( color );\n    len = strlen(text);\t\t\t\t\t \n\t\tif (limit > 0 && len > limit) {\n\t\t\tlen = limit;\n\t\t}\n\t\tcount = 0;\n\t\twhile (s && *s && count < len) {\n\t\t\tglyph = &font->glyphs[(int)*s]; // TTimo: FIXME: getting nasty warnings without the cast, hopefully this doesn't break the VM build\n\t\t\tif ( Q_IsColorString( s ) ) {\n\t\t\t\tmemcpy( newColor, g_color_table[ColorIndex(*(s+1))], sizeof( newColor ) );\n\t\t\t\tnewColor[3] = color[3];\n\t\t\t\ttrap_R_SetColor( newColor );\n\t\t\t\ts += 2;\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t      float yadj = useScale * glyph->top;\n\t\t\t\tif (Text_Width(s, useScale, 1) + x > max) {\n\t\t\t\t\t*maxX = 0;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t    Text_PaintChar(x, y - yadj, \n\t\t\t                 glyph->imageWidth,\n\t\t\t\t               glyph->imageHeight,\n\t\t\t\t               useScale, \n\t\t\t\t\t\t           glyph->s,\n\t\t\t\t\t\t\t\t       glyph->t,\n\t\t\t\t\t\t\t\t       glyph->s2,\n\t\t\t\t\t\t\t\t\t     glyph->t2,\n\t\t\t\t\t\t\t\t\t\t   glyph->glyph);\n\t      x += (glyph->xSkip * useScale) + adjust;\n\t\t\t\t*maxX = x;\n\t\t\t\tcount++;\n\t\t\t\ts++;\n\t    }\n\t\t}\n\t  trap_R_SetColor( NULL );\n  }\n\n}\n\n\nvoid UI_ShowPostGame(qboolean newHigh) {\n\ttrap_Cvar_Set (\"cg_cameraOrbit\", \"0\");\n\ttrap_Cvar_Set(\"cg_thirdPerson\", \"0\");\n\ttrap_Cvar_Set( \"sv_killserver\", \"1\" );\n\tuiInfo.soundHighScore = newHigh;\n  _UI_SetActiveMenu(UIMENU_POSTGAME);\n}\n/*\n=================\n_UI_Refresh\n=================\n*/\n\nvoid UI_DrawCenteredPic(qhandle_t image, int w, int h) {\n  int x, y;\n  x = (SCREEN_WIDTH - w) / 2;\n  y = (SCREEN_HEIGHT - h) / 2;\n  UI_DrawHandlePic(x, y, w, h, image);\n}\n\nint frameCount = 0;\nint startTime;\n\n#define\tUI_FPS_FRAMES\t4\nvoid _UI_Refresh( int realtime )\n{\n\tstatic int index;\n\tstatic int\tpreviousTimes[UI_FPS_FRAMES];\n\n\t//if ( !( trap_Key_GetCatcher() & KEYCATCH_UI ) ) {\n\t//\treturn;\n\t//}\n\n\tuiInfo.uiDC.frameTime = realtime - uiInfo.uiDC.realTime;\n\tuiInfo.uiDC.realTime = realtime;\n\n\tpreviousTimes[index % UI_FPS_FRAMES] = uiInfo.uiDC.frameTime;\n\tindex++;\n\tif ( index > UI_FPS_FRAMES ) {\n\t\tint i, total;\n\t\t// average multiple frames together to smooth changes out a bit\n\t\ttotal = 0;\n\t\tfor ( i = 0 ; i < UI_FPS_FRAMES ; i++ ) {\n\t\t\ttotal += previousTimes[i];\n\t\t}\n\t\tif ( !total ) {\n\t\t\ttotal = 1;\n\t\t}\n\t\tuiInfo.uiDC.FPS = 1000 * UI_FPS_FRAMES / total;\n\t}\n\n\n\n\tUI_UpdateCvars();\n\n\tif (Menu_Count() > 0) {\n\t\t// paint all the menus\n\t\tMenu_PaintAll();\n\t\t// refresh server browser list\n\t\tUI_DoServerRefresh();\n\t\t// refresh server status\n\t\tUI_BuildServerStatus(qfalse);\n\t\t// refresh find player list\n\t\tUI_BuildFindPlayerList(qfalse);\n\t} \n\t\n\t// draw cursor\n\tUI_SetColor( NULL );\n\tif (Menu_Count() > 0) {\n\t\tUI_DrawHandlePic( uiInfo.uiDC.cursorx-16, uiInfo.uiDC.cursory-16, 32, 32, uiInfo.uiDC.Assets.cursor);\n\t}\n\n#ifndef NDEBUG\n\tif (uiInfo.uiDC.debug)\n\t{\n\t\t// cursor coordinates\n\t\t//FIXME\n\t\t//UI_DrawString( 0, 0, va(\"(%d,%d)\",uis.cursorx,uis.cursory), UI_LEFT|UI_SMALLFONT, colorRed );\n\t}\n#endif\n\n}\n\n/*\n=================\n_UI_Shutdown\n=================\n*/\nvoid _UI_Shutdown( void ) {\n\ttrap_LAN_SaveCachedServers();\n}\n\nchar *defaultMenu = NULL;\n\nchar *GetMenuBuffer(const char *filename) {\n\tint\tlen;\n\tfileHandle_t\tf;\n\tstatic char buf[MAX_MENUFILE];\n\n\tlen = trap_FS_FOpenFile( filename, &f, FS_READ );\n\tif ( !f ) {\n\t\ttrap_Print( va( S_COLOR_RED \"menu file not found: %s, using default\\n\", filename ) );\n\t\treturn defaultMenu;\n\t}\n\tif ( len >= MAX_MENUFILE ) {\n\t\ttrap_Print( va( S_COLOR_RED \"menu file too large: %s is %i, max allowed is %i\", filename, len, MAX_MENUFILE ) );\n\t\ttrap_FS_FCloseFile( f );\n\t\treturn defaultMenu;\n\t}\n\n\ttrap_FS_Read( buf, len, f );\n\tbuf[len] = 0;\n\ttrap_FS_FCloseFile( f );\n\t//COM_Compress(buf);\n  return buf;\n\n}\n\nqboolean Asset_Parse(int handle) {\n\tpc_token_t token;\n\tconst char *tempStr;\n\n\tif (!trap_PC_ReadToken(handle, &token))\n\t\treturn qfalse;\n\tif (Q_stricmp(token.string, \"{\") != 0) {\n\t\treturn qfalse;\n\t}\n    \n\twhile ( 1 ) {\n\n\t\tmemset(&token, 0, sizeof(pc_token_t));\n\n\t\tif (!trap_PC_ReadToken(handle, &token))\n\t\t\treturn qfalse;\n\n\t\tif (Q_stricmp(token.string, \"}\") == 0) {\n\t\t\treturn qtrue;\n\t\t}\n\n\t\t// font\n\t\tif (Q_stricmp(token.string, \"font\") == 0) {\n\t\t\tint pointSize;\n\t\t\tif (!PC_String_Parse(handle, &tempStr) || !PC_Int_Parse(handle,&pointSize)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\ttrap_R_RegisterFont(tempStr, pointSize, &uiInfo.uiDC.Assets.textFont);\n\t\t\tuiInfo.uiDC.Assets.fontRegistered = qtrue;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (Q_stricmp(token.string, \"smallFont\") == 0) {\n\t\t\tint pointSize;\n\t\t\tif (!PC_String_Parse(handle, &tempStr) || !PC_Int_Parse(handle,&pointSize)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\ttrap_R_RegisterFont(tempStr, pointSize, &uiInfo.uiDC.Assets.smallFont);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (Q_stricmp(token.string, \"bigFont\") == 0) {\n\t\t\tint pointSize;\n\t\t\tif (!PC_String_Parse(handle, &tempStr) || !PC_Int_Parse(handle,&pointSize)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\ttrap_R_RegisterFont(tempStr, pointSize, &uiInfo.uiDC.Assets.bigFont);\n\t\t\tcontinue;\n\t\t}\n\n\n\t\t// gradientbar\n\t\tif (Q_stricmp(token.string, \"gradientbar\") == 0) {\n\t\t\tif (!PC_String_Parse(handle, &tempStr)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tuiInfo.uiDC.Assets.gradientBar = trap_R_RegisterShaderNoMip(tempStr);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// enterMenuSound\n\t\tif (Q_stricmp(token.string, \"menuEnterSound\") == 0) {\n\t\t\tif (!PC_String_Parse(handle, &tempStr)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tuiInfo.uiDC.Assets.menuEnterSound = trap_S_RegisterSound( tempStr, qfalse );\n\t\t\tcontinue;\n\t\t}\n\n\t\t// exitMenuSound\n\t\tif (Q_stricmp(token.string, \"menuExitSound\") == 0) {\n\t\t\tif (!PC_String_Parse(handle, &tempStr)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tuiInfo.uiDC.Assets.menuExitSound = trap_S_RegisterSound( tempStr, qfalse );\n\t\t\tcontinue;\n\t\t}\n\n\t\t// itemFocusSound\n\t\tif (Q_stricmp(token.string, \"itemFocusSound\") == 0) {\n\t\t\tif (!PC_String_Parse(handle, &tempStr)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tuiInfo.uiDC.Assets.itemFocusSound = trap_S_RegisterSound( tempStr, qfalse );\n\t\t\tcontinue;\n\t\t}\n\n\t\t// menuBuzzSound\n\t\tif (Q_stricmp(token.string, \"menuBuzzSound\") == 0) {\n\t\t\tif (!PC_String_Parse(handle, &tempStr)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tuiInfo.uiDC.Assets.menuBuzzSound = trap_S_RegisterSound( tempStr, qfalse );\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (Q_stricmp(token.string, \"cursor\") == 0) {\n\t\t\tif (!PC_String_Parse(handle, &uiInfo.uiDC.Assets.cursorStr)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tuiInfo.uiDC.Assets.cursor = trap_R_RegisterShaderNoMip( uiInfo.uiDC.Assets.cursorStr);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (Q_stricmp(token.string, \"fadeClamp\") == 0) {\n\t\t\tif (!PC_Float_Parse(handle, &uiInfo.uiDC.Assets.fadeClamp)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (Q_stricmp(token.string, \"fadeCycle\") == 0) {\n\t\t\tif (!PC_Int_Parse(handle, &uiInfo.uiDC.Assets.fadeCycle)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (Q_stricmp(token.string, \"fadeAmount\") == 0) {\n\t\t\tif (!PC_Float_Parse(handle, &uiInfo.uiDC.Assets.fadeAmount)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (Q_stricmp(token.string, \"shadowX\") == 0) {\n\t\t\tif (!PC_Float_Parse(handle, &uiInfo.uiDC.Assets.shadowX)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (Q_stricmp(token.string, \"shadowY\") == 0) {\n\t\t\tif (!PC_Float_Parse(handle, &uiInfo.uiDC.Assets.shadowY)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (Q_stricmp(token.string, \"shadowColor\") == 0) {\n\t\t\tif (!PC_Color_Parse(handle, &uiInfo.uiDC.Assets.shadowColor)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\tuiInfo.uiDC.Assets.shadowFadeClamp = uiInfo.uiDC.Assets.shadowColor[3];\n\t\t\tcontinue;\n\t\t}\n\n\t}\n\treturn qfalse;\n}\n\nvoid Font_Report() {\n  int i;\n  Com_Printf(\"Font Info\\n\");\n  Com_Printf(\"=========\\n\");\n  for ( i = 32; i < 96; i++) {\n    Com_Printf(\"Glyph handle %i: %i\\n\", i, uiInfo.uiDC.Assets.textFont.glyphs[i].glyph);\n  }\n}\n\nvoid UI_Report() {\n  String_Report();\n  //Font_Report();\n\n}\n\nvoid UI_ParseMenu(const char *menuFile) {\n\tint handle;\n\tpc_token_t token;\n\n\tCom_Printf(\"Parsing menu file:%s\\n\", menuFile);\n\n\thandle = trap_PC_LoadSource(menuFile);\n\tif (!handle) {\n\t\treturn;\n\t}\n\n\twhile ( 1 ) {\n\t\tmemset(&token, 0, sizeof(pc_token_t));\n\t\tif (!trap_PC_ReadToken( handle, &token )) {\n\t\t\tbreak;\n\t\t}\n\n\t\t//if ( Q_stricmp( token, \"{\" ) ) {\n\t\t//\tCom_Printf( \"Missing { in menu file\\n\" );\n\t\t//\tbreak;\n\t\t//}\n\n\t\t//if ( menuCount == MAX_MENUS ) {\n\t\t//\tCom_Printf( \"Too many menus!\\n\" );\n\t\t//\tbreak;\n\t\t//}\n\n\t\tif ( token.string[0] == '}' ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (Q_stricmp(token.string, \"assetGlobalDef\") == 0) {\n\t\t\tif (Asset_Parse(handle)) {\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (Q_stricmp(token.string, \"menudef\") == 0) {\n\t\t\t// start a new menu\n\t\t\tMenu_New(handle);\n\t\t}\n\t}\n\ttrap_PC_FreeSource(handle);\n}\n\nqboolean Load_Menu(int handle) {\n\tpc_token_t token;\n\n\tif (!trap_PC_ReadToken(handle, &token))\n\t\treturn qfalse;\n\tif (token.string[0] != '{') {\n\t\treturn qfalse;\n\t}\n\n\twhile ( 1 ) {\n\n\t\tif (!trap_PC_ReadToken(handle, &token))\n\t\t\treturn qfalse;\n    \n\t\tif ( token.string[0] == 0 ) {\n\t\t\treturn qfalse;\n\t\t}\n\n\t\tif ( token.string[0] == '}' ) {\n\t\t\treturn qtrue;\n\t\t}\n\n\t\tUI_ParseMenu(token.string); \n\t}\n\treturn qfalse;\n}\n\nvoid UI_LoadMenus(const char *menuFile, qboolean reset) {\n\tpc_token_t token;\n\tint handle;\n\tint start;\n\n\tstart = trap_Milliseconds();\n\n\thandle = trap_PC_LoadSource( menuFile );\n\tif (!handle) {\n\t\ttrap_Error( va( S_COLOR_YELLOW \"menu file not found: %s, using default\\n\", menuFile ) );\n\t\thandle = trap_PC_LoadSource( \"ui/menus.txt\" );\n\t\tif (!handle) {\n\t\t\ttrap_Error( va( S_COLOR_RED \"default menu file not found: ui/menus.txt, unable to continue!\\n\", menuFile ) );\n\t\t}\n\t}\n\n\tui_new.integer = 1;\n\n\tif (reset) {\n\t\tMenu_Reset();\n\t}\n\n\twhile ( 1 ) {\n\t\tif (!trap_PC_ReadToken(handle, &token))\n\t\t\tbreak;\n\t\tif( token.string[0] == 0 || token.string[0] == '}') {\n\t\t\tbreak;\n\t\t}\n\n\t\tif ( token.string[0] == '}' ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (Q_stricmp(token.string, \"loadmenu\") == 0) {\n\t\t\tif (Load_Menu(handle)) {\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tCom_Printf(\"UI menu load time = %d milli seconds\\n\", trap_Milliseconds() - start);\n\n\ttrap_PC_FreeSource( handle );\n}\n\nvoid UI_Load() {\n\tchar lastName[1024];\n  menuDef_t *menu = Menu_GetFocused();\n\tchar *menuSet = UI_Cvar_VariableString(\"ui_menuFiles\");\n\tif (menu && menu->window.name) {\n\t\tstrcpy(lastName, menu->window.name);\n\t}\n\tif (menuSet == NULL || menuSet[0] == '\\0') {\n\t\tmenuSet = \"ui/menus.txt\";\n\t}\n\n\tString_Init();\n\n#ifdef PRE_RELEASE_TADEMO\n\tUI_ParseGameInfo(\"demogameinfo.txt\");\n#else\n\tUI_ParseGameInfo(\"gameinfo.txt\");\n\tUI_LoadArenas();\n#endif\n\n\tUI_LoadMenus(menuSet, qtrue);\n\tMenus_CloseAll();\n\tMenus_ActivateByName(lastName);\n\n}\n\nstatic const char *handicapValues[] = {\"None\",\"95\",\"90\",\"85\",\"80\",\"75\",\"70\",\"65\",\"60\",\"55\",\"50\",\"45\",\"40\",\"35\",\"30\",\"25\",\"20\",\"15\",\"10\",\"5\",NULL};\n#ifndef MISSIONPACK // bk001206\nstatic int numHandicaps = sizeof(handicapValues) / sizeof(const char*);\n#endif\n\nstatic void UI_DrawHandicap(rectDef_t *rect, float scale, vec4_t color, int textStyle) {\n  int i, h;\n\n  h = Com_Clamp( 5, 100, trap_Cvar_VariableValue(\"handicap\") );\n  i = 20 - h / 5;\n\n  Text_Paint(rect->x, rect->y, scale, color, handicapValues[i], 0, 0, textStyle);\n}\n\nstatic void UI_DrawClanName(rectDef_t *rect, float scale, vec4_t color, int textStyle) {\n  Text_Paint(rect->x, rect->y, scale, color, UI_Cvar_VariableString(\"ui_teamName\"), 0, 0, textStyle);\n}\n\n\nstatic void UI_SetCapFragLimits(qboolean uiVars) {\n\tint cap = 5;\n\tint frag = 10;\n\tif (uiInfo.gameTypes[ui_gameType.integer].gtEnum == GT_OBELISK) {\n\t\tcap = 4;\n\t} else if (uiInfo.gameTypes[ui_gameType.integer].gtEnum == GT_HARVESTER) {\n\t\tcap = 15;\n\t}\n\tif (uiVars) {\n\t\ttrap_Cvar_Set(\"ui_captureLimit\", va(\"%d\", cap));\n\t\ttrap_Cvar_Set(\"ui_fragLimit\", va(\"%d\", frag));\n\t} else {\n\t\ttrap_Cvar_Set(\"capturelimit\", va(\"%d\", cap));\n\t\ttrap_Cvar_Set(\"fraglimit\", va(\"%d\", frag));\n\t}\n}\n// ui_gameType assumes gametype 0 is -1 ALL and will not show\nstatic void UI_DrawGameType(rectDef_t *rect, float scale, vec4_t color, int textStyle) {\n  Text_Paint(rect->x, rect->y, scale, color, uiInfo.gameTypes[ui_gameType.integer].gameType, 0, 0, textStyle);\n}\n\nstatic void UI_DrawNetGameType(rectDef_t *rect, float scale, vec4_t color, int textStyle) {\n\tif (ui_netGameType.integer < 0 || ui_netGameType.integer > uiInfo.numGameTypes) {\n\t\ttrap_Cvar_Set(\"ui_netGameType\", \"0\");\n\t\ttrap_Cvar_Set(\"ui_actualNetGameType\", \"0\");\n\t}\n  Text_Paint(rect->x, rect->y, scale, color, uiInfo.gameTypes[ui_netGameType.integer].gameType , 0, 0, textStyle);\n}\n\nstatic void UI_DrawJoinGameType(rectDef_t *rect, float scale, vec4_t color, int textStyle) {\n\tif (ui_joinGameType.integer < 0 || ui_joinGameType.integer > uiInfo.numJoinGameTypes) {\n\t\ttrap_Cvar_Set(\"ui_joinGameType\", \"0\");\n\t}\n  Text_Paint(rect->x, rect->y, scale, color, uiInfo.joinGameTypes[ui_joinGameType.integer].gameType , 0, 0, textStyle);\n}\n\n\n\nstatic int UI_TeamIndexFromName(const char *name) {\n  int i;\n\n  if (name && *name) {\n    for (i = 0; i < uiInfo.teamCount; i++) {\n      if (Q_stricmp(name, uiInfo.teamList[i].teamName) == 0) {\n        return i;\n      }\n    }\n  } \n\n  return 0;\n\n}\n\nstatic void UI_DrawClanLogo(rectDef_t *rect, float scale, vec4_t color) {\n  int i;\n  i = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_teamName\"));\n  if (i >= 0 && i < uiInfo.teamCount) {\n  \ttrap_R_SetColor( color );\n\n\t\tif (uiInfo.teamList[i].teamIcon == -1) {\n      uiInfo.teamList[i].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[i].imageName);\n      uiInfo.teamList[i].teamIcon_Metal = trap_R_RegisterShaderNoMip(va(\"%s_metal\",uiInfo.teamList[i].imageName));\n      uiInfo.teamList[i].teamIcon_Name = trap_R_RegisterShaderNoMip(va(\"%s_name\", uiInfo.teamList[i].imageName));\n\t\t}\n\n  \tUI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon);\n    trap_R_SetColor(NULL);\n  }\n}\n\nstatic void UI_DrawClanCinematic(rectDef_t *rect, float scale, vec4_t color) {\n  int i;\n  i = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_teamName\"));\n  if (i >= 0 && i < uiInfo.teamCount) {\n\n\t\tif (uiInfo.teamList[i].cinematic >= -2) {\n\t\t\tif (uiInfo.teamList[i].cinematic == -1) {\n\t\t\t\tuiInfo.teamList[i].cinematic = trap_CIN_PlayCinematic(va(\"%s.roq\", uiInfo.teamList[i].imageName), 0, 0, 0, 0, (CIN_loop | CIN_silent) );\n\t\t\t}\n\t\t\tif (uiInfo.teamList[i].cinematic >= 0) {\n\t\t\t  trap_CIN_RunCinematic(uiInfo.teamList[i].cinematic);\n\t\t\t\ttrap_CIN_SetExtents(uiInfo.teamList[i].cinematic, rect->x, rect->y, rect->w, rect->h);\n\t \t\t\ttrap_CIN_DrawCinematic(uiInfo.teamList[i].cinematic);\n\t\t\t} else {\n\t\t\t  \ttrap_R_SetColor( color );\n\t\t\t\tUI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon_Metal);\n\t\t\t\ttrap_R_SetColor(NULL);\n\t\t\t\tuiInfo.teamList[i].cinematic = -2;\n\t\t\t}\n\t\t} else {\n\t  \ttrap_R_SetColor( color );\n\t\t\tUI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon);\n\t\t\ttrap_R_SetColor(NULL);\n\t\t}\n\t}\n\n}\n\nstatic void UI_DrawPreviewCinematic(rectDef_t *rect, float scale, vec4_t color) {\n\tif (uiInfo.previewMovie > -2) {\n\t\tuiInfo.previewMovie = trap_CIN_PlayCinematic(va(\"%s.roq\", uiInfo.movieList[uiInfo.movieIndex]), 0, 0, 0, 0, (CIN_loop | CIN_silent) );\n\t\tif (uiInfo.previewMovie >= 0) {\n\t\t  trap_CIN_RunCinematic(uiInfo.previewMovie);\n\t\t\ttrap_CIN_SetExtents(uiInfo.previewMovie, rect->x, rect->y, rect->w, rect->h);\n \t\t\ttrap_CIN_DrawCinematic(uiInfo.previewMovie);\n\t\t} else {\n\t\t\tuiInfo.previewMovie = -2;\n\t\t}\n\t} \n\n}\n\n\n\nstatic void UI_DrawSkill(rectDef_t *rect, float scale, vec4_t color, int textStyle) {\n  int i;\n\ti = trap_Cvar_VariableValue( \"g_spSkill\" );\n  if (i < 1 || i > numSkillLevels) {\n    i = 1;\n  }\n  Text_Paint(rect->x, rect->y, scale, color, skillLevels[i-1],0, 0, textStyle);\n}\n\n\nstatic void UI_DrawTeamName(rectDef_t *rect, float scale, vec4_t color, qboolean blue, int textStyle) {\n  int i;\n  i = UI_TeamIndexFromName(UI_Cvar_VariableString((blue) ? \"ui_blueTeam\" : \"ui_redTeam\"));\n  if (i >= 0 && i < uiInfo.teamCount) {\n    Text_Paint(rect->x, rect->y, scale, color, va(\"%s: %s\", (blue) ? \"Blue\" : \"Red\", uiInfo.teamList[i].teamName),0, 0, textStyle);\n  }\n}\n\nstatic void UI_DrawTeamMember(rectDef_t *rect, float scale, vec4_t color, qboolean blue, int num, int textStyle) {\n\t// 0 - None\n\t// 1 - Human\n\t// 2..NumCharacters - Bot\n\tint value = trap_Cvar_VariableValue(va(blue ? \"ui_blueteam%i\" : \"ui_redteam%i\", num));\n\tconst char *text;\n\tif (value <= 0) {\n\t\ttext = \"Closed\";\n\t} else if (value == 1) {\n\t\ttext = \"Human\";\n\t} else {\n\t\tvalue -= 2;\n\n\t\tif (ui_actualNetGameType.integer >= GT_TEAM) {\n\t\t\tif (value >= uiInfo.characterCount) {\n\t\t\t\tvalue = 0;\n\t\t\t}\n\t\t\ttext = uiInfo.characterList[value].name;\n\t\t} else {\n\t\t\tif (value >= UI_GetNumBots()) {\n\t\t\t\tvalue = 0;\n\t\t\t}\n\t\t\ttext = UI_GetBotNameByNumber(value);\n\t\t}\n\t}\n  Text_Paint(rect->x, rect->y, scale, color, text, 0, 0, textStyle);\n}\n\nstatic void UI_DrawEffects(rectDef_t *rect, float scale, vec4_t color) {\n\tUI_DrawHandlePic( rect->x, rect->y - 14, 128, 8, uiInfo.uiDC.Assets.fxBasePic );\n\tUI_DrawHandlePic( rect->x + uiInfo.effectsColor * 16 + 8, rect->y - 16, 16, 12, uiInfo.uiDC.Assets.fxPic[uiInfo.effectsColor] );\n}\n\nstatic void UI_DrawMapPreview(rectDef_t *rect, float scale, vec4_t color, qboolean net) {\n\tint map = (net) ? ui_currentNetMap.integer : ui_currentMap.integer;\n\tif (map < 0 || map > uiInfo.mapCount) {\n\t\tif (net) {\n\t\t\tui_currentNetMap.integer = 0;\n\t\t\ttrap_Cvar_Set(\"ui_currentNetMap\", \"0\");\n\t\t} else {\n\t\t\tui_currentMap.integer = 0;\n\t\t\ttrap_Cvar_Set(\"ui_currentMap\", \"0\");\n\t\t}\n\t\tmap = 0;\n\t}\n\n\tif (uiInfo.mapList[map].levelShot == -1) {\n\t\tuiInfo.mapList[map].levelShot = trap_R_RegisterShaderNoMip(uiInfo.mapList[map].imageName);\n\t}\n\n\tif (uiInfo.mapList[map].levelShot > 0) {\n\t\tUI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.mapList[map].levelShot);\n\t} else {\n\t\tUI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, trap_R_RegisterShaderNoMip(\"menu/art/unknownmap\"));\n\t}\n}\t\t\t\t\t\t \n\n\nstatic void UI_DrawMapTimeToBeat(rectDef_t *rect, float scale, vec4_t color, int textStyle) {\n\tint minutes, seconds, time;\n\tif (ui_currentMap.integer < 0 || ui_currentMap.integer > uiInfo.mapCount) {\n\t\tui_currentMap.integer = 0;\n\t\ttrap_Cvar_Set(\"ui_currentMap\", \"0\");\n\t}\n\n\ttime = uiInfo.mapList[ui_currentMap.integer].timeToBeat[uiInfo.gameTypes[ui_gameType.integer].gtEnum];\n\n\tminutes = time / 60;\n\tseconds = time % 60;\n\n  Text_Paint(rect->x, rect->y, scale, color, va(\"%02i:%02i\", minutes, seconds), 0, 0, textStyle);\n}\n\n\n\nstatic void UI_DrawMapCinematic(rectDef_t *rect, float scale, vec4_t color, qboolean net) {\n\n\tint map = (net) ? ui_currentNetMap.integer : ui_currentMap.integer; \n\tif (map < 0 || map > uiInfo.mapCount) {\n\t\tif (net) {\n\t\t\tui_currentNetMap.integer = 0;\n\t\t\ttrap_Cvar_Set(\"ui_currentNetMap\", \"0\");\n\t\t} else {\n\t\t\tui_currentMap.integer = 0;\n\t\t\ttrap_Cvar_Set(\"ui_currentMap\", \"0\");\n\t\t}\n\t\tmap = 0;\n\t}\n\n\tif (uiInfo.mapList[map].cinematic >= -1) {\n\t\tif (uiInfo.mapList[map].cinematic == -1) {\n\t\t\tuiInfo.mapList[map].cinematic = trap_CIN_PlayCinematic(va(\"%s.roq\", uiInfo.mapList[map].mapLoadName), 0, 0, 0, 0, (CIN_loop | CIN_silent) );\n\t\t}\n\t\tif (uiInfo.mapList[map].cinematic >= 0) {\n\t\t  trap_CIN_RunCinematic(uiInfo.mapList[map].cinematic);\n\t\t  trap_CIN_SetExtents(uiInfo.mapList[map].cinematic, rect->x, rect->y, rect->w, rect->h);\n \t\t\ttrap_CIN_DrawCinematic(uiInfo.mapList[map].cinematic);\n\t\t} else {\n\t\t\tuiInfo.mapList[map].cinematic = -2;\n\t\t}\n\t} else {\n\t\tUI_DrawMapPreview(rect, scale, color, net);\n\t}\n}\n\n\n\nstatic qboolean updateModel = qtrue;\nstatic qboolean q3Model = qfalse;\n\nstatic void UI_DrawPlayerModel(rectDef_t *rect) {\n  static playerInfo_t info;\n  char model[MAX_QPATH];\n  char team[256];\n\tchar head[256];\n\tvec3_t\tviewangles;\n\tvec3_t\tmoveangles;\n\n\t  if (trap_Cvar_VariableValue(\"ui_Q3Model\")) {\n\t  strcpy(model, UI_Cvar_VariableString(\"model\"));\n\t\tstrcpy(head, UI_Cvar_VariableString(\"headmodel\"));\n\t\tif (!q3Model) {\n\t\t\tq3Model = qtrue;\n\t\t\tupdateModel = qtrue;\n\t\t}\n\t\tteam[0] = '\\0';\n\t} else {\n\n\t\tstrcpy(team, UI_Cvar_VariableString(\"ui_teamName\"));\n\t\tstrcpy(model, UI_Cvar_VariableString(\"team_model\"));\n\t\tstrcpy(head, UI_Cvar_VariableString(\"team_headmodel\"));\n\t\tif (q3Model) {\n\t\t\tq3Model = qfalse;\n\t\t\tupdateModel = qtrue;\n\t\t}\n\t}\n  if (updateModel) {\n  \tmemset( &info, 0, sizeof(playerInfo_t) );\n  \tviewangles[YAW]   = 180 - 10;\n  \tviewangles[PITCH] = 0;\n  \tviewangles[ROLL]  = 0;\n  \tVectorClear( moveangles );\n    UI_PlayerInfo_SetModel( &info, model, head, team);\n    UI_PlayerInfo_SetInfo( &info, LEGS_IDLE, TORSO_STAND, viewangles, vec3_origin, WP_MACHINEGUN, qfalse );\n//\t\tUI_RegisterClientModelname( &info, model, head, team);\n    updateModel = qfalse;\n  }\n\n  UI_DrawPlayer( rect->x, rect->y, rect->w, rect->h, &info, uiInfo.uiDC.realTime / 2);\n\n}\n\nstatic void UI_DrawNetSource(rectDef_t *rect, float scale, vec4_t color, int textStyle) {\n\tif (ui_netSource.integer < 0 || ui_netSource.integer > numNetSources) {\n\t\tui_netSource.integer = 0;\n\t}\n  Text_Paint(rect->x, rect->y, scale, color, va(\"Source: %s\", netSources[ui_netSource.integer]), 0, 0, textStyle);\n}\n\nstatic void UI_DrawNetMapPreview(rectDef_t *rect, float scale, vec4_t color) {\n\n\tif (uiInfo.serverStatus.currentServerPreview > 0) {\n\t\tUI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.serverStatus.currentServerPreview);\n\t} else {\n\t\tUI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, trap_R_RegisterShaderNoMip(\"menu/art/unknownmap\"));\n\t}\n}\n\nstatic void UI_DrawNetMapCinematic(rectDef_t *rect, float scale, vec4_t color) {\n\tif (ui_currentNetMap.integer < 0 || ui_currentNetMap.integer > uiInfo.mapCount) {\n\t\tui_currentNetMap.integer = 0;\n\t\ttrap_Cvar_Set(\"ui_currentNetMap\", \"0\");\n\t}\n\n\tif (uiInfo.serverStatus.currentServerCinematic >= 0) {\n\t  trap_CIN_RunCinematic(uiInfo.serverStatus.currentServerCinematic);\n\t  trap_CIN_SetExtents(uiInfo.serverStatus.currentServerCinematic, rect->x, rect->y, rect->w, rect->h);\n \t  trap_CIN_DrawCinematic(uiInfo.serverStatus.currentServerCinematic);\n\t} else {\n\t\tUI_DrawNetMapPreview(rect, scale, color);\n\t}\n}\n\n\n\nstatic void UI_DrawNetFilter(rectDef_t *rect, float scale, vec4_t color, int textStyle) {\n\tif (ui_serverFilterType.integer < 0 || ui_serverFilterType.integer > numServerFilters) {\n\t\tui_serverFilterType.integer = 0;\n\t}\n  Text_Paint(rect->x, rect->y, scale, color, va(\"Filter: %s\", serverFilters[ui_serverFilterType.integer].description), 0, 0, textStyle);\n}\n\n\nstatic void UI_DrawTier(rectDef_t *rect, float scale, vec4_t color, int textStyle) {\n  int i;\n\ti = trap_Cvar_VariableValue( \"ui_currentTier\" );\n  if (i < 0 || i >= uiInfo.tierCount) {\n    i = 0;\n  }\n  Text_Paint(rect->x, rect->y, scale, color, va(\"Tier: %s\", uiInfo.tierList[i].tierName),0, 0, textStyle);\n}\n\nstatic void UI_DrawTierMap(rectDef_t *rect, int index) {\n  int i;\n\ti = trap_Cvar_VariableValue( \"ui_currentTier\" );\n  if (i < 0 || i >= uiInfo.tierCount) {\n    i = 0;\n  }\n\n\tif (uiInfo.tierList[i].mapHandles[index] == -1) {\n\t\tuiInfo.tierList[i].mapHandles[index] = trap_R_RegisterShaderNoMip(va(\"levelshots/%s\", uiInfo.tierList[i].maps[index]));\n\t}\n\t\t\t\t\t\t\t\t\t\t\t\t \n\tUI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.tierList[i].mapHandles[index]);\n}\n\nstatic const char *UI_EnglishMapName(const char *map) {\n\tint i;\n\tfor (i = 0; i < uiInfo.mapCount; i++) {\n\t\tif (Q_stricmp(map, uiInfo.mapList[i].mapLoadName) == 0) {\n\t\t\treturn uiInfo.mapList[i].mapName;\n\t\t}\n\t}\n\treturn \"\";\n}\n\nstatic void UI_DrawTierMapName(rectDef_t *rect, float scale, vec4_t color, int textStyle) {\n  int i, j;\n\ti = trap_Cvar_VariableValue( \"ui_currentTier\" );\n  if (i < 0 || i >= uiInfo.tierCount) {\n    i = 0;\n  }\n\tj = trap_Cvar_VariableValue(\"ui_currentMap\");\n\tif (j < 0 || j > MAPS_PER_TIER) {\n\t\tj = 0;\n\t}\n\n  Text_Paint(rect->x, rect->y, scale, color, UI_EnglishMapName(uiInfo.tierList[i].maps[j]), 0, 0, textStyle);\n}\n\nstatic void UI_DrawTierGameType(rectDef_t *rect, float scale, vec4_t color, int textStyle) {\n  int i, j;\n\ti = trap_Cvar_VariableValue( \"ui_currentTier\" );\n  if (i < 0 || i >= uiInfo.tierCount) {\n    i = 0;\n  }\n\tj = trap_Cvar_VariableValue(\"ui_currentMap\");\n\tif (j < 0 || j > MAPS_PER_TIER) {\n\t\tj = 0;\n\t}\n\n  Text_Paint(rect->x, rect->y, scale, color, uiInfo.gameTypes[uiInfo.tierList[i].gameTypes[j]].gameType , 0, 0, textStyle);\n}\n\n\n#ifndef MISSIONPACK // bk001206\nstatic const char *UI_OpponentLeaderName() {\n  int i = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_opponentName\"));\n\treturn uiInfo.teamList[i].teamMembers[0];\n}\n#endif\n\nstatic const char *UI_AIFromName(const char *name) {\n\tint j;\n\tfor (j = 0; j < uiInfo.aliasCount; j++) {\n\t\tif (Q_stricmp(uiInfo.aliasList[j].name, name) == 0) {\n\t\t\treturn uiInfo.aliasList[j].ai;\n\t\t}\n\t}\n\treturn \"James\";\n}\n\n#ifndef MISSIONPACK // bk001206\nstatic const int UI_AIIndex(const char *name) {\n\tint j;\n\tfor (j = 0; j < uiInfo.characterCount; j++) {\n\t\tif (Q_stricmp(name, uiInfo.characterList[j].name) == 0) {\n\t\t\treturn j;\n\t\t}\n\t}\n\treturn 0;\n}\n#endif\n\n#ifndef MISSIONPACK // bk001206\nstatic const int UI_AIIndexFromName(const char *name) {\n\tint j;\n\tfor (j = 0; j < uiInfo.aliasCount; j++) {\n\t\tif (Q_stricmp(uiInfo.aliasList[j].name, name) == 0) {\n\t\t\treturn UI_AIIndex(uiInfo.aliasList[j].ai);\n\t\t}\n\t}\n\treturn 0;\n}\n#endif\n\n\n#ifndef MISSIONPACK // bk001206\nstatic const char *UI_OpponentLeaderHead() {\n\tconst char *leader = UI_OpponentLeaderName();\n\treturn UI_AIFromName(leader);\n}\n#endif\n\n#ifndef MISSIONPACK // bk001206\nstatic const char *UI_OpponentLeaderModel() {\n\tint i;\n\tconst char *head = UI_OpponentLeaderHead();\n\tfor (i = 0; i < uiInfo.characterCount; i++) {\n\t\tif (Q_stricmp(head, uiInfo.characterList[i].name) == 0) {\n\t\t\treturn uiInfo.characterList[i].base;\n\t\t}\n\t}\n\treturn \"James\";\n}\n#endif\n\n\nstatic qboolean updateOpponentModel = qtrue;\nstatic void UI_DrawOpponent(rectDef_t *rect) {\n  static playerInfo_t info2;\n  char model[MAX_QPATH];\n  char headmodel[MAX_QPATH];\n  char team[256];\n\tvec3_t\tviewangles;\n\tvec3_t\tmoveangles;\n  \n\tif (updateOpponentModel) {\n\t\t\n\t\tstrcpy(model, UI_Cvar_VariableString(\"ui_opponentModel\"));\n\t  strcpy(headmodel, UI_Cvar_VariableString(\"ui_opponentModel\"));\n\t\tteam[0] = '\\0';\n\n  \tmemset( &info2, 0, sizeof(playerInfo_t) );\n  \tviewangles[YAW]   = 180 - 10;\n  \tviewangles[PITCH] = 0;\n  \tviewangles[ROLL]  = 0;\n  \tVectorClear( moveangles );\n    UI_PlayerInfo_SetModel( &info2, model, headmodel, \"\");\n    UI_PlayerInfo_SetInfo( &info2, LEGS_IDLE, TORSO_STAND, viewangles, vec3_origin, WP_MACHINEGUN, qfalse );\n\t\tUI_RegisterClientModelname( &info2, model, headmodel, team);\n    updateOpponentModel = qfalse;\n  }\n\n  UI_DrawPlayer( rect->x, rect->y, rect->w, rect->h, &info2, uiInfo.uiDC.realTime / 2);\n\n}\n\nstatic void UI_NextOpponent() {\n  int i = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_opponentName\"));\n  int j = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_teamName\"));\n\ti++;\n\tif (i >= uiInfo.teamCount) {\n\t\ti = 0;\n\t}\n\tif (i == j) {\n\t\ti++;\n\t\tif ( i >= uiInfo.teamCount) {\n\t\t\ti = 0;\n\t\t}\n\t}\n \ttrap_Cvar_Set( \"ui_opponentName\", uiInfo.teamList[i].teamName );\n}\n\nstatic void UI_PriorOpponent() {\n  int i = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_opponentName\"));\n  int j = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_teamName\"));\n\ti--;\n\tif (i < 0) {\n\t\ti = uiInfo.teamCount - 1;\n\t}\n\tif (i == j) {\n\t\ti--;\n\t\tif ( i < 0) {\n\t\t\ti = uiInfo.teamCount - 1;\n\t\t}\n\t}\n \ttrap_Cvar_Set( \"ui_opponentName\", uiInfo.teamList[i].teamName );\n}\n\nstatic void\tUI_DrawPlayerLogo(rectDef_t *rect, vec3_t color) {\n  int i = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_teamName\"));\n\n\tif (uiInfo.teamList[i].teamIcon == -1) {\n    uiInfo.teamList[i].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[i].imageName);\n    uiInfo.teamList[i].teamIcon_Metal = trap_R_RegisterShaderNoMip(va(\"%s_metal\",uiInfo.teamList[i].imageName));\n    uiInfo.teamList[i].teamIcon_Name = trap_R_RegisterShaderNoMip(va(\"%s_name\", uiInfo.teamList[i].imageName));\n\t}\n\n \ttrap_R_SetColor( color );\n\tUI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon );\n \ttrap_R_SetColor( NULL );\n}\n\nstatic void\tUI_DrawPlayerLogoMetal(rectDef_t *rect, vec3_t color) {\n  int i = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_teamName\"));\n\tif (uiInfo.teamList[i].teamIcon == -1) {\n    uiInfo.teamList[i].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[i].imageName);\n    uiInfo.teamList[i].teamIcon_Metal = trap_R_RegisterShaderNoMip(va(\"%s_metal\",uiInfo.teamList[i].imageName));\n    uiInfo.teamList[i].teamIcon_Name = trap_R_RegisterShaderNoMip(va(\"%s_name\", uiInfo.teamList[i].imageName));\n\t}\n\n \ttrap_R_SetColor( color );\n\tUI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon_Metal );\n \ttrap_R_SetColor( NULL );\n}\n\nstatic void\tUI_DrawPlayerLogoName(rectDef_t *rect, vec3_t color) {\n  int i = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_teamName\"));\n\tif (uiInfo.teamList[i].teamIcon == -1) {\n    uiInfo.teamList[i].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[i].imageName);\n    uiInfo.teamList[i].teamIcon_Metal = trap_R_RegisterShaderNoMip(va(\"%s_metal\",uiInfo.teamList[i].imageName));\n    uiInfo.teamList[i].teamIcon_Name = trap_R_RegisterShaderNoMip(va(\"%s_name\", uiInfo.teamList[i].imageName));\n\t}\n\n \ttrap_R_SetColor( color );\n\tUI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon_Name );\n \ttrap_R_SetColor( NULL );\n}\n\nstatic void\tUI_DrawOpponentLogo(rectDef_t *rect, vec3_t color) {\n  int i = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_opponentName\"));\n\tif (uiInfo.teamList[i].teamIcon == -1) {\n    uiInfo.teamList[i].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[i].imageName);\n    uiInfo.teamList[i].teamIcon_Metal = trap_R_RegisterShaderNoMip(va(\"%s_metal\",uiInfo.teamList[i].imageName));\n    uiInfo.teamList[i].teamIcon_Name = trap_R_RegisterShaderNoMip(va(\"%s_name\", uiInfo.teamList[i].imageName));\n\t}\n\n \ttrap_R_SetColor( color );\n\tUI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon );\n \ttrap_R_SetColor( NULL );\n}\n\nstatic void\tUI_DrawOpponentLogoMetal(rectDef_t *rect, vec3_t color) {\n  int i = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_opponentName\"));\n\tif (uiInfo.teamList[i].teamIcon == -1) {\n    uiInfo.teamList[i].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[i].imageName);\n    uiInfo.teamList[i].teamIcon_Metal = trap_R_RegisterShaderNoMip(va(\"%s_metal\",uiInfo.teamList[i].imageName));\n    uiInfo.teamList[i].teamIcon_Name = trap_R_RegisterShaderNoMip(va(\"%s_name\", uiInfo.teamList[i].imageName));\n\t}\n\n \ttrap_R_SetColor( color );\n\tUI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon_Metal );\n \ttrap_R_SetColor( NULL );\n}\n\nstatic void\tUI_DrawOpponentLogoName(rectDef_t *rect, vec3_t color) {\n  int i = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_opponentName\"));\n\tif (uiInfo.teamList[i].teamIcon == -1) {\n    uiInfo.teamList[i].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[i].imageName);\n    uiInfo.teamList[i].teamIcon_Metal = trap_R_RegisterShaderNoMip(va(\"%s_metal\",uiInfo.teamList[i].imageName));\n    uiInfo.teamList[i].teamIcon_Name = trap_R_RegisterShaderNoMip(va(\"%s_name\", uiInfo.teamList[i].imageName));\n\t}\n\n \ttrap_R_SetColor( color );\n\tUI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon_Name );\n \ttrap_R_SetColor( NULL );\n}\n\nstatic void UI_DrawAllMapsSelection(rectDef_t *rect, float scale, vec4_t color, int textStyle, qboolean net) {\n\tint map = (net) ? ui_currentNetMap.integer : ui_currentMap.integer;\n\tif (map >= 0 && map < uiInfo.mapCount) {\n\t  Text_Paint(rect->x, rect->y, scale, color, uiInfo.mapList[map].mapName, 0, 0, textStyle);\n\t}\n}\n\nstatic void UI_DrawOpponentName(rectDef_t *rect, float scale, vec4_t color, int textStyle) {\n  Text_Paint(rect->x, rect->y, scale, color, UI_Cvar_VariableString(\"ui_opponentName\"), 0, 0, textStyle);\n}\n\n\nstatic int UI_OwnerDrawWidth(int ownerDraw, float scale) {\n\tint i, h, value;\n\tconst char *text;\n\tconst char *s = NULL;\n\n  switch (ownerDraw) {\n    case UI_HANDICAP:\n\t\t\t  h = Com_Clamp( 5, 100, trap_Cvar_VariableValue(\"handicap\") );\n\t\t\t\ti = 20 - h / 5;\n\t\t\t\ts = handicapValues[i];\n      break;\n    case UI_CLANNAME:\n\t\t\t\ts = UI_Cvar_VariableString(\"ui_teamName\");\n      break;\n    case UI_GAMETYPE:\n\t\t\t\ts = uiInfo.gameTypes[ui_gameType.integer].gameType;\n      break;\n    case UI_SKILL:\n\t\t\t\ti = trap_Cvar_VariableValue( \"g_spSkill\" );\n\t\t\t\tif (i < 1 || i > numSkillLevels) {\n\t\t\t\t\ti = 1;\n\t\t\t\t}\n\t\t\t  s = skillLevels[i-1];\n      break;\n    case UI_BLUETEAMNAME:\n\t\t\t  i = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_blueTeam\"));\n\t\t\t  if (i >= 0 && i < uiInfo.teamCount) {\n\t\t\t    s = va(\"%s: %s\", \"Blue\", uiInfo.teamList[i].teamName);\n\t\t\t  }\n      break;\n    case UI_REDTEAMNAME:\n\t\t\t  i = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_redTeam\"));\n\t\t\t  if (i >= 0 && i < uiInfo.teamCount) {\n\t\t\t    s = va(\"%s: %s\", \"Red\", uiInfo.teamList[i].teamName);\n\t\t\t  }\n      break;\n    case UI_BLUETEAM1:\n\t\tcase UI_BLUETEAM2:\n\t\tcase UI_BLUETEAM3:\n\t\tcase UI_BLUETEAM4:\n\t\tcase UI_BLUETEAM5:\n\t\t\tvalue = trap_Cvar_VariableValue(va(\"ui_blueteam%i\", ownerDraw-UI_BLUETEAM1 + 1));\n\t\t\tif (value <= 0) {\n\t\t\t\ttext = \"Closed\";\n\t\t\t} else if (value == 1) {\n\t\t\t\ttext = \"Human\";\n\t\t\t} else {\n\t\t\t\tvalue -= 2;\n\t\t\t\tif (value >= uiInfo.aliasCount) {\n\t\t\t\t\tvalue = 0;\n\t\t\t\t}\n\t\t\t\ttext = uiInfo.aliasList[value].name;\n\t\t\t}\n\t\t\ts = va(\"%i. %s\", ownerDraw-UI_BLUETEAM1 + 1, text);\n      break;\n    case UI_REDTEAM1:\n\t\tcase UI_REDTEAM2:\n\t\tcase UI_REDTEAM3:\n\t\tcase UI_REDTEAM4:\n\t\tcase UI_REDTEAM5:\n\t\t\tvalue = trap_Cvar_VariableValue(va(\"ui_redteam%i\", ownerDraw-UI_REDTEAM1 + 1));\n\t\t\tif (value <= 0) {\n\t\t\t\ttext = \"Closed\";\n\t\t\t} else if (value == 1) {\n\t\t\t\ttext = \"Human\";\n\t\t\t} else {\n\t\t\t\tvalue -= 2;\n\t\t\t\tif (value >= uiInfo.aliasCount) {\n\t\t\t\t\tvalue = 0;\n\t\t\t\t}\n\t\t\t\ttext = uiInfo.aliasList[value].name;\n\t\t\t}\n\t\t\ts = va(\"%i. %s\", ownerDraw-UI_REDTEAM1 + 1, text);\n      break;\n\t\tcase UI_NETSOURCE:\n\t\t\tif (ui_netSource.integer < 0 || ui_netSource.integer > uiInfo.numJoinGameTypes) {\n\t\t\t\tui_netSource.integer = 0;\n\t\t\t}\n\t\t\ts = va(\"Source: %s\", netSources[ui_netSource.integer]);\n\t\t\tbreak;\n\t\tcase UI_NETFILTER:\n\t\t\tif (ui_serverFilterType.integer < 0 || ui_serverFilterType.integer > numServerFilters) {\n\t\t\t\tui_serverFilterType.integer = 0;\n\t\t\t}\n\t\t\ts = va(\"Filter: %s\", serverFilters[ui_serverFilterType.integer].description );\n\t\t\tbreak;\n\t\tcase UI_TIER:\n\t\t\tbreak;\n\t\tcase UI_TIER_MAPNAME:\n\t\t\tbreak;\n\t\tcase UI_TIER_GAMETYPE:\n\t\t\tbreak;\n\t\tcase UI_ALLMAPS_SELECTION:\n\t\t\tbreak;\n\t\tcase UI_OPPONENT_NAME:\n\t\t\tbreak;\n\t\tcase UI_KEYBINDSTATUS:\n\t\t\tif (Display_KeyBindPending()) {\n\t\t\t\ts = \"Waiting for new key... Press ESCAPE to cancel\";\n\t\t\t} else {\n\t\t\t\ts = \"Press ENTER or CLICK to change, Press BACKSPACE to clear\";\n\t\t\t}\n\t\t\tbreak;\n\t\tcase UI_SERVERREFRESHDATE:\n\t\t\ts = UI_Cvar_VariableString(va(\"ui_lastServerRefresh_%i\", ui_netSource.integer));\n\t\t\tbreak;\n    default:\n      break;\n  }\n\n\tif (s) {\n\t\treturn Text_Width(s, scale, 0);\n\t}\n\treturn 0;\n}\n\nstatic void UI_DrawBotName(rectDef_t *rect, float scale, vec4_t color, int textStyle) {\n\tint value = uiInfo.botIndex;\n\tint game = trap_Cvar_VariableValue(\"g_gametype\");\n\tconst char *text = \"\";\n\tif (game >= GT_TEAM) {\n\t\tif (value >= uiInfo.characterCount) {\n\t\t\tvalue = 0;\n\t\t}\n\t\ttext = uiInfo.characterList[value].name;\n\t} else {\n\t\tif (value >= UI_GetNumBots()) {\n\t\t\tvalue = 0;\n\t\t}\n\t\ttext = UI_GetBotNameByNumber(value);\n\t}\n  Text_Paint(rect->x, rect->y, scale, color, text, 0, 0, textStyle);\n}\n\nstatic void UI_DrawBotSkill(rectDef_t *rect, float scale, vec4_t color, int textStyle) {\n\tif (uiInfo.skillIndex >= 0 && uiInfo.skillIndex < numSkillLevels) {\n\t  Text_Paint(rect->x, rect->y, scale, color, skillLevels[uiInfo.skillIndex], 0, 0, textStyle);\n\t}\n}\n\nstatic void UI_DrawRedBlue(rectDef_t *rect, float scale, vec4_t color, int textStyle) {\n  Text_Paint(rect->x, rect->y, scale, color, (uiInfo.redBlue == 0) ? \"Red\" : \"Blue\", 0, 0, textStyle);\n}\n\nstatic void UI_DrawCrosshair(rectDef_t *rect, float scale, vec4_t color) {\n \ttrap_R_SetColor( color );\n\tif (uiInfo.currentCrosshair < 0 || uiInfo.currentCrosshair >= NUM_CROSSHAIRS) {\n\t\tuiInfo.currentCrosshair = 0;\n\t}\n\tUI_DrawHandlePic( rect->x, rect->y - rect->h, rect->w, rect->h, uiInfo.uiDC.Assets.crosshairShader[uiInfo.currentCrosshair]);\n \ttrap_R_SetColor( NULL );\n}\n\n/*\n===============\nUI_BuildPlayerList\n===============\n*/\nstatic void UI_BuildPlayerList() {\n\tuiClientState_t\tcs;\n\tint\t\tn, count, team, team2, playerTeamNumber;\n\tchar\tinfo[MAX_INFO_STRING];\n\n\ttrap_GetClientState( &cs );\n\ttrap_GetConfigString( CS_PLAYERS + cs.clientNum, info, MAX_INFO_STRING );\n\tuiInfo.playerNumber = cs.clientNum;\n\tuiInfo.teamLeader = atoi(Info_ValueForKey(info, \"tl\"));\n\tteam = atoi(Info_ValueForKey(info, \"t\"));\n\ttrap_GetConfigString( CS_SERVERINFO, info, sizeof(info) );\n\tcount = atoi( Info_ValueForKey( info, \"sv_maxclients\" ) );\n\tuiInfo.playerCount = 0;\n\tuiInfo.myTeamCount = 0;\n\tplayerTeamNumber = 0;\n\tfor( n = 0; n < count; n++ ) {\n\t\ttrap_GetConfigString( CS_PLAYERS + n, info, MAX_INFO_STRING );\n\n\t\tif (info[0]) {\n\t\t\tQ_strncpyz( uiInfo.playerNames[uiInfo.playerCount], Info_ValueForKey( info, \"n\" ), MAX_NAME_LENGTH );\n\t\t\tQ_CleanStr( uiInfo.playerNames[uiInfo.playerCount] );\n\t\t\tuiInfo.playerCount++;\n\t\t\tteam2 = atoi(Info_ValueForKey(info, \"t\"));\n\t\t\tif (team2 == team) {\n\t\t\t\tQ_strncpyz( uiInfo.teamNames[uiInfo.myTeamCount], Info_ValueForKey( info, \"n\" ), MAX_NAME_LENGTH );\n\t\t\t\tQ_CleanStr( uiInfo.teamNames[uiInfo.myTeamCount] );\n\t\t\t\tuiInfo.teamClientNums[uiInfo.myTeamCount] = n;\n\t\t\t\tif (uiInfo.playerNumber == n) {\n\t\t\t\t\tplayerTeamNumber = uiInfo.myTeamCount;\n\t\t\t\t}\n\t\t\t\tuiInfo.myTeamCount++;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!uiInfo.teamLeader) {\n\t\ttrap_Cvar_Set(\"cg_selectedPlayer\", va(\"%d\", playerTeamNumber));\n\t}\n\n\tn = trap_Cvar_VariableValue(\"cg_selectedPlayer\");\n\tif (n < 0 || n > uiInfo.myTeamCount) {\n\t\tn = 0;\n\t}\n\tif (n < uiInfo.myTeamCount) {\n\t\ttrap_Cvar_Set(\"cg_selectedPlayerName\", uiInfo.teamNames[n]);\n\t}\n}\n\n\nstatic void UI_DrawSelectedPlayer(rectDef_t *rect, float scale, vec4_t color, int textStyle) {\n\tif (uiInfo.uiDC.realTime > uiInfo.playerRefresh) {\n\t\tuiInfo.playerRefresh = uiInfo.uiDC.realTime + 3000;\n\t\tUI_BuildPlayerList();\n\t}\n  Text_Paint(rect->x, rect->y, scale, color, (uiInfo.teamLeader) ? UI_Cvar_VariableString(\"cg_selectedPlayerName\") : UI_Cvar_VariableString(\"name\") , 0, 0, textStyle);\n}\n\nstatic void UI_DrawServerRefreshDate(rectDef_t *rect, float scale, vec4_t color, int textStyle) {\n\tif (uiInfo.serverStatus.refreshActive) {\n\t\tvec4_t lowLight, newColor;\n\t\tlowLight[0] = 0.8 * color[0]; \n\t\tlowLight[1] = 0.8 * color[1]; \n\t\tlowLight[2] = 0.8 * color[2]; \n\t\tlowLight[3] = 0.8 * color[3]; \n\t\tLerpColor(color,lowLight,newColor,0.5+0.5*sin(uiInfo.uiDC.realTime / PULSE_DIVISOR));\n\t  Text_Paint(rect->x, rect->y, scale, newColor, va(\"Getting info for %d servers (ESC to cancel)\", trap_LAN_GetServerCount(ui_netSource.integer)), 0, 0, textStyle);\n\t} else {\n\t\tchar buff[64];\n\t\tQ_strncpyz(buff, UI_Cvar_VariableString(va(\"ui_lastServerRefresh_%i\", ui_netSource.integer)), 64);\n\t  Text_Paint(rect->x, rect->y, scale, color, va(\"Refresh Time: %s\", buff), 0, 0, textStyle);\n\t}\n}\n\nstatic void UI_DrawServerMOTD(rectDef_t *rect, float scale, vec4_t color) {\n\tif (uiInfo.serverStatus.motdLen) {\n\t\tfloat maxX;\n\t \n\t\tif (uiInfo.serverStatus.motdWidth == -1) {\n\t\t\tuiInfo.serverStatus.motdWidth = 0;\n\t\t\tuiInfo.serverStatus.motdPaintX = rect->x + 1;\n\t\t\tuiInfo.serverStatus.motdPaintX2 = -1;\n\t\t}\n\n\t\tif (uiInfo.serverStatus.motdOffset > uiInfo.serverStatus.motdLen) {\n\t\t\tuiInfo.serverStatus.motdOffset = 0;\n\t\t\tuiInfo.serverStatus.motdPaintX = rect->x + 1;\n\t\t\tuiInfo.serverStatus.motdPaintX2 = -1;\n\t\t}\n\n\t\tif (uiInfo.uiDC.realTime > uiInfo.serverStatus.motdTime) {\n\t\t\tuiInfo.serverStatus.motdTime = uiInfo.uiDC.realTime + 10;\n\t\t\tif (uiInfo.serverStatus.motdPaintX <= rect->x + 2) {\n\t\t\t\tif (uiInfo.serverStatus.motdOffset < uiInfo.serverStatus.motdLen) {\n\t\t\t\t\tuiInfo.serverStatus.motdPaintX += Text_Width(&uiInfo.serverStatus.motd[uiInfo.serverStatus.motdOffset], scale, 1) - 1;\n\t\t\t\t\tuiInfo.serverStatus.motdOffset++;\n\t\t\t\t} else {\n\t\t\t\t\tuiInfo.serverStatus.motdOffset = 0;\n\t\t\t\t\tif (uiInfo.serverStatus.motdPaintX2 >= 0) {\n\t\t\t\t\t\tuiInfo.serverStatus.motdPaintX = uiInfo.serverStatus.motdPaintX2;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tuiInfo.serverStatus.motdPaintX = rect->x + rect->w - 2;\n\t\t\t\t\t}\n\t\t\t\t\tuiInfo.serverStatus.motdPaintX2 = -1;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t//serverStatus.motdPaintX--;\n\t\t\t\tuiInfo.serverStatus.motdPaintX -= 2;\n\t\t\t\tif (uiInfo.serverStatus.motdPaintX2 >= 0) {\n\t\t\t\t\t//serverStatus.motdPaintX2--;\n\t\t\t\t\tuiInfo.serverStatus.motdPaintX2 -= 2;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tmaxX = rect->x + rect->w - 2;\n\t\tText_Paint_Limit(&maxX, uiInfo.serverStatus.motdPaintX, rect->y + rect->h - 3, scale, color, &uiInfo.serverStatus.motd[uiInfo.serverStatus.motdOffset], 0, 0); \n\t\tif (uiInfo.serverStatus.motdPaintX2 >= 0) {\n\t\t\tfloat maxX2 = rect->x + rect->w - 2;\n\t\t\tText_Paint_Limit(&maxX2, uiInfo.serverStatus.motdPaintX2, rect->y + rect->h - 3, scale, color, uiInfo.serverStatus.motd, 0, uiInfo.serverStatus.motdOffset); \n\t\t}\n\t\tif (uiInfo.serverStatus.motdOffset && maxX > 0) {\n\t\t\t// if we have an offset ( we are skipping the first part of the string ) and we fit the string\n\t\t\tif (uiInfo.serverStatus.motdPaintX2 == -1) {\n\t\t\t\t\t\tuiInfo.serverStatus.motdPaintX2 = rect->x + rect->w - 2;\n\t\t\t}\n\t\t} else {\n\t\t\tuiInfo.serverStatus.motdPaintX2 = -1;\n\t\t}\n\n\t}\n}\n\nstatic void UI_DrawKeyBindStatus(rectDef_t *rect, float scale, vec4_t color, int textStyle) {\n//\tint ofs = 0; TTimo: unused\n\tif (Display_KeyBindPending()) {\n\t\tText_Paint(rect->x, rect->y, scale, color, \"Waiting for new key... Press ESCAPE to cancel\", 0, 0, textStyle);\n\t} else {\n\t\tText_Paint(rect->x, rect->y, scale, color, \"Press ENTER or CLICK to change, Press BACKSPACE to clear\", 0, 0, textStyle);\n\t}\n}\n\nstatic void UI_DrawGLInfo(rectDef_t *rect, float scale, vec4_t color, int textStyle) {\n\tchar * eptr;\n\tchar buff[1024];\n\tconst char *lines[64];\n\tint y, numLines, i;\n\n\tText_Paint(rect->x + 2, rect->y, scale, color, va(\"VENDOR: %s\", uiInfo.uiDC.glconfig.vendor_string), 0, 30, textStyle);\n\tText_Paint(rect->x + 2, rect->y + 15, scale, color, va(\"VERSION: %s: %s\", uiInfo.uiDC.glconfig.version_string,uiInfo.uiDC.glconfig.renderer_string), 0, 30, textStyle);\n\tText_Paint(rect->x + 2, rect->y + 30, scale, color, va (\"PIXELFORMAT: color(%d-bits) Z(%d-bits) stencil(%d-bits)\", uiInfo.uiDC.glconfig.colorBits, uiInfo.uiDC.glconfig.depthBits, uiInfo.uiDC.glconfig.stencilBits), 0, 30, textStyle);\n\n\t// build null terminated extension strings\n  // TTimo: https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=399\n  // in TA this was not directly crashing, but displaying a nasty broken shader right in the middle\n  // brought down the string size to 1024, there's not much that can be shown on the screen anyway\n\tQ_strncpyz(buff, uiInfo.uiDC.glconfig.extensions_string, 1024);\n\teptr = buff;\n\ty = rect->y + 45;\n\tnumLines = 0;\n\twhile ( y < rect->y + rect->h && *eptr )\n\t{\n\t\twhile ( *eptr && *eptr == ' ' )\n\t\t\t*eptr++ = '\\0';\n\n\t\t// track start of valid string\n\t\tif (*eptr && *eptr != ' ') {\n\t\t\tlines[numLines++] = eptr;\n\t\t}\n\n\t\twhile ( *eptr && *eptr != ' ' )\n\t\t\teptr++;\n\t}\n\n\ti = 0;\n\twhile (i < numLines) {\n\t\tText_Paint(rect->x + 2, y, scale, color, lines[i++], 0, 20, textStyle);\n\t\tif (i < numLines) {\n\t\t\tText_Paint(rect->x + rect->w / 2, y, scale, color, lines[i++], 0, 20, textStyle);\n\t\t}\n\t\ty += 10;\n\t\tif (y > rect->y + rect->h - 11) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\n}\n\n// FIXME: table drive\n//\nstatic void UI_OwnerDraw(float x, float y, float w, float h, float text_x, float text_y, int ownerDraw, int ownerDrawFlags, int align, float special, float scale, vec4_t color, qhandle_t shader, int textStyle) {\n\trectDef_t rect;\n\n  rect.x = x + text_x;\n  rect.y = y + text_y;\n  rect.w = w;\n  rect.h = h;\n\n  switch (ownerDraw) {\n    case UI_HANDICAP:\n      UI_DrawHandicap(&rect, scale, color, textStyle);\n      break;\n    case UI_EFFECTS:\n      UI_DrawEffects(&rect, scale, color);\n      break;\n    case UI_PLAYERMODEL:\n      UI_DrawPlayerModel(&rect);\n      break;\n    case UI_CLANNAME:\n      UI_DrawClanName(&rect, scale, color, textStyle);\n      break;\n    case UI_CLANLOGO:\n      UI_DrawClanLogo(&rect, scale, color);\n      break;\n    case UI_CLANCINEMATIC:\n      UI_DrawClanCinematic(&rect, scale, color);\n      break;\n    case UI_PREVIEWCINEMATIC:\n      UI_DrawPreviewCinematic(&rect, scale, color);\n      break;\n    case UI_GAMETYPE:\n      UI_DrawGameType(&rect, scale, color, textStyle);\n      break;\n    case UI_NETGAMETYPE:\n      UI_DrawNetGameType(&rect, scale, color, textStyle);\n      break;\n    case UI_JOINGAMETYPE:\n\t  UI_DrawJoinGameType(&rect, scale, color, textStyle);\n\t  break;\n    case UI_MAPPREVIEW:\n      UI_DrawMapPreview(&rect, scale, color, qtrue);\n      break;\n    case UI_MAP_TIMETOBEAT:\n      UI_DrawMapTimeToBeat(&rect, scale, color, textStyle);\n      break;\n    case UI_MAPCINEMATIC:\n      UI_DrawMapCinematic(&rect, scale, color, qfalse);\n      break;\n    case UI_STARTMAPCINEMATIC:\n      UI_DrawMapCinematic(&rect, scale, color, qtrue);\n      break;\n    case UI_SKILL:\n      UI_DrawSkill(&rect, scale, color, textStyle);\n      break;\n    case UI_BLUETEAMNAME:\n      UI_DrawTeamName(&rect, scale, color, qtrue, textStyle);\n      break;\n    case UI_REDTEAMNAME:\n      UI_DrawTeamName(&rect, scale, color, qfalse, textStyle);\n      break;\n    case UI_BLUETEAM1:\n\t\tcase UI_BLUETEAM2:\n\t\tcase UI_BLUETEAM3:\n\t\tcase UI_BLUETEAM4:\n\t\tcase UI_BLUETEAM5:\n      UI_DrawTeamMember(&rect, scale, color, qtrue, ownerDraw - UI_BLUETEAM1 + 1, textStyle);\n      break;\n    case UI_REDTEAM1:\n\t\tcase UI_REDTEAM2:\n\t\tcase UI_REDTEAM3:\n\t\tcase UI_REDTEAM4:\n\t\tcase UI_REDTEAM5:\n      UI_DrawTeamMember(&rect, scale, color, qfalse, ownerDraw - UI_REDTEAM1 + 1, textStyle);\n      break;\n\t\tcase UI_NETSOURCE:\n      UI_DrawNetSource(&rect, scale, color, textStyle);\n\t\t\tbreak;\n    case UI_NETMAPPREVIEW:\n      UI_DrawNetMapPreview(&rect, scale, color);\n      break;\n    case UI_NETMAPCINEMATIC:\n      UI_DrawNetMapCinematic(&rect, scale, color);\n      break;\n\t\tcase UI_NETFILTER:\n      UI_DrawNetFilter(&rect, scale, color, textStyle);\n\t\t\tbreak;\n\t\tcase UI_TIER:\n\t\t\tUI_DrawTier(&rect, scale, color, textStyle);\n\t\t\tbreak;\n\t\tcase UI_OPPONENTMODEL:\n\t\t\tUI_DrawOpponent(&rect);\n\t\t\tbreak;\n\t\tcase UI_TIERMAP1:\n\t\t\tUI_DrawTierMap(&rect, 0);\n\t\t\tbreak;\n\t\tcase UI_TIERMAP2:\n\t\t\tUI_DrawTierMap(&rect, 1);\n\t\t\tbreak;\n\t\tcase UI_TIERMAP3:\n\t\t\tUI_DrawTierMap(&rect, 2);\n\t\t\tbreak;\n\t\tcase UI_PLAYERLOGO:\n\t\t\tUI_DrawPlayerLogo(&rect, color);\n\t\t\tbreak;\n\t\tcase UI_PLAYERLOGO_METAL:\n\t\t\tUI_DrawPlayerLogoMetal(&rect, color);\n\t\t\tbreak;\n\t\tcase UI_PLAYERLOGO_NAME:\n\t\t\tUI_DrawPlayerLogoName(&rect, color);\n\t\t\tbreak;\n\t\tcase UI_OPPONENTLOGO:\n\t\t\tUI_DrawOpponentLogo(&rect, color);\n\t\t\tbreak;\n\t\tcase UI_OPPONENTLOGO_METAL:\n\t\t\tUI_DrawOpponentLogoMetal(&rect, color);\n\t\t\tbreak;\n\t\tcase UI_OPPONENTLOGO_NAME:\n\t\t\tUI_DrawOpponentLogoName(&rect, color);\n\t\t\tbreak;\n\t\tcase UI_TIER_MAPNAME:\n\t\t\tUI_DrawTierMapName(&rect, scale, color, textStyle);\n\t\t\tbreak;\n\t\tcase UI_TIER_GAMETYPE:\n\t\t\tUI_DrawTierGameType(&rect, scale, color, textStyle);\n\t\t\tbreak;\n\t\tcase UI_ALLMAPS_SELECTION:\n\t\t\tUI_DrawAllMapsSelection(&rect, scale, color, textStyle, qtrue);\n\t\t\tbreak;\n\t\tcase UI_MAPS_SELECTION:\n\t\t\tUI_DrawAllMapsSelection(&rect, scale, color, textStyle, qfalse);\n\t\t\tbreak;\n\t\tcase UI_OPPONENT_NAME:\n\t\t\tUI_DrawOpponentName(&rect, scale, color, textStyle);\n\t\t\tbreak;\n\t\tcase UI_BOTNAME:\n\t\t\tUI_DrawBotName(&rect, scale, color, textStyle);\n\t\t\tbreak;\n\t\tcase UI_BOTSKILL:\n\t\t\tUI_DrawBotSkill(&rect, scale, color, textStyle);\n\t\t\tbreak;\n\t\tcase UI_REDBLUE:\n\t\t\tUI_DrawRedBlue(&rect, scale, color, textStyle);\n\t\t\tbreak;\n\t\tcase UI_CROSSHAIR:\n\t\t\tUI_DrawCrosshair(&rect, scale, color);\n\t\t\tbreak;\n\t\tcase UI_SELECTEDPLAYER:\n\t\t\tUI_DrawSelectedPlayer(&rect, scale, color, textStyle);\n\t\t\tbreak;\n\t\tcase UI_SERVERREFRESHDATE:\n\t\t\tUI_DrawServerRefreshDate(&rect, scale, color, textStyle);\n\t\t\tbreak;\n\t\tcase UI_SERVERMOTD:\n\t\t\tUI_DrawServerMOTD(&rect, scale, color);\n\t\t\tbreak;\n\t\tcase UI_GLINFO:\n\t\t\tUI_DrawGLInfo(&rect,scale, color, textStyle);\n\t\t\tbreak;\n\t\tcase UI_KEYBINDSTATUS:\n\t\t\tUI_DrawKeyBindStatus(&rect,scale, color, textStyle);\n\t\t\tbreak;\n    default:\n      break;\n  }\n\n}\n\nstatic qboolean UI_OwnerDrawVisible(int flags) {\n\tqboolean vis = qtrue;\n\n\twhile (flags) {\n\n\t\tif (flags & UI_SHOW_FFA) {\n\t\t\tif (trap_Cvar_VariableValue(\"g_gametype\") != GT_FFA) {\n\t\t\t\tvis = qfalse;\n\t\t\t}\n\t\t\tflags &= ~UI_SHOW_FFA;\n\t\t}\n\n\t\tif (flags & UI_SHOW_NOTFFA) {\n\t\t\tif (trap_Cvar_VariableValue(\"g_gametype\") == GT_FFA) {\n\t\t\t\tvis = qfalse;\n\t\t\t}\n\t\t\tflags &= ~UI_SHOW_NOTFFA;\n\t\t}\n\n\t\tif (flags & UI_SHOW_LEADER) {\n\t\t\t// these need to show when this client can give orders to a player or a group\n\t\t\tif (!uiInfo.teamLeader) {\n\t\t\t\tvis = qfalse;\n\t\t\t} else {\n\t\t\t\t// if showing yourself\n\t\t\t\tif (ui_selectedPlayer.integer < uiInfo.myTeamCount && uiInfo.teamClientNums[ui_selectedPlayer.integer] == uiInfo.playerNumber) { \n\t\t\t\t\tvis = qfalse;\n\t\t\t\t}\n\t\t\t}\n\t\t\tflags &= ~UI_SHOW_LEADER;\n\t\t} \n\t\tif (flags & UI_SHOW_NOTLEADER) {\n\t\t\t// these need to show when this client is assigning their own status or they are NOT the leader\n\t\t\tif (uiInfo.teamLeader) {\n\t\t\t\t// if not showing yourself\n\t\t\t\tif (!(ui_selectedPlayer.integer < uiInfo.myTeamCount && uiInfo.teamClientNums[ui_selectedPlayer.integer] == uiInfo.playerNumber)) { \n\t\t\t\t\tvis = qfalse;\n\t\t\t\t}\n\t\t\t\t// these need to show when this client can give orders to a player or a group\n\t\t\t}\n\t\t\tflags &= ~UI_SHOW_NOTLEADER;\n\t\t} \n\t\tif (flags & UI_SHOW_FAVORITESERVERS) {\n\t\t\t// this assumes you only put this type of display flag on something showing in the proper context\n\t\t\tif (ui_netSource.integer != AS_FAVORITES) {\n\t\t\t\tvis = qfalse;\n\t\t\t}\n\t\t\tflags &= ~UI_SHOW_FAVORITESERVERS;\n\t\t} \n\t\tif (flags & UI_SHOW_NOTFAVORITESERVERS) {\n\t\t\t// this assumes you only put this type of display flag on something showing in the proper context\n\t\t\tif (ui_netSource.integer == AS_FAVORITES) {\n\t\t\t\tvis = qfalse;\n\t\t\t}\n\t\t\tflags &= ~UI_SHOW_NOTFAVORITESERVERS;\n\t\t} \n\t\tif (flags & UI_SHOW_ANYTEAMGAME) {\n\t\t\tif (uiInfo.gameTypes[ui_gameType.integer].gtEnum <= GT_TEAM ) {\n\t\t\t\tvis = qfalse;\n\t\t\t}\n\t\t\tflags &= ~UI_SHOW_ANYTEAMGAME;\n\t\t} \n\t\tif (flags & UI_SHOW_ANYNONTEAMGAME) {\n\t\t\tif (uiInfo.gameTypes[ui_gameType.integer].gtEnum > GT_TEAM ) {\n\t\t\t\tvis = qfalse;\n\t\t\t}\n\t\t\tflags &= ~UI_SHOW_ANYNONTEAMGAME;\n\t\t} \n\t\tif (flags & UI_SHOW_NETANYTEAMGAME) {\n\t\t\tif (uiInfo.gameTypes[ui_netGameType.integer].gtEnum <= GT_TEAM ) {\n\t\t\t\tvis = qfalse;\n\t\t\t}\n\t\t\tflags &= ~UI_SHOW_NETANYTEAMGAME;\n\t\t} \n\t\tif (flags & UI_SHOW_NETANYNONTEAMGAME) {\n\t\t\tif (uiInfo.gameTypes[ui_netGameType.integer].gtEnum > GT_TEAM ) {\n\t\t\t\tvis = qfalse;\n\t\t\t}\n\t\t\tflags &= ~UI_SHOW_NETANYNONTEAMGAME;\n\t\t} \n\t\tif (flags & UI_SHOW_NEWHIGHSCORE) {\n\t\t\tif (uiInfo.newHighScoreTime < uiInfo.uiDC.realTime) {\n\t\t\t\tvis = qfalse;\n\t\t\t} else {\n\t\t\t\tif (uiInfo.soundHighScore) {\n\t\t\t\t\tif (trap_Cvar_VariableValue(\"sv_killserver\") == 0) {\n\t\t\t\t\t\t// wait on server to go down before playing sound\n\t\t\t\t\t\ttrap_S_StartLocalSound(uiInfo.newHighScoreSound, CHAN_ANNOUNCER);\n\t\t\t\t\t\tuiInfo.soundHighScore = qfalse;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tflags &= ~UI_SHOW_NEWHIGHSCORE;\n\t\t} \n\t\tif (flags & UI_SHOW_NEWBESTTIME) {\n\t\t\tif (uiInfo.newBestTime < uiInfo.uiDC.realTime) {\n\t\t\t\tvis = qfalse;\n\t\t\t}\n\t\t\tflags &= ~UI_SHOW_NEWBESTTIME;\n\t\t} \n\t\tif (flags & UI_SHOW_DEMOAVAILABLE) {\n\t\t\tif (!uiInfo.demoAvailable) {\n\t\t\t\tvis = qfalse;\n\t\t\t}\n\t\t\tflags &= ~UI_SHOW_DEMOAVAILABLE;\n\t\t} else {\n\t\t\tflags = 0;\n\t\t}\n\t}\n  return vis;\n}\n\nstatic qboolean UI_Handicap_HandleKey(int flags, float *special, int key) {\n  if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) {\n    int h;\n    h = Com_Clamp( 5, 100, trap_Cvar_VariableValue(\"handicap\") );\n\t\tif (key == K_MOUSE2) {\n\t    h -= 5;\n\t\t} else {\n\t    h += 5;\n\t\t}\n    if (h > 100) {\n      h = 5;\n    } else if (h < 0) {\n\t\t\th = 100;\n\t\t}\n  \ttrap_Cvar_Set( \"handicap\", va( \"%i\", h) );\n    return qtrue;\n  }\n  return qfalse;\n}\n\nstatic qboolean UI_Effects_HandleKey(int flags, float *special, int key) {\n  if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) {\n\n\t\tif (key == K_MOUSE2) {\n\t    uiInfo.effectsColor--;\n\t\t} else {\n\t    uiInfo.effectsColor++;\n\t\t}\n\n    if( uiInfo.effectsColor > 6 ) {\n\t  \tuiInfo.effectsColor = 0;\n\t\t} else if (uiInfo.effectsColor < 0) {\n\t  \tuiInfo.effectsColor = 6;\n\t\t}\n\n\t  trap_Cvar_SetValue( \"color1\", uitogamecode[uiInfo.effectsColor] );\n    return qtrue;\n  }\n  return qfalse;\n}\n\nstatic qboolean UI_ClanName_HandleKey(int flags, float *special, int key) {\n  if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) {\n    int i;\n    i = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_teamName\"));\n\t\tif (uiInfo.teamList[i].cinematic >= 0) {\n\t\t  trap_CIN_StopCinematic(uiInfo.teamList[i].cinematic);\n\t\t\tuiInfo.teamList[i].cinematic = -1;\n\t\t}\n\t\tif (key == K_MOUSE2) {\n\t    i--;\n\t\t} else {\n\t    i++;\n\t\t}\n    if (i >= uiInfo.teamCount) {\n      i = 0;\n    } else if (i < 0) {\n\t\t\ti = uiInfo.teamCount - 1;\n\t\t}\n  \ttrap_Cvar_Set( \"ui_teamName\", uiInfo.teamList[i].teamName);\n\tUI_HeadCountByTeam();\n\tUI_FeederSelection(FEEDER_HEADS, 0);\n\tupdateModel = qtrue;\n    return qtrue;\n  }\n  return qfalse;\n}\n\nstatic qboolean UI_GameType_HandleKey(int flags, float *special, int key, qboolean resetMap) {\n  if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) {\n\t\tint oldCount = UI_MapCountByGameType(qtrue);\n\n\t\t// hard coded mess here\n\t\tif (key == K_MOUSE2) {\n\t\t\tui_gameType.integer--;\n\t\t\tif (ui_gameType.integer == 2) {\n\t\t\t\tui_gameType.integer = 1;\n\t\t\t} else if (ui_gameType.integer < 2) {\n\t\t\t\tui_gameType.integer = uiInfo.numGameTypes - 1;\n\t\t\t}\n\t\t} else {\n\t\t\tui_gameType.integer++;\n\t\t\tif (ui_gameType.integer >= uiInfo.numGameTypes) {\n\t\t\t\tui_gameType.integer = 1;\n\t\t\t} else if (ui_gameType.integer == 2) {\n\t\t\t\tui_gameType.integer = 3;\n\t\t\t}\n\t\t}\n    \n\t\tif (uiInfo.gameTypes[ui_gameType.integer].gtEnum == GT_TOURNAMENT) {\n\t\t\ttrap_Cvar_Set(\"ui_Q3Model\", \"1\");\n\t\t} else {\n\t\t\ttrap_Cvar_Set(\"ui_Q3Model\", \"0\");\n\t\t}\n\n\t\ttrap_Cvar_Set(\"ui_gameType\", va(\"%d\", ui_gameType.integer));\n\t\tUI_SetCapFragLimits(qtrue);\n\t\tUI_LoadBestScores(uiInfo.mapList[ui_currentMap.integer].mapLoadName, uiInfo.gameTypes[ui_gameType.integer].gtEnum);\n\t\tif (resetMap && oldCount != UI_MapCountByGameType(qtrue)) {\n\t  \ttrap_Cvar_Set( \"ui_currentMap\", \"0\");\n\t\t\tMenu_SetFeederSelection(NULL, FEEDER_MAPS, 0, NULL);\n\t\t}\n    return qtrue;\n  }\n  return qfalse;\n}\n\nstatic qboolean UI_NetGameType_HandleKey(int flags, float *special, int key) {\n  if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) {\n\n\t\tif (key == K_MOUSE2) {\n\t\t\tui_netGameType.integer--;\n\t\t} else {\n\t\t\tui_netGameType.integer++;\n\t\t}\n\n    if (ui_netGameType.integer < 0) {\n      ui_netGameType.integer = uiInfo.numGameTypes - 1;\n\t\t} else if (ui_netGameType.integer >= uiInfo.numGameTypes) {\n      ui_netGameType.integer = 0;\n    } \n\n  \ttrap_Cvar_Set( \"ui_netGameType\", va(\"%d\", ui_netGameType.integer));\n  \ttrap_Cvar_Set( \"ui_actualnetGameType\", va(\"%d\", uiInfo.gameTypes[ui_netGameType.integer].gtEnum));\n  \ttrap_Cvar_Set( \"ui_currentNetMap\", \"0\");\n\t\tUI_MapCountByGameType(qfalse);\n\t\tMenu_SetFeederSelection(NULL, FEEDER_ALLMAPS, 0, NULL);\n    return qtrue;\n  }\n  return qfalse;\n}\n\nstatic qboolean UI_JoinGameType_HandleKey(int flags, float *special, int key) {\n\tif (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) {\n\n\t\tif (key == K_MOUSE2) {\n\t\t\tui_joinGameType.integer--;\n\t\t} else {\n\t\t\tui_joinGameType.integer++;\n\t\t}\n\n\t\tif (ui_joinGameType.integer < 0) {\n\t\t\tui_joinGameType.integer = uiInfo.numJoinGameTypes - 1;\n\t\t} else if (ui_joinGameType.integer >= uiInfo.numJoinGameTypes) {\n\t\t\tui_joinGameType.integer = 0;\n\t\t}\n\n\t\ttrap_Cvar_Set( \"ui_joinGameType\", va(\"%d\", ui_joinGameType.integer));\n\t\tUI_BuildServerDisplayList(qtrue);\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n\n\nstatic qboolean UI_Skill_HandleKey(int flags, float *special, int key) {\n  if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) {\n  \tint i = trap_Cvar_VariableValue( \"g_spSkill\" );\n\n\t\tif (key == K_MOUSE2) {\n\t    i--;\n\t\t} else {\n\t    i++;\n\t\t}\n\n    if (i < 1) {\n\t\t\ti = numSkillLevels;\n\t\t} else if (i > numSkillLevels) {\n      i = 1;\n    }\n\n    trap_Cvar_Set(\"g_spSkill\", va(\"%i\", i));\n    return qtrue;\n  }\n  return qfalse;\n}\n\nstatic qboolean UI_TeamName_HandleKey(int flags, float *special, int key, qboolean blue) {\n  if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) {\n    int i;\n    i = UI_TeamIndexFromName(UI_Cvar_VariableString((blue) ? \"ui_blueTeam\" : \"ui_redTeam\"));\n\n\t\tif (key == K_MOUSE2) {\n\t    i--;\n\t\t} else {\n\t    i++;\n\t\t}\n\n    if (i >= uiInfo.teamCount) {\n      i = 0;\n    } else if (i < 0) {\n\t\t\ti = uiInfo.teamCount - 1;\n\t\t}\n\n    trap_Cvar_Set( (blue) ? \"ui_blueTeam\" : \"ui_redTeam\", uiInfo.teamList[i].teamName);\n\n    return qtrue;\n  }\n  return qfalse;\n}\n\nstatic qboolean UI_TeamMember_HandleKey(int flags, float *special, int key, qboolean blue, int num) {\n  if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) {\n\t\t// 0 - None\n\t\t// 1 - Human\n\t\t// 2..NumCharacters - Bot\n\t\tchar *cvar = va(blue ? \"ui_blueteam%i\" : \"ui_redteam%i\", num);\n\t\tint value = trap_Cvar_VariableValue(cvar);\n\n\t\tif (key == K_MOUSE2) {\n\t\t\tvalue--;\n\t\t} else {\n\t\t\tvalue++;\n\t\t}\n\n\t\tif (ui_actualNetGameType.integer >= GT_TEAM) {\n\t\t\tif (value >= uiInfo.characterCount + 2) {\n\t\t\t\tvalue = 0;\n\t\t\t} else if (value < 0) {\n\t\t\t\tvalue = uiInfo.characterCount + 2 - 1;\n\t\t\t}\n\t\t} else {\n\t\t\tif (value >= UI_GetNumBots() + 2) {\n\t\t\t\tvalue = 0;\n\t\t\t} else if (value < 0) {\n\t\t\t\tvalue = UI_GetNumBots() + 2 - 1;\n\t\t\t}\n\t\t}\n\n\t\ttrap_Cvar_Set(cvar, va(\"%i\", value));\n    return qtrue;\n  }\n  return qfalse;\n}\n\nstatic qboolean UI_NetSource_HandleKey(int flags, float *special, int key) {\n  if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) {\n\t\t\n\t\tif (key == K_MOUSE2) {\n\t\t\tui_netSource.integer--;\n\t\t\tif (ui_netSource.integer == AS_MPLAYER)\n\t\t\t\tui_netSource.integer--;\n\t\t} else {\n\t\t\tui_netSource.integer++;\n\t\t\tif (ui_netSource.integer == AS_MPLAYER)\n\t\t\t\tui_netSource.integer++;\n\t\t}\n    \n\t\tif (ui_netSource.integer >= numNetSources) {\n      ui_netSource.integer = 0;\n    } else if (ui_netSource.integer < 0) {\n      ui_netSource.integer = numNetSources - 1;\n\t\t}\n\n\t\tUI_BuildServerDisplayList(qtrue);\n\t\tif (ui_netSource.integer != AS_GLOBAL) {\n\t\t\tUI_StartServerRefresh(qtrue);\n\t\t}\n  \ttrap_Cvar_Set( \"ui_netSource\", va(\"%d\", ui_netSource.integer));\n    return qtrue;\n  }\n  return qfalse;\n}\n\nstatic qboolean UI_NetFilter_HandleKey(int flags, float *special, int key) {\n  if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) {\n\n\t\tif (key == K_MOUSE2) {\n\t\t\tui_serverFilterType.integer--;\n\t\t} else {\n\t\t\tui_serverFilterType.integer++;\n\t\t}\n\n    if (ui_serverFilterType.integer >= numServerFilters) {\n      ui_serverFilterType.integer = 0;\n    } else if (ui_serverFilterType.integer < 0) {\n      ui_serverFilterType.integer = numServerFilters - 1;\n\t\t}\n\t\tUI_BuildServerDisplayList(qtrue);\n    return qtrue;\n  }\n  return qfalse;\n}\n\nstatic qboolean UI_OpponentName_HandleKey(int flags, float *special, int key) {\n  if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) {\n\t\tif (key == K_MOUSE2) {\n\t\t\tUI_PriorOpponent();\n\t\t} else {\n\t\t\tUI_NextOpponent();\n\t\t}\n    return qtrue;\n  }\n  return qfalse;\n}\n\nstatic qboolean UI_BotName_HandleKey(int flags, float *special, int key) {\n  if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) {\n\t\tint game = trap_Cvar_VariableValue(\"g_gametype\");\n\t\tint value = uiInfo.botIndex;\n\n\t\tif (key == K_MOUSE2) {\n\t\t\tvalue--;\n\t\t} else {\n\t\t\tvalue++;\n\t\t}\n\n\t\tif (game >= GT_TEAM) {\n\t\t\tif (value >= uiInfo.characterCount + 2) {\n\t\t\t\tvalue = 0;\n\t\t\t} else if (value < 0) {\n\t\t\t\tvalue = uiInfo.characterCount + 2 - 1;\n\t\t\t}\n\t\t} else {\n\t\t\tif (value >= UI_GetNumBots() + 2) {\n\t\t\t\tvalue = 0;\n\t\t\t} else if (value < 0) {\n\t\t\t\tvalue = UI_GetNumBots() + 2 - 1;\n\t\t\t}\n\t\t}\n\t\tuiInfo.botIndex = value;\n    return qtrue;\n  }\n  return qfalse;\n}\n\nstatic qboolean UI_BotSkill_HandleKey(int flags, float *special, int key) {\n  if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) {\n\t\tif (key == K_MOUSE2) {\n\t\t\tuiInfo.skillIndex--;\n\t\t} else {\n\t\t\tuiInfo.skillIndex++;\n\t\t}\n\t\tif (uiInfo.skillIndex >= numSkillLevels) {\n\t\t\tuiInfo.skillIndex = 0;\n\t\t} else if (uiInfo.skillIndex < 0) {\n\t\t\tuiInfo.skillIndex = numSkillLevels-1;\n\t\t}\n    return qtrue;\n  }\n\treturn qfalse;\n}\n\nstatic qboolean UI_RedBlue_HandleKey(int flags, float *special, int key) {\n  if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) {\n\t\tuiInfo.redBlue ^= 1;\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\nstatic qboolean UI_Crosshair_HandleKey(int flags, float *special, int key) {\n  if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) {\n\t\tif (key == K_MOUSE2) {\n\t\t\tuiInfo.currentCrosshair--;\n\t\t} else {\n\t\t\tuiInfo.currentCrosshair++;\n\t\t}\n\n\t\tif (uiInfo.currentCrosshair >= NUM_CROSSHAIRS) {\n\t\t\tuiInfo.currentCrosshair = 0;\n\t\t} else if (uiInfo.currentCrosshair < 0) {\n\t\t\tuiInfo.currentCrosshair = NUM_CROSSHAIRS - 1;\n\t\t}\n\t\ttrap_Cvar_Set(\"cg_drawCrosshair\", va(\"%d\", uiInfo.currentCrosshair)); \n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n\n\nstatic qboolean UI_SelectedPlayer_HandleKey(int flags, float *special, int key) {\n  if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) {\n\t\tint selected;\n\n\t\tUI_BuildPlayerList();\n\t\tif (!uiInfo.teamLeader) {\n\t\t\treturn qfalse;\n\t\t}\n\t\tselected = trap_Cvar_VariableValue(\"cg_selectedPlayer\");\n\t\t\n\t\tif (key == K_MOUSE2) {\n\t\t\tselected--;\n\t\t} else {\n\t\t\tselected++;\n\t\t}\n\n\t\tif (selected > uiInfo.myTeamCount) {\n\t\t\tselected = 0;\n\t\t} else if (selected < 0) {\n\t\t\tselected = uiInfo.myTeamCount;\n\t\t}\n\n\t\tif (selected == uiInfo.myTeamCount) {\n\t\t \ttrap_Cvar_Set( \"cg_selectedPlayerName\", \"Everyone\");\n\t\t} else {\n\t\t \ttrap_Cvar_Set( \"cg_selectedPlayerName\", uiInfo.teamNames[selected]);\n\t\t}\n\t \ttrap_Cvar_Set( \"cg_selectedPlayer\", va(\"%d\", selected));\n\t}\n\treturn qfalse;\n}\n\n\nstatic qboolean UI_OwnerDrawHandleKey(int ownerDraw, int flags, float *special, int key) {\n  switch (ownerDraw) {\n    case UI_HANDICAP:\n      return UI_Handicap_HandleKey(flags, special, key);\n      break;\n    case UI_EFFECTS:\n      return UI_Effects_HandleKey(flags, special, key);\n      break;\n    case UI_CLANNAME:\n      return UI_ClanName_HandleKey(flags, special, key);\n      break;\n    case UI_GAMETYPE:\n      return UI_GameType_HandleKey(flags, special, key, qtrue);\n      break;\n    case UI_NETGAMETYPE:\n      return UI_NetGameType_HandleKey(flags, special, key);\n      break;\n    case UI_JOINGAMETYPE:\n      return UI_JoinGameType_HandleKey(flags, special, key);\n      break;\n    case UI_SKILL:\n      return UI_Skill_HandleKey(flags, special, key);\n      break;\n    case UI_BLUETEAMNAME:\n      return UI_TeamName_HandleKey(flags, special, key, qtrue);\n      break;\n    case UI_REDTEAMNAME:\n      return UI_TeamName_HandleKey(flags, special, key, qfalse);\n      break;\n    case UI_BLUETEAM1:\n\t\tcase UI_BLUETEAM2:\n\t\tcase UI_BLUETEAM3:\n\t\tcase UI_BLUETEAM4:\n\t\tcase UI_BLUETEAM5:\n      UI_TeamMember_HandleKey(flags, special, key, qtrue, ownerDraw - UI_BLUETEAM1 + 1);\n      break;\n    case UI_REDTEAM1:\n\t\tcase UI_REDTEAM2:\n\t\tcase UI_REDTEAM3:\n\t\tcase UI_REDTEAM4:\n\t\tcase UI_REDTEAM5:\n      UI_TeamMember_HandleKey(flags, special, key, qfalse, ownerDraw - UI_REDTEAM1 + 1);\n      break;\n\t\tcase UI_NETSOURCE:\n      UI_NetSource_HandleKey(flags, special, key);\n\t\t\tbreak;\n\t\tcase UI_NETFILTER:\n      UI_NetFilter_HandleKey(flags, special, key);\n\t\t\tbreak;\n\t\tcase UI_OPPONENT_NAME:\n\t\t\tUI_OpponentName_HandleKey(flags, special, key);\n\t\t\tbreak;\n\t\tcase UI_BOTNAME:\n\t\t\treturn UI_BotName_HandleKey(flags, special, key);\n\t\t\tbreak;\n\t\tcase UI_BOTSKILL:\n\t\t\treturn UI_BotSkill_HandleKey(flags, special, key);\n\t\t\tbreak;\n\t\tcase UI_REDBLUE:\n\t\t\tUI_RedBlue_HandleKey(flags, special, key);\n\t\t\tbreak;\n\t\tcase UI_CROSSHAIR:\n\t\t\tUI_Crosshair_HandleKey(flags, special, key);\n\t\t\tbreak;\n\t\tcase UI_SELECTEDPLAYER:\n\t\t\tUI_SelectedPlayer_HandleKey(flags, special, key);\n\t\t\tbreak;\n    default:\n      break;\n  }\n\n  return qfalse;\n}\n\n\nstatic float UI_GetValue(int ownerDraw) {\n  return 0;\n}\n\n/*\n=================\nUI_ServersQsortCompare\n=================\n*/\nstatic int QDECL UI_ServersQsortCompare( const void *arg1, const void *arg2 ) {\n\treturn trap_LAN_CompareServers( ui_netSource.integer, uiInfo.serverStatus.sortKey, uiInfo.serverStatus.sortDir, *(int*)arg1, *(int*)arg2);\n}\n\n\n/*\n=================\nUI_ServersSort\n=================\n*/\nvoid UI_ServersSort(int column, qboolean force) {\n\n\tif ( !force ) {\n\t\tif ( uiInfo.serverStatus.sortKey == column ) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\tuiInfo.serverStatus.sortKey = column;\n\tqsort( &uiInfo.serverStatus.displayServers[0], uiInfo.serverStatus.numDisplayServers, sizeof(int), UI_ServersQsortCompare);\n}\n\n/*\nstatic void UI_StartSinglePlayer() {\n\tint i,j, k, skill;\n\tchar buff[1024];\n\ti = trap_Cvar_VariableValue( \"ui_currentTier\" );\n  if (i < 0 || i >= tierCount) {\n    i = 0;\n  }\n\tj = trap_Cvar_VariableValue(\"ui_currentMap\");\n\tif (j < 0 || j > MAPS_PER_TIER) {\n\t\tj = 0;\n\t}\n\n \ttrap_Cvar_SetValue( \"singleplayer\", 1 );\n \ttrap_Cvar_SetValue( \"g_gametype\", Com_Clamp( 0, 7, tierList[i].gameTypes[j] ) );\n\ttrap_Cmd_ExecuteText( EXEC_APPEND, va( \"wait ; wait ; map %s\\n\", tierList[i].maps[j] ) );\n\tskill = trap_Cvar_VariableValue( \"g_spSkill\" );\n\n\tif (j == MAPS_PER_TIER-1) {\n\t\tk = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_opponentName\"));\n\t\tCom_sprintf( buff, sizeof(buff), \"wait ; addbot %s %i %s 250 %s\\n\", UI_AIFromName(teamList[k].teamMembers[0]), skill, \"\", teamList[k].teamMembers[0]);\n\t} else {\n\t\tk = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_opponentName\"));\n\t\tfor (i = 0; i < PLAYERS_PER_TEAM; i++) {\n\t\t\tCom_sprintf( buff, sizeof(buff), \"wait ; addbot %s %i %s 250 %s\\n\", UI_AIFromName(teamList[k].teamMembers[i]), skill, \"Blue\", teamList[k].teamMembers[i]);\n\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, buff );\n\t\t}\n\n\t\tk = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_teamName\"));\n\t\tfor (i = 1; i < PLAYERS_PER_TEAM; i++) {\n\t\t\tCom_sprintf( buff, sizeof(buff), \"wait ; addbot %s %i %s 250 %s\\n\", UI_AIFromName(teamList[k].teamMembers[i]), skill, \"Red\", teamList[k].teamMembers[i]);\n\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, buff );\n\t\t}\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"wait 5; team Red\\n\" );\n\t}\n\t\n\n}\n*/\n\n/*\n===============\nUI_LoadMods\n===============\n*/\nstatic void UI_LoadMods() {\n\tint\t\tnumdirs;\n\tchar\tdirlist[2048];\n\tchar\t*dirptr;\n  char  *descptr;\n\tint\t\ti;\n\tint\t\tdirlen;\n\n\tuiInfo.modCount = 0;\n\tnumdirs = trap_FS_GetFileList( \"$modlist\", \"\", dirlist, sizeof(dirlist) );\n\tdirptr  = dirlist;\n\tfor( i = 0; i < numdirs; i++ ) {\n\t\tdirlen = strlen( dirptr ) + 1;\n    descptr = dirptr + dirlen;\n\t\tuiInfo.modList[uiInfo.modCount].modName = String_Alloc(dirptr);\n\t\tuiInfo.modList[uiInfo.modCount].modDescr = String_Alloc(descptr);\n    dirptr += dirlen + strlen(descptr) + 1;\n\t\tuiInfo.modCount++;\n\t\tif (uiInfo.modCount >= MAX_MODS) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n}\n\n\n/*\n===============\nUI_LoadTeams\n===============\n*/\nstatic void UI_LoadTeams() {\n\tchar\tteamList[4096];\n\tchar\t*teamName;\n\tint\t\ti, len, count;\n\n\tcount = trap_FS_GetFileList( \"\", \"team\", teamList, 4096 );\n\n\tif (count) {\n\t\tteamName = teamList;\n\t\tfor ( i = 0; i < count; i++ ) {\n\t\t\tlen = strlen( teamName );\n\t\t\tUI_ParseTeamInfo(teamName);\n\t\t\tteamName += len + 1;\n\t\t}\n\t}\n\n}\n\n\n/*\n===============\nUI_LoadMovies\n===============\n*/\nstatic void UI_LoadMovies() {\n\tchar\tmovielist[4096];\n\tchar\t*moviename;\n\tint\t\ti, len;\n\n\tuiInfo.movieCount = trap_FS_GetFileList( \"video\", \"roq\", movielist, 4096 );\n\n\tif (uiInfo.movieCount) {\n\t\tif (uiInfo.movieCount > MAX_MOVIES) {\n\t\t\tuiInfo.movieCount = MAX_MOVIES;\n\t\t}\n\t\tmoviename = movielist;\n\t\tfor ( i = 0; i < uiInfo.movieCount; i++ ) {\n\t\t\tlen = strlen( moviename );\n\t\t\tif (!Q_stricmp(moviename +  len - 4,\".roq\")) {\n\t\t\t\tmoviename[len-4] = '\\0';\n\t\t\t}\n\t\t\tQ_strupr(moviename);\n\t\t\tuiInfo.movieList[i] = String_Alloc(moviename);\n\t\t\tmoviename += len + 1;\n\t\t}\n\t}\n\n}\n\n\n\n/*\n===============\nUI_LoadDemos\n===============\n*/\nstatic void UI_LoadDemos() {\n\tchar\tdemolist[4096];\n\tchar demoExt[32];\n\tchar\t*demoname;\n\tint\t\ti, len;\n\n\tCom_sprintf(demoExt, sizeof(demoExt), \"dm_%d\", (int)trap_Cvar_VariableValue(\"protocol\"));\n\n\tuiInfo.demoCount = trap_FS_GetFileList( \"demos\", demoExt, demolist, 4096 );\n\n\tCom_sprintf(demoExt, sizeof(demoExt), \".dm_%d\", (int)trap_Cvar_VariableValue(\"protocol\"));\n\n\tif (uiInfo.demoCount) {\n\t\tif (uiInfo.demoCount > MAX_DEMOS) {\n\t\t\tuiInfo.demoCount = MAX_DEMOS;\n\t\t}\n\t\tdemoname = demolist;\n\t\tfor ( i = 0; i < uiInfo.demoCount; i++ ) {\n\t\t\tlen = strlen( demoname );\n\t\t\tif (!Q_stricmp(demoname +  len - strlen(demoExt), demoExt)) {\n\t\t\t\tdemoname[len-strlen(demoExt)] = '\\0';\n\t\t\t}\n\t\t\tQ_strupr(demoname);\n\t\t\tuiInfo.demoList[i] = String_Alloc(demoname);\n\t\t\tdemoname += len + 1;\n\t\t}\n\t}\n\n}\n\n\nstatic qboolean UI_SetNextMap(int actual, int index) {\n\tint i;\n\tfor (i = actual + 1; i < uiInfo.mapCount; i++) {\n\t\tif (uiInfo.mapList[i].active) {\n\t\t\tMenu_SetFeederSelection(NULL, FEEDER_MAPS, index + 1, \"skirmish\");\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n\nstatic void UI_StartSkirmish(qboolean next) {\n\tint i, k, g, delay, temp;\n\tfloat skill;\n\tchar buff[MAX_STRING_CHARS];\n\n\tif (next) {\n\t\tint actual;\n\t\tint index = trap_Cvar_VariableValue(\"ui_mapIndex\");\n\t \tUI_MapCountByGameType(qtrue);\n\t\tUI_SelectedMap(index, &actual);\n\t\tif (UI_SetNextMap(actual, index)) {\n\t\t} else {\n\t\t\tUI_GameType_HandleKey(0, 0, K_MOUSE1, qfalse);\n\t\t\tUI_MapCountByGameType(qtrue);\n\t\t\tMenu_SetFeederSelection(NULL, FEEDER_MAPS, 0, \"skirmish\");\n\t\t}\n\t}\n\n\tg = uiInfo.gameTypes[ui_gameType.integer].gtEnum;\n\ttrap_Cvar_SetValue( \"g_gametype\", g );\n\ttrap_Cmd_ExecuteText( EXEC_APPEND, va( \"wait ; wait ; map %s\\n\", uiInfo.mapList[ui_currentMap.integer].mapLoadName) );\n\tskill = trap_Cvar_VariableValue( \"g_spSkill\" );\n\ttrap_Cvar_Set(\"ui_scoreMap\", uiInfo.mapList[ui_currentMap.integer].mapName);\n\n\tk = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_opponentName\"));\n\n\ttrap_Cvar_Set(\"ui_singlePlayerActive\", \"1\");\n\n\t// set up sp overrides, will be replaced on postgame\n\ttemp = trap_Cvar_VariableValue( \"capturelimit\" );\n\ttrap_Cvar_Set(\"ui_saveCaptureLimit\", va(\"%i\", temp));\n\ttemp = trap_Cvar_VariableValue( \"fraglimit\" );\n\ttrap_Cvar_Set(\"ui_saveFragLimit\", va(\"%i\", temp));\n\n\tUI_SetCapFragLimits(qfalse);\n\n\ttemp = trap_Cvar_VariableValue( \"cg_drawTimer\" );\n\ttrap_Cvar_Set(\"ui_drawTimer\", va(\"%i\", temp));\n\ttemp = trap_Cvar_VariableValue( \"g_doWarmup\" );\n\ttrap_Cvar_Set(\"ui_doWarmup\", va(\"%i\", temp));\n\ttemp = trap_Cvar_VariableValue( \"g_friendlyFire\" );\n\ttrap_Cvar_Set(\"ui_friendlyFire\", va(\"%i\", temp));\n\ttemp = trap_Cvar_VariableValue( \"sv_maxClients\" );\n\ttrap_Cvar_Set(\"ui_maxClients\", va(\"%i\", temp));\n\ttemp = trap_Cvar_VariableValue( \"g_warmup\" );\n\ttrap_Cvar_Set(\"ui_Warmup\", va(\"%i\", temp));\n\ttemp = trap_Cvar_VariableValue( \"sv_pure\" );\n\ttrap_Cvar_Set(\"ui_pure\", va(\"%i\", temp));\n\n\ttrap_Cvar_Set(\"cg_cameraOrbit\", \"0\");\n\ttrap_Cvar_Set(\"cg_thirdPerson\", \"0\");\n\ttrap_Cvar_Set(\"cg_drawTimer\", \"1\");\n\ttrap_Cvar_Set(\"g_doWarmup\", \"1\");\n\ttrap_Cvar_Set(\"g_warmup\", \"15\");\n\ttrap_Cvar_Set(\"sv_pure\", \"0\");\n\ttrap_Cvar_Set(\"g_friendlyFire\", \"0\");\n\ttrap_Cvar_Set(\"g_redTeam\", UI_Cvar_VariableString(\"ui_teamName\"));\n\ttrap_Cvar_Set(\"g_blueTeam\", UI_Cvar_VariableString(\"ui_opponentName\"));\n\n\tif (trap_Cvar_VariableValue(\"ui_recordSPDemo\")) {\n\t\tCom_sprintf(buff, MAX_STRING_CHARS, \"%s_%i\", uiInfo.mapList[ui_currentMap.integer].mapLoadName, g);\n\t\ttrap_Cvar_Set(\"ui_recordSPDemoName\", buff);\n\t}\n\n\tdelay = 500;\n\n\tif (g == GT_TOURNAMENT) {\n\t\ttrap_Cvar_Set(\"sv_maxClients\", \"2\");\n\t\tCom_sprintf( buff, sizeof(buff), \"wait ; addbot %s %f \"\", %i \\n\", uiInfo.mapList[ui_currentMap.integer].opponentName, skill, delay);\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, buff );\n\t} else {\n\t\ttemp = uiInfo.mapList[ui_currentMap.integer].teamMembers * 2;\n\t\ttrap_Cvar_Set(\"sv_maxClients\", va(\"%d\", temp));\n\t\tfor (i =0; i < uiInfo.mapList[ui_currentMap.integer].teamMembers; i++) {\n\t\t\tCom_sprintf( buff, sizeof(buff), \"addbot %s %f %s %i %s\\n\", UI_AIFromName(uiInfo.teamList[k].teamMembers[i]), skill, (g == GT_FFA) ? \"\" : \"Blue\", delay, uiInfo.teamList[k].teamMembers[i]);\n\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, buff );\n\t\t\tdelay += 500;\n\t\t}\n\t\tk = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_teamName\"));\n\t\tfor (i =0; i < uiInfo.mapList[ui_currentMap.integer].teamMembers-1; i++) {\n\t\t\tCom_sprintf( buff, sizeof(buff), \"addbot %s %f %s %i %s\\n\", UI_AIFromName(uiInfo.teamList[k].teamMembers[i]), skill, (g == GT_FFA) ? \"\" : \"Red\", delay, uiInfo.teamList[k].teamMembers[i]);\n\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, buff );\n\t\t\tdelay += 500;\n\t\t}\n\t}\n\tif (g >= GT_TEAM ) {\n\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"wait 5; team Red\\n\" );\n\t}\n}\n\nstatic void UI_Update(const char *name) {\n\tint\tval = trap_Cvar_VariableValue(name);\n\n \tif (Q_stricmp(name, \"ui_SetName\") == 0) {\n\t\ttrap_Cvar_Set( \"name\", UI_Cvar_VariableString(\"ui_Name\"));\n \t} else if (Q_stricmp(name, \"ui_setRate\") == 0) {\n\t\tfloat rate = trap_Cvar_VariableValue(\"rate\");\n\t\tif (rate >= 5000) {\n\t\t\ttrap_Cvar_Set(\"cl_maxpackets\", \"30\");\n\t\t\ttrap_Cvar_Set(\"cl_packetdup\", \"1\");\n\t\t} else if (rate >= 4000) {\n\t\t\ttrap_Cvar_Set(\"cl_maxpackets\", \"15\");\n\t\t\ttrap_Cvar_Set(\"cl_packetdup\", \"2\");\t\t// favor less prediction errors when there's packet loss\n\t\t} else {\n\t\t\ttrap_Cvar_Set(\"cl_maxpackets\", \"15\");\n\t\t\ttrap_Cvar_Set(\"cl_packetdup\", \"1\");\t\t// favor lower bandwidth\n\t\t}\n \t} else if (Q_stricmp(name, \"ui_GetName\") == 0) {\n\t\ttrap_Cvar_Set( \"ui_Name\", UI_Cvar_VariableString(\"name\"));\n \t} else if (Q_stricmp(name, \"r_colorbits\") == 0) {\n\t\tswitch (val) {\n\t\t\tcase 0:\n\t\t\t\ttrap_Cvar_SetValue( \"r_depthbits\", 0 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_stencilbits\", 0 );\n\t\t\tbreak;\n\t\t\tcase 16:\n\t\t\t\ttrap_Cvar_SetValue( \"r_depthbits\", 16 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_stencilbits\", 0 );\n\t\t\tbreak;\n\t\t\tcase 32:\n\t\t\t\ttrap_Cvar_SetValue( \"r_depthbits\", 24 );\n\t\t\tbreak;\n\t\t}\n\t} else if (Q_stricmp(name, \"r_lodbias\") == 0) {\n\t\tswitch (val) {\n\t\t\tcase 0:\n\t\t\t\ttrap_Cvar_SetValue( \"r_subdivisions\", 4 );\n\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\ttrap_Cvar_SetValue( \"r_subdivisions\", 12 );\n\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\ttrap_Cvar_SetValue( \"r_subdivisions\", 20 );\n\t\t\tbreak;\n\t\t}\n\t} else if (Q_stricmp(name, \"ui_glCustom\") == 0) {\n\t\tswitch (val) {\n\t\t\tcase 0:\t// high quality\n\t\t\t\ttrap_Cvar_SetValue( \"r_fullScreen\", 1 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_subdivisions\", 4 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_vertexlight\", 0 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_lodbias\", 0 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_colorbits\", 32 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_depthbits\", 24 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_picmip\", 0 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_mode\", 4 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_texturebits\", 32 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_fastSky\", 0 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_inGameVideo\", 1 );\n\t\t\t\ttrap_Cvar_SetValue( \"cg_shadows\", 1 );\n\t\t\t\ttrap_Cvar_SetValue( \"cg_brassTime\", 2500 );\n\t\t\t\ttrap_Cvar_Set( \"r_texturemode\", \"GL_LINEAR_MIPMAP_LINEAR\" );\n\t\t\tbreak;\n\t\t\tcase 1: // normal \n\t\t\t\ttrap_Cvar_SetValue( \"r_fullScreen\", 1 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_subdivisions\", 12 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_vertexlight\", 0 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_lodbias\", 0 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_colorbits\", 0 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_depthbits\", 24 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_picmip\", 1 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_mode\", 3 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_texturebits\", 0 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_fastSky\", 0 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_inGameVideo\", 1 );\n\t\t\t\ttrap_Cvar_SetValue( \"cg_brassTime\", 2500 );\n\t\t\t\ttrap_Cvar_Set( \"r_texturemode\", \"GL_LINEAR_MIPMAP_LINEAR\" );\n\t\t\t\ttrap_Cvar_SetValue( \"cg_shadows\", 0 );\n\t\t\tbreak;\n\t\t\tcase 2: // fast\n\t\t\t\ttrap_Cvar_SetValue( \"r_fullScreen\", 1 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_subdivisions\", 8 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_vertexlight\", 0 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_lodbias\", 1 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_colorbits\", 0 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_depthbits\", 0 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_picmip\", 1 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_mode\", 3 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_texturebits\", 0 );\n\t\t\t\ttrap_Cvar_SetValue( \"cg_shadows\", 0 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_fastSky\", 1 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_inGameVideo\", 0 );\n\t\t\t\ttrap_Cvar_SetValue( \"cg_brassTime\", 0 );\n\t\t\t\ttrap_Cvar_Set( \"r_texturemode\", \"GL_LINEAR_MIPMAP_NEAREST\" );\n\t\t\tbreak;\n\t\t\tcase 3: // fastest\n\t\t\t\ttrap_Cvar_SetValue( \"r_fullScreen\", 1 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_subdivisions\", 20 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_vertexlight\", 1 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_lodbias\", 2 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_colorbits\", 16 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_depthbits\", 16 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_mode\", 3 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_picmip\", 2 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_texturebits\", 16 );\n\t\t\t\ttrap_Cvar_SetValue( \"cg_shadows\", 0 );\n\t\t\t\ttrap_Cvar_SetValue( \"cg_brassTime\", 0 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_fastSky\", 1 );\n\t\t\t\ttrap_Cvar_SetValue( \"r_inGameVideo\", 0 );\n\t\t\t\ttrap_Cvar_Set( \"r_texturemode\", \"GL_LINEAR_MIPMAP_NEAREST\" );\n\t\t\tbreak;\n\t\t}\n\t} else if (Q_stricmp(name, \"ui_mousePitch\") == 0) {\n\t\tif (val == 0) {\n\t\t\ttrap_Cvar_SetValue( \"m_pitch\", 0.022f );\n\t\t} else {\n\t\t\ttrap_Cvar_SetValue( \"m_pitch\", -0.022f );\n\t\t}\n\t}\n}\n\nstatic void UI_RunMenuScript(char **args) {\n\tconst char *name, *name2;\n\tchar buff[1024];\n\n\tif (String_Parse(args, &name)) {\n\t\tif (Q_stricmp(name, \"StartServer\") == 0) {\n\t\t\tint i, clients, oldclients;\n\t\t\tfloat skill;\n\t\t\ttrap_Cvar_Set(\"cg_thirdPerson\", \"0\");\n\t\t\ttrap_Cvar_Set(\"cg_cameraOrbit\", \"0\");\n\t\t\ttrap_Cvar_Set(\"ui_singlePlayerActive\", \"0\");\n\t\t\ttrap_Cvar_SetValue( \"dedicated\", Com_Clamp( 0, 2, ui_dedicated.integer ) );\n\t\t\ttrap_Cvar_SetValue( \"g_gametype\", Com_Clamp( 0, 8, uiInfo.gameTypes[ui_netGameType.integer].gtEnum ) );\n\t\t\ttrap_Cvar_Set(\"g_redTeam\", UI_Cvar_VariableString(\"ui_teamName\"));\n\t\t\ttrap_Cvar_Set(\"g_blueTeam\", UI_Cvar_VariableString(\"ui_opponentName\"));\n\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va( \"wait ; wait ; map %s\\n\", uiInfo.mapList[ui_currentNetMap.integer].mapLoadName ) );\n\t\t\tskill = trap_Cvar_VariableValue( \"g_spSkill\" );\n\t\t\t// set max clients based on spots\n\t\t\toldclients = trap_Cvar_VariableValue( \"sv_maxClients\" );\n\t\t\tclients = 0;\n\t\t\tfor (i = 0; i < PLAYERS_PER_TEAM; i++) {\n\t\t\t\tint bot = trap_Cvar_VariableValue( va(\"ui_blueteam%i\", i+1));\n\t\t\t\tif (bot >= 0) {\n\t\t\t\t\tclients++;\n\t\t\t\t}\n\t\t\t\tbot = trap_Cvar_VariableValue( va(\"ui_redteam%i\", i+1));\n\t\t\t\tif (bot >= 0) {\n\t\t\t\t\tclients++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (clients == 0) {\n\t\t\t\tclients = 8;\n\t\t\t}\n\t\t\t\n\t\t\tif (oldclients > clients) {\n\t\t\t\tclients = oldclients;\n\t\t\t}\n\n\t\t\ttrap_Cvar_Set(\"sv_maxClients\", va(\"%d\",clients));\n\n\t\t\tfor (i = 0; i < PLAYERS_PER_TEAM; i++) {\n\t\t\t\tint bot = trap_Cvar_VariableValue( va(\"ui_blueteam%i\", i+1));\n\t\t\t\tif (bot > 1) {\n\t\t\t\t\tif (ui_actualNetGameType.integer >= GT_TEAM) {\n\t\t\t\t\t\tCom_sprintf( buff, sizeof(buff), \"addbot %s %f %s\\n\", uiInfo.characterList[bot-2].name, skill, \"Blue\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tCom_sprintf( buff, sizeof(buff), \"addbot %s %f \\n\", UI_GetBotNameByNumber(bot-2), skill);\n\t\t\t\t\t}\n\t\t\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, buff );\n\t\t\t\t}\n\t\t\t\tbot = trap_Cvar_VariableValue( va(\"ui_redteam%i\", i+1));\n\t\t\t\tif (bot > 1) {\n\t\t\t\t\tif (ui_actualNetGameType.integer >= GT_TEAM) {\n\t\t\t\t\t\tCom_sprintf( buff, sizeof(buff), \"addbot %s %f %s\\n\", uiInfo.characterList[bot-2].name, skill, \"Red\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tCom_sprintf( buff, sizeof(buff), \"addbot %s %f \\n\", UI_GetBotNameByNumber(bot-2), skill);\n\t\t\t\t\t}\n\t\t\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, buff );\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (Q_stricmp(name, \"updateSPMenu\") == 0) {\n\t\t\tUI_SetCapFragLimits(qtrue);\n\t\t\tUI_MapCountByGameType(qtrue);\n\t\t\tui_mapIndex.integer = UI_GetIndexFromSelection(ui_currentMap.integer);\n\t\t\ttrap_Cvar_Set(\"ui_mapIndex\", va(\"%d\", ui_mapIndex.integer));\n\t\t\tMenu_SetFeederSelection(NULL, FEEDER_MAPS, ui_mapIndex.integer, \"skirmish\");\n\t\t\tUI_GameType_HandleKey(0, 0, K_MOUSE1, qfalse);\n\t\t\tUI_GameType_HandleKey(0, 0, K_MOUSE2, qfalse);\n\t\t} else if (Q_stricmp(name, \"resetDefaults\") == 0) {\n\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"exec default.cfg\\n\");\n\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"cvar_restart\\n\");\n\t\t\tControls_SetDefaults();\n\t\t\ttrap_Cvar_Set(\"com_introPlayed\", \"1\" );\n\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"vid_restart\\n\" );\n\t\t} else if (Q_stricmp(name, \"getCDKey\") == 0) {\n\t\t\tchar out[17];\n\t\t\ttrap_GetCDKey(buff, 17);\n\t\t\ttrap_Cvar_Set(\"cdkey1\", \"\");\n\t\t\ttrap_Cvar_Set(\"cdkey2\", \"\");\n\t\t\ttrap_Cvar_Set(\"cdkey3\", \"\");\n\t\t\ttrap_Cvar_Set(\"cdkey4\", \"\");\n\t\t\tif (strlen(buff) == CDKEY_LEN) {\n\t\t\t\tQ_strncpyz(out, buff, 5);\n\t\t\t\ttrap_Cvar_Set(\"cdkey1\", out);\n\t\t\t\tQ_strncpyz(out, buff + 4, 5);\n\t\t\t\ttrap_Cvar_Set(\"cdkey2\", out);\n\t\t\t\tQ_strncpyz(out, buff + 8, 5);\n\t\t\t\ttrap_Cvar_Set(\"cdkey3\", out);\n\t\t\t\tQ_strncpyz(out, buff + 12, 5);\n\t\t\t\ttrap_Cvar_Set(\"cdkey4\", out);\n\t\t\t}\n\n\t\t} else if (Q_stricmp(name, \"verifyCDKey\") == 0) {\n\t\t\tbuff[0] = '\\0';\n\t\t\tQ_strcat(buff, 1024, UI_Cvar_VariableString(\"cdkey1\")); \n\t\t\tQ_strcat(buff, 1024, UI_Cvar_VariableString(\"cdkey2\")); \n\t\t\tQ_strcat(buff, 1024, UI_Cvar_VariableString(\"cdkey3\")); \n\t\t\tQ_strcat(buff, 1024, UI_Cvar_VariableString(\"cdkey4\")); \n\t\t\ttrap_Cvar_Set(\"cdkey\", buff);\n\t\t\tif (trap_VerifyCDKey(buff, UI_Cvar_VariableString(\"cdkeychecksum\"))) {\n\t\t\t\ttrap_Cvar_Set(\"ui_cdkeyvalid\", \"CD Key Appears to be valid.\");\n\t\t\t\ttrap_SetCDKey(buff);\n\t\t\t} else {\n\t\t\t\ttrap_Cvar_Set(\"ui_cdkeyvalid\", \"CD Key does not appear to be valid.\");\n\t\t\t}\n\t\t} else if (Q_stricmp(name, \"loadArenas\") == 0) {\n\t\t\tUI_LoadArenas();\n\t\t\tUI_MapCountByGameType(qfalse);\n\t\t\tMenu_SetFeederSelection(NULL, FEEDER_ALLMAPS, 0, \"createserver\");\n\t\t} else if (Q_stricmp(name, \"saveControls\") == 0) {\n\t\t\tControls_SetConfig(qtrue);\n\t\t} else if (Q_stricmp(name, \"loadControls\") == 0) {\n\t\t\tControls_GetConfig();\n\t\t} else if (Q_stricmp(name, \"clearError\") == 0) {\n\t\t\ttrap_Cvar_Set(\"com_errorMessage\", \"\");\n\t\t} else if (Q_stricmp(name, \"loadGameInfo\") == 0) {\n#ifdef PRE_RELEASE_TADEMO\n\t\t\tUI_ParseGameInfo(\"demogameinfo.txt\");\n#else\n\t\t\tUI_ParseGameInfo(\"gameinfo.txt\");\n#endif\n\t\t\tUI_LoadBestScores(uiInfo.mapList[ui_currentMap.integer].mapLoadName, uiInfo.gameTypes[ui_gameType.integer].gtEnum);\n\t\t} else if (Q_stricmp(name, \"resetScores\") == 0) {\n\t\t\tUI_ClearScores();\n\t\t} else if (Q_stricmp(name, \"RefreshServers\") == 0) {\n\t\t\tUI_StartServerRefresh(qtrue);\n\t\t\tUI_BuildServerDisplayList(qtrue);\n\t\t} else if (Q_stricmp(name, \"RefreshFilter\") == 0) {\n\t\t\tUI_StartServerRefresh(qfalse);\n\t\t\tUI_BuildServerDisplayList(qtrue);\n\t\t} else if (Q_stricmp(name, \"RunSPDemo\") == 0) {\n\t\t\tif (uiInfo.demoAvailable) {\n\t\t\t  trap_Cmd_ExecuteText( EXEC_APPEND, va(\"demo %s_%i\\n\", uiInfo.mapList[ui_currentMap.integer].mapLoadName, uiInfo.gameTypes[ui_gameType.integer].gtEnum));\n\t\t\t}\n\t\t} else if (Q_stricmp(name, \"LoadDemos\") == 0) {\n\t\t\tUI_LoadDemos();\n\t\t} else if (Q_stricmp(name, \"LoadMovies\") == 0) {\n\t\t\tUI_LoadMovies();\n\t\t} else if (Q_stricmp(name, \"LoadMods\") == 0) {\n\t\t\tUI_LoadMods();\n\t\t} else if (Q_stricmp(name, \"playMovie\") == 0) {\n\t\t\tif (uiInfo.previewMovie >= 0) {\n\t\t\t  trap_CIN_StopCinematic(uiInfo.previewMovie);\n\t\t\t}\n\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va(\"cinematic %s.roq 2\\n\", uiInfo.movieList[uiInfo.movieIndex]));\n\t\t} else if (Q_stricmp(name, \"RunMod\") == 0) {\n\t\t\ttrap_Cvar_Set( \"fs_game\", uiInfo.modList[uiInfo.modIndex].modName);\n\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"vid_restart;\" );\n\t\t} else if (Q_stricmp(name, \"RunDemo\") == 0) {\n\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va(\"demo %s\\n\", uiInfo.demoList[uiInfo.demoIndex]));\n\t\t} else if (Q_stricmp(name, \"Quake3\") == 0) {\n\t\t\ttrap_Cvar_Set( \"fs_game\", \"\");\n\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"vid_restart;\" );\n\t\t} else if (Q_stricmp(name, \"closeJoin\") == 0) {\n\t\t\tif (uiInfo.serverStatus.refreshActive) {\n\t\t\t\tUI_StopServerRefresh();\n\t\t\t\tuiInfo.serverStatus.nextDisplayRefresh = 0;\n\t\t\t\tuiInfo.nextServerStatusRefresh = 0;\n\t\t\t\tuiInfo.nextFindPlayerRefresh = 0;\n\t\t\t\tUI_BuildServerDisplayList(qtrue);\n\t\t\t} else {\n\t\t\t\tMenus_CloseByName(\"joinserver\");\n\t\t\t\tMenus_OpenByName(\"main\");\n\t\t\t}\n\t\t} else if (Q_stricmp(name, \"StopRefresh\") == 0) {\n\t\t\tUI_StopServerRefresh();\n\t\t\tuiInfo.serverStatus.nextDisplayRefresh = 0;\n\t\t\tuiInfo.nextServerStatusRefresh = 0;\n\t\t\tuiInfo.nextFindPlayerRefresh = 0;\n\t\t} else if (Q_stricmp(name, \"UpdateFilter\") == 0) {\n\t\t\tif (ui_netSource.integer == AS_LOCAL) {\n\t\t\t\tUI_StartServerRefresh(qtrue);\n\t\t\t}\n\t\t\tUI_BuildServerDisplayList(qtrue);\n\t\t\tUI_FeederSelection(FEEDER_SERVERS, 0);\n\t\t} else if (Q_stricmp(name, \"ServerStatus\") == 0) {\n\t\t\ttrap_LAN_GetServerAddressString(ui_netSource.integer, uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], uiInfo.serverStatusAddress, sizeof(uiInfo.serverStatusAddress));\n\t\t\tUI_BuildServerStatus(qtrue);\n\t\t} else if (Q_stricmp(name, \"FoundPlayerServerStatus\") == 0) {\n\t\t\tQ_strncpyz(uiInfo.serverStatusAddress, uiInfo.foundPlayerServerAddresses[uiInfo.currentFoundPlayerServer], sizeof(uiInfo.serverStatusAddress));\n\t\t\tUI_BuildServerStatus(qtrue);\n\t\t\tMenu_SetFeederSelection(NULL, FEEDER_FINDPLAYER, 0, NULL);\n\t\t} else if (Q_stricmp(name, \"FindPlayer\") == 0) {\n\t\t\tUI_BuildFindPlayerList(qtrue);\n\t\t\t// clear the displayed server status info\n\t\t\tuiInfo.serverStatusInfo.numLines = 0;\n\t\t\tMenu_SetFeederSelection(NULL, FEEDER_FINDPLAYER, 0, NULL);\n\t\t} else if (Q_stricmp(name, \"JoinServer\") == 0) {\n\t\t\ttrap_Cvar_Set(\"cg_thirdPerson\", \"0\");\n\t\t\ttrap_Cvar_Set(\"cg_cameraOrbit\", \"0\");\n\t\t\ttrap_Cvar_Set(\"ui_singlePlayerActive\", \"0\");\n\t\t\tif (uiInfo.serverStatus.currentServer >= 0 && uiInfo.serverStatus.currentServer < uiInfo.serverStatus.numDisplayServers) {\n\t\t\t\ttrap_LAN_GetServerAddressString(ui_netSource.integer, uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], buff, 1024);\n\t\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va( \"connect %s\\n\", buff ) );\n\t\t\t}\n\t\t} else if (Q_stricmp(name, \"FoundPlayerJoinServer\") == 0) {\n\t\t\ttrap_Cvar_Set(\"ui_singlePlayerActive\", \"0\");\n\t\t\tif (uiInfo.currentFoundPlayerServer >= 0 && uiInfo.currentFoundPlayerServer < uiInfo.numFoundPlayerServers) {\n\t\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va( \"connect %s\\n\", uiInfo.foundPlayerServerAddresses[uiInfo.currentFoundPlayerServer] ) );\n\t\t\t}\n\t\t} else if (Q_stricmp(name, \"Quit\") == 0) {\n\t\t\ttrap_Cvar_Set(\"ui_singlePlayerActive\", \"0\");\n\t\t\ttrap_Cmd_ExecuteText( EXEC_NOW, \"quit\");\n\t\t} else if (Q_stricmp(name, \"Controls\") == 0) {\n\t\t  trap_Cvar_Set( \"cl_paused\", \"1\" );\n\t\t\ttrap_Key_SetCatcher( KEYCATCH_UI );\n\t\t\tMenus_CloseAll();\n\t\t\tMenus_ActivateByName(\"setup_menu2\");\n\t\t} else if (Q_stricmp(name, \"Leave\") == 0) {\n\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"disconnect\\n\" );\n\t\t\ttrap_Key_SetCatcher( KEYCATCH_UI );\n\t\t\tMenus_CloseAll();\n\t\t\tMenus_ActivateByName(\"main\");\n\t\t} else if (Q_stricmp(name, \"ServerSort\") == 0) {\n\t\t\tint sortColumn;\n\t\t\tif (Int_Parse(args, &sortColumn)) {\n\t\t\t\t// if same column we're already sorting on then flip the direction\n\t\t\t\tif (sortColumn == uiInfo.serverStatus.sortKey) {\n\t\t\t\t\tuiInfo.serverStatus.sortDir = !uiInfo.serverStatus.sortDir;\n\t\t\t\t}\n\t\t\t\t// make sure we sort again\n\t\t\t\tUI_ServersSort(sortColumn, qtrue);\n\t\t\t}\n\t\t} else if (Q_stricmp(name, \"nextSkirmish\") == 0) {\n\t\t\tUI_StartSkirmish(qtrue);\n\t\t} else if (Q_stricmp(name, \"SkirmishStart\") == 0) {\n\t\t\tUI_StartSkirmish(qfalse);\n\t\t} else if (Q_stricmp(name, \"closeingame\") == 0) {\n\t\t\ttrap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI );\n\t\t\ttrap_Key_ClearStates();\n\t\t\ttrap_Cvar_Set( \"cl_paused\", \"0\" );\n\t\t\tMenus_CloseAll();\n\t\t} else if (Q_stricmp(name, \"voteMap\") == 0) {\n\t\t\tif (ui_currentNetMap.integer >=0 && ui_currentNetMap.integer < uiInfo.mapCount) {\n\t\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va(\"callvote map %s\\n\",uiInfo.mapList[ui_currentNetMap.integer].mapLoadName) );\n\t\t\t}\n\t\t} else if (Q_stricmp(name, \"voteKick\") == 0) {\n\t\t\tif (uiInfo.playerIndex >= 0 && uiInfo.playerIndex < uiInfo.playerCount) {\n\t\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va(\"callvote kick %s\\n\",uiInfo.playerNames[uiInfo.playerIndex]) );\n\t\t\t}\n\t\t} else if (Q_stricmp(name, \"voteGame\") == 0) {\n\t\t\tif (ui_netGameType.integer >= 0 && ui_netGameType.integer < uiInfo.numGameTypes) {\n\t\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va(\"callvote g_gametype %i\\n\",uiInfo.gameTypes[ui_netGameType.integer].gtEnum) );\n\t\t\t}\n\t\t} else if (Q_stricmp(name, \"voteLeader\") == 0) {\n\t\t\tif (uiInfo.teamIndex >= 0 && uiInfo.teamIndex < uiInfo.myTeamCount) {\n\t\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va(\"callteamvote leader %s\\n\",uiInfo.teamNames[uiInfo.teamIndex]) );\n\t\t\t}\n\t\t} else if (Q_stricmp(name, \"addBot\") == 0) {\n\t\t\tif (trap_Cvar_VariableValue(\"g_gametype\") >= GT_TEAM) {\n\t\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va(\"addbot %s %i %s\\n\", uiInfo.characterList[uiInfo.botIndex].name, uiInfo.skillIndex+1, (uiInfo.redBlue == 0) ? \"Red\" : \"Blue\") );\n\t\t\t} else {\n\t\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va(\"addbot %s %i %s\\n\", UI_GetBotNameByNumber(uiInfo.botIndex), uiInfo.skillIndex+1, (uiInfo.redBlue == 0) ? \"Red\" : \"Blue\") );\n\t\t\t}\n\t\t} else if (Q_stricmp(name, \"addFavorite\") == 0) {\n\t\t\tif (ui_netSource.integer != AS_FAVORITES) {\n\t\t\t\tchar name[MAX_NAME_LENGTH];\n\t\t\t\tchar addr[MAX_NAME_LENGTH];\n\t\t\t\tint res;\n\n\t\t\t\ttrap_LAN_GetServerInfo(ui_netSource.integer, uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], buff, MAX_STRING_CHARS);\n\t\t\t\tname[0] = addr[0] = '\\0';\n\t\t\t\tQ_strncpyz(name, \tInfo_ValueForKey(buff, \"hostname\"), MAX_NAME_LENGTH);\n\t\t\t\tQ_strncpyz(addr, \tInfo_ValueForKey(buff, \"addr\"), MAX_NAME_LENGTH);\n\t\t\t\tif (strlen(name) > 0 && strlen(addr) > 0) {\n\t\t\t\t\tres = trap_LAN_AddServer(AS_FAVORITES, name, addr);\n\t\t\t\t\tif (res == 0) {\n\t\t\t\t\t\t// server already in the list\n\t\t\t\t\t\tCom_Printf(\"Favorite already in list\\n\");\n\t\t\t\t\t}\n\t\t\t\t\telse if (res == -1) {\n\t\t\t\t\t\t// list full\n\t\t\t\t\t\tCom_Printf(\"Favorite list full\\n\");\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// successfully added\n\t\t\t\t\t\tCom_Printf(\"Added favorite server %s\\n\", addr);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (Q_stricmp(name, \"deleteFavorite\") == 0) {\n\t\t\tif (ui_netSource.integer == AS_FAVORITES) {\n\t\t\t\tchar addr[MAX_NAME_LENGTH];\n\t\t\t\ttrap_LAN_GetServerInfo(ui_netSource.integer, uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], buff, MAX_STRING_CHARS);\n\t\t\t\taddr[0] = '\\0';\n\t\t\t\tQ_strncpyz(addr, \tInfo_ValueForKey(buff, \"addr\"), MAX_NAME_LENGTH);\n\t\t\t\tif (strlen(addr) > 0) {\n\t\t\t\t\ttrap_LAN_RemoveServer(AS_FAVORITES, addr);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (Q_stricmp(name, \"createFavorite\") == 0) {\n\t\t\tif (ui_netSource.integer == AS_FAVORITES) {\n\t\t\t\tchar name[MAX_NAME_LENGTH];\n\t\t\t\tchar addr[MAX_NAME_LENGTH];\n\t\t\t\tint res;\n\n\t\t\t\tname[0] = addr[0] = '\\0';\n\t\t\t\tQ_strncpyz(name, \tUI_Cvar_VariableString(\"ui_favoriteName\"), MAX_NAME_LENGTH);\n\t\t\t\tQ_strncpyz(addr, \tUI_Cvar_VariableString(\"ui_favoriteAddress\"), MAX_NAME_LENGTH);\n\t\t\t\tif (strlen(name) > 0 && strlen(addr) > 0) {\n\t\t\t\t\tres = trap_LAN_AddServer(AS_FAVORITES, name, addr);\n\t\t\t\t\tif (res == 0) {\n\t\t\t\t\t\t// server already in the list\n\t\t\t\t\t\tCom_Printf(\"Favorite already in list\\n\");\n\t\t\t\t\t}\n\t\t\t\t\telse if (res == -1) {\n\t\t\t\t\t\t// list full\n\t\t\t\t\t\tCom_Printf(\"Favorite list full\\n\");\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// successfully added\n\t\t\t\t\t\tCom_Printf(\"Added favorite server %s\\n\", addr);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (Q_stricmp(name, \"orders\") == 0) {\n\t\t\tconst char *orders;\n\t\t\tif (String_Parse(args, &orders)) {\n\t\t\t\tint selectedPlayer = trap_Cvar_VariableValue(\"cg_selectedPlayer\");\n\t\t\t\tif (selectedPlayer < uiInfo.myTeamCount) {\n\t\t\t\t\tstrcpy(buff, orders);\n\t\t\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va(buff, uiInfo.teamClientNums[selectedPlayer]) );\n\t\t\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"\\n\" );\n\t\t\t\t} else {\n\t\t\t\t\tint i;\n\t\t\t\t\tfor (i = 0; i < uiInfo.myTeamCount; i++) {\n\t\t\t\t\t\tif (Q_stricmp(UI_Cvar_VariableString(\"name\"), uiInfo.teamNames[i]) == 0) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstrcpy(buff, orders);\n\t\t\t\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va(buff, uiInfo.teamNames[i]) );\n\t\t\t\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"\\n\" );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttrap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI );\n\t\t\t\ttrap_Key_ClearStates();\n\t\t\t\ttrap_Cvar_Set( \"cl_paused\", \"0\" );\n\t\t\t\tMenus_CloseAll();\n\t\t\t}\n\t\t} else if (Q_stricmp(name, \"voiceOrdersTeam\") == 0) {\n\t\t\tconst char *orders;\n\t\t\tif (String_Parse(args, &orders)) {\n\t\t\t\tint selectedPlayer = trap_Cvar_VariableValue(\"cg_selectedPlayer\");\n\t\t\t\tif (selectedPlayer == uiInfo.myTeamCount) {\n\t\t\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, orders );\n\t\t\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"\\n\" );\n\t\t\t\t}\n\t\t\t\ttrap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI );\n\t\t\t\ttrap_Key_ClearStates();\n\t\t\t\ttrap_Cvar_Set( \"cl_paused\", \"0\" );\n\t\t\t\tMenus_CloseAll();\n\t\t\t}\n\t\t} else if (Q_stricmp(name, \"voiceOrders\") == 0) {\n\t\t\tconst char *orders;\n\t\t\tif (String_Parse(args, &orders)) {\n\t\t\t\tint selectedPlayer = trap_Cvar_VariableValue(\"cg_selectedPlayer\");\n\t\t\t\tif (selectedPlayer < uiInfo.myTeamCount) {\n\t\t\t\t\tstrcpy(buff, orders);\n\t\t\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, va(buff, uiInfo.teamClientNums[selectedPlayer]) );\n\t\t\t\t\ttrap_Cmd_ExecuteText( EXEC_APPEND, \"\\n\" );\n\t\t\t\t}\n\t\t\t\ttrap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI );\n\t\t\t\ttrap_Key_ClearStates();\n\t\t\t\ttrap_Cvar_Set( \"cl_paused\", \"0\" );\n\t\t\t\tMenus_CloseAll();\n\t\t\t}\n\t\t} else if (Q_stricmp(name, \"glCustom\") == 0) {\n\t\t\ttrap_Cvar_Set(\"ui_glCustom\", \"4\");\n\t\t} else if (Q_stricmp(name, \"update\") == 0) {\n\t\t\tif (String_Parse(args, &name2)) {\n\t\t\t\tUI_Update(name2);\n\t\t\t}\n\t\t} else if (Q_stricmp(name, \"setPbClStatus\") == 0) {\n\t\t\tint stat;\n\t\t\tif ( Int_Parse( args, &stat ) )\n\t\t\t\ttrap_SetPbClStatus( stat );\n\t\t}\n\t\telse {\n\t\t\tCom_Printf(\"unknown UI script %s\\n\", name);\n\t\t}\n\t}\n}\n\nstatic void UI_GetTeamColor(vec4_t *color) {\n}\n\n/*\n==================\nUI_MapCountByGameType\n==================\n*/\nstatic int UI_MapCountByGameType(qboolean singlePlayer) {\n\tint i, c, game;\n\tc = 0;\n\tgame = singlePlayer ? uiInfo.gameTypes[ui_gameType.integer].gtEnum : uiInfo.gameTypes[ui_netGameType.integer].gtEnum;\n\tif (game == GT_SINGLE_PLAYER) {\n\t\tgame++;\n\t} \n\tif (game == GT_TEAM) {\n\t\tgame = GT_FFA;\n\t}\n\n\tfor (i = 0; i < uiInfo.mapCount; i++) {\n\t\tuiInfo.mapList[i].active = qfalse;\n\t\tif ( uiInfo.mapList[i].typeBits & (1 << game)) {\n\t\t\tif (singlePlayer) {\n\t\t\t\tif (!(uiInfo.mapList[i].typeBits & (1 << GT_SINGLE_PLAYER))) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tc++;\n\t\t\tuiInfo.mapList[i].active = qtrue;\n\t\t}\n\t}\n\treturn c;\n}\n\nqboolean UI_hasSkinForBase(const char *base, const char *team) {\n\tchar\ttest[1024];\n\t\n\tCom_sprintf( test, sizeof( test ), \"models/players/%s/%s/lower_default.skin\", base, team );\n\n\tif (trap_FS_FOpenFile(test, 0, FS_READ)) {\n\t\treturn qtrue;\n\t}\n\tCom_sprintf( test, sizeof( test ), \"models/players/characters/%s/%s/lower_default.skin\", base, team );\n\n\tif (trap_FS_FOpenFile(test, 0, FS_READ)) {\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nUI_MapCountByTeam\n==================\n*/\nstatic int UI_HeadCountByTeam() {\n\tstatic int init = 0;\n\tint i, j, k, c, tIndex;\n\t\n\tc = 0;\n\tif (!init) {\n\t\tfor (i = 0; i < uiInfo.characterCount; i++) {\n\t\t\tuiInfo.characterList[i].reference = 0;\n\t\t\tfor (j = 0; j < uiInfo.teamCount; j++) {\n\t\t\t  if (UI_hasSkinForBase(uiInfo.characterList[i].base, uiInfo.teamList[j].teamName)) {\n\t\t\t\t\tuiInfo.characterList[i].reference |= (1<<j);\n\t\t\t  }\n\t\t\t}\n\t\t}\n\t\tinit = 1;\n\t}\n\n\ttIndex = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_teamName\"));\n\n\t// do names\n\tfor (i = 0; i < uiInfo.characterCount; i++) {\n\t\tuiInfo.characterList[i].active = qfalse;\n\t\tfor(j = 0; j < TEAM_MEMBERS; j++) {\n\t\t\tif (uiInfo.teamList[tIndex].teamMembers[j] != NULL) {\n\t\t\t\tif (uiInfo.characterList[i].reference&(1<<tIndex)) {// && Q_stricmp(uiInfo.teamList[tIndex].teamMembers[j], uiInfo.characterList[i].name)==0) {\n\t\t\t\t\tuiInfo.characterList[i].active = qtrue;\n\t\t\t\t\tc++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// and then aliases\n\tfor(j = 0; j < TEAM_MEMBERS; j++) {\n\t\tfor(k = 0; k < uiInfo.aliasCount; k++) {\n\t\t\tif (uiInfo.aliasList[k].name != NULL) {\n\t\t\t\tif (Q_stricmp(uiInfo.teamList[tIndex].teamMembers[j], uiInfo.aliasList[k].name)==0) {\n\t\t\t\t\tfor (i = 0; i < uiInfo.characterCount; i++) {\n\t\t\t\t\t\tif (uiInfo.characterList[i].headImage != -1 && uiInfo.characterList[i].reference&(1<<tIndex) && Q_stricmp(uiInfo.aliasList[k].ai, uiInfo.characterList[i].name)==0) {\n\t\t\t\t\t\t\tif (uiInfo.characterList[i].active == qfalse) {\n\t\t\t\t\t\t\t\tuiInfo.characterList[i].active = qtrue;\n\t\t\t\t\t\t\t\tc++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn c;\n}\n\n/*\n==================\nUI_InsertServerIntoDisplayList\n==================\n*/\nstatic void UI_InsertServerIntoDisplayList(int num, int position) {\n\tint i;\n\n\tif (position < 0 || position > uiInfo.serverStatus.numDisplayServers ) {\n\t\treturn;\n\t}\n\t//\n\tuiInfo.serverStatus.numDisplayServers++;\n\tfor (i = uiInfo.serverStatus.numDisplayServers; i > position; i--) {\n\t\tuiInfo.serverStatus.displayServers[i] = uiInfo.serverStatus.displayServers[i-1];\n\t}\n\tuiInfo.serverStatus.displayServers[position] = num;\n}\n\n/*\n==================\nUI_RemoveServerFromDisplayList\n==================\n*/\nstatic void UI_RemoveServerFromDisplayList(int num) {\n\tint i, j;\n\n\tfor (i = 0; i < uiInfo.serverStatus.numDisplayServers; i++) {\n\t\tif (uiInfo.serverStatus.displayServers[i] == num) {\n\t\t\tuiInfo.serverStatus.numDisplayServers--;\n\t\t\tfor (j = i; j < uiInfo.serverStatus.numDisplayServers; j++) {\n\t\t\t\tuiInfo.serverStatus.displayServers[j] = uiInfo.serverStatus.displayServers[j+1];\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t}\n}\n\n/*\n==================\nUI_BinaryServerInsertion\n==================\n*/\nstatic void UI_BinaryServerInsertion(int num) {\n\tint mid, offset, res, len;\n\n\t// use binary search to insert server\n\tlen = uiInfo.serverStatus.numDisplayServers;\n\tmid = len;\n\toffset = 0;\n\tres = 0;\n\twhile(mid > 0) {\n\t\tmid = len >> 1;\n\t\t//\n\t\tres = trap_LAN_CompareServers( ui_netSource.integer, uiInfo.serverStatus.sortKey,\n\t\t\t\t\tuiInfo.serverStatus.sortDir, num, uiInfo.serverStatus.displayServers[offset+mid]);\n\t\t// if equal\n\t\tif (res == 0) {\n\t\t\tUI_InsertServerIntoDisplayList(num, offset+mid);\n\t\t\treturn;\n\t\t}\n\t\t// if larger\n\t\telse if (res == 1) {\n\t\t\toffset += mid;\n\t\t\tlen -= mid;\n\t\t}\n\t\t// if smaller\n\t\telse {\n\t\t\tlen -= mid;\n\t\t}\n\t}\n\tif (res == 1) {\n\t\toffset++;\n\t}\n\tUI_InsertServerIntoDisplayList(num, offset);\n}\n\n/*\n==================\nUI_BuildServerDisplayList\n==================\n*/\nstatic void UI_BuildServerDisplayList(qboolean force) {\n\tint i, count, clients, maxClients, ping, game, len, visible;\n\tchar info[MAX_STRING_CHARS];\n//\tqboolean startRefresh = qtrue; TTimo: unused\n\tstatic int numinvisible;\n\n\tif (!(force || uiInfo.uiDC.realTime > uiInfo.serverStatus.nextDisplayRefresh)) {\n\t\treturn;\n\t}\n\t// if we shouldn't reset\n\tif ( force == 2 ) {\n\t\tforce = 0;\n\t}\n\n\t// do motd updates here too\n\ttrap_Cvar_VariableStringBuffer( \"cl_motdString\", uiInfo.serverStatus.motd, sizeof(uiInfo.serverStatus.motd) );\n\tlen = strlen(uiInfo.serverStatus.motd);\n\tif (len == 0) {\n\t\tstrcpy(uiInfo.serverStatus.motd, \"Welcome to Team Arena!\");\n\t\tlen = strlen(uiInfo.serverStatus.motd);\n\t} \n\tif (len != uiInfo.serverStatus.motdLen) {\n\t\tuiInfo.serverStatus.motdLen = len;\n\t\tuiInfo.serverStatus.motdWidth = -1;\n\t} \n\n\tif (force) {\n\t\tnuminvisible = 0;\n\t\t// clear number of displayed servers\n\t\tuiInfo.serverStatus.numDisplayServers = 0;\n\t\tuiInfo.serverStatus.numPlayersOnServers = 0;\n\t\t// set list box index to zero\n\t\tMenu_SetFeederSelection(NULL, FEEDER_SERVERS, 0, NULL);\n\t\t// mark all servers as visible so we store ping updates for them\n\t\ttrap_LAN_MarkServerVisible(ui_netSource.integer, -1, qtrue);\n\t}\n\n\t// get the server count (comes from the master)\n\tcount = trap_LAN_GetServerCount(ui_netSource.integer);\n\tif (count == -1 || (ui_netSource.integer == AS_LOCAL && count == 0) ) {\n\t\t// still waiting on a response from the master\n\t\tuiInfo.serverStatus.numDisplayServers = 0;\n\t\tuiInfo.serverStatus.numPlayersOnServers = 0;\n\t\tuiInfo.serverStatus.nextDisplayRefresh = uiInfo.uiDC.realTime + 500;\n\t\treturn;\n\t}\n\n\tvisible = qfalse;\n\tfor (i = 0; i < count; i++) {\n\t\t// if we already got info for this server\n\t\tif (!trap_LAN_ServerIsVisible(ui_netSource.integer, i)) {\n\t\t\tcontinue;\n\t\t}\n\t\tvisible = qtrue;\n\t\t// get the ping for this server\n\t\tping = trap_LAN_GetServerPing(ui_netSource.integer, i);\n\t\tif (ping > 0 || ui_netSource.integer == AS_FAVORITES) {\n\n\t\t\ttrap_LAN_GetServerInfo(ui_netSource.integer, i, info, MAX_STRING_CHARS);\n\n\t\t\tclients = atoi(Info_ValueForKey(info, \"clients\"));\n\t\t\tuiInfo.serverStatus.numPlayersOnServers += clients;\n\n\t\t\tif (ui_browserShowEmpty.integer == 0) {\n\t\t\t\tif (clients == 0) {\n\t\t\t\t\ttrap_LAN_MarkServerVisible(ui_netSource.integer, i, qfalse);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (ui_browserShowFull.integer == 0) {\n\t\t\t\tmaxClients = atoi(Info_ValueForKey(info, \"sv_maxclients\"));\n\t\t\t\tif (clients == maxClients) {\n\t\t\t\t\ttrap_LAN_MarkServerVisible(ui_netSource.integer, i, qfalse);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (uiInfo.joinGameTypes[ui_joinGameType.integer].gtEnum != -1) {\n\t\t\t\tgame = atoi(Info_ValueForKey(info, \"gametype\"));\n\t\t\t\tif (game != uiInfo.joinGameTypes[ui_joinGameType.integer].gtEnum) {\n\t\t\t\t\ttrap_LAN_MarkServerVisible(ui_netSource.integer, i, qfalse);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\t\n\t\t\tif (ui_serverFilterType.integer > 0) {\n\t\t\t\tif (Q_stricmp(Info_ValueForKey(info, \"game\"), serverFilters[ui_serverFilterType.integer].basedir) != 0) {\n\t\t\t\t\ttrap_LAN_MarkServerVisible(ui_netSource.integer, i, qfalse);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// make sure we never add a favorite server twice\n\t\t\tif (ui_netSource.integer == AS_FAVORITES) {\n\t\t\t\tUI_RemoveServerFromDisplayList(i);\n\t\t\t}\n\t\t\t// insert the server into the list\n\t\t\tUI_BinaryServerInsertion(i);\n\t\t\t// done with this server\n\t\t\tif (ping > 0) {\n\t\t\t\ttrap_LAN_MarkServerVisible(ui_netSource.integer, i, qfalse);\n\t\t\t\tnuminvisible++;\n\t\t\t}\n\t\t}\n\t}\n\n\tuiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime;\n\n\t// if there were no servers visible for ping updates\n\tif (!visible) {\n//\t\tUI_StopServerRefresh();\n//\t\tuiInfo.serverStatus.nextDisplayRefresh = 0;\n\t}\n}\n\ntypedef struct\n{\n\tchar *name, *altName;\n} serverStatusCvar_t;\n\nserverStatusCvar_t serverStatusCvars[] = {\n\t{\"sv_hostname\", \"Name\"},\n\t{\"Address\", \"\"},\n\t{\"gamename\", \"Game name\"},\n\t{\"g_gametype\", \"Game type\"},\n\t{\"mapname\", \"Map\"},\n\t{\"version\", \"\"},\n\t{\"protocol\", \"\"},\n\t{\"timelimit\", \"\"},\n\t{\"fraglimit\", \"\"},\n\t{NULL, NULL}\n};\n\n/*\n==================\nUI_SortServerStatusInfo\n==================\n*/\nstatic void UI_SortServerStatusInfo( serverStatusInfo_t *info ) {\n\tint i, j, index;\n\tchar *tmp1, *tmp2;\n\n\t// FIXME: if \"gamename\" == \"baseq3\" or \"missionpack\" then\n\t// replace the gametype number by FFA, CTF etc.\n\t//\n\tindex = 0;\n\tfor (i = 0; serverStatusCvars[i].name; i++) {\n\t\tfor (j = 0; j < info->numLines; j++) {\n\t\t\tif ( !info->lines[j][1] || info->lines[j][1][0] ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( !Q_stricmp(serverStatusCvars[i].name, info->lines[j][0]) ) {\n\t\t\t\t// swap lines\n\t\t\t\ttmp1 = info->lines[index][0];\n\t\t\t\ttmp2 = info->lines[index][3];\n\t\t\t\tinfo->lines[index][0] = info->lines[j][0];\n\t\t\t\tinfo->lines[index][3] = info->lines[j][3];\n\t\t\t\tinfo->lines[j][0] = tmp1;\n\t\t\t\tinfo->lines[j][3] = tmp2;\n\t\t\t\t//\n\t\t\t\tif ( strlen(serverStatusCvars[i].altName) ) {\n\t\t\t\t\tinfo->lines[index][0] = serverStatusCvars[i].altName;\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n==================\nUI_GetServerStatusInfo\n==================\n*/\nstatic int UI_GetServerStatusInfo( const char *serverAddress, serverStatusInfo_t *info ) {\n\tchar *p, *score, *ping, *name;\n\tint i, len;\n\n\tif (!info) {\n\t\ttrap_LAN_ServerStatus( serverAddress, NULL, 0);\n\t\treturn qfalse;\n\t}\n\tmemset(info, 0, sizeof(*info));\n\tif ( trap_LAN_ServerStatus( serverAddress, info->text, sizeof(info->text)) ) {\n\t\tQ_strncpyz(info->address, serverAddress, sizeof(info->address));\n\t\tp = info->text;\n\t\tinfo->numLines = 0;\n\t\tinfo->lines[info->numLines][0] = \"Address\";\n\t\tinfo->lines[info->numLines][1] = \"\";\n\t\tinfo->lines[info->numLines][2] = \"\";\n\t\tinfo->lines[info->numLines][3] = info->address;\n\t\tinfo->numLines++;\n\t\t// get the cvars\n\t\twhile (p && *p) {\n\t\t\tp = strchr(p, '\\\\');\n\t\t\tif (!p) break;\n\t\t\t*p++ = '\\0';\n\t\t\tif (*p == '\\\\')\n\t\t\t\tbreak;\n\t\t\tinfo->lines[info->numLines][0] = p;\n\t\t\tinfo->lines[info->numLines][1] = \"\";\n\t\t\tinfo->lines[info->numLines][2] = \"\";\n\t\t\tp = strchr(p, '\\\\');\n\t\t\tif (!p) break;\n\t\t\t*p++ = '\\0';\n\t\t\tinfo->lines[info->numLines][3] = p;\n\n\t\t\tinfo->numLines++;\n\t\t\tif (info->numLines >= MAX_SERVERSTATUS_LINES)\n\t\t\t\tbreak;\n\t\t}\n\t\t// get the player list\n\t\tif (info->numLines < MAX_SERVERSTATUS_LINES-3) {\n\t\t\t// empty line\n\t\t\tinfo->lines[info->numLines][0] = \"\";\n\t\t\tinfo->lines[info->numLines][1] = \"\";\n\t\t\tinfo->lines[info->numLines][2] = \"\";\n\t\t\tinfo->lines[info->numLines][3] = \"\";\n\t\t\tinfo->numLines++;\n\t\t\t// header\n\t\t\tinfo->lines[info->numLines][0] = \"num\";\n\t\t\tinfo->lines[info->numLines][1] = \"score\";\n\t\t\tinfo->lines[info->numLines][2] = \"ping\";\n\t\t\tinfo->lines[info->numLines][3] = \"name\";\n\t\t\tinfo->numLines++;\n\t\t\t// parse players\n\t\t\ti = 0;\n\t\t\tlen = 0;\n\t\t\twhile (p && *p) {\n\t\t\t\tif (*p == '\\\\')\n\t\t\t\t\t*p++ = '\\0';\n\t\t\t\tif (!p)\n\t\t\t\t\tbreak;\n\t\t\t\tscore = p;\n\t\t\t\tp = strchr(p, ' ');\n\t\t\t\tif (!p)\n\t\t\t\t\tbreak;\n\t\t\t\t*p++ = '\\0';\n\t\t\t\tping = p;\n\t\t\t\tp = strchr(p, ' ');\n\t\t\t\tif (!p)\n\t\t\t\t\tbreak;\n\t\t\t\t*p++ = '\\0';\n\t\t\t\tname = p;\n\t\t\t\tCom_sprintf(&info->pings[len], sizeof(info->pings)-len, \"%d\", i);\n\t\t\t\tinfo->lines[info->numLines][0] = &info->pings[len];\n\t\t\t\tlen += strlen(&info->pings[len]) + 1;\n\t\t\t\tinfo->lines[info->numLines][1] = score;\n\t\t\t\tinfo->lines[info->numLines][2] = ping;\n\t\t\t\tinfo->lines[info->numLines][3] = name;\n\t\t\t\tinfo->numLines++;\n\t\t\t\tif (info->numLines >= MAX_SERVERSTATUS_LINES)\n\t\t\t\t\tbreak;\n\t\t\t\tp = strchr(p, '\\\\');\n\t\t\t\tif (!p)\n\t\t\t\t\tbreak;\n\t\t\t\t*p++ = '\\0';\n\t\t\t\t//\n\t\t\t\ti++;\n\t\t\t}\n\t\t}\n\t\tUI_SortServerStatusInfo( info );\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nstristr\n==================\n*/\nstatic char *stristr(char *str, char *charset) {\n\tint i;\n\n\twhile(*str) {\n\t\tfor (i = 0; charset[i] && str[i]; i++) {\n\t\t\tif (toupper(charset[i]) != toupper(str[i])) break;\n\t\t}\n\t\tif (!charset[i]) return str;\n\t\tstr++;\n\t}\n\treturn NULL;\n}\n\n/*\n==================\nUI_BuildFindPlayerList\n==================\n*/\nstatic void UI_BuildFindPlayerList(qboolean force) {\n\tstatic int numFound, numTimeOuts;\n\tint i, j, resend;\n\tserverStatusInfo_t info;\n\tchar name[MAX_NAME_LENGTH+2];\n\tchar infoString[MAX_STRING_CHARS];\n\n\tif (!force) {\n\t\tif (!uiInfo.nextFindPlayerRefresh || uiInfo.nextFindPlayerRefresh > uiInfo.uiDC.realTime) {\n\t\t\treturn;\n\t\t}\n\t}\n\telse {\n\t\tmemset(&uiInfo.pendingServerStatus, 0, sizeof(uiInfo.pendingServerStatus));\n\t\tuiInfo.numFoundPlayerServers = 0;\n\t\tuiInfo.currentFoundPlayerServer = 0;\n\t\ttrap_Cvar_VariableStringBuffer( \"ui_findPlayer\", uiInfo.findPlayerName, sizeof(uiInfo.findPlayerName));\n\t\tQ_CleanStr(uiInfo.findPlayerName);\n\t\t// should have a string of some length\n\t\tif (!strlen(uiInfo.findPlayerName)) {\n\t\t\tuiInfo.nextFindPlayerRefresh = 0;\n\t\t\treturn;\n\t\t}\n\t\t// set resend time\n\t\tresend = ui_serverStatusTimeOut.integer / 2 - 10;\n\t\tif (resend < 50) {\n\t\t\tresend = 50;\n\t\t}\n\t\ttrap_Cvar_Set(\"cl_serverStatusResendTime\", va(\"%d\", resend));\n\t\t// reset all server status requests\n\t\ttrap_LAN_ServerStatus( NULL, NULL, 0);\n\t\t//\n\t\tuiInfo.numFoundPlayerServers = 1;\n\t\tCom_sprintf(uiInfo.foundPlayerServerNames[uiInfo.numFoundPlayerServers-1],\n\t\t\t\t\t\tsizeof(uiInfo.foundPlayerServerNames[uiInfo.numFoundPlayerServers-1]),\n\t\t\t\t\t\t\t\"searching %d...\", uiInfo.pendingServerStatus.num);\n\t\tnumFound = 0;\n\t\tnumTimeOuts++;\n\t}\n\tfor (i = 0; i < MAX_SERVERSTATUSREQUESTS; i++) {\n\t\t// if this pending server is valid\n\t\tif (uiInfo.pendingServerStatus.server[i].valid) {\n\t\t\t// try to get the server status for this server\n\t\t\tif (UI_GetServerStatusInfo( uiInfo.pendingServerStatus.server[i].adrstr, &info ) ) {\n\t\t\t\t//\n\t\t\t\tnumFound++;\n\t\t\t\t// parse through the server status lines\n\t\t\t\tfor (j = 0; j < info.numLines; j++) {\n\t\t\t\t\t// should have ping info\n\t\t\t\t\tif ( !info.lines[j][2] || !info.lines[j][2][0] ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t// clean string first\n\t\t\t\t\tQ_strncpyz(name, info.lines[j][3], sizeof(name));\n\t\t\t\t\tQ_CleanStr(name);\n\t\t\t\t\t// if the player name is a substring\n\t\t\t\t\tif (stristr(name, uiInfo.findPlayerName)) {\n\t\t\t\t\t\t// add to found server list if we have space (always leave space for a line with the number found)\n\t\t\t\t\t\tif (uiInfo.numFoundPlayerServers < MAX_FOUNDPLAYER_SERVERS-1) {\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\tQ_strncpyz(uiInfo.foundPlayerServerAddresses[uiInfo.numFoundPlayerServers-1],\n\t\t\t\t\t\t\t\t\t\tuiInfo.pendingServerStatus.server[i].adrstr,\n\t\t\t\t\t\t\t\t\t\t\tsizeof(uiInfo.foundPlayerServerAddresses[0]));\n\t\t\t\t\t\t\tQ_strncpyz(uiInfo.foundPlayerServerNames[uiInfo.numFoundPlayerServers-1],\n\t\t\t\t\t\t\t\t\t\tuiInfo.pendingServerStatus.server[i].name,\n\t\t\t\t\t\t\t\t\t\t\tsizeof(uiInfo.foundPlayerServerNames[0]));\n\t\t\t\t\t\t\tuiInfo.numFoundPlayerServers++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t// can't add any more so we're done\n\t\t\t\t\t\t\tuiInfo.pendingServerStatus.num = uiInfo.serverStatus.numDisplayServers;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tCom_sprintf(uiInfo.foundPlayerServerNames[uiInfo.numFoundPlayerServers-1],\n\t\t\t\t\t\t\t\tsizeof(uiInfo.foundPlayerServerNames[uiInfo.numFoundPlayerServers-1]),\n\t\t\t\t\t\t\t\t\t\"searching %d/%d...\", uiInfo.pendingServerStatus.num, numFound);\n\t\t\t\t// retrieved the server status so reuse this spot\n\t\t\t\tuiInfo.pendingServerStatus.server[i].valid = qfalse;\n\t\t\t}\n\t\t}\n\t\t// if empty pending slot or timed out\n\t\tif (!uiInfo.pendingServerStatus.server[i].valid ||\n\t\t\tuiInfo.pendingServerStatus.server[i].startTime < uiInfo.uiDC.realTime - ui_serverStatusTimeOut.integer) {\n\t\t\tif (uiInfo.pendingServerStatus.server[i].valid) {\n\t\t\t\tnumTimeOuts++;\n\t\t\t}\n\t\t\t// reset server status request for this address\n\t\t\tUI_GetServerStatusInfo( uiInfo.pendingServerStatus.server[i].adrstr, NULL );\n\t\t\t// reuse pending slot\n\t\t\tuiInfo.pendingServerStatus.server[i].valid = qfalse;\n\t\t\t// if we didn't try to get the status of all servers in the main browser yet\n\t\t\tif (uiInfo.pendingServerStatus.num < uiInfo.serverStatus.numDisplayServers) {\n\t\t\t\tuiInfo.pendingServerStatus.server[i].startTime = uiInfo.uiDC.realTime;\n\t\t\t\ttrap_LAN_GetServerAddressString(ui_netSource.integer, uiInfo.serverStatus.displayServers[uiInfo.pendingServerStatus.num],\n\t\t\t\t\t\t\tuiInfo.pendingServerStatus.server[i].adrstr, sizeof(uiInfo.pendingServerStatus.server[i].adrstr));\n\t\t\t\ttrap_LAN_GetServerInfo(ui_netSource.integer, uiInfo.serverStatus.displayServers[uiInfo.pendingServerStatus.num], infoString, sizeof(infoString));\n\t\t\t\tQ_strncpyz(uiInfo.pendingServerStatus.server[i].name, Info_ValueForKey(infoString, \"hostname\"), sizeof(uiInfo.pendingServerStatus.server[0].name));\n\t\t\t\tuiInfo.pendingServerStatus.server[i].valid = qtrue;\n\t\t\t\tuiInfo.pendingServerStatus.num++;\n\t\t\t\tCom_sprintf(uiInfo.foundPlayerServerNames[uiInfo.numFoundPlayerServers-1],\n\t\t\t\t\t\t\t\tsizeof(uiInfo.foundPlayerServerNames[uiInfo.numFoundPlayerServers-1]),\n\t\t\t\t\t\t\t\t\t\"searching %d/%d...\", uiInfo.pendingServerStatus.num, numFound);\n\t\t\t}\n\t\t}\n\t}\n\tfor (i = 0; i < MAX_SERVERSTATUSREQUESTS; i++) {\n\t\tif (uiInfo.pendingServerStatus.server[i].valid) {\n\t\t\tbreak;\n\t\t}\n\t}\n\t// if still trying to retrieve server status info\n\tif (i < MAX_SERVERSTATUSREQUESTS) {\n\t\tuiInfo.nextFindPlayerRefresh = uiInfo.uiDC.realTime + 25;\n\t}\n\telse {\n\t\t// add a line that shows the number of servers found\n\t\tif (!uiInfo.numFoundPlayerServers) {\n\t\t\tCom_sprintf(uiInfo.foundPlayerServerNames[uiInfo.numFoundPlayerServers-1], sizeof(uiInfo.foundPlayerServerAddresses[0]), \"no servers found\");\n\t\t}\n\t\telse {\n\t\t\tCom_sprintf(uiInfo.foundPlayerServerNames[uiInfo.numFoundPlayerServers-1], sizeof(uiInfo.foundPlayerServerAddresses[0]),\n\t\t\t\t\t\t\"%d server%s found with player %s\", uiInfo.numFoundPlayerServers-1,\n\t\t\t\t\t\tuiInfo.numFoundPlayerServers == 2 ? \"\":\"s\", uiInfo.findPlayerName);\n\t\t}\n\t\tuiInfo.nextFindPlayerRefresh = 0;\n\t\t// show the server status info for the selected server\n\t\tUI_FeederSelection(FEEDER_FINDPLAYER, uiInfo.currentFoundPlayerServer);\n\t}\n}\n\n/*\n==================\nUI_BuildServerStatus\n==================\n*/\nstatic void UI_BuildServerStatus(qboolean force) {\n\n\tif (uiInfo.nextFindPlayerRefresh) {\n\t\treturn;\n\t}\n\tif (!force) {\n\t\tif (!uiInfo.nextServerStatusRefresh || uiInfo.nextServerStatusRefresh > uiInfo.uiDC.realTime) {\n\t\t\treturn;\n\t\t}\n\t}\n\telse {\n\t\tMenu_SetFeederSelection(NULL, FEEDER_SERVERSTATUS, 0, NULL);\n\t\tuiInfo.serverStatusInfo.numLines = 0;\n\t\t// reset all server status requests\n\t\ttrap_LAN_ServerStatus( NULL, NULL, 0);\n\t}\n\tif (uiInfo.serverStatus.currentServer < 0 || uiInfo.serverStatus.currentServer > uiInfo.serverStatus.numDisplayServers || uiInfo.serverStatus.numDisplayServers == 0) {\n\t\treturn;\n\t}\n\tif (UI_GetServerStatusInfo( uiInfo.serverStatusAddress, &uiInfo.serverStatusInfo ) ) {\n\t\tuiInfo.nextServerStatusRefresh = 0;\n\t\tUI_GetServerStatusInfo( uiInfo.serverStatusAddress, NULL );\n\t}\n\telse {\n\t\tuiInfo.nextServerStatusRefresh = uiInfo.uiDC.realTime + 500;\n\t}\n}\n\n/*\n==================\nUI_FeederCount\n==================\n*/\nstatic int UI_FeederCount(float feederID) {\n\tif (feederID == FEEDER_HEADS) {\n\t\treturn UI_HeadCountByTeam();\n\t} else if (feederID == FEEDER_Q3HEADS) {\n\t\treturn uiInfo.q3HeadCount;\n\t} else if (feederID == FEEDER_CINEMATICS) {\n\t\treturn uiInfo.movieCount;\n\t} else if (feederID == FEEDER_MAPS || feederID == FEEDER_ALLMAPS) {\n\t\treturn UI_MapCountByGameType(feederID == FEEDER_MAPS ? qtrue : qfalse);\n\t} else if (feederID == FEEDER_SERVERS) {\n\t\treturn uiInfo.serverStatus.numDisplayServers;\n\t} else if (feederID == FEEDER_SERVERSTATUS) {\n\t\treturn uiInfo.serverStatusInfo.numLines;\n\t} else if (feederID == FEEDER_FINDPLAYER) {\n\t\treturn uiInfo.numFoundPlayerServers;\n\t} else if (feederID == FEEDER_PLAYER_LIST) {\n\t\tif (uiInfo.uiDC.realTime > uiInfo.playerRefresh) {\n\t\t\tuiInfo.playerRefresh = uiInfo.uiDC.realTime + 3000;\n\t\t\tUI_BuildPlayerList();\n\t\t}\n\t\treturn uiInfo.playerCount;\n\t} else if (feederID == FEEDER_TEAM_LIST) {\n\t\tif (uiInfo.uiDC.realTime > uiInfo.playerRefresh) {\n\t\t\tuiInfo.playerRefresh = uiInfo.uiDC.realTime + 3000;\n\t\t\tUI_BuildPlayerList();\n\t\t}\n\t\treturn uiInfo.myTeamCount;\n\t} else if (feederID == FEEDER_MODS) {\n\t\treturn uiInfo.modCount;\n\t} else if (feederID == FEEDER_DEMOS) {\n\t\treturn uiInfo.demoCount;\n\t}\n\treturn 0;\n}\n\nstatic const char *UI_SelectedMap(int index, int *actual) {\n\tint i, c;\n\tc = 0;\n\t*actual = 0;\n\tfor (i = 0; i < uiInfo.mapCount; i++) {\n\t\tif (uiInfo.mapList[i].active) {\n\t\t\tif (c == index) {\n\t\t\t\t*actual = i;\n\t\t\t\treturn uiInfo.mapList[i].mapName;\n\t\t\t} else {\n\t\t\t\tc++;\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\";\n}\n\nstatic const char *UI_SelectedHead(int index, int *actual) {\n\tint i, c;\n\tc = 0;\n\t*actual = 0;\n\tfor (i = 0; i < uiInfo.characterCount; i++) {\n\t\tif (uiInfo.characterList[i].active) {\n\t\t\tif (c == index) {\n\t\t\t\t*actual = i;\n\t\t\t\treturn uiInfo.characterList[i].name;\n\t\t\t} else {\n\t\t\t\tc++;\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\";\n}\n\nstatic int UI_GetIndexFromSelection(int actual) {\n\tint i, c;\n\tc = 0;\n\tfor (i = 0; i < uiInfo.mapCount; i++) {\n\t\tif (uiInfo.mapList[i].active) {\n\t\t\tif (i == actual) {\n\t\t\t\treturn c;\n\t\t\t}\n\t\t\t\tc++;\n\t\t}\n\t}\n  return 0;\n}\n\nstatic void UI_UpdatePendingPings() { \n\ttrap_LAN_ResetPings(ui_netSource.integer);\n\tuiInfo.serverStatus.refreshActive = qtrue;\n\tuiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 1000;\n\n}\n\nstatic const char *UI_FeederItemText(float feederID, int index, int column, qhandle_t *handle) {\n\tstatic char info[MAX_STRING_CHARS];\n\tstatic char hostname[1024];\n\tstatic char clientBuff[32];\n\tstatic int lastColumn = -1;\n\tstatic int lastTime = 0;\n\t*handle = -1;\n\tif (feederID == FEEDER_HEADS) {\n\t\tint actual;\n\t\treturn UI_SelectedHead(index, &actual);\n\t} else if (feederID == FEEDER_Q3HEADS) {\n\t\tif (index >= 0 && index < uiInfo.q3HeadCount) {\n\t\t\treturn uiInfo.q3HeadNames[index];\n\t\t}\n\t} else if (feederID == FEEDER_MAPS || feederID == FEEDER_ALLMAPS) {\n\t\tint actual;\n\t\treturn UI_SelectedMap(index, &actual);\n\t} else if (feederID == FEEDER_SERVERS) {\n\t\tif (index >= 0 && index < uiInfo.serverStatus.numDisplayServers) {\n\t\t\tint ping, game, punkbuster;\n\t\t\tif (lastColumn != column || lastTime > uiInfo.uiDC.realTime + 5000) {\n\t\t\t\ttrap_LAN_GetServerInfo(ui_netSource.integer, uiInfo.serverStatus.displayServers[index], info, MAX_STRING_CHARS);\n\t\t\t\tlastColumn = column;\n\t\t\t\tlastTime = uiInfo.uiDC.realTime;\n\t\t\t}\n\t\t\tping = atoi(Info_ValueForKey(info, \"ping\"));\n\t\t\tif (ping == -1) {\n\t\t\t\t// if we ever see a ping that is out of date, do a server refresh\n\t\t\t\t// UI_UpdatePendingPings();\n\t\t\t}\n\t\t\tswitch (column) {\n\t\t\t\tcase SORT_HOST : \n\t\t\t\t\tif (ping <= 0) {\n\t\t\t\t\t\treturn Info_ValueForKey(info, \"addr\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif ( ui_netSource.integer == AS_LOCAL ) {\n\t\t\t\t\t\t\tCom_sprintf( hostname, sizeof(hostname), \"%s [%s]\",\n\t\t\t\t\t\t\t\t\t\t\tInfo_ValueForKey(info, \"hostname\"),\n\t\t\t\t\t\t\t\t\t\t\tnetnames[atoi(Info_ValueForKey(info, \"nettype\"))] );\n\t\t\t\t\t\t\treturn hostname;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tCom_sprintf( hostname, sizeof(hostname), \"%s\", Info_ValueForKey(info, \"hostname\"));\n\t\t\t\t\t\t\treturn hostname;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tcase SORT_MAP : return Info_ValueForKey(info, \"mapname\");\n\t\t\t\tcase SORT_CLIENTS : \n\t\t\t\t\tCom_sprintf( clientBuff, sizeof(clientBuff), \"%s (%s)\", Info_ValueForKey(info, \"clients\"), Info_ValueForKey(info, \"sv_maxclients\"));\n\t\t\t\t\treturn clientBuff;\n\t\t\t\tcase SORT_GAME : \n\t\t\t\t\tgame = atoi(Info_ValueForKey(info, \"gametype\"));\n\t\t\t\t\tif (game >= 0 && game < numTeamArenaGameTypes) {\n\t\t\t\t\t\treturn teamArenaGameTypes[game];\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn \"Unknown\";\n\t\t\t\t\t}\n\t\t\t\tcase SORT_PING : \n\t\t\t\t\tif (ping <= 0) {\n\t\t\t\t\t\treturn \"...\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn Info_ValueForKey(info, \"ping\");\n\t\t\t\t\t}\n\t\t\t\tcase SORT_PUNKBUSTER:\n\t\t\t\t\tpunkbuster = atoi(Info_ValueForKey(info, \"punkbuster\"));\n\t\t\t\t\tif ( punkbuster ) {\n\t\t\t\t\t\treturn \"Yes\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn \"No\";\n\t\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else if (feederID == FEEDER_SERVERSTATUS) {\n\t\tif ( index >= 0 && index < uiInfo.serverStatusInfo.numLines ) {\n\t\t\tif ( column >= 0 && column < 4 ) {\n\t\t\t\treturn uiInfo.serverStatusInfo.lines[index][column];\n\t\t\t}\n\t\t}\n\t} else if (feederID == FEEDER_FINDPLAYER) {\n\t\tif ( index >= 0 && index < uiInfo.numFoundPlayerServers ) {\n\t\t\t//return uiInfo.foundPlayerServerAddresses[index];\n\t\t\treturn uiInfo.foundPlayerServerNames[index];\n\t\t}\n\t} else if (feederID == FEEDER_PLAYER_LIST) {\n\t\tif (index >= 0 && index < uiInfo.playerCount) {\n\t\t\treturn uiInfo.playerNames[index];\n\t\t}\n\t} else if (feederID == FEEDER_TEAM_LIST) {\n\t\tif (index >= 0 && index < uiInfo.myTeamCount) {\n\t\t\treturn uiInfo.teamNames[index];\n\t\t}\n\t} else if (feederID == FEEDER_MODS) {\n\t\tif (index >= 0 && index < uiInfo.modCount) {\n\t\t\tif (uiInfo.modList[index].modDescr && *uiInfo.modList[index].modDescr) {\n\t\t\t\treturn uiInfo.modList[index].modDescr;\n\t\t\t} else {\n\t\t\t\treturn uiInfo.modList[index].modName;\n\t\t\t}\n\t\t}\n\t} else if (feederID == FEEDER_CINEMATICS) {\n\t\tif (index >= 0 && index < uiInfo.movieCount) {\n\t\t\treturn uiInfo.movieList[index];\n\t\t}\n\t} else if (feederID == FEEDER_DEMOS) {\n\t\tif (index >= 0 && index < uiInfo.demoCount) {\n\t\t\treturn uiInfo.demoList[index];\n\t\t}\n\t}\n\treturn \"\";\n}\n\n\nstatic qhandle_t UI_FeederItemImage(float feederID, int index) {\n  if (feederID == FEEDER_HEADS) {\n\tint actual;\n\tUI_SelectedHead(index, &actual);\n\tindex = actual;\n\tif (index >= 0 && index < uiInfo.characterCount) {\n\t\tif (uiInfo.characterList[index].headImage == -1) {\n\t\t\tuiInfo.characterList[index].headImage = trap_R_RegisterShaderNoMip(uiInfo.characterList[index].imageName);\n\t\t}\n\t\treturn uiInfo.characterList[index].headImage;\n\t}\n  } else if (feederID == FEEDER_Q3HEADS) {\n    if (index >= 0 && index < uiInfo.q3HeadCount) {\n      return uiInfo.q3HeadIcons[index];\n    }\n\t} else if (feederID == FEEDER_ALLMAPS || feederID == FEEDER_MAPS) {\n\t\tint actual;\n\t\tUI_SelectedMap(index, &actual);\n\t\tindex = actual;\n\t\tif (index >= 0 && index < uiInfo.mapCount) {\n\t\t\tif (uiInfo.mapList[index].levelShot == -1) {\n\t\t\t\tuiInfo.mapList[index].levelShot = trap_R_RegisterShaderNoMip(uiInfo.mapList[index].imageName);\n\t\t\t}\n\t\t\treturn uiInfo.mapList[index].levelShot;\n\t\t}\n\t}\n  return 0;\n}\n\nstatic void UI_FeederSelection(float feederID, int index) {\n\tstatic char info[MAX_STRING_CHARS];\n  if (feederID == FEEDER_HEADS) {\n\tint actual;\n\tUI_SelectedHead(index, &actual);\n\tindex = actual;\n    if (index >= 0 && index < uiInfo.characterCount) {\n\t\ttrap_Cvar_Set( \"team_model\", va(\"%s\", uiInfo.characterList[index].base));\n\t\ttrap_Cvar_Set( \"team_headmodel\", va(\"*%s\", uiInfo.characterList[index].name)); \n\t\tupdateModel = qtrue;\n    }\n  } else if (feederID == FEEDER_Q3HEADS) {\n    if (index >= 0 && index < uiInfo.q3HeadCount) {\n      trap_Cvar_Set( \"model\", uiInfo.q3HeadNames[index]);\n      trap_Cvar_Set( \"headmodel\", uiInfo.q3HeadNames[index]);\n\t\t\tupdateModel = qtrue;\n\t\t}\n  } else if (feederID == FEEDER_MAPS || feederID == FEEDER_ALLMAPS) {\n\t\tint actual, map;\n\t\tmap = (feederID == FEEDER_ALLMAPS) ? ui_currentNetMap.integer : ui_currentMap.integer;\n\t\tif (uiInfo.mapList[map].cinematic >= 0) {\n\t\t  trap_CIN_StopCinematic(uiInfo.mapList[map].cinematic);\n\t\t  uiInfo.mapList[map].cinematic = -1;\n\t\t}\n\t\tUI_SelectedMap(index, &actual);\n\t\ttrap_Cvar_Set(\"ui_mapIndex\", va(\"%d\", index));\n\t\tui_mapIndex.integer = index;\n\n\t\tif (feederID == FEEDER_MAPS) {\n\t\t\tui_currentMap.integer = actual;\n\t\t\ttrap_Cvar_Set(\"ui_currentMap\", va(\"%d\", actual));\n\t  \tuiInfo.mapList[ui_currentMap.integer].cinematic = trap_CIN_PlayCinematic(va(\"%s.roq\", uiInfo.mapList[ui_currentMap.integer].mapLoadName), 0, 0, 0, 0, (CIN_loop | CIN_silent) );\n\t\t\tUI_LoadBestScores(uiInfo.mapList[ui_currentMap.integer].mapLoadName, uiInfo.gameTypes[ui_gameType.integer].gtEnum);\n\t\t\ttrap_Cvar_Set(\"ui_opponentModel\", uiInfo.mapList[ui_currentMap.integer].opponentName);\n\t\t\tupdateOpponentModel = qtrue;\n\t\t} else {\n\t\t\tui_currentNetMap.integer = actual;\n\t\t\ttrap_Cvar_Set(\"ui_currentNetMap\", va(\"%d\", actual));\n\t  \tuiInfo.mapList[ui_currentNetMap.integer].cinematic = trap_CIN_PlayCinematic(va(\"%s.roq\", uiInfo.mapList[ui_currentNetMap.integer].mapLoadName), 0, 0, 0, 0, (CIN_loop | CIN_silent) );\n\t\t}\n\n  } else if (feederID == FEEDER_SERVERS) {\n\t\tconst char *mapName = NULL;\n\t\tuiInfo.serverStatus.currentServer = index;\n\t\ttrap_LAN_GetServerInfo(ui_netSource.integer, uiInfo.serverStatus.displayServers[index], info, MAX_STRING_CHARS);\n\t\tuiInfo.serverStatus.currentServerPreview = trap_R_RegisterShaderNoMip(va(\"levelshots/%s\", Info_ValueForKey(info, \"mapname\")));\n\t\tif (uiInfo.serverStatus.currentServerCinematic >= 0) {\n\t\t  trap_CIN_StopCinematic(uiInfo.serverStatus.currentServerCinematic);\n\t\t\tuiInfo.serverStatus.currentServerCinematic = -1;\n\t\t}\n\t\tmapName = Info_ValueForKey(info, \"mapname\");\n\t\tif (mapName && *mapName) {\n\t\t\tuiInfo.serverStatus.currentServerCinematic = trap_CIN_PlayCinematic(va(\"%s.roq\", mapName), 0, 0, 0, 0, (CIN_loop | CIN_silent) );\n\t\t}\n  } else if (feederID == FEEDER_SERVERSTATUS) {\n\t\t//\n  } else if (feederID == FEEDER_FINDPLAYER) {\n\t  uiInfo.currentFoundPlayerServer = index;\n\t  //\n\t  if ( index < uiInfo.numFoundPlayerServers-1) {\n\t\t\t// build a new server status for this server\n\t\t\tQ_strncpyz(uiInfo.serverStatusAddress, uiInfo.foundPlayerServerAddresses[uiInfo.currentFoundPlayerServer], sizeof(uiInfo.serverStatusAddress));\n\t\t\tMenu_SetFeederSelection(NULL, FEEDER_SERVERSTATUS, 0, NULL);\n\t\t\tUI_BuildServerStatus(qtrue);\n\t  }\n  } else if (feederID == FEEDER_PLAYER_LIST) {\n\t\tuiInfo.playerIndex = index;\n  } else if (feederID == FEEDER_TEAM_LIST) {\n\t\tuiInfo.teamIndex = index;\n  } else if (feederID == FEEDER_MODS) {\n\t\tuiInfo.modIndex = index;\n  } else if (feederID == FEEDER_CINEMATICS) {\n\t\tuiInfo.movieIndex = index;\n\t\tif (uiInfo.previewMovie >= 0) {\n\t\t  trap_CIN_StopCinematic(uiInfo.previewMovie);\n\t\t}\n\t\tuiInfo.previewMovie = -1;\n  } else if (feederID == FEEDER_DEMOS) {\n\t\tuiInfo.demoIndex = index;\n\t}\n}\n\nstatic qboolean Team_Parse(char **p) {\n  char *token;\n  const char *tempStr;\n\tint i;\n\n  token = COM_ParseExt(p, qtrue);\n\n  if (token[0] != '{') {\n    return qfalse;\n  }\n\n  while ( 1 ) {\n\n    token = COM_ParseExt(p, qtrue);\n    \n    if (Q_stricmp(token, \"}\") == 0) {\n      return qtrue;\n    }\n\n    if ( !token || token[0] == 0 ) {\n      return qfalse;\n    }\n\n    if (token[0] == '{') {\n      // seven tokens per line, team name and icon, and 5 team member names\n      if (!String_Parse(p, &uiInfo.teamList[uiInfo.teamCount].teamName) || !String_Parse(p, &tempStr)) {\n        return qfalse;\n      }\n    \n\n\t\t\tuiInfo.teamList[uiInfo.teamCount].imageName = tempStr;\n\t    uiInfo.teamList[uiInfo.teamCount].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[uiInfo.teamCount].imageName);\n\t\t  uiInfo.teamList[uiInfo.teamCount].teamIcon_Metal = trap_R_RegisterShaderNoMip(va(\"%s_metal\",uiInfo.teamList[uiInfo.teamCount].imageName));\n\t\t\tuiInfo.teamList[uiInfo.teamCount].teamIcon_Name = trap_R_RegisterShaderNoMip(va(\"%s_name\", uiInfo.teamList[uiInfo.teamCount].imageName));\n\n\t\t\tuiInfo.teamList[uiInfo.teamCount].cinematic = -1;\n\n\t\t\tfor (i = 0; i < TEAM_MEMBERS; i++) {\n\t\t\t\tuiInfo.teamList[uiInfo.teamCount].teamMembers[i] = NULL;\n\t\t\t\tif (!String_Parse(p, &uiInfo.teamList[uiInfo.teamCount].teamMembers[i])) {\n\t\t\t\t\treturn qfalse;\n\t\t\t\t}\n\t\t\t}\n\n      Com_Printf(\"Loaded team %s with team icon %s.\\n\", uiInfo.teamList[uiInfo.teamCount].teamName, tempStr);\n      if (uiInfo.teamCount < MAX_TEAMS) {\n        uiInfo.teamCount++;\n      } else {\n        Com_Printf(\"Too many teams, last team replaced!\\n\");\n      }\n      token = COM_ParseExt(p, qtrue);\n      if (token[0] != '}') {\n        return qfalse;\n      }\n    }\n  }\n\n  return qfalse;\n}\n\nstatic qboolean Character_Parse(char **p) {\n  char *token;\n  const char *tempStr;\n\n  token = COM_ParseExt(p, qtrue);\n\n  if (token[0] != '{') {\n    return qfalse;\n  }\n\n\n  while ( 1 ) {\n    token = COM_ParseExt(p, qtrue);\n\n    if (Q_stricmp(token, \"}\") == 0) {\n      return qtrue;\n    }\n\n    if ( !token || token[0] == 0 ) {\n      return qfalse;\n    }\n\n    if (token[0] == '{') {\n      // two tokens per line, character name and sex\n      if (!String_Parse(p, &uiInfo.characterList[uiInfo.characterCount].name) || !String_Parse(p, &tempStr)) {\n        return qfalse;\n      }\n    \n      uiInfo.characterList[uiInfo.characterCount].headImage = -1;\n\t\t\tuiInfo.characterList[uiInfo.characterCount].imageName = String_Alloc(va(\"models/players/heads/%s/icon_default.tga\", uiInfo.characterList[uiInfo.characterCount].name));\n\n\t  if (tempStr && (!Q_stricmp(tempStr, \"female\"))) {\n        uiInfo.characterList[uiInfo.characterCount].base = String_Alloc(va(\"Janet\"));\n      } else if (tempStr && (!Q_stricmp(tempStr, \"male\"))) {\n        uiInfo.characterList[uiInfo.characterCount].base = String_Alloc(va(\"James\"));\n\t  } else {\n        uiInfo.characterList[uiInfo.characterCount].base = String_Alloc(va(\"%s\",tempStr));\n\t  }\n\n      Com_Printf(\"Loaded %s character %s.\\n\", uiInfo.characterList[uiInfo.characterCount].base, uiInfo.characterList[uiInfo.characterCount].name);\n      if (uiInfo.characterCount < MAX_HEADS) {\n        uiInfo.characterCount++;\n      } else {\n        Com_Printf(\"Too many characters, last character replaced!\\n\");\n      }\n     \n      token = COM_ParseExt(p, qtrue);\n      if (token[0] != '}') {\n        return qfalse;\n      }\n    }\n  }\n\n  return qfalse;\n}\n\n\nstatic qboolean Alias_Parse(char **p) {\n  char *token;\n\n  token = COM_ParseExt(p, qtrue);\n\n  if (token[0] != '{') {\n    return qfalse;\n  }\n\n  while ( 1 ) {\n    token = COM_ParseExt(p, qtrue);\n\n    if (Q_stricmp(token, \"}\") == 0) {\n      return qtrue;\n    }\n\n    if ( !token || token[0] == 0 ) {\n      return qfalse;\n    }\n\n    if (token[0] == '{') {\n      // three tokens per line, character name, bot alias, and preferred action a - all purpose, d - defense, o - offense\n      if (!String_Parse(p, &uiInfo.aliasList[uiInfo.aliasCount].name) || !String_Parse(p, &uiInfo.aliasList[uiInfo.aliasCount].ai) || !String_Parse(p, &uiInfo.aliasList[uiInfo.aliasCount].action)) {\n        return qfalse;\n      }\n    \n      Com_Printf(\"Loaded character alias %s using character ai %s.\\n\", uiInfo.aliasList[uiInfo.aliasCount].name, uiInfo.aliasList[uiInfo.aliasCount].ai);\n      if (uiInfo.aliasCount < MAX_ALIASES) {\n        uiInfo.aliasCount++;\n      } else {\n        Com_Printf(\"Too many aliases, last alias replaced!\\n\");\n      }\n     \n      token = COM_ParseExt(p, qtrue);\n      if (token[0] != '}') {\n        return qfalse;\n      }\n    }\n  }\n\n  return qfalse;\n}\n\n\n\n// mode \n// 0 - high level parsing\n// 1 - team parsing\n// 2 - character parsing\nstatic void UI_ParseTeamInfo(const char *teamFile) {\n\tchar\t*token;\n  char *p;\n  char *buff = NULL;\n  //static int mode = 0; TTimo: unused\n\n  buff = GetMenuBuffer(teamFile);\n  if (!buff) {\n    return;\n  }\n\n  p = buff;\n\n\twhile ( 1 ) {\n\t\ttoken = COM_ParseExt( &p, qtrue );\n\t\tif( !token || token[0] == 0 || token[0] == '}') {\n\t\t\tbreak;\n\t\t}\n\n\t\tif ( Q_stricmp( token, \"}\" ) == 0 ) {\n      break;\n    }\n\n    if (Q_stricmp(token, \"teams\") == 0) {\n\n      if (Team_Parse(&p)) {\n        continue;\n      } else {\n        break;\n      }\n    }\n\n    if (Q_stricmp(token, \"characters\") == 0) {\n      Character_Parse(&p);\n    }\n\n    if (Q_stricmp(token, \"aliases\") == 0) {\n      Alias_Parse(&p);\n    }\n\n  }\n\n}\n\n\nstatic qboolean GameType_Parse(char **p, qboolean join) {\n\tchar *token;\n\n\ttoken = COM_ParseExt(p, qtrue);\n\n\tif (token[0] != '{') {\n\t\treturn qfalse;\n\t}\n\n\tif (join) {\n\t\tuiInfo.numJoinGameTypes = 0;\n\t} else {\n\t\tuiInfo.numGameTypes = 0;\n\t}\n\n\twhile ( 1 ) {\n\t\ttoken = COM_ParseExt(p, qtrue);\n\n\t\tif (Q_stricmp(token, \"}\") == 0) {\n\t\t\treturn qtrue;\n\t\t}\n\n\t\tif ( !token || token[0] == 0 ) {\n\t\t\treturn qfalse;\n\t\t}\n\n\t\tif (token[0] == '{') {\n\t\t\t// two tokens per line, character name and sex\n\t\t\tif (join) {\n\t\t\t\tif (!String_Parse(p, &uiInfo.joinGameTypes[uiInfo.numJoinGameTypes].gameType) || !Int_Parse(p, &uiInfo.joinGameTypes[uiInfo.numJoinGameTypes].gtEnum)) {\n\t\t\t\t\treturn qfalse;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (!String_Parse(p, &uiInfo.gameTypes[uiInfo.numGameTypes].gameType) || !Int_Parse(p, &uiInfo.gameTypes[uiInfo.numGameTypes].gtEnum)) {\n\t\t\t\t\treturn qfalse;\n\t\t\t\t}\n\t\t\t}\n    \n\t\t\tif (join) {\n\t\t\t\tif (uiInfo.numJoinGameTypes < MAX_GAMETYPES) {\n\t\t\t\t\tuiInfo.numJoinGameTypes++;\n\t\t\t\t} else {\n\t\t\t\t\tCom_Printf(\"Too many net game types, last one replace!\\n\");\n\t\t\t\t}\t\t\n\t\t\t} else {\n\t\t\t\tif (uiInfo.numGameTypes < MAX_GAMETYPES) {\n\t\t\t\t\tuiInfo.numGameTypes++;\n\t\t\t\t} else {\n\t\t\t\t\tCom_Printf(\"Too many game types, last one replace!\\n\");\n\t\t\t\t}\t\t\n\t\t\t}\n     \n\t\t\ttoken = COM_ParseExt(p, qtrue);\n\t\t\tif (token[0] != '}') {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t}\n\t}\n\treturn qfalse;\n}\n\nstatic qboolean MapList_Parse(char **p) {\n\tchar *token;\n\n\ttoken = COM_ParseExt(p, qtrue);\n\n\tif (token[0] != '{') {\n\t\treturn qfalse;\n\t}\n\n\tuiInfo.mapCount = 0;\n\n\twhile ( 1 ) {\n\t\ttoken = COM_ParseExt(p, qtrue);\n\n\t\tif (Q_stricmp(token, \"}\") == 0) {\n\t\t\treturn qtrue;\n\t\t}\n\n\t\tif ( !token || token[0] == 0 ) {\n\t\t\treturn qfalse;\n\t\t}\n\n\t\tif (token[0] == '{') {\n\t\t\tif (!String_Parse(p, &uiInfo.mapList[uiInfo.mapCount].mapName) || !String_Parse(p, &uiInfo.mapList[uiInfo.mapCount].mapLoadName) \n\t\t\t\t||!Int_Parse(p, &uiInfo.mapList[uiInfo.mapCount].teamMembers) ) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\n\t\t\tif (!String_Parse(p, &uiInfo.mapList[uiInfo.mapCount].opponentName)) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\n\t\t\tuiInfo.mapList[uiInfo.mapCount].typeBits = 0;\n\n\t\t\twhile (1) {\n\t\t\t\ttoken = COM_ParseExt(p, qtrue);\n\t\t\t\tif (token[0] >= '0' && token[0] <= '9') {\n\t\t\t\t\tuiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << (token[0] - 0x030));\n\t\t\t\t\tif (!Int_Parse(p, &uiInfo.mapList[uiInfo.mapCount].timeToBeat[token[0] - 0x30])) {\n\t\t\t\t\t\treturn qfalse;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t} \n\t\t\t}\n\n\t\t\t//mapList[mapCount].imageName = String_Alloc(va(\"levelshots/%s\", mapList[mapCount].mapLoadName));\n\t\t\t//if (uiInfo.mapCount == 0) {\n\t\t\t  // only load the first cinematic, selection loads the others\n  \t\t\t//  uiInfo.mapList[uiInfo.mapCount].cinematic = trap_CIN_PlayCinematic(va(\"%s.roq\",uiInfo.mapList[uiInfo.mapCount].mapLoadName), qfalse, qfalse, qtrue, 0, 0, 0, 0);\n\t\t\t//}\n  \t\tuiInfo.mapList[uiInfo.mapCount].cinematic = -1;\n\t\t\tuiInfo.mapList[uiInfo.mapCount].levelShot = trap_R_RegisterShaderNoMip(va(\"levelshots/%s_small\", uiInfo.mapList[uiInfo.mapCount].mapLoadName));\n\n\t\t\tif (uiInfo.mapCount < MAX_MAPS) {\n\t\t\t\tuiInfo.mapCount++;\n\t\t\t} else {\n\t\t\t\tCom_Printf(\"Too many maps, last one replaced!\\n\");\n\t\t\t}\n\t\t}\n\t}\n\treturn qfalse;\n}\n\nstatic void UI_ParseGameInfo(const char *teamFile) {\n\tchar\t*token;\n\tchar *p;\n\tchar *buff = NULL;\n\t//int mode = 0; TTimo: unused\n\n\tbuff = GetMenuBuffer(teamFile);\n\tif (!buff) {\n\t\treturn;\n\t}\n\n\tp = buff;\n\n\twhile ( 1 ) {\n\t\ttoken = COM_ParseExt( &p, qtrue );\n\t\tif( !token || token[0] == 0 || token[0] == '}') {\n\t\t\tbreak;\n\t\t}\n\n\t\tif ( Q_stricmp( token, \"}\" ) == 0 ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (Q_stricmp(token, \"gametypes\") == 0) {\n\n\t\t\tif (GameType_Parse(&p, qfalse)) {\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (Q_stricmp(token, \"joingametypes\") == 0) {\n\n\t\t\tif (GameType_Parse(&p, qtrue)) {\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (Q_stricmp(token, \"maps\") == 0) {\n\t\t\t// start a new menu\n\t\t\tMapList_Parse(&p);\n\t\t}\n\n\t}\n}\n\nstatic void UI_Pause(qboolean b) {\n\tif (b) {\n\t\t// pause the game and set the ui keycatcher\n\t  trap_Cvar_Set( \"cl_paused\", \"1\" );\n\t\ttrap_Key_SetCatcher( KEYCATCH_UI );\n\t} else {\n\t\t// unpause the game and clear the ui keycatcher\n\t\ttrap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI );\n\t\ttrap_Key_ClearStates();\n\t\ttrap_Cvar_Set( \"cl_paused\", \"0\" );\n\t}\n}\n\n#ifndef MISSIONPACK // bk001206\nstatic int UI_OwnerDraw_Width(int ownerDraw) {\n  // bk001205 - LCC missing return value\n  return 0;\n}\n#endif\n\nstatic int UI_PlayCinematic(const char *name, float x, float y, float w, float h) {\n  return trap_CIN_PlayCinematic(name, x, y, w, h, (CIN_loop | CIN_silent));\n}\n\nstatic void UI_StopCinematic(int handle) {\n\tif (handle >= 0) {\n\t  trap_CIN_StopCinematic(handle);\n\t} else {\n\t\thandle = abs(handle);\n\t\tif (handle == UI_MAPCINEMATIC) {\n\t\t\tif (uiInfo.mapList[ui_currentMap.integer].cinematic >= 0) {\n\t\t\t  trap_CIN_StopCinematic(uiInfo.mapList[ui_currentMap.integer].cinematic);\n\t\t\t  uiInfo.mapList[ui_currentMap.integer].cinematic = -1;\n\t\t\t}\n\t\t} else if (handle == UI_NETMAPCINEMATIC) {\n\t\t\tif (uiInfo.serverStatus.currentServerCinematic >= 0) {\n\t\t\t  trap_CIN_StopCinematic(uiInfo.serverStatus.currentServerCinematic);\n\t\t\t\tuiInfo.serverStatus.currentServerCinematic = -1;\n\t\t\t}\n\t\t} else if (handle == UI_CLANCINEMATIC) {\n\t\t  int i = UI_TeamIndexFromName(UI_Cvar_VariableString(\"ui_teamName\"));\n\t\t  if (i >= 0 && i < uiInfo.teamCount) {\n\t\t\t\tif (uiInfo.teamList[i].cinematic >= 0) {\n\t\t\t\t  trap_CIN_StopCinematic(uiInfo.teamList[i].cinematic);\n\t\t\t\t\tuiInfo.teamList[i].cinematic = -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nstatic void UI_DrawCinematic(int handle, float x, float y, float w, float h) {\n\ttrap_CIN_SetExtents(handle, x, y, w, h);\n  trap_CIN_DrawCinematic(handle);\n}\n\nstatic void UI_RunCinematicFrame(int handle) {\n  trap_CIN_RunCinematic(handle);\n}\n\n\n\n/*\n=================\nPlayerModel_BuildList\n=================\n*/\nstatic void UI_BuildQ3Model_List( void )\n{\n\tint\t\tnumdirs;\n\tint\t\tnumfiles;\n\tchar\tdirlist[2048];\n\tchar\tfilelist[2048];\n\tchar\tskinname[64];\n\tchar\tscratch[256];\n\tchar*\tdirptr;\n\tchar*\tfileptr;\n\tint\t\ti;\n\tint\t\tj, k, dirty;\n\tint\t\tdirlen;\n\tint\t\tfilelen;\n\n\tuiInfo.q3HeadCount = 0;\n\n\t// iterate directory of all player models\n\tnumdirs = trap_FS_GetFileList(\"models/players\", \"/\", dirlist, 2048 );\n\tdirptr  = dirlist;\n\tfor (i=0; i<numdirs && uiInfo.q3HeadCount < MAX_PLAYERMODELS; i++,dirptr+=dirlen+1)\n\t{\n\t\tdirlen = strlen(dirptr);\n\t\t\n\t\tif (dirlen && dirptr[dirlen-1]=='/') dirptr[dirlen-1]='\\0';\n\n\t\tif (!strcmp(dirptr,\".\") || !strcmp(dirptr,\"..\"))\n\t\t\tcontinue;\n\t\t\t\n\t\t// iterate all skin files in directory\n\t\tnumfiles = trap_FS_GetFileList( va(\"models/players/%s\",dirptr), \"tga\", filelist, 2048 );\n\t\tfileptr  = filelist;\n\t\tfor (j=0; j<numfiles && uiInfo.q3HeadCount < MAX_PLAYERMODELS;j++,fileptr+=filelen+1)\n\t\t{\n\t\t\tfilelen = strlen(fileptr);\n\n\t\t\tCOM_StripExtension(fileptr,skinname);\n\n\t\t\t// look for icon_????\n\t\t\tif (Q_stricmpn(skinname, \"icon_\", 5) == 0 && !(Q_stricmp(skinname,\"icon_blue\") == 0 || Q_stricmp(skinname,\"icon_red\") == 0))\n\t\t\t{\n\t\t\t\tif (Q_stricmp(skinname, \"icon_default\") == 0) {\n\t\t\t\t\tCom_sprintf( scratch, sizeof(scratch), dirptr);\n\t\t\t\t} else {\n\t\t\t\t\tCom_sprintf( scratch, sizeof(scratch), \"%s/%s\",dirptr, skinname + 5);\n\t\t\t\t}\n\t\t\t\tdirty = 0;\n\t\t\t\tfor(k=0;k<uiInfo.q3HeadCount;k++) {\n\t\t\t\t\tif (!Q_stricmp(scratch, uiInfo.q3HeadNames[uiInfo.q3HeadCount])) {\n\t\t\t\t\t\tdirty = 1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!dirty) {\n\t\t\t\t\tCom_sprintf( uiInfo.q3HeadNames[uiInfo.q3HeadCount], sizeof(uiInfo.q3HeadNames[uiInfo.q3HeadCount]), scratch);\n\t\t\t\t\tuiInfo.q3HeadIcons[uiInfo.q3HeadCount++] = trap_R_RegisterShaderNoMip(va(\"models/players/%s/%s\",dirptr,skinname));\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t}\t\n\n}\n\n\n\n/*\n=================\nUI_Init\n=================\n*/\nvoid _UI_Init( qboolean inGameLoad ) {\n\tconst char *menuSet;\n\tint start;\n\n\t//uiInfo.inGameLoad = inGameLoad;\n\n\tUI_RegisterCvars();\n\tUI_InitMemory();\n\n\t// cache redundant calulations\n\ttrap_GetGlconfig( &uiInfo.uiDC.glconfig );\n\n\t// for 640x480 virtualized screen\n\tuiInfo.uiDC.yscale = uiInfo.uiDC.glconfig.vidHeight * (1.0/480.0);\n\tuiInfo.uiDC.xscale = uiInfo.uiDC.glconfig.vidWidth * (1.0/640.0);\n\tif ( uiInfo.uiDC.glconfig.vidWidth * 480 > uiInfo.uiDC.glconfig.vidHeight * 640 ) {\n\t\t// wide screen\n\t\tuiInfo.uiDC.bias = 0.5 * ( uiInfo.uiDC.glconfig.vidWidth - ( uiInfo.uiDC.glconfig.vidHeight * (640.0/480.0) ) );\n\t}\n\telse {\n\t\t// no wide screen\n\t\tuiInfo.uiDC.bias = 0;\n\t}\n\n\n  //UI_Load();\n\tuiInfo.uiDC.registerShaderNoMip = &trap_R_RegisterShaderNoMip;\n\tuiInfo.uiDC.setColor = &UI_SetColor;\n\tuiInfo.uiDC.drawHandlePic = &UI_DrawHandlePic;\n\tuiInfo.uiDC.drawStretchPic = &trap_R_DrawStretchPic;\n\tuiInfo.uiDC.drawText = &Text_Paint;\n\tuiInfo.uiDC.textWidth = &Text_Width;\n\tuiInfo.uiDC.textHeight = &Text_Height;\n\tuiInfo.uiDC.registerModel = &trap_R_RegisterModel;\n\tuiInfo.uiDC.modelBounds = &trap_R_ModelBounds;\n\tuiInfo.uiDC.fillRect = &UI_FillRect;\n\tuiInfo.uiDC.drawRect = &_UI_DrawRect;\n\tuiInfo.uiDC.drawSides = &_UI_DrawSides;\n\tuiInfo.uiDC.drawTopBottom = &_UI_DrawTopBottom;\n\tuiInfo.uiDC.clearScene = &trap_R_ClearScene;\n\tuiInfo.uiDC.drawSides = &_UI_DrawSides;\n\tuiInfo.uiDC.addRefEntityToScene = &trap_R_AddRefEntityToScene;\n\tuiInfo.uiDC.renderScene = &trap_R_RenderScene;\n\tuiInfo.uiDC.registerFont = &trap_R_RegisterFont;\n\tuiInfo.uiDC.ownerDrawItem = &UI_OwnerDraw;\n\tuiInfo.uiDC.getValue = &UI_GetValue;\n\tuiInfo.uiDC.ownerDrawVisible = &UI_OwnerDrawVisible;\n\tuiInfo.uiDC.runScript = &UI_RunMenuScript;\n\tuiInfo.uiDC.getTeamColor = &UI_GetTeamColor;\n\tuiInfo.uiDC.setCVar = trap_Cvar_Set;\n\tuiInfo.uiDC.getCVarString = trap_Cvar_VariableStringBuffer;\n\tuiInfo.uiDC.getCVarValue = trap_Cvar_VariableValue;\n\tuiInfo.uiDC.drawTextWithCursor = &Text_PaintWithCursor;\n\tuiInfo.uiDC.setOverstrikeMode = &trap_Key_SetOverstrikeMode;\n\tuiInfo.uiDC.getOverstrikeMode = &trap_Key_GetOverstrikeMode;\n\tuiInfo.uiDC.startLocalSound = &trap_S_StartLocalSound;\n\tuiInfo.uiDC.ownerDrawHandleKey = &UI_OwnerDrawHandleKey;\n\tuiInfo.uiDC.feederCount = &UI_FeederCount;\n\tuiInfo.uiDC.feederItemImage = &UI_FeederItemImage;\n\tuiInfo.uiDC.feederItemText = &UI_FeederItemText;\n\tuiInfo.uiDC.feederSelection = &UI_FeederSelection;\n\tuiInfo.uiDC.setBinding = &trap_Key_SetBinding;\n\tuiInfo.uiDC.getBindingBuf = &trap_Key_GetBindingBuf;\n\tuiInfo.uiDC.keynumToStringBuf = &trap_Key_KeynumToStringBuf;\n\tuiInfo.uiDC.executeText = &trap_Cmd_ExecuteText;\n\tuiInfo.uiDC.Error = &Com_Error; \n\tuiInfo.uiDC.Print = &Com_Printf; \n\tuiInfo.uiDC.Pause = &UI_Pause;\n\tuiInfo.uiDC.ownerDrawWidth = &UI_OwnerDrawWidth;\n\tuiInfo.uiDC.registerSound = &trap_S_RegisterSound;\n\tuiInfo.uiDC.startBackgroundTrack = &trap_S_StartBackgroundTrack;\n\tuiInfo.uiDC.stopBackgroundTrack = &trap_S_StopBackgroundTrack;\n\tuiInfo.uiDC.playCinematic = &UI_PlayCinematic;\n\tuiInfo.uiDC.stopCinematic = &UI_StopCinematic;\n\tuiInfo.uiDC.drawCinematic = &UI_DrawCinematic;\n\tuiInfo.uiDC.runCinematicFrame = &UI_RunCinematicFrame;\n\n\tInit_Display(&uiInfo.uiDC);\n\n\tString_Init();\n  \n\tuiInfo.uiDC.cursor\t= trap_R_RegisterShaderNoMip( \"menu/art/3_cursor2\" );\n\tuiInfo.uiDC.whiteShader = trap_R_RegisterShaderNoMip( \"white\" );\n\n\tAssetCache();\n\n\tstart = trap_Milliseconds();\n\n  uiInfo.teamCount = 0;\n  uiInfo.characterCount = 0;\n  uiInfo.aliasCount = 0;\n\n#ifdef PRE_RELEASE_TADEMO\n\tUI_ParseTeamInfo(\"demoteaminfo.txt\");\n\tUI_ParseGameInfo(\"demogameinfo.txt\");\n#else\n\tUI_ParseTeamInfo(\"teaminfo.txt\");\n\tUI_LoadTeams();\n\tUI_ParseGameInfo(\"gameinfo.txt\");\n#endif\n\n\tmenuSet = UI_Cvar_VariableString(\"ui_menuFiles\");\n\tif (menuSet == NULL || menuSet[0] == '\\0') {\n\t\tmenuSet = \"ui/menus.txt\";\n\t}\n\n#if 0\n\tif (uiInfo.inGameLoad) {\n\t\tUI_LoadMenus(\"ui/ingame.txt\", qtrue);\n\t} else { // bk010222: left this: UI_LoadMenus(menuSet, qtrue);\n\t}\n#else \n\tUI_LoadMenus(menuSet, qtrue);\n\tUI_LoadMenus(\"ui/ingame.txt\", qfalse);\n#endif\n\t\n\tMenus_CloseAll();\n\n\ttrap_LAN_LoadCachedServers();\n\tUI_LoadBestScores(uiInfo.mapList[ui_currentMap.integer].mapLoadName, uiInfo.gameTypes[ui_gameType.integer].gtEnum);\n\n\tUI_BuildQ3Model_List();\n\tUI_LoadBots();\n\n\t// sets defaults for ui temp cvars\n\tuiInfo.effectsColor = gamecodetoui[(int)trap_Cvar_VariableValue(\"color1\")-1];\n\tuiInfo.currentCrosshair = (int)trap_Cvar_VariableValue(\"cg_drawCrosshair\");\n\ttrap_Cvar_Set(\"ui_mousePitch\", (trap_Cvar_VariableValue(\"m_pitch\") >= 0) ? \"0\" : \"1\");\n\n\tuiInfo.serverStatus.currentServerCinematic = -1;\n\tuiInfo.previewMovie = -1;\n\n\tif (trap_Cvar_VariableValue(\"ui_TeamArenaFirstRun\") == 0) {\n\t\ttrap_Cvar_Set(\"s_volume\", \"0.8\");\n\t\ttrap_Cvar_Set(\"s_musicvolume\", \"0.5\");\n\t\ttrap_Cvar_Set(\"ui_TeamArenaFirstRun\", \"1\");\n\t}\n\n\ttrap_Cvar_Register(NULL, \"debug_protocol\", \"\", 0 );\n\n\ttrap_Cvar_Set(\"ui_actualNetGameType\", va(\"%d\", ui_netGameType.integer));\n}\n\n\n/*\n=================\nUI_KeyEvent\n=================\n*/\nvoid _UI_KeyEvent( int key, qboolean down ) {\n\n  if (Menu_Count() > 0) {\n    menuDef_t *menu = Menu_GetFocused();\n\t\tif (menu) {\n\t\t\tif (key == K_ESCAPE && down && !Menus_AnyFullScreenVisible()) {\n\t\t\t\tMenus_CloseAll();\n\t\t\t} else {\n\t\t\t\tMenu_HandleKey(menu, key, down );\n\t\t\t}\n\t\t} else {\n\t\t\ttrap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI );\n\t\t\ttrap_Key_ClearStates();\n\t\t\ttrap_Cvar_Set( \"cl_paused\", \"0\" );\n\t\t}\n  }\n\n  //if ((s > 0) && (s != menu_null_sound)) {\n\t//  trap_S_StartLocalSound( s, CHAN_LOCAL_SOUND );\n  //}\n}\n\n/*\n=================\nUI_MouseEvent\n=================\n*/\nvoid _UI_MouseEvent( int dx, int dy )\n{\n\t// update mouse screen position\n\tuiInfo.uiDC.cursorx += dx;\n\tif (uiInfo.uiDC.cursorx < 0)\n\t\tuiInfo.uiDC.cursorx = 0;\n\telse if (uiInfo.uiDC.cursorx > SCREEN_WIDTH)\n\t\tuiInfo.uiDC.cursorx = SCREEN_WIDTH;\n\n\tuiInfo.uiDC.cursory += dy;\n\tif (uiInfo.uiDC.cursory < 0)\n\t\tuiInfo.uiDC.cursory = 0;\n\telse if (uiInfo.uiDC.cursory > SCREEN_HEIGHT)\n\t\tuiInfo.uiDC.cursory = SCREEN_HEIGHT;\n\n  if (Menu_Count() > 0) {\n    //menuDef_t *menu = Menu_GetFocused();\n    //Menu_HandleMouseMove(menu, uiInfo.uiDC.cursorx, uiInfo.uiDC.cursory);\n\t\tDisplay_MouseMove(NULL, uiInfo.uiDC.cursorx, uiInfo.uiDC.cursory);\n  }\n\n}\n\nvoid UI_LoadNonIngame() {\n\tconst char *menuSet = UI_Cvar_VariableString(\"ui_menuFiles\");\n\tif (menuSet == NULL || menuSet[0] == '\\0') {\n\t\tmenuSet = \"ui/menus.txt\";\n\t}\n\tUI_LoadMenus(menuSet, qfalse);\n\tuiInfo.inGameLoad = qfalse;\n}\n\nvoid _UI_SetActiveMenu( uiMenuCommand_t menu ) {\n\tchar buf[256];\n\n\t// this should be the ONLY way the menu system is brought up\n\t// enusure minumum menu data is cached\n  if (Menu_Count() > 0) {\n\t\tvec3_t v;\n\t\tv[0] = v[1] = v[2] = 0;\n\t  switch ( menu ) {\n\t  case UIMENU_NONE:\n\t\t\ttrap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI );\n\t\t\ttrap_Key_ClearStates();\n\t\t\ttrap_Cvar_Set( \"cl_paused\", \"0\" );\n\t\t\tMenus_CloseAll();\n\n\t\t  return;\n\t  case UIMENU_MAIN:\n\t\t\t//trap_Cvar_Set( \"sv_killserver\", \"1\" );\n\t\t\ttrap_Key_SetCatcher( KEYCATCH_UI );\n\t\t\t//trap_S_StartLocalSound( trap_S_RegisterSound(\"sound/misc/menu_background.wav\", qfalse) , CHAN_LOCAL_SOUND );\n\t\t\t//trap_S_StartBackgroundTrack(\"sound/misc/menu_background.wav\", NULL);\n\t\t\tif (uiInfo.inGameLoad) {\n\t\t\t\tUI_LoadNonIngame();\n\t\t\t}\n\t\t\tMenus_CloseAll();\n\t\t\tMenus_ActivateByName(\"main\");\n\t\t\ttrap_Cvar_VariableStringBuffer(\"com_errorMessage\", buf, sizeof(buf));\n\t\t\tif (strlen(buf)) {\n\t\t\t\tif (!ui_singlePlayerActive.integer) {\n\t\t\t\t\tMenus_ActivateByName(\"error_popmenu\");\n\t\t\t\t} else {\n\t\t\t\t\ttrap_Cvar_Set(\"com_errorMessage\", \"\");\n\t\t\t\t}\n\t\t\t}\n\t\t  return;\n\t  case UIMENU_TEAM:\n\t\t\ttrap_Key_SetCatcher( KEYCATCH_UI );\n      Menus_ActivateByName(\"team\");\n\t\t  return;\n\t  case UIMENU_NEED_CD:\n\t\t\t// no cd check in TA\n\t\t\t//trap_Key_SetCatcher( KEYCATCH_UI );\n      //Menus_ActivateByName(\"needcd\");\n\t\t  //UI_ConfirmMenu( \"Insert the CD\", NULL, NeedCDAction );\n\t\t  return;\n\t  case UIMENU_BAD_CD_KEY:\n\t\t\t// no cd check in TA\n\t\t\t//trap_Key_SetCatcher( KEYCATCH_UI );\n      //Menus_ActivateByName(\"badcd\");\n\t\t  //UI_ConfirmMenu( \"Bad CD Key\", NULL, NeedCDKeyAction );\n\t\t  return;\n\t  case UIMENU_POSTGAME:\n\t\t\t//trap_Cvar_Set( \"sv_killserver\", \"1\" );\n\t\t\ttrap_Key_SetCatcher( KEYCATCH_UI );\n\t\t\tif (uiInfo.inGameLoad) {\n\t\t\t\tUI_LoadNonIngame();\n\t\t\t}\n\t\t\tMenus_CloseAll();\n\t\t\tMenus_ActivateByName(\"endofgame\");\n\t\t  //UI_ConfirmMenu( \"Bad CD Key\", NULL, NeedCDKeyAction );\n\t\t  return;\n\t  case UIMENU_INGAME:\n\t\t  trap_Cvar_Set( \"cl_paused\", \"1\" );\n\t\t\ttrap_Key_SetCatcher( KEYCATCH_UI );\n\t\t\tUI_BuildPlayerList();\n\t\t\tMenus_CloseAll();\n\t\t\tMenus_ActivateByName(\"ingame\");\n\t\t  return;\n\t  }\n  }\n}\n\nqboolean _UI_IsFullscreen( void ) {\n\treturn Menus_AnyFullScreenVisible();\n}\n\n\n\nstatic connstate_t\tlastConnState;\nstatic char\t\t\tlastLoadingText[MAX_INFO_VALUE];\n\nstatic void UI_ReadableSize ( char *buf, int bufsize, int value )\n{\n\tif (value > 1024*1024*1024 ) { // gigs\n\t\tCom_sprintf( buf, bufsize, \"%d\", value / (1024*1024*1024) );\n\t\tCom_sprintf( buf+strlen(buf), bufsize-strlen(buf), \".%02d GB\", \n\t\t\t(value % (1024*1024*1024))*100 / (1024*1024*1024) );\n\t} else if (value > 1024*1024 ) { // megs\n\t\tCom_sprintf( buf, bufsize, \"%d\", value / (1024*1024) );\n\t\tCom_sprintf( buf+strlen(buf), bufsize-strlen(buf), \".%02d MB\", \n\t\t\t(value % (1024*1024))*100 / (1024*1024) );\n\t} else if (value > 1024 ) { // kilos\n\t\tCom_sprintf( buf, bufsize, \"%d KB\", value / 1024 );\n\t} else { // bytes\n\t\tCom_sprintf( buf, bufsize, \"%d bytes\", value );\n\t}\n}\n\n// Assumes time is in msec\nstatic void UI_PrintTime ( char *buf, int bufsize, int time ) {\n\ttime /= 1000;  // change to seconds\n\n\tif (time > 3600) { // in the hours range\n\t\tCom_sprintf( buf, bufsize, \"%d hr %d min\", time / 3600, (time % 3600) / 60 );\n\t} else if (time > 60) { // mins\n\t\tCom_sprintf( buf, bufsize, \"%d min %d sec\", time / 60, time % 60 );\n\t} else  { // secs\n\t\tCom_sprintf( buf, bufsize, \"%d sec\", time );\n\t}\n}\n\nvoid Text_PaintCenter(float x, float y, float scale, vec4_t color, const char *text, float adjust) {\n\tint len = Text_Width(text, scale, 0);\n\tText_Paint(x - len / 2, y, scale, color, text, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE);\n}\n\nvoid Text_PaintCenter_AutoWrapped(float x, float y, float xmax, float ystep, float scale, vec4_t color, const char *str, float adjust) {\n\tint width;\n\tchar *s1,*s2,*s3;\n\tchar c_bcp;\n\tchar buf[1024];\n\n\tif (!str || str[0]=='\\0')\n\t\treturn;\n\n\tQ_strncpyz(buf, str, sizeof(buf));\n\ts1 = s2 = s3 = buf;\n\n\twhile (1) {\n\t\tdo {\n\t\t\ts3++;\n\t\t} while (*s3!=' ' && *s3!='\\0');\n\t\tc_bcp = *s3;\n\t\t*s3 = '\\0';\n\t\twidth = Text_Width(s1, scale, 0);\n\t\t*s3 = c_bcp;\n\t\tif (width > xmax) {\n\t\t\tif (s1==s2)\n\t\t\t{\n\t\t\t\t// fuck, don't have a clean cut, we'll overflow\n\t\t\t\ts2 = s3;\n\t\t\t}\n\t\t\t*s2 = '\\0';\n\t\t\tText_PaintCenter(x, y, scale, color, s1, adjust);\n\t\t\ty += ystep;\n\t\t\tif (c_bcp == '\\0')\n      {\n\t\t\t\t// that was the last word\n        // we could start a new loop, but that wouldn't be much use\n        // even if the word is too long, we would overflow it (see above)\n        // so just print it now if needed\n        s2++;\n        if (*s2 != '\\0') // if we are printing an overflowing line we have s2 == s3\n          Text_PaintCenter(x, y, scale, color, s2, adjust);\n        break;\n      }\n\t\t\ts2++;\n\t\t\ts1 = s2;\n\t\t\ts3 = s2;\n\t\t}\n\t\telse\n\t\t{\n\t\t\ts2 = s3;\n\t\t\tif (c_bcp == '\\0') // we reached the end\n\t\t\t{\n\t\t\t\tText_PaintCenter(x, y, scale, color, s1, adjust);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\nstatic void UI_DisplayDownloadInfo( const char *downloadName, float centerPoint, float yStart, float scale ) {\n\tstatic char dlText[]\t= \"Downloading:\";\n\tstatic char etaText[]\t= \"Estimated time left:\";\n\tstatic char xferText[]\t= \"Transfer rate:\";\n\n\tint downloadSize, downloadCount, downloadTime;\n\tchar dlSizeBuf[64], totalSizeBuf[64], xferRateBuf[64], dlTimeBuf[64];\n\tint xferRate;\n\tint leftWidth;\n\tconst char *s;\n\n\tdownloadSize = trap_Cvar_VariableValue( \"cl_downloadSize\" );\n\tdownloadCount = trap_Cvar_VariableValue( \"cl_downloadCount\" );\n\tdownloadTime = trap_Cvar_VariableValue( \"cl_downloadTime\" );\n\n\tleftWidth = 320;\n\n\tUI_SetColor(colorWhite);\n\tText_PaintCenter(centerPoint, yStart + 112, scale, colorWhite, dlText, 0);\n\tText_PaintCenter(centerPoint, yStart + 192, scale, colorWhite, etaText, 0);\n\tText_PaintCenter(centerPoint, yStart + 248, scale, colorWhite, xferText, 0);\n\n\tif (downloadSize > 0) {\n\t\ts = va( \"%s (%d%%)\", downloadName, downloadCount * 100 / downloadSize );\n\t} else {\n\t\ts = downloadName;\n\t}\n\n\tText_PaintCenter(centerPoint, yStart+136, scale, colorWhite, s, 0);\n\n\tUI_ReadableSize( dlSizeBuf,\t\tsizeof dlSizeBuf,\t\tdownloadCount );\n\tUI_ReadableSize( totalSizeBuf,\tsizeof totalSizeBuf,\tdownloadSize );\n\n\tif (downloadCount < 4096 || !downloadTime) {\n\t\tText_PaintCenter(leftWidth, yStart+216, scale, colorWhite, \"estimating\", 0);\n\t\tText_PaintCenter(leftWidth, yStart+160, scale, colorWhite, va(\"(%s of %s copied)\", dlSizeBuf, totalSizeBuf), 0);\n\t} else {\n\t\tif ((uiInfo.uiDC.realTime - downloadTime) / 1000) {\n\t\t\txferRate = downloadCount / ((uiInfo.uiDC.realTime - downloadTime) / 1000);\n\t\t} else {\n\t\t\txferRate = 0;\n\t\t}\n\t\tUI_ReadableSize( xferRateBuf, sizeof xferRateBuf, xferRate );\n\n\t\t// Extrapolate estimated completion time\n\t\tif (downloadSize && xferRate) {\n\t\t\tint n = downloadSize / xferRate; // estimated time for entire d/l in secs\n\n\t\t\t// We do it in K (/1024) because we'd overflow around 4MB\n\t\t\tUI_PrintTime ( dlTimeBuf, sizeof dlTimeBuf, \n\t\t\t\t(n - (((downloadCount/1024) * n) / (downloadSize/1024))) * 1000);\n\n\t\t\tText_PaintCenter(leftWidth, yStart+216, scale, colorWhite, dlTimeBuf, 0);\n\t\t\tText_PaintCenter(leftWidth, yStart+160, scale, colorWhite, va(\"(%s of %s copied)\", dlSizeBuf, totalSizeBuf), 0);\n\t\t} else {\n\t\t\tText_PaintCenter(leftWidth, yStart+216, scale, colorWhite, \"estimating\", 0);\n\t\t\tif (downloadSize) {\n\t\t\t\tText_PaintCenter(leftWidth, yStart+160, scale, colorWhite, va(\"(%s of %s copied)\", dlSizeBuf, totalSizeBuf), 0);\n\t\t\t} else {\n\t\t\t\tText_PaintCenter(leftWidth, yStart+160, scale, colorWhite, va(\"(%s copied)\", dlSizeBuf), 0);\n\t\t\t}\n\t\t}\n\n\t\tif (xferRate) {\n\t\t\tText_PaintCenter(leftWidth, yStart+272, scale, colorWhite, va(\"%s/Sec\", xferRateBuf), 0);\n\t\t}\n\t}\n}\n\n/*\n========================\nUI_DrawConnectScreen\n\nThis will also be overlaid on the cgame info screen during loading\nto prevent it from blinking away too rapidly on local or lan games.\n========================\n*/\nvoid UI_DrawConnectScreen( qboolean overlay ) {\n\tchar\t\t\t*s;\n\tuiClientState_t\tcstate;\n\tchar\t\t\tinfo[MAX_INFO_VALUE];\n\tchar text[256];\n\tfloat centerPoint, yStart, scale;\n\t\n\tmenuDef_t *menu = Menus_FindByName(\"Connect\");\n\n\n\tif ( !overlay && menu ) {\n\t\tMenu_Paint(menu, qtrue);\n\t}\n\n\tif (!overlay) {\n\t\tcenterPoint = 320;\n\t\tyStart = 130;\n\t\tscale = 0.5f;\n\t} else {\n\t\tcenterPoint = 320;\n\t\tyStart = 32;\n\t\tscale = 0.6f;\n\t\treturn;\n\t}\n\n\t// see what information we should display\n\ttrap_GetClientState( &cstate );\n\n\tinfo[0] = '\\0';\n\tif( trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) ) ) {\n\t\tText_PaintCenter(centerPoint, yStart, scale, colorWhite, va( \"Loading %s\", Info_ValueForKey( info, \"mapname\" )), 0);\n\t}\n\n\tif (!Q_stricmp(cstate.servername,\"localhost\")) {\n\t\tText_PaintCenter(centerPoint, yStart + 48, scale, colorWhite, va(\"Starting up...\"), ITEM_TEXTSTYLE_SHADOWEDMORE);\n\t} else {\n\t\tstrcpy(text, va(\"Connecting to %s\", cstate.servername));\n\t\tText_PaintCenter(centerPoint, yStart + 48, scale, colorWhite,text , ITEM_TEXTSTYLE_SHADOWEDMORE);\n\t}\n\n\t// display global MOTD at bottom\n\tText_PaintCenter(centerPoint, 600, scale, colorWhite, Info_ValueForKey( cstate.updateInfoString, \"motd\" ), 0);\n\t// print any server info (server full, bad version, etc)\n\tif ( cstate.connState < CA_CONNECTED ) {\n\t\tText_PaintCenter_AutoWrapped(centerPoint, yStart + 176, 630, 20, scale, colorWhite, cstate.messageString, 0);\n\t}\n\n\tif ( lastConnState > cstate.connState ) {\n\t\tlastLoadingText[0] = '\\0';\n\t}\n\tlastConnState = cstate.connState;\n\n\tswitch ( cstate.connState ) {\n\tcase CA_CONNECTING:\n\t\ts = va(\"Awaiting connection...%i\", cstate.connectPacketCount);\n\t\tbreak;\n\tcase CA_CHALLENGING:\n\t\ts = va(\"Awaiting challenge...%i\", cstate.connectPacketCount);\n\t\tbreak;\n\tcase CA_CONNECTED: {\n\t\tchar downloadName[MAX_INFO_VALUE];\n\n\t\t\ttrap_Cvar_VariableStringBuffer( \"cl_downloadName\", downloadName, sizeof(downloadName) );\n\t\t\tif (*downloadName) {\n\t\t\t\tUI_DisplayDownloadInfo( downloadName, centerPoint, yStart, scale );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\ts = \"Awaiting gamestate...\";\n\t\tbreak;\n\tcase CA_LOADING:\n\t\treturn;\n\tcase CA_PRIMED:\n\t\treturn;\n\tdefault:\n\t\treturn;\n\t}\n\n\n\tif (Q_stricmp(cstate.servername,\"localhost\")) {\n\t\tText_PaintCenter(centerPoint, yStart + 80, scale, colorWhite, s, 0);\n\t}\n\n\t// password required / connection rejected information goes here\n}\n\n\n/*\n================\ncvars\n================\n*/\n\ntypedef struct {\n\tvmCvar_t\t*vmCvar;\n\tchar\t\t*cvarName;\n\tchar\t\t*defaultString;\n\tint\t\t\tcvarFlags;\n} cvarTable_t;\n\nvmCvar_t\tui_ffa_fraglimit;\nvmCvar_t\tui_ffa_timelimit;\n\nvmCvar_t\tui_tourney_fraglimit;\nvmCvar_t\tui_tourney_timelimit;\n\nvmCvar_t\tui_team_fraglimit;\nvmCvar_t\tui_team_timelimit;\nvmCvar_t\tui_team_friendly;\n\nvmCvar_t\tui_ctf_capturelimit;\nvmCvar_t\tui_ctf_timelimit;\nvmCvar_t\tui_ctf_friendly;\n\nvmCvar_t\tui_arenasFile;\nvmCvar_t\tui_botsFile;\nvmCvar_t\tui_spScores1;\nvmCvar_t\tui_spScores2;\nvmCvar_t\tui_spScores3;\nvmCvar_t\tui_spScores4;\nvmCvar_t\tui_spScores5;\nvmCvar_t\tui_spAwards;\nvmCvar_t\tui_spVideos;\nvmCvar_t\tui_spSkill;\n\nvmCvar_t\tui_spSelection;\n\nvmCvar_t\tui_browserMaster;\nvmCvar_t\tui_browserGameType;\nvmCvar_t\tui_browserSortKey;\nvmCvar_t\tui_browserShowFull;\nvmCvar_t\tui_browserShowEmpty;\n\nvmCvar_t\tui_brassTime;\nvmCvar_t\tui_drawCrosshair;\nvmCvar_t\tui_drawCrosshairNames;\nvmCvar_t\tui_marks;\n\nvmCvar_t\tui_server1;\nvmCvar_t\tui_server2;\nvmCvar_t\tui_server3;\nvmCvar_t\tui_server4;\nvmCvar_t\tui_server5;\nvmCvar_t\tui_server6;\nvmCvar_t\tui_server7;\nvmCvar_t\tui_server8;\nvmCvar_t\tui_server9;\nvmCvar_t\tui_server10;\nvmCvar_t\tui_server11;\nvmCvar_t\tui_server12;\nvmCvar_t\tui_server13;\nvmCvar_t\tui_server14;\nvmCvar_t\tui_server15;\nvmCvar_t\tui_server16;\n\nvmCvar_t\tui_cdkeychecked;\n\nvmCvar_t\tui_redteam;\nvmCvar_t\tui_redteam1;\nvmCvar_t\tui_redteam2;\nvmCvar_t\tui_redteam3;\nvmCvar_t\tui_redteam4;\nvmCvar_t\tui_redteam5;\nvmCvar_t\tui_blueteam;\nvmCvar_t\tui_blueteam1;\nvmCvar_t\tui_blueteam2;\nvmCvar_t\tui_blueteam3;\nvmCvar_t\tui_blueteam4;\nvmCvar_t\tui_blueteam5;\nvmCvar_t\tui_teamName;\nvmCvar_t\tui_dedicated;\nvmCvar_t\tui_gameType;\nvmCvar_t\tui_netGameType;\nvmCvar_t\tui_actualNetGameType;\nvmCvar_t\tui_joinGameType;\nvmCvar_t\tui_netSource;\nvmCvar_t\tui_serverFilterType;\nvmCvar_t\tui_opponentName;\nvmCvar_t\tui_menuFiles;\nvmCvar_t\tui_currentTier;\nvmCvar_t\tui_currentMap;\nvmCvar_t\tui_currentNetMap;\nvmCvar_t\tui_mapIndex;\nvmCvar_t\tui_currentOpponent;\nvmCvar_t\tui_selectedPlayer;\nvmCvar_t\tui_selectedPlayerName;\nvmCvar_t\tui_lastServerRefresh_0;\nvmCvar_t\tui_lastServerRefresh_1;\nvmCvar_t\tui_lastServerRefresh_2;\nvmCvar_t\tui_lastServerRefresh_3;\nvmCvar_t\tui_singlePlayerActive;\nvmCvar_t\tui_scoreAccuracy;\nvmCvar_t\tui_scoreImpressives;\nvmCvar_t\tui_scoreExcellents;\nvmCvar_t\tui_scoreCaptures;\nvmCvar_t\tui_scoreDefends;\nvmCvar_t\tui_scoreAssists;\nvmCvar_t\tui_scoreGauntlets;\nvmCvar_t\tui_scoreScore;\nvmCvar_t\tui_scorePerfect;\nvmCvar_t\tui_scoreTeam;\nvmCvar_t\tui_scoreBase;\nvmCvar_t\tui_scoreTimeBonus;\nvmCvar_t\tui_scoreSkillBonus;\nvmCvar_t\tui_scoreShutoutBonus;\nvmCvar_t\tui_scoreTime;\nvmCvar_t\tui_captureLimit;\nvmCvar_t\tui_fragLimit;\nvmCvar_t\tui_smallFont;\nvmCvar_t\tui_bigFont;\nvmCvar_t\tui_findPlayer;\nvmCvar_t\tui_Q3Model;\nvmCvar_t\tui_hudFiles;\nvmCvar_t\tui_recordSPDemo;\nvmCvar_t\tui_realCaptureLimit;\nvmCvar_t\tui_realWarmUp;\nvmCvar_t\tui_serverStatusTimeOut;\n\n\n// bk001129 - made static to avoid aliasing\nstatic cvarTable_t\t\tcvarTable[] = {\n\t{ &ui_ffa_fraglimit, \"ui_ffa_fraglimit\", \"20\", CVAR_ARCHIVE },\n\t{ &ui_ffa_timelimit, \"ui_ffa_timelimit\", \"0\", CVAR_ARCHIVE },\n\n\t{ &ui_tourney_fraglimit, \"ui_tourney_fraglimit\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_tourney_timelimit, \"ui_tourney_timelimit\", \"15\", CVAR_ARCHIVE },\n\n\t{ &ui_team_fraglimit, \"ui_team_fraglimit\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_team_timelimit, \"ui_team_timelimit\", \"20\", CVAR_ARCHIVE },\n\t{ &ui_team_friendly, \"ui_team_friendly\",  \"1\", CVAR_ARCHIVE },\n\n\t{ &ui_ctf_capturelimit, \"ui_ctf_capturelimit\", \"8\", CVAR_ARCHIVE },\n\t{ &ui_ctf_timelimit, \"ui_ctf_timelimit\", \"30\", CVAR_ARCHIVE },\n\t{ &ui_ctf_friendly, \"ui_ctf_friendly\",  \"0\", CVAR_ARCHIVE },\n\n\t{ &ui_arenasFile, \"g_arenasFile\", \"\", CVAR_INIT|CVAR_ROM },\n\t{ &ui_botsFile, \"g_botsFile\", \"\", CVAR_INIT|CVAR_ROM },\n\t{ &ui_spScores1, \"g_spScores1\", \"\", CVAR_ARCHIVE | CVAR_ROM },\n\t{ &ui_spScores2, \"g_spScores2\", \"\", CVAR_ARCHIVE | CVAR_ROM },\n\t{ &ui_spScores3, \"g_spScores3\", \"\", CVAR_ARCHIVE | CVAR_ROM },\n\t{ &ui_spScores4, \"g_spScores4\", \"\", CVAR_ARCHIVE | CVAR_ROM },\n\t{ &ui_spScores5, \"g_spScores5\", \"\", CVAR_ARCHIVE | CVAR_ROM },\n\t{ &ui_spAwards, \"g_spAwards\", \"\", CVAR_ARCHIVE | CVAR_ROM },\n\t{ &ui_spVideos, \"g_spVideos\", \"\", CVAR_ARCHIVE | CVAR_ROM },\n\t{ &ui_spSkill, \"g_spSkill\", \"2\", CVAR_ARCHIVE },\n\n\t{ &ui_spSelection, \"ui_spSelection\", \"\", CVAR_ROM },\n\n\t{ &ui_browserMaster, \"ui_browserMaster\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_browserGameType, \"ui_browserGameType\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_browserSortKey, \"ui_browserSortKey\", \"4\", CVAR_ARCHIVE },\n\t{ &ui_browserShowFull, \"ui_browserShowFull\", \"1\", CVAR_ARCHIVE },\n\t{ &ui_browserShowEmpty, \"ui_browserShowEmpty\", \"1\", CVAR_ARCHIVE },\n\n\t{ &ui_brassTime, \"cg_brassTime\", \"2500\", CVAR_ARCHIVE },\n\t{ &ui_drawCrosshair, \"cg_drawCrosshair\", \"4\", CVAR_ARCHIVE },\n\t{ &ui_drawCrosshairNames, \"cg_drawCrosshairNames\", \"1\", CVAR_ARCHIVE },\n\t{ &ui_marks, \"cg_marks\", \"1\", CVAR_ARCHIVE },\n\n\t{ &ui_server1, \"server1\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server2, \"server2\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server3, \"server3\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server4, \"server4\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server5, \"server5\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server6, \"server6\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server7, \"server7\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server8, \"server8\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server9, \"server9\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server10, \"server10\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server11, \"server11\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server12, \"server12\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server13, \"server13\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server14, \"server14\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server15, \"server15\", \"\", CVAR_ARCHIVE },\n\t{ &ui_server16, \"server16\", \"\", CVAR_ARCHIVE },\n\t{ &ui_cdkeychecked, \"ui_cdkeychecked\", \"0\", CVAR_ROM },\n\t{ &ui_new, \"ui_new\", \"0\", CVAR_TEMP },\n\t{ &ui_debug, \"ui_debug\", \"0\", CVAR_TEMP },\n\t{ &ui_initialized, \"ui_initialized\", \"0\", CVAR_TEMP },\n\t{ &ui_teamName, \"ui_teamName\", \"Pagans\", CVAR_ARCHIVE },\n\t{ &ui_opponentName, \"ui_opponentName\", \"Stroggs\", CVAR_ARCHIVE },\n\t{ &ui_redteam, \"ui_redteam\", \"Pagans\", CVAR_ARCHIVE },\n\t{ &ui_blueteam, \"ui_blueteam\", \"Stroggs\", CVAR_ARCHIVE },\n\t{ &ui_dedicated, \"ui_dedicated\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_gameType, \"ui_gametype\", \"3\", CVAR_ARCHIVE },\n\t{ &ui_joinGameType, \"ui_joinGametype\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_netGameType, \"ui_netGametype\", \"3\", CVAR_ARCHIVE },\n\t{ &ui_actualNetGameType, \"ui_actualNetGametype\", \"3\", CVAR_ARCHIVE },\n\t{ &ui_redteam1, \"ui_redteam1\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_redteam2, \"ui_redteam2\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_redteam3, \"ui_redteam3\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_redteam4, \"ui_redteam4\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_redteam5, \"ui_redteam5\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_blueteam1, \"ui_blueteam1\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_blueteam2, \"ui_blueteam2\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_blueteam3, \"ui_blueteam3\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_blueteam4, \"ui_blueteam4\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_blueteam5, \"ui_blueteam5\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_netSource, \"ui_netSource\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_menuFiles, \"ui_menuFiles\", \"ui/menus.txt\", CVAR_ARCHIVE },\n\t{ &ui_currentTier, \"ui_currentTier\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_currentMap, \"ui_currentMap\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_currentNetMap, \"ui_currentNetMap\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_mapIndex, \"ui_mapIndex\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_currentOpponent, \"ui_currentOpponent\", \"0\", CVAR_ARCHIVE },\n\t{ &ui_selectedPlayer, \"cg_selectedPlayer\", \"0\", CVAR_ARCHIVE},\n\t{ &ui_selectedPlayerName, \"cg_selectedPlayerName\", \"\", CVAR_ARCHIVE},\n\t{ &ui_lastServerRefresh_0, \"ui_lastServerRefresh_0\", \"\", CVAR_ARCHIVE},\n\t{ &ui_lastServerRefresh_1, \"ui_lastServerRefresh_1\", \"\", CVAR_ARCHIVE},\n\t{ &ui_lastServerRefresh_2, \"ui_lastServerRefresh_2\", \"\", CVAR_ARCHIVE},\n\t{ &ui_lastServerRefresh_3, \"ui_lastServerRefresh_3\", \"\", CVAR_ARCHIVE},\n\t{ &ui_singlePlayerActive, \"ui_singlePlayerActive\", \"0\", 0},\n\t{ &ui_scoreAccuracy, \"ui_scoreAccuracy\", \"0\", CVAR_ARCHIVE},\n\t{ &ui_scoreImpressives, \"ui_scoreImpressives\", \"0\", CVAR_ARCHIVE},\n\t{ &ui_scoreExcellents, \"ui_scoreExcellents\", \"0\", CVAR_ARCHIVE},\n\t{ &ui_scoreCaptures, \"ui_scoreCaptures\", \"0\", CVAR_ARCHIVE},\n\t{ &ui_scoreDefends, \"ui_scoreDefends\", \"0\", CVAR_ARCHIVE},\n\t{ &ui_scoreAssists, \"ui_scoreAssists\", \"0\", CVAR_ARCHIVE},\n\t{ &ui_scoreGauntlets, \"ui_scoreGauntlets\", \"0\",CVAR_ARCHIVE},\n\t{ &ui_scoreScore, \"ui_scoreScore\", \"0\", CVAR_ARCHIVE},\n\t{ &ui_scorePerfect, \"ui_scorePerfect\", \"0\", CVAR_ARCHIVE},\n\t{ &ui_scoreTeam, \"ui_scoreTeam\", \"0 to 0\", CVAR_ARCHIVE},\n\t{ &ui_scoreBase, \"ui_scoreBase\", \"0\", CVAR_ARCHIVE},\n\t{ &ui_scoreTime, \"ui_scoreTime\", \"00:00\", CVAR_ARCHIVE},\n\t{ &ui_scoreTimeBonus, \"ui_scoreTimeBonus\", \"0\", CVAR_ARCHIVE},\n\t{ &ui_scoreSkillBonus, \"ui_scoreSkillBonus\", \"0\", CVAR_ARCHIVE},\n\t{ &ui_scoreShutoutBonus, \"ui_scoreShutoutBonus\", \"0\", CVAR_ARCHIVE},\n\t{ &ui_fragLimit, \"ui_fragLimit\", \"10\", 0},\n\t{ &ui_captureLimit, \"ui_captureLimit\", \"5\", 0},\n\t{ &ui_smallFont, \"ui_smallFont\", \"0.25\", CVAR_ARCHIVE},\n\t{ &ui_bigFont, \"ui_bigFont\", \"0.4\", CVAR_ARCHIVE},\n\t{ &ui_findPlayer, \"ui_findPlayer\", \"Sarge\", CVAR_ARCHIVE},\n\t{ &ui_Q3Model, \"ui_q3model\", \"0\", CVAR_ARCHIVE},\n\t{ &ui_hudFiles, \"cg_hudFiles\", \"ui/hud.txt\", CVAR_ARCHIVE},\n\t{ &ui_recordSPDemo, \"ui_recordSPDemo\", \"0\", CVAR_ARCHIVE},\n\t{ &ui_teamArenaFirstRun, \"ui_teamArenaFirstRun\", \"0\", CVAR_ARCHIVE},\n\t{ &ui_realWarmUp, \"g_warmup\", \"20\", CVAR_ARCHIVE},\n\t{ &ui_realCaptureLimit, \"capturelimit\", \"8\", CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_NORESTART},\n\t{ &ui_serverStatusTimeOut, \"ui_serverStatusTimeOut\", \"7000\", CVAR_ARCHIVE},\n\n};\n\n// bk001129 - made static to avoid aliasing\nstatic int\t\tcvarTableSize = sizeof(cvarTable) / sizeof(cvarTable[0]);\n\n\n/*\n=================\nUI_RegisterCvars\n=================\n*/\nvoid UI_RegisterCvars( void ) {\n\tint\t\t\ti;\n\tcvarTable_t\t*cv;\n\n\tfor ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {\n\t\ttrap_Cvar_Register( cv->vmCvar, cv->cvarName, cv->defaultString, cv->cvarFlags );\n\t}\n}\n\n/*\n=================\nUI_UpdateCvars\n=================\n*/\nvoid UI_UpdateCvars( void ) {\n\tint\t\t\ti;\n\tcvarTable_t\t*cv;\n\n\tfor ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {\n\t\ttrap_Cvar_Update( cv->vmCvar );\n\t}\n}\n\n\n/*\n=================\nArenaServers_StopRefresh\n=================\n*/\nstatic void UI_StopServerRefresh( void )\n{\n\tint count;\n\n\tif (!uiInfo.serverStatus.refreshActive) {\n\t\t// not currently refreshing\n\t\treturn;\n\t}\n\tuiInfo.serverStatus.refreshActive = qfalse;\n\tCom_Printf(\"%d servers listed in browser with %d players.\\n\",\n\t\t\t\t\tuiInfo.serverStatus.numDisplayServers,\n\t\t\t\t\tuiInfo.serverStatus.numPlayersOnServers);\n\tcount = trap_LAN_GetServerCount(ui_netSource.integer);\n\tif (count - uiInfo.serverStatus.numDisplayServers > 0) {\n\t\tCom_Printf(\"%d servers not listed due to packet loss or pings higher than %d\\n\",\n\t\t\t\t\t\tcount - uiInfo.serverStatus.numDisplayServers,\n\t\t\t\t\t\t(int) trap_Cvar_VariableValue(\"cl_maxPing\"));\n\t}\n\n}\n\n/*\n=================\nArenaServers_MaxPing\n=================\n*/\n#ifndef MISSIONPACK // bk001206\nstatic int ArenaServers_MaxPing( void ) {\n\tint\t\tmaxPing;\n\n\tmaxPing = (int)trap_Cvar_VariableValue( \"cl_maxPing\" );\n\tif( maxPing < 100 ) {\n\t\tmaxPing = 100;\n\t}\n\treturn maxPing;\n}\n#endif\n\n/*\n=================\nUI_DoServerRefresh\n=================\n*/\nstatic void UI_DoServerRefresh( void )\n{\n\tqboolean wait = qfalse;\n\n\tif (!uiInfo.serverStatus.refreshActive) {\n\t\treturn;\n\t}\n\tif (ui_netSource.integer != AS_FAVORITES) {\n\t\tif (ui_netSource.integer == AS_LOCAL) {\n\t\t\tif (!trap_LAN_GetServerCount(ui_netSource.integer)) {\n\t\t\t\twait = qtrue;\n\t\t\t}\n\t\t} else {\n\t\t\tif (trap_LAN_GetServerCount(ui_netSource.integer) < 0) {\n\t\t\t\twait = qtrue;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (uiInfo.uiDC.realTime < uiInfo.serverStatus.refreshtime) {\n\t\tif (wait) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// if still trying to retrieve pings\n\tif (trap_LAN_UpdateVisiblePings(ui_netSource.integer)) {\n\t\tuiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 1000;\n\t} else if (!wait) {\n\t\t// get the last servers in the list\n\t\tUI_BuildServerDisplayList(2);\n\t\t// stop the refresh\n\t\tUI_StopServerRefresh();\n\t}\n\t//\n\tUI_BuildServerDisplayList(qfalse);\n}\n\n/*\n=================\nUI_StartServerRefresh\n=================\n*/\nstatic void UI_StartServerRefresh(qboolean full)\n{\n\tint\t\ti;\n\tchar\t*ptr;\n\n\tqtime_t q;\n\ttrap_RealTime(&q);\n \ttrap_Cvar_Set( va(\"ui_lastServerRefresh_%i\", ui_netSource.integer), va(\"%s-%i, %i at %i:%i\", MonthAbbrev[q.tm_mon],q.tm_mday, 1900+q.tm_year,q.tm_hour,q.tm_min));\n\n\tif (!full) {\n\t\tUI_UpdatePendingPings();\n\t\treturn;\n\t}\n\n\tuiInfo.serverStatus.refreshActive = qtrue;\n\tuiInfo.serverStatus.nextDisplayRefresh = uiInfo.uiDC.realTime + 1000;\n\t// clear number of displayed servers\n\tuiInfo.serverStatus.numDisplayServers = 0;\n\tuiInfo.serverStatus.numPlayersOnServers = 0;\n\t// mark all servers as visible so we store ping updates for them\n\ttrap_LAN_MarkServerVisible(ui_netSource.integer, -1, qtrue);\n\t// reset all the pings\n\ttrap_LAN_ResetPings(ui_netSource.integer);\n\t//\n\tif( ui_netSource.integer == AS_LOCAL ) {\n\t\ttrap_Cmd_ExecuteText( EXEC_NOW, \"localservers\\n\" );\n\t\tuiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 1000;\n\t\treturn;\n\t}\n\n\tuiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 5000;\n\tif( ui_netSource.integer == AS_GLOBAL || ui_netSource.integer == AS_MPLAYER ) {\n\t\tif( ui_netSource.integer == AS_GLOBAL ) {\n\t\t\ti = 0;\n\t\t}\n\t\telse {\n\t\t\ti = 1;\n\t\t}\n\n\t\tptr = UI_Cvar_VariableString(\"debug_protocol\");\n\t\tif (strlen(ptr)) {\n\t\t\ttrap_Cmd_ExecuteText( EXEC_NOW, va( \"globalservers %d %s full empty\\n\", i, ptr));\n\t\t}\n\t\telse {\n\t\t\ttrap_Cmd_ExecuteText( EXEC_NOW, va( \"globalservers %d %d full empty\\n\", i, (int)trap_Cvar_VariableValue( \"protocol\" ) ) );\n\t\t}\n\t}\n}\n\n"
  },
  {
    "path": "code/ui/ui_players.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// ui_players.c\n\n#include \"ui_local.h\"\n\n\n#define UI_TIMER_GESTURE\t\t2300\n#define UI_TIMER_JUMP\t\t\t1000\n#define UI_TIMER_LAND\t\t\t130\n#define UI_TIMER_WEAPON_SWITCH\t300\n#define UI_TIMER_ATTACK\t\t\t500\n#define\tUI_TIMER_MUZZLE_FLASH\t20\n#define\tUI_TIMER_WEAPON_DELAY\t250\n\n#define JUMP_HEIGHT\t\t\t\t56\n\n#define SWINGSPEED\t\t\t\t0.3f\n\n#define SPIN_SPEED\t\t\t\t0.9f\n#define COAST_TIME\t\t\t\t1000\n\n\nstatic int\t\t\tdp_realtime;\nstatic float\t\tjumpHeight;\nsfxHandle_t weaponChangeSound;\n\n\n/*\n===============\nUI_PlayerInfo_SetWeapon\n===============\n*/\nstatic void UI_PlayerInfo_SetWeapon( playerInfo_t *pi, weapon_t weaponNum ) {\n\tgitem_t *\titem;\n\tchar\t\tpath[MAX_QPATH];\n\n\tpi->currentWeapon = weaponNum;\ntryagain:\n\tpi->realWeapon = weaponNum;\n\tpi->weaponModel = 0;\n\tpi->barrelModel = 0;\n\tpi->flashModel = 0;\n\n\tif ( weaponNum == WP_NONE ) {\n\t\treturn;\n\t}\n\n\tfor ( item = bg_itemlist + 1; item->classname ; item++ ) {\n\t\tif ( item->giType != IT_WEAPON ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( item->giTag == weaponNum ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif ( item->classname ) {\n\t\tpi->weaponModel = trap_R_RegisterModel( item->world_model[0] );\n\t}\n\n\tif( pi->weaponModel == 0 ) {\n\t\tif( weaponNum == WP_MACHINEGUN ) {\n\t\t\tweaponNum = WP_NONE;\n\t\t\tgoto tryagain;\n\t\t}\n\t\tweaponNum = WP_MACHINEGUN;\n\t\tgoto tryagain;\n\t}\n\n\tif ( weaponNum == WP_MACHINEGUN || weaponNum == WP_GAUNTLET || weaponNum == WP_BFG ) {\n\t\tstrcpy( path, item->world_model[0] );\n\t\tCOM_StripExtension( path, path );\n\t\tstrcat( path, \"_barrel.md3\" );\n\t\tpi->barrelModel = trap_R_RegisterModel( path );\n\t}\n\n\tstrcpy( path, item->world_model[0] );\n\tCOM_StripExtension( path, path );\n\tstrcat( path, \"_flash.md3\" );\n\tpi->flashModel = trap_R_RegisterModel( path );\n\n\tswitch( weaponNum ) {\n\tcase WP_GAUNTLET:\n\t\tMAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 );\n\t\tbreak;\n\n\tcase WP_MACHINEGUN:\n\t\tMAKERGB( pi->flashDlightColor, 1, 1, 0 );\n\t\tbreak;\n\n\tcase WP_SHOTGUN:\n\t\tMAKERGB( pi->flashDlightColor, 1, 1, 0 );\n\t\tbreak;\n\n\tcase WP_GRENADE_LAUNCHER:\n\t\tMAKERGB( pi->flashDlightColor, 1, 0.7f, 0.5f );\n\t\tbreak;\n\n\tcase WP_ROCKET_LAUNCHER:\n\t\tMAKERGB( pi->flashDlightColor, 1, 0.75f, 0 );\n\t\tbreak;\n\n\tcase WP_LIGHTNING:\n\t\tMAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 );\n\t\tbreak;\n\n\tcase WP_RAILGUN:\n\t\tMAKERGB( pi->flashDlightColor, 1, 0.5f, 0 );\n\t\tbreak;\n\n\tcase WP_PLASMAGUN:\n\t\tMAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 );\n\t\tbreak;\n\n\tcase WP_BFG:\n\t\tMAKERGB( pi->flashDlightColor, 1, 0.7f, 1 );\n\t\tbreak;\n\n\tcase WP_GRAPPLING_HOOK:\n\t\tMAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 );\n\t\tbreak;\n\n\tdefault:\n\t\tMAKERGB( pi->flashDlightColor, 1, 1, 1 );\n\t\tbreak;\n\t}\n}\n\n\n/*\n===============\nUI_ForceLegsAnim\n===============\n*/\nstatic void UI_ForceLegsAnim( playerInfo_t *pi, int anim ) {\n\tpi->legsAnim = ( ( pi->legsAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim;\n\n\tif ( anim == LEGS_JUMP ) {\n\t\tpi->legsAnimationTimer = UI_TIMER_JUMP;\n\t}\n}\n\n\n/*\n===============\nUI_SetLegsAnim\n===============\n*/\nstatic void UI_SetLegsAnim( playerInfo_t *pi, int anim ) {\n\tif ( pi->pendingLegsAnim ) {\n\t\tanim = pi->pendingLegsAnim;\n\t\tpi->pendingLegsAnim = 0;\n\t}\n\tUI_ForceLegsAnim( pi, anim );\n}\n\n\n/*\n===============\nUI_ForceTorsoAnim\n===============\n*/\nstatic void UI_ForceTorsoAnim( playerInfo_t *pi, int anim ) {\n\tpi->torsoAnim = ( ( pi->torsoAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim;\n\n\tif ( anim == TORSO_GESTURE ) {\n\t\tpi->torsoAnimationTimer = UI_TIMER_GESTURE;\n\t}\n\n\tif ( anim == TORSO_ATTACK || anim == TORSO_ATTACK2 ) {\n\t\tpi->torsoAnimationTimer = UI_TIMER_ATTACK;\n\t}\n}\n\n\n/*\n===============\nUI_SetTorsoAnim\n===============\n*/\nstatic void UI_SetTorsoAnim( playerInfo_t *pi, int anim ) {\n\tif ( pi->pendingTorsoAnim ) {\n\t\tanim = pi->pendingTorsoAnim;\n\t\tpi->pendingTorsoAnim = 0;\n\t}\n\n\tUI_ForceTorsoAnim( pi, anim );\n}\n\n\n/*\n===============\nUI_TorsoSequencing\n===============\n*/\nstatic void UI_TorsoSequencing( playerInfo_t *pi ) {\n\tint\t\tcurrentAnim;\n\n\tcurrentAnim = pi->torsoAnim & ~ANIM_TOGGLEBIT;\n\n\tif ( pi->weapon != pi->currentWeapon ) {\n\t\tif ( currentAnim != TORSO_DROP ) {\n\t\t\tpi->torsoAnimationTimer = UI_TIMER_WEAPON_SWITCH;\n\t\t\tUI_ForceTorsoAnim( pi, TORSO_DROP );\n\t\t}\n\t}\n\n\tif ( pi->torsoAnimationTimer > 0 ) {\n\t\treturn;\n\t}\n\n\tif( currentAnim == TORSO_GESTURE ) {\n\t\tUI_SetTorsoAnim( pi, TORSO_STAND );\n\t\treturn;\n\t}\n\n\tif( currentAnim == TORSO_ATTACK || currentAnim == TORSO_ATTACK2 ) {\n\t\tUI_SetTorsoAnim( pi, TORSO_STAND );\n\t\treturn;\n\t}\n\n\tif ( currentAnim == TORSO_DROP ) {\n\t\tUI_PlayerInfo_SetWeapon( pi, pi->weapon );\n\t\tpi->torsoAnimationTimer = UI_TIMER_WEAPON_SWITCH;\n\t\tUI_ForceTorsoAnim( pi, TORSO_RAISE );\n\t\treturn;\n\t}\n\n\tif ( currentAnim == TORSO_RAISE ) {\n\t\tUI_SetTorsoAnim( pi, TORSO_STAND );\n\t\treturn;\n\t}\n}\n\n\n/*\n===============\nUI_LegsSequencing\n===============\n*/\nstatic void UI_LegsSequencing( playerInfo_t *pi ) {\n\tint\t\tcurrentAnim;\n\n\tcurrentAnim = pi->legsAnim & ~ANIM_TOGGLEBIT;\n\n\tif ( pi->legsAnimationTimer > 0 ) {\n\t\tif ( currentAnim == LEGS_JUMP ) {\n\t\t\tjumpHeight = JUMP_HEIGHT * sin( M_PI * ( UI_TIMER_JUMP - pi->legsAnimationTimer ) / UI_TIMER_JUMP );\n\t\t}\n\t\treturn;\n\t}\n\n\tif ( currentAnim == LEGS_JUMP ) {\n\t\tUI_ForceLegsAnim( pi, LEGS_LAND );\n\t\tpi->legsAnimationTimer = UI_TIMER_LAND;\n\t\tjumpHeight = 0;\n\t\treturn;\n\t}\n\n\tif ( currentAnim == LEGS_LAND ) {\n\t\tUI_SetLegsAnim( pi, LEGS_IDLE );\n\t\treturn;\n\t}\n}\n\n\n/*\n======================\nUI_PositionEntityOnTag\n======================\n*/\nstatic void UI_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent, \n\t\t\t\t\t\t\tclipHandle_t parentModel, char *tagName ) {\n\tint\t\t\t\ti;\n\torientation_t\tlerped;\n\t\n\t// lerp the tag\n\ttrap_CM_LerpTag( &lerped, parentModel, parent->oldframe, parent->frame,\n\t\t1.0 - parent->backlerp, tagName );\n\n\t// FIXME: allow origin offsets along tag?\n\tVectorCopy( parent->origin, entity->origin );\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tVectorMA( entity->origin, lerped.origin[i], parent->axis[i], entity->origin );\n\t}\n\n\t// cast away const because of compiler problems\n\tMatrixMultiply( lerped.axis, ((refEntity_t*)parent)->axis, entity->axis );\n\tentity->backlerp = parent->backlerp;\n}\n\n\n/*\n======================\nUI_PositionRotatedEntityOnTag\n======================\n*/\nstatic void UI_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *parent, \n\t\t\t\t\t\t\tclipHandle_t parentModel, char *tagName ) {\n\tint\t\t\t\ti;\n\torientation_t\tlerped;\n\tvec3_t\t\t\ttempAxis[3];\n\n\t// lerp the tag\n\ttrap_CM_LerpTag( &lerped, parentModel, parent->oldframe, parent->frame,\n\t\t1.0 - parent->backlerp, tagName );\n\n\t// FIXME: allow origin offsets along tag?\n\tVectorCopy( parent->origin, entity->origin );\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tVectorMA( entity->origin, lerped.origin[i], parent->axis[i], entity->origin );\n\t}\n\n\t// cast away const because of compiler problems\n\tMatrixMultiply( entity->axis, ((refEntity_t *)parent)->axis, tempAxis );\n\tMatrixMultiply( lerped.axis, tempAxis, entity->axis );\n}\n\n\n/*\n===============\nUI_SetLerpFrameAnimation\n===============\n*/\nstatic void UI_SetLerpFrameAnimation( playerInfo_t *ci, lerpFrame_t *lf, int newAnimation ) {\n\tanimation_t\t*anim;\n\n\tlf->animationNumber = newAnimation;\n\tnewAnimation &= ~ANIM_TOGGLEBIT;\n\n\tif ( newAnimation < 0 || newAnimation >= MAX_ANIMATIONS ) {\n\t\ttrap_Error( va(\"Bad animation number: %i\", newAnimation) );\n\t}\n\n\tanim = &ci->animations[ newAnimation ];\n\n\tlf->animation = anim;\n\tlf->animationTime = lf->frameTime + anim->initialLerp;\n}\n\n\n/*\n===============\nUI_RunLerpFrame\n===============\n*/\nstatic void UI_RunLerpFrame( playerInfo_t *ci, lerpFrame_t *lf, int newAnimation ) {\n\tint\t\t\tf;\n\tanimation_t\t*anim;\n\n\t// see if the animation sequence is switching\n\tif ( newAnimation != lf->animationNumber || !lf->animation ) {\n\t\tUI_SetLerpFrameAnimation( ci, lf, newAnimation );\n\t}\n\n\t// if we have passed the current frame, move it to\n\t// oldFrame and calculate a new frame\n\tif ( dp_realtime >= lf->frameTime ) {\n\t\tlf->oldFrame = lf->frame;\n\t\tlf->oldFrameTime = lf->frameTime;\n\n\t\t// get the next frame based on the animation\n\t\tanim = lf->animation;\n\t\tif ( dp_realtime < lf->animationTime ) {\n\t\t\tlf->frameTime = lf->animationTime;\t\t// initial lerp\n\t\t} else {\n\t\t\tlf->frameTime = lf->oldFrameTime + anim->frameLerp;\n\t\t}\n\t\tf = ( lf->frameTime - lf->animationTime ) / anim->frameLerp;\n\t\tif ( f >= anim->numFrames ) {\n\t\t\tf -= anim->numFrames;\n\t\t\tif ( anim->loopFrames ) {\n\t\t\t\tf %= anim->loopFrames;\n\t\t\t\tf += anim->numFrames - anim->loopFrames;\n\t\t\t} else {\n\t\t\t\tf = anim->numFrames - 1;\n\t\t\t\t// the animation is stuck at the end, so it\n\t\t\t\t// can immediately transition to another sequence\n\t\t\t\tlf->frameTime = dp_realtime;\n\t\t\t}\n\t\t}\n\t\tlf->frame = anim->firstFrame + f;\n\t\tif ( dp_realtime > lf->frameTime ) {\n\t\t\tlf->frameTime = dp_realtime;\n\t\t}\n\t}\n\n\tif ( lf->frameTime > dp_realtime + 200 ) {\n\t\tlf->frameTime = dp_realtime;\n\t}\n\n\tif ( lf->oldFrameTime > dp_realtime ) {\n\t\tlf->oldFrameTime = dp_realtime;\n\t}\n\t// calculate current lerp value\n\tif ( lf->frameTime == lf->oldFrameTime ) {\n\t\tlf->backlerp = 0;\n\t} else {\n\t\tlf->backlerp = 1.0 - (float)( dp_realtime - lf->oldFrameTime ) / ( lf->frameTime - lf->oldFrameTime );\n\t}\n}\n\n\n/*\n===============\nUI_PlayerAnimation\n===============\n*/\nstatic void UI_PlayerAnimation( playerInfo_t *pi, int *legsOld, int *legs, float *legsBackLerp,\n\t\t\t\t\t\tint *torsoOld, int *torso, float *torsoBackLerp ) {\n\n\t// legs animation\n\tpi->legsAnimationTimer -= uiInfo.uiDC.frameTime;\n\tif ( pi->legsAnimationTimer < 0 ) {\n\t\tpi->legsAnimationTimer = 0;\n\t}\n\n\tUI_LegsSequencing( pi );\n\n\tif ( pi->legs.yawing && ( pi->legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_IDLE ) {\n\t\tUI_RunLerpFrame( pi, &pi->legs, LEGS_TURN );\n\t} else {\n\t\tUI_RunLerpFrame( pi, &pi->legs, pi->legsAnim );\n\t}\n\t*legsOld = pi->legs.oldFrame;\n\t*legs = pi->legs.frame;\n\t*legsBackLerp = pi->legs.backlerp;\n\n\t// torso animation\n\tpi->torsoAnimationTimer -= uiInfo.uiDC.frameTime;\n\tif ( pi->torsoAnimationTimer < 0 ) {\n\t\tpi->torsoAnimationTimer = 0;\n\t}\n\n\tUI_TorsoSequencing( pi );\n\n\tUI_RunLerpFrame( pi, &pi->torso, pi->torsoAnim );\n\t*torsoOld = pi->torso.oldFrame;\n\t*torso = pi->torso.frame;\n\t*torsoBackLerp = pi->torso.backlerp;\n}\n\n\n/*\n==================\nUI_SwingAngles\n==================\n*/\nstatic void UI_SwingAngles( float destination, float swingTolerance, float clampTolerance,\n\t\t\t\t\tfloat speed, float *angle, qboolean *swinging ) {\n\tfloat\tswing;\n\tfloat\tmove;\n\tfloat\tscale;\n\n\tif ( !*swinging ) {\n\t\t// see if a swing should be started\n\t\tswing = AngleSubtract( *angle, destination );\n\t\tif ( swing > swingTolerance || swing < -swingTolerance ) {\n\t\t\t*swinging = qtrue;\n\t\t}\n\t}\n\n\tif ( !*swinging ) {\n\t\treturn;\n\t}\n\t\n\t// modify the speed depending on the delta\n\t// so it doesn't seem so linear\n\tswing = AngleSubtract( destination, *angle );\n\tscale = fabs( swing );\n\tif ( scale < swingTolerance * 0.5 ) {\n\t\tscale = 0.5;\n\t} else if ( scale < swingTolerance ) {\n\t\tscale = 1.0;\n\t} else {\n\t\tscale = 2.0;\n\t}\n\n\t// swing towards the destination angle\n\tif ( swing >= 0 ) {\n\t\tmove = uiInfo.uiDC.frameTime * scale * speed;\n\t\tif ( move >= swing ) {\n\t\t\tmove = swing;\n\t\t\t*swinging = qfalse;\n\t\t}\n\t\t*angle = AngleMod( *angle + move );\n\t} else if ( swing < 0 ) {\n\t\tmove = uiInfo.uiDC.frameTime * scale * -speed;\n\t\tif ( move <= swing ) {\n\t\t\tmove = swing;\n\t\t\t*swinging = qfalse;\n\t\t}\n\t\t*angle = AngleMod( *angle + move );\n\t}\n\n\t// clamp to no more than tolerance\n\tswing = AngleSubtract( destination, *angle );\n\tif ( swing > clampTolerance ) {\n\t\t*angle = AngleMod( destination - (clampTolerance - 1) );\n\t} else if ( swing < -clampTolerance ) {\n\t\t*angle = AngleMod( destination + (clampTolerance - 1) );\n\t}\n}\n\n\n/*\n======================\nUI_MovedirAdjustment\n======================\n*/\nstatic float UI_MovedirAdjustment( playerInfo_t *pi ) {\n\tvec3_t\t\trelativeAngles;\n\tvec3_t\t\tmoveVector;\n\n\tVectorSubtract( pi->viewAngles, pi->moveAngles, relativeAngles );\n\tAngleVectors( relativeAngles, moveVector, NULL, NULL );\n\tif ( Q_fabs( moveVector[0] ) < 0.01 ) {\n\t\tmoveVector[0] = 0.0;\n\t}\n\tif ( Q_fabs( moveVector[1] ) < 0.01 ) {\n\t\tmoveVector[1] = 0.0;\n\t}\n\n\tif ( moveVector[1] == 0 && moveVector[0] > 0 ) {\n\t\treturn 0;\n\t}\n\tif ( moveVector[1] < 0 && moveVector[0] > 0 ) {\n\t\treturn 22;\n\t}\n\tif ( moveVector[1] < 0 && moveVector[0] == 0 ) {\n\t\treturn 45;\n\t}\n\tif ( moveVector[1] < 0 && moveVector[0] < 0 ) {\n\t\treturn -22;\n\t}\n\tif ( moveVector[1] == 0 && moveVector[0] < 0 ) {\n\t\treturn 0;\n\t}\n\tif ( moveVector[1] > 0 && moveVector[0] < 0 ) {\n\t\treturn 22;\n\t}\n\tif ( moveVector[1] > 0 && moveVector[0] == 0 ) {\n\t\treturn  -45;\n\t}\n\n\treturn -22;\n}\n\n\n/*\n===============\nUI_PlayerAngles\n===============\n*/\nstatic void UI_PlayerAngles( playerInfo_t *pi, vec3_t legs[3], vec3_t torso[3], vec3_t head[3] ) {\n\tvec3_t\t\tlegsAngles, torsoAngles, headAngles;\n\tfloat\t\tdest;\n\tfloat\t\tadjust;\n\n\tVectorCopy( pi->viewAngles, headAngles );\n\theadAngles[YAW] = AngleMod( headAngles[YAW] );\n\tVectorClear( legsAngles );\n\tVectorClear( torsoAngles );\n\n\t// --------- yaw -------------\n\n\t// allow yaw to drift a bit\n\tif ( ( pi->legsAnim & ~ANIM_TOGGLEBIT ) != LEGS_IDLE \n\t\t|| ( pi->torsoAnim & ~ANIM_TOGGLEBIT ) != TORSO_STAND  ) {\n\t\t// if not standing still, always point all in the same direction\n\t\tpi->torso.yawing = qtrue;\t// always center\n\t\tpi->torso.pitching = qtrue;\t// always center\n\t\tpi->legs.yawing = qtrue;\t// always center\n\t}\n\n\t// adjust legs for movement dir\n\tadjust = UI_MovedirAdjustment( pi );\n\tlegsAngles[YAW] = headAngles[YAW] + adjust;\n\ttorsoAngles[YAW] = headAngles[YAW] + 0.25 * adjust;\n\n\n\t// torso\n\tUI_SwingAngles( torsoAngles[YAW], 25, 90, SWINGSPEED, &pi->torso.yawAngle, &pi->torso.yawing );\n\tUI_SwingAngles( legsAngles[YAW], 40, 90, SWINGSPEED, &pi->legs.yawAngle, &pi->legs.yawing );\n\n\ttorsoAngles[YAW] = pi->torso.yawAngle;\n\tlegsAngles[YAW] = pi->legs.yawAngle;\n\n\t// --------- pitch -------------\n\n\t// only show a fraction of the pitch angle in the torso\n\tif ( headAngles[PITCH] > 180 ) {\n\t\tdest = (-360 + headAngles[PITCH]) * 0.75;\n\t} else {\n\t\tdest = headAngles[PITCH] * 0.75;\n\t}\n\tUI_SwingAngles( dest, 15, 30, 0.1f, &pi->torso.pitchAngle, &pi->torso.pitching );\n\ttorsoAngles[PITCH] = pi->torso.pitchAngle;\n\n\t// pull the angles back out of the hierarchial chain\n\tAnglesSubtract( headAngles, torsoAngles, headAngles );\n\tAnglesSubtract( torsoAngles, legsAngles, torsoAngles );\n\tAnglesToAxis( legsAngles, legs );\n\tAnglesToAxis( torsoAngles, torso );\n\tAnglesToAxis( headAngles, head );\n}\n\n\n/*\n===============\nUI_PlayerFloatSprite\n===============\n*/\nstatic void UI_PlayerFloatSprite( playerInfo_t *pi, vec3_t origin, qhandle_t shader ) {\n\trefEntity_t\t\tent;\n\n\tmemset( &ent, 0, sizeof( ent ) );\n\tVectorCopy( origin, ent.origin );\n\tent.origin[2] += 48;\n\tent.reType = RT_SPRITE;\n\tent.customShader = shader;\n\tent.radius = 10;\n\tent.renderfx = 0;\n\ttrap_R_AddRefEntityToScene( &ent );\n}\n\n\n/*\n======================\nUI_MachinegunSpinAngle\n======================\n*/\nfloat\tUI_MachinegunSpinAngle( playerInfo_t *pi ) {\n\tint\t\tdelta;\n\tfloat\tangle;\n\tfloat\tspeed;\n\tint\t\ttorsoAnim;\n\n\tdelta = dp_realtime - pi->barrelTime;\n\tif ( pi->barrelSpinning ) {\n\t\tangle = pi->barrelAngle + delta * SPIN_SPEED;\n\t} else {\n\t\tif ( delta > COAST_TIME ) {\n\t\t\tdelta = COAST_TIME;\n\t\t}\n\n\t\tspeed = 0.5 * ( SPIN_SPEED + (float)( COAST_TIME - delta ) / COAST_TIME );\n\t\tangle = pi->barrelAngle + delta * speed;\n\t}\n\n\ttorsoAnim = pi->torsoAnim  & ~ANIM_TOGGLEBIT;\n\tif( torsoAnim == TORSO_ATTACK2 ) {\n\t\ttorsoAnim = TORSO_ATTACK;\n\t}\n\tif ( pi->barrelSpinning == !(torsoAnim == TORSO_ATTACK) ) {\n\t\tpi->barrelTime = dp_realtime;\n\t\tpi->barrelAngle = AngleMod( angle );\n\t\tpi->barrelSpinning = !!(torsoAnim == TORSO_ATTACK);\n\t}\n\n\treturn angle;\n}\n\n\n/*\n===============\nUI_DrawPlayer\n===============\n*/\nvoid UI_DrawPlayer( float x, float y, float w, float h, playerInfo_t *pi, int time ) {\n\trefdef_t\t\trefdef;\n\trefEntity_t\t\tlegs;\n\trefEntity_t\t\ttorso;\n\trefEntity_t\t\thead;\n\trefEntity_t\t\tgun;\n\trefEntity_t\t\tbarrel;\n\trefEntity_t\t\tflash;\n\tvec3_t\t\t\torigin;\n\tint\t\t\t\trenderfx;\n\tvec3_t\t\t\tmins = {-16, -16, -24};\n\tvec3_t\t\t\tmaxs = {16, 16, 32};\n\tfloat\t\t\tlen;\n\tfloat\t\t\txx;\n\n\tif ( !pi->legsModel || !pi->torsoModel || !pi->headModel || !pi->animations[0].numFrames ) {\n\t\treturn;\n\t}\n\n\t// this allows the ui to cache the player model on the main menu\n\tif (w == 0 || h == 0) {\n\t\treturn;\n\t}\n\n\tdp_realtime = time;\n\n\tif ( pi->pendingWeapon != -1 && dp_realtime > pi->weaponTimer ) {\n\t\tpi->weapon = pi->pendingWeapon;\n\t\tpi->lastWeapon = pi->pendingWeapon;\n\t\tpi->pendingWeapon = -1;\n\t\tpi->weaponTimer = 0;\n\t\tif( pi->currentWeapon != pi->weapon ) {\n\t\t\ttrap_S_StartLocalSound( weaponChangeSound, CHAN_LOCAL );\n\t\t}\n\t}\n\n\tUI_AdjustFrom640( &x, &y, &w, &h );\n\n\ty -= jumpHeight;\n\n\tmemset( &refdef, 0, sizeof( refdef ) );\n\tmemset( &legs, 0, sizeof(legs) );\n\tmemset( &torso, 0, sizeof(torso) );\n\tmemset( &head, 0, sizeof(head) );\n\n\trefdef.rdflags = RDF_NOWORLDMODEL;\n\n\tAxisClear( refdef.viewaxis );\n\n\trefdef.x = x;\n\trefdef.y = y;\n\trefdef.width = w;\n\trefdef.height = h;\n\n\trefdef.fov_x = (int)((float)refdef.width / 640.0f * 90.0f);\n\txx = refdef.width / tan( refdef.fov_x / 360 * M_PI );\n\trefdef.fov_y = atan2( refdef.height, xx );\n\trefdef.fov_y *= ( 360 / (float)M_PI );\n\n\t// calculate distance so the player nearly fills the box\n\tlen = 0.7 * ( maxs[2] - mins[2] );\t\t\n\torigin[0] = len / tan( DEG2RAD(refdef.fov_x) * 0.5 );\n\torigin[1] = 0.5 * ( mins[1] + maxs[1] );\n\torigin[2] = -0.5 * ( mins[2] + maxs[2] );\n\n\trefdef.time = dp_realtime;\n\n\ttrap_R_ClearScene();\n\n\t// get the rotation information\n\tUI_PlayerAngles( pi, legs.axis, torso.axis, head.axis );\n\t\n\t// get the animation state (after rotation, to allow feet shuffle)\n\tUI_PlayerAnimation( pi, &legs.oldframe, &legs.frame, &legs.backlerp,\n\t\t &torso.oldframe, &torso.frame, &torso.backlerp );\n\n\trenderfx = RF_LIGHTING_ORIGIN | RF_NOSHADOW;\n\n\t//\n\t// add the legs\n\t//\n\tlegs.hModel = pi->legsModel;\n\tlegs.customSkin = pi->legsSkin;\n\n\tVectorCopy( origin, legs.origin );\n\n\tVectorCopy( origin, legs.lightingOrigin );\n\tlegs.renderfx = renderfx;\n\tVectorCopy (legs.origin, legs.oldorigin);\n\n\ttrap_R_AddRefEntityToScene( &legs );\n\n\tif (!legs.hModel) {\n\t\treturn;\n\t}\n\n\t//\n\t// add the torso\n\t//\n\ttorso.hModel = pi->torsoModel;\n\tif (!torso.hModel) {\n\t\treturn;\n\t}\n\n\ttorso.customSkin = pi->torsoSkin;\n\n\tVectorCopy( origin, torso.lightingOrigin );\n\n\tUI_PositionRotatedEntityOnTag( &torso, &legs, pi->legsModel, \"tag_torso\");\n\n\ttorso.renderfx = renderfx;\n\n\ttrap_R_AddRefEntityToScene( &torso );\n\n\t//\n\t// add the head\n\t//\n\thead.hModel = pi->headModel;\n\tif (!head.hModel) {\n\t\treturn;\n\t}\n\thead.customSkin = pi->headSkin;\n\n\tVectorCopy( origin, head.lightingOrigin );\n\n\tUI_PositionRotatedEntityOnTag( &head, &torso, pi->torsoModel, \"tag_head\");\n\n\thead.renderfx = renderfx;\n\n\ttrap_R_AddRefEntityToScene( &head );\n\n\t//\n\t// add the gun\n\t//\n\tif ( pi->currentWeapon != WP_NONE ) {\n\t\tmemset( &gun, 0, sizeof(gun) );\n\t\tgun.hModel = pi->weaponModel;\n\t\tVectorCopy( origin, gun.lightingOrigin );\n\t\tUI_PositionEntityOnTag( &gun, &torso, pi->torsoModel, \"tag_weapon\");\n\t\tgun.renderfx = renderfx;\n\t\ttrap_R_AddRefEntityToScene( &gun );\n\t}\n\n\t//\n\t// add the spinning barrel\n\t//\n\tif ( pi->realWeapon == WP_MACHINEGUN || pi->realWeapon == WP_GAUNTLET || pi->realWeapon == WP_BFG ) {\n\t\tvec3_t\tangles;\n\n\t\tmemset( &barrel, 0, sizeof(barrel) );\n\t\tVectorCopy( origin, barrel.lightingOrigin );\n\t\tbarrel.renderfx = renderfx;\n\n\t\tbarrel.hModel = pi->barrelModel;\n\t\tangles[YAW] = 0;\n\t\tangles[PITCH] = 0;\n\t\tangles[ROLL] = UI_MachinegunSpinAngle( pi );\n\t\tif( pi->realWeapon == WP_GAUNTLET || pi->realWeapon == WP_BFG ) {\n\t\t\tangles[PITCH] = angles[ROLL];\n\t\t\tangles[ROLL] = 0;\n\t\t}\n\t\tAnglesToAxis( angles, barrel.axis );\n\n\t\tUI_PositionRotatedEntityOnTag( &barrel, &gun, pi->weaponModel, \"tag_barrel\");\n\n\t\ttrap_R_AddRefEntityToScene( &barrel );\n\t}\n\n\t//\n\t// add muzzle flash\n\t//\n\tif ( dp_realtime <= pi->muzzleFlashTime ) {\n\t\tif ( pi->flashModel ) {\n\t\t\tmemset( &flash, 0, sizeof(flash) );\n\t\t\tflash.hModel = pi->flashModel;\n\t\t\tVectorCopy( origin, flash.lightingOrigin );\n\t\t\tUI_PositionEntityOnTag( &flash, &gun, pi->weaponModel, \"tag_flash\");\n\t\t\tflash.renderfx = renderfx;\n\t\t\ttrap_R_AddRefEntityToScene( &flash );\n\t\t}\n\n\t\t// make a dlight for the flash\n\t\tif ( pi->flashDlightColor[0] || pi->flashDlightColor[1] || pi->flashDlightColor[2] ) {\n\t\t\ttrap_R_AddLightToScene( flash.origin, 200 + (rand()&31), pi->flashDlightColor[0],\n\t\t\t\tpi->flashDlightColor[1], pi->flashDlightColor[2] );\n\t\t}\n\t}\n\n\t//\n\t// add the chat icon\n\t//\n\tif ( pi->chat ) {\n\t\tUI_PlayerFloatSprite( pi, origin, trap_R_RegisterShaderNoMip( \"sprites/balloon3\" ) );\n\t}\n\n\t//\n\t// add an accent light\n\t//\n\torigin[0] -= 100;\t// + = behind, - = in front\n\torigin[1] += 100;\t// + = left, - = right\n\torigin[2] += 100;\t// + = above, - = below\n\ttrap_R_AddLightToScene( origin, 500, 1.0, 1.0, 1.0 );\n\n\torigin[0] -= 100;\n\torigin[1] -= 100;\n\torigin[2] -= 100;\n\ttrap_R_AddLightToScene( origin, 500, 1.0, 0.0, 0.0 );\n\n\ttrap_R_RenderScene( &refdef );\n}\n\n/*\n==========================\nUI_FileExists\n==========================\n*/\nstatic qboolean\tUI_FileExists(const char *filename) {\n\tint len;\n\n\tlen = trap_FS_FOpenFile( filename, 0, FS_READ );\n\tif (len>0) {\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n==========================\nUI_FindClientHeadFile\n==========================\n*/\nstatic qboolean\tUI_FindClientHeadFile( char *filename, int length, const char *teamName, const char *headModelName, const char *headSkinName, const char *base, const char *ext ) {\n\tchar *team, *headsFolder;\n\tint i;\n\n\tteam = \"default\";\n\n\tif ( headModelName[0] == '*' ) {\n\t\theadsFolder = \"heads/\";\n\t\theadModelName++;\n\t}\n\telse {\n\t\theadsFolder = \"\";\n\t}\n\twhile(1) {\n\t\tfor ( i = 0; i < 2; i++ ) {\n\t\t\tif ( i == 0 && teamName && *teamName ) {\n\t\t\t\tCom_sprintf( filename, length, \"models/players/%s%s/%s/%s%s_%s.%s\", headsFolder, headModelName, headSkinName, teamName, base, team, ext );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tCom_sprintf( filename, length, \"models/players/%s%s/%s/%s_%s.%s\", headsFolder, headModelName, headSkinName, base, team, ext );\n\t\t\t}\n\t\t\tif ( UI_FileExists( filename ) ) {\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t\tif ( i == 0 && teamName && *teamName ) {\n\t\t\t\tCom_sprintf( filename, length, \"models/players/%s%s/%s%s_%s.%s\", headsFolder, headModelName, teamName, base, headSkinName, ext );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tCom_sprintf( filename, length, \"models/players/%s%s/%s_%s.%s\", headsFolder, headModelName, base, headSkinName, ext );\n\t\t\t}\n\t\t\tif ( UI_FileExists( filename ) ) {\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t\tif ( !teamName || !*teamName ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t// if tried the heads folder first\n\t\tif ( headsFolder[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\theadsFolder = \"heads/\";\n\t}\n\n\treturn qfalse;\n}\n\n/*\n==========================\nUI_RegisterClientSkin\n==========================\n*/\nstatic qboolean\tUI_RegisterClientSkin( playerInfo_t *pi, const char *modelName, const char *skinName, const char *headModelName, const char *headSkinName , const char *teamName) {\n\tchar\t\tfilename[MAX_QPATH*2];\n\n\tif (teamName && *teamName) {\n\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/%s/%s/lower_%s.skin\", modelName, teamName, skinName );\n\t} else {\n\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/%s/lower_%s.skin\", modelName, skinName );\n\t}\n\tpi->legsSkin = trap_R_RegisterSkin( filename );\n\tif (!pi->legsSkin) {\n\t\tif (teamName && *teamName) {\n\t\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/characters/%s/%s/lower_%s.skin\", modelName, teamName, skinName );\n\t\t} else {\n\t\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/characters/%s/lower_%s.skin\", modelName, skinName );\n\t\t}\n\t\tpi->legsSkin = trap_R_RegisterSkin( filename );\n\t}\n\n\tif (teamName && *teamName) {\n\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/%s/%s/upper_%s.skin\", modelName, teamName, skinName );\n\t} else {\n\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/%s/upper_%s.skin\", modelName, skinName );\n\t}\n\tpi->torsoSkin = trap_R_RegisterSkin( filename );\n\tif (!pi->torsoSkin) {\n\t\tif (teamName && *teamName) {\n\t\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/characters/%s/%s/upper_%s.skin\", modelName, teamName, skinName );\n\t\t} else {\n\t\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/characters/%s/upper_%s.skin\", modelName, skinName );\n\t\t}\n\t\tpi->torsoSkin = trap_R_RegisterSkin( filename );\n\t}\n\n\tif ( UI_FindClientHeadFile( filename, sizeof(filename), teamName, headModelName, headSkinName, \"head\", \"skin\" ) ) {\n\t\tpi->headSkin = trap_R_RegisterSkin( filename );\n\t}\n\n\tif ( !pi->legsSkin || !pi->torsoSkin || !pi->headSkin ) {\n\t\treturn qfalse;\n\t}\n\n\treturn qtrue;\n}\n\n\n/*\n======================\nUI_ParseAnimationFile\n======================\n*/\nstatic qboolean UI_ParseAnimationFile( const char *filename, animation_t *animations ) {\n\tchar\t\t*text_p, *prev;\n\tint\t\t\tlen;\n\tint\t\t\ti;\n\tchar\t\t*token;\n\tfloat\t\tfps;\n\tint\t\t\tskip;\n\tchar\t\ttext[20000];\n\tfileHandle_t\tf;\n\n\tmemset( animations, 0, sizeof( animation_t ) * MAX_ANIMATIONS );\n\n\t// load the file\n\tlen = trap_FS_FOpenFile( filename, &f, FS_READ );\n\tif ( len <= 0 ) {\n\t\treturn qfalse;\n\t}\n\tif ( len >= ( sizeof( text ) - 1 ) ) {\n\t\tCom_Printf( \"File %s too long\\n\", filename );\n\t\treturn qfalse;\n\t}\n\ttrap_FS_Read( text, len, f );\n\ttext[len] = 0;\n\ttrap_FS_FCloseFile( f );\n\n\tCOM_Compress(text);\n\n\t// parse the text\n\ttext_p = text;\n\tskip = 0;\t// quite the compiler warning\n\n\t// read optional parameters\n\twhile ( 1 ) {\n\t\tprev = text_p;\t// so we can unget\n\t\ttoken = COM_Parse( &text_p );\n\t\tif ( !token ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( !Q_stricmp( token, \"footsteps\" ) ) {\n\t\t\ttoken = COM_Parse( &text_p );\n\t\t\tif ( !token ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcontinue;\n\t\t} else if ( !Q_stricmp( token, \"headoffset\" ) ) {\n\t\t\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\t\t\ttoken = COM_Parse( &text_p );\n\t\t\t\tif ( !token ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontinue;\n\t\t} else if ( !Q_stricmp( token, \"sex\" ) ) {\n\t\t\ttoken = COM_Parse( &text_p );\n\t\t\tif ( !token ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// if it is a number, start parsing animations\n\t\tif ( token[0] >= '0' && token[0] <= '9' ) {\n\t\t\ttext_p = prev;\t// unget the token\n\t\t\tbreak;\n\t\t}\n\n\t\tCom_Printf( \"unknown token '%s' is %s\\n\", token, filename );\n\t}\n\n\t// read information for each frame\n\tfor ( i = 0 ; i < MAX_ANIMATIONS ; i++ ) {\n\n\t\ttoken = COM_Parse( &text_p );\n\t\tif ( !token ) {\n\t\t\tbreak;\n\t\t}\n\t\tanimations[i].firstFrame = atoi( token );\n\t\t// leg only frames are adjusted to not count the upper body only frames\n\t\tif ( i == LEGS_WALKCR ) {\n\t\t\tskip = animations[LEGS_WALKCR].firstFrame - animations[TORSO_GESTURE].firstFrame;\n\t\t}\n\t\tif ( i >= LEGS_WALKCR ) {\n\t\t\tanimations[i].firstFrame -= skip;\n\t\t}\n\n\t\ttoken = COM_Parse( &text_p );\n\t\tif ( !token ) {\n\t\t\tbreak;\n\t\t}\n\t\tanimations[i].numFrames = atoi( token );\n\n\t\ttoken = COM_Parse( &text_p );\n\t\tif ( !token ) {\n\t\t\tbreak;\n\t\t}\n\t\tanimations[i].loopFrames = atoi( token );\n\n\t\ttoken = COM_Parse( &text_p );\n\t\tif ( !token ) {\n\t\t\tbreak;\n\t\t}\n\t\tfps = atof( token );\n\t\tif ( fps == 0 ) {\n\t\t\tfps = 1;\n\t\t}\n\t\tanimations[i].frameLerp = 1000 / fps;\n\t\tanimations[i].initialLerp = 1000 / fps;\n\t}\n\n\tif ( i != MAX_ANIMATIONS ) {\n\t\tCom_Printf( \"Error parsing animation file: %s\", filename );\n\t\treturn qfalse;\n\t}\n\n\treturn qtrue;\n}\n\n/*\n==========================\nUI_RegisterClientModelname\n==========================\n*/\nqboolean UI_RegisterClientModelname( playerInfo_t *pi, const char *modelSkinName, const char *headModelSkinName, const char *teamName ) {\n\tchar\t\tmodelName[MAX_QPATH];\n\tchar\t\tskinName[MAX_QPATH];\n\tchar\t\theadModelName[MAX_QPATH];\n\tchar\t\theadSkinName[MAX_QPATH];\n\tchar\t\tfilename[MAX_QPATH];\n\tchar\t\t*slash;\n\n\tpi->torsoModel = 0;\n\tpi->headModel = 0;\n\n\tif ( !modelSkinName[0] ) {\n\t\treturn qfalse;\n\t}\n\n\tQ_strncpyz( modelName, modelSkinName, sizeof( modelName ) );\n\n\tslash = strchr( modelName, '/' );\n\tif ( !slash ) {\n\t\t// modelName did not include a skin name\n\t\tQ_strncpyz( skinName, \"default\", sizeof( skinName ) );\n\t} else {\n\t\tQ_strncpyz( skinName, slash + 1, sizeof( skinName ) );\n\t\t*slash = '\\0';\n\t}\n\n\tQ_strncpyz( headModelName, headModelSkinName, sizeof( headModelName ) );\n\tslash = strchr( headModelName, '/' );\n\tif ( !slash ) {\n\t\t// modelName did not include a skin name\n\t\tQ_strncpyz( headSkinName, \"default\", sizeof( skinName ) );\n\t} else {\n\t\tQ_strncpyz( headSkinName, slash + 1, sizeof( skinName ) );\n\t\t*slash = '\\0';\n\t}\n\n\t// load cmodels before models so filecache works\n\n\tCom_sprintf( filename, sizeof( filename ), \"models/players/%s/lower.md3\", modelName );\n\tpi->legsModel = trap_R_RegisterModel( filename );\n\tif ( !pi->legsModel ) {\n\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/characters/%s/lower.md3\", modelName );\n\t\tpi->legsModel = trap_R_RegisterModel( filename );\n\t\tif ( !pi->legsModel ) {\n\t\t\tCom_Printf( \"Failed to load model file %s\\n\", filename );\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\tCom_sprintf( filename, sizeof( filename ), \"models/players/%s/upper.md3\", modelName );\n\tpi->torsoModel = trap_R_RegisterModel( filename );\n\tif ( !pi->torsoModel ) {\n\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/characters/%s/upper.md3\", modelName );\n\t\tpi->torsoModel = trap_R_RegisterModel( filename );\n\t\tif ( !pi->torsoModel ) {\n\t\t\tCom_Printf( \"Failed to load model file %s\\n\", filename );\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\tif (headModelName && headModelName[0] == '*' ) {\n\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/heads/%s/%s.md3\", &headModelName[1], &headModelName[1] );\n\t}\n\telse {\n\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/%s/head.md3\", headModelName );\n\t}\n\tpi->headModel = trap_R_RegisterModel( filename );\n\tif ( !pi->headModel && headModelName[0] != '*') {\n\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/heads/%s/%s.md3\", headModelName, headModelName );\n\t\tpi->headModel = trap_R_RegisterModel( filename );\n\t}\n\n\tif (!pi->headModel) {\n\t\tCom_Printf( \"Failed to load model file %s\\n\", filename );\n\t\treturn qfalse;\n\t}\n\n\t// if any skins failed to load, fall back to default\n\tif ( !UI_RegisterClientSkin( pi, modelName, skinName, headModelName, headSkinName, teamName) ) {\n\t\tif ( !UI_RegisterClientSkin( pi, modelName, \"default\", headModelName, \"default\", teamName ) ) {\n\t\t\tCom_Printf( \"Failed to load skin file: %s : %s\\n\", modelName, skinName );\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\t// load the animations\n\tCom_sprintf( filename, sizeof( filename ), \"models/players/%s/animation.cfg\", modelName );\n\tif ( !UI_ParseAnimationFile( filename, pi->animations ) ) {\n\t\tCom_sprintf( filename, sizeof( filename ), \"models/players/characters/%s/animation.cfg\", modelName );\n\t\tif ( !UI_ParseAnimationFile( filename, pi->animations ) ) {\n\t\t\tCom_Printf( \"Failed to load animation file %s\\n\", filename );\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\treturn qtrue;\n}\n\n\n/*\n===============\nUI_PlayerInfo_SetModel\n===============\n*/\nvoid UI_PlayerInfo_SetModel( playerInfo_t *pi, const char *model, const char *headmodel, char *teamName ) {\n\tmemset( pi, 0, sizeof(*pi) );\n\tUI_RegisterClientModelname( pi, model, headmodel, teamName );\n\tpi->weapon = WP_MACHINEGUN;\n\tpi->currentWeapon = pi->weapon;\n\tpi->lastWeapon = pi->weapon;\n\tpi->pendingWeapon = -1;\n\tpi->weaponTimer = 0;\n\tpi->chat = qfalse;\n\tpi->newModel = qtrue;\n\tUI_PlayerInfo_SetWeapon( pi, pi->weapon );\n}\n\n\n/*\n===============\nUI_PlayerInfo_SetInfo\n===============\n*/\nvoid UI_PlayerInfo_SetInfo( playerInfo_t *pi, int legsAnim, int torsoAnim, vec3_t viewAngles, vec3_t moveAngles, weapon_t weaponNumber, qboolean chat ) {\n\tint\t\t\tcurrentAnim;\n\tweapon_t\tweaponNum;\n\n\tpi->chat = chat;\n\n\t// view angles\n\tVectorCopy( viewAngles, pi->viewAngles );\n\n\t// move angles\n\tVectorCopy( moveAngles, pi->moveAngles );\n\n\tif ( pi->newModel ) {\n\t\tpi->newModel = qfalse;\n\n\t\tjumpHeight = 0;\n\t\tpi->pendingLegsAnim = 0;\n\t\tUI_ForceLegsAnim( pi, legsAnim );\n\t\tpi->legs.yawAngle = viewAngles[YAW];\n\t\tpi->legs.yawing = qfalse;\n\n\t\tpi->pendingTorsoAnim = 0;\n\t\tUI_ForceTorsoAnim( pi, torsoAnim );\n\t\tpi->torso.yawAngle = viewAngles[YAW];\n\t\tpi->torso.yawing = qfalse;\n\n\t\tif ( weaponNumber != -1 ) {\n\t\t\tpi->weapon = weaponNumber;\n\t\t\tpi->currentWeapon = weaponNumber;\n\t\t\tpi->lastWeapon = weaponNumber;\n\t\t\tpi->pendingWeapon = -1;\n\t\t\tpi->weaponTimer = 0;\n\t\t\tUI_PlayerInfo_SetWeapon( pi, pi->weapon );\n\t\t}\n\n\t\treturn;\n\t}\n\n\t// weapon\n\tif ( weaponNumber == -1 ) {\n\t\tpi->pendingWeapon = -1;\n\t\tpi->weaponTimer = 0;\n\t}\n\telse if ( weaponNumber != WP_NONE ) {\n\t\tpi->pendingWeapon = weaponNumber;\n\t\tpi->weaponTimer = dp_realtime + UI_TIMER_WEAPON_DELAY;\n\t}\n\tweaponNum = pi->lastWeapon;\n\tpi->weapon = weaponNum;\n\n\tif ( torsoAnim == BOTH_DEATH1 || legsAnim == BOTH_DEATH1 ) {\n\t\ttorsoAnim = legsAnim = BOTH_DEATH1;\n\t\tpi->weapon = pi->currentWeapon = WP_NONE;\n\t\tUI_PlayerInfo_SetWeapon( pi, pi->weapon );\n\n\t\tjumpHeight = 0;\n\t\tpi->pendingLegsAnim = 0;\n\t\tUI_ForceLegsAnim( pi, legsAnim );\n\n\t\tpi->pendingTorsoAnim = 0;\n\t\tUI_ForceTorsoAnim( pi, torsoAnim );\n\n\t\treturn;\n\t}\n\n\t// leg animation\n\tcurrentAnim = pi->legsAnim & ~ANIM_TOGGLEBIT;\n\tif ( legsAnim != LEGS_JUMP && ( currentAnim == LEGS_JUMP || currentAnim == LEGS_LAND ) ) {\n\t\tpi->pendingLegsAnim = legsAnim;\n\t}\n\telse if ( legsAnim != currentAnim ) {\n\t\tjumpHeight = 0;\n\t\tpi->pendingLegsAnim = 0;\n\t\tUI_ForceLegsAnim( pi, legsAnim );\n\t}\n\n\t// torso animation\n\tif ( torsoAnim == TORSO_STAND || torsoAnim == TORSO_STAND2 ) {\n\t\tif ( weaponNum == WP_NONE || weaponNum == WP_GAUNTLET ) {\n\t\t\ttorsoAnim = TORSO_STAND2;\n\t\t}\n\t\telse {\n\t\t\ttorsoAnim = TORSO_STAND;\n\t\t}\n\t}\n\n\tif ( torsoAnim == TORSO_ATTACK || torsoAnim == TORSO_ATTACK2 ) {\n\t\tif ( weaponNum == WP_NONE || weaponNum == WP_GAUNTLET ) {\n\t\t\ttorsoAnim = TORSO_ATTACK2;\n\t\t}\n\t\telse {\n\t\t\ttorsoAnim = TORSO_ATTACK;\n\t\t}\n\t\tpi->muzzleFlashTime = dp_realtime + UI_TIMER_MUZZLE_FLASH;\n\t\t//FIXME play firing sound here\n\t}\n\n\tcurrentAnim = pi->torsoAnim & ~ANIM_TOGGLEBIT;\n\n\tif ( weaponNum != pi->currentWeapon || currentAnim == TORSO_RAISE || currentAnim == TORSO_DROP ) {\n\t\tpi->pendingTorsoAnim = torsoAnim;\n\t}\n\telse if ( ( currentAnim == TORSO_GESTURE || currentAnim == TORSO_ATTACK ) && ( torsoAnim != currentAnim ) ) {\n\t\tpi->pendingTorsoAnim = torsoAnim;\n\t}\n\telse if ( torsoAnim != currentAnim ) {\n\t\tpi->pendingTorsoAnim = 0;\n\t\tUI_ForceTorsoAnim( pi, torsoAnim );\n\t}\n}\n"
  },
  {
    "path": "code/ui/ui_public.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#ifndef __UI_PUBLIC_H__\n#define __UI_PUBLIC_H__\n\n#define UI_API_VERSION\t6\n\ntypedef struct {\n\tconnstate_t\t\tconnState;\n\tint\t\t\t\tconnectPacketCount;\n\tint\t\t\t\tclientNum;\n\tchar\t\t\tservername[MAX_STRING_CHARS];\n\tchar\t\t\tupdateInfoString[MAX_STRING_CHARS];\n\tchar\t\t\tmessageString[MAX_STRING_CHARS];\n} uiClientState_t;\n\ntypedef enum {\n\tUI_ERROR,\n\tUI_PRINT,\n\tUI_MILLISECONDS,\n\tUI_CVAR_SET,\n\tUI_CVAR_VARIABLEVALUE,\n\tUI_CVAR_VARIABLESTRINGBUFFER,\n\tUI_CVAR_SETVALUE,\n\tUI_CVAR_RESET,\n\tUI_CVAR_CREATE,\n\tUI_CVAR_INFOSTRINGBUFFER,\n\tUI_ARGC,\n\tUI_ARGV,\n\tUI_CMD_EXECUTETEXT,\n\tUI_FS_FOPENFILE,\n\tUI_FS_READ,\n\tUI_FS_WRITE,\n\tUI_FS_FCLOSEFILE,\n\tUI_FS_GETFILELIST,\n\tUI_R_REGISTERMODEL,\n\tUI_R_REGISTERSKIN,\n\tUI_R_REGISTERSHADERNOMIP,\n\tUI_R_CLEARSCENE,\n\tUI_R_ADDREFENTITYTOSCENE,\n\tUI_R_ADDPOLYTOSCENE,\n\tUI_R_ADDLIGHTTOSCENE,\n\tUI_R_RENDERSCENE,\n\tUI_R_SETCOLOR,\n\tUI_R_DRAWSTRETCHPIC,\n\tUI_UPDATESCREEN,\n\tUI_CM_LERPTAG,\n\tUI_CM_LOADMODEL,\n\tUI_S_REGISTERSOUND,\n\tUI_S_STARTLOCALSOUND,\n\tUI_KEY_KEYNUMTOSTRINGBUF,\n\tUI_KEY_GETBINDINGBUF,\n\tUI_KEY_SETBINDING,\n\tUI_KEY_ISDOWN,\n\tUI_KEY_GETOVERSTRIKEMODE,\n\tUI_KEY_SETOVERSTRIKEMODE,\n\tUI_KEY_CLEARSTATES,\n\tUI_KEY_GETCATCHER,\n\tUI_KEY_SETCATCHER,\n\tUI_GETCLIPBOARDDATA,\n\tUI_GETGLCONFIG,\n\tUI_GETCLIENTSTATE,\n\tUI_GETCONFIGSTRING,\n\tUI_LAN_GETPINGQUEUECOUNT,\n\tUI_LAN_CLEARPING,\n\tUI_LAN_GETPING,\n\tUI_LAN_GETPINGINFO,\n\tUI_CVAR_REGISTER,\n\tUI_CVAR_UPDATE,\n\tUI_MEMORY_REMAINING,\n\tUI_GET_CDKEY,\n\tUI_SET_CDKEY,\n\tUI_R_REGISTERFONT,\n\tUI_R_MODELBOUNDS,\n\tUI_PC_ADD_GLOBAL_DEFINE,\n\tUI_PC_LOAD_SOURCE,\n\tUI_PC_FREE_SOURCE,\n\tUI_PC_READ_TOKEN,\n\tUI_PC_SOURCE_FILE_AND_LINE,\n\tUI_S_STOPBACKGROUNDTRACK,\n\tUI_S_STARTBACKGROUNDTRACK,\n\tUI_REAL_TIME,\n\tUI_LAN_GETSERVERCOUNT,\n\tUI_LAN_GETSERVERADDRESSSTRING,\n\tUI_LAN_GETSERVERINFO,\n\tUI_LAN_MARKSERVERVISIBLE,\n\tUI_LAN_UPDATEVISIBLEPINGS,\n\tUI_LAN_RESETPINGS,\n\tUI_LAN_LOADCACHEDSERVERS,\n\tUI_LAN_SAVECACHEDSERVERS,\n\tUI_LAN_ADDSERVER,\n\tUI_LAN_REMOVESERVER,\n\tUI_CIN_PLAYCINEMATIC,\n\tUI_CIN_STOPCINEMATIC,\n\tUI_CIN_RUNCINEMATIC,\n\tUI_CIN_DRAWCINEMATIC,\n\tUI_CIN_SETEXTENTS,\n\tUI_R_REMAP_SHADER,\n\tUI_VERIFY_CDKEY,\n\tUI_LAN_SERVERSTATUS,\n\tUI_LAN_GETSERVERPING,\n\tUI_LAN_SERVERISVISIBLE,\n\tUI_LAN_COMPARESERVERS,\n\t// 1.32\n\tUI_FS_SEEK,\n\tUI_SET_PBCLSTATUS,\n\n\tUI_MEMSET = 100,\n\tUI_MEMCPY,\n\tUI_STRNCPY,\n\tUI_SIN,\n\tUI_COS,\n\tUI_ATAN2,\n\tUI_SQRT,\n\tUI_FLOOR,\n\tUI_CEIL\n} uiImport_t;\n\ntypedef enum {\n\tUIMENU_NONE,\n\tUIMENU_MAIN,\n\tUIMENU_INGAME,\n\tUIMENU_NEED_CD,\n\tUIMENU_BAD_CD_KEY,\n\tUIMENU_TEAM,\n\tUIMENU_POSTGAME\n} uiMenuCommand_t;\n\n#define SORT_HOST\t\t\t0\n#define SORT_MAP\t\t\t1\n#define SORT_CLIENTS\t\t2\n#define SORT_GAME\t\t\t3\n#define SORT_PING\t\t\t4\n#define SORT_PUNKBUSTER\t\t5\n\ntypedef enum {\n\tUI_GETAPIVERSION = 0,\t// system reserved\n\n\tUI_INIT,\n//\tvoid\tUI_Init( void );\n\n\tUI_SHUTDOWN,\n//\tvoid\tUI_Shutdown( void );\n\n\tUI_KEY_EVENT,\n//\tvoid\tUI_KeyEvent( int key );\n\n\tUI_MOUSE_EVENT,\n//\tvoid\tUI_MouseEvent( int dx, int dy );\n\n\tUI_REFRESH,\n//\tvoid\tUI_Refresh( int time );\n\n\tUI_IS_FULLSCREEN,\n//\tqboolean UI_IsFullscreen( void );\n\n\tUI_SET_ACTIVE_MENU,\n//\tvoid\tUI_SetActiveMenu( uiMenuCommand_t menu );\n\n\tUI_CONSOLE_COMMAND,\n//\tqboolean UI_ConsoleCommand( int realTime );\n\n\tUI_DRAW_CONNECT_SCREEN,\n//\tvoid\tUI_DrawConnectScreen( qboolean overlay );\n\tUI_HASUNIQUECDKEY\n// if !overlay, the background will be drawn, otherwise it will be\n// overlayed over whatever the cgame has drawn.\n// a GetClientState syscall will be made to get the current strings\n} uiExport_t;\n\n#endif\n"
  },
  {
    "path": "code/ui/ui_shared.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// \n// string allocation/managment\n\n#include \"ui_shared.h\"\n\n#define SCROLL_TIME_START\t\t\t\t\t500\n#define SCROLL_TIME_ADJUST\t\t\t\t150\n#define SCROLL_TIME_ADJUSTOFFSET\t40\n#define SCROLL_TIME_FLOOR\t\t\t\t\t20\n\ntypedef struct scrollInfo_s {\n\tint nextScrollTime;\n\tint nextAdjustTime;\n\tint adjustValue;\n\tint scrollKey;\n\tfloat xStart;\n\tfloat yStart;\n\titemDef_t *item;\n\tqboolean scrollDir;\n} scrollInfo_t;\n\nstatic scrollInfo_t scrollInfo;\n\nstatic void (*captureFunc) (void *p) = NULL;\nstatic void *captureData = NULL;\nstatic itemDef_t *itemCapture = NULL;   // item that has the mouse captured ( if any )\n\ndisplayContextDef_t *DC = NULL;\n\nstatic qboolean g_waitingForKey = qfalse;\nstatic qboolean g_editingField = qfalse;\n\nstatic itemDef_t *g_bindItem = NULL;\nstatic itemDef_t *g_editItem = NULL;\n\nmenuDef_t Menus[MAX_MENUS];      // defined menus\nint menuCount = 0;               // how many\n\nmenuDef_t *menuStack[MAX_OPEN_MENUS];\nint openMenuCount = 0;\n\nstatic qboolean debugMode = qfalse;\n\n#define DOUBLE_CLICK_DELAY 300\nstatic int lastListBoxClickTime = 0;\n\nvoid Item_RunScript(itemDef_t *item, const char *s);\nvoid Item_SetupKeywordHash(void);\nvoid Menu_SetupKeywordHash(void);\nint BindingIDFromName(const char *name);\nqboolean Item_Bind_HandleKey(itemDef_t *item, int key, qboolean down);\nitemDef_t *Menu_SetPrevCursorItem(menuDef_t *menu);\nitemDef_t *Menu_SetNextCursorItem(menuDef_t *menu);\nstatic qboolean Menu_OverActiveItem(menuDef_t *menu, float x, float y);\n\n#ifdef CGAME\n#define MEM_POOL_SIZE  128 * 1024\n#else\n#define MEM_POOL_SIZE  1024 * 1024\n#endif\n\nstatic char\t\tmemoryPool[MEM_POOL_SIZE];\nstatic int\t\tallocPoint, outOfMemory;\n\n\n/*\n===============\nUI_Alloc\n===============\n*/\t\t\t\t  \nvoid *UI_Alloc( int size ) {\n\tchar\t*p; \n\n\tif ( allocPoint + size > MEM_POOL_SIZE ) {\n\t\toutOfMemory = qtrue;\n\t\tif (DC->Print) {\n\t\t\tDC->Print(\"UI_Alloc: Failure. Out of memory!\\n\");\n\t\t}\n    //DC->trap_Print(S_COLOR_YELLOW\"WARNING: UI Out of Memory!\\n\");\n\t\treturn NULL;\n\t}\n\n\tp = &memoryPool[allocPoint];\n\n\tallocPoint += ( size + 15 ) & ~15;\n\n\treturn p;\n}\n\n/*\n===============\nUI_InitMemory\n===============\n*/\nvoid UI_InitMemory( void ) {\n\tallocPoint = 0;\n\toutOfMemory = qfalse;\n}\n\nqboolean UI_OutOfMemory() {\n\treturn outOfMemory;\n}\n\n\n\n\n\n#define HASH_TABLE_SIZE 2048\n/*\n================\nreturn a hash value for the string\n================\n*/\nstatic long hashForString(const char *str) {\n\tint\t\ti;\n\tlong\thash;\n\tchar\tletter;\n\n\thash = 0;\n\ti = 0;\n\twhile (str[i] != '\\0') {\n\t\tletter = tolower(str[i]);\n\t\thash+=(long)(letter)*(i+119);\n\t\ti++;\n\t}\n\thash &= (HASH_TABLE_SIZE-1);\n\treturn hash;\n}\n\ntypedef struct stringDef_s {\n\tstruct stringDef_s *next;\n\tconst char *str;\n} stringDef_t;\n\nstatic int strPoolIndex = 0;\nstatic char strPool[STRING_POOL_SIZE];\n\nstatic int strHandleCount = 0;\nstatic stringDef_t *strHandle[HASH_TABLE_SIZE];\n\n\nconst char *String_Alloc(const char *p) {\n\tint len;\n\tlong hash;\n\tstringDef_t *str, *last;\n\tstatic const char *staticNULL = \"\";\n\n\tif (p == NULL) {\n\t\treturn NULL;\n\t}\n\n\tif (*p == 0) {\n\t\treturn staticNULL;\n\t}\n\n\thash = hashForString(p);\n\n\tstr = strHandle[hash];\n\twhile (str) {\n\t\tif (strcmp(p, str->str) == 0) {\n\t\t\treturn str->str;\n\t\t}\n\t\tstr = str->next;\n\t}\n\n\tlen = strlen(p);\n\tif (len + strPoolIndex + 1 < STRING_POOL_SIZE) {\n\t\tint ph = strPoolIndex;\n\t\tstrcpy(&strPool[strPoolIndex], p);\n\t\tstrPoolIndex += len + 1;\n\n\t\tstr = strHandle[hash];\n\t\tlast = str;\n\t\twhile (str && str->next) {\n\t\t\tlast = str;\n\t\t\tstr = str->next;\n\t\t}\n\n\t\tstr  = UI_Alloc(sizeof(stringDef_t));\n\t\tstr->next = NULL;\n\t\tstr->str = &strPool[ph];\n\t\tif (last) {\n\t\t\tlast->next = str;\n\t\t} else {\n\t\t\tstrHandle[hash] = str;\n\t\t}\n\t\treturn &strPool[ph];\n\t}\n\treturn NULL;\n}\n\nvoid String_Report() {\n\tfloat f;\n\tCom_Printf(\"Memory/String Pool Info\\n\");\n\tCom_Printf(\"----------------\\n\");\n\tf = strPoolIndex;\n\tf /= STRING_POOL_SIZE;\n\tf *= 100;\n\tCom_Printf(\"String Pool is %.1f%% full, %i bytes out of %i used.\\n\", f, strPoolIndex, STRING_POOL_SIZE);\n\tf = allocPoint;\n\tf /= MEM_POOL_SIZE;\n\tf *= 100;\n\tCom_Printf(\"Memory Pool is %.1f%% full, %i bytes out of %i used.\\n\", f, allocPoint, MEM_POOL_SIZE);\n}\n\n/*\n=================\nString_Init\n=================\n*/\nvoid String_Init() {\n\tint i;\n\tfor (i = 0; i < HASH_TABLE_SIZE; i++) {\n\t\tstrHandle[i] = 0;\n\t}\n\tstrHandleCount = 0;\n\tstrPoolIndex = 0;\n\tmenuCount = 0;\n\topenMenuCount = 0;\n\tUI_InitMemory();\n\tItem_SetupKeywordHash();\n\tMenu_SetupKeywordHash();\n\tif (DC && DC->getBindingBuf) {\n\t\tControls_GetConfig();\n\t}\n}\n\n/*\n=================\nPC_SourceWarning\n=================\n*/\nvoid PC_SourceWarning(int handle, char *format, ...) {\n\tint line;\n\tchar filename[128];\n\tva_list argptr;\n\tstatic char string[4096];\n\n\tva_start (argptr, format);\n\tvsprintf (string, format, argptr);\n\tva_end (argptr);\n\n\tfilename[0] = '\\0';\n\tline = 0;\n\ttrap_PC_SourceFileAndLine(handle, filename, &line);\n\n\tCom_Printf(S_COLOR_YELLOW \"WARNING: %s, line %d: %s\\n\", filename, line, string);\n}\n\n/*\n=================\nPC_SourceError\n=================\n*/\nvoid PC_SourceError(int handle, char *format, ...) {\n\tint line;\n\tchar filename[128];\n\tva_list argptr;\n\tstatic char string[4096];\n\n\tva_start (argptr, format);\n\tvsprintf (string, format, argptr);\n\tva_end (argptr);\n\n\tfilename[0] = '\\0';\n\tline = 0;\n\ttrap_PC_SourceFileAndLine(handle, filename, &line);\n\n\tCom_Printf(S_COLOR_RED \"ERROR: %s, line %d: %s\\n\", filename, line, string);\n}\n\n/*\n=================\nLerpColor\n=================\n*/\nvoid LerpColor(vec4_t a, vec4_t b, vec4_t c, float t)\n{\n\tint i;\n\n\t// lerp and clamp each component\n\tfor (i=0; i<4; i++)\n\t{\n\t\tc[i] = a[i] + t*(b[i]-a[i]);\n\t\tif (c[i] < 0)\n\t\t\tc[i] = 0;\n\t\telse if (c[i] > 1.0)\n\t\t\tc[i] = 1.0;\n\t}\n}\n\n/*\n=================\nFloat_Parse\n=================\n*/\nqboolean Float_Parse(char **p, float *f) {\n\tchar\t*token;\n\ttoken = COM_ParseExt(p, qfalse);\n\tif (token && token[0] != 0) {\n\t\t*f = atof(token);\n\t\treturn qtrue;\n\t} else {\n\t\treturn qfalse;\n\t}\n}\n\n/*\n=================\nPC_Float_Parse\n=================\n*/\nqboolean PC_Float_Parse(int handle, float *f) {\n\tpc_token_t token;\n\tint negative = qfalse;\n\n\tif (!trap_PC_ReadToken(handle, &token))\n\t\treturn qfalse;\n\tif (token.string[0] == '-') {\n\t\tif (!trap_PC_ReadToken(handle, &token))\n\t\t\treturn qfalse;\n\t\tnegative = qtrue;\n\t}\n\tif (token.type != TT_NUMBER) {\n\t\tPC_SourceError(handle, \"expected float but found %s\\n\", token.string);\n\t\treturn qfalse;\n\t}\n\tif (negative)\n\t\t*f = -token.floatvalue;\n\telse\n\t\t*f = token.floatvalue;\n\treturn qtrue;\n}\n\n/*\n=================\nColor_Parse\n=================\n*/\nqboolean Color_Parse(char **p, vec4_t *c) {\n\tint i;\n\tfloat f;\n\n\tfor (i = 0; i < 4; i++) {\n\t\tif (!Float_Parse(p, &f)) {\n\t\t\treturn qfalse;\n\t\t}\n\t\t(*c)[i] = f;\n\t}\n\treturn qtrue;\n}\n\n/*\n=================\nPC_Color_Parse\n=================\n*/\nqboolean PC_Color_Parse(int handle, vec4_t *c) {\n\tint i;\n\tfloat f;\n\n\tfor (i = 0; i < 4; i++) {\n\t\tif (!PC_Float_Parse(handle, &f)) {\n\t\t\treturn qfalse;\n\t\t}\n\t\t(*c)[i] = f;\n\t}\n\treturn qtrue;\n}\n\n/*\n=================\nInt_Parse\n=================\n*/\nqboolean Int_Parse(char **p, int *i) {\n\tchar\t*token;\n\ttoken = COM_ParseExt(p, qfalse);\n\n\tif (token && token[0] != 0) {\n\t\t*i = atoi(token);\n\t\treturn qtrue;\n\t} else {\n\t\treturn qfalse;\n\t}\n}\n\n/*\n=================\nPC_Int_Parse\n=================\n*/\nqboolean PC_Int_Parse(int handle, int *i) {\n\tpc_token_t token;\n\tint negative = qfalse;\n\n\tif (!trap_PC_ReadToken(handle, &token))\n\t\treturn qfalse;\n\tif (token.string[0] == '-') {\n\t\tif (!trap_PC_ReadToken(handle, &token))\n\t\t\treturn qfalse;\n\t\tnegative = qtrue;\n\t}\n\tif (token.type != TT_NUMBER) {\n\t\tPC_SourceError(handle, \"expected integer but found %s\\n\", token.string);\n\t\treturn qfalse;\n\t}\n\t*i = token.intvalue;\n\tif (negative)\n\t\t*i = - *i;\n\treturn qtrue;\n}\n\n/*\n=================\nRect_Parse\n=================\n*/\nqboolean Rect_Parse(char **p, rectDef_t *r) {\n\tif (Float_Parse(p, &r->x)) {\n\t\tif (Float_Parse(p, &r->y)) {\n\t\t\tif (Float_Parse(p, &r->w)) {\n\t\t\t\tif (Float_Parse(p, &r->h)) {\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n/*\n=================\nPC_Rect_Parse\n=================\n*/\nqboolean PC_Rect_Parse(int handle, rectDef_t *r) {\n\tif (PC_Float_Parse(handle, &r->x)) {\n\t\tif (PC_Float_Parse(handle, &r->y)) {\n\t\t\tif (PC_Float_Parse(handle, &r->w)) {\n\t\t\t\tif (PC_Float_Parse(handle, &r->h)) {\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n/*\n=================\nString_Parse\n=================\n*/\nqboolean String_Parse(char **p, const char **out) {\n\tchar *token;\n\n\ttoken = COM_ParseExt(p, qfalse);\n\tif (token && token[0] != 0) {\n\t\t*(out) = String_Alloc(token);\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n=================\nPC_String_Parse\n=================\n*/\nqboolean PC_String_Parse(int handle, const char **out) {\n\tpc_token_t token;\n\n\tif (!trap_PC_ReadToken(handle, &token))\n\t\treturn qfalse;\n\t\n\t*(out) = String_Alloc(token.string);\n    return qtrue;\n}\n\n/*\n=================\nPC_Script_Parse\n=================\n*/\nqboolean PC_Script_Parse(int handle, const char **out) {\n\tchar script[1024];\n\tpc_token_t token;\n\n\tmemset(script, 0, sizeof(script));\n\t// scripts start with { and have ; separated command lists.. commands are command, arg.. \n\t// basically we want everything between the { } as it will be interpreted at run time\n  \n\tif (!trap_PC_ReadToken(handle, &token))\n\t\treturn qfalse;\n\tif (Q_stricmp(token.string, \"{\") != 0) {\n\t    return qfalse;\n\t}\n\n\twhile ( 1 ) {\n\t\tif (!trap_PC_ReadToken(handle, &token))\n\t\t\treturn qfalse;\n\n\t\tif (Q_stricmp(token.string, \"}\") == 0) {\n\t\t\t*out = String_Alloc(script);\n\t\t\treturn qtrue;\n\t\t}\n\n\t\tif (token.string[1] != '\\0') {\n\t\t\tQ_strcat(script, 1024, va(\"\\\"%s\\\"\", token.string));\n\t\t} else {\n\t\t\tQ_strcat(script, 1024, token.string);\n\t\t}\n\t\tQ_strcat(script, 1024, \" \");\n\t}\n\treturn qfalse; \t// bk001105 - LCC   missing return value\n}\n\n// display, window, menu, item code\n// \n\n/*\n==================\nInit_Display\n\nInitializes the display with a structure to all the drawing routines\n ==================\n*/\nvoid Init_Display(displayContextDef_t *dc) {\n\tDC = dc;\n}\n\n\n\n// type and style painting \n\nvoid GradientBar_Paint(rectDef_t *rect, vec4_t color) {\n\t// gradient bar takes two paints\n\tDC->setColor( color );\n\tDC->drawHandlePic(rect->x, rect->y, rect->w, rect->h, DC->Assets.gradientBar);\n\tDC->setColor( NULL );\n}\n\n\n/*\n==================\nWindow_Init\n\nInitializes a window structure ( windowDef_t ) with defaults\n \n==================\n*/\nvoid Window_Init(Window *w) {\n\tmemset(w, 0, sizeof(windowDef_t));\n\tw->borderSize = 1;\n\tw->foreColor[0] = w->foreColor[1] = w->foreColor[2] = w->foreColor[3] = 1.0;\n\tw->cinematic = -1;\n}\n\nvoid Fade(int *flags, float *f, float clamp, int *nextTime, int offsetTime, qboolean bFlags, float fadeAmount) {\n  if (*flags & (WINDOW_FADINGOUT | WINDOW_FADINGIN)) {\n    if (DC->realTime > *nextTime) {\n      *nextTime = DC->realTime + offsetTime;\n      if (*flags & WINDOW_FADINGOUT) {\n        *f -= fadeAmount;\n        if (bFlags && *f <= 0.0) {\n          *flags &= ~(WINDOW_FADINGOUT | WINDOW_VISIBLE);\n        }\n      } else {\n        *f += fadeAmount;\n        if (*f >= clamp) {\n          *f = clamp;\n          if (bFlags) {\n            *flags &= ~WINDOW_FADINGIN;\n          }\n        }\n      }\n    }\n  }\n}\n\n\n\nvoid Window_Paint(Window *w, float fadeAmount, float fadeClamp, float fadeCycle) {\n  //float bordersize = 0;\n  vec4_t color;\n  rectDef_t fillRect = w->rect;\n\n\n  if (debugMode) {\n    color[0] = color[1] = color[2] = color[3] = 1;\n    DC->drawRect(w->rect.x, w->rect.y, w->rect.w, w->rect.h, 1, color);\n  }\n\n  if (w == NULL || (w->style == 0 && w->border == 0)) {\n    return;\n  }\n\n  if (w->border != 0) {\n    fillRect.x += w->borderSize;\n    fillRect.y += w->borderSize;\n    fillRect.w -= w->borderSize + 1;\n    fillRect.h -= w->borderSize + 1;\n  }\n\n  if (w->style == WINDOW_STYLE_FILLED) {\n    // box, but possible a shader that needs filled\n\t\tif (w->background) {\n\t\t  Fade(&w->flags, &w->backColor[3], fadeClamp, &w->nextTime, fadeCycle, qtrue, fadeAmount);\n      DC->setColor(w->backColor);\n\t    DC->drawHandlePic(fillRect.x, fillRect.y, fillRect.w, fillRect.h, w->background);\n\t\t  DC->setColor(NULL);\n\t\t} else {\n\t    DC->fillRect(fillRect.x, fillRect.y, fillRect.w, fillRect.h, w->backColor);\n\t\t}\n  } else if (w->style == WINDOW_STYLE_GRADIENT) {\n    GradientBar_Paint(&fillRect, w->backColor);\n    // gradient bar\n  } else if (w->style == WINDOW_STYLE_SHADER) {\n    if (w->flags & WINDOW_FORECOLORSET) {\n      DC->setColor(w->foreColor);\n    }\n    DC->drawHandlePic(fillRect.x, fillRect.y, fillRect.w, fillRect.h, w->background);\n    DC->setColor(NULL);\n  } else if (w->style == WINDOW_STYLE_TEAMCOLOR) {\n    if (DC->getTeamColor) {\n      DC->getTeamColor(&color);\n      DC->fillRect(fillRect.x, fillRect.y, fillRect.w, fillRect.h, color);\n    }\n  } else if (w->style == WINDOW_STYLE_CINEMATIC) {\n\t\tif (w->cinematic == -1) {\n\t\t\tw->cinematic = DC->playCinematic(w->cinematicName, fillRect.x, fillRect.y, fillRect.w, fillRect.h);\n\t\t\tif (w->cinematic == -1) {\n\t\t\t\tw->cinematic = -2;\n\t\t\t}\n\t\t} \n\t\tif (w->cinematic >= 0) {\n\t    DC->runCinematicFrame(w->cinematic);\n\t\t\tDC->drawCinematic(w->cinematic, fillRect.x, fillRect.y, fillRect.w, fillRect.h);\n\t\t}\n  }\n\n  if (w->border == WINDOW_BORDER_FULL) {\n    // full\n    // HACK HACK HACK\n    if (w->style == WINDOW_STYLE_TEAMCOLOR) {\n      if (color[0] > 0) { \n        // red\n        color[0] = 1;\n        color[1] = color[2] = .5;\n\n      } else {\n        color[2] = 1;\n        color[0] = color[1] = .5;\n      }\n      color[3] = 1;\n      DC->drawRect(w->rect.x, w->rect.y, w->rect.w, w->rect.h, w->borderSize, color);\n    } else {\n      DC->drawRect(w->rect.x, w->rect.y, w->rect.w, w->rect.h, w->borderSize, w->borderColor);\n    }\n  } else if (w->border == WINDOW_BORDER_HORZ) {\n    // top/bottom\n    DC->setColor(w->borderColor);\n    DC->drawTopBottom(w->rect.x, w->rect.y, w->rect.w, w->rect.h, w->borderSize);\n  \tDC->setColor( NULL );\n  } else if (w->border == WINDOW_BORDER_VERT) {\n    // left right\n    DC->setColor(w->borderColor);\n    DC->drawSides(w->rect.x, w->rect.y, w->rect.w, w->rect.h, w->borderSize);\n  \tDC->setColor( NULL );\n  } else if (w->border == WINDOW_BORDER_KCGRADIENT) {\n    // this is just two gradient bars along each horz edge\n    rectDef_t r = w->rect;\n    r.h = w->borderSize;\n    GradientBar_Paint(&r, w->borderColor);\n    r.y = w->rect.y + w->rect.h - 1;\n    GradientBar_Paint(&r, w->borderColor);\n  }\n\n}\n\n\nvoid Item_SetScreenCoords(itemDef_t *item, float x, float y) {\n  \n  if (item == NULL) {\n    return;\n  }\n\n  if (item->window.border != 0) {\n    x += item->window.borderSize;\n    y += item->window.borderSize;\n  }\n\n  item->window.rect.x = x + item->window.rectClient.x;\n  item->window.rect.y = y + item->window.rectClient.y;\n  item->window.rect.w = item->window.rectClient.w;\n  item->window.rect.h = item->window.rectClient.h;\n\n  // force the text rects to recompute\n  item->textRect.w = 0;\n  item->textRect.h = 0;\n}\n\n// FIXME: consolidate this with nearby stuff\nvoid Item_UpdatePosition(itemDef_t *item) {\n  float x, y;\n  menuDef_t *menu;\n  \n  if (item == NULL || item->parent == NULL) {\n    return;\n  }\n\n  menu = item->parent;\n\n  x = menu->window.rect.x;\n  y = menu->window.rect.y;\n  \n  if (menu->window.border != 0) {\n    x += menu->window.borderSize;\n    y += menu->window.borderSize;\n  }\n\n  Item_SetScreenCoords(item, x, y);\n\n}\n\n// menus\nvoid Menu_UpdatePosition(menuDef_t *menu) {\n  int i;\n  float x, y;\n\n  if (menu == NULL) {\n    return;\n  }\n  \n  x = menu->window.rect.x;\n  y = menu->window.rect.y;\n  if (menu->window.border != 0) {\n    x += menu->window.borderSize;\n    y += menu->window.borderSize;\n  }\n\n  for (i = 0; i < menu->itemCount; i++) {\n    Item_SetScreenCoords(menu->items[i], x, y);\n  }\n}\n\nvoid Menu_PostParse(menuDef_t *menu) {\n\tif (menu == NULL) {\n\t\treturn;\n\t}\n\tif (menu->fullScreen) {\n\t\tmenu->window.rect.x = 0;\n\t\tmenu->window.rect.y = 0;\n\t\tmenu->window.rect.w = 640;\n\t\tmenu->window.rect.h = 480;\n\t}\n\tMenu_UpdatePosition(menu);\n}\n\nitemDef_t *Menu_ClearFocus(menuDef_t *menu) {\n  int i;\n  itemDef_t *ret = NULL;\n\n  if (menu == NULL) {\n    return NULL;\n  }\n\n  for (i = 0; i < menu->itemCount; i++) {\n    if (menu->items[i]->window.flags & WINDOW_HASFOCUS) {\n      ret = menu->items[i];\n    } \n    menu->items[i]->window.flags &= ~WINDOW_HASFOCUS;\n    if (menu->items[i]->leaveFocus) {\n      Item_RunScript(menu->items[i], menu->items[i]->leaveFocus);\n    }\n  }\n \n  return ret;\n}\n\nqboolean IsVisible(int flags) {\n  return (flags & WINDOW_VISIBLE && !(flags & WINDOW_FADINGOUT));\n}\n\nqboolean Rect_ContainsPoint(rectDef_t *rect, float x, float y) {\n  if (rect) {\n    if (x > rect->x && x < rect->x + rect->w && y > rect->y && y < rect->y + rect->h) {\n      return qtrue;\n    }\n  }\n  return qfalse;\n}\n\nint Menu_ItemsMatchingGroup(menuDef_t *menu, const char *name) {\n  int i;\n  int count = 0;\n  for (i = 0; i < menu->itemCount; i++) {\n    if (Q_stricmp(menu->items[i]->window.name, name) == 0 || (menu->items[i]->window.group && Q_stricmp(menu->items[i]->window.group, name) == 0)) {\n      count++;\n    } \n  }\n  return count;\n}\n\nitemDef_t *Menu_GetMatchingItemByNumber(menuDef_t *menu, int index, const char *name) {\n  int i;\n  int count = 0;\n  for (i = 0; i < menu->itemCount; i++) {\n    if (Q_stricmp(menu->items[i]->window.name, name) == 0 || (menu->items[i]->window.group && Q_stricmp(menu->items[i]->window.group, name) == 0)) {\n      if (count == index) {\n        return menu->items[i];\n      }\n      count++;\n    } \n  }\n  return NULL;\n}\n\n\n\nvoid Script_SetColor(itemDef_t *item, char **args) {\n  const char *name;\n  int i;\n  float f;\n  vec4_t *out;\n  // expecting type of color to set and 4 args for the color\n  if (String_Parse(args, &name)) {\n      out = NULL;\n      if (Q_stricmp(name, \"backcolor\") == 0) {\n        out = &item->window.backColor;\n        item->window.flags |= WINDOW_BACKCOLORSET;\n      } else if (Q_stricmp(name, \"forecolor\") == 0) {\n        out = &item->window.foreColor;\n        item->window.flags |= WINDOW_FORECOLORSET;\n      } else if (Q_stricmp(name, \"bordercolor\") == 0) {\n        out = &item->window.borderColor;\n      }\n\n      if (out) {\n        for (i = 0; i < 4; i++) {\n          if (!Float_Parse(args, &f)) {\n            return;\n          }\n          (*out)[i] = f;\n        }\n      }\n  }\n}\n\nvoid Script_SetAsset(itemDef_t *item, char **args) {\n  const char *name;\n  // expecting name to set asset to\n  if (String_Parse(args, &name)) {\n    // check for a model \n    if (item->type == ITEM_TYPE_MODEL) {\n    }\n  }\n}\n\nvoid Script_SetBackground(itemDef_t *item, char **args) {\n  const char *name;\n  // expecting name to set asset to\n  if (String_Parse(args, &name)) {\n    item->window.background = DC->registerShaderNoMip(name);\n  }\n}\n\n\n\n\nitemDef_t *Menu_FindItemByName(menuDef_t *menu, const char *p) {\n  int i;\n  if (menu == NULL || p == NULL) {\n    return NULL;\n  }\n\n  for (i = 0; i < menu->itemCount; i++) {\n    if (Q_stricmp(p, menu->items[i]->window.name) == 0) {\n      return menu->items[i];\n    }\n  }\n\n  return NULL;\n}\n\nvoid Script_SetTeamColor(itemDef_t *item, char **args) {\n  if (DC->getTeamColor) {\n    int i;\n    vec4_t color;\n    DC->getTeamColor(&color);\n    for (i = 0; i < 4; i++) {\n      item->window.backColor[i] = color[i];\n    }\n  }\n}\n\nvoid Script_SetItemColor(itemDef_t *item, char **args) {\n  const char *itemname;\n  const char *name;\n  vec4_t color;\n  int i;\n  vec4_t *out;\n  // expecting type of color to set and 4 args for the color\n  if (String_Parse(args, &itemname) && String_Parse(args, &name)) {\n    itemDef_t *item2;\n    int j;\n    int count = Menu_ItemsMatchingGroup(item->parent, itemname);\n\n    if (!Color_Parse(args, &color)) {\n      return;\n    }\n\n    for (j = 0; j < count; j++) {\n      item2 = Menu_GetMatchingItemByNumber(item->parent, j, itemname);\n      if (item2 != NULL) {\n        out = NULL;\n        if (Q_stricmp(name, \"backcolor\") == 0) {\n          out = &item2->window.backColor;\n        } else if (Q_stricmp(name, \"forecolor\") == 0) {\n          out = &item2->window.foreColor;\n          item2->window.flags |= WINDOW_FORECOLORSET;\n        } else if (Q_stricmp(name, \"bordercolor\") == 0) {\n          out = &item2->window.borderColor;\n        }\n\n        if (out) {\n          for (i = 0; i < 4; i++) {\n            (*out)[i] = color[i];\n          }\n        }\n      }\n    }\n  }\n}\n\n\nvoid Menu_ShowItemByName(menuDef_t *menu, const char *p, qboolean bShow) {\n\titemDef_t *item;\n\tint i;\n\tint count = Menu_ItemsMatchingGroup(menu, p);\n\tfor (i = 0; i < count; i++) {\n\t\titem = Menu_GetMatchingItemByNumber(menu, i, p);\n\t\tif (item != NULL) {\n\t\t\tif (bShow) {\n\t\t\t\titem->window.flags |= WINDOW_VISIBLE;\n\t\t\t} else {\n\t\t\t\titem->window.flags &= ~WINDOW_VISIBLE;\n\t\t\t\t// stop cinematics playing in the window\n\t\t\t\tif (item->window.cinematic >= 0) {\n\t\t\t\t\tDC->stopCinematic(item->window.cinematic);\n\t\t\t\t\titem->window.cinematic = -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid Menu_FadeItemByName(menuDef_t *menu, const char *p, qboolean fadeOut) {\n  itemDef_t *item;\n  int i;\n  int count = Menu_ItemsMatchingGroup(menu, p);\n  for (i = 0; i < count; i++) {\n    item = Menu_GetMatchingItemByNumber(menu, i, p);\n    if (item != NULL) {\n      if (fadeOut) {\n        item->window.flags |= (WINDOW_FADINGOUT | WINDOW_VISIBLE);\n        item->window.flags &= ~WINDOW_FADINGIN;\n      } else {\n        item->window.flags |= (WINDOW_VISIBLE | WINDOW_FADINGIN);\n        item->window.flags &= ~WINDOW_FADINGOUT;\n      }\n    }\n  }\n}\n\nmenuDef_t *Menus_FindByName(const char *p) {\n  int i;\n  for (i = 0; i < menuCount; i++) {\n    if (Q_stricmp(Menus[i].window.name, p) == 0) {\n      return &Menus[i];\n    } \n  }\n  return NULL;\n}\n\nvoid Menus_ShowByName(const char *p) {\n\tmenuDef_t *menu = Menus_FindByName(p);\n\tif (menu) {\n\t\tMenus_Activate(menu);\n\t}\n}\n\nvoid Menus_OpenByName(const char *p) {\n  Menus_ActivateByName(p);\n}\n\nstatic void Menu_RunCloseScript(menuDef_t *menu) {\n\tif (menu && menu->window.flags & WINDOW_VISIBLE && menu->onClose) {\n\t\titemDef_t item;\n    item.parent = menu;\n    Item_RunScript(&item, menu->onClose);\n\t}\n}\n\nvoid Menus_CloseByName(const char *p) {\n  menuDef_t *menu = Menus_FindByName(p);\n  if (menu != NULL) {\n\t\tMenu_RunCloseScript(menu);\n\t\tmenu->window.flags &= ~(WINDOW_VISIBLE | WINDOW_HASFOCUS);\n  }\n}\n\nvoid Menus_CloseAll() {\n  int i;\n  for (i = 0; i < menuCount; i++) {\n\t\tMenu_RunCloseScript(&Menus[i]);\n\t\tMenus[i].window.flags &= ~(WINDOW_HASFOCUS | WINDOW_VISIBLE);\n  }\n}\n\n\nvoid Script_Show(itemDef_t *item, char **args) {\n  const char *name;\n  if (String_Parse(args, &name)) {\n    Menu_ShowItemByName(item->parent, name, qtrue);\n  }\n}\n\nvoid Script_Hide(itemDef_t *item, char **args) {\n  const char *name;\n  if (String_Parse(args, &name)) {\n    Menu_ShowItemByName(item->parent, name, qfalse);\n  }\n}\n\nvoid Script_FadeIn(itemDef_t *item, char **args) {\n  const char *name;\n  if (String_Parse(args, &name)) {\n    Menu_FadeItemByName(item->parent, name, qfalse);\n  }\n}\n\nvoid Script_FadeOut(itemDef_t *item, char **args) {\n  const char *name;\n  if (String_Parse(args, &name)) {\n    Menu_FadeItemByName(item->parent, name, qtrue);\n  }\n}\n\n\n\nvoid Script_Open(itemDef_t *item, char **args) {\n  const char *name;\n  if (String_Parse(args, &name)) {\n    Menus_OpenByName(name);\n  }\n}\n\nvoid Script_ConditionalOpen(itemDef_t *item, char **args) {\n\tconst char *cvar;\n\tconst char *name1;\n\tconst char *name2;\n\tfloat           val;\n\n\tif ( String_Parse(args, &cvar) && String_Parse(args, &name1) && String_Parse(args, &name2) ) {\n\t\tval = DC->getCVarValue( cvar );\n\t\tif ( val == 0.f ) {\n\t\t\tMenus_OpenByName(name2);\n\t\t} else {\n\t\t\tMenus_OpenByName(name1);\n\t\t}\n\t}\n}\n\nvoid Script_Close(itemDef_t *item, char **args) {\n  const char *name;\n  if (String_Parse(args, &name)) {\n    Menus_CloseByName(name);\n  }\n}\n\nvoid Menu_TransitionItemByName(menuDef_t *menu, const char *p, rectDef_t rectFrom, rectDef_t rectTo, int time, float amt) {\n  itemDef_t *item;\n  int i;\n  int count = Menu_ItemsMatchingGroup(menu, p);\n  for (i = 0; i < count; i++) {\n    item = Menu_GetMatchingItemByNumber(menu, i, p);\n    if (item != NULL) {\n      item->window.flags |= (WINDOW_INTRANSITION | WINDOW_VISIBLE);\n      item->window.offsetTime = time;\n\t\t\tmemcpy(&item->window.rectClient, &rectFrom, sizeof(rectDef_t));\n\t\t\tmemcpy(&item->window.rectEffects, &rectTo, sizeof(rectDef_t));\n\t\t\titem->window.rectEffects2.x = abs(rectTo.x - rectFrom.x) / amt;\n\t\t\titem->window.rectEffects2.y = abs(rectTo.y - rectFrom.y) / amt;\n\t\t\titem->window.rectEffects2.w = abs(rectTo.w - rectFrom.w) / amt;\n\t\t\titem->window.rectEffects2.h = abs(rectTo.h - rectFrom.h) / amt;\n      Item_UpdatePosition(item);\n    }\n  }\n}\n\n\nvoid Script_Transition(itemDef_t *item, char **args) {\n  const char *name;\n\trectDef_t rectFrom, rectTo;\n  int time;\n\tfloat amt;\n\n  if (String_Parse(args, &name)) {\n    if ( Rect_Parse(args, &rectFrom) && Rect_Parse(args, &rectTo) && Int_Parse(args, &time) && Float_Parse(args, &amt)) {\n      Menu_TransitionItemByName(item->parent, name, rectFrom, rectTo, time, amt);\n    }\n  }\n}\n\n\nvoid Menu_OrbitItemByName(menuDef_t *menu, const char *p, float x, float y, float cx, float cy, int time) {\n  itemDef_t *item;\n  int i;\n  int count = Menu_ItemsMatchingGroup(menu, p);\n  for (i = 0; i < count; i++) {\n    item = Menu_GetMatchingItemByNumber(menu, i, p);\n    if (item != NULL) {\n      item->window.flags |= (WINDOW_ORBITING | WINDOW_VISIBLE);\n      item->window.offsetTime = time;\n      item->window.rectEffects.x = cx;\n      item->window.rectEffects.y = cy;\n      item->window.rectClient.x = x;\n      item->window.rectClient.y = y;\n      Item_UpdatePosition(item);\n    }\n  }\n}\n\n\nvoid Script_Orbit(itemDef_t *item, char **args) {\n  const char *name;\n  float cx, cy, x, y;\n  int time;\n\n  if (String_Parse(args, &name)) {\n    if ( Float_Parse(args, &x) && Float_Parse(args, &y) && Float_Parse(args, &cx) && Float_Parse(args, &cy) && Int_Parse(args, &time) ) {\n      Menu_OrbitItemByName(item->parent, name, x, y, cx, cy, time);\n    }\n  }\n}\n\n\n\nvoid Script_SetFocus(itemDef_t *item, char **args) {\n  const char *name;\n  itemDef_t *focusItem;\n\n  if (String_Parse(args, &name)) {\n    focusItem = Menu_FindItemByName(item->parent, name);\n    if (focusItem && !(focusItem->window.flags & WINDOW_DECORATION) && !(focusItem->window.flags & WINDOW_HASFOCUS)) {\n      Menu_ClearFocus(item->parent);\n      focusItem->window.flags |= WINDOW_HASFOCUS;\n      if (focusItem->onFocus) {\n        Item_RunScript(focusItem, focusItem->onFocus);\n      }\n      if (DC->Assets.itemFocusSound) {\n        DC->startLocalSound( DC->Assets.itemFocusSound, CHAN_LOCAL_SOUND );\n      }\n    }\n  }\n}\n\nvoid Script_SetPlayerModel(itemDef_t *item, char **args) {\n  const char *name;\n  if (String_Parse(args, &name)) {\n    DC->setCVar(\"team_model\", name);\n  }\n}\n\nvoid Script_SetPlayerHead(itemDef_t *item, char **args) {\n  const char *name;\n  if (String_Parse(args, &name)) {\n    DC->setCVar(\"team_headmodel\", name);\n  }\n}\n\nvoid Script_SetCvar(itemDef_t *item, char **args) {\n\tconst char *cvar, *val;\n\tif (String_Parse(args, &cvar) && String_Parse(args, &val)) {\n\t\tDC->setCVar(cvar, val);\n\t}\n\t\n}\n\nvoid Script_Exec(itemDef_t *item, char **args) {\n\tconst char *val;\n\tif (String_Parse(args, &val)) {\n\t\tDC->executeText(EXEC_APPEND, va(\"%s ; \", val));\n\t}\n}\n\nvoid Script_Play(itemDef_t *item, char **args) {\n\tconst char *val;\n\tif (String_Parse(args, &val)) {\n\t\tDC->startLocalSound(DC->registerSound(val, qfalse), CHAN_LOCAL_SOUND);\n\t}\n}\n\nvoid Script_playLooped(itemDef_t *item, char **args) {\n\tconst char *val;\n\tif (String_Parse(args, &val)) {\n\t\tDC->stopBackgroundTrack();\n\t\tDC->startBackgroundTrack(val, val);\n\t}\n}\n\n\ncommandDef_t commandList[] =\n{\n  {\"fadein\", &Script_FadeIn},                   // group/name\n  {\"fadeout\", &Script_FadeOut},                 // group/name\n  {\"show\", &Script_Show},                       // group/name\n  {\"hide\", &Script_Hide},                       // group/name\n  {\"setcolor\", &Script_SetColor},               // works on this\n  {\"open\", &Script_Open},                       // menu\n\t{\"conditionalopen\", &Script_ConditionalOpen},\t// menu\n  {\"close\", &Script_Close},                     // menu\n  {\"setasset\", &Script_SetAsset},               // works on this\n  {\"setbackground\", &Script_SetBackground},     // works on this\n  {\"setitemcolor\", &Script_SetItemColor},       // group/name\n  {\"setteamcolor\", &Script_SetTeamColor},       // sets this background color to team color\n  {\"setfocus\", &Script_SetFocus},               // sets this background color to team color\n  {\"setplayermodel\", &Script_SetPlayerModel},   // sets this background color to team color\n  {\"setplayerhead\", &Script_SetPlayerHead},     // sets this background color to team color\n  {\"transition\", &Script_Transition},           // group/name\n  {\"setcvar\", &Script_SetCvar},           // group/name\n  {\"exec\", &Script_Exec},           // group/name\n  {\"play\", &Script_Play},           // group/name\n  {\"playlooped\", &Script_playLooped},           // group/name\n  {\"orbit\", &Script_Orbit}                      // group/name\n};\n\nint scriptCommandCount = sizeof(commandList) / sizeof(commandDef_t);\n\n\nvoid Item_RunScript(itemDef_t *item, const char *s) {\n  char script[1024], *p;\n  int i;\n  qboolean bRan;\n  memset(script, 0, sizeof(script));\n  if (item && s && s[0]) {\n    Q_strcat(script, 1024, s);\n    p = script;\n    while (1) {\n      const char *command;\n      // expect command then arguments, ; ends command, NULL ends script\n      if (!String_Parse(&p, &command)) {\n        return;\n      }\n\n      if (command[0] == ';' && command[1] == '\\0') {\n        continue;\n      }\n\n      bRan = qfalse;\n      for (i = 0; i < scriptCommandCount; i++) {\n        if (Q_stricmp(command, commandList[i].name) == 0) {\n          (commandList[i].handler(item, &p));\n          bRan = qtrue;\n          break;\n        }\n      }\n      // not in our auto list, pass to handler\n      if (!bRan) {\n        DC->runScript(&p);\n      }\n    }\n  }\n}\n\n\nqboolean Item_EnableShowViaCvar(itemDef_t *item, int flag) {\n  char script[1024], *p;\n  memset(script, 0, sizeof(script));\n  if (item && item->enableCvar && *item->enableCvar && item->cvarTest && *item->cvarTest) {\n\t\tchar buff[1024];\n\t  DC->getCVarString(item->cvarTest, buff, sizeof(buff));\n\n    Q_strcat(script, 1024, item->enableCvar);\n    p = script;\n    while (1) {\n      const char *val;\n      // expect value then ; or NULL, NULL ends list\n      if (!String_Parse(&p, &val)) {\n\t\t\t\treturn (item->cvarFlags & flag) ? qfalse : qtrue;\n      }\n\n      if (val[0] == ';' && val[1] == '\\0') {\n        continue;\n      }\n\n\t\t\t// enable it if any of the values are true\n\t\t\tif (item->cvarFlags & flag) {\n        if (Q_stricmp(buff, val) == 0) {\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// disable it if any of the values are true\n        if (Q_stricmp(buff, val) == 0) {\n\t\t\t\t\treturn qfalse;\n\t\t\t\t}\n\t\t\t}\n\n    }\n\t\treturn (item->cvarFlags & flag) ? qfalse : qtrue;\n  }\n\treturn qtrue;\n}\n\n\n// will optionaly set focus to this item \nqboolean Item_SetFocus(itemDef_t *item, float x, float y) {\n\tint i;\n\titemDef_t *oldFocus;\n\tsfxHandle_t *sfx = &DC->Assets.itemFocusSound;\n\tqboolean playSound = qfalse;\n\tmenuDef_t *parent; // bk001206: = (menuDef_t*)item->parent;\n\t// sanity check, non-null, not a decoration and does not already have the focus\n\tif (item == NULL || item->window.flags & WINDOW_DECORATION || item->window.flags & WINDOW_HASFOCUS || !(item->window.flags & WINDOW_VISIBLE)) {\n\t\treturn qfalse;\n\t}\n\n\t// bk001206 - this can be NULL.\n\tparent = (menuDef_t*)item->parent; \n      \n\t// items can be enabled and disabled based on cvars\n\tif (item->cvarFlags & (CVAR_ENABLE | CVAR_DISABLE) && !Item_EnableShowViaCvar(item, CVAR_ENABLE)) {\n\t\treturn qfalse;\n\t}\n\n\tif (item->cvarFlags & (CVAR_SHOW | CVAR_HIDE) && !Item_EnableShowViaCvar(item, CVAR_SHOW)) {\n\t\treturn qfalse;\n\t}\n\n\toldFocus = Menu_ClearFocus(item->parent);\n\n\tif (item->type == ITEM_TYPE_TEXT) {\n\t\trectDef_t r;\n\t\tr = item->textRect;\n\t\tr.y -= r.h;\n\t\tif (Rect_ContainsPoint(&r, x, y)) {\n\t\t\titem->window.flags |= WINDOW_HASFOCUS;\n\t\t\tif (item->focusSound) {\n\t\t\t\tsfx = &item->focusSound;\n\t\t\t}\n\t\t\tplaySound = qtrue;\n\t\t} else {\n\t\t\tif (oldFocus) {\n\t\t\t\toldFocus->window.flags |= WINDOW_HASFOCUS;\n\t\t\t\tif (oldFocus->onFocus) {\n\t\t\t\t\tItem_RunScript(oldFocus, oldFocus->onFocus);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t    item->window.flags |= WINDOW_HASFOCUS;\n\t\tif (item->onFocus) {\n\t\t\tItem_RunScript(item, item->onFocus);\n\t\t}\n\t\tif (item->focusSound) {\n\t\t\tsfx = &item->focusSound;\n\t\t}\n\t\tplaySound = qtrue;\n\t}\n\n\tif (playSound && sfx) {\n\t\tDC->startLocalSound( *sfx, CHAN_LOCAL_SOUND );\n\t}\n\n\tfor (i = 0; i < parent->itemCount; i++) {\n\t\tif (parent->items[i] == item) {\n\t\t\tparent->cursorItem = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn qtrue;\n}\n\nint Item_ListBox_MaxScroll(itemDef_t *item) {\n\tlistBoxDef_t *listPtr = (listBoxDef_t*)item->typeData;\n\tint count = DC->feederCount(item->special);\n\tint max;\n\n\tif (item->window.flags & WINDOW_HORIZONTAL) {\n\t\tmax = count - (item->window.rect.w / listPtr->elementWidth) + 1;\n\t}\n\telse {\n\t\tmax = count - (item->window.rect.h / listPtr->elementHeight) + 1;\n\t}\n\tif (max < 0) {\n\t\treturn 0;\n\t}\n\treturn max;\n}\n\nint Item_ListBox_ThumbPosition(itemDef_t *item) {\n\tfloat max, pos, size;\n\tlistBoxDef_t *listPtr = (listBoxDef_t*)item->typeData;\n\n\tmax = Item_ListBox_MaxScroll(item);\n\tif (item->window.flags & WINDOW_HORIZONTAL) {\n\t\tsize = item->window.rect.w - (SCROLLBAR_SIZE * 2) - 2;\n\t\tif (max > 0) {\n\t\t\tpos = (size-SCROLLBAR_SIZE) / (float) max;\n\t\t} else {\n\t\t\tpos = 0;\n\t\t}\n\t\tpos *= listPtr->startPos;\n\t\treturn item->window.rect.x + 1 + SCROLLBAR_SIZE + pos;\n\t}\n\telse {\n\t\tsize = item->window.rect.h - (SCROLLBAR_SIZE * 2) - 2;\n\t\tif (max > 0) {\n\t\t\tpos = (size-SCROLLBAR_SIZE) / (float) max;\n\t\t} else {\n\t\t\tpos = 0;\n\t\t}\n\t\tpos *= listPtr->startPos;\n\t\treturn item->window.rect.y + 1 + SCROLLBAR_SIZE + pos;\n\t}\n}\n\nint Item_ListBox_ThumbDrawPosition(itemDef_t *item) {\n\tint min, max;\n\n\tif (itemCapture == item) {\n\t\tif (item->window.flags & WINDOW_HORIZONTAL) {\n\t\t\tmin = item->window.rect.x + SCROLLBAR_SIZE + 1;\n\t\t\tmax = item->window.rect.x + item->window.rect.w - 2*SCROLLBAR_SIZE - 1;\n\t\t\tif (DC->cursorx >= min + SCROLLBAR_SIZE/2 && DC->cursorx <= max + SCROLLBAR_SIZE/2) {\n\t\t\t\treturn DC->cursorx - SCROLLBAR_SIZE/2;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn Item_ListBox_ThumbPosition(item);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tmin = item->window.rect.y + SCROLLBAR_SIZE + 1;\n\t\t\tmax = item->window.rect.y + item->window.rect.h - 2*SCROLLBAR_SIZE - 1;\n\t\t\tif (DC->cursory >= min + SCROLLBAR_SIZE/2 && DC->cursory <= max + SCROLLBAR_SIZE/2) {\n\t\t\t\treturn DC->cursory - SCROLLBAR_SIZE/2;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn Item_ListBox_ThumbPosition(item);\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\treturn Item_ListBox_ThumbPosition(item);\n\t}\n}\n\nfloat Item_Slider_ThumbPosition(itemDef_t *item) {\n\tfloat value, range, x;\n\teditFieldDef_t *editDef = item->typeData;\n\n\tif (item->text) {\n\t\tx = item->textRect.x + item->textRect.w + 8;\n\t} else {\n\t\tx = item->window.rect.x;\n\t}\n\n\tif (editDef == NULL && item->cvar) {\n\t\treturn x;\n\t}\n\n\tvalue = DC->getCVarValue(item->cvar);\n\n\tif (value < editDef->minVal) {\n\t\tvalue = editDef->minVal;\n\t} else if (value > editDef->maxVal) {\n\t\tvalue = editDef->maxVal;\n\t}\n\n\trange = editDef->maxVal - editDef->minVal;\n\tvalue -= editDef->minVal;\n\tvalue /= range;\n\t//value /= (editDef->maxVal - editDef->minVal);\n\tvalue *= SLIDER_WIDTH;\n\tx += value;\n\t// vm fuckage\n\t//x = x + (((float)value / editDef->maxVal) * SLIDER_WIDTH);\n\treturn x;\n}\n\nint Item_Slider_OverSlider(itemDef_t *item, float x, float y) {\n\trectDef_t r;\n\n\tr.x = Item_Slider_ThumbPosition(item) - (SLIDER_THUMB_WIDTH / 2);\n\tr.y = item->window.rect.y - 2;\n\tr.w = SLIDER_THUMB_WIDTH;\n\tr.h = SLIDER_THUMB_HEIGHT;\n\n\tif (Rect_ContainsPoint(&r, x, y)) {\n\t\treturn WINDOW_LB_THUMB;\n\t}\n\treturn 0;\n}\n\nint Item_ListBox_OverLB(itemDef_t *item, float x, float y) {\n\trectDef_t r;\n\tlistBoxDef_t *listPtr;\n\tint thumbstart;\n\tint count;\n\n\tcount = DC->feederCount(item->special);\n\tlistPtr = (listBoxDef_t*)item->typeData;\n\tif (item->window.flags & WINDOW_HORIZONTAL) {\n\t\t// check if on left arrow\n\t\tr.x = item->window.rect.x;\n\t\tr.y = item->window.rect.y + item->window.rect.h - SCROLLBAR_SIZE;\n\t\tr.h = r.w = SCROLLBAR_SIZE;\n\t\tif (Rect_ContainsPoint(&r, x, y)) {\n\t\t\treturn WINDOW_LB_LEFTARROW;\n\t\t}\n\t\t// check if on right arrow\n\t\tr.x = item->window.rect.x + item->window.rect.w - SCROLLBAR_SIZE;\n\t\tif (Rect_ContainsPoint(&r, x, y)) {\n\t\t\treturn WINDOW_LB_RIGHTARROW;\n\t\t}\n\t\t// check if on thumb\n\t\tthumbstart = Item_ListBox_ThumbPosition(item);\n\t\tr.x = thumbstart;\n\t\tif (Rect_ContainsPoint(&r, x, y)) {\n\t\t\treturn WINDOW_LB_THUMB;\n\t\t}\n\t\tr.x = item->window.rect.x + SCROLLBAR_SIZE;\n\t\tr.w = thumbstart - r.x;\n\t\tif (Rect_ContainsPoint(&r, x, y)) {\n\t\t\treturn WINDOW_LB_PGUP;\n\t\t}\n\t\tr.x = thumbstart + SCROLLBAR_SIZE;\n\t\tr.w = item->window.rect.x + item->window.rect.w - SCROLLBAR_SIZE;\n\t\tif (Rect_ContainsPoint(&r, x, y)) {\n\t\t\treturn WINDOW_LB_PGDN;\n\t\t}\n\t} else {\n\t\tr.x = item->window.rect.x + item->window.rect.w - SCROLLBAR_SIZE;\n\t\tr.y = item->window.rect.y;\n\t\tr.h = r.w = SCROLLBAR_SIZE;\n\t\tif (Rect_ContainsPoint(&r, x, y)) {\n\t\t\treturn WINDOW_LB_LEFTARROW;\n\t\t}\n\t\tr.y = item->window.rect.y + item->window.rect.h - SCROLLBAR_SIZE;\n\t\tif (Rect_ContainsPoint(&r, x, y)) {\n\t\t\treturn WINDOW_LB_RIGHTARROW;\n\t\t}\n\t\tthumbstart = Item_ListBox_ThumbPosition(item);\n\t\tr.y = thumbstart;\n\t\tif (Rect_ContainsPoint(&r, x, y)) {\n\t\t\treturn WINDOW_LB_THUMB;\n\t\t}\n\t\tr.y = item->window.rect.y + SCROLLBAR_SIZE;\n\t\tr.h = thumbstart - r.y;\n\t\tif (Rect_ContainsPoint(&r, x, y)) {\n\t\t\treturn WINDOW_LB_PGUP;\n\t\t}\n\t\tr.y = thumbstart + SCROLLBAR_SIZE;\n\t\tr.h = item->window.rect.y + item->window.rect.h - SCROLLBAR_SIZE;\n\t\tif (Rect_ContainsPoint(&r, x, y)) {\n\t\t\treturn WINDOW_LB_PGDN;\n\t\t}\n\t}\n\treturn 0;\n}\n\n\nvoid Item_ListBox_MouseEnter(itemDef_t *item, float x, float y) \n{\n\trectDef_t r;\n\tlistBoxDef_t *listPtr = (listBoxDef_t*)item->typeData;\n        \n\titem->window.flags &= ~(WINDOW_LB_LEFTARROW | WINDOW_LB_RIGHTARROW | WINDOW_LB_THUMB | WINDOW_LB_PGUP | WINDOW_LB_PGDN);\n\titem->window.flags |= Item_ListBox_OverLB(item, x, y);\n\n\tif (item->window.flags & WINDOW_HORIZONTAL) {\n\t\tif (!(item->window.flags & (WINDOW_LB_LEFTARROW | WINDOW_LB_RIGHTARROW | WINDOW_LB_THUMB | WINDOW_LB_PGUP | WINDOW_LB_PGDN))) {\n\t\t\t// check for selection hit as we have exausted buttons and thumb\n\t\t\tif (listPtr->elementStyle == LISTBOX_IMAGE) {\n\t\t\t\tr.x = item->window.rect.x;\n\t\t\t\tr.y = item->window.rect.y;\n\t\t\t\tr.h = item->window.rect.h - SCROLLBAR_SIZE;\n\t\t\t\tr.w = item->window.rect.w - listPtr->drawPadding;\n\t\t\t\tif (Rect_ContainsPoint(&r, x, y)) {\n\t\t\t\t\tlistPtr->cursorPos =  (int)((x - r.x) / listPtr->elementWidth)  + listPtr->startPos;\n\t\t\t\t\tif (listPtr->cursorPos >= listPtr->endPos) {\n\t\t\t\t\t\tlistPtr->cursorPos = listPtr->endPos;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// text hit.. \n\t\t\t}\n\t\t}\n\t} else if (!(item->window.flags & (WINDOW_LB_LEFTARROW | WINDOW_LB_RIGHTARROW | WINDOW_LB_THUMB | WINDOW_LB_PGUP | WINDOW_LB_PGDN))) {\n\t\tr.x = item->window.rect.x;\n\t\tr.y = item->window.rect.y;\n\t\tr.w = item->window.rect.w - SCROLLBAR_SIZE;\n\t\tr.h = item->window.rect.h - listPtr->drawPadding;\n\t\tif (Rect_ContainsPoint(&r, x, y)) {\n\t\t\tlistPtr->cursorPos =  (int)((y - 2 - r.y) / listPtr->elementHeight)  + listPtr->startPos;\n\t\t\tif (listPtr->cursorPos > listPtr->endPos) {\n\t\t\t\tlistPtr->cursorPos = listPtr->endPos;\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid Item_MouseEnter(itemDef_t *item, float x, float y) {\n\trectDef_t r;\n\tif (item) {\n\t\tr = item->textRect;\n\t\tr.y -= r.h;\n\t\t// in the text rect?\n\n\t\t// items can be enabled and disabled based on cvars\n\t\tif (item->cvarFlags & (CVAR_ENABLE | CVAR_DISABLE) && !Item_EnableShowViaCvar(item, CVAR_ENABLE)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (item->cvarFlags & (CVAR_SHOW | CVAR_HIDE) && !Item_EnableShowViaCvar(item, CVAR_SHOW)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (Rect_ContainsPoint(&r, x, y)) {\n\t\t\tif (!(item->window.flags & WINDOW_MOUSEOVERTEXT)) {\n\t\t\t\tItem_RunScript(item, item->mouseEnterText);\n\t\t\t\titem->window.flags |= WINDOW_MOUSEOVERTEXT;\n\t\t\t}\n\t\t\tif (!(item->window.flags & WINDOW_MOUSEOVER)) {\n\t\t\t\tItem_RunScript(item, item->mouseEnter);\n\t\t\t\titem->window.flags |= WINDOW_MOUSEOVER;\n\t\t\t}\n\n\t\t} else {\n\t\t\t// not in the text rect\n\t\t\tif (item->window.flags & WINDOW_MOUSEOVERTEXT) {\n\t\t\t\t// if we were\n\t\t\t\tItem_RunScript(item, item->mouseExitText);\n\t\t\t\titem->window.flags &= ~WINDOW_MOUSEOVERTEXT;\n\t\t\t}\n\t\t\tif (!(item->window.flags & WINDOW_MOUSEOVER)) {\n\t\t\t\tItem_RunScript(item, item->mouseEnter);\n\t\t\t\titem->window.flags |= WINDOW_MOUSEOVER;\n\t\t\t}\n\n\t\t\tif (item->type == ITEM_TYPE_LISTBOX) {\n\t\t\t\tItem_ListBox_MouseEnter(item, x, y);\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid Item_MouseLeave(itemDef_t *item) {\n  if (item) {\n    if (item->window.flags & WINDOW_MOUSEOVERTEXT) {\n      Item_RunScript(item, item->mouseExitText);\n      item->window.flags &= ~WINDOW_MOUSEOVERTEXT;\n    }\n    Item_RunScript(item, item->mouseExit);\n    item->window.flags &= ~(WINDOW_LB_RIGHTARROW | WINDOW_LB_LEFTARROW);\n  }\n}\n\nitemDef_t *Menu_HitTest(menuDef_t *menu, float x, float y) {\n  int i;\n  for (i = 0; i < menu->itemCount; i++) {\n    if (Rect_ContainsPoint(&menu->items[i]->window.rect, x, y)) {\n      return menu->items[i];\n    }\n  }\n  return NULL;\n}\n\nvoid Item_SetMouseOver(itemDef_t *item, qboolean focus) {\n  if (item) {\n    if (focus) {\n      item->window.flags |= WINDOW_MOUSEOVER;\n    } else {\n      item->window.flags &= ~WINDOW_MOUSEOVER;\n    }\n  }\n}\n\n\nqboolean Item_OwnerDraw_HandleKey(itemDef_t *item, int key) {\n  if (item && DC->ownerDrawHandleKey) {\n    return DC->ownerDrawHandleKey(item->window.ownerDraw, item->window.ownerDrawFlags, &item->special, key);\n  }\n  return qfalse;\n}\n\nqboolean Item_ListBox_HandleKey(itemDef_t *item, int key, qboolean down, qboolean force) {\n\tlistBoxDef_t *listPtr = (listBoxDef_t*)item->typeData;\n\tint count = DC->feederCount(item->special);\n\tint max, viewmax;\n\n\tif (force || (Rect_ContainsPoint(&item->window.rect, DC->cursorx, DC->cursory) && item->window.flags & WINDOW_HASFOCUS)) {\n\t\tmax = Item_ListBox_MaxScroll(item);\n\t\tif (item->window.flags & WINDOW_HORIZONTAL) {\n\t\t\tviewmax = (item->window.rect.w / listPtr->elementWidth);\n\t\t\tif ( key == K_LEFTARROW || key == K_KP_LEFTARROW ) \n\t\t\t{\n\t\t\t\tif (!listPtr->notselectable) {\n\t\t\t\t\tlistPtr->cursorPos--;\n\t\t\t\t\tif (listPtr->cursorPos < 0) {\n\t\t\t\t\t\tlistPtr->cursorPos = 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (listPtr->cursorPos < listPtr->startPos) {\n\t\t\t\t\t\tlistPtr->startPos = listPtr->cursorPos;\n\t\t\t\t\t}\n\t\t\t\t\tif (listPtr->cursorPos >= listPtr->startPos + viewmax) {\n\t\t\t\t\t\tlistPtr->startPos = listPtr->cursorPos - viewmax + 1;\n\t\t\t\t\t}\n\t\t\t\t\titem->cursorPos = listPtr->cursorPos;\n\t\t\t\t\tDC->feederSelection(item->special, item->cursorPos);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlistPtr->startPos--;\n\t\t\t\t\tif (listPtr->startPos < 0)\n\t\t\t\t\t\tlistPtr->startPos = 0;\n\t\t\t\t}\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t\tif ( key == K_RIGHTARROW || key == K_KP_RIGHTARROW ) \n\t\t\t{\n\t\t\t\tif (!listPtr->notselectable) {\n\t\t\t\t\tlistPtr->cursorPos++;\n\t\t\t\t\tif (listPtr->cursorPos < listPtr->startPos) {\n\t\t\t\t\t\tlistPtr->startPos = listPtr->cursorPos;\n\t\t\t\t\t}\n\t\t\t\t\tif (listPtr->cursorPos >= count) {\n\t\t\t\t\t\tlistPtr->cursorPos = count-1;\n\t\t\t\t\t}\n\t\t\t\t\tif (listPtr->cursorPos >= listPtr->startPos + viewmax) {\n\t\t\t\t\t\tlistPtr->startPos = listPtr->cursorPos - viewmax + 1;\n\t\t\t\t\t}\n\t\t\t\t\titem->cursorPos = listPtr->cursorPos;\n\t\t\t\t\tDC->feederSelection(item->special, item->cursorPos);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlistPtr->startPos++;\n\t\t\t\t\tif (listPtr->startPos >= count)\n\t\t\t\t\t\tlistPtr->startPos = count-1;\n\t\t\t\t}\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tviewmax = (item->window.rect.h / listPtr->elementHeight);\n\t\t\tif ( key == K_UPARROW || key == K_KP_UPARROW ) \n\t\t\t{\n\t\t\t\tif (!listPtr->notselectable) {\n\t\t\t\t\tlistPtr->cursorPos--;\n\t\t\t\t\tif (listPtr->cursorPos < 0) {\n\t\t\t\t\t\tlistPtr->cursorPos = 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (listPtr->cursorPos < listPtr->startPos) {\n\t\t\t\t\t\tlistPtr->startPos = listPtr->cursorPos;\n\t\t\t\t\t}\n\t\t\t\t\tif (listPtr->cursorPos >= listPtr->startPos + viewmax) {\n\t\t\t\t\t\tlistPtr->startPos = listPtr->cursorPos - viewmax + 1;\n\t\t\t\t\t}\n\t\t\t\t\titem->cursorPos = listPtr->cursorPos;\n\t\t\t\t\tDC->feederSelection(item->special, item->cursorPos);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlistPtr->startPos--;\n\t\t\t\t\tif (listPtr->startPos < 0)\n\t\t\t\t\t\tlistPtr->startPos = 0;\n\t\t\t\t}\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t\tif ( key == K_DOWNARROW || key == K_KP_DOWNARROW ) \n\t\t\t{\n\t\t\t\tif (!listPtr->notselectable) {\n\t\t\t\t\tlistPtr->cursorPos++;\n\t\t\t\t\tif (listPtr->cursorPos < listPtr->startPos) {\n\t\t\t\t\t\tlistPtr->startPos = listPtr->cursorPos;\n\t\t\t\t\t}\n\t\t\t\t\tif (listPtr->cursorPos >= count) {\n\t\t\t\t\t\tlistPtr->cursorPos = count-1;\n\t\t\t\t\t}\n\t\t\t\t\tif (listPtr->cursorPos >= listPtr->startPos + viewmax) {\n\t\t\t\t\t\tlistPtr->startPos = listPtr->cursorPos - viewmax + 1;\n\t\t\t\t\t}\n\t\t\t\t\titem->cursorPos = listPtr->cursorPos;\n\t\t\t\t\tDC->feederSelection(item->special, item->cursorPos);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlistPtr->startPos++;\n\t\t\t\t\tif (listPtr->startPos > max)\n\t\t\t\t\t\tlistPtr->startPos = max;\n\t\t\t\t}\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t}\n\t\t// mouse hit\n\t\tif (key == K_MOUSE1 || key == K_MOUSE2) {\n\t\t\tif (item->window.flags & WINDOW_LB_LEFTARROW) {\n\t\t\t\tlistPtr->startPos--;\n\t\t\t\tif (listPtr->startPos < 0) {\n\t\t\t\t\tlistPtr->startPos = 0;\n\t\t\t\t}\n\t\t\t} else if (item->window.flags & WINDOW_LB_RIGHTARROW) {\n\t\t\t\t// one down\n\t\t\t\tlistPtr->startPos++;\n\t\t\t\tif (listPtr->startPos > max) {\n\t\t\t\t\tlistPtr->startPos = max;\n\t\t\t\t}\n\t\t\t} else if (item->window.flags & WINDOW_LB_PGUP) {\n\t\t\t\t// page up\n\t\t\t\tlistPtr->startPos -= viewmax;\n\t\t\t\tif (listPtr->startPos < 0) {\n\t\t\t\t\tlistPtr->startPos = 0;\n\t\t\t\t}\n\t\t\t} else if (item->window.flags & WINDOW_LB_PGDN) {\n\t\t\t\t// page down\n\t\t\t\tlistPtr->startPos += viewmax;\n\t\t\t\tif (listPtr->startPos > max) {\n\t\t\t\t\tlistPtr->startPos = max;\n\t\t\t\t}\n\t\t\t} else if (item->window.flags & WINDOW_LB_THUMB) {\n\t\t\t\t// Display_SetCaptureItem(item);\n\t\t\t} else {\n\t\t\t\t// select an item\n\t\t\t\tif (DC->realTime < lastListBoxClickTime && listPtr->doubleClick) {\n\t\t\t\t\tItem_RunScript(item, listPtr->doubleClick);\n\t\t\t\t}\n\t\t\t\tlastListBoxClickTime = DC->realTime + DOUBLE_CLICK_DELAY;\n\t\t\t\tif (item->cursorPos != listPtr->cursorPos) {\n\t\t\t\t\titem->cursorPos = listPtr->cursorPos;\n\t\t\t\t\tDC->feederSelection(item->special, item->cursorPos);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn qtrue;\n\t\t}\n\t\tif ( key == K_HOME || key == K_KP_HOME) {\n\t\t\t// home\n\t\t\tlistPtr->startPos = 0;\n\t\t\treturn qtrue;\n\t\t}\n\t\tif ( key == K_END || key == K_KP_END) {\n\t\t\t// end\n\t\t\tlistPtr->startPos = max;\n\t\t\treturn qtrue;\n\t\t}\n\t\tif (key == K_PGUP || key == K_KP_PGUP ) {\n\t\t\t// page up\n\t\t\tif (!listPtr->notselectable) {\n\t\t\t\tlistPtr->cursorPos -= viewmax;\n\t\t\t\tif (listPtr->cursorPos < 0) {\n\t\t\t\t\tlistPtr->cursorPos = 0;\n\t\t\t\t}\n\t\t\t\tif (listPtr->cursorPos < listPtr->startPos) {\n\t\t\t\t\tlistPtr->startPos = listPtr->cursorPos;\n\t\t\t\t}\n\t\t\t\tif (listPtr->cursorPos >= listPtr->startPos + viewmax) {\n\t\t\t\t\tlistPtr->startPos = listPtr->cursorPos - viewmax + 1;\n\t\t\t\t}\n\t\t\t\titem->cursorPos = listPtr->cursorPos;\n\t\t\t\tDC->feederSelection(item->special, item->cursorPos);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tlistPtr->startPos -= viewmax;\n\t\t\t\tif (listPtr->startPos < 0) {\n\t\t\t\t\tlistPtr->startPos = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn qtrue;\n\t\t}\n\t\tif ( key == K_PGDN || key == K_KP_PGDN ) {\n\t\t\t// page down\n\t\t\tif (!listPtr->notselectable) {\n\t\t\t\tlistPtr->cursorPos += viewmax;\n\t\t\t\tif (listPtr->cursorPos < listPtr->startPos) {\n\t\t\t\t\tlistPtr->startPos = listPtr->cursorPos;\n\t\t\t\t}\n\t\t\t\tif (listPtr->cursorPos >= count) {\n\t\t\t\t\tlistPtr->cursorPos = count-1;\n\t\t\t\t}\n\t\t\t\tif (listPtr->cursorPos >= listPtr->startPos + viewmax) {\n\t\t\t\t\tlistPtr->startPos = listPtr->cursorPos - viewmax + 1;\n\t\t\t\t}\n\t\t\t\titem->cursorPos = listPtr->cursorPos;\n\t\t\t\tDC->feederSelection(item->special, item->cursorPos);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tlistPtr->startPos += viewmax;\n\t\t\t\tif (listPtr->startPos > max) {\n\t\t\t\t\tlistPtr->startPos = max;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\treturn qfalse;\n}\n\nqboolean Item_YesNo_HandleKey(itemDef_t *item, int key) {\n\n  if (Rect_ContainsPoint(&item->window.rect, DC->cursorx, DC->cursory) && item->window.flags & WINDOW_HASFOCUS && item->cvar) {\n\t\tif (key == K_MOUSE1 || key == K_ENTER || key == K_MOUSE2 || key == K_MOUSE3) {\n\t    DC->setCVar(item->cvar, va(\"%i\", !DC->getCVarValue(item->cvar)));\n\t\t  return qtrue;\n\t\t}\n  }\n\n  return qfalse;\n\n}\n\nint Item_Multi_CountSettings(itemDef_t *item) {\n\tmultiDef_t *multiPtr = (multiDef_t*)item->typeData;\n\tif (multiPtr == NULL) {\n\t\treturn 0;\n\t}\n\treturn multiPtr->count;\n}\n\nint Item_Multi_FindCvarByValue(itemDef_t *item) {\n\tchar buff[1024];\n\tfloat value = 0;\n\tint i;\n\tmultiDef_t *multiPtr = (multiDef_t*)item->typeData;\n\tif (multiPtr) {\n\t\tif (multiPtr->strDef) {\n\t    DC->getCVarString(item->cvar, buff, sizeof(buff));\n\t\t} else {\n\t\t\tvalue = DC->getCVarValue(item->cvar);\n\t\t}\n\t\tfor (i = 0; i < multiPtr->count; i++) {\n\t\t\tif (multiPtr->strDef) {\n\t\t\t\tif (Q_stricmp(buff, multiPtr->cvarStr[i]) == 0) {\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t} else {\n \t\t\t\tif (multiPtr->cvarValue[i] == value) {\n \t\t\t\t\treturn i;\n \t\t\t\t}\n \t\t\t}\n \t\t}\n\t}\n\treturn 0;\n}\n\nconst char *Item_Multi_Setting(itemDef_t *item) {\n\tchar buff[1024];\n\tfloat value = 0;\n\tint i;\n\tmultiDef_t *multiPtr = (multiDef_t*)item->typeData;\n\tif (multiPtr) {\n\t\tif (multiPtr->strDef) {\n\t    DC->getCVarString(item->cvar, buff, sizeof(buff));\n\t\t} else {\n\t\t\tvalue = DC->getCVarValue(item->cvar);\n\t\t}\n\t\tfor (i = 0; i < multiPtr->count; i++) {\n\t\t\tif (multiPtr->strDef) {\n\t\t\t\tif (Q_stricmp(buff, multiPtr->cvarStr[i]) == 0) {\n\t\t\t\t\treturn multiPtr->cvarList[i];\n\t\t\t\t}\n\t\t\t} else {\n \t\t\t\tif (multiPtr->cvarValue[i] == value) {\n\t\t\t\t\treturn multiPtr->cvarList[i];\n \t\t\t\t}\n \t\t\t}\n \t\t}\n\t}\n\treturn \"\";\n}\n\nqboolean Item_Multi_HandleKey(itemDef_t *item, int key) {\n\tmultiDef_t *multiPtr = (multiDef_t*)item->typeData;\n\tif (multiPtr) {\n\t  if (Rect_ContainsPoint(&item->window.rect, DC->cursorx, DC->cursory) && item->window.flags & WINDOW_HASFOCUS && item->cvar) {\n\t\t\tif (key == K_MOUSE1 || key == K_ENTER || key == K_MOUSE2 || key == K_MOUSE3) {\n\t\t\t\tint current = Item_Multi_FindCvarByValue(item) + 1;\n\t\t\t\tint max = Item_Multi_CountSettings(item);\n\t\t\t\tif ( current < 0 || current >= max ) {\n\t\t\t\t\tcurrent = 0;\n\t\t\t\t}\n\t\t\t\tif (multiPtr->strDef) {\n\t\t\t\t\tDC->setCVar(item->cvar, multiPtr->cvarStr[current]);\n\t\t\t\t} else {\n\t\t\t\t\tfloat value = multiPtr->cvarValue[current];\n\t\t\t\t\tif (((float)((int) value)) == value) {\n\t\t\t\t\t\tDC->setCVar(item->cvar, va(\"%i\", (int) value ));\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tDC->setCVar(item->cvar, va(\"%f\", value ));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t}\n\t}\n  return qfalse;\n}\n\nqboolean Item_TextField_HandleKey(itemDef_t *item, int key) {\n\tchar buff[1024];\n\tint len;\n\titemDef_t *newItem = NULL;\n\teditFieldDef_t *editPtr = (editFieldDef_t*)item->typeData;\n\n\tif (item->cvar) {\n\n\t\tmemset(buff, 0, sizeof(buff));\n\t\tDC->getCVarString(item->cvar, buff, sizeof(buff));\n\t\tlen = strlen(buff);\n\t\tif (editPtr->maxChars && len > editPtr->maxChars) {\n\t\t\tlen = editPtr->maxChars;\n\t\t}\n\t\tif ( key & K_CHAR_FLAG ) {\n\t\t\tkey &= ~K_CHAR_FLAG;\n\n\n\t\t\tif (key == 'h' - 'a' + 1 )\t{\t// ctrl-h is backspace\n\t\t\t\tif ( item->cursorPos > 0 ) {\n\t\t\t\t\tmemmove( &buff[item->cursorPos - 1], &buff[item->cursorPos], len + 1 - item->cursorPos);\n\t\t\t\t\titem->cursorPos--;\n\t\t\t\t\tif (item->cursorPos < editPtr->paintOffset) {\n\t\t\t\t\t\teditPtr->paintOffset--;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tDC->setCVar(item->cvar, buff);\n\t    \t\treturn qtrue;\n\t\t\t}\n\n\n\t\t\t//\n\t\t\t// ignore any non printable chars\n\t\t\t//\n\t\t\tif ( key < 32 || !item->cvar) {\n\t\t\t    return qtrue;\n\t\t    }\n\n\t\t\tif (item->type == ITEM_TYPE_NUMERICFIELD) {\n\t\t\t\tif (key < '0' || key > '9') {\n\t\t\t\t\treturn qfalse;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!DC->getOverstrikeMode()) {\n\t\t\t\tif (( len == MAX_EDITFIELD - 1 ) || (editPtr->maxChars && len >= editPtr->maxChars)) {\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n\t\t\t\tmemmove( &buff[item->cursorPos + 1], &buff[item->cursorPos], len + 1 - item->cursorPos );\n\t\t\t} else {\n\t\t\t\tif (editPtr->maxChars && item->cursorPos >= editPtr->maxChars) {\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbuff[item->cursorPos] = key;\n\n\t\t\tDC->setCVar(item->cvar, buff);\n\n\t\t\tif (item->cursorPos < len + 1) {\n\t\t\t\titem->cursorPos++;\n\t\t\t\tif (editPtr->maxPaintChars && item->cursorPos > editPtr->maxPaintChars) {\n\t\t\t\t\teditPtr->paintOffset++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tif ( key == K_DEL || key == K_KP_DEL ) {\n\t\t\t\tif ( item->cursorPos < len ) {\n\t\t\t\t\tmemmove( buff + item->cursorPos, buff + item->cursorPos + 1, len - item->cursorPos);\n\t\t\t\t\tDC->setCVar(item->cvar, buff);\n\t\t\t\t}\n\t\t\t\treturn qtrue;\n\t\t\t}\n\n\t\t\tif ( key == K_RIGHTARROW || key == K_KP_RIGHTARROW ) \n\t\t\t{\n\t\t\t\tif (editPtr->maxPaintChars && item->cursorPos >= editPtr->maxPaintChars && item->cursorPos < len) {\n\t\t\t\t\titem->cursorPos++;\n\t\t\t\t\teditPtr->paintOffset++;\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n\t\t\t\tif (item->cursorPos < len) {\n\t\t\t\t\titem->cursorPos++;\n\t\t\t\t} \n\t\t\t\treturn qtrue;\n\t\t\t}\n\n\t\t\tif ( key == K_LEFTARROW || key == K_KP_LEFTARROW ) \n\t\t\t{\n\t\t\t\tif ( item->cursorPos > 0 ) {\n\t\t\t\t\titem->cursorPos--;\n\t\t\t\t}\n\t\t\t\tif (item->cursorPos < editPtr->paintOffset) {\n\t\t\t\t\teditPtr->paintOffset--;\n\t\t\t\t}\n\t\t\t\treturn qtrue;\n\t\t\t}\n\n\t\t\tif ( key == K_HOME || key == K_KP_HOME) {// || ( tolower(key) == 'a' && trap_Key_IsDown( K_CTRL ) ) ) {\n\t\t\t\titem->cursorPos = 0;\n\t\t\t\teditPtr->paintOffset = 0;\n\t\t\t\treturn qtrue;\n\t\t\t}\n\n\t\t\tif ( key == K_END || key == K_KP_END)  {// ( tolower(key) == 'e' && trap_Key_IsDown( K_CTRL ) ) ) {\n\t\t\t\titem->cursorPos = len;\n\t\t\t\tif(item->cursorPos > editPtr->maxPaintChars) {\n\t\t\t\t\teditPtr->paintOffset = len - editPtr->maxPaintChars;\n\t\t\t\t}\n\t\t\t\treturn qtrue;\n\t\t\t}\n\n\t\t\tif ( key == K_INS || key == K_KP_INS ) {\n\t\t\t\tDC->setOverstrikeMode(!DC->getOverstrikeMode());\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t}\n\n\t\tif (key == K_TAB || key == K_DOWNARROW || key == K_KP_DOWNARROW) {\n\t\t\tnewItem = Menu_SetNextCursorItem(item->parent);\n\t\t\tif (newItem && (newItem->type == ITEM_TYPE_EDITFIELD || newItem->type == ITEM_TYPE_NUMERICFIELD)) {\n\t\t\t\tg_editItem = newItem;\n\t\t\t}\n\t\t}\n\n\t\tif (key == K_UPARROW || key == K_KP_UPARROW) {\n\t\t\tnewItem = Menu_SetPrevCursorItem(item->parent);\n\t\t\tif (newItem && (newItem->type == ITEM_TYPE_EDITFIELD || newItem->type == ITEM_TYPE_NUMERICFIELD)) {\n\t\t\t\tg_editItem = newItem;\n\t\t\t}\n\t\t}\n\n\t\tif ( key == K_ENTER || key == K_KP_ENTER || key == K_ESCAPE)  {\n\t\t\treturn qfalse;\n\t\t}\n\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n\n}\n\nstatic void Scroll_ListBox_AutoFunc(void *p) {\n\tscrollInfo_t *si = (scrollInfo_t*)p;\n\tif (DC->realTime > si->nextScrollTime) { \n\t\t// need to scroll which is done by simulating a click to the item\n\t\t// this is done a bit sideways as the autoscroll \"knows\" that the item is a listbox\n\t\t// so it calls it directly\n\t\tItem_ListBox_HandleKey(si->item, si->scrollKey, qtrue, qfalse);\n\t\tsi->nextScrollTime = DC->realTime + si->adjustValue; \n\t}\n\n\tif (DC->realTime > si->nextAdjustTime) {\n\t\tsi->nextAdjustTime = DC->realTime + SCROLL_TIME_ADJUST;\n\t\tif (si->adjustValue > SCROLL_TIME_FLOOR) {\n\t\t\tsi->adjustValue -= SCROLL_TIME_ADJUSTOFFSET;\n\t\t}\n\t}\n}\n\nstatic void Scroll_ListBox_ThumbFunc(void *p) {\n\tscrollInfo_t *si = (scrollInfo_t*)p;\n\trectDef_t r;\n\tint pos, max;\n\n\tlistBoxDef_t *listPtr = (listBoxDef_t*)si->item->typeData;\n\tif (si->item->window.flags & WINDOW_HORIZONTAL) {\n\t\tif (DC->cursorx == si->xStart) {\n\t\t\treturn;\n\t\t}\n\t\tr.x = si->item->window.rect.x + SCROLLBAR_SIZE + 1;\n\t\tr.y = si->item->window.rect.y + si->item->window.rect.h - SCROLLBAR_SIZE - 1;\n\t\tr.h = SCROLLBAR_SIZE;\n\t\tr.w = si->item->window.rect.w - (SCROLLBAR_SIZE*2) - 2;\n\t\tmax = Item_ListBox_MaxScroll(si->item);\n\t\t//\n\t\tpos = (DC->cursorx - r.x - SCROLLBAR_SIZE/2) * max / (r.w - SCROLLBAR_SIZE);\n\t\tif (pos < 0) {\n\t\t\tpos = 0;\n\t\t}\n\t\telse if (pos > max) {\n\t\t\tpos = max;\n\t\t}\n\t\tlistPtr->startPos = pos;\n\t\tsi->xStart = DC->cursorx;\n\t}\n\telse if (DC->cursory != si->yStart) {\n\n\t\tr.x = si->item->window.rect.x + si->item->window.rect.w - SCROLLBAR_SIZE - 1;\n\t\tr.y = si->item->window.rect.y + SCROLLBAR_SIZE + 1;\n\t\tr.h = si->item->window.rect.h - (SCROLLBAR_SIZE*2) - 2;\n\t\tr.w = SCROLLBAR_SIZE;\n\t\tmax = Item_ListBox_MaxScroll(si->item);\n\t\t//\n\t\tpos = (DC->cursory - r.y - SCROLLBAR_SIZE/2) * max / (r.h - SCROLLBAR_SIZE);\n\t\tif (pos < 0) {\n\t\t\tpos = 0;\n\t\t}\n\t\telse if (pos > max) {\n\t\t\tpos = max;\n\t\t}\n\t\tlistPtr->startPos = pos;\n\t\tsi->yStart = DC->cursory;\n\t}\n\n\tif (DC->realTime > si->nextScrollTime) { \n\t\t// need to scroll which is done by simulating a click to the item\n\t\t// this is done a bit sideways as the autoscroll \"knows\" that the item is a listbox\n\t\t// so it calls it directly\n\t\tItem_ListBox_HandleKey(si->item, si->scrollKey, qtrue, qfalse);\n\t\tsi->nextScrollTime = DC->realTime + si->adjustValue; \n\t}\n\n\tif (DC->realTime > si->nextAdjustTime) {\n\t\tsi->nextAdjustTime = DC->realTime + SCROLL_TIME_ADJUST;\n\t\tif (si->adjustValue > SCROLL_TIME_FLOOR) {\n\t\t\tsi->adjustValue -= SCROLL_TIME_ADJUSTOFFSET;\n\t\t}\n\t}\n}\n\nstatic void Scroll_Slider_ThumbFunc(void *p) {\n\tfloat x, value, cursorx;\n\tscrollInfo_t *si = (scrollInfo_t*)p;\n\teditFieldDef_t *editDef = si->item->typeData;\n\n\tif (si->item->text) {\n\t\tx = si->item->textRect.x + si->item->textRect.w + 8;\n\t} else {\n\t\tx = si->item->window.rect.x;\n\t}\n\n\tcursorx = DC->cursorx;\n\n\tif (cursorx < x) {\n\t\tcursorx = x;\n\t} else if (cursorx > x + SLIDER_WIDTH) {\n\t\tcursorx = x + SLIDER_WIDTH;\n\t}\n\tvalue = cursorx - x;\n\tvalue /= SLIDER_WIDTH;\n\tvalue *= (editDef->maxVal - editDef->minVal);\n\tvalue += editDef->minVal;\n\tDC->setCVar(si->item->cvar, va(\"%f\", value));\n}\n\nvoid Item_StartCapture(itemDef_t *item, int key) {\n\tint flags;\n\tswitch (item->type) {\n    case ITEM_TYPE_EDITFIELD:\n    case ITEM_TYPE_NUMERICFIELD:\n\n\t\tcase ITEM_TYPE_LISTBOX:\n\t\t{\n\t\t\tflags = Item_ListBox_OverLB(item, DC->cursorx, DC->cursory);\n\t\t\tif (flags & (WINDOW_LB_LEFTARROW | WINDOW_LB_RIGHTARROW)) {\n\t\t\t\tscrollInfo.nextScrollTime = DC->realTime + SCROLL_TIME_START;\n\t\t\t\tscrollInfo.nextAdjustTime = DC->realTime + SCROLL_TIME_ADJUST;\n\t\t\t\tscrollInfo.adjustValue = SCROLL_TIME_START;\n\t\t\t\tscrollInfo.scrollKey = key;\n\t\t\t\tscrollInfo.scrollDir = (flags & WINDOW_LB_LEFTARROW) ? qtrue : qfalse;\n\t\t\t\tscrollInfo.item = item;\n\t\t\t\tcaptureData = &scrollInfo;\n\t\t\t\tcaptureFunc = &Scroll_ListBox_AutoFunc;\n\t\t\t\titemCapture = item;\n\t\t\t} else if (flags & WINDOW_LB_THUMB) {\n\t\t\t\tscrollInfo.scrollKey = key;\n\t\t\t\tscrollInfo.item = item;\n\t\t\t\tscrollInfo.xStart = DC->cursorx;\n\t\t\t\tscrollInfo.yStart = DC->cursory;\n\t\t\t\tcaptureData = &scrollInfo;\n\t\t\t\tcaptureFunc = &Scroll_ListBox_ThumbFunc;\n\t\t\t\titemCapture = item;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase ITEM_TYPE_SLIDER:\n\t\t{\n\t\t\tflags = Item_Slider_OverSlider(item, DC->cursorx, DC->cursory);\n\t\t\tif (flags & WINDOW_LB_THUMB) {\n\t\t\t\tscrollInfo.scrollKey = key;\n\t\t\t\tscrollInfo.item = item;\n\t\t\t\tscrollInfo.xStart = DC->cursorx;\n\t\t\t\tscrollInfo.yStart = DC->cursory;\n\t\t\t\tcaptureData = &scrollInfo;\n\t\t\t\tcaptureFunc = &Scroll_Slider_ThumbFunc;\n\t\t\t\titemCapture = item;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nvoid Item_StopCapture(itemDef_t *item) {\n\n}\n\nqboolean Item_Slider_HandleKey(itemDef_t *item, int key, qboolean down) {\n\tfloat x, value, width, work;\n\n\t//DC->Print(\"slider handle key\\n\");\n\tif (item->window.flags & WINDOW_HASFOCUS && item->cvar && Rect_ContainsPoint(&item->window.rect, DC->cursorx, DC->cursory)) {\n\t\tif (key == K_MOUSE1 || key == K_ENTER || key == K_MOUSE2 || key == K_MOUSE3) {\n\t\t\teditFieldDef_t *editDef = item->typeData;\n\t\t\tif (editDef) {\n\t\t\t\trectDef_t testRect;\n\t\t\t\twidth = SLIDER_WIDTH;\n\t\t\t\tif (item->text) {\n\t\t\t\t\tx = item->textRect.x + item->textRect.w + 8;\n\t\t\t\t} else {\n\t\t\t\t\tx = item->window.rect.x;\n\t\t\t\t}\n\n\t\t\t\ttestRect = item->window.rect;\n\t\t\t\ttestRect.x = x;\n\t\t\t\tvalue = (float)SLIDER_THUMB_WIDTH / 2;\n\t\t\t\ttestRect.x -= value;\n\t\t\t\t//DC->Print(\"slider x: %f\\n\", testRect.x);\n\t\t\t\ttestRect.w = (SLIDER_WIDTH + (float)SLIDER_THUMB_WIDTH / 2);\n\t\t\t\t//DC->Print(\"slider w: %f\\n\", testRect.w);\n\t\t\t\tif (Rect_ContainsPoint(&testRect, DC->cursorx, DC->cursory)) {\n\t\t\t\t\twork = DC->cursorx - x;\n\t\t\t\t\tvalue = work / width;\n\t\t\t\t\tvalue *= (editDef->maxVal - editDef->minVal);\n\t\t\t\t\t// vm fuckage\n\t\t\t\t\t// value = (((float)(DC->cursorx - x)/ SLIDER_WIDTH) * (editDef->maxVal - editDef->minVal));\n\t\t\t\t\tvalue += editDef->minVal;\n\t\t\t\t\tDC->setCVar(item->cvar, va(\"%f\", value));\n\t\t\t\t\treturn qtrue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tDC->Print(\"slider handle key exit\\n\");\n\treturn qfalse;\n}\n\n\nqboolean Item_HandleKey(itemDef_t *item, int key, qboolean down) {\n\n\tif (itemCapture) {\n\t\tItem_StopCapture(itemCapture);\n\t\titemCapture = NULL;\n\t\tcaptureFunc = NULL;\n\t\tcaptureData = NULL;\n\t} else {\n\t  // bk001206 - parentheses\n\t\tif ( down && ( key == K_MOUSE1 || key == K_MOUSE2 || key == K_MOUSE3 ) ) {\n\t\t\tItem_StartCapture(item, key);\n\t\t}\n\t}\n\n\tif (!down) {\n\t\treturn qfalse;\n\t}\n\n  switch (item->type) {\n    case ITEM_TYPE_BUTTON:\n      return qfalse;\n      break;\n    case ITEM_TYPE_RADIOBUTTON:\n      return qfalse;\n      break;\n    case ITEM_TYPE_CHECKBOX:\n      return qfalse;\n      break;\n    case ITEM_TYPE_EDITFIELD:\n    case ITEM_TYPE_NUMERICFIELD:\n      //return Item_TextField_HandleKey(item, key);\n      return qfalse;\n      break;\n    case ITEM_TYPE_COMBO:\n      return qfalse;\n      break;\n    case ITEM_TYPE_LISTBOX:\n      return Item_ListBox_HandleKey(item, key, down, qfalse);\n      break;\n    case ITEM_TYPE_YESNO:\n      return Item_YesNo_HandleKey(item, key);\n      break;\n    case ITEM_TYPE_MULTI:\n      return Item_Multi_HandleKey(item, key);\n      break;\n    case ITEM_TYPE_OWNERDRAW:\n      return Item_OwnerDraw_HandleKey(item, key);\n      break;\n    case ITEM_TYPE_BIND:\n\t\t\treturn Item_Bind_HandleKey(item, key, down);\n      break;\n    case ITEM_TYPE_SLIDER:\n      return Item_Slider_HandleKey(item, key, down);\n      break;\n    //case ITEM_TYPE_IMAGE:\n    //  Item_Image_Paint(item);\n    //  break;\n    default:\n      return qfalse;\n      break;\n  }\n\n  //return qfalse;\n}\n\nvoid Item_Action(itemDef_t *item) {\n  if (item) {\n    Item_RunScript(item, item->action);\n  }\n}\n\nitemDef_t *Menu_SetPrevCursorItem(menuDef_t *menu) {\n  qboolean wrapped = qfalse;\n\tint oldCursor = menu->cursorItem;\n  \n  if (menu->cursorItem < 0) {\n    menu->cursorItem = menu->itemCount-1;\n    wrapped = qtrue;\n  } \n\n  while (menu->cursorItem > -1) {\n    \n    menu->cursorItem--;\n    if (menu->cursorItem < 0 && !wrapped) {\n      wrapped = qtrue;\n      menu->cursorItem = menu->itemCount -1;\n    }\n\n\t\tif (Item_SetFocus(menu->items[menu->cursorItem], DC->cursorx, DC->cursory)) {\n\t\t\tMenu_HandleMouseMove(menu, menu->items[menu->cursorItem]->window.rect.x + 1, menu->items[menu->cursorItem]->window.rect.y + 1);\n      return menu->items[menu->cursorItem];\n    }\n  }\n\tmenu->cursorItem = oldCursor;\n\treturn NULL;\n\n}\n\nitemDef_t *Menu_SetNextCursorItem(menuDef_t *menu) {\n\n  qboolean wrapped = qfalse;\n\tint oldCursor = menu->cursorItem;\n\n\n  if (menu->cursorItem == -1) {\n    menu->cursorItem = 0;\n    wrapped = qtrue;\n  }\n\n  while (menu->cursorItem < menu->itemCount) {\n\n    menu->cursorItem++;\n    if (menu->cursorItem >= menu->itemCount && !wrapped) {\n      wrapped = qtrue;\n      menu->cursorItem = 0;\n    }\n\t\tif (Item_SetFocus(menu->items[menu->cursorItem], DC->cursorx, DC->cursory)) {\n\t\t\tMenu_HandleMouseMove(menu, menu->items[menu->cursorItem]->window.rect.x + 1, menu->items[menu->cursorItem]->window.rect.y + 1);\n      return menu->items[menu->cursorItem];\n    }\n    \n  }\n\n\tmenu->cursorItem = oldCursor;\n\treturn NULL;\n}\n\nstatic void Window_CloseCinematic(windowDef_t *window) {\n\tif (window->style == WINDOW_STYLE_CINEMATIC && window->cinematic >= 0) {\n\t\tDC->stopCinematic(window->cinematic);\n\t\twindow->cinematic = -1;\n\t}\n}\n\nstatic void Menu_CloseCinematics(menuDef_t *menu) {\n\tif (menu) {\n\t\tint i;\n\t\tWindow_CloseCinematic(&menu->window);\n\t  for (i = 0; i < menu->itemCount; i++) {\n\t\t  Window_CloseCinematic(&menu->items[i]->window);\n\t\t\tif (menu->items[i]->type == ITEM_TYPE_OWNERDRAW) {\n\t\t\t\tDC->stopCinematic(0-menu->items[i]->window.ownerDraw);\n\t\t\t}\n\t  }\n\t}\n}\n\nstatic void Display_CloseCinematics() {\n\tint i;\n\tfor (i = 0; i < menuCount; i++) {\n\t\tMenu_CloseCinematics(&Menus[i]);\n\t}\n}\n\nvoid  Menus_Activate(menuDef_t *menu) {\n\tmenu->window.flags |= (WINDOW_HASFOCUS | WINDOW_VISIBLE);\n\tif (menu->onOpen) {\n\t\titemDef_t item;\n\t\titem.parent = menu;\n\t\tItem_RunScript(&item, menu->onOpen);\n\t}\n\n\tif (menu->soundName && *menu->soundName) {\n//\t\tDC->stopBackgroundTrack();\t\t\t\t\t// you don't want to do this since it will reset s_rawend\n\t\tDC->startBackgroundTrack(menu->soundName, menu->soundName);\n\t}\n\n\tDisplay_CloseCinematics();\n\n}\n\nint Display_VisibleMenuCount() {\n\tint i, count;\n\tcount = 0;\n\tfor (i = 0; i < menuCount; i++) {\n\t\tif (Menus[i].window.flags & (WINDOW_FORCED | WINDOW_VISIBLE)) {\n\t\t\tcount++;\n\t\t}\n\t}\n\treturn count;\n}\n\nvoid Menus_HandleOOBClick(menuDef_t *menu, int key, qboolean down) {\n\tif (menu) {\n\t\tint i;\n\t\t// basically the behaviour we are looking for is if there are windows in the stack.. see if \n\t\t// the cursor is within any of them.. if not close them otherwise activate them and pass the \n\t\t// key on.. force a mouse move to activate focus and script stuff \n\t\tif (down && menu->window.flags & WINDOW_OOB_CLICK) {\n\t\t\tMenu_RunCloseScript(menu);\n\t\t\tmenu->window.flags &= ~(WINDOW_HASFOCUS | WINDOW_VISIBLE);\n\t\t}\n\n\t\tfor (i = 0; i < menuCount; i++) {\n\t\t\tif (Menu_OverActiveItem(&Menus[i], DC->cursorx, DC->cursory)) {\n\t\t\t\tMenu_RunCloseScript(menu);\n\t\t\t\tmenu->window.flags &= ~(WINDOW_HASFOCUS | WINDOW_VISIBLE);\n\t\t\t\tMenus_Activate(&Menus[i]);\n\t\t\t\tMenu_HandleMouseMove(&Menus[i], DC->cursorx, DC->cursory);\n\t\t\t\tMenu_HandleKey(&Menus[i], key, down);\n\t\t\t}\n\t\t}\n\n\t\tif (Display_VisibleMenuCount() == 0) {\n\t\t\tif (DC->Pause) {\n\t\t\t\tDC->Pause(qfalse);\n\t\t\t}\n\t\t}\n\t\tDisplay_CloseCinematics();\n\t}\n}\n\nstatic rectDef_t *Item_CorrectedTextRect(itemDef_t *item) {\n\tstatic rectDef_t rect;\n\tmemset(&rect, 0, sizeof(rectDef_t));\n\tif (item) {\n\t\trect = item->textRect;\n\t\tif (rect.w) {\n\t\t\trect.y -= rect.h;\n\t\t}\n\t}\n\treturn &rect;\n}\n\nvoid Menu_HandleKey(menuDef_t *menu, int key, qboolean down) {\n\tint i;\n\titemDef_t *item = NULL;\n\tqboolean inHandler = qfalse;\n\n\tif (inHandler) {\n\t\treturn;\n\t}\n\n\tinHandler = qtrue;\n\tif (g_waitingForKey && down) {\n\t\tItem_Bind_HandleKey(g_bindItem, key, down);\n\t\tinHandler = qfalse;\n\t\treturn;\n\t}\n\n\tif (g_editingField && down) {\n\t\tif (!Item_TextField_HandleKey(g_editItem, key)) {\n\t\t\tg_editingField = qfalse;\n\t\t\tg_editItem = NULL;\n\t\t\tinHandler = qfalse;\n\t\t\treturn;\n\t\t} else if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_MOUSE3) {\n\t\t\tg_editingField = qfalse;\n\t\t\tg_editItem = NULL;\n\t\t\tDisplay_MouseMove(NULL, DC->cursorx, DC->cursory);\n\t\t} else if (key == K_TAB || key == K_UPARROW || key == K_DOWNARROW) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif (menu == NULL) {\n\t\tinHandler = qfalse;\n\t\treturn;\n\t}\n\n\t\t// see if the mouse is within the window bounds and if so is this a mouse click\n\tif (down && !(menu->window.flags & WINDOW_POPUP) && !Rect_ContainsPoint(&menu->window.rect, DC->cursorx, DC->cursory)) {\n\t\tstatic qboolean inHandleKey = qfalse;\n\t\t// bk001206 - parentheses\n\t\tif (!inHandleKey && ( key == K_MOUSE1 || key == K_MOUSE2 || key == K_MOUSE3 ) ) {\n\t\t\tinHandleKey = qtrue;\n\t\t\tMenus_HandleOOBClick(menu, key, down);\n\t\t\tinHandleKey = qfalse;\n\t\t\tinHandler = qfalse;\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// get the item with focus\n\tfor (i = 0; i < menu->itemCount; i++) {\n\t\tif (menu->items[i]->window.flags & WINDOW_HASFOCUS) {\n\t\t\titem = menu->items[i];\n\t\t}\n\t}\n\n\tif (item != NULL) {\n\t\tif (Item_HandleKey(item, key, down)) {\n\t\t\tItem_Action(item);\n\t\t\tinHandler = qfalse;\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif (!down) {\n\t\tinHandler = qfalse;\n\t\treturn;\n\t}\n\n\t// default handling\n\tswitch ( key ) {\n\n\t\tcase K_F11:\n\t\t\tif (DC->getCVarValue(\"developer\")) {\n\t\t\t\tdebugMode ^= 1;\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase K_F12:\n\t\t\tif (DC->getCVarValue(\"developer\")) {\n\t\t\t\tDC->executeText(EXEC_APPEND, \"screenshot\\n\");\n\t\t\t}\n\t\t\tbreak;\n\t\tcase K_KP_UPARROW:\n\t\tcase K_UPARROW:\n\t\t\tMenu_SetPrevCursorItem(menu);\n\t\t\tbreak;\n\n\t\tcase K_ESCAPE:\n\t\t\tif (!g_waitingForKey && menu->onESC) {\n\t\t\t\titemDef_t it;\n\t\t    it.parent = menu;\n\t\t    Item_RunScript(&it, menu->onESC);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase K_TAB:\n\t\tcase K_KP_DOWNARROW:\n\t\tcase K_DOWNARROW:\n\t\t\tMenu_SetNextCursorItem(menu);\n\t\t\tbreak;\n\n\t\tcase K_MOUSE1:\n\t\tcase K_MOUSE2:\n\t\t\tif (item) {\n\t\t\t\tif (item->type == ITEM_TYPE_TEXT) {\n\t\t\t\t\tif (Rect_ContainsPoint(Item_CorrectedTextRect(item), DC->cursorx, DC->cursory)) {\n\t\t\t\t\t\tItem_Action(item);\n\t\t\t\t\t}\n\t\t\t\t} else if (item->type == ITEM_TYPE_EDITFIELD || item->type == ITEM_TYPE_NUMERICFIELD) {\n\t\t\t\t\tif (Rect_ContainsPoint(&item->window.rect, DC->cursorx, DC->cursory)) {\n\t\t\t\t\t\titem->cursorPos = 0;\n\t\t\t\t\t\tg_editingField = qtrue;\n\t\t\t\t\t\tg_editItem = item;\n\t\t\t\t\t\tDC->setOverstrikeMode(qtrue);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (Rect_ContainsPoint(&item->window.rect, DC->cursorx, DC->cursory)) {\n\t\t\t\t\t\tItem_Action(item);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase K_JOY1:\n\t\tcase K_JOY2:\n\t\tcase K_JOY3:\n\t\tcase K_JOY4:\n\t\tcase K_AUX1:\n\t\tcase K_AUX2:\n\t\tcase K_AUX3:\n\t\tcase K_AUX4:\n\t\tcase K_AUX5:\n\t\tcase K_AUX6:\n\t\tcase K_AUX7:\n\t\tcase K_AUX8:\n\t\tcase K_AUX9:\n\t\tcase K_AUX10:\n\t\tcase K_AUX11:\n\t\tcase K_AUX12:\n\t\tcase K_AUX13:\n\t\tcase K_AUX14:\n\t\tcase K_AUX15:\n\t\tcase K_AUX16:\n\t\t\tbreak;\n\t\tcase K_KP_ENTER:\n\t\tcase K_ENTER:\n\t\t\tif (item) {\n\t\t\t\tif (item->type == ITEM_TYPE_EDITFIELD || item->type == ITEM_TYPE_NUMERICFIELD) {\n\t\t\t\t\titem->cursorPos = 0;\n\t\t\t\t\tg_editingField = qtrue;\n\t\t\t\t\tg_editItem = item;\n\t\t\t\t\tDC->setOverstrikeMode(qtrue);\n\t\t\t\t} else {\n\t\t\t\t\t\tItem_Action(item);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t}\n\tinHandler = qfalse;\n}\n\nvoid ToWindowCoords(float *x, float *y, windowDef_t *window) {\n\tif (window->border != 0) {\n\t\t*x += window->borderSize;\n\t\t*y += window->borderSize;\n\t} \n\t*x += window->rect.x;\n\t*y += window->rect.y;\n}\n\nvoid Rect_ToWindowCoords(rectDef_t *rect, windowDef_t *window) {\n\tToWindowCoords(&rect->x, &rect->y, window);\n}\n\nvoid Item_SetTextExtents(itemDef_t *item, int *width, int *height, const char *text) {\n\tconst char *textPtr = (text) ? text : item->text;\n\n\tif (textPtr == NULL ) {\n\t\treturn;\n\t}\n\n\t*width = item->textRect.w;\n\t*height = item->textRect.h;\n\n\t// keeps us from computing the widths and heights more than once\n\tif (*width == 0 || (item->type == ITEM_TYPE_OWNERDRAW && item->textalignment == ITEM_ALIGN_CENTER)) {\n\t\tint originalWidth = DC->textWidth(item->text, item->textscale, 0);\n\n\t\tif (item->type == ITEM_TYPE_OWNERDRAW && (item->textalignment == ITEM_ALIGN_CENTER || item->textalignment == ITEM_ALIGN_RIGHT)) {\n\t\t\toriginalWidth += DC->ownerDrawWidth(item->window.ownerDraw, item->textscale);\n\t\t} else if (item->type == ITEM_TYPE_EDITFIELD && item->textalignment == ITEM_ALIGN_CENTER && item->cvar) {\n\t\t\tchar buff[256];\n\t\t\tDC->getCVarString(item->cvar, buff, 256);\n\t\t\toriginalWidth += DC->textWidth(buff, item->textscale, 0);\n\t\t}\n\n\t\t*width = DC->textWidth(textPtr, item->textscale, 0);\n\t\t*height = DC->textHeight(textPtr, item->textscale, 0);\n\t\titem->textRect.w = *width;\n\t\titem->textRect.h = *height;\n\t\titem->textRect.x = item->textalignx;\n\t\titem->textRect.y = item->textaligny;\n\t\tif (item->textalignment == ITEM_ALIGN_RIGHT) {\n\t\t\titem->textRect.x = item->textalignx - originalWidth;\n\t\t} else if (item->textalignment == ITEM_ALIGN_CENTER) {\n\t\t\titem->textRect.x = item->textalignx - originalWidth / 2;\n\t\t}\n\n\t\tToWindowCoords(&item->textRect.x, &item->textRect.y, &item->window);\n\t}\n}\n\nvoid Item_TextColor(itemDef_t *item, vec4_t *newColor) {\n\tvec4_t lowLight;\n\tmenuDef_t *parent = (menuDef_t*)item->parent;\n\n\tFade(&item->window.flags, &item->window.foreColor[3], parent->fadeClamp, &item->window.nextTime, parent->fadeCycle, qtrue, parent->fadeAmount);\n\n\tif (item->window.flags & WINDOW_HASFOCUS) {\n\t\tlowLight[0] = 0.8 * parent->focusColor[0]; \n\t\tlowLight[1] = 0.8 * parent->focusColor[1]; \n\t\tlowLight[2] = 0.8 * parent->focusColor[2]; \n\t\tlowLight[3] = 0.8 * parent->focusColor[3]; \n\t\tLerpColor(parent->focusColor,lowLight,*newColor,0.5+0.5*sin(DC->realTime / PULSE_DIVISOR));\n\t} else if (item->textStyle == ITEM_TEXTSTYLE_BLINK && !((DC->realTime/BLINK_DIVISOR) & 1)) {\n\t\tlowLight[0] = 0.8 * item->window.foreColor[0]; \n\t\tlowLight[1] = 0.8 * item->window.foreColor[1]; \n\t\tlowLight[2] = 0.8 * item->window.foreColor[2]; \n\t\tlowLight[3] = 0.8 * item->window.foreColor[3]; \n\t\tLerpColor(item->window.foreColor,lowLight,*newColor,0.5+0.5*sin(DC->realTime / PULSE_DIVISOR));\n\t} else {\n\t\tmemcpy(newColor, &item->window.foreColor, sizeof(vec4_t));\n\t\t// items can be enabled and disabled based on cvars\n\t}\n\n\tif (item->enableCvar && *item->enableCvar && item->cvarTest && *item->cvarTest) {\n\t\tif (item->cvarFlags & (CVAR_ENABLE | CVAR_DISABLE) && !Item_EnableShowViaCvar(item, CVAR_ENABLE)) {\n\t\t\tmemcpy(newColor, &parent->disableColor, sizeof(vec4_t));\n\t\t}\n\t}\n}\n\nvoid Item_Text_AutoWrapped_Paint(itemDef_t *item) {\n\tchar text[1024];\n\tconst char *p, *textPtr, *newLinePtr;\n\tchar buff[1024];\n\tint width, height, len, textWidth, newLine, newLineWidth;\n\tfloat y;\n\tvec4_t color;\n\n\ttextWidth = 0;\n\tnewLinePtr = NULL;\n\n\tif (item->text == NULL) {\n\t\tif (item->cvar == NULL) {\n\t\t\treturn;\n\t\t}\n\t\telse {\n\t\t\tDC->getCVarString(item->cvar, text, sizeof(text));\n\t\t\ttextPtr = text;\n\t\t}\n\t}\n\telse {\n\t\ttextPtr = item->text;\n\t}\n\tif (*textPtr == '\\0') {\n\t\treturn;\n\t}\n\tItem_TextColor(item, &color);\n\tItem_SetTextExtents(item, &width, &height, textPtr);\n\n\ty = item->textaligny;\n\tlen = 0;\n\tbuff[0] = '\\0';\n\tnewLine = 0;\n\tnewLineWidth = 0;\n\tp = textPtr;\n\twhile (p) {\n\t\tif (*p == ' ' || *p == '\\t' || *p == '\\n' || *p == '\\0') {\n\t\t\tnewLine = len;\n\t\t\tnewLinePtr = p+1;\n\t\t\tnewLineWidth = textWidth;\n\t\t}\n\t\ttextWidth = DC->textWidth(buff, item->textscale, 0);\n\t\tif ( (newLine && textWidth > item->window.rect.w) || *p == '\\n' || *p == '\\0') {\n\t\t\tif (len) {\n\t\t\t\tif (item->textalignment == ITEM_ALIGN_LEFT) {\n\t\t\t\t\titem->textRect.x = item->textalignx;\n\t\t\t\t} else if (item->textalignment == ITEM_ALIGN_RIGHT) {\n\t\t\t\t\titem->textRect.x = item->textalignx - newLineWidth;\n\t\t\t\t} else if (item->textalignment == ITEM_ALIGN_CENTER) {\n\t\t\t\t\titem->textRect.x = item->textalignx - newLineWidth / 2;\n\t\t\t\t}\n\t\t\t\titem->textRect.y = y;\n\t\t\t\tToWindowCoords(&item->textRect.x, &item->textRect.y, &item->window);\n\t\t\t\t//\n\t\t\t\tbuff[newLine] = '\\0';\n\t\t\t\tDC->drawText(item->textRect.x, item->textRect.y, item->textscale, color, buff, 0, 0, item->textStyle);\n\t\t\t}\n\t\t\tif (*p == '\\0') {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t//\n\t\t\ty += height + 5;\n\t\t\tp = newLinePtr;\n\t\t\tlen = 0;\n\t\t\tnewLine = 0;\n\t\t\tnewLineWidth = 0;\n\t\t\tcontinue;\n\t\t}\n\t\tbuff[len++] = *p++;\n\t\tbuff[len] = '\\0';\n\t}\n}\n\nvoid Item_Text_Wrapped_Paint(itemDef_t *item) {\n\tchar text[1024];\n\tconst char *p, *start, *textPtr;\n\tchar buff[1024];\n\tint width, height;\n\tfloat x, y;\n\tvec4_t color;\n\n\t// now paint the text and/or any optional images\n\t// default to left\n\n\tif (item->text == NULL) {\n\t\tif (item->cvar == NULL) {\n\t\t\treturn;\n\t\t}\n\t\telse {\n\t\t\tDC->getCVarString(item->cvar, text, sizeof(text));\n\t\t\ttextPtr = text;\n\t\t}\n\t}\n\telse {\n\t\ttextPtr = item->text;\n\t}\n\tif (*textPtr == '\\0') {\n\t\treturn;\n\t}\n\n\tItem_TextColor(item, &color);\n\tItem_SetTextExtents(item, &width, &height, textPtr);\n\n\tx = item->textRect.x;\n\ty = item->textRect.y;\n\tstart = textPtr;\n\tp = strchr(textPtr, '\\r');\n\twhile (p && *p) {\n\t\tstrncpy(buff, start, p-start+1);\n\t\tbuff[p-start] = '\\0';\n\t\tDC->drawText(x, y, item->textscale, color, buff, 0, 0, item->textStyle);\n\t\ty += height + 5;\n\t\tstart += p - start + 1;\n\t\tp = strchr(p+1, '\\r');\n\t}\n\tDC->drawText(x, y, item->textscale, color, start, 0, 0, item->textStyle);\n}\n\nvoid Item_Text_Paint(itemDef_t *item) {\n\tchar text[1024];\n\tconst char *textPtr;\n\tint height, width;\n\tvec4_t color;\n\n\tif (item->window.flags & WINDOW_WRAPPED) {\n\t\tItem_Text_Wrapped_Paint(item);\n\t\treturn;\n\t}\n\tif (item->window.flags & WINDOW_AUTOWRAPPED) {\n\t\tItem_Text_AutoWrapped_Paint(item);\n\t\treturn;\n\t}\n\n\tif (item->text == NULL) {\n\t\tif (item->cvar == NULL) {\n\t\t\treturn;\n\t\t}\n\t\telse {\n\t\t\tDC->getCVarString(item->cvar, text, sizeof(text));\n\t\t\ttextPtr = text;\n\t\t}\n\t}\n\telse {\n\t\ttextPtr = item->text;\n\t}\n\n\t// this needs to go here as it sets extents for cvar types as well\n\tItem_SetTextExtents(item, &width, &height, textPtr);\n\n\tif (*textPtr == '\\0') {\n\t\treturn;\n\t}\n\n\n\tItem_TextColor(item, &color);\n\n\t//FIXME: this is a fucking mess\n/*\n\tadjust = 0;\n\tif (item->textStyle == ITEM_TEXTSTYLE_OUTLINED || item->textStyle == ITEM_TEXTSTYLE_OUTLINESHADOWED) {\n\t\tadjust = 0.5;\n\t}\n\n\tif (item->textStyle == ITEM_TEXTSTYLE_SHADOWED || item->textStyle == ITEM_TEXTSTYLE_OUTLINESHADOWED) {\n\t\tFade(&item->window.flags, &DC->Assets.shadowColor[3], DC->Assets.fadeClamp, &item->window.nextTime, DC->Assets.fadeCycle, qfalse);\n\t\tDC->drawText(item->textRect.x + DC->Assets.shadowX, item->textRect.y + DC->Assets.shadowY, item->textscale, DC->Assets.shadowColor, textPtr, adjust);\n\t}\n*/\n\n\n//\tif (item->textStyle == ITEM_TEXTSTYLE_OUTLINED || item->textStyle == ITEM_TEXTSTYLE_OUTLINESHADOWED) {\n//\t\tFade(&item->window.flags, &item->window.outlineColor[3], DC->Assets.fadeClamp, &item->window.nextTime, DC->Assets.fadeCycle, qfalse);\n//\t\t/*\n//\t\tText_Paint(item->textRect.x-1, item->textRect.y-1, item->textscale, item->window.foreColor, textPtr, adjust);\n//\t\tText_Paint(item->textRect.x, item->textRect.y-1, item->textscale, item->window.foreColor, textPtr, adjust);\n//\t\tText_Paint(item->textRect.x+1, item->textRect.y-1, item->textscale, item->window.foreColor, textPtr, adjust);\n//\t\tText_Paint(item->textRect.x-1, item->textRect.y, item->textscale, item->window.foreColor, textPtr, adjust);\n//\t\tText_Paint(item->textRect.x+1, item->textRect.y, item->textscale, item->window.foreColor, textPtr, adjust);\n//\t\tText_Paint(item->textRect.x-1, item->textRect.y+1, item->textscale, item->window.foreColor, textPtr, adjust);\n//\t\tText_Paint(item->textRect.x, item->textRect.y+1, item->textscale, item->window.foreColor, textPtr, adjust);\n//\t\tText_Paint(item->textRect.x+1, item->textRect.y+1, item->textscale, item->window.foreColor, textPtr, adjust);\n//\t\t*/\n//\t\tDC->drawText(item->textRect.x - 1, item->textRect.y + 1, item->textscale * 1.02, item->window.outlineColor, textPtr, adjust);\n//\t}\n\n\tDC->drawText(item->textRect.x, item->textRect.y, item->textscale, color, textPtr, 0, 0, item->textStyle);\n}\n\n\n\n//float\t\t\ttrap_Cvar_VariableValue( const char *var_name );\n//void\t\t\ttrap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize );\n\nvoid Item_TextField_Paint(itemDef_t *item) {\n\tchar buff[1024];\n\tvec4_t newColor, lowLight;\n\tint offset;\n\tmenuDef_t *parent = (menuDef_t*)item->parent;\n\teditFieldDef_t *editPtr = (editFieldDef_t*)item->typeData;\n\n\tItem_Text_Paint(item);\n\n\tbuff[0] = '\\0';\n\n\tif (item->cvar) {\n\t\tDC->getCVarString(item->cvar, buff, sizeof(buff));\n\t} \n\n\tparent = (menuDef_t*)item->parent;\n\n\tif (item->window.flags & WINDOW_HASFOCUS) {\n\t\tlowLight[0] = 0.8 * parent->focusColor[0]; \n\t\tlowLight[1] = 0.8 * parent->focusColor[1]; \n\t\tlowLight[2] = 0.8 * parent->focusColor[2]; \n\t\tlowLight[3] = 0.8 * parent->focusColor[3]; \n\t\tLerpColor(parent->focusColor,lowLight,newColor,0.5+0.5*sin(DC->realTime / PULSE_DIVISOR));\n\t} else {\n\t\tmemcpy(&newColor, &item->window.foreColor, sizeof(vec4_t));\n\t}\n\n\toffset = (item->text && *item->text) ? 8 : 0;\n\tif (item->window.flags & WINDOW_HASFOCUS && g_editingField) {\n\t\tchar cursor = DC->getOverstrikeMode() ? '_' : '|';\n\t\tDC->drawTextWithCursor(item->textRect.x + item->textRect.w + offset, item->textRect.y, item->textscale, newColor, buff + editPtr->paintOffset, item->cursorPos - editPtr->paintOffset , cursor, editPtr->maxPaintChars, item->textStyle);\n\t} else {\n\t\tDC->drawText(item->textRect.x + item->textRect.w + offset, item->textRect.y, item->textscale, newColor, buff + editPtr->paintOffset, 0, editPtr->maxPaintChars, item->textStyle);\n\t}\n\n}\n\nvoid Item_YesNo_Paint(itemDef_t *item) {\n\tvec4_t newColor, lowLight;\n\tfloat value;\n\tmenuDef_t *parent = (menuDef_t*)item->parent;\n\n\tvalue = (item->cvar) ? DC->getCVarValue(item->cvar) : 0;\n\n\tif (item->window.flags & WINDOW_HASFOCUS) {\n\t\tlowLight[0] = 0.8 * parent->focusColor[0]; \n\t\tlowLight[1] = 0.8 * parent->focusColor[1]; \n\t\tlowLight[2] = 0.8 * parent->focusColor[2]; \n\t\tlowLight[3] = 0.8 * parent->focusColor[3]; \n\t\tLerpColor(parent->focusColor,lowLight,newColor,0.5+0.5*sin(DC->realTime / PULSE_DIVISOR));\n\t} else {\n\t\tmemcpy(&newColor, &item->window.foreColor, sizeof(vec4_t));\n\t}\n\n\tif (item->text) {\n\t\tItem_Text_Paint(item);\n\t\tDC->drawText(item->textRect.x + item->textRect.w + 8, item->textRect.y, item->textscale, newColor, (value != 0) ? \"Yes\" : \"No\", 0, 0, item->textStyle);\n\t} else {\n\t\tDC->drawText(item->textRect.x, item->textRect.y, item->textscale, newColor, (value != 0) ? \"Yes\" : \"No\", 0, 0, item->textStyle);\n\t}\n}\n\nvoid Item_Multi_Paint(itemDef_t *item) {\n\tvec4_t newColor, lowLight;\n\tconst char *text = \"\";\n\tmenuDef_t *parent = (menuDef_t*)item->parent;\n\n\tif (item->window.flags & WINDOW_HASFOCUS) {\n\t\tlowLight[0] = 0.8 * parent->focusColor[0]; \n\t\tlowLight[1] = 0.8 * parent->focusColor[1]; \n\t\tlowLight[2] = 0.8 * parent->focusColor[2]; \n\t\tlowLight[3] = 0.8 * parent->focusColor[3]; \n\t\tLerpColor(parent->focusColor,lowLight,newColor,0.5+0.5*sin(DC->realTime / PULSE_DIVISOR));\n\t} else {\n\t\tmemcpy(&newColor, &item->window.foreColor, sizeof(vec4_t));\n\t}\n\n\ttext = Item_Multi_Setting(item);\n\n\tif (item->text) {\n\t\tItem_Text_Paint(item);\n\t\tDC->drawText(item->textRect.x + item->textRect.w + 8, item->textRect.y, item->textscale, newColor, text, 0, 0, item->textStyle);\n\t} else {\n\t\tDC->drawText(item->textRect.x, item->textRect.y, item->textscale, newColor, text, 0, 0, item->textStyle);\n\t}\n}\n\n\ntypedef struct {\n\tchar\t*command;\n\tint\t\tid;\n\tint\t\tdefaultbind1;\n\tint\t\tdefaultbind2;\n\tint\t\tbind1;\n\tint\t\tbind2;\n} bind_t;\n\ntypedef struct\n{\n\tchar*\tname;\n\tfloat\tdefaultvalue;\n\tfloat\tvalue;\t\n} configcvar_t;\n\n\nstatic bind_t g_bindings[] = \n{\n\t{\"+scores\",\t\t\t K_TAB,\t\t\t\t-1,\t\t-1, -1},\n\t{\"+button2\",\t\t K_ENTER,\t\t\t-1,\t\t-1, -1},\n\t{\"+speed\", \t\t\t K_SHIFT,\t\t\t-1,\t\t-1,\t-1},\n\t{\"+forward\", \t\t K_UPARROW,\t\t-1,\t\t-1, -1},\n\t{\"+back\", \t\t\t K_DOWNARROW,\t-1,\t\t-1, -1},\n\t{\"+moveleft\", \t ',',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"+moveright\", \t '.',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"+moveup\",\t\t\t K_SPACE,\t\t\t-1,\t\t-1, -1},\n\t{\"+movedown\",\t\t 'c',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"+left\", \t\t\t K_LEFTARROW,\t-1,\t\t-1, -1},\n\t{\"+right\", \t\t\t K_RIGHTARROW,\t-1,\t\t-1, -1},\n\t{\"+strafe\", \t\t K_ALT,\t\t\t\t-1,\t\t-1, -1},\n\t{\"+lookup\", \t\t K_PGDN,\t\t\t\t-1,\t\t-1, -1},\n\t{\"+lookdown\", \t K_DEL,\t\t\t\t-1,\t\t-1, -1},\n\t{\"+mlook\", \t\t\t '/',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"centerview\", \t K_END,\t\t\t\t-1,\t\t-1, -1},\n\t{\"+zoom\", \t\t\t -1,\t\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 1\",\t\t '1',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 2\",\t\t '2',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 3\",\t\t '3',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 4\",\t\t '4',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 5\",\t\t '5',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 6\",\t\t '6',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 7\",\t\t '7',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 8\",\t\t '8',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 9\",\t\t '9',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 10\",\t\t '0',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 11\",\t\t -1,\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 12\",\t\t -1,\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"weapon 13\",\t\t -1,\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"+attack\", \t\t K_CTRL,\t\t\t\t-1,\t\t-1, -1},\n\t{\"weapprev\",\t\t '[',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"weapnext\", \t\t ']',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"+button3\", \t\t K_MOUSE3,\t\t\t-1,\t\t-1, -1},\n\t{\"+button4\", \t\t K_MOUSE4,\t\t\t-1,\t\t-1, -1},\n\t{\"prevTeamMember\", 'w',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"nextTeamMember\", 'r',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"nextOrder\", 't',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"confirmOrder\", 'y',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"denyOrder\", 'n',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"taskOffense\", 'o',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"taskDefense\", 'd',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"taskPatrol\", 'p',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"taskCamp\", 'c',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"taskFollow\", 'f',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"taskRetrieve\", 'v',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"taskEscort\", 'e',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"taskOwnFlag\", 'i',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"taskSuicide\", 'k',\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"tauntKillInsult\", K_F1,\t\t\t-1,\t\t-1, -1},\n\t{\"tauntPraise\", K_F2,\t\t\t-1,\t\t-1, -1},\n\t{\"tauntTaunt\", K_F3,\t\t\t-1,\t\t-1, -1},\n\t{\"tauntDeathInsult\", K_F4,\t\t\t-1,\t\t-1, -1},\n\t{\"tauntGauntlet\", K_F5,\t\t\t-1,\t\t-1, -1},\n\t{\"scoresUp\", K_KP_PGUP,\t\t\t-1,\t\t-1, -1},\n\t{\"scoresDown\", K_KP_PGDN,\t\t\t-1,\t\t-1, -1},\n\t// bk001205 - this one below was:  '-1' \n\t{\"messagemode\",  -1,\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"messagemode2\", -1,\t\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"messagemode3\", -1,\t\t\t\t\t\t-1,\t\t-1, -1},\n\t{\"messagemode4\", -1,\t\t\t\t\t\t-1,\t\t-1, -1}\n};\n\n\nstatic const int g_bindCount = sizeof(g_bindings) / sizeof(bind_t);\n\n#ifndef MISSIONPACK // bk001206\nstatic configcvar_t g_configcvars[] =\n{\n\t{\"cl_run\",\t\t\t0,\t\t\t\t\t0},\n\t{\"m_pitch\",\t\t\t0,\t\t\t\t\t0},\n\t{\"cg_autoswitch\",\t0,\t\t\t\t\t0},\n\t{\"sensitivity\",\t\t0,\t\t\t\t\t0},\n\t{\"in_joystick\",\t\t0,\t\t\t\t\t0},\n\t{\"joy_threshold\",\t0,\t\t\t\t\t0},\n\t{\"m_filter\",\t\t0,\t\t\t\t\t0},\n\t{\"cl_freelook\",\t\t0,\t\t\t\t\t0},\n\t{NULL,\t\t\t\t0,\t\t\t\t\t0}\n};\n#endif\n\n/*\n=================\nControls_GetKeyAssignment\n=================\n*/\nstatic void Controls_GetKeyAssignment (char *command, int *twokeys)\n{\n\tint\t\tcount;\n\tint\t\tj;\n\tchar\tb[256];\n\n\ttwokeys[0] = twokeys[1] = -1;\n\tcount = 0;\n\n\tfor ( j = 0; j < 256; j++ )\n\t{\n\t\tDC->getBindingBuf( j, b, 256 );\n\t\tif ( *b == 0 ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( !Q_stricmp( b, command ) ) {\n\t\t\ttwokeys[count] = j;\n\t\t\tcount++;\n\t\t\tif (count == 2) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n=================\nControls_GetConfig\n=================\n*/\nvoid Controls_GetConfig( void )\n{\n\tint\t\ti;\n\tint\t\ttwokeys[2];\n\n\t// iterate each command, get its numeric binding\n\tfor (i=0; i < g_bindCount; i++)\n\t{\n\n\t\tControls_GetKeyAssignment(g_bindings[i].command, twokeys);\n\n\t\tg_bindings[i].bind1 = twokeys[0];\n\t\tg_bindings[i].bind2 = twokeys[1];\n\t}\n\n\t//s_controls.invertmouse.curvalue  = DC->getCVarValue( \"m_pitch\" ) < 0;\n\t//s_controls.smoothmouse.curvalue  = UI_ClampCvar( 0, 1, Controls_GetCvarValue( \"m_filter\" ) );\n\t//s_controls.alwaysrun.curvalue    = UI_ClampCvar( 0, 1, Controls_GetCvarValue( \"cl_run\" ) );\n\t//s_controls.autoswitch.curvalue   = UI_ClampCvar( 0, 1, Controls_GetCvarValue( \"cg_autoswitch\" ) );\n\t//s_controls.sensitivity.curvalue  = UI_ClampCvar( 2, 30, Controls_GetCvarValue( \"sensitivity\" ) );\n\t//s_controls.joyenable.curvalue    = UI_ClampCvar( 0, 1, Controls_GetCvarValue( \"in_joystick\" ) );\n\t//s_controls.joythreshold.curvalue = UI_ClampCvar( 0.05, 0.75, Controls_GetCvarValue( \"joy_threshold\" ) );\n\t//s_controls.freelook.curvalue     = UI_ClampCvar( 0, 1, Controls_GetCvarValue( \"cl_freelook\" ) );\n}\n\n/*\n=================\nControls_SetConfig\n=================\n*/\nvoid Controls_SetConfig(qboolean restart)\n{\n\tint\t\ti;\n\n\t// iterate each command, get its numeric binding\n\tfor (i=0; i < g_bindCount; i++)\n\t{\n\n\t\tif (g_bindings[i].bind1 != -1)\n\t\t{\t\n\t\t\tDC->setBinding( g_bindings[i].bind1, g_bindings[i].command );\n\n\t\t\tif (g_bindings[i].bind2 != -1)\n\t\t\t\tDC->setBinding( g_bindings[i].bind2, g_bindings[i].command );\n\t\t}\n\t}\n\n\t//if ( s_controls.invertmouse.curvalue )\n\t//\tDC->setCVar(\"m_pitch\", va(\"%f),-fabs( DC->getCVarValue( \"m_pitch\" ) ) );\n\t//else\n\t//\ttrap_Cvar_SetValue( \"m_pitch\", fabs( trap_Cvar_VariableValue( \"m_pitch\" ) ) );\n\n\t//trap_Cvar_SetValue( \"m_filter\", s_controls.smoothmouse.curvalue );\n\t//trap_Cvar_SetValue( \"cl_run\", s_controls.alwaysrun.curvalue );\n\t//trap_Cvar_SetValue( \"cg_autoswitch\", s_controls.autoswitch.curvalue );\n\t//trap_Cvar_SetValue( \"sensitivity\", s_controls.sensitivity.curvalue );\n\t//trap_Cvar_SetValue( \"in_joystick\", s_controls.joyenable.curvalue );\n\t//trap_Cvar_SetValue( \"joy_threshold\", s_controls.joythreshold.curvalue );\n\t//trap_Cvar_SetValue( \"cl_freelook\", s_controls.freelook.curvalue );\n\tDC->executeText(EXEC_APPEND, \"in_restart\\n\");\n\t//trap_Cmd_ExecuteText( EXEC_APPEND, \"in_restart\\n\" );\n}\n\n/*\n=================\nControls_SetDefaults\n=================\n*/\nvoid Controls_SetDefaults( void )\n{\n\tint\ti;\n\n\t// iterate each command, set its default binding\n  for (i=0; i < g_bindCount; i++)\n\t{\n\t\tg_bindings[i].bind1 = g_bindings[i].defaultbind1;\n\t\tg_bindings[i].bind2 = g_bindings[i].defaultbind2;\n\t}\n\n\t//s_controls.invertmouse.curvalue  = Controls_GetCvarDefault( \"m_pitch\" ) < 0;\n\t//s_controls.smoothmouse.curvalue  = Controls_GetCvarDefault( \"m_filter\" );\n\t//s_controls.alwaysrun.curvalue    = Controls_GetCvarDefault( \"cl_run\" );\n\t//s_controls.autoswitch.curvalue   = Controls_GetCvarDefault( \"cg_autoswitch\" );\n\t//s_controls.sensitivity.curvalue  = Controls_GetCvarDefault( \"sensitivity\" );\n\t//s_controls.joyenable.curvalue    = Controls_GetCvarDefault( \"in_joystick\" );\n\t//s_controls.joythreshold.curvalue = Controls_GetCvarDefault( \"joy_threshold\" );\n\t//s_controls.freelook.curvalue     = Controls_GetCvarDefault( \"cl_freelook\" );\n}\n\nint BindingIDFromName(const char *name) {\n\tint i;\n  for (i=0; i < g_bindCount; i++)\n\t{\n\t\tif (Q_stricmp(name, g_bindings[i].command) == 0) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\nchar g_nameBind1[32];\nchar g_nameBind2[32];\n\nvoid BindingFromName(const char *cvar) {\n\tint\ti, b1, b2;\n\n\t// iterate each command, set its default binding\n\tfor (i=0; i < g_bindCount; i++)\n\t{\n\t\tif (Q_stricmp(cvar, g_bindings[i].command) == 0) {\n\t\t\tb1 = g_bindings[i].bind1;\n\t\t\tif (b1 == -1) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\tDC->keynumToStringBuf( b1, g_nameBind1, 32 );\n\t\t\t\tQ_strupr(g_nameBind1);\n\n\t\t\t\tb2 = g_bindings[i].bind2;\n\t\t\t\tif (b2 != -1)\n\t\t\t\t{\n\t\t\t\t\tDC->keynumToStringBuf( b2, g_nameBind2, 32 );\n\t\t\t\t\tQ_strupr(g_nameBind2);\n\t\t\t\t\tstrcat( g_nameBind1, \" or \" );\n\t\t\t\t\tstrcat( g_nameBind1, g_nameBind2 );\n\t\t\t\t}\n\t\t\treturn;\n\t\t}\n\t}\n\tstrcpy(g_nameBind1, \"???\");\n}\n\nvoid Item_Slider_Paint(itemDef_t *item) {\n\tvec4_t newColor, lowLight;\n\tfloat x, y, value;\n\tmenuDef_t *parent = (menuDef_t*)item->parent;\n\n\tvalue = (item->cvar) ? DC->getCVarValue(item->cvar) : 0;\n\n\tif (item->window.flags & WINDOW_HASFOCUS) {\n\t\tlowLight[0] = 0.8 * parent->focusColor[0]; \n\t\tlowLight[1] = 0.8 * parent->focusColor[1]; \n\t\tlowLight[2] = 0.8 * parent->focusColor[2]; \n\t\tlowLight[3] = 0.8 * parent->focusColor[3]; \n\t\tLerpColor(parent->focusColor,lowLight,newColor,0.5+0.5*sin(DC->realTime / PULSE_DIVISOR));\n\t} else {\n\t\tmemcpy(&newColor, &item->window.foreColor, sizeof(vec4_t));\n\t}\n\n\ty = item->window.rect.y;\n\tif (item->text) {\n\t\tItem_Text_Paint(item);\n\t\tx = item->textRect.x + item->textRect.w + 8;\n\t} else {\n\t\tx = item->window.rect.x;\n\t}\n\tDC->setColor(newColor);\n\tDC->drawHandlePic( x, y, SLIDER_WIDTH, SLIDER_HEIGHT, DC->Assets.sliderBar );\n\n\tx = Item_Slider_ThumbPosition(item);\n\tDC->drawHandlePic( x - (SLIDER_THUMB_WIDTH / 2), y - 2, SLIDER_THUMB_WIDTH, SLIDER_THUMB_HEIGHT, DC->Assets.sliderThumb );\n\n}\n\nvoid Item_Bind_Paint(itemDef_t *item) {\n\tvec4_t newColor, lowLight;\n\tfloat value;\n\tint maxChars = 0;\n\tmenuDef_t *parent = (menuDef_t*)item->parent;\n\teditFieldDef_t *editPtr = (editFieldDef_t*)item->typeData;\n\tif (editPtr) {\n\t\tmaxChars = editPtr->maxPaintChars;\n\t}\n\n\tvalue = (item->cvar) ? DC->getCVarValue(item->cvar) : 0;\n\n\tif (item->window.flags & WINDOW_HASFOCUS) {\n\t\tif (g_bindItem == item) {\n\t\t\tlowLight[0] = 0.8f * 1.0f;\n\t\t\tlowLight[1] = 0.8f * 0.0f;\n\t\t\tlowLight[2] = 0.8f * 0.0f;\n\t\t\tlowLight[3] = 0.8f * 1.0f;\n\t\t} else {\n\t\t\tlowLight[0] = 0.8f * parent->focusColor[0]; \n\t\t\tlowLight[1] = 0.8f * parent->focusColor[1]; \n\t\t\tlowLight[2] = 0.8f * parent->focusColor[2]; \n\t\t\tlowLight[3] = 0.8f * parent->focusColor[3]; \n\t\t}\n\t\tLerpColor(parent->focusColor,lowLight,newColor,0.5+0.5*sin(DC->realTime / PULSE_DIVISOR));\n\t} else {\n\t\tmemcpy(&newColor, &item->window.foreColor, sizeof(vec4_t));\n\t}\n\n\tif (item->text) {\n\t\tItem_Text_Paint(item);\n\t\tBindingFromName(item->cvar);\n\t\tDC->drawText(item->textRect.x + item->textRect.w + 8, item->textRect.y, item->textscale, newColor, g_nameBind1, 0, maxChars, item->textStyle);\n\t} else {\n\t\tDC->drawText(item->textRect.x, item->textRect.y, item->textscale, newColor, (value != 0) ? \"FIXME\" : \"FIXME\", 0, maxChars, item->textStyle);\n\t}\n}\n\nqboolean Display_KeyBindPending() {\n\treturn g_waitingForKey;\n}\n\nqboolean Item_Bind_HandleKey(itemDef_t *item, int key, qboolean down) {\n\tint\t\t\tid;\n\tint\t\t\ti;\n\n\tif (Rect_ContainsPoint(&item->window.rect, DC->cursorx, DC->cursory) && !g_waitingForKey)\n\t{\n\t\tif (down && (key == K_MOUSE1 || key == K_ENTER)) {\n\t\t\tg_waitingForKey = qtrue;\n\t\t\tg_bindItem = item;\n\t\t}\n\t\treturn qtrue;\n\t}\n\telse\n\t{\n\t\tif (!g_waitingForKey || g_bindItem == NULL) {\n\t\t\treturn qtrue;\n\t\t}\n\n\t\tif (key & K_CHAR_FLAG) {\n\t\t\treturn qtrue;\n\t\t}\n\n\t\tswitch (key)\n\t\t{\n\t\t\tcase K_ESCAPE:\n\t\t\t\tg_waitingForKey = qfalse;\n\t\t\t\treturn qtrue;\n\t\n\t\t\tcase K_BACKSPACE:\n\t\t\t\tid = BindingIDFromName(item->cvar);\n\t\t\t\tif (id != -1) {\n\t\t\t\t\tg_bindings[id].bind1 = -1;\n\t\t\t\t\tg_bindings[id].bind2 = -1;\n\t\t\t\t}\n\t\t\t\tControls_SetConfig(qtrue);\n\t\t\t\tg_waitingForKey = qfalse;\n\t\t\t\tg_bindItem = NULL;\n\t\t\t\treturn qtrue;\n\n\t\t\tcase '`':\n\t\t\t\treturn qtrue;\n\t\t}\n\t}\n\n\tif (key != -1)\n\t{\n\n\t\tfor (i=0; i < g_bindCount; i++)\n\t\t{\n\n\t\t\tif (g_bindings[i].bind2 == key) {\n\t\t\t\tg_bindings[i].bind2 = -1;\n\t\t\t}\n\n\t\t\tif (g_bindings[i].bind1 == key)\n\t\t\t{\n\t\t\t\tg_bindings[i].bind1 = g_bindings[i].bind2;\n\t\t\t\tg_bindings[i].bind2 = -1;\n\t\t\t}\n\t\t}\n\t}\n\n\n\tid = BindingIDFromName(item->cvar);\n\n\tif (id != -1) {\n\t\tif (key == -1) {\n\t\t\tif( g_bindings[id].bind1 != -1 ) {\n\t\t\t\tDC->setBinding( g_bindings[id].bind1, \"\" );\n\t\t\t\tg_bindings[id].bind1 = -1;\n\t\t\t}\n\t\t\tif( g_bindings[id].bind2 != -1 ) {\n\t\t\t\tDC->setBinding( g_bindings[id].bind2, \"\" );\n\t\t\t\tg_bindings[id].bind2 = -1;\n\t\t\t}\n\t\t}\n\t\telse if (g_bindings[id].bind1 == -1) {\n\t\t\tg_bindings[id].bind1 = key;\n\t\t}\n\t\telse if (g_bindings[id].bind1 != key && g_bindings[id].bind2 == -1) {\n\t\t\tg_bindings[id].bind2 = key;\n\t\t}\n\t\telse {\n\t\t\tDC->setBinding( g_bindings[id].bind1, \"\" );\n\t\t\tDC->setBinding( g_bindings[id].bind2, \"\" );\n\t\t\tg_bindings[id].bind1 = key;\n\t\t\tg_bindings[id].bind2 = -1;\n\t\t}\t\t\t\t\t\t\n\t}\n\n\tControls_SetConfig(qtrue);\t\n\tg_waitingForKey = qfalse;\n\n\treturn qtrue;\n}\n\n\n\nvoid AdjustFrom640(float *x, float *y, float *w, float *h) {\n\t//*x = *x * DC->scale + DC->bias;\n\t*x *= DC->xscale;\n\t*y *= DC->yscale;\n\t*w *= DC->xscale;\n\t*h *= DC->yscale;\n}\n\nvoid Item_Model_Paint(itemDef_t *item) {\n\tfloat x, y, w, h;\n\trefdef_t refdef;\n\trefEntity_t\t\tent;\n\tvec3_t\t\t\tmins, maxs, origin;\n\tvec3_t\t\t\tangles;\n\tmodelDef_t *modelPtr = (modelDef_t*)item->typeData;\n\n\tif (modelPtr == NULL) {\n\t\treturn;\n\t}\n\n\t// setup the refdef\n\tmemset( &refdef, 0, sizeof( refdef ) );\n\trefdef.rdflags = RDF_NOWORLDMODEL;\n\tAxisClear( refdef.viewaxis );\n\tx = item->window.rect.x+1;\n\ty = item->window.rect.y+1;\n\tw = item->window.rect.w-2;\n\th = item->window.rect.h-2;\n\n\tAdjustFrom640( &x, &y, &w, &h );\n\n\trefdef.x = x;\n\trefdef.y = y;\n\trefdef.width = w;\n\trefdef.height = h;\n\n\tDC->modelBounds( item->asset, mins, maxs );\n\n\torigin[2] = -0.5 * ( mins[2] + maxs[2] );\n\torigin[1] = 0.5 * ( mins[1] + maxs[1] );\n\n\t// calculate distance so the model nearly fills the box\n\tif (qtrue) {\n\t\tfloat len = 0.5 * ( maxs[2] - mins[2] );\t\t\n\t\torigin[0] = len / 0.268;\t// len / tan( fov/2 )\n\t\t//origin[0] = len / tan(w/2);\n\t} else {\n\t\torigin[0] = item->textscale;\n\t}\n\trefdef.fov_x = (modelPtr->fov_x) ? modelPtr->fov_x : w;\n\trefdef.fov_y = (modelPtr->fov_y) ? modelPtr->fov_y : h;\n\n\t//refdef.fov_x = (int)((float)refdef.width / 640.0f * 90.0f);\n\t//xx = refdef.width / tan( refdef.fov_x / 360 * M_PI );\n\t//refdef.fov_y = atan2( refdef.height, xx );\n\t//refdef.fov_y *= ( 360 / M_PI );\n\n\tDC->clearScene();\n\n\trefdef.time = DC->realTime;\n\n\t// add the model\n\n\tmemset( &ent, 0, sizeof(ent) );\n\n\t//adjust = 5.0 * sin( (float)uis.realtime / 500 );\n\t//adjust = 360 % (int)((float)uis.realtime / 1000);\n\t//VectorSet( angles, 0, 0, 1 );\n\n\t// use item storage to track\n\tif (modelPtr->rotationSpeed) {\n\t\tif (DC->realTime > item->window.nextTime) {\n\t\t\titem->window.nextTime = DC->realTime + modelPtr->rotationSpeed;\n\t\t\tmodelPtr->angle = (int)(modelPtr->angle + 1) % 360;\n\t\t}\n\t}\n\tVectorSet( angles, 0, modelPtr->angle, 0 );\n\tAnglesToAxis( angles, ent.axis );\n\n\tent.hModel = item->asset;\n\tVectorCopy( origin, ent.origin );\n\tVectorCopy( origin, ent.lightingOrigin );\n\tent.renderfx = RF_LIGHTING_ORIGIN | RF_NOSHADOW;\n\tVectorCopy( ent.origin, ent.oldorigin );\n\n\tDC->addRefEntityToScene( &ent );\n\tDC->renderScene( &refdef );\n\n}\n\n\nvoid Item_Image_Paint(itemDef_t *item) {\n\tif (item == NULL) {\n\t\treturn;\n\t}\n\tDC->drawHandlePic(item->window.rect.x+1, item->window.rect.y+1, item->window.rect.w-2, item->window.rect.h-2, item->asset);\n}\n\nvoid Item_ListBox_Paint(itemDef_t *item) {\n\tfloat x, y, size, count, i, thumb;\n\tqhandle_t image;\n\tqhandle_t optionalImage;\n\tlistBoxDef_t *listPtr = (listBoxDef_t*)item->typeData;\n\n\t// the listbox is horizontal or vertical and has a fixed size scroll bar going either direction\n\t// elements are enumerated from the DC and either text or image handles are acquired from the DC as well\n\t// textscale is used to size the text, textalignx and textaligny are used to size image elements\n\t// there is no clipping available so only the last completely visible item is painted\n\tcount = DC->feederCount(item->special);\n\t// default is vertical if horizontal flag is not here\n\tif (item->window.flags & WINDOW_HORIZONTAL) {\n\t\t// draw scrollbar in bottom of the window\n\t\t// bar\n\t\tx = item->window.rect.x + 1;\n\t\ty = item->window.rect.y + item->window.rect.h - SCROLLBAR_SIZE - 1;\n\t\tDC->drawHandlePic(x, y, SCROLLBAR_SIZE, SCROLLBAR_SIZE, DC->Assets.scrollBarArrowLeft);\n\t\tx += SCROLLBAR_SIZE - 1;\n\t\tsize = item->window.rect.w - (SCROLLBAR_SIZE * 2);\n\t\tDC->drawHandlePic(x, y, size+1, SCROLLBAR_SIZE, DC->Assets.scrollBar);\n\t\tx += size - 1;\n\t\tDC->drawHandlePic(x, y, SCROLLBAR_SIZE, SCROLLBAR_SIZE, DC->Assets.scrollBarArrowRight);\n\t\t// thumb\n\t\tthumb = Item_ListBox_ThumbDrawPosition(item);//Item_ListBox_ThumbPosition(item);\n\t\tif (thumb > x - SCROLLBAR_SIZE - 1) {\n\t\t\tthumb = x - SCROLLBAR_SIZE - 1;\n\t\t}\n\t\tDC->drawHandlePic(thumb, y, SCROLLBAR_SIZE, SCROLLBAR_SIZE, DC->Assets.scrollBarThumb);\n\t\t//\n\t\tlistPtr->endPos = listPtr->startPos;\n\t\tsize = item->window.rect.w - 2;\n\t\t// items\n\t\t// size contains max available space\n\t\tif (listPtr->elementStyle == LISTBOX_IMAGE) {\n\t\t\t// fit = 0;\n\t\t\tx = item->window.rect.x + 1;\n\t\t\ty = item->window.rect.y + 1;\n\t\t\tfor (i = listPtr->startPos; i < count; i++) {\n\t\t\t\t// always draw at least one\n\t\t\t\t// which may overdraw the box if it is too small for the element\n\t\t\t\timage = DC->feederItemImage(item->special, i);\n\t\t\t\tif (image) {\n\t\t\t\t\tDC->drawHandlePic(x+1, y+1, listPtr->elementWidth - 2, listPtr->elementHeight - 2, image);\n\t\t\t\t}\n\n\t\t\t\tif (i == item->cursorPos) {\n\t\t\t\t\tDC->drawRect(x, y, listPtr->elementWidth-1, listPtr->elementHeight-1, item->window.borderSize, item->window.borderColor);\n\t\t\t\t}\n\n\t\t\t\tsize -= listPtr->elementWidth;\n\t\t\t\tif (size < listPtr->elementWidth) {\n\t\t\t\t\tlistPtr->drawPadding = size; //listPtr->elementWidth - size;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tx += listPtr->elementWidth;\n\t\t\t\tlistPtr->endPos++;\n\t\t\t\t// fit++;\n\t\t\t}\n\t\t} else {\n\t\t\t//\n\t\t}\n\t} else {\n\t\t// draw scrollbar to right side of the window\n\t\tx = item->window.rect.x + item->window.rect.w - SCROLLBAR_SIZE - 1;\n\t\ty = item->window.rect.y + 1;\n\t\tDC->drawHandlePic(x, y, SCROLLBAR_SIZE, SCROLLBAR_SIZE, DC->Assets.scrollBarArrowUp);\n\t\ty += SCROLLBAR_SIZE - 1;\n\n\t\tlistPtr->endPos = listPtr->startPos;\n\t\tsize = item->window.rect.h - (SCROLLBAR_SIZE * 2);\n\t\tDC->drawHandlePic(x, y, SCROLLBAR_SIZE, size+1, DC->Assets.scrollBar);\n\t\ty += size - 1;\n\t\tDC->drawHandlePic(x, y, SCROLLBAR_SIZE, SCROLLBAR_SIZE, DC->Assets.scrollBarArrowDown);\n\t\t// thumb\n\t\tthumb = Item_ListBox_ThumbDrawPosition(item);//Item_ListBox_ThumbPosition(item);\n\t\tif (thumb > y - SCROLLBAR_SIZE - 1) {\n\t\t\tthumb = y - SCROLLBAR_SIZE - 1;\n\t\t}\n\t\tDC->drawHandlePic(x, thumb, SCROLLBAR_SIZE, SCROLLBAR_SIZE, DC->Assets.scrollBarThumb);\n\n\t\t// adjust size for item painting\n\t\tsize = item->window.rect.h - 2;\n\t\tif (listPtr->elementStyle == LISTBOX_IMAGE) {\n\t\t\t// fit = 0;\n\t\t\tx = item->window.rect.x + 1;\n\t\t\ty = item->window.rect.y + 1;\n\t\t\tfor (i = listPtr->startPos; i < count; i++) {\n\t\t\t\t// always draw at least one\n\t\t\t\t// which may overdraw the box if it is too small for the element\n\t\t\t\timage = DC->feederItemImage(item->special, i);\n\t\t\t\tif (image) {\n\t\t\t\t\tDC->drawHandlePic(x+1, y+1, listPtr->elementWidth - 2, listPtr->elementHeight - 2, image);\n\t\t\t\t}\n\n\t\t\t\tif (i == item->cursorPos) {\n\t\t\t\t\tDC->drawRect(x, y, listPtr->elementWidth - 1, listPtr->elementHeight - 1, item->window.borderSize, item->window.borderColor);\n\t\t\t\t}\n\n\t\t\t\tlistPtr->endPos++;\n\t\t\t\tsize -= listPtr->elementWidth;\n\t\t\t\tif (size < listPtr->elementHeight) {\n\t\t\t\t\tlistPtr->drawPadding = listPtr->elementHeight - size;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\ty += listPtr->elementHeight;\n\t\t\t\t// fit++;\n\t\t\t}\n\t\t} else {\n\t\t\tx = item->window.rect.x + 1;\n\t\t\ty = item->window.rect.y + 1;\n\t\t\tfor (i = listPtr->startPos; i < count; i++) {\n\t\t\t\tconst char *text;\n\t\t\t\t// always draw at least one\n\t\t\t\t// which may overdraw the box if it is too small for the element\n\n\t\t\t\tif (listPtr->numColumns > 0) {\n\t\t\t\t\tint j;\n\t\t\t\t\tfor (j = 0; j < listPtr->numColumns; j++) {\n\t\t\t\t\t\ttext = DC->feederItemText(item->special, i, j, &optionalImage);\n\t\t\t\t\t\tif (optionalImage >= 0) {\n\t\t\t\t\t\t\tDC->drawHandlePic(x + 4 + listPtr->columnInfo[j].pos, y - 1 + listPtr->elementHeight / 2, listPtr->columnInfo[j].width, listPtr->columnInfo[j].width, optionalImage);\n\t\t\t\t\t\t} else if (text) {\n\t\t\t\t\t\t\tDC->drawText(x + 4 + listPtr->columnInfo[j].pos, y + listPtr->elementHeight, item->textscale, item->window.foreColor, text, 0, listPtr->columnInfo[j].maxChars, item->textStyle);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttext = DC->feederItemText(item->special, i, 0, &optionalImage);\n\t\t\t\t\tif (optionalImage >= 0) {\n\t\t\t\t\t\t//DC->drawHandlePic(x + 4 + listPtr->elementHeight, y, listPtr->columnInfo[j].width, listPtr->columnInfo[j].width, optionalImage);\n\t\t\t\t\t} else if (text) {\n\t\t\t\t\t\tDC->drawText(x + 4, y + listPtr->elementHeight, item->textscale, item->window.foreColor, text, 0, 0, item->textStyle);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (i == item->cursorPos) {\n\t\t\t\t\tDC->fillRect(x + 2, y + 2, item->window.rect.w - SCROLLBAR_SIZE - 4, listPtr->elementHeight, item->window.outlineColor);\n\t\t\t\t}\n\n\t\t\t\tsize -= listPtr->elementHeight;\n\t\t\t\tif (size < listPtr->elementHeight) {\n\t\t\t\t\tlistPtr->drawPadding = listPtr->elementHeight - size;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tlistPtr->endPos++;\n\t\t\t\ty += listPtr->elementHeight;\n\t\t\t\t// fit++;\n\t\t\t}\n\t\t}\n\t}\n}\n\n\nvoid Item_OwnerDraw_Paint(itemDef_t *item) {\n  menuDef_t *parent;\n\n\tif (item == NULL) {\n\t\treturn;\n\t}\n  parent = (menuDef_t*)item->parent;\n\n\tif (DC->ownerDrawItem) {\n\t\tvec4_t color, lowLight;\n\t\tmenuDef_t *parent = (menuDef_t*)item->parent;\n\t\tFade(&item->window.flags, &item->window.foreColor[3], parent->fadeClamp, &item->window.nextTime, parent->fadeCycle, qtrue, parent->fadeAmount);\n\t\tmemcpy(&color, &item->window.foreColor, sizeof(color));\n\t\tif (item->numColors > 0 && DC->getValue) {\n\t\t\t// if the value is within one of the ranges then set color to that, otherwise leave at default\n\t\t\tint i;\n\t\t\tfloat f = DC->getValue(item->window.ownerDraw);\n\t\t\tfor (i = 0; i < item->numColors; i++) {\n\t\t\t\tif (f >= item->colorRanges[i].low && f <= item->colorRanges[i].high) {\n\t\t\t\t\tmemcpy(&color, &item->colorRanges[i].color, sizeof(color));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (item->window.flags & WINDOW_HASFOCUS) {\n\t\t\tlowLight[0] = 0.8 * parent->focusColor[0]; \n\t\t\tlowLight[1] = 0.8 * parent->focusColor[1]; \n\t\t\tlowLight[2] = 0.8 * parent->focusColor[2]; \n\t\t\tlowLight[3] = 0.8 * parent->focusColor[3]; \n\t\t\tLerpColor(parent->focusColor,lowLight,color,0.5+0.5*sin(DC->realTime / PULSE_DIVISOR));\n\t\t} else if (item->textStyle == ITEM_TEXTSTYLE_BLINK && !((DC->realTime/BLINK_DIVISOR) & 1)) {\n\t\t\tlowLight[0] = 0.8 * item->window.foreColor[0]; \n\t\t\tlowLight[1] = 0.8 * item->window.foreColor[1]; \n\t\t\tlowLight[2] = 0.8 * item->window.foreColor[2]; \n\t\t\tlowLight[3] = 0.8 * item->window.foreColor[3]; \n\t\t\tLerpColor(item->window.foreColor,lowLight,color,0.5+0.5*sin(DC->realTime / PULSE_DIVISOR));\n\t\t}\n\n\t\tif (item->cvarFlags & (CVAR_ENABLE | CVAR_DISABLE) && !Item_EnableShowViaCvar(item, CVAR_ENABLE)) {\n\t\t  memcpy(color, parent->disableColor, sizeof(vec4_t)); // bk001207 - FIXME: Com_Memcpy\n\t\t}\n\t\n\t\tif (item->text) {\n\t\t\tItem_Text_Paint(item);\n\t\t\t\tif (item->text[0]) {\n\t\t\t\t\t// +8 is an offset kludge to properly align owner draw items that have text combined with them\n\t\t\t\t\tDC->ownerDrawItem(item->textRect.x + item->textRect.w + 8, item->window.rect.y, item->window.rect.w, item->window.rect.h, 0, item->textaligny, item->window.ownerDraw, item->window.ownerDrawFlags, item->alignment, item->special, item->textscale, color, item->window.background, item->textStyle );\n\t\t\t\t} else {\n\t\t\t\t\tDC->ownerDrawItem(item->textRect.x + item->textRect.w, item->window.rect.y, item->window.rect.w, item->window.rect.h, 0, item->textaligny, item->window.ownerDraw, item->window.ownerDrawFlags, item->alignment, item->special, item->textscale, color, item->window.background, item->textStyle );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\tDC->ownerDrawItem(item->window.rect.x, item->window.rect.y, item->window.rect.w, item->window.rect.h, item->textalignx, item->textaligny, item->window.ownerDraw, item->window.ownerDrawFlags, item->alignment, item->special, item->textscale, color, item->window.background, item->textStyle );\n\t\t}\n\t}\n}\n\n\nvoid Item_Paint(itemDef_t *item) {\n  vec4_t red;\n  menuDef_t *parent = (menuDef_t*)item->parent;\n  red[0] = red[3] = 1;\n  red[1] = red[2] = 0;\n\n  if (item == NULL) {\n    return;\n  }\n\n  if (item->window.flags & WINDOW_ORBITING) {\n    if (DC->realTime > item->window.nextTime) {\n      float rx, ry, a, c, s, w, h;\n      \n      item->window.nextTime = DC->realTime + item->window.offsetTime;\n      // translate\n      w = item->window.rectClient.w / 2;\n      h = item->window.rectClient.h / 2;\n      rx = item->window.rectClient.x + w - item->window.rectEffects.x;\n      ry = item->window.rectClient.y + h - item->window.rectEffects.y;\n      a = 3 * M_PI / 180;\n  \t  c = cos(a);\n      s = sin(a);\n      item->window.rectClient.x = (rx * c - ry * s) + item->window.rectEffects.x - w;\n      item->window.rectClient.y = (rx * s + ry * c) + item->window.rectEffects.y - h;\n      Item_UpdatePosition(item);\n\n    }\n  }\n\n\n  if (item->window.flags & WINDOW_INTRANSITION) {\n    if (DC->realTime > item->window.nextTime) {\n      int done = 0;\n      item->window.nextTime = DC->realTime + item->window.offsetTime;\n\t\t\t// transition the x,y\n\t\t\tif (item->window.rectClient.x == item->window.rectEffects.x) {\n\t\t\t\tdone++;\n\t\t\t} else {\n\t\t\t\tif (item->window.rectClient.x < item->window.rectEffects.x) {\n\t\t\t\t\titem->window.rectClient.x += item->window.rectEffects2.x;\n\t\t\t\t\tif (item->window.rectClient.x > item->window.rectEffects.x) {\n\t\t\t\t\t\titem->window.rectClient.x = item->window.rectEffects.x;\n\t\t\t\t\t\tdone++;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\titem->window.rectClient.x -= item->window.rectEffects2.x;\n\t\t\t\t\tif (item->window.rectClient.x < item->window.rectEffects.x) {\n\t\t\t\t\t\titem->window.rectClient.x = item->window.rectEffects.x;\n\t\t\t\t\t\tdone++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (item->window.rectClient.y == item->window.rectEffects.y) {\n\t\t\t\tdone++;\n\t\t\t} else {\n\t\t\t\tif (item->window.rectClient.y < item->window.rectEffects.y) {\n\t\t\t\t\titem->window.rectClient.y += item->window.rectEffects2.y;\n\t\t\t\t\tif (item->window.rectClient.y > item->window.rectEffects.y) {\n\t\t\t\t\t\titem->window.rectClient.y = item->window.rectEffects.y;\n\t\t\t\t\t\tdone++;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\titem->window.rectClient.y -= item->window.rectEffects2.y;\n\t\t\t\t\tif (item->window.rectClient.y < item->window.rectEffects.y) {\n\t\t\t\t\t\titem->window.rectClient.y = item->window.rectEffects.y;\n\t\t\t\t\t\tdone++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (item->window.rectClient.w == item->window.rectEffects.w) {\n\t\t\t\tdone++;\n\t\t\t} else {\n\t\t\t\tif (item->window.rectClient.w < item->window.rectEffects.w) {\n\t\t\t\t\titem->window.rectClient.w += item->window.rectEffects2.w;\n\t\t\t\t\tif (item->window.rectClient.w > item->window.rectEffects.w) {\n\t\t\t\t\t\titem->window.rectClient.w = item->window.rectEffects.w;\n\t\t\t\t\t\tdone++;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\titem->window.rectClient.w -= item->window.rectEffects2.w;\n\t\t\t\t\tif (item->window.rectClient.w < item->window.rectEffects.w) {\n\t\t\t\t\t\titem->window.rectClient.w = item->window.rectEffects.w;\n\t\t\t\t\t\tdone++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (item->window.rectClient.h == item->window.rectEffects.h) {\n\t\t\t\tdone++;\n\t\t\t} else {\n\t\t\t\tif (item->window.rectClient.h < item->window.rectEffects.h) {\n\t\t\t\t\titem->window.rectClient.h += item->window.rectEffects2.h;\n\t\t\t\t\tif (item->window.rectClient.h > item->window.rectEffects.h) {\n\t\t\t\t\t\titem->window.rectClient.h = item->window.rectEffects.h;\n\t\t\t\t\t\tdone++;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\titem->window.rectClient.h -= item->window.rectEffects2.h;\n\t\t\t\t\tif (item->window.rectClient.h < item->window.rectEffects.h) {\n\t\t\t\t\t\titem->window.rectClient.h = item->window.rectEffects.h;\n\t\t\t\t\t\tdone++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n      Item_UpdatePosition(item);\n\n      if (done == 4) {\n        item->window.flags &= ~WINDOW_INTRANSITION;\n      }\n\n    }\n  }\n\n\tif (item->window.ownerDrawFlags && DC->ownerDrawVisible) {\n\t\tif (!DC->ownerDrawVisible(item->window.ownerDrawFlags)) {\n\t\t\titem->window.flags &= ~WINDOW_VISIBLE;\n\t\t} else {\n\t\t\titem->window.flags |= WINDOW_VISIBLE;\n\t\t}\n\t}\n\n\tif (item->cvarFlags & (CVAR_SHOW | CVAR_HIDE)) {\n\t\tif (!Item_EnableShowViaCvar(item, CVAR_SHOW)) {\n\t\t\treturn;\n\t\t}\n\t}\n\n  if (item->window.flags & WINDOW_TIMEDVISIBLE) {\n\n\t}\n\n  if (!(item->window.flags & WINDOW_VISIBLE)) {\n    return;\n  }\n\n  // paint the rect first.. \n  Window_Paint(&item->window, parent->fadeAmount , parent->fadeClamp, parent->fadeCycle);\n\n  if (debugMode) {\n\t\tvec4_t color;\n\t\trectDef_t *r = Item_CorrectedTextRect(item);\n    color[1] = color[3] = 1;\n    color[0] = color[2] = 0;\n    DC->drawRect(r->x, r->y, r->w, r->h, 1, color);\n  }\n\n  //DC->drawRect(item->window.rect.x, item->window.rect.y, item->window.rect.w, item->window.rect.h, 1, red);\n\n  switch (item->type) {\n    case ITEM_TYPE_OWNERDRAW:\n      Item_OwnerDraw_Paint(item);\n      break;\n    case ITEM_TYPE_TEXT:\n    case ITEM_TYPE_BUTTON:\n      Item_Text_Paint(item);\n      break;\n    case ITEM_TYPE_RADIOBUTTON:\n      break;\n    case ITEM_TYPE_CHECKBOX:\n      break;\n    case ITEM_TYPE_EDITFIELD:\n    case ITEM_TYPE_NUMERICFIELD:\n      Item_TextField_Paint(item);\n      break;\n    case ITEM_TYPE_COMBO:\n      break;\n    case ITEM_TYPE_LISTBOX:\n      Item_ListBox_Paint(item);\n      break;\n    //case ITEM_TYPE_IMAGE:\n    //  Item_Image_Paint(item);\n    //  break;\n    case ITEM_TYPE_MODEL:\n      Item_Model_Paint(item);\n      break;\n    case ITEM_TYPE_YESNO:\n      Item_YesNo_Paint(item);\n      break;\n    case ITEM_TYPE_MULTI:\n      Item_Multi_Paint(item);\n      break;\n    case ITEM_TYPE_BIND:\n      Item_Bind_Paint(item);\n      break;\n    case ITEM_TYPE_SLIDER:\n      Item_Slider_Paint(item);\n      break;\n    default:\n      break;\n  }\n\n}\n\nvoid Menu_Init(menuDef_t *menu) {\n\tmemset(menu, 0, sizeof(menuDef_t));\n\tmenu->cursorItem = -1;\n\tmenu->fadeAmount = DC->Assets.fadeAmount;\n\tmenu->fadeClamp = DC->Assets.fadeClamp;\n\tmenu->fadeCycle = DC->Assets.fadeCycle;\n\tWindow_Init(&menu->window);\n}\n\nitemDef_t *Menu_GetFocusedItem(menuDef_t *menu) {\n  int i;\n  if (menu) {\n    for (i = 0; i < menu->itemCount; i++) {\n      if (menu->items[i]->window.flags & WINDOW_HASFOCUS) {\n        return menu->items[i];\n      }\n    }\n  }\n  return NULL;\n}\n\nmenuDef_t *Menu_GetFocused() {\n  int i;\n  for (i = 0; i < menuCount; i++) {\n    if (Menus[i].window.flags & WINDOW_HASFOCUS && Menus[i].window.flags & WINDOW_VISIBLE) {\n      return &Menus[i];\n    }\n  }\n  return NULL;\n}\n\nvoid Menu_ScrollFeeder(menuDef_t *menu, int feeder, qboolean down) {\n\tif (menu) {\n\t\tint i;\n    for (i = 0; i < menu->itemCount; i++) {\n\t\t\tif (menu->items[i]->special == feeder) {\n\t\t\t\tItem_ListBox_HandleKey(menu->items[i], (down) ? K_DOWNARROW : K_UPARROW, qtrue, qtrue);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n\nvoid Menu_SetFeederSelection(menuDef_t *menu, int feeder, int index, const char *name) {\n\tif (menu == NULL) {\n\t\tif (name == NULL) {\n\t\t\tmenu = Menu_GetFocused();\n\t\t} else {\n\t\t\tmenu = Menus_FindByName(name);\n\t\t}\n\t}\n\n\tif (menu) {\n\t\tint i;\n    for (i = 0; i < menu->itemCount; i++) {\n\t\t\tif (menu->items[i]->special == feeder) {\n\t\t\t\tif (index == 0) {\n\t\t\t\t\tlistBoxDef_t *listPtr = (listBoxDef_t*)menu->items[i]->typeData;\n\t\t\t\t\tlistPtr->cursorPos = 0;\n\t\t\t\t\tlistPtr->startPos = 0;\n\t\t\t\t}\n\t\t\t\tmenu->items[i]->cursorPos = index;\n\t\t\t\tDC->feederSelection(menu->items[i]->special, menu->items[i]->cursorPos);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n}\n\nqboolean Menus_AnyFullScreenVisible() {\n  int i;\n  for (i = 0; i < menuCount; i++) {\n    if (Menus[i].window.flags & WINDOW_VISIBLE && Menus[i].fullScreen) {\n\t\t\treturn qtrue;\n    }\n  }\n  return qfalse;\n}\n\nmenuDef_t *Menus_ActivateByName(const char *p) {\n  int i;\n  menuDef_t *m = NULL;\n\tmenuDef_t *focus = Menu_GetFocused();\n  for (i = 0; i < menuCount; i++) {\n    if (Q_stricmp(Menus[i].window.name, p) == 0) {\n\t    m = &Menus[i];\n\t\t\tMenus_Activate(m);\n\t\t\tif (openMenuCount < MAX_OPEN_MENUS && focus != NULL) {\n\t\t\t\tmenuStack[openMenuCount++] = focus;\n\t\t\t}\n    } else {\n      Menus[i].window.flags &= ~WINDOW_HASFOCUS;\n    }\n  }\n\tDisplay_CloseCinematics();\n  return m;\n}\n\n\nvoid Item_Init(itemDef_t *item) {\n\tmemset(item, 0, sizeof(itemDef_t));\n\titem->textscale = 0.55f;\n\tWindow_Init(&item->window);\n}\n\nvoid Menu_HandleMouseMove(menuDef_t *menu, float x, float y) {\n  int i, pass;\n  qboolean focusSet = qfalse;\n\n  itemDef_t *overItem;\n  if (menu == NULL) {\n    return;\n  }\n\n  if (!(menu->window.flags & (WINDOW_VISIBLE | WINDOW_FORCED))) {\n    return;\n  }\n\n\tif (itemCapture) {\n\t\t//Item_MouseMove(itemCapture, x, y);\n\t\treturn;\n\t}\n\n\tif (g_waitingForKey || g_editingField) {\n\t\treturn;\n\t}\n\n  // FIXME: this is the whole issue of focus vs. mouse over.. \n  // need a better overall solution as i don't like going through everything twice\n  for (pass = 0; pass < 2; pass++) {\n    for (i = 0; i < menu->itemCount; i++) {\n      // turn off focus each item\n      // menu->items[i].window.flags &= ~WINDOW_HASFOCUS;\n\n      if (!(menu->items[i]->window.flags & (WINDOW_VISIBLE | WINDOW_FORCED))) {\n        continue;\n      }\n\n\t\t\t// items can be enabled and disabled based on cvars\n\t\t\tif (menu->items[i]->cvarFlags & (CVAR_ENABLE | CVAR_DISABLE) && !Item_EnableShowViaCvar(menu->items[i], CVAR_ENABLE)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (menu->items[i]->cvarFlags & (CVAR_SHOW | CVAR_HIDE) && !Item_EnableShowViaCvar(menu->items[i], CVAR_SHOW)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\n\n      if (Rect_ContainsPoint(&menu->items[i]->window.rect, x, y)) {\n\t\t\t\tif (pass == 1) {\n\t\t\t\t\toverItem = menu->items[i];\n\t\t\t\t\tif (overItem->type == ITEM_TYPE_TEXT && overItem->text) {\n\t\t\t\t\t\tif (!Rect_ContainsPoint(Item_CorrectedTextRect(overItem), x, y)) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// if we are over an item\n\t\t\t\t\tif (IsVisible(overItem->window.flags)) {\n\t\t\t\t\t\t// different one\n\t\t\t\t\t\tItem_MouseEnter(overItem, x, y);\n\t\t\t\t\t\t// Item_SetMouseOver(overItem, qtrue);\n\n\t\t\t\t\t\t// if item is not a decoration see if it can take focus\n\t\t\t\t\t\tif (!focusSet) {\n\t\t\t\t\t\t\tfocusSet = Item_SetFocus(overItem, x, y);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n      } else if (menu->items[i]->window.flags & WINDOW_MOUSEOVER) {\n          Item_MouseLeave(menu->items[i]);\n          Item_SetMouseOver(menu->items[i], qfalse);\n      }\n    }\n  }\n\n}\n\nvoid Menu_Paint(menuDef_t *menu, qboolean forcePaint) {\n\tint i;\n\n\tif (menu == NULL) {\n\t\treturn;\n\t}\n\n\tif (!(menu->window.flags & WINDOW_VISIBLE) &&  !forcePaint) {\n\t\treturn;\n\t}\n\n\tif (menu->window.ownerDrawFlags && DC->ownerDrawVisible && !DC->ownerDrawVisible(menu->window.ownerDrawFlags)) {\n\t\treturn;\n\t}\n\t\n\tif (forcePaint) {\n\t\tmenu->window.flags |= WINDOW_FORCED;\n\t}\n\n\t// draw the background if necessary\n\tif (menu->fullScreen) {\n\t\t// implies a background shader\n\t\t// FIXME: make sure we have a default shader if fullscreen is set with no background\n\t\tDC->drawHandlePic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, menu->window.background );\n\t} else if (menu->window.background) {\n\t\t// this allows a background shader without being full screen\n\t\t//UI_DrawHandlePic(menu->window.rect.x, menu->window.rect.y, menu->window.rect.w, menu->window.rect.h, menu->backgroundShader);\n\t}\n\n\t// paint the background and or border\n\tWindow_Paint(&menu->window, menu->fadeAmount, menu->fadeClamp, menu->fadeCycle );\n\n\tfor (i = 0; i < menu->itemCount; i++) {\n\t\tItem_Paint(menu->items[i]);\n\t}\n\n\tif (debugMode) {\n\t\tvec4_t color;\n\t\tcolor[0] = color[2] = color[3] = 1;\n\t\tcolor[1] = 0;\n\t\tDC->drawRect(menu->window.rect.x, menu->window.rect.y, menu->window.rect.w, menu->window.rect.h, 1, color);\n\t}\n}\n\n/*\n===============\nItem_ValidateTypeData\n===============\n*/\nvoid Item_ValidateTypeData(itemDef_t *item) {\n\tif (item->typeData) {\n\t\treturn;\n\t}\n\n\tif (item->type == ITEM_TYPE_LISTBOX) {\n\t\titem->typeData = UI_Alloc(sizeof(listBoxDef_t));\n\t\tmemset(item->typeData, 0, sizeof(listBoxDef_t));\n\t} else if (item->type == ITEM_TYPE_EDITFIELD || item->type == ITEM_TYPE_NUMERICFIELD || item->type == ITEM_TYPE_YESNO || item->type == ITEM_TYPE_BIND || item->type == ITEM_TYPE_SLIDER || item->type == ITEM_TYPE_TEXT) {\n\t\titem->typeData = UI_Alloc(sizeof(editFieldDef_t));\n\t\tmemset(item->typeData, 0, sizeof(editFieldDef_t));\n\t\tif (item->type == ITEM_TYPE_EDITFIELD) {\n\t\t\tif (!((editFieldDef_t *) item->typeData)->maxPaintChars) {\n\t\t\t\t((editFieldDef_t *) item->typeData)->maxPaintChars = MAX_EDITFIELD;\n\t\t\t}\n\t\t}\n\t} else if (item->type == ITEM_TYPE_MULTI) {\n\t\titem->typeData = UI_Alloc(sizeof(multiDef_t));\n\t} else if (item->type == ITEM_TYPE_MODEL) {\n\t\titem->typeData = UI_Alloc(sizeof(modelDef_t));\n\t}\n}\n\n/*\n===============\nKeyword Hash\n===============\n*/\n\n#define KEYWORDHASH_SIZE\t512\n\ntypedef struct keywordHash_s\n{\n\tchar *keyword;\n\tqboolean (*func)(itemDef_t *item, int handle);\n\tstruct keywordHash_s *next;\n} keywordHash_t;\n\nint KeywordHash_Key(char *keyword) {\n\tint register hash, i;\n\n\thash = 0;\n\tfor (i = 0; keyword[i] != '\\0'; i++) {\n\t\tif (keyword[i] >= 'A' && keyword[i] <= 'Z')\n\t\t\thash += (keyword[i] + ('a' - 'A')) * (119 + i);\n\t\telse\n\t\t\thash += keyword[i] * (119 + i);\n\t}\n\thash = (hash ^ (hash >> 10) ^ (hash >> 20)) & (KEYWORDHASH_SIZE-1);\n\treturn hash;\n}\n\nvoid KeywordHash_Add(keywordHash_t *table[], keywordHash_t *key) {\n\tint hash;\n\n\thash = KeywordHash_Key(key->keyword);\n/*\n\tif (table[hash]) {\n\t\tint collision = qtrue;\n\t}\n*/\n\tkey->next = table[hash];\n\ttable[hash] = key;\n}\n\nkeywordHash_t *KeywordHash_Find(keywordHash_t *table[], char *keyword)\n{\n\tkeywordHash_t *key;\n\tint hash;\n\n\thash = KeywordHash_Key(keyword);\n\tfor (key = table[hash]; key; key = key->next) {\n\t\tif (!Q_stricmp(key->keyword, keyword))\n\t\t\treturn key;\n\t}\n\treturn NULL;\n}\n\n/*\n===============\nItem Keyword Parse functions\n===============\n*/\n\n// name <string>\nqboolean ItemParse_name( itemDef_t *item, int handle ) {\n\tif (!PC_String_Parse(handle, &item->window.name)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n// name <string>\nqboolean ItemParse_focusSound( itemDef_t *item, int handle ) {\n\tconst char *temp;\n\tif (!PC_String_Parse(handle, &temp)) {\n\t\treturn qfalse;\n\t}\n\titem->focusSound = DC->registerSound(temp, qfalse);\n\treturn qtrue;\n}\n\n\n// text <string>\nqboolean ItemParse_text( itemDef_t *item, int handle ) {\n\tif (!PC_String_Parse(handle, &item->text)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n// group <string>\nqboolean ItemParse_group( itemDef_t *item, int handle ) {\n\tif (!PC_String_Parse(handle, &item->window.group)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n// asset_model <string>\nqboolean ItemParse_asset_model( itemDef_t *item, int handle ) {\n\tconst char *temp;\n\tmodelDef_t *modelPtr;\n\tItem_ValidateTypeData(item);\n\tmodelPtr = (modelDef_t*)item->typeData;\n\n\tif (!PC_String_Parse(handle, &temp)) {\n\t\treturn qfalse;\n\t}\n\titem->asset = DC->registerModel(temp);\n\tmodelPtr->angle = rand() % 360;\n\treturn qtrue;\n}\n\n// asset_shader <string>\nqboolean ItemParse_asset_shader( itemDef_t *item, int handle ) {\n\tconst char *temp;\n\n\tif (!PC_String_Parse(handle, &temp)) {\n\t\treturn qfalse;\n\t}\n\titem->asset = DC->registerShaderNoMip(temp);\n\treturn qtrue;\n}\n\n// model_origin <number> <number> <number>\nqboolean ItemParse_model_origin( itemDef_t *item, int handle ) {\n\tmodelDef_t *modelPtr;\n\tItem_ValidateTypeData(item);\n\tmodelPtr = (modelDef_t*)item->typeData;\n\n\tif (PC_Float_Parse(handle, &modelPtr->origin[0])) {\n\t\tif (PC_Float_Parse(handle, &modelPtr->origin[1])) {\n\t\t\tif (PC_Float_Parse(handle, &modelPtr->origin[2])) {\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n// model_fovx <number>\nqboolean ItemParse_model_fovx( itemDef_t *item, int handle ) {\n\tmodelDef_t *modelPtr;\n\tItem_ValidateTypeData(item);\n\tmodelPtr = (modelDef_t*)item->typeData;\n\n\tif (!PC_Float_Parse(handle, &modelPtr->fov_x)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n// model_fovy <number>\nqboolean ItemParse_model_fovy( itemDef_t *item, int handle ) {\n\tmodelDef_t *modelPtr;\n\tItem_ValidateTypeData(item);\n\tmodelPtr = (modelDef_t*)item->typeData;\n\n\tif (!PC_Float_Parse(handle, &modelPtr->fov_y)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n// model_rotation <integer>\nqboolean ItemParse_model_rotation( itemDef_t *item, int handle ) {\n\tmodelDef_t *modelPtr;\n\tItem_ValidateTypeData(item);\n\tmodelPtr = (modelDef_t*)item->typeData;\n\n\tif (!PC_Int_Parse(handle, &modelPtr->rotationSpeed)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n// model_angle <integer>\nqboolean ItemParse_model_angle( itemDef_t *item, int handle ) {\n\tmodelDef_t *modelPtr;\n\tItem_ValidateTypeData(item);\n\tmodelPtr = (modelDef_t*)item->typeData;\n\n\tif (!PC_Int_Parse(handle, &modelPtr->angle)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n// rect <rectangle>\nqboolean ItemParse_rect( itemDef_t *item, int handle ) {\n\tif (!PC_Rect_Parse(handle, &item->window.rectClient)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n// style <integer>\nqboolean ItemParse_style( itemDef_t *item, int handle ) {\n\tif (!PC_Int_Parse(handle, &item->window.style)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n// decoration\nqboolean ItemParse_decoration( itemDef_t *item, int handle ) {\n\titem->window.flags |= WINDOW_DECORATION;\n\treturn qtrue;\n}\n\n// notselectable\nqboolean ItemParse_notselectable( itemDef_t *item, int handle ) {\n\tlistBoxDef_t *listPtr;\n\tItem_ValidateTypeData(item);\n\tlistPtr = (listBoxDef_t*)item->typeData;\n\tif (item->type == ITEM_TYPE_LISTBOX && listPtr) {\n\t\tlistPtr->notselectable = qtrue;\n\t}\n\treturn qtrue;\n}\n\n// manually wrapped\nqboolean ItemParse_wrapped( itemDef_t *item, int handle ) {\n\titem->window.flags |= WINDOW_WRAPPED;\n\treturn qtrue;\n}\n\n// auto wrapped\nqboolean ItemParse_autowrapped( itemDef_t *item, int handle ) {\n\titem->window.flags |= WINDOW_AUTOWRAPPED;\n\treturn qtrue;\n}\n\n\n// horizontalscroll\nqboolean ItemParse_horizontalscroll( itemDef_t *item, int handle ) {\n\titem->window.flags |= WINDOW_HORIZONTAL;\n\treturn qtrue;\n}\n\n// type <integer>\nqboolean ItemParse_type( itemDef_t *item, int handle ) {\n\tif (!PC_Int_Parse(handle, &item->type)) {\n\t\treturn qfalse;\n\t}\n\tItem_ValidateTypeData(item);\n\treturn qtrue;\n}\n\n// elementwidth, used for listbox image elements\n// uses textalignx for storage\nqboolean ItemParse_elementwidth( itemDef_t *item, int handle ) {\n\tlistBoxDef_t *listPtr;\n\n\tItem_ValidateTypeData(item);\n\tlistPtr = (listBoxDef_t*)item->typeData;\n\tif (!PC_Float_Parse(handle, &listPtr->elementWidth)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n// elementheight, used for listbox image elements\n// uses textaligny for storage\nqboolean ItemParse_elementheight( itemDef_t *item, int handle ) {\n\tlistBoxDef_t *listPtr;\n\n\tItem_ValidateTypeData(item);\n\tlistPtr = (listBoxDef_t*)item->typeData;\n\tif (!PC_Float_Parse(handle, &listPtr->elementHeight)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n// feeder <float>\nqboolean ItemParse_feeder( itemDef_t *item, int handle ) {\n\tif (!PC_Float_Parse(handle, &item->special)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n// elementtype, used to specify what type of elements a listbox contains\n// uses textstyle for storage\nqboolean ItemParse_elementtype( itemDef_t *item, int handle ) {\n\tlistBoxDef_t *listPtr;\n\n\tItem_ValidateTypeData(item);\n\tif (!item->typeData)\n\t\treturn qfalse;\n\tlistPtr = (listBoxDef_t*)item->typeData;\n\tif (!PC_Int_Parse(handle, &listPtr->elementStyle)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n// columns sets a number of columns and an x pos and width per.. \nqboolean ItemParse_columns( itemDef_t *item, int handle ) {\n\tint num, i;\n\tlistBoxDef_t *listPtr;\n\n\tItem_ValidateTypeData(item);\n\tif (!item->typeData)\n\t\treturn qfalse;\n\tlistPtr = (listBoxDef_t*)item->typeData;\n\tif (PC_Int_Parse(handle, &num)) {\n\t\tif (num > MAX_LB_COLUMNS) {\n\t\t\tnum = MAX_LB_COLUMNS;\n\t\t}\n\t\tlistPtr->numColumns = num;\n\t\tfor (i = 0; i < num; i++) {\n\t\t\tint pos, width, maxChars;\n\n\t\t\tif (PC_Int_Parse(handle, &pos) && PC_Int_Parse(handle, &width) && PC_Int_Parse(handle, &maxChars)) {\n\t\t\t\tlistPtr->columnInfo[i].pos = pos;\n\t\t\t\tlistPtr->columnInfo[i].width = width;\n\t\t\t\tlistPtr->columnInfo[i].maxChars = maxChars;\n\t\t\t} else {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t}\n\t} else {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_border( itemDef_t *item, int handle ) {\n\tif (!PC_Int_Parse(handle, &item->window.border)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_bordersize( itemDef_t *item, int handle ) {\n\tif (!PC_Float_Parse(handle, &item->window.borderSize)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_visible( itemDef_t *item, int handle ) {\n\tint i;\n\n\tif (!PC_Int_Parse(handle, &i)) {\n\t\treturn qfalse;\n\t}\n\tif (i) {\n\t\titem->window.flags |= WINDOW_VISIBLE;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_ownerdraw( itemDef_t *item, int handle ) {\n\tif (!PC_Int_Parse(handle, &item->window.ownerDraw)) {\n\t\treturn qfalse;\n\t}\n\titem->type = ITEM_TYPE_OWNERDRAW;\n\treturn qtrue;\n}\n\nqboolean ItemParse_align( itemDef_t *item, int handle ) {\n\tif (!PC_Int_Parse(handle, &item->alignment)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_textalign( itemDef_t *item, int handle ) {\n\tif (!PC_Int_Parse(handle, &item->textalignment)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_textalignx( itemDef_t *item, int handle ) {\n\tif (!PC_Float_Parse(handle, &item->textalignx)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_textaligny( itemDef_t *item, int handle ) {\n\tif (!PC_Float_Parse(handle, &item->textaligny)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_textscale( itemDef_t *item, int handle ) {\n\tif (!PC_Float_Parse(handle, &item->textscale)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_textstyle( itemDef_t *item, int handle ) {\n\tif (!PC_Int_Parse(handle, &item->textStyle)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_backcolor( itemDef_t *item, int handle ) {\n\tint i;\n\tfloat f;\n\n\tfor (i = 0; i < 4; i++) {\n\t\tif (!PC_Float_Parse(handle, &f)) {\n\t\t\treturn qfalse;\n\t\t}\n\t\titem->window.backColor[i]  = f;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_forecolor( itemDef_t *item, int handle ) {\n\tint i;\n\tfloat f;\n\n\tfor (i = 0; i < 4; i++) {\n\t\tif (!PC_Float_Parse(handle, &f)) {\n\t\t\treturn qfalse;\n\t\t}\n\t\titem->window.foreColor[i]  = f;\n\t\titem->window.flags |= WINDOW_FORECOLORSET;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_bordercolor( itemDef_t *item, int handle ) {\n\tint i;\n\tfloat f;\n\n\tfor (i = 0; i < 4; i++) {\n\t\tif (!PC_Float_Parse(handle, &f)) {\n\t\t\treturn qfalse;\n\t\t}\n\t\titem->window.borderColor[i]  = f;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_outlinecolor( itemDef_t *item, int handle ) {\n\tif (!PC_Color_Parse(handle, &item->window.outlineColor)){\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_background( itemDef_t *item, int handle ) {\n\tconst char *temp;\n\n\tif (!PC_String_Parse(handle, &temp)) {\n\t\treturn qfalse;\n\t}\n\titem->window.background = DC->registerShaderNoMip(temp);\n\treturn qtrue;\n}\n\nqboolean ItemParse_cinematic( itemDef_t *item, int handle ) {\n\tif (!PC_String_Parse(handle, &item->window.cinematicName)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_doubleClick( itemDef_t *item, int handle ) {\n\tlistBoxDef_t *listPtr;\n\n\tItem_ValidateTypeData(item);\n\tif (!item->typeData) {\n\t\treturn qfalse;\n\t}\n\n\tlistPtr = (listBoxDef_t*)item->typeData;\n\n\tif (!PC_Script_Parse(handle, &listPtr->doubleClick)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_onFocus( itemDef_t *item, int handle ) {\n\tif (!PC_Script_Parse(handle, &item->onFocus)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_leaveFocus( itemDef_t *item, int handle ) {\n\tif (!PC_Script_Parse(handle, &item->leaveFocus)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_mouseEnter( itemDef_t *item, int handle ) {\n\tif (!PC_Script_Parse(handle, &item->mouseEnter)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_mouseExit( itemDef_t *item, int handle ) {\n\tif (!PC_Script_Parse(handle, &item->mouseExit)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_mouseEnterText( itemDef_t *item, int handle ) {\n\tif (!PC_Script_Parse(handle, &item->mouseEnterText)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_mouseExitText( itemDef_t *item, int handle ) {\n\tif (!PC_Script_Parse(handle, &item->mouseExitText)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_action( itemDef_t *item, int handle ) {\n\tif (!PC_Script_Parse(handle, &item->action)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_special( itemDef_t *item, int handle ) {\n\tif (!PC_Float_Parse(handle, &item->special)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_cvarTest( itemDef_t *item, int handle ) {\n\tif (!PC_String_Parse(handle, &item->cvarTest)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_cvar( itemDef_t *item, int handle ) {\n\teditFieldDef_t *editPtr;\n\n\tItem_ValidateTypeData(item);\n\tif (!PC_String_Parse(handle, &item->cvar)) {\n\t\treturn qfalse;\n\t}\n\tif (item->typeData) {\n\t\teditPtr = (editFieldDef_t*)item->typeData;\n\t\teditPtr->minVal = -1;\n\t\teditPtr->maxVal = -1;\n\t\teditPtr->defVal = -1;\n\t}\n\treturn qtrue;\n}\n\nqboolean ItemParse_maxChars( itemDef_t *item, int handle ) {\n\teditFieldDef_t *editPtr;\n\tint maxChars;\n\n\tItem_ValidateTypeData(item);\n\tif (!item->typeData)\n\t\treturn qfalse;\n\n\tif (!PC_Int_Parse(handle, &maxChars)) {\n\t\treturn qfalse;\n\t}\n\teditPtr = (editFieldDef_t*)item->typeData;\n\teditPtr->maxChars = maxChars;\n\treturn qtrue;\n}\n\nqboolean ItemParse_maxPaintChars( itemDef_t *item, int handle ) {\n\teditFieldDef_t *editPtr;\n\tint maxChars;\n\n\tItem_ValidateTypeData(item);\n\tif (!item->typeData)\n\t\treturn qfalse;\n\n\tif (!PC_Int_Parse(handle, &maxChars)) {\n\t\treturn qfalse;\n\t}\n\teditPtr = (editFieldDef_t*)item->typeData;\n\teditPtr->maxPaintChars = maxChars;\n\treturn qtrue;\n}\n\n\n\nqboolean ItemParse_cvarFloat( itemDef_t *item, int handle ) {\n\teditFieldDef_t *editPtr;\n\n\tItem_ValidateTypeData(item);\n\tif (!item->typeData)\n\t\treturn qfalse;\n\teditPtr = (editFieldDef_t*)item->typeData;\n\tif (PC_String_Parse(handle, &item->cvar) &&\n\t\tPC_Float_Parse(handle, &editPtr->defVal) &&\n\t\tPC_Float_Parse(handle, &editPtr->minVal) &&\n\t\tPC_Float_Parse(handle, &editPtr->maxVal)) {\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\nqboolean ItemParse_cvarStrList( itemDef_t *item, int handle ) {\n\tpc_token_t token;\n\tmultiDef_t *multiPtr;\n\tint pass;\n\t\n\tItem_ValidateTypeData(item);\n\tif (!item->typeData)\n\t\treturn qfalse;\n\tmultiPtr = (multiDef_t*)item->typeData;\n\tmultiPtr->count = 0;\n\tmultiPtr->strDef = qtrue;\n\n\tif (!trap_PC_ReadToken(handle, &token))\n\t\treturn qfalse;\n\tif (*token.string != '{') {\n\t\treturn qfalse;\n\t}\n\n\tpass = 0;\n\twhile ( 1 ) {\n\t\tif (!trap_PC_ReadToken(handle, &token)) {\n\t\t\tPC_SourceError(handle, \"end of file inside menu item\\n\");\n\t\t\treturn qfalse;\n\t\t}\n\n\t\tif (*token.string == '}') {\n\t\t\treturn qtrue;\n\t\t}\n\n\t\tif (*token.string == ',' || *token.string == ';') {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (pass == 0) {\n\t\t\tmultiPtr->cvarList[multiPtr->count] = String_Alloc(token.string);\n\t\t\tpass = 1;\n\t\t} else {\n\t\t\tmultiPtr->cvarStr[multiPtr->count] = String_Alloc(token.string);\n\t\t\tpass = 0;\n\t\t\tmultiPtr->count++;\n\t\t\tif (multiPtr->count >= MAX_MULTI_CVARS) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t}\n\n\t}\n\treturn qfalse; \t// bk001205 - LCC missing return value\n}\n\nqboolean ItemParse_cvarFloatList( itemDef_t *item, int handle ) {\n\tpc_token_t token;\n\tmultiDef_t *multiPtr;\n\t\n\tItem_ValidateTypeData(item);\n\tif (!item->typeData)\n\t\treturn qfalse;\n\tmultiPtr = (multiDef_t*)item->typeData;\n\tmultiPtr->count = 0;\n\tmultiPtr->strDef = qfalse;\n\n\tif (!trap_PC_ReadToken(handle, &token))\n\t\treturn qfalse;\n\tif (*token.string != '{') {\n\t\treturn qfalse;\n\t}\n\n\twhile ( 1 ) {\n\t\tif (!trap_PC_ReadToken(handle, &token)) {\n\t\t\tPC_SourceError(handle, \"end of file inside menu item\\n\");\n\t\t\treturn qfalse;\n\t\t}\n\n\t\tif (*token.string == '}') {\n\t\t\treturn qtrue;\n\t\t}\n\n\t\tif (*token.string == ',' || *token.string == ';') {\n\t\t\tcontinue;\n\t\t}\n\n\t\tmultiPtr->cvarList[multiPtr->count] = String_Alloc(token.string);\n\t\tif (!PC_Float_Parse(handle, &multiPtr->cvarValue[multiPtr->count])) {\n\t\t\treturn qfalse;\n\t\t}\n\n\t\tmultiPtr->count++;\n\t\tif (multiPtr->count >= MAX_MULTI_CVARS) {\n\t\t\treturn qfalse;\n\t\t}\n\n\t}\n\treturn qfalse; \t// bk001205 - LCC missing return value\n}\n\n\n\nqboolean ItemParse_addColorRange( itemDef_t *item, int handle ) {\n\tcolorRangeDef_t color;\n\n\tif (PC_Float_Parse(handle, &color.low) &&\n\t\tPC_Float_Parse(handle, &color.high) &&\n\t\tPC_Color_Parse(handle, &color.color) ) {\n\t\tif (item->numColors < MAX_COLOR_RANGES) {\n\t\t\tmemcpy(&item->colorRanges[item->numColors], &color, sizeof(color));\n\t\t\titem->numColors++;\n\t\t}\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\nqboolean ItemParse_ownerdrawFlag( itemDef_t *item, int handle ) {\n\tint i;\n\tif (!PC_Int_Parse(handle, &i)) {\n\t\treturn qfalse;\n\t}\n\titem->window.ownerDrawFlags |= i;\n\treturn qtrue;\n}\n\nqboolean ItemParse_enableCvar( itemDef_t *item, int handle ) {\n\tif (PC_Script_Parse(handle, &item->enableCvar)) {\n\t\titem->cvarFlags = CVAR_ENABLE;\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\nqboolean ItemParse_disableCvar( itemDef_t *item, int handle ) {\n\tif (PC_Script_Parse(handle, &item->enableCvar)) {\n\t\titem->cvarFlags = CVAR_DISABLE;\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\nqboolean ItemParse_showCvar( itemDef_t *item, int handle ) {\n\tif (PC_Script_Parse(handle, &item->enableCvar)) {\n\t\titem->cvarFlags = CVAR_SHOW;\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\nqboolean ItemParse_hideCvar( itemDef_t *item, int handle ) {\n\tif (PC_Script_Parse(handle, &item->enableCvar)) {\n\t\titem->cvarFlags = CVAR_HIDE;\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n\nkeywordHash_t itemParseKeywords[] = {\n\t{\"name\", ItemParse_name, NULL},\n\t{\"text\", ItemParse_text, NULL},\n\t{\"group\", ItemParse_group, NULL},\n\t{\"asset_model\", ItemParse_asset_model, NULL},\n\t{\"asset_shader\", ItemParse_asset_shader, NULL},\n\t{\"model_origin\", ItemParse_model_origin, NULL},\n\t{\"model_fovx\", ItemParse_model_fovx, NULL},\n\t{\"model_fovy\", ItemParse_model_fovy, NULL},\n\t{\"model_rotation\", ItemParse_model_rotation, NULL},\n\t{\"model_angle\", ItemParse_model_angle, NULL},\n\t{\"rect\", ItemParse_rect, NULL},\n\t{\"style\", ItemParse_style, NULL},\n\t{\"decoration\", ItemParse_decoration, NULL},\n\t{\"notselectable\", ItemParse_notselectable, NULL},\n\t{\"wrapped\", ItemParse_wrapped, NULL},\n\t{\"autowrapped\", ItemParse_autowrapped, NULL},\n\t{\"horizontalscroll\", ItemParse_horizontalscroll, NULL},\n\t{\"type\", ItemParse_type, NULL},\n\t{\"elementwidth\", ItemParse_elementwidth, NULL},\n\t{\"elementheight\", ItemParse_elementheight, NULL},\n\t{\"feeder\", ItemParse_feeder, NULL},\n\t{\"elementtype\", ItemParse_elementtype, NULL},\n\t{\"columns\", ItemParse_columns, NULL},\n\t{\"border\", ItemParse_border, NULL},\n\t{\"bordersize\", ItemParse_bordersize, NULL},\n\t{\"visible\", ItemParse_visible, NULL},\n\t{\"ownerdraw\", ItemParse_ownerdraw, NULL},\n\t{\"align\", ItemParse_align, NULL},\n\t{\"textalign\", ItemParse_textalign, NULL},\n\t{\"textalignx\", ItemParse_textalignx, NULL},\n\t{\"textaligny\", ItemParse_textaligny, NULL},\n\t{\"textscale\", ItemParse_textscale, NULL},\n\t{\"textstyle\", ItemParse_textstyle, NULL},\n\t{\"backcolor\", ItemParse_backcolor, NULL},\n\t{\"forecolor\", ItemParse_forecolor, NULL},\n\t{\"bordercolor\", ItemParse_bordercolor, NULL},\n\t{\"outlinecolor\", ItemParse_outlinecolor, NULL},\n\t{\"background\", ItemParse_background, NULL},\n\t{\"onFocus\", ItemParse_onFocus, NULL},\n\t{\"leaveFocus\", ItemParse_leaveFocus, NULL},\n\t{\"mouseEnter\", ItemParse_mouseEnter, NULL},\n\t{\"mouseExit\", ItemParse_mouseExit, NULL},\n\t{\"mouseEnterText\", ItemParse_mouseEnterText, NULL},\n\t{\"mouseExitText\", ItemParse_mouseExitText, NULL},\n\t{\"action\", ItemParse_action, NULL},\n\t{\"special\", ItemParse_special, NULL},\n\t{\"cvar\", ItemParse_cvar, NULL},\n\t{\"maxChars\", ItemParse_maxChars, NULL},\n\t{\"maxPaintChars\", ItemParse_maxPaintChars, NULL},\n\t{\"focusSound\", ItemParse_focusSound, NULL},\n\t{\"cvarFloat\", ItemParse_cvarFloat, NULL},\n\t{\"cvarStrList\", ItemParse_cvarStrList, NULL},\n\t{\"cvarFloatList\", ItemParse_cvarFloatList, NULL},\n\t{\"addColorRange\", ItemParse_addColorRange, NULL},\n\t{\"ownerdrawFlag\", ItemParse_ownerdrawFlag, NULL},\n\t{\"enableCvar\", ItemParse_enableCvar, NULL},\n\t{\"cvarTest\", ItemParse_cvarTest, NULL},\n\t{\"disableCvar\", ItemParse_disableCvar, NULL},\n\t{\"showCvar\", ItemParse_showCvar, NULL},\n\t{\"hideCvar\", ItemParse_hideCvar, NULL},\n\t{\"cinematic\", ItemParse_cinematic, NULL},\n\t{\"doubleclick\", ItemParse_doubleClick, NULL},\n\t{NULL, NULL, NULL}\n};\n\nkeywordHash_t *itemParseKeywordHash[KEYWORDHASH_SIZE];\n\n/*\n===============\nItem_SetupKeywordHash\n===============\n*/\nvoid Item_SetupKeywordHash(void) {\n\tint i;\n\n\tmemset(itemParseKeywordHash, 0, sizeof(itemParseKeywordHash));\n\tfor (i = 0; itemParseKeywords[i].keyword; i++) {\n\t\tKeywordHash_Add(itemParseKeywordHash, &itemParseKeywords[i]);\n\t}\n}\n\n/*\n===============\nItem_Parse\n===============\n*/\nqboolean Item_Parse(int handle, itemDef_t *item) {\n\tpc_token_t token;\n\tkeywordHash_t *key;\n\n\n\tif (!trap_PC_ReadToken(handle, &token))\n\t\treturn qfalse;\n\tif (*token.string != '{') {\n\t\treturn qfalse;\n\t}\n\twhile ( 1 ) {\n\t\tif (!trap_PC_ReadToken(handle, &token)) {\n\t\t\tPC_SourceError(handle, \"end of file inside menu item\\n\");\n\t\t\treturn qfalse;\n\t\t}\n\n\t\tif (*token.string == '}') {\n\t\t\treturn qtrue;\n\t\t}\n\n\t\tkey = KeywordHash_Find(itemParseKeywordHash, token.string);\n\t\tif (!key) {\n\t\t\tPC_SourceError(handle, \"unknown menu item keyword %s\", token.string);\n\t\t\tcontinue;\n\t\t}\n\t\tif ( !key->func(item, handle) ) {\n\t\t\tPC_SourceError(handle, \"couldn't parse menu item keyword %s\", token.string);\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\treturn qfalse; \t// bk001205 - LCC missing return value\n}\n\n\n// Item_InitControls\n// init's special control types\nvoid Item_InitControls(itemDef_t *item) {\n\tif (item == NULL) {\n\t\treturn;\n\t}\n\tif (item->type == ITEM_TYPE_LISTBOX) {\n\t\tlistBoxDef_t *listPtr = (listBoxDef_t*)item->typeData;\n\t\titem->cursorPos = 0;\n\t\tif (listPtr) {\n\t\t\tlistPtr->cursorPos = 0;\n\t\t\tlistPtr->startPos = 0;\n\t\t\tlistPtr->endPos = 0;\n\t\t\tlistPtr->cursorPos = 0;\n\t\t}\n\t}\n}\n\n/*\n===============\nMenu Keyword Parse functions\n===============\n*/\n\nqboolean MenuParse_font( itemDef_t *item, int handle ) {\n\tmenuDef_t *menu = (menuDef_t*)item;\n\tif (!PC_String_Parse(handle, &menu->font)) {\n\t\treturn qfalse;\n\t}\n\tif (!DC->Assets.fontRegistered) {\n\t\tDC->registerFont(menu->font, 48, &DC->Assets.textFont);\n\t\tDC->Assets.fontRegistered = qtrue;\n\t}\n\treturn qtrue;\n}\n\nqboolean MenuParse_name( itemDef_t *item, int handle ) {\n\tmenuDef_t *menu = (menuDef_t*)item;\n\tif (!PC_String_Parse(handle, &menu->window.name)) {\n\t\treturn qfalse;\n\t}\n\tif (Q_stricmp(menu->window.name, \"main\") == 0) {\n\t\t// default main as having focus\n\t\t//menu->window.flags |= WINDOW_HASFOCUS;\n\t}\n\treturn qtrue;\n}\n\nqboolean MenuParse_fullscreen( itemDef_t *item, int handle ) {\n\tmenuDef_t *menu = (menuDef_t*)item;\n\tif (!PC_Int_Parse(handle, (int*) &menu->fullScreen)) { // bk001206 - cast qboolean\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean MenuParse_rect( itemDef_t *item, int handle ) {\n\tmenuDef_t *menu = (menuDef_t*)item;\n\tif (!PC_Rect_Parse(handle, &menu->window.rect)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean MenuParse_style( itemDef_t *item, int handle ) {\n\tmenuDef_t *menu = (menuDef_t*)item;\n\tif (!PC_Int_Parse(handle, &menu->window.style)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean MenuParse_visible( itemDef_t *item, int handle ) {\n\tint i;\n\tmenuDef_t *menu = (menuDef_t*)item;\n\n\tif (!PC_Int_Parse(handle, &i)) {\n\t\treturn qfalse;\n\t}\n\tif (i) {\n\t\tmenu->window.flags |= WINDOW_VISIBLE;\n\t}\n\treturn qtrue;\n}\n\nqboolean MenuParse_onOpen( itemDef_t *item, int handle ) {\n\tmenuDef_t *menu = (menuDef_t*)item;\n\tif (!PC_Script_Parse(handle, &menu->onOpen)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean MenuParse_onClose( itemDef_t *item, int handle ) {\n\tmenuDef_t *menu = (menuDef_t*)item;\n\tif (!PC_Script_Parse(handle, &menu->onClose)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean MenuParse_onESC( itemDef_t *item, int handle ) {\n\tmenuDef_t *menu = (menuDef_t*)item;\n\tif (!PC_Script_Parse(handle, &menu->onESC)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n\n\nqboolean MenuParse_border( itemDef_t *item, int handle ) {\n\tmenuDef_t *menu = (menuDef_t*)item;\n\tif (!PC_Int_Parse(handle, &menu->window.border)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean MenuParse_borderSize( itemDef_t *item, int handle ) {\n\tmenuDef_t *menu = (menuDef_t*)item;\n\tif (!PC_Float_Parse(handle, &menu->window.borderSize)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean MenuParse_backcolor( itemDef_t *item, int handle ) {\n\tint i;\n\tfloat f;\n\tmenuDef_t *menu = (menuDef_t*)item;\n\n\tfor (i = 0; i < 4; i++) {\n\t\tif (!PC_Float_Parse(handle, &f)) {\n\t\t\treturn qfalse;\n\t\t}\n\t\tmenu->window.backColor[i]  = f;\n\t}\n\treturn qtrue;\n}\n\nqboolean MenuParse_forecolor( itemDef_t *item, int handle ) {\n\tint i;\n\tfloat f;\n\tmenuDef_t *menu = (menuDef_t*)item;\n\n\tfor (i = 0; i < 4; i++) {\n\t\tif (!PC_Float_Parse(handle, &f)) {\n\t\t\treturn qfalse;\n\t\t}\n\t\tmenu->window.foreColor[i]  = f;\n\t\tmenu->window.flags |= WINDOW_FORECOLORSET;\n\t}\n\treturn qtrue;\n}\n\nqboolean MenuParse_bordercolor( itemDef_t *item, int handle ) {\n\tint i;\n\tfloat f;\n\tmenuDef_t *menu = (menuDef_t*)item;\n\n\tfor (i = 0; i < 4; i++) {\n\t\tif (!PC_Float_Parse(handle, &f)) {\n\t\t\treturn qfalse;\n\t\t}\n\t\tmenu->window.borderColor[i]  = f;\n\t}\n\treturn qtrue;\n}\n\nqboolean MenuParse_focuscolor( itemDef_t *item, int handle ) {\n\tint i;\n\tfloat f;\n\tmenuDef_t *menu = (menuDef_t*)item;\n\n\tfor (i = 0; i < 4; i++) {\n\t\tif (!PC_Float_Parse(handle, &f)) {\n\t\t\treturn qfalse;\n\t\t}\n\t\tmenu->focusColor[i]  = f;\n\t}\n\treturn qtrue;\n}\n\nqboolean MenuParse_disablecolor( itemDef_t *item, int handle ) {\n\tint i;\n\tfloat f;\n\tmenuDef_t *menu = (menuDef_t*)item;\n\tfor (i = 0; i < 4; i++) {\n\t\tif (!PC_Float_Parse(handle, &f)) {\n\t\t\treturn qfalse;\n\t\t}\n\t\tmenu->disableColor[i]  = f;\n\t}\n\treturn qtrue;\n}\n\n\nqboolean MenuParse_outlinecolor( itemDef_t *item, int handle ) {\n\tmenuDef_t *menu = (menuDef_t*)item;\n\tif (!PC_Color_Parse(handle, &menu->window.outlineColor)){\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean MenuParse_background( itemDef_t *item, int handle ) {\n\tconst char *buff;\n\tmenuDef_t *menu = (menuDef_t*)item;\n\n\tif (!PC_String_Parse(handle, &buff)) {\n\t\treturn qfalse;\n\t}\n\tmenu->window.background = DC->registerShaderNoMip(buff);\n\treturn qtrue;\n}\n\nqboolean MenuParse_cinematic( itemDef_t *item, int handle ) {\n\tmenuDef_t *menu = (menuDef_t*)item;\n\n\tif (!PC_String_Parse(handle, &menu->window.cinematicName)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean MenuParse_ownerdrawFlag( itemDef_t *item, int handle ) {\n\tint i;\n\tmenuDef_t *menu = (menuDef_t*)item;\n\n\tif (!PC_Int_Parse(handle, &i)) {\n\t\treturn qfalse;\n\t}\n\tmenu->window.ownerDrawFlags |= i;\n\treturn qtrue;\n}\n\nqboolean MenuParse_ownerdraw( itemDef_t *item, int handle ) {\n\tmenuDef_t *menu = (menuDef_t*)item;\n\n\tif (!PC_Int_Parse(handle, &menu->window.ownerDraw)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n\n// decoration\nqboolean MenuParse_popup( itemDef_t *item, int handle ) {\n\tmenuDef_t *menu = (menuDef_t*)item;\n\tmenu->window.flags |= WINDOW_POPUP;\n\treturn qtrue;\n}\n\n\nqboolean MenuParse_outOfBounds( itemDef_t *item, int handle ) {\n\tmenuDef_t *menu = (menuDef_t*)item;\n\n\tmenu->window.flags |= WINDOW_OOB_CLICK;\n\treturn qtrue;\n}\n\nqboolean MenuParse_soundLoop( itemDef_t *item, int handle ) {\n\tmenuDef_t *menu = (menuDef_t*)item;\n\n\tif (!PC_String_Parse(handle, &menu->soundName)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean MenuParse_fadeClamp( itemDef_t *item, int handle ) {\n\tmenuDef_t *menu = (menuDef_t*)item;\n\n\tif (!PC_Float_Parse(handle, &menu->fadeClamp)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\nqboolean MenuParse_fadeAmount( itemDef_t *item, int handle ) {\n\tmenuDef_t *menu = (menuDef_t*)item;\n\n\tif (!PC_Float_Parse(handle, &menu->fadeAmount)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n\nqboolean MenuParse_fadeCycle( itemDef_t *item, int handle ) {\n\tmenuDef_t *menu = (menuDef_t*)item;\n\n\tif (!PC_Int_Parse(handle, &menu->fadeCycle)) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n\nqboolean MenuParse_itemDef( itemDef_t *item, int handle ) {\n\tmenuDef_t *menu = (menuDef_t*)item;\n\tif (menu->itemCount < MAX_MENUITEMS) {\n\t\tmenu->items[menu->itemCount] = UI_Alloc(sizeof(itemDef_t));\n\t\tItem_Init(menu->items[menu->itemCount]);\n\t\tif (!Item_Parse(handle, menu->items[menu->itemCount])) {\n\t\t\treturn qfalse;\n\t\t}\n\t\tItem_InitControls(menu->items[menu->itemCount]);\n\t\tmenu->items[menu->itemCount++]->parent = menu;\n\t}\n\treturn qtrue;\n}\n\nkeywordHash_t menuParseKeywords[] = {\n\t{\"font\", MenuParse_font, NULL},\n\t{\"name\", MenuParse_name, NULL},\n\t{\"fullscreen\", MenuParse_fullscreen, NULL},\n\t{\"rect\", MenuParse_rect, NULL},\n\t{\"style\", MenuParse_style, NULL},\n\t{\"visible\", MenuParse_visible, NULL},\n\t{\"onOpen\", MenuParse_onOpen, NULL},\n\t{\"onClose\", MenuParse_onClose, NULL},\n\t{\"onESC\", MenuParse_onESC, NULL},\n\t{\"border\", MenuParse_border, NULL},\n\t{\"borderSize\", MenuParse_borderSize, NULL},\n\t{\"backcolor\", MenuParse_backcolor, NULL},\n\t{\"forecolor\", MenuParse_forecolor, NULL},\n\t{\"bordercolor\", MenuParse_bordercolor, NULL},\n\t{\"focuscolor\", MenuParse_focuscolor, NULL},\n\t{\"disablecolor\", MenuParse_disablecolor, NULL},\n\t{\"outlinecolor\", MenuParse_outlinecolor, NULL},\n\t{\"background\", MenuParse_background, NULL},\n\t{\"ownerdraw\", MenuParse_ownerdraw, NULL},\n\t{\"ownerdrawFlag\", MenuParse_ownerdrawFlag, NULL},\n\t{\"outOfBoundsClick\", MenuParse_outOfBounds, NULL},\n\t{\"soundLoop\", MenuParse_soundLoop, NULL},\n\t{\"itemDef\", MenuParse_itemDef, NULL},\n\t{\"cinematic\", MenuParse_cinematic, NULL},\n\t{\"popup\", MenuParse_popup, NULL},\n\t{\"fadeClamp\", MenuParse_fadeClamp, NULL},\n\t{\"fadeCycle\", MenuParse_fadeCycle, NULL},\n\t{\"fadeAmount\", MenuParse_fadeAmount, NULL},\n\t{NULL, NULL, NULL}\n};\n\nkeywordHash_t *menuParseKeywordHash[KEYWORDHASH_SIZE];\n\n/*\n===============\nMenu_SetupKeywordHash\n===============\n*/\nvoid Menu_SetupKeywordHash(void) {\n\tint i;\n\n\tmemset(menuParseKeywordHash, 0, sizeof(menuParseKeywordHash));\n\tfor (i = 0; menuParseKeywords[i].keyword; i++) {\n\t\tKeywordHash_Add(menuParseKeywordHash, &menuParseKeywords[i]);\n\t}\n}\n\n/*\n===============\nMenu_Parse\n===============\n*/\nqboolean Menu_Parse(int handle, menuDef_t *menu) {\n\tpc_token_t token;\n\tkeywordHash_t *key;\n\n\tif (!trap_PC_ReadToken(handle, &token))\n\t\treturn qfalse;\n\tif (*token.string != '{') {\n\t\treturn qfalse;\n\t}\n    \n\twhile ( 1 ) {\n\n\t\tmemset(&token, 0, sizeof(pc_token_t));\n\t\tif (!trap_PC_ReadToken(handle, &token)) {\n\t\t\tPC_SourceError(handle, \"end of file inside menu\\n\");\n\t\t\treturn qfalse;\n\t\t}\n\n\t\tif (*token.string == '}') {\n\t\t\treturn qtrue;\n\t\t}\n\n\t\tkey = KeywordHash_Find(menuParseKeywordHash, token.string);\n\t\tif (!key) {\n\t\t\tPC_SourceError(handle, \"unknown menu keyword %s\", token.string);\n\t\t\tcontinue;\n\t\t}\n\t\tif ( !key->func((itemDef_t*)menu, handle) ) {\n\t\t\tPC_SourceError(handle, \"couldn't parse menu keyword %s\", token.string);\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\treturn qfalse; \t// bk001205 - LCC missing return value\n}\n\n/*\n===============\nMenu_New\n===============\n*/\nvoid Menu_New(int handle) {\n\tmenuDef_t *menu = &Menus[menuCount];\n\n\tif (menuCount < MAX_MENUS) {\n\t\tMenu_Init(menu);\n\t\tif (Menu_Parse(handle, menu)) {\n\t\t\tMenu_PostParse(menu);\n\t\t\tmenuCount++;\n\t\t}\n\t}\n}\n\nint Menu_Count() {\n\treturn menuCount;\n}\n\nvoid Menu_PaintAll() {\n\tint i;\n\tif (captureFunc) {\n\t\tcaptureFunc(captureData);\n\t}\n\n\tfor (i = 0; i < Menu_Count(); i++) {\n\t\tMenu_Paint(&Menus[i], qfalse);\n\t}\n\n\tif (debugMode) {\n\t\tvec4_t v = {1, 1, 1, 1};\n\t\tDC->drawText(5, 25, .5, v, va(\"fps: %f\", DC->FPS), 0, 0, 0);\n\t}\n}\n\nvoid Menu_Reset() {\n\tmenuCount = 0;\n}\n\ndisplayContextDef_t *Display_GetContext() {\n\treturn DC;\n}\n \n#ifndef MISSIONPACK // bk001206\nstatic float captureX;\nstatic float captureY;\n#endif\n\nvoid *Display_CaptureItem(int x, int y) {\n\tint i;\n\n\tfor (i = 0; i < menuCount; i++) {\n\t\t// turn off focus each item\n\t\t// menu->items[i].window.flags &= ~WINDOW_HASFOCUS;\n\t\tif (Rect_ContainsPoint(&Menus[i].window.rect, x, y)) {\n\t\t\treturn &Menus[i];\n\t\t}\n\t}\n\treturn NULL;\n}\n\n\n// FIXME: \nqboolean Display_MouseMove(void *p, int x, int y) {\n\tint i;\n\tmenuDef_t *menu = p;\n\n\tif (menu == NULL) {\n    menu = Menu_GetFocused();\n\t\tif (menu) {\n\t\t\tif (menu->window.flags & WINDOW_POPUP) {\n\t\t\t\tMenu_HandleMouseMove(menu, x, y);\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t}\n\t\tfor (i = 0; i < menuCount; i++) {\n\t\t\tMenu_HandleMouseMove(&Menus[i], x, y);\n\t\t}\n\t} else {\n\t\tmenu->window.rect.x += x;\n\t\tmenu->window.rect.y += y;\n\t\tMenu_UpdatePosition(menu);\n\t}\n \treturn qtrue;\n\n}\n\nint Display_CursorType(int x, int y) {\n\tint i;\n\tfor (i = 0; i < menuCount; i++) {\n\t\trectDef_t r2;\n\t\tr2.x = Menus[i].window.rect.x - 3;\n\t\tr2.y = Menus[i].window.rect.y - 3;\n\t\tr2.w = r2.h = 7;\n\t\tif (Rect_ContainsPoint(&r2, x, y)) {\n\t\t\treturn CURSOR_SIZER;\n\t\t}\n\t}\n\treturn CURSOR_ARROW;\n}\n\n\nvoid Display_HandleKey(int key, qboolean down, int x, int y) {\n\tmenuDef_t *menu = Display_CaptureItem(x, y);\n\tif (menu == NULL) {  \n\t\tmenu = Menu_GetFocused();\n\t}\n\tif (menu) {\n\t\tMenu_HandleKey(menu, key, down );\n\t}\n}\n\nstatic void Window_CacheContents(windowDef_t *window) {\n\tif (window) {\n\t\tif (window->cinematicName) {\n\t\t\tint cin = DC->playCinematic(window->cinematicName, 0, 0, 0, 0);\n\t\t\tDC->stopCinematic(cin);\n\t\t}\n\t}\n}\n\n\nstatic void Item_CacheContents(itemDef_t *item) {\n\tif (item) {\n\t\tWindow_CacheContents(&item->window);\n\t}\n\n}\n\nstatic void Menu_CacheContents(menuDef_t *menu) {\n\tif (menu) {\n\t\tint i;\n\t\tWindow_CacheContents(&menu->window);\n\t\tfor (i = 0; i < menu->itemCount; i++) {\n\t\t\tItem_CacheContents(menu->items[i]);\n\t\t}\n\n\t\tif (menu->soundName && *menu->soundName) {\n\t\t\tDC->registerSound(menu->soundName, qfalse);\n\t\t}\n\t}\n\n}\n\nvoid Display_CacheAll() {\n\tint i;\n\tfor (i = 0; i < menuCount; i++) {\n\t\tMenu_CacheContents(&Menus[i]);\n\t}\n}\n\n\nstatic qboolean Menu_OverActiveItem(menuDef_t *menu, float x, float y) {\n \tif (menu && menu->window.flags & (WINDOW_VISIBLE | WINDOW_FORCED)) {\n\t\tif (Rect_ContainsPoint(&menu->window.rect, x, y)) {\n\t\t\tint i;\n\t\t\tfor (i = 0; i < menu->itemCount; i++) {\n\t\t\t\t// turn off focus each item\n\t\t\t\t// menu->items[i].window.flags &= ~WINDOW_HASFOCUS;\n\n\t\t\t\tif (!(menu->items[i]->window.flags & (WINDOW_VISIBLE | WINDOW_FORCED))) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (menu->items[i]->window.flags & WINDOW_DECORATION) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (Rect_ContainsPoint(&menu->items[i]->window.rect, x, y)) {\n\t\t\t\t\titemDef_t *overItem = menu->items[i];\n\t\t\t\t\tif (overItem->type == ITEM_TYPE_TEXT && overItem->text) {\n\t\t\t\t\t\tif (Rect_ContainsPoint(Item_CorrectedTextRect(overItem), x, y)) {\n\t\t\t\t\t\t\treturn qtrue;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn qtrue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n"
  },
  {
    "path": "code/ui/ui_shared.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __UI_SHARED_H\n#define __UI_SHARED_H\n\n\n#include \"../game/q_shared.h\"\n#include \"../cgame/tr_types.h\"\n#include \"keycodes.h\"\n\n#include \"../../ui/menudef.h\"\n\n#define MAX_MENUNAME 32\n#define MAX_ITEMTEXT 64\n#define MAX_ITEMACTION 64\n#define MAX_MENUDEFFILE 4096\n#define MAX_MENUFILE 32768\n#define MAX_MENUS 64\n#define MAX_MENUITEMS 96\n#define MAX_COLOR_RANGES 10\n#define MAX_OPEN_MENUS 16\n\n#define WINDOW_MOUSEOVER\t\t\t0x00000001\t// mouse is over it, non exclusive\n#define WINDOW_HASFOCUS\t\t\t\t0x00000002\t// has cursor focus, exclusive\n#define WINDOW_VISIBLE\t\t\t\t0x00000004\t// is visible\n#define WINDOW_GREY\t\t\t\t\t\t0x00000008\t// is visible but grey ( non-active )\n#define WINDOW_DECORATION\t\t\t0x00000010\t// for decoration only, no mouse, keyboard, etc.. \n#define WINDOW_FADINGOUT\t\t\t0x00000020\t// fading out, non-active\n#define WINDOW_FADINGIN\t\t\t\t0x00000040\t// fading in\n#define WINDOW_MOUSEOVERTEXT\t0x00000080\t// mouse is over it, non exclusive\n#define WINDOW_INTRANSITION\t\t0x00000100\t// window is in transition\n#define WINDOW_FORECOLORSET\t\t0x00000200\t// forecolor was explicitly set ( used to color alpha images or not )\n#define WINDOW_HORIZONTAL\t\t\t0x00000400\t// for list boxes and sliders, vertical is default this is set of horizontal\n#define WINDOW_LB_LEFTARROW\t\t0x00000800\t// mouse is over left/up arrow\n#define WINDOW_LB_RIGHTARROW\t0x00001000\t// mouse is over right/down arrow\n#define WINDOW_LB_THUMB\t\t\t\t0x00002000\t// mouse is over thumb\n#define WINDOW_LB_PGUP\t\t\t\t0x00004000\t// mouse is over page up\n#define WINDOW_LB_PGDN\t\t\t\t0x00008000\t// mouse is over page down\n#define WINDOW_ORBITING\t\t\t\t0x00010000\t// item is in orbit\n#define WINDOW_OOB_CLICK\t\t\t0x00020000\t// close on out of bounds click\n#define WINDOW_WRAPPED\t\t\t\t0x00040000\t// manually wrap text\n#define WINDOW_AUTOWRAPPED\t\t\t0x00080000\t// auto wrap text\n#define WINDOW_FORCED\t\t\t\t\t0x00100000\t// forced open\n#define WINDOW_POPUP\t\t\t\t\t0x00200000\t// popup\n#define WINDOW_BACKCOLORSET\t\t0x00400000\t// backcolor was explicitly set \n#define WINDOW_TIMEDVISIBLE\t\t0x00800000\t// visibility timing ( NOT implemented )\n\n\n// CGAME cursor type bits\n#define CURSOR_NONE\t\t\t\t\t0x00000001\n#define CURSOR_ARROW\t\t\t\t0x00000002\n#define CURSOR_SIZER\t\t\t\t0x00000004\n\n#ifdef CGAME\n#define STRING_POOL_SIZE 128*1024\n#else\n#define STRING_POOL_SIZE 384*1024\n#endif\n#define MAX_STRING_HANDLES 4096\n\n#define MAX_SCRIPT_ARGS 12\n#define MAX_EDITFIELD 256\n\n#define ART_FX_BASE\t\t\t\"menu/art/fx_base\"\n#define ART_FX_BLUE\t\t\t\"menu/art/fx_blue\"\n#define ART_FX_CYAN\t\t\t\"menu/art/fx_cyan\"\n#define ART_FX_GREEN\t\t\"menu/art/fx_grn\"\n#define ART_FX_RED\t\t\t\"menu/art/fx_red\"\n#define ART_FX_TEAL\t\t\t\"menu/art/fx_teal\"\n#define ART_FX_WHITE\t\t\"menu/art/fx_white\"\n#define ART_FX_YELLOW\t\t\"menu/art/fx_yel\"\n\n#define ASSET_GRADIENTBAR \"ui/assets/gradientbar2.tga\"\n#define ASSET_SCROLLBAR             \"ui/assets/scrollbar.tga\"\n#define ASSET_SCROLLBAR_ARROWDOWN   \"ui/assets/scrollbar_arrow_dwn_a.tga\"\n#define ASSET_SCROLLBAR_ARROWUP     \"ui/assets/scrollbar_arrow_up_a.tga\"\n#define ASSET_SCROLLBAR_ARROWLEFT   \"ui/assets/scrollbar_arrow_left.tga\"\n#define ASSET_SCROLLBAR_ARROWRIGHT  \"ui/assets/scrollbar_arrow_right.tga\"\n#define ASSET_SCROLL_THUMB          \"ui/assets/scrollbar_thumb.tga\"\n#define ASSET_SLIDER_BAR\t\t\t\t\t\t\"ui/assets/slider2.tga\"\n#define ASSET_SLIDER_THUMB\t\t\t\t\t\"ui/assets/sliderbutt_1.tga\"\n#define SCROLLBAR_SIZE 16.0\n#define SLIDER_WIDTH 96.0\n#define SLIDER_HEIGHT 16.0\n#define SLIDER_THUMB_WIDTH 12.0\n#define SLIDER_THUMB_HEIGHT 20.0\n#define\tNUM_CROSSHAIRS\t\t\t10\n\ntypedef struct {\n  const char *command;\n  const char *args[MAX_SCRIPT_ARGS];\n} scriptDef_t;\n\n\ntypedef struct {\n  float x;    // horiz position\n  float y;    // vert position\n  float w;    // width\n  float h;    // height;\n} rectDef_t;\n\ntypedef rectDef_t Rectangle;\n\n// FIXME: do something to separate text vs window stuff\ntypedef struct {\n  Rectangle rect;                 // client coord rectangle\n  Rectangle rectClient;           // screen coord rectangle\n  const char *name;               //\n  const char *group;              // if it belongs to a group\n  const char *cinematicName;\t\t  // cinematic name\n  int cinematic;\t\t\t\t\t\t\t\t  // cinematic handle\n  int style;                      //\n  int border;                     //\n  int ownerDraw;\t\t\t\t\t\t\t\t\t// ownerDraw style\n\tint ownerDrawFlags;\t\t\t\t\t\t\t// show flags for ownerdraw items\n  float borderSize;               // \n  int flags;                      // visible, focus, mouseover, cursor\n  Rectangle rectEffects;          // for various effects\n  Rectangle rectEffects2;         // for various effects\n  int offsetTime;                 // time based value for various effects\n  int nextTime;                   // time next effect should cycle\n  vec4_t foreColor;               // text color\n  vec4_t backColor;               // border color\n  vec4_t borderColor;             // border color\n  vec4_t outlineColor;            // border color\n  qhandle_t background;           // background asset  \n} windowDef_t;\n\ntypedef windowDef_t Window;\n\ntypedef struct {\n\tvec4_t\tcolor;\n\tfloat\t\tlow;\n\tfloat\t\thigh;\n} colorRangeDef_t;\n\n// FIXME: combine flags into bitfields to save space\n// FIXME: consolidate all of the common stuff in one structure for menus and items\n// THINKABOUTME: is there any compelling reason not to have items contain items\n// and do away with a menu per say.. major issue is not being able to dynamically allocate \n// and destroy stuff.. Another point to consider is adding an alloc free call for vm's and have \n// the engine just allocate the pool for it based on a cvar\n// many of the vars are re-used for different item types, as such they are not always named appropriately\n// the benefits of c++ in DOOM will greatly help crap like this\n// FIXME: need to put a type ptr that points to specific type info per type\n// \n#define MAX_LB_COLUMNS 16\n\ntypedef struct columnInfo_s {\n\tint pos;\n\tint width;\n\tint maxChars;\n} columnInfo_t;\n\ntypedef struct listBoxDef_s {\n\tint startPos;\n\tint endPos;\n\tint drawPadding;\n\tint cursorPos;\n\tfloat elementWidth;\n\tfloat elementHeight;\n\tint elementStyle;\n\tint numColumns;\n\tcolumnInfo_t columnInfo[MAX_LB_COLUMNS];\n\tconst char *doubleClick;\n\tqboolean notselectable;\n} listBoxDef_t;\n\ntypedef struct editFieldDef_s {\n  float minVal;                  //\tedit field limits\n  float maxVal;                  //\n  float defVal;                  //\n\tfloat range;\t\t\t\t\t\t\t\t\t // \n  int maxChars;                  // for edit fields\n  int maxPaintChars;             // for edit fields\n\tint paintOffset;\t\t\t\t\t\t\t // \n} editFieldDef_t;\n\n#define MAX_MULTI_CVARS 32\n\ntypedef struct multiDef_s {\n\tconst char *cvarList[MAX_MULTI_CVARS];\n\tconst char *cvarStr[MAX_MULTI_CVARS];\n\tfloat cvarValue[MAX_MULTI_CVARS];\n\tint count;\n\tqboolean strDef;\n} multiDef_t;\n\ntypedef struct modelDef_s {\n\tint angle;\n\tvec3_t origin;\n\tfloat fov_x;\n\tfloat fov_y;\n\tint rotationSpeed;\n} modelDef_t;\n\n#define CVAR_ENABLE\t\t0x00000001\n#define CVAR_DISABLE\t0x00000002\n#define CVAR_SHOW\t\t\t0x00000004\n#define CVAR_HIDE\t\t\t0x00000008\n\ntypedef struct itemDef_s {\n  Window window;                 // common positional, border, style, layout info\n  Rectangle textRect;            // rectangle the text ( if any ) consumes     \n  int type;                      // text, button, radiobutton, checkbox, textfield, listbox, combo\n  int alignment;                 // left center right\n  int textalignment;             // ( optional ) alignment for text within rect based on text width\n  float textalignx;              // ( optional ) text alignment x coord\n  float textaligny;              // ( optional ) text alignment x coord\n  float textscale;               // scale percentage from 72pts\n  int textStyle;                 // ( optional ) style, normal and shadowed are it for now\n  const char *text;              // display text\n  void *parent;                  // menu owner\n  qhandle_t asset;               // handle to asset\n  const char *mouseEnterText;    // mouse enter script\n  const char *mouseExitText;     // mouse exit script\n  const char *mouseEnter;        // mouse enter script\n  const char *mouseExit;         // mouse exit script \n  const char *action;            // select script\n  const char *onFocus;           // select script\n  const char *leaveFocus;        // select script\n  const char *cvar;              // associated cvar \n  const char *cvarTest;          // associated cvar for enable actions\n\tconst char *enableCvar;\t\t\t   // enable, disable, show, or hide based on value, this can contain a list\n\tint cvarFlags;\t\t\t\t\t\t\t\t //\twhat type of action to take on cvarenables\n  sfxHandle_t focusSound;\n\tint numColors;\t\t\t\t\t\t\t\t // number of color ranges\n\tcolorRangeDef_t colorRanges[MAX_COLOR_RANGES];\n\tfloat special;\t\t\t\t\t\t\t\t // used for feeder id's etc.. diff per type\n  int cursorPos;                 // cursor position in characters\n\tvoid *typeData;\t\t\t\t\t\t\t\t // type specific data ptr's\t\n} itemDef_t;\n\ntypedef struct {\n  Window window;\n  const char  *font;\t\t\t\t\t\t\t\t// font\n  qboolean fullScreen;\t\t\t\t\t\t\t// covers entire screen \n  int itemCount;\t\t\t\t\t\t\t\t\t\t// number of items;\n  int fontIndex;\t\t\t\t\t\t\t\t\t\t// \n  int cursorItem;\t\t\t\t\t\t\t\t\t\t// which item as the cursor\n\tint fadeCycle;\t\t\t\t\t\t\t\t\t\t//\n\tfloat fadeClamp;\t\t\t\t\t\t\t\t\t//\n\tfloat fadeAmount;\t\t\t\t\t\t\t\t\t//\n  const char *onOpen;\t\t\t\t\t\t\t\t// run when the menu is first opened\n  const char *onClose;\t\t\t\t\t\t\t// run when the menu is closed\n  const char *onESC;\t\t\t\t\t\t\t\t// run when the menu is closed\n\tconst char *soundName;\t\t\t\t\t\t// background loop sound for menu\n\n  vec4_t focusColor;\t\t\t\t\t\t\t\t// focus color for items\n  vec4_t disableColor;\t\t\t\t\t\t\t// focus color for items\n  itemDef_t *items[MAX_MENUITEMS];\t// items this menu contains   \n} menuDef_t;\n\ntypedef struct {\n  const char *fontStr;\n  const char *cursorStr;\n  const char *gradientStr;\n  fontInfo_t textFont;\n  fontInfo_t smallFont;\n  fontInfo_t bigFont;\n  qhandle_t cursor;\n  qhandle_t gradientBar;\n  qhandle_t scrollBarArrowUp;\n  qhandle_t scrollBarArrowDown;\n  qhandle_t scrollBarArrowLeft;\n  qhandle_t scrollBarArrowRight;\n  qhandle_t scrollBar;\n  qhandle_t scrollBarThumb;\n  qhandle_t buttonMiddle;\n  qhandle_t buttonInside;\n  qhandle_t solidBox;\n  qhandle_t sliderBar;\n  qhandle_t sliderThumb;\n  sfxHandle_t menuEnterSound;\n  sfxHandle_t menuExitSound;\n  sfxHandle_t menuBuzzSound;\n  sfxHandle_t itemFocusSound;\n  float fadeClamp;\n  int fadeCycle;\n  float fadeAmount;\n  float shadowX;\n  float shadowY;\n  vec4_t shadowColor;\n  float shadowFadeClamp;\n  qboolean fontRegistered;\n\n  // player settings\n\tqhandle_t fxBasePic;\n  qhandle_t fxPic[7];\n\tqhandle_t\tcrosshairShader[NUM_CROSSHAIRS];\n\n} cachedAssets_t;\n\ntypedef struct {\n  const char *name;\n  void (*handler) (itemDef_t *item, char** args);\n} commandDef_t;\n\ntypedef struct {\n  qhandle_t (*registerShaderNoMip) (const char *p);\n  void (*setColor) (const vec4_t v);\n  void (*drawHandlePic) (float x, float y, float w, float h, qhandle_t asset);\n  void (*drawStretchPic) (float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader );\n  void (*drawText) (float x, float y, float scale, vec4_t color, const char *text, float adjust, int limit, int style );\n  int (*textWidth) (const char *text, float scale, int limit);\n  int (*textHeight) (const char *text, float scale, int limit);\n  qhandle_t (*registerModel) (const char *p);\n  void (*modelBounds) (qhandle_t model, vec3_t min, vec3_t max);\n  void (*fillRect) ( float x, float y, float w, float h, const vec4_t color);\n  void (*drawRect) ( float x, float y, float w, float h, float size, const vec4_t color);\n  void (*drawSides) (float x, float y, float w, float h, float size);\n  void (*drawTopBottom) (float x, float y, float w, float h, float size);\n  void (*clearScene) ();\n  void (*addRefEntityToScene) (const refEntity_t *re );\n  void (*renderScene) ( const refdef_t *fd );\n  void (*registerFont) (const char *pFontname, int pointSize, fontInfo_t *font);\n  void (*ownerDrawItem) (float x, float y, float w, float h, float text_x, float text_y, int ownerDraw, int ownerDrawFlags, int align, float special, float scale, vec4_t color, qhandle_t shader, int textStyle);\n\tfloat (*getValue) (int ownerDraw);\n\tqboolean (*ownerDrawVisible) (int flags);\n  void (*runScript)(char **p);\n  void (*getTeamColor)(vec4_t *color);\n  void (*getCVarString)(const char *cvar, char *buffer, int bufsize);\n  float (*getCVarValue)(const char *cvar);\n  void (*setCVar)(const char *cvar, const char *value);\n  void (*drawTextWithCursor)(float x, float y, float scale, vec4_t color, const char *text, int cursorPos, char cursor, int limit, int style);\n  void (*setOverstrikeMode)(qboolean b);\n  qboolean (*getOverstrikeMode)();\n  void (*startLocalSound)( sfxHandle_t sfx, int channelNum );\n  qboolean (*ownerDrawHandleKey)(int ownerDraw, int flags, float *special, int key);\n  int (*feederCount)(float feederID);\n  const char *(*feederItemText)(float feederID, int index, int column, qhandle_t *handle);\n  qhandle_t (*feederItemImage)(float feederID, int index);\n  void (*feederSelection)(float feederID, int index);\n\tvoid (*keynumToStringBuf)( int keynum, char *buf, int buflen );\n\tvoid (*getBindingBuf)( int keynum, char *buf, int buflen );\n\tvoid (*setBinding)( int keynum, const char *binding );\n\tvoid (*executeText)(int exec_when, const char *text );\t\n\tvoid (*Error)(int level, const char *error, ...);\n\tvoid (*Print)(const char *msg, ...);\n\tvoid (*Pause)(qboolean b);\n\tint (*ownerDrawWidth)(int ownerDraw, float scale);\n\tsfxHandle_t (*registerSound)(const char *name, qboolean compressed);\n\tvoid (*startBackgroundTrack)( const char *intro, const char *loop);\n\tvoid (*stopBackgroundTrack)();\n\tint (*playCinematic)(const char *name, float x, float y, float w, float h);\n\tvoid (*stopCinematic)(int handle);\n\tvoid (*drawCinematic)(int handle, float x, float y, float w, float h);\n\tvoid (*runCinematicFrame)(int handle);\n\n  float\t\t\tyscale;\n  float\t\t\txscale;\n  float\t\t\tbias;\n  int\t\t\t\trealTime;\n  int\t\t\t\tframeTime;\n\tint\t\t\t\tcursorx;\n\tint\t\t\t\tcursory;\n\tqboolean\tdebug;\n\n  cachedAssets_t Assets;\n\n\tglconfig_t glconfig;\n\tqhandle_t\twhiteShader;\n  qhandle_t gradientImage;\n  qhandle_t cursor;\n\tfloat FPS;\n\n} displayContextDef_t;\n\nconst char *String_Alloc(const char *p);\nvoid String_Init();\nvoid String_Report();\nvoid Init_Display(displayContextDef_t *dc);\nvoid Display_ExpandMacros(char * buff);\nvoid Menu_Init(menuDef_t *menu);\nvoid Item_Init(itemDef_t *item);\nvoid Menu_PostParse(menuDef_t *menu);\nmenuDef_t *Menu_GetFocused();\nvoid Menu_HandleKey(menuDef_t *menu, int key, qboolean down);\nvoid Menu_HandleMouseMove(menuDef_t *menu, float x, float y);\nvoid Menu_ScrollFeeder(menuDef_t *menu, int feeder, qboolean down);\nqboolean Float_Parse(char **p, float *f);\nqboolean Color_Parse(char **p, vec4_t *c);\nqboolean Int_Parse(char **p, int *i);\nqboolean Rect_Parse(char **p, rectDef_t *r);\nqboolean String_Parse(char **p, const char **out);\nqboolean Script_Parse(char **p, const char **out);\nqboolean PC_Float_Parse(int handle, float *f);\nqboolean PC_Color_Parse(int handle, vec4_t *c);\nqboolean PC_Int_Parse(int handle, int *i);\nqboolean PC_Rect_Parse(int handle, rectDef_t *r);\nqboolean PC_String_Parse(int handle, const char **out);\nqboolean PC_Script_Parse(int handle, const char **out);\nint Menu_Count();\nvoid Menu_New(int handle);\nvoid Menu_PaintAll();\nmenuDef_t *Menus_ActivateByName(const char *p);\nvoid Menu_Reset();\nqboolean Menus_AnyFullScreenVisible();\nvoid  Menus_Activate(menuDef_t *menu);\n\ndisplayContextDef_t *Display_GetContext();\nvoid *Display_CaptureItem(int x, int y);\nqboolean Display_MouseMove(void *p, int x, int y);\nint Display_CursorType(int x, int y);\nqboolean Display_KeyBindPending();\nvoid Menus_OpenByName(const char *p);\nmenuDef_t *Menus_FindByName(const char *p);\nvoid Menus_ShowByName(const char *p);\nvoid Menus_CloseByName(const char *p);\nvoid Display_HandleKey(int key, qboolean down, int x, int y);\nvoid LerpColor(vec4_t a, vec4_t b, vec4_t c, float t);\nvoid Menus_CloseAll();\nvoid Menu_Paint(menuDef_t *menu, qboolean forcePaint);\nvoid Menu_SetFeederSelection(menuDef_t *menu, int feeder, int index, const char *name);\nvoid Display_CacheAll();\n\nvoid *UI_Alloc( int size );\nvoid UI_InitMemory( void );\nqboolean UI_OutOfMemory();\n\nvoid Controls_GetConfig( void );\nvoid Controls_SetConfig(qboolean restart);\nvoid Controls_SetDefaults( void );\n\nint\t\t\ttrap_PC_AddGlobalDefine( char *define );\nint\t\t\ttrap_PC_LoadSource( const char *filename );\nint\t\t\ttrap_PC_FreeSource( int handle );\nint\t\t\ttrap_PC_ReadToken( int handle, pc_token_t *pc_token );\nint\t\t\ttrap_PC_SourceFileAndLine( int handle, char *filename, int *line );\n\n#endif\n"
  },
  {
    "path": "code/ui/ui_syscalls.asm",
    "content": "code\n\nequ\ttrap_Error\t\t\t\t\t\t\t\t-1\nequ\ttrap_Print\t\t\t\t\t\t\t\t-2\nequ\ttrap_Milliseconds\t\t\t\t\t\t-3\nequ\ttrap_Cvar_Set\t\t\t\t\t\t\t-4\nequ\ttrap_Cvar_VariableValue\t\t\t\t\t-5\nequ\ttrap_Cvar_VariableStringBuffer\t\t\t-6\nequ\ttrap_Cvar_SetValue\t\t\t\t\t\t-7\nequ\ttrap_Cvar_Reset\t\t\t\t\t\t\t-8\nequ\ttrap_Cvar_Create\t\t\t\t\t\t-9\nequ\ttrap_Cvar_InfoStringBuffer\t\t\t\t-10\nequ\ttrap_Argc\t\t\t\t\t\t\t\t-11\nequ\ttrap_Argv\t\t\t\t\t\t\t\t-12\nequ\ttrap_Cmd_ExecuteText\t\t\t\t\t-13\nequ\ttrap_FS_FOpenFile\t\t\t\t\t\t-14\nequ\ttrap_FS_Read\t\t\t\t\t\t\t-15\nequ\ttrap_FS_Write\t\t\t\t\t\t\t-16\nequ\ttrap_FS_FCloseFile\t\t\t\t\t\t-17\nequ\ttrap_FS_GetFileList\t\t\t\t\t\t-18\nequ\ttrap_R_RegisterModel\t\t\t\t\t-19\nequ\ttrap_R_RegisterSkin\t\t\t\t\t\t-20\nequ\ttrap_R_RegisterShaderNoMip\t\t\t\t-21\nequ\ttrap_R_ClearScene\t\t\t\t\t\t-22\nequ\ttrap_R_AddRefEntityToScene\t\t\t\t-23\nequ\ttrap_R_AddPolyToScene\t\t\t\t\t-24\nequ\ttrap_R_AddLightToScene\t\t\t\t\t-25\nequ\ttrap_R_RenderScene\t\t\t\t\t\t-26\nequ\ttrap_R_SetColor\t\t\t\t\t\t\t-27\nequ\ttrap_R_DrawStretchPic\t\t\t\t\t-28\nequ\ttrap_UpdateScreen\t\t\t\t\t\t-29\nequ\ttrap_CM_LerpTag\t\t\t\t\t\t\t-30\nequ\ttrap_CM_LoadModel\t\t\t\t\t\t-31\nequ\ttrap_S_RegisterSound\t\t\t\t\t-32\nequ\ttrap_S_StartLocalSound\t\t\t\t\t-33\nequ\ttrap_Key_KeynumToStringBuf\t\t\t\t-34\nequ\ttrap_Key_GetBindingBuf\t\t\t\t\t-35\nequ\ttrap_Key_SetBinding\t\t\t\t\t\t-36\nequ\ttrap_Key_IsDown\t\t\t\t\t\t\t-37\nequ\ttrap_Key_GetOverstrikeMode\t\t\t\t-38\nequ\ttrap_Key_SetOverstrikeMode\t\t\t\t-39\nequ\ttrap_Key_ClearStates\t\t\t\t\t-40\nequ\ttrap_Key_GetCatcher\t\t\t\t\t\t-41\nequ\ttrap_Key_SetCatcher\t\t\t\t\t\t-42        \nequ\ttrap_GetClipboardData\t\t\t\t\t-43\nequ\ttrap_GetGlconfig\t\t\t\t\t\t-44\nequ\ttrap_GetClientState\t\t\t\t\t\t-45\nequ\ttrap_GetConfigString\t\t\t\t\t-46\nequ\ttrap_LAN_GetPingQueueCount\t\t\t\t-47\nequ\ttrap_LAN_ClearPing\t\t\t\t\t\t-48\nequ\ttrap_LAN_GetPing\t\t\t\t\t\t-49\nequ\ttrap_LAN_GetPingInfo\t\t\t\t\t-50\nequ\ttrap_Cvar_Register\t\t\t\t\t\t-51\nequ trap_Cvar_Update\t\t\t\t\t\t-52\nequ trap_MemoryRemaining\t\t\t\t\t-53\nequ\ttrap_GetCDKey\t\t\t\t\t\t\t-54\nequ\ttrap_SetCDKey\t\t\t\t\t\t\t-55\nequ trap_R_RegisterFont\t\t\t\t\t\t-56\nequ trap_R_ModelBounds\t\t\t\t\t\t-57\nequ trap_PC_AddGlobalDefine\t\t\t\t\t-58\nequ\ttrap_PC_LoadSource\t\t\t\t\t\t-59\nequ trap_PC_FreeSource\t\t\t\t\t\t-60\nequ trap_PC_ReadToken\t\t\t\t\t\t-61\nequ trap_PC_SourceFileAndLine\t\t\t\t-62\nequ trap_S_StopBackgroundTrack\t\t\t\t-63\nequ trap_S_StartBackgroundTrack\t\t\t\t-64\nequ trap_RealTime\t\t\t\t\t\t\t-65\nequ trap_LAN_GetServerCount\t\t\t\t\t-66\nequ trap_LAN_GetServerAddressString\t\t\t-67\nequ trap_LAN_GetServerInfo\t\t\t\t\t-68\nequ trap_LAN_MarkServerVisible \t\t\t\t-69\nequ trap_LAN_UpdateVisiblePings\t\t\t\t-70\nequ trap_LAN_ResetPings\t\t\t\t\t\t-71\nequ trap_LAN_LoadCachedServers\t\t\t\t-72\nequ trap_LAN_SaveCachedServers\t\t\t\t-73\nequ trap_LAN_AddServer\t\t\t\t\t\t-74\nequ trap_LAN_RemoveServer\t \t\t\t\t-75\nequ trap_CIN_PlayCinematic\t\t\t\t\t-76\nequ trap_CIN_StopCinematic\t\t\t\t\t-77\nequ trap_CIN_RunCinematic \t\t\t\t\t-78\nequ trap_CIN_DrawCinematic\t\t\t\t\t-79\nequ trap_CIN_SetExtents\t\t\t\t\t\t-80\nequ trap_R_RemapShader\t\t\t\t\t\t-81\nequ trap_VerifyCDKey\t\t\t\t\t\t-82\nequ trap_LAN_ServerStatus\t\t\t\t\t-83\nequ trap_LAN_GetServerPing\t\t\t\t\t-84\nequ trap_LAN_ServerIsVisible\t\t\t\t-85\nequ trap_LAN_CompareServers\t\t\t\t\t-86\nequ trap_FS_Seek\t\t-87\nequ trap_SetPbClStatus -88\n\nequ\tmemset\t\t\t\t\t\t-101\nequ\tmemcpy\t\t\t\t\t\t-102\nequ\tstrncpy\t\t\t\t\t\t-103\nequ\tsin\t\t\t\t\t\t\t-104\nequ\tcos\t\t\t\t\t\t\t-105\nequ\tatan2\t\t\t\t\t\t-106\nequ\tsqrt\t\t\t\t\t\t-107\nequ floor\t\t\t\t\t\t-108\nequ\tceil\t\t\t\t\t\t-109\n\n"
  },
  {
    "path": "code/ui/ui_syscalls.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n#include \"ui_local.h\"\n\n// this file is only included when building a dll\n// syscalls.asm is included instead when building a qvm\n#ifdef Q3_VM\n#error \"Do not use in VM build\"\n#endif\n\nstatic int (QDECL *syscall)( int arg, ... ) = (int (QDECL *)( int, ...))-1;\n\nvoid dllEntry( int (QDECL *syscallptr)( int arg,... ) ) {\n\tsyscall = syscallptr;\n}\n\nint PASSFLOAT( float x ) {\n\tfloat\tfloatTemp;\n\tfloatTemp = x;\n\treturn *(int *)&floatTemp;\n}\n\nvoid trap_Print( const char *string ) {\n\tsyscall( UI_PRINT, string );\n}\n\nvoid trap_Error( const char *string ) {\n\tsyscall( UI_ERROR, string );\n}\n\nint trap_Milliseconds( void ) {\n\treturn syscall( UI_MILLISECONDS ); \n}\n\nvoid trap_Cvar_Register( vmCvar_t *cvar, const char *var_name, const char *value, int flags ) {\n\tsyscall( UI_CVAR_REGISTER, cvar, var_name, value, flags );\n}\n\nvoid trap_Cvar_Update( vmCvar_t *cvar ) {\n\tsyscall( UI_CVAR_UPDATE, cvar );\n}\n\nvoid trap_Cvar_Set( const char *var_name, const char *value ) {\n\tsyscall( UI_CVAR_SET, var_name, value );\n}\n\nfloat trap_Cvar_VariableValue( const char *var_name ) {\n\tint temp;\n\ttemp = syscall( UI_CVAR_VARIABLEVALUE, var_name );\n\treturn (*(float*)&temp);\n}\n\nvoid trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize ) {\n\tsyscall( UI_CVAR_VARIABLESTRINGBUFFER, var_name, buffer, bufsize );\n}\n\nvoid trap_Cvar_SetValue( const char *var_name, float value ) {\n\tsyscall( UI_CVAR_SETVALUE, var_name, PASSFLOAT( value ) );\n}\n\nvoid trap_Cvar_Reset( const char *name ) {\n\tsyscall( UI_CVAR_RESET, name ); \n}\n\nvoid trap_Cvar_Create( const char *var_name, const char *var_value, int flags ) {\n\tsyscall( UI_CVAR_CREATE, var_name, var_value, flags );\n}\n\nvoid trap_Cvar_InfoStringBuffer( int bit, char *buffer, int bufsize ) {\n\tsyscall( UI_CVAR_INFOSTRINGBUFFER, bit, buffer, bufsize );\n}\n\nint trap_Argc( void ) {\n\treturn syscall( UI_ARGC );\n}\n\nvoid trap_Argv( int n, char *buffer, int bufferLength ) {\n\tsyscall( UI_ARGV, n, buffer, bufferLength );\n}\n\nvoid trap_Cmd_ExecuteText( int exec_when, const char *text ) {\n\tsyscall( UI_CMD_EXECUTETEXT, exec_when, text );\n}\n\nint trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode ) {\n\treturn syscall( UI_FS_FOPENFILE, qpath, f, mode );\n}\n\nvoid trap_FS_Read( void *buffer, int len, fileHandle_t f ) {\n\tsyscall( UI_FS_READ, buffer, len, f );\n}\n\nvoid trap_FS_Write( const void *buffer, int len, fileHandle_t f ) {\n\tsyscall( UI_FS_WRITE, buffer, len, f );\n}\n\nvoid trap_FS_FCloseFile( fileHandle_t f ) {\n\tsyscall( UI_FS_FCLOSEFILE, f );\n}\n\nint trap_FS_GetFileList(  const char *path, const char *extension, char *listbuf, int bufsize ) {\n\treturn syscall( UI_FS_GETFILELIST, path, extension, listbuf, bufsize );\n}\n\nint trap_FS_Seek( fileHandle_t f, long offset, int origin ) {\n\treturn syscall( UI_FS_SEEK, f, offset, origin );\n}\n\nqhandle_t trap_R_RegisterModel( const char *name ) {\n\treturn syscall( UI_R_REGISTERMODEL, name );\n}\n\nqhandle_t trap_R_RegisterSkin( const char *name ) {\n\treturn syscall( UI_R_REGISTERSKIN, name );\n}\n\nvoid trap_R_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {\n\tsyscall( UI_R_REGISTERFONT, fontName, pointSize, font );\n}\n\nqhandle_t trap_R_RegisterShaderNoMip( const char *name ) {\n\treturn syscall( UI_R_REGISTERSHADERNOMIP, name );\n}\n\nvoid trap_R_ClearScene( void ) {\n\tsyscall( UI_R_CLEARSCENE );\n}\n\nvoid trap_R_AddRefEntityToScene( const refEntity_t *re ) {\n\tsyscall( UI_R_ADDREFENTITYTOSCENE, re );\n}\n\nvoid trap_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts ) {\n\tsyscall( UI_R_ADDPOLYTOSCENE, hShader, numVerts, verts );\n}\n\nvoid trap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ) {\n\tsyscall( UI_R_ADDLIGHTTOSCENE, org, PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b) );\n}\n\nvoid trap_R_RenderScene( const refdef_t *fd ) {\n\tsyscall( UI_R_RENDERSCENE, fd );\n}\n\nvoid trap_R_SetColor( const float *rgba ) {\n\tsyscall( UI_R_SETCOLOR, rgba );\n}\n\nvoid trap_R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ) {\n\tsyscall( UI_R_DRAWSTRETCHPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), hShader );\n}\n\nvoid\ttrap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs ) {\n\tsyscall( UI_R_MODELBOUNDS, model, mins, maxs );\n}\n\nvoid trap_UpdateScreen( void ) {\n\tsyscall( UI_UPDATESCREEN );\n}\n\nint trap_CM_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame, float frac, const char *tagName ) {\n\treturn syscall( UI_CM_LERPTAG, tag, mod, startFrame, endFrame, PASSFLOAT(frac), tagName );\n}\n\nvoid trap_S_StartLocalSound( sfxHandle_t sfx, int channelNum ) {\n\tsyscall( UI_S_STARTLOCALSOUND, sfx, channelNum );\n}\n\nsfxHandle_t\ttrap_S_RegisterSound( const char *sample, qboolean compressed ) {\n\treturn syscall( UI_S_REGISTERSOUND, sample, compressed );\n}\n\nvoid trap_Key_KeynumToStringBuf( int keynum, char *buf, int buflen ) {\n\tsyscall( UI_KEY_KEYNUMTOSTRINGBUF, keynum, buf, buflen );\n}\n\nvoid trap_Key_GetBindingBuf( int keynum, char *buf, int buflen ) {\n\tsyscall( UI_KEY_GETBINDINGBUF, keynum, buf, buflen );\n}\n\nvoid trap_Key_SetBinding( int keynum, const char *binding ) {\n\tsyscall( UI_KEY_SETBINDING, keynum, binding );\n}\n\nqboolean trap_Key_IsDown( int keynum ) {\n\treturn syscall( UI_KEY_ISDOWN, keynum );\n}\n\nqboolean trap_Key_GetOverstrikeMode( void ) {\n\treturn syscall( UI_KEY_GETOVERSTRIKEMODE );\n}\n\nvoid trap_Key_SetOverstrikeMode( qboolean state ) {\n\tsyscall( UI_KEY_SETOVERSTRIKEMODE, state );\n}\n\nvoid trap_Key_ClearStates( void ) {\n\tsyscall( UI_KEY_CLEARSTATES );\n}\n\nint trap_Key_GetCatcher( void ) {\n\treturn syscall( UI_KEY_GETCATCHER );\n}\n\nvoid trap_Key_SetCatcher( int catcher ) {\n\tsyscall( UI_KEY_SETCATCHER, catcher );\n}\n\nvoid trap_GetClipboardData( char *buf, int bufsize ) {\n\tsyscall( UI_GETCLIPBOARDDATA, buf, bufsize );\n}\n\nvoid trap_GetClientState( uiClientState_t *state ) {\n\tsyscall( UI_GETCLIENTSTATE, state );\n}\n\nvoid trap_GetGlconfig( glconfig_t *glconfig ) {\n\tsyscall( UI_GETGLCONFIG, glconfig );\n}\n\nint trap_GetConfigString( int index, char* buff, int buffsize ) {\n\treturn syscall( UI_GETCONFIGSTRING, index, buff, buffsize );\n}\n\nint\ttrap_LAN_GetServerCount( int source ) {\n\treturn syscall( UI_LAN_GETSERVERCOUNT, source );\n}\n\nvoid trap_LAN_GetServerAddressString( int source, int n, char *buf, int buflen ) {\n\tsyscall( UI_LAN_GETSERVERADDRESSSTRING, source, n, buf, buflen );\n}\n\nvoid trap_LAN_GetServerInfo( int source, int n, char *buf, int buflen ) {\n\tsyscall( UI_LAN_GETSERVERINFO, source, n, buf, buflen );\n}\n\nint trap_LAN_GetServerPing( int source, int n ) {\n\treturn syscall( UI_LAN_GETSERVERPING, source, n );\n}\n\nint trap_LAN_GetPingQueueCount( void ) {\n\treturn syscall( UI_LAN_GETPINGQUEUECOUNT );\n}\n\nint trap_LAN_ServerStatus( const char *serverAddress, char *serverStatus, int maxLen ) {\n\treturn syscall( UI_LAN_SERVERSTATUS, serverAddress, serverStatus, maxLen );\n}\n\nvoid trap_LAN_SaveCachedServers() {\n\tsyscall( UI_LAN_SAVECACHEDSERVERS );\n}\n\nvoid trap_LAN_LoadCachedServers() {\n\tsyscall( UI_LAN_LOADCACHEDSERVERS );\n}\n\nvoid trap_LAN_ResetPings(int n) {\n\tsyscall( UI_LAN_RESETPINGS, n );\n}\n\nvoid trap_LAN_ClearPing( int n ) {\n\tsyscall( UI_LAN_CLEARPING, n );\n}\n\nvoid trap_LAN_GetPing( int n, char *buf, int buflen, int *pingtime ) {\n\tsyscall( UI_LAN_GETPING, n, buf, buflen, pingtime );\n}\n\nvoid trap_LAN_GetPingInfo( int n, char *buf, int buflen ) {\n\tsyscall( UI_LAN_GETPINGINFO, n, buf, buflen );\n}\n\nvoid trap_LAN_MarkServerVisible( int source, int n, qboolean visible ) {\n\tsyscall( UI_LAN_MARKSERVERVISIBLE, source, n, visible );\n}\n\nint trap_LAN_ServerIsVisible( int source, int n) {\n\treturn syscall( UI_LAN_SERVERISVISIBLE, source, n );\n}\n\nqboolean trap_LAN_UpdateVisiblePings( int source ) {\n\treturn syscall( UI_LAN_UPDATEVISIBLEPINGS, source );\n}\n\nint trap_LAN_AddServer(int source, const char *name, const char *addr) {\n\treturn syscall( UI_LAN_ADDSERVER, source, name, addr );\n}\n\nvoid trap_LAN_RemoveServer(int source, const char *addr) {\n\tsyscall( UI_LAN_REMOVESERVER, source, addr );\n}\n\nint trap_LAN_CompareServers( int source, int sortKey, int sortDir, int s1, int s2 ) {\n\treturn syscall( UI_LAN_COMPARESERVERS, source, sortKey, sortDir, s1, s2 );\n}\n\nint trap_MemoryRemaining( void ) {\n\treturn syscall( UI_MEMORY_REMAINING );\n}\n\nvoid trap_GetCDKey( char *buf, int buflen ) {\n\tsyscall( UI_GET_CDKEY, buf, buflen );\n}\n\nvoid trap_SetCDKey( char *buf ) {\n\tsyscall( UI_SET_CDKEY, buf );\n}\n\nint trap_PC_AddGlobalDefine( char *define ) {\n\treturn syscall( UI_PC_ADD_GLOBAL_DEFINE, define );\n}\n\nint trap_PC_LoadSource( const char *filename ) {\n\treturn syscall( UI_PC_LOAD_SOURCE, filename );\n}\n\nint trap_PC_FreeSource( int handle ) {\n\treturn syscall( UI_PC_FREE_SOURCE, handle );\n}\n\nint trap_PC_ReadToken( int handle, pc_token_t *pc_token ) {\n\treturn syscall( UI_PC_READ_TOKEN, handle, pc_token );\n}\n\nint trap_PC_SourceFileAndLine( int handle, char *filename, int *line ) {\n\treturn syscall( UI_PC_SOURCE_FILE_AND_LINE, handle, filename, line );\n}\n\nvoid trap_S_StopBackgroundTrack( void ) {\n\tsyscall( UI_S_STOPBACKGROUNDTRACK );\n}\n\nvoid trap_S_StartBackgroundTrack( const char *intro, const char *loop) {\n\tsyscall( UI_S_STARTBACKGROUNDTRACK, intro, loop );\n}\n\nint trap_RealTime(qtime_t *qtime) {\n\treturn syscall( UI_REAL_TIME, qtime );\n}\n\n// this returns a handle.  arg0 is the name in the format \"idlogo.roq\", set arg1 to NULL, alteredstates to qfalse (do not alter gamestate)\nint trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits) {\n  return syscall(UI_CIN_PLAYCINEMATIC, arg0, xpos, ypos, width, height, bits);\n}\n \n// stops playing the cinematic and ends it.  should always return FMV_EOF\n// cinematics must be stopped in reverse order of when they are started\ne_status trap_CIN_StopCinematic(int handle) {\n  return syscall(UI_CIN_STOPCINEMATIC, handle);\n}\n\n\n// will run a frame of the cinematic but will not draw it.  Will return FMV_EOF if the end of the cinematic has been reached.\ne_status trap_CIN_RunCinematic (int handle) {\n  return syscall(UI_CIN_RUNCINEMATIC, handle);\n}\n \n\n// draws the current frame\nvoid trap_CIN_DrawCinematic (int handle) {\n  syscall(UI_CIN_DRAWCINEMATIC, handle);\n}\n \n\n// allows you to resize the animation dynamically\nvoid trap_CIN_SetExtents (int handle, int x, int y, int w, int h) {\n  syscall(UI_CIN_SETEXTENTS, handle, x, y, w, h);\n}\n\n\nvoid\ttrap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset ) {\n\tsyscall( UI_R_REMAP_SHADER, oldShader, newShader, timeOffset );\n}\n\nqboolean trap_VerifyCDKey( const char *key, const char *chksum) {\n\treturn syscall( UI_VERIFY_CDKEY, key, chksum);\n}\n\nvoid trap_SetPbClStatus( int status ) {\n\tsyscall( UI_SET_PBCLSTATUS, status );\n}\n"
  },
  {
    "path": "code/ui/ui_util.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// ui_util.c\n//\n// origin: rad\n// new ui support stuff\n// \n// memory, string alloc\n\n\n"
  },
  {
    "path": "code/unix/ChangeLog",
    "content": "TODO: the Mac port seems stable, but outputs a bunch of warnings..\n\t\n2004-05-22\n- updated the xcode project from Apple's version\n  now with the latest vm_ppc code\n\t\n2004-05-21 Timothee Besset <ttimo@idsoftware.com>\n- fixed the Linux build to compile again on sid (glext.h and gcc3 warnings)\n- 2 weeks ago, hacked up the source to compile on panther / xcode 1.1\n  several cleanups were needed, and VM support seems broke (hangs or crashes)\n- got altivec optimisations from Apple (Kenneth Dyke)\n  merged back in\n- looks like with the new code merge the VM support is back in and working\n\t\n2003-09-15 Timothee Besset <ttimo@idsoftware.com>\n- import Q3 java master code, cleanups on monster\n\n2003-08-31 Timothee Besset <ttimo@idsoftware.com>\n+ loki_setup hell\n  https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=626\n  http://zerowing.idsoftware.com/linux/q3a/index.html#glibc\n  text mode installer in loki_setup image built on Mandrake 7.2 crashes on some glibc 2.3 systems such as RH9 etc.\n  need to move to a different version of the installer, and update old installers to keep them still 'installing'\n  moving to build the setup binaries on Debian Woody systems (glibc 2.2, text mode installer will no longer work on 2.1 systems)\n  hacked together a new setup, using setup tree from RTCW. would need a complete revamp if a new full setup with new binaries is needed\n\n2003-07-17 Timothee Besset <ttimo@idsoftware.com>\n\t+ new cvsreport, testing per-module config\n\n2003-01-19 Timothee Besset <ttimo@idsoftware.com>\n\t+ building on both gcc 2.x and 3.x\n\t\tadded conf modules to check gcc version\n\t\tccache support\n\n2003-01-13 Timothee Besset <ttimo@idsoftware.com>\n\t+ tweaking around for gcc 3.x build\n\t\tedit Conscript to change the compiler\n\n2002-12-16 Timothee Besset <ttimo@idsoftware.com>\n\t+ added pbEmit class to auth code, emit CD keys to local PB master\n\n2002-11-14 Timothee Besset <ttimo@idsoftware.com>\n  + up to latest makeself.sh\n\t+ add both quake3.x86 and quake3-smp.x86 to setup\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=573\n\t  console setup crash / glibc 2.3 (Debian Sid)\n\t\tinvestigated, put together a workaround\t\t\n\n2002-11-5 Timothee Besset <ttimo@idsoftware.com>\n\t+ Linux building both smp and non-smp again. Will have to put both in setup\n\t+ added in_subframe to toggle X subframe event handling\n\t+ reworked the timing code to be more reliable\n\t+ cleaned up dgamouse/in_mouse code, removed unnecessary dgamouse var\n\t+ made the mouse grabbing an in_nograb cvar, no longer a compile time option\n\t  in_nograb 1 force in_dgamouse 0 and r_fullscreen 0 (any of those two will b0rk)\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=565\n\t  mouse issues on Suze 8.1 - related to subframe event timing\n\t\tadded code chunk to detect broken X timing and disable subframe\n\t+ tweaked the subframe/X bug workaround to be less paranoid\t\n\n2002-10-28 Timothee Besset <ttimo@idsoftware.com>\n\t+ no longer blocking demo recording if g_synchronous clients != 0\n\t\tonly sending out a warning (everyone does g_sync 1 ; record ; g_sync 0)\n\n2002-10-21 Timothee Besset <ttimo@idsoftware.com>\n\t+ building final mod sdk setups (added lcc bins, added link to q3asm-turbo in readme)\n\n2002-10-8 Timothee Besset <ttimo@idsoftware.com>\n\t+ quickfix cl_maxpackets > 125 brings back to 100\n\n1.32 release ---\n\n2002-10-7 Timothee Besset <ttimo@idsoftware.com>\n\t+ made the 'demo' command case-insensitive on extension match (it was confused by demo FOUR.DM_68)\n\t+ mouse wheel scrolling with in_mouse 1 + window mode was not working, fixed (DI didn't catch)\n\t+ removing on-the-fly pk3 build from Linux setup, using the finalized ones now\n\t\tadded 'pk3' option to cons for toggle of pk3 building\n\n2002-10-5 Timothee Besset <ttimo@idsoftware.com>\n  + updated win32 mod sdk (in win32/mod-sdk-setup)\n    added q3asm and lcc source\n    updated the .bat to build VMs\n\n2002-10-3 Timothee Besset <ttimo@idsoftware.com>\n\t+ linux mod sdk, wrote the bulk of the scripts\n\n2002-9-30 Timothee Besset <ttimo@idsoftware.com>\n\t+ ATVI Quake 3 1.32 Patch #9\n\t\trolling back to the way it was before, leaving 1v1 force vote exploit, the fix was worse than the bug\n\t\tfrom comment on bug #9 in tracker:\n\t\t\n\t\tactually the fix is worse than the original bug\n\n     after the fix, voting when you are alone on the server was no longer working\n     it was kinda intended in the fix, that you would have to be at least two to pass a vote .. but\n     it is an oversight.\n\n     calling a vote in a 1v1 game against a bot fails immediately\n     (calling a vote in any situation where there's only 1 live player fails)\n\n     Say a server's running some lame custom map that you have but a friend doesn't. You can't go\n     on the server and change it to the map you want to play, so he ends up having to auto-dl it at\n     8K a second just so you can switch from it.\n\n     This particular 2 clients, vote / quit exploit would involve too many changes to fix properly.\n     I am reverting back to the old version, and leaving as WNF \n\n2002-9-29 Timothee Besset <ttimo@idsoftware.com>\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=50\n\t\tadded Wheel support to the DirectInput code IN_DIMouse (in_mouse 1)\n\t\ttweaked the Wheel mouse reading for in_mouse -1 (old win32 input code)\n\t\t\thandle correctly when zDelta is > 120\n\t\t\tprovide a in_logitechbug cvar to handle buggy Logitech MouseWare driver sending wheel events twice\n\n2002-9-26 Timothee Besset <ttimo@idsoftware.com>\n\t+ ATVI Quake 3 1.32 Patch #38\n\t\tadding trap_SetPbClStatus, reliably checks for PB presence before enabling PB in UI\n\n2002-9-25 Timothee Besset <ttimo@idsoftware.com>\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=551\n\t\tSVF_CLIENTMASK, fixed a typo\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=555\n\t\tpushed cl_maxpackets upper limit to 125 (from 100) per CPMA Arqon's request\n\n2002-9-24 Timothee Besset <ttimo@idsoftware.com>\n\t+ ATVI Quake 3 1.32 Patch #33\n\t\tPB reporting sv_paused cvar hacked, fixed SV_CheckPaused to use a Cvar_Set\n\t+ ATVI Quake 3 1.32 Patch #24\n\t\tadded [skipnotify] from RTCW, use to display in the console only, but not on client screen\n\t\t(also fixes pb_msgprefix and pb_sv_msgprefix)\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=553\n\t\tusing correct error message if listen server starting as cl_punkbuster 0 sv_punkbuster 1\n\t+ ATVI Quake 3 1.32 Patch #35\n\t\ttext auto wrap in UI code was eating the last word if it was wrapping\n\t\tfixed in Q3 and TA UI (this bug could have affected the server print message also)\n\t+ some updates to the win32 cons post-build process\t\n\n2002-9-21 Timothee Besset <ttimo@idsoftware.com>\n\t+ adding bspc cons build script\n\n2002-9-19 Timothee Besset <ttimo@idsoftware.com>\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=552\n\t\tdisconnect reason is transmitted in the disconnect command and processed into com_errorMessage\n\t\t(similar to RTCW behaviour)\n\t\tadded UI for com_errorMessage cvar in baseq3/, if client is kicked/dropped/disconnected for whatever reason\n\t\t(this is already functional in TA)\n\t+ ATVI Quake 3 1.32 Patch #9\n\t\tfailing vote if there's only one voting client (fixes exploit on 2-player server where one player votes then disconnects, forcing vote to pass)\n\t+ ATVI Quake 3 1.32 Patch #5\n\t\tremoved the userInfoChanged message (was a debugging leftover)\n\t+ ATVI Quake 3 1.32 Patch #18\n\t\trcon was not properly fixed yet, this only showed up for PB commands\n\t\tchanged the rcon parsing again to be more reliable\n\t\n2002-9-18 Timothee Besset <ttimo@idsoftware.com>\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=549\n\t\tthe demo command has a list of compatible protocols, it will loop through 66 67 68\n\t\tyou can do '/demo four' and it will try four.dm_66 four.dm_67 four.dm_68\n\t\tor you can explicitely give a '/demo demoname.dm_??'\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=551\n\t\tadded SVF_CLIENTMASK (0x00000002), works only with <= 32 players\n\t\tset bitmask of players to which send entity\n\n2002-9-17 Timothee Besset <ttimo@idsoftware.com>\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=550\n\t\trcon bug fix\n\t+ some scons updates for win32 (post build)\n\t+ 1.32rc2\n\n2002-9-06 Timothee Besset <ttimo@idsoftware.com>\n\t+ updated completely the setup system:\n\t\tfixed cons stuff to build setup with cons -- release setup\n\t\tworking from new setup codebase with some custom patches:\n\t\t\thttps://bugzilla.icculus.org/show_bug.cgi?id=52\n\t\t\thttps://bugzilla.icculus.org/show_bug.cgi?id=53\n\t\t\tchecked that BSD support was still in (brandelfing and symlinks) .. will have to get tester feedback\n\t\tbumped version to 1.32rc1\t\n\t\tTODO: update the windows .VCT (standalone setup and auto-update)\n\n2002-9-04 Timothee Besset <ttimo@idsoftware.com>\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=543\n\t\tbackport from RTCW 1.4 code\n\t\trcon commands where sent after being tokenized and rebuilt\n\t\tthat was breaking any quoting, for instance 'rcon g_motd \"hooka pooka\"'\n\t\tadded Cmd_Cmd() to retrieve the un-tokenized command and transmit as is on both ends\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=542\n\t\tb0rked text wrapping in connect screen\n\t\twas a missing sizeScale in q3_ui/, and a bad param in ui/\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=540\n\t\tbackport fix to pk3 reordering, happens when clearing the references, bad order from connection may break stuff\t\t\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=527\n\t\tTA ui/, quickfix to netSource (mod stuff, doesn't affect TA)\n\t+ cleaned up broken old DO_WIN32 stuff in cons scripts\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=526\n\t\ttypo in models2.shader\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=443\n\t\tLinux client: sub-frame timing of key/mouse events\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=453\n\t\tadded mousewheel support: wheel to scroll, ctrl+wheel to scroll faster, shift+wheel to scroll history\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=545\n\t\tbumped server count to 4096\n\t+ keep around: __asm__ __volatile__ (\"int $0x03\");\t\t\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=516\n\t\tmoved screenshots to backend with a new RC_SCREENSHOT render command\n\t\tfixes the r_smp 1 garbled screenshots\n\n2002-8-29 Timothee Besset <ttimo@idsoftware.com>\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=539\n\t\tnew VM code from Raven's Sof2\n\t+ cons / qvmtools build system fixes\t\n\t+ had to get a new qe3.ico again (resource compiler error)\n\t\thttp://vasin.hypermart.net/eei.htm\n\t+ updated, basic testing on win32, merging back in trunk\n\t+ merged bug-539 branch back into trunk, officialize the new VM code\n\n2002-8-26 Timothee Besset <ttimo@idsoftware.com>\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=472\n\t\tlinux client: handle ctrl+space situations (could leave space locked on + space not working with ctrl on)\n\t+ update the build system, build q3lcc and q3asm etc. on demand\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=62\n\t\tfixed invisible players/entities\n\n2002-8-23 Timothee Besset <ttimo@idsoftware.com>\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=536\n\t\tfixing donedl being ignored after autodl if map_restart'ed (propagate from RTCW)\n\t\tignoring multiple map_restart (propagated from RTCW)\n\t+ reworked the server 'client text ignored' message to only trigger\twhen there's actually a message that doesn't get to the game VM\n\n2002-8-18 Timothee Besset <ttimo@idsoftware.com>\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=528\n\t\tydnar: reorg bits in the drawsurf sort index, push MAX_SHADERS to 2^12\n\t+ commented out some debug stuff in java auth server\n\t+ added FAQ item with Linux & BSD patch to handle broadcast on multiple interfaces\n\n2002-8-15 Timothee Besset <ttimo@idsoftware.com>\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=534\n\t\tfixing rcon being broken on NT/XP with > 23 days uptime (or so)\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=525\n\t\tchanged the rcon buffer size to avoid overflows and dropping part of the message\n\n2002-8-14 Timothee Besset <ttimo@idsoftware.com>\n\t+ hacked in some experimental win32 stuff to the cons files\n\t\t(win32 recognition and pk3 installs .. very very experimental but I needed it for win32 dev)\n\t+\thttps://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=521\n\t\tui/ and q3_ui/ : added text auto wrapping in the connection screen drawing (server message)\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=531\n\t\tremoved the MPlayer stuff from the server browsers\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=505\n\t\tenabled back the ignore if protocol is != (fixes Wolf servers showing in browser)\n\n2002-8-10 Timothee Besset <ttimo@idsoftware.com>\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=500\n    propagated IP banning fix from RTCW\n\n2002-8-08 Timothee Besset <ttimo@idsoftware.com>\n\t+ propagate additional sv_lanForceRate fix from RTCW\n\n2002-8-07 Timothee Besset <ttimo@idsoftware.com>\n\t+ added trap_FS_Seek\n\n2002-8-05 Timothee Besset <ttimo@idsoftware.com>\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=50\n    fixed the DI mouse init procedure\n\t\t\n2002-8-05 Timothee Besset <ttimo@idsoftware.com>\n\t+ removed sv_allowanonymous, was dummy and polluting the serverinfo\n\t\t(sv_allowanonymous was designed to flag wether server was public or not, but that's replaced by g_needpass)\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=514\n\t\tsv_strictAuth (default 1): server variable to control wether strict CDKEY auth should be performed\n\t\t\tthis is required if you want reliable cl_guid on the server\n\t\textended the getIpAuthorize (server->auth message) syntax\n\t\tsending the fs_game at all times (default 'baseq3'), dummy sv_allowAnonymous 0, strict auth flag\n\t\tNOTE: 1.31 server on baseq3 sends a getIpAuthorize packet like:\n\t\t\tprocessing packet: getIpAuthorize -1230824753 217.128.77.195  0\n\t\t\tthe auth server will mistakenly read fs_game as '0'\n\t+ TAGGED the master / auth source as pre-1_32\n\t\twill need to go back to this to comment out all my debugging crap\n\n2002-8-04 Timothee Besset <ttimo@idsoftware.com>\n\t+ cleaned master server stuff, client was prompting master.quake3arena.com, \n\t\tserver was sending heartbeats to master3.idsoftware.com\n\t\tboth point to 192.246.40.56, unified to master.quake3arena.com\n\t\tthe MPlayer master, master.quake3world.com doesn't exist anymore, switched it to master.quake3arena.com\n\n2002-8-02 Timothee Besset <ttimo@idsoftware.com>\n\t+ added auth server source, reorganized\n\t+ auth server name / master key optionally set on command line for master and auth servers\n\t+ auth and master config in build system\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=524\n\t\tchanged default GL driver from libGL.so to libGL.so.1\n\t\tsee LSB 1.2 spec: http://www.linuxbase.org/spec/refspecs/LSB_1.2.0/gLSB/libgl.html\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=480\n\t\tapplying the 'no cp command' experimental fix for beta phase\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=462\n\t\tbackported from RTCW, fix to packet fragmenting emission\n\t\tFIXME: there is some verbose code that we have to take out in the final version (grep for #462)\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=475\n\t\tbackported from RTCW, don't get dropped if the server changes map while connecting (ignore outdated cp)\n\t+ PROTOCOL BUMPED TO 68\t\n\n2002-8-01 Timothee Besset <ttimo@idsoftware.com>\n\t+ Linux: dedicated build was not setting up signal handler like the full client does\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=522\n\t\tSplashDamage bugfix, now clearing client gentity before GAME_INIT call (instead of after)\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=498\n\t\tfixed NET_AdrToString to print the port as unsigned int (for ports > 1^^15, was showing negative)\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=501\n\t\tmaintain IP in userinfo sent to game\n\t+ checking in master server source\t\n\n2002-7-31 Timothee Besset <ttimo@idsoftware.com>\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=513\n\t\thttps://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=506\n\t\tporting fix from RTCW codebase. client re-orders it's pk3s to scan in the same order than the server\n\t\tthis eliminates several 'Invalid .PK3 file referenced' situations (caused by client not referencing the same thing as server)\n\t+ fixed border remnants in ta ui\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=517\n\t\tERR_DROP if PB client off / server on conflict when starting local server\n\t+ quickfix to q3 ui / punkbuster detect in server browser\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=458\n\t\tcode fix, no more taunt spam\n\t+ cons install of PB .so files\n\t+ correct MOD_KAMIKAZE and MOD_JUICED in TA games.log\n\n2002-7-29 Timothee Besset <ttimo@idsoftware.com>\n\t+ q3 ui: completed confirmation prompts and messages (added UI_ConfirmMenu_Style & UI_Message)\n\t+ ta ui: backported 'conditionalopen' from RTCW (conditionalopen <cvar> <menu1> <menu2>)\n\t+ ta ui: confirmation prompt for punkbuster enable/disable etc.\n\t+ added the win32 DLLs to pb/win32/\n\t\n2002-7-28 Timothee Besset <ttimo@idsoftware.com>\n\t+ ta ui: sv_punkbuster in StartServer menu\n\t+ ta ui: added cl_punkbuster in server browser\n\t+ view filters are in a modal dialog\n\t+ new files: filter.menu menus.txt (pak3.pk3 updated)\n\t+ fix broken link in Linux FAQ\t\n\n2002-7-27 Timothee Besset <ttimo@idsoftware.com>\n\t+ ta ui: PB display in the browser, in it's additional tab, with sorting\n\n2002-7-26 Timothee Besset <ttimo@idsoftware.com>\n\t+ PB UI: for baseq3/ AND missionpack/\n\t\tq3_ui: Punkbuster: Enable/Disable in server broswer (cl_punkbuster)\n\t\tq3_ui: PB logo, PB Yes/No in browser (TODO: validate this to be working)\n\t\tq3_ui: added sv_punkbuster toggle in start server menu\n\t+ automated building of the new PK3s, unix/Conscript-pk3\n\n2002-7-25 Timothee Besset <ttimo@idsoftware.com>\n\t+ added PB build scripts on Linux, fixed the Linux build\n\n2002-7-12 Timothee Besset <ttimo@idsoftware.com>\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=511\n    fixing re.SetColor crash for widescreen displays (q3dm11)\n    was calling to the renderer while not registered\n\n2002-6-19 Timothee Besset <ttimo@idsoftware.com>\n  + r_roundImagesDown 0 + map q3dm16 -> tr_image.c ResampleTexture crash\n\t  buffer overflow because of resample to 2048x..\n\t\txian_q3dm12_leftwall4fin.jpg 1152x384\n\t\tbumped one buffer byte p1[1024] -> byte p1[2048], added a safe check\n\n2002-6-14 Timothee Besset <ttimo@idsoftware.com>\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=493\n\t  propagate a renderer fix from RTCW. fixes a one-frame visual glitch when mod code \n\t\tregisters a shader after drawsurfaces are generated but before the frame is rendered\n\n2002-6-12 Timothee Besset <ttimo@idsoftware.com>\n  + added cons and pcons to unix/, updated the build script\n\n2002-5-24 Timothee Besset <ttimo@idsoftware.com>\n\ttowards a new Q3 release?\n\t\tsome bug fixes require protocol change, or mod code/mod interface change to be fixed properly\n\t\tthis is a biz decision, dunno yet if we are going to want a new protocol (probably not)\n\t-> have to create a branch for the 1.31b, i.e. backwards compatible with 1.31 'Stable-1_31'\n\t  and put the 1.32 specific / protocol changes on trunk\n\tno telling what will go in SOS in the end .. probably 1.32\t\n\n2002-5-5 Timothee Besset <ttimo@idsoftware.com>\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=491\n\t  adding a sv_lanForceRate (defaults to 1) to turn on/off server forcing rate of LAN clients\n\t\t(only affects LAN dedicated clients - dedicated 1, default behaviour forces LAN clients to 99999 rate)\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=470\n\t  fixing potential overflows with cl_cdkey (propagated from RTCW)\n\t+ cons-based build system (imported from Wolf, was partly written for mod tools release already)\n\t  building with SMP on by default\n\t+ better #ifdef SMP handling ('disabled at compile time' message)\t\n\t+ https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=494\t  \n\t\tQ_vsnprintf for vsprintf calls in the core\n\t\tnot putting this in game code as we'd need a vsnprintf implementation in bg_lib.c\n\n2002-4-5 Timothee Besset <ttimo@idsoftware.com>\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=462\n    taking out the fix which was found broken and incomplete  \n\n2002-8-4  Timothee Besset <ttimo@idsoftware.com>\n  + adding NO_MOUSEGRAB define (select in the Makefile)\n\n2002-2-4  Timothee Besset <ttimo@idsoftware.com>\n  + applying Gareth's SMP patch\n  + count number of CPUs (Sys_ProcessorCount in unix_shared.c), default r_smp appropriately\n  + bumping version to 1.32\n  + if XInitThreads fails, set r_smp to zero\n\n2002-28-2  Timothee Besset <ttimo@idsoftware.com>\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=462\n    send potential remaining fragmented packets before sending a gamestate\n    \n2002-26-2  Timothee Besset <ttimo@idsoftware.com>\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=455\n  removed old libMesaVoodooGL.so loading code\n  Voodoo cards should use XF4/DRI, that load code was outdated and confusing people with broken OpenGL\n\n2002-16-1  Timothee Besset <ttimo@idsoftware.com>\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=441\n  adding brandelf calls to the setup building process so that our binaries run on BSD\n\n2002-1-1  Timothee Besset <ttimo@idsoftware.com>\n  + updated FAQ with BSD info (bug #441)\n  + FAQ update on CLIENT_UNKNOWN_TO_AUTH\n  + FAQ update for proper strace usage\n\n2001-12-12  Timothee Besset <ttimo@idsoftware.com>\n  + Q3 1.31 point release\n    updating build_setup.sh to new pk3 files\n    (baseq3/pak7.pk3 missionpack/pak2.pk3)\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=395\n    adding quake3.xpm icon, and modified the setup accordingly to put symlinks\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=390\n    ignoring SIGTTIN SIGTTOU\n\n2001-06-12  Timothee Besset <ttimo@idsoftware.com>\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=402\n    bug with full scene\n\n2001-04-12  Timothee Besset <ttimo@idsoftware.com>\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=398\n    cg_bobup cheat protect\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=399\n    fixed Setup > System > Driver info crash\n  + checked in code/spank.sh script, perform checksuming  \n\t\n2001-18-09  Timothee Besset <ttimo@idsoftware.com>\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=371\n    propagating sound code fixes from Wolf to Q3\n\t\n2001-11-08  Timothee Besset <ttimo@idsoftware.com>\n  + setup script was still broken, damn shell expansion\n    the exit code for Q3 was always zero instead of $?\n    propagating the fix to Wolf\n\n2001-11-04  Timothee Besset <ttimo@idsoftware.com>\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=382\n    modified challenge code for motd to be truly random\n\t\n2001-10-31  Timothee Besset <ttimo@idsoftware.com>\n  Moved updated q3asm and lcc source at the toplevel, MissionPack/q3asm\n  and MissionPack/lcc\n\n2001-10-29  Timothee Besset <ttimo@idsoftware.com>\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=381\n    build system is now functional\n\n2001-10-21  Timothee Besset <ttimo@idsoftware.com>\n  + updated Sys_LoadDll code on linux to search in the following order:\n    #1 current directory\n    #2 fs_homepath\n    #3 fs_basepath\n    this was needed to make mod developement easier\n\n2001-10-09  Timothee Besset <ttimo@idsoftware.com>\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=51\n    the code to buffer the redirection was in there but disabled? (Com_Printf)\n    enabled it back\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=52\n    connection issues / userinfo\n    client side fix, instead of sending 'connect <userinfo>' packet\n    we now send 'connect \"<userinfo>\"'\n\n2001-10-08  Timothee Besset <ttimo@idsoftware.com>\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=371\n    added a PROT_READ to the mmap call\n    this was needed to go around a bug in glibc i586 i686, memset doing read access\n    since the audio_fd is opened O_RDWD this is harmless to Q3\n\n2001-10-07  Timothee Besset <ttimo@idsoftware.com>\n  + updating from SOS\n    S_WriteLinearBlastStereo16 C/asm is back in snd_mix.c (Graeme)\n    r_showtris r_shownormal cheat protections\n  + Sys_LoadDll changes:\n    removing -debug search when loading native dlls\n    changing the fatal aborts when not finding native from release only to debug only (was a misfeature)\n    used to search in cd_path which is bogus, now searching in pwd if basepath fails\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=275\n    fixed r_fullbright not being cheat protected / was a CVAR_LATCHED|CVAR_CHEAT issue\n\n2001-09-06  Timothee Besset <ttimo@idsoftware.com>\n  + updated from SOS, some changes to qcommon/unzip.c (statics)\n\n2001-08-27  Timothee Besset <ttimo@idsoftware.com>\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=3\n  Added some code in CL_InitDownloads to use FS_ComparePaks and print out information about server-referenced paks that are missing on the client. It is a first step, allows to get precise information about what can cause a connection to fail (typically when the user is sent back to the main screen).\n\n2001-08-22  Timothee Besset <ttimo@idsoftware.com>\n  + https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=86\n  fixed sound bug (with Graeme hints)\n\n2001-08-20  Timothee Besset <ttimo@idsoftware.com>\n  + made sure Sys_Printf doesn't get into an endless loop if logfile is on\n    fixed qconsole.log issues, +set logfile 1 +set fs_debug 1 was crashing (any OS)\n    fixed logfile 1 / ttycon 1 issue, didn't exit properly (same endless looping)\n    also fixes an issue reported by q3f team\n  + changed rcon commands from Com_DPrintf to Com_Printf so that they show up in the console\n  (with IP information)\n\n2001-08-19  Timothee Besset <ttimo@idsoftware.com>\n  + fixed https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=91\n  (autodownload toggle in q3 ui)\n  + fixed https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=76\n  g_password issue\n  + fixed https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=93\n  cheat protecting r_lodCurveError\n  + wontfix https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=92\n\n2001-08-18  Timothee Besset <ttimo@idsoftware.com>\n  + more fixes to the 7-button mouse code (linux only)\n  + updated faq about gamma slider\n  + added \"servers don't show up in ingame browser\" to faq\n  + added Alt+Enter toggle for fullscreen/windowed (linux)\n\n2001-08-16  Timothee Besset <ttimo@idsoftware.com>\n  reconfiguring CVS repository to give access to Gareth\n  + testin gareth's access\n\n2001-08-03  Timothee Besset <ttimo@idsoftware.com>\n  * https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=85\n  fixes in the setup code for older bash versions\n  \n2001-08-02  Timothee Besset <ttimo@idsoftware.com>\n  * commented out assembly implementation of S_WriteLinearBlastStereo16, using modified C implementation from Zaphod\n    need to check performance: https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=88\n  * finished const declarations in CG_Trace calls, was needed in pmove_t declaration and some other functions\n    cgame/cg_local.h : CG_trace trap_CM_BoxTrace\n    game/bg_public.h : using const in pmove_t trace functions prototypes\n    (fixes gcc warnings: assignment from incompatible pointer type)\n\n2001-07-26  Timothee Besset <ttimo@idsoftware.com>\n  * https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=78\n  mapped K_MOUSE4 K_MOUSE5\n\n2001-07-23  Timothee Besset <ttimo@idsoftware.com>\n  * https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=5\n  more fixes, handling meta characters and various kinds of backspace\n\n2001-07-22  Timothee Besset <ttimo@idsoftware.com>\n  * https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=5\n  after testing feedback, fixed more stuff:\n    better backspace, works with putty and potentially more terminals\n  * https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=51\n  band aid fix to rcon status, incresed MAX_PUSHED_EVENTS from 256 to 1024\n  (adds 28kb of mem requirements)\n\n2001-07-21  Timothee Besset <ttimo@idsoftware.com>\n  * https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=2\n  using XF86 Gamma extension to set the gamma in game from the menus\n  (previous behaviour was to set /r_gamma and restart, renderer relying on s_gammatable)\n  restoring initial gamma on GLimp_ShutDown\n\n2001-07-19  Timothee Besset <ttimo@idsoftware.com>\n  * https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=5\n  first usable version of dedicated console\n  added history and completion functionality\n  ready for some testing\n  still some TODOs and FIXMEs:\n    keep the currently edited line when going back from history exploration\n    edit the current line with cursor, insert mode etc.\n\n2001-07-18  Timothee Besset <ttimo@idsoftware.com>\n  * starting TAB completion and history for the dedicated server (tty console)\n  removed Sys_ConsoleOutput (unused)\n  removing bogus nostdout variable\n  cleanup of a big chunk of code that Bernd commented out and scheduled for deletion\n  moved completion code from client/cl_keys.c stuff into qcommon/common.c, Field_CompleteCommand(field_t*)\n\n2001-07-13  Timothee Besset <ttimo@idsoftware.com>\n  * fixed https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=8\n  screenshots overwrites\n  * fixed https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=31\n  DOUBLE SIGNAL FAULT\n\n2001-07-11  Timothee Besset <ttimo@idsoftware.com>\n  * fix for french keybards / console toggle / bound to XK_twosuperior\n\n2001-07-10  Timothee Besset <ttimo@idsoftware.com>\n  * https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=19\n  cleanup of the keyboard code, adding com_developer message in case XLookupString would fail\n\n2001-07-10  Timothee Besset <ttimo@idsoftware.com>\n  * https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=33\n  using our custom handlers for X errors, should make things more robust\n  (X docs say some X errors are not fatal, but the default X handler exits the app anyway)\n\n2001-07-08  Timothee Besset <ttimo@idsoftware.com>\n\t* https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=19\n\tkeyboard state issues, fixed the sticking with ctrl key (thks relnev)\n\n2001-07-07  Timothee Besset <ttimo@idsoftware.com>\n\t* closing https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=13\n\tthe fixes to bug #9 solved this one too\n\t* checking in to SOS\n\n2001-07-05  Timothee Besset <ttimo@idsoftware.com>\n\t* work on https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=9\n\tfilesystem code changes:\n\tupdated the documentation in files.c to the current system\n\tadded correct fs_homepath fs_basepath fs_cdpath scanning to FS_SV_FOpenFileRead\n\t  (fixes description.txt not found, and probably a few other linux issues)\n\n2001-06-29  Timothee Besset <ttimo@idsoftware.com>\n\t* fixed setup issues (graphical/console)\n\thttps://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=6\n\n2001-06-26  Timothee Besset <ttimo@idsoftware.com>\n\t* bug tracker is online at https://zerowing.idsoftware.com/bugzilla\n\t  authentication, use login: bugs password: b00gies\n\t  for now, using it as the linux bug tracker, possible use for more OSes and programs if anyone is interested.\n\t* tweaked the graphical setup to send to bugs@idsoftware.com on errors instead of support@lokigames.com\n\t  \n2001-06-19  Timothee Besset <ttimo@idsoftware.com>\n        * fixed generated launch script /usr/local/bin/quake3, exit $* should be exit\n\n2001-06-18  Timothee Besset <ttimo@idsoftware.com>\n        * rebuilt 1.29f setups, released as 1.29f-beta1 'Q3 1.29f linux-i386 Jun 19 2001'\n\n2001-06-10  Timothee Besset <ttimo@idsoftware.com>\n\t* rebuilt against PR source, packaged 1.29b setups\n\n2001-05-25  Timothee Besset <ttimo@idsoftware.com>\n\t* graphical setup, based on Loki's setup tool (GPL)\n\n2001-05-22  Timothee Besset <ttimo@idsoftware.com>\n\t* changed fs_basepath to fs_homepath, according to Graeme's changes (probably missed this change?)\n\t  this fixes the q3key prompting at each game startup\n\n2001-05-20  Timothee Besset <ttimo@idsoftware.com>\n\t* rebuilding 1.28b, various fixes on linux build:\n\t  - SetProgramPath was renamed to Sys_SetDefaultCDPath in unix_shared.c\n\t    updated unix_main.c accordingly\n\t  - some prototypes in qgl.h are guarded by #ifndef GL_VERSION_1_2 (ARB extentions)\n\t    those prototypes are needed by linux_glimp for importing functions and casting, added a #ifdef __linux__\n\t    (not a clean solution)\n\t  - game/q_shared.h\n\t    little endian / big endian functions have been added\n\t    gcc generates warnings about functions being unused .. inlined them\n\t   - cgame/cg_marks.c\n\t     // TTimo\n\t     // gcc warning: might be used uninitialized\n\t     float sInc = 0.0;\n             float s = 0.0;\n\n2001-05-15  Timothee Besset <ttimo@idsoftware.com>\n\t* fixes to linux Makefile for bspc 2.1h\n\t* various updates to 1.28b on linux\n\n2001-05-09  Timothee Besset <ttimo@idsoftware.com>\n\n\t* R. Duffy reverted game/bg_pmove.c PM_CheckDuck, was a merging screup on my side\n\t* updated setup to 1.27z, removed the .so from the setup distribution (they were in 1.27g because of issues)\n\t  FIXME: gotta get pk3's first\n\n2001-05-04  Timothee Besset <ttimo@idsoftware.com>\n\n\t* fixes to gcc, building RC for 1.27s\n\n2001-05-01  Timothee Besset <ttimo@idsoftware.com>\n\n\t* added qcommon/huffman.c to the Makefile\n\t* gcc -Wall:\n\tcommenting out \n\t  CL_Netchan_Encode CL_Netchan_Decode (cl_net_chan.c)\n\t  Netchan_ScramblePacket Netchan_UnScramblePacket (net_chan.c)\n\t  SV_Netchan_Encode SV_Netchan_Decode (sv_net_chan.c)\n\n2001-04-26  Timothee Besset <ttimo@idsoftware.com>\n\n\t* fixed dedicated server crash when entering the VM_COMPILED qagame on a mod (some statics lacked initialization)\n\n2001-04-25  Timothee Besset <ttimo@idsoftware.com>\n\n\t* added $(Q3POBJ) to clean target (cleanup of platform-dependent objects)\n\t* more make clean improvements\n\n2001-04-23  Timothee Besset <ttimo@idsoftware.com>\n\n\t* cleanup the mod selection code, remove duplicates\n\t* some issues with release builds, my main developement box doesn't build stable binaries with release settings\n\t  removing -fomit-frame-pointer seems to fix (there's probably a performance hit)\n\t  see OMIT-FRAME-POINTER.txt\n\n2001-04-13  Timothee Besset <ttimo@idsoftware.com>\n\n\t* checked in a first set of merged files\n\n2001-04-06  Timothee Besset <ttimo@idsoftware.com>\n\n\t* merged back the core linux parts to make 1.27g linux build from the Source Safe tree again\n\n2001-02-27  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* CVS: tag with changes as of today\n\t  cvs tag id1-27j-loki01027\n\n\t* code/qcommon/msg.c: numFields loop (SOS).\n\t* code/qcommon/files.c: ue Q_stricmp (SOS uses stricmp, was strcmp).\n\t* code/game/q_shared.h (Q3_VERSION): 1.27j. Also\n\tMAX_STRING_TOKENS upped from 256 to 1024 (SOS).\n\n\t* code/server/sv_snapshot.c (SV_AddEntitiesVisibleFromPoint): see below.\n\t* code/game/g_public.h (SVF_NOTSINGLECLIENT): added (SOS).\n\n\t* code/server/sv_ccmds.c: see below.\n\t* code/game/g_main.c: g_gametype cvar now userinfo (SOS).\n\n\t* code/game/g_active.c (SendPendingPredictableEvents): new (SOS).\n\t* code/game/bg_misc.c: new SOS (sos010227)\n\n\t* SOS: new update sos010227.\n\t\n2001-02-22  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* CVS: now in sync with last SOS and cleanup up\n \t  cvs tag id1-27i-loki01022\n\t\n\t* code/ui/ui_shared.c: below.\n\t* code/ui/ui_main.c: leftover code!\n\t* code/server/sv_world.c: below.\n\t* code/server/sv_snapshot.c: below.\n\t* code/server/sv_init.c: below.\n\t* code/server/sv_game.c: below.\n\t* code/server/sv_client.c: below.\n\t* code/server/sv_ccmds.c: below.\n\t* code/server/sv_bot.c: below.\n\t* code/server/server.h: below.\n\t* code/renderer/tr_surface.c: below. \n\t* code/renderer/tr_shader.c: changed assert to early return.\n\t* code/renderer/tr_shade_calc.c: below.\n\t* code/renderer/tr_shade.c: below.\n\t* code/renderer/tr_scene.c: below.\n\t* code/renderer/tr_mesh.c: below.\n\t* code/renderer/tr_local.h: below.\n\t* code/qcommon/vm_x86.c: cleanup.\n\t* code/qcommon/vm.c: below.\n\t* code/qcommon/unzip.c: below.\n\t* code/qcommon/qcommon.h: below.\n\t* code/qcommon/files.c: below.\n\t* code/qcommon/cvar.c: cleanup.\n\n2001-02-21  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* code/qcommon/common.c: cleanup.\n\t* code/qcommon/cm_trace.c: cleanup.\n\t* code/qcommon/cm_patch.c: cleanup.\n\t* code/qcommon/cm_public.h: cleanup.\n\t* code/game/q_shared.h: cleanup.\n\t* code/game/q_shared.c: cleanup.\n\t* code/game/q_math.c: cleanup.\n\t* code/game/g_syscalls.asm: changed (once more) floor,ceil etc.\n\t* code/game/g_spawn.c: cleanup.\n\t* code/game/g_session.c: cleanup.\n\t* code/game/g_cmds.c: cleanup.\n\t* code/game/g_client.c: cleanup.\n\t* code/game/g_arenas.c: cleanup.\n\t* code/game/bg_slidemove.c: cleanup.\n\t* code/game/bg_pmove.c (PM_CheckDuck): old call to trace?\n\t* code/game/bg_misc.c: cleanup.\n\t* code/game/be_aas.h: dead code.\n\t* code/game/ai_dmq3.c: cleanup. One clear/copy switched?\n\t* code/game/ai_dmnet.c: more //*/. Why oh why not DEBUG....\n\n\t* code/client/snd_mix.c: below.\n\t* code/client/snd_dma.c: below.\n\t* code/client/keys.h: cleanup.\n\tTODO: #error in q3_ui/keycodes.h ?\n\n\t* code/client/client.h: cleanup.\n\t* code/client/cl_main.c: misplaced bracket. Cleanup.\n\t* code/client/cl_keys.c: below.\n\t* code/client/cl_cin.c: below.\n\t* code/client/cl_cgame.c: cleanup.\n\tTODO: define assert for Win32 or guard my assertions.\n\n\t* code/cgame/cg_syscalls.c: below.\n\t* code/cgame/cg_servercmds.c: below.\n\t* code/cgame/cg_players.c: cleanup.\n\n\t* code/cgame/cg_newdraw.c: remember to diff against cg_newDraw.c\n\tin SOS (mixed case).\n\tTODO: get id to use cg_newdraw.c, and to remove cg_newDraw.c/cpp.\n\n\t* code/cgame/cg_main.c: below.\n\t* code/cgame/cg_local.h: below.\n\t* code/cgame/cg_event.c: below.\n\t* code/cgame/cg_drawtools.c: below.\n\t* code/cgame/cg_draw.c: cleanup.\n\t* code/cgame/cg_consolecmds.c: dead code.\n\t* code/bspc/qbsp.h: below.\n\t* code/bspc/l_poly.c: below. \n\t* code/bspc/l_math.c: cleanup.\n\t* code/bspc/bspc.c: cleanup.\n\t* code/bspc/be_aas_bspc.c: cleanup. \n\t* code/bspc/aas_map.c: kept comments - merge loss at their end?\n\t* code/bspc/aas_file.c: cleanup. \n\n\t* code/botlib/be_interface.c: this file is plain impossible. There\n\tare layers of code made dead with /* */ and the resurrected by\n\t//* or // /* or variations of this. I reverted to exact mirror\n\timage of SOS to be sure - short of removing it's too easy to mistake \n\tlive code for dead one.\n\tLater: have to change 5 occurences to avoid gcc complaints about\n\tnested comment tokens.\n\tTODO: somebody please get rid of the cruft in here.\n\n\t* code/botlib/be_ai_move.c: redundant typedef.\n\t* code/botlib/be_ai_chat.c: assertions on signed string index.\n\tNote: this is not in my ChangeLog - ouch.\n\tTODO: use  gcc -fsigned-char on all platsforms to enforce Win32\n\tTODO  behavior (PPC has a default unsigned char, Intel has not).\n\t* code/botlib/be_aas_sample.c (AAS_TraceClientBBox): one code block\n\twas placed in different location, and one FPE hack not used. I would\n\texpect that divide by zero will still occur here.\n\n\t* code/botlib/be_aas_reach.c: below. \n\t* code/botlib/be_aas_cluster.c: cleanup. \n\t* CVS: the last tag (below) marks the version with a lot of history\n\tand additional comments. I am now bringing the codebase in sync with\n\tSOS as of yesterday, cleaning out comments, dead code and other\n\tdifferences to minimize a diff - in a valiant if futile attempt to\n\troll back changes into the id codebase.\n\tNote: I ignore the $SOS$ - these are unfortunate but will change\n\tin the same awkward way at their end.\n\tNote: I stick to #if 0 instead of C comments around dead code id\n\tkept (nested comments issue). The commentary is changed to sosYYMMDD\n\tand includes the token DEAD.\n\n2001-02-20  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* CVS: update, then tag current version as\n\t cvs tag id1-27i-loki010219\n\n\t* SOS: patched up to sos010219.\n\n\t* code/qcommon/cm_trace.c (CM_Trace): fabs on sphere offsets (SOS).\n\t* code/game/bg_slidemove.c (PM_StepSlideMove): stepSize vs. STEPSIZE (SOS).\n\t* code/game/bg_pmove.c (PM_CheckDuck): fix in stand up check (SOS).\n\t* code/bspc/bspc.c (main): -capsule (SOS).\n\t* code/bspc/qbsp.h: below (SOS).\n\t* code/bspc/be_aas_bspc.c (capsule_collision): added (SOS).\n\t* code/bspc/aas_map.c (CapsuleOriginDistanceFromPlane): added and used (SOS).\n\t* code/bspc/aas_file.c (AAS_WriteAASFile): removed diagnostics recently\n\tadded. No matter how long you wait, they'll always get you ;-).\n\t* code/botlib/be_aas_cluster.c: enabled LogWrites, different flood (SOS).\n\n\t* SOS: patching up to snapshot sos010219. \n\tNote: For brevity, I use as marker sosYYMMDD now instead of bkYYMMDD, to \n\tdistinguish from changes not in SOS.\n\n\t*  CVS: tagged current version before patching up with SOS.\n         cvs tag id1-27i-loki010216-bsd\n\n2001-02-16  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* code/server/sv_init.c: DLL_ONLY sets sv_pure to 0 and ROM.\n\tTODO: determine good sv_pure policy for DLL-only servers.\n\n\t* code/renderer/tr_shade_calc.c: my_ftol implementation (BSD).\n\n\t* code/unix/Makefile: FreeBSD sections.\n\tTODO: include target-specific Make-freebsd etc.,\n\tinclude a Make-local not in CVS for build preferences,\n\tand generally clean up this mess.\n\t* code/unix/unix_glw.h: guard #error\n\t* code/unix/linux_snd.c: soundcard.h location (BSD).\n\t* code/unix/linux_glimp.c: guard system headers.\n\tLater: added Joystick stubs.\n\tNote: linux_ etc. prefixes start to loose meaning as we\n\tre-use most of this on UNIXes anyway. I didn't use Raf's\n\tfreebsd_joystick.c but instead put generic stubs here.\n\tTODO: introduce generic -DNO_JOYSTICK flag.\n\t* code/renderer/tr_local.h: my_ftol guard.\n\t* code/renderer/qgl.h: FreeBSD guards.\n\t* code/qcommon/vm_x86.c: sys/types include on FreeBSD.\n\t* code/qcommon/md4.c: Win32 pragma guard.\n\t* code/qcommon/common.c: Com_Memcpy/Memset external.\n\t* code/game/q_shared.h: added FreeBSD defines. \n\t* code/game/q_math.c (BoxOnPlaneSide): FreeBSD conditional.\n\tTODO: check whether we have/need the assembly version anyway.\n\t* code/client/snd_mix.c: use C fallback on FreeBSD.\n\tNote: all of the above changes from the original port by Rafael Barrero.\n\n\t* CVS: tagged current version before merging FreeBSD related changes.\n         cvs tag id1-27i-loki010215-ppc\n\n2001-02-15  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* code/unix/Makefile: BSD related changes.\n\t* code/cgame/cg_draw.c: hacked phone jack rendering check for Debug.\n\tTODO: finish Debug, fix CG_DrawDisconnect !!!\n\n\t* code/unix/vm_x86.c: error on compile attempts. Fight redundancy!\n\t* code/qcommon/vm_x86.c (VM_CallCompiled): dummy for linkage on PPC.\n\tNote: DLL_ONLY is the global Makefile option for DLL-only builts.\n\tCurrently only executed on Linux.\n\t* code/unix/unix_main.c: *ppc postfix for DLLs. Ignored the changes\n\tto redundant code (have to remove the unused Un/LoadDll/API calls).\n\t* code/server/sv_game.c (VMA): changed macro (see below). PPC.\n\t* code/qcommon/vm.c (VM_DllSyscall): see lengthy commentary by Ryan.\n\tThe existing VM code makes certain assumptions about the layout of\n\tvarargs on the stack, which fall apart with call conventions that\n\tdon't even put all parameters on the stack (gcc on PPC, register-rich).\n\tUsing a dedicated memory area as our own stack. This should actually\n\tbe the default behavior.\n\tLater: make vm_* cvars INIT/ROM for DLL_ONLY target.\n\n\t* code/qcommon/common.c: PPC change (from Ryan Gordon).\n\n2001-02-07  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* code/unix/unix_main.c: disabled FPE for debug for the time\n\tbeing (that is, until I can figure out\n          Program received signal SIGFPE, Arithmetic exception.\n          RB_BeginSurface (shader=0x449572e0, fogNum=0) at ..//renderer/tr_shade.c:307\n          307 tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset;\n        without any NaN's involved.\n\tTODO: unmask other FPE's selectively (see Mike's Tribes2, no getenv though).\n\n2001-02-06  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* SOS: up to date with todays snapshot.\n\tNote: got the date wrong, comment used was bk010205. Duh.\n\n\t* code/server/sv_snapshot.c (SV_UpdateServerCommandsToClient): below. \n\t* code/server/sv_main.c (SV_ReplacePendingServerCommands): new (SOS).\n\t* code/server/server.h: reliableSent (SOS).\n\n\t* code/renderer/tr_shade.c (ProjectDlightTexture): see below.\n\t* code/renderer/tr_scene.c: see below.\n\t* code/renderer/tr_public.h: see below (SOS).\n\t* code/renderer/tr_local.h: additive light support (SOS).\n\n\t* code/qcommon/cm_trace.c (CM_Trace): new tw.sphere.use branch (SOS).\n\n\t* code/game/g_spawn.c: notta, notq3a entities (SOS).\n\t* code/game/ai_dmq3.c: MAX_ACTIVATEAREAS search (SOS).\n\t\n\t* code/client/cl_cgame.c: see below.\n\t* code/cgame/cg_syscalls.c (trap_R_AddAdditiveLightToScene): below.\n\t* code/cgame/cg_syscalls.asm: see below (trap_R_AddAdditiveLightToScene).\n\t* code/cgame/cg_public.h: CG_R_ADDADDITIVELIGHTTOSCENE (SOS).\n\t\n\t* code/bspc/l_math.c: new VectorLengthSquared, removed rotate/matrix (SOS).\n\t* code/bspc/bspc.c (BSPC_VERSION): was 2.1e, now?\n\t* code/bspc/be_aas_bspc.c (BotImport_Trace): CM_BoxTrace sig. (SOS).\n\t* code/bspc/aas_file.c (AAS_WriteAASFile): SOS.\n\t* code/botlib/be_aas_sample.c (AAS_DeAllocAASLink): SOS.\n\n\t* code/unix/unix_main.c (Sys_LoadDll): do not load from installdir\n\tin NDEBUG (confusing relic from old Makefile). Postfix -debug.so\n\tfor debug binaries to let both builds coexist.\n\n\t* code/unix/Makefile: updated install targets and VERSION.\n\n\t* Win32: build from SOS snapshot.\n\tNote: Unix CR/LF in *.dsw/*.dsp fucks up MSVC++.\n\n2001-02-02  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* SOS: all changes up to today.\n\n\t* code/server/sv_init.c (SV_TouchCGame): added. Also memset\n\ton reallocated client data (SOS).\n\t* code/qcommon/qcommon.h: see below.\n\t* code/qcommon/cvar.c (Cvar_SetLatched): new (SOS).\n\t* code/qcommon/cm_trace.c: more sphere test fixes (SOS).\n\tNote: SOS encryption key expired and updated by MrElusive.\n\n\t* code/qcommon/cm_patch.c (CM_TraceThroughPatchCollide): \n\tfix from MrElusive, fall through curved corner floors (q3dm17).\n\tLater: also in SOS (so is shadow FPE fix).\n\n\t* Win32: can't get an unadulterated SOS snapshot to build.\n\tFirst, fix CR/LF back again (Linux client converts all).\n\t find . -name '*.ds*' -print\n\t alias dos2unix='recode ibmpc..lat1' \n\t alias unix2dos='recode lat1..ibmpc'\n        Next, find a *.dws that works? Nope, no cigar.\n\t\n2001-02-01  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* Win32: have to update dsp/dsw/etc. files in CVS, too.\n\n\t* CVS: tag previous version before update\n         cvs tag id1-27h-loki010131-beta3\n\n\t* code/game/q_math.c (Q_rsqrt): guard, #ifndef __linux__ \n\tfor assert (for Win32 build).\n\tTODO: assert replacement for Win32?\n\t* code/q3_ui/ui_qmenu.c: see below.\n\t* code/q3_ui/ui_players.c: see below.\n\t* code/q3_ui/ui_controls2.c: float const with f postfix\n\tNote: Win32 C4305 warning. Somebody at id has been doing\n\ta lot of these recently as well...\n\n\t* code/cgame/cg_players.c (CG_PlayerShadow): applied fix by \n\tMrElusive, removed FPE hack (player shadows on zero mormals).\n\tProlly in this evenings' CVS.\n\n\t* code/server/sv_game.c: new signatures (capsule again).\n\t* code/server/server.h: new signatures (SV_Trace,ClipToEntity).\n\t* code/server/sv_bot.c: new signatures (above).\n\t* code/qcommon/cm_trace.c: a truckload of changes. Math\n\tcode added before moved upwards. Capsule traces added all\n\tover the place, old box traces moved in conditional\n\tbranches, functions renamed and wrapped. Eliminated some\n\tof the previous' versions deadcode to keep diffs smaller.\n\tTODO: once a point release is out and reasonably bug\n\tTODO  free, remove // bkYYMMDD annotations where SOS related.\n\n\t* code/qcommon/cm_public.h: new signatures in prototypes.\n\t* code/qcommon/cm_patch.c: dead code re-enabled, new\n\tsections (conditional branches for spheres) added to \n\tseveral trace functions.\n\t* code/qcommon/cm_local.h (CAPSULE_MODEL_HANDLE): added.\n\t* code/qcommon/cm_load.c (CM_TempBoxModel): capsules.\n\n\t* code/game/q_shared.h (Q3_VERSION): 1.27i now (new QVM traps).\n\n\t* code/game/g_syscalls.asm: see below.\n\t* code/game/g_public.h (SVF_CAPSULE): added (SOS). Also\n\tG_ entry poiints for capsule traces.\n\n\t* code/client/cl_cgame.c: see below.\n\t* code/cgame/cg_syscalls.c: see below.\n\t* code/cgame/cg_syscalls.asm: see below.\n\t* code/cgame/cg_public.h: new capsule trace code (SOS).\n\n2001-01-31  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* Win32: test compile (WinCVS, MSVC++). Have to guard isnan.\n\tNote: too much shit going on....\n\n2001-01-30  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* CVS: update for patching up (pre-1.27i).\n\n\t* SOS: new changes (new collision detection primitives).\n\tNow Version 1.27i. \n\tTODO: start testing using DLL's (QVM code is out of sync).\n\n2001-01-25  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* SOS: caught up till today (below).\n\t* code/qcommon/cm_trace.c: new functions added: RotatePoint,\t\n\tTransposeMatrix, CreateRotationMatrix (SOS).\n\t(CM_TransformedBoxTrace): new rotation code used here.\n\n\t* code/q3_ui/ui_demo2.c: sizeof(extension). SOS.\n\t* code/game/g_cmds.c (G_SayTo): CON_CONNECTED.\n\t* code/game/ai_main.c: HOOK added (SOS).\n\t* code/botlib/be_aas_move.c (AAS_HorizontalVelocityForJump): \n\tcorrect fix for FPE occuring (SOS).\n\t* code/game/ai_dmq3.c: initmove.viewoffset (SOS).\n\n\t* code/game/q_math.c: guard asser/isnan with Q3_VM (q3asm).\n\tTODO: define Com_Error based assert macro? NDEBUG?\n\n2001-01-24  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* code/server/sv_ccmds.c (SV_MapRestart_f): some debug.\n\tTODO: map_restart 0 disconnects external client in 1.27h?\n\n\t* code/renderer/tr_image.c (LoadTGA): added some commentary \n\tand dead code based on fixes from GtkRadiant (Leonardo found\n\tflipped TGA's).\n\n2001-01-23  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* BETA3: finished testing, ready to upload to id FTP.\n\tLater: neither the FreeBSD beta not the Linux Beta3\n\tuloaded. Beta2 not yet released, and clients get\n\tdisconnected with Beta2 and Beta3 on SV_MapRestart_f.\n\n2001-01-22  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* code/client/cl_main.c (CL_InitDownloads): undid yesterday (SOS).\n\t* code/botlib/be_aas_sample.c (AAS_DeAllocAASLink): guard print (SOS).\n\t* code/server/sv_client.c (SV_DirectConnect): VM_Call disconnect (SOS).\n\t* code/qcommon/files.c (FS_ListFilteredFiles): trailing slashes (SOS).\n\t* code/game/g_cmds.c (SetTeam): print change (SOS).\n\tNote: the above plus VectorClear(v1) (below) are todays SOS changes.\n\n\t* code/cgame/cg_players.c (CG_PlayerShadow): ignore bogus \n\t(all zero) planes. This caused FPE in ProjectPointOnPlane.\n\tTODO: why does trace return zero normal planes?\n\tNote: gdb seems totally at loss with vec3_t arrays....\n\n\t* code/botlib/be_aas_sample.c (AAS_TraceAreas): FPE.\n\tNaN in uninitialized v1 that wasn't supposed to be referred \n\tto in this branch. \n\n\t* code/botlib/be_aas_move.c (AAS_HorizontalVelocityForJump): \n\tFPE divide by zero (zero zvel, zero t) for jump estimates.\n\n\t* code/client/cl_main.c (CL_Frame):1856. uivm==NULL on\n\tclient after server crashed.\n\tTODO: check that uivm always non-NULL for client.\n\tTODO: do setenv(FX_NO_SIGNALS) to avoid exit errors...\n\n\t* code/unix/linux_glimp.c (GLW_SetMode): added \"Indirect\"\n\tMesa token to software rendering detection. Reworded error\n\toutput and added drivername.\n\tTODO: measure framerate instead?\n\n2001-01-21  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* SOS: caught up with changes up until today. \n\n\t* code/server/sv_init.c (SV_SetConfigstring): gentity != NULL \n\n\t* code/server/sv_client.c: connect to \"{all bots\" server.\n\t* code/renderer/tr_init.c: JPEG extension on  screenshots\n\t* code/qcommon/files.c: modes based on mods, fs_basegame\n\n\t* code/q3_ui/ui_demo2.c: dm3 extension (demo names, protocol).\n\n\t* code/game/g_client.c: savedEvents[] removed.\n\t* code/game/bg_misc.c: event sequence fixes.\n\t* code/client/snd_dma.c (S_StopBackgroundTrack): different use.\t\n\t* code/client/cl_main.c: demo file handling changed (names).\n\tAlso CL_InitDownloads: always next download.\n\n\t* code/cgame/cg_servercmds.c: cg_thirdPerson.\n\t* code/cgame/cg_weapons.c: see below.\n\tAlso CG_ShotgunPattern: different call (seed parameter).\n\n\t* code/cgame/cg_main.c: see below.\n\t* code/cgame/cg_local.h: new cg_noProjectileTrail Cvar.\n\t* code/cgame/cg_effects.c (CG_BubbleTrail): early out (above).\n\n\t* code/bspc/l_poly.c (BOGUS_RANGE): increased.\n\t* code/bspc/bspc.c: applied patch up to \"2.1e\"\n\n2001-01-18  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* code/ui/ui_main.c: below.\n\t* code/q3_ui/ui_main.c: UI_HASUNIQUECDKEY comment.\n\tNote: mods have to return qfalse. See Bug #2890 in Fenris.\n\n2001-01-17  Bernd Kreimeier  <bk@lokigames.com>\n\t\n\t* BETA2: finished testing, uploaded to id's FTP for release.\n\t\n2001-01-16  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* CVS: checking in preparation for Beta2.\n         cvs tag id1-27h-loki010116-beta2\n\n\t* SOS: new bspc \"2.1e\". No change on 1.27h.\n\n\t* TEST: patch-up seems to work fine. No new files have been added\n\tto the linkage (i.e. the ft2/ files now added), so we might not be\n\tfeature complete.\n\n\t* code/game/g_active.c (ClientThink_real): id MISSIONPACK\n\tconditional in addition to the ones I added earlier.\n\t* code/qcommon/files.c: REJECT. Linux hack for userdir threw it off.\n\t* code/qcommon/unzip.c: REJECT. CRC-32 section removed.\n\tLater: unused tempB\n\n\t* code/q3_ui/ui_syscalls.asm: REJECT. Start/StopBackgroundTrack.\n\t* code/ui/ui_syscalls.asm: REJECT. syscalls ids from 1.27h \n\tas of SOS (floor/ceil - will this ever get straightened out)\n\t* code/win32/win_input.c: REJECT. g_pMouse edit.\n\t* ui/menus.txt: REJECT. Replaced with 1.27h version.\n        Note: some more due to $SOS$.\n\t\n\t* ui/: new scripts.\n\tcinematicmenu.menu, demo_quit.menu, ingame.txt, serverinfo_old.menu\n        vid_restart.menu\n\n\t* code/ft2/ttconfig.h: below.\n\t* code/ft2/sfconfig.h: below.\n\t* code/ft2/pstables.h: below.\n\t* code/ft2/psnames.c: below.\n\t* code/ft2/psdriver.h/c: below. \n\t* code/ft2/keys.h: below. \n\t* code/ft2/ftbbox.c: new in 1.27h\n\t\n\t* code/cgame/cg_newdraw.c: beware: cg_newDraw.c gets lost in diff easily.\n\n\t* code/cgame/cg_rankings.c: file removed from SOS.\n\t\n2001-01-15  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* Patch-up: patching up from RC4 to 1.27h current.\n\tNo changes since 010112 snapshot.\n\tln -s sos010112/ work\n \tdiff -urbB sos001204-rc4/ work > work.diff\n \tln -s cvs-1.27g/ work\n \tpatch -p0 < work.diff  > work.patch\n \tfind cvs1.27g/ -name '*.rej' -print\n\n\t* SOS: adding the remaining SOS snapshots to CVS.\n         cvs import Quake3_sos sos001211 pr1-27g-win32-001211\n\tNote: at this point id warned about repository corruption.\n\tWatch out for the syscall stuff in particular.\n\t cvs import Quake3_sos sos010104 pr1-27g-win32-010104\n\t cvs import Quake3_sos sos010108 pr1-27h-win32-010108\n         cvs import Quake3_sos sos010110 pr1-27h-win32-010110\n\t cvs import Quake3_sos sos010112 pr1-27h-win32-010112\n\tNote: the first 1.27h might be the public (server only) \n\tbeta released, the second one was post release. Beware\n\tof source files added and removed (botlib headers, FT2).\n\tNote: why so late? Don't ask...\n\n2001-01-08  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* SOS: id's working up to 1.27h (server side fix for\n\tGuard exploit seems to force earlier release). Updating\n\tCVS (most of the changes are debug code put in and\n\tthen disabled, plus some fixes as below). Next patching\n\tup to current SOS.\n\n2001-01-07  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* Makefile: need to rework this for multiple platforms.\n\tWe also need null/null_vm.c for platforms where we don't\n\thave JIT (assembly emit).\n\n2001-01-04  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* code/q3_ui/ui_connect.c (UI_DisplayDownloadInfo): time\n\tinformation for current (vs. start of download) is wrong,\n\tthus negative 1 \"estimated time\", as well as transfer\n\trate just negative downloadSize. Not fixed.\n\t\n\t* code/unix/unix_main.c (Sys_ParseArgs): added.\n\tNote: for support/us, to identify builts. This is only\n\ta skeleton right now - if I ever feel the need to support\n\tmore than \"-v\" and \"--version\" I'll have to flesh this out.\n\n\t* code/unix/linux_glimp.c (signal_handler): see below.\n\t* code/unix/unix_main.c (Sys_Exit): added an abstraction\n\tlayer for exit/_exit/assert/raise issues.\n\tNote: need both a better debug/backtrace handling, and\n\thave to find a way to determine why/where the alleged\n\tstartup/exit errors happen...\n\n2001-01-03  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* code/game/g_mem.c (G_Alloc): ERR_DROP initiated by\n\taddbot commands for large sv_maxclients, allegedly\n\tcaused segfaults in 1.17. Not reproducible.\n\tTODO: recover more gracefully from failure to add bot?\n\n\t* code/renderer/tr_light.c (R_LightForPoint): Tim Angus\n\treports a crashbug with nolight maps. Also assertion in\n\tR_SetupEntityLightingGrid, might want conditional there.\n\tDONE: fixed crash on LightForPoint for nolight maps.\n\n\t* code/qcommon/qcommon.h: NUM_SERVER_PORTS. A feature \n\trequest to increase this, or make it more flexible\n\totherwise (Fenris).\n\tTODO: id decision on more flexible NUM_SERVER_PORTS.\n\n2001-01-02  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* code/unix/snapvector.nasm: fixed FPU bit (the current\n\tone had reserved bits off, behavior should not change).\n\t* code/qcommon/vm_x86.c: fixed symbols (below).\n\t* code/unix/ftol.nasm: FPU bits weren't correct (duh).\n\tDONE: shoot-though floor (q3dm5)\n\tDONE: cursor-in-rect off  (TA/Player model selection)\n\tNote: in gdb, \"disassemble <funcname>\" is your friend.\n\n\t* code/cgame/cg_public.h:  CG_MEMSET is set to 100. In\n\tcg_syscalls.asm it's 101. If I change it I get Bad trap 100\n\tfrom the cgame VM code, so the 1.27g \"official\" VM code\n\tuses it.\n\n\t* code/unix/linux_common.c: have to fall back to C, the\n\tcurrent assembly is buggy...\n\t* code/unix/Makefile (linux_common.o): added.\n\tLater: also for dedicated. Less portable this way.\n\tTODO: C_ONLY for dedicated on non-i386 only?\n\n\t* code/qcommon/common.c: do not use memcpy/memset under Linux.\n\t* code/unix/linux_common.c: added Andrew's assembly port.\n\tTODO: C_ONLY for Com_Memset/Memcpy? Conditionals are fubared.\n\n\t* code/qcommon/vm.c (VM_Init): use Win32 defaults (do not\n\tuse DLL's by default). This exposes DLL rounding errors\n\t(damage through floors), and we don't want DLL's used by\n\tdefault anyway.\n\tTODO: why vm_ui default of 1?\n\n\t* code/botlib/l_precomp.c (SourceWarning): removed assert.\n\n\t* code/game/bg_lib.c (acos): defined, but we don't actually\n\tuse it except where the cg_syscalls.asm trap is used.\n\n\t* code/game/g_public.h: missing lots of trap tokens.\n\t* code/game/g_syscalls.c: missing lots of traps.\n\t* code/game/g_syscalls.asm: more inconsistent hooks, were:\n\t equ floor\t\t\t\t\t-111\n         equ ceil\t\t\t\t\t-112\n\t equ testPrintInt\t\t\t        -113\n         equ testPrintFloat\t\t\t        -114\n\tnow changed to match cg_syscalls.\n\tNote: fixed this in UI earlier, how did this slip through \n\tthe diffs against SOS?\n\t\n\t* code/game/g_syscalls.c: no acos hook.\n\t* code/cgame/cg_syscalls.c: no acos hook.\n\t* code/cgame/cg_syscalls.asm: has acos hook as -112\n\tNote: report from Tim Angus. The acos function is in bg_lib.c\n\twhich is linked only into ui (not q3_ui). That means we are\n\tusing libc acos right now?\n\tNote: QVM traps are negative?\n\n\t* BSD/Irix: tagged current CVS (not all of the below) as\n\t cvs tag id1-27g-loki010102-bsd1\n\tfor BSD work (Rafael Barrero). Also be used for Irix update.\n\n2001-01-01  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* SOS: adding the remaining SOS snapshots to CVS.\n         cvs import Quake3_sos sos001201-rc3 pr1-27f-win32-001201-rc3\n         cvs import Quake3_sos sos001202 pr1-27f-win32-001202\n         cvs import Quake3_sos sos001204 pr1-27g-win32-001204-rc4\n\tThis is the codebase to which the Linux branch has been patched\n\tup. I can't verify whether this is identical to the RC4 codebase\n\tas the tag doesn't work (but can check against the ZIP file..)\n\t cvs import Quake3_sos sos001211 pr1-27g-win32-001211\n\tThe above snapshot contains a (post-release?) fix to ui_syscalls\n\tin ui/ and q3_ui/. This change has been used in Linux (Beta1 and\n\tabove). At this point, id discouraged further use of SOS due to\n\trepository corruption on their end. No further snapshots were\n\ttaken since.\n\n\t* Fenris: since the release of the Beta1 bugs have been\n\tmaintained at http://fenris.lokigames.com/. I am going to\n\tlist issues here as they get fixed.\n\t\n2000-12-21  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* code/renderer/tr_font.c: graceful silence with old mods?\n\t* code/botlib/l_precomp.c (SourceWarning): graceful exit if old mod?\n\n2000-12-20  Bernd Kreimeier  <bk@lokigames.com>\n\t\n\t* code/server/sv_ccmds.c (SV_MapRestart_f): see below.\n\t* code/qcommon/vm.c: currentVM is 0x0 in VM_ArgPtr.\n\tIn VM_Call, oldVM was NULL - made conditional the\n\treset of currentVM to oldVM.\n\n2000-12-18  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* BETA1: closed Linux beta release. Stripped debug\n\tand release binaries, DLL's, and pak4.pk3. CVS checkin,\n\twill be tagged as \n            cvs tag id1-27g-loki001218-beta1\n\tLater: id added a pak5.pk3 to the Win32 point release,\n\tadded this to the BETA1 best.\n\n\t* code/qcommon/vm_x86.c: C37F.\n\t* code/unix/snapvector.nasm: C37F.\n\tNote: short of any real evidence, I gamble and use max. \n\tprecision (as well as default Linux precision, but NOT \n\tWin32 precision). It seems that precision change is not \n\treally an issue (despite Graeme's claim that the cursor\n\tin the menu was/is off). I also pick the roundiung behavior\n\tthat is seemingly used by ANSI and gcc (but possibly not\n\tWin32 _ftol depending on build).\n\n2000-12-15  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* code/unix/Makefile: added snapvector.o\n\t* code/unix/unix_shared.c: #if 0'ed the old snapvector code.\n\t* code/unix/snapvector.nasm (Sys_SnapVectorCW): two new\n\tassembly functions from AndrewH that explicitely set the \n\tFPU control word to convert vec3_t, to ensure cross-platform \n\tbehavior for both DLL and QVM.\n\n\t* code/unix/ftol.nasm (Q_ftolC37F): for globals. \n\n\t* code/unix/unix_main.c: took out global FPU manipulation.\n\tFor clarity this should be VM only.\n\t* code/qcommon/vm_x86.c: added prototypes for the ftol\n\tlibrary. To select a specific behavior for the entire VM,\n\tset ftolPtr accordingly.\n\tLater: the GCC ftol function of course affect the stack\n\t(there is no \"declspec naked\"). The problem seems to be \n\tthat the VM never handles the stack in a way compatible \n\tto regular gcc C functions. For some odd reason _ftol seems \n\tto do the right thing under Win32. All 4 control words \n\timplemented at the moment work just fine with the menus.\n\n\t* code/unix/ftol.nasm: added a small library of \"safe\" qftol\n\tvariations that explicitely set the control word to the\n\trelevant (4) possibilities.\n\n2000-12-13  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* code/qcommon/vm_x86.c: an entire day spent trying to nail\n\tthe ftol issues. It breaks down like this: id used to use\n\tan unsafe (no setting FPU control word) fistp. That seemingly\n\tcaused subtle physics bugs which nobody cared about in 1.17.\n\tThey then changed the UI code, and ran into the UI bugs:\n\tmenu entries shifted to the right, fonts vanishing. Then\n\tthey switched to using _ftol. Then they had to reproduce \n\tthe old behavior for the physics code due to public outrage.\n\tMy original port used a simple (long)float cast, which gcc\n\tseemingly compiles to code that does OR 0C00 on whatever\n\tcurrent control word (precision unchanged). This breaks the\n\tmenus. If I use the unprotected fistp instead, which should\n\t(Linux 037F default) use \"nearest/even\", then my menus are\n\tcorrect. That would mean Win32 _ftol in id's compile does\n\tthe same, only that would require /qifist or some equivalent\n\tcompile flag, which I can't find. Two disassemblies of _ftol\n\tI got from others showed OR 0C00 as part of the default (ANSI)\n\tbehavior.\n\n2000-12-13  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* code/game/bg_pmove.c (PmoveSingle): trap_SnapVector.\n\tThe one true and single call to snap velocity.\n\tNote: bspc/map.c:void SnapVector(vec3_t normal)\n        qcommon/cm_patch.c:void CM_SnapVector(vec3_t normal)\n\tgame/q_shared.h: #define SnapVector(v) {v[0]=((int)(v[0]));...\n\n\t* code/client/cl_cgame.c: CG_SNAPVECTOR. \n\t* code/server/sv_game.c:  G_SNAPVECTOR.\n\tNote: these go through trap_SnapVector in syscalls.\n\n\t* code/unix/unix_shared.c (Sys_SnapVector): sticking to\n\told Linux version for now...\n\t* code/win32/win_shared.c (Sys_SnapVector): changed.\n\tNote: Graeme points out this was changed to fix ftol\n\tartifacts?\n\tTODO: calculate errors for various ftol variants...\n\n\t* code/qcommon/vm_x86.c: both the old fistp code (1.17)\n\tand the new qftol function apparatently work. Using the\n\tftol.nasm code for now.\n\n\t* code/unix/Makefile: DO_NASM and ftol.o. \n\n\t* code/unix/ftol.nasm (qftol): created from Mike's SoF\n\treplacements, with Andrew's help to satify the VM\n\tstack/call requirements.\n\tTODO: use Q_ftol herein to replace myftol elsewhere.\n\n\t* code/unix/unix_main.c (Sys_ConfigureFPU): SIGFPE. \n\tTODO: divide by zero in botlib. Disable this for now.\n\tNote: we can't introduce calculation differences between\n\tversions, so fixing these will have to wait.\n\n\t* code/qcommon/vm_x86.c: two new lines in Win32 branch \n\tmissing from Linux assembly in AsmCall:\n\t mov eax, dword ptr [edi] \n\t and eax, [callMask]      \n        Added, doesn't seem to affect UI etc. bugs.\n\tLater: no FTOL_PTR, use fistp non-IEEE assembly as in old\n\tversion. This seems to work for Q3 and TA, while qftol \n\t(simple cast) does not - for Win32 Graeme says the reverse \n\tis true.\n\n\t* code/qcommon/vm_x86_old.c: used the old cvs-1.17 version.\n\tTwo fixes (Hunk_Alloc, Com_Memcpy), and it works:\n\t  +set vm_game 2 +set vm_ui 2 +set vm_cgame 2 \n        UI, cgame and game w/o apparent problems.\n\n2000-12-12  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* code/unix/Makefile: cleanup of redundant flags.\n\tRemoved bogus MALLOC_CHECK (note to self: export MALLOC_CHECK_=2).  \n\tAlso DO_SHLIB_CC on all UI DLL's.\n\tAdded and removed DEBUG_VM flag.\n\tTODO: figure out whether Zoid did UI this way intentionally.\n\tNote: this seemingly fixed the botimport problem, although\n\tmost of the changes were just redundant CFLAGS removed. Given\n\tour wanker toolchain, should have been more paranoid. All\n\tDLL's can now be used w/o apparent problems.\n\n\t* code/server/sv_main.c: gvm init.\n\t* code/server/sv_game.c: gvm assertions.\n\t* code/unix/unix_main.c (Sys_LoadDll): print vmMain\n\tNote: top no avail. There is some odd ld/gdb problem here\n\tthat prevents examining globals and obfuscates part of\n\tthe stack between VM_Call and lower level code, through\n\tG_InitGame. This is not just DLL's being loaded and unloaded.\n\tWromg flags during build? The vmCvar for \"bot_developer\"\n\tends up overlapping global botimport in memory, which\n\tthus zero-fills part of the function pointer table.\n\n\t* code/server/sv_bot.c (SV_BotInitBotLib): this (by way of\n\tGetBotLibAPI) is responsible for setting botimport, which,\n\tif using the game DLL, is not properly set up. Called in\n\tSV_Init().\n\n\t* code/game/q_shared.c: Q_strncpyz does zero padding (duh).\n\tNote: calls strncpy, which does a zero fill up to destsize.\n\tIf destsize exceeds memory size, zero padding will overwrite\n\tadjacent memory. Suspicion was this happend to botimport.\n\n\t* code/qcommon/cvar.c: possible problem in Q_strncpyz call.\n\n\t* code/botlib/be_ai_weap.c (weaponinfo_fields): made this static.\n\tNote: it seems that the \"number\" string got replaced by\n\t p def.fields[0]\n         {name = 0x40000000 \"\\177ELF\\001\\001\\001\", offset = 2, type = 50, ..\n        Memory corruption?\n\n\t* code/game/inv.h (WEAPONINDEX_GAUNTLET): defined here. \n\t* botfiles/weapons.c (Gauntlet): the baseq3/qagamei386.so parser\n\tbreaks here:\n\t number\t\t\t\tWEAPONINDEX_GAUNTLET\n\t* code/botlib/l_precomp.c (SourceWarning): added assertion to\n\ttrap botlib parsing problem..\n\n\t* RC1: for beta test. Using my own vm/ui.qvm files in this case.\n\tTODO: Setup with nouninstall.\n\tTODO: fix game DLL/ botlib setup problem (so all DLL's work)\n\tTODO: SIGFPE\n\tTODO: profile?\n\t\n\t* code/unix/Makefile (ai_vcmd.o): added to game DLL linkage. \n\tHow the fuck did this happen?\n\tDONE: \"qagamei386.so: undefined symbol: BotVoiceChat_Defend\"\n\n\t* TEST:  +set vm_ui 2 (vm_x86, not interpreter). Breaks!\n\tFurther: qagame had undefined, but seemingly gets reloaded \n\tsecond try (I hate the Linux linker).\n\t* TODO: never reload fail DLL, abort engine\n\n\n2000-12-11  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* TEST: recompile QVM/DLL and executable to test new UI code.\n\tThe UI QVMs from the paks still do not work.\n\n\t* SOS: changes in UI code!\n\t* code/q3_ui/ui_public.h: this file is deprecated\n\tNote: e.g. it does not contain the background track calls.\n\t* code/ui/ui_public.h: the uiImport_t enum here determines\n\tthe values.\n\t* code/ui/ui_syscalls.asm: same as q3_ui now, were:\n         equ floor\t\t\t\t\t-111\n\t equ ceil\t\t\t\t\t-112\n\t* code/q3_ui/ui_syscalls.asm: these are now switched, were:\n\t equ trap_S_StartBackgroundTrack\t\t\t-63\n         equ trap_S_StopBackgroundTrack\t\t\t\t-64\n\tThe new values match the ui/ equivalent. Also, floor (-108) \n\tand ceil (-109) are different in ui/.\n\t\n\t* CVS: going to check in this snapshot and tag it as\n\t    cvs tag id1-27g-loki001209-rc4\n\tPresumed equivalent to SOS tag \"1.27g RC4\" (master). As I can't\n\tobtain the tagged code using SOS (neither Win32 nor Linux client)\n\tI can only guess.\n\n\t* TEST: use my own VM code, ion baseq3/vm/*.qvm and missionpack/vm/.\n\tThis works - in other words, the menu bug seems in the UI code, and\n\tis fixed in my codebase.\n\n\t* TEST: make release. \n\tNote: I can postpone DLL specific problems. Bad performance is not\n\tas important as outright bugs. Thus the UI QVM issue is the only\n\tone that stops me from creating an RC.\n\tTODO: Q3 UI QVM code from pak file does not work (neither does TA).\n\tTODO: sound with video playback still awful. Threaded sound, I guess.\n\tTODO: ERROR: couldn't open demos/DEMO002.dm3.dm_48 (same demo001.dm3.dm_48)\n\t\n\tTODO: do not show Q3 demos in TA menu?\n\tTODO: new demos for Q3? Or at least error message?\n\t\n\t* code/game/bg_lib.c: itrinsics excluded by Q3_VM (another -O\n\tcompile). Uninitialized variable.\n\t* code/unix/Makefile: -O for uninit on patched code. Also shortcuts. \n\tTODO: DC_ONLY seems an obsolete flag, used in Makefiles, not source.\n\n\t* TEST: +set sv_pure 0 +set vm_game 1 +set vm_cgame 1 +set vm_ui 0\n\tTurns out that the pak0.pk3 UI QVM code is seemingly broken in TA\n\tand Q3, but my UI DLL is not. In reverse, the QVM game/cgame for\n\tQ3 seems to work quite well (including bots). The TA game/cgame\n\talso works, including botlib init.\n\tTODO: BotLib Init using game DLL gives: \n\tTODO:  Error: file weapons.c, line 38: unknown structure field number\n        TODO:  Fatal: couldn't load the weapon config\n        TODO:  Error: BotLoadMap: bot library used before being setup\n\t\n\t* TEST: checked the rc4winstlr.zip CD tree against\n\tmy test install. baseq3/pak4.pl3 and missionpack/pak0.pk3\n\tare identical, but I finally recognized that there was\n\ta missionpack/pak1.pk3 not in the final install - left over \n\tfrom an earlier update from id. Doesn't seem to affect the\n\tDLL based runs at all.\n\tNote: I still do not have the final CD snapshot Robert\n\tpromised me mid last week, they haven't even fixed the\n\tFTP account they took down. Communication with id is as\n\tabyssmal as ever. \n\n2000-12-08  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* TEST: running with RC4 data files.\n\tTODO: \"bot library used before setup\" (Q3+TA)\n\tTODO: Q3 old mods wreak havoc (graceful bounce)\n\tTODO: supress \"FreeType code not available\" in renderer\n\tTODO: can't move in Q3\n\tTODO: items flicker in Q3\n\tTODO: no decals in Q3\n\tTODO: VM UI code still broken (Q3+TA)\n\tTODO: sound code is awful\n\tTODO: video playback inferior to earlier builds\n\n\t* code/q3_ui/ui_local.h: prototype trap_VerifyCDKey(..)\n\t* code/game/g_active.c ( StuckInOtherClient): TA only.\n\t* code/cgame/cg_draw.c: 4x unbalanced `#endif' - from patch?\n\t* code/null/null_client.c (CL_CDKeyValidate): dummy added.\n\t* code/qcommon/common.c: Q_acos missing, changed conditionals\n\t\n\t* code/qcommon/vm_x86.c: unreacheable _asm instruction that\n\tgcc doesn't quite like... #if 0'ed for now\n \tTODO: understand _asm { mov eax,[ebx] }, fix it for gcc\n\n\t* TEST: compile...\n\n\t* code/ui/ui_main.c: full REJECT. Manual merge.\n\tNote: preserved debug_protocol lines, who knows what it's good for.\n\n\t* code/qcommon/files.c: REJECT. SafeMode, demo server FS_Restart.\n\n\t* code/client/snd_mem.c: REJECT: $SOS$.\n\t* code/client/snd_dma.c: REJECT: $SOS$.\n\t* code/client/cl_cin.c: REJECT. com_timescale, $SOS$.\n\n\t* code/cgame/cg_draw.c: REJECT. Lots, but virtually all either\n\tfloat postfix (on some, not all places), or #ifndef MISSIONPACK\n\tthat I had already put in during -Werror (conditional unused).\n\n\t* code/cgame/cg_consolecmds.c: REJECT. id commented unused code\n\tthat I had #if 0'ed earlier.\n\n\t* code/game/: three REJECT for $SOS$.\n\t* code/botlib/: lots REJECT for $SOS$.\n\n\t* Patch: patching up from demo source.\n\tln -s sos001204-rc4 work\n \tdiff -urbB sos001122-demo/ work > work.diff\n \tln -s cvs-1.27b/ work\n \tpatch -p0 < work.diff  > work.patch\n \tfind cvs1.27b/ -name '*.rej' -print\n\n\t* CVS: going to check in this snapshot and tag it as\n\t    cvs tag id1-27b-loki001208-demo\n\tThen patching up to RC4, as of sos001204-rc4 (no changes since,\n\tshould be equivalent to SOS tag \"1.27g RC4\" (raduffy), i.e. master.\n\n\t* TEST: installed demota/ from Win32 distribution. Binary\n\tfails claiming \"Corrupted pak0.pk3\". Abandoned.\n\tNote: a Linux demo for Q3TA has no priority. Most important is\n\tthe Q3A point release in time for Q3TA hitting shelves, followed\n\tby testing for Q3TA. The source is in CVS and tagged (see above)\n\tin case a demo matching the released files has to be provided\n\tlater.\n\t\n\n2000-12-07  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* TEST: compile and link - succeeds.\n\n\t* code/ui/ui_main.c: UI_StopServerRefresh now uaws. \n\tNew unused variables.\n\t\n\t* code/unix/unix_main.c: added  Sys_LowPhysicalMemory() stub.\n\tTODO: write Linux equivalent to GlobalMemoryStatus.\n\n\t* code/qcommon/common.c: Com_Memset/Com_Memcpy. Neither assembly \n\tnor C versions included if not on Win32 i386. \n\tTODO: using/porting assembly?\n\n\t* code/qcommon/files.c: unused variable.\n\tTODO: fs_scrambledProductId unused if 0 for now.\n\tNote: -DFS_MISSING for id's pak cleanup, not used.\n\n\t* TEST: compile and link - fails.\n\n\t* code/macosx/Client/Makefile.postamble: empty ORIG.\n\t* code/macosx/Client/Makefile.preamble: ORIG. $(BOTLIB_OBJS) added.\n\n\t* code/server/sv_client.c: ORIG. Com_Memset.\n\t* code/renderer/tr_shader.c: ORIG. Com_Memset, CIN_Shader.\n\t* code/qcommon/vm_x86.c:  ORIG. Com_Memcpy. \n\t* code/qcommon/unzip.c: REJECT. Com_Memcpy, $SOS$. \n\t* code/qcommon/qcommon.h: ORIG. PROTOCOL 47, plus Sys_LowPhysicalMemory.\n\t* code/qcommon/md4.c: Com_Memset,Com_Memcpy (ORIG).\n\t* code/qcommon/files.c (Sys_ConcatenateFileList): REJECT.\n\tOur additons threw it off, plus $SOS$. \n\t* code/qcommon/common.c: they fixed same unused variables (REJECT).\n\n\t* code/ui/ui_shared.c: additions (ORIG).\n\t* code/ui/ui_gameinfo.c: COM_Compress added (ORIG).\n\t* code/ui/ui_atoms.c: print statements removed (ORIG).\n\t* code/ui/ui_main.c (UI_DoServerRefresh): REJECT on comment edit... \n\n\t* code/game/g_cmds.c (Cmd_VoiceTaunt_f): logic changed heavily. ORIG.\n\t* code/game/q_shared.h: Q3_VERSION \"Q3 Team Arena Demo 1.27b\"\n\tplus Com_Memset, Com_Memcpy, CIN_shader, COM_Compress.\n\t* code/game/g_main.c: Cvar change only\n\t* code/game/ai_dmq3.c: $SOS$.\n\n\t* code/client/snd_mix.c: Com_Memset\n\t* code/client/client.h: additions (ORIG).\n\t* code/client/snd_mem.c: see below.\n\t* code/client/snd_dma.c: $SOS$ (CVS keyword).\n\n\t* code/client/cl_cin.c: they removed unused (REJECT).\n\t* code/cgame/cg_servercmds.c: ORIG. compress, noTaunt etc.\n\t* code/cgame/cg_main.c: ORIG. Conditonal branch, COM_Compress.\n\t* code/cgame/cg_consolecmds.c: ORIG. Cvar values changed.\n\t* code/cgame/cg_draw.c (CG_DrawTeamBackground): ORIG. \n\tno reject but *.orig file created. I just mark spots were \n\tcode changed after verifying the patch succeeded.\n\n\t* code/cgame/cg_event.c: fixed reject (REJECT).\n\t* code/botlib/: all *.rej here due to SOS/CVS $Keyword$.\n\tTODO: preserve SOS comments/rev history somehow.\n\n\t* Patch: patching up to demo source.\n\tln -s sos001122-demo work\n \tdiff -urbB sos001119/ work > work.diff\n \tln -s cvs-1.26/ work\n \tpatch -p0 < work.diff  > work.patch\n \tfind cvs1.26/ -name '*.rej' -print           \n\t\n\t* CVS: going to check in this snapshot and tag it as\n\t  cvs tag id1-26w-loki001207\n\tto prepare for upgrading to RC4. I have already made\n\tmany more changes than I wanted to w/o getting any \n\tcloser to pinpointing the problem, I might as well\n\tpatch up to id's more current sources.\n\n\t* code/botlib/be_interface.c: initialize by memset. Turns\n\tout that this fails in Export_BotLibSetup on BotSetupWeaponAI\n\tloading \"weapons.c\" (from the pak, presumably) with an unknown\n\tstructure field number. Mismatch of datafiles vs. source again.\n\t\n\tTODO: id replaced memsets in later source.\n\tTODO: have memsets on all exports and imports.\n\n\t* SOS: RC4 source should be tagged \"1.27g RC4\" (raduffy).\n\tUnfortunately the Linux client doesn't care a bit. Show\n\tHistory does work if from/to date differ by at least a\n\tday, and it shows the tag on code/ (only that subtree),\n\tbut recursive get aborts halfway.\n\tManual: http://www.sourcegear.com/SOS/Doc/\n\n2000-12-06  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* TEST: accepting missing shaders now. No bots, but I can\n\tactually enter the game and play (more than can be said for\n\tclassic Q3 right now).\n\tTODO: Error: BotStartFrame: bot library used before being setup\n\n\t* code/renderer/tr_shader.c: took out assertion for now...\n\t* TEST: now missiopack/cgame loads\n\tTODO: tr_shader.c:2275: R_FindShaderByName: failed \n\tTODO: searches ui/assets/3_cursor2.TGA, has ui/assets/3_cursor3.tga\n\t\n\t* code/unix/Makefile (MPCGOBJ): ui_shared.o (duh).\n\tDONE: /cgamei386.so: undefined symbol: PC_Float_Parse\n\t\n\t* code/botlib/be_ai_goal.c: initialize campspots etc. This\n\tmight or might not fix this one (didn't get back to gdb due\n\tto mouse-only navigation).\n\tDONE: 0x80d1d5b in BotFreeInfoEntities () at be_ai_goal.c:447\t\n\n\t* TEST: this time with missionpack/cgame loading... noy\n\tTODO: TA menu blocked after end of intro movie\n\tTODO: console in_mouse 1 doesn't grap pointer even on vid_start?\n\n\t* code/cgame/cg_newdraw.c: -Werror.\n\t* code/unix/Makefile (MPCGOBJ): cg_newdraw.o was missing (duh).\n\tDONE: missionpack/cgamei386.so: undefined symbol: CG_OwnerDrawVisible\"\n\n\t* code/ui/ui_shared.c:1309 assign after bail on NULL.\n\tDONE: segfault in Item_SetFocus (item=0x0, x=0, y=0)\n\n\t* TEST: new set of DLL's (this time hopefully correct).\n\tAll baseq3/ DLL's load, as does the missionpack/ UI DLL.\n\tThe menus now work in both (TA seems mouse-only on everything \n\tbut \"Quit\"). Segfault on delayed TA \"Quit\" (stack fubared):\n\t#5  0x809fc28 in VM_Call (vm=0x88408a0, callnum=3) at ..//qcommon/vm.c:617\n\t#6  0x805aafc in CL_KeyEvent (key=9, down=qtrue, time=128644) cl_keys.c:1194\n\tTODO: TA menu's w/o mouse? \n\tTODO: Win32 goes submenus but does not unfold\n\tTODO: Linux does not go submenus\n\t\n\t* code/ui/ui_main.c: see below. \n\tTODO: LCC gets fits -  operands of = have illegal types \n\tTODO: 'pointer to const unsigned char' and 'pointer to const char'\n\t* code/ui/ui_shared.c: see below.\n\t* code/ui/ui_gameinfo.c: see below.\n\t* code/ui/ui_atoms.c: see below.\n\t* code/game/g_bot.c: more cruft.\n\t* code/cgame/cg_draw.c: loads of functions modified for\n\tMISSIONPACK that aren't used at all for MISSIONPACK anymore.\n\tDevelopment relics.\n\n\t* code/cgame/cg_consolecmds.c: -Werror.\n\tNote: due to Makefile error never ever compiled...\n\n\t* code/unix/Makefile: fixed various dependency errors\n\tfor game and ui library.\n\tTODO: create a new Makefile with patsubst and rules.\n\tTODO: why C_ONLY in the i386 dedicated server?\n\n\t* code/unix/unix_main.c: use dlerror() excessively.\n\tLittered more unused DLL related functions with assert(0).\n\tTODO: clean up Sys_Load/UnloadDll (a real mess)\n\tTODO: remove Zoid code cruft (unused per-DLL functions)\n\t\n\t* code/game/bg_misc.c: changed G_Printf for Com_Printf.\n\tThis was undefined in baseq3/uii386.so preventing loading.\n\n\t* TEST: +set sv_pure 0 +set vm_game 0 +set vm_cgame 0 +set vm_ui 0\n\tNote: so far I used only the game DLL..  duh.\n\tUI DLL fails to load: missing G_Printf.\n\n\t* code/unix/Makefile:  -DMALLOC_CHECK in addition to\n\tthe -DZONE_DEBUG I have used since switching to calloc.\n\tUsing MALLOC_CHECK=1 for now, might use 2 if something\n\tcomes up.\n\n\t* code/renderer/tr_init.c (GL_SetDefaultState): it does get \n\tcalled, but does not show up in the log.\n\t\n\t* TEST: tried executing a script - get bounced.\n\tTODO: is there any way to jump into a map?\n\tTODO: cl_cinematics 0 (supress all fullscreen RoQ)\n\tNext: used r_logfile 200 in Win32 (RC4) and Linux.\n\tThere is a buckload of setup code seemingly not done\n\tat all in Linux? Either that, or logging is enabled\n\twith a delay in Linux.\n\n\t* code/unix/linux_glimp.c: fixed autorepeat (H2/Fakk2 way). \n\n2000-12-05  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* code/renderer/tr_mesh.c: added assert there.\n\t* TEST: menus and in-game drawing are just as they were with \n\tthe initial SOS001119 port. In addition:\n\t  R_AddMD3Surfaces: no such frame 0 to -2147483477 \n\t     for 'models/players/xaero/upper.md3'\n          R_AddMD3Surfaces: no such frame -2147483477 to 171 \n\t  R_AddMD3Surfaces: no such frame 171 to -2147483498\n        ad nauseam (used as my player model).\n\tTriggered: haveing a trRefEntity_t *) 0x41dbbd00 with \n\tframe = -2147483477. Might be a red herring (PRINT_DEVELOPER), \n\tignore for now.\n\n\t* code/ui/ui_main.c: missing return.\n\t* code/ui/ui_shared.c: excess byte in initializer (which gcc\n\tdid not caught, but LCC did). Also LCC complains about\n\tmissing returns, but gcc doesn't (neither says unreacheable\n\tcode though). If necessary (MsVC?) guard with Q3_VM.\n\n\t* code/q3_ui/ui_ingame.c: see below.\n\t* code/q3_ui/ui_atoms.c: voidfunc_f. LCC warns about conversion \n\tfrom `pointer to void' to `pointer to void function(void)' \n\tbeing compiler dependent. Casting NULL. Guess what, doesn't fix \n\tit either.\n\tTODO: do not use these cursed scripts to generate VM code,\n\twe do not have proper rules for LCC/q3asm, thus the files never\n\tget updated.\n\n\t* code/unix/Makefile: for paranoia's sake recreated the 1.17\n\tcompile for the UI DLL (where only q_shared/math were actually\n\tcompiled as DO_SHLIB_CC.\n\tLater: switched to different gcc. \n\n\t* STATIC: remaining problems are vmMain (same entry point for all\n\tDLL's), could use cgMain, uiMain and gMain here for HARD_LINKED. \n\tNote: I don't think id has used this in ages.\n\tPlus all the collisions in *_syscalls.c, which simply can't be\n\tfixed cheaply. None is the superset of 2 others, neither seems\n\tw/o overlap to others. Full stop.\n\n\t* code/botlib/be_aas_move.c: see below.\n\t* code/game/ai_dmq3.c: VEC_UP/DOWN, MOVEDIR_UP/DOWN now static.\n\tSee also game/g_utils.c for existing static duplicates.\n\n\t* code/game/q_shared.h: #define stricmp strcasecmp \n\t* code/unix/Makefile:  no mo'  -Dstricmp=strcasecmp, see q_shared.h\n\tAlso: no mo'  -I/usr/include/glide, no FX\n\tTODO: are we building against system GL headers? ../Mesa/?\n\n\t* code/q3_ui/ui_atoms.c: comment on duplication\n\t* code/cgame/cg_drawtools.c: use UI/CGAME_HARD_LINKED on UI duplicates \n\tTODO: does this UI_ code in cg_drawtools/ui_atoms belong into ui_shared?\n\n\t* code/unix/Makefile: use -DQ3_STATIC \n\t* code/game/q_shared.h (*_HARD_LINKED): trigger on Q3_STATIC \n\tLater: collision between UI and CGAME is still there. This fixed\n\tthe Com_Error, Com_Printf issues though\n\n\t* code/unix/Makefile ($(B)/q3static/ai_vcmd.o): this file was\n\tmissing, hence undefined symbol.\n\t($(B)/baseq3/game/ai_vcmd.o): same here.\n\t($(B)/missionpack/game/ai_vcmd.o): same here.\n\n\t* STATIC: cg_syscalls.c, g_syscalls.c and ui_syscalls.c alias.\n\tMultiply defined symbols:\n\t Com_Error, Com_Printf\n         VEC_UP, VEC_DOWN\n\t MOVEDIR_UP, MOVEDIR_DOWN\n\t vmMain\n\t dllEntry\n\t PASSFLOAT\n\t trap_Error\n\t trap_Milliseconds\n\t trap_Argc\n\t trap_Argv\n         trap_FS_FOpenFile\n\t trap_FS_Read\n\t trap_FS_Write\n         trap_FS_FCloseFile\n         trap_FS_GetFileList\n\t trap_R_RegisterModel\n\t trap_R_RegisterSkin\n\t trap_R_RegisterFont\n\t trap_R_RegisterShaderNoMip\n\t trap_R_ClearScene\n\t trap_R_AddRefEntityToScene\n\t trap_R_AddPolyToScene\n         trap_R_AddLightToScene\n\t trap_R_RenderScene\n\t trap_R_SetColor\n         trap_R_DrawStretchPic\n\t trap_R_ModelBounds\n\t trap_UpdateScree\n         trap_S_StartLocalSound\n\t trap_S_RegisterSound\n\t trap_Key_IsDown\n\t trap_Key_GetCatcher\n\t trap_Key_SetCatcher\n\t trap_GetGlconfig\n         trap_PC_AddGlobalDefine\n\t trap_PC_LoadSource\n\t trap_PC_FreeSource\n\t trap_PC_FreeSource\n\t trap_PC_ReadToken\n\t trap_PC_SourceFileAndLine\n\t trap_S_StopBackgroundTrack\n\t trap_S_StartBackgroundTrack\n\t trap_RealTime\n\t trap_CIN_PlayCinematic\n\t trap_CIN_StopCinematic\n\t trap_CIN_RunCinematic\n\t trap_CIN_DrawCinematic\n         trap_CIN_SetExtents\n\t trap_MemoryRemaining\n         trap_SendConsoleCommand\n\t trap_Cvar_Register\n\t trap_Cvar_Update\n         trap_Cvar_Set\n  \t trap_Cvar_VariableValue\n         trap_Cvar_VariableStringBuffer\n\t trap_RealTime\n\t trap_SnapVector  // used in game/bg_*.c, needs conditional\n\tMore aliasing between ui_atoms.c and cg_drawtools.c:\n         UI_DrawBannerString\n         UI_ProportionalStringWidth\n\t UI_ProportionalSizeScale\n        Undefined symbol: ai_team.o: In function `FindHumanTeamLeader':\n         ai_team.c:1899: undefined reference to `BotVoiceChat_Defend'\n\tNote: \n\t\n\t* code/game/g_main.c: unused.\n\t* code/game/g_arenas.c: unused.\n\t* code/game/ai_team.c: init.\n\t* code/game/ai_dmnet.c: /* in comment (odd).\n\tNote: why do these come up now but not earlier?\n\tTODO: the make dependencies might target wrong files.\n\n\t* code/unix/Makefile (TARGETS): added q3static.\n\tNote: this is baseq3/\n\n\t* TEST: +set r_logfile 100. It seems that the addition of\n\tcode (add an assertion etc.) changes the behavio of the binary.\n\tThe intro cinematics code seems to suffer first - didn't play,\n\tthen played, then (another assert added) doesn't play. Watch\n\tout for (missionpack):\n\t  UI_CIN_PlayCinematic\n          SCR_PlayCinematic( mpintro.roq )\n          trFMV::play(), playing mpintro.roq\n\tAlso fails to exit cleanly: break gives\n\t #0  0x401919ee in __select ()\n         #1  0x400bbcb8 in __DTOR_END__ ()\n         #2  0x4004baa1 in _XSend ()\n         #3  0x452b009f in GLXRenderFlush ()\n         #4  0x804ce0c in _XRead ()\n         #5  0x40680813 in ?? ()\n\tStack is corrupted.\n        Note: ~/.q3a/gl.log\n\tTODO: write per-frame files (see Heretic2)\n\tTODO: add Heretic2 QGL (more detail)\n\n\t* code/unix/linux_qgl.c (QGL_EnableLogging): fixed countdown\n\t(i.e. propagated changes from win32/, see Fakk2).\n\n\t* code/unix/linux_glimp.c: fixed QGL_EnableLogging argument\n\tto avoid cast error (always qfalse).\n\n\t* code/unix/Makefile (DEBUG_CFLAGS): use ZONE_DEBUG.\n\n\t* code/qcommon/common.c: replaced malloc with calloc calls.\n\n\t* code/q3_ui/ui_local.h: have to use ui/ui_public.h\n\t* code/cgame/cg_servercmds.c: requires ../ui/menudef.h\n\n\t* code/cgame/cg_consolecmds.c: ui/ui_shared.h is unique.\n\t* code/q3_ui/ui_public.h: make sure this won't be compiled.\t\n\t* code/client/client.h: we have to include ui/ui_public.h.\n\tNote: id is obviously maintaing only the ui/ headers, so the\n\theaders in q3_ui/ are deprecated.\n\n\t* code/renderer/tr_shader.c: added assertions (see Ryan's Fakk2\n\tproblems with missing shaders).\n\n\t* code/game/g_cmds.c: below.\n\t* code/game/ai_vcmd.c: below.\n\t* code/game/ai_team.c: below.\n\t* code/game/ai_dmnet.c: below.\n\t* code/game/ai_dmq3.c: below.\n\t* code/game/ai_chat.c: below.\n\t* code/game/ai_cmd.c: ../../ui/menudef.h (new Q3TA script directory).\n\n\t* code/cgame/cg_newdraw.c: make sure it won't compile w/o MISSIONPACK.\n\n\t* code/cgame/cg_servercmds.c: below.\n\t* code/cgame/cg_event.c: below.\n\t* code/cgame/cg_consolecmds.c: below.\n\t* code/client/keys.h: below.\n\t* code/client/client.h: below.\n\t* code/q3_ui/ui_local.h: include from ../q3_ui/ not ../ui/.\n\tNote: id seems to intentionally use the header from the new ui/.\n\n\t* Makefile: checked -I$(UIDIR), there is no such. That means all\n\tfiles include directly, which means all (including Q3) are using\n\tthe new ui/ headers.\n\n2000-12-04  Bernd Kreimeier  <bk@lokigames.com> \n\n\t* RC4: released as 362101115 Dec  4 11:40 TA_Q3A_RC4.zip\n\n\t* TEST: the corrupted menu problem is back :-(. Looks like I am in\n\tfor a static link next.\n\t\n\t* code/unix/Makefile (clean2): fixed (not all new OBJ covered).\n\t* code/q3_ui/ui_teamorders.c: -Werror.\n\t* code/q3_ui/ui_team.c: -Werror. \n\t* code/q3_ui/ui_qmenu.c (Bitmap_Draw): -Werror. \n\t* code/q3_ui/ui_mods.c (UI_Mods_LoadModsFromFile): unused. -Werror.\n\t* code/q3_ui/ui_controls2.c: -Werror.\n\t* code/q3_ui/ui_atoms.c: -Werror\n\t* code/null/null_client.c: -Werror.\n\t* code/unix/linux_joystick.c: -Werror.\n\t* code/unix/linux_glimp.c: -Werror. \n\t* code/unix/linux_qgl.c: -Werror. \n\t* code/unix/unix_shared.c: -Werror. \n\t* code/unix/unix_net.c: -Werror.\n\t* code/unix/linux_local.h: added missing prototypes.\n\t* code/unix/unix_main.c: -Werror. Includes linux_local.h\n\t* code/jpeg-6/jdmainct.c: see below.\n\t* code/jpeg-6/jcmainct.c: variables called \"main\" (*moan*) \n\t* code/jpeg-6/jcdctmgr.c (forward_DCT): -Werror.\n\t* code/botlib/l_script.c (PS_ReadLiteral): -Werror\n\t* code/botlib/l_precomp.c (PC_AddBuiltinDefines): -Werror.\n\t* code/botlib/be_interface.c: -Werror.\n\t* code/botlib/be_aas_reach.c: -Werror\n\t* code/botlib/be_aas_cluster.c: -Werror \n\t* code/game/be_aas.h: -Werror. \n\tNote: MrElusive accumulates a lot of code history in nested comments,\n\twhich gcc doesn't like at all. #if 0'ed to avoid.\n\t* code/qcommon/vm_interpreted.c: -Werror.\n\t* code/qcommon/unzip.c: -Werror.\n\t* code/cgame/cg_servercmds.c: -Werror.\n\t* code/cgame/cg_main.c: -Werror.\n\t* code/cgame/cg_drawtools.c: -Werror.\n\t* code/game/bg_misc.c: -Werror.\n\t* code/game/be_ai_move.h (bot_avoidspot_s): added.\n\t* code/botlib/be_ai_move.c: removed typedef struct bot_avoidspot_s\n\t* code/client/snd_mix.c: -Werror.\n\t* code/qcommon/md4.c: -Werror.\n\t* code/qcommon/common.c: -Werror.\n\t* code/client/cl_keys.c: -Werror.\n\t* code/client/cl_cin.c: -Werror, init local variables.\t\n\t* code/unix/Makefile: -Werror. need -O for -Wall for uninitialized\n\tNote: the above is the list of files that got touched during a pass\n\twith -g -O -Werror -Wall flags (in the hope of finding uninitialized\n\tmemory and ambiguous statements). Most of the above are simply\n\tunused variables (or even code).\n\n\tTEST: RC3 data files, but DLL's.\n\tTODO: TA gets stuck in initial sound, doesn't play cinematics (sometimes)\n\tTODO: Q3 intro movie looses sound after Sarge gets teleported\n\tTODO: Q3 ingame renders world, weapon, muzzleflash, hud, can shoot,\n\tTODO:  but no movement, hud background is fubared. \n\n\t* code/cgame/cg_main.c: cg_singlePlayerActive\n\n\t* code/q3_ui/ui_login.c: doesn't seem to be used?\n\t* code/game/g_rankings.c (G_RankRunFrame): doesn't seem to be used.\n\t* code/q3_ui/ui.sh: disabled this. \n\t* code/q3_ui/q3_ui.sh: changed include path to ../q3_ui/ (duh).\n\n\t* code/game/game.sh: changed include path to ../q3_ui/ which \n\tis not in the Win32 batch file. \n\t* code/cgame/cg_rankings.c: this does not seem to be included. \n\t* code/cgame/cgame_ta.sh: added -DCGAME. Also added cg_syscalls.c\n\tto build (also missing in Win32).\n\n\t* code/cgame/cgame.sh: added -DCGAME (see cgame.bat). Also\n\tchanged include path to ../q3_ui/ which is not in the Win32\n\tbatch file.  Also added cg_syscalls.c to build (missing in \n\tWin32).\n\n2000-12-01  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* RC3: released as of sos001201 / Q3 1.27f\n\n\t* code/unix/Makefile: more fixes with clean build. The\n\tchanges made fix the menu rendering for Q3 but not TA.\n\tIngame graphics still broken. \n\n\t* code/game/game_ta.sh: created. Use game_ta.q3asm here.\n\t* code/game/game.sh: no -DMISSIONPACK \n\t* code/game/game_ta.q3asm: CR/LF, /.\n\n\t* code/cgame/cgame_ta.sh: created. Use cgame_ta.q3asm here.\n\t* code/cgame/cgame.sh:  no -DMISSIONPACK. No cg_newdraw, ui_shared.\n\t* code/cgame/cgame.q3asm:  No cg_newdraw, ui_shared.\n\tCR/LF, /, cg_newDraw, and the output path/name.\n\t\n\t* code/q3_ui/q3_ui.q3asm: output to ui not q3_ui...\n\n\t* code/cgame/cg_event.c: cg_singlePlayerActive used here.\n\tTODO: guard by MISSIONPACK\n\t* code/cgame/cg_local.h: named q3print_t enum. Cvar\n\tcg_singlePlayerActive for both Q3 and TA.\n\n\n\t* code/unix/Makefile: cleanly separate B/baseq3/ and\n\tB/missionpack/ subtrees during build. While new and old\n\tUI are in separate directories, the cgame/ and game/\n\tare shared, with conditional -DMISSIONPACK compile\n\tand different files includeds (cd_draw, cg_newdraw).\n\tThat means twice the number of targets (3 DLL's, 3 QVM's,\n\ttimes two), and different build rules.\n\tTODO: carefully check Win32 build for (other) conditionals\n\tTODO: carefully check Win32 build for link lists\n\n\t* CVS:  ui/, code/ui, botfiles/ and subdirectories are added.\n\tThe code/macosx/ directory turned out to be a real pain that\n\thad to be edited manually, throwing out CVS/ directories in\n\tthe tree that had been created by SOS as they are in id's\n\trepository:\n\t  code/macosx/Client/CVS\n\t  code/macosx/Client/PBUserInfo/CVS \n\t  code/macosx/Client/Quake3.nib/CVS  \n\t  code/macosx/Common/CVS\n\t  code/macosx/DedicatedServer/CVS\n\t  code/macosx/DedicatedServer/PBUserInfo/CVS  \n\tNow tagged\n\t  cvs tag id1-26y-loki001119\n\tTODO: there are several new files not yet linked?\n\n\t* ChangeLog: merged the Changelog from the bk00119 working\n\tbranch (initial Q3TA port) based on sos001119 snapshot. Also\n\tmerged the source tree with cvs-1.17.\n\tIn the ChangeLog below  *** MISSIONPACK *** indicates work\n\tthat was done on the branch (code-sos/ prefix in files).\n\tThe cvs update of this will be tagged with\n\t cvs tag id1-26y-loki001119\n\tUse this tag to hunt for possible Linux fixes that got lost\n\t(i.e. got dropped by id since id000516 and were thus not in\n\tsos001119, but did not show in diff id000516 cvs1-17).\n\tNew directories in CVS: botfiles/, ui/.\n\tMissing from SOS/Missionpack: SDK directories.\n\t common, lcc, libs, q3asm, q3data, q3map, q3radiant.\n\n\n\t* ssreport.txt: below.\n        Note: watch for files called \"ssreport.txt\", that's id ChangeLog.\n\t* ui/ui_syscalls.asm: below.\n\t* q3_ui/ui_syscalls.asm: below.\n\t* game/g_syscalls.asm: below.\n\t* cgame/cg_syscalls.asm: below.\n\t* bspc/linux-i386.mak: below.\n\t* bspc/lcc.mak: below.\n\t* botlib/linux-i386.mak: below.\n\t* botlib/lcc.mak: below.\n\t* A3D/a3d_console_variables.txt: CR/LF issue (minimize diffs).\n\n\t* CVS: the checked bk001119 work copy of the sos001119 initial\n\tcheckout (completed with everything in the SOS \"Missionpack\"\n\ttree, i.e. botfiles/ and botfiles.* added), copied over the\n\tcvs-1.17 checkout.\n\tNote: in these cases, BEWARE ui -> q3_ui/ links, and different\n\tChangeLogs. Also \"make clean\" helps.\n\n\t* unix/unix_net.c: below. \n\t* unix/unix_main.c: below. \n\t* unix/matha.s: below.\n\t* unix/linux_qgl.c: below.\n\t* unix/linux_glimp.c: see also linux_joystick.c.\n\t* server/sv_client.c: below.\n\t* renderer/tr_surface.c: below.\n\t* renderer/qgl.h: below.\n\t* qcommon/qcommon.h: below.\n\t* qcommon/files.c: below.\n\t* qcommon/common.c: below.\n\t* q3_ui/ui_demo2.c: below.\n\t* mac/mac_net.c: below.\n\t* mac/mac_glimp2.c: below.\n\t* game/surfaceflags.h: below.\n\t* game/bg_lib.c: checked against id00516/cvs-1.17a diff.\n\t* bspc/bspc.c: TH_AASToTetrahedrons call removed since id000516.\n\tNote: our final compare of id000516 against cvs-1.17a, making sure\n\tthat all these differences are in bk001119 (initial Q3TA port).\n\tIf id branched the Q3TA base off before id000516 we might be screwed.\n\tNote: I do not diff against bk000520, which had some minor changes\n\tagainst id000516 (check VectorArrayNormalize, OTConfiguration), which\n\tseem consistent with me taking a pre-id000516 source snapshot for that\n\tworking branch.\n\n2000-11-30  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* TEST: compiled using the symbolic link ui/ -> q3_ui/.\n\tHad to undo one CVS change, regarding\n\t code/cgame/cg_syscalls.asm\n\t code/game/g_syscalls.asm\n\t code/q3_ui/ui_syscalls.asm\n\tThese files are neither generated by Win32 cgame.bat\n\tnor cgame.sh (etc.), thus seemingly maintained by hand.\n\t cvs tag pr1-17-loki001130b\n\tshould be used if somebody needs this 1.17 snapshot\n\t(which, remember, is post-release, with additional fixes).\n\tLater:\n\t cvs tag pr1-17-loki001130c\n        includes the full ChangeLog (duh).\n\t\n\t* CVS: up until cvs-1.17-001130, code/ui/ contained the\n\tQ3 code for the UI QVM/DLL. In Q3TA, this code has been\n\tmoved to code/q3_ui/, while at the same time the new\n\t(scripting driven) UI code for Q3TA was maintained in\n\tcode/ui/. To preserve the history of code/ui/, it has been\n\trenamed to q3/ui/ in the CVSROOT.\n\tNote: this will BREAK all cvs-1.17 and before checkouts.\n\tTo compile earlier versions, move or link q3_ui/ to ui/.\n\tThe code has been tagged\n\t  cvs tag pr1-17-loki001130\n        after the change.\n\tDONE: remove code/*/vm/*.asm from CVSROOT\n\tNote: this includes code/*/*.asm files (from *_syscalls.c).\n\tThese were originally tracked in CVS, but if we need \n\tcomparison of q3asm output or QVM files we can rely\n\ton the Win32 and Linux SDK now. These files have been\n\tphysically removed from CVS now, followed by\n\t  cvs tag pr1-17-loki001130a\n\n2000-11-30  Bernd Kreimeier  <bk@lokigames.com>      *** MISSIONPACK ***\n\n\t* RC2: new ZIP file (another 360M for convenience).\n\n\t* SOS: new CVS module, Quake3_sos. This will be used to track\n\tthe unchanged SOS checkouts from id. As their repository\n\tis read-only, and there is no estimate on when changes might\n\tbe backpropagated there, I will track their changes in a\n\tseparate module, and update our local Quake3 module \n\taccordingly. This is effectively \"tracking 3rd party\"\n\tw/o import and half-automated, forced mergers - in other\n\twords, we now branch starting with our post-1.17 changes,\n\tfor the benefit of moving at all.\n\tBaseline is a slightly changed PR-1.17 id000516 source dump\n\t(essentially ui/ moved to q3_ui for continuity, and CR/LF etc.).\n\t cvs import Quake3_sos id000516 pr1-17-win32\n\t cvs import Quake3_sos sos001119 pr1-26-win32\n\t cvs import Quake3_sos sos001120 pr1-26-win32-001120\n         cvs import Quake3_sos sos001121 pr1-26-win32-001121\n         cvs import Quake3_sos sos001122 pr1-26-win32-001122\n         cvs import Quake3_sos sos001122-demo pr1-26-win32-demo\n        This is about the 1.26w Team Arena Win32 demo release, give or\n\ttake a couple of lines. Has Q3_VERSION \"Q3 Team Arena Demo 1.27b\".\n\t cvs import Quake3_sos sos001123 pr1-26-win32-001123\n         cvs import Quake3_sos sos001126 pr1-26-win32-001126\n        Now track id versions (see code/game/q_shared.h:Q3_VERSION)\n\t cvs import Quake3_sos sos001128 pr1-27c-win32-001128\n\tWith 1.27d they switched from Demo to full version (RC1).\n\t cvs import Quake3_sos sos001129 pr1-27d-win32-001129\n         cvs import Quake3_sos sos001130a pr1-27d-win32-001130a\n        Now switched to 1.27e. This import is done from the SOS\n\tworking directory.\n\t cvs import Quake3_sos sos001130b pr1-27e-win32-001130b\n\tNote: SoS created rwx attributes which are luckily fixed\n\tautomagically during import. It is also seemingly incapable\n\tto compare files, and leave files that have not changed the\n\thell alone. I can't do cvs update due to the $..$ tags in\n\tthe original files (which CVS can't be told to ignore), \n\tso I have to do import (creating a load of vendor tagged \n\tbranches), but at least cvsweb and cvs get the revisions\n\tright.\n\n\t* code-sos/unix/Makefile: added linux_joystick\n\t* code-sos/unix/linux_local.h: match mac/ and win32/, for prototypes.\n\n\t* code-sos/unix/linux_joystick.c: new file, code from linux_glimp.c\n\tNote: decided to separate this, as (a) we might edit/extend\n\ta lot, (b), it's not in the id tree, (c) it's not GL, (d)\n\tthere might be even more oddball devices. Anything that\n\tcuts down on diffs.\n\n\t* code-sos/unix/linux_glimp.c (Q_stristr): const return (cvs1.17).\n\tAlso (XLateKey): added more keyboard mappings (ASCII on\n\tupper row digits) (cvs1.17). Added in the minimal joystick\n\thooks (cvars, function calls). Fixed joystick cvar naming\n\tto match win32 (kept joystick_threshold). \n\tTODO: joystick stubs for dedicated?\n\n\t* CVS: I have to move up to 1.27d (data, Win32 networking).\n\tWith exception of linux_glimp.c (mostly joystick code), \n\tall cvs1.17 changes should now be in the work snapshot \n\tbased on the first sos001119 we got from id. There are\n\talso some additional changes in there already, thus I'll\n\tmove the (buggy) 1.26 snapshot into CVS before adding even\n\tmore differences.\n\n\n2000-11-29  Bernd Kreimeier  <bk@lokigames.com>     *** MISSIONPACK ***\n\n\t* RC1: TeamArena_Q3A_RC1.zip. Source has moved from\n\tQ3VERSION \"Q3 Team Arena Demo 1.27c\" to \"Q3 1.27d\" now.\n\n\t* code-sos/qcommon/common.c: added Com_InitPushEvent(). Also\n\tincreased MAX_PUSHED_EVENTS to 256.\n\tNote: this is another case of buffer memory not zero'ed.\n\tCom_EventLoop, fixed evTime to evType in debug print.\n\t\n\t* TEST: baseq3/\n\t +set sv_pure 0 +set vm_game 0 +set in_mouse 0 +set developer 2\n        TODO: Team Arena in menu leads to RE_Shutdown(1) and locks\n\tTODO: can't play game\n\tTODO: shaders can't load *.tga, *.jpg files are there\n\tTODO: DO_CC linking for DLL's, DO_SHLIB_CC only for export?\n\tTODO: ERROR: Bad player movement angle\n        TODO: Warning: cvar \"...\" given initial values: \"...\" and \"...\"\n \tTODO: TA demo ERROR: CL_ParseServerMessage: Illegible server message\n        TODO: WARNING: Com_PushEvent overflow\n\n\t* code-sos/qcommon/files.c: add NULL filter for our Sys_ListFiles calls.\n\t* unix/unix_shared.c (Sys_ListFiles): signature has changed, \n\tadditional Sys_ListFiles argument now.\n\n\t* code-sos/unix/unix_net.c (Sys_GetPacket): see below (readcount=0).\n\t* code-sos/unix/unix_main.c: see below (Mike's and my changes to DLL\n\tloading, my event buffer clear fixes).\n\t* code-sos/unix/linux_qgl.c (QGL_Init): see below (__FX__ guards).\n\tTODO: abstract WGL/GLX and end unfortunate QGL duplication.\n\tTODO: spice up QGL with Linux H2 full version.\t\n\t* code-sos/q3_ui/ui_demo2.c: fix on demo names  - no Q_strupr(demoname).\n\tNote: in CVS this fix is in ui/ui_demo2.c. CVS is screwed by\n\tid choosing the old name for new directory...\n\tTODO: manual intervention on \"ui goes q3_ui\"  in CVSROOT?\n\t* renderer/qgl.h: see below (__FX__ guards).\n\t* qcommon/files.c: migrated in the 1.17cvs changes against the\n\tid000516 code dump, i.e. the (not marked - boo hiss) mkv changes.\n\tNote: all the above is based on a diff of the last id code dump\n\tpre-1.17 against our CVS, with those fixes now migrated into the\n\tsos1.26 snapshot.\n\tTODO: move in joystick code.\n\tTODO: replace XAutoRepeatOn/Off with filter (focus).\n\tTODO: DGA 2.0 and such.\n\t\n\t* code-sos/game/q_shared.c: valid compare for NULL strings\n\t* code-sos/unix/unix_main.c: QRTLD, and now using RTLD_NOW.\n\tNote: it is a bad idea to load game DLL's that are missing symbols.\n\n\t* code-sos/ui/ui_main.c: see below.\n\t* code-sos/game/g_main.c: see below.\n\t* code-sos/q3_ui/ui_main.c: see below.\n\t* code-sos/cgame/cg_main.c: made cvarTable and cvarTableSize static. This resolved\n\ta segfault related to traversing the UI table during Init.\n\tNote: there is a segfault related to this variable being out of bounds. \n\tDifferent struct size in global variables possible aliasing between the \n\tDLL's.\n\t\n\t* code-sos/unix/unix_main.c (Sys_Error): assert(0), no exit in debug.\n\t* code-sos/game/q_shared.c: now aborts on NULL destination. Also DPrintf's\n\ton bogus excess copies.\n\tTODO: make all those string functions safe, at least assert.\n\t* code-sos/server/sv_init.c: comment in SV_Init\n\t// init the botlib here because we need the pre-compiler in the UI\n\tCalled in qcommon/common.c:Com_Init, were CL_Init is called afterwards...\n\t* code-sos/server/sv_bot.c: the botlib_import is filled here.\n\t* code-sos/unix/unix_main.c (Sys_GetBotLibAPI): RTLD_NOW. Which is for naught,\n\tas this code is not used and has never been used. assert(0)\n\n\t* code-sos/botlib/be_interface.c: botimport supposed to be set here.\n\t* code-sos/botlib/l_memory.c: segfault with q3_ui/ DLL.\n        #1  0x80e23ec in GetMemory (size=35) at ..//botlib/l_memory.c:331\n        331             ptr = botimport.GetMemory(size + sizeof(unsigned long int));\n\tas botimport is completely NULL'ed.\n\n\t* code-sos/q3_ui/q3_ui.sh: created from ui/ui.sh 1.17 \n\n\t* code-sos/q3_ui/q3_ui.q3asm: unfubared (CR/LF, / path).\n\n\t* code-sos/unix/Makefile: added q3_ui/ make targets (basically\n\tui/ targets from CVS 1.17 Makefile for starters).\n\n\t* code-sos/q3_ui/: this is the old UI code, which does not use\n\t../ui/menus.txt (see ui/ui_main.c). In other words,\n\tthe code in ui/ now has to be compiled or qvm'ed \n\tfor missionpack/, but to create the necessary DLL or\n\tQVM modules for baseq3/ we need to use q3_ui/. \n\t\n\t\n2000-11-27  Bernd Kreimeier  <bk@lokigames.com>     *** MISSIONPACK ***\n\n\t* code-sos/game/bg_lib.c: ld problem with a custom \"tan(..)\"\n\tTODO: loooking forward to SIGFPE on this code base.\n\t\n\t* code-sos/ui/ui_util.c: this file is empty.\n\n\t* code-sos/ui/ui.sh: new files:\n\t  ui_shared.c\n\t  ui_util.c\n\tReplaced by the /ui/*.menu files:\n\t q3lcc: can't find `../ui_cdkey.c'\n\t q3lcc: can't find `../ui_ingame.c'\n\tetc.\n\n\t* code-sos/cgame/cgame.q3asm: added cg_newdraw entry.\n\tAlso added ui_shared entry.\n\t* cgame/cgame.sh: added cg_newdraw.c entry.\n\tAlso added ../ui/ui_shared.c entry.\n\n\t* code-sos/cgame/cg_newdraw.c: renamed (was cg_newDraw.c mixed case).\n\tNote: the infidels have taken over.\n\n\t* cgame/cgame.sh: added  -DMISSIONPACK.\n\tNote: w/o, q3lcc complains\n\t../cg_event.c:204: undeclared identifier `cg_singlePlayerActive'\n        ../cg_event.c:204: left operand of . has incompatible type `int'\n        which indicates that this source does not compile w/o MISSIONPACK\n\tanymore. The baseq3/pak4.pk3 file in the Q3TA snapshot archives\n\tare dated\n\t     284464  11-10-00 14:02   vm/cgame.qvm\n             463940  11-14-00 14:47   vm/qagame.qvm\n             271596  11-14-00 14:48   vm/ui.qvm\n\tthe code dump is from 11-19. \n\tNote: Make does not abort on q3lcc complains\n\n\t* code-sos/game/game.sh: also added ai_vcmd.c entry.\n\n\t* code-sos/ui/ui.q3asm: fubared (below). In addition, this is \n\tthe only one to have a \n\t -o \"/tmp/quake3/missionpack/vm/ui\"\n\tline in it. Given that the other 2 QVM modules are\n\talso dependend on -DMISSIONPACK, this seems a real mess.\n\tFor now using the same path as the other 3.\n\t* code-sos/cgame/cgame.q3asm: below.\n\t* code-sos/game/game.q3asm: fubared. Fixed CR/LF and \\ in paths\n\tagain (read by q3asm called by game.sh called by make).\n\t* unix/Makefile: updated fpor DLL/QVM.\n\tNote: also shell scripts to use q3lcc not lcc.\n\n\t\n2000-11-27  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* code/unix/Makefile: now expects a run/ directory\n\trelative (between this, the Loki standards, and the\n\tutility code in the same repository, it's ever so\n\tslightly less dorky).\n\tTODO: fix broken copyfiles target etc.pp.\n\n\t* code/game/bg_lib.c: turns out the changes I\n\tundid 001120 were affecting original Zoid\n\tLinux port related defines, which break VM\n\tcompile. Mike fixed those (which I unfixed\n\twhen referring to the latest id code that does\n\tnot contain these patches). However, they\n\tduplicate ANSI libc symbols, so the guards might\n\tbe wrong. The symbols are missing when compiling\n\tfor VM, so I now use the existing lcc -DQ3_VM\n\tflag:\n\t  //#if !defined ( _MSC_VER ) && ! defined ( __linux__ )\n          #if defined ( Q3_VM )\n\tThis will break DLL compile on non-ANSI platforms,\n\twhich will have to be added to the conditional then.\n\n\t* code/ui/ui.sh: below. \n\t* code/game/game.sh: below. \n\t* code/cgame/cgame.sh: Linux SDK installs q3lcc to\n\tavoid collisions with regular lcc pre-installs. The\n\tscripts fail with \"lcc not found\", but do not abort \n\tthe Makefile.\n\tNote: now that VM code gets actually built, there\n\tare errors:\n\tg_main:648 ERROR: symbol vsprintf undefined\n        bg_pmove:1221 ERROR: symbol abs undefined\n        q_math:4309 ERROR: symbol fabs undefined\n        q_shared:2801 ERROR: symbol tolower undefined\n        q_shared:2862 ERROR: symbol toupper undefined\n        ai_dmq3:208 ERROR: symbol atoi undefined\n        ai_cmd:4951 ERROR: symbol sscanf undefined\n\n\n2000-11-20  Bernd Kreimeier  <bk@lokigames.com>   \n\t\n\t* TEST: test compile of pr-1.17+cvs fixes segfaults due \n\tto new baseq3/pak4.pk3\n\tNote: to self ... 1.17 is not compatible with new files.\n\tChecking into CVS next.\n\n\t* code/: changes applied by us that are not in id's code base\n\taffect q_shared.c (NULL in Q_stricmp), files.c (FIXME fs_cdpath,\n\tSys_ConcatenateFileList, ui_demo2.c (demo no tolower on linux).\n\tIn unix/ linux_glimp.c (joystick code), qgl.h, linux_qgl.c (__FX__),\n        unix_main.c (dlopen bug and event buffers), unix_net.c (readcount),\n\tmatha.s (assembly warning).\n\n\t* code/server/sv_client.c (SV_WriteDownloadToClient): \n\tNo effective change  on FS_SV_FOpenFileRead call, they reworked \n\tautodownload some more seemingly.\n\n\t* code/renderer/tr_surface.c: VectorArrayNormalize\n\t\n\t* code/qcommon/qcommon.h: see below.\n\t* code/qcommon/files.c: Com_ReadConfigs removed.\n\t* code/qcommon/common.c: removed Com_ReadConfigs, \n\ttextual replacement of body in Com_Init.\n\n\t* code/mac/mac_net.c: not applied (undone by id)\n\tOTConfiguration *config <> OTConfigurationRef  config\n\n\t* code/mac/mac_glimp2.c: r_colorbits->integer > 16\n\t* code/game/surfaceflags.h (CONTENTS_BOTCLIP): added.\n\n\t* code/game/q_shared.h: not applied (undone by id)\n\t#if defined(ppc) || defined(__ppc) || defined(__ppc__) \n        #define idppc 1 \n\t#else \n        #define idppc 0 \n        #endif \n\n\t* code/game/q_math.c: added another CPP line to guard\n\tBoxOnPlaneSide, removed WIN32 guard. \n\tTODO: this could be broken code guarded in all current\n\tcompiles...\n\n\t* code/game/bg_lib.c: left Q#_VM guard for typedef cmp_t\n\tAdded !defined( __linux__ ) for tolower and atoi.\n\tNote: the changes above relate to the very last code update\n\tfrom id prior to the 6 month blackout, which were not in\n\tCVS when Michael made his updates. Needed to establish the\n\tbaseline for the new patch. Source dump 1.17.00520, against\n\tSOS 1.26w-001119 version.\n\t\n2000-11-20  Bernd Kreimeier  <bk@lokigames.com>       *** MISSIONPACK ***\n\n\t* TEST: running against the data up to TeamArena_Q3A_001109.zip\n\tHunk_Clear: reset the hunk ok\n        Program received signal SIGBUS, Bus error.\n        \"q3dm2\", killBots==qtrue\n\t#0  CM_ClearMap () at ..//qcommon/cm_load.c:644\n        #1  0x80884a7 in SV_Map_f () at ..//server/sv_ccmds.c:159\n        #2  0x8072579 in Cmd_ExecuteString (text=0xbffff4b0 \"spmap q3dm2\") at ..//qcommon/cmd.c:591\n        #3  0x8071dfe in Cbuf_Execute () at ..//qcommon/cmd.c:190\n        #4  0x80763f7 in Com_Frame () at ..//qcommon/common.c:2547\n        #5  0x8130d6b in main (argc=13, argv=0xbffff984) at ..//unix/unix_main.c:953\n        #6  0x40100cb3 in __libc_start_main (main=0x8130bc4 <main>\n\tNot reproducible (screen stayed black).\n\t\n\t* TEST: +set developer 1, same for Win32 and Linux:\n\tCan't find gfx/misc/flare.tga\n        Can't find gfx/misc/sun.tga\n        Can't find gfx/misc/console02.tga\n\tCan't find vm/ui.map\n\tCan't find textures/sfx/logo512.tga\n        Can't find gfx/colors/black.tga\n        Can't find models/mapobjects/banner/banner5_2.md3\n        Can't find models/mapobjects/banner/banner5_1.md3\n        Can't find textures/sfx/firegorre2.tga\n        Can't find textures/sfx/bolts.tga\n\tCan't find menu/art/unknownmap.tga\n\n\t* Q3TA: after nearly 6 months, a code update from id. SOS access \n\teven. Got it to compile, link and start, but its currently broken\n\t(menu doesn't render in full, can't get into game etc.). Need\n\ta baseline 1.17 to diff against. Last code dump was May 16, with \n\tbspc code updated May 19. Checking working directory of bk000520\n\tagainst CVS next (Mike's fixes never made it into id's codebase\n\tor a post 1.17 release, neither did my fixes as released in the\n\tpoint release version 1.17).\n\n2000-11-19  Bernd Kreimeier  <bk@lokigames.com>       *** MISSIONPACK ***\n\n\t* TEST: Win32 install as tested with 1.26w. quake3.x86 (Q3A game)\t\n\tWarning: cvar \"r_uifullscreen\" given initial values: \"1\" and \"0\"\n        Warning: cvar \"r_inGameVideo\" given initial values: \"1\" and \"0\"\n        ^3WARNING: sound/feedback/hit.wav is a 8 bit wav file\n\t(on windows, sound/weapons/weapon_hover.wav is missing...)\n\tMenu only partially displayed in TA and baseq3 play, menu itself\n\tseems to work. Freetype?\n\tWARNING: Com_PushEvent overflow\n\n\t* code-sos/game/game.sh: not in SOS, moved in from CVS snapshot.\n\n\t* code-sos/qcommon/common.c: conditional DEDICATED to get rid off \n\tCL_ShutdownCGame/CL_ShutdownUI/CIN_CloseAllVideos.\n\tSame for UI_usesUniqueCDKey: dedicated server does not\n\twrite CD key file.\n\tTODO: check whether there is an unneeded \"read CD key\"\n\tfor dedicated server.\n\n\t* code-sos/null/null_client.c (CL_ShutdownAll): added dummy.\n\n\t* code-sos/unix/Makefile:  server/sv_net_chan.o for dedicated server.\n\n\t* code-sos/null/null_snddma.c: fixed  S_RegisterSound signature.\n\n\t* code-sos/client/snd_mix.c: snd_p, snd_linear_count, snd_out\n\tcan't be static, as used by unix/snd_mixa.s.\n\n\t* code-sos/unix/Makefile: added to the executable target:\n\t   renderer/tr_font.c\n\t   client/cl_net_chan.c\n\t   server/sv_net_chan.c \n\tAlso added a lot of jc*.c files to build, to fix unresolved\n\tsymbol errors.\n\tTODO: is there unused jpeg-6/jd*.o code linked in now?\n\n\t* code-sos/ft2/smooth.c: includes ftgrays.c, ftsmooth.c\n\t\n\t* code-sos/ft2/truetype.c: ttdriver.c, ttpload.c, ttgload.c, ttobjs.c.\n        Also (see ftoption.h) TT_CONFIG_OPTION_BYTECODE_INTERPRETER ttinterp.c\n\t\n\t* code-sos/ft2/sfnt.c: includes ttload.c, ttcmap.c, sfobjs.c,\n\tsfdriver.c. lso (see ftoption.h)\n        TT_CONFIG_OPTION_EMBEDDED_BITMAPS     ttsbit.c\n        TT_CONFIG_OPTION_POSTSCRIPT_NAMES     ttpost.c\n\n\t* code-sos/ft2/ftbase.c: includes ftcalc.c, ftobjs.c, ftstream.c,\n\tftlist.c, ftoutln.c, ftextend.c, ftnames.c.\n\t\n\t* code-sos/ft2/autohint.c: includes ahangles.c, ahglyph.c, ahglobal.c,\n\tahhint.c, ahmodule.c.\n\n\t* code-sos/unix/Makefile: added ft2/ to client objects, took out\n\tftraster.c/ftrend1.c (see below), added -DFT_FLAT_COMPILE.\n\t* ft2/ftsmooth.c: -DFT_FLAT_COMPILE required.\n\t* ft2/raster1.c: -DFT_FLAT_COMPILE required.\n\tNote: this includes ftraster.c/ftrend1.c.\n\n\t* code-sos/qcommon/vm_x86.c: _ftol is missing, ftolPtr only defined\n\tfor Win32, but used in generic code. Workaround for now.\n\tTODO: find good Linux ftol, or use old solution. \n\n\t* SoS checkout. chown -R a+w *  recode ibmpc:lat1 */*.h */*.c\n\t\n2000-06-30  Michael Vance <briraeos@lokigames.com>\n\n\t* misc: Spoke with Leonardo about qvm mess.\n\n\t* ui/ui.sh: Created to build much like the ui.bat script.\n\n\t* ui/ui.q3asm: Use linux style paths.\n\n\t* game/game.sh: Created to build much like the game.bat script.\n\n\t* game/game.q3asm: Use linux style paths.\n\n\t* cgame/cgame.sh: Created to build much like the cgame.bat script.\n\n\t* cgame/cgame.q3asm: Use linux systel paths.\n\n\t* unix/Makefile: Use the new .sh scripts to build the QVM files.\n\n\t* lcc/etc/linux.c: Build .asm files instead of .s files.\n\n\t* misc: QVMs now load properly, with minor glitches that should\n\thopefully be solvable. The new build scripts conflict with the\n\t.asm files already in CVS, as the generated byte code is slightly\n\tdifferent in some cases.\n\t\n2000-06-29  Michael Vance <briareos@lokigames.com>\n\n\t* lcc/makefile: Tweaked to automatically include the system\n\tcompiler's header location. Added an install directory.\n\n\t* lcc/custom.mk: Added a build directory.\n\n\t* lcc/etc/linux.c: Numerous small tweaks to make compiling the VM\n\tcode a much simpler task.\n\n\t* q3asm/Makefile: Created.\n\n\t* q3asm/q3asm.c: Fixed uninitialized variable in\n\tHashString(). Fixed off by one in argument parsing.\n\t\n\t* misc: Had Brian remove the Xmd.h include from glx.h so that we can\n\tbuild Quake3 on XFree86 4.0 systems.\n\n\t* wine: Attempted to build with lcc.exe and q3asm.exe using wine,\n\talso did not work. This is in contrast to MikeP's .qvms, which\n\tseem to work.\n\t\n2000-06-28  Michael Vance <briareos@lokigames.com>\n\n\t* common/files.c: Fixed Mods menu behaviour.\n\n\t* unix/linux_qgl.c: Guarded references to fxMesa.\n\n\t* renderer/qgl.h: Guarded references to fxMesa.\n\n\t* ui/ui_demo2.c: Don't convert filename to uppercase.\n\t\n2000-05-07  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* common/cmdlib.c: windowism, not guarded. Added WIN32 around \"ATOM a\".\n\n\t* q3map/Makefile: Linux Makefile. \n\n\t* q3map/Makefile.irix: \"makefile\" in original code, Irix-only Makefile. \n\tJust fixed some redundant TAB that GNU make despises about as much as I \n\tdespise GNU Make, and changed to a relative path.\n\n2000-05-01  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* q3radiant/: updated with Q3Radiant198b3-src.zip. \n\tTagged (globally) as q3radiant-198b3.\n\tKept the old files \n\t  3DFXCamWnd.h\n\t  3DFXCamWnd.cpp\n          MainFrm2.cpp\n        New files\n          Shaders.h\n          misc/      (contributed special TGA resources, don't relly belong)\n        Removed:\n\t  pName\n        Changed filenames to previous case:\n         UNNAMED.MAP           -> unnamed.map\n         RES/BMP0002.BMP       -> RES/bmp00002.bmp\n\tChanged:\n         changelog.txt         -> ChangeLog\n\t\n2000-04-28  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* CVS: bk000425 modified sources. This replaces the unix/ directory\n\twhich is not yet in id's SourceSafe. Two check-ins, due to minor\n\tchanges in an attempt to nail the Voodoo3 related crashes (driver\n\tproblems, not a Q3 issue). Undid some of the QFL changes for PI\n\tand the log bug fix - put back in (TODO). Also includes:\n\t* Quake3/code/botlib/be_aas_sample.c: single file update from Robert.\n\t\n\t* CVS: id000423 code dumps (two of them). Applying Loki patches.\n\tTagged for the final version (all patches).\n\n\t* CVS: id000422 code dump. This did not include the 1.16n fixes\n\tused for Linux, and was the first dump for the 1.17 security fix\n\trelease.\n\tNote: forgot to check in the ft2/ headers themselves, but they\n\tare not used in the current codebase anyway. Are added in next\n\tdump. Also there is use of CVS/CVS-like $Keyword$ patterns in\n\tsome files, and between their revisions and ours we fuck this up.\n\tAlso, id ZIP files create write protected sources, have to do\n\tchmod -R a+w Quake3/ to work and overwrite files.\n\n\t* CVS: bk000315 modified source. This version was the 1.16n release.\n\tNote: the changes applied here are not in the subsequent code dumps\n\tof id. If you want to compile the Linux version as released you\n\thave to use bk-tagged versions until the patches are merged in by\n\tRobert Duffy.\n\n\t* CVS: id000314 engine code dump, same procedure as below, tag.\n\tNote: this version added vm/ sudirectories with assembly files\n\tfor cgame, game, ui. CVS tag id000314.\n\n\t* CVS: id000304 engine code dump. Now there is a problem, as CVS\n\twas used in the Mac sources. Do\n\t  find . -name 'CVS' -exec rm -r {} \\;\n        before cvs update, then tagged:\n\t cvs -d /loki/cvsroot/ tag id000304 Quake3/\n\n\t* CVS: checked in a source snapshot of the id00303 engine code\n\tand the id0003029 tools code. The tool sources are not fully in \n\tsync, and we have only partial source from earlier engine revisions.\n        The engine source marks where Loki took over from Dave Kirsch.\n        This snapshot (with all temporary and bogus files) is imported\n        and tagged using:\n          cvs -d /loki/cvsroot import Quake3 id000303 initial\n\n        Modules:\n          code:      the Q3 engine code, including a jpeg-6/ copy\n          common:    code shared by tools\n          libs:      code shared by tools, inlcuding a jpeg6/ copy\n          q3asm:     VM bytecode assembly \n          q3data:    misc. Q3 data conversions\n          q3map:     BSP builder\n          q3radiant: Win32 editor, as is\n          lcc:       C compiler for q3asm\n\n        The sources have not been cleaned up, and binary files have not been\n\tremoved. The Q3Radiant code base might exhibit mixed case asmbiguities\n\tin the future, and future source dumps might come from SourceForge\n\tinstead.\n\n2000-04-25  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* q3code.id000425/unix/Makefile: relative path, relocatable.\n\tNote: first code merge with id, finally :-).\n\n2000-04-24  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* q3code.bk000422/unix/matha.s: in C(BoxOnPlaneSide)\n\tthe following line triggers assembler warning: \n\t\"missing prefix `*' in absolute indirect address, maybe misassembled!\"\n\t  jmp Ljmptab(,%eax,4)  \n\t\n\n\t* q3code.bk000422/unix/Makefile (MOUNT_DIR): rember to change.\n\tTODO: fix this bloody Makefile to be relocatable, damnit.\n\n\t* q3code.bk000422/cgame/cg_event.c: applied JCash fix again\n\t(see EV_EVENT_BITS below). Send e-mail to verify.\n\n\t* q3code.bk000422/renderer/tr_image.c: \"../jpeg-6/jpeglib.h\" again.\n\t\n\t* q3code.bk000422/: created from the id dump of today, lacking\n\tall but one of my changes (sigh). Swapped unix/ competely, takes\n\tcare of 90%. Submitted all changes again to Robert...\n\n2000-04-19  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* q3code.bk000315/unix/linux_glimp.c (GLimp_EndFrame): \n\tQGL_EnableLogging( r_logFile->value ) doesn't work?\n\n\t* q3code.bk000315/unix/linux_qgl.c:  GLimp_LogNewFrame() is \n\tobsolete. QGL_EnableLogging was out of sync with Win32 and\n\tdid not support the new framecounter decrement logic.\n\n2000-04-03  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* q3code.bk000315/server/sv_snapshot.c: svs.nextSnapshotEntities\n\tis a signed integer unconditionally incremented, which gets\n\tnegative and causes a segfaulting indexing an array. Added reset\n\tto counter. Might fail if snapshot numbers are supposed to\n\tmonotonically increase.\n\n2000-04-02  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* q3code.bk000315/client/cl_parse.c (CL_ParseServerMessage): \n\tassert(0) on Illegible message (remember to +set in_mouse 0).\n\tTODO: have to add a dump message function, it's unreadable.\n\n\t* botlib/be_ai_goal.c (InitLevelItemHeap): loop counter -2\n\tleft -2 with uninitialized next, and -1 disconnected. Removed\n\tredundant memset. There is an item alloc leak I suspect, as\n\tmax_levelitems 1024 merely delayed the overflow error.\n\n2000-04-01  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* botlib/be_ai_goal.c (InitLevelItemHeap): still segfaults.\n\tNot memsetting the entire item heap. As items are cleared\n\ton return, that leaves only memory corruption?\n\tLater: upped max_levelitems from 256 to 1024\n\tLater: client dies on connect:\n\t  Error: CL_ParseServerMessage: Illegible server message 255\n\n\n2000-03-31  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* botlib/be_ai_goal.c: initializing global vars.\n\tSegfault in AllocLevelItem () \n\t  at /home/bk/Games/Quake3/q3code/botlib/be_ai_goal.c:364\n        I suspect that the initial freelevelitems setting is at\n\tthe end of the list and eventually exposed.\n\n\t* cgame/cg_event.c: according to Johmn Cash: \n\t itemNum = (es->event & ~EV_EVENT_BITS) - EV_USE_ITEM0\n        Quote: \"This causes itemNum to be invalid about half the time, \n\tpreventing any client side effect tied to the item from occurring.\"\n\t\n2000-03-06  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* qcommon/common.c: set pushEvent buffer and indices\n\tto zero in Com_Init().\n\n\t* q3code/qcommon/qcommon.h: made SE_NONE (and for paranoia\n\talso NA_BOT) explicitely set to zero.\n\n2000-02-27  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* unix/Makefile: added dmalloc in an attempt to get on\n\tthe Z_Free bug. Futile. Despite stripping dmalloc debug\n\ttoken down to essentials, I get a (seemingly bogus or\n\tunrelated):\n\t  debug-malloc library: dumping program, fatal error\n          Error: possibly bad .c filename pointer (err 24)\n\n\t\n2000-02-26  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* qcommon/common.c: various debug builts to isolate the\n\tZ_Free bug. It reproducibly happens on some machines\n\twith SE_PACKET, but the packets themselves look\n\tthoroughly corrupted.\n\n2000-02-21  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* qcommon/common.c (Com_EventLoop): possible problem\n\there, pointer does not get cleared.\n\n\t* unix/linux_glimp.c (InitSig): no signal handler.\n\t* common/common.c: dump in Com_Error for debug.\n\n2000-02-17  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* q3code: new dump from Zoid. Repeat tr_image.c fix.\n\n\t* unix/Makefile: added client/snd_adpcm.c (linkage errors).\n\tLater: added entire JPDIR and rules, for tr_image.c. \n\tLater: had to fix fules for game/ai_*.c files.\n\tLater: removed ui/ui_quit.o (n/a)\n\tLater: took out -mpentiumpro -march=pentiumpro \n\n\t* renderer/tr_image.c: windowism in #include path (see below).\n         #include \"..\\jpeg-6\\jpeglib.h\"\n\n1999-12-27  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* Alpha: tried a dedicated server compile. Segfaults in\n\t../qcommon/files.c:1682, a paksort function doing pointer\n\tfiddling.\n\n\t* Makefile.alpha: created.\n\tNote: want to take the SDL/Setup autoconf ASAP.\n\n\t* unix/unix_main.c: fixed __axp__ to __alpha__, guarded\n\t_FPU_SETCW.\n\n\t* qcommon/vm_alpha.c: dummy, created.\n\t* qcommon/vm_null.c: dummy, created.\n\n1999-12-04  Bernd Kreimeier  <bk@lokigames.com>\n\n\t* renderer/tr_image.c: windowism in #include path.\n         #include \"..\\jpeg-6\\jpeglib.h\"\n\t\n\t* Revision 1.11: from Zoid by e-mail.\n\tNote: threw away my playground copy, starting with the\n\tZIP file. Zoid's using CVS now, but we can't remote\n\taccess it. Thus did the\n\t \"find . -name 'CVS' -exec rm -rf {} \\;\"\n\tand then track it as 3rd party source by\n\t\n\n\t* ChangeLog: created. Now starting to track Q3A source.\n\n--------- q3code log ---------------------------------------------\n"
  },
  {
    "path": "code/unix/Cons_gcc.pm",
    "content": "#\n# Some utilities to handle gcc compiler setup\n#\n\npackage Cons_gcc;\n\n# pass the compiler name\n# returns an array, first element is 2 for 2.x 3 for 3.x, then full version, then machine info\nsub get_gcc_version\n{\n  my @ret;\n  my ($CC) = @_;\n  my $version=`$CC --version | head -1`;\n  chop($version);\n  my $machine=`$CC -dumpmachine`;\n  chop($machine);\n  if($version =~ '2\\.[0-9]*\\.[0-9]*')\n  {\n    push @ret, '2';\n  } else {\n    push @ret, '3';\n  }\n  push @ret, $version;\n  push @ret, $machine;\n  return @ret;\n}\n\n# http://ccache.samba.org/\n# check ccache existence and path\n# returns an array, first element 0 / 1, then path\nsub get_ccache\n{\n  my @ret;  \n  $ccache_path=`which ccache`;\n  chop($ccache_path);\n  if(-x $ccache_path)\n  {\n    push @ret, '1';\n    push @ret, $ccache_path;\n    return @ret;\n  }\n  push @ret, '0';\n  return @ret;\n}\n\n# close package\n1;\n"
  },
  {
    "path": "code/unix/Conscript-client",
    "content": "# full client build script\n\nImport qw( BASE_CFLAGS BASE_LDFLAGS INSTALL_DIR BUILD_DIR TARGETNAME CC CXX LINK );\n\n# splines\n$env_splines = new cons(\n  CC => $CC,\n  CXX => $CXX,\n  LINK => $LINK,\n\tENV => { PATH => $ENV{PATH}, HOME => $ENV{HOME} }\n  );\n\n@SPLINES_FILES = qw(\n  ../splines/math_angles.cpp\n  ../splines/math_matrix.cpp\n  ../splines/math_quaternion.cpp\n  ../splines/math_vector.cpp\n  ../splines/q_parse.cpp\n  ../splines/q_shared.cpp\n  ../splines/splines.cpp\n  ../splines/util_str.cpp  \n  );\n$SPLINES_FILESREF = \\@SPLINES_FILES;\n  \nLibrary $env_splines 'splines', @$SPLINES_FILESREF;  \n\n# botlib\n# FIXME TTimo\n# we already deal with botlib on dedicated target\n# the compilation options are a bit different but we could certainly rely on\n#   the same Conscript and make things cleaner\n\n$env_botlib = new cons(\n  CC => $CC,\n  CXX => $CXX,\n  LINK => $LINK,\n\tENV => { PATH => $ENV{PATH}, HOME => $ENV{HOME} },\n  CFLAGS => $BASE_CFLAGS . '-DBOTLIB '\n);\n\n@BOTLIB_FILES = qw(\n  ../botlib/be_aas_bspq3.c\n  ../botlib/be_aas_cluster.c\n  ../botlib/be_aas_debug.c\n  ../botlib/be_aas_entity.c\n  ../botlib/be_aas_file.c\n  ../botlib/be_aas_main.c\n  ../botlib/be_aas_move.c\n  ../botlib/be_aas_optimize.c\n  ../botlib/be_aas_reach.c\n  ../botlib/be_aas_route.c\n  ../botlib/be_aas_routealt.c\n  ../botlib/be_aas_sample.c\n  ../botlib/be_ai_char.c\n  ../botlib/be_ai_chat.c\n  ../botlib/be_ai_gen.c\n  ../botlib/be_ai_goal.c\n  ../botlib/be_ai_move.c\n  ../botlib/be_ai_weap.c\n  ../botlib/be_ai_weight.c\n  ../botlib/be_ea.c\n  ../botlib/be_interface.c\n  ../botlib/l_crc.c\n  ../botlib/l_libvar.c\n  ../botlib/l_log.c\n  ../botlib/l_memory.c\n  ../botlib/l_precomp.c\n  ../botlib/l_script.c\n  ../botlib/l_struct.c\n);\n$BOTLIB_REF = \\@BOTLIB_FILES;\n\nLibrary $env_botlib 'botlib', @$BOTLIB_REF;\n\n# jpeg\n# NOTE TTimo we might need this one on other targets\n$env_jpeglib = new cons(\n  CC => $CC,\n  CXX => $CXX,\n  LINK => $LINK,\n\tENV => { PATH => $ENV{PATH}, HOME => $ENV{HOME} },\n  CFLAGS => $BASE_CFLAGS\n  );\n  \n@JPEGLIB_FILES = qw(\n  ../jpeg-6/jcapimin.c \n  ../jpeg-6/jchuff.c \n  ../jpeg-6/jcinit.c \n  ../jpeg-6/jccoefct.c \n  ../jpeg-6/jccolor.c \n  ../jpeg-6/jfdctflt.c \n  ../jpeg-6/jcdctmgr.c \n  ../jpeg-6/jcphuff.c \n  ../jpeg-6/jcmainct.c \n  ../jpeg-6/jcmarker.c \n  ../jpeg-6/jcmaster.c \n  ../jpeg-6/jcomapi.c\n  ../jpeg-6/jcparam.c\n  ../jpeg-6/jcprepct.c\n  ../jpeg-6/jcsample.c \n  ../jpeg-6/jdapimin.c \n  ../jpeg-6/jdapistd.c \n  ../jpeg-6/jdatasrc.c \n  ../jpeg-6/jdcoefct.c \n  ../jpeg-6/jdcolor.c \n  ../jpeg-6/jddctmgr.c \n  ../jpeg-6/jdhuff.c \n  ../jpeg-6/jdinput.c \n  ../jpeg-6/jdmainct.c \n  ../jpeg-6/jdmarker.c \n  ../jpeg-6/jdmaster.c \n  ../jpeg-6/jdpostct.c \n  ../jpeg-6/jdsample.c \n  ../jpeg-6/jdtrans.c \n  ../jpeg-6/jerror.c  \n  ../jpeg-6/jidctflt.c \n  ../jpeg-6/jmemmgr.c \n  ../jpeg-6/jmemnobs.c   \n  ../jpeg-6/jutils.c \n  );\n$JPEGLIB_REF = \\@JPEGLIB_FILES;  \n  \nLibrary $env_jpeglib 'jpeglib', @$JPEGLIB_REF;   \n\n# NOTE TTimo this requires patched cons version to work (see unix/cons)\n%nasm_hash = new cons()->copy(\n  CC => 'nasm',\n  CCCOM => '%CC -f elf -o %> %<'\n);\n$nasm_hash{SUFMAP}{'.nasm'} = 'build::command::cc';\n$nasm_env = new cons(%nasm_hash);\n\nLibrary $nasm_env 'asmlib', 'ftol.nasm', 'snapvector.nasm';\n\n# compiling files with inlined assembly\n$env_inlined = new cons(\n  CFLAGS => '-DELF -x assembler-with-cpp'\n  );\n\nLibrary $env_inlined 'inlinelib', '../unix/matha.s', '../unix/snd_mixa.s';\n\n# putting it all together\n\n$env = new cons(\n  CC => $CC,\n  CXX => $CXX,\n  LINK => $LINK,\n\tENV => { PATH => $ENV{PATH}, HOME => $ENV{HOME} },\n  CFLAGS => $BASE_CFLAGS,\n  LIBS => ' ' . $BUILD_DIR . '/unix/splines.a ' \n  . $BUILD_DIR . '/unix/botlib.a ' \n  . $BUILD_DIR . '/unix/jpeglib.a '\n  . $BUILD_DIR . '/unix/asmlib.a '\n  . $BUILD_DIR . '/unix/inlinelib.a '\n\t. $BASE_LDFLAGS\n  . '-L/usr/X11R6/lib -lX11 -lXext -lXxf86dga -lXxf86vm -ldl -lm'\n);\n\n@RENDERER_FILES = qw(\n  ../renderer/tr_animation.c   \n  ../renderer/tr_backend.c   \n  ../renderer/tr_bsp.c   \n  ../renderer/tr_cmds.c   \n  ../renderer/tr_curve.c   \n  ../renderer/tr_flares.c   \n  ../renderer/tr_font.c    \n  ../renderer/tr_image.c    \n  ../renderer/tr_init.c     \n  ../renderer/tr_light.c   \n  ../renderer/tr_main.c    \n  ../renderer/tr_marks.c    \n  ../renderer/tr_mesh.c    \n  ../renderer/tr_model.c    \n  ../renderer/tr_noise.c    \n  ../renderer/tr_scene.c    \n  ../renderer/tr_shade.c    \n  ../renderer/tr_shade_calc.c   \n  ../renderer/tr_shader.c    \n  ../renderer/tr_shadows.c    \n  ../renderer/tr_sky.c    \n  ../renderer/tr_surface.c   \n  ../renderer/tr_world.c    \n  );\n$RENDERER_REF = \\@RENDERER_FILES;  \n\n@CLIENT_FILES = qw(\n  ../client/cl_cgame.c   \n  ../client/cl_cin.c       \n  ../client/cl_console.c  \n  ../client/cl_input.c   \n  ../client/cl_keys.c     \n  ../client/cl_main.c     \n  ../client/cl_net_chan.c  \n  ../client/cl_parse.c   \n  ../client/cl_scrn.c    \n  ../client/cl_ui.c         \n  );\n$CLIENT_REF = \\@CLIENT_FILES;\n\n@COMMON_FILES = qw(\n  ../qcommon/cm_load.c        \n  ../qcommon/cm_patch.c       \n  ../qcommon/cm_polylib.c     \n  ../qcommon/cm_test.c        \n  ../qcommon/cm_trace.c       \n  ../qcommon/cmd.c                   \n  ../qcommon/common.c               \n  ../qcommon/cvar.c                \n  ../qcommon/files.c              \n  ../qcommon/md4.c                   \n  ../qcommon/msg.c                    \n  ../qcommon/net_chan.c\n  ../qcommon/huffman.c\n  ../qcommon/unzip.c\n  );\n$COMMON_REF = \\@COMMON_FILES;  \n\n@SOUND_FILES = qw(\n  ../client/snd_adpcm.c\n  ../client/snd_dma.c\n  ../client/snd_mem.c\n  ../client/snd_mix.c\n  ../client/snd_wavelet.c\n  );\n$SOUND_REF = \\@SOUND_FILES;\n\n@UNIX_FILES = qw(\n  ../unix/unix_main.c \n  ../unix/unix_net.c \n  ../unix/unix_shared.c \n  ../unix/linux_common.c\n  ../unix/linux_qgl.c   \n  ../unix/linux_glimp.c   \n  ../unix/linux_joystick.c  \n  ../unix/linux_snd.c \n\t../unix/linux_signals.c\n  );\n$UNIX_REF = \\@UNIX_FILES;\n\n@SERVER_FILES = qw(\n  ../server/sv_bot.c\n  ../server/sv_ccmds.c\n  ../server/sv_client.c\n  ../server/sv_game.c\n  ../server/sv_init.c\n  ../server/sv_main.c\n  ../server/sv_net_chan.c\n  ../server/sv_snapshot.c\n  ../server/sv_world.c\n  );\n$SERVER_REF = \\@SERVER_FILES;\n\n# FIXME TTimo vm_<cpu>.c\n@VM_FILES = qw(\n  ../qcommon/vm.c\n  ../qcommon/vm_x86.c\n  ../qcommon/vm_interpreted.c\n  );\n$VM_REF = \\@VM_FILES;\n\n# FIXME: import the CPU string to build the name of the target\nProgram $env $TARGETNAME, '../game/q_shared.c', '../game/q_math.c',\n  @$RENDERER_REF, @$CLIENT_REF, @$COMMON_REF, @$SOUND_REF,\n  @$UNIX_REF, @$SERVER_REF, @$VM_REF;\nInstall $env $INSTALL_DIR, $TARGETNAME;\n"
  },
  {
    "path": "code/unix/Conscript-dedicated",
    "content": "# dedicated server build script\n\nImport qw( BASE_CFLAGS BUILD_DIR INSTALL_DIR CC CXX LINK );\n\n$DEDICATED_NAME = 'linuxq3ded';\n\n$env_botlib = new cons(\n  CC => $CC,\n  CXX => $CXX,\n  LINK => $LINK,\n\tENV => { PATH => $ENV{PATH}, HOME => $ENV{HOME} },\n  CFLAGS => $BASE_CFLAGS . '-DBOTLIB '\n);\n\n@BOTLIB_FILES = qw(\n  ../botlib/be_aas_bspq3.c\n  ../botlib/be_aas_cluster.c\n  ../botlib/be_aas_debug.c\n  ../botlib/be_aas_entity.c\n  ../botlib/be_aas_file.c\n  ../botlib/be_aas_main.c\n  ../botlib/be_aas_move.c\n  ../botlib/be_aas_optimize.c\n  ../botlib/be_aas_reach.c\n  ../botlib/be_aas_route.c\n  ../botlib/be_aas_routealt.c\n  ../botlib/be_aas_sample.c\n  ../botlib/be_ai_char.c\n  ../botlib/be_ai_chat.c\n  ../botlib/be_ai_gen.c\n  ../botlib/be_ai_goal.c\n  ../botlib/be_ai_move.c\n  ../botlib/be_ai_weap.c\n  ../botlib/be_ai_weight.c\n  ../botlib/be_ea.c\n  ../botlib/be_interface.c\n  ../botlib/l_crc.c\n  ../botlib/l_libvar.c\n  ../botlib/l_log.c\n  ../botlib/l_memory.c\n  ../botlib/l_precomp.c\n  ../botlib/l_script.c\n  ../botlib/l_struct.c\n);\n$BOTLIB_REF = \\@BOTLIB_FILES;\n\nLibrary $env_botlib 'botlib', @$BOTLIB_REF;\n\n# NOTE TTimo this requires patched cons version to work (see unix/cons)\n%nasm_hash = new cons()->copy(\n  CC => 'nasm',\n  CCCOM => '%CC -f elf -o %> %<'\n);\n$nasm_hash{SUFMAP}{'.nasm'} = 'build::command::cc';\n$nasm_env = new cons(%nasm_hash);\n\nLibrary $nasm_env 'asmlib', 'ftol.nasm', 'snapvector.nasm';\n\n$env = new cons(\n  CC => $CC,\n  CXX => $CXX,\n  LINK => $LINK,\n\tENV => { PATH => $ENV{PATH}, HOME => $ENV{HOME} },\n  # FIXME TTimo I'm not sure about what C_ONLY is for\n  CFLAGS => $BASE_CFLAGS . '-DC_ONLY',\n  LDFLAGS => '-ldl -lm',\n  LIBS => ' ' \n  . $BUILD_DIR . '/unix/botlib.a '\n  . $BUILD_DIR . '/unix/asmlib.a '\n);\n\n# list the files for the dedicated server\n@FILES = qw( \n  ../null/null_client.c\n  ../null/null_input.c\n  ../null/null_snddma.c\n  ../server/sv_bot.c\n  ../server/sv_ccmds.c\n  ../server/sv_client.c\n  ../server/sv_game.c\n  ../server/sv_init.c\n  ../server/sv_main.c\n  ../server/sv_net_chan.c\n  ../server/sv_snapshot.c\n  ../server/sv_world.c\n  ../qcommon/cm_load.c\n  ../qcommon/cm_patch.c\n  ../qcommon/cm_polylib.c\n  ../qcommon/cm_test.c\n  ../qcommon/cm_trace.c\n  ../qcommon/cmd.c\n  ../qcommon/common.c\n  ../qcommon/cvar.c\n  ../qcommon/files.c\n  ../qcommon/huffman.c\n  ../qcommon/md4.c\n  ../qcommon/msg.c\n  ../qcommon/net_chan.c\n  ../qcommon/unzip.c\n  ../qcommon/vm.c\n  ../qcommon/vm_interpreted.c\n  ../game/q_math.c\n  ../game/q_shared.c\n  ../unix/linux_common.c\n  ../unix/unix_main.c\n  ../unix/unix_net.c\n  ../unix/unix_shared.c\n\t../unix/linux_signals.c\n   );\n$FILESREF = \\@FILES;\n\n# DEDICATED_NAME is imported, holds the name of the target\n# wolfded.x86 usually\nProgram $env $DEDICATED_NAME, '../qcommon/vm_x86.c', @$FILESREF;\nInstall $env $INSTALL_DIR, $DEDICATED_NAME;\n"
  },
  {
    "path": "code/unix/Conscript-pk3",
    "content": "# build pk3 on the fly\n\nImport qw( INSTALL_DIR BUILD_DIR CONFIG_DIR CC CXX LINK );\n\nuse Data::Dumper;\n\n$env = new cons(); # the env on which we will be working for all pk3s (NOTE: maybe we need several ctually)\n\n$hcf_do_exec = 1;\nsub do_command($)\n{\n  printf(\"@_[0]\\n\");\n  if ($hcf_do_exec)\n  {\n    system(\"@_[0]\");\n  }\n}\n\nsub build_pk3 {\n\n\tsub launch {\n\t\t#print \"In launch\\n\";\t\t\n\t\t$Data::Dumper::Indent = 2;\n\t\t#print Dumper(@_);\n\t\t$tmpdir = \"/tmp/pk3-builder$$\";\n\t\tdo_command(\"rm -rf $tmpdir\");\n\t\t\n\t\t($target, $sets) = @_;\n\t\t$base=`basename $target`; chomp($base);\n\t\t$dirname=`dirname $target`; chomp($dirname);\n\t\t\n\t\tforeach (@{$sets})\n\t\t{\n\t\t\t($sourcepath, $destpath, $file) = @{$_};\n\t\t\t#print \"source: $sourcepath dest: $destpath file: $file\\n\";\n\t\t\tdo_command(\"mkdir -p $tmpdir/$destpath\");\n\t\t\tif ($sourcepath =~ /#.*/)\n\t\t\t{\n\t\t\t\t#print \"$sourcepath is absolute\\n\";\n\t\t\t\t$sourcepath =~ s/#//;\n\t\t\t\tif (ref($file))\n\t\t\t\t{\n\t\t\t\t\tforeach(@{$file})\n\t\t\t\t\t{\n\t\t\t\t\t\tdo_command(\"cp $sourcepath/$_ $tmpdir/$destpath/$_\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tdo_command(\"cp $sourcepath/$file $tmpdir/$destpath/$file\");\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t#print \"$sourcepath in linked dir\\n\";\n\t\t\t\tif (ref($file))\n\t\t\t\t{\n\t\t\t\t\tforeach(@{$file})\n\t\t\t\t\t{\n\t\t\t\t\t\tdo_command(\"cp $BUILD_DIR/$sourcepath/$_ $tmpdir/$destpath/$_\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tdo_command(\"cp $BUILD_DIR/$sourcepath/$file $tmpdir/$destpath/$file\");\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t}\n\t\t\n\t\tdo_command(\"cd $tmpdir ; zip -r $base *\");\n\t\tdo_command(\"mkdir -p $BUILD_DIR/$dirname\");\n\t\tdo_command(\"cp $tmpdir/$base $BUILD_DIR/$target\");\n\t\tdo_command(\"rm -rf $tmpdir\");\n\t\t\n\t\treturn 1;\n\t}\n\t\n\t# extract the parameters\n\t($target, $sets) = @_;\n\t\n\t$base=`basename $target`; chomp($base);\n\t$dirname=`dirname $target`; chomp($dirname);\n\t\n\t# the build command is stored and called later on by cons\n\t# this makes it impossible to have several build_pk3 working together\n\t# there is probably a cleaner solution than this hack, but this works\n\t$target_uniquename=\"target_$base\";\n\t$target_uniquename=~s/\\.//g;\n\teval(\"\\$$target_uniquename=\\$target\");\n\t$sets_uniquename=\"sets_$base\";\n\t$sets_uniquename=~s/\\.//g;\n\teval(\"\\$$sets_uniquename=\\$sets\");\n\t#print \"name: $target_uniquename after the hack: $target_pak8pk3\";\n\t\n\t# don't pass @{@_} .. since this will be called during the process\n\t$command = \"[perl] &launch( \\$$target_uniquename, [ \\@{\\$$sets_uniquename} ] )\";\n\t#print \"$command\\n\";\n\t\t\n\tforeach(@{$sets})\n\t{\n\t\t($sourcepath, $destpath, $file) = @{$_};\n\t\tif (ref($file))\n\t\t{\n\t\t\tforeach(@{$file})\n\t\t\t{\n\t\t\t\tDepends $env $target, $sourcepath . '/' . $_;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tDepends $env $target, $sourcepath . '/' . $file;\n\t\t}\n\t}\n\tCommand $env $target, $command;\n\tInstall $env $INSTALL_DIR . \"/$dirname\", $target;\n}\n\n# quick rundown on the syntax:\n# <target file>, [ <fileset1>, <fileset2>, ... ]\n# where <fileset>: [ <source directory>, <directory in zip>, <file1>, <file2>, .. ]\n\nbuild_pk3('baseq3/pak8.pk3', \n\t[ [ '#../../../media/Q3Media-1.32/baseq3/menu/art', 'menu/art', 'pblogo.tga' ],\n\t[ '../Q3/q3_ui/q3_ui', 'vm', 'ui.qvm' ],\n\t[ '../Q3/cgame/cgame', 'vm', 'cgame.qvm' ],\n\t[ '../Q3/game/game', 'vm', 'qagame.qvm' ] ]\n);\n\nbuild_pk3('missionpack/pak3.pk3',\n\t[\t[ '#../ui', 'ui', [ 'createserver.menu', 'joinserver.menu', 'filter.menu', 'punkbuster.menu', 'menus.txt' ] ],\n\t[ '../TA/ui/ui', 'vm', 'ui.qvm' ],\n\t[ '../TA/cgame/cgame', 'vm', 'cgame.qvm' ],\n\t[ '../TA/game/game', 'vm', 'qagame.qvm' ],\n\t[ '#../../../media/Q3Media-1.32/missionpack/scripts', 'scripts', 'models2.shader' ] ]\n);\n"
  },
  {
    "path": "code/unix/Conscript-sdk",
    "content": "# sdk\n\nImport qw( SDK_NAME Q3_VER CC CXX LINK );\n\n# http://www.devdaily.com/perl/edu/articles/pl010005/pl010005.shtml\n#----------------------------(  promptUser  )-----------------------------#\n#                                                                         #\n#  FUNCTION:\tpromptUser                                                #\n#                                                                         #\n#  PURPOSE:\tPrompt the user for some type of input, and return the    #\n#\t\tinput back to the calling program.                        #\n#                                                                         #\n#  ARGS:\t$promptString - what you want to prompt the user with     #\n#\t\t$defaultValue - (optional) a default value for the prompt #\n#                                                                         #\n#-------------------------------------------------------------------------#\n\nsub promptUser {\n\n   #-------------------------------------------------------------------#\n   #  two possible input arguments - $promptString, and $defaultValue  #\n   #  make the input arguments local variables.                        #\n   #-------------------------------------------------------------------#\n\n   local($promptString,$defaultValue) = @_;\n\n   #-------------------------------------------------------------------#\n   #  if there is a default value, use the first print statement; if   #\n   #  no default is provided, print the second string.                 #\n   #-------------------------------------------------------------------#\n\n   if ($defaultValue) {\n      print $promptString, \"[\", $defaultValue, \"]: \";\n   } else {\n      print $promptString, \": \";\n   }\n\n   $| = 1;               # force a flush after our print\n   $_ = <STDIN>;         # get the input from STDIN (presumably the keyboard)\n\n\n   #------------------------------------------------------------------#\n   # remove the newline character from the end of the input the user  #\n   # gave us.                                                         #\n   #------------------------------------------------------------------#\n\n   chomp;\n\n   #-----------------------------------------------------------------#\n   #  if we had a $default value, and the user gave us input, then   #\n   #  return the input; if we had a default, and they gave us no     #\n   #  no input, return the $defaultValue.                            #\n   #                                                                 # \n   #  if we did not have a default value, then just return whatever  #\n   #  the user gave us.  if they just hit the <enter> key,           #\n   #  the calling routine will have to deal with that.               #\n   #-----------------------------------------------------------------#\n\n   if (\"$defaultValue\") {\n      return $_ ? $_ : $defaultValue;    # return $_ if it has a value\n   } else {\n      return $_;\n   }\n}\n\nsub launch {\n\n  print(\"Building MOD SDK (version $Q3_VER)\\n\");\n  print(\"Before building the mod sdk, your CVS tree must be completely clean!\\nIf there are some temporary files and binaries in the tree, they can get included in the distribution and cause problems.\\n\");\n  $ok = &promptUser(\"Ready to build mod sdk [y/n]? \");\n  if ($ok ne 'y')\n  {\n    print(\"aborting\\n\");\n    return 0;\n  }  \n  # create the dirs:\n  $RAW_DATA = \"mod-sdk-$Q3_VER\";\n  system(\"rm -rf $RAW_DATA ; mkdir -p $RAW_DATA/code\");\n  # actual code\n  system(\"cp -R cgame game q3_ui ui $RAW_DATA/code\");\n  # UI stuff\n  system(\"cp -R ../ui $RAW_DATA\");\n  # tools\n  system(\"cp -R ../lcc ../q3asm $RAW_DATA\");\n  # build scripts\n  system(\"cp Construct $RAW_DATA/code\");\n  system(\"mkdir $RAW_DATA/code/unix ; cp unix/cons unix/pcons-2.3.1 unix/Conscript-pk3 $RAW_DATA/code/unix\");\n  system(\"cp unix/mod-sdk-data/Makefile $RAW_DATA/code/\");\n  # cleanup some stuff\n  system(\"find $RAW_DATA -name CVS -exec rm -rf {} \\\\; 2>/dev/null\");\n  # test that the build works just fine\n  $host=`hostname`; chomp($host);\n  if ($host ne 'antares')\n  {\n    system(\"rm -rf /tmp/$RAW_DATA ; cp -R $RAW_DATA /tmp\");\n    system(\"cd /tmp/$RAW_DATA/code ; make\");\n    if ($? ne 0)\n    {\n      printf(\"ERROR: test build failed\\n\");\n      return 0;\n    }\n    printf(\"build test successful\\n\");\n  }\n  # make a setup out of this\n  system(\"cp -R unix/setup/setup.sh unix/setup/setup.data $RAW_DATA\");\n  # TODO: splash!\n  system(\"cp unix/mod-sdk-data/setup.xml unix/mod-sdk-data/config.sh unix/mod-sdk-data/postinstall.sh $RAW_DATA/setup.data\");\n  # mod-sdk-data/Q3A_EULA.txt is a copy of stuff that is usually in $Q3SETUPMEDIA .. can't be arsed\n  system(\"cp unix/mod-sdk-data/Q3A_EULA.txt $RAW_DATA\");\n  # I love those dirty hacks\n  system(\"cd $RAW_DATA/setup.data/bin ; ln -s Linux FreeBSD ; ln -s Linux OpenBSD ; ln -s Linux NetBSD\");\n  # cleanup some stuff\n  system(\"find $RAW_DATA -name CVS -exec rm -rf {} \\\\; 2>/dev/null\");\n  # weeee\n  system(\"unix/mod-sdk-data/makeself/makeself.sh $RAW_DATA $SDK_NAME \\\"Quake III Arena mod SDK\\\" ./setup.sh $Q3_VER\");\n  return 1;\n}\n\nprint(\"in Conscript-sdk\\n\");\n\n$env = new cons();\nCommand $env \"$SDK_NAME\", \"[perl] &launch()\";\n"
  },
  {
    "path": "code/unix/Conscript-setup",
    "content": "# setup\n\nImport qw( INSTALL_BASEDIR );\n\n$env = new cons(\n  # add this path so setup script finds brandelf\n  ENV => { PATH => $ENV{PATH} . \":\" . $ENV{HOME} . \"./usr/bin\", },\n);\n\nsub launch {\n  # need to get the correct version (i.e. from SP source)\n  $version = `cat game/q_shared.h | grep Q3_VERSION`;\n  chomp $version;\n  $version =~ s/.*Q3\\ (.*)\\\"/$1/;\n  print(\"version: $version\\n\");\n  system(\"cd unix ; ./build_setup.sh $version\");\n\n  return 1;\n}\n\n# no dependency to PB, we get it directly from the tree and not in install/\nDepends $env \"$INSTALL_BASEDIR/foo\",\n  \"$INSTALL_BASEDIR/linuxq3ded\",\n  \"$INSTALL_BASEDIR/linuxquake3-smp\",\n  \"$INSTALL_BASEDIR/linuxquake3\";\n  # during developement phase, we generate and copy the pk3 on the fly\n  # then those should move to the media tree\n# those have been finalized and moved to the media tree\n#  \"$INSTALL_BASEDIR/baseq3/pak8.pk3\",\n#  \"$INSTALL_BASEDIR/missionpack/pak3.pk3\";\n  \n  \nCommand $env \"$INSTALL_BASEDIR/foo\", \"[perl] &launch()\";\n"
  },
  {
    "path": "code/unix/LinuxSupport/CHANGES-1.32.txt",
    "content": "CHANGES 1.32\n\n11/13/2002 - 1.32b\n\nUpdate to the Linux client, fixing a number of issues:\n\n\n- Text mode install broken on glibc 2.3 (Debian Sid)\nhttp://bugs.debian.org/cgi-bin/bugreport.cgi?bug=165358\nCurrent Debian Sid's glibc package break backwards compatibility\nwith binaries compiled on older glibc and statically linked.\nThis will cause the text mode setup to segfault.\n\nFor now you can either:\n - find a solution to run the graphical gtk-based setup\n - roll back to glibc 2.2\n - use an updated setup binary:\n   run the linux setup once, with the --keep option\n     (this will exand all the files to setup.tmp/)\n   get this updated setup file:\n     http://zerowing.idsoftware.com/linux/165358/setup\n   replace setup.tmp/setup.data/bin/Linux/x86/setup by the new one\n   cd to setup.tmp/ and run setup.sh \n\n\n- Current NVidia drivers don't officially support glibc 2.3 systems\nThis affects Debian Sid in particular, causing crashes during vid_restart\nThe issue is related to the SMP build depending upon libpthreads\n1.32b has both SMP and non-SMP binary. Use quake3-smp to launch\nthe SMP version if you want to use it.\n\n\n- SMP and non-SMP builds:\nDefault quake3 shortcut will spawn a non-SMP build. Use quake3-smp\nfor an SMP-enabled run. From the feedback we got after the 1.32 release, \nthe SMP support as designed in the Quake III Arena technology isn't so\nmuch relevant anymore. It was designed for much lower CPU frequencies\nand lower AGP throughputs. Modern systems won't benefit from SMP. Since\nit didn't make much sense to remove the SMP binary, we have both now.\n\n\n- Fixing broken mouse on Suse:\nStarting with XFree 4.2, the event timestamps returned by the X server \nare no longer matching gettimeofday. And there is currently no API in X \nto provide easy synchronisation. 1.32 introduced improved event timing \nby correcting event time with X server event timestamp (sub-frame timing).\nThis worked fine with XFree 4.1, and no longer does. 1.32b adds a safe\ncheck to work again with XFree 4.2, but basically the input timing is\nback to 1.31 quality.\n\nSome new cvars related to the mouse control:\nin_dgamouse - not new, but be sure to have it set to 1 on any recent system\nin_subframe - completely disables sub-frame timing. If XFree 4.2\n  in_subframe 1 won't hurt, but it won't do anything either.\nin_nograb   - for mod developers. Set to 1 and run windowed, Q3 won't be\n  grabbing your mouse pointer (useful for debug breaks)\n\n\n8/26/2002\n\nGeneral:\n\n- new network protocol, 68\n\n- network code:\n  improved fragmented messages handling\n  map change while client loads map no longer causes an 'Invalid .PK3' error\n  map_restart while client loads map no longer causes a reload\n  fixing donedl being ignored after autodl if map_restart'ed\n- the demo command has a list of compatible protocols, it will loop through 66 67 68\n  you can do '/demo four' and it will try four.dm_66 four.dm_67 four.dm_68\n  or you can explicitely give a '/demo demoname.dm_??'\n\n- added mousewheel support in the console: \n  wheel to scroll, ctrl+wheel to scroll faster, shift+wheel to scroll history\n\n- UI in baseq3/ and missionpack/ for PunkBuster configuration\n  punkbuster server in server creation dialog (sv_punkbuster)\n  punkbuster client in server browser (cl_punkbuster)\n  added PB Yes/No to the browsers\n- removed obsolete MPlayer UI stuff\n- bumped server browser to handle up to 4096 servers\n\n- IP maintained in userinfo\n- cl_guid in userinfo (as part of PB integration)\n- printing ports as unsigned ints, no longer printing negative port numbers\n- cleaned up the legacy IP banning code\n  use * for IP pattern matching now instead of 0 (fixes some confusion)\n    ex: 192.246.12.*\n  made it safe from overflowing and crashing\n  NOTE: using PunkBuster's banning system is advised instead though\n- rcon: some fixes to the buffering to avoid overflowing and dropping parts of the message \n- rcon: now supports quoting /rcon g_motd \"foo bar\"\n- added SVF_CLIENTMASK (0x00000002), works only with <= 32 players\n\tset bitmask of players to which send entity\n- pushed cl_maxpackets upper limit to 125\n- added [skipnotify] from RTCW, use to display in the console only, but not on client screen\n\t(also fixes pb_msgprefix and pb_sv_msgprefix)\n\n- new cvar sv_lanForceRate (defaults 1):\n  forces LAN clients to the maximum rate instead of accepting client setting\n  (1 is the default behaviour, backward compatible)\n\n- new cvar sv_strictAuth (defaults 1):\n  server side variable to control wether strict CDKEY auth should be performed with the auth server\n  this is required if you want reliable cl_guid for the server (for users tracking)\n\n- filesystem:\n  client re-orders it's pk3s according to the order given by server\n  (fixes some 'Invalid .PK3 files referenced' situations\n\n- fixed invisible entities/players bug (thanks goes to Rick Johnson / Raven for this one!)\n- update x86 VM code (better and safer optimisations) (Richk Johnson / Raven too)\n- clearing client gentity before GAME_INIT call\n- failing vote if there's only one voting client (fixes exploit on 2-player server where one player votes then disconnects, forcing vote to pass)\n\n- added trap_FS_Seek\n\n- renderer fix:\n  if client game code registers a shader after drawsurfaces are generated but before frame is rendered\n  had a one-frame visual glitch (shader indexes messed up)\n- renderer fix:\n  r_roundImagesDown 0 + map q3dm1 -> crash (buffer overflow fix)\n- renderer fix:\n  fixed a crash in widescreen displays (q3dm11)\n- renderer fix:\n  MAX_SHADERS up to 2^12  \n- renderer fix:\n  moved screenshot from frontend to backend, fixes broken r_smp 1 screenshots\n\n- TA fixes:\n  MOD_KAMIKAZE MOD_JUICED logging properly to games.log\n  fixed bot taunt spamming\n- fixed typo in scripts/models2.shader (shader error Ursula head)\n\nWin32 specific:\n\n- fixed the DirectInput mouse init procedure\n- rcon:\n  fixed rcon not working on NT/2000/XP workstations that have a long uptime\n\nLinux specific:\n\n- no longer trying to load libMesaVoodooGL.so\n  obsolete code, was confusing when trying to setup correct OpenGL acceleration\n- SMP support in the renderer. Detects CPU count, r_smp 1 default if available. (thanks to Gareth Hughes for contributing this)\n- changed default GL driver from libGL.so to libGL.so.1\n  see LSB 1.2 spec: http://www.linuxbase.org/spec/refspecs/LSB_1.2.0/gLSB/libgl.html\n- Handle Ctrl and Space key together correctly (Ctrl was disabling Space)    \n- sub-frame timing of input events (key/mouse) (input timing quality now equivalent to win32)\n"
  },
  {
    "path": "code/unix/LinuxSupport/INSTALL",
    "content": "                      Quake III Arena\n                   Quake III: Team Arena\n                 Installation instructions\n                          ------\n\nWhat you need:                          \n\n- retail CD-ROM of Quake III Arena for Windows or linux\n- optionally, retail CD-ROM of Quake III: Team Arena \n- a computer running linux (kernel >= 2.2 glibc >= 2.1)\n- running the client requires X11 and 3D hardware acceleration with OpenGL\n\nInstallation:\n\nIf you have the retail CD-ROM of Quake III Arena for linux:\n- install Quake III Arena from the CD-ROM\n- run the Point Release installer\n(to buy Quake III Arena for linux online, try http://www.tuxgames.com/)\n\nIf you have the retail CD-ROM of Quake III Arena for Windows:\n- run the Point Release installer first\n- now you need to copy the main pak files from the CD-ROM\n  or from your win32 partition. Namely, you need to copy baseq3/pak0.pk3\n  and for Team Arena, missionpack/pak0.pk3\n  see below for more instructions on how to copy the files:\n\nWARNING: Those instructions are provided as a reference, \ndepending on your distribution the CD-ROM might not have the same \nmount point. Please refer to your linux documentation for additional \ninformation.\n\n- open a root shell and cd to the default installation path:\n  cd /usr/local/games/quake3\n- mount the Quake III Arena CD-ROM and install the game content\n  cp /mnt/cdrom/Quake3/baseq3/pak0.pk3 /usr/local/games/quake3/baseq3\n- optionally, mount the Quake III: Team Arena CD-ROM\n  cp /mnt/cdrom/Setup/missionpack/pak0.pk3 /usr/local/games/quake3/missionpack\n  \nNOTES:\n- If you are running Quake III Arena and Quake III: Team Arena on a \n  Windows partition, you can save some space by symlinking the game \n  assets to their windows installation:\n  ln -s /win/quake3/baseq3/pak0.pk3 /usr/local/games/quake3/baseq3/pak0.pk3\n  ln -s /win/quake3/missionpack/pak0.pk3 /usr/local/games/quake3/missionpack/pak0.pk3\n  (Windows partition is mounted as /win and Quake III Arena installation is C:\\quake3)\n\nGetting Help:\n\n- consult the FAQ in Help/Q3A_FAQ.html\n- head over to the Quake3World forums http://www.quake3world.com/forums\n- consult the list of known issues and tips at \n  http://zerowing.idsoftware.com/linux\n"
  },
  {
    "path": "code/unix/LinuxSupport/index.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"><html><head>\n  <title>Linux Quake III Arena Known issues</title></head>\n\n<body text=\"#000000\" bgcolor=\"#ffffff\">\n<font size=\"+2\"><b>Linux Quake III Arena Known issues</b></font><br>\n<i>Known issues and frequently asked questions - 1.32b</i><br>\n<br>\n<a href=\"mailto:ttimo@idsoftware.com\">TTimo</a><br>\n<i>Changes history</i><br>\n2004.2.20 Last update<br>\n2001.6.18 Initial version\n<hr size=\"1\"><br>\n<font size=\"+1\">Current topics</font>\n<ul>\n  <li><a href=\"#install\">Installation instructions</a></li>\n  <li><a href=\"#setupfiles\">What do I do with a .x86.run file?</a></li>\n  <li><a href=\"#glibc\">The setup crashes with <i>Segmentation fault \"$setup\" \"$@\" 2>/dev/null</i></a></li>\n  <li><a href=\"#bsd\">Installation on BSD</a></li>\n  <li><a href=\"#auth\">CLIENT_UNKNOWN_TO_AUTH</a></li>\n  <li><a href=\"#pk3\">Sys_Error: Couldn't load default.cfg / Sys_Error: FS_FreeFile(\nNULL )</a></li>\n  <li><a href=\"#setupbug29h\">I get <i>./setup.sh {: ==: binary operator expected</i>\nwhen running the setup?</a></li>\n  <li><a href=\"#hints\">The game doesn't start, I have performance problems,\netc.</a></li>\n  <li><a href=\"#aureal\">Aureal sound drivers</a></li>\n  <li><a href=\"#nosound\">The sound doesn't work / sound crashes</a></li>\n  <li><a href=\"#discuss\">Where can I report bugs and discuss about linux\nQuake III Arena?</a></li>\n  <li><a href=\"#gameso\">The *.so files are not in the setups? (<i>cgamei386.so\nqagamei386.so uii386.so</i>)</a></li>\n  <li><a href=\"#vm_game\">I get <i>Sys_Error: Sys_LoadDll(..) failed dlopen()\ncompletely!</i> when running quake3?</a></li>\n  <li><a href=\"#3dnow\">I have an AMD CPU and a kernel 2.4.*, Quake III Arena\nis slowing down to a complete stop after a while?</a></li>\n  <li><a href=\"#gamma\">How do I set up the gamma correction?</a></li>\n  <li><a href=\"#browser\">Servers don't show up in the ingame browser</a></li>\n  <li><a href=\"#libsafe\">Detected an attempt to write across stack boundary</a></li>\n  <li><a href=\"#libmesa\">libMesaVoodooGL.so</a></li>\n  <li><a href=\"#UDPwide\">Running a LAN dedicated server with multiple network\ninterfaces</a></li>\n  <li><a href=\"#64bits\">Setup and execution on 64 bits CPUs</a></li>\n  <li><a href=\"#links\">Links</a></li>\n</ul>\n<hr size=\"1\"><font size=\"+1\"><a name=\"install\"><b>Installation instructions</b></a></font>\n<a name=\"install\"><br>\n</a>\n<p><a name=\"install\">Linux Quake III Arena is using a graphical installer\n(based on Loki software's </a><a href=\"http://www.icculus.org/loki_setup/\">Setup Graphic Installer\n</a>). However, since it's a Point Release, you need a retail CD-ROM of  Quake\nIII Arena to perform a complete installation (and optionally your Quake III:\nTeam Arena CD-ROM). This process is documented in the <a href=\"http://zerowing.idsoftware.com/linux/q3a/INSTALL\">INSTALL</a>file\n(this file is also in the setups, it's default location is /usr/local/games/quake3/INSTALL\n.. you can run the PR setup and read it to finish the installation afterwards).</p>\n<font size=\"+1\"><a name=\"setupfiles\"><b>What do I do with a .x86.run file?</b></a></font>\n<a name=\"setupfiles\"><br>\n</a>\n<p>Those are setup files, meant to be executed. They\ncome with graphical  installation UI or console installation, depending on\nwhat's available on your system. You may need to <i>chmod +x file.x86.run</i>\nto make them executable.</p>\n<font size=\"+1\"><a name=\"glibc\"><b>The setup crashes with <i>Segmentation fault \"$setup\" \"$@\" 2>/dev/null</i></b></a></font>\n<p>This is happening on glibc 2.3 systems such as RedHat 9 and Suze. The text mode installer will crash. If you can do a graphical installation, make sure you have Gtk1 installed and avoid the text installer altogether.\nIf you are doing a remote installation (such as a dedicated server through ssh), you need to use a newer text mode installer. Run the installer with <i>--keep</i> to extract the files \n(look for a <i>setup*</i> directory in the current directory for the extracted setup). \nThen replace <i>setup.data/bin/Linux/x86/setup</i> by <a href=\"http://zerowing.idsoftware.com/linux/setup-RH9/setup\">this newer version</a>. Run <i>setup.sh</i> at top level and things should work fine.</p>\n<p>\n<b>Update</b>: Turns out this solution is working for RTCW and ET, but not for Q3 (because the last q3 setup uses an older version of the installer). Will update a specific solution for Q3 'soon'.\n</p>\n<font size=\"+1\"><a name=\"bsd\"><b>Installation on\nBSD</b></a></font><a name=\"bsd\"><br>\n</a>\n<p><a name=\"bsd\">The linux binaries will run fine on the BSD family (FreeBSD,\nNetBSD and OpenBSD) with the linux binary compatibility software. However\nif you are getting the  error message <i>ELF binary type \"0\" not known</i>\nwhile installing or trying to run the binaries, that means you need to run\n<i>brandelf</i> on the files.</a></p>\n<p><a name=\"bsd\">If it's a setup problem, proceed with the following steps:\n</a></p>\n<pre><a name=\"bsd\">./linuxq3apoint-1.31.x86.run --keep<br>brandelf -t Linux setup.tmp/setup.data/bin/FreeBSD/x86/setup<br>cd setup.tmp<br>sh ./setup.sh<br></a></pre>\n<p><a name=\"bsd\">The --keep option will extract the files and leave them\nsomewhere below your current directory. Depending on the game (Q3 or RTCW)\nand the setup version, your mileage may vary (setup.tmp or another directory).</a></p>\n<p><a name=\"bsd\">The game binaries might need to be brandelf'ed too, with\na command such as</a></p>\n<pre><a name=\"bsd\">brandelf -t Linux /usr/local/games/quake3/quake3.x86<br></a></pre>\n<a name=\"bsd\"></a><font size=\"+1\"><a name=\"auth\"><b>CLIENT_UNKNOWN_TO_AUTH</b></a></font>\n<a name=\"auth\"><br>\n</a>\n<p><a name=\"auth\">Graeme Devine recently updated his <i>.plan</i> with very\ncomplete </a><a href=\"http://www.webdog.org/cgi-bin/finger.plm?id=279&amp;time=20011210020942\" target=\"_new\">information about CLIENT_UNKNOWN_TO_AUTH errors</a>.</p>\n<p>\nSee some additional information from the <a href=\"http://www.gameadmins.com/modules.php?name=Mail_List\">gameadmins.com mailing list</a>:\n</p> \n<pre>If the server you are playing on and the auth server don't see you as the\nsame IP (for instance you are trying to play on a public internet server\nthat's on your LAN, and your internet access is using NAT), then it won't\nwork.\n\nIt used to work in 1.31, and it doesn't in 1.32. PunkBuster requires\nreliable auth of the players. What you can do:\n\n- run a server with sv_strictauth 0 and you'll be able to join your\nserver. This will be the same behaviour as 1.31\n\n- connect to a server on the internet before you connect to your local\nserver (this will trigger your IP into the cache of the auth server for\n15mn and let you in to your local server).\n\n- setup two NATs, one for your client one for your server and make sure\nyour server and Id's auth see the same IP. (this one ain't for network\nsetup newbies)\n</pre>\n<font size=\"+1\"><a name=\"pk3\"><b>Sys_Error: Couldn't load default.cfg / Sys_Error:\nFS_FreeFile( NULL )</b></a></font><br>\n<p>If you get one of these errors after installing Quake III Arena or Return\nTo Castle Wolfenstein, it means that the engine didn't find all the required\n.pk3 files. Either you didn't copy them, or you copied them to the wrong\nplace. Check the INSTALL instructions for the game for more details, make\nsure they are in baseq3/ for quake3 (missionpack/ for TA files) and main/\nfor Return To Castle Wolfenstein.</p>\n<font size=\"+1\"><a name=\"setupbug29h\"><b>I get <i>./setup.sh {: ==: binary\noperator expected</i> when running the setup?</b></a></font><a name=\"setupbug29h\"><br>\n</a>\n<p><a name=\"setupbug29h\">This is a known issue to 1.29h setups and prior.\nIt happens on systems with bash  version &lt; 2.*. There are several solutions:<br>\n- Upgrade bash to something more recent and run the setup again - Run the\nsetup with the --keep option. It will fail but it will leave a <i>setup-full</i>\ndirectory. You can then copy the files manually from that dir. - Once you\nused the --keep option above, you can edit setup.sh and replace  occurences\nof == by =. Then run setup.sh and the installer will execute.</a></p>\n<a name=\"setupbug29h\"></a><font size=\"+1\"><a name=\"hints\"><b>The game doesn't\nstart, I have performance problems, etc.</b></a></font><br>\n<p>The first thing to do is to check on the forums and various FAQs (this\none, but  there are others. See the <a href=\"#links\">links</a>). The Quake3World\nforums have a great search function.</p>\n<p>Before reporting the problem to <a href=\"mailto:ttimo@idsoftware.com\">me</a>\nmake sure it's an issue with the game, and not an issue with your  OS/OpenGL/sound\nconfiguration. Common OS issues are listed in this FAQ. You should make sure\nyou have OpenGL configured correctly (by checking if <i>gears</i>is running\nfor instance, and how well it runs). And see if non-Id linux games are running\nfine too.</p>\n<p>When you are going to report a bug, first make sure you are using the\nlatest version of the game. Include the game version in your report.</p>\n<p>Include general information about your OS:<br>\n</p>\n<ul>\n  <li>Motherboard brand, CPU type, RAM</li>\n  <li>distribution name and version</li>\n  <li>kernel / OS info (from <i>uname -a</i>)</li>\n  <li>libc version (<i>ls -l /lib/libc.so.*</i>)<br>\n please specify if you can if the libc is your distribution's standard\nversion, or if you compiled yourself, and what binary target was used (x86,\nor AMD, i686 etc.)</li>\n</ul>\n<p>If it's a problem with the client, send the output of <i>glxinfo</i>.</p>\n<p>If you have an nvidia board, send the output of <i>cat /proc/nv/card0</i>\n</p>\n<p>Send output of the run:<br>\nrun the game with <i>+set developer 1</i> option, and send the output. You\ncan do something like <i>quake3 +set developer 1 &amp;&gt;q3run.log</i>.</p>\n<p>If it's a crash, you can send a backtrace of the game running  through\n<i>gdb</i>.</p>\n<p>You can also send a log of the game running with <i>strace</i>:</p>\n<pre>cd /usr/local/games/quake3<br>strace -o ~/strace.log ./quake3.x86<br></pre>\n<p>NOTE: please <b>avoid</b> sending me the <i>strace</i> of <i>/usr/local/games/quake3/quake3</i>,\nwhich is a shell script wrapper and probably no interest to your problem.\n</p>\n<font size=\"+1\"><a name=\"aureal\"><b>Aureal sound drivers</b></a></font><a name=\"aureal\"><br>\n</a>\n<p><a name=\"aureal\">It seems that some versions of the Aureal sound drivers\ndon't work right with Q3. Last I heard, a kernel upgrade to 2.4.17 + Aureal\n1.1.3, and/or using the  old 1.1.1 drivers from </a><a href=\"http://aureal.sourceforge.net/\" target=\"_new\">Aureal's website</a>fixed\nthe problem.</p>\n<p>If you need to know more about this, have a look at this <a href=\"http://www.quake3world.com/ubb/Forum15/HTML/001348.html\" target=\"_new\">Q3W forum thread</a>.</p>\n<font size=\"+1\"><a name=\"nosound\"><b>The sound doesn't work / sound crashes</b></a></font><br>\n<p>The first thing to check is that it is actually a sound related.  Run\nthe game with <i>+set s_initsound 0</i> and see what happens.  All problems\nreported so far about sound turned out to be OS/drivers.  Listed below:</p>\n<p>On some Mandrake distributions:<br>\nCheck if you are running the enlightenment sound daemon (esd). With <i>ps\naux | grep esd</i>for instance. It is a multiplexer for /dev/dsp, and might\nblock use of /dev/dsp by Quake III Arena. You can disable esd with <i>esdctl\nstop</i> (as root).</p>\n<p><b><a href=\"http://www.linux-mandrake.com/\">Mandrake 8</a></b>'s default\nsound drivers seem broken, installing the <a href=\"http://www.alsa-project.org/\" target=\"_new\">Alsa drivers</a> or the\n <a href=\"http://www.opensound.com/\">http://www.opensound.com</a>  drivers\nfixes the problem.</p>\n<p>Some beta <a href=\"http://www.alsa-project.org/\" target=\"_new\">Alsa drivers</a>\nhave  been reported to crash with Q3. Non-beta ones are fine.</p>\n<p>VIA chipset and AC97 driver:<br>\nThis combination is known to have various issues. They have been fixed in\nrecent drivers (thanks to Arne Schmitz for the heads up):<br>\n</p>\n<pre>http://sourceforge.net/projects/gkernel has got the up to date version of <br>the AC97 kernel driver. The current version can be found here:<br><br>http://prdownloads.sourceforge.net/gkernel/via82cxxx-1.1.15.tar.gz<br><br>It has working mmap sound, so Q3 shouldn't be a problem any more.<br></pre>\n(thanks to Arne Schmitz for the heads up)<p></p>\n\n<font size=\"+1\"><a name=\"discuss\"><b>Where can I report bugs and discuss about linux Quake III\nArena?</b></a></font><a name=\"discuss\"><br>\n</a>\n<p><a name=\"discuss\">Reports bugs to </a><a href=\"mailto:bugs@idsoftware.com\">bugs@idsoftware.com</a>. If you are pretty\nsure this is a linux-only issue, you can shorten the loop by emailing <a href=\"mailto:ttimo@idsoftware.com\">ttimo@idsoftware.com</a> directly.</p>\n<p>You will find the discussion forums for linux Quake III Arena on <a href=\"http://www.quake3world.com/cgi-bin/forumdisplay.cgi?action=topics&amp;forum=*nix+Discussion&amp;number=15&amp;DaysPrune=30&amp;LastLogin=\">\nQuake3World forums</a>. There is for sure a lot of other places to talk about\nlinux Quake III Arena, but this is the one we read regularly to track bugs\nand common issues.</p>\n<font size=\"+1\"><a name=\"gameso\"><b>The *.so files are not in the setups?\n(<i>cgamei386.so qagamei386.so uii386.so</i>)</b></a></font><a name=\"gameso\"><br>\n</a>\n<p><a name=\"gameso\">If you still have <i>baseq3/*.so</i> and <i>missionpack/*.so</i>\nfiles, then those come from the earlier 1.27g beta installation and you should\nREMOVE them. They were provided in 1.27g to go around a bug in the VM code,\nwhich made win32 VMs incompatible with linux. This problem has been fixed\nand the two files are no longer required.</a></p>\n<p><a name=\"gameso\">If you are upgrading from 1.27g, it is likely that your\n<i>q3config.cfg</i> files are set to use the native libraries (*.so files)\ninstead of the bytecode. Run quake3 with the following options to set things\nright:<br>\n<i>quake3 +set vm_game 2 +set vm_cgame 2 +set vm_ui 2</i></a></p>\n<a name=\"gameso\"></a><font size=\"+1\"><a name=\"vm_game\"><b>I get <i>Sys_Error:\nSys_LoadDll(..) failed dlopen() completely!</i>when running quake3?</b></a></font><a name=\"vm_game\"><br>\n</a>\n<p><a name=\"vm_game\">Try running quake3 with the following options:<br>\n<i>quake3 +set vm_game 2 +set vm_cgame 2 +set vm_ui 2</i><br>\nYou should also read the </a><a href=\"#gameso\">above answer</a>.</p>\n<font size=\"+1\"><a name=\"3dnow\"><b>I have an AMD CPU and a kernel 2.4.*,\nQuake III Arena is slowing down to a complete stop after a while?</b></a></font><br>\n<p>It seems the 3DNow! copy routines have issues with the southbridge chip\nin the KT133A, this results in performances degrading while playing for a\nwhile. Re-compile your kernel without 3DNow! instructions to avoid the problem,\nand wait for newer kernels with better support for 3DNow! / KT133A.</p>\n<font size=\"+1\"><a name=\"gamma\"><b>How do I set up the gamma correction?</b></a></font><br>\n<p>Starting with 1.29h, you can set the gamma correction with the brightness\nslider in the graphical menu (under setup). On some older systems which don't\nhave the appropriate XFree86 extensions, you might have to set <b>r_gamma</b>\nmanually from the console, and issue a <b>vid_restart</b> command.</p>\n<font size=\"+1\"><a name=\"browser\"><b>Servers don't show up in the ingame\nbrowser</b></a></font>\n<p>The reason for this has not been clearly identified yet, seems to be related\nto upgrade from older versions. Deleting ~/.q3a/baseq3/q3config.cfg fixes\nthe problem (you will have to reconfigure your bindings)</p>\n<font size=\"+1\"><a name=\"libsafe\"><b>Detected an attempt to write across\nstack boundary</b></a></font>\n<p>If Quake III Arena exits with the error \"Detected an attempt to write\nacross stack boundary\", this probably means that you are running libsafe\non this system. Quake III Arena is compiled with some options that confuse\nlibsafe, you should disable it before running. See <a href=\"http://www.mudos.org/?faq\" target=\"_new\">this page</a> for more details.\n</p>\n<font size=\"+1\"><a name=\"libmesa\"><b>libMesaVoodooGL.so</b></a></font>\n<p>The GL driver for Voodoo cards (libMesaVoodoGL.so) used to be distributed\nin older Q3 setups. <b>This is no longer the case.</b> If you have this .so\nin your Quake III Arena directory (<i>/usr/local/games/quake3</i>), you should\nremove it. Any recent/decent linux distribution should support your Voodoo\ncard out of the box, otherwise it is recommended that you setup  XFree 4.*\nand the correct DRI infrastructure for it.</p>\n<font size=\"+1\"><a name=\"UDPwide\"><b>Running a LAN dedicated server with\nmultiple network interfaces</b></a></font>\n<p>A LAN dedicated server will use the <i>net_ip</i> cvar to identify the\nNIC it is going to use (default is \"localhost\"). As it only opens one socket,\nit is not possible to have a server broadcast it's packets on all the NICs.\nThis can be a problem if the server is serving games for a LAN and runs several\nNICs to access the various sub networks.<br>\n</p>\n<p>The following Linux kernel patch (2.4.19) was provided by Rogier Mulhujzen\nand John Tobin, it will force broadcasts to be emitted on all interfaces:<br>\n<a href=\"http://zerowing.idsoftware.com/linux/q3a/udp_wide_broadcast.patch\">udp_wide_broadcast.patch</a><br>\n<a href=\"http://zerowing.idsoftware.com/linux/q3a/udp_wide_README.txt\">udp_wide_README.txt</a><br>\nThe equivalent <a href=\"http://www.bsdchicks.com/patches/\">patch for FreeBSD</a>\nis available too.<br>\n </p>\n<font size=\"+1\"><a name=\"64bits\"><b>Setup and execution on 64 bits CPUs</b></a></font><br>\n<p>If you are running Linux on a 64 bit CPU (such as AMD's Opteron), and if your system is backwards compatible so that it can execute 32 bits x86 binaries, then the regular Quake III Arena binaries should work (your mileage may vary).</p>\n<p>It's likely that the installer scripts will get confused though, and will refuse to install giving you an error: \"This installation doesn't support glibc-2.1 on Linux / unknown\". You will have to extract the game files manually by passing --keep on the command line when running the setup script. Once the files are unpacked, you will need to copy them manually to /usr/local/games. You probably want to have a working installation to refer to while doing this. This also applies to RTCW and ET</p>\n<font size=\"+1\"><a name=\"links\"><b>Links</b></a></font><br>\n<p>The <a href=\"http://www.icculus.org/lgfaq\" target=\"_new\">Linux Gamer's\nfaq</a> is a very good resource for general Linux Gaming topics.</p>\n<p>Also at <a href=\"http://www.icculus.org/\" target=\"_new\">icculus.org</a>,\nthe <a href=\"http://www.icculus.org/lgfaq/loki/q3faq.html\" target=\"_new\">old\nQ3 FAQ from Loki Software</a>.</p>\n<p><a href=\"http://www.quake3world.com/ubb/Forum15/HTML/000529.html\">Quake3World's\nlinux FAQ</a></p>\n<br>\n</body></html>\n"
  },
  {
    "path": "code/unix/LinuxSupport/udp_wide_README.txt",
    "content": "UDP Wide Broadcast Patch for Kernel 2.4.19\n\nMain purpose is to allow Quake 3 servers, and all games powered by the\nengine, to be visible in the server browser when the servers are being run on\naliased IP addresses and multiple NICs using the +set net_ip option.\n\nTo apply the patch run \"patch -p1 < udp_wide_broadcast.patch\" from your\nsource directory and recompile.\n\nAdd \"echo \"1\" > /proc/sys/net/ipv4/udp_wide_broadcast\" to one of your startup\nscripts, i.e./etc/rc.d/rc.local, and run thousands of servers from your\ncomputer.\n\n\nPatch by:\nRogier Mulhujzen <linux@bsdchicks.com>\nJohn Tobin <ogre@sirinet.net>\n\nA patch with the same functionality for FreeBSD is available from\nhttp://www.bsdchicks.com/patches\n"
  },
  {
    "path": "code/unix/LinuxSupport/udp_wide_broadcast.patch",
    "content": "--- linux/include/linux/sysctl.h.orig\t2002-08-17 19:52:27.000000000 -0500\n+++ linux/include/linux/sysctl.h\t2002-08-17 19:53:00.000000000 -0500\n@@ -291,7 +291,8 @@\n \tNET_IPV4_NONLOCAL_BIND=88,\n \tNET_IPV4_ICMP_RATELIMIT=89,\n \tNET_IPV4_ICMP_RATEMASK=90,\n-\tNET_TCP_TW_REUSE=91\n+\tNET_TCP_TW_REUSE=91,\n+\tNET_UDP_WIDE_BROADCAST=92\n };\n \n enum {\n--- linux-modified/net/ipv4/sysctl_net_ipv4.c.orig\t2002-08-17 19:48:19.000000000 -0500\n+++ linux-modified/net/ipv4/sysctl_net_ipv4.c\t2002-08-17 19:52:03.000000000 -0500\n@@ -45,6 +45,9 @@\n extern int inet_peer_gc_mintime;\n extern int inet_peer_gc_maxtime;\n \n+/* From udp.c */\n+extern int sysctl_udp_wide_broadcast;\n+\n #ifdef CONFIG_SYSCTL\n static int tcp_retr1_max = 255; \n static int ip_local_port_range_min[] = { 1, 1 };\n@@ -221,6 +224,8 @@\n \t &sysctl_icmp_ratemask, sizeof(int), 0644, NULL, &proc_dointvec},\n \t{NET_TCP_TW_REUSE, \"tcp_tw_reuse\",\n \t &sysctl_tcp_tw_reuse, sizeof(int), 0644, NULL, &proc_dointvec},\n+\t{NET_UDP_WIDE_BROADCAST, \"udp_wide_broadcast\",\n+\t &sysctl_udp_wide_broadcast, sizeof(int), 0644, NULL, &proc_dointvec},\n \t{0}\n };\n \n--- linux-modified/net/ipv4/udp.c.orig\t2002-08-17 19:40:59.000000000 -0500\n+++ linux-modified/net/ipv4/udp.c\t2002-08-17 23:37:47.000000000 -0500\n@@ -94,6 +94,8 @@\n #include <net/inet_common.h>\n #include <net/checksum.h>\n \n+int sysctl_udp_wide_broadcast = 0;\n+\n /*\n  *\tSnmp MIB for the UDP layer\n  */\n@@ -272,9 +274,10 @@\n \t\tif ((s->num != hnum)\t\t\t\t\t||\n \t\t    (s->daddr && s->daddr!=rmt_addr)\t\t\t||\n \t\t    (s->dport != rmt_port && s->dport != 0)\t\t\t||\n-\t\t    (s->rcv_saddr  && s->rcv_saddr != loc_addr)\t\t||\n-\t\t    (s->bound_dev_if && s->bound_dev_if != dif))\n+\t\t    !(sysctl_udp_wide_broadcast || !(s->rcv_saddr  && s->rcv_saddr != loc_addr))\t||\n+\t\t    (s->bound_dev_if && s->bound_dev_if != dif)) {\n \t\t\tcontinue;\n+\t\t}\n \t\tbreak;\n   \t}\n   \treturn s;\n"
  },
  {
    "path": "code/unix/Makefile",
    "content": "#\n# Quake3 Unix Makefile\n#\n# Currently build for the following:\n#\tLinux i386 (full client)\n#\tLinux Alpha (dedicated server only) (TTimo: dropped)\n#\tFreeBSD i386 (dedicated server only) (TTimo: maybe worth updating)\n#\tSGI IRIX (full client) (TTimo: who's in charge - dropped otherwise)\n#   Linux PPC (full client) (TTimo: dropped)\n#\n# Nov '98 by Zoid <zoid@idsoftware.com>\n#\n# Loki Hacking by Bernd Kreimeier \n#  and a little more by Ryan C. Gordon.\n#  and a little more by Rafael Barrero\n#\n# GNU Make required\n#\n\nPLATFORM=$(shell uname|tr A-Z a-z)\nPLATFORM_RELEASE=$(shell uname -r)\n\n###\n### These paths are where you probably want to change things\n###\n\n# Where we are building from (where the source code should be!)\nMOUNT_DIR=../\n\n# Where we are building to, libMesaVoodooGL.so.3.3 should be here, etc.\n# the demo pk3 file should be here in demoq3/pak0.pk3 or baseq3/pak0.pk3\nBDIR=$(MOUNT_DIR)/../run\n\n\n# Build name\n# BUILD_NAME=$(BUILD_NAME)\nBUILD_NAME=quake3.x86\n\n\n\n#############################################################################\n##\n## You shouldn't have to touch anything below here\n##\n#############################################################################\n\nBASEQ3_DIR=$(BDIR)/baseq3\n\nBD=debug$(ARCH)$(GLIBC)\nBR=release$(ARCH)$(GLIBC)\nCDIR=$(MOUNT_DIR)/client\nSDIR=$(MOUNT_DIR)/server\nRDIR=$(MOUNT_DIR)/renderer\nCMDIR=$(MOUNT_DIR)/qcommon\nUDIR=$(MOUNT_DIR)/unix\nGDIR=$(MOUNT_DIR)/game\nCGDIR=$(MOUNT_DIR)/cgame\nBAIDIR=$(GDIR)\nBLIBDIR=$(MOUNT_DIR)/botlib\nNDIR=$(MOUNT_DIR)/null\nUIDIR=$(MOUNT_DIR)/ui\nQ3UIDIR=$(MOUNT_DIR)/q3_ui\nFTDIR=$(MOUNT_DIR)/ft2\nJPDIR=$(MOUNT_DIR)/jpeg-6\nSPLNDIR=$(MOUNT_DIR)/splines\n\n# extract version info\nVERSION=$(shell ./extract_ver.pl)\nRPM_RELEASE=1\n\n# NOTE: used by dcp rcp targets, not referenced\n#TESTDIR=/home/timo/Id/Quake3-loki/run\n\n#############################################################################\n# SETUP AND BUILD -- LINUX\n#############################################################################\n\n## Defaults\nDLL_ONLY=false\n# bk010215 - TODO - add all defaults / kill Ryan\n\n\nifeq ($(PLATFORM),linux)\n\n  ifneq (,$(findstring libc6,$(shell if [ -e /lib/libc.so.6* ];then echo libc6;fi)))\n    GLIBC=-glibc\n  else\n    GLIBC=\n  endif #libc6 test\n\n  ifneq (,$(findstring alpha,$(shell uname -m)))\n    ARCH=axp\n    RPMARCH=alpha\n    VENDOR=dec\n  else\n    ifneq (,$(findstring ppc,$(shell uname -m)))\n      #used for linux builds\n      MESADIR=/usr/src/DRI-CVS/xc/xc/\n      ARCH=ppc\n      RPMARCH=ppc\n      VENDOR=unknown\n      DLL_ONLY=true\n    else #default to i386\n      MESADIR=../Mesa/\n      ARCH=i386\n      RPMARCH=i386\n      VENDOR=unknown\n      DLL_ONLY=false\n    endif\n  endif\n\n  # bk001205: no mo'  -I/usr/include/glide, no FX\n  # bk001205: no mo'  -Dstricmp=strcasecmp, see q_shared.h\n  BASE_CFLAGS =  -pipe -fsigned-char\n  # rcg010216: DLL_ONLY for PPC\n  ifeq ($(strip $(DLL_ONLY)),true)\n    BASE_CFLAGS += -DDLL_ONLY\n  endif\n\n\n  #GL_CFLAGS = -I$(MESADIR)/include -I/usr/X11R6/include\n  GL_CFAGS = -I/usr/X11R6/include\n\n  # bk001204 - need -O for -Wall for uninitialized\n  # bk001205 - took out -O to get assertions (NDEBUG)\n  # bk001206 - MALLOC_CHECK in addition to ZONE_DEBUG\n  # TTimo 03/30/2001 temporary took out -Werror for initial merge\n  DEBUG_CFLAGS = $(BASE_CFLAGS) -g  -Wall -Werror\n  DEBUG_CFLAGS += -DNO_MOUSEGRAB\n  DEBUG_CFLAGS += -O\n#  DEBUG_CFLAGS=$(BASE_CFLAGS) -g  -Wall -O\n  ifeq ($(ARCH),axp)\n    CC=pgcc\n    RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O6 -ffast-math -funroll-loops -fomit-frame-pointer -fexpensive-optimizations\n  else\n    ifeq ($(ARCH),ppc)\n      NEWPGCC=/loki/global/ppc/bin/gcc\n      CC=$(NEWPGCC)\n      RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O6 -fomit-frame-pointer -pipe -ffast-math -malign-loops=2 -malign-jumps=2 -malign-functions=2 -fno-strict-aliasing -fstrength-reduce\n    else\n      #NEWPGCC=/usr/local/gcc-2.95.2/bin/gcc # bk001205\n      #NEWPGCC=/loki/global/x86/bin/gcc\n      NEWPGCC=/usr/bin/gcc\n      CC=$(shell if [ -f $(NEWPGCC) ]; then echo $(NEWPGCC); else echo pgcc; fi )\n      CXX=/usr/bin/g++\n# TTimo: legacy RELEASE_CFLAGS\n# NOTE: the -fomit-frame-pointer option leads to an unstable binary on my test box if it was built on the main box\n#   but building on the Mdk 7.2 baseline seems to work\n      RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O6 -mcpu=pentiumpro -march=pentium -fomit-frame-pointer -pipe -ffast-math -malign-loops=2 -malign-jumps=2 -malign-functions=2 -fno-strict-aliasing -fstrength-reduce\n# TTimo: use this for building on P3 gcc 2.95.3 libc2.2 for all targets (experimental! -fomit-fram-pointer removed)\n#      RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O6 -mcpu=pentiumpro -march=pentium -pipe -ffast-math -malign-loops=2 -malign-jumps=2 -malign-functions=2 -fno-strict-aliasing -fstrength-reduce\n    endif\n  endif\n\n  LIBEXT=a\n\n  SHLIBEXT=so\n  SHLIBCFLAGS=-fPIC\n  SHLIBLDFLAGS=-shared $(LDFLAGS)\n\n  ARFLAGS=ar rv\n  RANLIB=ranlib\n\n  THREAD_LDFLAGS=-lpthread\n  LDFLAGS=-ldl -lm\n  GLLDFLAGS=-L/usr/X11R6/lib -lX11 -lXext -lXxf86dga -lXxf86vm\n\n  ifeq ($(ARCH),axp)\n    TARGETS=\\\n\t  $(B)/$(PLATFORM)q3ded\n  else\n    TARGETS=\\\n\t  $(B)/$(PLATFORM)quake3 \\\n\t  $(B)/$(PLATFORM)quake3-smp \\\n\t  $(B)/$(PLATFORM)q3ded \\\n\t  $(B)/baseq3/cgame$(ARCH).$(SHLIBEXT) \\\n\t  $(B)/baseq3/qagame$(ARCH).$(SHLIBEXT) \\\n\t  $(B)/baseq3/ui$(ARCH).$(SHLIBEXT)     \\\n\t  $(B)/missionpack/cgame$(ARCH).$(SHLIBEXT) \\\n\t  $(B)/missionpack/qagame$(ARCH).$(SHLIBEXT) \\\n\t  $(B)/missionpack/ui$(ARCH).$(SHLIBEXT) \\\n#\t  $(B)/baseq3/vm/qagame.qvm \\\n#\t  $(B)/baseq3/vm/cgame.qvm \\\n#\t  $(B)/baseq3/vm/ui.qvm \\\n#\t  $(B)/missionpack/vm/qagame.qvm \\\n#\t  $(B)/missionpack/vm/cgame.qvm \\\n#\t  $(B)/missionpack/vm/ui.qvm\n  endif\n\n## $(B)/$(PLATFORM)q3static   \\\n\nelse # ifeq Linux\n\n#############################################################################\n# SETUP AND BUILD -- FREEBSD\n#############################################################################\n\nifeq ($(PLATFORM),freebsd)\n\nGLIBC= #libc is irrelevant\n\nifneq (,$(findstring alpha,$(shell uname -m)))\nARCH=axp\nRPMARCH=alpha\nVENDOR=dec\nelse #default to i386\nARCH=i386\nRPMARCH=i386\nVENDOR=unknown\nendif #alpha test\n\n\nBASE_CFLAGS =  -pipe\n\nGL_CFLAGS = -I$(MESADIR)/include -I/usr/X11R6/include\n\nDEBUG_CFLAGS=$(BASE_CFLAGS) -g  -Wall -Werror\nifeq ($(ARCH),axp)\nCC=pgcc\nRELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O6 -ffast-math -funroll-loops -fomit-frame-pointer -fexpensive-optimizations\nelse\n#NEWPGCC=/loki/global/x86/bin/gcc # raistlin012301\n#NEWPGCC=/usr/local/gcc-2.95.2/bin/gcc\nNEWPGCC=/home/raistllin/src/gcc/build/install/bin/gcc\nCC=$(shell if [ -f $(NEWPGCC) ]; then echo $(NEWPGCC); else echo pgcc; fi )\nRELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O6 -mcpu=pentiumpro -march=pentium -fomit-frame-pointer -pipe -ffast-math -malign-loops=2 -malign-jumps=2 -malign-functions=2 -fno-strict-aliasing - fstrength-reduce\nendif\n\nLIBEXT=a\n\nSHLIBEXT=so\nSHLIBCFLAGS=-fPIC\nSHLIBLDFLAGS=-shared $(LDFLAGS)\n\nARFLAGS=ar rv\nRANLIB=ranlib\n\nTHREAD_LDFLAGS=-lpthread\n# don't need -ldl (FreeBSD)\nLDFLAGS=-lm\n#GLLDFLAGS=-L/usr/X11R6/lib -L$(MESADIR)/lib -lGL -lX11 -lXext -lXxf86dga -lXxf86vm\n#GLLDFLAGS=-L/usr/X11/lib -lGL -lX11 -lXext -lm\nGLLDFLAGS=-L/usr/X11R6/lib -lGL -lX11 -lXext -lXxf86dga -lXxf86vm\n\nifeq ($(ARCH),axp)\nTARGETS=\\\n        $(B)/$(PLATFORM)q3ded\nelse\nTARGETS=\\\n\t$(B)/$(PLATFORM)quake3 \\\n\t$(B)/baseq3/cgame$(ARCH).$(SHLIBEXT) \\\n\t$(B)/baseq3/qagame$(ARCH).$(SHLIBEXT) \\\n\t$(B)/baseq3/ui$(ARCH).$(SHLIBEXT)     \\\n\t$(B)/missionpack/cgame$(ARCH).$(SHLIBEXT) \\\n\t$(B)/missionpack/qagame$(ARCH).$(SHLIBEXT) \\\n\t$(B)/missionpack/ui$(ARCH).$(SHLIBEXT)\nendif\n\nelse # ifeq freebsd\n\n#############################################################################\n# SETUP AND BUILD -- IRIX\n#############################################################################\n\nifeq ($(PLATFORM),irix)\n\nARCH=mips  #default to MIPS\nVENDOR=sgi\nGLIBC=  #libc is irrelevant\n\nCC=cc\nBASE_CFLAGS=-Dstricmp=strcasecmp -Xcpluscomm -woff 1185 -mips3 \\\n\t-nostdinc -I. -I$(ROOT)/usr/include\nRELEASE_CFLAGS=$(BASE_CFLAGS) -O3\nDEBUG_CFLAGS=$(BASE_CFLAGS) -g\n\nLIBEXT=a\n\nSHLIBEXT=so\nSHLIBCFLAGS=\nSHLIBLDFLAGS=-shared\n\nARFLAGS=ar rv\nRANLIB=ranlib\n\nLDFLAGS=-ldl -lm\nGLLDFLAGS=-L/usr/X11/lib -lGL -lX11 -lXext -lm\n\nTARGETS=$(B)/sgiquake3 \\\n\t$(B)/q3ded\n\nelse # ifeq IRIX\n\n#############################################################################\n# SETUP AND BUILD -- GENERIC\n#############################################################################\n\n#CC=egcs\n#BASE_CFLAGS=-Dstricmp=strcasecmp\n#DEBUG_CFLAGS=$(BASE_CFLAGS) -g \n#RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3\n\nLIBEXT=a\n\nSHLIBEXT=so\nSHLIBCFLAGS=-fPIC\nSHLIBLDFLAGS=-shared\n\nARFLAGS=ar rv\nRANLIB=ranlib\n\nifeq ($(PLATFORM),freebsd)\nLDFLAGS=-lm\nelse\nLDFLAGS=-ldl -lm\nendif # ifeq freebsd\n\nTARGETS=\\\n\t$(B)/$(PLATFORM)q3ded\n\nendif #Linux\nendif #FreeBSD\nendif #IRIX\n\nDO_CC=$(CC) $(CFLAGS) -o $@ -c $<\nDO_CXX=$(CXX) $(CFLAGS) -o $@ -c $<\nDO_SMP_CC=$(CC) $(CFLAGS) -DSMP -o $@ -c $<\nDO_BOT_CC=$(CC) $(CFLAGS) -DBOTLIB  -o $@ -c $<   # $(SHLIBCFLAGS) # bk001212\nDO_DEBUG_CC=$(CC) $(DEBUG_CFLAGS) -o $@ -c $<\nDO_SHLIB_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<\nDO_SHLIB_DEBUG_CC=$(CC) $(DEBUG_CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<\nDO_AS=$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<\nDO_NASM=nasm -f elf -o $@  $<\nDO_DED_CC=$(CC) -DDEDICATED -DC_ONLY $(CFLAGS) -o $@ -c $<\n\n#DO_LCC=$(LCC) -o $@ -S -Wf-target=bytecode -Wf-g -DQ3_VM -I$(CGDIR) -I$(GDIR)  -I$(UIDIR)  $< \n\n#### DEFAULT TARGET\ndefault:build_debug\n\ndebug: build_debug\nrelease: build_release\n\nbuild_debug:\n\t$(MAKE)  targets B=$(BD) CFLAGS=\"$(DEBUG_CFLAGS)\"\n\nbuild_release:\n\t$(MAKE)  targets B=$(BR) CFLAGS=\"$(RELEASE_CFLAGS)\"\n\n#Build both debug and release builds\nall:build_debug build_release\n\ntargets:makedirs $(TARGETS)\n\nmakedirs:\n\t@if [ ! -d $(B) ];then mkdir $(B);fi\n\t@if [ ! -d $(B)/client ];then mkdir $(B)/client;fi\n\t@if [ ! -d $(B)/ded ];then mkdir $(B)/ded;fi\n\t@if [ ! -d $(B)/ref ];then mkdir $(B)/ref;fi\n\t@if [ ! -d $(B)/ft2 ];then mkdir $(B)/ft2;fi\n\t@if [ ! -d $(B)/baseq3 ];then mkdir $(B)/baseq3;fi\n\t@if [ ! -d $(B)/baseq3/cgame ];then mkdir $(B)/baseq3/cgame;fi\n\t@if [ ! -d $(B)/baseq3/game ];then mkdir $(B)/baseq3/game;fi\n\t@if [ ! -d $(B)/baseq3/ui ];then mkdir $(B)/baseq3/ui;fi\n\t@if [ ! -d $(B)/baseq3/vm ];then mkdir $(B)/baseq3/vm;fi\n\t@if [ ! -d $(B)/missionpack ];then mkdir $(B)/missionpack;fi\n\t@if [ ! -d $(B)/missionpack/cgame ];then mkdir $(B)/missionpack/cgame;fi\n\t@if [ ! -d $(B)/missionpack/game ];then mkdir $(B)/missionpack/game;fi\n\t@if [ ! -d $(B)/missionpack/ui ];then mkdir $(B)/missionpack/ui;fi\n\t@if [ ! -d $(B)/missionpack/vm ];then mkdir $(B)/missionpack/vm;fi\n\t@if [ ! -d $(B)/q3static ];then mkdir $(B)/q3static;fi\n\n#############################################################################\n# CLIENT/SERVER\n#############################################################################\n\nQ3OBJ = \\\n\t$(B)/client/cl_cgame.o \\\n\t$(B)/client/cl_cin.o \\\n\t$(B)/client/cl_console.o \\\n\t$(B)/client/cl_input.o \\\n\t$(B)/client/cl_keys.o \\\n\t$(B)/client/cl_main.o \\\n\t$(B)/client/cl_net_chan.o \\\n\t$(B)/client/cl_parse.o \\\n\t$(B)/client/cl_scrn.o \\\n\t$(B)/client/cl_ui.o \\\n\t\\\n\t$(B)/client/cm_load.o \\\n\t$(B)/client/cm_patch.o \\\n\t$(B)/client/cm_polylib.o \\\n\t$(B)/client/cm_test.o \\\n\t$(B)/client/cm_trace.o \\\n\t\\\n\t$(B)/client/cmd.o \\\n\t$(B)/client/common.o \\\n\t$(B)/client/cvar.o \\\n\t$(B)/client/files.o \\\n\t$(B)/client/md4.o \\\n\t$(B)/client/msg.o \\\n\t$(B)/client/net_chan.o \\\n\t$(B)/client/huffman.o \\\n\t\\\n\t$(B)/client/snd_adpcm.o \\\n\t$(B)/client/snd_dma.o \\\n\t$(B)/client/snd_mem.o \\\n\t$(B)/client/snd_mix.o \\\n\t$(B)/client/snd_wavelet.o \\\n\t\\\n\t$(B)/client/sv_bot.o \\\n\t$(B)/client/sv_ccmds.o \\\n\t$(B)/client/sv_client.o \\\n\t$(B)/client/sv_game.o \\\n\t$(B)/client/sv_init.o \\\n\t$(B)/client/sv_main.o \\\n\t$(B)/client/sv_net_chan.o \\\n\t$(B)/client/sv_snapshot.o \\\n\t$(B)/client/sv_world.o \\\n\t\\\n\t$(B)/client/q_math.o \\\n\t$(B)/client/q_shared.o \\\n\t\\\n\t$(B)/client/unzip.o \\\n\t$(B)/client/vm.o \\\n\t$(B)/client/vm_interpreted.o \\\n\t\\\n\t$(B)/client/be_aas_bspq3.o \\\n\t$(B)/client/be_aas_cluster.o \\\n\t$(B)/client/be_aas_debug.o \\\n\t$(B)/client/be_aas_entity.o \\\n\t$(B)/client/be_aas_file.o \\\n\t$(B)/client/be_aas_main.o \\\n\t$(B)/client/be_aas_move.o \\\n\t$(B)/client/be_aas_optimize.o \\\n\t$(B)/client/be_aas_reach.o \\\n\t$(B)/client/be_aas_route.o \\\n\t$(B)/client/be_aas_routealt.o \\\n\t$(B)/client/be_aas_sample.o \\\n\t$(B)/client/be_ai_char.o \\\n\t$(B)/client/be_ai_chat.o \\\n\t$(B)/client/be_ai_gen.o \\\n\t$(B)/client/be_ai_goal.o \\\n\t$(B)/client/be_ai_move.o \\\n\t$(B)/client/be_ai_weap.o \\\n\t$(B)/client/be_ai_weight.o \\\n\t$(B)/client/be_ea.o \\\n\t$(B)/client/be_interface.o \\\n\t$(B)/client/l_crc.o \\\n\t$(B)/client/l_libvar.o \\\n\t$(B)/client/l_log.o \\\n\t$(B)/client/l_memory.o \\\n\t$(B)/client/l_precomp.o \\\n\t$(B)/client/l_script.o \\\n\t$(B)/client/l_struct.o \\\n\t\\\n\t$(B)/client/jcapimin.o \\\n\t$(B)/client/jchuff.o   \\\n\t$(B)/client/jcinit.o \\\n\t$(B)/client/jccoefct.o  \\\n\t$(B)/client/jccolor.o \\\n\t$(B)/client/jfdctflt.o \\\n\t$(B)/client/jcdctmgr.o \\\n\t$(B)/client/jcphuff.o \\\n\t$(B)/client/jcmainct.o \\\n\t$(B)/client/jcmarker.o \\\n\t$(B)/client/jcmaster.o \\\n\t$(B)/client/jcomapi.o \\\n\t$(B)/client/jcparam.o \\\n\t$(B)/client/jcprepct.o \\\n\t$(B)/client/jcsample.o \\\n\t$(B)/client/jdapimin.o \\\n\t$(B)/client/jdapistd.o \\\n\t$(B)/client/jdatasrc.o \\\n\t$(B)/client/jdcoefct.o \\\n\t$(B)/client/jdcolor.o \\\n\t$(B)/client/jddctmgr.o \\\n\t$(B)/client/jdhuff.o \\\n\t$(B)/client/jdinput.o \\\n\t$(B)/client/jdmainct.o \\\n\t$(B)/client/jdmarker.o \\\n\t$(B)/client/jdmaster.o \\\n\t$(B)/client/jdpostct.o \\\n\t$(B)/client/jdsample.o \\\n\t$(B)/client/jdtrans.o \\\n\t$(B)/client/jerror.o \\\n\t$(B)/client/jidctflt.o \\\n\t$(B)/client/jmemmgr.o \\\n\t$(B)/client/jmemnobs.o \\\n\t$(B)/client/jutils.o \\\n\t\\\n\t$(B)/client/tr_animation.o \\\n\t$(B)/client/tr_backend.o \\\n\t$(B)/client/tr_bsp.o \\\n\t$(B)/client/tr_cmds.o \\\n\t$(B)/client/tr_curve.o \\\n\t$(B)/client/tr_flares.o \\\n\t$(B)/client/tr_font.o \\\n\t$(B)/client/tr_image.o \\\n\t$(B)/client/tr_init.o \\\n\t$(B)/client/tr_light.o \\\n\t$(B)/client/tr_main.o \\\n\t$(B)/client/tr_marks.o \\\n\t$(B)/client/tr_mesh.o \\\n\t$(B)/client/tr_model.o \\\n\t$(B)/client/tr_noise.o \\\n\t$(B)/client/tr_scene.o \\\n\t$(B)/client/tr_shade.o \\\n\t$(B)/client/tr_shade_calc.o \\\n\t$(B)/client/tr_shader.o \\\n\t$(B)/client/tr_shadows.o \\\n\t$(B)/client/tr_sky.o \\\n\t$(B)/client/tr_surface.o \\\n\t$(B)/client/tr_world.o \\\n\t\\\n\t$(B)/client/unix_main.o \\\n\t$(B)/client/unix_net.o \\\n\t$(B)/client/unix_shared.o \\\n\t\\\n\t$(B)/client/ahoptim.o  \\\n\t$(B)/client/autohint.o \\\n\t$(B)/client/ftbase.o   \\\n\t$(B)/client/ftdebug.o  \\\n\t$(B)/client/ftglyph.o  \\\n\t$(B)/client/ftinit.o   \\\n\t$(B)/client/ftmm.o     \\\n\t$(B)/client/ftsystem.o \\\n\t$(B)/client/raster1.o  \\\n\t$(B)/client/sfnt.o     \\\n\t$(B)/client/sfobjs.o   \\\n\t$(B)/client/smooth.o   \\\n\t$(B)/client/truetype.o\n#\t\\\n#\t$(B)/client/q_parse.o \\\n#\t$(B)/client/math_quaternion.o \\\n#\t$(B)/client/util_str.o \\\n#\t$(B)/client/math_angles.o \\\n#\t$(B)/client/math_vector.o \\\n#\t$(B)/client/splines.o \\\n#\t$(B)/client/math_matrix.o\n\n#\t$(B)/client/q_shared.o \\\n\n    ifeq ($(ARCH),i386)\n\t  Q3OBJ += $(B)/client/vm_x86.o\n    endif\n\n    ifeq ($(ARCH),ppc)\n      ifeq ($(DLL_ONLY),false)\n        Q3OBJ += $(B)/client/vm_ppc.o\n      endif\n    endif\n\n#\t$(B)/client/jctrans.o \\\n\n#platform specific objects\nifeq ($(PLATFORM),freebsd)\n\tQ3POBJ=\\\n\t\t$(B)/client/linux_common.o \\\n\t\t$(B)/client/linux_qgl.o \\\n\t\t$(B)/client/linux_glimp.o \\\n\t\t$(B)/client/linux_snd.o \\\n\t\t$(B)/client/snd_mixa.o \\\n\t\t$(B)/client/matha.o   \\\n\t\t$(B)/client/ftol.o \\\n\t\t$(B)/client/snapvector.o\nelse\nifeq ($(PLATFORM),irix)\n\tQ3POBJ=\\\n\t\t$(B)/client/irix_qgl.o \\\n\t\t$(B)/client/irix_glimp.o \\\n\t\t$(B)/client/irix_snd.o\nelse\nifeq ($(PLATFORM),linux)\nifeq ($(ARCH),axp)\n\tQ3POBJ=\nelse\n\tQ3POBJ=\\\n\t\t$(B)/client/linux_common.o \\\n\t\t$(B)/client/linux_qgl.o \\\n\t\t$(B)/client/linux_glimp.o \\\n\t\t$(B)/client/linux_joystick.o \\\n\t\t$(B)/client/linux_snd.o \\\n\t\t$(B)/client/snd_mixa.o \\\n\t\t$(B)/client/matha.o \\\n\n\tQ3POBJ_SMP=\\\n\t\t$(B)/client/linux_common.o \\\n\t\t$(B)/client/linux_qgl.o \\\n\t\t$(B)/client/linux_glimp_smp.o \\\n\t\t$(B)/client/linux_joystick.o \\\n\t\t$(B)/client/linux_snd.o \\\n\t\t$(B)/client/snd_mixa.o \\\n\t\t$(B)/client/matha.o\n\n    ifeq ($(ARCH),i386)\n\t\tQ3POBJ += $(B)/client/ftol.o $(B)/client/snapvector.o\n\t\tQ3POBJ_SMP += $(B)/client/ftol.o $(B)/client/snapvector.o\n    endif\n\nendif\nendif #Linux\nendif #FreeBSD\nendif #IRIX\n\n$(B)/$(PLATFORM)quake3 : $(Q3OBJ) $(Q3POBJ)\n\t$(CC)  -o $@ $(Q3OBJ) $(Q3POBJ) $(GLLDFLAGS) $(LDFLAGS) \n# TTimo: splines code requires C++ linking, but splines have not been officially included in the codebase\n#\t$(CXX)  -o $@ $(Q3OBJ) $(Q3POBJ) $(GLLDFLAGS) $(LDFLAGS) \n\n$(B)/$(PLATFORM)quake3-smp : $(Q3OBJ) $(Q3POBJ_SMP)\n\t$(CC)  -o $@ $(Q3OBJ) $(Q3POBJ_SMP) $(GLLDFLAGS) \\\n\t\t$(THREAD_LDFLAGS) $(LDFLAGS) \n\n$(B)/client/cl_cgame.o : $(CDIR)/cl_cgame.c; $(DO_CC)   \n$(B)/client/cl_cin.o : $(CDIR)/cl_cin.c; $(DO_CC)       \n$(B)/client/cl_console.o : $(CDIR)/cl_console.c; $(DO_CC)  \n$(B)/client/cl_input.o : $(CDIR)/cl_input.c; $(DO_CC)   \n$(B)/client/cl_keys.o : $(CDIR)/cl_keys.c; $(DO_CC)     \n$(B)/client/cl_main.o : $(CDIR)/cl_main.c; $(DO_CC)     \n$(B)/client/cl_net_chan.o : $(CDIR)/cl_net_chan.c; $(DO_CC)  \n$(B)/client/cl_parse.o : $(CDIR)/cl_parse.c; $(DO_CC)   \n$(B)/client/cl_scrn.o : $(CDIR)/cl_scrn.c; $(DO_CC)    \n$(B)/client/cl_ui.o : $(CDIR)/cl_ui.c; $(DO_CC)         \n$(B)/client/snd_adpcm.o : $(CDIR)/snd_adpcm.c; $(DO_CC)   \n$(B)/client/snd_dma.o : $(CDIR)/snd_dma.c; $(DO_CC)       \n$(B)/client/snd_mem.o : $(CDIR)/snd_mem.c; $(DO_CC)        \n$(B)/client/snd_mix.o : $(CDIR)/snd_mix.c; $(DO_CC)       \n$(B)/client/snd_wavelet.o : $(CDIR)/snd_wavelet.c; $(DO_CC)     \n$(B)/client/sv_bot.o : $(SDIR)/sv_bot.c; $(DO_CC)        \n$(B)/client/sv_client.o : $(SDIR)/sv_client.c; $(DO_CC)     \n$(B)/client/sv_ccmds.o : $(SDIR)/sv_ccmds.c; $(DO_CC)       \n$(B)/client/sv_game.o : $(SDIR)/sv_game.c; $(DO_CC)        \n$(B)/client/sv_init.o : $(SDIR)/sv_init.c; $(DO_CC)        \n$(B)/client/sv_main.o : $(SDIR)/sv_main.c; $(DO_CC)        \n$(B)/client/sv_net_chan.o : $(SDIR)/sv_net_chan.c; $(DO_CC)     \n$(B)/client/sv_snapshot.o : $(SDIR)/sv_snapshot.c; $(DO_CC)      \n$(B)/client/sv_world.o : $(SDIR)/sv_world.c; $(DO_CC)         \n$(B)/client/cm_trace.o : $(CMDIR)/cm_trace.c; $(DO_CC)       \n$(B)/client/cm_load.o : $(CMDIR)/cm_load.c; $(DO_CC)        \n$(B)/client/cm_test.o : $(CMDIR)/cm_test.c; $(DO_CC)        \n$(B)/client/cm_patch.o : $(CMDIR)/cm_patch.c; $(DO_CC)       \n$(B)/client/cm_polylib.o : $(CMDIR)/cm_polylib.c; $(DO_CC)     \n$(B)/client/cmd.o : $(CMDIR)/cmd.c; $(DO_CC)                   \n$(B)/client/common.o : $(CMDIR)/common.c; $(DO_CC)               \n$(B)/client/cvar.o : $(CMDIR)/cvar.c; $(DO_CC)                \n$(B)/client/files.o : $(CMDIR)/files.c; $(DO_CC)              \n$(B)/client/md4.o : $(CMDIR)/md4.c; $(DO_CC)                   \n$(B)/client/msg.o : $(CMDIR)/msg.c; $(DO_CC)                    \n$(B)/client/net_chan.o : $(CMDIR)/net_chan.c; $(DO_CC)\n$(B)/client/huffman.o : $(CMDIR)/huffman.c; $(DO_CC)\n$(B)/client/q_shared.o : $(GDIR)/q_shared.c; $(DO_CC)         \n$(B)/client/q_math.o : $(GDIR)/q_math.c; $(DO_CC)               \n\n$(B)/client/be_aas_bspq3.o : $(BLIBDIR)/be_aas_bspq3.c; $(DO_BOT_CC) \n$(B)/client/be_aas_cluster.o : $(BLIBDIR)/be_aas_cluster.c; $(DO_BOT_CC) \n$(B)/client/be_aas_debug.o : $(BLIBDIR)/be_aas_debug.c; $(DO_BOT_CC) \n$(B)/client/be_aas_entity.o : $(BLIBDIR)/be_aas_entity.c; $(DO_BOT_CC) \n$(B)/client/be_aas_file.o : $(BLIBDIR)/be_aas_file.c; $(DO_BOT_CC) \n$(B)/client/be_aas_main.o : $(BLIBDIR)/be_aas_main.c; $(DO_BOT_CC) \n$(B)/client/be_aas_move.o : $(BLIBDIR)/be_aas_move.c; $(DO_BOT_CC) \n$(B)/client/be_aas_optimize.o : $(BLIBDIR)/be_aas_optimize.c; $(DO_BOT_CC) \n$(B)/client/be_aas_reach.o : $(BLIBDIR)/be_aas_reach.c; $(DO_BOT_CC) \n$(B)/client/be_aas_route.o : $(BLIBDIR)/be_aas_route.c; $(DO_BOT_CC) \n$(B)/client/be_aas_routealt.o : $(BLIBDIR)/be_aas_routealt.c; $(DO_BOT_CC) \n$(B)/client/be_aas_sample.o : $(BLIBDIR)/be_aas_sample.c; $(DO_BOT_CC) \n$(B)/client/be_ai_char.o : $(BLIBDIR)/be_ai_char.c; $(DO_BOT_CC) \n$(B)/client/be_ai_chat.o : $(BLIBDIR)/be_ai_chat.c; $(DO_BOT_CC) \n$(B)/client/be_ai_gen.o : $(BLIBDIR)/be_ai_gen.c; $(DO_BOT_CC) \n$(B)/client/be_ai_goal.o : $(BLIBDIR)/be_ai_goal.c; $(DO_BOT_CC) \n$(B)/client/be_ai_move.o : $(BLIBDIR)/be_ai_move.c; $(DO_BOT_CC) \n$(B)/client/be_ai_weap.o : $(BLIBDIR)/be_ai_weap.c; $(DO_BOT_CC) \n$(B)/client/be_ai_weight.o : $(BLIBDIR)/be_ai_weight.c; $(DO_BOT_CC) \n$(B)/client/be_ea.o : $(BLIBDIR)/be_ea.c; $(DO_BOT_CC) \n$(B)/client/be_interface.o : $(BLIBDIR)/be_interface.c; $(DO_BOT_CC) \n$(B)/client/l_crc.o : $(BLIBDIR)/l_crc.c; $(DO_BOT_CC) \n$(B)/client/l_libvar.o : $(BLIBDIR)/l_libvar.c; $(DO_BOT_CC) \n$(B)/client/l_log.o : $(BLIBDIR)/l_log.c; $(DO_BOT_CC) \n$(B)/client/l_memory.o : $(BLIBDIR)/l_memory.c; $(DO_BOT_CC) \n$(B)/client/l_precomp.o : $(BLIBDIR)/l_precomp.c; $(DO_BOT_CC) \n$(B)/client/l_script.o : $(BLIBDIR)/l_script.c; $(DO_BOT_CC) \n$(B)/client/l_struct.o : $(BLIBDIR)/l_struct.c; $(DO_BOT_CC) \n\n$(B)/client/jcapimin.o : $(JPDIR)/jcapimin.c; $(DO_CC) \n$(B)/client/jchuff.o : $(JPDIR)/jchuff.c; $(DO_CC) \n$(B)/client/jcinit.o : $(JPDIR)/jcinit.c; $(DO_CC) \n$(B)/client/jccoefct.o : $(JPDIR)/jccoefct.c; $(DO_CC) \n$(B)/client/jccolor.o : $(JPDIR)/jccolor.c; $(DO_CC) \n$(B)/client/jfdctflt.o : $(JPDIR)/jfdctflt.c; $(DO_CC) \n$(B)/client/jcdctmgr.o : $(JPDIR)/jcdctmgr.c; $(DO_CC) \n$(B)/client/jcmainct.o : $(JPDIR)/jcmainct.c; $(DO_CC) \n$(B)/client/jcmarker.o : $(JPDIR)/jcmarker.c; $(DO_CC) \n$(B)/client/jcmaster.o : $(JPDIR)/jcmaster.c; $(DO_CC) \n$(B)/client/jcomapi.o : $(JPDIR)/jcomapi.c; $(DO_CC)\n$(B)/client/jcparam.o : $(JPDIR)/jcparam.c;  $(DO_CC)\n$(B)/client/jcprepct.o : $(JPDIR)/jcprepct.c; $(DO_CC)\n$(B)/client/jcsample.o : $(JPDIR)/jcsample.c; $(DO_CC) \n\n$(B)/client/jdapimin.o : $(JPDIR)/jdapimin.c; $(DO_CC) \n$(B)/client/jdapistd.o : $(JPDIR)/jdapistd.c; $(DO_CC) \n$(B)/client/jdatasrc.o : $(JPDIR)/jdatasrc.c; $(DO_CC) \n$(B)/client/jdcoefct.o : $(JPDIR)/jdcoefct.c; $(DO_CC) \n$(B)/client/jdcolor.o : $(JPDIR)/jdcolor.c; $(DO_CC) \n$(B)/client/jcphuff.o : $(JPDIR)/jcphuff.c; $(DO_CC) \n$(B)/client/jddctmgr.o : $(JPDIR)/jddctmgr.c; $(DO_CC) \n$(B)/client/jdhuff.o : $(JPDIR)/jdhuff.c; $(DO_CC) \n$(B)/client/jdinput.o : $(JPDIR)/jdinput.c; $(DO_CC) \n$(B)/client/jdmainct.o : $(JPDIR)/jdmainct.c; $(DO_CC) \n$(B)/client/jdmarker.o : $(JPDIR)/jdmarker.c; $(DO_CC) \n$(B)/client/jdmaster.o : $(JPDIR)/jdmaster.c; $(DO_CC) \n$(B)/client/jdpostct.o : $(JPDIR)/jdpostct.c; $(DO_CC) \n$(B)/client/jdsample.o : $(JPDIR)/jdsample.c; $(DO_CC) \n$(B)/client/jdtrans.o : $(JPDIR)/jdtrans.c; $(DO_CC) \n$(B)/client/jerror.o : $(JPDIR)/jerror.c; $(DO_CC) $(GL_CFLAGS) \n$(B)/client/jidctflt.o : $(JPDIR)/jidctflt.c; $(DO_CC) \n$(B)/client/jmemmgr.o : $(JPDIR)/jmemmgr.c; $(DO_CC) \n$(B)/client/jmemnobs.o : $(JPDIR)/jmemnobs.c; $(DO_CC)  $(GL_CFLAGS) \n$(B)/client/jutils.o : $(JPDIR)/jutils.c; $(DO_CC) \n\n$(B)/client/tr_bsp.o : $(RDIR)/tr_bsp.c; $(DO_CC)  $(GL_CFLAGS) \n$(B)/client/tr_animation.o : $(RDIR)/tr_animation.c; $(DO_CC)  $(GL_CFLAGS) \n$(B)/client/tr_backend.o : $(RDIR)/tr_backend.c; $(DO_CC)  $(GL_CFLAGS) \n$(B)/client/tr_cmds.o : $(RDIR)/tr_cmds.c; $(DO_CC)  $(GL_CFLAGS) \n$(B)/client/tr_curve.o : $(RDIR)/tr_curve.c; $(DO_CC)  $(GL_CFLAGS) \n$(B)/client/tr_flares.o : $(RDIR)/tr_flares.c; $(DO_CC)  $(GL_CFLAGS) \n$(B)/client/tr_font.o : $(RDIR)/tr_font.c; $(DO_CC)   $(GL_CFLAGS) \n$(B)/client/tr_image.o : $(RDIR)/tr_image.c; $(DO_CC)   $(GL_CFLAGS) \n$(B)/client/tr_init.o : $(RDIR)/tr_init.c; $(DO_CC)    $(GL_CFLAGS) \n$(B)/client/tr_light.o : $(RDIR)/tr_light.c; $(DO_CC)  $(GL_CFLAGS) \n$(B)/client/tr_main.o : $(RDIR)/tr_main.c; $(DO_CC)   $(GL_CFLAGS) \n$(B)/client/tr_marks.o : $(RDIR)/tr_marks.c; $(DO_CC)   $(GL_CFLAGS) \n$(B)/client/tr_mesh.o : $(RDIR)/tr_mesh.c; $(DO_CC)   $(GL_CFLAGS) \n$(B)/client/tr_model.o : $(RDIR)/tr_model.c; $(DO_CC)   $(GL_CFLAGS) \n$(B)/client/tr_noise.o : $(RDIR)/tr_noise.c; $(DO_CC)   $(GL_CFLAGS) \n$(B)/client/tr_scene.o : $(RDIR)/tr_scene.c; $(DO_CC)   $(GL_CFLAGS) \n$(B)/client/tr_shade.o : $(RDIR)/tr_shade.c; $(DO_CC)   $(GL_CFLAGS) \n$(B)/client/tr_shader.o : $(RDIR)/tr_shader.c; $(DO_CC)   $(GL_CFLAGS) \n$(B)/client/tr_shade_calc.o : $(RDIR)/tr_shade_calc.c; $(DO_CC)  $(GL_CFLAGS) \n$(B)/client/tr_shadows.o : $(RDIR)/tr_shadows.c; $(DO_CC)   $(GL_CFLAGS) \n$(B)/client/tr_sky.o : $(RDIR)/tr_sky.c; $(DO_CC)   $(GL_CFLAGS) \n$(B)/client/tr_smp.o : $(RDIR)/tr_smp.c; $(DO_CC)   $(GL_CFLAGS) \n$(B)/client/tr_stripify.o : $(RDIR)/tr_stripify.c; $(DO_CC)   $(GL_CFLAGS) \n$(B)/client/tr_subdivide.o : $(RDIR)/tr_subdivide.c; $(DO_CC)   $(GL_CFLAGS) \n$(B)/client/tr_surface.o : $(RDIR)/tr_surface.c; $(DO_CC)  $(GL_CFLAGS) \n$(B)/client/tr_world.o : $(RDIR)/tr_world.c; $(DO_CC)   $(GL_CFLAGS) \n\n$(B)/client/unix_qgl.o : $(UDIR)/unix_qgl.c; $(DO_CC)  $(GL_CFLAGS) \n$(B)/client/unix_main.o : $(UDIR)/unix_main.c; $(DO_CC) \n$(B)/client/unix_net.o : $(UDIR)/unix_net.c; $(DO_CC) \n$(B)/client/unix_shared.o : $(UDIR)/unix_shared.c; $(DO_CC) \n$(B)/client/irix_glimp.o : $(UDIR)/irix_glimp.c; $(DO_CC) \n$(B)/client/irix_glimp_smp.o : $(UDIR)/irix_glimp.c; $(DO_SMP_CC) \n$(B)/client/irix_snd.o : $(UDIR)/irix_snd.c; $(DO_CC) \n$(B)/client/irix_input.o : $(UDIR)/irix_input.c; $(DO_CC) \n$(B)/client/linux_common.o : $(UDIR)/linux_common.c; $(DO_CC)\n$(B)/client/linux_glimp.o : $(UDIR)/linux_glimp.c; $(DO_CC)  $(GL_CFLAGS) \n$(B)/client/linux_glimp_smp.o : $(UDIR)/linux_glimp.c; $(DO_SMP_CC)  $(GL_CFLAGS) \n$(B)/client/linux_joystick.o : $(UDIR)/linux_joystick.c; $(DO_CC)  \n$(B)/client/linux_qgl.o : $(UDIR)/linux_qgl.c; $(DO_CC)  $(GL_CFLAGS) \n$(B)/client/linux_input.o : $(UDIR)/linux_input.c; $(DO_CC) \n$(B)/client/linux_snd.o : $(UDIR)/linux_snd.c; $(DO_CC) \n$(B)/client/snd_mixa.o : $(UDIR)/snd_mixa.s; $(DO_AS) \n$(B)/client/matha.o : $(UDIR)/matha.s; $(DO_AS) \n\nifeq ($(ARCH),i386)\n$(B)/client/ftol.o : $(UDIR)/ftol.nasm; $(DO_NASM)\n$(B)/client/snapvector.o : $(UDIR)/snapvector.nasm; $(DO_NASM)\n$(B)/client/vm_x86.o : $(CMDIR)/vm_x86.c; $(DO_CC) \nendif\n\nifeq ($(ARCH),ppc)\nifeq ($(DLL_ONLY),false)\n$(B)/client/vm_ppc.o : $(CMDIR)/vm_ppc.c; $(DO_CC)\nendif\nendif\n\n$(B)/client/unzip.o : $(CMDIR)/unzip.c; $(DO_CC) \n$(B)/client/vm.o : $(CMDIR)/vm.c; $(DO_CC) \n$(B)/client/vm_interpreted.o : $(CMDIR)/vm_interpreted.c; $(DO_CC) \n\n$(B)/client/ahoptim.o  : $(FTDIR)/ahoptim.c;   $(DO_CC)\n$(B)/client/autohint.o : $(FTDIR)/autohint.c;  $(DO_CC)\n$(B)/client/ftbase.o   : $(FTDIR)/ftbase.c;    $(DO_CC)\n$(B)/client/ftdebug.o  : $(FTDIR)/ftdebug.c;   $(DO_CC)\n$(B)/client/ftglyph.o  : $(FTDIR)/ftglyph.c;   $(DO_CC)\n$(B)/client/ftinit.o   : $(FTDIR)/ftinit.c;    $(DO_CC)\n$(B)/client/ftmm.o     : $(FTDIR)/ftmm.c;      $(DO_CC)\n$(B)/client/ftsystem.o : $(FTDIR)/ftsystem.c;  $(DO_CC)\n$(B)/client/raster1.o  : $(FTDIR)/raster1.c;   $(DO_CC) -DFT_FLAT_COMPILE\n$(B)/client/sfnt.o     : $(FTDIR)/sfnt.c;      $(DO_CC)\n$(B)/client/sfobjs.o   : $(FTDIR)/sfobjs.c;    $(DO_CC)\n$(B)/client/smooth.o   : $(FTDIR)/smooth.c;    $(DO_CC) -DFT_FLAT_COMPILE\n$(B)/client/truetype.o : $(FTDIR)/truetype.c;  $(DO_CC)\n\n# TTimo: took out splines code\n#$(B)/client/q_parse.o : $(SPLNDIR)/q_parse.cpp; $(DO_CXX)\n#$(B)/client/math_quaternion.o : $(SPLNDIR)/math_quaternion.cpp; $(DO_CXX)\n# TTimo: ignored\n#$(B)/client/q_shared.o : $(SPLNDIR)/q_shared.cpp; $(DO_CXX)\n#$(B)/client/util_str.o : $(SPLNDIR)/util_str.cpp; $(DO_CXX)\n#$(B)/client/math_angles.o : $(SPLNDIR)/math_angles.cpp; $(DO_CXX)\n#$(B)/client/math_vector.o : $(SPLNDIR)/math_vector.cpp; $(DO_CXX)\n#$(B)/client/splines.o : $(SPLNDIR)/splines.cpp; $(DO_CXX)\n#$(B)/client/math_matrix.o : $(SPLNDIR)/math_matrix.cpp; $(DO_CXX)\n\n## Included by raster1.c\n# $(B)/client/ftraster.o : $(FTDIR)/ftraster.c;  $(DO_CC)\n# $(B)/client/ftrend1.o  : $(FTDIR)/ftrend1.c;   $(DO_CC)\n\n## Included by autohint.c\n# $(B)/client/ahangles.o : $(FTDIR)/ahangles.c;  $(DO_CC)\n# $(B)/client/ahglyph.o  : $(FTDIR)/ahglyph.c;   $(DO_CC)\n# $(B)/client/ahglobal.o : $(FTDIR)/ahglobal.c;  $(DO_CC)\n# $(B)/client/ahhint.o   : $(FTDIR)/ahhint.c;    $(DO_CC)\n# $(B)/client/ahmodule.o : $(FTDIR)/ahmodule.c;  $(DO_CC)\n\n## Included by ftcalc.c\n# $(B)/client/ftcalc.o   : $(FTDIR)/ftcalc.c;    $(DO_CC)\n# $(B)/client/ftobjs.o   : $(FTDIR)/ftobjs.c;    $(DO_CC)\n# $(B)/client/ftstream.o : $(FTDIR)/ftstream.c;  $(DO_CC)\n# $(B)/client/ftlist.o   : $(FTDIR)/ftlist.c;    $(DO_CC)\n# $(B)/client/ftoutln.o  : $(FTDIR)/ftoutln.c;   $(DO_CC)\n# $(B)/client/ftextend.o : $(FTDIR)/ftextend.c;  $(DO_CC)\n# $(B)/client/ftnames.o  : $(FTDIR)/ftnames.c;   $(DO_CC)\n\n## Included by sfnt.c\n# $(B)/client/ttload.o   : $(FTDIR)/ttload.c;    $(DO_CC)\n# $(B)/client/ttcmap.o   : $(FTDIR)/ttcmap.c;    $(DO_CC)\n# $(B)/client/sfobjs.o   : $(FTDIR)/sfobjs.c;    $(DO_CC)\n# $(B)/client/sfdriver.o : $(FTDIR)/sfdriver.c;  $(DO_CC)\n## Unused in sfnt.c\n# $(B)/client/ttpost.o   : $(FTDIR)/ttpost.c;    $(DO_CC)\n# $(B)/client/ttsbit.o   : $(FTDIR)/ttsbit.c;    $(DO_CC)\n\n## Included by truetype.c\n# $(B)/client/ttdriver.o : $(FTDIR)/ttdriver.c;  $(DO_CC)\n# $(B)/client/ttgload.o  : $(FTDIR)/ttgload.c;   $(DO_CC)\n# $(B)/client/ttobjs.o   : $(FTDIR)/ttobjs.c;    $(DO_CC)\n# $(B)/client/ttpload.o  : $(FTDIR)/ttpload.c;   $(DO_CC)\n## Unused in truetype.c\n# $(B)/client/ttinterp.o : $(FTDIR)/ttinterp.c;  $(DO_CC)\n\n## Included by smooth.c\n# $(B)/client/ftsmooth.o : $(FTDIR)/ftsmooth.c;  $(DO_CC) -DFT_FLAT_COMPILE\n# $(B)/client/ftgrays.o  : $(FTDIR)/ftgrays.c;   $(DO_CC)\n\n#############################################################################\n# DEDICATED SERVER                        \n#############################################################################\n\nQ3DOBJ = \\\n\t$(B)/ded/sv_bot.o \\\n\t$(B)/ded/sv_client.o \\\n\t$(B)/ded/sv_ccmds.o \\\n\t$(B)/ded/sv_game.o \\\n\t$(B)/ded/sv_init.o \\\n\t$(B)/ded/sv_main.o \\\n\t$(B)/ded/sv_net_chan.o \\\n\t$(B)/ded/sv_snapshot.o \\\n\t$(B)/ded/sv_world.o \\\n\t\\\n\t$(B)/ded/cm_load.o \\\n\t$(B)/ded/cm_patch.o \\\n\t$(B)/ded/cm_polylib.o \\\n\t$(B)/ded/cm_test.o \\\n\t$(B)/ded/cm_trace.o \\\n\t$(B)/ded/cmd.o \\\n\t$(B)/ded/common.o \\\n\t$(B)/ded/cvar.o \\\n\t$(B)/ded/files.o \\\n\t$(B)/ded/md4.o \\\n\t$(B)/ded/msg.o \\\n\t$(B)/ded/net_chan.o \\\n\t$(B)/ded/huffman.o \\\n\t\\\n\t$(B)/ded/q_math.o \\\n\t$(B)/ded/q_shared.o \\\n\t\\\n\t$(B)/ded/unzip.o \\\n\t$(B)/ded/vm.o \\\n\t$(B)/ded/vm_interpreted.o \\\n\t\\\n\t$(B)/ded/be_aas_bspq3.o \\\n\t$(B)/ded/be_aas_cluster.o \\\n\t$(B)/ded/be_aas_debug.o \\\n\t$(B)/ded/be_aas_entity.o \\\n\t$(B)/ded/be_aas_file.o \\\n\t$(B)/ded/be_aas_main.o \\\n\t$(B)/ded/be_aas_move.o \\\n\t$(B)/ded/be_aas_optimize.o \\\n\t$(B)/ded/be_aas_reach.o \\\n\t$(B)/ded/be_aas_route.o \\\n\t$(B)/ded/be_aas_routealt.o \\\n\t$(B)/ded/be_aas_sample.o \\\n\t$(B)/ded/be_ai_char.o \\\n\t$(B)/ded/be_ai_chat.o \\\n\t$(B)/ded/be_ai_gen.o \\\n\t$(B)/ded/be_ai_goal.o \\\n\t$(B)/ded/be_ai_move.o \\\n\t$(B)/ded/be_ai_weap.o \\\n\t$(B)/ded/be_ai_weight.o \\\n\t$(B)/ded/be_ea.o \\\n\t$(B)/ded/be_interface.o \\\n\t$(B)/ded/l_crc.o \\\n\t$(B)/ded/l_libvar.o \\\n\t$(B)/ded/l_log.o \\\n\t$(B)/ded/l_memory.o \\\n\t$(B)/ded/l_precomp.o \\\n\t$(B)/ded/l_script.o \\\n\t$(B)/ded/l_struct.o \\\n\t\\\n\t$(B)/ded/linux_common.o \\\n\t$(B)/ded/unix_main.o \\\n\t$(B)/ded/unix_net.o \\\n\t$(B)/ded/unix_shared.o \\\n\t\\\n\t$(B)/ded/null_client.o \\\n\t$(B)/ded/null_input.o \\\n\t$(B)/ded/null_snddma.o\n\nifeq ($(ARCH),i386)\n  Q3DOBJ += $(B)/ded/vm_x86.o $(B)/ded/ftol.o $(B)/ded/snapvector.o\nendif\n\nifeq ($(ARCH),ppc)\n  ifeq ($(DLL_ONLY),false)\n    Q3DOBJ += $(B)/ded/vm_ppc.o\n  endif\nendif\n\n$(B)/$(PLATFORM)q3ded : $(Q3DOBJ)\n\t$(CC)  -o $@ $(Q3DOBJ) $(LDFLAGS)\n\n$(B)/ded/sv_bot.o : $(SDIR)/sv_bot.c; $(DO_DED_CC) \n$(B)/ded/sv_client.o : $(SDIR)/sv_client.c; $(DO_DED_CC) \n$(B)/ded/sv_ccmds.o : $(SDIR)/sv_ccmds.c; $(DO_DED_CC) \n$(B)/ded/sv_game.o : $(SDIR)/sv_game.c; $(DO_DED_CC) \n$(B)/ded/sv_init.o : $(SDIR)/sv_init.c; $(DO_DED_CC) \n$(B)/ded/sv_main.o : $(SDIR)/sv_main.c; $(DO_DED_CC) \n$(B)/ded/sv_net_chan.o : $(SDIR)/sv_net_chan.c; $(DO_DED_CC) \n$(B)/ded/sv_snapshot.o : $(SDIR)/sv_snapshot.c; $(DO_DED_CC) \n$(B)/ded/sv_world.o : $(SDIR)/sv_world.c; $(DO_DED_CC) \n$(B)/ded/cm_load.o : $(CMDIR)/cm_load.c; $(DO_DED_CC) \n$(B)/ded/cm_polylib.o : $(CMDIR)/cm_polylib.c; $(DO_DED_CC) \n$(B)/ded/cm_test.o : $(CMDIR)/cm_test.c; $(DO_DED_CC) \n$(B)/ded/cm_trace.o : $(CMDIR)/cm_trace.c; $(DO_DED_CC) \n$(B)/ded/cm_patch.o : $(CMDIR)/cm_patch.c; $(DO_DED_CC) \n$(B)/ded/cmd.o : $(CMDIR)/cmd.c; $(DO_DED_CC) \n$(B)/ded/common.o : $(CMDIR)/common.c; $(DO_DED_CC) \n$(B)/ded/cvar.o : $(CMDIR)/cvar.c; $(DO_DED_CC) \n$(B)/ded/files.o : $(CMDIR)/files.c; $(DO_DED_CC) \n$(B)/ded/md4.o : $(CMDIR)/md4.c; $(DO_DED_CC) \n$(B)/ded/msg.o : $(CMDIR)/msg.c; $(DO_DED_CC) \n$(B)/ded/net_chan.o : $(CMDIR)/net_chan.c; $(DO_DED_CC)\n$(B)/ded/huffman.o : $(CMDIR)/huffman.c; $(DO_DED_CC)\n$(B)/ded/q_shared.o : $(GDIR)/q_shared.c; $(DO_DED_CC) \n$(B)/ded/q_math.o : $(GDIR)/q_math.c; $(DO_DED_CC) \n\n$(B)/ded/be_aas_bspq3.o : $(BLIBDIR)/be_aas_bspq3.c; $(DO_BOT_CC) \n$(B)/ded/be_aas_cluster.o : $(BLIBDIR)/be_aas_cluster.c; $(DO_BOT_CC) \n$(B)/ded/be_aas_debug.o : $(BLIBDIR)/be_aas_debug.c; $(DO_BOT_CC) \n$(B)/ded/be_aas_entity.o : $(BLIBDIR)/be_aas_entity.c; $(DO_BOT_CC) \n$(B)/ded/be_aas_file.o : $(BLIBDIR)/be_aas_file.c; $(DO_BOT_CC) \n$(B)/ded/be_aas_main.o : $(BLIBDIR)/be_aas_main.c; $(DO_BOT_CC) \n$(B)/ded/be_aas_move.o : $(BLIBDIR)/be_aas_move.c; $(DO_BOT_CC) \n$(B)/ded/be_aas_optimize.o : $(BLIBDIR)/be_aas_optimize.c; $(DO_BOT_CC) \n$(B)/ded/be_aas_reach.o : $(BLIBDIR)/be_aas_reach.c; $(DO_BOT_CC) \n$(B)/ded/be_aas_route.o : $(BLIBDIR)/be_aas_route.c; $(DO_BOT_CC) \n$(B)/ded/be_aas_routealt.o : $(BLIBDIR)/be_aas_routealt.c; $(DO_BOT_CC) \n$(B)/ded/be_aas_sample.o : $(BLIBDIR)/be_aas_sample.c; $(DO_BOT_CC) \n$(B)/ded/be_ai_char.o : $(BLIBDIR)/be_ai_char.c; $(DO_BOT_CC) \n$(B)/ded/be_ai_chat.o : $(BLIBDIR)/be_ai_chat.c; $(DO_BOT_CC) \n$(B)/ded/be_ai_gen.o : $(BLIBDIR)/be_ai_gen.c; $(DO_BOT_CC) \n$(B)/ded/be_ai_goal.o : $(BLIBDIR)/be_ai_goal.c; $(DO_BOT_CC) \n$(B)/ded/be_ai_move.o : $(BLIBDIR)/be_ai_move.c; $(DO_BOT_CC) \n$(B)/ded/be_ai_weap.o : $(BLIBDIR)/be_ai_weap.c; $(DO_BOT_CC) \n$(B)/ded/be_ai_weight.o : $(BLIBDIR)/be_ai_weight.c; $(DO_BOT_CC) \n$(B)/ded/be_ea.o : $(BLIBDIR)/be_ea.c; $(DO_BOT_CC) \n$(B)/ded/be_interface.o : $(BLIBDIR)/be_interface.c; $(DO_BOT_CC) \n$(B)/ded/l_crc.o : $(BLIBDIR)/l_crc.c; $(DO_BOT_CC) \n$(B)/ded/l_libvar.o : $(BLIBDIR)/l_libvar.c; $(DO_BOT_CC) \n$(B)/ded/l_log.o : $(BLIBDIR)/l_log.c; $(DO_BOT_CC) \n$(B)/ded/l_memory.o : $(BLIBDIR)/l_memory.c; $(DO_BOT_CC) \n$(B)/ded/l_precomp.o : $(BLIBDIR)/l_precomp.c; $(DO_BOT_CC) \n$(B)/ded/l_script.o : $(BLIBDIR)/l_script.c; $(DO_BOT_CC) \n$(B)/ded/l_struct.o : $(BLIBDIR)/l_struct.c; $(DO_BOT_CC) \n\n$(B)/ded/linux_common.o : $(UDIR)/linux_common.c; $(DO_CC)\n$(B)/ded/unix_main.o : $(UDIR)/unix_main.c; $(DO_DED_CC) \n$(B)/ded/unix_net.o : $(UDIR)/unix_net.c; $(DO_DED_CC) \n$(B)/ded/unix_shared.o : $(UDIR)/unix_shared.c; $(DO_DED_CC) \n$(B)/ded/null_client.o : $(NDIR)/null_client.c; $(DO_DED_CC) \n$(B)/ded/null_input.o : $(NDIR)/null_input.c; $(DO_DED_CC) \n$(B)/ded/null_snddma.o : $(NDIR)/null_snddma.c; $(DO_DED_CC) \n$(B)/ded/unzip.o : $(CMDIR)/unzip.c; $(DO_DED_CC) \n$(B)/ded/vm.o : $(CMDIR)/vm.c; $(DO_DED_CC) \n$(B)/ded/vm_interpreted.o : $(CMDIR)/vm_interpreted.c; $(DO_DED_CC) \n\nifeq ($(ARCH),i386)\n$(B)/ded/vm_x86.o : $(CMDIR)/vm_x86.c; $(DO_DED_CC) \n$(B)/ded/ftol.o : $(UDIR)/ftol.nasm; $(DO_NASM)\n$(B)/ded/snapvector.o : $(UDIR)/snapvector.nasm; $(DO_NASM) \nendif\n\nifeq ($(ARCH),ppc)\nifeq ($(DLL_ONLY),false)\n$(B)/ded/vm_ppc.o : $(CMDIR)/vm_ppc.c; $(DO_DED_CC)\nendif\nendif\n\n\n#############################################################################\n## QVM\n#############################################################################\n\n$(B)/baseq3/vm/cgame.qvm:\n\tcd $(CGDIR) && ./cgame.sh\n\tmv /tmp/quake3/baseq3/vm/cgame.qvm $@\n\n$(B)/baseq3/vm/ui.qvm:\n\tcd $(Q3UIDIR) && ./q3_ui.sh\n\tmv /tmp/quake3/baseq3/vm/ui.qvm $@\n\n$(B)/baseq3/vm/qagame.qvm:\n\tcd $(GDIR) && ./game.sh\n\tmv /tmp/quake3/baseq3/vm/qagame.qvm $@\n\n$(B)/missionpack/vm/cgame.qvm:\n\tcd $(CGDIR) && ./cgame_ta.sh\n\tmv /tmp/quake3/missionpack/vm/cgame.qvm $@\n\n$(B)/missionpack/vm/qagame.qvm:\n\tcd $(GDIR) && ./game_ta.sh\n\tmv /tmp/quake3/missionpack/vm/qagame.qvm $@\n\n$(B)/missionpack/vm/ui.qvm:\n\tcd $(UIDIR) && ./ui.sh\n\tmv /tmp/quake3/missionpack/vm/ui.qvm $@\n\n\n\n#############################################################################\n## BASEQ3 CGAME\n#############################################################################\n\nQ3CGOBJ = \\\n\t$(B)/baseq3/cgame/bg_misc.o \\\n\t$(B)/baseq3/cgame/bg_pmove.o \\\n\t$(B)/baseq3/cgame/bg_slidemove.o \\\n\t$(B)/baseq3/cgame/cg_consolecmds.o \\\n\t$(B)/baseq3/cgame/cg_draw.o \\\n\t$(B)/baseq3/cgame/cg_drawtools.o \\\n\t$(B)/baseq3/cgame/cg_effects.o \\\n\t$(B)/baseq3/cgame/cg_ents.o \\\n\t$(B)/baseq3/cgame/cg_event.o \\\n\t$(B)/baseq3/cgame/cg_info.o \\\n\t$(B)/baseq3/cgame/cg_localents.o \\\n\t$(B)/baseq3/cgame/cg_main.o \\\n\t$(B)/baseq3/cgame/cg_marks.o \\\n\t$(B)/baseq3/cgame/cg_players.o \\\n\t$(B)/baseq3/cgame/cg_playerstate.o \\\n\t$(B)/baseq3/cgame/cg_predict.o \\\n\t$(B)/baseq3/cgame/cg_scoreboard.o \\\n\t$(B)/baseq3/cgame/cg_servercmds.o \\\n\t$(B)/baseq3/cgame/cg_snapshot.o \\\n\t$(B)/baseq3/cgame/cg_syscalls.o \\\n\t$(B)/baseq3/cgame/cg_view.o \\\n\t$(B)/baseq3/cgame/cg_weapons.o \\\n\t$(B)/baseq3/cgame/q_math.o \\\n\t$(B)/baseq3/cgame/q_shared.o\n\n$(B)/baseq3/cgame$(ARCH).$(SHLIBEXT) : $(Q3CGOBJ)\n\t$(CC)  $(SHLIBLDFLAGS) -o $@ $(Q3CGOBJ)\n\n$(B)/baseq3/cgame/bg_misc.o : $(GDIR)/bg_misc.c; $(DO_SHLIB_CC)         \n$(B)/baseq3/cgame/bg_pmove.o : $(GDIR)/bg_pmove.c; $(DO_SHLIB_CC)        \n$(B)/baseq3/cgame/bg_slidemove.o : $(GDIR)/bg_slidemove.c; $(DO_SHLIB_CC)        \n$(B)/baseq3/cgame/cg_consolecmds.o : $(CGDIR)/cg_consolecmds.c; $(DO_SHLIB_CC)       \n$(B)/baseq3/cgame/cg_draw.o : $(CGDIR)/cg_draw.c; $(DO_SHLIB_CC)             \n$(B)/baseq3/cgame/cg_drawtools.o : $(CGDIR)/cg_drawtools.c; $(DO_SHLIB_CC)        \n$(B)/baseq3/cgame/cg_effects.o : $(CGDIR)/cg_effects.c; $(DO_SHLIB_CC)           \n$(B)/baseq3/cgame/cg_ents.o : $(CGDIR)/cg_ents.c; $(DO_SHLIB_CC)               \n$(B)/baseq3/cgame/cg_event.o : $(CGDIR)/cg_event.c; $(DO_SHLIB_CC)            \n$(B)/baseq3/cgame/cg_info.o : $(CGDIR)/cg_info.c; $(DO_SHLIB_CC)               \n$(B)/baseq3/cgame/cg_localents.o : $(CGDIR)/cg_localents.c; $(DO_SHLIB_CC)           \n$(B)/baseq3/cgame/cg_main.o : $(CGDIR)/cg_main.c; $(DO_SHLIB_CC)                   \n$(B)/baseq3/cgame/cg_marks.o : $(CGDIR)/cg_marks.c; $(DO_SHLIB_CC)                 \n$(B)/baseq3/cgame/cg_players.o : $(CGDIR)/cg_players.c; $(DO_SHLIB_CC)             \n$(B)/baseq3/cgame/cg_playerstate.o : $(CGDIR)/cg_playerstate.c; $(DO_SHLIB_CC)        \n$(B)/baseq3/cgame/cg_predict.o : $(CGDIR)/cg_predict.c; $(DO_SHLIB_CC)        \n$(B)/baseq3/cgame/cg_scoreboard.o : $(CGDIR)/cg_scoreboard.c; $(DO_SHLIB_CC)        \n$(B)/baseq3/cgame/cg_servercmds.o : $(CGDIR)/cg_servercmds.c; $(DO_SHLIB_CC)        \n$(B)/baseq3/cgame/cg_snapshot.o : $(CGDIR)/cg_snapshot.c; $(DO_SHLIB_CC)             \n$(B)/baseq3/cgame/cg_syscalls.o : $(CGDIR)/cg_syscalls.c; $(DO_SHLIB_CC)        \n$(B)/baseq3/cgame/cg_view.o : $(CGDIR)/cg_view.c; $(DO_SHLIB_CC)                     \n$(B)/baseq3/cgame/cg_weapons.o : $(CGDIR)/cg_weapons.c; $(DO_SHLIB_CC)               \n$(B)/baseq3/cgame/q_math.o : $(GDIR)/q_math.c; $(DO_SHLIB_CC)                       \n$(B)/baseq3/cgame/q_shared.o : $(GDIR)/q_shared.c; $(DO_SHLIB_CC)                     \n\n#############################################################################\n## MISSIONPACK CGAME\n#############################################################################\n\nMPCGOBJ = \\\n\t$(B)/missionpack/cgame/bg_misc.o \\\n\t$(B)/missionpack/cgame/bg_pmove.o \\\n\t$(B)/missionpack/cgame/bg_slidemove.o \\\n\t$(B)/missionpack/cgame/cg_consolecmds.o \\\n\t$(B)/missionpack/cgame/cg_newdraw.o \\\n\t$(B)/missionpack/cgame/cg_draw.o \\\n\t$(B)/missionpack/cgame/cg_drawtools.o \\\n\t$(B)/missionpack/cgame/cg_effects.o \\\n\t$(B)/missionpack/cgame/cg_ents.o \\\n\t$(B)/missionpack/cgame/cg_event.o \\\n\t$(B)/missionpack/cgame/cg_info.o \\\n\t$(B)/missionpack/cgame/cg_localents.o \\\n\t$(B)/missionpack/cgame/cg_main.o \\\n\t$(B)/missionpack/cgame/cg_marks.o \\\n\t$(B)/missionpack/cgame/cg_players.o \\\n\t$(B)/missionpack/cgame/cg_playerstate.o \\\n\t$(B)/missionpack/cgame/cg_predict.o \\\n\t$(B)/missionpack/cgame/cg_scoreboard.o \\\n\t$(B)/missionpack/cgame/cg_servercmds.o \\\n\t$(B)/missionpack/cgame/cg_snapshot.o \\\n\t$(B)/missionpack/cgame/cg_syscalls.o \\\n\t$(B)/missionpack/cgame/cg_view.o \\\n\t$(B)/missionpack/cgame/cg_weapons.o \\\n\t$(B)/missionpack/cgame/q_math.o \\\n\t$(B)/missionpack/cgame/q_shared.o \\\n\t$(B)/missionpack/cgame/ui_shared.o\n\n$(B)/missionpack/cgame$(ARCH).$(SHLIBEXT) : $(MPCGOBJ)\n\t$(CC) $(SHLIBLDFLAGS) -o $@ $(MPCGOBJ)\n\n$(B)/missionpack/cgame/bg_misc.o : $(GDIR)/bg_misc.c; $(DO_SHLIB_CC)     -DMISSIONPACK \n$(B)/missionpack/cgame/bg_pmove.o : $(GDIR)/bg_pmove.c; $(DO_SHLIB_CC)    -DMISSIONPACK \n$(B)/missionpack/cgame/bg_slidemove.o : $(GDIR)/bg_slidemove.c; $(DO_SHLIB_CC)   -DMISSIONPACK \n$(B)/missionpack/cgame/cg_consolecmds.o : $(CGDIR)/cg_consolecmds.c; $(DO_SHLIB_CC)   -DMISSIONPACK \n$(B)/missionpack/cgame/cg_newdraw.o : $(CGDIR)/cg_newdraw.c; $(DO_SHLIB_CC)         -DMISSIONPACK\n$(B)/missionpack/cgame/cg_draw.o : $(CGDIR)/cg_draw.c; $(DO_SHLIB_CC)    -DMISSIONPACK  \n$(B)/missionpack/cgame/cg_drawtools.o : $(CGDIR)/cg_drawtools.c; $(DO_SHLIB_CC)    -DMISSIONPACK \n$(B)/missionpack/cgame/cg_effects.o : $(CGDIR)/cg_effects.c; $(DO_SHLIB_CC)       -DMISSIONPACK \n$(B)/missionpack/cgame/cg_ents.o : $(CGDIR)/cg_ents.c; $(DO_SHLIB_CC)           -DMISSIONPACK \n$(B)/missionpack/cgame/cg_event.o : $(CGDIR)/cg_event.c; $(DO_SHLIB_CC)        -DMISSIONPACK \n$(B)/missionpack/cgame/cg_info.o : $(CGDIR)/cg_info.c; $(DO_SHLIB_CC)           -DMISSIONPACK \n$(B)/missionpack/cgame/cg_localents.o : $(CGDIR)/cg_localents.c; $(DO_SHLIB_CC)   -DMISSIONPACK \n$(B)/missionpack/cgame/cg_main.o : $(CGDIR)/cg_main.c; $(DO_SHLIB_CC)             -DMISSIONPACK \n$(B)/missionpack/cgame/cg_marks.o : $(CGDIR)/cg_marks.c; $(DO_SHLIB_CC)          -DMISSIONPACK  \n$(B)/missionpack/cgame/cg_players.o : $(CGDIR)/cg_players.c; $(DO_SHLIB_CC)       -DMISSIONPACK \n$(B)/missionpack/cgame/cg_playerstate.o : $(CGDIR)/cg_playerstate.c; $(DO_SHLIB_CC)  -DMISSIONPACK \n$(B)/missionpack/cgame/cg_predict.o : $(CGDIR)/cg_predict.c; $(DO_SHLIB_CC)  -DMISSIONPACK \n$(B)/missionpack/cgame/cg_scoreboard.o : $(CGDIR)/cg_scoreboard.c; $(DO_SHLIB_CC)  -DMISSIONPACK \n$(B)/missionpack/cgame/cg_servercmds.o : $(CGDIR)/cg_servercmds.c; $(DO_SHLIB_CC)  -DMISSIONPACK \n$(B)/missionpack/cgame/cg_snapshot.o : $(CGDIR)/cg_snapshot.c; $(DO_SHLIB_CC)       -DMISSIONPACK \n$(B)/missionpack/cgame/cg_syscalls.o : $(CGDIR)/cg_syscalls.c; $(DO_SHLIB_CC)  -DMISSIONPACK \n$(B)/missionpack/cgame/cg_view.o : $(CGDIR)/cg_view.c; $(DO_SHLIB_CC)               -DMISSIONPACK \n$(B)/missionpack/cgame/cg_weapons.o : $(CGDIR)/cg_weapons.c; $(DO_SHLIB_CC)        -DMISSIONPACK  \n$(B)/missionpack/cgame/q_math.o : $(GDIR)/q_math.c; $(DO_SHLIB_CC)                 -DMISSIONPACK \n$(B)/missionpack/cgame/q_shared.o : $(GDIR)/q_shared.c; $(DO_SHLIB_CC)             -DMISSIONPACK \n$(B)/missionpack/cgame/ui_shared.o : $(UIDIR)/ui_shared.c; $(DO_SHLIB_CC)             -DMISSIONPACK \n\n\n\n#############################################################################\n## BASEQ3 GAME\n#############################################################################\n\nQ3GOBJ = \\\n\t$(B)/baseq3/game/ai_chat.o \\\n\t$(B)/baseq3/game/ai_cmd.o \\\n\t$(B)/baseq3/game/ai_dmnet.o \\\n\t$(B)/baseq3/game/ai_dmq3.o \\\n\t$(B)/baseq3/game/ai_main.o \\\n\t$(B)/baseq3/game/ai_team.o \\\n\t$(B)/baseq3/game/ai_vcmd.o \\\n\t$(B)/baseq3/game/bg_misc.o \\\n\t$(B)/baseq3/game/bg_pmove.o \\\n\t$(B)/baseq3/game/bg_slidemove.o \\\n\t$(B)/baseq3/game/g_active.o \\\n\t$(B)/baseq3/game/g_arenas.o \\\n\t$(B)/baseq3/game/g_bot.o \\\n\t$(B)/baseq3/game/g_client.o \\\n\t$(B)/baseq3/game/g_cmds.o \\\n\t$(B)/baseq3/game/g_combat.o \\\n\t$(B)/baseq3/game/g_items.o \\\n\t$(B)/baseq3/game/g_main.o \\\n\t$(B)/baseq3/game/g_mem.o \\\n\t$(B)/baseq3/game/g_misc.o \\\n\t$(B)/baseq3/game/g_missile.o \\\n\t$(B)/baseq3/game/g_mover.o \\\n\t$(B)/baseq3/game/g_session.o \\\n\t$(B)/baseq3/game/g_spawn.o \\\n\t$(B)/baseq3/game/g_svcmds.o \\\n\t$(B)/baseq3/game/g_syscalls.o \\\n\t$(B)/baseq3/game/g_target.o \\\n\t$(B)/baseq3/game/g_team.o \\\n\t$(B)/baseq3/game/g_trigger.o \\\n\t$(B)/baseq3/game/g_utils.o \\\n\t$(B)/baseq3/game/g_weapon.o \\\n\t\\\n\t$(B)/baseq3/game/q_math.o \\\n\t$(B)/baseq3/game/q_shared.o\n\n$(B)/baseq3/qagame$(ARCH).$(SHLIBEXT) : $(Q3GOBJ)\n\t$(CC)  $(SHLIBLDFLAGS) -o $@ $(Q3GOBJ)\n\n$(B)/baseq3/game/ai_chat.o : $(GDIR)/ai_chat.c; $(DO_SHLIB_CC)     \n$(B)/baseq3/game/ai_cmd.o : $(GDIR)/ai_cmd.c; $(DO_SHLIB_CC)       \n$(B)/baseq3/game/ai_dmnet.o : $(GDIR)/ai_dmnet.c; $(DO_SHLIB_CC)   \n$(B)/baseq3/game/ai_dmq3.o : $(GDIR)/ai_dmq3.c; $(DO_SHLIB_CC)       \n$(B)/baseq3/game/ai_main.o : $(GDIR)/ai_main.c; $(DO_SHLIB_CC)      \n$(B)/baseq3/game/ai_team.o : $(GDIR)/ai_team.c; $(DO_SHLIB_CC)  \n$(B)/baseq3/game/ai_vcmd.o : $(GDIR)/ai_vcmd.c; $(DO_SHLIB_CC)     \n$(B)/baseq3/game/bg_misc.o : $(GDIR)/bg_misc.c; $(DO_SHLIB_CC)     \n$(B)/baseq3/game/bg_pmove.o : $(GDIR)/bg_pmove.c; $(DO_SHLIB_CC)     \n$(B)/baseq3/game/bg_slidemove.o : $(GDIR)/bg_slidemove.c; $(DO_SHLIB_CC)    \n$(B)/baseq3/game/g_active.o : $(GDIR)/g_active.c; $(DO_SHLIB_CC)       \n$(B)/baseq3/game/g_arenas.o : $(GDIR)/g_arenas.c; $(DO_SHLIB_CC)       \n$(B)/baseq3/game/g_bot.o : $(GDIR)/g_bot.c; $(DO_SHLIB_CC)            \n$(B)/baseq3/game/g_client.o : $(GDIR)/g_client.c; $(DO_SHLIB_CC)      \n$(B)/baseq3/game/g_cmds.o : $(GDIR)/g_cmds.c; $(DO_SHLIB_CC)          \n$(B)/baseq3/game/g_combat.o : $(GDIR)/g_combat.c; $(DO_SHLIB_CC)       \n$(B)/baseq3/game/g_items.o : $(GDIR)/g_items.c; $(DO_SHLIB_CC)          \n$(B)/baseq3/game/g_main.o : $(GDIR)/g_main.c; $(DO_SHLIB_CC)            \n$(B)/baseq3/game/g_mem.o : $(GDIR)/g_mem.c; $(DO_SHLIB_CC)               \n$(B)/baseq3/game/g_misc.o : $(GDIR)/g_misc.c; $(DO_SHLIB_CC)             \n$(B)/baseq3/game/g_missile.o : $(GDIR)/g_missile.c; $(DO_SHLIB_CC)        \n$(B)/baseq3/game/g_mover.o : $(GDIR)/g_mover.c; $(DO_SHLIB_CC)          \n$(B)/baseq3/game/g_session.o : $(GDIR)/g_session.c; $(DO_SHLIB_CC)       \n$(B)/baseq3/game/g_spawn.o : $(GDIR)/g_spawn.c; $(DO_SHLIB_CC)          \n$(B)/baseq3/game/g_svcmds.o : $(GDIR)/g_svcmds.c; $(DO_SHLIB_CC)         \n$(B)/baseq3/game/g_syscalls.o : $(GDIR)/g_syscalls.c; $(DO_SHLIB_CC)    \n$(B)/baseq3/game/g_target.o : $(GDIR)/g_target.c; $(DO_SHLIB_CC)        \n$(B)/baseq3/game/g_team.o : $(GDIR)/g_team.c; $(DO_SHLIB_CC)           \n$(B)/baseq3/game/g_trigger.o : $(GDIR)/g_trigger.c; $(DO_SHLIB_CC)       \n$(B)/baseq3/game/g_utils.o : $(GDIR)/g_utils.c; $(DO_SHLIB_CC)          \n$(B)/baseq3/game/g_weapon.o : $(GDIR)/g_weapon.c; $(DO_SHLIB_CC)       \n$(B)/baseq3/game/q_math.o : $(GDIR)/q_math.c; $(DO_SHLIB_CC)            \n$(B)/baseq3/game/q_shared.o : $(GDIR)/q_shared.c; $(DO_SHLIB_CC)       \n\n\n#############################################################################\n## MISSIONPACK GAME\n#############################################################################\n\nMPGOBJ = \\\n\t$(B)/missionpack/game/ai_chat.o \\\n\t$(B)/missionpack/game/ai_cmd.o \\\n\t$(B)/missionpack/game/ai_dmnet.o \\\n\t$(B)/missionpack/game/ai_dmq3.o \\\n\t$(B)/missionpack/game/ai_main.o \\\n\t$(B)/missionpack/game/ai_team.o \\\n\t$(B)/missionpack/game/ai_vcmd.o \\\n\t$(B)/missionpack/game/bg_misc.o \\\n\t$(B)/missionpack/game/bg_pmove.o \\\n\t$(B)/missionpack/game/bg_slidemove.o \\\n\t$(B)/missionpack/game/g_active.o \\\n\t$(B)/missionpack/game/g_arenas.o \\\n\t$(B)/missionpack/game/g_bot.o \\\n\t$(B)/missionpack/game/g_client.o \\\n\t$(B)/missionpack/game/g_cmds.o \\\n\t$(B)/missionpack/game/g_combat.o \\\n\t$(B)/missionpack/game/g_items.o \\\n\t$(B)/missionpack/game/g_main.o \\\n\t$(B)/missionpack/game/g_mem.o \\\n\t$(B)/missionpack/game/g_misc.o \\\n\t$(B)/missionpack/game/g_missile.o \\\n\t$(B)/missionpack/game/g_mover.o \\\n\t$(B)/missionpack/game/g_session.o \\\n\t$(B)/missionpack/game/g_spawn.o \\\n\t$(B)/missionpack/game/g_svcmds.o \\\n\t$(B)/missionpack/game/g_syscalls.o \\\n\t$(B)/missionpack/game/g_target.o \\\n\t$(B)/missionpack/game/g_team.o \\\n\t$(B)/missionpack/game/g_trigger.o \\\n\t$(B)/missionpack/game/g_utils.o \\\n\t$(B)/missionpack/game/g_weapon.o \\\n\t\\\n\t$(B)/missionpack/game/q_math.o \\\n\t$(B)/missionpack/game/q_shared.o\n\n$(B)/missionpack/qagame$(ARCH).$(SHLIBEXT) : $(MPGOBJ)\n\t$(CC) $(SHLIBLDFLAGS) -o $@ $(MPGOBJ)\n\n$(B)/missionpack/game/ai_chat.o : $(GDIR)/ai_chat.c; $(DO_SHLIB_CC)    -DMISSIONPACK \n$(B)/missionpack/game/ai_cmd.o : $(GDIR)/ai_cmd.c; $(DO_SHLIB_CC)      -DMISSIONPACK \n$(B)/missionpack/game/ai_dmnet.o : $(GDIR)/ai_dmnet.c; $(DO_SHLIB_CC)  -DMISSIONPACK \n$(B)/missionpack/game/ai_dmq3.o : $(GDIR)/ai_dmq3.c; $(DO_SHLIB_CC)    -DMISSIONPACK   \n$(B)/missionpack/game/ai_main.o : $(GDIR)/ai_main.c; $(DO_SHLIB_CC)    -DMISSIONPACK  \n$(B)/missionpack/game/ai_team.o : $(GDIR)/ai_team.c; $(DO_SHLIB_CC)    -DMISSIONPACK \n$(B)/missionpack/game/ai_vcmd.o : $(GDIR)/ai_vcmd.c; $(DO_SHLIB_CC)    -DMISSIONPACK \n$(B)/missionpack/game/bg_misc.o : $(GDIR)/bg_misc.c; $(DO_SHLIB_CC)    -DMISSIONPACK \n$(B)/missionpack/game/bg_pmove.o : $(GDIR)/bg_pmove.c; $(DO_SHLIB_CC)    -DMISSIONPACK \n$(B)/missionpack/game/bg_slidemove.o : $(GDIR)/bg_slidemove.c; $(DO_SHLIB_CC)  -DMISSIONPACK  \n$(B)/missionpack/game/g_active.o : $(GDIR)/g_active.c; $(DO_SHLIB_CC)      -DMISSIONPACK \n$(B)/missionpack/game/g_arenas.o : $(GDIR)/g_arenas.c; $(DO_SHLIB_CC)      -DMISSIONPACK \n$(B)/missionpack/game/g_bot.o : $(GDIR)/g_bot.c; $(DO_SHLIB_CC)           -DMISSIONPACK \n$(B)/missionpack/game/g_client.o : $(GDIR)/g_client.c; $(DO_SHLIB_CC)     -DMISSIONPACK \n$(B)/missionpack/game/g_cmds.o : $(GDIR)/g_cmds.c; $(DO_SHLIB_CC)         -DMISSIONPACK \n$(B)/missionpack/game/g_combat.o : $(GDIR)/g_combat.c; $(DO_SHLIB_CC)      -DMISSIONPACK \n$(B)/missionpack/game/g_items.o : $(GDIR)/g_items.c; $(DO_SHLIB_CC)         -DMISSIONPACK \n$(B)/missionpack/game/g_main.o : $(GDIR)/g_main.c; $(DO_SHLIB_CC)          -DMISSIONPACK  \n$(B)/missionpack/game/g_mem.o : $(GDIR)/g_mem.c; $(DO_SHLIB_CC)             -DMISSIONPACK  \n$(B)/missionpack/game/g_misc.o : $(GDIR)/g_misc.c; $(DO_SHLIB_CC)            -DMISSIONPACK \n$(B)/missionpack/game/g_missile.o : $(GDIR)/g_missile.c; $(DO_SHLIB_CC)      -DMISSIONPACK  \n$(B)/missionpack/game/g_mover.o : $(GDIR)/g_mover.c; $(DO_SHLIB_CC)        -DMISSIONPACK  \n$(B)/missionpack/game/g_session.o : $(GDIR)/g_session.c; $(DO_SHLIB_CC)     -DMISSIONPACK  \n$(B)/missionpack/game/g_spawn.o : $(GDIR)/g_spawn.c; $(DO_SHLIB_CC)         -DMISSIONPACK \n$(B)/missionpack/game/g_svcmds.o : $(GDIR)/g_svcmds.c; $(DO_SHLIB_CC)       -DMISSIONPACK  \n$(B)/missionpack/game/g_syscalls.o : $(GDIR)/g_syscalls.c; $(DO_SHLIB_CC)   -DMISSIONPACK \n$(B)/missionpack/game/g_target.o : $(GDIR)/g_target.c; $(DO_SHLIB_CC)       -DMISSIONPACK \n$(B)/missionpack/game/g_team.o : $(GDIR)/g_team.c; $(DO_SHLIB_CC)         -DMISSIONPACK  \n$(B)/missionpack/game/g_trigger.o : $(GDIR)/g_trigger.c; $(DO_SHLIB_CC)    -DMISSIONPACK   \n$(B)/missionpack/game/g_utils.o : $(GDIR)/g_utils.c; $(DO_SHLIB_CC)        -DMISSIONPACK  \n$(B)/missionpack/game/g_weapon.o : $(GDIR)/g_weapon.c; $(DO_SHLIB_CC)      -DMISSIONPACK \n$(B)/missionpack/game/q_math.o : $(GDIR)/q_math.c; $(DO_SHLIB_CC)          -DMISSIONPACK  \n$(B)/missionpack/game/q_shared.o : $(GDIR)/q_shared.c; $(DO_SHLIB_CC)      -DMISSIONPACK \n\n\n\n#############################################################################\n## BASEQ3 UI\n#############################################################################\n\nQ3UIOBJ = \\\n        $(B)/baseq3/ui/bg_misc.o \\\n        $(B)/baseq3/ui/ui_addbots.o \\\n        $(B)/baseq3/ui/ui_atoms.o \\\n        $(B)/baseq3/ui/ui_cdkey.o \\\n        $(B)/baseq3/ui/ui_cinematics.o \\\n        $(B)/baseq3/ui/ui_confirm.o \\\n        $(B)/baseq3/ui/ui_connect.o \\\n        $(B)/baseq3/ui/ui_controls2.o \\\n        $(B)/baseq3/ui/ui_credits.o \\\n        $(B)/baseq3/ui/ui_demo2.o \\\n        $(B)/baseq3/ui/ui_display.o \\\n        $(B)/baseq3/ui/ui_gameinfo.o \\\n        $(B)/baseq3/ui/ui_ingame.o \\\n        $(B)/baseq3/ui/ui_loadconfig.o \\\n        $(B)/baseq3/ui/ui_main.o \\\n        $(B)/baseq3/ui/ui_menu.o \\\n        $(B)/baseq3/ui/ui_mfield.o \\\n        $(B)/baseq3/ui/ui_mods.o \\\n        $(B)/baseq3/ui/ui_network.o \\\n        $(B)/baseq3/ui/ui_options.o \\\n        $(B)/baseq3/ui/ui_playermodel.o \\\n        $(B)/baseq3/ui/ui_players.o \\\n        $(B)/baseq3/ui/ui_playersettings.o \\\n        $(B)/baseq3/ui/ui_preferences.o \\\n        $(B)/baseq3/ui/ui_qmenu.o \\\n        $(B)/baseq3/ui/ui_removebots.o \\\n        $(B)/baseq3/ui/ui_saveconfig.o \\\n        $(B)/baseq3/ui/ui_serverinfo.o \\\n        $(B)/baseq3/ui/ui_servers2.o \\\n        $(B)/baseq3/ui/ui_setup.o \\\n        $(B)/baseq3/ui/ui_sound.o \\\n        $(B)/baseq3/ui/ui_sparena.o \\\n        $(B)/baseq3/ui/ui_specifyserver.o \\\n        $(B)/baseq3/ui/ui_splevel.o \\\n        $(B)/baseq3/ui/ui_sppostgame.o \\\n        $(B)/baseq3/ui/ui_spskill.o \\\n        $(B)/baseq3/ui/ui_startserver.o \\\n        $(B)/baseq3/ui/ui_syscalls.o \\\n        $(B)/baseq3/ui/ui_team.o \\\n        $(B)/baseq3/ui/ui_teamorders.o \\\n        $(B)/baseq3/ui/ui_video.o \\\n        \\\n        $(B)/baseq3/ui/q_math.o \\\n        $(B)/baseq3/ui/q_shared.o\n\n$(B)/baseq3/ui$(ARCH).$(SHLIBEXT) : $(Q3UIOBJ)\n\t$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(Q3UIOBJ)\n\n$(B)/baseq3/ui/bg_misc.o : $(GDIR)/bg_misc.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_addbots.o : $(Q3UIDIR)/ui_addbots.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_atoms.o : $(Q3UIDIR)/ui_atoms.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_cinematics.o : $(Q3UIDIR)/ui_cinematics.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_cdkey.o : $(Q3UIDIR)/ui_cdkey.c; $(DO_SHLIB_CC)\n$(B)/baseq3/ui/ui_confirm.o : $(Q3UIDIR)/ui_confirm.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_connect.o : $(Q3UIDIR)/ui_connect.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_controls2.o : $(Q3UIDIR)/ui_controls2.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_credits.o : $(Q3UIDIR)/ui_credits.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_demo2.o : $(Q3UIDIR)/ui_demo2.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_display.o : $(Q3UIDIR)/ui_display.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_gameinfo.o : $(Q3UIDIR)/ui_gameinfo.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_ingame.o : $(Q3UIDIR)/ui_ingame.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_loadconfig.o : $(Q3UIDIR)/ui_loadconfig.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_main.o : $(Q3UIDIR)/ui_main.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_menu.o : $(Q3UIDIR)/ui_menu.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_mfield.o : $(Q3UIDIR)/ui_mfield.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_mods.o : $(Q3UIDIR)/ui_mods.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_network.o : $(Q3UIDIR)/ui_network.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_options.o : $(Q3UIDIR)/ui_options.c; $(DO_SHLIB_CC)\n$(B)/baseq3/ui/ui_playermodel.o : $(Q3UIDIR)/ui_playermodel.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_players.o : $(Q3UIDIR)/ui_players.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_playersettings.o : $(Q3UIDIR)/ui_playersettings.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_preferences.o : $(Q3UIDIR)/ui_preferences.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_qmenu.o : $(Q3UIDIR)/ui_qmenu.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_quit.o : $(Q3UIDIR)/ui_quit.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_removebots.o : $(Q3UIDIR)/ui_removebots.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_saveconfig.o : $(Q3UIDIR)/ui_saveconfig.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_serverinfo.o : $(Q3UIDIR)/ui_serverinfo.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_servers2.o : $(Q3UIDIR)/ui_servers2.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_setup.o : $(Q3UIDIR)/ui_setup.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_sound.o : $(Q3UIDIR)/ui_sound.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_sparena.o : $(Q3UIDIR)/ui_sparena.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_specifyserver.o : $(Q3UIDIR)/ui_specifyserver.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_splevel.o : $(Q3UIDIR)/ui_splevel.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_sppostgame.o : $(Q3UIDIR)/ui_sppostgame.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_spskill.o : $(Q3UIDIR)/ui_spskill.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_startserver.o : $(Q3UIDIR)/ui_startserver.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_team.o : $(Q3UIDIR)/ui_team.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_teamorders.o : $(Q3UIDIR)/ui_teamorders.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_syscalls.o : $(Q3UIDIR)/ui_syscalls.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/ui_video.o : $(Q3UIDIR)/ui_video.c; $(DO_SHLIB_CC) \n\n# bk001205 - these wre the only SHLIB compiles in 1.17\n$(B)/baseq3/ui/q_math.o : $(GDIR)/q_math.c; $(DO_SHLIB_CC) \n$(B)/baseq3/ui/q_shared.o : $(GDIR)/q_shared.c; $(DO_SHLIB_CC) \n\n\n\n#############################################################################\n## MISSIONPACK UI\n#############################################################################\n\nMPUIOBJ = \\\n\t$(B)/missionpack/ui/ui_atoms.o \\\n\t$(B)/missionpack/ui/ui_gameinfo.o \\\n\t$(B)/missionpack/ui/ui_main.o \\\n\t$(B)/missionpack/ui/ui_players.o \\\n\t$(B)/missionpack/ui/ui_syscalls.o \\\n\t$(B)/missionpack/ui/ui_util.o \\\n\t$(B)/missionpack/ui/ui_shared.o \\\n\t\\\n\t$(B)/missionpack/ui/bg_misc.o \\\n\t\\\n\t$(B)/missionpack/ui/q_math.o \\\n\t$(B)/missionpack/ui/q_shared.o\n#\t$(B)/missionpack/ui/ui_atoms.o \\\n#\t$(B)/missionpack/ui/ui_gameinfo.o \\\n#\t$(B)/missionpack/ui/ui_main.o \\\n#\t$(B)/missionpack/ui/ui_players.o \\\n#\t$(B)/missionpack/ui/ui_syscalls.o \\\n#\t$(B)/missionpack/ui/ui_util.o \\\n#\t$(B)/missionpack/ui/ui_shared.o \\\n#\t\\\n#\t$(B)/missionpack/ui/bg_misc.o \\\n#\t$(B)/missionpack/ui/bg_lib.o \\\n#\t\\\n#\t$(B)/missionpack/ui/q_math.o \\\n#\t$(B)/missionpack/ui/q_shared.o\n\n$(B)/missionpack/ui$(ARCH).$(SHLIBEXT) : $(MPUIOBJ)\n\t$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(MPUIOBJ)\n\n$(B)/missionpack/ui/ui_atoms.o : $(UIDIR)/ui_atoms.c; $(DO_SHLIB_CC)  -DMISSIONPACK  \n$(B)/missionpack/ui/ui_gameinfo.o : $(UIDIR)/ui_gameinfo.c; $(DO_SHLIB_CC)  -DMISSIONPACK  \n$(B)/missionpack/ui/ui_main.o : $(UIDIR)/ui_main.c; $(DO_SHLIB_CC)  -DMISSIONPACK  \n$(B)/missionpack/ui/ui_players.o : $(UIDIR)/ui_players.c; $(DO_SHLIB_CC)  -DMISSIONPACK  \n$(B)/missionpack/ui/ui_syscalls.o : $(UIDIR)/ui_syscalls.c; $(DO_SHLIB_CC)  -DMISSIONPACK  \n$(B)/missionpack/ui/ui_util.o : $(UIDIR)/ui_util.c; $(DO_SHLIB_CC)  -DMISSIONPACK\n$(B)/missionpack/ui/ui_shared.o : $(UIDIR)/ui_shared.c; $(DO_SHLIB_CC)  -DMISSIONPACK\n\n$(B)/missionpack/ui/bg_misc.o : $(GDIR)/bg_misc.c; $(DO_SHLIB_CC)  -DMISSIONPACK  \n$(B)/missionpack/ui/bg_lib.o : $(GDIR)/bg_lib.c; $(DO_SHLIB_CC)  -DMISSIONPACK  \n\n$(B)/missionpack/ui/q_math.o : $(GDIR)/q_math.c; $(DO_SHLIB_CC)     -DMISSIONPACK  \n$(B)/missionpack/ui/q_shared.o : $(GDIR)/q_shared.c; $(DO_SHLIB_CC)  -DMISSIONPACK  \n\n\n\n\n\n#############################################################################\n## Q3 STATIC (DEBUG) BUILD\n#############################################################################\n\nQ3SOBJ = \\\n\t$(B)/q3static/cl_cgame.o \\\n\t$(B)/q3static/cl_cin.o \\\n\t$(B)/q3static/cl_console.o \\\n\t$(B)/q3static/cl_input.o \\\n\t$(B)/q3static/cl_keys.o \\\n\t$(B)/q3static/cl_main.o \\\n\t$(B)/q3static/cl_net_chan.o \\\n\t$(B)/q3static/cl_parse.o \\\n\t$(B)/q3static/cl_scrn.o \\\n\t$(B)/q3static/cl_ui.o \\\n\t\\\n\t$(B)/q3static/cm_load.o \\\n\t$(B)/q3static/cm_patch.o \\\n\t$(B)/q3static/cm_polylib.o \\\n\t$(B)/q3static/cm_test.o \\\n\t$(B)/q3static/cm_trace.o \\\n\t\\\n\t$(B)/q3static/cmd.o \\\n\t$(B)/q3static/common.o \\\n\t$(B)/q3static/cvar.o \\\n\t$(B)/q3static/files.o \\\n\t$(B)/q3static/md4.o \\\n\t$(B)/q3static/msg.o \\\n\t$(B)/q3static/net_chan.o \\\n\t\\\n\t$(B)/q3static/snd_adpcm.o \\\n\t$(B)/q3static/snd_dma.o \\\n\t$(B)/q3static/snd_mem.o \\\n\t$(B)/q3static/snd_mix.o \\\n\t$(B)/q3static/snd_wavelet.o \\\n\t\\\n\t$(B)/q3static/sv_bot.o \\\n\t$(B)/q3static/sv_ccmds.o \\\n\t$(B)/q3static/sv_client.o \\\n\t$(B)/q3static/sv_game.o \\\n\t$(B)/q3static/sv_init.o \\\n\t$(B)/q3static/sv_main.o \\\n\t$(B)/q3static/sv_net_chan.o \\\n\t$(B)/q3static/sv_snapshot.o \\\n\t$(B)/q3static/sv_world.o \\\n\t\\\n\t$(B)/q3static/unzip.o \\\n\t$(B)/q3static/vm.o \\\n\t$(B)/q3static/vm_interpreted.o \\\n\t\\\n\t$(B)/q3static/be_aas_bspq3.o \\\n\t$(B)/q3static/be_aas_cluster.o \\\n\t$(B)/q3static/be_aas_debug.o \\\n\t$(B)/q3static/be_aas_entity.o \\\n\t$(B)/q3static/be_aas_file.o \\\n\t$(B)/q3static/be_aas_main.o \\\n\t$(B)/q3static/be_aas_move.o \\\n\t$(B)/q3static/be_aas_optimize.o \\\n\t$(B)/q3static/be_aas_reach.o \\\n\t$(B)/q3static/be_aas_route.o \\\n\t$(B)/q3static/be_aas_routealt.o \\\n\t$(B)/q3static/be_aas_sample.o \\\n\t$(B)/q3static/be_ai_char.o \\\n\t$(B)/q3static/be_ai_chat.o \\\n\t$(B)/q3static/be_ai_gen.o \\\n\t$(B)/q3static/be_ai_goal.o \\\n\t$(B)/q3static/be_ai_move.o \\\n\t$(B)/q3static/be_ai_weap.o \\\n\t$(B)/q3static/be_ai_weight.o \\\n\t$(B)/q3static/be_ea.o \\\n\t$(B)/q3static/be_interface.o \\\n\t$(B)/q3static/l_crc.o \\\n\t$(B)/q3static/l_libvar.o \\\n\t$(B)/q3static/l_log.o \\\n\t$(B)/q3static/l_memory.o \\\n\t$(B)/q3static/l_precomp.o \\\n\t$(B)/q3static/l_script.o \\\n\t$(B)/q3static/l_struct.o \\\n\t\\\n\t$(B)/q3static/jcapimin.o \\\n\t$(B)/q3static/jchuff.o   \\\n\t$(B)/q3static/jcinit.o \\\n\t$(B)/q3static/jccoefct.o  \\\n\t$(B)/q3static/jccolor.o \\\n\t$(B)/q3static/jfdctflt.o \\\n\t$(B)/q3static/jcdctmgr.o \\\n\t$(B)/q3static/jcphuff.o \\\n\t$(B)/q3static/jcmainct.o \\\n\t$(B)/q3static/jcmarker.o \\\n\t$(B)/q3static/jcmaster.o \\\n\t$(B)/q3static/jcomapi.o \\\n\t$(B)/q3static/jcparam.o \\\n\t$(B)/q3static/jcprepct.o \\\n\t$(B)/q3static/jcsample.o \\\n\t$(B)/q3static/jdapimin.o \\\n\t$(B)/q3static/jdapistd.o \\\n\t$(B)/q3static/jdatasrc.o \\\n\t$(B)/q3static/jdcoefct.o \\\n\t$(B)/q3static/jdcolor.o \\\n\t$(B)/q3static/jddctmgr.o \\\n\t$(B)/q3static/jdhuff.o \\\n\t$(B)/q3static/jdinput.o \\\n\t$(B)/q3static/jdmainct.o \\\n\t$(B)/q3static/jdmarker.o \\\n\t$(B)/q3static/jdmaster.o \\\n\t$(B)/q3static/jdpostct.o \\\n\t$(B)/q3static/jdsample.o \\\n\t$(B)/q3static/jdtrans.o \\\n\t$(B)/q3static/jerror.o \\\n\t$(B)/q3static/jidctflt.o \\\n\t$(B)/q3static/jmemmgr.o \\\n\t$(B)/q3static/jmemnobs.o \\\n\t$(B)/q3static/jutils.o \\\n\t\\\n\t$(B)/q3static/tr_animation.o \\\n\t$(B)/q3static/tr_backend.o \\\n\t$(B)/q3static/tr_bsp.o \\\n\t$(B)/q3static/tr_cmds.o \\\n\t$(B)/q3static/tr_curve.o \\\n\t$(B)/q3static/tr_flares.o \\\n\t$(B)/q3static/tr_font.o \\\n\t$(B)/q3static/tr_image.o \\\n\t$(B)/q3static/tr_init.o \\\n\t$(B)/q3static/tr_light.o \\\n\t$(B)/q3static/tr_main.o \\\n\t$(B)/q3static/tr_marks.o \\\n\t$(B)/q3static/tr_mesh.o \\\n\t$(B)/q3static/tr_model.o \\\n\t$(B)/q3static/tr_noise.o \\\n\t$(B)/q3static/tr_scene.o \\\n\t$(B)/q3static/tr_shade.o \\\n\t$(B)/q3static/tr_shade_calc.o \\\n\t$(B)/q3static/tr_shader.o \\\n\t$(B)/q3static/tr_shadows.o \\\n\t$(B)/q3static/tr_sky.o \\\n\t$(B)/q3static/tr_surface.o \\\n\t$(B)/q3static/tr_world.o \\\n\t\\\n\t$(B)/q3static/unix_main.o \\\n\t$(B)/q3static/unix_net.o \\\n\t$(B)/q3static/unix_shared.o \\\n\t\\\n\t$(B)/q3static/ahoptim.o  \\\n\t$(B)/q3static/autohint.o \\\n\t$(B)/q3static/ftbase.o   \\\n\t$(B)/q3static/ftdebug.o  \\\n\t$(B)/q3static/ftglyph.o  \\\n\t$(B)/q3static/ftinit.o   \\\n\t$(B)/q3static/ftmm.o     \\\n\t$(B)/q3static/ftsystem.o \\\n\t$(B)/q3static/raster1.o  \\\n\t$(B)/q3static/sfnt.o     \\\n\t$(B)/q3static/sfobjs.o   \\\n\t$(B)/q3static/smooth.o   \\\n\t$(B)/q3static/truetype.o \\\n\t\\\n\t$(B)/q3static/linux_qgl.o \\\n\t$(B)/q3static/linux_glimp.o \\\n\t$(B)/q3static/linux_joystick.o \\\n\t$(B)/q3static/linux_snd.o \\\n\t$(B)/q3static/snd_mixa.o \\\n\t$(B)/q3static/matha.o\n\nifeq ($(ARCH),i386)\n  Q3SOBJ += $(B)/q3static/vm_x86.o\nendif\n\nifeq ($(ARCH),ppc)\n  ifeq ($(DLL_ONLY),false)\n    Q3SOBJ += $(B)/q3static/vm_ppc.o\n  endif\nendif\n\n\n$(B)/q3static/cl_cgame.o : $(CDIR)/cl_cgame.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/cl_cin.o : $(CDIR)/cl_cin.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/cl_console.o : $(CDIR)/cl_console.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/cl_input.o : $(CDIR)/cl_input.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/cl_keys.o : $(CDIR)/cl_keys.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/cl_main.o : $(CDIR)/cl_main.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/cl_net_chan.o : $(CDIR)/cl_net_chan.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/cl_parse.o : $(CDIR)/cl_parse.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/cl_scrn.o : $(CDIR)/cl_scrn.c; $(DO_CC) -DQ3_STATIC    \n$(B)/q3static/cl_ui.o : $(CDIR)/cl_ui.c; $(DO_CC) -DQ3_STATIC         \n$(B)/q3static/snd_adpcm.o : $(CDIR)/snd_adpcm.c; $(DO_CC) -DQ3_STATIC   \n$(B)/q3static/snd_dma.o : $(CDIR)/snd_dma.c; $(DO_CC) -DQ3_STATIC       \n$(B)/q3static/snd_mem.o : $(CDIR)/snd_mem.c; $(DO_CC) -DQ3_STATIC        \n$(B)/q3static/snd_mix.o : $(CDIR)/snd_mix.c; $(DO_CC) -DQ3_STATIC       \n$(B)/q3static/snd_wavelet.o : $(CDIR)/snd_wavelet.c; $(DO_CC) -DQ3_STATIC     \n$(B)/q3static/sv_bot.o : $(SDIR)/sv_bot.c; $(DO_CC) -DQ3_STATIC        \n$(B)/q3static/sv_client.o : $(SDIR)/sv_client.c; $(DO_CC) -DQ3_STATIC     \n$(B)/q3static/sv_ccmds.o : $(SDIR)/sv_ccmds.c; $(DO_CC) -DQ3_STATIC       \n$(B)/q3static/sv_game.o : $(SDIR)/sv_game.c; $(DO_CC) -DQ3_STATIC        \n$(B)/q3static/sv_init.o : $(SDIR)/sv_init.c; $(DO_CC) -DQ3_STATIC        \n$(B)/q3static/sv_main.o : $(SDIR)/sv_main.c; $(DO_CC) -DQ3_STATIC        \n$(B)/q3static/sv_net_chan.o : $(SDIR)/sv_net_chan.c; $(DO_CC) -DQ3_STATIC     \n$(B)/q3static/sv_snapshot.o : $(SDIR)/sv_snapshot.c; $(DO_CC) -DQ3_STATIC      \n$(B)/q3static/sv_world.o : $(SDIR)/sv_world.c; $(DO_CC) -DQ3_STATIC         \n$(B)/q3static/cm_trace.o : $(CMDIR)/cm_trace.c; $(DO_CC) -DQ3_STATIC       \n$(B)/q3static/cm_load.o : $(CMDIR)/cm_load.c; $(DO_CC) -DQ3_STATIC        \n$(B)/q3static/cm_test.o : $(CMDIR)/cm_test.c; $(DO_CC) -DQ3_STATIC        \n$(B)/q3static/cm_patch.o : $(CMDIR)/cm_patch.c; $(DO_CC) -DQ3_STATIC       \n$(B)/q3static/cm_polylib.o : $(CMDIR)/cm_polylib.c; $(DO_CC) -DQ3_STATIC     \n$(B)/q3static/cmd.o : $(CMDIR)/cmd.c; $(DO_CC) -DQ3_STATIC                   \n$(B)/q3static/common.o : $(CMDIR)/common.c; $(DO_CC) -DQ3_STATIC               \n$(B)/q3static/cvar.o : $(CMDIR)/cvar.c; $(DO_CC) -DQ3_STATIC                \n$(B)/q3static/files.o : $(CMDIR)/files.c; $(DO_CC) -DQ3_STATIC              \n$(B)/q3static/md4.o : $(CMDIR)/md4.c; $(DO_CC) -DQ3_STATIC                   \n$(B)/q3static/msg.o : $(CMDIR)/msg.c; $(DO_CC) -DQ3_STATIC                    \n$(B)/q3static/net_chan.o : $(CMDIR)/net_chan.c; $(DO_CC) -DQ3_STATIC\n\n$(B)/q3static/be_aas_bspq3.o : $(BLIBDIR)/be_aas_bspq3.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/be_aas_cluster.o : $(BLIBDIR)/be_aas_cluster.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/be_aas_debug.o : $(BLIBDIR)/be_aas_debug.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/be_aas_entity.o : $(BLIBDIR)/be_aas_entity.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/be_aas_file.o : $(BLIBDIR)/be_aas_file.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/be_aas_main.o : $(BLIBDIR)/be_aas_main.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/be_aas_move.o : $(BLIBDIR)/be_aas_move.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/be_aas_optimize.o : $(BLIBDIR)/be_aas_optimize.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/be_aas_reach.o : $(BLIBDIR)/be_aas_reach.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/be_aas_route.o : $(BLIBDIR)/be_aas_route.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/be_aas_routealt.o : $(BLIBDIR)/be_aas_routealt.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/be_aas_sample.o : $(BLIBDIR)/be_aas_sample.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/be_ai_char.o : $(BLIBDIR)/be_ai_char.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/be_ai_chat.o : $(BLIBDIR)/be_ai_chat.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/be_ai_gen.o : $(BLIBDIR)/be_ai_gen.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/be_ai_goal.o : $(BLIBDIR)/be_ai_goal.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/be_ai_move.o : $(BLIBDIR)/be_ai_move.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/be_ai_weap.o : $(BLIBDIR)/be_ai_weap.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/be_ai_weight.o : $(BLIBDIR)/be_ai_weight.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/be_ea.o : $(BLIBDIR)/be_ea.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/be_interface.o : $(BLIBDIR)/be_interface.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/l_crc.o : $(BLIBDIR)/l_crc.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/l_libvar.o : $(BLIBDIR)/l_libvar.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/l_log.o : $(BLIBDIR)/l_log.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/l_memory.o : $(BLIBDIR)/l_memory.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/l_precomp.o : $(BLIBDIR)/l_precomp.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/l_script.o : $(BLIBDIR)/l_script.c; $(DO_BOT_CC) -DQ3_STATIC \n$(B)/q3static/l_struct.o : $(BLIBDIR)/l_struct.c; $(DO_BOT_CC) -DQ3_STATIC \n\n$(B)/q3static/jcapimin.o : $(JPDIR)/jcapimin.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jchuff.o : $(JPDIR)/jchuff.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jcinit.o : $(JPDIR)/jcinit.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jccoefct.o : $(JPDIR)/jccoefct.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jccolor.o : $(JPDIR)/jccolor.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jfdctflt.o : $(JPDIR)/jfdctflt.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jcdctmgr.o : $(JPDIR)/jcdctmgr.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jcmainct.o : $(JPDIR)/jcmainct.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jcmarker.o : $(JPDIR)/jcmarker.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jcmaster.o : $(JPDIR)/jcmaster.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jcomapi.o : $(JPDIR)/jcomapi.c; $(DO_CC) -DQ3_STATIC\n$(B)/q3static/jcparam.o : $(JPDIR)/jcparam.c;  $(DO_CC) -DQ3_STATIC\n$(B)/q3static/jcprepct.o : $(JPDIR)/jcprepct.c; $(DO_CC) -DQ3_STATIC\n$(B)/q3static/jcsample.o : $(JPDIR)/jcsample.c; $(DO_CC) -DQ3_STATIC \n\n$(B)/q3static/jdapimin.o : $(JPDIR)/jdapimin.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jdapistd.o : $(JPDIR)/jdapistd.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jdatasrc.o : $(JPDIR)/jdatasrc.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jdcoefct.o : $(JPDIR)/jdcoefct.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jdcolor.o : $(JPDIR)/jdcolor.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jcphuff.o : $(JPDIR)/jcphuff.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jddctmgr.o : $(JPDIR)/jddctmgr.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jdhuff.o : $(JPDIR)/jdhuff.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jdinput.o : $(JPDIR)/jdinput.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jdmainct.o : $(JPDIR)/jdmainct.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jdmarker.o : $(JPDIR)/jdmarker.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jdmaster.o : $(JPDIR)/jdmaster.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jdpostct.o : $(JPDIR)/jdpostct.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jdsample.o : $(JPDIR)/jdsample.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jdtrans.o : $(JPDIR)/jdtrans.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jerror.o : $(JPDIR)/jerror.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jidctflt.o : $(JPDIR)/jidctflt.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jmemmgr.o : $(JPDIR)/jmemmgr.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jmemnobs.o : $(JPDIR)/jmemnobs.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/jutils.o : $(JPDIR)/jutils.c; $(DO_CC) -DQ3_STATIC \n\n$(B)/q3static/tr_bsp.o : $(RDIR)/tr_bsp.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_animation.o : $(RDIR)/tr_animation.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_backend.o : $(RDIR)/tr_backend.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_cmds.o : $(RDIR)/tr_cmds.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_curve.o : $(RDIR)/tr_curve.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_flares.o : $(RDIR)/tr_flares.c; $(DO_CC) -DQ3_STATIC\n$(B)/q3static/tr_font.o : $(RDIR)/tr_font.c; $(DO_CC) -DQ3_STATIC  \n$(B)/q3static/tr_image.o : $(RDIR)/tr_image.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_init.o : $(RDIR)/tr_init.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_light.o : $(RDIR)/tr_light.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_main.o : $(RDIR)/tr_main.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_marks.o : $(RDIR)/tr_marks.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_mesh.o : $(RDIR)/tr_mesh.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_model.o : $(RDIR)/tr_model.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_noise.o : $(RDIR)/tr_noise.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_scene.o : $(RDIR)/tr_scene.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_shade.o : $(RDIR)/tr_shade.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_shader.o : $(RDIR)/tr_shader.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_shade_calc.o : $(RDIR)/tr_shade_calc.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_shadows.o : $(RDIR)/tr_shadows.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_sky.o : $(RDIR)/tr_sky.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_smp.o : $(RDIR)/tr_smp.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_stripify.o : $(RDIR)/tr_stripify.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_subdivide.o : $(RDIR)/tr_subdivide.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_surface.o : $(RDIR)/tr_surface.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/tr_world.o : $(RDIR)/tr_world.c; $(DO_CC) -DQ3_STATIC \n\n$(B)/q3static/unix_qgl.o : $(UDIR)/unix_qgl.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/unix_main.o : $(UDIR)/unix_main.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/unix_net.o : $(UDIR)/unix_net.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/unix_shared.o : $(UDIR)/unix_shared.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/linux_glimp.o : $(UDIR)/linux_glimp.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/linux_joystick.o : $(UDIR)/linux_joystick.c; $(DO_CC) -DQ3_STATIC  \n$(B)/q3static/linux_qgl.o : $(UDIR)/linux_qgl.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/linux_input.o : $(UDIR)/linux_input.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/linux_snd.o : $(UDIR)/linux_snd.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/snd_mixa.o : $(UDIR)/snd_mixa.s; $(DO_AS) \n$(B)/q3static/matha.o : $(UDIR)/matha.s; $(DO_AS) \n$(B)/q3static/unzip.o : $(CMDIR)/unzip.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/vm.o : $(CMDIR)/vm.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/vm_interpreted.o : $(CMDIR)/vm_interpreted.c; $(DO_CC) -DQ3_STATIC \n\nifeq ($(ARCH),i386)\n  $(B)/q3static/vm_x86.o : $(CMDIR)/vm_x86.c; $(DO_CC) -DQ3_STATIC\nendif\n\nifeq ($(ARCH),ppc)\nifeq ($(DLL_ONLY),false)\n$(B)/q3static/vm_ppc.o : $(CMDIR)/vm_ppc.c; $(DO_CC) -DQ3_STATIC\nendif\nendif\n\n$(B)/q3static/ahoptim.o  : $(FTDIR)/ahoptim.c;   $(DO_CC) -DQ3_STATIC\n$(B)/q3static/autohint.o : $(FTDIR)/autohint.c;  $(DO_CC) -DQ3_STATIC\n$(B)/q3static/ftbase.o   : $(FTDIR)/ftbase.c;    $(DO_CC) -DQ3_STATIC\n$(B)/q3static/ftdebug.o  : $(FTDIR)/ftdebug.c;   $(DO_CC) -DQ3_STATIC\n$(B)/q3static/ftglyph.o  : $(FTDIR)/ftglyph.c;   $(DO_CC) -DQ3_STATIC\n$(B)/q3static/ftinit.o   : $(FTDIR)/ftinit.c;    $(DO_CC) -DQ3_STATIC\n$(B)/q3static/ftmm.o     : $(FTDIR)/ftmm.c;      $(DO_CC) -DQ3_STATIC\n$(B)/q3static/ftsystem.o : $(FTDIR)/ftsystem.c;  $(DO_CC) -DQ3_STATIC\n$(B)/q3static/raster1.o  : $(FTDIR)/raster1.c;   $(DO_CC) -DQ3_STATIC -DFT_FLAT_COMPILE\n$(B)/q3static/sfnt.o     : $(FTDIR)/sfnt.c;      $(DO_CC) -DQ3_STATIC\n$(B)/q3static/sfobjs.o   : $(FTDIR)/sfobjs.c;    $(DO_CC) -DQ3_STATIC\n$(B)/q3static/smooth.o   : $(FTDIR)/smooth.c;    $(DO_CC) -DQ3_STATIC -DFT_FLAT_COMPILE\n$(B)/q3static/truetype.o : $(FTDIR)/truetype.c;  $(DO_CC) -DQ3_STATIC\n\n## add BASEQ3 CGAME\nQ3SOBJ += \\\n\t$(B)/q3static/cg_consolecmds.o \\\n\t$(B)/q3static/cg_draw.o \\\n\t$(B)/q3static/cg_drawtools.o \\\n\t$(B)/q3static/cg_effects.o \\\n\t$(B)/q3static/cg_ents.o \\\n\t$(B)/q3static/cg_event.o \\\n\t$(B)/q3static/cg_info.o \\\n\t$(B)/q3static/cg_localents.o \\\n\t$(B)/q3static/cg_main.o \\\n\t$(B)/q3static/cg_marks.o \\\n\t$(B)/q3static/cg_players.o \\\n\t$(B)/q3static/cg_playerstate.o \\\n\t$(B)/q3static/cg_predict.o \\\n\t$(B)/q3static/cg_scoreboard.o \\\n\t$(B)/q3static/cg_servercmds.o \\\n\t$(B)/q3static/cg_snapshot.o \\\n\t$(B)/q3static/cg_syscalls.o \\\n\t$(B)/q3static/cg_view.o \\\n\t$(B)/q3static/cg_weapons.o\n\n$(B)/q3static/cg_consolecmds.o : $(CGDIR)/cg_consolecmds.c; $(DO_CC) -DQ3_STATIC       \n$(B)/q3static/cg_draw.o : $(CGDIR)/cg_draw.c; $(DO_CC) -DQ3_STATIC             \n$(B)/q3static/cg_drawtools.o : $(CGDIR)/cg_drawtools.c; $(DO_CC) -DQ3_STATIC        \n$(B)/q3static/cg_effects.o : $(CGDIR)/cg_effects.c; $(DO_CC) -DQ3_STATIC           \n$(B)/q3static/cg_ents.o : $(CGDIR)/cg_ents.c; $(DO_CC) -DQ3_STATIC               \n$(B)/q3static/cg_event.o : $(CGDIR)/cg_event.c; $(DO_CC) -DQ3_STATIC            \n$(B)/q3static/cg_info.o : $(CGDIR)/cg_info.c; $(DO_CC) -DQ3_STATIC               \n$(B)/q3static/cg_localents.o : $(CGDIR)/cg_localents.c; $(DO_CC) -DQ3_STATIC           \n$(B)/q3static/cg_main.o : $(CGDIR)/cg_main.c; $(DO_CC) -DQ3_STATIC                   \n$(B)/q3static/cg_marks.o : $(CGDIR)/cg_marks.c; $(DO_CC) -DQ3_STATIC                 \n$(B)/q3static/cg_players.o : $(CGDIR)/cg_players.c; $(DO_CC) -DQ3_STATIC             \n$(B)/q3static/cg_playerstate.o : $(CGDIR)/cg_playerstate.c; $(DO_CC) -DQ3_STATIC        \n$(B)/q3static/cg_predict.o : $(CGDIR)/cg_predict.c; $(DO_CC) -DQ3_STATIC        \n$(B)/q3static/cg_scoreboard.o : $(CGDIR)/cg_scoreboard.c; $(DO_CC) -DQ3_STATIC        \n$(B)/q3static/cg_servercmds.o : $(CGDIR)/cg_servercmds.c; $(DO_CC) -DQ3_STATIC        \n$(B)/q3static/cg_snapshot.o : $(CGDIR)/cg_snapshot.c; $(DO_CC) -DQ3_STATIC             \n$(B)/q3static/cg_syscalls.o : $(CGDIR)/cg_syscalls.c; $(DO_CC) -DQ3_STATIC        \n$(B)/q3static/cg_view.o : $(CGDIR)/cg_view.c; $(DO_CC) -DQ3_STATIC                     \n$(B)/q3static/cg_weapons.o : $(CGDIR)/cg_weapons.c; $(DO_CC) -DQ3_STATIC \n\n## add BASEQ3 GAME\nQ3SOBJ += \\\n\t$(B)/q3static/ai_chat.o \\\n\t$(B)/q3static/ai_cmd.o \\\n\t$(B)/q3static/ai_dmnet.o \\\n\t$(B)/q3static/ai_dmq3.o \\\n\t$(B)/q3static/ai_main.o \\\n\t$(B)/q3static/ai_team.o \\\n\t$(B)/q3static/ai_vcmd.o \\\n\t$(B)/q3static/g_active.o \\\n\t$(B)/q3static/g_arenas.o \\\n\t$(B)/q3static/g_bot.o \\\n\t$(B)/q3static/g_client.o \\\n\t$(B)/q3static/g_cmds.o \\\n\t$(B)/q3static/g_combat.o \\\n\t$(B)/q3static/g_items.o \\\n\t$(B)/q3static/g_main.o \\\n\t$(B)/q3static/g_mem.o \\\n\t$(B)/q3static/g_misc.o \\\n\t$(B)/q3static/g_missile.o \\\n\t$(B)/q3static/g_mover.o \\\n\t$(B)/q3static/g_session.o \\\n\t$(B)/q3static/g_spawn.o \\\n\t$(B)/q3static/g_svcmds.o \\\n\t$(B)/q3static/g_target.o \\\n\t$(B)/q3static/g_team.o \\\n\t$(B)/q3static/g_trigger.o \\\n\t$(B)/q3static/g_utils.o \\\n\t$(B)/q3static/g_weapon.o \\\n\t\\\n\t$(B)/q3static/g_syscalls.o\n\n$(B)/q3static/ai_chat.o : $(GDIR)/ai_chat.c; $(DO_CC) -DQ3_STATIC     \n$(B)/q3static/ai_cmd.o : $(GDIR)/ai_cmd.c; $(DO_CC) -DQ3_STATIC       \n$(B)/q3static/ai_dmnet.o : $(GDIR)/ai_dmnet.c; $(DO_CC) -DQ3_STATIC   \n$(B)/q3static/ai_dmq3.o : $(GDIR)/ai_dmq3.c; $(DO_CC) -DQ3_STATIC       \n$(B)/q3static/ai_main.o : $(GDIR)/ai_main.c; $(DO_CC) -DQ3_STATIC      \n$(B)/q3static/ai_team.o : $(GDIR)/ai_team.c; $(DO_CC) -DQ3_STATIC     \n$(B)/q3static/ai_vcmd.o : $(GDIR)/ai_vcmd.c; $(DO_CC) -DQ3_STATIC     \n$(B)/q3static/g_active.o : $(GDIR)/g_active.c; $(DO_CC) -DQ3_STATIC       \n$(B)/q3static/g_arenas.o : $(GDIR)/g_arenas.c; $(DO_CC) -DQ3_STATIC       \n$(B)/q3static/g_bot.o : $(GDIR)/g_bot.c; $(DO_CC) -DQ3_STATIC            \n$(B)/q3static/g_client.o : $(GDIR)/g_client.c; $(DO_CC) -DQ3_STATIC      \n$(B)/q3static/g_cmds.o : $(GDIR)/g_cmds.c; $(DO_CC) -DQ3_STATIC          \n$(B)/q3static/g_combat.o : $(GDIR)/g_combat.c; $(DO_CC) -DQ3_STATIC       \n$(B)/q3static/g_items.o : $(GDIR)/g_items.c; $(DO_CC) -DQ3_STATIC          \n$(B)/q3static/g_main.o : $(GDIR)/g_main.c; $(DO_CC) -DQ3_STATIC            \n$(B)/q3static/g_mem.o : $(GDIR)/g_mem.c; $(DO_CC) -DQ3_STATIC               \n$(B)/q3static/g_misc.o : $(GDIR)/g_misc.c; $(DO_CC) -DQ3_STATIC             \n$(B)/q3static/g_missile.o : $(GDIR)/g_missile.c; $(DO_CC) -DQ3_STATIC        \n$(B)/q3static/g_mover.o : $(GDIR)/g_mover.c; $(DO_CC) -DQ3_STATIC          \n$(B)/q3static/g_session.o : $(GDIR)/g_session.c; $(DO_CC) -DQ3_STATIC       \n$(B)/q3static/g_spawn.o : $(GDIR)/g_spawn.c; $(DO_CC) -DQ3_STATIC          \n$(B)/q3static/g_svcmds.o : $(GDIR)/g_svcmds.c; $(DO_CC) -DQ3_STATIC         \n$(B)/q3static/g_syscalls.o : $(GDIR)/g_syscalls.c; $(DO_CC) -DQ3_STATIC    \n$(B)/q3static/g_target.o : $(GDIR)/g_target.c; $(DO_CC) -DQ3_STATIC        \n$(B)/q3static/g_team.o : $(GDIR)/g_team.c; $(DO_CC) -DQ3_STATIC           \n$(B)/q3static/g_trigger.o : $(GDIR)/g_trigger.c; $(DO_CC) -DQ3_STATIC       \n$(B)/q3static/g_utils.o : $(GDIR)/g_utils.c; $(DO_CC) -DQ3_STATIC          \n$(B)/q3static/g_weapon.o : $(GDIR)/g_weapon.c; $(DO_CC) -DQ3_STATIC             \n\n## add BASEQ3 UI\nQ3SOBJ += \\\n        $(B)/q3static/ui_addbots.o \\\n        $(B)/q3static/ui_atoms.o \\\n        $(B)/q3static/ui_cdkey.o \\\n        $(B)/q3static/ui_cinematics.o \\\n        $(B)/q3static/ui_confirm.o \\\n        $(B)/q3static/ui_connect.o \\\n        $(B)/q3static/ui_controls2.o \\\n        $(B)/q3static/ui_credits.o \\\n        $(B)/q3static/ui_demo2.o \\\n        $(B)/q3static/ui_display.o \\\n        $(B)/q3static/ui_gameinfo.o \\\n        $(B)/q3static/ui_ingame.o \\\n        $(B)/q3static/ui_loadconfig.o \\\n        $(B)/q3static/ui_main.o \\\n        $(B)/q3static/ui_menu.o \\\n        $(B)/q3static/ui_mfield.o \\\n        $(B)/q3static/ui_mods.o \\\n        $(B)/q3static/ui_network.o \\\n        $(B)/q3static/ui_options.o \\\n        $(B)/q3static/ui_playermodel.o \\\n        $(B)/q3static/ui_players.o \\\n        $(B)/q3static/ui_playersettings.o \\\n        $(B)/q3static/ui_preferences.o \\\n        $(B)/q3static/ui_qmenu.o \\\n        $(B)/q3static/ui_removebots.o \\\n        $(B)/q3static/ui_saveconfig.o \\\n        $(B)/q3static/ui_serverinfo.o \\\n        $(B)/q3static/ui_servers2.o \\\n        $(B)/q3static/ui_setup.o \\\n        $(B)/q3static/ui_sound.o \\\n        $(B)/q3static/ui_sparena.o \\\n        $(B)/q3static/ui_specifyserver.o \\\n        $(B)/q3static/ui_splevel.o \\\n        $(B)/q3static/ui_sppostgame.o \\\n        $(B)/q3static/ui_spskill.o \\\n        $(B)/q3static/ui_startserver.o \\\n        $(B)/q3static/ui_team.o \\\n        $(B)/q3static/ui_teamorders.o \\\n        $(B)/q3static/ui_video.o \\\n\t\\\n\t$(B)/q3static/ui_syscalls.o\n\n$(B)/q3static/ui_addbots.o : $(Q3UIDIR)/ui_addbots.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_atoms.o : $(Q3UIDIR)/ui_atoms.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_cinematics.o : $(Q3UIDIR)/ui_cinematics.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_cdkey.o : $(Q3UIDIR)/ui_cdkey.c; $(DO_CC) -DQ3_STATIC\n$(B)/q3static/ui_confirm.o : $(Q3UIDIR)/ui_confirm.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_connect.o : $(Q3UIDIR)/ui_connect.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_controls2.o : $(Q3UIDIR)/ui_controls2.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_credits.o : $(Q3UIDIR)/ui_credits.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_demo2.o : $(Q3UIDIR)/ui_demo2.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_display.o : $(Q3UIDIR)/ui_display.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_gameinfo.o : $(Q3UIDIR)/ui_gameinfo.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_ingame.o : $(Q3UIDIR)/ui_ingame.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_loadconfig.o : $(Q3UIDIR)/ui_loadconfig.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_main.o : $(Q3UIDIR)/ui_main.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_menu.o : $(Q3UIDIR)/ui_menu.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_mfield.o : $(Q3UIDIR)/ui_mfield.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_mods.o : $(Q3UIDIR)/ui_mods.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_network.o : $(Q3UIDIR)/ui_network.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_options.o : $(Q3UIDIR)/ui_options.c; $(DO_CC) -DQ3_STATIC\n$(B)/q3static/ui_playermodel.o : $(Q3UIDIR)/ui_playermodel.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_players.o : $(Q3UIDIR)/ui_players.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_playersettings.o : $(Q3UIDIR)/ui_playersettings.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_preferences.o : $(Q3UIDIR)/ui_preferences.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_qmenu.o : $(Q3UIDIR)/ui_qmenu.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_quit.o : $(Q3UIDIR)/ui_quit.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_removebots.o : $(Q3UIDIR)/ui_removebots.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_saveconfig.o : $(Q3UIDIR)/ui_saveconfig.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_serverinfo.o : $(Q3UIDIR)/ui_serverinfo.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_servers2.o : $(Q3UIDIR)/ui_servers2.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_setup.o : $(Q3UIDIR)/ui_setup.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_sound.o : $(Q3UIDIR)/ui_sound.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_sparena.o : $(Q3UIDIR)/ui_sparena.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_specifyserver.o : $(Q3UIDIR)/ui_specifyserver.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_splevel.o : $(Q3UIDIR)/ui_splevel.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_sppostgame.o : $(Q3UIDIR)/ui_sppostgame.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_spskill.o : $(Q3UIDIR)/ui_spskill.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_startserver.o : $(Q3UIDIR)/ui_startserver.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_team.o : $(Q3UIDIR)/ui_team.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_teamorders.o : $(Q3UIDIR)/ui_teamorders.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_syscalls.o : $(Q3UIDIR)/ui_syscalls.c; $(DO_CC) -DQ3_STATIC \n$(B)/q3static/ui_video.o : $(Q3UIDIR)/ui_video.c; $(DO_CC) -DQ3_STATIC \n\n\n## add shared files\nQ3SOBJ += \\\n\t$(B)/q3static/bg_misc.o \\\n\t$(B)/q3static/bg_pmove.o \\\n\t$(B)/q3static/bg_slidemove.o \\\n        $(B)/q3static/q_math.o \\\n        $(B)/q3static/q_shared.o\n\n## shared files\n$(B)/q3static/q_math.o : $(GDIR)/q_math.c; $(DO_CC) -DQ3_STATIC               \n$(B)/q3static/q_shared.o : $(GDIR)/q_shared.c; $(DO_CC) -DQ3_STATIC      \n$(B)/q3static/bg_misc.o : $(GDIR)/bg_misc.c; $(DO_CC) -DQ3_STATIC\n$(B)/q3static/bg_pmove.o : $(GDIR)/bg_pmove.c; $(DO_CC) -DQ3_STATIC  \n$(B)/q3static/bg_slidemove.o : $(GDIR)/bg_slidemove.c; $(DO_CC) -DQ3_STATIC    \n\n\n\n$(B)/$(PLATFORM)q3static : $(Q3SOBJ) \n\t$(CC) $(CFLAGS) -o $@ $(Q3SOBJ)  $(GLLDFLAGS) $(LDFLAGS) \n\n\n#############################################################################\n# RPM\n#############################################################################\n\nTMPDIR=/var/tmp\nTARDIR=$(TMPDIR)/$(BUILD_NAME)\nTARFILE = $(BUILD_NAME)-$(VERSION)-$(RPM_RELEASE).$(ARCH).tar\n\ntar:\n\tif [ ! -d archives ];then mkdir archives;chmod 755 archives;fi\n\t$(MAKE) copyfiles COPYDIR=$(TARDIR)\n\tcd $(TARDIR); tar cvf $(TARFILE) * && gzip -9 $(TARFILE)\n\tmv $(TARDIR)/$(TARFILE).gz archives/.\n\trm -rf $(TARDIR)\n\n# Make RPMs.  You need to be root to make this work\nRPMROOT=/usr/src/redhat\nRPM = rpm\nRPMFLAGS = -bb\nINSTALLDIR = /usr/local/games/$(BUILD_NAME)\nRPMDIR = $(TMPDIR)/$(BUILD_NAME)-$(VERSION)\nDESTDIR= $(RPMDIR)/$(INSTALLDIR)\n\nrpm: $(BUILD_NAME).spec\n\ttouch $(RPMROOT)/SOURCES/$(BUILD_NAME)-$(VERSION).tar.gz\n\tif [ ! -d archives ];then mkdir archives;fi\n\t$(MAKE) copyfiles COPYDIR=$(DESTDIR)\n\tcp $(UDIR)/quake3.gif $(RPMROOT)/SOURCES/.\n\tcp $(BUILD_NAME).spec $(RPMROOT)/SPECS/.\n\tcd $(RPMROOT)/SPECS; $(RPM) $(RPMFLAGS) $(BUILD_NAME).spec\n\trm -rf $(RPMDIR)\n\tmv $(RPMROOT)/RPMS/$(RPMARCH)/$(BUILD_NAME)-$(VERSION)-$(RPM_RELEASE).$(RPMARCH).rpm archives/$(BUILD_NAME)-$(VERSION)-$(RPM_RELEASE).$(RPMARCH).rpm \n\ncopyfiles:\n\t-mkdirhier $(COPYDIR)\n\tcp $(BR)/linuxquake3 $(COPYDIR)/quake3.x86\n\tstrip $(COPYDIR)/quake3.x86\n\tchmod 755 $(COPYDIR)/quake3.x86\n\tcp $(BR)/linuxq3ded $(COPYDIR)/q3ded\n\tstrip $(COPYDIR)/q3ded\n\tchmod 755 $(COPYDIR)/q3ded\n\tcp $(BDIR)/libMesaVoodooGL.so.3.2 $(COPYDIR)/.\n\tchmod 755 $(COPYDIR)/libMesaVoodooGL.so.3.2\n\t( cd $(COPYDIR); ln -s libMesaVoodooGL.so.3.2 libMesaVoodooGL.so )\n\tcp $(BDIR)/Quake_III_Arena_FAQ.html $(COPYDIR)/.\n\tchmod 644 $(COPYDIR)/Quake_III_Arena_FAQ.html\n\tmkdir $(COPYDIR)/baseq3\n\tcp $(BASEQ3_DIR)/pak2.pk3 $(COPYDIR)/baseq3/.\n\tchmod 644 $(COPYDIR)/baseq3/pak2.pk3\n\n$(BUILD_NAME).spec : $(UDIR)/$(BUILD_NAME).spec.sh Makefile\n\tsh $< $(VERSION) $(RPM_RELEASE) $(ARCH) $(INSTALLDIR) > $@\n\n#############################################################################\n# MISC\n#############################################################################\n\n# TTimo: FIXME: doesn't clean the binary and .so\n\nclean:clean-debug clean-release\n\nclean2: clean-bins\n\trm -f $(Q3OBJ) $(Q3POBJ) $(Q3POBJ_SMP) $(Q3DOBJ) $(MPGOBJ) $(Q3GOBJ) $(Q3CGOBJ) $(MPCGOBJ) $(Q3UIOBJ) $(MPUIOBJ)\n\trm -f $(CGDIR)/vm/*.asm\n\trm -f $(GDIR)/vm/*.asm\n\trm -f $(UIDIR)/vm/*.asm\n\trm -f $(Q3UIDIR)/vm/*.asm\n\n# TTimo: linuxq3ded linuxquake3 linuxquake3-smp .. hardcoded the names .. maybe not such a good thing\n# FIXME: also, removing the *.so is crappy .. I just want to avoid rm -rf debugi386-glibc to save the symlinks to pk3's for testing\nclean-bins:\n\tif [ -d $(B) ];then (find $(B) -name '*.so' -exec rm {} \\;)fi\n\trm -f $(B)/linuxq3ded\n\trm -f $(B)/linuxquake3\n\trm -f $(B)/linuxquake3-smp\n\trm -f $(B)/baseq3/vm/cgame.qvm\n\trm -f $(B)/baseq3/vm/ui.qvm\n\trm -f $(B)/baseq3/vm/qagame.qvm\n\trm -f $(B)/missionpack/vm/cgame.qvm\n\trm -f $(B)/missionpack/vm/qagame.qvm\n\trm -f $(B)/missionpack/vm/ui.qvm\n\nclean-debug:\n\t$(MAKE) clean2 B=$(BD) CFLAGS=\"$(DEBUG_CFLAGS)\"\n\nclean-release:\n\t$(MAKE) clean2 B=$(BR) CFLAGS=\"$(DEBUG_CFLAGS)\"\n\n# TTimo: for the setups it's easier to shell out to a script\n\nsetup: release\n\t./build_setup.sh $(VERSION)\n\n"
  },
  {
    "path": "code/unix/Makefile.Game",
    "content": "#\n# Quake3 Unix Game Makefile\n#\n# GNU Make required\n#\n\n###\n### These paths are where you probably want to change things\n###\n\n#The main Quake3 directory\nBDIR=..\n\n#This is the game dir\nGAMEDIR=baseq3\n\n#Where the source is, assumed to be same directory as this Makefile\nSRCDIR=.\n\n#Location of binaries\nBINDIR=../bin\nLCC=$(BINDIR)/lcc # -lccdir=$(BINDIR)/\nQ3ASM=$(BINDIR)/q3asm\n\n\n#############################################################################\n##\n## You shouldn't have to touch anything below here\n##\n#############################################################################\n\nGDIR=$(SRCDIR)/game\nCGDIR=$(SRCDIR)/cgame\nUIDIR=$(SRCDIR)/ui\n\nLCCFLAGS=-DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\\cgame -I..\\game -I..\\ui\n\nDO_LCC=$(LCC) $(LCCFLAGS) -o $@ -c $<\n\nTARGETS=\\\n\t$(BDIR)/$(GAMEDIR)/vm/cgame.qvm \\\n\t$(BDIR)/$(GAMEDIR)/vm/qagame.qvm \\\n\t$(BDIR)/$(GAMEDIR)/vm/ui.qvm\n\ndefault: makedir $(TARGETS)\n\nmakedir:\n\t@-mkdir $(GDIR)/vm\n\t@-mkdir $(CGDIR)/vm\n\t@-mkdir $(UIDIR)/vm\n\n#############################################################################\n# GAME VM\n#############################################################################\n\n##NOTE:  g_main must be first.  Control passes to first function in the vm\n\nGVMASM = \\\n\t$(GDIR)/vm/g_main.asm \\\n\t$(GDIR)/vm/bg_misc.asm \\\n\t$(GDIR)/vm/bg_lib.asm \\\n\t$(GDIR)/vm/bg_pmove.asm \\\n\t$(GDIR)/vm/bg_slidemove.asm \\\n\t$(GDIR)/vm/q_math.asm \\\n\t$(GDIR)/vm/q_shared.asm \\\n\t$(GDIR)/vm/ai_dmnet.asm \\\n\t$(GDIR)/vm/ai_dmq3.asm \\\n\t$(GDIR)/vm/ai_team.asm \\\n\t$(GDIR)/vm/ai_main.asm \\\n\t$(GDIR)/vm/ai_chat.asm \\\n\t$(GDIR)/vm/ai_cmd.asm \\\n\t$(GDIR)/vm/g_active.asm \\\n\t$(GDIR)/vm/g_arenas.asm \\\n\t$(GDIR)/vm/g_bot.asm \\\n\t$(GDIR)/vm/g_client.asm \\\n\t$(GDIR)/vm/g_cmds.asm \\\n\t$(GDIR)/vm/g_combat.asm \\\n\t$(GDIR)/vm/g_items.asm \\\n\t$(GDIR)/vm/g_mem.asm \\\n\t$(GDIR)/vm/g_misc.asm \\\n\t$(GDIR)/vm/g_missile.asm \\\n\t$(GDIR)/vm/g_mover.asm \\\n\t$(GDIR)/vm/g_session.asm \\\n\t$(GDIR)/vm/g_spawn.asm \\\n\t$(GDIR)/vm/g_svcmds.asm \\\n\t$(GDIR)/vm/g_target.asm \\\n\t$(GDIR)/vm/g_team.asm \\\n\t$(GDIR)/vm/g_trigger.asm \\\n\t$(GDIR)/vm/g_utils.asm \\\n\t$(GDIR)/vm/g_weapon.asm\n\n$(BDIR)/$(GAMEDIR)/vm/qagame.qvm : $(GVMASM)\n\t$(Q3ASM) -o $@ $(GVMASM) $(SRCDIR)/game/g_syscalls.asm\n\n$(GDIR)/vm/ai_chat.asm : $(GDIR)/ai_chat.c; $(DO_LCC) \n$(GDIR)/vm/ai_cmd.asm : $(GDIR)/ai_cmd.c; $(DO_LCC) \n$(GDIR)/vm/ai_dmnet.asm : $(GDIR)/ai_dmnet.c; $(DO_LCC) \n$(GDIR)/vm/ai_dmq3.asm : $(GDIR)/ai_dmq3.c; $(DO_LCC) \n$(GDIR)/vm/ai_main.asm : $(GDIR)/ai_main.c; $(DO_LCC) \n$(GDIR)/vm/ai_team.asm : $(GDIR)/ai_team.c; $(DO_LCC) \n$(GDIR)/vm/bg_lib.asm : $(GDIR)/bg_lib.c; $(DO_LCC) \n$(GDIR)/vm/bg_misc.asm : $(GDIR)/bg_misc.c; $(DO_LCC) \n$(GDIR)/vm/bg_pmove.asm : $(GDIR)/bg_pmove.c; $(DO_LCC) \n$(GDIR)/vm/bg_slidemove.asm : $(GDIR)/bg_slidemove.c; $(DO_LCC) \n$(GDIR)/vm/g_active.asm : $(GDIR)/g_active.c; $(DO_LCC) \n$(GDIR)/vm/g_arenas.asm : $(GDIR)/g_arenas.c; $(DO_LCC) \n$(GDIR)/vm/g_bot.asm : $(GDIR)/g_bot.c; $(DO_LCC) \n$(GDIR)/vm/g_client.asm : $(GDIR)/g_client.c; $(DO_LCC) \n$(GDIR)/vm/g_cmds.asm : $(GDIR)/g_cmds.c; $(DO_LCC) \n$(GDIR)/vm/g_combat.asm : $(GDIR)/g_combat.c; $(DO_LCC) \n$(GDIR)/vm/g_items.asm : $(GDIR)/g_items.c; $(DO_LCC) \n$(GDIR)/vm/g_main.asm : $(GDIR)/g_main.c; $(DO_LCC) \n$(GDIR)/vm/g_mem.asm : $(GDIR)/g_mem.c; $(DO_LCC) \n$(GDIR)/vm/g_misc.asm : $(GDIR)/g_misc.c; $(DO_LCC) \n$(GDIR)/vm/g_missile.asm : $(GDIR)/g_missile.c; $(DO_LCC) \n$(GDIR)/vm/g_mover.asm : $(GDIR)/g_mover.c; $(DO_LCC) \n$(GDIR)/vm/g_session.asm : $(GDIR)/g_session.c; $(DO_LCC) \n$(GDIR)/vm/g_spawn.asm : $(GDIR)/g_spawn.c; $(DO_LCC) \n$(GDIR)/vm/g_svcmds.asm : $(GDIR)/g_svcmds.c; $(DO_LCC) \n$(GDIR)/vm/g_target.asm : $(GDIR)/g_target.c; $(DO_LCC) \n$(GDIR)/vm/g_team.asm : $(GDIR)/g_team.c; $(DO_LCC) \n$(GDIR)/vm/g_trigger.asm : $(GDIR)/g_trigger.c; $(DO_LCC) \n$(GDIR)/vm/g_utils.asm : $(GDIR)/g_utils.c; $(DO_LCC) \n$(GDIR)/vm/g_weapon.asm : $(GDIR)/g_weapon.c; $(DO_LCC) \n$(GDIR)/vm/q_math.asm : $(GDIR)/q_math.c; $(DO_LCC) \n$(GDIR)/vm/q_shared.asm : $(GDIR)/q_shared.c; $(DO_LCC) \n\n$(BDIR)/$(GAMEDIR)/vm/cgame.qvm : \n\techo cgame.qvm disabled\n\n$(BDIR)/$(GAMEDIR)/vm/ui.qvm : \n\techo ui.qvm disabled\n\n#############################################################################\n# CGAME\n#############################################################################\n\nCGOBJ = \\\n\t$(SRCDIR)/cgame/bg_lib.o \\\n\t$(SRCDIR)/cgame/bg_misc.o \\\n\t$(SRCDIR)/cgame/bg_pmove.o \\\n\t$(SRCDIR)/cgame/bg_slidemove.o \\\n\t$(SRCDIR)/cgame/cg_consolecmds.o \\\n\t$(SRCDIR)/cgame/cg_draw.o \\\n\t$(SRCDIR)/cgame/cg_drawtools.o \\\n\t$(SRCDIR)/cgame/cg_effects.o \\\n\t$(SRCDIR)/cgame/cg_ents.o \\\n\t$(SRCDIR)/cgame/cg_event.o \\\n\t$(SRCDIR)/cgame/cg_info.o \\\n\t$(SRCDIR)/cgame/cg_localents.o \\\n\t$(SRCDIR)/cgame/cg_main.o \\\n\t$(SRCDIR)/cgame/cg_marks.o \\\n\t$(SRCDIR)/cgame/cg_players.o \\\n\t$(SRCDIR)/cgame/cg_playerstate.o \\\n\t$(SRCDIR)/cgame/cg_predict.o \\\n\t$(SRCDIR)/cgame/cg_scoreboard.o \\\n\t$(SRCDIR)/cgame/cg_servercmds.o \\\n\t$(SRCDIR)/cgame/cg_snapshot.o \\\n\t$(SRCDIR)/cgame/cg_view.o \\\n\t$(SRCDIR)/cgame/cg_weapons.o \\\n\t$(SRCDIR)/cgame/q_math.o \\\n\t$(SRCDIR)/cgame/q_shared.o\n\n$(SRCDIR)/cgame$(ARCH).$(SHLIBEXT) : $(CGOBJ)\n\t$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(CGOBJ)\n\n$(SRCDIR)/cgame/bg_lib.o : $(GDIR)/bg_lib.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/bg_misc.o : $(GDIR)/bg_misc.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/bg_pmove.o : $(GDIR)/bg_pmove.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/bg_slidemove.o : $(GDIR)/bg_slidemove.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/cg_consolecmds.o : $(CGDIR)/cg_consolecmds.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/cg_draw.o : $(CGDIR)/cg_draw.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/cg_drawtools.o : $(CGDIR)/cg_drawtools.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/cg_effects.o : $(CGDIR)/cg_effects.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/cg_ents.o : $(CGDIR)/cg_ents.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/cg_event.o : $(CGDIR)/cg_event.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/cg_info.o : $(CGDIR)/cg_info.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/cg_localents.o : $(CGDIR)/cg_localents.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/cg_main.o : $(CGDIR)/cg_main.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/cg_marks.o : $(CGDIR)/cg_marks.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/cg_players.o : $(CGDIR)/cg_players.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/cg_playerstate.o : $(CGDIR)/cg_playerstate.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/cg_predict.o : $(CGDIR)/cg_predict.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/cg_scoreboard.o : $(CGDIR)/cg_scoreboard.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/cg_servercmds.o : $(CGDIR)/cg_servercmds.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/cg_snapshot.o : $(CGDIR)/cg_snapshot.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/cg_view.o : $(CGDIR)/cg_view.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/cg_weapons.o : $(CGDIR)/cg_weapons.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/q_math.o : $(GDIR)/q_math.c; $(DO_SHLIB_CC) \n$(SRCDIR)/cgame/q_shared.o : $(GDIR)/q_shared.c; $(DO_SHLIB_CC) \n\n#############################################################################\n# UI\n#############################################################################\n\nUIOBJ = \\\n\t$(SRCDIR)/ui/bg_lib.o \\\n\t$(SRCDIR)/ui/bg_misc.o \\\n\t$(SRCDIR)/ui/ui_addbots.o \\\n\t$(SRCDIR)/ui/ui_atoms.o \\\n\t$(SRCDIR)/ui/ui_cinematics.o \\\n\t$(SRCDIR)/ui/ui_confirm.o \\\n\t$(SRCDIR)/ui/ui_connect.o \\\n\t$(SRCDIR)/ui/ui_controls2.o \\\n\t$(SRCDIR)/ui/ui_credits.o \\\n\t$(SRCDIR)/ui/ui_demo2.o \\\n\t$(SRCDIR)/ui/ui_display.o \\\n\t$(SRCDIR)/ui/ui_gameinfo.o \\\n\t$(SRCDIR)/ui/ui_ingame.o \\\n\t$(SRCDIR)/ui/ui_loadconfig.o \\\n\t$(SRCDIR)/ui/ui_main.o \\\n\t$(SRCDIR)/ui/ui_menu.o \\\n\t$(SRCDIR)/ui/ui_mfield.o \\\n\t$(SRCDIR)/ui/ui_network.o \\\n\t$(SRCDIR)/ui/ui_playermodel.o \\\n\t$(SRCDIR)/ui/ui_players.o \\\n\t$(SRCDIR)/ui/ui_playersettings.o \\\n\t$(SRCDIR)/ui/ui_preferences.o \\\n\t$(SRCDIR)/ui/ui_qmenu.o \\\n\t$(SRCDIR)/ui/ui_saveconfig.o \\\n\t$(SRCDIR)/ui/ui_serverinfo.o \\\n\t$(SRCDIR)/ui/ui_servers2.o \\\n\t$(SRCDIR)/ui/ui_setup.o \\\n\t$(SRCDIR)/ui/ui_sound.o \\\n\t$(SRCDIR)/ui/ui_sparena.o \\\n\t$(SRCDIR)/ui/ui_specifyserver.o \\\n\t$(SRCDIR)/ui/ui_splevel.o \\\n\t$(SRCDIR)/ui/ui_sppostgame.o \\\n\t$(SRCDIR)/ui/ui_spskill.o \\\n\t$(SRCDIR)/ui/ui_startserver.o \\\n\t$(SRCDIR)/ui/ui_team.o \\\n\t$(SRCDIR)/ui/ui_video.o \\\n\t\\\n\t$(SRCDIR)/ui/q_math.o \\\n\t$(SRCDIR)/ui/q_shared.o\n\n$(SRCDIR)/ui$(ARCH).$(SHLIBEXT) : $(UIOBJ)\n\t$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(UIOBJ)\n\n$(SRCDIR)/ui/bg_lib.o : $(GDIR)/bg_lib.c; $(DO_CC) \n$(SRCDIR)/ui/bg_misc.o : $(GDIR)/bg_misc.c; $(DO_CC) \n$(SRCDIR)/ui/ui_addbots.o : $(UIDIR)/ui_addbots.c; $(DO_CC) \n$(SRCDIR)/ui/ui_atoms.o : $(UIDIR)/ui_atoms.c; $(DO_CC) \n$(SRCDIR)/ui/ui_cinematics.o : $(UIDIR)/ui_cinematics.c; $(DO_CC) \n$(SRCDIR)/ui/ui_confirm.o : $(UIDIR)/ui_confirm.c; $(DO_CC) \n$(SRCDIR)/ui/ui_connect.o : $(UIDIR)/ui_connect.c; $(DO_CC) \n$(SRCDIR)/ui/ui_controls2.o : $(UIDIR)/ui_controls2.c; $(DO_CC) \n$(SRCDIR)/ui/ui_credits.o : $(UIDIR)/ui_credits.c; $(DO_CC) \n$(SRCDIR)/ui/ui_demo2.o : $(UIDIR)/ui_demo2.c; $(DO_CC) \n$(SRCDIR)/ui/ui_display.o : $(UIDIR)/ui_display.c; $(DO_CC) \n$(SRCDIR)/ui/ui_gameinfo.o : $(UIDIR)/ui_gameinfo.c; $(DO_CC) \n$(SRCDIR)/ui/ui_ingame.o : $(UIDIR)/ui_ingame.c; $(DO_CC) \n$(SRCDIR)/ui/ui_loadconfig.o : $(UIDIR)/ui_loadconfig.c; $(DO_CC) \n$(SRCDIR)/ui/ui_main.o : $(UIDIR)/ui_main.c; $(DO_CC) \n$(SRCDIR)/ui/ui_menu.o : $(UIDIR)/ui_menu.c; $(DO_CC) \n$(SRCDIR)/ui/ui_mfield.o : $(UIDIR)/ui_mfield.c; $(DO_CC) \n$(SRCDIR)/ui/ui_network.o : $(UIDIR)/ui_network.c; $(DO_CC) \n$(SRCDIR)/ui/ui_playermodel.o : $(UIDIR)/ui_playermodel.c; $(DO_CC) \n$(SRCDIR)/ui/ui_players.o : $(UIDIR)/ui_players.c; $(DO_CC) \n$(SRCDIR)/ui/ui_playersettings.o : $(UIDIR)/ui_playersettings.c; $(DO_CC) \n$(SRCDIR)/ui/ui_preferences.o : $(UIDIR)/ui_preferences.c; $(DO_CC) \n$(SRCDIR)/ui/ui_qmenu.o : $(UIDIR)/ui_qmenu.c; $(DO_CC) \n$(SRCDIR)/ui/ui_quit.o : $(UIDIR)/ui_quit.c; $(DO_CC) \n$(SRCDIR)/ui/ui_saveconfig.o : $(UIDIR)/ui_saveconfig.c; $(DO_CC) \n$(SRCDIR)/ui/ui_serverinfo.o : $(UIDIR)/ui_serverinfo.c; $(DO_CC) \n$(SRCDIR)/ui/ui_servers2.o : $(UIDIR)/ui_servers2.c; $(DO_CC) \n$(SRCDIR)/ui/ui_setup.o : $(UIDIR)/ui_setup.c; $(DO_CC) \n$(SRCDIR)/ui/ui_sound.o : $(UIDIR)/ui_sound.c; $(DO_CC) \n$(SRCDIR)/ui/ui_sparena.o : $(UIDIR)/ui_sparena.c; $(DO_CC) \n$(SRCDIR)/ui/ui_specifyserver.o : $(UIDIR)/ui_specifyserver.c; $(DO_CC) \n$(SRCDIR)/ui/ui_splevel.o : $(UIDIR)/ui_splevel.c; $(DO_CC) \n$(SRCDIR)/ui/ui_sppostgame.o : $(UIDIR)/ui_sppostgame.c; $(DO_CC) \n$(SRCDIR)/ui/ui_spskill.o : $(UIDIR)/ui_spskill.c; $(DO_CC) \n$(SRCDIR)/ui/ui_startserver.o : $(UIDIR)/ui_startserver.c; $(DO_CC) \n$(SRCDIR)/ui/ui_team.o : $(UIDIR)/ui_team.c; $(DO_CC) \n$(SRCDIR)/ui/ui_video.o : $(UIDIR)/ui_video.c; $(DO_CC) \n$(SRCDIR)/ui/q_math.o : $(GDIR)/q_math.c; $(DO_SHLIB_CC) \n$(SRCDIR)/ui/q_shared.o : $(GDIR)/q_shared.c; $(DO_SHLIB_CC) \n\n#############################################################################\n# MISC\n#############################################################################\n\nclean:\n\trm -f $(GVMASM)\n"
  },
  {
    "path": "code/unix/Quake3.kdelnk",
    "content": "# KDE Config File\n[KDE Desktop Entry]\nName=Quake3\nName[C]=Quake3\nMimeType=\nExec=/usr/local/games/quake3/linuxquake3\nComment=Quake3: Arena by id Software\nIcon=quake3.xpm\nTerminalOptions=\nPath=\nType=Application\nTerminal=0\n"
  },
  {
    "path": "code/unix/README.EULA",
    "content": "\tLIMITED COMPATIBILITY TESTING AND RECREATIONAL\n\tUSE SOFTWARE TEST LICENSE AGREEMENT\n\nThis Limited Compatibility Testing and Recreational Use Software Test\nLicense Agreement (the \"Agreement\") is a legal agreement between you, the\nend-user, and Id Software, Inc. (\"ID\").  BY CONTINUING THE INSTALLATION\nOF THIS TEST VERSION OF THE GAME PROGRAM ENTITLED QUAKE III: ARENA (THE\n\"SOFTWARE\"), BY LOADING OR RUNNING THE SOFTWARE, OR BY PLACING OR COPYING\nTHE SOFTWARE ONTO YOUR COMPUTER HARD DRIVE, COMPUTER RAM OR OTHER STORAGE,\nYOU ARE AGREEING TO BE BOUND BY THE TERMS OF THIS AGREEMENT.\n\n1.\tGrant of License.  Subject to the terms and provisions of this\nAgreement, ID grants to you the non-exclusive limited right to use this\nSoftware only in executable or object code form and only for the purpose\nof testing the compatibility of your computer system with the Software\nand for non-commercial, recreational purposes.\tThe term \"Software\"\nincludes all elements of the Software such as data files and screen\ndisplays.  You are not receiving any ownership or proprietary right,\ntitle or interest in or to the Software or the copyright, trademarks, or\nother rights related thereto.  For purposes of this section, \"use\" means\nloading the Software into RAM and/or onto computer hard drive, as well\nas installation of the Software on a hard disk or other storage device.\nYou agree that the Software will not be shipped, transferred or exported\ninto any country in violation of the U.S. Export Administration Act (or\nany other law governing such matters) by you or anyone at your direction\nand that you will not utilize and will not authorize anyone to utilize,\nin any other manner, the Software in violation of any applicable law.\nThe Software may not be downloaded or otherwise exported or reexported\ninto (or to a national or resident of) any country to which the U.S. has\nembargoed goods or to anyone or into any country who/which are prohibited,\nby applicable law, from receiving such property.\n\n2.\tProhibitions. You, either directly or indirectly, shall not do\nany of the following acts:\n\na.\trent the Software;\n\nb.\tsell the Software;\n\nc.\tlease or lend the Software;\n\nd.\toffer the Software on a \"pay-per-play\" basis;\n\ne.\tdistribute the Software (except by electronic means, as permitted\nby section 3. hereinbelow) by any means, including, but not limited to\ndirect mail, retail, mail order or other means;\n\nf.\tin any other manner and through any medium whatsoever commercially\nexploit the Software or use the Software for any commercial purpose;\n\ng.\tdisassemble, reverse engineer, disassemble, decompile, modify\nor alter the Software;\n\nh.\ttranslate the Software;\n\ni.\treproduce or copy the Software (except as permitted by section\n3. hereinbelow);\n\nj.\tpublicly display the Software; \n\nk.\tprepare or develop derivative works based upon the Software; \n\nl.\tremove or alter any legal notices, such as trademark and copyright\nnotices, affixed on or within the Software; or\n\nm.\tcreate or develop extra or add-on levels for the Software.\n\n3.\tPermitted Electronic Distribution and Copying.\tSo long as this\nAgreement accompanies the Software at all times, ID grants to you the\nlimited right to distribute, free of charge, and by electronic means\nonly, the Software.  Anyone who receives the Software shall be limited to\nall the terms and conditions of this Agreement.  You may make only the\nfollowing copies of the Software:   (i) you may download the Software\nfrom the Internet and onto your computer hard drive; (ii) you may copy\nthe Software from your computer hard drive into your computer RAM; and\n(iii) you may make one (1) \"back up\" or archival copy of the Software\non one (1) hard disk.\n\n4.\tCopyright.  The Software and all copyrights, trademarks and all\nother conceivable intellectual property rights related to the Software\nare owned by ID and are protected by United States copyright laws,\ninternational treaty provisions and all applicable law, such as the\nLanham Act.  You must treat the Software like any other copyrighted\nmaterial, as required by 17 U.S.C., 101 et seq. and other applicable law.\nYou agree to use your best efforts to see that any user of the Software\nlicensed hereunder complies with this Agreement.  You agree that you\nare receiving a copy of the Software by license only and not by sale and\nthat the \"first sale\" doctrine of 17 U.S.C. 109 does not apply to your\nreceipt or use of the Software.\n\n5.\tNO WARRANTIES.\tID DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS\nOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE WITH RESPECT TO\nTHE SOFTWARE.  ID DOES NOT WARRANT THAT THE OPERATION OF THE SOFTWARE\nWILL BE UNINTERRUPTED OR ERROR FREE OR THAT THE SOFTWARE WILL MEET YOUR\nSPECIFIC REQUIREMENTS.\tADDITIONAL STATEMENTS SUCH AS PRESENTATIONS,\nWHETHER ORAL OR WRITTEN, DO NOT CONSTITUTE WARRANTIES BY ID AND SHOULD\nNOT BE RELIED UPON.\n\n6.\tGoverning Law, Venue and Liability Limitation.\tThis Agreement\nshall be construed in accordance with and governed by the applicable laws\nof the State of Texas and applicable United States federal law.  Copyright\nand other proprietary matters will be governed by United States laws and\ninternational treaties.  Exclusive venue for all litigation regarding\nthis Agreement shall be in Dallas County, Texas and you agree to submit to\nthe jurisdiction of the courts in Dallas, Texas for any such litigation.\nIN ANY CASE, NEITHER ID NOR ID'S OFFICERS, EMPLOYEES, DIRECTORS, AGENTS,\nLICENSEES, SUBLICENSEES, SUCCESSORS OR ASSIGNS SHALL BE LIABLE FOR LOSS OF\nDATA, LOSS OF PROFITS, LOST SAVINGS, SPECIAL, INCIDENTAL, CONSEQUENTIAL,\nINDIRECT, PUNITIVE OR OTHER SIMILAR DAMAGES ARISING FROM BREACH OF\nWARRANTY, BREACH OF CONTRACT, NEGLIGENCE, STRICT PRODUCT  LIABILITY,\nOR OTHER LEGAL THEORY EVEN IF ID OR ITS AGENT HAS BEEN ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGES OR EVEN IF SUCH DAMAGES ARE FORESEEABLE,\nOR LIABLE FOR ANY CLAIM BY ANY OTHER PARTY.  Some jurisdictions do not\nallow the exclusion or limitation of incidental or consequential damages,\nso the above limitation or exclusion may not apply to you.\n\n7.\tU.S. Government Restricted Rights. To the extent applicable,\nthe United States Government shall only have those rights to use the\nSoftware as expressly stated and expressly limited and restricted in\nthis Agreement, as provided in 48 C.F.R.  227.7202-1 through 227.7204,\ninclusive.\n\n8.\tGeneral Provisions.  A copy of all notices or other correspondence\nwhich you send to ID shall also be sent by you to ID's counsel:\n\nD. Wade Cloud, Jr.\nHIERSCHE, MARTENS, HAYWARD, DRAKELEY & URBACH, P.C.\n15303 Dallas Parkway, Suite 700\nDallas, TX 75248\n(972) 701-7000\nFacsimile:   (972) 701-8765\n\nNeither this Agreement nor any part or portion hereof shall be assigned\nor sublicensed by you.  ID may assign its rights under this Agreement\nin ID's sole discretion.  Should any provision of this Agreement\nbe held to be void, invalid, unenforceable or illegal by a court,\nthe validity and enforceability of the other provisions shall not be\naffected thereby.  If any provision is determined to be unenforceable,\nyou agree to a modification of such provision to provide for enforcement\nof the provision's intent, to the extent permitted by applicable law.\nFailure of ID to enforce any provision of this Agreement shall not\nconstitute or be construed as a waiver of such provision or of the right\nto enforce such provision.  If you fail to comply with any term of this\nAgreement, YOUR LICENSE IS AUTOMATICALLY TERMINATED, WITHOUT NOTICE AND\nID MAY PURSUE ALL RELIEF AND REMEDIES AGAINST YOU WHICH ARE AVAILABLE\nUNDER APPLICABLE LAW AND/OR THIS AGREEMENT.  You agree that in the event\nof litigation relating to this Agreement, the prevailing litigant shall\nbe entitled to recover the prevailing litigant's attorneys' fees and\nexpenses and costs of court in addition to all other relief available\nunder this Agreement and/or applicable law.  In the event this Agreement\nis terminated, you shall have no right to use the Software, in any manner\nand you shall immediately destroy all copies of the Software in your\npossession, custody or control.  You agree that your unauthorized use\nof any ID property, whether in whole or in part, would immediately and\nirreparably damage ID such that ID could not be adequately compensated\nby an award of monetary damages, and in the event of such threatened\nor actual unauthorized use ID shall be entitled to an injunctive order\nappropriately restraining and/or prohibiting such unauthorized use\nwithout the necessity of ID posting bond or other security.\n\nYOU ACKNOWLEDGE THAT YOU HAVE READ THIS AGREEMENT, YOU UNDERSTAND THIS\nAGREEMENT, AND UNDERSTAND THAT BY CONTINUING THE INSTALLATION OF THE\nSOFTWARE, BY LOADING OR RUNNING THE SOFTWARE, OR BY PLACING OR COPYING\nTHE SOFTWARE ONTO YOUR COMPUTER HARD DRIVE OR RAM, YOU AGREE TO BE BOUND\nBY THE TERMS AND CONDITIONS OF THIS AGREEMENT.  YOU FURTHER AGREE THAT,\nEXCEPT FOR WRITTEN SEPARATE AGREEMENTS BETWEEN ID AND YOU, THIS AGREEMENT\nIS A COMPLETE AND EXCLUSIVE STATEMENT OF THE RIGHTS AND LIABILITIES OF\nTHE PARTIES HERETO.  THIS AGREEMENT SUPERSEDES ALL PRIOR ORAL AGREEMENTS,\nPROPOSALS OR UNDERSTANDINGS, AND ANY OTHER COMMUNICATIONS BETWEEN ID\nAND YOU RELATING TO THE SUBJECT MATTER OF THIS AGREEMENT.\n\n\n\nApril 23, 1999     5:11 p.m.\n\n\n\n\n\nLIMITED COMPATIBILITY TESTING AND RECREATIONAL USE SOFTWARE\nTEST LICENSE AGREEMENT\tPage 4\n3406.0586\\C:\\DWC\\DOC\\2082.DOC\n\n"
  },
  {
    "path": "code/unix/README.Linux",
    "content": "+----------------------------------------+\n| Q3Test                                 |\n| The Official Quake 3: Arena TEST       |\n| Linux version                          |\n| Revision 1.08                          |\n| Released Aug 3, 1999                   |\n| Copyright (C) 1999 id Software, inc.   |\n+----------------------------------------+\n| Documentation: Paul Jaquays            |\n|                Dave Kirsch             |\n+----------------------------------------+\n\nOutline:\n\n1.  Introduction\n2.  Bug Reporting\n3.  Installing Q3Test\n4.  Running Q3Test.  Operating Instructions\n5.  Known Issues\n\n==================\n== Section 1.   ==\n== INTRODUCTION ==\n==================\n\nThis is the Linux version of the test.\n\nBefore proceeding onward, please read the README.EULA file. This is\nthe End User License Agreement. It's the agreement between you and id\nregarding this test.  Read it. Understand that the acts of loading or\nrunning the software, or placing it on your computer hard drive, RAM,\nor other storage, you are agreeing to be bound by the terms of the End\nUser License Agreement. So it's best to know what you are agreeing to.\n\nThe operating instructions for the test are included in the \nseparate \"README.Q3Test\" file.  For the most part, the game functions\nare the same across all platforms.  Differences will be noted when necessary.\n\n+----------------+\n| THIS IS A TEST |\n+----------------+\n\nWe want to set the record straight from the outset. This is neither a\ndemo nor an ALPHA version of the final game and should not be expected\nto behave as such. Q3Test is a test of Quake3: Arena's network technology\nand graphics compatibility. While many of the game features that you will\nsee in this test are in a highly polished state, do not confuse this with\nbeing anything other than what it is intended to be: a test. By running\nthis test openly on the Internet and on a multitude of local networks,\nwe hope to expose problems that could not otherwise be discovered on the\nlimited number of in-house systems and computer. That's why we need your\nassistance for this test.\n\nFurthermore, it is anticipated that there may be revisions and additions\nmade to the test that will make it incompatible with earlier versions.\n\n+---------------------+\n| SYSTEM REQUIREMENTS |\n+---------------------+\n\nThere is no software-only version of the game. If your computer is not\nhardware accelerated with a game compatible graphics card, you will NOT be\nable to run Q3Test. Currently, 3DFX based cards are the only\ntested compatible cards. If your computer does not meet the \nminimum requirements, you are unlikely to be able to run a satisfactory \ngame experience.\n\nA glibc compatible Linux installation is required.  An easy to determine\nif you have glibc support is to type this:\n\n\tls -l /lib/libc*\n\nIf you get a report of libc6 (you may also have libc5), you have a\nglibc based system.\n\nThe Linux version requires a supported hardware 3D acceleration card. The\nfollowing are currently supported:\n\n        o 3Dfx Voodoo Graphics based cards\n        o 3Dfx Voodoo2 based cards\n\nOther cards of similar make and model may work, but are not supported.\n\nOther X11 OpenGL libraries may work with a supported hardware\naccelerator, but have not been extensively tested.  Performance on\nuntested OpenGL configurations may not produce acceptable game\nspeed.\n\nFor 3Dfx based products, Linux Q3Test is distributed with a version of Mesa\n3-D specifically compiled for Voodoo support. You must have 3Dfx Linux Glide\ndrivers installed however. These drivers are available from:\n\n\t\thttp://glide.xxedgexx.com/3DfxRPMS.html\n\nMake sure that you download and install the glibc versions of the drivers\n(found at the bottom of the page).\n\nMirrors for this site are can be found at:\n\n\t\thttp://glide.mirrors.sonic.net \n\t\thttp://glide.samiam.org \n\nPlease follow the installation instructions presented there for adding the\ncorrect drivers for your 3D-acceleration card. Note that there are two ways\nto install the 3DFX drivers-one with support for a /dev/3dfx device that\ndoes not require root permissions in order to use the card. If you choose to\nnot use the /dev/3dfx method, you will have to run Q3Test as the root user.\n\nNOTE:  Linux Q3Test will try to load \"libGL.so\" before using 3Dfx drivers.\nThis can cause problems if you have a software or third party OpenGL driver\ninstalled.  You can specifically target the included 3Dfx based Mesa driver\nby using the following command line:\n\n\t./linuxquake3 +set r_glDriver libMesaVoodooGL.so.3.1\n\nFor 3DFX users, you may disable the vertical sync refresh.  This can improve\nproformance at the cost of some visual tearing of the image.  Entering the\nfollowing command into your shell before running Q3Test will turn off\nthe vertical sync:\n\n\texport FX_GLIDE_SWAPINTERVAL=0\n\nThen run Linux Q3Test from the same command line normally.\n\n+-----------+\n| X11 Setup |\n+-----------+\n\nLinux Q3Test requires X11 to run. There is no console-based version as in\nprevious id products such as GLQuake and Quake2. XFree86 version 3.2 or\nlater is required.\n\nThere are two ways that mouse input is handled under XFree86:\n\n        o By default, Q3Test will attempt to use DGA mouse handling. DGA\n          support features direct reading of the mouse motion and provides\n          more accurate control while playing the game. By default this\n          support is enabled, but can be disabled by adding \"+set\n          in_dgamouse 0\" to the command line at startup.\n        o The non-DGA method of mouse input uses pointer grabbing and warps\n          the pointer to the middle of the window on each mouse update. On\n          systems with a slow frame rate and a lot of mouse user input, the\n          motion can get \"clipped\" to the window boundaries. This method of\n          input is more compatible however.\n\nQ3Test uses the XFree86 VidModeExtension facilities if available to provide\nfullscreen play. This does not apply to 3Dfx passthrough based cards, since\nthe passthrough cable takes over the video display upon activation anyway.\n\nWhen configuring your X11 server, make sure that you include lower\nresolution modes such as 640x480 and 800x600. Q3Test will auto-switch to\nthese modes using the VidModeExtension if you select fullscreen from the\ngraphics options menu. If the lower resolution modes are not listed in the\nXFree86 configuration file, Q3Test will be unable to switch to the desired\nresolution for fullscreen play.\n\n+-------------------------+\n| Sound Support and Setup |\n+-------------------------+\n\nQ3Test uses the /dev/dsp sound device for sound support under Linux. This is\nthe default device provided by the sound drivers included with the Linux\nkernel. Please note that at the time of this writing, PCI based sound cards\nsuch as the SoundBlaster Live and Diamond Monster MX series were not\nsupported. They may be supported in the future. Check\nhttp://www.opensound.com/ for support in the future.\n\nIf you do not run Q3Test as root (recommended), you may need to make sure\nthe permissions for the /dev/dsp device are read and write by the user\nrunning Q3Test. The cheap and easy way to make this happen is to do \"chmod\no+rw /dev/dsp\" as root. For the more security conscious, a special sound\ngroup could be created and Q3Test could be made setgid to the sound group to\naccess the device.\n\nQ3Test uses mmap() to map the sound buffers on /dev/dsp directly in order to\nprovide responsive sound needs. Sound cards must be able to support this\nfeature in order to work. SoundBlaster 16, AWE32 and AWE64 cards are known\nto work.\n\n+----------------------+\n| WHAT'S IN THIS TEST? |\n+----------------------+\n\nWe have included three maps with this test version of Quake3: Arena. They\nare q3test1, q3test2,  and q3tourney.\n\nq3test1    for 4-8 players    on Internet or LAN play   Best with 6 players\nq3test2    for 3-8 players    Primarily for LAN play    Best with 3 players \nq3tourney is the tournament map\n\n===================\n== Section 2.    ==\n== BUG REPORTING ==\n===================\n\nWhat we would like from our testers are emails with descriptions of\nproblems that are encountered, particularly those involving video or\nnetwork bugs. Do NOT send reports to individual id employees.  All bug\nreports should go to the following e-mail address:\n\nq3feedback@idsoftware.com\n\nIn your subject line, please describe the system the game is being played\non (Mac, Linux, Win32) and the type of problem you are reporting: video,\nnetwork, sound or game. Example Subject Line:  \"Mac/video problem\" or\n\"Linux/network connection problem.\"\n\nIn the body of your letter (no attached files please), briefly list and\ndescribe the problems.  Detailed descriptions of problems are good, but\nremember that brevity is best. Please do NOT send screen shots unless\nthey are the ONLY way to show a problem.\n\nWhile we realize that you may have comments and suggestions regarding\nspecific game play features, please refrain from submitting such along\nwith bug reports. Comments on game play can be made on the official\nQuake 3: Arena message board at:\n\nhttp://www.quake3arena.com \n\n========================\n== Section 3.         ==\n== INSTALLING Q3TEST  ==\n========================\n\nAfter you have installed the needed hardware drivers for your 3D\nacceleration and sound hardware, you need to install the Q3Test package.\n\nQ3Test is available as a Red Hat RPM file or as a tar file. To install the\nRPM file, enter the following when logged in as the root user:\n\nrpm -Uvh q3test-1.00-glibc-1.i386.rpm\n\nThe rpm installs the game and data files in /usr/local/games/q3test.\n\n[ Note: If you have not installed (or do not wish to install) the Linux\nglide drivers, you may get an error message about not having libglide2x.so \ninstalled.  This can be ignored and installation can be forced by adding \nthe --nodeps option to the rpm command line as follows: \nrpm --nodeps -Uvh q3test-1.00-glibc-1.i386.rpm ]\n\nIf you are going to install the tar version, make a directory for\ninstallation, untar the file as follows:\n\ntar xzvf q3test-1.00-glibc-i386.tar.gz\n\nThis will untar the files into a q3test subdirectory under the current\ndirectory.\n\n====================\n== Section 4.     ==\n== RUNNING Q3TEST ==\n====================\n\nIt is recommended that you do not run Q3Test using the root account or with\nroot privileges. There are two exceptions to this:\n\n        o If you are using a 3Dfx based accelerator card and do not install\n          the /dev/3dfx configuration option. (You will have to run as root\n          in order to access the card).\n        o If you do not have access to the /dev/dsp device and do not wish\n          to change the mode of the device so that non-root accounts can\n          access it.\n\nYou will have to be running under X11 or have the DISPLAY variable pointed\nto a OpenGL glX capable X Server.\n\nBy default, Q3Test tries to find the following OpenGL libraries in this\norder:\n\n        o libGL.so.1\n        o libMesaVoodooGL.so.3.1\n\nYou can override the library name by entering, \"+set r_glDriver <libname>\"\non the command line. This may be needed if you are using a non-standard set\nup and have a different name for the OpenGL shared library.\n\nIf everything proceeds successfully, you should have a Q3Test window on your\ndesktop with a menu displayed (3DFX owners will get a full screen view). If\nyou want to use full screen, go to the System Configuration, Graphics\nOptions, Fullscreen, change the value to Yes, and hit enter to apply it.\n\nIf you intend to connect to the Internet to play Q3Test, make certain\nthat your net connection is open and working first.\n\n======================\n== Section 5.       ==\n== KNOWN ISSUES     ==\n======================\n\nQ. My mouse is erratic. My player is constantly looking up or down and\nI can't seem to move him.\n\nA. This happens with two issues. Some versions of XFree86 have a bug in\nDGA mouse handling that confuses Q3Test. You can try turning off DGA mouse\nsupport by entering \"+set in_dgamouse 0\" on the command line when you\nstart Q3Test. This problem can also occur after a restart of the video\nsystem (such as after a graphic setting change). This is because some\nsort of event occurred to jam up the mouse. Restarting the video system\nanother time and not moving the mouse during the restart should clear it.\n\n\nQ. When I do a video restart (for example, selecting Apply in the Graphics\nOptions menu), Q3Test exits with a Sig11.\n\nA. This is a driver related problem.  \nOn 3DFX hardware that is using the /dev/3dfx device and you are NOT running \nas root, it seems that the restart doesn't clear some sort of permission. \nRunning Q3Test as root will fix this problem.  \n\n\nQ. Performance is so slow I can't play! The frame rate looks like one\nframe per second!\n\nA. Most of the current drivers for Linux do not support hardware\nacceleration at any bit depth other than 15 or 16 bit color. Make sure\nthat you specify 16 bit color when you run your X11 Server, such as:\n\n\tstartx -- -bpp 16\n\n\nQ. I have a Voodoo3.  When I start the game, I send up at a low resolution\nversion of my desktop.\n\nA. The current Voodoo3 X11 Servers have problems with DGA Mouse support.\nThis is a known driver issue and will be fixed in newer revisions of the\nVoodoo3 X11 Server.  Run the game with the following to disable it:\n\t./linuxquake3 +set in_dgamouse 0\n\n\nQ. I'm running Gnome with Englightenment and sound doesn't work.\n\nA. If you are using the Enlightenment Sound Daemon (esd), it will not release\nthe sound hardware for Quake3 Test's usage.  You can disable it before running\nthe test as follows:\n\t\tesdctl off  # turn it off\n\t\tstart q3test the normal way\n\t\tesdctl on   # turn it back on\n\n\nQ. I try to run Q3Test, but sound doesn't work.  The console says \"Can't\nopen /dev/dsp.  /dev/dsp:  Can't allocate memory.\"\n\nA. This can happen if the vmware kernel modules are loaded.  You can unload\nthem by typing when logged as root:\n\t/etc/rc.d/init.d/vmware stop\nAssuming you are using a RedHat system.\n\n\nQ. I was playing Q3Test and suddenly it quit and reported a signal error.\n\nA. This is probably a bug. Please report it.\n\n"
  },
  {
    "path": "code/unix/README.Q3Test",
    "content": "+----------------------------------------+\n| Q3Test                                 |\n| The Official Quake 3: Arena TEST       |\n| Operating Instructions Readme\t     |\n| Revision 2.1                           |\n| Released Friday July 16th, 1999      |\n| Copyright (C) 1999 id Software, inc.   |\n+----------------------------------------+\n| Documentation: Paul Jaquays            |\n+----------------------------------------+\n\nThis game is not yet rated by the ESRB. It contains animated\nviolence and blood.  A rating for mature audiences 17+ is \nanticipated.\n\n1.  Introduction\n2.  Operating Instructions\n3.  Status Readouts\n4.  Player Actions\n5.  The Arena Environment\n6.  The Game Console\n7.  Problem Icons\n\n==================\n== Section 1.   ==\n== INTRODUCTION ==\n==================\n\n\tThese instructions for game play should work with the versions of the game that are targeted at different platforms.\n\n\tBefore proceeding onward, click on the EULA_Readme file icon. This is the End User License Agreement. It's the agreement between you and id regarding this test.  Read it. Understand that the acts of loading or running the software, or placing it on your computer hard drive, RAM, or other storage, you are agreeing to be bound by the terms of the End User License Agreement. So it's best to know what you are agreeing to.\n\n\tIf you agree to the conditions of the End User License Agreement, install the game on your computer's hard drive.\n\tIf you are using the Win32 version, open the readme file included for GLSetup.  This application will load the most recent versions of the GL drivers needed to play Quake3: Arena.\n\n\tThe platform-specific instructions for the test are included in a separate Readme file. Refer to the appropriate Readme for your hardware.\n\n+----------------+\n| THIS IS A TEST |\n+----------------+\n\tWe want to set the record straight from the outset. This is neither a demo nor an ALPHA version of the final game and should not be expected to behave as such. Q3Test is a test of Quake3: Arena's network technology and graphics compatibility. While many of the game features that you will see in this test are in a highly polished state, do not confuse this with being anything other than what it is intended to be: a test. By running this test openly on the Internet and on a multitude of local networks, we hope to expose problems that could not otherwise be discovered on the limited number of in-house systems and computers we have available. That's why we need your assistance for this test.\n\n\tFurthermore, it is anticipated that there may be ongoing revisions and additions made to the test that will make it incompatible with earlier versions.\n\n============================\n== Section 2.             ==\n== OPERATING INSTRUCTIONS ==\n============================\n\n\tWhen you start Q3Test, the game does not automatically load a map. Instead it displays the Main Menu screen.  At this point (or at any time during the game) you may adjust and customize the video and audio settings on your computer, change details regarding your game character, and if desired, change the default controls to ones more to your liking.\n\nAt any time during the game, press the Escape key to bring up the Main menu and superimpose it over the game screen. Use the up and down arrow keys to navigate the menu, and press the Enter key to select a function. Press Escape to return to the main level menu (and set any selected choices). Each Main menu function brings up a list of secondary menu items. If you have problems using the secondary menu selections, please refer to the message banner at the bottom of the screen for technical details.\n\nIf a menu selection appears in gray, you cannot select or modify it.  Choosing some options in the CONTROL CUSTOMIZATION and GRAPHICS OPTIONS menus will disallow other options. This is because they are either unnecessary (as is the case with MOUSE LOOK if you select the FREE LOOK option), or are not supported (as is the case with COLOR DEPTH if you chose the VOODOO OPENGL).\n\n+-----------+\n| MAIN MENU |\n+-----------+\nThe first three Main Menu options, SEARCH FOR LAN GAME, CONNECT TO NETWORK GAME and START NETWORK GAME are only available if the player is not currently connected to an ongoing game.\n\nSEARCH FOR LAN GAME:\nIf your computer is on a Local Area Network (LAN), this will show any currently active Q3Test servers on the network, along with the number of players currently in the game and the maximum number of players that can be in that game.  \n\nExample:  idserver   q3test1   1/8\n\nThis indicates that the server on the LAN called \"idserver\" is currently playing the map \"q3test1\" and has one player in it out of the possible 8 that can be in the game at one time.\n\nUse the up/down arrow keys to select a server and hit ENTER to command your computer to connect to that game.\n\nCONNECT TO NETWORK GAME: \n\tSERVER: If your computer is connected to the Internet, you can enter the IP address of a server and hit ENTER to attempt to make a connection to that server. For server id's Q3Test server listings, go to http://www.quake3arena.com or check with your favorite 3D gaming web sites for other servers.\n\tRATE:  Set the type of network connection you are using. Choices are: \"<=28.8K\", \"33.6K\", \"56K\", \"ISDN\", and \"LAN/cable/xDSL\".\n\nSTART NETWORK GAME:\nTo start a network game, whether on a LAN or over the Internet, select this option.  The secondary menu screen has the following options:\n\nSTART: Launches the game using the parameters currently set on this menu.\nMAP:  This gives access to the list of maps located in the Quake3/Baseq3/Maps directory/folder.  For the purposes of this test, there are only two maps. Use the left and right arrow keys to toggle between the two maps.\nDEDICATED: This is either \"no\", \"dedicated LAN,\" or \"dedicated Internet.\"\nA dedicated server (set to YES) runs the game, but does not display a graphic version of the game on the screen of the computer running the game. The default value for this is no. This means that you are running the server and participating as a player at the same time.\nTIME LIMIT: entering a non-zero number here sets a time limit (in minutes) for the game duration.  If the game has not ended because a frag limit has been set, then it will end when time runs out.\nFRAG LIMIT: Entering a non-zero number here sets the number of \"frags\" or \"kills\" needed to win the game. If the game has not ended because a time limit has been set, then it will end when one player in the game reaches this number of frags.\nMAX PLAYERS: This is the total number of players that may be in the game at any one time.\nHOSTNAME:  This is the name of the server.  In the LAN example above, the hostname is \"idserver.\"\n\nCUSTOMIZE PLAYER: \nAllows the player to change information about his in-game persona.\n\nNAME: This is the player's name as it will appear on-screen during the game. It may be up to 33 characters long.\n\nSKIN: Visor is the only model in the test. Two skins (red and blue) are available for the model. Use the left and right arrow keys to select one.\n\nEFFECTS COLOR: You can choose an identifying color for your rail gun projectile trails.  Use the left and right arrow keys to select a color. \n\nHANDICAP: Better players can choose to handicap themselves to balance a match against players of less skill by limiting the maximum amount of health and armor that they can have during the game. Use the left and right arrows to select a value from 25 to 100 points.  Certain items and power ups will temporarily raise this value, but will then count down to the preset value. The default is 100.\n\nCUSTOMIZE CONTROLS: \nAllows the player to change the assignment of game controls to other keyboard and mouse buttons.  When you visit this menu for the first time, the default assignments for all controls are shown.  To change an assignment, use the up/down arrow keys to select a game function. Press ENTER to activate the change process. Press the keyboard key or mouse input that you want to use for that function.  Up to two keys/buttons may be assigned to each game function in this manner by repeating the process. If you inadvertently use a key assigned to another function, three question marks (\"???\") appear next to the function that previously used that key.\n\nALWAYS RUN: setting this to YES causes your player to move faster, but make more noise as he moves. The RUN/WALK key allows the player to switch between fast/noisy and slow/silent movement modes.\nFREELOOK:  If YES, then you may look freely in all directions as if you were moving only your head by moving the mouse around.  If this is Set to NO you must bind a key to mouse look.\nINVERT MOUSE: Selecting YES inverts the up and down view movement directions.\nMOUSE SPEED: This is set on the menu with a slide control. The faster your mouse speed, the greater the on-screen response to small movements of the mouse.  Mouse speed can also be adjusted from the console.  Bring the console down and type in \"sensitivity\".  The game will respond by printing \"sensitivity\" is: \"__\" (the blank indicating the number value currently assigned to mouse speed) default is \"5\". Use the up arrow key to display sensitivity on the console again, enter a different number value and hit enter.  Higher numbers are more sensitive.  Lower numbers are less sensitive.\n\nSYSTEM CONFIGURATION:\nEFFECTS VOLUME: Use the slide control to adjust game sound playback volume to your liking.\nSOUND QUALITY: Select either Low (16 bit sound running at 11 megahertz) or High (32 bit sound running at 22 megahertz).\nBRIGHTNESS:  First, try running the game with the brightness set to 1.0 (the default level used by the designer when making the map).  If the map is too dark to see in dimly lighted areas or too light in sunny areas, use this slide control to compensate for differences in the way some monitors and video cards draw the game world.  Remember that the arenas are supposed to be dark and foreboding places.\n\nGRAPHICS OPTIONS: \nThis drops you down into another menu layer. The controls here are designed to help you optimize graphics and or/enhance the game's playability on your system. When you are satisfied with your selections, you must move the cursor to the bottom of the screen to the APPLY option to activate them.  Pressing Escape to return to the SYSTEM CONFIGURATION MENU does not activate changes in the graphics settings. Changing anything on this menu will cause the game to restart the video.\n\nGRAPHICS MODE: This is a global setting for the display of the game's screen graphics.  The settings are HIGH QUALITY, NORMAL, FAST, FASTEST, and CUSTOM. Selecting one of these choices affects most of the other settings on this page. If you make any adjustments to other settings on this page, the graphics mode changes to CUSTOM.\nDRIVER:  Consult the platform specific readme for the drivers that will work with your platform. \nVIDEO MODE:  This is the screen resolution size.  Smaller resolutions can improve performance speed on slower machines.\nCOLOR DEPTH: Determines whether you are using 16-bit textures or 32-bit textures. Default means you run with the color depth currently set for your computer's desktop.\nFULLSCREEN: A YES selection allows you to choose to run with the test filling the entire screen.  A NO selection will run the game in a window.  If run in a window, COLOR DEPTH is disabled because you are limited to whatever has been selected for the desktop.\nLIGHTING:  Allows you to chose either a LIGHTMAP or VERTEX lighting.  Using the LIGHTMAP is recommended for best appearance.  VERTEX lighting may improve game performance, but at a cost to appearance.\nGEOMETRIC DETAIL: Lets you adjust the number subdivisions used to define curves in the arena on both world geometry and items, weapons and characters.  HIGH is the normal setting. LOW greatly reduces curve complexity.\nSCREEN SIZE: The slide control changes the amount of screen area devoted to display of the game.  Reducing screen size can improve performance.\nTEXTURE DETAIL: This sliding control allows you to adjust the level of detail displayed. Unless you have an extremely fast computer, the normal setting gives the best balance of detail vs. game speed.\nTEXTURE QUALITY:  This determines whether you wish to use 32-bit textures, 16-bit textures, or compressed textures.  Many of the game's special effects will appear at their best only when defined by 32-bit textures.\nOPENGL EXTENSIONS: Allows you to enable or disable OPENGL extensions.\nDRIVER INFORMATION: Brings up a display of information regarding the drivers currently operating in your machine. It is not interactive. Hit ESC to return to the previous menu.\n\n\nPREFERENCES:  Hitting ENTER here will drop you into another menu that allows you to adjust other game features.\nCROSSHAIR: choose one of four options, none, cross, dot, or angle.\nMARKS ON WALLS: Enable or Disable weapons scars and blood smears.  Disabling this feature may improve performance.\nDYNAMIC LIGHTS:  Enable or Disable lights that move through the world (such as light generated by weapon projectile trails). Disabling this feature may improve performance.\nLIGHT FLARES: Enable or DISABLE glowing light halos around lights.  Disabling this feature may improve performance.\nIDENTIFY TARGET: Enable or Disable the ability to see the name of your foe when you put your crosshair on him (does not function if target is in fog).\nSKY: Set the sky for either HIGH SPEED or HIGH QUALITY.\n\nRESET DEFAULTS: Restore all game settings and controls to their default value by reloading the default configuration.\n\nAPPLY:  You must select this and hit ENTER to lock in your choices.  Doing so will restart the game video.\n\nSCREENSHOT: \nMakes a targa file screen shot of what is currently in view on the screen. Look for it in the Screenshot folder within your Quake 3/Baseq3/screenshots folder.\n\nLEAVE ARENA: \nThis disconnects you from the arena you are currently playing, but does not quit you out of the game.  From here you can connect to other servers or start your own. You can also leave an arena by typing \"disconnect\" on the command line of the console.\n\nQUIT GAME: \nReturns you to the desktop.\n\n\n======================\n== Section 6.       ==\n== STATUS READOUTS  ==\n======================\n\n\tYour player status is shown as numbers and icons floating in your view at the bottom of the screen.  There is an indicator for your ammo (far left) including the type of ammo currently in use, current health (left-center), your character portrait (center), armor (center-right), and Frag Count (far right). The digital timer in the upper right shows the amount of time you have been in this arena.  When you have a one-use item in your inventory (such as the personal teleporter), its icon will appear on the right side of your display.  When you are fragged, the character portrait and name of the foe who killed you appears in the upper right corner of the display.  When you change weapons, icons representing the ammo of the weapons in your inventory will appear above your character portrait. If you have a weapon, but no ammunition for it, a negation symbol will be superimposed over the ammo icon.\n\n+----------------------------+\n| INTERPRETING THE LAGOMETER |\n+----------------------------+\n     The Lagometer is the graph in the lower right corner of the status display. It is a test function and not a part of regular game play.  The upper graph (blue/yellow) slides one pixel for every rendered frame. Blue lines below the baseline mean that the frame is interpolating between two valid snapshots. Yellow lines above the baseline mean the frame is extrapolating beyond the latest valid time. The length of the line is proportional to the time. \nThe lower graph (green/yellow/red) slides one pixel for every received snapshot. By default, snapshots come 20 times a second, so if you are running >20 fps, the top graph will move faster, and vice versa. A red bar means the snapshot was dropped by the network. Green and yellow bars are properly received snapshots, with the height of the bar proportional to the ping. A yellow bar indicates that the previous snapshot was intentionally suppressed to stay under the rate limit. \nThe upper graph indicates the consistency of your connection. Ideally, you should always have blue bars of only a pixel or two in height. If you are commonly getting big triangles of yellow on the graph, your connection is inconsistent. \n     In a heavy firefight, it is normal for modem players to see yellow bars in the bottom graph, which should return to green when the action quiets down. If you are getting several red bars visible, you may want to look for a server that drops less packets. \n     There are a few tuning variables for people trying to optimize their connection: The most important one is \"rate\", which is what the connection speed option in the menu sets. We are fairly conservative with the values we set for the given modem speeds: 2500 for 28.8, 3000 for 33, and 3500 for 56k. You may actually be connecting faster than that, and modem compression may be buying you something, so you might get a better play experience by increasing the values slightly.  If you connect at 50000 bps, try a rate of 5000, etc. Quake 3 errs on the conservative side, because too low of a rate will only make the movement of other things in the world choppy, while too high of a rate can cause huge amounts of lag. \n     Note that the optimal rate will be somewhat lower than a rate for QW or Q2, because Quake 3 now includes the UDP packet header length in the bandwidth estimate.  You can ask for a different number of snapshots by changing the \"snaps\" variable, but there isn't a lot of benefit to that. Dedicated servers run at 40hz, so stick to divisors of that: 40, 20 (default), 10. A \"snaps\" of 40 will usually just cause you to hit your rate limit a lot faster. It may be useful for tuning rate, if nothing else. \n     You can adjust the local timing point with \"cg_timenudge \", which effectively adds local lag to try to make sure you interpolate instead of extrapolate. If you really want to play on a server that is dropping a ton of packets, a timenudge of 100 or so might make the game smoother. \n\n=====================\n== Section 7.      ==\n== PLAYER ACTIONS  ==\n=====================\n\n\tThe descriptions below are based on the preset default configurations for the game controls.  If you have played first person shooting games previously (such as Quake or Quake 2), you may want to reconfigure the controls to match your preferences.\n\n+----------+\n| ACTIONS  |\n+----------+\nWALKING:  Use the four arrow keys or the mouse to walk around.  To walk steadily forward, hold down the \"forward\" key (the up arrow or center button on a 3-button mouse).  Turn left or right with the left or right arrow keys, or by sliding your mouse in the desired direction.\n\nRUNNING:  To run, simply hold down the left Shift key to increase your \nSpeed (unless you have selected \"Always Run\", in which case it reverts you to a walk.  If you prefer to always run during the game, open the Main menu, then the Customize Controls menu, and select Always Run.\n\nSHOOTING:  Tap the Ctrl key or the left mouse button to fire. Hold the \nfire key down to keep firing.\n\nLOOKING UP AND DOWN: The letters A and Z allow you to look up and down, \nrespectively.  Start walking forward and your line of vision will \nautomatically readjust to the center position.  You may also choose to \nselect Free Look under the Controls menu which will allow you to move the \nmouse around as if it was your head movement.\n\nSWIMMING:  While underwater, aim yourself in the direction you wish to go \nand press the forward key to go in that direction.  Unfortunately, as in \nreal life, you may lose your bearings while underwater.  Use the jump key, \n(default is the Space Bar), to kick straight up towards the surface. Once on \nthe surface, tread water by holding down the jump key.  To get out of the \ndrink, swim toward the shore and you can either jump up onto the land or \nwalk straight out if it is shallow enough.  There is always a way out of \nwater, but you may have to submerge even deeper in order to find it.\n\nCROUCHING:  Press and hold down the C key to duck and move forward to \"duck walk.\"  When you release the C key, you will return to an upright position.  It is also possible to avoid rockets in this manner.\n\nJUMPING:  Tap the space bar to jump.  You jump farther if you're moving \nforward at the time.\n\nSTRAFING:  Hold down the ALT key and the left or right arrow key and you will side-step in that particular direction. This is perfect for avoiding incoming weapon attacks.\n\nPICKING UP OBJECTS: To pick up items, weapons, and power-ups, simply walk \nover them.  The weapon cross-hair will pulse larger briefly to indicate you have acquired a new weapon or supply. If you are unable to pick something up, it means you already have the maximum amount possible for that object.\n\nTALKING:  To communicate with other players, press the T key \nand type in your message.  Press Enter when finished and your words will \nappear at the top of the screen. You can also enter communications on the command line of the console.\n\nATTACKING: Point your weapon at an opponent and press the fire button.  Default fire keys are the left mouse and the control key). If a weapon runs out of ammo, it switches to the next available weapon with ammo the next time you fire it.  If you have no ammo at all, you fight with the gauntlet.\n\n+--------+\n| DYING: |\n+--------+\n\tWhen you die, the weapon you were using (except for the gauntlet and the machine gun), and any active power ups drop where you died.  Armor, ammo and one-use items like the teleporter are lost.  To respawn into the game, press the fire key. When you re-enter the game you are once again armed with only your starting equipment.\n\n===========================\n== Section 8.            ==\n== THE ARENA ENVIRONMENT ==\n===========================\n\n+-----------------------+\n| RAPID TRANSIT DEVICES |\n+-----------------------+\nTELEPORTERS: These devices instantaneously move you to a pre-selected destination.\n\nPORTALS:  These are devices that generate holes in space through which you can see your ultimate destination and move to it like walking through a doorway.\n\nJUMP PADS: Jump pads throw you upwards to land on higher portions of the arena.  You have some \"air\" control over your final landing point.\n\nACCELERATION PADS: Acceleration pads turn you into a human cannon ball, launching you to distant locations in the arena. As with the jump pads, you have some \"air\" control over your final landing point.\n\n+-----------------------+\n| ENVIRONMENTAL HAZARDS |\n+-----------------------+\nLAVA:  Walking on lava is not instantly fatal, but even with good armor protection, it can be a relatively quick (and noisy) doom.\n\nTHE VOID: Falling off into the infinite blackness of the void is a near inescapable death.\n\n+--------------+\n| TEST ARSENAL |\n+--------------+\nMACHINE GUN: This is your default weapon. It's an instant hit attack and reasonably accurate even at long range. It uses bullets.\n\nGAUNTLET:  This is either your weapon of last resort when you're out of ammo or a cool tool to humiliate other players. When it hits, it does damage and knocks a foe back. It does not require ammunition, but you have to be in direct contact with a foe and activating (firing) it to cause injury and knockback.\n\nSHOTGUN:  This uses shells for ammunition. The spread of the shotgun blast makes it deadly in close combat, but not the best choice for long-range attacks.\n\nROCKET LAUNCHER: The rocket launcher delivers heavy fire power to your target, but travels slower compared to other attacks.  Be careful when you use this weapon in close combat.\n\nPLASMA GUN: Powered by Energy cells, this rapid-fire weapon delivers deadly gouts of glowing energy quickly and accurately.  \n\nRAIL GUN:  The Rail Gun fires depleted uranium slugs at super high velocities. It hits instantly and can pass through the bodies of multiple opponents. But be warned, it recharges slowly and can be a liability in close combat. Take note of the distinctive trail of atmospheric disturbance \ncaused by the projectile. The color of the rail gun's trail can be changed under the CUSTOMIZE PLAYER menu on the EFFECTS COLOR line. \n\nLIGHTNING GUN: Zap them!\n\n+------------------+\n| COMBAT SUPPLIES: |\n+------------------+\nPick up these helpful items whenever possible. Some items take effect when \npicked up, others you must activate during play.\n\nAMMO:  With the exception of the gauntlet, each weapon has a corresponding ammo type. The color of the ammo boxes corresponds with the color of the graphic weapon icons displayed briefly in your heads up display. Each ammo type has a maximum you can carry. \n\nARMOR:  There are three armor types: Green armor shards, yellow combat armor and red body armor. Collecting them increases your armor protection.  The red armor and the green armor shards can increase your total armor protection above the maximum for short duration.  The points \"decay\" back to the normal maximum value.\n\nHEALTH:  There are three types of standard health kits: small (green), medium (yellow) and large (red) encased in crystalline shells. The green health can increase your total health value above the maximum.  Like armor, it \"decays\" back to your maximum possible health value.\n\nQUAD DAMAGE: The quad temporarily multiplies all your weapon's strengths. \n\nMEGA HEALTH: This blue health power up provides a temporary but significant boost to your health, taking it above your maximum level.  Like armor, it \"decays\" back to your maximum possible health value.\n\nPERSONAL TELEPORTER: Grab this single-use power up and use it to escape from dangerous situations.  Activating it immediately teleports you to one of the arena's spawn spots.\n\n=======================\n== Section 9.        ==\n== THE GAME CONSOLE  ==\n=======================\n\n\tThe game console (or just the console) is a pull down window shade that shows recent game information, including the text of conversations and recently executed game commands.  The bottom line of the console is the command line. While playing Q3test, you can enter into console mode by pressing the tilde (~) key and exit by pressing it again. The console is where you enter all the commands to change the game state.\n\n\tFor example, one console command is \"map <name>\" which will load a map\nand start it up.  Starting up a map actually starts a local Server and a Client. For the purposes of this test, most of the console commands will be executed to optimize graphics. Pressing the up and down arrows in the console will change to the last command entered. You can backspace over the command and enter new values if you'd like. There is also a command-completion function.  Type in the first few letters of a command. By pressing the TAB key, you can have the console automatically finish the name of the command for you. \n\n\tWhen you are in console mode (or when you have selected to \"talk\" by typing in words to appear on the screen), a blue \"voice balloon\" will appear over your head. Common game courtesy is to NOT shoot players who are in this mode.\n\n=======================\n== Section 10.       ==\n== PROBLEM ICONS     ==\n=======================\n\nQ3Test has a Problem Icon that you may see on your screen from time to time. When you are disconnected from a Quake Server or the network packet flow is disturbed, you will see a Network Disconnect icon above the spot where your frag count is displayed.  Other players will see it displayed over your character's head (similar to the way the talk balloon is displayed). If you are not immediately reconnected to the server, you will need to disconnect (leave arena) and attempt to reconnect with the server by either using the menu commands or by typing \"connect\" <server IP address> in the console command line.\n\tNOTE:  Courteous players will refrain from getting cheap points by fragging lagged out opponents.\n\n=======================\n== Section 11.       ==\n== MESSAGE OF THE DAY     ==\n=======================\n\nWhen Quake 3 Arena starts a map up, it sends the GL_RENDERER string to the Message Of The Day server at id.  This responds back with a message of the day to the client.  If you wish to switch this option off, set CL_MOTD to 0 (+set CL_MOTD 0 from the command line). \n\n"
  },
  {
    "path": "code/unix/build_setup.sh",
    "content": "#!/bin/bash\n# Build various setups..\n\n# inputs: \n#   directory with the common media\nQ3SETUPMEDIA=/home/timo/Id/Q3SetupMedia/quake3\n#   directory with binaries tree\nQ3BINARIES=../install\n#   version: $1\nVERSION=$1\n#   temporary directory used to prepare the files\n#   NOTE: this dir is erased before a new setup is built\nTMPDIR=setup.tmp\n\n# location of the setup dir (for graphical installer and makeself)\nSETUPDIR=setup\n\n# cp setup phase\n# we need to copy the symlinked files, and not the symlinks themselves\n# on antares this is forced with a cp -L\n# on spoutnik, -L is not recognized, and dereference is the default behaviour\n# we need a robust way of checking\nTESTFILE=/tmp/foo$$\ntouch $TESTFILE\n# see if option is supported\ncp -L $TESTFILE $TESTFILE.cp 2>/dev/null\nif [ $? -eq 1 ]\nthen\n  # option not supported, should be on by default\n  echo \"cp doesn't have -L option\"\n  unset CPOPT\nelse\n  # option supported, use it\n  echo \"cp supports -L option\"\n  CPOPT=\"-L\"\nfi\nrm $TESTFILE\n\n\n# graphical installer (based on Loki Software's Setup tool)\nbuild_installer ()\n{\nTMPDIR=setup.tmp\n\nrm -rf $TMPDIR\nmkdir $TMPDIR\n\n# copy base setup files\ncp $CPOPT -R $SETUPDIR/setup.sh $SETUPDIR/setup.data $TMPDIR\n\n# copy media files\ncp $CPOPT -R $Q3SETUPMEDIA/* $TMPDIR\n\n# remove CVS entries\nfind $TMPDIR -name CVS | xargs rm -rf\n\n# copy binaries\nmkdir -p $TMPDIR/bin/x86\n# smp\ncp $CPOPT $Q3BINARIES/linuxquake3-smp $TMPDIR/bin/x86/quake3-smp.x86\nstrip $TMPDIR/bin/x86/quake3-smp.x86\nbrandelf -t Linux $TMPDIR/bin/x86/quake3-smp.x86\n# old school\ncp $CPOPT $Q3BINARIES/linuxquake3 $TMPDIR/bin/x86/quake3.x86\nstrip $TMPDIR/bin/x86/quake3.x86\nbrandelf -t Linux $TMPDIR/bin/x86/quake3.x86\n# ded\ncp $CPOPT $Q3BINARIES/linuxq3ded $TMPDIR/bin/x86/q3ded\nstrip $TMPDIR/bin/x86/q3ded\nbrandelf -t Linux $TMPDIR/bin/x86/q3ded\n\n# PB files\nmkdir -p $TMPDIR/pb/htm\ncp $CPOPT ../pb/linux/*.so $TMPDIR/pb\ncp $CPOPT ../pb/htm/*.htm $TMPDIR/pb/htm\n\n# Linux FAQ\nmkdir -p $TMPDIR/Docs/LinuxFAQ\ncp $CPOPT LinuxSupport/* $TMPDIR/Docs/LinuxFAQ\n\n# generated .qvm pk3 files\nmkdir -p $TMPDIR/baseq3\nmkdir -p $TMPDIR/missionpack\n# not needed now\n#cp $CPOPT $Q3BINARIES/baseq3/pak8.pk3 $TMPDIR/baseq3/\n#cp $CPOPT $Q3BINARIES/missionpack/pak3.pk3 $TMPDIR/missionpack/\n\n# menu shortcut to the game\n# FIXME current setup doesn't have a way to set symlinks on arbitrary things\n# so we use a dummy quake3 script (which will be overwritten by postinstall.sh)\necho -e \"#!/bin/sh\\necho \\\"If you read this, then the setup script failed miserably.\\nPlease report to ttimo@idsoftware.com\\n\\\"\" > $TMPDIR/bin/x86/quake3\necho -e \"#!/bin/sh\\necho \\\"If you read this, then the setup script failed miserably.\\nPlease report to ttimo@idsoftware.com\\n\\\"\" > $TMPDIR/bin/x86/quake3-smp\n# create the auto-extractible archive\n# first step: on FreeBSD we would default to Linux binaries .. use a symlink\n(\ncd $TMPDIR/setup.data/bin\nln -s Linux FreeBSD\nln -s Linux NetBSD\nln -s Linux OpenBSD\n)\n# NOTE: we used to pass the $VERSION, but it doesn't seem very usefull\n./$SETUPDIR/makeself/makeself.sh $TMPDIR linuxq3apoint-$VERSION.x86.run \"Quake III Arena Point Release $VERSION \" ./setup.sh\n\nchmod a+rx linuxq3apoint-$VERSION.x86.run\n\n#rm -rf $TMPDIR\n}\n\ncheck_brandelf()\n{\n  # make sure brandelf is installed to avoid any problem when building the setups\n  BRAND=`which brandelf`;\n  if [ -n \"$BRAND\" ] && [ -x \"$BRAND\" ]\n  then\n    echo \"brandelf is present: $BRAND\"\n  else\n    echo \"brandelf not found\"\n    exit\n  fi\n}\n\n# safe checks\ncheck_brandelf\n\nbuild_installer\n"
  },
  {
    "path": "code/unix/cons",
    "content": "#!/usr/bin/env perl\n\n# NOTE:  Cons intentionally does not use the \"perl -w\" option or\n# \"use strict.\"  Because Cons \"configuration files\" are actually\n# Perl scripts, enabling those restrictions here would force them\n# on every user's config files, wanted or not.  Would users write\n# \"better\" Construct and Conscript files if we forced \"use strict\"\n# on them?  Probably.  But we want people to use Cons to get work\n# done, not force everyone to become a Perl guru to use it, so we\n# don't insist.\n#\n# That said, Cons' code is both \"perl -w\" and \"use strict\" clean.\n# Regression tests keep the code honest by checking for warnings\n# and \"use strict\" failures.\n\nuse vars qw( $CVS_id $CVS_ver $ver_num $ver_rev $version );\n\n$CVS_id = 'Id';\n$CVS_ver = (split(/\\s+/, $CVS_id))[2];\n\n$ver_num = \"2.3\";\n$ver_rev = \".1\";\n\n$version = \"This is Cons $ver_num$ver_rev ($CVS_id)\\n\";\n\n# Cons: A Software Construction Tool.\n# Copyright (c) 1996-2001 Free Software Foundation, Inc.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 2 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; see the file COPYING.  If not, write to\n# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n# Boston, MA 02111-1307, USA.\n\nrequire 5.003;\n# See the NOTE above about why Cons doesn't \"use strict\".\nuse integer;\nuse Cwd;\nuse File::Copy;\n\nuse vars qw( $_WIN32 $_a $_exe $_o $_so );\n\n#------------------------------------------------------------------\n# Determine if running on win32 platform - either Windows NT or 95\n#------------------------------------------------------------------\n\nuse vars qw( $PATH_SEPARATOR $iswin32 $_WIN32 $usage $indent @targets );\n\nBEGIN {\n    use Config;\n\n    # if the version is 5.003, we can check $^O\n    if ($] <  5.003) {\n\teval(\"require Win32\");\n\t$_WIN32 = (!$@);\n    } else {\n\t$_WIN32 = ($^O eq \"MSWin32\") ? 1 : 0;\n    }\n\n    # Fetch the PATH separator from Config;\n    # provide our old defaults in case it's not set.\n    $PATH_SEPARATOR = $Config{path_sep};\n    $PATH_SEPARATOR = $_WIN32 ? ';' : ':' if ! defined $PATH_SEPARATOR;\n\n    # Fetch file suffixes from Config,\n    # accomodating differences in the Config variables\n    # used by different Perl versions.\n    $_exe = $Config{_exe};\n    $_exe = $Config{exe_ext} if ! defined $_exe;\n    $_exe = $_WIN32 ? '.exe' : '' if ! defined $_exe;\n    $_o = $Config{_o};\n    $_o = $Config{obj_ext}  if ! defined $_o;\n    $_o = $_WIN32 ? '.obj' : '.o' if ! defined $_o;\n    $_a = $Config{_a};\n    $_a = $Config{lib_ext} if ! defined $_a;\n    $_a = $_WIN32 ? '.lib' : '.a' if ! defined $_a;\n    $_so = \".$Config{so}\";\n    $_so = $_WIN32 ? '.dll' : '.so' if ! defined $_so;\n}\n\n# Flush stdout each time.\n$| = 1;\n\n# Seed random number generator.\nsrand(time . $$); # this works better than time ^ $$ in perlfunc manpage.\n\n$usage = q(\nUsage: cons <arguments> -- <construct-args>\n\nArguments can be any of the following, in any order:\n\n  <targets>\tBuild the specified targets. If <target> is a directory\n\t\trecursively build everything within that directory.\n\n  +<pattern>\tLimit the cons scripts considered to just those that\n\t\tmatch <pattern>. Multiple + arguments are accepted.\n\n  <name>=<val>\tSets <name> to value <val> in the ARG hash passed to the\n\t\ttop-level Construct file.\n\n  -cc           Show command that would have been executed, when\n\t\tretrieving from cache. No indication that the file\n\t\thas been retrieved is given; this is useful for\n\t\tgenerating build logs that can be compared with\n\t\treal build logs.\n\n  -cd           Disable all caching. Do not retrieve from cache nor\n\t\tflush to cache.\n\n  -cr           Build dependencies in random order. This is useful when\n\t\tbuilding multiple similar trees with caching enabled.\n\n  -cs           Synchronize existing build targets that are found to be\n\t\tup-to-date with cache. This is useful if caching has\n\t\tbeen disabled with -cc or just recently enabled with\n\t\tUseCache.\n\n  -d            Enable dependency debugging.\n\n  -f <file>\tUse the specified file instead of \"Construct\" (but first\n\t\tchange to containing directory of <file>).\n\n  -h            Show a help message local to the current build if\n\t\tone such is defined,  and exit.\n\n  -k\t\tKeep going as far as possible after errors.\n\n  -o <file>\tRead override file <file>.\n\n  -p\t\tShow construction products in specified trees.\n  -pa\t\tShow construction products and associated actions.\n  -pw\t\tShow products and where they are defined.\n\n  -q\t\tBe quiet; multiple -q flags increase quietness level:\n\t\t1: quiet about Installing and Removing targets\n\t\t2: quiet about build commands, up-to-date targets\n\n  -r\t\tRemove construction products associated with <targets>\n\n  -R <repos>\tSearch for files in <repos>.  Multiple -R <repos>\n\t\tdirectories are searched in the order specified.\n\n  -S <pkg>\tUse package sig::<pkg> to calculate file signatures.\n\t\tCurrently supported values are \"md5\" for MD5\n\t\tsignatures (the default) and \"md5::debug\" for MD5\n\t\tsignature debug information.\n\n  -t            Traverse up the directory hierarchy looking for a\n\t\tConstruct file, if none exists in the current directory.\n\t\t(Targets will be modified to be relative to the\n\t\tConstruct file.)\n\n  -v\t\tShow cons version and continue processing.\n  -V            Show cons version and exit.\n\n  -wf <file>    Write all filenames considered into <file>.\n\n  -x\t\tShow this message and exit.\n\n\n   Please report any suggestions through the cons-discuss@gnu.org mailing\n   list.\n\n   To subscribe, send mail to cons-discuss-request@gnu.org with body\n   'subscribe'.\n\n   If you find a bug, please report it through the bug-cons@gnu.org\n   mailing list.\n\n   Information about CONS can be obtained from the official cons web site\n   http://www.dsmit.com/cons/ or its mirrors (listed there).\n\n   The cons maintainers can be contacted by email at cons-maintainers@gnu.org\n\n   User documentation of cons is contained in cons and can be obtained\n   by doing 'perldoc /path/to/cons'.\n\n);\n\n# Simplify program name, if it is a path.\n{\n    my ($vol, $dir, $file) = File::Spec->splitpath(File::Spec->canonpath($0));\n    $0 = $file;\n}\n\n# Default parameters.\n$param::topfile = 'Construct';\t# Top-level construction file.\n$param::install = 1;\t\t# Show installations\n$param::build = 1;\t\t# Build targets\n### $param::show = 1;\t\t# Show building of targets.\n$param::sigpro = 'md5';\t\t# Signature protocol.\n$param::depfile = '';\t\t# Write all deps out to this file\n$param::salt = '';\t\t# Salt derived file signatures with this.\n$param::sourcesig = ['*' => 'content'];# Source file signature calculation\n$param::rep_sig_times_ok = 1;\t# Repository .consign times are in sync\n\t\t\t\t#   w/files.\n$param::conscript_chdir = 0;\t# Change dir to Conscript directory\n$param::quiet = 0;\t\t# should we show the command being executed.\n\n@param::defaults = ();\n\n#\n$indent = '';\n\n# Display a command while executing or otherwise. This\n# should be called by command builder action methods.\nsub showcom {\n    print($indent . $_[0] . \"\\n\") if ($param::quiet < 2);\n}\n\n# Default environment.\n# This contains only the completely platform-independent information\n# we can figure out.  Platform-specific information (UNIX, Win32)\n# gets added below.\n@param::base = (\n     'SIGNATURE'    => [ '*' => 'build' ],\n     'SUFEXE'\t    => $_exe,\t\t\t\t# '' on UNIX systems\n     'SUFLIB'\t    => $_a,\t\t\t\t# '.a' on UNIX systems\n     'SUFLIBS'      => \"$_so:$_a\",\t\t\t# '.so:.a' on UNIX\n     'SUFOBJ'\t    => $_o,\t\t\t\t# '.o' on UNIX systems\n     'SUFMAP'       => {\n\t '.c'  => 'build::command::cc',\n\t '.s'  => 'build::command::cc',\n\t '.S'  => 'build::command::cc',\n\t '.C'  => 'build::command::cxx',\n\t '.cc' => 'build::command::cxx',\n\t '.cxx'=> 'build::command::cxx',\n\t '.cpp'=> 'build::command::cxx',\n\t '.c++'=> 'build::command::cxx',\n\t '.C++'=> 'build::command::cxx',\n     },\n     'PERL'\t    => $^X,\n);\n\n%param::rulesets =\n    (\n     # Defaults for Win32.\n     # Defined for VC++ 6.0 by Greg Spencer <greg_spencer@acm.org>\n     # Your mileage may vary.\n     'msvc' => [\n\t\t'CC'             => 'cl',\n\t\t'CFLAGS'         => '/nologo',\n\t\t'CCCOM'          => '%CC %CFLAGS %_IFLAGS /c %< /Fo%>',\n\t\t'CXX'            => '%CC',\n\t\t'CXXFLAGS'       => '%CFLAGS',\n\t\t'CXXCOM'         => '%CXX %CXXFLAGS %_IFLAGS /c %< /Fo%>',\n\t\t'INCDIRPREFIX'   => '/I',\n\t\t'INCDIRSUFFIX'   => '',\n\t\t'LINK'           => 'link',\n\t\t'LINKCOM'        => '%LINK %LDFLAGS /out:%> %< %_LDIRS %LIBS',\n\t\t'LINKMODULECOM'  => '%LD /r /o %> %<',\n\t\t'LIBDIRPREFIX'   => '/LIBPATH:',\n\t\t'LIBDIRSUFFIX'   => '',\n\t\t'AR'             => 'lib',\n\t\t'ARFLAGS'        => '/nologo ',\n\t\t'ARCOM'          => \"%AR %ARFLAGS /out:%> %<\",\n\t\t'RANLIB'         => '',\n\t\t'LD'             => 'link',\n\t\t'LDFLAGS'        => '/nologo ',\n\t\t'PREFLIB'        => '',\n\t\t],\n     # Defaults for a typical (?) UNIX platform.\n     # Your mileage may vary.\n     'unix' => [\n\t\t'CC'             => 'cc',\n\t\t'CFLAGS'         => '',\n\t\t'CCCOM'          => '%CC %CFLAGS %_IFLAGS -c %< -o %>',\n\t\t'CXX'            => '%CC',\n\t\t'CXXFLAGS'       => '%CFLAGS',\n\t\t'CXXCOM'         => '%CXX %CXXFLAGS %_IFLAGS -c %< -o %>',\n\t\t'INCDIRPREFIX'   => '-I',\n\t\t'INCDIRSUFFIX'   => '',\n\t\t'LINK'           => '%CXX',\n\t\t'LINKCOM'        => '%LINK %LDFLAGS -o %> %< %_LDIRS %LIBS',\n\t\t'LINKMODULECOM'  => '%LD -r -o %> %<',\n\t\t'LIBDIRPREFIX'   => '-L',\n\t\t'LIBDIRSUFFIX'   => '',\n\t\t'AR'             => 'ar',\n\t\t'ARFLAGS'        => 'r', # rs?\n\t\t'ARCOM'          => ['%AR %ARFLAGS %> %<', '%RANLIB %>'],\n\t\t'RANLIB'         => 'ranlib',\n\t\t'AS'             => 'as',\n\t\t'ASFLAGS'        => '',\n\t\t'ASCOM'          => '%AS %ASFLAGS %< -o %>',\n\t\t'LD'             => 'ld',\n\t\t'LDFLAGS'        => '',\n\t\t'PREFLIB'        => 'lib',\n\t\t'ENV'            => { 'PATH' => '/bin:/usr/bin' },\n\t\t],\n     );\n\n# Set the rules based on the platform.\nscript::DefaultRules(script::RuleSet($_WIN32 ? 'msvc' : 'unix'));\n\n# Handle command line arguments.\nwhile (@ARGV) {\n    $_ = shift @ARGV;\n    last if /^--$/;\t\t# Argument passing to Construct.\n    &option, next\t\t\tif s/^-//;\n    push (@param::include, $_), next\tif s/^\\+//;\n    &equate, next\t\t\tif /=/;\n    push (@targets, $_), next;\n}\n\nsub option {\n    my %opt = (\n\t\t    'cc' =>   sub { $param::cachecom = 1; },\n\t\t    'cd' =>   sub { $param::cachedisable = 1; },\n\t\t    'cr' =>   sub { $param::random = 1; },\n\t\t    'cs' =>   sub { $param::cachesync = 1; },\n\t\t    'd' =>    sub { $param::depends = 1; },\n\t\t    'h' =>    sub { $param::localhelp = 1; },\n\t\t    'k' =>    sub { $param::kflag = 1; },\n\t\t    'p' =>    sub { $param::pflag = 1;\n\t\t\t\t    $param::build = 0; },\n\t\t    'pa' =>   sub { $param::pflag = 1;\n\t\t\t\t    $param::aflag = 1;\n\t\t\t\t    $indent = \"... \";\n\t\t\t\t    $param::build = 0; },\n\t\t    'pw' =>   sub { $param::pflag = 1;\n\t\t\t\t    $param::wflag = 1;\n\t\t\t\t    $param::build = 0; },\n\t\t    'q' =>    sub { $param::quiet++; },\n\t\t    'r' =>    sub { $param::rflag = 1;\n\t\t\t\t    $param::build = 0; },\n\t\t    't' =>    sub { $param::traverse = 1; },\n\t\t    'v' =>    sub { print($version); },\n\t\t    'V' =>    sub { print($version), exit(0); },\n\t\t    'x' =>    sub { print($usage), exit 0; },\n\t\t);\n\n    my %opt_arg = (\n\t\t    'f' =>    sub { $param::topfile = $_[0]; },\n\t\t    'o' =>    sub { $param::overfile = $_[0]; },\n\t\t    'R' =>    sub { script::Repository($_[0]); },\n\t\t    'S' =>    sub { $param::sigpro = $_[0]; },\n\t\t    'wf' =>   sub { $param::depfile = $_[0]; },\n\t\t);\n\n    if (defined $opt{$_}) {\n\t&{$opt{$_}}();\n\treturn;\n    }\n    while ($_) {\n\t$_  =~ m/(.)(.*)/;\n\tif (defined $opt{$1}) {\n\t    &{$opt{$1}}();\n\t    $_ = $2;\n\t    next;\n\t}\n\tif (defined $opt_arg{$1}) {\n\t    if (! $2) {\n\t\t$_ = shift @ARGV;\n\t\tdie(\"$0: -$1 option requires an argument.\\n\") if ! $_;\n\t    }\n\t    &{$opt_arg{$1}}($2 || $_);\n\t    return;\n\t}\n\t$_  =~ m/(..)(.*)/;\n\tif (defined $opt_arg{$1}) {\n\t    if (! $2) {\n\t\t$_ = shift @ARGV;\n\t\tdie(\"$0: -$1 option requires an argument.\\n\") if ! $_;\n\t    }\n\t    &{$opt_arg{$1}}($2 || $_);\n\t    return;\n\t}\n\tif ($_) {\n\t    die qq($0: unrecognized option \"-$_\".  Use -x for a usage message.\\n);\n\t}\n    }\n}\n\n# Process an equate argument (var=val).\nsub equate {\n    my($var, $val) = /([^=]*)=(.*)/;\n    $script::ARG{$var} = $val;\n}\n\n# Define file signature protocol.\n'sig'->select($param::sigpro);\n\n# Cleanup after an interrupt.\n$SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {\n    $SIG{PIPE} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = 'IGNORE';\n    $SIG{HUP} = $SIG{INT} if ! $main::_WIN32;\n    warn(\"\\n$0: killed\\n\");\n    # Call this first, to make sure that this processing\n    # occurs even if a child process does not die (and we\n    # hang on the wait).\n    sig::hash::END();\n    wait();\n    exit(1);\n};\n$SIG{HUP} = $SIG{INT} if ! $main::_WIN32;\n\n# Cleanup after a broken pipe (someone piped our stdout?)\n$SIG{PIPE} = sub {\n    $SIG{PIPE} = $SIG{HUP} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = 'IGNORE';\n    warn(\"\\n$0: broken pipe\\n\");\n    sig::hash::END();\n    wait();\n    exit(1);\n};\n\nif ($param::depfile) {\n  open (main::DEPFILE, \">\".$param::depfile) ||\n    die (\"$0: couldn't open $param::depfile ($!)\\n\");\n}\n\n# If the supplied top-level Conscript file is not in the\n# current directory, then change to that directory.\n{\n    my ($vol, $dir, $file) =\n      File::Spec->splitpath(File::Spec->canonpath($param::topfile));\n    if ($vol || $dir) {\n\tmy($cd) = File::Spec->catpath($vol, $dir, undef);\n\tchdir($cd) || die(\"$0: couldn't change to directory $cd ($!)\\n\");\n\t$param::topfile = $file;\n    }\n}\n\n# Walk up the directory hierarchy looking for a Conscript file (if -t set).\nmy($target_top);\nmy(@targetdir) = ();\nif ($param::traverse && ! -f $param::topfile) {\n    my($vol, $dirs, $file) = File::Spec->splitpath(cwd());\n    my(@dirs) = (File::Spec->splitdir($dirs), $file);\n    while (! -f File::Spec->catpath($vol, File::Spec->catdir(@dirs),\n\t\t\t\t    $param::topfile)) {\n\tdie(\"$0: unable to find $param::topfile.\\n\") if ! @dirs;\n\tunshift(@targetdir, pop(@dirs));\n    }\n    my($cwd) = File::Spec->catpath($vol, File::Spec->catdir(@dirs), '');\n    print \"$0: Entering directory `$cwd'\\n\";\n    chdir($cwd);\n    @targets = map {File::Spec->catdir(@targetdir, $_)} @targets;\n}\n\n# Set up $dir::top and $dir::cwd, now that we are in the right directory.\ndir::init();\n\n#\nif (@targetdir) {\n    $target_top = $dir::top->lookupdir(File::Spec->catdir(@targetdir));\n}\n\n# Now handle override file.\npackage override;\nif ($param::overfile) {\n    my($ov) = $param::overfile;\n    die qq($0: can\\'t read override file \"$ov\" ($!)\\n) if ! -f $ov; #'\n    do $ov;\n    if ($@) {\n\tchop($@);\n\tdie qq($0: errors in override file \"$ov\" ($@)\\n);\n    }\n}\n\n# Provide this to user to setup override patterns.\nsub Override {\n    my($re, @env) = @_;\n    return if $param::overrides{$re}; # if identical, first will win.\n    $param::overrides = 1;\n    $param::overrides{$re} = \\@env;\n    push(@param::overrides, $re);\n}\n\npackage main;\n\nuse vars qw( %priority $errors );\n\n# Check script inclusion regexps\nmy $re;\nfor $re (@param::include) {\n    if (! defined eval {\"\" =~ /$re/}) {\n\tmy($err) = $@;\n\t$err =~ s/in regexp at .*$//;\n\tdie(\"$0: error in regexp $err\");\n    }\n}\n\n# Read the top-level construct file and its included scripts.\ndoscripts($param::topfile);\n\n# Status priorities. This lets us aggregate status for directories\n# and print an appropriate message (at the top-level).\n%priority =\n    ('none' => 1, 'handled' => 2, 'built' => 3, 'unknown' => 4, 'errors' => 5);\n\n# If no targets were specified, supply default targets (if any).\n@targets = @param::default_targets if ! @targets;\n\n$errors = 0;\n\n# Build the supplied target patterns.\nmy $tgt;\nfor $tgt (map($dir::top->lookup($_), @targets)) {\n    if ($target_top && ! $tgt->is_under($target_top)) {\n\t# A -t option was used, and this target is not underneath\n\t# the directory where we were invoked via -t.\n\t# If the target is a directory and the -t directory\n\t# is underneath it, then build the -t directory.\n\tif (ref $tgt ne \"dir\" || ! $target_top->is_under($tgt)) {\n\t    next;\n\t}\n\t$tgt = $target_top;\n    }\n    buildtoptarget($tgt);\n}\n\nexit 0 + ($errors != 0);\n\nsub buildtoptarget {\n    my($tgt) = @_;\n    return if ! $tgt;\n    my($status) = buildtarget($tgt);\n    if ($status ne 'built') {\n\tmy($path) = $tgt->path;\n\tif ($status eq \"errors\") {\n\t    print qq($0: \"$path\" not remade because of errors.\\n);\n\t    $errors++;\n\t} elsif ($status eq \"handled\") {\n\t    print qq($0: \"$path\" is up-to-date.\\n) if ($param::quiet < 2);\n\t} elsif ($status eq \"unknown\") {\n\t    # cons error already reported.\n\t    $errors++;\n\t} elsif ($status eq \"none\") {\n\t    # search for targets that may be linked to the given path.\n\t    my @linked = dir::linked_targets($tgt) if $target_top;\n\t    if (@linked) {\n\t\tmy @names = map($_->path, @linked);\n\t\tprint \"Linked targets: @names\\n\" if ($param::quiet < 1);\n\t\tmap(buildtoptarget($_), @linked);\n\t    } else {\n\t\tprint qq($0: nothing to be built in \"$path\".\\n)\n\t\t      if $param::build && ($param::quiet < 2);\n\t    }\n\t} else {\n\t    print qq($0: don\\'t know how to construct \"$path\".\\n); #'\n\t    $errors++;\n\t}\n    }\n}\n\n# Build the supplied target directory or files. Return aggregated status.\nsub buildtarget {\n    my($tgt) = @_;\n    if (ref($tgt) eq \"dir\") {\n\tmy($result) = \"none\";\n\tmy($priority) = $priority{$result};\n\tif (exists $tgt->{member}) {\n\t    my($members) = $tgt->{member};\n\t    my $entry;\n\t    for $entry (sort keys %$members) {\n\t\tnext if $entry eq $dir::CURDIR || $entry eq $dir::UPDIR;\n\t\tmy($tgt) = $members->{$entry};\n\t\tnext if ref($tgt) ne \"dir\" && !exists($tgt->{builder});\n\t\tmy($stat) = buildtarget($members->{$entry});\n\t\tmy($pri) = $priority{$stat};\n\t\tif ($pri > $priority) {\n\t\t    $priority = $pri;\n\t\t    $result = $stat;\n\t\t}\n\t    }\n\t}\n\treturn $result;\n    }\n    if ($param::depends) {\n\tmy($path) = $tgt->path;\n\tif ($tgt->{builder}) {\n\t    my(@dep) = (@{$tgt->{dep}}, @{$tgt->{sources}});\n\t    my($dep) = join(' ',map($_->path, @dep));\n\t    print(\"Target $path: $dep\\n\");\n\t} else {\n\t    print(\"Target $path: not a derived file\\n\");\n\t}\n    }\n    if ($param::build) {\n\treturn build $tgt;\n    } elsif ($param::pflag || $param::wflag || $param::aflag) {\n\tif ($tgt->{builder}) {\n\t    if ($param::wflag) {\n\t\tprint qq(${\\$tgt->path}: $tgt->{script}\\n);\n\t    } elsif ($param::pflag) {\n\t\tprint qq(${\\$tgt->path}:\\n) if $param::aflag;\n\t\tprint qq(${\\$tgt->path}\\n) if !$param::aflag;\n\t    }\n\t    if ($param::aflag) {\n\t\t$tgt->{builder}->action($tgt);\n\t    }\n\t}\n    } elsif ($param::rflag && $tgt->{builder}) {\n\tmy($path) = $tgt->path;\n\tif (-f $path) {\n\t    if (unlink($path)) {\n\t\tprint(\"Removed $path\\n\") if ($param::quiet < 1);\n\t    } else {\n\t\twarn(\"$0: couldn't remove $path\\n\");\n\t    }\n\t}\n    }\n\n    return \"none\";\n}\n\npackage NameSpace;\n\n# Return a hash that maps the name of symbols in a namespace to an\n# array of refs for all types for which the name has a defined value.\n# A list of symbols may be specified; default is all symbols in the\n# name space.\nsub save {\n    my $package = shift;\n    my(%namerefs, $var, $type);\n    no strict 'refs';\n    @_ = keys %{$package.\"::\"} if ! @_;\n    foreach $var (@_) {\n\t$namerefs{$var} = [];\n\tmy $fqvar = $package.\"::\".$var;\n\t# If the scalar for this variable name doesn't already\n\t# exist, *foo{SCALAR} will autovivify the reference\n\t# instead of returning undef, so unlike the other types,\n\t# we have to dereference to find out if it exists.\n\tpush(@{$namerefs{$var}}, *{$fqvar}{SCALAR})\n\t\t    if defined ${*{$fqvar}{SCALAR}};\n\tforeach $type (qw(ARRAY HASH CODE IO)) {\n\t    push(@{$namerefs{$var}}, *{$fqvar}{$type})\n\t\t\t  if defined *{$fqvar}{$type};\n\t}\n    }\n    return \\%namerefs;\n}\n\n# Remove the specified symbols from the namespace.\n# Default is to remove all.\nsub remove {\n    my $package = shift;\n    my(%namerefs, $var);\n    no strict 'refs';\n    @_ = keys %{$package.\"::\"} if ! @_;\n    foreach $var (@_) {\n\tdelete ${$package.\"::\"}{$var};\n    }\n}\n\n# Restore values to symbols specified in a hash as returned\n# by NameSpace::save.\nsub restore {\n    my($package, $namerefs) = @_;\n    my($var, $ref);\n    no strict 'refs';\n    foreach $var (keys %$namerefs) {\n\tmy $fqvar = $package.\"::\".$var;\n\tforeach $ref (@{$namerefs->{$var}}) {\n\t    *{$fqvar} = $ref;\n\t}\n    }\n}\n\n# Support for \"building\" scripts, importing and exporting variables.\n# With the exception of the top-level routine here (invoked from the\n# main package by cons), these are all invoked by user scripts.\npackage script;\n\nuse vars qw( $ARG $caller_dir_path %special_var );\n\nBEGIN {\n    # We can't Export or Import the following variables because Perl always\n    # treats them as part of the \"main::\" package (see perlvar(1)).\n    %special_var = map {$_ => 1} qw(ENV INC ARGV ARGVOUT SIG\n\t\t\t\t    STDIN STDOUT STDERR);\n}\n\n# This is called from main to interpret/run the top-level Construct\n# file, passed in as the single argument.\nsub main::doscripts {\n    my($script) = @_;\n    Build($script);\n    # Now set up the includes/excludes (after the Construct file is read).\n    $param::include = join('|', @param::include);\n\n    # Save the original variable names from the script package.\n    # These will stay intact, but any other \"script::\" variables\n    # defined in a Conscript file will get saved, deleted,\n    # and (when necessary) restored.\n    my(%orig_script_var) = map {$_ => 1} keys %script::;\n    $caller_dir_path = undef;\n    my $cwd = Cwd::cwd();\n    my(@scripts) = pop(@priv::scripts);\n    while ($priv::self = shift(@scripts)) {\n\tmy($path) = $priv::self->{script}->rsrcpath;\n\tif (-f $path) {\n\t    $dir::cwd = $priv::self->{script}->{dir};\n\t    # Handle chdir to the Conscript file directory, if necessary.\n\t    my ($vol, $dir, $file);\n\t    if ($param::conscript_chdir) {\n\t\t($vol, $dir, $file) =\n\t\t  File::Spec->splitpath(File::Spec->canonpath($path));\n\t\tif ($vol ne '' || $dir ne '') {\n\t\t    $caller_dir_path = File::Spec->catpath($vol, $dir, undef);\n\t\t    chdir($caller_dir_path) ||\n\t\t\tdie \"Could not chdir to $caller_dir_path: $!\\n\";\n\t\t}\n\t    } else {\n\t\t$file = $path;\n\t    }\n\t    # Actually process the Conscript file.\n\t    do $file;\n\t    # Save any variables defined by the Conscript file\n\t    # so we can restore them later, if needed;\n\t    # then delete them from the script:: namespace.\n\t    my(@del) = grep(! $orig_script_var{$_}, keys %script::);\n\t    if (@del) {\n\t\t$priv::self->{script}->{pkgvars} = NameSpace::save('script',\n\t\t\t\t\t\t\t\t   @del);\n\t\tNameSpace::remove('script', @del);\n\t    }\n\t    if ($caller_dir_path) {\n\t\tchdir($cwd);\n\t\t$caller_dir_path = undef;\n\t    }\n\t    if ($@) {\n\t\tchomp($@);\n\t\tmy $err = ($@ =~ /\\n/ms) ? \":\\n$@\" : \" ($@)\";\n\t\tprint qq($0: error in file \"$path\"$err\\n);\n\t\t$run::errors++;\n\t    } else {\n\t\t# Only process subsidiary scripts if no errors in parent.\n\t\tunshift(@scripts, @priv::scripts);\n\t    }\n\t    undef @priv::scripts;\n\t} else {\n\t    my $where = '';\n\t    my $cref = $priv::self->{script}->creator;\n\t    if (defined $cref) {\n\t\tmy($_foo, $script, $line, $sub) = @$cref;\n\t\t$where = \" ($sub in $script, line $line)\";\n\t    }\n\t    warn qq(Ignoring missing script \"$path\"$where);\n\t}\n    }\n    die(\"$0: script errors encountered: construction aborted\\n\")\n\tif $run::errors;\n}\n\n# Return caller info about the method being invoked.\n# This is everything from the Perl \"caller\" builtin function,\n# including which Construct/Conscript file, line number,\n# subroutine name, etc.\nsub caller_info {\n    my($lev) = 1;\n    my(@frame);\n    do {\n\t@frame = caller ++$lev;\n\tif (defined($frame[3]) && $frame[3] eq '(eval)') {\n\t    @frame = caller --$lev;\n\t    if ($caller_dir_path) {\n\t\t$frame[1] = File::Spec->catfile($caller_dir_path, $frame[1]);\n\t    }\n\t    return @frame;\n\t}\n    } while ($frame[3]);\n    return;\n}\n\n# Link a directory to another. This simply means set up the *source*\n# for the directory to be the other directory.\nsub Link {\n    dir::link(@_);\n}\n\n# Add directories to the repository search path for files.\n# Strip our current directory from the list so Repository\n# (or -R options) can be used from within the repository.\nsub Repository {\n    my($my_dir) = Cwd::cwd();\n    my $dir;\n    foreach $dir (@_) {\n\t# The following more direct call isn't available in\n\t# Cwd.pm until some time after 5.003...\n\t#\tmy($d) = Cwd::abs_path($dir);\n\tchdir($dir);\n\tmy($d) = Cwd::cwd();\n\tchdir($my_dir);\n\t#\n\tnext if ! $d || ! -d $d || $d eq $my_dir;\n\t# We know we can get away with passing undef to lookupdir\n\t# as the directory because $dir is an absolute path.\n\tpush(@param::rpath, dir::lookupdir(undef, $dir));\n\tpush @INC, $d;\n    }\n}\n\n# Return the list of Repository directories specified.\nsub Repository_List {\n    map($_->path, @param::rpath);\n}\n\n# Specify whether the .consign signature times in repository files are,\n# in fact, consistent with the times on the files themselves.\nsub Repository_Sig_Times_OK {\n    $param::rep_sig_times_ok = shift;\n}\n\nsub SourceSignature {\n    $param::sourcesig = [@_];\n}\n\n# Specify whether we should chdir to the containing directories\n# of Conscript files.\nsub Conscript_chdir {\n    $param::conscript_chdir = shift;\n}\n\n# Specify files/targets that must be present and built locally,\n# even if they exist already-built in a Repository.\nsub Local {\n    my(@files) = map($dir::cwd->lookupfile($_), @_);\n    map($_->local(1), @files);\n}\n\n# Export variables to any scripts invoked from this one.\nsub Export {\n    my(@illegal) = grep($special_var{$_}, @_);\n    if (@illegal) {\n\tdie qq($0: cannot Export special Perl variables: @illegal\\n);\n    }\n    @{$priv::self->{exports}} = grep(! defined $special_var{$_}, @_);\n}\n\n# Import variables from the export list of the caller\n# of the current script.\nsub Import {\n    my(@illegal) = grep($special_var{$_}, @_);\n    if (@illegal) {\n\tdie qq($0: cannot Import special Perl variables: @illegal\\n);\n    }\n    my($parent) = $priv::self->{parent};\n    my($imports) = $priv::self->{imports};\n    @{$priv::self->{exports}} = keys %$imports;\n    my($var);\n    foreach $var (grep(! defined $special_var{$_}, @_)) {\n\tif (!exists $imports->{$var}) {\n\t    my($path) = $parent->{script}->path;\n\t    die qq($0: variable \"$var\" not exported by file \"$path\"\\n);\n\t}\n\tif (!defined $imports->{$var}) {\n\t    my $path = $parent->{script}->path;\n\t    my $err = \"$0: variable \\\"$var\\\" exported but not \" .\n\t\t      \"defined by file \\\"$path\\\"\\n\";\n\t    die $err;\n\t}\n\t${\"script::$var\"} = $imports->{$var};\n    }\n}\n\n# Build an inferior script. That is, arrange to read and execute\n# the specified script, passing to it any exported variables from\n# the current script.\nsub Build {\n    my(@files) = map($dir::cwd->lookupfile($_), @_);\n    my(%imports) = map {$_ => ${\"script::$_\"}} @{$priv::self->{exports}};\n    my $file;\n    for $file (@files) {\n\tnext if $param::include && $file->path !~ /$param::include/o;\n\tmy($self) = {'script' => $file,\n\t\t     'parent' => $priv::self,\n\t\t     'imports' => \\%imports};\n\tbless $self;  # may want to bless into class of parent in future\n\tpush(@priv::scripts, $self);\n    }\n}\n\n# Set up regexps dependencies to ignore. Should only be called once.\nsub Ignore {\n    die(\"Ignore called more than once\\n\") if $param::ignore;\n    $param::ignore = join(\"|\", map(\"($_)\", @_)) if @_;\n}\n\n# Specification of default targets.\nsub Default {\n    push(@param::default_targets, map($dir::cwd->lookup($_)->path, @_));\n}\n\n# Local Help.  Should only be called once.\nsub Help {\n    if ($param::localhelp) {\n\tprint \"@_\\n\";\n\texit 2;\n    }\n}\n\n# For windows platforms which use unix tool sets, the msvc defaults may\n# not be useful. Also, in the future, other platforms (Mac?) may have the\n# same problem.\nsub RuleSet {\n    my $style = shift;\n    my @rulesets = sort keys %param::rulesets;\n    die \"Unknown style for rules: $style.\\n\" .\n\t\"Supported rules are: (\" . join(\" \", @rulesets) . \")\"\n\t    unless eval(join(\"||\", map(\"\\$style eq '$_'\", @rulesets)));\n    return @param::base, @{$param::rulesets{$style}};\n}\n\nsub DefaultRules {\n    @param::defaults = ();\n    push @param::defaults, @_;\n}\n\n# Return the build name(s) of a file or file list.\nsub FilePath {\n    wantarray\n\t? map($dir::cwd->lookupfile($_)->path, @_)\n\t: $dir::cwd->lookupfile($_[0])->path;\n}\n\n# Return the build name(s) of a directory or directory list.\nsub DirPath {\n    wantarray\n\t? map($dir::cwd->lookupdir($_)->path, @_)\n\t: $dir::cwd->lookupdir($_[0])->path;\n}\n\n# Split the search path provided into components. Look each up\n# relative to the current directory.\n# The usual path separator problems abound; for now we'll use :\nsub SplitPath {\n    my($dirs) = @_;\n    if (ref($dirs) ne \"ARRAY\") {\n\t$dirs = [ split(/$main::PATH_SEPARATOR/o, $dirs) ];\n    }\n    map { DirPath($_) } @$dirs;\n}\n\n# Return true if the supplied path is available as a source file\n# or is buildable (by rules seen to-date in the build).\nsub ConsPath {\n    my($path) = @_;\n    my($file) = $dir::cwd->lookup($path);\n    return $file->accessible;\n}\n\n# Return the source path of the supplied path.\nsub SourcePath {\n    wantarray\n\t? map($dir::cwd->lookupfile($_)->rsrcpath, @_)\n\t: $dir::cwd->lookupfile($_[0])->rsrcpath;\n}\n\n# Search up the tree for the specified cache directory, starting with\n# the current directory. Returns undef if not found, 1 otherwise.\n# If the directory is found, then caching is enabled. The directory\n# must be readable and writable. If the argument \"mixtargets\" is provided,\n# then targets may be mixed in the cache (two targets may share the same\n# cache file--not recommended).\nsub UseCache($@) {\n    my($dir, @args) = @_;\n    # NOTE: it's important to process arguments here regardless of whether\n    # the cache is disabled temporarily, since the mixtargets option affects\n    # the salt for derived signatures.\n    for (@args) {\n\tif ($_ eq \"mixtargets\") {\n\t    # When mixtargets is enabled, we salt the target signatures.\n\t    # This is done purely to avoid a scenario whereby if\n\t    # mixtargets is turned on or off after doing builds, and\n\t    # if cache synchronization with -cs is used, then\n\t    # cache files may be shared in the cache itself (linked\n\t    # under more than one name in the cache). This is not bad,\n\t    # per se, but simply would mean that a cache cleaning algorithm\n\t    # that looked for a link count of 1 would never find those\n\t    # particular files; they would always appear to be in use.\n\t    $param::salt = 'M' . $param::salt;\n\t    $param::mixtargets = 1;\n\t} else {\n\t    die qq($0: UseCache unrecognized option \"$_\"\\n);\n\t}\n    }\n    if ($param::cachedisable) {\n\twarn(\"Note: caching disabled by -cd flag\\n\");\n\treturn 1;\n    }\n    my($depth) = 15;\n    while ($depth-- && ! -d $dir) {\n\t$dir = File::Spec->catdir($dir::UPDIR, $dir);\n    }\n    if (-d $dir) {\n\t$param::cache = $dir;\n\treturn 1;\n    }\n    return undef;\n}\n\n# Salt the signature generator. The salt (a number of string) is added\n# into the signature of each derived file. Changing the salt will\n# force recompilation of all derived files.\nsub Salt($) {\n    # We append the value, so that UseCache and Salt may be used\n    # in either order without changing the signature calculation.\n    $param::salt .= $_[0];\n}\n\n# Mark files (or directories) to not be removed before building.\nsub Precious {\n    map($_->{precious} = 1, map($dir::cwd->lookup($_), @_));\n}\n\n\f\n# These methods are callable from Conscript files, via a cons\n# object. Procs beginning with _ are intended for internal use.\npackage cons;\n\nuse vars qw( %envcache );\n\n# This is passed the name of the base environment to instantiate.\n# Overrides to the base environment may also be passed in\n# as key/value pairs.\nsub new {\n    my($package) = shift;\n    my ($env) = {@param::defaults, @_};\n    @{$env->{_envcopy}} = %$env; # Note: we never change PATH\n    $env->{_cwd} = $dir::cwd; # Save directory of environment for\n    bless $env, $package;\t# any deferred name interpretation.\n}\n\n# Clone an environment.\n# Note that the working directory will be the initial directory\n# of the original environment.\nsub clone {\n    my($env) = shift;\n    my $clone = {@{$env->{_envcopy}}, @_};\n    @{$clone->{_envcopy}} = %$clone; # Note: we never change PATH\n    $clone->{_cwd} = $env->{_cwd};\n    bless $clone, ref $env;\n}\n\n# Create a flattened hash representing the environment.\n# It also contains a copy of the PATH, so that the path\n# may be modified if it is converted back to a hash.\nsub copy {\n    my($env) = shift;\n    (@{$env->{_envcopy}}, 'ENV' => {%{$env->{ENV}}}, @_)\n}\n\n# Resolve which environment to actually use for a given\n# target. This is just used for simple overrides.\nsub _resolve {\n    return $_[0] if !$param::overrides;\n    my($env, $tgt) = @_;\n    my($path) = $tgt->path;\n    my $re;\n    for $re (@param::overrides) {\n\tnext if $path !~ /$re/;\n\t# Found one. Return a combination of the original environment\n\t# and the override.\n\tmy($ovr) = $param::overrides{$re};\n\treturn $envcache{$env,$re} if $envcache{$env,$re};\n\tmy($newenv) = {@{$env->{_envcopy}}, @$ovr};\n\t@{$newenv->{_envcopy}} = %$env;\n\t$newenv->{_cwd} = $env->{_cwd};\n\treturn $envcache{$env,$re} = bless $newenv, ref $env;\n    }\n    return $env;\n}\n\n# Substitute construction environment variables into a string.\n# Internal function/method.\nsub _subst {\n    my($env, $str) = @_;\n    if (! defined $str) {\n\treturn undef;\n    } elsif (ref($str) eq \"ARRAY\") {\n\treturn [ map($env->_subst($_), @$str) ];\n    } else {\n\t# % expansion.  %% gets converted to % later, so expand any\n\t# %keyword construction that doesn't have a % in front of it,\n\t# modulo multiple %% pairs in between.\n\t# In Perl 5.005 and later, we could actually do this in one regex\n\t# using a conditional expression as follows,\n\t#\twhile ($str =~ s/($pre)\\%(\\{)?([_a-zA-Z]\\w*)(?(2)\\})/\"$1\".\n\t#                      $env->{$3}/ge) {}\n\t# The following two-step approach is backwards-compatible\n\t# to (at least) Perl5.003.\n\tmy $pre = '^|[^\\%](?:\\%\\%)*';\n\twhile (($str =~ s/($pre)\\%([_a-zA-Z]\\w*)/$1.($env->{$2}||'')/ge) ||\n\t       ($str =~ s/($pre)\\%\\{([_a-zA-Z]\\w*)\\}/$1.($env->{$2}||'')/ge)) {\n\t}\n\treturn $str;\n    }\n}\n\nsub AfterBuild {\n    my($env) = shift;\n    my($perl_eval_str) = pop(@_);\n    my $file;\n    for $file (map($dir::cwd->lookup($_), @_)) {\n\t$file->{after_build_func} = $perl_eval_str;\n    }\n}\n\nsub Install {\n    my($env) = shift;\n    my($tgtdir) = $dir::cwd->lookupdir($env->_subst(shift));\n    my $file;\n    for $file (map($dir::cwd->lookupfile($env->_subst($_)), @_)) {\n\tmy($tgt) = $tgtdir->lookupfile($file->{entry});\n\t$tgt->bind(find build::install($env), $file);\n    }\n}\n\nsub InstallAs {\n    my $env = shift;\n    my $tgt = shift;\n    my $src = shift;\n    my @sources = ();\n    my @targets = ();\n\n    if (ref $tgt) {\n\tdie \"InstallAs: Source is a file and target is a list!\\n\"\n\t    if (!ref($src));\n\t@sources = @$src;\n\t@targets = @$tgt;\n    } elsif (ref $src) {\n\tdie \"InstallAs: Target is a file and source is a list!\\n\";\n    } else {\n\tpush @sources, $src;\n\tpush @targets, $tgt;\n    }\n\n    if ($#sources != $#targets) {\n\tmy $tn = $#targets+1;\n\tmy $sn = $#sources+1;\n\tdie \"InstallAs: Source file list ($sn) and target file list ($tn) \" .\n\t    \"are inconsistent in length!\\n\";\n    } else {\n\tforeach (0..$#sources) {\n\t    my $tfile = $dir::cwd->lookupfile($env->_subst($targets[$_]));\n\t    my $sfile = $dir::cwd->lookupfile($env->_subst($sources[$_]));\n\t    $tfile->bind(find build::install($env), $sfile);\n\t}\n    }\n}\n\n# Installation in a local build directory,\n# copying from the repository if it's already built there.\n# Functionally equivalent to:\n#\tInstall $env $dir, $file;\n#\tLocal \"$dir/$file\";\nsub Install_Local {\n    my($env) = shift;\n    my($tgtdir) = $dir::cwd->lookupdir($env->_subst(shift));\n    my $file;\n    for $file (map($dir::cwd->lookupfile($env->_subst($_)), @_)) {\n\tmy($tgt) = $tgtdir->lookupfile($file->{entry});\n\t$tgt->bind(find build::install($env), $file);\n\t$tgt->local(1);\n    }\n}\n\nsub Objects {\n    my($env) = shift;\n    map($dir::cwd->relpath($_), $env->_Objects(@_));\n}\n\n# Called with multiple source file references (or object files).\n# Returns corresponding object files references.\nsub _Objects {\n    my($env) = shift;\n    my($suffix) = $env->{SUFOBJ};\n    map($env->_Object($_, $_->{dir}->lookupfile($_->base_suf($suffix))),\n\tmap { ref $_ ? $_ : $dir::cwd->lookupfile($env->_subst($_)) }\n\t\tgrep(defined $_, @_));\n}\n\n# Called with an object and source reference.  If no object reference\n# is supplied, then the object file is determined implicitly from the\n# source file's extension. Sets up the appropriate rules for creating\n# the object from the source.  Returns the object reference.\nsub _Object {\n    my($env, $src, $obj) = @_;\n    return $obj if $src eq $obj; # don't need to build self from self.\n    my($objenv) = $env->_resolve($obj);\n    my($suffix) = $src->suffix;\n\n    my($builder) = $env->{SUFMAP}{$suffix};\n\n    if ($builder) {\n\t$obj->bind((find $builder($objenv)), $src);\n    } else {\n\tdie(\"don't know how to construct ${\\$obj->path} from \" .\n\t    \"${\\$src->path}.\\n\");\n    }\n    $obj\n}\n\nsub Program {\n    my($env) = shift;\n    my($tgt) = $dir::cwd->lookupfile(file::addsuffix($env->_subst(shift),\n\t\t\t\t\t\t $env->{SUFEXE}));\n    my($progenv) = $env->_resolve($tgt);\n    $tgt->bind(find build::command::link($progenv, $progenv->{LINKCOM}),\n\t       $env->_Objects(@_));\n}\n\nsub Module {\n    my($env) = shift;\n    my($tgt) = $dir::cwd->lookupfile($env->_subst(shift));\n    my($modenv) = $env->_resolve($tgt);\n    my($com) = pop(@_);\n    $tgt->bind(find build::command::link($modenv, $com), $env->_Objects(@_));\n}\n\nsub LinkedModule {\n    my($env) = shift;\n    my($tgt) = $dir::cwd->lookupfile($env->_subst(shift));\n    my($progenv) = $env->_resolve($tgt);\n    $tgt->bind(find build::command::linkedmodule\n\t       ($progenv, $progenv->{LINKMODULECOM}),\n\t       $env->_Objects(@_));\n}\n\nsub Library {\n    my($env) = shift;\n    my($lib) = $dir::cwd->lookupfile(file::addsuffix($env->_subst(shift),\n\t\t\t\t\t\t $env->{SUFLIB}));\n    my($libenv) = $env->_resolve($lib);\n    $lib->bind(find build::command::library($libenv), $env->_Objects(@_));\n}\n\n# Simple derivation: you provide target, source(s), command.\n# Special variables substitute into the rule.\n# Target may be a reference, in which case it is taken\n# to be a multiple target (all targets built at once).\nsub Command {\n    my($env) = shift;\n    my($tgt) = $env->_subst(shift);\n    my($builder) = find build::command::user($env, pop(@_), 'script');\n    my(@sources) = map($dir::cwd->lookupfile($env->_subst($_)), @_);\n    if (ref($tgt)) {\n\t# A multi-target command.\n\tmy(@tgts) = map($dir::cwd->lookupfile($_), @$tgt);\n\tdie(\"empty target list in multi-target command\\n\") if !@tgts;\n\t$env = $env->_resolve($tgts[0]);\n\tmy($multi) = build::multiple->new($builder, \\@tgts);\n\tfor $tgt (@tgts) {\n\t    $tgt->bind($multi, @sources);\n\t}\n    } else {\n\t$tgt = $dir::cwd->lookupfile($tgt);\n\t$env = $env->_resolve($tgt);\n\t$tgt->bind($builder, @sources);\n    }\n}\n\nsub Depends {\n    my($env) = shift;\n    my($tgt) = $env->_subst(shift);\n    my(@deps) = map($dir::cwd->lookup($env->_subst($_)), @_);\n    if (! ref($tgt)) {\n\t$tgt = [ $tgt ];\n    }\n    my($t);\n    foreach $t (map($dir::cwd->lookupfile($_), @$tgt)) {\n\tpush(@{$t->{dep}}, @deps);\n    }\n}\n\n# Setup a quick scanner for the specified input file, for the\n# associated environment. Any use of the input file will cause the\n# scanner to be invoked, once only. The scanner sees just one line at\n# a time of the file, and is expected to return a list of\n# dependencies.\nsub QuickScan {\n    my($env, $code, $file, $path) = @_;\n    $dir::cwd->lookup($env->_subst($file))->{'srcscan',$env} =\n\tfind scan::quickscan($code, $env, $env->_subst($path));\n}\n\f\n# Generic builder module. Just a few default methods.  Every derivable\n# file must have a builder object of some sort attached.  Usually\n# builder objects are shared.\npackage build;\n\nuse vars qw( %builder );\n\n# Every builder must now have at least an associated environment,\n# so we can find its sigarray and calculate the proper signature.\nsub find {\n    my($class, $env) = @_;\n    $builder{$env} || do {\n\tmy $self = { env => $env };\n\t$builder{$env} = bless $self, $class;\n    }\n}\n\n# Null signature for dynamic includes.\nsub includes { () }\n\n# Null signature for build script.\nsub scriptsig { () }\n\n# Not compatible with any other builder, by default.\nsub compatible { 0 }\n\n\f\n# Builder module for the Install command.\npackage build::install;\n\nuse vars qw( @ISA );\n\nBEGIN { @ISA = qw(build) }\n\n# Caching not supported for Install: generally install is trivial anyway,\n# and we don't want to clutter the cache.\nsub cachin { undef }\nsub cachout { }\n\n# Do the installation.\nsub action {\n    my($self, $tgt) = @_;\n    my($src) = $tgt->{sources}[0];\n    main::showcom(\"Install ${\\$src->rpath} as ${\\$tgt->path}\")\n\tif ($param::install && $param::quiet < 1);\n    return unless $param::build;\n    futil::install($src->rpath, $tgt);\n    return 1;\n}\n\n\f\n# Builder module for generic UNIX commands.\npackage build::command;\n\nuse vars qw( @ISA %com );\n\nBEGIN { @ISA = qw(build) }\n\nsub find {\n    my($class, $env, $cmd, $package) = @_;\n    my($act) = action::new($env, $cmd);\n    $package ||= '';\n    $com{$env,$act,$package} || do {\n\tmy $self = { env => $env, act => $act, 'package' => $package };\n\t$com{$env,$act,$package} = bless $self, $class;\n    }\n}\n\n# Default cache in function.\nsub cachin {\n    my($self, $tgt, $sig) = @_;\n    if (cache::in($tgt, $sig)) {\n\tif ($param::cachecom) {\n\t    $self->{act}->show($self->{env}, $tgt);\n\t} else {\n\t    printf(\"Retrieved %s from cache\\n\", $tgt->path)\n\t\tif ($param::quiet < 1);\n\t}\n\treturn 1;\n    }\n    return undef;\n}\n\n# Default cache out function.\nsub cachout {\n    my($self, $tgt, $sig) = @_;\n    cache::out($tgt, $sig);\n}\n\n# Build the target using the previously specified commands.\nsub action {\n    my($self, $tgt) = @_;\n    $self->{act}->execute($self->{env}, $tgt, $self->{'package'});\n}\n\n# Return script signature.\nsub scriptsig {\n    $_[0]->{act}->scriptsig\n}\n\n\f\n# Create a linked module.\npackage build::command::link;\n\nuse vars qw( @ISA );\n\nBEGIN { @ISA = qw(build::command) }\n\n# Find an appropriate linker.\nsub find {\n    my($class, $env, $command) = @_;\n    if (!exists $env->{_LDIRS}) {\n\tmy($ldirs) = '';\n\tmy($wd) = $env->{_cwd};\n\tmy($pdirs) = $env->{LIBPATH};\n\tif (! defined $pdirs) {\n\t    $pdirs = [ ];\n\t} elsif (ref($pdirs) ne 'ARRAY') {\n\t    $pdirs = [ split(/$main::PATH_SEPARATOR/o, $pdirs) ];\n\t}\n\tmy($dir, $dpath);\n\tfor $dir (map($wd->lookupdir($env->_subst($_)), @$pdirs)) {\n\t    $dpath = $dir->path;\n\t    # Add the (presumably local) directory to the -L flags\n\t    # if we're not using repositories, the directory exists,\n\t    # or it's Linked to a source directory (that is, it *will*\n\t    # exist by the time the link occurs).\n\t    $ldirs .= \" \".$env->{LIBDIRPREFIX}.$dpath.$env->{LIBDIRSUFFIX}\n\t\t\tif ! @param::rpath || -d $dpath || $dir->is_linked;\n\t    next if File::Spec->file_name_is_absolute($dpath);\n\t    if (@param::rpath) {\n\t\tmy $d;\n\t\tif ($dpath eq $dir::CURDIR) {\n\t\t    foreach $d (map($_->path, @param::rpath)) {\n\t\t\t$ldirs .= \" \" . $env->{LIBDIRPREFIX} .\n\t\t\t\t  $d . $env->{LIBDIRSUFFIX};\n\t\t    }\n\t\t} else {\n\t\t    my($rpath);\n\t\t    foreach $d (map($_->path, @param::rpath)) {\n\t\t\t$rpath = File::Spec->catfile($d, $dpath);\n\t\t\t$ldirs .= \" \". $env->{LIBDIRPREFIX} .\n\t\t\t\t  $rpath . $env->{LIBDIRSUFFIX} if -d $rpath;\n\t\t    }\n\t\t}\n\t    }\n\t}\n\t$env->{_LDIRS} = \"%($ldirs%)\";\n    }\n\n    # Introduce a new magic _LIBS symbol which allows to use the\n    # Unix-style -lNAME syntax for Win32 only. -lNAME will be replaced\n    # with %{PREFLIB}NAME%{SUFLIB}. <schwarze@isa.de> 1998-06-18\n\n    if ($main::_WIN32 && !exists $env->{_LIBS}) {\n\tmy $libs;\n\tmy $name;\n\tfor $name (split(' ', $env->_subst($env->{LIBS} || ''))) {\n\t    if ($name =~ /^-l(.*)/) {\n\t\t$name = \"$env->{PREFLIB}$1$env->{SUFLIB}\";\n\t    }\n\t    $libs .= ' ' . $name;\n\t}\n\t$env->{_LIBS} = $libs ? \"%($libs%)\" : '';\n    }\n    bless find build::command($env, $command);\n}\n\n# Called from file::build. Make sure any libraries needed by the\n# environment are built, and return the collected signatures\n# of the libraries in the path.\nsub includes {\n    return $_[0]->{'bsig'} if exists $_[0]->{'bsig'};\n    my($self, $tgt) = @_;\n    my($env) = $self->{env};\n    my($ewd) = $env->{_cwd};\n    my $ldirs = $env->{LIBPATH};\n    if (! defined $ldirs) {\n\t$ldirs = [ ];\n    } elsif (ref($ldirs) ne 'ARRAY') {\n\t$ldirs = [ split(/$main::PATH_SEPARATOR/o, $ldirs) ];\n    }\n    my @lpath = map($ewd->lookupdir($_), @$ldirs);\n    my(@sigs);\n    my(@names);\n\n    # Pass %LIBS symbol through %-substituition\n    # <schwarze@isa.de> 1998-06-18\n    @names = split(' ', $env->_subst($env->{LIBS} || ''));\n    my $name;\n    for $name (@names) {\n\tmy ($lpath, @allnames);\n\tif ($name =~ /^-l(.*)/) {\n\t    # -l style names are looked up on LIBPATH, using all\n\t    # possible lib suffixes in the same search order the\n\t    # linker uses (according to SUFLIBS).\n\t    # Recognize new PREFLIB symbol, which should be 'lib' on\n\t    # Unix, and empty on Win32. TODO: What about shared\n\t    # library suffixes?  <schwarze@isa.de> 1998-05-13\n\t   @allnames = map(\"$env->{PREFLIB}$1$_\",\n\t\t\t   split(/:/, $env->{SUFLIBS}));\n\t    $lpath = \\@lpath;\n\t} else {\n\t    @allnames = ($name);\n\t    # On Win32, all library names are looked up in LIBPATH\n\t    # <schwarze@isa.de> 1998-05-13\n\t    if ($main::_WIN32) {\n\t\t$lpath = [$dir::top, @lpath];\n\t    }\n\t    else {\n\t\t$lpath = [$dir::top];\n\t    }\n\t}\n\tmy $dir;\n\tDIR: for $dir (@$lpath) {\n\t    my $n;\n\t    for $n (@allnames) {\n\t\tmy($lib) = $dir->lookup_accessible($n);\n\t\tif ($lib) {\n\t\t    last DIR if $lib->ignore;\n\t\t    if ((build $lib) eq 'errors') {\n\t\t\t$tgt->{status} = 'errors';\n\t\t\treturn undef;\n\t\t    }\n\t\t    push(@sigs, 'sig'->signature($lib));\n\t\t    last DIR;\n\t\t}\n\t    }\n\t}\n    }\n    $self->{'bsig'} = 'sig'->collect(@sigs);\n}\n\n# Always compatible with other such builders, so the user\n# can define a single program or module from multiple places.\nsub compatible {\n    my($self, $other) = @_;\n    ref($other) eq \"build::command::link\";\n}\n\n# Link a program.\npackage build::command::linkedmodule;\n\nuse vars qw( @ISA );\n\nBEGIN { @ISA = qw(build::command) }\n\n# Always compatible with other such builders, so the user\n# can define a single linked module from multiple places.\nsub compatible {\n    my($self, $other) = @_;\n    ref($other) eq \"build::command::linkedmodule\";\n}\n\f\n# Builder for a C module\npackage build::command::cc;\n\nuse vars qw( @ISA );\n\nBEGIN { @ISA = qw(build::command) }\n\nsub find {\n    $_[1]->{_cc} || do {\n\tmy($class, $env) = @_;\n\tmy($cpppath) = $env->_subst($env->{CPPPATH});\n\tmy($cscanner) = find scan::cpp($env->{_cwd}, $cpppath);\n\t$env->{_IFLAGS} = \"%(\" . $cscanner->iflags($env) . \"%)\";\n\tmy($self) = find build::command($env, $env->{CCCOM});\n\t$self->{scanner} = $cscanner;\n\tbless $env->{_cc} = $self;\n    }\n}\n\n# Invoke the associated\t C scanner to get signature of included files.\nsub includes {\n    my($self, $tgt) = @_;\n    $self->{scanner}->includes($tgt, $tgt->{sources}[0]);\n}\n\f\n# Builder for a C++ module\npackage build::command::cxx;\n\nuse vars qw( @ISA );\n\nBEGIN { @ISA = qw(build::command) }\n\nsub find {\n    $_[1]->{_cxx} || do {\n\tmy($class, $env) = @_;\n\tmy($cpppath) = $env->_subst($env->{CPPPATH});\n\tmy($cscanner) = find scan::cpp($env->{_cwd}, $cpppath);\n\t$env->{_IFLAGS} = \"%(\" . $cscanner->iflags($env) . \"%)\";\n\tmy($self) = find build::command($env, $env->{CXXCOM});\n\t$self->{scanner} = $cscanner;\n\tbless $env->{_cxx} = $self;\n    }\n}\n\n# Invoke the associated\t C scanner to get signature of included files.\nsub includes {\n    my($self, $tgt) = @_;\n    $self->{scanner}->includes($tgt, $tgt->{sources}[0]);\n}\n\f\n# Builder for a user command (cons::Command).  We assume that a user\n# command might be built and implement the appropriate dependencies on\n# the command itself (actually, just on the first word of the command\n# line).\npackage build::command::user;\n\nuse vars qw( @ISA );\n\nBEGIN { @ISA = qw(build::command) }\n\nsub includes {\n    my($self, $tgt) = @_;\n    my($sig) = '';\n\n    # Check for any quick scanners attached to source files.\n    my $dep;\n    for $dep (@{$tgt->{dep}}, @{$tgt->{sources}}) {\n\tmy($scanner) = $dep->{'srcscan',$self->{env}};\n\tif ($scanner) {\n\t    $sig .= $scanner->includes($tgt, $dep);\n\t}\n    }\n\n    # XXX Optimize this to not use ignored paths.\n    if (! exists $self->{_comsig}) {\n\tmy($env) = $self->{env};\n\t$self->{_comsig} = '';\n\tmy($com, $dir);\n      com:\n\tfor $com ($self->{act}->commands) {\n\t    my($pdirs) = $env->{ENV}->{PATH};\n\t    if (! defined $pdirs) {\n\t\t$pdirs = [ ];\n\t    } elsif (ref($pdirs) ne 'ARRAY') {\n\t\t$pdirs = [ split(/$main::PATH_SEPARATOR/o, $pdirs) ];\n\t    }\n\t    for $dir (map($dir::top->lookupdir($_), @$pdirs)) {\n\t\tmy($prog) = $dir->lookup_accessible($com);\n\t\tif ($prog) { # XXX Not checking execute permission.\n\t\t    if ((build $prog) eq 'errors') {\n\t\t\t$tgt->{status} = 'errors';\n\t\t\treturn $sig;\n\t\t    }\n\t\t    next com if $prog->ignore;\n\t\t    $self->{_comsig} .= 'sig'->signature($prog);\n\t\t    next com;\n\t\t}\n\t    }\n\t}\n    }\n\n    return $self->{_comsig} . $sig\n}\n\n\f\n# Builder for a library module (archive).\n# We assume that a user command might be built and implement the\n# appropriate dependencies on the command itself.\npackage build::command::library;\n\nuse vars qw( @ISA );\n\nBEGIN { @ISA = qw(build::command) }\n\nsub find {\n    my($class, $env) = @_;\n    bless find build::command($env, $env->{ARCOM})\n}\n\n# Always compatible with other library builders, so the user\n# can define a single library from multiple places.\nsub compatible {\n    my($self, $other) = @_;\n    ref($other) eq \"build::command::library\";\n}\n\f\n# A multi-target builder.\n# This allows multiple targets to be associated with a single build\n# script, without forcing all the code to be aware of multiple targets.\npackage build::multiple;\n\nsub new {\n    my($class, $builder, $tgts) = @_;\n    bless { 'builder' => $builder, 'env' => $builder->{env}, 'tgts' => $tgts };\n}\n\nsub scriptsig {\n    my($self, $tgt) = @_;\n    $self->{builder}->scriptsig($tgt);\n}\n\nsub includes {\n    my($self, $tgt) = @_;\n    $self->{builder}->includes($tgt);\n}\n\nsub compatible {\n    my($self, $tgt) = @_;\n    $self->{builder}->compatible($tgt);\n}\n\nsub cachin {\n    my($self, $tgt, $sig) = @_;\n    $self->{builder}->cachin($tgt, $sig);\n}\n\nsub cachout {\n    my($self, $tgt, $sig) = @_;\n    $self->{builder}->cachout($tgt, $sig);\n}\n\nsub action {\n    my($self, $invoked_tgt) = @_;\n    return $self->{built} if exists $self->{built};\n\n    # Make sure all targets in the group are unlinked before building any.\n    my($tgts) = $self->{tgts};\n    my $tgt;\n    for $tgt (@$tgts) {\n\tfutil::mkdir($tgt->{dir});\n\tunlink($tgt->path) if ! $tgt->precious;\n    }\n\n    # Now do the action to build all the targets. For consistency\n    # we always call the action on the first target, just so that\n    # $> is deterministic.\n    $self->{built} = $self->{builder}->action($tgts->[0]);\n\n    # Now \"build\" all the other targets (except for the one\n    # we were called with). This guarantees that the signature\n    # of each target is updated appropriately. We force the\n    # targets to be built even if they have been previously\n    # considered and found to be OK; the only effect this\n    # has is to make sure that signature files are updated\n    # correctly.\n    for $tgt (@$tgts) {\n\tif ($tgt ne $invoked_tgt) {\n\t    delete $tgt->{status};\n\t    'sig'->invalidate($tgt);\n\t    build $tgt;\n\t}\n    }\n\n    # Status of action.\n    $self->{built};\n}\n\f\npackage action;\n\nsub new {\n    my($env, $act) = @_;\n    if (ref($act) eq 'CODE') {\n\treturn action::perl->new($act);\n    } else {\n\treturn action::command->new($env, $act);\n    }\n}\n\npackage action::command;\n\nuse vars qw( @ISA %cmd %_varopts $_varletters );\n\nBEGIN {\n    @ISA = $main::_WIN32 ? 'action::command::win32' : 'action::command::unix';\n\n    # Internal hash for processing variable options.\n    # f: return file part\n    # d: return directory part\n    # F: return file part, but strip any suffix\n    # b: return full path, but strip any suffix (a.k.a. return basename)\n    # s: return only the suffix (or an empty string, if no suffix is there)\n    # a: return the absolute path to the file\n    # S: return the absolute path to a Linked source file\n    %_varopts = (\n\t'f' => sub { return $_[0]->{entry}; },\n\t'd' => sub { return $_[0]->{dir}->path; },\n\t'F' => sub { my $subst = $_[0]->{entry};\n\t\t     $subst =~ s/\\.[^\\.]+$//;\n\t\t     return $subst; },\n\t'b' => sub { my $subst =  $_[0]->path;\n\t\t     $subst =~ s/\\.[^\\.]+$//;\n\t\t     return $subst; },\n\t's' => sub { my $subst = $_[0]->{entry};\n\t\t     $subst =~ m/(\\.[^\\.]+)$/;\n\t\t     return $1; },\n\t'a' => sub { my $path = $_[0]->path;\n\t\t     if (! File::Spec->file_name_is_absolute($path)) {\n\t\t\t$path = File::Spec->catfile(Cwd::cwd(), $path);\n\t\t     }\n\t\t     return $path; },\n\t'S' => sub { my $path = $_[0]->srcpath;\n\t\t     if (! File::Spec->file_name_is_absolute($path)) {\n\t\t\tmy $cwd = File::Spec->canonpath(Cwd::cwd());\n\t\t\t$path = File::Spec->catfile($cwd, $path);\n\t\t     }\n\t\t     return $path; },\n    );\n\n    $_varletters = join('', keys %_varopts);\n}\n\n# Internal routine for processing variable options.\n# Options are specified in hash in the BEGIN block above.\n# no option: return path to file (relative to top,\n# or absolute if it's outside)\nsub _variant {\n    my($opt, $file) = @_;\n    $opt = '' if ! defined $opt;\n    if (defined $_varopts{$opt}) {\n\treturn &{$_varopts{$opt}}($file);\n    }\n    return $file->path;\n}\n\nsub new {\n    my($class, $env, $cmd) = @_;\n    $cmd = $env->_subst($cmd);\n    $cmd{$env,$cmd} || do {\n\t# Remove unwanted bits from signature -- those bracketed by %( ... %)\n\tmy $sigs = $cmd;\n\tmy $sig = '';\n\tif (ref($sigs) eq 'ARRAY') {\n\t    # This is an array of commands..\n\t    my $f;\n\t    foreach $f (@$sigs) {\n\t\t$sig .= _strip($f);\n\t    }\n\t} else {\n\t    $sig = _strip($sigs);\n\t}\n\tmy $self = { cmd => $cmd, cmdsig => 'sig'->cmdsig($sig) };\n\t$cmd{$env,$cmd} = bless $self, $class;\n    }\n}\n\nsub _strip {\n    my $sig = shift;\n    $sig =~ s/^\\@\\s*//mg;\n    while ($sig =~ s/%\\(([^%]|%[^\\(])*?%\\)//g) { }\n    $sig;\n}\n\nsub scriptsig {\n    $_[0]->{cmdsig};\n}\n\n# Return an array of all the commands (first word on each line).\nsub commands {\n    my($self) = @_;\n    my(@cmds) = ();\n    my $com;\n    my $cmd = $self->{'cmd'};\n    my @allcoms;\n\n    push @allcoms, ref $cmd ? @{$cmd} : split(/\\n/, $cmd);\n\n    for $com (@allcoms) {\n\t$com =~ s/^\\s*//;\n\t$com =~ s/\\s.*//;\n\tnext if ! $com; # blank line\n\tpush @cmds, $com;\n    }\n    @cmds;\n}\n\n# For the signature of a basic command, we don't bother\n# including the command itself. This is not strictly correct,\n# and if we wanted to be rigorous, we might want to insist\n# that the command was checked for all the basic commands\n# like gcc, etc. For this reason we don't have an includes\n# method.\n\n# Call this to get the command line script: an array of\n# fully substituted commands.\nsub getcoms {\n    my($self, $env, $tgt) = @_;\n    my(@coms);\n    my $com;\n    my @allcoms = ();\n    my $cmd = $self->{'cmd'};\n\n    push @allcoms, ref $cmd ? @{$cmd} : split(/\\n/, $cmd);\n\n    for $com (@allcoms) {\n\tmy(@src) = (undef, @{$tgt->{sources}});\n\tmy(@src1) = @src;\n\n\tnext if $com =~ /^\\s*$/;\n\n\t# NOTE: we used to have a more elegant s//.../e solution\n\t# for the items below, but this caused a bus error...\n\n\t# Remove %( and %) -- those are only used to bracket parts\n\t# of the command that we don't depend on.\n\t$com =~ s/%[()]//g;\n\n\t# Deal with %n, n=1,9 and variants.\n\twhile ($com =~ /%([1-9])(:([$_varletters]?))?/o) {\n\t    my($match) = $&;\n\t    my($src) = $src1[$1];\n\t    my($subst) = _variant($3, $src1[$1]->rfile);\n\t    undef $src[$1];\n\t    $com =~ s/$match/$subst/;\n\t}\n\n\t# Deal with %0 aka %> and variants.\n\twhile ($com =~ /%[0>](:([$_varletters]?))?/o) {\n\t    my($match) = $&;\n\t    my($subst) = _variant($2, $tgt);\n\t    $com =~ s/$match/$subst/;\n\t}\n\n\t# Deal with %< (all sources except %n's already used)\n\twhile ($com =~ /%<(:([$_varletters]?))?/o) {\n\t    my($match) = $&;\n\t    my @list = ();\n\t    foreach (@src) {\n\t\tpush(@list, _variant($2, $_->rfile)) if $_;\n\t    }\n\t    my($subst) = join(' ', @list);\n\t    $com =~ s/$match/$subst/;\n\t}\n\n\t# Deal with %[ %].\n\t$com =~ s{%\\[(.*?)%\\]}{\n\t    my($func, @args) = grep { $_ ne '' } split(/\\s+/, $1);\n\t    die(\"$0: \\\"$func\\\" is not defined.\\n\")\n\t\tunless ($env->{$func});\n\t    &{$env->{$func}}(@args);\n\t}gex;\n\n\t# Convert left-over %% into %.\n\t$com =~ s/%%/%/g;\n\n\t# White space cleanup. XXX NO WAY FOR USER TO HAVE QUOTED SPACES\n\t$com = join(' ', split(' ', $com));\n\tnext if $com =~ /^:/ && $com !~ /^:\\S/;\n\tpush(@coms, $com);\n    }\n    @coms\n}\n\n# Build the target using the previously specified commands.\nsub execute {\n    my($self, $env, $tgt, $package) = @_;\n\n    if ($param::build) {\n\tfutil::mkdir($tgt->{dir});\n\tunlink($tgt->path) if ! $tgt->precious;\n    }\n\n    # Set environment.\n    map(delete $ENV{$_}, keys %ENV);\n    %ENV = %{$env->{ENV}};\n\n    # Handle multi-line commands.\n    my $com;\n    for $com ($self->getcoms($env, $tgt)) {\n\tif ($com !~ s/^\\@\\s*//) {\n\t    main::showcom($com);\n\t}\n\tnext if ! $param::build;\n\n\tif ($com =~ /^\\[perl\\]\\s*/) {\n\t    my $perlcmd = $';\n\t    my $status;\n\t    {\n\t\t# Restore the script package variables that were defined\n\t\t# in the Conscript file that defined this [perl] build,\n\t\t# so the code executes with the expected variables.\n\t\t# Then actually execute (eval) the [perl] command to build\n\t\t# the target, followed by cleaning up the name space\n\t\t# by deleting the package variables we just restored.\n\t\tmy($pkgvars) = $tgt->{conscript}->{pkgvars};\n\t\tNameSpace::restore($package, $pkgvars) if $pkgvars;\n\t\t$status = eval \"package $package; $perlcmd\";\n\t\tNameSpace::remove($package, keys %$pkgvars) if $pkgvars;\n\t    }\n\t    if (!defined($status)) {\n\t\twarn \"$0: *** Error during perl command eval: $@.\\n\";\n\t\treturn undef;\n\t    } elsif ($status == 0) {\n\t\twarn \"$0: *** Perl command returned $status \"\n\t\t   . \"(this indicates an error).\\n\";\n\t\treturn undef;\n\t    }\n\t    next;\n\t}\n\tif (! $self->do_command($com, $tgt->path)) {\n\t\treturn undef;\n\t}\n    }\n\n    # success.\n    return 1;\n}\n\nsub show {\n    my($self, $env, $tgt) = @_;\n    my $com;\n    for $com ($self->getcoms($env, $tgt)) {\n\tif ($com !~ /^\\@\\s*/) {\n\t    main::showcom($com);\n\t}\n    }\n}\n\npackage action::command::unix;\n\nsub do_command {\n    my($class, $com, $path) = @_;\n    my($pid) = fork();\n    die(\"$0: unable to fork child process ($!)\\n\") if !defined $pid;\n    if (!$pid) {\n\t# This is the child.  We eval the command to suppress -w\n\t# warnings about not reaching the statements afterwards.\n\teval 'exec($com)';\n\t$com =~ s/\\s.*//;\n\tdie qq($0: failed to execute \"$com\" ($!). )\n\t  . qq(Is this an executable on path \"$ENV{PATH}\"?\\n);\n    }\n    for (;;) {\n\tdo {} until wait() == $pid;\n\tmy ($b0, $b1) = ($? & 0xFF, $? >> 8);\n\t# Don't actually see 0177 on stopped process; is this necessary?\n\tnext if $b0 == 0177; # process stopped; we can wait.\n\tif ($b0) {\n\t    my($core, $sig) = ($b0 & 0200, $b0 & 0177);\n\t    my($coremsg) = $core ? \"; core dumped\" : \"\";\n\t    $com =~ s/\\s.*//;\n\t    my $err = \"$0: *** \\[$path\\] $com terminated by signal \" .\n\t\t  \"$sig$coremsg\\n\";\n\t    warn $err;\n\t    return undef;\n\t}\n\tif ($b1) {\n\t    warn qq($0: *** [$path] Error $b1\\n); # trying to be like make.\n\t    return undef;\n\t}\n\tlast;\n    }\n    return 1;\n}\n\npackage action::command::win32;\n\nsub do_command {\n    my($class, $com, $path) = @_;\n    system($com);\n    if ($?) {\n\tmy ($b0, $b1) = ($? & 0xFF, $? >> 8);\n\tmy $err = $b1 || $?;\n\tmy $warn = qq($0: *** [$path] Error $err);\n\t$warn .= \" (executable not found in path?)\" if $b1 == 0xFF;\n\twarn \"$warn\\n\";\n\treturn undef;\n    }\n    return 1;\n}\n\npackage action::perl;\n\n# THIS IS AN EXPERIMENTAL PACKAGE.  It's entirely possible that the\n# interface may change as this gets completed, so use at your own risk.\n#\n# There are (at least) two issues that need to be solved before blessing\n# this as a real, fully-supported feature:\n#\n#   --\tWe need to calculate a signature value for a Perl code ref, in\n#\torder to rebuild the target if there's a change to the Perl code\n#\tused to generate it.\n#\n#\tThis is not straightforward.  A B::Deparse package exists that\n#\tdecompiles a coderef into text.  It's reportedly not completely\n#\treliable for closures; it misses which variables are global, and\n#\tthe values of private lexicals.  Nevertheless, it'd probably\n#\tbe perfect for our purposes, except that it wasn't added until\n#\tsome time between Perl 5.00502 and 5.00554, and doesn't seem to\n#\treally work until Perl 5.6.0, so by relying on it, we'd lose\n#\tsupport for Perl versions back to 5.003*.\n#\n#   --\tIdeally, a code ref should be able to use something like\n#\t$env->_subst to fetch values from the construction environment\n#\tto modify its behavior without having to cut-and-paste code.\n#\t(Actually, since we pass the environment to the executed code\n#\tref, there's no reason you can't do this with the code as it\n#\tstands today.)  But this REALLY complicates the signature\n#\tcalculation, because now the actual signature would depend not\n#\tjust on the code contents, but on the construction variables (or\n#\tmaybe just the environment).\n#\n# A potentially valid workaround would be to use the contents of the\n# Conscript file in which the code reference is defined as the code\n# ref's signature.  This has the drawback of causing a recompilation of\n# the target file even in response to unrelated changes in the Conscript\n# file, but it would ensure correct builds without having to solve the\n# messy issues of generating a signature directly from a code ref.\n#\n# Nevertheless, this seemed a useful enough skeleton of a feature that\n# it made sense to release it in hopes that some practical experience\n# will encourage someone to figure out how to solve the signature\n# issues.  Or maybe we'll discover these aren't big issues in practice\n# and end up blessing it as is.\n\nuse vars qw( %code );\n\nsub new {\n    my($class, $cref) = @_;\n    $code{$cref} || do {\n\tmy $sig = '';\n\t# Generating a code signature using B::Deparse doesn't really\n\t# work for us until Perl 5.6.0.  Here's the code in case\n\t# someone wants to use it.\n\t#use B::Deparse;\n\t#my $deparse = B::Deparse->new();\n\t#my $body = $deparse->coderef2text($cref);\n\t#$sig = $body;\t# should be an MD5 sig\n\tmy($self) = { cref => $cref, crefsig => $sig };\n\t$code{$cref} = bless $self, $class;\n    }\n}\n\nsub scriptsig {\n    $_[0]->{crefsig}\n}\n\nsub execute {\n    my($self, $env, $tgt) = @_;\n    if ($param::build) {\n\tfutil::mkdir($tgt->{dir});\n\tunlink($tgt->path) if ! $tgt->precious;\n\tmy($cref) = $self->{cref};\n\t&$cref($env, $tgt->path, map($_->rpath, @{$tgt->{sources}}));\n    }\n}\n\nsub commands {\n    return ();\n}\n\n\f\n# Generic scanning module.\npackage scan;\n\n# Returns the signature of files included by the specified files on\n# behalf of the associated target. Any errors in handling the included\n# files are propagated to the target on whose behalf this processing\n# is being done. Signatures are cached for each unique file/scanner\n# pair.\nsub includes {\n    my($self, $tgt, @files) = @_;\n    my(%files, $file);\n    my($inc) = $self->{includes} || ($self->{includes} = {});\n    while ($file = pop @files) {\n\tnext if exists $files{$file};\n\tif ($inc->{$file}) {\n\t    push(@files, @{$inc->{$file}});\n\t    $files{$file} = 'sig'->signature($file->rfile);\n\t} else {\n\t    if ((build $file) eq 'errors') {\n\t\t$tgt->{status} = 'errors'; # tgt inherits build status\n\t\treturn ();\n\t    }\n\t    $files{$file} = 'sig'->signature($file->rfile);\n\t    my(@includes) = $self->scan($file);\n\t    $inc->{$file} = \\@includes;\n\t    push(@files, @includes);\n\t}\n    }\n    'sig'->collect(sort values %files)\n}\n\n\f\n# A simple scanner. This is used by the QuickScanfunction, to setup\n# one-time target and environment-independent scanning for a source\n# file. Only used for commands run by the Command method.\npackage scan::quickscan;\n\nuse vars qw( @ISA %scanner );\n\nBEGIN { @ISA = qw(scan) }\n\nsub find {\n    my($class, $code, $env, $pdirs) = @_;\n    if (! defined $pdirs) {\n\t$pdirs = [ ] ;\n    } elsif (ref($pdirs) ne 'ARRAY') {\n\t$pdirs = [ split(/$main::PATH_SEPARATOR/o, $pdirs) ];\n    }\n    my(@path) = map { $dir::cwd->lookupdir($_) } @$pdirs;\n    my($spath) = \"@path\";\n    $scanner{$code,$env,$spath} || do {\n\tmy($self) = { code => $code, env => $env, path => \\@path };\n\t$scanner{$code,$env,$spath} = bless $self;\n    }\n}\n\n# Scan the specified file for included file names.\nsub scan {\n    my($self, $file) = @_;\n    my($code) = $self->{code};\n    my(@includes);\n    # File should have been built by now. If not, we'll ignore it.\n    return () unless open(SCAN, $file->rpath);\n    while(<SCAN>) {\n\tpush(@includes, grep($_ ne '', &$code));\n    }\n    close(SCAN);\n    my($wd) = $file->{dir};\n    my(@files);\n    my $name;\n    for $name (@includes) {\n\tmy $dir;\n\tfor $dir ($file->{dir}, @{$self->{path}}) {\n\t    my($include) = $dir->lookup_accessible($name);\n\t    if ($include) {\n\t\tpush(@files, $include) unless $include->ignore;\n\t\tlast;\n\t    }\n\t}\n    }\n    @files\n}\n\n\f\n# CPP (C preprocessor) scanning module\npackage scan::cpp;\n\nuse vars qw( @ISA %scanner );\n\nBEGIN { @ISA = qw(scan) }\n\n# For this constructor, provide the include path argument (colon\n# separated). Each path is taken relative to the provided directory.\n\n# Note: a particular scanning object is assumed to always return the\n# same result for the same input. This is why the search path is a\n# parameter to the constructor for a CPP scanning object. We go to\n# some pains to make sure that we return the same scanner object\n# for the same path: otherwise we will unecessarily scan files.\nsub find {\n    my($class, $dir, $pdirs) = @_;\n    if (! defined $pdirs) {\n\t$pdirs = [ ];\n    } elsif (ref($pdirs) ne 'ARRAY') {\n\t$pdirs = [ split(/$main::PATH_SEPARATOR/o, $pdirs) ];\n    }\n    my @path = map($dir->lookupdir($_), @$pdirs);\n    my($spath) = \"@path\";\n    $scanner{$spath} || do {\n\tmy($self) = {'path' => \\@path};\n\t$scanner{$spath} = bless $self;\n    }\n}\n\n# Scan the specified file for include lines.\nsub scan {\n    my($self, $file) = @_;\n    my($angles, $quotes);\n\n    if (exists $file->{angles}) {\n\t$angles = $file->{angles};\n\t$quotes = $file->{quotes};\n    } else {\n\tmy(@anglenames, @quotenames);\n\treturn () unless open(SCAN, $file->rpath);\n\twhile (<SCAN>) {\n\t    next unless /^\\s*#/;\n\t    if (/^\\s*#\\s*include\\s*([<\"])(.*?)[>\"]/) {\n\t\tif ($1 eq \"<\") {\n\t\t    push(@anglenames, $2);\n\t\t} else {\n\t\t    push(@quotenames, $2);\n\t\t}\n\t    }\n\t}\n\tclose(SCAN);\n\t$angles = $file->{angles} = \\@anglenames;\n\t$quotes = $file->{quotes} = \\@quotenames;\n    }\n\n\n    my(@shortpath) = @{$self->{path}};\t  # path for <> style includes\n    my(@longpath) = ($file->{dir}, @shortpath); # path for \"\" style includes\n\n    my(@includes);\n\n    my $name;\n    for $name (@$angles) {\n\tmy $dir;\n\tfor $dir (@shortpath) {\n\t    my($include) = $dir->lookup_accessible($name);\n\t    if ($include) {\n\t\tpush(@includes, $include) unless $include->ignore;\n\t\tlast;\n\t    }\n\t}\n    }\n\n    for $name (@$quotes) {\n\tmy $dir;\n\tfor $dir(@longpath) {\n\t    my($include) = $dir->lookup_accessible($name);\n\t    if ($include) {\n\t\tpush(@includes, $include) unless $include->ignore;\n\t\tlast;\n\t    }\n\t}\n    }\n\n    return @includes\n}\n\n# Return the include flags that would be used for a C Compile.\nsub iflags {\n    my($self, $env) = @_;\n    my($iflags) = '';\n    my($dir, $dpath);\n    for $dir (@{$self->{path}}) {\n\t$dpath = $dir->path;\n\t# Add the (presumably local) directory to the -I flags\n\t# if we're not using repositories, the directory exists,\n\t# or it's Linked to a source directory (that is, it *will*\n\t# exist by the time the compilation occurs).\n\t$iflags .= \" \".$env->{INCDIRPREFIX}.$dpath.$env->{INCDIRSUFFIX}\n\t\tif ! @param::rpath || -d $dpath || $dir->is_linked;\n\tnext if File::Spec->file_name_is_absolute($dpath);\n\tif (@param::rpath) {\n\t    my $d;\n\t    if ($dpath eq $dir::CURDIR) {\n\t\tforeach $d (map($_->path, @param::rpath)) {\n\t\t    $iflags .= \" \".$env->{INCDIRPREFIX}.$d.$env->{INCDIRSUFFIX};\n\t\t}\n\t    } else {\n\t\tmy($rpath);\n\t\tforeach $d (map($_->path, @param::rpath)) {\n\t\t    $rpath = File::Spec->catfile($d, $dpath);\n\t\t    $iflags .= \" \".$env->{INCDIRPREFIX}.$rpath.$env->{INCDIRSUFFIX}\n\t\t\t\tif -d $rpath;\n\t\t}\n\t    }\n\t}\n    }\n    $iflags\n}\n\f\npackage File::Spec;\n\nuse vars qw( $_SEP $_MATCH_SEP $_MATCH_VOL );\n\n# Cons is migrating to using File::Spec for portable path name\n# manipulation.  This is the right long-term direction, but there are\n# some problems with making the transition:\n#\n#\tFor multi-volume support, we need to use newer interfaces\n#\t(splitpath, catpath, splitdir) that are only available in\n#\tFile::Spec 0.8.\n#\n#\tFile::Spec 0.8 doesn't work with Perl 5.00[34] due to\n#\tregular expression incompatibilities (use of \\z).\n#\n#\tForcing people to use a new version of a module is painful\n#\tbecause (in the workplace) their administrators aren't\n#\talways going to agree to install it everywhere.\n#\n# As a middle ground, we provide our own versions of all the File::Spec\n# methods we use, supporting both UNIX and Win32.  Some of these methods\n# are home brew, some are cut-and-pasted from the real File::Spec methods.\n# This way, we're not reinventing the whole wheel, at least.\n#\n# We can (and should) get rid of this class whenever 5.00[34] and\n# versions of File::Spec prior to 0.9 (?) have faded sufficiently.\n# We also may need to revisit whenever someone first wants to use\n# Cons on some platform other than UNIX or Win32.\n\nBEGIN {\n    if ($main::_WIN32) {\n\t$_SEP = '\\\\';\n\t$_MATCH_SEP = \"[\\Q/$_SEP\\E]\";\n\t$_MATCH_VOL = \"([a-z]:)?$_MATCH_SEP\";\n    } else {\n\t$_SEP = '/';\n\t$_MATCH_SEP = \"\\Q$_SEP\\E\";\n\t$_MATCH_VOL = $_MATCH_SEP;\n    }\n}\n\nsub canonpath {\n    my ($self, $path) = @_;\n    if ($main::_WIN32) {\n\t$path =~ s/^([a-z]:)/\\u$1/s;\n\t$path =~ s|/|\\\\|g;\n\t$path =~ s|([^\\\\])\\\\+|$1\\\\|g;                  # xx////xx  -> xx/xx\n\t$path =~ s|(\\\\\\.)+\\\\|\\\\|g;                     # xx/././xx -> xx/xx\n\t$path =~ s|^(\\.\\\\)+||s unless $path eq \".\\\\\";  # ./xx      -> xx\n\t$path =~ s|\\\\$||\n\t\t unless $path =~ m#^([A-Z]:)?\\\\$#s;   # xx/       -> xx\n    } else {\n\t$path =~ s|/+|/|g unless($^O eq 'cygwin');     # xx////xx  -> xx/xx\n\t$path =~ s|(/\\.)+/|/|g;                        # xx/././xx -> xx/xx\n\t$path =~ s|^(\\./)+||s unless $path eq \"./\";    # ./xx      -> xx\n\t$path =~ s|^/(\\.\\./)+|/|s;                     # /../../xx -> xx\n\t$path =~ s|/$|| unless $path eq \"/\";          # xx/       -> xx\n    }\n    return $path;\n}\n\nsub catdir {\n    my $self = shift;\n    my @args = @_;\n    foreach (@args) {\n\t# append a slash to each argument unless it has one there\n\t$_ .= $_SEP if $_ eq '' || substr($_,-1) ne $_SEP;\n    }\n    return $self->canonpath(join('', @args));\n}\n\nsub catfile {\n    my $self = shift;\n    my $file = pop @_;\n    return $file unless @_;\n    my $dir = $self->catdir(@_);\n    $dir .= $_SEP unless substr($dir,-1) eq $_SEP;\n    $file = '' if ! defined($file);\n    return $dir.$file;\n}\n\nsub catpath {\n    my $path = $_[1] . $_[0]->catfile(@_[2..$#_]);\n    $path =~ s/(.)$_MATCH_SEP*$/$1/;\n    $path;\n}\n\nsub curdir {\n    '.'\n}\n\nsub file_name_is_absolute {\n    my ($self, $file) = @_;\n    return scalar($file =~ m{^$_MATCH_VOL}is);\n}\n\nsub splitdir {\n    my @dirs = split(/$_MATCH_SEP/, $_[1], -1);\n    push(@dirs, '') if $dirs[$#dirs];\n    @dirs;\n}\n\nsub splitpath {\n    my ($self, $path) = @_;\n    my $vol = '';\n    my $sep = $_SEP;\n    if ($main::_WIN32) {\n\tif ($path =~ s#^([A-Za-z]:|(?:\\\\\\\\|//)[^\\\\/]+[\\\\/][^\\\\/]+)([\\\\/])#$2#) {\n\t    $vol = $1;\n\t    $sep = $2;\n\t}\n    }\n    my(@path) = split(/$_MATCH_SEP/, $path, -1);\n    my $file = pop @path;\n    my $dirs = join($sep, @path, '');\n    return ($vol, $dirs, $file);\n}\n\nsub updir {\n    '..'\n}\n\nsub case_tolerant {\n    return $main::_WIN32;\n}\n\f\n# Directory and file handling. Files/dirs are represented by objects.\n# Other packages are welcome to add component-specific attributes.\npackage dir;\n\nuse vars qw( $SEPARATOR $MATCH_SEPARATOR $CURDIR $UPDIR\n\t     $cwd_vol %root $top $cwd );\n\nBEGIN {\n    # A portable way of determing our directory separator.\n    $SEPARATOR = File::Spec->catdir('', '');\n    # A fast-path regular expression to match a directory separator\n    # anywhere in a path name.\n    if ($SEPARATOR eq '/') {\n\t$MATCH_SEPARATOR = \"\\Q$SEPARATOR\\E\";\n    } else {\n\t$MATCH_SEPARATOR = \"[\\Q/$SEPARATOR\\E]\";\n    }\n    # Cache these values so we don't have to make a method call\n    # every time we need them.\n    $CURDIR = File::Spec->curdir;\t# '.' on UNIX\n    $UPDIR = File::Spec->updir;\t# '..' on UNIX\n    #\n    $cwd_vol = '';\n}\n\n# Annotate a node (file or directory) with info about the\n# method that created it.\nsub creator {\n    my($self, @frame) = @_;\n    $self->{'creator'} = \\@frame if @frame;\n    $self->{'creator'};\n}\n\n# Handle a file|dir type exception.  We only die if we find we were\n# invoked by something in a Conscript/Construct file, because\n# dependencies created directly by Cons' analysis shouldn't cause\n# an error.\nsub _type_exception {\n    my($e) = @_;\n    my($line, $sub);\n    (undef, undef, $line, $sub) = script::caller_info;\n    if (defined $line) {\n\tmy $err = \"\\\"${\\$e->path}\\\" already in use as a \" . ref($e) . \" before $sub on line $line\";\n\tif ($e->{'creator'}) {\n\t    my $script;\n\t    (undef, $script, $line, $sub) = @{$e->{'creator'}};\n\t    $err = \"\\t\" . $err . \",\\n\\t\\tdefined by $sub in $script, line $line\";\n\t}\n\t$err .= \"\\n\";\n\tdie $err;\n    }\n}\n\n# This wraps up all the common File::Spec logic that we use for parsing\n# directory separators in a path and turning it into individual\n# subdirectories that we must create, as well as creation of root\n# nodes for any new file system volumes we find.  File::Spec doesn't have\n# intuitively obvious interfaces, so this is heavily commented.\n#\n# Note:  This is NOT an object or class method;\n# it's just a utility subroutine.\nsub _parse_path {\n    my($dir, $path) = @_;\n\n    # Convert all slashes to the native directory separator.\n    # This allows Construct files to always be written with good\n    # old POSIX path names, regardless of what we're running on.\n    $path = File::Spec->canonpath($path);\n\n    # File::Spec doesn't understand the Cons convention of\n    # an initial '#' for top-relative files.  Strip it.\n    my($toprel) = $path =~ s/^#//;\n\n    # Let File::Spec do the heavy lifting of parsing the path name.\n    my($vol, $directories, $entry) = File::Spec->splitpath($path);\n    my @dirs = File::Spec->splitdir($directories);\n\n    # If there was a file entry on the end of the path, then the\n    # last @dirs element is '' and we don't need it.  If there\n    # wasn't a file entry on the end (File::Spec->splitpath() knew\n    # the last component was a directory), then the last @dirs\n    # element becomes the entry we want to look up.\n    my($e) = pop @dirs;\n    $entry = $e if $entry eq '';\n\n    if (File::Spec->file_name_is_absolute($path)) {\n\t# An absolute path name.  If no volume was supplied,\n\t# use the volume of our current directory.\n\t$vol = $cwd_vol if $vol eq '';\n\t$vol = uc($vol) if File::Spec->case_tolerant;\n\tif (! defined $root{$vol}) {\n\t    # This is our first time looking up a path name\n\t    # on this volume, so create a root node for it.\n\t    # (On UNIX systems, $vol is always '', so '/'\n\t    # always maps to the $root{''} node.)\n\t    $root{$vol} = {path => $vol.$SEPARATOR,\n\t\t\tprefix => $vol.$SEPARATOR,\n\t\t\tsrcpath => $vol.$SEPARATOR,\n\t\t\t'exists' => 1 };\n\t    $root{$vol}->{'srcdir'} = $root{$vol};\n\t    bless $root{$vol};\n\t}\n\t# We're at the top, so strip the blank entry from the front of\n\t# the @dirs array since the initial '/' it represents will now\n\t# be supplied by the root node we return.\n\tshift @dirs;\n\t$dir = $root{$vol};\n    } elsif ($toprel) {\n\t$dir = $dir::top;\n    }\n    ($dir, \\@dirs, $entry);\n}\n\n# Common subroutine for creating directory nodes.\nsub _create_dirs {\n    my ($dir, @dirs) = @_;\n    my $e;\n    foreach $e (@dirs) {\n\tmy $d = $dir->{member}->{$e};\n\tif (! defined $d) {\n\t    bless $d = { 'entry' => $e, 'dir' => $dir, }, 'dir';\n\t    $d->creator(script::caller_info);\n\t    $d->{member}->{$dir::CURDIR} = $d;\n\t    $d->{member}->{$dir::UPDIR} = $dir;\n\t    $dir->{member}->{$e} = $d;\n\t} elsif (ref $d eq 'entry') {\n\t    bless $d, 'dir';\n\t    $d->{member}->{$dir::CURDIR} = $d;\n\t    $d->{member}->{$dir::UPDIR} = $dir;\n\t} elsif (ref $d eq 'file') {\n\t    # This clause is to supply backwards compatibility,\n\t    # with a warning, for anyone that's used FilePath\n\t    # to refer to a directory.  After people have using\n\t    # 1.8 have had time to adjust (sometime in version\n\t    # 1.9 or later), we should remove this entire clause.\n\t    my($script, $line, $sub);\n\t    (undef, $script, $line, $sub) = @{$d->{'creator'}};\n\t    if ($sub eq 'script::FilePath') {\n\t\tprint STDERR \"$0:  Warning:  $sub used to refer to a directory\\n\"\n\t\t\t. \"\\tat line $line of $script.  Use DirPath instead.\\n\";\n\t\tbless $d, 'dir';\n\t    } else {\n\t\t_type_exception($d);\n\t    }\n\t} elsif (ref $d ne 'dir') {\n\t    _type_exception($d);\n\t}\n\t$dir = $d;\n    }\n    $dir;\n}\n\n# Look up an entry in a directory.  This method is for when we don't\n# care whether a file or directory is returned, so if the entry already\n# exists, it will simply be returned.  If not, we create it as a\n# generic \"entry\" which can be later turned into a file or directory\n# by a more-specific lookup.\n#\n# The file entry may be specified as relative, absolute (starts with /),\n# or top-relative (starts with #).\nsub lookup {\n    my($dir, $entry) = @_;\n\n    if ($entry !~ m#$MATCH_SEPARATOR#o) {\n\t# Fast path: simple entry name in a known directory.\n\tif ($entry =~ s/^#//) {\n\t    # Top-relative names begin with #.\n\t    $dir = $dir::top;\n\t} elsif ($entry =~ s/^!//) {\n\t    $dir = $dir::cwd->srcdir;\n\t}\n    } else {\n\tmy $dirsref;\n\t($dir, $dirsref, $entry) = _parse_path($dir, $entry);\n\t$dir = _create_dirs($dir, @$dirsref) if @$dirsref;\n\treturn if ! defined $dir;\n\treturn $dir if $entry eq '';\n    }\n\n    my $e = $dir->{member}->{$entry};\n    if (! defined $e) {\n\tbless $e = { 'entry' => $entry, 'dir' => $dir, }, 'entry';\n\t$e->creator(script::caller_info);\n\t$dir->{member}->{$entry} = $e;\n    }\n\n    $e;\n}\n\n# Look up a file entry in a directory.\n#\n# The file entry may be specified as relative, absolute (starts with /),\n# or top-relative (starts with #).\nsub lookupfile {\n    my($dir, $entry) = @_;\n\n    if ($entry !~ m#$MATCH_SEPARATOR#o) {\n\t# Fast path: simple entry name in a known directory.\n\tif ($entry =~ s/^#//) {\n\t    # Top-relative names begin with #.\n\t    $dir = $dir::top;\n\t} elsif ($entry =~ s/^!//) {\n\t    $dir = $dir::cwd->srcdir;\n\t}\n    } else {\n\tmy $dirsref;\n\t($dir, $dirsref, $entry) = _parse_path($dir, $entry);\n\t$dir = _create_dirs($dir, @$dirsref) if @$dirsref;\n\treturn undef if $entry eq '';\n    }\n\n    my $f = $dir->{member}->{$entry};\n    if (! defined $f) {\n\tbless $f = { 'entry' => $entry, 'dir' => $dir, }, 'file';\n\t$f->creator(script::caller_info);\n\t$dir->{member}->{$entry} = $f;\n    } elsif (ref $f eq 'entry') {\n\tbless $f, 'file';\n    } elsif (ref $f ne 'file') {\n\t_type_exception($f);\n    }\n\n    $f;\n}\n\n# Look up a (sub-)directory entry in a directory.\n#\n# The (sub-)directory entry may be specified as relative, absolute\n# (starts with /), or top-relative (starts with #).\nsub lookupdir {\n    my($dir, $entry) = @_;\n\n    my $dirsref;\n    if ($entry !~ m#$MATCH_SEPARATOR#o) {\n\t# Fast path: simple entry name in a known directory.\n\tif ($entry =~ s/^#//) {\n\t    # Top-relative names begin with #.\n\t    $dir = $dir::top;\n\t} elsif ($entry =~ s/^!//) {\n\t    $dir = $dir::cwd->srcdir;\n\t}\n    } else {\n\t($dir, $dirsref, $entry) = _parse_path($dir, $entry);\n    }\n    push(@$dirsref, $entry) if $entry ne '';\n    _create_dirs($dir, @$dirsref);\n}\n\n# Look up a file entry and return it if it's accessible.\nsub lookup_accessible {\n    my $file = $_[0]->lookupfile($_[1]);\n    return ($file && $file->accessible) ? $file : undef;\n}\n\n# Return the parent directory without doing a lookupdir,\n# which would create a parent if it doesn't already exist.\n# A return value of undef (! $dir->up) indicates a root directory.\nsub up {\n    $_[0]->{member}->{$dir::UPDIR};\n}\n\n# Return whether this is an entry somewhere underneath the\n# specified directory.\nsub is_under {\n    my $dir = $_[0];\n    while ($dir) {\n\treturn 1 if $_[1] == $dir;\n\t$dir = $dir->up;\n    }\n    return undef;\n}\n\n# Return the relative path from the calling directory ($_[1])\n# to the object.  If the object is not under the directory, then\n# we return it as a top-relative or absolute path name.\nsub relpath {\n    my ($dir, $obj) = @_;\n    my @dirs;\n    my $o = $obj;\n    while ($o) {\n\tif ($dir == $o) {\n\t    if (@dirs < 2) {\n\t\treturn $dirs[0] || '';\n\t    } else {\n\t\treturn File::Spec->catdir(@dirs);\n\t    }\n\t}\n\tunshift(@dirs, $o->{entry});\n\t$o = $o->up;\n    }\n    # The object was not underneath the specified directory.\n    # Use the node's cached path, which is either top-relative\n    # (in which case we append '#' to the beginning) or\n    # absolute.\n    my $p = $obj->path;\n    $p = '#' . $p if ! File::Spec->file_name_is_absolute($p);\n    return $p;\n}\n\n# Return the path of the directory (file paths implemented\n# separately, below).\nsub path {\n    $_[0]->{path} ||\n\t($_[0]->{path} = $_[0]->{dir}->prefix . $_[0]->{entry});\n}\n\n# Return the pathname as a prefix to be concatenated with an entry.\nsub prefix {\n    return $_[0]->{prefix} if exists $_[0]->{prefix};\n    $_[0]->{prefix} = $_[0]->path . $SEPARATOR;\n}\n\n# Return the related source path prefix.\nsub srcprefix {\n    return $_[0]->{srcprefix} if exists $_[0]->{srcprefix};\n    my($srcdir) = $_[0]->srcdir;\n    $srcdir->{srcprefix} = $srcdir eq $_[0] ? $srcdir->prefix\n\t\t\t\t\t    : $srcdir->srcprefix;\n}\n\n# Return the related source directory.\nsub srcdir {\n    $_[0]->{'srcdir'} ||\n\t($_[0]->{'srcdir'} = $_[0]->{dir}->srcdir->lookupdir($_[0]->{entry}))\n}\n\n# Return if the directory is linked to a separate source directory.\nsub is_linked {\n    return $_[0]->{is_linked} if defined $_[0]->{is_linked};\n    $_[0]->{is_linked} = $_[0]->path ne $_[0]->srcdir->path;\n}\n\nsub link {\n    my(@paths) = @_;\n    my($srcdir) = $dir::cwd->lookupdir(pop @paths)->srcdir;\n    map($dir::cwd->lookupdir($_)->{'srcdir'} = $srcdir, @paths);\n\n    # make a reverse lookup for the link.\n    $srcdir->{links} = [] if ! $srcdir->{links};\n    push @{$srcdir->{links}}, @paths;\n}\n\nuse vars qw( @tail ); # TODO: Why global ????\n\nsub linked_targets {\n    my $tgt = shift;\n    my @targets = ();\n    my $dir;\n    if (ref $tgt eq 'dir') {\n\t$dir = $tgt;\n    } else {\n\tpush @tail, $tgt;\n\t$dir = $tgt->{dir};\n    }\n    while ($dir) {\n\tif (defined $dir->{links} && @{$dir->{links}}) {\n\t    push @targets,\n\t\t map(File::Spec->catdir($_, @tail), @{$dir->{links}});\n\t    #print STDERR \"Found Link: ${\\$dir->path} -> @{\\$dir->{links}}\\n\";\n\t}\n\tunshift @tail, $dir->{entry};\n\t$dir = $dir->up;\n    }\n\n    return map($dir::top->lookupdir($_), @targets);\n}\n\nsub accessible {\n    my $path = $_[0]->path;\n    my $err = \"$0: you have attempted to use path \\\"$path\\\" both as a file \" .\n\t      \"and as a directory!\\n\";\n    die $err;\n}\n\nsub init {\n    my $path = Cwd::cwd();\n\n    # We know we can get away with passing undef to lookupdir\n    # as the directory because $dir is an absolute path.\n    $top = lookupdir(undef, $path);\n    $top->{'path'} = $top->{srcpath} = $dir::CURDIR;\n    $top->{'prefix'} = '';\n    $top->{'srcdir'} = $top;\n\n    $cwd = $top;\n\n    ($cwd_vol, undef, undef) = File::Spec->splitpath($path);\n    $cwd_vol = '' if ! defined $cwd_vol;\n    $cwd_vol = uc($cwd_vol) if File::Spec->case_tolerant;\n}\n\f\npackage file;\n\nuse vars qw( @ISA $level );\n\nBEGIN { @ISA = qw(dir); $level = 0 }\n\n# Return the pathname of the file.\n# Define this separately from dir::path because we don't want to\n# cache all file pathnames (just directory pathnames).\nsub path {\n    $_[0]->{dir}->prefix . $_[0]->{entry}\n}\n\n# Return the related source file path.\nsub srcpath {\n    $_[0]->{dir}->srcprefix . $_[0]->{entry}\n}\n\n# Return if the file is (should be) linked to a separate source file.\nsub is_linked {\n    $_[0]->{dir}->is_linked\n}\n\n# Repository file search.  If the local file exists, that wins.\n# Otherwise, return the first existing same-named file under a\n# Repository directory.  If there isn't anything with the same name\n# under a Repository directory, return the local file name anyway\n# so that some higher layer can try to construct it.\nsub rfile {\n    return $_[0]->{rfile} if exists $_[0]->{rfile};\n    my($self) = @_;\n    my($rfile) = $self;\n    if (@param::rpath) {\n\tmy($path) = $self->path;\n\tif (! File::Spec->file_name_is_absolute($path) && ! -f $path) {\n\t    my($dir);\n\t    foreach $dir (@param::rpath) {\n\t\tmy($t) = $dir->prefix . $path;\n\t\tif (-f $t) {\n\t\t    $rfile = $_[0]->lookupfile($t);\n\t\t    $rfile->{'lfile'} = $self;\n\t\t    last;\n\t\t}\n\t    }\n\t}\n    }\n    $self->{rfile} = $rfile;\n}\n\n# Returns the local file for a repository file;\n# returns self if it's already a local file.\nsub lfile {\n    $_[0]->{'lfile'} || $_[0]\n}\n\n# returns the \"precious\" status of this file.\nsub precious {\n    return $_[0]->{precious};\n}\n\n# \"Erase\" reference to a Repository file,\n# making this a completely local file object\n# by pointing it back to itself.\nsub no_rfile {\n    $_[0]->{'rfile'} = $_[0];\n}\n\n# Return a path to the first existing file under a Repository directory,\n# implicitly returning the current file's path if there isn't a\n# same-named file under a Repository directory.\nsub rpath {\n    $_[0]->{rpath} ||\n\t($_[0]->{rpath} = $_[0]->rfile->path)\n}\n\n# Return a path to the first linked srcpath file under a Repositoy\n# directory, implicitly returning the current file's srcpath if there\n# isn't a same-named file under a Repository directory.\nsub rsrcpath {\n    return $_[0]->{rsrcpath} if exists $_[0]->{rsrcpath};\n    my($self) = @_;\n    my($path) = $self->{rsrcpath} = $self->srcpath;\n    if (@param::rpath && ! File::Spec->file_name_is_absolute($path) && ! -f $path) {\n\tmy($dir);\n\tforeach $dir (@param::rpath) {\n\t    my($t) = $dir->prefix . $path;\n\t    if (-f $t) {\n\t\t$self->{rsrcpath} = $t;\n\t\tlast;\n\t    }\n\t}\n    }\n    $self->{rsrcpath};\n}\n\n# Return if a same-named file source file exists.\n# This handles the interaction of Link and Repository logic.\n# As a side effect, it will link a source file from its Linked\n# directory (preferably local, but maybe in a repository)\n# into a build directory from its proper Linked directory.\nsub source_exists {\n    return $_[0]->{source_exists} if defined $_[0]->{source_exists};\n    my($self) = @_;\n    my($path) = $self->path;\n    my($mtime, $ctime) = (stat($path))[9,10];\n    if ($self->is_linked) {\n\t# Linked directory, local logic.\n\tmy($srcpath) = $self->srcpath;\n\tmy($src_mtime, $src_ctime) = (stat($srcpath))[9,10];\n\tif ($src_mtime) {\n\t    if (! $mtime || $src_mtime != $mtime || $src_ctime != $ctime) {\n\t\tfutil::install($srcpath, $self);\n\t    }\n\t    return $self->{source_exists} = 1;\n\t}\n\t# Linked directory, repository logic.\n\tif (@param::rpath) {\n\t    if ($self != $self->rfile) {\n\t\treturn $self->{source_exists} = 1;\n\t    }\n\t    my($rsrcpath) = $self->rsrcpath;\n\t    if ($path ne $rsrcpath) {\n\t\tmy($rsrc_mtime, $rsrc_ctime) = (stat($rsrcpath))[9,10];\n\t\tif ($rsrc_mtime) {\n\t\t    if (! $mtime || $rsrc_mtime != $mtime\n\t\t\t\t || $rsrc_ctime != $ctime) {\n\t\t\tfutil::install($rsrcpath, $self);\n\t\t    }\n\t\t    return $self->{source_exists} = 1;\n\t\t}\n\t    }\n\t}\n\t# There was no source file in any Linked directory\n\t# under any Repository.  If there's one in the local\n\t# build directory, it no longer belongs there.\n\tif ($mtime) {\n\t    unlink($path) || die(\"$0: couldn't unlink $path ($!)\\n\");\n\t}\n\treturn $self->{source_exists} = '';\n    } else {\n\tif ($mtime) {\n\t    return $self->{source_exists} = 1;\n\t}\n\tif (@param::rpath && $self != $self->rfile) {\n\t    return $self->{source_exists} = 1;\n\t}\n\treturn $self->{source_exists} = '';\n    }\n}\n\n# Return if a same-named derived file exists under a Repository directory.\nsub derived_exists {\n    $_[0]->{derived_exists} ||\n\t($_[0]->{derived_exists} = ($_[0] != $_[0]->rfile));\n}\n\n# Return if this file is somewhere under a Repository directory.\nsub is_on_rpath {\n    defined $_[0]->{'lfile'};\n}\n\nsub local {\n    my($self, $arg) = @_;\n    if (defined $arg) {\n\t$self->{'local'} = $arg;\n    }\n    $self->{'local'};\n}\n\n# Return the entry name of the specified file with the specified\n# suffix appended.  Leave it untouched if the suffix is already there.\n# Differs from the addsuffix function, below, in that this strips\n# the existing suffix (if any) before appending the desired one.\nsub base_suf {\n    my($entry) = $_[0]->{entry};\n    if ($entry !~ m/$_[1]$/) {\n\t$entry =~ s/\\.[^\\.]*$//;\n\t$entry .= $_[1];\n    }\n    $entry;\n}\n\n# Return the suffix of the file; everything including and to the\n# right of the last dot.\nsub suffix {\n    my @pieces = split(/\\./, $_[0]->{entry});\n    my $suffix = pop(@pieces);\n    return \".$suffix\";\n}\n\n# Called as a simple function file::addsuffix(name, suffix)\nsub addsuffix {\n    my($name, $suffix) = @_;\n\n    if ($suffix && substr($name, -length($suffix)) ne $suffix) {\n\treturn $name .= $suffix;\n    }\n    $name;\n}\n\n# Return true if the file is (or will be) accessible.\n# That is, if we can build it, or if it is already present.\nsub accessible {\n    (exists $_[0]->{builder}) || ($_[0]->source_exists);\n}\n\n# Return true if the file should be ignored for the purpose\n# of computing dependency information (should not be considered\n# as a dependency and, further, should not be scanned for\n# dependencies).\nsub ignore {\n    return 0 if !$param::ignore;\n    return $_[0]->{ignore} if exists $_[0]->{ignore};\n    $_[0]->{ignore} = $_[0]->path =~ /$param::ignore/o;\n}\n\n# Build the file, if necessary.\nsub build {\n    return $_[0]->{status} if $_[0]->{status};\n    my($status) = &file::_build;\n    if ($_[0]->{after_build_func}) {\n\tmy($pkgvars) = $_[0]->{conscript}->{pkgvars};\n\tNameSpace::restore('script', $pkgvars) if $pkgvars;\n\teval(\"package script; \" . $_[0]->{after_build_func});\n\tprint \"Error running AfterBuild for ${\\$_[0]->path}: $@\\n\" if ($@);\n\tNameSpace::remove('script', keys %$pkgvars) if $pkgvars;\n    }\n    return $status;\n}\n\nsub _build {\n    my($self) = @_;\n    print main::DEPFILE $self->path, \"\\n\" if $param::depfile;\n    print((' ' x $level), \"Checking \", $self->path, \"\\n\") if $param::depends;\n    if (!exists $self->{builder}) {\n\t# We don't know how to build the file. This is OK, if\n\t# the file is present as a source file, under either the\n\t# local tree or a Repository.\n\tif ($self->source_exists) {\n\t    return $self->{status} = 'handled';\n\t} else {\n\t    my($name) = $self->path;\n\t    print(\"$0: don't know how to construct \\\"$name\\\"\\n\");\n\t    exit(1) unless $param::kflag;\n\t    return $self->{status} = 'errors'; # xxx used to be 'unknown'\n\t}\n    }\n\n    # An associated build object exists, so we know how to build\n    # the file. We first compute the signature of the file, based\n    # on its dependendencies, then only rebuild the file if the\n    # signature has changed.\n    my($builder) = $self->{builder};\n    $level += 2;\n\n    my(@deps) = (@{$self->{dep}}, @{$self->{sources}});\n    my($rdeps) = \\@deps;\n\n    if ($param::random) {\n\t# If requested, build in a random order, instead of the\n\t# order that the dependencies were listed.\n\tmy(%rdeps);\n\tmap { $rdeps{$_,'*' x int(rand 10)} = $_ } @deps;\n\t$rdeps = [values(%rdeps)];\n    }\n\n    $self->{status} = '';\n\n    my $dep;\n    for $dep (@$rdeps) {\n\tif ((build $dep) eq 'errors') {\n\t    # Propagate dependent errors to target.\n\t    # but try to build all dependents regardless of errors.\n\t    $self->{status} = 'errors';\n\t}\n    }\n\n    # If any dependents had errors, then we abort.\n    if ($self->{status} eq 'errors') {\n\t$level -= 2;\n\treturn 'errors';\n    }\n\n    # Compute the final signature of the file, based on\n    # the static dependencies (in order), dynamic dependencies,\n    # output path name, and (non-substituted) build script.\n    my($sig) = 'sig'->collect(map('sig'->signature($_->rfile), @deps),\n\t\t\t    $builder->includes($self),\n\t\t\t    $builder->scriptsig);\n\n    # May have gotten errors during computation of dynamic\n    # dependency signature, above.\n    $level -= 2;\n    return 'errors' if $self->{status} eq 'errors';\n\n    if (@param::rpath && $self->derived_exists) {\n\t# There is no local file of this name, but there is one\n\t# under a Repository directory.\n\n\tif ('sig'->current($self->rfile, $sig)) {\n\t    # The Repository copy is current (its signature matches\n\t    # our calculated signature).\n\t    if ($self->local) {\n\t\t# ...but they want a local copy, so provide it.\n\t\tmain::showcom(\"Local copy of ${\\$self->path} from \" .\n\t\t\t      \"${\\$self->rpath}\");\n\t\tfutil::install($self->rpath, $self);\n\t\t'sig'->bsig($self, $sig);\n\t    }\n\t    return $self->{status} = 'handled';\n\t}\n\n\t# The signatures don't match, implicitly because something\n\t# on which we depend exists locally.  Get rid of the reference\n\t# to the Repository file; we'll build this (and anything that\n\t# depends on it) locally.\n\t$self->no_rfile;\n    }\n\n    # Then check for currency.\n    if (! 'sig'->current($self, $sig)) {\n\t# We have to build/derive the file.\n\tprint((' ' x $level), \"Rebuilding \", $self->path, \": out of date.\\n\")\n\t\tif $param::depends;\n\t# First check to see if the built file is cached.\n\tif ($builder->cachin($self, $sig)) {\n\t    'sig'->bsig($self, $sig);\n\t    return $self->{status} = 'built';\n\t} elsif ($builder->action($self)) {\n\t    $builder->cachout($self, $sig);\n\t    'sig'->bsig($self, $sig);\n\t    return $self->{status} = 'built';\n\t} else {\n\t    die(\"$0: errors constructing ${\\$self->path}\\n\")\n\t\tunless $param::kflag;\n\t    return $self->{status} = 'errors';\n\t}\n    } else {\n\t# Push this out to the cache if we've been asked to (-C option).\n\t# Don't normally do this because it slows us down.\n\t# In a fully built system, no accesses to the cache directory\n\t# are required to check any files. This is a win if cache is\n\t# heavily shared. Enabling this option puts the directory in the\n\t# loop. Useful only when you wish to recreate a cache from a build.\n\tif ($param::cachesync) {\n\t    $builder->cachout($self, $sig);\n\t    'sig'->bsig($self, $sig);\n\t}\n\treturn $self->{status} = 'handled';\n    }\n}\n\n# Bind an action to a file, with the specified sources. No return value.\nsub bind {\n    my($self, $builder, @sources) = @_;\n    if ($self->{builder} && !$self->{builder}->compatible($builder)) {\n\t# Even if not \"compatible\", we can still check to see if the\n\t# derivation is identical. It should be identical if the builder is\n\t# the same and the sources are the same.\n\tif (\"$self->{builder} @{$self->{sources}}\" ne \"$builder @sources\") {\n\t    $main::errors++;\n\t    my($_foo1, $script1, $line1, $sub1) = @{$self->creator};\n\t    my($_foo2, $script2, $line2, $sub2) = script::caller_info;\n\t    my $err = \"\\t${\\$self->path}\\n\" .\n\t\t      \"\\tbuilt (at least) two different ways:\\n\" .\n\t\t      \"\\t\\t$script1, line $line1:  $sub1\\n\" .\n\t\t      \"\\t\\t$script2, line $line2:  $sub2\\n\";\n\t    die $err;\n\t}\n\treturn;\n    }\n    if ($param::wflag) {\n\tmy($script, $line, $sub);\n\t(undef, $script, $line, $sub) = script::caller_info;\n\t$self->{script} = '' if ! defined $self->{script};\n\t$self->{script} .= \"; \" if $self->{script};\n\t$self->{script} .= qq($sub in \"$script\", line $line);\n    }\n    $self->{builder} = $builder;\n    push(@{$self->{sources}}, @sources);\n    @{$self->{dep}} = () if ! defined $self->{dep};\n    $self->{conscript} = $priv::self->{script};\n}\n\nsub is_under {\n    $_[0]->{dir}->is_under($_[1]);\n}\n\nsub relpath {\n    my $dirpath = $_[0]->relpath($_[1]->{dir});\n    if (! $dirpath) {\n\treturn $_[1]->{entry};\n    } else {\n\tFile::Spec->catfile($dirpath, $_[1]->{entry});\n    }\n}\n\n# Return the signature array for this file.\n# This probably belongs in its own \"sigarray\" package,\n# which would make it easier to optimize performance.\nsub sigarray {\n    if ($_[0]->{sigaref}) {\n\treturn @{$_[0]->{sigaref}};\n    }\n    my $self = shift;\n    # glob2pat based on The Perl Cookbook, p. 180.\n    sub glob2pat {\n\tmy $globstr = shift;\n\tmy %patmap = (\n\t    '*' => '.*',\n\t    '?' => '.',\n\t    '[' => '[',\n\t    ']' => ']',\n\t    '/' => \"\\Q$dir::SEPARATOR\",\t# Cons-specific modification\n\t);\n\t$globstr =~ s{(.)} { $patmap{$1} || \"\\Q$1\" }ge;\n\treturn '^' . $globstr . '$';\n    }\n    my @sigarray;\n    my $default;\n    my $builder = $self->lfile->{builder};\n    if (! $builder) {\n\t@sigarray = @$param::sourcesig;\n\t$default = [qw(content)];\n    } else {\n\tif ($builder->{env} && $builder->{env}->{SIGNATURE}) {\n\t    @sigarray = @{$builder->{env}->{SIGNATURE}};\n\t} else {\n\t    my $class = ref $builder;\n\t    my $path = $self->path;\n\t    warn qq($0: Warning:  Builder package $class did not record\\n) .\n\t\t qq(\\tthe calling environment for '$path'.\\n) .\n\t\t qq(\\tUnable to use any %SIGNATURE construction variable\\n) .\n\t\t qq(\\tfor signature configuration.\\n);\n\t}\n\t$default = [qw(build)];\n    }\n    my $path = $self->path;\n    while (@sigarray) {\n\tmy($glob, $aref) = splice(@sigarray, 0, 2);\n\tmy $re = glob2pat($glob);\n\tif ($path =~ /$re/) {\n\t    $aref = [split(/\\s+/, $aref)] if ! ref $aref;\n\t    $self->{sigaref} = $aref;\n\t    return @$aref;\n\t}\n    }\n    $self->{sigaref} = $default;\n    return @{$self->{sigaref}}\n}\n\n# Decide if this file's signature should be the content or build signature.\nsub sigtype {\n    if ($_[0]->{sigtype}) {\n\treturn $_[0]->{sigtype};\n    }\n    my $self = shift;\n    my @sigarray = $self->sigarray;\n    my $sigtype;\n    if (grep($_ eq \"build\", @sigarray)) {\n\t$sigtype = 'bsig';\n    } elsif (grep($_ =~ /content$/, @sigarray)) {\n\t$sigtype = 'csig';\n    }\n    return $self->{sigtype} = $sigtype;\n}\n\n# Return whether this file is configured to use stored\n# signature values from the .consign file.\nsub stored {\n    if (! defined $_[0]->{stored}) {\n\t$_[0]->{stored} = grep($_ eq \"stored-content\", $_[0]->sigarray);\n    }\n    return $_[0]->{stored};\n}\n\f\n# Generic entry (file or directory) handling.\n# This is an empty subclass for nodes that haven't\n# quite decided whether they're files or dirs.\n# Use file methods until someone blesses them one way or the other.\npackage entry;\n\nuse vars qw( @ISA );\n\nBEGIN { @ISA = qw(file) }\n\f\n# File utilities\npackage futil;\n\n# Install one file as another.\n# Links them if possible (hard link), otherwise copies.\n# Don't ask why, but the source is a path, the tgt is a file obj.\nsub install {\n    my($sp, $tgt) = @_;\n    my($tp) = $tgt->path;\n    return 1 if $tp eq $sp;\n    return 1 if eval { link($sp, $tp) };\n    unlink($tp);\n    if (! futil::mkdir($tgt->{dir})) {\n\treturn undef;\n    }\n    return 1 if eval { link($sp, $tp) };\n    futil::copy($sp, $tp);\n}\n\n# Copy one file to another. Arguments are actual file names.\n# Returns undef on failure. Preserves mtime and mode.\nsub copy {\n    my ($sp, $tp) = @_;\n    my ($mode, $length, $atime, $mtime) = (stat($sp))[2,7,8,9];\n\n    # Use Perl standard library module for file copying, which handles\n    # binary copies. <schwarze@isa.de> 1998-06-18\n    if (! File::Copy::copy($sp, $tp)) {\n\twarn qq($0: can\\'t install \"$sp\" to \"$tp\" ($!)\\n); #'\n\treturn undef;\n    }\n    # The file has been created, so try both the chmod and utime,\n    # first making sure the copy is writable (because permissions\n    # affect the ability to modify file times on some operating\n    # systems), and then changing permissions back if necessary.\n    my $ret = 1;\n    my $wmode = $mode | 0700;\n    if (! chmod $wmode, $tp) {\n\twarn qq($0: can\\'t set mode $wmode on file \"$tp\" ($!)\\n); #'\n\t$ret = undef;\n    }\n    if (! utime $atime, $mtime, $tp) {\n\twarn qq($0: can\\'t set modification time for file \"$tp\" ($!)\\n); #'\n\t$ret = undef;\n    }\n    if ($mode !=  $wmode && ! chmod $mode, $tp) {\n\twarn qq($0: can\\'t set mode $mode on file \"$tp\" ($!)\\n); #'\n\t$ret = undef;\n    }\n    return $ret;\n}\n\n# Ensure that the specified directory exists.\n# Aborts on failure.\nsub mkdir {\n    return 1 if $_[0]->{'exists'};\n    if (! futil::mkdir($_[0]->{dir})) { # Recursively make parent.\n\treturn undef;\n    }\n    my($path) = $_[0]->path;\n    if (!-d $path && !mkdir($path, 0777)) {\n\twarn qq($0: can't create directory $path ($!).\\n); #'\n\treturn undef;\n    }\n    $_[0]->{'exists'} = 1;\n}\n\n\f\n# Signature package.\npackage sig::hash;\n\nuse vars qw( $called );\n\nsub init {\n    my($dir) = @_;\n    my($consign) = $dir->prefix . \".consign\";\n    my($dhash) = $dir->{consign} = {};\n    if (-f $consign) {\n\topen(CONSIGN, $consign) || die(\"$0: can't open $consign ($!)\\n\");\n\twhile(<CONSIGN>) {\n\t    chop;\n\t    my ($file, $sig) = split(/:/,$_);\n\t    $dhash->{$file} = $sig;\n\t}\n\tclose(CONSIGN);\n    }\n    $dhash\n}\n\n# Read the hash entry for a particular file.\nsub in {\n    my($dir) = $_[0]->{dir};\n    ($dir->{consign} || init($dir))->{$_[0]->{entry}}\n}\n\n# Write the hash entry for a particular file.\nsub out {\n    my($file, $sig) = @_;\n    my($dir) = $file->{dir};\n    ($dir->{consign} || init($dir))->{$file->{entry}} = $sig;\n    $sig::hash::dirty{$dir} = $dir;\n}\n\n# Eliminate the hash entry for a particular file.\nsub clear {\n    my($file) = @_;\n    my($dir) = $file->{dir};\n    delete $dir->{consign}->{$file->{entry}} if $dir->{consign};\n    $sig::hash::dirty{$dir} = $dir;\n}\n\n# Flush hash entries. Called at end or via ^C interrupt.\nsub END {\n    return if $called++; # May be called twice.\n    close(CONSIGN); # in case this came in via ^C.\n    my $dir;\n    for $dir (values %sig::hash::dirty) {\n\tmy($consign) = $dir->prefix . \".consign\";\n\tmy($constemp) = $consign . \".$$\";\n\tif (! open(CONSIGN, \">$constemp\")) {\n\t    die(\"$0: can't create $constemp ($!)\\n\");\n\t}\n\tmy($entry, $sig);\n\twhile (($entry, $sig) = each %{$dir->{consign}}) {\n\t    if (! print CONSIGN \"$entry:$sig\\n\") {\n\t\tdie(\"$0: error writing to $constemp ($!)\\n\");\n\t    }\n\t}\n\tclose(CONSIGN);\n\tif (! rename($constemp, $consign)) {\n\t    if (futil::copy($constemp, $consign)) {\n\t\tunlink($constemp);\n\t    } else {\n\t\tdie(\"$0: couldn't rename or copy $constemp to $consign \" .\n\t\t    \"($!)\\n\");\n\t    }\n\t}\n    }\n}\n\n\f\n# Derived file caching.\npackage cache;\n\n# Find a file in the cache. Return non-null if the file is in the cache.\nsub in {\n    return undef unless $param::cache;\n    my($file, $sig) = @_;\n    # Add the path to the signature, to make it unique.\n    $sig = 'sig'->collect($sig, $file->path) unless $param::mixtargets;\n    my($dir) = substr($sig, 0, 1);\n    my($cp) = File::Spec->catfile($param::cache, $dir, $sig);\n    return -f $cp && futil::install($cp, $file);\n}\n\n# Try to flush a file to the cache, if not already there.\n# If it doesn't make it out, due to an error, then that doesn't\n# really matter.\nsub out {\n    return unless $param::cache;\n    my($file, $sig) = @_;\n    # Add the path to the signature, to make it unique.\n    $sig = 'sig'->collect($sig, $file->path) unless $param::mixtargets;\n    my($dir) = substr($sig, 0, 1);\n    my($sp) = $file->path;\n    my($cp) = File::Spec->catfile($param::cache, $dir, $sig);\n    my($cdir) = File::Spec->catfile($param::cache, $dir);\n    if (! -d $cdir) {\n\tmkdir($cdir, 0777) ||\n\t    die(\"$0: can't create cache directory $cdir ($!).\\n\");\n    } elsif (-f $cp) {\n\t# Already cached: try to use that instead, to save space.\n\t# This can happen if the -cs option is used on a previously\n\t# uncached build, or if two builds occur simultaneously.\n\tmy($lp) = \".$sig\";\n\tunlink($lp);\n\treturn if ! eval { link($cp, $lp) };\n\trename($lp, $sp);\n\t# Unix98 says, \"If the old argument and the new argument both\n\t# [refer] to the same existing file, the rename() function\n\t# returns successfully and performs no other action.\"  So, if\n\t# $lp and $sp are links (i.e., $cp and $sp are links), $lp is\n\t# left, and we must unlink it ourselves.  If the rename failed\n\t# for any reason, it is also good form to unlink the temporary\n\t# $lp.  Otherwise $lp no longer exists and, barring some race,\n\t# the unlink fails silently.\n\tunlink($lp);\n\treturn;\n    }\n\n    return if eval { link($sp, $cp) };\n    return if ! -f $sp; # if nothing to cache.\n    if (futil::copy($sp, \"$cp.new\")) {\n\trename(\"$cp.new\", $cp);\n    }\n}\n\n\f\n# Generic signature handling package.\n# This handles the higher-layer distinction between content and build\n# signatures, relying on an underlying calculation package like\n# \"sig::md5\"\" to provide the signature values themselves.\npackage sig;\n\nuse vars qw( @ISA );\n\n# Select the underlying package to be used for signature calculation.\n# We play a few namespace games here.  Specifically, we append\n# \"sig::\" to the beginning of the subclass we're passed.  Then,\n# if the package ends in \"::debug\", we actually subclass the\n# \"sig::debug\" package and as a wrapper around the underlying\n# (e.g.) \"sig::md5\" package that's doing the real calculation.\nsub select {\n    my($package, $subclass) = @_;\n    my $p = $package . \"::\" . $subclass;\n    my $sigpkg = $p;\n    if ($p =~ /(.*)::debug$/) {\n\t$sigpkg = $1;\n\t$p = 'sig::debug';\n    }\n    @ISA = ($p);\n    $p->init($sigpkg);\n};\n\n# Set or return the build signature of a file.\n# This is computed elsewhere and passed in to us.\nsub bsig {\n    my($self, $file, $sig) = @_;\n    if (defined $sig) {\n\t$file->{'bsig'} = $sig;\n\t$self->set($file);\n    } elsif (! defined $file->{'bsig'}) {\n\t$file->{'bsig'} = '';\n    }\n    $file->{'bsig'}\n}\n\n# Determine the content signature of a file.\n# This also sets the .consign entry unless the file is in a\n# repository; we don't write into repositories, only read from them.\nsub csig {\n    my($self, $file) = @_;\n    if (! $file->{'csig'}) {\n\t$file->{'csig'} = $self->srcsig($file->path);\n\t$self->set($file) if ! $file->is_on_rpath;\n    }\n    $_[1]->{'csig'}\n}\n\n# Determine the current signature of an already-existing or\n# non-existant file.  Unless a specific signature type (bsig\n# or csig) is requested, this consults the file's signature\n# array to decide whether to return content or build signature,\n# and whether to use a cached value from a .consign file.\nsub signature {\n    my($self, $file, $sigtype) = @_;\n    $sigtype = $file->sigtype if ! $sigtype;\n    #open(TTY, \">/dev/tty\");\n    #print TTY $file->path, \": $sigtype\\n\";\n    #close(TTY);\n    my($path) = $file->path;\n    my($time) = (stat($path))[9];\n    if ($time) {\n\tif ($file->{$sigtype}) {\n\t    return $file->{$sigtype};\n\t}\n\tif ($file->is_on_rpath || $file->stored) {\n\t    if ('sig'->fetch($file) && $file->{$sigtype}) {\n\t\tif ($file->{'sigtime'} == $time ||\n\t\t    ! $param::rep_sig_times_ok\n\t\t    && $file->is_on_rpath) {\n\t\t    return $file->{$sigtype};\n\t\t}\n\t    }\n\t    $file->{$sigtype} = undef;\n\t}\n\tif ($file->is_on_rpath || ! File::Spec->file_name_is_absolute($path)) {\n\t    my $sig = '';\n\t    if ($sigtype eq 'bsig') { $sig = $self->bsig($file); }\n\t    elsif ($sigtype eq 'csig') { $sig = $self->csig($file); }\n\t    return $sig;\n\t}\n\t# This file is not in a repository or under the local directory\n\t# structure.  In the canonical case, it's a utility that will be\n\t# executed by a command.  Historically, Cons has returned the\n\t# name of the command concatenated with the modification time.\n\t# Note that this is *not* the path (\"cc\" not \"/bin/cc\"), so it\n\t# would lose in the unlikely event that a different copy of the\n\t# utility was used that happened to have the same modification\n\t# time (due to living in a different directory on the PATH, for\n\t# example).  The obvious \"fix\" of using the path like so, however:\n\t#\treturn $path . $time;\n\t# is wrong.  In a multi-machine build environment, different\n\t# systems may have the same utility in different locations (due\n\t# to different NFS mount points, for example), which would\n\t# cause a lot of unnecessary builds if we used the full path.\n\t# A better solution to strengthen this signature would be to\n\t# also concatenate the size of the file, but that would cause\n\t# unnecessary rebuilds when coming from .consign files that used\n\t# the old scheme.  All of which is to merely explain why we're\n\t# leaving this as it has been, but documenting it here in case\n\t# there's reason to change it in the future.\n\treturn $file->{entry} . $time;\n    }\n    return $file->{$sigtype} = '';\n}\n\nsub bsignature {\n    my($self, $file) = @_;\n    my($path) = $file->path;\n    my($time) = (stat($path))[9];\n    if ($time) {\n\tif ($file->{'bsig'}) {\n\t    return $file->{'bsig'};\n\t}\n\tif ('sig'->fetch($file, 'bsig') && $file->{'bsig'}) {\n\t\tif ($file->{'sigtime'} == $time ||\n\t\t    ! $param::rep_sig_times_ok\n\t\t    && $file->is_on_rpath) {\n\t\t    return $file->{'bsig'};\n\t\t}\n\t}\n\tif ($file->is_on_rpath || ! File::Spec->file_name_is_absolute($path)) {\n\t    return $self->bsig($file);\n\t}\n\treturn $path . $time;\n    }\n    return $file->{'bsig'} = '';\n}\n\n# Invalidate a file's signature, also clearing its .consign entry.\nsub invalidate {\n    my($self, $file) = @_;\n    delete $file->{'sigtime'};\n    delete $file->{'bsig'};\n    delete $file->{'csig'};\n    sig::hash::clear($file);\n}\n\n# Store the signature for a file.\nsub set {\n    my($self, $file) = @_;\n    my $sig = (stat($file->path))[9];\n    $sig .= \" \" . ($file->{'bsig'} || '-');\n    $sig .= \" \" . $file->{'csig'} if $file->{'csig'};\n    sig::hash::out($file, $sig);\n}\n\n# Fetch the signature(s) for a file.\n# Returns whether there was a signature to fetch.\nsub fetch {\n    my($self, $file, @kw) = @_;\n    @kw = ('bsig', 'csig') if ! @kw;\n    my $sig = sig::hash::in($file) || '';\n    my($sigtime, $bsig, $csig) = split(/ /, $sig);\n    $file->{'sigtime'} = $sigtime;\n    $file->{'bsig'} = $bsig || '' if grep($_ eq 'bsig', @kw);\n    $file->{'csig'} = $csig || '' if grep($_ eq 'csig', @kw);\n    $file->{'bsig'} = '' if $file->{'bsig'} eq '-';\n    return $sig ne '';\n}\n\f\n# MD5-based signature package.\npackage sig::md5;\n\nuse vars qw( $md5 );\n\n# Initialize MD5 signature calculation by finding an appropriate\n# module and creating the proper object.\nsub init {\n    my $self = shift;\n    my @md5_modules = qw(Digest::MD5 MD5 Digest::Perl::MD5);\n    # We used to find the right module more simply, using $_ as the\n    # loop iterator and just doing:\n    #\n    #\t\teval \"use $_\";\n    #\t\t$module = $_, $last if ! $@;\n    #\n    # in the loop.  Empirically, though, this doesn't pass back the\n    # right value in $module on some ActiveState versions.  (Maybe\n    # it's something to do with the eval in a for loop, I dunno.)\n    # Work around it by using $_ to pass the value out of the loop,\n    # which seems to work everywhere.\n    my $module;\n    for $module (@md5_modules) {\n\teval \"use $module\";\n\t$_ = $module, last if ! $@;\n    }\n    $module = $_;\n    die \"Cannot find any MD5 module from:  @md5_modules\" if $@;\n\n    $md5 = new $module;\n}\n\n# Is the provided signature equal to the signature of the current\n# instantiation of the target (and does the target exist)?\nsub current {\n    my($self, $file, $sig, $sigtype) = @_;\n    $self->bsignature($file) eq $sig;\n}\n\n# Return an aggregate signature for a list of signature values.\nsub collect {\n    my($self, @sigs) = @_;\n    # The following sequence is faster than calling the hex interface.\n    $md5->reset();\n    $md5->add(join('', $param::salt, @sigs));\n    unpack(\"H*\", $md5->digest());\n}\n\n# Directly compute a file signature as the MD5 checksum of the\n# bytes in the file.\nsub srcsig {\n    my($self, $path) = @_;\n    $md5->reset();\n    open(FILE, $path) || return '';\n    binmode(FILE);\n    $md5->addfile(\\*FILE);\n    close(FILE);\n    unpack(\"H*\", $md5->digest());\n}\n\n# Compute the signature of a command string.\n# For MD5, this is just the string itself, since MD5 will condense\n# the string contents into the ultimate signature.  Other signature\n# schemes may need to figure this out differently.\nsub cmdsig {\n    my($self, $sig) = @_;\n    return $sig\n}\n\f\n# Generic debug package for signature calculation.\n# Because of the way we're called by sig::select() and then use\n# the specified value to set up @ISA, this package is essentially a\n# factory that creates packages like sig::md5::debug, etc., on the fly.\npackage sig::debug;\n\nuse vars qw( @ISA $sigpkg $outfh );\n\nlocal *FH;\n\nsub init {\n    my $self = shift;\n    $sigpkg = shift;\n    @ISA = ($sigpkg);\n    $sigpkg->init();\n    my $file = $ENV{CONS_SIG_DEBUG};\n    if ($file) {\n\tif (! open(FH, \">$file\")) {\n\t    die \"Cannot open $file: $!\";\n\t}\n\t$outfh = \\*FH;\n    } else {\n\t$outfh = \\*STDOUT;\n    }\n}\n\nsub current {\n    my($self, $file, $sig, $sigtype) = @_;\n    my $fsig = $self->bsignature($file);\n    my $sub = \"${sigpkg}::current\";\n    my $sep = \"\\n\" . ' ' x (length($sub) + 1 - 3);\n    print $outfh \"$sub(|$fsig|${sep}eq |$sig|)\\n\";\n    return $fsig eq $sig;\n}\n\nsub collect {\n    my($self, @sigs) = @_;\n    my $sig = $sigpkg->collect(@sigs);\n    my $sub = \"${sigpkg}::collect\";\n    my $sep = \",\\n\" . ' ' x (length($sub) + 1);\n    my $buf = join($sep, @sigs);\n    $buf = $param::salt . $sep . $buf if $param::salt;\n    print $outfh \"$sub($buf)\\n\\t=> |$sig|\\n\";\n    return $sig;\n}\n\nsub srcsig {\n    my($self, $path) = @_;\n    my $sig = $sigpkg->srcsig($path);\n    print $outfh \"${sigpkg}::srcsig($path)\\n\\t=> |$sig|\\n\";\n    return $sig;\n}\n\n__END__;\n\n=head1 NAME\n\nCons - A Software Construction System\n\n=head1 DESCRIPTION\n\nA guide and reference for version 2.3.1\n\nCopyright (c) 1996-2001 Free Software Foundation, Inc.\n\nThis program is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 2 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; see the file COPYING.  If not, write to\nthe Free Software Foundation, Inc., 59 Temple Place - Suite 330,\nBoston, MA 02111-1307, USA.\n\n=head1 Introduction\n\nB<Cons> is a system for constructing, primarily, software, but is quite\ndifferent from previous software construction systems. Cons was designed\nfrom the ground up to deal easily with the construction of software spread\nover multiple source directories. Cons makes it easy to create build scripts\nthat are simple, understandable and maintainable. Cons ensures that complex\nsoftware is easily and accurately reproducible.\n\nCons uses a number of techniques to accomplish all of this. Construction\nscripts are just Perl scripts, making them both easy to comprehend and very\nflexible. Global scoping of variables is replaced with an import/export\nmechanism for sharing information between scripts, significantly improving\nthe readability and maintainability of each script. B<Construction\nenvironments> are introduced: these are Perl objects that capture the\ninformation required for controlling the build process. Multiple\nenvironments are used when different semantics are required for generating\nproducts in the build tree. Cons implements automatic dependency analysis\nand uses this to globally sequence the entire build. Variant builds are\neasily produced from a single source tree. Intelligent build subsetting is\npossible, when working on localized changes. Overrides can be setup to\neasily override build instructions without modifying any scripts. MD5\ncryptographic B<signatures> are associated with derived files, and are used\nto accurately determine whether a given file needs to be rebuilt.\n\nWhile offering all of the above, and more, Cons remains simple and easy to\nuse. This will, hopefully, become clear as you read the remainder of this\ndocument.\n\n\n=head1 Why Cons? Why not Make?\n\nCons is a B<make> replacement. In the following paragraphs, we look at a few\nof the undesirable characteristics of make--and typical build environments\nbased on make--that motivated the development of Cons.\n\n=head2 Build complexity\n\nTraditional make-based systems of any size tend to become quite complex. The\noriginal make utility and its derivatives have contributed to this tendency\nin a number of ways. Make is not good at dealing with systems that are\nspread over multiple directories. Various work-arounds are used to overcome\nthis difficulty; the usual choice is for make to invoke itself recursively\nfor each sub-directory of a build. This leads to complicated code, in which\nit is often unclear how a variable is set, or what effect the setting of a\nvariable will have on the build as a whole. The make scripting language has\ngradually been extended to provide more possibilities, but these have\nlargely served to clutter an already overextended language. Often, builds\nare done in multiple passes in order to provide appropriate products from\none directory to another directory. This represents a further increase in\nbuild complexity.\n\n\n=head2 Build reproducibility\n\nThe bane of all makes has always been the correct handling of\ndependencies. Most often, an attempt is made to do a reasonable job of\ndependencies within a single directory, but no serious attempt is made to do\nthe job between directories. Even when dependencies are working correctly,\nmake's reliance on a simple time stamp comparison to determine whether a\nfile is out of date with respect to its dependents is not, in general,\nadequate for determining when a file should be rederived. If an external\nlibrary, for example, is rebuilt and then ``snapped'' into place, the\ntimestamps on its newly created files may well be earlier than the last\nlocal build, since it was built before it became visible.\n\n\n=head2 Variant builds\n\nMake provides only limited facilities for handling variant builds. With the\nproliferation of hardware platforms and the need for debuggable\nvs. optimized code, the ability to easily create these variants is\nessential. More importantly, if variants are created, it is important to\neither be able to separate the variants or to be able to reproduce the\noriginal or variant at will. With make it is very difficult to separate the\nbuilds into multiple build directories, separate from the source. And if\nthis technique isn't used, it's also virtually impossible to guarantee at\nany given time which variant is present in the tree, without resorting to a\ncomplete rebuild.\n\n\n=head2 Repositories\n\nMake provides only limited support for building software from code that\nexists in a central repository directory structure.  The VPATH feature of\nGNU make (and some other make implementations) is intended to provide this,\nbut doesn't work as expected: it changes the path of target file to the\nVPATH name too early in its analysis, and therefore searches for all\ndependencies in the VPATH directory.  To ensure correct development builds,\nit is important to be able to create a file in a local build directory and\nhave any files in a code repository (a VPATH directory, in make terms) that\ndepend on the local file get rebuilt properly.  This isn't possible with\nVPATH, without coding a lot of complex repository knowledge directly into\nthe makefiles.\n\n\n=head1 Keeping it simple\n\nA few of the difficulties with make have been cited above. In this and\nsubsequent sections, we shall introduce Cons and show how these issues are\naddressed.\n\n=head2 Perl scripts\n\nCons is Perl-based. That is, Cons scripts--F<Conscript> and F<Construct>\nfiles, the equivalent to F<Makefile> or F<makefile>--are all written in\nPerl. This provides an immediate benefit: the language for writing scripts\nis a familiar one. Even if you don't happen to be a Perl programmer, it\nhelps to know that Perl is basically just a simple declarative language,\nwith a well-defined flow of control, and familiar semantics. It has\nvariables that behave basically the way you would expect them to,\nsubroutines, flow of control, and so on. There is no special syntax\nintroduced for Cons. The use of Perl as a scripting language simplifies\nthe task of expressing the appropriate solution to the often complex\nrequirements of a build.\n\n\n=head2 Hello, World!\n\nTo ground the following discussion, here's how you could build the B<Hello,\nWorld!> C application with Cons:\n\n\n\n  $env = new cons();\n  Program $env 'hello', 'hello.c';\n\nIf you install this script in a directory, naming the script F<Construct>,\nand create the F<hello.c> source file in the same directory, then you can\ntype C<cons hello> to build the application:\n\n\n\n  % cons hello\n  cc -c hello.c -o hello.o\n  cc -o hello hello.o\n\n\n=head2 Construction environments\n\nA key simplification of Cons is the idea of a B<construction environment>. A\nconstruction environment is an B<object> characterized by a set of key/value\npairs and a set of B<methods>. In order to tell Cons how to build something,\nyou invoke the appropriate method via an appropriate construction\nenvironment. Consider the following example:\n\n\n\n  $env = new cons(\n\tCC\t=>\t'gcc',\n\tLIBS\t=>\t'libworld.a'\n  );\n\n  Program $env 'hello', 'hello.c';\n\nIn this case, rather than using the default construction environment, as is,\nwe have overridden the value of C<CC> so that the GNU C Compiler equivalent\nis used, instead. Since this version of B<Hello, World!> requires a library,\nF<libworld.a>, we have specified that any program linked in this environment\nshould be linked with that library. If the library exists already, well and\ngood, but if not, then we'll also have to include the statement:\n\n\n\n  Library $env 'libworld', 'world.c';\n\nNow if you type C<cons hello>, the library will be built before the program\nis linked, and, of course, C<gcc> will be used to compile both modules:\n\n\n\n  % cons hello\n  gcc -c hello.c -o hello.o\n  gcc -c world.c -o world.o\n  ar r libworld.a world.o\n  ar: creating libworld.a\n  ranlib libworld.a\n  gcc -o hello hello.o libworld.a\n\n\n=head2 Automatic and complete dependency analysis\n\nWith Cons, dependencies are handled automatically. Continuing the previous\nexample, note that when we modify F<world.c>, F<world.o> is recompiled,\nF<libworld.a> recreated, and F<hello> relinked:\n\n\n\n  % vi world.c\n    [EDIT]\n  % cons hello\n  gcc -c world.c -o world.o\n  ar r libworld.a world.o\n  ar: creating libworld.a\n  ranlib libworld.a\n  gcc -o hello hello.o libworld.a\n\nThis is a relatively simple example: Cons ``knows'' F<world.o> depends upon\nF<world.c>, because the dependency is explicitly set up by the C<Library>\nmethod. It also knows that F<libworld.a> depends upon F<world.o> and that\nF<hello> depends upon F<libworld.a>, all for similar reasons.\n\nNow it turns out that F<hello.c> also includes the interface definition\nfile, F<world.h>:\n\n\n\n  % emacs world.h\n    [EDIT]\n  % cons hello\n  gcc -c hello.c -o hello.o\n  gcc -o hello hello.o libworld.a\n\nHow does Cons know that F<hello.c> includes F<world.h>, and that F<hello.o>\nmust therefore be recompiled? For now, suffice it to say that when\nconsidering whether or not F<hello.o> is up-to-date, Cons invokes a scanner\nfor its dependency, F<hello.c>. This scanner enumerates the files included\nby F<hello.c> to come up with a list of further dependencies, beyond those\nmade explicit by the Cons script. This process is recursive: any files\nincluded by included files will also be scanned.\n\nIsn't this expensive? The answer is--it depends. If you do a full build of a\nlarge system, the scanning time is insignificant. If you do a rebuild of a\nlarge system, then Cons will spend a fair amount of time thinking about it\nbefore it decides that nothing has to be done (although not necessarily more\ntime than make!). The good news is that Cons makes it very easy to\nintelligently subset your build, when you are working on localized changes.\n\n\n=head2 Automatic global build sequencing\n\nBecause Cons does full and accurate dependency analysis, and does this\nglobally, for the entire build, Cons is able to use this information to take\nfull control of the B<sequencing> of the build. This sequencing is evident\nin the above examples, and is equivalent to what you would expect for make,\ngiven a full set of dependencies. With Cons, this extends trivially to\nlarger, multi-directory builds. As a result, all of the complexity involved\nin making sure that a build is organized correctly--including multi-pass\nhierarchical builds--is eliminated. We'll discuss this further in the next\nsections.\n\n=head1 Building large trees--still just as simple\n\n\n=head2 A hierarchy of build scripts\n\nA larger build, in Cons, is organized by creating a hierarchy of B<build\nscripts>. At the top of the tree is a script called F<Construct>. The rest\nof the scripts, by convention, are each called F<Conscript>. These scripts\nare connected together, very simply, by the C<Build>, C<Export>, and\nC<Import> commands.\n\n\n=head2 The Build command\n\nThe C<Build> command takes a list of F<Conscript> file names, and arranges\nfor them to be included in the build. For example:\n\n  Build qw(\n\tdrivers/display/Conscript\n\tdrivers/mouse/Conscript\n\tparser/Conscript\n\tutilities/Conscript\n  );\n\nThis is a simple two-level hierarchy of build scripts: all the subsidiary\nF<Conscript> files are mentioned in the top-level F<Construct> file. Notice\nthat not all directories in the tree necessarily have build scripts\nassociated with them.\n\nThis could also be written as a multi-level script. For example, the\nF<Construct> file might contain this command:\n\n  Build qw(\n\tparser/Conscript\n\tdrivers/Conscript\n\tutilities/Conscript\n  );\n\nand the F<Conscript> file in the F<drivers> directory might contain this:\n\n  Build qw(\n\tdisplay/Conscript\n\tmouse/Conscript\n  );\n\nExperience has shown that the former model is a little easier to understand,\nsince the whole construction tree is laid out in front of you, at the\ntop-level. Hybrid schemes are also possible. A separately maintained\ncomponent that needs to be incorporated into a build tree, for example,\nmight hook into the build tree in one place, but define its own construction\nhierarchy.\n\nBy default, Cons does not change its working directory to the directory\ncontaining a subsidiary F<Conscript> file it is including.  This behavior\ncan be enabled for a build by specifying, in the top-level F<Construct>\nfile:\n\n  Conscript_chdir 1;\n\nWhen enabled, Cons will change to the subsidiary F<Conscript> file's\ncontaining directory while reading in that file, and then change back\nto the top-level directory once the file has been processed.\n\nIt is expected that this behavior will become the default in some future\nversion of Cons.  To prepare for this transition, builds that expect\nCons to remain at the top of the build while it reads in a subsidiary\nF<Conscript> file should explicitly disable this feature as follows:\n\n  Conscript_chdir 0;\n\n\n=head2 Relative, top-relative, and absolute file names\n\nYou may have noticed that the file names specified to the Build command are\nrelative to the location of the script it is invoked from. This is generally\ntrue for other filename arguments to other commands, too, although we might\nas well mention here that if you begin a file name with a hash mark, ``#'',\nthen that file is interpreted relative to the top-level directory (where the\nF<Construct> file resides). And, not surprisingly, if you begin it with ``/'',\nthen it is considered to be an absolute pathname. This is true even on\nsystems which use a back slash rather than a forward slash to name absolute\npaths.\n\n(There is another file prefix, ``!'', that is interpreted specially by\nCons.  See discussion of the C<Link> command, below, for details.)\n\n\n=head2 Using modules in build scripts\n\nYou may pull modules into each F<Conscript> file using the normal Perl\nC<use> or C<require> statements:\n\n  use English;\n  require My::Module;\n\nEach C<use> or C<require> only affects the one F<Conscript> file in which\nit appears.  To use a module in multiple F<Conscript> files, you must\nput a C<use> or C<require> statement in each one that needs the module.\n\n\n=head2 Scope of variables\n\nThe top-level F<Construct> file and all F<Conscript> files begin life in\na common, separate Perl package.  B<Cons> controls the symbol table for\nthe package so that, the symbol table for each script is empty, except\nfor the F<Construct> file, which gets some of the command line arguments.\nAll of the variables that are set or used, therefore, are set by the\nscript itself--not by some external script.\n\nVariables can be explicitly B<imported> by a script from its parent\nscript. To import a variable, it must have been B<exported> by the parent\nand initialized (otherwise an error will occur).\n\n\n=head2 The Export command\n\nThe C<Export> command is used as in the following example:\n\n  $env = new cons();\n  $INCLUDE = \"#export/include\";\n  $LIB = \"#export/lib\";\n  Export qw( env INCLUDE LIB );\n  Build qw( util/Conscript );\n\nThe values of the simple variables mentioned in the C<Export> list will be\nsquirreled away by any subsequent C<Build> commands. The C<Export> command\nwill only export Perl B<scalar> variables, that is, variables whose name\nbegins with C<$>. Other variables, objects, etc. can be exported by\nreference--but all scripts will refer to the same object, and this object\nshould be considered to be read-only by the subsidiary scripts and by the\noriginal exporting script. It's acceptable, however, to assign a new value\nto the exported scalar variable--that won't change the underlying variable\nreferenced. This sequence, for example, is OK:\n\n  $env = new cons();\n  Export qw( env INCLUDE LIB );\n  Build qw( util/Conscript );\n  $env = new cons(CFLAGS => '-O');\n  Build qw( other/Conscript );\n\nIt doesn't matter whether the variable is set before or after the C<Export>\ncommand. The important thing is the value of the variable at the time the\nC<Build> command is executed. This is what gets squirreled away. Any\nsubsequent C<Export> commands, by the way, invalidate the first: you must\nmention all the variables you wish to export on each C<Export> command.\n\n\n=head2 The Import command\n\nVariables exported by the C<Export> command can be imported into subsidiary\nscripts by the C<Import> command. The subsidiary script always imports\nvariables directly from the superior script. Consider this example:\n\n  Import qw( env INCLUDE );\n\nThis is only legal if the parent script exported both C<$env> and\nC<$INCLUDE>. It also must have given each of these variables values. It is\nOK for the subsidiary script to only import a subset of the exported\nvariables (in this example, C<$LIB>, which was exported by the previous\nexample, is not imported).\n\nAll the imported variables are automatically re-exported, so the sequence:\n\n  Import qw ( env INCLUDE );\n  Build qw ( beneath-me/Conscript );\n\nwill supply both C<$env> and C<$INCLUDE> to the subsidiary file. If only\nC<$env> is to be exported, then the following will suffice:\n\n  Import qw ( env INCLUDE );\n  Export qw ( env );\n  Build qw ( beneath-me/Conscript );\n\nNeedless to say, the variables may be modified locally before invoking\nC<Build> on the subsidiary script.\n\n\n=head2 Build script evaluation order\n\nThe only constraint on the ordering of build scripts is that superior\nscripts are evaluated before their inferior scripts. The top-level\nF<Construct> file, for instance, is evaluated first, followed by any\ninferior scripts. This is all you really need to know about the evaluation\norder, since order is generally irrelevant. Consider the following C<Build>\ncommand:\n\n  Build qw(\n\tdrivers/display/Conscript\n\tdrivers/mouse/Conscript\n\tparser/Conscript\n\tutilities/Conscript\n  );\n\nWe've chosen to put the script names in alphabetical order, simply because\nthat's the most convenient for maintenance purposes. Changing the order will\nmake no difference to the build.\n\n\n=head1 A Model for sharing files\n\n\n=head2 Some simple conventions\n\nIn any complex software system, a method for sharing build products needs to\nbe established. We propose a simple set of conventions which are trivial to\nimplement with Cons, but very effective.\n\nThe basic rule is to require that all build products which need to be shared\nbetween directories are shared via an intermediate directory. We have\ntypically called this F<export>, and, in a C environment, provided\nconventional sub-directories of this directory, such as F<include>, F<lib>,\nF<bin>, etc.\n\nThese directories are defined by the top-level F<Construct> file. A simple\nF<Construct> file for a B<Hello, World!> application, organized using\nmultiple directories, might look like this:\n\n  # Construct file for Hello, World!\n\n  # Where to put all our shared products.\n  $EXPORT = '#export';\n\n  Export qw( CONS INCLUDE LIB BIN );\n\n  # Standard directories for sharing products.\n  $INCLUDE = \"$EXPORT/include\";\n  $LIB = \"$EXPORT/lib\";\n  $BIN = \"$EXPORT/bin\";\n\n  # A standard construction environment.\n  $CONS = new cons (\n\tCPPPATH => $INCLUDE,\t# Include path for C Compilations\n\tLIBPATH => $LIB,\t# Library path for linking programs\n\tLIBS => '-lworld',\t# List of standard libraries\n  );\n\n  Build qw(\n\thello/Conscript\n\tworld/Conscript\n  );\n\nThe F<world> directory's F<Conscript> file looks like this:\n\n  # Conscript file for directory world\n  Import qw( CONS INCLUDE LIB );\n\n  # Install the products of this directory\n  Install $CONS $LIB, 'libworld.a';\n  Install $CONS $INCLUDE, 'world.h';\n\n  # Internal products\n  Library $CONS 'libworld.a', 'world.c';\n\nand the F<hello> directory's F<Conscript> file looks like this:\n\n  # Conscript file for directory hello\n  Import qw( CONS BIN );\n\n  # Exported products\n  Install $CONS $BIN, 'hello';\n\n  # Internal products\n  Program $CONS 'hello', 'hello.c';\n\nTo construct a B<Hello, World!> program with this directory structure, go to\nthe top-level directory, and invoke C<cons> with the appropriate\narguments. In the following example, we tell Cons to build the directory\nF<export>. To build a directory, Cons recursively builds all known products\nwithin that directory (only if they need rebuilding, of course). If any of\nthose products depend upon other products in other directories, then those\nwill be built, too.\n\n  % cons export\n  Install world/world.h as export/include/world.h\n  cc -Iexport/include -c hello/hello.c -o hello/hello.o\n  cc -Iexport/include -c world/world.c -o world/world.o\n  ar r world/libworld.a world/world.o\n  ar: creating world/libworld.a\n  ranlib world/libworld.a\n  Install world/libworld.a as export/lib/libworld.a\n  cc -o hello/hello hello/hello.o -Lexport/lib -lworld\n  Install hello/hello as export/bin/hello\n\n\n=head2 Clean, understandable, location-independent scripts\n\nYou'll note that the two F<Conscript> files are very clean and\nto-the-point. They simply specify products of the directory and how to build\nthose products. The build instructions are minimal: they specify which\nconstruction environment to use, the name of the product, and the name of\nthe inputs. Note also that the scripts are location-independent: if you wish\nto reorganize your source tree, you are free to do so: you only have to\nchange the F<Construct> file (in this example), to specify the new locations\nof the F<Conscript> files. The use of an export tree makes this goal easy.\n\nNote, too, how Cons takes care of little details for you. All the F<export>\ndirectories, for example, were made automatically. And the installed files\nwere really hard-linked into the respective export directories, to save\nspace and time. This attention to detail saves considerable work, and makes\nit even easier to produce simple, maintainable scripts.\n\n\n=head1 Separating source and build trees\n\nIt's often desirable to keep any derived files from the build completely\nseparate from the source files. This makes it much easier to keep track of\njust what is a source file, and also makes it simpler to handle B<variant>\nbuilds, especially if you want the variant builds to co-exist.\n\n\n=head2 Separating build and source directories using the Link command\n\nCons provides a simple mechanism that handles all of these requirements. The\nC<Link> command is invoked as in this example:\n\n  Link 'build' => 'src';\n\nThe specified directories are ``linked'' to the specified source\ndirectory. Let's suppose that you setup a source directory, F<src>, with the\nsub-directories F<world> and F<hello> below it, as in the previous\nexample. You could then substitute for the original build lines the\nfollowing:\n\n  Build qw(\n\tbuild/world/Conscript\n\tbuild/hello/Conscript\n  );\n\nNotice that you treat the F<Conscript> file as if it existed in the build\ndirectory. Now if you type the same command as before, you will get the\nfollowing results:\n\n  % cons export\n  Install build/world/world.h as export/include/world.h\n  cc -Iexport/include -c build/hello/hello.c -o build/hello/hello.o\n  cc -Iexport/include -c build/world/world.c -o build/world/world.o\n  ar r build/world/libworld.a build/world/world.o\n  ar: creating build/world/libworld.a\n  ranlib build/world/libworld.a\n  Install build/world/libworld.a as export/lib/libworld.a\n  cc -o build/hello/hello build/hello/hello.o -Lexport/lib -lworld\n  Install build/hello/hello as export/bin/hello\n\nAgain, Cons has taken care of the details for you. In particular, you will\nnotice that all the builds are done using source files and object files from\nthe build directory. For example, F<build/world/world.o> is compiled from\nF<build/world/world.c>, and F<export/include/world.h> is installed from\nF<build/world/world.h>. This is accomplished on most systems by the simple\nexpedient of ``hard'' linking the required files from each source directory\ninto the appropriate build directory.\n\nThe links are maintained correctly by Cons, no matter what you do to the\nsource directory. If you modify a source file, your editor may do this ``in\nplace'' or it may rename it first and create a new file. In the latter case,\nany hard link will be lost. Cons will detect this condition the next time\nthe source file is needed, and will relink it appropriately.\n\nYou'll also notice, by the way, that B<no> changes were required to the\nunderlying F<Conscript> files. And we can go further, as we shall see in the\nnext section.\n\n=head2 Explicit references to the source directory\n\nWhen using the C<Link> command on some operating systems or with some\ntool chains, it's sometimes useful to have a command actually use\nthe path name to the source directory, not the build directory.  For\nexample, on systems that must copy, not \"hard link,\" the F<src/> and\nF<build/> copies of C<Linked> files, using the F<src/> path of a file\nname might make an editor aware that a syntax error must be fixed in the\nsource directory, not the build directory.\n\nYou can tell Cons that you want to use the \"source path\" for a file by\npreceding the file name with a ``!'' (exclamation point).  For example,\nif we add a ``!'' to the beginning of a source file:\n\n  Program $env \"foo\", \"!foo.c\";\t# Notice initial ! on foo.c\n\nCons will compile the target as follows:\n\n  cc -c src/foo.c -o build/foo.o\n  cc -o build/foo build/foo.o\n\nNotice that Cons has compiled the program from the the F<src/foo.c>\nsource file.  Without the initial ``!'', Cons would have compiled the\nprogram using the F<build/foo.c> path name.\n\n\n\n=head1 Variant builds\n\n\n=head2 Hello, World! for baNaNa and peAcH OS's\n\nVariant builds require just another simple extension. Let's take as an\nexample a requirement to allow builds for both the baNaNa and peAcH\noperating systems. In this case, we are using a distributed file system,\nsuch as NFS to access the particular system, and only one or the other of\nthe systems has to be compiled for any given invocation of C<cons>. Here's\none way we could set up the F<Construct> file for our B<Hello, World!>\napplication:\n\n  # Construct file for Hello, World!\n\n  die qq(OS must be specified) unless $OS = $ARG{OS};\n  die qq(OS must be \"peach\" or \"banana\")\n\tif $OS ne \"peach\" && $OS ne \"banana\";\n\n  # Where to put all our shared products.\n  $EXPORT = \"#export/$OS\";\n\n  Export qw( CONS INCLUDE LIB BIN );\n\n  # Standard directories for sharing products.\n  $INCLUDE = \"$EXPORT/include\";\n  $LIB = \"$EXPORT/lib\";\n  $BIN = \"$EXPORT/bin\";\n\n  # A standard construction environment.\n  $CONS = new cons (\n\tCPPPATH => $INCLUDE,\t# Include path for C Compilations\n\tLIBPATH => $LIB,\t# Library path for linking programs\n\tLIBS => '-lworld',\t# List of standard libraries\n  );\n\n  # $BUILD is where we will derive everything.\n  $BUILD = \"#build/$OS\";\n\n  # Tell cons where the source files for $BUILD are.\n  Link $BUILD => 'src';\n\n  Build (\n\t\"$BUILD/hello/Conscript\",\n\t\"$BUILD/world/Conscript\",\n  );\n\nNow if we login to a peAcH system, we can build our B<Hello, World!>\napplication for that platform:\n\n  % cons export OS=peach\n  Install build/peach/world/world.h as export/peach/include/world.h\n  cc -Iexport/peach/include -c build/peach/hello/hello.c -o build/peach/hello/hello.o\n  cc -Iexport/peach/include -c build/peach/world/world.c -o build/peach/world/world.o\n  ar r build/peach/world/libworld.a build/peach/world/world.o\n  ar: creating build/peach/world/libworld.a\n  ranlib build/peach/world/libworld.a\n  Install build/peach/world/libworld.a as export/peach/lib/libworld.a\n  cc -o build/peach/hello/hello build/peach/hello/hello.o -Lexport/peach/lib -lworld\n  Install build/peach/hello/hello as export/peach/bin/hello\n\n\n=head2 Variations on a theme\n\nOther variations of this model are possible. For example, you might decide\nthat you want to separate out your include files into platform dependent and\nplatform independent files. In this case, you'd have to define an\nalternative to C<$INCLUDE> for platform-dependent files. Most F<Conscript>\nfiles, generating purely platform-independent include files, would not have\nto change.\n\nYou might also want to be able to compile your whole system with debugging\nor profiling, for example, enabled. You could do this with appropriate\ncommand line options, such as C<DEBUG=on>. This would then be translated\ninto the appropriate platform-specific requirements to enable debugging\n(this might include turning off optimization, for example). You could\noptionally vary the name space for these different types of systems, but, as\nwe'll see in the next section, it's not B<essential> to do this, since Cons\nis pretty smart about rebuilding things when you change options.\n\n\n=head1 Signatures\n\nCons uses file B<signatures> to decide if a derived file is out-of-date\nand needs rebuilding.  In essence, if the contents of a file change,\nor the manner in which the file is built changes, the file's signature\nchanges as well.  This allows Cons to decide with certainty when a file\nneeds rebuilding, because Cons can detect, quickly and reliably, whether\nany of its dependency files have been changed.\n\n\n=head2 MD5 content and build signatures\n\nCons uses the B<MD5> (B<Message Digest 5>) algorithm to compute file\nsignatures.  The MD5 algorithm computes a strong cryptographic checksum\nfor any given input string.  Cons can, based on configuration, use two\ndifferent MD5 signatures for a given file:\n\nThe B<content signature> of a file is an MD5 checksum of the file's\ncontents.  Consequently, when the contents of a file change, its content\nsignature changes as well.\n\nThe B<build signature> of a file is a combined MD5 checksum of:\n\n=over 4\n\nthe signatures of all the input files used to build the file\n\nthe signatures of all dependency files discovered by source scanners\n(for example, C<.h> files)\n\nthe signatures of all dependency files specified explicitly via the\nC<Depends> method)\n\nthe command-line string used to build the file\n\n=back\n\nThe build signature is, in effect, a digest of all the dependency\ninformation for the specified file.  Consequently, a file's build\nsignature changes whenever any part of its dependency information\nchanges: a new file is added, the contents of a file on which it depends\nchange, there's a change to the command line used to build the file (or\nany of its dependency files), etc.\n\nFor example, in the previous section, the build signature of the\nF<world.o> file will include:\n\n=over 4\n\nthe signature of the F<world.c> file\n\nthe signatures of any header files that Cons detects are included,\ndirectly or indirectly, by F<world.c>\n\nthe text of the actual command line was used to generate F<world.o>\n\n=back\n\nSimilarly, the build signature of the F<libworld.a> file will include\nall the signatures of its constituents (and hence, transitively, the\nsignatures of B<their> constituents), as well as the command line that\ncreated the file.\n\nNote that there is no need for a derived file to depend upon any\nparticular F<Construct> or F<Conscript> file.  If changes to these files\naffect a file, then this will be automatically reflected in its build\nsignature, since relevant parts of the command line are included in the\nsignature. Unrelated F<Construct> or F<Conscript> changes will have no\neffect.\n\n\n=head2 Storing signatures in .consign files\n\nBefore Cons exits, it stores the calculated signatures for all of the\nfiles it built or examined in F<.consign> files, one per directory.\nCons uses this stored information on later invocations to decide if\nderived files need to be rebuilt.\n\nAfter the previous example was compiled, the F<.consign> file in the\nF<build/peach/world> directory looked like this:\n\n  world.h:985533370 - d181712f2fdc07c1f05d97b16bfad904\n  world.o:985533372 2a0f71e0766927c0532977b0d2158981\n  world.c:985533370 - c712f77189307907f4189b5a7ab62ff3\n  libworld.a:985533374 69e568fc5241d7d25be86d581e1fb6aa\n\nAfter the file name and colon, the first number is a timestamp of the\nfile's modification time (on UNIX systems, this is typically the number\nof seconds since January 1st, 1970).  The second value is the build\nsignature of the file (or ``-'' in the case of files with no build\nsignature--that is, source files).  The third value, if any, is the\ncontent signature of the file.\n\n\n=head2 Using build signatures to decide when to rebuild files\n\nWhen Cons is deciding whether to build or rebuild a derived file, it\nfirst computes the file's current build signature.  If the file doesn't\nexist, it must obviously be built.\n\nIf, however, the file already exists, Cons next compares the\nmodification timestamp of the file against the timestamp value in\nthe F<.consign> file.  If the timestamps match, Cons compares the\nnewly-computed build signature against the build signature in the\nF<.consign> file.  If the timestamps do not match or the build\nsignatures do not match, the derived file is rebuilt.\n\nAfter the file is built or rebuilt, Cons arranges to store the\nnewly-computed build signature in the F<.consign> file when it exits.\n\n\n=head2 Signature example\n\nThe use of these signatures is an extremely simple, efficient, and\neffective method of improving--dramatically--the reproducibility of a\nsystem.\n\nWe'll demonstrate this with a simple example:\n\n  # Simple \"Hello, World!\" Construct file\n  $CFLAGS = '-g' if $ARG{DEBUG} eq 'on';\n  $CONS = new cons(CFLAGS => $CFLAGS);\n  Program $CONS 'hello', 'hello.c';\n\nNotice how Cons recompiles at the appropriate times:\n\n  % cons hello\n  cc -c hello.c -o hello.o\n  cc -o hello hello.o\n  % cons hello\n  cons: \"hello\" is up-to-date.\n  % cons DEBUG=on hello\n  cc -g -c hello.c -o hello.o\n  cc -o hello hello.o\n  % cons DEBUG=on hello\n  cons: \"hello\" is up-to-date.\n  % cons hello\n  cc -c hello.c -o hello.o\n  cc -o hello hello.o\n\n\n=head2 Source-file signature configuration\n\nCons provides a C<SourceSignature> method that allows you to configure\nhow the signature should be calculated for any source file when its\nsignature is being used to decide if a dependent file is up-to-date.\nThe arguments to the C<SourceSignature> method consist of one or more\npairs of strings:\n\n  SourceSignature 'auto/*.c' => 'content',\n\t\t  '*' => 'stored-content';\n\nThe first string in each pair is a pattern to match against derived file\npath names. The pattern is a file-globbing pattern, not a Perl regular\nexpression; the pattern <*.l> will match all Lex source files.  The C<*>\nwildcard will match across directory separators; the pattern C<foo/*.c>\nwould match all C source files in any subdirectory underneath the C<foo>\nsubdirectory.\n\nThe second string in each pair contains one of the following keywords to\nspecify how signatures should be calculated for source files that match\nthe pattern.  The available keywords are:\n\n=over 4\n\n=item content\n\nUse the content signature of the source file when calculating signatures\nof files that depend on it.  This guarantees correct calculation of the\nfile's signature for all builds, by telling Cons to read the contents of\na source file to calculate its content signature each time it is run.\n\n=item stored-content\n\nUse the source file's content signature as stored in the F<.consign>\nfile, provided the file's timestamp matches the cached timestamp value\nin the F<.consign> file.  This optimizes performance, with the slight\nrisk of an incorrect build if a source file's contents have been changed\nso quickly after its previous update that the timestamp still matches\nthe stored timestamp in the F<.consign> file even though the contents\nhave changed.\n\n=back\n\nThe Cons default behavior of always calculating a source file's\nsignature from the file's contents is equivalent to specifying:\n\n  SourceSignature '*' => 'content';\n\nThe C<*> will match all source files.  The C<content> keyword\nspecifies that Cons will read the contents of a source file to calculate\nits signature each time it is run.\n\nA useful global performance optimization is:\n\n  SourceSignature '*' => 'stored-content';\n\nThis specifies that Cons will use pre-computed content signatures\nfrom F<.consign> files, when available, rather than re-calculating a\nsignature from the the source file's contents each time Cons is run.  In\npractice, this is safe for most build situations, and only a problem\nwhen source files are changed automatically (by scripts, for example).\nThe Cons default, however, errs on the side of guaranteeing a correct\nbuild in all situations.\n\nCons tries to match source file path names against the patterns in the\norder they are specified in the C<SourceSignature> arguments:\n\n  SourceSignature '/usr/repository/objects/*' => 'stored-content',\n\t\t  '/usr/repository/*' => 'content',\n\t\t  '*.y' => 'content',\n\t\t  '*' => 'stored-content';\n\nIn this example, all source files under the F</usr/repository/objects>\ndirectory will use F<.consign> file content signatures, source files\nanywhere else underneath F</usr/repository> will not use F<.consign>\nsignature values, all Yacc source files (C<*.y>) anywhere else will not\nuse F<.consign> signature values, and any other source file will use\nF<.consign> signature values.\n\n\n=head2 Derived-file signature configuration\n\nCons provides a C<SIGNATURE> construction variable that allows you to\nconfigure how signatures are calculated for any derived file when its\nsignature is being used to decide if a dependent file is up-to-date.\nThe value of the C<SIGNATURE> construction variable is a Perl array\nreference that holds one or more pairs of strings, like the arguments to\nthe C<SourceSignature> method.\n\nThe first string in each pair is a pattern to match against derived file\npath names. The pattern is a file-globbing pattern, not a Perl regular\nexpression; the pattern `*.obj' will match all (Win32) object files.\nThe C<*> wildcard will match across directory separators; the pattern\n`foo/*.a' would match all (UNIX) library archives in any subdirectory\nunderneath the foo subdirectory.\n\nThe second string in each pair contains one of the following keywords\nto specify how signatures should be calculated for derived files that\nmatch the pattern.  The available keywords are the same as for the\nC<SourceSignature> method, with an additional keyword:\n\n=over 4\n\n=item build\n\nUse the build signature of the derived file when calculating signatures\nof files that depend on it.  This guarantees correct builds by forcing\nCons to rebuild any and all files that depend on the derived file.\n\n=item content\n\nUse the content signature of the derived file when calculating signatures\nof files that depend on it.  This guarantees correct calculation of the\nfile's signature for all builds, by telling Cons to read the contents of\na derived file to calculate its content signature each time it is run.\n\n=item stored-content\n\nUse the derived file's content signature as stored in the F<.consign>\nfile, provided the file's timestamp matches the cached timestamp value\nin the F<.consign> file.  This optimizes performance, with the slight\nrisk of an incorrect build if a derived file's contents have been\nchanged so quickly after a Cons build that the file's timestamp still\nmatches the stored timestamp in the F<.consign> file.\n\n=back\n\nThe Cons default behavior (as previously described) for using\nderived-file signatures is equivalent to:\n\n  $env = new cons(SIGNATURE => ['*' => 'build']);\n\nThe C<*> will match all derived files.  The C<build> keyword specifies\nthat all derived files' build signatures will be used when calculating\nwhether a dependent file is up-to-date.\n\nA useful alternative default C<SIGNATURE> configuration for many sites:\n\n  $env = new cons(SIGNATURE => ['*' => 'content']);\n\nIn this configuration, derived files have their signatures calculated\nfrom the file contents.  This adds slightly to Cons' workload, but has\nthe useful effect of \"stopping\" further rebuilds if a derived file is\nrebuilt to exactly the same file contents as before, which usually\noutweighs the additional computation Cons must perform.\n\nFor example, changing a comment in a C file and recompiling should\ngenerate the exact same object file (assuming the compiler doesn't\ninsert a timestamp in the object file's header).  In that case,\nspecifying C<content> or C<stored-content> for the signature calculation\nwill cause Cons to recognize that the object file did not actually\nchange as a result of being rebuilt, and libraries or programs that\ninclude the object file will not be rebuilt.  When C<build> is\nspecified, however, Cons will only \"know\" that the object file was\nrebuilt, and proceed to rebuild any additional files that include the\nobject file.\n\nNote that Cons tries to match derived file path names against the\npatterns in the order they are specified in the C<SIGNATURE> array\nreference:\n\n  $env = new cons(SIGNATURE => ['foo/*.o' => 'build',\n\t\t\t\t'*.o' => 'content',\n\t\t\t\t'*.a' => 'stored-content',\n\t\t\t\t'*' => 'content']);\n\nIn this example, all object files underneath the F<foo> subdirectory\nwill use build signatures, all other object files (including object\nfiles underneath other subdirectories!) will use F<.consign> file\ncontent signatures, libraries will use F<.consign> file build\nsignatures, and all other derived files will use content signatures.\n\n\n=head2 Debugging signature calculation\n\nCons provides a C<-S> option that can be used to specify what internal\nPerl package Cons should use to calculate signatures.  The default Cons\nbehavior is equivalent to specifying C<-S md5> on the command line.\n\nThe only other package (currently) available is an C<md5::debug>\npackage that prints out detailed information about the MD5 signature\ncalculations performed by Cons:\n\n  % cons -S md5::debug hello\n  sig::md5::srcsig(hello.c)\n          => |52d891204c62fe93ecb95281e1571938|\n  sig::md5::collect(52d891204c62fe93ecb95281e1571938)\n          => |fb0660af4002c40461a2f01fbb5ffd03|\n  sig::md5::collect(52d891204c62fe93ecb95281e1571938,\n                    fb0660af4002c40461a2f01fbb5ffd03,\n                    cc   -c %< -o %>)\n          => |f7128da6c3fe3c377dc22ade70647b39|\n  sig::md5::current(||\n                 eq |f7128da6c3fe3c377dc22ade70647b39|)\n  cc -c hello.c -o hello.o\n  sig::md5::collect()\n          => |d41d8cd98f00b204e9800998ecf8427e|\n  sig::md5::collect(f7128da6c3fe3c377dc22ade70647b39,\n                    d41d8cd98f00b204e9800998ecf8427e,\n                    cc  -o %> %<  )\n          => |a0bdce7fd09e0350e7efbbdb043a00b0|\n  sig::md5::current(||\n                 eq |a0bdce7fd09e0350e7efbbdb043a00b0|)\n  cc -o hello, hello.o\n\n\n=head1 Code Repositories\n\nMany software development organizations will have one or more central\nrepository directory trees containing the current source code for one or\nmore projects, as well as the derived object files, libraries, and\nexecutables.  In order to reduce unnecessary recompilation, it is useful to\nuse files from the repository to build development software--assuming, of\ncourse, that no newer dependency file exists in the local build tree.\n\n\n=head2 Repository\n\nCons provides a mechanism to specify a list of code repositories that will\nbe searched, in-order, for source files and derived files not found in the\nlocal build directory tree.\n\nThe following lines in a F<Construct> file will instruct Cons to look first\nunder the F</usr/experiment/repository> directory and then under the\nF</usr/product/repository> directory:\n\n  Repository qw (\n\t/usr/experiment/repository\n\t/usr/product/repository\n  );\n\nThe repository directories specified may contain source files, derived files\n(objects, libraries and executables), or both.  If there is no local file\n(source or derived) under the directory in which Cons is executed, then the\nfirst copy of a same-named file found under a repository directory will be\nused to build any local derived files.\n\nCons maintains one global list of repositories directories.  Cons will\neliminate the current directory, and any non-existent directories, from the\nlist.\n\n\n=head2 Finding the Construct file in a Repository\n\nCons will also search for F<Construct> and F<Conscript> files in the\nrepository tree or trees.  This leads to a chicken-and-egg situation,\nthough: how do you look in a repository tree for a F<Construct> file if the\nF<Construct> file tells you where the repository is?  To get around this,\nrepositories may be specified via C<-R> options on the command line:\n\n  % cons -R /usr/experiment/repository -R /usr/product/repository .\n\nAny repository directories specified in the F<Construct> or F<Conscript>\nfiles will be appended to the repository directories specified by\ncommand-line C<-R> options.\n\n=head2 Repository source files\n\nIf the source code (include the F<Conscript> file) for the library version\nof the I<Hello, World!> C application is in a repository (with no derived\nfiles), Cons will use the repository source files to create the local object\nfiles and executable file:\n\n  % cons -R /usr/src_only/repository hello\n  gcc -c /usr/src_only/repository/hello.c -o hello.o\n  gcc -c /usr/src_only/repository/world.c -o world.o\n  ar r libworld.a world.o\n  ar: creating libworld.a\n  ranlib libworld.a\n  gcc -o hello hello.o libworld.a\n\nCreating a local source file will cause Cons to rebuild the appropriate\nderived file or files:\n\n  % pico world.c\n    [EDIT]\n  % cons -R /usr/src_only/repository hello\n  gcc -c world.c -o world.o\n  ar r libworld.a world.o\n  ar: creating libworld.a\n  ranlib libworld.a\n  gcc -o hello hello.o libworld.a\n\nAnd removing the local source file will cause Cons to revert back to\nbuilding the derived files from the repository source:\n\n  % rm world.c\n  % cons -R /usr/src_only/repository hello\n  gcc -c /usr/src_only/repository/world.c -o world.o\n  ar r libworld.a world.o\n  ar: creating libworld.a\n  ranlib libworld.a\n  gcc -o hello hello.o libworld.a\n\n\n=head2 Repository derived files\n\nIf a repository tree contains derived files (usually object files,\nlibraries, or executables), Cons will perform its normal signature\ncalculation to decide whether the repository file is up-to-date or a derived\nfile must be built locally.  This means that, in order to ensure correct\nsignature calculation, a repository tree must also contain the F<.consign>\nfiles that were created by Cons when generating the derived files.\n\nThis would usually be accomplished by building the software in the\nrepository (or, alternatively, in a build directory, and then copying the\nresult to the repository):\n\n  % cd /usr/all/repository\n  % cons hello\n  gcc -c hello.c -o hello.o\n  gcc -c world.c -o world.o\n  ar r libworld.a world.o\n  ar: creating libworld.a\n  ranlib libworld.a\n  gcc -o hello hello.o libworld.a\n\n(This is safe even if the F<Construct> file lists the F</usr/all/repository>\ndirectory in a C<Repository> command because Cons will remove the current\ndirectory from the repository list.)\n\nNow if we want to build a copy of the application with our own F<hello.c>\nfile, we only need to create the one necessary source file, and use the\nC<-R> option to have Cons use other files from the repository:\n\n  % mkdir $HOME/build1\n  % cd $HOME/build1\n  % ed hello.c\n    [EDIT]\n  % cons -R /usr/all/repository hello\n  gcc -c hello.c -o hello.o\n  gcc -o hello hello.o /usr/all/repository/libworld.a\n\nNotice that Cons has not bothered to recreate a local F<libworld.a> library\n(or recompile the F<world.o> module), but instead uses the already-compiled\nversion from the repository.\n\nBecause the MD5 signatures that Cons puts in the F<.consign> file contain\ntimestamps for the derived files, the signature timestamps must match the\nfile timestamps for a signature to be considered valid.\n\nSome software systems may alter the timestamps on repository files (by\ncopying them, e.g.), in which case Cons will, by default, assume the\nrepository signatures are invalid and rebuild files unnecessarily.  This\nbehavior may be altered by specifying:\n\n  Repository_Sig_Times_OK 0;\n\nThis tells Cons to ignore timestamps when deciding whether a signature is\nvalid.  (Note that avoiding this sanity check means there must be proper\ncontrol over the repository tree to ensure that the derived files cannot be\nmodified without updating the F<.consign> signature.)\n\n\n=head2 Local copies of files\n\nIf the repository tree contains the complete results of a build, and we try\nto build from the repository without any files in our local tree, something\nmoderately surprising happens:\n\n  % mkdir $HOME/build2\n  % cd $HOME/build2\n  % cons -R /usr/all/repository hello\n  cons: \"hello\" is up-to-date.\n\nWhy does Cons say that the F<hello> program is up-to-date when there is no\nF<hello> program in the local build directory?  Because the repository (not\nthe local directory) contains the up-to-date F<hello> program, and Cons\ncorrectly determines that nothing needs to be done to rebuild this\nup-to-date copy of the file.\n\nThere are, however, many times in which it is appropriate to ensure that a\nlocal copy of a file always exists.  A packaging or testing script, for\nexample, may assume that certain generated files exist locally.  Instead of\nmaking these subsidiary scripts aware of the repository directory, the\nC<Local> command may be added to a F<Construct> or F<Conscript> file to\nspecify that a certain file or files must appear in the local build\ndirectory:\n\n  Local qw(\n\thello\n  );\n\nThen, if we re-run the same command, Cons will make a local copy of the\nprogram from the repository copy (telling you that it is doing so):\n\n  % cons -R /usr/all/repository hello\n  Local copy of hello from /usr/all/repository/hello\n  cons: \"hello\" is up-to-date.\n\nNotice that, because the act of making the local copy is not considered a\n\"build\" of the F<hello> file, Cons still reports that it is up-to-date.\n\nCreating local copies is most useful for files that are being installed into\nan intermediate directory (for sharing with other directories) via the\nC<Install> command.  Accompanying the C<Install> command for a file with a\ncompanion C<Local> command is so common that Cons provides a\nC<Install_Local> command as a convenient way to do both:\n\n  Install_Local $env, '#export', 'hello';\n\nis exactly equivalent to:\n\n  Install $env '#export', 'hello';\n  Local '#export/hello';\n\nBoth the C<Local> and C<Install_Local> commands update the local F<.consign>\nfile with the appropriate file signatures, so that future builds are\nperformed correctly.\n\n\n=head2 Repository dependency analysis\n\nDue to its built-in scanning, Cons will search the specified repository\ntrees for included F<.h> files.  Unless the compiler also knows about the\nrepository trees, though, it will be unable to find F<.h> files that only\nexist in a repository.  If, for example, the F<hello.c> file includes the\nF<hello.h> file in its current directory:\n\n  % cons -R /usr/all/repository hello\n  gcc -c /usr/all/repository/hello.c -o hello.o\n  /usr/all/repository/hello.c:1: hello.h: No such file or directory\n\nSolving this problem forces some requirements onto the way construction\nenvironments are defined and onto the way the C C<#include> preprocessor\ndirective is used to include files.\n\nIn order to inform the compiler about the repository trees, Cons will add\nappropriate C<-I> flags to the compilation commands.  This means that the\nC<CPPPATH> variable in the construction environment must explicitly specify\nall subdirectories which are to be searched for included files, including the\ncurrent directory.  Consequently, we can fix the above example by changing\nthe environment creation in the F<Construct> file as follows:\n\n  $env = new cons(\n\tCC\t=> 'gcc',\n\tCPPPATH\t=> '.',\n\tLIBS\t=> 'libworld.a',\n  );\n\nDue to the definition of the C<CPPPATH> variable, this yields, when we\nre-execute the command:\n\n  % cons -R /usr/all/repository hello\n  gcc -c -I. -I/usr/all/repository /usr/all/repository/hello.c -o hello.o\n  gcc -o hello hello.o /usr/all/repository/libworld.a\n\nThe order of the C<-I> flags replicates, for the C preprocessor, the same\nrepository-directory search path that Cons uses for its own dependency\nanalysis.  If there are multiple repositories and multiple C<CPPPATH>\ndirectories, Cons will append the repository directories to the beginning of\neach C<CPPPATH> directory, rapidly multiplying the number of C<-I> flags.\nAs an extreme example, a F<Construct> file containing:\n\n  Repository qw(\n\t/u1\n\t/u2\n  );\n\n  $env = new cons(\n\tCPPPATH\t=> 'a:b:c',\n  );\n\nWould yield a compilation command of:\n\n  cc -Ia -I/u1/a -I/u2/a -Ib -I/u1/b -I/u2/b -Ic -I/u1/c -I/u2/c -c hello.c -o hello.o\n\nIn order to shorten the command lines as much as possible, Cons will\nremove C<-I> flags for any directories, locally or in the repositories,\nwhich do not actually exist.  (Note that the C<-I> flags are not included\nin the MD5 signature calculation for the target file, so the target will\nnot be recompiled if the compilation command changes due to a directory\ncoming into existence.)\n\nBecause Cons relies on the compiler's C<-I> flags to communicate the\norder in which repository directories must be searched, Cons' handling\nof repository directories is fundamentally incompatible with using\ndouble-quotes on the C<#include> directives in any C source code that\nyou plan to modify:\n\n  #include \"file.h\"\t/* DON'T USE DOUBLE-QUOTES LIKE THIS */\n\nThis is because most C preprocessors, when faced with such a directive, will\nalways first search the directory containing the source file.  This\nundermines the elaborate C<-I> options that Cons constructs to make the\npreprocessor conform to its preferred search path.\n\nConsequently, when using repository trees in Cons, B<always> use\nangle-brackets for included files in any C source (.c or .h) files that\nyou plan to modify locally:\n\n  #include <file.h>\t/* USE ANGLE-BRACKETS INSTEAD */\n\nCode that will not change can still safely use double quotes on #include\nlines.\n\n\n=head2 Repository_List\n\nCons provides a C<Repository_List> command to return a list of all\nrepository directories in their current search order.  This can be used for\ndebugging, or to do more complex Perl stuff:\n\n  @list = Repository_List;\n  print join(' ', @list), \"\\n\";\n\n\n=head2 Repository interaction with other Cons features\n\nCons' handling of repository trees interacts correctly with other Cons\nfeatures--which is to say, it generally does what you would expect.\n\nMost notably, repository trees interact correctly, and rather powerfully,\nwith the 'Link' command.  A repository tree may contain one or more\nsubdirectories for version builds established via C<Link> to a source\nsubdirectory.  Cons will search for derived files in the appropriate build\nsubdirectories under the repository tree.\n\n\n=head1 Default targets\n\nUntil now, we've demonstrated invoking Cons with an explicit target\nto build:\n\n  % cons hello\n\nNormally, Cons does not build anything unless a target is specified,\nbut specifying '.' (the current directory) will build everything:\n\n  % cons\t\t# does not build anything\n\n  % cons .\t\t# builds everything under the top-level directory\n\nAdding the C<Default> method to any F<Construct> or F<Conscript> file will add\nthe specified targets to a list of default targets.  Cons will build\nthese defaults if there are no targets specified on the command line.\nSo adding the following line to the top-level F<Construct> file will mimic\nMake's typical behavior of building everything by default:\n\n  Default '.';\n\nThe following would add the F<hello> and F<goodbye> commands (in the\nsame directory as the F<Construct> or F<Conscript> file) to the default list:\n\n  Default qw(\n\thello\n\tgoodbye\n  );\n\nThe C<Default> method may be used more than once to add targets to the\ndefault list.\n\n=head1 Selective builds\n\nCons provides two methods for reducing the size of given build. The first is\nby specifying targets on the command line, and the second is a method for\npruning the build tree. We'll consider target specification first.\n\n\n=head2 Selective targeting\n\nLike make, Cons allows the specification of ``targets'' on the command\nline. Cons targets may be either files or directories. When a directory is\nspecified, this is simply a short-hand notation for every derivable\nproduct--that Cons knows about--in the specified directory and below. For\nexample:\n\n  % cons build/hello/hello.o\n\nmeans build F<hello.o> and everything that F<hello.o> might need. This is\nfrom a previous version of the B<Hello, World!> program in which F<hello.o>\ndepended upon F<export/include/world.h>. If that file is not up-to-date\n(because someone modified F<src/world/world.h)>, then it will be rebuilt,\neven though it is in a directory remote from F<build/hello>.\n\nIn this example:\n\n  % cons build\n\nEverything in the F<build> directory is built, if necessary. Again, this may\ncause more files to be built. In particular, both F<export/include/world.h>\nand F<export/lib/libworld.a> are required by the F<build/hello> directory,\nand so they will be built if they are out-of-date.\n\nIf we do, instead:\n\n  % cons export\n\nthen only the files that should be installed in the export directory will be\nrebuilt, if necessary, and then installed there. Note that C<cons build>\nmight build files that C<cons export> doesn't build, and vice-versa.\n\n\n=head2 No ``special'' targets\n\nWith Cons, make-style ``special'' targets are not required. The simplest\nanalog with Cons is to use special F<export> directories, instead. Let's\nsuppose, for example, that you have a whole series of unit tests that are\nassociated with your code. The tests live in the source directory near the\ncode. Normally, however, you don't want to build these tests. One solution\nis to provide all the build instructions for creating the tests, and then to\ninstall the tests into a separate part of the tree. If we install the tests\nin a top-level directory called F<tests>, then:\n\n  % cons tests\n\nwill build all the tests.\n\n  % cons export\n\nwill build the production version of the system (but not the tests), and:\n\n  % cons build\n\nshould probably be avoided (since it will compile tests unnecessarily).\n\nIf you want to build just a single test, then you could explicitly name the\ntest (in either the F<tests> directory or the F<build> directory). You could\nalso aggregate the tests into a convenient hierarchy within the tests\ndirectory. This hierarchy need not necessarily match the source hierarchy,\nin much the same manner that the include hierarchy probably doesn't match\nthe source hierarchy (the include hierarchy is unlikely to be more than two\nlevels deep, for C programs).\n\nIf you want to build absolutely everything in the tree (subject to whatever\noptions you select), you can use:\n\n  % cons .\n\nThis is not particularly efficient, since it will redundantly walk all the\ntrees, including the source tree. The source tree, of course, may have\nbuildable objects in it--nothing stops you from doing this, even if you\nnormally build in a separate build tree.\n\n\n=head1 Build Pruning\n\nIn conjunction with target selection, B<build pruning> can be used to reduce\nthe scope of the build. In the previous peAcH and baNaNa example, we have\nalready seen how script-driven build pruning can be used to make only half\nof the potential build available for any given invocation of C<cons>. Cons\nalso provides, as a convenience, a command line convention that allows you\nto specify which F<Conscript> files actually get ``built''--that is,\nincorporated into the build tree. For example:\n\n  % cons build +world\n\nThe C<+> argument introduces a Perl regular expression. This must, of\ncourse, be quoted at the shell level if there are any shell meta-characters\nwithin the expression. The expression is matched against each F<Conscript>\nfile which has been mentioned in a C<Build> statement, and only those\nscripts with matching names are actually incorporated into the build\ntree. Multiple such arguments are allowed, in which case a match against any\nof them is sufficient to cause a script to be included.\n\nIn the example, above, the F<hello> program will not be built, since Cons\nwill have no knowledge of the script F<hello/Conscript>. The F<libworld.a>\narchive will be built, however, if need be.\n\nThere are a couple of uses for build pruning via the command line. Perhaps\nthe most useful is the ability to make local changes, and then, with\nsufficient knowledge of the consequences of those changes, restrict the size\nof the build tree in order to speed up the rebuild time. A second use for\nbuild pruning is to actively prevent the recompilation of certain files that\nyou know will recompile due to, for example, a modified header file. You may\nknow that either the changes to the header file are immaterial, or that the\nchanges may be safely ignored for most of the tree, for testing\npurposes.With Cons, the view is that it is pragmatic to admit this type of\nbehavior, with the understanding that on the next full build everything that\nneeds to be rebuilt will be. There is no equivalent to a ``make touch''\ncommand, to mark files as permanently up-to-date. So any risk that is\nincurred by build pruning is mitigated. For release quality work, obviously,\nwe recommend that you do not use build pruning (it's perfectly OK to use\nduring integration, however, for checking compilation, etc. Just be sure to\ndo an unconstrained build before committing the integration).\n\n\n=head1 Temporary overrides\n\nCons provides a very simple mechanism for overriding aspects of a build. The\nessence is that you write an override file containing one or more\nC<Override> commands, and you specify this on the command line, when you run\nC<cons>:\n\n  % cons -o over export\n\nwill build the F<export> directory, with all derived files subject to the\noverrides present in the F<over> file. If you leave out the C<-o> option,\nthen everything necessary to remove all overrides will be rebuilt.\n\n\n=head2 Overriding environment variables\n\nThe override file can contain two types of overrides. The first is incoming\nenvironment variables. These are normally accessible by the F<Construct>\nfile from the C<%ENV> hash variable. These can trivially be overridden in\nthe override file by setting the appropriate elements of C<%ENV> (these\ncould also be overridden in the user's environment, of course).\n\n\n=head2 The Override command\n\nThe second type of override is accomplished with the C<Override> command,\nwhich looks like this:\n\n  Override <regexp>, <var1> => <value1>, <var2> => <value2>, ...;\n\nThe regular expression I<regexp> is matched against every derived file that\nis a candidate for the build. If the derived file matches, then the\nvariable/value pairs are used to override the values in the construction\nenvironment associated with the derived file.\n\nLet's suppose that we have a construction environment like this:\n\n  $CONS = new cons(\n\tCOPT => '',\n\tCDBG => '-g',\n\tCFLAGS => '%COPT %CDBG',\n  );\n\nThen if we have an override file F<over> containing this command:\n\n  Override '\\.o$', COPT => '-O', CDBG => '';\n\nthen any C<cons> invocation with C<-o over> that creates F<.o> files via\nthis environment will cause them to be compiled with C<-O >and no C<-g>. The\noverride could, of course, be restricted to a single directory by the\nappropriate selection of a regular expression.\n\nHere's the original version of the Hello, World! program, built with this\nenvironment. Note that Cons rebuilds the appropriate pieces when the\noverride is applied or removed:\n\n  % cons hello\n  cc -g -c hello.c -o hello.o\n  cc -o hello hello.o\n  % cons -o over hello\n  cc -O -c hello.c -o hello.o\n  cc -o hello hello.o\n  % cons -o over hello\n  cons: \"hello\" is up-to-date.\n  % cons hello\n  cc -g -c hello.c -o hello.o\n  cc -o hello hello.o\n\nIt's important that the C<Override> command only be used for temporary,\non-the-fly overrides necessary for development because the overrides are not\nplatform independent and because they rely too much on intimate knowledge of\nthe workings of the scripts. For temporary use, however, they are exactly\nwhat you want.\n\nNote that it is still useful to provide, say, the ability to create a fully\noptimized version of a system for production use--from the F<Construct> and\nF<Conscript> files. This way you can tailor the optimized system to the\nplatform. Where optimizer trade-offs need to be made (particular files may\nnot be compiled with full optimization, for example), then these can be\nrecorded for posterity (and reproducibility) directly in the scripts.\n\n\n=head1 More on construction environments\n\nAs previously mentioned, a B<construction environment> is an object that\nhas a set of keyword/value pairs and a set of methods, and which is used\nto tell Cons how target files should be built.  This section describes\nhow Cons uses and expands construction environment values to control its\nbuild behavior.\n\n=head2 Construction variable expansion\n\nConstruction variables from a construction environment are expanded\nby preceding the keyword with a C<%> (percent sign):\n\n  Construction variables:\n\tXYZZY => 'abracadabra',\n\n  The string:  \"The magic word is:  %XYZZY!\"\n  expands to:  \"The magic word is:  abracadabra!\"\n\nA construction variable name may be surrounded by C<{> and C<}> (curly\nbraces), which are stripped as part of the expansion.  This can\nsometimes be necessary to separate a variable expansion from trailing\nalphanumeric characters:\n\n  Construction variables:\n\tOPT    => 'value1',\n\tOPTION => 'value2',\n\n  The string:  \"%OPT %{OPT}ION %OPTION %{OPTION}\"\n  expands to:  \"value1 value1ION value2 value2\"\n\nConstruction variable expansion is recursive--that is, a string\ncontaining C<%->expansions after substitution will be re-expanded until\nno further substitutions can be made:\n\n  Construction variables:\n\tSTRING => 'The result is:  %FOO',\n\tFOO    => '%BAR',\n\tBAR    => 'final value',\n\n  The string:  \"The string says:  %STRING\"\n  expands to:  \"The string says:  The result is:  final value\"\n\nIf a construction variable is not defined in an environment, then the\nnull string is substituted:\n\n  Construction variables:\n\tFOO => 'value1',\n\tBAR => 'value2',\n\n  The string:  \"%FOO <%NO_VARIABLE> %BAR\"\n  expands to:  \"value1 <> value2\"\n\nA doubled C<%%> will be replaced by a single C<%>:\n\n  The string:  \"Here is a percent sign:  %%\"\n  expands to:  \"Here is a percent sign: %\"\n\n=head2 Default construction variables\n\nWhen you specify no arguments when creating a new construction\nenvironment:\n\n  $env = new cons();\n\nCons creates a reference to a new, default construction\nenvironment. This contains a number of construction variables and some\nmethods. At the present writing, the default construction variables on a\nUNIX system are:\n\n  CC            => 'cc',\n  CFLAGS        => '',\n  CCCOM         => '%CC %CFLAGS %_IFLAGS -c %< -o %>',\n  CXX           => '%CC',\n  CXXFLAGS      => '%CFLAGS',\n  CXXCOM        => '%CXX %CXXFLAGS %_IFLAGS -c %< -o %>',\n  INCDIRPREFIX  => '-I',\n  INCDIRSUFFIX  => '',\n  LINK          => '%CXX',\n  LINKCOM       => '%LINK %LDFLAGS -o %> %< %_LDIRS %LIBS',\n  LINKMODULECOM => '%LD -r -o %> %<',\n  LIBDIRPREFIX  => '-L',\n  LIBDIRSUFFIX  => '',\n  AR\t\t=> 'ar',\n  ARFLAGS\t=> 'r',\n  ARCOM\t\t=> ['%AR %ARFLAGS %> %<', '%RANLIB %>'],\n  RANLIB\t=> 'ranlib',\n  AS\t\t=> 'as',\n  ASFLAGS\t=> '',\n  ASCOM\t\t=> '%AS %ASFLAGS %< -o %>',\n  LD\t\t=> 'ld',\n  LDFLAGS\t=> '',\n  PREFLIB\t=> 'lib',\n  SUFLIB\t=> '.a',\n  SUFLIBS\t=> '.so:.a',\n  SUFOBJ\t=> '.o',\n  SIGNATURE     => [ '*' => 'build' ],\n  ENV\t\t=> { 'PATH' => '/bin:/usr/bin' },\n\n\nAnd on a Win32 system (Windows NT), the default construction variables\nare (unless the default rule style is set using the B<DefaultRules>\nmethod):\n\n  CC\t\t=> 'cl',\n  CFLAGS\t=> '/nologo',\n  CCCOM\t\t=> '%CC %CFLAGS %_IFLAGS /c %< /Fo%>',\n  CXXCOM        => '%CXX %CXXFLAGS %_IFLAGS /c %< /Fo%>',\n  INCDIRPREFIX  => '/I',\n  INCDIRSUFFIX  => '',\n  LINK          => 'link',\n  LINKCOM       => '%LINK %LDFLAGS /out:%> %< %_LDIRS %LIBS',\n  LINKMODULECOM => '%LD /r /o %> %<',\n  LIBDIRPREFIX  => '/LIBPATH:',\n  LIBDIRSUFFIX  => '',\n  AR            => 'lib',\n  ARFLAGS       => '/nologo ',\n  ARCOM         => \"%AR %ARFLAGS /out:%> %<\",\n  RANLIB        => '',\n  LD            => 'link',\n  LDFLAGS       => '/nologo ',\n  PREFLIB       => '',\n  SUFEXE\t=> '.exe',\n  SUFLIB\t=> '.lib',\n  SUFLIBS\t=> '.dll:.lib',\n  SUFOBJ\t=> '.obj',\n  SIGNATURE     => [ '*' => 'build' ],\n\nThese variables are used by the various methods associated with the\nenvironment. In particular, any method that ultimately invokes an external\ncommand will substitute these variables into the final command, as\nappropriate. For example, the C<Objects> method takes a number of source\nfiles and arranges to derive, if necessary, the corresponding object\nfiles:\n\n  Objects $env 'foo.c', 'bar.c';\n\nThis will arrange to produce, if necessary, F<foo.o> and F<bar.o>. The\ncommand invoked is simply C<%CCCOM>, which expands, through substitution,\nto the appropriate external command required to build each object. The\nsubstitution rules will be discussed in detail in the next section.\n\nThe construction variables are also used for other purposes. For example,\nC<CPPPATH> is used to specify a colon-separated path of include\ndirectories. These are intended to be passed to the C preprocessor and are\nalso used by the C-file scanning machinery to determine the dependencies\ninvolved in a C Compilation.\n\nVariables beginning with underscore are created by various methods,\nand should normally be considered ``internal'' variables. For example,\nwhen a method is called which calls for the creation of an object from\na C source, the variable C<_IFLAGS> is created: this corresponds to the\nC<-I> switches required by the C compiler to represent the directories\nspecified by C<CPPPATH>.\n\nNote that, for any particular environment, the value of a variable is set\nonce, and then never reset (to change a variable, you must create a new\nenvironment. Methods are provided for copying existing environments for this\npurpose). Some internal variables, such as C<_IFLAGS> are created on demand,\nbut once set, they remain fixed for the life of the environment.\n\nThe C<CFLAGS>, C<LDFLAGS>, and C<ARFLAGS> variables all supply a place\nfor passing options to the compiler, loader, and archiver, respectively.\n\nThe C<INCDIRPREFIX> and C<INCDIRSUFFIX> variables specify option\nstrings to be appended to the beginning and end, respectively, of each\ninclude directory so that the compiler knows where to find F<.h> files.\nSimilarly, the C<LIBDIRPREFIX> and C<LIBDIRSUFFIX> variables specify the\noption string to be appended to the beginning of and end, respectively,\nof each directory that the linker should search for libraries.\n\nAnother variable, C<ENV>, is used to determine the system environment during\nthe execution of an external command. By default, the only environment\nvariable that is set is C<PATH>, which is the execution path for a UNIX\ncommand. For the utmost reproducibility, you should really arrange to set\nyour own execution path, in your top-level F<Construct> file (or perhaps by\nimporting an appropriate construction package with the Perl C<use>\ncommand). The default variables are intended to get you off the ground.\n\n=head2 Expanding variables in construction commands\n\nWithin a construction command, construction variables will be expanded\naccording to the rules described above.  In addition to normal variable\nexpansion from the construction environment, construction commands also\nexpand the following pseudo-variables to insert the specific input and\noutput files in the command line that will be executed:\n\n=over 10\n\n=item %>\n\nThe target file name.  In a multi-target command, this expands to the\nfirst target mentioned.)\n\n=item %0\n\nSame as C<%E<gt>>.\n\n=item %1, %2, ..., %9\n\nThese refer to the first through ninth input file, respectively.\n\n=item %E<lt>\n\nThe full set of input file names. If any of these have been used\nanywhere else in the current command line (via C<%1>, C<%2>, etc.), then\nthose will be deleted from the list provided by C<%E<lt>>. Consider the\nfollowing command found in a F<Conscript> file in the F<test> directory:\n\n  Command $env 'tgt', qw(foo bar baz), qq(\n\techo %< -i %1 > %>\n\techo %< -i %2 >> %>\n\techo %< -i %3 >> %>\n  );\n\nIf F<tgt> needed to be updated, then this would result in the execution of\nthe following commands, assuming that no remapping has been established for\nthe F<test> directory:\n\n  echo test/bar test/baz -i test/foo > test/tgt\n  echo test/foo test/baz -i test/bar >> test/tgt\n  echo test/foo test/bar -i test/baz >> test/tgt\n\n=back\n\nAny of the above pseudo-variables may be followed immediately by one of\nthe following suffixes to select a portion of the expanded path name:\n\n  :a    the absolute path to the file name\n  :b    the directory plus the file name stripped of any suffix\n  :d    the directory\n  :f    the file name\n  :s    the file name suffix\n  :F    the file name stripped of any suffix\n  :S    the absolute path path to a Linked source file\n\nContinuing with the above example, C<%E<lt>:f> would expand to C<foo bar baz>,\nand C<%E<gt>:d> would expand to C<test>.\n\nThere are additional C<%> elements which affect the command line(s):\n\n=over 10\n\n=item %[ %]\n\nIt is possible to programmatically rewrite part of the command by\nenclosing part of it between C<%[> and C<%]>.  This will call the\nconstruction variable named as the first word enclosed in the brackets\nas a Perl code reference; the results of this call will be used to\nreplace the contents of the brackets in the command line.  For example,\ngiven an existing input file named F<tgt.in>:\n\n  @keywords = qw(foo bar baz);\n  $env = new cons(X_COMMA => sub { join(\",\", @_) });\n  Command $env 'tgt', 'tgt.in', qq(\n\techo '# Keywords: %[X_COMMA @keywords %]' > %>\n\tcat %< >> %>\n  );\n\nThis will execute:\n\n  echo '# Keywords: foo,bar,baz' > tgt\n  cat tgt.in >> tgt\n\n=item %( %)\n\nCons includes the text of the command line in the MD5 signature for a\nbuild, so that targets get rebuilt if you change the command line (to\nadd or remove an option, for example).  Command-line text in between\nC<%(> and C<%)>, however, will be ignored for MD5 signature calculation.\n\nInternally, Cons uses C<%(> and C<%)> around include and library\ndirectory options (C<-I> and C<-L> on UNIX systems, C</I> and\nC</LIBPATH> on Windows NT) to avoid rebuilds just because the directory\nlist changes.  Rebuilds occur only if the changed directory list causes\nany included I<files> to change, and a changed include file is detected\nby the MD5 signature calculation on the actual file contents.\n\n=back\n\n=head2 Expanding construction variables in file names\n\nCons expands construction variables in the source and target file names\npassed to the various construction methods according to the expansion\nrules described above:\n\n  $env = new cons(\n\tDESTDIR\t=>\t'programs',\n\tSRCDIR\t=>\t'src',\n  );\n  Program $env '%DESTDIR/hello', '%SRCDIR/hello.c';\n\nThis allows for flexible configuration, through the construction\nenvironment, of directory names, suffixes, etc.\n\n\n=head1 Build actions\n\nCons supports several types of B<build actions> that can be performed\nto construct one or more target files.  Usually, a build action is\na construction command--that is, a command-line string that invokes\nan external command.  Cons can also execute Perl code embedded in a\ncommand-line string, and even supports an experimental ability to build\na target file by executing a Perl code reference directly.\n\nA build action is usually specified as the value of a construction\nvariable:\n\n  $env = new cons(\n\tCCCOM         => '%CC %CFLAGS %_IFLAGS -c %< -o %>',\n\tLINKCOM       => '[perl] &link_executable(\"%>\", \"%<\")',\n\tARCOM         => sub { my($env, $target, @sources) = @_;\n\t\t\t\t # code to create an archive\n\t\t\t\t}\n  );\n\nA build action may be associated directly with one or more target files\nvia the C<Command> method; see below.\n\n=head2 Construction commands\n\nA construction command goes through expansion of construction variables\nand C<%-> pseudo-variables, as described above, to create the actual\ncommand line that Cons will execute to generate the target file or\nfiles.\n\nAfter substitution occurs, strings of white space are converted into\nsingle blanks, and leading and trailing white space is eliminated. It\nis therefore currently not possible to introduce variable length white\nspace in strings passed into a command.\n\nIf a multi-line command string is provided, the commands are executed\nsequentially. If any of the commands fails, then none of the rest are\nexecuted, and the target is not marked as updated, i.e. a new signature is\nnot stored for the target.\n\nNormally, if all the commands succeed, and return a zero status (or whatever\nplatform-specific indication of success is required), then a new signature\nis stored for the target. If a command erroneously reports success even\nafter a failure, then Cons will assume that the target file created by that\ncommand is accurate and up-to-date.\n\nThe first word of each command string, after expansion, is assumed to be an\nexecutable command looked up on the C<PATH> environment variable (which is,\nin turn, specified by the C<ENV> construction variable). If this command is\nfound on the path, then the target will depend upon it: the command will\ntherefore be automatically built, as necessary. It's possible to write\nmulti-part commands to some shells, separated by semi-colons. Only the first\ncommand word will be depended upon, however, so if you write your command\nstrings this way, you must either explicitly set up a dependency (with the\nC<Depends> method), or be sure that the command you are using is a system\ncommand which is expected to be available. If it isn't available, you will,\nof course, get an error.\n\nCons normally prints a command before executing it.  This behavior is\nsuppressed if the first character of the command is C<@>.  Note that\nyou may need to separate the C<@> from the command name or escape it to\nprevent C<@cmd> from looking like an array to Perl quote operators that\nperform interpolation:\n\n  # The first command line is incorrect,\n  # because \"@cp\" looks like an array\n  # to the Perl qq// function.\n  # Use the second form instead.\n  Command $env 'foo', 'foo.in', qq(\n\t@cp %< tempfile\n\t@ cp tempfile %>\n  );\n\nIf there are shell meta characters anywhere in the expanded command line,\nsuch as C<E<lt>>, C<E<gt>>, quotes, or semi-colon, then the command\nwill actually be executed by invoking a shell. This means that a command\nsuch as:\n\n  cd foo\n\nalone will typically fail, since there is no command C<cd> on the path. But\nthe command string:\n\n  cd $<:d; tar cf $>:f $<:f\n\nwhen expanded will still contain the shell meta character semi-colon, and a\nshell will be invoked to interpret the command. Since C<cd> is interpreted\nby this sub-shell, the command will execute as expected.\n\n=head2 Perl expressions\n\nIf any command (even one within a multi-line command) begins with\nC<[perl]>, the remainder of that command line will be evaluated by the\nrunning Perl instead of being forked by the shell.  If an error occurs\nin parsing the Perl code, or if the Perl expression returns 0 or undef,\nthe command will be considered to have failed.  For example, here is a\nsimple command which creates a file C<foo> directly from Perl:\n\n  $env = new cons();\n  Command $env 'foo',\n    qq([perl] open(FOO,'>foo');print FOO \"hi\\\\n\"; close(FOO); 1);\n\nNote that when the command is executed, you are in the same package as\nwhen the F<Construct> or F<Conscript> file was read, so you can call\nPerl functions you've defined in the same F<Construct> or F<Conscript>\nfile in which the C<Command> appears:\n\n  $env = new cons();\n  sub create_file {\n\tmy $file = shift;\n\topen(FILE, \">$file\");\n\tprint FILE \"hi\\n\";\n\tclose(FILE);\n\treturn 1;\n  }\n  Command $env 'foo', \"[perl] &create_file('%>')\";\n\nThe Perl string will be used to generate the signature for the derived\nfile, so if you change the string, the file will be rebuilt.  The contents\nof any subroutines you call, however, are not part of the signature,\nso if you modify a called subroutine such as C<create_file> above,\nthe target will I<not> be rebuilt.  Caveat user.\n\n=head2 Perl code references [EXPERIMENTAL]\n\nCons supports the ability to create a derived file by directly executing\na Perl code reference.  This feature is considered EXPERIMENTAL and\nsubject to change in the future.\n\nA code reference may either be a named subroutine referenced by the\nusual C<\\&> syntax:\n\n  sub build_output {\n\tmy($env, $target, @sources) = @_;\n\tprint \"build_output building $target\\n\";\n\topen(OUT, \">$target\");\n\tforeach $src (@sources) {\n\t    if (! open(IN, \"<$src\")) {\n\t\tprint STDERR \"cannot open '$src': $!\\n\";\n\t\treturn undef;\n\t    }\n\t    print OUT, <IN>;\n\t}\n\tclose(OUT);\n\treturn 1;\n  }\n  Command $env 'output', \\&build_output;\n\nor the code reference may be an anonymous subroutine:\n\n  Command $env 'output', sub {\n\tmy($env, $target, @sources) = @_;\n\tprint \"building $target\\n\";\n\topen(FILE, \">$target\");\n\tprint FILE \"hello\\n\";\n\tclose(FILE);\n\treturn 1;\n  };\n\nTo build the target file, the referenced subroutine is passed, in order:\nthe construction environment used to generate the target; the path\nname of the target itself; and the path names of all the source files\nnecessary to build the target file.\n\nThe code reference is expected to generate the target file, of course,\nbut may manipulate the source and target files in any way it chooses.\nThe code reference must return a false value (C<undef> or C<0>) if\nthe build of the file failed.  Any true value indicates a successful\nbuild of the target.\n\nBuilding target files using code references is considered EXPERIMENTAL\ndue to the following current limitations:\n\n=over 4\n\nCons does I<not> print anything to indicate the code reference is being\ncalled to build the file.  The only way to give the user any indication\nis to have the code reference explicitly print some sort of \"building\"\nmessage, as in the above examples.\n\nCons does not generate any signatures for code references, so if the\ncode in the reference changes, the target will I<not> be rebuilt.\n\nCons has no public method to allow a code reference to extract\nconstruction variables.  This would be good to allow generalization of\ncode references based on the current construction environment, but would\nalso complicate the problem of generating meaningful signatures for code\nreferences.\n\n=back\n\nSupport for building targets via code references has been released in\nthis version to encourage experimentation and the seeking of possible\nsolutions to the above limitations.\n\n\n=head1 Default construction methods\n\nThe list of default construction methods includes the following:\n\n\n=head2 The C<new> constructor\n\nThe C<new> method is a Perl object constructor. That is, it is not invoked\nvia a reference to an existing construction environment B<reference>, but,\nrather statically, using the name of the Perl B<package> where the\nconstructor is defined. The method is invoked like this:\n\n  $env = new cons(<overrides>);\n\nThe environment you get back is blessed into the package C<cons>, which\nmeans that it will have associated with it the default methods described\nbelow. Individual construction variables can be overridden by providing\nname/value pairs in an override list. Note that to override any command\nenvironment variable (i.e. anything under C<ENV>), you will have to override\nall of them. You can get around this difficulty by using the C<copy> method\non an existing construction environment.\n\n\n=head2 The C<clone> method\n\nThe C<clone> method creates a clone of an existing construction environment,\nand can be called as in the following example:\n\n  $env2 = $env1->clone(<overrides>);\n\nYou can provide overrides in the usual manner to create a different\nenvironment from the original. If you just want a new name for the same\nenvironment (which may be helpful when exporting environments to existing\ncomponents), you can just use simple assignment.\n\n\n=head2 The C<copy> method\n\nThe C<copy> method extracts the externally defined construction variables\nfrom an environment and returns them as a list of name/value\npairs. Overrides can also be provided, in which case, the overridden values\nwill be returned, as appropriate. The returned list can be assigned to a\nhash, as shown in the prototype, below, but it can also be manipulated in\nother ways:\n\n  %env = $env1->copy(<overrides>);\n\nThe value of C<ENV>, which is itself a hash, is also copied to a new hash,\nso this may be changed without fear of affecting the original\nenvironment. So, for example, if you really want to override just the\nC<PATH> variable in the default environment, you could do the following:\n\n  %cons = new cons()->copy();\n  $cons{ENV}{PATH} = \"<your path here>\";\n  $cons = new cons(%cons);\n\nThis will leave anything else that might be in the default execution\nenvironment undisturbed.\n\n\n=head2 The C<Install> method\n\nThe C<Install> method arranges for the specified files to be installed in\nthe specified directory. The installation is optimized: the file is not\ncopied if it can be linked. If this is not the desired behavior, you will\nneed to use a different method to install the file. It is called as follows:\n\n  Install $env <directory>, <names>;\n\nNote that, while the files to be installed may be arbitrarily named,\nonly the last component of each name is used for the installed target\nname. So, for example, if you arrange to install F<foo/bar> in F<baz>,\nthis will create a F<bar> file in the F<baz> directory (not F<foo/bar>).\n\n\n=head2 The C<InstallAs> method\n\nThe C<InstallAs> method arranges for the specified source file(s) to be\ninstalled as the specified target file(s). Multiple files should be\nspecified as a file list. The installation is optimized: the file is not\ncopied if it can be linked. If this is not the desired behavior, you will\nneed to use a different method to install the file. It is called as follows:\n\nC<InstallAs> works in two ways:\n\nSingle file install:\n\n  InstallAs $env TgtFile, SrcFile;\n\nMultiple file install:\n\n  InstallAs $env ['tgt1', 'tgt2'], ['src1', 'src2'];\n\nOr, even as:\n\n  @srcs = qw(src1 src2 src3);\n  @tgts = qw(tgt1 tgt2 tgt3);\n  InstallAs $env [@tgts], [@srcs];\n\nBoth the target and the sources lists should be of the same length.\n\n=head2 The C<Precious> method\n\nThe C<Precious> method asks cons not to delete the specified file or\nlist of files before building them again.  It is invoked as:\n\n  Precious <files>;\n\nThis is especially useful for allowing incremental updates to libraries\nor debug information files which are updated rather than rebuilt anew each\ntime.  Cons will still delete the files when the C<-r> flag is specified.\n\n=head2 The C<AfterBuild> method\n\nThe C<AfterBuild> method evaluates the specified perl string after\nbuilding the given file or files (or finding that they are up to date).\nThe eval will happen once per specified file.  C<AfterBuild> is called\nas follows:\n\n  AfterBuild $env 'foo.o', qq(print \"foo.o is up to date!\\n\");\n\nThe perl string is evaluated in the C<script> package, and has access\nto all variables and subroutines defined in the F<Conscript> file in\nwhich the C<AfterBuild> method is called.\n\n=head2 The C<Command> method\n\nThe C<Command> method is a catchall method which can be used to arrange for\nany build action to be executed to update the target. For this command, a\ntarget file and list of inputs is provided. In addition, a build action\nis specified as the last argument.  The build action is typically a\ncommand line or lines, but may also contain Perl code to be executed;\nsee the section above on build actions for details.\n\nThe C<Command> method is called as follows:\n\n  Command $env <target>, <inputs>, <build action>;\n\nThe target is made dependent upon the list of input files specified, and the\ninputs must be built successfully or Cons will not attempt to build the\ntarget.\n\nTo specify a command with multiple targets, you can specify a reference to a\nlist of targets. In Perl, a list reference can be created by enclosing a\nlist in square brackets. Hence the following command:\n\n  Command $env ['foo.h', 'foo.c'], 'foo.template', q(\n\tgen %1\n  );\n\ncould be used in a case where the command C<gen> creates two files, both\nF<foo.h> and F<foo.c>.\n\n\n=head2 The C<Objects> method\n\nThe C<Objects> method arranges to create the object files that correspond to\nthe specified source files. It is invoked as shown below:\n\n  @files = Objects $env <source or object files>;\n\nUnder Unix, source files ending in F<.s> and F<.c> are currently\nsupported, and will be compiled into a name of the same file ending\nin F<.o>. By default, all files are created by invoking the external\ncommand which results from expanding the C<CCCOM> construction variable,\nwith C<%E<lt>> and C<%E<gt>> set to the source and object files,\nrespectively. (See the section above on construction variable expansion\nfor details).  The variable C<CPPPATH> is also used when scanning source\nfiles for dependencies. This is a colon separated list of pathnames, and\nis also used to create the construction variable C<_IFLAGS,> which will\ncontain the appropriate list of -C<I> options for the compilation. Any\nrelative pathnames in C<CPPPATH> is interpreted relative to the\ndirectory in which the associated construction environment was created\n(absolute and top-relative names may also be used). This variable is\nused by C<CCCOM>. The behavior of this command can be modified by\nchanging any of the variables which are interpolated into C<CCCOM>, such\nas C<CC>, C<CFLAGS>, and, indirectly, C<CPPPATH>. It's also possible\nto replace the value of C<CCCOM>, itself. As a convenience, this file\nreturns the list of object filenames.\n\n\n=head2 The C<Program> method\n\nThe C<Program> method arranges to link the specified program with the\nspecified object files. It is invoked in the following manner:\n\n  Program $env <program name>, <source or object files>;\n\nThe program name will have the value of the C<SUFEXE> construction\nvariable appended (by default, C<.exe> on Win32 systems, nothing on Unix\nsystems) if the suffix is not already present.\n\nSource files may be specified in place of objects files--the C<Objects>\nmethod will be invoked to arrange the conversion of all the files into\nobject files, and hence all the observations about the C<Objects> method,\nabove, apply to this method also.\n\nThe actual linking of the program will be handled by an external command\nwhich results from expanding the C<LINKCOM> construction variable, with\nC<%E<lt>> set to the object files to be linked (in the order presented),\nand C<%E<gt>> set to the target. (See the section above on construction\nvariable expansion for details.)  The user may set additional variables\nin the construction environment, including C<LINK>, to define which\nprogram to use for linking, C<LIBPATH>, a colon-separated list of\nlibrary search paths, for use with library specifications of the form\nI<-llib>, and C<LIBS>, specifying the list of libraries to link against\n(in either I<-llib> form or just as pathnames. Relative pathnames in\nboth C<LIBPATH> and C<LIBS> are interpreted relative to the directory\nin which the associated construction environment is created (absolute\nand top-relative names may also be used). Cons automatically sets up\ndependencies on any libraries mentioned in C<LIBS>: those libraries will\nbe built before the command is linked.\n\n\n=head2 The C<Library> method\n\nThe C<Library> method arranges to create the specified library from the\nspecified object files. It is invoked as follows:\n\n  Library $env <library name>, <source or object files>;\n\nThe library name will have the value of the C<SUFLIB> construction\nvariable appended (by default, C<.lib> on Win32 systems, C<.a> on Unix\nsystems) if the suffix is not already present.\n\nSource files may be specified in place of objects files--the C<Objects>\nmethod will be invoked to arrange the conversion of all the files into\nobject files, and hence all the observations about the C<Objects> method,\nabove, apply to this method also.\n\nThe actual creation of the library will be handled by an external\ncommand which results from expanding the C<ARCOM> construction variable,\nwith C<%E<lt>> set to the library members (in the order presented),\nand C<%E<gt>> to the library to be created.  (See the section above\non construction variable expansion for details.)  The user may set\nvariables in the construction environment which will affect the\noperation of the command. These include C<AR>, the archive program\nto use, C<ARFLAGS>, which can be used to modify the flags given to\nthe program specified by C<AR>, and C<RANLIB>, the name of a archive\nindex generation program, if needed (if the particular need does not\nrequire the latter functionality, then C<ARCOM> must be redefined to not\nreference C<RANLIB>).\n\nThe C<Library> method allows the same library to be specified in multiple\nmethod invocations. All of the contributing objects from all the invocations\n(which may be from different directories) are combined and generated by a\nsingle archive command. Note, however, that if you prune a build so that\nonly part of a library is specified, then only that part of the library will\nbe generated (the rest will disappear!).\n\n\n=head2 The C<Module> method\n\nThe C<Module> method is a combination of the C<Program> and C<Command>\nmethods. Rather than generating an executable program directly, this command\nallows you to specify your own command to actually generate a module. The\nmethod is invoked as follows:\n\n  Module $env <module name>, <source or object files>, <construction command>;\n\nThis command is useful in instances where you wish to create, for example,\ndynamically loaded modules, or statically linked code libraries.\n\n\n=head2 The C<Depends> method\n\nThe C<Depends> method allows you to specify additional dependencies for a\ntarget.  It is invoked as follows:\n\n  Depends $env <target>, <dependencies>;\n\nThis may be occasionally useful, especially in cases where no scanner exists\n(or is writable) for particular types of files. Normally, dependencies are\ncalculated automatically from a combination of the explicit dependencies set\nup by the method invocation or by scanning source files.\n\nA set of identical dependencies for multiple targets may be specified\nusing a reference to a list of targets. In Perl, a list reference can\nbe created by enclosing a list in square brackets. Hence the following\ncommand:\n\n  Depends $env ['foo', 'bar'], 'input_file_1', 'input_file_2';\n\nspecifies that both the F<foo> and F<bar> files depend on the listed\ninput files.\n\n\n=head2 The C<RuleSet> method\n\nThe C<RuleSet> method returns the construction variables for building\nvarious components with one of the rule sets supported by Cons.  The\ncurrently supported rule sets are:\n\n=over 4\n\n=item msvc\n\nRules for the Microsoft Visual C++ compiler suite.\n\n=item unix\n\nGeneric rules for most UNIX-like compiler suites.\n\n=back\n\nOn systems with more than one available compiler suite, this allows you\nto easily create side-by-side environments for building software with\nmultiple tools:\n\n    $msvcenv = new cons(RuleSet(\"msvc\"));\n    $cygnusenv = new cons(RuleSet(\"unix\"));\n\nIn the future, this could also be extended to other platforms that\nhave different default rule sets.\n\n\n=head2 The C<DefaultRules> method\n\nThe C<DefaultRules> method sets the default construction variables that\nwill be returned by the C<new> method to the specified arguments:\n\n  DefaultRules(CC     => 'gcc',\n\t       CFLAGS => '',\n\t       CCCOM  => '%CC %CFLAGS %_IFLAGS -c %< -o %>');\n  $env = new cons();\n  # $env now contains *only* the CC, CFLAGS,\n  # and CCCOM construction variables\n\nCombined with the C<RuleSet> method, this also provides an easy way\nto set explicitly the default build environment to use some supported\ntoolset other than the Cons defaults:\n\n    # use a UNIX-like tool suite (like cygwin) on Win32\n    DefaultRules(RuleSet('unix'));\n    $env = new cons();\n\nNote that the C<DefaultRules> method completely replaces the default\nconstruction environment with the specified arguments, it does not\nsimply override the existing defaults.  To override one or more\nvariables in a supported C<RuleSet>, append the variables and values:\n\n  DefaultRules(RuleSet('unix'), CFLAGS => '-O3');\n  $env1 = new cons();\n  $env2 = new cons();\n  # both $env1 and $env2 have 'unix' defaults\n  # with CFLAGS set to '-O3'\n\n\n=head2 The C<Ignore> method\n\nThe C<Ignore> method allows you to ignore explicitly dependencies that\nCons infers on its own.  It is invoked as follows:\n\n  Ignore <patterns>;\n\nThis can be used to avoid recompilations due to changes in system header\nfiles or utilities that are known to not affect the generated targets.\n\nIf, for example, a program is built in an NFS-mounted directory on\nmultiple systems that have different copies of F<stdio.h>, the differences\nwill affect the signatures of all derived targets built from source files\nthat C<#include E<lt>stdio.hE<gt>>.  This will cause all those targets to\nbe rebuilt when changing systems.  If this is not desirable behavior, then\nthe following line will remove the dependencies on the F<stdio.h> file:\n\n  Ignore '^/usr/include/stdio\\.h$';\n\nNote that the arguments to the C<Ignore> method are regular expressions,\nso special characters must be escaped and you may wish to anchor the\nbeginning or end of the expression with C<^> or C<$> characters.\n\n\n=head2 The C<Salt> method\n\nThe C<Salt> method adds a constant value to the signature calculation\nfor every derived file.  It is invoked as follows:\n\n  Salt $string;\n\nChanging the Salt value will force a complete rebuild of every derived\nfile.  This can be used to force rebuilds in certain desired\ncircumstances.  For example,\n\n  Salt `uname -s`;\n\nWould force a complete rebuild of every derived file whenever the\noperating system on which the build is performed (as reported by C<uname\n-s>) changes.\n\n\n=head2 The C<UseCache> method\n\nThe C<UseCache> method instructs Cons to maintain a cache of derived\nfiles, to be shared among separate build trees of the same project.\n\n  UseCache(\"cache/<buildname>\") || warn(\"cache directory not found\");\n\n\n=head2 The C<SourcePath> method\n\nThe C<SourcePath> mathod returns the real source path name of a file,\nas opposed to the path name within a build directory.  It is invoked\nas follows:\n\n  $path = SourcePath <buildpath>;\n\n\n=head2 The C<ConsPath> method\n\nThe C<ConsPath> method returns true if the supplied path is a derivable\nfile, and returns undef (false) otherwise.\nIt is invoked as follows:\n\n  $result = ConsPath <path>;\n\n\n=head2 The C<SplitPath> method\n\nThe C<SplitPath> method looks up multiple path names in a string separated\nby the default path separator for the operating system (':' on UNIX\nsystems, ';' on Windows NT), and returns the fully-qualified names.\nIt is invoked as follows:\n\n  @paths = SplitPath <pathlist>;\n\nThe C<SplitPath> method will convert  names prefixed '#' to the\nappropriate top-level build name (without the '#') and will convert\nrelative names to top-level names.\n\n\n=head2 The C<DirPath> method\n\nThe C<DirPath> method returns the build path name(s) of a directory or\nlist of directories.  It is invoked as follows:\n\n  $cwd = DirPath <paths>;\n\nThe most common use for the C<DirPath> method is:\n\n  $cwd = DirPath '.';\n\nto fetch the path to the current directory of a subsidiary F<Conscript>\nfile.\n\n\n=head2 The C<FilePath> method\n\nThe C<FilePath> method returns the build path name(s) of a file or\nlist of files.  It is invoked as follows:\n\n  $file = FilePath <path>;\n\n\n=head2 The C<Help> method\n\nThe C<Help> method specifies help text that will be displayed when the\nuser invokes C<cons -h>.  This can be used to provide documentation\nof specific targets, values, build options, etc. for the build tree.\nIt is invoked as follows:\n\n  Help <helptext>;\n\nThe C<Help> method may only be called once, and should typically be\nspecified in the top-level F<Construct> file.\n\n\n=head1 Extending Cons\n\n\n=head2 Overriding construction variables\n\nThere are several ways of extending Cons, which vary in degree of\ndifficulty. The simplest method is to define your own construction\nenvironment, based on the default environment, but modified to reflect your\nparticular needs. This will often suffice for C-based applications. You can\nuse the C<new> constructor, and the C<clone> and C<copy> methods to create\nhybrid environments. These changes can be entirely transparent to the\nunderlying F<Conscript> files.\n\n\n=head2 Adding new methods\n\nFor slightly more demanding changes, you may wish to add new methods to the\nC<cons> package. Here's an example of a very simple extension,\nC<InstallScript>, which installs a tcl script in a requested location, but\nedits the script first to reflect a platform-dependent path that needs to be\ninstalled in the script:\n\n  # cons::InstallScript - Create a platform dependent version of a shell\n  # script by replacing string ``#!your-path-here'' with platform specific\n  # path $BIN_DIR.\n\n  sub cons::InstallScript {\n\tmy ($env, $dst, $src) = @_;\n\tCommand $env $dst, $src, qq(\n\t\tsed s+your-path-here+$BIN_DIR+ %< > %>\n\t\tchmod oug+x %>\n\t);\n  }\n\nNotice that this method is defined directly in the C<cons> package (by\nprefixing the name with C<cons::>). A change made in this manner will be\nglobally visible to all environments, and could be called as in the\nfollowing example:\n\n  InstallScript $env \"$BIN/foo\", \"foo.tcl\";\n\nFor a small improvement in generality, the C<BINDIR> variable could be\npassed in as an argument or taken from the construction environment--as\nC<%BINDIR>.\n\n\n=head2 Overriding methods\n\nInstead of adding the method to the C<cons> name space, you could define a\nnew package which inherits existing methods from the C<cons> package and\noverrides or adds others. This can be done using Perl's inheritance\nmechanisms.\n\nThe following example defines a new package C<cons::switch> which\noverrides the standard C<Library> method. The overridden method builds\nlinked library modules, rather than library archives. A new\nconstructor is provided. Environments created with this constructor\nwill have the new library method; others won't.\n\n  package cons::switch;\n  BEGIN {@ISA = 'cons'}\n\n  sub new {\n\tshift;\n\tbless new cons(@_);\n  }\n\n  sub Library {\n\tmy($env) = shift;\n\tmy($lib) = shift;\n\tmy(@objs) = Objects $env @_;\n\tCommand $env $lib, @objs, q(\n\t\t%LD -r %LDFLAGS %< -o %>\n\t);\n  }\n\nThis functionality could be invoked as in the following example:\n\n  $env = new cons::switch(@overrides);\n  ...\n  Library $env 'lib.o', 'foo.c', 'bar.c';\n\n\n=head1 Invoking Cons\n\nThe C<cons> command is usually invoked from the root of the build tree. A\nF<Construct> file must exist in that directory. If the C<-f> argument is\nused, then an alternate F<Construct> file may be used (and, possibly, an\nalternate root, since C<cons> will cd to F<Construct> file's containing\ndirectory).\n\nIf C<cons> is invoked from a child of the root of the build tree with\nthe C<-t> argument, it will walk up the directory hierarchy looking for a\nF<Construct> file.  (An alternate name may still be specified with C<-f>.)\nThe targets supplied on the command line will be modified to be relative\nto the discovered F<Construct> file.  For example, from a directory\ncontaining a top-level F<Construct> file, the following invocation:\n\n  % cd libfoo/subdir\n  % cons -t target\n\nis exactly equivalent to:\n\n  % cons libfoo/subdir/target\n\nIf there are any C<Default> targets specified in the directory hierarchy's\nF<Construct> or F<Conscript> files, only the default targets at or below\nthe directory from which C<cons -t> was invoked will be built.\n\nThe command is invoked as follows:\n\n  cons <arguments> -- <construct-args>\n\nwhere I<arguments> can be any of the following, in any order:\n\n=over 10\n\n=item I<target>\n\nBuild the specified target. If I<target> is a directory, then recursively\nbuild everything within that directory.\n\n=item I<+pattern>\n\nLimit the F<Conscript> files considered to just those that match I<pattern>,\nwhich is a Perl regular expression. Multiple C<+> arguments are accepted.\n\n=item I<name>=<val>\n\nSets I<name> to value I<val> in the C<ARG> hash passed to the top-level\nF<Construct> file.\n\n=item C<-cc>\n\nShow command that would have been executed, when retrieving from cache. No\nindication that the file has been retrieved is given; this is useful for\ngenerating build logs that can be compared with real build logs.\n\n=item C<-cd>\n\nDisable all caching. Do not retrieve from cache nor flush to cache.\n\n=item C<-cr>\n\nBuild dependencies in random order. This is useful when building multiple\nsimilar trees with caching enabled.\n\n=item C<-cs>\n\nSynchronize existing build targets that are found to be up-to-date with\ncache. This is useful if caching has been disabled with -cc or just recently\nenabled with UseCache.\n\n=item C<-d>\n\nEnable dependency debugging.\n\n=item C<-f> <file>\n\nUse the specified file instead of F<Construct> (but first change to\ncontaining directory of I<file>).\n\n=item C<-h>\n\nShow a help message local to the current build if one such is defined, and\nexit.\n\n=item C<-k>\n\nKeep going as far as possible after errors.\n\n=item C<-o> <file>\n\nRead override file I<file>.\n\n=item C<-p>\n\nShow construction products in specified trees. No build is attempted.\n\n=item C<-pa>\n\nShow construction products and associated actions. No build is attempted.\n\n=item C<-pw>\n\nShow products and where they are defined. No build is attempted.\n\n=item C<-q>\n\nMake the build quiet.  Multiple C<-q> options may be specified.\n\nA single C<-q> options suppress messages about Installing and Removing\ntargets.\n\nTwo C<-q> options suppress build command lines and target up-to-date\nmessages.\n\n=item C<-r>\n\nRemove construction products associated with <targets>. No build is\nattempted.\n\n=item C<-R> <repos>\n\nSearch for files in I<repos>.  Multiple B<-R> I<repos> directories are\nsearched in the order specified.\n\n=item C<-S> <pkg>\n\nUse the sig::<pkg> package to calculate.  Supported <pkg> values\ninclude \"md5\" for MD5 signature calculation and \"md5::debug\" for debug\ninformation about MD5 signature calculation.\n\nIf the specified package ends in <::debug>, signature debug information\nwill be printed to the file name specified in the C<CONS_SIG_DEBUG>\nenvironment variable, or to standard output if the environment variable\nis not set.\n\n=item C<-t>\n\nTraverse up the directory hierarchy looking for a F<Construct> file,\nif none exists in the current directory.  Targets will be modified to\nbe relative to the F<Construct> file.\n\nInternally, C<cons> will change its working directory to the directory\nwhich contains the top-level F<Construct> file and report:\n\n  cons: Entering directory `top-level-directory'\n\nThis message indicates to an invoking editor (such as emacs) or build\nenvironment that Cons will now report all file names relative to the\ntop-level directory.  This message can not be suppressed with the C<-q>\noption.\n\n=item C<-v>\n\nShow C<cons> version and continue processing.\n\n=item C<-V>\n\nShow C<cons> version and exit.\n\n=item C<-wf> <file>\n\nWrite all filenames considered into I<file>.\n\n=item C<-x>\n\nShow a help message similar to this one, and exit.\n\n=back\n\nAnd I<construct-args> can be any arguments that you wish to process in the\nF<Construct> file. Note that there should be a B<--> separating the arguments\nto cons and the arguments that you wish to process in the F<Construct> file.\n\nProcessing of I<construct-args> can be done by any standard package like\nB<Getopt> or its variants, or any user defined package. B<cons> will pass in\nthe I<construct-args> as B<@ARGV> and will not attempt to interpret anything\nafter the B<-->.\n\n  % cons -R /usr/local/repository -d os=solaris +driver -- -c test -f DEBUG\n\nwould pass the following to cons\n\n  -R /usr/local/repository -d os=solaris +driver\n\nand the following, to the top level F<Construct> file as B<@ARGV>\n\n  -c test -f DEBUG\n\nNote that C<cons -r .> is equivalent to a full recursive C<make clean>,\nbut requires no support in the F<Construct> file or any F<Conscript>\nfiles. This is most useful if you are compiling files into source\ndirectories (if you separate the F<build> and F<export> directories,\nthen you can just remove the directories).\n\nThe options C<-p>, C<-pa>, and C<-pw> are extremely useful for use as an aid\nin reading scripts or debugging them. If you want to know what script\ninstalls F<export/include/foo.h>, for example, just type:\n\n  % cons -pw export/include/foo.h\n\n\n=head1 Using and writing dependency scanners\n\nQuickScan allows simple target-independent scanners to be set up for\nsource files. Only one QuickScan scanner may be associated with any given\nsource file and environment, although the same scanner may (and should)\nbe used for multiple files of a given type.\n\nA QuickScan scanner is only ever invoked once for a given source file,\nand it is only invoked if the file is used by some target in the tree\n(i.e., there is a dependency on the source file).\n\nQuickScan is invoked as follows:\n\n  QuickScan CONSENV CODEREF, FILENAME [, PATH]\n\nThe subroutine referenced by CODEREF is expected to return a list of\nfilenames included directly by FILE. These filenames will, in turn, be\nscanned. The optional PATH argument supplies a lookup path for finding\nFILENAME and/or files returned by the user-supplied subroutine.  The PATH\nmay be a reference to an array of lookup-directory names, or a string of\nnames separated by the system's separator character (':' on UNIX systems,\n';' on Windows NT).\n\nThe subroutine is called once for each line in the file, with $_ set to the\ncurrent line. If the subroutine needs to look at additional lines, or, for\nthat matter, the entire file, then it may read them itself, from the\nfilehandle SCAN. It may also terminate the loop, if it knows that no further\ninclude information is available, by closing the filehandle.\n\nWhether or not a lookup path is provided, QuickScan first tries to lookup\nthe file relative to the current directory (for the top-level file\nsupplied directly to QuickScan), or from the directory containing the\nfile which referenced the file. This is not very general, but seems good\nenough--especially if you have the luxury of writing your own utilities\nand can control the use of the search path in a standard way.\n\nHere's a real example, taken from a F<Construct> file here:\n\n  sub cons::SMFgen {\n      my($env, @tables) = @_;\n      foreach $t (@tables) {\n\t  $env->QuickScan(sub { /\\b\\S*?\\.smf\\b/g }, \"$t.smf\",\n\t\t\t  $env->{SMF_INCLUDE_PATH});\n\t  $env->Command([\"$t.smdb.cc\",\"$t.smdb.h\",\"$t.snmp.cc\",\n\t\t\t \"$t.ami.cc\", \"$t.http.cc\"], \"$t.smf\",\n\t\t\tq(smfgen %( %SMF_INCLUDE_OPT %) %<));\n      }\n  }\n\nThe subroutine above finds all names of the form <name>.smf in the\nfile. It will return the names even if they're found within comments,\nbut that's OK (the mechanism is forgiving of extra files; they're just\nignored on the assumption that the missing file will be noticed when\nthe program, in this example, smfgen, is actually invoked).\n\n[NOTE that the form C<$env-E<gt>QuickScan ...>  and C<$env-E<gt>Command\n...> should not be necessary, but, for some reason, is required\nfor this particular invocation. This appears to be a bug in Perl or\na misunderstanding on my part; this invocation style does not always\nappear to be necessary.]\n\nHere is another way to build the same scanner. This one uses an\nexplicit code reference, and also (unnecessarily, in this case) reads\nthe whole file itself:\n\n  sub myscan {\n      my(@includes);\n      do {\n\t  push(@includes, /\\b\\S*?\\.smf\\b/g);\n      } while <SCAN>;\n      @includes\n  }\n\nNote that the order of the loop is reversed, with the loop test at the\nend. This is because the first line is already read for you. This scanner\ncan be attached to a source file by:\n\n  QuickScan $env \\&myscan, \"$_.smf\";\n\nThis final example, which scans a different type of input file, takes\nover the file scanning rather than being called for each input line:\n\n  $env->QuickScan(\n      sub { my(@includes) = ();\n\t  do {\n\t     push(@includes, $3)\n\t\t if /^(#include|import)\\s+(\\\")(.+)(\\\")/ && $3\n\t  } while <SCAN>;\n\t  @includes\n      },\n      \"$idlFileName\",\n      \"$env->{CPPPATH};$BUILD/ActiveContext/ACSCLientInterfaces\"\n  );\n\n=head1 SUPPORT AND SUGGESTIONS\n\nCons is maintained by the user community.  To subscribe, send mail to\nB<cons-discuss-request@gnu.org> with body B<subscribe>.\n\nPlease report any suggestions through the B<cons-discuss@gnu.org> mailing\nlist.\n\n=head1 BUGS\n\nSure to be some. Please report any bugs through the B<bug-cons@gnu.org>\nmailing list.\n\n=head1 INFORMATION ABOUT CONS\n\nInformation about CONS can be obtained from the official cons web site\nB<http://www.dsmit.com/cons/> or its mirrors listed there.\n\nThe cons maintainers can be contacted by email at\nB<cons-maintainers@gnu.org>\n\n=head1 AUTHORS\n\nOriginally by Bob Sidebotham. Then significantly enriched by the members\nof the Cons community B<cons-discuss@gnu.org>.\n\nThe Cons community would like to thank Ulrich Pfeifer for the original pod\ndocumentation derived from the F<cons.html> file. Cons documentation is now\na part of the program itself.\n\n=cut\n"
  },
  {
    "path": "code/unix/extract_ver.pl",
    "content": "#!/usr/bin/env perl\n# extracting version string from game/q_shared.h\n# hacked from Wolf build process\n\n# extract the wolf version from q_shared.h\n$line = `cat ../game/q_shared.h | grep Q3_VERSION`;\nchomp $line;\n$line =~ s/.*Q3\\ (.*)\\\"/$1/;\nprint \"$line\\n\";\n"
  },
  {
    "path": "code/unix/ftol.nasm",
    "content": ";===========================================================================\n;Copyright (C) 1999-2005 Id Software, Inc.\n;\n;This file is part of Quake III Arena source code.\n;\n;Quake III Arena source code is free software; you can redistribute it\n;and/or modify it under the terms of the GNU General Public License as\n;published by the Free Software Foundation; either version 2 of the License,\n;or (at your option) any later version.\n;\n;Quake III Arena source code is distributed in the hope that it will be\n;useful, but WITHOUT ANY WARRANTY; without even the implied warranty of\n;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n;GNU General Public License for more details.\n;\n;You should have received a copy of the GNU General Public License\n;along with Foobar; if not, write to the Free Software\n;Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n;===========================================================================\n\n;\n; qftol -- fast floating point to long conversion.\n;\n\nsegment .data\n\ntemp    dd 0.0\nfpucw   dd 0\n\n; Precision Control Field , 2 bits / 0x0300 \n; PC24 0x0000   Single precision (24 bits). \n; PC53 0x0200   Double precision (53 bits). \n; PC64 0x0300   Extended precision (64 bits).\n\n; Rounding Control Field, 2 bits / 0x0C00\n; RCN  0x0000   Rounding to nearest (even). \n; RCD  0x0400   Rounding down (directed, minus). \n; RCU  0x0800   Rounding up (directed plus).\n; RC0  0x0C00   Rounding towards zero (chop mode).\n\n\n; rounding towards nearest (even)\ncw027F  dd 0x027F ; double precision\ncw037F  dd 0x037F ; extended precision\n\n; rounding towards zero (chop mode)\ncw0E7F  dd 0x0E7F ; double precision\ncw0F7F  dd 0x0F7F ; extended precision\n\n\nsegment .text\n\n;\n; int qftol( void ) - default control word\n;\n\nglobal qftol\n\nqftol: \n        fistp dword [temp]\n        mov eax, [temp]\n        ret\n\n\n;\n; int qftol027F( void ) - DirectX FPU \n;\n\nglobal qftol027F\n\nqftol027F:\n\tfnstcw [fpucw]\n\tfldcw  [cw027F]  \n        fistp dword [temp]\n\tfldcw  [fpucw]\n        mov eax, [temp]\n        ret\n\n;\n; int qftol037F( void ) - Linux FPU \n;\n\nglobal qftol037F\n\nqftol037F:\n\tfnstcw [fpucw]\n\tfldcw  [cw037F]  \n        fistp dword [temp]\n\tfldcw  [fpucw]\n        mov eax, [temp]\n        ret\n\n\n;\n; int qftol0F7F( void ) - ANSI\n;\n\nglobal qftol0F7F\n\nqftol0F7F:\n\tfnstcw [fpucw]\n\tfldcw  [cw0F7F]  \n        fistp dword [temp]\n\tfldcw  [fpucw]\n        mov eax, [temp]\n        ret\n\n;\n; int qftol0E7F( void ) \n;\n\nglobal qftol0E7F\n\nqftol0E7F:\n\tfnstcw [fpucw]\n\tfldcw  [cw0E7F]  \n        fistp dword [temp]\n\tfldcw  [fpucw]\n        mov eax, [temp]\n        ret\n\n\n\n;\n; long Q_ftol( float q )\n;\n\nglobal Q_ftol\n\nQ_ftol:\n        fld dword [esp+4]  \n        fistp dword [temp]\n        mov eax, [temp]\n        ret\n\n\n;\n; long qftol0F7F( float q ) - Linux FPU \n;\n\nglobal Q_ftol0F7F\n\nQ_ftol0F7F:\n\tfnstcw [fpucw]\n\tfld dword [esp+4]  \n\tfldcw  [cw0F7F]  \n        fistp dword [temp]\n\tfldcw  [fpucw]\n        mov eax, [temp]\n        ret\n\n"
  },
  {
    "path": "code/unix/linux_common.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n/** \n * GAS syntax equivalents of the MSVC asm memory calls in common.c\n *\n * The following changes have been made to the asm:\n * 1. Registers are loaded by the inline asm arguments when possible\n * 2. Labels have been changed to local label format (0,1,etc.) to allow inlining\n *\n * HISTORY:\n *\tAH - Created on 08 Dec 2000\n */\n\n#include <unistd.h>   // AH - for size_t\n#include <string.h>\n\n// bk001207 - we need something under Linux, too. Mac?\n#if 1 // defined(C_ONLY) // bk010102 - dedicated?\nvoid Com_Memcpy (void* dest, const void* src, const size_t count) {\n  memcpy(dest, src, count);\n}\n\nvoid Com_Memset (void* dest, const int val, const size_t count) {\n  memset(dest, val, count);\n}\n\n#else\n\ntypedef enum {\n  PRE_READ,         // prefetch assuming that buffer is used for reading only\n  PRE_WRITE,        // prefetch assuming that buffer is used for writing only\n  PRE_READ_WRITE    // prefetch assuming that buffer is used for both reading and writing\n} e_prefetch;\n\nvoid Com_Prefetch (const void *s, const unsigned int bytes, e_prefetch type);\n\nvoid _copyDWord (unsigned int* dest, const unsigned int constant, const unsigned int count) {\n\t// MMX version not used on standard Pentium MMX\n\t// because the dword version is faster (with\n\t// proper destination prefetching)\n\t\t__asm__ __volatile__ (\" \\\n\t\t\t//mov\t\t\teax,constant\t\t// eax = val \\\n\t\t\t//mov\t\t\tedx,dest\t\t\t// dest \\\n\t\t\t//mov\t\t\tecx,count \\\n\t\t\tmovd\t\t%%eax, %%mm0 \\\n\t\t\tpunpckldq\t%%mm0, %%mm0 \\\n\\\n\t\t\t// ensure that destination is qword aligned \\\n\\\n\t\t\ttestl\t\t$7, %%edx\t\t\t\t// qword padding?\\\n\t\t\tjz\t\t0f\t\\\n\t\t\tmovl\t\t%%eax, (%%edx) \\\n\t\t\tdecl\t\t%%ecx \\\n\t\t\taddl\t\t$4, %%edx \\\n\\\n0:\t\t\tmovl\t\t%%ecx, %%ebx\t\t\t\t\\\n\t\t\tandl\t\t$0xfffffff0, %%ecx\t\\\n\t\t\tjz\t\t2f \\\n\t\t\tjmp\t\t1f \\\n\t\t\t.align \t\t16 \\\n\\\n\t\t\t// funny ordering here to avoid commands \\\n\t\t\t// that cross 32-byte boundaries (the \\\n\t\t\t// [edx+0] version has a special 3-byte opcode... \\\n1:\t\t\tmovq\t\t%%mm0, 8(%%edx) \\\n\t\t\tmovq\t\t%%mm0, 16(%%edx) \\\n\t\t\tmovq\t\t%%mm0, 24(%%edx) \\\n\t\t\tmovq\t\t%%mm0, 32(%%edx) \\\n\t\t\tmovq\t\t%%mm0, 40(%%edx) \\\n\t\t\tmovq\t\t%%mm0, 48(%%edx) \\\n\t\t\tmovq\t\t%%mm0, 56(%%edx) \\\n\t\t\tmovq\t\t%%mm0, (%%edx)\\\n\t\t\taddl\t\t$64, %%edx \\\n\t\t\tsubl\t\t$16, %%ecx \\\n\t\t\tjnz\t\t1b \\\n2:\t\\\n\t\t\tmovl\t\t%%ebx, %%ecx\t\t\t\t// ebx = cnt \\\n\t\t\tandl\t\t$0xfffffff0, %%ecx\t\t\t\t// ecx = cnt&~15 \\\n\t\t\tsubl\t\t%%ecx, %%ebx \\\n\t\t\tjz\t\t6f \\\n\t\t\tcmpl\t\t$8, %%ebx \\\n\t\t\tjl\t\t3f \\\n\\\n\t\t\tmovq\t\t%%mm0, (%%edx) \\\n\t\t\tmovq\t\t%%mm0, 8(%%edx) \\\n\t\t\tmovq\t\t%%mm0, 16(%%edx) \\\n\t\t\tmovq\t\t%%mm0, 24(%%edx) \\\n\t\t\taddl\t\t$32, %%edx \\\n\t\t\tsubl\t\t$8, %%ebx \\\n\t\t\tjz\t\t6f \\\n\\\n3:\t\t\tcmpl\t\t$4, %%ebx \\\n\t\t\tjl\t\t4f \\\n\t\t\t\\\n\t\t\tmovq\t\t%%mm0, (%%edx) \\\n\t\t\tmovq\t\t%%mm0, 8(%%edx) \\\n\t\t\taddl\t\t$16, %%edx \\\n\t\t\tsubl\t\t$4, %%ebx \\\n\\\n4:\t\t\tcmpl\t\t$2, %%ebx \\\n\t\t\tjl\t\t5f \\\n\t\t\tmovq\t\t%%mm0, (%%edx) \\\n\t\t\taddl\t\t$8, %%edx \\\n\t\t\tsubl\t\t$2, %%ebx \\\n\\\n5:\t\t\tcmpl\t\t$1, %%ebx \\\n\t\t\tjl\t\t6f \\\n\t\t\tmovl\t\t%%eax, (%%edx) \\\n6: \\\n\t\t\temms \\\n\t\"\n\t: : \"a\" (constant), \"c\" (count), \"d\" (dest)\n\t: \"%ebx\", \"%edi\", \"%esi\", \"cc\", \"memory\");\n}\n\n// optimized memory copy routine that handles all alignment\n// cases and block sizes efficiently\nvoid Com_Memcpy (void* dest, const void* src, const size_t count) {\n\tCom_Prefetch (src, count, PRE_READ);\n\t__asm__ __volatile__ (\" \\\n\t\tpushl\t\t%%edi \\\n\t\tpushl\t\t%%esi \\\n\t\t//mov\t\tecx,count \\\n\t\tcmpl\t\t$0, %%ecx\t\t\t\t\t\t// count = 0 check (just to be on the safe side) \\\n\t\tje\t\t6f \\\n\t\t//mov\t\tedx,dest \\\n\t\tmovl\t\t%0, %%ebx \\\n\t\tcmpl\t\t$32, %%ecx\t\t\t\t\t\t// padding only? \\\n\t\tjl\t\t1f \\\n\\\n\t\tmovl\t\t%%ecx, %%edi\t\t\t\t\t\\\n\t\tandl\t\t$0xfffffe00, %%edi\t\t\t\t\t// edi = count&~31 \\\n\t\tsubl\t\t$32, %%edi \\\n\\\n\t\t.align 16 \\\n0: \\\n\t\tmovl\t\t(%%ebx, %%edi, 1), %%eax \\\n\t\tmovl\t\t4(%%ebx, %%edi, 1), %%esi \\\n\t\tmovl\t\t%%eax, (%%edx, %%edi, 1) \\\n\t\tmovl\t\t%%esi, 4(%%edx, %%edi, 1) \\\n\t\tmovl\t\t8(%%ebx, %%edi, 1), %%eax \\\n\t\tmovl\t\t12(%%ebx, %%edi, 1), %%esi \\\n\t\tmovl\t\t%%eax, 8(%%edx, %%edi, 1) \\\n\t\tmovl\t\t%%esi, 12(%%edx, %%edi, 1) \\\n\t\tmovl\t\t16(%%ebx, %%edi, 1), %%eax \\\n\t\tmovl\t\t20(%%ebx, %%edi, 1), %%esi \\\n\t\tmovl\t\t%%eax, 16(%%edx, %%edi, 1) \\\n\t\tmovl\t\t%%esi, 20(%%edx, %%edi, 1) \\\n\t\tmovl\t\t24(%%ebx, %%edi, 1), %%eax \\\n\t\tmovl\t\t28(%%ebx, %%edi, 1), %%esi \\\n\t\tmovl\t\t%%eax, 24(%%edx, %%edi, 1) \\\n\t\tmovl\t\t%%esi, 28(%%edx, %%edi, 1) \\\n\t\tsubl\t\t$32, %%edi \\\n\t\tjge\t\t0b \\\n\t\t\\\n\t\tmovl\t\t%%ecx, %%edi \\\n\t\tandl\t\t$0xfffffe00, %%edi \\\n\t\taddl\t\t%%edi, %%ebx\t\t\t\t\t// increase src pointer \\\n\t\taddl\t\t%%edi, %%edx\t\t\t\t\t// increase dst pointer \\\n\t\tandl\t\t$31, %%ecx\t\t\t\t\t// new count \\\n\t\tjz\t\t6f\t\t\t\t\t// if count = 0, get outta here \\\n\\\n1: \\\n\t\tcmpl\t\t$16, %%ecx \\\n\t\tjl\t\t2f \\\n\t\tmovl\t\t(%%ebx), %%eax \\\n\t\tmovl\t\t%%eax, (%%edx) \\\n\t\tmovl\t\t4(%%ebx), %%eax \\\n\t\tmovl\t\t%%eax, 4(%%edx) \\\n\t\tmovl\t\t8(%%ebx), %%eax \\\n\t\tmovl\t\t%%eax, 8(%%edx) \\\n\t\tmovl\t\t12(%%ebx), %%eax \\\n\t\tmovl\t\t%%eax, 12(%%edx) \\\n\t\tsubl\t\t$16, %%ecx \\\n\t\taddl\t\t$16, %%ebx \\\n\t\taddl\t\t$16, %%edx \\\n2: \\\n\t\tcmpl\t\t$8, %%ecx \\\n\t\tjl\t\t3f \\\n\t\tmovl\t\t(%%ebx), %%eax \\\n\t\tmovl\t\t%%eax, (%%edx) \\\n\t\tmovl\t\t4(%%ebx), %%eax \\\n\t\tsubl\t\t$8, %%ecx \\\n\t\tmovl\t\t%%eax, 4(%%edx) \\\n\t\taddl\t\t$8, %%ebx \\\n\t\taddl\t\t$8, %%edx \\\n3: \\\n\t\tcmpl\t\t$4, %%ecx \\\n\t\tjl\t\t4f \\\n\t\tmovl\t\t(%%ebx), %%eax\t// here 4-7 bytes \\\n\t\taddl\t\t$4, %%ebx \\\n\t\tsubl\t\t$4, %%ecx \\\n\t\tmovl\t\t%%eax, (%%edx) \\\n\t\taddl\t\t$4, %%edx \\\n4:\t\t\t\t\t\t\t// 0-3 remaining bytes \\\n\t\tcmpl\t\t$2, %%ecx \\\n\t\tjl\t\t5f \\\n\t\tmovw\t\t(%%ebx), %%ax\t// two bytes \\\n\t\tcmpl\t\t$3, %%ecx\t\t\t\t// less than 3? \\\n\t\tmovw\t\t%%ax, (%%edx) \\\n\t\tjl\t\t6f \\\n\t\tmovb\t\t2(%%ebx), %%al\t// last byte \\\n\t\tmovb\t\t%%al, 2(%%edx) \\\n\t\tjmp\t\t6f \\\n5: \\\n\t\tcmpl\t\t$1, %%ecx \\\n\t\tjl\t\t6f \\\n\t\tmovb\t\t(%%ebx), %%al \\\n\t\tmovb\t\t%%al, (%%edx) \\\n6: \\\n\t\tpopl\t\t%%esi \\\n\t\tpopl\t\t%%edi \\\n\t\"\n\t: : \"m\" (src), \"d\" (dest), \"c\" (count)\n\t: \"%eax\", \"%ebx\", \"%edi\", \"%esi\", \"cc\", \"memory\");\n}\n\nvoid Com_Memset (void* dest, const int val, const size_t count)\n{\n\tunsigned int fillval;\n\n\tif (count < 8)\n\t{\n\t\t__asm__ __volatile__ (\" \\\n\t\t\t//mov\t\tedx,dest \\\n\t\t\t//mov\t\teax, val \\\n\t\t\tmovb\t\t%%al, %%ah \\\n\t\t\tmovl\t\t%%eax, %%ebx \\\n\t\t\tandl\t\t$0xffff, %%ebx \\\n\t\t\tshll\t\t$16, %%eax \\\n\t\t\taddl\t\t%%ebx, %%eax\t// eax now contains pattern \\\n\t\t\t//mov\t\tecx,count \\\n\t\t\tcmpl\t\t$4, %%ecx \\\n\t\t\tjl\t\t0f \\\n\t\t\tmovl\t\t%%eax, (%%edx)\t// copy first dword \\\n\t\t\taddl\t\t$4, %%edx \\\n\t\t\tsubl\t\t$4, %%ecx \\\n\t0:\t\tcmpl\t\t$2, %%ecx \\\n\t\t\tjl\t\t1f \\\n\t\t\tmovw\t\t%%ax, (%%edx)\t// copy 2 bytes \\\n\t\t\taddl\t\t$2, %%edx \\\n\t\t\tsubl\t\t$2, %%ecx \\\n\t1:\t\tcmpl\t\t$0, %%ecx \\\n\t\t\tje\t\t2f \\\n\t\t\tmovb\t\t%%al, (%%edx)\t// copy single byte \\\n\t2:\t\t \\\n\t\t\"\n\t\t: : \"d\" (dest), \"a\" (val), \"c\" (count)\n\t\t: \"%ebx\", \"%edi\", \"%esi\", \"cc\", \"memory\");\n\t\t\n\t\treturn;\n\t}\n\n\tfillval = val;\n\t\n\tfillval = fillval|(fillval<<8);\n\tfillval = fillval|(fillval<<16);\t\t// fill dword with 8-bit pattern\n\n\t_copyDWord ((unsigned int*)(dest),fillval, count/4);\n\t\n\t__asm__ __volatile__ (\"     \t\t// padding of 0-3 bytes \\\n\t\t//mov\t\tecx,count \\\n\t\tmovl\t\t%%ecx, %%eax \\\n\t\tandl\t\t$3, %%ecx \\\n\t\tjz\t\t1f \\\n\t\tandl\t\t$0xffffff00, %%eax \\\n\t\t//mov\t\tebx,dest \\\n\t\taddl\t\t%%eax, %%edx \\\n\t\tmovl\t\t%0, %%eax \\\n\t\tcmpl\t\t$2, %%ecx \\\n\t\tjl\t\t0f \\\n\t\tmovw\t\t%%ax, (%%edx) \\\n\t\tcmpl\t\t$2, %%ecx \\\n\t\tje\t\t1f\t\t\t\t\t\\\n\t\tmovb\t\t%%al, 2(%%edx)\t\t\\\n\t\tjmp\t\t1f \\\n0:\t\t\\\n\t\tcmpl\t\t$0, %%ecx\\\n\t\tje\t\t1f\\\n\t\tmovb\t\t%%al, (%%edx)\\\n1:\t\\\n\t\"\n\t: : \"m\" (fillval), \"c\" (count), \"d\" (dest)\n\t: \"%eax\", \"%ebx\", \"%edi\", \"%esi\", \"cc\", \"memory\");\t\n}\n\nvoid Com_Prefetch (const void *s, const unsigned int bytes, e_prefetch type)\n{\n\t// write buffer prefetching is performed only if\n\t// the processor benefits from it. Read and read/write\n\t// prefetching is always performed.\n\n\tswitch (type)\n\t{\n\t\tcase PRE_WRITE : break;\n\t\tcase PRE_READ:\n\t\tcase PRE_READ_WRITE:\n\n\t\t__asm__ __volatile__ (\"\\\n\t\t\t//mov\t\tebx,s\\\n\t\t\t//mov\t\tecx,bytes\\\n\t\t\tcmpl\t\t$4096, %%ecx\t\t\t\t// clamp to 4kB\\\n\t\t\tjle\t\t0f\\\n\t\t\tmovl\t\t$4096, %%ecx\\\n\t0:\\\n\t\t\taddl\t\t$0x1f, %%ecx\\\n\t\t\tshrl\t\t$5, %%ecx\t\t\t\t\t// number of cache lines\\\n\t\t\tjz\t\t2f\\\n\t\t\tjmp\t\t1f\\\n\\\n\t\t\t.align 16\\\n\t1:\t\ttestb\t\t%%al, (%%edx)\\\n\t\t\taddl\t\t$32, %%edx\\\n\t\t\tdecl\t\t%%ecx\\\n\t\t\tjnz\t\t1b\\\n\t2:\\\n\t\t\"\n\t\t: : \"d\" (s), \"c\" (bytes)\n\t\t: \"%eax\", \"%ebx\", \"%edi\", \"%esi\", \"memory\", \"cc\");\n\t\t\n\t\tbreak;\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "code/unix/linux_glimp.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n/*\n** GLW_IMP.C\n**\n** This file contains ALL Linux specific stuff having to do with the\n** OpenGL refresh.  When a port is being made the following functions\n** must be implemented by the port:\n**\n** GLimp_EndFrame\n** GLimp_Init\n** GLimp_Shutdown\n** GLimp_SwitchFullscreen\n** GLimp_SetGamma\n**\n*/\n\n#include <termios.h>\n#include <sys/ioctl.h>\n#ifdef __linux__\n  #include <sys/stat.h>\n  #include <sys/vt.h>\n#endif\n#include <stdarg.h>\n#include <stdio.h>\n#include <signal.h>\n#include <pthread.h>\n#include <semaphore.h>\n\n// bk001204\n#include <dlfcn.h>\n\n// bk001206 - from my Heretic2 by way of Ryan's Fakk2\n// Needed for the new X11_PendingInput() function.\n#include <sys/time.h>\n#include <sys/types.h>\n#include <unistd.h>\n\n#include \"../renderer/tr_local.h\"\n#include \"../client/client.h\"\n#include \"linux_local.h\" // bk001130\n\n#include \"unix_glw.h\"\n\n#include <GL/glx.h>\n\n#include <X11/keysym.h>\n#include <X11/cursorfont.h>\n\n#include <X11/extensions/xf86dga.h>\n#include <X11/extensions/xf86vmode.h>\n\n#define\tWINDOW_CLASS_NAME\t\"Quake III: Arena\"\n\ntypedef enum\n{\n  RSERR_OK,\n\n  RSERR_INVALID_FULLSCREEN,\n  RSERR_INVALID_MODE,\n\n  RSERR_UNKNOWN\n} rserr_t;\n\nglwstate_t glw_state;\n\nstatic Display *dpy = NULL;\nstatic int scrnum;\nstatic Window win = 0;\nstatic GLXContext ctx = NULL;\n\n// bk001206 - not needed anymore\n// static qboolean autorepeaton = qtrue;\n\n#define KEY_MASK (KeyPressMask | KeyReleaseMask)\n#define MOUSE_MASK (ButtonPressMask | ButtonReleaseMask | \\\n\t\t    PointerMotionMask | ButtonMotionMask )\n#define X_MASK (KEY_MASK | MOUSE_MASK | VisibilityChangeMask | StructureNotifyMask )\n\nstatic qboolean mouse_avail;\nstatic qboolean mouse_active = qfalse;\nstatic int mwx, mwy;\nstatic int mx = 0, my = 0;\n\n// Time mouse was reset, we ignore the first 50ms of the mouse to allow settling of events\nstatic int mouseResetTime = 0;\n#define MOUSE_RESET_DELAY 50\n\nstatic cvar_t *in_mouse;\nstatic cvar_t *in_dgamouse; // user pref for dga mouse\ncvar_t *in_subframe;\ncvar_t *in_nograb; // this is strictly for developers\n\n// bk001130 - from cvs1.17 (mkv), but not static\ncvar_t   *in_joystick      = NULL;\ncvar_t   *in_joystickDebug = NULL;\ncvar_t   *joy_threshold    = NULL;\n\ncvar_t  *r_allowSoftwareGL;   // don't abort out if the pixelformat claims software\ncvar_t  *r_previousglDriver;\n\nqboolean vidmode_ext = qfalse;\nstatic int vidmode_MajorVersion = 0, vidmode_MinorVersion = 0; // major and minor of XF86VidExtensions\n\n// gamma value of the X display before we start playing with it\nstatic XF86VidModeGamma vidmode_InitialGamma;\n\nstatic int win_x, win_y;\n\nstatic XF86VidModeModeInfo **vidmodes;\n//static int default_dotclock_vidmode; // bk001204 - unused\nstatic int num_vidmodes;\nstatic qboolean vidmode_active = qfalse;\n\nstatic int mouse_accel_numerator;\nstatic int mouse_accel_denominator;\nstatic int mouse_threshold;    \n\n/*\n* Find the first occurrence of find in s.\n*/\n// bk001130 - from cvs1.17 (mkv), const\n// bk001130 - made first argument const\nstatic const char *Q_stristr( const char *s, const char *find)\n{\n  register char c, sc;\n  register size_t len;\n\n  if ((c = *find++) != 0)\n  {\n    if (c >= 'a' && c <= 'z')\n    {\n      c -= ('a' - 'A');\n    }\n    len = strlen(find);\n    do\n    {\n      do\n      {\n        if ((sc = *s++) == 0)\n          return NULL;\n        if (sc >= 'a' && sc <= 'z')\n        {\n          sc -= ('a' - 'A');\n        }\n      } while (sc != c);\n    } while (Q_stricmpn(s, find, len) != 0);\n    s--;\n  }\n  return s;\n}\n\n/*****************************************************************************\n** KEYBOARD\n** NOTE TTimo the keyboard handling is done with KeySyms\n**   that means relying on the keyboard mapping provided by X\n**   in-game it would probably be better to use KeyCode (i.e. hardware key codes)\n**   you would still need the KeySyms in some cases, such as for the console and all entry textboxes\n**     (cause there's nothing worse than a qwerty mapping on a french keyboard)\n**\n** you can turn on some debugging and verbose of the keyboard code with #define KBD_DBG\n******************************************************************************/\n\n//#define KBD_DBG\n\nstatic char *XLateKey(XKeyEvent *ev, int *key)\n{\n  static char buf[64];\n  KeySym keysym;\n  int XLookupRet;\n\n  *key = 0;\n\n  XLookupRet = XLookupString(ev, buf, sizeof buf, &keysym, 0);\n#ifdef KBD_DBG\n  ri.Printf(PRINT_ALL, \"XLookupString ret: %d buf: %s keysym: %x\\n\", XLookupRet, buf, keysym);\n#endif\n  \n  switch (keysym)\n  {\n  case XK_KP_Page_Up: \n  case XK_KP_9:  *key = K_KP_PGUP; break;\n  case XK_Page_Up:   *key = K_PGUP; break;\n\n  case XK_KP_Page_Down: \n  case XK_KP_3: *key = K_KP_PGDN; break;\n  case XK_Page_Down:   *key = K_PGDN; break;\n\n  case XK_KP_Home: *key = K_KP_HOME; break;\n  case XK_KP_7: *key = K_KP_HOME; break;\n  case XK_Home:  *key = K_HOME; break;\n\n  case XK_KP_End:\n  case XK_KP_1:   *key = K_KP_END; break;\n  case XK_End:   *key = K_END; break;\n\n  case XK_KP_Left: *key = K_KP_LEFTARROW; break;\n  case XK_KP_4: *key = K_KP_LEFTARROW; break;\n  case XK_Left:  *key = K_LEFTARROW; break;\n\n  case XK_KP_Right: *key = K_KP_RIGHTARROW; break;\n  case XK_KP_6: *key = K_KP_RIGHTARROW; break;\n  case XK_Right:  *key = K_RIGHTARROW;    break;\n\n  case XK_KP_Down:\n  case XK_KP_2:    *key = K_KP_DOWNARROW; break;\n  case XK_Down:  *key = K_DOWNARROW; break;\n\n  case XK_KP_Up:   \n  case XK_KP_8:    *key = K_KP_UPARROW; break;\n  case XK_Up:    *key = K_UPARROW;   break;\n\n  case XK_Escape: *key = K_ESCAPE;    break;\n\n  case XK_KP_Enter: *key = K_KP_ENTER;  break;\n  case XK_Return: *key = K_ENTER;    break;\n\n  case XK_Tab:    *key = K_TAB;      break;\n\n  case XK_F1:    *key = K_F1;       break;\n\n  case XK_F2:    *key = K_F2;       break;\n\n  case XK_F3:    *key = K_F3;       break;\n\n  case XK_F4:    *key = K_F4;       break;\n\n  case XK_F5:    *key = K_F5;       break;\n\n  case XK_F6:    *key = K_F6;       break;\n\n  case XK_F7:    *key = K_F7;       break;\n\n  case XK_F8:    *key = K_F8;       break;\n\n  case XK_F9:    *key = K_F9;       break;\n\n  case XK_F10:    *key = K_F10;      break;\n\n  case XK_F11:    *key = K_F11;      break;\n\n  case XK_F12:    *key = K_F12;      break;\n\n    // bk001206 - from Ryan's Fakk2 \n    //case XK_BackSpace: *key = 8; break; // ctrl-h\n  case XK_BackSpace: *key = K_BACKSPACE; break; // ctrl-h\n\n  case XK_KP_Delete:\n  case XK_KP_Decimal: *key = K_KP_DEL; break;\n  case XK_Delete: *key = K_DEL; break;\n\n  case XK_Pause:  *key = K_PAUSE;    break;\n\n  case XK_Shift_L:\n  case XK_Shift_R:  *key = K_SHIFT;   break;\n\n  case XK_Execute: \n  case XK_Control_L: \n  case XK_Control_R:  *key = K_CTRL;  break;\n\n  case XK_Alt_L:  \n  case XK_Meta_L: \n  case XK_Alt_R:  \n  case XK_Meta_R: *key = K_ALT;     break;\n\n  case XK_KP_Begin: *key = K_KP_5;  break;\n\n  case XK_Insert:   *key = K_INS; break;\n  case XK_KP_Insert:\n  case XK_KP_0: *key = K_KP_INS; break;\n\n  case XK_KP_Multiply: *key = '*'; break;\n  case XK_KP_Add:  *key = K_KP_PLUS; break;\n  case XK_KP_Subtract: *key = K_KP_MINUS; break;\n  case XK_KP_Divide: *key = K_KP_SLASH; break;\n\n    // bk001130 - from cvs1.17 (mkv)\n  case XK_exclam: *key = '1'; break;\n  case XK_at: *key = '2'; break;\n  case XK_numbersign: *key = '3'; break;\n  case XK_dollar: *key = '4'; break;\n  case XK_percent: *key = '5'; break;\n  case XK_asciicircum: *key = '6'; break;\n  case XK_ampersand: *key = '7'; break;\n  case XK_asterisk: *key = '8'; break;\n  case XK_parenleft: *key = '9'; break;\n  case XK_parenright: *key = '0'; break;\n  \n  // weird french keyboards ..\n  // NOTE: console toggle is hardcoded in cl_keys.c, can't be unbound\n  //   cleaner would be .. using hardware key codes instead of the key syms\n  //   could also add a new K_KP_CONSOLE\n  case XK_twosuperior: *key = '~'; break;\n\t\t\n\t// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=472\n\tcase XK_space:\n\tcase XK_KP_Space: *key = K_SPACE; break;\n\n  default:\n    if (XLookupRet == 0)\n    {\n      if (com_developer->value)\n      {\n        ri.Printf(PRINT_ALL, \"Warning: XLookupString failed on KeySym %d\\n\", keysym);\n      }\n      return NULL;\n    }\n    else\n    {\n      // XK_* tests failed, but XLookupString got a buffer, so let's try it\n      *key = *(unsigned char *)buf;\n      if (*key >= 'A' && *key <= 'Z')\n        *key = *key - 'A' + 'a';\n      // if ctrl is pressed, the keys are not between 'A' and 'Z', for instance ctrl-z == 26 ^Z ^C etc.\n      // see https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=19\n      else if (*key >= 1 && *key <= 26)\n     \t  *key = *key + 'a' - 1;\n    }\n    break;\n  } \n\n  return buf;\n}\n\n// ========================================================================\n// makes a null cursor\n// ========================================================================\n\nstatic Cursor CreateNullCursor(Display *display, Window root)\n{\n  Pixmap cursormask; \n  XGCValues xgc;\n  GC gc;\n  XColor dummycolour;\n  Cursor cursor;\n\n  cursormask = XCreatePixmap(display, root, 1, 1, 1/*depth*/);\n  xgc.function = GXclear;\n  gc =  XCreateGC(display, cursormask, GCFunction, &xgc);\n  XFillRectangle(display, cursormask, gc, 0, 0, 1, 1);\n  dummycolour.pixel = 0;\n  dummycolour.red = 0;\n  dummycolour.flags = 04;\n  cursor = XCreatePixmapCursor(display, cursormask, cursormask,\n                               &dummycolour,&dummycolour, 0,0);\n  XFreePixmap(display,cursormask);\n  XFreeGC(display,gc);\n  return cursor;\n}\n\nstatic void install_grabs(void)\n{\n  // inviso cursor\n  XWarpPointer(dpy, None, win,\n               0, 0, 0, 0,\n               glConfig.vidWidth / 2, glConfig.vidHeight / 2);\n  XSync(dpy, False);\n\n  XDefineCursor(dpy, win, CreateNullCursor(dpy, win));\n\n  XGrabPointer(dpy, win, // bk010108 - do this earlier?\n               False,\n               MOUSE_MASK,\n               GrabModeAsync, GrabModeAsync,\n               win,\n               None,\n               CurrentTime);\n\n  XGetPointerControl(dpy, &mouse_accel_numerator, &mouse_accel_denominator,\n                     &mouse_threshold);\n\n  XChangePointerControl(dpy, True, True, 1, 1, 0);\n\n  XSync(dpy, False);\n\n  mouseResetTime = Sys_Milliseconds ();\n\n  if (in_dgamouse->value)\n  {\n    int MajorVersion, MinorVersion;\n\n    if (!XF86DGAQueryVersion(dpy, &MajorVersion, &MinorVersion))\n    {\n      // unable to query, probalby not supported, force the setting to 0\n      ri.Printf( PRINT_ALL, \"Failed to detect XF86DGA Mouse\\n\" );\n      ri.Cvar_Set( \"in_dgamouse\", \"0\" );\n    } else\n    {\n      XF86DGADirectVideo(dpy, DefaultScreen(dpy), XF86DGADirectMouse);\n      XWarpPointer(dpy, None, win, 0, 0, 0, 0, 0, 0);\n    }\n  } else\n  {\n    mwx = glConfig.vidWidth / 2;\n    mwy = glConfig.vidHeight / 2;\n    mx = my = 0;\n  }\n\n  XGrabKeyboard(dpy, win,\n                False,\n                GrabModeAsync, GrabModeAsync,\n                CurrentTime);\n\n  XSync(dpy, False);\n}\n\nstatic void uninstall_grabs(void)\n{\n  if (in_dgamouse->value)\n  {\n\t\tif (com_developer->value)\n\t\t\tri.Printf( PRINT_ALL, \"DGA Mouse - Disabling DGA DirectVideo\\n\" );\n    XF86DGADirectVideo(dpy, DefaultScreen(dpy), 0);\n  }\n\n  XChangePointerControl(dpy, qtrue, qtrue, mouse_accel_numerator, \n                        mouse_accel_denominator, mouse_threshold);\n\n  XUngrabPointer(dpy, CurrentTime);\n  XUngrabKeyboard(dpy, CurrentTime);\n\n  XWarpPointer(dpy, None, win,\n               0, 0, 0, 0,\n               glConfig.vidWidth / 2, glConfig.vidHeight / 2);\n\n  // inviso cursor\n  XUndefineCursor(dpy, win);\n}\n\n// bk001206 - from Ryan's Fakk2\n/**\n * XPending() actually performs a blocking read \n *  if no events available. From Fakk2, by way of\n *  Heretic2, by way of SDL, original idea GGI project.\n * The benefit of this approach over the quite\n *  badly behaved XAutoRepeatOn/Off is that you get\n *  focus handling for free, which is a major win\n *  with debug and windowed mode. It rests on the\n *  assumption that the X server will use the\n *  same timestamp on press/release event pairs \n *  for key repeats. \n */\nstatic qboolean X11_PendingInput(void) {\n\n  assert(dpy != NULL);\n\n  // Flush the display connection\n  //  and look to see if events are queued\n  XFlush( dpy );\n  if ( XEventsQueued( dpy, QueuedAlready) )\n  {\n    return qtrue;\n  }\n\n  // More drastic measures are required -- see if X is ready to talk\n  {\n    static struct timeval zero_time;\n    int x11_fd;\n    fd_set fdset;\n\n    x11_fd = ConnectionNumber( dpy );\n    FD_ZERO(&fdset);\n    FD_SET(x11_fd, &fdset);\n    if ( select(x11_fd+1, &fdset, NULL, NULL, &zero_time) == 1 )\n    {\n      return(XPending(dpy));\n    }\n  }\n\n  // Oh well, nothing is ready ..\n  return qfalse;\n}\n\n// bk001206 - from Ryan's Fakk2. See above.\nstatic qboolean repeated_press(XEvent *event)\n{\n  XEvent        peekevent;\n  qboolean      repeated = qfalse;\n\n  assert(dpy != NULL);\n\n  if (X11_PendingInput())\n  {\n    XPeekEvent(dpy, &peekevent);\n\n    if ((peekevent.type == KeyPress) &&\n        (peekevent.xkey.keycode == event->xkey.keycode) &&\n        (peekevent.xkey.time == event->xkey.time))\n    {\n      repeated = qtrue;\n      XNextEvent(dpy, &peekevent);  // skip event.\n    } // if\n  } // if\n\n  return(repeated);\n} // repeated_press\n\nint Sys_XTimeToSysTime (Time xtime);\nstatic void HandleEvents(void)\n{\n  int b;\n  int key;\n  XEvent event;\n  qboolean dowarp = qfalse;\n  char *p;\n  int dx, dy;\n  int t = 0; // default to 0 in case we don't set\n\t\n  if (!dpy)\n    return;\n\n  while (XPending(dpy))\n  {\n    XNextEvent(dpy, &event);\n    switch (event.type)\n    {\n    case KeyPress:\n\t\t\tt = Sys_XTimeToSysTime(event.xkey.time);\n      p = XLateKey(&event.xkey, &key);\n      if (key)\n      {\n        Sys_QueEvent( t, SE_KEY, key, qtrue, 0, NULL );\n      }\n      if (p)\n      {\n        while (*p)\n        {\n          Sys_QueEvent( t, SE_CHAR, *p++, 0, 0, NULL );\n        }\n      }\n      break;\n\n    case KeyRelease:\n\t\t\tt = Sys_XTimeToSysTime(event.xkey.time);\n      // bk001206 - handle key repeat w/o XAutRepatOn/Off\n      //            also: not done if console/menu is active.\n      // From Ryan's Fakk2.\n      // see game/q_shared.h, KEYCATCH_* . 0 == in 3d game.  \n      if (cls.keyCatchers == 0)\n      {   // FIXME: KEYCATCH_NONE\n        if (repeated_press(&event) == qtrue)\n          continue;\n      } // if\n      XLateKey(&event.xkey, &key);\n\n      Sys_QueEvent( t, SE_KEY, key, qfalse, 0, NULL );\n      break;\n\n    case MotionNotify:\n\t\t\tt = Sys_XTimeToSysTime(event.xkey.time);\n      if (mouse_active)\n      {\n        if (in_dgamouse->value)\n        {\n          if (abs(event.xmotion.x_root) > 1)\n            mx += event.xmotion.x_root * 2;\n          else\n            mx += event.xmotion.x_root;\n          if (abs(event.xmotion.y_root) > 1)\n            my += event.xmotion.y_root * 2;\n          else\n            my += event.xmotion.y_root;\n          if (t - mouseResetTime > MOUSE_RESET_DELAY )\n          {\n            Sys_QueEvent( t, SE_MOUSE, mx, my, 0, NULL );\n          }\n          mx = my = 0;\n        } else\n        {\n          // If it's a center motion, we've just returned from our warp\n          if (event.xmotion.x == glConfig.vidWidth/2 &&\n              event.xmotion.y == glConfig.vidHeight/2)\n          {\n            mwx = glConfig.vidWidth/2;\n            mwy = glConfig.vidHeight/2;\n            if (t - mouseResetTime > MOUSE_RESET_DELAY )\n            {\n              Sys_QueEvent( t, SE_MOUSE, mx, my, 0, NULL );\n            }\n            mx = my = 0;\n            break;\n          }\n\n          dx = ((int)event.xmotion.x - mwx);\n          dy = ((int)event.xmotion.y - mwy);\n          if (abs(dx) > 1)\n            mx += dx * 2;\n          else\n            mx += dx;\n          if (abs(dy) > 1)\n            my += dy * 2;\n          else\n            my += dy;\n\n          mwx = event.xmotion.x;\n          mwy = event.xmotion.y;\n          dowarp = qtrue;\n        }\n      }\n      break;\n\n    case ButtonPress:\n\t\t  t = Sys_XTimeToSysTime(event.xkey.time);\n      if (event.xbutton.button == 4)\n      {\n        Sys_QueEvent( t, SE_KEY, K_MWHEELUP, qtrue, 0, NULL );\n      } else if (event.xbutton.button == 5)\n      {\n        Sys_QueEvent( t, SE_KEY, K_MWHEELDOWN, qtrue, 0, NULL );\n      } else\n      {\n        // NOTE TTimo there seems to be a weird mapping for K_MOUSE1 K_MOUSE2 K_MOUSE3 ..\n        b=-1;\n        if (event.xbutton.button == 1)\n        {\n          b = 0; // K_MOUSE1\n        } else if (event.xbutton.button == 2)\n        {\n          b = 2; // K_MOUSE3\n        } else if (event.xbutton.button == 3)\n        {\n          b = 1; // K_MOUSE2\n        } else if (event.xbutton.button == 6)\n        {\n          b = 3; // K_MOUSE4\n        } else if (event.xbutton.button == 7)\n        {\n          b = 4; // K_MOUSE5\n        };\n\n        Sys_QueEvent( t, SE_KEY, K_MOUSE1 + b, qtrue, 0, NULL );\n      }\n      break;\n\n    case ButtonRelease:\n\t\t  t = Sys_XTimeToSysTime(event.xkey.time);\n      if (event.xbutton.button == 4)\n      {\n        Sys_QueEvent( t, SE_KEY, K_MWHEELUP, qfalse, 0, NULL );\n      } else if (event.xbutton.button == 5)\n      {\n        Sys_QueEvent( t, SE_KEY, K_MWHEELDOWN, qfalse, 0, NULL );\n      } else\n      {\n        b=-1;\n        if (event.xbutton.button == 1)\n        {\n          b = 0;\n        } else if (event.xbutton.button == 2)\n        {\n          b = 2;\n        } else if (event.xbutton.button == 3)\n        {\n          b = 1;\n        } else if (event.xbutton.button == 6)\n        {\n          b = 3; // K_MOUSE4\n        } else if (event.xbutton.button == 7)\n        {\n          b = 4; // K_MOUSE5\n        };\n        Sys_QueEvent( t, SE_KEY, K_MOUSE1 + b, qfalse, 0, NULL );\n      }\n      break;\n\n    case CreateNotify :\n      win_x = event.xcreatewindow.x;\n      win_y = event.xcreatewindow.y;\n      break;\n\n    case ConfigureNotify :\n      win_x = event.xconfigure.x;\n      win_y = event.xconfigure.y;\n      break;\n    }\n  }\n\n  if (dowarp)\n  {\n    XWarpPointer(dpy,None,win,0,0,0,0, \n                 (glConfig.vidWidth/2),(glConfig.vidHeight/2));\n  }\n}\n\n// NOTE TTimo for the tty console input, we didn't rely on those .. \n//   it's not very surprising actually cause they are not used otherwise\nvoid KBD_Init(void)\n{\n}\n\nvoid KBD_Close(void)\n{\n}\n\nvoid IN_ActivateMouse( void ) \n{\n  if (!mouse_avail || !dpy || !win)\n    return;\n\n  if (!mouse_active)\n  {\n\t\tif (!in_nograb->value)\n      install_grabs();\n\t\telse if (in_dgamouse->value) // force dga mouse to 0 if using nograb\n\t\t\tri.Cvar_Set(\"in_dgamouse\", \"0\");\n    mouse_active = qtrue;\n  }\n}\n\nvoid IN_DeactivateMouse( void ) \n{\n  if (!mouse_avail || !dpy || !win)\n    return;\n\n  if (mouse_active)\n  {\n\t\tif (!in_nograb->value)\n      uninstall_grabs();\n\t\telse if (in_dgamouse->value) // force dga mouse to 0 if using nograb\n\t\t\tri.Cvar_Set(\"in_dgamouse\", \"0\");\n    mouse_active = qfalse;\n  }\n}\n/*****************************************************************************/\n\n/*\n** GLimp_SetGamma\n**\n** This routine should only be called if glConfig.deviceSupportsGamma is TRUE\n*/\nvoid GLimp_SetGamma( unsigned char red[256], unsigned char green[256], unsigned char blue[256] )\n{\n  // NOTE TTimo we get the gamma value from cvar, because we can't work with the s_gammatable\n  //   the API wasn't changed to avoid breaking other OSes\n  float g = Cvar_Get(\"r_gamma\", \"1.0\", 0)->value;\n  XF86VidModeGamma gamma;\n  assert(glConfig.deviceSupportsGamma);\n  gamma.red = g;\n  gamma.green = g;\n  gamma.blue = g;\n  XF86VidModeSetGamma(dpy, scrnum, &gamma);\n}\n\n/*\n** GLimp_Shutdown\n**\n** This routine does all OS specific shutdown procedures for the OpenGL\n** subsystem.  Under OpenGL this means NULLing out the current DC and\n** HGLRC, deleting the rendering context, and releasing the DC acquired\n** for the window.  The state structure is also nulled out.\n**\n*/\nvoid GLimp_Shutdown( void )\n{\n  if (!ctx || !dpy)\n    return;\n  IN_DeactivateMouse();\n  // bk001206 - replaced with H2/Fakk2 solution\n  // XAutoRepeatOn(dpy);\n  // autorepeaton = qfalse; // bk001130 - from cvs1.17 (mkv)\n  if (dpy)\n  {\n    if (ctx)\n      qglXDestroyContext(dpy, ctx);\n    if (win)\n      XDestroyWindow(dpy, win);\n    if (vidmode_active)\n      XF86VidModeSwitchToMode(dpy, scrnum, vidmodes[0]);\n    if (glConfig.deviceSupportsGamma)\n    {\n      XF86VidModeSetGamma(dpy, scrnum, &vidmode_InitialGamma);\n    }\n    // NOTE TTimo opening/closing the display should be necessary only once per run\n    //   but it seems QGL_Shutdown gets called in a lot of occasion\n    //   in some cases, this XCloseDisplay is known to raise some X errors\n    //   ( https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=33 )\n    XCloseDisplay(dpy);\n  }\n  vidmode_active = qfalse;\n  dpy = NULL;\n  win = 0;\n  ctx = NULL;\n\n  memset( &glConfig, 0, sizeof( glConfig ) );\n  memset( &glState, 0, sizeof( glState ) );\n\n  QGL_Shutdown();\n}\n\n/*\n** GLimp_LogComment\n*/\nvoid GLimp_LogComment( char *comment ) \n{\n  if ( glw_state.log_fp )\n  {\n    fprintf( glw_state.log_fp, \"%s\", comment );\n  }\n}\n\n/*\n** GLW_StartDriverAndSetMode\n*/\n// bk001204 - prototype needed\nint GLW_SetMode( const char *drivername, int mode, qboolean fullscreen );\nstatic qboolean GLW_StartDriverAndSetMode( const char *drivername, \n                                           int mode, \n                                           qboolean fullscreen )\n{\n  rserr_t err;\n\n  // don't ever bother going into fullscreen with a voodoo card\n#if 1\t// JDC: I reenabled this\n  if ( Q_stristr( drivername, \"Voodoo\" ) )\n  {\n    ri.Cvar_Set( \"r_fullscreen\", \"0\" );\n    r_fullscreen->modified = qfalse;\n    fullscreen = qfalse;\n  }\n#endif\n\t\n\tif (fullscreen && in_nograb->value)\n\t{\n\t\tri.Printf( PRINT_ALL, \"Fullscreen not allowed with in_nograb 1\\n\");\n    ri.Cvar_Set( \"r_fullscreen\", \"0\" );\n    r_fullscreen->modified = qfalse;\n    fullscreen = qfalse;\t\t\n\t}\n\n  err = GLW_SetMode( drivername, mode, fullscreen );\n\n  switch ( err )\n  {\n  case RSERR_INVALID_FULLSCREEN:\n    ri.Printf( PRINT_ALL, \"...WARNING: fullscreen unavailable in this mode\\n\" );\n    return qfalse;\n  case RSERR_INVALID_MODE:\n    ri.Printf( PRINT_ALL, \"...WARNING: could not set the given mode (%d)\\n\", mode );\n    return qfalse;\n  default:\n    break;\n  }\n  return qtrue;\n}\n\n/*\n** GLW_SetMode\n*/\nint GLW_SetMode( const char *drivername, int mode, qboolean fullscreen )\n{\n  int attrib[] = {\n    GLX_RGBA,         // 0\n    GLX_RED_SIZE, 4,      // 1, 2\n    GLX_GREEN_SIZE, 4,      // 3, 4\n    GLX_BLUE_SIZE, 4,     // 5, 6\n    GLX_DOUBLEBUFFER,     // 7\n    GLX_DEPTH_SIZE, 1,      // 8, 9\n    GLX_STENCIL_SIZE, 1,    // 10, 11\n    None\n  };\n  // these match in the array\n#define ATTR_RED_IDX 2\n#define ATTR_GREEN_IDX 4\n#define ATTR_BLUE_IDX 6\n#define ATTR_DEPTH_IDX 9\n#define ATTR_STENCIL_IDX 11\n  Window root;\n  XVisualInfo *visinfo;\n  XSetWindowAttributes attr;\n  XSizeHints sizehints;\n  unsigned long mask;\n  int colorbits, depthbits, stencilbits;\n  int tcolorbits, tdepthbits, tstencilbits;\n  int dga_MajorVersion, dga_MinorVersion;\n  int actualWidth, actualHeight;\n  int i;\n  const char*   glstring; // bk001130 - from cvs1.17 (mkv)\n\n  ri.Printf( PRINT_ALL, \"Initializing OpenGL display\\n\");\n\n  ri.Printf (PRINT_ALL, \"...setting mode %d:\", mode );\n\n  if ( !R_GetModeInfo( &glConfig.vidWidth, &glConfig.vidHeight, &glConfig.windowAspect, mode ) )\n  {\n    ri.Printf( PRINT_ALL, \" invalid mode\\n\" );\n    return RSERR_INVALID_MODE;\n  }\n  ri.Printf( PRINT_ALL, \" %d %d\\n\", glConfig.vidWidth, glConfig.vidHeight);\n\n  if (!(dpy = XOpenDisplay(NULL)))\n  {\n    fprintf(stderr, \"Error couldn't open the X display\\n\");\n    return RSERR_INVALID_MODE;\n  }\n  \n  scrnum = DefaultScreen(dpy);\n  root = RootWindow(dpy, scrnum);\n\n  actualWidth = glConfig.vidWidth;\n  actualHeight = glConfig.vidHeight;\n\n  // Get video mode list\n  if (!XF86VidModeQueryVersion(dpy, &vidmode_MajorVersion, &vidmode_MinorVersion))\n  {\n    vidmode_ext = qfalse;\n  } else\n  {\n    ri.Printf(PRINT_ALL, \"Using XFree86-VidModeExtension Version %d.%d\\n\",\n              vidmode_MajorVersion, vidmode_MinorVersion);\n    vidmode_ext = qtrue;\n  }\n\n  // Check for DGA\t\n  dga_MajorVersion = 0, dga_MinorVersion = 0;\n  if (in_dgamouse->value)\n  {\n    if (!XF86DGAQueryVersion(dpy, &dga_MajorVersion, &dga_MinorVersion))\n    {\n      // unable to query, probalby not supported\n      ri.Printf( PRINT_ALL, \"Failed to detect XF86DGA Mouse\\n\" );\n      ri.Cvar_Set( \"in_dgamouse\", \"0\" );\n    } else\n    {\n      ri.Printf( PRINT_ALL, \"XF86DGA Mouse (Version %d.%d) initialized\\n\",\n                 dga_MajorVersion, dga_MinorVersion);\n    }\n  }\n\n  if (vidmode_ext)\n  {\n    int best_fit, best_dist, dist, x, y;\n\n    XF86VidModeGetAllModeLines(dpy, scrnum, &num_vidmodes, &vidmodes);\n\n    // Are we going fullscreen?  If so, let's change video mode\n    if (fullscreen)\n    {\n      best_dist = 9999999;\n      best_fit = -1;\n\n      for (i = 0; i < num_vidmodes; i++)\n      {\n        if (glConfig.vidWidth > vidmodes[i]->hdisplay ||\n            glConfig.vidHeight > vidmodes[i]->vdisplay)\n          continue;\n\n        x = glConfig.vidWidth - vidmodes[i]->hdisplay;\n        y = glConfig.vidHeight - vidmodes[i]->vdisplay;\n        dist = (x * x) + (y * y);\n        if (dist < best_dist)\n        {\n          best_dist = dist;\n          best_fit = i;\n        }\n      }\n\n      if (best_fit != -1)\n      {\n        actualWidth = vidmodes[best_fit]->hdisplay;\n        actualHeight = vidmodes[best_fit]->vdisplay;\n\n        // change to the mode\n        XF86VidModeSwitchToMode(dpy, scrnum, vidmodes[best_fit]);\n        vidmode_active = qtrue;\n\n        // Move the viewport to top left\n        XF86VidModeSetViewPort(dpy, scrnum, 0, 0);\n\n        ri.Printf(PRINT_ALL, \"XFree86-VidModeExtension Activated at %dx%d\\n\",\n                  actualWidth, actualHeight);\n\n      } else\n      {\n        fullscreen = 0;\n        ri.Printf(PRINT_ALL, \"XFree86-VidModeExtension: No acceptable modes found\\n\");\n      }\n    } else\n    {\n      ri.Printf(PRINT_ALL, \"XFree86-VidModeExtension:  Ignored on non-fullscreen/Voodoo\\n\");\n    }\n  }\n\n\n  if (!r_colorbits->value)\n    colorbits = 24;\n  else\n    colorbits = r_colorbits->value;\n\n  if ( !Q_stricmp( r_glDriver->string, _3DFX_DRIVER_NAME ) )\n    colorbits = 16;\n\n  if (!r_depthbits->value)\n    depthbits = 24;\n  else\n    depthbits = r_depthbits->value;\n  stencilbits = r_stencilbits->value;\n\n  for (i = 0; i < 16; i++)\n  {\n    // 0 - default\n    // 1 - minus colorbits\n    // 2 - minus depthbits\n    // 3 - minus stencil\n    if ((i % 4) == 0 && i)\n    {\n      // one pass, reduce\n      switch (i / 4)\n      {\n      case 2 :\n        if (colorbits == 24)\n          colorbits = 16;\n        break;\n      case 1 :\n        if (depthbits == 24)\n          depthbits = 16;\n        else if (depthbits == 16)\n          depthbits = 8;\n      case 3 :\n        if (stencilbits == 24)\n          stencilbits = 16;\n        else if (stencilbits == 16)\n          stencilbits = 8;\n      }\n    }\n\n    tcolorbits = colorbits;\n    tdepthbits = depthbits;\n    tstencilbits = stencilbits;\n\n    if ((i % 4) == 3)\n    { // reduce colorbits\n      if (tcolorbits == 24)\n        tcolorbits = 16;\n    }\n\n    if ((i % 4) == 2)\n    { // reduce depthbits\n      if (tdepthbits == 24)\n        tdepthbits = 16;\n      else if (tdepthbits == 16)\n        tdepthbits = 8;\n    }\n\n    if ((i % 4) == 1)\n    { // reduce stencilbits\n      if (tstencilbits == 24)\n        tstencilbits = 16;\n      else if (tstencilbits == 16)\n        tstencilbits = 8;\n      else\n        tstencilbits = 0;\n    }\n\n    if (tcolorbits == 24)\n    {\n      attrib[ATTR_RED_IDX] = 8;\n      attrib[ATTR_GREEN_IDX] = 8;\n      attrib[ATTR_BLUE_IDX] = 8;\n    } else\n    {\n      // must be 16 bit\n      attrib[ATTR_RED_IDX] = 4;\n      attrib[ATTR_GREEN_IDX] = 4;\n      attrib[ATTR_BLUE_IDX] = 4;\n    }\n\n    attrib[ATTR_DEPTH_IDX] = tdepthbits; // default to 24 depth\n    attrib[ATTR_STENCIL_IDX] = tstencilbits;\n\n    visinfo = qglXChooseVisual(dpy, scrnum, attrib);\n    if (!visinfo)\n    {\n      continue;\n    }\n\n    ri.Printf( PRINT_ALL, \"Using %d/%d/%d Color bits, %d depth, %d stencil display.\\n\", \n               attrib[ATTR_RED_IDX], attrib[ATTR_GREEN_IDX], attrib[ATTR_BLUE_IDX],\n               attrib[ATTR_DEPTH_IDX], attrib[ATTR_STENCIL_IDX]);\n\n    glConfig.colorBits = tcolorbits;\n    glConfig.depthBits = tdepthbits;\n    glConfig.stencilBits = tstencilbits;\n    break;\n  }\n\n  if (!visinfo)\n  {\n    ri.Printf( PRINT_ALL, \"Couldn't get a visual\\n\" );\n    return RSERR_INVALID_MODE;\n  }\n\n  /* window attributes */\n  attr.background_pixel = BlackPixel(dpy, scrnum);\n  attr.border_pixel = 0;\n  attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);\n  attr.event_mask = X_MASK;\n  if (vidmode_active)\n  {\n    mask = CWBackPixel | CWColormap | CWSaveUnder | CWBackingStore | \n           CWEventMask | CWOverrideRedirect;\n    attr.override_redirect = True;\n    attr.backing_store = NotUseful;\n    attr.save_under = False;\n  } else\n    mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;\n\n  win = XCreateWindow(dpy, root, 0, 0, \n                      actualWidth, actualHeight, \n                      0, visinfo->depth, InputOutput,\n                      visinfo->visual, mask, &attr);\n\n  XStoreName( dpy, win, WINDOW_CLASS_NAME );\n\n  /* GH: Don't let the window be resized */\n  sizehints.flags = PMinSize | PMaxSize;\n  sizehints.min_width = sizehints.max_width = actualWidth;\n  sizehints.min_height = sizehints.max_height = actualHeight;\n\n  XSetWMNormalHints( dpy, win, &sizehints );\n\n  XMapWindow( dpy, win );\n\n  if (vidmode_active)\n    XMoveWindow(dpy, win, 0, 0);\n\n  XFlush(dpy);\n  XSync(dpy,False); // bk001130 - from cvs1.17 (mkv)\n  ctx = qglXCreateContext(dpy, visinfo, NULL, True);\n  XSync(dpy,False); // bk001130 - from cvs1.17 (mkv)\n\n  /* GH: Free the visinfo after we're done with it */\n  XFree( visinfo );\n\n  qglXMakeCurrent(dpy, win, ctx);\n\n  // bk001130 - from cvs1.17 (mkv)\n  glstring = qglGetString (GL_RENDERER);\n  ri.Printf( PRINT_ALL, \"GL_RENDERER: %s\\n\", glstring );\n\n  // bk010122 - new software token (Indirect)\n  if ( !Q_stricmp( glstring, \"Mesa X11\")\n       || !Q_stricmp( glstring, \"Mesa GLX Indirect\") )\n  {\n    if ( !r_allowSoftwareGL->integer )\n    {\n      ri.Printf( PRINT_ALL, \"\\n\\n***********************************************************\\n\" );\n      ri.Printf( PRINT_ALL, \" You are using software Mesa (no hardware acceleration)!   \\n\" );\n      ri.Printf( PRINT_ALL, \" Driver DLL used: %s\\n\", drivername ); \n      ri.Printf( PRINT_ALL, \" If this is intentional, add\\n\" );\n      ri.Printf( PRINT_ALL, \"       \\\"+set r_allowSoftwareGL 1\\\"\\n\" );\n      ri.Printf( PRINT_ALL, \" to the command line when starting the game.\\n\" );\n      ri.Printf( PRINT_ALL, \"***********************************************************\\n\");\n      GLimp_Shutdown( );\n      return RSERR_INVALID_MODE;\n    } else\n    {\n      ri.Printf( PRINT_ALL, \"...using software Mesa (r_allowSoftwareGL==1).\\n\" );\n    }\n  }\n\n  return RSERR_OK;\n}\n\n/*\n** GLW_InitExtensions\n*/\nstatic void GLW_InitExtensions( void )\n{\n  if ( !r_allowExtensions->integer )\n  {\n    ri.Printf( PRINT_ALL, \"*** IGNORING OPENGL EXTENSIONS ***\\n\" );\n    return;\n  }\n\n  ri.Printf( PRINT_ALL, \"Initializing OpenGL extensions\\n\" );\n\n  // GL_S3_s3tc\n  if ( Q_stristr( glConfig.extensions_string, \"GL_S3_s3tc\" ) )\n  {\n    if ( r_ext_compressed_textures->value )\n    {\n      glConfig.textureCompression = TC_S3TC;\n      ri.Printf( PRINT_ALL, \"...using GL_S3_s3tc\\n\" );\n    } else\n    {\n      glConfig.textureCompression = TC_NONE;\n      ri.Printf( PRINT_ALL, \"...ignoring GL_S3_s3tc\\n\" );\n    }\n  } else\n  {\n    glConfig.textureCompression = TC_NONE;\n    ri.Printf( PRINT_ALL, \"...GL_S3_s3tc not found\\n\" );\n  }\n\n  // GL_EXT_texture_env_add\n  glConfig.textureEnvAddAvailable = qfalse;\n  if ( Q_stristr( glConfig.extensions_string, \"EXT_texture_env_add\" ) )\n  {\n    if ( r_ext_texture_env_add->integer )\n    {\n      glConfig.textureEnvAddAvailable = qtrue;\n      ri.Printf( PRINT_ALL, \"...using GL_EXT_texture_env_add\\n\" );\n    } else\n    {\n      glConfig.textureEnvAddAvailable = qfalse;\n      ri.Printf( PRINT_ALL, \"...ignoring GL_EXT_texture_env_add\\n\" );\n    }\n  } else\n  {\n    ri.Printf( PRINT_ALL, \"...GL_EXT_texture_env_add not found\\n\" );\n  }\n\n  // GL_ARB_multitexture\n  qglMultiTexCoord2fARB = NULL;\n  qglActiveTextureARB = NULL;\n  qglClientActiveTextureARB = NULL;\n  if ( Q_stristr( glConfig.extensions_string, \"GL_ARB_multitexture\" ) )\n  {\n    if ( r_ext_multitexture->value )\n    {\n      qglMultiTexCoord2fARB = ( PFNGLMULTITEXCOORD2FARBPROC ) dlsym( glw_state.OpenGLLib, \"glMultiTexCoord2fARB\" );\n      qglActiveTextureARB = ( PFNGLACTIVETEXTUREARBPROC ) dlsym( glw_state.OpenGLLib, \"glActiveTextureARB\" );\n      qglClientActiveTextureARB = ( PFNGLCLIENTACTIVETEXTUREARBPROC ) dlsym( glw_state.OpenGLLib, \"glClientActiveTextureARB\" );\n\n      if ( qglActiveTextureARB )\n      {\n        qglGetIntegerv( GL_MAX_ACTIVE_TEXTURES_ARB, &glConfig.maxActiveTextures );\n\n        if ( glConfig.maxActiveTextures > 1 )\n        {\n          ri.Printf( PRINT_ALL, \"...using GL_ARB_multitexture\\n\" );\n        } else\n        {\n          qglMultiTexCoord2fARB = NULL;\n          qglActiveTextureARB = NULL;\n          qglClientActiveTextureARB = NULL;\n          ri.Printf( PRINT_ALL, \"...not using GL_ARB_multitexture, < 2 texture units\\n\" );\n        }\n      }\n    } else\n    {\n      ri.Printf( PRINT_ALL, \"...ignoring GL_ARB_multitexture\\n\" );\n    }\n  } else\n  {\n    ri.Printf( PRINT_ALL, \"...GL_ARB_multitexture not found\\n\" );\n  }\n\n  // GL_EXT_compiled_vertex_array\n  if ( Q_stristr( glConfig.extensions_string, \"GL_EXT_compiled_vertex_array\" ) )\n  {\n    if ( r_ext_compiled_vertex_array->value )\n    {\n      ri.Printf( PRINT_ALL, \"...using GL_EXT_compiled_vertex_array\\n\" );\n      qglLockArraysEXT = ( void ( APIENTRY * )( int, int ) ) dlsym( glw_state.OpenGLLib, \"glLockArraysEXT\" );\n      qglUnlockArraysEXT = ( void ( APIENTRY * )( void ) ) dlsym( glw_state.OpenGLLib, \"glUnlockArraysEXT\" );\n      if (!qglLockArraysEXT || !qglUnlockArraysEXT)\n      {\n        ri.Error (ERR_FATAL, \"bad getprocaddress\");\n      }\n    } else\n    {\n      ri.Printf( PRINT_ALL, \"...ignoring GL_EXT_compiled_vertex_array\\n\" );\n    }\n  } else\n  {\n    ri.Printf( PRINT_ALL, \"...GL_EXT_compiled_vertex_array not found\\n\" );\n  }\n\n}\n\nstatic void GLW_InitGamma()\n{\n  /* Minimum extension version required */\n  #define GAMMA_MINMAJOR 2\n  #define GAMMA_MINMINOR 0\n  \n  glConfig.deviceSupportsGamma = qfalse;\n\n  if (vidmode_ext)\n  {\n    if (vidmode_MajorVersion < GAMMA_MINMAJOR || \n        (vidmode_MajorVersion == GAMMA_MINMAJOR && vidmode_MinorVersion < GAMMA_MINMINOR)) {\n      ri.Printf( PRINT_ALL, \"XF86 Gamma extension not supported in this version\\n\");\n      return;\n    }\n    XF86VidModeGetGamma(dpy, scrnum, &vidmode_InitialGamma);\n    ri.Printf( PRINT_ALL, \"XF86 Gamma extension initialized\\n\");\n    glConfig.deviceSupportsGamma = qtrue;\n  }\n}\n\n/*\n** GLW_LoadOpenGL\n**\n** GLimp_win.c internal function that that attempts to load and use \n** a specific OpenGL DLL.\n*/\nstatic qboolean GLW_LoadOpenGL( const char *name )\n{\n  qboolean fullscreen;\n\n  ri.Printf( PRINT_ALL, \"...loading %s: \", name );\n\n  // disable the 3Dfx splash screen and set gamma\n  // we do this all the time, but it shouldn't hurt anything\n  // on non-3Dfx stuff\n  putenv(\"FX_GLIDE_NO_SPLASH=0\");\n\n  // Mesa VooDoo hacks\n  putenv(\"MESA_GLX_FX=fullscreen\\n\");\n\n  // load the QGL layer\n  if ( QGL_Init( name ) )\n  {\n    fullscreen = r_fullscreen->integer;\n\n    // create the window and set up the context\n    if ( !GLW_StartDriverAndSetMode( name, r_mode->integer, fullscreen ) )\n    {\n      if (r_mode->integer != 3)\n      {\n        if ( !GLW_StartDriverAndSetMode( name, 3, fullscreen ) )\n        {\n          goto fail;\n        }\n      } else\n        goto fail;\n    }\n\n    return qtrue;\n  } else\n  {\n    ri.Printf( PRINT_ALL, \"failed\\n\" );\n  }\n  fail:\n\n  QGL_Shutdown();\n\n  return qfalse;\n}\n\n/*\n** XErrorHandler\n**   the default X error handler exits the application\n**   I found out that on some hosts some operations would raise X errors (GLXUnsupportedPrivateRequest)\n**   but those don't seem to be fatal .. so the default would be to just ignore them\n**   our implementation mimics the default handler behaviour (not completely cause I'm lazy)\n*/\nint qXErrorHandler(Display *dpy, XErrorEvent *ev)\n{\n  static char buf[1024];\n  XGetErrorText(dpy, ev->error_code, buf, 1024);\n  ri.Printf( PRINT_ALL, \"X Error of failed request: %s\\n\", buf);\n  ri.Printf( PRINT_ALL, \"  Major opcode of failed request: %d\\n\", ev->request_code, buf);\n  ri.Printf( PRINT_ALL, \"  Minor opcode of failed request: %d\\n\", ev->minor_code);  \n  ri.Printf( PRINT_ALL, \"  Serial number of failed request: %d\\n\", ev->serial);\n  return 0;\n}\n\n/*\n** GLimp_Init\n**\n** This routine is responsible for initializing the OS specific portions\n** of OpenGL.  \n*/\nvoid GLimp_Init( void )\n{\n  qboolean attemptedlibGL = qfalse;\n  qboolean attempted3Dfx = qfalse;\n  qboolean success = qfalse;\n  char  buf[1024];\n  cvar_t *lastValidRenderer = ri.Cvar_Get( \"r_lastValidRenderer\", \"(uninitialized)\", CVAR_ARCHIVE );\n\n  // guarded, as this is only relevant to SMP renderer thread\n#ifdef SMP\n  if (!XInitThreads())\n  {\n    Com_Printf(\"GLimp_Init() - XInitThreads() failed, disabling r_smp\\n\");\n    ri.Cvar_Set( \"r_smp\", \"0\" );\n  }\n#endif\n\n  r_allowSoftwareGL = ri.Cvar_Get( \"r_allowSoftwareGL\", \"0\", CVAR_LATCH );\n\n  r_previousglDriver = ri.Cvar_Get( \"r_previousglDriver\", \"\", CVAR_ROM );\n\n  InitSig();\n\n  // Hack here so that if the UI \n  if ( *r_previousglDriver->string )\n  {\n    // The UI changed it on us, hack it back\n    // This means the renderer can't be changed on the fly\n    ri.Cvar_Set( \"r_glDriver\", r_previousglDriver->string );\n  }\n  \n  // set up our custom error handler for X failures\n  XSetErrorHandler(&qXErrorHandler);\n\n  //\n  // load and initialize the specific OpenGL driver\n  //\n  if ( !GLW_LoadOpenGL( r_glDriver->string ) )\n  {\n    if ( !Q_stricmp( r_glDriver->string, OPENGL_DRIVER_NAME ) )\n    {\n      attemptedlibGL = qtrue;\n    } else if ( !Q_stricmp( r_glDriver->string, _3DFX_DRIVER_NAME ) )\n    {\n      attempted3Dfx = qtrue;\n    }\n\n    #if 0\n    // TTimo\n    // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=455\n    // old legacy load code, was confusing people who had a bad OpenGL setup\n    if ( !attempted3Dfx && !success )\n    {\n      attempted3Dfx = qtrue;\n      if ( GLW_LoadOpenGL( _3DFX_DRIVER_NAME ) )\n      {\n        ri.Cvar_Set( \"r_glDriver\", _3DFX_DRIVER_NAME );\n        r_glDriver->modified = qfalse;\n        success = qtrue;\n      }\n    }\n    #endif\n\n    // try ICD before trying 3Dfx standalone driver\n    if ( !attemptedlibGL && !success )\n    {\n      attemptedlibGL = qtrue;\n      if ( GLW_LoadOpenGL( OPENGL_DRIVER_NAME ) )\n      {\n        ri.Cvar_Set( \"r_glDriver\", OPENGL_DRIVER_NAME );\n        r_glDriver->modified = qfalse;\n        success = qtrue;\n      }\n    }\n\n    if (!success)\n      ri.Error( ERR_FATAL, \"GLimp_Init() - could not load OpenGL subsystem\\n\" );\n\n  }\n\n  // Save it in case the UI stomps it\n  ri.Cvar_Set( \"r_previousglDriver\", r_glDriver->string );\n\n  // This values force the UI to disable driver selection\n  glConfig.driverType = GLDRV_ICD;\n  glConfig.hardwareType = GLHW_GENERIC;\n\n  // get our config strings\n  Q_strncpyz( glConfig.vendor_string, qglGetString (GL_VENDOR), sizeof( glConfig.vendor_string ) );\n  Q_strncpyz( glConfig.renderer_string, qglGetString (GL_RENDERER), sizeof( glConfig.renderer_string ) );\n  if (*glConfig.renderer_string && glConfig.renderer_string[strlen(glConfig.renderer_string) - 1] == '\\n')\n    glConfig.renderer_string[strlen(glConfig.renderer_string) - 1] = 0;\n  Q_strncpyz( glConfig.version_string, qglGetString (GL_VERSION), sizeof( glConfig.version_string ) );\n  Q_strncpyz( glConfig.extensions_string, qglGetString (GL_EXTENSIONS), sizeof( glConfig.extensions_string ) );\n\n  //\n  // chipset specific configuration\n  //\n  strcpy( buf, glConfig.renderer_string );\n  strlwr( buf );\n\n  //\n  // NOTE: if changing cvars, do it within this block.  This allows them\n  // to be overridden when testing driver fixes, etc. but only sets\n  // them to their default state when the hardware is first installed/run.\n  //\n  if ( Q_stricmp( lastValidRenderer->string, glConfig.renderer_string ) )\n  {\n    glConfig.hardwareType = GLHW_GENERIC;\n\n    ri.Cvar_Set( \"r_textureMode\", \"GL_LINEAR_MIPMAP_NEAREST\" );\n\n    // VOODOO GRAPHICS w/ 2MB\n    if ( Q_stristr( buf, \"voodoo graphics/1 tmu/2 mb\" ) )\n    {\n      ri.Cvar_Set( \"r_picmip\", \"2\" );\n      ri.Cvar_Get( \"r_picmip\", \"1\", CVAR_ARCHIVE | CVAR_LATCH );\n    } else\n    {\n      ri.Cvar_Set( \"r_picmip\", \"1\" );\n\n      if ( Q_stristr( buf, \"rage 128\" ) || Q_stristr( buf, \"rage128\" ) )\n      {\n        ri.Cvar_Set( \"r_finish\", \"0\" );\n      }\n      // Savage3D and Savage4 should always have trilinear enabled\n      else if ( Q_stristr( buf, \"savage3d\" ) || Q_stristr( buf, \"s3 savage4\" ) )\n      {\n        ri.Cvar_Set( \"r_texturemode\", \"GL_LINEAR_MIPMAP_LINEAR\" );\n      }\n    }\n  }\n\n  //\n  // this is where hardware specific workarounds that should be\n  // detected/initialized every startup should go.\n  //\n  if ( Q_stristr( buf, \"banshee\" ) || Q_stristr( buf, \"Voodoo_Graphics\" ) )\n  {\n    glConfig.hardwareType = GLHW_3DFX_2D3D;\n  } else if ( Q_stristr( buf, \"rage pro\" ) || Q_stristr( buf, \"RagePro\" ) )\n  {\n    glConfig.hardwareType = GLHW_RAGEPRO;\n  } else if ( Q_stristr( buf, \"permedia2\" ) )\n  {\n    glConfig.hardwareType = GLHW_PERMEDIA2;\n  } else if ( Q_stristr( buf, \"riva 128\" ) )\n  {\n    glConfig.hardwareType = GLHW_RIVA128;\n  } else if ( Q_stristr( buf, \"riva tnt \" ) )\n  {\n  }\n\n  ri.Cvar_Set( \"r_lastValidRenderer\", glConfig.renderer_string );\n\n  // initialize extensions\n  GLW_InitExtensions();\n  GLW_InitGamma();\n\n  InitSig(); // not clear why this is at begin & end of function\n\n  return;\n}\n\n\n/*\n** GLimp_EndFrame\n** \n** Responsible for doing a swapbuffers and possibly for other stuff\n** as yet to be determined.  Probably better not to make this a GLimp\n** function and instead do a call to GLimp_SwapBuffers.\n*/\nvoid GLimp_EndFrame (void)\n{\n  // don't flip if drawing to front buffer\n  if ( stricmp( r_drawBuffer->string, \"GL_FRONT\" ) != 0 )\n  {\n    qglXSwapBuffers(dpy, win);\n  }\n\n  // check logging\n  QGL_EnableLogging( (qboolean)r_logFile->integer ); // bk001205 - was ->value\n}\n\n#ifdef SMP\n/*\n===========================================================\n\nSMP acceleration\n\n===========================================================\n*/\n\nstatic pthread_mutex_t\tsmpMutex = PTHREAD_MUTEX_INITIALIZER;\n\nstatic pthread_cond_t\t\trenderCommandsEvent = PTHREAD_COND_INITIALIZER;\nstatic pthread_cond_t\t\trenderCompletedEvent = PTHREAD_COND_INITIALIZER;\n\nstatic void (*glimpRenderThread)( void );\n\nstatic void *GLimp_RenderThreadWrapper( void *arg )\n{\n\tCom_Printf( \"Render thread starting\\n\" );\n\n  glimpRenderThread();\n\n\tqglXMakeCurrent( dpy, None, NULL );\n\n\tCom_Printf( \"Render thread terminating\\n\" );\n\n\treturn arg;\n}\n\nqboolean GLimp_SpawnRenderThread( void (*function)( void ) )\n{\n\tpthread_t renderThread;\n\tint ret;\n\n\tpthread_mutex_init( &smpMutex, NULL );\n\n\tpthread_cond_init( &renderCommandsEvent, NULL );\n\tpthread_cond_init( &renderCompletedEvent, NULL );\n\n  glimpRenderThread = function;\n\n\tret = pthread_create( &renderThread,\n\t\t\t\t\t\t  NULL,\t\t\t// attributes\n\t\t\t\t\t\t  GLimp_RenderThreadWrapper,\n\t\t\t\t\t\t  NULL );\t\t// argument\n\tif ( ret ) {\n\t\tri.Printf( PRINT_ALL, \"pthread_create returned %d: %s\", ret, strerror( ret ) );\n    return qfalse;\n\t} else {\n\t\tret = pthread_detach( renderThread );\n\t\tif ( ret ) {\n\t\t\tri.Printf( PRINT_ALL, \"pthread_detach returned %d: %s\", ret, strerror( ret ) );\n\t\t}\n  }\n\n  return qtrue;\n}\n\nstatic volatile void    *smpData = NULL;\nstatic volatile qboolean smpDataReady;\n\nvoid *GLimp_RendererSleep( void )\n{\n\tvoid  *data;\n\n\tqglXMakeCurrent( dpy, None, NULL );\n\n\tpthread_mutex_lock( &smpMutex );\n\t{\n\t\tsmpData = NULL;\n\t\tsmpDataReady = qfalse;\n\n\t\t// after this, the front end can exit GLimp_FrontEndSleep\n\t\tpthread_cond_signal( &renderCompletedEvent );\n\n\t\twhile ( !smpDataReady ) {\n\t\t\tpthread_cond_wait( &renderCommandsEvent, &smpMutex );\n\t\t}\n\n\t\tdata = (void *)smpData;\n\t}\n\tpthread_mutex_unlock( &smpMutex );\n\n\tqglXMakeCurrent( dpy, win, ctx );\n\n  return data;\n}\n\nvoid GLimp_FrontEndSleep( void )\n{\n\tpthread_mutex_lock( &smpMutex );\n\t{\n\t\twhile ( smpData ) {\n\t\t\tpthread_cond_wait( &renderCompletedEvent, &smpMutex );\n\t\t}\n\t}\n\tpthread_mutex_unlock( &smpMutex );\n\n\tqglXMakeCurrent( dpy, win, ctx );\n}\n\nvoid GLimp_WakeRenderer( void *data )\n{\n\tqglXMakeCurrent( dpy, None, NULL );\n\n\tpthread_mutex_lock( &smpMutex );\n\t{\n\t\tassert( smpData == NULL );\n\t\tsmpData = data;\n\t\tsmpDataReady = qtrue;\n\n\t\t// after this, the renderer can continue through GLimp_RendererSleep\n\t\tpthread_cond_signal( &renderCommandsEvent );\n\t}\n\tpthread_mutex_unlock( &smpMutex );\n}\n\n#else\n\nvoid GLimp_RenderThreadWrapper( void *stub ) {}\nqboolean GLimp_SpawnRenderThread( void (*function)( void ) ) {\n\tri.Printf( PRINT_WARNING, \"ERROR: SMP support was disabled at compile time\\n\");\n  return qfalse;\n}\nvoid *GLimp_RendererSleep( void ) {\n  return NULL;\n}\nvoid GLimp_FrontEndSleep( void ) {}\nvoid GLimp_WakeRenderer( void *data ) {}\n\n#endif\n\n/*****************************************************************************/\n/* MOUSE                                                                     */\n/*****************************************************************************/\n\nvoid IN_Init(void) {\n\tCom_Printf (\"\\n------- Input Initialization -------\\n\");\n  // mouse variables\n  in_mouse = Cvar_Get (\"in_mouse\", \"1\", CVAR_ARCHIVE);\n  in_dgamouse = Cvar_Get (\"in_dgamouse\", \"1\", CVAR_ARCHIVE);\n\t\n\t// turn on-off sub-frame timing of X events\n\tin_subframe = Cvar_Get (\"in_subframe\", \"1\", CVAR_ARCHIVE);\n\t\n\t// developer feature, allows to break without loosing mouse pointer\n\tin_nograb = Cvar_Get (\"in_nograb\", \"0\", 0);\n\n  // bk001130 - from cvs.17 (mkv), joystick variables\n  in_joystick = Cvar_Get (\"in_joystick\", \"0\", CVAR_ARCHIVE|CVAR_LATCH);\n  // bk001130 - changed this to match win32\n  in_joystickDebug = Cvar_Get (\"in_debugjoystick\", \"0\", CVAR_TEMP);\n  joy_threshold = Cvar_Get (\"joy_threshold\", \"0.15\", CVAR_ARCHIVE); // FIXME: in_joythreshold\n\n  if (in_mouse->value)\n    mouse_avail = qtrue;\n  else\n    mouse_avail = qfalse;\n\n  IN_StartupJoystick( ); // bk001130 - from cvs1.17 (mkv)\n\tCom_Printf (\"------------------------------------\\n\");\n}\n\nvoid IN_Shutdown(void)\n{\n  mouse_avail = qfalse;\n}\n\nvoid IN_Frame (void) {\n\n  // bk001130 - from cvs 1.17 (mkv)\n  IN_JoyMove(); // FIXME: disable if on desktop?\n\n  if ( cls.keyCatchers & KEYCATCH_CONSOLE )\n  {\n    // temporarily deactivate if not in the game and\n    // running on the desktop\n    // voodoo always counts as full screen\n    if (Cvar_VariableValue (\"r_fullscreen\") == 0\n        && strcmp( Cvar_VariableString(\"r_glDriver\"), _3DFX_DRIVER_NAME ) )\n    {\n      IN_DeactivateMouse ();\n      return;\n    }\n  }\n\n  IN_ActivateMouse();\n}\n\nvoid IN_Activate(void)\n{\n}\n\n// bk001130 - cvs1.17 joystick code (mkv) was here, no linux_joystick.c\n\nvoid Sys_SendKeyEvents (void) {\n  // XEvent event; // bk001204 - unused\n\n  if (!dpy)\n    return;\n  HandleEvents();\n}\n\n\n// bk010216 - added stubs for non-Linux UNIXes here\n// FIXME - use NO_JOYSTICK or something else generic\n\n#if defined( __FreeBSD__ ) // rb010123\nvoid IN_StartupJoystick( void ) {}\nvoid IN_JoyMove( void ) {}\n#endif\n"
  },
  {
    "path": "code/unix/linux_joystick.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n/*\n** linux_joystick.c\n**\n** This file contains ALL Linux specific stuff having to do with the\n** Joystick input.  When a port is being made the following functions\n** must be implemented by the port:\n**\n** Authors: mkv, bk\n**\n*/\n\n#include <linux/joystick.h>\n#include <sys/types.h>\n#include <fcntl.h>\n#include <sys/ioctl.h>\n#include <unistd.h>  // bk001204\n\n\n#include \"../client/client.h\"\n#include \"linux_local.h\"\n\n/* We translate axes movement into keypresses. */\nint joy_keys[16] = {\n     K_LEFTARROW, K_RIGHTARROW,\n     K_UPARROW, K_DOWNARROW,\n     K_JOY16, K_JOY17,\n     K_JOY18, K_JOY19,\n     K_JOY20, K_JOY21,\n     K_JOY22, K_JOY23,\n\n     K_JOY24, K_JOY25,\n     K_JOY26, K_JOY27\n};\n\n/* Our file descriptor for the joystick device. */\nstatic int             joy_fd = -1;\n\n\n// bk001130 - from linux_glimp.c\nextern cvar_t *  in_joystick;\nextern cvar_t *  in_joystickDebug;\nextern cvar_t *  joy_threshold;\n\n\n/**********************************************/\n/* Joystick routines.                         */\n/**********************************************/\n// bk001130 - from cvs1.17 (mkv), removed from linux_glimp.c\nvoid IN_StartupJoystick( void )\n{\n  int i = 0;\n\n  joy_fd = -1;\n\n  if( !in_joystick->integer ) {\n    Com_Printf( \"Joystick is not active.\\n\" );\n    return;\n  }\n\n  for( i = 0; i < 4; i++ ) {\n    char filename[PATH_MAX];\n\n    snprintf( filename, PATH_MAX, \"/dev/js%d\", i );\n\n    joy_fd = open( filename, O_RDONLY | O_NONBLOCK );\n\n    if( joy_fd != -1 ) {\n      struct js_event event;\n      char axes = 0;\n      char buttons = 0;\n      char name[128];\n      int n = -1;\n\n      Com_Printf( \"Joystick %s found\\n\", filename );\n\n      /* Get rid of initialization messages. */\n      do {\n\tn = read( joy_fd, &event, sizeof( event ) );\n\n\tif( n == -1 ) {\n\t  break;\n\t}\n\n      } while( ( event.type & JS_EVENT_INIT ) );\n\n      /* Get joystick statistics. */\n      ioctl( joy_fd, JSIOCGAXES, &axes );\n      ioctl( joy_fd, JSIOCGBUTTONS, &buttons );\n\n      if( ioctl( joy_fd, JSIOCGNAME( sizeof( name ) ), name ) < 0 ) {\n\tstrncpy( name, \"Unknown\", sizeof( name ) );\n      }\n\n      Com_Printf( \"Name:    %s\\n\", name );\n      Com_Printf( \"Axes:    %d\\n\", axes );\n      Com_Printf( \"Buttons: %d\\n\", buttons );\n\n      /* Our work here is done. */\n      return;\n    }\n\n  }\n\n  /* No soup for you. */\n  if( joy_fd == -1 ) {\n    Com_Printf( \"No joystick found.\\n\" );\n    return;\n  }\n\n}\n\nvoid IN_JoyMove( void )\n{\n  /* Store instantaneous joystick state. Hack to get around\n   * event model used in Linux joystick driver.\n\t */\n  static int axes_state[16];\n  /* Old bits for Quake-style input compares. */\n  static unsigned int old_axes = 0;\n  /* Our current goodies. */\n  unsigned int axes = 0;\n  int i = 0;\n\n  if( joy_fd == -1 ) {\n    return;\n  }\n\n  /* Empty the queue, dispatching button presses immediately\n\t * and updating the instantaneous state for the axes.\n\t */\n  do {\n    int n = -1;\n    struct js_event event;\n\n    n = read( joy_fd, &event, sizeof( event ) );\n\n    if( n == -1 ) {\n      /* No error, we're non-blocking. */\n      break;\n    }\n\n    if( event.type & JS_EVENT_BUTTON ) {\n      Sys_QueEvent( 0, SE_KEY, K_JOY1 + event.number, event.value, 0, NULL );\n    } else if( event.type & JS_EVENT_AXIS ) {\n\n      if( event.number >= 16 ) {\n\tcontinue;\n      }\n\n      axes_state[event.number] = event.value;\n    } else {\n      Com_Printf( \"Unknown joystick event type\\n\" );\n    }\n\n  } while( 1 );\n\n\n  /* Translate our instantaneous state to bits. */\n  for( i = 0; i < 16; i++ ) {\n    float f = ( (float) axes_state[i] ) / 32767.0f;\n\n    if( f < -joy_threshold->value ) {\n      axes |= ( 1 << ( i * 2 ) );\n    } else if( f > joy_threshold->value ) {\n      axes |= ( 1 << ( ( i * 2 ) + 1 ) );\n    }\n\n  }\n\n  /* Time to update axes state based on old vs. new. */\n  for( i = 0; i < 16; i++ ) {\n\n    if( ( axes & ( 1 << i ) ) && !( old_axes & ( 1 << i ) ) ) {\n      Sys_QueEvent( 0, SE_KEY, joy_keys[i], qtrue, 0, NULL );\n    }\n\n    if( !( axes & ( 1 << i ) ) && ( old_axes & ( 1 << i ) ) ) {\n      Sys_QueEvent( 0, SE_KEY, joy_keys[i], qfalse, 0, NULL );\n    }\n  }\n\n  /* Save for future generations. */\n  old_axes = axes;\n}\n\n\n"
  },
  {
    "path": "code/unix/linux_local.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// linux_local.h: Linux-specific Quake3 header file\n\nvoid Sys_QueEvent( int time, sysEventType_t type, int value, int value2, int ptrLength, void *ptr );\nqboolean Sys_GetPacket ( netadr_t *net_from, msg_t *net_message );\nvoid Sys_SendKeyEvents (void);\n\n// Input subsystem\n\nvoid IN_Init (void);\nvoid IN_Frame (void);\nvoid IN_Shutdown (void);\n\n\nvoid IN_JoyMove( void );\nvoid IN_StartupJoystick( void );\n\n// GL subsystem\nqboolean QGL_Init( const char *dllname );\nvoid QGL_EnableLogging( qboolean enable );\nvoid QGL_Shutdown( void );\n\n// bk001130 - win32\n// void IN_JoystickCommands (void);\n\nchar *strlwr (char *s);\n\n// signals.c\nvoid InitSig(void);\n"
  },
  {
    "path": "code/unix/linux_qgl.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n/*\n** LINUX_QGL.C\n**\n** This file implements the operating system binding of GL to QGL function\n** pointers.  When doing a port of Quake2 you must implement the following\n** two functions:\n**\n** QGL_Init() - loads libraries, assigns function pointers, etc.\n** QGL_Shutdown() - unloads libraries, NULLs function pointers\n*/\n\n// bk001204\n#include <unistd.h>\n#include <sys/types.h>\n\n\n#include <float.h>\n#include \"../renderer/tr_local.h\"\n#include \"unix_glw.h\"\n\n// bk001129 - from cvs1.17 (mkv)\n//#if defined(__FX__)\n//#include <GL/fxmesa.h>\n//#endif\n//#include <GL/glx.h> // bk010216 - FIXME: all of the above redundant? renderer/qgl.h\n\n#include <dlfcn.h>\n\n\n// bk001129 - from cvs1.17 (mkv)\n#if defined(__FX__)\n//FX Mesa Functions\nfxMesaContext (*qfxMesaCreateContext)(GLuint win, GrScreenResolution_t, GrScreenRefresh_t, const GLint attribList[]);\nfxMesaContext (*qfxMesaCreateBestContext)(GLuint win, GLint width, GLint height, const GLint attribList[]);\nvoid (*qfxMesaDestroyContext)(fxMesaContext ctx);\nvoid (*qfxMesaMakeCurrent)(fxMesaContext ctx);\nfxMesaContext (*qfxMesaGetCurrentContext)(void);\nvoid (*qfxMesaSwapBuffers)(void);\n#endif\n\n//GLX Functions\nXVisualInfo * (*qglXChooseVisual)( Display *dpy, int screen, int *attribList );\nGLXContext (*qglXCreateContext)( Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct );\nvoid (*qglXDestroyContext)( Display *dpy, GLXContext ctx );\nBool (*qglXMakeCurrent)( Display *dpy, GLXDrawable drawable, GLXContext ctx);\nvoid (*qglXCopyContext)( Display *dpy, GLXContext src, GLXContext dst, GLuint mask );\nvoid (*qglXSwapBuffers)( Display *dpy, GLXDrawable drawable );\n\nvoid ( APIENTRY * qglAccum )(GLenum op, GLfloat value);\nvoid ( APIENTRY * qglAlphaFunc )(GLenum func, GLclampf ref);\nGLboolean ( APIENTRY * qglAreTexturesResident )(GLsizei n, const GLuint *textures, GLboolean *residences);\nvoid ( APIENTRY * qglArrayElement )(GLint i);\nvoid ( APIENTRY * qglBegin )(GLenum mode);\nvoid ( APIENTRY * qglBindTexture )(GLenum target, GLuint texture);\nvoid ( APIENTRY * qglBitmap )(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);\nvoid ( APIENTRY * qglBlendFunc )(GLenum sfactor, GLenum dfactor);\nvoid ( APIENTRY * qglCallList )(GLuint list);\nvoid ( APIENTRY * qglCallLists )(GLsizei n, GLenum type, const GLvoid *lists);\nvoid ( APIENTRY * qglClear )(GLbitfield mask);\nvoid ( APIENTRY * qglClearAccum )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nvoid ( APIENTRY * qglClearColor )(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);\nvoid ( APIENTRY * qglClearDepth )(GLclampd depth);\nvoid ( APIENTRY * qglClearIndex )(GLfloat c);\nvoid ( APIENTRY * qglClearStencil )(GLint s);\nvoid ( APIENTRY * qglClipPlane )(GLenum plane, const GLdouble *equation);\nvoid ( APIENTRY * qglColor3b )(GLbyte red, GLbyte green, GLbyte blue);\nvoid ( APIENTRY * qglColor3bv )(const GLbyte *v);\nvoid ( APIENTRY * qglColor3d )(GLdouble red, GLdouble green, GLdouble blue);\nvoid ( APIENTRY * qglColor3dv )(const GLdouble *v);\nvoid ( APIENTRY * qglColor3f )(GLfloat red, GLfloat green, GLfloat blue);\nvoid ( APIENTRY * qglColor3fv )(const GLfloat *v);\nvoid ( APIENTRY * qglColor3i )(GLint red, GLint green, GLint blue);\nvoid ( APIENTRY * qglColor3iv )(const GLint *v);\nvoid ( APIENTRY * qglColor3s )(GLshort red, GLshort green, GLshort blue);\nvoid ( APIENTRY * qglColor3sv )(const GLshort *v);\nvoid ( APIENTRY * qglColor3ub )(GLubyte red, GLubyte green, GLubyte blue);\nvoid ( APIENTRY * qglColor3ubv )(const GLubyte *v);\nvoid ( APIENTRY * qglColor3ui )(GLuint red, GLuint green, GLuint blue);\nvoid ( APIENTRY * qglColor3uiv )(const GLuint *v);\nvoid ( APIENTRY * qglColor3us )(GLushort red, GLushort green, GLushort blue);\nvoid ( APIENTRY * qglColor3usv )(const GLushort *v);\nvoid ( APIENTRY * qglColor4b )(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha);\nvoid ( APIENTRY * qglColor4bv )(const GLbyte *v);\nvoid ( APIENTRY * qglColor4d )(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);\nvoid ( APIENTRY * qglColor4dv )(const GLdouble *v);\nvoid ( APIENTRY * qglColor4f )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nvoid ( APIENTRY * qglColor4fv )(const GLfloat *v);\nvoid ( APIENTRY * qglColor4i )(GLint red, GLint green, GLint blue, GLint alpha);\nvoid ( APIENTRY * qglColor4iv )(const GLint *v);\nvoid ( APIENTRY * qglColor4s )(GLshort red, GLshort green, GLshort blue, GLshort alpha);\nvoid ( APIENTRY * qglColor4sv )(const GLshort *v);\nvoid ( APIENTRY * qglColor4ub )(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);\nvoid ( APIENTRY * qglColor4ubv )(const GLubyte *v);\nvoid ( APIENTRY * qglColor4ui )(GLuint red, GLuint green, GLuint blue, GLuint alpha);\nvoid ( APIENTRY * qglColor4uiv )(const GLuint *v);\nvoid ( APIENTRY * qglColor4us )(GLushort red, GLushort green, GLushort blue, GLushort alpha);\nvoid ( APIENTRY * qglColor4usv )(const GLushort *v);\nvoid ( APIENTRY * qglColorMask )(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);\nvoid ( APIENTRY * qglColorMaterial )(GLenum face, GLenum mode);\nvoid ( APIENTRY * qglColorPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglCopyPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);\nvoid ( APIENTRY * qglCopyTexImage1D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border);\nvoid ( APIENTRY * qglCopyTexImage2D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\nvoid ( APIENTRY * qglCopyTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\nvoid ( APIENTRY * qglCopyTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nvoid ( APIENTRY * qglCullFace )(GLenum mode);\nvoid ( APIENTRY * qglDeleteLists )(GLuint list, GLsizei range);\nvoid ( APIENTRY * qglDeleteTextures )(GLsizei n, const GLuint *textures);\nvoid ( APIENTRY * qglDepthFunc )(GLenum func);\nvoid ( APIENTRY * qglDepthMask )(GLboolean flag);\nvoid ( APIENTRY * qglDepthRange )(GLclampd zNear, GLclampd zFar);\nvoid ( APIENTRY * qglDisable )(GLenum cap);\nvoid ( APIENTRY * qglDisableClientState )(GLenum array);\nvoid ( APIENTRY * qglDrawArrays )(GLenum mode, GLint first, GLsizei count);\nvoid ( APIENTRY * qglDrawBuffer )(GLenum mode);\nvoid ( APIENTRY * qglDrawElements )(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);\nvoid ( APIENTRY * qglDrawPixels )(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nvoid ( APIENTRY * qglEdgeFlag )(GLboolean flag);\nvoid ( APIENTRY * qglEdgeFlagPointer )(GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglEdgeFlagv )(const GLboolean *flag);\nvoid ( APIENTRY * qglEnable )(GLenum cap);\nvoid ( APIENTRY * qglEnableClientState )(GLenum array);\nvoid ( APIENTRY * qglEnd )(void);\nvoid ( APIENTRY * qglEndList )(void);\nvoid ( APIENTRY * qglEvalCoord1d )(GLdouble u);\nvoid ( APIENTRY * qglEvalCoord1dv )(const GLdouble *u);\nvoid ( APIENTRY * qglEvalCoord1f )(GLfloat u);\nvoid ( APIENTRY * qglEvalCoord1fv )(const GLfloat *u);\nvoid ( APIENTRY * qglEvalCoord2d )(GLdouble u, GLdouble v);\nvoid ( APIENTRY * qglEvalCoord2dv )(const GLdouble *u);\nvoid ( APIENTRY * qglEvalCoord2f )(GLfloat u, GLfloat v);\nvoid ( APIENTRY * qglEvalCoord2fv )(const GLfloat *u);\nvoid ( APIENTRY * qglEvalMesh1 )(GLenum mode, GLint i1, GLint i2);\nvoid ( APIENTRY * qglEvalMesh2 )(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);\nvoid ( APIENTRY * qglEvalPoint1 )(GLint i);\nvoid ( APIENTRY * qglEvalPoint2 )(GLint i, GLint j);\nvoid ( APIENTRY * qglFeedbackBuffer )(GLsizei size, GLenum type, GLfloat *buffer);\nvoid ( APIENTRY * qglFinish )(void);\nvoid ( APIENTRY * qglFlush )(void);\nvoid ( APIENTRY * qglFogf )(GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglFogfv )(GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglFogi )(GLenum pname, GLint param);\nvoid ( APIENTRY * qglFogiv )(GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglFrontFace )(GLenum mode);\nvoid ( APIENTRY * qglFrustum )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nGLuint ( APIENTRY * qglGenLists )(GLsizei range);\nvoid ( APIENTRY * qglGenTextures )(GLsizei n, GLuint *textures);\nvoid ( APIENTRY * qglGetBooleanv )(GLenum pname, GLboolean *params);\nvoid ( APIENTRY * qglGetClipPlane )(GLenum plane, GLdouble *equation);\nvoid ( APIENTRY * qglGetDoublev )(GLenum pname, GLdouble *params);\nGLenum ( APIENTRY * qglGetError )(void);\nvoid ( APIENTRY * qglGetFloatv )(GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetIntegerv )(GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetLightfv )(GLenum light, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetLightiv )(GLenum light, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetMapdv )(GLenum target, GLenum query, GLdouble *v);\nvoid ( APIENTRY * qglGetMapfv )(GLenum target, GLenum query, GLfloat *v);\nvoid ( APIENTRY * qglGetMapiv )(GLenum target, GLenum query, GLint *v);\nvoid ( APIENTRY * qglGetMaterialfv )(GLenum face, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetMaterialiv )(GLenum face, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetPixelMapfv )(GLenum map, GLfloat *values);\nvoid ( APIENTRY * qglGetPixelMapuiv )(GLenum map, GLuint *values);\nvoid ( APIENTRY * qglGetPixelMapusv )(GLenum map, GLushort *values);\nvoid ( APIENTRY * qglGetPointerv )(GLenum pname, GLvoid* *params);\nvoid ( APIENTRY * qglGetPolygonStipple )(GLubyte *mask);\nconst GLubyte * ( APIENTRY * qglGetString )(GLenum name);\nvoid ( APIENTRY * qglGetTexEnvfv )(GLenum target, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetTexEnviv )(GLenum target, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetTexGendv )(GLenum coord, GLenum pname, GLdouble *params);\nvoid ( APIENTRY * qglGetTexGenfv )(GLenum coord, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetTexGeniv )(GLenum coord, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetTexImage )(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);\nvoid ( APIENTRY * qglGetTexLevelParameterfv )(GLenum target, GLint level, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetTexLevelParameteriv )(GLenum target, GLint level, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetTexParameterfv )(GLenum target, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetTexParameteriv )(GLenum target, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglHint )(GLenum target, GLenum mode);\nvoid ( APIENTRY * qglIndexMask )(GLuint mask);\nvoid ( APIENTRY * qglIndexPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglIndexd )(GLdouble c);\nvoid ( APIENTRY * qglIndexdv )(const GLdouble *c);\nvoid ( APIENTRY * qglIndexf )(GLfloat c);\nvoid ( APIENTRY * qglIndexfv )(const GLfloat *c);\nvoid ( APIENTRY * qglIndexi )(GLint c);\nvoid ( APIENTRY * qglIndexiv )(const GLint *c);\nvoid ( APIENTRY * qglIndexs )(GLshort c);\nvoid ( APIENTRY * qglIndexsv )(const GLshort *c);\nvoid ( APIENTRY * qglIndexub )(GLubyte c);\nvoid ( APIENTRY * qglIndexubv )(const GLubyte *c);\nvoid ( APIENTRY * qglInitNames )(void);\nvoid ( APIENTRY * qglInterleavedArrays )(GLenum format, GLsizei stride, const GLvoid *pointer);\nGLboolean ( APIENTRY * qglIsEnabled )(GLenum cap);\nGLboolean ( APIENTRY * qglIsList )(GLuint list);\nGLboolean ( APIENTRY * qglIsTexture )(GLuint texture);\nvoid ( APIENTRY * qglLightModelf )(GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglLightModelfv )(GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglLightModeli )(GLenum pname, GLint param);\nvoid ( APIENTRY * qglLightModeliv )(GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglLightf )(GLenum light, GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglLightfv )(GLenum light, GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglLighti )(GLenum light, GLenum pname, GLint param);\nvoid ( APIENTRY * qglLightiv )(GLenum light, GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglLineStipple )(GLint factor, GLushort pattern);\nvoid ( APIENTRY * qglLineWidth )(GLfloat width);\nvoid ( APIENTRY * qglListBase )(GLuint base);\nvoid ( APIENTRY * qglLoadIdentity )(void);\nvoid ( APIENTRY * qglLoadMatrixd )(const GLdouble *m);\nvoid ( APIENTRY * qglLoadMatrixf )(const GLfloat *m);\nvoid ( APIENTRY * qglLoadName )(GLuint name);\nvoid ( APIENTRY * qglLogicOp )(GLenum opcode);\nvoid ( APIENTRY * qglMap1d )(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);\nvoid ( APIENTRY * qglMap1f )(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);\nvoid ( APIENTRY * qglMap2d )(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);\nvoid ( APIENTRY * qglMap2f )(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);\nvoid ( APIENTRY * qglMapGrid1d )(GLint un, GLdouble u1, GLdouble u2);\nvoid ( APIENTRY * qglMapGrid1f )(GLint un, GLfloat u1, GLfloat u2);\nvoid ( APIENTRY * qglMapGrid2d )(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);\nvoid ( APIENTRY * qglMapGrid2f )(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);\nvoid ( APIENTRY * qglMaterialf )(GLenum face, GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglMaterialfv )(GLenum face, GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglMateriali )(GLenum face, GLenum pname, GLint param);\nvoid ( APIENTRY * qglMaterialiv )(GLenum face, GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglMatrixMode )(GLenum mode);\nvoid ( APIENTRY * qglMultMatrixd )(const GLdouble *m);\nvoid ( APIENTRY * qglMultMatrixf )(const GLfloat *m);\nvoid ( APIENTRY * qglNewList )(GLuint list, GLenum mode);\nvoid ( APIENTRY * qglNormal3b )(GLbyte nx, GLbyte ny, GLbyte nz);\nvoid ( APIENTRY * qglNormal3bv )(const GLbyte *v);\nvoid ( APIENTRY * qglNormal3d )(GLdouble nx, GLdouble ny, GLdouble nz);\nvoid ( APIENTRY * qglNormal3dv )(const GLdouble *v);\nvoid ( APIENTRY * qglNormal3f )(GLfloat nx, GLfloat ny, GLfloat nz);\nvoid ( APIENTRY * qglNormal3fv )(const GLfloat *v);\nvoid ( APIENTRY * qglNormal3i )(GLint nx, GLint ny, GLint nz);\nvoid ( APIENTRY * qglNormal3iv )(const GLint *v);\nvoid ( APIENTRY * qglNormal3s )(GLshort nx, GLshort ny, GLshort nz);\nvoid ( APIENTRY * qglNormal3sv )(const GLshort *v);\nvoid ( APIENTRY * qglNormalPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglOrtho )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nvoid ( APIENTRY * qglPassThrough )(GLfloat token);\nvoid ( APIENTRY * qglPixelMapfv )(GLenum map, GLsizei mapsize, const GLfloat *values);\nvoid ( APIENTRY * qglPixelMapuiv )(GLenum map, GLsizei mapsize, const GLuint *values);\nvoid ( APIENTRY * qglPixelMapusv )(GLenum map, GLsizei mapsize, const GLushort *values);\nvoid ( APIENTRY * qglPixelStoref )(GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglPixelStorei )(GLenum pname, GLint param);\nvoid ( APIENTRY * qglPixelTransferf )(GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglPixelTransferi )(GLenum pname, GLint param);\nvoid ( APIENTRY * qglPixelZoom )(GLfloat xfactor, GLfloat yfactor);\nvoid ( APIENTRY * qglPointSize )(GLfloat size);\nvoid ( APIENTRY * qglPolygonMode )(GLenum face, GLenum mode);\nvoid ( APIENTRY * qglPolygonOffset )(GLfloat factor, GLfloat units);\nvoid ( APIENTRY * qglPolygonStipple )(const GLubyte *mask);\nvoid ( APIENTRY * qglPopAttrib )(void);\nvoid ( APIENTRY * qglPopClientAttrib )(void);\nvoid ( APIENTRY * qglPopMatrix )(void);\nvoid ( APIENTRY * qglPopName )(void);\nvoid ( APIENTRY * qglPrioritizeTextures )(GLsizei n, const GLuint *textures, const GLclampf *priorities);\nvoid ( APIENTRY * qglPushAttrib )(GLbitfield mask);\nvoid ( APIENTRY * qglPushClientAttrib )(GLbitfield mask);\nvoid ( APIENTRY * qglPushMatrix )(void);\nvoid ( APIENTRY * qglPushName )(GLuint name);\nvoid ( APIENTRY * qglRasterPos2d )(GLdouble x, GLdouble y);\nvoid ( APIENTRY * qglRasterPos2dv )(const GLdouble *v);\nvoid ( APIENTRY * qglRasterPos2f )(GLfloat x, GLfloat y);\nvoid ( APIENTRY * qglRasterPos2fv )(const GLfloat *v);\nvoid ( APIENTRY * qglRasterPos2i )(GLint x, GLint y);\nvoid ( APIENTRY * qglRasterPos2iv )(const GLint *v);\nvoid ( APIENTRY * qglRasterPos2s )(GLshort x, GLshort y);\nvoid ( APIENTRY * qglRasterPos2sv )(const GLshort *v);\nvoid ( APIENTRY * qglRasterPos3d )(GLdouble x, GLdouble y, GLdouble z);\nvoid ( APIENTRY * qglRasterPos3dv )(const GLdouble *v);\nvoid ( APIENTRY * qglRasterPos3f )(GLfloat x, GLfloat y, GLfloat z);\nvoid ( APIENTRY * qglRasterPos3fv )(const GLfloat *v);\nvoid ( APIENTRY * qglRasterPos3i )(GLint x, GLint y, GLint z);\nvoid ( APIENTRY * qglRasterPos3iv )(const GLint *v);\nvoid ( APIENTRY * qglRasterPos3s )(GLshort x, GLshort y, GLshort z);\nvoid ( APIENTRY * qglRasterPos3sv )(const GLshort *v);\nvoid ( APIENTRY * qglRasterPos4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nvoid ( APIENTRY * qglRasterPos4dv )(const GLdouble *v);\nvoid ( APIENTRY * qglRasterPos4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nvoid ( APIENTRY * qglRasterPos4fv )(const GLfloat *v);\nvoid ( APIENTRY * qglRasterPos4i )(GLint x, GLint y, GLint z, GLint w);\nvoid ( APIENTRY * qglRasterPos4iv )(const GLint *v);\nvoid ( APIENTRY * qglRasterPos4s )(GLshort x, GLshort y, GLshort z, GLshort w);\nvoid ( APIENTRY * qglRasterPos4sv )(const GLshort *v);\nvoid ( APIENTRY * qglReadBuffer )(GLenum mode);\nvoid ( APIENTRY * qglReadPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);\nvoid ( APIENTRY * qglRectd )(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);\nvoid ( APIENTRY * qglRectdv )(const GLdouble *v1, const GLdouble *v2);\nvoid ( APIENTRY * qglRectf )(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);\nvoid ( APIENTRY * qglRectfv )(const GLfloat *v1, const GLfloat *v2);\nvoid ( APIENTRY * qglRecti )(GLint x1, GLint y1, GLint x2, GLint y2);\nvoid ( APIENTRY * qglRectiv )(const GLint *v1, const GLint *v2);\nvoid ( APIENTRY * qglRects )(GLshort x1, GLshort y1, GLshort x2, GLshort y2);\nvoid ( APIENTRY * qglRectsv )(const GLshort *v1, const GLshort *v2);\nGLint ( APIENTRY * qglRenderMode )(GLenum mode);\nvoid ( APIENTRY * qglRotated )(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);\nvoid ( APIENTRY * qglRotatef )(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);\nvoid ( APIENTRY * qglScaled )(GLdouble x, GLdouble y, GLdouble z);\nvoid ( APIENTRY * qglScalef )(GLfloat x, GLfloat y, GLfloat z);\nvoid ( APIENTRY * qglScissor )(GLint x, GLint y, GLsizei width, GLsizei height);\nvoid ( APIENTRY * qglSelectBuffer )(GLsizei size, GLuint *buffer);\nvoid ( APIENTRY * qglShadeModel )(GLenum mode);\nvoid ( APIENTRY * qglStencilFunc )(GLenum func, GLint ref, GLuint mask);\nvoid ( APIENTRY * qglStencilMask )(GLuint mask);\nvoid ( APIENTRY * qglStencilOp )(GLenum fail, GLenum zfail, GLenum zpass);\nvoid ( APIENTRY * qglTexCoord1d )(GLdouble s);\nvoid ( APIENTRY * qglTexCoord1dv )(const GLdouble *v);\nvoid ( APIENTRY * qglTexCoord1f )(GLfloat s);\nvoid ( APIENTRY * qglTexCoord1fv )(const GLfloat *v);\nvoid ( APIENTRY * qglTexCoord1i )(GLint s);\nvoid ( APIENTRY * qglTexCoord1iv )(const GLint *v);\nvoid ( APIENTRY * qglTexCoord1s )(GLshort s);\nvoid ( APIENTRY * qglTexCoord1sv )(const GLshort *v);\nvoid ( APIENTRY * qglTexCoord2d )(GLdouble s, GLdouble t);\nvoid ( APIENTRY * qglTexCoord2dv )(const GLdouble *v);\nvoid ( APIENTRY * qglTexCoord2f )(GLfloat s, GLfloat t);\nvoid ( APIENTRY * qglTexCoord2fv )(const GLfloat *v);\nvoid ( APIENTRY * qglTexCoord2i )(GLint s, GLint t);\nvoid ( APIENTRY * qglTexCoord2iv )(const GLint *v);\nvoid ( APIENTRY * qglTexCoord2s )(GLshort s, GLshort t);\nvoid ( APIENTRY * qglTexCoord2sv )(const GLshort *v);\nvoid ( APIENTRY * qglTexCoord3d )(GLdouble s, GLdouble t, GLdouble r);\nvoid ( APIENTRY * qglTexCoord3dv )(const GLdouble *v);\nvoid ( APIENTRY * qglTexCoord3f )(GLfloat s, GLfloat t, GLfloat r);\nvoid ( APIENTRY * qglTexCoord3fv )(const GLfloat *v);\nvoid ( APIENTRY * qglTexCoord3i )(GLint s, GLint t, GLint r);\nvoid ( APIENTRY * qglTexCoord3iv )(const GLint *v);\nvoid ( APIENTRY * qglTexCoord3s )(GLshort s, GLshort t, GLshort r);\nvoid ( APIENTRY * qglTexCoord3sv )(const GLshort *v);\nvoid ( APIENTRY * qglTexCoord4d )(GLdouble s, GLdouble t, GLdouble r, GLdouble q);\nvoid ( APIENTRY * qglTexCoord4dv )(const GLdouble *v);\nvoid ( APIENTRY * qglTexCoord4f )(GLfloat s, GLfloat t, GLfloat r, GLfloat q);\nvoid ( APIENTRY * qglTexCoord4fv )(const GLfloat *v);\nvoid ( APIENTRY * qglTexCoord4i )(GLint s, GLint t, GLint r, GLint q);\nvoid ( APIENTRY * qglTexCoord4iv )(const GLint *v);\nvoid ( APIENTRY * qglTexCoord4s )(GLshort s, GLshort t, GLshort r, GLshort q);\nvoid ( APIENTRY * qglTexCoord4sv )(const GLshort *v);\nvoid ( APIENTRY * qglTexCoordPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglTexEnvf )(GLenum target, GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglTexEnvfv )(GLenum target, GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglTexEnvi )(GLenum target, GLenum pname, GLint param);\nvoid ( APIENTRY * qglTexEnviv )(GLenum target, GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglTexGend )(GLenum coord, GLenum pname, GLdouble param);\nvoid ( APIENTRY * qglTexGendv )(GLenum coord, GLenum pname, const GLdouble *params);\nvoid ( APIENTRY * qglTexGenf )(GLenum coord, GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglTexGenfv )(GLenum coord, GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglTexGeni )(GLenum coord, GLenum pname, GLint param);\nvoid ( APIENTRY * qglTexGeniv )(GLenum coord, GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglTexImage1D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nvoid ( APIENTRY * qglTexImage2D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nvoid ( APIENTRY * qglTexParameterf )(GLenum target, GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglTexParameterfv )(GLenum target, GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglTexParameteri )(GLenum target, GLenum pname, GLint param);\nvoid ( APIENTRY * qglTexParameteriv )(GLenum target, GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);\nvoid ( APIENTRY * qglTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nvoid ( APIENTRY * qglTranslated )(GLdouble x, GLdouble y, GLdouble z);\nvoid ( APIENTRY * qglTranslatef )(GLfloat x, GLfloat y, GLfloat z);\nvoid ( APIENTRY * qglVertex2d )(GLdouble x, GLdouble y);\nvoid ( APIENTRY * qglVertex2dv )(const GLdouble *v);\nvoid ( APIENTRY * qglVertex2f )(GLfloat x, GLfloat y);\nvoid ( APIENTRY * qglVertex2fv )(const GLfloat *v);\nvoid ( APIENTRY * qglVertex2i )(GLint x, GLint y);\nvoid ( APIENTRY * qglVertex2iv )(const GLint *v);\nvoid ( APIENTRY * qglVertex2s )(GLshort x, GLshort y);\nvoid ( APIENTRY * qglVertex2sv )(const GLshort *v);\nvoid ( APIENTRY * qglVertex3d )(GLdouble x, GLdouble y, GLdouble z);\nvoid ( APIENTRY * qglVertex3dv )(const GLdouble *v);\nvoid ( APIENTRY * qglVertex3f )(GLfloat x, GLfloat y, GLfloat z);\nvoid ( APIENTRY * qglVertex3fv )(const GLfloat *v);\nvoid ( APIENTRY * qglVertex3i )(GLint x, GLint y, GLint z);\nvoid ( APIENTRY * qglVertex3iv )(const GLint *v);\nvoid ( APIENTRY * qglVertex3s )(GLshort x, GLshort y, GLshort z);\nvoid ( APIENTRY * qglVertex3sv )(const GLshort *v);\nvoid ( APIENTRY * qglVertex4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nvoid ( APIENTRY * qglVertex4dv )(const GLdouble *v);\nvoid ( APIENTRY * qglVertex4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nvoid ( APIENTRY * qglVertex4fv )(const GLfloat *v);\nvoid ( APIENTRY * qglVertex4i )(GLint x, GLint y, GLint z, GLint w);\nvoid ( APIENTRY * qglVertex4iv )(const GLint *v);\nvoid ( APIENTRY * qglVertex4s )(GLshort x, GLshort y, GLshort z, GLshort w);\nvoid ( APIENTRY * qglVertex4sv )(const GLshort *v);\nvoid ( APIENTRY * qglVertexPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglViewport )(GLint x, GLint y, GLsizei width, GLsizei height);\n\nvoid ( APIENTRY * qglMultiTexCoord2fARB )( GLenum texture, GLfloat s, GLfloat t );\nvoid ( APIENTRY * qglActiveTextureARB )( GLenum texture );\nvoid ( APIENTRY * qglClientActiveTextureARB )( GLenum texture );\n\nvoid ( APIENTRY * qglLockArraysEXT)( int, int);\nvoid ( APIENTRY * qglUnlockArraysEXT) ( void );\n\nvoid ( APIENTRY * qglPointParameterfEXT)( GLenum param, GLfloat value );\nvoid ( APIENTRY * qglPointParameterfvEXT)( GLenum param, const GLfloat *value );\nvoid ( APIENTRY * qglColorTableEXT)( int, int, int, int, int, const void * );\nvoid ( APIENTRY * qgl3DfxSetPaletteEXT)( GLuint * );\nvoid ( APIENTRY * qglSelectTextureSGIS)( GLenum );\nvoid ( APIENTRY * qglMTexCoord2fSGIS)( GLenum, GLfloat, GLfloat );\n\nstatic void ( APIENTRY * dllAccum )(GLenum op, GLfloat value);\nstatic void ( APIENTRY * dllAlphaFunc )(GLenum func, GLclampf ref);\nGLboolean ( APIENTRY * dllAreTexturesResident )(GLsizei n, const GLuint *textures, GLboolean *residences);\nstatic void ( APIENTRY * dllArrayElement )(GLint i);\nstatic void ( APIENTRY * dllBegin )(GLenum mode);\nstatic void ( APIENTRY * dllBindTexture )(GLenum target, GLuint texture);\nstatic void ( APIENTRY * dllBitmap )(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);\nstatic void ( APIENTRY * dllBlendFunc )(GLenum sfactor, GLenum dfactor);\nstatic void ( APIENTRY * dllCallList )(GLuint list);\nstatic void ( APIENTRY * dllCallLists )(GLsizei n, GLenum type, const GLvoid *lists);\nstatic void ( APIENTRY * dllClear )(GLbitfield mask);\nstatic void ( APIENTRY * dllClearAccum )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nstatic void ( APIENTRY * dllClearColor )(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);\nstatic void ( APIENTRY * dllClearDepth )(GLclampd depth);\nstatic void ( APIENTRY * dllClearIndex )(GLfloat c);\nstatic void ( APIENTRY * dllClearStencil )(GLint s);\nstatic void ( APIENTRY * dllClipPlane )(GLenum plane, const GLdouble *equation);\nstatic void ( APIENTRY * dllColor3b )(GLbyte red, GLbyte green, GLbyte blue);\nstatic void ( APIENTRY * dllColor3bv )(const GLbyte *v);\nstatic void ( APIENTRY * dllColor3d )(GLdouble red, GLdouble green, GLdouble blue);\nstatic void ( APIENTRY * dllColor3dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllColor3f )(GLfloat red, GLfloat green, GLfloat blue);\nstatic void ( APIENTRY * dllColor3fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllColor3i )(GLint red, GLint green, GLint blue);\nstatic void ( APIENTRY * dllColor3iv )(const GLint *v);\nstatic void ( APIENTRY * dllColor3s )(GLshort red, GLshort green, GLshort blue);\nstatic void ( APIENTRY * dllColor3sv )(const GLshort *v);\nstatic void ( APIENTRY * dllColor3ub )(GLubyte red, GLubyte green, GLubyte blue);\nstatic void ( APIENTRY * dllColor3ubv )(const GLubyte *v);\nstatic void ( APIENTRY * dllColor3ui )(GLuint red, GLuint green, GLuint blue);\nstatic void ( APIENTRY * dllColor3uiv )(const GLuint *v);\nstatic void ( APIENTRY * dllColor3us )(GLushort red, GLushort green, GLushort blue);\nstatic void ( APIENTRY * dllColor3usv )(const GLushort *v);\nstatic void ( APIENTRY * dllColor4b )(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha);\nstatic void ( APIENTRY * dllColor4bv )(const GLbyte *v);\nstatic void ( APIENTRY * dllColor4d )(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);\nstatic void ( APIENTRY * dllColor4dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllColor4f )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nstatic void ( APIENTRY * dllColor4fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllColor4i )(GLint red, GLint green, GLint blue, GLint alpha);\nstatic void ( APIENTRY * dllColor4iv )(const GLint *v);\nstatic void ( APIENTRY * dllColor4s )(GLshort red, GLshort green, GLshort blue, GLshort alpha);\nstatic void ( APIENTRY * dllColor4sv )(const GLshort *v);\nstatic void ( APIENTRY * dllColor4ub )(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);\nstatic void ( APIENTRY * dllColor4ubv )(const GLubyte *v);\nstatic void ( APIENTRY * dllColor4ui )(GLuint red, GLuint green, GLuint blue, GLuint alpha);\nstatic void ( APIENTRY * dllColor4uiv )(const GLuint *v);\nstatic void ( APIENTRY * dllColor4us )(GLushort red, GLushort green, GLushort blue, GLushort alpha);\nstatic void ( APIENTRY * dllColor4usv )(const GLushort *v);\nstatic void ( APIENTRY * dllColorMask )(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);\nstatic void ( APIENTRY * dllColorMaterial )(GLenum face, GLenum mode);\nstatic void ( APIENTRY * dllColorPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nstatic void ( APIENTRY * dllCopyPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);\nstatic void ( APIENTRY * dllCopyTexImage1D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border);\nstatic void ( APIENTRY * dllCopyTexImage2D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\nstatic void ( APIENTRY * dllCopyTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\nstatic void ( APIENTRY * dllCopyTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nstatic void ( APIENTRY * dllCullFace )(GLenum mode);\nstatic void ( APIENTRY * dllDeleteLists )(GLuint list, GLsizei range);\nstatic void ( APIENTRY * dllDeleteTextures )(GLsizei n, const GLuint *textures);\nstatic void ( APIENTRY * dllDepthFunc )(GLenum func);\nstatic void ( APIENTRY * dllDepthMask )(GLboolean flag);\nstatic void ( APIENTRY * dllDepthRange )(GLclampd zNear, GLclampd zFar);\nstatic void ( APIENTRY * dllDisable )(GLenum cap);\nstatic void ( APIENTRY * dllDisableClientState )(GLenum array);\nstatic void ( APIENTRY * dllDrawArrays )(GLenum mode, GLint first, GLsizei count);\nstatic void ( APIENTRY * dllDrawBuffer )(GLenum mode);\nstatic void ( APIENTRY * dllDrawElements )(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);\nstatic void ( APIENTRY * dllDrawPixels )(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nstatic void ( APIENTRY * dllEdgeFlag )(GLboolean flag);\nstatic void ( APIENTRY * dllEdgeFlagPointer )(GLsizei stride, const GLvoid *pointer);\nstatic void ( APIENTRY * dllEdgeFlagv )(const GLboolean *flag);\nstatic void ( APIENTRY * dllEnable )(GLenum cap);\nstatic void ( APIENTRY * dllEnableClientState )(GLenum array);\nstatic void ( APIENTRY * dllEnd )(void);\nstatic void ( APIENTRY * dllEndList )(void);\nstatic void ( APIENTRY * dllEvalCoord1d )(GLdouble u);\nstatic void ( APIENTRY * dllEvalCoord1dv )(const GLdouble *u);\nstatic void ( APIENTRY * dllEvalCoord1f )(GLfloat u);\nstatic void ( APIENTRY * dllEvalCoord1fv )(const GLfloat *u);\nstatic void ( APIENTRY * dllEvalCoord2d )(GLdouble u, GLdouble v);\nstatic void ( APIENTRY * dllEvalCoord2dv )(const GLdouble *u);\nstatic void ( APIENTRY * dllEvalCoord2f )(GLfloat u, GLfloat v);\nstatic void ( APIENTRY * dllEvalCoord2fv )(const GLfloat *u);\nstatic void ( APIENTRY * dllEvalMesh1 )(GLenum mode, GLint i1, GLint i2);\nstatic void ( APIENTRY * dllEvalMesh2 )(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);\nstatic void ( APIENTRY * dllEvalPoint1 )(GLint i);\nstatic void ( APIENTRY * dllEvalPoint2 )(GLint i, GLint j);\nstatic void ( APIENTRY * dllFeedbackBuffer )(GLsizei size, GLenum type, GLfloat *buffer);\nstatic void ( APIENTRY * dllFinish )(void);\nstatic void ( APIENTRY * dllFlush )(void);\nstatic void ( APIENTRY * dllFogf )(GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllFogfv )(GLenum pname, const GLfloat *params);\nstatic void ( APIENTRY * dllFogi )(GLenum pname, GLint param);\nstatic void ( APIENTRY * dllFogiv )(GLenum pname, const GLint *params);\nstatic void ( APIENTRY * dllFrontFace )(GLenum mode);\nstatic void ( APIENTRY * dllFrustum )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nGLuint ( APIENTRY * dllGenLists )(GLsizei range);\nstatic void ( APIENTRY * dllGenTextures )(GLsizei n, GLuint *textures);\nstatic void ( APIENTRY * dllGetBooleanv )(GLenum pname, GLboolean *params);\nstatic void ( APIENTRY * dllGetClipPlane )(GLenum plane, GLdouble *equation);\nstatic void ( APIENTRY * dllGetDoublev )(GLenum pname, GLdouble *params);\nGLenum ( APIENTRY * dllGetError )(void);\nstatic void ( APIENTRY * dllGetFloatv )(GLenum pname, GLfloat *params);\nstatic void ( APIENTRY * dllGetIntegerv )(GLenum pname, GLint *params);\nstatic void ( APIENTRY * dllGetLightfv )(GLenum light, GLenum pname, GLfloat *params);\nstatic void ( APIENTRY * dllGetLightiv )(GLenum light, GLenum pname, GLint *params);\nstatic void ( APIENTRY * dllGetMapdv )(GLenum target, GLenum query, GLdouble *v);\nstatic void ( APIENTRY * dllGetMapfv )(GLenum target, GLenum query, GLfloat *v);\nstatic void ( APIENTRY * dllGetMapiv )(GLenum target, GLenum query, GLint *v);\nstatic void ( APIENTRY * dllGetMaterialfv )(GLenum face, GLenum pname, GLfloat *params);\nstatic void ( APIENTRY * dllGetMaterialiv )(GLenum face, GLenum pname, GLint *params);\nstatic void ( APIENTRY * dllGetPixelMapfv )(GLenum map, GLfloat *values);\nstatic void ( APIENTRY * dllGetPixelMapuiv )(GLenum map, GLuint *values);\nstatic void ( APIENTRY * dllGetPixelMapusv )(GLenum map, GLushort *values);\nstatic void ( APIENTRY * dllGetPointerv )(GLenum pname, GLvoid* *params);\nstatic void ( APIENTRY * dllGetPolygonStipple )(GLubyte *mask);\nconst GLubyte * ( APIENTRY * dllGetString )(GLenum name);\nstatic void ( APIENTRY * dllGetTexEnvfv )(GLenum target, GLenum pname, GLfloat *params);\nstatic void ( APIENTRY * dllGetTexEnviv )(GLenum target, GLenum pname, GLint *params);\nstatic void ( APIENTRY * dllGetTexGendv )(GLenum coord, GLenum pname, GLdouble *params);\nstatic void ( APIENTRY * dllGetTexGenfv )(GLenum coord, GLenum pname, GLfloat *params);\nstatic void ( APIENTRY * dllGetTexGeniv )(GLenum coord, GLenum pname, GLint *params);\nstatic void ( APIENTRY * dllGetTexImage )(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);\nstatic void ( APIENTRY * dllGetTexLevelParameterfv )(GLenum target, GLint level, GLenum pname, GLfloat *params);\nstatic void ( APIENTRY * dllGetTexLevelParameteriv )(GLenum target, GLint level, GLenum pname, GLint *params);\nstatic void ( APIENTRY * dllGetTexParameterfv )(GLenum target, GLenum pname, GLfloat *params);\nstatic void ( APIENTRY * dllGetTexParameteriv )(GLenum target, GLenum pname, GLint *params);\nstatic void ( APIENTRY * dllHint )(GLenum target, GLenum mode);\nstatic void ( APIENTRY * dllIndexMask )(GLuint mask);\nstatic void ( APIENTRY * dllIndexPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);\nstatic void ( APIENTRY * dllIndexd )(GLdouble c);\nstatic void ( APIENTRY * dllIndexdv )(const GLdouble *c);\nstatic void ( APIENTRY * dllIndexf )(GLfloat c);\nstatic void ( APIENTRY * dllIndexfv )(const GLfloat *c);\nstatic void ( APIENTRY * dllIndexi )(GLint c);\nstatic void ( APIENTRY * dllIndexiv )(const GLint *c);\nstatic void ( APIENTRY * dllIndexs )(GLshort c);\nstatic void ( APIENTRY * dllIndexsv )(const GLshort *c);\nstatic void ( APIENTRY * dllIndexub )(GLubyte c);\nstatic void ( APIENTRY * dllIndexubv )(const GLubyte *c);\nstatic void ( APIENTRY * dllInitNames )(void);\nstatic void ( APIENTRY * dllInterleavedArrays )(GLenum format, GLsizei stride, const GLvoid *pointer);\nGLboolean ( APIENTRY * dllIsEnabled )(GLenum cap);\nGLboolean ( APIENTRY * dllIsList )(GLuint list);\nGLboolean ( APIENTRY * dllIsTexture )(GLuint texture);\nstatic void ( APIENTRY * dllLightModelf )(GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllLightModelfv )(GLenum pname, const GLfloat *params);\nstatic void ( APIENTRY * dllLightModeli )(GLenum pname, GLint param);\nstatic void ( APIENTRY * dllLightModeliv )(GLenum pname, const GLint *params);\nstatic void ( APIENTRY * dllLightf )(GLenum light, GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllLightfv )(GLenum light, GLenum pname, const GLfloat *params);\nstatic void ( APIENTRY * dllLighti )(GLenum light, GLenum pname, GLint param);\nstatic void ( APIENTRY * dllLightiv )(GLenum light, GLenum pname, const GLint *params);\nstatic void ( APIENTRY * dllLineStipple )(GLint factor, GLushort pattern);\nstatic void ( APIENTRY * dllLineWidth )(GLfloat width);\nstatic void ( APIENTRY * dllListBase )(GLuint base);\nstatic void ( APIENTRY * dllLoadIdentity )(void);\nstatic void ( APIENTRY * dllLoadMatrixd )(const GLdouble *m);\nstatic void ( APIENTRY * dllLoadMatrixf )(const GLfloat *m);\nstatic void ( APIENTRY * dllLoadName )(GLuint name);\nstatic void ( APIENTRY * dllLogicOp )(GLenum opcode);\nstatic void ( APIENTRY * dllMap1d )(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);\nstatic void ( APIENTRY * dllMap1f )(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);\nstatic void ( APIENTRY * dllMap2d )(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);\nstatic void ( APIENTRY * dllMap2f )(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);\nstatic void ( APIENTRY * dllMapGrid1d )(GLint un, GLdouble u1, GLdouble u2);\nstatic void ( APIENTRY * dllMapGrid1f )(GLint un, GLfloat u1, GLfloat u2);\nstatic void ( APIENTRY * dllMapGrid2d )(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);\nstatic void ( APIENTRY * dllMapGrid2f )(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);\nstatic void ( APIENTRY * dllMaterialf )(GLenum face, GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllMaterialfv )(GLenum face, GLenum pname, const GLfloat *params);\nstatic void ( APIENTRY * dllMateriali )(GLenum face, GLenum pname, GLint param);\nstatic void ( APIENTRY * dllMaterialiv )(GLenum face, GLenum pname, const GLint *params);\nstatic void ( APIENTRY * dllMatrixMode )(GLenum mode);\nstatic void ( APIENTRY * dllMultMatrixd )(const GLdouble *m);\nstatic void ( APIENTRY * dllMultMatrixf )(const GLfloat *m);\nstatic void ( APIENTRY * dllNewList )(GLuint list, GLenum mode);\nstatic void ( APIENTRY * dllNormal3b )(GLbyte nx, GLbyte ny, GLbyte nz);\nstatic void ( APIENTRY * dllNormal3bv )(const GLbyte *v);\nstatic void ( APIENTRY * dllNormal3d )(GLdouble nx, GLdouble ny, GLdouble nz);\nstatic void ( APIENTRY * dllNormal3dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllNormal3f )(GLfloat nx, GLfloat ny, GLfloat nz);\nstatic void ( APIENTRY * dllNormal3fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllNormal3i )(GLint nx, GLint ny, GLint nz);\nstatic void ( APIENTRY * dllNormal3iv )(const GLint *v);\nstatic void ( APIENTRY * dllNormal3s )(GLshort nx, GLshort ny, GLshort nz);\nstatic void ( APIENTRY * dllNormal3sv )(const GLshort *v);\nstatic void ( APIENTRY * dllNormalPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);\nstatic void ( APIENTRY * dllOrtho )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nstatic void ( APIENTRY * dllPassThrough )(GLfloat token);\nstatic void ( APIENTRY * dllPixelMapfv )(GLenum map, GLsizei mapsize, const GLfloat *values);\nstatic void ( APIENTRY * dllPixelMapuiv )(GLenum map, GLsizei mapsize, const GLuint *values);\nstatic void ( APIENTRY * dllPixelMapusv )(GLenum map, GLsizei mapsize, const GLushort *values);\nstatic void ( APIENTRY * dllPixelStoref )(GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllPixelStorei )(GLenum pname, GLint param);\nstatic void ( APIENTRY * dllPixelTransferf )(GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllPixelTransferi )(GLenum pname, GLint param);\nstatic void ( APIENTRY * dllPixelZoom )(GLfloat xfactor, GLfloat yfactor);\nstatic void ( APIENTRY * dllPointSize )(GLfloat size);\nstatic void ( APIENTRY * dllPolygonMode )(GLenum face, GLenum mode);\nstatic void ( APIENTRY * dllPolygonOffset )(GLfloat factor, GLfloat units);\nstatic void ( APIENTRY * dllPolygonStipple )(const GLubyte *mask);\nstatic void ( APIENTRY * dllPopAttrib )(void);\nstatic void ( APIENTRY * dllPopClientAttrib )(void);\nstatic void ( APIENTRY * dllPopMatrix )(void);\nstatic void ( APIENTRY * dllPopName )(void);\nstatic void ( APIENTRY * dllPrioritizeTextures )(GLsizei n, const GLuint *textures, const GLclampf *priorities);\nstatic void ( APIENTRY * dllPushAttrib )(GLbitfield mask);\nstatic void ( APIENTRY * dllPushClientAttrib )(GLbitfield mask);\nstatic void ( APIENTRY * dllPushMatrix )(void);\nstatic void ( APIENTRY * dllPushName )(GLuint name);\nstatic void ( APIENTRY * dllRasterPos2d )(GLdouble x, GLdouble y);\nstatic void ( APIENTRY * dllRasterPos2dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllRasterPos2f )(GLfloat x, GLfloat y);\nstatic void ( APIENTRY * dllRasterPos2fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllRasterPos2i )(GLint x, GLint y);\nstatic void ( APIENTRY * dllRasterPos2iv )(const GLint *v);\nstatic void ( APIENTRY * dllRasterPos2s )(GLshort x, GLshort y);\nstatic void ( APIENTRY * dllRasterPos2sv )(const GLshort *v);\nstatic void ( APIENTRY * dllRasterPos3d )(GLdouble x, GLdouble y, GLdouble z);\nstatic void ( APIENTRY * dllRasterPos3dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllRasterPos3f )(GLfloat x, GLfloat y, GLfloat z);\nstatic void ( APIENTRY * dllRasterPos3fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllRasterPos3i )(GLint x, GLint y, GLint z);\nstatic void ( APIENTRY * dllRasterPos3iv )(const GLint *v);\nstatic void ( APIENTRY * dllRasterPos3s )(GLshort x, GLshort y, GLshort z);\nstatic void ( APIENTRY * dllRasterPos3sv )(const GLshort *v);\nstatic void ( APIENTRY * dllRasterPos4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nstatic void ( APIENTRY * dllRasterPos4dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllRasterPos4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nstatic void ( APIENTRY * dllRasterPos4fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllRasterPos4i )(GLint x, GLint y, GLint z, GLint w);\nstatic void ( APIENTRY * dllRasterPos4iv )(const GLint *v);\nstatic void ( APIENTRY * dllRasterPos4s )(GLshort x, GLshort y, GLshort z, GLshort w);\nstatic void ( APIENTRY * dllRasterPos4sv )(const GLshort *v);\nstatic void ( APIENTRY * dllReadBuffer )(GLenum mode);\nstatic void ( APIENTRY * dllReadPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);\nstatic void ( APIENTRY * dllRectd )(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);\nstatic void ( APIENTRY * dllRectdv )(const GLdouble *v1, const GLdouble *v2);\nstatic void ( APIENTRY * dllRectf )(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);\nstatic void ( APIENTRY * dllRectfv )(const GLfloat *v1, const GLfloat *v2);\nstatic void ( APIENTRY * dllRecti )(GLint x1, GLint y1, GLint x2, GLint y2);\nstatic void ( APIENTRY * dllRectiv )(const GLint *v1, const GLint *v2);\nstatic void ( APIENTRY * dllRects )(GLshort x1, GLshort y1, GLshort x2, GLshort y2);\nstatic void ( APIENTRY * dllRectsv )(const GLshort *v1, const GLshort *v2);\nGLint ( APIENTRY * dllRenderMode )(GLenum mode);\nstatic void ( APIENTRY * dllRotated )(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);\nstatic void ( APIENTRY * dllRotatef )(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);\nstatic void ( APIENTRY * dllScaled )(GLdouble x, GLdouble y, GLdouble z);\nstatic void ( APIENTRY * dllScalef )(GLfloat x, GLfloat y, GLfloat z);\nstatic void ( APIENTRY * dllScissor )(GLint x, GLint y, GLsizei width, GLsizei height);\nstatic void ( APIENTRY * dllSelectBuffer )(GLsizei size, GLuint *buffer);\nstatic void ( APIENTRY * dllShadeModel )(GLenum mode);\nstatic void ( APIENTRY * dllStencilFunc )(GLenum func, GLint ref, GLuint mask);\nstatic void ( APIENTRY * dllStencilMask )(GLuint mask);\nstatic void ( APIENTRY * dllStencilOp )(GLenum fail, GLenum zfail, GLenum zpass);\nstatic void ( APIENTRY * dllTexCoord1d )(GLdouble s);\nstatic void ( APIENTRY * dllTexCoord1dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllTexCoord1f )(GLfloat s);\nstatic void ( APIENTRY * dllTexCoord1fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllTexCoord1i )(GLint s);\nstatic void ( APIENTRY * dllTexCoord1iv )(const GLint *v);\nstatic void ( APIENTRY * dllTexCoord1s )(GLshort s);\nstatic void ( APIENTRY * dllTexCoord1sv )(const GLshort *v);\nstatic void ( APIENTRY * dllTexCoord2d )(GLdouble s, GLdouble t);\nstatic void ( APIENTRY * dllTexCoord2dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllTexCoord2f )(GLfloat s, GLfloat t);\nstatic void ( APIENTRY * dllTexCoord2fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllTexCoord2i )(GLint s, GLint t);\nstatic void ( APIENTRY * dllTexCoord2iv )(const GLint *v);\nstatic void ( APIENTRY * dllTexCoord2s )(GLshort s, GLshort t);\nstatic void ( APIENTRY * dllTexCoord2sv )(const GLshort *v);\nstatic void ( APIENTRY * dllTexCoord3d )(GLdouble s, GLdouble t, GLdouble r);\nstatic void ( APIENTRY * dllTexCoord3dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllTexCoord3f )(GLfloat s, GLfloat t, GLfloat r);\nstatic void ( APIENTRY * dllTexCoord3fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllTexCoord3i )(GLint s, GLint t, GLint r);\nstatic void ( APIENTRY * dllTexCoord3iv )(const GLint *v);\nstatic void ( APIENTRY * dllTexCoord3s )(GLshort s, GLshort t, GLshort r);\nstatic void ( APIENTRY * dllTexCoord3sv )(const GLshort *v);\nstatic void ( APIENTRY * dllTexCoord4d )(GLdouble s, GLdouble t, GLdouble r, GLdouble q);\nstatic void ( APIENTRY * dllTexCoord4dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllTexCoord4f )(GLfloat s, GLfloat t, GLfloat r, GLfloat q);\nstatic void ( APIENTRY * dllTexCoord4fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllTexCoord4i )(GLint s, GLint t, GLint r, GLint q);\nstatic void ( APIENTRY * dllTexCoord4iv )(const GLint *v);\nstatic void ( APIENTRY * dllTexCoord4s )(GLshort s, GLshort t, GLshort r, GLshort q);\nstatic void ( APIENTRY * dllTexCoord4sv )(const GLshort *v);\nstatic void ( APIENTRY * dllTexCoordPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nstatic void ( APIENTRY * dllTexEnvf )(GLenum target, GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllTexEnvfv )(GLenum target, GLenum pname, const GLfloat *params);\nstatic void ( APIENTRY * dllTexEnvi )(GLenum target, GLenum pname, GLint param);\nstatic void ( APIENTRY * dllTexEnviv )(GLenum target, GLenum pname, const GLint *params);\nstatic void ( APIENTRY * dllTexGend )(GLenum coord, GLenum pname, GLdouble param);\nstatic void ( APIENTRY * dllTexGendv )(GLenum coord, GLenum pname, const GLdouble *params);\nstatic void ( APIENTRY * dllTexGenf )(GLenum coord, GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllTexGenfv )(GLenum coord, GLenum pname, const GLfloat *params);\nstatic void ( APIENTRY * dllTexGeni )(GLenum coord, GLenum pname, GLint param);\nstatic void ( APIENTRY * dllTexGeniv )(GLenum coord, GLenum pname, const GLint *params);\nstatic void ( APIENTRY * dllTexImage1D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nstatic void ( APIENTRY * dllTexImage2D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nstatic void ( APIENTRY * dllTexParameterf )(GLenum target, GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllTexParameterfv )(GLenum target, GLenum pname, const GLfloat *params);\nstatic void ( APIENTRY * dllTexParameteri )(GLenum target, GLenum pname, GLint param);\nstatic void ( APIENTRY * dllTexParameteriv )(GLenum target, GLenum pname, const GLint *params);\nstatic void ( APIENTRY * dllTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);\nstatic void ( APIENTRY * dllTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nstatic void ( APIENTRY * dllTranslated )(GLdouble x, GLdouble y, GLdouble z);\nstatic void ( APIENTRY * dllTranslatef )(GLfloat x, GLfloat y, GLfloat z);\nstatic void ( APIENTRY * dllVertex2d )(GLdouble x, GLdouble y);\nstatic void ( APIENTRY * dllVertex2dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllVertex2f )(GLfloat x, GLfloat y);\nstatic void ( APIENTRY * dllVertex2fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllVertex2i )(GLint x, GLint y);\nstatic void ( APIENTRY * dllVertex2iv )(const GLint *v);\nstatic void ( APIENTRY * dllVertex2s )(GLshort x, GLshort y);\nstatic void ( APIENTRY * dllVertex2sv )(const GLshort *v);\nstatic void ( APIENTRY * dllVertex3d )(GLdouble x, GLdouble y, GLdouble z);\nstatic void ( APIENTRY * dllVertex3dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllVertex3f )(GLfloat x, GLfloat y, GLfloat z);\nstatic void ( APIENTRY * dllVertex3fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllVertex3i )(GLint x, GLint y, GLint z);\nstatic void ( APIENTRY * dllVertex3iv )(const GLint *v);\nstatic void ( APIENTRY * dllVertex3s )(GLshort x, GLshort y, GLshort z);\nstatic void ( APIENTRY * dllVertex3sv )(const GLshort *v);\nstatic void ( APIENTRY * dllVertex4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nstatic void ( APIENTRY * dllVertex4dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllVertex4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nstatic void ( APIENTRY * dllVertex4fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllVertex4i )(GLint x, GLint y, GLint z, GLint w);\nstatic void ( APIENTRY * dllVertex4iv )(const GLint *v);\nstatic void ( APIENTRY * dllVertex4s )(GLshort x, GLshort y, GLshort z, GLshort w);\nstatic void ( APIENTRY * dllVertex4sv )(const GLshort *v);\nstatic void ( APIENTRY * dllVertexPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nstatic void ( APIENTRY * dllViewport )(GLint x, GLint y, GLsizei width, GLsizei height);\n\nstatic void APIENTRY logAccum(GLenum op, GLfloat value)\n{\n\tfprintf( glw_state.log_fp, \"glAccum\\n\" );\n\tdllAccum( op, value );\n}\n\nstatic void APIENTRY logAlphaFunc(GLenum func, GLclampf ref)\n{\n\tfprintf( glw_state.log_fp, \"glAlphaFunc( 0x%x, %f )\\n\", func, ref );\n\tdllAlphaFunc( func, ref );\n}\n\nstatic GLboolean APIENTRY logAreTexturesResident(GLsizei n, const GLuint *textures, GLboolean *residences)\n{\n\tfprintf( glw_state.log_fp, \"glAreTexturesResident\\n\" );\n\treturn dllAreTexturesResident( n, textures, residences );\n}\n\nstatic void APIENTRY logArrayElement(GLint i)\n{\n\tfprintf( glw_state.log_fp, \"glArrayElement\\n\" );\n\tdllArrayElement( i );\n}\n\nstatic void APIENTRY logBegin(GLenum mode)\n{\n\tfprintf( glw_state.log_fp, \"glBegin( 0x%x )\\n\", mode );\n\tdllBegin( mode );\n}\n\nstatic void APIENTRY logBindTexture(GLenum target, GLuint texture)\n{\n\tfprintf( glw_state.log_fp, \"glBindTexture( 0x%x, %u )\\n\", target, texture );\n\tdllBindTexture( target, texture );\n}\n\nstatic void APIENTRY logBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap)\n{\n\tfprintf( glw_state.log_fp, \"glBitmap\\n\" );\n\tdllBitmap( width, height, xorig, yorig, xmove, ymove, bitmap );\n}\n\nstatic void APIENTRY logBlendFunc(GLenum sfactor, GLenum dfactor)\n{\n\tfprintf( glw_state.log_fp, \"glBlendFunc( 0x%x, 0x%x )\\n\", sfactor, dfactor );\n\tdllBlendFunc( sfactor, dfactor );\n}\n\nstatic void APIENTRY logCallList(GLuint list)\n{\n\tfprintf( glw_state.log_fp, \"glCallList( %u )\\n\", list );\n\tdllCallList( list );\n}\n\nstatic void APIENTRY logCallLists(GLsizei n, GLenum type, const void *lists)\n{\n\tfprintf( glw_state.log_fp, \"glCallLists\\n\" );\n\tdllCallLists( n, type, lists );\n}\n\nstatic void APIENTRY logClear(GLbitfield mask)\n{\n\tfprintf( glw_state.log_fp, \"glClear\\n\" );\n\tdllClear( mask );\n}\n\nstatic void APIENTRY logClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)\n{\n\tfprintf( glw_state.log_fp, \"glClearAccum\\n\" );\n\tdllClearAccum( red, green, blue, alpha );\n}\n\nstatic void APIENTRY logClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)\n{\n\tfprintf( glw_state.log_fp, \"glClearColor\\n\" );\n\tdllClearColor( red, green, blue, alpha );\n}\n\nstatic void APIENTRY logClearDepth(GLclampd depth)\n{\n\tfprintf( glw_state.log_fp, \"glClearDepth\\n\" );\n\tdllClearDepth( depth );\n}\n\nstatic void APIENTRY logClearIndex(GLfloat c)\n{\n\tfprintf( glw_state.log_fp, \"glClearIndex\\n\" );\n\tdllClearIndex( c );\n}\n\nstatic void APIENTRY logClearStencil(GLint s)\n{\n\tfprintf( glw_state.log_fp, \"glClearStencil\\n\" );\n\tdllClearStencil( s );\n}\n\nstatic void APIENTRY logClipPlane(GLenum plane, const GLdouble *equation)\n{\n\tfprintf( glw_state.log_fp, \"glClipPlane\\n\" );\n\tdllClipPlane( plane, equation );\n}\n\nstatic void APIENTRY logColor3b(GLbyte red, GLbyte green, GLbyte blue)\n{\n\tfprintf( glw_state.log_fp, \"glColor3b\\n\" );\n\tdllColor3b( red, green, blue );\n}\n\nstatic void APIENTRY logColor3bv(const GLbyte *v)\n{\n\tfprintf( glw_state.log_fp, \"glColor3bv\\n\" );\n\tdllColor3bv( v );\n}\n\nstatic void APIENTRY logColor3d(GLdouble red, GLdouble green, GLdouble blue)\n{\n\tfprintf( glw_state.log_fp, \"glColor3d\\n\" );\n\tdllColor3d( red, green, blue );\n}\n\nstatic void APIENTRY logColor3dv(const GLdouble *v)\n{\n\tfprintf( glw_state.log_fp, \"glColor3dv\\n\" );\n\tdllColor3dv( v );\n}\n\nstatic void APIENTRY logColor3f(GLfloat red, GLfloat green, GLfloat blue)\n{\n\tfprintf( glw_state.log_fp, \"glColor3f\\n\" );\n\tdllColor3f( red, green, blue );\n}\n\nstatic void APIENTRY logColor3fv(const GLfloat *v)\n{\n\tfprintf( glw_state.log_fp, \"glColor3fv\\n\" );\n\tdllColor3fv( v );\n}\n\nstatic void APIENTRY logColor3i(GLint red, GLint green, GLint blue)\n{\n\tfprintf( glw_state.log_fp, \"glColor3i\\n\" );\n\tdllColor3i( red, green, blue );\n}\n\nstatic void APIENTRY logColor3iv(const GLint *v)\n{\n\tfprintf( glw_state.log_fp, \"glColor3iv\\n\" );\n\tdllColor3iv( v );\n}\n\nstatic void APIENTRY logColor3s(GLshort red, GLshort green, GLshort blue)\n{\n\tfprintf( glw_state.log_fp, \"glColor3s\\n\" );\n\tdllColor3s( red, green, blue );\n}\n\nstatic void APIENTRY logColor3sv(const GLshort *v)\n{\n\tfprintf( glw_state.log_fp, \"glColor3sv\\n\" );\n\tdllColor3sv( v );\n}\n\nstatic void APIENTRY logColor3ub(GLubyte red, GLubyte green, GLubyte blue)\n{\n\tfprintf( glw_state.log_fp, \"glColor3ub\\n\" );\n\tdllColor3ub( red, green, blue );\n}\n\nstatic void APIENTRY logColor3ubv(const GLubyte *v)\n{\n\tfprintf( glw_state.log_fp, \"glColor3ubv\\n\" );\n\tdllColor3ubv( v );\n}\n\n#define SIG( x ) fprintf( glw_state.log_fp, x \"\\n\" )\n\nstatic void APIENTRY logColor3ui(GLuint red, GLuint green, GLuint blue)\n{\n\tSIG( \"glColor3ui\" );\n\tdllColor3ui( red, green, blue );\n}\n\nstatic void APIENTRY logColor3uiv(const GLuint *v)\n{\n\tSIG( \"glColor3uiv\" );\n\tdllColor3uiv( v );\n}\n\nstatic void APIENTRY logColor3us(GLushort red, GLushort green, GLushort blue)\n{\n\tSIG( \"glColor3us\" );\n\tdllColor3us( red, green, blue );\n}\n\nstatic void APIENTRY logColor3usv(const GLushort *v)\n{\n\tSIG( \"glColor3usv\" );\n\tdllColor3usv( v );\n}\n\nstatic void APIENTRY logColor4b(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha)\n{\n\tSIG( \"glColor4b\" );\n\tdllColor4b( red, green, blue, alpha );\n}\n\nstatic void APIENTRY logColor4bv(const GLbyte *v)\n{\n\tSIG( \"glColor4bv\" );\n\tdllColor4bv( v );\n}\n\nstatic void APIENTRY logColor4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha)\n{\n\tSIG( \"glColor4d\" );\n\tdllColor4d( red, green, blue, alpha );\n}\nstatic void APIENTRY logColor4dv(const GLdouble *v)\n{\n\tSIG( \"glColor4dv\" );\n\tdllColor4dv( v );\n}\nstatic void APIENTRY logColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)\n{\n\tfprintf( glw_state.log_fp, \"glColor4f( %f,%f,%f,%f )\\n\", red, green, blue, alpha );\n\tdllColor4f( red, green, blue, alpha );\n}\nstatic void APIENTRY logColor4fv(const GLfloat *v)\n{\n\tfprintf( glw_state.log_fp, \"glColor4fv( %f,%f,%f,%f )\\n\", v[0], v[1], v[2], v[3] );\n\tdllColor4fv( v );\n}\nstatic void APIENTRY logColor4i(GLint red, GLint green, GLint blue, GLint alpha)\n{\n\tSIG( \"glColor4i\" );\n\tdllColor4i( red, green, blue, alpha );\n}\nstatic void APIENTRY logColor4iv(const GLint *v)\n{\n\tSIG( \"glColor4iv\" );\n\tdllColor4iv( v );\n}\nstatic void APIENTRY logColor4s(GLshort red, GLshort green, GLshort blue, GLshort alpha)\n{\n\tSIG( \"glColor4s\" );\n\tdllColor4s( red, green, blue, alpha );\n}\nstatic void APIENTRY logColor4sv(const GLshort *v)\n{\n\tSIG( \"glColor4sv\" );\n\tdllColor4sv( v );\n}\nstatic void APIENTRY logColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)\n{\n\tSIG( \"glColor4b\" );\n\tdllColor4b( red, green, blue, alpha );\n}\nstatic void APIENTRY logColor4ubv(const GLubyte *v)\n{\n\tSIG( \"glColor4ubv\" );\n\tdllColor4ubv( v );\n}\nstatic void APIENTRY logColor4ui(GLuint red, GLuint green, GLuint blue, GLuint alpha)\n{\n\tSIG( \"glColor4ui\" );\n\tdllColor4ui( red, green, blue, alpha );\n}\nstatic void APIENTRY logColor4uiv(const GLuint *v)\n{\n\tSIG( \"glColor4uiv\" );\n\tdllColor4uiv( v );\n}\nstatic void APIENTRY logColor4us(GLushort red, GLushort green, GLushort blue, GLushort alpha)\n{\n\tSIG( \"glColor4us\" );\n\tdllColor4us( red, green, blue, alpha );\n}\nstatic void APIENTRY logColor4usv(const GLushort *v)\n{\n\tSIG( \"glColor4usv\" );\n\tdllColor4usv( v );\n}\nstatic void APIENTRY logColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)\n{\n\tSIG( \"glColorMask\" );\n\tdllColorMask( red, green, blue, alpha );\n}\nstatic void APIENTRY logColorMaterial(GLenum face, GLenum mode)\n{\n\tSIG( \"glColorMaterial\" );\n\tdllColorMaterial( face, mode );\n}\n\nstatic void APIENTRY logColorPointer(GLint size, GLenum type, GLsizei stride, const void *pointer)\n{\n\tSIG( \"glColorPointer\" );\n\tdllColorPointer( size, type, stride, pointer );\n}\n\nstatic void APIENTRY logCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)\n{\n\tSIG( \"glCopyPixels\" );\n\tdllCopyPixels( x, y, width, height, type );\n}\n\nstatic void APIENTRY logCopyTexImage1D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border)\n{\n\tSIG( \"glCopyTexImage1D\" );\n\tdllCopyTexImage1D( target, level, internalFormat, x, y, width, border );\n}\n\nstatic void APIENTRY logCopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)\n{\n\tSIG( \"glCopyTexImage2D\" );\n\tdllCopyTexImage2D( target, level, internalFormat, x, y, width, height, border );\n}\n\nstatic void APIENTRY logCopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width)\n{\n\tSIG( \"glCopyTexSubImage1D\" );\n\tdllCopyTexSubImage1D( target, level, xoffset, x, y, width );\n}\n\nstatic void APIENTRY logCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)\n{\n\tSIG( \"glCopyTexSubImage2D\" );\n\tdllCopyTexSubImage2D( target, level, xoffset, yoffset, x, y, width, height );\n}\n\nstatic void APIENTRY logCullFace(GLenum mode)\n{\n\tSIG( \"glCullFace\" );\n\tdllCullFace( mode );\n}\n\nstatic void APIENTRY logDeleteLists(GLuint list, GLsizei range)\n{\n\tSIG( \"glDeleteLists\" );\n\tdllDeleteLists( list, range );\n}\n\nstatic void APIENTRY logDeleteTextures(GLsizei n, const GLuint *textures)\n{\n\tSIG( \"glDeleteTextures\" );\n\tdllDeleteTextures( n, textures );\n}\n\nstatic void APIENTRY logDepthFunc(GLenum func)\n{\n\tSIG( \"glDepthFunc\" );\n\tdllDepthFunc( func );\n}\n\nstatic void APIENTRY logDepthMask(GLboolean flag)\n{\n\tSIG( \"glDepthMask\" );\n\tdllDepthMask( flag );\n}\n\nstatic void APIENTRY logDepthRange(GLclampd zNear, GLclampd zFar)\n{\n\tSIG( \"glDepthRange\" );\n\tdllDepthRange( zNear, zFar );\n}\n\nstatic void APIENTRY logDisable(GLenum cap)\n{\n\tfprintf( glw_state.log_fp, \"glDisable( 0x%x )\\n\", cap );\n\tdllDisable( cap );\n}\n\nstatic void APIENTRY logDisableClientState(GLenum array)\n{\n\tSIG( \"glDisableClientState\" );\n\tdllDisableClientState( array );\n}\n\nstatic void APIENTRY logDrawArrays(GLenum mode, GLint first, GLsizei count)\n{\n\tSIG( \"glDrawArrays\" );\n\tdllDrawArrays( mode, first, count );\n}\n\nstatic void APIENTRY logDrawBuffer(GLenum mode)\n{\n\tSIG( \"glDrawBuffer\" );\n\tdllDrawBuffer( mode );\n}\n\nstatic void APIENTRY logDrawElements(GLenum mode, GLsizei count, GLenum type, const void *indices)\n{\n\tSIG( \"glDrawElements\" );\n\tdllDrawElements( mode, count, type, indices );\n}\n\nstatic void APIENTRY logDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels)\n{\n\tSIG( \"glDrawPixels\" );\n\tdllDrawPixels( width, height, format, type, pixels );\n}\n\nstatic void APIENTRY logEdgeFlag(GLboolean flag)\n{\n\tSIG( \"glEdgeFlag\" );\n\tdllEdgeFlag( flag );\n}\n\nstatic void APIENTRY logEdgeFlagPointer(GLsizei stride, const void *pointer)\n{\n\tSIG( \"glEdgeFlagPointer\" );\n\tdllEdgeFlagPointer( stride, pointer );\n}\n\nstatic void APIENTRY logEdgeFlagv(const GLboolean *flag)\n{\n\tSIG( \"glEdgeFlagv\" );\n\tdllEdgeFlagv( flag );\n}\n\nstatic void APIENTRY logEnable(GLenum cap)\n{\n\tfprintf( glw_state.log_fp, \"glEnable( 0x%x )\\n\", cap );\n\tdllEnable( cap );\n}\n\nstatic void APIENTRY logEnableClientState(GLenum array)\n{\n\tSIG( \"glEnableClientState\" );\n\tdllEnableClientState( array );\n}\n\nstatic void APIENTRY logEnd(void)\n{\n\tSIG( \"glEnd\" );\n\tdllEnd();\n}\n\nstatic void APIENTRY logEndList(void)\n{\n\tSIG( \"glEndList\" );\n\tdllEndList();\n}\n\nstatic void APIENTRY logEvalCoord1d(GLdouble u)\n{\n\tSIG( \"glEvalCoord1d\" );\n\tdllEvalCoord1d( u );\n}\n\nstatic void APIENTRY logEvalCoord1dv(const GLdouble *u)\n{\n\tSIG( \"glEvalCoord1dv\" );\n\tdllEvalCoord1dv( u );\n}\n\nstatic void APIENTRY logEvalCoord1f(GLfloat u)\n{\n\tSIG( \"glEvalCoord1f\" );\n\tdllEvalCoord1f( u );\n}\n\nstatic void APIENTRY logEvalCoord1fv(const GLfloat *u)\n{\n\tSIG( \"glEvalCoord1fv\" );\n\tdllEvalCoord1fv( u );\n}\nstatic void APIENTRY logEvalCoord2d(GLdouble u, GLdouble v)\n{\n\tSIG( \"glEvalCoord2d\" );\n\tdllEvalCoord2d( u, v );\n}\nstatic void APIENTRY logEvalCoord2dv(const GLdouble *u)\n{\n\tSIG( \"glEvalCoord2dv\" );\n\tdllEvalCoord2dv( u );\n}\nstatic void APIENTRY logEvalCoord2f(GLfloat u, GLfloat v)\n{\n\tSIG( \"glEvalCoord2f\" );\n\tdllEvalCoord2f( u, v );\n}\nstatic void APIENTRY logEvalCoord2fv(const GLfloat *u)\n{\n\tSIG( \"glEvalCoord2fv\" );\n\tdllEvalCoord2fv( u );\n}\n\nstatic void APIENTRY logEvalMesh1(GLenum mode, GLint i1, GLint i2)\n{\n\tSIG( \"glEvalMesh1\" );\n\tdllEvalMesh1( mode, i1, i2 );\n}\nstatic void APIENTRY logEvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)\n{\n\tSIG( \"glEvalMesh2\" );\n\tdllEvalMesh2( mode, i1, i2, j1, j2 );\n}\nstatic void APIENTRY logEvalPoint1(GLint i)\n{\n\tSIG( \"glEvalPoint1\" );\n\tdllEvalPoint1( i );\n}\nstatic void APIENTRY logEvalPoint2(GLint i, GLint j)\n{\n\tSIG( \"glEvalPoint2\" );\n\tdllEvalPoint2( i, j );\n}\n\nstatic void APIENTRY logFeedbackBuffer(GLsizei size, GLenum type, GLfloat *buffer)\n{\n\tSIG( \"glFeedbackBuffer\" );\n\tdllFeedbackBuffer( size, type, buffer );\n}\n\nstatic void APIENTRY logFinish(void)\n{\n\tSIG( \"glFinish\" );\n\tdllFinish();\n}\n\nstatic void APIENTRY logFlush(void)\n{\n\tSIG( \"glFlush\" );\n\tdllFlush();\n}\n\nstatic void APIENTRY logFogf(GLenum pname, GLfloat param)\n{\n\tSIG( \"glFogf\" );\n\tdllFogf( pname, param );\n}\n\nstatic void APIENTRY logFogfv(GLenum pname, const GLfloat *params)\n{\n\tSIG( \"glFogfv\" );\n\tdllFogfv( pname, params );\n}\n\nstatic void APIENTRY logFogi(GLenum pname, GLint param)\n{\n\tSIG( \"glFogi\" );\n\tdllFogi( pname, param );\n}\n\nstatic void APIENTRY logFogiv(GLenum pname, const GLint *params)\n{\n\tSIG( \"glFogiv\" );\n\tdllFogiv( pname, params );\n}\n\nstatic void APIENTRY logFrontFace(GLenum mode)\n{\n\tSIG( \"glFrontFace\" );\n\tdllFrontFace( mode );\n}\n\nstatic void APIENTRY logFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)\n{\n\tSIG( \"glFrustum\" );\n\tdllFrustum( left, right, bottom, top, zNear, zFar );\n}\n\nstatic GLuint APIENTRY logGenLists(GLsizei range)\n{\n\tSIG( \"glGenLists\" );\n\treturn dllGenLists( range );\n}\n\nstatic void APIENTRY logGenTextures(GLsizei n, GLuint *textures)\n{\n\tSIG( \"glGenTextures\" );\n\tdllGenTextures( n, textures );\n}\n\nstatic void APIENTRY logGetBooleanv(GLenum pname, GLboolean *params)\n{\n\tSIG( \"glGetBooleanv\" );\n\tdllGetBooleanv( pname, params );\n}\n\nstatic void APIENTRY logGetClipPlane(GLenum plane, GLdouble *equation)\n{\n\tSIG( \"glGetClipPlane\" );\n\tdllGetClipPlane( plane, equation );\n}\n\nstatic void APIENTRY logGetDoublev(GLenum pname, GLdouble *params)\n{\n\tSIG( \"glGetDoublev\" );\n\tdllGetDoublev( pname, params );\n}\n\nstatic GLenum APIENTRY logGetError(void)\n{\n\tSIG( \"glGetError\" );\n\treturn dllGetError();\n}\n\nstatic void APIENTRY logGetFloatv(GLenum pname, GLfloat *params)\n{\n\tSIG( \"glGetFloatv\" );\n\tdllGetFloatv( pname, params );\n}\n\nstatic void APIENTRY logGetIntegerv(GLenum pname, GLint *params)\n{\n\tSIG( \"glGetIntegerv\" );\n\tdllGetIntegerv( pname, params );\n}\n\nstatic void APIENTRY logGetLightfv(GLenum light, GLenum pname, GLfloat *params)\n{\n\tSIG( \"glGetLightfv\" );\n\tdllGetLightfv( light, pname, params );\n}\n\nstatic void APIENTRY logGetLightiv(GLenum light, GLenum pname, GLint *params)\n{\n\tSIG( \"glGetLightiv\" );\n\tdllGetLightiv( light, pname, params );\n}\n\nstatic void APIENTRY logGetMapdv(GLenum target, GLenum query, GLdouble *v)\n{\n\tSIG( \"glGetMapdv\" );\n\tdllGetMapdv( target, query, v );\n}\n\nstatic void APIENTRY logGetMapfv(GLenum target, GLenum query, GLfloat *v)\n{\n\tSIG( \"glGetMapfv\" );\n\tdllGetMapfv( target, query, v );\n}\n\nstatic void APIENTRY logGetMapiv(GLenum target, GLenum query, GLint *v)\n{\n\tSIG( \"glGetMapiv\" );\n\tdllGetMapiv( target, query, v );\n}\n\nstatic void APIENTRY logGetMaterialfv(GLenum face, GLenum pname, GLfloat *params)\n{\n\tSIG( \"glGetMaterialfv\" );\n\tdllGetMaterialfv( face, pname, params );\n}\n\nstatic void APIENTRY logGetMaterialiv(GLenum face, GLenum pname, GLint *params)\n{\n\tSIG( \"glGetMaterialiv\" );\n\tdllGetMaterialiv( face, pname, params );\n}\n\nstatic void APIENTRY logGetPixelMapfv(GLenum map, GLfloat *values)\n{\n\tSIG( \"glGetPixelMapfv\" );\n\tdllGetPixelMapfv( map, values );\n}\n\nstatic void APIENTRY logGetPixelMapuiv(GLenum map, GLuint *values)\n{\n\tSIG( \"glGetPixelMapuiv\" );\n\tdllGetPixelMapuiv( map, values );\n}\n\nstatic void APIENTRY logGetPixelMapusv(GLenum map, GLushort *values)\n{\n\tSIG( \"glGetPixelMapusv\" );\n\tdllGetPixelMapusv( map, values );\n}\n\nstatic void APIENTRY logGetPointerv(GLenum pname, GLvoid* *params)\n{\n\tSIG( \"glGetPointerv\" );\n\tdllGetPointerv( pname, params );\n}\n\nstatic void APIENTRY logGetPolygonStipple(GLubyte *mask)\n{\n\tSIG( \"glGetPolygonStipple\" );\n\tdllGetPolygonStipple( mask );\n}\n\nstatic const GLubyte * APIENTRY logGetString(GLenum name)\n{\n\tSIG( \"glGetString\" );\n\treturn dllGetString( name );\n}\n\nstatic void APIENTRY logGetTexEnvfv(GLenum target, GLenum pname, GLfloat *params)\n{\n\tSIG( \"glGetTexEnvfv\" );\n\tdllGetTexEnvfv( target, pname, params );\n}\n\nstatic void APIENTRY logGetTexEnviv(GLenum target, GLenum pname, GLint *params)\n{\n\tSIG( \"glGetTexEnviv\" );\n\tdllGetTexEnviv( target, pname, params );\n}\n\nstatic void APIENTRY logGetTexGendv(GLenum coord, GLenum pname, GLdouble *params)\n{\n\tSIG( \"glGetTexGendv\" );\n\tdllGetTexGendv( coord, pname, params );\n}\n\nstatic void APIENTRY logGetTexGenfv(GLenum coord, GLenum pname, GLfloat *params)\n{\n\tSIG( \"glGetTexGenfv\" );\n\tdllGetTexGenfv( coord, pname, params );\n}\n\nstatic void APIENTRY logGetTexGeniv(GLenum coord, GLenum pname, GLint *params)\n{\n\tSIG( \"glGetTexGeniv\" );\n\tdllGetTexGeniv( coord, pname, params );\n}\n\nstatic void APIENTRY logGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, void *pixels)\n{\n\tSIG( \"glGetTexImage\" );\n\tdllGetTexImage( target, level, format, type, pixels );\n}\nstatic void APIENTRY logGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat *params )\n{\n\tSIG( \"glGetTexLevelParameterfv\" );\n\tdllGetTexLevelParameterfv( target, level, pname, params );\n}\n\nstatic void APIENTRY logGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params)\n{\n\tSIG( \"glGetTexLevelParameteriv\" );\n\tdllGetTexLevelParameteriv( target, level, pname, params );\n}\n\nstatic void APIENTRY logGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)\n{\n\tSIG( \"glGetTexParameterfv\" );\n\tdllGetTexParameterfv( target, pname, params );\n}\n\nstatic void APIENTRY logGetTexParameteriv(GLenum target, GLenum pname, GLint *params)\n{\n\tSIG( \"glGetTexParameteriv\" );\n\tdllGetTexParameteriv( target, pname, params );\n}\n\nstatic void APIENTRY logHint(GLenum target, GLenum mode)\n{\n\tfprintf( glw_state.log_fp, \"glHint( 0x%x, 0x%x )\\n\", target, mode );\n\tdllHint( target, mode );\n}\n\nstatic void APIENTRY logIndexMask(GLuint mask)\n{\n\tSIG( \"glIndexMask\" );\n\tdllIndexMask( mask );\n}\n\nstatic void APIENTRY logIndexPointer(GLenum type, GLsizei stride, const void *pointer)\n{\n\tSIG( \"glIndexPointer\" );\n\tdllIndexPointer( type, stride, pointer );\n}\n\nstatic void APIENTRY logIndexd(GLdouble c)\n{\n\tSIG( \"glIndexd\" );\n\tdllIndexd( c );\n}\n\nstatic void APIENTRY logIndexdv(const GLdouble *c)\n{\n\tSIG( \"glIndexdv\" );\n\tdllIndexdv( c );\n}\n\nstatic void APIENTRY logIndexf(GLfloat c)\n{\n\tSIG( \"glIndexf\" );\n\tdllIndexf( c );\n}\n\nstatic void APIENTRY logIndexfv(const GLfloat *c)\n{\n\tSIG( \"glIndexfv\" );\n\tdllIndexfv( c );\n}\n\nstatic void APIENTRY logIndexi(GLint c)\n{\n\tSIG( \"glIndexi\" );\n\tdllIndexi( c );\n}\n\nstatic void APIENTRY logIndexiv(const GLint *c)\n{\n\tSIG( \"glIndexiv\" );\n\tdllIndexiv( c );\n}\n\nstatic void APIENTRY logIndexs(GLshort c)\n{\n\tSIG( \"glIndexs\" );\n\tdllIndexs( c );\n}\n\nstatic void APIENTRY logIndexsv(const GLshort *c)\n{\n\tSIG( \"glIndexsv\" );\n\tdllIndexsv( c );\n}\n\nstatic void APIENTRY logIndexub(GLubyte c)\n{\n\tSIG( \"glIndexub\" );\n\tdllIndexub( c );\n}\n\nstatic void APIENTRY logIndexubv(const GLubyte *c)\n{\n\tSIG( \"glIndexubv\" );\n\tdllIndexubv( c );\n}\n\nstatic void APIENTRY logInitNames(void)\n{\n\tSIG( \"glInitNames\" );\n\tdllInitNames();\n}\n\nstatic void APIENTRY logInterleavedArrays(GLenum format, GLsizei stride, const void *pointer)\n{\n\tSIG( \"glInterleavedArrays\" );\n\tdllInterleavedArrays( format, stride, pointer );\n}\n\nstatic GLboolean APIENTRY logIsEnabled(GLenum cap)\n{\n\tSIG( \"glIsEnabled\" );\n\treturn dllIsEnabled( cap );\n}\nstatic GLboolean APIENTRY logIsList(GLuint list)\n{\n\tSIG( \"glIsList\" );\n\treturn dllIsList( list );\n}\nstatic GLboolean APIENTRY logIsTexture(GLuint texture)\n{\n\tSIG( \"glIsTexture\" );\n\treturn dllIsTexture( texture );\n}\n\nstatic void APIENTRY logLightModelf(GLenum pname, GLfloat param)\n{\n\tSIG( \"glLightModelf\" );\n\tdllLightModelf( pname, param );\n}\n\nstatic void APIENTRY logLightModelfv(GLenum pname, const GLfloat *params)\n{\n\tSIG( \"glLightModelfv\" );\n\tdllLightModelfv( pname, params );\n}\n\nstatic void APIENTRY logLightModeli(GLenum pname, GLint param)\n{\n\tSIG( \"glLightModeli\" );\n\tdllLightModeli( pname, param );\n\n}\n\nstatic void APIENTRY logLightModeliv(GLenum pname, const GLint *params)\n{\n\tSIG( \"glLightModeliv\" );\n\tdllLightModeliv( pname, params );\n}\n\nstatic void APIENTRY logLightf(GLenum light, GLenum pname, GLfloat param)\n{\n\tSIG( \"glLightf\" );\n\tdllLightf( light, pname, param );\n}\n\nstatic void APIENTRY logLightfv(GLenum light, GLenum pname, const GLfloat *params)\n{\n\tSIG( \"glLightfv\" );\n\tdllLightfv( light, pname, params );\n}\n\nstatic void APIENTRY logLighti(GLenum light, GLenum pname, GLint param)\n{\n\tSIG( \"glLighti\" );\n\tdllLighti( light, pname, param );\n}\n\nstatic void APIENTRY logLightiv(GLenum light, GLenum pname, const GLint *params)\n{\n\tSIG( \"glLightiv\" );\n\tdllLightiv( light, pname, params );\n}\n\nstatic void APIENTRY logLineStipple(GLint factor, GLushort pattern)\n{\n\tSIG( \"glLineStipple\" );\n\tdllLineStipple( factor, pattern );\n}\n\nstatic void APIENTRY logLineWidth(GLfloat width)\n{\n\tSIG( \"glLineWidth\" );\n\tdllLineWidth( width );\n}\n\nstatic void APIENTRY logListBase(GLuint base)\n{\n\tSIG( \"glListBase\" );\n\tdllListBase( base );\n}\n\nstatic void APIENTRY logLoadIdentity(void)\n{\n\tSIG( \"glLoadIdentity\" );\n\tdllLoadIdentity();\n}\n\nstatic void APIENTRY logLoadMatrixd(const GLdouble *m)\n{\n\tSIG( \"glLoadMatrixd\" );\n\tdllLoadMatrixd( m );\n}\n\nstatic void APIENTRY logLoadMatrixf(const GLfloat *m)\n{\n\tSIG( \"glLoadMatrixf\" );\n\tdllLoadMatrixf( m );\n}\n\nstatic void APIENTRY logLoadName(GLuint name)\n{\n\tSIG( \"glLoadName\" );\n\tdllLoadName( name );\n}\n\nstatic void APIENTRY logLogicOp(GLenum opcode)\n{\n\tSIG( \"glLogicOp\" );\n\tdllLogicOp( opcode );\n}\n\nstatic void APIENTRY logMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points)\n{\n\tSIG( \"glMap1d\" );\n\tdllMap1d( target, u1, u2, stride, order, points );\n}\n\nstatic void APIENTRY logMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points)\n{\n\tSIG( \"glMap1f\" );\n\tdllMap1f( target, u1, u2, stride, order, points );\n}\n\nstatic void APIENTRY logMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points)\n{\n\tSIG( \"glMap2d\" );\n\tdllMap2d( target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points );\n}\n\nstatic void APIENTRY logMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points)\n{\n\tSIG( \"glMap2f\" );\n\tdllMap2f( target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points );\n}\n\nstatic void APIENTRY logMapGrid1d(GLint un, GLdouble u1, GLdouble u2)\n{\n\tSIG( \"glMapGrid1d\" );\n\tdllMapGrid1d( un, u1, u2 );\n}\n\nstatic void APIENTRY logMapGrid1f(GLint un, GLfloat u1, GLfloat u2)\n{\n\tSIG( \"glMapGrid1f\" );\n\tdllMapGrid1f( un, u1, u2 );\n}\n\nstatic void APIENTRY logMapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2)\n{\n\tSIG( \"glMapGrid2d\" );\n\tdllMapGrid2d( un, u1, u2, vn, v1, v2 );\n}\nstatic void APIENTRY logMapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2)\n{\n\tSIG( \"glMapGrid2f\" );\n\tdllMapGrid2f( un, u1, u2, vn, v1, v2 );\n}\nstatic void APIENTRY logMaterialf(GLenum face, GLenum pname, GLfloat param)\n{\n\tSIG( \"glMaterialf\" );\n\tdllMaterialf( face, pname, param );\n}\nstatic void APIENTRY logMaterialfv(GLenum face, GLenum pname, const GLfloat *params)\n{\n\tSIG( \"glMaterialfv\" );\n\tdllMaterialfv( face, pname, params );\n}\n\nstatic void APIENTRY logMateriali(GLenum face, GLenum pname, GLint param)\n{\n\tSIG( \"glMateriali\" );\n\tdllMateriali( face, pname, param );\n}\n\nstatic void APIENTRY logMaterialiv(GLenum face, GLenum pname, const GLint *params)\n{\n\tSIG( \"glMaterialiv\" );\n\tdllMaterialiv( face, pname, params );\n}\n\nstatic void APIENTRY logMatrixMode(GLenum mode)\n{\n\tSIG( \"glMatrixMode\" );\n\tdllMatrixMode( mode );\n}\n\nstatic void APIENTRY logMultMatrixd(const GLdouble *m)\n{\n\tSIG( \"glMultMatrixd\" );\n\tdllMultMatrixd( m );\n}\n\nstatic void APIENTRY logMultMatrixf(const GLfloat *m)\n{\n\tSIG( \"glMultMatrixf\" );\n\tdllMultMatrixf( m );\n}\n\nstatic void APIENTRY logNewList(GLuint list, GLenum mode)\n{\n\tSIG( \"glNewList\" );\n\tdllNewList( list, mode );\n}\n\nstatic void APIENTRY logNormal3b(GLbyte nx, GLbyte ny, GLbyte nz)\n{\n\tSIG (\"glNormal3b\" );\n\tdllNormal3b( nx, ny, nz );\n}\n\nstatic void APIENTRY logNormal3bv(const GLbyte *v)\n{\n\tSIG( \"glNormal3bv\" );\n\tdllNormal3bv( v );\n}\n\nstatic void APIENTRY logNormal3d(GLdouble nx, GLdouble ny, GLdouble nz)\n{\n\tSIG( \"glNormal3d\" );\n\tdllNormal3d( nx, ny, nz );\n}\n\nstatic void APIENTRY logNormal3dv(const GLdouble *v)\n{\n\tSIG( \"glNormal3dv\" );\n\tdllNormal3dv( v );\n}\n\nstatic void APIENTRY logNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)\n{\n\tSIG( \"glNormal3f\" );\n\tdllNormal3f( nx, ny, nz );\n}\n\nstatic void APIENTRY logNormal3fv(const GLfloat *v)\n{\n\tSIG( \"glNormal3fv\" );\n\tdllNormal3fv( v );\n}\nstatic void APIENTRY logNormal3i(GLint nx, GLint ny, GLint nz)\n{\n\tSIG( \"glNormal3i\" );\n\tdllNormal3i( nx, ny, nz );\n}\nstatic void APIENTRY logNormal3iv(const GLint *v)\n{\n\tSIG( \"glNormal3iv\" );\n\tdllNormal3iv( v );\n}\nstatic void APIENTRY logNormal3s(GLshort nx, GLshort ny, GLshort nz)\n{\n\tSIG( \"glNormal3s\" );\n\tdllNormal3s( nx, ny, nz );\n}\nstatic void APIENTRY logNormal3sv(const GLshort *v)\n{\n\tSIG( \"glNormal3sv\" );\n\tdllNormal3sv( v );\n}\nstatic void APIENTRY logNormalPointer(GLenum type, GLsizei stride, const void *pointer)\n{\n\tSIG( \"glNormalPointer\" );\n\tdllNormalPointer( type, stride, pointer );\n}\nstatic void APIENTRY logOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)\n{\n\tSIG( \"glOrtho\" );\n\tdllOrtho( left, right, bottom, top, zNear, zFar );\n}\n\nstatic void APIENTRY logPassThrough(GLfloat token)\n{\n\tSIG( \"glPassThrough\" );\n\tdllPassThrough( token );\n}\n\nstatic void APIENTRY logPixelMapfv(GLenum map, GLsizei mapsize, const GLfloat *values)\n{\n\tSIG( \"glPixelMapfv\" );\n\tdllPixelMapfv( map, mapsize, values );\n}\n\nstatic void APIENTRY logPixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values)\n{\n\tSIG( \"glPixelMapuiv\" );\n\tdllPixelMapuiv( map, mapsize, values );\n}\n\nstatic void APIENTRY logPixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values)\n{\n\tSIG( \"glPixelMapusv\" );\n\tdllPixelMapusv( map, mapsize, values );\n}\nstatic void APIENTRY logPixelStoref(GLenum pname, GLfloat param)\n{\n\tSIG( \"glPixelStoref\" );\n\tdllPixelStoref( pname, param );\n}\nstatic void APIENTRY logPixelStorei(GLenum pname, GLint param)\n{\n\tSIG( \"glPixelStorei\" );\n\tdllPixelStorei( pname, param );\n}\nstatic void APIENTRY logPixelTransferf(GLenum pname, GLfloat param)\n{\n\tSIG( \"glPixelTransferf\" );\n\tdllPixelTransferf( pname, param );\n}\n\nstatic void APIENTRY logPixelTransferi(GLenum pname, GLint param)\n{\n\tSIG( \"glPixelTransferi\" );\n\tdllPixelTransferi( pname, param );\n}\n\nstatic void APIENTRY logPixelZoom(GLfloat xfactor, GLfloat yfactor)\n{\n\tSIG( \"glPixelZoom\" );\n\tdllPixelZoom( xfactor, yfactor );\n}\n\nstatic void APIENTRY logPointSize(GLfloat size)\n{\n\tSIG( \"glPointSize\" );\n\tdllPointSize( size );\n}\n\nstatic void APIENTRY logPolygonMode(GLenum face, GLenum mode)\n{\n\tfprintf( glw_state.log_fp, \"glPolygonMode( 0x%x, 0x%x )\\n\", face, mode );\n\tdllPolygonMode( face, mode );\n}\n\nstatic void APIENTRY logPolygonOffset(GLfloat factor, GLfloat units)\n{\n\tSIG( \"glPolygonOffset\" );\n\tdllPolygonOffset( factor, units );\n}\nstatic void APIENTRY logPolygonStipple(const GLubyte *mask )\n{\n\tSIG( \"glPolygonStipple\" );\n\tdllPolygonStipple( mask );\n}\nstatic void APIENTRY logPopAttrib(void)\n{\n\tSIG( \"glPopAttrib\" );\n\tdllPopAttrib();\n}\n\nstatic void APIENTRY logPopClientAttrib(void)\n{\n\tSIG( \"glPopClientAttrib\" );\n\tdllPopClientAttrib();\n}\n\nstatic void APIENTRY logPopMatrix(void)\n{\n\tSIG( \"glPopMatrix\" );\n\tdllPopMatrix();\n}\n\nstatic void APIENTRY logPopName(void)\n{\n\tSIG( \"glPopName\" );\n\tdllPopName();\n}\n\nstatic void APIENTRY logPrioritizeTextures(GLsizei n, const GLuint *textures, const GLclampf *priorities)\n{\n\tSIG( \"glPrioritizeTextures\" );\n\tdllPrioritizeTextures( n, textures, priorities );\n}\n\nstatic void APIENTRY logPushAttrib(GLbitfield mask)\n{\n\tSIG( \"glPushAttrib\" );\n\tdllPushAttrib( mask );\n}\n\nstatic void APIENTRY logPushClientAttrib(GLbitfield mask)\n{\n\tSIG( \"glPushClientAttrib\" );\n\tdllPushClientAttrib( mask );\n}\n\nstatic void APIENTRY logPushMatrix(void)\n{\n\tSIG( \"glPushMatrix\" );\n\tdllPushMatrix();\n}\n\nstatic void APIENTRY logPushName(GLuint name)\n{\n\tSIG( \"glPushName\" );\n\tdllPushName( name );\n}\n\nstatic void APIENTRY logRasterPos2d(GLdouble x, GLdouble y)\n{\n\tSIG (\"glRasterPot2d\" );\n\tdllRasterPos2d( x, y );\n}\n\nstatic void APIENTRY logRasterPos2dv(const GLdouble *v)\n{\n\tSIG( \"glRasterPos2dv\" );\n\tdllRasterPos2dv( v );\n}\n\nstatic void APIENTRY logRasterPos2f(GLfloat x, GLfloat y)\n{\n\tSIG( \"glRasterPos2f\" );\n\tdllRasterPos2f( x, y );\n}\nstatic void APIENTRY logRasterPos2fv(const GLfloat *v)\n{\n\tSIG( \"glRasterPos2dv\" );\n\tdllRasterPos2fv( v );\n}\nstatic void APIENTRY logRasterPos2i(GLint x, GLint y)\n{\n\tSIG( \"glRasterPos2if\" );\n\tdllRasterPos2i( x, y );\n}\nstatic void APIENTRY logRasterPos2iv(const GLint *v)\n{\n\tSIG( \"glRasterPos2iv\" );\n\tdllRasterPos2iv( v );\n}\nstatic void APIENTRY logRasterPos2s(GLshort x, GLshort y)\n{\n\tSIG( \"glRasterPos2s\" );\n\tdllRasterPos2s( x, y );\n}\nstatic void APIENTRY logRasterPos2sv(const GLshort *v)\n{\n\tSIG( \"glRasterPos2sv\" );\n\tdllRasterPos2sv( v );\n}\nstatic void APIENTRY logRasterPos3d(GLdouble x, GLdouble y, GLdouble z)\n{\n\tSIG( \"glRasterPos3d\" );\n\tdllRasterPos3d( x, y, z );\n}\nstatic void APIENTRY logRasterPos3dv(const GLdouble *v)\n{\n\tSIG( \"glRasterPos3dv\" );\n\tdllRasterPos3dv( v );\n}\nstatic void APIENTRY logRasterPos3f(GLfloat x, GLfloat y, GLfloat z)\n{\n\tSIG( \"glRasterPos3f\" );\n\tdllRasterPos3f( x, y, z );\n}\nstatic void APIENTRY logRasterPos3fv(const GLfloat *v)\n{\n\tSIG( \"glRasterPos3fv\" );\n\tdllRasterPos3fv( v );\n}\nstatic void APIENTRY logRasterPos3i(GLint x, GLint y, GLint z)\n{\n\tSIG( \"glRasterPos3i\" );\n\tdllRasterPos3i( x, y, z );\n}\nstatic void APIENTRY logRasterPos3iv(const GLint *v)\n{\n\tSIG( \"glRasterPos3iv\" );\n\tdllRasterPos3iv( v );\n}\nstatic void APIENTRY logRasterPos3s(GLshort x, GLshort y, GLshort z)\n{\n\tSIG( \"glRasterPos3s\" );\n\tdllRasterPos3s( x, y, z );\n}\nstatic void APIENTRY logRasterPos3sv(const GLshort *v)\n{\n\tSIG( \"glRasterPos3sv\" );\n\tdllRasterPos3sv( v );\n}\nstatic void APIENTRY logRasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)\n{\n\tSIG( \"glRasterPos4d\" );\n\tdllRasterPos4d( x, y, z, w );\n}\nstatic void APIENTRY logRasterPos4dv(const GLdouble *v)\n{\n\tSIG( \"glRasterPos4dv\" );\n\tdllRasterPos4dv( v );\n}\nstatic void APIENTRY logRasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)\n{\n\tSIG( \"glRasterPos4f\" );\n\tdllRasterPos4f( x, y, z, w );\n}\nstatic void APIENTRY logRasterPos4fv(const GLfloat *v)\n{\n\tSIG( \"glRasterPos4fv\" );\n\tdllRasterPos4fv( v );\n}\nstatic void APIENTRY logRasterPos4i(GLint x, GLint y, GLint z, GLint w)\n{\n\tSIG( \"glRasterPos4i\" );\n\tdllRasterPos4i( x, y, z, w );\n}\nstatic void APIENTRY logRasterPos4iv(const GLint *v)\n{\n\tSIG( \"glRasterPos4iv\" );\n\tdllRasterPos4iv( v );\n}\nstatic void APIENTRY logRasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)\n{\n\tSIG( \"glRasterPos4s\" );\n\tdllRasterPos4s( x, y, z, w );\n}\nstatic void APIENTRY logRasterPos4sv(const GLshort *v)\n{\n\tSIG( \"glRasterPos4sv\" );\n\tdllRasterPos4sv( v );\n}\nstatic void APIENTRY logReadBuffer(GLenum mode)\n{\n\tSIG( \"glReadBuffer\" );\n\tdllReadBuffer( mode );\n}\nstatic void APIENTRY logReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels)\n{\n\tSIG( \"glReadPixels\" );\n\tdllReadPixels( x, y, width, height, format, type, pixels );\n}\n\nstatic void APIENTRY logRectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)\n{\n\tSIG( \"glRectd\" );\n\tdllRectd( x1, y1, x2, y2 );\n}\n\nstatic void APIENTRY logRectdv(const GLdouble *v1, const GLdouble *v2)\n{\n\tSIG( \"glRectdv\" );\n\tdllRectdv( v1, v2 );\n}\n\nstatic void APIENTRY logRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)\n{\n\tSIG( \"glRectf\" );\n\tdllRectf( x1, y1, x2, y2 );\n}\n\nstatic void APIENTRY logRectfv(const GLfloat *v1, const GLfloat *v2)\n{\n\tSIG( \"glRectfv\" );\n\tdllRectfv( v1, v2 );\n}\nstatic void APIENTRY logRecti(GLint x1, GLint y1, GLint x2, GLint y2)\n{\n\tSIG( \"glRecti\" );\n\tdllRecti( x1, y1, x2, y2 );\n}\nstatic void APIENTRY logRectiv(const GLint *v1, const GLint *v2)\n{\n\tSIG( \"glRectiv\" );\n\tdllRectiv( v1, v2 );\n}\nstatic void APIENTRY logRects(GLshort x1, GLshort y1, GLshort x2, GLshort y2)\n{\n\tSIG( \"glRects\" );\n\tdllRects( x1, y1, x2, y2 );\n}\nstatic void APIENTRY logRectsv(const GLshort *v1, const GLshort *v2)\n{\n\tSIG( \"glRectsv\" );\n\tdllRectsv( v1, v2 );\n}\nstatic GLint APIENTRY logRenderMode(GLenum mode)\n{\n\tSIG( \"glRenderMode\" );\n\treturn dllRenderMode( mode );\n}\nstatic void APIENTRY logRotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z)\n{\n\tSIG( \"glRotated\" );\n\tdllRotated( angle, x, y, z );\n}\n\nstatic void APIENTRY logRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)\n{\n\tSIG( \"glRotatef\" );\n\tdllRotatef( angle, x, y, z );\n}\n\nstatic void APIENTRY logScaled(GLdouble x, GLdouble y, GLdouble z)\n{\n\tSIG( \"glScaled\" );\n\tdllScaled( x, y, z );\n}\n\nstatic void APIENTRY logScalef(GLfloat x, GLfloat y, GLfloat z)\n{\n\tSIG( \"glScalef\" );\n\tdllScalef( x, y, z );\n}\n\nstatic void APIENTRY logScissor(GLint x, GLint y, GLsizei width, GLsizei height)\n{\n\tSIG( \"glScissor\" );\n\tdllScissor( x, y, width, height );\n}\n\nstatic void APIENTRY logSelectBuffer(GLsizei size, GLuint *buffer)\n{\n\tSIG( \"glSelectBuffer\" );\n\tdllSelectBuffer( size, buffer );\n}\n\nstatic void APIENTRY logShadeModel(GLenum mode)\n{\n\tSIG( \"glShadeModel\" );\n\tdllShadeModel( mode );\n}\n\nstatic void APIENTRY logStencilFunc(GLenum func, GLint ref, GLuint mask)\n{\n\tSIG( \"glStencilFunc\" );\n\tdllStencilFunc( func, ref, mask );\n}\n\nstatic void APIENTRY logStencilMask(GLuint mask)\n{\n\tSIG( \"glStencilMask\" );\n\tdllStencilMask( mask );\n}\n\nstatic void APIENTRY logStencilOp(GLenum fail, GLenum zfail, GLenum zpass)\n{\n\tSIG( \"glStencilOp\" );\n\tdllStencilOp( fail, zfail, zpass );\n}\n\nstatic void APIENTRY logTexCoord1d(GLdouble s)\n{\n\tSIG( \"glTexCoord1d\" );\n\tdllTexCoord1d( s );\n}\n\nstatic void APIENTRY logTexCoord1dv(const GLdouble *v)\n{\n\tSIG( \"glTexCoord1dv\" );\n\tdllTexCoord1dv( v );\n}\n\nstatic void APIENTRY logTexCoord1f(GLfloat s)\n{\n\tSIG( \"glTexCoord1f\" );\n\tdllTexCoord1f( s );\n}\nstatic void APIENTRY logTexCoord1fv(const GLfloat *v)\n{\n\tSIG( \"glTexCoord1fv\" );\n\tdllTexCoord1fv( v );\n}\nstatic void APIENTRY logTexCoord1i(GLint s)\n{\n\tSIG( \"glTexCoord1i\" );\n\tdllTexCoord1i( s );\n}\nstatic void APIENTRY logTexCoord1iv(const GLint *v)\n{\n\tSIG( \"glTexCoord1iv\" );\n\tdllTexCoord1iv( v );\n}\nstatic void APIENTRY logTexCoord1s(GLshort s)\n{\n\tSIG( \"glTexCoord1s\" );\n\tdllTexCoord1s( s );\n}\nstatic void APIENTRY logTexCoord1sv(const GLshort *v)\n{\n\tSIG( \"glTexCoord1sv\" );\n\tdllTexCoord1sv( v );\n}\nstatic void APIENTRY logTexCoord2d(GLdouble s, GLdouble t)\n{\n\tSIG( \"glTexCoord2d\" );\n\tdllTexCoord2d( s, t );\n}\n\nstatic void APIENTRY logTexCoord2dv(const GLdouble *v)\n{\n\tSIG( \"glTexCoord2dv\" );\n\tdllTexCoord2dv( v );\n}\nstatic void APIENTRY logTexCoord2f(GLfloat s, GLfloat t)\n{\n\tSIG( \"glTexCoord2f\" );\n\tdllTexCoord2f( s, t );\n}\nstatic void APIENTRY logTexCoord2fv(const GLfloat *v)\n{\n\tSIG( \"glTexCoord2fv\" );\n\tdllTexCoord2fv( v );\n}\nstatic void APIENTRY logTexCoord2i(GLint s, GLint t)\n{\n\tSIG( \"glTexCoord2i\" );\n\tdllTexCoord2i( s, t );\n}\nstatic void APIENTRY logTexCoord2iv(const GLint *v)\n{\n\tSIG( \"glTexCoord2iv\" );\n\tdllTexCoord2iv( v );\n}\nstatic void APIENTRY logTexCoord2s(GLshort s, GLshort t)\n{\n\tSIG( \"glTexCoord2s\" );\n\tdllTexCoord2s( s, t );\n}\nstatic void APIENTRY logTexCoord2sv(const GLshort *v)\n{\n\tSIG( \"glTexCoord2sv\" );\n\tdllTexCoord2sv( v );\n}\nstatic void APIENTRY logTexCoord3d(GLdouble s, GLdouble t, GLdouble r)\n{\n\tSIG( \"glTexCoord3d\" );\n\tdllTexCoord3d( s, t, r );\n}\nstatic void APIENTRY logTexCoord3dv(const GLdouble *v)\n{\n\tSIG( \"glTexCoord3dv\" );\n\tdllTexCoord3dv( v );\n}\nstatic void APIENTRY logTexCoord3f(GLfloat s, GLfloat t, GLfloat r)\n{\n\tSIG( \"glTexCoord3f\" );\n\tdllTexCoord3f( s, t, r );\n}\nstatic void APIENTRY logTexCoord3fv(const GLfloat *v)\n{\n\tSIG( \"glTexCoord3fv\" );\n\tdllTexCoord3fv( v );\n}\nstatic void APIENTRY logTexCoord3i(GLint s, GLint t, GLint r)\n{\n\tSIG( \"glTexCoord3i\" );\n\tdllTexCoord3i( s, t, r );\n}\nstatic void APIENTRY logTexCoord3iv(const GLint *v)\n{\n\tSIG( \"glTexCoord3iv\" );\n\tdllTexCoord3iv( v );\n}\nstatic void APIENTRY logTexCoord3s(GLshort s, GLshort t, GLshort r)\n{\n\tSIG( \"glTexCoord3s\" );\n\tdllTexCoord3s( s, t, r );\n}\nstatic void APIENTRY logTexCoord3sv(const GLshort *v)\n{\n\tSIG( \"glTexCoord3sv\" );\n\tdllTexCoord3sv( v );\n}\nstatic void APIENTRY logTexCoord4d(GLdouble s, GLdouble t, GLdouble r, GLdouble q)\n{\n\tSIG( \"glTexCoord4d\" );\n\tdllTexCoord4d( s, t, r, q );\n}\nstatic void APIENTRY logTexCoord4dv(const GLdouble *v)\n{\n\tSIG( \"glTexCoord4dv\" );\n\tdllTexCoord4dv( v );\n}\nstatic void APIENTRY logTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q)\n{\n\tSIG( \"glTexCoord4f\" );\n\tdllTexCoord4f( s, t, r, q );\n}\nstatic void APIENTRY logTexCoord4fv(const GLfloat *v)\n{\n\tSIG( \"glTexCoord4fv\" );\n\tdllTexCoord4fv( v );\n}\nstatic void APIENTRY logTexCoord4i(GLint s, GLint t, GLint r, GLint q)\n{\n\tSIG( \"glTexCoord4i\" );\n\tdllTexCoord4i( s, t, r, q );\n}\nstatic void APIENTRY logTexCoord4iv(const GLint *v)\n{\n\tSIG( \"glTexCoord4iv\" );\n\tdllTexCoord4iv( v );\n}\nstatic void APIENTRY logTexCoord4s(GLshort s, GLshort t, GLshort r, GLshort q)\n{\n\tSIG( \"glTexCoord4s\" );\n\tdllTexCoord4s( s, t, r, q );\n}\nstatic void APIENTRY logTexCoord4sv(const GLshort *v)\n{\n\tSIG( \"glTexCoord4sv\" );\n\tdllTexCoord4sv( v );\n}\nstatic void APIENTRY logTexCoordPointer(GLint size, GLenum type, GLsizei stride, const void *pointer)\n{\n\tSIG( \"glTexCoordPointer\" );\n\tdllTexCoordPointer( size, type, stride, pointer );\n}\n\nstatic void APIENTRY logTexEnvf(GLenum target, GLenum pname, GLfloat param)\n{\n\tfprintf( glw_state.log_fp, \"glTexEnvf( 0x%x, 0x%x, %f )\\n\", target, pname, param );\n\tdllTexEnvf( target, pname, param );\n}\n\nstatic void APIENTRY logTexEnvfv(GLenum target, GLenum pname, const GLfloat *params)\n{\n\tSIG( \"glTexEnvfv\" );\n\tdllTexEnvfv( target, pname, params );\n}\n\nstatic void APIENTRY logTexEnvi(GLenum target, GLenum pname, GLint param)\n{\n\tfprintf( glw_state.log_fp, \"glTexEnvi( 0x%x, 0x%x, 0x%x )\\n\", target, pname, param );\n\tdllTexEnvi( target, pname, param );\n}\nstatic void APIENTRY logTexEnviv(GLenum target, GLenum pname, const GLint *params)\n{\n\tSIG( \"glTexEnviv\" );\n\tdllTexEnviv( target, pname, params );\n}\n\nstatic void APIENTRY logTexGend(GLenum coord, GLenum pname, GLdouble param)\n{\n\tSIG( \"glTexGend\" );\n\tdllTexGend( coord, pname, param );\n}\n\nstatic void APIENTRY logTexGendv(GLenum coord, GLenum pname, const GLdouble *params)\n{\n\tSIG( \"glTexGendv\" );\n\tdllTexGendv( coord, pname, params );\n}\n\nstatic void APIENTRY logTexGenf(GLenum coord, GLenum pname, GLfloat param)\n{\n\tSIG( \"glTexGenf\" );\n\tdllTexGenf( coord, pname, param );\n}\nstatic void APIENTRY logTexGenfv(GLenum coord, GLenum pname, const GLfloat *params)\n{\n\tSIG( \"glTexGenfv\" );\n\tdllTexGenfv( coord, pname, params );\n}\nstatic void APIENTRY logTexGeni(GLenum coord, GLenum pname, GLint param)\n{\n\tSIG( \"glTexGeni\" );\n\tdllTexGeni( coord, pname, param );\n}\nstatic void APIENTRY logTexGeniv(GLenum coord, GLenum pname, const GLint *params)\n{\n\tSIG( \"glTexGeniv\" );\n\tdllTexGeniv( coord, pname, params );\n}\nstatic void APIENTRY logTexImage1D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels)\n{\n\tSIG( \"glTexImage1D\" );\n\tdllTexImage1D( target, level, internalformat, width, border, format, type, pixels );\n}\nstatic void APIENTRY logTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels)\n{\n\tSIG( \"glTexImage2D\" );\n\tdllTexImage2D( target, level, internalformat, width, height, border, format, type, pixels );\n}\n\nstatic void APIENTRY logTexParameterf(GLenum target, GLenum pname, GLfloat param)\n{\n\tfprintf( glw_state.log_fp, \"glTexParameterf( 0x%x, 0x%x, %f )\\n\", target, pname, param );\n\tdllTexParameterf( target, pname, param );\n}\n\nstatic void APIENTRY logTexParameterfv(GLenum target, GLenum pname, const GLfloat *params)\n{\n\tSIG( \"glTexParameterfv\" );\n\tdllTexParameterfv( target, pname, params );\n}\nstatic void APIENTRY logTexParameteri(GLenum target, GLenum pname, GLint param)\n{\n\tfprintf( glw_state.log_fp, \"glTexParameteri( 0x%x, 0x%x, 0x%x )\\n\", target, pname, param );\n\tdllTexParameteri( target, pname, param );\n}\nstatic void APIENTRY logTexParameteriv(GLenum target, GLenum pname, const GLint *params)\n{\n\tSIG( \"glTexParameteriv\" );\n\tdllTexParameteriv( target, pname, params );\n}\nstatic void APIENTRY logTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels)\n{\n\tSIG( \"glTexSubImage1D\" );\n\tdllTexSubImage1D( target, level, xoffset, width, format, type, pixels );\n}\nstatic void APIENTRY logTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels)\n{\n\tSIG( \"glTexSubImage2D\" );\n\tdllTexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, pixels );\n}\nstatic void APIENTRY logTranslated(GLdouble x, GLdouble y, GLdouble z)\n{\n\tSIG( \"glTranslated\" );\n\tdllTranslated( x, y, z );\n}\n\nstatic void APIENTRY logTranslatef(GLfloat x, GLfloat y, GLfloat z)\n{\n\tSIG( \"glTranslatef\" );\n\tdllTranslatef( x, y, z );\n}\n\nstatic void APIENTRY logVertex2d(GLdouble x, GLdouble y)\n{\n\tSIG( \"glVertex2d\" );\n\tdllVertex2d( x, y );\n}\n\nstatic void APIENTRY logVertex2dv(const GLdouble *v)\n{\n\tSIG( \"glVertex2dv\" );\n\tdllVertex2dv( v );\n}\nstatic void APIENTRY logVertex2f(GLfloat x, GLfloat y)\n{\n\tSIG( \"glVertex2f\" );\n\tdllVertex2f( x, y );\n}\nstatic void APIENTRY logVertex2fv(const GLfloat *v)\n{\n\tSIG( \"glVertex2fv\" );\n\tdllVertex2fv( v );\n}\nstatic void APIENTRY logVertex2i(GLint x, GLint y)\n{\n\tSIG( \"glVertex2i\" );\n\tdllVertex2i( x, y );\n}\nstatic void APIENTRY logVertex2iv(const GLint *v)\n{\n\tSIG( \"glVertex2iv\" );\n\tdllVertex2iv( v );\n}\nstatic void APIENTRY logVertex2s(GLshort x, GLshort y)\n{\n\tSIG( \"glVertex2s\" );\n\tdllVertex2s( x, y );\n}\nstatic void APIENTRY logVertex2sv(const GLshort *v)\n{\n\tSIG( \"glVertex2sv\" );\n\tdllVertex2sv( v );\n}\nstatic void APIENTRY logVertex3d(GLdouble x, GLdouble y, GLdouble z)\n{\n\tSIG( \"glVertex3d\" );\n\tdllVertex3d( x, y, z );\n}\nstatic void APIENTRY logVertex3dv(const GLdouble *v)\n{\n\tSIG( \"glVertex3dv\" );\n\tdllVertex3dv( v );\n}\nstatic void APIENTRY logVertex3f(GLfloat x, GLfloat y, GLfloat z)\n{\n\tSIG( \"glVertex3f\" );\n\tdllVertex3f( x, y, z );\n}\nstatic void APIENTRY logVertex3fv(const GLfloat *v)\n{\n\tSIG( \"glVertex3fv\" );\n\tdllVertex3fv( v );\n}\nstatic void APIENTRY logVertex3i(GLint x, GLint y, GLint z)\n{\n\tSIG( \"glVertex3i\" );\n\tdllVertex3i( x, y, z );\n}\nstatic void APIENTRY logVertex3iv(const GLint *v)\n{\n\tSIG( \"glVertex3iv\" );\n\tdllVertex3iv( v );\n}\nstatic void APIENTRY logVertex3s(GLshort x, GLshort y, GLshort z)\n{\n\tSIG( \"glVertex3s\" );\n\tdllVertex3s( x, y, z );\n}\nstatic void APIENTRY logVertex3sv(const GLshort *v)\n{\n\tSIG( \"glVertex3sv\" );\n\tdllVertex3sv( v );\n}\nstatic void APIENTRY logVertex4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)\n{\n\tSIG( \"glVertex4d\" );\n\tdllVertex4d( x, y, z, w );\n}\nstatic void APIENTRY logVertex4dv(const GLdouble *v)\n{\n\tSIG( \"glVertex4dv\" );\n\tdllVertex4dv( v );\n}\nstatic void APIENTRY logVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)\n{\n\tSIG( \"glVertex4f\" );\n\tdllVertex4f( x, y, z, w );\n}\nstatic void APIENTRY logVertex4fv(const GLfloat *v)\n{\n\tSIG( \"glVertex4fv\" );\n\tdllVertex4fv( v );\n}\nstatic void APIENTRY logVertex4i(GLint x, GLint y, GLint z, GLint w)\n{\n\tSIG( \"glVertex4i\" );\n\tdllVertex4i( x, y, z, w );\n}\nstatic void APIENTRY logVertex4iv(const GLint *v)\n{\n\tSIG( \"glVertex4iv\" );\n\tdllVertex4iv( v );\n}\nstatic void APIENTRY logVertex4s(GLshort x, GLshort y, GLshort z, GLshort w)\n{\n\tSIG( \"glVertex4s\" );\n\tdllVertex4s( x, y, z, w );\n}\nstatic void APIENTRY logVertex4sv(const GLshort *v)\n{\n\tSIG( \"glVertex4sv\" );\n\tdllVertex4sv( v );\n}\nstatic void APIENTRY logVertexPointer(GLint size, GLenum type, GLsizei stride, const void *pointer)\n{\n\tSIG( \"glVertexPointer\" );\n\tdllVertexPointer( size, type, stride, pointer );\n}\nstatic void APIENTRY logViewport(GLint x, GLint y, GLsizei width, GLsizei height)\n{\n\tSIG( \"glViewport\" );\n\tdllViewport( x, y, width, height );\n}\n\n/*\n** QGL_Shutdown\n**\n** Unloads the specified DLL then nulls out all the proc pointers.\n*/\nvoid QGL_Shutdown( void )\n{\n\tif ( glw_state.OpenGLLib )\n\t{\n\t\tdlclose ( glw_state.OpenGLLib );\n\t\tglw_state.OpenGLLib = NULL;\n\t}\n\n\tglw_state.OpenGLLib = NULL;\n\n\tqglAccum                     = NULL;\n\tqglAlphaFunc                 = NULL;\n\tqglAreTexturesResident       = NULL;\n\tqglArrayElement              = NULL;\n\tqglBegin                     = NULL;\n\tqglBindTexture               = NULL;\n\tqglBitmap                    = NULL;\n\tqglBlendFunc                 = NULL;\n\tqglCallList                  = NULL;\n\tqglCallLists                 = NULL;\n\tqglClear                     = NULL;\n\tqglClearAccum                = NULL;\n\tqglClearColor                = NULL;\n\tqglClearDepth                = NULL;\n\tqglClearIndex                = NULL;\n\tqglClearStencil              = NULL;\n\tqglClipPlane                 = NULL;\n\tqglColor3b                   = NULL;\n\tqglColor3bv                  = NULL;\n\tqglColor3d                   = NULL;\n\tqglColor3dv                  = NULL;\n\tqglColor3f                   = NULL;\n\tqglColor3fv                  = NULL;\n\tqglColor3i                   = NULL;\n\tqglColor3iv                  = NULL;\n\tqglColor3s                   = NULL;\n\tqglColor3sv                  = NULL;\n\tqglColor3ub                  = NULL;\n\tqglColor3ubv                 = NULL;\n\tqglColor3ui                  = NULL;\n\tqglColor3uiv                 = NULL;\n\tqglColor3us                  = NULL;\n\tqglColor3usv                 = NULL;\n\tqglColor4b                   = NULL;\n\tqglColor4bv                  = NULL;\n\tqglColor4d                   = NULL;\n\tqglColor4dv                  = NULL;\n\tqglColor4f                   = NULL;\n\tqglColor4fv                  = NULL;\n\tqglColor4i                   = NULL;\n\tqglColor4iv                  = NULL;\n\tqglColor4s                   = NULL;\n\tqglColor4sv                  = NULL;\n\tqglColor4ub                  = NULL;\n\tqglColor4ubv                 = NULL;\n\tqglColor4ui                  = NULL;\n\tqglColor4uiv                 = NULL;\n\tqglColor4us                  = NULL;\n\tqglColor4usv                 = NULL;\n\tqglColorMask                 = NULL;\n\tqglColorMaterial             = NULL;\n\tqglColorPointer              = NULL;\n\tqglCopyPixels                = NULL;\n\tqglCopyTexImage1D            = NULL;\n\tqglCopyTexImage2D            = NULL;\n\tqglCopyTexSubImage1D         = NULL;\n\tqglCopyTexSubImage2D         = NULL;\n\tqglCullFace                  = NULL;\n\tqglDeleteLists               = NULL;\n\tqglDeleteTextures            = NULL;\n\tqglDepthFunc                 = NULL;\n\tqglDepthMask                 = NULL;\n\tqglDepthRange                = NULL;\n\tqglDisable                   = NULL;\n\tqglDisableClientState        = NULL;\n\tqglDrawArrays                = NULL;\n\tqglDrawBuffer                = NULL;\n\tqglDrawElements              = NULL;\n\tqglDrawPixels                = NULL;\n\tqglEdgeFlag                  = NULL;\n\tqglEdgeFlagPointer           = NULL;\n\tqglEdgeFlagv                 = NULL;\n\tqglEnable                    = NULL;\n\tqglEnableClientState         = NULL;\n\tqglEnd                       = NULL;\n\tqglEndList                   = NULL;\n\tqglEvalCoord1d               = NULL;\n\tqglEvalCoord1dv              = NULL;\n\tqglEvalCoord1f               = NULL;\n\tqglEvalCoord1fv              = NULL;\n\tqglEvalCoord2d               = NULL;\n\tqglEvalCoord2dv              = NULL;\n\tqglEvalCoord2f               = NULL;\n\tqglEvalCoord2fv              = NULL;\n\tqglEvalMesh1                 = NULL;\n\tqglEvalMesh2                 = NULL;\n\tqglEvalPoint1                = NULL;\n\tqglEvalPoint2                = NULL;\n\tqglFeedbackBuffer            = NULL;\n\tqglFinish                    = NULL;\n\tqglFlush                     = NULL;\n\tqglFogf                      = NULL;\n\tqglFogfv                     = NULL;\n\tqglFogi                      = NULL;\n\tqglFogiv                     = NULL;\n\tqglFrontFace                 = NULL;\n\tqglFrustum                   = NULL;\n\tqglGenLists                  = NULL;\n\tqglGenTextures               = NULL;\n\tqglGetBooleanv               = NULL;\n\tqglGetClipPlane              = NULL;\n\tqglGetDoublev                = NULL;\n\tqglGetError                  = NULL;\n\tqglGetFloatv                 = NULL;\n\tqglGetIntegerv               = NULL;\n\tqglGetLightfv                = NULL;\n\tqglGetLightiv                = NULL;\n\tqglGetMapdv                  = NULL;\n\tqglGetMapfv                  = NULL;\n\tqglGetMapiv                  = NULL;\n\tqglGetMaterialfv             = NULL;\n\tqglGetMaterialiv             = NULL;\n\tqglGetPixelMapfv             = NULL;\n\tqglGetPixelMapuiv            = NULL;\n\tqglGetPixelMapusv            = NULL;\n\tqglGetPointerv               = NULL;\n\tqglGetPolygonStipple         = NULL;\n\tqglGetString                 = NULL;\n\tqglGetTexEnvfv               = NULL;\n\tqglGetTexEnviv               = NULL;\n\tqglGetTexGendv               = NULL;\n\tqglGetTexGenfv               = NULL;\n\tqglGetTexGeniv               = NULL;\n\tqglGetTexImage               = NULL;\n\tqglGetTexLevelParameterfv    = NULL;\n\tqglGetTexLevelParameteriv    = NULL;\n\tqglGetTexParameterfv         = NULL;\n\tqglGetTexParameteriv         = NULL;\n\tqglHint                      = NULL;\n\tqglIndexMask                 = NULL;\n\tqglIndexPointer              = NULL;\n\tqglIndexd                    = NULL;\n\tqglIndexdv                   = NULL;\n\tqglIndexf                    = NULL;\n\tqglIndexfv                   = NULL;\n\tqglIndexi                    = NULL;\n\tqglIndexiv                   = NULL;\n\tqglIndexs                    = NULL;\n\tqglIndexsv                   = NULL;\n\tqglIndexub                   = NULL;\n\tqglIndexubv                  = NULL;\n\tqglInitNames                 = NULL;\n\tqglInterleavedArrays         = NULL;\n\tqglIsEnabled                 = NULL;\n\tqglIsList                    = NULL;\n\tqglIsTexture                 = NULL;\n\tqglLightModelf               = NULL;\n\tqglLightModelfv              = NULL;\n\tqglLightModeli               = NULL;\n\tqglLightModeliv              = NULL;\n\tqglLightf                    = NULL;\n\tqglLightfv                   = NULL;\n\tqglLighti                    = NULL;\n\tqglLightiv                   = NULL;\n\tqglLineStipple               = NULL;\n\tqglLineWidth                 = NULL;\n\tqglListBase                  = NULL;\n\tqglLoadIdentity              = NULL;\n\tqglLoadMatrixd               = NULL;\n\tqglLoadMatrixf               = NULL;\n\tqglLoadName                  = NULL;\n\tqglLogicOp                   = NULL;\n\tqglMap1d                     = NULL;\n\tqglMap1f                     = NULL;\n\tqglMap2d                     = NULL;\n\tqglMap2f                     = NULL;\n\tqglMapGrid1d                 = NULL;\n\tqglMapGrid1f                 = NULL;\n\tqglMapGrid2d                 = NULL;\n\tqglMapGrid2f                 = NULL;\n\tqglMaterialf                 = NULL;\n\tqglMaterialfv                = NULL;\n\tqglMateriali                 = NULL;\n\tqglMaterialiv                = NULL;\n\tqglMatrixMode                = NULL;\n\tqglMultMatrixd               = NULL;\n\tqglMultMatrixf               = NULL;\n\tqglNewList                   = NULL;\n\tqglNormal3b                  = NULL;\n\tqglNormal3bv                 = NULL;\n\tqglNormal3d                  = NULL;\n\tqglNormal3dv                 = NULL;\n\tqglNormal3f                  = NULL;\n\tqglNormal3fv                 = NULL;\n\tqglNormal3i                  = NULL;\n\tqglNormal3iv                 = NULL;\n\tqglNormal3s                  = NULL;\n\tqglNormal3sv                 = NULL;\n\tqglNormalPointer             = NULL;\n\tqglOrtho                     = NULL;\n\tqglPassThrough               = NULL;\n\tqglPixelMapfv                = NULL;\n\tqglPixelMapuiv               = NULL;\n\tqglPixelMapusv               = NULL;\n\tqglPixelStoref               = NULL;\n\tqglPixelStorei               = NULL;\n\tqglPixelTransferf            = NULL;\n\tqglPixelTransferi            = NULL;\n\tqglPixelZoom                 = NULL;\n\tqglPointSize                 = NULL;\n\tqglPolygonMode               = NULL;\n\tqglPolygonOffset             = NULL;\n\tqglPolygonStipple            = NULL;\n\tqglPopAttrib                 = NULL;\n\tqglPopClientAttrib           = NULL;\n\tqglPopMatrix                 = NULL;\n\tqglPopName                   = NULL;\n\tqglPrioritizeTextures        = NULL;\n\tqglPushAttrib                = NULL;\n\tqglPushClientAttrib          = NULL;\n\tqglPushMatrix                = NULL;\n\tqglPushName                  = NULL;\n\tqglRasterPos2d               = NULL;\n\tqglRasterPos2dv              = NULL;\n\tqglRasterPos2f               = NULL;\n\tqglRasterPos2fv              = NULL;\n\tqglRasterPos2i               = NULL;\n\tqglRasterPos2iv              = NULL;\n\tqglRasterPos2s               = NULL;\n\tqglRasterPos2sv              = NULL;\n\tqglRasterPos3d               = NULL;\n\tqglRasterPos3dv              = NULL;\n\tqglRasterPos3f               = NULL;\n\tqglRasterPos3fv              = NULL;\n\tqglRasterPos3i               = NULL;\n\tqglRasterPos3iv              = NULL;\n\tqglRasterPos3s               = NULL;\n\tqglRasterPos3sv              = NULL;\n\tqglRasterPos4d               = NULL;\n\tqglRasterPos4dv              = NULL;\n\tqglRasterPos4f               = NULL;\n\tqglRasterPos4fv              = NULL;\n\tqglRasterPos4i               = NULL;\n\tqglRasterPos4iv              = NULL;\n\tqglRasterPos4s               = NULL;\n\tqglRasterPos4sv              = NULL;\n\tqglReadBuffer                = NULL;\n\tqglReadPixels                = NULL;\n\tqglRectd                     = NULL;\n\tqglRectdv                    = NULL;\n\tqglRectf                     = NULL;\n\tqglRectfv                    = NULL;\n\tqglRecti                     = NULL;\n\tqglRectiv                    = NULL;\n\tqglRects                     = NULL;\n\tqglRectsv                    = NULL;\n\tqglRenderMode                = NULL;\n\tqglRotated                   = NULL;\n\tqglRotatef                   = NULL;\n\tqglScaled                    = NULL;\n\tqglScalef                    = NULL;\n\tqglScissor                   = NULL;\n\tqglSelectBuffer              = NULL;\n\tqglShadeModel                = NULL;\n\tqglStencilFunc               = NULL;\n\tqglStencilMask               = NULL;\n\tqglStencilOp                 = NULL;\n\tqglTexCoord1d                = NULL;\n\tqglTexCoord1dv               = NULL;\n\tqglTexCoord1f                = NULL;\n\tqglTexCoord1fv               = NULL;\n\tqglTexCoord1i                = NULL;\n\tqglTexCoord1iv               = NULL;\n\tqglTexCoord1s                = NULL;\n\tqglTexCoord1sv               = NULL;\n\tqglTexCoord2d                = NULL;\n\tqglTexCoord2dv               = NULL;\n\tqglTexCoord2f                = NULL;\n\tqglTexCoord2fv               = NULL;\n\tqglTexCoord2i                = NULL;\n\tqglTexCoord2iv               = NULL;\n\tqglTexCoord2s                = NULL;\n\tqglTexCoord2sv               = NULL;\n\tqglTexCoord3d                = NULL;\n\tqglTexCoord3dv               = NULL;\n\tqglTexCoord3f                = NULL;\n\tqglTexCoord3fv               = NULL;\n\tqglTexCoord3i                = NULL;\n\tqglTexCoord3iv               = NULL;\n\tqglTexCoord3s                = NULL;\n\tqglTexCoord3sv               = NULL;\n\tqglTexCoord4d                = NULL;\n\tqglTexCoord4dv               = NULL;\n\tqglTexCoord4f                = NULL;\n\tqglTexCoord4fv               = NULL;\n\tqglTexCoord4i                = NULL;\n\tqglTexCoord4iv               = NULL;\n\tqglTexCoord4s                = NULL;\n\tqglTexCoord4sv               = NULL;\n\tqglTexCoordPointer           = NULL;\n\tqglTexEnvf                   = NULL;\n\tqglTexEnvfv                  = NULL;\n\tqglTexEnvi                   = NULL;\n\tqglTexEnviv                  = NULL;\n\tqglTexGend                   = NULL;\n\tqglTexGendv                  = NULL;\n\tqglTexGenf                   = NULL;\n\tqglTexGenfv                  = NULL;\n\tqglTexGeni                   = NULL;\n\tqglTexGeniv                  = NULL;\n\tqglTexImage1D                = NULL;\n\tqglTexImage2D                = NULL;\n\tqglTexParameterf             = NULL;\n\tqglTexParameterfv            = NULL;\n\tqglTexParameteri             = NULL;\n\tqglTexParameteriv            = NULL;\n\tqglTexSubImage1D             = NULL;\n\tqglTexSubImage2D             = NULL;\n\tqglTranslated                = NULL;\n\tqglTranslatef                = NULL;\n\tqglVertex2d                  = NULL;\n\tqglVertex2dv                 = NULL;\n\tqglVertex2f                  = NULL;\n\tqglVertex2fv                 = NULL;\n\tqglVertex2i                  = NULL;\n\tqglVertex2iv                 = NULL;\n\tqglVertex2s                  = NULL;\n\tqglVertex2sv                 = NULL;\n\tqglVertex3d                  = NULL;\n\tqglVertex3dv                 = NULL;\n\tqglVertex3f                  = NULL;\n\tqglVertex3fv                 = NULL;\n\tqglVertex3i                  = NULL;\n\tqglVertex3iv                 = NULL;\n\tqglVertex3s                  = NULL;\n\tqglVertex3sv                 = NULL;\n\tqglVertex4d                  = NULL;\n\tqglVertex4dv                 = NULL;\n\tqglVertex4f                  = NULL;\n\tqglVertex4fv                 = NULL;\n\tqglVertex4i                  = NULL;\n\tqglVertex4iv                 = NULL;\n\tqglVertex4s                  = NULL;\n\tqglVertex4sv                 = NULL;\n\tqglVertexPointer             = NULL;\n\tqglViewport                  = NULL;\n\n// bk001129 - from cvs1.17 (mkv)\n#if defined(__FX__)\n\tqfxMesaCreateContext         = NULL;\n\tqfxMesaCreateBestContext     = NULL;\n\tqfxMesaDestroyContext        = NULL;\n\tqfxMesaMakeCurrent           = NULL;\n\tqfxMesaGetCurrentContext     = NULL;\n\tqfxMesaSwapBuffers           = NULL;\n#endif\n\n\tqglXChooseVisual             = NULL;\n\tqglXCreateContext            = NULL;\n\tqglXDestroyContext           = NULL;\n\tqglXMakeCurrent              = NULL;\n\tqglXCopyContext              = NULL;\n\tqglXSwapBuffers              = NULL;\n}\n\n#define GPA( a ) dlsym( glw_state.OpenGLLib, a )\n\nvoid *qwglGetProcAddress(char *symbol)\n{\n\tif (glw_state.OpenGLLib)\n\t\treturn GPA ( symbol );\n\treturn NULL;\n}\n\n/*\n** QGL_Init\n**\n** This is responsible for binding our qgl function pointers to \n** the appropriate GL stuff.  In Windows this means doing a \n** LoadLibrary and a bunch of calls to GetProcAddress.  On other\n** operating systems we need to do the right thing, whatever that\n** might be.\n** \n*/\n\nqboolean QGL_Init( const char *dllname )\n{\n\tif ( ( glw_state.OpenGLLib = dlopen( dllname, RTLD_LAZY|RTLD_GLOBAL ) ) == 0 )\n\t{\n\t\tchar\tfn[1024];\n\t\t// FILE *fp; // bk001204 - unused\n\t\textern uid_t saved_euid; // unix_main.c\n\n\t\t// if we are not setuid, try current directory\n\t\tif (getuid() == saved_euid) {\n\t\t\tgetcwd(fn, sizeof(fn));\n\t\t\tQ_strcat(fn, sizeof(fn), \"/\");\n\t\t\tQ_strcat(fn, sizeof(fn), dllname);\n\n\t\t\tif ( ( glw_state.OpenGLLib = dlopen( fn, RTLD_LAZY ) ) == 0 ) {\n\t\t\t\tri.Printf(PRINT_ALL, \"QGL_Init: Can't load %s from /etc/ld.so.conf or current dir: %s\\n\", dllname, dlerror());\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t} else {\n\t\t\tri.Printf(PRINT_ALL, \"QGL_Init: Can't load %s from /etc/ld.so.conf: %s\\n\", dllname, dlerror());\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\tqglAccum                     = dllAccum = GPA( \"glAccum\" );\n\tqglAlphaFunc                 = dllAlphaFunc = GPA( \"glAlphaFunc\" );\n\tqglAreTexturesResident       = dllAreTexturesResident = GPA( \"glAreTexturesResident\" );\n\tqglArrayElement              = dllArrayElement = GPA( \"glArrayElement\" );\n\tqglBegin                     = dllBegin = GPA( \"glBegin\" );\n\tqglBindTexture               = dllBindTexture = GPA( \"glBindTexture\" );\n\tqglBitmap                    = dllBitmap = GPA( \"glBitmap\" );\n\tqglBlendFunc                 = dllBlendFunc = GPA( \"glBlendFunc\" );\n\tqglCallList                  = dllCallList = GPA( \"glCallList\" );\n\tqglCallLists                 = dllCallLists = GPA( \"glCallLists\" );\n\tqglClear                     = dllClear = GPA( \"glClear\" );\n\tqglClearAccum                = dllClearAccum = GPA( \"glClearAccum\" );\n\tqglClearColor                = dllClearColor = GPA( \"glClearColor\" );\n\tqglClearDepth                = dllClearDepth = GPA( \"glClearDepth\" );\n\tqglClearIndex                = dllClearIndex = GPA( \"glClearIndex\" );\n\tqglClearStencil              = dllClearStencil = GPA( \"glClearStencil\" );\n\tqglClipPlane                 = dllClipPlane = GPA( \"glClipPlane\" );\n\tqglColor3b                   = dllColor3b = GPA( \"glColor3b\" );\n\tqglColor3bv                  = dllColor3bv = GPA( \"glColor3bv\" );\n\tqglColor3d                   = dllColor3d = GPA( \"glColor3d\" );\n\tqglColor3dv                  = dllColor3dv = GPA( \"glColor3dv\" );\n\tqglColor3f                   = dllColor3f = GPA( \"glColor3f\" );\n\tqglColor3fv                  = dllColor3fv = GPA( \"glColor3fv\" );\n\tqglColor3i                   = dllColor3i = GPA( \"glColor3i\" );\n\tqglColor3iv                  = dllColor3iv = GPA( \"glColor3iv\" );\n\tqglColor3s                   = dllColor3s = GPA( \"glColor3s\" );\n\tqglColor3sv                  = dllColor3sv = GPA( \"glColor3sv\" );\n\tqglColor3ub                  = dllColor3ub = GPA( \"glColor3ub\" );\n\tqglColor3ubv                 = dllColor3ubv = GPA( \"glColor3ubv\" );\n\tqglColor3ui                  = dllColor3ui = GPA( \"glColor3ui\" );\n\tqglColor3uiv                 = dllColor3uiv = GPA( \"glColor3uiv\" );\n\tqglColor3us                  = dllColor3us = GPA( \"glColor3us\" );\n\tqglColor3usv                 = dllColor3usv = GPA( \"glColor3usv\" );\n\tqglColor4b                   = dllColor4b = GPA( \"glColor4b\" );\n\tqglColor4bv                  = dllColor4bv = GPA( \"glColor4bv\" );\n\tqglColor4d                   = dllColor4d = GPA( \"glColor4d\" );\n\tqglColor4dv                  = dllColor4dv = GPA( \"glColor4dv\" );\n\tqglColor4f                   = dllColor4f = GPA( \"glColor4f\" );\n\tqglColor4fv                  = dllColor4fv = GPA( \"glColor4fv\" );\n\tqglColor4i                   = dllColor4i = GPA( \"glColor4i\" );\n\tqglColor4iv                  = dllColor4iv = GPA( \"glColor4iv\" );\n\tqglColor4s                   = dllColor4s = GPA( \"glColor4s\" );\n\tqglColor4sv                  = dllColor4sv = GPA( \"glColor4sv\" );\n\tqglColor4ub                  = dllColor4ub = GPA( \"glColor4ub\" );\n\tqglColor4ubv                 = dllColor4ubv = GPA( \"glColor4ubv\" );\n\tqglColor4ui                  = dllColor4ui = GPA( \"glColor4ui\" );\n\tqglColor4uiv                 = dllColor4uiv = GPA( \"glColor4uiv\" );\n\tqglColor4us                  = dllColor4us = GPA( \"glColor4us\" );\n\tqglColor4usv                 = dllColor4usv = GPA( \"glColor4usv\" );\n\tqglColorMask                 = dllColorMask = GPA( \"glColorMask\" );\n\tqglColorMaterial             = dllColorMaterial = GPA( \"glColorMaterial\" );\n\tqglColorPointer              = dllColorPointer = GPA( \"glColorPointer\" );\n\tqglCopyPixels                = dllCopyPixels = GPA( \"glCopyPixels\" );\n\tqglCopyTexImage1D            = dllCopyTexImage1D = GPA( \"glCopyTexImage1D\" );\n\tqglCopyTexImage2D            = dllCopyTexImage2D = GPA( \"glCopyTexImage2D\" );\n\tqglCopyTexSubImage1D         = dllCopyTexSubImage1D = GPA( \"glCopyTexSubImage1D\" );\n\tqglCopyTexSubImage2D         = dllCopyTexSubImage2D = GPA( \"glCopyTexSubImage2D\" );\n\tqglCullFace                  = dllCullFace = GPA( \"glCullFace\" );\n\tqglDeleteLists               = dllDeleteLists = GPA( \"glDeleteLists\" );\n\tqglDeleteTextures            = dllDeleteTextures = GPA( \"glDeleteTextures\" );\n\tqglDepthFunc                 = dllDepthFunc = GPA( \"glDepthFunc\" );\n\tqglDepthMask                 = dllDepthMask = GPA( \"glDepthMask\" );\n\tqglDepthRange                = dllDepthRange = GPA( \"glDepthRange\" );\n\tqglDisable                   = dllDisable = GPA( \"glDisable\" );\n\tqglDisableClientState        = dllDisableClientState = GPA( \"glDisableClientState\" );\n\tqglDrawArrays                = dllDrawArrays = GPA( \"glDrawArrays\" );\n\tqglDrawBuffer                = dllDrawBuffer = GPA( \"glDrawBuffer\" );\n\tqglDrawElements              = dllDrawElements = GPA( \"glDrawElements\" );\n\tqglDrawPixels                = dllDrawPixels = GPA( \"glDrawPixels\" );\n\tqglEdgeFlag                  = dllEdgeFlag = GPA( \"glEdgeFlag\" );\n\tqglEdgeFlagPointer           = dllEdgeFlagPointer = GPA( \"glEdgeFlagPointer\" );\n\tqglEdgeFlagv                 = dllEdgeFlagv = GPA( \"glEdgeFlagv\" );\n\tqglEnable                    = \tdllEnable                    = GPA( \"glEnable\" );\n\tqglEnableClientState         = \tdllEnableClientState         = GPA( \"glEnableClientState\" );\n\tqglEnd                       = \tdllEnd                       = GPA( \"glEnd\" );\n\tqglEndList                   = \tdllEndList                   = GPA( \"glEndList\" );\n\tqglEvalCoord1d\t\t\t\t = \tdllEvalCoord1d\t\t\t\t = GPA( \"glEvalCoord1d\" );\n\tqglEvalCoord1dv              = \tdllEvalCoord1dv              = GPA( \"glEvalCoord1dv\" );\n\tqglEvalCoord1f               = \tdllEvalCoord1f               = GPA( \"glEvalCoord1f\" );\n\tqglEvalCoord1fv              = \tdllEvalCoord1fv              = GPA( \"glEvalCoord1fv\" );\n\tqglEvalCoord2d               = \tdllEvalCoord2d               = GPA( \"glEvalCoord2d\" );\n\tqglEvalCoord2dv              = \tdllEvalCoord2dv              = GPA( \"glEvalCoord2dv\" );\n\tqglEvalCoord2f               = \tdllEvalCoord2f               = GPA( \"glEvalCoord2f\" );\n\tqglEvalCoord2fv              = \tdllEvalCoord2fv              = GPA( \"glEvalCoord2fv\" );\n\tqglEvalMesh1                 = \tdllEvalMesh1                 = GPA( \"glEvalMesh1\" );\n\tqglEvalMesh2                 = \tdllEvalMesh2                 = GPA( \"glEvalMesh2\" );\n\tqglEvalPoint1                = \tdllEvalPoint1                = GPA( \"glEvalPoint1\" );\n\tqglEvalPoint2                = \tdllEvalPoint2                = GPA( \"glEvalPoint2\" );\n\tqglFeedbackBuffer            = \tdllFeedbackBuffer            = GPA( \"glFeedbackBuffer\" );\n\tqglFinish                    = \tdllFinish                    = GPA( \"glFinish\" );\n\tqglFlush                     = \tdllFlush                     = GPA( \"glFlush\" );\n\tqglFogf                      = \tdllFogf                      = GPA( \"glFogf\" );\n\tqglFogfv                     = \tdllFogfv                     = GPA( \"glFogfv\" );\n\tqglFogi                      = \tdllFogi                      = GPA( \"glFogi\" );\n\tqglFogiv                     = \tdllFogiv                     = GPA( \"glFogiv\" );\n\tqglFrontFace                 = \tdllFrontFace                 = GPA( \"glFrontFace\" );\n\tqglFrustum                   = \tdllFrustum                   = GPA( \"glFrustum\" );\n\tqglGenLists                  = \tdllGenLists                  = GPA( \"glGenLists\" );\n\tqglGenTextures               = \tdllGenTextures               = GPA( \"glGenTextures\" );\n\tqglGetBooleanv               = \tdllGetBooleanv               = GPA( \"glGetBooleanv\" );\n\tqglGetClipPlane              = \tdllGetClipPlane              = GPA( \"glGetClipPlane\" );\n\tqglGetDoublev                = \tdllGetDoublev                = GPA( \"glGetDoublev\" );\n\tqglGetError                  = \tdllGetError                  = GPA( \"glGetError\" );\n\tqglGetFloatv                 = \tdllGetFloatv                 = GPA( \"glGetFloatv\" );\n\tqglGetIntegerv               = \tdllGetIntegerv               = GPA( \"glGetIntegerv\" );\n\tqglGetLightfv                = \tdllGetLightfv                = GPA( \"glGetLightfv\" );\n\tqglGetLightiv                = \tdllGetLightiv                = GPA( \"glGetLightiv\" );\n\tqglGetMapdv                  = \tdllGetMapdv                  = GPA( \"glGetMapdv\" );\n\tqglGetMapfv                  = \tdllGetMapfv                  = GPA( \"glGetMapfv\" );\n\tqglGetMapiv                  = \tdllGetMapiv                  = GPA( \"glGetMapiv\" );\n\tqglGetMaterialfv             = \tdllGetMaterialfv             = GPA( \"glGetMaterialfv\" );\n\tqglGetMaterialiv             = \tdllGetMaterialiv             = GPA( \"glGetMaterialiv\" );\n\tqglGetPixelMapfv             = \tdllGetPixelMapfv             = GPA( \"glGetPixelMapfv\" );\n\tqglGetPixelMapuiv            = \tdllGetPixelMapuiv            = GPA( \"glGetPixelMapuiv\" );\n\tqglGetPixelMapusv            = \tdllGetPixelMapusv            = GPA( \"glGetPixelMapusv\" );\n\tqglGetPointerv               = \tdllGetPointerv               = GPA( \"glGetPointerv\" );\n\tqglGetPolygonStipple         = \tdllGetPolygonStipple         = GPA( \"glGetPolygonStipple\" );\n\tqglGetString                 = \tdllGetString                 = GPA( \"glGetString\" );\n\tqglGetTexEnvfv               = \tdllGetTexEnvfv               = GPA( \"glGetTexEnvfv\" );\n\tqglGetTexEnviv               = \tdllGetTexEnviv               = GPA( \"glGetTexEnviv\" );\n\tqglGetTexGendv               = \tdllGetTexGendv               = GPA( \"glGetTexGendv\" );\n\tqglGetTexGenfv               = \tdllGetTexGenfv               = GPA( \"glGetTexGenfv\" );\n\tqglGetTexGeniv               = \tdllGetTexGeniv               = GPA( \"glGetTexGeniv\" );\n\tqglGetTexImage               = \tdllGetTexImage               = GPA( \"glGetTexImage\" );\n\tqglGetTexParameterfv         = \tdllGetTexParameterfv         = GPA( \"glGetTexParameterfv\" );\n\tqglGetTexParameteriv         = \tdllGetTexParameteriv         = GPA( \"glGetTexParameteriv\" );\n\tqglHint                      = \tdllHint                      = GPA( \"glHint\" );\n\tqglIndexMask                 = \tdllIndexMask                 = GPA( \"glIndexMask\" );\n\tqglIndexPointer              = \tdllIndexPointer              = GPA( \"glIndexPointer\" );\n\tqglIndexd                    = \tdllIndexd                    = GPA( \"glIndexd\" );\n\tqglIndexdv                   = \tdllIndexdv                   = GPA( \"glIndexdv\" );\n\tqglIndexf                    = \tdllIndexf                    = GPA( \"glIndexf\" );\n\tqglIndexfv                   = \tdllIndexfv                   = GPA( \"glIndexfv\" );\n\tqglIndexi                    = \tdllIndexi                    = GPA( \"glIndexi\" );\n\tqglIndexiv                   = \tdllIndexiv                   = GPA( \"glIndexiv\" );\n\tqglIndexs                    = \tdllIndexs                    = GPA( \"glIndexs\" );\n\tqglIndexsv                   = \tdllIndexsv                   = GPA( \"glIndexsv\" );\n\tqglIndexub                   = \tdllIndexub                   = GPA( \"glIndexub\" );\n\tqglIndexubv                  = \tdllIndexubv                  = GPA( \"glIndexubv\" );\n\tqglInitNames                 = \tdllInitNames                 = GPA( \"glInitNames\" );\n\tqglInterleavedArrays         = \tdllInterleavedArrays         = GPA( \"glInterleavedArrays\" );\n\tqglIsEnabled                 = \tdllIsEnabled                 = GPA( \"glIsEnabled\" );\n\tqglIsList                    = \tdllIsList                    = GPA( \"glIsList\" );\n\tqglIsTexture                 = \tdllIsTexture                 = GPA( \"glIsTexture\" );\n\tqglLightModelf               = \tdllLightModelf               = GPA( \"glLightModelf\" );\n\tqglLightModelfv              = \tdllLightModelfv              = GPA( \"glLightModelfv\" );\n\tqglLightModeli               = \tdllLightModeli               = GPA( \"glLightModeli\" );\n\tqglLightModeliv              = \tdllLightModeliv              = GPA( \"glLightModeliv\" );\n\tqglLightf                    = \tdllLightf                    = GPA( \"glLightf\" );\n\tqglLightfv                   = \tdllLightfv                   = GPA( \"glLightfv\" );\n\tqglLighti                    = \tdllLighti                    = GPA( \"glLighti\" );\n\tqglLightiv                   = \tdllLightiv                   = GPA( \"glLightiv\" );\n\tqglLineStipple               = \tdllLineStipple               = GPA( \"glLineStipple\" );\n\tqglLineWidth                 = \tdllLineWidth                 = GPA( \"glLineWidth\" );\n\tqglListBase                  = \tdllListBase                  = GPA( \"glListBase\" );\n\tqglLoadIdentity              = \tdllLoadIdentity              = GPA( \"glLoadIdentity\" );\n\tqglLoadMatrixd               = \tdllLoadMatrixd               = GPA( \"glLoadMatrixd\" );\n\tqglLoadMatrixf               = \tdllLoadMatrixf               = GPA( \"glLoadMatrixf\" );\n\tqglLoadName                  = \tdllLoadName                  = GPA( \"glLoadName\" );\n\tqglLogicOp                   = \tdllLogicOp                   = GPA( \"glLogicOp\" );\n\tqglMap1d                     = \tdllMap1d                     = GPA( \"glMap1d\" );\n\tqglMap1f                     = \tdllMap1f                     = GPA( \"glMap1f\" );\n\tqglMap2d                     = \tdllMap2d                     = GPA( \"glMap2d\" );\n\tqglMap2f                     = \tdllMap2f                     = GPA( \"glMap2f\" );\n\tqglMapGrid1d                 = \tdllMapGrid1d                 = GPA( \"glMapGrid1d\" );\n\tqglMapGrid1f                 = \tdllMapGrid1f                 = GPA( \"glMapGrid1f\" );\n\tqglMapGrid2d                 = \tdllMapGrid2d                 = GPA( \"glMapGrid2d\" );\n\tqglMapGrid2f                 = \tdllMapGrid2f                 = GPA( \"glMapGrid2f\" );\n\tqglMaterialf                 = \tdllMaterialf                 = GPA( \"glMaterialf\" );\n\tqglMaterialfv                = \tdllMaterialfv                = GPA( \"glMaterialfv\" );\n\tqglMateriali                 = \tdllMateriali                 = GPA( \"glMateriali\" );\n\tqglMaterialiv                = \tdllMaterialiv                = GPA( \"glMaterialiv\" );\n\tqglMatrixMode                = \tdllMatrixMode                = GPA( \"glMatrixMode\" );\n\tqglMultMatrixd               = \tdllMultMatrixd               = GPA( \"glMultMatrixd\" );\n\tqglMultMatrixf               = \tdllMultMatrixf               = GPA( \"glMultMatrixf\" );\n\tqglNewList                   = \tdllNewList                   = GPA( \"glNewList\" );\n\tqglNormal3b                  = \tdllNormal3b                  = GPA( \"glNormal3b\" );\n\tqglNormal3bv                 = \tdllNormal3bv                 = GPA( \"glNormal3bv\" );\n\tqglNormal3d                  = \tdllNormal3d                  = GPA( \"glNormal3d\" );\n\tqglNormal3dv                 = \tdllNormal3dv                 = GPA( \"glNormal3dv\" );\n\tqglNormal3f                  = \tdllNormal3f                  = GPA( \"glNormal3f\" );\n\tqglNormal3fv                 = \tdllNormal3fv                 = GPA( \"glNormal3fv\" );\n\tqglNormal3i                  = \tdllNormal3i                  = GPA( \"glNormal3i\" );\n\tqglNormal3iv                 = \tdllNormal3iv                 = GPA( \"glNormal3iv\" );\n\tqglNormal3s                  = \tdllNormal3s                  = GPA( \"glNormal3s\" );\n\tqglNormal3sv                 = \tdllNormal3sv                 = GPA( \"glNormal3sv\" );\n\tqglNormalPointer             = \tdllNormalPointer             = GPA( \"glNormalPointer\" );\n\tqglOrtho                     = \tdllOrtho                     = GPA( \"glOrtho\" );\n\tqglPassThrough               = \tdllPassThrough               = GPA( \"glPassThrough\" );\n\tqglPixelMapfv                = \tdllPixelMapfv                = GPA( \"glPixelMapfv\" );\n\tqglPixelMapuiv               = \tdllPixelMapuiv               = GPA( \"glPixelMapuiv\" );\n\tqglPixelMapusv               = \tdllPixelMapusv               = GPA( \"glPixelMapusv\" );\n\tqglPixelStoref               = \tdllPixelStoref               = GPA( \"glPixelStoref\" );\n\tqglPixelStorei               = \tdllPixelStorei               = GPA( \"glPixelStorei\" );\n\tqglPixelTransferf            = \tdllPixelTransferf            = GPA( \"glPixelTransferf\" );\n\tqglPixelTransferi            = \tdllPixelTransferi            = GPA( \"glPixelTransferi\" );\n\tqglPixelZoom                 = \tdllPixelZoom                 = GPA( \"glPixelZoom\" );\n\tqglPointSize                 = \tdllPointSize                 = GPA( \"glPointSize\" );\n\tqglPolygonMode               = \tdllPolygonMode               = GPA( \"glPolygonMode\" );\n\tqglPolygonOffset             = \tdllPolygonOffset             = GPA( \"glPolygonOffset\" );\n\tqglPolygonStipple            = \tdllPolygonStipple            = GPA( \"glPolygonStipple\" );\n\tqglPopAttrib                 = \tdllPopAttrib                 = GPA( \"glPopAttrib\" );\n\tqglPopClientAttrib           = \tdllPopClientAttrib           = GPA( \"glPopClientAttrib\" );\n\tqglPopMatrix                 = \tdllPopMatrix                 = GPA( \"glPopMatrix\" );\n\tqglPopName                   = \tdllPopName                   = GPA( \"glPopName\" );\n\tqglPrioritizeTextures        = \tdllPrioritizeTextures        = GPA( \"glPrioritizeTextures\" );\n\tqglPushAttrib                = \tdllPushAttrib                = GPA( \"glPushAttrib\" );\n\tqglPushClientAttrib          = \tdllPushClientAttrib          = GPA( \"glPushClientAttrib\" );\n\tqglPushMatrix                = \tdllPushMatrix                = GPA( \"glPushMatrix\" );\n\tqglPushName                  = \tdllPushName                  = GPA( \"glPushName\" );\n\tqglRasterPos2d               = \tdllRasterPos2d               = GPA( \"glRasterPos2d\" );\n\tqglRasterPos2dv              = \tdllRasterPos2dv              = GPA( \"glRasterPos2dv\" );\n\tqglRasterPos2f               = \tdllRasterPos2f               = GPA( \"glRasterPos2f\" );\n\tqglRasterPos2fv              = \tdllRasterPos2fv              = GPA( \"glRasterPos2fv\" );\n\tqglRasterPos2i               = \tdllRasterPos2i               = GPA( \"glRasterPos2i\" );\n\tqglRasterPos2iv              = \tdllRasterPos2iv              = GPA( \"glRasterPos2iv\" );\n\tqglRasterPos2s               = \tdllRasterPos2s               = GPA( \"glRasterPos2s\" );\n\tqglRasterPos2sv              = \tdllRasterPos2sv              = GPA( \"glRasterPos2sv\" );\n\tqglRasterPos3d               = \tdllRasterPos3d               = GPA( \"glRasterPos3d\" );\n\tqglRasterPos3dv              = \tdllRasterPos3dv              = GPA( \"glRasterPos3dv\" );\n\tqglRasterPos3f               = \tdllRasterPos3f               = GPA( \"glRasterPos3f\" );\n\tqglRasterPos3fv              = \tdllRasterPos3fv              = GPA( \"glRasterPos3fv\" );\n\tqglRasterPos3i               = \tdllRasterPos3i               = GPA( \"glRasterPos3i\" );\n\tqglRasterPos3iv              = \tdllRasterPos3iv              = GPA( \"glRasterPos3iv\" );\n\tqglRasterPos3s               = \tdllRasterPos3s               = GPA( \"glRasterPos3s\" );\n\tqglRasterPos3sv              = \tdllRasterPos3sv              = GPA( \"glRasterPos3sv\" );\n\tqglRasterPos4d               = \tdllRasterPos4d               = GPA( \"glRasterPos4d\" );\n\tqglRasterPos4dv              = \tdllRasterPos4dv              = GPA( \"glRasterPos4dv\" );\n\tqglRasterPos4f               = \tdllRasterPos4f               = GPA( \"glRasterPos4f\" );\n\tqglRasterPos4fv              = \tdllRasterPos4fv              = GPA( \"glRasterPos4fv\" );\n\tqglRasterPos4i               = \tdllRasterPos4i               = GPA( \"glRasterPos4i\" );\n\tqglRasterPos4iv              = \tdllRasterPos4iv              = GPA( \"glRasterPos4iv\" );\n\tqglRasterPos4s               = \tdllRasterPos4s               = GPA( \"glRasterPos4s\" );\n\tqglRasterPos4sv              = \tdllRasterPos4sv              = GPA( \"glRasterPos4sv\" );\n\tqglReadBuffer                = \tdllReadBuffer                = GPA( \"glReadBuffer\" );\n\tqglReadPixels                = \tdllReadPixels                = GPA( \"glReadPixels\" );\n\tqglRectd                     = \tdllRectd                     = GPA( \"glRectd\" );\n\tqglRectdv                    = \tdllRectdv                    = GPA( \"glRectdv\" );\n\tqglRectf                     = \tdllRectf                     = GPA( \"glRectf\" );\n\tqglRectfv                    = \tdllRectfv                    = GPA( \"glRectfv\" );\n\tqglRecti                     = \tdllRecti                     = GPA( \"glRecti\" );\n\tqglRectiv                    = \tdllRectiv                    = GPA( \"glRectiv\" );\n\tqglRects                     = \tdllRects                     = GPA( \"glRects\" );\n\tqglRectsv                    = \tdllRectsv                    = GPA( \"glRectsv\" );\n\tqglRenderMode                = \tdllRenderMode                = GPA( \"glRenderMode\" );\n\tqglRotated                   = \tdllRotated                   = GPA( \"glRotated\" );\n\tqglRotatef                   = \tdllRotatef                   = GPA( \"glRotatef\" );\n\tqglScaled                    = \tdllScaled                    = GPA( \"glScaled\" );\n\tqglScalef                    = \tdllScalef                    = GPA( \"glScalef\" );\n\tqglScissor                   = \tdllScissor                   = GPA( \"glScissor\" );\n\tqglSelectBuffer              = \tdllSelectBuffer              = GPA( \"glSelectBuffer\" );\n\tqglShadeModel                = \tdllShadeModel                = GPA( \"glShadeModel\" );\n\tqglStencilFunc               = \tdllStencilFunc               = GPA( \"glStencilFunc\" );\n\tqglStencilMask               = \tdllStencilMask               = GPA( \"glStencilMask\" );\n\tqglStencilOp                 = \tdllStencilOp                 = GPA( \"glStencilOp\" );\n\tqglTexCoord1d                = \tdllTexCoord1d                = GPA( \"glTexCoord1d\" );\n\tqglTexCoord1dv               = \tdllTexCoord1dv               = GPA( \"glTexCoord1dv\" );\n\tqglTexCoord1f                = \tdllTexCoord1f                = GPA( \"glTexCoord1f\" );\n\tqglTexCoord1fv               = \tdllTexCoord1fv               = GPA( \"glTexCoord1fv\" );\n\tqglTexCoord1i                = \tdllTexCoord1i                = GPA( \"glTexCoord1i\" );\n\tqglTexCoord1iv               = \tdllTexCoord1iv               = GPA( \"glTexCoord1iv\" );\n\tqglTexCoord1s                = \tdllTexCoord1s                = GPA( \"glTexCoord1s\" );\n\tqglTexCoord1sv               = \tdllTexCoord1sv               = GPA( \"glTexCoord1sv\" );\n\tqglTexCoord2d                = \tdllTexCoord2d                = GPA( \"glTexCoord2d\" );\n\tqglTexCoord2dv               = \tdllTexCoord2dv               = GPA( \"glTexCoord2dv\" );\n\tqglTexCoord2f                = \tdllTexCoord2f                = GPA( \"glTexCoord2f\" );\n\tqglTexCoord2fv               = \tdllTexCoord2fv               = GPA( \"glTexCoord2fv\" );\n\tqglTexCoord2i                = \tdllTexCoord2i                = GPA( \"glTexCoord2i\" );\n\tqglTexCoord2iv               = \tdllTexCoord2iv               = GPA( \"glTexCoord2iv\" );\n\tqglTexCoord2s                = \tdllTexCoord2s                = GPA( \"glTexCoord2s\" );\n\tqglTexCoord2sv               = \tdllTexCoord2sv               = GPA( \"glTexCoord2sv\" );\n\tqglTexCoord3d                = \tdllTexCoord3d                = GPA( \"glTexCoord3d\" );\n\tqglTexCoord3dv               = \tdllTexCoord3dv               = GPA( \"glTexCoord3dv\" );\n\tqglTexCoord3f                = \tdllTexCoord3f                = GPA( \"glTexCoord3f\" );\n\tqglTexCoord3fv               = \tdllTexCoord3fv               = GPA( \"glTexCoord3fv\" );\n\tqglTexCoord3i                = \tdllTexCoord3i                = GPA( \"glTexCoord3i\" );\n\tqglTexCoord3iv               = \tdllTexCoord3iv               = GPA( \"glTexCoord3iv\" );\n\tqglTexCoord3s                = \tdllTexCoord3s                = GPA( \"glTexCoord3s\" );\n\tqglTexCoord3sv               = \tdllTexCoord3sv               = GPA( \"glTexCoord3sv\" );\n\tqglTexCoord4d                = \tdllTexCoord4d                = GPA( \"glTexCoord4d\" );\n\tqglTexCoord4dv               = \tdllTexCoord4dv               = GPA( \"glTexCoord4dv\" );\n\tqglTexCoord4f                = \tdllTexCoord4f                = GPA( \"glTexCoord4f\" );\n\tqglTexCoord4fv               = \tdllTexCoord4fv               = GPA( \"glTexCoord4fv\" );\n\tqglTexCoord4i                = \tdllTexCoord4i                = GPA( \"glTexCoord4i\" );\n\tqglTexCoord4iv               = \tdllTexCoord4iv               = GPA( \"glTexCoord4iv\" );\n\tqglTexCoord4s                = \tdllTexCoord4s                = GPA( \"glTexCoord4s\" );\n\tqglTexCoord4sv               = \tdllTexCoord4sv               = GPA( \"glTexCoord4sv\" );\n\tqglTexCoordPointer           = \tdllTexCoordPointer           = GPA( \"glTexCoordPointer\" );\n\tqglTexEnvf                   = \tdllTexEnvf                   = GPA( \"glTexEnvf\" );\n\tqglTexEnvfv                  = \tdllTexEnvfv                  = GPA( \"glTexEnvfv\" );\n\tqglTexEnvi                   = \tdllTexEnvi                   = GPA( \"glTexEnvi\" );\n\tqglTexEnviv                  = \tdllTexEnviv                  = GPA( \"glTexEnviv\" );\n\tqglTexGend                   = \tdllTexGend                   = GPA( \"glTexGend\" );\n\tqglTexGendv                  = \tdllTexGendv                  = GPA( \"glTexGendv\" );\n\tqglTexGenf                   = \tdllTexGenf                   = GPA( \"glTexGenf\" );\n\tqglTexGenfv                  = \tdllTexGenfv                  = GPA( \"glTexGenfv\" );\n\tqglTexGeni                   = \tdllTexGeni                   = GPA( \"glTexGeni\" );\n\tqglTexGeniv                  = \tdllTexGeniv                  = GPA( \"glTexGeniv\" );\n\tqglTexImage1D                = \tdllTexImage1D                = GPA( \"glTexImage1D\" );\n\tqglTexImage2D                = \tdllTexImage2D                = GPA( \"glTexImage2D\" );\n\tqglTexParameterf             = \tdllTexParameterf             = GPA( \"glTexParameterf\" );\n\tqglTexParameterfv            = \tdllTexParameterfv            = GPA( \"glTexParameterfv\" );\n\tqglTexParameteri             = \tdllTexParameteri             = GPA( \"glTexParameteri\" );\n\tqglTexParameteriv            = \tdllTexParameteriv            = GPA( \"glTexParameteriv\" );\n\tqglTexSubImage1D             = \tdllTexSubImage1D             = GPA( \"glTexSubImage1D\" );\n\tqglTexSubImage2D             = \tdllTexSubImage2D             = GPA( \"glTexSubImage2D\" );\n\tqglTranslated                = \tdllTranslated                = GPA( \"glTranslated\" );\n\tqglTranslatef                = \tdllTranslatef                = GPA( \"glTranslatef\" );\n\tqglVertex2d                  = \tdllVertex2d                  = GPA( \"glVertex2d\" );\n\tqglVertex2dv                 = \tdllVertex2dv                 = GPA( \"glVertex2dv\" );\n\tqglVertex2f                  = \tdllVertex2f                  = GPA( \"glVertex2f\" );\n\tqglVertex2fv                 = \tdllVertex2fv                 = GPA( \"glVertex2fv\" );\n\tqglVertex2i                  = \tdllVertex2i                  = GPA( \"glVertex2i\" );\n\tqglVertex2iv                 = \tdllVertex2iv                 = GPA( \"glVertex2iv\" );\n\tqglVertex2s                  = \tdllVertex2s                  = GPA( \"glVertex2s\" );\n\tqglVertex2sv                 = \tdllVertex2sv                 = GPA( \"glVertex2sv\" );\n\tqglVertex3d                  = \tdllVertex3d                  = GPA( \"glVertex3d\" );\n\tqglVertex3dv                 = \tdllVertex3dv                 = GPA( \"glVertex3dv\" );\n\tqglVertex3f                  = \tdllVertex3f                  = GPA( \"glVertex3f\" );\n\tqglVertex3fv                 = \tdllVertex3fv                 = GPA( \"glVertex3fv\" );\n\tqglVertex3i                  = \tdllVertex3i                  = GPA( \"glVertex3i\" );\n\tqglVertex3iv                 = \tdllVertex3iv                 = GPA( \"glVertex3iv\" );\n\tqglVertex3s                  = \tdllVertex3s                  = GPA( \"glVertex3s\" );\n\tqglVertex3sv                 = \tdllVertex3sv                 = GPA( \"glVertex3sv\" );\n\tqglVertex4d                  = \tdllVertex4d                  = GPA( \"glVertex4d\" );\n\tqglVertex4dv                 = \tdllVertex4dv                 = GPA( \"glVertex4dv\" );\n\tqglVertex4f                  = \tdllVertex4f                  = GPA( \"glVertex4f\" );\n\tqglVertex4fv                 = \tdllVertex4fv                 = GPA( \"glVertex4fv\" );\n\tqglVertex4i                  = \tdllVertex4i                  = GPA( \"glVertex4i\" );\n\tqglVertex4iv                 = \tdllVertex4iv                 = GPA( \"glVertex4iv\" );\n\tqglVertex4s                  = \tdllVertex4s                  = GPA( \"glVertex4s\" );\n\tqglVertex4sv                 = \tdllVertex4sv                 = GPA( \"glVertex4sv\" );\n\tqglVertexPointer             = \tdllVertexPointer             = GPA( \"glVertexPointer\" );\n\tqglViewport                  = \tdllViewport                  = GPA( \"glViewport\" );\n\n// bk001129 - from cvs1.17 (mkv)\n#if defined(__FX__)\n\tqfxMesaCreateContext         =  GPA(\"fxMesaCreateContext\");\n\tqfxMesaCreateBestContext     =  GPA(\"fxMesaCreateBestContext\");\n\tqfxMesaDestroyContext        =  GPA(\"fxMesaDestroyContext\");\n\tqfxMesaMakeCurrent           =  GPA(\"fxMesaMakeCurrent\");\n\tqfxMesaGetCurrentContext     =  GPA(\"fxMesaGetCurrentContext\");\n\tqfxMesaSwapBuffers           =  GPA(\"fxMesaSwapBuffers\");\n#endif\n\n\tqglXChooseVisual             =  GPA(\"glXChooseVisual\");\n\tqglXCreateContext            =  GPA(\"glXCreateContext\");\n\tqglXDestroyContext           =  GPA(\"glXDestroyContext\");\n\tqglXMakeCurrent              =  GPA(\"glXMakeCurrent\");\n\tqglXCopyContext              =  GPA(\"glXCopyContext\");\n\tqglXSwapBuffers              =  GPA(\"glXSwapBuffers\");\n\n\tqglLockArraysEXT = 0;\n\tqglUnlockArraysEXT = 0;\n\tqglPointParameterfEXT = 0;\n\tqglPointParameterfvEXT = 0;\n\tqglColorTableEXT = 0;\n\tqgl3DfxSetPaletteEXT = 0;\n\tqglSelectTextureSGIS = 0;\n\tqglMTexCoord2fSGIS = 0;\n\tqglActiveTextureARB = 0;\n\tqglClientActiveTextureARB = 0;\n\tqglMultiTexCoord2fARB = 0;\n\n\treturn qtrue;\n}\n\nvoid QGL_EnableLogging( qboolean enable ) {\n  // bk001205 - fixed for new countdown\n  static qboolean isEnabled = qfalse; // init\n  \n  // return if we're already active\n  if ( isEnabled && enable ) {\n    // decrement log counter and stop if it has reached 0\n    ri.Cvar_Set( \"r_logFile\", va(\"%d\", r_logFile->integer - 1 ) );\n    if ( r_logFile->integer ) {\n      return;\n    }\n    enable = qfalse;\n  }\n\n  // return if we're already disabled\n  if ( !enable && !isEnabled )\n    return;\n\n  isEnabled = enable;\n\n  // bk001205 - old code starts here\n  if ( enable ) {\n    if ( !glw_state.log_fp ) {\n      struct tm *newtime;\n      time_t aclock;\n      char buffer[1024];\n      cvar_t\t*basedir;\n      \n      time( &aclock );\n      newtime = localtime( &aclock );\n      \n      asctime( newtime );\n      \n      basedir = ri.Cvar_Get( \"fs_basepath\", \"\", 0 ); // FIXME: userdir?\n      assert(basedir);\n      Com_sprintf( buffer, sizeof(buffer), \"%s/gl.log\", basedir->string ); \n      glw_state.log_fp = fopen( buffer, \"wt\" );\n      assert(glw_state.log_fp);\n      ri.Printf(PRINT_ALL, \"QGL_EnableLogging(%d): writing %s\\n\", r_logFile->integer, buffer );\n\n      fprintf( glw_state.log_fp, \"%s\\n\", asctime( newtime ) );\n    }\n\n                qglAccum                     = logAccum;\n                qglAlphaFunc                 = logAlphaFunc;\n                qglAreTexturesResident       = logAreTexturesResident;\n\t\tqglArrayElement              = logArrayElement;\n\t\tqglBegin                     = logBegin;\n\t\tqglBindTexture               = logBindTexture;\n\t\tqglBitmap                    = logBitmap;\n\t\tqglBlendFunc                 = logBlendFunc;\n\t\tqglCallList                  = logCallList;\n\t\tqglCallLists                 = logCallLists;\n\t\tqglClear                     = logClear;\n\t\tqglClearAccum                = logClearAccum;\n\t\tqglClearColor                = logClearColor;\n\t\tqglClearDepth                = logClearDepth;\n\t\tqglClearIndex                = logClearIndex;\n\t\tqglClearStencil              = logClearStencil;\n\t\tqglClipPlane                 = logClipPlane;\n\t\tqglColor3b                   = logColor3b;\n\t\tqglColor3bv                  = logColor3bv;\n\t\tqglColor3d                   = logColor3d;\n\t\tqglColor3dv                  = logColor3dv;\n\t\tqglColor3f                   = logColor3f;\n\t\tqglColor3fv                  = logColor3fv;\n\t\tqglColor3i                   = logColor3i;\n\t\tqglColor3iv                  = logColor3iv;\n\t\tqglColor3s                   = logColor3s;\n\t\tqglColor3sv                  = logColor3sv;\n\t\tqglColor3ub                  = logColor3ub;\n\t\tqglColor3ubv                 = logColor3ubv;\n\t\tqglColor3ui                  = logColor3ui;\n\t\tqglColor3uiv                 = logColor3uiv;\n\t\tqglColor3us                  = logColor3us;\n\t\tqglColor3usv                 = logColor3usv;\n\t\tqglColor4b                   = logColor4b;\n\t\tqglColor4bv                  = logColor4bv;\n\t\tqglColor4d                   = logColor4d;\n\t\tqglColor4dv                  = logColor4dv;\n\t\tqglColor4f                   = logColor4f;\n\t\tqglColor4fv                  = logColor4fv;\n\t\tqglColor4i                   = logColor4i;\n\t\tqglColor4iv                  = logColor4iv;\n\t\tqglColor4s                   = logColor4s;\n\t\tqglColor4sv                  = logColor4sv;\n\t\tqglColor4ub                  = logColor4ub;\n\t\tqglColor4ubv                 = logColor4ubv;\n\t\tqglColor4ui                  = logColor4ui;\n\t\tqglColor4uiv                 = logColor4uiv;\n\t\tqglColor4us                  = logColor4us;\n\t\tqglColor4usv                 = logColor4usv;\n\t\tqglColorMask                 = logColorMask;\n\t\tqglColorMaterial             = logColorMaterial;\n\t\tqglColorPointer              = logColorPointer;\n\t\tqglCopyPixels                = logCopyPixels;\n\t\tqglCopyTexImage1D            = logCopyTexImage1D;\n\t\tqglCopyTexImage2D            = logCopyTexImage2D;\n\t\tqglCopyTexSubImage1D         = logCopyTexSubImage1D;\n\t\tqglCopyTexSubImage2D         = logCopyTexSubImage2D;\n\t\tqglCullFace                  = logCullFace;\n\t\tqglDeleteLists               = logDeleteLists ;\n\t\tqglDeleteTextures            = logDeleteTextures ;\n\t\tqglDepthFunc                 = logDepthFunc ;\n\t\tqglDepthMask                 = logDepthMask ;\n\t\tqglDepthRange                = logDepthRange ;\n\t\tqglDisable                   = logDisable ;\n\t\tqglDisableClientState        = logDisableClientState ;\n\t\tqglDrawArrays                = logDrawArrays ;\n\t\tqglDrawBuffer                = logDrawBuffer ;\n\t\tqglDrawElements              = logDrawElements ;\n\t\tqglDrawPixels                = logDrawPixels ;\n\t\tqglEdgeFlag                  = logEdgeFlag ;\n\t\tqglEdgeFlagPointer           = logEdgeFlagPointer ;\n\t\tqglEdgeFlagv                 = logEdgeFlagv ;\n\t\tqglEnable                    = \tlogEnable                    ;\n\t\tqglEnableClientState         = \tlogEnableClientState         ;\n\t\tqglEnd                       = \tlogEnd                       ;\n\t\tqglEndList                   = \tlogEndList                   ;\n\t\tqglEvalCoord1d\t\t\t\t = \tlogEvalCoord1d\t\t\t\t ;\n\t\tqglEvalCoord1dv              = \tlogEvalCoord1dv              ;\n\t\tqglEvalCoord1f               = \tlogEvalCoord1f               ;\n\t\tqglEvalCoord1fv              = \tlogEvalCoord1fv              ;\n\t\tqglEvalCoord2d               = \tlogEvalCoord2d               ;\n\t\tqglEvalCoord2dv              = \tlogEvalCoord2dv              ;\n\t\tqglEvalCoord2f               = \tlogEvalCoord2f               ;\n\t\tqglEvalCoord2fv              = \tlogEvalCoord2fv              ;\n\t\tqglEvalMesh1                 = \tlogEvalMesh1                 ;\n\t\tqglEvalMesh2                 = \tlogEvalMesh2                 ;\n\t\tqglEvalPoint1                = \tlogEvalPoint1                ;\n\t\tqglEvalPoint2                = \tlogEvalPoint2                ;\n\t\tqglFeedbackBuffer            = \tlogFeedbackBuffer            ;\n\t\tqglFinish                    = \tlogFinish                    ;\n\t\tqglFlush                     = \tlogFlush                     ;\n\t\tqglFogf                      = \tlogFogf                      ;\n\t\tqglFogfv                     = \tlogFogfv                     ;\n\t\tqglFogi                      = \tlogFogi                      ;\n\t\tqglFogiv                     = \tlogFogiv                     ;\n\t\tqglFrontFace                 = \tlogFrontFace                 ;\n\t\tqglFrustum                   = \tlogFrustum                   ;\n\t\tqglGenLists                  = \tlogGenLists                  ;\n\t\tqglGenTextures               = \tlogGenTextures               ;\n\t\tqglGetBooleanv               = \tlogGetBooleanv               ;\n\t\tqglGetClipPlane              = \tlogGetClipPlane              ;\n\t\tqglGetDoublev                = \tlogGetDoublev                ;\n\t\tqglGetError                  = \tlogGetError                  ;\n\t\tqglGetFloatv                 = \tlogGetFloatv                 ;\n\t\tqglGetIntegerv               = \tlogGetIntegerv               ;\n\t\tqglGetLightfv                = \tlogGetLightfv                ;\n\t\tqglGetLightiv                = \tlogGetLightiv                ;\n\t\tqglGetMapdv                  = \tlogGetMapdv                  ;\n\t\tqglGetMapfv                  = \tlogGetMapfv                  ;\n\t\tqglGetMapiv                  = \tlogGetMapiv                  ;\n\t\tqglGetMaterialfv             = \tlogGetMaterialfv             ;\n\t\tqglGetMaterialiv             = \tlogGetMaterialiv             ;\n\t\tqglGetPixelMapfv             = \tlogGetPixelMapfv             ;\n\t\tqglGetPixelMapuiv            = \tlogGetPixelMapuiv            ;\n\t\tqglGetPixelMapusv            = \tlogGetPixelMapusv            ;\n\t\tqglGetPointerv               = \tlogGetPointerv               ;\n\t\tqglGetPolygonStipple         = \tlogGetPolygonStipple         ;\n\t\tqglGetString                 = \tlogGetString                 ;\n\t\tqglGetTexEnvfv               = \tlogGetTexEnvfv               ;\n\t\tqglGetTexEnviv               = \tlogGetTexEnviv               ;\n\t\tqglGetTexGendv               = \tlogGetTexGendv               ;\n\t\tqglGetTexGenfv               = \tlogGetTexGenfv               ;\n\t\tqglGetTexGeniv               = \tlogGetTexGeniv               ;\n\t\tqglGetTexImage               = \tlogGetTexImage               ;\n\t\tqglGetTexLevelParameterfv    = \tlogGetTexLevelParameterfv    ;\n\t\tqglGetTexLevelParameteriv    = \tlogGetTexLevelParameteriv    ;\n\t\tqglGetTexParameterfv         = \tlogGetTexParameterfv         ;\n\t\tqglGetTexParameteriv         = \tlogGetTexParameteriv         ;\n\t\tqglHint                      = \tlogHint                      ;\n\t\tqglIndexMask                 = \tlogIndexMask                 ;\n\t\tqglIndexPointer              = \tlogIndexPointer              ;\n\t\tqglIndexd                    = \tlogIndexd                    ;\n\t\tqglIndexdv                   = \tlogIndexdv                   ;\n\t\tqglIndexf                    = \tlogIndexf                    ;\n\t\tqglIndexfv                   = \tlogIndexfv                   ;\n\t\tqglIndexi                    = \tlogIndexi                    ;\n\t\tqglIndexiv                   = \tlogIndexiv                   ;\n\t\tqglIndexs                    = \tlogIndexs                    ;\n\t\tqglIndexsv                   = \tlogIndexsv                   ;\n\t\tqglIndexub                   = \tlogIndexub                   ;\n\t\tqglIndexubv                  = \tlogIndexubv                  ;\n\t\tqglInitNames                 = \tlogInitNames                 ;\n\t\tqglInterleavedArrays         = \tlogInterleavedArrays         ;\n\t\tqglIsEnabled                 = \tlogIsEnabled                 ;\n\t\tqglIsList                    = \tlogIsList                    ;\n\t\tqglIsTexture                 = \tlogIsTexture                 ;\n\t\tqglLightModelf               = \tlogLightModelf               ;\n\t\tqglLightModelfv              = \tlogLightModelfv              ;\n\t\tqglLightModeli               = \tlogLightModeli               ;\n\t\tqglLightModeliv              = \tlogLightModeliv              ;\n\t\tqglLightf                    = \tlogLightf                    ;\n\t\tqglLightfv                   = \tlogLightfv                   ;\n\t\tqglLighti                    = \tlogLighti                    ;\n\t\tqglLightiv                   = \tlogLightiv                   ;\n\t\tqglLineStipple               = \tlogLineStipple               ;\n\t\tqglLineWidth                 = \tlogLineWidth                 ;\n\t\tqglListBase                  = \tlogListBase                  ;\n\t\tqglLoadIdentity              = \tlogLoadIdentity              ;\n\t\tqglLoadMatrixd               = \tlogLoadMatrixd               ;\n\t\tqglLoadMatrixf               = \tlogLoadMatrixf               ;\n\t\tqglLoadName                  = \tlogLoadName                  ;\n\t\tqglLogicOp                   = \tlogLogicOp                   ;\n\t\tqglMap1d                     = \tlogMap1d                     ;\n\t\tqglMap1f                     = \tlogMap1f                     ;\n\t\tqglMap2d                     = \tlogMap2d                     ;\n\t\tqglMap2f                     = \tlogMap2f                     ;\n\t\tqglMapGrid1d                 = \tlogMapGrid1d                 ;\n\t\tqglMapGrid1f                 = \tlogMapGrid1f                 ;\n\t\tqglMapGrid2d                 = \tlogMapGrid2d                 ;\n\t\tqglMapGrid2f                 = \tlogMapGrid2f                 ;\n\t\tqglMaterialf                 = \tlogMaterialf                 ;\n\t\tqglMaterialfv                = \tlogMaterialfv                ;\n\t\tqglMateriali                 = \tlogMateriali                 ;\n\t\tqglMaterialiv                = \tlogMaterialiv                ;\n\t\tqglMatrixMode                = \tlogMatrixMode                ;\n\t\tqglMultMatrixd               = \tlogMultMatrixd               ;\n\t\tqglMultMatrixf               = \tlogMultMatrixf               ;\n\t\tqglNewList                   = \tlogNewList                   ;\n\t\tqglNormal3b                  = \tlogNormal3b                  ;\n\t\tqglNormal3bv                 = \tlogNormal3bv                 ;\n\t\tqglNormal3d                  = \tlogNormal3d                  ;\n\t\tqglNormal3dv                 = \tlogNormal3dv                 ;\n\t\tqglNormal3f                  = \tlogNormal3f                  ;\n\t\tqglNormal3fv                 = \tlogNormal3fv                 ;\n\t\tqglNormal3i                  = \tlogNormal3i                  ;\n\t\tqglNormal3iv                 = \tlogNormal3iv                 ;\n\t\tqglNormal3s                  = \tlogNormal3s                  ;\n\t\tqglNormal3sv                 = \tlogNormal3sv                 ;\n\t\tqglNormalPointer             = \tlogNormalPointer             ;\n\t\tqglOrtho                     = \tlogOrtho                     ;\n\t\tqglPassThrough               = \tlogPassThrough               ;\n\t\tqglPixelMapfv                = \tlogPixelMapfv                ;\n\t\tqglPixelMapuiv               = \tlogPixelMapuiv               ;\n\t\tqglPixelMapusv               = \tlogPixelMapusv               ;\n\t\tqglPixelStoref               = \tlogPixelStoref               ;\n\t\tqglPixelStorei               = \tlogPixelStorei               ;\n\t\tqglPixelTransferf            = \tlogPixelTransferf            ;\n\t\tqglPixelTransferi            = \tlogPixelTransferi            ;\n\t\tqglPixelZoom                 = \tlogPixelZoom                 ;\n\t\tqglPointSize                 = \tlogPointSize                 ;\n\t\tqglPolygonMode               = \tlogPolygonMode               ;\n\t\tqglPolygonOffset             = \tlogPolygonOffset             ;\n\t\tqglPolygonStipple            = \tlogPolygonStipple            ;\n\t\tqglPopAttrib                 = \tlogPopAttrib                 ;\n\t\tqglPopClientAttrib           = \tlogPopClientAttrib           ;\n\t\tqglPopMatrix                 = \tlogPopMatrix                 ;\n\t\tqglPopName                   = \tlogPopName                   ;\n\t\tqglPrioritizeTextures        = \tlogPrioritizeTextures        ;\n\t\tqglPushAttrib                = \tlogPushAttrib                ;\n\t\tqglPushClientAttrib          = \tlogPushClientAttrib          ;\n\t\tqglPushMatrix                = \tlogPushMatrix                ;\n\t\tqglPushName                  = \tlogPushName                  ;\n\t\tqglRasterPos2d               = \tlogRasterPos2d               ;\n\t\tqglRasterPos2dv              = \tlogRasterPos2dv              ;\n\t\tqglRasterPos2f               = \tlogRasterPos2f               ;\n\t\tqglRasterPos2fv              = \tlogRasterPos2fv              ;\n\t\tqglRasterPos2i               = \tlogRasterPos2i               ;\n\t\tqglRasterPos2iv              = \tlogRasterPos2iv              ;\n\t\tqglRasterPos2s               = \tlogRasterPos2s               ;\n\t\tqglRasterPos2sv              = \tlogRasterPos2sv              ;\n\t\tqglRasterPos3d               = \tlogRasterPos3d               ;\n\t\tqglRasterPos3dv              = \tlogRasterPos3dv              ;\n\t\tqglRasterPos3f               = \tlogRasterPos3f               ;\n\t\tqglRasterPos3fv              = \tlogRasterPos3fv              ;\n\t\tqglRasterPos3i               = \tlogRasterPos3i               ;\n\t\tqglRasterPos3iv              = \tlogRasterPos3iv              ;\n\t\tqglRasterPos3s               = \tlogRasterPos3s               ;\n\t\tqglRasterPos3sv              = \tlogRasterPos3sv              ;\n\t\tqglRasterPos4d               = \tlogRasterPos4d               ;\n\t\tqglRasterPos4dv              = \tlogRasterPos4dv              ;\n\t\tqglRasterPos4f               = \tlogRasterPos4f               ;\n\t\tqglRasterPos4fv              = \tlogRasterPos4fv              ;\n\t\tqglRasterPos4i               = \tlogRasterPos4i               ;\n\t\tqglRasterPos4iv              = \tlogRasterPos4iv              ;\n\t\tqglRasterPos4s               = \tlogRasterPos4s               ;\n\t\tqglRasterPos4sv              = \tlogRasterPos4sv              ;\n\t\tqglReadBuffer                = \tlogReadBuffer                ;\n\t\tqglReadPixels                = \tlogReadPixels                ;\n\t\tqglRectd                     = \tlogRectd                     ;\n\t\tqglRectdv                    = \tlogRectdv                    ;\n\t\tqglRectf                     = \tlogRectf                     ;\n\t\tqglRectfv                    = \tlogRectfv                    ;\n\t\tqglRecti                     = \tlogRecti                     ;\n\t\tqglRectiv                    = \tlogRectiv                    ;\n\t\tqglRects                     = \tlogRects                     ;\n\t\tqglRectsv                    = \tlogRectsv                    ;\n\t\tqglRenderMode                = \tlogRenderMode                ;\n\t\tqglRotated                   = \tlogRotated                   ;\n\t\tqglRotatef                   = \tlogRotatef                   ;\n\t\tqglScaled                    = \tlogScaled                    ;\n\t\tqglScalef                    = \tlogScalef                    ;\n\t\tqglScissor                   = \tlogScissor                   ;\n\t\tqglSelectBuffer              = \tlogSelectBuffer              ;\n\t\tqglShadeModel                = \tlogShadeModel                ;\n\t\tqglStencilFunc               = \tlogStencilFunc               ;\n\t\tqglStencilMask               = \tlogStencilMask               ;\n\t\tqglStencilOp                 = \tlogStencilOp                 ;\n\t\tqglTexCoord1d                = \tlogTexCoord1d                ;\n\t\tqglTexCoord1dv               = \tlogTexCoord1dv               ;\n\t\tqglTexCoord1f                = \tlogTexCoord1f                ;\n\t\tqglTexCoord1fv               = \tlogTexCoord1fv               ;\n\t\tqglTexCoord1i                = \tlogTexCoord1i                ;\n\t\tqglTexCoord1iv               = \tlogTexCoord1iv               ;\n\t\tqglTexCoord1s                = \tlogTexCoord1s                ;\n\t\tqglTexCoord1sv               = \tlogTexCoord1sv               ;\n\t\tqglTexCoord2d                = \tlogTexCoord2d                ;\n\t\tqglTexCoord2dv               = \tlogTexCoord2dv               ;\n\t\tqglTexCoord2f                = \tlogTexCoord2f                ;\n\t\tqglTexCoord2fv               = \tlogTexCoord2fv               ;\n\t\tqglTexCoord2i                = \tlogTexCoord2i                ;\n\t\tqglTexCoord2iv               = \tlogTexCoord2iv               ;\n\t\tqglTexCoord2s                = \tlogTexCoord2s                ;\n\t\tqglTexCoord2sv               = \tlogTexCoord2sv               ;\n\t\tqglTexCoord3d                = \tlogTexCoord3d                ;\n\t\tqglTexCoord3dv               = \tlogTexCoord3dv               ;\n\t\tqglTexCoord3f                = \tlogTexCoord3f                ;\n\t\tqglTexCoord3fv               = \tlogTexCoord3fv               ;\n\t\tqglTexCoord3i                = \tlogTexCoord3i                ;\n\t\tqglTexCoord3iv               = \tlogTexCoord3iv               ;\n\t\tqglTexCoord3s                = \tlogTexCoord3s                ;\n\t\tqglTexCoord3sv               = \tlogTexCoord3sv               ;\n\t\tqglTexCoord4d                = \tlogTexCoord4d                ;\n\t\tqglTexCoord4dv               = \tlogTexCoord4dv               ;\n\t\tqglTexCoord4f                = \tlogTexCoord4f                ;\n\t\tqglTexCoord4fv               = \tlogTexCoord4fv               ;\n\t\tqglTexCoord4i                = \tlogTexCoord4i                ;\n\t\tqglTexCoord4iv               = \tlogTexCoord4iv               ;\n\t\tqglTexCoord4s                = \tlogTexCoord4s                ;\n\t\tqglTexCoord4sv               = \tlogTexCoord4sv               ;\n\t\tqglTexCoordPointer           = \tlogTexCoordPointer           ;\n\t\tqglTexEnvf                   = \tlogTexEnvf                   ;\n\t\tqglTexEnvfv                  = \tlogTexEnvfv                  ;\n\t\tqglTexEnvi                   = \tlogTexEnvi                   ;\n\t\tqglTexEnviv                  = \tlogTexEnviv                  ;\n\t\tqglTexGend                   = \tlogTexGend                   ;\n\t\tqglTexGendv                  = \tlogTexGendv                  ;\n\t\tqglTexGenf                   = \tlogTexGenf                   ;\n\t\tqglTexGenfv                  = \tlogTexGenfv                  ;\n\t\tqglTexGeni                   = \tlogTexGeni                   ;\n\t\tqglTexGeniv                  = \tlogTexGeniv                  ;\n\t\tqglTexImage1D                = \tlogTexImage1D                ;\n\t\tqglTexImage2D                = \tlogTexImage2D                ;\n\t\tqglTexParameterf             = \tlogTexParameterf             ;\n\t\tqglTexParameterfv            = \tlogTexParameterfv            ;\n\t\tqglTexParameteri             = \tlogTexParameteri             ;\n\t\tqglTexParameteriv            = \tlogTexParameteriv            ;\n\t\tqglTexSubImage1D             = \tlogTexSubImage1D             ;\n\t\tqglTexSubImage2D             = \tlogTexSubImage2D             ;\n\t\tqglTranslated                = \tlogTranslated                ;\n\t\tqglTranslatef                = \tlogTranslatef                ;\n\t\tqglVertex2d                  = \tlogVertex2d                  ;\n\t\tqglVertex2dv                 = \tlogVertex2dv                 ;\n\t\tqglVertex2f                  = \tlogVertex2f                  ;\n\t\tqglVertex2fv                 = \tlogVertex2fv                 ;\n\t\tqglVertex2i                  = \tlogVertex2i                  ;\n\t\tqglVertex2iv                 = \tlogVertex2iv                 ;\n\t\tqglVertex2s                  = \tlogVertex2s                  ;\n\t\tqglVertex2sv                 = \tlogVertex2sv                 ;\n\t\tqglVertex3d                  = \tlogVertex3d                  ;\n\t\tqglVertex3dv                 = \tlogVertex3dv                 ;\n\t\tqglVertex3f                  = \tlogVertex3f                  ;\n\t\tqglVertex3fv                 = \tlogVertex3fv                 ;\n\t\tqglVertex3i                  = \tlogVertex3i                  ;\n\t\tqglVertex3iv                 = \tlogVertex3iv                 ;\n\t\tqglVertex3s                  = \tlogVertex3s                  ;\n\t\tqglVertex3sv                 = \tlogVertex3sv                 ;\n\t\tqglVertex4d                  = \tlogVertex4d                  ;\n\t\tqglVertex4dv                 = \tlogVertex4dv                 ;\n\t\tqglVertex4f                  = \tlogVertex4f                  ;\n\t\tqglVertex4fv                 = \tlogVertex4fv                 ;\n\t\tqglVertex4i                  = \tlogVertex4i                  ;\n\t\tqglVertex4iv                 = \tlogVertex4iv                 ;\n\t\tqglVertex4s                  = \tlogVertex4s                  ;\n\t\tqglVertex4sv                 = \tlogVertex4sv                 ;\n\t\tqglVertexPointer             = \tlogVertexPointer             ;\n\t\tqglViewport                  = \tlogViewport                  ;\n\t}\n\telse\n\t{\n\t\tqglAccum                     = dllAccum;\n\t\tqglAlphaFunc                 = dllAlphaFunc;\n\t\tqglAreTexturesResident       = dllAreTexturesResident;\n\t\tqglArrayElement              = dllArrayElement;\n\t\tqglBegin                     = dllBegin;\n\t\tqglBindTexture               = dllBindTexture;\n\t\tqglBitmap                    = dllBitmap;\n\t\tqglBlendFunc                 = dllBlendFunc;\n\t\tqglCallList                  = dllCallList;\n\t\tqglCallLists                 = dllCallLists;\n\t\tqglClear                     = dllClear;\n\t\tqglClearAccum                = dllClearAccum;\n\t\tqglClearColor                = dllClearColor;\n\t\tqglClearDepth                = dllClearDepth;\n\t\tqglClearIndex                = dllClearIndex;\n\t\tqglClearStencil              = dllClearStencil;\n\t\tqglClipPlane                 = dllClipPlane;\n\t\tqglColor3b                   = dllColor3b;\n\t\tqglColor3bv                  = dllColor3bv;\n\t\tqglColor3d                   = dllColor3d;\n\t\tqglColor3dv                  = dllColor3dv;\n\t\tqglColor3f                   = dllColor3f;\n\t\tqglColor3fv                  = dllColor3fv;\n\t\tqglColor3i                   = dllColor3i;\n\t\tqglColor3iv                  = dllColor3iv;\n\t\tqglColor3s                   = dllColor3s;\n\t\tqglColor3sv                  = dllColor3sv;\n\t\tqglColor3ub                  = dllColor3ub;\n\t\tqglColor3ubv                 = dllColor3ubv;\n\t\tqglColor3ui                  = dllColor3ui;\n\t\tqglColor3uiv                 = dllColor3uiv;\n\t\tqglColor3us                  = dllColor3us;\n\t\tqglColor3usv                 = dllColor3usv;\n\t\tqglColor4b                   = dllColor4b;\n\t\tqglColor4bv                  = dllColor4bv;\n\t\tqglColor4d                   = dllColor4d;\n\t\tqglColor4dv                  = dllColor4dv;\n\t\tqglColor4f                   = dllColor4f;\n\t\tqglColor4fv                  = dllColor4fv;\n\t\tqglColor4i                   = dllColor4i;\n\t\tqglColor4iv                  = dllColor4iv;\n\t\tqglColor4s                   = dllColor4s;\n\t\tqglColor4sv                  = dllColor4sv;\n\t\tqglColor4ub                  = dllColor4ub;\n\t\tqglColor4ubv                 = dllColor4ubv;\n\t\tqglColor4ui                  = dllColor4ui;\n\t\tqglColor4uiv                 = dllColor4uiv;\n\t\tqglColor4us                  = dllColor4us;\n\t\tqglColor4usv                 = dllColor4usv;\n\t\tqglColorMask                 = dllColorMask;\n\t\tqglColorMaterial             = dllColorMaterial;\n\t\tqglColorPointer              = dllColorPointer;\n\t\tqglCopyPixels                = dllCopyPixels;\n\t\tqglCopyTexImage1D            = dllCopyTexImage1D;\n\t\tqglCopyTexImage2D            = dllCopyTexImage2D;\n\t\tqglCopyTexSubImage1D         = dllCopyTexSubImage1D;\n\t\tqglCopyTexSubImage2D         = dllCopyTexSubImage2D;\n\t\tqglCullFace                  = dllCullFace;\n\t\tqglDeleteLists               = dllDeleteLists ;\n\t\tqglDeleteTextures            = dllDeleteTextures ;\n\t\tqglDepthFunc                 = dllDepthFunc ;\n\t\tqglDepthMask                 = dllDepthMask ;\n\t\tqglDepthRange                = dllDepthRange ;\n\t\tqglDisable                   = dllDisable ;\n\t\tqglDisableClientState        = dllDisableClientState ;\n\t\tqglDrawArrays                = dllDrawArrays ;\n\t\tqglDrawBuffer                = dllDrawBuffer ;\n\t\tqglDrawElements              = dllDrawElements ;\n\t\tqglDrawPixels                = dllDrawPixels ;\n\t\tqglEdgeFlag                  = dllEdgeFlag ;\n\t\tqglEdgeFlagPointer           = dllEdgeFlagPointer ;\n\t\tqglEdgeFlagv                 = dllEdgeFlagv ;\n\t\tqglEnable                    = \tdllEnable                    ;\n\t\tqglEnableClientState         = \tdllEnableClientState         ;\n\t\tqglEnd                       = \tdllEnd                       ;\n\t\tqglEndList                   = \tdllEndList                   ;\n\t\tqglEvalCoord1d\t\t\t\t = \tdllEvalCoord1d\t\t\t\t ;\n\t\tqglEvalCoord1dv              = \tdllEvalCoord1dv              ;\n\t\tqglEvalCoord1f               = \tdllEvalCoord1f               ;\n\t\tqglEvalCoord1fv              = \tdllEvalCoord1fv              ;\n\t\tqglEvalCoord2d               = \tdllEvalCoord2d               ;\n\t\tqglEvalCoord2dv              = \tdllEvalCoord2dv              ;\n\t\tqglEvalCoord2f               = \tdllEvalCoord2f               ;\n\t\tqglEvalCoord2fv              = \tdllEvalCoord2fv              ;\n\t\tqglEvalMesh1                 = \tdllEvalMesh1                 ;\n\t\tqglEvalMesh2                 = \tdllEvalMesh2                 ;\n\t\tqglEvalPoint1                = \tdllEvalPoint1                ;\n\t\tqglEvalPoint2                = \tdllEvalPoint2                ;\n\t\tqglFeedbackBuffer            = \tdllFeedbackBuffer            ;\n\t\tqglFinish                    = \tdllFinish                    ;\n\t\tqglFlush                     = \tdllFlush                     ;\n\t\tqglFogf                      = \tdllFogf                      ;\n\t\tqglFogfv                     = \tdllFogfv                     ;\n\t\tqglFogi                      = \tdllFogi                      ;\n\t\tqglFogiv                     = \tdllFogiv                     ;\n\t\tqglFrontFace                 = \tdllFrontFace                 ;\n\t\tqglFrustum                   = \tdllFrustum                   ;\n\t\tqglGenLists                  = \tdllGenLists                  ;\n\t\tqglGenTextures               = \tdllGenTextures               ;\n\t\tqglGetBooleanv               = \tdllGetBooleanv               ;\n\t\tqglGetClipPlane              = \tdllGetClipPlane              ;\n\t\tqglGetDoublev                = \tdllGetDoublev                ;\n\t\tqglGetError                  = \tdllGetError                  ;\n\t\tqglGetFloatv                 = \tdllGetFloatv                 ;\n\t\tqglGetIntegerv               = \tdllGetIntegerv               ;\n\t\tqglGetLightfv                = \tdllGetLightfv                ;\n\t\tqglGetLightiv                = \tdllGetLightiv                ;\n\t\tqglGetMapdv                  = \tdllGetMapdv                  ;\n\t\tqglGetMapfv                  = \tdllGetMapfv                  ;\n\t\tqglGetMapiv                  = \tdllGetMapiv                  ;\n\t\tqglGetMaterialfv             = \tdllGetMaterialfv             ;\n\t\tqglGetMaterialiv             = \tdllGetMaterialiv             ;\n\t\tqglGetPixelMapfv             = \tdllGetPixelMapfv             ;\n\t\tqglGetPixelMapuiv            = \tdllGetPixelMapuiv            ;\n\t\tqglGetPixelMapusv            = \tdllGetPixelMapusv            ;\n\t\tqglGetPointerv               = \tdllGetPointerv               ;\n\t\tqglGetPolygonStipple         = \tdllGetPolygonStipple         ;\n\t\tqglGetString                 = \tdllGetString                 ;\n\t\tqglGetTexEnvfv               = \tdllGetTexEnvfv               ;\n\t\tqglGetTexEnviv               = \tdllGetTexEnviv               ;\n\t\tqglGetTexGendv               = \tdllGetTexGendv               ;\n\t\tqglGetTexGenfv               = \tdllGetTexGenfv               ;\n\t\tqglGetTexGeniv               = \tdllGetTexGeniv               ;\n\t\tqglGetTexImage               = \tdllGetTexImage               ;\n\t\tqglGetTexLevelParameterfv    = \tdllGetTexLevelParameterfv    ;\n\t\tqglGetTexLevelParameteriv    = \tdllGetTexLevelParameteriv    ;\n\t\tqglGetTexParameterfv         = \tdllGetTexParameterfv         ;\n\t\tqglGetTexParameteriv         = \tdllGetTexParameteriv         ;\n\t\tqglHint                      = \tdllHint                      ;\n\t\tqglIndexMask                 = \tdllIndexMask                 ;\n\t\tqglIndexPointer              = \tdllIndexPointer              ;\n\t\tqglIndexd                    = \tdllIndexd                    ;\n\t\tqglIndexdv                   = \tdllIndexdv                   ;\n\t\tqglIndexf                    = \tdllIndexf                    ;\n\t\tqglIndexfv                   = \tdllIndexfv                   ;\n\t\tqglIndexi                    = \tdllIndexi                    ;\n\t\tqglIndexiv                   = \tdllIndexiv                   ;\n\t\tqglIndexs                    = \tdllIndexs                    ;\n\t\tqglIndexsv                   = \tdllIndexsv                   ;\n\t\tqglIndexub                   = \tdllIndexub                   ;\n\t\tqglIndexubv                  = \tdllIndexubv                  ;\n\t\tqglInitNames                 = \tdllInitNames                 ;\n\t\tqglInterleavedArrays         = \tdllInterleavedArrays         ;\n\t\tqglIsEnabled                 = \tdllIsEnabled                 ;\n\t\tqglIsList                    = \tdllIsList                    ;\n\t\tqglIsTexture                 = \tdllIsTexture                 ;\n\t\tqglLightModelf               = \tdllLightModelf               ;\n\t\tqglLightModelfv              = \tdllLightModelfv              ;\n\t\tqglLightModeli               = \tdllLightModeli               ;\n\t\tqglLightModeliv              = \tdllLightModeliv              ;\n\t\tqglLightf                    = \tdllLightf                    ;\n\t\tqglLightfv                   = \tdllLightfv                   ;\n\t\tqglLighti                    = \tdllLighti                    ;\n\t\tqglLightiv                   = \tdllLightiv                   ;\n\t\tqglLineStipple               = \tdllLineStipple               ;\n\t\tqglLineWidth                 = \tdllLineWidth                 ;\n\t\tqglListBase                  = \tdllListBase                  ;\n\t\tqglLoadIdentity              = \tdllLoadIdentity              ;\n\t\tqglLoadMatrixd               = \tdllLoadMatrixd               ;\n\t\tqglLoadMatrixf               = \tdllLoadMatrixf               ;\n\t\tqglLoadName                  = \tdllLoadName                  ;\n\t\tqglLogicOp                   = \tdllLogicOp                   ;\n\t\tqglMap1d                     = \tdllMap1d                     ;\n\t\tqglMap1f                     = \tdllMap1f                     ;\n\t\tqglMap2d                     = \tdllMap2d                     ;\n\t\tqglMap2f                     = \tdllMap2f                     ;\n\t\tqglMapGrid1d                 = \tdllMapGrid1d                 ;\n\t\tqglMapGrid1f                 = \tdllMapGrid1f                 ;\n\t\tqglMapGrid2d                 = \tdllMapGrid2d                 ;\n\t\tqglMapGrid2f                 = \tdllMapGrid2f                 ;\n\t\tqglMaterialf                 = \tdllMaterialf                 ;\n\t\tqglMaterialfv                = \tdllMaterialfv                ;\n\t\tqglMateriali                 = \tdllMateriali                 ;\n\t\tqglMaterialiv                = \tdllMaterialiv                ;\n\t\tqglMatrixMode                = \tdllMatrixMode                ;\n\t\tqglMultMatrixd               = \tdllMultMatrixd               ;\n\t\tqglMultMatrixf               = \tdllMultMatrixf               ;\n\t\tqglNewList                   = \tdllNewList                   ;\n\t\tqglNormal3b                  = \tdllNormal3b                  ;\n\t\tqglNormal3bv                 = \tdllNormal3bv                 ;\n\t\tqglNormal3d                  = \tdllNormal3d                  ;\n\t\tqglNormal3dv                 = \tdllNormal3dv                 ;\n\t\tqglNormal3f                  = \tdllNormal3f                  ;\n\t\tqglNormal3fv                 = \tdllNormal3fv                 ;\n\t\tqglNormal3i                  = \tdllNormal3i                  ;\n\t\tqglNormal3iv                 = \tdllNormal3iv                 ;\n\t\tqglNormal3s                  = \tdllNormal3s                  ;\n\t\tqglNormal3sv                 = \tdllNormal3sv                 ;\n\t\tqglNormalPointer             = \tdllNormalPointer             ;\n\t\tqglOrtho                     = \tdllOrtho                     ;\n\t\tqglPassThrough               = \tdllPassThrough               ;\n\t\tqglPixelMapfv                = \tdllPixelMapfv                ;\n\t\tqglPixelMapuiv               = \tdllPixelMapuiv               ;\n\t\tqglPixelMapusv               = \tdllPixelMapusv               ;\n\t\tqglPixelStoref               = \tdllPixelStoref               ;\n\t\tqglPixelStorei               = \tdllPixelStorei               ;\n\t\tqglPixelTransferf            = \tdllPixelTransferf            ;\n\t\tqglPixelTransferi            = \tdllPixelTransferi            ;\n\t\tqglPixelZoom                 = \tdllPixelZoom                 ;\n\t\tqglPointSize                 = \tdllPointSize                 ;\n\t\tqglPolygonMode               = \tdllPolygonMode               ;\n\t\tqglPolygonOffset             = \tdllPolygonOffset             ;\n\t\tqglPolygonStipple            = \tdllPolygonStipple            ;\n\t\tqglPopAttrib                 = \tdllPopAttrib                 ;\n\t\tqglPopClientAttrib           = \tdllPopClientAttrib           ;\n\t\tqglPopMatrix                 = \tdllPopMatrix                 ;\n\t\tqglPopName                   = \tdllPopName                   ;\n\t\tqglPrioritizeTextures        = \tdllPrioritizeTextures        ;\n\t\tqglPushAttrib                = \tdllPushAttrib                ;\n\t\tqglPushClientAttrib          = \tdllPushClientAttrib          ;\n\t\tqglPushMatrix                = \tdllPushMatrix                ;\n\t\tqglPushName                  = \tdllPushName                  ;\n\t\tqglRasterPos2d               = \tdllRasterPos2d               ;\n\t\tqglRasterPos2dv              = \tdllRasterPos2dv              ;\n\t\tqglRasterPos2f               = \tdllRasterPos2f               ;\n\t\tqglRasterPos2fv              = \tdllRasterPos2fv              ;\n\t\tqglRasterPos2i               = \tdllRasterPos2i               ;\n\t\tqglRasterPos2iv              = \tdllRasterPos2iv              ;\n\t\tqglRasterPos2s               = \tdllRasterPos2s               ;\n\t\tqglRasterPos2sv              = \tdllRasterPos2sv              ;\n\t\tqglRasterPos3d               = \tdllRasterPos3d               ;\n\t\tqglRasterPos3dv              = \tdllRasterPos3dv              ;\n\t\tqglRasterPos3f               = \tdllRasterPos3f               ;\n\t\tqglRasterPos3fv              = \tdllRasterPos3fv              ;\n\t\tqglRasterPos3i               = \tdllRasterPos3i               ;\n\t\tqglRasterPos3iv              = \tdllRasterPos3iv              ;\n\t\tqglRasterPos3s               = \tdllRasterPos3s               ;\n\t\tqglRasterPos3sv              = \tdllRasterPos3sv              ;\n\t\tqglRasterPos4d               = \tdllRasterPos4d               ;\n\t\tqglRasterPos4dv              = \tdllRasterPos4dv              ;\n\t\tqglRasterPos4f               = \tdllRasterPos4f               ;\n\t\tqglRasterPos4fv              = \tdllRasterPos4fv              ;\n\t\tqglRasterPos4i               = \tdllRasterPos4i               ;\n\t\tqglRasterPos4iv              = \tdllRasterPos4iv              ;\n\t\tqglRasterPos4s               = \tdllRasterPos4s               ;\n\t\tqglRasterPos4sv              = \tdllRasterPos4sv              ;\n\t\tqglReadBuffer                = \tdllReadBuffer                ;\n\t\tqglReadPixels                = \tdllReadPixels                ;\n\t\tqglRectd                     = \tdllRectd                     ;\n\t\tqglRectdv                    = \tdllRectdv                    ;\n\t\tqglRectf                     = \tdllRectf                     ;\n\t\tqglRectfv                    = \tdllRectfv                    ;\n\t\tqglRecti                     = \tdllRecti                     ;\n\t\tqglRectiv                    = \tdllRectiv                    ;\n\t\tqglRects                     = \tdllRects                     ;\n\t\tqglRectsv                    = \tdllRectsv                    ;\n\t\tqglRenderMode                = \tdllRenderMode                ;\n\t\tqglRotated                   = \tdllRotated                   ;\n\t\tqglRotatef                   = \tdllRotatef                   ;\n\t\tqglScaled                    = \tdllScaled                    ;\n\t\tqglScalef                    = \tdllScalef                    ;\n\t\tqglScissor                   = \tdllScissor                   ;\n\t\tqglSelectBuffer              = \tdllSelectBuffer              ;\n\t\tqglShadeModel                = \tdllShadeModel                ;\n\t\tqglStencilFunc               = \tdllStencilFunc               ;\n\t\tqglStencilMask               = \tdllStencilMask               ;\n\t\tqglStencilOp                 = \tdllStencilOp                 ;\n\t\tqglTexCoord1d                = \tdllTexCoord1d                ;\n\t\tqglTexCoord1dv               = \tdllTexCoord1dv               ;\n\t\tqglTexCoord1f                = \tdllTexCoord1f                ;\n\t\tqglTexCoord1fv               = \tdllTexCoord1fv               ;\n\t\tqglTexCoord1i                = \tdllTexCoord1i                ;\n\t\tqglTexCoord1iv               = \tdllTexCoord1iv               ;\n\t\tqglTexCoord1s                = \tdllTexCoord1s                ;\n\t\tqglTexCoord1sv               = \tdllTexCoord1sv               ;\n\t\tqglTexCoord2d                = \tdllTexCoord2d                ;\n\t\tqglTexCoord2dv               = \tdllTexCoord2dv               ;\n\t\tqglTexCoord2f                = \tdllTexCoord2f                ;\n\t\tqglTexCoord2fv               = \tdllTexCoord2fv               ;\n\t\tqglTexCoord2i                = \tdllTexCoord2i                ;\n\t\tqglTexCoord2iv               = \tdllTexCoord2iv               ;\n\t\tqglTexCoord2s                = \tdllTexCoord2s                ;\n\t\tqglTexCoord2sv               = \tdllTexCoord2sv               ;\n\t\tqglTexCoord3d                = \tdllTexCoord3d                ;\n\t\tqglTexCoord3dv               = \tdllTexCoord3dv               ;\n\t\tqglTexCoord3f                = \tdllTexCoord3f                ;\n\t\tqglTexCoord3fv               = \tdllTexCoord3fv               ;\n\t\tqglTexCoord3i                = \tdllTexCoord3i                ;\n\t\tqglTexCoord3iv               = \tdllTexCoord3iv               ;\n\t\tqglTexCoord3s                = \tdllTexCoord3s                ;\n\t\tqglTexCoord3sv               = \tdllTexCoord3sv               ;\n\t\tqglTexCoord4d                = \tdllTexCoord4d                ;\n\t\tqglTexCoord4dv               = \tdllTexCoord4dv               ;\n\t\tqglTexCoord4f                = \tdllTexCoord4f                ;\n\t\tqglTexCoord4fv               = \tdllTexCoord4fv               ;\n\t\tqglTexCoord4i                = \tdllTexCoord4i                ;\n\t\tqglTexCoord4iv               = \tdllTexCoord4iv               ;\n\t\tqglTexCoord4s                = \tdllTexCoord4s                ;\n\t\tqglTexCoord4sv               = \tdllTexCoord4sv               ;\n\t\tqglTexCoordPointer           = \tdllTexCoordPointer           ;\n\t\tqglTexEnvf                   = \tdllTexEnvf                   ;\n\t\tqglTexEnvfv                  = \tdllTexEnvfv                  ;\n\t\tqglTexEnvi                   = \tdllTexEnvi                   ;\n\t\tqglTexEnviv                  = \tdllTexEnviv                  ;\n\t\tqglTexGend                   = \tdllTexGend                   ;\n\t\tqglTexGendv                  = \tdllTexGendv                  ;\n\t\tqglTexGenf                   = \tdllTexGenf                   ;\n\t\tqglTexGenfv                  = \tdllTexGenfv                  ;\n\t\tqglTexGeni                   = \tdllTexGeni                   ;\n\t\tqglTexGeniv                  = \tdllTexGeniv                  ;\n\t\tqglTexImage1D                = \tdllTexImage1D                ;\n\t\tqglTexImage2D                = \tdllTexImage2D                ;\n\t\tqglTexParameterf             = \tdllTexParameterf             ;\n\t\tqglTexParameterfv            = \tdllTexParameterfv            ;\n\t\tqglTexParameteri             = \tdllTexParameteri             ;\n\t\tqglTexParameteriv            = \tdllTexParameteriv            ;\n\t\tqglTexSubImage1D             = \tdllTexSubImage1D             ;\n\t\tqglTexSubImage2D             = \tdllTexSubImage2D             ;\n\t\tqglTranslated                = \tdllTranslated                ;\n\t\tqglTranslatef                = \tdllTranslatef                ;\n\t\tqglVertex2d                  = \tdllVertex2d                  ;\n\t\tqglVertex2dv                 = \tdllVertex2dv                 ;\n\t\tqglVertex2f                  = \tdllVertex2f                  ;\n\t\tqglVertex2fv                 = \tdllVertex2fv                 ;\n\t\tqglVertex2i                  = \tdllVertex2i                  ;\n\t\tqglVertex2iv                 = \tdllVertex2iv                 ;\n\t\tqglVertex2s                  = \tdllVertex2s                  ;\n\t\tqglVertex2sv                 = \tdllVertex2sv                 ;\n\t\tqglVertex3d                  = \tdllVertex3d                  ;\n\t\tqglVertex3dv                 = \tdllVertex3dv                 ;\n\t\tqglVertex3f                  = \tdllVertex3f                  ;\n\t\tqglVertex3fv                 = \tdllVertex3fv                 ;\n\t\tqglVertex3i                  = \tdllVertex3i                  ;\n\t\tqglVertex3iv                 = \tdllVertex3iv                 ;\n\t\tqglVertex3s                  = \tdllVertex3s                  ;\n\t\tqglVertex3sv                 = \tdllVertex3sv                 ;\n\t\tqglVertex4d                  = \tdllVertex4d                  ;\n\t\tqglVertex4dv                 = \tdllVertex4dv                 ;\n\t\tqglVertex4f                  = \tdllVertex4f                  ;\n\t\tqglVertex4fv                 = \tdllVertex4fv                 ;\n\t\tqglVertex4i                  = \tdllVertex4i                  ;\n\t\tqglVertex4iv                 = \tdllVertex4iv                 ;\n\t\tqglVertex4s                  = \tdllVertex4s                  ;\n\t\tqglVertex4sv                 = \tdllVertex4sv                 ;\n\t\tqglVertexPointer             = \tdllVertexPointer             ;\n\t\tqglViewport                  = \tdllViewport                  ;\n\t}\n}\n\n\nvoid GLimp_LogNewFrame( void )\n{\n\tfprintf( glw_state.log_fp, \"*** R_BeginFrame ***\\n\" );\n}\n\n\n"
  },
  {
    "path": "code/unix/linux_signals.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include <signal.h>\n\n#include \"../game/q_shared.h\"\n#include \"../qcommon/qcommon.h\"\n#ifndef DEDICATED\n#include \"../renderer/tr_local.h\"\n#endif\n\nstatic qboolean signalcaught = qfalse;;\n\nvoid Sys_Exit(int); // bk010104 - abstraction\n\nstatic void signal_handler(int sig) // bk010104 - replace this... (NOTE TTimo huh?)\n{\n  if (signalcaught)\n  {\n    printf(\"DOUBLE SIGNAL FAULT: Received signal %d, exiting...\\n\", sig);\n    Sys_Exit(1); // bk010104 - abstraction\n  }\n\n  signalcaught = qtrue;\n  printf(\"Received signal %d, exiting...\\n\", sig);\n#ifndef DEDICATED\n  GLimp_Shutdown(); // bk010104 - shouldn't this be CL_Shutdown\n#endif\n  Sys_Exit(0); // bk010104 - abstraction NOTE TTimo send a 0 to avoid DOUBLE SIGNAL FAULT\n}\n\nvoid InitSig(void)\n{\n  signal(SIGHUP, signal_handler);\n  signal(SIGQUIT, signal_handler);\n  signal(SIGILL, signal_handler);\n  signal(SIGTRAP, signal_handler);\n  signal(SIGIOT, signal_handler);\n  signal(SIGBUS, signal_handler);\n  signal(SIGFPE, signal_handler);\n  signal(SIGSEGV, signal_handler);\n  signal(SIGTERM, signal_handler);\n}\n"
  },
  {
    "path": "code/unix/linux_snd.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include <unistd.h>\n#include <fcntl.h>\n#include <stdlib.h>\n#include <sys/types.h>\n#include <sys/ioctl.h>\n#include <sys/mman.h>\n#include <sys/shm.h>\n#include <sys/wait.h>\n#ifdef __linux__ // rb0101023 - guard this\n#include <linux/soundcard.h>\n#endif\n#ifdef __FreeBSD__ // rb0101023 - added\n#include <sys/soundcard.h>\n#endif\n#include <stdio.h>\n\n#include \"../game/q_shared.h\"\n#include \"../client/snd_local.h\"\n\nint audio_fd;\nint snd_inited=0;\n\ncvar_t *sndbits;\ncvar_t *sndspeed;\ncvar_t *sndchannels;\n\ncvar_t *snddevice;\n\n/* Some devices may work only with 48000 */\nstatic int tryrates[] = { 22050, 11025, 44100, 48000, 8000 };\n\nstatic qboolean use_custom_memset = qfalse;\n// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=371 \nvoid Snd_Memset (void* dest, const int val, const size_t count)\n{\n  int *pDest;\n  int i, iterate;\n\n  if (!use_custom_memset)\n  {\n    Com_Memset(dest,val,count);\n    return;\n  }\n  iterate = count / sizeof(int);\n  pDest = (int*)dest;\n  for(i=0; i<iterate; i++)\n  {\n    pDest[i] = val;\n  }\n}\n\nqboolean SNDDMA_Init(void)\n{\n\tint rc;\n    int fmt;\n\tint tmp;\n    int i;\n    // char *s; // bk001204 - unused\n\tstruct audio_buf_info info;\n\tint caps;\n\textern uid_t saved_euid;\n\n\tif (snd_inited)\n\t\treturn 1;\n\n\tif (!snddevice) {\n\t\tsndbits = Cvar_Get(\"sndbits\", \"16\", CVAR_ARCHIVE);\n\t\tsndspeed = Cvar_Get(\"sndspeed\", \"0\", CVAR_ARCHIVE);\n\t\tsndchannels = Cvar_Get(\"sndchannels\", \"2\", CVAR_ARCHIVE);\n\t\tsnddevice = Cvar_Get(\"snddevice\", \"/dev/dsp\", CVAR_ARCHIVE);\n\t}\n\n\t// open /dev/dsp, confirm capability to mmap, and get size of dma buffer\n\tif (!audio_fd) {\n\t\tseteuid(saved_euid);\n\n\t\taudio_fd = open(snddevice->string, O_RDWR);\n\n\t\tseteuid(getuid());\n\n\t\tif (audio_fd < 0) {\n\t\t\tperror(snddevice->string);\n\t\t\tCom_Printf(\"Could not open %s\\n\", snddevice->string);\n\t\t\treturn 0;\n\t\t\t}\n\t}\n\n\tif (ioctl(audio_fd, SNDCTL_DSP_GETCAPS, &caps) == -1) {\n\t\tperror(snddevice->string);\n        Com_Printf(\"Sound driver too old\\n\");\n\t\tclose(audio_fd);\n\t\treturn 0;\n\t}\n\n\tif (!(caps & DSP_CAP_TRIGGER) || !(caps & DSP_CAP_MMAP)) {\n\t\tCom_Printf(\"Sorry but your soundcard can't do this\\n\");\n\t\tclose(audio_fd);\n\t\treturn 0;\n\t}\n\n\n\t/* SNDCTL_DSP_GETOSPACE moved to be called later */\n    \n\t// set sample bits & speed\n  dma.samplebits = (int)sndbits->value;\n\tif (dma.samplebits != 16 && dma.samplebits != 8) {\n        ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &fmt);\n        if (fmt & AFMT_S16_LE) \n\t\t\tdma.samplebits = 16;\n        else if (fmt & AFMT_U8) \n\t\t\tdma.samplebits = 8;\n    }\n\n\tdma.speed = (int)sndspeed->value;\n\tif (!dma.speed) {\n        for (i=0 ; i<sizeof(tryrates)/4 ; i++)\n            if (!ioctl(audio_fd, SNDCTL_DSP_SPEED, &tryrates[i])) \n\t\t\t\tbreak;\n        dma.speed = tryrates[i];\n    }\n\n\tdma.channels = (int)sndchannels->value;\n\tif (dma.channels < 1 || dma.channels > 2)\n\t\tdma.channels = 2;\n        \n/*  mmap() call moved forward */\n\n\ttmp = 0;\n\tif (dma.channels == 2)\n\t\ttmp = 1;\n    rc = ioctl(audio_fd, SNDCTL_DSP_STEREO, &tmp);\n    if (rc < 0) {\n\t\tperror(snddevice->string);\n        Com_Printf(\"Could not set %s to stereo=%d\", snddevice->string, dma.channels);\n\t\tclose(audio_fd);\n        return 0;\n    }\n\n\tif (tmp)\n\t\tdma.channels = 2;\n\telse\n\t\tdma.channels = 1;\n\n    rc = ioctl(audio_fd, SNDCTL_DSP_SPEED, &dma.speed);\n    if (rc < 0) {\n\t\tperror(snddevice->string);\n        Com_Printf(\"Could not set %s speed to %d\", snddevice->string, dma.speed);\n\t\tclose(audio_fd);\n        return 0;\n    }\n\n    if (dma.samplebits == 16) {\n        rc = AFMT_S16_LE;\n        rc = ioctl(audio_fd, SNDCTL_DSP_SETFMT, &rc);\n        if (rc < 0) {\n\t\t\tperror(snddevice->string);\n\t\t\tCom_Printf(\"Could not support 16-bit data.  Try 8-bit.\\n\");\n\t\t\tclose(audio_fd);\n\t\t\treturn 0;\n\t\t}\n    } else if (dma.samplebits == 8) {\n        rc = AFMT_U8;\n        rc = ioctl(audio_fd, SNDCTL_DSP_SETFMT, &rc);\n        if (rc < 0) {\n\t\t\tperror(snddevice->string);\n\t\t\tCom_Printf(\"Could not support 8-bit data.\\n\");\n\t\t\tclose(audio_fd);\n\t\t\treturn 0;\n\t\t}\n    } else {\n\t\tperror(snddevice->string);\n\t\tCom_Printf(\"%d-bit sound not supported.\", dma.samplebits);\n\t\tclose(audio_fd);\n\t\treturn 0;\n\t}\n\n    if (ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info)==-1) {   \n        perror(\"GETOSPACE\");\n\t\tCom_Printf(\"Um, can't do GETOSPACE?\\n\");\n\t\tclose(audio_fd);\n\t\treturn 0;\n    }\n\n\tdma.samples = info.fragstotal * info.fragsize / (dma.samplebits/8);\n\tdma.submission_chunk = 1;\n\n\t// memory map the dma buffer\n\n  // TTimo 2001/10/08 added PROT_READ to the mmap\n  // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=371\n  // checking Alsa bug, doesn't allow dma alloc with PROT_READ?\n\n\tif (!dma.buffer)\n\t\tdma.buffer = (unsigned char *) mmap(NULL, info.fragstotal\n\t\t\t* info.fragsize, PROT_WRITE|PROT_READ, MAP_FILE|MAP_SHARED, audio_fd, 0);\n\n  if (dma.buffer == MAP_FAILED)\n  {\n    Com_Printf(\"Could not mmap dma buffer PROT_WRITE|PROT_READ\\n\");\n    Com_Printf(\"trying mmap PROT_WRITE (with associated better compatibility / less performance code)\\n\");\n\t\tdma.buffer = (unsigned char *) mmap(NULL, info.fragstotal\n\t\t\t* info.fragsize, PROT_WRITE, MAP_FILE|MAP_SHARED, audio_fd, 0);\n    // NOTE TTimo could add a variable to force using regular memset on systems that are known to be safe\n    use_custom_memset = qtrue;\n  }\n\n\tif (dma.buffer == MAP_FAILED) {\n\t\tperror(snddevice->string);\n\t\tCom_Printf(\"Could not mmap %s\\n\", snddevice->string);\n\t\tclose(audio_fd);\n\t\treturn 0;\n\t}\n\n\t// toggle the trigger & start her up\n\n  tmp = 0;\n  rc  = ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &tmp);\n\tif (rc < 0) {\n\t\tperror(snddevice->string);\n\t\tCom_Printf(\"Could not toggle.\\n\");\n\t\tclose(audio_fd);\n\t\treturn 0;\n\t}\n\n  tmp = PCM_ENABLE_OUTPUT;\n  rc = ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &tmp);\n\tif (rc < 0) {\n\t\tperror(snddevice->string);\n\t\tCom_Printf(\"Could not toggle.\\n\");\n\t\tclose(audio_fd);\n\n\t\treturn 0;\n\t}\n\n\tsnd_inited = 1;\n\treturn 1;\n}\n\nint SNDDMA_GetDMAPos(void)\n{\n\tstruct count_info count;\n\n\tif (!snd_inited) return 0;\n\n\tif (ioctl(audio_fd, SNDCTL_DSP_GETOPTR, &count) == -1) {\n\t\tperror(snddevice->string);\n\t\tCom_Printf(\"Uh, sound dead.\\n\");\n\t\tclose(audio_fd);\n\t\tsnd_inited = 0;\n\t\treturn 0;\n\t}\n\treturn count.ptr / (dma.samplebits / 8);\n}\n\nvoid SNDDMA_Shutdown(void)\n{\n}\n\n/*\n==============\nSNDDMA_Submit\n\nSend sound to device if buffer isn't really the dma buffer\n===============\n*/\nvoid SNDDMA_Submit(void)\n{\n}\n\nvoid SNDDMA_BeginPainting (void)\n{\n}\n"
  },
  {
    "path": "code/unix/matha.s",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// math.s\n// x86 assembly-language math routines.\n\n#define GLQUAKE\t1\t// don't include unneeded defs\n#include \"qasm.h\"\n\n\n#if\tid386\n\n\t.data\n\n\t.align\t4\nLjmptab:\t.long\tLcase0, Lcase1, Lcase2, Lcase3\n\t\t\t.long\tLcase4, Lcase5, Lcase6, Lcase7\n\n\t.text\n\n// TODO: rounding needed?\n// stack parameter offset\n#define\tval\t4\n\n.globl C(Invert24To16)\nC(Invert24To16):\n\n\tmovl\tval(%esp),%ecx\n\tmovl\t$0x100,%edx\t\t// 0x10000000000 as dividend\n\tcmpl\t%edx,%ecx\n\tjle\t\tLOutOfRange\n\n\tsubl\t%eax,%eax\n\tdivl\t%ecx\n\n\tret\n\nLOutOfRange:\n\tmovl\t$0xFFFFFFFF,%eax\n\tret\n\n#if 0\n\n#define\tin\t4\n#define out\t8\n\n\t.align 2\n.globl C(TransformVector)\nC(TransformVector):\n\tmovl\tin(%esp),%eax\n\tmovl\tout(%esp),%edx\n\n\tflds\t(%eax)\t\t// in[0]\n\tfmuls\tC(vright)\t\t// in[0]*vright[0]\n\tflds\t(%eax)\t\t// in[0] | in[0]*vright[0]\n\tfmuls\tC(vup)\t\t// in[0]*vup[0] | in[0]*vright[0]\n\tflds\t(%eax)\t\t// in[0] | in[0]*vup[0] | in[0]*vright[0]\n\tfmuls\tC(vpn)\t\t// in[0]*vpn[0] | in[0]*vup[0] | in[0]*vright[0]\n\n\tflds\t4(%eax)\t\t// in[1] | ...\n\tfmuls\tC(vright)+4\t// in[1]*vright[1] | ...\n\tflds\t4(%eax)\t\t// in[1] | in[1]*vright[1] | ...\n\tfmuls\tC(vup)+4\t\t// in[1]*vup[1] | in[1]*vright[1] | ...\n\tflds\t4(%eax)\t\t// in[1] | in[1]*vup[1] | in[1]*vright[1] | ...\n\tfmuls\tC(vpn)+4\t\t// in[1]*vpn[1] | in[1]*vup[1] | in[1]*vright[1] | ...\n\tfxch\t%st(2)\t\t// in[1]*vright[1] | in[1]*vup[1] | in[1]*vpn[1] | ...\n\n\tfaddp\t%st(0),%st(5)\t// in[1]*vup[1] | in[1]*vpn[1] | ...\n\tfaddp\t%st(0),%st(3)\t// in[1]*vpn[1] | ...\n\tfaddp\t%st(0),%st(1)\t// vpn_accum | vup_accum | vright_accum\n\n\tflds\t8(%eax)\t\t// in[2] | ...\n\tfmuls\tC(vright)+8\t// in[2]*vright[2] | ...\n\tflds\t8(%eax)\t\t// in[2] | in[2]*vright[2] | ...\n\tfmuls\tC(vup)+8\t\t// in[2]*vup[2] | in[2]*vright[2] | ...\n\tflds\t8(%eax)\t\t// in[2] | in[2]*vup[2] | in[2]*vright[2] | ...\n\tfmuls\tC(vpn)+8\t\t// in[2]*vpn[2] | in[2]*vup[2] | in[2]*vright[2] | ...\n\tfxch\t%st(2)\t\t// in[2]*vright[2] | in[2]*vup[2] | in[2]*vpn[2] | ...\n\n\tfaddp\t%st(0),%st(5)\t// in[2]*vup[2] | in[2]*vpn[2] | ...\n\tfaddp\t%st(0),%st(3)\t// in[2]*vpn[2] | ...\n\tfaddp\t%st(0),%st(1)\t// vpn_accum | vup_accum | vright_accum\n\n\tfstps\t8(%edx)\t\t// out[2]\n\tfstps\t4(%edx)\t\t// out[1]\n\tfstps\t(%edx)\t\t// out[0]\n\n\tret\n\n#endif\n\n#define EMINS\t4+4\n#define EMAXS\t4+8\n#define P\t\t4+12\n\n\t.align 2\n.globl C(BoxOnPlaneSide)\nC(BoxOnPlaneSide):\n\tpushl\t%ebx\n\n\tmovl\tP(%esp),%edx\n\tmovl\tEMINS(%esp),%ecx\n\txorl\t%eax,%eax\n\tmovl\tEMAXS(%esp),%ebx\n\tmovb\tpl_signbits(%edx),%al\n\tcmpb\t$8,%al\n\tjge\t\tLerror\n\tflds\tpl_normal(%edx)\t\t// p->normal[0]\n\tfld\t\t%st(0)\t\t\t\t// p->normal[0] | p->normal[0]\n\t// bk000422 - warning: missing prefix `*' in absolute indirect address, maybe misassembled!\n\t// bk001129 - fix from Andrew Henderson, was: Ljmptab(,%eax,4) \n\tjmp\t\t*Ljmptab(,%eax,4)\n\n\n//dist1= p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];\n//dist2= p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];\nLcase0:\n\tfmuls\t(%ebx)\t\t\t\t// p->normal[0]*emaxs[0] | p->normal[0]\n\tflds\tpl_normal+4(%edx)\t// p->normal[1] | p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]\n\tfxch\t%st(2)\t\t\t\t// p->normal[0] | p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[1]\n\tfmuls\t(%ecx)\t\t\t\t// p->normal[0]*emins[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emaxs[0] | p->normal[1]\n\tfxch\t%st(2)\t\t\t\t// p->normal[1] | p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emins[0]\n\tfld\t\t%st(0)\t\t\t\t// p->normal[1] | p->normal[1] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emins[0]\n\tfmuls\t4(%ebx)\t\t\t\t// p->normal[1]*emaxs[1] | p->normal[1] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emins[0]\n\tflds\tpl_normal+8(%edx)\t// p->normal[2] | p->normal[1]*emaxs[1] |\n\t\t\t\t\t\t\t\t//  p->normal[1] | p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emins[0]\n\tfxch\t%st(2)\t\t\t\t// p->normal[1] | p->normal[1]*emaxs[1] |\n\t\t\t\t\t\t\t\t//  p->normal[2] | p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emins[0]\n\tfmuls\t4(%ecx)\t\t\t\t// p->normal[1]*emins[1] |\n\t\t\t\t\t\t\t\t//  p->normal[1]*emaxs[1] |\n\t\t\t\t\t\t\t\t//  p->normal[2] | p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emins[0]\n\tfxch\t%st(2)\t\t\t\t// p->normal[2] | p->normal[1]*emaxs[1] |\n\t\t\t\t\t\t\t\t//  p->normal[1]*emins[1] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emins[0]\n\tfld\t\t%st(0)\t\t\t\t// p->normal[2] | p->normal[2] |\n\t\t\t\t\t\t\t\t//  p->normal[1]*emaxs[1] |\n\t\t\t\t\t\t\t\t//  p->normal[1]*emins[1] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emins[0]\n\tfmuls\t8(%ebx)\t\t\t\t// p->normal[2]*emaxs[2] |\n\t\t\t\t\t\t\t\t//  p->normal[2] |\n\t\t\t\t\t\t\t\t//  p->normal[1]*emaxs[1] |\n\t\t\t\t\t\t\t\t//  p->normal[1]*emins[1] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emins[0]\n\tfxch\t%st(5)\t\t\t\t// p->normal[0]*emins[0] |\n\t\t\t\t\t\t\t\t//  p->normal[2] |\n\t\t\t\t\t\t\t\t//  p->normal[1]*emaxs[1] |\n\t\t\t\t\t\t\t\t//  p->normal[1]*emins[1] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[2]*emaxs[2]\n\tfaddp\t%st(0),%st(3)\t\t//p->normal[2] |\n\t\t\t\t\t\t\t\t// p->normal[1]*emaxs[1] |\n\t\t\t\t\t\t\t\t// p->normal[1]*emins[1]+p->normal[0]*emins[0]|\n\t\t\t\t\t\t\t\t// p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t// p->normal[2]*emaxs[2]\n\tfmuls\t8(%ecx)\t\t\t\t//p->normal[2]*emins[2] |\n\t\t\t\t\t\t\t\t// p->normal[1]*emaxs[1] |\n\t\t\t\t\t\t\t\t// p->normal[1]*emins[1]+p->normal[0]*emins[0]|\n\t\t\t\t\t\t\t\t// p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t// p->normal[2]*emaxs[2]\n\tfxch\t%st(1)\t\t\t\t//p->normal[1]*emaxs[1] |\n\t\t\t\t\t\t\t\t// p->normal[2]*emins[2] |\n\t\t\t\t\t\t\t\t// p->normal[1]*emins[1]+p->normal[0]*emins[0]|\n\t\t\t\t\t\t\t\t// p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t// p->normal[2]*emaxs[2]\n\tfaddp\t%st(0),%st(3)\t\t//p->normal[2]*emins[2] |\n\t\t\t\t\t\t\t\t// p->normal[1]*emins[1]+p->normal[0]*emins[0]|\n\t\t\t\t\t\t\t\t// p->normal[0]*emaxs[0]+p->normal[1]*emaxs[1]|\n\t\t\t\t\t\t\t\t// p->normal[2]*emaxs[2]\n\tfxch\t%st(3)\t\t\t\t//p->normal[2]*emaxs[2] +\n\t\t\t\t\t\t\t\t// p->normal[1]*emins[1]+p->normal[0]*emins[0]|\n\t\t\t\t\t\t\t\t// p->normal[0]*emaxs[0]+p->normal[1]*emaxs[1]|\n\t\t\t\t\t\t\t\t// p->normal[2]*emins[2]\n\tfaddp\t%st(0),%st(2)\t\t//p->normal[1]*emins[1]+p->normal[0]*emins[0]|\n\t\t\t\t\t\t\t\t// dist1 | p->normal[2]*emins[2]\n\n\tjmp\t\tLSetSides\n\n//dist1= p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];\n//dist2= p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];\nLcase1:\n\tfmuls\t(%ecx)\t\t\t\t// emins[0]\n\tflds\tpl_normal+4(%edx)\n\tfxch\t%st(2)\n\tfmuls\t(%ebx)\t\t\t\t// emaxs[0]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t4(%ebx)\t\t\t\t// emaxs[1]\n\tflds\tpl_normal+8(%edx)\n\tfxch\t%st(2)\n\tfmuls\t4(%ecx)\t\t\t\t// emins[1]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t8(%ebx)\t\t\t\t// emaxs[2]\n\tfxch\t%st(5)\n\tfaddp\t%st(0),%st(3)\n\tfmuls\t8(%ecx)\t\t\t\t// emins[2]\n\tfxch\t%st(1)\n\tfaddp\t%st(0),%st(3)\n\tfxch\t%st(3)\n\tfaddp\t%st(0),%st(2)\n\n\tjmp\t\tLSetSides\n\n//dist1= p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];\n//dist2= p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];\nLcase2:\n\tfmuls\t(%ebx)\t\t\t\t// emaxs[0]\n\tflds\tpl_normal+4(%edx)\n\tfxch\t%st(2)\n\tfmuls\t(%ecx)\t\t\t\t// emins[0]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t4(%ecx)\t\t\t\t// emins[1]\n\tflds\tpl_normal+8(%edx)\n\tfxch\t%st(2)\n\tfmuls\t4(%ebx)\t\t\t\t// emaxs[1]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t8(%ebx)\t\t\t\t// emaxs[2]\n\tfxch\t%st(5)\n\tfaddp\t%st(0),%st(3)\n\tfmuls\t8(%ecx)\t\t\t\t// emins[2]\n\tfxch\t%st(1)\n\tfaddp\t%st(0),%st(3)\n\tfxch\t%st(3)\n\tfaddp\t%st(0),%st(2)\n\n\tjmp\t\tLSetSides\n\n//dist1= p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];\n//dist2= p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];\nLcase3:\n\tfmuls\t(%ecx)\t\t\t\t// emins[0]\n\tflds\tpl_normal+4(%edx)\n\tfxch\t%st(2)\n\tfmuls\t(%ebx)\t\t\t\t// emaxs[0]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t4(%ecx)\t\t\t\t// emins[1]\n\tflds\tpl_normal+8(%edx)\n\tfxch\t%st(2)\n\tfmuls\t4(%ebx)\t\t\t\t// emaxs[1]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t8(%ebx)\t\t\t\t// emaxs[2]\n\tfxch\t%st(5)\n\tfaddp\t%st(0),%st(3)\n\tfmuls\t8(%ecx)\t\t\t\t// emins[2]\n\tfxch\t%st(1)\n\tfaddp\t%st(0),%st(3)\n\tfxch\t%st(3)\n\tfaddp\t%st(0),%st(2)\n\n\tjmp\t\tLSetSides\n\n//dist1= p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];\n//dist2= p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];\nLcase4:\n\tfmuls\t(%ebx)\t\t\t\t// emaxs[0]\n\tflds\tpl_normal+4(%edx)\n\tfxch\t%st(2)\n\tfmuls\t(%ecx)\t\t\t\t// emins[0]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t4(%ebx)\t\t\t\t// emaxs[1]\n\tflds\tpl_normal+8(%edx)\n\tfxch\t%st(2)\n\tfmuls\t4(%ecx)\t\t\t\t// emins[1]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t8(%ecx)\t\t\t\t// emins[2]\n\tfxch\t%st(5)\n\tfaddp\t%st(0),%st(3)\n\tfmuls\t8(%ebx)\t\t\t\t// emaxs[2]\n\tfxch\t%st(1)\n\tfaddp\t%st(0),%st(3)\n\tfxch\t%st(3)\n\tfaddp\t%st(0),%st(2)\n\n\tjmp\t\tLSetSides\n\n//dist1= p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];\n//dist2= p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];\nLcase5:\n\tfmuls\t(%ecx)\t\t\t\t// emins[0]\n\tflds\tpl_normal+4(%edx)\n\tfxch\t%st(2)\n\tfmuls\t(%ebx)\t\t\t\t// emaxs[0]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t4(%ebx)\t\t\t\t// emaxs[1]\n\tflds\tpl_normal+8(%edx)\n\tfxch\t%st(2)\n\tfmuls\t4(%ecx)\t\t\t\t// emins[1]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t8(%ecx)\t\t\t\t// emins[2]\n\tfxch\t%st(5)\n\tfaddp\t%st(0),%st(3)\n\tfmuls\t8(%ebx)\t\t\t\t// emaxs[2]\n\tfxch\t%st(1)\n\tfaddp\t%st(0),%st(3)\n\tfxch\t%st(3)\n\tfaddp\t%st(0),%st(2)\n\n\tjmp\t\tLSetSides\n\n//dist1= p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];\n//dist2= p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];\nLcase6:\n\tfmuls\t(%ebx)\t\t\t\t// emaxs[0]\n\tflds\tpl_normal+4(%edx)\n\tfxch\t%st(2)\n\tfmuls\t(%ecx)\t\t\t\t// emins[0]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t4(%ecx)\t\t\t\t// emins[1]\n\tflds\tpl_normal+8(%edx)\n\tfxch\t%st(2)\n\tfmuls\t4(%ebx)\t\t\t\t// emaxs[1]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t8(%ecx)\t\t\t\t// emins[2]\n\tfxch\t%st(5)\n\tfaddp\t%st(0),%st(3)\n\tfmuls\t8(%ebx)\t\t\t\t// emaxs[2]\n\tfxch\t%st(1)\n\tfaddp\t%st(0),%st(3)\n\tfxch\t%st(3)\n\tfaddp\t%st(0),%st(2)\n\n\tjmp\t\tLSetSides\n\n//dist1= p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];\n//dist2= p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];\nLcase7:\n\tfmuls\t(%ecx)\t\t\t\t// emins[0]\n\tflds\tpl_normal+4(%edx)\n\tfxch\t%st(2)\n\tfmuls\t(%ebx)\t\t\t\t// emaxs[0]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t4(%ecx)\t\t\t\t// emins[1]\n\tflds\tpl_normal+8(%edx)\n\tfxch\t%st(2)\n\tfmuls\t4(%ebx)\t\t\t\t// emaxs[1]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t8(%ecx)\t\t\t\t// emins[2]\n\tfxch\t%st(5)\n\tfaddp\t%st(0),%st(3)\n\tfmuls\t8(%ebx)\t\t\t\t// emaxs[2]\n\tfxch\t%st(1)\n\tfaddp\t%st(0),%st(3)\n\tfxch\t%st(3)\n\tfaddp\t%st(0),%st(2)\n\nLSetSides:\n\n//\tsides = 0;\n//\tif (dist1 >= p->dist)\n//\t\tsides = 1;\n//\tif (dist2 < p->dist)\n//\t\tsides |= 2;\n\n\tfaddp\t%st(0),%st(2)\t\t// dist1 | dist2\n\tfcomps\tpl_dist(%edx)\n\txorl\t%ecx,%ecx\n\tfnstsw\t%ax\n\tfcomps\tpl_dist(%edx)\n\tandb\t$1,%ah\n\txorb\t$1,%ah\n\taddb\t%ah,%cl\n\n\tfnstsw\t%ax\n\tandb\t$1,%ah\n\taddb\t%ah,%ah\n\taddb\t%ah,%cl\n\n//\treturn sides;\n\n\tpopl\t%ebx\n\tmovl\t%ecx,%eax\t// return status\n\n\tret\n\n\nLerror:\n\tmovl\t1, %eax\n\tret\n\n#endif\t// id386\n"
  },
  {
    "path": "code/unix/pcons-2.3.1",
    "content": "#!/usr/bin/env perl\n\n#\n# Revision history:\n# -----------------\n# July 2001, Thomas Gleerup <tgl@oticon.dk>\n#   1) pcons-1.6 (John Erickson, August 1999) merged into cons-2.3.0.\n#   2) Added automatic insertion of && for multi-line commands.\n#\n# September 2001, Thomas Gleerup <tgl@oticon.dk>\n#   1) Updated with Kevin Nolish's multi-line improvement.\n#   2) Improved this so that single [perl] commands can still be used.\n#\n\n# NOTE:  Cons intentionally does not use the \"perl -w\" option or\n# \"use strict.\"  Because Cons \"configuration files\" are actually\n# Perl scripts, enabling those restrictions here would force them\n# on every user's config files, wanted or not.  Would users write\n# \"better\" Construct and Conscript files if we forced \"use strict\"\n# on them?  Probably.  But we want people to use Cons to get work\n# done, not force everyone to become a Perl guru to use it, so we\n# don't insist.\n#\n# That said, Cons' code is both \"perl -w\" and \"use strict\" clean.\n# Regression tests keep the code honest by checking for warnings\n# and \"use strict\" failures.\n\nuse vars qw( $CVS_id $CVS_ver $ver_num $ver_rev $version );\n\n# I hate those CVS tags\n$CVS_id  = 'pcons-2.3.1';\n$CVS_ver = (split (/\\s+/, $CVS_id))[2];\n\n$ver_num = \"__VERSION__\";\n$ver_rev = \"__REVISION__\";\n\n#$version = \"This is Cons $ver_num$ver_rev ($CVS_id)\\n\";\n$version = \"This is parallel Cons (pcons) $ver_num$ver_rev ($CVS_id)\\n\";\n\n# Cons: A Software Construction Tool.\n# Copyright (c) 1996-2001 Free Software Foundation, Inc.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 2 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; see the file COPYING.  If not, write to\n# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n# Boston, MA 02111-1307, USA.\n\nrequire 5.003;\n\n# See the NOTE above about why Cons doesn't \"use strict\".\nuse integer;\nuse Cwd;\nuse File::Copy;\n\nuse vars qw( $_WIN32 $_a $_exe $_o $_so );\n\n#------------------------------------------------------------------\n# Determine if running on win32 platform - either Windows NT or 95\n#------------------------------------------------------------------\n\nuse vars qw( $PATH_SEPARATOR $iswin32 $_WIN32 $usage $indent @targets );\n\nBEGIN\n{\n    use Config;\n\n    # if the version is 5.003, we can check $^O\n    if ($] < 5.003)\n    {\n        eval(\"require Win32\");\n        $_WIN32 = (!$@);\n    }\n    else\n    {\n        $_WIN32 = ($^O eq \"MSWin32\") ? 1 : 0;\n    }\n\n    # Fetch the PATH separator from Config;\n    # provide our old defaults in case it's not set.\n    $PATH_SEPARATOR = $Config{path_sep};\n    $PATH_SEPARATOR = $_WIN32 ? ';' : ':' if !defined $PATH_SEPARATOR;\n\n    # Fetch file suffixes from Config,\n    # accomodating differences in the Config variables\n    # used by different Perl versions.\n    $_exe = $Config{_exe};\n    $_exe = $Config{exe_ext} if !defined $_exe;\n    $_exe = $_WIN32 ? '.exe' : '' if !defined $_exe;\n    $_o   = $Config{_o};\n    $_o = $Config{obj_ext} if !defined $_o;\n    $_o = $_WIN32 ? '.obj' : '.o' if !defined $_o;\n    $_a  = $Config{_a};\n    $_a  = $Config{lib_ext} if !defined $_a;\n    $_a  = $_WIN32 ? '.lib' : '.a' if !defined $_a;\n    $_so = \".$Config{so}\";\n    $_so = $_WIN32 ? '.dll' : '.so' if !defined $_so;\n}\n\n# Flush stdout each time.\n$| = 1;\n\n# Seed random number generator.\nsrand(time . $$);    # this works better than time ^ $$ in perlfunc manpage.\n\n$usage = q(\nUsage: cons <arguments> -- <construct-args>\n\nArguments can be any of the following, in any order:\n\n  <targets>\tBuild the specified targets. If <target> is a directory\n\t\trecursively build everything within that directory.\n\n  +<pattern>\tLimit the cons scripts considered to just those that\n\t\tmatch <pattern>. Multiple + arguments are accepted.\n\n  <name>=<val>\tSets <name> to value <val> in the ARG hash passed to the\n\t\ttop-level Construct file.\n\n  -cc           Show command that would have been executed, when\n\t\tretrieving from cache. No indication that the file\n\t\thas been retrieved is given; this is useful for\n\t\tgenerating build logs that can be compared with\n\t\treal build logs.\n\n  -cd           Disable all caching. Do not retrieve from cache nor\n\t\tflush to cache.\n\n  -cr           Build dependencies in random order. This is useful when\n\t\tbuilding multiple similar trees with caching enabled.\n\n  -cs           Synchronize existing build targets that are found to be\n\t\tup-to-date with cache. This is useful if caching has\n\t\tbeen disabled with -cc or just recently enabled with\n\t\tUseCache.\n\n  -d            Enable dependency debugging.\n\n  -f <file>\tUse the specified file instead of \"Construct\" (but first\n\t\tchange to containing directory of <file>).\n\n  -h            Show a help message local to the current build if\n\t\tone such is defined,  and exit.\n\n  -k\t\tKeep going as far as possible after errors.\n\n  -o <file>\tRead override file <file>.\n\n  -p\t\tShow construction products in specified trees.\n  -pa\t\tShow construction products and associated actions.\n  -pw\t\tShow products and where they are defined.\n\n  -q\t\tBe quiet; multiple -q flags increase quietness level:\n\t\t1: quiet about Installing and Removing targets\n\t\t2: quiet about build commands, up-to-date targets\n\n  -r\t\tRemove construction products associated with <targets>\n\n  -R <repos>\tSearch for files in <repos>.  Multiple -R <repos>\n\t\tdirectories are searched in the order specified.\n\n  -S <pkg>\tUse package sig::<pkg> to calculate file signatures.\n\t\tCurrently supported values are \"md5\" for MD5\n\t\tsignatures (the default) and \"md5::debug\" for MD5\n\t\tsignature debug information.\n\n  -t            Traverse up the directory hierarchy looking for a\n\t\tConstruct file, if none exists in the current directory.\n\t\t(Targets will be modified to be relative to the\n\t\tConstruct file.)\n\n  -v\t\tShow cons version and continue processing.\n  -V            Show cons version and exit.\n\n  -wf <file>    Write all filenames considered into <file>.\n\n  -x\t\tShow this message and exit.\n\n\n   Please report any suggestions through the cons-discuss@gnu.org mailing\n   list.\n\n   To subscribe, send mail to cons-discuss-request@gnu.org with body\n   'subscribe'.\n\n   If you find a bug, please report it through the bug-cons@gnu.org\n   mailing list.\n\n   Information about CONS can be obtained from the official cons web site\n   http://www.dsmit.com/cons/ or its mirrors (listed there).\n\n   The cons maintainers can be contacted by email at cons-maintainers@gnu.org\n\n   User documentation of cons is contained in cons and can be obtained\n   by doing 'perldoc /path/to/cons'.\n\n);\nmy $pcons = 1;\n\n# Simplify program name, if it is a path.\n{\n    my ($vol, $dir, $file) = File::Spec->splitpath(File::Spec->canonpath($0));\n    $0 = $file;\n}\n\n# Default parameters.\n$param::topfile = 'Construct';    # Top-level construction file.\n$param::install = 1;              # Show installations\n$param::build   = 1;              # Build targets\n     ### $param::show = 1;\t\t# Show building of targets.\n$param::sigpro  = 'md5';    # Signature protocol.\n$param::depfile = '';       # Write all deps out to this file\n$param::salt    = '';       # Salt derived file signatures with this.\n$param::sourcesig = ['*' => 'content'];    # Source file signature calculation\n$param::rep_sig_times_ok = 1;    # Repository .consign times are in sync\n                                 #   w/files.\n$param::conscript_chdir  = 0;    # Change dir to Conscript directory\n$param::quiet            = 0;    # should we show the command being executed.\n$param::max_jobs         = 1;    # pcons\n\n@param::defaults = ();\n\n#\n$indent = '';\n\n# Display a command while executing or otherwise. This\n# should be called by command builder action methods.\nsub showcom\n{\n    print($indent . $_[0] . \"\\n\") if ($param::quiet < 2);\n}\n\n# Default environment.\n# This contains only the completely platform-independent information\n# we can figure out.  Platform-specific information (UNIX, Win32)\n# gets added below.\n@param::base = (\n    'SIGNATURE' => ['*' => 'build'],\n    'SUFEXE'  => $_exe,         # '' on UNIX systems\n    'SUFLIB'  => $_a,           # '.a' on UNIX systems\n    'SUFLIBS' => \"$_so:$_a\",    # '.so:.a' on UNIX\n    'SUFOBJ'  => $_o,           # '.o' on UNIX systems\n    'SUFMAP' => {\n                  '.c'   => 'build::command::cc',\n                  '.s'   => 'build::command::cc',\n                  '.S'   => 'build::command::cc',\n                  '.C'   => 'build::command::cxx',\n                  '.cc'  => 'build::command::cxx',\n                  '.cxx' => 'build::command::cxx',\n                  '.cpp' => 'build::command::cxx',\n                  '.c++' => 'build::command::cxx',\n                  '.C++' => 'build::command::cxx',\n    },\n    'PERL' => $^X,\n    );\n\n# pcons does not allow multi-line commands\nmy $ar_command = ($param::max_jobs <= 1)\n  ?    # pcons\n  ['%AR %ARFLAGS %> %<', '%RANLIB %>']\n  :                                          # cons\n  '%AR %ARFLAGS %> %<   &&   %RANLIB %>';    # pcons\n\n%param::rulesets = (\n\n    # Defaults for Win32.\n    # Defined for VC++ 6.0 by Greg Spencer <greg_spencer@acm.org>\n    # Your mileage may vary.\n    'msvc' => [\n                'CC'            => 'cl',\n                'CFLAGS'        => '/nologo',\n                'CCCOM'         => '%CC %CFLAGS %_IFLAGS /c %< /Fo%>',\n                'CXX'           => '%CC',\n                'CXXFLAGS'      => '%CFLAGS',\n                'CXXCOM'        => '%CXX %CXXFLAGS %_IFLAGS /c %< /Fo%>',\n                'INCDIRPREFIX'  => '/I',\n                'INCDIRSUFFIX'  => '',\n                'LINK'          => 'link',\n                'LINKCOM'       => '%LINK %LDFLAGS /out:%> %< %_LDIRS %LIBS',\n                'LINKMODULECOM' => '%LD /r /o %> %<',\n                'LIBDIRPREFIX'  => '/LIBPATH:',\n                'LIBDIRSUFFIX'  => '',\n                'AR'            => 'lib',\n                'ARFLAGS'       => '/nologo ',\n                'ARCOM'         => \"%AR %ARFLAGS /out:%> %<\",\n                'RANLIB'        => '',\n                'LD'            => 'link',\n                'LDFLAGS'       => '/nologo ',\n                'PREFLIB'       => '',\n    ],\n\n    # Defaults for a typical (?) UNIX platform.\n    # Your mileage may vary.\n    'unix' => [\n           'CC'            => 'cc',\n           'CFLAGS'        => '',\n           'CCCOM'         => '%CC %CFLAGS %_IFLAGS -c %< -o %>',\n           'CXX'           => '%CC',\n           'CXXFLAGS'      => '%CFLAGS',\n           'CXXCOM'        => '%CXX %CXXFLAGS %_IFLAGS -c %< -o %>',\n           'INCDIRPREFIX'  => '-I',\n           'INCDIRSUFFIX'  => '',\n           'LINK'          => '%CXX',\n           'LINKCOM'       => '%LINK %LDFLAGS -o %> %< %_LDIRS %LIBS',\n           'LINKMODULECOM' => '%LD -r -o %> %<',\n           'LIBDIRPREFIX'  => '-L',\n           'LIBDIRSUFFIX'  => '',\n           'AR'            => 'ar',\n           'ARFLAGS'       => 'r',                                       # rs?\n           'ARCOM'         => $ar_command,                               # pcons\n           'RANLIB'        => 'ranlib',\n           'AS'            => 'as',\n           'ASFLAGS'       => '',\n           'ASCOM'         => '%AS %ASFLAGS %< -o %>',\n           'LD'            => 'ld',\n           'LDFLAGS'       => '',\n           'PREFLIB'       => 'lib',\n           'ENV'           => {'PATH' => '/bin:/usr/bin'},\n    ],\n    );\n\n# Set the rules based on the platform.\nscript::DefaultRules(script::RuleSet($_WIN32 ? 'msvc' : 'unix'));\n\n# Handle command line arguments.\nwhile (@ARGV)\n{\n    $_ = shift @ARGV;\n    last if /^--$/;    # Argument passing to Construct.\n    &option, next if s/^-//;\n    push (@param::include, $_), next if s/^\\+//;\n    &equate, next if /=/;\n    push (@targets, $_), next;\n}\n\nsub option\n{\n    my %opt = (\n        'cc' => sub { $param::cachecom     = 1; },\n        'cd' => sub { $param::cachedisable = 1; },\n        'cr' => sub { $param::random       = 1; },\n        'cs' => sub { $param::cachesync    = 1; },\n        'd'  => sub { $param::depends      = 1; },\n        'h'  => sub { $param::localhelp    = 1; },\n        'k'  => sub { $param::kflag        = 1; },\n        'p'  => sub {\n            $param::pflag = 1;\n            $param::build = 0;\n        },\n        'pa' => sub {\n            $param::pflag = 1;\n            $param::aflag = 1;\n            $indent       = \"... \";\n            $param::build = 0;\n        },\n        'pw' => sub {\n            $param::pflag = 1;\n            $param::wflag = 1;\n            $param::build = 0;\n        },\n        'q' => sub { $param::quiet++; },\n        'r' => sub {\n            $param::rflag = 1;\n            $param::build = 0;\n        },\n        't' => sub { $param::traverse = 1; },\n        'v' => sub { print($version); },\n        'V' => sub { print($version), exit(0); },\n        'x' => sub { print($usage), exit 0; },\n        );\n\n    my %opt_arg = (\n        'f' => sub { $param::topfile  = $_[0]; },\n        'o' => sub { $param::overfile = $_[0]; },\n        'R'  => sub { script::Repository($_[0]); },\n        'S'  => sub { $param::sigpro = $_[0]; },\n        'wf' => sub { $param::depfile = $_[0]; },\n        'j'  => sub { $param::max_jobs = $_[0]; },    # pcons\n        );\n\n    if (defined $opt{$_})\n    {\n        &{$opt{$_}} ();\n        return;\n    }\n    while ($_)\n    {\n        $_ =~ m/(.)(.*)/;\n        if (defined $opt{$1})\n        {\n            &{$opt{$1}} ();\n            $_ = $2;\n            next;\n        }\n        if (defined $opt_arg{$1})\n        {\n            if (!$2)\n            {\n                $_ = shift @ARGV;\n                die (\"$0: -$1 option requires an argument.\\n\") if !$_;\n            }\n            &{$opt_arg{$1}} ($2 || $_);\n            return;\n        }\n        $_ =~ m/(..)(.*)/;\n        if (defined $opt_arg{$1})\n        {\n            if (!$2)\n            {\n                $_ = shift @ARGV;\n                die (\"$0: -$1 option requires an argument.\\n\") if !$_;\n            }\n            &{$opt_arg{$1}} ($2 || $_);\n            return;\n        }\n        if ($_)\n        {\n            die\n              qq($0: unrecognized option \"-$_\".  Use -x for a usage message.\\n);\n        }\n    }\n}\n\n# Process an equate argument (var=val).\nsub equate\n{\n    my ($var, $val) = /([^=]*)=(.*)/;\n    $script::ARG{$var} = $val;\n}\n\n# Define file signature protocol.\n'sig'->select($param::sigpro);\n\n# Cleanup after an interrupt.\n$SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {\n    $SIG{PIPE} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = 'IGNORE';\n    $SIG{HUP} = $SIG{INT} if !$main::_WIN32;\n    warn(\"\\n$0: killed\\n\");\n\n    # Call this first, to make sure that this processing\n    # occurs even if a child process does not die (and we\n    # hang on the wait).\n    sig::hash::END();\n    wait();\n    exit(1);\n};\n$SIG{HUP} = $SIG{INT} if !$main::_WIN32;\n\n# Cleanup after a broken pipe (someone piped our stdout?)\n$SIG{PIPE} = sub {\n    $SIG{PIPE} = $SIG{HUP} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = 'IGNORE';\n    warn(\"\\n$0: broken pipe\\n\");\n    sig::hash::END();\n    wait();\n    exit(1);\n};\n\nif ($param::depfile)\n{\n    open(main::DEPFILE, \">\" . $param::depfile)\n      || die (\"$0: couldn't open $param::depfile ($!)\\n\");\n}\n\n# If the supplied top-level Conscript file is not in the\n# current directory, then change to that directory.\n{\n    my ($vol, $dir, $file) =\n      File::Spec->splitpath(File::Spec->canonpath($param::topfile));\n    if ($vol || $dir)\n    {\n        my ($cd) = File::Spec->catpath($vol, $dir, undef);\n        chdir($cd) || die (\"$0: couldn't change to directory $cd ($!)\\n\");\n        $param::topfile = $file;\n    }\n}\n\n# Walk up the directory hierarchy looking for a Conscript file (if -t set).\nmy ($target_top);\nmy (@targetdir) = ();\nif ($param::traverse && !-f $param::topfile)\n{\n    my ($vol, $dirs, $file) = File::Spec->splitpath(cwd());\n    my (@dirs) = (File::Spec->splitdir($dirs), $file);\n    while (\n        !-f File::Spec->catpath($vol, File::Spec->catdir(@dirs),\n                                $param::topfile))\n    {\n        die (\"$0: unable to find $param::topfile.\\n\") if !@dirs;\n        unshift (@targetdir, pop (@dirs));\n    }\n    my ($cwd) = File::Spec->catpath($vol, File::Spec->catdir(@dirs), '');\n    print \"$0: Entering directory `$cwd'\\n\";\n    chdir($cwd);\n    @targets = map { File::Spec->catdir(@targetdir, $_) } @targets;\n}\n\n# Set up $dir::top and $dir::cwd, now that we are in the right directory.\ndir::init();\n\n#\nif (@targetdir)\n{\n    $target_top = $dir::top->lookupdir(File::Spec->catdir(@targetdir));\n}\n\n# Now handle override file.\npackage override;\nif ($param::overfile)\n{\n    my ($ov) = $param::overfile;\n    die qq($0: can\\'t read override file \"$ov\" ($!)\\n) if !-f $ov;    #'\n    do $ov;\n    if ($@)\n    {\n        chop($@);\n        die qq($0: errors in override file \"$ov\" ($@)\\n);\n    }\n}\n\n# Provide this to user to setup override patterns.\nsub Override\n{\n    my ($re, @env) = @_;\n    return if $param::overrides{$re};    # if identical, first will win.\n    $param::overrides = 1;\n    $param::overrides{$re} = \\@env;\n    push (@param::overrides, $re);\n}\n\npackage main;\n\nuse vars qw( %priority $errors );\n\n# Check script inclusion regexps\nmy $re;\nfor $re (@param::include)\n{\n    if (!defined eval { \"\" =~ /$re/ })\n    {\n        my ($err) = $@;\n        $err =~ s/in regexp at .*$//;\n        die (\"$0: error in regexp $err\");\n    }\n}\n\n# Read the top-level construct file and its included scripts.\ndoscripts($param::topfile);\n\n# Status priorities. This lets us aggregate status for directories\n# and print an appropriate message (at the top-level).\n%priority =\n  ('none' => 1, 'handled' => 2, 'built' => 3, 'unknown' => 4, 'errors' => 5);\n\n# If no targets were specified, supply default targets (if any).\n@targets = @param::default_targets if !@targets;\n\n$errors = 0;\n\n# Build the supplied target patterns.\nmy $tgt;\nfor $tgt (map($dir::top->lookup($_), @targets))\n{\n    if ($target_top && !$tgt->is_under($target_top))\n    {\n\n        # A -t option was used, and this target is not underneath\n        # the directory where we were invoked via -t.\n        # If the target is a directory and the -t directory\n        # is underneath it, then build the -t directory.\n        if (ref $tgt ne \"dir\" || !$target_top->is_under($tgt))\n        {\n            next;\n        }\n        $tgt = $target_top;\n    }\n    buildtoptarget($tgt);\n}\n\nexit 0 + ($errors != 0);\n\nsub buildtoptarget\n{\n    my ($tgt) = @_;\n    return if !$tgt;\n    my ($status) = buildtarget($tgt);\n    if ($status ne 'built')\n    {\n        my ($path) = $tgt->path;\n        if ($status eq \"errors\")\n        {\n            print qq($0: \"$path\" not remade because of errors.\\n);\n            $errors++;\n        }\n        elsif ($status eq \"handled\")\n        {\n            print qq($0: \"$path\" is up-to-date.\\n) if ($param::quiet < 2);\n        }\n        elsif ($status eq \"unknown\")\n        {\n\n            # cons error already reported.\n            $errors++;\n        }\n        elsif ($status eq \"none\")\n        {\n\n            # search for targets that may be linked to the given path.\n            my @linked = dir::linked_targets($tgt) if $target_top;\n            if (@linked)\n            {\n                my @names = map($_->path, @linked);\n                print \"Linked targets: @names\\n\" if ($param::quiet < 1);\n                map(buildtoptarget($_), @linked);\n            }\n            else\n            {\n                print qq($0: nothing to be built in \"$path\".\\n)\n                  if $param::build && ($param::quiet < 2);\n            }\n        }\n        else\n        {\n            print qq($0: don\\'t know how to construct \"$path\".\\n);    #'\n            $errors++;\n        }\n    }\n}\n\n# Build the supplied target directory or files. Return aggregated status.\nsub buildtarget\n{\n    my ($tgt) = @_;\n    if (ref($tgt) eq \"dir\")\n    {\n        my ($result)   = \"none\";\n        my ($priority) = $priority{$result};\n        if (exists $tgt->{member})\n        {\n            my ($members) = $tgt->{member};\n            my $entry;\n            for $entry (sort keys %$members)\n            {\n                next if $entry eq $dir::CURDIR || $entry eq $dir::UPDIR;\n                my ($tgt) = $members->{$entry};\n                next if ref($tgt) ne \"dir\" && !exists($tgt->{builder});\n                my ($stat) = buildtarget($members->{$entry});\n                my ($pri)  = $priority{$stat};\n                if ($pri > $priority)\n                {\n                    $priority = $pri;\n                    $result   = $stat;\n                }\n            }\n        }\n        return $result;\n    }\n    if ($param::depends)\n    {\n        my ($path) = $tgt->path;\n        if ($tgt->{builder})\n        {\n            my (@dep) = (@{$tgt->{dep}}, @{$tgt->{sources}});\n            my ($dep) = join (' ', map($_->path, @dep));\n            print(\"Target $path: $dep\\n\");\n        }\n        else\n        {\n            print(\"Target $path: not a derived file\\n\");\n        }\n    }\n    if ($param::build)\n    {\n        return build $tgt;\n    }\n    elsif ($param::pflag || $param::wflag || $param::aflag)\n    {\n        if ($tgt->{builder})\n        {\n            if ($param::wflag)\n            {\n                print qq(${\\$tgt->path}: $tgt->{script}\\n);\n            }\n            elsif ($param::pflag)\n            {\n                print qq(${\\$tgt->path}:\\n) if $param::aflag;\n                print qq(${\\$tgt->path}\\n)  if !$param::aflag;\n            }\n            if ($param::aflag)\n            {\n                $tgt->{builder}->action($tgt);\n            }\n        }\n    }\n    elsif ($param::rflag && $tgt->{builder})\n    {\n        my ($path) = $tgt->path;\n        if (-f $path)\n        {\n            if (unlink($path))\n            {\n                print(\"Removed $path\\n\") if ($param::quiet < 1);\n            }\n            else\n            {\n                warn(\"$0: couldn't remove $path\\n\");\n            }\n        }\n    }\n\n    return \"none\";\n}\n\npackage NameSpace;\n\n# Return a hash that maps the name of symbols in a namespace to an\n# array of refs for all types for which the name has a defined value.\n# A list of symbols may be specified; default is all symbols in the\n# name space.\nsub save\n{\n    my $package = shift;\n    my (%namerefs, $var, $type);\n    no strict 'refs';\n    @_ = keys %{$package . \"::\"} if !@_;\n    foreach $var (@_)\n    {\n        $namerefs{$var} = [];\n        my $fqvar = $package . \"::\" . $var;\n\n        # If the scalar for this variable name doesn't already\n        # exist, *foo{SCALAR} will autovivify the reference\n        # instead of returning undef, so unlike the other types,\n        # we have to dereference to find out if it exists.\n        push (@{$namerefs{$var}}, *{$fqvar}{SCALAR})\n          if defined ${*{$fqvar}{SCALAR}};\n        foreach $type (qw(ARRAY HASH CODE IO))\n        {\n            push (@{$namerefs{$var}}, *{$fqvar}{$type})\n              if defined *{$fqvar}{$type};\n        }\n    }\n    return \\%namerefs;\n}\n\n# Remove the specified symbols from the namespace.\n# Default is to remove all.\nsub remove\n{\n    my $package = shift;\n    my (%namerefs, $var);\n    no strict 'refs';\n    @_ = keys %{$package . \"::\"} if !@_;\n    foreach $var (@_)\n    {\n        delete ${$package . \"::\"}{$var};\n    }\n}\n\n# Restore values to symbols specified in a hash as returned\n# by NameSpace::save.\nsub restore\n{\n    my ($package, $namerefs) = @_;\n    my ($var, $ref);\n    no strict 'refs';\n    foreach $var (keys %$namerefs)\n    {\n        my $fqvar = $package . \"::\" . $var;\n        foreach $ref (@{$namerefs->{$var}})\n        {\n            *{$fqvar} = $ref;\n        }\n    }\n}\n\n# Support for \"building\" scripts, importing and exporting variables.\n# With the exception of the top-level routine here (invoked from the\n# main package by cons), these are all invoked by user scripts.\npackage script;\n\nuse vars qw( $ARG $caller_dir_path %special_var );\n\nBEGIN\n{\n\n    # We can't Export or Import the following variables because Perl always\n    # treats them as part of the \"main::\" package (see perlvar(1)).\n    %special_var = map { $_ => 1 } qw(ENV INC ARGV ARGVOUT SIG\n      STDIN STDOUT STDERR);\n}\n\n# This is called from main to interpret/run the top-level Construct\n# file, passed in as the single argument.\nsub main::doscripts\n{\n    my ($script) = @_;\n    Build($script);\n\n    # Now set up the includes/excludes (after the Construct file is read).\n    $param::include = join ('|', @param::include);\n\n    # Save the original variable names from the script package.\n    # These will stay intact, but any other \"script::\" variables\n    # defined in a Conscript file will get saved, deleted,\n    # and (when necessary) restored.\n    my (%orig_script_var) = map { $_ => 1 } keys %script::;\n    $caller_dir_path = undef;\n    my $cwd = Cwd::cwd();\n    my (@scripts) = pop (@priv::scripts);\n    while ($priv::self = shift (@scripts))\n    {\n        my ($path) = $priv::self->{script}->rsrcpath;\n        if (-f $path)\n        {\n            $dir::cwd = $priv::self->{script}->{dir};\n\n            # Handle chdir to the Conscript file directory, if necessary.\n            my ($vol, $dir, $file);\n            if ($param::conscript_chdir)\n            {\n                ($vol, $dir, $file) =\n                  File::Spec->splitpath(File::Spec->canonpath($path));\n                if ($vol ne '' || $dir ne '')\n                {\n                    $caller_dir_path = File::Spec->catpath($vol, $dir, undef);\n                    chdir($caller_dir_path)\n                      || die \"Could not chdir to $caller_dir_path: $!\\n\";\n                }\n            }\n            else\n            {\n                $file = $path;\n            }\n\n            # Actually process the Conscript file.\n            do $file;\n\n            # Save any variables defined by the Conscript file\n            # so we can restore them later, if needed;\n            # then delete them from the script:: namespace.\n            my (@del) = grep(!$orig_script_var{$_}, keys %script::);\n            if (@del)\n            {\n                $priv::self->{script}->{pkgvars} =\n                  NameSpace::save('script', @del);\n                NameSpace::remove('script', @del);\n            }\n            if ($caller_dir_path)\n            {\n                chdir($cwd);\n                $caller_dir_path = undef;\n            }\n            if ($@)\n            {\n                chomp($@);\n                my $err = ($@ =~ /\\n/ms) ? \":\\n$@\" : \" ($@)\";\n                print qq($0: error in file \"$path\"$err\\n);\n                $run::errors++;\n            }\n            else\n            {\n\n                # Only process subsidiary scripts if no errors in parent.\n                unshift (@scripts, @priv::scripts);\n            }\n            undef @priv::scripts;\n        }\n        else\n        {\n            my $where = '';\n            my $cref  = $priv::self->{script}->creator;\n            if (defined $cref)\n            {\n                my ($_foo, $script, $line, $sub) = @$cref;\n                $where = \" ($sub in $script, line $line)\";\n            }\n            warn qq(Ignoring missing script \"$path\"$where);\n        }\n    }\n    die (\"$0: script errors encountered: construction aborted\\n\")\n      if $run::errors;\n}\n\n# Return caller info about the method being invoked.\n# This is everything from the Perl \"caller\" builtin function,\n# including which Construct/Conscript file, line number,\n# subroutine name, etc.\nsub caller_info\n{\n    my ($lev) = 1;\n    my (@frame);\n    do\n    {\n        @frame = caller ++$lev;\n        if (defined($frame[3]) && $frame[3] eq '(eval)')\n        {\n            @frame = caller --$lev;\n            if ($caller_dir_path)\n            {\n                $frame[1] = File::Spec->catfile($caller_dir_path, $frame[1]);\n            }\n            return @frame;\n        }\n    } while ($frame[3]);\n    return;\n}\n\n# Link a directory to another. This simply means set up the *source*\n# for the directory to be the other directory.\nsub Link\n{\n    dir::link(@_);\n}\n\n# Add directories to the repository search path for files.\n# Strip our current directory from the list so Repository\n# (or -R options) can be used from within the repository.\nsub Repository\n{\n    my ($my_dir) = Cwd::cwd();\n    my $dir;\n    foreach $dir (@_)\n    {\n\n        # The following more direct call isn't available in\n        # Cwd.pm until some time after 5.003...\n        #\tmy($d) = Cwd::abs_path($dir);\n        chdir($dir);\n        my ($d) = Cwd::cwd();\n        chdir($my_dir);\n\n        #\n        next if !$d || !-d $d || $d eq $my_dir;\n\n        # We know we can get away with passing undef to lookupdir\n        # as the directory because $dir is an absolute path.\n        push (@param::rpath, dir::lookupdir(undef, $dir));\n        push @INC, $d;\n    }\n}\n\n# Return the list of Repository directories specified.\nsub Repository_List\n{\n    map($_->path, @param::rpath);\n}\n\n# Specify whether the .consign signature times in repository files are,\n# in fact, consistent with the times on the files themselves.\nsub Repository_Sig_Times_OK\n{\n    $param::rep_sig_times_ok = shift;\n}\n\nsub SourceSignature\n{\n    $param::sourcesig = [@_];\n}\n\n# Specify whether we should chdir to the containing directories\n# of Conscript files.\nsub Conscript_chdir\n{\n    $param::conscript_chdir = shift;\n}\n\n# Specify files/targets that must be present and built locally,\n# even if they exist already-built in a Repository.\nsub Local\n{\n    my (@files) = map($dir::cwd->lookupfile($_), @_);\n    map($_->local(1), @files);\n}\n\n# Export variables to any scripts invoked from this one.\nsub Export\n{\n    my (@illegal) = grep($special_var{$_}, @_);\n    if (@illegal)\n    {\n        die qq($0: cannot Export special Perl variables: @illegal\\n);\n    }\n    @{$priv::self->{exports}} = grep(!defined $special_var{$_}, @_);\n}\n\n# Import variables from the export list of the caller\n# of the current script.\nsub Import\n{\n    my (@illegal) = grep($special_var{$_}, @_);\n    if (@illegal)\n    {\n        die qq($0: cannot Import special Perl variables: @illegal\\n);\n    }\n    my ($parent)  = $priv::self->{parent};\n    my ($imports) = $priv::self->{imports};\n    @{$priv::self->{exports}} = keys %$imports;\n    my ($var);\n    foreach $var (grep(!defined $special_var{$_}, @_))\n    {\n        if (!exists $imports->{$var})\n        {\n            my ($path) = $parent->{script}->path;\n            die qq($0: variable \"$var\" not exported by file \"$path\"\\n);\n        }\n        if (!defined $imports->{$var})\n        {\n            my $path = $parent->{script}->path;\n            my $err  =\n              \"$0: variable \\\"$var\\\" exported but not \"\n              . \"defined by file \\\"$path\\\"\\n\";\n            die $err;\n        }\n        ${\"script::$var\"} = $imports->{$var};\n    }\n}\n\n# Build an inferior script. That is, arrange to read and execute\n# the specified script, passing to it any exported variables from\n# the current script.\nsub Build\n{\n    my (@files) = map($dir::cwd->lookupfile($_), @_);\n    my (%imports) = map { $_ => ${\"script::$_\"} } @{$priv::self->{exports}};\n    my $file;\n    for $file (@files)\n    {\n        next if $param::include && $file->path !~ /$param::include/o;\n        my ($self) = {\n                       'script'  => $file,\n                       'parent'  => $priv::self,\n                       'imports' => \\%imports\n                       };\n        bless $self;    # may want to bless into class of parent in future\n        push (@priv::scripts, $self);\n    }\n}\n\n# Set up regexps dependencies to ignore. Should only be called once.\nsub Ignore\n{\n    die (\"Ignore called more than once\\n\") if $param::ignore;\n    $param::ignore = join (\"|\", map(\"($_)\", @_)) if @_;\n}\n\n# Specification of default targets.\nsub Default\n{\n    push (@param::default_targets, map($dir::cwd->lookup($_)->path, @_));\n}\n\n# Local Help.  Should only be called once.\nsub Help\n{\n    if ($param::localhelp)\n    {\n        print \"@_\\n\";\n        exit 2;\n    }\n}\n\n# For windows platforms which use unix tool sets, the msvc defaults may\n# not be useful. Also, in the future, other platforms (Mac?) may have the\n# same problem.\nsub RuleSet\n{\n    my $style    = shift;\n    my @rulesets = sort keys %param::rulesets;\n    die \"Unknown style for rules: $style.\\n\"\n      . \"Supported rules are: (\"\n      . join (\" \", @rulesets) . \")\"\n      unless eval(join (\"||\", map(\"\\$style eq '$_'\", @rulesets)));\n    return @param::base, @{$param::rulesets{$style}};\n}\n\nsub DefaultRules\n{\n    @param::defaults = ();\n    push @param::defaults, @_;\n}\n\n# Return the build name(s) of a file or file list.\nsub FilePath\n{\n    wantarray \n      ? map($dir::cwd->lookupfile($_)->path, @_)\n      : $dir::cwd->lookupfile($_[0])->path;\n}\n\n# Return the build name(s) of a directory or directory list.\nsub DirPath\n{\n    wantarray \n      ? map($dir::cwd->lookupdir($_)->path, @_)\n      : $dir::cwd->lookupdir($_[0])->path;\n}\n\n# Split the search path provided into components. Look each up\n# relative to the current directory.\n# The usual path separator problems abound; for now we'll use :\nsub SplitPath\n{\n    my ($dirs) = @_;\n    if (ref($dirs) ne \"ARRAY\")\n    {\n        $dirs = [split (/$main::PATH_SEPARATOR/o, $dirs)];\n    }\n    map { DirPath($_) } @$dirs;\n}\n\n# Return true if the supplied path is available as a source file\n# or is buildable (by rules seen to-date in the build).\nsub ConsPath\n{\n    my ($path) = @_;\n    my ($file) = $dir::cwd->lookup($path);\n    return $file->accessible;\n}\n\n# Return the source path of the supplied path.\nsub SourcePath\n{\n    wantarray \n      ? map($dir::cwd->lookupfile($_)->rsrcpath, @_)\n      : $dir::cwd->lookupfile($_[0])->rsrcpath;\n}\n\n# Search up the tree for the specified cache directory, starting with\n# the current directory. Returns undef if not found, 1 otherwise.\n# If the directory is found, then caching is enabled. The directory\n# must be readable and writable. If the argument \"mixtargets\" is provided,\n# then targets may be mixed in the cache (two targets may share the same\n# cache file--not recommended).\nsub UseCache($@)\n{\n    my ($dir, @args) = @_;\n\n    # NOTE: it's important to process arguments here regardless of whether\n    # the cache is disabled temporarily, since the mixtargets option affects\n    # the salt for derived signatures.\n    for (@args)\n    {\n        if ($_ eq \"mixtargets\")\n        {\n\n            # When mixtargets is enabled, we salt the target signatures.\n            # This is done purely to avoid a scenario whereby if\n            # mixtargets is turned on or off after doing builds, and\n            # if cache synchronization with -cs is used, then\n            # cache files may be shared in the cache itself (linked\n            # under more than one name in the cache). This is not bad,\n            # per se, but simply would mean that a cache cleaning algorithm\n            # that looked for a link count of 1 would never find those\n            # particular files; they would always appear to be in use.\n            $param::salt       = 'M' . $param::salt;\n            $param::mixtargets = 1;\n        }\n        else\n        {\n            die qq($0: UseCache unrecognized option \"$_\"\\n);\n        }\n    }\n    if ($param::cachedisable)\n    {\n        warn(\"Note: caching disabled by -cd flag\\n\");\n        return 1;\n    }\n    my ($depth) = 15;\n    while ($depth-- && !-d $dir)\n    {\n        $dir = File::Spec->catdir($dir::UPDIR, $dir);\n    }\n    if (-d $dir)\n    {\n        $param::cache = $dir;\n        return 1;\n    }\n    return undef;\n}\n\n# Salt the signature generator. The salt (a number of string) is added\n# into the signature of each derived file. Changing the salt will\n# force recompilation of all derived files.\nsub Salt($)\n{\n\n    # We append the value, so that UseCache and Salt may be used\n    # in either order without changing the signature calculation.\n    $param::salt .= $_[0];\n}\n\n# Mark files (or directories) to not be removed before building.\nsub Precious\n{\n    map($_->{precious} = 1, map($dir::cwd->lookup($_), @_));\n}\n\n# These methods are callable from Conscript files, via a cons\n# object. Procs beginning with _ are intended for internal use.\npackage cons;\n\nuse vars qw( %envcache );\n\n# This is passed the name of the base environment to instantiate.\n# Overrides to the base environment may also be passed in\n# as key/value pairs.\nsub new\n{\n    my ($package) = shift;\n    my ($env) = {@param::defaults, @_};\n    @{$env->{_envcopy}} = %$env;    # Note: we never change PATH\n    $env->{_cwd} = $dir::cwd;       # Save directory of environment for\n    bless $env, $package;           # any deferred name interpretation.\n}\n\n# Clone an environment.\n# Note that the working directory will be the initial directory\n# of the original environment.\nsub clone\n{\n    my ($env) = shift;\n    my $clone = {@{$env->{_envcopy}}, @_};\n    @{$clone->{_envcopy}} = %$clone;    # Note: we never change PATH\n    $clone->{_cwd} = $env->{_cwd};\n    bless $clone, ref $env;\n}\n\n# Create a flattened hash representing the environment.\n# It also contains a copy of the PATH, so that the path\n# may be modified if it is converted back to a hash.\nsub copy\n{\n    my ($env) = shift;\n    (@{$env->{_envcopy}}, 'ENV' => {%{$env->{ENV}}}, @_);\n}\n\n# Resolve which environment to actually use for a given\n# target. This is just used for simple overrides.\nsub _resolve\n{\n    return $_[0] if !$param::overrides;\n    my ($env, $tgt) = @_;\n    my ($path) = $tgt->path;\n    my $re;\n    for $re (@param::overrides)\n    {\n        next if $path !~ /$re/;\n\n        # Found one. Return a combination of the original environment\n        # and the override.\n        my ($ovr) = $param::overrides{$re};\n        return $envcache{$env, $re} if $envcache{$env, $re};\n        my ($newenv) = {@{$env->{_envcopy}}, @$ovr};\n        @{$newenv->{_envcopy}} = %$env;\n        $newenv->{_cwd} = $env->{_cwd};\n        return $envcache{$env, $re} = bless $newenv, ref $env;\n    }\n    return $env;\n}\n\n# Substitute construction environment variables into a string.\n# Internal function/method.\nsub _subst\n{\n    my ($env, $str) = @_;\n    if (!defined $str)\n    {\n        return undef;\n    }\n    elsif (ref($str) eq \"ARRAY\")\n    {\n        return [map($env->_subst($_), @$str)];\n    }\n    else\n    {\n\n        # % expansion.  %% gets converted to % later, so expand any\n        # %keyword construction that doesn't have a % in front of it,\n        # modulo multiple %% pairs in between.\n        # In Perl 5.005 and later, we could actually do this in one regex\n        # using a conditional expression as follows,\n        #\twhile ($str =~ s/($pre)\\%(\\{)?([_a-zA-Z]\\w*)(?(2)\\})/\"$1\".\n        #                      $env->{$3}/ge) {}\n        # The following two-step approach is backwards-compatible\n        # to (at least) Perl5.003.\n        my $pre = '^|[^\\%](?:\\%\\%)*';\n        while (($str =~ s/($pre)\\%([_a-zA-Z]\\w*)/$1.($env->{$2}||'')/ge)\n               || ($str =~ s/($pre)\\%\\{([_a-zA-Z]\\w*)\\}/$1.($env->{$2}||'')/ge))\n        {\n        }\n        return $str;\n    }\n}\n\nsub AfterBuild\n{\n    my ($env)           = shift;\n    my ($perl_eval_str) = pop (@_);\n    my $file;\n    for $file (map($dir::cwd->lookup($_), @_))\n    {\n        $file->{after_build_func} = $perl_eval_str;\n\n    }\n}\n\nsub Install\n{\n    my ($env)    = shift;\n    my ($tgtdir) = $dir::cwd->lookupdir($env->_subst(shift));\n    my $file;\n    for $file (map($dir::cwd->lookupfile($env->_subst($_)), @_))\n    {\n        my ($tgt) = $tgtdir->lookupfile($file->{entry});\n        $tgt->bind(find build::install($env), $file);\n    }\n}\n\nsub InstallAs\n{\n    my $env     = shift;\n    my $tgt     = shift;\n    my $src     = shift;\n    my @sources = ();\n    my @targets = ();\n\n    if (ref $tgt)\n    {\n        die \"InstallAs: Source is a file and target is a list!\\n\"\n          if (!ref($src));\n        @sources = @$src;\n        @targets = @$tgt;\n    }\n    elsif (ref $src)\n    {\n        die \"InstallAs: Target is a file and source is a list!\\n\";\n    }\n    else\n    {\n        push @sources, $src;\n        push @targets, $tgt;\n    }\n\n    if ($#sources != $#targets)\n    {\n        my $tn = $#targets + 1;\n        my $sn = $#sources + 1;\n        die \"InstallAs: Source file list ($sn) and target file list ($tn) \"\n          . \"are inconsistent in length!\\n\";\n    }\n    else\n    {\n        foreach (0 .. $#sources)\n        {\n            my $tfile = $dir::cwd->lookupfile($env->_subst($targets[$_]));\n            my $sfile = $dir::cwd->lookupfile($env->_subst($sources[$_]));\n            $tfile->bind(find build::install($env), $sfile);\n        }\n    }\n}\n\n# Installation in a local build directory,\n# copying from the repository if it's already built there.\n# Functionally equivalent to:\n#\tInstall $env $dir, $file;\n#\tLocal \"$dir/$file\";\nsub Install_Local\n{\n    my ($env)    = shift;\n    my ($tgtdir) = $dir::cwd->lookupdir($env->_subst(shift));\n    my $file;\n    for $file (map($dir::cwd->lookupfile($env->_subst($_)), @_))\n    {\n        my ($tgt) = $tgtdir->lookupfile($file->{entry});\n        $tgt->bind(find build::install($env), $file);\n        $tgt->local(1);\n    }\n}\n\nsub Objects\n{\n    my ($env) = shift;\n    map($dir::cwd->relpath($_), $env->_Objects(@_));\n}\n\n# Called with multiple source file references (or object files).\n# Returns corresponding object files references.\nsub _Objects\n{\n    my ($env)    = shift;\n    my ($suffix) = $env->{SUFOBJ};\n    map($env->_Object($_, $_->{dir}->lookupfile($_->base_suf($suffix))),\n      map { ref $_ ? $_ : $dir::cwd->lookupfile($env->_subst($_)) }\n      grep(defined $_, @_));\n}\n\n# Called with an object and source reference.  If no object reference\n# is supplied, then the object file is determined implicitly from the\n# source file's extension. Sets up the appropriate rules for creating\n# the object from the source.  Returns the object reference.\nsub _Object\n{\n    my ($env, $src, $obj) = @_;\n    return $obj if $src eq $obj;    # don't need to build self from self.\n    my ($objenv) = $env->_resolve($obj);\n    my ($suffix) = $src->suffix;\n\n    my ($builder) = $env->{SUFMAP}{$suffix};\n\n    if ($builder)\n    {\n        $obj->bind((find $builder($objenv)), $src);\n    }\n    else\n    {\n        die (\"don't know how to construct ${\\$obj->path} from \"\n             . \"${\\$src->path}.\\n\");\n    }\n    $obj;\n}\n\nsub Program\n{\n    my ($env) = shift;\n    my ($tgt) =\n      $dir::cwd->lookupfile(\n                          file::addsuffix($env->_subst(shift), $env->{SUFEXE}));\n    my ($progenv) = $env->_resolve($tgt);\n    $tgt->bind(find build::command::link($progenv, $progenv->{LINKCOM}),\n               $env->_Objects(@_));\n}\n\nsub Module\n{\n    my ($env)    = shift;\n    my ($tgt)    = $dir::cwd->lookupfile($env->_subst(shift));\n    my ($modenv) = $env->_resolve($tgt);\n    my ($com)    = pop (@_);\n    $tgt->bind(find build::command::link($modenv, $com), $env->_Objects(@_));\n}\n\nsub LinkedModule\n{\n    my ($env)     = shift;\n    my ($tgt)     = $dir::cwd->lookupfile($env->_subst(shift));\n    my ($progenv) = $env->_resolve($tgt);\n    $tgt->bind(\n               find build::command::linkedmodule($progenv,\n                                                 $progenv->{LINKMODULECOM}),\n               $env->_Objects(@_));\n}\n\nsub Library\n{\n    my ($env) = shift;\n    my ($lib) =\n      $dir::cwd->lookupfile(\n                          file::addsuffix($env->_subst(shift), $env->{SUFLIB}));\n    my ($libenv) = $env->_resolve($lib);\n    $lib->bind(find build::command::library($libenv), $env->_Objects(@_));\n}\n\n# Simple derivation: you provide target, source(s), command.\n# Special variables substitute into the rule.\n# Target may be a reference, in which case it is taken\n# to be a multiple target (all targets built at once).\nsub Command\n{\n    my ($env)     = shift;\n    my ($tgt)     = $env->_subst(shift);\n    my ($builder) = find build::command::user($env, pop (@_), 'script');\n    my (@sources) = map($dir::cwd->lookupfile($env->_subst($_)), @_);\n    if (ref($tgt))\n    {\n\n        # A multi-target command.\n        my (@tgts) = map($dir::cwd->lookupfile($_), @$tgt);\n        die (\"empty target list in multi-target command\\n\") if !@tgts;\n        $env = $env->_resolve($tgts[0]);\n        my ($multi) = build::multiple->new($builder, \\@tgts);\n        for $tgt (@tgts)\n        {\n            $tgt->bind($multi, @sources);\n        }\n    }\n    else\n    {\n        $tgt = $dir::cwd->lookupfile($tgt);\n        $env = $env->_resolve($tgt);\n        $tgt->bind($builder, @sources);\n    }\n}\n\nsub Depends\n{\n    my ($env)  = shift;\n    my ($tgt)  = $env->_subst(shift);\n    my (@deps) = map($dir::cwd->lookup($env->_subst($_)), @_);\n    if (!ref($tgt))\n    {\n        $tgt = [$tgt];\n    }\n    my ($t);\n    foreach $t (map($dir::cwd->lookupfile($_), @$tgt))\n    {\n        push (@{$t->{dep}}, @deps);\n    }\n}\n\n# Setup a quick scanner for the specified input file, for the\n# associated environment. Any use of the input file will cause the\n# scanner to be invoked, once only. The scanner sees just one line at\n# a time of the file, and is expected to return a list of\n# dependencies.\nsub QuickScan\n{\n    my ($env, $code, $file, $path) = @_;\n    $dir::cwd->lookup($env->_subst($file))->{'srcscan', $env} =\n      find scan::quickscan($code, $env, $env->_subst($path));\n}\n\n# Generic builder module. Just a few default methods.  Every derivable\n# file must have a builder object of some sort attached.  Usually\n# builder objects are shared.\npackage build;\n\nuse vars qw( %builder );\n\n# Every builder must now have at least an associated environment,\n# so we can find its sigarray and calculate the proper signature.\nsub find\n{\n    my ($class, $env) = @_;\n    $builder{$env} || do\n    {\n        my $self = {env => $env};\n        $builder{$env} = bless $self, $class;\n      }\n}\n\n# Null signature for dynamic includes.\nsub includes { () }\n\n# Null signature for build script.\nsub scriptsig { () }\n\n# Not compatible with any other builder, by default.\nsub compatible { 0 }\n\n# Builder module for the Install command.\npackage build::install;\n\nuse vars qw( @ISA );\n\nBEGIN { @ISA = qw(build) }\n\n# Caching not supported for Install: generally install is trivial anyway,\n# and we don't want to clutter the cache.\nsub cachin  { undef }\nsub cachout { }\n\n# Do the installation.\nsub action\n{\n    my ($self, $tgt) = @_;\n    my ($src) = $tgt->{sources}[0];\n    main::showcom(\"Install ${\\$src->rpath} as ${\\$tgt->path}\")\n      if ($param::install && $param::quiet < 1);\n    return unless $param::build;\n    futil::install($src->rpath, $tgt);\n    return 1;\n}\n\n# Builder module for generic UNIX commands.\npackage build::command;\n\nuse vars qw( @ISA %com );\n\nBEGIN { @ISA = qw(build) }\n\nsub find\n{\n    my ($class, $env, $cmd, $package) = @_;\n    my ($act) = action::new($env, $cmd);\n    $package ||= '';\n    $com{$env, $act, $package} || do\n    {\n        my $self = {env => $env, act => $act, 'package' => $package};\n        $com{$env, $act, $package} = bless $self, $class;\n      }\n}\n\n# Default cache in function.\nsub cachin\n{\n    my ($self, $tgt, $sig) = @_;\n    if (cache::in($tgt, $sig))\n    {\n        if ($param::cachecom)\n        {\n            $self->{act}->show($self->{env}, $tgt);\n        }\n        else\n        {\n            printf(\"Retrieved %s from cache\\n\", $tgt->path)\n              if ($param::quiet < 1);\n        }\n        return 1;\n    }\n    return undef;\n}\n\n# Default cache out function.\nsub cachout\n{\n    my ($self, $tgt, $sig) = @_;\n    cache::out($tgt, $sig);\n}\n\n# Build the target using the previously specified commands.\nsub action\n{\n    my ($self, $tgt) = @_;\n    $self->{act}->execute($self->{env}, $tgt, $self->{'package'});\n}\n\n# Return script signature.\nsub scriptsig\n{\n    $_[0]->{act}->scriptsig;\n}\n\n# Create a linked module.\npackage build::command::link;\n\nuse vars qw( @ISA );\n\nBEGIN { @ISA = qw(build::command) }\n\n# Find an appropriate linker.\nsub find\n{\n    my ($class, $env, $command) = @_;\n    if (!exists $env->{_LDIRS})\n    {\n        my ($ldirs) = '';\n        my ($wd)    = $env->{_cwd};\n        my ($pdirs) = $env->{LIBPATH};\n        if (!defined $pdirs)\n        {\n            $pdirs = [];\n        }\n        elsif (ref($pdirs) ne 'ARRAY')\n        {\n            $pdirs = [split (/$main::PATH_SEPARATOR/o, $pdirs)];\n        }\n        my ($dir, $dpath);\n        for $dir (map($wd->lookupdir($env->_subst($_)), @$pdirs))\n        {\n            $dpath = $dir->path;\n\n            # Add the (presumably local) directory to the -L flags\n            # if we're not using repositories, the directory exists,\n            # or it's Linked to a source directory (that is, it *will*\n            # exist by the time the link occurs).\n            $ldirs .= \" \" . $env->{LIBDIRPREFIX} . $dpath . $env->{LIBDIRSUFFIX}\n              if !@param::rpath || -d $dpath || $dir->is_linked;\n            next if File::Spec->file_name_is_absolute($dpath);\n            if (@param::rpath)\n            {\n                my $d;\n                if ($dpath eq $dir::CURDIR)\n                {\n                    foreach $d (map($_->path, @param::rpath))\n                    {\n                        $ldirs .= \" \"\n                          . $env->{LIBDIRPREFIX} . $d\n                          . $env->{LIBDIRSUFFIX};\n                    }\n                }\n                else\n                {\n                    my ($rpath);\n                    foreach $d (map($_->path, @param::rpath))\n                    {\n                        $rpath = File::Spec->catfile($d, $dpath);\n                        $ldirs .= \" \"\n                          . $env->{LIBDIRPREFIX} . $rpath\n                          . $env->{LIBDIRSUFFIX}\n                          if -d $rpath;\n                    }\n                }\n            }\n        }\n        $env->{_LDIRS} = \"%($ldirs%)\";\n    }\n\n    # Introduce a new magic _LIBS symbol which allows to use the\n    # Unix-style -lNAME syntax for Win32 only. -lNAME will be replaced\n    # with %{PREFLIB}NAME%{SUFLIB}. <schwarze@isa.de> 1998-06-18\n\n    if ($main::_WIN32 && !exists $env->{_LIBS})\n    {\n        my $libs;\n        my $name;\n        for $name (split (' ', $env->_subst($env->{LIBS} || '')))\n        {\n            if ($name =~ /^-l(.*)/)\n            {\n                $name = \"$env->{PREFLIB}$1$env->{SUFLIB}\";\n            }\n            $libs .= ' ' . $name;\n        }\n        $env->{_LIBS} = $libs ? \"%($libs%)\" : '';\n    }\n    bless find build::command($env, $command);\n}\n\n# Called from file::build. Make sure any libraries needed by the\n# environment are built, and return the collected signatures\n# of the libraries in the path.\nsub includes\n{\n    return $_[0]->{'bsig'} if exists $_[0]->{'bsig'};\n    my ($self, $tgt) = @_;\n    my ($env) = $self->{env};\n    my ($ewd) = $env->{_cwd};\n    my $ldirs = $env->{LIBPATH};\n    if (!defined $ldirs)\n    {\n        $ldirs = [];\n    }\n    elsif (ref($ldirs) ne 'ARRAY')\n    {\n        $ldirs = [split (/$main::PATH_SEPARATOR/o, $ldirs)];\n    }\n    my @lpath = map($ewd->lookupdir($_), @$ldirs);\n    my (@sigs);\n    my (@names);\n\n    # Pass %LIBS symbol through %-substituition\n    # <schwarze@isa.de> 1998-06-18\n    @names = split (' ', $env->_subst($env->{LIBS} || ''));\n    my $name;\n    for $name (@names)\n    {\n        my ($lpath, @allnames);\n        if ($name =~ /^-l(.*)/)\n        {\n\n            # -l style names are looked up on LIBPATH, using all\n            # possible lib suffixes in the same search order the\n            # linker uses (according to SUFLIBS).\n            # Recognize new PREFLIB symbol, which should be 'lib' on\n            # Unix, and empty on Win32. TODO: What about shared\n            # library suffixes?  <schwarze@isa.de> 1998-05-13\n            @allnames =\n              map(\"$env->{PREFLIB}$1$_\", split (/:/, $env->{SUFLIBS}));\n            $lpath = \\@lpath;\n        }\n        else\n        {\n            @allnames = ($name);\n\n            # On Win32, all library names are looked up in LIBPATH\n            # <schwarze@isa.de> 1998-05-13\n            if ($main::_WIN32)\n            {\n                $lpath = [$dir::top, @lpath];\n            }\n            else\n            {\n                $lpath = [$dir::top];\n            }\n        }\n        my $dir;\n        DIR: for $dir (@$lpath)\n        {\n            my $n;\n            for $n (@allnames)\n            {\n                my ($lib) = $dir->lookup_accessible($n);\n                if ($lib)\n                {\n                    last DIR if $lib->ignore;\n                    if ((build $lib) eq 'errors')\n                    {\n                        $tgt->{status} = 'errors';\n                        return undef;\n                    }\n                    push (@sigs, 'sig'->signature($lib));\n                    last DIR;\n                }\n            }\n        }\n    }\n    $self->{'bsig'} = 'sig'->collect(@sigs);\n}\n\n# Always compatible with other such builders, so the user\n# can define a single program or module from multiple places.\nsub compatible\n{\n    my ($self, $other) = @_;\n    ref($other) eq \"build::command::link\";\n}\n\n# Link a program.\npackage build::command::linkedmodule;\n\nuse vars qw( @ISA );\n\nBEGIN { @ISA = qw(build::command) }\n\n# Always compatible with other such builders, so the user\n# can define a single linked module from multiple places.\nsub compatible\n{\n    my ($self, $other) = @_;\n    ref($other) eq \"build::command::linkedmodule\";\n}\n\n# Builder for a C module\npackage build::command::cc;\n\nuse vars qw( @ISA );\n\nBEGIN { @ISA = qw(build::command) }\n\nsub find\n{\n    $_[1]->{_cc} || do\n    {\n        my ($class, $env) = @_;\n        my ($cpppath) = $env->_subst($env->{CPPPATH});\n        my ($cscanner) = find scan::cpp($env->{_cwd}, $cpppath);\n        $env->{_IFLAGS} = \"%(\" . $cscanner->iflags($env) . \"%)\";\n        my ($self) = find build::command($env, $env->{CCCOM});\n        $self->{scanner} = $cscanner;\n        bless $env->{_cc} = $self;\n      }\n}\n\n# Invoke the associated\t C scanner to get signature of included files.\nsub includes\n{\n    my ($self, $tgt) = @_;\n    $self->{scanner}->includes($tgt, $tgt->{sources}[0]);\n}\n\n# Builder for a C++ module\npackage build::command::cxx;\n\nuse vars qw( @ISA );\n\nBEGIN { @ISA = qw(build::command) }\n\nsub find\n{\n    $_[1]->{_cxx} || do\n    {\n        my ($class, $env) = @_;\n        my ($cpppath) = $env->_subst($env->{CPPPATH});\n        my ($cscanner) = find scan::cpp($env->{_cwd}, $cpppath);\n        $env->{_IFLAGS} = \"%(\" . $cscanner->iflags($env) . \"%)\";\n        my ($self) = find build::command($env, $env->{CXXCOM});\n        $self->{scanner} = $cscanner;\n        bless $env->{_cxx} = $self;\n      }\n}\n\n# Invoke the associated\t C scanner to get signature of included files.\nsub includes\n{\n    my ($self, $tgt) = @_;\n    $self->{scanner}->includes($tgt, $tgt->{sources}[0]);\n}\n\n# Builder for a user command (cons::Command).  We assume that a user\n# command might be built and implement the appropriate dependencies on\n# the command itself (actually, just on the first word of the command\n# line).\npackage build::command::user;\n\nuse vars qw( @ISA );\n\nBEGIN { @ISA = qw(build::command) }\n\nsub includes\n{\n    my ($self, $tgt) = @_;\n    my ($sig) = '';\n\n    # Check for any quick scanners attached to source files.\n    my $dep;\n    for $dep (@{$tgt->{dep}}, @{$tgt->{sources}})\n    {\n        my ($scanner) = $dep->{'srcscan', $self->{env}};\n        if ($scanner)\n        {\n            $sig .= $scanner->includes($tgt, $dep);\n        }\n    }\n\n    # XXX Optimize this to not use ignored paths.\n    if (!exists $self->{_comsig})\n    {\n        my ($env) = $self->{env};\n        $self->{_comsig} = '';\n        my ($com, $dir);\n        com:\n        for $com ($self->{act}->commands)\n        {\n            my ($pdirs) = $env->{ENV}->{PATH};\n            if (!defined $pdirs)\n            {\n                $pdirs = [];\n            }\n            elsif (ref($pdirs) ne 'ARRAY')\n            {\n                $pdirs = [split (/$main::PATH_SEPARATOR/o, $pdirs)];\n            }\n            for $dir (map($dir::top->lookupdir($_), @$pdirs))\n            {\n                my ($prog) = $dir->lookup_accessible($com);\n                if ($prog)\n                {    # XXX Not checking execute permission.\n                    if ((build $prog) eq 'errors')\n                    {\n                        $tgt->{status} = 'errors';\n                        return $sig;\n                    }\n                    next com if $prog->ignore;\n                    $self->{_comsig} .= 'sig'->signature($prog);\n                    next com;\n                }\n            }\n        }\n    }\n\n    return $self->{_comsig} . $sig;\n}\n\n# Builder for a library module (archive).\n# We assume that a user command might be built and implement the\n# appropriate dependencies on the command itself.\npackage build::command::library;\n\nuse vars qw( @ISA );\n\nBEGIN { @ISA = qw(build::command) }\n\nsub find\n{\n    my ($class, $env) = @_;\n    bless find build::command($env, $env->{ARCOM});\n}\n\n# Always compatible with other library builders, so the user\n# can define a single library from multiple places.\nsub compatible\n{\n    my ($self, $other) = @_;\n    ref($other) eq \"build::command::library\";\n}\n\n# A multi-target builder.\n# This allows multiple targets to be associated with a single build\n# script, without forcing all the code to be aware of multiple targets.\npackage build::multiple;\n\nsub new\n{\n    my ($class, $builder, $tgts) = @_;\n    bless {'builder' => $builder, 'env' => $builder->{env}, 'tgts' => $tgts};\n}\n\nsub scriptsig\n{\n    my ($self, $tgt) = @_;\n    $self->{builder}->scriptsig($tgt);\n}\n\nsub includes\n{\n    my ($self, $tgt) = @_;\n    $self->{builder}->includes($tgt);\n}\n\nsub compatible\n{\n    my ($self, $tgt) = @_;\n    $self->{builder}->compatible($tgt);\n}\n\nsub cachin\n{\n    my ($self, $tgt, $sig) = @_;\n    $self->{builder}->cachin($tgt, $sig);\n}\n\nsub cachout\n{\n    my ($self, $tgt, $sig) = @_;\n    $self->{builder}->cachout($tgt, $sig);\n}\n\nsub action\n{\n    my ($self, $invoked_tgt) = @_;\n    return $self->{built} if exists $self->{built};\n\n    # Make sure all targets in the group are unlinked before building any.\n    my ($tgts) = $self->{tgts};\n    my $tgt;\n    for $tgt (@$tgts)\n    {\n        futil::mkdir($tgt->{dir});\n        unlink($tgt->path) if !$tgt->precious;\n    }\n\n    # Now do the action to build all the targets. For consistency\n    # we always call the action on the first target, just so that\n    # $> is deterministic.\n    if ($param::max_jobs <= 1)\n    {    # pcons\n        $self->{built} = $self->{builder}->action($tgts->[0]);\n    }\n    else\n    {\n        {\n\n            # action now is non-blocking, so we must kludge blocking for this\n            # explicit call\n            local ($file::child_queue) = {parent => $tgts->[0]};    # pcons\n            $self->{built} = $self->{builder}->action($tgts->[0]);  # pcons\n            &file::wait_on_all_children();                          # pcons\n        }\n    }\n\n    # Now \"build\" all the other targets (except for the one\n    # we were called with). This guarantees that the signature\n    # of each target is updated appropriately. We force the\n    # targets to be built even if they have been previously\n    # considered and found to be OK; the only effect this\n    # has is to make sure that signature files are updated\n    # correctly.\n    for $tgt (@$tgts)\n    {\n        if ($tgt ne $invoked_tgt)\n        {\n            delete $tgt->{status};\n            'sig'->invalidate($tgt);\n            build $tgt;\n        }\n    }\n\n    # Status of action.\n    $self->{built};\n}\n\npackage action;\n\nsub new\n{\n    my ($env, $act) = @_;\n    if (ref($act) eq 'CODE')\n    {\n        return action::perl->new($act);\n    }\n    else\n    {\n        return action::command->new($env, $act);\n    }\n}\n\npackage action::command;\n\nuse vars qw( @ISA %cmd %_varopts $_varletters );\n\nBEGIN\n{\n    @ISA = $main::_WIN32 ? 'action::command::win32' : 'action::command::unix';\n\n    # Internal hash for processing variable options.\n    # f: return file part\n    # d: return directory part\n    # F: return file part, but strip any suffix\n    # b: return full path, but strip any suffix (a.k.a. return basename)\n    # s: return only the suffix (or an empty string, if no suffix is there)\n    # a: return the absolute path to the file\n    # S: return the absolute path to a Linked source file\n    %_varopts = (\n        'f' => sub { return $_[0]->{entry}; },\n        'd' => sub { return $_[0]->{dir}->path; },\n        'F' => sub {\n            my $subst = $_[0]->{entry};\n            $subst =~ s/\\.[^\\.]+$//;\n            return $subst;\n        },\n        'b' => sub {\n            my $subst = $_[0]->path;\n            $subst =~ s/\\.[^\\.]+$//;\n            return $subst;\n        },\n        's' => sub {\n            my $subst = $_[0]->{entry};\n            $subst =~ m/(\\.[^\\.]+)$/;\n            return $1;\n        },\n        'a' => sub {\n            my $path = $_[0]->path;\n            if (!File::Spec->file_name_is_absolute($path))\n            {\n                $path = File::Spec->catfile(Cwd::cwd(), $path);\n            }\n            return $path;\n        },\n        'S' => sub {\n            my $path = $_[0]->srcpath;\n            if (!File::Spec->file_name_is_absolute($path))\n            {\n                my $cwd = File::Spec->canonpath(Cwd::cwd());\n                $path = File::Spec->catfile($cwd, $path);\n            }\n            return $path;\n        },\n        );\n\n    $_varletters = join ('', keys %_varopts);\n}\n\n# Internal routine for processing variable options.\n# Options are specified in hash in the BEGIN block above.\n# no option: return path to file (relative to top,\n# or absolute if it's outside)\nsub _variant\n{\n    my ($opt, $file) = @_;\n    $opt = '' if !defined $opt;\n    if (defined $_varopts{$opt})\n    {\n        return &{$_varopts{$opt}} ($file);\n    }\n    return $file->path;\n}\n\nsub new\n{\n    my ($class, $env, $cmd) = @_;\n    $cmd = $env->_subst($cmd);\n    $cmd{$env, $cmd} || do\n    {\n\n        # Remove unwanted bits from signature -- those bracketed by %( ... %)\n        my $sigs = $cmd;\n        my $sig  = '';\n        if (ref($sigs) eq 'ARRAY')\n        {\n\n            # This is an array of commands..\n            my $f;\n            foreach $f (@$sigs)\n            {\n                $sig .= _strip($f);\n            }\n        }\n        else\n        {\n            $sig = _strip($sigs);\n        }\n        my $self = {cmd => $cmd, cmdsig => 'sig'->cmdsig($sig)};\n        $cmd{$env, $cmd} = bless $self, $class;\n    };\n}\n\nsub _strip\n{\n    my $sig = shift;\n    $sig =~ s/^\\@\\s*//mg;\n    while ($sig =~ s/%\\(([^%]|%[^\\(])*?%\\)//g) { }\n    $sig;\n}\n\nsub scriptsig\n{\n    $_[0]->{cmdsig};\n}\n\n# Return an array of all the commands (first word on each line).\nsub commands\n{\n    my ($self) = @_;\n    my (@cmds) = ();\n    my $com;\n    my $cmd = $self->{'cmd'};\n    my @allcoms;\n\n    push @allcoms, ref $cmd ? @{$cmd} : split (/\\n/, $cmd);\n\n    for $com (@allcoms)\n    {\n        $com =~ s/^\\s*//;\n        $com =~ s/\\s.*//;\n        next if !$com;    # blank line\n        push @cmds, $com;\n    }\n    @cmds;\n}\n\n# For the signature of a basic command, we don't bother\n# including the command itself. This is not strictly correct,\n# and if we wanted to be rigorous, we might want to insist\n# that the command was checked for all the basic commands\n# like gcc, etc. For this reason we don't have an includes\n# method.\n\n# Call this to get the command line script: an array of\n# fully substituted commands.\nsub getcoms\n{\n    my ($self, $env, $tgt) = @_;\n    my (@coms);\n    my $com;\n    my @allcoms = ();\n    my $cmd     = $self->{'cmd'};\n\n    push @allcoms, ref $cmd ? @{$cmd} : split (/\\n/, $cmd);\n\n    for $com (@allcoms)\n    {\n        my (@src) = (undef, @{$tgt->{sources}});\n        my (@src1) = @src;\n\n        next if $com =~ /^\\s*$/;\n\n        # NOTE: we used to have a more elegant s//.../e solution\n        # for the items below, but this caused a bus error...\n\n        # Remove %( and %) -- those are only used to bracket parts\n        # of the command that we don't depend on.\n        $com =~ s/%[()]//g;\n\n        # Deal with %n, n=1,9 and variants.\n        while ($com =~ /%([1-9])(:([$_varletters]?))?/o)\n        {\n            my ($match) = $&;\n            my ($src)   = $src1[$1];\n            my ($subst) = _variant($3, $src1[$1]->rfile);\n            undef $src[$1];\n            $com =~ s/$match/$subst/;\n        }\n\n        # Deal with %0 aka %> and variants.\n        while ($com =~ /%[0>](:([$_varletters]?))?/o)\n        {\n            my ($match) = $&;\n            my ($subst) = _variant($2, $tgt);\n            $com =~ s/$match/$subst/;\n        }\n\n        # Deal with %< (all sources except %n's already used)\n        while ($com =~ /%<(:([$_varletters]?))?/o)\n        {\n            my ($match) = $&;\n            my @list = ();\n            foreach (@src)\n            {\n                push (@list, _variant($2, $_->rfile)) if $_;\n            }\n            my ($subst) = join (' ', @list);\n            $com =~ s/$match/$subst/;\n        }\n\n        # Deal with %[ %].\n        $com =~ s{%\\[(.*?)%\\]}{\n\t    my($func, @args) = grep { $_ ne '' } split(/\\s+/, $1);\n\t    die(\"$0: \\\"$func\\\" is not defined.\\n\")\n\t\tunless ($env->{$func});\n\t    &{$env->{$func}}(@args);\n\t}gex;\n\n        # Convert left-over %% into %.\n        $com =~ s/%%/%/g;\n\n        # White space cleanup. XXX NO WAY FOR USER TO HAVE QUOTED SPACES\n        $com = join (' ', split (' ', $com));\n        next if $com =~ /^:/ && $com !~ /^:\\S/;\n        push (@coms, $com);\n    }\n    @coms;\n}\n\n# Build the target using the previously specified commands.\nsub execute\n{\n    my ($self, $env, $tgt, $package) = @_;\n\n    if ($param::build)\n    {\n        futil::mkdir($tgt->{dir});\n        unlink($tgt->path) if !$tgt->precious;\n    }\n\n    # Set environment.\n    map(delete $ENV{$_}, keys %ENV);\n    %ENV = %{$env->{ENV}};\n\n    # Handle multi-line commands.\n\n    my @cmds = $self->getcoms($env, $tgt);    # pcons\n    if ($param::max_jobs > 1)\n    {    # pcons\n        if ($#cmds > 0)\n        {\n            for ($i = 0 ; $i < @cmds ; $i++)\n            {    #pcons -kn\n                $cmds[$i] = \"( \" . $cmds[$i] . \" )\";    #pcons -kn\n            }    #pcons -kn\n            @cmds = join (\" && \", @cmds);    # pcons\n        }    # pcons\n    }    # pcons\n\n    my $com;    # pcons\n    for $com (@cmds)\n    {           # pcons\n        if ($com !~ s/^\\@\\s*//)\n        {\n            main::showcom($com);\n        }\n        next if !$param::build;\n\n        if ($com =~ /^\\[perl\\]\\s*/)\n        {\n            my $perlcmd = $';\n            my $status;\n            {\n\n                # Restore the script package variables that were defined\n                # in the Conscript file that defined this [perl] build,\n                # so the code executes with the expected variables.\n                # Then actually execute (eval) the [perl] command to build\n                # the target, followed by cleaning up the name space\n                # by deleting the package variables we just restored.\n                my ($pkgvars) = $tgt->{conscript}->{pkgvars};\n                NameSpace::restore($package, $pkgvars) if $pkgvars;\n                $status = eval \"package $package; $perlcmd\";\n                NameSpace::remove($package, keys %$pkgvars) if $pkgvars;\n            }\n            if (!defined($status))\n            {\n                warn \"$0: *** Error during perl command eval: $@.\\n\";\n                return undef;\n            }\n            elsif ($status == 0)\n            {\n                warn \"$0: *** Perl command returned $status \"\n                  . \"(this indicates an error).\\n\";\n                return undef;\n            }\n            next;\n        }\n        if (!$self->do_command($com, $tgt->path, $tgt))\n        {\n            return undef;\n        }\n    }\n\n    # success.\n    return 1;\n}\n\nsub show\n{\n    my ($self, $env, $tgt) = @_;\n    my $com;\n    for $com ($self->getcoms($env, $tgt))\n    {\n        if ($com !~ /^\\@\\s*/)\n        {\n            main::showcom($com);\n        }\n    }\n}\n\npackage action::command::unix;\n\nsub do_command\n{\n    my ($class, $com, $path) = @_;    # cons\n    my ($class, $com, $path, $tgt) = @_;    # pcons\n\n    if ($param::max_jobs > 1)\n    {    # pcons\n        &file::wait_on_max_jobs();    # pcons\n    }    # pcons\n    my ($pid) = fork();\n    die (\"$0: unable to fork child process ($!)\\n\") if !defined $pid;\n    if (!$pid)\n    {\n\n        # This is the child.  We eval the command to suppress -w\n        # warnings about not reaching the statements afterwards.\n        eval 'exec($com)';\n        $com =~ s/\\s.*//;\n        die qq($0: failed to execute \"$com\" ($!). )\n          . qq(Is this an executable on path \"$ENV{PATH}\"?\\n);\n    }\n    if ($param::max_jobs <= 1)\n    {    # pcons\n        for (; ;)\n        {\n            do { } until wait() == $pid;\n            my ($b0, $b1) = ($? & 0xFF, $? >> 8);\n\n            # Don't actually see 0177 on stopped process; is this necessary?\n            next if $b0 == 0177;    # process stopped; we can wait.\n            if ($b0)\n            {\n                my ($core, $sig) = ($b0 & 0200, $b0 & 0177);\n                my ($coremsg) = $core ? \"; core dumped\" : \"\";\n                $com =~ s/\\s.*//;\n                my $err =\n                  \"$0: *** \\[$path\\] $com terminated by signal \"\n                  . \"$sig$coremsg\\n\";\n                warn $err;\n                return undef;\n            }\n            if ($b1)\n            {\n                warn qq($0: *** [$path] Error $b1\\n);  # trying to be like make.\n                return undef;\n            }\n            last;\n        }\n    }\n    else\n    {    # pcons\n        $file::child_queue->{$pid}->{com} = $com;    # pcons\n        $file::child_queue->{$pid}->{tgt} = $tgt;    # pcons\n\n    }    # pcons\n\n    return 1;\n}\n\npackage action::command::win32;\n\nsub do_command\n{\n    my ($class, $com, $path, $tgt) = @_;\n    system($com);\n    if ($?)\n    {\n        my ($b0, $b1) = ($? & 0xFF, $? >> 8);\n        my $err = $b1 || $?;\n        my $warn = qq($0: *** [$path] Error $err);\n        $warn .= \" (executable not found in path?)\" if $b1 == 0xFF;\n        warn \"$warn\\n\";\n        return undef;\n    }\n    return 1;\n}\n\npackage action::perl;\n\n# THIS IS AN EXPERIMENTAL PACKAGE.  It's entirely possible that the\n# interface may change as this gets completed, so use at your own risk.\n#\n# There are (at least) two issues that need to be solved before blessing\n# this as a real, fully-supported feature:\n#\n#   --\tWe need to calculate a signature value for a Perl code ref, in\n#\torder to rebuild the target if there's a change to the Perl code\n#\tused to generate it.\n#\n#\tThis is not straightforward.  A B::Deparse package exists that\n#\tdecompiles a coderef into text.  It's reportedly not completely\n#\treliable for closures; it misses which variables are global, and\n#\tthe values of private lexicals.  Nevertheless, it'd probably\n#\tbe perfect for our purposes, except that it wasn't added until\n#\tsome time between Perl 5.00502 and 5.00554, and doesn't seem to\n#\treally work until Perl 5.6.0, so by relying on it, we'd lose\n#\tsupport for Perl versions back to 5.003*.\n#\n#   --\tIdeally, a code ref should be able to use something like\n#\t$env->_subst to fetch values from the construction environment\n#\tto modify its behavior without having to cut-and-paste code.\n#\t(Actually, since we pass the environment to the executed code\n#\tref, there's no reason you can't do this with the code as it\n#\tstands today.)  But this REALLY complicates the signature\n#\tcalculation, because now the actual signature would depend not\n#\tjust on the code contents, but on the construction variables (or\n#\tmaybe just the environment).\n#\n# A potentially valid workaround would be to use the contents of the\n# Conscript file in which the code reference is defined as the code\n# ref's signature.  This has the drawback of causing a recompilation of\n# the target file even in response to unrelated changes in the Conscript\n# file, but it would ensure correct builds without having to solve the\n# messy issues of generating a signature directly from a code ref.\n#\n# Nevertheless, this seemed a useful enough skeleton of a feature that\n# it made sense to release it in hopes that some practical experience\n# will encourage someone to figure out how to solve the signature\n# issues.  Or maybe we'll discover these aren't big issues in practice\n# and end up blessing it as is.\n\nuse vars qw( %code );\n\nsub new\n{\n    my ($class, $cref) = @_;\n    $code{$cref} || do\n    {\n        my $sig = '';\n\n        # Generating a code signature using B::Deparse doesn't really\n        # work for us until Perl 5.6.0.  Here's the code in case\n        # someone wants to use it.\n        #use B::Deparse;\n        #my $deparse = B::Deparse->new();\n        #my $body = $deparse->coderef2text($cref);\n        #$sig = $body;\t# should be an MD5 sig\n        my ($self) = {cref => $cref, crefsig => $sig};\n        $code{$cref} = bless $self, $class;\n      }\n}\n\nsub scriptsig\n{\n    $_[0]->{crefsig};\n}\n\nsub execute\n{\n    my ($self, $env, $tgt) = @_;\n    if ($param::build)\n    {\n        futil::mkdir($tgt->{dir});\n        unlink($tgt->path) if !$tgt->precious;\n        my ($cref) = $self->{cref};\n        &$cref($env, $tgt->path, map($_->rpath, @{$tgt->{sources}}));\n    }\n}\n\nsub commands\n{\n    return ();\n}\n\n# Generic scanning module.\npackage scan;\n\n# Returns the signature of files included by the specified files on\n# behalf of the associated target. Any errors in handling the included\n# files are propagated to the target on whose behalf this processing\n# is being done. Signatures are cached for each unique file/scanner\n# pair.\nsub includes\n{\n    my ($self, $tgt, @files) = @_;\n    my (%files, $file);\n    my ($inc) = $self->{includes} || ($self->{includes} = {});\n    while ($file = pop @files)\n    {\n        next if exists $files{$file};\n        if ($inc->{$file})\n        {\n            push (@files, @{$inc->{$file}});\n            $files{$file} = 'sig'->signature($file->rfile);\n        }\n        else\n        {\n            if ((build $file) eq 'errors')\n            {\n                $tgt->{status} = 'errors';    # tgt inherits build status\n                return ();\n            }\n            $files{$file} = 'sig'->signature($file->rfile);\n            my (@includes) = $self->scan($file);\n            $inc->{$file} = \\@includes;\n            push (@files, @includes);\n        }\n    }\n    'sig'->collect(sort values %files);\n}\n\n# A simple scanner. This is used by the QuickScanfunction, to setup\n# one-time target and environment-independent scanning for a source\n# file. Only used for commands run by the Command method.\npackage scan::quickscan;\n\nuse vars qw( @ISA %scanner );\n\nBEGIN { @ISA = qw(scan) }\n\nsub find\n{\n    my ($class, $code, $env, $pdirs) = @_;\n    if (!defined $pdirs)\n    {\n        $pdirs = [];\n    }\n    elsif (ref($pdirs) ne 'ARRAY')\n    {\n        $pdirs = [split (/$main::PATH_SEPARATOR/o, $pdirs)];\n    }\n    my (@path) = map { $dir::cwd->lookupdir($_) } @$pdirs;\n    my ($spath) = \"@path\";\n    $scanner{$code, $env, $spath} || do\n    {\n        my ($self) = {code => $code, env => $env, path => \\@path};\n        $scanner{$code, $env, $spath} = bless $self;\n      }\n}\n\n# Scan the specified file for included file names.\nsub scan\n{\n    my ($self, $file) = @_;\n    my ($code) = $self->{code};\n    my (@includes);\n\n    # File should have been built by now. If not, we'll ignore it.\n    return () unless open(SCAN, $file->rpath);\n    while (<SCAN>)\n    {\n        push (@includes, grep($_ ne '', &$code));\n    }\n    close(SCAN);\n    my ($wd) = $file->{dir};\n    my (@files);\n    my $name;\n    for $name (@includes)\n    {\n        my $dir;\n        for $dir ($file->{dir}, @{$self->{path}})\n        {\n            my ($include) = $dir->lookup_accessible($name);\n            if ($include)\n            {\n                push (@files, $include) unless $include->ignore;\n                last;\n            }\n        }\n    }\n    @files;\n}\n\n# CPP (C preprocessor) scanning module\npackage scan::cpp;\n\nuse vars qw( @ISA %scanner );\n\nBEGIN { @ISA = qw(scan) }\n\n# For this constructor, provide the include path argument (colon\n# separated). Each path is taken relative to the provided directory.\n\n# Note: a particular scanning object is assumed to always return the\n# same result for the same input. This is why the search path is a\n# parameter to the constructor for a CPP scanning object. We go to\n# some pains to make sure that we return the same scanner object\n# for the same path: otherwise we will unecessarily scan files.\nsub find\n{\n    my ($class, $dir, $pdirs) = @_;\n    if (!defined $pdirs)\n    {\n        $pdirs = [];\n    }\n    elsif (ref($pdirs) ne 'ARRAY')\n    {\n        $pdirs = [split (/$main::PATH_SEPARATOR/o, $pdirs)];\n    }\n    my @path = map($dir->lookupdir($_), @$pdirs);\n    my ($spath) = \"@path\";\n    $scanner{$spath} || do\n    {\n        my ($self) = {'path' => \\@path};\n        $scanner{$spath} = bless $self;\n      }\n}\n\n# Scan the specified file for include lines.\nsub scan\n{\n    my ($self, $file) = @_;\n    my ($angles, $quotes);\n\n    if (exists $file->{angles})\n    {\n        $angles = $file->{angles};\n        $quotes = $file->{quotes};\n    }\n    else\n    {\n        my (@anglenames, @quotenames);\n        return () unless open(SCAN, $file->rpath);\n        while (<SCAN>)\n        {\n            next unless /^\\s*#/;\n            if (/^\\s*#\\s*include\\s*([<\"])(.*?)[>\"]/)\n            {\n                if ($1 eq \"<\")\n                {\n                    push (@anglenames, $2);\n                }\n                else\n                {\n                    push (@quotenames, $2);\n                }\n            }\n        }\n        close(SCAN);\n        $angles = $file->{angles} = \\@anglenames;\n        $quotes = $file->{quotes} = \\@quotenames;\n    }\n\n    my (@shortpath) = @{$self->{path}};             # path for <> style includes\n    my (@longpath)  = ($file->{dir}, @shortpath);   # path for \"\" style includes\n\n    my (@includes);\n\n    my $name;\n    for $name (@$angles)\n    {\n        my $dir;\n        for $dir (@shortpath)\n        {\n            my ($include) = $dir->lookup_accessible($name);\n            if ($include)\n            {\n                push (@includes, $include) unless $include->ignore;\n                last;\n            }\n        }\n    }\n\n    for $name (@$quotes)\n    {\n        my $dir;\n        for $dir (@longpath)\n        {\n            my ($include) = $dir->lookup_accessible($name);\n            if ($include)\n            {\n                push (@includes, $include) unless $include->ignore;\n                last;\n            }\n        }\n    }\n\n    return @includes;\n}\n\n# Return the include flags that would be used for a C Compile.\nsub iflags\n{\n    my ($self, $env) = @_;\n    my ($iflags) = '';\n    my ($dir, $dpath);\n    for $dir (@{$self->{path}})\n    {\n        $dpath = $dir->path;\n\n        # Add the (presumably local) directory to the -I flags\n        # if we're not using repositories, the directory exists,\n        # or it's Linked to a source directory (that is, it *will*\n        # exist by the time the compilation occurs).\n        $iflags .= \" \" . $env->{INCDIRPREFIX} . $dpath . $env->{INCDIRSUFFIX}\n          if !@param::rpath || -d $dpath || $dir->is_linked;\n        next if File::Spec->file_name_is_absolute($dpath);\n        if (@param::rpath)\n        {\n            my $d;\n            if ($dpath eq $dir::CURDIR)\n            {\n                foreach $d (map($_->path, @param::rpath))\n                {\n                    $iflags .=\n                      \" \" . $env->{INCDIRPREFIX} . $d . $env->{INCDIRSUFFIX};\n                }\n            }\n            else\n            {\n                my ($rpath);\n                foreach $d (map($_->path, @param::rpath))\n                {\n                    $rpath = File::Spec->catfile($d, $dpath);\n                    $iflags .=\n                      \" \" . $env->{INCDIRPREFIX} . $rpath . $env->{INCDIRSUFFIX}\n                      if -d $rpath;\n                }\n            }\n        }\n    }\n    $iflags;\n}\n\npackage File::Spec;\n\nuse vars qw( $_SEP $_MATCH_SEP $_MATCH_VOL );\n\n# Cons is migrating to using File::Spec for portable path name\n# manipulation.  This is the right long-term direction, but there are\n# some problems with making the transition:\n#\n#\tFor multi-volume support, we need to use newer interfaces\n#\t(splitpath, catpath, splitdir) that are only available in\n#\tFile::Spec 0.8.\n#\n#\tFile::Spec 0.8 doesn't work with Perl 5.00[34] due to\n#\tregular expression incompatibilities (use of \\z).\n#\n#\tForcing people to use a new version of a module is painful\n#\tbecause (in the workplace) their administrators aren't\n#\talways going to agree to install it everywhere.\n#\n# As a middle ground, we provide our own versions of all the File::Spec\n# methods we use, supporting both UNIX and Win32.  Some of these methods\n# are home brew, some are cut-and-pasted from the real File::Spec methods.\n# This way, we're not reinventing the whole wheel, at least.\n#\n# We can (and should) get rid of this class whenever 5.00[34] and\n# versions of File::Spec prior to 0.9 (?) have faded sufficiently.\n# We also may need to revisit whenever someone first wants to use\n# Cons on some platform other than UNIX or Win32.\n\nBEGIN\n{\n    if ($main::_WIN32)\n    {\n        $_SEP       = '\\\\';\n        $_MATCH_SEP = \"[\\Q/$_SEP\\E]\";\n        $_MATCH_VOL = \"([a-z]:)?$_MATCH_SEP\";\n    }\n    else\n    {\n        $_SEP       = '/';\n        $_MATCH_SEP = \"\\Q$_SEP\\E\";\n        $_MATCH_VOL = $_MATCH_SEP;\n    }\n}\n\nsub canonpath\n{\n    my ($self, $path) = @_;\n    if ($main::_WIN32)\n    {\n        $path =~ s/^([a-z]:)/\\u$1/s;\n        $path =~ s|/|\\\\|g;\n        $path =~ s|([^\\\\])\\\\+|$1\\\\|g;                       # xx////xx  -> xx/xx\n        $path =~ s|(\\\\\\.)+\\\\|\\\\|g;                          # xx/././xx -> xx/xx\n        $path =~ s|^(\\.\\\\)+||s unless $path eq \".\\\\\";       # ./xx      -> xx\n        $path =~ s|\\\\$|| unless $path =~ m#^([A-Z]:)?\\\\$#s; # xx/       -> xx\n    }\n    else\n    {\n        $path =~ s|/+|/|g unless ($^O eq 'cygwin');    # xx////xx  -> xx/xx\n        $path =~ s|(/\\.)+/|/|g;                        # xx/././xx -> xx/xx\n        $path =~ s|^(\\./)+||s unless $path eq \"./\";    # ./xx      -> xx\n        $path =~ s|^/(\\.\\./)+|/|s;                     # /../../xx -> xx\n        $path =~ s|/$|| unless $path eq \"/\";           # xx/       -> xx\n    }\n    return $path;\n}\n\nsub catdir\n{\n    my $self = shift;\n    my @args = @_;\n    foreach (@args)\n    {\n\n        # append a slash to each argument unless it has one there\n        $_ .= $_SEP if $_ eq '' || substr($_, -1) ne $_SEP;\n    }\n    return $self->canonpath(join ('', @args));\n}\n\nsub catfile\n{\n    my $self = shift;\n    my $file = pop @_;\n    return $file unless @_;\n    my $dir = $self->catdir(@_);\n    $dir .= $_SEP unless substr($dir, -1) eq $_SEP;\n    $file = '' if !defined($file);\n    return $dir . $file;\n}\n\nsub catpath\n{\n    my $path = $_[1] . $_[0]->catfile(@_[2 .. $#_]);\n    $path =~ s/(.)$_MATCH_SEP*$/$1/;\n    $path;\n}\n\nsub curdir\n{\n    '.';\n}\n\nsub file_name_is_absolute\n{\n    my ($self, $file) = @_;\n    return scalar($file =~ m{^$_MATCH_VOL}is);\n}\n\nsub splitdir\n{\n    my @dirs = split (/$_MATCH_SEP/, $_[1], -1);\n    push (@dirs, '') if $dirs[$#dirs];\n    @dirs;\n}\n\nsub splitpath\n{\n    my ($self, $path) = @_;\n    my $vol = '';\n    my $sep = $_SEP;\n    if ($main::_WIN32)\n    {\n        if ($path =~ s#^([A-Za-z]:|(?:\\\\\\\\|//)[^\\\\/]+[\\\\/][^\\\\/]+)([\\\\/])#$2#)\n        {\n            $vol = $1;\n            $sep = $2;\n        }\n    }\n    my (@path) = split (/$_MATCH_SEP/, $path, -1);\n    my $file = pop @path;\n    my $dirs = join ($sep, @path, '');\n    return ($vol, $dirs, $file);\n}\n\nsub updir\n{\n    '..';\n}\n\nsub case_tolerant\n{\n    return $main::_WIN32;\n}\n\n# Directory and file handling. Files/dirs are represented by objects.\n# Other packages are welcome to add component-specific attributes.\npackage dir;\n\nuse vars qw( $SEPARATOR $MATCH_SEPARATOR $CURDIR $UPDIR\n  $cwd_vol %root $top $cwd );\n\nBEGIN\n{\n\n    # A portable way of determing our directory separator.\n    $SEPARATOR = File::Spec->catdir('', '');\n\n    # A fast-path regular expression to match a directory separator\n    # anywhere in a path name.\n    if ($SEPARATOR eq '/')\n    {\n        $MATCH_SEPARATOR = \"\\Q$SEPARATOR\\E\";\n    }\n    else\n    {\n        $MATCH_SEPARATOR = \"[\\Q/$SEPARATOR\\E]\";\n    }\n\n    # Cache these values so we don't have to make a method call\n    # every time we need them.\n    $CURDIR  = File::Spec->curdir;    # '.' on UNIX\n    $UPDIR   = File::Spec->updir;     # '..' on UNIX\n                                      #\n    $cwd_vol = '';\n}\n\n# Annotate a node (file or directory) with info about the\n# method that created it.\nsub creator\n{\n    my ($self, @frame) = @_;\n    $self->{'creator'} = \\@frame if @frame;\n    $self->{'creator'};\n}\n\n# Handle a file|dir type exception.  We only die if we find we were\n# invoked by something in a Conscript/Construct file, because\n# dependencies created directly by Cons' analysis shouldn't cause\n# an error.\nsub _type_exception\n{\n    my ($e) = @_;\n    my ($line, $sub);\n    (undef, undef, $line, $sub) = script::caller_info;\n    if (defined $line)\n    {\n        my $err =\n          \"\\\"${\\$e->path}\\\" already in use as a \"\n          . ref($e)\n          . \" before $sub on line $line\";\n        if ($e->{'creator'})\n        {\n            my $script;\n            (undef, $script, $line, $sub) = @{$e->{'creator'}};\n            $err =\n              \"\\t\" . $err . \",\\n\\t\\tdefined by $sub in $script, line $line\";\n        }\n        $err .= \"\\n\";\n        die $err;\n    }\n}\n\n# This wraps up all the common File::Spec logic that we use for parsing\n# directory separators in a path and turning it into individual\n# subdirectories that we must create, as well as creation of root\n# nodes for any new file system volumes we find.  File::Spec doesn't have\n# intuitively obvious interfaces, so this is heavily commented.\n#\n# Note:  This is NOT an object or class method;\n# it's just a utility subroutine.\nsub _parse_path\n{\n    my ($dir, $path) = @_;\n\n    # Convert all slashes to the native directory separator.\n    # This allows Construct files to always be written with good\n    # old POSIX path names, regardless of what we're running on.\n    $path = File::Spec->canonpath($path);\n\n    # File::Spec doesn't understand the Cons convention of\n    # an initial '#' for top-relative files.  Strip it.\n    my ($toprel) = $path =~ s/^#//;\n\n    # Let File::Spec do the heavy lifting of parsing the path name.\n    my ($vol, $directories, $entry) = File::Spec->splitpath($path);\n    my @dirs = File::Spec->splitdir($directories);\n\n    # If there was a file entry on the end of the path, then the\n    # last @dirs element is '' and we don't need it.  If there\n    # wasn't a file entry on the end (File::Spec->splitpath() knew\n    # the last component was a directory), then the last @dirs\n    # element becomes the entry we want to look up.\n    my ($e) = pop @dirs;\n    $entry = $e if $entry eq '';\n\n    if (File::Spec->file_name_is_absolute($path))\n    {\n\n        # An absolute path name.  If no volume was supplied,\n        # use the volume of our current directory.\n        $vol = $cwd_vol if $vol eq '';\n        $vol = uc($vol) if File::Spec->case_tolerant;\n        if (!defined $root{$vol})\n        {\n\n            # This is our first time looking up a path name\n            # on this volume, so create a root node for it.\n            # (On UNIX systems, $vol is always '', so '/'\n            # always maps to the $root{''} node.)\n            $root{$vol} = {\n                            path     => $vol . $SEPARATOR,\n                            prefix   => $vol . $SEPARATOR,\n                            srcpath  => $vol . $SEPARATOR,\n                            'exists' => 1\n                            };\n            $root{$vol}->{'srcdir'} = $root{$vol};\n            bless $root{$vol};\n        }\n\n        # We're at the top, so strip the blank entry from the front of\n        # the @dirs array since the initial '/' it represents will now\n        # be supplied by the root node we return.\n        shift @dirs;\n        $dir = $root{$vol};\n    }\n    elsif ($toprel)\n    {\n        $dir = $dir::top;\n    }\n    ($dir, \\@dirs, $entry);\n}\n\n# Common subroutine for creating directory nodes.\nsub _create_dirs\n{\n    my ($dir, @dirs) = @_;\n    my $e;\n    foreach $e (@dirs)\n    {\n        my $d = $dir->{member}->{$e};\n        if (!defined $d)\n        {\n            bless $d = {'entry' => $e, 'dir' => $dir,}, 'dir';\n            $d->creator(script::caller_info);\n            $d->{member}->{$dir::CURDIR} = $d;\n            $d->{member}->{$dir::UPDIR}  = $dir;\n            $dir->{member}->{$e}         = $d;\n        }\n        elsif (ref $d eq 'entry')\n        {\n            bless $d, 'dir';\n            $d->{member}->{$dir::CURDIR} = $d;\n            $d->{member}->{$dir::UPDIR}  = $dir;\n        }\n        elsif (ref $d eq 'file')\n        {\n\n            # This clause is to supply backwards compatibility,\n            # with a warning, for anyone that's used FilePath\n            # to refer to a directory.  After people have using\n            # 1.8 have had time to adjust (sometime in version\n            # 1.9 or later), we should remove this entire clause.\n            my ($script, $line, $sub);\n            (undef, $script, $line, $sub) = @{$d->{'creator'}};\n            if ($sub eq 'script::FilePath')\n            {\n                print STDERR\n                  \"$0:  Warning:  $sub used to refer to a directory\\n\"\n                  . \"\\tat line $line of $script.  Use DirPath instead.\\n\";\n                bless $d, 'dir';\n            }\n            else\n            {\n                _type_exception($d);\n            }\n        }\n        elsif (ref $d ne 'dir')\n        {\n            _type_exception($d);\n        }\n        $dir = $d;\n    }\n    $dir;\n}\n\n# Look up an entry in a directory.  This method is for when we don't\n# care whether a file or directory is returned, so if the entry already\n# exists, it will simply be returned.  If not, we create it as a\n# generic \"entry\" which can be later turned into a file or directory\n# by a more-specific lookup.\n#\n# The file entry may be specified as relative, absolute (starts with /),\n# or top-relative (starts with #).\nsub lookup\n{\n    my ($dir, $entry) = @_;\n\n    if ($entry !~ m#$MATCH_SEPARATOR#o)\n    {\n\n        # Fast path: simple entry name in a known directory.\n        if ($entry =~ s/^#//)\n        {\n\n            # Top-relative names begin with #.\n            $dir = $dir::top;\n        }\n        elsif ($entry =~ s/^!//)\n        {\n            $dir = $dir::cwd->srcdir;\n        }\n    }\n    else\n    {\n        my $dirsref;\n        ($dir, $dirsref, $entry) = _parse_path($dir, $entry);\n        $dir = _create_dirs($dir, @$dirsref) if @$dirsref;\n        return if !defined $dir;\n        return $dir if $entry eq '';\n    }\n\n    my $e = $dir->{member}->{$entry};\n    if (!defined $e)\n    {\n        bless $e = {'entry' => $entry, 'dir' => $dir,}, 'entry';\n        $e->creator(script::caller_info);\n        $dir->{member}->{$entry} = $e;\n    }\n\n    $e;\n}\n\n# Look up a file entry in a directory.\n#\n# The file entry may be specified as relative, absolute (starts with /),\n# or top-relative (starts with #).\nsub lookupfile\n{\n    my ($dir, $entry) = @_;\n\n    if ($entry !~ m#$MATCH_SEPARATOR#o)\n    {\n\n        # Fast path: simple entry name in a known directory.\n        if ($entry =~ s/^#//)\n        {\n\n            # Top-relative names begin with #.\n            $dir = $dir::top;\n        }\n        elsif ($entry =~ s/^!//)\n        {\n            $dir = $dir::cwd->srcdir;\n        }\n    }\n    else\n    {\n        my $dirsref;\n        ($dir, $dirsref, $entry) = _parse_path($dir, $entry);\n        $dir = _create_dirs($dir, @$dirsref) if @$dirsref;\n        return undef if $entry eq '';\n    }\n\n    my $f = $dir->{member}->{$entry};\n    if (!defined $f)\n    {\n        bless $f = {'entry' => $entry, 'dir' => $dir,}, 'file';\n        $f->creator(script::caller_info);\n        $dir->{member}->{$entry} = $f;\n    }\n    elsif (ref $f eq 'entry')\n    {\n        bless $f, 'file';\n    }\n    elsif (ref $f ne 'file')\n    {\n        _type_exception($f);\n    }\n\n    $f;\n}\n\n# Look up a (sub-)directory entry in a directory.\n#\n# The (sub-)directory entry may be specified as relative, absolute\n# (starts with /), or top-relative (starts with #).\nsub lookupdir\n{\n    my ($dir, $entry) = @_;\n\n    my $dirsref;\n    if ($entry !~ m#$MATCH_SEPARATOR#o)\n    {\n\n        # Fast path: simple entry name in a known directory.\n        if ($entry =~ s/^#//)\n        {\n\n            # Top-relative names begin with #.\n            $dir = $dir::top;\n        }\n        elsif ($entry =~ s/^!//)\n        {\n            $dir = $dir::cwd->srcdir;\n        }\n    }\n    else\n    {\n        ($dir, $dirsref, $entry) = _parse_path($dir, $entry);\n    }\n    push (@$dirsref, $entry) if $entry ne '';\n    _create_dirs($dir, @$dirsref);\n}\n\n# Look up a file entry and return it if it's accessible.\nsub lookup_accessible\n{\n    my $file = $_[0]->lookupfile($_[1]);\n    return ($file && $file->accessible) ? $file : undef;\n}\n\n# Return the parent directory without doing a lookupdir,\n# which would create a parent if it doesn't already exist.\n# A return value of undef (! $dir->up) indicates a root directory.\nsub up\n{\n    $_[0]->{member}->{$dir::UPDIR};\n}\n\n# Return whether this is an entry somewhere underneath the\n# specified directory.\nsub is_under\n{\n    my $dir = $_[0];\n    while ($dir)\n    {\n        return 1 if $_[1] == $dir;\n        $dir = $dir->up;\n    }\n    return undef;\n}\n\n# Return the relative path from the calling directory ($_[1])\n# to the object.  If the object is not under the directory, then\n# we return it as a top-relative or absolute path name.\nsub relpath\n{\n    my ($dir, $obj) = @_;\n    my @dirs;\n    my $o = $obj;\n    while ($o)\n    {\n        if ($dir == $o)\n        {\n            if (@dirs < 2)\n            {\n                return $dirs[0] || '';\n            }\n            else\n            {\n                return File::Spec->catdir(@dirs);\n            }\n        }\n        unshift (@dirs, $o->{entry});\n        $o = $o->up;\n    }\n\n    # The object was not underneath the specified directory.\n    # Use the node's cached path, which is either top-relative\n    # (in which case we append '#' to the beginning) or\n    # absolute.\n    my $p = $obj->path;\n    $p = '#' . $p if !File::Spec->file_name_is_absolute($p);\n    return $p;\n}\n\n# Return the path of the directory (file paths implemented\n# separately, below).\nsub path\n{\n    $_[0]->{path} || ($_[0]->{path} = $_[0]->{dir}->prefix . $_[0]->{entry});\n}\n\n# Return the pathname as a prefix to be concatenated with an entry.\nsub prefix\n{\n    return $_[0]->{prefix} if exists $_[0]->{prefix};\n    $_[0]->{prefix} = $_[0]->path . $SEPARATOR;\n}\n\n# Return the related source path prefix.\nsub srcprefix\n{\n    return $_[0]->{srcprefix} if exists $_[0]->{srcprefix};\n    my ($srcdir) = $_[0]->srcdir;\n    $srcdir->{srcprefix} =\n      $srcdir eq $_[0] ? $srcdir->prefix : $srcdir->srcprefix;\n}\n\n# Return the related source directory.\nsub srcdir\n{\n    $_[0]->{'srcdir'}\n      || ($_[0]->{'srcdir'} = $_[0]->{dir}->srcdir->lookupdir($_[0]->{entry}));\n}\n\n# Return if the directory is linked to a separate source directory.\nsub is_linked\n{\n    return $_[0]->{is_linked} if defined $_[0]->{is_linked};\n    $_[0]->{is_linked} = $_[0]->path ne $_[0]->srcdir->path;\n}\n\nsub link\n{\n    my (@paths)  = @_;\n    my ($srcdir) = $dir::cwd->lookupdir(pop @paths)->srcdir;\n    map($dir::cwd->lookupdir($_)->{'srcdir'} = $srcdir, @paths);\n\n    # make a reverse lookup for the link.\n    $srcdir->{links} = [] if !$srcdir->{links};\n    push @{$srcdir->{links}}, @paths;\n}\n\nuse vars qw( @tail );    # TODO: Why global ????\n\nsub linked_targets\n{\n    my $tgt     = shift;\n    my @targets = ();\n    my $dir;\n    if (ref $tgt eq 'dir')\n    {\n        $dir = $tgt;\n    }\n    else\n    {\n        push @tail, $tgt;\n        $dir = $tgt->{dir};\n    }\n    while ($dir)\n    {\n        if (defined $dir->{links} && @{$dir->{links}})\n        {\n            push @targets, map(File::Spec->catdir($_, @tail), @{$dir->{links}});\n\n            #print STDERR \"Found Link: ${\\$dir->path} -> @{\\$dir->{links}}\\n\";\n        }\n        unshift @tail, $dir->{entry};\n        $dir = $dir->up;\n    }\n\n    return map($dir::top->lookupdir($_), @targets);\n}\n\nsub accessible\n{\n    my $path = $_[0]->path;\n    my $err  =\n      \"$0: you have attempted to use path \\\"$path\\\" both as a file \"\n      . \"and as a directory!\\n\";\n    die $err;\n}\n\nsub init\n{\n    my $path = Cwd::cwd();\n\n    # We know we can get away with passing undef to lookupdir\n    # as the directory because $dir is an absolute path.\n    $top = lookupdir(undef, $path);\n    $top->{'path'} = $top->{srcpath} = $dir::CURDIR;\n    $top->{'prefix'} = '';\n    $top->{'srcdir'} = $top;\n\n    $cwd = $top;\n\n    ($cwd_vol, undef, undef) = File::Spec->splitpath($path);\n    $cwd_vol = '' if !defined $cwd_vol;\n    $cwd_vol = uc($cwd_vol) if File::Spec->case_tolerant;\n}\n\npackage file;\n\nuse vars qw( @ISA $level );\n\nBEGIN { @ISA = qw(dir); $level = 0 }\n\n# Return the pathname of the file.\n# Define this separately from dir::path because we don't want to\n# cache all file pathnames (just directory pathnames).\nsub path\n{\n    $_[0]->{dir}->prefix . $_[0]->{entry};\n}\n\n# Return the related source file path.\nsub srcpath\n{\n    $_[0]->{dir}->srcprefix . $_[0]->{entry};\n}\n\n# Return if the file is (should be) linked to a separate source file.\nsub is_linked\n{\n    $_[0]->{dir}->is_linked;\n}\n\n# Repository file search.  If the local file exists, that wins.\n# Otherwise, return the first existing same-named file under a\n# Repository directory.  If there isn't anything with the same name\n# under a Repository directory, return the local file name anyway\n# so that some higher layer can try to construct it.\nsub rfile\n{\n    return $_[0]->{rfile} if exists $_[0]->{rfile};\n    my ($self)  = @_;\n    my ($rfile) = $self;\n    if (@param::rpath)\n    {\n        my ($path) = $self->path;\n        if (!File::Spec->file_name_is_absolute($path) && !-f $path)\n        {\n            my ($dir);\n            foreach $dir (@param::rpath)\n            {\n                my ($t) = $dir->prefix . $path;\n                if (-f $t)\n                {\n                    $rfile = $_[0]->lookupfile($t);\n                    $rfile->{'lfile'} = $self;\n                    last;\n                }\n            }\n        }\n    }\n    $self->{rfile} = $rfile;\n}\n\n# Returns the local file for a repository file;\n# returns self if it's already a local file.\nsub lfile\n{\n    $_[0]->{'lfile'} || $_[0];\n}\n\n# returns the \"precious\" status of this file.\nsub precious\n{\n    return $_[0]->{precious};\n}\n\n# \"Erase\" reference to a Repository file,\n# making this a completely local file object\n# by pointing it back to itself.\nsub no_rfile\n{\n    $_[0]->{'rfile'} = $_[0];\n}\n\n# Return a path to the first existing file under a Repository directory,\n# implicitly returning the current file's path if there isn't a\n# same-named file under a Repository directory.\nsub rpath\n{\n    $_[0]->{rpath} || ($_[0]->{rpath} = $_[0]->rfile->path);\n}\n\n# Return a path to the first linked srcpath file under a Repositoy\n# directory, implicitly returning the current file's srcpath if there\n# isn't a same-named file under a Repository directory.\nsub rsrcpath\n{\n    return $_[0]->{rsrcpath} if exists $_[0]->{rsrcpath};\n    my ($self) = @_;\n    my ($path) = $self->{rsrcpath} = $self->srcpath;\n    if (@param::rpath && !File::Spec->file_name_is_absolute($path) && !-f $path)\n    {\n        my ($dir);\n        foreach $dir (@param::rpath)\n        {\n            my ($t) = $dir->prefix . $path;\n            if (-f $t)\n            {\n                $self->{rsrcpath} = $t;\n                last;\n            }\n        }\n    }\n    $self->{rsrcpath};\n}\n\n# Return if a same-named file source file exists.\n# This handles the interaction of Link and Repository logic.\n# As a side effect, it will link a source file from its Linked\n# directory (preferably local, but maybe in a repository)\n# into a build directory from its proper Linked directory.\nsub source_exists\n{\n    return $_[0]->{source_exists} if defined $_[0]->{source_exists};\n    my ($self) = @_;\n    my ($path) = $self->path;\n    my ($mtime, $ctime) = (stat($path))[9, 10];\n    if ($self->is_linked)\n    {\n\n        # Linked directory, local logic.\n        my ($srcpath) = $self->srcpath;\n        my ($src_mtime, $src_ctime) = (stat($srcpath))[9, 10];\n        if ($src_mtime)\n        {\n            if (!$mtime || $src_mtime != $mtime || $src_ctime != $ctime)\n            {\n                futil::install($srcpath, $self);\n            }\n            return $self->{source_exists} = 1;\n        }\n\n        # Linked directory, repository logic.\n        if (@param::rpath)\n        {\n            if ($self != $self->rfile)\n            {\n                return $self->{source_exists} = 1;\n            }\n            my ($rsrcpath) = $self->rsrcpath;\n            if ($path ne $rsrcpath)\n            {\n                my ($rsrc_mtime, $rsrc_ctime) = (stat($rsrcpath))[9, 10];\n                if ($rsrc_mtime)\n                {\n                    if (!$mtime\n                        || $rsrc_mtime != $mtime\n                        || $rsrc_ctime != $ctime)\n                    {\n                        futil::install($rsrcpath, $self);\n                    }\n                    return $self->{source_exists} = 1;\n                }\n            }\n        }\n\n        # There was no source file in any Linked directory\n        # under any Repository.  If there's one in the local\n        # build directory, it no longer belongs there.\n        if ($mtime)\n        {\n            unlink($path) || die (\"$0: couldn't unlink $path ($!)\\n\");\n        }\n        return $self->{source_exists} = '';\n    }\n    else\n    {\n        if ($mtime)\n        {\n            return $self->{source_exists} = 1;\n        }\n        if (@param::rpath && $self != $self->rfile)\n        {\n            return $self->{source_exists} = 1;\n        }\n        return $self->{source_exists} = '';\n    }\n}\n\n# Return if a same-named derived file exists under a Repository directory.\nsub derived_exists\n{\n    $_[0]->{derived_exists}\n      || ($_[0]->{derived_exists} = ($_[0] != $_[0]->rfile));\n}\n\n# Return if this file is somewhere under a Repository directory.\nsub is_on_rpath\n{\n    defined $_[0]->{'lfile'};\n}\n\nsub local\n{\n    my ($self, $arg) = @_;\n    if (defined $arg)\n    {\n        $self->{'local'} = $arg;\n    }\n    $self->{'local'};\n}\n\n# Return the entry name of the specified file with the specified\n# suffix appended.  Leave it untouched if the suffix is already there.\n# Differs from the addsuffix function, below, in that this strips\n# the existing suffix (if any) before appending the desired one.\nsub base_suf\n{\n    my ($entry) = $_[0]->{entry};\n    if ($entry !~ m/$_[1]$/)\n    {\n        $entry =~ s/\\.[^\\.]*$//;\n        $entry .= $_[1];\n    }\n    $entry;\n}\n\n# Return the suffix of the file; everything including and to the\n# right of the last dot.\nsub suffix\n{\n    my @pieces = split (/\\./, $_[0]->{entry});\n    my $suffix = pop (@pieces);\n    return \".$suffix\";\n}\n\n# Called as a simple function file::addsuffix(name, suffix)\nsub addsuffix\n{\n    my ($name, $suffix) = @_;\n\n    if ($suffix && substr($name, -length($suffix)) ne $suffix)\n    {\n        return $name .= $suffix;\n    }\n    $name;\n}\n\n# Return true if the file is (or will be) accessible.\n# That is, if we can build it, or if it is already present.\nsub accessible\n{\n    (exists $_[0]->{builder}) || ($_[0]->source_exists);\n}\n\n# Return true if the file should be ignored for the purpose\n# of computing dependency information (should not be considered\n# as a dependency and, further, should not be scanned for\n# dependencies).\nsub ignore\n{\n    return 0 if !$param::ignore;\n    return $_[0]->{ignore} if exists $_[0]->{ignore};\n    $_[0]->{ignore} = $_[0]->path =~ /$param::ignore/o;\n}\n\n# Build the file, if necessary.\nsub build\n{\n    return $_[0]->{status} if $_[0]->{status};\n    my ($status) = &file::_build;\n    if ($_[0]->{after_build_func})\n    {\n\n        #print STDERR \"DEBUG: after_build_func=$_[0]->{after_build_func}\\n\";\n        my ($pkgvars) = $_[0]->{conscript}->{pkgvars};\n        NameSpace::restore('script', $pkgvars) if $pkgvars;\n        eval(\"package script; \" . $_[0]->{after_build_func});\n        print \"Error running AfterBuild for ${\\$_[0]->path}: $@\\n\" if ($@);\n        NameSpace::remove('script', keys %$pkgvars) if $pkgvars;\n    }\n    return $status;\n}\n\nsub _build\n{\n    my @args = @_;\n\n    if ($param::max_jobs <= 1)\n    {    # pcons\n        my ($self) = @args;\n        print main::DEPFILE $self->path, \"\\n\" if $param::depfile;\n        print((' ' x $level), \"Checking \", $self->path, \"\\n\")\n          if $param::depends;\n        if (!exists $self->{builder})\n        {\n\n            # We don't know how to build the file. This is OK, if\n            # the file is present as a source file, under either the\n            # local tree or a Repository.\n            if ($self->source_exists)\n            {\n                return $self->{status} = 'handled';\n            }\n            else\n            {\n                my ($name) = $self->path;\n                print(\"$0: don't know how to construct \\\"$name\\\"\\n\");\n                exit(1) unless $param::kflag;\n                return $self->{status} = 'errors';    # xxx used to be 'unknown'\n            }\n        }\n\n        # An associated build object exists, so we know how to build\n        # the file. We first compute the signature of the file, based\n        # on its dependendencies, then only rebuild the file if the\n        # signature has changed.\n        my ($builder) = $self->{builder};\n        $level += 2;\n\n        my (@deps) = (@{$self->{dep}}, @{$self->{sources}});\n        my ($rdeps) = \\@deps;\n\n        if ($param::random)\n        {\n\n            # If requested, build in a random order, instead of the\n            # order that the dependencies were listed.\n            my (%rdeps);\n            map { $rdeps{$_, '*' x int(rand 10)} = $_ } @deps;\n            $rdeps = [values(%rdeps)];\n        }\n\n        $self->{status} = '';\n\n        my $dep;\n        for $dep (@$rdeps)\n        {\n            if ((build $dep) eq 'errors')\n            {\n\n                # Propagate dependent errors to target.\n                # but try to build all dependents regardless of errors.\n                $self->{status} = 'errors';\n            }\n        }\n\n        # If any dependents had errors, then we abort.\n        if ($self->{status} eq 'errors')\n        {\n            $level -= 2;\n            return 'errors';\n        }\n\n        # Compute the final signature of the file, based on\n        # the static dependencies (in order), dynamic dependencies,\n        # output path name, and (non-substituted) build script.\n        my ($sig) =\n          'sig'->collect(map('sig'->signature($_->rfile), @deps),\n                         $builder->includes($self), $builder->scriptsig);\n\n        # May have gotten errors during computation of dynamic\n        # dependency signature, above.\n        $level -= 2;\n        return 'errors' if $self->{status} eq 'errors';\n\n        if (@param::rpath && $self->derived_exists)\n        {\n\n            # There is no local file of this name, but there is one\n            # under a Repository directory.\n\n            if ('sig'->current($self->rfile, $sig))\n            {\n\n                # The Repository copy is current (its signature matches\n                # our calculated signature).\n                if ($self->local)\n                {\n\n                    # ...but they want a local copy, so provide it.\n                    main::showcom(\"Local copy of ${\\$self->path} from \"\n                                  . \"${\\$self->rpath}\");\n                    futil::install($self->rpath, $self);\n                    'sig'->bsig($self, $sig);\n                }\n                return $self->{status} = 'handled';\n            }\n\n            # The signatures don't match, implicitly because something\n            # on which we depend exists locally.  Get rid of the reference\n            # to the Repository file; we'll build this (and anything that\n            # depends on it) locally.\n            $self->no_rfile;\n        }\n\n        # Then check for currency.\n        if (!'sig'->current($self, $sig))\n        {\n\n            # We have to build/derive the file.\n            print((' ' x $level), \"Rebuilding \", $self->path,\n                  \": out of date.\\n\")\n              if $param::depends;\n\n            # First check to see if the built file is cached.\n            if ($builder->cachin($self, $sig))\n            {\n                'sig'->bsig($self, $sig);\n                return $self->{status} = 'built';\n            }\n            elsif ($builder->action($self))\n            {\n                $builder->cachout($self, $sig);\n                'sig'->bsig($self, $sig);\n                return $self->{status} = 'built';\n            }\n            else\n            {\n                die (\"$0: errors constructing ${\\$self->path}\\n\")\n                  unless $param::kflag;\n                return $self->{status} = 'errors';\n            }\n        }\n        else\n        {\n\n            # Push this out to the cache if we've been asked to (-C option).\n            # Don't normally do this because it slows us down.\n            # In a fully built system, no accesses to the cache directory\n            # are required to check any files. This is a win if cache is\n            # heavily shared. Enabling this option puts the directory in the\n            # loop. Useful only when you wish to recreate a cache from a build.\n            if ($param::cachesync)\n            {\n                $builder->cachout($self, $sig);\n                'sig'->bsig($self, $sig);\n            }\n            return $self->{status} = 'handled';\n        }\n    }\n    else\n    {    # pcons\n        my ($tgt) = @args;    # pcons\n        local ($file::child_queue) = {parent => $tgt};    # pcons\n        _pbuild($tgt);                                    # pcons\n        wait_on_all_children();                           # pcons\n        return $tgt->{status};                            # pcons\n    }\n}\n\n########################################\n# pcons only BEGIN\n#\n\nsub pbuild\n{\n    $_[0]->{status} || &file::_pbuild;\n}\n\nsub _pbuild\n{\n    my ($self) = @_;\n    $self->{status} = '';    # tgl\n    print main::DEPFILE $self->path, \"\\n\" if param::depfile;\n    print((' ' x $level), $self->path, \"\\n\") if $param::depends;\n    if (!exists $self->{builder})\n    {\n\n        # We don't know how to build the file. This is OK, if\n        # the file is present as a source file, under either the\n        # local tree or a Repository.\n        if ($self->source_exists)\n        {\n            return $self->{status} = 'handled';\n        }\n        else\n        {\n            my ($name) = $self->path;\n            print(\"$0: don't know how to construct \\\"$name\\\"\\n\");\n            exit(1) unless $param::kflag;\n            return $self->{status} = 'errors';    # xxx used to be 'unknown'\n        }\n    }\n\n    # An associated build object exists, so we know how to build\n    # the file. We first compute the signature of the file, based\n    # on its dependendencies, then only rebuild the file if the\n    # signature has changed.\n    my ($builder) = $self->{'builder'};\n    $level += 2;\n\n    my (@deps) = (@{$self->{dep}}, @{$self->{sources}});\n    my ($rdeps) = \\@deps;\n\n    if ($param::random)\n    {\n\n        # If requested, build in a random order, instead of the\n        # order that the dependencies were listed.\n        my (%rdeps);\n\n        # FIX\tmap { $rdeps{$_,'*' x int(rand(0,10))} = $_ } @deps;\n        map { $rdeps{$_, '*' x int(rand(10))} = $_ } @deps;\n        $rdeps = [values(%rdeps)];\n    }\n\n    $self->{status} = '';\n\n    my $sig;\n    {\n\n        # print \"in \", $self->path, \"\\n\";\n        local ($file::child_queue) = {parent => $self};\n        for my $dep (@$rdeps)\n        {\n            if ((pbuild $dep) eq 'errors')\n            {\n\n                # Propagate dependent errors to target.\n                # but try to build all dependents regardless of errors.\n                $self->{status} = 'errors';\n            }\n        }\n        wait_on_all_children();\n\n    }\n\n    # If any dependents had errors, then we abort.\n    if ($self->{'status'} eq 'errors')\n    {\n        $level -= 2;\n        return 'errors';\n    }\n\n    # Compute the final signature of the file, based on\n    # the static dependencies (in order), dynamic dependencies,\n    # output path name, and (non-substituted) build script.\n\n    #    my($sig) = $self->{'sign'} = sig->collect(map(sig->signature($_->rfile), @deps),\n    #\t\t\t    $builder->includes($self),\n    ## FIX\t\t\t    $builder->script);\n    #\t\t\t    $builder->scriptsig);\n\n    my ($sig) = 'sig'->collect(\n        map('sig'->signature($_->rfile), @deps),    # from cons-2.3.0\n        $builder->includes($self),                  # from cons-2.3.0\n        $builder->scriptsig\n        );    # from cons-2.3.0\n    $self->{sign} = $sig;\n\n    # May have gotten errors during computation of dynamic\n    # dependency signature, above.\n    $level -= 2;\n    return 'errors' if $self->{status} eq 'errors';\n\n    if (@param::rpath && $self->derived_exists)\n    {\n\n        # There is no local file of this name, but there is one\n        # under a Repository directory.\n\n        if ('sig'->current($self->rfile, $sig))\n        {\n\n            # The Repository copy is current (its signature matches\n            # our calculated signature).\n            if ($self->local)\n            {\n\n                # ...but they want a local copy, so provide it.\n                main::showcom(\n                         \"Local copy of ${\\$self->path} from ${\\$self->rpath}\");\n                futil::install($self->rpath, $self);\n\n                #'sig'->set($self, $sig);\n                'sig'->bsig($self, $sig);    # pcons\n            }\n            return $self->{status} = 'handled';\n        }\n\n        # The signatures don't match, implicitly because something\n        # on which we depend exists locally.  Get rid of the reference\n        # to the Repository file; we'll build this (and anything that\n        # depends on it) locally.\n        $self->no_rfile;\n    }\n\n    # Then check for currency.\n    if (!'sig'->current($self, $sig))\n    {\n\n        # We have to build/derive the file.\n        # First check to see if the built file is cached.\n        if ($builder->cachin($self, $sig))\n        {\n\n            #'sig'->set($self, $sig);\n            'sig'->bsig($self, $sig);    # pcons\n            return $self->{status} = 'built';\n\n            # action no longer blocks (for most actions), so this returns\n            # immediately, before any  commands are actually run.  The\n            # signature and return status should be overridden later in\n            # wait_on_child if a process was forked, but they are still set\n            # here in case a non-spawning action was called\n        }\n        elsif ($builder->action($self))\n        {\n            $builder->cachout($self, $sig);\n\n            #'sig'->set($self, $sig);\n            'sig'->bsig($self, $sig);    # pcons\n            return $self->{status} = 'built';\n        }\n        else\n        {\n            die (\"$0: errors constructing ${\\$self->path}\\n\")\n              unless $param::kflag;\n            return $self->{status} = 'errors';\n        }\n    }\n    else\n    {\n\n        # Push this out to the cache if we've been asked to (-C option).\n        # Don't normally do this because it slows us down.\n        # In a fully built system, no accesses to the cache directory\n        # are required to check any files. This is a win if cache is\n        # heavily shared. Enabling this option puts the directory in the\n        # loop. Useful only when you wish to recreate a cache from a build.\n        if ($param::cachesync)\n        {\n            $builder->cachout($self, $sig);\n\n            #'sig'->set($self, $sig);\n            'sig'->bsig($self, $sig);\n        }\n        return $self->{status} = 'handled';\n    }\n}\n\nmy @finished;    # pcons //fix -Mstrict\n\nsub wait_on_max_jobs\n{\n    while (grep(/\\d+/, keys %{$file::child_queue}) >= $param::max_jobs)\n    {\n        wait_on_child();\n    }\n}\n\nsub wait_on_all_children\n{\n\n    while (grep(/\\d+/, keys %{$file::child_queue}) != 0)\n    {\n        wait_on_child();\n    }\n}\n\nsub wait_on_child\n{\n    my ($queue)  = $file::child_queue;\n    my ($parent) = $queue->{parent};\n\n    my $n = grep(/\\d+/, keys %{$file::child_queue});\n\n    # printf \"Waiting to build (%s): %s\\n\", $n, $parent->path if ref($parent) eq 'file';\n    my $pid = undef;\n\n    # first check for jobs that have already been collected from child\n    # targets\n    for my $p (@finished)\n    {\n        if ($queue->{$p})\n        {\n            $pid = $p;\n            last;\n        }\n    }\n\n    while (!$queue->{$pid})\n    {\n        $pid = wait();\n        if ($pid < 1)\n        {\n            die \"wait returned invalid pid $pid\";\n        }\n        else\n        {\n\n            # this job was meant for a parent, save it so that it can be\n            # found later\n            if (!$queue->{$pid})\n            {\n                push @finished, $pid;\n            }\n        }\n    }\n\n    my $child = $queue->{$pid};\n    my $tgt   = $queue->{$pid}->{'tgt'};\n    my $com   = $child->{'com'};\n    $tgt->{status} = 'built';\n\n    #print \"waited: \", $tgt->path; \n    #print \"on: \",  keys %{$queue}, \"\\n\";\n\n    my ($b0, $b1) = ($? & 0xFF, $? >> 8);\n\n    # Don't actually see 0177 on stopped process; is this necessary?\n    # next if $b0 == 0177; # process stopped; we can wait.\n    if ($b0)\n    {\n        my ($core, $sig) = ($b0 & 0200, $b0 & 0177);\n        my ($coremsg) = $core ? \"; core dumped\" : \"\";\n        $com =~ s/\\s.*//;\n        my ($path) = $tgt->path;\n        warn qq($0: *** [$path] $com terminated by signal $sig$coremsg\\n);\n        $parent->{status} = $tgt->{status} = 'errors';\n    }\n    if ($b1)\n    {\n        my ($path) = $tgt->path;\n        warn qq($0: *** [$path] Error $b1\\n);    # trying to be like make.\n        $parent->{status} = $tgt->{status} = 'errors';\n    }\n    if ($tgt->{status} eq 'built')\n    {\n        $tgt->{builder}->cachout($tgt, $tgt->{sign});\n\n        #'sig'->set($tgt, $tgt->{sign});\n        'sig'->bsig($tgt, $tgt->{sign});\n    }\n    else\n    {\n        die (\"$0: errors constructing ${\\$tgt->path}\\n\") unless $param::kflag;\n    }\n    delete $queue->{$pid};\n\n}\n\n#\n# pcons END\n########################################\n\n# Bind an action to a file, with the specified sources. No return value.\nsub bind\n{\n    my ($self, $builder, @sources) = @_;\n    if ($self->{builder} && !$self->{builder}->compatible($builder))\n    {\n\n        # Even if not \"compatible\", we can still check to see if the\n        # derivation is identical. It should be identical if the builder is\n        # the same and the sources are the same.\n        if (\"$self->{builder} @{$self->{sources}}\" ne \"$builder @sources\")\n        {\n            $main::errors++;\n            my ($_foo1, $script1, $line1, $sub1) = @{$self->creator};\n            my ($_foo2, $script2, $line2, $sub2) = script::caller_info;\n            my $err =\n              \"\\t${\\$self->path}\\n\"\n              . \"\\tbuilt (at least) two different ways:\\n\"\n              . \"\\t\\t$script1, line $line1:  $sub1\\n\"\n              . \"\\t\\t$script2, line $line2:  $sub2\\n\";\n            die $err;\n        }\n        return;\n    }\n    if ($param::wflag)\n    {\n        my ($script, $line, $sub);\n        (undef, $script, $line, $sub) = script::caller_info;\n        $self->{script} = '' if !defined $self->{script};\n        $self->{script} .= \"; \" if $self->{script};\n        $self->{script} .= qq($sub in \"$script\", line $line);\n    }\n    $self->{builder} = $builder;\n    push (@{$self->{sources}}, @sources);\n    @{$self->{dep}} = () if !defined $self->{dep};\n    $self->{conscript} = $priv::self->{script};\n}\n\nsub is_under\n{\n    $_[0]->{dir}->is_under($_[1]);\n}\n\nsub relpath\n{\n    my $dirpath = $_[0]->relpath($_[1]->{dir});\n    if (!$dirpath)\n    {\n        return $_[1]->{entry};\n    }\n    else\n    {\n        File::Spec->catfile($dirpath, $_[1]->{entry});\n    }\n}\n\n# Return the signature array for this file.\n# This probably belongs in its own \"sigarray\" package,\n# which would make it easier to optimize performance.\nsub sigarray\n{\n    if ($_[0]->{sigaref})\n    {\n        return @{$_[0]->{sigaref}};\n    }\n    my $self = shift;\n\n    # glob2pat based on The Perl Cookbook, p. 180.\n    sub glob2pat\n    {\n        my $globstr = shift;\n        my %patmap = (\n                     '*' => '.*',\n                     '?' => '.',\n                     '[' => '[',\n                     ']' => ']',\n                     '/' => \"\\Q$dir::SEPARATOR\",    # Cons-specific modification\n                     );\n        $globstr =~ s{(.)} { $patmap{$1} || \"\\Q$1\" }ge;\n        return '^' . $globstr . '$';\n    }\n    my @sigarray;\n    my $default;\n    my $builder = $self->lfile->{builder};\n    if (!$builder)\n    {\n        @sigarray = @$param::sourcesig;\n        $default  = [qw(content)];\n    }\n    else\n    {\n        if ($builder->{env} && $builder->{env}->{SIGNATURE})\n        {\n            @sigarray = @{$builder->{env}->{SIGNATURE}};\n        }\n        else\n        {\n            my $class = ref $builder;\n            my $path  = $self->path;\n            warn qq($0: Warning:  Builder package $class did not record\\n)\n              . qq(\\tthe calling environment for '$path'.\\n)\n              . qq(\\tUnable to use any %SIGNATURE construction variable\\n)\n              . qq(\\tfor signature configuration.\\n);\n        }\n        $default = [qw(build)];\n    }\n    my $path = $self->path;\n    while (@sigarray)\n    {\n        my ($glob, $aref) = splice(@sigarray, 0, 2);\n        my $re = glob2pat($glob);\n        if ($path =~ /$re/)\n        {\n            $aref = [split (/\\s+/, $aref)] if !ref $aref;\n            $self->{sigaref} = $aref;\n            return @$aref;\n        }\n    }\n    $self->{sigaref} = $default;\n    return @{$self->{sigaref}};\n}\n\n# Decide if this file's signature should be the content or build signature.\nsub sigtype\n{\n    if ($_[0]->{sigtype})\n    {\n        return $_[0]->{sigtype};\n    }\n    my $self     = shift;\n    my @sigarray = $self->sigarray;\n    my $sigtype;\n    if (grep($_ eq \"build\", @sigarray))\n    {\n        $sigtype = 'bsig';\n    }\n    elsif (grep($_ =~ /content$/, @sigarray))\n    {\n        $sigtype = 'csig';\n    }\n    return $self->{sigtype} = $sigtype;\n}\n\n# Return whether this file is configured to use stored\n# signature values from the .consign file.\nsub stored\n{\n    if (!defined $_[0]->{stored})\n    {\n        $_[0]->{stored} = grep($_ eq \"stored-content\", $_[0]->sigarray);\n    }\n    return $_[0]->{stored};\n}\n\n# Generic entry (file or directory) handling.\n# This is an empty subclass for nodes that haven't\n# quite decided whether they're files or dirs.\n# Use file methods until someone blesses them one way or the other.\npackage entry;\n\nuse vars qw( @ISA );\n\nBEGIN { @ISA = qw(file) }\n\n# File utilities\npackage futil;\n\n# Install one file as another.\n# Links them if possible (hard link), otherwise copies.\n# Don't ask why, but the source is a path, the tgt is a file obj.\nsub install\n{\n    my ($sp, $tgt) = @_;\n    my ($tp) = $tgt->path;\n    return 1 if $tp eq $sp;\n    return 1 if eval { link($sp, $tp) };\n    unlink($tp);\n    if (!futil::mkdir($tgt->{dir}))\n    {\n        return undef;\n    }\n    return 1 if eval { link($sp, $tp) };\n    futil::copy($sp, $tp);\n}\n\n# Copy one file to another. Arguments are actual file names.\n# Returns undef on failure. Preserves mtime and mode.\nsub copy\n{\n    my ($sp, $tp) = @_;\n    my ($mode, $length, $atime, $mtime) = (stat($sp))[2, 7, 8, 9];\n\n    # Use Perl standard library module for file copying, which handles\n    # binary copies. <schwarze@isa.de> 1998-06-18\n    if (!File::Copy::copy($sp, $tp))\n    {\n        warn qq($0: can\\'t install \"$sp\" to \"$tp\" ($!)\\n);    #'\n        return undef;\n    }\n\n    # The file has been created, so try both the chmod and utime,\n    # first making sure the copy is writable (because permissions\n    # affect the ability to modify file times on some operating\n    # systems), and then changing permissions back if necessary.\n    my $ret   = 1;\n    my $wmode = $mode | 0700;\n    if (!chmod $wmode, $tp)\n    {\n        warn qq($0: can\\'t set mode $wmode on file \"$tp\" ($!)\\n);    #'\n        $ret = undef;\n    }\n    if (!utime $atime, $mtime, $tp)\n    {\n        warn qq($0: can\\'t set modification time for file \"$tp\" ($!)\\n);    #'\n        $ret = undef;\n    }\n    if ($mode != $wmode && !chmod $mode, $tp)\n    {\n        warn qq($0: can\\'t set mode $mode on file \"$tp\" ($!)\\n);    #'\n        $ret = undef;\n    }\n    return $ret;\n}\n\n# Ensure that the specified directory exists.\n# Aborts on failure.\nsub mkdir\n{\n    return 1 if $_[0]->{'exists'};\n    if (!futil::mkdir($_[0]->{dir}))\n    {    # Recursively make parent.\n        return undef;\n    }\n    my ($path) = $_[0]->path;\n    if (!-d $path && !mkdir($path, 0777))\n    {\n        warn qq($0: can't create directory $path ($!).\\n);    #'\n        return undef;\n    }\n    $_[0]->{'exists'} = 1;\n}\n\n# Signature package.\npackage sig::hash;\n\nuse vars qw( $called );\n\nsub init\n{\n    my ($dir)     = @_;\n    my ($consign) = $dir->prefix . \".consign\";\n    my ($dhash)   = $dir->{consign} = {};\n    if (-f $consign)\n    {\n        open(CONSIGN, $consign) || die (\"$0: can't open $consign ($!)\\n\");\n        while (<CONSIGN>)\n        {\n            chop;\n            my ($file, $sig) = split (/:/, $_);\n            $dhash->{$file} = $sig;\n        }\n        close(CONSIGN);\n    }\n    $dhash;\n}\n\n# Read the hash entry for a particular file.\nsub in\n{\n    my ($dir) = $_[0]->{dir};\n    ($dir->{consign} || init($dir))->{$_[0]->{entry}};\n}\n\n# Write the hash entry for a particular file.\nsub out\n{\n    my ($file, $sig) = @_;\n    my ($dir) = $file->{dir};\n    ($dir->{consign} || init($dir))->{$file->{entry}} = $sig;\n    $sig::hash::dirty{$dir} = $dir;\n}\n\n# Eliminate the hash entry for a particular file.\nsub clear\n{\n    my ($file) = @_;\n    my ($dir)  = $file->{dir};\n    delete $dir->{consign}->{$file->{entry}} if $dir->{consign};\n    $sig::hash::dirty{$dir} = $dir;\n}\n\n# Flush hash entries. Called at end or via ^C interrupt.\nsub END\n{\n    return if $called++;    # May be called twice.\n    close(CONSIGN);         # in case this came in via ^C.\n    my $dir;\n    for $dir (values %sig::hash::dirty)\n    {\n        my ($consign)  = $dir->prefix . \".consign\";\n        my ($constemp) = $consign . \".$$\";\n        if (!open(CONSIGN, \">$constemp\"))\n        {\n            die (\"$0: can't create $constemp ($!)\\n\");\n        }\n        my ($entry, $sig);\n        while (($entry, $sig) = each %{$dir->{consign}})\n        {\n            if (!print CONSIGN \"$entry:$sig\\n\")\n            {\n                die (\"$0: error writing to $constemp ($!)\\n\");\n            }\n        }\n        close(CONSIGN);\n        if (!rename($constemp, $consign))\n        {\n            if (futil::copy($constemp, $consign))\n            {\n                unlink($constemp);\n            }\n            else\n            {\n                die (\"$0: couldn't rename or copy $constemp to $consign \"\n                     . \"($!)\\n\");\n            }\n        }\n    }\n}\n\n# Derived file caching.\npackage cache;\n\n# Find a file in the cache. Return non-null if the file is in the cache.\nsub in\n{\n    return undef unless $param::cache;\n    my ($file, $sig) = @_;\n\n    # Add the path to the signature, to make it unique.\n    $sig = 'sig'->collect($sig, $file->path) unless $param::mixtargets;\n    my ($dir) = substr($sig, 0, 1);\n    my ($cp) = File::Spec->catfile($param::cache, $dir, $sig);\n    return -f $cp && futil::install($cp, $file);\n}\n\n# Try to flush a file to the cache, if not already there.\n# If it doesn't make it out, due to an error, then that doesn't\n# really matter.\nsub out\n{\n    return unless $param::cache;\n    my ($file, $sig) = @_;\n\n    # Add the path to the signature, to make it unique.\n    $sig = 'sig'->collect($sig, $file->path) unless $param::mixtargets;\n    my ($dir) = substr($sig, 0, 1);\n    my ($sp) = $file->path;\n    my ($cp) = File::Spec->catfile($param::cache, $dir, $sig);\n    my ($cdir) = File::Spec->catfile($param::cache, $dir);\n    if (!-d $cdir)\n    {\n        mkdir($cdir, 0777)\n          || die (\"$0: can't create cache directory $cdir ($!).\\n\");\n    }\n    elsif (-f $cp)\n    {\n\n        # Already cached: try to use that instead, to save space.\n        # This can happen if the -cs option is used on a previously\n        # uncached build, or if two builds occur simultaneously.\n        my ($lp) = \".$sig\";\n        unlink($lp);\n        return if !eval { link($cp, $lp) };\n        rename($lp, $sp);\n\n        # Unix98 says, \"If the old argument and the new argument both\n        # [refer] to the same existing file, the rename() function\n        # returns successfully and performs no other action.\"  So, if\n        # $lp and $sp are links (i.e., $cp and $sp are links), $lp is\n        # left, and we must unlink it ourselves.  If the rename failed\n        # for any reason, it is also good form to unlink the temporary\n        # $lp.  Otherwise $lp no longer exists and, barring some race,\n        # the unlink fails silently.\n        unlink($lp);\n        return;\n    }\n\n    return if eval { link($sp, $cp) };\n    return if !-f $sp;    # if nothing to cache.\n    if (futil::copy($sp, \"$cp.new\"))\n    {\n        rename(\"$cp.new\", $cp);\n    }\n}\n\n# Generic signature handling package.\n# This handles the higher-layer distinction between content and build\n# signatures, relying on an underlying calculation package like\n# \"sig::md5\"\" to provide the signature values themselves.\npackage sig;\n\nuse vars qw( @ISA );\n\n# Select the underlying package to be used for signature calculation.\n# We play a few namespace games here.  Specifically, we append\n# \"sig::\" to the beginning of the subclass we're passed.  Then,\n# if the package ends in \"::debug\", we actually subclass the\n# \"sig::debug\" package and as a wrapper around the underlying\n# (e.g.) \"sig::md5\" package that's doing the real calculation.\nsub select\n{\n    my ($package, $subclass) = @_;\n    my $p      = $package . \"::\" . $subclass;\n    my $sigpkg = $p;\n    if ($p =~ /(.*)::debug$/)\n    {\n        $sigpkg = $1;\n        $p      = 'sig::debug';\n    }\n    @ISA = ($p);\n    $p->init($sigpkg);\n};\n\n# Set or return the build signature of a file.\n# This is computed elsewhere and passed in to us.\nsub bsig\n{\n    my ($self, $file, $sig) = @_;\n    if (defined $sig)\n    {\n        $file->{'bsig'} = $sig;\n        $self->set($file);\n    }\n    elsif (!defined $file->{'bsig'})\n    {\n        $file->{'bsig'} = '';\n    }\n    $file->{'bsig'};\n}\n\n# Determine the content signature of a file.\n# This also sets the .consign entry unless the file is in a\n# repository; we don't write into repositories, only read from them.\nsub csig\n{\n    my ($self, $file) = @_;\n    if (!$file->{'csig'})\n    {\n        $file->{'csig'} = $self->srcsig($file->path);\n        $self->set($file) if !$file->is_on_rpath;\n    }\n    $_[1]->{'csig'};\n}\n\n# Determine the current signature of an already-existing or\n# non-existant file.  Unless a specific signature type (bsig\n# or csig) is requested, this consults the file's signature\n# array to decide whether to return content or build signature,\n# and whether to use a cached value from a .consign file.\nsub signature\n{\n    my ($self, $file, $sigtype) = @_;\n    $sigtype = $file->sigtype if !$sigtype;\n\n    #open(TTY, \">/dev/tty\");\n    #print TTY $file->path, \": $sigtype\\n\";\n    #close(TTY);\n    my ($path) = $file->path;\n    my ($time) = (stat($path))[9];\n    if ($time)\n    {\n        if ($file->{$sigtype})\n        {\n            return $file->{$sigtype};\n        }\n        if ($file->is_on_rpath || $file->stored)\n        {\n            if ('sig'->fetch($file) && $file->{$sigtype})\n            {\n                if ($file->{'sigtime'} == $time\n                    || !$param::rep_sig_times_ok && $file->is_on_rpath)\n                {\n                    return $file->{$sigtype};\n                }\n            }\n            $file->{$sigtype} = undef;\n        }\n        if ($file->is_on_rpath || !File::Spec->file_name_is_absolute($path))\n        {\n            my $sig = '';\n            if    ($sigtype eq 'bsig') { $sig = $self->bsig($file); }\n            elsif ($sigtype eq 'csig') { $sig = $self->csig($file); }\n            return $sig;\n        }\n\n        # This file is not in a repository or under the local directory\n        # structure.  In the canonical case, it's a utility that will be\n        # executed by a command.  Historically, Cons has returned the\n        # name of the command concatenated with the modification time.\n        # Note that this is *not* the path (\"cc\" not \"/bin/cc\"), so it\n        # would lose in the unlikely event that a different copy of the\n        # utility was used that happened to have the same modification\n        # time (due to living in a different directory on the PATH, for\n        # example).  The obvious \"fix\" of using the path like so, however:\n        #\treturn $path . $time;\n        # is wrong.  In a multi-machine build environment, different\n        # systems may have the same utility in different locations (due\n        # to different NFS mount points, for example), which would\n        # cause a lot of unnecessary builds if we used the full path.\n        # A better solution to strengthen this signature would be to\n        # also concatenate the size of the file, but that would cause\n        # unnecessary rebuilds when coming from .consign files that used\n        # the old scheme.  All of which is to merely explain why we're\n        # leaving this as it has been, but documenting it here in case\n        # there's reason to change it in the future.\n        return $file->{entry} . $time;\n    }\n    return $file->{$sigtype} = '';\n}\n\nsub bsignature\n{\n    my ($self, $file) = @_;\n    my ($path) = $file->path;\n    my ($time) = (stat($path))[9];\n    if ($time)\n    {\n        if ($file->{'bsig'})\n        {\n            return $file->{'bsig'};\n        }\n        if ('sig'->fetch($file, 'bsig') && $file->{'bsig'})\n        {\n            if ($file->{'sigtime'} == $time\n                || !$param::rep_sig_times_ok && $file->is_on_rpath)\n            {\n                return $file->{'bsig'};\n            }\n        }\n        if ($file->is_on_rpath || !File::Spec->file_name_is_absolute($path))\n        {\n            return $self->bsig($file);\n        }\n        return $path . $time;\n    }\n    return $file->{'bsig'} = '';\n}\n\n# Invalidate a file's signature, also clearing its .consign entry.\nsub invalidate\n{\n    my ($self, $file) = @_;\n    delete $file->{'sigtime'};\n    delete $file->{'bsig'};\n    delete $file->{'csig'};\n    sig::hash::clear($file);\n}\n\n# Store the signature for a file.\nsub set\n{\n    my ($self, $file) = @_;\n    my $sig = (stat($file->path))[9];\n    $sig .= \" \" . ($file->{'bsig'} || '-');\n    $sig .= \" \" . $file->{'csig'} if $file->{'csig'};\n    sig::hash::out($file, $sig);\n}\n\n# Fetch the signature(s) for a file.\n# Returns whether there was a signature to fetch.\nsub fetch\n{\n    my ($self, $file, @kw) = @_;\n    @kw = ('bsig', 'csig') if !@kw;\n    my $sig = sig::hash::in($file) || '';\n    my ($sigtime, $bsig, $csig) = split (/ /, $sig);\n    $file->{'sigtime'} = $sigtime;\n    $file->{'bsig'}    = $bsig || '' if grep($_ eq 'bsig', @kw);\n    $file->{'csig'}    = $csig || '' if grep($_ eq 'csig', @kw);\n    $file->{'bsig'} = '' if $file->{'bsig'} eq '-';\n    return $sig ne '';\n}\n\n# MD5-based signature package.\npackage sig::md5;\n\nuse vars qw( $md5 );\n\n# Initialize MD5 signature calculation by finding an appropriate\n# module and creating the proper object.\nsub init\n{\n    my $self        = shift;\n    my @md5_modules = qw(Digest::MD5 MD5 Digest::Perl::MD5);\n\n    # We used to find the right module more simply, using $_ as the\n    # loop iterator and just doing:\n    #\n    #\t\teval \"use $_\";\n    #\t\t$module = $_, $last if ! $@;\n    #\n    # in the loop.  Empirically, though, this doesn't pass back the\n    # right value in $module on some ActiveState versions.  (Maybe\n    # it's something to do with the eval in a for loop, I dunno.)\n    # Work around it by using $_ to pass the value out of the loop,\n    # which seems to work everywhere.\n    my $module;\n    for $module (@md5_modules)\n    {\n        eval \"use $module\";\n        $_ = $module, last if !$@;\n    }\n    $module = $_;\n    die \"Cannot find any MD5 module from:  @md5_modules\" if $@;\n\n    $md5 = new $module;\n}\n\n# Is the provided signature equal to the signature of the current\n# instantiation of the target (and does the target exist)?\nsub current\n{\n    my ($self, $file, $sig, $sigtype) = @_;\n    $self->bsignature($file) eq $sig;\n}\n\n# Return an aggregate signature for a list of signature values.\nsub collect\n{\n    my ($self, @sigs) = @_;\n\n    # The following sequence is faster than calling the hex interface.\n    $md5->reset();\n    $md5->add(join ('', $param::salt, @sigs));\n    unpack(\"H*\", $md5->digest());\n}\n\n# Directly compute a file signature as the MD5 checksum of the\n# bytes in the file.\nsub srcsig\n{\n    my ($self, $path) = @_;\n    $md5->reset();\n    open(FILE, $path) || return '';\n    binmode(FILE);\n    $md5->addfile(\\*FILE);\n    close(FILE);\n    unpack(\"H*\", $md5->digest());\n}\n\n# Compute the signature of a command string.\n# For MD5, this is just the string itself, since MD5 will condense\n# the string contents into the ultimate signature.  Other signature\n# schemes may need to figure this out differently.\nsub cmdsig\n{\n    my ($self, $sig) = @_;\n    return $sig;\n}\n\n# Generic debug package for signature calculation.\n# Because of the way we're called by sig::select() and then use\n# the specified value to set up @ISA, this package is essentially a\n# factory that creates packages like sig::md5::debug, etc., on the fly.\npackage sig::debug;\n\nuse vars qw( @ISA $sigpkg $outfh );\n\nlocal *FH;\n\nsub init\n{\n    my $self = shift;\n    $sigpkg = shift;\n    @ISA    = ($sigpkg);\n    $sigpkg->init();\n    my $file = $ENV{CONS_SIG_DEBUG};\n    if ($file)\n    {\n        if (!open(FH, \">$file\"))\n        {\n            die \"Cannot open $file: $!\";\n        }\n        $outfh = \\*FH;\n    }\n    else\n    {\n        $outfh = \\*STDOUT;\n    }\n}\n\nsub current\n{\n    my ($self, $file, $sig, $sigtype) = @_;\n    my $fsig = $self->bsignature($file);\n    my $sub  = \"${sigpkg}::current\";\n    my $sep  = \"\\n\" . ' ' x (length($sub) + 1 - 3);\n    print $outfh \"$sub(|$fsig|${sep}eq |$sig|)\\n\";\n    return $fsig eq $sig;\n}\n\nsub collect\n{\n    my ($self, @sigs) = @_;\n    my $sig = $sigpkg->collect(@sigs);\n    my $sub = \"${sigpkg}::collect\";\n    my $sep = \",\\n\" . ' ' x (length($sub) + 1);\n    my $buf = join ($sep, @sigs);\n    $buf = $param::salt . $sep . $buf if $param::salt;\n    print $outfh \"$sub($buf)\\n\\t=> |$sig|\\n\";\n    return $sig;\n}\n\nsub srcsig\n{\n    my ($self, $path) = @_;\n    my $sig = $sigpkg->srcsig($path);\n    print $outfh \"${sigpkg}::srcsig($path)\\n\\t=> |$sig|\\n\";\n    return $sig;\n}\n\n__END__;\n\n=head1 NAME\n\nCons - A Software Construction System\n\n=head1 DESCRIPTION\n\nA guide and reference for version __VERSION____REVISION__\n\nCopyright (c) 1996-2001 Free Software Foundation, Inc.\n\nThis program is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 2 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; see the file COPYING.  If not, write to\nthe Free Software Foundation, Inc., 59 Temple Place - Suite 330,\nBoston, MA 02111-1307, USA.\n\n=head1 Introduction\n\nB<Cons> is a system for constructing, primarily, software, but is quite\ndifferent from previous software construction systems. Cons was designed\nfrom the ground up to deal easily with the construction of software spread\nover multiple source directories. Cons makes it easy to create build scripts\nthat are simple, understandable and maintainable. Cons ensures that complex\nsoftware is easily and accurately reproducible.\n\nCons uses a number of techniques to accomplish all of this. Construction\nscripts are just Perl scripts, making them both easy to comprehend and very\nflexible. Global scoping of variables is replaced with an import/export\nmechanism for sharing information between scripts, significantly improving\nthe readability and maintainability of each script. B<Construction\nenvironments> are introduced: these are Perl objects that capture the\ninformation required for controlling the build process. Multiple\nenvironments are used when different semantics are required for generating\nproducts in the build tree. Cons implements automatic dependency analysis\nand uses this to globally sequence the entire build. Variant builds are\neasily produced from a single source tree. Intelligent build subsetting is\npossible, when working on localized changes. Overrides can be setup to\neasily override build instructions without modifying any scripts. MD5\ncryptographic B<signatures> are associated with derived files, and are used\nto accurately determine whether a given file needs to be rebuilt.\n\nWhile offering all of the above, and more, Cons remains simple and easy to\nuse. This will, hopefully, become clear as you read the remainder of this\ndocument.\n\n\n=head1 Why Cons? Why not Make?\n\nCons is a B<make> replacement. In the following paragraphs, we look at a few\nof the undesirable characteristics of make--and typical build environments\nbased on make--that motivated the development of Cons.\n\n=head2 Build complexity\n\nTraditional make-based systems of any size tend to become quite complex. The\noriginal make utility and its derivatives have contributed to this tendency\nin a number of ways. Make is not good at dealing with systems that are\nspread over multiple directories. Various work-arounds are used to overcome\nthis difficulty; the usual choice is for make to invoke itself recursively\nfor each sub-directory of a build. This leads to complicated code, in which\nit is often unclear how a variable is set, or what effect the setting of a\nvariable will have on the build as a whole. The make scripting language has\ngradually been extended to provide more possibilities, but these have\nlargely served to clutter an already overextended language. Often, builds\nare done in multiple passes in order to provide appropriate products from\none directory to another directory. This represents a further increase in\nbuild complexity.\n\n\n=head2 Build reproducibility\n\nThe bane of all makes has always been the correct handling of\ndependencies. Most often, an attempt is made to do a reasonable job of\ndependencies within a single directory, but no serious attempt is made to do\nthe job between directories. Even when dependencies are working correctly,\nmake's reliance on a simple time stamp comparison to determine whether a\nfile is out of date with respect to its dependents is not, in general,\nadequate for determining when a file should be rederived. If an external\nlibrary, for example, is rebuilt and then ``snapped'' into place, the\ntimestamps on its newly created files may well be earlier than the last\nlocal build, since it was built before it became visible.\n\n\n=head2 Variant builds\n\nMake provides only limited facilities for handling variant builds. With the\nproliferation of hardware platforms and the need for debuggable\nvs. optimized code, the ability to easily create these variants is\nessential. More importantly, if variants are created, it is important to\neither be able to separate the variants or to be able to reproduce the\noriginal or variant at will. With make it is very difficult to separate the\nbuilds into multiple build directories, separate from the source. And if\nthis technique isn't used, it's also virtually impossible to guarantee at\nany given time which variant is present in the tree, without resorting to a\ncomplete rebuild.\n\n\n=head2 Repositories\n\nMake provides only limited support for building software from code that\nexists in a central repository directory structure.  The VPATH feature of\nGNU make (and some other make implementations) is intended to provide this,\nbut doesn't work as expected: it changes the path of target file to the\nVPATH name too early in its analysis, and therefore searches for all\ndependencies in the VPATH directory.  To ensure correct development builds,\nit is important to be able to create a file in a local build directory and\nhave any files in a code repository (a VPATH directory, in make terms) that\ndepend on the local file get rebuilt properly.  This isn't possible with\nVPATH, without coding a lot of complex repository knowledge directly into\nthe makefiles.\n\n\n=head1 Keeping it simple\n\nA few of the difficulties with make have been cited above. In this and\nsubsequent sections, we shall introduce Cons and show how these issues are\naddressed.\n\n=head2 Perl scripts\n\nCons is Perl-based. That is, Cons scripts--F<Conscript> and F<Construct>\nfiles, the equivalent to F<Makefile> or F<makefile>--are all written in\nPerl. This provides an immediate benefit: the language for writing scripts\nis a familiar one. Even if you don't happen to be a Perl programmer, it\nhelps to know that Perl is basically just a simple declarative language,\nwith a well-defined flow of control, and familiar semantics. It has\nvariables that behave basically the way you would expect them to,\nsubroutines, flow of control, and so on. There is no special syntax\nintroduced for Cons. The use of Perl as a scripting language simplifies\nthe task of expressing the appropriate solution to the often complex\nrequirements of a build.\n\n\n=head2 Hello, World!\n\nTo ground the following discussion, here's how you could build the B<Hello,\nWorld!> C application with Cons:\n\n\n\n  $env = new cons();\n  Program $env 'hello', 'hello.c';\n\nIf you install this script in a directory, naming the script F<Construct>,\nand create the F<hello.c> source file in the same directory, then you can\ntype C<cons hello> to build the application:\n\n\n\n  % cons hello\n  cc -c hello.c -o hello.o\n  cc -o hello hello.o\n\n\n=head2 Construction environments\n\nA key simplification of Cons is the idea of a B<construction environment>. A\nconstruction environment is an B<object> characterized by a set of key/value\npairs and a set of B<methods>. In order to tell Cons how to build something,\nyou invoke the appropriate method via an appropriate construction\nenvironment. Consider the following example:\n\n\n\n  $env = new cons(\n\tCC\t=>\t'gcc',\n\tLIBS\t=>\t'libworld.a'\n  );\n\n  Program $env 'hello', 'hello.c';\n\nIn this case, rather than using the default construction environment, as is,\nwe have overridden the value of C<CC> so that the GNU C Compiler equivalent\nis used, instead. Since this version of B<Hello, World!> requires a library,\nF<libworld.a>, we have specified that any program linked in this environment\nshould be linked with that library. If the library exists already, well and\ngood, but if not, then we'll also have to include the statement:\n\n\n\n  Library $env 'libworld', 'world.c';\n\nNow if you type C<cons hello>, the library will be built before the program\nis linked, and, of course, C<gcc> will be used to compile both modules:\n\n\n\n  % cons hello\n  gcc -c hello.c -o hello.o\n  gcc -c world.c -o world.o\n  ar r libworld.a world.o\n  ar: creating libworld.a\n  ranlib libworld.a\n  gcc -o hello hello.o libworld.a\n\n\n=head2 Automatic and complete dependency analysis\n\nWith Cons, dependencies are handled automatically. Continuing the previous\nexample, note that when we modify F<world.c>, F<world.o> is recompiled,\nF<libworld.a> recreated, and F<hello> relinked:\n\n\n\n  % vi world.c\n    [EDIT]\n  % cons hello\n  gcc -c world.c -o world.o\n  ar r libworld.a world.o\n  ar: creating libworld.a\n  ranlib libworld.a\n  gcc -o hello hello.o libworld.a\n\nThis is a relatively simple example: Cons ``knows'' F<world.o> depends upon\nF<world.c>, because the dependency is explicitly set up by the C<Library>\nmethod. It also knows that F<libworld.a> depends upon F<world.o> and that\nF<hello> depends upon F<libworld.a>, all for similar reasons.\n\nNow it turns out that F<hello.c> also includes the interface definition\nfile, F<world.h>:\n\n\n\n  % emacs world.h\n    [EDIT]\n  % cons hello\n  gcc -c hello.c -o hello.o\n  gcc -o hello hello.o libworld.a\n\nHow does Cons know that F<hello.c> includes F<world.h>, and that F<hello.o>\nmust therefore be recompiled? For now, suffice it to say that when\nconsidering whether or not F<hello.o> is up-to-date, Cons invokes a scanner\nfor its dependency, F<hello.c>. This scanner enumerates the files included\nby F<hello.c> to come up with a list of further dependencies, beyond those\nmade explicit by the Cons script. This process is recursive: any files\nincluded by included files will also be scanned.\n\nIsn't this expensive? The answer is--it depends. If you do a full build of a\nlarge system, the scanning time is insignificant. If you do a rebuild of a\nlarge system, then Cons will spend a fair amount of time thinking about it\nbefore it decides that nothing has to be done (although not necessarily more\ntime than make!). The good news is that Cons makes it very easy to\nintelligently subset your build, when you are working on localized changes.\n\n\n=head2 Automatic global build sequencing\n\nBecause Cons does full and accurate dependency analysis, and does this\nglobally, for the entire build, Cons is able to use this information to take\nfull control of the B<sequencing> of the build. This sequencing is evident\nin the above examples, and is equivalent to what you would expect for make,\ngiven a full set of dependencies. With Cons, this extends trivially to\nlarger, multi-directory builds. As a result, all of the complexity involved\nin making sure that a build is organized correctly--including multi-pass\nhierarchical builds--is eliminated. We'll discuss this further in the next\nsections.\n\n=head1 Building large trees--still just as simple\n\n\n=head2 A hierarchy of build scripts\n\nA larger build, in Cons, is organized by creating a hierarchy of B<build\nscripts>. At the top of the tree is a script called F<Construct>. The rest\nof the scripts, by convention, are each called F<Conscript>. These scripts\nare connected together, very simply, by the C<Build>, C<Export>, and\nC<Import> commands.\n\n\n=head2 The Build command\n\nThe C<Build> command takes a list of F<Conscript> file names, and arranges\nfor them to be included in the build. For example:\n\n  Build qw(\n\tdrivers/display/Conscript\n\tdrivers/mouse/Conscript\n\tparser/Conscript\n\tutilities/Conscript\n  );\n\nThis is a simple two-level hierarchy of build scripts: all the subsidiary\nF<Conscript> files are mentioned in the top-level F<Construct> file. Notice\nthat not all directories in the tree necessarily have build scripts\nassociated with them.\n\nThis could also be written as a multi-level script. For example, the\nF<Construct> file might contain this command:\n\n  Build qw(\n\tparser/Conscript\n\tdrivers/Conscript\n\tutilities/Conscript\n  );\n\nand the F<Conscript> file in the F<drivers> directory might contain this:\n\n  Build qw(\n\tdisplay/Conscript\n\tmouse/Conscript\n  );\n\nExperience has shown that the former model is a little easier to understand,\nsince the whole construction tree is laid out in front of you, at the\ntop-level. Hybrid schemes are also possible. A separately maintained\ncomponent that needs to be incorporated into a build tree, for example,\nmight hook into the build tree in one place, but define its own construction\nhierarchy.\n\nBy default, Cons does not change its working directory to the directory\ncontaining a subsidiary F<Conscript> file it is including.  This behavior\ncan be enabled for a build by specifying, in the top-level F<Construct>\nfile:\n\n  Conscript_chdir 1;\n\nWhen enabled, Cons will change to the subsidiary F<Conscript> file's\ncontaining directory while reading in that file, and then change back\nto the top-level directory once the file has been processed.\n\nIt is expected that this behavior will become the default in some future\nversion of Cons.  To prepare for this transition, builds that expect\nCons to remain at the top of the build while it reads in a subsidiary\nF<Conscript> file should explicitly disable this feature as follows:\n\n  Conscript_chdir 0;\n\n\n=head2 Relative, top-relative, and absolute file names\n\nYou may have noticed that the file names specified to the Build command are\nrelative to the location of the script it is invoked from. This is generally\ntrue for other filename arguments to other commands, too, although we might\nas well mention here that if you begin a file name with a hash mark, ``#'',\nthen that file is interpreted relative to the top-level directory (where the\nF<Construct> file resides). And, not surprisingly, if you begin it with ``/'',\nthen it is considered to be an absolute pathname. This is true even on\nsystems which use a back slash rather than a forward slash to name absolute\npaths.\n\n(There is another file prefix, ``!'', that is interpreted specially by\nCons.  See discussion of the C<Link> command, below, for details.)\n\n\n=head2 Using modules in build scripts\n\nYou may pull modules into each F<Conscript> file using the normal Perl\nC<use> or C<require> statements:\n\n  use English;\n  require My::Module;\n\nEach C<use> or C<require> only affects the one F<Conscript> file in which\nit appears.  To use a module in multiple F<Conscript> files, you must\nput a C<use> or C<require> statement in each one that needs the module.\n\n\n=head2 Scope of variables\n\nThe top-level F<Construct> file and all F<Conscript> files begin life in\na common, separate Perl package.  B<Cons> controls the symbol table for\nthe package so that, the symbol table for each script is empty, except\nfor the F<Construct> file, which gets some of the command line arguments.\nAll of the variables that are set or used, therefore, are set by the\nscript itself--not by some external script.\n\nVariables can be explicitly B<imported> by a script from its parent\nscript. To import a variable, it must have been B<exported> by the parent\nand initialized (otherwise an error will occur).\n\n\n=head2 The Export command\n\nThe C<Export> command is used as in the following example:\n\n  $env = new cons();\n  $INCLUDE = \"#export/include\";\n  $LIB = \"#export/lib\";\n  Export qw( env INCLUDE LIB );\n  Build qw( util/Conscript );\n\nThe values of the simple variables mentioned in the C<Export> list will be\nsquirreled away by any subsequent C<Build> commands. The C<Export> command\nwill only export Perl B<scalar> variables, that is, variables whose name\nbegins with C<$>. Other variables, objects, etc. can be exported by\nreference--but all scripts will refer to the same object, and this object\nshould be considered to be read-only by the subsidiary scripts and by the\noriginal exporting script. It's acceptable, however, to assign a new value\nto the exported scalar variable--that won't change the underlying variable\nreferenced. This sequence, for example, is OK:\n\n  $env = new cons();\n  Export qw( env INCLUDE LIB );\n  Build qw( util/Conscript );\n  $env = new cons(CFLAGS => '-O');\n  Build qw( other/Conscript );\n\nIt doesn't matter whether the variable is set before or after the C<Export>\ncommand. The important thing is the value of the variable at the time the\nC<Build> command is executed. This is what gets squirreled away. Any\nsubsequent C<Export> commands, by the way, invalidate the first: you must\nmention all the variables you wish to export on each C<Export> command.\n\n\n=head2 The Import command\n\nVariables exported by the C<Export> command can be imported into subsidiary\nscripts by the C<Import> command. The subsidiary script always imports\nvariables directly from the superior script. Consider this example:\n\n  Import qw( env INCLUDE );\n\nThis is only legal if the parent script exported both C<$env> and\nC<$INCLUDE>. It also must have given each of these variables values. It is\nOK for the subsidiary script to only import a subset of the exported\nvariables (in this example, C<$LIB>, which was exported by the previous\nexample, is not imported).\n\nAll the imported variables are automatically re-exported, so the sequence:\n\n  Import qw ( env INCLUDE );\n  Build qw ( beneath-me/Conscript );\n\nwill supply both C<$env> and C<$INCLUDE> to the subsidiary file. If only\nC<$env> is to be exported, then the following will suffice:\n\n  Import qw ( env INCLUDE );\n  Export qw ( env );\n  Build qw ( beneath-me/Conscript );\n\nNeedless to say, the variables may be modified locally before invoking\nC<Build> on the subsidiary script.\n\n\n=head2 Build script evaluation order\n\nThe only constraint on the ordering of build scripts is that superior\nscripts are evaluated before their inferior scripts. The top-level\nF<Construct> file, for instance, is evaluated first, followed by any\ninferior scripts. This is all you really need to know about the evaluation\norder, since order is generally irrelevant. Consider the following C<Build>\ncommand:\n\n  Build qw(\n\tdrivers/display/Conscript\n\tdrivers/mouse/Conscript\n\tparser/Conscript\n\tutilities/Conscript\n  );\n\nWe've chosen to put the script names in alphabetical order, simply because\nthat's the most convenient for maintenance purposes. Changing the order will\nmake no difference to the build.\n\n\n=head1 A Model for sharing files\n\n\n=head2 Some simple conventions\n\nIn any complex software system, a method for sharing build products needs to\nbe established. We propose a simple set of conventions which are trivial to\nimplement with Cons, but very effective.\n\nThe basic rule is to require that all build products which need to be shared\nbetween directories are shared via an intermediate directory. We have\ntypically called this F<export>, and, in a C environment, provided\nconventional sub-directories of this directory, such as F<include>, F<lib>,\nF<bin>, etc.\n\nThese directories are defined by the top-level F<Construct> file. A simple\nF<Construct> file for a B<Hello, World!> application, organized using\nmultiple directories, might look like this:\n\n  # Construct file for Hello, World!\n\n  # Where to put all our shared products.\n  $EXPORT = '#export';\n\n  Export qw( CONS INCLUDE LIB BIN );\n\n  # Standard directories for sharing products.\n  $INCLUDE = \"$EXPORT/include\";\n  $LIB = \"$EXPORT/lib\";\n  $BIN = \"$EXPORT/bin\";\n\n  # A standard construction environment.\n  $CONS = new cons (\n\tCPPPATH => $INCLUDE,\t# Include path for C Compilations\n\tLIBPATH => $LIB,\t# Library path for linking programs\n\tLIBS => '-lworld',\t# List of standard libraries\n  );\n\n  Build qw(\n\thello/Conscript\n\tworld/Conscript\n  );\n\nThe F<world> directory's F<Conscript> file looks like this:\n\n  # Conscript file for directory world\n  Import qw( CONS INCLUDE LIB );\n\n  # Install the products of this directory\n  Install $CONS $LIB, 'libworld.a';\n  Install $CONS $INCLUDE, 'world.h';\n\n  # Internal products\n  Library $CONS 'libworld.a', 'world.c';\n\nand the F<hello> directory's F<Conscript> file looks like this:\n\n  # Conscript file for directory hello\n  Import qw( CONS BIN );\n\n  # Exported products\n  Install $CONS $BIN, 'hello';\n\n  # Internal products\n  Program $CONS 'hello', 'hello.c';\n\nTo construct a B<Hello, World!> program with this directory structure, go to\nthe top-level directory, and invoke C<cons> with the appropriate\narguments. In the following example, we tell Cons to build the directory\nF<export>. To build a directory, Cons recursively builds all known products\nwithin that directory (only if they need rebuilding, of course). If any of\nthose products depend upon other products in other directories, then those\nwill be built, too.\n\n  % cons export\n  Install world/world.h as export/include/world.h\n  cc -Iexport/include -c hello/hello.c -o hello/hello.o\n  cc -Iexport/include -c world/world.c -o world/world.o\n  ar r world/libworld.a world/world.o\n  ar: creating world/libworld.a\n  ranlib world/libworld.a\n  Install world/libworld.a as export/lib/libworld.a\n  cc -o hello/hello hello/hello.o -Lexport/lib -lworld\n  Install hello/hello as export/bin/hello\n\n\n=head2 Clean, understandable, location-independent scripts\n\nYou'll note that the two F<Conscript> files are very clean and\nto-the-point. They simply specify products of the directory and how to build\nthose products. The build instructions are minimal: they specify which\nconstruction environment to use, the name of the product, and the name of\nthe inputs. Note also that the scripts are location-independent: if you wish\nto reorganize your source tree, you are free to do so: you only have to\nchange the F<Construct> file (in this example), to specify the new locations\nof the F<Conscript> files. The use of an export tree makes this goal easy.\n\nNote, too, how Cons takes care of little details for you. All the F<export>\ndirectories, for example, were made automatically. And the installed files\nwere really hard-linked into the respective export directories, to save\nspace and time. This attention to detail saves considerable work, and makes\nit even easier to produce simple, maintainable scripts.\n\n\n=head1 Separating source and build trees\n\nIt's often desirable to keep any derived files from the build completely\nseparate from the source files. This makes it much easier to keep track of\njust what is a source file, and also makes it simpler to handle B<variant>\nbuilds, especially if you want the variant builds to co-exist.\n\n\n=head2 Separating build and source directories using the Link command\n\nCons provides a simple mechanism that handles all of these requirements. The\nC<Link> command is invoked as in this example:\n\n  Link 'build' => 'src';\n\nThe specified directories are ``linked'' to the specified source\ndirectory. Let's suppose that you setup a source directory, F<src>, with the\nsub-directories F<world> and F<hello> below it, as in the previous\nexample. You could then substitute for the original build lines the\nfollowing:\n\n  Build qw(\n\tbuild/world/Conscript\n\tbuild/hello/Conscript\n  );\n\nNotice that you treat the F<Conscript> file as if it existed in the build\ndirectory. Now if you type the same command as before, you will get the\nfollowing results:\n\n  % cons export\n  Install build/world/world.h as export/include/world.h\n  cc -Iexport/include -c build/hello/hello.c -o build/hello/hello.o\n  cc -Iexport/include -c build/world/world.c -o build/world/world.o\n  ar r build/world/libworld.a build/world/world.o\n  ar: creating build/world/libworld.a\n  ranlib build/world/libworld.a\n  Install build/world/libworld.a as export/lib/libworld.a\n  cc -o build/hello/hello build/hello/hello.o -Lexport/lib -lworld\n  Install build/hello/hello as export/bin/hello\n\nAgain, Cons has taken care of the details for you. In particular, you will\nnotice that all the builds are done using source files and object files from\nthe build directory. For example, F<build/world/world.o> is compiled from\nF<build/world/world.c>, and F<export/include/world.h> is installed from\nF<build/world/world.h>. This is accomplished on most systems by the simple\nexpedient of ``hard'' linking the required files from each source directory\ninto the appropriate build directory.\n\nThe links are maintained correctly by Cons, no matter what you do to the\nsource directory. If you modify a source file, your editor may do this ``in\nplace'' or it may rename it first and create a new file. In the latter case,\nany hard link will be lost. Cons will detect this condition the next time\nthe source file is needed, and will relink it appropriately.\n\nYou'll also notice, by the way, that B<no> changes were required to the\nunderlying F<Conscript> files. And we can go further, as we shall see in the\nnext section.\n\n=head2 Explicit references to the source directory\n\nWhen using the C<Link> command on some operating systems or with some\ntool chains, it's sometimes useful to have a command actually use\nthe path name to the source directory, not the build directory.  For\nexample, on systems that must copy, not \"hard link,\" the F<src/> and\nF<build/> copies of C<Linked> files, using the F<src/> path of a file\nname might make an editor aware that a syntax error must be fixed in the\nsource directory, not the build directory.\n\nYou can tell Cons that you want to use the \"source path\" for a file by\npreceding the file name with a ``!'' (exclamation point).  For example,\nif we add a ``!'' to the beginning of a source file:\n\n  Program $env \"foo\", \"!foo.c\";\t# Notice initial ! on foo.c\n\nCons will compile the target as follows:\n\n  cc -c src/foo.c -o build/foo.o\n  cc -o build/foo build/foo.o\n\nNotice that Cons has compiled the program from the the F<src/foo.c>\nsource file.  Without the initial ``!'', Cons would have compiled the\nprogram using the F<build/foo.c> path name.\n\n\n\n=head1 Variant builds\n\n\n=head2 Hello, World! for baNaNa and peAcH OS's\n\nVariant builds require just another simple extension. Let's take as an\nexample a requirement to allow builds for both the baNaNa and peAcH\noperating systems. In this case, we are using a distributed file system,\nsuch as NFS to access the particular system, and only one or the other of\nthe systems has to be compiled for any given invocation of C<cons>. Here's\none way we could set up the F<Construct> file for our B<Hello, World!>\napplication:\n\n  # Construct file for Hello, World!\n\n  die qq(OS must be specified) unless $OS = $ARG{OS};\n  die qq(OS must be \"peach\" or \"banana\")\n\tif $OS ne \"peach\" && $OS ne \"banana\";\n\n  # Where to put all our shared products.\n  $EXPORT = \"#export/$OS\";\n\n  Export qw( CONS INCLUDE LIB BIN );\n\n  # Standard directories for sharing products.\n  $INCLUDE = \"$EXPORT/include\";\n  $LIB = \"$EXPORT/lib\";\n  $BIN = \"$EXPORT/bin\";\n\n  # A standard construction environment.\n  $CONS = new cons (\n\tCPPPATH => $INCLUDE,\t# Include path for C Compilations\n\tLIBPATH => $LIB,\t# Library path for linking programs\n\tLIBS => '-lworld',\t# List of standard libraries\n  );\n\n  # $BUILD is where we will derive everything.\n  $BUILD = \"#build/$OS\";\n\n  # Tell cons where the source files for $BUILD are.\n  Link $BUILD => 'src';\n\n  Build (\n\t\"$BUILD/hello/Conscript\",\n\t\"$BUILD/world/Conscript\",\n  );\n\nNow if we login to a peAcH system, we can build our B<Hello, World!>\napplication for that platform:\n\n  % cons export OS=peach\n  Install build/peach/world/world.h as export/peach/include/world.h\n  cc -Iexport/peach/include -c build/peach/hello/hello.c -o build/peach/hello/hello.o\n  cc -Iexport/peach/include -c build/peach/world/world.c -o build/peach/world/world.o\n  ar r build/peach/world/libworld.a build/peach/world/world.o\n  ar: creating build/peach/world/libworld.a\n  ranlib build/peach/world/libworld.a\n  Install build/peach/world/libworld.a as export/peach/lib/libworld.a\n  cc -o build/peach/hello/hello build/peach/hello/hello.o -Lexport/peach/lib -lworld\n  Install build/peach/hello/hello as export/peach/bin/hello\n\n\n=head2 Variations on a theme\n\nOther variations of this model are possible. For example, you might decide\nthat you want to separate out your include files into platform dependent and\nplatform independent files. In this case, you'd have to define an\nalternative to C<$INCLUDE> for platform-dependent files. Most F<Conscript>\nfiles, generating purely platform-independent include files, would not have\nto change.\n\nYou might also want to be able to compile your whole system with debugging\nor profiling, for example, enabled. You could do this with appropriate\ncommand line options, such as C<DEBUG=on>. This would then be translated\ninto the appropriate platform-specific requirements to enable debugging\n(this might include turning off optimization, for example). You could\noptionally vary the name space for these different types of systems, but, as\nwe'll see in the next section, it's not B<essential> to do this, since Cons\nis pretty smart about rebuilding things when you change options.\n\n\n=head1 Signatures\n\nCons uses file B<signatures> to decide if a derived file is out-of-date\nand needs rebuilding.  In essence, if the contents of a file change,\nor the manner in which the file is built changes, the file's signature\nchanges as well.  This allows Cons to decide with certainty when a file\nneeds rebuilding, because Cons can detect, quickly and reliably, whether\nany of its dependency files have been changed.\n\n\n=head2 MD5 content and build signatures\n\nCons uses the B<MD5> (B<Message Digest 5>) algorithm to compute file\nsignatures.  The MD5 algorithm computes a strong cryptographic checksum\nfor any given input string.  Cons can, based on configuration, use two\ndifferent MD5 signatures for a given file:\n\nThe B<content signature> of a file is an MD5 checksum of the file's\ncontents.  Consequently, when the contents of a file change, its content\nsignature changes as well.\n\nThe B<build signature> of a file is a combined MD5 checksum of:\n\n=over 4\n\nthe signatures of all the input files used to build the file\n\nthe signatures of all dependency files discovered by source scanners\n(for example, C<.h> files)\n\nthe signatures of all dependency files specified explicitly via the\nC<Depends> method)\n\nthe command-line string used to build the file\n\n=back\n\nThe build signature is, in effect, a digest of all the dependency\ninformation for the specified file.  Consequently, a file's build\nsignature changes whenever any part of its dependency information\nchanges: a new file is added, the contents of a file on which it depends\nchange, there's a change to the command line used to build the file (or\nany of its dependency files), etc.\n\nFor example, in the previous section, the build signature of the\nF<world.o> file will include:\n\n=over 4\n\nthe signature of the F<world.c> file\n\nthe signatures of any header files that Cons detects are included,\ndirectly or indirectly, by F<world.c>\n\nthe text of the actual command line was used to generate F<world.o>\n\n=back\n\nSimilarly, the build signature of the F<libworld.a> file will include\nall the signatures of its constituents (and hence, transitively, the\nsignatures of B<their> constituents), as well as the command line that\ncreated the file.\n\nNote that there is no need for a derived file to depend upon any\nparticular F<Construct> or F<Conscript> file.  If changes to these files\naffect a file, then this will be automatically reflected in its build\nsignature, since relevant parts of the command line are included in the\nsignature. Unrelated F<Construct> or F<Conscript> changes will have no\neffect.\n\n\n=head2 Storing signatures in .consign files\n\nBefore Cons exits, it stores the calculated signatures for all of the\nfiles it built or examined in F<.consign> files, one per directory.\nCons uses this stored information on later invocations to decide if\nderived files need to be rebuilt.\n\nAfter the previous example was compiled, the F<.consign> file in the\nF<build/peach/world> directory looked like this:\n\n  world.h:985533370 - d181712f2fdc07c1f05d97b16bfad904\n  world.o:985533372 2a0f71e0766927c0532977b0d2158981\n  world.c:985533370 - c712f77189307907f4189b5a7ab62ff3\n  libworld.a:985533374 69e568fc5241d7d25be86d581e1fb6aa\n\nAfter the file name and colon, the first number is a timestamp of the\nfile's modification time (on UNIX systems, this is typically the number\nof seconds since January 1st, 1970).  The second value is the build\nsignature of the file (or ``-'' in the case of files with no build\nsignature--that is, source files).  The third value, if any, is the\ncontent signature of the file.\n\n\n=head2 Using build signatures to decide when to rebuild files\n\nWhen Cons is deciding whether to build or rebuild a derived file, it\nfirst computes the file's current build signature.  If the file doesn't\nexist, it must obviously be built.\n\nIf, however, the file already exists, Cons next compares the\nmodification timestamp of the file against the timestamp value in\nthe F<.consign> file.  If the timestamps match, Cons compares the\nnewly-computed build signature against the build signature in the\nF<.consign> file.  If the timestamps do not match or the build\nsignatures do not match, the derived file is rebuilt.\n\nAfter the file is built or rebuilt, Cons arranges to store the\nnewly-computed build signature in the F<.consign> file when it exits.\n\n\n=head2 Signature example\n\nThe use of these signatures is an extremely simple, efficient, and\neffective method of improving--dramatically--the reproducibility of a\nsystem.\n\nWe'll demonstrate this with a simple example:\n\n  # Simple \"Hello, World!\" Construct file\n  $CFLAGS = '-g' if $ARG{DEBUG} eq 'on';\n  $CONS = new cons(CFLAGS => $CFLAGS);\n  Program $CONS 'hello', 'hello.c';\n\nNotice how Cons recompiles at the appropriate times:\n\n  % cons hello\n  cc -c hello.c -o hello.o\n  cc -o hello hello.o\n  % cons hello\n  cons: \"hello\" is up-to-date.\n  % cons DEBUG=on hello\n  cc -g -c hello.c -o hello.o\n  cc -o hello hello.o\n  % cons DEBUG=on hello\n  cons: \"hello\" is up-to-date.\n  % cons hello\n  cc -c hello.c -o hello.o\n  cc -o hello hello.o\n\n\n=head2 Source-file signature configuration\n\nCons provides a C<SourceSignature> method that allows you to configure\nhow the signature should be calculated for any source file when its\nsignature is being used to decide if a dependent file is up-to-date.\nThe arguments to the C<SourceSignature> method consist of one or more\npairs of strings:\n\n  SourceSignature 'auto/*.c' => 'content',\n\t\t  '*' => 'stored-content';\n\nThe first string in each pair is a pattern to match against derived file\npath names. The pattern is a file-globbing pattern, not a Perl regular\nexpression; the pattern <*.l> will match all Lex source files.  The C<*>\nwildcard will match across directory separators; the pattern C<foo/*.c>\nwould match all C source files in any subdirectory underneath the C<foo>\nsubdirectory.\n\nThe second string in each pair contains one of the following keywords to\nspecify how signatures should be calculated for source files that match\nthe pattern.  The available keywords are:\n\n=over 4\n\n=item content\n\nUse the content signature of the source file when calculating signatures\nof files that depend on it.  This guarantees correct calculation of the\nfile's signature for all builds, by telling Cons to read the contents of\na source file to calculate its content signature each time it is run.\n\n=item stored-content\n\nUse the source file's content signature as stored in the F<.consign>\nfile, provided the file's timestamp matches the cached timestamp value\nin the F<.consign> file.  This optimizes performance, with the slight\nrisk of an incorrect build if a source file's contents have been changed\nso quickly after its previous update that the timestamp still matches\nthe stored timestamp in the F<.consign> file even though the contents\nhave changed.\n\n=back\n\nThe Cons default behavior of always calculating a source file's\nsignature from the file's contents is equivalent to specifying:\n\n  SourceSignature '*' => 'content';\n\nThe C<*> will match all source files.  The C<content> keyword\nspecifies that Cons will read the contents of a source file to calculate\nits signature each time it is run.\n\nA useful global performance optimization is:\n\n  SourceSignature '*' => 'stored-content';\n\nThis specifies that Cons will use pre-computed content signatures\nfrom F<.consign> files, when available, rather than re-calculating a\nsignature from the the source file's contents each time Cons is run.  In\npractice, this is safe for most build situations, and only a problem\nwhen source files are changed automatically (by scripts, for example).\nThe Cons default, however, errs on the side of guaranteeing a correct\nbuild in all situations.\n\nCons tries to match source file path names against the patterns in the\norder they are specified in the C<SourceSignature> arguments:\n\n  SourceSignature '/usr/repository/objects/*' => 'stored-content',\n\t\t  '/usr/repository/*' => 'content',\n\t\t  '*.y' => 'content',\n\t\t  '*' => 'stored-content';\n\nIn this example, all source files under the F</usr/repository/objects>\ndirectory will use F<.consign> file content signatures, source files\nanywhere else underneath F</usr/repository> will not use F<.consign>\nsignature values, all Yacc source files (C<*.y>) anywhere else will not\nuse F<.consign> signature values, and any other source file will use\nF<.consign> signature values.\n\n\n=head2 Derived-file signature configuration\n\nCons provides a C<SIGNATURE> construction variable that allows you to\nconfigure how signatures are calculated for any derived file when its\nsignature is being used to decide if a dependent file is up-to-date.\nThe value of the C<SIGNATURE> construction variable is a Perl array\nreference that holds one or more pairs of strings, like the arguments to\nthe C<SourceSignature> method.\n\nThe first string in each pair is a pattern to match against derived file\npath names. The pattern is a file-globbing pattern, not a Perl regular\nexpression; the pattern `*.obj' will match all (Win32) object files.\nThe C<*> wildcard will match across directory separators; the pattern\n`foo/*.a' would match all (UNIX) library archives in any subdirectory\nunderneath the foo subdirectory.\n\nThe second string in each pair contains one of the following keywords\nto specify how signatures should be calculated for derived files that\nmatch the pattern.  The available keywords are the same as for the\nC<SourceSignature> method, with an additional keyword:\n\n=over 4\n\n=item build\n\nUse the build signature of the derived file when calculating signatures\nof files that depend on it.  This guarantees correct builds by forcing\nCons to rebuild any and all files that depend on the derived file.\n\n=item content\n\nUse the content signature of the derived file when calculating signatures\nof files that depend on it.  This guarantees correct calculation of the\nfile's signature for all builds, by telling Cons to read the contents of\na derived file to calculate its content signature each time it is run.\n\n=item stored-content\n\nUse the derived file's content signature as stored in the F<.consign>\nfile, provided the file's timestamp matches the cached timestamp value\nin the F<.consign> file.  This optimizes performance, with the slight\nrisk of an incorrect build if a derived file's contents have been\nchanged so quickly after a Cons build that the file's timestamp still\nmatches the stored timestamp in the F<.consign> file.\n\n=back\n\nThe Cons default behavior (as previously described) for using\nderived-file signatures is equivalent to:\n\n  $env = new cons(SIGNATURE => ['*' => 'build']);\n\nThe C<*> will match all derived files.  The C<build> keyword specifies\nthat all derived files' build signatures will be used when calculating\nwhether a dependent file is up-to-date.\n\nA useful alternative default C<SIGNATURE> configuration for many sites:\n\n  $env = new cons(SIGNATURE => ['*' => 'content']);\n\nIn this configuration, derived files have their signatures calculated\nfrom the file contents.  This adds slightly to Cons' workload, but has\nthe useful effect of \"stopping\" further rebuilds if a derived file is\nrebuilt to exactly the same file contents as before, which usually\noutweighs the additional computation Cons must perform.\n\nFor example, changing a comment in a C file and recompiling should\ngenerate the exact same object file (assuming the compiler doesn't\ninsert a timestamp in the object file's header).  In that case,\nspecifying C<content> or C<stored-content> for the signature calculation\nwill cause Cons to recognize that the object file did not actually\nchange as a result of being rebuilt, and libraries or programs that\ninclude the object file will not be rebuilt.  When C<build> is\nspecified, however, Cons will only \"know\" that the object file was\nrebuilt, and proceed to rebuild any additional files that include the\nobject file.\n\nNote that Cons tries to match derived file path names against the\npatterns in the order they are specified in the C<SIGNATURE> array\nreference:\n\n  $env = new cons(SIGNATURE => ['foo/*.o' => 'build',\n\t\t\t\t'*.o' => 'content',\n\t\t\t\t'*.a' => 'stored-content',\n\t\t\t\t'*' => 'content']);\n\nIn this example, all object files underneath the F<foo> subdirectory\nwill use build signatures, all other object files (including object\nfiles underneath other subdirectories!) will use F<.consign> file\ncontent signatures, libraries will use F<.consign> file build\nsignatures, and all other derived files will use content signatures.\n\n\n=head2 Debugging signature calculation\n\nCons provides a C<-S> option that can be used to specify what internal\nPerl package Cons should use to calculate signatures.  The default Cons\nbehavior is equivalent to specifying C<-S md5> on the command line.\n\nThe only other package (currently) available is an C<md5::debug>\npackage that prints out detailed information about the MD5 signature\ncalculations performed by Cons:\n\n  % cons -S md5::debug hello\n  sig::md5::srcsig(hello.c)\n          => |52d891204c62fe93ecb95281e1571938|\n  sig::md5::collect(52d891204c62fe93ecb95281e1571938)\n          => |fb0660af4002c40461a2f01fbb5ffd03|\n  sig::md5::collect(52d891204c62fe93ecb95281e1571938,\n                    fb0660af4002c40461a2f01fbb5ffd03,\n                    cc   -c %< -o %>)\n          => |f7128da6c3fe3c377dc22ade70647b39|\n  sig::md5::current(||\n                 eq |f7128da6c3fe3c377dc22ade70647b39|)\n  cc -c hello.c -o hello.o\n  sig::md5::collect()\n          => |d41d8cd98f00b204e9800998ecf8427e|\n  sig::md5::collect(f7128da6c3fe3c377dc22ade70647b39,\n                    d41d8cd98f00b204e9800998ecf8427e,\n                    cc  -o %> %<  )\n          => |a0bdce7fd09e0350e7efbbdb043a00b0|\n  sig::md5::current(||\n                 eq |a0bdce7fd09e0350e7efbbdb043a00b0|)\n  cc -o hello, hello.o\n\n\n=head1 Code Repositories\n\nMany software development organizations will have one or more central\nrepository directory trees containing the current source code for one or\nmore projects, as well as the derived object files, libraries, and\nexecutables.  In order to reduce unnecessary recompilation, it is useful to\nuse files from the repository to build development software--assuming, of\ncourse, that no newer dependency file exists in the local build tree.\n\n\n=head2 Repository\n\nCons provides a mechanism to specify a list of code repositories that will\nbe searched, in-order, for source files and derived files not found in the\nlocal build directory tree.\n\nThe following lines in a F<Construct> file will instruct Cons to look first\nunder the F</usr/experiment/repository> directory and then under the\nF</usr/product/repository> directory:\n\n  Repository qw (\n\t/usr/experiment/repository\n\t/usr/product/repository\n  );\n\nThe repository directories specified may contain source files, derived files\n(objects, libraries and executables), or both.  If there is no local file\n(source or derived) under the directory in which Cons is executed, then the\nfirst copy of a same-named file found under a repository directory will be\nused to build any local derived files.\n\nCons maintains one global list of repositories directories.  Cons will\neliminate the current directory, and any non-existent directories, from the\nlist.\n\n\n=head2 Finding the Construct file in a Repository\n\nCons will also search for F<Construct> and F<Conscript> files in the\nrepository tree or trees.  This leads to a chicken-and-egg situation,\nthough: how do you look in a repository tree for a F<Construct> file if the\nF<Construct> file tells you where the repository is?  To get around this,\nrepositories may be specified via C<-R> options on the command line:\n\n  % cons -R /usr/experiment/repository -R /usr/product/repository .\n\nAny repository directories specified in the F<Construct> or F<Conscript>\nfiles will be appended to the repository directories specified by\ncommand-line C<-R> options.\n\n=head2 Repository source files\n\nIf the source code (include the F<Conscript> file) for the library version\nof the I<Hello, World!> C application is in a repository (with no derived\nfiles), Cons will use the repository source files to create the local object\nfiles and executable file:\n\n  % cons -R /usr/src_only/repository hello\n  gcc -c /usr/src_only/repository/hello.c -o hello.o\n  gcc -c /usr/src_only/repository/world.c -o world.o\n  ar r libworld.a world.o\n  ar: creating libworld.a\n  ranlib libworld.a\n  gcc -o hello hello.o libworld.a\n\nCreating a local source file will cause Cons to rebuild the appropriate\nderived file or files:\n\n  % pico world.c\n    [EDIT]\n  % cons -R /usr/src_only/repository hello\n  gcc -c world.c -o world.o\n  ar r libworld.a world.o\n  ar: creating libworld.a\n  ranlib libworld.a\n  gcc -o hello hello.o libworld.a\n\nAnd removing the local source file will cause Cons to revert back to\nbuilding the derived files from the repository source:\n\n  % rm world.c\n  % cons -R /usr/src_only/repository hello\n  gcc -c /usr/src_only/repository/world.c -o world.o\n  ar r libworld.a world.o\n  ar: creating libworld.a\n  ranlib libworld.a\n  gcc -o hello hello.o libworld.a\n\n\n=head2 Repository derived files\n\nIf a repository tree contains derived files (usually object files,\nlibraries, or executables), Cons will perform its normal signature\ncalculation to decide whether the repository file is up-to-date or a derived\nfile must be built locally.  This means that, in order to ensure correct\nsignature calculation, a repository tree must also contain the F<.consign>\nfiles that were created by Cons when generating the derived files.\n\nThis would usually be accomplished by building the software in the\nrepository (or, alternatively, in a build directory, and then copying the\nresult to the repository):\n\n  % cd /usr/all/repository\n  % cons hello\n  gcc -c hello.c -o hello.o\n  gcc -c world.c -o world.o\n  ar r libworld.a world.o\n  ar: creating libworld.a\n  ranlib libworld.a\n  gcc -o hello hello.o libworld.a\n\n(This is safe even if the F<Construct> file lists the F</usr/all/repository>\ndirectory in a C<Repository> command because Cons will remove the current\ndirectory from the repository list.)\n\nNow if we want to build a copy of the application with our own F<hello.c>\nfile, we only need to create the one necessary source file, and use the\nC<-R> option to have Cons use other files from the repository:\n\n  % mkdir $HOME/build1\n  % cd $HOME/build1\n  % ed hello.c\n    [EDIT]\n  % cons -R /usr/all/repository hello\n  gcc -c hello.c -o hello.o\n  gcc -o hello hello.o /usr/all/repository/libworld.a\n\nNotice that Cons has not bothered to recreate a local F<libworld.a> library\n(or recompile the F<world.o> module), but instead uses the already-compiled\nversion from the repository.\n\nBecause the MD5 signatures that Cons puts in the F<.consign> file contain\ntimestamps for the derived files, the signature timestamps must match the\nfile timestamps for a signature to be considered valid.\n\nSome software systems may alter the timestamps on repository files (by\ncopying them, e.g.), in which case Cons will, by default, assume the\nrepository signatures are invalid and rebuild files unnecessarily.  This\nbehavior may be altered by specifying:\n\n  Repository_Sig_Times_OK 0;\n\nThis tells Cons to ignore timestamps when deciding whether a signature is\nvalid.  (Note that avoiding this sanity check means there must be proper\ncontrol over the repository tree to ensure that the derived files cannot be\nmodified without updating the F<.consign> signature.)\n\n\n=head2 Local copies of files\n\nIf the repository tree contains the complete results of a build, and we try\nto build from the repository without any files in our local tree, something\nmoderately surprising happens:\n\n  % mkdir $HOME/build2\n  % cd $HOME/build2\n  % cons -R /usr/all/repository hello\n  cons: \"hello\" is up-to-date.\n\nWhy does Cons say that the F<hello> program is up-to-date when there is no\nF<hello> program in the local build directory?  Because the repository (not\nthe local directory) contains the up-to-date F<hello> program, and Cons\ncorrectly determines that nothing needs to be done to rebuild this\nup-to-date copy of the file.\n\nThere are, however, many times in which it is appropriate to ensure that a\nlocal copy of a file always exists.  A packaging or testing script, for\nexample, may assume that certain generated files exist locally.  Instead of\nmaking these subsidiary scripts aware of the repository directory, the\nC<Local> command may be added to a F<Construct> or F<Conscript> file to\nspecify that a certain file or files must appear in the local build\ndirectory:\n\n  Local qw(\n\thello\n  );\n\nThen, if we re-run the same command, Cons will make a local copy of the\nprogram from the repository copy (telling you that it is doing so):\n\n  % cons -R /usr/all/repository hello\n  Local copy of hello from /usr/all/repository/hello\n  cons: \"hello\" is up-to-date.\n\nNotice that, because the act of making the local copy is not considered a\n\"build\" of the F<hello> file, Cons still reports that it is up-to-date.\n\nCreating local copies is most useful for files that are being installed into\nan intermediate directory (for sharing with other directories) via the\nC<Install> command.  Accompanying the C<Install> command for a file with a\ncompanion C<Local> command is so common that Cons provides a\nC<Install_Local> command as a convenient way to do both:\n\n  Install_Local $env, '#export', 'hello';\n\nis exactly equivalent to:\n\n  Install $env '#export', 'hello';\n  Local '#export/hello';\n\nBoth the C<Local> and C<Install_Local> commands update the local F<.consign>\nfile with the appropriate file signatures, so that future builds are\nperformed correctly.\n\n\n=head2 Repository dependency analysis\n\nDue to its built-in scanning, Cons will search the specified repository\ntrees for included F<.h> files.  Unless the compiler also knows about the\nrepository trees, though, it will be unable to find F<.h> files that only\nexist in a repository.  If, for example, the F<hello.c> file includes the\nF<hello.h> file in its current directory:\n\n  % cons -R /usr/all/repository hello\n  gcc -c /usr/all/repository/hello.c -o hello.o\n  /usr/all/repository/hello.c:1: hello.h: No such file or directory\n\nSolving this problem forces some requirements onto the way construction\nenvironments are defined and onto the way the C C<#include> preprocessor\ndirective is used to include files.\n\nIn order to inform the compiler about the repository trees, Cons will add\nappropriate C<-I> flags to the compilation commands.  This means that the\nC<CPPPATH> variable in the construction environment must explicitly specify\nall subdirectories which are to be searched for included files, including the\ncurrent directory.  Consequently, we can fix the above example by changing\nthe environment creation in the F<Construct> file as follows:\n\n  $env = new cons(\n\tCC\t=> 'gcc',\n\tCPPPATH\t=> '.',\n\tLIBS\t=> 'libworld.a',\n  );\n\nDue to the definition of the C<CPPPATH> variable, this yields, when we\nre-execute the command:\n\n  % cons -R /usr/all/repository hello\n  gcc -c -I. -I/usr/all/repository /usr/all/repository/hello.c -o hello.o\n  gcc -o hello hello.o /usr/all/repository/libworld.a\n\nThe order of the C<-I> flags replicates, for the C preprocessor, the same\nrepository-directory search path that Cons uses for its own dependency\nanalysis.  If there are multiple repositories and multiple C<CPPPATH>\ndirectories, Cons will append the repository directories to the beginning of\neach C<CPPPATH> directory, rapidly multiplying the number of C<-I> flags.\nAs an extreme example, a F<Construct> file containing:\n\n  Repository qw(\n\t/u1\n\t/u2\n  );\n\n  $env = new cons(\n\tCPPPATH\t=> 'a:b:c',\n  );\n\nWould yield a compilation command of:\n\n  cc -Ia -I/u1/a -I/u2/a -Ib -I/u1/b -I/u2/b -Ic -I/u1/c -I/u2/c -c hello.c -o hello.o\n\nIn order to shorten the command lines as much as possible, Cons will\nremove C<-I> flags for any directories, locally or in the repositories,\nwhich do not actually exist.  (Note that the C<-I> flags are not included\nin the MD5 signature calculation for the target file, so the target will\nnot be recompiled if the compilation command changes due to a directory\ncoming into existence.)\n\nBecause Cons relies on the compiler's C<-I> flags to communicate the\norder in which repository directories must be searched, Cons' handling\nof repository directories is fundamentally incompatible with using\ndouble-quotes on the C<#include> directives in any C source code that\nyou plan to modify:\n\n  #include \"file.h\"\t/* DON'T USE DOUBLE-QUOTES LIKE THIS */\n\nThis is because most C preprocessors, when faced with such a directive, will\nalways first search the directory containing the source file.  This\nundermines the elaborate C<-I> options that Cons constructs to make the\npreprocessor conform to its preferred search path.\n\nConsequently, when using repository trees in Cons, B<always> use\nangle-brackets for included files in any C source (.c or .h) files that\nyou plan to modify locally:\n\n  #include <file.h>\t/* USE ANGLE-BRACKETS INSTEAD */\n\nCode that will not change can still safely use double quotes on #include\nlines.\n\n\n=head2 Repository_List\n\nCons provides a C<Repository_List> command to return a list of all\nrepository directories in their current search order.  This can be used for\ndebugging, or to do more complex Perl stuff:\n\n  @list = Repository_List;\n  print join(' ', @list), \"\\n\";\n\n\n=head2 Repository interaction with other Cons features\n\nCons' handling of repository trees interacts correctly with other Cons\nfeatures--which is to say, it generally does what you would expect.\n\nMost notably, repository trees interact correctly, and rather powerfully,\nwith the 'Link' command.  A repository tree may contain one or more\nsubdirectories for version builds established via C<Link> to a source\nsubdirectory.  Cons will search for derived files in the appropriate build\nsubdirectories under the repository tree.\n\n\n=head1 Default targets\n\nUntil now, we've demonstrated invoking Cons with an explicit target\nto build:\n\n  % cons hello\n\nNormally, Cons does not build anything unless a target is specified,\nbut specifying '.' (the current directory) will build everything:\n\n  % cons\t\t# does not build anything\n\n  % cons .\t\t# builds everything under the top-level directory\n\nAdding the C<Default> method to any F<Construct> or F<Conscript> file will add\nthe specified targets to a list of default targets.  Cons will build\nthese defaults if there are no targets specified on the command line.\nSo adding the following line to the top-level F<Construct> file will mimic\nMake's typical behavior of building everything by default:\n\n  Default '.';\n\nThe following would add the F<hello> and F<goodbye> commands (in the\nsame directory as the F<Construct> or F<Conscript> file) to the default list:\n\n  Default qw(\n\thello\n\tgoodbye\n  );\n\nThe C<Default> method may be used more than once to add targets to the\ndefault list.\n\n=head1 Selective builds\n\nCons provides two methods for reducing the size of given build. The first is\nby specifying targets on the command line, and the second is a method for\npruning the build tree. We'll consider target specification first.\n\n\n=head2 Selective targeting\n\nLike make, Cons allows the specification of ``targets'' on the command\nline. Cons targets may be either files or directories. When a directory is\nspecified, this is simply a short-hand notation for every derivable\nproduct--that Cons knows about--in the specified directory and below. For\nexample:\n\n  % cons build/hello/hello.o\n\nmeans build F<hello.o> and everything that F<hello.o> might need. This is\nfrom a previous version of the B<Hello, World!> program in which F<hello.o>\ndepended upon F<export/include/world.h>. If that file is not up-to-date\n(because someone modified F<src/world/world.h)>, then it will be rebuilt,\neven though it is in a directory remote from F<build/hello>.\n\nIn this example:\n\n  % cons build\n\nEverything in the F<build> directory is built, if necessary. Again, this may\ncause more files to be built. In particular, both F<export/include/world.h>\nand F<export/lib/libworld.a> are required by the F<build/hello> directory,\nand so they will be built if they are out-of-date.\n\nIf we do, instead:\n\n  % cons export\n\nthen only the files that should be installed in the export directory will be\nrebuilt, if necessary, and then installed there. Note that C<cons build>\nmight build files that C<cons export> doesn't build, and vice-versa.\n\n\n=head2 No ``special'' targets\n\nWith Cons, make-style ``special'' targets are not required. The simplest\nanalog with Cons is to use special F<export> directories, instead. Let's\nsuppose, for example, that you have a whole series of unit tests that are\nassociated with your code. The tests live in the source directory near the\ncode. Normally, however, you don't want to build these tests. One solution\nis to provide all the build instructions for creating the tests, and then to\ninstall the tests into a separate part of the tree. If we install the tests\nin a top-level directory called F<tests>, then:\n\n  % cons tests\n\nwill build all the tests.\n\n  % cons export\n\nwill build the production version of the system (but not the tests), and:\n\n  % cons build\n\nshould probably be avoided (since it will compile tests unnecessarily).\n\nIf you want to build just a single test, then you could explicitly name the\ntest (in either the F<tests> directory or the F<build> directory). You could\nalso aggregate the tests into a convenient hierarchy within the tests\ndirectory. This hierarchy need not necessarily match the source hierarchy,\nin much the same manner that the include hierarchy probably doesn't match\nthe source hierarchy (the include hierarchy is unlikely to be more than two\nlevels deep, for C programs).\n\nIf you want to build absolutely everything in the tree (subject to whatever\noptions you select), you can use:\n\n  % cons .\n\nThis is not particularly efficient, since it will redundantly walk all the\ntrees, including the source tree. The source tree, of course, may have\nbuildable objects in it--nothing stops you from doing this, even if you\nnormally build in a separate build tree.\n\n\n=head1 Build Pruning\n\nIn conjunction with target selection, B<build pruning> can be used to reduce\nthe scope of the build. In the previous peAcH and baNaNa example, we have\nalready seen how script-driven build pruning can be used to make only half\nof the potential build available for any given invocation of C<cons>. Cons\nalso provides, as a convenience, a command line convention that allows you\nto specify which F<Conscript> files actually get ``built''--that is,\nincorporated into the build tree. For example:\n\n  % cons build +world\n\nThe C<+> argument introduces a Perl regular expression. This must, of\ncourse, be quoted at the shell level if there are any shell meta-characters\nwithin the expression. The expression is matched against each F<Conscript>\nfile which has been mentioned in a C<Build> statement, and only those\nscripts with matching names are actually incorporated into the build\ntree. Multiple such arguments are allowed, in which case a match against any\nof them is sufficient to cause a script to be included.\n\nIn the example, above, the F<hello> program will not be built, since Cons\nwill have no knowledge of the script F<hello/Conscript>. The F<libworld.a>\narchive will be built, however, if need be.\n\nThere are a couple of uses for build pruning via the command line. Perhaps\nthe most useful is the ability to make local changes, and then, with\nsufficient knowledge of the consequences of those changes, restrict the size\nof the build tree in order to speed up the rebuild time. A second use for\nbuild pruning is to actively prevent the recompilation of certain files that\nyou know will recompile due to, for example, a modified header file. You may\nknow that either the changes to the header file are immaterial, or that the\nchanges may be safely ignored for most of the tree, for testing\npurposes.With Cons, the view is that it is pragmatic to admit this type of\nbehavior, with the understanding that on the next full build everything that\nneeds to be rebuilt will be. There is no equivalent to a ``make touch''\ncommand, to mark files as permanently up-to-date. So any risk that is\nincurred by build pruning is mitigated. For release quality work, obviously,\nwe recommend that you do not use build pruning (it's perfectly OK to use\nduring integration, however, for checking compilation, etc. Just be sure to\ndo an unconstrained build before committing the integration).\n\n\n=head1 Temporary overrides\n\nCons provides a very simple mechanism for overriding aspects of a build. The\nessence is that you write an override file containing one or more\nC<Override> commands, and you specify this on the command line, when you run\nC<cons>:\n\n  % cons -o over export\n\nwill build the F<export> directory, with all derived files subject to the\noverrides present in the F<over> file. If you leave out the C<-o> option,\nthen everything necessary to remove all overrides will be rebuilt.\n\n\n=head2 Overriding environment variables\n\nThe override file can contain two types of overrides. The first is incoming\nenvironment variables. These are normally accessible by the F<Construct>\nfile from the C<%ENV> hash variable. These can trivially be overridden in\nthe override file by setting the appropriate elements of C<%ENV> (these\ncould also be overridden in the user's environment, of course).\n\n\n=head2 The Override command\n\nThe second type of override is accomplished with the C<Override> command,\nwhich looks like this:\n\n  Override <regexp>, <var1> => <value1>, <var2> => <value2>, ...;\n\nThe regular expression I<regexp> is matched against every derived file that\nis a candidate for the build. If the derived file matches, then the\nvariable/value pairs are used to override the values in the construction\nenvironment associated with the derived file.\n\nLet's suppose that we have a construction environment like this:\n\n  $CONS = new cons(\n\tCOPT => '',\n\tCDBG => '-g',\n\tCFLAGS => '%COPT %CDBG',\n  );\n\nThen if we have an override file F<over> containing this command:\n\n  Override '\\.o$', COPT => '-O', CDBG => '';\n\nthen any C<cons> invocation with C<-o over> that creates F<.o> files via\nthis environment will cause them to be compiled with C<-O >and no C<-g>. The\noverride could, of course, be restricted to a single directory by the\nappropriate selection of a regular expression.\n\nHere's the original version of the Hello, World! program, built with this\nenvironment. Note that Cons rebuilds the appropriate pieces when the\noverride is applied or removed:\n\n  % cons hello\n  cc -g -c hello.c -o hello.o\n  cc -o hello hello.o\n  % cons -o over hello\n  cc -O -c hello.c -o hello.o\n  cc -o hello hello.o\n  % cons -o over hello\n  cons: \"hello\" is up-to-date.\n  % cons hello\n  cc -g -c hello.c -o hello.o\n  cc -o hello hello.o\n\nIt's important that the C<Override> command only be used for temporary,\non-the-fly overrides necessary for development because the overrides are not\nplatform independent and because they rely too much on intimate knowledge of\nthe workings of the scripts. For temporary use, however, they are exactly\nwhat you want.\n\nNote that it is still useful to provide, say, the ability to create a fully\noptimized version of a system for production use--from the F<Construct> and\nF<Conscript> files. This way you can tailor the optimized system to the\nplatform. Where optimizer trade-offs need to be made (particular files may\nnot be compiled with full optimization, for example), then these can be\nrecorded for posterity (and reproducibility) directly in the scripts.\n\n\n=head1 More on construction environments\n\nAs previously mentioned, a B<construction environment> is an object that\nhas a set of keyword/value pairs and a set of methods, and which is used\nto tell Cons how target files should be built.  This section describes\nhow Cons uses and expands construction environment values to control its\nbuild behavior.\n\n=head2 Construction variable expansion\n\nConstruction variables from a construction environment are expanded\nby preceding the keyword with a C<%> (percent sign):\n\n  Construction variables:\n\tXYZZY => 'abracadabra',\n\n  The string:  \"The magic word is:  %XYZZY!\"\n  expands to:  \"The magic word is:  abracadabra!\"\n\nA construction variable name may be surrounded by C<{> and C<}> (curly\nbraces), which are stripped as part of the expansion.  This can\nsometimes be necessary to separate a variable expansion from trailing\nalphanumeric characters:\n\n  Construction variables:\n\tOPT    => 'value1',\n\tOPTION => 'value2',\n\n  The string:  \"%OPT %{OPT}ION %OPTION %{OPTION}\"\n  expands to:  \"value1 value1ION value2 value2\"\n\nConstruction variable expansion is recursive--that is, a string\ncontaining C<%->expansions after substitution will be re-expanded until\nno further substitutions can be made:\n\n  Construction variables:\n\tSTRING => 'The result is:  %FOO',\n\tFOO    => '%BAR',\n\tBAR    => 'final value',\n\n  The string:  \"The string says:  %STRING\"\n  expands to:  \"The string says:  The result is:  final value\"\n\nIf a construction variable is not defined in an environment, then the\nnull string is substituted:\n\n  Construction variables:\n\tFOO => 'value1',\n\tBAR => 'value2',\n\n  The string:  \"%FOO <%NO_VARIABLE> %BAR\"\n  expands to:  \"value1 <> value2\"\n\nA doubled C<%%> will be replaced by a single C<%>:\n\n  The string:  \"Here is a percent sign:  %%\"\n  expands to:  \"Here is a percent sign: %\"\n\n=head2 Default construction variables\n\nWhen you specify no arguments when creating a new construction\nenvironment:\n\n  $env = new cons();\n\nCons creates a reference to a new, default construction\nenvironment. This contains a number of construction variables and some\nmethods. At the present writing, the default construction variables on a\nUNIX system are:\n\n  CC            => 'cc',\n  CFLAGS        => '',\n  CCCOM         => '%CC %CFLAGS %_IFLAGS -c %< -o %>',\n  CXX           => '%CC',\n  CXXFLAGS      => '%CFLAGS',\n  CXXCOM        => '%CXX %CXXFLAGS %_IFLAGS -c %< -o %>',\n  INCDIRPREFIX  => '-I',\n  INCDIRSUFFIX  => '',\n  LINK          => '%CXX',\n  LINKCOM       => '%LINK %LDFLAGS -o %> %< %_LDIRS %LIBS',\n  LINKMODULECOM => '%LD -r -o %> %<',\n  LIBDIRPREFIX  => '-L',\n  LIBDIRSUFFIX  => '',\n  AR\t\t=> 'ar',\n  ARFLAGS\t=> 'r',\n  ARCOM\t\t=> ['%AR %ARFLAGS %> %<', '%RANLIB %>'],\n  RANLIB\t=> 'ranlib',\n  AS\t\t=> 'as',\n  ASFLAGS\t=> '',\n  ASCOM\t\t=> '%AS %ASFLAGS %< -o %>',\n  LD\t\t=> 'ld',\n  LDFLAGS\t=> '',\n  PREFLIB\t=> 'lib',\n  SUFLIB\t=> '.a',\n  SUFLIBS\t=> '.so:.a',\n  SUFOBJ\t=> '.o',\n  SIGNATURE     => [ '*' => 'build' ],\n  ENV\t\t=> { 'PATH' => '/bin:/usr/bin' },\n\n\nAnd on a Win32 system (Windows NT), the default construction variables\nare (unless the default rule style is set using the B<DefaultRules>\nmethod):\n\n  CC\t\t=> 'cl',\n  CFLAGS\t=> '/nologo',\n  CCCOM\t\t=> '%CC %CFLAGS %_IFLAGS /c %< /Fo%>',\n  CXXCOM        => '%CXX %CXXFLAGS %_IFLAGS /c %< /Fo%>',\n  INCDIRPREFIX  => '/I',\n  INCDIRSUFFIX  => '',\n  LINK          => 'link',\n  LINKCOM       => '%LINK %LDFLAGS /out:%> %< %_LDIRS %LIBS',\n  LINKMODULECOM => '%LD /r /o %> %<',\n  LIBDIRPREFIX  => '/LIBPATH:',\n  LIBDIRSUFFIX  => '',\n  AR            => 'lib',\n  ARFLAGS       => '/nologo ',\n  ARCOM         => \"%AR %ARFLAGS /out:%> %<\",\n  RANLIB        => '',\n  LD            => 'link',\n  LDFLAGS       => '/nologo ',\n  PREFLIB       => '',\n  SUFEXE\t=> '.exe',\n  SUFLIB\t=> '.lib',\n  SUFLIBS\t=> '.dll:.lib',\n  SUFOBJ\t=> '.obj',\n  SIGNATURE     => [ '*' => 'build' ],\n\nThese variables are used by the various methods associated with the\nenvironment. In particular, any method that ultimately invokes an external\ncommand will substitute these variables into the final command, as\nappropriate. For example, the C<Objects> method takes a number of source\nfiles and arranges to derive, if necessary, the corresponding object\nfiles:\n\n  Objects $env 'foo.c', 'bar.c';\n\nThis will arrange to produce, if necessary, F<foo.o> and F<bar.o>. The\ncommand invoked is simply C<%CCCOM>, which expands, through substitution,\nto the appropriate external command required to build each object. The\nsubstitution rules will be discussed in detail in the next section.\n\nThe construction variables are also used for other purposes. For example,\nC<CPPPATH> is used to specify a colon-separated path of include\ndirectories. These are intended to be passed to the C preprocessor and are\nalso used by the C-file scanning machinery to determine the dependencies\ninvolved in a C Compilation.\n\nVariables beginning with underscore are created by various methods,\nand should normally be considered ``internal'' variables. For example,\nwhen a method is called which calls for the creation of an object from\na C source, the variable C<_IFLAGS> is created: this corresponds to the\nC<-I> switches required by the C compiler to represent the directories\nspecified by C<CPPPATH>.\n\nNote that, for any particular environment, the value of a variable is set\nonce, and then never reset (to change a variable, you must create a new\nenvironment. Methods are provided for copying existing environments for this\npurpose). Some internal variables, such as C<_IFLAGS> are created on demand,\nbut once set, they remain fixed for the life of the environment.\n\nThe C<CFLAGS>, C<LDFLAGS>, and C<ARFLAGS> variables all supply a place\nfor passing options to the compiler, loader, and archiver, respectively.\n\nThe C<INCDIRPREFIX> and C<INCDIRSUFFIX> variables specify option\nstrings to be appended to the beginning and end, respectively, of each\ninclude directory so that the compiler knows where to find F<.h> files.\nSimilarly, the C<LIBDIRPREFIX> and C<LIBDIRSUFFIX> variables specify the\noption string to be appended to the beginning of and end, respectively,\nof each directory that the linker should search for libraries.\n\nAnother variable, C<ENV>, is used to determine the system environment during\nthe execution of an external command. By default, the only environment\nvariable that is set is C<PATH>, which is the execution path for a UNIX\ncommand. For the utmost reproducibility, you should really arrange to set\nyour own execution path, in your top-level F<Construct> file (or perhaps by\nimporting an appropriate construction package with the Perl C<use>\ncommand). The default variables are intended to get you off the ground.\n\n=head2 Expanding variables in construction commands\n\nWithin a construction command, construction variables will be expanded\naccording to the rules described above.  In addition to normal variable\nexpansion from the construction environment, construction commands also\nexpand the following pseudo-variables to insert the specific input and\noutput files in the command line that will be executed:\n\n=over 10\n\n=item %>\n\nThe target file name.  In a multi-target command, this expands to the\nfirst target mentioned.)\n\n=item %0\n\nSame as C<%E<gt>>.\n\n=item %1, %2, ..., %9\n\nThese refer to the first through ninth input file, respectively.\n\n=item %E<lt>\n\nThe full set of input file names. If any of these have been used\nanywhere else in the current command line (via C<%1>, C<%2>, etc.), then\nthose will be deleted from the list provided by C<%E<lt>>. Consider the\nfollowing command found in a F<Conscript> file in the F<test> directory:\n\n  Command $env 'tgt', qw(foo bar baz), qq(\n\techo %< -i %1 > %>\n\techo %< -i %2 >> %>\n\techo %< -i %3 >> %>\n  );\n\nIf F<tgt> needed to be updated, then this would result in the execution of\nthe following commands, assuming that no remapping has been established for\nthe F<test> directory:\n\n  echo test/bar test/baz -i test/foo > test/tgt\n  echo test/foo test/baz -i test/bar >> test/tgt\n  echo test/foo test/bar -i test/baz >> test/tgt\n\n=back\n\nAny of the above pseudo-variables may be followed immediately by one of\nthe following suffixes to select a portion of the expanded path name:\n\n  :a    the absolute path to the file name\n  :b    the directory plus the file name stripped of any suffix\n  :d    the directory\n  :f    the file name\n  :s    the file name suffix\n  :F    the file name stripped of any suffix\n  :S    the absolute path path to a Linked source file\n\nContinuing with the above example, C<%E<lt>:f> would expand to C<foo bar baz>,\nand C<%E<gt>:d> would expand to C<test>.\n\nThere are additional C<%> elements which affect the command line(s):\n\n=over 10\n\n=item %[ %]\n\nIt is possible to programmatically rewrite part of the command by\nenclosing part of it between C<%[> and C<%]>.  This will call the\nconstruction variable named as the first word enclosed in the brackets\nas a Perl code reference; the results of this call will be used to\nreplace the contents of the brackets in the command line.  For example,\ngiven an existing input file named F<tgt.in>:\n\n  @keywords = qw(foo bar baz);\n  $env = new cons(X_COMMA => sub { join(\",\", @_) });\n  Command $env 'tgt', 'tgt.in', qq(\n\techo '# Keywords: %[X_COMMA @keywords %]' > %>\n\tcat %< >> %>\n  );\n\nThis will execute:\n\n  echo '# Keywords: foo,bar,baz' > tgt\n  cat tgt.in >> tgt\n\n=item %( %)\n\nCons includes the text of the command line in the MD5 signature for a\nbuild, so that targets get rebuilt if you change the command line (to\nadd or remove an option, for example).  Command-line text in between\nC<%(> and C<%)>, however, will be ignored for MD5 signature calculation.\n\nInternally, Cons uses C<%(> and C<%)> around include and library\ndirectory options (C<-I> and C<-L> on UNIX systems, C</I> and\nC</LIBPATH> on Windows NT) to avoid rebuilds just because the directory\nlist changes.  Rebuilds occur only if the changed directory list causes\nany included I<files> to change, and a changed include file is detected\nby the MD5 signature calculation on the actual file contents.\n\n=back\n\n=head2 Expanding construction variables in file names\n\nCons expands construction variables in the source and target file names\npassed to the various construction methods according to the expansion\nrules described above:\n\n  $env = new cons(\n\tDESTDIR\t=>\t'programs',\n\tSRCDIR\t=>\t'src',\n  );\n  Program $env '%DESTDIR/hello', '%SRCDIR/hello.c';\n\nThis allows for flexible configuration, through the construction\nenvironment, of directory names, suffixes, etc.\n\n\n=head1 Build actions\n\nCons supports several types of B<build actions> that can be performed\nto construct one or more target files.  Usually, a build action is\na construction command--that is, a command-line string that invokes\nan external command.  Cons can also execute Perl code embedded in a\ncommand-line string, and even supports an experimental ability to build\na target file by executing a Perl code reference directly.\n\nA build action is usually specified as the value of a construction\nvariable:\n\n  $env = new cons(\n\tCCCOM         => '%CC %CFLAGS %_IFLAGS -c %< -o %>',\n\tLINKCOM       => '[perl] &link_executable(\"%>\", \"%<\")',\n\tARCOM         => sub { my($env, $target, @sources) = @_;\n\t\t\t\t # code to create an archive\n\t\t\t\t}\n  );\n\nA build action may be associated directly with one or more target files\nvia the C<Command> method; see below.\n\n=head2 Construction commands\n\nA construction command goes through expansion of construction variables\nand C<%-> pseudo-variables, as described above, to create the actual\ncommand line that Cons will execute to generate the target file or\nfiles.\n\nAfter substitution occurs, strings of white space are converted into\nsingle blanks, and leading and trailing white space is eliminated. It\nis therefore currently not possible to introduce variable length white\nspace in strings passed into a command.\n\nIf a multi-line command string is provided, the commands are executed\nsequentially. If any of the commands fails, then none of the rest are\nexecuted, and the target is not marked as updated, i.e. a new signature is\nnot stored for the target.\n\nNormally, if all the commands succeed, and return a zero status (or whatever\nplatform-specific indication of success is required), then a new signature\nis stored for the target. If a command erroneously reports success even\nafter a failure, then Cons will assume that the target file created by that\ncommand is accurate and up-to-date.\n\nThe first word of each command string, after expansion, is assumed to be an\nexecutable command looked up on the C<PATH> environment variable (which is,\nin turn, specified by the C<ENV> construction variable). If this command is\nfound on the path, then the target will depend upon it: the command will\ntherefore be automatically built, as necessary. It's possible to write\nmulti-part commands to some shells, separated by semi-colons. Only the first\ncommand word will be depended upon, however, so if you write your command\nstrings this way, you must either explicitly set up a dependency (with the\nC<Depends> method), or be sure that the command you are using is a system\ncommand which is expected to be available. If it isn't available, you will,\nof course, get an error.\n\nCons normally prints a command before executing it.  This behavior is\nsuppressed if the first character of the command is C<@>.  Note that\nyou may need to separate the C<@> from the command name or escape it to\nprevent C<@cmd> from looking like an array to Perl quote operators that\nperform interpolation:\n\n  # The first command line is incorrect,\n  # because \"@cp\" looks like an array\n  # to the Perl qq// function.\n  # Use the second form instead.\n  Command $env 'foo', 'foo.in', qq(\n\t@cp %< tempfile\n\t@ cp tempfile %>\n  );\n\nIf there are shell meta characters anywhere in the expanded command line,\nsuch as C<E<lt>>, C<E<gt>>, quotes, or semi-colon, then the command\nwill actually be executed by invoking a shell. This means that a command\nsuch as:\n\n  cd foo\n\nalone will typically fail, since there is no command C<cd> on the path. But\nthe command string:\n\n  cd $<:d; tar cf $>:f $<:f\n\nwhen expanded will still contain the shell meta character semi-colon, and a\nshell will be invoked to interpret the command. Since C<cd> is interpreted\nby this sub-shell, the command will execute as expected.\n\n=head2 Perl expressions\n\nIf any command (even one within a multi-line command) begins with\nC<[perl]>, the remainder of that command line will be evaluated by the\nrunning Perl instead of being forked by the shell.  If an error occurs\nin parsing the Perl code, or if the Perl expression returns 0 or undef,\nthe command will be considered to have failed.  For example, here is a\nsimple command which creates a file C<foo> directly from Perl:\n\n  $env = new cons();\n  Command $env 'foo',\n    qq([perl] open(FOO,'>foo');print FOO \"hi\\\\n\"; close(FOO); 1);\n\nNote that when the command is executed, you are in the same package as\nwhen the F<Construct> or F<Conscript> file was read, so you can call\nPerl functions you've defined in the same F<Construct> or F<Conscript>\nfile in which the C<Command> appears:\n\n  $env = new cons();\n  sub create_file {\n\tmy $file = shift;\n\topen(FILE, \">$file\");\n\tprint FILE \"hi\\n\";\n\tclose(FILE);\n\treturn 1;\n  }\n  Command $env 'foo', \"[perl] &create_file('%>')\";\n\nThe Perl string will be used to generate the signature for the derived\nfile, so if you change the string, the file will be rebuilt.  The contents\nof any subroutines you call, however, are not part of the signature,\nso if you modify a called subroutine such as C<create_file> above,\nthe target will I<not> be rebuilt.  Caveat user.\n\n=head2 Perl code references [EXPERIMENTAL]\n\nCons supports the ability to create a derived file by directly executing\na Perl code reference.  This feature is considered EXPERIMENTAL and\nsubject to change in the future.\n\nA code reference may either be a named subroutine referenced by the\nusual C<\\&> syntax:\n\n  sub build_output {\n\tmy($env, $target, @sources) = @_;\n\tprint \"build_output building $target\\n\";\n\topen(OUT, \">$target\");\n\tforeach $src (@sources) {\n\t    if (! open(IN, \"<$src\")) {\n\t\tprint STDERR \"cannot open '$src': $!\\n\";\n\t\treturn undef;\n\t    }\n\t    print OUT, <IN>;\n\t}\n\tclose(OUT);\n\treturn 1;\n  }\n  Command $env 'output', \\&build_output;\n\nor the code reference may be an anonymous subroutine:\n\n  Command $env 'output', sub {\n\tmy($env, $target, @sources) = @_;\n\tprint \"building $target\\n\";\n\topen(FILE, \">$target\");\n\tprint FILE \"hello\\n\";\n\tclose(FILE);\n\treturn 1;\n  };\n\nTo build the target file, the referenced subroutine is passed, in order:\nthe construction environment used to generate the target; the path\nname of the target itself; and the path names of all the source files\nnecessary to build the target file.\n\nThe code reference is expected to generate the target file, of course,\nbut may manipulate the source and target files in any way it chooses.\nThe code reference must return a false value (C<undef> or C<0>) if\nthe build of the file failed.  Any true value indicates a successful\nbuild of the target.\n\nBuilding target files using code references is considered EXPERIMENTAL\ndue to the following current limitations:\n\n=over 4\n\nCons does I<not> print anything to indicate the code reference is being\ncalled to build the file.  The only way to give the user any indication\nis to have the code reference explicitly print some sort of \"building\"\nmessage, as in the above examples.\n\nCons does not generate any signatures for code references, so if the\ncode in the reference changes, the target will I<not> be rebuilt.\n\nCons has no public method to allow a code reference to extract\nconstruction variables.  This would be good to allow generalization of\ncode references based on the current construction environment, but would\nalso complicate the problem of generating meaningful signatures for code\nreferences.\n\n=back\n\nSupport for building targets via code references has been released in\nthis version to encourage experimentation and the seeking of possible\nsolutions to the above limitations.\n\n\n=head1 Default construction methods\n\nThe list of default construction methods includes the following:\n\n\n=head2 The C<new> constructor\n\nThe C<new> method is a Perl object constructor. That is, it is not invoked\nvia a reference to an existing construction environment B<reference>, but,\nrather statically, using the name of the Perl B<package> where the\nconstructor is defined. The method is invoked like this:\n\n  $env = new cons(<overrides>);\n\nThe environment you get back is blessed into the package C<cons>, which\nmeans that it will have associated with it the default methods described\nbelow. Individual construction variables can be overridden by providing\nname/value pairs in an override list. Note that to override any command\nenvironment variable (i.e. anything under C<ENV>), you will have to override\nall of them. You can get around this difficulty by using the C<copy> method\non an existing construction environment.\n\n\n=head2 The C<clone> method\n\nThe C<clone> method creates a clone of an existing construction environment,\nand can be called as in the following example:\n\n  $env2 = $env1->clone(<overrides>);\n\nYou can provide overrides in the usual manner to create a different\nenvironment from the original. If you just want a new name for the same\nenvironment (which may be helpful when exporting environments to existing\ncomponents), you can just use simple assignment.\n\n\n=head2 The C<copy> method\n\nThe C<copy> method extracts the externally defined construction variables\nfrom an environment and returns them as a list of name/value\npairs. Overrides can also be provided, in which case, the overridden values\nwill be returned, as appropriate. The returned list can be assigned to a\nhash, as shown in the prototype, below, but it can also be manipulated in\nother ways:\n\n  %env = $env1->copy(<overrides>);\n\nThe value of C<ENV>, which is itself a hash, is also copied to a new hash,\nso this may be changed without fear of affecting the original\nenvironment. So, for example, if you really want to override just the\nC<PATH> variable in the default environment, you could do the following:\n\n  %cons = new cons()->copy();\n  $cons{ENV}{PATH} = \"<your path here>\";\n  $cons = new cons(%cons);\n\nThis will leave anything else that might be in the default execution\nenvironment undisturbed.\n\n\n=head2 The C<Install> method\n\nThe C<Install> method arranges for the specified files to be installed in\nthe specified directory. The installation is optimized: the file is not\ncopied if it can be linked. If this is not the desired behavior, you will\nneed to use a different method to install the file. It is called as follows:\n\n  Install $env <directory>, <names>;\n\nNote that, while the files to be installed may be arbitrarily named,\nonly the last component of each name is used for the installed target\nname. So, for example, if you arrange to install F<foo/bar> in F<baz>,\nthis will create a F<bar> file in the F<baz> directory (not F<foo/bar>).\n\n\n=head2 The C<InstallAs> method\n\nThe C<InstallAs> method arranges for the specified source file(s) to be\ninstalled as the specified target file(s). Multiple files should be\nspecified as a file list. The installation is optimized: the file is not\ncopied if it can be linked. If this is not the desired behavior, you will\nneed to use a different method to install the file. It is called as follows:\n\nC<InstallAs> works in two ways:\n\nSingle file install:\n\n  InstallAs $env TgtFile, SrcFile;\n\nMultiple file install:\n\n  InstallAs $env ['tgt1', 'tgt2'], ['src1', 'src2'];\n\nOr, even as:\n\n  @srcs = qw(src1 src2 src3);\n  @tgts = qw(tgt1 tgt2 tgt3);\n  InstallAs $env [@tgts], [@srcs];\n\nBoth the target and the sources lists should be of the same length.\n\n=head2 The C<Precious> method\n\nThe C<Precious> method asks cons not to delete the specified file or\nlist of files before building them again.  It is invoked as:\n\n  Precious <files>;\n\nThis is especially useful for allowing incremental updates to libraries\nor debug information files which are updated rather than rebuilt anew each\ntime.  Cons will still delete the files when the C<-r> flag is specified.\n\n=head2 The C<AfterBuild> method\n\nThe C<AfterBuild> method evaluates the specified perl string after\nbuilding the given file or files (or finding that they are up to date).\nThe eval will happen once per specified file.  C<AfterBuild> is called\nas follows:\n\n  AfterBuild $env 'foo.o', qq(print \"foo.o is up to date!\\n\");\n\nThe perl string is evaluated in the C<script> package, and has access\nto all variables and subroutines defined in the F<Conscript> file in\nwhich the C<AfterBuild> method is called.\n\n=head2 The C<Command> method\n\nThe C<Command> method is a catchall method which can be used to arrange for\nany build action to be executed to update the target. For this command, a\ntarget file and list of inputs is provided. In addition, a build action\nis specified as the last argument.  The build action is typically a\ncommand line or lines, but may also contain Perl code to be executed;\nsee the section above on build actions for details.\n\nThe C<Command> method is called as follows:\n\n  Command $env <target>, <inputs>, <build action>;\n\nThe target is made dependent upon the list of input files specified, and the\ninputs must be built successfully or Cons will not attempt to build the\ntarget.\n\nTo specify a command with multiple targets, you can specify a reference to a\nlist of targets. In Perl, a list reference can be created by enclosing a\nlist in square brackets. Hence the following command:\n\n  Command $env ['foo.h', 'foo.c'], 'foo.template', q(\n\tgen %1\n  );\n\ncould be used in a case where the command C<gen> creates two files, both\nF<foo.h> and F<foo.c>.\n\n\n=head2 The C<Objects> method\n\nThe C<Objects> method arranges to create the object files that correspond to\nthe specified source files. It is invoked as shown below:\n\n  @files = Objects $env <source or object files>;\n\nUnder Unix, source files ending in F<.s> and F<.c> are currently\nsupported, and will be compiled into a name of the same file ending\nin F<.o>. By default, all files are created by invoking the external\ncommand which results from expanding the C<CCCOM> construction variable,\nwith C<%E<lt>> and C<%E<gt>> set to the source and object files,\nrespectively. (See the section above on construction variable expansion\nfor details).  The variable C<CPPPATH> is also used when scanning source\nfiles for dependencies. This is a colon separated list of pathnames, and\nis also used to create the construction variable C<_IFLAGS,> which will\ncontain the appropriate list of -C<I> options for the compilation. Any\nrelative pathnames in C<CPPPATH> is interpreted relative to the\ndirectory in which the associated construction environment was created\n(absolute and top-relative names may also be used). This variable is\nused by C<CCCOM>. The behavior of this command can be modified by\nchanging any of the variables which are interpolated into C<CCCOM>, such\nas C<CC>, C<CFLAGS>, and, indirectly, C<CPPPATH>. It's also possible\nto replace the value of C<CCCOM>, itself. As a convenience, this file\nreturns the list of object filenames.\n\n\n=head2 The C<Program> method\n\nThe C<Program> method arranges to link the specified program with the\nspecified object files. It is invoked in the following manner:\n\n  Program $env <program name>, <source or object files>;\n\nThe program name will have the value of the C<SUFEXE> construction\nvariable appended (by default, C<.exe> on Win32 systems, nothing on Unix\nsystems) if the suffix is not already present.\n\nSource files may be specified in place of objects files--the C<Objects>\nmethod will be invoked to arrange the conversion of all the files into\nobject files, and hence all the observations about the C<Objects> method,\nabove, apply to this method also.\n\nThe actual linking of the program will be handled by an external command\nwhich results from expanding the C<LINKCOM> construction variable, with\nC<%E<lt>> set to the object files to be linked (in the order presented),\nand C<%E<gt>> set to the target. (See the section above on construction\nvariable expansion for details.)  The user may set additional variables\nin the construction environment, including C<LINK>, to define which\nprogram to use for linking, C<LIBPATH>, a colon-separated list of\nlibrary search paths, for use with library specifications of the form\nI<-llib>, and C<LIBS>, specifying the list of libraries to link against\n(in either I<-llib> form or just as pathnames. Relative pathnames in\nboth C<LIBPATH> and C<LIBS> are interpreted relative to the directory\nin which the associated construction environment is created (absolute\nand top-relative names may also be used). Cons automatically sets up\ndependencies on any libraries mentioned in C<LIBS>: those libraries will\nbe built before the command is linked.\n\n\n=head2 The C<Library> method\n\nThe C<Library> method arranges to create the specified library from the\nspecified object files. It is invoked as follows:\n\n  Library $env <library name>, <source or object files>;\n\nThe library name will have the value of the C<SUFLIB> construction\nvariable appended (by default, C<.lib> on Win32 systems, C<.a> on Unix\nsystems) if the suffix is not already present.\n\nSource files may be specified in place of objects files--the C<Objects>\nmethod will be invoked to arrange the conversion of all the files into\nobject files, and hence all the observations about the C<Objects> method,\nabove, apply to this method also.\n\nThe actual creation of the library will be handled by an external\ncommand which results from expanding the C<ARCOM> construction variable,\nwith C<%E<lt>> set to the library members (in the order presented),\nand C<%E<gt>> to the library to be created.  (See the section above\non construction variable expansion for details.)  The user may set\nvariables in the construction environment which will affect the\noperation of the command. These include C<AR>, the archive program\nto use, C<ARFLAGS>, which can be used to modify the flags given to\nthe program specified by C<AR>, and C<RANLIB>, the name of a archive\nindex generation program, if needed (if the particular need does not\nrequire the latter functionality, then C<ARCOM> must be redefined to not\nreference C<RANLIB>).\n\nThe C<Library> method allows the same library to be specified in multiple\nmethod invocations. All of the contributing objects from all the invocations\n(which may be from different directories) are combined and generated by a\nsingle archive command. Note, however, that if you prune a build so that\nonly part of a library is specified, then only that part of the library will\nbe generated (the rest will disappear!).\n\n\n=head2 The C<Module> method\n\nThe C<Module> method is a combination of the C<Program> and C<Command>\nmethods. Rather than generating an executable program directly, this command\nallows you to specify your own command to actually generate a module. The\nmethod is invoked as follows:\n\n  Module $env <module name>, <source or object files>, <construction command>;\n\nThis command is useful in instances where you wish to create, for example,\ndynamically loaded modules, or statically linked code libraries.\n\n\n=head2 The C<Depends> method\n\nThe C<Depends> method allows you to specify additional dependencies for a\ntarget.  It is invoked as follows:\n\n  Depends $env <target>, <dependencies>;\n\nThis may be occasionally useful, especially in cases where no scanner exists\n(or is writable) for particular types of files. Normally, dependencies are\ncalculated automatically from a combination of the explicit dependencies set\nup by the method invocation or by scanning source files.\n\nA set of identical dependencies for multiple targets may be specified\nusing a reference to a list of targets. In Perl, a list reference can\nbe created by enclosing a list in square brackets. Hence the following\ncommand:\n\n  Depends $env ['foo', 'bar'], 'input_file_1', 'input_file_2';\n\nspecifies that both the F<foo> and F<bar> files depend on the listed\ninput files.\n\n\n=head2 The C<RuleSet> method\n\nThe C<RuleSet> method returns the construction variables for building\nvarious components with one of the rule sets supported by Cons.  The\ncurrently supported rule sets are:\n\n=over 4\n\n=item msvc\n\nRules for the Microsoft Visual C++ compiler suite.\n\n=item unix\n\nGeneric rules for most UNIX-like compiler suites.\n\n=back\n\nOn systems with more than one available compiler suite, this allows you\nto easily create side-by-side environments for building software with\nmultiple tools:\n\n    $msvcenv = new cons(RuleSet(\"msvc\"));\n    $cygnusenv = new cons(RuleSet(\"unix\"));\n\nIn the future, this could also be extended to other platforms that\nhave different default rule sets.\n\n\n=head2 The C<DefaultRules> method\n\nThe C<DefaultRules> method sets the default construction variables that\nwill be returned by the C<new> method to the specified arguments:\n\n  DefaultRules(CC     => 'gcc',\n\t       CFLAGS => '',\n\t       CCCOM  => '%CC %CFLAGS %_IFLAGS -c %< -o %>');\n  $env = new cons();\n  # $env now contains *only* the CC, CFLAGS,\n  # and CCCOM construction variables\n\nCombined with the C<RuleSet> method, this also provides an easy way\nto set explicitly the default build environment to use some supported\ntoolset other than the Cons defaults:\n\n    # use a UNIX-like tool suite (like cygwin) on Win32\n    DefaultRules(RuleSet('unix'));\n    $env = new cons();\n\nNote that the C<DefaultRules> method completely replaces the default\nconstruction environment with the specified arguments, it does not\nsimply override the existing defaults.  To override one or more\nvariables in a supported C<RuleSet>, append the variables and values:\n\n  DefaultRules(RuleSet('unix'), CFLAGS => '-O3');\n  $env1 = new cons();\n  $env2 = new cons();\n  # both $env1 and $env2 have 'unix' defaults\n  # with CFLAGS set to '-O3'\n\n\n=head2 The C<Ignore> method\n\nThe C<Ignore> method allows you to ignore explicitly dependencies that\nCons infers on its own.  It is invoked as follows:\n\n  Ignore <patterns>;\n\nThis can be used to avoid recompilations due to changes in system header\nfiles or utilities that are known to not affect the generated targets.\n\nIf, for example, a program is built in an NFS-mounted directory on\nmultiple systems that have different copies of F<stdio.h>, the differences\nwill affect the signatures of all derived targets built from source files\nthat C<#include E<lt>stdio.hE<gt>>.  This will cause all those targets to\nbe rebuilt when changing systems.  If this is not desirable behavior, then\nthe following line will remove the dependencies on the F<stdio.h> file:\n\n  Ignore '^/usr/include/stdio\\.h$';\n\nNote that the arguments to the C<Ignore> method are regular expressions,\nso special characters must be escaped and you may wish to anchor the\nbeginning or end of the expression with C<^> or C<$> characters.\n\n\n=head2 The C<Salt> method\n\nThe C<Salt> method adds a constant value to the signature calculation\nfor every derived file.  It is invoked as follows:\n\n  Salt $string;\n\nChanging the Salt value will force a complete rebuild of every derived\nfile.  This can be used to force rebuilds in certain desired\ncircumstances.  For example,\n\n  Salt `uname -s`;\n\nWould force a complete rebuild of every derived file whenever the\noperating system on which the build is performed (as reported by C<uname\n-s>) changes.\n\n\n=head2 The C<UseCache> method\n\nThe C<UseCache> method instructs Cons to maintain a cache of derived\nfiles, to be shared among separate build trees of the same project.\n\n  UseCache(\"cache/<buildname>\") || warn(\"cache directory not found\");\n\n\n=head2 The C<SourcePath> method\n\nThe C<SourcePath> mathod returns the real source path name of a file,\nas opposed to the path name within a build directory.  It is invoked\nas follows:\n\n  $path = SourcePath <buildpath>;\n\n\n=head2 The C<ConsPath> method\n\nThe C<ConsPath> method returns true if the supplied path is a derivable\nfile, and returns undef (false) otherwise.\nIt is invoked as follows:\n\n  $result = ConsPath <path>;\n\n\n=head2 The C<SplitPath> method\n\nThe C<SplitPath> method looks up multiple path names in a string separated\nby the default path separator for the operating system (':' on UNIX\nsystems, ';' on Windows NT), and returns the fully-qualified names.\nIt is invoked as follows:\n\n  @paths = SplitPath <pathlist>;\n\nThe C<SplitPath> method will convert  names prefixed '#' to the\nappropriate top-level build name (without the '#') and will convert\nrelative names to top-level names.\n\n\n=head2 The C<DirPath> method\n\nThe C<DirPath> method returns the build path name(s) of a directory or\nlist of directories.  It is invoked as follows:\n\n  $cwd = DirPath <paths>;\n\nThe most common use for the C<DirPath> method is:\n\n  $cwd = DirPath '.';\n\nto fetch the path to the current directory of a subsidiary F<Conscript>\nfile.\n\n\n=head2 The C<FilePath> method\n\nThe C<FilePath> method returns the build path name(s) of a file or\nlist of files.  It is invoked as follows:\n\n  $file = FilePath <path>;\n\n\n=head2 The C<Help> method\n\nThe C<Help> method specifies help text that will be displayed when the\nuser invokes C<cons -h>.  This can be used to provide documentation\nof specific targets, values, build options, etc. for the build tree.\nIt is invoked as follows:\n\n  Help <helptext>;\n\nThe C<Help> method may only be called once, and should typically be\nspecified in the top-level F<Construct> file.\n\n\n=head1 Extending Cons\n\n\n=head2 Overriding construction variables\n\nThere are several ways of extending Cons, which vary in degree of\ndifficulty. The simplest method is to define your own construction\nenvironment, based on the default environment, but modified to reflect your\nparticular needs. This will often suffice for C-based applications. You can\nuse the C<new> constructor, and the C<clone> and C<copy> methods to create\nhybrid environments. These changes can be entirely transparent to the\nunderlying F<Conscript> files.\n\n\n=head2 Adding new methods\n\nFor slightly more demanding changes, you may wish to add new methods to the\nC<cons> package. Here's an example of a very simple extension,\nC<InstallScript>, which installs a tcl script in a requested location, but\nedits the script first to reflect a platform-dependent path that needs to be\ninstalled in the script:\n\n  # cons::InstallScript - Create a platform dependent version of a shell\n  # script by replacing string ``#!your-path-here'' with platform specific\n  # path $BIN_DIR.\n\n  sub cons::InstallScript {\n\tmy ($env, $dst, $src) = @_;\n\tCommand $env $dst, $src, qq(\n\t\tsed s+your-path-here+$BIN_DIR+ %< > %>\n\t\tchmod oug+x %>\n\t);\n  }\n\nNotice that this method is defined directly in the C<cons> package (by\nprefixing the name with C<cons::>). A change made in this manner will be\nglobally visible to all environments, and could be called as in the\nfollowing example:\n\n  InstallScript $env \"$BIN/foo\", \"foo.tcl\";\n\nFor a small improvement in generality, the C<BINDIR> variable could be\npassed in as an argument or taken from the construction environment--as\nC<%BINDIR>.\n\n\n=head2 Overriding methods\n\nInstead of adding the method to the C<cons> name space, you could define a\nnew package which inherits existing methods from the C<cons> package and\noverrides or adds others. This can be done using Perl's inheritance\nmechanisms.\n\nThe following example defines a new package C<cons::switch> which\noverrides the standard C<Library> method. The overridden method builds\nlinked library modules, rather than library archives. A new\nconstructor is provided. Environments created with this constructor\nwill have the new library method; others won't.\n\n  package cons::switch;\n  BEGIN {@ISA = 'cons'}\n\n  sub new {\n\tshift;\n\tbless new cons(@_);\n  }\n\n  sub Library {\n\tmy($env) = shift;\n\tmy($lib) = shift;\n\tmy(@objs) = Objects $env @_;\n\tCommand $env $lib, @objs, q(\n\t\t%LD -r %LDFLAGS %< -o %>\n\t);\n  }\n\nThis functionality could be invoked as in the following example:\n\n  $env = new cons::switch(@overrides);\n  ...\n  Library $env 'lib.o', 'foo.c', 'bar.c';\n\n\n=head1 Invoking Cons\n\nThe C<cons> command is usually invoked from the root of the build tree. A\nF<Construct> file must exist in that directory. If the C<-f> argument is\nused, then an alternate F<Construct> file may be used (and, possibly, an\nalternate root, since C<cons> will cd to F<Construct> file's containing\ndirectory).\n\nIf C<cons> is invoked from a child of the root of the build tree with\nthe C<-t> argument, it will walk up the directory hierarchy looking for a\nF<Construct> file.  (An alternate name may still be specified with C<-f>.)\nThe targets supplied on the command line will be modified to be relative\nto the discovered F<Construct> file.  For example, from a directory\ncontaining a top-level F<Construct> file, the following invocation:\n\n  % cd libfoo/subdir\n  % cons -t target\n\nis exactly equivalent to:\n\n  % cons libfoo/subdir/target\n\nIf there are any C<Default> targets specified in the directory hierarchy's\nF<Construct> or F<Conscript> files, only the default targets at or below\nthe directory from which C<cons -t> was invoked will be built.\n\nThe command is invoked as follows:\n\n  cons <arguments> -- <construct-args>\n\nwhere I<arguments> can be any of the following, in any order:\n\n=over 10\n\n=item I<target>\n\nBuild the specified target. If I<target> is a directory, then recursively\nbuild everything within that directory.\n\n=item I<+pattern>\n\nLimit the F<Conscript> files considered to just those that match I<pattern>,\nwhich is a Perl regular expression. Multiple C<+> arguments are accepted.\n\n=item I<name>=<val>\n\nSets I<name> to value I<val> in the C<ARG> hash passed to the top-level\nF<Construct> file.\n\n=item C<-cc>\n\nShow command that would have been executed, when retrieving from cache. No\nindication that the file has been retrieved is given; this is useful for\ngenerating build logs that can be compared with real build logs.\n\n=item C<-cd>\n\nDisable all caching. Do not retrieve from cache nor flush to cache.\n\n=item C<-cr>\n\nBuild dependencies in random order. This is useful when building multiple\nsimilar trees with caching enabled.\n\n=item C<-cs>\n\nSynchronize existing build targets that are found to be up-to-date with\ncache. This is useful if caching has been disabled with -cc or just recently\nenabled with UseCache.\n\n=item C<-d>\n\nEnable dependency debugging.\n\n=item C<-f> <file>\n\nUse the specified file instead of F<Construct> (but first change to\ncontaining directory of I<file>).\n\n=item C<-h>\n\nShow a help message local to the current build if one such is defined, and\nexit.\n\n=item C<-k>\n\nKeep going as far as possible after errors.\n\n=item C<-o> <file>\n\nRead override file I<file>.\n\n=item C<-p>\n\nShow construction products in specified trees. No build is attempted.\n\n=item C<-pa>\n\nShow construction products and associated actions. No build is attempted.\n\n=item C<-pw>\n\nShow products and where they are defined. No build is attempted.\n\n=item C<-q>\n\nMake the build quiet.  Multiple C<-q> options may be specified.\n\nA single C<-q> options suppress messages about Installing and Removing\ntargets.\n\nTwo C<-q> options suppress build command lines and target up-to-date\nmessages.\n\n=item C<-r>\n\nRemove construction products associated with <targets>. No build is\nattempted.\n\n=item C<-R> <repos>\n\nSearch for files in I<repos>.  Multiple B<-R> I<repos> directories are\nsearched in the order specified.\n\n=item C<-S> <pkg>\n\nUse the sig::<pkg> package to calculate.  Supported <pkg> values\ninclude \"md5\" for MD5 signature calculation and \"md5::debug\" for debug\ninformation about MD5 signature calculation.\n\nIf the specified package ends in <::debug>, signature debug information\nwill be printed to the file name specified in the C<CONS_SIG_DEBUG>\nenvironment variable, or to standard output if the environment variable\nis not set.\n\n=item C<-t>\n\nTraverse up the directory hierarchy looking for a F<Construct> file,\nif none exists in the current directory.  Targets will be modified to\nbe relative to the F<Construct> file.\n\nInternally, C<cons> will change its working directory to the directory\nwhich contains the top-level F<Construct> file and report:\n\n  cons: Entering directory `top-level-directory'\n\nThis message indicates to an invoking editor (such as emacs) or build\nenvironment that Cons will now report all file names relative to the\ntop-level directory.  This message can not be suppressed with the C<-q>\noption.\n\n=item C<-v>\n\nShow C<cons> version and continue processing.\n\n=item C<-V>\n\nShow C<cons> version and exit.\n\n=item C<-wf> <file>\n\nWrite all filenames considered into I<file>.\n\n=item C<-x>\n\nShow a help message similar to this one, and exit.\n\n=back\n\nAnd I<construct-args> can be any arguments that you wish to process in the\nF<Construct> file. Note that there should be a B<--> separating the arguments\nto cons and the arguments that you wish to process in the F<Construct> file.\n\nProcessing of I<construct-args> can be done by any standard package like\nB<Getopt> or its variants, or any user defined package. B<cons> will pass in\nthe I<construct-args> as B<@ARGV> and will not attempt to interpret anything\nafter the B<-->.\n\n  % cons -R /usr/local/repository -d os=solaris +driver -- -c test -f DEBUG\n\nwould pass the following to cons\n\n  -R /usr/local/repository -d os=solaris +driver\n\nand the following, to the top level F<Construct> file as B<@ARGV>\n\n  -c test -f DEBUG\n\nNote that C<cons -r .> is equivalent to a full recursive C<make clean>,\nbut requires no support in the F<Construct> file or any F<Conscript>\nfiles. This is most useful if you are compiling files into source\ndirectories (if you separate the F<build> and F<export> directories,\nthen you can just remove the directories).\n\nThe options C<-p>, C<-pa>, and C<-pw> are extremely useful for use as an aid\nin reading scripts or debugging them. If you want to know what script\ninstalls F<export/include/foo.h>, for example, just type:\n\n  % cons -pw export/include/foo.h\n\n\n=head1 Using and writing dependency scanners\n\nQuickScan allows simple target-independent scanners to be set up for\nsource files. Only one QuickScan scanner may be associated with any given\nsource file and environment, although the same scanner may (and should)\nbe used for multiple files of a given type.\n\nA QuickScan scanner is only ever invoked once for a given source file,\nand it is only invoked if the file is used by some target in the tree\n(i.e., there is a dependency on the source file).\n\nQuickScan is invoked as follows:\n\n  QuickScan CONSENV CODEREF, FILENAME [, PATH]\n\nThe subroutine referenced by CODEREF is expected to return a list of\nfilenames included directly by FILE. These filenames will, in turn, be\nscanned. The optional PATH argument supplies a lookup path for finding\nFILENAME and/or files returned by the user-supplied subroutine.  The PATH\nmay be a reference to an array of lookup-directory names, or a string of\nnames separated by the system's separator character (':' on UNIX systems,\n';' on Windows NT).\n\nThe subroutine is called once for each line in the file, with $_ set to the\ncurrent line. If the subroutine needs to look at additional lines, or, for\nthat matter, the entire file, then it may read them itself, from the\nfilehandle SCAN. It may also terminate the loop, if it knows that no further\ninclude information is available, by closing the filehandle.\n\nWhether or not a lookup path is provided, QuickScan first tries to lookup\nthe file relative to the current directory (for the top-level file\nsupplied directly to QuickScan), or from the directory containing the\nfile which referenced the file. This is not very general, but seems good\nenough--especially if you have the luxury of writing your own utilities\nand can control the use of the search path in a standard way.\n\nHere's a real example, taken from a F<Construct> file here:\n\n  sub cons::SMFgen {\n      my($env, @tables) = @_;\n      foreach $t (@tables) {\n\t  $env->QuickScan(sub { /\\b\\S*?\\.smf\\b/g }, \"$t.smf\",\n\t\t\t  $env->{SMF_INCLUDE_PATH});\n\t  $env->Command([\"$t.smdb.cc\",\"$t.smdb.h\",\"$t.snmp.cc\",\n\t\t\t \"$t.ami.cc\", \"$t.http.cc\"], \"$t.smf\",\n\t\t\tq(smfgen %( %SMF_INCLUDE_OPT %) %<));\n      }\n  }\n\nThe subroutine above finds all names of the form <name>.smf in the\nfile. It will return the names even if they're found within comments,\nbut that's OK (the mechanism is forgiving of extra files; they're just\nignored on the assumption that the missing file will be noticed when\nthe program, in this example, smfgen, is actually invoked).\n\n[NOTE that the form C<$env-E<gt>QuickScan ...>  and C<$env-E<gt>Command\n...> should not be necessary, but, for some reason, is required\nfor this particular invocation. This appears to be a bug in Perl or\na misunderstanding on my part; this invocation style does not always\nappear to be necessary.]\n\nHere is another way to build the same scanner. This one uses an\nexplicit code reference, and also (unnecessarily, in this case) reads\nthe whole file itself:\n\n  sub myscan {\n      my(@includes);\n      do {\n\t  push(@includes, /\\b\\S*?\\.smf\\b/g);\n      } while <SCAN>;\n      @includes\n  }\n\nNote that the order of the loop is reversed, with the loop test at the\nend. This is because the first line is already read for you. This scanner\ncan be attached to a source file by:\n\n  QuickScan $env \\&myscan, \"$_.smf\";\n\nThis final example, which scans a different type of input file, takes\nover the file scanning rather than being called for each input line:\n\n  $env->QuickScan(\n      sub { my(@includes) = ();\n\t  do {\n\t     push(@includes, $3)\n\t\t if /^(#include|import)\\s+(\\\")(.+)(\\\")/ && $3\n\t  } while <SCAN>;\n\t  @includes\n      },\n      \"$idlFileName\",\n      \"$env->{CPPPATH};$BUILD/ActiveContext/ACSCLientInterfaces\"\n  );\n\n=head1 SUPPORT AND SUGGESTIONS\n\nCons is maintained by the user community.  To subscribe, send mail to\nB<cons-discuss-request@gnu.org> with body B<subscribe>.\n\nPlease report any suggestions through the B<cons-discuss@gnu.org> mailing\nlist.\n\n=head1 BUGS\n\nSure to be some. Please report any bugs through the B<bug-cons@gnu.org>\nmailing list.\n\n=head1 INFORMATION ABOUT CONS\n\nInformation about CONS can be obtained from the official cons web site\nB<http://www.dsmit.com/cons/> or its mirrors listed there.\n\nThe cons maintainers can be contacted by email at\nB<cons-maintainers@gnu.org>\n\n=head1 AUTHORS\n\nOriginally by Bob Sidebotham. Then significantly enriched by the members\nof the Cons community B<cons-discuss@gnu.org>.\n\nThe Cons community would like to thank Ulrich Pfeifer for the original pod\ndocumentation derived from the F<cons.html> file. Cons documentation is now\na part of the program itself.\n\n=cut\n\n"
  },
  {
    "path": "code/unix/q3test.spec.sh",
    "content": "#!/bin/sh\n# Generate Quake3 test\n# $1 is version\n# $2 is release\n# $3 is arch\n# $4 is install dir (assumed to be in /var/tmp)\ncat <<EOF\n%define name q3test\n%define version ${1}\n%define release ${2}\n%define arch ${3}\n%define builddir \\$RPM_BUILD_DIR/%{name}-%{version}\nName:\t\t%{name}\nVersion:\t%{version}\nRelease:\t%{release}\nVendor:\t\tid Software\nPackager:\tDave \"Zoid\" Kirsch <zoid@idsoftware.com>\nURL:\t\thttp://www.idsoftware.com/\nSource:\t\tq3test-%{version}.tar.gz\nGroup:\t\tGames\nCopyright:\tRestricted\nIcon:\t\tquake3.gif\nBuildRoot:\t/var/tmp/%{name}-%{version}\nSummary:\tQ3Test for Linux\n\n%description\n\n%install\n\n%files\n\n%attr(644,root,root) $4/README.EULA\n%attr(644,root,root) $4/README.Q3Test\n%attr(644,root,root) $4/README.Linux\n%attr(644,root,root) $4/Quake3.kdelnk\n%attr(644,root,root) $4/quake3.xpm\n%attr(755,root,root) $4/linuxquake3\n%attr(755,root,root) $4/cgamei386.so\n%attr(755,root,root) $4/qagamei386.so\n%attr(755,root,root) $4/uii386.so\n%attr(755,root,root) $4/libMesaVoodooGL.so.3.1\n%attr(644,root,root) $4/demoq3/pak0.pk3\n\n%post\n\nif [ -n \"\\$KDEDIR\" ]; then\n\tln -sf $4/Quake3.kdelnk \\$KDEDIR/share/applnk/Games/Quake3.kdelnk\n\tln -sf $4/quake3.xpm \\$KDEDIR/share/icons/quake3.xpm\nfi\n\nEOF\n\n"
  },
  {
    "path": "code/unix/qasm.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __ASM_I386__\n#define __ASM_I386__\n\n#ifdef ELF\n#define C(label) label\n#else\n#define C(label) _##label\n#endif\n\n\n//#define GLQUAKE\t1\n\n#if defined(_WIN32) && !defined(WINDED)\n\n#if defined(_M_IX86)\n#define __i386__\t1\n#endif\n\n#endif\n\n#ifdef __i386__\n#define id386\t1\n#else\n#define id386\t0\n#endif\n\n// !!! must be kept the same as in d_iface.h !!!\n#define TRANSPARENT_COLOR\t255\n\n#ifndef GLQUAKE\n\t.extern C(d_zistepu)\n\t.extern C(d_pzbuffer)\n\t.extern C(d_zistepv)\n\t.extern C(d_zrowbytes)\n\t.extern C(d_ziorigin)\n\t.extern C(r_turb_s)\n\t.extern C(r_turb_t)\n\t.extern C(r_turb_pdest)\n\t.extern C(r_turb_spancount)\n\t.extern C(r_turb_turb)\n\t.extern C(r_turb_pbase)\n\t.extern C(r_turb_sstep)\n\t.extern C(r_turb_tstep)\n\t.extern\tC(r_bmodelactive)\n\t.extern\tC(d_sdivzstepu)\n\t.extern\tC(d_tdivzstepu)\n\t.extern\tC(d_sdivzstepv)\n\t.extern\tC(d_tdivzstepv)\n\t.extern\tC(d_sdivzorigin)\n\t.extern\tC(d_tdivzorigin)\n\t.extern\tC(sadjust)\n\t.extern\tC(tadjust)\n\t.extern\tC(bbextents)\n\t.extern\tC(bbextentt)\n\t.extern\tC(cacheblock)\n\t.extern\tC(d_viewbuffer)\n\t.extern\tC(cachewidth)\n\t.extern\tC(d_pzbuffer)\n\t.extern\tC(d_zrowbytes)\n\t.extern\tC(d_zwidth)\n\t.extern C(d_scantable)\n\t.extern C(r_lightptr)\n\t.extern C(r_numvblocks)\n\t.extern C(prowdestbase)\n\t.extern C(pbasesource)\n\t.extern C(r_lightwidth)\n\t.extern C(lightright)\n\t.extern C(lightrightstep)\n\t.extern C(lightdeltastep)\n\t.extern C(lightdelta)\n\t.extern C(lightright)\n\t.extern C(lightdelta)\n\t.extern C(sourcetstep)\n\t.extern C(surfrowbytes)\n\t.extern C(lightrightstep)\n\t.extern C(lightdeltastep)\n\t.extern C(r_sourcemax)\n\t.extern C(r_stepback)\n\t.extern C(colormap)\n\t.extern C(blocksize)\n\t.extern C(sourcesstep)\n\t.extern C(lightleft)\n\t.extern C(blockdivshift)\n\t.extern C(blockdivmask)\n\t.extern C(lightleftstep)\n\t.extern C(r_origin)\n\t.extern C(r_ppn)\n\t.extern C(r_pup)\n\t.extern C(r_pright)\n\t.extern C(ycenter)\n\t.extern C(xcenter)\n\t.extern C(d_vrectbottom_particle)\n\t.extern C(d_vrectright_particle)\n\t.extern C(d_vrecty)\n\t.extern C(d_vrectx)\n\t.extern C(d_pix_shift)\n\t.extern C(d_pix_min)\n\t.extern C(d_pix_max)\n\t.extern C(d_y_aspect_shift)\n\t.extern C(screenwidth)\n\t.extern C(r_leftclipped)\n\t.extern C(r_leftenter)\n\t.extern C(r_rightclipped)\n\t.extern C(r_rightenter)\n\t.extern C(modelorg)\n\t.extern C(xscale)\n\t.extern C(r_refdef)\n\t.extern C(yscale)\n\t.extern C(r_leftexit)\n\t.extern C(r_rightexit)\n\t.extern C(r_lastvertvalid)\n\t.extern C(cacheoffset)\n\t.extern C(newedges)\n\t.extern C(removeedges)\n\t.extern C(r_pedge)\n\t.extern C(r_framecount)\n\t.extern C(r_u1)\n\t.extern C(r_emitted)\n\t.extern C(edge_p)\n\t.extern C(surface_p)\n\t.extern C(surfaces)\n\t.extern C(r_lzi1)\n\t.extern C(r_v1)\n\t.extern C(r_ceilv1)\n\t.extern C(r_nearzi)\n\t.extern C(r_nearzionly)\n\t.extern C(edge_aftertail)\n\t.extern C(edge_tail)\n\t.extern C(current_iv)\n\t.extern C(edge_head_u_shift20)\n\t.extern C(span_p)\n\t.extern C(edge_head)\n\t.extern C(fv)\n\t.extern C(edge_tail_u_shift20)\n\t.extern C(r_apverts)\n\t.extern C(r_anumverts)\n\t.extern C(aliastransform)\n\t.extern C(r_avertexnormals)\n\t.extern C(r_plightvec)\n\t.extern C(r_ambientlight)\n\t.extern C(r_shadelight)\n\t.extern C(aliasxcenter)\n\t.extern C(aliasycenter)\n\t.extern C(a_sstepxfrac)\n\t.extern C(r_affinetridesc)\n\t.extern C(acolormap)\n\t.extern C(d_pcolormap)\n\t.extern C(r_affinetridesc)\n\t.extern C(d_sfrac)\n\t.extern C(d_ptex)\n\t.extern C(d_pedgespanpackage)\n\t.extern C(d_tfrac)\n\t.extern C(d_light)\n\t.extern C(d_zi)\n\t.extern C(d_pdest)\n\t.extern C(d_pz)\n\t.extern C(d_aspancount)\n\t.extern C(erroradjustup)\n\t.extern C(errorterm)\n\t.extern C(d_xdenom)\n\t.extern C(r_p0)\n\t.extern C(r_p1)\n\t.extern C(r_p2)\n\t.extern C(a_tstepxfrac)\n\t.extern C(r_sstepx)\n\t.extern C(r_tstepx)\n\t.extern C(a_ststepxwhole)\n\t.extern C(zspantable)\n\t.extern C(skintable)\n\t.extern C(r_zistepx)\n\t.extern C(erroradjustdown)\n\t.extern C(d_countextrastep)\n\t.extern C(ubasestep)\n\t.extern C(a_ststepxwhole)\n\t.extern C(a_tstepxfrac)\n\t.extern C(r_lstepx)\n\t.extern C(a_spans)\n\t.extern C(erroradjustdown)\n\t.extern C(d_pdestextrastep)\n\t.extern C(d_pzextrastep)\n\t.extern C(d_sfracextrastep)\n\t.extern C(d_ptexextrastep)\n\t.extern C(d_countextrastep)\n\t.extern C(d_tfracextrastep)\n\t.extern C(d_lightextrastep)\n\t.extern C(d_ziextrastep)\n\t.extern C(d_pdestbasestep)\n\t.extern C(d_pzbasestep)\n\t.extern C(d_sfracbasestep)\n\t.extern C(d_ptexbasestep)\n\t.extern C(ubasestep)\n\t.extern C(d_tfracbasestep)\n\t.extern C(d_lightbasestep)\n\t.extern C(d_zibasestep)\n\t.extern C(zspantable)\n\t.extern C(r_lstepy)\n\t.extern C(r_sstepy)\n\t.extern C(r_tstepy)\n\t.extern C(r_zistepy)\n\t.extern C(D_PolysetSetEdgeTable)\n\t.extern C(D_RasterizeAliasPolySmooth)\n\n\t.extern float_point5\n\t.extern Float2ToThe31nd\n\t.extern izistep\n\t.extern izi\n\t.extern FloatMinus2ToThe31nd\n\t.extern float_1\n\t.extern float_particle_z_clip\n\t.extern float_minus_1\n\t.extern float_0\n\t.extern fp_16\n\t.extern fp_64k\n\t.extern fp_1m\n\t.extern fp_1m_minus_1\n\t.extern fp_8 \n\t.extern entryvec_table\n\t.extern advancetable\n\t.extern sstep\n\t.extern tstep\n\t.extern pspantemp\n\t.extern counttemp\n\t.extern jumptemp\n\t.extern reciprocal_table\n\t.extern DP_Count\n\t.extern DP_u\n\t.extern DP_v\n\t.extern DP_32768\n\t.extern DP_Color\n\t.extern DP_Pix\n\t.extern DP_EntryTable\n\t.extern\tpbase\n\t.extern s\n\t.extern t\n\t.extern sfracf\n\t.extern tfracf\n\t.extern snext\n\t.extern tnext\n\t.extern\tspancountminus1\n\t.extern zi16stepu\n\t.extern sdivz16stepu\n\t.extern tdivz16stepu\n\t.extern\tzi8stepu\n\t.extern sdivz8stepu\n\t.extern tdivz8stepu\n\t.extern reciprocal_table_16\n\t.extern entryvec_table_16\n\t.extern ceil_cw\n\t.extern single_cw\n\t.extern fp_64kx64k\n\t.extern pz\n\t.extern spr8entryvec_table\n#endif\n\n\t.extern C(snd_scaletable)\n\t.extern C(paintbuffer)\n\t.extern C(snd_linear_count)\n\t.extern C(snd_p)\n\t.extern C(snd_vol)\n\t.extern C(snd_out)\n\t.extern C(vright)\n\t.extern C(vup)\n\t.extern C(vpn)\n\t.extern C(BOPS_Error)\n\n//\n// !!! note that this file must match the corresponding C structures at all\n// times !!!\n//\n\n// plane_t structure\n// !!! if this is changed, it must be changed in model.h too !!!\n// !!! if the size of this is changed, the array lookup in SV_HullPointContents\n//     must be changed too !!!\n#define pl_normal\t0\n#define pl_dist\t\t12\n#define pl_type\t\t16\n#define pl_signbits\t17\n#define pl_pad\t\t18\n#define pl_size\t\t20\n\n// hull_t structure\n// !!! if this is changed, it must be changed in model.h too !!!\n#define\thu_clipnodes\t\t0\n#define\thu_planes\t\t\t4\n#define\thu_firstclipnode\t8\n#define\thu_lastclipnode\t\t12\n#define\thu_clip_mins\t\t16\n#define\thu_clip_maxs\t\t28\n#define hu_size  \t\t\t40\n\n// dnode_t structure\n// !!! if this is changed, it must be changed in bspfile.h too !!!\n#define\tnd_planenum\t\t0\n#define\tnd_children\t\t4\n#define\tnd_mins\t\t\t8\n#define\tnd_maxs\t\t\t20\n#define\tnd_firstface\t32\n#define\tnd_numfaces\t\t36\n#define nd_size\t\t\t40\n\n// sfxcache_t structure\n// !!! if this is changed, it much be changed in sound.h too !!!\n#define sfxc_length\t\t0\n#define sfxc_loopstart\t4\n#define sfxc_speed\t\t8\n#define sfxc_width\t\t12\n#define sfxc_stereo\t\t16\n#define sfxc_data\t\t20\n\n// channel_t structure\n// !!! if this is changed, it much be changed in sound.h too !!!\n#define ch_sfx\t\t\t0\n#define ch_leftvol\t\t4\n#define ch_rightvol\t\t8\n#define ch_end\t\t\t12\n#define ch_pos\t\t\t16\n#define ch_looping\t\t20\n#define ch_entnum\t\t24\n#define ch_entchannel\t28\n#define ch_origin\t\t32\n#define ch_dist_mult\t44\n#define ch_master_vol\t48\n#define ch_size\t\t\t52\n\n// portable_samplepair_t structure\n// !!! if this is changed, it much be changed in sound.h too !!!\n#define psp_left\t\t0\n#define psp_right\t\t4\n#define psp_size\t\t8\n\n\n//\n// !!! note that this file must match the corresponding C structures at all\n// times !!!\n//\n\n// !!! if this is changed, it must be changed in r_local.h too !!!\n#define\tNEAR_CLIP\t0.01\n\n// !!! if this is changed, it must be changed in r_local.h too !!!\n#define\tCYCLE\t128\n\n// espan_t structure\n// !!! if this is changed, it must be changed in r_shared.h too !!!\n#define espan_t_u    \t0\n#define espan_t_v\t    4\n#define espan_t_count   8\n#define espan_t_pnext\t12\n#define espan_t_size    16\n\n// sspan_t structure\n// !!! if this is changed, it must be changed in d_local.h too !!!\n#define sspan_t_u    \t0\n#define sspan_t_v\t    4\n#define sspan_t_count   8\n#define sspan_t_size    12\n\n// spanpackage_t structure\n// !!! if this is changed, it must be changed in d_polyset.c too !!!\n#define spanpackage_t_pdest\t\t\t\t0\n#define spanpackage_t_pz\t\t\t\t4\n#define spanpackage_t_count\t\t\t\t8\n#define spanpackage_t_ptex\t\t\t\t12\n#define spanpackage_t_sfrac\t\t\t\t16\n#define spanpackage_t_tfrac\t\t\t\t20\n#define spanpackage_t_light\t\t\t\t24\n#define spanpackage_t_zi\t\t\t\t28\n#define spanpackage_t_size\t\t\t\t32 \n\n// edge_t structure\n// !!! if this is changed, it must be changed in r_shared.h too !!!\n#define et_u\t\t\t0\n#define et_u_step\t\t4\n#define et_prev\t\t\t8\n#define et_next\t\t\t12\n#define et_surfs\t\t16\n#define et_nextremove\t20\n#define et_nearzi\t\t24\n#define et_owner\t\t28\n#define et_size\t\t\t32\n\n// surf_t structure\n// !!! if this is changed, it must be changed in r_shared.h too !!!\n#define SURF_T_SHIFT\t6\n#define st_next\t\t\t0\n#define st_prev\t\t\t4\n#define st_spans\t\t8\n#define st_key\t\t\t12\n#define st_last_u\t\t16\n#define st_spanstate\t20\n#define st_flags\t\t24\n#define st_data\t\t\t28\n#define st_entity\t\t32\n#define st_nearzi\t\t36\n#define st_insubmodel\t40\n#define st_d_ziorigin\t44\n#define st_d_zistepu\t48\n#define st_d_zistepv\t52\n#define st_pad\t\t\t56\n#define st_size\t\t\t64\n\n// clipplane_t structure\n// !!! if this is changed, it must be changed in r_local.h too !!!\n#define cp_normal\t\t0\n#define cp_dist\t\t\t12\n#define cp_next\t\t\t16\n#define cp_leftedge\t\t20\n#define cp_rightedge\t21\n#define cp_reserved\t\t22\n#define cp_size\t\t\t24\n\n// medge_t structure\n// !!! if this is changed, it must be changed in model.h too !!!\n#define me_v\t\t\t\t0\n#define me_cachededgeoffset\t4\n#define me_size\t\t\t\t8\n\n// mvertex_t structure\n// !!! if this is changed, it must be changed in model.h too !!!\n#define mv_position\t\t0\n#define mv_size\t\t\t12\n\n// refdef_t structure\n// !!! if this is changed, it must be changed in render.h too !!!\n#define rd_vrect\t\t\t\t\t0\n#define rd_aliasvrect\t\t\t\t20\n#define rd_vrectright\t\t\t\t40\n#define rd_vrectbottom\t\t\t\t44\n#define rd_aliasvrectright\t\t\t48\n#define rd_aliasvrectbottom\t\t\t52\n#define rd_vrectrightedge\t\t\t56\n#define rd_fvrectx\t\t\t\t\t60\n#define rd_fvrecty\t\t\t\t\t64\n#define rd_fvrectx_adj\t\t\t\t68\n#define rd_fvrecty_adj\t\t\t\t72\n#define rd_vrect_x_adj_shift20\t\t76\n#define rd_vrectright_adj_shift20\t80\n#define rd_fvrectright_adj\t\t\t84\n#define rd_fvrectbottom_adj\t\t\t88\n#define rd_fvrectright\t\t\t\t92\n#define rd_fvrectbottom\t\t\t\t96\n#define rd_horizontalFieldOfView\t100\n#define rd_xOrigin\t\t\t\t\t104\n#define rd_yOrigin\t\t\t\t\t108\n#define rd_vieworg\t\t\t\t\t112\n#define rd_viewangles\t\t\t\t124\n#define rd_ambientlight\t\t\t\t136\n#define rd_size\t\t\t\t\t\t140\n\n// mtriangle_t structure\n// !!! if this is changed, it must be changed in model.h too !!!\n#define mtri_facesfront\t\t0\n#define mtri_vertindex\t\t4\n#define mtri_size\t\t\t16\t// !!! if this changes, array indexing in !!!\n\t\t\t\t\t\t\t\t// !!! d_polysa.s must be changed to match !!!\n#define mtri_shift\t\t\t4\n\n#endif\n"
  },
  {
    "path": "code/unix/quake3.xpm",
    "content": "/* XPM */\nstatic char *quake3[] = {\n/* width height num_colors chars_per_pixel */\n\"    32    32      122            2\",\n/* colors */\n\".. c #6b1008\",\n\".# c #6b1810\",\n\".a c #6b2118\",\n\".b c #6b2921\",\n\".c c #6b3129\",\n\".d c #731810\",\n\".e c #732118\",\n\".f c #732921\",\n\".g c #733129\",\n\".h c #733931\",\n\".i c #733939\",\n\".j c #734239\",\n\".k c #734a4a\",\n\".l c #7b1810\",\n\".m c #7b2118\",\n\".n c #7b2921\",\n\".o c #7b4239\",\n\".p c #7b4a4a\",\n\".q c #7b524a\",\n\".r c #7b5252\",\n\".s c #7b5a5a\",\n\".t c #7b6363\",\n\".u c #7b6b6b\",\n\".v c #7b7373\",\n\".w c #842110\",\n\".x c #842118\",\n\".y c #842921\",\n\".z c #843129\",\n\".A c #843931\",\n\".B c #844239\",\n\".C c #844a42\",\n\".D c #84524a\",\n\".E c #845252\",\n\".F c #845a5a\",\n\".G c #846b63\",\n\".H c #846b6b\",\n\".I c #847373\",\n\".J c #847b7b\",\n\".K c #848484\",\n\".L c #8c2118\",\n\".M c #8c2921\",\n\".N c #8c4239\",\n\".O c #8c4a42\",\n\".P c #8c5a52\",\n\".Q c #8c635a\",\n\".R c #8c6363\",\n\".S c #8c6b6b\",\n\".T c #8c7b7b\",\n\".U c #8c8484\",\n\".V c #8c848c\",\n\".W c #8c8c8c\",\n\".X c #942921\",\n\".Y c #944a42\",\n\".Z c #946363\",\n\".0 c #946b63\",\n\".1 c #947373\",\n\".2 c #947b7b\",\n\".3 c #948484\",\n\".4 c #949494\",\n\".5 c #9c5a5a\",\n\".6 c #9c6363\",\n\".7 c #9c6b63\",\n\".8 c #9c736b\",\n\".9 c #9c7b73\",\n\"#. c #9c7b7b\",\n\"## c #9c8c8c\",\n\"#a c #9c9494\",\n\"#b c #9c949c\",\n\"#c c #9c9c9c\",\n\"#d c #a55a52\",\n\"#e c #a5736b\",\n\"#f c #a57b73\",\n\"#g c #a57b7b\",\n\"#h c #a58484\",\n\"#i c #a58c8c\",\n\"#j c #a59c9c\",\n\"#k c #a5a5a5\",\n\"#l c #ad8c84\",\n\"#m c #ad8c8c\",\n\"#n c #ad9494\",\n\"#o c #ada5a5\",\n\"#p c #adadad\",\n\"#q c #b59c9c\",\n\"#r c #b5a5a5\",\n\"#s c #b5adad\",\n\"#t c #b5b5b5\",\n\"#u c #bda5a5\",\n\"#v c #bdadad\",\n\"#w c #bdb5b5\",\n\"#x c #bdbdbd\",\n\"#y c #c69c9c\",\n\"#z c #c6a59c\",\n\"#A c #c6adad\",\n\"#B c #c6b5ad\",\n\"#C c #c6b5b5\",\n\"#D c #c6bdbd\",\n\"#E c #c6c6c6\",\n\"#F c #ceb5b5\",\n\"#G c #cec6c6\",\n\"#H c #cecece\",\n\"#I c #d6b5b5\",\n\"#J c #d6bdbd\",\n\"#K c #d6c6bd\",\n\"#L c #d6cece\",\n\"#M c #d6d6d6\",\n\"#N c #decec6\",\n\"#O c #decece\",\n\"#P c #ded6ce\",\n\"#Q c #ded6d6\",\n\"#R c #dedede\",\n\"#S c #e7d6d6\",\n\"#T c #e7dede\",\n\"#U c #e7e7e7\",\n\"#V c #efe7e7\",\n\"#W c #efefe7\",\n\"#X c #efefef\",\n\"#Y c #f7efef\",\n\"#Z c #f7f7ef\",\n\"#0 c #f7f7f7\",\n\"#1 c #fff7f7\",\n\"#2 c #fffff7\",\n\"#3 c #ffffff\",\n/* pixels */\n\"#3#2#3#0#3#2#3#2#3#0#3#2#3#2#3#0#3#2#3#2#3#0#3#2#3#2#3#0#3#2#3#2\",\n\"#3#2#3#2#3#0#3#2#3#2#3#0#3#2#Z#A#3#2#3#0#3#2#3#2#3#0#3#2#3#2#3#0\",\n\"#3#2#3#0#3#3#2#3#0#3#3#2#3#3#X#l#U#0#3#2#3#3#0#3#2#3#3#2#3#0#3#3\",\n\"#3#2#3#2#3#0#3#3#2#3#2#3#0#3#Y#e#G#0#3#2#3#2#3#3#0#3#2#3#2#3#0#3\",\n\"#3#2#3#0#3#3#2#3#0#3#3#2#3#2#U.6#D#X#3#2#3#3#0#3#2#3#3#0#3#2#3#2\",\n\"#3#2#3#2#3#0#3#2#3#2#3#3#0#3#Q#d#t#X#3#2#3#2#3#0#3#2#3#3#2#3#0#3\",\n\"#3#2#3#0#3#3#2#3#0#3#2#3#3#2#H.Y#t#X#2#3#1#3#3#2#3#2#3#0#3#3#2#3\",\n\"#3#2#3#2#3#0#3#3#2#3#2#3#0#3#G.N#s#X#3#2#3#2#3#3#0#3#2#3#2#3#3#0\",\n\"#3#2#3#0#3#3#2#3#0#3#3#2#3#2#A.A#o#W#3#0#3#3#2#3#2#3#3#0#3#2#3#2\",\n\"#3#Z#O#s#R#2#3#2#3#2#3#3#0#3#r.z#k#U#2#3#0#3#2#3#2#T#F#L#X#2#3#0\",\n\"#O.2#B#V#X#X#3#2#3#3#0#3#2#3#n.m#a#U#2#3#3#0#3#2#3#3#X#C#.#u#2#3\",\n\".D#Q#M#H#M#Z#3#3#0#3#2#3#2#3#h.x.W#R#3#2#3#2#3#3#0#3#Z#R#D.C#M#0\",\n\".7.D#n#R#1#3#2#3#2#3#0#3#3#1#f.x.W#R#2#3#1#3#2#3#2#0#X#F.5.o#s#U\",\n\"#V.R.b.f.C.7#i#y#F#K#N#O#P#X.8.w.K#D#O#N#J#I#z#h.7.C.f.f.P#v#k#R\",\n\"#3#R#a.s.h.a.#...d.d.m.y.n#A.Z.x.I.D.y.m.e.#...#.a.i.t###a#c#x#Y\",\n\"#3#1#W#E#k.T.H.k.j.j.h.y.m.1.C.L.v.o.l.a.b.h.k.u.v.J.W#c#t#M#0#3\",\n\"#3#2#3#0#Z#R#E#t#b#a.W.H.y.t.p.X.J.o.g.v.J.V.W.4#o#x#M#V#0#3#2#3\",\n\"#3#2#3#2#3#3#1#0#X#U#R#r.n.I.q.M.J.p.g.U#t#M#R#V#0#0#2#3#2#3#2#3\",\n\"#3#2#3#0#3#2#3#2#3#2#3#N.z.J.E.x.K.D.h.4#T#3#2#3#2#3#2#3#0#3#3#2\",\n\"#3#2#3#2#3#3#0#3#2#3#2#O.A.K.Q.m.K.F.o#a#U#3#2#3#0#3#3#2#3#2#3#0\",\n\"#3#2#3#0#3#2#3#3#2#3#0#S.B.U.T.d.4.0.p#c#X#3#2#3#2#3#0#3#3#2#3#2\",\n\"#3#2#3#2#3#3#0#3#2#3#3#S.O.4.3.e.4#g.r#p#X#3#2#3#0#3#3#2#3#0#3#3\",\n\"#3#2#3#0#3#2#3#2#3#0#3#T.C#a.4.b.4#h.G#s#Z#3#3#2#3#0#3#2#3#2#3#2\",\n\"#3#2#3#2#3#3#0#3#2#3#2#U.F#j#o.c.4#m.T#w#0#3#0#3#2#3#3#2#3#0#3#3\",\n\"#3#2#3#0#3#2#3#3#2#3#0#Y.S#o#t.j#j#q###x#0#3#2#3#3#0#3#2#3#3#2#3\",\n\"#3#2#3#2#3#3#0#3#2#3#3#0.9#w#G.p#k#r#o#E#0#3#2#3#2#3#0#3#2#3#2#3\",\n\"#3#2#3#0#3#2#3#2#3#0#3#2#n#E#Q.Q#p#w#x#G#0#3#2#3#3#2#3#0#3#3#2#3\",\n\"#3#2#3#2#3#3#0#3#2#3#3#2#R#H#T.3#t#R#T#R#2#3#2#3#0#3#3#2#3#2#3#0\",\n\"#3#2#3#0#3#2#3#3#2#3#0#3#2#U#U#s#D#0#0#W#3#3#0#3#2#3#2#3#3#0#3#2\",\n\"#3#2#3#2#3#3#0#3#2#3#3#2#3#2#3#X#E#0#3#2#3#0#3#3#2#3#0#3#2#3#3#0\",\n\"#3#2#3#0#3#2#3#2#3#0#3#2#3#3#0#3#W#2#3#0#3#3#2#3#0#3#3#2#3#0#3#2\",\n\"#3#2#3#2#3#3#0#3#2#3#3#2#3#0#3#2#3#3#0#3#2#3#2#3#2#3#0#3#3#2#3#2\"\n};\n"
  },
  {
    "path": "code/unix/run-target.sh",
    "content": "#!/bin/sh\n# for easy use with Anjuta\ncd `dirname $0`/debugi386-glibc\necho \"in $PWD\"\n\n# now execute whatever you want\n#./linuxquake3-smp +set fs_basepath /usr/local/games/quake3 +set developer 1 +set r_smp 1 +set r_showsmp 1 +devmap mythology\n\n#gvd ./linuxquake3-smp --pargs +set logfile 2 +set fs_basepath /usr/local/games/quake3 +set developer 1 +set r_smp 0 +set r_showsmp 1 +devmap mythology\n\n./linuxquake3-smp +set logfile 2 +set fs_basepath /usr/local/games/quake3 +set developer 1 +set r_smp 1 +set r_fullscreen 0 +set r_showsmp 1 +devmap mythology &\ngvd ./linuxquake3-smp\n"
  },
  {
    "path": "code/unix/snapvector.nasm",
    "content": ";===========================================================================\n;Copyright (C) 1999-2005 Id Software, Inc.\n;\n;This file is part of Quake III Arena source code.\n;\n;Quake III Arena source code is free software; you can redistribute it\n;and/or modify it under the terms of the GNU General Public License as\n;published by the Free Software Foundation; either version 2 of the License,\n;or (at your option) any later version.\n;\n;Quake III Arena source code is distributed in the hope that it will be\n;useful, but WITHOUT ANY WARRANTY; without even the implied warranty of\n;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n;GNU General Public License for more details.\n;\n;You should have received a copy of the GNU General Public License\n;along with Foobar; if not, write to the Free Software\n;Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n;===========================================================================\n\n;\n; Sys_SnapVector NASM code (Andrew Henderson)\n; See win32/win_shared.c for the Win32 equivalent\n; This code is provided to ensure that the\n;  rounding behavior (and, if necessary, the\n;  precision) of DLL and QVM code are identical\n;  e.g. for network-visible operations.\n; See ftol.nasm for operations on a single float,\n;  as used in compiled VM and DLL code that does\n;  not use this system trap.\n;\n\n\nsegment .data\n\nfpucw\tdd\t0\ncw037F  dd 0x037F   ; Rounding to nearest (even). \n\nsegment .text\n\n; void Sys_SnapVector( float *v )\nglobal Sys_SnapVector\nSys_SnapVector:\n\tpush \teax\n\tpush \tebp\n\tmov\tebp, esp\n\n\tfnstcw\t[fpucw]\n\tmov\teax, dword [ebp + 12]\n\tfldcw\t[cw037F]\t\n\tfld\tdword [eax]\n\tfistp\tdword [eax]\n\tfild\tdword [eax]\n\tfstp\tdword [eax]\n\tfld\tdword [eax + 4]\n\tfistp\tdword [eax + 4]\n\tfild\tdword [eax + 4]\n\tfstp\tdword [eax + 4]\n\tfld\tdword [eax + 8]\n\tfistp\tdword [eax + 8]\n\tfild\tdword [eax + 8]\n\tfstp\tdword [eax + 8]\n\tfldcw\t[fpucw]\n\t\n\tpop ebp\n\tpop eax\n\tret\n\t\n; void Sys_SnapVectorCW( float *v, unsigned short int cw )\nglobal Sys_SnapVectorCW\nSys_SnapVector_cw:\n\tpush \teax\n\tpush \tebp\n\tmov\tebp, esp\n\n\tfnstcw\t[fpucw]\n\tmov\teax, dword [ebp + 12]\n\tfldcw\t[ebp + 16]\t\n\tfld\tdword [eax]\n\tfistp\tdword [eax]\n\tfild\tdword [eax]\n\tfstp\tdword [eax]\t\n\tfld\tdword [eax + 4]\n\tfistp\tdword [eax + 4]\n\tfild\tdword [eax + 4]\n\tfstp\tdword [eax + 4]\n\tfld\tdword [eax + 8]\n\tfistp\tdword [eax + 8]\n\tfild\tdword [eax + 8]\n\tfstp\tdword [eax + 8]\n\tfldcw\t[fpucw]\n\t\n\tpop ebp\n\tpop eax\n\tret"
  },
  {
    "path": "code/unix/snd_mixa.s",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// snd_mixa.s\n// x86 assembly-language sound code\n//\n\n#include \"qasm.h\"\n\n#if\tid386\n\n\t.text\n\n#if 0 \n//----------------------------------------------------------------------\n// 8-bit sound-mixing code\n//----------------------------------------------------------------------\n\n#define ch\t\t4+16\n#define sc\t\t8+16\n#define count\t12+16\n\n.globl C(S_PaintChannelFrom8)\nC(S_PaintChannelFrom8):\n\tpushl\t%esi\t\t\t\t// preserve register variables\n\tpushl\t%edi\n\tpushl\t%ebx\n\tpushl\t%ebp\n\n//\tint \tdata;\n//\tshort\t*lscale, *rscale;\n//\tunsigned char *sfx;\n//\tint\t\ti;\n\n\tmovl\tch(%esp),%ebx\n\tmovl\tsc(%esp),%esi\n\n//\tif (ch->leftvol > 255)\n//\t\tch->leftvol = 255;\n//\tif (ch->rightvol > 255)\n//\t\tch->rightvol = 255;\n\tmovl\tch_leftvol(%ebx),%eax\n\tmovl\tch_rightvol(%ebx),%edx\n\tcmpl\t$255,%eax\n\tjna\t\tLLeftSet\n\tmovl\t$255,%eax\nLLeftSet:\n\tcmpl\t$255,%edx\n\tjna\t\tLRightSet\n\tmovl\t$255,%edx\nLRightSet:\n\n//\tlscale = snd_scaletable[ch->leftvol >> 3];\n//\trscale = snd_scaletable[ch->rightvol >> 3];\n//\tsfx = (signed char *)sc->data + ch->pos;\n//\tch->pos += count;\n\tandl\t$0xF8,%eax\n\taddl\t$20,%esi\n\tmovl\t(%esi),%esi\n\tandl\t$0xF8,%edx\n\tmovl\tch_pos(%ebx),%edi\n\tmovl\tcount(%esp),%ecx\n\taddl\t%edi,%esi\n\tshll\t$7,%eax\n\taddl\t%ecx,%edi\n\tshll\t$7,%edx\n\tmovl\t%edi,ch_pos(%ebx)\n\taddl\t$(C(snd_scaletable)),%eax\n\taddl\t$(C(snd_scaletable)),%edx\n\tsubl\t%ebx,%ebx\n\tmovb\t-1(%esi,%ecx,1),%bl\n\n\ttestl\t$1,%ecx\n\tjz\t\tLMix8Loop\n\n\tmovl\t(%eax,%ebx,4),%edi\n\tmovl\t(%edx,%ebx,4),%ebp\n\taddl\tC(paintbuffer)+psp_left-psp_size(,%ecx,psp_size),%edi\n\taddl\tC(paintbuffer)+psp_right-psp_size(,%ecx,psp_size),%ebp\n\tmovl\t%edi,C(paintbuffer)+psp_left-psp_size(,%ecx,psp_size)\n\tmovl\t%ebp,C(paintbuffer)+psp_right-psp_size(,%ecx,psp_size)\n\tmovb\t-2(%esi,%ecx,1),%bl\n\n\tdecl\t%ecx\n\tjz\t\tLDone\n\n//\tfor (i=0 ; i<count ; i++)\n//\t{\nLMix8Loop:\n\n//\t\tdata = sfx[i];\n//\t\tpaintbuffer[i].left += lscale[data];\n//\t\tpaintbuffer[i].right += rscale[data];\n\tmovl\t(%eax,%ebx,4),%edi\n\tmovl\t(%edx,%ebx,4),%ebp\n\taddl\tC(paintbuffer)+psp_left-psp_size(,%ecx,psp_size),%edi\n\taddl\tC(paintbuffer)+psp_right-psp_size(,%ecx,psp_size),%ebp\n\tmovb\t-2(%esi,%ecx,1),%bl\n\tmovl\t%edi,C(paintbuffer)+psp_left-psp_size(,%ecx,psp_size)\n\tmovl\t%ebp,C(paintbuffer)+psp_right-psp_size(,%ecx,psp_size)\n\n\tmovl\t(%eax,%ebx,4),%edi\n\tmovl\t(%edx,%ebx,4),%ebp\n\tmovb\t-3(%esi,%ecx,1),%bl\n\taddl\tC(paintbuffer)+psp_left-psp_size*2(,%ecx,psp_size),%edi\n\taddl\tC(paintbuffer)+psp_right-psp_size*2(,%ecx,psp_size),%ebp\n\tmovl\t%edi,C(paintbuffer)+psp_left-psp_size*2(,%ecx,psp_size)\n\tmovl\t%ebp,C(paintbuffer)+psp_right-psp_size*2(,%ecx,psp_size)\n\n//\t}\n\tsubl\t$2,%ecx\n\tjnz\t\tLMix8Loop\n\nLDone:\n\tpopl\t%ebp\n\tpopl\t%ebx\n\tpopl\t%edi\n\tpopl\t%esi\n\n\tret\n\n\n#endif\n\n//----------------------------------------------------------------------\n// Transfer of stereo buffer to 16-bit DMA buffer code\n//----------------------------------------------------------------------\n\n.globl C(S_WriteLinearBlastStereo16)\nC(S_WriteLinearBlastStereo16):\n\tpushl\t%edi\n\tpushl\t%ebx\n\n//\tint\t\ti;\n//\tint\t\tval;\n\tmovl\tC(snd_linear_count),%ecx\n\tmovl\tC(snd_p),%ebx\n\tmovl\tC(snd_out),%edi\n\n//\tfor (i=0 ; i<snd_linear_count ; i+=2)\n//\t{\nLWLBLoopTop:\n\n//\t\tval = (snd_p[i]*snd_vol)>>8;\n//\t\tif (val > 0x7fff)\n//\t\t\tsnd_out[i] = 0x7fff;\n//\t\telse if (val < (short)0x8000)\n//\t\t\tsnd_out[i] = (short)0x8000;\n//\t\telse\n//\t\t\tsnd_out[i] = val;\n\tmovl\t-8(%ebx,%ecx,4),%eax\n\tsarl\t$8,%eax\n\tcmpl\t$0x7FFF,%eax\n\tjg\t\tLClampHigh\n\tcmpl\t$0xFFFF8000,%eax\n\tjnl\t\tLClampDone\n\tmovl\t$0xFFFF8000,%eax\n\tjmp\t\tLClampDone\nLClampHigh:\n\tmovl\t$0x7FFF,%eax\nLClampDone:\n\n//\t\tval = (snd_p[i+1]*snd_vol)>>8;\n//\t\tif (val > 0x7fff)\n//\t\t\tsnd_out[i+1] = 0x7fff;\n//\t\telse if (val < (short)0x8000)\n//\t\t\tsnd_out[i+1] = (short)0x8000;\n//\t\telse\n//\t\t\tsnd_out[i+1] = val;\n\tmovl\t-4(%ebx,%ecx,4),%edx\n\tsarl\t$8,%edx\n\tcmpl\t$0x7FFF,%edx\n\tjg\t\tLClampHigh2\n\tcmpl\t$0xFFFF8000,%edx\n\tjnl\t\tLClampDone2\n\tmovl\t$0xFFFF8000,%edx\n\tjmp\t\tLClampDone2\nLClampHigh2:\n\tmovl\t$0x7FFF,%edx\nLClampDone2:\n\tshll\t$16,%edx\n\tandl\t$0xFFFF,%eax\n\torl\t\t%eax,%edx\n\tmovl\t%edx,-4(%edi,%ecx,2)\n\n//\t}\n\tsubl\t$2,%ecx\n\tjnz\t\tLWLBLoopTop\n\n//\tsnd_p += snd_linear_count;\n\n\tpopl\t%ebx\n\tpopl\t%edi\n\n\tret\n\n#endif\t// id386\n\n"
  },
  {
    "path": "code/unix/sys_dosa.s",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// sys_dosa.s\n// x86 assembly-language DOS-dependent routines.\n\n#include \"qasm.h\"\n\n\n\t.data\n\n\t.align\t4\nfpenv:\n\t.long\t0, 0, 0, 0, 0, 0, 0, 0\n\n\t.text\n\n.globl C(MaskExceptions)\nC(MaskExceptions):\n\tfnstenv\tfpenv\n\torl\t\t$0x3F,fpenv\n\tfldenv\tfpenv\n\n\tret\n\n#if 0\n.globl C(unmaskexceptions)\nC(unmaskexceptions):\n\tfnstenv\tfpenv\n\tandl\t\t$0xFFFFFFE0,fpenv\n\tfldenv\tfpenv\n\n\tret\n#endif\n\n\t.data\n\n\t.align\t4\n.globl\tceil_cw, single_cw, full_cw, cw, pushed_cw\nceil_cw:\t.long\t0\nsingle_cw:\t.long\t0\nfull_cw:\t.long\t0\ncw:\t\t\t.long\t0\npushed_cw:\t.long\t0\n\n\t.text\n\n.globl C(Sys_LowFPPrecision)\nC(Sys_LowFPPrecision):\n\tfldcw\tsingle_cw\n\n\tret\n\n.globl C(Sys_HighFPPrecision)\nC(Sys_HighFPPrecision):\n\tfldcw\tfull_cw\n\n\tret\n\n.globl C(Sys_PushFPCW_SetHigh)\nC(Sys_PushFPCW_SetHigh):\n\tfnstcw\tpushed_cw\n\tfldcw\tfull_cw\n\n\tret\n\n.globl C(Sys_PopFPCW)\nC(Sys_PopFPCW):\n\tfldcw\tpushed_cw\n\n\tret\n\n.globl C(Sys_SetFPCW)\nC(Sys_SetFPCW):\n\tfnstcw\tcw\n\tmovl\tcw,%eax\n#if\tid386\n\tandb\t$0xF0,%ah\n\torb\t\t$0x03,%ah\t// round mode, 64-bit precision\n#endif\n\tmovl\t%eax,full_cw\n\n#if\tid386\n\tandb\t$0xF0,%ah\n\torb\t\t$0x0C,%ah\t// chop mode, single precision\n#endif\n\tmovl\t%eax,single_cw\n\n#if\tid386\n\tandb\t$0xF0,%ah\n\torb\t\t$0x08,%ah\t// ceil mode, single precision\n#endif\n\tmovl\t%eax,ceil_cw\n\n\tret\n\n"
  },
  {
    "path": "code/unix/unix_glw.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !( defined __linux__ || defined __FreeBSD__ )\n#error You should include this file only on Linux/FreeBSD platforms\n#endif\n\n#ifndef __GLW_LINUX_H__\n#define __GLW_LINUX_H__\n\ntypedef struct\n{\n\tvoid *OpenGLLib; // instance of OpenGL library\n\n\tFILE *log_fp;\n} glwstate_t;\n\nextern glwstate_t glw_state;\n\n#endif\n"
  },
  {
    "path": "code/unix/unix_main.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include <unistd.h>\n#include <signal.h>\n#include <stdlib.h>\n#include <limits.h>\n#include <sys/time.h>\n#include <sys/types.h>\n#include <unistd.h>\n#include <fcntl.h>\n#include <stdarg.h>\n#include <stdio.h>\n#include <sys/ipc.h>\n#include <sys/shm.h>\n#include <sys/stat.h>\n#include <string.h>\n#include <ctype.h>\n#include <sys/wait.h>\n#include <sys/mman.h>\n#include <errno.h>\n#ifdef __linux__ // rb010123\n  #include <mntent.h>\n#endif\n#include <dlfcn.h>\n\n#ifdef __linux__\n  #include <fpu_control.h> // bk001213 - force dumps on divide by zero\n#endif\n\n// FIXME TTimo should we gard this? most *nix system should comply?\n#include <termios.h>\n\n#include \"../game/q_shared.h\"\n#include \"../qcommon/qcommon.h\"\n#include \"../renderer/tr_public.h\"\n\n#include \"linux_local.h\" // bk001204\n\n// Structure containing functions exported from refresh DLL\nrefexport_t re;\n\nunsigned  sys_frame_time;\n\nuid_t saved_euid;\nqboolean stdin_active = qtrue;\n\n// =============================================================\n// tty console variables\n// =============================================================\n\n// enable/disabled tty input mode\n// NOTE TTimo this is used during startup, cannot be changed during run\nstatic cvar_t *ttycon = NULL;\n// general flag to tell about tty console mode\nstatic qboolean ttycon_on = qfalse;\n// when printing general stuff to stdout stderr (Sys_Printf)\n//   we need to disable the tty console stuff\n// this increments so we can recursively disable\nstatic int ttycon_hide = 0;\n// some key codes that the terminal may be using\n// TTimo NOTE: I'm not sure how relevant this is\nstatic int tty_erase;\nstatic int tty_eof;\n\nstatic struct termios tty_tc;\n\nstatic field_t tty_con;\n\n// history\n// NOTE TTimo this is a bit duplicate of the graphical console history\n//   but it's safer and faster to write our own here\n#define TTY_HISTORY 32\nstatic field_t ttyEditLines[TTY_HISTORY];\nstatic int hist_current = -1, hist_count = 0;\n\n// =======================================================================\n// General routines\n// =======================================================================\n\n// bk001207 \n#define MEM_THRESHOLD 96*1024*1024\n\n/*\n==================\nSys_LowPhysicalMemory()\n==================\n*/\nqboolean Sys_LowPhysicalMemory() {\n  //MEMORYSTATUS stat;\n  //GlobalMemoryStatus (&stat);\n  //return (stat.dwTotalPhys <= MEM_THRESHOLD) ? qtrue : qfalse;\n  return qfalse; // bk001207 - FIXME\n}\n\n/*\n==================\nSys_FunctionCmp\n==================\n*/\nint Sys_FunctionCmp(void *f1, void *f2) {\n  return qtrue;\n}\n\n/*\n==================\nSys_FunctionCheckSum\n==================\n*/\nint Sys_FunctionCheckSum(void *f1) {\n  return 0;\n}\n\n/*\n==================\nSys_MonkeyShouldBeSpanked\n==================\n*/\nint Sys_MonkeyShouldBeSpanked( void ) {\n  return 0;\n}\n\nvoid Sys_BeginProfiling( void ) {\n}\n\n/*\n=================\nSys_In_Restart_f\n\nRestart the input subsystem\n=================\n*/\nvoid Sys_In_Restart_f( void ) \n{\n  IN_Shutdown();\n  IN_Init();\n}\n\n// =============================================================\n// tty console routines\n// NOTE: if the user is editing a line when something gets printed to the early console then it won't look good\n//   so we provide tty_Clear and tty_Show to be called before and after a stdout or stderr output\n// =============================================================\n\n// flush stdin, I suspect some terminals are sending a LOT of shit\n// FIXME TTimo relevant?\nvoid tty_FlushIn()\n{\n  char key;\n  while (read(0, &key, 1)!=-1);\n}\n\n// do a backspace\n// TTimo NOTE: it seems on some terminals just sending '\\b' is not enough\n//   so for now, in any case we send \"\\b \\b\" .. yeah well ..\n//   (there may be a way to find out if '\\b' alone would work though)\nvoid tty_Back()\n{\n  char key;\n  key = '\\b';\n  write(1, &key, 1);\n  key = ' ';\n  write(1, &key, 1);\n  key = '\\b';\n  write(1, &key, 1);\n}\n\n// clear the display of the line currently edited\n// bring cursor back to beginning of line\nvoid tty_Hide()\n{\n  int i;\n  assert(ttycon_on);\n  if (ttycon_hide)\n  {\n    ttycon_hide++;\n    return;\n  }\n  if (tty_con.cursor>0)\n  {\n    for (i=0; i<tty_con.cursor; i++)\n    {\n      tty_Back();\n    }\n  }\n  ttycon_hide++;\n}\n\n// show the current line\n// FIXME TTimo need to position the cursor if needed??\nvoid tty_Show()\n{\n  int i;\n  assert(ttycon_on);\n  assert(ttycon_hide>0);\n  ttycon_hide--;\n  if (ttycon_hide == 0)\n  {\n    if (tty_con.cursor)\n    {\n      for (i=0; i<tty_con.cursor; i++)\n      {\n        write(1, tty_con.buffer+i, 1);\n      }\n    }\n  }\n}\n\n// never exit without calling this, or your terminal will be left in a pretty bad state\nvoid Sys_ConsoleInputShutdown()\n{\n  if (ttycon_on)\n  {\n    Com_Printf(\"Shutdown tty console\\n\");\n    tcsetattr (0, TCSADRAIN, &tty_tc);\n  }\n}\n\nvoid Hist_Add(field_t *field)\n{\n  int i;\n  assert(hist_count <= TTY_HISTORY);\n  assert(hist_count >= 0);\n  assert(hist_current >= -1);\n  assert(hist_current <= hist_count);\n  // make some room\n  for (i=TTY_HISTORY-1; i>0; i--)\n  {\n    ttyEditLines[i] = ttyEditLines[i-1];\n  }\n  ttyEditLines[0] = *field;\n  if (hist_count<TTY_HISTORY)\n  {\n    hist_count++;\n  }\n  hist_current = -1; // re-init\n}\n\nfield_t *Hist_Prev()\n{\n  int hist_prev;\n  assert(hist_count <= TTY_HISTORY);\n  assert(hist_count >= 0);\n  assert(hist_current >= -1);\n  assert(hist_current <= hist_count);\n  hist_prev = hist_current + 1;\n  if (hist_prev >= hist_count)\n  {\n    return NULL;\n  }\n  hist_current++;\n  return &(ttyEditLines[hist_current]);\n}\n\nfield_t *Hist_Next()\n{\n  assert(hist_count <= TTY_HISTORY);\n  assert(hist_count >= 0);\n  assert(hist_current >= -1);\n  assert(hist_current <= hist_count);\n  if (hist_current >= 0)\n  {\n    hist_current--;\n  }\n  if (hist_current == -1)\n  {\n    return NULL;\n  }\n  return &(ttyEditLines[hist_current]);\n}\n\n// =============================================================\n// general sys routines\n// =============================================================\n\n#if 0\n// NOTE TTimo this is not used .. looks interesting though? protection against buffer overflow kind of stuff?\nvoid Sys_Printf (char *fmt, ...)\n{\n  va_list   argptr;\n  char    text[1024];\n  unsigned char   *p;\n\n  va_start (argptr,fmt);\n  vsprintf (text,fmt,argptr);\n  va_end (argptr);\n\n  if (strlen(text) > sizeof(text))\n    Sys_Error(\"memory overwrite in Sys_Printf\");\n\n  for (p = (unsigned char *)text; *p; p++)\n  {\n    *p &= 0x7f;\n    if ((*p > 128 || *p < 32) && *p != 10 && *p != 13 && *p != 9)\n      printf(\"[%02x]\", *p);\n    else\n      putc(*p, stdout);\n  }\n}\n#endif\n\n// single exit point (regular exit or in case of signal fault)\nvoid Sys_Exit( int ex ) {\n  Sys_ConsoleInputShutdown();\n\n#ifdef NDEBUG // regular behavior\n\n  // We can't do this \n  //  as long as GL DLL's keep installing with atexit...\n  //exit(ex);\n  _exit(ex);\n#else\n\n  // Give me a backtrace on error exits.\n  assert( ex == 0 );\n  exit(ex);\n#endif\n}\n\n\nvoid Sys_Quit (void) {\n  CL_Shutdown ();\n  fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);\n  Sys_Exit(0);\n}\n\nvoid Sys_Init(void)\n{\n  Cmd_AddCommand (\"in_restart\", Sys_In_Restart_f);\n\n#if defined __linux__\n#if defined __i386__\n  Cvar_Set( \"arch\", \"linux i386\" );\n#elif defined __alpha__\n  Cvar_Set( \"arch\", \"linux alpha\" );\n#elif defined __sparc__\n  Cvar_Set( \"arch\", \"linux sparc\" );\n#elif defined __FreeBSD__\n\n#if defined __i386__ // FreeBSD\n  Cvar_Set( \"arch\", \"freebsd i386\" );\n#elif defined __alpha__\n  Cvar_Set( \"arch\", \"freebsd alpha\" );\n#else\n  Cvar_Set( \"arch\", \"freebsd unknown\" );\n#endif // FreeBSD\n\n#else\n  Cvar_Set( \"arch\", \"linux unknown\" );\n#endif\n#elif defined __sun__\n#if defined __i386__\n  Cvar_Set( \"arch\", \"solaris x86\" );\n#elif defined __sparc__\n  Cvar_Set( \"arch\", \"solaris sparc\" );\n#else\n  Cvar_Set( \"arch\", \"solaris unknown\" );\n#endif\n#elif defined __sgi__\n#if defined __mips__\n  Cvar_Set( \"arch\", \"sgi mips\" );\n#else\n  Cvar_Set( \"arch\", \"sgi unknown\" );\n#endif\n#else\n  Cvar_Set( \"arch\", \"unknown\" );\n#endif\n\n  Cvar_Set( \"username\", Sys_GetCurrentUser() );\n\n  IN_Init();\n\n}\n\nvoid  Sys_Error( const char *error, ...)\n{ \n  va_list     argptr;\n  char        string[1024];\n\n  // change stdin to non blocking\n  // NOTE TTimo not sure how well that goes with tty console mode\n  fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);\n\n  // don't bother do a show on this one heh\n  if (ttycon_on)\n  {\n    tty_Hide();\n  }\n\n  CL_Shutdown ();\n\n  va_start (argptr,error);\n  vsprintf (string,error,argptr);\n  va_end (argptr);\n  fprintf(stderr, \"Sys_Error: %s\\n\", string);\n\n  Sys_Exit( 1 ); // bk010104 - use single exit point.\n} \n\nvoid Sys_Warn (char *warning, ...)\n{ \n  va_list     argptr;\n  char        string[1024];\n\n  va_start (argptr,warning);\n  vsprintf (string,warning,argptr);\n  va_end (argptr);\n\n  if (ttycon_on)\n  {\n    tty_Hide();\n  }\n\n  fprintf(stderr, \"Warning: %s\", string);\n\n  if (ttycon_on)\n  {\n    tty_Show();\n  }\n} \n\n/*\n============\nSys_FileTime\n\nreturns -1 if not present\n============\n*/\nint Sys_FileTime (char *path)\n{\n  struct  stat  buf;\n\n  if (stat (path,&buf) == -1)\n    return -1;\n\n  return buf.st_mtime;\n}\n\nvoid floating_point_exception_handler(int whatever)\n{\n  signal(SIGFPE, floating_point_exception_handler);\n}\n\n// initialize the console input (tty mode if wanted and possible)\nvoid Sys_ConsoleInputInit()\n{\n  struct termios tc;\n\n  // TTimo \n  // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=390\n  // ttycon 0 or 1, if the process is backgrounded (running non interactively)\n  // then SIGTTIN or SIGTOU is emitted, if not catched, turns into a SIGSTP\n  signal(SIGTTIN, SIG_IGN);\n  signal(SIGTTOU, SIG_IGN);\n\n  // FIXME TTimo initialize this in Sys_Init or something?\n  ttycon = Cvar_Get(\"ttycon\", \"1\", 0);\n  if (ttycon && ttycon->value)\n  {\n    if (isatty(STDIN_FILENO)!=1)\n    {\n      Com_Printf(\"stdin is not a tty, tty console mode failed\\n\");\n      Cvar_Set(\"ttycon\", \"0\");\n      ttycon_on = qfalse;\n      return;\n    }\n    Com_Printf(\"Started tty console (use +set ttycon 0 to disable)\\n\");\n    Field_Clear(&tty_con);\n    tcgetattr (0, &tty_tc);\n    tty_erase = tty_tc.c_cc[VERASE];\n    tty_eof = tty_tc.c_cc[VEOF];\n    tc = tty_tc;\n    /*\n     ECHO: don't echo input characters\n     ICANON: enable canonical mode.  This  enables  the  special\n              characters  EOF,  EOL,  EOL2, ERASE, KILL, REPRINT,\n              STATUS, and WERASE, and buffers by lines.\n     ISIG: when any of the characters  INTR,  QUIT,  SUSP,  or\n              DSUSP are received, generate the corresponding sig\n              nal\n    */              \n    tc.c_lflag &= ~(ECHO | ICANON);\n    /*\n     ISTRIP strip off bit 8\n     INPCK enable input parity checking\n     */\n    tc.c_iflag &= ~(ISTRIP | INPCK);\n    tc.c_cc[VMIN] = 1;\n    tc.c_cc[VTIME] = 0;\n    tcsetattr (0, TCSADRAIN, &tc);    \n    ttycon_on = qtrue;\n  } else\n    ttycon_on = qfalse;\n}\n\nchar *Sys_ConsoleInput(void)\n{\n  // we use this when sending back commands\n  static char text[256];\n  int i;\n  int avail;\n  char key;\n  field_t *history;\n\n  if (ttycon && ttycon->value)\n  {\n    avail = read(0, &key, 1);\n    if (avail != -1)\n    {\n      // we have something\n      // backspace?\n      // NOTE TTimo testing a lot of values .. seems it's the only way to get it to work everywhere\n      if ((key == tty_erase) || (key == 127) || (key == 8))\n      {\n        if (tty_con.cursor > 0)\n        {\n          tty_con.cursor--;\n          tty_con.buffer[tty_con.cursor] = '\\0';\n          tty_Back();\n        }\n        return NULL;\n      }\n      // check if this is a control char\n      if ((key) && (key) < ' ')\n      {\n        if (key == '\\n')\n        {\n          // push it in history\n          Hist_Add(&tty_con);\n          strcpy(text, tty_con.buffer);\n          Field_Clear(&tty_con);\n          key = '\\n';\n          write(1, &key, 1);\n          return text;\n        }\n        if (key == '\\t')\n        {\n          tty_Hide();\n          Field_CompleteCommand( &tty_con );\n          // Field_CompleteCommand does weird things to the string, do a cleanup\n          //   it adds a '\\' at the beginning of the string\n          //   cursor doesn't reflect actual length of the string that's sent back\n          tty_con.cursor = strlen(tty_con.buffer);\n          if (tty_con.cursor>0)\n          {\n            if (tty_con.buffer[0] == '\\\\')\n            {\n              for (i=0; i<=tty_con.cursor; i++)\n              {\n                tty_con.buffer[i] = tty_con.buffer[i+1];\n              }\n              tty_con.cursor--;\n            }\n          }\n          tty_Show();\n          return NULL;\n        }\n        avail = read(0, &key, 1);\n        if (avail != -1)\n        {\n          // VT 100 keys\n          if (key == '[' || key == 'O')\n          {\n            avail = read(0, &key, 1);\n            if (avail != -1)\n            {\n              switch (key)\n              {\n              case 'A':\n                history = Hist_Prev();\n                if (history)\n                {\n                  tty_Hide();\n                  tty_con = *history;\n                  tty_Show();\n                }\n                tty_FlushIn();\n                return NULL;\n                break;\n              case 'B':\n                history = Hist_Next();\n                tty_Hide();\n                if (history)\n                {\n                  tty_con = *history;\n                } else\n                {\n                  Field_Clear(&tty_con);\n                }\n                tty_Show();\n                tty_FlushIn();\n                return NULL;\n                break;\n              case 'C':\n                return NULL;\n              case 'D':\n                return NULL;\n              }\n            }\n          }\n        }\n        Com_DPrintf(\"droping ISCTL sequence: %d, tty_erase: %d\\n\", key, tty_erase);\n        tty_FlushIn();\n        return NULL;\n      }\n      // push regular character\n      tty_con.buffer[tty_con.cursor] = key;\n      tty_con.cursor++;\n      // print the current line (this is differential)\n      write(1, &key, 1);\n    }\n    return NULL;\n  } else\n  {\n    int     len;\n    fd_set  fdset;\n    struct timeval timeout;\n\n    if (!com_dedicated || !com_dedicated->value)\n      return NULL;\n\n    if (!stdin_active)\n      return NULL;\n\n    FD_ZERO(&fdset);\n    FD_SET(0, &fdset); // stdin\n    timeout.tv_sec = 0;\n    timeout.tv_usec = 0;\n    if (select (1, &fdset, NULL, NULL, &timeout) == -1 || !FD_ISSET(0, &fdset))\n    {\n      return NULL;\n    }\n\n    len = read (0, text, sizeof(text));\n    if (len == 0)\n    { // eof!\n      stdin_active = qfalse;\n      return NULL;\n    }\n\n    if (len < 1)\n      return NULL;\n    text[len-1] = 0;    // rip off the /n and terminate\n\n    return text;\n  }\n}\n\n/*****************************************************************************/\n\n/*\n=================\nSys_UnloadDll\n\n=================\n*/\nvoid Sys_UnloadDll( void *dllHandle ) {\n  // bk001206 - verbose error reporting\n  const char* err; // rb010123 - now const\n  if ( !dllHandle )\n  {\n    Com_Printf(\"Sys_UnloadDll(NULL)\\n\");\n    return;\n  }\n  dlclose( dllHandle );\n  err = dlerror();\n  if ( err != NULL )\n    Com_Printf ( \"Sys_UnloadGame failed on dlclose: \\\"%s\\\"!\\n\", err );\n}\n\n\n/*\n=================\nSys_LoadDll\n\nUsed to load a development dll instead of a virtual machine\nTTimo:\nchanged the load procedure to match VFS logic, and allow developer use\n#1 look down current path\n#2 look in fs_homepath\n#3 look in fs_basepath\n=================\n*/\nextern char   *FS_BuildOSPath( const char *base, const char *game, const char *qpath );\n\nvoid *Sys_LoadDll( const char *name, char *fqpath ,\n                   int (**entryPoint)(int, ...),\n                   int (*systemcalls)(int, ...) ) \n{\n  void *libHandle;\n  void  (*dllEntry)( int (*syscallptr)(int, ...) );\n  char  curpath[MAX_OSPATH];\n  char  fname[MAX_OSPATH];\n  char  *basepath;\n  char  *homepath;\n  char  *pwdpath;\n  char  *gamedir;\n  char  *fn;\n  const char*  err = NULL;\n\t\n\t*fqpath = 0;\n\n  // bk001206 - let's have some paranoia\n  assert( name );\n\n  getcwd(curpath, sizeof(curpath));\n#if defined __i386__\n  snprintf (fname, sizeof(fname), \"%si386.so\", name);\n#elif defined __powerpc__   //rcg010207 - PPC support.\n  snprintf (fname, sizeof(fname), \"%sppc.so\", name);\n#elif defined __axp__\n  snprintf (fname, sizeof(fname), \"%saxp.so\", name);\n#elif defined __mips__\n  snprintf (fname, sizeof(fname), \"%smips.so\", name);\n#else\n#error Unknown arch\n#endif\n\n// bk001129 - was RTLD_LAZY \n#define Q_RTLD    RTLD_NOW\n\n  pwdpath = Sys_Cwd();\n  basepath = Cvar_VariableString( \"fs_basepath\" );\n  homepath = Cvar_VariableString( \"fs_homepath\" );\n  gamedir = Cvar_VariableString( \"fs_game\" );\n\n  // pwdpath\n  fn = FS_BuildOSPath( pwdpath, gamedir, fname );\n  Com_Printf( \"Sys_LoadDll(%s)... \\n\", fn );\n  libHandle = dlopen( fn, Q_RTLD );\n\n  if ( !libHandle )\n  {\n    Com_Printf( \"Sys_LoadDll(%s) failed:\\n\\\"%s\\\"\\n\", fn, dlerror() );\n    // fs_homepath\n    fn = FS_BuildOSPath( homepath, gamedir, fname );\n    Com_Printf( \"Sys_LoadDll(%s)... \\n\", fn );\n    libHandle = dlopen( fn, Q_RTLD );\n\n    if ( !libHandle )\n    {\n      Com_Printf( \"Sys_LoadDll(%s) failed:\\n\\\"%s\\\"\\n\", fn, dlerror() );\n      // fs_basepath\n      fn = FS_BuildOSPath( basepath, gamedir, fname );\n      Com_Printf( \"Sys_LoadDll(%s)... \\n\", fn );\n      libHandle = dlopen( fn, Q_RTLD );\n\n      if ( !libHandle )\n      {\n#ifndef NDEBUG // bk001206 - in debug abort on failure\n        Com_Error ( ERR_FATAL, \"Sys_LoadDll(%s) failed dlopen() completely!\\n\", name  );\n#else\n        Com_Printf ( \"Sys_LoadDll(%s) failed dlopen() completely!\\n\", name );\n#endif\n        return NULL;\n      } else\n        Com_Printf ( \"Sys_LoadDll(%s): succeeded ...\\n\", fn );\n    } else\n      Com_Printf ( \"Sys_LoadDll(%s): succeeded ...\\n\", fn );\n  } else\n    Com_Printf ( \"Sys_LoadDll(%s): succeeded ...\\n\", fn ); \n\n  dllEntry = dlsym( libHandle, \"dllEntry\" ); \n  *entryPoint = dlsym( libHandle, \"vmMain\" );\n  if ( !*entryPoint || !dllEntry )\n  {\n    err = dlerror();\n#ifndef NDEBUG // bk001206 - in debug abort on failure\n    Com_Error ( ERR_FATAL, \"Sys_LoadDll(%s) failed dlsym(vmMain):\\n\\\"%s\\\" !\\n\", name, err );\n#else\n    Com_Printf ( \"Sys_LoadDll(%s) failed dlsym(vmMain):\\n\\\"%s\\\" !\\n\", name, err );\n#endif\n    dlclose( libHandle );\n    err = dlerror();\n    if ( err != NULL )\n      Com_Printf ( \"Sys_LoadDll(%s) failed dlcose:\\n\\\"%s\\\"\\n\", name, err );\n    return NULL;\n  }\n  Com_Printf ( \"Sys_LoadDll(%s) found **vmMain** at  %p  \\n\", name, *entryPoint ); // bk001212\n  dllEntry( systemcalls );\n  Com_Printf ( \"Sys_LoadDll(%s) succeeded!\\n\", name );\n  if ( libHandle ) Q_strncpyz ( fqpath , fn , MAX_QPATH ) ;\t\t// added 7/20/02 by T.Ray\n  return libHandle;\n}\n\n/*\n========================================================================\n\nBACKGROUND FILE STREAMING\n\n========================================================================\n*/\n\n#if 1\n\nvoid Sys_InitStreamThread( void ) {\n}\n\nvoid Sys_ShutdownStreamThread( void ) {\n}\n\nvoid Sys_BeginStreamedFile( fileHandle_t f, int readAhead ) {\n}\n\nvoid Sys_EndStreamedFile( fileHandle_t f ) {\n}\n\nint Sys_StreamedRead( void *buffer, int size, int count, fileHandle_t f ) {\n  return FS_Read( buffer, size * count, f );\n}\n\nvoid Sys_StreamSeek( fileHandle_t f, int offset, int origin ) {\n  FS_Seek( f, offset, origin );\n}\n\n#else\n\ntypedef struct\n{\n  fileHandle_t file;\n  byte  *buffer;\n  qboolean  eof;\n  int   bufferSize;\n  int   streamPosition; // next byte to be returned by Sys_StreamRead\n  int   threadPosition; // next byte to be read from file\n} streamState_t;\n\nstreamState_t stream;\n\n/*\n===============\nSys_StreamThread\n\nA thread will be sitting in this loop forever\n================\n*/\nvoid Sys_StreamThread( void ) \n{\n  int   buffer;\n  int   count;\n  int   readCount;\n  int   bufferPoint;\n  int   r;\n\n  // if there is any space left in the buffer, fill it up\n  if ( !stream.eof )\n  {\n    count = stream.bufferSize - (stream.threadPosition - stream.streamPosition);\n    if ( count )\n    {\n      bufferPoint = stream.threadPosition % stream.bufferSize;\n      buffer = stream.bufferSize - bufferPoint;\n      readCount = buffer < count ? buffer : count;\n      r = FS_Read ( stream.buffer + bufferPoint, readCount, stream.file );\n      stream.threadPosition += r;\n\n      if ( r != readCount )\n        stream.eof = qtrue;\n    }\n  }\n}\n\n/*\n===============\nSys_InitStreamThread\n\n================\n*/\nvoid Sys_InitStreamThread( void ) \n{\n}\n\n/*\n===============\nSys_ShutdownStreamThread\n\n================\n*/\nvoid Sys_ShutdownStreamThread( void ) \n{\n}\n\n\n/*\n===============\nSys_BeginStreamedFile\n\n================\n*/\nvoid Sys_BeginStreamedFile( fileHandle_t f, int readAhead ) \n{\n  if ( stream.file )\n  {\n    Com_Error( ERR_FATAL, \"Sys_BeginStreamedFile: unclosed stream\");\n  }\n\n  stream.file = f;\n  stream.buffer = Z_Malloc( readAhead );\n  stream.bufferSize = readAhead;\n  stream.streamPosition = 0;\n  stream.threadPosition = 0;\n  stream.eof = qfalse;\n}\n\n/*\n===============\nSys_EndStreamedFile\n\n================\n*/\nvoid Sys_EndStreamedFile( fileHandle_t f ) \n{\n  if ( f != stream.file )\n  {\n    Com_Error( ERR_FATAL, \"Sys_EndStreamedFile: wrong file\");\n  }\n\n  stream.file = 0;\n  Z_Free( stream.buffer );\n}\n\n\n/*\n===============\nSys_StreamedRead\n\n================\n*/\nint Sys_StreamedRead( void *buffer, int size, int count, fileHandle_t f ) \n{\n  int   available;\n  int   remaining;\n  int   sleepCount;\n  int   copy;\n  int   bufferCount;\n  int   bufferPoint;\n  byte  *dest;\n\n  dest = (byte *)buffer;\n  remaining = size * count;\n\n  if ( remaining <= 0 )\n  {\n    Com_Error( ERR_FATAL, \"Streamed read with non-positive size\" );\n  }\n\n  sleepCount = 0;\n  while ( remaining > 0 )\n  {\n    available = stream.threadPosition - stream.streamPosition;\n    if ( !available )\n    {\n      if (stream.eof)\n        break;\n      Sys_StreamThread();\n      continue;\n    }\n\n    bufferPoint = stream.streamPosition % stream.bufferSize;\n    bufferCount = stream.bufferSize - bufferPoint;\n\n    copy = available < bufferCount ? available : bufferCount;\n    if ( copy > remaining )\n    {\n      copy = remaining;\n    }\n    memcpy( dest, stream.buffer + bufferPoint, copy );\n    stream.streamPosition += copy;\n    dest += copy;\n    remaining -= copy;\n  }\n\n  return(count * size - remaining) / size;\n}\n\n/*\n===============\nSys_StreamSeek\n\n================\n*/\nvoid Sys_StreamSeek( fileHandle_t f, int offset, int origin ) {\n  // clear to that point\n  FS_Seek( f, offset, origin );\n  stream.streamPosition = 0;\n  stream.threadPosition = 0;\n  stream.eof = qfalse;\n}\n\n#endif\n\n/*\n========================================================================\n\nEVENT LOOP\n\n========================================================================\n*/\n\n// bk000306: upped this from 64\n#define\tMAX_QUED_EVENTS\t\t256\n#define\tMASK_QUED_EVENTS\t( MAX_QUED_EVENTS - 1 )\n\nsysEvent_t  eventQue[MAX_QUED_EVENTS];\n// bk000306: initialize\nint   eventHead = 0;\nint             eventTail = 0;\nbyte    sys_packetReceived[MAX_MSGLEN];\n\n/*\n================\nSys_QueEvent\n\nA time of 0 will get the current time\nPtr should either be null, or point to a block of data that can\nbe freed by the game later.\n================\n*/\nvoid Sys_QueEvent( int time, sysEventType_t type, int value, int value2, int ptrLength, void *ptr ) {\n  sysEvent_t  *ev;\n\n  ev = &eventQue[ eventHead & MASK_QUED_EVENTS ];\n\n  // bk000305 - was missing\n  if ( eventHead - eventTail >= MAX_QUED_EVENTS )\n  {\n    Com_Printf(\"Sys_QueEvent: overflow\\n\");\n    // we are discarding an event, but don't leak memory\n    if ( ev->evPtr )\n    {\n      Z_Free( ev->evPtr );\n    }\n    eventTail++;\n  }\n\n  eventHead++;\n\n  if ( time == 0 )\n  {\n    time = Sys_Milliseconds();\n  }\n\n  ev->evTime = time;\n  ev->evType = type;\n  ev->evValue = value;\n  ev->evValue2 = value2;\n  ev->evPtrLength = ptrLength;\n  ev->evPtr = ptr;\n}\n\n/*\n================\nSys_GetEvent\n\n================\n*/\nsysEvent_t Sys_GetEvent( void ) {\n  sysEvent_t  ev;\n  char    *s;\n  msg_t   netmsg;\n  netadr_t  adr;\n\n  // return if we have data\n  if ( eventHead > eventTail )\n  {\n    eventTail++;\n    return eventQue[ ( eventTail - 1 ) & MASK_QUED_EVENTS ];\n  }\n\n  // pump the message loop\n  // in vga this calls KBD_Update, under X, it calls GetEvent\n  Sys_SendKeyEvents ();\n\n  // check for console commands\n  s = Sys_ConsoleInput();\n  if ( s )\n  {\n    char  *b;\n    int   len;\n\n    len = strlen( s ) + 1;\n    b = Z_Malloc( len );\n    strcpy( b, s );\n    Sys_QueEvent( 0, SE_CONSOLE, 0, 0, len, b );\n  }\n\n  // check for other input devices\n  IN_Frame();\n\n  // check for network packets\n  MSG_Init( &netmsg, sys_packetReceived, sizeof( sys_packetReceived ) );\n  if ( Sys_GetPacket ( &adr, &netmsg ) )\n  {\n    netadr_t    *buf;\n    int       len;\n\n    // copy out to a seperate buffer for qeueing\n    len = sizeof( netadr_t ) + netmsg.cursize;\n    buf = Z_Malloc( len );\n    *buf = adr;\n    memcpy( buf+1, netmsg.data, netmsg.cursize );\n    Sys_QueEvent( 0, SE_PACKET, 0, 0, len, buf );\n  }\n\n  // return if we have data\n  if ( eventHead > eventTail )\n  {\n    eventTail++;\n    return eventQue[ ( eventTail - 1 ) & MASK_QUED_EVENTS ];\n  }\n\n  // create an empty event to return\n\n  memset( &ev, 0, sizeof( ev ) );\n  ev.evTime = Sys_Milliseconds();\n\n  return ev;\n}\n\n/*****************************************************************************/\n\nqboolean Sys_CheckCD( void ) {\n  return qtrue;\n}\n\nvoid Sys_AppActivate (void)\n{\n}\n\nchar *Sys_GetClipboardData(void)\n{\n  return NULL;\n}\n\nvoid  Sys_Print( const char *msg )\n{\n  if (ttycon_on)\n  {\n    tty_Hide();\n  }\n  fputs(msg, stderr);\n  if (ttycon_on)\n  {\n    tty_Show();\n  }\n}\n\n\nvoid    Sys_ConfigureFPU() { // bk001213 - divide by zero\n#ifdef __linux__\n#ifdef __i386\n#ifndef NDEBUG\n\n  // bk0101022 - enable FPE's in debug mode\n  static int fpu_word = _FPU_DEFAULT & ~(_FPU_MASK_ZM | _FPU_MASK_IM);\n  int current = 0;\n  _FPU_GETCW(current);\n  if ( current!=fpu_word)\n  {\n#if 0\n    Com_Printf(\"FPU Control 0x%x (was 0x%x)\\n\", fpu_word, current );\n    _FPU_SETCW( fpu_word );\n    _FPU_GETCW( current );\n    assert(fpu_word==current);\n#endif\n  }\n#else // NDEBUG\n  static int fpu_word = _FPU_DEFAULT;\n  _FPU_SETCW( fpu_word );\n#endif // NDEBUG\n#endif // __i386 \n#endif // __linux\n}\n\nvoid Sys_PrintBinVersion( const char* name ) {\n  char* date = __DATE__;\n  char* time = __TIME__;\n  char* sep = \"==============================================================\";\n  fprintf( stdout, \"\\n\\n%s\\n\", sep );\n#ifdef DEDICATED\n  fprintf( stdout, \"Linux Quake3 Dedicated Server [%s %s]\\n\", date, time );  \n#else\n  fprintf( stdout, \"Linux Quake3 Full Executable  [%s %s]\\n\", date, time );  \n#endif\n  fprintf( stdout, \" local install: %s\\n\", name );\n  fprintf( stdout, \"%s\\n\\n\", sep );\n}\n\nvoid Sys_ParseArgs( int argc, char* argv[] ) {\n\n  if ( argc==2 )\n  {\n    if ( (!strcmp( argv[1], \"--version\" ))\n         || ( !strcmp( argv[1], \"-v\" )) )\n    {\n      Sys_PrintBinVersion( argv[0] );\n      Sys_Exit(0);\n    }\n  }\n}\n\n#include \"../client/client.h\"\nextern clientStatic_t cls;\n\nint main ( int argc, char* argv[] )\n{\n  // int \toldtime, newtime; // bk001204 - unused\n  int   len, i;\n  char  *cmdline;\n  void Sys_SetDefaultCDPath(const char *path);\n\n  // go back to real user for config loads\n  saved_euid = geteuid();\n  seteuid(getuid());\n\n  Sys_ParseArgs( argc, argv );  // bk010104 - added this for support\n\n  Sys_SetDefaultCDPath(argv[0]);\n\n  // merge the command line, this is kinda silly\n  for (len = 1, i = 1; i < argc; i++)\n    len += strlen(argv[i]) + 1;\n  cmdline = malloc(len);\n  *cmdline = 0;\n  for (i = 1; i < argc; i++)\n  {\n    if (i > 1)\n      strcat(cmdline, \" \");\n    strcat(cmdline, argv[i]);\n  }\n\n  // bk000306 - clear queues\n  memset( &eventQue[0], 0, MAX_QUED_EVENTS*sizeof(sysEvent_t) ); \n  memset( &sys_packetReceived[0], 0, MAX_MSGLEN*sizeof(byte) );\n\n  Com_Init(cmdline);\n  NET_Init();\n\n  Sys_ConsoleInputInit();\n\n  fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);\n\t\n#ifdef DEDICATED\n\t// init here for dedicated, as we don't have GLimp_Init\n\tInitSig();\n#endif\n\n  while (1)\n  {\n#ifdef __linux__\n    Sys_ConfigureFPU();\n#endif\n    Com_Frame ();\n  }\n}\n"
  },
  {
    "path": "code/unix/unix_net.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// unix_net.c\n\n#include \"../game/q_shared.h\"\n#include \"../qcommon/qcommon.h\"\n\n#include <unistd.h>\n#include <sys/socket.h>\n#include <sys/time.h>\n#include <netinet/in.h>\n#include <netdb.h>\n#include <arpa/inet.h> // bk001204\n\n#include <sys/param.h>\n#include <sys/ioctl.h>\n#include <sys/uio.h>\n#include <errno.h>\n\n#ifdef MACOS_X\n#import <sys/sockio.h>\n#import <net/if.h>\n#import <net/if_types.h>\n\n#import <arpa/inet.h>         // for inet_ntoa()\n#import <net/if_dl.h>         // for 'struct sockaddr_dl'\n#endif\n\nstatic cvar_t\t*noudp;\n\nnetadr_t\tnet_local_adr;\n\nint\t\t\tip_socket;\nint\t\t\tipx_socket;\n\n#define\tMAX_IPS\t\t16\nstatic\tint\t\tnumIP;\nstatic\tbyte\tlocalIP[MAX_IPS][4];\n\nint NET_Socket (char *net_interface, int port);\nchar *NET_ErrorString (void);\n\n//=============================================================================\n\nvoid NetadrToSockadr (netadr_t *a, struct sockaddr_in *s)\n{\n\tmemset (s, 0, sizeof(*s));\n\n\tif (a->type == NA_BROADCAST)\n\t{\n\t\ts->sin_family = AF_INET;\n\n\t\ts->sin_port = a->port;\n\t\t*(int *)&s->sin_addr = -1;\n\t}\n\telse if (a->type == NA_IP)\n\t{\n\t\ts->sin_family = AF_INET;\n\n\t\t*(int *)&s->sin_addr = *(int *)&a->ip;\n\t\ts->sin_port = a->port;\n\t}\n}\n\nvoid SockadrToNetadr (struct sockaddr_in *s, netadr_t *a)\n{\n\t*(int *)&a->ip = *(int *)&s->sin_addr;\n\ta->port = s->sin_port;\n\ta->type = NA_IP;\n}\n\nchar\t*NET_BaseAdrToString (netadr_t a)\n{\n\tstatic\tchar\ts[64];\n\t\n\tCom_sprintf (s, sizeof(s), \"%i.%i.%i.%i\", a.ip[0], a.ip[1], a.ip[2], a.ip[3]);\n\n\treturn s;\n}\n\n/*\n=============\nSys_StringToAdr\n\nidnewt\n192.246.40.70\n=============\n*/\nqboolean\tSys_StringToSockaddr (const char *s, struct sockaddr *sadr)\n{\n\tstruct hostent\t*h;\n\t//char\t*colon; // bk001204 - unused\n\t\n\tmemset (sadr, 0, sizeof(*sadr));\n\t((struct sockaddr_in *)sadr)->sin_family = AF_INET;\n\t\n\t((struct sockaddr_in *)sadr)->sin_port = 0;\n\t\n\tif ( s[0] >= '0' && s[0] <= '9')\n\t{\n\t\t*(int *)&((struct sockaddr_in *)sadr)->sin_addr = inet_addr(s);\n\t}\n\telse\n\t{\n\t\tif (! (h = gethostbyname(s)) )\n\t\t\treturn qfalse;\n\t\t*(int *)&((struct sockaddr_in *)sadr)->sin_addr = *(int *)h->h_addr_list[0];\n\t}\n\t\n\treturn qtrue;\n}\n\n/*\n=============\nSys_StringToAdr\n\nlocalhost\nidnewt\nidnewt:28000\n192.246.40.70\n192.246.40.70:28000\n=============\n*/\nqboolean\tSys_StringToAdr (const char *s, netadr_t *a)\n{\n\tstruct sockaddr_in sadr;\n\t\n\tif (!Sys_StringToSockaddr (s, (struct sockaddr *)&sadr))\n\t\treturn qfalse;\n\t\n\tSockadrToNetadr (&sadr, a);\n\n\treturn qtrue;\n}\n\n\n//=============================================================================\n\nqboolean\tSys_GetPacket (netadr_t *net_from, msg_t *net_message)\n{\n\tint \tret;\n\tstruct sockaddr_in\tfrom;\n\tint\t\tfromlen;\n\tint\t\tnet_socket;\n\tint\t\tprotocol;\n\tint\t\terr;\n\n\tfor (protocol = 0 ; protocol < 2 ; protocol++)\n\t{\n\t\tif (protocol == 0)\n\t\t\tnet_socket = ip_socket;\n\t\telse\n\t\t\tnet_socket = ipx_socket;\n\n\t\tif (!net_socket)\n\t\t\tcontinue;\n\n\t\tfromlen = sizeof(from);\n\t\tret = recvfrom (net_socket, net_message->data, net_message->maxsize\n\t\t\t, 0, (struct sockaddr *)&from, &fromlen);\n\n\t\tSockadrToNetadr (&from, net_from);\n\t\t// bk000305: was missing\n\t\tnet_message->readcount = 0;\n\n\t\tif (ret == -1)\n\t\t{\n\t\t\terr = errno;\n\n\t\t\tif (err == EWOULDBLOCK || err == ECONNREFUSED)\n\t\t\t\tcontinue;\n\t\t\tCom_Printf (\"NET_GetPacket: %s from %s\\n\", NET_ErrorString(),\n\t\t\t\t\t\tNET_AdrToString(*net_from));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (ret == net_message->maxsize)\n\t\t{\n\t\t\tCom_Printf (\"Oversize packet from %s\\n\", NET_AdrToString (*net_from));\n\t\t\tcontinue;\n\t\t}\n\n\t\tnet_message->cursize = ret;\n\t\treturn qtrue;\n\t}\n\n\treturn qfalse;\n}\n\n//=============================================================================\n\nvoid\tSys_SendPacket( int length, const void *data, netadr_t to )\n{\n\tint\t\tret;\n\tstruct sockaddr_in\taddr;\n\tint\t\tnet_socket;\n\n\tif (to.type == NA_BROADCAST)\n\t{\n\t\tnet_socket = ip_socket;\n\t}\n\telse if (to.type == NA_IP)\n\t{\n\t\tnet_socket = ip_socket;\n\t}\n\telse if (to.type == NA_IPX)\n\t{\n\t\tnet_socket = ipx_socket;\n\t}\n\telse if (to.type == NA_BROADCAST_IPX)\n\t{\n\t\tnet_socket = ipx_socket;\n\t}\n\telse {\n\t\tCom_Error (ERR_FATAL, \"NET_SendPacket: bad address type\");\n\t\treturn;\n\t}\n\n\tif (!net_socket)\n\t\treturn;\n\n\tNetadrToSockadr (&to, &addr);\n\n\tret = sendto (net_socket, data, length, 0, (struct sockaddr *)&addr, sizeof(addr) );\n\tif (ret == -1)\n\t{\n\t\tCom_Printf (\"NET_SendPacket ERROR: %s to %s\\n\", NET_ErrorString(),\n\t\t\t\tNET_AdrToString (to));\n\t}\n}\n\n\n//=============================================================================\n\n/*\n==================\nSys_IsLANAddress\n\nLAN clients will have their rate var ignored\n==================\n*/\nqboolean\tSys_IsLANAddress (netadr_t adr) {\n\tint\t\ti;\n\n\tif( adr.type == NA_LOOPBACK ) {\n\t\treturn qtrue;\n\t}\n\n\tif( adr.type == NA_IPX ) {\n\t\treturn qtrue;\n\t}\n\n\tif( adr.type != NA_IP ) {\n\t\treturn qfalse;\n\t}\n\n\t// choose which comparison to use based on the class of the address being tested\n\t// any local adresses of a different class than the address being tested will fail based on the first byte\n\n\t// Class A\n\tif( (adr.ip[0] & 0x80) == 0x00 ) {\n\t\tfor ( i = 0 ; i < numIP ; i++ ) {\n\t\t\tif( adr.ip[0] == localIP[i][0] ) {\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t}\n\t\t// the RFC1918 class a block will pass the above test\n\t\treturn qfalse;\n\t}\n\n\t// Class B\n\tif( (adr.ip[0] & 0xc0) == 0x80 ) {\n\t\tfor ( i = 0 ; i < numIP ; i++ ) {\n\t\t\tif( adr.ip[0] == localIP[i][0] && adr.ip[1] == localIP[i][1] ) {\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t\t// also check against the RFC1918 class b blocks\n\t\t\tif( adr.ip[0] == 172 && localIP[i][0] == 172 && (adr.ip[1] & 0xf0) == 16 && (localIP[i][1] & 0xf0) == 16 ) {\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t}\n\t\treturn qfalse;\n\t}\n\n\t// Class C\n\tfor ( i = 0 ; i < numIP ; i++ ) {\n\t\tif( adr.ip[0] == localIP[i][0] && adr.ip[1] == localIP[i][1] && adr.ip[2] == localIP[i][2] ) {\n\t\t\treturn qtrue;\n\t\t}\n\t\t// also check against the RFC1918 class c blocks\n\t\tif( adr.ip[0] == 192 && localIP[i][0] == 192 && adr.ip[1] == 168 && localIP[i][1] == 168 ) {\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nSys_ShowIP\n==================\n*/\nvoid Sys_ShowIP(void) {\n\tint i;\n\n\tfor (i = 0; i < numIP; i++) {\n\t\tCom_Printf( \"IP: %i.%i.%i.%i\\n\", localIP[i][0], localIP[i][1], localIP[i][2], localIP[i][3] );\n\t}\n}\n\n/*\n=====================\nNET_GetLocalAddress\n=====================\n*/\n#ifdef MACOS_X\n// Don't do a forward mapping from the hostname of the machine to the IP.  The reason is that we might have obtained an IP address from DHCP and there might not be any name registered for the machine.  On Mac OS X, the machine name defaults to 'localhost' and NetInfo has 127.0.0.1 listed for this name.  Instead, we want to get a list of all the IP network interfaces on the machine.\n// This code adapted from OmniNetworking.\n\n#define IFR_NEXT(ifr)\t\\\n    ((struct ifreq *) ((char *) (ifr) + sizeof(*(ifr)) + \\\n      MAX(0, (int) (ifr)->ifr_addr.sa_len - (int) sizeof((ifr)->ifr_addr))))\n\nvoid NET_GetLocalAddress( void ) {\n        struct ifreq requestBuffer[MAX_IPS], *linkInterface, *inetInterface;\n        struct ifconf ifc;\n        struct ifreq ifr;\n        struct sockaddr_dl *sdl;\n        int interfaceSocket;\n        int family;\n        \n        //Com_Printf(\"NET_GetLocalAddress: Querying for network interfaces\\n\");\n        \n        // Set this early so we can just return if there is an error\n\tnumIP = 0;\n        \n        ifc.ifc_len = sizeof(requestBuffer);\n        ifc.ifc_buf = (caddr_t)requestBuffer;\n\n        // Since we get at this info via an ioctl, we need a temporary little socket.  This will only get AF_INET interfaces, but we probably don't care about anything else.  If we do end up caring later, we should add a ONAddressFamily and at a -interfaces method to it.\n        family = AF_INET;\n        if ((interfaceSocket = socket(family, SOCK_DGRAM, 0)) < 0) {\n            Com_Printf(\"NET_GetLocalAddress: Unable to create temporary socket, errno = %d\\n\", errno);\n            return;\n        }\n\n        if (ioctl(interfaceSocket, SIOCGIFCONF, &ifc) != 0) {\n            Com_Printf(\"NET_GetLocalAddress: Unable to get list of network interfaces, errno = %d\\n\", errno);\n            return;\n        }\n\n\n        linkInterface = (struct ifreq *) ifc.ifc_buf;\n        while ((char *) linkInterface < &ifc.ifc_buf[ifc.ifc_len]) {\n            unsigned int nameLength;\n\n            // The ioctl returns both the entries having the address (AF_INET) and the link layer entries (AF_LINK).  The AF_LINK entry has the link layer address which contains the interface type.  This is the only way I can see to get this information.  We cannot assume that we will get bot an AF_LINK and AF_INET entry since the interface may not be configured.  For example, if you have a 10Mb port on the motherboard and a 100Mb card, you may not configure the motherboard port.\n\n            // For each AF_LINK entry...\n            if (linkInterface->ifr_addr.sa_family == AF_LINK) {\n                // if there is a matching AF_INET entry\n                inetInterface = (struct ifreq *) ifc.ifc_buf;\n                while ((char *) inetInterface < &ifc.ifc_buf[ifc.ifc_len]) {\n                    if (inetInterface->ifr_addr.sa_family == AF_INET &&\n                        !strncmp(inetInterface->ifr_name, linkInterface->ifr_name, sizeof(linkInterface->ifr_name))) {\n\n                        for (nameLength = 0; nameLength < IFNAMSIZ; nameLength++)\n                            if (!linkInterface->ifr_name[nameLength])\n                                break;\n\n                        sdl = (struct sockaddr_dl *)&linkInterface->ifr_addr;\n                        // Skip loopback interfaces\n                        if (sdl->sdl_type != IFT_LOOP) {\n                            // Get the local interface address\n                            strncpy(ifr.ifr_name, inetInterface->ifr_name, sizeof(ifr.ifr_name));\n                            if (ioctl(interfaceSocket, OSIOCGIFADDR, (caddr_t)&ifr) < 0) {\n                                Com_Printf(\"NET_GetLocalAddress: Unable to get local address for interface '%s', errno = %d\\n\", inetInterface->ifr_name, errno);\n                            } else {\n                                struct sockaddr_in *sin;\n                                int ip;\n            \n                                sin = (struct sockaddr_in *)&ifr.ifr_addr;\n            \n                                ip = ntohl(sin->sin_addr.s_addr);\n                                localIP[ numIP ][0] = (ip >> 24) & 0xff;\n                                localIP[ numIP ][1] = (ip >> 16) & 0xff;\n                                localIP[ numIP ][2] = (ip >>  8) & 0xff;\n                                localIP[ numIP ][3] = (ip >>  0) & 0xff;\n                                Com_Printf( \"IP: %i.%i.%i.%i (%s)\\n\", localIP[ numIP ][0], localIP[ numIP ][1], localIP[ numIP ][2], localIP[ numIP ][3], inetInterface->ifr_name);\n                                numIP++;\n                            }\n                        }\n\n                        // We will assume that there is only one AF_INET entry per AF_LINK entry.\n                        // What happens when we have an interface that has multiple IP addresses, or\n                        // can that even happen?\n                        // break;\n                    }\n                    inetInterface = IFR_NEXT(inetInterface);\n                }\n            }\n            linkInterface = IFR_NEXT(linkInterface);\n        }\n\n        close(interfaceSocket);\n}\n\n#else\nvoid NET_GetLocalAddress( void ) {\n\tchar\t\t\t\thostname[256];\n\tstruct hostent\t\t*hostInfo;\n\t// int\t\t\t\t\terror; // bk001204 - unused\n\tchar\t\t\t\t*p;\n\tint\t\t\t\t\tip;\n\tint\t\t\t\t\tn;\n\n\tif ( gethostname( hostname, 256 ) == -1 ) {\n\t\treturn;\n\t}\n\n\thostInfo = gethostbyname( hostname );\n\tif ( !hostInfo ) {\n\t\treturn;\n\t}\n\n\tCom_Printf( \"Hostname: %s\\n\", hostInfo->h_name );\n\tn = 0;\n\twhile( ( p = hostInfo->h_aliases[n++] ) != NULL ) {\n\t\tCom_Printf( \"Alias: %s\\n\", p );\n\t}\n\n\tif ( hostInfo->h_addrtype != AF_INET ) {\n\t\treturn;\n\t}\n\n\tnumIP = 0;\n\twhile( ( p = hostInfo->h_addr_list[numIP++] ) != NULL && numIP < MAX_IPS ) {\n\t\tip = ntohl( *(int *)p );\n\t\tlocalIP[ numIP ][0] = p[0];\n\t\tlocalIP[ numIP ][1] = p[1];\n\t\tlocalIP[ numIP ][2] = p[2];\n\t\tlocalIP[ numIP ][3] = p[3];\n\t\tCom_Printf( \"IP: %i.%i.%i.%i\\n\", ( ip >> 24 ) & 0xff, ( ip >> 16 ) & 0xff, ( ip >> 8 ) & 0xff, ip & 0xff );\n\t}\n}\n#endif\n\n/*\n====================\nNET_OpenIP\n====================\n*/\n// bk001204 - prototype needed\nint NET_IPSocket (char *net_interface, int port);\nvoid NET_OpenIP (void)\n{\n\tcvar_t\t*ip;\n\tint\t\tport;\n\tint\t\ti;\n\n\tip = Cvar_Get (\"net_ip\", \"localhost\", 0);\n\n\tport = Cvar_Get(\"net_port\", va(\"%i\", PORT_SERVER), 0)->value;\n\n\tfor ( i = 0 ; i < 10 ; i++ ) {\n\t\tip_socket = NET_IPSocket (ip->string, port + i);\n\t\tif ( ip_socket ) {\n\t\t\tCvar_SetValue( \"net_port\", port + i );\n\t\t\tNET_GetLocalAddress();\n\t\t\treturn;\n\t\t}\n\t}\n\tCom_Error (ERR_FATAL, \"Couldn't allocate IP port\");\n}\n\n\n/*\n====================\nNET_Init\n====================\n*/\nvoid NET_Init (void)\n{\n\tnoudp = Cvar_Get (\"net_noudp\", \"0\", 0);\n\t// open sockets\n\tif (! noudp->value) {\n\t\tNET_OpenIP ();\n\t}\n}\n\n\n/*\n====================\nNET_IPSocket\n====================\n*/\nint NET_IPSocket (char *net_interface, int port)\n{\n\tint newsocket;\n\tstruct sockaddr_in address;\n\tqboolean _qtrue = qtrue;\n\tint\ti = 1;\n\n\tif ( net_interface ) {\n\t\tCom_Printf(\"Opening IP socket: %s:%i\\n\", net_interface, port );\n\t} else {\n\t\tCom_Printf(\"Opening IP socket: localhost:%i\\n\", port );\n\t}\n\n\tif ((newsocket = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)\n\t{\n\t\tCom_Printf (\"ERROR: UDP_OpenSocket: socket: %s\", NET_ErrorString());\n\t\treturn 0;\n\t}\n\n\t// make it non-blocking\n\tif (ioctl (newsocket, FIONBIO, &_qtrue) == -1)\n\t{\n\t\tCom_Printf (\"ERROR: UDP_OpenSocket: ioctl FIONBIO:%s\\n\", NET_ErrorString());\n\t\treturn 0;\n\t}\n\n\t// make it broadcast capable\n\tif (setsockopt(newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&i, sizeof(i)) == -1)\n\t{\n\t\tCom_Printf (\"ERROR: UDP_OpenSocket: setsockopt SO_BROADCAST:%s\\n\", NET_ErrorString());\n\t\treturn 0;\n\t}\n\n\tif (!net_interface || !net_interface[0] || !Q_stricmp(net_interface, \"localhost\"))\n\t\taddress.sin_addr.s_addr = INADDR_ANY;\n\telse\n\t\tSys_StringToSockaddr (net_interface, (struct sockaddr *)&address);\n\n\tif (port == PORT_ANY)\n\t\taddress.sin_port = 0;\n\telse\n\t\taddress.sin_port = htons((short)port);\n\n\taddress.sin_family = AF_INET;\n\n\tif( bind (newsocket, (void *)&address, sizeof(address)) == -1)\n\t{\n\t\tCom_Printf (\"ERROR: UDP_OpenSocket: bind: %s\\n\", NET_ErrorString());\n\t\tclose (newsocket);\n\t\treturn 0;\n\t}\n\n\treturn newsocket;\n}\n\n/*\n====================\nNET_Shutdown\n====================\n*/\nvoid\tNET_Shutdown (void)\n{\n\tif (ip_socket) {\n\t\tclose(ip_socket);\n\t\tip_socket = 0;\n\t}\n}\n\n\n/*\n====================\nNET_ErrorString\n====================\n*/\nchar *NET_ErrorString (void)\n{\n\tint\t\tcode;\n\n\tcode = errno;\n\treturn strerror (code);\n}\n\n// sleeps msec or until net socket is ready\nvoid NET_Sleep(int msec)\n{\n    struct timeval timeout;\n\tfd_set\tfdset;\n\textern qboolean stdin_active;\n\n\tif (!ip_socket || !com_dedicated->integer)\n\t\treturn; // we're not a server, just run full speed\n\n\tFD_ZERO(&fdset);\n\tif (stdin_active)\n\t\tFD_SET(0, &fdset); // stdin is processed too\n\tFD_SET(ip_socket, &fdset); // network socket\n\ttimeout.tv_sec = msec/1000;\n\ttimeout.tv_usec = (msec%1000)*1000;\n\tselect(ip_socket+1, &fdset, NULL, NULL, &timeout);\n}\n\n"
  },
  {
    "path": "code/unix/unix_shared.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <errno.h>\n#include <stdio.h>\n#include <dirent.h>\n#include <unistd.h>\n#include <sys/mman.h>\n#include <sys/time.h>\n#include <pwd.h>\n\n#include \"../game/q_shared.h\"\n#include \"../qcommon/qcommon.h\"\n\n//=============================================================================\n\n// Used to determine CD Path\nstatic char cdPath[MAX_OSPATH];\n\n// Used to determine local installation path\nstatic char installPath[MAX_OSPATH];\n\n// Used to determine where to store user-specific files\nstatic char homePath[MAX_OSPATH];\n\n/*\n================\nSys_Milliseconds\n================\n*/\n/* base time in seconds, that's our origin\n   timeval:tv_sec is an int: \n   assuming this wraps every 0x7fffffff - ~68 years since the Epoch (1970) - we're safe till 2038\n   using unsigned long data type to work right with Sys_XTimeToSysTime */\nunsigned long sys_timeBase = 0;\n/* current time in ms, using sys_timeBase as origin\n   NOTE: sys_timeBase*1000 + curtime -> ms since the Epoch\n     0x7fffffff ms - ~24 days\n   although timeval:tv_usec is an int, I'm not sure wether it is actually used as an unsigned int\n     (which would affect the wrap period) */\nint curtime;\nint Sys_Milliseconds (void)\n{\n\tstruct timeval tp;\n\n\tgettimeofday(&tp, NULL);\n\t\n\tif (!sys_timeBase)\n\t{\n\t\tsys_timeBase = tp.tv_sec;\n\t\treturn tp.tv_usec/1000;\n\t}\n\n\tcurtime = (tp.tv_sec - sys_timeBase)*1000 + tp.tv_usec/1000;\n\t\n\treturn curtime;\n}\n\n#if defined(__linux__) && !defined(DEDICATED)\n/*\n================\nSys_XTimeToSysTime\nsub-frame timing of events returned by X\nX uses the Time typedef - unsigned long\ndisable with in_subframe 0\n\n sys_timeBase*1000 is the number of ms since the Epoch of our origin\n xtime is in ms and uses the Epoch as origin\n   Time data type is an unsigned long: 0xffffffff ms - ~49 days period\n I didn't find much info in the XWindow documentation about the wrapping\n   we clamp sys_timeBase*1000 to unsigned long, that gives us the current origin for xtime\n   the computation will still work if xtime wraps (at ~49 days period since the Epoch) after we set sys_timeBase\n\n================\n*/\nextern cvar_t *in_subframe;\nint Sys_XTimeToSysTime (unsigned long xtime)\n{\n\tint ret, time, test;\n\t\n\tif (!in_subframe->value)\n\t{\n\t\t// if you don't want to do any event times corrections\n\t\treturn Sys_Milliseconds();\n\t}\n\n\t// test the wrap issue\n#if 0\t\n\t// reference values for test: sys_timeBase 0x3dc7b5e9 xtime 0x541ea451 (read these from a test run)\n\t// xtime will wrap in 0xabe15bae ms >~ 0x2c0056 s (33 days from Nov 5 2002 -> 8 Dec)\n\t//   NOTE: date -d '1970-01-01 UTC 1039384002 seconds' +%c\n\t// use sys_timeBase 0x3dc7b5e9+0x2c0056 = 0x3df3b63f\n\t// after around 5s, xtime would have wrapped around\n\t// we get 7132, the formula handles the wrap safely\n\tunsigned long xtime_aux,base_aux;\n\tint test;\n//\tCom_Printf(\"sys_timeBase: %p\\n\", sys_timeBase);\n//\tCom_Printf(\"xtime: %p\\n\", xtime);\n\txtime_aux = 500; // 500 ms after wrap\n\tbase_aux = 0x3df3b63f; // the base a few seconds before wrap\n\ttest = xtime_aux - (unsigned long)(base_aux*1000);\n\tCom_Printf(\"xtime wrap test: %d\\n\", test);\n#endif\n\n  // some X servers (like suse 8.1's) report weird event times\n  // if the game is loading, resolving DNS, etc. we are also getting old events\n  // so we only deal with subframe corrections that look 'normal'\n  ret = xtime - (unsigned long)(sys_timeBase*1000);\n  time = Sys_Milliseconds();\n  test = time - ret;\n  //printf(\"delta: %d\\n\", test);\n  if (test < 0 || test > 30) // in normal conditions I've never seen this go above\n  {\n    return time;\n  }\n\n\treturn ret;\n}\n#endif\n\n//#if 0 // bk001215 - see snapvector.nasm for replacement\n#if (defined __APPLE__) // rcg010206 - using this for PPC builds...\nlong fastftol( float f ) { // bk001213 - from win32/win_shared.c\n  //static int tmp;\n  //\t__asm fld f\n  //__asm fistp tmp\n  //__asm mov eax, tmp\n  return (long)f;\n}\n\nvoid Sys_SnapVector( float *v ) { // bk001213 - see win32/win_shared.c\n  // bk001213 - old linux\n  v[0] = rint(v[0]);\n  v[1] = rint(v[1]);\n  v[2] = rint(v[2]);\n}\n#endif\n\n\nvoid\tSys_Mkdir( const char *path )\n{\n    mkdir (path, 0777);\n}\n\nchar *strlwr (char *s) {\n  if ( s==NULL ) { // bk001204 - paranoia\n    assert(0);\n    return s;\n  }\n  while (*s) {\n    *s = tolower(*s);\n    s++;\n  }\n  return s; // bk001204 - duh\n}\n\n//============================================\n\n#define\tMAX_FOUND_FILES\t0x1000\n\n// bk001129 - new in 1.26\nvoid Sys_ListFilteredFiles( const char *basedir, char *subdirs, char *filter, char **list, int *numfiles ) {\n\tchar\t\tsearch[MAX_OSPATH], newsubdirs[MAX_OSPATH];\n\tchar\t\tfilename[MAX_OSPATH];\n\tDIR\t\t\t*fdir;\n\tstruct dirent *d;\n\tstruct stat st;\n\n\tif ( *numfiles >= MAX_FOUND_FILES - 1 ) {\n\t\treturn;\n\t}\n\n\tif (strlen(subdirs)) {\n\t\tCom_sprintf( search, sizeof(search), \"%s/%s\", basedir, subdirs );\n\t}\n\telse {\n\t\tCom_sprintf( search, sizeof(search), \"%s\", basedir );\n\t}\n\n\tif ((fdir = opendir(search)) == NULL) {\n\t\treturn;\n\t}\n\n\twhile ((d = readdir(fdir)) != NULL) {\n\t\tCom_sprintf(filename, sizeof(filename), \"%s/%s\", search, d->d_name);\n\t\tif (stat(filename, &st) == -1)\n\t\t\tcontinue;\n\n\t\tif (st.st_mode & S_IFDIR) {\n\t\t\tif (Q_stricmp(d->d_name, \".\") && Q_stricmp(d->d_name, \"..\")) {\n\t\t\t\tif (strlen(subdirs)) {\n\t\t\t\t\tCom_sprintf( newsubdirs, sizeof(newsubdirs), \"%s/%s\", subdirs, d->d_name);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tCom_sprintf( newsubdirs, sizeof(newsubdirs), \"%s\", d->d_name);\n\t\t\t\t}\n\t\t\t\tSys_ListFilteredFiles( basedir, newsubdirs, filter, list, numfiles );\n\t\t\t}\n\t\t}\n\t\tif ( *numfiles >= MAX_FOUND_FILES - 1 ) {\n\t\t\tbreak;\n\t\t}\n\t\tCom_sprintf( filename, sizeof(filename), \"%s/%s\", subdirs, d->d_name );\n\t\tif (!Com_FilterPath( filter, filename, qfalse ))\n\t\t\tcontinue;\n\t\tlist[ *numfiles ] = CopyString( filename );\n\t\t(*numfiles)++;\n\t}\n\n\tclosedir(fdir);\n}\n\n// bk001129 - in 1.17 this used to be\n// char **Sys_ListFiles( const char *directory, const char *extension, int *numfiles, qboolean wantsubs )\nchar **Sys_ListFiles( const char *directory, const char *extension, char *filter, int *numfiles, qboolean wantsubs )\n{\n\tstruct dirent *d;\n\t// char *p; // bk001204 - unused\n\tDIR\t\t*fdir;\n\tqboolean dironly = wantsubs;\n\tchar\t\tsearch[MAX_OSPATH];\n\tint\t\t\tnfiles;\n\tchar\t\t**listCopy;\n\tchar\t\t*list[MAX_FOUND_FILES];\n\t//int\t\t\tflag; // bk001204 - unused\n\tint\t\t\ti;\n\tstruct stat st;\n\n\tint\t\t\textLen;\n\n\tif (filter) {\n\n\t\tnfiles = 0;\n\t\tSys_ListFilteredFiles( directory, \"\", filter, list, &nfiles );\n\n\t\tlist[ nfiles ] = 0;\n\t\t*numfiles = nfiles;\n\n\t\tif (!nfiles)\n\t\t\treturn NULL;\n\n\t\tlistCopy = Z_Malloc( ( nfiles + 1 ) * sizeof( *listCopy ) );\n\t\tfor ( i = 0 ; i < nfiles ; i++ ) {\n\t\t\tlistCopy[i] = list[i];\n\t\t}\n\t\tlistCopy[i] = NULL;\n\n\t\treturn listCopy;\n\t}\n\n\tif ( !extension)\n\t\textension = \"\";\n\n\tif ( extension[0] == '/' && extension[1] == 0 ) {\n\t\textension = \"\";\n\t\tdironly = qtrue;\n\t}\n\n\textLen = strlen( extension );\n\t\n\t// search\n\tnfiles = 0;\n\n\tif ((fdir = opendir(directory)) == NULL) {\n\t\t*numfiles = 0;\n\t\treturn NULL;\n\t}\n\n\twhile ((d = readdir(fdir)) != NULL) {\n\t\tCom_sprintf(search, sizeof(search), \"%s/%s\", directory, d->d_name);\n\t\tif (stat(search, &st) == -1)\n\t\t\tcontinue;\n\t\tif ((dironly && !(st.st_mode & S_IFDIR)) ||\n\t\t\t(!dironly && (st.st_mode & S_IFDIR)))\n\t\t\tcontinue;\n\n\t\tif (*extension) {\n\t\t\tif ( strlen( d->d_name ) < strlen( extension ) ||\n\t\t\t\tQ_stricmp( \n\t\t\t\t\td->d_name + strlen( d->d_name ) - strlen( extension ),\n\t\t\t\t\textension ) ) {\n\t\t\t\tcontinue; // didn't match\n\t\t\t}\n\t\t}\n\n\t\tif ( nfiles == MAX_FOUND_FILES - 1 )\n\t\t\tbreak;\n\t\tlist[ nfiles ] = CopyString( d->d_name );\n\t\tnfiles++;\n\t}\n\n\tlist[ nfiles ] = 0;\n\n\tclosedir(fdir);\n\n\t// return a copy of the list\n\t*numfiles = nfiles;\n\n\tif ( !nfiles ) {\n\t\treturn NULL;\n\t}\n\n\tlistCopy = Z_Malloc( ( nfiles + 1 ) * sizeof( *listCopy ) );\n\tfor ( i = 0 ; i < nfiles ; i++ ) {\n\t\tlistCopy[i] = list[i];\n\t}\n\tlistCopy[i] = NULL;\n\n\treturn listCopy;\n}\n\nvoid\tSys_FreeFileList( char **list ) {\n\tint\t\ti;\n\n\tif ( !list ) {\n\t\treturn;\n\t}\n\n\tfor ( i = 0 ; list[i] ; i++ ) {\n\t\tZ_Free( list[i] );\n\t}\n\n\tZ_Free( list );\n}\n\nchar *Sys_Cwd( void ) \n{\n\tstatic char cwd[MAX_OSPATH];\n\n\tgetcwd( cwd, sizeof( cwd ) - 1 );\n\tcwd[MAX_OSPATH-1] = 0;\n\n\treturn cwd;\n}\n\nvoid Sys_SetDefaultCDPath(const char *path)\n{\n\tQ_strncpyz(cdPath, path, sizeof(cdPath));\n}\n\nchar *Sys_DefaultCDPath(void)\n{\n        return cdPath;\n}\n\nvoid Sys_SetDefaultInstallPath(const char *path)\n{\n\tQ_strncpyz(installPath, path, sizeof(installPath));\n}\n\nchar *Sys_DefaultInstallPath(void)\n{\n\tif (*installPath)\n\t\treturn installPath;\n\telse\n\t\treturn Sys_Cwd();\n}\n\nvoid Sys_SetDefaultHomePath(const char *path)\n{\n\tQ_strncpyz(homePath, path, sizeof(homePath));\n}\n\nchar *Sys_DefaultHomePath(void)\n{\n\tchar *p;\n\n        if (*homePath)\n            return homePath;\n            \n\tif ((p = getenv(\"HOME\")) != NULL) {\n\t\tQ_strncpyz(homePath, p, sizeof(homePath));\n#ifdef MACOS_X\n\t\tQ_strcat(homePath, sizeof(homePath), \"/Library/Application Support/Quake3\");\n#else\n\t\tQ_strcat(homePath, sizeof(homePath), \"/.q3a\");\n#endif\n\t\tif (mkdir(homePath, 0777)) {\n\t\t\tif (errno != EEXIST) \n\t\t\t\tSys_Error(\"Unable to create directory \\\"%s\\\", error is %s(%d)\\n\", homePath, strerror(errno), errno);\n\t\t}\n\t\treturn homePath;\n\t}\n\treturn \"\"; // assume current dir\n}\n\n//============================================\n\nint Sys_GetProcessorId( void )\n{\n\treturn CPUID_GENERIC;\n}\n\nvoid Sys_ShowConsole( int visLevel, qboolean quitOnClose )\n{\n}\n\nchar *Sys_GetCurrentUser( void )\n{\n\tstruct passwd *p;\n\n\tif ( (p = getpwuid( getuid() )) == NULL ) {\n\t\treturn \"player\";\n\t}\n\treturn p->pw_name;\n}\n\n#if defined(__linux__)\n// TTimo \n// sysconf() in libc, POSIX.1 compliant\nunsigned int Sys_ProcessorCount()\n{\n  return sysconf(_SC_NPROCESSORS_ONLN);\n}\n#endif\n"
  },
  {
    "path": "code/unix/vm_x86.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"../qcommon/vm_local.h\"\n\nvoid VM_Compile( vm_t *vm, vmHeader_t *header ) {}\nint\tVM_CallCompiled( vm_t *vm, int *args ) {}\n\n\n\n"
  },
  {
    "path": "code/unix/vm_x86a.s",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// vm_x86a.s\n// linux x86 vm support\n\n#include \"qasm.h\"\n\n.extern\tC(instructionPointers)\n\n\t.data\n\n\t.align\t4\n\nprogramStack\t.long\t0\nopStack\t\t\t.long\t0\nsyscallNum\t\t.long\t0\n\n\t.text\n\n.globl C(AsmCAll)\nC(AsmCall):\n\tmovl\t(%edi),%eax\n\tsubl\t4,%edi\n\torl\t\t%eax,%eax\n\tjl\t\tsystemCall\n\t// calling another vm function\n\tshll\t2,%eax\n\taddl\tC(instructionPointers),%eax\n\tcall\t(%eax)\n\tret\nsystemCall:\n\n\t// convert negative num to system call number\n\t// and store right before the first arg\n\tnegl\t%eax\n\tdecl\t%eax\n\n\tmovl\t%eax,syscallNum\n///---- UNFINISHED FROM HERE\n\tmov\t\tdword ptr syscallNum, eax\t// so C code can get at it\n\tmov\t\tdword ptr programStack, esi\t// so C code can get at it\n\tmov\t\tdword ptr opStack, edi\n\n\tpush\tecx\n\tpush\tesi\t\t\t\t\t\t\t// we may call recursively, so the\n\tpush\tedi\t\t\t\t\t\t\t// statics aren't guaranteed to be around\n}\n\t// save the stack to allow recursive VM entry\n\tcurrentVM->programStack = programStack - 4;\n\t*(int *)((byte *)currentVM->dataBase + programStack + 4) = syscallNum;\n//VM_LogSyscalls(  (int *)((byte *)currentVM->dataBase + programStack + 4) );\n\t*(opStack+1) = currentVM->systemCall( (int *)((byte *)currentVM->dataBase + programStack + 4) );\n\n_asm {\n\tpop\t\tedi\n\tpop\t\tesi\n\tpop\t\tecx\n\tadd\t\tedi, 4\t\t// we added the return value\n\n\tret\n}\n\n}\n\n//--------------------------------------------\n\tmovl\tval(%esp),%ecx\n\tmovl\t$0x100,%edx\t\t// 0x10000000000 as dividend\n\tcmpl\t%edx,%ecx\n\tjle\t\tLOutOfRange\n\n\tsubl\t%eax,%eax\n\tdivl\t%ecx\n\n\tret\n\nLOutOfRange:\n\tmovl\t$0xFFFFFFFF,%eax\n\tret\n\n#if 0\n\n#define\tin\t4\n#define out\t8\n\n\t.align 2\n.globl C(TransformVector)\nC(TransformVector):\n\tmovl\tin(%esp),%eax\n\tmovl\tout(%esp),%edx\n\n\tflds\t(%eax)\t\t// in[0]\n\tfmuls\tC(vright)\t\t// in[0]*vright[0]\n\tflds\t(%eax)\t\t// in[0] | in[0]*vright[0]\n\tfmuls\tC(vup)\t\t// in[0]*vup[0] | in[0]*vright[0]\n\tflds\t(%eax)\t\t// in[0] | in[0]*vup[0] | in[0]*vright[0]\n\tfmuls\tC(vpn)\t\t// in[0]*vpn[0] | in[0]*vup[0] | in[0]*vright[0]\n\n\tflds\t4(%eax)\t\t// in[1] | ...\n\tfmuls\tC(vright)+4\t// in[1]*vright[1] | ...\n\tflds\t4(%eax)\t\t// in[1] | in[1]*vright[1] | ...\n\tfmuls\tC(vup)+4\t\t// in[1]*vup[1] | in[1]*vright[1] | ...\n\tflds\t4(%eax)\t\t// in[1] | in[1]*vup[1] | in[1]*vright[1] | ...\n\tfmuls\tC(vpn)+4\t\t// in[1]*vpn[1] | in[1]*vup[1] | in[1]*vright[1] | ...\n\tfxch\t%st(2)\t\t// in[1]*vright[1] | in[1]*vup[1] | in[1]*vpn[1] | ...\n\n\tfaddp\t%st(0),%st(5)\t// in[1]*vup[1] | in[1]*vpn[1] | ...\n\tfaddp\t%st(0),%st(3)\t// in[1]*vpn[1] | ...\n\tfaddp\t%st(0),%st(1)\t// vpn_accum | vup_accum | vright_accum\n\n\tflds\t8(%eax)\t\t// in[2] | ...\n\tfmuls\tC(vright)+8\t// in[2]*vright[2] | ...\n\tflds\t8(%eax)\t\t// in[2] | in[2]*vright[2] | ...\n\tfmuls\tC(vup)+8\t\t// in[2]*vup[2] | in[2]*vright[2] | ...\n\tflds\t8(%eax)\t\t// in[2] | in[2]*vup[2] | in[2]*vright[2] | ...\n\tfmuls\tC(vpn)+8\t\t// in[2]*vpn[2] | in[2]*vup[2] | in[2]*vright[2] | ...\n\tfxch\t%st(2)\t\t// in[2]*vright[2] | in[2]*vup[2] | in[2]*vpn[2] | ...\n\n\tfaddp\t%st(0),%st(5)\t// in[2]*vup[2] | in[2]*vpn[2] | ...\n\tfaddp\t%st(0),%st(3)\t// in[2]*vpn[2] | ...\n\tfaddp\t%st(0),%st(1)\t// vpn_accum | vup_accum | vright_accum\n\n\tfstps\t8(%edx)\t\t// out[2]\n\tfstps\t4(%edx)\t\t// out[1]\n\tfstps\t(%edx)\t\t// out[0]\n\n\tret\n\n#endif\n\n#define EMINS\t4+4\n#define EMAXS\t4+8\n#define P\t\t4+12\n\n\t.align 2\n.globl C(BoxOnPlaneSide)\nC(BoxOnPlaneSide):\n\tpushl\t%ebx\n\n\tmovl\tP(%esp),%edx\n\tmovl\tEMINS(%esp),%ecx\n\txorl\t%eax,%eax\n\tmovl\tEMAXS(%esp),%ebx\n\tmovb\tpl_signbits(%edx),%al\n\tcmpb\t$8,%al\n\tjge\t\tLerror\n\tflds\tpl_normal(%edx)\t\t// p->normal[0]\n\tfld\t\t%st(0)\t\t\t\t// p->normal[0] | p->normal[0]\n\tjmp\t\tLjmptab(,%eax,4)\n\n\n//dist1= p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];\n//dist2= p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];\nLcase0:\n\tfmuls\t(%ebx)\t\t\t\t// p->normal[0]*emaxs[0] | p->normal[0]\n\tflds\tpl_normal+4(%edx)\t// p->normal[1] | p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]\n\tfxch\t%st(2)\t\t\t\t// p->normal[0] | p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[1]\n\tfmuls\t(%ecx)\t\t\t\t// p->normal[0]*emins[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emaxs[0] | p->normal[1]\n\tfxch\t%st(2)\t\t\t\t// p->normal[1] | p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emins[0]\n\tfld\t\t%st(0)\t\t\t\t// p->normal[1] | p->normal[1] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emins[0]\n\tfmuls\t4(%ebx)\t\t\t\t// p->normal[1]*emaxs[1] | p->normal[1] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emins[0]\n\tflds\tpl_normal+8(%edx)\t// p->normal[2] | p->normal[1]*emaxs[1] |\n\t\t\t\t\t\t\t\t//  p->normal[1] | p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emins[0]\n\tfxch\t%st(2)\t\t\t\t// p->normal[1] | p->normal[1]*emaxs[1] |\n\t\t\t\t\t\t\t\t//  p->normal[2] | p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emins[0]\n\tfmuls\t4(%ecx)\t\t\t\t// p->normal[1]*emins[1] |\n\t\t\t\t\t\t\t\t//  p->normal[1]*emaxs[1] |\n\t\t\t\t\t\t\t\t//  p->normal[2] | p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emins[0]\n\tfxch\t%st(2)\t\t\t\t// p->normal[2] | p->normal[1]*emaxs[1] |\n\t\t\t\t\t\t\t\t//  p->normal[1]*emins[1] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emins[0]\n\tfld\t\t%st(0)\t\t\t\t// p->normal[2] | p->normal[2] |\n\t\t\t\t\t\t\t\t//  p->normal[1]*emaxs[1] |\n\t\t\t\t\t\t\t\t//  p->normal[1]*emins[1] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emins[0]\n\tfmuls\t8(%ebx)\t\t\t\t// p->normal[2]*emaxs[2] |\n\t\t\t\t\t\t\t\t//  p->normal[2] |\n\t\t\t\t\t\t\t\t//  p->normal[1]*emaxs[1] |\n\t\t\t\t\t\t\t\t//  p->normal[1]*emins[1] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emins[0]\n\tfxch\t%st(5)\t\t\t\t// p->normal[0]*emins[0] |\n\t\t\t\t\t\t\t\t//  p->normal[2] |\n\t\t\t\t\t\t\t\t//  p->normal[1]*emaxs[1] |\n\t\t\t\t\t\t\t\t//  p->normal[1]*emins[1] |\n\t\t\t\t\t\t\t\t//  p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t//  p->normal[2]*emaxs[2]\n\tfaddp\t%st(0),%st(3)\t\t//p->normal[2] |\n\t\t\t\t\t\t\t\t// p->normal[1]*emaxs[1] |\n\t\t\t\t\t\t\t\t// p->normal[1]*emins[1]+p->normal[0]*emins[0]|\n\t\t\t\t\t\t\t\t// p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t// p->normal[2]*emaxs[2]\n\tfmuls\t8(%ecx)\t\t\t\t//p->normal[2]*emins[2] |\n\t\t\t\t\t\t\t\t// p->normal[1]*emaxs[1] |\n\t\t\t\t\t\t\t\t// p->normal[1]*emins[1]+p->normal[0]*emins[0]|\n\t\t\t\t\t\t\t\t// p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t// p->normal[2]*emaxs[2]\n\tfxch\t%st(1)\t\t\t\t//p->normal[1]*emaxs[1] |\n\t\t\t\t\t\t\t\t// p->normal[2]*emins[2] |\n\t\t\t\t\t\t\t\t// p->normal[1]*emins[1]+p->normal[0]*emins[0]|\n\t\t\t\t\t\t\t\t// p->normal[0]*emaxs[0] |\n\t\t\t\t\t\t\t\t// p->normal[2]*emaxs[2]\n\tfaddp\t%st(0),%st(3)\t\t//p->normal[2]*emins[2] |\n\t\t\t\t\t\t\t\t// p->normal[1]*emins[1]+p->normal[0]*emins[0]|\n\t\t\t\t\t\t\t\t// p->normal[0]*emaxs[0]+p->normal[1]*emaxs[1]|\n\t\t\t\t\t\t\t\t// p->normal[2]*emaxs[2]\n\tfxch\t%st(3)\t\t\t\t//p->normal[2]*emaxs[2] +\n\t\t\t\t\t\t\t\t// p->normal[1]*emins[1]+p->normal[0]*emins[0]|\n\t\t\t\t\t\t\t\t// p->normal[0]*emaxs[0]+p->normal[1]*emaxs[1]|\n\t\t\t\t\t\t\t\t// p->normal[2]*emins[2]\n\tfaddp\t%st(0),%st(2)\t\t//p->normal[1]*emins[1]+p->normal[0]*emins[0]|\n\t\t\t\t\t\t\t\t// dist1 | p->normal[2]*emins[2]\n\n\tjmp\t\tLSetSides\n\n//dist1= p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];\n//dist2= p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];\nLcase1:\n\tfmuls\t(%ecx)\t\t\t\t// emins[0]\n\tflds\tpl_normal+4(%edx)\n\tfxch\t%st(2)\n\tfmuls\t(%ebx)\t\t\t\t// emaxs[0]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t4(%ebx)\t\t\t\t// emaxs[1]\n\tflds\tpl_normal+8(%edx)\n\tfxch\t%st(2)\n\tfmuls\t4(%ecx)\t\t\t\t// emins[1]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t8(%ebx)\t\t\t\t// emaxs[2]\n\tfxch\t%st(5)\n\tfaddp\t%st(0),%st(3)\n\tfmuls\t8(%ecx)\t\t\t\t// emins[2]\n\tfxch\t%st(1)\n\tfaddp\t%st(0),%st(3)\n\tfxch\t%st(3)\n\tfaddp\t%st(0),%st(2)\n\n\tjmp\t\tLSetSides\n\n//dist1= p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];\n//dist2= p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];\nLcase2:\n\tfmuls\t(%ebx)\t\t\t\t// emaxs[0]\n\tflds\tpl_normal+4(%edx)\n\tfxch\t%st(2)\n\tfmuls\t(%ecx)\t\t\t\t// emins[0]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t4(%ecx)\t\t\t\t// emins[1]\n\tflds\tpl_normal+8(%edx)\n\tfxch\t%st(2)\n\tfmuls\t4(%ebx)\t\t\t\t// emaxs[1]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t8(%ebx)\t\t\t\t// emaxs[2]\n\tfxch\t%st(5)\n\tfaddp\t%st(0),%st(3)\n\tfmuls\t8(%ecx)\t\t\t\t// emins[2]\n\tfxch\t%st(1)\n\tfaddp\t%st(0),%st(3)\n\tfxch\t%st(3)\n\tfaddp\t%st(0),%st(2)\n\n\tjmp\t\tLSetSides\n\n//dist1= p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];\n//dist2= p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];\nLcase3:\n\tfmuls\t(%ecx)\t\t\t\t// emins[0]\n\tflds\tpl_normal+4(%edx)\n\tfxch\t%st(2)\n\tfmuls\t(%ebx)\t\t\t\t// emaxs[0]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t4(%ecx)\t\t\t\t// emins[1]\n\tflds\tpl_normal+8(%edx)\n\tfxch\t%st(2)\n\tfmuls\t4(%ebx)\t\t\t\t// emaxs[1]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t8(%ebx)\t\t\t\t// emaxs[2]\n\tfxch\t%st(5)\n\tfaddp\t%st(0),%st(3)\n\tfmuls\t8(%ecx)\t\t\t\t// emins[2]\n\tfxch\t%st(1)\n\tfaddp\t%st(0),%st(3)\n\tfxch\t%st(3)\n\tfaddp\t%st(0),%st(2)\n\n\tjmp\t\tLSetSides\n\n//dist1= p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];\n//dist2= p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];\nLcase4:\n\tfmuls\t(%ebx)\t\t\t\t// emaxs[0]\n\tflds\tpl_normal+4(%edx)\n\tfxch\t%st(2)\n\tfmuls\t(%ecx)\t\t\t\t// emins[0]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t4(%ebx)\t\t\t\t// emaxs[1]\n\tflds\tpl_normal+8(%edx)\n\tfxch\t%st(2)\n\tfmuls\t4(%ecx)\t\t\t\t// emins[1]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t8(%ecx)\t\t\t\t// emins[2]\n\tfxch\t%st(5)\n\tfaddp\t%st(0),%st(3)\n\tfmuls\t8(%ebx)\t\t\t\t// emaxs[2]\n\tfxch\t%st(1)\n\tfaddp\t%st(0),%st(3)\n\tfxch\t%st(3)\n\tfaddp\t%st(0),%st(2)\n\n\tjmp\t\tLSetSides\n\n//dist1= p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];\n//dist2= p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];\nLcase5:\n\tfmuls\t(%ecx)\t\t\t\t// emins[0]\n\tflds\tpl_normal+4(%edx)\n\tfxch\t%st(2)\n\tfmuls\t(%ebx)\t\t\t\t// emaxs[0]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t4(%ebx)\t\t\t\t// emaxs[1]\n\tflds\tpl_normal+8(%edx)\n\tfxch\t%st(2)\n\tfmuls\t4(%ecx)\t\t\t\t// emins[1]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t8(%ecx)\t\t\t\t// emins[2]\n\tfxch\t%st(5)\n\tfaddp\t%st(0),%st(3)\n\tfmuls\t8(%ebx)\t\t\t\t// emaxs[2]\n\tfxch\t%st(1)\n\tfaddp\t%st(0),%st(3)\n\tfxch\t%st(3)\n\tfaddp\t%st(0),%st(2)\n\n\tjmp\t\tLSetSides\n\n//dist1= p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];\n//dist2= p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];\nLcase6:\n\tfmuls\t(%ebx)\t\t\t\t// emaxs[0]\n\tflds\tpl_normal+4(%edx)\n\tfxch\t%st(2)\n\tfmuls\t(%ecx)\t\t\t\t// emins[0]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t4(%ecx)\t\t\t\t// emins[1]\n\tflds\tpl_normal+8(%edx)\n\tfxch\t%st(2)\n\tfmuls\t4(%ebx)\t\t\t\t// emaxs[1]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t8(%ecx)\t\t\t\t// emins[2]\n\tfxch\t%st(5)\n\tfaddp\t%st(0),%st(3)\n\tfmuls\t8(%ebx)\t\t\t\t// emaxs[2]\n\tfxch\t%st(1)\n\tfaddp\t%st(0),%st(3)\n\tfxch\t%st(3)\n\tfaddp\t%st(0),%st(2)\n\n\tjmp\t\tLSetSides\n\n//dist1= p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];\n//dist2= p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];\nLcase7:\n\tfmuls\t(%ecx)\t\t\t\t// emins[0]\n\tflds\tpl_normal+4(%edx)\n\tfxch\t%st(2)\n\tfmuls\t(%ebx)\t\t\t\t// emaxs[0]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t4(%ecx)\t\t\t\t// emins[1]\n\tflds\tpl_normal+8(%edx)\n\tfxch\t%st(2)\n\tfmuls\t4(%ebx)\t\t\t\t// emaxs[1]\n\tfxch\t%st(2)\n\tfld\t\t%st(0)\n\tfmuls\t8(%ecx)\t\t\t\t// emins[2]\n\tfxch\t%st(5)\n\tfaddp\t%st(0),%st(3)\n\tfmuls\t8(%ebx)\t\t\t\t// emaxs[2]\n\tfxch\t%st(1)\n\tfaddp\t%st(0),%st(3)\n\tfxch\t%st(3)\n\tfaddp\t%st(0),%st(2)\n\nLSetSides:\n\n//\tsides = 0;\n//\tif (dist1 >= p->dist)\n//\t\tsides = 1;\n//\tif (dist2 < p->dist)\n//\t\tsides |= 2;\n\n\tfaddp\t%st(0),%st(2)\t\t// dist1 | dist2\n\tfcomps\tpl_dist(%edx)\n\txorl\t%ecx,%ecx\n\tfnstsw\t%ax\n\tfcomps\tpl_dist(%edx)\n\tandb\t$1,%ah\n\txorb\t$1,%ah\n\taddb\t%ah,%cl\n\n\tfnstsw\t%ax\n\tandb\t$1,%ah\n\taddb\t%ah,%ah\n\taddb\t%ah,%cl\n\n//\treturn sides;\n\n\tpopl\t%ebx\n\tmovl\t%ecx,%eax\t// return status\n\n\tret\n\n\nLerror:\n\tmovl\t1, %eax\n\tret\n\n#endif\t// id386\n"
  },
  {
    "path": "code/win32/glw_win.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef _WIN32\n#  error You should not be including this file on this platform\n#endif\n\n#ifndef __GLW_WIN_H__\n#define __GLW_WIN_H__\n\ntypedef struct\n{\n\tWNDPROC\t\twndproc;\n\n\tHDC     hDC;\t\t\t// handle to device context\n\tHGLRC   hGLRC;\t\t\t// handle to GL rendering context\n\n\tHINSTANCE hinstOpenGL;\t// HINSTANCE for the OpenGL library\n\n\tqboolean allowdisplaydepthchange;\n\tqboolean pixelFormatSet;\n\n\tint\t\t desktopBitsPixel;\n\tint\t\t desktopWidth, desktopHeight;\n\n\tqboolean\tcdsFullscreen;\n\n\tFILE *log_fp;\n} glwstate_t;\n\nextern glwstate_t glw_state;\n\n#endif\n"
  },
  {
    "path": "code/win32/resource.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//{{NO_DEPENDENCIES}}\n// Microsoft Developer Studio generated include file.\n// Used by winquake.rc\n//\n#define IDS_STRING1                     1\n#define IDI_ICON1                       1\n#define IDB_BITMAP1                     1\n#define IDB_BITMAP2                     128\n#define IDC_CURSOR1                     129\n#define IDC_CURSOR2                     130\n#define IDC_CURSOR3                     131\n\n// Next default values for new objects\n// \n#ifdef APSTUDIO_INVOKED\n#ifndef APSTUDIO_READONLY_SYMBOLS\n#define _APS_NO_MFC                     1\n#define _APS_NEXT_RESOURCE_VALUE        132\n#define _APS_NEXT_COMMAND_VALUE         40001\n#define _APS_NEXT_CONTROL_VALUE         1005\n#define _APS_NEXT_SYMED_VALUE           101\n#endif\n#endif\n"
  },
  {
    "path": "code/win32/win_gamma.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n/*\n** WIN_GAMMA.C\n*/\n#include <assert.h>\n#include \"../renderer/tr_local.h\"\n#include \"../qcommon/qcommon.h\"\n#include \"glw_win.h\"\n#include \"win_local.h\"\n\nstatic unsigned short s_oldHardwareGamma[3][256];\n\n/*\n** WG_CheckHardwareGamma\n**\n** Determines if the underlying hardware supports the Win32 gamma correction API.\n*/\nvoid WG_CheckHardwareGamma( void )\n{\n\tHDC\t\t\thDC;\n\n\tglConfig.deviceSupportsGamma = qfalse;\n\n\tif ( qwglSetDeviceGammaRamp3DFX )\n\t{\n\t\tglConfig.deviceSupportsGamma = qtrue;\n\n\t\thDC = GetDC( GetDesktopWindow() );\n\t\tglConfig.deviceSupportsGamma = qwglGetDeviceGammaRamp3DFX( hDC, s_oldHardwareGamma );\n\t\tReleaseDC( GetDesktopWindow(), hDC );\n\n\t\treturn;\n\t}\n\n\t// non-3Dfx standalone drivers don't support gamma changes, period\n\tif ( glConfig.driverType == GLDRV_STANDALONE )\n\t{\n\t\treturn;\n\t}\n\n\tif ( !r_ignorehwgamma->integer )\n\t{\n\t\thDC = GetDC( GetDesktopWindow() );\n\t\tglConfig.deviceSupportsGamma = GetDeviceGammaRamp( hDC, s_oldHardwareGamma );\n\t\tReleaseDC( GetDesktopWindow(), hDC );\n\n\t\tif ( glConfig.deviceSupportsGamma )\n\t\t{\n\t\t\t//\n\t\t\t// do a sanity check on the gamma values\n\t\t\t//\n\t\t\tif ( ( HIBYTE( s_oldHardwareGamma[0][255] ) <= HIBYTE( s_oldHardwareGamma[0][0] ) ) ||\n\t\t\t\t ( HIBYTE( s_oldHardwareGamma[1][255] ) <= HIBYTE( s_oldHardwareGamma[1][0] ) ) ||\n\t\t\t\t ( HIBYTE( s_oldHardwareGamma[2][255] ) <= HIBYTE( s_oldHardwareGamma[2][0] ) ) )\n\t\t\t{\n\t\t\t\tglConfig.deviceSupportsGamma = qfalse;\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: device has broken gamma support, generated gamma.dat\\n\" );\n\t\t\t}\n\n\t\t\t//\n\t\t\t// make sure that we didn't have a prior crash in the game, and if so we need to\n\t\t\t// restore the gamma values to at least a linear value\n\t\t\t//\n\t\t\tif ( ( HIBYTE( s_oldHardwareGamma[0][181] ) == 255 ) )\n\t\t\t{\n\t\t\t\tint g;\n\n\t\t\t\tri.Printf( PRINT_WARNING, \"WARNING: suspicious gamma tables, using linear ramp for restoration\\n\" );\n\n\t\t\t\tfor ( g = 0; g < 255; g++ )\n\t\t\t\t{\n\t\t\t\t\ts_oldHardwareGamma[0][g] = g << 8;\n\t\t\t\t\ts_oldHardwareGamma[1][g] = g << 8;\n\t\t\t\t\ts_oldHardwareGamma[2][g] = g << 8;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\nvoid mapGammaMax( void ) {\n\tint\t\ti, j;\n\tunsigned short table[3][256];\n\n\t// try to figure out what win2k will let us get away with setting\n\tfor ( i = 0 ; i < 256 ; i++ ) {\n\t\tif ( i >= 128 ) {\n\t\t\ttable[0][i] = table[1][i] = table[2][i] = 0xffff;\n\t\t} else {\n\t\t\ttable[0][i] = table[1][i] = table[2][i] = i<<9;\n\t\t}\n\t}\n\n\tfor ( i = 0 ; i < 128 ; i++ ) {\n\t\tfor ( j = i*2 ; j < 255 ; j++ ) {\n\t\t\ttable[0][i] = table[1][i] = table[2][i] = j<<8;\n\t\t\tif ( !SetDeviceGammaRamp( glw_state.hDC, table ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\ttable[0][i] = table[1][i] = table[2][i] = i<<9;\n\t\tCom_Printf( \"index %i max: %i\\n\", i, j-1 );\n\t}\n}\n*/\n\n/*\n** GLimp_SetGamma\n**\n** This routine should only be called if glConfig.deviceSupportsGamma is TRUE\n*/\nvoid GLimp_SetGamma( unsigned char red[256], unsigned char green[256], unsigned char blue[256] ) {\n\tunsigned short table[3][256];\n\tint\t\ti, j;\n\tint\t\tret;\n\tOSVERSIONINFO\tvinfo;\n\n\tif ( !glConfig.deviceSupportsGamma || r_ignorehwgamma->integer || !glw_state.hDC ) {\n\t\treturn;\n\t}\n\n//mapGammaMax();\n\n\tfor ( i = 0; i < 256; i++ ) {\n\t\ttable[0][i] = ( ( ( unsigned short ) red[i] ) << 8 ) | red[i];\n\t\ttable[1][i] = ( ( ( unsigned short ) green[i] ) << 8 ) | green[i];\n\t\ttable[2][i] = ( ( ( unsigned short ) blue[i] ) << 8 ) | blue[i];\n\t}\n\n\t// Win2K puts this odd restriction on gamma ramps...\n\tvinfo.dwOSVersionInfoSize = sizeof(vinfo);\n\tGetVersionEx( &vinfo );\n\tif ( vinfo.dwMajorVersion == 5 && vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT ) {\n\t\tCom_DPrintf( \"performing W2K gamma clamp.\\n\" );\n\t\tfor ( j = 0 ; j < 3 ; j++ ) {\n\t\t\tfor ( i = 0 ; i < 128 ; i++ ) {\n\t\t\t\tif ( table[j][i] > ( (128+i) << 8 ) ) {\n\t\t\t\t\ttable[j][i] = (128+i) << 8;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( table[j][127] > 254<<8 ) {\n\t\t\t\ttable[j][127] = 254<<8;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tCom_DPrintf( \"skipping W2K gamma clamp.\\n\" );\n\t}\n\n\t// enforce constantly increasing\n\tfor ( j = 0 ; j < 3 ; j++ ) {\n\t\tfor ( i = 1 ; i < 256 ; i++ ) {\n\t\t\tif ( table[j][i] < table[j][i-1] ) {\n\t\t\t\ttable[j][i] = table[j][i-1];\n\t\t\t}\n\t\t}\n\t}\n\n\n\tif ( qwglSetDeviceGammaRamp3DFX )\n\t{\n\t\tqwglSetDeviceGammaRamp3DFX( glw_state.hDC, table );\n\t}\n\telse\n\t{\n\t\tret = SetDeviceGammaRamp( glw_state.hDC, table );\n\t\tif ( !ret ) {\n\t\t\tCom_Printf( \"SetDeviceGammaRamp failed.\\n\" );\n\t\t}\n\t}\n}\n\n/*\n** WG_RestoreGamma\n*/\nvoid WG_RestoreGamma( void )\n{\n\tif ( glConfig.deviceSupportsGamma )\n\t{\n\t\tif ( qwglSetDeviceGammaRamp3DFX )\n\t\t{\n\t\t\tqwglSetDeviceGammaRamp3DFX( glw_state.hDC, s_oldHardwareGamma );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tHDC hDC;\n\t\t\t\n\t\t\thDC = GetDC( GetDesktopWindow() );\n\t\t\tSetDeviceGammaRamp( hDC, s_oldHardwareGamma );\n\t\t\tReleaseDC( GetDesktopWindow(), hDC );\n\t\t}\n\t}\n}\n\n"
  },
  {
    "path": "code/win32/win_glimp.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n/*\n** WIN_GLIMP.C\n**\n** This file contains ALL Win32 specific stuff having to do with the\n** OpenGL refresh.  When a port is being made the following functions\n** must be implemented by the port:\n**\n** GLimp_EndFrame\n** GLimp_Init\n** GLimp_LogComment\n** GLimp_Shutdown\n**\n** Note that the GLW_xxx functions are Windows specific GL-subsystem\n** related functions that are relevant ONLY to win_glimp.c\n*/\n#include <assert.h>\n#include \"../renderer/tr_local.h\"\n#include \"../qcommon/qcommon.h\"\n#include \"resource.h\"\n#include \"glw_win.h\"\n#include \"win_local.h\"\n\nextern void WG_CheckHardwareGamma( void );\nextern void WG_RestoreGamma( void );\n\ntypedef enum {\n\tRSERR_OK,\n\n\tRSERR_INVALID_FULLSCREEN,\n\tRSERR_INVALID_MODE,\n\n\tRSERR_UNKNOWN\n} rserr_t;\n\n#define TRY_PFD_SUCCESS\t\t0\n#define TRY_PFD_FAIL_SOFT\t1\n#define TRY_PFD_FAIL_HARD\t2\n\n#define\tWINDOW_CLASS_NAME\t\"Quake 3: Arena\"\n\nstatic void\t\tGLW_InitExtensions( void );\nstatic rserr_t\tGLW_SetMode( const char *drivername, \n\t\t\t\t\t\t\t int mode, \n\t\t\t\t\t\t\t int colorbits, \n\t\t\t\t\t\t\t qboolean cdsFullscreen );\n\nstatic qboolean s_classRegistered = qfalse;\n\n//\n// function declaration\n//\nvoid\t QGL_EnableLogging( qboolean enable );\nqboolean QGL_Init( const char *dllname );\nvoid     QGL_Shutdown( void );\n\n//\n// variable declarations\n//\nglwstate_t glw_state;\n\ncvar_t\t*r_allowSoftwareGL;\t\t// don't abort out if the pixelformat claims software\ncvar_t\t*r_maskMinidriver;\t\t// allow a different dll name to be treated as if it were opengl32.dll\n\n\n\n/*\n** GLW_StartDriverAndSetMode\n*/\nstatic qboolean GLW_StartDriverAndSetMode( const char *drivername, \n\t\t\t\t\t\t\t\t\t\t   int mode, \n\t\t\t\t\t\t\t\t\t\t   int colorbits,\n\t\t\t\t\t\t\t\t\t\t   qboolean cdsFullscreen )\n{\n\trserr_t err;\n\n\terr = GLW_SetMode( drivername, r_mode->integer, colorbits, cdsFullscreen );\n\n\tswitch ( err )\n\t{\n\tcase RSERR_INVALID_FULLSCREEN:\n\t\tri.Printf( PRINT_ALL, \"...WARNING: fullscreen unavailable in this mode\\n\" );\n\t\treturn qfalse;\n\tcase RSERR_INVALID_MODE:\n\t\tri.Printf( PRINT_ALL, \"...WARNING: could not set the given mode (%d)\\n\", mode );\n\t\treturn qfalse;\n\tdefault:\n\t\tbreak;\n\t}\n\treturn qtrue;\n}\n\n/*\n** ChoosePFD\n**\n** Helper function that replaces ChoosePixelFormat.\n*/\n#define MAX_PFDS 256\n\nstatic int GLW_ChoosePFD( HDC hDC, PIXELFORMATDESCRIPTOR *pPFD )\n{\n\tPIXELFORMATDESCRIPTOR pfds[MAX_PFDS+1];\n\tint maxPFD = 0;\n\tint i;\n\tint bestMatch = 0;\n\n\tri.Printf( PRINT_ALL, \"...GLW_ChoosePFD( %d, %d, %d )\\n\", ( int ) pPFD->cColorBits, ( int ) pPFD->cDepthBits, ( int ) pPFD->cStencilBits );\n\n\t// count number of PFDs\n\tif ( glConfig.driverType > GLDRV_ICD )\n\t{\n\t\tmaxPFD = qwglDescribePixelFormat( hDC, 1, sizeof( PIXELFORMATDESCRIPTOR ), &pfds[0] );\n\t}\n\telse\n\t{\n\t\tmaxPFD = DescribePixelFormat( hDC, 1, sizeof( PIXELFORMATDESCRIPTOR ), &pfds[0] );\n\t}\n\tif ( maxPFD > MAX_PFDS )\n\t{\n\t\tri.Printf( PRINT_WARNING, \"...numPFDs > MAX_PFDS (%d > %d)\\n\", maxPFD, MAX_PFDS );\n\t\tmaxPFD = MAX_PFDS;\n\t}\n\n\tri.Printf( PRINT_ALL, \"...%d PFDs found\\n\", maxPFD - 1 );\n\n\t// grab information\n\tfor ( i = 1; i <= maxPFD; i++ )\n\t{\n\t\tif ( glConfig.driverType > GLDRV_ICD )\n\t\t{\n\t\t\tqwglDescribePixelFormat( hDC, i, sizeof( PIXELFORMATDESCRIPTOR ), &pfds[i] );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tDescribePixelFormat( hDC, i, sizeof( PIXELFORMATDESCRIPTOR ), &pfds[i] );\n\t\t}\n\t}\n\n\t// look for a best match\n\tfor ( i = 1; i <= maxPFD; i++ )\n\t{\n\t\t//\n\t\t// make sure this has hardware acceleration\n\t\t//\n\t\tif ( ( pfds[i].dwFlags & PFD_GENERIC_FORMAT ) != 0 ) \n\t\t{\n\t\t\tif ( !r_allowSoftwareGL->integer )\n\t\t\t{\n\t\t\t\tif ( r_verbose->integer )\n\t\t\t\t{\n\t\t\t\t\tri.Printf( PRINT_ALL, \"...PFD %d rejected, software acceleration\\n\", i );\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\t// verify pixel type\n\t\tif ( pfds[i].iPixelType != PFD_TYPE_RGBA )\n\t\t{\n\t\t\tif ( r_verbose->integer )\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_ALL, \"...PFD %d rejected, not RGBA\\n\", i );\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// verify proper flags\n\t\tif ( ( ( pfds[i].dwFlags & pPFD->dwFlags ) & pPFD->dwFlags ) != pPFD->dwFlags ) \n\t\t{\n\t\t\tif ( r_verbose->integer )\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_ALL, \"...PFD %d rejected, improper flags (%x instead of %x)\\n\", i, pfds[i].dwFlags, pPFD->dwFlags );\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// verify enough bits\n\t\tif ( pfds[i].cDepthBits < 15 )\n\t\t{\n\t\t\tcontinue;\n\t\t}\n\t\tif ( ( pfds[i].cStencilBits < 4 ) && ( pPFD->cStencilBits > 0 ) )\n\t\t{\n\t\t\tcontinue;\n\t\t}\n\n\t\t//\n\t\t// selection criteria (in order of priority):\n\t\t// \n\t\t//  PFD_STEREO\n\t\t//  colorBits\n\t\t//  depthBits\n\t\t//  stencilBits\n\t\t//\n\t\tif ( bestMatch )\n\t\t{\n\t\t\t// check stereo\n\t\t\tif ( ( pfds[i].dwFlags & PFD_STEREO ) && ( !( pfds[bestMatch].dwFlags & PFD_STEREO ) ) && ( pPFD->dwFlags & PFD_STEREO ) )\n\t\t\t{\n\t\t\t\tbestMatch = i;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\n\t\t\tif ( !( pfds[i].dwFlags & PFD_STEREO ) && ( pfds[bestMatch].dwFlags & PFD_STEREO ) && ( pPFD->dwFlags & PFD_STEREO ) )\n\t\t\t{\n\t\t\t\tbestMatch = i;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// check color\n\t\t\tif ( pfds[bestMatch].cColorBits != pPFD->cColorBits )\n\t\t\t{\n\t\t\t\t// prefer perfect match\n\t\t\t\tif ( pfds[i].cColorBits == pPFD->cColorBits )\n\t\t\t\t{\n\t\t\t\t\tbestMatch = i;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// otherwise if this PFD has more bits than our best, use it\n\t\t\t\telse if ( pfds[i].cColorBits > pfds[bestMatch].cColorBits )\n\t\t\t\t{\n\t\t\t\t\tbestMatch = i;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// check depth\n\t\t\tif ( pfds[bestMatch].cDepthBits != pPFD->cDepthBits )\n\t\t\t{\n\t\t\t\t// prefer perfect match\n\t\t\t\tif ( pfds[i].cDepthBits == pPFD->cDepthBits )\n\t\t\t\t{\n\t\t\t\t\tbestMatch = i;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// otherwise if this PFD has more bits than our best, use it\n\t\t\t\telse if ( pfds[i].cDepthBits > pfds[bestMatch].cDepthBits )\n\t\t\t\t{\n\t\t\t\t\tbestMatch = i;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// check stencil\n\t\t\tif ( pfds[bestMatch].cStencilBits != pPFD->cStencilBits )\n\t\t\t{\n\t\t\t\t// prefer perfect match\n\t\t\t\tif ( pfds[i].cStencilBits == pPFD->cStencilBits )\n\t\t\t\t{\n\t\t\t\t\tbestMatch = i;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// otherwise if this PFD has more bits than our best, use it\n\t\t\t\telse if ( ( pfds[i].cStencilBits > pfds[bestMatch].cStencilBits ) && \n\t\t\t\t\t ( pPFD->cStencilBits > 0 ) )\n\t\t\t\t{\n\t\t\t\t\tbestMatch = i;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tbestMatch = i;\n\t\t}\n\t}\n\t\n\tif ( !bestMatch )\n\t\treturn 0;\n\n\tif ( ( pfds[bestMatch].dwFlags & PFD_GENERIC_FORMAT ) != 0 )\n\t{\n\t\tif ( !r_allowSoftwareGL->integer )\n\t\t{\n\t\t\tri.Printf( PRINT_ALL, \"...no hardware acceleration found\\n\" );\n\t\t\treturn 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tri.Printf( PRINT_ALL, \"...using software emulation\\n\" );\n\t\t}\n\t}\n\telse if ( pfds[bestMatch].dwFlags & PFD_GENERIC_ACCELERATED )\n\t{\n\t\tri.Printf( PRINT_ALL, \"...MCD acceleration found\\n\" );\n\t}\n\telse\n\t{\n\t\tri.Printf( PRINT_ALL, \"...hardware acceleration found\\n\" );\n\t}\n\n\t*pPFD = pfds[bestMatch];\n\n\treturn bestMatch;\n}\n\n/*\n** void GLW_CreatePFD\n**\n** Helper function zeros out then fills in a PFD\n*/\nstatic void GLW_CreatePFD( PIXELFORMATDESCRIPTOR *pPFD, int colorbits, int depthbits, int stencilbits, qboolean stereo )\n{\n    PIXELFORMATDESCRIPTOR src = \n\t{\n\t\tsizeof(PIXELFORMATDESCRIPTOR),\t// size of this pfd\n\t\t1,\t\t\t\t\t\t\t\t// version number\n\t\tPFD_DRAW_TO_WINDOW |\t\t\t// support window\n\t\tPFD_SUPPORT_OPENGL |\t\t\t// support OpenGL\n\t\tPFD_DOUBLEBUFFER,\t\t\t\t// double buffered\n\t\tPFD_TYPE_RGBA,\t\t\t\t\t// RGBA type\n\t\t24,\t\t\t\t\t\t\t\t// 24-bit color depth\n\t\t0, 0, 0, 0, 0, 0,\t\t\t\t// color bits ignored\n\t\t0,\t\t\t\t\t\t\t\t// no alpha buffer\n\t\t0,\t\t\t\t\t\t\t\t// shift bit ignored\n\t\t0,\t\t\t\t\t\t\t\t// no accumulation buffer\n\t\t0, 0, 0, 0, \t\t\t\t\t// accum bits ignored\n\t\t24,\t\t\t\t\t\t\t\t// 24-bit z-buffer\t\n\t\t8,\t\t\t\t\t\t\t\t// 8-bit stencil buffer\n\t\t0,\t\t\t\t\t\t\t\t// no auxiliary buffer\n\t\tPFD_MAIN_PLANE,\t\t\t\t\t// main layer\n\t\t0,\t\t\t\t\t\t\t\t// reserved\n\t\t0, 0, 0\t\t\t\t\t\t\t// layer masks ignored\n    };\n\n\tsrc.cColorBits = colorbits;\n\tsrc.cDepthBits = depthbits;\n\tsrc.cStencilBits = stencilbits;\n\n\tif ( stereo )\n\t{\n\t\tri.Printf( PRINT_ALL, \"...attempting to use stereo\\n\" );\n\t\tsrc.dwFlags |= PFD_STEREO;\n\t\tglConfig.stereoEnabled = qtrue;\n\t}\n\telse\n\t{\n\t\tglConfig.stereoEnabled = qfalse;\n\t}\n\n\t*pPFD = src;\n}\n\n/*\n** GLW_MakeContext\n*/\nstatic int GLW_MakeContext( PIXELFORMATDESCRIPTOR *pPFD )\n{\n\tint pixelformat;\n\n\t//\n\t// don't putz around with pixelformat if it's already set (e.g. this is a soft\n\t// reset of the graphics system)\n\t//\n\tif ( !glw_state.pixelFormatSet )\n\t{\n\t\t//\n\t\t// choose, set, and describe our desired pixel format.  If we're\n\t\t// using a minidriver then we need to bypass the GDI functions,\n\t\t// otherwise use the GDI functions.\n\t\t//\n\t\tif ( ( pixelformat = GLW_ChoosePFD( glw_state.hDC, pPFD ) ) == 0 )\n\t\t{\n\t\t\tri.Printf( PRINT_ALL, \"...GLW_ChoosePFD failed\\n\");\n\t\t\treturn TRY_PFD_FAIL_SOFT;\n\t\t}\n\t\tri.Printf( PRINT_ALL, \"...PIXELFORMAT %d selected\\n\", pixelformat );\n\n\t\tif ( glConfig.driverType > GLDRV_ICD )\n\t\t{\n\t\t\tqwglDescribePixelFormat( glw_state.hDC, pixelformat, sizeof( *pPFD ), pPFD );\n\t\t\tif ( qwglSetPixelFormat( glw_state.hDC, pixelformat, pPFD ) == FALSE )\n\t\t\t{\n\t\t\t\tri.Printf ( PRINT_ALL, \"...qwglSetPixelFormat failed\\n\");\n\t\t\t\treturn TRY_PFD_FAIL_SOFT;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tDescribePixelFormat( glw_state.hDC, pixelformat, sizeof( *pPFD ), pPFD );\n\n\t\t\tif ( SetPixelFormat( glw_state.hDC, pixelformat, pPFD ) == FALSE )\n\t\t\t{\n\t\t\t\tri.Printf (PRINT_ALL, \"...SetPixelFormat failed\\n\", glw_state.hDC );\n\t\t\t\treturn TRY_PFD_FAIL_SOFT;\n\t\t\t}\n\t\t}\n\n\t\tglw_state.pixelFormatSet = qtrue;\n\t}\n\n\t//\n\t// startup the OpenGL subsystem by creating a context and making it current\n\t//\n\tif ( !glw_state.hGLRC )\n\t{\n\t\tri.Printf( PRINT_ALL, \"...creating GL context: \" );\n\t\tif ( ( glw_state.hGLRC = qwglCreateContext( glw_state.hDC ) ) == 0 )\n\t\t{\n\t\t\tri.Printf (PRINT_ALL, \"failed\\n\");\n\n\t\t\treturn TRY_PFD_FAIL_HARD;\n\t\t}\n\t\tri.Printf( PRINT_ALL, \"succeeded\\n\" );\n\n\t\tri.Printf( PRINT_ALL, \"...making context current: \" );\n\t\tif ( !qwglMakeCurrent( glw_state.hDC, glw_state.hGLRC ) )\n\t\t{\n\t\t\tqwglDeleteContext( glw_state.hGLRC );\n\t\t\tglw_state.hGLRC = NULL;\n\t\t\tri.Printf (PRINT_ALL, \"failed\\n\");\n\t\t\treturn TRY_PFD_FAIL_HARD;\n\t\t}\n\t\tri.Printf( PRINT_ALL, \"succeeded\\n\" );\n\t}\n\n\treturn TRY_PFD_SUCCESS;\n}\n\n\n/*\n** GLW_InitDriver\n**\n** - get a DC if one doesn't exist\n** - create an HGLRC if one doesn't exist\n*/\nstatic qboolean GLW_InitDriver( const char *drivername, int colorbits )\n{\n\tint\t\ttpfd;\n\tint\t\tdepthbits, stencilbits;\n\tstatic PIXELFORMATDESCRIPTOR pfd;\t\t// save between frames since 'tr' gets cleared\n\n\tri.Printf( PRINT_ALL, \"Initializing OpenGL driver\\n\" );\n\n\t//\n\t// get a DC for our window if we don't already have one allocated\n\t//\n\tif ( glw_state.hDC == NULL )\n\t{\n\t\tri.Printf( PRINT_ALL, \"...getting DC: \" );\n\n\t\tif ( ( glw_state.hDC = GetDC( g_wv.hWnd ) ) == NULL )\n\t\t{\n\t\t\tri.Printf( PRINT_ALL, \"failed\\n\" );\n\t\t\treturn qfalse;\n\t\t}\n\t\tri.Printf( PRINT_ALL, \"succeeded\\n\" );\n\t}\n\n\tif ( colorbits == 0 )\n\t{\n\t\tcolorbits = glw_state.desktopBitsPixel;\n\t}\n\n\t//\n\t// implicitly assume Z-buffer depth == desktop color depth\n\t//\n\tif ( r_depthbits->integer == 0 ) {\n\t\tif ( colorbits > 16 ) {\n\t\t\tdepthbits = 24;\n\t\t} else {\n\t\t\tdepthbits = 16;\n\t\t}\n\t} else {\n\t\tdepthbits = r_depthbits->integer;\n\t}\n\n\t//\n\t// do not allow stencil if Z-buffer depth likely won't contain it\n\t//\n\tstencilbits = r_stencilbits->integer;\n\tif ( depthbits < 24 )\n\t{\n\t\tstencilbits = 0;\n\t}\n\n\t//\n\t// make two attempts to set the PIXELFORMAT\n\t//\n\n\t//\n\t// first attempt: r_colorbits, depthbits, and r_stencilbits\n\t//\n\tif ( !glw_state.pixelFormatSet )\n\t{\n\t\tGLW_CreatePFD( &pfd, colorbits, depthbits, stencilbits, r_stereo->integer );\n\t\tif ( ( tpfd = GLW_MakeContext( &pfd ) ) != TRY_PFD_SUCCESS )\n\t\t{\n\t\t\tif ( tpfd == TRY_PFD_FAIL_HARD )\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_WARNING, \"...failed hard\\n\" );\n\t\t\t\treturn qfalse;\n\t\t\t}\n\n\t\t\t//\n\t\t\t// punt if we've already tried the desktop bit depth and no stencil bits\n\t\t\t//\n\t\t\tif ( ( r_colorbits->integer == glw_state.desktopBitsPixel ) &&\n\t\t\t\t ( stencilbits == 0 ) )\n\t\t\t{\n\t\t\t\tReleaseDC( g_wv.hWnd, glw_state.hDC );\n\t\t\t\tglw_state.hDC = NULL;\n\n\t\t\t\tri.Printf( PRINT_ALL, \"...failed to find an appropriate PIXELFORMAT\\n\" );\n\n\t\t\t\treturn qfalse;\n\t\t\t}\n\n\t\t\t//\n\t\t\t// second attempt: desktop's color bits and no stencil\n\t\t\t//\n\t\t\tif ( colorbits > glw_state.desktopBitsPixel )\n\t\t\t{\n\t\t\t\tcolorbits = glw_state.desktopBitsPixel;\n\t\t\t}\n\t\t\tGLW_CreatePFD( &pfd, colorbits, depthbits, 0, r_stereo->integer );\n\t\t\tif ( GLW_MakeContext( &pfd ) != TRY_PFD_SUCCESS )\n\t\t\t{\n\t\t\t\tif ( glw_state.hDC )\n\t\t\t\t{\n\t\t\t\t\tReleaseDC( g_wv.hWnd, glw_state.hDC );\n\t\t\t\t\tglw_state.hDC = NULL;\n\t\t\t\t}\n\n\t\t\t\tri.Printf( PRINT_ALL, \"...failed to find an appropriate PIXELFORMAT\\n\" );\n\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t}\n\n\t\t/*\n\t\t** report if stereo is desired but unavailable\n\t\t*/\n\t\tif ( !( pfd.dwFlags & PFD_STEREO ) && ( r_stereo->integer != 0 ) ) \n\t\t{\n\t\t\tri.Printf( PRINT_ALL, \"...failed to select stereo pixel format\\n\" );\n\t\t\tglConfig.stereoEnabled = qfalse;\n\t\t}\n\t}\n\n\t/*\n\t** store PFD specifics \n\t*/\n\tglConfig.colorBits = ( int ) pfd.cColorBits;\n\tglConfig.depthBits = ( int ) pfd.cDepthBits;\n\tglConfig.stencilBits = ( int ) pfd.cStencilBits;\n\n\treturn qtrue;\n}\n\n/*\n** GLW_CreateWindow\n**\n** Responsible for creating the Win32 window and initializing the OpenGL driver.\n*/\n#define\tWINDOW_STYLE\t(WS_OVERLAPPED|WS_BORDER|WS_CAPTION|WS_VISIBLE)\nstatic qboolean GLW_CreateWindow( const char *drivername, int width, int height, int colorbits, qboolean cdsFullscreen )\n{\n\tRECT\t\t\tr;\n\tcvar_t\t\t\t*vid_xpos, *vid_ypos;\n\tint\t\t\t\tstylebits;\n\tint\t\t\t\tx, y, w, h;\n\tint\t\t\t\texstyle;\n\n\t//\n\t// register the window class if necessary\n\t//\n\tif ( !s_classRegistered )\n\t{\n\t\tWNDCLASS wc;\n\n\t\tmemset( &wc, 0, sizeof( wc ) );\n\n\t\twc.style         = 0;\n\t\twc.lpfnWndProc   = (WNDPROC) glw_state.wndproc;\n\t\twc.cbClsExtra    = 0;\n\t\twc.cbWndExtra    = 0;\n\t\twc.hInstance     = g_wv.hInstance;\n\t\twc.hIcon         = LoadIcon( g_wv.hInstance, MAKEINTRESOURCE(IDI_ICON1));\n\t\twc.hCursor       = LoadCursor (NULL,IDC_ARROW);\n\t\twc.hbrBackground = (void *)COLOR_GRAYTEXT;\n\t\twc.lpszMenuName  = 0;\n\t\twc.lpszClassName = WINDOW_CLASS_NAME;\n\n\t\tif ( !RegisterClass( &wc ) )\n\t\t{\n\t\t\tri.Error( ERR_FATAL, \"GLW_CreateWindow: could not register window class\" );\n\t\t}\n\t\ts_classRegistered = qtrue;\n\t\tri.Printf( PRINT_ALL, \"...registered window class\\n\" );\n\t}\n\n\t//\n\t// create the HWND if one does not already exist\n\t//\n\tif ( !g_wv.hWnd )\n\t{\n\t\t//\n\t\t// compute width and height\n\t\t//\n\t\tr.left = 0;\n\t\tr.top = 0;\n\t\tr.right  = width;\n\t\tr.bottom = height;\n\n\t\tif ( cdsFullscreen || !Q_stricmp( _3DFX_DRIVER_NAME, drivername ) )\n\t\t{\n\t\t\texstyle = WS_EX_TOPMOST;\n\t\t\tstylebits = WS_POPUP|WS_VISIBLE|WS_SYSMENU;\n\t\t}\n\t\telse\n\t\t{\n\t\t\texstyle = 0;\n\t\t\tstylebits = WINDOW_STYLE|WS_SYSMENU;\n\t\t\tAdjustWindowRect (&r, stylebits, FALSE);\n\t\t}\n\n\t\tw = r.right - r.left;\n\t\th = r.bottom - r.top;\n\n\t\tif ( cdsFullscreen || !Q_stricmp( _3DFX_DRIVER_NAME, drivername ) )\n\t\t{\n\t\t\tx = 0;\n\t\t\ty = 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tvid_xpos = ri.Cvar_Get (\"vid_xpos\", \"\", 0);\n\t\t\tvid_ypos = ri.Cvar_Get (\"vid_ypos\", \"\", 0);\n\t\t\tx = vid_xpos->integer;\n\t\t\ty = vid_ypos->integer;\n\n\t\t\t// adjust window coordinates if necessary \n\t\t\t// so that the window is completely on screen\n\t\t\tif ( x < 0 )\n\t\t\t\tx = 0;\n\t\t\tif ( y < 0 )\n\t\t\t\ty = 0;\n\n\t\t\tif ( w < glw_state.desktopWidth &&\n\t\t\t\t h < glw_state.desktopHeight )\n\t\t\t{\n\t\t\t\tif ( x + w > glw_state.desktopWidth )\n\t\t\t\t\tx = ( glw_state.desktopWidth - w );\n\t\t\t\tif ( y + h > glw_state.desktopHeight )\n\t\t\t\t\ty = ( glw_state.desktopHeight - h );\n\t\t\t}\n\t\t}\n\n\t\tg_wv.hWnd = CreateWindowEx (\n\t\t\t exstyle, \n\t\t\t WINDOW_CLASS_NAME,\n\t\t\t \"Quake 3: Arena\",\n\t\t\t stylebits,\n\t\t\t x, y, w, h,\n\t\t\t NULL,\n\t\t\t NULL,\n\t\t\t g_wv.hInstance,\n\t\t\t NULL);\n\n\t\tif ( !g_wv.hWnd )\n\t\t{\n\t\t\tri.Error (ERR_FATAL, \"GLW_CreateWindow() - Couldn't create window\");\n\t\t}\n\t\n\t\tShowWindow( g_wv.hWnd, SW_SHOW );\n\t\tUpdateWindow( g_wv.hWnd );\n\t\tri.Printf( PRINT_ALL, \"...created window@%d,%d (%dx%d)\\n\", x, y, w, h );\n\t}\n\telse\n\t{\n\t\tri.Printf( PRINT_ALL, \"...window already present, CreateWindowEx skipped\\n\" );\n\t}\n\n\tif ( !GLW_InitDriver( drivername, colorbits ) )\n\t{\n\t\tShowWindow( g_wv.hWnd, SW_HIDE );\n\t\tDestroyWindow( g_wv.hWnd );\n\t\tg_wv.hWnd = NULL;\n\n\t\treturn qfalse;\n\t}\n\n\tSetForegroundWindow( g_wv.hWnd );\n\tSetFocus( g_wv.hWnd );\n\n\treturn qtrue;\n}\n\nstatic void PrintCDSError( int value )\n{\n\tswitch ( value )\n\t{\n\tcase DISP_CHANGE_RESTART:\n\t\tri.Printf( PRINT_ALL, \"restart required\\n\" );\n\t\tbreak;\n\tcase DISP_CHANGE_BADPARAM:\n\t\tri.Printf( PRINT_ALL, \"bad param\\n\" );\n\t\tbreak;\n\tcase DISP_CHANGE_BADFLAGS:\n\t\tri.Printf( PRINT_ALL, \"bad flags\\n\" );\n\t\tbreak;\n\tcase DISP_CHANGE_FAILED:\n\t\tri.Printf( PRINT_ALL, \"DISP_CHANGE_FAILED\\n\" );\n\t\tbreak;\n\tcase DISP_CHANGE_BADMODE:\n\t\tri.Printf( PRINT_ALL, \"bad mode\\n\" );\n\t\tbreak;\n\tcase DISP_CHANGE_NOTUPDATED:\n\t\tri.Printf( PRINT_ALL, \"not updated\\n\" );\n\t\tbreak;\n\tdefault:\n\t\tri.Printf( PRINT_ALL, \"unknown error %d\\n\", value );\n\t\tbreak;\n\t}\n}\n\n/*\n** GLW_SetMode\n*/\nstatic rserr_t GLW_SetMode( const char *drivername, \n\t\t\t\t\t\t    int mode, \n\t\t\t\t\t\t\tint colorbits, \n\t\t\t\t\t\t\tqboolean cdsFullscreen )\n{\n\tHDC hDC;\n\tconst char *win_fs[] = { \"W\", \"FS\" };\n\tint\t\tcdsRet;\n\tDEVMODE dm;\n\t\t\n\t//\n\t// print out informational messages\n\t//\n\tri.Printf( PRINT_ALL, \"...setting mode %d:\", mode );\n\tif ( !R_GetModeInfo( &glConfig.vidWidth, &glConfig.vidHeight, &glConfig.windowAspect, mode ) )\n\t{\n\t\tri.Printf( PRINT_ALL, \" invalid mode\\n\" );\n\t\treturn RSERR_INVALID_MODE;\n\t}\n\tri.Printf( PRINT_ALL, \" %d %d %s\\n\", glConfig.vidWidth, glConfig.vidHeight, win_fs[cdsFullscreen] );\n\n\t//\n\t// check our desktop attributes\n\t//\n\thDC = GetDC( GetDesktopWindow() );\n\tglw_state.desktopBitsPixel = GetDeviceCaps( hDC, BITSPIXEL );\n\tglw_state.desktopWidth = GetDeviceCaps( hDC, HORZRES );\n\tglw_state.desktopHeight = GetDeviceCaps( hDC, VERTRES );\n\tReleaseDC( GetDesktopWindow(), hDC );\n\n\t//\n\t// verify desktop bit depth\n\t//\n\tif ( glConfig.driverType != GLDRV_VOODOO )\n\t{\n\t\tif ( glw_state.desktopBitsPixel < 15 || glw_state.desktopBitsPixel == 24 )\n\t\t{\n\t\t\tif ( colorbits == 0 || ( !cdsFullscreen && colorbits >= 15 ) )\n\t\t\t{\n\t\t\t\tif ( MessageBox( NULL,\n\t\t\t\t\t\t\t\"It is highly unlikely that a correct\\n\"\n\t\t\t\t\t\t\t\"windowed display can be initialized with\\n\"\n\t\t\t\t\t\t\t\"the current desktop display depth.  Select\\n\"\n\t\t\t\t\t\t\t\"'OK' to try anyway.  Press 'Cancel' if you\\n\"\n\t\t\t\t\t\t\t\"have a 3Dfx Voodoo, Voodoo-2, or Voodoo Rush\\n\"\n\t\t\t\t\t\t\t\"3D accelerator installed, or if you otherwise\\n\"\n\t\t\t\t\t\t\t\"wish to quit.\",\n\t\t\t\t\t\t\t\"Low Desktop Color Depth\",\n\t\t\t\t\t\t\tMB_OKCANCEL | MB_ICONEXCLAMATION ) != IDOK )\n\t\t\t\t{\n\t\t\t\t\treturn RSERR_INVALID_MODE;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// do a CDS if needed\n\tif ( cdsFullscreen )\n\t{\n\t\tmemset( &dm, 0, sizeof( dm ) );\n\t\t\n\t\tdm.dmSize = sizeof( dm );\n\t\t\n\t\tdm.dmPelsWidth  = glConfig.vidWidth;\n\t\tdm.dmPelsHeight = glConfig.vidHeight;\n\t\tdm.dmFields     = DM_PELSWIDTH | DM_PELSHEIGHT;\n\n\t\tif ( r_displayRefresh->integer != 0 )\n\t\t{\n\t\t\tdm.dmDisplayFrequency = r_displayRefresh->integer;\n\t\t\tdm.dmFields |= DM_DISPLAYFREQUENCY;\n\t\t}\n\t\t\n\t\t// try to change color depth if possible\n\t\tif ( colorbits != 0 )\n\t\t{\n\t\t\tif ( glw_state.allowdisplaydepthchange )\n\t\t\t{\n\t\t\t\tdm.dmBitsPerPel = colorbits;\n\t\t\t\tdm.dmFields |= DM_BITSPERPEL;\n\t\t\t\tri.Printf( PRINT_ALL, \"...using colorsbits of %d\\n\", colorbits );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_ALL, \"WARNING:...changing depth not supported on Win95 < pre-OSR 2.x\\n\" );\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tri.Printf( PRINT_ALL, \"...using desktop display depth of %d\\n\", glw_state.desktopBitsPixel );\n\t\t}\n\n\t\t//\n\t\t// if we're already in fullscreen then just create the window\n\t\t//\n\t\tif ( glw_state.cdsFullscreen )\n\t\t{\n\t\t\tri.Printf( PRINT_ALL, \"...already fullscreen, avoiding redundant CDS\\n\" );\n\n\t\t\tif ( !GLW_CreateWindow ( drivername, glConfig.vidWidth, glConfig.vidHeight, colorbits, qtrue ) )\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_ALL, \"...restoring display settings\\n\" );\n\t\t\t\tChangeDisplaySettings( 0, 0 );\n\t\t\t\treturn RSERR_INVALID_MODE;\n\t\t\t}\n\t\t}\n\t\t//\n\t\t// need to call CDS\n\t\t//\n\t\telse\n\t\t{\n\t\t\tri.Printf( PRINT_ALL, \"...calling CDS: \" );\n\t\t\t\n\t\t\t// try setting the exact mode requested, because some drivers don't report\n\t\t\t// the low res modes in EnumDisplaySettings, but still work\n\t\t\tif ( ( cdsRet = ChangeDisplaySettings( &dm, CDS_FULLSCREEN ) ) == DISP_CHANGE_SUCCESSFUL )\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_ALL, \"ok\\n\" );\n\n\t\t\t\tif ( !GLW_CreateWindow ( drivername, glConfig.vidWidth, glConfig.vidHeight, colorbits, qtrue) )\n\t\t\t\t{\n\t\t\t\t\tri.Printf( PRINT_ALL, \"...restoring display settings\\n\" );\n\t\t\t\t\tChangeDisplaySettings( 0, 0 );\n\t\t\t\t\treturn RSERR_INVALID_MODE;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tglw_state.cdsFullscreen = qtrue;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t//\n\t\t\t\t// the exact mode failed, so scan EnumDisplaySettings for the next largest mode\n\t\t\t\t//\n\t\t\t\tDEVMODE\t\tdevmode;\n\t\t\t\tint\t\t\tmodeNum;\n\n\t\t\t\tri.Printf( PRINT_ALL, \"failed, \" );\n\t\t\t\t\n\t\t\t\tPrintCDSError( cdsRet );\n\t\t\t\n\t\t\t\tri.Printf( PRINT_ALL, \"...trying next higher resolution:\" );\n\t\t\t\t\n\t\t\t\t// we could do a better matching job here...\n\t\t\t\tfor ( modeNum = 0 ; ; modeNum++ ) {\n\t\t\t\t\tif ( !EnumDisplaySettings( NULL, modeNum, &devmode ) ) {\n\t\t\t\t\t\tmodeNum = -1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif ( devmode.dmPelsWidth >= glConfig.vidWidth\n\t\t\t\t\t\t&& devmode.dmPelsHeight >= glConfig.vidHeight\n\t\t\t\t\t\t&& devmode.dmBitsPerPel >= 15 ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( modeNum != -1 && ( cdsRet = ChangeDisplaySettings( &devmode, CDS_FULLSCREEN ) ) == DISP_CHANGE_SUCCESSFUL )\n\t\t\t\t{\n\t\t\t\t\tri.Printf( PRINT_ALL, \" ok\\n\" );\n\t\t\t\t\tif ( !GLW_CreateWindow( drivername, glConfig.vidWidth, glConfig.vidHeight, colorbits, qtrue) )\n\t\t\t\t\t{\n\t\t\t\t\t\tri.Printf( PRINT_ALL, \"...restoring display settings\\n\" );\n\t\t\t\t\t\tChangeDisplaySettings( 0, 0 );\n\t\t\t\t\t\treturn RSERR_INVALID_MODE;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tglw_state.cdsFullscreen = qtrue;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tri.Printf( PRINT_ALL, \" failed, \" );\n\t\t\t\t\t\n\t\t\t\t\tPrintCDSError( cdsRet );\n\t\t\t\t\t\n\t\t\t\t\tri.Printf( PRINT_ALL, \"...restoring display settings\\n\" );\n\t\t\t\t\tChangeDisplaySettings( 0, 0 );\n\t\t\t\t\t\n\t\t\t\t\tglw_state.cdsFullscreen = qfalse;\n\t\t\t\t\tglConfig.isFullscreen = qfalse;\n\t\t\t\t\tif ( !GLW_CreateWindow( drivername, glConfig.vidWidth, glConfig.vidHeight, colorbits, qfalse) )\n\t\t\t\t\t{\n\t\t\t\t\t\treturn RSERR_INVALID_MODE;\n\t\t\t\t\t}\n\t\t\t\t\treturn RSERR_INVALID_FULLSCREEN;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tif ( glw_state.cdsFullscreen )\n\t\t{\n\t\t\tChangeDisplaySettings( 0, 0 );\n\t\t}\n\n\t\tglw_state.cdsFullscreen = qfalse;\n\t\tif ( !GLW_CreateWindow( drivername, glConfig.vidWidth, glConfig.vidHeight, colorbits, qfalse ) )\n\t\t{\n\t\t\treturn RSERR_INVALID_MODE;\n\t\t}\n\t}\n\n\t//\n\t// success, now check display frequency, although this won't be valid on Voodoo(2)\n\t//\n\tmemset( &dm, 0, sizeof( dm ) );\n\tdm.dmSize = sizeof( dm );\n\tif ( EnumDisplaySettings( NULL, ENUM_CURRENT_SETTINGS, &dm ) )\n\t{\n\t\tglConfig.displayFrequency = dm.dmDisplayFrequency;\n\t}\n\n\t// NOTE: this is overridden later on standalone 3Dfx drivers\n\tglConfig.isFullscreen = cdsFullscreen;\n\n\treturn RSERR_OK;\n}\n\n/*\n** GLW_InitExtensions\n*/\nstatic void GLW_InitExtensions( void )\n{\n\tif ( !r_allowExtensions->integer )\n\t{\n\t\tri.Printf( PRINT_ALL, \"*** IGNORING OPENGL EXTENSIONS ***\\n\" );\n\t\treturn;\n\t}\n\n\tri.Printf( PRINT_ALL, \"Initializing OpenGL extensions\\n\" );\n\n\t// GL_S3_s3tc\n\tglConfig.textureCompression = TC_NONE;\n\tif ( strstr( glConfig.extensions_string, \"GL_S3_s3tc\" ) )\n\t{\n\t\tif ( r_ext_compressed_textures->integer )\n\t\t{\n\t\t\tglConfig.textureCompression = TC_S3TC;\n\t\t\tri.Printf( PRINT_ALL, \"...using GL_S3_s3tc\\n\" );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tglConfig.textureCompression = TC_NONE;\n\t\t\tri.Printf( PRINT_ALL, \"...ignoring GL_S3_s3tc\\n\" );\n\t\t}\n\t}\n\telse\n\t{\n\t\tri.Printf( PRINT_ALL, \"...GL_S3_s3tc not found\\n\" );\n\t}\n\n\t// GL_EXT_texture_env_add\n\tglConfig.textureEnvAddAvailable = qfalse;\n\tif ( strstr( glConfig.extensions_string, \"EXT_texture_env_add\" ) )\n\t{\n\t\tif ( r_ext_texture_env_add->integer )\n\t\t{\n\t\t\tglConfig.textureEnvAddAvailable = qtrue;\n\t\t\tri.Printf( PRINT_ALL, \"...using GL_EXT_texture_env_add\\n\" );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tglConfig.textureEnvAddAvailable = qfalse;\n\t\t\tri.Printf( PRINT_ALL, \"...ignoring GL_EXT_texture_env_add\\n\" );\n\t\t}\n\t}\n\telse\n\t{\n\t\tri.Printf( PRINT_ALL, \"...GL_EXT_texture_env_add not found\\n\" );\n\t}\n\n\t// WGL_EXT_swap_control\n\tqwglSwapIntervalEXT = ( BOOL (WINAPI *)(int)) qwglGetProcAddress( \"wglSwapIntervalEXT\" );\n\tif ( qwglSwapIntervalEXT )\n\t{\n\t\tri.Printf( PRINT_ALL, \"...using WGL_EXT_swap_control\\n\" );\n\t\tr_swapInterval->modified = qtrue;\t// force a set next frame\n\t}\n\telse\n\t{\n\t\tri.Printf( PRINT_ALL, \"...WGL_EXT_swap_control not found\\n\" );\n\t}\n\n\t// GL_ARB_multitexture\n\tqglMultiTexCoord2fARB = NULL;\n\tqglActiveTextureARB = NULL;\n\tqglClientActiveTextureARB = NULL;\n\tif ( strstr( glConfig.extensions_string, \"GL_ARB_multitexture\" )  )\n\t{\n\t\tif ( r_ext_multitexture->integer )\n\t\t{\n\t\t\tqglMultiTexCoord2fARB = ( PFNGLMULTITEXCOORD2FARBPROC ) qwglGetProcAddress( \"glMultiTexCoord2fARB\" );\n\t\t\tqglActiveTextureARB = ( PFNGLACTIVETEXTUREARBPROC ) qwglGetProcAddress( \"glActiveTextureARB\" );\n\t\t\tqglClientActiveTextureARB = ( PFNGLCLIENTACTIVETEXTUREARBPROC ) qwglGetProcAddress( \"glClientActiveTextureARB\" );\n\n\t\t\tif ( qglActiveTextureARB )\n\t\t\t{\n\t\t\t\tqglGetIntegerv( GL_MAX_ACTIVE_TEXTURES_ARB, &glConfig.maxActiveTextures );\n\n\t\t\t\tif ( glConfig.maxActiveTextures > 1 )\n\t\t\t\t{\n\t\t\t\t\tri.Printf( PRINT_ALL, \"...using GL_ARB_multitexture\\n\" );\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tqglMultiTexCoord2fARB = NULL;\n\t\t\t\t\tqglActiveTextureARB = NULL;\n\t\t\t\t\tqglClientActiveTextureARB = NULL;\n\t\t\t\t\tri.Printf( PRINT_ALL, \"...not using GL_ARB_multitexture, < 2 texture units\\n\" );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tri.Printf( PRINT_ALL, \"...ignoring GL_ARB_multitexture\\n\" );\n\t\t}\n\t}\n\telse\n\t{\n\t\tri.Printf( PRINT_ALL, \"...GL_ARB_multitexture not found\\n\" );\n\t}\n\n\t// GL_EXT_compiled_vertex_array\n\tqglLockArraysEXT = NULL;\n\tqglUnlockArraysEXT = NULL;\n\tif ( strstr( glConfig.extensions_string, \"GL_EXT_compiled_vertex_array\" ) && ( glConfig.hardwareType != GLHW_RIVA128 ) )\n\t{\n\t\tif ( r_ext_compiled_vertex_array->integer )\n\t\t{\n\t\t\tri.Printf( PRINT_ALL, \"...using GL_EXT_compiled_vertex_array\\n\" );\n\t\t\tqglLockArraysEXT = ( void ( APIENTRY * )( int, int ) ) qwglGetProcAddress( \"glLockArraysEXT\" );\n\t\t\tqglUnlockArraysEXT = ( void ( APIENTRY * )( void ) ) qwglGetProcAddress( \"glUnlockArraysEXT\" );\n\t\t\tif (!qglLockArraysEXT || !qglUnlockArraysEXT) {\n\t\t\t\tri.Error (ERR_FATAL, \"bad getprocaddress\");\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tri.Printf( PRINT_ALL, \"...ignoring GL_EXT_compiled_vertex_array\\n\" );\n\t\t}\n\t}\n\telse\n\t{\n\t\tri.Printf( PRINT_ALL, \"...GL_EXT_compiled_vertex_array not found\\n\" );\n\t}\n\n\t// WGL_3DFX_gamma_control\n\tqwglGetDeviceGammaRamp3DFX = NULL;\n\tqwglSetDeviceGammaRamp3DFX = NULL;\n\n\tif ( strstr( glConfig.extensions_string, \"WGL_3DFX_gamma_control\" ) )\n\t{\n\t\tif ( !r_ignorehwgamma->integer && r_ext_gamma_control->integer )\n\t\t{\n\t\t\tqwglGetDeviceGammaRamp3DFX = ( BOOL ( WINAPI * )( HDC, LPVOID ) ) qwglGetProcAddress( \"wglGetDeviceGammaRamp3DFX\" );\n\t\t\tqwglSetDeviceGammaRamp3DFX = ( BOOL ( WINAPI * )( HDC, LPVOID ) ) qwglGetProcAddress( \"wglSetDeviceGammaRamp3DFX\" );\n\n\t\t\tif ( qwglGetDeviceGammaRamp3DFX && qwglSetDeviceGammaRamp3DFX )\n\t\t\t{\n\t\t\t\tri.Printf( PRINT_ALL, \"...using WGL_3DFX_gamma_control\\n\" );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tqwglGetDeviceGammaRamp3DFX = NULL;\n\t\t\t\tqwglSetDeviceGammaRamp3DFX = NULL;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tri.Printf( PRINT_ALL, \"...ignoring WGL_3DFX_gamma_control\\n\" );\n\t\t}\n\t}\n\telse\n\t{\n\t\tri.Printf( PRINT_ALL, \"...WGL_3DFX_gamma_control not found\\n\" );\n\t}\n}\n\n/*\n** GLW_CheckOSVersion\n*/\nstatic qboolean GLW_CheckOSVersion( void )\n{\n#define OSR2_BUILD_NUMBER 1111\n\n\tOSVERSIONINFO\tvinfo;\n\n\tvinfo.dwOSVersionInfoSize = sizeof(vinfo);\n\n\tglw_state.allowdisplaydepthchange = qfalse;\n\n\tif ( GetVersionEx( &vinfo) )\n\t{\n\t\tif ( vinfo.dwMajorVersion > 4 )\n\t\t{\n\t\t\tglw_state.allowdisplaydepthchange = qtrue;\n\t\t}\n\t\telse if ( vinfo.dwMajorVersion == 4 )\n\t\t{\n\t\t\tif ( vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT )\n\t\t\t{\n\t\t\t\tglw_state.allowdisplaydepthchange = qtrue;\n\t\t\t}\n\t\t\telse if ( vinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS )\n\t\t\t{\n\t\t\t\tif ( LOWORD( vinfo.dwBuildNumber ) >= OSR2_BUILD_NUMBER )\n\t\t\t\t{\n\t\t\t\t\tglw_state.allowdisplaydepthchange = qtrue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tri.Printf( PRINT_ALL, \"GLW_CheckOSVersion() - GetVersionEx failed\\n\" );\n\t\treturn qfalse;\n\t}\n\n\treturn qtrue;\n}\n\n/*\n** GLW_LoadOpenGL\n**\n** GLimp_win.c internal function that attempts to load and use \n** a specific OpenGL DLL.\n*/\nstatic qboolean GLW_LoadOpenGL( const char *drivername )\n{\n\tchar buffer[1024];\n\tqboolean cdsFullscreen;\n\n\tQ_strncpyz( buffer, drivername, sizeof(buffer) );\n\tQ_strlwr(buffer);\n\n\t//\n\t// determine if we're on a standalone driver\n\t//\n\tif ( strstr( buffer, \"opengl32\" ) != 0 || r_maskMinidriver->integer )\n\t{\n\t\tglConfig.driverType = GLDRV_ICD;\n\t}\n\telse\n\t{\n\t\tglConfig.driverType = GLDRV_STANDALONE;\n\n\t\tri.Printf( PRINT_ALL, \"...assuming '%s' is a standalone driver\\n\", drivername );\n\n\t\tif ( strstr( buffer, _3DFX_DRIVER_NAME ) )\n\t\t{\n\t\t\tglConfig.driverType = GLDRV_VOODOO;\n\t\t}\n\t}\n\n\t// disable the 3Dfx splash screen\n\t_putenv(\"FX_GLIDE_NO_SPLASH=0\");\n\n\t//\n\t// load the driver and bind our function pointers to it\n\t// \n\tif ( QGL_Init( buffer ) ) \n\t{\n\t\tcdsFullscreen = r_fullscreen->integer;\n\n\t\t// create the window and set up the context\n\t\tif ( !GLW_StartDriverAndSetMode( drivername, r_mode->integer, r_colorbits->integer, cdsFullscreen ) )\n\t\t{\n\t\t\t// if we're on a 24/32-bit desktop and we're going fullscreen on an ICD,\n\t\t\t// try it again but with a 16-bit desktop\n\t\t\tif ( glConfig.driverType == GLDRV_ICD )\n\t\t\t{\n\t\t\t\tif ( r_colorbits->integer != 16 ||\n\t\t\t\t\t cdsFullscreen != qtrue ||\n\t\t\t\t\t r_mode->integer != 3 )\n\t\t\t\t{\n\t\t\t\t\tif ( !GLW_StartDriverAndSetMode( drivername, 3, 16, qtrue ) )\n\t\t\t\t\t{\n\t\t\t\t\t\tgoto fail;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n\n\t\tif ( glConfig.driverType == GLDRV_VOODOO )\n\t\t{\n\t\t\tglConfig.isFullscreen = qtrue;\n\t\t}\n\n\t\treturn qtrue;\n\t}\nfail:\n\n\tQGL_Shutdown();\n\n\treturn qfalse;\n}\n\n/*\n** GLimp_EndFrame\n*/\nvoid GLimp_EndFrame (void)\n{\n\t//\n\t// swapinterval stuff\n\t//\n\tif ( r_swapInterval->modified ) {\n\t\tr_swapInterval->modified = qfalse;\n\n\t\tif ( !glConfig.stereoEnabled ) {\t// why?\n\t\t\tif ( qwglSwapIntervalEXT ) {\n\t\t\t\tqwglSwapIntervalEXT( r_swapInterval->integer );\n\t\t\t}\n\t\t}\n\t}\n\n\n\t// don't flip if drawing to front buffer\n\tif ( Q_stricmp( r_drawBuffer->string, \"GL_FRONT\" ) != 0 )\n\t{\n\t\tif ( glConfig.driverType > GLDRV_ICD )\n\t\t{\n\t\t\tif ( !qwglSwapBuffers( glw_state.hDC ) )\n\t\t\t{\n\t\t\t\tri.Error( ERR_FATAL, \"GLimp_EndFrame() - SwapBuffers() failed!\\n\" );\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tSwapBuffers( glw_state.hDC );\n\t\t}\n\t}\n\n\t// check logging\n\tQGL_EnableLogging( r_logFile->integer );\n}\n\nstatic void GLW_StartOpenGL( void )\n{\n\tqboolean attemptedOpenGL32 = qfalse;\n\tqboolean attempted3Dfx = qfalse;\n\n\t//\n\t// load and initialize the specific OpenGL driver\n\t//\n\tif ( !GLW_LoadOpenGL( r_glDriver->string ) )\n\t{\n\t\tif ( !Q_stricmp( r_glDriver->string, OPENGL_DRIVER_NAME ) )\n\t\t{\n\t\t\tattemptedOpenGL32 = qtrue;\n\t\t}\n\t\telse if ( !Q_stricmp( r_glDriver->string, _3DFX_DRIVER_NAME ) )\n\t\t{\n\t\t\tattempted3Dfx = qtrue;\n\t\t}\n\n\t\tif ( !attempted3Dfx )\n\t\t{\n\t\t\tattempted3Dfx = qtrue;\n\t\t\tif ( GLW_LoadOpenGL( _3DFX_DRIVER_NAME ) )\n\t\t\t{\n\t\t\t\tri.Cvar_Set( \"r_glDriver\", _3DFX_DRIVER_NAME );\n\t\t\t\tr_glDriver->modified = qfalse;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif ( !attemptedOpenGL32 )\n\t\t\t\t{\n\t\t\t\t\tif ( !GLW_LoadOpenGL( OPENGL_DRIVER_NAME ) )\n\t\t\t\t\t{\n\t\t\t\t\t\tri.Error( ERR_FATAL, \"GLW_StartOpenGL() - could not load OpenGL subsystem\\n\" );\n\t\t\t\t\t}\n\t\t\t\t\tri.Cvar_Set( \"r_glDriver\", OPENGL_DRIVER_NAME );\n\t\t\t\t\tr_glDriver->modified = qfalse;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tri.Error( ERR_FATAL, \"GLW_StartOpenGL() - could not load OpenGL subsystem\\n\" );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if ( !attemptedOpenGL32 )\n\t\t{\n\t\t\tattemptedOpenGL32 = qtrue;\n\t\t\tif ( GLW_LoadOpenGL( OPENGL_DRIVER_NAME ) )\n\t\t\t{\n\t\t\t\tri.Cvar_Set( \"r_glDriver\", OPENGL_DRIVER_NAME );\n\t\t\t\tr_glDriver->modified = qfalse;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tri.Error( ERR_FATAL, \"GLW_StartOpenGL() - could not load OpenGL subsystem\\n\" );\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n** GLimp_Init\n**\n** This is the platform specific OpenGL initialization function.  It\n** is responsible for loading OpenGL, initializing it, setting\n** extensions, creating a window of the appropriate size, doing\n** fullscreen manipulations, etc.  Its overall responsibility is\n** to make sure that a functional OpenGL subsystem is operating\n** when it returns to the ref.\n*/\nvoid GLimp_Init( void )\n{\n\tchar\tbuf[1024];\n\tcvar_t *lastValidRenderer = ri.Cvar_Get( \"r_lastValidRenderer\", \"(uninitialized)\", CVAR_ARCHIVE );\n\tcvar_t\t*cv;\n\n\tri.Printf( PRINT_ALL, \"Initializing OpenGL subsystem\\n\" );\n\n\t//\n\t// check OS version to see if we can do fullscreen display changes\n\t//\n\tif ( !GLW_CheckOSVersion() )\n\t{\n\t\tri.Error( ERR_FATAL, \"GLimp_Init() - incorrect operating system\\n\" );\n\t}\n\n\t// save off hInstance and wndproc\n\tcv = ri.Cvar_Get( \"win_hinstance\", \"\", 0 );\n\tsscanf( cv->string, \"%i\", (int *)&g_wv.hInstance );\n\n\tcv = ri.Cvar_Get( \"win_wndproc\", \"\", 0 );\n\tsscanf( cv->string, \"%i\", (int *)&glw_state.wndproc );\n\n\tr_allowSoftwareGL = ri.Cvar_Get( \"r_allowSoftwareGL\", \"0\", CVAR_LATCH );\n\tr_maskMinidriver = ri.Cvar_Get( \"r_maskMinidriver\", \"0\", CVAR_LATCH );\n\n\t// load appropriate DLL and initialize subsystem\n\tGLW_StartOpenGL();\n\n\t// get our config strings\n\tQ_strncpyz( glConfig.vendor_string, qglGetString (GL_VENDOR), sizeof( glConfig.vendor_string ) );\n\tQ_strncpyz( glConfig.renderer_string, qglGetString (GL_RENDERER), sizeof( glConfig.renderer_string ) );\n\tQ_strncpyz( glConfig.version_string, qglGetString (GL_VERSION), sizeof( glConfig.version_string ) );\n\tQ_strncpyz( glConfig.extensions_string, qglGetString (GL_EXTENSIONS), sizeof( glConfig.extensions_string ) );\n\n\t//\n\t// chipset specific configuration\n\t//\n\tQ_strncpyz( buf, glConfig.renderer_string, sizeof(buf) );\n\tQ_strlwr( buf );\n\n\t//\n\t// NOTE: if changing cvars, do it within this block.  This allows them\n\t// to be overridden when testing driver fixes, etc. but only sets\n\t// them to their default state when the hardware is first installed/run.\n\t//\n\tif ( Q_stricmp( lastValidRenderer->string, glConfig.renderer_string ) )\n\t{\n\t\tglConfig.hardwareType = GLHW_GENERIC;\n\n\t\tri.Cvar_Set( \"r_textureMode\", \"GL_LINEAR_MIPMAP_NEAREST\" );\n\n\t\t// VOODOO GRAPHICS w/ 2MB\n\t\tif ( strstr( buf, \"voodoo graphics/1 tmu/2 mb\" ) )\n\t\t{\n\t\t\tri.Cvar_Set( \"r_picmip\", \"2\" );\n\t\t\tri.Cvar_Get( \"r_picmip\", \"1\", CVAR_ARCHIVE | CVAR_LATCH );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tri.Cvar_Set( \"r_picmip\", \"1\" );\n\n\t\t\tif ( strstr( buf, \"rage 128\" ) || strstr( buf, \"rage128\" ) )\n\t\t\t{\n\t\t\t\tri.Cvar_Set( \"r_finish\", \"0\" );\n\t\t\t}\n\t\t\t// Savage3D and Savage4 should always have trilinear enabled\n\t\t\telse if ( strstr( buf, \"savage3d\" ) || strstr( buf, \"s3 savage4\" ) )\n\t\t\t{\n\t\t\t\tri.Cvar_Set( \"r_texturemode\", \"GL_LINEAR_MIPMAP_LINEAR\" );\n\t\t\t}\n\t\t}\n\t}\n\t\n\t//\n\t// this is where hardware specific workarounds that should be\n\t// detected/initialized every startup should go.\n\t//\n\tif ( strstr( buf, \"banshee\" ) || strstr( buf, \"voodoo3\" ) )\n\t{\n\t\tglConfig.hardwareType = GLHW_3DFX_2D3D;\n\t}\n\t// VOODOO GRAPHICS w/ 2MB\n\telse if ( strstr( buf, \"voodoo graphics/1 tmu/2 mb\" ) )\n\t{\n\t}\n\telse if ( strstr( buf, \"glzicd\" ) )\n\t{\n\t}\n\telse if ( strstr( buf, \"rage pro\" ) || strstr( buf, \"Rage Pro\" ) || strstr( buf, \"ragepro\" ) )\n\t{\n\t\tglConfig.hardwareType = GLHW_RAGEPRO;\n\t}\n\telse if ( strstr( buf, \"rage 128\" ) )\n\t{\n\t}\n\telse if ( strstr( buf, \"permedia2\" ) )\n\t{\n\t\tglConfig.hardwareType = GLHW_PERMEDIA2;\n\t}\n\telse if ( strstr( buf, \"riva 128\" ) )\n\t{\n\t\tglConfig.hardwareType = GLHW_RIVA128;\n\t}\n\telse if ( strstr( buf, \"riva tnt \" ) )\n\t{\n\t}\n\n\tri.Cvar_Set( \"r_lastValidRenderer\", glConfig.renderer_string );\n\n\tGLW_InitExtensions();\n\tWG_CheckHardwareGamma();\n}\n\n/*\n** GLimp_Shutdown\n**\n** This routine does all OS specific shutdown procedures for the OpenGL\n** subsystem.\n*/\nvoid GLimp_Shutdown( void )\n{\n//\tconst char *strings[] = { \"soft\", \"hard\" };\n\tconst char *success[] = { \"failed\", \"success\" };\n\tint retVal;\n\n\t// FIXME: Brian, we need better fallbacks from partially initialized failures\n\tif ( !qwglMakeCurrent ) {\n\t\treturn;\n\t}\n\n\tri.Printf( PRINT_ALL, \"Shutting down OpenGL subsystem\\n\" );\n\n\t// restore gamma.  We do this first because 3Dfx's extension needs a valid OGL subsystem\n\tWG_RestoreGamma();\n\n\t// set current context to NULL\n\tif ( qwglMakeCurrent )\n\t{\n\t\tretVal = qwglMakeCurrent( NULL, NULL ) != 0;\n\n\t\tri.Printf( PRINT_ALL, \"...wglMakeCurrent( NULL, NULL ): %s\\n\", success[retVal] );\n\t}\n\n\t// delete HGLRC\n\tif ( glw_state.hGLRC )\n\t{\n\t\tretVal = qwglDeleteContext( glw_state.hGLRC ) != 0;\n\t\tri.Printf( PRINT_ALL, \"...deleting GL context: %s\\n\", success[retVal] );\n\t\tglw_state.hGLRC = NULL;\n\t}\n\n\t// release DC\n\tif ( glw_state.hDC )\n\t{\n\t\tretVal = ReleaseDC( g_wv.hWnd, glw_state.hDC ) != 0;\n\t\tri.Printf( PRINT_ALL, \"...releasing DC: %s\\n\", success[retVal] );\n\t\tglw_state.hDC   = NULL;\n\t}\n\n\t// destroy window\n\tif ( g_wv.hWnd )\n\t{\n\t\tri.Printf( PRINT_ALL, \"...destroying window\\n\" );\n\t\tShowWindow( g_wv.hWnd, SW_HIDE );\n\t\tDestroyWindow( g_wv.hWnd );\n\t\tg_wv.hWnd = NULL;\n\t\tglw_state.pixelFormatSet = qfalse;\n\t}\n\n\t// close the r_logFile\n\tif ( glw_state.log_fp )\n\t{\n\t\tfclose( glw_state.log_fp );\n\t\tglw_state.log_fp = 0;\n\t}\n\n\t// reset display settings\n\tif ( glw_state.cdsFullscreen )\n\t{\n\t\tri.Printf( PRINT_ALL, \"...resetting display\\n\" );\n\t\tChangeDisplaySettings( 0, 0 );\n\t\tglw_state.cdsFullscreen = qfalse;\n\t}\n\n\t// shutdown QGL subsystem\n\tQGL_Shutdown();\n\n\tmemset( &glConfig, 0, sizeof( glConfig ) );\n\tmemset( &glState, 0, sizeof( glState ) );\n}\n\n/*\n** GLimp_LogComment\n*/\nvoid GLimp_LogComment( char *comment ) \n{\n\tif ( glw_state.log_fp ) {\n\t\tfprintf( glw_state.log_fp, \"%s\", comment );\n\t}\n}\n\n\n/*\n===========================================================\n\nSMP acceleration\n\n===========================================================\n*/\n\nHANDLE\trenderCommandsEvent;\nHANDLE\trenderCompletedEvent;\nHANDLE\trenderActiveEvent;\n\nvoid (*glimpRenderThread)( void );\n\nvoid GLimp_RenderThreadWrapper( void ) {\n\tglimpRenderThread();\n\n\t// unbind the context before we die\n\tqwglMakeCurrent( glw_state.hDC, NULL );\n}\n\n/*\n=======================\nGLimp_SpawnRenderThread\n=======================\n*/\nHANDLE\trenderThreadHandle;\nint\t\trenderThreadId;\nqboolean GLimp_SpawnRenderThread( void (*function)( void ) ) {\n\n\trenderCommandsEvent = CreateEvent( NULL, TRUE, FALSE, NULL );\n\trenderCompletedEvent = CreateEvent( NULL, TRUE, FALSE, NULL );\n\trenderActiveEvent = CreateEvent( NULL, TRUE, FALSE, NULL );\n\n\tglimpRenderThread = function;\n\n\trenderThreadHandle = CreateThread(\n\t   NULL,\t// LPSECURITY_ATTRIBUTES lpsa,\n\t   0,\t\t// DWORD cbStack,\n\t   (LPTHREAD_START_ROUTINE)GLimp_RenderThreadWrapper,\t// LPTHREAD_START_ROUTINE lpStartAddr,\n\t   0,\t\t\t// LPVOID lpvThreadParm,\n\t   0,\t\t\t//   DWORD fdwCreate,\n\t   &renderThreadId );\n\n\tif ( !renderThreadHandle ) {\n\t\treturn qfalse;\n\t}\n\n\treturn qtrue;\n}\n\nstatic\tvoid\t*smpData;\nstatic\tint\t\twglErrors;\n\nvoid *GLimp_RendererSleep( void ) {\n\tvoid\t*data;\n\n\tif ( !qwglMakeCurrent( glw_state.hDC, NULL ) ) {\n\t\twglErrors++;\n\t}\n\n\tResetEvent( renderActiveEvent );\n\n\t// after this, the front end can exit GLimp_FrontEndSleep\n\tSetEvent( renderCompletedEvent );\n\n\tWaitForSingleObject( renderCommandsEvent, INFINITE );\n\n\tif ( !qwglMakeCurrent( glw_state.hDC, glw_state.hGLRC ) ) {\n\t\twglErrors++;\n\t}\n\n\tResetEvent( renderCompletedEvent );\n\tResetEvent( renderCommandsEvent );\n\n\tdata = smpData;\n\n\t// after this, the main thread can exit GLimp_WakeRenderer\n\tSetEvent( renderActiveEvent );\n\n\treturn data;\n}\n\n\nvoid GLimp_FrontEndSleep( void ) {\n\tWaitForSingleObject( renderCompletedEvent, INFINITE );\n\n\tif ( !qwglMakeCurrent( glw_state.hDC, glw_state.hGLRC ) ) {\n\t\twglErrors++;\n\t}\n}\n\n\nvoid GLimp_WakeRenderer( void *data ) {\n\tsmpData = data;\n\n\tif ( !qwglMakeCurrent( glw_state.hDC, NULL ) ) {\n\t\twglErrors++;\n\t}\n\n\t// after this, the renderer can continue through GLimp_RendererSleep\n\tSetEvent( renderCommandsEvent );\n\n\tWaitForSingleObject( renderActiveEvent, INFINITE );\n}\n\n"
  },
  {
    "path": "code/win32/win_input.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// win_input.c -- win32 mouse and joystick code\n// 02/21/97 JCB Added extended DirectInput code to support external controllers.\n\n#include \"../client/client.h\"\n#include \"win_local.h\"\n\n\ntypedef struct {\n\tint\t\t\toldButtonState;\n\n\tqboolean\tmouseActive;\n\tqboolean\tmouseInitialized;\n  qboolean  mouseStartupDelayed; // delay mouse init to try DI again when we have a window\n} WinMouseVars_t;\n\nstatic WinMouseVars_t s_wmv;\n\nstatic int\twindow_center_x, window_center_y;\n\n//\n// MIDI definitions\n//\nstatic void IN_StartupMIDI( void );\nstatic void IN_ShutdownMIDI( void );\n\n#define MAX_MIDIIN_DEVICES\t8\n\ntypedef struct {\n\tint\t\t\tnumDevices;\n\tMIDIINCAPS\tcaps[MAX_MIDIIN_DEVICES];\n\n\tHMIDIIN\t\thMidiIn;\n} MidiInfo_t;\n\nstatic MidiInfo_t s_midiInfo;\n\n//\n// Joystick definitions\n//\n#define\tJOY_MAX_AXES\t\t6\t\t\t\t// X, Y, Z, R, U, V\n\ntypedef struct {\n\tqboolean\tavail;\n\tint\t\t\tid;\t\t\t// joystick number\n\tJOYCAPS\t\tjc;\n\n\tint\t\t\toldbuttonstate;\n\tint\t\t\toldpovstate;\n\n\tJOYINFOEX\tji;\n} joystickInfo_t;\n\nstatic\tjoystickInfo_t\tjoy;\n\n\n\ncvar_t\t*in_midi;\ncvar_t\t*in_midiport;\ncvar_t\t*in_midichannel;\ncvar_t\t*in_mididevice;\n\ncvar_t\t*in_mouse;\ncvar_t  *in_logitechbug;\ncvar_t\t*in_joystick;\ncvar_t\t*in_joyBallScale;\ncvar_t\t*in_debugJoystick;\ncvar_t\t*joy_threshold;\n\nqboolean\tin_appactive;\n\n// forward-referenced functions\nvoid IN_StartupJoystick (void);\nvoid IN_JoyMove(void);\n\nstatic void MidiInfo_f( void );\n\n/*\n============================================================\n\nWIN32 MOUSE CONTROL\n\n============================================================\n*/\n\n/*\n================\nIN_InitWin32Mouse\n================\n*/\nvoid IN_InitWin32Mouse( void ) \n{\n}\n\n/*\n================\nIN_ShutdownWin32Mouse\n================\n*/\nvoid IN_ShutdownWin32Mouse( void ) {\n}\n\n/*\n================\nIN_ActivateWin32Mouse\n================\n*/\nvoid IN_ActivateWin32Mouse( void ) {\n\tint\t\t\twidth, height;\n\tRECT\t\twindow_rect;\n\n\twidth = GetSystemMetrics (SM_CXSCREEN);\n\theight = GetSystemMetrics (SM_CYSCREEN);\n\n\tGetWindowRect ( g_wv.hWnd, &window_rect);\n\tif (window_rect.left < 0)\n\t\twindow_rect.left = 0;\n\tif (window_rect.top < 0)\n\t\twindow_rect.top = 0;\n\tif (window_rect.right >= width)\n\t\twindow_rect.right = width-1;\n\tif (window_rect.bottom >= height-1)\n\t\twindow_rect.bottom = height-1;\n\twindow_center_x = (window_rect.right + window_rect.left)/2;\n\twindow_center_y = (window_rect.top + window_rect.bottom)/2;\n\n\tSetCursorPos (window_center_x, window_center_y);\n\n\tSetCapture ( g_wv.hWnd );\n\tClipCursor (&window_rect);\n\twhile (ShowCursor (FALSE) >= 0)\n\t\t;\n}\n\n/*\n================\nIN_DeactivateWin32Mouse\n================\n*/\nvoid IN_DeactivateWin32Mouse( void ) \n{\n\tClipCursor (NULL);\n\tReleaseCapture ();\n\twhile (ShowCursor (TRUE) < 0)\n\t\t;\n}\n\n/*\n================\nIN_Win32Mouse\n================\n*/\nvoid IN_Win32Mouse( int *mx, int *my ) {\n\tPOINT\t\tcurrent_pos;\n\n\t// find mouse movement\n\tGetCursorPos (&current_pos);\n\n\t// force the mouse to the center, so there's room to move\n\tSetCursorPos (window_center_x, window_center_y);\n\n\t*mx = current_pos.x - window_center_x;\n\t*my = current_pos.y - window_center_y;\n}\n\n\n/*\n============================================================\n\nDIRECT INPUT MOUSE CONTROL\n\n============================================================\n*/\n\n#undef DEFINE_GUID\n\n#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \\\n        EXTERN_C const GUID name \\\n                = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }\n\nDEFINE_GUID(GUID_SysMouse,   0x6F1D2B60,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);\nDEFINE_GUID(GUID_XAxis,   0xA36D02E0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);\nDEFINE_GUID(GUID_YAxis,   0xA36D02E1,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);\nDEFINE_GUID(GUID_ZAxis,   0xA36D02E2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);\n\n\n#define DINPUT_BUFFERSIZE           16\n#define iDirectInputCreate(a,b,c,d)\tpDirectInputCreate(a,b,c,d)\n\nHRESULT (WINAPI *pDirectInputCreate)(HINSTANCE hinst, DWORD dwVersion,\n\tLPDIRECTINPUT * lplpDirectInput, LPUNKNOWN punkOuter);\n\nstatic HINSTANCE hInstDI;\n\ntypedef struct MYDATA {\n\tLONG  lX;                   // X axis goes here\n\tLONG  lY;                   // Y axis goes here\n\tLONG  lZ;                   // Z axis goes here\n\tBYTE  bButtonA;             // One button goes here\n\tBYTE  bButtonB;             // Another button goes here\n\tBYTE  bButtonC;             // Another button goes here\n\tBYTE  bButtonD;             // Another button goes here\n} MYDATA;\n\nstatic DIOBJECTDATAFORMAT rgodf[] = {\n  { &GUID_XAxis,    FIELD_OFFSET(MYDATA, lX),       DIDFT_AXIS | DIDFT_ANYINSTANCE,   0,},\n  { &GUID_YAxis,    FIELD_OFFSET(MYDATA, lY),       DIDFT_AXIS | DIDFT_ANYINSTANCE,   0,},\n  { &GUID_ZAxis,    FIELD_OFFSET(MYDATA, lZ),       0x80000000 | DIDFT_AXIS | DIDFT_ANYINSTANCE,   0,},\n  { 0,              FIELD_OFFSET(MYDATA, bButtonA), DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},\n  { 0,              FIELD_OFFSET(MYDATA, bButtonB), DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},\n  { 0,              FIELD_OFFSET(MYDATA, bButtonC), 0x80000000 | DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},\n  { 0,              FIELD_OFFSET(MYDATA, bButtonD), 0x80000000 | DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},\n};\n\n#define NUM_OBJECTS (sizeof(rgodf) / sizeof(rgodf[0]))\n\n// NOTE TTimo: would be easier using c_dfDIMouse or c_dfDIMouse2 \nstatic DIDATAFORMAT\tdf = {\n\tsizeof(DIDATAFORMAT),       // this structure\n\tsizeof(DIOBJECTDATAFORMAT), // size of object data format\n\tDIDF_RELAXIS,               // absolute axis coordinates\n\tsizeof(MYDATA),             // device data size\n\tNUM_OBJECTS,                // number of objects\n\trgodf,                      // and here they are\n};\n\nstatic LPDIRECTINPUT\t\tg_pdi;\nstatic LPDIRECTINPUTDEVICE\tg_pMouse;\n\nvoid IN_DIMouse( int *mx, int *my );\n\n/*\n========================\nIN_InitDIMouse\n========================\n*/\nqboolean IN_InitDIMouse( void ) {\n    HRESULT\t\thr;\n\tint\t\t\tx, y;\n\tDIPROPDWORD\tdipdw = {\n\t\t{\n\t\t\tsizeof(DIPROPDWORD),        // diph.dwSize\n\t\t\tsizeof(DIPROPHEADER),       // diph.dwHeaderSize\n\t\t\t0,                          // diph.dwObj\n\t\t\tDIPH_DEVICE,                // diph.dwHow\n\t\t},\n\t\tDINPUT_BUFFERSIZE,              // dwData\n\t};\n\n\tCom_Printf( \"Initializing DirectInput...\\n\");\n\n\tif (!hInstDI) {\n\t\thInstDI = LoadLibrary(\"dinput.dll\");\n\t\t\n\t\tif (hInstDI == NULL) {\n\t\t\tCom_Printf (\"Couldn't load dinput.dll\\n\");\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\tif (!pDirectInputCreate) {\n\t\tpDirectInputCreate = (long (__stdcall *)(void *,unsigned long ,struct IDirectInputA ** ,struct IUnknown *))\n\t\t\tGetProcAddress(hInstDI,\"DirectInputCreateA\");\n\n\t\tif (!pDirectInputCreate) {\n\t\t\tCom_Printf (\"Couldn't get DI proc addr\\n\");\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\t// register with DirectInput and get an IDirectInput to play with.\n\thr = iDirectInputCreate( g_wv.hInstance, DIRECTINPUT_VERSION, &g_pdi, NULL);\n\n\tif (FAILED(hr)) {\n\t\tCom_Printf (\"iDirectInputCreate failed\\n\");\n\t\treturn qfalse;\n\t}\n\n\t// obtain an interface to the system mouse device.\n\thr = IDirectInput_CreateDevice(g_pdi, &GUID_SysMouse, &g_pMouse, NULL);\n\n\tif (FAILED(hr)) {\n\t\tCom_Printf (\"Couldn't open DI mouse device\\n\");\n\t\treturn qfalse;\n\t}\n\n\t// set the data format to \"mouse format\".\n\thr = IDirectInputDevice_SetDataFormat(g_pMouse, &df);\n\n\tif (FAILED(hr)) \t{\n\t\tCom_Printf (\"Couldn't set DI mouse format\\n\");\n\t\treturn qfalse;\n\t}\n\n\t// set the cooperativity level.\n\thr = IDirectInputDevice_SetCooperativeLevel(g_pMouse, g_wv.hWnd,\n\t\t\tDISCL_EXCLUSIVE | DISCL_FOREGROUND);\n\n\t// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=50\n\tif (FAILED(hr)) {\n\t\tCom_Printf (\"Couldn't set DI coop level\\n\");\n\t\treturn qfalse;\n\t}\n\n\n\t// set the buffer size to DINPUT_BUFFERSIZE elements.\n\t// the buffer size is a DWORD property associated with the device\n\thr = IDirectInputDevice_SetProperty(g_pMouse, DIPROP_BUFFERSIZE, &dipdw.diph);\n\n\tif (FAILED(hr)) {\n\t\tCom_Printf (\"Couldn't set DI buffersize\\n\");\n\t\treturn qfalse;\n\t}\n\n\t// clear any pending samples\n\tIN_DIMouse( &x, &y );\n\tIN_DIMouse( &x, &y );\n\n\tCom_Printf( \"DirectInput initialized.\\n\");\n\treturn qtrue;\n}\n\n/*\n==========================\nIN_ShutdownDIMouse\n==========================\n*/\nvoid IN_ShutdownDIMouse( void ) {\n    if (g_pMouse) {\n\t\tIDirectInputDevice_Release(g_pMouse);\n\t\tg_pMouse = NULL;\n\t}\n\n    if (g_pdi) {\n\t\tIDirectInput_Release(g_pdi);\n\t\tg_pdi = NULL;\n\t}\n}\n\n/*\n==========================\nIN_ActivateDIMouse\n==========================\n*/\nvoid IN_ActivateDIMouse( void ) {\n\tHRESULT\t\thr;\n\n\tif (!g_pMouse) {\n\t\treturn;\n\t}\n\n\t// we may fail to reacquire if the window has been recreated\n\thr = IDirectInputDevice_Acquire( g_pMouse );\n\tif (FAILED(hr)) {\n\t\tif ( !IN_InitDIMouse() ) {\n\t\t\tCom_Printf (\"Falling back to Win32 mouse support...\\n\");\n\t\t\tCvar_Set( \"in_mouse\", \"-1\" );\n\t\t}\n\t}\n}\n\n/*\n==========================\nIN_DeactivateDIMouse\n==========================\n*/\nvoid IN_DeactivateDIMouse( void ) {\n\tif (!g_pMouse) {\n\t\treturn;\n\t}\n\tIDirectInputDevice_Unacquire( g_pMouse );\n}\n\n\n/*\n===================\nIN_DIMouse\n===================\n*/\nvoid IN_DIMouse( int *mx, int *my ) {\n\tDIDEVICEOBJECTDATA\tod;\n\tDIMOUSESTATE\t\tstate;\n\tDWORD\t\t\t\tdwElements;\n\tHRESULT\t\t\t\thr;\n  int value;\n\tstatic float\t\toldSysTime;\n\n\tif ( !g_pMouse ) {\n\t\treturn;\n\t}\n\n\t// fetch new events\n\tfor (;;)\n\t{\n\t\tdwElements = 1;\n\n\t\thr = IDirectInputDevice_GetDeviceData(g_pMouse,\n\t\t\t\tsizeof(DIDEVICEOBJECTDATA), &od, &dwElements, 0);\n\t\tif ((hr == DIERR_INPUTLOST) || (hr == DIERR_NOTACQUIRED)) {\n\t\t\tIDirectInputDevice_Acquire(g_pMouse);\n\t\t\treturn;\n\t\t}\n\n\t\t/* Unable to read data or no data available */\n\t\tif ( FAILED(hr) ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif ( dwElements == 0 ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tswitch (od.dwOfs) {\n\t\tcase DIMOFS_BUTTON0:\n\t\t\tif (od.dwData & 0x80)\n\t\t\t\tSys_QueEvent( od.dwTimeStamp, SE_KEY, K_MOUSE1, qtrue, 0, NULL );\n\t\t\telse\n\t\t\t\tSys_QueEvent( od.dwTimeStamp, SE_KEY, K_MOUSE1, qfalse, 0, NULL );\n\t\t\tbreak;\n\n\t\tcase DIMOFS_BUTTON1:\n\t\t\tif (od.dwData & 0x80)\n\t\t\t\tSys_QueEvent( od.dwTimeStamp, SE_KEY, K_MOUSE2, qtrue, 0, NULL );\n\t\t\telse\n\t\t\t\tSys_QueEvent( od.dwTimeStamp, SE_KEY, K_MOUSE2, qfalse, 0, NULL );\n\t\t\tbreak;\n\t\t\t\n\t\tcase DIMOFS_BUTTON2:\n\t\t\tif (od.dwData & 0x80)\n\t\t\t\tSys_QueEvent( od.dwTimeStamp, SE_KEY, K_MOUSE3, qtrue, 0, NULL );\n\t\t\telse\n\t\t\t\tSys_QueEvent( od.dwTimeStamp, SE_KEY, K_MOUSE3, qfalse, 0, NULL );\n\t\t\tbreak;\n\n\t\tcase DIMOFS_BUTTON3:\n\t\t\tif (od.dwData & 0x80)\n\t\t\t\tSys_QueEvent( od.dwTimeStamp, SE_KEY, K_MOUSE4, qtrue, 0, NULL );\n\t\t\telse\n\t\t\t\tSys_QueEvent( od.dwTimeStamp, SE_KEY, K_MOUSE4, qfalse, 0, NULL );\n\t\t\tbreak;      \n    // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=50\n\t\tcase DIMOFS_Z:\n\t\t\tvalue = od.dwData;\n\t\t\tif (value == 0) {\n\n\t\t\t} else if (value < 0) {\n\t\t\t\tSys_QueEvent( od.dwTimeStamp, SE_KEY, K_MWHEELDOWN, qtrue, 0, NULL );\n\t\t\t\tSys_QueEvent( od.dwTimeStamp, SE_KEY, K_MWHEELDOWN, qfalse, 0, NULL );\n\t\t\t} else {\n\t\t\t\tSys_QueEvent( od.dwTimeStamp, SE_KEY, K_MWHEELUP, qtrue, 0, NULL );\n\t\t\t\tSys_QueEvent( od.dwTimeStamp, SE_KEY, K_MWHEELUP, qfalse, 0, NULL );\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// read the raw delta counter and ignore\n\t// the individual sample time / values\n\thr = IDirectInputDevice_GetDeviceState(g_pMouse,\n\t\t\tsizeof(DIDEVICEOBJECTDATA), &state);\n\tif ( FAILED(hr) ) {\n\t\t*mx = *my = 0;\n\t\treturn;\n\t}\n\t*mx = state.lX;\n\t*my = state.lY;\n}\n\n/*\n============================================================\n\n  MOUSE CONTROL\n\n============================================================\n*/\n\n/*\n===========\nIN_ActivateMouse\n\nCalled when the window gains focus or changes in some way\n===========\n*/\nvoid IN_ActivateMouse( void ) \n{\n\tif (!s_wmv.mouseInitialized ) {\n\t\treturn;\n\t}\n\tif ( !in_mouse->integer ) \n\t{\n\t\ts_wmv.mouseActive = qfalse;\n\t\treturn;\n\t}\n\tif ( s_wmv.mouseActive ) \n\t{\n\t\treturn;\n\t}\n\n\ts_wmv.mouseActive = qtrue;\n\n\tif ( in_mouse->integer != -1 ) {\n\t\tIN_ActivateDIMouse();\n\t}\n\tIN_ActivateWin32Mouse();\n}\n\n\n/*\n===========\nIN_DeactivateMouse\n\nCalled when the window loses focus\n===========\n*/\nvoid IN_DeactivateMouse( void ) {\n\tif (!s_wmv.mouseInitialized ) {\n\t\treturn;\n\t}\n\tif (!s_wmv.mouseActive ) {\n\t\treturn;\n\t}\n\ts_wmv.mouseActive = qfalse;\n\n\tIN_DeactivateDIMouse();\n\tIN_DeactivateWin32Mouse();\n}\n\n\n\n/*\n===========\nIN_StartupMouse\n===========\n*/\nvoid IN_StartupMouse( void ) \n{\n\ts_wmv.mouseInitialized = qfalse;\n  s_wmv.mouseStartupDelayed = qfalse;\n\n\tif ( in_mouse->integer == 0 ) {\n\t\tCom_Printf (\"Mouse control not active.\\n\");\n\t\treturn;\n\t}\n\n\t// nt4.0 direct input is screwed up\n\tif ( ( g_wv.osversion.dwPlatformId == VER_PLATFORM_WIN32_NT ) &&\n\t\t ( g_wv.osversion.dwMajorVersion == 4 ) )\n\t{\n\t\tCom_Printf (\"Disallowing DirectInput on NT 4.0\\n\");\n\t\tCvar_Set( \"in_mouse\", \"-1\" );\n\t}\n\n\tif ( in_mouse->integer == -1 ) {\n\t\tCom_Printf (\"Skipping check for DirectInput\\n\");\n\t} else {\n    if (!g_wv.hWnd)\n    {\n      Com_Printf (\"No window for DirectInput mouse init, delaying\\n\");\n      s_wmv.mouseStartupDelayed = qtrue;\n      return;\n    }\n\t\tif ( IN_InitDIMouse() ) {\n\t    s_wmv.mouseInitialized = qtrue;\n\t\t\treturn;\n\t\t}\n\t\tCom_Printf (\"Falling back to Win32 mouse support...\\n\");\n\t}\n\ts_wmv.mouseInitialized = qtrue;\n\tIN_InitWin32Mouse();\n}\n\n/*\n===========\nIN_MouseEvent\n===========\n*/\nvoid IN_MouseEvent (int mstate)\n{\n\tint\t\ti;\n\n\tif ( !s_wmv.mouseInitialized )\n\t\treturn;\n\n// perform button actions\n\tfor  (i = 0 ; i < 3 ; i++ )\n\t{\n\t\tif ( (mstate & (1<<i)) &&\n\t\t\t!(s_wmv.oldButtonState & (1<<i)) )\n\t\t{\n\t\t\tSys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MOUSE1 + i, qtrue, 0, NULL );\n\t\t}\n\n\t\tif ( !(mstate & (1<<i)) &&\n\t\t\t(s_wmv.oldButtonState & (1<<i)) )\n\t\t{\n\t\t\tSys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MOUSE1 + i, qfalse, 0, NULL );\n\t\t}\n\t}\t\n\n\ts_wmv.oldButtonState = mstate;\n}\n\n\n/*\n===========\nIN_MouseMove\n===========\n*/\nvoid IN_MouseMove ( void ) {\n\tint\t\tmx, my;\n\n\tif ( g_pMouse ) {\n\t\tIN_DIMouse( &mx, &my );\n\t} else {\n\t\tIN_Win32Mouse( &mx, &my );\n\t}\n\n\tif ( !mx && !my ) {\n\t\treturn;\n\t}\n\n\tSys_QueEvent( 0, SE_MOUSE, mx, my, 0, NULL );\n}\n\n\n/*\n=========================================================================\n\n=========================================================================\n*/\n\n/*\n===========\nIN_Startup\n===========\n*/\nvoid IN_Startup( void ) {\n\tCom_Printf (\"\\n------- Input Initialization -------\\n\");\n\tIN_StartupMouse ();\n\tIN_StartupJoystick ();\n\tIN_StartupMIDI();\n\tCom_Printf (\"------------------------------------\\n\");\n\n\tin_mouse->modified = qfalse;\n\tin_joystick->modified = qfalse;\n}\n\n/*\n===========\nIN_Shutdown\n===========\n*/\nvoid IN_Shutdown( void ) {\n\tIN_DeactivateMouse();\n\tIN_ShutdownDIMouse();\n\tIN_ShutdownMIDI();\n\tCmd_RemoveCommand(\"midiinfo\" );\n}\n\n\n/*\n===========\nIN_Init\n===========\n*/\nvoid IN_Init( void ) {\n\t// MIDI input controler variables\n\tin_midi\t\t\t\t\t= Cvar_Get (\"in_midi\",\t\t\t\t\t\"0\",\t\tCVAR_ARCHIVE);\n\tin_midiport\t\t\t\t= Cvar_Get (\"in_midiport\",\t\t\t\t\"1\",\t\tCVAR_ARCHIVE);\n\tin_midichannel\t\t\t= Cvar_Get (\"in_midichannel\",\t\t\t\"1\",\t\tCVAR_ARCHIVE);\n\tin_mididevice\t\t\t= Cvar_Get (\"in_mididevice\",\t\t\t\"0\",\t\tCVAR_ARCHIVE);\n\n\tCmd_AddCommand( \"midiinfo\", MidiInfo_f );\n\n\t// mouse variables\n  in_mouse\t\t\t\t= Cvar_Get (\"in_mouse\",\t\t\t\t\t\"1\",\t\tCVAR_ARCHIVE|CVAR_LATCH);\n\tin_logitechbug  = Cvar_Get (\"in_logitechbug\", \"0\", CVAR_ARCHIVE);\n\n\t// joystick variables\n\tin_joystick\t\t\t\t= Cvar_Get (\"in_joystick\",\t\t\t\t\"0\",\t\tCVAR_ARCHIVE|CVAR_LATCH);\n\tin_joyBallScale\t\t\t= Cvar_Get (\"in_joyBallScale\",\t\t\t\"0.02\",\t\tCVAR_ARCHIVE);\n\tin_debugJoystick\t\t= Cvar_Get (\"in_debugjoystick\",\t\t\t\"0\",\t\tCVAR_TEMP);\n\n\tjoy_threshold\t\t\t= Cvar_Get (\"joy_threshold\",\t\t\t\"0.15\",\t\tCVAR_ARCHIVE);\n\n\tIN_Startup();\n}\n\n\n/*\n===========\nIN_Activate\n\nCalled when the main window gains or loses focus.\nThe window may have been destroyed and recreated\nbetween a deactivate and an activate.\n===========\n*/\nvoid IN_Activate (qboolean active) {\n\tin_appactive = active;\n\n\tif ( !active )\n\t{\n\t\tIN_DeactivateMouse();\n\t}\n}\n\n\n/*\n==================\nIN_Frame\n\nCalled every frame, even if not generating commands\n==================\n*/\nvoid IN_Frame (void) {\n\t// post joystick events\n\tIN_JoyMove();\n\n\tif ( !s_wmv.mouseInitialized ) {\n    if (s_wmv.mouseStartupDelayed && g_wv.hWnd)\n\t\t{\n\t\t\tCom_Printf(\"Proceeding with delayed mouse init\\n\");\n      IN_StartupMouse();\n\t\t\ts_wmv.mouseStartupDelayed = qfalse;\n\t\t}\n\t\treturn;\n\t}\n\n\tif ( cls.keyCatchers & KEYCATCH_CONSOLE ) {\n\t\t// temporarily deactivate if not in the game and\n\t\t// running on the desktop\n\t\t// voodoo always counts as full screen\n\t\tif (Cvar_VariableValue (\"r_fullscreen\") == 0\n\t\t\t&& strcmp( Cvar_VariableString(\"r_glDriver\"), _3DFX_DRIVER_NAME) )\t{\n\t\t\tIN_DeactivateMouse ();\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif ( !in_appactive ) {\n\t\tIN_DeactivateMouse ();\n\t\treturn;\n\t}\n\n\tIN_ActivateMouse();\n\n\t// post events to the system que\n\tIN_MouseMove();\n\n}\n\n\n/*\n===================\nIN_ClearStates\n===================\n*/\nvoid IN_ClearStates (void) \n{\n\ts_wmv.oldButtonState = 0;\n}\n\n\n/*\n=========================================================================\n\nJOYSTICK\n\n=========================================================================\n*/\n\n/* \n=============== \nIN_StartupJoystick \n=============== \n*/  \nvoid IN_StartupJoystick (void) { \n\tint\t\t\tnumdevs;\n\tMMRESULT\tmmr;\n\n\t// assume no joystick\n\tjoy.avail = qfalse; \n\n\tif (! in_joystick->integer ) {\n\t\tCom_Printf (\"Joystick is not active.\\n\");\n\t\treturn;\n\t}\n\n\t// verify joystick driver is present\n\tif ((numdevs = joyGetNumDevs ()) == 0)\n\t{\n\t\tCom_Printf (\"joystick not found -- driver not present\\n\");\n\t\treturn;\n\t}\n\n\t// cycle through the joystick ids for the first valid one\n\tmmr = 0;\n\tfor (joy.id=0 ; joy.id<numdevs ; joy.id++)\n\t{\n\t\tCom_Memset (&joy.ji, 0, sizeof(joy.ji));\n\t\tjoy.ji.dwSize = sizeof(joy.ji);\n\t\tjoy.ji.dwFlags = JOY_RETURNCENTERED;\n\n\t\tif ((mmr = joyGetPosEx (joy.id, &joy.ji)) == JOYERR_NOERROR)\n\t\t\tbreak;\n\t} \n\n\t// abort startup if we didn't find a valid joystick\n\tif (mmr != JOYERR_NOERROR)\n\t{\n\t\tCom_Printf (\"joystick not found -- no valid joysticks (%x)\\n\", mmr);\n\t\treturn;\n\t}\n\n\t// get the capabilities of the selected joystick\n\t// abort startup if command fails\n\tCom_Memset (&joy.jc, 0, sizeof(joy.jc));\n\tif ((mmr = joyGetDevCaps (joy.id, &joy.jc, sizeof(joy.jc))) != JOYERR_NOERROR)\n\t{\n\t\tCom_Printf (\"joystick not found -- invalid joystick capabilities (%x)\\n\", mmr); \n\t\treturn;\n\t}\n\n\tCom_Printf( \"Joystick found.\\n\" );\n\tCom_Printf( \"Pname: %s\\n\", joy.jc.szPname );\n\tCom_Printf( \"OemVxD: %s\\n\", joy.jc.szOEMVxD );\n\tCom_Printf( \"RegKey: %s\\n\", joy.jc.szRegKey );\n\n\tCom_Printf( \"Numbuttons: %i / %i\\n\", joy.jc.wNumButtons, joy.jc.wMaxButtons );\n\tCom_Printf( \"Axis: %i / %i\\n\", joy.jc.wNumAxes, joy.jc.wMaxAxes );\n\tCom_Printf( \"Caps: 0x%x\\n\", joy.jc.wCaps );\n\tif ( joy.jc.wCaps & JOYCAPS_HASPOV ) {\n\t\tCom_Printf( \"HASPOV\\n\" );\n\t} else {\n\t\tCom_Printf( \"no POV\\n\" );\n\t}\n\n\t// old button and POV states default to no buttons pressed\n\tjoy.oldbuttonstate = 0;\n\tjoy.oldpovstate = 0;\n\n\t// mark the joystick as available\n\tjoy.avail = qtrue; \n}\n\n/*\n===========\nJoyToF\n===========\n*/\nfloat JoyToF( int value ) {\n\tfloat\tfValue;\n\n\t// move centerpoint to zero\n\tvalue -= 32768;\n\n\t// convert range from -32768..32767 to -1..1 \n\tfValue = (float)value / 32768.0;\n\n\tif ( fValue < -1 ) {\n\t\tfValue = -1;\n\t}\n\tif ( fValue > 1 ) {\n\t\tfValue = 1;\n\t}\n\treturn fValue;\n}\n\nint JoyToI( int value ) {\n\t// move centerpoint to zero\n\tvalue -= 32768;\n\n\treturn value;\n}\n\nint\tjoyDirectionKeys[16] = {\n\tK_LEFTARROW, K_RIGHTARROW,\n\tK_UPARROW, K_DOWNARROW,\n\tK_JOY16, K_JOY17,\n\tK_JOY18, K_JOY19,\n\tK_JOY20, K_JOY21,\n\tK_JOY22, K_JOY23,\n\n\tK_JOY24, K_JOY25,\n\tK_JOY26, K_JOY27\n};\n\n/*\n===========\nIN_JoyMove\n===========\n*/\nvoid IN_JoyMove( void ) {\n\tfloat\tfAxisValue;\n\tint\t\ti;\n\tDWORD\tbuttonstate, povstate;\n\tint\t\tx, y;\n\n\t// verify joystick is available and that the user wants to use it\n\tif ( !joy.avail ) {\n\t\treturn; \n\t}\n\n\t// collect the joystick data, if possible\n\tCom_Memset (&joy.ji, 0, sizeof(joy.ji));\n\tjoy.ji.dwSize = sizeof(joy.ji);\n\tjoy.ji.dwFlags = JOY_RETURNALL;\n\n\tif ( joyGetPosEx (joy.id, &joy.ji) != JOYERR_NOERROR ) {\n\t\t// read error occurred\n\t\t// turning off the joystick seems too harsh for 1 read error,\\\n\t\t// but what should be done?\n\t\t// Com_Printf (\"IN_ReadJoystick: no response\\n\");\n\t\t// joy.avail = false;\n\t\treturn;\n\t}\n\n\tif ( in_debugJoystick->integer ) {\n\t\tCom_Printf( \"%8x %5i %5.2f %5.2f %5.2f %5.2f %6i %6i\\n\", \n\t\t\tjoy.ji.dwButtons,\n\t\t\tjoy.ji.dwPOV,\n\t\t\tJoyToF( joy.ji.dwXpos ), JoyToF( joy.ji.dwYpos ),\n\t\t\tJoyToF( joy.ji.dwZpos ), JoyToF( joy.ji.dwRpos ),\n\t\t\tJoyToI( joy.ji.dwUpos ), JoyToI( joy.ji.dwVpos ) );\n\t}\n\n\t// loop through the joystick buttons\n\t// key a joystick event or auxillary event for higher number buttons for each state change\n\tbuttonstate = joy.ji.dwButtons;\n\tfor ( i=0 ; i < joy.jc.wNumButtons ; i++ ) {\n\t\tif ( (buttonstate & (1<<i)) && !(joy.oldbuttonstate & (1<<i)) ) {\n\t\t\tSys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_JOY1 + i, qtrue, 0, NULL );\n\t\t}\n\t\tif ( !(buttonstate & (1<<i)) && (joy.oldbuttonstate & (1<<i)) ) {\n\t\t\tSys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_JOY1 + i, qfalse, 0, NULL );\n\t\t}\n\t}\n\tjoy.oldbuttonstate = buttonstate;\n\n\tpovstate = 0;\n\n\t// convert main joystick motion into 6 direction button bits\n\tfor (i = 0; i < joy.jc.wNumAxes && i < 4 ; i++) {\n\t\t// get the floating point zero-centered, potentially-inverted data for the current axis\n\t\tfAxisValue = JoyToF( (&joy.ji.dwXpos)[i] );\n\n\t\tif ( fAxisValue < -joy_threshold->value ) {\n\t\t\tpovstate |= (1<<(i*2));\n\t\t} else if ( fAxisValue > joy_threshold->value ) {\n\t\t\tpovstate |= (1<<(i*2+1));\n\t\t}\n\t}\n\n\t// convert POV information from a direction into 4 button bits\n\tif ( joy.jc.wCaps & JOYCAPS_HASPOV ) {\n\t\tif ( joy.ji.dwPOV != JOY_POVCENTERED ) {\n\t\t\tif (joy.ji.dwPOV == JOY_POVFORWARD)\n\t\t\t\tpovstate |= 1<<12;\n\t\t\tif (joy.ji.dwPOV == JOY_POVBACKWARD)\n\t\t\t\tpovstate |= 1<<13;\n\t\t\tif (joy.ji.dwPOV == JOY_POVRIGHT)\n\t\t\t\tpovstate |= 1<<14;\n\t\t\tif (joy.ji.dwPOV == JOY_POVLEFT)\n\t\t\t\tpovstate |= 1<<15;\n\t\t}\n\t}\n\n\t// determine which bits have changed and key an auxillary event for each change\n\tfor (i=0 ; i < 16 ; i++) {\n\t\tif ( (povstate & (1<<i)) && !(joy.oldpovstate & (1<<i)) ) {\n\t\t\tSys_QueEvent( g_wv.sysMsgTime, SE_KEY, joyDirectionKeys[i], qtrue, 0, NULL );\n\t\t}\n\n\t\tif ( !(povstate & (1<<i)) && (joy.oldpovstate & (1<<i)) ) {\n\t\t\tSys_QueEvent( g_wv.sysMsgTime, SE_KEY, joyDirectionKeys[i], qfalse, 0, NULL );\n\t\t}\n\t}\n\tjoy.oldpovstate = povstate;\n\n\t// if there is a trackball like interface, simulate mouse moves\n\tif ( joy.jc.wNumAxes >= 6 ) {\n\t\tx = JoyToI( joy.ji.dwUpos ) * in_joyBallScale->value;\n\t\ty = JoyToI( joy.ji.dwVpos ) * in_joyBallScale->value;\n\t\tif ( x || y ) {\n\t\t\tSys_QueEvent( g_wv.sysMsgTime, SE_MOUSE, x, y, 0, NULL );\n\t\t}\n\t}\n}\n\n/*\n=========================================================================\n\nMIDI\n\n=========================================================================\n*/\n\nstatic void MIDI_NoteOff( int note )\n{\n\tint qkey;\n\n\tqkey = note - 60 + K_AUX1;\n\n\tif ( qkey > 255 || qkey < K_AUX1 )\n\t\treturn;\n\n\tSys_QueEvent( g_wv.sysMsgTime, SE_KEY, qkey, qfalse, 0, NULL );\n}\n\nstatic void MIDI_NoteOn( int note, int velocity )\n{\n\tint qkey;\n\n\tif ( velocity == 0 )\n\t\tMIDI_NoteOff( note );\n\n\tqkey = note - 60 + K_AUX1;\n\n\tif ( qkey > 255 || qkey < K_AUX1 )\n\t\treturn;\n\n\tSys_QueEvent( g_wv.sysMsgTime, SE_KEY, qkey, qtrue, 0, NULL );\n}\n\nstatic void CALLBACK MidiInProc( HMIDIIN hMidiIn, UINT uMsg, DWORD dwInstance, \n\t\t\t\t\t\t\t\t DWORD dwParam1, DWORD dwParam2 )\n{\n\tint message;\n\n\tswitch ( uMsg )\n\t{\n\tcase MIM_OPEN:\n\t\tbreak;\n\tcase MIM_CLOSE:\n\t\tbreak;\n\tcase MIM_DATA:\n\t\tmessage = dwParam1 & 0xff;\n\n\t\t// note on\n\t\tif ( ( message & 0xf0 ) == 0x90 )\n\t\t{\n\t\t\tif ( ( ( message & 0x0f ) + 1 ) == in_midichannel->integer )\n\t\t\t\tMIDI_NoteOn( ( dwParam1 & 0xff00 ) >> 8, ( dwParam1 & 0xff0000 ) >> 16 );\n\t\t}\n\t\telse if ( ( message & 0xf0 ) == 0x80 )\n\t\t{\n\t\t\tif ( ( ( message & 0x0f ) + 1 ) == in_midichannel->integer )\n\t\t\t\tMIDI_NoteOff( ( dwParam1 & 0xff00 ) >> 8 );\n\t\t}\n\t\tbreak;\n\tcase MIM_LONGDATA:\n\t\tbreak;\n\tcase MIM_ERROR:\n\t\tbreak;\n\tcase MIM_LONGERROR:\n\t\tbreak;\n\t}\n\n//\tSys_QueEvent( sys_msg_time, SE_KEY, wMsg, qtrue, 0, NULL );\n}\n\nstatic void MidiInfo_f( void )\n{\n\tint i;\n\n\tconst char *enableStrings[] = { \"disabled\", \"enabled\" };\n\n\tCom_Printf( \"\\nMIDI control:       %s\\n\", enableStrings[in_midi->integer != 0] );\n\tCom_Printf( \"port:               %d\\n\", in_midiport->integer );\n\tCom_Printf( \"channel:            %d\\n\", in_midichannel->integer );\n\tCom_Printf( \"current device:     %d\\n\", in_mididevice->integer );\n\tCom_Printf( \"number of devices:  %d\\n\", s_midiInfo.numDevices );\n\tfor ( i = 0; i < s_midiInfo.numDevices; i++ )\n\t{\n\t\tif ( i == Cvar_VariableValue( \"in_mididevice\" ) )\n\t\t\tCom_Printf( \"***\" );\n\t\telse\n\t\t\tCom_Printf( \"...\" );\n\t\tCom_Printf(    \"device %2d:       %s\\n\", i, s_midiInfo.caps[i].szPname );\n\t\tCom_Printf( \"...manufacturer ID: 0x%hx\\n\", s_midiInfo.caps[i].wMid );\n\t\tCom_Printf( \"...product ID:      0x%hx\\n\", s_midiInfo.caps[i].wPid );\n\n\t\tCom_Printf( \"\\n\" );\n\t}\n}\n\nstatic void IN_StartupMIDI( void )\n{\n\tint i;\n\n\tif ( !Cvar_VariableValue( \"in_midi\" ) )\n\t\treturn;\n\n\t//\n\t// enumerate MIDI IN devices\n\t//\n\ts_midiInfo.numDevices = midiInGetNumDevs();\n\n\tfor ( i = 0; i < s_midiInfo.numDevices; i++ )\n\t{\n\t\tmidiInGetDevCaps( i, &s_midiInfo.caps[i], sizeof( s_midiInfo.caps[i] ) );\n\t}\n\n\t//\n\t// open the MIDI IN port\n\t//\n\tif ( midiInOpen( &s_midiInfo.hMidiIn, \n\t\t             in_mididevice->integer,\n\t\t\t\t\t ( unsigned long ) MidiInProc,\n\t\t\t\t\t ( unsigned long ) NULL,\n\t\t\t\t\t CALLBACK_FUNCTION ) != MMSYSERR_NOERROR )\n\t{\n\t\tCom_Printf( \"WARNING: could not open MIDI device %d: '%s'\\n\", in_mididevice->integer , s_midiInfo.caps[( int ) in_mididevice->value] );\n\t\treturn;\n\t}\n\n\tmidiInStart( s_midiInfo.hMidiIn );\n}\n\nstatic void IN_ShutdownMIDI( void )\n{\n\tif ( s_midiInfo.hMidiIn )\n\t{\n\t\tmidiInClose( s_midiInfo.hMidiIn );\n\t}\n\tCom_Memset( &s_midiInfo, 0, sizeof( s_midiInfo ) );\n}\n\n"
  },
  {
    "path": "code/win32/win_local.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// win_local.h: Win32-specific Quake3 header file\n\n#if defined (_MSC_VER) && (_MSC_VER >= 1200)\n#pragma warning(disable : 4201)\n#pragma warning( push )\n#endif\n#include <windows.h>\n#if defined (_MSC_VER) && (_MSC_VER >= 1200)\n#pragma warning( pop )\n#endif\n\n#define\tDIRECTSOUND_VERSION\t0x0300\n#define\tDIRECTINPUT_VERSION\t0x0300\n\n#include <dinput.h>\n#include <dsound.h>\n#include <winsock.h>\n#include <wsipx.h>\n\nvoid\tIN_MouseEvent (int mstate);\n\nvoid Sys_QueEvent( int time, sysEventType_t type, int value, int value2, int ptrLength, void *ptr );\n\nvoid\tSys_CreateConsole( void );\nvoid\tSys_DestroyConsole( void );\n\nchar\t*Sys_ConsoleInput (void);\n\nqboolean\tSys_GetPacket ( netadr_t *net_from, msg_t *net_message );\n\n// Input subsystem\n\nvoid\tIN_Init (void);\nvoid\tIN_Shutdown (void);\nvoid\tIN_JoystickCommands (void);\n\nvoid\tIN_Move (usercmd_t *cmd);\n// add additional non keyboard / non mouse movement on top of the keyboard move cmd\n\nvoid\tIN_DeactivateWin32Mouse( void);\n\nvoid\tIN_Activate (qboolean active);\nvoid\tIN_Frame (void);\n\n// window procedure\nLONG WINAPI MainWndProc (\n    HWND    hWnd,\n    UINT    uMsg,\n    WPARAM  wParam,\n    LPARAM  lParam);\n\nvoid Conbuf_AppendText( const char *msg );\n\nvoid SNDDMA_Activate( void );\nint  SNDDMA_InitDS ();\n\ntypedef struct\n{\n\t\n\tHINSTANCE\t\treflib_library;\t\t// Handle to refresh DLL \n\tqboolean\t\treflib_active;\n\n\tHWND\t\t\thWnd;\n\tHINSTANCE\t\thInstance;\n\tqboolean\t\tactiveApp;\n\tqboolean\t\tisMinimized;\n\tOSVERSIONINFO\tosversion;\n\n\t// when we get a windows message, we store the time off so keyboard processing\n\t// can know the exact time of an event\n\tunsigned\t\tsysMsgTime;\n} WinVars_t;\n\nextern WinVars_t\tg_wv;\n"
  },
  {
    "path": "code/win32/win_main.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// win_main.c\n\n#include \"../client/client.h\"\n#include \"../qcommon/qcommon.h\"\n#include \"win_local.h\"\n#include \"resource.h\"\n#include <errno.h>\n#include <float.h>\n#include <fcntl.h>\n#include <stdio.h>\n#include <direct.h>\n#include <io.h>\n#include <conio.h>\n\n#define\tCD_BASEDIR\t\"quake3\"\n#define\tCD_EXE\t\t\"quake3.exe\"\n#define\tCD_BASEDIR_LINUX\t\"bin\\\\x86\\\\glibc-2.1\"\n#define\tCD_EXE_LINUX \"quake3\"\n#define MEM_THRESHOLD 96*1024*1024\n\nstatic char\t\tsys_cmdline[MAX_STRING_CHARS];\n\n// define this to use alternate spanking method\n// I found out that the regular way doesn't work on my box for some reason\n// see the associated spank.sh script\n#define ALT_SPANK\n#ifdef ALT_SPANK\n#include <stdio.h>\n#include <sys\\stat.h>\n\nint fh = 0;\n\nvoid Spk_Open(char *name)\n{\n  fh = open( name, O_TRUNC | O_CREAT | O_WRONLY, S_IREAD | S_IWRITE );\n};\n\nvoid Spk_Close()\n{\n  if (!fh)\n    return;\n\n  close( fh );\n  fh = 0;\n}\n\nvoid Spk_Printf (const char *text, ...)\n{\n  va_list argptr;\n  char buf[32768];\n\n  if (!fh)\n    return;\n\n  va_start (argptr,text);\n  vsprintf (buf, text, argptr);\n  write(fh, buf, strlen(buf));\n  _commit(fh);\n  va_end (argptr);\n\n};\n#endif\n\n/*\n==================\nSys_LowPhysicalMemory()\n==================\n*/\n\nqboolean Sys_LowPhysicalMemory() {\n\tMEMORYSTATUS stat;\n  GlobalMemoryStatus (&stat);\n\treturn (stat.dwTotalPhys <= MEM_THRESHOLD) ? qtrue : qfalse;\n}\n\n/*\n==================\nSys_BeginProfiling\n==================\n*/\nvoid Sys_BeginProfiling( void ) {\n\t// this is just used on the mac build\n}\n\n/*\n=============\nSys_Error\n\nShow the early console as an error dialog\n=============\n*/\nvoid QDECL Sys_Error( const char *error, ... ) {\n\tva_list\t\targptr;\n\tchar\t\ttext[4096];\n    MSG        msg;\n\n\tva_start (argptr, error);\n\tvsprintf (text, error, argptr);\n\tva_end (argptr);\n\n\tConbuf_AppendText( text );\n\tConbuf_AppendText( \"\\n\" );\n\n\tSys_SetErrorText( text );\n\tSys_ShowConsole( 1, qtrue );\n\n\ttimeEndPeriod( 1 );\n\n\tIN_Shutdown();\n\n\t// wait for the user to quit\n\twhile ( 1 ) {\n\t\tif (!GetMessage (&msg, NULL, 0, 0))\n\t\t\tCom_Quit_f ();\n\t\tTranslateMessage (&msg);\n      \tDispatchMessage (&msg);\n\t}\n\n\tSys_DestroyConsole();\n\n\texit (1);\n}\n\n/*\n==============\nSys_Quit\n==============\n*/\nvoid Sys_Quit( void ) {\n\ttimeEndPeriod( 1 );\n\tIN_Shutdown();\n\tSys_DestroyConsole();\n\n\texit (0);\n}\n\n/*\n==============\nSys_Print\n==============\n*/\nvoid Sys_Print( const char *msg ) {\n\tConbuf_AppendText( msg );\n}\n\n\n/*\n==============\nSys_Mkdir\n==============\n*/\nvoid Sys_Mkdir( const char *path ) {\n\t_mkdir (path);\n}\n\n/*\n==============\nSys_Cwd\n==============\n*/\nchar *Sys_Cwd( void ) {\n\tstatic char cwd[MAX_OSPATH];\n\n\t_getcwd( cwd, sizeof( cwd ) - 1 );\n\tcwd[MAX_OSPATH-1] = 0;\n\n\treturn cwd;\n}\n\n/*\n==============\nSys_DefaultCDPath\n==============\n*/\nchar *Sys_DefaultCDPath( void ) {\n\treturn \"\";\n}\n\n/*\n==============\nSys_DefaultBasePath\n==============\n*/\nchar *Sys_DefaultBasePath( void ) {\n\treturn Sys_Cwd();\n}\n\n/*\n==============================================================\n\nDIRECTORY SCANNING\n\n==============================================================\n*/\n\n#define\tMAX_FOUND_FILES\t0x1000\n\nvoid Sys_ListFilteredFiles( const char *basedir, char *subdirs, char *filter, char **list, int *numfiles ) {\n\tchar\t\tsearch[MAX_OSPATH], newsubdirs[MAX_OSPATH];\n\tchar\t\tfilename[MAX_OSPATH];\n\tint\t\t\tfindhandle;\n\tstruct _finddata_t findinfo;\n\n\tif ( *numfiles >= MAX_FOUND_FILES - 1 ) {\n\t\treturn;\n\t}\n\n\tif (strlen(subdirs)) {\n\t\tCom_sprintf( search, sizeof(search), \"%s\\\\%s\\\\*\", basedir, subdirs );\n\t}\n\telse {\n\t\tCom_sprintf( search, sizeof(search), \"%s\\\\*\", basedir );\n\t}\n\n\tfindhandle = _findfirst (search, &findinfo);\n\tif (findhandle == -1) {\n\t\treturn;\n\t}\n\n\tdo {\n\t\tif (findinfo.attrib & _A_SUBDIR) {\n\t\t\tif (Q_stricmp(findinfo.name, \".\") && Q_stricmp(findinfo.name, \"..\")) {\n\t\t\t\tif (strlen(subdirs)) {\n\t\t\t\t\tCom_sprintf( newsubdirs, sizeof(newsubdirs), \"%s\\\\%s\", subdirs, findinfo.name);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tCom_sprintf( newsubdirs, sizeof(newsubdirs), \"%s\", findinfo.name);\n\t\t\t\t}\n\t\t\t\tSys_ListFilteredFiles( basedir, newsubdirs, filter, list, numfiles );\n\t\t\t}\n\t\t}\n\t\tif ( *numfiles >= MAX_FOUND_FILES - 1 ) {\n\t\t\tbreak;\n\t\t}\n\t\tCom_sprintf( filename, sizeof(filename), \"%s\\\\%s\", subdirs, findinfo.name );\n\t\tif (!Com_FilterPath( filter, filename, qfalse ))\n\t\t\tcontinue;\n\t\tlist[ *numfiles ] = CopyString( filename );\n\t\t(*numfiles)++;\n\t} while ( _findnext (findhandle, &findinfo) != -1 );\n\n\t_findclose (findhandle);\n}\n\nstatic qboolean strgtr(const char *s0, const char *s1) {\n\tint l0, l1, i;\n\n\tl0 = strlen(s0);\n\tl1 = strlen(s1);\n\n\tif (l1<l0) {\n\t\tl0 = l1;\n\t}\n\n\tfor(i=0;i<l0;i++) {\n\t\tif (s1[i] > s0[i]) {\n\t\t\treturn qtrue;\n\t\t}\n\t\tif (s1[i] < s0[i]) {\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\treturn qfalse;\n}\n\nchar **Sys_ListFiles( const char *directory, const char *extension, char *filter, int *numfiles, qboolean wantsubs ) {\n\tchar\t\tsearch[MAX_OSPATH];\n\tint\t\t\tnfiles;\n\tchar\t\t**listCopy;\n\tchar\t\t*list[MAX_FOUND_FILES];\n\tstruct _finddata_t findinfo;\n\tint\t\t\tfindhandle;\n\tint\t\t\tflag;\n\tint\t\t\ti;\n\n\tif (filter) {\n\n\t\tnfiles = 0;\n\t\tSys_ListFilteredFiles( directory, \"\", filter, list, &nfiles );\n\n\t\tlist[ nfiles ] = 0;\n\t\t*numfiles = nfiles;\n\n\t\tif (!nfiles)\n\t\t\treturn NULL;\n\n\t\tlistCopy = Z_Malloc( ( nfiles + 1 ) * sizeof( *listCopy ) );\n\t\tfor ( i = 0 ; i < nfiles ; i++ ) {\n\t\t\tlistCopy[i] = list[i];\n\t\t}\n\t\tlistCopy[i] = NULL;\n\n\t\treturn listCopy;\n\t}\n\n\tif ( !extension) {\n\t\textension = \"\";\n\t}\n\n\t// passing a slash as extension will find directories\n\tif ( extension[0] == '/' && extension[1] == 0 ) {\n\t\textension = \"\";\n\t\tflag = 0;\n\t} else {\n\t\tflag = _A_SUBDIR;\n\t}\n\n\tCom_sprintf( search, sizeof(search), \"%s\\\\*%s\", directory, extension );\n\n\t// search\n\tnfiles = 0;\n\n\tfindhandle = _findfirst (search, &findinfo);\n\tif (findhandle == -1) {\n\t\t*numfiles = 0;\n\t\treturn NULL;\n\t}\n\n\tdo {\n\t\tif ( (!wantsubs && flag ^ ( findinfo.attrib & _A_SUBDIR )) || (wantsubs && findinfo.attrib & _A_SUBDIR) ) {\n\t\t\tif ( nfiles == MAX_FOUND_FILES - 1 ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tlist[ nfiles ] = CopyString( findinfo.name );\n\t\t\tnfiles++;\n\t\t}\n\t} while ( _findnext (findhandle, &findinfo) != -1 );\n\n\tlist[ nfiles ] = 0;\n\n\t_findclose (findhandle);\n\n\t// return a copy of the list\n\t*numfiles = nfiles;\n\n\tif ( !nfiles ) {\n\t\treturn NULL;\n\t}\n\n\tlistCopy = Z_Malloc( ( nfiles + 1 ) * sizeof( *listCopy ) );\n\tfor ( i = 0 ; i < nfiles ; i++ ) {\n\t\tlistCopy[i] = list[i];\n\t}\n\tlistCopy[i] = NULL;\n\n\tdo {\n\t\tflag = 0;\n\t\tfor(i=1; i<nfiles; i++) {\n\t\t\tif (strgtr(listCopy[i-1], listCopy[i])) {\n\t\t\t\tchar *temp = listCopy[i];\n\t\t\t\tlistCopy[i] = listCopy[i-1];\n\t\t\t\tlistCopy[i-1] = temp;\n\t\t\t\tflag = 1;\n\t\t\t}\n\t\t}\n\t} while(flag);\n\n\treturn listCopy;\n}\n\nvoid\tSys_FreeFileList( char **list ) {\n\tint\t\ti;\n\n\tif ( !list ) {\n\t\treturn;\n\t}\n\n\tfor ( i = 0 ; list[i] ; i++ ) {\n\t\tZ_Free( list[i] );\n\t}\n\n\tZ_Free( list );\n}\n\n//========================================================\n\n\n/*\n================\nSys_ScanForCD\n\nSearch all the drives to see if there is a valid CD to grab\nthe cddir from\n================\n*/\nqboolean Sys_ScanForCD( void ) {\n\tstatic char\tcddir[MAX_OSPATH];\n\tchar\t\tdrive[4];\n\tFILE\t\t*f;\n\tchar\t\ttest[MAX_OSPATH];\n#if 0\n\t// don't override a cdpath on the command line\n\tif ( strstr( sys_cmdline, \"cdpath\" ) ) {\n\t\treturn;\n\t}\n#endif\n\n\tdrive[0] = 'c';\n\tdrive[1] = ':';\n\tdrive[2] = '\\\\';\n\tdrive[3] = 0;\n\n\t// scan the drives\n\tfor ( drive[0] = 'c' ; drive[0] <= 'z' ; drive[0]++ ) {\n\t\tif ( GetDriveType (drive) != DRIVE_CDROM ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tsprintf (cddir, \"%s%s\", drive, CD_BASEDIR);\n\t\tsprintf (test, \"%s\\\\%s\", cddir, CD_EXE);\n\t\tf = fopen( test, \"r\" );\n\t\tif ( f ) {\n\t\t\tfclose (f);\n\t\t\treturn qtrue;\n    } else {\n      sprintf(cddir, \"%s%s\", drive, CD_BASEDIR_LINUX);\n      sprintf(test, \"%s\\\\%s\", cddir, CD_EXE_LINUX);\n  \t\tf = fopen( test, \"r\" );\n\t  \tif ( f ) {\n\t\t  \tfclose (f);\n\t\t\t  return qtrue;\n      }\n    }\n\t}\n\n\treturn qfalse;\n}\n\n/*\n================\nSys_CheckCD\n\nReturn true if the proper CD is in the drive\n================\n*/\nqboolean\tSys_CheckCD( void ) {\n  // FIXME: mission pack\n  return qtrue;\n\t//return Sys_ScanForCD();\n}\n\n\n/*\n================\nSys_GetClipboardData\n\n================\n*/\nchar *Sys_GetClipboardData( void ) {\n\tchar *data = NULL;\n\tchar *cliptext;\n\n\tif ( OpenClipboard( NULL ) != 0 ) {\n\t\tHANDLE hClipboardData;\n\n\t\tif ( ( hClipboardData = GetClipboardData( CF_TEXT ) ) != 0 ) {\n\t\t\tif ( ( cliptext = GlobalLock( hClipboardData ) ) != 0 ) {\n\t\t\t\tdata = Z_Malloc( GlobalSize( hClipboardData ) + 1 );\n\t\t\t\tQ_strncpyz( data, cliptext, GlobalSize( hClipboardData ) );\n\t\t\t\tGlobalUnlock( hClipboardData );\n\t\t\t\t\n\t\t\t\tstrtok( data, \"\\n\\r\\b\" );\n\t\t\t}\n\t\t}\n\t\tCloseClipboard();\n\t}\n\treturn data;\n}\n\n\n/*\n========================================================================\n\nLOAD/UNLOAD DLL\n\n========================================================================\n*/\n\n/*\n=================\nSys_UnloadDll\n\n=================\n*/\nvoid Sys_UnloadDll( void *dllHandle ) {\n\tif ( !dllHandle ) {\n\t\treturn;\n\t}\n\tif ( !FreeLibrary( dllHandle ) ) {\n\t\tCom_Error (ERR_FATAL, \"Sys_UnloadDll FreeLibrary failed\");\n\t}\n}\n\n/*\n=================\nSys_LoadDll\n\nUsed to load a development dll instead of a virtual machine\n\nTTimo: added some verbosity in debug\n=================\n*/\nextern char\t\t*FS_BuildOSPath( const char *base, const char *game, const char *qpath );\n\n// fqpath param added 7/20/02 by T.Ray - Sys_LoadDll is only called in vm.c at this time\n// fqpath will be empty if dll not loaded, otherwise will hold fully qualified path of dll module loaded\n// fqpath buffersize must be at least MAX_QPATH+1 bytes long\nvoid * QDECL Sys_LoadDll( const char *name, char *fqpath , int (QDECL **entryPoint)(int, ...),\n\t\t\t\t  int (QDECL *systemcalls)(int, ...) ) {\n\tstatic int\tlastWarning = 0;\n\tHINSTANCE\tlibHandle;\n\tvoid\t(QDECL *dllEntry)( int (QDECL *syscallptr)(int, ...) );\n\tchar\t*basepath;\n\tchar\t*cdpath;\n\tchar\t*gamedir;\n\tchar\t*fn;\n#ifdef NDEBUG\n\tint\t\ttimestamp;\n  int   ret;\n#endif\n\tchar\tfilename[MAX_QPATH];\n\n\t*fqpath = 0 ;\t\t// added 7/20/02 by T.Ray\n\n\tCom_sprintf( filename, sizeof( filename ), \"%sx86.dll\", name );\n\n#ifdef NDEBUG\n\ttimestamp = Sys_Milliseconds();\n\tif( ((timestamp - lastWarning) > (5 * 60000)) && !Cvar_VariableIntegerValue( \"dedicated\" )\n\t\t&& !Cvar_VariableIntegerValue( \"com_blindlyLoadDLLs\" ) ) {\n\t\tif (FS_FileExists(filename)) {\n\t\t\tlastWarning = timestamp;\n\t\t\tret = MessageBoxEx( NULL, \"You are about to load a .DLL executable that\\n\"\n\t\t\t\t  \"has not been verified for use with Quake III Arena.\\n\"\n\t\t\t\t  \"This type of file can compromise the security of\\n\"\n\t\t\t\t  \"your computer.\\n\\n\"\n\t\t\t\t  \"Select 'OK' if you choose to load it anyway.\",\n\t\t\t\t  \"Security Warning\", MB_OKCANCEL | MB_ICONEXCLAMATION | MB_DEFBUTTON2 | MB_TOPMOST | MB_SETFOREGROUND,\n\t\t\t\t  MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ) );\n\t\t\tif( ret != IDOK ) {\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t}\n#endif\n\n#ifndef NDEBUG\n\tlibHandle = LoadLibrary( filename );\n  if (libHandle)\n    Com_Printf(\"LoadLibrary '%s' ok\\n\", filename);\n  else\n    Com_Printf(\"LoadLibrary '%s' failed\\n\", filename);\n\tif ( !libHandle ) {\n#endif\n\tbasepath = Cvar_VariableString( \"fs_basepath\" );\n\tcdpath = Cvar_VariableString( \"fs_cdpath\" );\n\tgamedir = Cvar_VariableString( \"fs_game\" );\n\n\tfn = FS_BuildOSPath( basepath, gamedir, filename );\n\tlibHandle = LoadLibrary( fn );\n#ifndef NDEBUG\n  if (libHandle)\n    Com_Printf(\"LoadLibrary '%s' ok\\n\", fn);\n  else\n    Com_Printf(\"LoadLibrary '%s' failed\\n\", fn);\n#endif\n\n\tif ( !libHandle ) {\n\t\tif( cdpath[0] ) {\n\t\t\tfn = FS_BuildOSPath( cdpath, gamedir, filename );\n\t\t\tlibHandle = LoadLibrary( fn );\n#ifndef NDEBUG\n      if (libHandle)\n        Com_Printf(\"LoadLibrary '%s' ok\\n\", fn);\n      else\n        Com_Printf(\"LoadLibrary '%s' failed\\n\", fn);\n#endif\n\t\t}\n\n\t\tif ( !libHandle ) {\n\t\t\treturn NULL;\n\t\t}\n\t}\n#ifndef NDEBUG\n\t}\n#endif\n\n\tdllEntry = ( void (QDECL *)( int (QDECL *)( int, ... ) ) )GetProcAddress( libHandle, \"dllEntry\" ); \n\t*entryPoint = (int (QDECL *)(int,...))GetProcAddress( libHandle, \"vmMain\" );\n\tif ( !*entryPoint || !dllEntry ) {\n\t\tFreeLibrary( libHandle );\n\t\treturn NULL;\n\t}\n\tdllEntry( systemcalls );\n\n\tif ( libHandle ) Q_strncpyz ( fqpath , filename , MAX_QPATH ) ;\t\t// added 7/20/02 by T.Ray\n\treturn libHandle;\n}\n\n\n/*\n========================================================================\n\nBACKGROUND FILE STREAMING\n\n========================================================================\n*/\n\n#if 1\n\nvoid Sys_InitStreamThread( void ) {\n}\n\nvoid Sys_ShutdownStreamThread( void ) {\n}\n\nvoid Sys_BeginStreamedFile( fileHandle_t f, int readAhead ) {\n}\n\nvoid Sys_EndStreamedFile( fileHandle_t f ) {\n}\n\nint Sys_StreamedRead( void *buffer, int size, int count, fileHandle_t f ) {\n   return FS_Read( buffer, size * count, f );\n}\n\nvoid Sys_StreamSeek( fileHandle_t f, int offset, int origin ) {\n   FS_Seek( f, offset, origin );\n}\n\n\n#else\n\ntypedef struct {\n\tfileHandle_t\tfile;\n\tbyte\t*buffer;\n\tqboolean\teof;\n\tqboolean\tactive;\n\tint\t\tbufferSize;\n\tint\t\tstreamPosition;\t// next byte to be returned by Sys_StreamRead\n\tint\t\tthreadPosition;\t// next byte to be read from file\n} streamsIO_t;\n\ntypedef struct {\n\tHANDLE\t\t\t\tthreadHandle;\n\tint\t\t\t\t\tthreadId;\n\tCRITICAL_SECTION\tcrit;\n\tstreamsIO_t\t\t\tsIO[MAX_FILE_HANDLES];\n} streamState_t;\n\nstreamState_t\tstream;\n\n/*\n===============\nSys_StreamThread\n\nA thread will be sitting in this loop forever\n================\n*/\nvoid Sys_StreamThread( void ) {\n\tint\t\tbuffer;\n\tint\t\tcount;\n\tint\t\treadCount;\n\tint\t\tbufferPoint;\n\tint\t\tr, i;\n\n\twhile (1) {\n\t\tSleep( 10 );\n//\t\tEnterCriticalSection (&stream.crit);\n\n\t\tfor (i=1;i<MAX_FILE_HANDLES;i++) {\n\t\t\t// if there is any space left in the buffer, fill it up\n\t\t\tif ( stream.sIO[i].active  && !stream.sIO[i].eof ) {\n\t\t\t\tcount = stream.sIO[i].bufferSize - (stream.sIO[i].threadPosition - stream.sIO[i].streamPosition);\n\t\t\t\tif ( !count ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tbufferPoint = stream.sIO[i].threadPosition % stream.sIO[i].bufferSize;\n\t\t\t\tbuffer = stream.sIO[i].bufferSize - bufferPoint;\n\t\t\t\treadCount = buffer < count ? buffer : count;\n\n\t\t\t\tr = FS_Read( stream.sIO[i].buffer + bufferPoint, readCount, stream.sIO[i].file );\n\t\t\t\tstream.sIO[i].threadPosition += r;\n\n\t\t\t\tif ( r != readCount ) {\n\t\t\t\t\tstream.sIO[i].eof = qtrue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n//\t\tLeaveCriticalSection (&stream.crit);\n\t}\n}\n\n/*\n===============\nSys_InitStreamThread\n\n================\n*/\nvoid Sys_InitStreamThread( void ) {\n\tint i;\n\n\tInitializeCriticalSection ( &stream.crit );\n\n\t// don't leave the critical section until there is a\n\t// valid file to stream, which will cause the StreamThread\n\t// to sleep without any overhead\n//\tEnterCriticalSection( &stream.crit );\n\n\tstream.threadHandle = CreateThread(\n\t   NULL,\t// LPSECURITY_ATTRIBUTES lpsa,\n\t   0,\t\t// DWORD cbStack,\n\t   (LPTHREAD_START_ROUTINE)Sys_StreamThread,\t// LPTHREAD_START_ROUTINE lpStartAddr,\n\t   0,\t\t\t// LPVOID lpvThreadParm,\n\t   0,\t\t\t//   DWORD fdwCreate,\n\t   &stream.threadId);\n\tfor(i=0;i<MAX_FILE_HANDLES;i++) {\n\t\tstream.sIO[i].active = qfalse;\n\t}\n}\n\n/*\n===============\nSys_ShutdownStreamThread\n\n================\n*/\nvoid Sys_ShutdownStreamThread( void ) {\n}\n\n\n/*\n===============\nSys_BeginStreamedFile\n\n================\n*/\nvoid Sys_BeginStreamedFile( fileHandle_t f, int readAhead ) {\n\tif ( stream.sIO[f].file ) {\n\t\tSys_EndStreamedFile( stream.sIO[f].file );\n\t}\n\n\tstream.sIO[f].file = f;\n\tstream.sIO[f].buffer = Z_Malloc( readAhead );\n\tstream.sIO[f].bufferSize = readAhead;\n\tstream.sIO[f].streamPosition = 0;\n\tstream.sIO[f].threadPosition = 0;\n\tstream.sIO[f].eof = qfalse;\n\tstream.sIO[f].active = qtrue;\n\n\t// let the thread start running\n//\tLeaveCriticalSection( &stream.crit );\n}\n\n/*\n===============\nSys_EndStreamedFile\n\n================\n*/\nvoid Sys_EndStreamedFile( fileHandle_t f ) {\n\tif ( f != stream.sIO[f].file ) {\n\t\tCom_Error( ERR_FATAL, \"Sys_EndStreamedFile: wrong file\");\n\t}\n\t// don't leave critical section until another stream is started\n\tEnterCriticalSection( &stream.crit );\n\n\tstream.sIO[f].file = 0;\n\tstream.sIO[f].active = qfalse;\n\n\tZ_Free( stream.sIO[f].buffer );\n\n\tLeaveCriticalSection( &stream.crit );\n}\n\n\n/*\n===============\nSys_StreamedRead\n\n================\n*/\nint Sys_StreamedRead( void *buffer, int size, int count, fileHandle_t f ) {\n\tint\t\tavailable;\n\tint\t\tremaining;\n\tint\t\tsleepCount;\n\tint\t\tcopy;\n\tint\t\tbufferCount;\n\tint\t\tbufferPoint;\n\tbyte\t*dest;\n\n\tif (stream.sIO[f].active == qfalse) {\n\t\tCom_Error( ERR_FATAL, \"Streamed read with non-streaming file\" );\n\t}\n\n\tdest = (byte *)buffer;\n\tremaining = size * count;\n\n\tif ( remaining <= 0 ) {\n\t\tCom_Error( ERR_FATAL, \"Streamed read with non-positive size\" );\n\t}\n\n\tsleepCount = 0;\n\twhile ( remaining > 0 ) {\n\t\tavailable = stream.sIO[f].threadPosition - stream.sIO[f].streamPosition;\n\t\tif ( !available ) {\n\t\t\tif ( stream.sIO[f].eof ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( sleepCount == 1 ) {\n\t\t\t\tCom_DPrintf( \"Sys_StreamedRead: waiting\\n\" );\n\t\t\t}\n\t\t\tif ( ++sleepCount > 100 ) {\n\t\t\t\tCom_Error( ERR_FATAL, \"Sys_StreamedRead: thread has died\");\n\t\t\t}\n\t\t\tSleep( 10 );\n\t\t\tcontinue;\n\t\t}\n\n\t\tEnterCriticalSection( &stream.crit );\n\n\t\tbufferPoint = stream.sIO[f].streamPosition % stream.sIO[f].bufferSize;\n\t\tbufferCount = stream.sIO[f].bufferSize - bufferPoint;\n\n\t\tcopy = available < bufferCount ? available : bufferCount;\n\t\tif ( copy > remaining ) {\n\t\t\tcopy = remaining;\n\t\t}\n\t\tmemcpy( dest, stream.sIO[f].buffer + bufferPoint, copy );\n\t\tstream.sIO[f].streamPosition += copy;\n\t\tdest += copy;\n\t\tremaining -= copy;\n\n\t\tLeaveCriticalSection( &stream.crit );\n\t}\n\n\treturn (count * size - remaining) / size;\n}\n\n/*\n===============\nSys_StreamSeek\n\n================\n*/\nvoid Sys_StreamSeek( fileHandle_t f, int offset, int origin ) {\n\n\t// halt the thread\n\tEnterCriticalSection( &stream.crit );\n\n\t// clear to that point\n\tFS_Seek( f, offset, origin );\n\tstream.sIO[f].streamPosition = 0;\n\tstream.sIO[f].threadPosition = 0;\n\tstream.sIO[f].eof = qfalse;\n\n\t// let the thread start running at the new position\n\tLeaveCriticalSection( &stream.crit );\n}\n\n#endif\n\n/*\n========================================================================\n\nEVENT LOOP\n\n========================================================================\n*/\n\n#define\tMAX_QUED_EVENTS\t\t256\n#define\tMASK_QUED_EVENTS\t( MAX_QUED_EVENTS - 1 )\n\nsysEvent_t\teventQue[MAX_QUED_EVENTS];\nint\t\t\teventHead, eventTail;\nbyte\t\tsys_packetReceived[MAX_MSGLEN];\n\n/*\n================\nSys_QueEvent\n\nA time of 0 will get the current time\nPtr should either be null, or point to a block of data that can\nbe freed by the game later.\n================\n*/\nvoid Sys_QueEvent( int time, sysEventType_t type, int value, int value2, int ptrLength, void *ptr ) {\n\tsysEvent_t\t*ev;\n\n\tev = &eventQue[ eventHead & MASK_QUED_EVENTS ];\n\tif ( eventHead - eventTail >= MAX_QUED_EVENTS ) {\n\t\tCom_Printf(\"Sys_QueEvent: overflow\\n\");\n\t\t// we are discarding an event, but don't leak memory\n\t\tif ( ev->evPtr ) {\n\t\t\tZ_Free( ev->evPtr );\n\t\t}\n\t\teventTail++;\n\t}\n\n\teventHead++;\n\n\tif ( time == 0 ) {\n\t\ttime = Sys_Milliseconds();\n\t}\n\n\tev->evTime = time;\n\tev->evType = type;\n\tev->evValue = value;\n\tev->evValue2 = value2;\n\tev->evPtrLength = ptrLength;\n\tev->evPtr = ptr;\n}\n\n/*\n================\nSys_GetEvent\n\n================\n*/\nsysEvent_t Sys_GetEvent( void ) {\n    MSG\t\t\tmsg;\n\tsysEvent_t\tev;\n\tchar\t\t*s;\n\tmsg_t\t\tnetmsg;\n\tnetadr_t\tadr;\n\n\t// return if we have data\n\tif ( eventHead > eventTail ) {\n\t\teventTail++;\n\t\treturn eventQue[ ( eventTail - 1 ) & MASK_QUED_EVENTS ];\n\t}\n\n\t// pump the message loop\n\twhile (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)) {\n\t\tif ( !GetMessage (&msg, NULL, 0, 0) ) {\n\t\t\tCom_Quit_f();\n\t\t}\n\n\t\t// save the msg time, because wndprocs don't have access to the timestamp\n\t\tg_wv.sysMsgTime = msg.time;\n\n\t\tTranslateMessage (&msg);\n      \tDispatchMessage (&msg);\n\t}\n\n\t// check for console commands\n\ts = Sys_ConsoleInput();\n\tif ( s ) {\n\t\tchar\t*b;\n\t\tint\t\tlen;\n\n\t\tlen = strlen( s ) + 1;\n\t\tb = Z_Malloc( len );\n\t\tQ_strncpyz( b, s, len-1 );\n\t\tSys_QueEvent( 0, SE_CONSOLE, 0, 0, len, b );\n\t}\n\n\t// check for network packets\n\tMSG_Init( &netmsg, sys_packetReceived, sizeof( sys_packetReceived ) );\n\tif ( Sys_GetPacket ( &adr, &netmsg ) ) {\n\t\tnetadr_t\t\t*buf;\n\t\tint\t\t\t\tlen;\n\n\t\t// copy out to a seperate buffer for qeueing\n\t\t// the readcount stepahead is for SOCKS support\n\t\tlen = sizeof( netadr_t ) + netmsg.cursize - netmsg.readcount;\n\t\tbuf = Z_Malloc( len );\n\t\t*buf = adr;\n\t\tmemcpy( buf+1, &netmsg.data[netmsg.readcount], netmsg.cursize - netmsg.readcount );\n\t\tSys_QueEvent( 0, SE_PACKET, 0, 0, len, buf );\n\t}\n\n\t// return if we have data\n\tif ( eventHead > eventTail ) {\n\t\teventTail++;\n\t\treturn eventQue[ ( eventTail - 1 ) & MASK_QUED_EVENTS ];\n\t}\n\n\t// create an empty event to return\n\n\tmemset( &ev, 0, sizeof( ev ) );\n\tev.evTime = timeGetTime();\n\n\treturn ev;\n}\n\n//================================================================\n\n/*\n=================\nSys_In_Restart_f\n\nRestart the input subsystem\n=================\n*/\nvoid Sys_In_Restart_f( void ) {\n\tIN_Shutdown();\n\tIN_Init();\n}\n\n\n/*\n=================\nSys_Net_Restart_f\n\nRestart the network subsystem\n=================\n*/\nvoid Sys_Net_Restart_f( void ) {\n\tNET_Restart();\n}\n\n\n/*\n================\nSys_Init\n\nCalled after the common systems (cvars, files, etc)\nare initialized\n================\n*/\n#define OSR2_BUILD_NUMBER 1111\n#define WIN98_BUILD_NUMBER 1998\n\nvoid Sys_Init( void ) {\n\tint cpuid;\n\n\t// make sure the timer is high precision, otherwise\n\t// NT gets 18ms resolution\n\ttimeBeginPeriod( 1 );\n\n\tCmd_AddCommand (\"in_restart\", Sys_In_Restart_f);\n\tCmd_AddCommand (\"net_restart\", Sys_Net_Restart_f);\n\n\tg_wv.osversion.dwOSVersionInfoSize = sizeof( g_wv.osversion );\n\n\tif (!GetVersionEx (&g_wv.osversion))\n\t\tSys_Error (\"Couldn't get OS info\");\n\n\tif (g_wv.osversion.dwMajorVersion < 4)\n\t\tSys_Error (\"Quake3 requires Windows version 4 or greater\");\n\tif (g_wv.osversion.dwPlatformId == VER_PLATFORM_WIN32s)\n\t\tSys_Error (\"Quake3 doesn't run on Win32s\");\n\n\tif ( g_wv.osversion.dwPlatformId == VER_PLATFORM_WIN32_NT )\n\t{\n\t\tCvar_Set( \"arch\", \"winnt\" );\n\t}\n\telse if ( g_wv.osversion.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS )\n\t{\n\t\tif ( LOWORD( g_wv.osversion.dwBuildNumber ) >= WIN98_BUILD_NUMBER )\n\t\t{\n\t\t\tCvar_Set( \"arch\", \"win98\" );\n\t\t}\n\t\telse if ( LOWORD( g_wv.osversion.dwBuildNumber ) >= OSR2_BUILD_NUMBER )\n\t\t{\n\t\t\tCvar_Set( \"arch\", \"win95 osr2.x\" );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tCvar_Set( \"arch\", \"win95\" );\n\t\t}\n\t}\n\telse\n\t{\n\t\tCvar_Set( \"arch\", \"unknown Windows variant\" );\n\t}\n\n\t// save out a couple things in rom cvars for the renderer to access\n\tCvar_Get( \"win_hinstance\", va(\"%i\", (int)g_wv.hInstance), CVAR_ROM );\n\tCvar_Get( \"win_wndproc\", va(\"%i\", (int)MainWndProc), CVAR_ROM );\n\n\t//\n\t// figure out our CPU\n\t//\n\tCvar_Get( \"sys_cpustring\", \"detect\", 0 );\n\tif ( !Q_stricmp( Cvar_VariableString( \"sys_cpustring\"), \"detect\" ) )\n\t{\n\t\tCom_Printf( \"...detecting CPU, found \" );\n\n\t\tcpuid = Sys_GetProcessorId();\n\n\t\tswitch ( cpuid )\n\t\t{\n\t\tcase CPUID_GENERIC:\n\t\t\tCvar_Set( \"sys_cpustring\", \"generic\" );\n\t\t\tbreak;\n\t\tcase CPUID_INTEL_UNSUPPORTED:\n\t\t\tCvar_Set( \"sys_cpustring\", \"x86 (pre-Pentium)\" );\n\t\t\tbreak;\n\t\tcase CPUID_INTEL_PENTIUM:\n\t\t\tCvar_Set( \"sys_cpustring\", \"x86 (P5/PPro, non-MMX)\" );\n\t\t\tbreak;\n\t\tcase CPUID_INTEL_MMX:\n\t\t\tCvar_Set( \"sys_cpustring\", \"x86 (P5/Pentium2, MMX)\" );\n\t\t\tbreak;\n\t\tcase CPUID_INTEL_KATMAI:\n\t\t\tCvar_Set( \"sys_cpustring\", \"Intel Pentium III\" );\n\t\t\tbreak;\n\t\tcase CPUID_AMD_3DNOW:\n\t\t\tCvar_Set( \"sys_cpustring\", \"AMD w/ 3DNow!\" );\n\t\t\tbreak;\n\t\tcase CPUID_AXP:\n\t\t\tCvar_Set( \"sys_cpustring\", \"Alpha AXP\" );\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tCom_Error( ERR_FATAL, \"Unknown cpu type %d\\n\", cpuid );\n\t\t\tbreak;\n\t\t}\n\t}\n\telse\n\t{\n\t\tCom_Printf( \"...forcing CPU type to \" );\n\t\tif ( !Q_stricmp( Cvar_VariableString( \"sys_cpustring\" ), \"generic\" ) )\n\t\t{\n\t\t\tcpuid = CPUID_GENERIC;\n\t\t}\n\t\telse if ( !Q_stricmp( Cvar_VariableString( \"sys_cpustring\" ), \"x87\" ) )\n\t\t{\n\t\t\tcpuid = CPUID_INTEL_PENTIUM;\n\t\t}\n\t\telse if ( !Q_stricmp( Cvar_VariableString( \"sys_cpustring\" ), \"mmx\" ) )\n\t\t{\n\t\t\tcpuid = CPUID_INTEL_MMX;\n\t\t}\n\t\telse if ( !Q_stricmp( Cvar_VariableString( \"sys_cpustring\" ), \"3dnow\" ) )\n\t\t{\n\t\t\tcpuid = CPUID_AMD_3DNOW;\n\t\t}\n\t\telse if ( !Q_stricmp( Cvar_VariableString( \"sys_cpustring\" ), \"PentiumIII\" ) )\n\t\t{\n\t\t\tcpuid = CPUID_INTEL_KATMAI;\n\t\t}\n\t\telse if ( !Q_stricmp( Cvar_VariableString( \"sys_cpustring\" ), \"axp\" ) )\n\t\t{\n\t\t\tcpuid = CPUID_AXP;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tCom_Printf( \"WARNING: unknown sys_cpustring '%s'\\n\", Cvar_VariableString( \"sys_cpustring\" ) );\n\t\t\tcpuid = CPUID_GENERIC;\n\t\t}\n\t}\n\tCvar_SetValue( \"sys_cpuid\", cpuid );\n\tCom_Printf( \"%s\\n\", Cvar_VariableString( \"sys_cpustring\" ) );\n\n\tCvar_Set( \"username\", Sys_GetCurrentUser() );\n\n\tIN_Init();\t\t// FIXME: not in dedicated?\n}\n\n\n//=======================================================================\n\nint\ttotalMsec, countMsec;\n\n/*\n==================\nWinMain\n\n==================\n*/\nint WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {\n\tchar\t\tcwd[MAX_OSPATH];\n\tint\t\t\tstartTime, endTime;\n\n    // should never get a previous instance in Win32\n    if ( hPrevInstance ) {\n        return 0;\n\t}\n\n\tg_wv.hInstance = hInstance;\n\tQ_strncpyz( sys_cmdline, lpCmdLine, sizeof( sys_cmdline ) );\n\n\t// done before Com/Sys_Init since we need this for error output\n\tSys_CreateConsole();\n\n\t// no abort/retry/fail errors\n\tSetErrorMode( SEM_FAILCRITICALERRORS );\n\n\t// get the initial time base\n\tSys_Milliseconds();\n#if 0\n\t// if we find the CD, add a +set cddir xxx command line\n\tSys_ScanForCD();\n#endif\n\n\tSys_InitStreamThread();\n\n\tCom_Init( sys_cmdline );\n\tNET_Init();\n\n\t_getcwd (cwd, sizeof(cwd));\n\tCom_Printf(\"Working directory: %s\\n\", cwd);\n\n\t// hide the early console since we've reached the point where we\n\t// have a working graphics subsystems\n\tif ( !com_dedicated->integer && !com_viewlog->integer ) {\n\t\tSys_ShowConsole( 0, qfalse );\n\t}\n\n    // main game loop\n\twhile( 1 ) {\n\t\t// if not running as a game client, sleep a bit\n\t\tif ( g_wv.isMinimized || ( com_dedicated && com_dedicated->integer ) ) {\n\t\t\tSleep( 5 );\n\t\t}\n\n\t\t// set low precision every frame, because some system calls\n\t\t// reset it arbitrarily\n//\t\t_controlfp( _PC_24, _MCW_PC );\n//    _controlfp( -1, _MCW_EM  ); // no exceptions, even if some crappy\n                                // syscall turns them back on!\n\n\t\tstartTime = Sys_Milliseconds();\n\n\t\t// make sure mouse and joystick are only called once a frame\n\t\tIN_Frame();\n\n\t\t// run the game\n\t\tCom_Frame();\n\n\t\tendTime = Sys_Milliseconds();\n\t\ttotalMsec += endTime - startTime;\n\t\tcountMsec++;\n\t}\n\n\t// never gets here\n}\n\n\n"
  },
  {
    "path": "code/win32/win_net.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// net_wins.c\n\n#include \"../game/q_shared.h\"\n#include \"../qcommon/qcommon.h\"\n#include \"win_local.h\"\n\nstatic WSADATA\twinsockdata;\nstatic qboolean\twinsockInitialized = qfalse;\nstatic qboolean usingSocks = qfalse;\nstatic qboolean networkingEnabled = qfalse;\n\nstatic cvar_t\t*net_noudp;\nstatic cvar_t\t*net_noipx;\n\nstatic cvar_t\t*net_socksEnabled;\nstatic cvar_t\t*net_socksServer;\nstatic cvar_t\t*net_socksPort;\nstatic cvar_t\t*net_socksUsername;\nstatic cvar_t\t*net_socksPassword;\nstatic struct sockaddr\tsocksRelayAddr;\n\nstatic SOCKET\tip_socket;\nstatic SOCKET\tsocks_socket;\nstatic SOCKET\tipx_socket;\n\n#define\tMAX_IPS\t\t16\nstatic\tint\t\tnumIP;\nstatic\tbyte\tlocalIP[MAX_IPS][4];\n\n//=============================================================================\n\n\n/*\n====================\nNET_ErrorString\n====================\n*/\nchar *NET_ErrorString( void ) {\n\tint\t\tcode;\n\n\tcode = WSAGetLastError();\n\tswitch( code ) {\n\tcase WSAEINTR: return \"WSAEINTR\";\n\tcase WSAEBADF: return \"WSAEBADF\";\n\tcase WSAEACCES: return \"WSAEACCES\";\n\tcase WSAEDISCON: return \"WSAEDISCON\";\n\tcase WSAEFAULT: return \"WSAEFAULT\";\n\tcase WSAEINVAL: return \"WSAEINVAL\";\n\tcase WSAEMFILE: return \"WSAEMFILE\";\n\tcase WSAEWOULDBLOCK: return \"WSAEWOULDBLOCK\";\n\tcase WSAEINPROGRESS: return \"WSAEINPROGRESS\";\n\tcase WSAEALREADY: return \"WSAEALREADY\";\n\tcase WSAENOTSOCK: return \"WSAENOTSOCK\";\n\tcase WSAEDESTADDRREQ: return \"WSAEDESTADDRREQ\";\n\tcase WSAEMSGSIZE: return \"WSAEMSGSIZE\";\n\tcase WSAEPROTOTYPE: return \"WSAEPROTOTYPE\";\n\tcase WSAENOPROTOOPT: return \"WSAENOPROTOOPT\";\n\tcase WSAEPROTONOSUPPORT: return \"WSAEPROTONOSUPPORT\";\n\tcase WSAESOCKTNOSUPPORT: return \"WSAESOCKTNOSUPPORT\";\n\tcase WSAEOPNOTSUPP: return \"WSAEOPNOTSUPP\";\n\tcase WSAEPFNOSUPPORT: return \"WSAEPFNOSUPPORT\";\n\tcase WSAEAFNOSUPPORT: return \"WSAEAFNOSUPPORT\";\n\tcase WSAEADDRINUSE: return \"WSAEADDRINUSE\";\n\tcase WSAEADDRNOTAVAIL: return \"WSAEADDRNOTAVAIL\";\n\tcase WSAENETDOWN: return \"WSAENETDOWN\";\n\tcase WSAENETUNREACH: return \"WSAENETUNREACH\";\n\tcase WSAENETRESET: return \"WSAENETRESET\";\n\tcase WSAECONNABORTED: return \"WSWSAECONNABORTEDAEINTR\";\n\tcase WSAECONNRESET: return \"WSAECONNRESET\";\n\tcase WSAENOBUFS: return \"WSAENOBUFS\";\n\tcase WSAEISCONN: return \"WSAEISCONN\";\n\tcase WSAENOTCONN: return \"WSAENOTCONN\";\n\tcase WSAESHUTDOWN: return \"WSAESHUTDOWN\";\n\tcase WSAETOOMANYREFS: return \"WSAETOOMANYREFS\";\n\tcase WSAETIMEDOUT: return \"WSAETIMEDOUT\";\n\tcase WSAECONNREFUSED: return \"WSAECONNREFUSED\";\n\tcase WSAELOOP: return \"WSAELOOP\";\n\tcase WSAENAMETOOLONG: return \"WSAENAMETOOLONG\";\n\tcase WSAEHOSTDOWN: return \"WSAEHOSTDOWN\";\n\tcase WSASYSNOTREADY: return \"WSASYSNOTREADY\";\n\tcase WSAVERNOTSUPPORTED: return \"WSAVERNOTSUPPORTED\";\n\tcase WSANOTINITIALISED: return \"WSANOTINITIALISED\";\n\tcase WSAHOST_NOT_FOUND: return \"WSAHOST_NOT_FOUND\";\n\tcase WSATRY_AGAIN: return \"WSATRY_AGAIN\";\n\tcase WSANO_RECOVERY: return \"WSANO_RECOVERY\";\n\tcase WSANO_DATA: return \"WSANO_DATA\";\n\tdefault: return \"NO ERROR\";\n\t}\n}\n\nvoid NetadrToSockadr( netadr_t *a, struct sockaddr *s ) {\n\tmemset( s, 0, sizeof(*s) );\n\n\tif( a->type == NA_BROADCAST ) {\n\t\t((struct sockaddr_in *)s)->sin_family = AF_INET;\n\t\t((struct sockaddr_in *)s)->sin_port = a->port;\n\t\t((struct sockaddr_in *)s)->sin_addr.s_addr = INADDR_BROADCAST;\n\t}\n\telse if( a->type == NA_IP ) {\n\t\t((struct sockaddr_in *)s)->sin_family = AF_INET;\n\t\t((struct sockaddr_in *)s)->sin_addr.s_addr = *(int *)&a->ip;\n\t\t((struct sockaddr_in *)s)->sin_port = a->port;\n\t}\n\telse if( a->type == NA_IPX ) {\n\t\t((struct sockaddr_ipx *)s)->sa_family = AF_IPX;\n\t\tmemcpy( ((struct sockaddr_ipx *)s)->sa_netnum, &a->ipx[0], 4 );\n\t\tmemcpy( ((struct sockaddr_ipx *)s)->sa_nodenum, &a->ipx[4], 6 );\n\t\t((struct sockaddr_ipx *)s)->sa_socket = a->port;\n\t}\n\telse if( a->type == NA_BROADCAST_IPX ) {\n\t\t((struct sockaddr_ipx *)s)->sa_family = AF_IPX;\n\t\tmemset( ((struct sockaddr_ipx *)s)->sa_netnum, 0, 4 );\n\t\tmemset( ((struct sockaddr_ipx *)s)->sa_nodenum, 0xff, 6 );\n\t\t((struct sockaddr_ipx *)s)->sa_socket = a->port;\n\t}\n}\n\n\nvoid SockadrToNetadr( struct sockaddr *s, netadr_t *a ) {\n\tif (s->sa_family == AF_INET) {\n\t\ta->type = NA_IP;\n\t\t*(int *)&a->ip = ((struct sockaddr_in *)s)->sin_addr.s_addr;\n\t\ta->port = ((struct sockaddr_in *)s)->sin_port;\n\t}\n\telse if( s->sa_family == AF_IPX ) {\n\t\ta->type = NA_IPX;\n\t\tmemcpy( &a->ipx[0], ((struct sockaddr_ipx *)s)->sa_netnum, 4 );\n\t\tmemcpy( &a->ipx[4], ((struct sockaddr_ipx *)s)->sa_nodenum, 6 );\n\t\ta->port = ((struct sockaddr_ipx *)s)->sa_socket;\n\t}\n}\n\n\n/*\n=============\nSys_StringToAdr\n\nidnewt\n192.246.40.70\n12121212.121212121212\n=============\n*/\n#define DO(src,dest)\t\\\n\tcopy[0] = s[src];\t\\\n\tcopy[1] = s[src + 1];\t\\\n\tsscanf (copy, \"%x\", &val);\t\\\n\t((struct sockaddr_ipx *)sadr)->dest = val\n\nqboolean Sys_StringToSockaddr( const char *s, struct sockaddr *sadr ) {\n\tstruct hostent\t*h;\n\tint\t\tval;\n\tchar\tcopy[MAX_STRING_CHARS];\n\t\n\tmemset( sadr, 0, sizeof( *sadr ) );\n\n\t// check for an IPX address\n\tif( ( strlen( s ) == 21 ) && ( s[8] == '.' ) ) {\n\t\t((struct sockaddr_ipx *)sadr)->sa_family = AF_IPX;\n\t\t((struct sockaddr_ipx *)sadr)->sa_socket = 0;\n\t\tcopy[2] = 0;\n\t\tDO(0, sa_netnum[0]);\n\t\tDO(2, sa_netnum[1]);\n\t\tDO(4, sa_netnum[2]);\n\t\tDO(6, sa_netnum[3]);\n\t\tDO(9, sa_nodenum[0]);\n\t\tDO(11, sa_nodenum[1]);\n\t\tDO(13, sa_nodenum[2]);\n\t\tDO(15, sa_nodenum[3]);\n\t\tDO(17, sa_nodenum[4]);\n\t\tDO(19, sa_nodenum[5]);\n\t}\n\telse {\n\t\t((struct sockaddr_in *)sadr)->sin_family = AF_INET;\n\t\t((struct sockaddr_in *)sadr)->sin_port = 0;\n\n\t\tif( s[0] >= '0' && s[0] <= '9' ) {\n\t\t\t*(int *)&((struct sockaddr_in *)sadr)->sin_addr = inet_addr(s);\n\t\t} else {\n\t\t\tif( ( h = gethostbyname( s ) ) == 0 ) {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\t*(int *)&((struct sockaddr_in *)sadr)->sin_addr = *(int *)h->h_addr_list[0];\n\t\t}\n\t}\n\t\n\treturn qtrue;\n}\n\n#undef DO\n\n/*\n=============\nSys_StringToAdr\n\nidnewt\n192.246.40.70\n=============\n*/\nqboolean Sys_StringToAdr( const char *s, netadr_t *a ) {\n\tstruct sockaddr sadr;\n\t\n\tif ( !Sys_StringToSockaddr( s, &sadr ) ) {\n\t\treturn qfalse;\n\t}\n\t\n\tSockadrToNetadr( &sadr, a );\n\treturn qtrue;\n}\n\n//=============================================================================\n\n/*\n==================\nSys_GetPacket\n\nNever called by the game logic, just the system event queing\n==================\n*/\nint\trecvfromCount;\n\nqboolean Sys_GetPacket( netadr_t *net_from, msg_t *net_message ) {\n\tint \tret;\n\tstruct sockaddr from;\n\tint\t\tfromlen;\n\tint\t\tnet_socket;\n\tint\t\tprotocol;\n\tint\t\terr;\n\n\tfor( protocol = 0 ; protocol < 2 ; protocol++ )\t{\n\t\tif( protocol == 0 ) {\n\t\t\tnet_socket = ip_socket;\n\t\t}\n\t\telse {\n\t\t\tnet_socket = ipx_socket;\n\t\t}\n\n\t\tif( !net_socket ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tfromlen = sizeof(from);\n\t\trecvfromCount++;\t\t// performance check\n\t\tret = recvfrom( net_socket, net_message->data, net_message->maxsize, 0, (struct sockaddr *)&from, &fromlen );\n\t\tif (ret == SOCKET_ERROR)\n\t\t{\n\t\t\terr = WSAGetLastError();\n\n\t\t\tif( err == WSAEWOULDBLOCK || err == WSAECONNRESET ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tCom_Printf( \"NET_GetPacket: %s\\n\", NET_ErrorString() );\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( net_socket == ip_socket ) {\n\t\t\tmemset( ((struct sockaddr_in *)&from)->sin_zero, 0, 8 );\n\t\t}\n\n\t\tif ( usingSocks && net_socket == ip_socket && memcmp( &from, &socksRelayAddr, fromlen ) == 0 ) {\n\t\t\tif ( ret < 10 || net_message->data[0] != 0 || net_message->data[1] != 0 || net_message->data[2] != 0 || net_message->data[3] != 1 ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tnet_from->type = NA_IP;\n\t\t\tnet_from->ip[0] = net_message->data[4];\n\t\t\tnet_from->ip[1] = net_message->data[5];\n\t\t\tnet_from->ip[2] = net_message->data[6];\n\t\t\tnet_from->ip[3] = net_message->data[7];\n\t\t\tnet_from->port = *(short *)&net_message->data[8];\n\t\t\tnet_message->readcount = 10;\n\t\t}\n\t\telse {\n\t\t\tSockadrToNetadr( &from, net_from );\n\t\t\tnet_message->readcount = 0;\n\t\t}\n\n\t\tif( ret == net_message->maxsize ) {\n\t\t\tCom_Printf( \"Oversize packet from %s\\n\", NET_AdrToString (*net_from) );\n\t\t\tcontinue;\n\t\t}\n\n\t\tnet_message->cursize = ret;\n\t\treturn qtrue;\n\t}\n\n\treturn qfalse;\n}\n\n//=============================================================================\n\nstatic char socksBuf[4096];\n\n/*\n==================\nSys_SendPacket\n==================\n*/\nvoid Sys_SendPacket( int length, const void *data, netadr_t to ) {\n\tint\t\t\t\tret;\n\tstruct sockaddr\taddr;\n\tSOCKET\t\t\tnet_socket;\n\n\tif( to.type == NA_BROADCAST ) {\n\t\tnet_socket = ip_socket;\n\t}\n\telse if( to.type == NA_IP ) {\n\t\tnet_socket = ip_socket;\n\t}\n\telse if( to.type == NA_IPX ) {\n\t\tnet_socket = ipx_socket;\n\t}\n\telse if( to.type == NA_BROADCAST_IPX ) {\n\t\tnet_socket = ipx_socket;\n\t}\n\telse {\n\t\tCom_Error( ERR_FATAL, \"Sys_SendPacket: bad address type\" );\n\t\treturn;\n\t}\n\n\tif( !net_socket ) {\n\t\treturn;\n\t}\n\n\tNetadrToSockadr( &to, &addr );\n\n\tif( usingSocks && to.type == NA_IP ) {\n\t\tsocksBuf[0] = 0;\t// reserved\n\t\tsocksBuf[1] = 0;\n\t\tsocksBuf[2] = 0;\t// fragment (not fragmented)\n\t\tsocksBuf[3] = 1;\t// address type: IPV4\n\t\t*(int *)&socksBuf[4] = ((struct sockaddr_in *)&addr)->sin_addr.s_addr;\n\t\t*(short *)&socksBuf[8] = ((struct sockaddr_in *)&addr)->sin_port;\n\t\tmemcpy( &socksBuf[10], data, length );\n\t\tret = sendto( net_socket, socksBuf, length+10, 0, &socksRelayAddr, sizeof(socksRelayAddr) );\n\t}\n\telse {\n\t\tret = sendto( net_socket, data, length, 0, &addr, sizeof(addr) );\n\t}\n\tif( ret == SOCKET_ERROR ) {\n\t\tint err = WSAGetLastError();\n\n\t\t// wouldblock is silent\n\t\tif( err == WSAEWOULDBLOCK ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// some PPP links do not allow broadcasts and return an error\n\t\tif( ( err == WSAEADDRNOTAVAIL ) && ( ( to.type == NA_BROADCAST ) || ( to.type == NA_BROADCAST_IPX ) ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tCom_Printf( \"NET_SendPacket: %s\\n\", NET_ErrorString() );\n\t}\n}\n\n\n//=============================================================================\n\n/*\n==================\nSys_IsLANAddress\n\nLAN clients will have their rate var ignored\n==================\n*/\nqboolean Sys_IsLANAddress( netadr_t adr ) {\n\tint\t\ti;\n\n\tif( adr.type == NA_LOOPBACK ) {\n\t\treturn qtrue;\n\t}\n\n\tif( adr.type == NA_IPX ) {\n\t\treturn qtrue;\n\t}\n\n\tif( adr.type != NA_IP ) {\n\t\treturn qfalse;\n\t}\n\n\t// choose which comparison to use based on the class of the address being tested\n\t// any local adresses of a different class than the address being tested will fail based on the first byte\n\n\tif( adr.ip[0] == 127 && adr.ip[1] == 0 && adr.ip[2] == 0 && adr.ip[3] == 1 ) {\n\t\treturn qtrue;\n\t}\n\n\t// Class A\n\tif( (adr.ip[0] & 0x80) == 0x00 ) {\n\t\tfor ( i = 0 ; i < numIP ; i++ ) {\n\t\t\tif( adr.ip[0] == localIP[i][0] ) {\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t}\n\t\t// the RFC1918 class a block will pass the above test\n\t\treturn qfalse;\n\t}\n\n\t// Class B\n\tif( (adr.ip[0] & 0xc0) == 0x80 ) {\n\t\tfor ( i = 0 ; i < numIP ; i++ ) {\n\t\t\tif( adr.ip[0] == localIP[i][0] && adr.ip[1] == localIP[i][1] ) {\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t\t// also check against the RFC1918 class b blocks\n\t\t\tif( adr.ip[0] == 172 && localIP[i][0] == 172 && (adr.ip[1] & 0xf0) == 16 && (localIP[i][1] & 0xf0) == 16 ) {\n\t\t\t\treturn qtrue;\n\t\t\t}\n\t\t}\n\t\treturn qfalse;\n\t}\n\n\t// Class C\n\tfor ( i = 0 ; i < numIP ; i++ ) {\n\t\tif( adr.ip[0] == localIP[i][0] && adr.ip[1] == localIP[i][1] && adr.ip[2] == localIP[i][2] ) {\n\t\t\treturn qtrue;\n\t\t}\n\t\t// also check against the RFC1918 class c blocks\n\t\tif( adr.ip[0] == 192 && localIP[i][0] == 192 && adr.ip[1] == 168 && localIP[i][1] == 168 ) {\n\t\t\treturn qtrue;\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n/*\n==================\nSys_ShowIP\n==================\n*/\nvoid Sys_ShowIP(void) {\n\tint i;\n\n\tfor (i = 0; i < numIP; i++) {\n\t\tCom_Printf( \"IP: %i.%i.%i.%i\\n\", localIP[i][0], localIP[i][1], localIP[i][2], localIP[i][3] );\n\t}\n}\n\n\n//=============================================================================\n\n\n/*\n====================\nNET_IPSocket\n====================\n*/\nint NET_IPSocket( char *net_interface, int port ) {\n\tSOCKET\t\t\t\tnewsocket;\n\tstruct sockaddr_in\taddress;\n\tqboolean\t\t\t_true = qtrue;\n\tint\t\t\t\t\ti = 1;\n\tint\t\t\t\t\terr;\n\n\tif( net_interface ) {\n\t\tCom_Printf( \"Opening IP socket: %s:%i\\n\", net_interface, port );\n\t}\n\telse {\n\t\tCom_Printf( \"Opening IP socket: localhost:%i\\n\", port );\n\t}\n\n\tif( ( newsocket = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP ) ) == INVALID_SOCKET ) {\n\t\terr = WSAGetLastError();\n\t\tif( err != WSAEAFNOSUPPORT ) {\n\t\t\tCom_Printf( \"WARNING: UDP_OpenSocket: socket: %s\\n\", NET_ErrorString() );\n\t\t}\n\t\treturn 0;\n\t}\n\n\t// make it non-blocking\n\tif( ioctlsocket( newsocket, FIONBIO, &_true ) == SOCKET_ERROR ) {\n\t\tCom_Printf( \"WARNING: UDP_OpenSocket: ioctl FIONBIO: %s\\n\", NET_ErrorString() );\n\t\treturn 0;\n\t}\n\n\t// make it broadcast capable\n\tif( setsockopt( newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&i, sizeof(i) ) == SOCKET_ERROR ) {\n\t\tCom_Printf( \"WARNING: UDP_OpenSocket: setsockopt SO_BROADCAST: %s\\n\", NET_ErrorString() );\n\t\treturn 0;\n\t}\n\n\tif( !net_interface || !net_interface[0] || !Q_stricmp(net_interface, \"localhost\") ) {\n\t\taddress.sin_addr.s_addr = INADDR_ANY;\n\t}\n\telse {\n\t\tSys_StringToSockaddr( net_interface, (struct sockaddr *)&address );\n\t}\n\n\tif( port == PORT_ANY ) {\n\t\taddress.sin_port = 0;\n\t}\n\telse {\n\t\taddress.sin_port = htons( (short)port );\n\t}\n\n\taddress.sin_family = AF_INET;\n\n\tif( bind( newsocket, (void *)&address, sizeof(address) ) == SOCKET_ERROR ) {\n\t\tCom_Printf( \"WARNING: UDP_OpenSocket: bind: %s\\n\", NET_ErrorString() );\n\t\tclosesocket( newsocket );\n\t\treturn 0;\n\t}\n\n\treturn newsocket;\n}\n\n\n/*\n====================\nNET_OpenSocks\n====================\n*/\nvoid NET_OpenSocks( int port ) {\n\tstruct sockaddr_in\taddress;\n\tint\t\t\t\t\terr;\n\tstruct hostent\t\t*h;\n\tint\t\t\t\t\tlen;\n\tqboolean\t\t\trfc1929;\n\tunsigned char\t\tbuf[64];\n\n\tusingSocks = qfalse;\n\n\tCom_Printf( \"Opening connection to SOCKS server.\\n\" );\n\n\tif ( ( socks_socket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ) ) == INVALID_SOCKET ) {\n\t\terr = WSAGetLastError();\n\t\tCom_Printf( \"WARNING: NET_OpenSocks: socket: %s\\n\", NET_ErrorString() );\n\t\treturn;\n\t}\n\n\th = gethostbyname( net_socksServer->string );\n\tif ( h == NULL ) {\n\t\terr = WSAGetLastError();\n\t\tCom_Printf( \"WARNING: NET_OpenSocks: gethostbyname: %s\\n\", NET_ErrorString() );\n\t\treturn;\n\t}\n\tif ( h->h_addrtype != AF_INET ) {\n\t\tCom_Printf( \"WARNING: NET_OpenSocks: gethostbyname: address type was not AF_INET\\n\" );\n\t\treturn;\n\t}\n\taddress.sin_family = AF_INET;\n\taddress.sin_addr.s_addr = *(int *)h->h_addr_list[0];\n\taddress.sin_port = htons( (short)net_socksPort->integer );\n\n\tif ( connect( socks_socket, (struct sockaddr *)&address, sizeof( address ) ) == SOCKET_ERROR ) {\n\t\terr = WSAGetLastError();\n\t\tCom_Printf( \"NET_OpenSocks: connect: %s\\n\", NET_ErrorString() );\n\t\treturn;\n\t}\n\n\t// send socks authentication handshake\n\tif ( *net_socksUsername->string || *net_socksPassword->string ) {\n\t\trfc1929 = qtrue;\n\t}\n\telse {\n\t\trfc1929 = qfalse;\n\t}\n\n\tbuf[0] = 5;\t\t// SOCKS version\n\t// method count\n\tif ( rfc1929 ) {\n\t\tbuf[1] = 2;\n\t\tlen = 4;\n\t}\n\telse {\n\t\tbuf[1] = 1;\n\t\tlen = 3;\n\t}\n\tbuf[2] = 0;\t\t// method #1 - method id #00: no authentication\n\tif ( rfc1929 ) {\n\t\tbuf[2] = 2;\t\t// method #2 - method id #02: username/password\n\t}\n\tif ( send( socks_socket, buf, len, 0 ) == SOCKET_ERROR ) {\n\t\terr = WSAGetLastError();\n\t\tCom_Printf( \"NET_OpenSocks: send: %s\\n\", NET_ErrorString() );\n\t\treturn;\n\t}\n\n\t// get the response\n\tlen = recv( socks_socket, buf, 64, 0 );\n\tif ( len == SOCKET_ERROR ) {\n\t\terr = WSAGetLastError();\n\t\tCom_Printf( \"NET_OpenSocks: recv: %s\\n\", NET_ErrorString() );\n\t\treturn;\n\t}\n\tif ( len != 2 || buf[0] != 5 ) {\n\t\tCom_Printf( \"NET_OpenSocks: bad response\\n\" );\n\t\treturn;\n\t}\n\tswitch( buf[1] ) {\n\tcase 0:\t// no authentication\n\t\tbreak;\n\tcase 2: // username/password authentication\n\t\tbreak;\n\tdefault:\n\t\tCom_Printf( \"NET_OpenSocks: request denied\\n\" );\n\t\treturn;\n\t}\n\n\t// do username/password authentication if needed\n\tif ( buf[1] == 2 ) {\n\t\tint\t\tulen;\n\t\tint\t\tplen;\n\n\t\t// build the request\n\t\tulen = strlen( net_socksUsername->string );\n\t\tplen = strlen( net_socksPassword->string );\n\n\t\tbuf[0] = 1;\t\t// username/password authentication version\n\t\tbuf[1] = ulen;\n\t\tif ( ulen ) {\n\t\t\tmemcpy( &buf[2], net_socksUsername->string, ulen );\n\t\t}\n\t\tbuf[2 + ulen] = plen;\n\t\tif ( plen ) {\n\t\t\tmemcpy( &buf[3 + ulen], net_socksPassword->string, plen );\n\t\t}\n\n\t\t// send it\n\t\tif ( send( socks_socket, buf, 3 + ulen + plen, 0 ) == SOCKET_ERROR ) {\n\t\t\terr = WSAGetLastError();\n\t\t\tCom_Printf( \"NET_OpenSocks: send: %s\\n\", NET_ErrorString() );\n\t\t\treturn;\n\t\t}\n\n\t\t// get the response\n\t\tlen = recv( socks_socket, buf, 64, 0 );\n\t\tif ( len == SOCKET_ERROR ) {\n\t\t\terr = WSAGetLastError();\n\t\t\tCom_Printf( \"NET_OpenSocks: recv: %s\\n\", NET_ErrorString() );\n\t\t\treturn;\n\t\t}\n\t\tif ( len != 2 || buf[0] != 1 ) {\n\t\t\tCom_Printf( \"NET_OpenSocks: bad response\\n\" );\n\t\t\treturn;\n\t\t}\n\t\tif ( buf[1] != 0 ) {\n\t\t\tCom_Printf( \"NET_OpenSocks: authentication failed\\n\" );\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// send the UDP associate request\n\tbuf[0] = 5;\t\t// SOCKS version\n\tbuf[1] = 3;\t\t// command: UDP associate\n\tbuf[2] = 0;\t\t// reserved\n\tbuf[3] = 1;\t\t// address type: IPV4\n\t*(int *)&buf[4] = INADDR_ANY;\n\t*(short *)&buf[8] = htons( (short)port );\t\t// port\n\tif ( send( socks_socket, buf, 10, 0 ) == SOCKET_ERROR ) {\n\t\terr = WSAGetLastError();\n\t\tCom_Printf( \"NET_OpenSocks: send: %s\\n\", NET_ErrorString() );\n\t\treturn;\n\t}\n\n\t// get the response\n\tlen = recv( socks_socket, buf, 64, 0 );\n\tif( len == SOCKET_ERROR ) {\n\t\terr = WSAGetLastError();\n\t\tCom_Printf( \"NET_OpenSocks: recv: %s\\n\", NET_ErrorString() );\n\t\treturn;\n\t}\n\tif( len < 2 || buf[0] != 5 ) {\n\t\tCom_Printf( \"NET_OpenSocks: bad response\\n\" );\n\t\treturn;\n\t}\n\t// check completion code\n\tif( buf[1] != 0 ) {\n\t\tCom_Printf( \"NET_OpenSocks: request denied: %i\\n\", buf[1] );\n\t\treturn;\n\t}\n\tif( buf[3] != 1 ) {\n\t\tCom_Printf( \"NET_OpenSocks: relay address is not IPV4: %i\\n\", buf[3] );\n\t\treturn;\n\t}\n\t((struct sockaddr_in *)&socksRelayAddr)->sin_family = AF_INET;\n\t((struct sockaddr_in *)&socksRelayAddr)->sin_addr.s_addr = *(int *)&buf[4];\n\t((struct sockaddr_in *)&socksRelayAddr)->sin_port = *(short *)&buf[8];\n\tmemset( ((struct sockaddr_in *)&socksRelayAddr)->sin_zero, 0, 8 );\n\n\tusingSocks = qtrue;\n}\n\n\n/*\n=====================\nNET_GetLocalAddress\n=====================\n*/\nvoid NET_GetLocalAddress( void ) {\n\tchar\t\t\t\thostname[256];\n\tstruct hostent\t\t*hostInfo;\n\tint\t\t\t\t\terror;\n\tchar\t\t\t\t*p;\n\tint\t\t\t\t\tip;\n\tint\t\t\t\t\tn;\n\n\tif( gethostname( hostname, 256 ) == SOCKET_ERROR ) {\n\t\terror = WSAGetLastError();\n\t\treturn;\n\t}\n\n\thostInfo = gethostbyname( hostname );\n\tif( !hostInfo ) {\n\t\terror = WSAGetLastError();\n\t\treturn;\n\t}\n\n\tCom_Printf( \"Hostname: %s\\n\", hostInfo->h_name );\n\tn = 0;\n\twhile( ( p = hostInfo->h_aliases[n++] ) != NULL ) {\n\t\tCom_Printf( \"Alias: %s\\n\", p );\n\t}\n\n\tif ( hostInfo->h_addrtype != AF_INET ) {\n\t\treturn;\n\t}\n\n\tnumIP = 0;\n\twhile( ( p = hostInfo->h_addr_list[numIP] ) != NULL && numIP < MAX_IPS ) {\n\t\tip = ntohl( *(int *)p );\n\t\tlocalIP[ numIP ][0] = p[0];\n\t\tlocalIP[ numIP ][1] = p[1];\n\t\tlocalIP[ numIP ][2] = p[2];\n\t\tlocalIP[ numIP ][3] = p[3];\n\t\tCom_Printf( \"IP: %i.%i.%i.%i\\n\", ( ip >> 24 ) & 0xff, ( ip >> 16 ) & 0xff, ( ip >> 8 ) & 0xff, ip & 0xff );\n\t\tnumIP++;\n\t}\n}\n\n/*\n====================\nNET_OpenIP\n====================\n*/\nvoid NET_OpenIP( void ) {\n\tcvar_t\t*ip;\n\tint\t\tport;\n\tint\t\ti;\n\n\tip = Cvar_Get( \"net_ip\", \"localhost\", CVAR_LATCH );\n\tport = Cvar_Get( \"net_port\", va( \"%i\", PORT_SERVER ), CVAR_LATCH )->integer;\n\n\t// automatically scan for a valid port, so multiple\n\t// dedicated servers can be started without requiring\n\t// a different net_port for each one\n\tfor( i = 0 ; i < 10 ; i++ ) {\n\t\tip_socket = NET_IPSocket( ip->string, port + i );\n\t\tif ( ip_socket ) {\n\t\t\tCvar_SetValue( \"net_port\", port + i );\n\t\t\tif ( net_socksEnabled->integer ) {\n\t\t\t\tNET_OpenSocks( port + i );\n\t\t\t}\n\t\t\tNET_GetLocalAddress();\n\t\t\treturn;\n\t\t}\n\t}\n\tCom_Printf( \"WARNING: Couldn't allocate IP port\\n\");\n}\n\n\n/*\n====================\nNET_IPXSocket\n====================\n*/\nint NET_IPXSocket( int port ) {\n\tSOCKET\t\t\t\tnewsocket;\n\tstruct sockaddr_ipx\taddress;\n\tint\t\t\t\t\t_true = 1;\n\tint\t\t\t\t\terr;\n\n\tif( ( newsocket = socket( AF_IPX, SOCK_DGRAM, NSPROTO_IPX ) ) == INVALID_SOCKET ) {\n\t\terr = WSAGetLastError();\n\t\tif (err != WSAEAFNOSUPPORT) {\n\t\t\tCom_Printf( \"WARNING: IPX_Socket: socket: %s\\n\", NET_ErrorString() );\n\t\t}\n\t\treturn 0;\n\t}\n\n\t// make it non-blocking\n\tif( ioctlsocket( newsocket, FIONBIO, &_true ) == SOCKET_ERROR ) {\n\t\tCom_Printf( \"WARNING: IPX_Socket: ioctl FIONBIO: %s\\n\", NET_ErrorString() );\n\t\treturn 0;\n\t}\n\n\t// make it broadcast capable\n\tif( setsockopt( newsocket, SOL_SOCKET, SO_BROADCAST, (char *)&_true, sizeof( _true ) ) == SOCKET_ERROR ) {\n\t\tCom_Printf( \"WARNING: IPX_Socket: setsockopt SO_BROADCAST: %s\\n\", NET_ErrorString() );\n\t\treturn 0;\n\t}\n\n\taddress.sa_family = AF_IPX;\n\tmemset( address.sa_netnum, 0, 4 );\n\tmemset( address.sa_nodenum, 0, 6 );\n\tif( port == PORT_ANY ) {\n\t\taddress.sa_socket = 0;\n\t}\n\telse {\n\t\taddress.sa_socket = htons( (short)port );\n\t}\n\n\tif( bind( newsocket, (void *)&address, sizeof(address) ) == SOCKET_ERROR ) {\n\t\tCom_Printf( \"WARNING: IPX_Socket: bind: %s\\n\", NET_ErrorString() );\n\t\tclosesocket( newsocket );\n\t\treturn 0;\n\t}\n\n\treturn newsocket;\n}\n\n\n/*\n====================\nNET_OpenIPX\n====================\n*/\nvoid NET_OpenIPX( void ) {\n\tint\t\tport;\n\n\tport = Cvar_Get( \"net_port\", va( \"%i\", PORT_SERVER ), CVAR_LATCH )->integer;\n\tipx_socket = NET_IPXSocket( port );\n}\n\n\n\n//===================================================================\n\n\n/*\n====================\nNET_GetCvars\n====================\n*/\nstatic qboolean NET_GetCvars( void ) {\n\tqboolean\tmodified;\n\n\tmodified = qfalse;\n\n\tif( net_noudp && net_noudp->modified ) {\n\t\tmodified = qtrue;\n\t}\n\tnet_noudp = Cvar_Get( \"net_noudp\", \"0\", CVAR_LATCH | CVAR_ARCHIVE );\n\n\tif( net_noipx && net_noipx->modified ) {\n\t\tmodified = qtrue;\n\t}\n\tnet_noipx = Cvar_Get( \"net_noipx\", \"0\", CVAR_LATCH | CVAR_ARCHIVE );\n\n\n\tif( net_socksEnabled && net_socksEnabled->modified ) {\n\t\tmodified = qtrue;\n\t}\n\tnet_socksEnabled = Cvar_Get( \"net_socksEnabled\", \"0\", CVAR_LATCH | CVAR_ARCHIVE );\n\n\tif( net_socksServer && net_socksServer->modified ) {\n\t\tmodified = qtrue;\n\t}\n\tnet_socksServer = Cvar_Get( \"net_socksServer\", \"\", CVAR_LATCH | CVAR_ARCHIVE );\n\n\tif( net_socksPort && net_socksPort->modified ) {\n\t\tmodified = qtrue;\n\t}\n\tnet_socksPort = Cvar_Get( \"net_socksPort\", \"1080\", CVAR_LATCH | CVAR_ARCHIVE );\n\n\tif( net_socksUsername && net_socksUsername->modified ) {\n\t\tmodified = qtrue;\n\t}\n\tnet_socksUsername = Cvar_Get( \"net_socksUsername\", \"\", CVAR_LATCH | CVAR_ARCHIVE );\n\n\tif( net_socksPassword && net_socksPassword->modified ) {\n\t\tmodified = qtrue;\n\t}\n\tnet_socksPassword = Cvar_Get( \"net_socksPassword\", \"\", CVAR_LATCH | CVAR_ARCHIVE );\n\n\n\treturn modified;\n}\n\n\n/*\n====================\nNET_Config\n====================\n*/\nvoid NET_Config( qboolean enableNetworking ) {\n\tqboolean\tmodified;\n\tqboolean\tstop;\n\tqboolean\tstart;\n\n\t// get any latched changes to cvars\n\tmodified = NET_GetCvars();\n\n\tif( net_noudp->integer && net_noipx->integer ) {\n\t\tenableNetworking = qfalse;\n\t}\n\n\t// if enable state is the same and no cvars were modified, we have nothing to do\n\tif( enableNetworking == networkingEnabled && !modified ) {\n\t\treturn;\n\t}\n\n\tif( enableNetworking == networkingEnabled ) {\n\t\tif( enableNetworking ) {\n\t\t\tstop = qtrue;\n\t\t\tstart = qtrue;\n\t\t}\n\t\telse {\n\t\t\tstop = qfalse;\n\t\t\tstart = qfalse;\n\t\t}\n\t}\n\telse {\n\t\tif( enableNetworking ) {\n\t\t\tstop = qfalse;\n\t\t\tstart = qtrue;\n\t\t}\n\t\telse {\n\t\t\tstop = qtrue;\n\t\t\tstart = qfalse;\n\t\t}\n\t\tnetworkingEnabled = enableNetworking;\n\t}\n\n\tif( stop ) {\n\t\tif ( ip_socket && ip_socket != INVALID_SOCKET ) {\n\t\t\tclosesocket( ip_socket );\n\t\t\tip_socket = 0;\n\t\t}\n\n\t\tif ( socks_socket && socks_socket != INVALID_SOCKET ) {\n\t\t\tclosesocket( socks_socket );\n\t\t\tsocks_socket = 0;\n\t\t}\n\n\t\tif ( ipx_socket && ipx_socket != INVALID_SOCKET ) {\n\t\t\tclosesocket( ipx_socket );\n\t\t\tipx_socket = 0;\n\t\t}\n\t}\n\n\tif( start ) {\n\t\tif (! net_noudp->integer ) {\n\t\t\tNET_OpenIP();\n\t\t}\n\t\tif (! net_noipx->integer ) {\n\t\t\tNET_OpenIPX();\n\t\t}\n\t}\n}\n\n\n/*\n====================\nNET_Init\n====================\n*/\nvoid NET_Init( void ) {\n\tint\t\tr;\n\n\tr = WSAStartup( MAKEWORD( 1, 1 ), &winsockdata );\n\tif( r ) {\n\t\tCom_Printf( \"WARNING: Winsock initialization failed, returned %d\\n\", r );\n\t\treturn;\n\t}\n\n\twinsockInitialized = qtrue;\n\tCom_Printf( \"Winsock Initialized\\n\" );\n\n\t// this is really just to get the cvars registered\n\tNET_GetCvars();\n\n\t//FIXME testing!\n\tNET_Config( qtrue );\n}\n\n\n/*\n====================\nNET_Shutdown\n====================\n*/\nvoid NET_Shutdown( void ) {\n\tif ( !winsockInitialized ) {\n\t\treturn;\n\t}\n\tNET_Config( qfalse );\n\tWSACleanup();\n\twinsockInitialized = qfalse;\n}\n\n\n/*\n====================\nNET_Sleep\n\nsleeps msec or until net socket is ready\n====================\n*/\nvoid NET_Sleep( int msec ) {\n}\n\n\n/*\n====================\nNET_Restart_f\n====================\n*/\nvoid NET_Restart( void ) {\n\tNET_Config( networkingEnabled );\n}\n"
  },
  {
    "path": "code/win32/win_qgl.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n/*\n** QGL_WIN.C\n**\n** This file implements the operating system binding of GL to QGL function\n** pointers.  When doing a port of Quake3 you must implement the following\n** two functions:\n**\n** QGL_Init() - loads libraries, assigns function pointers, etc.\n** QGL_Shutdown() - unloads libraries, NULLs function pointers\n*/\n#include <float.h>\n#include \"../renderer/tr_local.h\"\n#include \"glw_win.h\"\n\nvoid QGL_EnableLogging( qboolean enable );\n\nint ( WINAPI * qwglSwapIntervalEXT)( int interval );\nBOOL  ( WINAPI * qwglGetDeviceGammaRamp3DFX)( HDC, LPVOID );\nBOOL  ( WINAPI * qwglSetDeviceGammaRamp3DFX)( HDC, LPVOID );\n\nint   ( WINAPI * qwglChoosePixelFormat )(HDC, CONST PIXELFORMATDESCRIPTOR *);\nint   ( WINAPI * qwglDescribePixelFormat) (HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);\nint   ( WINAPI * qwglGetPixelFormat)(HDC);\nBOOL  ( WINAPI * qwglSetPixelFormat)(HDC, int, CONST PIXELFORMATDESCRIPTOR *);\nBOOL  ( WINAPI * qwglSwapBuffers)(HDC);\n\nBOOL  ( WINAPI * qwglCopyContext)(HGLRC, HGLRC, UINT);\nHGLRC ( WINAPI * qwglCreateContext)(HDC);\nHGLRC ( WINAPI * qwglCreateLayerContext)(HDC, int);\nBOOL  ( WINAPI * qwglDeleteContext)(HGLRC);\nHGLRC ( WINAPI * qwglGetCurrentContext)(VOID);\nHDC   ( WINAPI * qwglGetCurrentDC)(VOID);\nPROC  ( WINAPI * qwglGetProcAddress)(LPCSTR);\nBOOL  ( WINAPI * qwglMakeCurrent)(HDC, HGLRC);\nBOOL  ( WINAPI * qwglShareLists)(HGLRC, HGLRC);\nBOOL  ( WINAPI * qwglUseFontBitmaps)(HDC, DWORD, DWORD, DWORD);\n\nBOOL  ( WINAPI * qwglUseFontOutlines)(HDC, DWORD, DWORD, DWORD, FLOAT,\n                                           FLOAT, int, LPGLYPHMETRICSFLOAT);\n\nBOOL ( WINAPI * qwglDescribeLayerPlane)(HDC, int, int, UINT,\n                                            LPLAYERPLANEDESCRIPTOR);\nint  ( WINAPI * qwglSetLayerPaletteEntries)(HDC, int, int, int,\n                                                CONST COLORREF *);\nint  ( WINAPI * qwglGetLayerPaletteEntries)(HDC, int, int, int,\n                                                COLORREF *);\nBOOL ( WINAPI * qwglRealizeLayerPalette)(HDC, int, BOOL);\nBOOL ( WINAPI * qwglSwapLayerBuffers)(HDC, UINT);\n\nvoid ( APIENTRY * qglAccum )(GLenum op, GLfloat value);\nvoid ( APIENTRY * qglAlphaFunc )(GLenum func, GLclampf ref);\nGLboolean ( APIENTRY * qglAreTexturesResident )(GLsizei n, const GLuint *textures, GLboolean *residences);\nvoid ( APIENTRY * qglArrayElement )(GLint i);\nvoid ( APIENTRY * qglBegin )(GLenum mode);\nvoid ( APIENTRY * qglBindTexture )(GLenum target, GLuint texture);\nvoid ( APIENTRY * qglBitmap )(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);\nvoid ( APIENTRY * qglBlendFunc )(GLenum sfactor, GLenum dfactor);\nvoid ( APIENTRY * qglCallList )(GLuint list);\nvoid ( APIENTRY * qglCallLists )(GLsizei n, GLenum type, const GLvoid *lists);\nvoid ( APIENTRY * qglClear )(GLbitfield mask);\nvoid ( APIENTRY * qglClearAccum )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nvoid ( APIENTRY * qglClearColor )(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);\nvoid ( APIENTRY * qglClearDepth )(GLclampd depth);\nvoid ( APIENTRY * qglClearIndex )(GLfloat c);\nvoid ( APIENTRY * qglClearStencil )(GLint s);\nvoid ( APIENTRY * qglClipPlane )(GLenum plane, const GLdouble *equation);\nvoid ( APIENTRY * qglColor3b )(GLbyte red, GLbyte green, GLbyte blue);\nvoid ( APIENTRY * qglColor3bv )(const GLbyte *v);\nvoid ( APIENTRY * qglColor3d )(GLdouble red, GLdouble green, GLdouble blue);\nvoid ( APIENTRY * qglColor3dv )(const GLdouble *v);\nvoid ( APIENTRY * qglColor3f )(GLfloat red, GLfloat green, GLfloat blue);\nvoid ( APIENTRY * qglColor3fv )(const GLfloat *v);\nvoid ( APIENTRY * qglColor3i )(GLint red, GLint green, GLint blue);\nvoid ( APIENTRY * qglColor3iv )(const GLint *v);\nvoid ( APIENTRY * qglColor3s )(GLshort red, GLshort green, GLshort blue);\nvoid ( APIENTRY * qglColor3sv )(const GLshort *v);\nvoid ( APIENTRY * qglColor3ub )(GLubyte red, GLubyte green, GLubyte blue);\nvoid ( APIENTRY * qglColor3ubv )(const GLubyte *v);\nvoid ( APIENTRY * qglColor3ui )(GLuint red, GLuint green, GLuint blue);\nvoid ( APIENTRY * qglColor3uiv )(const GLuint *v);\nvoid ( APIENTRY * qglColor3us )(GLushort red, GLushort green, GLushort blue);\nvoid ( APIENTRY * qglColor3usv )(const GLushort *v);\nvoid ( APIENTRY * qglColor4b )(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha);\nvoid ( APIENTRY * qglColor4bv )(const GLbyte *v);\nvoid ( APIENTRY * qglColor4d )(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);\nvoid ( APIENTRY * qglColor4dv )(const GLdouble *v);\nvoid ( APIENTRY * qglColor4f )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nvoid ( APIENTRY * qglColor4fv )(const GLfloat *v);\nvoid ( APIENTRY * qglColor4i )(GLint red, GLint green, GLint blue, GLint alpha);\nvoid ( APIENTRY * qglColor4iv )(const GLint *v);\nvoid ( APIENTRY * qglColor4s )(GLshort red, GLshort green, GLshort blue, GLshort alpha);\nvoid ( APIENTRY * qglColor4sv )(const GLshort *v);\nvoid ( APIENTRY * qglColor4ub )(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);\nvoid ( APIENTRY * qglColor4ubv )(const GLubyte *v);\nvoid ( APIENTRY * qglColor4ui )(GLuint red, GLuint green, GLuint blue, GLuint alpha);\nvoid ( APIENTRY * qglColor4uiv )(const GLuint *v);\nvoid ( APIENTRY * qglColor4us )(GLushort red, GLushort green, GLushort blue, GLushort alpha);\nvoid ( APIENTRY * qglColor4usv )(const GLushort *v);\nvoid ( APIENTRY * qglColorMask )(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);\nvoid ( APIENTRY * qglColorMaterial )(GLenum face, GLenum mode);\nvoid ( APIENTRY * qglColorPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglCopyPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);\nvoid ( APIENTRY * qglCopyTexImage1D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border);\nvoid ( APIENTRY * qglCopyTexImage2D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\nvoid ( APIENTRY * qglCopyTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\nvoid ( APIENTRY * qglCopyTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nvoid ( APIENTRY * qglCullFace )(GLenum mode);\nvoid ( APIENTRY * qglDeleteLists )(GLuint list, GLsizei range);\nvoid ( APIENTRY * qglDeleteTextures )(GLsizei n, const GLuint *textures);\nvoid ( APIENTRY * qglDepthFunc )(GLenum func);\nvoid ( APIENTRY * qglDepthMask )(GLboolean flag);\nvoid ( APIENTRY * qglDepthRange )(GLclampd zNear, GLclampd zFar);\nvoid ( APIENTRY * qglDisable )(GLenum cap);\nvoid ( APIENTRY * qglDisableClientState )(GLenum array);\nvoid ( APIENTRY * qglDrawArrays )(GLenum mode, GLint first, GLsizei count);\nvoid ( APIENTRY * qglDrawBuffer )(GLenum mode);\nvoid ( APIENTRY * qglDrawElements )(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);\nvoid ( APIENTRY * qglDrawPixels )(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nvoid ( APIENTRY * qglEdgeFlag )(GLboolean flag);\nvoid ( APIENTRY * qglEdgeFlagPointer )(GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglEdgeFlagv )(const GLboolean *flag);\nvoid ( APIENTRY * qglEnable )(GLenum cap);\nvoid ( APIENTRY * qglEnableClientState )(GLenum array);\nvoid ( APIENTRY * qglEnd )(void);\nvoid ( APIENTRY * qglEndList )(void);\nvoid ( APIENTRY * qglEvalCoord1d )(GLdouble u);\nvoid ( APIENTRY * qglEvalCoord1dv )(const GLdouble *u);\nvoid ( APIENTRY * qglEvalCoord1f )(GLfloat u);\nvoid ( APIENTRY * qglEvalCoord1fv )(const GLfloat *u);\nvoid ( APIENTRY * qglEvalCoord2d )(GLdouble u, GLdouble v);\nvoid ( APIENTRY * qglEvalCoord2dv )(const GLdouble *u);\nvoid ( APIENTRY * qglEvalCoord2f )(GLfloat u, GLfloat v);\nvoid ( APIENTRY * qglEvalCoord2fv )(const GLfloat *u);\nvoid ( APIENTRY * qglEvalMesh1 )(GLenum mode, GLint i1, GLint i2);\nvoid ( APIENTRY * qglEvalMesh2 )(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);\nvoid ( APIENTRY * qglEvalPoint1 )(GLint i);\nvoid ( APIENTRY * qglEvalPoint2 )(GLint i, GLint j);\nvoid ( APIENTRY * qglFeedbackBuffer )(GLsizei size, GLenum type, GLfloat *buffer);\nvoid ( APIENTRY * qglFinish )(void);\nvoid ( APIENTRY * qglFlush )(void);\nvoid ( APIENTRY * qglFogf )(GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglFogfv )(GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglFogi )(GLenum pname, GLint param);\nvoid ( APIENTRY * qglFogiv )(GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglFrontFace )(GLenum mode);\nvoid ( APIENTRY * qglFrustum )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nGLuint ( APIENTRY * qglGenLists )(GLsizei range);\nvoid ( APIENTRY * qglGenTextures )(GLsizei n, GLuint *textures);\nvoid ( APIENTRY * qglGetBooleanv )(GLenum pname, GLboolean *params);\nvoid ( APIENTRY * qglGetClipPlane )(GLenum plane, GLdouble *equation);\nvoid ( APIENTRY * qglGetDoublev )(GLenum pname, GLdouble *params);\nGLenum ( APIENTRY * qglGetError )(void);\nvoid ( APIENTRY * qglGetFloatv )(GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetIntegerv )(GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetLightfv )(GLenum light, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetLightiv )(GLenum light, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetMapdv )(GLenum target, GLenum query, GLdouble *v);\nvoid ( APIENTRY * qglGetMapfv )(GLenum target, GLenum query, GLfloat *v);\nvoid ( APIENTRY * qglGetMapiv )(GLenum target, GLenum query, GLint *v);\nvoid ( APIENTRY * qglGetMaterialfv )(GLenum face, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetMaterialiv )(GLenum face, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetPixelMapfv )(GLenum map, GLfloat *values);\nvoid ( APIENTRY * qglGetPixelMapuiv )(GLenum map, GLuint *values);\nvoid ( APIENTRY * qglGetPixelMapusv )(GLenum map, GLushort *values);\nvoid ( APIENTRY * qglGetPointerv )(GLenum pname, GLvoid* *params);\nvoid ( APIENTRY * qglGetPolygonStipple )(GLubyte *mask);\nconst GLubyte * ( APIENTRY * qglGetString )(GLenum name);\nvoid ( APIENTRY * qglGetTexEnvfv )(GLenum target, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetTexEnviv )(GLenum target, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetTexGendv )(GLenum coord, GLenum pname, GLdouble *params);\nvoid ( APIENTRY * qglGetTexGenfv )(GLenum coord, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetTexGeniv )(GLenum coord, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetTexImage )(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);\nvoid ( APIENTRY * qglGetTexLevelParameterfv )(GLenum target, GLint level, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetTexLevelParameteriv )(GLenum target, GLint level, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetTexParameterfv )(GLenum target, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetTexParameteriv )(GLenum target, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglHint )(GLenum target, GLenum mode);\nvoid ( APIENTRY * qglIndexMask )(GLuint mask);\nvoid ( APIENTRY * qglIndexPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglIndexd )(GLdouble c);\nvoid ( APIENTRY * qglIndexdv )(const GLdouble *c);\nvoid ( APIENTRY * qglIndexf )(GLfloat c);\nvoid ( APIENTRY * qglIndexfv )(const GLfloat *c);\nvoid ( APIENTRY * qglIndexi )(GLint c);\nvoid ( APIENTRY * qglIndexiv )(const GLint *c);\nvoid ( APIENTRY * qglIndexs )(GLshort c);\nvoid ( APIENTRY * qglIndexsv )(const GLshort *c);\nvoid ( APIENTRY * qglIndexub )(GLubyte c);\nvoid ( APIENTRY * qglIndexubv )(const GLubyte *c);\nvoid ( APIENTRY * qglInitNames )(void);\nvoid ( APIENTRY * qglInterleavedArrays )(GLenum format, GLsizei stride, const GLvoid *pointer);\nGLboolean ( APIENTRY * qglIsEnabled )(GLenum cap);\nGLboolean ( APIENTRY * qglIsList )(GLuint list);\nGLboolean ( APIENTRY * qglIsTexture )(GLuint texture);\nvoid ( APIENTRY * qglLightModelf )(GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglLightModelfv )(GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglLightModeli )(GLenum pname, GLint param);\nvoid ( APIENTRY * qglLightModeliv )(GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglLightf )(GLenum light, GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglLightfv )(GLenum light, GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglLighti )(GLenum light, GLenum pname, GLint param);\nvoid ( APIENTRY * qglLightiv )(GLenum light, GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglLineStipple )(GLint factor, GLushort pattern);\nvoid ( APIENTRY * qglLineWidth )(GLfloat width);\nvoid ( APIENTRY * qglListBase )(GLuint base);\nvoid ( APIENTRY * qglLoadIdentity )(void);\nvoid ( APIENTRY * qglLoadMatrixd )(const GLdouble *m);\nvoid ( APIENTRY * qglLoadMatrixf )(const GLfloat *m);\nvoid ( APIENTRY * qglLoadName )(GLuint name);\nvoid ( APIENTRY * qglLogicOp )(GLenum opcode);\nvoid ( APIENTRY * qglMap1d )(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);\nvoid ( APIENTRY * qglMap1f )(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);\nvoid ( APIENTRY * qglMap2d )(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);\nvoid ( APIENTRY * qglMap2f )(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);\nvoid ( APIENTRY * qglMapGrid1d )(GLint un, GLdouble u1, GLdouble u2);\nvoid ( APIENTRY * qglMapGrid1f )(GLint un, GLfloat u1, GLfloat u2);\nvoid ( APIENTRY * qglMapGrid2d )(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);\nvoid ( APIENTRY * qglMapGrid2f )(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);\nvoid ( APIENTRY * qglMaterialf )(GLenum face, GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglMaterialfv )(GLenum face, GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglMateriali )(GLenum face, GLenum pname, GLint param);\nvoid ( APIENTRY * qglMaterialiv )(GLenum face, GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglMatrixMode )(GLenum mode);\nvoid ( APIENTRY * qglMultMatrixd )(const GLdouble *m);\nvoid ( APIENTRY * qglMultMatrixf )(const GLfloat *m);\nvoid ( APIENTRY * qglNewList )(GLuint list, GLenum mode);\nvoid ( APIENTRY * qglNormal3b )(GLbyte nx, GLbyte ny, GLbyte nz);\nvoid ( APIENTRY * qglNormal3bv )(const GLbyte *v);\nvoid ( APIENTRY * qglNormal3d )(GLdouble nx, GLdouble ny, GLdouble nz);\nvoid ( APIENTRY * qglNormal3dv )(const GLdouble *v);\nvoid ( APIENTRY * qglNormal3f )(GLfloat nx, GLfloat ny, GLfloat nz);\nvoid ( APIENTRY * qglNormal3fv )(const GLfloat *v);\nvoid ( APIENTRY * qglNormal3i )(GLint nx, GLint ny, GLint nz);\nvoid ( APIENTRY * qglNormal3iv )(const GLint *v);\nvoid ( APIENTRY * qglNormal3s )(GLshort nx, GLshort ny, GLshort nz);\nvoid ( APIENTRY * qglNormal3sv )(const GLshort *v);\nvoid ( APIENTRY * qglNormalPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglOrtho )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nvoid ( APIENTRY * qglPassThrough )(GLfloat token);\nvoid ( APIENTRY * qglPixelMapfv )(GLenum map, GLsizei mapsize, const GLfloat *values);\nvoid ( APIENTRY * qglPixelMapuiv )(GLenum map, GLsizei mapsize, const GLuint *values);\nvoid ( APIENTRY * qglPixelMapusv )(GLenum map, GLsizei mapsize, const GLushort *values);\nvoid ( APIENTRY * qglPixelStoref )(GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglPixelStorei )(GLenum pname, GLint param);\nvoid ( APIENTRY * qglPixelTransferf )(GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglPixelTransferi )(GLenum pname, GLint param);\nvoid ( APIENTRY * qglPixelZoom )(GLfloat xfactor, GLfloat yfactor);\nvoid ( APIENTRY * qglPointSize )(GLfloat size);\nvoid ( APIENTRY * qglPolygonMode )(GLenum face, GLenum mode);\nvoid ( APIENTRY * qglPolygonOffset )(GLfloat factor, GLfloat units);\nvoid ( APIENTRY * qglPolygonStipple )(const GLubyte *mask);\nvoid ( APIENTRY * qglPopAttrib )(void);\nvoid ( APIENTRY * qglPopClientAttrib )(void);\nvoid ( APIENTRY * qglPopMatrix )(void);\nvoid ( APIENTRY * qglPopName )(void);\nvoid ( APIENTRY * qglPrioritizeTextures )(GLsizei n, const GLuint *textures, const GLclampf *priorities);\nvoid ( APIENTRY * qglPushAttrib )(GLbitfield mask);\nvoid ( APIENTRY * qglPushClientAttrib )(GLbitfield mask);\nvoid ( APIENTRY * qglPushMatrix )(void);\nvoid ( APIENTRY * qglPushName )(GLuint name);\nvoid ( APIENTRY * qglRasterPos2d )(GLdouble x, GLdouble y);\nvoid ( APIENTRY * qglRasterPos2dv )(const GLdouble *v);\nvoid ( APIENTRY * qglRasterPos2f )(GLfloat x, GLfloat y);\nvoid ( APIENTRY * qglRasterPos2fv )(const GLfloat *v);\nvoid ( APIENTRY * qglRasterPos2i )(GLint x, GLint y);\nvoid ( APIENTRY * qglRasterPos2iv )(const GLint *v);\nvoid ( APIENTRY * qglRasterPos2s )(GLshort x, GLshort y);\nvoid ( APIENTRY * qglRasterPos2sv )(const GLshort *v);\nvoid ( APIENTRY * qglRasterPos3d )(GLdouble x, GLdouble y, GLdouble z);\nvoid ( APIENTRY * qglRasterPos3dv )(const GLdouble *v);\nvoid ( APIENTRY * qglRasterPos3f )(GLfloat x, GLfloat y, GLfloat z);\nvoid ( APIENTRY * qglRasterPos3fv )(const GLfloat *v);\nvoid ( APIENTRY * qglRasterPos3i )(GLint x, GLint y, GLint z);\nvoid ( APIENTRY * qglRasterPos3iv )(const GLint *v);\nvoid ( APIENTRY * qglRasterPos3s )(GLshort x, GLshort y, GLshort z);\nvoid ( APIENTRY * qglRasterPos3sv )(const GLshort *v);\nvoid ( APIENTRY * qglRasterPos4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nvoid ( APIENTRY * qglRasterPos4dv )(const GLdouble *v);\nvoid ( APIENTRY * qglRasterPos4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nvoid ( APIENTRY * qglRasterPos4fv )(const GLfloat *v);\nvoid ( APIENTRY * qglRasterPos4i )(GLint x, GLint y, GLint z, GLint w);\nvoid ( APIENTRY * qglRasterPos4iv )(const GLint *v);\nvoid ( APIENTRY * qglRasterPos4s )(GLshort x, GLshort y, GLshort z, GLshort w);\nvoid ( APIENTRY * qglRasterPos4sv )(const GLshort *v);\nvoid ( APIENTRY * qglReadBuffer )(GLenum mode);\nvoid ( APIENTRY * qglReadPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);\nvoid ( APIENTRY * qglRectd )(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);\nvoid ( APIENTRY * qglRectdv )(const GLdouble *v1, const GLdouble *v2);\nvoid ( APIENTRY * qglRectf )(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);\nvoid ( APIENTRY * qglRectfv )(const GLfloat *v1, const GLfloat *v2);\nvoid ( APIENTRY * qglRecti )(GLint x1, GLint y1, GLint x2, GLint y2);\nvoid ( APIENTRY * qglRectiv )(const GLint *v1, const GLint *v2);\nvoid ( APIENTRY * qglRects )(GLshort x1, GLshort y1, GLshort x2, GLshort y2);\nvoid ( APIENTRY * qglRectsv )(const GLshort *v1, const GLshort *v2);\nGLint ( APIENTRY * qglRenderMode )(GLenum mode);\nvoid ( APIENTRY * qglRotated )(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);\nvoid ( APIENTRY * qglRotatef )(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);\nvoid ( APIENTRY * qglScaled )(GLdouble x, GLdouble y, GLdouble z);\nvoid ( APIENTRY * qglScalef )(GLfloat x, GLfloat y, GLfloat z);\nvoid ( APIENTRY * qglScissor )(GLint x, GLint y, GLsizei width, GLsizei height);\nvoid ( APIENTRY * qglSelectBuffer )(GLsizei size, GLuint *buffer);\nvoid ( APIENTRY * qglShadeModel )(GLenum mode);\nvoid ( APIENTRY * qglStencilFunc )(GLenum func, GLint ref, GLuint mask);\nvoid ( APIENTRY * qglStencilMask )(GLuint mask);\nvoid ( APIENTRY * qglStencilOp )(GLenum fail, GLenum zfail, GLenum zpass);\nvoid ( APIENTRY * qglTexCoord1d )(GLdouble s);\nvoid ( APIENTRY * qglTexCoord1dv )(const GLdouble *v);\nvoid ( APIENTRY * qglTexCoord1f )(GLfloat s);\nvoid ( APIENTRY * qglTexCoord1fv )(const GLfloat *v);\nvoid ( APIENTRY * qglTexCoord1i )(GLint s);\nvoid ( APIENTRY * qglTexCoord1iv )(const GLint *v);\nvoid ( APIENTRY * qglTexCoord1s )(GLshort s);\nvoid ( APIENTRY * qglTexCoord1sv )(const GLshort *v);\nvoid ( APIENTRY * qglTexCoord2d )(GLdouble s, GLdouble t);\nvoid ( APIENTRY * qglTexCoord2dv )(const GLdouble *v);\nvoid ( APIENTRY * qglTexCoord2f )(GLfloat s, GLfloat t);\nvoid ( APIENTRY * qglTexCoord2fv )(const GLfloat *v);\nvoid ( APIENTRY * qglTexCoord2i )(GLint s, GLint t);\nvoid ( APIENTRY * qglTexCoord2iv )(const GLint *v);\nvoid ( APIENTRY * qglTexCoord2s )(GLshort s, GLshort t);\nvoid ( APIENTRY * qglTexCoord2sv )(const GLshort *v);\nvoid ( APIENTRY * qglTexCoord3d )(GLdouble s, GLdouble t, GLdouble r);\nvoid ( APIENTRY * qglTexCoord3dv )(const GLdouble *v);\nvoid ( APIENTRY * qglTexCoord3f )(GLfloat s, GLfloat t, GLfloat r);\nvoid ( APIENTRY * qglTexCoord3fv )(const GLfloat *v);\nvoid ( APIENTRY * qglTexCoord3i )(GLint s, GLint t, GLint r);\nvoid ( APIENTRY * qglTexCoord3iv )(const GLint *v);\nvoid ( APIENTRY * qglTexCoord3s )(GLshort s, GLshort t, GLshort r);\nvoid ( APIENTRY * qglTexCoord3sv )(const GLshort *v);\nvoid ( APIENTRY * qglTexCoord4d )(GLdouble s, GLdouble t, GLdouble r, GLdouble q);\nvoid ( APIENTRY * qglTexCoord4dv )(const GLdouble *v);\nvoid ( APIENTRY * qglTexCoord4f )(GLfloat s, GLfloat t, GLfloat r, GLfloat q);\nvoid ( APIENTRY * qglTexCoord4fv )(const GLfloat *v);\nvoid ( APIENTRY * qglTexCoord4i )(GLint s, GLint t, GLint r, GLint q);\nvoid ( APIENTRY * qglTexCoord4iv )(const GLint *v);\nvoid ( APIENTRY * qglTexCoord4s )(GLshort s, GLshort t, GLshort r, GLshort q);\nvoid ( APIENTRY * qglTexCoord4sv )(const GLshort *v);\nvoid ( APIENTRY * qglTexCoordPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglTexEnvf )(GLenum target, GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglTexEnvfv )(GLenum target, GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglTexEnvi )(GLenum target, GLenum pname, GLint param);\nvoid ( APIENTRY * qglTexEnviv )(GLenum target, GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglTexGend )(GLenum coord, GLenum pname, GLdouble param);\nvoid ( APIENTRY * qglTexGendv )(GLenum coord, GLenum pname, const GLdouble *params);\nvoid ( APIENTRY * qglTexGenf )(GLenum coord, GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglTexGenfv )(GLenum coord, GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglTexGeni )(GLenum coord, GLenum pname, GLint param);\nvoid ( APIENTRY * qglTexGeniv )(GLenum coord, GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglTexImage1D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nvoid ( APIENTRY * qglTexImage2D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nvoid ( APIENTRY * qglTexParameterf )(GLenum target, GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglTexParameterfv )(GLenum target, GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglTexParameteri )(GLenum target, GLenum pname, GLint param);\nvoid ( APIENTRY * qglTexParameteriv )(GLenum target, GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);\nvoid ( APIENTRY * qglTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nvoid ( APIENTRY * qglTranslated )(GLdouble x, GLdouble y, GLdouble z);\nvoid ( APIENTRY * qglTranslatef )(GLfloat x, GLfloat y, GLfloat z);\nvoid ( APIENTRY * qglVertex2d )(GLdouble x, GLdouble y);\nvoid ( APIENTRY * qglVertex2dv )(const GLdouble *v);\nvoid ( APIENTRY * qglVertex2f )(GLfloat x, GLfloat y);\nvoid ( APIENTRY * qglVertex2fv )(const GLfloat *v);\nvoid ( APIENTRY * qglVertex2i )(GLint x, GLint y);\nvoid ( APIENTRY * qglVertex2iv )(const GLint *v);\nvoid ( APIENTRY * qglVertex2s )(GLshort x, GLshort y);\nvoid ( APIENTRY * qglVertex2sv )(const GLshort *v);\nvoid ( APIENTRY * qglVertex3d )(GLdouble x, GLdouble y, GLdouble z);\nvoid ( APIENTRY * qglVertex3dv )(const GLdouble *v);\nvoid ( APIENTRY * qglVertex3f )(GLfloat x, GLfloat y, GLfloat z);\nvoid ( APIENTRY * qglVertex3fv )(const GLfloat *v);\nvoid ( APIENTRY * qglVertex3i )(GLint x, GLint y, GLint z);\nvoid ( APIENTRY * qglVertex3iv )(const GLint *v);\nvoid ( APIENTRY * qglVertex3s )(GLshort x, GLshort y, GLshort z);\nvoid ( APIENTRY * qglVertex3sv )(const GLshort *v);\nvoid ( APIENTRY * qglVertex4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nvoid ( APIENTRY * qglVertex4dv )(const GLdouble *v);\nvoid ( APIENTRY * qglVertex4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nvoid ( APIENTRY * qglVertex4fv )(const GLfloat *v);\nvoid ( APIENTRY * qglVertex4i )(GLint x, GLint y, GLint z, GLint w);\nvoid ( APIENTRY * qglVertex4iv )(const GLint *v);\nvoid ( APIENTRY * qglVertex4s )(GLshort x, GLshort y, GLshort z, GLshort w);\nvoid ( APIENTRY * qglVertex4sv )(const GLshort *v);\nvoid ( APIENTRY * qglVertexPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglViewport )(GLint x, GLint y, GLsizei width, GLsizei height);\n\n\n\nstatic void ( APIENTRY * dllAccum )(GLenum op, GLfloat value);\nstatic void ( APIENTRY * dllAlphaFunc )(GLenum func, GLclampf ref);\nGLboolean ( APIENTRY * dllAreTexturesResident )(GLsizei n, const GLuint *textures, GLboolean *residences);\nstatic void ( APIENTRY * dllArrayElement )(GLint i);\nstatic void ( APIENTRY * dllBegin )(GLenum mode);\nstatic void ( APIENTRY * dllBindTexture )(GLenum target, GLuint texture);\nstatic void ( APIENTRY * dllBitmap )(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);\nstatic void ( APIENTRY * dllBlendFunc )(GLenum sfactor, GLenum dfactor);\nstatic void ( APIENTRY * dllCallList )(GLuint list);\nstatic void ( APIENTRY * dllCallLists )(GLsizei n, GLenum type, const GLvoid *lists);\nstatic void ( APIENTRY * dllClear )(GLbitfield mask);\nstatic void ( APIENTRY * dllClearAccum )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nstatic void ( APIENTRY * dllClearColor )(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);\nstatic void ( APIENTRY * dllClearDepth )(GLclampd depth);\nstatic void ( APIENTRY * dllClearIndex )(GLfloat c);\nstatic void ( APIENTRY * dllClearStencil )(GLint s);\nstatic void ( APIENTRY * dllClipPlane )(GLenum plane, const GLdouble *equation);\nstatic void ( APIENTRY * dllColor3b )(GLbyte red, GLbyte green, GLbyte blue);\nstatic void ( APIENTRY * dllColor3bv )(const GLbyte *v);\nstatic void ( APIENTRY * dllColor3d )(GLdouble red, GLdouble green, GLdouble blue);\nstatic void ( APIENTRY * dllColor3dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllColor3f )(GLfloat red, GLfloat green, GLfloat blue);\nstatic void ( APIENTRY * dllColor3fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllColor3i )(GLint red, GLint green, GLint blue);\nstatic void ( APIENTRY * dllColor3iv )(const GLint *v);\nstatic void ( APIENTRY * dllColor3s )(GLshort red, GLshort green, GLshort blue);\nstatic void ( APIENTRY * dllColor3sv )(const GLshort *v);\nstatic void ( APIENTRY * dllColor3ub )(GLubyte red, GLubyte green, GLubyte blue);\nstatic void ( APIENTRY * dllColor3ubv )(const GLubyte *v);\nstatic void ( APIENTRY * dllColor3ui )(GLuint red, GLuint green, GLuint blue);\nstatic void ( APIENTRY * dllColor3uiv )(const GLuint *v);\nstatic void ( APIENTRY * dllColor3us )(GLushort red, GLushort green, GLushort blue);\nstatic void ( APIENTRY * dllColor3usv )(const GLushort *v);\nstatic void ( APIENTRY * dllColor4b )(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha);\nstatic void ( APIENTRY * dllColor4bv )(const GLbyte *v);\nstatic void ( APIENTRY * dllColor4d )(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);\nstatic void ( APIENTRY * dllColor4dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllColor4f )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nstatic void ( APIENTRY * dllColor4fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllColor4i )(GLint red, GLint green, GLint blue, GLint alpha);\nstatic void ( APIENTRY * dllColor4iv )(const GLint *v);\nstatic void ( APIENTRY * dllColor4s )(GLshort red, GLshort green, GLshort blue, GLshort alpha);\nstatic void ( APIENTRY * dllColor4sv )(const GLshort *v);\nstatic void ( APIENTRY * dllColor4ub )(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);\nstatic void ( APIENTRY * dllColor4ubv )(const GLubyte *v);\nstatic void ( APIENTRY * dllColor4ui )(GLuint red, GLuint green, GLuint blue, GLuint alpha);\nstatic void ( APIENTRY * dllColor4uiv )(const GLuint *v);\nstatic void ( APIENTRY * dllColor4us )(GLushort red, GLushort green, GLushort blue, GLushort alpha);\nstatic void ( APIENTRY * dllColor4usv )(const GLushort *v);\nstatic void ( APIENTRY * dllColorMask )(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);\nstatic void ( APIENTRY * dllColorMaterial )(GLenum face, GLenum mode);\nstatic void ( APIENTRY * dllColorPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nstatic void ( APIENTRY * dllCopyPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);\nstatic void ( APIENTRY * dllCopyTexImage1D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border);\nstatic void ( APIENTRY * dllCopyTexImage2D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\nstatic void ( APIENTRY * dllCopyTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\nstatic void ( APIENTRY * dllCopyTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nstatic void ( APIENTRY * dllCullFace )(GLenum mode);\nstatic void ( APIENTRY * dllDeleteLists )(GLuint list, GLsizei range);\nstatic void ( APIENTRY * dllDeleteTextures )(GLsizei n, const GLuint *textures);\nstatic void ( APIENTRY * dllDepthFunc )(GLenum func);\nstatic void ( APIENTRY * dllDepthMask )(GLboolean flag);\nstatic void ( APIENTRY * dllDepthRange )(GLclampd zNear, GLclampd zFar);\nstatic void ( APIENTRY * dllDisable )(GLenum cap);\nstatic void ( APIENTRY * dllDisableClientState )(GLenum array);\nstatic void ( APIENTRY * dllDrawArrays )(GLenum mode, GLint first, GLsizei count);\nstatic void ( APIENTRY * dllDrawBuffer )(GLenum mode);\nstatic void ( APIENTRY * dllDrawElements )(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);\nstatic void ( APIENTRY * dllDrawPixels )(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nstatic void ( APIENTRY * dllEdgeFlag )(GLboolean flag);\nstatic void ( APIENTRY * dllEdgeFlagPointer )(GLsizei stride, const GLvoid *pointer);\nstatic void ( APIENTRY * dllEdgeFlagv )(const GLboolean *flag);\nstatic void ( APIENTRY * dllEnable )(GLenum cap);\nstatic void ( APIENTRY * dllEnableClientState )(GLenum array);\nstatic void ( APIENTRY * dllEnd )(void);\nstatic void ( APIENTRY * dllEndList )(void);\nstatic void ( APIENTRY * dllEvalCoord1d )(GLdouble u);\nstatic void ( APIENTRY * dllEvalCoord1dv )(const GLdouble *u);\nstatic void ( APIENTRY * dllEvalCoord1f )(GLfloat u);\nstatic void ( APIENTRY * dllEvalCoord1fv )(const GLfloat *u);\nstatic void ( APIENTRY * dllEvalCoord2d )(GLdouble u, GLdouble v);\nstatic void ( APIENTRY * dllEvalCoord2dv )(const GLdouble *u);\nstatic void ( APIENTRY * dllEvalCoord2f )(GLfloat u, GLfloat v);\nstatic void ( APIENTRY * dllEvalCoord2fv )(const GLfloat *u);\nstatic void ( APIENTRY * dllEvalMesh1 )(GLenum mode, GLint i1, GLint i2);\nstatic void ( APIENTRY * dllEvalMesh2 )(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);\nstatic void ( APIENTRY * dllEvalPoint1 )(GLint i);\nstatic void ( APIENTRY * dllEvalPoint2 )(GLint i, GLint j);\nstatic void ( APIENTRY * dllFeedbackBuffer )(GLsizei size, GLenum type, GLfloat *buffer);\nstatic void ( APIENTRY * dllFinish )(void);\nstatic void ( APIENTRY * dllFlush )(void);\nstatic void ( APIENTRY * dllFogf )(GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllFogfv )(GLenum pname, const GLfloat *params);\nstatic void ( APIENTRY * dllFogi )(GLenum pname, GLint param);\nstatic void ( APIENTRY * dllFogiv )(GLenum pname, const GLint *params);\nstatic void ( APIENTRY * dllFrontFace )(GLenum mode);\nstatic void ( APIENTRY * dllFrustum )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nGLuint ( APIENTRY * dllGenLists )(GLsizei range);\nstatic void ( APIENTRY * dllGenTextures )(GLsizei n, GLuint *textures);\nstatic void ( APIENTRY * dllGetBooleanv )(GLenum pname, GLboolean *params);\nstatic void ( APIENTRY * dllGetClipPlane )(GLenum plane, GLdouble *equation);\nstatic void ( APIENTRY * dllGetDoublev )(GLenum pname, GLdouble *params);\nGLenum ( APIENTRY * dllGetError )(void);\nstatic void ( APIENTRY * dllGetFloatv )(GLenum pname, GLfloat *params);\nstatic void ( APIENTRY * dllGetIntegerv )(GLenum pname, GLint *params);\nstatic void ( APIENTRY * dllGetLightfv )(GLenum light, GLenum pname, GLfloat *params);\nstatic void ( APIENTRY * dllGetLightiv )(GLenum light, GLenum pname, GLint *params);\nstatic void ( APIENTRY * dllGetMapdv )(GLenum target, GLenum query, GLdouble *v);\nstatic void ( APIENTRY * dllGetMapfv )(GLenum target, GLenum query, GLfloat *v);\nstatic void ( APIENTRY * dllGetMapiv )(GLenum target, GLenum query, GLint *v);\nstatic void ( APIENTRY * dllGetMaterialfv )(GLenum face, GLenum pname, GLfloat *params);\nstatic void ( APIENTRY * dllGetMaterialiv )(GLenum face, GLenum pname, GLint *params);\nstatic void ( APIENTRY * dllGetPixelMapfv )(GLenum map, GLfloat *values);\nstatic void ( APIENTRY * dllGetPixelMapuiv )(GLenum map, GLuint *values);\nstatic void ( APIENTRY * dllGetPixelMapusv )(GLenum map, GLushort *values);\nstatic void ( APIENTRY * dllGetPointerv )(GLenum pname, GLvoid* *params);\nstatic void ( APIENTRY * dllGetPolygonStipple )(GLubyte *mask);\nconst GLubyte * ( APIENTRY * dllGetString )(GLenum name);\nstatic void ( APIENTRY * dllGetTexEnvfv )(GLenum target, GLenum pname, GLfloat *params);\nstatic void ( APIENTRY * dllGetTexEnviv )(GLenum target, GLenum pname, GLint *params);\nstatic void ( APIENTRY * dllGetTexGendv )(GLenum coord, GLenum pname, GLdouble *params);\nstatic void ( APIENTRY * dllGetTexGenfv )(GLenum coord, GLenum pname, GLfloat *params);\nstatic void ( APIENTRY * dllGetTexGeniv )(GLenum coord, GLenum pname, GLint *params);\nstatic void ( APIENTRY * dllGetTexImage )(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);\nstatic void ( APIENTRY * dllGetTexLevelParameterfv )(GLenum target, GLint level, GLenum pname, GLfloat *params);\nstatic void ( APIENTRY * dllGetTexLevelParameteriv )(GLenum target, GLint level, GLenum pname, GLint *params);\nstatic void ( APIENTRY * dllGetTexParameterfv )(GLenum target, GLenum pname, GLfloat *params);\nstatic void ( APIENTRY * dllGetTexParameteriv )(GLenum target, GLenum pname, GLint *params);\nstatic void ( APIENTRY * dllHint )(GLenum target, GLenum mode);\nstatic void ( APIENTRY * dllIndexMask )(GLuint mask);\nstatic void ( APIENTRY * dllIndexPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);\nstatic void ( APIENTRY * dllIndexd )(GLdouble c);\nstatic void ( APIENTRY * dllIndexdv )(const GLdouble *c);\nstatic void ( APIENTRY * dllIndexf )(GLfloat c);\nstatic void ( APIENTRY * dllIndexfv )(const GLfloat *c);\nstatic void ( APIENTRY * dllIndexi )(GLint c);\nstatic void ( APIENTRY * dllIndexiv )(const GLint *c);\nstatic void ( APIENTRY * dllIndexs )(GLshort c);\nstatic void ( APIENTRY * dllIndexsv )(const GLshort *c);\nstatic void ( APIENTRY * dllIndexub )(GLubyte c);\nstatic void ( APIENTRY * dllIndexubv )(const GLubyte *c);\nstatic void ( APIENTRY * dllInitNames )(void);\nstatic void ( APIENTRY * dllInterleavedArrays )(GLenum format, GLsizei stride, const GLvoid *pointer);\nGLboolean ( APIENTRY * dllIsEnabled )(GLenum cap);\nGLboolean ( APIENTRY * dllIsList )(GLuint list);\nGLboolean ( APIENTRY * dllIsTexture )(GLuint texture);\nstatic void ( APIENTRY * dllLightModelf )(GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllLightModelfv )(GLenum pname, const GLfloat *params);\nstatic void ( APIENTRY * dllLightModeli )(GLenum pname, GLint param);\nstatic void ( APIENTRY * dllLightModeliv )(GLenum pname, const GLint *params);\nstatic void ( APIENTRY * dllLightf )(GLenum light, GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllLightfv )(GLenum light, GLenum pname, const GLfloat *params);\nstatic void ( APIENTRY * dllLighti )(GLenum light, GLenum pname, GLint param);\nstatic void ( APIENTRY * dllLightiv )(GLenum light, GLenum pname, const GLint *params);\nstatic void ( APIENTRY * dllLineStipple )(GLint factor, GLushort pattern);\nstatic void ( APIENTRY * dllLineWidth )(GLfloat width);\nstatic void ( APIENTRY * dllListBase )(GLuint base);\nstatic void ( APIENTRY * dllLoadIdentity )(void);\nstatic void ( APIENTRY * dllLoadMatrixd )(const GLdouble *m);\nstatic void ( APIENTRY * dllLoadMatrixf )(const GLfloat *m);\nstatic void ( APIENTRY * dllLoadName )(GLuint name);\nstatic void ( APIENTRY * dllLogicOp )(GLenum opcode);\nstatic void ( APIENTRY * dllMap1d )(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);\nstatic void ( APIENTRY * dllMap1f )(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);\nstatic void ( APIENTRY * dllMap2d )(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);\nstatic void ( APIENTRY * dllMap2f )(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);\nstatic void ( APIENTRY * dllMapGrid1d )(GLint un, GLdouble u1, GLdouble u2);\nstatic void ( APIENTRY * dllMapGrid1f )(GLint un, GLfloat u1, GLfloat u2);\nstatic void ( APIENTRY * dllMapGrid2d )(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);\nstatic void ( APIENTRY * dllMapGrid2f )(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);\nstatic void ( APIENTRY * dllMaterialf )(GLenum face, GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllMaterialfv )(GLenum face, GLenum pname, const GLfloat *params);\nstatic void ( APIENTRY * dllMateriali )(GLenum face, GLenum pname, GLint param);\nstatic void ( APIENTRY * dllMaterialiv )(GLenum face, GLenum pname, const GLint *params);\nstatic void ( APIENTRY * dllMatrixMode )(GLenum mode);\nstatic void ( APIENTRY * dllMultMatrixd )(const GLdouble *m);\nstatic void ( APIENTRY * dllMultMatrixf )(const GLfloat *m);\nstatic void ( APIENTRY * dllNewList )(GLuint list, GLenum mode);\nstatic void ( APIENTRY * dllNormal3b )(GLbyte nx, GLbyte ny, GLbyte nz);\nstatic void ( APIENTRY * dllNormal3bv )(const GLbyte *v);\nstatic void ( APIENTRY * dllNormal3d )(GLdouble nx, GLdouble ny, GLdouble nz);\nstatic void ( APIENTRY * dllNormal3dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllNormal3f )(GLfloat nx, GLfloat ny, GLfloat nz);\nstatic void ( APIENTRY * dllNormal3fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllNormal3i )(GLint nx, GLint ny, GLint nz);\nstatic void ( APIENTRY * dllNormal3iv )(const GLint *v);\nstatic void ( APIENTRY * dllNormal3s )(GLshort nx, GLshort ny, GLshort nz);\nstatic void ( APIENTRY * dllNormal3sv )(const GLshort *v);\nstatic void ( APIENTRY * dllNormalPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);\nstatic void ( APIENTRY * dllOrtho )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nstatic void ( APIENTRY * dllPassThrough )(GLfloat token);\nstatic void ( APIENTRY * dllPixelMapfv )(GLenum map, GLsizei mapsize, const GLfloat *values);\nstatic void ( APIENTRY * dllPixelMapuiv )(GLenum map, GLsizei mapsize, const GLuint *values);\nstatic void ( APIENTRY * dllPixelMapusv )(GLenum map, GLsizei mapsize, const GLushort *values);\nstatic void ( APIENTRY * dllPixelStoref )(GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllPixelStorei )(GLenum pname, GLint param);\nstatic void ( APIENTRY * dllPixelTransferf )(GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllPixelTransferi )(GLenum pname, GLint param);\nstatic void ( APIENTRY * dllPixelZoom )(GLfloat xfactor, GLfloat yfactor);\nstatic void ( APIENTRY * dllPointSize )(GLfloat size);\nstatic void ( APIENTRY * dllPolygonMode )(GLenum face, GLenum mode);\nstatic void ( APIENTRY * dllPolygonOffset )(GLfloat factor, GLfloat units);\nstatic void ( APIENTRY * dllPolygonStipple )(const GLubyte *mask);\nstatic void ( APIENTRY * dllPopAttrib )(void);\nstatic void ( APIENTRY * dllPopClientAttrib )(void);\nstatic void ( APIENTRY * dllPopMatrix )(void);\nstatic void ( APIENTRY * dllPopName )(void);\nstatic void ( APIENTRY * dllPrioritizeTextures )(GLsizei n, const GLuint *textures, const GLclampf *priorities);\nstatic void ( APIENTRY * dllPushAttrib )(GLbitfield mask);\nstatic void ( APIENTRY * dllPushClientAttrib )(GLbitfield mask);\nstatic void ( APIENTRY * dllPushMatrix )(void);\nstatic void ( APIENTRY * dllPushName )(GLuint name);\nstatic void ( APIENTRY * dllRasterPos2d )(GLdouble x, GLdouble y);\nstatic void ( APIENTRY * dllRasterPos2dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllRasterPos2f )(GLfloat x, GLfloat y);\nstatic void ( APIENTRY * dllRasterPos2fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllRasterPos2i )(GLint x, GLint y);\nstatic void ( APIENTRY * dllRasterPos2iv )(const GLint *v);\nstatic void ( APIENTRY * dllRasterPos2s )(GLshort x, GLshort y);\nstatic void ( APIENTRY * dllRasterPos2sv )(const GLshort *v);\nstatic void ( APIENTRY * dllRasterPos3d )(GLdouble x, GLdouble y, GLdouble z);\nstatic void ( APIENTRY * dllRasterPos3dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllRasterPos3f )(GLfloat x, GLfloat y, GLfloat z);\nstatic void ( APIENTRY * dllRasterPos3fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllRasterPos3i )(GLint x, GLint y, GLint z);\nstatic void ( APIENTRY * dllRasterPos3iv )(const GLint *v);\nstatic void ( APIENTRY * dllRasterPos3s )(GLshort x, GLshort y, GLshort z);\nstatic void ( APIENTRY * dllRasterPos3sv )(const GLshort *v);\nstatic void ( APIENTRY * dllRasterPos4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nstatic void ( APIENTRY * dllRasterPos4dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllRasterPos4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nstatic void ( APIENTRY * dllRasterPos4fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllRasterPos4i )(GLint x, GLint y, GLint z, GLint w);\nstatic void ( APIENTRY * dllRasterPos4iv )(const GLint *v);\nstatic void ( APIENTRY * dllRasterPos4s )(GLshort x, GLshort y, GLshort z, GLshort w);\nstatic void ( APIENTRY * dllRasterPos4sv )(const GLshort *v);\nstatic void ( APIENTRY * dllReadBuffer )(GLenum mode);\nstatic void ( APIENTRY * dllReadPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);\nstatic void ( APIENTRY * dllRectd )(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);\nstatic void ( APIENTRY * dllRectdv )(const GLdouble *v1, const GLdouble *v2);\nstatic void ( APIENTRY * dllRectf )(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);\nstatic void ( APIENTRY * dllRectfv )(const GLfloat *v1, const GLfloat *v2);\nstatic void ( APIENTRY * dllRecti )(GLint x1, GLint y1, GLint x2, GLint y2);\nstatic void ( APIENTRY * dllRectiv )(const GLint *v1, const GLint *v2);\nstatic void ( APIENTRY * dllRects )(GLshort x1, GLshort y1, GLshort x2, GLshort y2);\nstatic void ( APIENTRY * dllRectsv )(const GLshort *v1, const GLshort *v2);\nGLint ( APIENTRY * dllRenderMode )(GLenum mode);\nstatic void ( APIENTRY * dllRotated )(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);\nstatic void ( APIENTRY * dllRotatef )(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);\nstatic void ( APIENTRY * dllScaled )(GLdouble x, GLdouble y, GLdouble z);\nstatic void ( APIENTRY * dllScalef )(GLfloat x, GLfloat y, GLfloat z);\nstatic void ( APIENTRY * dllScissor )(GLint x, GLint y, GLsizei width, GLsizei height);\nstatic void ( APIENTRY * dllSelectBuffer )(GLsizei size, GLuint *buffer);\nstatic void ( APIENTRY * dllShadeModel )(GLenum mode);\nstatic void ( APIENTRY * dllStencilFunc )(GLenum func, GLint ref, GLuint mask);\nstatic void ( APIENTRY * dllStencilMask )(GLuint mask);\nstatic void ( APIENTRY * dllStencilOp )(GLenum fail, GLenum zfail, GLenum zpass);\nstatic void ( APIENTRY * dllTexCoord1d )(GLdouble s);\nstatic void ( APIENTRY * dllTexCoord1dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllTexCoord1f )(GLfloat s);\nstatic void ( APIENTRY * dllTexCoord1fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllTexCoord1i )(GLint s);\nstatic void ( APIENTRY * dllTexCoord1iv )(const GLint *v);\nstatic void ( APIENTRY * dllTexCoord1s )(GLshort s);\nstatic void ( APIENTRY * dllTexCoord1sv )(const GLshort *v);\nstatic void ( APIENTRY * dllTexCoord2d )(GLdouble s, GLdouble t);\nstatic void ( APIENTRY * dllTexCoord2dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllTexCoord2f )(GLfloat s, GLfloat t);\nstatic void ( APIENTRY * dllTexCoord2fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllTexCoord2i )(GLint s, GLint t);\nstatic void ( APIENTRY * dllTexCoord2iv )(const GLint *v);\nstatic void ( APIENTRY * dllTexCoord2s )(GLshort s, GLshort t);\nstatic void ( APIENTRY * dllTexCoord2sv )(const GLshort *v);\nstatic void ( APIENTRY * dllTexCoord3d )(GLdouble s, GLdouble t, GLdouble r);\nstatic void ( APIENTRY * dllTexCoord3dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllTexCoord3f )(GLfloat s, GLfloat t, GLfloat r);\nstatic void ( APIENTRY * dllTexCoord3fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllTexCoord3i )(GLint s, GLint t, GLint r);\nstatic void ( APIENTRY * dllTexCoord3iv )(const GLint *v);\nstatic void ( APIENTRY * dllTexCoord3s )(GLshort s, GLshort t, GLshort r);\nstatic void ( APIENTRY * dllTexCoord3sv )(const GLshort *v);\nstatic void ( APIENTRY * dllTexCoord4d )(GLdouble s, GLdouble t, GLdouble r, GLdouble q);\nstatic void ( APIENTRY * dllTexCoord4dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllTexCoord4f )(GLfloat s, GLfloat t, GLfloat r, GLfloat q);\nstatic void ( APIENTRY * dllTexCoord4fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllTexCoord4i )(GLint s, GLint t, GLint r, GLint q);\nstatic void ( APIENTRY * dllTexCoord4iv )(const GLint *v);\nstatic void ( APIENTRY * dllTexCoord4s )(GLshort s, GLshort t, GLshort r, GLshort q);\nstatic void ( APIENTRY * dllTexCoord4sv )(const GLshort *v);\nstatic void ( APIENTRY * dllTexCoordPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nstatic void ( APIENTRY * dllTexEnvf )(GLenum target, GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllTexEnvfv )(GLenum target, GLenum pname, const GLfloat *params);\nstatic void ( APIENTRY * dllTexEnvi )(GLenum target, GLenum pname, GLint param);\nstatic void ( APIENTRY * dllTexEnviv )(GLenum target, GLenum pname, const GLint *params);\nstatic void ( APIENTRY * dllTexGend )(GLenum coord, GLenum pname, GLdouble param);\nstatic void ( APIENTRY * dllTexGendv )(GLenum coord, GLenum pname, const GLdouble *params);\nstatic void ( APIENTRY * dllTexGenf )(GLenum coord, GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllTexGenfv )(GLenum coord, GLenum pname, const GLfloat *params);\nstatic void ( APIENTRY * dllTexGeni )(GLenum coord, GLenum pname, GLint param);\nstatic void ( APIENTRY * dllTexGeniv )(GLenum coord, GLenum pname, const GLint *params);\nstatic void ( APIENTRY * dllTexImage1D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nstatic void ( APIENTRY * dllTexImage2D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nstatic void ( APIENTRY * dllTexParameterf )(GLenum target, GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllTexParameterfv )(GLenum target, GLenum pname, const GLfloat *params);\nstatic void ( APIENTRY * dllTexParameteri )(GLenum target, GLenum pname, GLint param);\nstatic void ( APIENTRY * dllTexParameteriv )(GLenum target, GLenum pname, const GLint *params);\nstatic void ( APIENTRY * dllTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);\nstatic void ( APIENTRY * dllTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nstatic void ( APIENTRY * dllTranslated )(GLdouble x, GLdouble y, GLdouble z);\nstatic void ( APIENTRY * dllTranslatef )(GLfloat x, GLfloat y, GLfloat z);\nstatic void ( APIENTRY * dllVertex2d )(GLdouble x, GLdouble y);\nstatic void ( APIENTRY * dllVertex2dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllVertex2f )(GLfloat x, GLfloat y);\nstatic void ( APIENTRY * dllVertex2fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllVertex2i )(GLint x, GLint y);\nstatic void ( APIENTRY * dllVertex2iv )(const GLint *v);\nstatic void ( APIENTRY * dllVertex2s )(GLshort x, GLshort y);\nstatic void ( APIENTRY * dllVertex2sv )(const GLshort *v);\nstatic void ( APIENTRY * dllVertex3d )(GLdouble x, GLdouble y, GLdouble z);\nstatic void ( APIENTRY * dllVertex3dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllVertex3f )(GLfloat x, GLfloat y, GLfloat z);\nstatic void ( APIENTRY * dllVertex3fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllVertex3i )(GLint x, GLint y, GLint z);\nstatic void ( APIENTRY * dllVertex3iv )(const GLint *v);\nstatic void ( APIENTRY * dllVertex3s )(GLshort x, GLshort y, GLshort z);\nstatic void ( APIENTRY * dllVertex3sv )(const GLshort *v);\nstatic void ( APIENTRY * dllVertex4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nstatic void ( APIENTRY * dllVertex4dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllVertex4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nstatic void ( APIENTRY * dllVertex4fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllVertex4i )(GLint x, GLint y, GLint z, GLint w);\nstatic void ( APIENTRY * dllVertex4iv )(const GLint *v);\nstatic void ( APIENTRY * dllVertex4s )(GLshort x, GLshort y, GLshort z, GLshort w);\nstatic void ( APIENTRY * dllVertex4sv )(const GLshort *v);\nstatic void ( APIENTRY * dllVertexPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nstatic void ( APIENTRY * dllViewport )(GLint x, GLint y, GLsizei width, GLsizei height);\n\nstatic const char * BooleanToString( GLboolean b )\n{\n\tif ( b == GL_FALSE )\n\t\treturn \"GL_FALSE\";\n\telse if ( b == GL_TRUE )\n\t\treturn \"GL_TRUE\";\n\telse\n\t\treturn \"OUT OF RANGE FOR BOOLEAN\";\n}\n\nstatic const char * FuncToString( GLenum f )\n{\n\tswitch ( f )\n\t{\n\tcase GL_ALWAYS:\n\t\treturn \"GL_ALWAYS\";\n\tcase GL_NEVER:\n\t\treturn \"GL_NEVER\";\n\tcase GL_LEQUAL:\n\t\treturn \"GL_LEQUAL\";\n\tcase GL_LESS:\n\t\treturn \"GL_LESS\";\n\tcase GL_EQUAL:\n\t\treturn \"GL_EQUAL\";\n\tcase GL_GREATER:\n\t\treturn \"GL_GREATER\";\n\tcase GL_GEQUAL:\n\t\treturn \"GL_GEQUAL\";\n\tcase GL_NOTEQUAL:\n\t\treturn \"GL_NOTEQUAL\";\n\tdefault:\n\t\treturn \"!!! UNKNOWN !!!\";\n\t}\n}\n\nstatic const char * PrimToString( GLenum mode )\n{\n\tstatic char prim[1024];\n\n\tif ( mode == GL_TRIANGLES )\n\t\tstrcpy( prim, \"GL_TRIANGLES\" );\n\telse if ( mode == GL_TRIANGLE_STRIP )\n\t\tstrcpy( prim, \"GL_TRIANGLE_STRIP\" );\n\telse if ( mode == GL_TRIANGLE_FAN )\n\t\tstrcpy( prim, \"GL_TRIANGLE_FAN\" );\n\telse if ( mode == GL_QUADS )\n\t\tstrcpy( prim, \"GL_QUADS\" );\n\telse if ( mode == GL_QUAD_STRIP )\n\t\tstrcpy( prim, \"GL_QUAD_STRIP\" );\n\telse if ( mode == GL_POLYGON )\n\t\tstrcpy( prim, \"GL_POLYGON\" );\n\telse if ( mode == GL_POINTS )\n\t\tstrcpy( prim, \"GL_POINTS\" );\n\telse if ( mode == GL_LINES )\n\t\tstrcpy( prim, \"GL_LINES\" );\n\telse if ( mode == GL_LINE_STRIP )\n\t\tstrcpy( prim, \"GL_LINE_STRIP\" );\n\telse if ( mode == GL_LINE_LOOP )\n\t\tstrcpy( prim, \"GL_LINE_LOOP\" );\n\telse\n\t\tsprintf( prim, \"0x%x\", mode );\n\n\treturn prim;\n}\n\nstatic const char * CapToString( GLenum cap )\n{\n\tstatic char buffer[1024];\n\n\tswitch ( cap )\n\t{\n\tcase GL_TEXTURE_2D:\n\t\treturn \"GL_TEXTURE_2D\";\n\tcase GL_BLEND:\n\t\treturn \"GL_BLEND\";\n\tcase GL_DEPTH_TEST:\n\t\treturn \"GL_DEPTH_TEST\";\n\tcase GL_CULL_FACE:\n\t\treturn \"GL_CULL_FACE\";\n\tcase GL_CLIP_PLANE0:\n\t\treturn \"GL_CLIP_PLANE0\";\n\tcase GL_COLOR_ARRAY:\n\t\treturn \"GL_COLOR_ARRAY\";\n\tcase GL_TEXTURE_COORD_ARRAY:\n\t\treturn \"GL_TEXTURE_COORD_ARRAY\";\n\tcase GL_VERTEX_ARRAY:\n\t\treturn \"GL_VERTEX_ARRAY\";\n\tcase GL_ALPHA_TEST:\n\t\treturn \"GL_ALPHA_TEST\";\n\tcase GL_STENCIL_TEST:\n\t\treturn \"GL_STENCIL_TEST\";\n\tdefault:\n\t\tsprintf( buffer, \"0x%x\", cap );\n\t}\n\n\treturn buffer;\n}\n\nstatic const char * TypeToString( GLenum t )\n{\n\tswitch ( t )\n\t{\n\tcase GL_BYTE:\n\t\treturn \"GL_BYTE\";\n\tcase GL_UNSIGNED_BYTE:\n\t\treturn \"GL_UNSIGNED_BYTE\";\n\tcase GL_SHORT:\n\t\treturn \"GL_SHORT\";\n\tcase GL_UNSIGNED_SHORT:\n\t\treturn \"GL_UNSIGNED_SHORT\";\n\tcase GL_INT:\n\t\treturn \"GL_INT\";\n\tcase GL_UNSIGNED_INT:\n\t\treturn \"GL_UNSIGNED_INT\";\n\tcase GL_FLOAT:\n\t\treturn \"GL_FLOAT\";\n\tcase GL_DOUBLE:\n\t\treturn \"GL_DOUBLE\";\n\tdefault:\n\t\treturn \"!!! UNKNOWN !!!\";\n\t}\n}\n\nstatic void APIENTRY logAccum(GLenum op, GLfloat value)\n{\n\tfprintf( glw_state.log_fp, \"glAccum\\n\" );\n\tdllAccum( op, value );\n}\n\nstatic void APIENTRY logAlphaFunc(GLenum func, GLclampf ref)\n{\n\tfprintf( glw_state.log_fp, \"glAlphaFunc( 0x%x, %f )\\n\", func, ref );\n\tdllAlphaFunc( func, ref );\n}\n\nstatic GLboolean APIENTRY logAreTexturesResident(GLsizei n, const GLuint *textures, GLboolean *residences)\n{\n\tfprintf( glw_state.log_fp, \"glAreTexturesResident\\n\" );\n\treturn dllAreTexturesResident( n, textures, residences );\n}\n\nstatic void APIENTRY logArrayElement(GLint i)\n{\n\tfprintf( glw_state.log_fp, \"glArrayElement\\n\" );\n\tdllArrayElement( i );\n}\n\nstatic void APIENTRY logBegin(GLenum mode)\n{\n\tfprintf( glw_state.log_fp, \"glBegin( %s )\\n\", PrimToString( mode ));\n\tdllBegin( mode );\n}\n\nstatic void APIENTRY logBindTexture(GLenum target, GLuint texture)\n{\n\tfprintf( glw_state.log_fp, \"glBindTexture( 0x%x, %u )\\n\", target, texture );\n\tdllBindTexture( target, texture );\n}\n\nstatic void APIENTRY logBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap)\n{\n\tfprintf( glw_state.log_fp, \"glBitmap\\n\" );\n\tdllBitmap( width, height, xorig, yorig, xmove, ymove, bitmap );\n}\n\nstatic void BlendToName( char *n, GLenum f )\n{\n\tswitch ( f )\n\t{\n\tcase GL_ONE:\n\t\tstrcpy( n, \"GL_ONE\" );\n\t\tbreak;\n\tcase GL_ZERO:\n\t\tstrcpy( n, \"GL_ZERO\" );\n\t\tbreak;\n\tcase GL_SRC_ALPHA:\n\t\tstrcpy( n, \"GL_SRC_ALPHA\" );\n\t\tbreak;\n\tcase GL_ONE_MINUS_SRC_ALPHA:\n\t\tstrcpy( n, \"GL_ONE_MINUS_SRC_ALPHA\" );\n\t\tbreak;\n\tcase GL_DST_COLOR:\n\t\tstrcpy( n, \"GL_DST_COLOR\" );\n\t\tbreak;\n\tcase GL_ONE_MINUS_DST_COLOR:\n\t\tstrcpy( n, \"GL_ONE_MINUS_DST_COLOR\" );\n\t\tbreak;\n\tcase GL_DST_ALPHA:\n\t\tstrcpy( n, \"GL_DST_ALPHA\" );\n\t\tbreak;\n\tdefault:\n\t\tsprintf( n, \"0x%x\", f );\n\t}\n}\nstatic void APIENTRY logBlendFunc(GLenum sfactor, GLenum dfactor)\n{\n\tchar sf[128], df[128];\n\n\tBlendToName( sf, sfactor );\n\tBlendToName( df, dfactor );\n\n\tfprintf( glw_state.log_fp, \"glBlendFunc( %s, %s )\\n\", sf, df );\n\tdllBlendFunc( sfactor, dfactor );\n}\n\nstatic void APIENTRY logCallList(GLuint list)\n{\n\tfprintf( glw_state.log_fp, \"glCallList( %u )\\n\", list );\n\tdllCallList( list );\n}\n\nstatic void APIENTRY logCallLists(GLsizei n, GLenum type, const void *lists)\n{\n\tfprintf( glw_state.log_fp, \"glCallLists\\n\" );\n\tdllCallLists( n, type, lists );\n}\n\nstatic void APIENTRY logClear(GLbitfield mask)\n{\n\tfprintf( glw_state.log_fp, \"glClear( 0x%x = \", mask );\n\n\tif ( mask & GL_COLOR_BUFFER_BIT )\n\t\tfprintf( glw_state.log_fp, \"GL_COLOR_BUFFER_BIT \" );\n\tif ( mask & GL_DEPTH_BUFFER_BIT )\n\t\tfprintf( glw_state.log_fp, \"GL_DEPTH_BUFFER_BIT \" );\n\tif ( mask & GL_STENCIL_BUFFER_BIT )\n\t\tfprintf( glw_state.log_fp, \"GL_STENCIL_BUFFER_BIT \" );\n\tif ( mask & GL_ACCUM_BUFFER_BIT )\n\t\tfprintf( glw_state.log_fp, \"GL_ACCUM_BUFFER_BIT \" );\n\n\tfprintf( glw_state.log_fp, \")\\n\" );\n\tdllClear( mask );\n}\n\nstatic void APIENTRY logClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)\n{\n\tfprintf( glw_state.log_fp, \"glClearAccum\\n\" );\n\tdllClearAccum( red, green, blue, alpha );\n}\n\nstatic void APIENTRY logClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)\n{\n\tfprintf( glw_state.log_fp, \"glClearColor\\n\" );\n\tdllClearColor( red, green, blue, alpha );\n}\n\nstatic void APIENTRY logClearDepth(GLclampd depth)\n{\n\tfprintf( glw_state.log_fp, \"glClearDepth( %f )\\n\", ( float ) depth );\n\tdllClearDepth( depth );\n}\n\nstatic void APIENTRY logClearIndex(GLfloat c)\n{\n\tfprintf( glw_state.log_fp, \"glClearIndex\\n\" );\n\tdllClearIndex( c );\n}\n\nstatic void APIENTRY logClearStencil(GLint s)\n{\n\tfprintf( glw_state.log_fp, \"glClearStencil( %d )\\n\", s );\n\tdllClearStencil( s );\n}\n\nstatic void APIENTRY logClipPlane(GLenum plane, const GLdouble *equation)\n{\n\tfprintf( glw_state.log_fp, \"glClipPlane\\n\" );\n\tdllClipPlane( plane, equation );\n}\n\nstatic void APIENTRY logColor3b(GLbyte red, GLbyte green, GLbyte blue)\n{\n\tfprintf( glw_state.log_fp, \"glColor3b\\n\" );\n\tdllColor3b( red, green, blue );\n}\n\nstatic void APIENTRY logColor3bv(const GLbyte *v)\n{\n\tfprintf( glw_state.log_fp, \"glColor3bv\\n\" );\n\tdllColor3bv( v );\n}\n\nstatic void APIENTRY logColor3d(GLdouble red, GLdouble green, GLdouble blue)\n{\n\tfprintf( glw_state.log_fp, \"glColor3d\\n\" );\n\tdllColor3d( red, green, blue );\n}\n\nstatic void APIENTRY logColor3dv(const GLdouble *v)\n{\n\tfprintf( glw_state.log_fp, \"glColor3dv\\n\" );\n\tdllColor3dv( v );\n}\n\nstatic void APIENTRY logColor3f(GLfloat red, GLfloat green, GLfloat blue)\n{\n\tfprintf( glw_state.log_fp, \"glColor3f\\n\" );\n\tdllColor3f( red, green, blue );\n}\n\nstatic void APIENTRY logColor3fv(const GLfloat *v)\n{\n\tfprintf( glw_state.log_fp, \"glColor3fv\\n\" );\n\tdllColor3fv( v );\n}\n\nstatic void APIENTRY logColor3i(GLint red, GLint green, GLint blue)\n{\n\tfprintf( glw_state.log_fp, \"glColor3i\\n\" );\n\tdllColor3i( red, green, blue );\n}\n\nstatic void APIENTRY logColor3iv(const GLint *v)\n{\n\tfprintf( glw_state.log_fp, \"glColor3iv\\n\" );\n\tdllColor3iv( v );\n}\n\nstatic void APIENTRY logColor3s(GLshort red, GLshort green, GLshort blue)\n{\n\tfprintf( glw_state.log_fp, \"glColor3s\\n\" );\n\tdllColor3s( red, green, blue );\n}\n\nstatic void APIENTRY logColor3sv(const GLshort *v)\n{\n\tfprintf( glw_state.log_fp, \"glColor3sv\\n\" );\n\tdllColor3sv( v );\n}\n\nstatic void APIENTRY logColor3ub(GLubyte red, GLubyte green, GLubyte blue)\n{\n\tfprintf( glw_state.log_fp, \"glColor3ub\\n\" );\n\tdllColor3ub( red, green, blue );\n}\n\nstatic void APIENTRY logColor3ubv(const GLubyte *v)\n{\n\tfprintf( glw_state.log_fp, \"glColor3ubv\\n\" );\n\tdllColor3ubv( v );\n}\n\n#define SIG( x ) fprintf( glw_state.log_fp, x \"\\n\" )\n\nstatic void APIENTRY logColor3ui(GLuint red, GLuint green, GLuint blue)\n{\n\tSIG( \"glColor3ui\" );\n\tdllColor3ui( red, green, blue );\n}\n\nstatic void APIENTRY logColor3uiv(const GLuint *v)\n{\n\tSIG( \"glColor3uiv\" );\n\tdllColor3uiv( v );\n}\n\nstatic void APIENTRY logColor3us(GLushort red, GLushort green, GLushort blue)\n{\n\tSIG( \"glColor3us\" );\n\tdllColor3us( red, green, blue );\n}\n\nstatic void APIENTRY logColor3usv(const GLushort *v)\n{\n\tSIG( \"glColor3usv\" );\n\tdllColor3usv( v );\n}\n\nstatic void APIENTRY logColor4b(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha)\n{\n\tSIG( \"glColor4b\" );\n\tdllColor4b( red, green, blue, alpha );\n}\n\nstatic void APIENTRY logColor4bv(const GLbyte *v)\n{\n\tSIG( \"glColor4bv\" );\n\tdllColor4bv( v );\n}\n\nstatic void APIENTRY logColor4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha)\n{\n\tSIG( \"glColor4d\" );\n\tdllColor4d( red, green, blue, alpha );\n}\nstatic void APIENTRY logColor4dv(const GLdouble *v)\n{\n\tSIG( \"glColor4dv\" );\n\tdllColor4dv( v );\n}\nstatic void APIENTRY logColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)\n{\n\tfprintf( glw_state.log_fp, \"glColor4f( %f,%f,%f,%f )\\n\", red, green, blue, alpha );\n\tdllColor4f( red, green, blue, alpha );\n}\nstatic void APIENTRY logColor4fv(const GLfloat *v)\n{\n\tfprintf( glw_state.log_fp, \"glColor4fv( %f,%f,%f,%f )\\n\", v[0], v[1], v[2], v[3] );\n\tdllColor4fv( v );\n}\nstatic void APIENTRY logColor4i(GLint red, GLint green, GLint blue, GLint alpha)\n{\n\tSIG( \"glColor4i\" );\n\tdllColor4i( red, green, blue, alpha );\n}\nstatic void APIENTRY logColor4iv(const GLint *v)\n{\n\tSIG( \"glColor4iv\" );\n\tdllColor4iv( v );\n}\nstatic void APIENTRY logColor4s(GLshort red, GLshort green, GLshort blue, GLshort alpha)\n{\n\tSIG( \"glColor4s\" );\n\tdllColor4s( red, green, blue, alpha );\n}\nstatic void APIENTRY logColor4sv(const GLshort *v)\n{\n\tSIG( \"glColor4sv\" );\n\tdllColor4sv( v );\n}\nstatic void APIENTRY logColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)\n{\n\tSIG( \"glColor4b\" );\n\tdllColor4b( red, green, blue, alpha );\n}\nstatic void APIENTRY logColor4ubv(const GLubyte *v)\n{\n\tSIG( \"glColor4ubv\" );\n\tdllColor4ubv( v );\n}\nstatic void APIENTRY logColor4ui(GLuint red, GLuint green, GLuint blue, GLuint alpha)\n{\n\tSIG( \"glColor4ui\" );\n\tdllColor4ui( red, green, blue, alpha );\n}\nstatic void APIENTRY logColor4uiv(const GLuint *v)\n{\n\tSIG( \"glColor4uiv\" );\n\tdllColor4uiv( v );\n}\nstatic void APIENTRY logColor4us(GLushort red, GLushort green, GLushort blue, GLushort alpha)\n{\n\tSIG( \"glColor4us\" );\n\tdllColor4us( red, green, blue, alpha );\n}\nstatic void APIENTRY logColor4usv(const GLushort *v)\n{\n\tSIG( \"glColor4usv\" );\n\tdllColor4usv( v );\n}\nstatic void APIENTRY logColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)\n{\n\tSIG( \"glColorMask\" );\n\tdllColorMask( red, green, blue, alpha );\n}\nstatic void APIENTRY logColorMaterial(GLenum face, GLenum mode)\n{\n\tSIG( \"glColorMaterial\" );\n\tdllColorMaterial( face, mode );\n}\n\nstatic void APIENTRY logColorPointer(GLint size, GLenum type, GLsizei stride, const void *pointer)\n{\n\tfprintf( glw_state.log_fp, \"glColorPointer( %d, %s, %d, MEM )\\n\", size, TypeToString( type ), stride );\n\tdllColorPointer( size, type, stride, pointer );\n}\n\nstatic void APIENTRY logCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)\n{\n\tSIG( \"glCopyPixels\" );\n\tdllCopyPixels( x, y, width, height, type );\n}\n\nstatic void APIENTRY logCopyTexImage1D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border)\n{\n\tSIG( \"glCopyTexImage1D\" );\n\tdllCopyTexImage1D( target, level, internalFormat, x, y, width, border );\n}\n\nstatic void APIENTRY logCopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)\n{\n\tSIG( \"glCopyTexImage2D\" );\n\tdllCopyTexImage2D( target, level, internalFormat, x, y, width, height, border );\n}\n\nstatic void APIENTRY logCopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width)\n{\n\tSIG( \"glCopyTexSubImage1D\" );\n\tdllCopyTexSubImage1D( target, level, xoffset, x, y, width );\n}\n\nstatic void APIENTRY logCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)\n{\n\tSIG( \"glCopyTexSubImage2D\" );\n\tdllCopyTexSubImage2D( target, level, xoffset, yoffset, x, y, width, height );\n}\n\nstatic void APIENTRY logCullFace(GLenum mode)\n{\n\tfprintf( glw_state.log_fp, \"glCullFace( %s )\\n\", ( mode == GL_FRONT ) ? \"GL_FRONT\" : \"GL_BACK\" );\n\tdllCullFace( mode );\n}\n\nstatic void APIENTRY logDeleteLists(GLuint list, GLsizei range)\n{\n\tSIG( \"glDeleteLists\" );\n\tdllDeleteLists( list, range );\n}\n\nstatic void APIENTRY logDeleteTextures(GLsizei n, const GLuint *textures)\n{\n\tSIG( \"glDeleteTextures\" );\n\tdllDeleteTextures( n, textures );\n}\n\nstatic void APIENTRY logDepthFunc(GLenum func)\n{\n\tfprintf( glw_state.log_fp, \"glDepthFunc( %s )\\n\", FuncToString( func ) );\n\tdllDepthFunc( func );\n}\n\nstatic void APIENTRY logDepthMask(GLboolean flag)\n{\n\tfprintf( glw_state.log_fp, \"glDepthMask( %s )\\n\", BooleanToString( flag ) );\n\tdllDepthMask( flag );\n}\n\nstatic void APIENTRY logDepthRange(GLclampd zNear, GLclampd zFar)\n{\n\tfprintf( glw_state.log_fp, \"glDepthRange( %f, %f )\\n\", ( float ) zNear, ( float ) zFar );\n\tdllDepthRange( zNear, zFar );\n}\n\nstatic void APIENTRY logDisable(GLenum cap)\n{\n\tfprintf( glw_state.log_fp, \"glDisable( %s )\\n\", CapToString( cap ) );\n\tdllDisable( cap );\n}\n\nstatic void APIENTRY logDisableClientState(GLenum array)\n{\n\tfprintf( glw_state.log_fp, \"glDisableClientState( %s )\\n\", CapToString( array ) );\n\tdllDisableClientState( array );\n}\n\nstatic void APIENTRY logDrawArrays(GLenum mode, GLint first, GLsizei count)\n{\n\tSIG( \"glDrawArrays\" );\n\tdllDrawArrays( mode, first, count );\n}\n\nstatic void APIENTRY logDrawBuffer(GLenum mode)\n{\n\tSIG( \"glDrawBuffer\" );\n\tdllDrawBuffer( mode );\n}\n\nstatic void APIENTRY logDrawElements(GLenum mode, GLsizei count, GLenum type, const void *indices)\n{\n\tfprintf( glw_state.log_fp, \"glDrawElements( %s, %d, %s, MEM )\\n\", PrimToString( mode ), count, TypeToString( type ) );\n\tdllDrawElements( mode, count, type, indices );\n}\n\nstatic void APIENTRY logDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels)\n{\n\tSIG( \"glDrawPixels\" );\n\tdllDrawPixels( width, height, format, type, pixels );\n}\n\nstatic void APIENTRY logEdgeFlag(GLboolean flag)\n{\n\tSIG( \"glEdgeFlag\" );\n\tdllEdgeFlag( flag );\n}\n\nstatic void APIENTRY logEdgeFlagPointer(GLsizei stride, const void *pointer)\n{\n\tSIG( \"glEdgeFlagPointer\" );\n\tdllEdgeFlagPointer( stride, pointer );\n}\n\nstatic void APIENTRY logEdgeFlagv(const GLboolean *flag)\n{\n\tSIG( \"glEdgeFlagv\" );\n\tdllEdgeFlagv( flag );\n}\n\nstatic void APIENTRY logEnable(GLenum cap)\n{\n\tfprintf( glw_state.log_fp, \"glEnable( %s )\\n\", CapToString( cap ) );\n\tdllEnable( cap );\n}\n\nstatic void APIENTRY logEnableClientState(GLenum array)\n{\n\tfprintf( glw_state.log_fp, \"glEnableClientState( %s )\\n\", CapToString( array ) );\n\tdllEnableClientState( array );\n}\n\nstatic void APIENTRY logEnd(void)\n{\n\tSIG( \"glEnd\" );\n\tdllEnd();\n}\n\nstatic void APIENTRY logEndList(void)\n{\n\tSIG( \"glEndList\" );\n\tdllEndList();\n}\n\nstatic void APIENTRY logEvalCoord1d(GLdouble u)\n{\n\tSIG( \"glEvalCoord1d\" );\n\tdllEvalCoord1d( u );\n}\n\nstatic void APIENTRY logEvalCoord1dv(const GLdouble *u)\n{\n\tSIG( \"glEvalCoord1dv\" );\n\tdllEvalCoord1dv( u );\n}\n\nstatic void APIENTRY logEvalCoord1f(GLfloat u)\n{\n\tSIG( \"glEvalCoord1f\" );\n\tdllEvalCoord1f( u );\n}\n\nstatic void APIENTRY logEvalCoord1fv(const GLfloat *u)\n{\n\tSIG( \"glEvalCoord1fv\" );\n\tdllEvalCoord1fv( u );\n}\nstatic void APIENTRY logEvalCoord2d(GLdouble u, GLdouble v)\n{\n\tSIG( \"glEvalCoord2d\" );\n\tdllEvalCoord2d( u, v );\n}\nstatic void APIENTRY logEvalCoord2dv(const GLdouble *u)\n{\n\tSIG( \"glEvalCoord2dv\" );\n\tdllEvalCoord2dv( u );\n}\nstatic void APIENTRY logEvalCoord2f(GLfloat u, GLfloat v)\n{\n\tSIG( \"glEvalCoord2f\" );\n\tdllEvalCoord2f( u, v );\n}\nstatic void APIENTRY logEvalCoord2fv(const GLfloat *u)\n{\n\tSIG( \"glEvalCoord2fv\" );\n\tdllEvalCoord2fv( u );\n}\n\nstatic void APIENTRY logEvalMesh1(GLenum mode, GLint i1, GLint i2)\n{\n\tSIG( \"glEvalMesh1\" );\n\tdllEvalMesh1( mode, i1, i2 );\n}\nstatic void APIENTRY logEvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)\n{\n\tSIG( \"glEvalMesh2\" );\n\tdllEvalMesh2( mode, i1, i2, j1, j2 );\n}\nstatic void APIENTRY logEvalPoint1(GLint i)\n{\n\tSIG( \"glEvalPoint1\" );\n\tdllEvalPoint1( i );\n}\nstatic void APIENTRY logEvalPoint2(GLint i, GLint j)\n{\n\tSIG( \"glEvalPoint2\" );\n\tdllEvalPoint2( i, j );\n}\n\nstatic void APIENTRY logFeedbackBuffer(GLsizei size, GLenum type, GLfloat *buffer)\n{\n\tSIG( \"glFeedbackBuffer\" );\n\tdllFeedbackBuffer( size, type, buffer );\n}\n\nstatic void APIENTRY logFinish(void)\n{\n\tSIG( \"glFinish\" );\n\tdllFinish();\n}\n\nstatic void APIENTRY logFlush(void)\n{\n\tSIG( \"glFlush\" );\n\tdllFlush();\n}\n\nstatic void APIENTRY logFogf(GLenum pname, GLfloat param)\n{\n\tSIG( \"glFogf\" );\n\tdllFogf( pname, param );\n}\n\nstatic void APIENTRY logFogfv(GLenum pname, const GLfloat *params)\n{\n\tSIG( \"glFogfv\" );\n\tdllFogfv( pname, params );\n}\n\nstatic void APIENTRY logFogi(GLenum pname, GLint param)\n{\n\tSIG( \"glFogi\" );\n\tdllFogi( pname, param );\n}\n\nstatic void APIENTRY logFogiv(GLenum pname, const GLint *params)\n{\n\tSIG( \"glFogiv\" );\n\tdllFogiv( pname, params );\n}\n\nstatic void APIENTRY logFrontFace(GLenum mode)\n{\n\tSIG( \"glFrontFace\" );\n\tdllFrontFace( mode );\n}\n\nstatic void APIENTRY logFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)\n{\n\tSIG( \"glFrustum\" );\n\tdllFrustum( left, right, bottom, top, zNear, zFar );\n}\n\nstatic GLuint APIENTRY logGenLists(GLsizei range)\n{\n\tSIG( \"glGenLists\" );\n\treturn dllGenLists( range );\n}\n\nstatic void APIENTRY logGenTextures(GLsizei n, GLuint *textures)\n{\n\tSIG( \"glGenTextures\" );\n\tdllGenTextures( n, textures );\n}\n\nstatic void APIENTRY logGetBooleanv(GLenum pname, GLboolean *params)\n{\n\tSIG( \"glGetBooleanv\" );\n\tdllGetBooleanv( pname, params );\n}\n\nstatic void APIENTRY logGetClipPlane(GLenum plane, GLdouble *equation)\n{\n\tSIG( \"glGetClipPlane\" );\n\tdllGetClipPlane( plane, equation );\n}\n\nstatic void APIENTRY logGetDoublev(GLenum pname, GLdouble *params)\n{\n\tSIG( \"glGetDoublev\" );\n\tdllGetDoublev( pname, params );\n}\n\nstatic GLenum APIENTRY logGetError(void)\n{\n\tSIG( \"glGetError\" );\n\treturn dllGetError();\n}\n\nstatic void APIENTRY logGetFloatv(GLenum pname, GLfloat *params)\n{\n\tSIG( \"glGetFloatv\" );\n\tdllGetFloatv( pname, params );\n}\n\nstatic void APIENTRY logGetIntegerv(GLenum pname, GLint *params)\n{\n\tSIG( \"glGetIntegerv\" );\n\tdllGetIntegerv( pname, params );\n}\n\nstatic void APIENTRY logGetLightfv(GLenum light, GLenum pname, GLfloat *params)\n{\n\tSIG( \"glGetLightfv\" );\n\tdllGetLightfv( light, pname, params );\n}\n\nstatic void APIENTRY logGetLightiv(GLenum light, GLenum pname, GLint *params)\n{\n\tSIG( \"glGetLightiv\" );\n\tdllGetLightiv( light, pname, params );\n}\n\nstatic void APIENTRY logGetMapdv(GLenum target, GLenum query, GLdouble *v)\n{\n\tSIG( \"glGetMapdv\" );\n\tdllGetMapdv( target, query, v );\n}\n\nstatic void APIENTRY logGetMapfv(GLenum target, GLenum query, GLfloat *v)\n{\n\tSIG( \"glGetMapfv\" );\n\tdllGetMapfv( target, query, v );\n}\n\nstatic void APIENTRY logGetMapiv(GLenum target, GLenum query, GLint *v)\n{\n\tSIG( \"glGetMapiv\" );\n\tdllGetMapiv( target, query, v );\n}\n\nstatic void APIENTRY logGetMaterialfv(GLenum face, GLenum pname, GLfloat *params)\n{\n\tSIG( \"glGetMaterialfv\" );\n\tdllGetMaterialfv( face, pname, params );\n}\n\nstatic void APIENTRY logGetMaterialiv(GLenum face, GLenum pname, GLint *params)\n{\n\tSIG( \"glGetMaterialiv\" );\n\tdllGetMaterialiv( face, pname, params );\n}\n\nstatic void APIENTRY logGetPixelMapfv(GLenum map, GLfloat *values)\n{\n\tSIG( \"glGetPixelMapfv\" );\n\tdllGetPixelMapfv( map, values );\n}\n\nstatic void APIENTRY logGetPixelMapuiv(GLenum map, GLuint *values)\n{\n\tSIG( \"glGetPixelMapuiv\" );\n\tdllGetPixelMapuiv( map, values );\n}\n\nstatic void APIENTRY logGetPixelMapusv(GLenum map, GLushort *values)\n{\n\tSIG( \"glGetPixelMapusv\" );\n\tdllGetPixelMapusv( map, values );\n}\n\nstatic void APIENTRY logGetPointerv(GLenum pname, GLvoid* *params)\n{\n\tSIG( \"glGetPointerv\" );\n\tdllGetPointerv( pname, params );\n}\n\nstatic void APIENTRY logGetPolygonStipple(GLubyte *mask)\n{\n\tSIG( \"glGetPolygonStipple\" );\n\tdllGetPolygonStipple( mask );\n}\n\nstatic const GLubyte * APIENTRY logGetString(GLenum name)\n{\n\tSIG( \"glGetString\" );\n\treturn dllGetString( name );\n}\n\nstatic void APIENTRY logGetTexEnvfv(GLenum target, GLenum pname, GLfloat *params)\n{\n\tSIG( \"glGetTexEnvfv\" );\n\tdllGetTexEnvfv( target, pname, params );\n}\n\nstatic void APIENTRY logGetTexEnviv(GLenum target, GLenum pname, GLint *params)\n{\n\tSIG( \"glGetTexEnviv\" );\n\tdllGetTexEnviv( target, pname, params );\n}\n\nstatic void APIENTRY logGetTexGendv(GLenum coord, GLenum pname, GLdouble *params)\n{\n\tSIG( \"glGetTexGendv\" );\n\tdllGetTexGendv( coord, pname, params );\n}\n\nstatic void APIENTRY logGetTexGenfv(GLenum coord, GLenum pname, GLfloat *params)\n{\n\tSIG( \"glGetTexGenfv\" );\n\tdllGetTexGenfv( coord, pname, params );\n}\n\nstatic void APIENTRY logGetTexGeniv(GLenum coord, GLenum pname, GLint *params)\n{\n\tSIG( \"glGetTexGeniv\" );\n\tdllGetTexGeniv( coord, pname, params );\n}\n\nstatic void APIENTRY logGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, void *pixels)\n{\n\tSIG( \"glGetTexImage\" );\n\tdllGetTexImage( target, level, format, type, pixels );\n}\nstatic void APIENTRY logGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat *params )\n{\n\tSIG( \"glGetTexLevelParameterfv\" );\n\tdllGetTexLevelParameterfv( target, level, pname, params );\n}\n\nstatic void APIENTRY logGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params)\n{\n\tSIG( \"glGetTexLevelParameteriv\" );\n\tdllGetTexLevelParameteriv( target, level, pname, params );\n}\n\nstatic void APIENTRY logGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)\n{\n\tSIG( \"glGetTexParameterfv\" );\n\tdllGetTexParameterfv( target, pname, params );\n}\n\nstatic void APIENTRY logGetTexParameteriv(GLenum target, GLenum pname, GLint *params)\n{\n\tSIG( \"glGetTexParameteriv\" );\n\tdllGetTexParameteriv( target, pname, params );\n}\n\nstatic void APIENTRY logHint(GLenum target, GLenum mode)\n{\n\tfprintf( glw_state.log_fp, \"glHint( 0x%x, 0x%x )\\n\", target, mode );\n\tdllHint( target, mode );\n}\n\nstatic void APIENTRY logIndexMask(GLuint mask)\n{\n\tSIG( \"glIndexMask\" );\n\tdllIndexMask( mask );\n}\n\nstatic void APIENTRY logIndexPointer(GLenum type, GLsizei stride, const void *pointer)\n{\n\tSIG( \"glIndexPointer\" );\n\tdllIndexPointer( type, stride, pointer );\n}\n\nstatic void APIENTRY logIndexd(GLdouble c)\n{\n\tSIG( \"glIndexd\" );\n\tdllIndexd( c );\n}\n\nstatic void APIENTRY logIndexdv(const GLdouble *c)\n{\n\tSIG( \"glIndexdv\" );\n\tdllIndexdv( c );\n}\n\nstatic void APIENTRY logIndexf(GLfloat c)\n{\n\tSIG( \"glIndexf\" );\n\tdllIndexf( c );\n}\n\nstatic void APIENTRY logIndexfv(const GLfloat *c)\n{\n\tSIG( \"glIndexfv\" );\n\tdllIndexfv( c );\n}\n\nstatic void APIENTRY logIndexi(GLint c)\n{\n\tSIG( \"glIndexi\" );\n\tdllIndexi( c );\n}\n\nstatic void APIENTRY logIndexiv(const GLint *c)\n{\n\tSIG( \"glIndexiv\" );\n\tdllIndexiv( c );\n}\n\nstatic void APIENTRY logIndexs(GLshort c)\n{\n\tSIG( \"glIndexs\" );\n\tdllIndexs( c );\n}\n\nstatic void APIENTRY logIndexsv(const GLshort *c)\n{\n\tSIG( \"glIndexsv\" );\n\tdllIndexsv( c );\n}\n\nstatic void APIENTRY logIndexub(GLubyte c)\n{\n\tSIG( \"glIndexub\" );\n\tdllIndexub( c );\n}\n\nstatic void APIENTRY logIndexubv(const GLubyte *c)\n{\n\tSIG( \"glIndexubv\" );\n\tdllIndexubv( c );\n}\n\nstatic void APIENTRY logInitNames(void)\n{\n\tSIG( \"glInitNames\" );\n\tdllInitNames();\n}\n\nstatic void APIENTRY logInterleavedArrays(GLenum format, GLsizei stride, const void *pointer)\n{\n\tSIG( \"glInterleavedArrays\" );\n\tdllInterleavedArrays( format, stride, pointer );\n}\n\nstatic GLboolean APIENTRY logIsEnabled(GLenum cap)\n{\n\tSIG( \"glIsEnabled\" );\n\treturn dllIsEnabled( cap );\n}\nstatic GLboolean APIENTRY logIsList(GLuint list)\n{\n\tSIG( \"glIsList\" );\n\treturn dllIsList( list );\n}\nstatic GLboolean APIENTRY logIsTexture(GLuint texture)\n{\n\tSIG( \"glIsTexture\" );\n\treturn dllIsTexture( texture );\n}\n\nstatic void APIENTRY logLightModelf(GLenum pname, GLfloat param)\n{\n\tSIG( \"glLightModelf\" );\n\tdllLightModelf( pname, param );\n}\n\nstatic void APIENTRY logLightModelfv(GLenum pname, const GLfloat *params)\n{\n\tSIG( \"glLightModelfv\" );\n\tdllLightModelfv( pname, params );\n}\n\nstatic void APIENTRY logLightModeli(GLenum pname, GLint param)\n{\n\tSIG( \"glLightModeli\" );\n\tdllLightModeli( pname, param );\n\n}\n\nstatic void APIENTRY logLightModeliv(GLenum pname, const GLint *params)\n{\n\tSIG( \"glLightModeliv\" );\n\tdllLightModeliv( pname, params );\n}\n\nstatic void APIENTRY logLightf(GLenum light, GLenum pname, GLfloat param)\n{\n\tSIG( \"glLightf\" );\n\tdllLightf( light, pname, param );\n}\n\nstatic void APIENTRY logLightfv(GLenum light, GLenum pname, const GLfloat *params)\n{\n\tSIG( \"glLightfv\" );\n\tdllLightfv( light, pname, params );\n}\n\nstatic void APIENTRY logLighti(GLenum light, GLenum pname, GLint param)\n{\n\tSIG( \"glLighti\" );\n\tdllLighti( light, pname, param );\n}\n\nstatic void APIENTRY logLightiv(GLenum light, GLenum pname, const GLint *params)\n{\n\tSIG( \"glLightiv\" );\n\tdllLightiv( light, pname, params );\n}\n\nstatic void APIENTRY logLineStipple(GLint factor, GLushort pattern)\n{\n\tSIG( \"glLineStipple\" );\n\tdllLineStipple( factor, pattern );\n}\n\nstatic void APIENTRY logLineWidth(GLfloat width)\n{\n\tSIG( \"glLineWidth\" );\n\tdllLineWidth( width );\n}\n\nstatic void APIENTRY logListBase(GLuint base)\n{\n\tSIG( \"glListBase\" );\n\tdllListBase( base );\n}\n\nstatic void APIENTRY logLoadIdentity(void)\n{\n\tSIG( \"glLoadIdentity\" );\n\tdllLoadIdentity();\n}\n\nstatic void APIENTRY logLoadMatrixd(const GLdouble *m)\n{\n\tSIG( \"glLoadMatrixd\" );\n\tdllLoadMatrixd( m );\n}\n\nstatic void APIENTRY logLoadMatrixf(const GLfloat *m)\n{\n\tSIG( \"glLoadMatrixf\" );\n\tdllLoadMatrixf( m );\n}\n\nstatic void APIENTRY logLoadName(GLuint name)\n{\n\tSIG( \"glLoadName\" );\n\tdllLoadName( name );\n}\n\nstatic void APIENTRY logLogicOp(GLenum opcode)\n{\n\tSIG( \"glLogicOp\" );\n\tdllLogicOp( opcode );\n}\n\nstatic void APIENTRY logMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points)\n{\n\tSIG( \"glMap1d\" );\n\tdllMap1d( target, u1, u2, stride, order, points );\n}\n\nstatic void APIENTRY logMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points)\n{\n\tSIG( \"glMap1f\" );\n\tdllMap1f( target, u1, u2, stride, order, points );\n}\n\nstatic void APIENTRY logMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points)\n{\n\tSIG( \"glMap2d\" );\n\tdllMap2d( target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points );\n}\n\nstatic void APIENTRY logMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points)\n{\n\tSIG( \"glMap2f\" );\n\tdllMap2f( target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points );\n}\n\nstatic void APIENTRY logMapGrid1d(GLint un, GLdouble u1, GLdouble u2)\n{\n\tSIG( \"glMapGrid1d\" );\n\tdllMapGrid1d( un, u1, u2 );\n}\n\nstatic void APIENTRY logMapGrid1f(GLint un, GLfloat u1, GLfloat u2)\n{\n\tSIG( \"glMapGrid1f\" );\n\tdllMapGrid1f( un, u1, u2 );\n}\n\nstatic void APIENTRY logMapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2)\n{\n\tSIG( \"glMapGrid2d\" );\n\tdllMapGrid2d( un, u1, u2, vn, v1, v2 );\n}\nstatic void APIENTRY logMapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2)\n{\n\tSIG( \"glMapGrid2f\" );\n\tdllMapGrid2f( un, u1, u2, vn, v1, v2 );\n}\nstatic void APIENTRY logMaterialf(GLenum face, GLenum pname, GLfloat param)\n{\n\tSIG( \"glMaterialf\" );\n\tdllMaterialf( face, pname, param );\n}\nstatic void APIENTRY logMaterialfv(GLenum face, GLenum pname, const GLfloat *params)\n{\n\tSIG( \"glMaterialfv\" );\n\tdllMaterialfv( face, pname, params );\n}\n\nstatic void APIENTRY logMateriali(GLenum face, GLenum pname, GLint param)\n{\n\tSIG( \"glMateriali\" );\n\tdllMateriali( face, pname, param );\n}\n\nstatic void APIENTRY logMaterialiv(GLenum face, GLenum pname, const GLint *params)\n{\n\tSIG( \"glMaterialiv\" );\n\tdllMaterialiv( face, pname, params );\n}\n\nstatic void APIENTRY logMatrixMode(GLenum mode)\n{\n\tSIG( \"glMatrixMode\" );\n\tdllMatrixMode( mode );\n}\n\nstatic void APIENTRY logMultMatrixd(const GLdouble *m)\n{\n\tSIG( \"glMultMatrixd\" );\n\tdllMultMatrixd( m );\n}\n\nstatic void APIENTRY logMultMatrixf(const GLfloat *m)\n{\n\tSIG( \"glMultMatrixf\" );\n\tdllMultMatrixf( m );\n}\n\nstatic void APIENTRY logNewList(GLuint list, GLenum mode)\n{\n\tSIG( \"glNewList\" );\n\tdllNewList( list, mode );\n}\n\nstatic void APIENTRY logNormal3b(GLbyte nx, GLbyte ny, GLbyte nz)\n{\n\tSIG (\"glNormal3b\" );\n\tdllNormal3b( nx, ny, nz );\n}\n\nstatic void APIENTRY logNormal3bv(const GLbyte *v)\n{\n\tSIG( \"glNormal3bv\" );\n\tdllNormal3bv( v );\n}\n\nstatic void APIENTRY logNormal3d(GLdouble nx, GLdouble ny, GLdouble nz)\n{\n\tSIG( \"glNormal3d\" );\n\tdllNormal3d( nx, ny, nz );\n}\n\nstatic void APIENTRY logNormal3dv(const GLdouble *v)\n{\n\tSIG( \"glNormal3dv\" );\n\tdllNormal3dv( v );\n}\n\nstatic void APIENTRY logNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)\n{\n\tSIG( \"glNormal3f\" );\n\tdllNormal3f( nx, ny, nz );\n}\n\nstatic void APIENTRY logNormal3fv(const GLfloat *v)\n{\n\tSIG( \"glNormal3fv\" );\n\tdllNormal3fv( v );\n}\nstatic void APIENTRY logNormal3i(GLint nx, GLint ny, GLint nz)\n{\n\tSIG( \"glNormal3i\" );\n\tdllNormal3i( nx, ny, nz );\n}\nstatic void APIENTRY logNormal3iv(const GLint *v)\n{\n\tSIG( \"glNormal3iv\" );\n\tdllNormal3iv( v );\n}\nstatic void APIENTRY logNormal3s(GLshort nx, GLshort ny, GLshort nz)\n{\n\tSIG( \"glNormal3s\" );\n\tdllNormal3s( nx, ny, nz );\n}\nstatic void APIENTRY logNormal3sv(const GLshort *v)\n{\n\tSIG( \"glNormal3sv\" );\n\tdllNormal3sv( v );\n}\nstatic void APIENTRY logNormalPointer(GLenum type, GLsizei stride, const void *pointer)\n{\n\tSIG( \"glNormalPointer\" );\n\tdllNormalPointer( type, stride, pointer );\n}\nstatic void APIENTRY logOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)\n{\n\tSIG( \"glOrtho\" );\n\tdllOrtho( left, right, bottom, top, zNear, zFar );\n}\n\nstatic void APIENTRY logPassThrough(GLfloat token)\n{\n\tSIG( \"glPassThrough\" );\n\tdllPassThrough( token );\n}\n\nstatic void APIENTRY logPixelMapfv(GLenum map, GLsizei mapsize, const GLfloat *values)\n{\n\tSIG( \"glPixelMapfv\" );\n\tdllPixelMapfv( map, mapsize, values );\n}\n\nstatic void APIENTRY logPixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values)\n{\n\tSIG( \"glPixelMapuiv\" );\n\tdllPixelMapuiv( map, mapsize, values );\n}\n\nstatic void APIENTRY logPixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values)\n{\n\tSIG( \"glPixelMapusv\" );\n\tdllPixelMapusv( map, mapsize, values );\n}\nstatic void APIENTRY logPixelStoref(GLenum pname, GLfloat param)\n{\n\tSIG( \"glPixelStoref\" );\n\tdllPixelStoref( pname, param );\n}\nstatic void APIENTRY logPixelStorei(GLenum pname, GLint param)\n{\n\tSIG( \"glPixelStorei\" );\n\tdllPixelStorei( pname, param );\n}\nstatic void APIENTRY logPixelTransferf(GLenum pname, GLfloat param)\n{\n\tSIG( \"glPixelTransferf\" );\n\tdllPixelTransferf( pname, param );\n}\n\nstatic void APIENTRY logPixelTransferi(GLenum pname, GLint param)\n{\n\tSIG( \"glPixelTransferi\" );\n\tdllPixelTransferi( pname, param );\n}\n\nstatic void APIENTRY logPixelZoom(GLfloat xfactor, GLfloat yfactor)\n{\n\tSIG( \"glPixelZoom\" );\n\tdllPixelZoom( xfactor, yfactor );\n}\n\nstatic void APIENTRY logPointSize(GLfloat size)\n{\n\tSIG( \"glPointSize\" );\n\tdllPointSize( size );\n}\n\nstatic void APIENTRY logPolygonMode(GLenum face, GLenum mode)\n{\n\tfprintf( glw_state.log_fp, \"glPolygonMode( 0x%x, 0x%x )\\n\", face, mode );\n\tdllPolygonMode( face, mode );\n}\n\nstatic void APIENTRY logPolygonOffset(GLfloat factor, GLfloat units)\n{\n\tSIG( \"glPolygonOffset\" );\n\tdllPolygonOffset( factor, units );\n}\nstatic void APIENTRY logPolygonStipple(const GLubyte *mask )\n{\n\tSIG( \"glPolygonStipple\" );\n\tdllPolygonStipple( mask );\n}\nstatic void APIENTRY logPopAttrib(void)\n{\n\tSIG( \"glPopAttrib\" );\n\tdllPopAttrib();\n}\n\nstatic void APIENTRY logPopClientAttrib(void)\n{\n\tSIG( \"glPopClientAttrib\" );\n\tdllPopClientAttrib();\n}\n\nstatic void APIENTRY logPopMatrix(void)\n{\n\tSIG( \"glPopMatrix\" );\n\tdllPopMatrix();\n}\n\nstatic void APIENTRY logPopName(void)\n{\n\tSIG( \"glPopName\" );\n\tdllPopName();\n}\n\nstatic void APIENTRY logPrioritizeTextures(GLsizei n, const GLuint *textures, const GLclampf *priorities)\n{\n\tSIG( \"glPrioritizeTextures\" );\n\tdllPrioritizeTextures( n, textures, priorities );\n}\n\nstatic void APIENTRY logPushAttrib(GLbitfield mask)\n{\n\tSIG( \"glPushAttrib\" );\n\tdllPushAttrib( mask );\n}\n\nstatic void APIENTRY logPushClientAttrib(GLbitfield mask)\n{\n\tSIG( \"glPushClientAttrib\" );\n\tdllPushClientAttrib( mask );\n}\n\nstatic void APIENTRY logPushMatrix(void)\n{\n\tSIG( \"glPushMatrix\" );\n\tdllPushMatrix();\n}\n\nstatic void APIENTRY logPushName(GLuint name)\n{\n\tSIG( \"glPushName\" );\n\tdllPushName( name );\n}\n\nstatic void APIENTRY logRasterPos2d(GLdouble x, GLdouble y)\n{\n\tSIG (\"glRasterPot2d\" );\n\tdllRasterPos2d( x, y );\n}\n\nstatic void APIENTRY logRasterPos2dv(const GLdouble *v)\n{\n\tSIG( \"glRasterPos2dv\" );\n\tdllRasterPos2dv( v );\n}\n\nstatic void APIENTRY logRasterPos2f(GLfloat x, GLfloat y)\n{\n\tSIG( \"glRasterPos2f\" );\n\tdllRasterPos2f( x, y );\n}\nstatic void APIENTRY logRasterPos2fv(const GLfloat *v)\n{\n\tSIG( \"glRasterPos2dv\" );\n\tdllRasterPos2fv( v );\n}\nstatic void APIENTRY logRasterPos2i(GLint x, GLint y)\n{\n\tSIG( \"glRasterPos2if\" );\n\tdllRasterPos2i( x, y );\n}\nstatic void APIENTRY logRasterPos2iv(const GLint *v)\n{\n\tSIG( \"glRasterPos2iv\" );\n\tdllRasterPos2iv( v );\n}\nstatic void APIENTRY logRasterPos2s(GLshort x, GLshort y)\n{\n\tSIG( \"glRasterPos2s\" );\n\tdllRasterPos2s( x, y );\n}\nstatic void APIENTRY logRasterPos2sv(const GLshort *v)\n{\n\tSIG( \"glRasterPos2sv\" );\n\tdllRasterPos2sv( v );\n}\nstatic void APIENTRY logRasterPos3d(GLdouble x, GLdouble y, GLdouble z)\n{\n\tSIG( \"glRasterPos3d\" );\n\tdllRasterPos3d( x, y, z );\n}\nstatic void APIENTRY logRasterPos3dv(const GLdouble *v)\n{\n\tSIG( \"glRasterPos3dv\" );\n\tdllRasterPos3dv( v );\n}\nstatic void APIENTRY logRasterPos3f(GLfloat x, GLfloat y, GLfloat z)\n{\n\tSIG( \"glRasterPos3f\" );\n\tdllRasterPos3f( x, y, z );\n}\nstatic void APIENTRY logRasterPos3fv(const GLfloat *v)\n{\n\tSIG( \"glRasterPos3fv\" );\n\tdllRasterPos3fv( v );\n}\nstatic void APIENTRY logRasterPos3i(GLint x, GLint y, GLint z)\n{\n\tSIG( \"glRasterPos3i\" );\n\tdllRasterPos3i( x, y, z );\n}\nstatic void APIENTRY logRasterPos3iv(const GLint *v)\n{\n\tSIG( \"glRasterPos3iv\" );\n\tdllRasterPos3iv( v );\n}\nstatic void APIENTRY logRasterPos3s(GLshort x, GLshort y, GLshort z)\n{\n\tSIG( \"glRasterPos3s\" );\n\tdllRasterPos3s( x, y, z );\n}\nstatic void APIENTRY logRasterPos3sv(const GLshort *v)\n{\n\tSIG( \"glRasterPos3sv\" );\n\tdllRasterPos3sv( v );\n}\nstatic void APIENTRY logRasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)\n{\n\tSIG( \"glRasterPos4d\" );\n\tdllRasterPos4d( x, y, z, w );\n}\nstatic void APIENTRY logRasterPos4dv(const GLdouble *v)\n{\n\tSIG( \"glRasterPos4dv\" );\n\tdllRasterPos4dv( v );\n}\nstatic void APIENTRY logRasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)\n{\n\tSIG( \"glRasterPos4f\" );\n\tdllRasterPos4f( x, y, z, w );\n}\nstatic void APIENTRY logRasterPos4fv(const GLfloat *v)\n{\n\tSIG( \"glRasterPos4fv\" );\n\tdllRasterPos4fv( v );\n}\nstatic void APIENTRY logRasterPos4i(GLint x, GLint y, GLint z, GLint w)\n{\n\tSIG( \"glRasterPos4i\" );\n\tdllRasterPos4i( x, y, z, w );\n}\nstatic void APIENTRY logRasterPos4iv(const GLint *v)\n{\n\tSIG( \"glRasterPos4iv\" );\n\tdllRasterPos4iv( v );\n}\nstatic void APIENTRY logRasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)\n{\n\tSIG( \"glRasterPos4s\" );\n\tdllRasterPos4s( x, y, z, w );\n}\nstatic void APIENTRY logRasterPos4sv(const GLshort *v)\n{\n\tSIG( \"glRasterPos4sv\" );\n\tdllRasterPos4sv( v );\n}\nstatic void APIENTRY logReadBuffer(GLenum mode)\n{\n\tSIG( \"glReadBuffer\" );\n\tdllReadBuffer( mode );\n}\nstatic void APIENTRY logReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels)\n{\n\tSIG( \"glReadPixels\" );\n\tdllReadPixels( x, y, width, height, format, type, pixels );\n}\n\nstatic void APIENTRY logRectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)\n{\n\tSIG( \"glRectd\" );\n\tdllRectd( x1, y1, x2, y2 );\n}\n\nstatic void APIENTRY logRectdv(const GLdouble *v1, const GLdouble *v2)\n{\n\tSIG( \"glRectdv\" );\n\tdllRectdv( v1, v2 );\n}\n\nstatic void APIENTRY logRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)\n{\n\tSIG( \"glRectf\" );\n\tdllRectf( x1, y1, x2, y2 );\n}\n\nstatic void APIENTRY logRectfv(const GLfloat *v1, const GLfloat *v2)\n{\n\tSIG( \"glRectfv\" );\n\tdllRectfv( v1, v2 );\n}\nstatic void APIENTRY logRecti(GLint x1, GLint y1, GLint x2, GLint y2)\n{\n\tSIG( \"glRecti\" );\n\tdllRecti( x1, y1, x2, y2 );\n}\nstatic void APIENTRY logRectiv(const GLint *v1, const GLint *v2)\n{\n\tSIG( \"glRectiv\" );\n\tdllRectiv( v1, v2 );\n}\nstatic void APIENTRY logRects(GLshort x1, GLshort y1, GLshort x2, GLshort y2)\n{\n\tSIG( \"glRects\" );\n\tdllRects( x1, y1, x2, y2 );\n}\nstatic void APIENTRY logRectsv(const GLshort *v1, const GLshort *v2)\n{\n\tSIG( \"glRectsv\" );\n\tdllRectsv( v1, v2 );\n}\nstatic GLint APIENTRY logRenderMode(GLenum mode)\n{\n\tSIG( \"glRenderMode\" );\n\treturn dllRenderMode( mode );\n}\nstatic void APIENTRY logRotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z)\n{\n\tSIG( \"glRotated\" );\n\tdllRotated( angle, x, y, z );\n}\n\nstatic void APIENTRY logRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)\n{\n\tSIG( \"glRotatef\" );\n\tdllRotatef( angle, x, y, z );\n}\n\nstatic void APIENTRY logScaled(GLdouble x, GLdouble y, GLdouble z)\n{\n\tSIG( \"glScaled\" );\n\tdllScaled( x, y, z );\n}\n\nstatic void APIENTRY logScalef(GLfloat x, GLfloat y, GLfloat z)\n{\n\tSIG( \"glScalef\" );\n\tdllScalef( x, y, z );\n}\n\nstatic void APIENTRY logScissor(GLint x, GLint y, GLsizei width, GLsizei height)\n{\n\tfprintf( glw_state.log_fp, \"glScissor( %d, %d, %d, %d )\\n\", x, y, width, height );\n\tdllScissor( x, y, width, height );\n}\n\nstatic void APIENTRY logSelectBuffer(GLsizei size, GLuint *buffer)\n{\n\tSIG( \"glSelectBuffer\" );\n\tdllSelectBuffer( size, buffer );\n}\n\nstatic void APIENTRY logShadeModel(GLenum mode)\n{\n\tSIG( \"glShadeModel\" );\n\tdllShadeModel( mode );\n}\n\nstatic void APIENTRY logStencilFunc(GLenum func, GLint ref, GLuint mask)\n{\n\tSIG( \"glStencilFunc\" );\n\tdllStencilFunc( func, ref, mask );\n}\n\nstatic void APIENTRY logStencilMask(GLuint mask)\n{\n\tSIG( \"glStencilMask\" );\n\tdllStencilMask( mask );\n}\n\nstatic void APIENTRY logStencilOp(GLenum fail, GLenum zfail, GLenum zpass)\n{\n\tSIG( \"glStencilOp\" );\n\tdllStencilOp( fail, zfail, zpass );\n}\n\nstatic void APIENTRY logTexCoord1d(GLdouble s)\n{\n\tSIG( \"glTexCoord1d\" );\n\tdllTexCoord1d( s );\n}\n\nstatic void APIENTRY logTexCoord1dv(const GLdouble *v)\n{\n\tSIG( \"glTexCoord1dv\" );\n\tdllTexCoord1dv( v );\n}\n\nstatic void APIENTRY logTexCoord1f(GLfloat s)\n{\n\tSIG( \"glTexCoord1f\" );\n\tdllTexCoord1f( s );\n}\nstatic void APIENTRY logTexCoord1fv(const GLfloat *v)\n{\n\tSIG( \"glTexCoord1fv\" );\n\tdllTexCoord1fv( v );\n}\nstatic void APIENTRY logTexCoord1i(GLint s)\n{\n\tSIG( \"glTexCoord1i\" );\n\tdllTexCoord1i( s );\n}\nstatic void APIENTRY logTexCoord1iv(const GLint *v)\n{\n\tSIG( \"glTexCoord1iv\" );\n\tdllTexCoord1iv( v );\n}\nstatic void APIENTRY logTexCoord1s(GLshort s)\n{\n\tSIG( \"glTexCoord1s\" );\n\tdllTexCoord1s( s );\n}\nstatic void APIENTRY logTexCoord1sv(const GLshort *v)\n{\n\tSIG( \"glTexCoord1sv\" );\n\tdllTexCoord1sv( v );\n}\nstatic void APIENTRY logTexCoord2d(GLdouble s, GLdouble t)\n{\n\tSIG( \"glTexCoord2d\" );\n\tdllTexCoord2d( s, t );\n}\n\nstatic void APIENTRY logTexCoord2dv(const GLdouble *v)\n{\n\tSIG( \"glTexCoord2dv\" );\n\tdllTexCoord2dv( v );\n}\nstatic void APIENTRY logTexCoord2f(GLfloat s, GLfloat t)\n{\n\tSIG( \"glTexCoord2f\" );\n\tdllTexCoord2f( s, t );\n}\nstatic void APIENTRY logTexCoord2fv(const GLfloat *v)\n{\n\tSIG( \"glTexCoord2fv\" );\n\tdllTexCoord2fv( v );\n}\nstatic void APIENTRY logTexCoord2i(GLint s, GLint t)\n{\n\tSIG( \"glTexCoord2i\" );\n\tdllTexCoord2i( s, t );\n}\nstatic void APIENTRY logTexCoord2iv(const GLint *v)\n{\n\tSIG( \"glTexCoord2iv\" );\n\tdllTexCoord2iv( v );\n}\nstatic void APIENTRY logTexCoord2s(GLshort s, GLshort t)\n{\n\tSIG( \"glTexCoord2s\" );\n\tdllTexCoord2s( s, t );\n}\nstatic void APIENTRY logTexCoord2sv(const GLshort *v)\n{\n\tSIG( \"glTexCoord2sv\" );\n\tdllTexCoord2sv( v );\n}\nstatic void APIENTRY logTexCoord3d(GLdouble s, GLdouble t, GLdouble r)\n{\n\tSIG( \"glTexCoord3d\" );\n\tdllTexCoord3d( s, t, r );\n}\nstatic void APIENTRY logTexCoord3dv(const GLdouble *v)\n{\n\tSIG( \"glTexCoord3dv\" );\n\tdllTexCoord3dv( v );\n}\nstatic void APIENTRY logTexCoord3f(GLfloat s, GLfloat t, GLfloat r)\n{\n\tSIG( \"glTexCoord3f\" );\n\tdllTexCoord3f( s, t, r );\n}\nstatic void APIENTRY logTexCoord3fv(const GLfloat *v)\n{\n\tSIG( \"glTexCoord3fv\" );\n\tdllTexCoord3fv( v );\n}\nstatic void APIENTRY logTexCoord3i(GLint s, GLint t, GLint r)\n{\n\tSIG( \"glTexCoord3i\" );\n\tdllTexCoord3i( s, t, r );\n}\nstatic void APIENTRY logTexCoord3iv(const GLint *v)\n{\n\tSIG( \"glTexCoord3iv\" );\n\tdllTexCoord3iv( v );\n}\nstatic void APIENTRY logTexCoord3s(GLshort s, GLshort t, GLshort r)\n{\n\tSIG( \"glTexCoord3s\" );\n\tdllTexCoord3s( s, t, r );\n}\nstatic void APIENTRY logTexCoord3sv(const GLshort *v)\n{\n\tSIG( \"glTexCoord3sv\" );\n\tdllTexCoord3sv( v );\n}\nstatic void APIENTRY logTexCoord4d(GLdouble s, GLdouble t, GLdouble r, GLdouble q)\n{\n\tSIG( \"glTexCoord4d\" );\n\tdllTexCoord4d( s, t, r, q );\n}\nstatic void APIENTRY logTexCoord4dv(const GLdouble *v)\n{\n\tSIG( \"glTexCoord4dv\" );\n\tdllTexCoord4dv( v );\n}\nstatic void APIENTRY logTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q)\n{\n\tSIG( \"glTexCoord4f\" );\n\tdllTexCoord4f( s, t, r, q );\n}\nstatic void APIENTRY logTexCoord4fv(const GLfloat *v)\n{\n\tSIG( \"glTexCoord4fv\" );\n\tdllTexCoord4fv( v );\n}\nstatic void APIENTRY logTexCoord4i(GLint s, GLint t, GLint r, GLint q)\n{\n\tSIG( \"glTexCoord4i\" );\n\tdllTexCoord4i( s, t, r, q );\n}\nstatic void APIENTRY logTexCoord4iv(const GLint *v)\n{\n\tSIG( \"glTexCoord4iv\" );\n\tdllTexCoord4iv( v );\n}\nstatic void APIENTRY logTexCoord4s(GLshort s, GLshort t, GLshort r, GLshort q)\n{\n\tSIG( \"glTexCoord4s\" );\n\tdllTexCoord4s( s, t, r, q );\n}\nstatic void APIENTRY logTexCoord4sv(const GLshort *v)\n{\n\tSIG( \"glTexCoord4sv\" );\n\tdllTexCoord4sv( v );\n}\nstatic void APIENTRY logTexCoordPointer(GLint size, GLenum type, GLsizei stride, const void *pointer)\n{\n\tfprintf( glw_state.log_fp, \"glTexCoordPointer( %d, %s, %d, MEM )\\n\", size, TypeToString( type ), stride );\n\tdllTexCoordPointer( size, type, stride, pointer );\n}\n\nstatic void APIENTRY logTexEnvf(GLenum target, GLenum pname, GLfloat param)\n{\n\tfprintf( glw_state.log_fp, \"glTexEnvf( 0x%x, 0x%x, %f )\\n\", target, pname, param );\n\tdllTexEnvf( target, pname, param );\n}\n\nstatic void APIENTRY logTexEnvfv(GLenum target, GLenum pname, const GLfloat *params)\n{\n\tSIG( \"glTexEnvfv\" );\n\tdllTexEnvfv( target, pname, params );\n}\n\nstatic void APIENTRY logTexEnvi(GLenum target, GLenum pname, GLint param)\n{\n\tfprintf( glw_state.log_fp, \"glTexEnvi( 0x%x, 0x%x, 0x%x )\\n\", target, pname, param );\n\tdllTexEnvi( target, pname, param );\n}\nstatic void APIENTRY logTexEnviv(GLenum target, GLenum pname, const GLint *params)\n{\n\tSIG( \"glTexEnviv\" );\n\tdllTexEnviv( target, pname, params );\n}\n\nstatic void APIENTRY logTexGend(GLenum coord, GLenum pname, GLdouble param)\n{\n\tSIG( \"glTexGend\" );\n\tdllTexGend( coord, pname, param );\n}\n\nstatic void APIENTRY logTexGendv(GLenum coord, GLenum pname, const GLdouble *params)\n{\n\tSIG( \"glTexGendv\" );\n\tdllTexGendv( coord, pname, params );\n}\n\nstatic void APIENTRY logTexGenf(GLenum coord, GLenum pname, GLfloat param)\n{\n\tSIG( \"glTexGenf\" );\n\tdllTexGenf( coord, pname, param );\n}\nstatic void APIENTRY logTexGenfv(GLenum coord, GLenum pname, const GLfloat *params)\n{\n\tSIG( \"glTexGenfv\" );\n\tdllTexGenfv( coord, pname, params );\n}\nstatic void APIENTRY logTexGeni(GLenum coord, GLenum pname, GLint param)\n{\n\tSIG( \"glTexGeni\" );\n\tdllTexGeni( coord, pname, param );\n}\nstatic void APIENTRY logTexGeniv(GLenum coord, GLenum pname, const GLint *params)\n{\n\tSIG( \"glTexGeniv\" );\n\tdllTexGeniv( coord, pname, params );\n}\nstatic void APIENTRY logTexImage1D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels)\n{\n\tSIG( \"glTexImage1D\" );\n\tdllTexImage1D( target, level, internalformat, width, border, format, type, pixels );\n}\nstatic void APIENTRY logTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels)\n{\n\tSIG( \"glTexImage2D\" );\n\tdllTexImage2D( target, level, internalformat, width, height, border, format, type, pixels );\n}\n\nstatic void APIENTRY logTexParameterf(GLenum target, GLenum pname, GLfloat param)\n{\n\tfprintf( glw_state.log_fp, \"glTexParameterf( 0x%x, 0x%x, %f )\\n\", target, pname, param );\n\tdllTexParameterf( target, pname, param );\n}\n\nstatic void APIENTRY logTexParameterfv(GLenum target, GLenum pname, const GLfloat *params)\n{\n\tSIG( \"glTexParameterfv\" );\n\tdllTexParameterfv( target, pname, params );\n}\nstatic void APIENTRY logTexParameteri(GLenum target, GLenum pname, GLint param)\n{\n\tfprintf( glw_state.log_fp, \"glTexParameteri( 0x%x, 0x%x, 0x%x )\\n\", target, pname, param );\n\tdllTexParameteri( target, pname, param );\n}\nstatic void APIENTRY logTexParameteriv(GLenum target, GLenum pname, const GLint *params)\n{\n\tSIG( \"glTexParameteriv\" );\n\tdllTexParameteriv( target, pname, params );\n}\nstatic void APIENTRY logTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels)\n{\n\tSIG( \"glTexSubImage1D\" );\n\tdllTexSubImage1D( target, level, xoffset, width, format, type, pixels );\n}\nstatic void APIENTRY logTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels)\n{\n\tSIG( \"glTexSubImage2D\" );\n\tdllTexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, pixels );\n}\nstatic void APIENTRY logTranslated(GLdouble x, GLdouble y, GLdouble z)\n{\n\tSIG( \"glTranslated\" );\n\tdllTranslated( x, y, z );\n}\n\nstatic void APIENTRY logTranslatef(GLfloat x, GLfloat y, GLfloat z)\n{\n\tSIG( \"glTranslatef\" );\n\tdllTranslatef( x, y, z );\n}\n\nstatic void APIENTRY logVertex2d(GLdouble x, GLdouble y)\n{\n\tSIG( \"glVertex2d\" );\n\tdllVertex2d( x, y );\n}\n\nstatic void APIENTRY logVertex2dv(const GLdouble *v)\n{\n\tSIG( \"glVertex2dv\" );\n\tdllVertex2dv( v );\n}\nstatic void APIENTRY logVertex2f(GLfloat x, GLfloat y)\n{\n\tSIG( \"glVertex2f\" );\n\tdllVertex2f( x, y );\n}\nstatic void APIENTRY logVertex2fv(const GLfloat *v)\n{\n\tSIG( \"glVertex2fv\" );\n\tdllVertex2fv( v );\n}\nstatic void APIENTRY logVertex2i(GLint x, GLint y)\n{\n\tSIG( \"glVertex2i\" );\n\tdllVertex2i( x, y );\n}\nstatic void APIENTRY logVertex2iv(const GLint *v)\n{\n\tSIG( \"glVertex2iv\" );\n\tdllVertex2iv( v );\n}\nstatic void APIENTRY logVertex2s(GLshort x, GLshort y)\n{\n\tSIG( \"glVertex2s\" );\n\tdllVertex2s( x, y );\n}\nstatic void APIENTRY logVertex2sv(const GLshort *v)\n{\n\tSIG( \"glVertex2sv\" );\n\tdllVertex2sv( v );\n}\nstatic void APIENTRY logVertex3d(GLdouble x, GLdouble y, GLdouble z)\n{\n\tSIG( \"glVertex3d\" );\n\tdllVertex3d( x, y, z );\n}\nstatic void APIENTRY logVertex3dv(const GLdouble *v)\n{\n\tSIG( \"glVertex3dv\" );\n\tdllVertex3dv( v );\n}\nstatic void APIENTRY logVertex3f(GLfloat x, GLfloat y, GLfloat z)\n{\n\tSIG( \"glVertex3f\" );\n\tdllVertex3f( x, y, z );\n}\nstatic void APIENTRY logVertex3fv(const GLfloat *v)\n{\n\tSIG( \"glVertex3fv\" );\n\tdllVertex3fv( v );\n}\nstatic void APIENTRY logVertex3i(GLint x, GLint y, GLint z)\n{\n\tSIG( \"glVertex3i\" );\n\tdllVertex3i( x, y, z );\n}\nstatic void APIENTRY logVertex3iv(const GLint *v)\n{\n\tSIG( \"glVertex3iv\" );\n\tdllVertex3iv( v );\n}\nstatic void APIENTRY logVertex3s(GLshort x, GLshort y, GLshort z)\n{\n\tSIG( \"glVertex3s\" );\n\tdllVertex3s( x, y, z );\n}\nstatic void APIENTRY logVertex3sv(const GLshort *v)\n{\n\tSIG( \"glVertex3sv\" );\n\tdllVertex3sv( v );\n}\nstatic void APIENTRY logVertex4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)\n{\n\tSIG( \"glVertex4d\" );\n\tdllVertex4d( x, y, z, w );\n}\nstatic void APIENTRY logVertex4dv(const GLdouble *v)\n{\n\tSIG( \"glVertex4dv\" );\n\tdllVertex4dv( v );\n}\nstatic void APIENTRY logVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)\n{\n\tSIG( \"glVertex4f\" );\n\tdllVertex4f( x, y, z, w );\n}\nstatic void APIENTRY logVertex4fv(const GLfloat *v)\n{\n\tSIG( \"glVertex4fv\" );\n\tdllVertex4fv( v );\n}\nstatic void APIENTRY logVertex4i(GLint x, GLint y, GLint z, GLint w)\n{\n\tSIG( \"glVertex4i\" );\n\tdllVertex4i( x, y, z, w );\n}\nstatic void APIENTRY logVertex4iv(const GLint *v)\n{\n\tSIG( \"glVertex4iv\" );\n\tdllVertex4iv( v );\n}\nstatic void APIENTRY logVertex4s(GLshort x, GLshort y, GLshort z, GLshort w)\n{\n\tSIG( \"glVertex4s\" );\n\tdllVertex4s( x, y, z, w );\n}\nstatic void APIENTRY logVertex4sv(const GLshort *v)\n{\n\tSIG( \"glVertex4sv\" );\n\tdllVertex4sv( v );\n}\nstatic void APIENTRY logVertexPointer(GLint size, GLenum type, GLsizei stride, const void *pointer)\n{\n\tfprintf( glw_state.log_fp, \"glVertexPointer( %d, %s, %d, MEM )\\n\", size, TypeToString( type ), stride );\n\tdllVertexPointer( size, type, stride, pointer );\n}\nstatic void APIENTRY logViewport(GLint x, GLint y, GLsizei width, GLsizei height)\n{\n\tfprintf( glw_state.log_fp, \"glViewport( %d, %d, %d, %d )\\n\", x, y, width, height );\n\tdllViewport( x, y, width, height );\n}\n\n/*\n** QGL_Shutdown\n**\n** Unloads the specified DLL then nulls out all the proc pointers.  This\n** is only called during a hard shutdown of the OGL subsystem (e.g. vid_restart).\n*/\nvoid QGL_Shutdown( void )\n{\n\tri.Printf( PRINT_ALL, \"...shutting down QGL\\n\" );\n\n\tif ( glw_state.hinstOpenGL )\n\t{\n\t\tri.Printf( PRINT_ALL, \"...unloading OpenGL DLL\\n\" );\n\t\tFreeLibrary( glw_state.hinstOpenGL );\n\t}\n\n\tglw_state.hinstOpenGL = NULL;\n\n\tqglAccum                     = NULL;\n\tqglAlphaFunc                 = NULL;\n\tqglAreTexturesResident       = NULL;\n\tqglArrayElement              = NULL;\n\tqglBegin                     = NULL;\n\tqglBindTexture               = NULL;\n\tqglBitmap                    = NULL;\n\tqglBlendFunc                 = NULL;\n\tqglCallList                  = NULL;\n\tqglCallLists                 = NULL;\n\tqglClear                     = NULL;\n\tqglClearAccum                = NULL;\n\tqglClearColor                = NULL;\n\tqglClearDepth                = NULL;\n\tqglClearIndex                = NULL;\n\tqglClearStencil              = NULL;\n\tqglClipPlane                 = NULL;\n\tqglColor3b                   = NULL;\n\tqglColor3bv                  = NULL;\n\tqglColor3d                   = NULL;\n\tqglColor3dv                  = NULL;\n\tqglColor3f                   = NULL;\n\tqglColor3fv                  = NULL;\n\tqglColor3i                   = NULL;\n\tqglColor3iv                  = NULL;\n\tqglColor3s                   = NULL;\n\tqglColor3sv                  = NULL;\n\tqglColor3ub                  = NULL;\n\tqglColor3ubv                 = NULL;\n\tqglColor3ui                  = NULL;\n\tqglColor3uiv                 = NULL;\n\tqglColor3us                  = NULL;\n\tqglColor3usv                 = NULL;\n\tqglColor4b                   = NULL;\n\tqglColor4bv                  = NULL;\n\tqglColor4d                   = NULL;\n\tqglColor4dv                  = NULL;\n\tqglColor4f                   = NULL;\n\tqglColor4fv                  = NULL;\n\tqglColor4i                   = NULL;\n\tqglColor4iv                  = NULL;\n\tqglColor4s                   = NULL;\n\tqglColor4sv                  = NULL;\n\tqglColor4ub                  = NULL;\n\tqglColor4ubv                 = NULL;\n\tqglColor4ui                  = NULL;\n\tqglColor4uiv                 = NULL;\n\tqglColor4us                  = NULL;\n\tqglColor4usv                 = NULL;\n\tqglColorMask                 = NULL;\n\tqglColorMaterial             = NULL;\n\tqglColorPointer              = NULL;\n\tqglCopyPixels                = NULL;\n\tqglCopyTexImage1D            = NULL;\n\tqglCopyTexImage2D            = NULL;\n\tqglCopyTexSubImage1D         = NULL;\n\tqglCopyTexSubImage2D         = NULL;\n\tqglCullFace                  = NULL;\n\tqglDeleteLists               = NULL;\n\tqglDeleteTextures            = NULL;\n\tqglDepthFunc                 = NULL;\n\tqglDepthMask                 = NULL;\n\tqglDepthRange                = NULL;\n\tqglDisable                   = NULL;\n\tqglDisableClientState        = NULL;\n\tqglDrawArrays                = NULL;\n\tqglDrawBuffer                = NULL;\n\tqglDrawElements              = NULL;\n\tqglDrawPixels                = NULL;\n\tqglEdgeFlag                  = NULL;\n\tqglEdgeFlagPointer           = NULL;\n\tqglEdgeFlagv                 = NULL;\n\tqglEnable                    = NULL;\n\tqglEnableClientState         = NULL;\n\tqglEnd                       = NULL;\n\tqglEndList                   = NULL;\n\tqglEvalCoord1d               = NULL;\n\tqglEvalCoord1dv              = NULL;\n\tqglEvalCoord1f               = NULL;\n\tqglEvalCoord1fv              = NULL;\n\tqglEvalCoord2d               = NULL;\n\tqglEvalCoord2dv              = NULL;\n\tqglEvalCoord2f               = NULL;\n\tqglEvalCoord2fv              = NULL;\n\tqglEvalMesh1                 = NULL;\n\tqglEvalMesh2                 = NULL;\n\tqglEvalPoint1                = NULL;\n\tqglEvalPoint2                = NULL;\n\tqglFeedbackBuffer            = NULL;\n\tqglFinish                    = NULL;\n\tqglFlush                     = NULL;\n\tqglFogf                      = NULL;\n\tqglFogfv                     = NULL;\n\tqglFogi                      = NULL;\n\tqglFogiv                     = NULL;\n\tqglFrontFace                 = NULL;\n\tqglFrustum                   = NULL;\n\tqglGenLists                  = NULL;\n\tqglGenTextures               = NULL;\n\tqglGetBooleanv               = NULL;\n\tqglGetClipPlane              = NULL;\n\tqglGetDoublev                = NULL;\n\tqglGetError                  = NULL;\n\tqglGetFloatv                 = NULL;\n\tqglGetIntegerv               = NULL;\n\tqglGetLightfv                = NULL;\n\tqglGetLightiv                = NULL;\n\tqglGetMapdv                  = NULL;\n\tqglGetMapfv                  = NULL;\n\tqglGetMapiv                  = NULL;\n\tqglGetMaterialfv             = NULL;\n\tqglGetMaterialiv             = NULL;\n\tqglGetPixelMapfv             = NULL;\n\tqglGetPixelMapuiv            = NULL;\n\tqglGetPixelMapusv            = NULL;\n\tqglGetPointerv               = NULL;\n\tqglGetPolygonStipple         = NULL;\n\tqglGetString                 = NULL;\n\tqglGetTexEnvfv               = NULL;\n\tqglGetTexEnviv               = NULL;\n\tqglGetTexGendv               = NULL;\n\tqglGetTexGenfv               = NULL;\n\tqglGetTexGeniv               = NULL;\n\tqglGetTexImage               = NULL;\n\tqglGetTexLevelParameterfv    = NULL;\n\tqglGetTexLevelParameteriv    = NULL;\n\tqglGetTexParameterfv         = NULL;\n\tqglGetTexParameteriv         = NULL;\n\tqglHint                      = NULL;\n\tqglIndexMask                 = NULL;\n\tqglIndexPointer              = NULL;\n\tqglIndexd                    = NULL;\n\tqglIndexdv                   = NULL;\n\tqglIndexf                    = NULL;\n\tqglIndexfv                   = NULL;\n\tqglIndexi                    = NULL;\n\tqglIndexiv                   = NULL;\n\tqglIndexs                    = NULL;\n\tqglIndexsv                   = NULL;\n\tqglIndexub                   = NULL;\n\tqglIndexubv                  = NULL;\n\tqglInitNames                 = NULL;\n\tqglInterleavedArrays         = NULL;\n\tqglIsEnabled                 = NULL;\n\tqglIsList                    = NULL;\n\tqglIsTexture                 = NULL;\n\tqglLightModelf               = NULL;\n\tqglLightModelfv              = NULL;\n\tqglLightModeli               = NULL;\n\tqglLightModeliv              = NULL;\n\tqglLightf                    = NULL;\n\tqglLightfv                   = NULL;\n\tqglLighti                    = NULL;\n\tqglLightiv                   = NULL;\n\tqglLineStipple               = NULL;\n\tqglLineWidth                 = NULL;\n\tqglListBase                  = NULL;\n\tqglLoadIdentity              = NULL;\n\tqglLoadMatrixd               = NULL;\n\tqglLoadMatrixf               = NULL;\n\tqglLoadName                  = NULL;\n\tqglLogicOp                   = NULL;\n\tqglMap1d                     = NULL;\n\tqglMap1f                     = NULL;\n\tqglMap2d                     = NULL;\n\tqglMap2f                     = NULL;\n\tqglMapGrid1d                 = NULL;\n\tqglMapGrid1f                 = NULL;\n\tqglMapGrid2d                 = NULL;\n\tqglMapGrid2f                 = NULL;\n\tqglMaterialf                 = NULL;\n\tqglMaterialfv                = NULL;\n\tqglMateriali                 = NULL;\n\tqglMaterialiv                = NULL;\n\tqglMatrixMode                = NULL;\n\tqglMultMatrixd               = NULL;\n\tqglMultMatrixf               = NULL;\n\tqglNewList                   = NULL;\n\tqglNormal3b                  = NULL;\n\tqglNormal3bv                 = NULL;\n\tqglNormal3d                  = NULL;\n\tqglNormal3dv                 = NULL;\n\tqglNormal3f                  = NULL;\n\tqglNormal3fv                 = NULL;\n\tqglNormal3i                  = NULL;\n\tqglNormal3iv                 = NULL;\n\tqglNormal3s                  = NULL;\n\tqglNormal3sv                 = NULL;\n\tqglNormalPointer             = NULL;\n\tqglOrtho                     = NULL;\n\tqglPassThrough               = NULL;\n\tqglPixelMapfv                = NULL;\n\tqglPixelMapuiv               = NULL;\n\tqglPixelMapusv               = NULL;\n\tqglPixelStoref               = NULL;\n\tqglPixelStorei               = NULL;\n\tqglPixelTransferf            = NULL;\n\tqglPixelTransferi            = NULL;\n\tqglPixelZoom                 = NULL;\n\tqglPointSize                 = NULL;\n\tqglPolygonMode               = NULL;\n\tqglPolygonOffset             = NULL;\n\tqglPolygonStipple            = NULL;\n\tqglPopAttrib                 = NULL;\n\tqglPopClientAttrib           = NULL;\n\tqglPopMatrix                 = NULL;\n\tqglPopName                   = NULL;\n\tqglPrioritizeTextures        = NULL;\n\tqglPushAttrib                = NULL;\n\tqglPushClientAttrib          = NULL;\n\tqglPushMatrix                = NULL;\n\tqglPushName                  = NULL;\n\tqglRasterPos2d               = NULL;\n\tqglRasterPos2dv              = NULL;\n\tqglRasterPos2f               = NULL;\n\tqglRasterPos2fv              = NULL;\n\tqglRasterPos2i               = NULL;\n\tqglRasterPos2iv              = NULL;\n\tqglRasterPos2s               = NULL;\n\tqglRasterPos2sv              = NULL;\n\tqglRasterPos3d               = NULL;\n\tqglRasterPos3dv              = NULL;\n\tqglRasterPos3f               = NULL;\n\tqglRasterPos3fv              = NULL;\n\tqglRasterPos3i               = NULL;\n\tqglRasterPos3iv              = NULL;\n\tqglRasterPos3s               = NULL;\n\tqglRasterPos3sv              = NULL;\n\tqglRasterPos4d               = NULL;\n\tqglRasterPos4dv              = NULL;\n\tqglRasterPos4f               = NULL;\n\tqglRasterPos4fv              = NULL;\n\tqglRasterPos4i               = NULL;\n\tqglRasterPos4iv              = NULL;\n\tqglRasterPos4s               = NULL;\n\tqglRasterPos4sv              = NULL;\n\tqglReadBuffer                = NULL;\n\tqglReadPixels                = NULL;\n\tqglRectd                     = NULL;\n\tqglRectdv                    = NULL;\n\tqglRectf                     = NULL;\n\tqglRectfv                    = NULL;\n\tqglRecti                     = NULL;\n\tqglRectiv                    = NULL;\n\tqglRects                     = NULL;\n\tqglRectsv                    = NULL;\n\tqglRenderMode                = NULL;\n\tqglRotated                   = NULL;\n\tqglRotatef                   = NULL;\n\tqglScaled                    = NULL;\n\tqglScalef                    = NULL;\n\tqglScissor                   = NULL;\n\tqglSelectBuffer              = NULL;\n\tqglShadeModel                = NULL;\n\tqglStencilFunc               = NULL;\n\tqglStencilMask               = NULL;\n\tqglStencilOp                 = NULL;\n\tqglTexCoord1d                = NULL;\n\tqglTexCoord1dv               = NULL;\n\tqglTexCoord1f                = NULL;\n\tqglTexCoord1fv               = NULL;\n\tqglTexCoord1i                = NULL;\n\tqglTexCoord1iv               = NULL;\n\tqglTexCoord1s                = NULL;\n\tqglTexCoord1sv               = NULL;\n\tqglTexCoord2d                = NULL;\n\tqglTexCoord2dv               = NULL;\n\tqglTexCoord2f                = NULL;\n\tqglTexCoord2fv               = NULL;\n\tqglTexCoord2i                = NULL;\n\tqglTexCoord2iv               = NULL;\n\tqglTexCoord2s                = NULL;\n\tqglTexCoord2sv               = NULL;\n\tqglTexCoord3d                = NULL;\n\tqglTexCoord3dv               = NULL;\n\tqglTexCoord3f                = NULL;\n\tqglTexCoord3fv               = NULL;\n\tqglTexCoord3i                = NULL;\n\tqglTexCoord3iv               = NULL;\n\tqglTexCoord3s                = NULL;\n\tqglTexCoord3sv               = NULL;\n\tqglTexCoord4d                = NULL;\n\tqglTexCoord4dv               = NULL;\n\tqglTexCoord4f                = NULL;\n\tqglTexCoord4fv               = NULL;\n\tqglTexCoord4i                = NULL;\n\tqglTexCoord4iv               = NULL;\n\tqglTexCoord4s                = NULL;\n\tqglTexCoord4sv               = NULL;\n\tqglTexCoordPointer           = NULL;\n\tqglTexEnvf                   = NULL;\n\tqglTexEnvfv                  = NULL;\n\tqglTexEnvi                   = NULL;\n\tqglTexEnviv                  = NULL;\n\tqglTexGend                   = NULL;\n\tqglTexGendv                  = NULL;\n\tqglTexGenf                   = NULL;\n\tqglTexGenfv                  = NULL;\n\tqglTexGeni                   = NULL;\n\tqglTexGeniv                  = NULL;\n\tqglTexImage1D                = NULL;\n\tqglTexImage2D                = NULL;\n\tqglTexParameterf             = NULL;\n\tqglTexParameterfv            = NULL;\n\tqglTexParameteri             = NULL;\n\tqglTexParameteriv            = NULL;\n\tqglTexSubImage1D             = NULL;\n\tqglTexSubImage2D             = NULL;\n\tqglTranslated                = NULL;\n\tqglTranslatef                = NULL;\n\tqglVertex2d                  = NULL;\n\tqglVertex2dv                 = NULL;\n\tqglVertex2f                  = NULL;\n\tqglVertex2fv                 = NULL;\n\tqglVertex2i                  = NULL;\n\tqglVertex2iv                 = NULL;\n\tqglVertex2s                  = NULL;\n\tqglVertex2sv                 = NULL;\n\tqglVertex3d                  = NULL;\n\tqglVertex3dv                 = NULL;\n\tqglVertex3f                  = NULL;\n\tqglVertex3fv                 = NULL;\n\tqglVertex3i                  = NULL;\n\tqglVertex3iv                 = NULL;\n\tqglVertex3s                  = NULL;\n\tqglVertex3sv                 = NULL;\n\tqglVertex4d                  = NULL;\n\tqglVertex4dv                 = NULL;\n\tqglVertex4f                  = NULL;\n\tqglVertex4fv                 = NULL;\n\tqglVertex4i                  = NULL;\n\tqglVertex4iv                 = NULL;\n\tqglVertex4s                  = NULL;\n\tqglVertex4sv                 = NULL;\n\tqglVertexPointer             = NULL;\n\tqglViewport                  = NULL;\n\n\tqwglCopyContext              = NULL;\n\tqwglCreateContext            = NULL;\n\tqwglCreateLayerContext       = NULL;\n\tqwglDeleteContext            = NULL;\n\tqwglDescribeLayerPlane       = NULL;\n\tqwglGetCurrentContext        = NULL;\n\tqwglGetCurrentDC             = NULL;\n\tqwglGetLayerPaletteEntries   = NULL;\n\tqwglGetProcAddress           = NULL;\n\tqwglMakeCurrent              = NULL;\n\tqwglRealizeLayerPalette      = NULL;\n\tqwglSetLayerPaletteEntries   = NULL;\n\tqwglShareLists               = NULL;\n\tqwglSwapLayerBuffers         = NULL;\n\tqwglUseFontBitmaps           = NULL;\n\tqwglUseFontOutlines          = NULL;\n\n\tqwglChoosePixelFormat        = NULL;\n\tqwglDescribePixelFormat      = NULL;\n\tqwglGetPixelFormat           = NULL;\n\tqwglSetPixelFormat           = NULL;\n\tqwglSwapBuffers              = NULL;\n}\n\n#define GR_NUM_BOARDS 0x0f\n\nstatic qboolean GlideIsValid( void )\n{\n\tHMODULE hGlide;\n//\tint numBoards;\n//\tvoid (__stdcall *grGet)(unsigned int, unsigned int, int*);\n\n    if ( ( hGlide = LoadLibrary(\"Glide3X\") ) != 0 ) \n\t{\n\t\t// FIXME: 3Dfx needs to fix this shit\n\t\treturn qtrue;\n\n#if 0\n        grGet = (void *)GetProcAddress( hGlide, \"_grGet@12\");\n\n\t\tif ( grGet )\n\t\t{\n\t        grGet( GR_NUM_BOARDS, sizeof(int), &numBoards);\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// if we've reached this point, something is seriously wrong\n\t\t\tri.Printf( PRINT_WARNING, \"WARNING: could not find grGet in GLIDE3X.DLL\\n\" );\n\t\t\tnumBoards = 0;\n\t\t}\n\n\t\tFreeLibrary( hGlide );\n\t\thGlide = NULL;\n\n\t\tif ( numBoards > 0 )\n\t\t{\n\t\t\treturn qtrue;\n\t\t}\n\n\t\tri.Printf( PRINT_WARNING, \"WARNING: invalid Glide installation!\\n\" );\n#endif\n    }\n\n\treturn qfalse;\n} \n\n#\tpragma warning (disable : 4113 4133 4047 )\n#\tdefine GPA( a ) GetProcAddress( glw_state.hinstOpenGL, a )\n\n/*\n** QGL_Init\n**\n** This is responsible for binding our qgl function pointers to \n** the appropriate GL stuff.  In Windows this means doing a \n** LoadLibrary and a bunch of calls to GetProcAddress.  On other\n** operating systems we need to do the right thing, whatever that\n** might be.\n*/\nqboolean QGL_Init( const char *dllname )\n{\n\tchar systemDir[1024];\n\tchar libName[1024];\n\n\tGetSystemDirectory( systemDir, sizeof( systemDir ) );\n\n\tassert( glw_state.hinstOpenGL == 0 );\n\n\tri.Printf( PRINT_ALL, \"...initializing QGL\\n\" );\n\n\t// NOTE: this assumes that 'dllname' is lower case (and it should be)!\n\tif ( strstr( dllname, _3DFX_DRIVER_NAME ) )\n\t{\n\t\tif ( !GlideIsValid() )\n\t\t{\n\t\t\tri.Printf( PRINT_ALL, \"...WARNING: missing Glide installation, assuming no 3Dfx available\\n\" );\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\tif ( dllname[0] != '!' )\n\t{\n\t\tCom_sprintf( libName, sizeof( libName ), \"%s\\\\%s\", systemDir, dllname );\n\t}\n\telse\n\t{\n\t\tQ_strncpyz( libName, dllname, sizeof( libName ) );\n\t}\n\n\tri.Printf( PRINT_ALL, \"...calling LoadLibrary( '%s.dll' ): \", libName );\n\n\tif ( ( glw_state.hinstOpenGL = LoadLibrary( dllname ) ) == 0 )\n\t{\n\t\tri.Printf( PRINT_ALL, \"failed\\n\" );\n\t\treturn qfalse;\n\t}\n\tri.Printf( PRINT_ALL, \"succeeded\\n\" );\n\n\tqglAccum                     = dllAccum = GPA( \"glAccum\" );\n\tqglAlphaFunc                 = dllAlphaFunc = GPA( \"glAlphaFunc\" );\n\tqglAreTexturesResident       = dllAreTexturesResident = GPA( \"glAreTexturesResident\" );\n\tqglArrayElement              = dllArrayElement = GPA( \"glArrayElement\" );\n\tqglBegin                     = dllBegin = GPA( \"glBegin\" );\n\tqglBindTexture               = dllBindTexture = GPA( \"glBindTexture\" );\n\tqglBitmap                    = dllBitmap = GPA( \"glBitmap\" );\n\tqglBlendFunc                 = dllBlendFunc = GPA( \"glBlendFunc\" );\n\tqglCallList                  = dllCallList = GPA( \"glCallList\" );\n\tqglCallLists                 = dllCallLists = GPA( \"glCallLists\" );\n\tqglClear                     = dllClear = GPA( \"glClear\" );\n\tqglClearAccum                = dllClearAccum = GPA( \"glClearAccum\" );\n\tqglClearColor                = dllClearColor = GPA( \"glClearColor\" );\n\tqglClearDepth                = dllClearDepth = GPA( \"glClearDepth\" );\n\tqglClearIndex                = dllClearIndex = GPA( \"glClearIndex\" );\n\tqglClearStencil              = dllClearStencil = GPA( \"glClearStencil\" );\n\tqglClipPlane                 = dllClipPlane = GPA( \"glClipPlane\" );\n\tqglColor3b                   = dllColor3b = GPA( \"glColor3b\" );\n\tqglColor3bv                  = dllColor3bv = GPA( \"glColor3bv\" );\n\tqglColor3d                   = dllColor3d = GPA( \"glColor3d\" );\n\tqglColor3dv                  = dllColor3dv = GPA( \"glColor3dv\" );\n\tqglColor3f                   = dllColor3f = GPA( \"glColor3f\" );\n\tqglColor3fv                  = dllColor3fv = GPA( \"glColor3fv\" );\n\tqglColor3i                   = dllColor3i = GPA( \"glColor3i\" );\n\tqglColor3iv                  = dllColor3iv = GPA( \"glColor3iv\" );\n\tqglColor3s                   = dllColor3s = GPA( \"glColor3s\" );\n\tqglColor3sv                  = dllColor3sv = GPA( \"glColor3sv\" );\n\tqglColor3ub                  = dllColor3ub = GPA( \"glColor3ub\" );\n\tqglColor3ubv                 = dllColor3ubv = GPA( \"glColor3ubv\" );\n\tqglColor3ui                  = dllColor3ui = GPA( \"glColor3ui\" );\n\tqglColor3uiv                 = dllColor3uiv = GPA( \"glColor3uiv\" );\n\tqglColor3us                  = dllColor3us = GPA( \"glColor3us\" );\n\tqglColor3usv                 = dllColor3usv = GPA( \"glColor3usv\" );\n\tqglColor4b                   = dllColor4b = GPA( \"glColor4b\" );\n\tqglColor4bv                  = dllColor4bv = GPA( \"glColor4bv\" );\n\tqglColor4d                   = dllColor4d = GPA( \"glColor4d\" );\n\tqglColor4dv                  = dllColor4dv = GPA( \"glColor4dv\" );\n\tqglColor4f                   = dllColor4f = GPA( \"glColor4f\" );\n\tqglColor4fv                  = dllColor4fv = GPA( \"glColor4fv\" );\n\tqglColor4i                   = dllColor4i = GPA( \"glColor4i\" );\n\tqglColor4iv                  = dllColor4iv = GPA( \"glColor4iv\" );\n\tqglColor4s                   = dllColor4s = GPA( \"glColor4s\" );\n\tqglColor4sv                  = dllColor4sv = GPA( \"glColor4sv\" );\n\tqglColor4ub                  = dllColor4ub = GPA( \"glColor4ub\" );\n\tqglColor4ubv                 = dllColor4ubv = GPA( \"glColor4ubv\" );\n\tqglColor4ui                  = dllColor4ui = GPA( \"glColor4ui\" );\n\tqglColor4uiv                 = dllColor4uiv = GPA( \"glColor4uiv\" );\n\tqglColor4us                  = dllColor4us = GPA( \"glColor4us\" );\n\tqglColor4usv                 = dllColor4usv = GPA( \"glColor4usv\" );\n\tqglColorMask                 = dllColorMask = GPA( \"glColorMask\" );\n\tqglColorMaterial             = dllColorMaterial = GPA( \"glColorMaterial\" );\n\tqglColorPointer              = dllColorPointer = GPA( \"glColorPointer\" );\n\tqglCopyPixels                = dllCopyPixels = GPA( \"glCopyPixels\" );\n\tqglCopyTexImage1D            = dllCopyTexImage1D = GPA( \"glCopyTexImage1D\" );\n\tqglCopyTexImage2D            = dllCopyTexImage2D = GPA( \"glCopyTexImage2D\" );\n\tqglCopyTexSubImage1D         = dllCopyTexSubImage1D = GPA( \"glCopyTexSubImage1D\" );\n\tqglCopyTexSubImage2D         = dllCopyTexSubImage2D = GPA( \"glCopyTexSubImage2D\" );\n\tqglCullFace                  = dllCullFace = GPA( \"glCullFace\" );\n\tqglDeleteLists               = dllDeleteLists = GPA( \"glDeleteLists\" );\n\tqglDeleteTextures            = dllDeleteTextures = GPA( \"glDeleteTextures\" );\n\tqglDepthFunc                 = dllDepthFunc = GPA( \"glDepthFunc\" );\n\tqglDepthMask                 = dllDepthMask = GPA( \"glDepthMask\" );\n\tqglDepthRange                = dllDepthRange = GPA( \"glDepthRange\" );\n\tqglDisable                   = dllDisable = GPA( \"glDisable\" );\n\tqglDisableClientState        = dllDisableClientState = GPA( \"glDisableClientState\" );\n\tqglDrawArrays                = dllDrawArrays = GPA( \"glDrawArrays\" );\n\tqglDrawBuffer                = dllDrawBuffer = GPA( \"glDrawBuffer\" );\n\tqglDrawElements              = dllDrawElements = GPA( \"glDrawElements\" );\n\tqglDrawPixels                = dllDrawPixels = GPA( \"glDrawPixels\" );\n\tqglEdgeFlag                  = dllEdgeFlag = GPA( \"glEdgeFlag\" );\n\tqglEdgeFlagPointer           = dllEdgeFlagPointer = GPA( \"glEdgeFlagPointer\" );\n\tqglEdgeFlagv                 = dllEdgeFlagv = GPA( \"glEdgeFlagv\" );\n\tqglEnable                    = \tdllEnable                    = GPA( \"glEnable\" );\n\tqglEnableClientState         = \tdllEnableClientState         = GPA( \"glEnableClientState\" );\n\tqglEnd                       = \tdllEnd                       = GPA( \"glEnd\" );\n\tqglEndList                   = \tdllEndList                   = GPA( \"glEndList\" );\n\tqglEvalCoord1d\t\t\t\t = \tdllEvalCoord1d\t\t\t\t = GPA( \"glEvalCoord1d\" );\n\tqglEvalCoord1dv              = \tdllEvalCoord1dv              = GPA( \"glEvalCoord1dv\" );\n\tqglEvalCoord1f               = \tdllEvalCoord1f               = GPA( \"glEvalCoord1f\" );\n\tqglEvalCoord1fv              = \tdllEvalCoord1fv              = GPA( \"glEvalCoord1fv\" );\n\tqglEvalCoord2d               = \tdllEvalCoord2d               = GPA( \"glEvalCoord2d\" );\n\tqglEvalCoord2dv              = \tdllEvalCoord2dv              = GPA( \"glEvalCoord2dv\" );\n\tqglEvalCoord2f               = \tdllEvalCoord2f               = GPA( \"glEvalCoord2f\" );\n\tqglEvalCoord2fv              = \tdllEvalCoord2fv              = GPA( \"glEvalCoord2fv\" );\n\tqglEvalMesh1                 = \tdllEvalMesh1                 = GPA( \"glEvalMesh1\" );\n\tqglEvalMesh2                 = \tdllEvalMesh2                 = GPA( \"glEvalMesh2\" );\n\tqglEvalPoint1                = \tdllEvalPoint1                = GPA( \"glEvalPoint1\" );\n\tqglEvalPoint2                = \tdllEvalPoint2                = GPA( \"glEvalPoint2\" );\n\tqglFeedbackBuffer            = \tdllFeedbackBuffer            = GPA( \"glFeedbackBuffer\" );\n\tqglFinish                    = \tdllFinish                    = GPA( \"glFinish\" );\n\tqglFlush                     = \tdllFlush                     = GPA( \"glFlush\" );\n\tqglFogf                      = \tdllFogf                      = GPA( \"glFogf\" );\n\tqglFogfv                     = \tdllFogfv                     = GPA( \"glFogfv\" );\n\tqglFogi                      = \tdllFogi                      = GPA( \"glFogi\" );\n\tqglFogiv                     = \tdllFogiv                     = GPA( \"glFogiv\" );\n\tqglFrontFace                 = \tdllFrontFace                 = GPA( \"glFrontFace\" );\n\tqglFrustum                   = \tdllFrustum                   = GPA( \"glFrustum\" );\n\tqglGenLists                  = \tdllGenLists                  = ( GLuint (__stdcall * )(int) ) GPA( \"glGenLists\" );\n\tqglGenTextures               = \tdllGenTextures               = GPA( \"glGenTextures\" );\n\tqglGetBooleanv               = \tdllGetBooleanv               = GPA( \"glGetBooleanv\" );\n\tqglGetClipPlane              = \tdllGetClipPlane              = GPA( \"glGetClipPlane\" );\n\tqglGetDoublev                = \tdllGetDoublev                = GPA( \"glGetDoublev\" );\n\tqglGetError                  = \tdllGetError                  = ( GLenum (__stdcall * )(void) ) GPA( \"glGetError\" );\n\tqglGetFloatv                 = \tdllGetFloatv                 = GPA( \"glGetFloatv\" );\n\tqglGetIntegerv               = \tdllGetIntegerv               = GPA( \"glGetIntegerv\" );\n\tqglGetLightfv                = \tdllGetLightfv                = GPA( \"glGetLightfv\" );\n\tqglGetLightiv                = \tdllGetLightiv                = GPA( \"glGetLightiv\" );\n\tqglGetMapdv                  = \tdllGetMapdv                  = GPA( \"glGetMapdv\" );\n\tqglGetMapfv                  = \tdllGetMapfv                  = GPA( \"glGetMapfv\" );\n\tqglGetMapiv                  = \tdllGetMapiv                  = GPA( \"glGetMapiv\" );\n\tqglGetMaterialfv             = \tdllGetMaterialfv             = GPA( \"glGetMaterialfv\" );\n\tqglGetMaterialiv             = \tdllGetMaterialiv             = GPA( \"glGetMaterialiv\" );\n\tqglGetPixelMapfv             = \tdllGetPixelMapfv             = GPA( \"glGetPixelMapfv\" );\n\tqglGetPixelMapuiv            = \tdllGetPixelMapuiv            = GPA( \"glGetPixelMapuiv\" );\n\tqglGetPixelMapusv            = \tdllGetPixelMapusv            = GPA( \"glGetPixelMapusv\" );\n\tqglGetPointerv               = \tdllGetPointerv               = GPA( \"glGetPointerv\" );\n\tqglGetPolygonStipple         = \tdllGetPolygonStipple         = GPA( \"glGetPolygonStipple\" );\n\tqglGetString                 = \tdllGetString                 = GPA( \"glGetString\" );\n\tqglGetTexEnvfv               = \tdllGetTexEnvfv               = GPA( \"glGetTexEnvfv\" );\n\tqglGetTexEnviv               = \tdllGetTexEnviv               = GPA( \"glGetTexEnviv\" );\n\tqglGetTexGendv               = \tdllGetTexGendv               = GPA( \"glGetTexGendv\" );\n\tqglGetTexGenfv               = \tdllGetTexGenfv               = GPA( \"glGetTexGenfv\" );\n\tqglGetTexGeniv               = \tdllGetTexGeniv               = GPA( \"glGetTexGeniv\" );\n\tqglGetTexImage               = \tdllGetTexImage               = GPA( \"glGetTexImage\" );\n\tqglGetTexParameterfv         = \tdllGetTexParameterfv         = GPA( \"glGetTexParameterfv\" );\n\tqglGetTexParameteriv         = \tdllGetTexParameteriv         = GPA( \"glGetTexParameteriv\" );\n\tqglHint                      = \tdllHint                      = GPA( \"glHint\" );\n\tqglIndexMask                 = \tdllIndexMask                 = GPA( \"glIndexMask\" );\n\tqglIndexPointer              = \tdllIndexPointer              = GPA( \"glIndexPointer\" );\n\tqglIndexd                    = \tdllIndexd                    = GPA( \"glIndexd\" );\n\tqglIndexdv                   = \tdllIndexdv                   = GPA( \"glIndexdv\" );\n\tqglIndexf                    = \tdllIndexf                    = GPA( \"glIndexf\" );\n\tqglIndexfv                   = \tdllIndexfv                   = GPA( \"glIndexfv\" );\n\tqglIndexi                    = \tdllIndexi                    = GPA( \"glIndexi\" );\n\tqglIndexiv                   = \tdllIndexiv                   = GPA( \"glIndexiv\" );\n\tqglIndexs                    = \tdllIndexs                    = GPA( \"glIndexs\" );\n\tqglIndexsv                   = \tdllIndexsv                   = GPA( \"glIndexsv\" );\n\tqglIndexub                   = \tdllIndexub                   = GPA( \"glIndexub\" );\n\tqglIndexubv                  = \tdllIndexubv                  = GPA( \"glIndexubv\" );\n\tqglInitNames                 = \tdllInitNames                 = GPA( \"glInitNames\" );\n\tqglInterleavedArrays         = \tdllInterleavedArrays         = GPA( \"glInterleavedArrays\" );\n\tqglIsEnabled                 = \tdllIsEnabled                 = GPA( \"glIsEnabled\" );\n\tqglIsList                    = \tdllIsList                    = GPA( \"glIsList\" );\n\tqglIsTexture                 = \tdllIsTexture                 = GPA( \"glIsTexture\" );\n\tqglLightModelf               = \tdllLightModelf               = GPA( \"glLightModelf\" );\n\tqglLightModelfv              = \tdllLightModelfv              = GPA( \"glLightModelfv\" );\n\tqglLightModeli               = \tdllLightModeli               = GPA( \"glLightModeli\" );\n\tqglLightModeliv              = \tdllLightModeliv              = GPA( \"glLightModeliv\" );\n\tqglLightf                    = \tdllLightf                    = GPA( \"glLightf\" );\n\tqglLightfv                   = \tdllLightfv                   = GPA( \"glLightfv\" );\n\tqglLighti                    = \tdllLighti                    = GPA( \"glLighti\" );\n\tqglLightiv                   = \tdllLightiv                   = GPA( \"glLightiv\" );\n\tqglLineStipple               = \tdllLineStipple               = GPA( \"glLineStipple\" );\n\tqglLineWidth                 = \tdllLineWidth                 = GPA( \"glLineWidth\" );\n\tqglListBase                  = \tdllListBase                  = GPA( \"glListBase\" );\n\tqglLoadIdentity              = \tdllLoadIdentity              = GPA( \"glLoadIdentity\" );\n\tqglLoadMatrixd               = \tdllLoadMatrixd               = GPA( \"glLoadMatrixd\" );\n\tqglLoadMatrixf               = \tdllLoadMatrixf               = GPA( \"glLoadMatrixf\" );\n\tqglLoadName                  = \tdllLoadName                  = GPA( \"glLoadName\" );\n\tqglLogicOp                   = \tdllLogicOp                   = GPA( \"glLogicOp\" );\n\tqglMap1d                     = \tdllMap1d                     = GPA( \"glMap1d\" );\n\tqglMap1f                     = \tdllMap1f                     = GPA( \"glMap1f\" );\n\tqglMap2d                     = \tdllMap2d                     = GPA( \"glMap2d\" );\n\tqglMap2f                     = \tdllMap2f                     = GPA( \"glMap2f\" );\n\tqglMapGrid1d                 = \tdllMapGrid1d                 = GPA( \"glMapGrid1d\" );\n\tqglMapGrid1f                 = \tdllMapGrid1f                 = GPA( \"glMapGrid1f\" );\n\tqglMapGrid2d                 = \tdllMapGrid2d                 = GPA( \"glMapGrid2d\" );\n\tqglMapGrid2f                 = \tdllMapGrid2f                 = GPA( \"glMapGrid2f\" );\n\tqglMaterialf                 = \tdllMaterialf                 = GPA( \"glMaterialf\" );\n\tqglMaterialfv                = \tdllMaterialfv                = GPA( \"glMaterialfv\" );\n\tqglMateriali                 = \tdllMateriali                 = GPA( \"glMateriali\" );\n\tqglMaterialiv                = \tdllMaterialiv                = GPA( \"glMaterialiv\" );\n\tqglMatrixMode                = \tdllMatrixMode                = GPA( \"glMatrixMode\" );\n\tqglMultMatrixd               = \tdllMultMatrixd               = GPA( \"glMultMatrixd\" );\n\tqglMultMatrixf               = \tdllMultMatrixf               = GPA( \"glMultMatrixf\" );\n\tqglNewList                   = \tdllNewList                   = GPA( \"glNewList\" );\n\tqglNormal3b                  = \tdllNormal3b                  = GPA( \"glNormal3b\" );\n\tqglNormal3bv                 = \tdllNormal3bv                 = GPA( \"glNormal3bv\" );\n\tqglNormal3d                  = \tdllNormal3d                  = GPA( \"glNormal3d\" );\n\tqglNormal3dv                 = \tdllNormal3dv                 = GPA( \"glNormal3dv\" );\n\tqglNormal3f                  = \tdllNormal3f                  = GPA( \"glNormal3f\" );\n\tqglNormal3fv                 = \tdllNormal3fv                 = GPA( \"glNormal3fv\" );\n\tqglNormal3i                  = \tdllNormal3i                  = GPA( \"glNormal3i\" );\n\tqglNormal3iv                 = \tdllNormal3iv                 = GPA( \"glNormal3iv\" );\n\tqglNormal3s                  = \tdllNormal3s                  = GPA( \"glNormal3s\" );\n\tqglNormal3sv                 = \tdllNormal3sv                 = GPA( \"glNormal3sv\" );\n\tqglNormalPointer             = \tdllNormalPointer             = GPA( \"glNormalPointer\" );\n\tqglOrtho                     = \tdllOrtho                     = GPA( \"glOrtho\" );\n\tqglPassThrough               = \tdllPassThrough               = GPA( \"glPassThrough\" );\n\tqglPixelMapfv                = \tdllPixelMapfv                = GPA( \"glPixelMapfv\" );\n\tqglPixelMapuiv               = \tdllPixelMapuiv               = GPA( \"glPixelMapuiv\" );\n\tqglPixelMapusv               = \tdllPixelMapusv               = GPA( \"glPixelMapusv\" );\n\tqglPixelStoref               = \tdllPixelStoref               = GPA( \"glPixelStoref\" );\n\tqglPixelStorei               = \tdllPixelStorei               = GPA( \"glPixelStorei\" );\n\tqglPixelTransferf            = \tdllPixelTransferf            = GPA( \"glPixelTransferf\" );\n\tqglPixelTransferi            = \tdllPixelTransferi            = GPA( \"glPixelTransferi\" );\n\tqglPixelZoom                 = \tdllPixelZoom                 = GPA( \"glPixelZoom\" );\n\tqglPointSize                 = \tdllPointSize                 = GPA( \"glPointSize\" );\n\tqglPolygonMode               = \tdllPolygonMode               = GPA( \"glPolygonMode\" );\n\tqglPolygonOffset             = \tdllPolygonOffset             = GPA( \"glPolygonOffset\" );\n\tqglPolygonStipple            = \tdllPolygonStipple            = GPA( \"glPolygonStipple\" );\n\tqglPopAttrib                 = \tdllPopAttrib                 = GPA( \"glPopAttrib\" );\n\tqglPopClientAttrib           = \tdllPopClientAttrib           = GPA( \"glPopClientAttrib\" );\n\tqglPopMatrix                 = \tdllPopMatrix                 = GPA( \"glPopMatrix\" );\n\tqglPopName                   = \tdllPopName                   = GPA( \"glPopName\" );\n\tqglPrioritizeTextures        = \tdllPrioritizeTextures        = GPA( \"glPrioritizeTextures\" );\n\tqglPushAttrib                = \tdllPushAttrib                = GPA( \"glPushAttrib\" );\n\tqglPushClientAttrib          = \tdllPushClientAttrib          = GPA( \"glPushClientAttrib\" );\n\tqglPushMatrix                = \tdllPushMatrix                = GPA( \"glPushMatrix\" );\n\tqglPushName                  = \tdllPushName                  = GPA( \"glPushName\" );\n\tqglRasterPos2d               = \tdllRasterPos2d               = GPA( \"glRasterPos2d\" );\n\tqglRasterPos2dv              = \tdllRasterPos2dv              = GPA( \"glRasterPos2dv\" );\n\tqglRasterPos2f               = \tdllRasterPos2f               = GPA( \"glRasterPos2f\" );\n\tqglRasterPos2fv              = \tdllRasterPos2fv              = GPA( \"glRasterPos2fv\" );\n\tqglRasterPos2i               = \tdllRasterPos2i               = GPA( \"glRasterPos2i\" );\n\tqglRasterPos2iv              = \tdllRasterPos2iv              = GPA( \"glRasterPos2iv\" );\n\tqglRasterPos2s               = \tdllRasterPos2s               = GPA( \"glRasterPos2s\" );\n\tqglRasterPos2sv              = \tdllRasterPos2sv              = GPA( \"glRasterPos2sv\" );\n\tqglRasterPos3d               = \tdllRasterPos3d               = GPA( \"glRasterPos3d\" );\n\tqglRasterPos3dv              = \tdllRasterPos3dv              = GPA( \"glRasterPos3dv\" );\n\tqglRasterPos3f               = \tdllRasterPos3f               = GPA( \"glRasterPos3f\" );\n\tqglRasterPos3fv              = \tdllRasterPos3fv              = GPA( \"glRasterPos3fv\" );\n\tqglRasterPos3i               = \tdllRasterPos3i               = GPA( \"glRasterPos3i\" );\n\tqglRasterPos3iv              = \tdllRasterPos3iv              = GPA( \"glRasterPos3iv\" );\n\tqglRasterPos3s               = \tdllRasterPos3s               = GPA( \"glRasterPos3s\" );\n\tqglRasterPos3sv              = \tdllRasterPos3sv              = GPA( \"glRasterPos3sv\" );\n\tqglRasterPos4d               = \tdllRasterPos4d               = GPA( \"glRasterPos4d\" );\n\tqglRasterPos4dv              = \tdllRasterPos4dv              = GPA( \"glRasterPos4dv\" );\n\tqglRasterPos4f               = \tdllRasterPos4f               = GPA( \"glRasterPos4f\" );\n\tqglRasterPos4fv              = \tdllRasterPos4fv              = GPA( \"glRasterPos4fv\" );\n\tqglRasterPos4i               = \tdllRasterPos4i               = GPA( \"glRasterPos4i\" );\n\tqglRasterPos4iv              = \tdllRasterPos4iv              = GPA( \"glRasterPos4iv\" );\n\tqglRasterPos4s               = \tdllRasterPos4s               = GPA( \"glRasterPos4s\" );\n\tqglRasterPos4sv              = \tdllRasterPos4sv              = GPA( \"glRasterPos4sv\" );\n\tqglReadBuffer                = \tdllReadBuffer                = GPA( \"glReadBuffer\" );\n\tqglReadPixels                = \tdllReadPixels                = GPA( \"glReadPixels\" );\n\tqglRectd                     = \tdllRectd                     = GPA( \"glRectd\" );\n\tqglRectdv                    = \tdllRectdv                    = GPA( \"glRectdv\" );\n\tqglRectf                     = \tdllRectf                     = GPA( \"glRectf\" );\n\tqglRectfv                    = \tdllRectfv                    = GPA( \"glRectfv\" );\n\tqglRecti                     = \tdllRecti                     = GPA( \"glRecti\" );\n\tqglRectiv                    = \tdllRectiv                    = GPA( \"glRectiv\" );\n\tqglRects                     = \tdllRects                     = GPA( \"glRects\" );\n\tqglRectsv                    = \tdllRectsv                    = GPA( \"glRectsv\" );\n\tqglRenderMode                = \tdllRenderMode                = GPA( \"glRenderMode\" );\n\tqglRotated                   = \tdllRotated                   = GPA( \"glRotated\" );\n\tqglRotatef                   = \tdllRotatef                   = GPA( \"glRotatef\" );\n\tqglScaled                    = \tdllScaled                    = GPA( \"glScaled\" );\n\tqglScalef                    = \tdllScalef                    = GPA( \"glScalef\" );\n\tqglScissor                   = \tdllScissor                   = GPA( \"glScissor\" );\n\tqglSelectBuffer              = \tdllSelectBuffer              = GPA( \"glSelectBuffer\" );\n\tqglShadeModel                = \tdllShadeModel                = GPA( \"glShadeModel\" );\n\tqglStencilFunc               = \tdllStencilFunc               = GPA( \"glStencilFunc\" );\n\tqglStencilMask               = \tdllStencilMask               = GPA( \"glStencilMask\" );\n\tqglStencilOp                 = \tdllStencilOp                 = GPA( \"glStencilOp\" );\n\tqglTexCoord1d                = \tdllTexCoord1d                = GPA( \"glTexCoord1d\" );\n\tqglTexCoord1dv               = \tdllTexCoord1dv               = GPA( \"glTexCoord1dv\" );\n\tqglTexCoord1f                = \tdllTexCoord1f                = GPA( \"glTexCoord1f\" );\n\tqglTexCoord1fv               = \tdllTexCoord1fv               = GPA( \"glTexCoord1fv\" );\n\tqglTexCoord1i                = \tdllTexCoord1i                = GPA( \"glTexCoord1i\" );\n\tqglTexCoord1iv               = \tdllTexCoord1iv               = GPA( \"glTexCoord1iv\" );\n\tqglTexCoord1s                = \tdllTexCoord1s                = GPA( \"glTexCoord1s\" );\n\tqglTexCoord1sv               = \tdllTexCoord1sv               = GPA( \"glTexCoord1sv\" );\n\tqglTexCoord2d                = \tdllTexCoord2d                = GPA( \"glTexCoord2d\" );\n\tqglTexCoord2dv               = \tdllTexCoord2dv               = GPA( \"glTexCoord2dv\" );\n\tqglTexCoord2f                = \tdllTexCoord2f                = GPA( \"glTexCoord2f\" );\n\tqglTexCoord2fv               = \tdllTexCoord2fv               = GPA( \"glTexCoord2fv\" );\n\tqglTexCoord2i                = \tdllTexCoord2i                = GPA( \"glTexCoord2i\" );\n\tqglTexCoord2iv               = \tdllTexCoord2iv               = GPA( \"glTexCoord2iv\" );\n\tqglTexCoord2s                = \tdllTexCoord2s                = GPA( \"glTexCoord2s\" );\n\tqglTexCoord2sv               = \tdllTexCoord2sv               = GPA( \"glTexCoord2sv\" );\n\tqglTexCoord3d                = \tdllTexCoord3d                = GPA( \"glTexCoord3d\" );\n\tqglTexCoord3dv               = \tdllTexCoord3dv               = GPA( \"glTexCoord3dv\" );\n\tqglTexCoord3f                = \tdllTexCoord3f                = GPA( \"glTexCoord3f\" );\n\tqglTexCoord3fv               = \tdllTexCoord3fv               = GPA( \"glTexCoord3fv\" );\n\tqglTexCoord3i                = \tdllTexCoord3i                = GPA( \"glTexCoord3i\" );\n\tqglTexCoord3iv               = \tdllTexCoord3iv               = GPA( \"glTexCoord3iv\" );\n\tqglTexCoord3s                = \tdllTexCoord3s                = GPA( \"glTexCoord3s\" );\n\tqglTexCoord3sv               = \tdllTexCoord3sv               = GPA( \"glTexCoord3sv\" );\n\tqglTexCoord4d                = \tdllTexCoord4d                = GPA( \"glTexCoord4d\" );\n\tqglTexCoord4dv               = \tdllTexCoord4dv               = GPA( \"glTexCoord4dv\" );\n\tqglTexCoord4f                = \tdllTexCoord4f                = GPA( \"glTexCoord4f\" );\n\tqglTexCoord4fv               = \tdllTexCoord4fv               = GPA( \"glTexCoord4fv\" );\n\tqglTexCoord4i                = \tdllTexCoord4i                = GPA( \"glTexCoord4i\" );\n\tqglTexCoord4iv               = \tdllTexCoord4iv               = GPA( \"glTexCoord4iv\" );\n\tqglTexCoord4s                = \tdllTexCoord4s                = GPA( \"glTexCoord4s\" );\n\tqglTexCoord4sv               = \tdllTexCoord4sv               = GPA( \"glTexCoord4sv\" );\n\tqglTexCoordPointer           = \tdllTexCoordPointer           = GPA( \"glTexCoordPointer\" );\n\tqglTexEnvf                   = \tdllTexEnvf                   = GPA( \"glTexEnvf\" );\n\tqglTexEnvfv                  = \tdllTexEnvfv                  = GPA( \"glTexEnvfv\" );\n\tqglTexEnvi                   = \tdllTexEnvi                   = GPA( \"glTexEnvi\" );\n\tqglTexEnviv                  = \tdllTexEnviv                  = GPA( \"glTexEnviv\" );\n\tqglTexGend                   = \tdllTexGend                   = GPA( \"glTexGend\" );\n\tqglTexGendv                  = \tdllTexGendv                  = GPA( \"glTexGendv\" );\n\tqglTexGenf                   = \tdllTexGenf                   = GPA( \"glTexGenf\" );\n\tqglTexGenfv                  = \tdllTexGenfv                  = GPA( \"glTexGenfv\" );\n\tqglTexGeni                   = \tdllTexGeni                   = GPA( \"glTexGeni\" );\n\tqglTexGeniv                  = \tdllTexGeniv                  = GPA( \"glTexGeniv\" );\n\tqglTexImage1D                = \tdllTexImage1D                = GPA( \"glTexImage1D\" );\n\tqglTexImage2D                = \tdllTexImage2D                = GPA( \"glTexImage2D\" );\n\tqglTexParameterf             = \tdllTexParameterf             = GPA( \"glTexParameterf\" );\n\tqglTexParameterfv            = \tdllTexParameterfv            = GPA( \"glTexParameterfv\" );\n\tqglTexParameteri             = \tdllTexParameteri             = GPA( \"glTexParameteri\" );\n\tqglTexParameteriv            = \tdllTexParameteriv            = GPA( \"glTexParameteriv\" );\n\tqglTexSubImage1D             = \tdllTexSubImage1D             = GPA( \"glTexSubImage1D\" );\n\tqglTexSubImage2D             = \tdllTexSubImage2D             = GPA( \"glTexSubImage2D\" );\n\tqglTranslated                = \tdllTranslated                = GPA( \"glTranslated\" );\n\tqglTranslatef                = \tdllTranslatef                = GPA( \"glTranslatef\" );\n\tqglVertex2d                  = \tdllVertex2d                  = GPA( \"glVertex2d\" );\n\tqglVertex2dv                 = \tdllVertex2dv                 = GPA( \"glVertex2dv\" );\n\tqglVertex2f                  = \tdllVertex2f                  = GPA( \"glVertex2f\" );\n\tqglVertex2fv                 = \tdllVertex2fv                 = GPA( \"glVertex2fv\" );\n\tqglVertex2i                  = \tdllVertex2i                  = GPA( \"glVertex2i\" );\n\tqglVertex2iv                 = \tdllVertex2iv                 = GPA( \"glVertex2iv\" );\n\tqglVertex2s                  = \tdllVertex2s                  = GPA( \"glVertex2s\" );\n\tqglVertex2sv                 = \tdllVertex2sv                 = GPA( \"glVertex2sv\" );\n\tqglVertex3d                  = \tdllVertex3d                  = GPA( \"glVertex3d\" );\n\tqglVertex3dv                 = \tdllVertex3dv                 = GPA( \"glVertex3dv\" );\n\tqglVertex3f                  = \tdllVertex3f                  = GPA( \"glVertex3f\" );\n\tqglVertex3fv                 = \tdllVertex3fv                 = GPA( \"glVertex3fv\" );\n\tqglVertex3i                  = \tdllVertex3i                  = GPA( \"glVertex3i\" );\n\tqglVertex3iv                 = \tdllVertex3iv                 = GPA( \"glVertex3iv\" );\n\tqglVertex3s                  = \tdllVertex3s                  = GPA( \"glVertex3s\" );\n\tqglVertex3sv                 = \tdllVertex3sv                 = GPA( \"glVertex3sv\" );\n\tqglVertex4d                  = \tdllVertex4d                  = GPA( \"glVertex4d\" );\n\tqglVertex4dv                 = \tdllVertex4dv                 = GPA( \"glVertex4dv\" );\n\tqglVertex4f                  = \tdllVertex4f                  = GPA( \"glVertex4f\" );\n\tqglVertex4fv                 = \tdllVertex4fv                 = GPA( \"glVertex4fv\" );\n\tqglVertex4i                  = \tdllVertex4i                  = GPA( \"glVertex4i\" );\n\tqglVertex4iv                 = \tdllVertex4iv                 = GPA( \"glVertex4iv\" );\n\tqglVertex4s                  = \tdllVertex4s                  = GPA( \"glVertex4s\" );\n\tqglVertex4sv                 = \tdllVertex4sv                 = GPA( \"glVertex4sv\" );\n\tqglVertexPointer             = \tdllVertexPointer             = GPA( \"glVertexPointer\" );\n\tqglViewport                  = \tdllViewport                  = GPA( \"glViewport\" );\n\n\tqwglCopyContext              = GPA( \"wglCopyContext\" );\n\tqwglCreateContext            = GPA( \"wglCreateContext\" );\n\tqwglCreateLayerContext       = GPA( \"wglCreateLayerContext\" );\n\tqwglDeleteContext            = GPA( \"wglDeleteContext\" );\n\tqwglDescribeLayerPlane       = GPA( \"wglDescribeLayerPlane\" );\n\tqwglGetCurrentContext        = GPA( \"wglGetCurrentContext\" );\n\tqwglGetCurrentDC             = GPA( \"wglGetCurrentDC\" );\n\tqwglGetLayerPaletteEntries   = GPA( \"wglGetLayerPaletteEntries\" );\n\tqwglGetProcAddress           = GPA( \"wglGetProcAddress\" );\n\tqwglMakeCurrent              = GPA( \"wglMakeCurrent\" );\n\tqwglRealizeLayerPalette      = GPA( \"wglRealizeLayerPalette\" );\n\tqwglSetLayerPaletteEntries   = GPA( \"wglSetLayerPaletteEntries\" );\n\tqwglShareLists               = GPA( \"wglShareLists\" );\n\tqwglSwapLayerBuffers         = GPA( \"wglSwapLayerBuffers\" );\n\tqwglUseFontBitmaps           = GPA( \"wglUseFontBitmapsA\" );\n\tqwglUseFontOutlines          = GPA( \"wglUseFontOutlinesA\" );\n\n\tqwglChoosePixelFormat        = GPA( \"wglChoosePixelFormat\" );\n\tqwglDescribePixelFormat      = GPA( \"wglDescribePixelFormat\" );\n\tqwglGetPixelFormat           = GPA( \"wglGetPixelFormat\" );\n\tqwglSetPixelFormat           = GPA( \"wglSetPixelFormat\" );\n\tqwglSwapBuffers              = GPA( \"wglSwapBuffers\" );\n\n\tqwglSwapIntervalEXT = 0;\n\tqglActiveTextureARB = 0;\n\tqglClientActiveTextureARB = 0;\n\tqglMultiTexCoord2fARB = 0;\n\tqglLockArraysEXT = 0;\n\tqglUnlockArraysEXT = 0;\n\tqwglGetDeviceGammaRamp3DFX = NULL;\n\tqwglSetDeviceGammaRamp3DFX = NULL;\n\n\t// check logging\n\tQGL_EnableLogging( r_logFile->integer );\n\n\treturn qtrue;\n}\n\nvoid QGL_EnableLogging( qboolean enable )\n{\n\tstatic qboolean isEnabled;\n\n\t// return if we're already active\n\tif ( isEnabled && enable ) {\n\t\t// decrement log counter and stop if it has reached 0\n\t\tri.Cvar_Set( \"r_logFile\", va(\"%d\", r_logFile->integer - 1 ) );\n\t\tif ( r_logFile->integer ) {\n\t\t\treturn;\n\t\t}\n\t\tenable = qfalse;\n\t}\n\n\t// return if we're already disabled\n\tif ( !enable && !isEnabled )\n\t\treturn;\n\n\tisEnabled = enable;\n\n\tif ( enable )\n\t{\n\t\tif ( !glw_state.log_fp )\n\t\t{\n\t\t\tstruct tm *newtime;\n\t\t\ttime_t aclock;\n\t\t\tchar buffer[1024];\n\t\t\tcvar_t\t*basedir;\n\n\t\t\ttime( &aclock );\n\t\t\tnewtime = localtime( &aclock );\n\n\t\t\tasctime( newtime );\n\n\t\t\tbasedir = ri.Cvar_Get( \"fs_basepath\", \"\", 0 );\n\t\t\tCom_sprintf( buffer, sizeof(buffer), \"%s/gl.log\", basedir->string ); \n\t\t\tglw_state.log_fp = fopen( buffer, \"wt\" );\n\n\t\t\tfprintf( glw_state.log_fp, \"%s\\n\", asctime( newtime ) );\n\t\t}\n\n\t\tqglAccum                     = logAccum;\n\t\tqglAlphaFunc                 = logAlphaFunc;\n\t\tqglAreTexturesResident       = logAreTexturesResident;\n\t\tqglArrayElement              = logArrayElement;\n\t\tqglBegin                     = logBegin;\n\t\tqglBindTexture               = logBindTexture;\n\t\tqglBitmap                    = logBitmap;\n\t\tqglBlendFunc                 = logBlendFunc;\n\t\tqglCallList                  = logCallList;\n\t\tqglCallLists                 = logCallLists;\n\t\tqglClear                     = logClear;\n\t\tqglClearAccum                = logClearAccum;\n\t\tqglClearColor                = logClearColor;\n\t\tqglClearDepth                = logClearDepth;\n\t\tqglClearIndex                = logClearIndex;\n\t\tqglClearStencil              = logClearStencil;\n\t\tqglClipPlane                 = logClipPlane;\n\t\tqglColor3b                   = logColor3b;\n\t\tqglColor3bv                  = logColor3bv;\n\t\tqglColor3d                   = logColor3d;\n\t\tqglColor3dv                  = logColor3dv;\n\t\tqglColor3f                   = logColor3f;\n\t\tqglColor3fv                  = logColor3fv;\n\t\tqglColor3i                   = logColor3i;\n\t\tqglColor3iv                  = logColor3iv;\n\t\tqglColor3s                   = logColor3s;\n\t\tqglColor3sv                  = logColor3sv;\n\t\tqglColor3ub                  = logColor3ub;\n\t\tqglColor3ubv                 = logColor3ubv;\n\t\tqglColor3ui                  = logColor3ui;\n\t\tqglColor3uiv                 = logColor3uiv;\n\t\tqglColor3us                  = logColor3us;\n\t\tqglColor3usv                 = logColor3usv;\n\t\tqglColor4b                   = logColor4b;\n\t\tqglColor4bv                  = logColor4bv;\n\t\tqglColor4d                   = logColor4d;\n\t\tqglColor4dv                  = logColor4dv;\n\t\tqglColor4f                   = logColor4f;\n\t\tqglColor4fv                  = logColor4fv;\n\t\tqglColor4i                   = logColor4i;\n\t\tqglColor4iv                  = logColor4iv;\n\t\tqglColor4s                   = logColor4s;\n\t\tqglColor4sv                  = logColor4sv;\n\t\tqglColor4ub                  = logColor4ub;\n\t\tqglColor4ubv                 = logColor4ubv;\n\t\tqglColor4ui                  = logColor4ui;\n\t\tqglColor4uiv                 = logColor4uiv;\n\t\tqglColor4us                  = logColor4us;\n\t\tqglColor4usv                 = logColor4usv;\n\t\tqglColorMask                 = logColorMask;\n\t\tqglColorMaterial             = logColorMaterial;\n\t\tqglColorPointer              = logColorPointer;\n\t\tqglCopyPixels                = logCopyPixels;\n\t\tqglCopyTexImage1D            = logCopyTexImage1D;\n\t\tqglCopyTexImage2D            = logCopyTexImage2D;\n\t\tqglCopyTexSubImage1D         = logCopyTexSubImage1D;\n\t\tqglCopyTexSubImage2D         = logCopyTexSubImage2D;\n\t\tqglCullFace                  = logCullFace;\n\t\tqglDeleteLists               = logDeleteLists ;\n\t\tqglDeleteTextures            = logDeleteTextures ;\n\t\tqglDepthFunc                 = logDepthFunc ;\n\t\tqglDepthMask                 = logDepthMask ;\n\t\tqglDepthRange                = logDepthRange ;\n\t\tqglDisable                   = logDisable ;\n\t\tqglDisableClientState        = logDisableClientState ;\n\t\tqglDrawArrays                = logDrawArrays ;\n\t\tqglDrawBuffer                = logDrawBuffer ;\n\t\tqglDrawElements              = logDrawElements ;\n\t\tqglDrawPixels                = logDrawPixels ;\n\t\tqglEdgeFlag                  = logEdgeFlag ;\n\t\tqglEdgeFlagPointer           = logEdgeFlagPointer ;\n\t\tqglEdgeFlagv                 = logEdgeFlagv ;\n\t\tqglEnable                    = \tlogEnable                    ;\n\t\tqglEnableClientState         = \tlogEnableClientState         ;\n\t\tqglEnd                       = \tlogEnd                       ;\n\t\tqglEndList                   = \tlogEndList                   ;\n\t\tqglEvalCoord1d\t\t\t\t = \tlogEvalCoord1d\t\t\t\t ;\n\t\tqglEvalCoord1dv              = \tlogEvalCoord1dv              ;\n\t\tqglEvalCoord1f               = \tlogEvalCoord1f               ;\n\t\tqglEvalCoord1fv              = \tlogEvalCoord1fv              ;\n\t\tqglEvalCoord2d               = \tlogEvalCoord2d               ;\n\t\tqglEvalCoord2dv              = \tlogEvalCoord2dv              ;\n\t\tqglEvalCoord2f               = \tlogEvalCoord2f               ;\n\t\tqglEvalCoord2fv              = \tlogEvalCoord2fv              ;\n\t\tqglEvalMesh1                 = \tlogEvalMesh1                 ;\n\t\tqglEvalMesh2                 = \tlogEvalMesh2                 ;\n\t\tqglEvalPoint1                = \tlogEvalPoint1                ;\n\t\tqglEvalPoint2                = \tlogEvalPoint2                ;\n\t\tqglFeedbackBuffer            = \tlogFeedbackBuffer            ;\n\t\tqglFinish                    = \tlogFinish                    ;\n\t\tqglFlush                     = \tlogFlush                     ;\n\t\tqglFogf                      = \tlogFogf                      ;\n\t\tqglFogfv                     = \tlogFogfv                     ;\n\t\tqglFogi                      = \tlogFogi                      ;\n\t\tqglFogiv                     = \tlogFogiv                     ;\n\t\tqglFrontFace                 = \tlogFrontFace                 ;\n\t\tqglFrustum                   = \tlogFrustum                   ;\n\t\tqglGenLists                  = \tlogGenLists                  ;\n\t\tqglGenTextures               = \tlogGenTextures               ;\n\t\tqglGetBooleanv               = \tlogGetBooleanv               ;\n\t\tqglGetClipPlane              = \tlogGetClipPlane              ;\n\t\tqglGetDoublev                = \tlogGetDoublev                ;\n\t\tqglGetError                  = \tlogGetError                  ;\n\t\tqglGetFloatv                 = \tlogGetFloatv                 ;\n\t\tqglGetIntegerv               = \tlogGetIntegerv               ;\n\t\tqglGetLightfv                = \tlogGetLightfv                ;\n\t\tqglGetLightiv                = \tlogGetLightiv                ;\n\t\tqglGetMapdv                  = \tlogGetMapdv                  ;\n\t\tqglGetMapfv                  = \tlogGetMapfv                  ;\n\t\tqglGetMapiv                  = \tlogGetMapiv                  ;\n\t\tqglGetMaterialfv             = \tlogGetMaterialfv             ;\n\t\tqglGetMaterialiv             = \tlogGetMaterialiv             ;\n\t\tqglGetPixelMapfv             = \tlogGetPixelMapfv             ;\n\t\tqglGetPixelMapuiv            = \tlogGetPixelMapuiv            ;\n\t\tqglGetPixelMapusv            = \tlogGetPixelMapusv            ;\n\t\tqglGetPointerv               = \tlogGetPointerv               ;\n\t\tqglGetPolygonStipple         = \tlogGetPolygonStipple         ;\n\t\tqglGetString                 = \tlogGetString                 ;\n\t\tqglGetTexEnvfv               = \tlogGetTexEnvfv               ;\n\t\tqglGetTexEnviv               = \tlogGetTexEnviv               ;\n\t\tqglGetTexGendv               = \tlogGetTexGendv               ;\n\t\tqglGetTexGenfv               = \tlogGetTexGenfv               ;\n\t\tqglGetTexGeniv               = \tlogGetTexGeniv               ;\n\t\tqglGetTexImage               = \tlogGetTexImage               ;\n\t\tqglGetTexLevelParameterfv    = \tlogGetTexLevelParameterfv    ;\n\t\tqglGetTexLevelParameteriv    = \tlogGetTexLevelParameteriv    ;\n\t\tqglGetTexParameterfv         = \tlogGetTexParameterfv         ;\n\t\tqglGetTexParameteriv         = \tlogGetTexParameteriv         ;\n\t\tqglHint                      = \tlogHint                      ;\n\t\tqglIndexMask                 = \tlogIndexMask                 ;\n\t\tqglIndexPointer              = \tlogIndexPointer              ;\n\t\tqglIndexd                    = \tlogIndexd                    ;\n\t\tqglIndexdv                   = \tlogIndexdv                   ;\n\t\tqglIndexf                    = \tlogIndexf                    ;\n\t\tqglIndexfv                   = \tlogIndexfv                   ;\n\t\tqglIndexi                    = \tlogIndexi                    ;\n\t\tqglIndexiv                   = \tlogIndexiv                   ;\n\t\tqglIndexs                    = \tlogIndexs                    ;\n\t\tqglIndexsv                   = \tlogIndexsv                   ;\n\t\tqglIndexub                   = \tlogIndexub                   ;\n\t\tqglIndexubv                  = \tlogIndexubv                  ;\n\t\tqglInitNames                 = \tlogInitNames                 ;\n\t\tqglInterleavedArrays         = \tlogInterleavedArrays         ;\n\t\tqglIsEnabled                 = \tlogIsEnabled                 ;\n\t\tqglIsList                    = \tlogIsList                    ;\n\t\tqglIsTexture                 = \tlogIsTexture                 ;\n\t\tqglLightModelf               = \tlogLightModelf               ;\n\t\tqglLightModelfv              = \tlogLightModelfv              ;\n\t\tqglLightModeli               = \tlogLightModeli               ;\n\t\tqglLightModeliv              = \tlogLightModeliv              ;\n\t\tqglLightf                    = \tlogLightf                    ;\n\t\tqglLightfv                   = \tlogLightfv                   ;\n\t\tqglLighti                    = \tlogLighti                    ;\n\t\tqglLightiv                   = \tlogLightiv                   ;\n\t\tqglLineStipple               = \tlogLineStipple               ;\n\t\tqglLineWidth                 = \tlogLineWidth                 ;\n\t\tqglListBase                  = \tlogListBase                  ;\n\t\tqglLoadIdentity              = \tlogLoadIdentity              ;\n\t\tqglLoadMatrixd               = \tlogLoadMatrixd               ;\n\t\tqglLoadMatrixf               = \tlogLoadMatrixf               ;\n\t\tqglLoadName                  = \tlogLoadName                  ;\n\t\tqglLogicOp                   = \tlogLogicOp                   ;\n\t\tqglMap1d                     = \tlogMap1d                     ;\n\t\tqglMap1f                     = \tlogMap1f                     ;\n\t\tqglMap2d                     = \tlogMap2d                     ;\n\t\tqglMap2f                     = \tlogMap2f                     ;\n\t\tqglMapGrid1d                 = \tlogMapGrid1d                 ;\n\t\tqglMapGrid1f                 = \tlogMapGrid1f                 ;\n\t\tqglMapGrid2d                 = \tlogMapGrid2d                 ;\n\t\tqglMapGrid2f                 = \tlogMapGrid2f                 ;\n\t\tqglMaterialf                 = \tlogMaterialf                 ;\n\t\tqglMaterialfv                = \tlogMaterialfv                ;\n\t\tqglMateriali                 = \tlogMateriali                 ;\n\t\tqglMaterialiv                = \tlogMaterialiv                ;\n\t\tqglMatrixMode                = \tlogMatrixMode                ;\n\t\tqglMultMatrixd               = \tlogMultMatrixd               ;\n\t\tqglMultMatrixf               = \tlogMultMatrixf               ;\n\t\tqglNewList                   = \tlogNewList                   ;\n\t\tqglNormal3b                  = \tlogNormal3b                  ;\n\t\tqglNormal3bv                 = \tlogNormal3bv                 ;\n\t\tqglNormal3d                  = \tlogNormal3d                  ;\n\t\tqglNormal3dv                 = \tlogNormal3dv                 ;\n\t\tqglNormal3f                  = \tlogNormal3f                  ;\n\t\tqglNormal3fv                 = \tlogNormal3fv                 ;\n\t\tqglNormal3i                  = \tlogNormal3i                  ;\n\t\tqglNormal3iv                 = \tlogNormal3iv                 ;\n\t\tqglNormal3s                  = \tlogNormal3s                  ;\n\t\tqglNormal3sv                 = \tlogNormal3sv                 ;\n\t\tqglNormalPointer             = \tlogNormalPointer             ;\n\t\tqglOrtho                     = \tlogOrtho                     ;\n\t\tqglPassThrough               = \tlogPassThrough               ;\n\t\tqglPixelMapfv                = \tlogPixelMapfv                ;\n\t\tqglPixelMapuiv               = \tlogPixelMapuiv               ;\n\t\tqglPixelMapusv               = \tlogPixelMapusv               ;\n\t\tqglPixelStoref               = \tlogPixelStoref               ;\n\t\tqglPixelStorei               = \tlogPixelStorei               ;\n\t\tqglPixelTransferf            = \tlogPixelTransferf            ;\n\t\tqglPixelTransferi            = \tlogPixelTransferi            ;\n\t\tqglPixelZoom                 = \tlogPixelZoom                 ;\n\t\tqglPointSize                 = \tlogPointSize                 ;\n\t\tqglPolygonMode               = \tlogPolygonMode               ;\n\t\tqglPolygonOffset             = \tlogPolygonOffset             ;\n\t\tqglPolygonStipple            = \tlogPolygonStipple            ;\n\t\tqglPopAttrib                 = \tlogPopAttrib                 ;\n\t\tqglPopClientAttrib           = \tlogPopClientAttrib           ;\n\t\tqglPopMatrix                 = \tlogPopMatrix                 ;\n\t\tqglPopName                   = \tlogPopName                   ;\n\t\tqglPrioritizeTextures        = \tlogPrioritizeTextures        ;\n\t\tqglPushAttrib                = \tlogPushAttrib                ;\n\t\tqglPushClientAttrib          = \tlogPushClientAttrib          ;\n\t\tqglPushMatrix                = \tlogPushMatrix                ;\n\t\tqglPushName                  = \tlogPushName                  ;\n\t\tqglRasterPos2d               = \tlogRasterPos2d               ;\n\t\tqglRasterPos2dv              = \tlogRasterPos2dv              ;\n\t\tqglRasterPos2f               = \tlogRasterPos2f               ;\n\t\tqglRasterPos2fv              = \tlogRasterPos2fv              ;\n\t\tqglRasterPos2i               = \tlogRasterPos2i               ;\n\t\tqglRasterPos2iv              = \tlogRasterPos2iv              ;\n\t\tqglRasterPos2s               = \tlogRasterPos2s               ;\n\t\tqglRasterPos2sv              = \tlogRasterPos2sv              ;\n\t\tqglRasterPos3d               = \tlogRasterPos3d               ;\n\t\tqglRasterPos3dv              = \tlogRasterPos3dv              ;\n\t\tqglRasterPos3f               = \tlogRasterPos3f               ;\n\t\tqglRasterPos3fv              = \tlogRasterPos3fv              ;\n\t\tqglRasterPos3i               = \tlogRasterPos3i               ;\n\t\tqglRasterPos3iv              = \tlogRasterPos3iv              ;\n\t\tqglRasterPos3s               = \tlogRasterPos3s               ;\n\t\tqglRasterPos3sv              = \tlogRasterPos3sv              ;\n\t\tqglRasterPos4d               = \tlogRasterPos4d               ;\n\t\tqglRasterPos4dv              = \tlogRasterPos4dv              ;\n\t\tqglRasterPos4f               = \tlogRasterPos4f               ;\n\t\tqglRasterPos4fv              = \tlogRasterPos4fv              ;\n\t\tqglRasterPos4i               = \tlogRasterPos4i               ;\n\t\tqglRasterPos4iv              = \tlogRasterPos4iv              ;\n\t\tqglRasterPos4s               = \tlogRasterPos4s               ;\n\t\tqglRasterPos4sv              = \tlogRasterPos4sv              ;\n\t\tqglReadBuffer                = \tlogReadBuffer                ;\n\t\tqglReadPixels                = \tlogReadPixels                ;\n\t\tqglRectd                     = \tlogRectd                     ;\n\t\tqglRectdv                    = \tlogRectdv                    ;\n\t\tqglRectf                     = \tlogRectf                     ;\n\t\tqglRectfv                    = \tlogRectfv                    ;\n\t\tqglRecti                     = \tlogRecti                     ;\n\t\tqglRectiv                    = \tlogRectiv                    ;\n\t\tqglRects                     = \tlogRects                     ;\n\t\tqglRectsv                    = \tlogRectsv                    ;\n\t\tqglRenderMode                = \tlogRenderMode                ;\n\t\tqglRotated                   = \tlogRotated                   ;\n\t\tqglRotatef                   = \tlogRotatef                   ;\n\t\tqglScaled                    = \tlogScaled                    ;\n\t\tqglScalef                    = \tlogScalef                    ;\n\t\tqglScissor                   = \tlogScissor                   ;\n\t\tqglSelectBuffer              = \tlogSelectBuffer              ;\n\t\tqglShadeModel                = \tlogShadeModel                ;\n\t\tqglStencilFunc               = \tlogStencilFunc               ;\n\t\tqglStencilMask               = \tlogStencilMask               ;\n\t\tqglStencilOp                 = \tlogStencilOp                 ;\n\t\tqglTexCoord1d                = \tlogTexCoord1d                ;\n\t\tqglTexCoord1dv               = \tlogTexCoord1dv               ;\n\t\tqglTexCoord1f                = \tlogTexCoord1f                ;\n\t\tqglTexCoord1fv               = \tlogTexCoord1fv               ;\n\t\tqglTexCoord1i                = \tlogTexCoord1i                ;\n\t\tqglTexCoord1iv               = \tlogTexCoord1iv               ;\n\t\tqglTexCoord1s                = \tlogTexCoord1s                ;\n\t\tqglTexCoord1sv               = \tlogTexCoord1sv               ;\n\t\tqglTexCoord2d                = \tlogTexCoord2d                ;\n\t\tqglTexCoord2dv               = \tlogTexCoord2dv               ;\n\t\tqglTexCoord2f                = \tlogTexCoord2f                ;\n\t\tqglTexCoord2fv               = \tlogTexCoord2fv               ;\n\t\tqglTexCoord2i                = \tlogTexCoord2i                ;\n\t\tqglTexCoord2iv               = \tlogTexCoord2iv               ;\n\t\tqglTexCoord2s                = \tlogTexCoord2s                ;\n\t\tqglTexCoord2sv               = \tlogTexCoord2sv               ;\n\t\tqglTexCoord3d                = \tlogTexCoord3d                ;\n\t\tqglTexCoord3dv               = \tlogTexCoord3dv               ;\n\t\tqglTexCoord3f                = \tlogTexCoord3f                ;\n\t\tqglTexCoord3fv               = \tlogTexCoord3fv               ;\n\t\tqglTexCoord3i                = \tlogTexCoord3i                ;\n\t\tqglTexCoord3iv               = \tlogTexCoord3iv               ;\n\t\tqglTexCoord3s                = \tlogTexCoord3s                ;\n\t\tqglTexCoord3sv               = \tlogTexCoord3sv               ;\n\t\tqglTexCoord4d                = \tlogTexCoord4d                ;\n\t\tqglTexCoord4dv               = \tlogTexCoord4dv               ;\n\t\tqglTexCoord4f                = \tlogTexCoord4f                ;\n\t\tqglTexCoord4fv               = \tlogTexCoord4fv               ;\n\t\tqglTexCoord4i                = \tlogTexCoord4i                ;\n\t\tqglTexCoord4iv               = \tlogTexCoord4iv               ;\n\t\tqglTexCoord4s                = \tlogTexCoord4s                ;\n\t\tqglTexCoord4sv               = \tlogTexCoord4sv               ;\n\t\tqglTexCoordPointer           = \tlogTexCoordPointer           ;\n\t\tqglTexEnvf                   = \tlogTexEnvf                   ;\n\t\tqglTexEnvfv                  = \tlogTexEnvfv                  ;\n\t\tqglTexEnvi                   = \tlogTexEnvi                   ;\n\t\tqglTexEnviv                  = \tlogTexEnviv                  ;\n\t\tqglTexGend                   = \tlogTexGend                   ;\n\t\tqglTexGendv                  = \tlogTexGendv                  ;\n\t\tqglTexGenf                   = \tlogTexGenf                   ;\n\t\tqglTexGenfv                  = \tlogTexGenfv                  ;\n\t\tqglTexGeni                   = \tlogTexGeni                   ;\n\t\tqglTexGeniv                  = \tlogTexGeniv                  ;\n\t\tqglTexImage1D                = \tlogTexImage1D                ;\n\t\tqglTexImage2D                = \tlogTexImage2D                ;\n\t\tqglTexParameterf             = \tlogTexParameterf             ;\n\t\tqglTexParameterfv            = \tlogTexParameterfv            ;\n\t\tqglTexParameteri             = \tlogTexParameteri             ;\n\t\tqglTexParameteriv            = \tlogTexParameteriv            ;\n\t\tqglTexSubImage1D             = \tlogTexSubImage1D             ;\n\t\tqglTexSubImage2D             = \tlogTexSubImage2D             ;\n\t\tqglTranslated                = \tlogTranslated                ;\n\t\tqglTranslatef                = \tlogTranslatef                ;\n\t\tqglVertex2d                  = \tlogVertex2d                  ;\n\t\tqglVertex2dv                 = \tlogVertex2dv                 ;\n\t\tqglVertex2f                  = \tlogVertex2f                  ;\n\t\tqglVertex2fv                 = \tlogVertex2fv                 ;\n\t\tqglVertex2i                  = \tlogVertex2i                  ;\n\t\tqglVertex2iv                 = \tlogVertex2iv                 ;\n\t\tqglVertex2s                  = \tlogVertex2s                  ;\n\t\tqglVertex2sv                 = \tlogVertex2sv                 ;\n\t\tqglVertex3d                  = \tlogVertex3d                  ;\n\t\tqglVertex3dv                 = \tlogVertex3dv                 ;\n\t\tqglVertex3f                  = \tlogVertex3f                  ;\n\t\tqglVertex3fv                 = \tlogVertex3fv                 ;\n\t\tqglVertex3i                  = \tlogVertex3i                  ;\n\t\tqglVertex3iv                 = \tlogVertex3iv                 ;\n\t\tqglVertex3s                  = \tlogVertex3s                  ;\n\t\tqglVertex3sv                 = \tlogVertex3sv                 ;\n\t\tqglVertex4d                  = \tlogVertex4d                  ;\n\t\tqglVertex4dv                 = \tlogVertex4dv                 ;\n\t\tqglVertex4f                  = \tlogVertex4f                  ;\n\t\tqglVertex4fv                 = \tlogVertex4fv                 ;\n\t\tqglVertex4i                  = \tlogVertex4i                  ;\n\t\tqglVertex4iv                 = \tlogVertex4iv                 ;\n\t\tqglVertex4s                  = \tlogVertex4s                  ;\n\t\tqglVertex4sv                 = \tlogVertex4sv                 ;\n\t\tqglVertexPointer             = \tlogVertexPointer             ;\n\t\tqglViewport                  = \tlogViewport                  ;\n\t}\n\telse\n\t{\n\t\tif ( glw_state.log_fp )\t{\n\t\t\tfprintf( glw_state.log_fp, \"*** CLOSING LOG ***\\n\" );\n\t\t\tfclose( glw_state.log_fp );\n\t\t\tglw_state.log_fp = NULL;\n\t\t}\n\t\tqglAccum                     = dllAccum;\n\t\tqglAlphaFunc                 = dllAlphaFunc;\n\t\tqglAreTexturesResident       = dllAreTexturesResident;\n\t\tqglArrayElement              = dllArrayElement;\n\t\tqglBegin                     = dllBegin;\n\t\tqglBindTexture               = dllBindTexture;\n\t\tqglBitmap                    = dllBitmap;\n\t\tqglBlendFunc                 = dllBlendFunc;\n\t\tqglCallList                  = dllCallList;\n\t\tqglCallLists                 = dllCallLists;\n\t\tqglClear                     = dllClear;\n\t\tqglClearAccum                = dllClearAccum;\n\t\tqglClearColor                = dllClearColor;\n\t\tqglClearDepth                = dllClearDepth;\n\t\tqglClearIndex                = dllClearIndex;\n\t\tqglClearStencil              = dllClearStencil;\n\t\tqglClipPlane                 = dllClipPlane;\n\t\tqglColor3b                   = dllColor3b;\n\t\tqglColor3bv                  = dllColor3bv;\n\t\tqglColor3d                   = dllColor3d;\n\t\tqglColor3dv                  = dllColor3dv;\n\t\tqglColor3f                   = dllColor3f;\n\t\tqglColor3fv                  = dllColor3fv;\n\t\tqglColor3i                   = dllColor3i;\n\t\tqglColor3iv                  = dllColor3iv;\n\t\tqglColor3s                   = dllColor3s;\n\t\tqglColor3sv                  = dllColor3sv;\n\t\tqglColor3ub                  = dllColor3ub;\n\t\tqglColor3ubv                 = dllColor3ubv;\n\t\tqglColor3ui                  = dllColor3ui;\n\t\tqglColor3uiv                 = dllColor3uiv;\n\t\tqglColor3us                  = dllColor3us;\n\t\tqglColor3usv                 = dllColor3usv;\n\t\tqglColor4b                   = dllColor4b;\n\t\tqglColor4bv                  = dllColor4bv;\n\t\tqglColor4d                   = dllColor4d;\n\t\tqglColor4dv                  = dllColor4dv;\n\t\tqglColor4f                   = dllColor4f;\n\t\tqglColor4fv                  = dllColor4fv;\n\t\tqglColor4i                   = dllColor4i;\n\t\tqglColor4iv                  = dllColor4iv;\n\t\tqglColor4s                   = dllColor4s;\n\t\tqglColor4sv                  = dllColor4sv;\n\t\tqglColor4ub                  = dllColor4ub;\n\t\tqglColor4ubv                 = dllColor4ubv;\n\t\tqglColor4ui                  = dllColor4ui;\n\t\tqglColor4uiv                 = dllColor4uiv;\n\t\tqglColor4us                  = dllColor4us;\n\t\tqglColor4usv                 = dllColor4usv;\n\t\tqglColorMask                 = dllColorMask;\n\t\tqglColorMaterial             = dllColorMaterial;\n\t\tqglColorPointer              = dllColorPointer;\n\t\tqglCopyPixels                = dllCopyPixels;\n\t\tqglCopyTexImage1D            = dllCopyTexImage1D;\n\t\tqglCopyTexImage2D            = dllCopyTexImage2D;\n\t\tqglCopyTexSubImage1D         = dllCopyTexSubImage1D;\n\t\tqglCopyTexSubImage2D         = dllCopyTexSubImage2D;\n\t\tqglCullFace                  = dllCullFace;\n\t\tqglDeleteLists               = dllDeleteLists ;\n\t\tqglDeleteTextures            = dllDeleteTextures ;\n\t\tqglDepthFunc                 = dllDepthFunc ;\n\t\tqglDepthMask                 = dllDepthMask ;\n\t\tqglDepthRange                = dllDepthRange ;\n\t\tqglDisable                   = dllDisable ;\n\t\tqglDisableClientState        = dllDisableClientState ;\n\t\tqglDrawArrays                = dllDrawArrays ;\n\t\tqglDrawBuffer                = dllDrawBuffer ;\n\t\tqglDrawElements              = dllDrawElements ;\n\t\tqglDrawPixels                = dllDrawPixels ;\n\t\tqglEdgeFlag                  = dllEdgeFlag ;\n\t\tqglEdgeFlagPointer           = dllEdgeFlagPointer ;\n\t\tqglEdgeFlagv                 = dllEdgeFlagv ;\n\t\tqglEnable                    = \tdllEnable                    ;\n\t\tqglEnableClientState         = \tdllEnableClientState         ;\n\t\tqglEnd                       = \tdllEnd                       ;\n\t\tqglEndList                   = \tdllEndList                   ;\n\t\tqglEvalCoord1d\t\t\t\t = \tdllEvalCoord1d\t\t\t\t ;\n\t\tqglEvalCoord1dv              = \tdllEvalCoord1dv              ;\n\t\tqglEvalCoord1f               = \tdllEvalCoord1f               ;\n\t\tqglEvalCoord1fv              = \tdllEvalCoord1fv              ;\n\t\tqglEvalCoord2d               = \tdllEvalCoord2d               ;\n\t\tqglEvalCoord2dv              = \tdllEvalCoord2dv              ;\n\t\tqglEvalCoord2f               = \tdllEvalCoord2f               ;\n\t\tqglEvalCoord2fv              = \tdllEvalCoord2fv              ;\n\t\tqglEvalMesh1                 = \tdllEvalMesh1                 ;\n\t\tqglEvalMesh2                 = \tdllEvalMesh2                 ;\n\t\tqglEvalPoint1                = \tdllEvalPoint1                ;\n\t\tqglEvalPoint2                = \tdllEvalPoint2                ;\n\t\tqglFeedbackBuffer            = \tdllFeedbackBuffer            ;\n\t\tqglFinish                    = \tdllFinish                    ;\n\t\tqglFlush                     = \tdllFlush                     ;\n\t\tqglFogf                      = \tdllFogf                      ;\n\t\tqglFogfv                     = \tdllFogfv                     ;\n\t\tqglFogi                      = \tdllFogi                      ;\n\t\tqglFogiv                     = \tdllFogiv                     ;\n\t\tqglFrontFace                 = \tdllFrontFace                 ;\n\t\tqglFrustum                   = \tdllFrustum                   ;\n\t\tqglGenLists                  = \tdllGenLists                  ;\n\t\tqglGenTextures               = \tdllGenTextures               ;\n\t\tqglGetBooleanv               = \tdllGetBooleanv               ;\n\t\tqglGetClipPlane              = \tdllGetClipPlane              ;\n\t\tqglGetDoublev                = \tdllGetDoublev                ;\n\t\tqglGetError                  = \tdllGetError                  ;\n\t\tqglGetFloatv                 = \tdllGetFloatv                 ;\n\t\tqglGetIntegerv               = \tdllGetIntegerv               ;\n\t\tqglGetLightfv                = \tdllGetLightfv                ;\n\t\tqglGetLightiv                = \tdllGetLightiv                ;\n\t\tqglGetMapdv                  = \tdllGetMapdv                  ;\n\t\tqglGetMapfv                  = \tdllGetMapfv                  ;\n\t\tqglGetMapiv                  = \tdllGetMapiv                  ;\n\t\tqglGetMaterialfv             = \tdllGetMaterialfv             ;\n\t\tqglGetMaterialiv             = \tdllGetMaterialiv             ;\n\t\tqglGetPixelMapfv             = \tdllGetPixelMapfv             ;\n\t\tqglGetPixelMapuiv            = \tdllGetPixelMapuiv            ;\n\t\tqglGetPixelMapusv            = \tdllGetPixelMapusv            ;\n\t\tqglGetPointerv               = \tdllGetPointerv               ;\n\t\tqglGetPolygonStipple         = \tdllGetPolygonStipple         ;\n\t\tqglGetString                 = \tdllGetString                 ;\n\t\tqglGetTexEnvfv               = \tdllGetTexEnvfv               ;\n\t\tqglGetTexEnviv               = \tdllGetTexEnviv               ;\n\t\tqglGetTexGendv               = \tdllGetTexGendv               ;\n\t\tqglGetTexGenfv               = \tdllGetTexGenfv               ;\n\t\tqglGetTexGeniv               = \tdllGetTexGeniv               ;\n\t\tqglGetTexImage               = \tdllGetTexImage               ;\n\t\tqglGetTexLevelParameterfv    = \tdllGetTexLevelParameterfv    ;\n\t\tqglGetTexLevelParameteriv    = \tdllGetTexLevelParameteriv    ;\n\t\tqglGetTexParameterfv         = \tdllGetTexParameterfv         ;\n\t\tqglGetTexParameteriv         = \tdllGetTexParameteriv         ;\n\t\tqglHint                      = \tdllHint                      ;\n\t\tqglIndexMask                 = \tdllIndexMask                 ;\n\t\tqglIndexPointer              = \tdllIndexPointer              ;\n\t\tqglIndexd                    = \tdllIndexd                    ;\n\t\tqglIndexdv                   = \tdllIndexdv                   ;\n\t\tqglIndexf                    = \tdllIndexf                    ;\n\t\tqglIndexfv                   = \tdllIndexfv                   ;\n\t\tqglIndexi                    = \tdllIndexi                    ;\n\t\tqglIndexiv                   = \tdllIndexiv                   ;\n\t\tqglIndexs                    = \tdllIndexs                    ;\n\t\tqglIndexsv                   = \tdllIndexsv                   ;\n\t\tqglIndexub                   = \tdllIndexub                   ;\n\t\tqglIndexubv                  = \tdllIndexubv                  ;\n\t\tqglInitNames                 = \tdllInitNames                 ;\n\t\tqglInterleavedArrays         = \tdllInterleavedArrays         ;\n\t\tqglIsEnabled                 = \tdllIsEnabled                 ;\n\t\tqglIsList                    = \tdllIsList                    ;\n\t\tqglIsTexture                 = \tdllIsTexture                 ;\n\t\tqglLightModelf               = \tdllLightModelf               ;\n\t\tqglLightModelfv              = \tdllLightModelfv              ;\n\t\tqglLightModeli               = \tdllLightModeli               ;\n\t\tqglLightModeliv              = \tdllLightModeliv              ;\n\t\tqglLightf                    = \tdllLightf                    ;\n\t\tqglLightfv                   = \tdllLightfv                   ;\n\t\tqglLighti                    = \tdllLighti                    ;\n\t\tqglLightiv                   = \tdllLightiv                   ;\n\t\tqglLineStipple               = \tdllLineStipple               ;\n\t\tqglLineWidth                 = \tdllLineWidth                 ;\n\t\tqglListBase                  = \tdllListBase                  ;\n\t\tqglLoadIdentity              = \tdllLoadIdentity              ;\n\t\tqglLoadMatrixd               = \tdllLoadMatrixd               ;\n\t\tqglLoadMatrixf               = \tdllLoadMatrixf               ;\n\t\tqglLoadName                  = \tdllLoadName                  ;\n\t\tqglLogicOp                   = \tdllLogicOp                   ;\n\t\tqglMap1d                     = \tdllMap1d                     ;\n\t\tqglMap1f                     = \tdllMap1f                     ;\n\t\tqglMap2d                     = \tdllMap2d                     ;\n\t\tqglMap2f                     = \tdllMap2f                     ;\n\t\tqglMapGrid1d                 = \tdllMapGrid1d                 ;\n\t\tqglMapGrid1f                 = \tdllMapGrid1f                 ;\n\t\tqglMapGrid2d                 = \tdllMapGrid2d                 ;\n\t\tqglMapGrid2f                 = \tdllMapGrid2f                 ;\n\t\tqglMaterialf                 = \tdllMaterialf                 ;\n\t\tqglMaterialfv                = \tdllMaterialfv                ;\n\t\tqglMateriali                 = \tdllMateriali                 ;\n\t\tqglMaterialiv                = \tdllMaterialiv                ;\n\t\tqglMatrixMode                = \tdllMatrixMode                ;\n\t\tqglMultMatrixd               = \tdllMultMatrixd               ;\n\t\tqglMultMatrixf               = \tdllMultMatrixf               ;\n\t\tqglNewList                   = \tdllNewList                   ;\n\t\tqglNormal3b                  = \tdllNormal3b                  ;\n\t\tqglNormal3bv                 = \tdllNormal3bv                 ;\n\t\tqglNormal3d                  = \tdllNormal3d                  ;\n\t\tqglNormal3dv                 = \tdllNormal3dv                 ;\n\t\tqglNormal3f                  = \tdllNormal3f                  ;\n\t\tqglNormal3fv                 = \tdllNormal3fv                 ;\n\t\tqglNormal3i                  = \tdllNormal3i                  ;\n\t\tqglNormal3iv                 = \tdllNormal3iv                 ;\n\t\tqglNormal3s                  = \tdllNormal3s                  ;\n\t\tqglNormal3sv                 = \tdllNormal3sv                 ;\n\t\tqglNormalPointer             = \tdllNormalPointer             ;\n\t\tqglOrtho                     = \tdllOrtho                     ;\n\t\tqglPassThrough               = \tdllPassThrough               ;\n\t\tqglPixelMapfv                = \tdllPixelMapfv                ;\n\t\tqglPixelMapuiv               = \tdllPixelMapuiv               ;\n\t\tqglPixelMapusv               = \tdllPixelMapusv               ;\n\t\tqglPixelStoref               = \tdllPixelStoref               ;\n\t\tqglPixelStorei               = \tdllPixelStorei               ;\n\t\tqglPixelTransferf            = \tdllPixelTransferf            ;\n\t\tqglPixelTransferi            = \tdllPixelTransferi            ;\n\t\tqglPixelZoom                 = \tdllPixelZoom                 ;\n\t\tqglPointSize                 = \tdllPointSize                 ;\n\t\tqglPolygonMode               = \tdllPolygonMode               ;\n\t\tqglPolygonOffset             = \tdllPolygonOffset             ;\n\t\tqglPolygonStipple            = \tdllPolygonStipple            ;\n\t\tqglPopAttrib                 = \tdllPopAttrib                 ;\n\t\tqglPopClientAttrib           = \tdllPopClientAttrib           ;\n\t\tqglPopMatrix                 = \tdllPopMatrix                 ;\n\t\tqglPopName                   = \tdllPopName                   ;\n\t\tqglPrioritizeTextures        = \tdllPrioritizeTextures        ;\n\t\tqglPushAttrib                = \tdllPushAttrib                ;\n\t\tqglPushClientAttrib          = \tdllPushClientAttrib          ;\n\t\tqglPushMatrix                = \tdllPushMatrix                ;\n\t\tqglPushName                  = \tdllPushName                  ;\n\t\tqglRasterPos2d               = \tdllRasterPos2d               ;\n\t\tqglRasterPos2dv              = \tdllRasterPos2dv              ;\n\t\tqglRasterPos2f               = \tdllRasterPos2f               ;\n\t\tqglRasterPos2fv              = \tdllRasterPos2fv              ;\n\t\tqglRasterPos2i               = \tdllRasterPos2i               ;\n\t\tqglRasterPos2iv              = \tdllRasterPos2iv              ;\n\t\tqglRasterPos2s               = \tdllRasterPos2s               ;\n\t\tqglRasterPos2sv              = \tdllRasterPos2sv              ;\n\t\tqglRasterPos3d               = \tdllRasterPos3d               ;\n\t\tqglRasterPos3dv              = \tdllRasterPos3dv              ;\n\t\tqglRasterPos3f               = \tdllRasterPos3f               ;\n\t\tqglRasterPos3fv              = \tdllRasterPos3fv              ;\n\t\tqglRasterPos3i               = \tdllRasterPos3i               ;\n\t\tqglRasterPos3iv              = \tdllRasterPos3iv              ;\n\t\tqglRasterPos3s               = \tdllRasterPos3s               ;\n\t\tqglRasterPos3sv              = \tdllRasterPos3sv              ;\n\t\tqglRasterPos4d               = \tdllRasterPos4d               ;\n\t\tqglRasterPos4dv              = \tdllRasterPos4dv              ;\n\t\tqglRasterPos4f               = \tdllRasterPos4f               ;\n\t\tqglRasterPos4fv              = \tdllRasterPos4fv              ;\n\t\tqglRasterPos4i               = \tdllRasterPos4i               ;\n\t\tqglRasterPos4iv              = \tdllRasterPos4iv              ;\n\t\tqglRasterPos4s               = \tdllRasterPos4s               ;\n\t\tqglRasterPos4sv              = \tdllRasterPos4sv              ;\n\t\tqglReadBuffer                = \tdllReadBuffer                ;\n\t\tqglReadPixels                = \tdllReadPixels                ;\n\t\tqglRectd                     = \tdllRectd                     ;\n\t\tqglRectdv                    = \tdllRectdv                    ;\n\t\tqglRectf                     = \tdllRectf                     ;\n\t\tqglRectfv                    = \tdllRectfv                    ;\n\t\tqglRecti                     = \tdllRecti                     ;\n\t\tqglRectiv                    = \tdllRectiv                    ;\n\t\tqglRects                     = \tdllRects                     ;\n\t\tqglRectsv                    = \tdllRectsv                    ;\n\t\tqglRenderMode                = \tdllRenderMode                ;\n\t\tqglRotated                   = \tdllRotated                   ;\n\t\tqglRotatef                   = \tdllRotatef                   ;\n\t\tqglScaled                    = \tdllScaled                    ;\n\t\tqglScalef                    = \tdllScalef                    ;\n\t\tqglScissor                   = \tdllScissor                   ;\n\t\tqglSelectBuffer              = \tdllSelectBuffer              ;\n\t\tqglShadeModel                = \tdllShadeModel                ;\n\t\tqglStencilFunc               = \tdllStencilFunc               ;\n\t\tqglStencilMask               = \tdllStencilMask               ;\n\t\tqglStencilOp                 = \tdllStencilOp                 ;\n\t\tqglTexCoord1d                = \tdllTexCoord1d                ;\n\t\tqglTexCoord1dv               = \tdllTexCoord1dv               ;\n\t\tqglTexCoord1f                = \tdllTexCoord1f                ;\n\t\tqglTexCoord1fv               = \tdllTexCoord1fv               ;\n\t\tqglTexCoord1i                = \tdllTexCoord1i                ;\n\t\tqglTexCoord1iv               = \tdllTexCoord1iv               ;\n\t\tqglTexCoord1s                = \tdllTexCoord1s                ;\n\t\tqglTexCoord1sv               = \tdllTexCoord1sv               ;\n\t\tqglTexCoord2d                = \tdllTexCoord2d                ;\n\t\tqglTexCoord2dv               = \tdllTexCoord2dv               ;\n\t\tqglTexCoord2f                = \tdllTexCoord2f                ;\n\t\tqglTexCoord2fv               = \tdllTexCoord2fv               ;\n\t\tqglTexCoord2i                = \tdllTexCoord2i                ;\n\t\tqglTexCoord2iv               = \tdllTexCoord2iv               ;\n\t\tqglTexCoord2s                = \tdllTexCoord2s                ;\n\t\tqglTexCoord2sv               = \tdllTexCoord2sv               ;\n\t\tqglTexCoord3d                = \tdllTexCoord3d                ;\n\t\tqglTexCoord3dv               = \tdllTexCoord3dv               ;\n\t\tqglTexCoord3f                = \tdllTexCoord3f                ;\n\t\tqglTexCoord3fv               = \tdllTexCoord3fv               ;\n\t\tqglTexCoord3i                = \tdllTexCoord3i                ;\n\t\tqglTexCoord3iv               = \tdllTexCoord3iv               ;\n\t\tqglTexCoord3s                = \tdllTexCoord3s                ;\n\t\tqglTexCoord3sv               = \tdllTexCoord3sv               ;\n\t\tqglTexCoord4d                = \tdllTexCoord4d                ;\n\t\tqglTexCoord4dv               = \tdllTexCoord4dv               ;\n\t\tqglTexCoord4f                = \tdllTexCoord4f                ;\n\t\tqglTexCoord4fv               = \tdllTexCoord4fv               ;\n\t\tqglTexCoord4i                = \tdllTexCoord4i                ;\n\t\tqglTexCoord4iv               = \tdllTexCoord4iv               ;\n\t\tqglTexCoord4s                = \tdllTexCoord4s                ;\n\t\tqglTexCoord4sv               = \tdllTexCoord4sv               ;\n\t\tqglTexCoordPointer           = \tdllTexCoordPointer           ;\n\t\tqglTexEnvf                   = \tdllTexEnvf                   ;\n\t\tqglTexEnvfv                  = \tdllTexEnvfv                  ;\n\t\tqglTexEnvi                   = \tdllTexEnvi                   ;\n\t\tqglTexEnviv                  = \tdllTexEnviv                  ;\n\t\tqglTexGend                   = \tdllTexGend                   ;\n\t\tqglTexGendv                  = \tdllTexGendv                  ;\n\t\tqglTexGenf                   = \tdllTexGenf                   ;\n\t\tqglTexGenfv                  = \tdllTexGenfv                  ;\n\t\tqglTexGeni                   = \tdllTexGeni                   ;\n\t\tqglTexGeniv                  = \tdllTexGeniv                  ;\n\t\tqglTexImage1D                = \tdllTexImage1D                ;\n\t\tqglTexImage2D                = \tdllTexImage2D                ;\n\t\tqglTexParameterf             = \tdllTexParameterf             ;\n\t\tqglTexParameterfv            = \tdllTexParameterfv            ;\n\t\tqglTexParameteri             = \tdllTexParameteri             ;\n\t\tqglTexParameteriv            = \tdllTexParameteriv            ;\n\t\tqglTexSubImage1D             = \tdllTexSubImage1D             ;\n\t\tqglTexSubImage2D             = \tdllTexSubImage2D             ;\n\t\tqglTranslated                = \tdllTranslated                ;\n\t\tqglTranslatef                = \tdllTranslatef                ;\n\t\tqglVertex2d                  = \tdllVertex2d                  ;\n\t\tqglVertex2dv                 = \tdllVertex2dv                 ;\n\t\tqglVertex2f                  = \tdllVertex2f                  ;\n\t\tqglVertex2fv                 = \tdllVertex2fv                 ;\n\t\tqglVertex2i                  = \tdllVertex2i                  ;\n\t\tqglVertex2iv                 = \tdllVertex2iv                 ;\n\t\tqglVertex2s                  = \tdllVertex2s                  ;\n\t\tqglVertex2sv                 = \tdllVertex2sv                 ;\n\t\tqglVertex3d                  = \tdllVertex3d                  ;\n\t\tqglVertex3dv                 = \tdllVertex3dv                 ;\n\t\tqglVertex3f                  = \tdllVertex3f                  ;\n\t\tqglVertex3fv                 = \tdllVertex3fv                 ;\n\t\tqglVertex3i                  = \tdllVertex3i                  ;\n\t\tqglVertex3iv                 = \tdllVertex3iv                 ;\n\t\tqglVertex3s                  = \tdllVertex3s                  ;\n\t\tqglVertex3sv                 = \tdllVertex3sv                 ;\n\t\tqglVertex4d                  = \tdllVertex4d                  ;\n\t\tqglVertex4dv                 = \tdllVertex4dv                 ;\n\t\tqglVertex4f                  = \tdllVertex4f                  ;\n\t\tqglVertex4fv                 = \tdllVertex4fv                 ;\n\t\tqglVertex4i                  = \tdllVertex4i                  ;\n\t\tqglVertex4iv                 = \tdllVertex4iv                 ;\n\t\tqglVertex4s                  = \tdllVertex4s                  ;\n\t\tqglVertex4sv                 = \tdllVertex4sv                 ;\n\t\tqglVertexPointer             = \tdllVertexPointer             ;\n\t\tqglViewport                  = \tdllViewport                  ;\n\t}\n}\n\n#pragma warning (default : 4113 4133 4047 )\n\n\n\n"
  },
  {
    "path": "code/win32/win_shared.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"../game/q_shared.h\"\n#include \"../qcommon/qcommon.h\"\n#include \"win_local.h\"\n#include <lmerr.h>\n#include <lmcons.h>\n#include <lmwksta.h>\n#include <errno.h>\n#include <fcntl.h>\n#include <stdio.h>\n#include <direct.h>\n#include <io.h>\n#include <conio.h>\n\n/*\n================\nSys_Milliseconds\n================\n*/\nint\t\t\tsys_timeBase;\nint Sys_Milliseconds (void)\n{\n\tint\t\t\tsys_curtime;\n\tstatic qboolean\tinitialized = qfalse;\n\n\tif (!initialized) {\n\t\tsys_timeBase = timeGetTime();\n\t\tinitialized = qtrue;\n\t}\n\tsys_curtime = timeGetTime() - sys_timeBase;\n\n\treturn sys_curtime;\n}\n\n/*\n================\nSys_SnapVector\n================\n*/\nlong fastftol( float f ) {\n\tstatic int tmp;\n\t__asm fld f\n\t__asm fistp tmp\n\t__asm mov eax, tmp\n}\n\nvoid Sys_SnapVector( float *v )\n{\n\tint i;\n\tfloat f;\n\n\tf = *v;\n\t__asm\tfld\t\tf;\n\t__asm\tfistp\ti;\n\t*v = i;\n\tv++;\n\tf = *v;\n\t__asm\tfld\t\tf;\n\t__asm\tfistp\ti;\n\t*v = i;\n\tv++;\n\tf = *v;\n\t__asm\tfld\t\tf;\n\t__asm\tfistp\ti;\n\t*v = i;\n\t/*\n\t*v = fastftol(*v);\n\tv++;\n\t*v = fastftol(*v);\n\tv++;\n\t*v = fastftol(*v);\n\t*/\n}\n\n\n/*\n**\n** Disable all optimizations temporarily so this code works correctly!\n**\n*/\n#pragma optimize( \"\", off )\n\n/*\n** --------------------------------------------------------------------------------\n**\n** PROCESSOR STUFF\n**\n** --------------------------------------------------------------------------------\n*/\nstatic void CPUID( int func, unsigned regs[4] )\n{\n\tunsigned regEAX, regEBX, regECX, regEDX;\n\n#ifndef __VECTORC\n\t__asm mov eax, func\n\t__asm __emit 00fh\n\t__asm __emit 0a2h\n\t__asm mov regEAX, eax\n\t__asm mov regEBX, ebx\n\t__asm mov regECX, ecx\n\t__asm mov regEDX, edx\n\n\tregs[0] = regEAX;\n\tregs[1] = regEBX;\n\tregs[2] = regECX;\n\tregs[3] = regEDX;\n#else\n\tregs[0] = 0;\n\tregs[1] = 0;\n\tregs[2] = 0;\n\tregs[3] = 0;\n#endif\n}\n\nstatic int IsPentium( void )\n{\n\t__asm \n\t{\n\t\tpushfd\t\t\t\t\t\t// save eflags\n\t\tpop\t\teax\n\t\ttest\teax, 0x00200000\t\t// check ID bit\n\t\tjz\t\tset21\t\t\t\t// bit 21 is not set, so jump to set_21\n\t\tand\t\teax, 0xffdfffff\t\t// clear bit 21\n\t\tpush\teax\t\t\t\t\t// save new value in register\n\t\tpopfd\t\t\t\t\t\t// store new value in flags\n\t\tpushfd\n\t\tpop\t\teax\n\t\ttest\teax, 0x00200000\t\t// check ID bit\n\t\tjz\t\tgood\n\t\tjmp\t\terr\t\t\t\t\t// cpuid not supported\nset21:\n\t\tor\t\teax, 0x00200000\t\t// set ID bit\n\t\tpush\teax\t\t\t\t\t// store new value\n\t\tpopfd\t\t\t\t\t\t// store new value in EFLAGS\n\t\tpushfd\n\t\tpop\t\teax\n\t\ttest\teax, 0x00200000\t\t// if bit 21 is on\n\t\tjnz\t\tgood\n\t\tjmp\t\terr\n\t}\n\nerr:\n\treturn qfalse;\ngood:\n\treturn qtrue;\n}\n\nstatic int Is3DNOW( void )\n{\n\tunsigned regs[4];\n\tchar pstring[16];\n\tchar processorString[13];\n\n\t// get name of processor\n\tCPUID( 0, ( unsigned int * ) pstring );\n\tprocessorString[0] = pstring[4];\n\tprocessorString[1] = pstring[5];\n\tprocessorString[2] = pstring[6];\n\tprocessorString[3] = pstring[7];\n\tprocessorString[4] = pstring[12];\n\tprocessorString[5] = pstring[13];\n\tprocessorString[6] = pstring[14];\n\tprocessorString[7] = pstring[15];\n\tprocessorString[8] = pstring[8];\n\tprocessorString[9] = pstring[9];\n\tprocessorString[10] = pstring[10];\n\tprocessorString[11] = pstring[11];\n\tprocessorString[12] = 0;\n\n//  REMOVED because you can have 3DNow! on non-AMD systems\n//\tif ( strcmp( processorString, \"AuthenticAMD\" ) )\n//\t\treturn qfalse;\n\n\t// check AMD-specific functions\n\tCPUID( 0x80000000, regs );\n\tif ( regs[0] < 0x80000000 )\n\t\treturn qfalse;\n\n\t// bit 31 of EDX denotes 3DNOW! support\n\tCPUID( 0x80000001, regs );\n\tif ( regs[3] & ( 1 << 31 ) )\n\t\treturn qtrue;\n\n\treturn qfalse;\n}\n\nstatic int IsKNI( void )\n{\n\tunsigned regs[4];\n\n\t// get CPU feature bits\n\tCPUID( 1, regs );\n\n\t// bit 25 of EDX denotes KNI existence\n\tif ( regs[3] & ( 1 << 25 ) )\n\t\treturn qtrue;\n\n\treturn qfalse;\n}\n\nstatic int IsMMX( void )\n{\n\tunsigned regs[4];\n\n\t// get CPU feature bits\n\tCPUID( 1, regs );\n\n\t// bit 23 of EDX denotes MMX existence\n\tif ( regs[3] & ( 1 << 23 ) )\n\t\treturn qtrue;\n\treturn qfalse;\n}\n\nint Sys_GetProcessorId( void )\n{\n#if defined _M_ALPHA\n\treturn CPUID_AXP;\n#elif !defined _M_IX86\n\treturn CPUID_GENERIC;\n#else\n\n\t// verify we're at least a Pentium or 486 w/ CPUID support\n\tif ( !IsPentium() )\n\t\treturn CPUID_INTEL_UNSUPPORTED;\n\n\t// check for MMX\n\tif ( !IsMMX() )\n\t{\n\t\t// Pentium or PPro\n\t\treturn CPUID_INTEL_PENTIUM;\n\t}\n\n\t// see if we're an AMD 3DNOW! processor\n\tif ( Is3DNOW() )\n\t{\n\t\treturn CPUID_AMD_3DNOW;\n\t}\n\n\t// see if we're an Intel Katmai\n\tif ( IsKNI() )\n\t{\n\t\treturn CPUID_INTEL_KATMAI;\n\t}\n\n\t// by default we're functionally a vanilla Pentium/MMX or P2/MMX\n\treturn CPUID_INTEL_MMX;\n\n#endif\n}\n\n/*\n**\n** Re-enable optimizations back to what they were\n**\n*/\n#pragma optimize( \"\", on )\n\n//============================================\n\nchar *Sys_GetCurrentUser( void )\n{\n\tstatic char s_userName[1024];\n\tunsigned long size = sizeof( s_userName );\n\n\n\tif ( !GetUserName( s_userName, &size ) )\n\t\tstrcpy( s_userName, \"player\" );\n\n\tif ( !s_userName[0] )\n\t{\n\t\tstrcpy( s_userName, \"player\" );\n\t}\n\n\treturn s_userName;\n}\n\nchar\t*Sys_DefaultHomePath(void) {\n\treturn NULL;\n}\n\nchar *Sys_DefaultInstallPath(void)\n{\n\treturn Sys_Cwd();\n}\n\n"
  },
  {
    "path": "code/win32/win_snd.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include <float.h>\n\n#include \"../client/snd_local.h\"\n#include \"win_local.h\"\n\nHRESULT (WINAPI *pDirectSoundCreate)(GUID FAR *lpGUID, LPDIRECTSOUND FAR *lplpDS, IUnknown FAR *pUnkOuter);\n#define iDirectSoundCreate(a,b,c)\tpDirectSoundCreate(a,b,c)\n\n#define SECONDARY_BUFFER_SIZE\t0x10000\n\n\nstatic qboolean\tdsound_init;\nstatic int\t\tsample16;\nstatic DWORD\tgSndBufSize;\nstatic DWORD\tlocksize;\nstatic LPDIRECTSOUND pDS;\nstatic LPDIRECTSOUNDBUFFER pDSBuf, pDSPBuf;\nstatic HINSTANCE hInstDS;\n\n\nstatic const char *DSoundError( int error ) {\n\tswitch ( error ) {\n\tcase DSERR_BUFFERLOST:\n\t\treturn \"DSERR_BUFFERLOST\";\n\tcase DSERR_INVALIDCALL:\n\t\treturn \"DSERR_INVALIDCALLS\";\n\tcase DSERR_INVALIDPARAM:\n\t\treturn \"DSERR_INVALIDPARAM\";\n\tcase DSERR_PRIOLEVELNEEDED:\n\t\treturn \"DSERR_PRIOLEVELNEEDED\";\n\t}\n\n\treturn \"unknown\";\n}\n\n/*\n==================\nSNDDMA_Shutdown\n==================\n*/\nvoid SNDDMA_Shutdown( void ) {\n\tCom_DPrintf( \"Shutting down sound system\\n\" );\n\n\tif ( pDS ) {\n\t\tCom_DPrintf( \"Destroying DS buffers\\n\" );\n\t\tif ( pDS )\n\t\t{\n\t\t\tCom_DPrintf( \"...setting NORMAL coop level\\n\" );\n\t\t\tpDS->lpVtbl->SetCooperativeLevel( pDS, g_wv.hWnd, DSSCL_PRIORITY );\n\t\t}\n\n\t\tif ( pDSBuf )\n\t\t{\n\t\t\tCom_DPrintf( \"...stopping and releasing sound buffer\\n\" );\n\t\t\tpDSBuf->lpVtbl->Stop( pDSBuf );\n\t\t\tpDSBuf->lpVtbl->Release( pDSBuf );\n\t\t}\n\n\t\t// only release primary buffer if it's not also the mixing buffer we just released\n\t\tif ( pDSPBuf && ( pDSBuf != pDSPBuf ) )\n\t\t{\n\t\t\tCom_DPrintf( \"...releasing primary buffer\\n\" );\n\t\t\tpDSPBuf->lpVtbl->Release( pDSPBuf );\n\t\t}\n\t\tpDSBuf = NULL;\n\t\tpDSPBuf = NULL;\n\n\t\tdma.buffer = NULL;\n\n\t\tCom_DPrintf( \"...releasing DS object\\n\" );\n\t\tpDS->lpVtbl->Release( pDS );\n\t}\n\n\tif ( hInstDS ) {\n\t\tCom_DPrintf( \"...freeing DSOUND.DLL\\n\" );\n\t\tFreeLibrary( hInstDS );\n\t\thInstDS = NULL;\n\t}\n\n\tpDS = NULL;\n\tpDSBuf = NULL;\n\tpDSPBuf = NULL;\n\tdsound_init = qfalse;\n\tmemset ((void *)&dma, 0, sizeof (dma));\n\tCoUninitialize( );\n}\n\n/*\n==================\nSNDDMA_Init\n\nInitialize direct sound\nReturns false if failed\n==================\n*/\nqboolean SNDDMA_Init(void) {\n\n\tmemset ((void *)&dma, 0, sizeof (dma));\n\tdsound_init = 0;\n\n\tCoInitialize(NULL);\n\n\tif ( !SNDDMA_InitDS () ) {\n\t\treturn qfalse;\n\t}\n\n\tdsound_init = qtrue;\n\n\tCom_DPrintf(\"Completed successfully\\n\" );\n\n    return qtrue;\n}\n\n#undef DEFINE_GUID\n\n#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \\\n        EXTERN_C const GUID name \\\n                = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }\n\n// DirectSound Component GUID {47D4D946-62E8-11CF-93BC-444553540000}\nDEFINE_GUID(CLSID_DirectSound, 0x47d4d946, 0x62e8, 0x11cf, 0x93, 0xbc, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0);\n\n// DirectSound 8.0 Component GUID {3901CC3F-84B5-4FA4-BA35-AA8172B8A09B}\nDEFINE_GUID(CLSID_DirectSound8, 0x3901cc3f, 0x84b5, 0x4fa4, 0xba, 0x35, 0xaa, 0x81, 0x72, 0xb8, 0xa0, 0x9b);\n\nDEFINE_GUID(IID_IDirectSound8, 0xC50A7E93, 0xF395, 0x4834, 0x9E, 0xF6, 0x7F, 0xA9, 0x9D, 0xE5, 0x09, 0x66);\nDEFINE_GUID(IID_IDirectSound, 0x279AFA83, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60);\n\n\nint SNDDMA_InitDS ()\n{\n\tHRESULT\t\t\thresult;\n\tDSBUFFERDESC\tdsbuf;\n\tDSBCAPS\t\t\tdsbcaps;\n\tWAVEFORMATEX\tformat;\n\tint\t\t\t\tuse8;\n\n\tCom_Printf( \"Initializing DirectSound\\n\");\n\n\tuse8 = 1;\n    // Create IDirectSound using the primary sound device\n    if( FAILED( hresult = CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectSound8, (void **)&pDS))) {\n\t\tuse8 = 0;\n\t    if( FAILED( hresult = CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectSound, (void **)&pDS))) {\n\t\t\tCom_Printf (\"failed\\n\");\n\t\t\tSNDDMA_Shutdown ();\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\thresult = pDS->lpVtbl->Initialize( pDS, NULL);\n\n\tCom_DPrintf( \"ok\\n\" );\n\n\tCom_DPrintf(\"...setting DSSCL_PRIORITY coop level: \" );\n\n\tif ( DS_OK != pDS->lpVtbl->SetCooperativeLevel( pDS, g_wv.hWnd, DSSCL_PRIORITY ) )\t{\n\t\tCom_Printf (\"failed\\n\");\n\t\tSNDDMA_Shutdown ();\n\t\treturn qfalse;\n\t}\n\tCom_DPrintf(\"ok\\n\" );\n\n\n\t// create the secondary buffer we'll actually work with\n\tdma.channels = 2;\n\tdma.samplebits = 16;\n\n//\tif (s_khz->integer == 44)\n//\t\tdma.speed = 44100;\n//\telse if (s_khz->integer == 22)\n//\t\tdma.speed = 22050;\n//\telse\n//\t\tdma.speed = 11025;\n\n\tdma.speed = 22050;\n\tmemset (&format, 0, sizeof(format));\n\tformat.wFormatTag = WAVE_FORMAT_PCM;\n    format.nChannels = dma.channels;\n    format.wBitsPerSample = dma.samplebits;\n    format.nSamplesPerSec = dma.speed;\n    format.nBlockAlign = format.nChannels * format.wBitsPerSample / 8;\n    format.cbSize = 0;\n    format.nAvgBytesPerSec = format.nSamplesPerSec*format.nBlockAlign; \n\n\tmemset (&dsbuf, 0, sizeof(dsbuf));\n\tdsbuf.dwSize = sizeof(DSBUFFERDESC);\n\n\t// Micah: take advantage of 2D hardware.if available.\n\tdsbuf.dwFlags = DSBCAPS_LOCHARDWARE;\n\tif (use8) {\n\t\tdsbuf.dwFlags |= DSBCAPS_GETCURRENTPOSITION2;\n\t}\n\tdsbuf.dwBufferBytes = SECONDARY_BUFFER_SIZE;\n\tdsbuf.lpwfxFormat = &format;\n\t\n\tmemset(&dsbcaps, 0, sizeof(dsbcaps));\n\tdsbcaps.dwSize = sizeof(dsbcaps);\n\t\n\tCom_DPrintf( \"...creating secondary buffer: \" );\n\tif (DS_OK == pDS->lpVtbl->CreateSoundBuffer(pDS, &dsbuf, &pDSBuf, NULL)) {\n\t\tCom_Printf( \"locked hardware.  ok\\n\" );\n\t}\n\telse {\n\t\t// Couldn't get hardware, fallback to software.\n\t\tdsbuf.dwFlags = DSBCAPS_LOCSOFTWARE;\n\t\tif (use8) {\n\t\t\tdsbuf.dwFlags |= DSBCAPS_GETCURRENTPOSITION2;\n\t\t}\n\t\tif (DS_OK != pDS->lpVtbl->CreateSoundBuffer(pDS, &dsbuf, &pDSBuf, NULL)) {\n\t\t\tCom_Printf( \"failed\\n\" );\n\t\t\tSNDDMA_Shutdown ();\n\t\t\treturn qfalse;\n\t\t}\n\t\tCom_DPrintf( \"forced to software.  ok\\n\" );\n\t}\n\t\t\n\t// Make sure mixer is active\n\tif ( DS_OK != pDSBuf->lpVtbl->Play(pDSBuf, 0, 0, DSBPLAY_LOOPING) ) {\n\t\tCom_Printf (\"*** Looped sound play failed ***\\n\");\n\t\tSNDDMA_Shutdown ();\n\t\treturn qfalse;\n\t}\n\n\t// get the returned buffer size\n\tif ( DS_OK != pDSBuf->lpVtbl->GetCaps (pDSBuf, &dsbcaps) ) {\n\t\tCom_Printf (\"*** GetCaps failed ***\\n\");\n\t\tSNDDMA_Shutdown ();\n\t\treturn qfalse;\n\t}\n\t\n\tgSndBufSize = dsbcaps.dwBufferBytes;\n\n\tdma.channels = format.nChannels;\n\tdma.samplebits = format.wBitsPerSample;\n\tdma.speed = format.nSamplesPerSec;\n\tdma.samples = gSndBufSize/(dma.samplebits/8);\n\tdma.submission_chunk = 1;\n\tdma.buffer = NULL;\t\t\t// must be locked first\n\n\tsample16 = (dma.samplebits/8) - 1;\n\n\tSNDDMA_BeginPainting ();\n\tif (dma.buffer)\n\t\tmemset(dma.buffer, 0, dma.samples * dma.samplebits/8);\n\tSNDDMA_Submit ();\n\treturn 1;\n}\n/*\n==============\nSNDDMA_GetDMAPos\n\nreturn the current sample position (in mono samples read)\ninside the recirculating dma buffer, so the mixing code will know\nhow many sample are required to fill it up.\n===============\n*/\nint SNDDMA_GetDMAPos( void ) {\n\tMMTIME\tmmtime;\n\tint\t\ts;\n\tDWORD\tdwWrite;\n\n\tif ( !dsound_init ) {\n\t\treturn 0;\n\t}\n\n\tmmtime.wType = TIME_SAMPLES;\n\tpDSBuf->lpVtbl->GetCurrentPosition(pDSBuf, &mmtime.u.sample, &dwWrite);\n\n\ts = mmtime.u.sample;\n\n\ts >>= sample16;\n\n\ts &= (dma.samples-1);\n\n\treturn s;\n}\n\n/*\n==============\nSNDDMA_BeginPainting\n\nMakes sure dma.buffer is valid\n===============\n*/\nvoid SNDDMA_BeginPainting( void ) {\n\tint\t\treps;\n\tDWORD\tdwSize2;\n\tDWORD\t*pbuf, *pbuf2;\n\tHRESULT\thresult;\n\tDWORD\tdwStatus;\n\n\tif ( !pDSBuf ) {\n\t\treturn;\n\t}\n\n\t// if the buffer was lost or stopped, restore it and/or restart it\n\tif ( pDSBuf->lpVtbl->GetStatus (pDSBuf, &dwStatus) != DS_OK ) {\n\t\tCom_Printf (\"Couldn't get sound buffer status\\n\");\n\t}\n\t\n\tif (dwStatus & DSBSTATUS_BUFFERLOST)\n\t\tpDSBuf->lpVtbl->Restore (pDSBuf);\n\t\n\tif (!(dwStatus & DSBSTATUS_PLAYING))\n\t\tpDSBuf->lpVtbl->Play(pDSBuf, 0, 0, DSBPLAY_LOOPING);\n\n\t// lock the dsound buffer\n\n\treps = 0;\n\tdma.buffer = NULL;\n\n\twhile ((hresult = pDSBuf->lpVtbl->Lock(pDSBuf, 0, gSndBufSize, &pbuf, &locksize, \n\t\t\t\t\t\t\t\t   &pbuf2, &dwSize2, 0)) != DS_OK)\n\t{\n\t\tif (hresult != DSERR_BUFFERLOST)\n\t\t{\n\t\t\tCom_Printf( \"SNDDMA_BeginPainting: Lock failed with error '%s'\\n\", DSoundError( hresult ) );\n\t\t\tS_Shutdown ();\n\t\t\treturn;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tpDSBuf->lpVtbl->Restore( pDSBuf );\n\t\t}\n\n\t\tif (++reps > 2)\n\t\t\treturn;\n\t}\n\tdma.buffer = (unsigned char *)pbuf;\n}\n\n/*\n==============\nSNDDMA_Submit\n\nSend sound to device if buffer isn't really the dma buffer\nAlso unlocks the dsound buffer\n===============\n*/\nvoid SNDDMA_Submit( void ) {\n    // unlock the dsound buffer\n\tif ( pDSBuf ) {\n\t\tpDSBuf->lpVtbl->Unlock(pDSBuf, dma.buffer, locksize, NULL, 0);\n\t}\n}\n\n\n/*\n=================\nSNDDMA_Activate\n\nWhen we change windows we need to do this\n=================\n*/\nvoid SNDDMA_Activate( void ) {\n\tif ( !pDS ) {\n\t\treturn;\n\t}\n\n\tif ( DS_OK != pDS->lpVtbl->SetCooperativeLevel( pDS, g_wv.hWnd, DSSCL_PRIORITY ) )\t{\n\t\tCom_Printf (\"sound SetCooperativeLevel failed\\n\");\n\t\tSNDDMA_Shutdown ();\n\t}\n}\n\n\n"
  },
  {
    "path": "code/win32/win_syscon.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// win_syscon.h\n#include \"../client/client.h\"\n#include \"win_local.h\"\n#include \"resource.h\"\n#include <errno.h>\n#include <float.h>\n#include <fcntl.h>\n#include <stdio.h>\n#include <direct.h>\n#include <io.h>\n#include <conio.h>\n\n#define COPY_ID\t\t\t1\n#define QUIT_ID\t\t\t2\n#define CLEAR_ID\t\t3\n\n#define ERRORBOX_ID\t\t10\n#define ERRORTEXT_ID\t11\n\n#define EDIT_ID\t\t\t100\n#define INPUT_ID\t\t101\n\ntypedef struct\n{\n\tHWND\t\thWnd;\n\tHWND\t\thwndBuffer;\n\n\tHWND\t\thwndButtonClear;\n\tHWND\t\thwndButtonCopy;\n\tHWND\t\thwndButtonQuit;\n\n\tHWND\t\thwndErrorBox;\n\tHWND\t\thwndErrorText;\n\n\tHBITMAP\t\thbmLogo;\n\tHBITMAP\t\thbmClearBitmap;\n\n\tHBRUSH\t\thbrEditBackground;\n\tHBRUSH\t\thbrErrorBackground;\n\n\tHFONT\t\thfBufferFont;\n\tHFONT\t\thfButtonFont;\n\n\tHWND\t\thwndInputLine;\n\n\tchar\t\terrorString[80];\n\n\tchar\t\tconsoleText[512], returnedText[512];\n\tint\t\t\tvisLevel;\n\tqboolean\tquitOnClose;\n\tint\t\t\twindowWidth, windowHeight;\n\t\n\tWNDPROC\t\tSysInputLineWndProc;\n\n} WinConData;\n\nstatic WinConData s_wcd;\n\nstatic LONG WINAPI ConWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\n{\n\tchar *cmdString;\n\tstatic qboolean s_timePolarity;\n\n\tswitch (uMsg)\n\t{\n\tcase WM_ACTIVATE:\n\t\tif ( LOWORD( wParam ) != WA_INACTIVE )\n\t\t{\n\t\t\tSetFocus( s_wcd.hwndInputLine );\n\t\t}\n\n\t\tif ( com_viewlog && ( com_dedicated && !com_dedicated->integer ) )\n\t\t{\n\t\t\t// if the viewlog is open, check to see if it's being minimized\n\t\t\tif ( com_viewlog->integer == 1 )\n\t\t\t{\n\t\t\t\tif ( HIWORD( wParam ) )\t\t// minimized flag\n\t\t\t\t{\n\t\t\t\t\tCvar_Set( \"viewlog\", \"2\" );\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ( com_viewlog->integer == 2 )\n\t\t\t{\n\t\t\t\tif ( !HIWORD( wParam ) )\t\t// minimized flag\n\t\t\t\t{\n\t\t\t\t\tCvar_Set( \"viewlog\", \"1\" );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n\tcase WM_CLOSE:\n\t\tif ( ( com_dedicated && com_dedicated->integer ) )\n\t\t{\n\t\t\tcmdString = CopyString( \"quit\" );\n\t\t\tSys_QueEvent( 0, SE_CONSOLE, 0, 0, strlen( cmdString ) + 1, cmdString );\n\t\t}\n\t\telse if ( s_wcd.quitOnClose )\n\t\t{\n\t\t\tPostQuitMessage( 0 );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tSys_ShowConsole( 0, qfalse );\n\t\t\tCvar_Set( \"viewlog\", \"0\" );\n\t\t}\n\t\treturn 0;\n\tcase WM_CTLCOLORSTATIC:\n\t\tif ( ( HWND ) lParam == s_wcd.hwndBuffer )\n\t\t{\n\t\t\tSetBkColor( ( HDC ) wParam, RGB( 0x00, 0x00, 0xB0 ) );\n\t\t\tSetTextColor( ( HDC ) wParam, RGB( 0xff, 0xff, 0x00 ) );\n\n#if 0\t// this draws a background in the edit box, but there are issues with this\n\t\t\tif ( ( hdcScaled = CreateCompatibleDC( ( HDC ) wParam ) ) != 0 )\n\t\t\t{\n\t\t\t\tif ( SelectObject( ( HDC ) hdcScaled, s_wcd.hbmLogo ) )\n\t\t\t\t{\n\t\t\t\t\tStretchBlt( ( HDC ) wParam, 0, 0, 512, 384, \n\t\t\t\t\t\t\thdcScaled, 0, 0, 512, 384,\n\t\t\t\t\t\t\tSRCCOPY );\n\t\t\t\t}\n\t\t\t\tDeleteDC( hdcScaled );\n\t\t\t}\n#endif\n\t\t\treturn ( long ) s_wcd.hbrEditBackground;\n\t\t}\n\t\telse if ( ( HWND ) lParam == s_wcd.hwndErrorBox )\n\t\t{\n\t\t\tif ( s_timePolarity & 1 )\n\t\t\t{\n\t\t\t\tSetBkColor( ( HDC ) wParam, RGB( 0x80, 0x80, 0x80 ) );\n\t\t\t\tSetTextColor( ( HDC ) wParam, RGB( 0xff, 0x0, 0x00 ) );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tSetBkColor( ( HDC ) wParam, RGB( 0x80, 0x80, 0x80 ) );\n\t\t\t\tSetTextColor( ( HDC ) wParam, RGB( 0x00, 0x0, 0x00 ) );\n\t\t\t}\n\t\t\treturn ( long ) s_wcd.hbrErrorBackground;\n\t\t}\n\t\tbreak;\n\n\tcase WM_COMMAND:\n\t\tif ( wParam == COPY_ID )\n\t\t{\n\t\t\tSendMessage( s_wcd.hwndBuffer, EM_SETSEL, 0, -1 );\n\t\t\tSendMessage( s_wcd.hwndBuffer, WM_COPY, 0, 0 );\n\t\t}\n\t\telse if ( wParam == QUIT_ID )\n\t\t{\n\t\t\tif ( s_wcd.quitOnClose )\n\t\t\t{\n\t\t\t\tPostQuitMessage( 0 );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcmdString = CopyString( \"quit\" );\n\t\t\t\tSys_QueEvent( 0, SE_CONSOLE, 0, 0, strlen( cmdString ) + 1, cmdString );\n\t\t\t}\n\t\t}\n\t\telse if ( wParam == CLEAR_ID )\n\t\t{\n\t\t\tSendMessage( s_wcd.hwndBuffer, EM_SETSEL, 0, -1 );\n\t\t\tSendMessage( s_wcd.hwndBuffer, EM_REPLACESEL, FALSE, ( LPARAM ) \"\" );\n\t\t\tUpdateWindow( s_wcd.hwndBuffer );\n\t\t}\n\t\tbreak;\n\tcase WM_CREATE:\n//\t\ts_wcd.hbmLogo = LoadBitmap( g_wv.hInstance, MAKEINTRESOURCE( IDB_BITMAP1 ) );\n//\t\ts_wcd.hbmClearBitmap = LoadBitmap( g_wv.hInstance, MAKEINTRESOURCE( IDB_BITMAP2 ) );\n\t\ts_wcd.hbrEditBackground = CreateSolidBrush( RGB( 0x00, 0x00, 0xB0 ) );\n\t\ts_wcd.hbrErrorBackground = CreateSolidBrush( RGB( 0x80, 0x80, 0x80 ) );\n\t\tSetTimer( hWnd, 1, 1000, NULL );\n\t\tbreak;\n\tcase WM_ERASEBKGND:\n#if 0\n\tHDC hdcScaled;\n\tHGDIOBJ oldObject;\n\n#if 1\t// a single, large image\n\t\thdcScaled = CreateCompatibleDC( ( HDC ) wParam );\n\t\tassert( hdcScaled != 0 );\n\n\t\tif ( hdcScaled )\n\t\t{\n\t\t\toldObject = SelectObject( ( HDC ) hdcScaled, s_wcd.hbmLogo );\n\t\t\tassert( oldObject != 0 );\n\t\t\tif ( oldObject )\n\t\t\t{\n\t\t\t\tStretchBlt( ( HDC ) wParam, 0, 0, s_wcd.windowWidth, s_wcd.windowHeight, \n\t\t\t\t\t\thdcScaled, 0, 0, 512, 384,\n\t\t\t\t\t\tSRCCOPY );\n\t\t\t}\n\t\t\tDeleteDC( hdcScaled );\n\t\t\thdcScaled = 0;\n\t\t}\n#else\t// a repeating brush\n\t\t{\n\t\t\tHBRUSH hbrClearBrush;\n\t\t\tRECT r;\n\n\t\t\tGetWindowRect( hWnd, &r );\n\n\t\t\tr.bottom = r.bottom - r.top + 1;\n\t\t\tr.right = r.right - r.left + 1;\n\t\t\tr.top = 0;\n\t\t\tr.left = 0;\n\n\t\t\thbrClearBrush = CreatePatternBrush( s_wcd.hbmClearBitmap );\n\n\t\t\tassert( hbrClearBrush != 0 );\n\n\t\t\tif ( hbrClearBrush )\n\t\t\t{\n\t\t\t\tFillRect( ( HDC ) wParam, &r, hbrClearBrush );\n\t\t\t\tDeleteObject( hbrClearBrush );\n\t\t\t}\n\t\t}\n#endif\n\t\treturn 1;\n#endif\n\t    return DefWindowProc( hWnd, uMsg, wParam, lParam );\n\tcase WM_TIMER:\n\t\tif ( wParam == 1 )\n\t\t{\n\t\t\ts_timePolarity = !s_timePolarity;\n\t\t\tif ( s_wcd.hwndErrorBox )\n\t\t\t{\n\t\t\t\tInvalidateRect( s_wcd.hwndErrorBox, NULL, FALSE );\n\t\t\t}\n\t\t}\n\t\tbreak;\n    }\n\n    return DefWindowProc( hWnd, uMsg, wParam, lParam );\n}\n\nLONG WINAPI InputLineWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\n{\n\tchar inputBuffer[1024];\n\n\tswitch ( uMsg )\n\t{\n\tcase WM_KILLFOCUS:\n\t\tif ( ( HWND ) wParam == s_wcd.hWnd ||\n\t\t\t ( HWND ) wParam == s_wcd.hwndErrorBox )\n\t\t{\n\t\t\tSetFocus( hWnd );\n\t\t\treturn 0;\n\t\t}\n\t\tbreak;\n\n\tcase WM_CHAR:\n\t\tif ( wParam == 13 )\n\t\t{\n\t\t\tGetWindowText( s_wcd.hwndInputLine, inputBuffer, sizeof( inputBuffer ) );\n\t\t\tstrncat( s_wcd.consoleText, inputBuffer, sizeof( s_wcd.consoleText ) - strlen( s_wcd.consoleText ) - 5 );\n\t\t\tstrcat( s_wcd.consoleText, \"\\n\" );\n\t\t\tSetWindowText( s_wcd.hwndInputLine, \"\" );\n\n\t\t\tSys_Print( va( \"]%s\\n\", inputBuffer ) );\n\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\treturn CallWindowProc( s_wcd.SysInputLineWndProc, hWnd, uMsg, wParam, lParam );\n}\n\n/*\n** Sys_CreateConsole\n*/\nvoid Sys_CreateConsole( void )\n{\n\tHDC hDC;\n\tWNDCLASS wc;\n\tRECT rect;\n\tconst char *DEDCLASS = \"Q3 WinConsole\";\n\tint nHeight;\n\tint swidth, sheight;\n\tint DEDSTYLE = WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX;\n\n\tmemset( &wc, 0, sizeof( wc ) );\n\n\twc.style         = 0;\n\twc.lpfnWndProc   = (WNDPROC) ConWndProc;\n\twc.cbClsExtra    = 0;\n\twc.cbWndExtra    = 0;\n\twc.hInstance     = g_wv.hInstance;\n\twc.hIcon         = LoadIcon( g_wv.hInstance, MAKEINTRESOURCE(IDI_ICON1));\n\twc.hCursor       = LoadCursor (NULL,IDC_ARROW);\n\twc.hbrBackground = (void *)COLOR_WINDOW;\n\twc.lpszMenuName  = 0;\n\twc.lpszClassName = DEDCLASS;\n\n\tif ( !RegisterClass (&wc) )\n\t\treturn;\n\n\trect.left = 0;\n\trect.right = 540;\n\trect.top = 0;\n\trect.bottom = 450;\n\tAdjustWindowRect( &rect, DEDSTYLE, FALSE );\n\n\thDC = GetDC( GetDesktopWindow() );\n\tswidth = GetDeviceCaps( hDC, HORZRES );\n\tsheight = GetDeviceCaps( hDC, VERTRES );\n\tReleaseDC( GetDesktopWindow(), hDC );\n\n\ts_wcd.windowWidth = rect.right - rect.left + 1;\n\ts_wcd.windowHeight = rect.bottom - rect.top + 1;\n\n\ts_wcd.hWnd = CreateWindowEx( 0,\n\t\t\t\t\t\t\t   DEDCLASS,\n\t\t\t\t\t\t\t   \"Quake 3 Console\",\n\t\t\t\t\t\t\t   DEDSTYLE,\n\t\t\t\t\t\t\t   ( swidth - 600 ) / 2, ( sheight - 450 ) / 2 , rect.right - rect.left + 1, rect.bottom - rect.top + 1,\n\t\t\t\t\t\t\t   NULL,\n\t\t\t\t\t\t\t   NULL,\n\t\t\t\t\t\t\t   g_wv.hInstance,\n\t\t\t\t\t\t\t   NULL );\n\n\tif ( s_wcd.hWnd == NULL )\n\t{\n\t\treturn;\n\t}\n\n\t//\n\t// create fonts\n\t//\n\thDC = GetDC( s_wcd.hWnd );\n\tnHeight = -MulDiv( 8, GetDeviceCaps( hDC, LOGPIXELSY), 72);\n\n\ts_wcd.hfBufferFont = CreateFont( nHeight,\n\t\t\t\t\t\t\t\t\t  0,\n\t\t\t\t\t\t\t\t\t  0,\n\t\t\t\t\t\t\t\t\t  0,\n\t\t\t\t\t\t\t\t\t  FW_LIGHT,\n\t\t\t\t\t\t\t\t\t  0,\n\t\t\t\t\t\t\t\t\t  0,\n\t\t\t\t\t\t\t\t\t  0,\n\t\t\t\t\t\t\t\t\t  DEFAULT_CHARSET,\n\t\t\t\t\t\t\t\t\t  OUT_DEFAULT_PRECIS,\n\t\t\t\t\t\t\t\t\t  CLIP_DEFAULT_PRECIS,\n\t\t\t\t\t\t\t\t\t  DEFAULT_QUALITY,\n\t\t\t\t\t\t\t\t\t  FF_MODERN | FIXED_PITCH,\n\t\t\t\t\t\t\t\t\t  \"Courier New\" );\n\n\tReleaseDC( s_wcd.hWnd, hDC );\n\n\t//\n\t// create the input line\n\t//\n\ts_wcd.hwndInputLine = CreateWindow( \"edit\", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | \n\t\t\t\t\t\t\t\t\t\t\t\tES_LEFT | ES_AUTOHSCROLL,\n\t\t\t\t\t\t\t\t\t\t\t\t6, 400, 528, 20,\n\t\t\t\t\t\t\t\t\t\t\t\ts_wcd.hWnd, \n\t\t\t\t\t\t\t\t\t\t\t\t( HMENU ) INPUT_ID,\t// child window ID\n\t\t\t\t\t\t\t\t\t\t\t\tg_wv.hInstance, NULL );\n\n\t//\n\t// create the buttons\n\t//\n\ts_wcd.hwndButtonCopy = CreateWindow( \"button\", NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,\n\t\t\t\t\t\t\t\t\t\t\t\t5, 425, 72, 24,\n\t\t\t\t\t\t\t\t\t\t\t\ts_wcd.hWnd, \n\t\t\t\t\t\t\t\t\t\t\t\t( HMENU ) COPY_ID,\t// child window ID\n\t\t\t\t\t\t\t\t\t\t\t\tg_wv.hInstance, NULL );\n\tSendMessage( s_wcd.hwndButtonCopy, WM_SETTEXT, 0, ( LPARAM ) \"copy\" );\n\n\ts_wcd.hwndButtonClear = CreateWindow( \"button\", NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,\n\t\t\t\t\t\t\t\t\t\t\t\t82, 425, 72, 24,\n\t\t\t\t\t\t\t\t\t\t\t\ts_wcd.hWnd, \n\t\t\t\t\t\t\t\t\t\t\t\t( HMENU ) CLEAR_ID,\t// child window ID\n\t\t\t\t\t\t\t\t\t\t\t\tg_wv.hInstance, NULL );\n\tSendMessage( s_wcd.hwndButtonClear, WM_SETTEXT, 0, ( LPARAM ) \"clear\" );\n\n\ts_wcd.hwndButtonQuit = CreateWindow( \"button\", NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,\n\t\t\t\t\t\t\t\t\t\t\t\t462, 425, 72, 24,\n\t\t\t\t\t\t\t\t\t\t\t\ts_wcd.hWnd, \n\t\t\t\t\t\t\t\t\t\t\t\t( HMENU ) QUIT_ID,\t// child window ID\n\t\t\t\t\t\t\t\t\t\t\t\tg_wv.hInstance, NULL );\n\tSendMessage( s_wcd.hwndButtonQuit, WM_SETTEXT, 0, ( LPARAM ) \"quit\" );\n\n\n\t//\n\t// create the scrollbuffer\n\t//\n\ts_wcd.hwndBuffer = CreateWindow( \"edit\", NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER | \n\t\t\t\t\t\t\t\t\t\t\t\tES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY,\n\t\t\t\t\t\t\t\t\t\t\t\t6, 40, 526, 354,\n\t\t\t\t\t\t\t\t\t\t\t\ts_wcd.hWnd, \n\t\t\t\t\t\t\t\t\t\t\t\t( HMENU ) EDIT_ID,\t// child window ID\n\t\t\t\t\t\t\t\t\t\t\t\tg_wv.hInstance, NULL );\n\tSendMessage( s_wcd.hwndBuffer, WM_SETFONT, ( WPARAM ) s_wcd.hfBufferFont, 0 );\n\n\ts_wcd.SysInputLineWndProc = ( WNDPROC ) SetWindowLong( s_wcd.hwndInputLine, GWL_WNDPROC, ( long ) InputLineWndProc );\n\tSendMessage( s_wcd.hwndInputLine, WM_SETFONT, ( WPARAM ) s_wcd.hfBufferFont, 0 );\n\n\tShowWindow( s_wcd.hWnd, SW_SHOWDEFAULT);\n\tUpdateWindow( s_wcd.hWnd );\n\tSetForegroundWindow( s_wcd.hWnd );\n\tSetFocus( s_wcd.hwndInputLine );\n\n\ts_wcd.visLevel = 1;\n}\n\n/*\n** Sys_DestroyConsole\n*/\nvoid Sys_DestroyConsole( void ) {\n\tif ( s_wcd.hWnd ) {\n\t\tShowWindow( s_wcd.hWnd, SW_HIDE );\n\t\tCloseWindow( s_wcd.hWnd );\n\t\tDestroyWindow( s_wcd.hWnd );\n\t\ts_wcd.hWnd = 0;\n\t}\n}\n\n/*\n** Sys_ShowConsole\n*/\nvoid Sys_ShowConsole( int visLevel, qboolean quitOnClose )\n{\n\ts_wcd.quitOnClose = quitOnClose;\n\n\tif ( visLevel == s_wcd.visLevel )\n\t{\n\t\treturn;\n\t}\n\n\ts_wcd.visLevel = visLevel;\n\n\tif ( !s_wcd.hWnd )\n\t\treturn;\n\n\tswitch ( visLevel )\n\t{\n\tcase 0:\n\t\tShowWindow( s_wcd.hWnd, SW_HIDE );\n\t\tbreak;\n\tcase 1:\n\t\tShowWindow( s_wcd.hWnd, SW_SHOWNORMAL );\n\t\tSendMessage( s_wcd.hwndBuffer, EM_LINESCROLL, 0, 0xffff );\n\t\tbreak;\n\tcase 2:\n\t\tShowWindow( s_wcd.hWnd, SW_MINIMIZE );\n\t\tbreak;\n\tdefault:\n\t\tSys_Error( \"Invalid visLevel %d sent to Sys_ShowConsole\\n\", visLevel );\n\t\tbreak;\n\t}\n}\n\n/*\n** Sys_ConsoleInput\n*/\nchar *Sys_ConsoleInput( void )\n{\n\tif ( s_wcd.consoleText[0] == 0 )\n\t{\n\t\treturn NULL;\n\t}\n\t\t\n\tstrcpy( s_wcd.returnedText, s_wcd.consoleText );\n\ts_wcd.consoleText[0] = 0;\n\t\n\treturn s_wcd.returnedText;\n}\n\n/*\n** Conbuf_AppendText\n*/\nvoid Conbuf_AppendText( const char *pMsg )\n{\n#define CONSOLE_BUFFER_SIZE\t\t16384\n\n\tchar buffer[CONSOLE_BUFFER_SIZE*2];\n\tchar *b = buffer;\n\tconst char *msg;\n\tint bufLen;\n\tint i = 0;\n\tstatic unsigned long s_totalChars;\n\n\t//\n\t// if the message is REALLY long, use just the last portion of it\n\t//\n\tif ( strlen( pMsg ) > CONSOLE_BUFFER_SIZE - 1 )\n\t{\n\t\tmsg = pMsg + strlen( pMsg ) - CONSOLE_BUFFER_SIZE + 1;\n\t}\n\telse\n\t{\n\t\tmsg = pMsg;\n\t}\n\n\t//\n\t// copy into an intermediate buffer\n\t//\n\twhile ( msg[i] && ( ( b - buffer ) < sizeof( buffer ) - 1 ) )\n\t{\n\t\tif ( msg[i] == '\\n' && msg[i+1] == '\\r' )\n\t\t{\n\t\t\tb[0] = '\\r';\n\t\t\tb[1] = '\\n';\n\t\t\tb += 2;\n\t\t\ti++;\n\t\t}\n\t\telse if ( msg[i] == '\\r' )\n\t\t{\n\t\t\tb[0] = '\\r';\n\t\t\tb[1] = '\\n';\n\t\t\tb += 2;\n\t\t}\n\t\telse if ( msg[i] == '\\n' )\n\t\t{\n\t\t\tb[0] = '\\r';\n\t\t\tb[1] = '\\n';\n\t\t\tb += 2;\n\t\t}\n\t\telse if ( Q_IsColorString( &msg[i] ) )\n\t\t{\n\t\t\ti++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t*b= msg[i];\n\t\t\tb++;\n\t\t}\n\t\ti++;\n\t}\n\t*b = 0;\n\tbufLen = b - buffer;\n\n\ts_totalChars += bufLen;\n\n\t//\n\t// replace selection instead of appending if we're overflowing\n\t//\n\tif ( s_totalChars > 0x7fff )\n\t{\n\t\tSendMessage( s_wcd.hwndBuffer, EM_SETSEL, 0, -1 );\n\t\ts_totalChars = bufLen;\n\t}\n\n\t//\n\t// put this text into the windows console\n\t//\n\tSendMessage( s_wcd.hwndBuffer, EM_LINESCROLL, 0, 0xffff );\n\tSendMessage( s_wcd.hwndBuffer, EM_SCROLLCARET, 0, 0 );\n\tSendMessage( s_wcd.hwndBuffer, EM_REPLACESEL, 0, (LPARAM) buffer );\n}\n\n/*\n** Sys_SetErrorText\n*/\nvoid Sys_SetErrorText( const char *buf )\n{\n\tQ_strncpyz( s_wcd.errorString, buf, sizeof( s_wcd.errorString ) );\n\n\tif ( !s_wcd.hwndErrorBox )\n\t{\n\t\ts_wcd.hwndErrorBox = CreateWindow( \"static\", NULL, WS_CHILD | WS_VISIBLE | SS_SUNKEN,\n\t\t\t\t\t\t\t\t\t\t\t\t\t6, 5, 526, 30,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts_wcd.hWnd, \n\t\t\t\t\t\t\t\t\t\t\t\t\t( HMENU ) ERRORBOX_ID,\t// child window ID\n\t\t\t\t\t\t\t\t\t\t\t\t\tg_wv.hInstance, NULL );\n\t\tSendMessage( s_wcd.hwndErrorBox, WM_SETFONT, ( WPARAM ) s_wcd.hfBufferFont, 0 );\n\t\tSetWindowText( s_wcd.hwndErrorBox, s_wcd.errorString );\n\n\t\tDestroyWindow( s_wcd.hwndInputLine );\n\t\ts_wcd.hwndInputLine = NULL;\n\t}\n}\n"
  },
  {
    "path": "code/win32/win_wndproc.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"../client/client.h\"\n#include \"win_local.h\"\n\nWinVars_t\tg_wv;\n\n#ifndef WM_MOUSEWHEEL\n#define WM_MOUSEWHEEL (WM_MOUSELAST+1)  // message that will be supported by the OS \n#endif\n\nstatic UINT MSH_MOUSEWHEEL;\n\n// Console variables that we need to access from this module\ncvar_t\t\t*vid_xpos;\t\t\t// X coordinate of window position\ncvar_t\t\t*vid_ypos;\t\t\t// Y coordinate of window position\ncvar_t\t\t*r_fullscreen;\n\n#define VID_NUM_MODES ( sizeof( vid_modes ) / sizeof( vid_modes[0] ) )\n\nLONG WINAPI MainWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );\n\nstatic qboolean s_alttab_disabled;\n\nstatic void WIN_DisableAltTab( void )\n{\n\tif ( s_alttab_disabled )\n\t\treturn;\n\n\tif ( !Q_stricmp( Cvar_VariableString( \"arch\" ), \"winnt\" ) )\n\t{\n\t\tRegisterHotKey( 0, 0, MOD_ALT, VK_TAB );\n\t}\n\telse\n\t{\n\t\tBOOL old;\n\n\t\tSystemParametersInfo( SPI_SCREENSAVERRUNNING, 1, &old, 0 );\n\t}\n\ts_alttab_disabled = qtrue;\n}\n\nstatic void WIN_EnableAltTab( void )\n{\n\tif ( s_alttab_disabled )\n\t{\n\t\tif ( !Q_stricmp( Cvar_VariableString( \"arch\" ), \"winnt\" ) )\n\t\t{\n\t\t\tUnregisterHotKey( 0, 0 );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tBOOL old;\n\n\t\t\tSystemParametersInfo( SPI_SCREENSAVERRUNNING, 0, &old, 0 );\n\t\t}\n\n\t\ts_alttab_disabled = qfalse;\n\t}\n}\n\n/*\n==================\nVID_AppActivate\n==================\n*/\nstatic void VID_AppActivate(BOOL fActive, BOOL minimize)\n{\n\tg_wv.isMinimized = minimize;\n\n\tCom_DPrintf(\"VID_AppActivate: %i\\n\", fActive );\n\n\tKey_ClearStates();\t// FIXME!!!\n\n\t// we don't want to act like we're active if we're minimized\n\tif (fActive && !g_wv.isMinimized )\n\t{\n\t\tg_wv.activeApp = qtrue;\n\t}\n\telse\n\t{\n\t\tg_wv.activeApp = qfalse;\n\t}\n\n\t// minimize/restore mouse-capture on demand\n\tif (!g_wv.activeApp )\n\t{\n\t\tIN_Activate (qfalse);\n\t}\n\telse\n\t{\n\t\tIN_Activate (qtrue);\n\t}\n}\n\n//==========================================================================\n\nstatic byte s_scantokey[128] = \n\t\t\t\t\t{ \n//  0           1       2       3       4       5       6       7 \n//  8           9       A       B       C       D       E       F \n\t0  ,    27,     '1',    '2',    '3',    '4',    '5',    '6', \n\t'7',    '8',    '9',    '0',    '-',    '=',    K_BACKSPACE, 9, // 0 \n\t'q',    'w',    'e',    'r',    't',    'y',    'u',    'i', \n\t'o',    'p',    '[',    ']',    13 ,    K_CTRL,'a',  's',      // 1 \n\t'd',    'f',    'g',    'h',    'j',    'k',    'l',    ';', \n\t'\\'' ,    '`',    K_SHIFT,'\\\\',  'z',    'x',    'c',    'v',      // 2 \n\t'b',    'n',    'm',    ',',    '.',    '/',    K_SHIFT,'*', \n\tK_ALT,' ',   K_CAPSLOCK  ,    K_F1, K_F2, K_F3, K_F4, K_F5,   // 3 \n\tK_F6, K_F7, K_F8, K_F9, K_F10,  K_PAUSE,    0  , K_HOME, \n\tK_UPARROW,K_PGUP,K_KP_MINUS,K_LEFTARROW,K_KP_5,K_RIGHTARROW, K_KP_PLUS,K_END, //4 \n\tK_DOWNARROW,K_PGDN,K_INS,K_DEL,0,0,             0,              K_F11, \n\tK_F12,0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0,        // 5\n\t0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0, \n\t0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0,        // 6 \n\t0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0, \n\t0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0  ,    0         // 7 \n}; \n\n/*\n=======\nMapKey\n\nMap from windows to quake keynums\n=======\n*/\nstatic int MapKey (int key)\n{\n\tint result;\n\tint modified;\n\tqboolean is_extended;\n\n//\tCom_Printf( \"0x%x\\n\", key);\n\n\tmodified = ( key >> 16 ) & 255;\n\n\tif ( modified > 127 )\n\t\treturn 0;\n\n\tif ( key & ( 1 << 24 ) )\n\t{\n\t\tis_extended = qtrue;\n\t}\n\telse\n\t{\n\t\tis_extended = qfalse;\n\t}\n\n\tresult = s_scantokey[modified];\n\n\tif ( !is_extended )\n\t{\n\t\tswitch ( result )\n\t\t{\n\t\tcase K_HOME:\n\t\t\treturn K_KP_HOME;\n\t\tcase K_UPARROW:\n\t\t\treturn K_KP_UPARROW;\n\t\tcase K_PGUP:\n\t\t\treturn K_KP_PGUP;\n\t\tcase K_LEFTARROW:\n\t\t\treturn K_KP_LEFTARROW;\n\t\tcase K_RIGHTARROW:\n\t\t\treturn K_KP_RIGHTARROW;\n\t\tcase K_END:\n\t\t\treturn K_KP_END;\n\t\tcase K_DOWNARROW:\n\t\t\treturn K_KP_DOWNARROW;\n\t\tcase K_PGDN:\n\t\t\treturn K_KP_PGDN;\n\t\tcase K_INS:\n\t\t\treturn K_KP_INS;\n\t\tcase K_DEL:\n\t\t\treturn K_KP_DEL;\n\t\tdefault:\n\t\t\treturn result;\n\t\t}\n\t}\n\telse\n\t{\n\t\tswitch ( result )\n\t\t{\n\t\tcase K_PAUSE:\n\t\t\treturn K_KP_NUMLOCK;\n\t\tcase 0x0D:\n\t\t\treturn K_KP_ENTER;\n\t\tcase 0x2F:\n\t\t\treturn K_KP_SLASH;\n\t\tcase 0xAF:\n\t\t\treturn K_KP_PLUS;\n\t\t}\n\t\treturn result;\n\t}\n}\n\n\n/*\n====================\nMainWndProc\n\nmain window procedure\n====================\n*/\nextern cvar_t *in_mouse;\nextern cvar_t *in_logitechbug;\nLONG WINAPI MainWndProc (\n    HWND    hWnd,\n    UINT    uMsg,\n    WPARAM  wParam,\n    LPARAM  lParam)\n{\n\tstatic qboolean flip = qtrue;\n\tint zDelta, i;\n\n\t// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/mouseinput/aboutmouseinput.asp\n\t// Windows 95, Windows NT 3.51 - uses MSH_MOUSEWHEEL\n\t// only relevant for non-DI input\n\t//\n\t// NOTE: not sure how reliable this is anymore, might trigger double wheel events\n\tif (in_mouse->integer != 1)\n\t{\n\t\tif ( uMsg == MSH_MOUSEWHEEL )\n\t\t{\n\t\t\tif ( ( ( int ) wParam ) > 0 )\n\t\t\t{\n\t\t\t\tSys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELUP, qtrue, 0, NULL );\n\t\t\t\tSys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELUP, qfalse, 0, NULL );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tSys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELDOWN, qtrue, 0, NULL );\n\t\t\t\tSys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELDOWN, qfalse, 0, NULL );\n\t\t\t}\n\t\t\treturn DefWindowProc (hWnd, uMsg, wParam, lParam);\n\t\t}\n\t}\n\n\tswitch (uMsg)\n\t{\n\tcase WM_MOUSEWHEEL:\n\t\t// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/mouseinput/aboutmouseinput.asp\n\t\t// Windows 98/Me, Windows NT 4.0 and later - uses WM_MOUSEWHEEL\n\t\t// only relevant for non-DI input and when console is toggled in window mode\n\t\t//   if console is toggled in window mode (KEYCATCH_CONSOLE) then mouse is released and DI doesn't see any mouse wheel\n\t\tif (in_mouse->integer != 1 || (!r_fullscreen->integer && (cls.keyCatchers & KEYCATCH_CONSOLE)))\n\t\t{\n\t\t\t// 120 increments, might be 240 and multiples if wheel goes too fast\n\t\t\t// NOTE Logitech: logitech drivers are screwed and send the message twice?\n\t\t\t//   could add a cvar to interpret the message as successive press/release events\n\t\t\tzDelta = ( short ) HIWORD( wParam ) / 120;\n\t\t\tif ( zDelta > 0 )\n\t\t\t{\n\t\t\t\tfor(i=0; i<zDelta; i++)\n\t\t\t\t{\n\t\t\t\t\tif (!in_logitechbug->integer)\n\t\t\t\t\t{\n\t\t\t\t\t\tSys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELUP, qtrue, 0, NULL );\n\t\t\t\t\t\tSys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELUP, qfalse, 0, NULL );\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tSys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELUP, flip, 0, NULL );\n\t\t\t\t\t\tflip = !flip;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfor(i=0; i<-zDelta; i++)\n\t\t\t\t{\n\t\t\t\t\tif (!in_logitechbug->integer)\n\t\t\t\t\t{\n\t\t\t\t\t\tSys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELDOWN, qtrue, 0, NULL );\n\t\t\t\t\t\tSys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELDOWN, qfalse, 0, NULL );\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tSys_QueEvent( g_wv.sysMsgTime, SE_KEY, K_MWHEELDOWN, flip, 0, NULL );\n\t\t\t\t\t\tflip = !flip;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t// when an application processes the WM_MOUSEWHEEL message, it must return zero\n\t\t\treturn 0;\n\t\t}\n\t\tbreak;\n\n\tcase WM_CREATE:\n\n\t\tg_wv.hWnd = hWnd;\n\n\t\tvid_xpos = Cvar_Get (\"vid_xpos\", \"3\", CVAR_ARCHIVE);\n\t\tvid_ypos = Cvar_Get (\"vid_ypos\", \"22\", CVAR_ARCHIVE);\n\t\tr_fullscreen = Cvar_Get (\"r_fullscreen\", \"1\", CVAR_ARCHIVE | CVAR_LATCH );\n\n\t\tMSH_MOUSEWHEEL = RegisterWindowMessage(\"MSWHEEL_ROLLMSG\"); \n\t\tif ( r_fullscreen->integer )\n\t\t{\n\t\t\tWIN_DisableAltTab();\n\t\t}\n\t\telse\n\t\t{\n\t\t\tWIN_EnableAltTab();\n\t\t}\n\n\t\tbreak;\n#if 0\n\tcase WM_DISPLAYCHANGE:\n\t\tCom_DPrintf( \"WM_DISPLAYCHANGE\\n\" );\n\t\t// we need to force a vid_restart if the user has changed\n\t\t// their desktop resolution while the game is running,\n\t\t// but don't do anything if the message is a result of\n\t\t// our own calling of ChangeDisplaySettings\n\t\tif ( com_insideVidInit ) {\n\t\t\tbreak;\t\t// we did this on purpose\n\t\t}\n\t\t// something else forced a mode change, so restart all our gl stuff\n\t\tCbuf_AddText( \"vid_restart\\n\" );\n\t\tbreak;\n#endif\n\tcase WM_DESTROY:\n\t\t// let sound and input know about this?\n\t\tg_wv.hWnd = NULL;\n\t\tif ( r_fullscreen->integer )\n\t\t{\n\t\t\tWIN_EnableAltTab();\n\t\t}\n\t\tbreak;\n\n\tcase WM_CLOSE:\n\t\tCbuf_ExecuteText( EXEC_APPEND, \"quit\" );\n\t\tbreak;\n\n\tcase WM_ACTIVATE:\n\t\t{\n\t\t\tint\tfActive, fMinimized;\n\n\t\t\tfActive = LOWORD(wParam);\n\t\t\tfMinimized = (BOOL) HIWORD(wParam);\n\n\t\t\tVID_AppActivate( fActive != WA_INACTIVE, fMinimized);\n\t\t\tSNDDMA_Activate();\n\t\t}\n\t\tbreak;\n\n\tcase WM_MOVE:\n\t\t{\n\t\t\tint\t\txPos, yPos;\n\t\t\tRECT r;\n\t\t\tint\t\tstyle;\n\n\t\t\tif (!r_fullscreen->integer )\n\t\t\t{\n\t\t\t\txPos = (short) LOWORD(lParam);    // horizontal position \n\t\t\t\tyPos = (short) HIWORD(lParam);    // vertical position \n\n\t\t\t\tr.left   = 0;\n\t\t\t\tr.top    = 0;\n\t\t\t\tr.right  = 1;\n\t\t\t\tr.bottom = 1;\n\n\t\t\t\tstyle = GetWindowLong( hWnd, GWL_STYLE );\n\t\t\t\tAdjustWindowRect( &r, style, FALSE );\n\n\t\t\t\tCvar_SetValue( \"vid_xpos\", xPos + r.left);\n\t\t\t\tCvar_SetValue( \"vid_ypos\", yPos + r.top);\n\t\t\t\tvid_xpos->modified = qfalse;\n\t\t\t\tvid_ypos->modified = qfalse;\n\t\t\t\tif ( g_wv.activeApp )\n\t\t\t\t{\n\t\t\t\t\tIN_Activate (qtrue);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbreak;\n\n// this is complicated because Win32 seems to pack multiple mouse events into\n// one update sometimes, so we always check all states and look for events\n\tcase WM_LBUTTONDOWN:\n\tcase WM_LBUTTONUP:\n\tcase WM_RBUTTONDOWN:\n\tcase WM_RBUTTONUP:\n\tcase WM_MBUTTONDOWN:\n\tcase WM_MBUTTONUP:\n\tcase WM_MOUSEMOVE:\n\t\t{\n\t\t\tint\ttemp;\n\n\t\t\ttemp = 0;\n\n\t\t\tif (wParam & MK_LBUTTON)\n\t\t\t\ttemp |= 1;\n\n\t\t\tif (wParam & MK_RBUTTON)\n\t\t\t\ttemp |= 2;\n\n\t\t\tif (wParam & MK_MBUTTON)\n\t\t\t\ttemp |= 4;\n\n\t\t\tIN_MouseEvent (temp);\n\t\t}\n\t\tbreak;\n\n\tcase WM_SYSCOMMAND:\n\t\tif ( wParam == SC_SCREENSAVE )\n\t\t\treturn 0;\n\t\tbreak;\n\n\tcase WM_SYSKEYDOWN:\n\t\tif ( wParam == 13 )\n\t\t{\n\t\t\tif ( r_fullscreen )\n\t\t\t{\n\t\t\t\tCvar_SetValue( \"r_fullscreen\", !r_fullscreen->integer );\n\t\t\t\tCbuf_AddText( \"vid_restart\\n\" );\n\t\t\t}\n\t\t\treturn 0;\n\t\t}\n\t\t// fall through\n\tcase WM_KEYDOWN:\n\t\tSys_QueEvent( g_wv.sysMsgTime, SE_KEY, MapKey( lParam ), qtrue, 0, NULL );\n\t\tbreak;\n\n\tcase WM_SYSKEYUP:\n\tcase WM_KEYUP:\n\t\tSys_QueEvent( g_wv.sysMsgTime, SE_KEY, MapKey( lParam ), qfalse, 0, NULL );\n\t\tbreak;\n\n\tcase WM_CHAR:\n\t\tSys_QueEvent( g_wv.sysMsgTime, SE_CHAR, wParam, 0, 0, NULL );\n\t\tbreak;\n   }\n\n    return DefWindowProc( hWnd, uMsg, wParam, lParam );\n}\n\n"
  },
  {
    "path": "code/win32/winquake.rc",
    "content": "//Microsoft Developer Studio generated resource script.\n//\n#include \"resource.h\"\n\n#define APSTUDIO_READONLY_SYMBOLS\n/////////////////////////////////////////////////////////////////////////////\n//\n// Generated from the TEXTINCLUDE 2 resource.\n//\n#include \"winres.h\"\n\n/////////////////////////////////////////////////////////////////////////////\n#undef APSTUDIO_READONLY_SYMBOLS\n\n/////////////////////////////////////////////////////////////////////////////\n// English (U.S.) resources\n\n#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\n#ifdef _WIN32\nLANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\n#pragma code_page(1252)\n#endif //_WIN32\n\n#ifdef APSTUDIO_INVOKED\n/////////////////////////////////////////////////////////////////////////////\n//\n// TEXTINCLUDE\n//\n\n1 TEXTINCLUDE DISCARDABLE \nBEGIN\n    \"resource.h\\0\"\nEND\n\n2 TEXTINCLUDE DISCARDABLE \nBEGIN\n    \"#include \"\"winres.h\"\"\\r\\n\"\n    \"\\0\"\nEND\n\n3 TEXTINCLUDE DISCARDABLE \nBEGIN\n    \"\\0\"\nEND\n\n#endif    // APSTUDIO_INVOKED\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Icon\n//\n\n// Icon with lowest ID value placed first to ensure application icon\n// remains consistent on all systems.\nIDI_ICON1               ICON    DISCARDABLE     \"qe3.ico\"\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// String Table\n//\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    IDS_STRING1             \"Quake3\"\nEND\n\n#endif    // English (U.S.) resources\n/////////////////////////////////////////////////////////////////////////////\n\n\n"
  },
  {
    "path": "common/aselib.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"aselib.h\"\n\n#include <assert.h>\n#include <stdio.h>\n#include <stdlib.h>\n\n#define MAX_ASE_MATERIALS\t\t\t32\n#define MAX_ASE_OBJECTS\t\t\t\t64\n#define MAX_ASE_ANIMATIONS\t\t\t32\n#define MAX_ASE_ANIMATION_FRAMES\t512\n\n#define VERBOSE( x ) { if ( ase.verbose ) { printf x ; } }\n\ntypedef struct\n{\n\tfloat x, y, z;\n\tfloat nx, ny, nz;\n\tfloat s, t;\n} aseVertex_t;\n\ntypedef struct\n{\n\tfloat s, t;\n} aseTVertex_t;\n\ntypedef int aseFace_t[3];\n\ntypedef struct\n{\n\tint numFaces;\n\tint numVertexes;\n\tint numTVertexes;\n\n\tint timeValue;\n\n\taseVertex_t\t\t*vertexes;\n\taseTVertex_t\t*tvertexes;\n\taseFace_t\t\t*faces, *tfaces;\n\n\tint currentFace, currentVertex;\n} aseMesh_t;\n\ntypedef struct\n{\n\tint\t\t\tnumFrames;\n\taseMesh_t\tframes[MAX_ASE_ANIMATION_FRAMES];\n\n\tint\t\t   currentFrame;\n} aseMeshAnimation_t;\n\ntypedef struct\n{\n\tchar name[128];\n} aseMaterial_t;\n\n/*\n** contains the animate sequence of a single surface\n** using a single material\n*/\ntypedef struct\n{\n\tchar name[128];\n\n\tint materialRef;\n\tint numAnimations;\n\n\taseMeshAnimation_t\tanim;\n\n} aseGeomObject_t;\n\ntypedef struct\n{\n\tint\t\t\t\tnumMaterials;\n\taseMaterial_t\tmaterials[MAX_ASE_MATERIALS];\n\taseGeomObject_t objects[MAX_ASE_OBJECTS];\n\n\tchar\t*buffer;\n\tchar\t*curpos;\n\tint\t\t len;\n\n\tint\t\t\tcurrentObject;\n\tqboolean\tverbose;\n\tqboolean\tgrabAnims;\n\n} ase_t;\n\nstatic char s_token[1024];\nstatic ase_t ase;\n\nstatic void ASE_Process( void );\nstatic void ASE_FreeGeomObject( int ndx );\n\n/*\n** ASE_Load\n*/\nvoid ASE_Load( const char *filename, qboolean verbose, qboolean grabAnims )\n{\n\tFILE *fp = fopen( filename, \"rb\" );\n\n\tif ( !fp )\n\t\tError( \"File not found '%s'\", filename );\n\n\tmemset( &ase, 0, sizeof( ase ) );\n\n\tase.verbose = verbose;\n\tase.grabAnims = grabAnims;\n\tase.len = Q_filelength( fp );\n\n\tase.curpos = ase.buffer = malloc( ase.len );\n\n\tprintf( \"Processing '%s'\\n\", filename );\n\n\tif ( fread( ase.buffer, ase.len, 1, fp ) != 1 )\n\t{\n\t\tfclose( fp );\n\t\tError( \"fread() != -1 for '%s'\", filename );\n\t}\n\n\tfclose( fp );\n\n\tASE_Process();\n}\n\n/*\n** ASE_Free\n*/\nvoid ASE_Free( void )\n{\n\tint i;\n\n\tfor ( i = 0; i < ase.currentObject; i++ )\n\t{\n\t\tASE_FreeGeomObject( i );\n\t}\n}\n\n/*\n** ASE_GetNumSurfaces\n*/\nint ASE_GetNumSurfaces( void )\n{\n\treturn ase.currentObject;\n}\n\n/*\n** ASE_GetSurfaceName\n*/\nconst char *ASE_GetSurfaceName( int which )\n{\n\taseGeomObject_t *pObject = &ase.objects[which];\n\n\tif ( !pObject->anim.numFrames )\n\t\treturn 0;\n\n\treturn pObject->name;\n}\n\n/*\n** ASE_GetSurfaceAnimation\n**\n** Returns an animation (sequence of polysets)\n*/\npolyset_t *ASE_GetSurfaceAnimation( int which, int *pNumFrames, int skipFrameStart, int skipFrameEnd, int maxFrames )\n{\n\taseGeomObject_t *pObject = &ase.objects[which];\n\tpolyset_t *psets;\n\tint numFramesInAnimation;\n\tint numFramesToKeep;\n\tint i, f;\n\n\tif ( !pObject->anim.numFrames )\n\t\treturn 0;\n\n\tif ( pObject->anim.numFrames > maxFrames && maxFrames != -1 )\n\t{\n\t\tnumFramesInAnimation = maxFrames;\n\t}\n\telse \n\t{\n\t\tnumFramesInAnimation = pObject->anim.numFrames;\n\t\tif ( maxFrames != -1 )\n\t\t\tprintf( \"WARNING: ASE_GetSurfaceAnimation maxFrames > numFramesInAnimation\\n\" );\n\t}\n\n\tif ( skipFrameEnd != -1 )\n\t\tnumFramesToKeep = numFramesInAnimation - ( skipFrameEnd - skipFrameStart + 1 );\n\telse\n\t\tnumFramesToKeep = numFramesInAnimation;\n\n\t*pNumFrames = numFramesToKeep;\n\n\tpsets = calloc( sizeof( polyset_t ) * numFramesToKeep, 1 );\n\n\tfor ( f = 0, i = 0; i < numFramesInAnimation; i++ )\n\t{\n\t\tint t;\n\t\taseMesh_t *pMesh = &pObject->anim.frames[i];\n\n\t\tif ( skipFrameStart != -1 )\n\t\t{\n\t\t\tif ( i >= skipFrameStart && i <= skipFrameEnd )\n\t\t\t\tcontinue;\n\t\t}\n\n\t\tstrcpy( psets[f].name, pObject->name );\n\t\tstrcpy( psets[f].materialname, ase.materials[pObject->materialRef].name );\n\n\t\tpsets[f].triangles = calloc( sizeof( triangle_t ) * pObject->anim.frames[i].numFaces, 1 );\n\t\tpsets[f].numtriangles = pObject->anim.frames[i].numFaces;\n\n\t\tfor ( t = 0; t < pObject->anim.frames[i].numFaces; t++ )\n\t\t{\n\t\t\tint k;\n\n\t\t\tfor ( k = 0; k < 3; k++ )\n\t\t\t{\n\t\t\t\tpsets[f].triangles[t].verts[k][0] = pMesh->vertexes[pMesh->faces[t][k]].x;\n\t\t\t\tpsets[f].triangles[t].verts[k][1] = pMesh->vertexes[pMesh->faces[t][k]].y;\n\t\t\t\tpsets[f].triangles[t].verts[k][2] = pMesh->vertexes[pMesh->faces[t][k]].z;\n\n\t\t\t\tif ( pMesh->tvertexes && pMesh->tfaces )\n\t\t\t\t{\n\t\t\t\t\tpsets[f].triangles[t].texcoords[k][0] = pMesh->tvertexes[pMesh->tfaces[t][k]].s;\n\t\t\t\t\tpsets[f].triangles[t].texcoords[k][1] = pMesh->tvertexes[pMesh->tfaces[t][k]].t;\n\t\t\t\t}\n\n\t\t\t}\n\t\t}\n\n\t\tf++;\n\t}\n\n\treturn psets;\n}\n\nstatic void ASE_FreeGeomObject( int ndx )\n{\n\taseGeomObject_t *pObject;\n\tint i;\n\n\tpObject = &ase.objects[ndx];\n\n\tfor ( i = 0; i < pObject->anim.numFrames; i++ )\n\t{\n\t\tif ( pObject->anim.frames[i].vertexes )\n\t\t{\n\t\t\tfree( pObject->anim.frames[i].vertexes );\n\t\t}\n\t\tif ( pObject->anim.frames[i].tvertexes )\n\t\t{\n\t\t\tfree( pObject->anim.frames[i].tvertexes );\n\t\t}\n\t\tif ( pObject->anim.frames[i].faces )\n\t\t{\n\t\t\tfree( pObject->anim.frames[i].faces );\n\t\t}\n\t\tif ( pObject->anim.frames[i].tfaces )\n\t\t{\n\t\t\tfree( pObject->anim.frames[i].tfaces );\n\t\t}\n\t}\n\n\tmemset( pObject, 0, sizeof( *pObject ) );\n}\n\nstatic aseMesh_t *ASE_GetCurrentMesh( void )\n{\n\taseGeomObject_t *pObject;\n\n\tif ( ase.currentObject >= MAX_ASE_OBJECTS )\n\t{\n\t\tError( \"Too many GEOMOBJECTs\" );\n\t\treturn 0; // never called\n\t}\n\n\tpObject = &ase.objects[ase.currentObject];\n\n\tif ( pObject->anim.currentFrame >= MAX_ASE_ANIMATION_FRAMES )\n\t{\n\t\tError( \"Too many MESHes\" );\n\t\treturn 0;\n\t}\n\n\treturn &pObject->anim.frames[pObject->anim.currentFrame];\n}\n\nstatic int CharIsTokenDelimiter( int ch )\n{\n\tif ( ch <= 32 )\n\t\treturn 1;\n\treturn 0;\n}\n\nstatic int ASE_GetToken( qboolean restOfLine )\n{\n\tint i = 0;\n\n\tif ( ase.buffer == 0 )\n\t\treturn 0;\n\n\tif ( ( ase.curpos - ase.buffer ) == ase.len )\n\t\treturn 0;\n\n\t// skip over crap\n\twhile ( ( ( ase.curpos - ase.buffer ) < ase.len ) &&\n\t\t    ( *ase.curpos <= 32 ) )\n\t{\n\t\tase.curpos++;\n\t}\n\n\twhile ( ( ase.curpos - ase.buffer ) < ase.len )\n\t{\n\t\ts_token[i] = *ase.curpos;\n\n\t\tase.curpos++;\n\t\ti++;\n\n\t\tif ( ( CharIsTokenDelimiter( s_token[i-1] ) && !restOfLine ) ||\n\t\t\t ( ( s_token[i-1] == '\\n' ) || ( s_token[i-1] == '\\r' ) ) )\n\t\t{\n\t\t\ts_token[i-1] = 0;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\ts_token[i] = 0;\n\n\treturn 1;\n}\n\nstatic void ASE_ParseBracedBlock( void (*parser)( const char *token ) )\n{\n\tint indent = 0;\n\n\twhile ( ASE_GetToken( qfalse ) )\n\t{\n\t\tif ( !strcmp( s_token, \"{\" ) )\n\t\t{\n\t\t\tindent++;\n\t\t}\n\t\telse if ( !strcmp( s_token, \"}\" ) )\n\t\t{\n\t\t\t--indent;\n\t\t\tif ( indent == 0 )\n\t\t\t\tbreak;\n\t\t\telse if ( indent < 0 )\n\t\t\t\tError( \"Unexpected '}'\" );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif ( parser )\n\t\t\t\tparser( s_token );\n\t\t}\n\t}\n}\n\nstatic void ASE_SkipEnclosingBraces( void )\n{\n\tint indent = 0;\n\n\twhile ( ASE_GetToken( qfalse ) )\n\t{\n\t\tif ( !strcmp( s_token, \"{\" ) )\n\t\t{\n\t\t\tindent++;\n\t\t}\n\t\telse if ( !strcmp( s_token, \"}\" ) )\n\t\t{\n\t\t\tindent--;\n\t\t\tif ( indent == 0 )\n\t\t\t\tbreak;\n\t\t\telse if ( indent < 0 )\n\t\t\t\tError( \"Unexpected '}'\" );\n\t\t}\n\t}\n}\n\nstatic void ASE_SkipRestOfLine( void )\n{\n\tASE_GetToken( qtrue );\n}\n\nstatic void ASE_KeyMAP_DIFFUSE( const char *token )\n{\n\tchar buffer[1024], buff1[1024], buff2[1024];\n  char *buf1, *buf2;\n\tint i = 0, count;\n\n\tif ( !strcmp( token, \"*BITMAP\" ) )\n\t{\n\t\tASE_GetToken( qfalse );\n\n\t\tstrcpy( buffer, s_token + 1 );\n\t\tif ( strchr( buffer, '\"' ) )\n\t\t\t*strchr( buffer, '\"' ) = 0;\n\n\t\twhile ( buffer[i] )\n\t\t{\n\t\t\tif ( buffer[i] == '\\\\' )\n\t\t\t\tbuffer[i] = '/';\n\t\t\ti++;\n\t\t}\n\n    buf1 = buffer;\n    buf2 = gamedir;\n    // need to compare win32 volumes to potential unix junk\n    // \n    if ( (gamedir[1] == ':' && (buffer[0] == '/' && buffer[1] == '/')) ||\n      (buffer[1] == ':' && (gamedir[0] == '/' && gamedir[1] == '/')) ) {\n      if (buffer[1] == ':') {\n        buf1 = buffer + 2;\n        buf2 = gamedir + 2;\n      } else {\n        buf1 = gamedir + 2;\n        buf2 = buffer +2;\n      }\n      count = 0;\n      while (*buf2 && count < 2) {\n        if (*buf2 == '/') {\n          count++;\n        }\n        buf2++;\n      }\n    } \n    strcpy(buff1, buf1);\n    strlwr(buff1);\n    strcpy(buff2, buf2);\n    strlwr(buff2);\n    if ( strstr( buff2, buff1 + 2 ) )\n\t\t{\n\t\t\tstrcpy( ase.materials[ase.numMaterials].name, strstr( buff2, buff1 + 2 ) + strlen( buff1 ) - 2 );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tsprintf( ase.materials[ase.numMaterials].name, \"(not converted: '%s')\", buffer );\n\t\t\tprintf( \"WARNING: illegal material name '%s'\\n\", buffer );\n\t\t}\n\t}\n\telse\n\t{\n\t}\n}\n\nstatic void ASE_KeyMATERIAL( const char *token )\n{\n\tif ( !strcmp( token, \"*MAP_DIFFUSE\" ) )\n\t{\n\t\tASE_ParseBracedBlock( ASE_KeyMAP_DIFFUSE );\n\t}\n\telse\n\t{\n\t}\n}\n\nstatic void ASE_KeyMATERIAL_LIST( const char *token )\n{\n\tif ( !strcmp( token, \"*MATERIAL_COUNT\" ) )\n\t{\n\t\tASE_GetToken( qfalse );\n\t\tVERBOSE( ( \"..num materials: %s\\n\", s_token ) );\n\t\tif ( atoi( s_token ) > MAX_ASE_MATERIALS )\n\t\t{\n\t\t\tError( \"Too many materials!\" );\n\t\t}\n\t\tase.numMaterials = 0;\n\t}\n\telse if ( !strcmp( token, \"*MATERIAL\" ) )\n\t{\n\t\tVERBOSE( ( \"..material %d \", ase.numMaterials ) );\n\t\tASE_ParseBracedBlock( ASE_KeyMATERIAL );\n\t\tase.numMaterials++;\n\t}\n}\n\nstatic void ASE_KeyMESH_VERTEX_LIST( const char *token )\n{\n\taseMesh_t *pMesh = ASE_GetCurrentMesh();\n\n\tif ( !strcmp( token, \"*MESH_VERTEX\" ) )\n\t{\n\t\tASE_GetToken( qfalse );\t\t// skip number\n\n\t\tASE_GetToken( qfalse );\n\t\tpMesh->vertexes[pMesh->currentVertex].y = atof( s_token );\n\n\t\tASE_GetToken( qfalse );\n\t\tpMesh->vertexes[pMesh->currentVertex].x = -atof( s_token );\n\n\t\tASE_GetToken( qfalse );\n\t\tpMesh->vertexes[pMesh->currentVertex].z = atof( s_token );\n\n\t\tpMesh->currentVertex++;\n\n\t\tif ( pMesh->currentVertex > pMesh->numVertexes )\n\t\t{\n\t\t\tError( \"pMesh->currentVertex >= pMesh->numVertexes\" );\n\t\t}\n\t}\n\telse\n\t{\n\t\tError( \"Unknown token '%s' while parsing MESH_VERTEX_LIST\", token );\n\t}\n}\n\nstatic void ASE_KeyMESH_FACE_LIST( const char *token )\n{\n\taseMesh_t *pMesh = ASE_GetCurrentMesh();\n\n\tif ( !strcmp( token, \"*MESH_FACE\" ) )\n\t{\n\t\tASE_GetToken( qfalse );\t// skip face number\n\n\t\tASE_GetToken( qfalse );\t// skip label\n\t\tASE_GetToken( qfalse );\t// first vertex\n\t\tpMesh->faces[pMesh->currentFace][0] = atoi( s_token );\n\n\t\tASE_GetToken( qfalse );\t// skip label\n\t\tASE_GetToken( qfalse );\t// second vertex\n\t\tpMesh->faces[pMesh->currentFace][2] = atoi( s_token );\n\n\t\tASE_GetToken( qfalse );\t// skip label\n\t\tASE_GetToken( qfalse );\t// third vertex\n\t\tpMesh->faces[pMesh->currentFace][1] = atoi( s_token );\n\n\t\tASE_GetToken( qtrue );\n\n/*\n\t\tif ( ( p = strstr( s_token, \"*MESH_MTLID\" ) ) != 0 )\n\t\t{\n\t\t\tp += strlen( \"*MESH_MTLID\" ) + 1;\n\t\t\tmtlID = atoi( p );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tError( \"No *MESH_MTLID found for face!\" );\n\t\t}\n*/\n\n\t\tpMesh->currentFace++;\n\t}\n\telse\n\t{\n\t\tError( \"Unknown token '%s' while parsing MESH_FACE_LIST\", token );\n\t}\n}\n\nstatic void ASE_KeyTFACE_LIST( const char *token )\n{\n\taseMesh_t *pMesh = ASE_GetCurrentMesh();\n\n\tif ( !strcmp( token, \"*MESH_TFACE\" ) )\n\t{\n\t\tint a, b, c;\n\n\t\tASE_GetToken( qfalse );\n\n\t\tASE_GetToken( qfalse );\n\t\ta = atoi( s_token );\n\t\tASE_GetToken( qfalse );\n\t\tc = atoi( s_token );\n\t\tASE_GetToken( qfalse );\n\t\tb = atoi( s_token );\n\n\t\tpMesh->tfaces[pMesh->currentFace][0] = a;\n\t\tpMesh->tfaces[pMesh->currentFace][1] = b;\n\t\tpMesh->tfaces[pMesh->currentFace][2] = c;\n\n\t\tpMesh->currentFace++;\n\t}\n\telse\n\t{\n\t\tError( \"Unknown token '%s' in MESH_TFACE\", token );\n\t}\n}\n\nstatic void ASE_KeyMESH_TVERTLIST( const char *token )\n{\n\taseMesh_t *pMesh = ASE_GetCurrentMesh();\n\n\tif ( !strcmp( token, \"*MESH_TVERT\" ) )\n\t{\n\t\tchar u[80], v[80], w[80];\n\n\t\tASE_GetToken( qfalse );\n\n\t\tASE_GetToken( qfalse );\n\t\tstrcpy( u, s_token );\n\n\t\tASE_GetToken( qfalse );\n\t\tstrcpy( v, s_token );\n\n\t\tASE_GetToken( qfalse );\n\t\tstrcpy( w, s_token );\n\n\t\tpMesh->tvertexes[pMesh->currentVertex].s = atof( u );\n\t\tpMesh->tvertexes[pMesh->currentVertex].t = 1.0f - atof( v );\n\n\t\tpMesh->currentVertex++;\n\n\t\tif ( pMesh->currentVertex > pMesh->numTVertexes )\n\t\t{\n\t\t\tError( \"pMesh->currentVertex > pMesh->numTVertexes\" );\n\t\t}\n\t}\n\telse\n\t{\n\t\tError( \"Unknown token '%s' while parsing MESH_TVERTLIST\" );\n\t}\n}\n\nstatic void ASE_KeyMESH( const char *token )\n{\n\taseMesh_t *pMesh = ASE_GetCurrentMesh();\n\n\tif ( !strcmp( token, \"*TIMEVALUE\" ) )\n\t{\n\t\tASE_GetToken( qfalse );\n\n\t\tpMesh->timeValue = atoi( s_token );\n\t\tVERBOSE( ( \".....timevalue: %d\\n\", pMesh->timeValue ) );\n\t}\n\telse if ( !strcmp( token, \"*MESH_NUMVERTEX\" ) )\n\t{\n\t\tASE_GetToken( qfalse );\n\n\t\tpMesh->numVertexes = atoi( s_token );\n\t\tVERBOSE( ( \".....TIMEVALUE: %d\\n\", pMesh->timeValue ) );\n\t\tVERBOSE( ( \".....num vertexes: %d\\n\", pMesh->numVertexes ) );\n\t}\n\telse if ( !strcmp( token, \"*MESH_NUMFACES\" ) )\n\t{\n\t\tASE_GetToken( qfalse );\n\n\t\tpMesh->numFaces = atoi( s_token );\n\t\tVERBOSE( ( \".....num faces: %d\\n\", pMesh->numFaces ) );\n\t}\n\telse if ( !strcmp( token, \"*MESH_NUMTVFACES\" ) )\n\t{\n\t\tASE_GetToken( qfalse );\n\n\t\tif ( atoi( s_token ) != pMesh->numFaces )\n\t\t{\n\t\t\tError( \"MESH_NUMTVFACES != MESH_NUMFACES\" );\n\t\t}\n\t}\n\telse if ( !strcmp( token, \"*MESH_NUMTVERTEX\" ) )\n\t{\n\t\tASE_GetToken( qfalse );\n\n\t\tpMesh->numTVertexes = atoi( s_token );\n\t\tVERBOSE( ( \".....num tvertexes: %d\\n\", pMesh->numTVertexes ) );\n\t}\n\telse if ( !strcmp( token, \"*MESH_VERTEX_LIST\" ) )\n\t{\n\t\tpMesh->vertexes = calloc( sizeof( aseVertex_t ) * pMesh->numVertexes, 1 );\n\t\tpMesh->currentVertex = 0;\n\t\tVERBOSE( ( \".....parsing MESH_VERTEX_LIST\\n\" ) );\n\t\tASE_ParseBracedBlock( ASE_KeyMESH_VERTEX_LIST );\n\t}\n\telse if ( !strcmp( token, \"*MESH_TVERTLIST\" ) )\n\t{\n\t\tpMesh->currentVertex = 0;\n\t\tpMesh->tvertexes = calloc( sizeof( aseTVertex_t ) * pMesh->numTVertexes, 1 );\n\t\tVERBOSE( ( \".....parsing MESH_TVERTLIST\\n\" ) );\n\t\tASE_ParseBracedBlock( ASE_KeyMESH_TVERTLIST );\n\t}\n\telse if ( !strcmp( token, \"*MESH_FACE_LIST\" ) )\n\t{\n\t\tpMesh->faces = calloc( sizeof( aseFace_t ) * pMesh->numFaces, 1 );\n\t\tpMesh->currentFace = 0;\n\t\tVERBOSE( ( \".....parsing MESH_FACE_LIST\\n\" ) );\n\t\tASE_ParseBracedBlock( ASE_KeyMESH_FACE_LIST );\n\t}\n\telse if ( !strcmp( token, \"*MESH_TFACELIST\" ) )\n\t{\n\t\tpMesh->tfaces = calloc( sizeof( aseFace_t ) * pMesh->numFaces, 1 );\n\t\tpMesh->currentFace = 0;\n\t\tVERBOSE( ( \".....parsing MESH_TFACE_LIST\\n\" ) );\n\t\tASE_ParseBracedBlock( ASE_KeyTFACE_LIST );\n\t}\n\telse if ( !strcmp( token, \"*MESH_NORMALS\" ) )\n\t{\n\t\tASE_ParseBracedBlock( 0 );\n\t}\n}\n\nstatic void ASE_KeyMESH_ANIMATION( const char *token )\n{\n\taseMesh_t *pMesh = ASE_GetCurrentMesh();\n\n\t// loads a single animation frame\n\tif ( !strcmp( token, \"*MESH\" ) )\n\t{\n\t\tVERBOSE( ( \"...found MESH\\n\" ) );\n\t\tassert( pMesh->faces == 0 );\n\t\tassert( pMesh->vertexes == 0 );\n\t\tassert( pMesh->tvertexes == 0 );\n\t\tmemset( pMesh, 0, sizeof( *pMesh ) );\n\n\t\tASE_ParseBracedBlock( ASE_KeyMESH );\n\n\t\tif ( ++ase.objects[ase.currentObject].anim.currentFrame == MAX_ASE_ANIMATION_FRAMES )\n\t\t{\n\t\t\tError( \"Too many animation frames\" );\n\t\t}\n\t}\n\telse\n\t{\n\t\tError( \"Unknown token '%s' while parsing MESH_ANIMATION\", token );\n\t}\n}\n\nstatic void ASE_KeyGEOMOBJECT( const char *token )\n{\n\tif ( !strcmp( token, \"*NODE_NAME\" ) )\n\t{\n\t\tchar *name = ase.objects[ase.currentObject].name;\n\n\t\tASE_GetToken( qtrue );\n\t\tVERBOSE( ( \" %s\\n\", s_token ) );\n\t\tstrcpy( ase.objects[ase.currentObject].name, s_token + 1 );\n\t\tif ( strchr( ase.objects[ase.currentObject].name, '\"' ) )\n\t\t\t*strchr( ase.objects[ase.currentObject].name, '\"' ) = 0;\n\n\t\tif ( strstr( name, \"tag\" ) == name )\n\t\t{\n\t\t\twhile ( strchr( name, '_' ) != strrchr( name, '_' ) )\n\t\t\t{\n\t\t\t\t*strrchr( name, '_' ) = 0;\n\t\t\t}\n\t\t\twhile ( strrchr( name, ' ' ) )\n\t\t\t{\n\t\t\t\t*strrchr( name, ' ' ) = 0;\n\t\t\t}\n\t\t}\n\t}\n\telse if ( !strcmp( token, \"*NODE_PARENT\" ) )\n\t{\n\t\tASE_SkipRestOfLine();\n\t}\n\t// ignore unused data blocks\n\telse if ( !strcmp( token, \"*NODE_TM\" ) ||\n\t\t      !strcmp( token, \"*TM_ANIMATION\" ) )\n\t{\n\t\tASE_ParseBracedBlock( 0 );\n\t}\n\t// ignore regular meshes that aren't part of animation\n\telse if ( !strcmp( token, \"*MESH\" ) && !ase.grabAnims )\n\t{\n/*\n\t\tif ( strstr( ase.objects[ase.currentObject].name, \"tag_\" ) == ase.objects[ase.currentObject].name ) \n\t\t{\n\t\t\ts_forceStaticMesh = true;\n\t\t\tASE_ParseBracedBlock( ASE_KeyMESH );\n\t\t\ts_forceStaticMesh = false;\n\t\t}\n*/\n\t\tASE_ParseBracedBlock( ASE_KeyMESH );\n\t\tif ( ++ase.objects[ase.currentObject].anim.currentFrame == MAX_ASE_ANIMATION_FRAMES )\n\t\t{\n\t\t\tError( \"Too many animation frames\" );\n\t\t}\n\t\tase.objects[ase.currentObject].anim.numFrames = ase.objects[ase.currentObject].anim.currentFrame;\n\t\tase.objects[ase.currentObject].numAnimations++;\n/*\n\t\t// ignore meshes that aren't part of animations if this object isn't a \n\t\t// a tag\n\t\telse\n\t\t{\n\t\t\tASE_ParseBracedBlock( 0 );\n\t\t}\n*/\n\t}\n\t// according to spec these are obsolete\n\telse if ( !strcmp( token, \"*MATERIAL_REF\" ) )\n\t{\n\t\tASE_GetToken( qfalse );\n\n\t\tase.objects[ase.currentObject].materialRef = atoi( s_token );\n\t}\n\t// loads a sequence of animation frames\n\telse if ( !strcmp( token, \"*MESH_ANIMATION\" ) )\n\t{\n\t\tif ( ase.grabAnims )\n\t\t{\n\t\t\tVERBOSE( ( \"..found MESH_ANIMATION\\n\" ) );\n\n\t\t\tif ( ase.objects[ase.currentObject].numAnimations )\n\t\t\t{\n\t\t\t\tError( \"Multiple MESH_ANIMATIONS within a single GEOM_OBJECT\" );\n\t\t\t}\n\t\t\tASE_ParseBracedBlock( ASE_KeyMESH_ANIMATION );\n\t\t\tase.objects[ase.currentObject].anim.numFrames = ase.objects[ase.currentObject].anim.currentFrame;\n\t\t\tase.objects[ase.currentObject].numAnimations++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tASE_SkipEnclosingBraces();\n\t\t}\n\t}\n\t// skip unused info\n\telse if ( !strcmp( token, \"*PROP_MOTIONBLUR\" ) ||\n\t\t      !strcmp( token, \"*PROP_CASTSHADOW\" ) ||\n\t\t\t  !strcmp( token, \"*PROP_RECVSHADOW\" ) )\n\t{\n\t\tASE_SkipRestOfLine();\n\t}\n}\n\nstatic void ConcatenateObjects( aseGeomObject_t *pObjA, aseGeomObject_t *pObjB )\n{\n}\n\nstatic void CollapseObjects( void )\n{\n\tint i;\n\tint numObjects = ase.currentObject;\n\n\tfor ( i = 0; i < numObjects; i++ )\n\t{\n\t\tint j;\n\n\t\t// skip tags\n\t\tif ( strstr( ase.objects[i].name, \"tag\" ) == ase.objects[i].name )\n\t\t{\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( !ase.objects[i].numAnimations )\n\t\t{\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor ( j = i + 1; j < numObjects; j++ )\n\t\t{\n\t\t\tif ( strstr( ase.objects[j].name, \"tag\" ) == ase.objects[j].name )\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( ase.objects[i].materialRef == ase.objects[j].materialRef )\n\t\t\t{\n\t\t\t\tif ( ase.objects[j].numAnimations )\n\t\t\t\t{\n\t\t\t\t\tConcatenateObjects( &ase.objects[i], &ase.objects[j] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n** ASE_Process\n*/\nstatic void ASE_Process( void )\n{\n\twhile ( ASE_GetToken( qfalse ) )\n\t{\n\t\tif ( !strcmp( s_token, \"*3DSMAX_ASCIIEXPORT\" ) ||\n\t\t\t !strcmp( s_token, \"*COMMENT\" ) )\n\t\t{\n\t\t\tASE_SkipRestOfLine();\n\t\t}\n\t\telse if ( !strcmp( s_token, \"*SCENE\" ) )\n\t\t\tASE_SkipEnclosingBraces();\n\t\telse if ( !strcmp( s_token, \"*MATERIAL_LIST\" ) )\n\t\t{\n\t\t\tVERBOSE( (\"MATERIAL_LIST\\n\") );\n\n\t\t\tASE_ParseBracedBlock( ASE_KeyMATERIAL_LIST );\n\t\t}\n\t\telse if ( !strcmp( s_token, \"*GEOMOBJECT\" ) )\n\t\t{\n\t\t\tVERBOSE( (\"GEOMOBJECT\" ) );\n\n\t\t\tASE_ParseBracedBlock( ASE_KeyGEOMOBJECT );\n\n\t\t\tif ( strstr( ase.objects[ase.currentObject].name, \"Bip\" ) ||\n\t\t\t\t strstr( ase.objects[ase.currentObject].name, \"ignore_\" ) )\n\t\t\t{\n\t\t\t\tASE_FreeGeomObject( ase.currentObject );\n\t\t\t\tVERBOSE( ( \"(discarding BIP/ignore object)\\n\" ) );\n\t\t\t}\n\t\t\telse if ( ( strstr( ase.objects[ase.currentObject].name, \"h_\" ) != ase.objects[ase.currentObject].name ) &&\n\t\t\t\t      ( strstr( ase.objects[ase.currentObject].name, \"l_\" ) != ase.objects[ase.currentObject].name ) &&\n\t\t\t\t\t  ( strstr( ase.objects[ase.currentObject].name, \"u_\" ) != ase.objects[ase.currentObject].name ) &&\n\t\t\t\t\t  ( strstr( ase.objects[ase.currentObject].name, \"tag\" ) != ase.objects[ase.currentObject].name ) &&\n\t\t\t\t\t  ase.grabAnims )\n\t\t\t{\n\t\t\t\tVERBOSE( ( \"(ignoring improperly labeled object '%s')\\n\", ase.objects[ase.currentObject].name ) );\n\t\t\t\tASE_FreeGeomObject( ase.currentObject );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif ( ++ase.currentObject == MAX_ASE_OBJECTS )\n\t\t\t\t{\n\t\t\t\t\tError( \"Too many GEOMOBJECTs\" );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if ( s_token[0] )\n\t\t{\n\t\t\tprintf( \"Unknown token '%s'\\n\", s_token );\n\t\t}\n\t}\n\n\tif ( !ase.currentObject )\n\t\tError( \"No animation data!\" );\n\n\tCollapseObjects();\n}\n\n"
  },
  {
    "path": "common/aselib.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"cmdlib.h\"\n#include \"mathlib.h\"\n#include \"polyset.h\"\n\nvoid\t\tASE_Load( const char *filename, qboolean verbose, qboolean meshanims );\nint\t\t\tASE_GetNumSurfaces( void );\npolyset_t\t*ASE_GetSurfaceAnimation( int ndx, int *numFrames, int skipFrameStart, int skipFrameEnd, int maxFrames );\nconst char  *ASE_GetSurfaceName( int ndx );\nvoid\t\tASE_Free( void );\n"
  },
  {
    "path": "common/bspfile.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"cmdlib.h\"\n#include \"mathlib.h\"\n#include \"bspfile.h\"\n#include \"scriplib.h\"\n\nvoid GetLeafNums (void);\n\n//=============================================================================\n\nint\t\t\tnummodels;\ndmodel_t\tdmodels[MAX_MAP_MODELS];\n\nint\t\t\tnumShaders;\ndshader_t\tdshaders[MAX_MAP_SHADERS];\n\nint\t\t\tentdatasize;\nchar\t\tdentdata[MAX_MAP_ENTSTRING];\n\nint\t\t\tnumleafs;\ndleaf_t\t\tdleafs[MAX_MAP_LEAFS];\n\nint\t\t\tnumplanes;\ndplane_t\tdplanes[MAX_MAP_PLANES];\n\nint\t\t\tnumnodes;\ndnode_t\t\tdnodes[MAX_MAP_NODES];\n\nint\t\t\tnumleafsurfaces;\nint\t\t\tdleafsurfaces[MAX_MAP_LEAFFACES];\n\nint\t\t\tnumleafbrushes;\nint\t\t\tdleafbrushes[MAX_MAP_LEAFBRUSHES];\n\nint\t\t\tnumbrushes;\ndbrush_t\tdbrushes[MAX_MAP_BRUSHES];\n\nint\t\t\tnumbrushsides;\ndbrushside_t\tdbrushsides[MAX_MAP_BRUSHSIDES];\n\nint\t\t\tnumLightBytes;\nbyte\t\tlightBytes[MAX_MAP_LIGHTING];\n\nint\t\t\tnumGridPoints;\nbyte\t\tgridData[MAX_MAP_LIGHTGRID];\n\nint\t\t\tnumVisBytes;\nbyte\t\tvisBytes[MAX_MAP_VISIBILITY];\n\nint\t\t\tnumDrawVerts;\ndrawVert_t\tdrawVerts[MAX_MAP_DRAW_VERTS];\n\nint\t\t\tnumDrawIndexes;\nint\t\t\tdrawIndexes[MAX_MAP_DRAW_INDEXES];\n\nint\t\t\tnumDrawSurfaces;\ndsurface_t\tdrawSurfaces[MAX_MAP_DRAW_SURFS];\n\nint\t\t\tnumFogs;\ndfog_t\t\tdfogs[MAX_MAP_FOGS];\n\n//=============================================================================\n\n/*\n=============\nSwapBlock\n\nIf all values are 32 bits, this can be used to swap everything\n=============\n*/\nvoid SwapBlock( int *block, int sizeOfBlock ) {\n\tint\t\ti;\n\n\tsizeOfBlock >>= 2;\n\tfor ( i = 0 ; i < sizeOfBlock ; i++ ) {\n\t\tblock[i] = LittleLong( block[i] );\n\t}\n}\n\n/*\n=============\nSwapBSPFile\n\nByte swaps all data in a bsp file.\n=============\n*/\nvoid SwapBSPFile( void ) {\n\tint\t\t\t\ti;\n\t\n\t// models\t\n\tSwapBlock( (int *)dmodels, nummodels * sizeof( dmodels[0] ) );\n\n\t// shaders (don't swap the name)\n\tfor ( i = 0 ; i < numShaders ; i++ ) {\n\t\tdshaders[i].contentFlags = LittleLong( dshaders[i].contentFlags );\n\t\tdshaders[i].surfaceFlags = LittleLong( dshaders[i].surfaceFlags );\n\t}\n\n\t// planes\n\tSwapBlock( (int *)dplanes, numplanes * sizeof( dplanes[0] ) );\n\t\n\t// nodes\n\tSwapBlock( (int *)dnodes, numnodes * sizeof( dnodes[0] ) );\n\n\t// leafs\n\tSwapBlock( (int *)dleafs, numleafs * sizeof( dleafs[0] ) );\n\n\t// leaffaces\n\tSwapBlock( (int *)dleafsurfaces, numleafsurfaces * sizeof( dleafsurfaces[0] ) );\n\n\t// leafbrushes\n\tSwapBlock( (int *)dleafbrushes, numleafbrushes * sizeof( dleafbrushes[0] ) );\n\n\t// brushes\n\tSwapBlock( (int *)dbrushes, numbrushes * sizeof( dbrushes[0] ) );\n\n\t// brushsides\n\tSwapBlock( (int *)dbrushsides, numbrushsides * sizeof( dbrushsides[0] ) );\n\n\t// vis\n\t((int *)&visBytes)[0] = LittleLong( ((int *)&visBytes)[0] );\n\t((int *)&visBytes)[1] = LittleLong( ((int *)&visBytes)[1] );\n\n\t// drawverts (don't swap colors )\n\tfor ( i = 0 ; i < numDrawVerts ; i++ ) {\n\t\tdrawVerts[i].lightmap[0] = LittleFloat( drawVerts[i].lightmap[0] );\n\t\tdrawVerts[i].lightmap[1] = LittleFloat( drawVerts[i].lightmap[1] );\n\t\tdrawVerts[i].st[0] = LittleFloat( drawVerts[i].st[0] );\n\t\tdrawVerts[i].st[1] = LittleFloat( drawVerts[i].st[1] );\n\t\tdrawVerts[i].xyz[0] = LittleFloat( drawVerts[i].xyz[0] );\n\t\tdrawVerts[i].xyz[1] = LittleFloat( drawVerts[i].xyz[1] );\n\t\tdrawVerts[i].xyz[2] = LittleFloat( drawVerts[i].xyz[2] );\n\t\tdrawVerts[i].normal[0] = LittleFloat( drawVerts[i].normal[0] );\n\t\tdrawVerts[i].normal[1] = LittleFloat( drawVerts[i].normal[1] );\n\t\tdrawVerts[i].normal[2] = LittleFloat( drawVerts[i].normal[2] );\n\t}\n\n\t// drawindexes\n\tSwapBlock( (int *)drawIndexes, numDrawIndexes * sizeof( drawIndexes[0] ) );\n\n\t// drawsurfs\n\tSwapBlock( (int *)drawSurfaces, numDrawSurfaces * sizeof( drawSurfaces[0] ) );\n\n\t// fogs\n\tfor ( i = 0 ; i < numFogs ; i++ ) {\n\t\tdfogs[i].brushNum = LittleLong( dfogs[i].brushNum );\n\t\tdfogs[i].visibleSide = LittleLong( dfogs[i].visibleSide );\n\t}\n}\n\n\n\n/*\n=============\nCopyLump\n=============\n*/\nint CopyLump( dheader_t\t*header, int lump, void *dest, int size ) {\n\tint\t\tlength, ofs;\n\n\tlength = header->lumps[lump].filelen;\n\tofs = header->lumps[lump].fileofs;\n\t\n\tif ( length % size ) {\n\t\tError (\"LoadBSPFile: odd lump size\");\n\t}\n\n\tmemcpy( dest, (byte *)header + ofs, length );\n\n\treturn length / size;\n}\n\n/*\n=============\nLoadBSPFile\n=============\n*/\nvoid\tLoadBSPFile( const char *filename ) {\n\tdheader_t\t*header;\n\n\t// load the file header\n\tLoadFile (filename, (void **)&header);\n\n\t// swap the header\n\tSwapBlock( (int *)header, sizeof(*header) );\n\n\tif ( header->ident != BSP_IDENT ) {\n\t\tError( \"%s is not a IBSP file\", filename );\n\t}\n\tif ( header->version != BSP_VERSION ) {\n\t\tError( \"%s is version %i, not %i\", filename, header->version, BSP_VERSION );\n\t}\n\n\tnumShaders = CopyLump( header, LUMP_SHADERS, dshaders, sizeof(dshader_t) );\n\tnummodels = CopyLump( header, LUMP_MODELS, dmodels, sizeof(dmodel_t) );\n\tnumplanes = CopyLump( header, LUMP_PLANES, dplanes, sizeof(dplane_t) );\n\tnumleafs = CopyLump( header, LUMP_LEAFS, dleafs, sizeof(dleaf_t) );\n\tnumnodes = CopyLump( header, LUMP_NODES, dnodes, sizeof(dnode_t) );\n\tnumleafsurfaces = CopyLump( header, LUMP_LEAFSURFACES, dleafsurfaces, sizeof(dleafsurfaces[0]) );\n\tnumleafbrushes = CopyLump( header, LUMP_LEAFBRUSHES, dleafbrushes, sizeof(dleafbrushes[0]) );\n\tnumbrushes = CopyLump( header, LUMP_BRUSHES, dbrushes, sizeof(dbrush_t) );\n\tnumbrushsides = CopyLump( header, LUMP_BRUSHSIDES, dbrushsides, sizeof(dbrushside_t) );\n\tnumDrawVerts = CopyLump( header, LUMP_DRAWVERTS, drawVerts, sizeof(drawVert_t) );\n\tnumDrawSurfaces = CopyLump( header, LUMP_SURFACES, drawSurfaces, sizeof(dsurface_t) );\n\tnumFogs = CopyLump( header, LUMP_FOGS, dfogs, sizeof(dfog_t) );\n\tnumDrawIndexes = CopyLump( header, LUMP_DRAWINDEXES, drawIndexes, sizeof(drawIndexes[0]) );\n\n\tnumVisBytes = CopyLump( header, LUMP_VISIBILITY, visBytes, 1 );\n\tnumLightBytes = CopyLump( header, LUMP_LIGHTMAPS, lightBytes, 1 );\n\tentdatasize = CopyLump( header, LUMP_ENTITIES, dentdata, 1);\n\n\tnumGridPoints = CopyLump( header, LUMP_LIGHTGRID, gridData, 8 );\n\n\n\tfree( header );\t\t// everything has been copied out\n\t\t\n\t// swap everything\n\tSwapBSPFile();\n}\n\n\n//============================================================================\n\n/*\n=============\nAddLump\n=============\n*/\nvoid AddLump( FILE *bspfile, dheader_t *header, int lumpnum, const void *data, int len ) {\n\tlump_t *lump;\n\n\tlump = &header->lumps[lumpnum];\n\t\n\tlump->fileofs = LittleLong( ftell(bspfile) );\n\tlump->filelen = LittleLong( len );\n\tSafeWrite( bspfile, data, (len+3)&~3 );\n}\n\n/*\n=============\nWriteBSPFile\n\nSwaps the bsp file in place, so it should not be referenced again\n=============\n*/\nvoid\tWriteBSPFile( const char *filename ) {\t\t\n\tdheader_t\toutheader, *header;\n\tFILE\t\t*bspfile;\n\n\theader = &outheader;\n\tmemset( header, 0, sizeof(dheader_t) );\n\t\n\tSwapBSPFile();\n\n\theader->ident = LittleLong( BSP_IDENT );\n\theader->version = LittleLong( BSP_VERSION );\n\t\n\tbspfile = SafeOpenWrite( filename );\n\tSafeWrite( bspfile, header, sizeof(dheader_t) );\t// overwritten later\n\n\tAddLump( bspfile, header, LUMP_SHADERS, dshaders, numShaders*sizeof(dshader_t) );\n\tAddLump( bspfile, header, LUMP_PLANES, dplanes, numplanes*sizeof(dplane_t) );\n\tAddLump( bspfile, header, LUMP_LEAFS, dleafs, numleafs*sizeof(dleaf_t) );\n\tAddLump( bspfile, header, LUMP_NODES, dnodes, numnodes*sizeof(dnode_t) );\n\tAddLump( bspfile, header, LUMP_BRUSHES, dbrushes, numbrushes*sizeof(dbrush_t) );\n\tAddLump( bspfile, header, LUMP_BRUSHSIDES, dbrushsides, numbrushsides*sizeof(dbrushside_t) );\n\tAddLump( bspfile, header, LUMP_LEAFSURFACES, dleafsurfaces, numleafsurfaces*sizeof(dleafsurfaces[0]) );\n\tAddLump( bspfile, header, LUMP_LEAFBRUSHES, dleafbrushes, numleafbrushes*sizeof(dleafbrushes[0]) );\n\tAddLump( bspfile, header, LUMP_MODELS, dmodels, nummodels*sizeof(dmodel_t) );\n\tAddLump( bspfile, header, LUMP_DRAWVERTS, drawVerts, numDrawVerts*sizeof(drawVert_t) );\n\tAddLump( bspfile, header, LUMP_SURFACES, drawSurfaces, numDrawSurfaces*sizeof(dsurface_t) );\n\tAddLump( bspfile, header, LUMP_VISIBILITY, visBytes, numVisBytes );\n\tAddLump( bspfile, header, LUMP_LIGHTMAPS, lightBytes, numLightBytes );\n\tAddLump( bspfile, header, LUMP_LIGHTGRID, gridData, 8 * numGridPoints );\n\tAddLump( bspfile, header, LUMP_ENTITIES, dentdata, entdatasize );\n\tAddLump( bspfile, header, LUMP_FOGS, dfogs, numFogs * sizeof(dfog_t) );\n\tAddLump( bspfile, header, LUMP_DRAWINDEXES, drawIndexes, numDrawIndexes * sizeof(drawIndexes[0]) );\n\t\n\tfseek (bspfile, 0, SEEK_SET);\n\tSafeWrite (bspfile, header, sizeof(dheader_t));\n\tfclose (bspfile);\t\n}\n\n//============================================================================\n\n/*\n=============\nPrintBSPFileSizes\n\nDumps info about current file\n=============\n*/\nvoid PrintBSPFileSizes( void ) {\n\tif ( !num_entities ) {\n\t\tParseEntities();\n\t}\n\n\tprintf (\"%6i models       %7i\\n\"\n\t\t,nummodels, (int)(nummodels*sizeof(dmodel_t)));\n\tprintf (\"%6i shaders      %7i\\n\"\n\t\t,numShaders, (int)(numShaders*sizeof(dshader_t)));\n\tprintf (\"%6i brushes      %7i\\n\"\n\t\t,numbrushes, (int)(numbrushes*sizeof(dbrush_t)));\n\tprintf (\"%6i brushsides   %7i\\n\"\n\t\t,numbrushsides, (int)(numbrushsides*sizeof(dbrushside_t)));\n\tprintf (\"%6i fogs         %7i\\n\"\n\t\t,numFogs, (int)(numFogs*sizeof(dfog_t)));\n\tprintf (\"%6i planes       %7i\\n\"\n\t\t,numplanes, (int)(numplanes*sizeof(dplane_t)));\n\tprintf (\"%6i entdata      %7i\\n\", num_entities, entdatasize);\n\n\tprintf (\"\\n\");\n\n\tprintf (\"%6i nodes        %7i\\n\"\n\t\t,numnodes, (int)(numnodes*sizeof(dnode_t)));\n\tprintf (\"%6i leafs        %7i\\n\"\n\t\t,numleafs, (int)(numleafs*sizeof(dleaf_t)));\n\tprintf (\"%6i leafsurfaces %7i\\n\"\n\t\t,numleafsurfaces, (int)(numleafsurfaces*sizeof(dleafsurfaces[0])));\n\tprintf (\"%6i leafbrushes  %7i\\n\"\n\t\t,numleafbrushes, (int)(numleafbrushes*sizeof(dleafbrushes[0])));\n\tprintf (\"%6i drawverts    %7i\\n\"\n\t\t,numDrawVerts, (int)(numDrawVerts*sizeof(drawVerts[0])));\n\tprintf (\"%6i drawindexes  %7i\\n\"\n\t\t,numDrawIndexes, (int)(numDrawIndexes*sizeof(drawIndexes[0])));\n\tprintf (\"%6i drawsurfaces %7i\\n\"\n\t\t,numDrawSurfaces, (int)(numDrawSurfaces*sizeof(drawSurfaces[0])));\n\n\tprintf (\"%6i lightmaps    %7i\\n\"\n\t\t,numLightBytes / (LIGHTMAP_WIDTH*LIGHTMAP_HEIGHT*3), numLightBytes );\n\tprintf (\"       visibility   %7i\\n\"\n\t\t, numVisBytes );\n}\n\n\n//============================================\n\nint\t\t\tnum_entities;\nentity_t\tentities[MAX_MAP_ENTITIES];\n\nvoid StripTrailing( char *e ) {\n\tchar\t*s;\n\n\ts = e + strlen(e)-1;\n\twhile (s >= e && *s <= 32)\n\t{\n\t\t*s = 0;\n\t\ts--;\n\t}\n}\n\n/*\n=================\nParseEpair\n=================\n*/\nepair_t *ParseEpair( void ) {\n\tepair_t\t*e;\n\n\te = malloc( sizeof(epair_t) );\n\tmemset( e, 0, sizeof(epair_t) );\n\t\n\tif ( strlen(token) >= MAX_KEY-1 ) {\n\t\tError (\"ParseEpar: token too long\");\n\t}\n\te->key = copystring( token );\n\tGetToken( qfalse );\n\tif ( strlen(token) >= MAX_VALUE-1 ) {\n\t\tError (\"ParseEpar: token too long\");\n\t}\n\te->value = copystring( token );\n\n\t// strip trailing spaces that sometimes get accidentally\n\t// added in the editor\n\tStripTrailing( e->key );\n\tStripTrailing( e->value );\n\n\treturn e;\n}\n\n\n/*\n================\nParseEntity\n================\n*/\nqboolean\tParseEntity( void ) {\n\tepair_t\t\t*e;\n\tentity_t\t*mapent;\n\n\tif ( !GetToken (qtrue) ) {\n\t\treturn qfalse;\n\t}\n\n\tif ( strcmp (token, \"{\") ) {\n\t\tError (\"ParseEntity: { not found\");\n\t}\n\tif ( num_entities == MAX_MAP_ENTITIES ) {\n\t\tError (\"num_entities == MAX_MAP_ENTITIES\");\n\t}\n\tmapent = &entities[num_entities];\n\tnum_entities++;\n\n\tdo {\n\t\tif ( !GetToken (qtrue) ) {\n\t\t\tError (\"ParseEntity: EOF without closing brace\");\n\t\t}\n\t\tif ( !strcmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\t\te = ParseEpair ();\n\t\te->next = mapent->epairs;\n\t\tmapent->epairs = e;\n\t} while (1);\n\t\n\treturn qtrue;\n}\n\n/*\n================\nParseEntities\n\nParses the dentdata string into entities\n================\n*/\nvoid ParseEntities( void ) {\n\tnum_entities = 0;\n\tParseFromMemory( dentdata, entdatasize );\n\n\twhile ( ParseEntity () ) {\n\t}\t\n}\n\n\n/*\n================\nUnparseEntities\n\nGenerates the dentdata string from all the entities\nThis allows the utilities to add or remove key/value pairs\nto the data created by the map editor.\n================\n*/\nvoid UnparseEntities( void ) {\n\tchar\t*buf, *end;\n\tepair_t\t*ep;\n\tchar\tline[2048];\n\tint\t\ti;\n\tchar\tkey[1024], value[1024];\n\n\tbuf = dentdata;\n\tend = buf;\n\t*end = 0;\n\t\n\tfor (i=0 ; i<num_entities ; i++) {\n\t\tep = entities[i].epairs;\n\t\tif ( !ep ) {\n\t\t\tcontinue;\t// ent got removed\n\t\t}\n\t\t\n\t\tstrcat (end,\"{\\n\");\n\t\tend += 2;\n\t\t\t\t\n\t\tfor ( ep = entities[i].epairs ; ep ; ep=ep->next ) {\n\t\t\tstrcpy (key, ep->key);\n\t\t\tStripTrailing (key);\n\t\t\tstrcpy (value, ep->value);\n\t\t\tStripTrailing (value);\n\t\t\t\t\n\t\t\tsprintf (line, \"\\\"%s\\\" \\\"%s\\\"\\n\", key, value);\n\t\t\tstrcat (end, line);\n\t\t\tend += strlen(line);\n\t\t}\n\t\tstrcat (end,\"}\\n\");\n\t\tend += 2;\n\n\t\tif (end > buf + MAX_MAP_ENTSTRING) {\n\t\t\tError (\"Entity text too long\");\n\t\t}\n\t}\n\tentdatasize = end - buf + 1;\n}\n\nvoid PrintEntity( const entity_t *ent ) {\n\tepair_t\t*ep;\n\t\n\tprintf (\"------- entity %p -------\\n\", ent);\n\tfor (ep=ent->epairs ; ep ; ep=ep->next) {\n\t\tprintf( \"%s = %s\\n\", ep->key, ep->value );\n\t}\n\n}\n\nvoid \tSetKeyValue( entity_t *ent, const char *key, const char *value ) {\n\tepair_t\t*ep;\n\t\n\tfor ( ep=ent->epairs ; ep ; ep=ep->next ) {\n\t\tif ( !strcmp (ep->key, key) ) {\n\t\t\tfree (ep->value);\n\t\t\tep->value = copystring(value);\n\t\t\treturn;\n\t\t}\n\t}\n\tep = malloc (sizeof(*ep));\n\tep->next = ent->epairs;\n\tent->epairs = ep;\n\tep->key = copystring(key);\n\tep->value = copystring(value);\n}\n\nconst char \t*ValueForKey( const entity_t *ent, const char *key ) {\n\tepair_t\t*ep;\n\t\n\tfor (ep=ent->epairs ; ep ; ep=ep->next) {\n\t\tif (!strcmp (ep->key, key) ) {\n\t\t\treturn ep->value;\n\t\t}\n\t}\n\treturn \"\";\n}\n\nvec_t\tFloatForKey( const entity_t *ent, const char *key ) {\n\tconst char\t*k;\n\t\n\tk = ValueForKey( ent, key );\n\treturn atof(k);\n}\n\nvoid \tGetVectorForKey( const entity_t *ent, const char *key, vec3_t vec ) {\n\tconst char\t*k;\n\tdouble\tv1, v2, v3;\n\n\tk = ValueForKey (ent, key);\n\n\t// scanf into doubles, then assign, so it is vec_t size independent\n\tv1 = v2 = v3 = 0;\n\tsscanf (k, \"%lf %lf %lf\", &v1, &v2, &v3);\n\tvec[0] = v1;\n\tvec[1] = v2;\n\tvec[2] = v3;\n}\n\n\n"
  },
  {
    "path": "common/bspfile.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifdef _TTIMOBUILD\n#include \"qfiles.h\"\n#include \"surfaceflags.h\"\n#else\n#include \"../code/qcommon/qfiles.h\"\n#include \"../code/game/surfaceflags.h\"\n#endif\n\nextern\tint\t\t\tnummodels;\nextern\tdmodel_t\tdmodels[MAX_MAP_MODELS];\n\nextern\tint\t\t\tnumShaders;\nextern\tdshader_t\tdshaders[MAX_MAP_MODELS];\n\nextern\tint\t\t\tentdatasize;\nextern\tchar\t\tdentdata[MAX_MAP_ENTSTRING];\n\nextern\tint\t\t\tnumleafs;\nextern\tdleaf_t\t\tdleafs[MAX_MAP_LEAFS];\n\nextern\tint\t\t\tnumplanes;\nextern\tdplane_t\tdplanes[MAX_MAP_PLANES];\n\nextern\tint\t\t\tnumnodes;\nextern\tdnode_t\t\tdnodes[MAX_MAP_NODES];\n\nextern\tint\t\t\tnumleafsurfaces;\nextern\tint\t\t\tdleafsurfaces[MAX_MAP_LEAFFACES];\n\nextern\tint\t\t\tnumleafbrushes;\nextern\tint\t\t\tdleafbrushes[MAX_MAP_LEAFBRUSHES];\n\nextern\tint\t\t\tnumbrushes;\nextern\tdbrush_t\tdbrushes[MAX_MAP_BRUSHES];\n\nextern\tint\t\t\tnumbrushsides;\nextern\tdbrushside_t\tdbrushsides[MAX_MAP_BRUSHSIDES];\n\nextern\tint\t\t\tnumLightBytes;\nextern\tbyte\t\tlightBytes[MAX_MAP_LIGHTING];\n\nextern\tint\t\t\tnumGridPoints;\nextern\tbyte\t\tgridData[MAX_MAP_LIGHTGRID];\n\nextern\tint\t\t\tnumVisBytes;\nextern\tbyte\t\tvisBytes[MAX_MAP_VISIBILITY];\n\nextern\tint\t\t\tnumDrawVerts;\nextern\tdrawVert_t\tdrawVerts[MAX_MAP_DRAW_VERTS];\n\nextern\tint\t\t\tnumDrawIndexes;\nextern\tint\t\t\tdrawIndexes[MAX_MAP_DRAW_INDEXES];\n\nextern\tint\t\t\tnumDrawSurfaces;\nextern\tdsurface_t\tdrawSurfaces[MAX_MAP_DRAW_SURFS];\n\nextern\tint\t\t\tnumFogs;\nextern\tdfog_t\t\tdfogs[MAX_MAP_FOGS];\n\nvoid\tLoadBSPFile( const char *filename );\nvoid\tWriteBSPFile( const char *filename );\nvoid\tPrintBSPFileSizes( void );\n\n//===============\n\n\ntypedef struct epair_s {\n\tstruct epair_s\t*next;\n\tchar\t*key;\n\tchar\t*value;\n} epair_t;\n\ntypedef struct {\n\tvec3_t\t\torigin;\n\tstruct bspbrush_s\t*brushes;\n\tstruct parseMesh_s\t*patches;\n\tint\t\t\tfirstDrawSurf;\n\tepair_t\t\t*epairs;\n} entity_t;\n\nextern\tint\t\t\tnum_entities;\nextern\tentity_t\tentities[MAX_MAP_ENTITIES];\n\nvoid\tParseEntities( void );\nvoid\tUnparseEntities( void );\n\nvoid \tSetKeyValue( entity_t *ent, const char *key, const char *value );\nconst char \t*ValueForKey( const entity_t *ent, const char *key );\n// will return \"\" if not present\n\nvec_t\tFloatForKey( const entity_t *ent, const char *key );\nvoid \tGetVectorForKey( const entity_t *ent, const char *key, vec3_t vec );\n\nepair_t *ParseEpair( void );\n\nvoid\tPrintEntity( const entity_t *ent );\n\n"
  },
  {
    "path": "common/cmdlib.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// cmdlib.c\n\n#include \"cmdlib.h\"\n#include <sys/types.h>\n#include <sys/stat.h>\n\n#ifdef WIN32\n#include <direct.h>\n#include <windows.h>\n#endif\n\n#ifdef NeXT\n#include <libc.h>\n#endif\n\n#define\tBASEDIRNAME\t\"quake\"\t\t// assumed to have a 2 or 3 following\n#define PATHSEPERATOR   '/'\n\n// set these before calling CheckParm\nint myargc;\nchar **myargv;\n\nchar\t\tcom_token[1024];\nqboolean\tcom_eof;\n\nqboolean\t\tarchive;\nchar\t\t\tarchivedir[1024];\n\n\n/*\n===================\nExpandWildcards\n\nMimic unix command line expansion\n===================\n*/\n#define\tMAX_EX_ARGC\t1024\nint\t\tex_argc;\nchar\t*ex_argv[MAX_EX_ARGC];\n#ifdef _WIN32\n#include \"io.h\"\nvoid ExpandWildcards( int *argc, char ***argv )\n{\n\tstruct _finddata_t fileinfo;\n\tint\t\thandle;\n\tint\t\ti;\n\tchar\tfilename[1024];\n\tchar\tfilebase[1024];\n\tchar\t*path;\n\n\tex_argc = 0;\n\tfor (i=0 ; i<*argc ; i++)\n\t{\n\t\tpath = (*argv)[i];\n\t\tif ( path[0] == '-'\n\t\t\t|| ( !strstr(path, \"*\") && !strstr(path, \"?\") ) )\n\t\t{\n\t\t\tex_argv[ex_argc++] = path;\n\t\t\tcontinue;\n\t\t}\n\n\t\thandle = _findfirst (path, &fileinfo);\n\t\tif (handle == -1)\n\t\t\treturn;\n\n\t\tExtractFilePath (path, filebase);\n\n\t\tdo\n\t\t{\n\t\t\tsprintf (filename, \"%s%s\", filebase, fileinfo.name);\n\t\t\tex_argv[ex_argc++] = copystring (filename);\n\t\t} while (_findnext( handle, &fileinfo ) != -1);\n\n\t\t_findclose (handle);\n\t}\n\n\t*argc = ex_argc;\n\t*argv = ex_argv;\n}\n#else\nvoid ExpandWildcards (int *argc, char ***argv)\n{\n}\n#endif\n\n#ifdef WIN_ERROR\n#include <windows.h>\n/*\n=================\nError\n\nFor abnormal program terminations in windowed apps\n=================\n*/\nvoid Error( const char *error, ... )\n{\n\tva_list argptr;\n\tchar\ttext[1024];\n\tchar\ttext2[1024];\n\tint\t\terr;\n\n\terr = GetLastError ();\n\n\tva_start (argptr,error);\n\tvsprintf (text, error,argptr);\n\tva_end (argptr);\n\n\tsprintf (text2, \"%s\\nGetLastError() = %i\", text, err);\n    MessageBox(NULL, text2, \"Error\", 0 /* MB_OK */ );\n\n\texit (1);\n}\n\n#else\n/*\n=================\nError\n\nFor abnormal program terminations in console apps\n=================\n*/\nvoid Error( const char *error, ...)\n{\n\tva_list argptr;\n\n\t_printf (\"\\n************ ERROR ************\\n\");\n\n\tva_start (argptr,error);\n\tvprintf (error,argptr);\n\tva_end (argptr);\n\t_printf (\"\\r\\n\");\n\n\texit (1);\n}\n#endif\n\n// only printf if in verbose mode\nqboolean verbose = qfalse;\nvoid qprintf( const char *format, ... ) {\n\tva_list argptr;\n\n\tif (!verbose)\n\t\treturn;\n\n\tva_start (argptr,format);\n\tvprintf (format,argptr);\n\tva_end (argptr);\n\n}\n\n#ifdef WIN32\nHWND hwndOut = NULL;\nqboolean lookedForServer = qfalse;\nUINT wm_BroadcastCommand = -1;\n#endif\n\nvoid _printf( const char *format, ... ) {\n\tva_list argptr;\n  char text[4096];\n  ATOM a;\n\n\tva_start (argptr,format);\n\tvsprintf (text, format, argptr);\n\tva_end (argptr);\n\n  printf(text);\n\n#ifdef WIN32\n  if (!lookedForServer) {\n    lookedForServer = qtrue;\n    hwndOut = FindWindow(NULL, \"Q3Map Process Server\");\n    if (hwndOut) {\n      wm_BroadcastCommand = RegisterWindowMessage( \"Q3MPS_BroadcastCommand\" );\n    }\n  }\n  if (hwndOut) {\n    a = GlobalAddAtom(text);\n    PostMessage(hwndOut, wm_BroadcastCommand, 0, (LPARAM)a);\n  }\n#endif\n}\n\n\n/*\n\nqdir will hold the path up to the quake directory, including the slash\n\n  f:\\quake\\\n  /raid/quake/\n\ngamedir will hold qdir + the game directory (id1, id2, etc)\n\n  */\n\nchar\t\tqdir[1024];\nchar\t\tgamedir[1024];\nchar\t\twritedir[1024];\n\nvoid SetQdirFromPath( const char *path )\n{\n\tchar\ttemp[1024];\n\tconst char\t*c;\n  const char *sep;\n\tint\t\tlen, count;\n\n\tif (!(path[0] == '/' || path[0] == '\\\\' || path[1] == ':'))\n\t{\t// path is partial\n\t\tQ_getwd (temp);\n\t\tstrcat (temp, path);\n\t\tpath = temp;\n\t}\n\n\t// search for \"quake2\" in path\n\n\tlen = strlen(BASEDIRNAME);\n\tfor (c=path+strlen(path)-1 ; c != path ; c--)\n\t{\n\t\tint i;\n\n\t\tif (!Q_strncasecmp (c, BASEDIRNAME, len))\n\t\t{\n      //\n\t\t\t//strncpy (qdir, path, c+len+2-path);\n      // the +2 assumes a 2 or 3 following quake which is not the\n      // case with a retail install\n      // so we need to add up how much to the next separator\n      sep = c + len;\n      count = 1;\n      while (*sep && *sep != '/' && *sep != '\\\\')\n      {\n        sep++;\n        count++;\n      }\n\t\t\tstrncpy (qdir, path, c+len+count-path);\n\t\t\tqprintf (\"qdir: %s\\n\", qdir);\n\t\t\tfor ( i = 0; i < strlen( qdir ); i++ )\n\t\t\t{\n\t\t\t\tif ( qdir[i] == '\\\\' ) \n\t\t\t\t\tqdir[i] = '/';\n\t\t\t}\n\n\t\t\tc += len+count;\n\t\t\twhile (*c)\n\t\t\t{\n\t\t\t\tif (*c == '/' || *c == '\\\\')\n\t\t\t\t{\n\t\t\t\t\tstrncpy (gamedir, path, c+1-path);\n\n\t\t\t\t\tfor ( i = 0; i < strlen( gamedir ); i++ )\n\t\t\t\t\t{\n\t\t\t\t\t\tif ( gamedir[i] == '\\\\' ) \n\t\t\t\t\t\t\tgamedir[i] = '/';\n\t\t\t\t\t}\n\n\t\t\t\t\tqprintf (\"gamedir: %s\\n\", gamedir);\n\n\t\t\t\t\tif ( !writedir[0] )\n\t\t\t\t\t\tstrcpy( writedir, gamedir );\n\t\t\t\t\telse if ( writedir[strlen( writedir )-1] != '/' )\n\t\t\t\t\t{\n\t\t\t\t\t\twritedir[strlen( writedir )] = '/';\n\t\t\t\t\t\twritedir[strlen( writedir )+1] = 0;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tc++;\n\t\t\t}\n\t\t\tError (\"No gamedir in %s\", path);\n\t\t\treturn;\n\t\t}\n\t}\n\tError (\"SetQdirFromPath: no '%s' in %s\", BASEDIRNAME, path);\n}\n\nchar *ExpandArg (const char *path)\n{\n\tstatic char full[1024];\n\n\tif (path[0] != '/' && path[0] != '\\\\' && path[1] != ':')\n\t{\n\t\tQ_getwd (full);\n\t\tstrcat (full, path);\n\t}\n\telse\n\t\tstrcpy (full, path);\n\treturn full;\n}\n\nchar *ExpandPath (const char *path)\n{\n\tstatic char full[1024];\n\tif (!qdir)\n\t\tError (\"ExpandPath called without qdir set\");\n\tif (path[0] == '/' || path[0] == '\\\\' || path[1] == ':') {\n\t\tstrcpy( full, path );\n\t\treturn full;\n\t}\n\tsprintf (full, \"%s%s\", qdir, path);\n\treturn full;\n}\n\nchar *ExpandGamePath (const char *path)\n{\n\tstatic char full[1024];\n\tif (!qdir)\n\t\tError (\"ExpandGamePath called without qdir set\");\n\tif (path[0] == '/' || path[0] == '\\\\' || path[1] == ':') {\n\t\tstrcpy( full, path );\n\t\treturn full;\n\t}\n\tsprintf (full, \"%s%s\", gamedir, path);\n\treturn full;\n}\n\nchar *ExpandPathAndArchive (const char *path)\n{\n\tchar\t*expanded;\n\tchar\tarchivename[1024];\n\n\texpanded = ExpandPath (path);\n\n\tif (archive)\n\t{\n\t\tsprintf (archivename, \"%s/%s\", archivedir, path);\n\t\tQCopyFile (expanded, archivename);\n\t}\n\treturn expanded;\n}\n\n\nchar *copystring(const char *s)\n{\n\tchar\t*b;\n\tb = malloc(strlen(s)+1);\n\tstrcpy (b, s);\n\treturn b;\n}\n\n\n\n/*\n================\nI_FloatTime\n================\n*/\ndouble I_FloatTime (void)\n{\n\ttime_t\tt;\n\t\n\ttime (&t);\n\t\n\treturn t;\n#if 0\n// more precise, less portable\n\tstruct timeval tp;\n\tstruct timezone tzp;\n\tstatic int\t\tsecbase;\n\n\tgettimeofday(&tp, &tzp);\n\t\n\tif (!secbase)\n\t{\n\t\tsecbase = tp.tv_sec;\n\t\treturn tp.tv_usec/1000000.0;\n\t}\n\t\n\treturn (tp.tv_sec - secbase) + tp.tv_usec/1000000.0;\n#endif\n}\n\nvoid Q_getwd (char *out)\n{\n\tint i = 0;\n\n#ifdef WIN32\n   _getcwd (out, 256);\n   strcat (out, \"\\\\\");\n#else\n   getwd (out);\n   strcat (out, \"/\");\n#endif\n\n   while ( out[i] != 0 )\n   {\n\t   if ( out[i] == '\\\\' )\n\t\t   out[i] = '/';\n\t   i++;\n   }\n}\n\n\nvoid Q_mkdir (const char *path)\n{\n#ifdef WIN32\n\tif (_mkdir (path) != -1)\n\t\treturn;\n#else\n\tif (mkdir (path, 0777) != -1)\n\t\treturn;\n#endif\n\tif (errno != EEXIST)\n\t\tError (\"mkdir %s: %s\",path, strerror(errno));\n}\n\n/*\n============\nFileTime\n\nreturns -1 if not present\n============\n*/\nint\tFileTime (const char *path)\n{\n\tstruct\tstat\tbuf;\n\t\n\tif (stat (path,&buf) == -1)\n\t\treturn -1;\n\t\n\treturn buf.st_mtime;\n}\n\n\n\n/*\n==============\nCOM_Parse\n\nParse a token out of a string\n==============\n*/\nchar *COM_Parse (char *data)\n{\n\tint\t\tc;\n\tint\t\tlen;\n\t\n\tlen = 0;\n\tcom_token[0] = 0;\n\t\n\tif (!data)\n\t\treturn NULL;\n\t\t\n// skip whitespace\nskipwhite:\n\twhile ( (c = *data) <= ' ')\n\t{\n\t\tif (c == 0)\n\t\t{\n\t\t\tcom_eof = qtrue;\n\t\t\treturn NULL;\t\t\t// end of file;\n\t\t}\n\t\tdata++;\n\t}\n\t\n// skip // comments\n\tif (c=='/' && data[1] == '/')\n\t{\n\t\twhile (*data && *data != '\\n')\n\t\t\tdata++;\n\t\tgoto skipwhite;\n\t}\n\t\n\n// handle quoted strings specially\n\tif (c == '\\\"')\n\t{\n\t\tdata++;\n\t\tdo\n\t\t{\n\t\t\tc = *data++;\n\t\t\tif (c=='\\\"')\n\t\t\t{\n\t\t\t\tcom_token[len] = 0;\n\t\t\t\treturn data;\n\t\t\t}\n\t\t\tcom_token[len] = c;\n\t\t\tlen++;\n\t\t} while (1);\n\t}\n\n// parse single characters\n\tif (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\\'' || c==':')\n\t{\n\t\tcom_token[len] = c;\n\t\tlen++;\n\t\tcom_token[len] = 0;\n\t\treturn data+1;\n\t}\n\n// parse a regular word\n\tdo\n\t{\n\t\tcom_token[len] = c;\n\t\tdata++;\n\t\tlen++;\n\t\tc = *data;\n\tif (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\\'' || c==':')\n\t\t\tbreak;\n\t} while (c>32);\n\t\n\tcom_token[len] = 0;\n\treturn data;\n}\n\n\nint Q_strncasecmp (const char *s1, const char *s2, int n)\n{\n\tint\t\tc1, c2;\n\t\n\tdo\n\t{\n\t\tc1 = *s1++;\n\t\tc2 = *s2++;\n\n\t\tif (!n--)\n\t\t\treturn 0;\t\t// strings are equal until end point\n\t\t\n\t\tif (c1 != c2)\n\t\t{\n\t\t\tif (c1 >= 'a' && c1 <= 'z')\n\t\t\t\tc1 -= ('a' - 'A');\n\t\t\tif (c2 >= 'a' && c2 <= 'z')\n\t\t\t\tc2 -= ('a' - 'A');\n\t\t\tif (c1 != c2)\n\t\t\t\treturn -1;\t\t// strings not equal\n\t\t}\n\t} while (c1);\n\t\n\treturn 0;\t\t// strings are equal\n}\n\nint Q_stricmp (const char *s1, const char *s2)\n{\n\treturn Q_strncasecmp (s1, s2, 99999);\n}\n\n\nchar *strupr (char *start)\n{\n\tchar\t*in;\n\tin = start;\n\twhile (*in)\n\t{\n\t\t*in = toupper(*in);\n\t\tin++;\n\t}\n\treturn start;\n}\n\nchar *strlower (char *start)\n{\n\tchar\t*in;\n\tin = start;\n\twhile (*in)\n\t{\n\t\t*in = tolower(*in); \n\t\tin++;\n\t}\n\treturn start;\n}\n\n\n/*\n=============================================================================\n\n\t\t\t\t\t\tMISC FUNCTIONS\n\n=============================================================================\n*/\n\n\n/*\n=================\nCheckParm\n\nChecks for the given parameter in the program's command line arguments\nReturns the argument number (1 to argc-1) or 0 if not present\n=================\n*/\nint CheckParm (const char *check)\n{\n\tint             i;\n\n\tfor (i = 1;i<myargc;i++)\n\t{\n\t\tif ( !Q_stricmp(check, myargv[i]) )\n\t\t\treturn i;\n\t}\n\n\treturn 0;\n}\n\n\n\n/*\n================\nQ_filelength\n================\n*/\nint Q_filelength (FILE *f)\n{\n\tint\t\tpos;\n\tint\t\tend;\n\n\tpos = ftell (f);\n\tfseek (f, 0, SEEK_END);\n\tend = ftell (f);\n\tfseek (f, pos, SEEK_SET);\n\n\treturn end;\n}\n\n\nFILE *SafeOpenWrite (const char *filename)\n{\n\tFILE\t*f;\n\n\tf = fopen(filename, \"wb\");\n\n\tif (!f)\n\t\tError (\"Error opening %s: %s\",filename,strerror(errno));\n\n\treturn f;\n}\n\nFILE *SafeOpenRead (const char *filename)\n{\n\tFILE\t*f;\n\n\tf = fopen(filename, \"rb\");\n\n\tif (!f)\n\t\tError (\"Error opening %s: %s\",filename,strerror(errno));\n\n\treturn f;\n}\n\n\nvoid SafeRead (FILE *f, void *buffer, int count)\n{\n\tif ( fread (buffer, 1, count, f) != (size_t)count)\n\t\tError (\"File read failure\");\n}\n\n\nvoid SafeWrite (FILE *f, const void *buffer, int count)\n{\n\tif (fwrite (buffer, 1, count, f) != (size_t)count)\n\t\tError (\"File write failure\");\n}\n\n\n/*\n==============\nFileExists\n==============\n*/\nqboolean\tFileExists (const char *filename)\n{\n\tFILE\t*f;\n\n\tf = fopen (filename, \"r\");\n\tif (!f)\n\t\treturn qfalse;\n\tfclose (f);\n\treturn qtrue;\n}\n\n/*\n==============\nLoadFile\n==============\n*/\nint    LoadFile( const char *filename, void **bufferptr )\n{\n\tFILE\t*f;\n\tint    length;\n\tvoid    *buffer;\n\n\tf = SafeOpenRead (filename);\n\tlength = Q_filelength (f);\n\tbuffer = malloc (length+1);\n\t((char *)buffer)[length] = 0;\n\tSafeRead (f, buffer, length);\n\tfclose (f);\n\n\t*bufferptr = buffer;\n\treturn length;\n}\n\n\n/*\n==============\nLoadFileBlock\n-\nrounds up memory allocation to 4K boundry\n-\n==============\n*/\nint    LoadFileBlock( const char *filename, void **bufferptr )\n{\n\tFILE\t*f;\n\tint    length, nBlock, nAllocSize;\n\tvoid    *buffer;\n\n\tf = SafeOpenRead (filename);\n\tlength = Q_filelength (f);\n  nAllocSize = length;\n  nBlock = nAllocSize % MEM_BLOCKSIZE;\n  if ( nBlock > 0) {\n    nAllocSize += MEM_BLOCKSIZE - nBlock;\n  }\n\tbuffer = malloc (nAllocSize+1);\n  memset(buffer, 0, nAllocSize+1);\n\tSafeRead (f, buffer, length);\n\tfclose (f);\n\n\t*bufferptr = buffer;\n\treturn length;\n}\n\n\n/*\n==============\nTryLoadFile\n\nAllows failure\n==============\n*/\nint    TryLoadFile (const char *filename, void **bufferptr)\n{\n\tFILE\t*f;\n\tint    length;\n\tvoid    *buffer;\n\n\t*bufferptr = NULL;\n\n\tf = fopen (filename, \"rb\");\n\tif (!f)\n\t\treturn -1;\n\tlength = Q_filelength (f);\n\tbuffer = malloc (length+1);\n\t((char *)buffer)[length] = 0;\n\tSafeRead (f, buffer, length);\n\tfclose (f);\n\n\t*bufferptr = buffer;\n\treturn length;\n}\n\n\n/*\n==============\nSaveFile\n==============\n*/\nvoid    SaveFile (const char *filename, const void *buffer, int count)\n{\n\tFILE\t*f;\n\n\tf = SafeOpenWrite (filename);\n\tSafeWrite (f, buffer, count);\n\tfclose (f);\n}\n\n\n\nvoid DefaultExtension (char *path, const char *extension)\n{\n\tchar    *src;\n//\n// if path doesnt have a .EXT, append extension\n// (extension should include the .)\n//\n\tsrc = path + strlen(path) - 1;\n\n\twhile (*src != '/' && *src != '\\\\' && src != path)\n\t{\n\t\tif (*src == '.')\n\t\t\treturn;                 // it has an extension\n\t\tsrc--;\n\t}\n\n\tstrcat (path, extension);\n}\n\n\nvoid DefaultPath (char *path, const char *basepath)\n{\n\tchar    temp[128];\n\n\tif (path[0] == PATHSEPERATOR)\n\t\treturn;                   // absolute path location\n\tstrcpy (temp,path);\n\tstrcpy (path,basepath);\n\tstrcat (path,temp);\n}\n\n\nvoid    StripFilename (char *path)\n{\n\tint             length;\n\n\tlength = strlen(path)-1;\n\twhile (length > 0 && path[length] != PATHSEPERATOR)\n\t\tlength--;\n\tpath[length] = 0;\n}\n\nvoid    StripExtension (char *path)\n{\n\tint             length;\n\n\tlength = strlen(path)-1;\n\twhile (length > 0 && path[length] != '.')\n\t{\n\t\tlength--;\n\t\tif (path[length] == '/')\n\t\t\treturn;\t\t// no extension\n\t}\n\tif (length)\n\t\tpath[length] = 0;\n}\n\n\n/*\n====================\nExtract file parts\n====================\n*/\n// FIXME: should include the slash, otherwise\n// backing to an empty path will be wrong when appending a slash\nvoid ExtractFilePath (const char *path, char *dest)\n{\n\tconst char    *src;\n\n\tsrc = path + strlen(path) - 1;\n\n//\n// back up until a \\ or the start\n//\n\twhile (src != path && *(src-1) != '\\\\' && *(src-1) != '/')\n\t\tsrc--;\n\n\tmemcpy (dest, path, src-path);\n\tdest[src-path] = 0;\n}\n\nvoid ExtractFileBase (const char *path, char *dest)\n{\n\tconst char    *src;\n\n\tsrc = path + strlen(path) - 1;\n\n//\n// back up until a \\ or the start\n//\n\twhile (src != path && *(src-1) != PATHSEPERATOR)\n\t\tsrc--;\n\n\twhile (*src && *src != '.')\n\t{\n\t\t*dest++ = *src++;\n\t}\n\t*dest = 0;\n}\n\nvoid ExtractFileExtension (const char *path, char *dest)\n{\n\tconst char    *src;\n\n\tsrc = path + strlen(path) - 1;\n\n//\n// back up until a . or the start\n//\n\twhile (src != path && *(src-1) != '.')\n\t\tsrc--;\n\tif (src == path)\n\t{\n\t\t*dest = 0;\t// no extension\n\t\treturn;\n\t}\n\n\tstrcpy (dest,src);\n}\n\n\n/*\n==============\nParseNum / ParseHex\n==============\n*/\nint ParseHex (const char *hex)\n{\n\tconst char    *str;\n\tint    num;\n\n\tnum = 0;\n\tstr = hex;\n\n\twhile (*str)\n\t{\n\t\tnum <<= 4;\n\t\tif (*str >= '0' && *str <= '9')\n\t\t\tnum += *str-'0';\n\t\telse if (*str >= 'a' && *str <= 'f')\n\t\t\tnum += 10 + *str-'a';\n\t\telse if (*str >= 'A' && *str <= 'F')\n\t\t\tnum += 10 + *str-'A';\n\t\telse\n\t\t\tError (\"Bad hex number: %s\",hex);\n\t\tstr++;\n\t}\n\n\treturn num;\n}\n\n\nint ParseNum (const char *str)\n{\n\tif (str[0] == '$')\n\t\treturn ParseHex (str+1);\n\tif (str[0] == '0' && str[1] == 'x')\n\t\treturn ParseHex (str+2);\n\treturn atol (str);\n}\n\n\n\n/*\n============================================================================\n\n\t\t\t\t\tBYTE ORDER FUNCTIONS\n\n============================================================================\n*/\n\n#ifdef _SGI_SOURCE\n#define\t__BIG_ENDIAN__\n#endif\n\n#ifdef __BIG_ENDIAN__\n\nshort   LittleShort (short l)\n{\n\tbyte    b1,b2;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\n\treturn (b1<<8) + b2;\n}\n\nshort   BigShort (short l)\n{\n\treturn l;\n}\n\n\nint    LittleLong (int l)\n{\n\tbyte    b1,b2,b3,b4;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\tb3 = (l>>16)&255;\n\tb4 = (l>>24)&255;\n\n\treturn ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;\n}\n\nint    BigLong (int l)\n{\n\treturn l;\n}\n\n\nfloat\tLittleFloat (float l)\n{\n\tunion {byte b[4]; float f;} in, out;\n\t\n\tin.f = l;\n\tout.b[0] = in.b[3];\n\tout.b[1] = in.b[2];\n\tout.b[2] = in.b[1];\n\tout.b[3] = in.b[0];\n\t\n\treturn out.f;\n}\n\nfloat\tBigFloat (float l)\n{\n\treturn l;\n}\n\n\n#else\n\n\nshort   BigShort (short l)\n{\n\tbyte    b1,b2;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\n\treturn (b1<<8) + b2;\n}\n\nshort   LittleShort (short l)\n{\n\treturn l;\n}\n\n\nint    BigLong (int l)\n{\n\tbyte    b1,b2,b3,b4;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\tb3 = (l>>16)&255;\n\tb4 = (l>>24)&255;\n\n\treturn ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;\n}\n\nint    LittleLong (int l)\n{\n\treturn l;\n}\n\nfloat\tBigFloat (float l)\n{\n\tunion {byte b[4]; float f;} in, out;\n\t\n\tin.f = l;\n\tout.b[0] = in.b[3];\n\tout.b[1] = in.b[2];\n\tout.b[2] = in.b[1];\n\tout.b[3] = in.b[0];\n\t\n\treturn out.f;\n}\n\nfloat\tLittleFloat (float l)\n{\n\treturn l;\n}\n\n\n#endif\n\n\n//=======================================================\n\n\n// FIXME: byte swap?\n\n// this is a 16 bit, non-reflected CRC using the polynomial 0x1021\n// and the initial and final xor values shown below...  in other words, the\n// CCITT standard CRC used by XMODEM\n\n#define CRC_INIT_VALUE\t0xffff\n#define CRC_XOR_VALUE\t0x0000\n\nstatic unsigned short crctable[256] =\n{\n\t0x0000,\t0x1021,\t0x2042,\t0x3063,\t0x4084,\t0x50a5,\t0x60c6,\t0x70e7,\n\t0x8108,\t0x9129,\t0xa14a,\t0xb16b,\t0xc18c,\t0xd1ad,\t0xe1ce,\t0xf1ef,\n\t0x1231,\t0x0210,\t0x3273,\t0x2252,\t0x52b5,\t0x4294,\t0x72f7,\t0x62d6,\n\t0x9339,\t0x8318,\t0xb37b,\t0xa35a,\t0xd3bd,\t0xc39c,\t0xf3ff,\t0xe3de,\n\t0x2462,\t0x3443,\t0x0420,\t0x1401,\t0x64e6,\t0x74c7,\t0x44a4,\t0x5485,\n\t0xa56a,\t0xb54b,\t0x8528,\t0x9509,\t0xe5ee,\t0xf5cf,\t0xc5ac,\t0xd58d,\n\t0x3653,\t0x2672,\t0x1611,\t0x0630,\t0x76d7,\t0x66f6,\t0x5695,\t0x46b4,\n\t0xb75b,\t0xa77a,\t0x9719,\t0x8738,\t0xf7df,\t0xe7fe,\t0xd79d,\t0xc7bc,\n\t0x48c4,\t0x58e5,\t0x6886,\t0x78a7,\t0x0840,\t0x1861,\t0x2802,\t0x3823,\n\t0xc9cc,\t0xd9ed,\t0xe98e,\t0xf9af,\t0x8948,\t0x9969,\t0xa90a,\t0xb92b,\n\t0x5af5,\t0x4ad4,\t0x7ab7,\t0x6a96,\t0x1a71,\t0x0a50,\t0x3a33,\t0x2a12,\n\t0xdbfd,\t0xcbdc,\t0xfbbf,\t0xeb9e,\t0x9b79,\t0x8b58,\t0xbb3b,\t0xab1a,\n\t0x6ca6,\t0x7c87,\t0x4ce4,\t0x5cc5,\t0x2c22,\t0x3c03,\t0x0c60,\t0x1c41,\n\t0xedae,\t0xfd8f,\t0xcdec,\t0xddcd,\t0xad2a,\t0xbd0b,\t0x8d68,\t0x9d49,\n\t0x7e97,\t0x6eb6,\t0x5ed5,\t0x4ef4,\t0x3e13,\t0x2e32,\t0x1e51,\t0x0e70,\n\t0xff9f,\t0xefbe,\t0xdfdd,\t0xcffc,\t0xbf1b,\t0xaf3a,\t0x9f59,\t0x8f78,\n\t0x9188,\t0x81a9,\t0xb1ca,\t0xa1eb,\t0xd10c,\t0xc12d,\t0xf14e,\t0xe16f,\n\t0x1080,\t0x00a1,\t0x30c2,\t0x20e3,\t0x5004,\t0x4025,\t0x7046,\t0x6067,\n\t0x83b9,\t0x9398,\t0xa3fb,\t0xb3da,\t0xc33d,\t0xd31c,\t0xe37f,\t0xf35e,\n\t0x02b1,\t0x1290,\t0x22f3,\t0x32d2,\t0x4235,\t0x5214,\t0x6277,\t0x7256,\n\t0xb5ea,\t0xa5cb,\t0x95a8,\t0x8589,\t0xf56e,\t0xe54f,\t0xd52c,\t0xc50d,\n\t0x34e2,\t0x24c3,\t0x14a0,\t0x0481,\t0x7466,\t0x6447,\t0x5424,\t0x4405,\n\t0xa7db,\t0xb7fa,\t0x8799,\t0x97b8,\t0xe75f,\t0xf77e,\t0xc71d,\t0xd73c,\n\t0x26d3,\t0x36f2,\t0x0691,\t0x16b0,\t0x6657,\t0x7676,\t0x4615,\t0x5634,\n\t0xd94c,\t0xc96d,\t0xf90e,\t0xe92f,\t0x99c8,\t0x89e9,\t0xb98a,\t0xa9ab,\n\t0x5844,\t0x4865,\t0x7806,\t0x6827,\t0x18c0,\t0x08e1,\t0x3882,\t0x28a3,\n\t0xcb7d,\t0xdb5c,\t0xeb3f,\t0xfb1e,\t0x8bf9,\t0x9bd8,\t0xabbb,\t0xbb9a,\n\t0x4a75,\t0x5a54,\t0x6a37,\t0x7a16,\t0x0af1,\t0x1ad0,\t0x2ab3,\t0x3a92,\n\t0xfd2e,\t0xed0f,\t0xdd6c,\t0xcd4d,\t0xbdaa,\t0xad8b,\t0x9de8,\t0x8dc9,\n\t0x7c26,\t0x6c07,\t0x5c64,\t0x4c45,\t0x3ca2,\t0x2c83,\t0x1ce0,\t0x0cc1,\n\t0xef1f,\t0xff3e,\t0xcf5d,\t0xdf7c,\t0xaf9b,\t0xbfba,\t0x8fd9,\t0x9ff8,\n\t0x6e17,\t0x7e36,\t0x4e55,\t0x5e74,\t0x2e93,\t0x3eb2,\t0x0ed1,\t0x1ef0\n};\n\nvoid CRC_Init(unsigned short *crcvalue)\n{\n\t*crcvalue = CRC_INIT_VALUE;\n}\n\nvoid CRC_ProcessByte(unsigned short *crcvalue, byte data)\n{\n\t*crcvalue = (*crcvalue << 8) ^ crctable[(*crcvalue >> 8) ^ data];\n}\n\nunsigned short CRC_Value(unsigned short crcvalue)\n{\n\treturn crcvalue ^ CRC_XOR_VALUE;\n}\n//=============================================================================\n\n/*\n============\nCreatePath\n============\n*/\nvoid\tCreatePath (const char *path)\n{\n\tconst char\t*ofs;\n\tchar\t\tc;\n\tchar\t\tdir[1024];\n\n#ifdef _WIN32\n\tint\t\tolddrive = -1;\n\n\tif ( path[1] == ':' )\n\t{\n\t\tolddrive = _getdrive();\n\t\t_chdrive( toupper( path[0] ) - 'A' + 1 );\n\t}\n#endif\n\n\tif (path[1] == ':')\n\t\tpath += 2;\n\n\tfor (ofs = path+1 ; *ofs ; ofs++)\n\t{\n\t\tc = *ofs;\n\t\tif (c == '/' || c == '\\\\')\n\t\t{\t// create the directory\n\t\t\tmemcpy( dir, path, ofs - path );\n\t\t\tdir[ ofs - path ] = 0;\n\t\t\tQ_mkdir( dir );\n\t\t}\n\t}\n\n#ifdef _WIN32\n\tif ( olddrive != -1 )\n\t{\n\t\t_chdrive( olddrive );\n\t}\n#endif\n}\n\n\n/*\n============\nQCopyFile\n\n  Used to archive source files\n============\n*/\nvoid QCopyFile (const char *from, const char *to)\n{\n\tvoid\t*buffer;\n\tint\t\tlength;\n\n\tlength = LoadFile (from, &buffer);\n\tCreatePath (to);\n\tSaveFile (to, buffer, length);\n\tfree (buffer);\n}\n"
  },
  {
    "path": "common/cmdlib.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// cmdlib.h\n\n#ifndef __CMDLIB__\n#define __CMDLIB__\n\n#ifdef _WIN32\n#pragma warning(disable : 4244)     // MIPS\n#pragma warning(disable : 4136)     // X86\n#pragma warning(disable : 4051)     // ALPHA\n\n#pragma warning(disable : 4018)     // signed/unsigned mismatch\n#pragma warning(disable : 4305)     // truncate from double to float\n\n#pragma check_stack(off)\n\n#endif\n\n#include <stdio.h>\n#include <string.h>\n#include <stdlib.h>\n#include <errno.h>\n#include <ctype.h>\n#include <time.h>\n#include <stdarg.h>\n\n#ifdef _WIN32\n\n#pragma intrinsic( memset, memcpy )\n\n#endif\n\n#ifndef __BYTEBOOL__\n#define __BYTEBOOL__\ntypedef enum { qfalse, qtrue } qboolean;\ntypedef unsigned char byte;\n#endif\n\n#define\tMAX_OS_PATH\t\t1024\n#define MEM_BLOCKSIZE 4096\n\n// the dec offsetof macro doesnt work very well...\n#define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier)\n\n\n// set these before calling CheckParm\nextern int myargc;\nextern char **myargv;\n\nchar *strupr (char *in);\nchar *strlower (char *in);\nint Q_strncasecmp( const char *s1, const char *s2, int n );\nint Q_stricmp( const char *s1, const char *s2 );\nvoid Q_getwd( char *out );\n\nint Q_filelength (FILE *f);\nint\tFileTime( const char *path );\n\nvoid\tQ_mkdir( const char *path );\n\nextern\tchar\t\tqdir[1024];\nextern\tchar\t\tgamedir[1024];\nextern  char\t\twritedir[1024];\nvoid SetQdirFromPath( const char *path );\nchar *ExpandArg( const char *path );\t// from cmd line\nchar *ExpandPath( const char *path );\t// from scripts\nchar *ExpandGamePath (const char *path);\nchar *ExpandPathAndArchive( const char *path );\n\n\ndouble I_FloatTime( void );\n\nvoid\tError( const char *error, ... );\nint\t\tCheckParm( const char *check );\n\nFILE\t*SafeOpenWrite( const char *filename );\nFILE\t*SafeOpenRead( const char *filename );\nvoid\tSafeRead (FILE *f, void *buffer, int count);\nvoid\tSafeWrite (FILE *f, const void *buffer, int count);\n\nint\t\tLoadFile( const char *filename, void **bufferptr );\nint   LoadFileBlock( const char *filename, void **bufferptr );\nint\t\tTryLoadFile( const char *filename, void **bufferptr );\nvoid\tSaveFile( const char *filename, const void *buffer, int count );\nqboolean\tFileExists( const char *filename );\n\nvoid \tDefaultExtension( char *path, const char *extension );\nvoid \tDefaultPath( char *path, const char *basepath );\nvoid \tStripFilename( char *path );\nvoid \tStripExtension( char *path );\n\nvoid \tExtractFilePath( const char *path, char *dest );\nvoid \tExtractFileBase( const char *path, char *dest );\nvoid\tExtractFileExtension( const char *path, char *dest );\n\nint \tParseNum (const char *str);\n\nshort\tBigShort (short l);\nshort\tLittleShort (short l);\nint\t\tBigLong (int l);\nint\t\tLittleLong (int l);\nfloat\tBigFloat (float l);\nfloat\tLittleFloat (float l);\n\n\nchar *COM_Parse (char *data);\n\nextern\tchar\t\tcom_token[1024];\nextern\tqboolean\tcom_eof;\n\nchar *copystring(const char *s);\n\n\nvoid CRC_Init(unsigned short *crcvalue);\nvoid CRC_ProcessByte(unsigned short *crcvalue, byte data);\nunsigned short CRC_Value(unsigned short crcvalue);\n\nvoid\tCreatePath( const char *path );\nvoid\tQCopyFile( const char *from, const char *to );\n\nextern\tqboolean\t\tarchive;\nextern\tchar\t\t\tarchivedir[1024];\n\n\nextern\tqboolean verbose;\nvoid qprintf( const char *format, ... );\nvoid _printf( const char *format, ... );\n\nvoid ExpandWildcards( int *argc, char ***argv );\n\n\n// for compression routines\ntypedef struct\n{\n\tvoid\t*data;\n\tint\t\tcount, width, height;\n} cblock_t;\n\n\n#endif\n"
  },
  {
    "path": "common/imagelib.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// imagelib.c\n\n#include \"cmdlib.h\"\n#include \"imagelib.h\"\n\n\nint fgetLittleShort (FILE *f)\n{\n\tbyte\tb1, b2;\n\n\tb1 = fgetc(f);\n\tb2 = fgetc(f);\n\n\treturn (short)(b1 + b2*256);\n}\n\nint fgetLittleLong (FILE *f)\n{\n\tbyte\tb1, b2, b3, b4;\n\n\tb1 = fgetc(f);\n\tb2 = fgetc(f);\n\tb3 = fgetc(f);\n\tb4 = fgetc(f);\n\n\treturn b1 + (b2<<8) + (b3<<16) + (b4<<24);\n}\n\n\n\n/*\n============================================================================\n\n\t\t\t\t\t\tLBM STUFF\n\n============================================================================\n*/\n\n\ntypedef unsigned char\tUBYTE;\n//conflicts with windows typedef short\t\t\tWORD;\ntypedef unsigned short\tUWORD;\ntypedef long\t\t\tLONG;\n\ntypedef enum\n{\n\tms_none,\n\tms_mask,\n\tms_transcolor,\n\tms_lasso\n} mask_t;\n\ntypedef enum\n{\n\tcm_none,\n\tcm_rle1\n} compress_t;\n\ntypedef struct\n{\n\tUWORD\t\tw,h;\n\tshort\t\tx,y;\n\tUBYTE\t\tnPlanes;\n\tUBYTE\t\tmasking;\n\tUBYTE\t\tcompression;\n\tUBYTE\t\tpad1;\n\tUWORD\t\ttransparentColor;\n\tUBYTE\t\txAspect,yAspect;\n\tshort\t\tpageWidth,pageHeight;\n} bmhd_t;\n\nextern\tbmhd_t\tbmhd;\t\t\t\t\t\t// will be in native byte order\n\n\n\n#define FORMID ('F'+('O'<<8)+((int)'R'<<16)+((int)'M'<<24))\n#define ILBMID ('I'+('L'<<8)+((int)'B'<<16)+((int)'M'<<24))\n#define PBMID  ('P'+('B'<<8)+((int)'M'<<16)+((int)' '<<24))\n#define BMHDID ('B'+('M'<<8)+((int)'H'<<16)+((int)'D'<<24))\n#define BODYID ('B'+('O'<<8)+((int)'D'<<16)+((int)'Y'<<24))\n#define CMAPID ('C'+('M'<<8)+((int)'A'<<16)+((int)'P'<<24))\n\n\nbmhd_t  bmhd;\n\nint    Align (int l)\n{\n\tif (l&1)\n\t\treturn l+1;\n\treturn l;\n}\n\n\n\n/*\n================\nLBMRLEdecompress\n\nSource must be evenly aligned!\n================\n*/\nbyte  *LBMRLEDecompress (byte *source,byte *unpacked, int bpwidth)\n{\n\tint     count;\n\tbyte    b,rept;\n\n\tcount = 0;\n\n\tdo\n\t{\n\t\trept = *source++;\n\n\t\tif (rept > 0x80)\n\t\t{\n\t\t\trept = (rept^0xff)+2;\n\t\t\tb = *source++;\n\t\t\tmemset(unpacked,b,rept);\n\t\t\tunpacked += rept;\n\t\t}\n\t\telse if (rept < 0x80)\n\t\t{\n\t\t\trept++;\n\t\t\tmemcpy(unpacked,source,rept);\n\t\t\tunpacked += rept;\n\t\t\tsource += rept;\n\t\t}\n\t\telse\n\t\t\trept = 0;               // rept of 0x80 is NOP\n\n\t\tcount += rept;\n\n\t} while (count<bpwidth);\n\n\tif (count>bpwidth)\n\t\tError (\"Decompression exceeded width!\\n\");\n\n\n\treturn source;\n}\n\n\n/*\n=================\nLoadLBM\n=================\n*/\nvoid LoadLBM (const char *filename, byte **picture, byte **palette)\n{\n\tbyte    *LBMbuffer, *picbuffer, *cmapbuffer;\n\tint             y;\n\tbyte    *LBM_P, *LBMEND_P;\n\tbyte    *pic_p;\n\tbyte    *body_p;\n\n\tint    formtype,formlength;\n\tint    chunktype,chunklength;\n\n// qiet compiler warnings\n\tpicbuffer = NULL;\n\tcmapbuffer = NULL;\n\n//\n// load the LBM\n//\n\tLoadFile (filename, (void **)&LBMbuffer);\n\n//\n// parse the LBM header\n//\n\tLBM_P = LBMbuffer;\n\tif ( *(int *)LBMbuffer != LittleLong(FORMID) )\n\t   Error (\"No FORM ID at start of file!\\n\");\n\n\tLBM_P += 4;\n\tformlength = BigLong( *(int *)LBM_P );\n\tLBM_P += 4;\n\tLBMEND_P = LBM_P + Align(formlength);\n\n\tformtype = LittleLong(*(int *)LBM_P);\n\n\tif (formtype != ILBMID && formtype != PBMID)\n\t\tError (\"Unrecognized form type: %c%c%c%c\\n\", formtype&0xff\n\t\t,(formtype>>8)&0xff,(formtype>>16)&0xff,(formtype>>24)&0xff);\n\n\tLBM_P += 4;\n\n//\n// parse chunks\n//\n\n\twhile (LBM_P < LBMEND_P)\n\t{\n\t\tchunktype = LBM_P[0] + (LBM_P[1]<<8) + (LBM_P[2]<<16) + (LBM_P[3]<<24);\n\t\tLBM_P += 4;\n\t\tchunklength = LBM_P[3] + (LBM_P[2]<<8) + (LBM_P[1]<<16) + (LBM_P[0]<<24);\n\t\tLBM_P += 4;\n\n\t\tswitch ( chunktype )\n\t\t{\n\t\tcase BMHDID:\n\t\t\tmemcpy (&bmhd,LBM_P,sizeof(bmhd));\n\t\t\tbmhd.w = BigShort(bmhd.w);\n\t\t\tbmhd.h = BigShort(bmhd.h);\n\t\t\tbmhd.x = BigShort(bmhd.x);\n\t\t\tbmhd.y = BigShort(bmhd.y);\n\t\t\tbmhd.pageWidth = BigShort(bmhd.pageWidth);\n\t\t\tbmhd.pageHeight = BigShort(bmhd.pageHeight);\n\t\t\tbreak;\n\n\t\tcase CMAPID:\n\t\t\tcmapbuffer = malloc (768);\n\t\t\tmemset (cmapbuffer, 0, 768);\n\t\t\tmemcpy (cmapbuffer, LBM_P, chunklength);\n\t\t\tbreak;\n\n\t\tcase BODYID:\n\t\t\tbody_p = LBM_P;\n\n\t\t\tpic_p = picbuffer = malloc (bmhd.w*bmhd.h);\n\t\t\tif (formtype == PBMID)\n\t\t\t{\n\t\t\t//\n\t\t\t// unpack PBM\n\t\t\t//\n\t\t\t\tfor (y=0 ; y<bmhd.h ; y++, pic_p += bmhd.w)\n\t\t\t\t{\n\t\t\t\t\tif (bmhd.compression == cm_rle1)\n\t\t\t\t\t\tbody_p = LBMRLEDecompress ((byte *)body_p\n\t\t\t\t\t\t, pic_p , bmhd.w);\n\t\t\t\t\telse if (bmhd.compression == cm_none)\n\t\t\t\t\t{\n\t\t\t\t\t\tmemcpy (pic_p,body_p,bmhd.w);\n\t\t\t\t\t\tbody_p += Align(bmhd.w);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t//\n\t\t\t// unpack ILBM\n\t\t\t//\n\t\t\t\tError (\"%s is an interlaced LBM, not packed\", filename);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tLBM_P += Align(chunklength);\n\t}\n\n\tfree (LBMbuffer);\n\n\t*picture = picbuffer;\n\n\tif (palette)\n\t\t*palette = cmapbuffer;\n}\n\n\n/*\n============================================================================\n\n\t\t\t\t\t\t\tWRITE LBM\n\n============================================================================\n*/\n\n/*\n==============\nWriteLBMfile\n==============\n*/\nvoid WriteLBMfile (const char *filename, byte *data,\n\t\t\t\t   int width, int height, byte *palette)\n{\n\tbyte    *lbm, *lbmptr;\n\tint    *formlength, *bmhdlength, *cmaplength, *bodylength;\n\tint    length;\n\tbmhd_t  basebmhd;\n\n\tlbm = lbmptr = malloc (width*height+1000);\n\n//\n// start FORM\n//\n\t*lbmptr++ = 'F';\n\t*lbmptr++ = 'O';\n\t*lbmptr++ = 'R';\n\t*lbmptr++ = 'M';\n\n\tformlength = (int*)lbmptr;\n\tlbmptr+=4;                      // leave space for length\n\n\t*lbmptr++ = 'P';\n\t*lbmptr++ = 'B';\n\t*lbmptr++ = 'M';\n\t*lbmptr++ = ' ';\n\n//\n// write BMHD\n//\n\t*lbmptr++ = 'B';\n\t*lbmptr++ = 'M';\n\t*lbmptr++ = 'H';\n\t*lbmptr++ = 'D';\n\n\tbmhdlength = (int *)lbmptr;\n\tlbmptr+=4;                      // leave space for length\n\n\tmemset (&basebmhd,0,sizeof(basebmhd));\n\tbasebmhd.w = BigShort((short)width);\n\tbasebmhd.h = BigShort((short)height);\n\tbasebmhd.nPlanes = BigShort(8);\n\tbasebmhd.xAspect = BigShort(5);\n\tbasebmhd.yAspect = BigShort(6);\n\tbasebmhd.pageWidth = BigShort((short)width);\n\tbasebmhd.pageHeight = BigShort((short)height);\n\n\tmemcpy (lbmptr,&basebmhd,sizeof(basebmhd));\n\tlbmptr += sizeof(basebmhd);\n\n\tlength = lbmptr-(byte *)bmhdlength-4;\n\t*bmhdlength = BigLong(length);\n\tif (length&1)\n\t\t*lbmptr++ = 0;          // pad chunk to even offset\n\n//\n// write CMAP\n//\n\t*lbmptr++ = 'C';\n\t*lbmptr++ = 'M';\n\t*lbmptr++ = 'A';\n\t*lbmptr++ = 'P';\n\n\tcmaplength = (int *)lbmptr;\n\tlbmptr+=4;                      // leave space for length\n\n\tmemcpy (lbmptr,palette,768);\n\tlbmptr += 768;\n\n\tlength = lbmptr-(byte *)cmaplength-4;\n\t*cmaplength = BigLong(length);\n\tif (length&1)\n\t\t*lbmptr++ = 0;          // pad chunk to even offset\n\n//\n// write BODY\n//\n\t*lbmptr++ = 'B';\n\t*lbmptr++ = 'O';\n\t*lbmptr++ = 'D';\n\t*lbmptr++ = 'Y';\n\n\tbodylength = (int *)lbmptr;\n\tlbmptr+=4;                      // leave space for length\n\n\tmemcpy (lbmptr,data,width*height);\n\tlbmptr += width*height;\n\n\tlength = lbmptr-(byte *)bodylength-4;\n\t*bodylength = BigLong(length);\n\tif (length&1)\n\t\t*lbmptr++ = 0;          // pad chunk to even offset\n\n//\n// done\n//\n\tlength = lbmptr-(byte *)formlength-4;\n\t*formlength = BigLong(length);\n\tif (length&1)\n\t\t*lbmptr++ = 0;          // pad chunk to even offset\n\n//\n// write output file\n//\n\tSaveFile (filename, lbm, lbmptr-lbm);\n\tfree (lbm);\n}\n\n\n/*\n============================================================================\n\nLOAD PCX\n\n============================================================================\n*/\n\ntypedef struct\n{\n    char\tmanufacturer;\n    char\tversion;\n    char\tencoding;\n    char\tbits_per_pixel;\n    unsigned short\txmin,ymin,xmax,ymax;\n    unsigned short\thres,vres;\n    unsigned char\tpalette[48];\n    char\treserved;\n    char\tcolor_planes;\n    unsigned short\tbytes_per_line;\n    unsigned short\tpalette_type;\n    char\tfiller[58];\n    unsigned char\tdata;\t\t\t// unbounded\n} pcx_t;\n\n\n/*\n==============\nLoadPCX\n==============\n*/\nvoid LoadPCX (const char *filename, byte **pic, byte **palette, int *width, int *height)\n{\n\tbyte\t*raw;\n\tpcx_t\t*pcx;\n\tint\t\tx, y;\n\tint\t\tlen;\n\tint\t\tdataByte, runLength;\n\tbyte\t*out, *pix;\n\n\t//\n\t// load the file\n\t//\n\tlen = LoadFile (filename, (void **)&raw);\n\n\t//\n\t// parse the PCX file\n\t//\n\tpcx = (pcx_t *)raw;\n\traw = &pcx->data;\n\n\tpcx->xmin = LittleShort(pcx->xmin);\n\tpcx->ymin = LittleShort(pcx->ymin);\n\tpcx->xmax = LittleShort(pcx->xmax);\n\tpcx->ymax = LittleShort(pcx->ymax);\n\tpcx->hres = LittleShort(pcx->hres);\n\tpcx->vres = LittleShort(pcx->vres);\n\tpcx->bytes_per_line = LittleShort(pcx->bytes_per_line);\n\tpcx->palette_type = LittleShort(pcx->palette_type);\n\n\tif (pcx->manufacturer != 0x0a\n\t\t|| pcx->version != 5\n\t\t|| pcx->encoding != 1\n\t\t|| pcx->bits_per_pixel != 8\n\t\t|| pcx->xmax >= 640\n\t\t|| pcx->ymax >= 480)\n\t\tError (\"Bad pcx file %s\", filename);\n\t\n\tif (palette)\n\t{\n\t\t*palette = malloc(768);\n\t\tmemcpy (*palette, (byte *)pcx + len - 768, 768);\n\t}\n\n\tif (width)\n\t\t*width = pcx->xmax+1;\n\tif (height)\n\t\t*height = pcx->ymax+1;\n\n\tif (!pic)\n\t\treturn;\n\n\tout = malloc ( (pcx->ymax+1) * (pcx->xmax+1) );\n\tif (!out)\n\t\tError (\"Skin_Cache: couldn't allocate\");\n\n\t*pic = out;\n\n\tpix = out;\n\n\tfor (y=0 ; y<=pcx->ymax ; y++, pix += pcx->xmax+1)\n\t{\n\t\tfor (x=0 ; x<=pcx->xmax ; )\n\t\t{\n\t\t\tdataByte = *raw++;\n\n\t\t\tif((dataByte & 0xC0) == 0xC0)\n\t\t\t{\n\t\t\t\trunLength = dataByte & 0x3F;\n\t\t\t\tdataByte = *raw++;\n\t\t\t}\n\t\t\telse\n\t\t\t\trunLength = 1;\n\n\t\t\t// FIXME: this shouldn't happen, but it does.  Are we decoding the file wrong?\n\t\t\t// Truncate runLength so we don't overrun the end of the buffer\n\t\t\tif ( ( y == pcx->ymax ) && ( x + runLength > pcx->xmax + 1 ) ) {\n\t\t\t\trunLength = pcx->xmax - x + 1;\n\t\t\t}\n\n\t\t\twhile(runLength-- > 0)\n\t\t\t\tpix[x++] = dataByte;\n\t\t}\n\n\t}\n\n\tif ( raw - (byte *)pcx > len)\n\t\tError (\"PCX file %s was malformed\", filename);\n\n\tfree (pcx);\n}\n\n/* \n============== \nWritePCXfile \n============== \n*/ \nvoid WritePCXfile (const char *filename, byte *data, \n\t\t\t\t   int width, int height, byte *palette) \n{\n\tint\t\ti, j, length;\n\tpcx_t\t*pcx;\n\tbyte\t\t*pack;\n\t  \n\tpcx = malloc (width*height*2+1000);\n\tmemset (pcx, 0, sizeof(*pcx));\n\n\tpcx->manufacturer = 0x0a;\t// PCX id\n\tpcx->version = 5;\t\t\t// 256 color\n \tpcx->encoding = 1;\t\t// uncompressed\n\tpcx->bits_per_pixel = 8;\t\t// 256 color\n\tpcx->xmin = 0;\n\tpcx->ymin = 0;\n\tpcx->xmax = LittleShort((short)(width-1));\n\tpcx->ymax = LittleShort((short)(height-1));\n\tpcx->hres = LittleShort((short)width);\n\tpcx->vres = LittleShort((short)height);\n\tpcx->color_planes = 1;\t\t// chunky image\n\tpcx->bytes_per_line = LittleShort((short)width);\n\tpcx->palette_type = LittleShort(1);\t\t// not a grey scale\n\n\t// pack the image\n\tpack = &pcx->data;\n\t\n\tfor (i=0 ; i<height ; i++)\n\t{\n\t\tfor (j=0 ; j<width ; j++)\n\t\t{\n\t\t\tif ( (*data & 0xc0) != 0xc0)\n\t\t\t\t*pack++ = *data++;\n\t\t\telse\n\t\t\t{\n\t\t\t\t*pack++ = 0xc1;\n\t\t\t\t*pack++ = *data++;\n\t\t\t}\n\t\t}\n\t}\n\t\t\t\n\t// write the palette\n\t*pack++ = 0x0c;\t// palette ID byte\n\tfor (i=0 ; i<768 ; i++)\n\t\t*pack++ = *palette++;\n\t\t\n// write output file \n\tlength = pack - (byte *)pcx;\n\tSaveFile (filename, pcx, length);\n\n\tfree (pcx);\n} \n \n/*\n============================================================================\n\nLOAD BMP\n\n============================================================================\n*/\n\n\n/*\n\n// we can't just use these structures, because\n// compiler structure alignment will not be portable\n// on this unaligned stuff\n\ntypedef struct tagBITMAPFILEHEADER { // bmfh \n        WORD    bfType;\t\t\t\t// BM\n        DWORD   bfSize; \n        WORD    bfReserved1; \n        WORD    bfReserved2; \n        DWORD   bfOffBits; \n} BITMAPFILEHEADER; \n \ntypedef struct tagBITMAPINFOHEADER{ // bmih \n   DWORD  biSize; \n   LONG   biWidth; \n   LONG   biHeight; \n   WORD   biPlanes; \n   WORD   biBitCount \n   DWORD  biCompression; \n   DWORD  biSizeImage; \n   LONG   biXPelsPerMeter; \n   LONG   biYPelsPerMeter; \n   DWORD  biClrUsed; \n   DWORD  biClrImportant; \n} BITMAPINFOHEADER; \n \ntypedef struct tagBITMAPINFO { // bmi \n   BITMAPINFOHEADER bmiHeader; \n   RGBQUAD          bmiColors[1]; \n} BITMAPINFO; \n\ntypedef struct tagBITMAPCOREHEADER { // bmch \n        DWORD   bcSize; \n        WORD    bcWidth; \n        WORD    bcHeight; \n        WORD    bcPlanes; \n        WORD    bcBitCount; \n} BITMAPCOREHEADER; \n \ntypedef struct _BITMAPCOREINFO {    // bmci \n        BITMAPCOREHEADER  bmciHeader; \n        RGBTRIPLE         bmciColors[1]; \n} BITMAPCOREINFO; \n \n*/\n\n/*\n==============\nLoadBMP\n==============\n*/\nvoid LoadBMP (const char *filename, byte **pic, byte **palette, int *width, int *height)\n{\n\tbyte\t*out;\n\tFILE\t*fin;\n\tint\t\ti;\n    int\t\tbfSize; \n    int\t\tbfOffBits; \n\tint\t\tstructSize;\n    int\t\tbcWidth; \n    int     bcHeight; \n    int\t    bcPlanes; \n    int\t\tbcBitCount; \n\tbyte\tbcPalette[1024];\n\tqboolean\tflipped;\n\n\tfin = fopen (filename, \"rb\");\n\tif (!fin) {\n\t\tError (\"Couldn't read %s\", filename);\n\t}\n\n\ti = fgetLittleShort (fin);\n\tif (i != 'B' + ('M'<<8) ) {\n\t\tError (\"%s is not a bmp file\", filename);\n\t}\n\n\tbfSize = fgetLittleLong (fin);\n\tfgetLittleShort(fin);\n\tfgetLittleShort(fin);\n\tbfOffBits = fgetLittleLong (fin);\n\n\t// the size will tell us if it is a\n\t// bitmapinfo or a bitmapcore\n\tstructSize = fgetLittleLong (fin);\n\tif (structSize == 40) {\n\t\t// bitmapinfo\n        bcWidth = fgetLittleLong(fin); \n        bcHeight= fgetLittleLong(fin); \n        bcPlanes = fgetLittleShort(fin); \n        bcBitCount = fgetLittleShort(fin); \n\n\t\tfseek (fin, 24, SEEK_CUR);\n\n\t\tif (palette) {\n\t\t\tfread (bcPalette, 1, 1024, fin);\n\t\t\t*palette = malloc(768);\n\n\t\t\tfor (i = 0 ; i < 256 ; i++) {\n\t\t\t\t(*palette)[i * 3 + 0] = bcPalette[i * 4 + 2];\n\t\t\t\t(*palette)[i * 3 + 1] = bcPalette[i * 4 + 1];\n\t\t\t\t(*palette)[i * 3 + 2] = bcPalette[i * 4 + 0];\n\t\t\t}\n\t\t}\n\t} else if (structSize == 12) {\n\t\t// bitmapcore\n        bcWidth = fgetLittleShort(fin); \n        bcHeight= fgetLittleShort(fin); \n        bcPlanes = fgetLittleShort(fin); \n        bcBitCount = fgetLittleShort(fin); \n\n\t\tif (palette) {\n\t\t\tfread (bcPalette, 1, 768, fin);\n\t\t\t*palette = malloc(768);\n\n\t\t\tfor (i = 0 ; i < 256 ; i++) {\n\t\t\t\t(*palette)[i * 3 + 0] = bcPalette[i * 3 + 2];\n\t\t\t\t(*palette)[i * 3 + 1] = bcPalette[i * 3 + 1];\n\t\t\t\t(*palette)[i * 3 + 2] = bcPalette[i * 3 + 0];\n\t\t\t}\n\t\t}\n\t} else {\n\t\tError (\"%s had strange struct size\", filename);\n\t}\n\t\n\tif (bcPlanes != 1) {\n\t\tError (\"%s was not a single plane image\", filename);\n\t}\n\n\tif (bcBitCount != 8) {\n\t\tError (\"%s was not an 8 bit image\", filename);\n\t}\n\n\tif (bcHeight < 0) {\n\t\tbcHeight = -bcHeight;\n\t\tflipped = qtrue;\n\t} else {\n\t\tflipped = qfalse;\n\t}\n\n\tif (width)\n\t\t*width = bcWidth;\n\tif (height)\n\t\t*height = bcHeight;\n\n\tif (!pic) {\n\t\tfclose (fin);\n\t\treturn;\n\t}\n\n\tout = malloc ( bcWidth * bcHeight );\n\t*pic = out;\n\tfseek (fin, bfOffBits, SEEK_SET);\n\n\tif (flipped) {\n\t\tfor (i = 0 ; i < bcHeight ; i++) {\n\t\t\tfread (out + bcWidth * (bcHeight - 1 - i), 1, bcWidth, fin);\n\t\t}\n\t} else {\n\t\tfread (out, 1, bcWidth*bcHeight, fin);\n\t}\n\n\tfclose (fin);\n}\n\n\n/*\n============================================================================\n\nLOAD IMAGE\n\n============================================================================\n*/\n\n/*\n==============\nLoad256Image\n\nWill load either an lbm or pcx, depending on extension.\nAny of the return pointers can be NULL if you don't want them.\n==============\n*/\nvoid Load256Image (const char *name, byte **pixels, byte **palette,\n\t\t\t\t   int *width, int *height)\n{\n\tchar\text[128];\n\n\tExtractFileExtension (name, ext);\n\tif (!Q_stricmp (ext, \"lbm\"))\n\t{\n\t\tLoadLBM (name, pixels, palette);\n\t\tif (width)\n\t\t\t*width = bmhd.w;\n\t\tif (height)\n\t\t\t*height = bmhd.h;\n\t}\n\telse if (!Q_stricmp (ext, \"pcx\"))\n\t{\n\t\tLoadPCX (name, pixels, palette, width, height);\n\t}\n\telse if (!Q_stricmp (ext, \"bmp\"))\n\t{\n\t\tLoadBMP (name, pixels, palette, width, height);\n\t}\n\telse\n\t\tError (\"%s doesn't have a known image extension\", name);\n}\n\n\n/*\n==============\nSave256Image\n\nWill save either an lbm or pcx, depending on extension.\n==============\n*/\nvoid Save256Image (const char *name, byte *pixels, byte *palette,\n\t\t\t\t   int width, int height)\n{\n\tchar\text[128];\n\n\tExtractFileExtension (name, ext);\n\tif (!Q_stricmp (ext, \"lbm\"))\n\t{\n\t\tWriteLBMfile (name, pixels, width, height, palette);\n\t}\n\telse if (!Q_stricmp (ext, \"pcx\"))\n\t{\n\t\tWritePCXfile (name, pixels, width, height, palette);\n\t}\n\telse\n\t\tError (\"%s doesn't have a known image extension\", name);\n}\n\n\n\n\n/*\n============================================================================\n\nTARGA IMAGE\n\n============================================================================\n*/\n\ntypedef struct _TargaHeader {\n\tunsigned char \tid_length, colormap_type, image_type;\n\tunsigned short\tcolormap_index, colormap_length;\n\tunsigned char\tcolormap_size;\n\tunsigned short\tx_origin, y_origin, width, height;\n\tunsigned char\tpixel_size, attributes;\n} TargaHeader;\n\n/*\n=============\nLoadTGABuffer\n=============\n*/\nvoid LoadTGABuffer ( byte *buffer, byte **pic, int *width, int *height)\n{\n\tint\t\tcolumns, rows, numPixels;\n\tbyte\t*pixbuf;\n\tint\t\trow, column;\n\tbyte\t*buf_p;\n\tTargaHeader\ttarga_header;\n\tbyte\t\t*targa_rgba;\n\n\t*pic = NULL;\n\n\tbuf_p = buffer;\n\n\ttarga_header.id_length = *buf_p++;\n\ttarga_header.colormap_type = *buf_p++;\n\ttarga_header.image_type = *buf_p++;\n\t\n\ttarga_header.colormap_index = LittleShort ( *(short *)buf_p );\n\tbuf_p += 2;\n\ttarga_header.colormap_length = LittleShort ( *(short *)buf_p );\n\tbuf_p += 2;\n\ttarga_header.colormap_size = *buf_p++;\n\ttarga_header.x_origin = LittleShort ( *(short *)buf_p );\n\tbuf_p += 2;\n\ttarga_header.y_origin = LittleShort ( *(short *)buf_p );\n\tbuf_p += 2;\n\ttarga_header.width = LittleShort ( *(short *)buf_p );\n\tbuf_p += 2;\n\ttarga_header.height = LittleShort ( *(short *)buf_p );\n\tbuf_p += 2;\n\ttarga_header.pixel_size = *buf_p++;\n\ttarga_header.attributes = *buf_p++;\n\n\tif (targa_header.image_type!=2 \n\t\t&& targa_header.image_type!=10\n\t\t&& targa_header.image_type != 3 ) \n\t{\n\t\tError(\"LoadTGA: Only type 2 (RGB), 3 (gray), and 10 (RGB) TGA images supported\\n\");\n\t}\n\n\tif ( targa_header.colormap_type != 0 )\n\t{\n\t\tError(\"LoadTGA: colormaps not supported\\n\" );\n\t}\n\n\tif ( ( targa_header.pixel_size != 32 && targa_header.pixel_size != 24 ) && targa_header.image_type != 3 )\n\t{\n\t\tError(\"LoadTGA: Only 32 or 24 bit images supported (no colormaps)\\n\");\n\t}\n\n\tcolumns = targa_header.width;\n\trows = targa_header.height;\n\tnumPixels = columns * rows;\n\n\tif (width)\n\t\t*width = columns;\n\tif (height)\n\t\t*height = rows;\n\n\ttarga_rgba = malloc (numPixels*4);\n\t*pic = targa_rgba;\n\n\tif (targa_header.id_length != 0)\n\t\tbuf_p += targa_header.id_length;  // skip TARGA image comment\n\t\n\tif ( targa_header.image_type==2 || targa_header.image_type == 3 )\n\t{ \n\t\t// Uncompressed RGB or gray scale image\n\t\tfor(row=rows-1; row>=0; row--) \n\t\t{\n\t\t\tpixbuf = targa_rgba + row*columns*4;\n\t\t\tfor(column=0; column<columns; column++) \n\t\t\t{\n\t\t\t\tunsigned char red,green,blue,alphabyte;\n\t\t\t\tswitch (targa_header.pixel_size) \n\t\t\t\t{\n\t\t\t\t\t\n\t\t\t\tcase 8:\n\t\t\t\t\tblue = *buf_p++;\n\t\t\t\t\tgreen = blue;\n\t\t\t\t\tred = blue;\n\t\t\t\t\t*pixbuf++ = red;\n\t\t\t\t\t*pixbuf++ = green;\n\t\t\t\t\t*pixbuf++ = blue;\n\t\t\t\t\t*pixbuf++ = 255;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 24:\n\t\t\t\t\tblue = *buf_p++;\n\t\t\t\t\tgreen = *buf_p++;\n\t\t\t\t\tred = *buf_p++;\n\t\t\t\t\t*pixbuf++ = red;\n\t\t\t\t\t*pixbuf++ = green;\n\t\t\t\t\t*pixbuf++ = blue;\n\t\t\t\t\t*pixbuf++ = 255;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 32:\n\t\t\t\t\tblue = *buf_p++;\n\t\t\t\t\tgreen = *buf_p++;\n\t\t\t\t\tred = *buf_p++;\n\t\t\t\t\talphabyte = *buf_p++;\n\t\t\t\t\t*pixbuf++ = red;\n\t\t\t\t\t*pixbuf++ = green;\n\t\t\t\t\t*pixbuf++ = blue;\n\t\t\t\t\t*pixbuf++ = alphabyte;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\t//Error(\"LoadTGA: illegal pixel_size '%d' in file '%s'\\n\", targa_header.pixel_size, name );\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\telse if (targa_header.image_type==10) {   // Runlength encoded RGB images\n\t\tunsigned char red,green,blue,alphabyte,packetHeader,packetSize,j;\n\n\t\tred = 0;\n\t\tgreen = 0;\n\t\tblue = 0;\n\t\talphabyte = 0xff;\n\n\t\tfor(row=rows-1; row>=0; row--) {\n\t\t\tpixbuf = targa_rgba + row*columns*4;\n\t\t\tfor(column=0; column<columns; ) {\n\t\t\t\tpacketHeader= *buf_p++;\n\t\t\t\tpacketSize = 1 + (packetHeader & 0x7f);\n\t\t\t\tif (packetHeader & 0x80) {        // run-length packet\n\t\t\t\t\tswitch (targa_header.pixel_size) {\n\t\t\t\t\t\tcase 24:\n\t\t\t\t\t\t\t\tblue = *buf_p++;\n\t\t\t\t\t\t\t\tgreen = *buf_p++;\n\t\t\t\t\t\t\t\tred = *buf_p++;\n\t\t\t\t\t\t\t\talphabyte = 255;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 32:\n\t\t\t\t\t\t\t\tblue = *buf_p++;\n\t\t\t\t\t\t\t\tgreen = *buf_p++;\n\t\t\t\t\t\t\t\tred = *buf_p++;\n\t\t\t\t\t\t\t\talphabyte = *buf_p++;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t//Error(\"LoadTGA: illegal pixel_size '%d' in file '%s'\\n\", targa_header.pixel_size, name );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\n\t\t\t\t\tfor(j=0;j<packetSize;j++) {\n\t\t\t\t\t\t*pixbuf++=red;\n\t\t\t\t\t\t*pixbuf++=green;\n\t\t\t\t\t\t*pixbuf++=blue;\n\t\t\t\t\t\t*pixbuf++=alphabyte;\n\t\t\t\t\t\tcolumn++;\n\t\t\t\t\t\tif (column==columns) { // run spans across rows\n\t\t\t\t\t\t\tcolumn=0;\n\t\t\t\t\t\t\tif (row>0)\n\t\t\t\t\t\t\t\trow--;\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tgoto breakOut;\n\t\t\t\t\t\t\tpixbuf = targa_rgba + row*columns*4;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {                            // non run-length packet\n\t\t\t\t\tfor(j=0;j<packetSize;j++) {\n\t\t\t\t\t\tswitch (targa_header.pixel_size) {\n\t\t\t\t\t\t\tcase 24:\n\t\t\t\t\t\t\t\t\tblue = *buf_p++;\n\t\t\t\t\t\t\t\t\tgreen = *buf_p++;\n\t\t\t\t\t\t\t\t\tred = *buf_p++;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = red;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = green;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = blue;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = 255;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 32:\n\t\t\t\t\t\t\t\t\tblue = *buf_p++;\n\t\t\t\t\t\t\t\t\tgreen = *buf_p++;\n\t\t\t\t\t\t\t\t\tred = *buf_p++;\n\t\t\t\t\t\t\t\t\talphabyte = *buf_p++;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = red;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = green;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = blue;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = alphabyte;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t//Sys_Printf(\"LoadTGA: illegal pixel_size '%d' in file '%s'\\n\", targa_header.pixel_size, name );\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcolumn++;\n\t\t\t\t\t\tif (column==columns) { // pixel packet run spans across rows\n\t\t\t\t\t\t\tcolumn=0;\n\t\t\t\t\t\t\tif (row>0)\n\t\t\t\t\t\t\t\trow--;\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tgoto breakOut;\n\t\t\t\t\t\t\tpixbuf = targa_rgba + row*columns*4;\n\t\t\t\t\t\t}\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreakOut:;\n\t\t}\n\t}\n\n\t//free(buffer);\n}\n\n\n\n/*\n=============\nLoadTGA\n=============\n*/\nvoid LoadTGA (const char *name, byte **pixels, int *width, int *height)\n{\n\tbyte\t\t\t*buffer;\n  int nLen;\n\t//\n\t// load the file\n\t//\n\tnLen = LoadFile ( ( char * ) name, (void **)&buffer);\n\tif (nLen == -1) \n  {\n\t\tError (\"Couldn't read %s\", name);\n  }\n\n  LoadTGABuffer(buffer, pixels, width, height);\n\n}\n\n\n/*\n================\nWriteTGA\n================\n*/\nvoid WriteTGA (const char *filename, byte *data, int width, int height) {\n\tbyte\t*buffer;\n\tint\t\ti;\n\tint\t\tc;\n\tFILE\t*f;\n\n\tbuffer = malloc(width*height*4 + 18);\n\tmemset (buffer, 0, 18);\n\tbuffer[2] = 2;\t\t// uncompressed type\n\tbuffer[12] = width&255;\n\tbuffer[13] = width>>8;\n\tbuffer[14] = height&255;\n\tbuffer[15] = height>>8;\n\tbuffer[16] = 32;\t// pixel size\n\n\t// swap rgb to bgr\n\tc = 18 + width * height * 4;\n\tfor (i=18 ; i<c ; i+=4)\n\t{\n\t\tbuffer[i] = data[i-18+2];\t\t// blue\n\t\tbuffer[i+1] = data[i-18+1];\t\t// green\n\t\tbuffer[i+2] = data[i-18+0];\t\t// red\n\t\tbuffer[i+3] = data[i-18+3];\t\t// alpha\n\t}\n\n\tf = fopen (filename, \"wb\");\n\tfwrite (buffer, 1, c, f);\n\tfclose (f);\n\n\tfree (buffer);\n}\n\n/*\n============================================================================\n\nLOAD32BITIMAGE\n\n============================================================================\n*/\n\n/*\n==============\nLoad32BitImage\n\nAny of the return pointers can be NULL if you don't want them.\n==============\n*/\nvoid Load32BitImage (const char *name, unsigned **pixels,  int *width, int *height)\n{\n\tchar\text[128];\n\tbyte\t*palette;\n\tbyte\t*pixels8;\n\tbyte\t*pixels32;\n\tint\t\tsize;\n\tint\t\ti;\n\tint\t\tv;\n\n\tExtractFileExtension (name, ext);\n\tif (!Q_stricmp (ext, \"tga\")) {\n\t\tLoadTGA (name, (byte **)pixels, width, height);\n\t} else {\n\t\tLoad256Image (name, &pixels8, &palette, width, height);\n\t\tif (!pixels) {\n\t\t\treturn;\n\t\t}\n\t\tsize = *width * *height;\n\t\tpixels32 = malloc(size * 4);\n\t\t*pixels = (unsigned *)pixels32;\n\t\tfor (i = 0 ; i < size ; i++) {\n\t\t\tv = pixels8[i];\n\t\t\tpixels32[i*4 + 0] = palette[ v * 3 + 0 ];\n\t\t\tpixels32[i*4 + 1] = palette[ v * 3 + 1 ];\n\t\t\tpixels32[i*4 + 2] = palette[ v * 3 + 2 ];\n\t\t\tpixels32[i*4 + 3] = 0xff;\n\t\t}\n\t}\n}\n\n\n"
  },
  {
    "path": "common/imagelib.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// piclib.h\n\n\nvoid LoadLBM (const char *filename, byte **picture, byte **palette);\nvoid WriteLBMfile (const char *filename, byte *data, int width, int height\n\t, byte *palette);\nvoid LoadPCX (const char *filename, byte **picture, byte **palette, int *width, int *height);\nvoid WritePCXfile (const char *filename, byte *data, int width, int height\n\t, byte *palette);\n\n// loads / saves either lbm or pcx, depending on extension\nvoid Load256Image (const char *name, byte **pixels, byte **palette,\n\t\t\t\t   int *width, int *height);\nvoid Save256Image (const char *name, byte *pixels, byte *palette,\n\t\t\t\t   int width, int height);\n\n\nvoid LoadTGA (const char *filename, byte **pixels, int *width, int *height);\nvoid LoadTGABuffer ( byte *buffer, byte **pic, int *width, int *height);\nvoid WriteTGA (const char *filename, byte *data, int width, int height);\n\nvoid Load32BitImage (const char *name, unsigned **pixels, int *width, int *height);\n\n"
  },
  {
    "path": "common/l3dslib.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// l3dslib.c: library for loading triangles from an Alias triangle file\n//\n\n#include <stdio.h>\n#include \"cmdlib.h\"\n#include \"mathlib.h\"\n#include \"trilib.h\"\n#include \"l3dslib.h\"\n\n#define MAIN3DS       0x4D4D\n#define EDIT3DS       0x3D3D  // this is the start of the editor config\n#define EDIT_OBJECT   0x4000\n#define OBJ_TRIMESH   0x4100\n#define TRI_VERTEXL   0x4110\n#define TRI_FACEL1    0x4120\n\n#define MAXVERTS\t2000\n\ntypedef struct {\n\tint\tv[4];\n} tri;\n\nfloat\tfverts[MAXVERTS][3];\ntri\t\ttris[MAXTRIANGLES];\n\nint\tbytesread, level, numtris, totaltris;\nint\tvertsfound, trisfound;\n\ntriangle_t\t*ptri;\n\n\n// Alias stores triangles as 3 explicit vertices in .tri files, so even though we\n// start out with a vertex pool and vertex indices for triangles, we have to convert\n// to raw, explicit triangles\nvoid StoreAliasTriangles (void)\n{\n\tint\t\ti, j, k;\n\n\tif ((totaltris + numtris) > MAXTRIANGLES)\n\t\tError (\"Error: Too many triangles\");\n\n\tfor (i=0; i<numtris ; i++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\tfor (k=0 ; k<3 ; k++)\n\t\t\t{\n\t\t\t\tptri[i+totaltris].verts[j][k] = fverts[tris[i].v[j]][k];\n\t\t\t}\n\t\t}\n\t}\n\t\n\ttotaltris += numtris;\n\tnumtris = 0;\n\tvertsfound = 0;\n\ttrisfound = 0;\n}\n\n\nint ParseVertexL (FILE *input)\n{\n\tint\t\t\t\ti, j, startbytesread, numverts;\n\tunsigned short\ttshort;\n\n\tif (vertsfound)\n\t\tError (\"Error: Multiple vertex chunks\");\n\n\tvertsfound = 1;\n\tstartbytesread = bytesread;\n\n\tif (feof(input))\n\t\tError (\"Error: unexpected end of file\");\n\n\tfread(&tshort, sizeof(tshort), 1, input);\n\tbytesread += sizeof(tshort);\n\tnumverts = (int)tshort;\n\n\tif (numverts > MAXVERTS)\n\t\tError (\"Error: Too many vertices\");\n\n\tfor (i=0 ; i<numverts ; i++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\tif (feof(input))\n\t\t\t\tError (\"Error: unexpected end of file\");\n\n\t\t\tfread(&fverts[i][j], sizeof(float), 1, input);\n\t\t\tbytesread += sizeof(float);\n\t\t}\n\t}\n\n\tif (vertsfound && trisfound)\n\t\tStoreAliasTriangles ();\n\n\treturn bytesread - startbytesread;\n}\n\n\nint ParseFaceL1 (FILE *input)\n{\n\n\tint\t\t\t\ti, j, startbytesread;\n\tunsigned short\ttshort;\n\n\tif (trisfound)\n\t\tError (\"Error: Multiple face chunks\");\n\n\ttrisfound = 1;\n\tstartbytesread = bytesread;\n\n\tif (feof(input))\n\t\tError (\"Error: unexpected end of file\");\n\n\tfread(&tshort, sizeof(tshort), 1, input);\n\tbytesread += sizeof(tshort);\n\tnumtris = (int)tshort;\n\n\tif (numtris > MAXTRIANGLES)\n\t\tError (\"Error: Too many triangles\");\n\n\tfor (i=0 ; i<numtris ; i++)\n\t{\n\t\tfor (j=0 ; j<4 ; j++)\n\t\t{\n\t\t\tif (feof(input))\n\t\t\t\tError (\"Error: unexpected end of file\");\n\n\t\t\tfread(&tshort, sizeof(tshort), 1, input);\n\t\t\tbytesread += sizeof(tshort);\n\t\t\ttris[i].v[j] = (int)tshort;\n\t\t}\n\t}\n\n\tif (vertsfound && trisfound)\n\t\tStoreAliasTriangles ();\n\n\treturn bytesread - startbytesread;\n}\n\n\nint ParseChunk (FILE *input)\n{\n#define BLOCK_SIZE\t4096\n\tchar\t\t\ttemp[BLOCK_SIZE];\n\tunsigned short\ttype;\n\tint\t\t\t\ti, length, w, t, retval;\n\n\tlevel++;\n\tretval = 0;\n\n// chunk type\n\tif (feof(input))\n\t\tError (\"Error: unexpected end of file\");\n\n\tfread(&type, sizeof(type), 1, input);\n\tbytesread += sizeof(type);\n\n// chunk length\n\tif (feof(input))\n\t\tError (\"Error: unexpected end of file\");\n\n\tfread (&length, sizeof(length), 1, input);\n\tbytesread += sizeof(length);\n\tw = length - 6;\n\n// process chunk if we care about it, otherwise skip it\n\tswitch (type)\n\t{\n\tcase TRI_VERTEXL:\n\t\tw -= ParseVertexL (input);\n\t\tgoto ParseSubchunk;\n\n\tcase TRI_FACEL1:\n\t\tw -= ParseFaceL1 (input);\n\t\tgoto ParseSubchunk;\n\n\tcase EDIT_OBJECT:\n\t// read the name\n\t\ti = 0;\n\n\t\tdo\n\t\t{\n\t\t\tif (feof(input))\n\t\t\t\tError (\"Error: unexpected end of file\");\n\n\t\t\tfread (&temp[i], 1, 1, input);\n\t\t\ti++;\n\t\t\tw--;\n\t\t\tbytesread++;\n\t\t} while (temp[i-1]);\n\n\tcase MAIN3DS:\n\tcase OBJ_TRIMESH:\n\tcase EDIT3DS:\n\t// parse through subchunks\nParseSubchunk:\n\t\twhile (w > 0)\n\t\t{\n\t\t\tw -= ParseChunk (input);\n\t\t}\n\n\t\tretval = length;\n\t\tgoto Done;\n\n\tdefault:\n\t// skip other chunks\n\t\twhile (w > 0)\n\t\t{\n\t\t\tt = w;\n\n\t\t\tif (t > BLOCK_SIZE)\n\t\t\t\tt = BLOCK_SIZE;\n\n\t\t\tif (feof(input))\n\t\t\t\tError (\"Error: unexpected end of file\");\n\n\t\t\tfread (&temp, t, 1, input);\n\t\t\tbytesread += t;\n\n\t\t\tw -= t;\n\t\t}\n\n\t\tretval = length;\n\t\tgoto Done;\n\t}\n\nDone:\n\tlevel--;\n\treturn retval;\n}\n\n\nvoid Load3DSTriangleList (char *filename, triangle_t **pptri, int *numtriangles)\n{\n\tFILE        *input;\n\tshort int\ttshort;\n\n\tbytesread = 0;\n\tlevel = 0;\n\tnumtris = 0;\n\ttotaltris = 0;\n\tvertsfound = 0;\n\ttrisfound = 0;\n\n\tif ((input = fopen(filename, \"rb\")) == 0) {\n\t\tfprintf(stderr,\"reader: could not open file '%s'\\n\", filename);\n\t\texit(0);\n\t}\n\n\tfread(&tshort, sizeof(tshort), 1, input);\n\n// should only be MAIN3DS, but some files seem to start with EDIT3DS, with\n// no MAIN3DS\n\tif ((tshort != MAIN3DS) && (tshort != EDIT3DS)) {\n\t\tfprintf(stderr,\"File is not a 3DS file.\\n\");\n\t\texit(0);\n\t}\n\n// back to top of file so we can parse the first chunk descriptor\n\tfseek(input, 0, SEEK_SET);\n\n\tptri = malloc (MAXTRIANGLES * sizeof(triangle_t));\n\n\t*pptri = ptri;\n\n// parse through looking for the relevant chunk tree (MAIN3DS | EDIT3DS | EDIT_OBJECT |\n// OBJ_TRIMESH | {TRI_VERTEXL, TRI_FACEL1}) and skipping other chunks\n\tParseChunk (input);\n\n\tif (vertsfound || trisfound)\n\t\tError (\"Incomplete triangle set\");\n\n\t*numtriangles = totaltris;\n\n\tfclose (input);\n}\n\n"
  },
  {
    "path": "common/l3dslib.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// l3dslib.h: header file for loading triangles from a 3DS triangle file\n//\nvoid Load3DSTriangleList (char *filename, triangle_t **pptri, int *numtriangles);\n\n"
  },
  {
    "path": "common/mathlib.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// mathlib.c -- math primitives\n\n#include \"cmdlib.h\"\n#include \"mathlib.h\"\n\n#ifdef _WIN32\n//Improve floating-point consistency.\n//without this option weird floating point issues occur\n#pragma optimize( \"p\", on )\n#endif\n\n\nvec3_t vec3_origin = {0,0,0};\n\n/*\n** NormalToLatLong\n**\n** We use two byte encoded normals in some space critical applications.\n** Lat = 0 at (1,0,0) to 360 (-1,0,0), encoded in 8-bit sine table format\n** Lng = 0 at (0,0,1) to 180 (0,0,-1), encoded in 8-bit sine table format\n**\n*/\nvoid NormalToLatLong( const vec3_t normal, byte bytes[2] ) {\n\t// check for singularities\n\tif ( normal[0] == 0 && normal[1] == 0 ) {\n\t\tif ( normal[2] > 0 ) {\n\t\t\tbytes[0] = 0;\n\t\t\tbytes[1] = 0;\t\t// lat = 0, long = 0\n\t\t} else {\n\t\t\tbytes[0] = 128;\n\t\t\tbytes[1] = 0;\t\t// lat = 0, long = 128\n\t\t}\n\t} else {\n\t\tint\ta, b;\n\n\t\ta = RAD2DEG( atan2( normal[1], normal[0] ) ) * (255.0f / 360.0f );\n\t\ta &= 0xff;\n\n\t\tb = RAD2DEG( acos( normal[2] ) ) * ( 255.0f / 360.0f );\n\t\tb &= 0xff;\n\n\t\tbytes[0] = b;\t// longitude\n\t\tbytes[1] = a;\t// lattitude\n\t}\n}\n\n/*\n=====================\nPlaneFromPoints\n\nReturns false if the triangle is degenrate.\nThe normal will point out of the clock for clockwise ordered points\n=====================\n*/\nqboolean PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const vec3_t c ) {\n\tvec3_t\td1, d2;\n\n\tVectorSubtract( b, a, d1 );\n\tVectorSubtract( c, a, d2 );\n\tCrossProduct( d2, d1, plane );\n\tif ( VectorNormalize( plane, plane ) == 0 ) {\n\t\treturn qfalse;\n\t}\n\n\tplane[3] = DotProduct( a, plane );\n\treturn qtrue;\n}\n\n/*\n================\nMakeNormalVectors\n\nGiven a normalized forward vector, create two\nother perpendicular vectors\n================\n*/\nvoid MakeNormalVectors (vec3_t forward, vec3_t right, vec3_t up)\n{\n\tfloat\t\td;\n\n\t// this rotate and negate guarantees a vector\n\t// not colinear with the original\n\tright[1] = -forward[0];\n\tright[2] = forward[1];\n\tright[0] = forward[2];\n\n\td = DotProduct (right, forward);\n\tVectorMA (right, -d, forward, right);\n\tVectorNormalize (right, right);\n\tCrossProduct (right, forward, up);\n}\n\n\nvoid Vec10Copy( vec_t *in, vec_t *out ) {\n\tout[0] = in[0];\n\tout[1] = in[1];\n\tout[2] = in[2];\n\tout[3] = in[3];\n\tout[4] = in[4];\n\tout[5] = in[5];\n\tout[6] = in[6];\n\tout[7] = in[7];\n\tout[8] = in[8];\n\tout[9] = in[9];\n}\n\n\nvoid VectorRotate3x3( vec3_t v, float r[3][3], vec3_t d )\n{\n\td[0] = v[0] * r[0][0] + v[1] * r[1][0] + v[2] * r[2][0];\n\td[1] = v[0] * r[0][1] + v[1] * r[1][1] + v[2] * r[2][1];\n\td[2] = v[0] * r[0][2] + v[1] * r[1][2] + v[2] * r[2][2];\n}\n\ndouble VectorLength( const vec3_t v ) {\n\tint\t\ti;\n\tdouble\tlength;\n\t\n\tlength = 0;\n\tfor (i=0 ; i< 3 ; i++)\n\t\tlength += v[i]*v[i];\n\tlength = sqrt (length);\t\t// FIXME\n\n\treturn length;\n}\n\nqboolean VectorCompare( const vec3_t v1, const vec3_t v2 ) {\n\tint\t\ti;\n\t\n\tfor (i=0 ; i<3 ; i++)\n\t\tif (fabs(v1[i]-v2[i]) > EQUAL_EPSILON)\n\t\t\treturn qfalse;\n\t\t\t\n\treturn qtrue;\n}\n\nvec_t Q_rint (vec_t in)\n{\n\treturn floor (in + 0.5);\n}\n\nvoid VectorMA( const vec3_t va, double scale, const vec3_t vb, vec3_t vc ) {\n\tvc[0] = va[0] + scale*vb[0];\n\tvc[1] = va[1] + scale*vb[1];\n\tvc[2] = va[2] + scale*vb[2];\n}\n\nvoid CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ) {\n\tcross[0] = v1[1]*v2[2] - v1[2]*v2[1];\n\tcross[1] = v1[2]*v2[0] - v1[0]*v2[2];\n\tcross[2] = v1[0]*v2[1] - v1[1]*v2[0];\n}\n\nvec_t _DotProduct (vec3_t v1, vec3_t v2)\n{\n\treturn v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];\n}\n\nvoid _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out)\n{\n\tout[0] = va[0]-vb[0];\n\tout[1] = va[1]-vb[1];\n\tout[2] = va[2]-vb[2];\n}\n\nvoid _VectorAdd (vec3_t va, vec3_t vb, vec3_t out)\n{\n\tout[0] = va[0]+vb[0];\n\tout[1] = va[1]+vb[1];\n\tout[2] = va[2]+vb[2];\n}\n\nvoid _VectorCopy (vec3_t in, vec3_t out)\n{\n\tout[0] = in[0];\n\tout[1] = in[1];\n\tout[2] = in[2];\n}\n\nvoid _VectorScale (vec3_t v, vec_t scale, vec3_t out)\n{\n\tout[0] = v[0] * scale;\n\tout[1] = v[1] * scale;\n\tout[2] = v[2] * scale;\n}\n\nvec_t VectorNormalize( const vec3_t in, vec3_t out ) {\n\tvec_t\tlength, ilength;\n\n\tlength = sqrt (in[0]*in[0] + in[1]*in[1] + in[2]*in[2]);\n\tif (length == 0)\n\t{\n\t\tVectorClear (out);\n\t\treturn 0;\n\t}\n\n\tilength = 1.0/length;\n\tout[0] = in[0]*ilength;\n\tout[1] = in[1]*ilength;\n\tout[2] = in[2]*ilength;\n\n\treturn length;\n}\n\nvec_t ColorNormalize( const vec3_t in, vec3_t out ) {\n\tfloat\tmax, scale;\n\n\tmax = in[0];\n\tif (in[1] > max)\n\t\tmax = in[1];\n\tif (in[2] > max)\n\t\tmax = in[2];\n\n\tif (max == 0) {\n\t\tout[0] = out[1] = out[2] = 1.0;\n\t\treturn 0;\n\t}\n\n\tscale = 1.0 / max;\n\n\tVectorScale (in, scale, out);\n\n\treturn max;\n}\n\n\n\nvoid VectorInverse (vec3_t v)\n{\n\tv[0] = -v[0];\n\tv[1] = -v[1];\n\tv[2] = -v[2];\n}\n\nvoid ClearBounds (vec3_t mins, vec3_t maxs)\n{\n\tmins[0] = mins[1] = mins[2] = 99999;\n\tmaxs[0] = maxs[1] = maxs[2] = -99999;\n}\n\nvoid AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs ) {\n\tint\t\ti;\n\tvec_t\tval;\n\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tval = v[i];\n\t\tif (val < mins[i])\n\t\t\tmins[i] = val;\n\t\tif (val > maxs[i])\n\t\t\tmaxs[i] = val;\n\t}\n}\n\n\n/*\n=================\nPlaneTypeForNormal\n=================\n*/\nint\tPlaneTypeForNormal (vec3_t normal) {\n\tif (normal[0] == 1.0 || normal[0] == -1.0)\n\t\treturn PLANE_X;\n\tif (normal[1] == 1.0 || normal[1] == -1.0)\n\t\treturn PLANE_Y;\n\tif (normal[2] == 1.0 || normal[2] == -1.0)\n\t\treturn PLANE_Z;\n\t\n\treturn PLANE_NON_AXIAL;\n}\n\n/*\n================\nMatrixMultiply\n================\n*/\nvoid MatrixMultiply(float in1[3][3], float in2[3][3], float out[3][3]) {\n\tout[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] +\n\t\t\t\tin1[0][2] * in2[2][0];\n\tout[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] +\n\t\t\t\tin1[0][2] * in2[2][1];\n\tout[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] +\n\t\t\t\tin1[0][2] * in2[2][2];\n\tout[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] +\n\t\t\t\tin1[1][2] * in2[2][0];\n\tout[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] +\n\t\t\t\tin1[1][2] * in2[2][1];\n\tout[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] +\n\t\t\t\tin1[1][2] * in2[2][2];\n\tout[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] +\n\t\t\t\tin1[2][2] * in2[2][0];\n\tout[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] +\n\t\t\t\tin1[2][2] * in2[2][1];\n\tout[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] +\n\t\t\t\tin1[2][2] * in2[2][2];\n}\n\nvoid ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal )\n{\n\tfloat d;\n\tvec3_t n;\n\tfloat inv_denom;\n\n\tinv_denom = 1.0F / DotProduct( normal, normal );\n\n\td = DotProduct( normal, p ) * inv_denom;\n\n\tn[0] = normal[0] * inv_denom;\n\tn[1] = normal[1] * inv_denom;\n\tn[2] = normal[2] * inv_denom;\n\n\tdst[0] = p[0] - d * n[0];\n\tdst[1] = p[1] - d * n[1];\n\tdst[2] = p[2] - d * n[2];\n}\n\n/*\n** assumes \"src\" is normalized\n*/\nvoid PerpendicularVector( vec3_t dst, const vec3_t src )\n{\n\tint\tpos;\n\tint i;\n\tfloat minelem = 1.0F;\n\tvec3_t tempvec;\n\n\t/*\n\t** find the smallest magnitude axially aligned vector\n\t*/\n\tfor ( pos = 0, i = 0; i < 3; i++ )\n\t{\n\t\tif ( fabs( src[i] ) < minelem )\n\t\t{\n\t\t\tpos = i;\n\t\t\tminelem = fabs( src[i] );\n\t\t}\n\t}\n\ttempvec[0] = tempvec[1] = tempvec[2] = 0.0F;\n\ttempvec[pos] = 1.0F;\n\n\t/*\n\t** project the point onto the plane defined by src\n\t*/\n\tProjectPointOnPlane( dst, tempvec, src );\n\n\t/*\n\t** normalize the result\n\t*/\n\tVectorNormalize( dst, dst );\n}\n\n/*\n===============\nRotatePointAroundVector\n\nThis is not implemented very well...\n===============\n*/\nvoid RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point,\n\t\t\t\t\t\t\t float degrees ) {\n\tfloat\tm[3][3];\n\tfloat\tim[3][3];\n\tfloat\tzrot[3][3];\n\tfloat\ttmpmat[3][3];\n\tfloat\trot[3][3];\n\tint\ti;\n\tvec3_t vr, vup, vf;\n\tfloat\trad;\n\n\tvf[0] = dir[0];\n\tvf[1] = dir[1];\n\tvf[2] = dir[2];\n\n\tPerpendicularVector( vr, dir );\n\tCrossProduct( vr, vf, vup );\n\n\tm[0][0] = vr[0];\n\tm[1][0] = vr[1];\n\tm[2][0] = vr[2];\n\n\tm[0][1] = vup[0];\n\tm[1][1] = vup[1];\n\tm[2][1] = vup[2];\n\n\tm[0][2] = vf[0];\n\tm[1][2] = vf[1];\n\tm[2][2] = vf[2];\n\n\tmemcpy( im, m, sizeof( im ) );\n\n\tim[0][1] = m[1][0];\n\tim[0][2] = m[2][0];\n\tim[1][0] = m[0][1];\n\tim[1][2] = m[2][1];\n\tim[2][0] = m[0][2];\n\tim[2][1] = m[1][2];\n\n\tmemset( zrot, 0, sizeof( zrot ) );\n\tzrot[0][0] = zrot[1][1] = zrot[2][2] = 1.0F;\n\n\trad = DEG2RAD( degrees );\n\tzrot[0][0] = cos( rad );\n\tzrot[0][1] = sin( rad );\n\tzrot[1][0] = -sin( rad );\n\tzrot[1][1] = cos( rad );\n\n\tMatrixMultiply( m, zrot, tmpmat );\n\tMatrixMultiply( tmpmat, im, rot );\n\n\tfor ( i = 0; i < 3; i++ ) {\n\t\tdst[i] = rot[i][0] * point[0] + rot[i][1] * point[1] + rot[i][2] * point[2];\n\t}\n}\n"
  },
  {
    "path": "common/mathlib.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __MATHLIB__\n#define __MATHLIB__\n\n// mathlib.h\n\n#include <math.h>\n\n#ifdef DOUBLEVEC_T\ntypedef double vec_t;\n#else\ntypedef float vec_t;\n#endif\ntypedef vec_t vec2_t[3];\ntypedef vec_t vec3_t[3];\ntypedef vec_t vec4_t[4];\n\n#define\tSIDE_FRONT\t\t0\n#define\tSIDE_ON\t\t\t2\n#define\tSIDE_BACK\t\t1\n#define\tSIDE_CROSS\t\t-2\n\n#define\tQ_PI\t3.14159265358979323846\n#define DEG2RAD( a ) ( ( (a) * Q_PI ) / 180.0F )\n#define RAD2DEG( a ) ( ( (a) * 180.0f ) / Q_PI )\n\nextern vec3_t vec3_origin;\n\n#define\tEQUAL_EPSILON\t0.001\n\n// plane types are used to speed some tests\n// 0-2 are axial planes\n#define\tPLANE_X\t\t\t0\n#define\tPLANE_Y\t\t\t1\n#define\tPLANE_Z\t\t\t2\n#define\tPLANE_NON_AXIAL\t3\n\nqboolean VectorCompare( const vec3_t v1, const vec3_t v2 );\n\n#define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])\n#define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];}\n#define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];}\n#define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];}\n#define VectorScale(a,b,c) {c[0]=b*a[0];c[1]=b*a[1];c[2]=b*a[2];}\n#define VectorClear(x) {x[0] = x[1] = x[2] = 0;}\n#define\tVectorNegate(x) {x[0]=-x[0];x[1]=-x[1];x[2]=-x[2];}\nvoid Vec10Copy( vec_t *in, vec_t *out );\n\nvec_t Q_rint (vec_t in);\nvec_t _DotProduct (vec3_t v1, vec3_t v2);\nvoid _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out);\nvoid _VectorAdd (vec3_t va, vec3_t vb, vec3_t out);\nvoid _VectorCopy (vec3_t in, vec3_t out);\nvoid _VectorScale (vec3_t v, vec_t scale, vec3_t out);\n\ndouble VectorLength( const vec3_t v );\n\nvoid VectorMA( const vec3_t va, double scale, const vec3_t vb, vec3_t vc );\n\nvoid CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross );\nvec_t VectorNormalize( const vec3_t in, vec3_t out );\nvec_t ColorNormalize( const vec3_t in, vec3_t out );\nvoid VectorInverse (vec3_t v);\n\nvoid ClearBounds (vec3_t mins, vec3_t maxs);\nvoid AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs );\n\nqboolean PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const vec3_t c );\n\nvoid NormalToLatLong( const vec3_t normal, byte bytes[2] );\n\nint\tPlaneTypeForNormal (vec3_t normal);\n\nvoid RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point,\n\t\t\t\t\t\t\t float degrees );\n#endif\n"
  },
  {
    "path": "common/md4.c",
    "content": "/* GLOBAL.H - RSAREF types and constants */\n\n#include <string.h>\n\n/* POINTER defines a generic pointer type */\ntypedef unsigned char *POINTER;\n\n/* UINT2 defines a two byte word */\ntypedef unsigned short int UINT2;\n\n/* UINT4 defines a four byte word */\ntypedef unsigned long int UINT4;\n\n  \n/* MD4.H - header file for MD4C.C */\n\n/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. \n\nAll rights reserved.\n  \nLicense to copy and use this software is granted provided that it is identified as the RSA Data Security, Inc. MD4 Message-Digest Algorithm in all material mentioning or referencing this software or this function.\nLicense is also granted to make and use derivative works provided that such works are identified as derived from the RSA Data Security, Inc. MD4 Message-Digest Algorithm in all material mentioning or referencing the derived work.\nRSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided as is without express or implied warranty of any kind.\n  \nThese notices must be retained in any copies of any part of this documentation and/or software. */\n\n/* MD4 context. */\ntypedef struct {\n\tUINT4 state[4];\t\t\t\t/* state (ABCD) */\n\tUINT4 count[2];\t\t\t\t/* number of bits, modulo 2^64 (lsb first) */\n\tunsigned char buffer[64]; \t\t\t/* input buffer */\n} MD4_CTX;\n\nvoid MD4Init (MD4_CTX *);\nvoid MD4Update (MD4_CTX *, unsigned char *, unsigned int);\nvoid MD4Final (unsigned char [16], MD4_CTX *);\n  \n\n  \n/* MD4C.C - RSA Data Security, Inc., MD4 message-digest algorithm */\n/* Copyright (C) 1990-2, RSA Data Security, Inc. All rights reserved.\n  \nLicense to copy and use this software is granted provided that it is identified as the\nRSA Data Security, Inc. MD4 Message-Digest Algorithm\n in all material mentioning or referencing this software or this function.\nLicense is also granted to make and use derivative works provided that such works are identified as \nderived from the RSA Data Security, Inc. MD4 Message-Digest Algorithm\nin all material mentioning or referencing the derived work.\nRSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided\nas is without express or implied warranty of any kind.\n  \nThese notices must be retained in any copies of any part of this documentation and/or software. */\n\n/* Constants for MD4Transform routine.  */\n#define S11 3\n#define S12 7\n#define S13 11\n#define S14 19\n#define S21 3\n#define S22 5\n#define S23 9\n#define S24 13\n#define S31 3\n#define S32 9\n#define S33 11\n#define S34 15\n\nstatic void MD4Transform (UINT4 [4], unsigned char [64]);\nstatic void Encode (unsigned char *, UINT4 *, unsigned int);\nstatic void Decode (UINT4 *, unsigned char *, unsigned int);\nstatic void MD4_memcpy (POINTER, POINTER, unsigned int);\nstatic void MD4_memset (POINTER, int, unsigned int);\n\nstatic unsigned char PADDING[64] = {\n0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\n};\n\n/* F, G and H are basic MD4 functions. */\n#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))\n#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))\n#define H(x, y, z) ((x) ^ (y) ^ (z))\n\n/* ROTATE_LEFT rotates x left n bits. */\n#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))\n\n/* FF, GG and HH are transformations for rounds 1, 2 and 3 */\n/* Rotation is separate from addition to prevent recomputation */\n#define FF(a, b, c, d, x, s) {(a) += F ((b), (c), (d)) + (x); (a) = ROTATE_LEFT ((a), (s));}\n\n#define GG(a, b, c, d, x, s) {(a) += G ((b), (c), (d)) + (x) + (UINT4)0x5a827999; (a) = ROTATE_LEFT ((a), (s));}\n\n#define HH(a, b, c, d, x, s) {(a) += H ((b), (c), (d)) + (x) + (UINT4)0x6ed9eba1; (a) = \\\nROTATE_LEFT ((a), (s)); }\n\n\n/* MD4 initialization. Begins an MD4 operation, writing a new context. */\nvoid MD4Init (MD4_CTX *context)\n{\n\tcontext->count[0] = context->count[1] = 0;\n\n/* Load magic initialization constants.*/\ncontext->state[0] = 0x67452301;\ncontext->state[1] = 0xefcdab89;\ncontext->state[2] = 0x98badcfe;\ncontext->state[3] = 0x10325476;\n}\n\n/* MD4 block update operation. Continues an MD4 message-digest operation, processing another message block, and updating the context. */\nvoid MD4Update (MD4_CTX *context, unsigned char *input, unsigned int inputLen)\n{\n\tunsigned int i, index, partLen;\n\n\t/* Compute number of bytes mod 64 */\n\tindex = (unsigned int)((context->count[0] >> 3) & 0x3F);\n\n\t/* Update number of bits */\n\tif ((context->count[0] += ((UINT4)inputLen << 3))< ((UINT4)inputLen << 3))\n\t\tcontext->count[1]++;\n\n\tcontext->count[1] += ((UINT4)inputLen >> 29);\n\n\tpartLen = 64 - index;\n\n\t/* Transform as many times as possible.*/\n\tif (inputLen >= partLen)\n\t{\n \t\tmemcpy((POINTER)&context->buffer[index], (POINTER)input, partLen);\n \t\tMD4Transform (context->state, context->buffer);\n\n \t\tfor (i = partLen; i + 63 < inputLen; i += 64)\n \t\t\tMD4Transform (context->state, &input[i]);\n\n \t\tindex = 0;\n\t}\n\telse\n \t\ti = 0;\n\n\t/* Buffer remaining input */\n\tmemcpy ((POINTER)&context->buffer[index], (POINTER)&input[i], inputLen-i);\n}\n\n\n/* MD4 finalization. Ends an MD4 message-digest operation, writing the the message digest and zeroizing the context. */\nvoid MD4Final (unsigned char digest[16], MD4_CTX *context)\n{\n\tunsigned char bits[8];\n\tunsigned int index, padLen;\n\n\t/* Save number of bits */\n\tEncode (bits, context->count, 8);\n\n\t/* Pad out to 56 mod 64.*/\n\tindex = (unsigned int)((context->count[0] >> 3) & 0x3f);\n\tpadLen = (index < 56) ? (56 - index) : (120 - index);\n\tMD4Update (context, PADDING, padLen);\n\n\t/* Append length (before padding) */\n\tMD4Update (context, bits, 8);\n\t\n\t/* Store state in digest */\n\tEncode (digest, context->state, 16);\n\n\t/* Zeroize sensitive information.*/\n\tmemset ((POINTER)context, 0, sizeof (*context));\n}\n\n\n/* MD4 basic transformation. Transforms state based on block. */\nstatic void MD4Transform (UINT4 state[4], unsigned char block[64])\n{\n\tUINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];\n\n\tDecode (x, block, 64);\n\n/* Round 1 */\nFF (a, b, c, d, x[ 0], S11); \t\t\t\t/* 1 */\nFF (d, a, b, c, x[ 1], S12); \t\t\t\t/* 2 */\nFF (c, d, a, b, x[ 2], S13); \t\t\t\t/* 3 */\nFF (b, c, d, a, x[ 3], S14); \t\t\t\t/* 4 */\nFF (a, b, c, d, x[ 4], S11); \t\t\t\t/* 5 */\nFF (d, a, b, c, x[ 5], S12); \t\t\t\t/* 6 */\nFF (c, d, a, b, x[ 6], S13); \t\t\t\t/* 7 */\nFF (b, c, d, a, x[ 7], S14); \t\t\t\t/* 8 */\nFF (a, b, c, d, x[ 8], S11); \t\t\t\t/* 9 */\nFF (d, a, b, c, x[ 9], S12); \t\t\t\t/* 10 */\nFF (c, d, a, b, x[10], S13); \t\t\t/* 11 */\nFF (b, c, d, a, x[11], S14); \t\t\t/* 12 */\nFF (a, b, c, d, x[12], S11); \t\t\t/* 13 */\nFF (d, a, b, c, x[13], S12); \t\t\t/* 14 */\nFF (c, d, a, b, x[14], S13); \t\t\t/* 15 */\nFF (b, c, d, a, x[15], S14); \t\t\t/* 16 */\n\n/* Round 2 */\nGG (a, b, c, d, x[ 0], S21); \t\t\t/* 17 */\nGG (d, a, b, c, x[ 4], S22); \t\t\t/* 18 */\nGG (c, d, a, b, x[ 8], S23); \t\t\t/* 19 */\nGG (b, c, d, a, x[12], S24); \t\t\t/* 20 */\nGG (a, b, c, d, x[ 1], S21); \t\t\t/* 21 */\nGG (d, a, b, c, x[ 5], S22); \t\t\t/* 22 */\nGG (c, d, a, b, x[ 9], S23); \t\t\t/* 23 */\nGG (b, c, d, a, x[13], S24); \t\t\t/* 24 */\nGG (a, b, c, d, x[ 2], S21); \t\t\t/* 25 */\nGG (d, a, b, c, x[ 6], S22); \t\t\t/* 26 */\nGG (c, d, a, b, x[10], S23); \t\t\t/* 27 */\nGG (b, c, d, a, x[14], S24); \t\t\t/* 28 */\nGG (a, b, c, d, x[ 3], S21); \t\t\t/* 29 */\nGG (d, a, b, c, x[ 7], S22); \t\t\t/* 30 */\nGG (c, d, a, b, x[11], S23); \t\t\t/* 31 */\nGG (b, c, d, a, x[15], S24); \t\t\t/* 32 */\n\n/* Round 3 */\nHH (a, b, c, d, x[ 0], S31);\t\t\t\t/* 33 */\nHH (d, a, b, c, x[ 8], S32); \t\t\t/* 34 */\nHH (c, d, a, b, x[ 4], S33); \t\t\t/* 35 */\nHH (b, c, d, a, x[12], S34); \t\t\t/* 36 */\nHH (a, b, c, d, x[ 2], S31); \t\t\t/* 37 */\nHH (d, a, b, c, x[10], S32); \t\t\t/* 38 */\nHH (c, d, a, b, x[ 6], S33); \t\t\t/* 39 */\nHH (b, c, d, a, x[14], S34); \t\t\t/* 40 */\nHH (a, b, c, d, x[ 1], S31); \t\t\t/* 41 */\nHH (d, a, b, c, x[ 9], S32); \t\t\t/* 42 */\nHH (c, d, a, b, x[ 5], S33); \t\t\t/* 43 */\nHH (b, c, d, a, x[13], S34); \t\t\t/* 44 */\nHH (a, b, c, d, x[ 3], S31); \t\t\t/* 45 */\nHH (d, a, b, c, x[11], S32); \t\t\t/* 46 */\nHH (c, d, a, b, x[ 7], S33); \t\t\t/* 47 */\nHH (b, c, d, a, x[15], S34);\t\t\t/* 48 */\n\nstate[0] += a;\nstate[1] += b;\nstate[2] += c;\nstate[3] += d;\n\n\t/* Zeroize sensitive information.*/\n\tmemset ((POINTER)x, 0, sizeof (x));\n}\n\n\n/* Encodes input (UINT4) into output (unsigned char). Assumes len is a multiple of 4. */\nstatic void Encode (unsigned char *output, UINT4 *input, unsigned int len)\n{\n\tunsigned int i, j;\n\n\tfor (i = 0, j = 0; j < len; i++, j += 4) {\n \t\toutput[j] = (unsigned char)(input[i] & 0xff);\n \t\toutput[j+1] = (unsigned char)((input[i] >> 8) & 0xff);\n \t\toutput[j+2] = (unsigned char)((input[i] >> 16) & 0xff);\n \t\toutput[j+3] = (unsigned char)((input[i] >> 24) & 0xff);\n\t}\n}\n\n\n/* Decodes input (unsigned char) into output (UINT4). Assumes len is a multiple of 4. */\nstatic void Decode (UINT4 *output, unsigned char *input, unsigned int len)\n{\nunsigned int i, j;\n\nfor (i = 0, j = 0; j < len; i++, j += 4)\n \toutput[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);\n}\n\n//===================================================================\n\nunsigned Com_BlockChecksum (void *buffer, int length)\n{\n\tint\t\t\tdigest[4];\n\tunsigned\tval;\n\tMD4_CTX\t\tctx;\n\n\tMD4Init (&ctx);\n\tMD4Update (&ctx, (unsigned char *)buffer, length);\n\tMD4Final ( (unsigned char *)digest, &ctx);\n\t\n\tval = digest[0] ^ digest[1] ^ digest[2] ^ digest[3];\n\n\treturn val;\n}\n"
  },
  {
    "path": "common/mutex.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"cmdlib.h\"\n#include \"threads.h\"\n#include \"mutex.h\"\n\n/*\n===================================================================\n\nWIN32\n\n===================================================================\n*/\n#ifdef WIN32\n\n#define\tUSED\n\n#include <windows.h>\n\nvoid MutexLock (mutex_t *m)\n{\n\tCRITICAL_SECTION *crit;\n\n\tif (!m)\n\t\treturn;\n\tcrit = (CRITICAL_SECTION *) m;\n\tEnterCriticalSection (crit);\n}\n\nvoid MutexUnlock (mutex_t *m)\n{\n\tCRITICAL_SECTION *crit;\n\n\tif (!m)\n\t\treturn;\n\tcrit = (CRITICAL_SECTION *) m;\n\tLeaveCriticalSection (crit);\n}\n\nmutex_t *MutexAlloc(void)\n{\n\tCRITICAL_SECTION *crit;\n\n\tif (numthreads == 1)\n\t\treturn NULL;\n\tcrit = (CRITICAL_SECTION *) malloc(sizeof(CRITICAL_SECTION));\n\tInitializeCriticalSection (crit);\n\treturn (void *) crit;\n}\n\n#endif\n\n/*\n===================================================================\n\nOSF1\n\n===================================================================\n*/\n\n#ifdef __osf__\n#define\tUSED\n\n#include <pthread.h>\n\nvoid MutexLock (mutex_t *m)\n{\n\tpthread_mutex_t\t*my_mutex;\n\n\tif (!m)\n\t\treturn;\n\tmy_mutex = (pthread_mutex_t *) m;\n\tpthread_mutex_lock (my_mutex);\n}\n\nvoid MutexUnlock (mutex_t *m)\n{\n\tpthread_mutex_t\t*my_mutex;\n\n\tif (!m)\n\t\treturn;\n\tmy_mutex = (pthread_mutex_t *) m;\n\tpthread_mutex_unlock (my_mutex);\n}\n\nmutex_t *MutexAlloc(void)\n{\n\tpthread_mutex_t\t*my_mutex;\n\tpthread_mutexattr_t\tmattrib;\n\n\tif (numthreads == 1)\n\t\treturn NULL;\n\tmy_mutex = malloc (sizeof(*my_mutex));\n\tif (pthread_mutexattr_create (&mattrib) == -1)\n\t\tError (\"pthread_mutex_attr_create failed\");\n\tif (pthread_mutexattr_setkind_np (&mattrib, MUTEX_FAST_NP) == -1)\n\t\tError (\"pthread_mutexattr_setkind_np failed\");\n\tif (pthread_mutex_init (my_mutex, mattrib) == -1)\n\t\tError (\"pthread_mutex_init failed\");\n\treturn (void *) my_mutex;\n}\n\n#endif\n\n/*\n===================================================================\n\nIRIX\n\n===================================================================\n*/\n\n#ifdef _MIPS_ISA \n#define\tUSED\n\n#include <task.h>\n#include <abi_mutex.h>\n#include <sys/types.h>\n#include <sys/prctl.h>\n\nvoid MutexLock (mutex_t *m)\n{\n\tabilock_t *lck;\n\n\tif (!m)\n\t\treturn;\n\tlck = (abilock_t *) m;\n\tspin_lock (lck);\n}\n\nvoid MutexUnlock (mutex_t *m)\n{\n\tabilock_t *lck;\n\n\tif (!m)\n\t\treturn;\n\tlck = (abilock_t *) m;\n\trelease_lock (lck);\n}\n\nmutex_t *MutexAlloc(void)\n{\n\tabilock_t *lck;\n\n\tif (numthreads == 1)\n\t\treturn NULL;\n\tlck = (abilock_t *) malloc(sizeof(abilock_t));\n\tinit_lock (lck);\n\treturn (void *) lck;\n}\n\n#endif\n\n/*\n=======================================================================\n\n  SINGLE THREAD\n\n=======================================================================\n*/\n\n#ifndef USED\n\nvoid MutexLock (mutex_t *m)\n{\n}\n\nvoid MutexUnlock (mutex_t *m)\n{\n}\n\nmutex_t *MutexAlloc(void)\n{\n\treturn NULL;\n}\n\n#endif\n"
  },
  {
    "path": "common/mutex.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n\ntypedef void *mutex_t;\n\nvoid MutexLock (mutex_t *m);\nvoid MutexUnlock (mutex_t *m);\nmutex_t *MutexAlloc(void);\n"
  },
  {
    "path": "common/polylib.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"cmdlib.h\"\n#include \"mathlib.h\"\n#include \"polylib.h\"\n#include \"qfiles.h\"\n\n\nextern int numthreads;\n\n// counters are only bumped when running single threaded,\n// because they are an awefull coherence problem\nint\tc_active_windings;\nint\tc_peak_windings;\nint\tc_winding_allocs;\nint\tc_winding_points;\n\n#define\tBOGUS_RANGE\tWORLD_SIZE\n\nvoid pw(winding_t *w)\n{\n\tint\t\ti;\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\tprintf (\"(%5.1f, %5.1f, %5.1f)\\n\",w->p[i][0], w->p[i][1],w->p[i][2]);\n}\n\n\n/*\n=============\nAllocWinding\n=============\n*/\nwinding_t\t*AllocWinding (int points)\n{\n\twinding_t\t*w;\n\tint\t\t\ts;\n\n\tif (numthreads == 1)\n\t{\n\t\tc_winding_allocs++;\n\t\tc_winding_points += points;\n\t\tc_active_windings++;\n\t\tif (c_active_windings > c_peak_windings)\n\t\t\tc_peak_windings = c_active_windings;\n\t}\n\ts = sizeof(vec_t)*3*points + sizeof(int);\n\tw = malloc (s);\n\tmemset (w, 0, s); \n\treturn w;\n}\n\nvoid FreeWinding (winding_t *w)\n{\n\tif (*(unsigned *)w == 0xdeaddead)\n\t\tError (\"FreeWinding: freed a freed winding\");\n\t*(unsigned *)w = 0xdeaddead;\n\n\tif (numthreads == 1)\n\t\tc_active_windings--;\n\tfree (w);\n}\n\n/*\n============\nRemoveColinearPoints\n============\n*/\nint\tc_removed;\n\nvoid\tRemoveColinearPoints (winding_t *w)\n{\n\tint\t\ti, j, k;\n\tvec3_t\tv1, v2;\n\tint\t\tnump;\n\tvec3_t\tp[MAX_POINTS_ON_WINDING];\n\n\tnump = 0;\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tj = (i+1)%w->numpoints;\n\t\tk = (i+w->numpoints-1)%w->numpoints;\n\t\tVectorSubtract (w->p[j], w->p[i], v1);\n\t\tVectorSubtract (w->p[i], w->p[k], v2);\n\t\tVectorNormalize(v1,v1);\n\t\tVectorNormalize(v2,v2);\n\t\tif (DotProduct(v1, v2) < 0.999)\n\t\t{\n\t\t\tVectorCopy (w->p[i], p[nump]);\n\t\t\tnump++;\n\t\t}\n\t}\n\n\tif (nump == w->numpoints)\n\t\treturn;\n\n\tif (numthreads == 1)\n\t\tc_removed += w->numpoints - nump;\n\tw->numpoints = nump;\n\tmemcpy (w->p, p, nump*sizeof(p[0]));\n}\n\n/*\n============\nWindingPlane\n============\n*/\nvoid WindingPlane (winding_t *w, vec3_t normal, vec_t *dist)\n{\n\tvec3_t\tv1, v2;\n\n\tVectorSubtract (w->p[1], w->p[0], v1);\n\tVectorSubtract (w->p[2], w->p[0], v2);\n\tCrossProduct (v2, v1, normal);\n\tVectorNormalize (normal, normal);\n\t*dist = DotProduct (w->p[0], normal);\n\n}\n\n/*\n=============\nWindingArea\n=============\n*/\nvec_t\tWindingArea (winding_t *w)\n{\n\tint\t\ti;\n\tvec3_t\td1, d2, cross;\n\tvec_t\ttotal;\n\n\ttotal = 0;\n\tfor (i=2 ; i<w->numpoints ; i++)\n\t{\n\t\tVectorSubtract (w->p[i-1], w->p[0], d1);\n\t\tVectorSubtract (w->p[i], w->p[0], d2);\n\t\tCrossProduct (d1, d2, cross);\n\t\ttotal += 0.5 * VectorLength ( cross );\n\t}\n\treturn total;\n}\n\nvoid\tWindingBounds (winding_t *w, vec3_t mins, vec3_t maxs)\n{\n\tvec_t\tv;\n\tint\t\ti,j;\n\n\tmins[0] = mins[1] = mins[2] = 99999;\n\tmaxs[0] = maxs[1] = maxs[2] = -99999;\n\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\tv = w->p[i][j];\n\t\t\tif (v < mins[j])\n\t\t\t\tmins[j] = v;\n\t\t\tif (v > maxs[j])\n\t\t\t\tmaxs[j] = v;\n\t\t}\n\t}\n}\n\n/*\n=============\nWindingCenter\n=============\n*/\nvoid\tWindingCenter (winding_t *w, vec3_t center)\n{\n\tint\t\ti;\n\tfloat\tscale;\n\n\tVectorCopy (vec3_origin, center);\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\tVectorAdd (w->p[i], center, center);\n\n\tscale = 1.0/w->numpoints;\n\tVectorScale (center, scale, center);\n}\n\n/*\n=================\nBaseWindingForPlane\n=================\n*/\nwinding_t *BaseWindingForPlane (vec3_t normal, vec_t dist)\n{\n\tint\t\ti, x;\n\tvec_t\tmax, v;\n\tvec3_t\torg, vright, vup;\n\twinding_t\t*w;\n\t\n// find the major axis\n\n\tmax = -BOGUS_RANGE;\n\tx = -1;\n\tfor (i=0 ; i<3; i++)\n\t{\n\t\tv = fabs(normal[i]);\n\t\tif (v > max)\n\t\t{\n\t\t\tx = i;\n\t\t\tmax = v;\n\t\t}\n\t}\n\tif (x==-1)\n\t\tError (\"BaseWindingForPlane: no axis found\");\n\t\t\n\tVectorCopy (vec3_origin, vup);\t\n\tswitch (x)\n\t{\n\tcase 0:\n\tcase 1:\n\t\tvup[2] = 1;\n\t\tbreak;\t\t\n\tcase 2:\n\t\tvup[0] = 1;\n\t\tbreak;\t\t\n\t}\n\n\tv = DotProduct (vup, normal);\n\tVectorMA (vup, -v, normal, vup);\n\tVectorNormalize (vup, vup);\n\t\t\n\tVectorScale (normal, dist, org);\n\t\n\tCrossProduct (vup, normal, vright);\n\t\n\tVectorScale (vup, MAX_WORLD_COORD, vup);\n\tVectorScale (vright, MAX_WORLD_COORD, vright);\n\n// project a really big\taxis aligned box onto the plane\n\tw = AllocWinding (4);\n\t\n\tVectorSubtract (org, vright, w->p[0]);\n\tVectorAdd (w->p[0], vup, w->p[0]);\n\t\n\tVectorAdd (org, vright, w->p[1]);\n\tVectorAdd (w->p[1], vup, w->p[1]);\n\t\n\tVectorAdd (org, vright, w->p[2]);\n\tVectorSubtract (w->p[2], vup, w->p[2]);\n\t\n\tVectorSubtract (org, vright, w->p[3]);\n\tVectorSubtract (w->p[3], vup, w->p[3]);\n\t\n\tw->numpoints = 4;\n\t\n\treturn w;\t\n}\n\n/*\n==================\nCopyWinding\n==================\n*/\nwinding_t\t*CopyWinding (winding_t *w)\n{\n\tint\t\t\tsize;\n\twinding_t\t*c;\n\n\tc = AllocWinding (w->numpoints);\n\tsize = (int)((winding_t *)0)->p[w->numpoints];\n\tmemcpy (c, w, size);\n\treturn c;\n}\n\n/*\n==================\nReverseWinding\n==================\n*/\nwinding_t\t*ReverseWinding (winding_t *w)\n{\n\tint\t\t\ti;\n\twinding_t\t*c;\n\n\tc = AllocWinding (w->numpoints);\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tVectorCopy (w->p[w->numpoints-1-i], c->p[i]);\n\t}\n\tc->numpoints = w->numpoints;\n\treturn c;\n}\n\n\n/*\n=============\nClipWindingEpsilon\n=============\n*/\nvoid\tClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist, \n\t\t\t\tvec_t epsilon, winding_t **front, winding_t **back)\n{\n\tvec_t\tdists[MAX_POINTS_ON_WINDING+4];\n\tint\t\tsides[MAX_POINTS_ON_WINDING+4];\n\tint\t\tcounts[3];\n\tstatic\tvec_t\tdot;\t\t// VC 4.2 optimizer bug if not static\n\tint\t\ti, j;\n\tvec_t\t*p1, *p2;\n\tvec3_t\tmid;\n\twinding_t\t*f, *b;\n\tint\t\tmaxpts;\n\t\n\tcounts[0] = counts[1] = counts[2] = 0;\n\n// determine sides for each point\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tdot = DotProduct (in->p[i], normal);\n\t\tdot -= dist;\n\t\tdists[i] = dot;\n\t\tif (dot > epsilon)\n\t\t\tsides[i] = SIDE_FRONT;\n\t\telse if (dot < -epsilon)\n\t\t\tsides[i] = SIDE_BACK;\n\t\telse\n\t\t{\n\t\t\tsides[i] = SIDE_ON;\n\t\t}\n\t\tcounts[sides[i]]++;\n\t}\n\tsides[i] = sides[0];\n\tdists[i] = dists[0];\n\t\n\t*front = *back = NULL;\n\n\tif (!counts[0])\n\t{\n\t\t*back = CopyWinding (in);\n\t\treturn;\n\t}\n\tif (!counts[1])\n\t{\n\t\t*front = CopyWinding (in);\n\t\treturn;\n\t}\n\n\tmaxpts = in->numpoints+4;\t// cant use counts[0]+2 because\n\t\t\t\t\t\t\t\t// of fp grouping errors\n\n\t*front = f = AllocWinding (maxpts);\n\t*back = b = AllocWinding (maxpts);\n\t\t\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tp1 = in->p[i];\n\t\t\n\t\tif (sides[i] == SIDE_ON)\n\t\t{\n\t\t\tVectorCopy (p1, f->p[f->numpoints]);\n\t\t\tf->numpoints++;\n\t\t\tVectorCopy (p1, b->p[b->numpoints]);\n\t\t\tb->numpoints++;\n\t\t\tcontinue;\n\t\t}\n\t\n\t\tif (sides[i] == SIDE_FRONT)\n\t\t{\n\t\t\tVectorCopy (p1, f->p[f->numpoints]);\n\t\t\tf->numpoints++;\n\t\t}\n\t\tif (sides[i] == SIDE_BACK)\n\t\t{\n\t\t\tVectorCopy (p1, b->p[b->numpoints]);\n\t\t\tb->numpoints++;\n\t\t}\n\n\t\tif (sides[i+1] == SIDE_ON || sides[i+1] == sides[i])\n\t\t\tcontinue;\n\t\t\t\n\t// generate a split point\n\t\tp2 = in->p[(i+1)%in->numpoints];\n\t\t\n\t\tdot = dists[i] / (dists[i]-dists[i+1]);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\t// avoid round off error when possible\n\t\t\tif (normal[j] == 1)\n\t\t\t\tmid[j] = dist;\n\t\t\telse if (normal[j] == -1)\n\t\t\t\tmid[j] = -dist;\n\t\t\telse\n\t\t\t\tmid[j] = p1[j] + dot*(p2[j]-p1[j]);\n\t\t}\n\t\t\t\n\t\tVectorCopy (mid, f->p[f->numpoints]);\n\t\tf->numpoints++;\n\t\tVectorCopy (mid, b->p[b->numpoints]);\n\t\tb->numpoints++;\n\t}\n\t\n\tif (f->numpoints > maxpts || b->numpoints > maxpts)\n\t\tError (\"ClipWinding: points exceeded estimate\");\n\tif (f->numpoints > MAX_POINTS_ON_WINDING || b->numpoints > MAX_POINTS_ON_WINDING)\n\t\tError (\"ClipWinding: MAX_POINTS_ON_WINDING\");\n}\n\n\n/*\n=============\nChopWindingInPlace\n=============\n*/\nvoid ChopWindingInPlace (winding_t **inout, vec3_t normal, vec_t dist, vec_t epsilon)\n{\n\twinding_t\t*in;\n\tvec_t\tdists[MAX_POINTS_ON_WINDING+4];\n\tint\t\tsides[MAX_POINTS_ON_WINDING+4];\n\tint\t\tcounts[3];\n\tstatic\tvec_t\tdot;\t\t// VC 4.2 optimizer bug if not static\n\tint\t\ti, j;\n\tvec_t\t*p1, *p2;\n\tvec3_t\tmid;\n\twinding_t\t*f;\n\tint\t\tmaxpts;\n\n\tin = *inout;\n\tcounts[0] = counts[1] = counts[2] = 0;\n\n// determine sides for each point\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tdot = DotProduct (in->p[i], normal);\n\t\tdot -= dist;\n\t\tdists[i] = dot;\n\t\tif (dot > epsilon)\n\t\t\tsides[i] = SIDE_FRONT;\n\t\telse if (dot < -epsilon)\n\t\t\tsides[i] = SIDE_BACK;\n\t\telse\n\t\t{\n\t\t\tsides[i] = SIDE_ON;\n\t\t}\n\t\tcounts[sides[i]]++;\n\t}\n\tsides[i] = sides[0];\n\tdists[i] = dists[0];\n\t\n\tif (!counts[0])\n\t{\n\t\tFreeWinding (in);\n\t\t*inout = NULL;\n\t\treturn;\n\t}\n\tif (!counts[1])\n\t\treturn;\t\t// inout stays the same\n\n\tmaxpts = in->numpoints+4;\t// cant use counts[0]+2 because\n\t\t\t\t\t\t\t\t// of fp grouping errors\n\n\tf = AllocWinding (maxpts);\n\t\t\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tp1 = in->p[i];\n\t\t\n\t\tif (sides[i] == SIDE_ON)\n\t\t{\n\t\t\tVectorCopy (p1, f->p[f->numpoints]);\n\t\t\tf->numpoints++;\n\t\t\tcontinue;\n\t\t}\n\t\n\t\tif (sides[i] == SIDE_FRONT)\n\t\t{\n\t\t\tVectorCopy (p1, f->p[f->numpoints]);\n\t\t\tf->numpoints++;\n\t\t}\n\n\t\tif (sides[i+1] == SIDE_ON || sides[i+1] == sides[i])\n\t\t\tcontinue;\n\t\t\t\n\t// generate a split point\n\t\tp2 = in->p[(i+1)%in->numpoints];\n\t\t\n\t\tdot = dists[i] / (dists[i]-dists[i+1]);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\t// avoid round off error when possible\n\t\t\tif (normal[j] == 1)\n\t\t\t\tmid[j] = dist;\n\t\t\telse if (normal[j] == -1)\n\t\t\t\tmid[j] = -dist;\n\t\t\telse\n\t\t\t\tmid[j] = p1[j] + dot*(p2[j]-p1[j]);\n\t\t}\n\t\t\t\n\t\tVectorCopy (mid, f->p[f->numpoints]);\n\t\tf->numpoints++;\n\t}\n\t\n\tif (f->numpoints > maxpts)\n\t\tError (\"ClipWinding: points exceeded estimate\");\n\tif (f->numpoints > MAX_POINTS_ON_WINDING)\n\t\tError (\"ClipWinding: MAX_POINTS_ON_WINDING\");\n\n\tFreeWinding (in);\n\t*inout = f;\n}\n\n\n/*\n=================\nChopWinding\n\nReturns the fragment of in that is on the front side\nof the cliping plane.  The original is freed.\n=================\n*/\nwinding_t\t*ChopWinding (winding_t *in, vec3_t normal, vec_t dist)\n{\n\twinding_t\t*f, *b;\n\n\tClipWindingEpsilon (in, normal, dist, ON_EPSILON, &f, &b);\n\tFreeWinding (in);\n\tif (b)\n\t\tFreeWinding (b);\n\treturn f;\n}\n\n\n/*\n=================\nCheckWinding\n\n=================\n*/\nvoid CheckWinding (winding_t *w)\n{\n\tint\t\ti, j;\n\tvec_t\t*p1, *p2;\n\tvec_t\td, edgedist;\n\tvec3_t\tdir, edgenormal, facenormal;\n\tvec_t\tarea;\n\tvec_t\tfacedist;\n\n\tif (w->numpoints < 3)\n\t\tError (\"CheckWinding: %i points\",w->numpoints);\n\t\n\tarea = WindingArea(w);\n\tif (area < 1)\n\t\tError (\"CheckWinding: %f area\", area);\n\n\tWindingPlane (w, facenormal, &facedist);\n\t\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tp1 = w->p[i];\n\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t\tif (p1[j] > MAX_WORLD_COORD || p1[j] < MIN_WORLD_COORD)\n\t\t\t\tError (\"CheckFace: BUGUS_RANGE: %f\",p1[j]);\n\n\t\tj = i+1 == w->numpoints ? 0 : i+1;\n\t\t\n\t// check the point is on the face plane\n\t\td = DotProduct (p1, facenormal) - facedist;\n\t\tif (d < -ON_EPSILON || d > ON_EPSILON)\n\t\t\tError (\"CheckWinding: point off plane\");\n\t\n\t// check the edge isnt degenerate\n\t\tp2 = w->p[j];\n\t\tVectorSubtract (p2, p1, dir);\n\t\t\n\t\tif (VectorLength (dir) < ON_EPSILON)\n\t\t\tError (\"CheckWinding: degenerate edge\");\n\t\t\t\n\t\tCrossProduct (facenormal, dir, edgenormal);\n\t\tVectorNormalize (edgenormal, edgenormal);\n\t\tedgedist = DotProduct (p1, edgenormal);\n\t\tedgedist += ON_EPSILON;\n\t\t\n\t// all other points must be on front side\n\t\tfor (j=0 ; j<w->numpoints ; j++)\n\t\t{\n\t\t\tif (j == i)\n\t\t\t\tcontinue;\n\t\t\td = DotProduct (w->p[j], edgenormal);\n\t\t\tif (d > edgedist)\n\t\t\t\tError (\"CheckWinding: non-convex\");\n\t\t}\n\t}\n}\n\n\n/*\n============\nWindingOnPlaneSide\n============\n*/\nint\t\tWindingOnPlaneSide (winding_t *w, vec3_t normal, vec_t dist)\n{\n\tqboolean\tfront, back;\n\tint\t\t\ti;\n\tvec_t\t\td;\n\n\tfront = qfalse;\n\tback = qfalse;\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\td = DotProduct (w->p[i], normal) - dist;\n\t\tif (d < -ON_EPSILON)\n\t\t{\n\t\t\tif (front)\n\t\t\t\treturn SIDE_CROSS;\n\t\t\tback = qtrue;\n\t\t\tcontinue;\n\t\t}\n\t\tif (d > ON_EPSILON)\n\t\t{\n\t\t\tif (back)\n\t\t\t\treturn SIDE_CROSS;\n\t\t\tfront = qtrue;\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\tif (back)\n\t\treturn SIDE_BACK;\n\tif (front)\n\t\treturn SIDE_FRONT;\n\treturn SIDE_ON;\n}\n\n\n/*\n=================\nAddWindingToConvexHull\n\nBoth w and *hull are on the same plane\n=================\n*/\n#define\tMAX_HULL_POINTS\t\t128\nvoid\tAddWindingToConvexHull( winding_t *w, winding_t **hull, vec3_t normal ) {\n\tint\t\t\ti, j, k;\n\tfloat\t\t*p, *copy;\n\tvec3_t\t\tdir;\n\tfloat\t\td;\n\tint\t\t\tnumHullPoints, numNew;\n\tvec3_t\t\thullPoints[MAX_HULL_POINTS];\n\tvec3_t\t\tnewHullPoints[MAX_HULL_POINTS];\n\tvec3_t\t\thullDirs[MAX_HULL_POINTS];\n\tqboolean\thullSide[MAX_HULL_POINTS];\n\tqboolean\toutside;\n\n\tif ( !*hull ) {\n\t\t*hull = CopyWinding( w );\n\t\treturn;\n\t}\n\n\tnumHullPoints = (*hull)->numpoints;\n\tmemcpy( hullPoints, (*hull)->p, numHullPoints * sizeof(vec3_t) );\n\n\tfor ( i = 0 ; i < w->numpoints ; i++ ) {\n\t\tp = w->p[i];\n\n\t\t// calculate hull side vectors\n\t\tfor ( j = 0 ; j < numHullPoints ; j++ ) {\n\t\t\tk = ( j + 1 ) % numHullPoints;\n\n\t\t\tVectorSubtract( hullPoints[k], hullPoints[j], dir );\n\t\t\tVectorNormalize( dir, dir );\n\t\t\tCrossProduct( normal, dir, hullDirs[j] );\n\t\t}\n\n\t\toutside = qfalse;\n\t\tfor ( j = 0 ; j < numHullPoints ; j++ ) {\n\t\t\tVectorSubtract( p, hullPoints[j], dir );\n\t\t\td = DotProduct( dir, hullDirs[j] );\n\t\t\tif ( d >= ON_EPSILON ) {\n\t\t\t\toutside = qtrue;\n\t\t\t}\n\t\t\tif ( d >= -ON_EPSILON ) {\n\t\t\t\thullSide[j] = qtrue;\n\t\t\t} else {\n\t\t\t\thullSide[j] = qfalse;\n\t\t\t}\n\t\t}\n\n\t\t// if the point is effectively inside, do nothing\n\t\tif ( !outside ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// find the back side to front side transition\n\t\tfor ( j = 0 ; j < numHullPoints ; j++ ) {\n\t\t\tif ( !hullSide[ j % numHullPoints ] && hullSide[ (j + 1) % numHullPoints ] ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif ( j == numHullPoints ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// insert the point here\n\t\tVectorCopy( p, newHullPoints[0] );\n\t\tnumNew = 1;\n\n\t\t// copy over all points that aren't double fronts\n\t\tj = (j+1)%numHullPoints;\n\t\tfor ( k = 0 ; k < numHullPoints ; k++ ) {\n\t\t\tif ( hullSide[ (j+k) % numHullPoints ] && hullSide[ (j+k+1) % numHullPoints ] ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tcopy = hullPoints[ (j+k+1) % numHullPoints ];\n\t\t\tVectorCopy( copy, newHullPoints[numNew] );\n\t\t\tnumNew++;\n\t\t}\n\n\t\tnumHullPoints = numNew;\n\t\tmemcpy( hullPoints, newHullPoints, numHullPoints * sizeof(vec3_t) );\n\t}\n\n\tFreeWinding( *hull );\n\tw = AllocWinding( numHullPoints );\n\tw->numpoints = numHullPoints;\n\t*hull = w;\n\tmemcpy( w->p, hullPoints, numHullPoints * sizeof(vec3_t) );\n}\n\n\n"
  },
  {
    "path": "common/polylib.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\ntypedef struct\n{\n\tint\t\tnumpoints;\n\tvec3_t\tp[4];\t\t// variable sized\n} winding_t;\n\n#define\tMAX_POINTS_ON_WINDING\t64\n\n// you can define on_epsilon in the makefile as tighter\n#ifndef\tON_EPSILON\n#define\tON_EPSILON\t0.1\n#endif\n\nwinding_t\t*AllocWinding (int points);\nvec_t\tWindingArea (winding_t *w);\nvoid\tWindingCenter (winding_t *w, vec3_t center);\nvoid\tClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist, \n\t\t\t\tvec_t epsilon, winding_t **front, winding_t **back);\nwinding_t\t*ChopWinding (winding_t *in, vec3_t normal, vec_t dist);\nwinding_t\t*CopyWinding (winding_t *w);\nwinding_t\t*ReverseWinding (winding_t *w);\nwinding_t\t*BaseWindingForPlane (vec3_t normal, vec_t dist);\nvoid\tCheckWinding (winding_t *w);\nvoid\tWindingPlane (winding_t *w, vec3_t normal, vec_t *dist);\nvoid\tRemoveColinearPoints (winding_t *w);\nint\t\tWindingOnPlaneSide (winding_t *w, vec3_t normal, vec_t dist);\nvoid\tFreeWinding (winding_t *w);\nvoid\tWindingBounds (winding_t *w, vec3_t mins, vec3_t maxs);\n\nvoid\tAddWindingToConvexHull( winding_t *w, winding_t **hull, vec3_t normal );\n\nvoid\tChopWindingInPlace (winding_t **w, vec3_t normal, vec_t dist, vec_t epsilon);\n// frees the original if clipped\n\nvoid pw(winding_t *w);\n"
  },
  {
    "path": "common/polyset.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __POLYSET_H__\n#define __POLYSET_H__\n\n#define POLYSET_MAXTRIANGLES\t4096\n#define POLYSET_MAXPOLYSETS\t\t64\n\ntypedef float st_t[2];\ntypedef float rgb_t[3];\n\ntypedef struct {\n\tvec3_t\tverts[3];\n\tvec3_t\tnormals[3];\n\tst_t\ttexcoords[3];\n} triangle_t;\n\ntypedef struct\n{\n\tchar name[100];\n\tchar materialname[100];\n\ttriangle_t *triangles;\n\tint numtriangles;\n} polyset_t;\n\npolyset_t *Polyset_LoadSets( const char *file, int *numpolysets, int maxTrisPerSet );\npolyset_t *Polyset_CollapseSets( polyset_t *psets, int numpolysets );\npolyset_t *Polyset_SplitSets( polyset_t *psets, int numpolysets, int *pNumNewPolysets, int maxTris );\nvoid Polyset_SnapSets( polyset_t *psets, int numpolysets );\nvoid Polyset_ComputeNormals( polyset_t *psets, int numpolysets );\n\n#endif\n"
  },
  {
    "path": "common/qfiles.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __QFILES_H__\n#define __QFILES_H__\n\n//\n// qfiles.h: quake file formats\n// This file must be identical in the quake and utils directories\n//\n\n// surface geometry should not exceed these limits\n#define\tSHADER_MAX_VERTEXES\t1000\n#define\tSHADER_MAX_INDEXES\t(6*SHADER_MAX_VERTEXES)\n\n\n// the maximum size of game reletive pathnames\n#define\tMAX_QPATH\t\t64\n\n\n/*\n========================================================================\n\nQVM files\n\n========================================================================\n*/\n\n#define\tVM_MAGIC\t0x12721444\ntypedef struct {\n\tint\t\tvmMagic;\n\n\tint\t\tinstructionCount;\n\n\tint\t\tcodeOffset;\n\tint\t\tcodeLength;\n\n\tint\t\tdataOffset;\n\tint\t\tdataLength;\n\tint\t\tlitLength;\t\t\t// ( dataLength - litLength ) should be byteswapped on load\n\tint\t\tbssLength;\t\t\t// zero filled memory appended to datalength\n} vmHeader_t;\n\n/*\n========================================================================\n\nPCX files are used for 8 bit images\n\n========================================================================\n*/\n\ntypedef struct {\n    char\tmanufacturer;\n    char\tversion;\n    char\tencoding;\n    char\tbits_per_pixel;\n    unsigned short\txmin,ymin,xmax,ymax;\n    unsigned short\thres,vres;\n    unsigned char\tpalette[48];\n    char\treserved;\n    char\tcolor_planes;\n    unsigned short\tbytes_per_line;\n    unsigned short\tpalette_type;\n    char\tfiller[58];\n    unsigned char\tdata;\t\t\t// unbounded\n} pcx_t;\n\n\n/*\n========================================================================\n\nTGA files are used for 24/32 bit images\n\n========================================================================\n*/\n\ntypedef struct _TargaHeader {\n\tunsigned char \tid_length, colormap_type, image_type;\n\tunsigned short\tcolormap_index, colormap_length;\n\tunsigned char\tcolormap_size;\n\tunsigned short\tx_origin, y_origin, width, height;\n\tunsigned char\tpixel_size, attributes;\n} TargaHeader;\n\n\n\n/*\n========================================================================\n\n.MD3 triangle model file format\n\n========================================================================\n*/\n\n#define MD3_IDENT\t\t\t(('3'<<24)+('P'<<16)+('D'<<8)+'I')\n#define MD3_VERSION\t\t\t15\n\n// limits\n#define MD3_MAX_LODS\t\t4\n#define\tMD3_MAX_TRIANGLES\t8192\t// per surface\n#define MD3_MAX_VERTS\t\t4096\t// per surface\n#define MD3_MAX_SHADERS\t\t256\t\t// per surface\n#define MD3_MAX_FRAMES\t\t1024\t// per model\n#define\tMD3_MAX_SURFACES\t32\t\t// per model\n#define MD3_MAX_TAGS\t\t16\t\t// per frame\n\n// vertex scales\n#define\tMD3_XYZ_SCALE\t\t(1.0/64)\n\ntypedef struct md3Frame_s {\n\tvec3_t\t\tbounds[2];\n\tvec3_t\t\tlocalOrigin;\n\tfloat\t\tradius;\n\tchar\t\tname[16];\n} md3Frame_t;\n\ntypedef struct md3Tag_s {\n\tchar\t\tname[MAX_QPATH];\t// tag name\n\tvec3_t\t\torigin;\n\tvec3_t\t\taxis[3];\n} md3Tag_t;\n\n/*\n** md3Surface_t\n**\n** CHUNK\t\t\tSIZE\n** header\t\t\tsizeof( md3Surface_t )\n** shaders\t\t\tsizeof( md3Shader_t ) * numShaders\n** triangles[0]\t\tsizeof( md3Triangle_t ) * numTriangles\n** st\t\t\t\tsizeof( md3St_t ) * numVerts\n** XyzNormals\t\tsizeof( md3XyzNormal_t ) * numVerts * numFrames\n*/\ntypedef struct {\n\tint\t\tident;\t\t\t\t// \n\n\tchar\tname[MAX_QPATH];\t// polyset name\n\n\tint\t\tflags;\n\tint\t\tnumFrames;\t\t\t// all surfaces in a model should have the same\n\n\tint\t\tnumShaders;\t\t\t// all surfaces in a model should have the same\n\tint\t\tnumVerts;\n\n\tint\t\tnumTriangles;\n\tint\t\tofsTriangles;\n\n\tint\t\tofsShaders;\t\t\t// offset from start of md3Surface_t\n\tint\t\tofsSt;\t\t\t\t// texture coords are common for all frames\n\tint\t\tofsXyzNormals;\t\t// numVerts * numFrames\n\n\tint\t\tofsEnd;\t\t\t\t// next surface follows\n} md3Surface_t;\n\ntypedef struct {\n\tchar\t\t\tname[MAX_QPATH];\n\tint\t\t\t\tshaderIndex;\t// for in-game use\n} md3Shader_t;\n\ntypedef struct {\n\tint\t\t\tindexes[3];\n} md3Triangle_t;\n\ntypedef struct {\n\tfloat\t\tst[2];\n} md3St_t;\n\ntypedef struct {\n\tshort\t\txyz[3];\n\tshort\t\tnormal;\n} md3XyzNormal_t;\n\ntypedef struct {\n\tint\t\t\tident;\n\tint\t\t\tversion;\n\n\tchar\t\tname[MAX_QPATH];\t// model name\n\n\tint\t\t\tflags;\n\n\tint\t\t\tnumFrames;\n\tint\t\t\tnumTags;\t\t\t\n\tint\t\t\tnumSurfaces;\n\n\tint\t\t\tnumSkins;\n\n\tint\t\t\tofsFrames;\t\t\t// offset for first frame\n\tint\t\t\tofsTags;\t\t\t// numFrames * numTags\n\tint\t\t\tofsSurfaces;\t\t// first surface, others follow\n\n\tint\t\t\tofsEnd;\t\t\t\t// end of file\n} md3Header_t;\n\n\n/*\n==============================================================================\n\nMD4 file format\n\n==============================================================================\n*/\n\n#define MD4_IDENT\t\t\t(('4'<<24)+('P'<<16)+('D'<<8)+'I')\n#define MD4_VERSION\t\t\t1\n#define\tMD4_MAX_BONES\t\t128\n\ntypedef struct {\n\tint\t\t\tboneIndex;\t\t// these are indexes into the boneReferences,\n\tfloat\t\tboneWeight;\t\t// not the global per-frame bone list\n} md4Weight_t;\n\ntypedef struct {\n\tvec3_t\t\tvertex;\n\tvec3_t\t\tnormal;\n\tfloat\t\ttexCoords[2];\n\tint\t\t\tnumWeights;\n\tmd4Weight_t\tweights[1];\t\t// variable sized\n} md4Vertex_t;\n\ntypedef struct {\n\tint\t\t\tindexes[3];\n} md4Triangle_t;\n\ntypedef struct {\n\tint\t\t\tident;\n\n\tchar\t\tname[MAX_QPATH];\t// polyset name\n\tchar\t\tshader[MAX_QPATH];\n\tint\t\t\tshaderIndex;\t\t// for in-game use\n\n\tint\t\t\tofsHeader;\t\t\t// this will be a negative number\n\n\tint\t\t\tnumVerts;\n\tint\t\t\tofsVerts;\n\n\tint\t\t\tnumTriangles;\n\tint\t\t\tofsTriangles;\n\n\t// Bone references are a set of ints representing all the bones\n\t// present in any vertex weights for this surface.  This is\n\t// needed because a model may have surfaces that need to be\n\t// drawn at different sort times, and we don't want to have\n\t// to re-interpolate all the bones for each surface.\n\tint\t\t\tnumBoneReferences;\n\tint\t\t\tofsBoneReferences;\n\n\tint\t\t\tofsEnd;\t\t\t\t// next surface follows\n} md4Surface_t;\n\ntypedef struct {\n\tfloat\t\tmatrix[3][4];\n} md4Bone_t;\n\ntypedef struct {\n\tvec3_t\t\tbounds[2];\t\t\t// bounds of all surfaces of all LOD's for this frame\n\tvec3_t\t\tlocalOrigin;\t\t// midpoint of bounds, used for sphere cull\n\tfloat\t\tradius;\t\t\t\t// dist from localOrigin to corner\n\tchar\t\tname[16];\n\tmd4Bone_t\tbones[1];\t\t\t// [numBones]\n} md4Frame_t;\n\ntypedef struct {\n\tint\t\t\tnumSurfaces;\n\tint\t\t\tofsSurfaces;\t\t// first surface, others follow\n\tint\t\t\tofsEnd;\t\t\t\t// next lod follows\n} md4LOD_t;\n\ntypedef struct {\n\tint\t\t\tident;\n\tint\t\t\tversion;\n\n\tchar\t\tname[MAX_QPATH];\t// model name\n\n\t// frames and bones are shared by all levels of detail\n\tint\t\t\tnumFrames;\n\tint\t\t\tnumBones;\n\tint\t\t\tofsFrames;\t\t\t// md4Frame_t[numFrames]\n\n\t// each level of detail has completely separate sets of surfaces\n\tint\t\t\tnumLODs;\n\tint\t\t\tofsLODs;\n\n\tint\t\t\tofsEnd;\t\t\t\t// end of file\n} md4Header_t;\n\n\n/*\n==============================================================================\n\n  .BSP file format\n\n==============================================================================\n*/\n\n\n#define BSP_IDENT\t(('P'<<24)+('S'<<16)+('B'<<8)+'I')\n\t\t// little-endian \"IBSP\"\n\n#define BSP_VERSION\t\t\t46\n\n\n// there shouldn't be any problem with increasing these values at the\n// expense of more memory allocation in the utilities\n#define\tMAX_MAP_MODELS\t\t0x400\n#define\tMAX_MAP_BRUSHES\t\t0x8000\n#define\tMAX_MAP_ENTITIES\t0x800\n#define\tMAX_MAP_ENTSTRING\t0x40000\n#define\tMAX_MAP_SHADERS\t\t0x400\n\n#define\tMAX_MAP_AREAS\t\t0x100\t// MAX_MAP_AREA_BYTES in q_shared must match!\n#define\tMAX_MAP_FOGS\t\t0x100\n#define\tMAX_MAP_PLANES\t\t0x20000\n#define\tMAX_MAP_NODES\t\t0x20000\n#define\tMAX_MAP_BRUSHSIDES\t0x20000\n#define\tMAX_MAP_LEAFS\t\t0x20000\n#define\tMAX_MAP_LEAFFACES\t0x20000\n#define\tMAX_MAP_LEAFBRUSHES 0x40000\n#define\tMAX_MAP_PORTALS\t\t0x20000\n#define\tMAX_MAP_LIGHTING\t0x800000\n#define\tMAX_MAP_LIGHTGRID\t0x800000\n#define\tMAX_MAP_VISIBILITY\t0x200000\n\n#define\tMAX_MAP_DRAW_SURFS\t0x20000\n#define\tMAX_MAP_DRAW_VERTS\t0x80000\n#define\tMAX_MAP_DRAW_INDEXES\t0x80000\n\n\n// key / value pair sizes in the entities lump\n#define\tMAX_KEY\t\t\t\t32\n#define\tMAX_VALUE\t\t\t1024\n\n// the editor uses these predefined yaw angles to orient entities up or down\n#define\tANGLE_UP\t\t\t-1\n#define\tANGLE_DOWN\t\t\t-2\n\n#define\tLIGHTMAP_WIDTH\t\t128\n#define\tLIGHTMAP_HEIGHT\t\t128\n\n#define MAX_WORLD_COORD\t\t( 128*1024 )\n#define MIN_WORLD_COORD\t\t( -128*1024 )\n#define WORLD_SIZE\t\t\t( MAX_WORLD_COORD - MIN_WORLD_COORD )\n\n//=============================================================================\n\n\ntypedef struct {\n\tint\t\tfileofs, filelen;\n} lump_t;\n\n#define\tLUMP_ENTITIES\t\t0\n#define\tLUMP_SHADERS\t\t1\n#define\tLUMP_PLANES\t\t\t2\n#define\tLUMP_NODES\t\t\t3\n#define\tLUMP_LEAFS\t\t\t4\n#define\tLUMP_LEAFSURFACES\t5\n#define\tLUMP_LEAFBRUSHES\t6\n#define\tLUMP_MODELS\t\t\t7\n#define\tLUMP_BRUSHES\t\t8\n#define\tLUMP_BRUSHSIDES\t\t9\n#define\tLUMP_DRAWVERTS\t\t10\n#define\tLUMP_DRAWINDEXES\t11\n#define\tLUMP_FOGS\t\t\t12\n#define\tLUMP_SURFACES\t\t13\n#define\tLUMP_LIGHTMAPS\t\t14\n#define\tLUMP_LIGHTGRID\t\t15\n#define\tLUMP_VISIBILITY\t\t16\n#define\tHEADER_LUMPS\t\t17\n\ntypedef struct {\n\tint\t\t\tident;\n\tint\t\t\tversion;\n\n\tlump_t\t\tlumps[HEADER_LUMPS];\n} dheader_t;\n\ntypedef struct {\n\tfloat\t\tmins[3], maxs[3];\n\tint\t\t\tfirstSurface, numSurfaces;\n\tint\t\t\tfirstBrush, numBrushes;\n} dmodel_t;\n\ntypedef struct {\n\tchar\t\tshader[MAX_QPATH];\n\tint\t\t\tsurfaceFlags;\n\tint\t\t\tcontentFlags;\n} dshader_t;\n\n// planes x^1 is allways the opposite of plane x\n\ntypedef struct {\n\tfloat\t\tnormal[3];\n\tfloat\t\tdist;\n} dplane_t;\n\ntypedef struct {\n\tint\t\t\tplaneNum;\n\tint\t\t\tchildren[2];\t// negative numbers are -(leafs+1), not nodes\n\tint\t\t\tmins[3];\t\t// for frustom culling\n\tint\t\t\tmaxs[3];\n} dnode_t;\n\ntypedef struct {\n\tint\t\t\tcluster;\t\t\t// -1 = opaque cluster (do I still store these?)\n\tint\t\t\tarea;\n\n\tint\t\t\tmins[3];\t\t\t// for frustum culling\n\tint\t\t\tmaxs[3];\n\n\tint\t\t\tfirstLeafSurface;\n\tint\t\t\tnumLeafSurfaces;\n\n\tint\t\t\tfirstLeafBrush;\n\tint\t\t\tnumLeafBrushes;\n} dleaf_t;\n\ntypedef struct {\n\tint\t\t\tplaneNum;\t\t\t// positive plane side faces out of the leaf\n\tint\t\t\tshaderNum;\n} dbrushside_t;\n\ntypedef struct {\n\tint\t\t\tfirstSide;\n\tint\t\t\tnumSides;\n\tint\t\t\tshaderNum;\t\t// the shader that determines the contents flags\n} dbrush_t;\n\ntypedef struct {\n\tchar\t\tshader[MAX_QPATH];\n\tint\t\t\tbrushNum;\n\tint\t\t\tvisibleSide;\t// the brush side that ray tests need to clip against (-1 == none)\n} dfog_t;\n\ntypedef struct {\n\tvec3_t\t\txyz;\n\tfloat\t\tst[2];\n\tfloat\t\tlightmap[2];\n\tvec3_t\t\tnormal;\n\tbyte\t\tcolor[4];\n} drawVert_t;\n\ntypedef enum {\n\tMST_BAD,\n\tMST_PLANAR,\n\tMST_PATCH,\n\tMST_TRIANGLE_SOUP,\n\tMST_FLARE\n} mapSurfaceType_t;\n\ntypedef struct {\n\tint\t\t\tshaderNum;\n\tint\t\t\tfogNum;\n\tint\t\t\tsurfaceType;\n\n\tint\t\t\tfirstVert;\n\tint\t\t\tnumVerts;\n\n\tint\t\t\tfirstIndex;\n\tint\t\t\tnumIndexes;\n\n\tint\t\t\tlightmapNum;\n\tint\t\t\tlightmapX, lightmapY;\n\tint\t\t\tlightmapWidth, lightmapHeight;\n\n\tvec3_t\t\tlightmapOrigin;\n\tvec3_t\t\tlightmapVecs[3];\t// for patches, [0] and [1] are lodbounds\n\n\tint\t\t\tpatchWidth;\n\tint\t\t\tpatchHeight;\n} dsurface_t;\n\n\n#endif\n"
  },
  {
    "path": "common/scriplib.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// scriplib.c\n\n#include \"cmdlib.h\"\n#include \"scriplib.h\"\n\n/*\n=============================================================================\n\n\t\t\t\t\t\tPARSING STUFF\n\n=============================================================================\n*/\n\ntypedef struct\n{\n\tchar\tfilename[1024];\n\tchar    *buffer,*script_p,*end_p;\n\tint     line;\n} script_t;\n\n#define\tMAX_INCLUDES\t8\nscript_t\tscriptstack[MAX_INCLUDES];\nscript_t\t*script;\nint\t\t\tscriptline;\n\nchar    token[MAXTOKEN];\nqboolean endofscript;\nqboolean tokenready;                     // only qtrue if UnGetToken was just called\n\n/*\n==============\nAddScriptToStack\n==============\n*/\nvoid AddScriptToStack( const char *filename ) {\n\tint            size;\n\n\tscript++;\n\tif (script == &scriptstack[MAX_INCLUDES])\n\t\tError (\"script file exceeded MAX_INCLUDES\");\n\tstrcpy (script->filename, ExpandPath (filename) );\n\n\tsize = LoadFile (script->filename, (void **)&script->buffer);\n\n\tprintf (\"entering %s\\n\", script->filename);\n\n\tscript->line = 1;\n\n\tscript->script_p = script->buffer;\n\tscript->end_p = script->buffer + size;\n}\n\n\n/*\n==============\nLoadScriptFile\n==============\n*/\nvoid LoadScriptFile( const char *filename ) {\n\tscript = scriptstack;\n\tAddScriptToStack (filename);\n\n\tendofscript = qfalse;\n\ttokenready = qfalse;\n}\n\n\n/*\n==============\nParseFromMemory\n==============\n*/\nvoid ParseFromMemory (char *buffer, int size)\n{\n\tscript = scriptstack;\n\tscript++;\n\tif (script == &scriptstack[MAX_INCLUDES])\n\t\tError (\"script file exceeded MAX_INCLUDES\");\n\tstrcpy (script->filename, \"memory buffer\" );\n\n\tscript->buffer = buffer;\n\tscript->line = 1;\n\tscript->script_p = script->buffer;\n\tscript->end_p = script->buffer + size;\n\n\tendofscript = qfalse;\n\ttokenready = qfalse;\n}\n\n\n/*\n==============\nUnGetToken\n\nSignals that the current token was not used, and should be reported\nfor the next GetToken.  Note that\n\nGetToken (qtrue);\nUnGetToken ();\nGetToken (qfalse);\n\ncould cross a line boundary.\n==============\n*/\nvoid UnGetToken (void)\n{\n\ttokenready = qtrue;\n}\n\n\nqboolean EndOfScript (qboolean crossline)\n{\n\tif (!crossline)\n\t\tError (\"Line %i is incomplete\\n\",scriptline);\n\n\tif (!strcmp (script->filename, \"memory buffer\"))\n\t{\n\t\tendofscript = qtrue;\n\t\treturn qfalse;\n\t}\n\n\tfree (script->buffer);\n\tif (script == scriptstack+1)\n\t{\n\t\tendofscript = qtrue;\n\t\treturn qfalse;\n\t}\n\tscript--;\n\tscriptline = script->line;\n\tprintf (\"returning to %s\\n\", script->filename);\n\treturn GetToken (crossline);\n}\n\n/*\n==============\nGetToken\n==============\n*/\nqboolean GetToken (qboolean crossline)\n{\n\tchar    *token_p;\n\n\tif (tokenready)                         // is a token allready waiting?\n\t{\n\t\ttokenready = qfalse;\n\t\treturn qtrue;\n\t}\n\n\tif (script->script_p >= script->end_p)\n\t\treturn EndOfScript (crossline);\n\n//\n// skip space\n//\nskipspace:\n\twhile (*script->script_p <= 32)\n\t{\n\t\tif (script->script_p >= script->end_p)\n\t\t\treturn EndOfScript (crossline);\n\t\tif (*script->script_p++ == '\\n')\n\t\t{\n\t\t\tif (!crossline)\n\t\t\t\tError (\"Line %i is incomplete\\n\",scriptline);\n\t\t\tscriptline = script->line++;\n\t\t}\n\t}\n\n\tif (script->script_p >= script->end_p)\n\t\treturn EndOfScript (crossline);\n\n\t// ; # // comments\n\tif (*script->script_p == ';' || *script->script_p == '#'\n\t\t|| ( script->script_p[0] == '/' && script->script_p[1] == '/') )\n\t{\n\t\tif (!crossline)\n\t\t\tError (\"Line %i is incomplete\\n\",scriptline);\n\t\twhile (*script->script_p++ != '\\n')\n\t\t\tif (script->script_p >= script->end_p)\n\t\t\t\treturn EndOfScript (crossline);\n\t\tscriptline = script->line++;\n\t\tgoto skipspace;\n\t}\n\n\t// /* */ comments\n\tif (script->script_p[0] == '/' && script->script_p[1] == '*')\n\t{\n\t\tif (!crossline)\n\t\t\tError (\"Line %i is incomplete\\n\",scriptline);\n\t\tscript->script_p+=2;\n\t\twhile (script->script_p[0] != '*' && script->script_p[1] != '/')\n\t\t{\n\t\t\tif ( *script->script_p == '\\n' ) {\n\t\t\t\tscriptline = script->line++;\n\t\t\t}\n\t\t\tscript->script_p++;\n\t\t\tif (script->script_p >= script->end_p)\n\t\t\t\treturn EndOfScript (crossline);\n\t\t}\n\t\tscript->script_p += 2;\n\t\tgoto skipspace;\n\t}\n\n//\n// copy token\n//\n\ttoken_p = token;\n\n\tif (*script->script_p == '\"')\n\t{\n\t\t// quoted token\n\t\tscript->script_p++;\n\t\twhile (*script->script_p != '\"')\n\t\t{\n\t\t\t*token_p++ = *script->script_p++;\n\t\t\tif (script->script_p == script->end_p)\n\t\t\t\tbreak;\n\t\t\tif (token_p == &token[MAXTOKEN])\n\t\t\t\tError (\"Token too large on line %i\\n\",scriptline);\n\t\t}\n\t\tscript->script_p++;\n\t}\n\telse\t// regular token\n\twhile ( *script->script_p > 32 && *script->script_p != ';')\n\t{\n\t\t*token_p++ = *script->script_p++;\n\t\tif (script->script_p == script->end_p)\n\t\t\tbreak;\n\t\tif (token_p == &token[MAXTOKEN])\n\t\t\tError (\"Token too large on line %i\\n\",scriptline);\n\t}\n\n\t*token_p = 0;\n\n\tif (!strcmp (token, \"$include\"))\n\t{\n\t\tGetToken (qfalse);\n\t\tAddScriptToStack (token);\n\t\treturn GetToken (crossline);\n\t}\n\n\treturn qtrue;\n}\n\n\n/*\n==============\nTokenAvailable\n\nReturns qtrue if there is another token on the line\n==============\n*/\nqboolean TokenAvailable (void) {\n\tint\t\toldLine;\n\tqboolean\tr;\n\n\toldLine = script->line;\n\tr = GetToken( qtrue );\n\tif ( !r ) {\n\t\treturn qfalse;\n\t}\n\tUnGetToken();\n\tif ( oldLine == script->line ) {\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n\n//=====================================================================\n\n\nvoid MatchToken( char *match ) {\n\tGetToken( qtrue );\n\n\tif ( strcmp( token, match ) ) {\n\t\tError( \"MatchToken( \\\"%s\\\" ) failed at line %i\", match, scriptline );\n\t}\n}\n\n\nvoid Parse1DMatrix (int x, vec_t *m) {\n\tint\t\ti;\n\n\tMatchToken( \"(\" );\n\n\tfor (i = 0 ; i < x ; i++) {\n\t\tGetToken( qfalse );\n\t\tm[i] = atof(token);\n\t}\n\n\tMatchToken( \")\" );\n}\n\nvoid Parse2DMatrix (int y, int x, vec_t *m) {\n\tint\t\ti;\n\n\tMatchToken( \"(\" );\n\n\tfor (i = 0 ; i < y ; i++) {\n\t\tParse1DMatrix (x, m + i * x);\n\t}\n\n\tMatchToken( \")\" );\n}\n\nvoid Parse3DMatrix (int z, int y, int x, vec_t *m) {\n\tint\t\ti;\n\n\tMatchToken( \"(\" );\n\n\tfor (i = 0 ; i < z ; i++) {\n\t\tParse2DMatrix (y, x, m + i * x*y);\n\t}\n\n\tMatchToken( \")\" );\n}\n\n\nvoid Write1DMatrix (FILE *f, int x, vec_t *m) {\n\tint\t\ti;\n\n\tfprintf (f, \"( \");\n\tfor (i = 0 ; i < x ; i++) {\n\t\tif (m[i] == (int)m[i] ) {\n\t\t\tfprintf (f, \"%i \", (int)m[i]);\n\t\t} else {\n\t\t\tfprintf (f, \"%f \", m[i]);\n\t\t}\n\t}\n\tfprintf (f, \")\");\n}\n\nvoid Write2DMatrix (FILE *f, int y, int x, vec_t *m) {\n\tint\t\ti;\n\n\tfprintf (f, \"( \");\n\tfor (i = 0 ; i < y ; i++) {\n\t\tWrite1DMatrix (f, x, m + i*x);\n\t\tfprintf (f, \" \");\n\t}\n\tfprintf (f, \")\\n\");\n}\n\n\nvoid Write3DMatrix (FILE *f, int z, int y, int x, vec_t *m) {\n\tint\t\ti;\n\n\tfprintf (f, \"(\\n\");\n\tfor (i = 0 ; i < z ; i++) {\n\t\tWrite2DMatrix (f, y, x, m + i*(x*y) );\n\t}\n\tfprintf (f, \")\\n\");\n}\n\n"
  },
  {
    "path": "common/scriplib.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// scriplib.h\n\n#ifndef __CMDLIB__\n#include \"cmdlib.h\"\n#endif\n#ifndef __MATHLIB__\n#include \"mathlib.h\"\n#endif\n\n#define\tMAXTOKEN\t1024\n\nextern\tchar\ttoken[MAXTOKEN];\nextern\tchar\t*scriptbuffer,*script_p,*scriptend_p;\nextern\tint\t\tgrabbed;\nextern\tint\t\tscriptline;\nextern\tqboolean\tendofscript;\n\n\nvoid LoadScriptFile( const char *filename );\nvoid ParseFromMemory (char *buffer, int size);\n\nqboolean GetToken (qboolean crossline);\nvoid UnGetToken (void);\nqboolean TokenAvailable (void);\n\nvoid MatchToken( char *match );\n\nvoid Parse1DMatrix (int x, vec_t *m);\nvoid Parse2DMatrix (int y, int x, vec_t *m);\nvoid Parse3DMatrix (int z, int y, int x, vec_t *m);\n\nvoid Write1DMatrix (FILE *f, int x, vec_t *m);\nvoid Write2DMatrix (FILE *f, int y, int x, vec_t *m);\nvoid Write3DMatrix (FILE *f, int z, int y, int x, vec_t *m);\n"
  },
  {
    "path": "common/surfaceflags.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// This file must be identical in the quake and utils directories\n\n// contents flags are seperate bits\n// a given brush can contribute multiple content bits\n\n// these definitions also need to be in q_shared.h!\n\n#define\tCONTENTS_SOLID\t\t\t1\t\t// an eye is never valid in a solid\n#define\tCONTENTS_LAVA\t\t\t8\n#define\tCONTENTS_SLIME\t\t\t16\n#define\tCONTENTS_WATER\t\t\t32\n#define\tCONTENTS_FOG\t\t\t64\n\n#define\tCONTENTS_AREAPORTAL\t\t0x8000\n\n#define\tCONTENTS_PLAYERCLIP\t\t0x10000\n#define\tCONTENTS_MONSTERCLIP\t0x20000\n//bot specific contents types\n#define\tCONTENTS_TELEPORTER\t\t0x40000\n#define\tCONTENTS_JUMPPAD\t\t0x80000\n#define CONTENTS_CLUSTERPORTAL\t0x100000\n#define CONTENTS_DONOTENTER\t\t0x200000\n\n#define\tCONTENTS_ORIGIN\t\t\t0x1000000\t// removed before bsping an entity\n\n#define\tCONTENTS_BODY\t\t\t0x2000000\t// should never be on a brush, only in game\n#define\tCONTENTS_CORPSE\t\t\t0x4000000\n#define\tCONTENTS_DETAIL\t\t\t0x8000000\t// brushes not used for the bsp\n#define\tCONTENTS_STRUCTURAL\t\t0x10000000\t// brushes used for the bsp\n#define\tCONTENTS_TRANSLUCENT\t0x20000000\t// don't consume surface fragments inside\n#define\tCONTENTS_TRIGGER\t\t0x40000000\n#define\tCONTENTS_NODROP\t\t\t0x80000000\t// don't leave bodies or items (death fog, lava)\n\n#define\tSURF_NODAMAGE\t\t\t0x1\t\t// never give falling damage\n#define\tSURF_SLICK\t\t\t\t0x2\t\t// effects game physics\n#define\tSURF_SKY\t\t\t\t0x4\t\t// lighting from environment map\n#define\tSURF_LADDER\t\t\t\t0x8\n#define\tSURF_NOIMPACT\t\t\t0x10\t// don't make missile explosions\n#define\tSURF_NOMARKS\t\t\t0x20\t// don't leave missile marks\n#define\tSURF_FLESH\t\t\t\t0x40\t// make flesh sounds and effects\n#define\tSURF_NODRAW\t\t\t\t0x80\t// don't generate a drawsurface at all\n#define\tSURF_HINT\t\t\t\t0x100\t// make a primary bsp splitter\n#define\tSURF_SKIP\t\t\t\t0x200\t// completely ignore, allowing non-closed brushes\n#define\tSURF_NOLIGHTMAP\t\t\t0x400\t// surface doesn't need a lightmap\n#define\tSURF_POINTLIGHT\t\t\t0x800\t// generate lighting info at vertexes\n#define\tSURF_METALSTEPS\t\t\t0x1000\t// clanking footsteps\n#define\tSURF_NOSTEPS\t\t\t0x2000\t// no footstep sounds\n#define\tSURF_NONSOLID\t\t\t0x4000\t// don't collide against curves with this set\n#define SURF_LIGHTFILTER\t\t0x8000\t// act as a light filter during q3map -light\n#define\tSURF_ALPHASHADOW\t\t0x10000\t// do per-pixel light shadow casting in q3map\n#define\tSURF_NODLIGHT\t\t\t0x20000\t// never add dynamic lights\n"
  },
  {
    "path": "common/threads.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"cmdlib.h\"\n#include \"threads.h\"\n\n#define\tMAX_THREADS\t64\n\nint\t\tdispatch;\nint\t\tworkcount;\nint\t\toldf;\nqboolean\t\tpacifier;\n\nqboolean\tthreaded;\n\n/*\n=============\nGetThreadWork\n\n=============\n*/\nint\tGetThreadWork (void)\n{\n\tint\tr;\n\tint\tf;\n\n\tThreadLock ();\n\n\tif (dispatch == workcount)\n\t{\n\t\tThreadUnlock ();\n\t\treturn -1;\n\t}\n\n\tf = 10*dispatch / workcount;\n\tif (f != oldf)\n\t{\n\t\toldf = f;\n\t\tif (pacifier)\n\t\t\t_printf (\"%i...\", f);\n\t}\n\n\tr = dispatch;\n\tdispatch++;\n\tThreadUnlock ();\n\n\treturn r;\n}\n\n\nvoid (*workfunction) (int);\n\nvoid ThreadWorkerFunction (int threadnum)\n{\n\tint\t\twork;\n\n\twhile (1)\n\t{\n\t\twork = GetThreadWork ();\n\t\tif (work == -1)\n\t\t\tbreak;\n//_printf (\"thread %i, work %i\\n\", threadnum, work);\n\t\tworkfunction(work);\n\t}\n}\n\nvoid RunThreadsOnIndividual (int workcnt, qboolean showpacifier, void(*func)(int))\n{\n\tif (numthreads == -1)\n\t\tThreadSetDefault ();\n\tworkfunction = func;\n\tRunThreadsOn (workcnt, showpacifier, ThreadWorkerFunction);\n}\n\n\n/*\n===================================================================\n\nWIN32\n\n===================================================================\n*/\n#ifdef WIN32\n\n#define\tUSED\n\n#include <windows.h>\n\nint\t\tnumthreads = -1;\nCRITICAL_SECTION\t\tcrit;\nstatic int enter;\n\nvoid ThreadSetDefault (void)\n{\n\tSYSTEM_INFO info;\n\n\tif (numthreads == -1)\t// not set manually\n\t{\n\t\tGetSystemInfo (&info);\n\t\tnumthreads = info.dwNumberOfProcessors;\n\t\tif (numthreads < 1 || numthreads > 32)\n\t\t\tnumthreads = 1;\n\t}\n\n\tqprintf (\"%i threads\\n\", numthreads);\n}\n\n\nvoid ThreadLock (void)\n{\n\tif (!threaded)\n\t\treturn;\n\tEnterCriticalSection (&crit);\n\tif (enter)\n\t\tError (\"Recursive ThreadLock\\n\");\n\tenter = 1;\n}\n\nvoid ThreadUnlock (void)\n{\n\tif (!threaded)\n\t\treturn;\n\tif (!enter)\n\t\tError (\"ThreadUnlock without lock\\n\");\n\tenter = 0;\n\tLeaveCriticalSection (&crit);\n}\n\n/*\n=============\nRunThreadsOn\n=============\n*/\nvoid RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int))\n{\n\tint\t\tthreadid[MAX_THREADS];\n\tHANDLE\tthreadhandle[MAX_THREADS];\n\tint\t\ti;\n\tint\t\tstart, end;\n\n\tstart = I_FloatTime ();\n\tdispatch = 0;\n\tworkcount = workcnt;\n\toldf = -1;\n\tpacifier = showpacifier;\n\tthreaded = qtrue;\n\n\t//\n\t// run threads in parallel\n\t//\n\tInitializeCriticalSection (&crit);\n\n\tif (numthreads == 1)\n\t{\t// use same thread\n\t\tfunc (0);\n\t}\n\telse\n\t{\n\t\tfor (i=0 ; i<numthreads ; i++)\n\t\t{\n\t\t\tthreadhandle[i] = CreateThread(\n\t\t\t   NULL,\t// LPSECURITY_ATTRIBUTES lpsa,\n\t\t\t   0,\t\t// DWORD cbStack,\n\t\t\t   (LPTHREAD_START_ROUTINE)func,\t// LPTHREAD_START_ROUTINE lpStartAddr,\n\t\t\t   (LPVOID)i,\t// LPVOID lpvThreadParm,\n\t\t\t   0,\t\t\t//   DWORD fdwCreate,\n\t\t\t   &threadid[i]);\n\t\t}\n\n\t\tfor (i=0 ; i<numthreads ; i++)\n\t\t\tWaitForSingleObject (threadhandle[i], INFINITE);\n\t}\n\tDeleteCriticalSection (&crit);\n\n\tthreaded = qfalse;\n\tend = I_FloatTime ();\n\tif (pacifier)\n\t\t_printf (\" (%i)\\n\", end-start);\n}\n\n\n#endif\n\n/*\n===================================================================\n\nOSF1\n\n===================================================================\n*/\n\n#ifdef __osf__\n#define\tUSED\n\nint\t\tnumthreads = 4;\n\nvoid ThreadSetDefault (void)\n{\n\tif (numthreads == -1)\t// not set manually\n\t{\n\t\tnumthreads = 4;\n\t}\n}\n\n\n#include <pthread.h>\n\npthread_mutex_t\t*my_mutex;\n\nvoid ThreadLock (void)\n{\n\tif (my_mutex)\n\t\tpthread_mutex_lock (my_mutex);\n}\n\nvoid ThreadUnlock (void)\n{\n\tif (my_mutex)\n\t\tpthread_mutex_unlock (my_mutex);\n}\n\n\n/*\n=============\nRunThreadsOn\n=============\n*/\nvoid RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int))\n{\n\tint\t\ti;\n\tpthread_t\twork_threads[MAX_THREADS];\n\tpthread_addr_t\tstatus;\n\tpthread_attr_t\tattrib;\n\tpthread_mutexattr_t\tmattrib;\n\tint\t\tstart, end;\n\n\tstart = I_FloatTime ();\n\tdispatch = 0;\n\tworkcount = workcnt;\n\toldf = -1;\n\tpacifier = showpacifier;\n\tthreaded = qtrue;\n\n\tif (pacifier)\n\t\tsetbuf (stdout, NULL);\n\n\tif (!my_mutex)\n\t{\n\t\tmy_mutex = malloc (sizeof(*my_mutex));\n\t\tif (pthread_mutexattr_create (&mattrib) == -1)\n\t\t\tError (\"pthread_mutex_attr_create failed\");\n\t\tif (pthread_mutexattr_setkind_np (&mattrib, MUTEX_FAST_NP) == -1)\n\t\t\tError (\"pthread_mutexattr_setkind_np failed\");\n\t\tif (pthread_mutex_init (my_mutex, mattrib) == -1)\n\t\t\tError (\"pthread_mutex_init failed\");\n\t}\n\n\tif (pthread_attr_create (&attrib) == -1)\n\t\tError (\"pthread_attr_create failed\");\n\tif (pthread_attr_setstacksize (&attrib, 0x100000) == -1)\n\t\tError (\"pthread_attr_setstacksize failed\");\n\t\n\tfor (i=0 ; i<numthreads ; i++)\n\t{\n  \t\tif (pthread_create(&work_threads[i], attrib\n\t\t, (pthread_startroutine_t)func, (pthread_addr_t)i) == -1)\n\t\t\tError (\"pthread_create failed\");\n\t}\n\t\t\n\tfor (i=0 ; i<numthreads ; i++)\n\t{\n\t\tif (pthread_join (work_threads[i], &status) == -1)\n\t\t\tError (\"pthread_join failed\");\n\t}\n\n\tthreaded = qfalse;\n\n\tend = I_FloatTime ();\n\tif (pacifier)\n\t\t_printf (\" (%i)\\n\", end-start);\n}\n\n\n#endif\n\n/*\n===================================================================\n\nIRIX\n\n===================================================================\n*/\n\n#ifdef _MIPS_ISA \n#define\tUSED\n\n#include <task.h>\n#include <abi_mutex.h>\n#include <sys/types.h>\n#include <sys/prctl.h>\n\n\nint\t\tnumthreads = -1;\nabilock_t\t\tlck;\n\nvoid ThreadSetDefault (void)\n{\n\tif (numthreads == -1)\n\t\tnumthreads = prctl(PR_MAXPPROCS);\n\t_printf (\"%i threads\\n\", numthreads);\n\tusconfig (CONF_INITUSERS, numthreads);\n}\n\n\nvoid ThreadLock (void)\n{\n\tspin_lock (&lck);\n}\n\nvoid ThreadUnlock (void)\n{\n\trelease_lock (&lck);\n}\n\n\n/*\n=============\nRunThreadsOn\n=============\n*/\nvoid RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int))\n{\n\tint\t\ti;\n\tint\t\tpid[MAX_THREADS];\n\tint\t\tstart, end;\n\n\tstart = I_FloatTime ();\n\tdispatch = 0;\n\tworkcount = workcnt;\n\toldf = -1;\n\tpacifier = showpacifier;\n\tthreaded = qtrue;\n\n\tif (pacifier)\n\t\tsetbuf (stdout, NULL);\n\n\tinit_lock (&lck);\n\n\tfor (i=0 ; i<numthreads-1 ; i++)\n\t{\n\t\tpid[i] = sprocsp ( (void (*)(void *, size_t))func, PR_SALL, (void *)i\n\t\t\t, NULL, 0x200000);\t\t// 2 meg stacks\n\t\tif (pid[i] == -1)\n\t\t{\n\t\t\tperror (\"sproc\");\n\t\t\tError (\"sproc failed\");\n\t\t}\n\t}\n\t\t\n\tfunc(i);\n\t\t\t\n\tfor (i=0 ; i<numthreads-1 ; i++)\n\t\twait (NULL);\n\n\tthreaded = qfalse;\n\n\tend = I_FloatTime ();\n\tif (pacifier)\n\t\t_printf (\" (%i)\\n\", end-start);\n}\n\n\n#endif\n\n/*\n=======================================================================\n\n  SINGLE THREAD\n\n=======================================================================\n*/\n\n#ifndef USED\n\nint\t\tnumthreads = 1;\n\nvoid ThreadSetDefault (void)\n{\n\tnumthreads = 1;\n}\n\nvoid ThreadLock (void)\n{\n}\n\nvoid ThreadUnlock (void)\n{\n}\n\n/*\n=============\nRunThreadsOn\n=============\n*/\nvoid RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int))\n{\n\tint\t\ti;\n\tint\t\tstart, end;\n\n\tdispatch = 0;\n\tworkcount = workcnt;\n\toldf = -1;\n\tpacifier = showpacifier;\n\tstart = I_FloatTime (); \n\tfunc(0);\n\n\tend = I_FloatTime ();\n\tif (pacifier)\n\t\t_printf (\" (%i)\\n\", end-start);\n}\n\n#endif\n"
  },
  {
    "path": "common/threads.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\nextern\tint\t\tnumthreads;\n\nvoid ThreadSetDefault (void);\nint\tGetThreadWork (void);\nvoid RunThreadsOnIndividual (int workcnt, qboolean showpacifier, void(*func)(int));\nvoid RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int));\nvoid ThreadLock (void);\nvoid ThreadUnlock (void);\n\n"
  },
  {
    "path": "common/trilib.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// trilib.c: library for loading triangles from an Alias triangle file\n//\n\n#include <stdio.h>\n#include \"cmdlib.h\"\n#include \"mathlib.h\"\n#include \"polyset.h\"\n#include \"trilib.h\"\n\n// on disk representation of a face\n\n\n#define\tFLOAT_START\t99999.0\n#define\tFLOAT_END\t-FLOAT_START\n#define MAGIC       123322\n\n//#define NOISY 1\n\ntypedef struct {\n\tfloat v[3];\n} vector;\n\ntypedef struct\n{\n\tvector n;    /* normal */\n\tvector p;    /* point */\n\tvector c;    /* color */\n\tfloat  u;    /* u */\n\tfloat  v;    /* v */\n} aliaspoint_t;\n\ntypedef struct {\n\taliaspoint_t\tpt[3];\n} tf_triangle;\n\n\nstatic void ByteSwapTri (tf_triangle *tri)\n{\n\tint\t\ti;\n\t\n\tfor (i=0 ; i<sizeof(tf_triangle)/4 ; i++)\n\t{\n\t\t((int *)tri)[i] = BigLong (((int *)tri)[i]);\n\t}\n}\n\nstatic void ReadPolysetGeometry( triangle_t *tripool, FILE *input, int count, triangle_t *ptri )\n{\n\ttf_triangle tri;\n\tint i;\n\n\tfor (i = 0; i < count; ++i) {\n\t\tint\t\tj;\n\n\t\tfread( &tri, sizeof(tf_triangle), 1, input );\n\t\tByteSwapTri (&tri);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\tint\t\tk;\n\n\t\t\tfor (k=0 ; k<3 ; k++)\n\t\t\t{\n\t\t\t\tptri->verts[j][k] = tri.pt[j].p.v[k];\n\t\t\t\tptri->normals[j][k] = tri.pt[j].n.v[k];\n//\t\t\t\tptri->colors[j][k] = tri.pt[j].c.v[k];\n\t\t\t}\n\n\t\t\tptri->texcoords[j][0] = tri.pt[j].u;\n\t\t\tptri->texcoords[j][1] = tri.pt[j].v;\n\t\t}\n\n\t\tptri++;\n\t\tif ((ptri - tripool ) >= POLYSET_MAXTRIANGLES)\n\t\t\tError (\"Error: too many triangles; increase POLYSET_MAXTRIANGLES\\n\");\n\t}\n}\n\nvoid TRI_LoadPolysets( const char *filename, polyset_t **ppPSET, int *numpsets )\n{\n\tFILE        *input;\n\tfloat       start;\n\tchar        name[256], tex[256];\n\tint         i, count, magic, pset = 0;\n\ttriangle_t\t*ptri;\n\tpolyset_t\t*pPSET;\n\tint\t\t\tiLevel;\n\tint\t\t\texitpattern;\n\tfloat\t\tt;\n\n\tt = -FLOAT_START;\n\t*((unsigned char *)&exitpattern + 0) = *((unsigned char *)&t + 3);\n\t*((unsigned char *)&exitpattern + 1) = *((unsigned char *)&t + 2);\n\t*((unsigned char *)&exitpattern + 2) = *((unsigned char *)&t + 1);\n\t*((unsigned char *)&exitpattern + 3) = *((unsigned char *)&t + 0);\n\n\tif ((input = fopen(filename, \"rb\")) == 0)\n\t\tError (\"reader: could not open file '%s'\", filename);\n\n\tiLevel = 0;\n\n\tfread(&magic, sizeof(int), 1, input);\n\tif (BigLong(magic) != MAGIC)\n\t\tError (\"%s is not a Alias object separated triangle file, magic number is wrong.\", filename);\n\n\tpPSET = calloc( 1, POLYSET_MAXPOLYSETS * sizeof( polyset_t ) );\n\tptri = calloc( 1, POLYSET_MAXTRIANGLES * sizeof( triangle_t ) );\n\n\t*ppPSET = pPSET;\n\n\twhile (feof(input) == 0) {\n\t\tif (fread(&start,  sizeof(float), 1, input) < 1)\n\t\t\tbreak;\n\t\t*(int *)&start = BigLong(*(int *)&start);\n\t\tif (*(int *)&start != exitpattern)\n\t\t{\n\t\t\tif (start == FLOAT_START) {\n\t\t\t\t/* Start of an object or group of objects. */\n\t\t\t\ti = -1;\n\t\t\t\tdo {\n\t\t\t\t\t/* There are probably better ways to read a string from */\n\t\t\t\t\t/* a file, but this does allow you to do error checking */\n\t\t\t\t\t/* (which I'm not doing) on a per character basis.      */\n\t\t\t\t\t++i;\n\t\t\t\t\tfread( &(name[i]), sizeof( char ), 1, input);\n\t\t\t\t} while( name[i] != '\\0' );\n\t\n\t\t\t\tif ( i != 0 )\n\t\t\t\t\tstrncpy( pPSET[pset].name, name, sizeof( pPSET[pset].name ) - 1 );\n\t\t\t\telse\n\t\t\t\t\tstrcpy( pPSET[pset].name , \"(unnamed)\" );\n\t\t\t\tstrlwr( pPSET[pset].name );\n\n//\t\t\t\tindent();\n//\t\t\t\tfprintf(stdout,\"OBJECT START: %s\\n\",name);\n\t\t\t\tfread( &count, sizeof(int), 1, input);\n\t\t\t\tcount = BigLong(count);\n\t\t\t\t++iLevel;\n\t\t\t\tif (count != 0) {\n//\t\t\t\t\tindent();\n//\t\t\t\t\tfprintf(stdout,\"NUMBER OF TRIANGLES: %d\\n\",count);\n\t\n\t\t\t\t\ti = -1;\n\t\t\t\t\tdo {\n\t\t\t\t\t\t++i;\n\t\t\t\t\t\tfread( &(tex[i]), sizeof( char ), 1, input);\n\t\t\t\t\t} while( tex[i] != '\\0' );\n\n/*\n\t\t\t\t\tif ( i != 0 )\n\t\t\t\t\t\tstrncpy( pPSET[pset].texname, tex, sizeof( pPSET[pset].texname ) - 1 );\n\t\t\t\t\telse\n\t\t\t\t\t\tstrcpy( pPSET[pset].texname, \"(unnamed)\" );\n\t\t\t\t\tstrlwr( pPSET[pset].texname );\n*/\n\n//\t\t\t\t\tindent();\n//\t\t\t\t\tfprintf(stdout,\"  Object texture name: '%s'\\n\",tex);\n\t\t\t\t}\n\t\n\t\t\t\t/* Else (count == 0) this is the start of a group, and */\n\t\t\t\t/* no texture name is present. */\n\t\t\t}\n\t\t\telse if (start == FLOAT_END) {\n\t\t\t\t/* End of an object or group. Yes, the name should be */\n\t\t\t\t/* obvious from context, but it is in here just to be */\n\t\t\t\t/* safe and to provide a little extra information for */\n\t\t\t\t/* those who do not wish to write a recursive reader. */\n\t\t\t\t/* Mea culpa. */\n\t\t\t\t--iLevel;\n\t\t\t\ti = -1;\n\t\t\t\tdo {\n\t\t\t\t\t++i;\n\t\t\t\t\tfread( &(name[i]), sizeof( char ), 1, input);\n\t\t\t\t} while( name[i] != '\\0' );\n\n\t\t\t\tif ( i != 0 )\n\t\t\t\t\tstrncpy( pPSET[pset].name, name, sizeof( pPSET[pset].name ) - 1 );\n\t\t\t\telse\n\t\t\t\t\tstrcpy( pPSET[pset].name , \"(unnamed)\" );\n\n\t\t\t\tstrlwr( pPSET[pset].name );\n\t\n//\t\t\t\tindent();\n//\t\t\t\tfprintf(stdout,\"OBJECT END: %s\\n\",name);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n//\n// read the triangles\n//\t\t\n\t\tif ( count > 0 )\n\t\t{\n\t\t\tpPSET[pset].triangles = ptri;\n\t\t\tReadPolysetGeometry( pPSET[0].triangles, input, count, ptri );\n\t\t\tptri += count;\n\t\t\tpPSET[pset].numtriangles = count;\n\t\t\tif ( ++pset >= POLYSET_MAXPOLYSETS )\n\t\t\t{\n\t\t\t\tError (\"Error: too many polysets; increase POLYSET_MAXPOLYSETS\\n\");\n\t\t\t}\n\t\t}\n\t}\n\n\t*numpsets = pset;\n\n\tfclose (input);\n}\n\n"
  },
  {
    "path": "common/trilib.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// trilib.h: header file for loading triangles from an Alias triangle file\n//\nvoid TRI_LoadPolysets( const char *filename, polyset_t **ppPSET, int *numpsets );\n\n"
  },
  {
    "path": "lcc/COPYRIGHT",
    "content": "The authors of this software are Christopher W. Fraser and\nDavid R. Hanson.\n\nCopyright (c) 1991,1992,1993,1994,1995,1996,1997,1998 by AT&T,\nChristopher W. Fraser, and David R. Hanson. All Rights Reserved.\n\nPermission to use, copy, modify, and distribute this software for any\npurpose, subject to the provisions described below, without fee is\nhereby granted, provided that this entire notice is included in all\ncopies of any software that is or includes a copy or modification of\nthis software and in all copies of the supporting documentation for\nsuch software.\n\nTHIS SOFTWARE IS BEING PROVIDED \"AS IS\", WITHOUT ANY EXPRESS OR IMPLIED\nWARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR AT&T MAKE ANY\nREPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY\nOF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.\n\n\nlcc is not public-domain software, shareware, and it is not protected\nby a `copyleft' agreement, like the code from the Free Software\nFoundation.\n\nlcc is available free for your personal research and instructional use\nunder the `fair use' provisions of the copyright law. You may, however,\nredistribute lcc in whole or in part provided you acknowledge its\nsource and include this CPYRIGHT file. You may, for example, include\nthe distribution in a CDROM of free software, provided you charge only\nfor the media, or mirror the distribution files at your site.\n\nYou may not sell lcc or any product derived from it in which it is a\nsignificant part of the value of the product. Using the lcc front end\nto build a C syntax checker is an example of this kind of product.\n\nYou may use parts of lcc in products as long as you charge for only\nthose components that are entirely your own and you acknowledge the use\nof lcc clearly in all product documentation and distribution media. You\nmust state clearly that your product uses or is based on parts of lcc\nand that lcc is available free of charge. You must also request that\nbug reports on your product be reported to you. Using the lcc front\nend to build a C compiler for the Motorola 88000 chip and charging for\nand distributing only the 88000 code generator is an example of this\nkind of product.\n\nUsing parts of lcc in other products is more problematic. For example,\nusing parts of lcc in a C++ compiler could save substantial time and\neffort and therefore contribute significantly to the profitability of\nthe product. This kind of use, or any use where others stand to make a\nprofit from what is primarily our work, requires a license agreement\nwith Addison-Wesley.  Per-copy and unlimited use licenses are\navailable; for more information, contact\n\n\tJ. Carter Shanklin\n\tAddison Wesley Longman, Inc. \n\t2725 Sand Hill Rd.\n\tMenlo Park, CA 94025\n\t650/854-0300 x2478 FAX: 650/614-2930 jcs@awl.com\n-----\nChris Fraser / cwfraser@microsoft.com\nDavid Hanson / drh@microsoft.com\n$Revision: 145 $ $Date: 2001-10-17 16:53:10 -0500 (Wed, 17 Oct 2001) $\n"
  },
  {
    "path": "lcc/LOG",
    "content": "From lcc 4.0 to 4.1:\n\nChanges:\n\nSee doc/4.html for changes in the code-generation interface.\n\nWarns about constants that are too large, eg, short x = 70000;\n\nWarns about expressions that have no effect.\n\nUnsigned shorts are now used for wide-character constants, and\nwchar_t is a typedef for unsigned short.\n\nMore assertions in gen.c to confirm that the register allocator is\nconfigured correctly; ie, that the various masks, wildcards,\nclobbers, and targets are internally consistent. Full checking\nappears impractical, but there's still more than than there was\nbefore.\n\nOn the SPARC, lcc now emits .type and .size directives\nunconditionally.\n\nOn the x86, constants are now emitted into the text segment.\n\nIf the environment variable \"LCCDIR\" is defined, it gives the directory\nthat contains the preprocessor, the compiler proper, and the\nlcc-specific libraries.\n\nUnder Windows, lcc searches the directories named in the environment\nvariable \"include\" for header files.\n\nErrors fixed:\n\nErroneously complained about unknown sizes for some const fields, eg,\ntypedef struct foo ref; struct foo { const ref *q; int a; };\nf(ref *p, int i) { return p->q[i].a; }\n\n-A -A erroneously complained about static main's that didn't conform\nto the ANSI-mandated \"int main(void)\" or \"int main(int, char **)\".\n\nSilently generated incorrect code for a structure copy with a\npost-incremented target, eg,\nstruct { int x; } data = {1}, copy[2], *q = copy;\nmain() { *q++ = data; }\n\nGenerated incorrect values in some expressions with constant pointers.\n\nSilently truncated string literals longer than 4095 characters.\n\nFailed to emit debugging information for uninitialized globals.\n\nFailed to diagnose missing sizes in some multi-dimensioned array\ndeclarators, eg, extern int x[][10]; int x[5][];\n\nSilently emitted incorrect sizes and initalizations for some\nincomplete multi-dimensioned arrays involving pointers and whose size\nis determined by the number of initializers.\n\nSet only the x.name field for some back-end symbols (eg, wildcards),\nand the uninitialized name field crashed some debugging output.\n\nuses() failed to check the register *set* as well as the register\nmask.  There's no known bug demo, but a wildcard set might be\ncontrived that would need the test.\n\nCrashed with -b on some conditional expressions involving calls, eg,\nint p; void g(void) { p ? f() : 1; }\n\nOn the MIPS, sometimes generated an incorrect frame size and thus a\ncrash when floating-point registers were saved.\n\nOn the SPARC, erroneously reused a register variable as a temporary\nwhen the variable is compiler-generated.\n\nOn the SPARC with -b, emitted incorrect code for returning structs.\n\nOn the x86, conversion from float to int rounded instead of truncated\nwith the default floating-point mode.\n\nOn the x86, eliminate rtargets for kids after the first (see p. 419).\n\nOn the x86, substitute reg for freg, in order to use the common reg\nrules. Needed only for debugging output, since we're not using any\nfloat regs as regs at this time.\n\nOn the x86, \"double f(); main(){f();}\" wasn't popping the FP register stack.\n\nOn the x86, ECX was saved by the callee, when it should have been\nsaved by the caller.\n\n$Id: LOG 145 2001-10-17 21:53:10Z timo $\n"
  },
  {
    "path": "lcc/README",
    "content": "This hierarchy is the distribution for lcc version 4.1.\n\nlcc version 3.x is described in the book \"A Retargetable C Compiler:\nDesign and Implementation\" (Addison-Wesley, 1995, ISBN 0-8053-1670-1).\nThere are significant differences between 3.x and 4.x, most notably in\nthe intermediate code. doc/4.html summarizes the differences.\n\nVERSION 4.1 IS INCOMPATIBLE WITH EARLIER VERSIONS OF LCC. DO NOT\nUNLOAD THIS DISTRIBUTION ON TOP OF A 3.X DISTRIBUTION.\n\nLOG describes the changes since the last release.\n\nCPYRIGHT describes the conditions under you can use, copy, modify, and\ndistribute lcc or works derived from lcc.\n\ndoc/install.html is an HTML file that gives a complete description of\nthe distribution and installation instructions.\n\nChris Fraser / cwfraser@microsoft.com\nDavid Hanson / drh@microsoft.com\n$Revision: 145 $ $Date: 2001-10-17 16:53:10 -0500 (Wed, 17 Oct 2001) $\n"
  },
  {
    "path": "lcc/README.id",
    "content": "2001-10-31  Timothee Besset <ttimo@idsoftware.com>\nupdated from the $/source/lcc code\nmodified for portability and use with >= 1.31 mod source release\n"
  },
  {
    "path": "lcc/alpha/osf/tst/8q.1bk",
    "content": "1 5 8 6 3 7 2 4 \n1 6 8 3 7 4 2 5 \n1 7 4 6 8 2 5 3 \n1 7 5 8 2 4 6 3 \n2 4 6 8 3 1 7 5 \n2 5 7 1 3 8 6 4 \n2 5 7 4 1 8 6 3 \n2 6 1 7 4 8 3 5 \n2 6 8 3 1 4 7 5 \n2 7 3 6 8 5 1 4 \n2 7 5 8 1 4 6 3 \n2 8 6 1 3 5 7 4 \n3 1 7 5 8 2 4 6 \n3 5 2 8 1 7 4 6 \n3 5 2 8 6 4 7 1 \n3 5 7 1 4 2 8 6 \n3 5 8 4 1 7 2 6 \n3 6 2 5 8 1 7 4 \n3 6 2 7 1 4 8 5 \n3 6 2 7 5 1 8 4 \n3 6 4 1 8 5 7 2 \n3 6 4 2 8 5 7 1 \n3 6 8 1 4 7 5 2 \n3 6 8 1 5 7 2 4 \n3 6 8 2 4 1 7 5 \n3 7 2 8 5 1 4 6 \n3 7 2 8 6 4 1 5 \n3 8 4 7 1 6 2 5 \n4 1 5 8 2 7 3 6 \n4 1 5 8 6 3 7 2 \n4 2 5 8 6 1 3 7 \n4 2 7 3 6 8 1 5 \n4 2 7 3 6 8 5 1 \n4 2 7 5 1 8 6 3 \n4 2 8 5 7 1 3 6 \n4 2 8 6 1 3 5 7 \n4 6 1 5 2 8 3 7 \n4 6 8 2 7 1 3 5 \n4 6 8 3 1 7 5 2 \n4 7 1 8 5 2 6 3 \n4 7 3 8 2 5 1 6 \n4 7 5 2 6 1 3 8 \n4 7 5 3 1 6 8 2 \n4 8 1 3 6 2 7 5 \n4 8 1 5 7 2 6 3 \n4 8 5 3 1 7 2 6 \n5 1 4 6 8 2 7 3 \n5 1 8 4 2 7 3 6 \n5 1 8 6 3 7 2 4 \n5 2 4 6 8 3 1 7 \n5 2 4 7 3 8 6 1 \n5 2 6 1 7 4 8 3 \n5 2 8 1 4 7 3 6 \n5 3 1 6 8 2 4 7 \n5 3 1 7 2 8 6 4 \n5 3 8 4 7 1 6 2 \n5 7 1 3 8 6 4 2 \n5 7 1 4 2 8 6 3 \n5 7 2 4 8 1 3 6 \n5 7 2 6 3 1 4 8 \n5 7 2 6 3 1 8 4 \n5 7 4 1 3 8 6 2 \n5 8 4 1 3 6 2 7 \n5 8 4 1 7 2 6 3 \n6 1 5 2 8 3 7 4 \n6 2 7 1 3 5 8 4 \n6 2 7 1 4 8 5 3 \n6 3 1 7 5 8 2 4 \n6 3 1 8 4 2 7 5 \n6 3 1 8 5 2 4 7 \n6 3 5 7 1 4 2 8 \n6 3 5 8 1 4 2 7 \n6 3 7 2 4 8 1 5 \n6 3 7 2 8 5 1 4 \n6 3 7 4 1 8 2 5 \n6 4 1 5 8 2 7 3 \n6 4 2 8 5 7 1 3 \n6 4 7 1 3 5 2 8 \n6 4 7 1 8 2 5 3 \n6 8 2 4 1 7 5 3 \n7 1 3 8 6 4 2 5 \n7 2 4 1 8 5 3 6 \n7 2 6 3 1 4 8 5 \n7 3 1 6 8 5 2 4 \n7 3 8 2 5 1 6 4 \n7 4 2 5 8 1 3 6 \n7 4 2 8 6 1 3 5 \n7 5 3 1 6 8 2 4 \n8 2 4 1 7 5 3 6 \n8 2 5 3 1 7 4 6 \n8 3 1 6 2 5 7 4 \n8 4 1 3 6 2 7 5 \n"
  },
  {
    "path": "lcc/alpha/osf/tst/8q.2bk",
    "content": "tst/8q.c:30: warning: missing return value\ntst/8q.c:39: warning: missing return value\n"
  },
  {
    "path": "lcc/alpha/osf/tst/8q.sbk",
    "content": ".globl main\n.text\n.text\n.ent main\nmain:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4004000,-72\n.frame $sp,80,$26,48\nstq $14,0($sp)\nstq $26,8($sp)\n.prologue 1\nmov $31,$14\nL.2:\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nlda $25,1\nstl $25,down($27)\nstl $25,up($27)\nL.3:\nlda $14,1($14)\ncmplt $14,15,$23\nbne $23,L.2\nmov $31,$14\nL.6:\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nlda $25,1\nstl $25,rows($27)\nL.7:\nlda $14,1($14)\ncmplt $14,8,$23\nbne $23,L.6\nmov $31,$16\njsr $26,queens\nldgp $gp,0($26)\nmov $31,$0\nL.1:\nldq $14,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end main\n.globl queens\n.text\n.ent queens\nqueens:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4006000,-64\n.frame $sp,80,$26,48\nstq $13,0($sp)\nstq $14,8($sp)\nstq $26,16($sp)\nmov $16,$14\n.prologue 1\nmov $31,$13\nL.11:\nsll $13,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,2,$25\nldl $25,rows($25)\ncmpeq $25,$31,$23\nbne $23,L.15\nsubl $13,$14,$25\nlda $25,7($25)\nsll $25,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,2,$25\nldl $25,up($25)\ncmpeq $25,$31,$23\nbne $23,L.15\naddl $13,$14,$25\nsll $25,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,2,$25\nldl $25,down($25)\ncmpeq $25,$31,$23\nbne $23,L.15\naddl $13,$14,$25\nsll $25,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,2,$25\nstl $31,down($25)\nsubl $13,$14,$25\nlda $25,7($25)\nsll $25,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,2,$25\nstl $31,up($25)\nsll $13,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,2,$25\nstl $31,rows($25)\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nstl $13,x($27)\ncmpeq $14,7,$23\nbeq $23,L.17\njsr $26,print\nldgp $gp,0($26)\nbr L.18\nL.17:\nlda $16,1($14)\njsr $26,queens\nldgp $gp,0($26)\nL.18:\nlda $27,1\naddl $13,$14,$25\nsll $25,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,2,$25\nstl $27,down($25)\nsubl $13,$14,$25\nlda $25,7($25)\nsll $25,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,2,$25\nstl $27,up($25)\nsll $13,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,2,$25\nstl $27,rows($25)\nL.15:\nL.12:\nlda $13,1($13)\ncmplt $13,8,$23\nbne $23,L.11\nmov $31,$0\nL.10:\nldq $13,0($sp)\nldq $14,8($sp)\nldq $26,16($sp)\nlda $sp,80($sp)\nret\n.end queens\n.globl print\n.text\n.ent print\nprint:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4004000,-72\n.frame $sp,80,$26,48\nstq $14,0($sp)\nstq $26,8($sp)\n.prologue 1\nmov $31,$14\nL.20:\nlda $16,L.24\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nldl $27,x($27)\nlda $17,49($27)\njsr $26,printf\nldgp $gp,0($26)\nL.21:\nlda $14,1($14)\ncmplt $14,8,$23\nbne $23,L.20\nlda $16,L.25\njsr $26,printf\nldgp $gp,0($26)\nmov $31,$0\nL.19:\nldq $14,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end print\n.globl x\n.comm x,32\n.globl rows\n.comm rows,32\n.globl down\n.comm down,60\n.globl up\n.comm up,60\n.rdata\n.align 0\nL.25:\n.byte 10\n.byte 0\n.align 0\nL.24:\n.byte 37\n.byte 99\n.byte 32\n.byte 0\n"
  },
  {
    "path": "lcc/alpha/osf/tst/array.1bk",
    "content": " 0 1 2 3 1000 1001 1002 1003 2000 2001 2002 2003\n 0 1 2 3 1000 1001 1002 1003 2000 2001 2002 2003\n 0 1 2 3 1000 1001 1002 1003 2000 2001 2002 2003\n 0 1 2 3 1000 1001 1002 1003 2000 2001 2002 2003\n"
  },
  {
    "path": "lcc/alpha/osf/tst/array.2bk",
    "content": "tst/array.c:33: warning: missing return value\ntst/array.c:48: warning: missing return value\n"
  },
  {
    "path": "lcc/alpha/osf/tst/array.sbk",
    "content": ".globl main\n.text\n.text\n.ent main\nmain:\nldgp $gp,0($27)\nlda $sp,-144($sp)\n.mask 0x4007000,-120\n.frame $sp,144,$26,48\nstq $12,0($sp)\nstq $13,8($sp)\nstq $14,16($sp)\nstq $26,24($sp)\n.prologue 1\nmov $31,$13\nL.2:\nmov $31,$14\nL.6:\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nsll $13,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,4,$25\nlda $25,x($25)\naddq $27,$25,$27\nlda $25,1000\nmull $25,$13,$25\naddl $25,$14,$25\nstl $25,($27)\nL.7:\nlda $14,1($14)\ncmplt $14,4,$23\nbne $23,L.6\nsll $13,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,3,$25\nsll $27,4,$27\nlda $27,x($27)\nstq $27,y($25)\nL.3:\nlda $13,1($13)\ncmplt $13,3,$23\nbne $23,L.2\njsr $26,f\nldgp $gp,0($26)\nmov $31,$13\nL.10:\nsll $13,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,4,$25\nlda $22,-104+144($sp)\naddq $25,$22,$25\nmov $25,$12\nsll $27,3,$27\nstq $25,y($27)\nmov $31,$14\nL.14:\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\naddq $27,$12,$25\nsll $13,8*(8-4),$22\nsra $22,8*(8-4),$22\nsll $22,4,$22\nlda $22,x($22)\naddq $27,$22,$27\nldl $27,($27)\nstl $27,($25)\nL.15:\nlda $14,1($14)\ncmplt $14,4,$23\nbne $23,L.14\nL.11:\nlda $13,1($13)\ncmplt $13,3,$23\nbne $23,L.10\nlda $16,-104+144($sp)\nlda $17,y\njsr $26,g\nldgp $gp,0($26)\nmov $31,$0\nL.1:\nldq $12,0($sp)\nldq $13,8($sp)\nldq $14,16($sp)\nldq $26,24($sp)\nlda $sp,144($sp)\nret\n.end main\n.globl f\n.text\n.ent f\nf:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4006000,-64\n.frame $sp,80,$26,48\nstq $13,0($sp)\nstq $14,8($sp)\nstq $26,16($sp)\n.prologue 1\nmov $31,$13\nL.19:\nmov $31,$14\nL.23:\nlda $16,L.27\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nsll $13,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,4,$25\nlda $25,x($25)\naddq $27,$25,$27\nldl $17,($27)\njsr $26,printf\nldgp $gp,0($26)\nL.24:\nlda $14,1($14)\ncmplt $14,4,$23\nbne $23,L.23\nL.20:\nlda $13,1($13)\ncmplt $13,3,$23\nbne $23,L.19\nlda $16,L.28\njsr $26,printf\nldgp $gp,0($26)\nmov $31,$13\nL.29:\nmov $31,$14\nL.33:\nlda $16,L.27\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nsll $13,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,3,$25\nldq $25,y($25)\naddq $27,$25,$27\nldl $17,($27)\njsr $26,printf\nldgp $gp,0($26)\nL.34:\nlda $14,1($14)\ncmplt $14,4,$23\nbne $23,L.33\nL.30:\nlda $13,1($13)\ncmplt $13,3,$23\nbne $23,L.29\nlda $16,L.28\njsr $26,printf\nldgp $gp,0($26)\nmov $31,$0\nL.18:\nldq $13,0($sp)\nldq $14,8($sp)\nldq $26,16($sp)\nlda $sp,80($sp)\nret\n.end f\n.globl g\n.text\n.ent g\ng:\nldgp $gp,0($27)\nlda $sp,-96($sp)\n.mask 0x4007800,-64\n.frame $sp,96,$26,48\nstq $11,0($sp)\nstq $12,8($sp)\nstq $13,16($sp)\nstq $14,24($sp)\nstq $26,32($sp)\nmov $16,$14\nmov $17,$13\n.prologue 1\nmov $31,$11\nL.38:\nmov $31,$12\nL.42:\nlda $16,L.27\nsll $12,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nsll $11,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,4,$25\naddq $25,$14,$25\naddq $27,$25,$27\nldl $17,($27)\njsr $26,printf\nldgp $gp,0($26)\nL.43:\nlda $12,1($12)\ncmplt $12,4,$23\nbne $23,L.42\nL.39:\nlda $11,1($11)\ncmplt $11,3,$23\nbne $23,L.38\nlda $16,L.28\njsr $26,printf\nldgp $gp,0($26)\nmov $31,$11\nL.46:\nmov $31,$12\nL.50:\nlda $16,L.27\nsll $12,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nsll $11,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,3,$25\naddq $25,$13,$25\nldq $25,($25)\naddq $27,$25,$27\nldl $17,($27)\njsr $26,printf\nldgp $gp,0($26)\nL.51:\nlda $12,1($12)\ncmplt $12,4,$23\nbne $23,L.50\nL.47:\nlda $11,1($11)\ncmplt $11,3,$23\nbne $23,L.46\nlda $16,L.28\njsr $26,printf\nldgp $gp,0($26)\nmov $31,$0\nL.37:\nldq $11,0($sp)\nldq $12,8($sp)\nldq $13,16($sp)\nldq $14,24($sp)\nldq $26,32($sp)\nlda $sp,96($sp)\nret\n.end g\n.globl y\n.comm y,24\n.globl x\n.comm x,48\n.rdata\n.align 0\nL.28:\n.byte 10\n.byte 0\n.align 0\nL.27:\n.byte 32\n.byte 37\n.byte 100\n.byte 0\n"
  },
  {
    "path": "lcc/alpha/osf/tst/cf.1bk",
    "content": "char\tfreq\n011\t8.1\n012\t6.1\n040\t11.9\n!\t0.2\n\"\t1.5\n%\t0.6\n&\t0.4\n'\t0.4\n(\t2.9\n)\t2.9\n*\t0.8\n+\t1.3\n,\t1.3\n-\t0.4\n.\t0.6\n/\t1.0\n0\t2.5\n1\t1.9\n2\t0.6\n3\t0.2\n7\t0.4\n8\t0.2\n;\t3.8\n<\t0.8\n=\t2.7\n>\t0.2\n[\t1.5\n\\\t0.8\n]\t1.5\na\t3.1\nc\t4.4\ne\t2.3\nf\t6.0\ng\t1.3\nh\t1.0\ni\t5.0\nl\t1.0\nm\t0.2\nn\t3.3\no\t2.1\np\t1.0\nq\t0.4\nr\t4.2\ns\t0.6\nt\t3.8\nu\t1.2\nv\t0.6\nw\t0.2\n{\t0.6\n}\t0.6\n"
  },
  {
    "path": "lcc/alpha/osf/tst/cf.2bk",
    "content": ""
  },
  {
    "path": "lcc/alpha/osf/tst/cf.sbk",
    "content": ".globl main\n.text\n.text\n.ent main\nmain:\nldgp $gp,0($27)\nlda $sp,-96($sp)\n.fmask 0x200,-96\n.mask 0x4007000,-64\n.frame $sp,96,$26,48\nstt $f9,0($sp)\nstq $12,8($sp)\nstq $13,16($sp)\nstq $14,24($sp)\nstq $26,32($sp)\nstq $16,48($sp)\nstq $17,56($sp)\n.prologue 1\nldl $27,-48+96($sp)\ncmple $27,1,$23\nbeq $23,L.2\nlds $f9,L.4\nbr L.3\nL.2:\nldq $27,-40+96($sp)\nldq $16,8($27)\njsr $26,atof\nldgp $gp,0($26)\nlds $f29,L.5\ndivs $f0,$f29,$f9\nL.3:\nmov $31,$14\nL.6:\nmov $14,$27\nlda $14,1($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nlds $f30,L.4\nsts $f30,f($27)\nL.7:\nlda $27,127\ncmple $14,$27,$23\nbne $23,L.6\nmov $31,$13\nbr L.11\nL.10:\nsll $12,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nlda $27,f($27)\nlds $f30,($27)\nlds $f29,L.13\nadds $f30,$f29,$f30\nsts $f30,($27)\nlda $13,1($13)\nL.11:\njsr $26,getchar\nldgp $gp,0($26)\nmov $0,$12\nlda $25,-1\ncmpeq $0,$25,$23\nbeq $23,L.10\nlda $16,L.14\njsr $26,printf\nldgp $gp,0($26)\nmov $31,$14\nL.15:\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nlds $f30,f($27)\nlds $f29,L.4\ncmpteq $f30,$f29,$f1\nfbne $f1,L.19\nstq $13,-56+96($sp)\nldt $f29,-56+96($sp)\ncvtqs $f29,$f29\ndivs $f30,$f29,$f30\ncmptlt $f30,$f9,$f1\nfbne $f1,L.19\ncmple $14,32,$23\nbeq $23,L.21\nlda $16,L.23\nmov $14,$17\njsr $26,printf\nldgp $gp,0($26)\nbr L.22\nL.21:\nlda $16,L.24\nmov $14,$17\njsr $26,printf\nldgp $gp,0($26)\nL.22:\nlda $16,L.25\nlds $f30,L.5\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nlds $f29,f($27)\nmuls $f30,$f29,$f30\nstq $13,-56+96($sp)\nldt $f29,-56+96($sp)\ncvtqs $f29,$f29\ndivs $f30,$f29,$f30\ncvtst $f30,$f17\njsr $26,printf\nldgp $gp,0($26)\nL.19:\nL.16:\nlda $14,1($14)\nlda $27,127\ncmple $14,$27,$23\nbne $23,L.15\nmov $31,$0\nL.1:\nldt $f9,0($sp)\nldq $12,8($sp)\nldq $13,16($sp)\nldq $14,24($sp)\nldq $26,32($sp)\nlda $sp,96($sp)\nret\n.end main\n.globl f\n.comm f,512\n.rdata\n.align 0\nL.25:\n.byte 9\n.byte 37\n.byte 46\n.byte 49\n.byte 102\n.byte 10\n.byte 0\n.align 0\nL.24:\n.byte 37\n.byte 99\n.byte 0\n.align 0\nL.23:\n.byte 37\n.byte 48\n.byte 51\n.byte 111\n.byte 0\n.align 0\nL.14:\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 9\n.byte 102\n.byte 114\n.byte 101\n.byte 113\n.byte 10\n.byte 0\n.align 2\nL.13:\n.long 0x3f800000\n.align 2\nL.5:\n.long 0x42c80000\n.align 2\nL.4:\n.long 0x0\n"
  },
  {
    "path": "lcc/alpha/osf/tst/cq.1bk",
    "content": "Section s22     returned 0.\ns241,er4\nSection s241    returned 4.\nSection s243    returned 0.\nSection s244    returned 0.\nSection s25     returned 0.\n  8 bits in chars.\n 32 bits in ints.\n 16 bits in shorts.\n 64 bits in longs.\n 32 bits in unsigneds.\n 32 bits in floats.\n 64 bits in doubles.\n1.192093e-07 is the least number that can be added to 1. (float).\n2.220446e-16 is the least number that can be added to 1. (double).\nSection s26     returned 0.\nSection s4      returned 0.\nSection s61     returned 0.\nSection s626    returned 0.\nSection s71     returned 0.\nSection s72     returned 0.\nSection s757    returned 0.\nSection s7813   returned 0.\nSection s714    returned 0.\nSection s715    returned 0.\nRegister count for char is unreliable.\nRegister count for pointer is unreliable.\nRegister count for int is unreliable.\nSection s81     returned 0.\nSection s84     returned 0.\nchar alignment: 1\nshort alignment: 2\nint alignment: 4\nlong alignment: 8\nunsigned alignment: 4\nfloat alignment: 4\ndouble alignment: 8\nSign extension in fields\nBe especially careful with 1-bit fields!\nSection s85     returned 0.\nSection s86     returned 0.\nSection s88     returned 0.\nSection s9      returned 0.\n\nFailed.\n"
  },
  {
    "path": "lcc/alpha/osf/tst/cq.2bk",
    "content": "tst/cq.c:533: warning: missing return value\ntst/cq.c:1169: warning: missing return value\ntst/cq.c:5294: warning: unreachable code\ntst/cq.c:5303: warning: missing return value\n"
  },
  {
    "path": "lcc/alpha/osf/tst/cq.sbk",
    "content": ".sdata\n.align 3\nL.2:\n.quad s22\n.quad s241\n.quad s243\n.quad s244\n.quad s25\n.quad s26\n.quad s4\n.quad s61\n.quad s626\n.quad s71\n.quad s72\n.quad s757\n.quad s7813\n.quad s714\n.quad s715\n.quad s81\n.quad s84\n.quad s85\n.quad s86\n.quad s88\n.quad s9\n.lcomm L.3,68\n.lcomm L.4,8\n.globl main\n.text\n.text\n.ent main\nmain:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4004000,-72\n.frame $sp,80,$26,48\nstq $14,0($sp)\nstq $26,8($sp)\nstq $16,32($sp)\nstq $17,40($sp)\n.prologue 1\nlda $27,1\nstl $27,L.3+36\nlda $27,1\nstl $27,L.3+40\nlda $27,1\nstl $27,L.3+44\nlda $27,1\nstl $27,L.3+48\nlda $27,L.3\nstq $27,L.4\nmov $31,$14\nbr L.12\nL.9:\nldq $16,L.4\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,3,$27\nldq $27,L.2($27)\njsr $26,($27)\nldgp $gp,0($26)\nstl $0,L.3+52\nldl $27,L.3+56\nldl $25,L.3+52\naddl $27,$25,$27\nstl $27,L.3+56\nldl $27,L.3+36\ncmpeq $27,$31,$23\nbne $23,L.17\nlda $16,L.20\nlda $17,L.3+60\nldl $18,L.3+52\njsr $26,printf\nldgp $gp,0($26)\nL.17:\nL.10:\nlda $14,1($14)\nL.12:\nmov $14,$27\nlda $25,21\ncmpult $27,$25,$23\nbne $23,L.9\nldl $27,L.3+56\ncmpeq $27,$31,$23\nbeq $23,L.23\nlda $16,L.26\njsr $26,printf\nldgp $gp,0($26)\nbr L.24\nL.23:\nlda $16,L.27\njsr $26,printf\nldgp $gp,0($26)\nL.24:\nmov $31,$0\nL.1:\nldq $14,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end main\n.sdata\n.align 0\nL.29:\n.byte 115\n.byte 50\n.byte 50\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.30:\n.byte 115\n.byte 50\n.byte 50\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s22\n.text\n.text\n.ent s22\ns22:\nldgp $gp,0($27)\nlda $sp,-128($sp)\n.mask 0x5007800,-88\n.frame $sp,128,$26,48\nstq $11,0($sp)\nstq $12,8($sp)\nstq $13,16($sp)\nstq $14,24($sp)\nstq $24,32($sp)\nstq $26,40($sp)\nstq $16,80($sp)\n.prologue 1\nmov $31,$12\nlda $14,L.30\nldq $27,-48+128($sp)\nlda $13,60($27)\nL.31:\nL.32:\nmov $13,$27\nlda $13,1($27)\nmov $14,$25\nlda $14,1($25)\nldb $25,($25)\nstb $25,($27)\nsll $25,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbeq $23,L.31\nlda $11,1\nlda $27,2\nstl $27,-64+128($sp)\nlda $27,3\nstl $27,-68+128($sp)\nlda $27,4\nstl $27,-60+128($sp)\nldl $27,-64+128($sp)\naddl $11,$27,$27\nldl $25,-68+128($sp)\naddl $27,$25,$27\nldl $25,-60+128($sp)\naddl $27,$25,$27\ncmpeq $27,10,$23\nbne $23,L.34\nlda $12,1($12)\nldq $27,-48+128($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.36\nlda $16,L.29\nlda $17,1\njsr $26,printf\nldgp $gp,0($26)\nL.36:\nL.34:\nlda $27,2\nstl $27,-72+128($sp)\nldl $27,-72+128($sp)\ncmpeq $27,$11,$23\nbeq $23,L.38\nlda $12,4($12)\nldq $27,-48+128($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.40\nlda $16,L.29\nlda $17,4\njsr $26,printf\nldgp $gp,0($26)\nL.40:\nL.38:\nmov $12,$0\nL.28:\nldq $11,0($sp)\nldq $12,8($sp)\nldq $13,16($sp)\nldq $14,24($sp)\nldq $24,32($sp)\nldq $26,40($sp)\nlda $sp,128($sp)\nret\n.end s22\n.sdata\n.align 0\nL.43:\n.byte 115\n.byte 50\n.byte 52\n.byte 49\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.44:\n.byte 115\n.byte 50\n.byte 52\n.byte 49\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.align 3\nL.45:\n.quad 0x0\n.quad 0x0\n.quad 0x0\n.quad 0x0\n.quad 0x0\n.quad 0x0\n.quad 0x0\n.quad 0x0\n.quad 0x0\n.quad 0x0\n.quad 0x0\n.quad 0x0\n.quad 0x0\n.quad 0x0\n.quad 0x0\n.quad 0x0\n.quad 0x0\n.quad 0x0\n.quad 0x6\n.quad 0x0\n.quad 0x8\n.quad 0x0\n.quad 0xc\n.quad 0x0\n.quad 0x10\n.quad 0x0\n.quad 0x12\n.quad 0x0\n.quad 0x14\n.quad 0x0\n.quad 0x18\n.quad 0x0\n.quad 0x1c\n.quad 0x0\n.quad 0x1e\n.quad 0x0\n.quad 0x20\n.quad 0x0\n.quad 0x24\n.globl s241\n.text\n.text\n.ent s241\ns241:\nldgp $gp,0($27)\nlda $sp,-1072($sp)\n.mask 0x5007c00,-1024\n.frame $sp,1072,$26,48\nstq $10,0($sp)\nstq $11,8($sp)\nstq $12,16($sp)\nstq $13,24($sp)\nstq $14,32($sp)\nstq $24,40($sp)\nstq $26,48($sp)\nmov $16,$14\n.prologue 1\nmov $31,$10\nstl $31,-996+1072($sp)\nlda $12,L.44\nlda $11,60($14)\nL.46:\nL.47:\nmov $11,$27\nlda $11,1($27)\nmov $12,$25\nlda $12,1($25)\nldb $25,($25)\nstb $25,($27)\nsll $25,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbeq $23,L.46\nbr L.49\nlda $10,1($10)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.51\nlda $16,L.43\nlda $17,1\njsr $26,printf\nldgp $gp,0($26)\nL.51:\nL.49:\nbr L.53\nlda $10,2($10)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.55\nlda $16,L.43\nlda $17,2\njsr $26,printf\nldgp $gp,0($26)\nL.55:\nL.53:\nlda $10,4($10)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.59\nlda $16,L.43\nlda $17,4\njsr $26,printf\nldgp $gp,0($26)\nL.59:\nL.57:\nbr L.61\nlda $10,8($10)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.63\nlda $16,L.43\nlda $17,8\njsr $26,printf\nldgp $gp,0($26)\nL.63:\nL.61:\nmov $31,$13\nL.65:\nsll $13,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,3,$25\nstq $27,L.45($25)\nL.66:\nlda $13,1($13)\ncmplt $13,17,$23\nbne $23,L.65\nlda $13,18\nL.69:\nsll $13,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,3,$27\nlda $27,L.45($27)\nstq $27,-1008+1072($sp)\nldq $16,($27)\njsr $26,pow2\nldgp $gp,0($26)\nldq $25,-1008+1072($sp)\nstq $0,($25)\nsubl $13,1,$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,3,$27\nsll $13,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,3,$25\nldq $25,L.45($25)\nsubq $25,1,$25\nstq $25,L.45($27)\nlda $13,2($13)\nL.70:\ncmplt $13,39,$23\nbne $23,L.69\nstq $31,-368+1072($sp)\nstq $31,-680+1072($sp)\nstq $31,-992+1072($sp)\nlda $27,1\nstq $27,-360+1072($sp)\nlda $27,1\nstq $27,-672+1072($sp)\nlda $27,1\nstq $27,-984+1072($sp)\nlda $27,2\nstq $27,-352+1072($sp)\nlda $27,2\nstq $27,-664+1072($sp)\nlda $27,2\nstq $27,-976+1072($sp)\nlda $27,3\nstq $27,-344+1072($sp)\nlda $27,3\nstq $27,-656+1072($sp)\nlda $27,3\nstq $27,-968+1072($sp)\nlda $27,4\nstq $27,-336+1072($sp)\nlda $27,4\nstq $27,-648+1072($sp)\nlda $27,4\nstq $27,-960+1072($sp)\nlda $27,5\nstq $27,-328+1072($sp)\nlda $27,5\nstq $27,-640+1072($sp)\nlda $27,5\nstq $27,-952+1072($sp)\nlda $27,6\nstq $27,-320+1072($sp)\nlda $27,6\nstq $27,-632+1072($sp)\nlda $27,6\nstq $27,-944+1072($sp)\nlda $27,7\nstq $27,-312+1072($sp)\nlda $27,7\nstq $27,-624+1072($sp)\nlda $27,7\nstq $27,-936+1072($sp)\nlda $27,8\nstq $27,-304+1072($sp)\nlda $27,8\nstq $27,-616+1072($sp)\nlda $27,8\nstq $27,-928+1072($sp)\nlda $27,9\nstq $27,-296+1072($sp)\nlda $27,9\nstq $27,-608+1072($sp)\nlda $27,9\nstq $27,-920+1072($sp)\nlda $27,10\nstq $27,-288+1072($sp)\nlda $27,10\nstq $27,-600+1072($sp)\nlda $27,10\nstq $27,-912+1072($sp)\nlda $27,11\nstq $27,-280+1072($sp)\nlda $27,11\nstq $27,-592+1072($sp)\nlda $27,11\nstq $27,-904+1072($sp)\nlda $27,12\nstq $27,-272+1072($sp)\nlda $27,12\nstq $27,-584+1072($sp)\nlda $27,12\nstq $27,-896+1072($sp)\nlda $27,13\nstq $27,-264+1072($sp)\nlda $27,13\nstq $27,-576+1072($sp)\nlda $27,13\nstq $27,-888+1072($sp)\nlda $27,14\nstq $27,-256+1072($sp)\nlda $27,14\nstq $27,-568+1072($sp)\nlda $27,14\nstq $27,-880+1072($sp)\nlda $27,15\nstq $27,-248+1072($sp)\nlda $27,15\nstq $27,-560+1072($sp)\nlda $27,15\nstq $27,-872+1072($sp)\nlda $27,16\nstq $27,-240+1072($sp)\nlda $27,16\nstq $27,-552+1072($sp)\nlda $27,16\nstq $27,-864+1072($sp)\nlda $27,63\nstq $27,-232+1072($sp)\nlda $27,63\nstq $27,-544+1072($sp)\nlda $27,63\nstq $27,-856+1072($sp)\nlda $27,64\nstq $27,-224+1072($sp)\nlda $27,64\nstq $27,-536+1072($sp)\nlda $27,64\nstq $27,-848+1072($sp)\nlda $27,255\nstq $27,-216+1072($sp)\nlda $27,255\nstq $27,-528+1072($sp)\nlda $27,255\nstq $27,-840+1072($sp)\nlda $27,256\nstq $27,-208+1072($sp)\nlda $27,256\nstq $27,-520+1072($sp)\nlda $27,256\nstq $27,-832+1072($sp)\nlda $27,4095\nstq $27,-200+1072($sp)\nlda $27,4095\nstq $27,-512+1072($sp)\nlda $27,4095\nstq $27,-824+1072($sp)\nlda $27,4096\nstq $27,-192+1072($sp)\nlda $27,4096\nstq $27,-504+1072($sp)\nlda $27,4096\nstq $27,-816+1072($sp)\nlda $27,65535\nstq $27,-184+1072($sp)\nlda $27,65535\nstq $27,-496+1072($sp)\nlda $27,65535\nstq $27,-808+1072($sp)\nlda $27,65536\nstq $27,-176+1072($sp)\nlda $27,65536\nstq $27,-488+1072($sp)\nlda $27,65536\nstq $27,-800+1072($sp)\nlda $27,262143\nstq $27,-168+1072($sp)\nlda $27,262143\nstq $27,-480+1072($sp)\nlda $27,262143\nstq $27,-792+1072($sp)\nlda $27,262144\nstq $27,-160+1072($sp)\nlda $27,262144\nstq $27,-472+1072($sp)\nlda $27,262144\nstq $27,-784+1072($sp)\nlda $27,1048575\nstq $27,-152+1072($sp)\nlda $27,1048575\nstq $27,-464+1072($sp)\nlda $27,1048575\nstq $27,-776+1072($sp)\nlda $27,1048576\nstq $27,-144+1072($sp)\nlda $27,1048576\nstq $27,-456+1072($sp)\nlda $27,1048576\nstq $27,-768+1072($sp)\nlda $27,16777215\nstq $27,-136+1072($sp)\nlda $27,16777215\nstq $27,-448+1072($sp)\nlda $27,16777215\nstq $27,-760+1072($sp)\nlda $27,16777216\nstq $27,-128+1072($sp)\nlda $27,16777216\nstq $27,-440+1072($sp)\nlda $27,16777216\nstq $27,-752+1072($sp)\nlda $27,268435455\nstq $27,-120+1072($sp)\nlda $27,268435455\nstq $27,-432+1072($sp)\nlda $27,268435455\nstq $27,-744+1072($sp)\nlda $27,268435456\nstq $27,-112+1072($sp)\nlda $27,268435456\nstq $27,-424+1072($sp)\nlda $27,268435456\nstq $27,-736+1072($sp)\nlda $27,1073741823\nstq $27,-104+1072($sp)\nlda $27,1073741823\nstq $27,-416+1072($sp)\nlda $27,1073741823\nstq $27,-728+1072($sp)\nlda $27,1073741824\nstq $27,-96+1072($sp)\nlda $27,1073741824\nstq $27,-408+1072($sp)\nlda $27,1073741824\nstq $27,-720+1072($sp)\nlda $27,4294967295\nstq $27,-88+1072($sp)\nlda $27,4294967295\nstq $27,-400+1072($sp)\nlda $27,4294967295\nstq $27,-712+1072($sp)\nlda $27,4294967296\nstq $27,-80+1072($sp)\nlda $27,4294967296\nstq $27,-392+1072($sp)\nlda $27,4294967296\nstq $27,-704+1072($sp)\nlda $27,68719476735\nstq $27,-72+1072($sp)\nlda $27,68719476735\nstq $27,-384+1072($sp)\nlda $27,68719476735\nstq $27,-696+1072($sp)\nlda $27,68719476736\nstq $27,-64+1072($sp)\nlda $27,68719476736\nstq $27,-376+1072($sp)\nlda $27,68719476736\nstq $27,-688+1072($sp)\nmov $31,$13\nL.187:\nsll $13,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,3,$27\nlda $25,-368+1072($sp)\naddq $27,$25,$25\nldq $25,($25)\nldq $22,L.45($27)\ncmpeq $22,$25,$23\nbeq $23,L.194\nlda $22,-680+1072($sp)\naddq $27,$22,$22\nldq $22,($22)\ncmpeq $25,$22,$23\nbeq $23,L.194\nlda $25,-992+1072($sp)\naddq $27,$25,$27\nldq $27,($27)\ncmpeq $22,$27,$23\nbne $23,L.191\nL.194:\nldl $27,40($14)\ncmpeq $27,$31,$23\nbne $23,L.195\nlda $16,L.197\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.198\njsr $26,printf\nldgp $gp,0($26)\nL.195:\nL.191:\nL.188:\nlda $13,1($13)\ncmplt $13,39,$23\nbne $23,L.187\nldl $27,-996+1072($sp)\ncmpeq $27,$31,$23\nbne $23,L.199\nlda $10,16\nL.199:\nmov $10,$0\nL.42:\nldq $10,0($sp)\nldq $11,8($sp)\nldq $12,16($sp)\nldq $13,24($sp)\nldq $14,32($sp)\nldq $24,40($sp)\nldq $26,48($sp)\nlda $sp,1072($sp)\nret\n.end s241\n.globl pow2\n.text\n.ent pow2\npow2:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4004000,-72\n.frame $sp,80,$26,48\nstq $14,0($sp)\nstq $26,8($sp)\n.prologue 1\nlda $14,1\nbr L.203\nL.202:\nsll $14,1,$14\nL.203:\nmov $16,$27\nsubq $27,1,$16\ncmpeq $27,$31,$23\nbeq $23,L.202\nmov $14,$0\nL.201:\nldq $14,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end pow2\n.sdata\n.align 0\nL.206:\n.byte 115\n.byte 50\n.byte 52\n.byte 51\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.207:\n.byte 115\n.byte 50\n.byte 52\n.byte 51\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s243\n.text\n.text\n.ent s243\ns243:\nldgp $gp,0($27)\nlda $sp,-352($sp)\n.mask 0x5007000,-320\n.frame $sp,352,$26,48\nstq $12,0($sp)\nstq $13,8($sp)\nstq $14,16($sp)\nstq $24,24($sp)\nstq $26,32($sp)\nstq $16,304($sp)\n.prologue 1\nmov $31,$12\nlda $14,L.207\nldq $27,-48+352($sp)\nlda $13,60($27)\nL.208:\nL.209:\nmov $13,$27\nlda $13,1($27)\nmov $14,$25\nlda $14,1($25)\nldb $25,($25)\nstb $25,($27)\nsll $25,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbeq $23,L.208\nlda $16,-312+352($sp)\njsr $26,zerofill\nldgp $gp,0($26)\nlda $27,1\nstb $27,-215+352($sp)\nlda $27,1\nstb $27,-247+352($sp)\nlda $27,1\nstb $27,-186+352($sp)\nlda $27,1\nstb $27,-264+352($sp)\nlda $27,1\nstb $27,-214+352($sp)\nlda $27,1\nstb $27,-246+352($sp)\nlda $27,1\nstb $27,-279+352($sp)\nlda $27,1\nstb $27,-263+352($sp)\nlda $27,1\nstb $27,-213+352($sp)\nlda $27,1\nstb $27,-245+352($sp)\nlda $27,1\nstb $27,-278+352($sp)\nlda $27,1\nstb $27,-262+352($sp)\nlda $27,1\nstb $27,-212+352($sp)\nlda $27,1\nstb $27,-244+352($sp)\nlda $27,1\nstb $27,-277+352($sp)\nlda $27,1\nstb $27,-261+352($sp)\nlda $27,1\nstb $27,-211+352($sp)\nlda $27,1\nstb $27,-243+352($sp)\nlda $27,1\nstb $27,-275+352($sp)\nlda $27,1\nstb $27,-260+352($sp)\nlda $27,1\nstb $27,-210+352($sp)\nlda $27,1\nstb $27,-242+352($sp)\nlda $27,1\nstb $27,-274+352($sp)\nlda $27,1\nstb $27,-259+352($sp)\nlda $27,1\nstb $27,-209+352($sp)\nlda $27,1\nstb $27,-241+352($sp)\nlda $27,1\nstb $27,-272+352($sp)\nlda $27,1\nstb $27,-258+352($sp)\nlda $27,1\nstb $27,-208+352($sp)\nlda $27,1\nstb $27,-240+352($sp)\nlda $27,1\nstb $27,-271+352($sp)\nlda $27,1\nstb $27,-257+352($sp)\nlda $27,1\nstb $27,-207+352($sp)\nlda $27,1\nstb $27,-239+352($sp)\nlda $27,1\nstb $27,-217+352($sp)\nlda $27,1\nstb $27,-256+352($sp)\nlda $27,1\nstb $27,-206+352($sp)\nlda $27,1\nstb $27,-238+352($sp)\nlda $27,1\nstb $27,-251+352($sp)\nlda $27,1\nstb $27,-255+352($sp)\nlda $27,1\nstb $27,-205+352($sp)\nlda $27,1\nstb $27,-237+352($sp)\nlda $27,1\nstb $27,-267+352($sp)\nlda $27,1\nstb $27,-204+352($sp)\nlda $27,1\nstb $27,-236+352($sp)\nlda $27,1\nstb $27,-218+352($sp)\nlda $27,1\nstb $27,-203+352($sp)\nlda $27,1\nstb $27,-235+352($sp)\nlda $27,1\nstb $27,-188+352($sp)\nlda $27,1\nstb $27,-302+352($sp)\nlda $27,1\nstb $27,-202+352($sp)\nlda $27,1\nstb $27,-234+352($sp)\nlda $27,1\nstb $27,-303+352($sp)\nlda $27,1\nstb $27,-201+352($sp)\nlda $27,1\nstb $27,-233+352($sp)\nlda $27,1\nstb $27,-189+352($sp)\nlda $27,1\nstb $27,-304+352($sp)\nlda $27,1\nstb $27,-200+352($sp)\nlda $27,1\nstb $27,-232+352($sp)\nlda $27,1\nstb $27,-187+352($sp)\nlda $27,1\nstb $27,-299+352($sp)\nlda $27,1\nstb $27,-199+352($sp)\nlda $27,1\nstb $27,-231+352($sp)\nlda $27,1\nstb $27,-221+352($sp)\nlda $27,1\nstb $27,-300+352($sp)\nlda $27,1\nstb $27,-198+352($sp)\nlda $27,1\nstb $27,-230+352($sp)\nlda $27,1\nstb $27,-219+352($sp)\nlda $27,1\nstb $27,-197+352($sp)\nlda $27,1\nstb $27,-229+352($sp)\nlda $27,1\nstb $27,-269+352($sp)\nlda $27,1\nstb $27,-220+352($sp)\nlda $27,1\nstb $27,-196+352($sp)\nlda $27,1\nstb $27,-228+352($sp)\nlda $27,1\nstb $27,-253+352($sp)\nlda $27,1\nstb $27,-273+352($sp)\nlda $27,1\nstb $27,-195+352($sp)\nlda $27,1\nstb $27,-227+352($sp)\nlda $27,1\nstb $27,-270+352($sp)\nlda $27,1\nstb $27,-194+352($sp)\nlda $27,1\nstb $27,-226+352($sp)\nlda $27,1\nstb $27,-254+352($sp)\nlda $27,1\nstb $27,-312+352($sp)\nstb $27,-193+352($sp)\nlda $27,1\nstb $27,-225+352($sp)\nlda $27,1\nstb $27,-252+352($sp)\nlda $27,1\nstb $27,-280+352($sp)\nlda $27,1\nstb $27,-192+352($sp)\nlda $27,1\nstb $27,-224+352($sp)\nlda $27,1\nstb $27,-250+352($sp)\nlda $27,1\nstb $27,-191+352($sp)\nlda $27,1\nstb $27,-223+352($sp)\nlda $27,1\nstb $27,-268+352($sp)\nlda $27,1\nstb $27,-190+352($sp)\nlda $27,1\nstb $27,-222+352($sp)\nlda $27,1\nstb $27,-266+352($sp)\nlda $27,1\nstb $27,-249+352($sp)\nlda $27,1\nstb $27,-265+352($sp)\nlda $16,-312+352($sp)\njsr $26,sumof\nldgp $gp,0($26)\nlda $25,98\ncmpeq $0,$25,$23\nbne $23,L.308\nlda $12,1($12)\nldq $27,-48+352($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.310\nlda $16,L.206\nlda $17,1\njsr $26,printf\nldgp $gp,0($26)\nL.310:\nL.308:\nbr L.312\nlda $12,8($12)\nldq $27,-48+352($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.314\nlda $16,L.206\nlda $17,8\njsr $26,printf\nldgp $gp,0($26)\nL.314:\nL.312:\nmov $12,$0\nL.205:\nldq $12,0($sp)\nldq $13,8($sp)\nldq $14,16($sp)\nldq $24,24($sp)\nldq $26,32($sp)\nlda $sp,352($sp)\nret\n.end s243\n.globl zerofill\n.text\n.ent zerofill\nzerofill:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x5004000,-64\n.frame $sp,80,$26,48\nstq $14,0($sp)\nstq $24,8($sp)\nstq $26,16($sp)\n.prologue 1\nmov $31,$14\nL.317:\nmov $16,$27\nlda $16,1($27)\nstb $31,($27)\nL.318:\nlda $14,1($14)\nlda $27,256\ncmplt $14,$27,$23\nbne $23,L.317\nmov $31,$0\nL.316:\nldq $14,0($sp)\nldq $24,8($sp)\nldq $26,16($sp)\nlda $sp,80($sp)\nret\n.end zerofill\n.globl sumof\n.text\n.ent sumof\nsumof:\nldgp $gp,0($27)\nlda $sp,-96($sp)\n.mask 0x4007000,-72\n.frame $sp,96,$26,48\nstq $12,0($sp)\nstq $13,8($sp)\nstq $14,16($sp)\nstq $26,24($sp)\n.prologue 1\nmov $16,$12\nmov $31,$14\nmov $31,$13\nL.322:\nmov $12,$27\nlda $12,1($27)\nldb $27,($27)\naddl $14,$27,$14\nL.323:\nlda $13,1($13)\nlda $27,256\ncmplt $13,$27,$23\nbne $23,L.322\nmov $14,$0\nL.321:\nldq $12,0($sp)\nldq $13,8($sp)\nldq $14,16($sp)\nldq $26,24($sp)\nlda $sp,96($sp)\nret\n.end sumof\n.sdata\n.align 0\nL.327:\n.byte 115\n.byte 50\n.byte 52\n.byte 52\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.328:\n.byte 115\n.byte 50\n.byte 52\n.byte 52\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s244\n.text\n.text\n.ent s244\ns244:\nldgp $gp,0($27)\nlda $sp,-176($sp)\n.mask 0x5007c00,-128\n.frame $sp,176,$26,48\nstq $10,0($sp)\nstq $11,8($sp)\nstq $12,16($sp)\nstq $13,24($sp)\nstq $14,32($sp)\nstq $24,40($sp)\nstq $26,48($sp)\nstq $16,128($sp)\n.prologue 1\nlda $13,L.328\nldq $27,-48+176($sp)\nlda $12,60($27)\nL.329:\nL.330:\nmov $12,$27\nlda $12,1($27)\nmov $13,$25\nlda $13,1($25)\nldb $25,($25)\nstb $25,($27)\nsll $25,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbeq $23,L.329\nmov $31,$10\nmov $31,$11\nldt $f30,L.332\nstt $f30,-120+176($sp)\nstt $f30,-112+176($sp)\nldt $f30,L.332\nstt $f30,-104+176($sp)\nldt $f30,L.332\nstt $f30,-96+176($sp)\nldt $f30,L.332\nstt $f30,-88+176($sp)\nldt $f30,L.332\nstt $f30,-80+176($sp)\nldt $f30,L.332\nstt $f30,-72+176($sp)\nldt $f30,L.332\nstt $f30,-64+176($sp)\nmov $31,$11\nmov $31,$14\nL.340:\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,3,$27\nlda $25,-120+176($sp)\naddq $27,$25,$27\nldt $f30,($27)\nlda $27,1($14)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,3,$27\nlda $25,-120+176($sp)\naddq $27,$25,$27\nldt $f29,($27)\ncmpteq $f30,$f29,$f1\nfbne $f1,L.344\nlda $11,1\nL.344:\nL.341:\nlda $14,1($14)\ncmplt $14,7,$23\nbne $23,L.340\ncmpeq $11,$31,$23\nbne $23,L.346\nldq $27,-48+176($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.348\nlda $16,L.327\nlda $17,1\njsr $26,printf\nldgp $gp,0($26)\nL.348:\nlda $10,1($10)\nL.346:\nbr L.350\nldq $27,-48+176($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.352\nlda $16,L.327\nlda $17,2\njsr $26,printf\nldgp $gp,0($26)\nL.352:\nlda $10,2($10)\nL.350:\nmov $10,$0\nL.326:\nldq $10,0($sp)\nldq $11,8($sp)\nldq $12,16($sp)\nldq $13,24($sp)\nldq $14,32($sp)\nldq $24,40($sp)\nldq $26,48($sp)\nlda $sp,176($sp)\nret\n.end s244\n.sdata\n.align 0\nL.355:\n.byte 115\n.byte 50\n.byte 53\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.356:\n.byte 115\n.byte 50\n.byte 53\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s25\n.text\n.text\n.ent s25\ns25:\nldgp $gp,0($27)\nlda $sp,-128($sp)\n.mask 0x5007e00,-72\n.frame $sp,128,$26,48\nstq $9,0($sp)\nstq $10,8($sp)\nstq $11,16($sp)\nstq $12,24($sp)\nstq $13,32($sp)\nstq $14,40($sp)\nstq $24,48($sp)\nstq $26,56($sp)\nmov $16,$14\n.prologue 1\nlda $10,L.356\nlda $9,60($14)\nL.357:\nL.358:\nmov $9,$27\nlda $9,1($27)\nmov $10,$25\nlda $10,1($25)\nldb $25,($25)\nstb $25,($27)\nsll $25,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbeq $23,L.357\nstl $31,-60+128($sp)\nlda $12,L.360\nlda $27,1($12)\nldb $27,($27)\nldb $25,($12)\ncmpeq $25,$27,$23\nbeq $23,L.364\nlda $25,2($12)\nldb $25,($25)\ncmpeq $27,$25,$23\nbeq $23,L.364\ncmpeq $25,46,$23\nbne $23,L.361\nL.364:\nldl $27,-60+128($sp)\nlda $27,1($27)\nstl $27,-60+128($sp)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.365\nlda $16,L.355\nlda $17,1\njsr $26,printf\nldgp $gp,0($26)\nL.365:\nL.361:\nlda $27,3($12)\nldb $27,($27)\ncmpeq $27,$31,$23\nbne $23,L.367\nldl $27,-60+128($sp)\nlda $27,4($27)\nstl $27,-60+128($sp)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.369\nlda $16,L.355\nlda $17,4\njsr $26,printf\nldgp $gp,0($26)\nL.369:\nL.367:\nlda $27,L.373+1\nldb $27,($27)\ncmpeq $27,34,$23\nbne $23,L.371\nldl $27,-60+128($sp)\nlda $27,8($27)\nstl $27,-60+128($sp)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.375\nlda $16,L.355\nlda $17,8\njsr $26,printf\nldgp $gp,0($26)\nL.375:\nL.371:\nlda $12,L.377\nldb $27,($12)\ncmpeq $27,10,$23\nbeq $23,L.385\nlda $27,1($12)\nldb $27,($27)\ncmpeq $27,9,$23\nbeq $23,L.385\nlda $27,2($12)\nldb $27,($27)\ncmpeq $27,8,$23\nbeq $23,L.385\nlda $27,3($12)\nldb $27,($27)\ncmpeq $27,13,$23\nbeq $23,L.385\nlda $27,4($12)\nldb $27,($27)\ncmpeq $27,12,$23\nbeq $23,L.385\nlda $27,5($12)\nldb $27,($27)\nlda $25,92\ncmpeq $27,$25,$23\nbeq $23,L.385\nlda $27,6($12)\nldb $27,($27)\ncmpeq $27,39,$23\nbne $23,L.378\nL.385:\nldl $27,-60+128($sp)\nlda $27,16($27)\nstl $27,-60+128($sp)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.386\nlda $16,L.355\nlda $17,16\njsr $26,printf\nldgp $gp,0($26)\nL.386:\nL.378:\nlda $27,L.388\nmov $27,$11\nmov $27,$12\nstl $31,-64+128($sp)\nmov $31,$13\nbr L.392\nL.389:\naddq $13,$12,$27\nldb $27,($27)\naddq $13,$11,$25\nldb $25,($25)\ncmpeq $27,$25,$23\nbne $23,L.393\nlda $27,1\nstl $27,-64+128($sp)\nL.393:\nL.390:\nlda $13,1($13)\nL.392:\nmov $13,$27\nlda $25,7\ncmpult $27,$25,$23\nbne $23,L.389\nldl $27,-64+128($sp)\ncmpeq $27,$31,$23\nbne $23,L.395\nldl $27,-60+128($sp)\nlda $27,32($27)\nstl $27,-60+128($sp)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.397\nlda $16,L.355\nlda $17,32\njsr $26,printf\nldgp $gp,0($26)\nL.397:\nL.395:\nldl $0,-60+128($sp)\nL.354:\nldq $9,0($sp)\nldq $10,8($sp)\nldq $11,16($sp)\nldq $12,24($sp)\nldq $13,32($sp)\nldq $14,40($sp)\nldq $24,48($sp)\nldq $26,56($sp)\nlda $sp,128($sp)\nret\n.end s25\n.sdata\n.align 0\nL.400:\n.byte 115\n.byte 50\n.byte 54\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.align 0\nL.401:\n.byte 37\n.byte 51\n.byte 100\n.byte 32\n.byte 98\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 37\n.byte 115\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.402:\n.byte 37\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 108\n.byte 101\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 97\n.byte 100\n.byte 100\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 49\n.byte 46\n.byte 32\n.byte 40\n.byte 37\n.byte 115\n.byte 41\n.byte 46\n.byte 10\n.byte 0\n.globl s26\n.text\n.text\n.ent s26\ns26:\nldgp $gp,0($27)\nlda $sp,-160($sp)\n.fmask 0x3e0,-128\n.mask 0x5007c00,-72\n.frame $sp,160,$26,48\nstt $f5,0($sp)\nstt $f6,8($sp)\nstt $f7,16($sp)\nstt $f8,24($sp)\nstt $f9,32($sp)\nstq $10,40($sp)\nstq $11,48($sp)\nstq $12,56($sp)\nstq $13,64($sp)\nstq $14,72($sp)\nstq $24,80($sp)\nstq $26,88($sp)\nmov $16,$14\n.prologue 1\nlda $12,L.400\nlda $11,60($14)\nL.403:\nL.404:\nmov $11,$27\nlda $11,1($27)\nmov $12,$25\nlda $12,1($25)\nldb $25,($25)\nstb $25,($27)\nsll $25,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbeq $23,L.403\nstl $31,($14)\nmov $31,$10\nlda $13,1\nbr L.407\nL.406:\nsll $13,8*(8-1),$27\nsra $27,8*(8-1),$27\nsll $27,1,$27\naddl $27,0,$27\nmov $27,$13\nldl $27,($14)\nlda $27,1($27)\nstl $27,($14)\nL.407:\nsll $10,8*(8-1),$27\nsra $27,8*(8-1),$27\nsll $13,8*(8-1),$25\nsra $25,8*(8-1),$25\ncmpeq $27,$25,$23\nbeq $23,L.406\nldl $27,($14)\nsll $27,2,$27\nstl $27,4($14)\nldl $27,($14)\nsll $27,1,$27\nstl $27,8($14)\nldl $27,($14)\nsll $27,3,$27\nstl $27,12($14)\nldl $27,($14)\nsll $27,2,$27\nstl $27,16($14)\nldl $27,($14)\nsll $27,2,$27\nstl $27,20($14)\nldl $27,($14)\nsll $27,3,$27\nstl $27,24($14)\nlds $f30,L.409\nfmov $f30,$f7\nfmov $f30,$f9\nlds $f8,L.410\nbr L.412\nL.411:\nadds $f7,$f9,$f8\ncvtst $f9,$f30\nldt $f29,L.414\ndivt $f30,$f29,$f30\ncvtts $f30,$f9\nL.412:\ncmpteq $f8,$f7,$f1\nfbeq $f1,L.411\nldt $f30,L.415\ncvtst $f9,$f29\nmult $f30,$f29,$f30\ncvtts $f30,$f30\nsts $f30,28($14)\nldt $f5,L.416\nlds $f9,L.409\nldt $f6,L.417\nbr L.419\nL.418:\ncvtst $f9,$f30\naddt $f5,$f30,$f6\nldt $f29,L.414\ndivt $f30,$f29,$f30\ncvtts $f30,$f9\nL.419:\ncmpteq $f6,$f5,$f1\nfbeq $f1,L.418\nldt $f30,L.415\ncvtst $f9,$f29\nmult $f30,$f29,$f30\ncvtts $f30,$f30\nsts $f30,32($14)\nldl $27,40($14)\ncmpeq $27,$31,$23\nbne $23,L.421\nlda $16,L.401\nldl $17,($14)\nlda $18,L.423\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.401\nldl $17,4($14)\nlda $18,L.424\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.401\nldl $17,8($14)\nlda $18,L.425\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.401\nldl $17,12($14)\nlda $18,L.426\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.401\nldl $17,16($14)\nlda $18,L.427\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.401\nldl $17,20($14)\nlda $18,L.428\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.401\nldl $17,24($14)\nlda $18,L.429\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.402\nlds $f30,28($14)\ncvtst $f30,$f17\nlda $18,L.428\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.402\nlds $f30,32($14)\ncvtst $f30,$f17\nlda $18,L.429\njsr $26,printf\nldgp $gp,0($26)\nL.421:\nmov $31,$0\nL.399:\nldt $f5,0($sp)\nldt $f6,8($sp)\nldt $f7,16($sp)\nldt $f8,24($sp)\nldt $f9,32($sp)\nldq $10,40($sp)\nldq $11,48($sp)\nldq $12,56($sp)\nldq $13,64($sp)\nldq $14,72($sp)\nldq $24,80($sp)\nldq $26,88($sp)\nlda $sp,160($sp)\nret\n.end s26\n.sdata\n.align 0\nL.431:\n.byte 115\n.byte 52\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.432:\n.byte 115\n.byte 52\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s4\n.text\n.text\n.ent s4\ns4:\nldgp $gp,0($27)\nlda $sp,-160($sp)\n.mask 0x5007e00,-104\n.frame $sp,160,$26,48\nstq $9,0($sp)\nstq $10,8($sp)\nstq $11,16($sp)\nstq $12,24($sp)\nstq $13,32($sp)\nstq $14,40($sp)\nstq $24,48($sp)\nstq $26,56($sp)\nmov $16,$14\n.prologue 1\nstl $31,-60+160($sp)\nlda $10,L.432\nlda $9,60($14)\nL.433:\nL.434:\nmov $9,$27\nlda $9,1($27)\nmov $10,$25\nlda $10,1($25)\nldb $25,($25)\nstb $25,($27)\nsll $25,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbeq $23,L.433\nmov $31,$13\nL.436:\nmov $13,$16\njsr $26,svtest\nldgp $gp,0($26)\nmov $0,$27\nstl $27,-84+160($sp)\njsr $26,zero\nldgp $gp,0($26)\nldl $25,-84+160($sp)\ncmpeq $25,$0,$23\nbne $23,L.440\nlda $27,1\nstl $27,-60+160($sp)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.442\nlda $16,L.431\nlda $17,1\njsr $26,printf\nldgp $gp,0($26)\nL.442:\nL.440:\nL.437:\nlda $13,1($13)\ncmplt $13,3,$23\nbne $23,L.436\njsr $26,setev\nldgp $gp,0($26)\njsr $26,testev\nldgp $gp,0($26)\ncmpeq $0,$31,$23\nbne $23,L.444\nldl $27,-60+160($sp)\nlda $27,2($27)\nstl $27,-60+160($sp)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.446\nlda $16,L.431\nlda $17,2\njsr $26,printf\nldgp $gp,0($26)\nL.446:\nL.444:\nbr L.448\nldl $27,-60+160($sp)\nlda $27,4($27)\nstl $27,-60+160($sp)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.450\nlda $16,L.431\nlda $17,4\njsr $26,printf\nldgp $gp,0($26)\nL.450:\nL.448:\nlda $12,0xffffffff\nlda $11,1\nmov $31,$13\nbr L.455\nL.452:\nand $11,$12,$11\nsrl $12,1,$12\nL.453:\nlda $13,1($13)\nL.455:\nmov $13,$27\nldl $25,($14)\nsll $25,2,$25\ncmpult $27,$25,$23\nbne $23,L.452\nlda $27,1\ncmpeq $11,$27,$23\nbeq $23,L.458\ncmpeq $12,$31,$23\nbne $23,L.456\nL.458:\nldl $27,-60+160($sp)\nlda $27,8($27)\nstl $27,-60+160($sp)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.459\nlda $16,L.431\nlda $17,8\njsr $26,printf\nldgp $gp,0($26)\nL.459:\nL.456:\nldl $0,-60+160($sp)\nL.430:\nldq $9,0($sp)\nldq $10,8($sp)\nldq $11,16($sp)\nldq $12,24($sp)\nldq $13,32($sp)\nldq $14,40($sp)\nldq $24,48($sp)\nldq $26,56($sp)\nlda $sp,160($sp)\nret\n.end s4\n.lcomm L.462,4\n.globl svtest\n.text\n.text\n.ent svtest\nsvtest:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.frame $sp,64,$26,48\n.prologue 1\ncmpeq $16,$31,$23\nbne $23,L.465\ncmpeq $16,1,$23\nbne $23,L.466\ncmpeq $16,2,$23\nbne $23,L.469\nbr L.463\nL.465:\nlda $27,1978\nstl $27,L.462\nstl $31,-60+64($sp)\nbr L.464\nL.466:\nldl $27,L.462\nlda $25,1978\ncmpeq $27,$25,$23\nbne $23,L.467\nlda $27,1\nstl $27,-60+64($sp)\nbr L.464\nL.467:\nlda $27,1929\nstl $27,L.462\nstl $31,-60+64($sp)\nbr L.464\nL.469:\nldl $27,L.462\nlda $25,1929\ncmpeq $27,$25,$23\nbne $23,L.470\nlda $27,1\nstl $27,-60+64($sp)\nbr L.464\nL.470:\nstl $31,-60+64($sp)\nL.463:\nL.464:\nldl $0,-60+64($sp)\nL.461:\nlda $sp,64($sp)\nret\n.end svtest\n.lcomm L.473,4\n.globl zero\n.text\n.text\n.ent zero\nzero:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.frame $sp,64,$26,48\n.prologue 1\nlda $27,2\nstl $27,L.473\nstl $31,-60+64($sp)\nldl $0,-60+64($sp)\nL.472:\nlda $sp,64($sp)\nret\n.end zero\n.globl testev\n.text\n.ent testev\ntestev:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.frame $sp,64,$26,48\n.prologue 1\nldl $27,extvar\nlda $25,1066\ncmpeq $27,$25,$23\nbne $23,L.475\nlda $0,1\nbr L.474\nL.475:\nmov $31,$0\nL.474:\nlda $sp,64($sp)\nret\n.end testev\n.sdata\n.align 0\nL.478:\n.byte 115\n.byte 54\n.byte 49\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.479:\n.byte 115\n.byte 54\n.byte 49\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.align 0\nL.480:\n.byte 65\n.byte 66\n.byte 67\n.byte 68\n.byte 69\n.byte 70\n.byte 71\n.byte 72\n.byte 73\n.byte 74\n.byte 75\n.byte 76\n.byte 77\n.byte 78\n.byte 79\n.byte 80\n.byte 81\n.byte 82\n.byte 83\n.byte 84\n.byte 85\n.byte 86\n.byte 87\n.byte 88\n.byte 89\n.byte 90\n.byte 0\n.align 0\nL.481:\n.byte 97\n.byte 98\n.byte 99\n.byte 100\n.byte 101\n.byte 102\n.byte 103\n.byte 104\n.byte 105\n.byte 106\n.byte 107\n.byte 108\n.byte 109\n.byte 110\n.byte 111\n.byte 112\n.byte 113\n.byte 114\n.byte 115\n.byte 116\n.byte 117\n.byte 118\n.byte 119\n.byte 120\n.byte 121\n.byte 122\n.byte 0\n.align 0\nL.482:\n.byte 48\n.byte 49\n.byte 50\n.byte 51\n.byte 52\n.byte 53\n.byte 54\n.byte 55\n.byte 56\n.byte 57\n.byte 0\n.align 0\nL.483:\n.byte 126\n.byte 33\n.byte 34\n.byte 35\n.byte 37\n.byte 38\n.byte 40\n.byte 41\n.byte 95\n.byte 61\n.byte 45\n.byte 94\n.byte 124\n.byte 123\n.byte 125\n.byte 91\n.byte 93\n.byte 43\n.byte 59\n.byte 42\n.byte 58\n.byte 60\n.byte 62\n.byte 44\n.byte 46\n.byte 63\n.byte 47\n.byte 0\n.align 0\nL.484:\n.byte 10\n.byte 9\n.byte 8\n.byte 13\n.byte 12\n.byte 92\n.byte 39\n.byte 0\n.align 0\nL.485:\n.byte 32\n.byte 0\n.byte 0\n.globl s61\n.text\n.text\n.ent s61\ns61:\nldgp $gp,0($27)\nlda $sp,-192($sp)\n.mask 0x5007e00,-136\n.frame $sp,192,$26,48\nstq $9,0($sp)\nstq $10,8($sp)\nstq $11,16($sp)\nstq $12,24($sp)\nstq $13,32($sp)\nstq $14,40($sp)\nstq $24,48($sp)\nstq $26,56($sp)\nstq $16,144($sp)\n.prologue 1\nlda $12,L.479\nldq $27,-48+192($sp)\nlda $11,60($27)\nmov $31,$9\nL.486:\nL.487:\nmov $11,$27\nlda $11,1($27)\nmov $12,$25\nlda $12,1($25)\nldb $25,($25)\nstb $25,($27)\nsll $25,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbeq $23,L.486\nlda $27,-19\nstw $27,-110+192($sp)\nlda $27,-110+192($sp)\nldw $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nstq $27,-120+192($sp)\nldq $27,-120+192($sp)\nlda $25,-19\ncmpeq $27,$25,$23\nbne $23,L.489\nlda $9,1($9)\nldq $27,-48+192($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.491\nlda $16,L.478\nlda $17,1\njsr $26,printf\nldgp $gp,0($26)\nL.491:\nL.489:\nlda $27,L.480\nstq $27,-104+192($sp)\nlda $27,L.481\nstq $27,-96+192($sp)\nlda $27,L.482\nstq $27,-88+192($sp)\nlda $27,L.483\nstq $27,-80+192($sp)\nlda $27,L.484\nstq $27,-72+192($sp)\nlda $27,L.485\nstq $27,-64+192($sp)\nmov $31,$13\nmov $31,$14\nbr L.503\nL.502:\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,3,$27\nlda $25,-104+192($sp)\naddq $27,$25,$27\nldq $25,($27)\nlda $22,1($25)\nstq $22,($27)\nldb $27,($25)\ncmplt $27,$31,$23\nbeq $23,L.505\nlda $13,1\nL.505:\nL.503:\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,3,$27\nlda $25,-104+192($sp)\naddq $27,$25,$27\nldq $27,($27)\nldb $27,($27)\ncmpeq $27,$31,$23\nbeq $23,L.502\nL.499:\nlda $14,1($14)\ncmplt $14,6,$23\nbne $23,L.503\ncmpeq $13,$31,$23\nbne $23,L.507\nlda $9,2($9)\nldq $27,-48+192($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.509\nlda $16,L.478\nlda $17,2\njsr $26,printf\nldgp $gp,0($26)\nL.509:\nL.507:\nlda $10,1048579\nmov $10,$27\nstw $27,-106+192($sp)\nmov $10,$27\nstb $27,-107+192($sp)\nlda $27,-106+192($sp)\nldw $27,($27)\nsll $27,8*(8-4),$25\nsra $25,8*(8-4),$25\ncmpeq $25,$10,$23\nbne $23,L.514\ncmpeq $27,3,$23\nbeq $23,L.513\nL.514:\nlda $27,-107+192($sp)\nldb $27,($27)\nsll $27,8*(8-4),$25\nsra $25,8*(8-4),$25\ncmpeq $25,$10,$23\nbne $23,L.511\ncmpeq $27,3,$23\nbne $23,L.511\nL.513:\nlda $9,8($9)\nldq $27,-48+192($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.515\nlda $16,L.478\nlda $17,8\njsr $26,printf\nldgp $gp,0($26)\nL.515:\nL.511:\nmov $9,$0\nL.477:\nldq $9,0($sp)\nldq $10,8($sp)\nldq $11,16($sp)\nldq $12,24($sp)\nldq $13,32($sp)\nldq $14,40($sp)\nldq $24,48($sp)\nldq $26,56($sp)\nlda $sp,192($sp)\nret\n.end s61\n.sdata\n.align 0\nL.518:\n.byte 115\n.byte 54\n.byte 50\n.byte 54\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.519:\n.byte 115\n.byte 54\n.byte 50\n.byte 54\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s626\n.text\n.text\n.ent s626\ns626:\nldgp $gp,0($27)\nlda $sp,-240($sp)\n.fmask 0x3c0,-216\n.mask 0x5007e00,-152\n.frame $sp,240,$26,48\nstt $f6,0($sp)\nstt $f7,8($sp)\nstt $f8,16($sp)\nstt $f9,24($sp)\nstq $9,32($sp)\nstq $10,40($sp)\nstq $11,48($sp)\nstq $12,56($sp)\nstq $13,64($sp)\nstq $14,72($sp)\nstq $24,80($sp)\nstq $26,88($sp)\nmov $16,$14\n.prologue 1\nlda $10,L.519\nlda $9,60($14)\nstl $31,-128+240($sp)\nL.520:\nL.521:\nmov $9,$27\nlda $9,1($27)\nmov $10,$25\nlda $10,1($25)\nldb $25,($25)\nstb $25,($27)\nsll $25,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbeq $23,L.520\nlds $f9,L.409\nlda $27,1\nstq $27,-96+240($sp)\nmov $27,$12\nmov $31,$13\nbr L.526\nL.523:\nlds $f30,L.527\nmuls $f30,$f9,$f9\nsll $12,1,$27\nldq $25,-96+240($sp)\nor $27,$25,$12\nL.524:\nlda $13,1($13)\nL.526:\nldl $27,12($14)\nsubl $27,2,$27\ncmplt $13,$27,$23\nbne $23,L.523\nstq $12,-56+240($sp)\nldt $f30,-56+240($sp)\ncvtqs $f30,$f30\nsts $f30,-140+240($sp)\nlds $f30,-140+240($sp)\nsubs $f9,$f30,$f30\ndivs $f30,$f9,$f9\ncvtst $f9,$f30\nldt $f29,L.414\nlds $f28,28($14)\ncvtst $f28,$f28\nmult $f29,$f28,$f29\ncmptle $f30,$f29,$f1\nfbne $f1,L.528\nldl $27,-128+240($sp)\nlda $27,2($27)\nstl $27,-128+240($sp)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.530\nlda $16,L.518\nlda $17,2\njsr $26,printf\nldgp $gp,0($26)\nL.530:\nL.528:\nlda $27,125\nstb $27,-105+240($sp)\nlda $27,125\nstw $27,-108+240($sp)\nlda $27,125\nstl $27,-112+240($sp)\nlda $27,15625\nstl $27,-120+240($sp)\nlda $27,125\nstl $27,-116+240($sp)\nlda $27,15625\nstl $27,-124+240($sp)\nlda $27,125\nstq $27,-104+240($sp)\nlda $27,15625\nstq $27,-136+240($sp)\nlds $f7,L.532\nldt $f6,L.533\nldt $f8,L.534\nmov $31,$13\nL.535:\nlda $27,-84+240($sp)\naddq $13,$27,$27\nstb $31,($27)\nL.536:\nlda $13,1($13)\ncmplt $13,28,$23\nbne $23,L.535\nlda $27,-105+240($sp)\nldb $27,($27)\nmull $27,$27,$27\nldl $25,-120+240($sp)\ncmpeq $27,$25,$23\nbne $23,L.539\nlda $27,1\nstb $27,-84+240($sp)\nL.539:\nlda $27,-108+240($sp)\nldw $27,($27)\nlda $25,-105+240($sp)\nldb $25,($25)\nmull $27,$25,$27\nldl $25,-120+240($sp)\ncmpeq $27,$25,$23\nbne $23,L.541\nlda $27,1\nstb $27,-83+240($sp)\nL.541:\nlda $27,-108+240($sp)\nldw $27,($27)\nmull $27,$27,$27\nldl $25,-120+240($sp)\ncmpeq $27,$25,$23\nbne $23,L.544\nlda $27,1\nstb $27,-82+240($sp)\nL.544:\nldl $27,-112+240($sp)\nlda $25,-105+240($sp)\nldb $25,($25)\nmull $27,$25,$27\nldl $25,-120+240($sp)\ncmpeq $27,$25,$23\nbne $23,L.547\nlda $27,1\nstb $27,-81+240($sp)\nL.547:\nldl $27,-112+240($sp)\nlda $25,-108+240($sp)\nldw $25,($25)\nmull $27,$25,$27\nldl $25,-120+240($sp)\ncmpeq $27,$25,$23\nbne $23,L.550\nlda $27,1\nstb $27,-80+240($sp)\nL.550:\nldl $27,-112+240($sp)\nmull $27,$27,$27\nldl $25,-120+240($sp)\ncmpeq $27,$25,$23\nbne $23,L.553\nlda $27,1\nstb $27,-79+240($sp)\nL.553:\nldl $27,-116+240($sp)\nzap $27,240,$27\nlda $25,-105+240($sp)\nldb $25,($25)\nmull $27,$25,$27\nzap $27,240,$27\nldl $25,-124+240($sp)\nzap $25,240,$25\ncmpeq $27,$25,$23\nbne $23,L.556\nlda $27,1\nstb $27,-78+240($sp)\nL.556:\nldl $27,-116+240($sp)\nzap $27,240,$27\nlda $25,-108+240($sp)\nldw $25,($25)\nmull $27,$25,$27\nzap $27,240,$27\nldl $25,-124+240($sp)\nzap $25,240,$25\ncmpeq $27,$25,$23\nbne $23,L.559\nlda $27,1\nstb $27,-77+240($sp)\nL.559:\nldl $27,-116+240($sp)\nzap $27,240,$27\nldl $25,-112+240($sp)\nmull $27,$25,$27\nzap $27,240,$27\nldl $25,-124+240($sp)\nzap $25,240,$25\ncmpeq $27,$25,$23\nbne $23,L.562\nlda $27,1\nstb $27,-76+240($sp)\nL.562:\nldl $27,-116+240($sp)\nzap $27,240,$27\nmull $27,$27,$27\nzap $27,240,$27\nldl $25,-124+240($sp)\nzap $25,240,$25\ncmpeq $27,$25,$23\nbne $23,L.565\nlda $27,1\nstb $27,-75+240($sp)\nL.565:\nldq $27,-104+240($sp)\nlda $25,-105+240($sp)\nldb $25,($25)\nsll $25,8*(8-4),$25\nsra $25,8*(8-4),$25\nmulq $27,$25,$27\nldq $25,-136+240($sp)\ncmpeq $27,$25,$23\nbne $23,L.568\nlda $27,1\nstb $27,-74+240($sp)\nL.568:\nldq $27,-104+240($sp)\nlda $25,-108+240($sp)\nldw $25,($25)\nsll $25,8*(8-4),$25\nsra $25,8*(8-4),$25\nmulq $27,$25,$27\nldq $25,-136+240($sp)\ncmpeq $27,$25,$23\nbne $23,L.571\nlda $27,1\nstb $27,-73+240($sp)\nL.571:\nldq $27,-104+240($sp)\nldl $25,-112+240($sp)\nmulq $27,$25,$27\nldq $25,-136+240($sp)\ncmpeq $27,$25,$23\nbne $23,L.574\nlda $27,1\nstb $27,-72+240($sp)\nL.574:\nldq $27,-104+240($sp)\nldl $25,-116+240($sp)\nzap $25,240,$25\nmulq $27,$25,$27\nldl $25,-124+240($sp)\nzap $25,240,$25\ncmpeq $27,$25,$23\nbne $23,L.577\nlda $27,1\nstb $27,-71+240($sp)\nL.577:\nldq $27,-104+240($sp)\nmulq $27,$27,$27\nldq $25,-136+240($sp)\ncmpeq $27,$25,$23\nbne $23,L.580\nlda $27,1\nstb $27,-70+240($sp)\nL.580:\nlda $27,-105+240($sp)\nldb $27,($27)\nstq $27,-56+240($sp)\nldt $f30,-56+240($sp)\ncvtqs $f30,$f30\nmuls $f7,$f30,$f30\ncvtst $f30,$f30\ncmpteq $f30,$f8,$f1\nfbne $f1,L.583\nlda $27,1\nstb $27,-69+240($sp)\nL.583:\nlda $27,-108+240($sp)\nldw $27,($27)\nstq $27,-56+240($sp)\nldt $f30,-56+240($sp)\ncvtqs $f30,$f30\nmuls $f7,$f30,$f30\ncvtst $f30,$f30\ncmpteq $f30,$f8,$f1\nfbne $f1,L.586\nlda $27,1\nstb $27,-68+240($sp)\nL.586:\nlds $f30,-112+240($sp)\ncvtlq $f30,$f30\ncvtqs $f30,$f30\nmuls $f7,$f30,$f30\ncvtst $f30,$f30\ncmpteq $f30,$f8,$f1\nfbne $f1,L.589\nlda $27,1\nstb $27,-67+240($sp)\nL.589:\nldl $27,-116+240($sp)\nzap $27,240,$27\nldt $f30,L.594\nsrl $27,1,$25\nstq $25,-56+240($sp)\nldt $f29,-56+240($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+240($sp)\nldt $f29,-56+240($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f30\ncvtts $f30,$f30\nmuls $f7,$f30,$f30\ncvtst $f30,$f30\ncmpteq $f30,$f8,$f1\nfbne $f1,L.592\nlda $27,1\nstb $27,-66+240($sp)\nL.592:\nldt $f30,-104+240($sp)\ncvtqs $f30,$f30\nmuls $f7,$f30,$f30\ncvtst $f30,$f30\ncmpteq $f30,$f8,$f1\nfbne $f1,L.596\nlda $27,1\nstb $27,-65+240($sp)\nL.596:\nmuls $f7,$f7,$f30\ncvtst $f30,$f30\ncmpteq $f30,$f8,$f1\nfbne $f1,L.599\nlda $27,1\nstb $27,-64+240($sp)\nL.599:\nlda $27,-105+240($sp)\nldb $27,($27)\nstq $27,-56+240($sp)\nldt $f30,-56+240($sp)\ncvtqt $f30,$f30\nmult $f6,$f30,$f30\ncmpteq $f30,$f8,$f1\nfbne $f1,L.602\nlda $27,1\nstb $27,-63+240($sp)\nL.602:\nlda $27,-108+240($sp)\nldw $27,($27)\nstq $27,-56+240($sp)\nldt $f30,-56+240($sp)\ncvtqt $f30,$f30\nmult $f6,$f30,$f30\ncmpteq $f30,$f8,$f1\nfbne $f1,L.605\nlda $27,1\nstb $27,-62+240($sp)\nL.605:\nlds $f30,-112+240($sp)\ncvtlq $f30,$f30\ncvtqt $f30,$f30\nmult $f6,$f30,$f30\ncmpteq $f30,$f8,$f1\nfbne $f1,L.608\nlda $27,1\nstb $27,-61+240($sp)\nL.608:\nldl $27,-116+240($sp)\nzap $27,240,$27\nldt $f30,L.594\nsrl $27,1,$25\nstq $25,-56+240($sp)\nldt $f29,-56+240($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+240($sp)\nldt $f29,-56+240($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f30\nmult $f6,$f30,$f30\ncmpteq $f30,$f8,$f1\nfbne $f1,L.611\nlda $27,1\nstb $27,-60+240($sp)\nL.611:\nldt $f30,-104+240($sp)\ncvtqt $f30,$f30\nmult $f6,$f30,$f30\ncmpteq $f30,$f8,$f1\nfbne $f1,L.614\nlda $27,1\nstb $27,-59+240($sp)\nL.614:\ncvtst $f7,$f30\nmult $f6,$f30,$f30\ncmpteq $f30,$f8,$f1\nfbne $f1,L.617\nlda $27,1\nstb $27,-58+240($sp)\nL.617:\nmult $f6,$f6,$f30\ncmpteq $f30,$f8,$f1\nfbne $f1,L.620\nlda $27,1\nstb $27,-57+240($sp)\nL.620:\nmov $31,$11\nmov $31,$13\nL.623:\nsll $11,8*(8-1),$27\nsra $27,8*(8-1),$27\nlda $25,-84+240($sp)\naddq $13,$25,$25\nldb $25,($25)\naddl $27,$25,$27\nmov $27,$11\nL.624:\nlda $13,1($13)\ncmplt $13,28,$23\nbne $23,L.623\nsll $11,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbne $23,L.627\nldl $27,-128+240($sp)\nlda $27,4($27)\nstl $27,-128+240($sp)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.629\nlda $16,L.518\nlda $17,4\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.631\njsr $26,printf\nldgp $gp,0($26)\nmov $31,$13\nL.632:\nlda $16,L.636\nlda $27,-84+240($sp)\naddq $13,$27,$27\nldb $17,($27)\njsr $26,printf\nldgp $gp,0($26)\nL.633:\nlda $13,1($13)\ncmplt $13,28,$23\nbne $23,L.632\nlda $16,L.637\njsr $26,printf\nldgp $gp,0($26)\nL.629:\nL.627:\nlda $27,32768\nstq $27,-104+240($sp)\nldq $25,-104+240($sp)\ncmple $25,$27,$23\nbne $23,L.638\nldl $27,-128+240($sp)\nlda $27,8($27)\nstl $27,-128+240($sp)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.640\nlda $16,L.518\nlda $17,8\njsr $26,printf\nldgp $gp,0($26)\nL.640:\nL.638:\nldl $0,-128+240($sp)\nL.517:\nldt $f6,0($sp)\nldt $f7,8($sp)\nldt $f8,16($sp)\nldt $f9,24($sp)\nldq $9,32($sp)\nldq $10,40($sp)\nldq $11,48($sp)\nldq $12,56($sp)\nldq $13,64($sp)\nldq $14,72($sp)\nldq $24,80($sp)\nldq $26,88($sp)\nlda $sp,240($sp)\nret\n.end s626\n.sdata\n.align 0\nL.643:\n.byte 115\n.byte 55\n.byte 49\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.644:\n.byte 115\n.byte 55\n.byte 49\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.align 0\nL.645:\n.byte 0x71\n.globl s71\n.text\n.text\n.ent s71\ns71:\nldgp $gp,0($27)\nlda $sp,-176($sp)\n.mask 0x5007c00,-128\n.frame $sp,176,$26,48\nstq $10,0($sp)\nstq $11,8($sp)\nstq $12,16($sp)\nstq $13,24($sp)\nstq $14,32($sp)\nstq $24,40($sp)\nstq $26,48($sp)\nmov $16,$14\n.prologue 1\nlda $13,L.644\nlda $12,60($14)\nmov $31,$11\nL.646:\nL.647:\nmov $12,$27\nlda $12,1($27)\nmov $13,$25\nlda $13,1($25)\nldb $25,($25)\nstb $25,($27)\nsll $25,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbeq $23,L.646\nlda $27,L.651\nldb $27,($27)\nlda $25,L.645\nldb $25,($25)\ncmpeq $27,$25,$23\nbne $23,L.649\nlda $11,1($11)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.652\nlda $16,L.643\nlda $17,1\njsr $26,printf\nldgp $gp,0($26)\nL.652:\nL.649:\nbr L.654\nlda $11,2($11)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.656\nlda $16,L.643\nlda $17,2\njsr $26,printf\nldgp $gp,0($26)\nL.656:\nL.654:\nlda $27,1942\nstl $27,-76+176($sp)\nldl $27,-76+176($sp)\nlda $25,1942\ncmpeq $27,$25,$23\nbeq $23,L.664\nldl $27,-76+176($sp)\nldl $25,-76+176($sp)\ncmpeq $27,$25,$23\nbne $23,L.659\nL.664:\nlda $11,4($11)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.665\nlda $16,L.643\nlda $17,4\njsr $26,printf\nldgp $gp,0($26)\nL.665:\nL.659:\nlda $16,-5\njsr $26,McCarthy\nldgp $gp,0($26)\nlda $25,91\ncmpeq $0,$25,$23\nbne $23,L.667\nlda $11,8($11)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.669\nlda $16,L.643\nlda $17,8\njsr $26,printf\nldgp $gp,0($26)\nL.669:\nL.667:\nlda $10,2\nlda $27,3\nstl $27,-100+176($sp)\nlda $27,-100+176($sp)\nstq $27,-112+176($sp)\nmov $10,$16\nldq $17,-112+176($sp)\njsr $26,clobber\nldgp $gp,0($26)\ncmpeq $10,2,$23\nbeq $23,L.673\nldl $27,-100+176($sp)\ncmpeq $27,2,$23\nbne $23,L.671\nL.673:\nlda $11,16($11)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.674\nlda $16,L.643\nlda $17,16\njsr $26,printf\nldgp $gp,0($26)\nL.674:\nL.671:\nlds $f30,32($14)\ncmpteq $f30,$f30,$f1\nfbne $f1,L.676\nlda $11,32($11)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.678\nlda $16,L.643\nlda $17,32\njsr $26,printf\nldgp $gp,0($26)\nL.678:\nL.676:\nmov $11,$0\nL.642:\nldq $10,0($sp)\nldq $11,8($sp)\nldq $12,16($sp)\nldq $13,24($sp)\nldq $14,32($sp)\nldq $24,40($sp)\nldq $26,48($sp)\nlda $sp,176($sp)\nret\n.end s71\n.globl McCarthy\n.text\n.ent McCarthy\nMcCarthy:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\nstq $16,16($sp)\n.prologue 1\nldl $27,-48+64($sp)\nlda $25,100\ncmple $27,$25,$23\nbne $23,L.681\nldl $27,-48+64($sp)\nsubl $27,10,$0\nbr L.680\nL.681:\nldl $27,-48+64($sp)\nlda $16,11($27)\njsr $26,McCarthy\nldgp $gp,0($26)\nmov $0,$27\nmov $27,$16\njsr $26,McCarthy\nldgp $gp,0($26)\nmov $0,$27\nL.680:\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end McCarthy\n.globl clobber\n.text\n.ent clobber\nclobber:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.frame $sp,64,$26,48\n.prologue 1\nlda $16,3\nlda $27,2\nstl $27,($17)\nmov $31,$0\nL.683:\nlda $sp,64($sp)\nret\n.end clobber\n.sdata\n.align 0\nL.685:\n.byte 76\n.byte 111\n.byte 99\n.byte 97\n.byte 108\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 37\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.686:\n.byte 115\n.byte 55\n.byte 49\n.byte 52\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.687:\n.byte 115\n.byte 55\n.byte 49\n.byte 52\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s714\n.text\n.text\n.ent s714\ns714:\nldgp $gp,0($27)\nlda $sp,-256($sp)\n.fmask 0x3c0,-232\n.mask 0x5007e00,-168\n.frame $sp,256,$26,48\nstt $f6,0($sp)\nstt $f7,8($sp)\nstt $f8,16($sp)\nstt $f9,24($sp)\nstq $9,32($sp)\nstq $10,40($sp)\nstq $11,48($sp)\nstq $12,56($sp)\nstq $13,64($sp)\nstq $14,72($sp)\nstq $24,80($sp)\nstq $26,88($sp)\nstq $16,208($sp)\n.prologue 1\nlda $27,L.687\nstq $27,-96+256($sp)\nldq $27,-48+256($sp)\nlda $25,60($27)\nstq $25,-104+256($sp)\nstl $31,-108+256($sp)\nmov $31,$13\nldl $14,48($27)\nL.688:\nL.689:\nldq $27,-104+256($sp)\nlda $25,1($27)\nstq $25,-104+256($sp)\nldq $25,-96+256($sp)\nlda $22,1($25)\nstq $22,-96+256($sp)\nldb $25,($25)\nstb $25,($27)\nsll $25,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbeq $23,L.688\nlda $12,5\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $12,($27)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,2,$23\nbne $23,L.691\nlda $13,1\ncmpeq $14,$31,$23\nbne $23,L.693\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.693:\nL.691:\nlda $12,5\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,2,$23\nbne $23,L.695\nlda $13,2\ncmpeq $14,$31,$23\nbne $23,L.697\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.697:\nL.695:\nlda $12,5\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,2,$23\nbne $23,L.699\nlda $13,3\ncmpeq $14,$31,$23\nbne $23,L.701\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.701:\nL.699:\nlda $12,5\nlda $27,2\nstq $27,-80+256($sp)\nldq $27,-80+256($sp)\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,2,$23\nbne $23,L.703\nlda $13,4\ncmpeq $14,$31,$23\nbne $23,L.705\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.705:\nL.703:\nlda $12,5\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,2,$23\nbne $23,L.707\nlda $13,5\ncmpeq $14,$31,$23\nbne $23,L.709\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.709:\nL.707:\nlda $12,5\nlds $f7,L.527\ncvttqc $f7,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,2,$23\nbne $23,L.711\nlda $13,6\ncmpeq $14,$31,$23\nbne $23,L.713\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.713:\nL.711:\nlda $12,5\nldt $f6,L.414\ncvttqc $f6,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,2,$23\nbne $23,L.715\nlda $13,7\ncmpeq $14,$31,$23\nbne $23,L.717\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.717:\nL.715:\nlda $11,5\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,2,$23\nbne $23,L.719\nlda $13,8\ncmpeq $14,$31,$23\nbne $23,L.721\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.721:\nL.719:\nlda $11,5\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $11,($27)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,2,$23\nbne $23,L.723\nlda $13,9\ncmpeq $14,$31,$23\nbne $23,L.725\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.725:\nL.723:\nlda $11,5\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,2,$23\nbne $23,L.727\nlda $13,10\ncmpeq $14,$31,$23\nbne $23,L.729\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.729:\nL.727:\nlda $11,5\nlda $27,2\nstq $27,-80+256($sp)\nldq $27,-80+256($sp)\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,2,$23\nbne $23,L.731\nlda $13,11\ncmpeq $14,$31,$23\nbne $23,L.733\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.733:\nL.731:\nlda $11,5\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,2,$23\nbne $23,L.735\nlda $13,12\ncmpeq $14,$31,$23\nbne $23,L.737\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.737:\nL.735:\nlda $11,5\nlds $f7,L.527\ncvttqc $f7,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,2,$23\nbne $23,L.739\nlda $13,13\ncmpeq $14,$31,$23\nbne $23,L.741\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.741:\nL.739:\nlda $11,5\nldt $f6,L.414\ncvttqc $f6,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,2,$23\nbne $23,L.743\nlda $13,14\ncmpeq $14,$31,$23\nbne $23,L.745\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.745:\nL.743:\nlda $10,5\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $10,($27)\ncmpeq $10,2,$23\nbne $23,L.747\nlda $13,15\ncmpeq $14,$31,$23\nbne $23,L.749\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.749:\nL.747:\nlda $10,5\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $10,($27)\ncmpeq $10,2,$23\nbne $23,L.751\nlda $13,16\ncmpeq $14,$31,$23\nbne $23,L.753\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.753:\nL.751:\nlda $10,5\nlda $27,2\nstl $27,-68+256($sp)\nldl $10,-68+256($sp)\ncmpeq $10,2,$23\nbne $23,L.755\nlda $13,17\ncmpeq $14,$31,$23\nbne $23,L.757\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.757:\nL.755:\nlda $10,5\nlda $27,2\nstq $27,-80+256($sp)\nldq $27,-80+256($sp)\nmov $27,$10\ncmpeq $10,2,$23\nbne $23,L.759\nlda $13,18\ncmpeq $14,$31,$23\nbne $23,L.761\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.761:\nL.759:\nlda $10,5\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nmov $27,$10\ncmpeq $10,2,$23\nbne $23,L.763\nlda $13,19\ncmpeq $14,$31,$23\nbne $23,L.765\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.765:\nL.763:\nlda $10,5\nlds $f7,L.527\ncvttqc $f7,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $10,-56+256($sp)\ncmpeq $10,2,$23\nbne $23,L.767\nlda $13,20\ncmpeq $14,$31,$23\nbne $23,L.769\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.769:\nL.767:\nlda $10,5\nldt $f6,L.414\ncvttqc $f6,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $10,-56+256($sp)\ncmpeq $10,2,$23\nbne $23,L.771\nlda $13,21\ncmpeq $14,$31,$23\nbne $23,L.773\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.773:\nL.771:\nlda $9,5\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nsll $27,8*(8-4),$9\nsra $9,8*(8-4),$9\ncmpeq $9,2,$23\nbne $23,L.775\nlda $13,22\ncmpeq $14,$31,$23\nbne $23,L.777\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.777:\nL.775:\nlda $9,5\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nsll $27,8*(8-4),$9\nsra $9,8*(8-4),$9\ncmpeq $9,2,$23\nbne $23,L.779\nlda $13,23\ncmpeq $14,$31,$23\nbne $23,L.781\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.781:\nL.779:\nlda $9,5\nlda $27,2\nstl $27,-68+256($sp)\nldl $9,-68+256($sp)\ncmpeq $9,2,$23\nbne $23,L.783\nlda $13,24\ncmpeq $14,$31,$23\nbne $23,L.785\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.785:\nL.783:\nlda $9,5\nlda $27,2\nstq $27,-80+256($sp)\nldq $9,-80+256($sp)\ncmpeq $9,2,$23\nbne $23,L.787\nlda $13,25\ncmpeq $14,$31,$23\nbne $23,L.789\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.789:\nL.787:\nlda $9,5\nlda $27,2\nstl $27,-84+256($sp)\nldl $9,-84+256($sp)\nzap $9,240,$9\ncmpeq $9,2,$23\nbne $23,L.791\nlda $13,26\ncmpeq $14,$31,$23\nbne $23,L.793\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.793:\nL.791:\nlda $9,5\nlds $f7,L.527\ncvttqc $f7,$f1\nstt $f1,-56+256($sp)\nldq $9,-56+256($sp)\ncmpeq $9,2,$23\nbne $23,L.795\nlda $13,27\ncmpeq $14,$31,$23\nbne $23,L.797\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.797:\nL.795:\nlda $9,5\nldt $f6,L.414\ncvttqc $f6,$f1\nstt $f1,-56+256($sp)\nldq $9,-56+256($sp)\ncmpeq $9,2,$23\nbne $23,L.799\nlda $13,28\ncmpeq $14,$31,$23\nbne $23,L.801\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.801:\nL.799:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,2\ncmpeq $27,$25,$23\nbne $23,L.803\nlda $13,29\ncmpeq $14,$31,$23\nbne $23,L.805\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.805:\nL.803:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,2\ncmpeq $27,$25,$23\nbne $23,L.807\nlda $13,30\ncmpeq $14,$31,$23\nbne $23,L.809\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.809:\nL.807:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,2\ncmpeq $27,$25,$23\nbne $23,L.811\nlda $13,31\ncmpeq $14,$31,$23\nbne $23,L.813\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.813:\nL.811:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstq $27,-80+256($sp)\nldq $27,-80+256($sp)\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,2\ncmpeq $27,$25,$23\nbne $23,L.815\nlda $13,32\ncmpeq $14,$31,$23\nbne $23,L.817\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.817:\nL.815:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstl $27,-84+256($sp)\nldl $25,-84+256($sp)\nzap $25,240,$25\nstl $25,-60+256($sp)\nldl $25,-60+256($sp)\nzap $25,240,$25\ncmpeq $25,$27,$23\nbne $23,L.819\nlda $13,33\ncmpeq $14,$31,$23\nbne $23,L.821\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.821:\nL.819:\nlda $27,5\nstl $27,-60+256($sp)\nlds $f7,L.527\nlds $f30,L.826\ncmptlt $f7,$f30,$f1\nfbne $f1,L.824\nsubs $f7,$f30,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\naddl $27,0x80000000,$27\nzap $27,240,$27\nstl $27,-112+256($sp)\nbr L.825\nL.824:\ncvttqc $f7,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nstl $27,-112+256($sp)\nL.825:\nldl $27,-112+256($sp)\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,2\ncmpeq $27,$25,$23\nbne $23,L.827\nlda $13,34\ncmpeq $14,$31,$23\nbne $23,L.829\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.829:\nL.827:\nlda $27,5\nstl $27,-60+256($sp)\nldt $f6,L.414\nldt $f30,L.834\ncmptlt $f6,$f30,$f1\nfbne $f1,L.832\nsubt $f6,$f30,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\naddl $27,0x80000000,$27\nzap $27,240,$27\nstl $27,-116+256($sp)\nbr L.833\nL.832:\ncvttqc $f6,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nstl $27,-116+256($sp)\nL.833:\nldl $27,-116+256($sp)\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,2\ncmpeq $27,$25,$23\nbne $23,L.835\nlda $13,35\ncmpeq $14,$31,$23\nbne $23,L.837\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.837:\nL.835:\nlds $f9,L.839\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nstq $27,-56+256($sp)\nldt $f9,-56+256($sp)\ncvtqs $f9,$f9\nlds $f30,L.527\ncmpteq $f9,$f30,$f1\nfbne $f1,L.840\nlda $13,36\ncmpeq $14,$31,$23\nbne $23,L.842\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.842:\nL.840:\nlds $f9,L.839\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nstq $27,-56+256($sp)\nldt $f9,-56+256($sp)\ncvtqs $f9,$f9\nlds $f30,L.527\ncmpteq $f9,$f30,$f1\nfbne $f1,L.844\nlda $13,37\ncmpeq $14,$31,$23\nbne $23,L.846\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.846:\nL.844:\nlds $f9,L.839\nlda $27,2\nstl $27,-68+256($sp)\nlds $f9,-68+256($sp)\ncvtlq $f9,$f9\ncvtqs $f9,$f9\nlds $f30,L.527\ncmpteq $f9,$f30,$f1\nfbne $f1,L.848\nlda $13,38\ncmpeq $14,$31,$23\nbne $23,L.850\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.850:\nL.848:\nlds $f9,L.839\nlda $27,2\nstq $27,-80+256($sp)\nldt $f9,-80+256($sp)\ncvtqs $f9,$f9\nlds $f30,L.527\ncmpteq $f9,$f30,$f1\nfbne $f1,L.852\nlda $13,39\ncmpeq $14,$31,$23\nbne $23,L.854\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.854:\nL.852:\nlds $f9,L.839\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nldt $f30,L.594\nsrl $27,1,$25\nstq $25,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f30\ncvtts $f30,$f9\nlds $f30,L.527\ncmpteq $f9,$f30,$f1\nfbne $f1,L.856\nlda $13,40\ncmpeq $14,$31,$23\nbne $23,L.858\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.858:\nL.856:\nlds $f9,L.839\nlds $f30,L.527\nfmov $f30,$f7\nfmov $f7,$f9\ncmpteq $f9,$f30,$f1\nfbne $f1,L.860\nlda $13,41\ncmpeq $14,$31,$23\nbne $23,L.862\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.862:\nL.860:\nlds $f9,L.839\nldt $f6,L.414\ncvtts $f6,$f9\nlds $f30,L.527\ncmpteq $f9,$f30,$f1\nfbne $f1,L.864\nlda $13,42\ncmpeq $14,$31,$23\nbne $23,L.866\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.866:\nL.864:\nldt $f8,L.868\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nstq $27,-56+256($sp)\nldt $f8,-56+256($sp)\ncvtqt $f8,$f8\nldt $f30,L.414\ncmpteq $f8,$f30,$f1\nfbne $f1,L.869\nlda $13,43\ncmpeq $14,$31,$23\nbne $23,L.871\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.871:\nL.869:\nldt $f8,L.868\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nstq $27,-56+256($sp)\nldt $f8,-56+256($sp)\ncvtqt $f8,$f8\nldt $f30,L.414\ncmpteq $f8,$f30,$f1\nfbne $f1,L.873\nlda $13,44\ncmpeq $14,$31,$23\nbne $23,L.875\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.875:\nL.873:\nldt $f8,L.868\nlda $27,2\nstl $27,-68+256($sp)\nlds $f8,-68+256($sp)\ncvtlq $f8,$f8\ncvtqt $f8,$f8\nldt $f30,L.414\ncmpteq $f8,$f30,$f1\nfbne $f1,L.877\nlda $13,45\ncmpeq $14,$31,$23\nbne $23,L.879\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.879:\nL.877:\nldt $f8,L.868\nlda $27,2\nstq $27,-80+256($sp)\nldt $f8,-80+256($sp)\ncvtqt $f8,$f8\nldt $f30,L.414\ncmpteq $f8,$f30,$f1\nfbne $f1,L.881\nlda $13,46\ncmpeq $14,$31,$23\nbne $23,L.883\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.883:\nL.881:\nldt $f8,L.868\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nldt $f30,L.594\nsrl $27,1,$25\nstq $25,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f8\nldt $f30,L.414\ncmpteq $f8,$f30,$f1\nfbne $f1,L.885\nlda $13,47\ncmpeq $14,$31,$23\nbne $23,L.887\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.887:\nL.885:\nldt $f8,L.868\nlds $f7,L.527\ncvtst $f7,$f8\nldt $f30,L.414\ncmpteq $f8,$f30,$f1\nfbne $f1,L.889\nlda $13,48\ncmpeq $14,$31,$23\nbne $23,L.891\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.891:\nL.889:\nldt $f8,L.868\nldt $f30,L.414\nfmov $f30,$f6\nfmov $f6,$f8\ncmpteq $f8,$f30,$f1\nfbne $f1,L.893\nlda $13,49\ncmpeq $14,$31,$23\nbne $23,L.895\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.895:\nL.893:\nlda $12,5\nlda $27,2\nstb $27,-61+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nlda $25,-61+256($sp)\nldb $25,($25)\naddl $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,7,$23\nbne $23,L.897\nlda $13,50\ncmpeq $14,$31,$23\nbne $23,L.899\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.899:\nL.897:\nlda $12,5\nlda $27,2\nstw $27,-64+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nlda $25,-64+256($sp)\nldw $25,($25)\naddl $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,7,$23\nbne $23,L.901\nlda $13,51\ncmpeq $14,$31,$23\nbne $23,L.903\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.903:\nL.901:\nlda $12,5\nlda $27,2\nstl $27,-68+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldl $25,-68+256($sp)\naddl $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,7,$23\nbne $23,L.905\nlda $13,52\ncmpeq $14,$31,$23\nbne $23,L.907\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.907:\nL.905:\nlda $12,5\nlda $27,2\nstq $27,-80+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\naddq $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,7,$23\nbne $23,L.909\nlda $13,53\ncmpeq $14,$31,$23\nbne $23,L.911\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.911:\nL.909:\nlda $12,5\nlda $27,2\nstl $27,-84+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldl $25,-84+256($sp)\nzap $25,240,$25\naddl $27,$25,$27\nzap $27,240,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,7,$23\nbne $23,L.913\nlda $13,54\ncmpeq $14,$31,$23\nbne $23,L.915\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.915:\nL.913:\nlda $12,5\nlds $f7,L.527\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\nadds $f30,$f7,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,7,$23\nbne $23,L.917\nlda $13,55\ncmpeq $14,$31,$23\nbne $23,L.919\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.919:\nL.917:\nlda $12,5\nldt $f6,L.414\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\naddt $f30,$f6,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,7,$23\nbne $23,L.921\nlda $13,56\ncmpeq $14,$31,$23\nbne $23,L.923\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.923:\nL.921:\nlda $11,5\nlda $27,2\nstb $27,-61+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-61+256($sp)\nldb $25,($25)\naddl $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,7,$23\nbne $23,L.925\nlda $13,57\ncmpeq $14,$31,$23\nbne $23,L.927\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.927:\nL.925:\nlda $11,5\nlda $27,2\nstw $27,-64+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-64+256($sp)\nldw $25,($25)\naddl $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,7,$23\nbne $23,L.929\nlda $13,58\ncmpeq $14,$31,$23\nbne $23,L.931\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.931:\nL.929:\nlda $11,5\nlda $27,2\nstl $27,-68+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldl $25,-68+256($sp)\naddl $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,7,$23\nbne $23,L.933\nlda $13,59\ncmpeq $14,$31,$23\nbne $23,L.935\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.935:\nL.933:\nlda $11,5\nlda $27,2\nstq $27,-80+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\naddq $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,7,$23\nbne $23,L.937\nlda $13,60\ncmpeq $14,$31,$23\nbne $23,L.939\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.939:\nL.937:\nlda $11,5\nlda $27,2\nstl $27,-84+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldl $25,-84+256($sp)\nzap $25,240,$25\naddl $27,$25,$27\nzap $27,240,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,7,$23\nbne $23,L.941\nlda $13,61\ncmpeq $14,$31,$23\nbne $23,L.943\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.943:\nL.941:\nlda $11,5\nlds $f7,L.527\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\nadds $f30,$f7,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,7,$23\nbne $23,L.945\nlda $13,62\ncmpeq $14,$31,$23\nbne $23,L.947\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.947:\nL.945:\nlda $11,5\nldt $f6,L.414\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\naddt $f30,$f6,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,7,$23\nbne $23,L.949\nlda $13,63\ncmpeq $14,$31,$23\nbne $23,L.951\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.951:\nL.949:\nlda $10,5\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\naddl $10,$27,$10\ncmpeq $10,7,$23\nbne $23,L.953\nlda $13,64\ncmpeq $14,$31,$23\nbne $23,L.955\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.955:\nL.953:\nlda $10,5\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\naddl $10,$27,$10\ncmpeq $10,7,$23\nbne $23,L.957\nlda $13,65\ncmpeq $14,$31,$23\nbne $23,L.959\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.959:\nL.957:\nlda $10,5\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\naddl $10,$27,$10\ncmpeq $10,7,$23\nbne $23,L.961\nlda $13,66\ncmpeq $14,$31,$23\nbne $23,L.963\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.963:\nL.961:\nlda $10,5\nlda $27,2\nstq $27,-80+256($sp)\nsll $10,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\naddq $27,$25,$27\nmov $27,$10\ncmpeq $10,7,$23\nbne $23,L.965\nlda $13,67\ncmpeq $14,$31,$23\nbne $23,L.967\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.967:\nL.965:\nlda $10,5\nlda $27,2\nstl $27,-84+256($sp)\nmov $10,$27\nldl $25,-84+256($sp)\nzap $25,240,$25\naddl $27,$25,$27\nzap $27,240,$27\nmov $27,$10\ncmpeq $10,7,$23\nbne $23,L.969\nlda $13,68\ncmpeq $14,$31,$23\nbne $23,L.971\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.971:\nL.969:\nlda $10,5\nlds $f7,L.527\nstq $10,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\nadds $f30,$f7,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $10,-56+256($sp)\ncmpeq $10,7,$23\nbne $23,L.973\nlda $13,69\ncmpeq $14,$31,$23\nbne $23,L.975\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.975:\nL.973:\nlda $10,5\nldt $f6,L.414\nstq $10,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\naddt $f30,$f6,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $10,-56+256($sp)\ncmpeq $10,7,$23\nbne $23,L.977\nlda $13,70\ncmpeq $14,$31,$23\nbne $23,L.979\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.979:\nL.977:\nlda $9,5\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\naddq $9,$27,$9\ncmpeq $9,7,$23\nbne $23,L.981\nlda $13,71\ncmpeq $14,$31,$23\nbne $23,L.983\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.983:\nL.981:\nlda $9,5\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\naddq $9,$27,$9\ncmpeq $9,7,$23\nbne $23,L.985\nlda $13,72\ncmpeq $14,$31,$23\nbne $23,L.987\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.987:\nL.985:\nlda $9,5\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\naddq $9,$27,$9\ncmpeq $9,7,$23\nbne $23,L.989\nlda $13,73\ncmpeq $14,$31,$23\nbne $23,L.991\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.991:\nL.989:\nlda $9,5\nlda $27,2\nstq $27,-80+256($sp)\nldq $27,-80+256($sp)\naddq $9,$27,$9\ncmpeq $9,7,$23\nbne $23,L.993\nlda $13,74\ncmpeq $14,$31,$23\nbne $23,L.995\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.995:\nL.993:\nlda $9,5\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\naddq $9,$27,$9\ncmpeq $9,7,$23\nbne $23,L.997\nlda $13,75\ncmpeq $14,$31,$23\nbne $23,L.999\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.999:\nL.997:\nlda $9,5\nlds $f7,L.527\nstq $9,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\nadds $f30,$f7,$f30\ncvttqc $f30,$f1\nstt $f1,-56+256($sp)\nldq $9,-56+256($sp)\ncmpeq $9,7,$23\nbne $23,L.1001\nlda $13,76\ncmpeq $14,$31,$23\nbne $23,L.1003\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1003:\nL.1001:\nlda $9,5\nldt $f6,L.414\nstq $9,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\naddt $f30,$f6,$f30\ncvttqc $f30,$f1\nstt $f1,-56+256($sp)\nldq $9,-56+256($sp)\ncmpeq $9,7,$23\nbne $23,L.1005\nlda $13,77\ncmpeq $14,$31,$23\nbne $23,L.1007\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1007:\nL.1005:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstb $27,-61+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,-61+256($sp)\nldb $25,($25)\naddl $27,$25,$27\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,7\ncmpeq $27,$25,$23\nbne $23,L.1009\nlda $13,78\ncmpeq $14,$31,$23\nbne $23,L.1011\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1011:\nL.1009:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstw $27,-64+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,-64+256($sp)\nldw $25,($25)\naddl $27,$25,$27\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,7\ncmpeq $27,$25,$23\nbne $23,L.1013\nlda $13,79\ncmpeq $14,$31,$23\nbne $23,L.1015\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1015:\nL.1013:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldl $25,-68+256($sp)\naddl $27,$25,$27\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,7\ncmpeq $27,$25,$23\nbne $23,L.1017\nlda $13,80\ncmpeq $14,$31,$23\nbne $23,L.1019\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1019:\nL.1017:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstq $27,-80+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldq $25,-80+256($sp)\naddq $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,7\ncmpeq $27,$25,$23\nbne $23,L.1021\nlda $13,81\ncmpeq $14,$31,$23\nbne $23,L.1023\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1023:\nL.1021:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldl $25,-84+256($sp)\nzap $25,240,$25\naddl $27,$25,$27\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,7\ncmpeq $27,$25,$23\nbne $23,L.1025\nlda $13,82\ncmpeq $14,$31,$23\nbne $23,L.1027\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1027:\nL.1025:\nlda $27,5\nstl $27,-60+256($sp)\nlds $f7,L.527\nldl $27,-60+256($sp)\nzap $27,240,$27\nldt $f30,L.594\nsrl $27,1,$25\nstq $25,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f30\ncvtts $f30,$f30\nadds $f30,$f7,$f30\nlds $f29,L.826\ncmptlt $f30,$f29,$f1\nfbne $f1,L.1030\nsubs $f30,$f29,$f29\ncvttqc $f29,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\naddl $27,0x80000000,$27\nzap $27,240,$27\nstl $27,-120+256($sp)\nbr L.1031\nL.1030:\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nstl $27,-120+256($sp)\nL.1031:\nldl $27,-120+256($sp)\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,7\ncmpeq $27,$25,$23\nbne $23,L.1032\nlda $13,83\ncmpeq $14,$31,$23\nbne $23,L.1034\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1034:\nL.1032:\nlda $27,5\nstl $27,-60+256($sp)\nldt $f6,L.414\nldl $27,-60+256($sp)\nzap $27,240,$27\nldt $f30,L.594\nsrl $27,1,$25\nstq $25,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f30\naddt $f30,$f6,$f30\nldt $f29,L.834\ncmptlt $f30,$f29,$f1\nfbne $f1,L.1037\nsubt $f30,$f29,$f29\ncvttqc $f29,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\naddl $27,0x80000000,$27\nzap $27,240,$27\nstl $27,-124+256($sp)\nbr L.1038\nL.1037:\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nstl $27,-124+256($sp)\nL.1038:\nldl $27,-124+256($sp)\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,7\ncmpeq $27,$25,$23\nbne $23,L.1039\nlda $13,84\ncmpeq $14,$31,$23\nbne $23,L.1041\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1041:\nL.1039:\nlds $f9,L.839\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\nadds $f9,$f30,$f9\nlds $f30,L.1045\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1043\nlda $13,85\ncmpeq $14,$31,$23\nbne $23,L.1046\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1046:\nL.1043:\nlds $f9,L.839\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\nadds $f9,$f30,$f9\nlds $f30,L.1045\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1048\nlda $13,86\ncmpeq $14,$31,$23\nbne $23,L.1050\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1050:\nL.1048:\nlds $f9,L.839\nlda $27,2\nstl $27,-68+256($sp)\nlds $f30,-68+256($sp)\ncvtlq $f30,$f30\ncvtqs $f30,$f30\nadds $f9,$f30,$f9\nlds $f30,L.1045\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1052\nlda $13,87\ncmpeq $14,$31,$23\nbne $23,L.1054\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1054:\nL.1052:\nlds $f9,L.839\nlda $27,2\nstq $27,-80+256($sp)\nldt $f30,-80+256($sp)\ncvtqs $f30,$f30\nadds $f9,$f30,$f9\nlds $f30,L.1045\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1056\nlda $13,88\ncmpeq $14,$31,$23\nbne $23,L.1058\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1058:\nL.1056:\nlds $f9,L.839\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nldt $f30,L.594\nsrl $27,1,$25\nstq $25,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f30\ncvtts $f30,$f30\nadds $f9,$f30,$f9\nlds $f30,L.1045\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1060\nlda $13,89\ncmpeq $14,$31,$23\nbne $23,L.1062\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1062:\nL.1060:\nlds $f9,L.839\nlds $f7,L.527\nadds $f9,$f7,$f9\nlds $f30,L.1045\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1064\nlda $13,90\ncmpeq $14,$31,$23\nbne $23,L.1066\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1066:\nL.1064:\nlds $f9,L.839\nldt $f6,L.414\ncvtst $f9,$f30\naddt $f30,$f6,$f30\ncvtts $f30,$f9\nlds $f30,L.1045\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1068\nlda $13,91\ncmpeq $14,$31,$23\nbne $23,L.1070\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1070:\nL.1068:\nldt $f8,L.868\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\naddt $f8,$f30,$f8\nldt $f30,L.1074\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1072\nlda $13,92\ncmpeq $14,$31,$23\nbne $23,L.1075\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1075:\nL.1072:\nldt $f8,L.868\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\naddt $f8,$f30,$f8\nldt $f30,L.1074\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1077\nlda $13,93\ncmpeq $14,$31,$23\nbne $23,L.1079\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1079:\nL.1077:\nldt $f8,L.868\nlda $27,2\nstl $27,-68+256($sp)\nlds $f30,-68+256($sp)\ncvtlq $f30,$f30\ncvtqt $f30,$f30\naddt $f8,$f30,$f8\nldt $f30,L.1074\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1081\nlda $13,94\ncmpeq $14,$31,$23\nbne $23,L.1083\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1083:\nL.1081:\nldt $f8,L.868\nlda $27,2\nstq $27,-80+256($sp)\nldt $f30,-80+256($sp)\ncvtqt $f30,$f30\naddt $f8,$f30,$f8\nldt $f30,L.1074\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1085\nlda $13,95\ncmpeq $14,$31,$23\nbne $23,L.1087\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1087:\nL.1085:\nldt $f8,L.868\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nldt $f30,L.594\nsrl $27,1,$25\nstq $25,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f30\naddt $f8,$f30,$f8\nldt $f30,L.1074\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1089\nlda $13,96\ncmpeq $14,$31,$23\nbne $23,L.1091\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1091:\nL.1089:\nldt $f8,L.868\nlds $f7,L.527\ncvtst $f7,$f30\naddt $f8,$f30,$f8\nldt $f30,L.1074\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1093\nlda $13,97\ncmpeq $14,$31,$23\nbne $23,L.1095\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1095:\nL.1093:\nldt $f8,L.868\nldt $f6,L.414\naddt $f8,$f6,$f8\nldt $f30,L.1074\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1097\nlda $13,98\ncmpeq $14,$31,$23\nbne $23,L.1099\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1099:\nL.1097:\nlda $12,5\nlda $27,2\nstb $27,-61+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nlda $25,-61+256($sp)\nldb $25,($25)\nsubl $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,3,$23\nbne $23,L.1101\nlda $13,99\ncmpeq $14,$31,$23\nbne $23,L.1103\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1103:\nL.1101:\nlda $12,5\nlda $27,2\nstw $27,-64+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nlda $25,-64+256($sp)\nldw $25,($25)\nsubl $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,3,$23\nbne $23,L.1105\nlda $13,100\ncmpeq $14,$31,$23\nbne $23,L.1107\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1107:\nL.1105:\nlda $12,5\nlda $27,2\nstl $27,-68+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldl $25,-68+256($sp)\nsubl $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,3,$23\nbne $23,L.1109\nlda $13,101\ncmpeq $14,$31,$23\nbne $23,L.1111\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1111:\nL.1109:\nlda $12,5\nlda $27,2\nstq $27,-80+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\nsubq $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,3,$23\nbne $23,L.1113\nlda $13,102\ncmpeq $14,$31,$23\nbne $23,L.1115\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1115:\nL.1113:\nlda $12,5\nlda $27,2\nstl $27,-84+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nsubl $27,$25,$27\nzap $27,240,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,3,$23\nbne $23,L.1117\nlda $13,103\ncmpeq $14,$31,$23\nbne $23,L.1119\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1119:\nL.1117:\nlda $12,5\nlds $f7,L.527\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\nsubs $f30,$f7,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,3,$23\nbne $23,L.1121\nlda $13,104\ncmpeq $14,$31,$23\nbne $23,L.1123\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1123:\nL.1121:\nlda $12,5\nldt $f6,L.414\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\nsubt $f30,$f6,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,3,$23\nbne $23,L.1125\nlda $13,105\ncmpeq $14,$31,$23\nbne $23,L.1127\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1127:\nL.1125:\nlda $11,5\nlda $27,2\nstb $27,-61+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-61+256($sp)\nldb $25,($25)\nsubl $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,3,$23\nbne $23,L.1129\nlda $13,106\ncmpeq $14,$31,$23\nbne $23,L.1131\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1131:\nL.1129:\nlda $11,5\nlda $27,2\nstw $27,-64+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-64+256($sp)\nldw $25,($25)\nsubl $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,3,$23\nbne $23,L.1133\nlda $13,107\ncmpeq $14,$31,$23\nbne $23,L.1135\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1135:\nL.1133:\nlda $11,5\nlda $27,2\nstl $27,-68+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldl $25,-68+256($sp)\nsubl $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,3,$23\nbne $23,L.1137\nlda $13,108\ncmpeq $14,$31,$23\nbne $23,L.1139\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1139:\nL.1137:\nlda $11,5\nlda $27,2\nstq $27,-80+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\nsubq $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,3,$23\nbne $23,L.1141\nlda $13,109\ncmpeq $14,$31,$23\nbne $23,L.1143\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1143:\nL.1141:\nlda $11,5\nlda $27,2\nstl $27,-84+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nsubl $27,$25,$27\nzap $27,240,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,3,$23\nbne $23,L.1145\nlda $13,110\ncmpeq $14,$31,$23\nbne $23,L.1147\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1147:\nL.1145:\nlda $11,5\nlds $f7,L.527\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\nsubs $f30,$f7,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,3,$23\nbne $23,L.1149\nlda $13,111\ncmpeq $14,$31,$23\nbne $23,L.1151\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1151:\nL.1149:\nlda $11,5\nldt $f6,L.414\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\nsubt $f30,$f6,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,3,$23\nbne $23,L.1153\nlda $13,112\ncmpeq $14,$31,$23\nbne $23,L.1155\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1155:\nL.1153:\nlda $10,5\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nsubl $10,$27,$10\ncmpeq $10,3,$23\nbne $23,L.1157\nlda $13,113\ncmpeq $14,$31,$23\nbne $23,L.1159\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1159:\nL.1157:\nlda $10,5\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nsubl $10,$27,$10\ncmpeq $10,3,$23\nbne $23,L.1161\nlda $13,114\ncmpeq $14,$31,$23\nbne $23,L.1163\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1163:\nL.1161:\nlda $10,5\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\nsubl $10,$27,$10\ncmpeq $10,3,$23\nbne $23,L.1165\nlda $13,115\ncmpeq $14,$31,$23\nbne $23,L.1167\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1167:\nL.1165:\nlda $10,5\nlda $27,2\nstq $27,-80+256($sp)\nsll $10,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\nsubq $27,$25,$27\nmov $27,$10\ncmpeq $10,3,$23\nbne $23,L.1169\nlda $13,116\ncmpeq $14,$31,$23\nbne $23,L.1171\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1171:\nL.1169:\nlda $10,5\nlda $27,2\nstl $27,-84+256($sp)\nmov $10,$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nsubl $27,$25,$27\nzap $27,240,$27\nmov $27,$10\ncmpeq $10,3,$23\nbne $23,L.1173\nlda $13,117\ncmpeq $14,$31,$23\nbne $23,L.1175\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1175:\nL.1173:\nlda $10,5\nlds $f7,L.527\nstq $10,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\nsubs $f30,$f7,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $10,-56+256($sp)\ncmpeq $10,3,$23\nbne $23,L.1177\nlda $13,118\ncmpeq $14,$31,$23\nbne $23,L.1179\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1179:\nL.1177:\nlda $10,5\nldt $f6,L.414\nstq $10,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\nsubt $f30,$f6,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $10,-56+256($sp)\ncmpeq $10,3,$23\nbne $23,L.1181\nlda $13,119\ncmpeq $14,$31,$23\nbne $23,L.1183\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1183:\nL.1181:\nlda $9,5\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsubq $9,$27,$9\ncmpeq $9,3,$23\nbne $23,L.1185\nlda $13,120\ncmpeq $14,$31,$23\nbne $23,L.1187\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1187:\nL.1185:\nlda $9,5\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsubq $9,$27,$9\ncmpeq $9,3,$23\nbne $23,L.1189\nlda $13,121\ncmpeq $14,$31,$23\nbne $23,L.1191\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1191:\nL.1189:\nlda $9,5\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\nsubq $9,$27,$9\ncmpeq $9,3,$23\nbne $23,L.1193\nlda $13,122\ncmpeq $14,$31,$23\nbne $23,L.1195\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1195:\nL.1193:\nlda $9,5\nlda $27,2\nstq $27,-80+256($sp)\nldq $27,-80+256($sp)\nsubq $9,$27,$9\ncmpeq $9,3,$23\nbne $23,L.1197\nlda $13,123\ncmpeq $14,$31,$23\nbne $23,L.1199\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1199:\nL.1197:\nlda $9,5\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nsubq $9,$27,$9\ncmpeq $9,3,$23\nbne $23,L.1201\nlda $13,124\ncmpeq $14,$31,$23\nbne $23,L.1203\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1203:\nL.1201:\nlda $9,5\nlds $f7,L.527\nstq $9,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\nsubs $f30,$f7,$f30\ncvttqc $f30,$f1\nstt $f1,-56+256($sp)\nldq $9,-56+256($sp)\ncmpeq $9,3,$23\nbne $23,L.1205\nlda $13,125\ncmpeq $14,$31,$23\nbne $23,L.1207\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1207:\nL.1205:\nlda $9,5\nldt $f6,L.414\nstq $9,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\nsubt $f30,$f6,$f30\ncvttqc $f30,$f1\nstt $f1,-56+256($sp)\nldq $9,-56+256($sp)\ncmpeq $9,3,$23\nbne $23,L.1209\nlda $13,126\ncmpeq $14,$31,$23\nbne $23,L.1211\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1211:\nL.1209:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstb $27,-61+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,-61+256($sp)\nldb $25,($25)\nsubl $27,$25,$27\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,3\ncmpeq $27,$25,$23\nbne $23,L.1213\nlda $13,127\ncmpeq $14,$31,$23\nbne $23,L.1215\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1215:\nL.1213:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstw $27,-64+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,-64+256($sp)\nldw $25,($25)\nsubl $27,$25,$27\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,3\ncmpeq $27,$25,$23\nbne $23,L.1217\nlda $13,128\ncmpeq $14,$31,$23\nbne $23,L.1219\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1219:\nL.1217:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldl $25,-68+256($sp)\nsubl $27,$25,$27\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,3\ncmpeq $27,$25,$23\nbne $23,L.1221\nlda $13,129\ncmpeq $14,$31,$23\nbne $23,L.1223\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1223:\nL.1221:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstq $27,-80+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldq $25,-80+256($sp)\nsubq $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,3\ncmpeq $27,$25,$23\nbne $23,L.1225\nlda $13,130\ncmpeq $14,$31,$23\nbne $23,L.1227\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1227:\nL.1225:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nsubl $27,$25,$27\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,3\ncmpeq $27,$25,$23\nbne $23,L.1229\nlda $13,131\ncmpeq $14,$31,$23\nbne $23,L.1231\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1231:\nL.1229:\nlda $27,5\nstl $27,-60+256($sp)\nlds $f7,L.527\nldl $27,-60+256($sp)\nzap $27,240,$27\nldt $f30,L.594\nsrl $27,1,$25\nstq $25,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f30\ncvtts $f30,$f30\nsubs $f30,$f7,$f30\nlds $f29,L.826\ncmptlt $f30,$f29,$f1\nfbne $f1,L.1234\nsubs $f30,$f29,$f29\ncvttqc $f29,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\naddl $27,0x80000000,$27\nzap $27,240,$27\nstl $27,-128+256($sp)\nbr L.1235\nL.1234:\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nstl $27,-128+256($sp)\nL.1235:\nldl $27,-128+256($sp)\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,3\ncmpeq $27,$25,$23\nbne $23,L.1236\nlda $13,132\ncmpeq $14,$31,$23\nbne $23,L.1238\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1238:\nL.1236:\nlda $27,5\nstl $27,-60+256($sp)\nldt $f6,L.414\nldl $27,-60+256($sp)\nzap $27,240,$27\nldt $f30,L.594\nsrl $27,1,$25\nstq $25,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f30\nsubt $f30,$f6,$f30\nldt $f29,L.834\ncmptlt $f30,$f29,$f1\nfbne $f1,L.1241\nsubt $f30,$f29,$f29\ncvttqc $f29,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\naddl $27,0x80000000,$27\nzap $27,240,$27\nstl $27,-132+256($sp)\nbr L.1242\nL.1241:\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nstl $27,-132+256($sp)\nL.1242:\nldl $27,-132+256($sp)\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,3\ncmpeq $27,$25,$23\nbne $23,L.1243\nlda $13,133\ncmpeq $14,$31,$23\nbne $23,L.1245\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1245:\nL.1243:\nlds $f9,L.839\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\nsubs $f9,$f30,$f9\nlds $f30,L.1249\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1247\nlda $13,134\ncmpeq $14,$31,$23\nbne $23,L.1250\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1250:\nL.1247:\nlds $f9,L.839\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\nsubs $f9,$f30,$f9\nlds $f30,L.1249\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1252\nlda $13,135\ncmpeq $14,$31,$23\nbne $23,L.1254\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1254:\nL.1252:\nlds $f9,L.839\nlda $27,2\nstl $27,-68+256($sp)\nlds $f30,-68+256($sp)\ncvtlq $f30,$f30\ncvtqs $f30,$f30\nsubs $f9,$f30,$f9\nlds $f30,L.1249\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1256\nlda $13,136\ncmpeq $14,$31,$23\nbne $23,L.1258\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1258:\nL.1256:\nlds $f9,L.839\nlda $27,2\nstq $27,-80+256($sp)\nldt $f30,-80+256($sp)\ncvtqs $f30,$f30\nsubs $f9,$f30,$f9\nlds $f30,L.1249\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1260\nlda $13,137\ncmpeq $14,$31,$23\nbne $23,L.1262\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1262:\nL.1260:\nlds $f9,L.839\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nldt $f30,L.594\nsrl $27,1,$25\nstq $25,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f30\ncvtts $f30,$f30\nsubs $f9,$f30,$f9\nlds $f30,L.1249\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1264\nlda $13,138\ncmpeq $14,$31,$23\nbne $23,L.1266\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1266:\nL.1264:\nlds $f9,L.839\nlds $f7,L.527\nsubs $f9,$f7,$f9\nlds $f30,L.1249\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1268\nlda $13,139\ncmpeq $14,$31,$23\nbne $23,L.1270\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1270:\nL.1268:\nlds $f9,L.839\nldt $f6,L.414\ncvtst $f9,$f30\nsubt $f30,$f6,$f30\ncvtts $f30,$f9\nlds $f30,L.1249\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1272\nlda $13,140\ncmpeq $14,$31,$23\nbne $23,L.1274\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1274:\nL.1272:\nldt $f8,L.868\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\nsubt $f8,$f30,$f8\nldt $f30,L.1278\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1276\nlda $13,141\ncmpeq $14,$31,$23\nbne $23,L.1279\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1279:\nL.1276:\nldt $f8,L.868\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\nsubt $f8,$f30,$f8\nldt $f30,L.1278\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1281\nlda $13,142\ncmpeq $14,$31,$23\nbne $23,L.1283\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1283:\nL.1281:\nldt $f8,L.868\nlda $27,2\nstl $27,-68+256($sp)\nlds $f30,-68+256($sp)\ncvtlq $f30,$f30\ncvtqt $f30,$f30\nsubt $f8,$f30,$f8\nldt $f30,L.1278\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1285\nlda $13,143\ncmpeq $14,$31,$23\nbne $23,L.1287\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1287:\nL.1285:\nldt $f8,L.868\nlda $27,2\nstq $27,-80+256($sp)\nldt $f30,-80+256($sp)\ncvtqt $f30,$f30\nsubt $f8,$f30,$f8\nldt $f30,L.1278\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1289\nlda $13,144\ncmpeq $14,$31,$23\nbne $23,L.1291\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1291:\nL.1289:\nldt $f8,L.868\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nldt $f30,L.594\nsrl $27,1,$25\nstq $25,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f30\nsubt $f8,$f30,$f8\nldt $f30,L.1278\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1293\nlda $13,145\ncmpeq $14,$31,$23\nbne $23,L.1295\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1295:\nL.1293:\nldt $f8,L.868\nlds $f7,L.527\ncvtst $f7,$f30\nsubt $f8,$f30,$f8\nldt $f30,L.1278\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1297\nlda $13,146\ncmpeq $14,$31,$23\nbne $23,L.1299\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1299:\nL.1297:\nldt $f8,L.868\nldt $f6,L.414\nsubt $f8,$f6,$f8\nldt $f30,L.1278\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1301\nlda $13,147\ncmpeq $14,$31,$23\nbne $23,L.1303\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1303:\nL.1301:\nlda $12,5\nlda $27,2\nstb $27,-61+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nlda $25,-61+256($sp)\nldb $25,($25)\nmull $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,10,$23\nbne $23,L.1305\nlda $13,148\ncmpeq $14,$31,$23\nbne $23,L.1307\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1307:\nL.1305:\nlda $12,5\nlda $27,2\nstw $27,-64+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nlda $25,-64+256($sp)\nldw $25,($25)\nmull $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,10,$23\nbne $23,L.1309\nlda $13,149\ncmpeq $14,$31,$23\nbne $23,L.1311\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1311:\nL.1309:\nlda $12,5\nlda $27,2\nstl $27,-68+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldl $25,-68+256($sp)\nmull $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,10,$23\nbne $23,L.1313\nlda $13,150\ncmpeq $14,$31,$23\nbne $23,L.1315\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1315:\nL.1313:\nlda $12,5\nlda $27,2\nstq $27,-80+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\nmulq $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,10,$23\nbne $23,L.1317\nlda $13,151\ncmpeq $14,$31,$23\nbne $23,L.1319\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1319:\nL.1317:\nlda $12,5\nlda $27,2\nstl $27,-84+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nmull $27,$25,$27\nzap $27,240,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,10,$23\nbne $23,L.1321\nlda $13,152\ncmpeq $14,$31,$23\nbne $23,L.1323\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1323:\nL.1321:\nlda $12,5\nlds $f7,L.527\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\nmuls $f30,$f7,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,10,$23\nbne $23,L.1325\nlda $13,153\ncmpeq $14,$31,$23\nbne $23,L.1327\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1327:\nL.1325:\nlda $12,5\nldt $f6,L.414\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\nmult $f30,$f6,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,10,$23\nbne $23,L.1329\nlda $13,154\ncmpeq $14,$31,$23\nbne $23,L.1331\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1331:\nL.1329:\nlda $11,5\nlda $27,2\nstb $27,-61+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-61+256($sp)\nldb $25,($25)\nmull $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,10,$23\nbne $23,L.1333\nlda $13,155\ncmpeq $14,$31,$23\nbne $23,L.1335\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1335:\nL.1333:\nlda $11,5\nlda $27,2\nstw $27,-64+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-64+256($sp)\nldw $25,($25)\nmull $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,10,$23\nbne $23,L.1337\nlda $13,156\ncmpeq $14,$31,$23\nbne $23,L.1339\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1339:\nL.1337:\nlda $11,5\nlda $27,2\nstl $27,-68+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldl $25,-68+256($sp)\nmull $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,10,$23\nbne $23,L.1341\nlda $13,157\ncmpeq $14,$31,$23\nbne $23,L.1343\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1343:\nL.1341:\nlda $11,5\nlda $27,2\nstq $27,-80+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\nmulq $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,10,$23\nbne $23,L.1345\nlda $13,158\ncmpeq $14,$31,$23\nbne $23,L.1347\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1347:\nL.1345:\nlda $11,5\nlda $27,2\nstl $27,-84+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nmull $27,$25,$27\nzap $27,240,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,10,$23\nbne $23,L.1349\nlda $13,159\ncmpeq $14,$31,$23\nbne $23,L.1351\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1351:\nL.1349:\nlda $11,5\nlds $f7,L.527\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\nmuls $f30,$f7,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,10,$23\nbne $23,L.1353\nlda $13,160\ncmpeq $14,$31,$23\nbne $23,L.1355\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1355:\nL.1353:\nlda $11,5\nldt $f6,L.414\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\nmult $f30,$f6,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,10,$23\nbne $23,L.1357\nlda $13,161\ncmpeq $14,$31,$23\nbne $23,L.1359\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1359:\nL.1357:\nlda $10,5\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nmull $10,$27,$10\ncmpeq $10,10,$23\nbne $23,L.1361\nlda $13,162\ncmpeq $14,$31,$23\nbne $23,L.1363\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1363:\nL.1361:\nlda $10,5\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nmull $10,$27,$10\ncmpeq $10,10,$23\nbne $23,L.1365\nlda $13,163\ncmpeq $14,$31,$23\nbne $23,L.1367\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1367:\nL.1365:\nlda $10,5\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\nmull $10,$27,$10\ncmpeq $10,10,$23\nbne $23,L.1369\nlda $13,164\ncmpeq $14,$31,$23\nbne $23,L.1371\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1371:\nL.1369:\nlda $10,5\nlda $27,2\nstq $27,-80+256($sp)\nsll $10,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\nmulq $27,$25,$27\nmov $27,$10\ncmpeq $10,10,$23\nbne $23,L.1373\nlda $13,165\ncmpeq $14,$31,$23\nbne $23,L.1375\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1375:\nL.1373:\nlda $10,5\nlda $27,2\nstl $27,-84+256($sp)\nmov $10,$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nmull $27,$25,$27\nzap $27,240,$27\nmov $27,$10\ncmpeq $10,10,$23\nbne $23,L.1377\nlda $13,166\ncmpeq $14,$31,$23\nbne $23,L.1379\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1379:\nL.1377:\nlda $10,5\nlds $f7,L.527\nstq $10,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\nmuls $f30,$f7,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $10,-56+256($sp)\ncmpeq $10,10,$23\nbne $23,L.1381\nlda $13,167\ncmpeq $14,$31,$23\nbne $23,L.1383\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1383:\nL.1381:\nlda $10,5\nldt $f6,L.414\nstq $10,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\nmult $f30,$f6,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $10,-56+256($sp)\ncmpeq $10,10,$23\nbne $23,L.1385\nlda $13,168\ncmpeq $14,$31,$23\nbne $23,L.1387\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1387:\nL.1385:\nlda $9,5\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nmulq $9,$27,$9\ncmpeq $9,10,$23\nbne $23,L.1389\nlda $13,169\ncmpeq $14,$31,$23\nbne $23,L.1391\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1391:\nL.1389:\nlda $9,5\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nmulq $9,$27,$9\ncmpeq $9,10,$23\nbne $23,L.1393\nlda $13,170\ncmpeq $14,$31,$23\nbne $23,L.1395\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1395:\nL.1393:\nlda $9,5\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\nmulq $9,$27,$9\ncmpeq $9,10,$23\nbne $23,L.1397\nlda $13,171\ncmpeq $14,$31,$23\nbne $23,L.1399\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1399:\nL.1397:\nlda $9,5\nlda $27,2\nstq $27,-80+256($sp)\nldq $27,-80+256($sp)\nmulq $9,$27,$9\ncmpeq $9,10,$23\nbne $23,L.1401\nlda $13,172\ncmpeq $14,$31,$23\nbne $23,L.1403\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1403:\nL.1401:\nlda $9,5\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nmulq $9,$27,$9\ncmpeq $9,10,$23\nbne $23,L.1405\nlda $13,173\ncmpeq $14,$31,$23\nbne $23,L.1407\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1407:\nL.1405:\nlda $9,5\nlds $f7,L.527\nstq $9,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\nmuls $f30,$f7,$f30\ncvttqc $f30,$f1\nstt $f1,-56+256($sp)\nldq $9,-56+256($sp)\ncmpeq $9,10,$23\nbne $23,L.1409\nlda $13,174\ncmpeq $14,$31,$23\nbne $23,L.1411\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1411:\nL.1409:\nlda $9,5\nldt $f6,L.414\nstq $9,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\nmult $f30,$f6,$f30\ncvttqc $f30,$f1\nstt $f1,-56+256($sp)\nldq $9,-56+256($sp)\ncmpeq $9,10,$23\nbne $23,L.1413\nlda $13,175\ncmpeq $14,$31,$23\nbne $23,L.1415\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1415:\nL.1413:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstb $27,-61+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,-61+256($sp)\nldb $25,($25)\nmull $27,$25,$27\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,10\ncmpeq $27,$25,$23\nbne $23,L.1417\nlda $13,176\ncmpeq $14,$31,$23\nbne $23,L.1419\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1419:\nL.1417:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstw $27,-64+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,-64+256($sp)\nldw $25,($25)\nmull $27,$25,$27\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,10\ncmpeq $27,$25,$23\nbne $23,L.1421\nlda $13,177\ncmpeq $14,$31,$23\nbne $23,L.1423\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1423:\nL.1421:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldl $25,-68+256($sp)\nmull $27,$25,$27\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,10\ncmpeq $27,$25,$23\nbne $23,L.1425\nlda $13,178\ncmpeq $14,$31,$23\nbne $23,L.1427\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1427:\nL.1425:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstq $27,-80+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldq $25,-80+256($sp)\nmulq $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,10\ncmpeq $27,$25,$23\nbne $23,L.1429\nlda $13,179\ncmpeq $14,$31,$23\nbne $23,L.1431\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1431:\nL.1429:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nmull $27,$25,$27\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,10\ncmpeq $27,$25,$23\nbne $23,L.1433\nlda $13,180\ncmpeq $14,$31,$23\nbne $23,L.1435\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1435:\nL.1433:\nlda $27,5\nstl $27,-60+256($sp)\nlds $f7,L.527\nldl $27,-60+256($sp)\nzap $27,240,$27\nldt $f30,L.594\nsrl $27,1,$25\nstq $25,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f30\ncvtts $f30,$f30\nmuls $f30,$f7,$f30\nlds $f29,L.826\ncmptlt $f30,$f29,$f1\nfbne $f1,L.1438\nsubs $f30,$f29,$f29\ncvttqc $f29,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\naddl $27,0x80000000,$27\nzap $27,240,$27\nstl $27,-136+256($sp)\nbr L.1439\nL.1438:\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nstl $27,-136+256($sp)\nL.1439:\nldl $27,-136+256($sp)\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,10\ncmpeq $27,$25,$23\nbne $23,L.1440\nlda $13,181\ncmpeq $14,$31,$23\nbne $23,L.1442\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1442:\nL.1440:\nlda $27,5\nstl $27,-60+256($sp)\nldt $f6,L.414\nldl $27,-60+256($sp)\nzap $27,240,$27\nldt $f30,L.594\nsrl $27,1,$25\nstq $25,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f30\nmult $f30,$f6,$f30\nldt $f29,L.834\ncmptlt $f30,$f29,$f1\nfbne $f1,L.1445\nsubt $f30,$f29,$f29\ncvttqc $f29,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\naddl $27,0x80000000,$27\nzap $27,240,$27\nstl $27,-140+256($sp)\nbr L.1446\nL.1445:\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nstl $27,-140+256($sp)\nL.1446:\nldl $27,-140+256($sp)\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,10\ncmpeq $27,$25,$23\nbne $23,L.1447\nlda $13,182\ncmpeq $14,$31,$23\nbne $23,L.1449\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1449:\nL.1447:\nlds $f9,L.839\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\nmuls $f9,$f30,$f9\nlds $f30,L.1453\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1451\nlda $13,183\ncmpeq $14,$31,$23\nbne $23,L.1454\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1454:\nL.1451:\nlds $f9,L.839\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\nmuls $f9,$f30,$f9\nlds $f30,L.1453\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1456\nlda $13,184\ncmpeq $14,$31,$23\nbne $23,L.1458\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1458:\nL.1456:\nlds $f9,L.839\nlda $27,2\nstl $27,-68+256($sp)\nlds $f30,-68+256($sp)\ncvtlq $f30,$f30\ncvtqs $f30,$f30\nmuls $f9,$f30,$f9\nlds $f30,L.1453\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1460\nlda $13,185\ncmpeq $14,$31,$23\nbne $23,L.1462\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1462:\nL.1460:\nlds $f9,L.839\nlda $27,2\nstq $27,-80+256($sp)\nldt $f30,-80+256($sp)\ncvtqs $f30,$f30\nmuls $f9,$f30,$f9\nlds $f30,L.1453\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1464\nlda $13,186\ncmpeq $14,$31,$23\nbne $23,L.1466\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1466:\nL.1464:\nlds $f9,L.839\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nldt $f30,L.594\nsrl $27,1,$25\nstq $25,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f30\ncvtts $f30,$f30\nmuls $f9,$f30,$f9\nlds $f30,L.1453\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1468\nlda $13,187\ncmpeq $14,$31,$23\nbne $23,L.1470\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1470:\nL.1468:\nlds $f9,L.839\nlds $f7,L.527\nmuls $f9,$f7,$f9\nlds $f30,L.1453\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1472\nlda $13,188\ncmpeq $14,$31,$23\nbne $23,L.1474\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1474:\nL.1472:\nlds $f9,L.839\nldt $f6,L.414\ncvtst $f9,$f30\nmult $f30,$f6,$f30\ncvtts $f30,$f9\nlds $f30,L.1453\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1476\nlda $13,189\ncmpeq $14,$31,$23\nbne $23,L.1478\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1478:\nL.1476:\nldt $f8,L.868\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\nmult $f8,$f30,$f8\nldt $f30,L.1482\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1480\nlda $13,190\ncmpeq $14,$31,$23\nbne $23,L.1483\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1483:\nL.1480:\nldt $f8,L.868\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\nmult $f8,$f30,$f8\nldt $f30,L.1482\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1485\nlda $13,191\ncmpeq $14,$31,$23\nbne $23,L.1487\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1487:\nL.1485:\nldt $f8,L.868\nlda $27,2\nstl $27,-68+256($sp)\nlds $f30,-68+256($sp)\ncvtlq $f30,$f30\ncvtqt $f30,$f30\nmult $f8,$f30,$f8\nldt $f30,L.1482\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1489\nlda $13,192\ncmpeq $14,$31,$23\nbne $23,L.1491\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1491:\nL.1489:\nldt $f8,L.868\nlda $27,2\nstq $27,-80+256($sp)\nldt $f30,-80+256($sp)\ncvtqt $f30,$f30\nmult $f8,$f30,$f8\nldt $f30,L.1482\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1493\nlda $13,193\ncmpeq $14,$31,$23\nbne $23,L.1495\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1495:\nL.1493:\nldt $f8,L.868\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nldt $f30,L.594\nsrl $27,1,$25\nstq $25,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f30\nmult $f8,$f30,$f8\nldt $f30,L.1482\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1497\nlda $13,194\ncmpeq $14,$31,$23\nbne $23,L.1499\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1499:\nL.1497:\nldt $f8,L.868\nlds $f7,L.527\ncvtst $f7,$f30\nmult $f8,$f30,$f8\nldt $f30,L.1482\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1501\nlda $13,195\ncmpeq $14,$31,$23\nbne $23,L.1503\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1503:\nL.1501:\nldt $f8,L.868\nldt $f6,L.414\nmult $f8,$f6,$f8\nldt $f30,L.1482\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1505\nlda $13,196\ncmpeq $14,$31,$23\nbne $23,L.1507\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1507:\nL.1505:\nlda $12,5\nlda $27,2\nstb $27,-61+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nlda $25,-61+256($sp)\nldb $25,($25)\ndivl $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,2,$23\nbne $23,L.1509\nlda $13,197\ncmpeq $14,$31,$23\nbne $23,L.1511\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1511:\nL.1509:\nlda $12,5\nlda $27,2\nstw $27,-64+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nlda $25,-64+256($sp)\nldw $25,($25)\ndivl $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,2,$23\nbne $23,L.1513\nlda $13,198\ncmpeq $14,$31,$23\nbne $23,L.1515\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1515:\nL.1513:\nlda $12,5\nlda $27,2\nstl $27,-68+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldl $25,-68+256($sp)\ndivl $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,2,$23\nbne $23,L.1517\nlda $13,199\ncmpeq $14,$31,$23\nbne $23,L.1519\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1519:\nL.1517:\nlda $12,5\nlda $27,2\nstq $27,-80+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\ndivq $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,2,$23\nbne $23,L.1521\nlda $13,200\ncmpeq $14,$31,$23\nbne $23,L.1523\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1523:\nL.1521:\nlda $12,5\nlda $27,2\nstl $27,-84+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldl $25,-84+256($sp)\nzap $25,240,$25\ndivlu $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,2,$23\nbne $23,L.1525\nlda $13,201\ncmpeq $14,$31,$23\nbne $23,L.1527\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1527:\nL.1525:\nlda $12,5\nlds $f7,L.527\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\ndivs $f30,$f7,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,2,$23\nbne $23,L.1529\nlda $13,202\ncmpeq $14,$31,$23\nbne $23,L.1531\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1531:\nL.1529:\nlda $12,5\nldt $f6,L.414\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\ndivt $f30,$f6,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,2,$23\nbne $23,L.1533\nlda $13,203\ncmpeq $14,$31,$23\nbne $23,L.1535\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1535:\nL.1533:\nlda $11,5\nlda $27,2\nstb $27,-61+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-61+256($sp)\nldb $25,($25)\ndivl $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,2,$23\nbne $23,L.1537\nlda $13,204\ncmpeq $14,$31,$23\nbne $23,L.1539\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1539:\nL.1537:\nlda $11,5\nlda $27,2\nstw $27,-64+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-64+256($sp)\nldw $25,($25)\ndivl $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,2,$23\nbne $23,L.1541\nlda $13,205\ncmpeq $14,$31,$23\nbne $23,L.1543\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1543:\nL.1541:\nlda $11,5\nlda $27,2\nstl $27,-68+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldl $25,-68+256($sp)\ndivl $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,2,$23\nbne $23,L.1545\nlda $13,206\ncmpeq $14,$31,$23\nbne $23,L.1547\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1547:\nL.1545:\nlda $11,5\nlda $27,2\nstq $27,-80+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\ndivq $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,2,$23\nbne $23,L.1549\nlda $13,207\ncmpeq $14,$31,$23\nbne $23,L.1551\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1551:\nL.1549:\nlda $11,5\nlda $27,2\nstl $27,-84+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldl $25,-84+256($sp)\nzap $25,240,$25\ndivlu $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,2,$23\nbne $23,L.1553\nlda $13,208\ncmpeq $14,$31,$23\nbne $23,L.1555\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1555:\nL.1553:\nlda $11,5\nlds $f7,L.527\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\ndivs $f30,$f7,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,2,$23\nbne $23,L.1557\nlda $13,209\ncmpeq $14,$31,$23\nbne $23,L.1559\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1559:\nL.1557:\nlda $11,5\nldt $f6,L.414\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\ndivt $f30,$f6,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,2,$23\nbne $23,L.1561\nlda $13,210\ncmpeq $14,$31,$23\nbne $23,L.1563\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1563:\nL.1561:\nlda $10,5\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\ndivl $10,$27,$10\ncmpeq $10,2,$23\nbne $23,L.1565\nlda $13,211\ncmpeq $14,$31,$23\nbne $23,L.1567\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1567:\nL.1565:\nlda $10,5\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\ndivl $10,$27,$10\ncmpeq $10,2,$23\nbne $23,L.1569\nlda $13,212\ncmpeq $14,$31,$23\nbne $23,L.1571\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1571:\nL.1569:\nlda $10,5\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\ndivl $10,$27,$10\ncmpeq $10,2,$23\nbne $23,L.1573\nlda $13,213\ncmpeq $14,$31,$23\nbne $23,L.1575\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1575:\nL.1573:\nlda $10,5\nlda $27,2\nstq $27,-80+256($sp)\nsll $10,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\ndivq $27,$25,$27\nmov $27,$10\ncmpeq $10,2,$23\nbne $23,L.1577\nlda $13,214\ncmpeq $14,$31,$23\nbne $23,L.1579\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1579:\nL.1577:\nlda $10,5\nlda $27,2\nstl $27,-84+256($sp)\nmov $10,$27\nldl $25,-84+256($sp)\nzap $25,240,$25\ndivlu $27,$25,$27\nmov $27,$10\ncmpeq $10,2,$23\nbne $23,L.1581\nlda $13,215\ncmpeq $14,$31,$23\nbne $23,L.1583\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1583:\nL.1581:\nlda $10,5\nlds $f7,L.527\nstq $10,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\ndivs $f30,$f7,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $10,-56+256($sp)\ncmpeq $10,2,$23\nbne $23,L.1585\nlda $13,216\ncmpeq $14,$31,$23\nbne $23,L.1587\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1587:\nL.1585:\nlda $10,5\nldt $f6,L.414\nstq $10,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\ndivt $f30,$f6,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $10,-56+256($sp)\ncmpeq $10,2,$23\nbne $23,L.1589\nlda $13,217\ncmpeq $14,$31,$23\nbne $23,L.1591\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1591:\nL.1589:\nlda $9,5\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\ndivq $9,$27,$9\ncmpeq $9,2,$23\nbne $23,L.1593\nlda $13,218\ncmpeq $14,$31,$23\nbne $23,L.1595\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1595:\nL.1593:\nlda $9,5\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\ndivq $9,$27,$9\ncmpeq $9,2,$23\nbne $23,L.1597\nlda $13,219\ncmpeq $14,$31,$23\nbne $23,L.1599\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1599:\nL.1597:\nlda $9,5\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\ndivq $9,$27,$9\ncmpeq $9,2,$23\nbne $23,L.1601\nlda $13,220\ncmpeq $14,$31,$23\nbne $23,L.1603\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1603:\nL.1601:\nlda $9,5\nlda $27,2\nstq $27,-80+256($sp)\nldq $27,-80+256($sp)\ndivq $9,$27,$9\ncmpeq $9,2,$23\nbne $23,L.1605\nlda $13,221\ncmpeq $14,$31,$23\nbne $23,L.1607\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1607:\nL.1605:\nlda $9,5\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\ndivq $9,$27,$9\ncmpeq $9,2,$23\nbne $23,L.1609\nlda $13,222\ncmpeq $14,$31,$23\nbne $23,L.1611\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1611:\nL.1609:\nlda $9,5\nlds $f7,L.527\nstq $9,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\ndivs $f30,$f7,$f30\ncvttqc $f30,$f1\nstt $f1,-56+256($sp)\nldq $9,-56+256($sp)\ncmpeq $9,2,$23\nbne $23,L.1613\nlda $13,223\ncmpeq $14,$31,$23\nbne $23,L.1615\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1615:\nL.1613:\nlda $9,5\nldt $f6,L.414\nstq $9,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\ndivt $f30,$f6,$f30\ncvttqc $f30,$f1\nstt $f1,-56+256($sp)\nldq $9,-56+256($sp)\ncmpeq $9,2,$23\nbne $23,L.1617\nlda $13,224\ncmpeq $14,$31,$23\nbne $23,L.1619\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1619:\nL.1617:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstb $27,-61+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,-61+256($sp)\nldb $25,($25)\ndivlu $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,2\ncmpeq $27,$25,$23\nbne $23,L.1621\nlda $13,225\ncmpeq $14,$31,$23\nbne $23,L.1623\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1623:\nL.1621:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstw $27,-64+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,-64+256($sp)\nldw $25,($25)\ndivlu $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,2\ncmpeq $27,$25,$23\nbne $23,L.1625\nlda $13,226\ncmpeq $14,$31,$23\nbne $23,L.1627\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1627:\nL.1625:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldl $25,-68+256($sp)\ndivlu $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,2\ncmpeq $27,$25,$23\nbne $23,L.1629\nlda $13,227\ncmpeq $14,$31,$23\nbne $23,L.1631\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1631:\nL.1629:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstq $27,-80+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldq $25,-80+256($sp)\ndivq $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,2\ncmpeq $27,$25,$23\nbne $23,L.1633\nlda $13,228\ncmpeq $14,$31,$23\nbne $23,L.1635\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1635:\nL.1633:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstl $27,-144+256($sp)\nstl $27,-84+256($sp)\nldl $25,-60+256($sp)\nzap $25,240,$25\nldl $22,-84+256($sp)\nzap $22,240,$22\ndivlu $25,$22,$25\nstl $25,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldl $25,-144+256($sp)\nzap $25,240,$25\ncmpeq $27,$25,$23\nbne $23,L.1637\nlda $13,229\ncmpeq $14,$31,$23\nbne $23,L.1639\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1639:\nL.1637:\nlda $27,5\nstl $27,-60+256($sp)\nlds $f7,L.527\nldl $27,-60+256($sp)\nzap $27,240,$27\nldt $f30,L.594\nsrl $27,1,$25\nstq $25,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f30\ncvtts $f30,$f30\ndivs $f30,$f7,$f30\nlds $f29,L.826\ncmptlt $f30,$f29,$f1\nfbne $f1,L.1642\nsubs $f30,$f29,$f29\ncvttqc $f29,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\naddl $27,0x80000000,$27\nzap $27,240,$27\nstl $27,-148+256($sp)\nbr L.1643\nL.1642:\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nstl $27,-148+256($sp)\nL.1643:\nldl $27,-148+256($sp)\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,2\ncmpeq $27,$25,$23\nbne $23,L.1644\nlda $13,230\ncmpeq $14,$31,$23\nbne $23,L.1646\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1646:\nL.1644:\nlda $27,5\nstl $27,-60+256($sp)\nldt $f6,L.414\nldl $27,-60+256($sp)\nzap $27,240,$27\nldt $f30,L.594\nsrl $27,1,$25\nstq $25,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f30\ndivt $f30,$f6,$f30\nldt $f29,L.834\ncmptlt $f30,$f29,$f1\nfbne $f1,L.1649\nsubt $f30,$f29,$f29\ncvttqc $f29,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\naddl $27,0x80000000,$27\nzap $27,240,$27\nstl $27,-152+256($sp)\nbr L.1650\nL.1649:\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nstl $27,-152+256($sp)\nL.1650:\nldl $27,-152+256($sp)\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,2\ncmpeq $27,$25,$23\nbne $23,L.1651\nlda $13,231\ncmpeq $14,$31,$23\nbne $23,L.1653\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1653:\nL.1651:\nlds $f9,L.839\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\ndivs $f9,$f30,$f9\ncvtst $f9,$f30\nldt $f29,L.1657\ncmpteq $f30,$f29,$f1\nfbne $f1,L.1655\nlda $13,232\ncmpeq $14,$31,$23\nbne $23,L.1658\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1658:\nL.1655:\nlds $f9,L.839\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqs $f30,$f30\ndivs $f9,$f30,$f9\ncvtst $f9,$f30\nldt $f29,L.1657\ncmpteq $f30,$f29,$f1\nfbne $f1,L.1660\nlda $13,233\ncmpeq $14,$31,$23\nbne $23,L.1662\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1662:\nL.1660:\nlds $f9,L.839\nlda $27,2\nstl $27,-68+256($sp)\nlds $f30,-68+256($sp)\ncvtlq $f30,$f30\ncvtqs $f30,$f30\ndivs $f9,$f30,$f9\ncvtst $f9,$f30\nldt $f29,L.1657\ncmpteq $f30,$f29,$f1\nfbne $f1,L.1664\nlda $13,234\ncmpeq $14,$31,$23\nbne $23,L.1666\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1666:\nL.1664:\nlds $f9,L.839\nlda $27,2\nstq $27,-80+256($sp)\nldt $f30,-80+256($sp)\ncvtqs $f30,$f30\ndivs $f9,$f30,$f9\ncvtst $f9,$f30\nldt $f29,L.1657\ncmpteq $f30,$f29,$f1\nfbne $f1,L.1668\nlda $13,235\ncmpeq $14,$31,$23\nbne $23,L.1670\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1670:\nL.1668:\nlds $f9,L.839\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nldt $f30,L.594\nsrl $27,1,$25\nstq $25,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f30\ncvtts $f30,$f30\ndivs $f9,$f30,$f9\ncvtst $f9,$f30\nldt $f29,L.1657\ncmpteq $f30,$f29,$f1\nfbne $f1,L.1672\nlda $13,236\ncmpeq $14,$31,$23\nbne $23,L.1674\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1674:\nL.1672:\nlds $f9,L.839\nlds $f7,L.527\ndivs $f9,$f7,$f9\ncvtst $f9,$f30\nldt $f29,L.1657\ncmpteq $f30,$f29,$f1\nfbne $f1,L.1676\nlda $13,237\ncmpeq $14,$31,$23\nbne $23,L.1678\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1678:\nL.1676:\nlds $f9,L.839\nldt $f6,L.414\ncvtst $f9,$f30\ndivt $f30,$f6,$f30\ncvtts $f30,$f9\ncvtst $f9,$f30\nldt $f29,L.1657\ncmpteq $f30,$f29,$f1\nfbne $f1,L.1680\nlda $13,238\ncmpeq $14,$31,$23\nbne $23,L.1682\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1682:\nL.1680:\nldt $f8,L.868\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\ndivt $f8,$f30,$f8\nldt $f30,L.1657\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1684\nlda $13,239\ncmpeq $14,$31,$23\nbne $23,L.1686\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1686:\nL.1684:\nldt $f8,L.868\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nstq $27,-56+256($sp)\nldt $f30,-56+256($sp)\ncvtqt $f30,$f30\ndivt $f8,$f30,$f8\nldt $f30,L.1657\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1688\nlda $13,240\ncmpeq $14,$31,$23\nbne $23,L.1690\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1690:\nL.1688:\nldt $f8,L.868\nlda $27,2\nstl $27,-68+256($sp)\nlds $f30,-68+256($sp)\ncvtlq $f30,$f30\ncvtqt $f30,$f30\ndivt $f8,$f30,$f8\nldt $f30,L.1657\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1692\nlda $13,241\ncmpeq $14,$31,$23\nbne $23,L.1694\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1694:\nL.1692:\nldt $f8,L.868\nlda $27,2\nstq $27,-80+256($sp)\nldt $f30,-80+256($sp)\ncvtqt $f30,$f30\ndivt $f8,$f30,$f8\nldt $f30,L.1657\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1696\nlda $13,242\ncmpeq $14,$31,$23\nbne $23,L.1698\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1698:\nL.1696:\nldt $f8,L.868\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nldt $f30,L.594\nsrl $27,1,$25\nstq $25,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f30\ndivt $f8,$f30,$f8\nldt $f30,L.1657\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1700\nlda $13,243\ncmpeq $14,$31,$23\nbne $23,L.1702\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1702:\nL.1700:\nldt $f8,L.868\nlds $f7,L.527\ncvtst $f7,$f30\ndivt $f8,$f30,$f8\nldt $f30,L.1657\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1704\nlda $13,244\ncmpeq $14,$31,$23\nbne $23,L.1706\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1706:\nL.1704:\nldt $f8,L.868\nldt $f6,L.414\ndivt $f8,$f6,$f8\nldt $f30,L.1657\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1708\nlda $13,245\ncmpeq $14,$31,$23\nbne $23,L.1710\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1710:\nL.1708:\nlda $12,5\nlda $27,2\nstb $27,-61+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nlda $25,-61+256($sp)\nldb $25,($25)\nreml $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,1,$23\nbne $23,L.1712\nlda $13,246\ncmpeq $14,$31,$23\nbne $23,L.1714\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1714:\nL.1712:\nlda $12,5\nlda $27,2\nstw $27,-64+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nlda $25,-64+256($sp)\nldw $25,($25)\nreml $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,1,$23\nbne $23,L.1716\nlda $13,247\ncmpeq $14,$31,$23\nbne $23,L.1718\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1718:\nL.1716:\nlda $12,5\nlda $27,2\nstl $27,-68+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldl $25,-68+256($sp)\nreml $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,1,$23\nbne $23,L.1720\nlda $13,248\ncmpeq $14,$31,$23\nbne $23,L.1722\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1722:\nL.1720:\nlda $12,5\nlda $27,2\nstq $27,-80+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\nremq $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,1,$23\nbne $23,L.1724\nlda $13,249\ncmpeq $14,$31,$23\nbne $23,L.1726\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1726:\nL.1724:\nlda $12,5\nlda $27,2\nstl $27,-84+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nremlu $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,1,$23\nbne $23,L.1728\nlda $13,250\ncmpeq $14,$31,$23\nbne $23,L.1730\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1730:\nL.1728:\nlda $11,5\nlda $27,2\nstb $27,-61+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-61+256($sp)\nldb $25,($25)\nreml $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,1,$23\nbne $23,L.1732\nlda $13,251\ncmpeq $14,$31,$23\nbne $23,L.1734\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1734:\nL.1732:\nlda $11,5\nlda $27,2\nstw $27,-64+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-64+256($sp)\nldw $25,($25)\nreml $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,1,$23\nbne $23,L.1736\nlda $13,252\ncmpeq $14,$31,$23\nbne $23,L.1738\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1738:\nL.1736:\nlda $11,5\nlda $27,2\nstl $27,-68+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldl $25,-68+256($sp)\nreml $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,1,$23\nbne $23,L.1740\nlda $13,253\ncmpeq $14,$31,$23\nbne $23,L.1742\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1742:\nL.1740:\nlda $11,5\nlda $27,2\nstq $27,-80+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\nremq $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,1,$23\nbne $23,L.1744\nlda $13,254\ncmpeq $14,$31,$23\nbne $23,L.1746\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1746:\nL.1744:\nlda $11,5\nlda $27,2\nstl $27,-84+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nremlu $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,1,$23\nbne $23,L.1748\nlda $13,255\ncmpeq $14,$31,$23\nbne $23,L.1750\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1750:\nL.1748:\nlda $10,5\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nreml $10,$27,$10\ncmpeq $10,1,$23\nbne $23,L.1752\nlda $13,256\ncmpeq $14,$31,$23\nbne $23,L.1754\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1754:\nL.1752:\nlda $10,5\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nreml $10,$27,$10\ncmpeq $10,1,$23\nbne $23,L.1756\nlda $13,257\ncmpeq $14,$31,$23\nbne $23,L.1758\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1758:\nL.1756:\nlda $10,5\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\nreml $10,$27,$10\ncmpeq $10,1,$23\nbne $23,L.1760\nlda $13,258\ncmpeq $14,$31,$23\nbne $23,L.1762\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1762:\nL.1760:\nlda $10,5\nlda $27,2\nstq $27,-80+256($sp)\nsll $10,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\nremq $27,$25,$27\nmov $27,$10\ncmpeq $10,1,$23\nbne $23,L.1764\nlda $13,259\ncmpeq $14,$31,$23\nbne $23,L.1766\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1766:\nL.1764:\nlda $10,5\nlda $27,2\nstl $27,-84+256($sp)\nmov $10,$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nremlu $27,$25,$27\nmov $27,$10\ncmpeq $10,1,$23\nbne $23,L.1768\nlda $13,260\ncmpeq $14,$31,$23\nbne $23,L.1770\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1770:\nL.1768:\nlda $9,5\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nremq $9,$27,$9\ncmpeq $9,1,$23\nbne $23,L.1772\nlda $13,261\ncmpeq $14,$31,$23\nbne $23,L.1774\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1774:\nL.1772:\nlda $9,5\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nremq $9,$27,$9\ncmpeq $9,1,$23\nbne $23,L.1776\nlda $13,262\ncmpeq $14,$31,$23\nbne $23,L.1778\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1778:\nL.1776:\nlda $9,5\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\nremq $9,$27,$9\ncmpeq $9,1,$23\nbne $23,L.1780\nlda $13,263\ncmpeq $14,$31,$23\nbne $23,L.1782\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1782:\nL.1780:\nlda $9,5\nlda $27,2\nstq $27,-80+256($sp)\nldq $27,-80+256($sp)\nremq $9,$27,$9\ncmpeq $9,1,$23\nbne $23,L.1784\nlda $13,264\ncmpeq $14,$31,$23\nbne $23,L.1786\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1786:\nL.1784:\nlda $9,5\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nremq $9,$27,$9\ncmpeq $9,1,$23\nbne $23,L.1788\nlda $13,265\ncmpeq $14,$31,$23\nbne $23,L.1790\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1790:\nL.1788:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstb $27,-61+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,-61+256($sp)\nldb $25,($25)\nremlu $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,1\ncmpeq $27,$25,$23\nbne $23,L.1792\nlda $13,266\ncmpeq $14,$31,$23\nbne $23,L.1794\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1794:\nL.1792:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstw $27,-64+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,-64+256($sp)\nldw $25,($25)\nremlu $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,1\ncmpeq $27,$25,$23\nbne $23,L.1796\nlda $13,267\ncmpeq $14,$31,$23\nbne $23,L.1798\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1798:\nL.1796:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldl $25,-68+256($sp)\nremlu $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,1\ncmpeq $27,$25,$23\nbne $23,L.1800\nlda $13,268\ncmpeq $14,$31,$23\nbne $23,L.1802\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1802:\nL.1800:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstq $27,-80+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldq $25,-80+256($sp)\nremq $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,1\ncmpeq $27,$25,$23\nbne $23,L.1804\nlda $13,269\ncmpeq $14,$31,$23\nbne $23,L.1806\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1806:\nL.1804:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nremlu $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,1\ncmpeq $27,$25,$23\nbne $23,L.1808\nlda $13,270\ncmpeq $14,$31,$23\nbne $23,L.1810\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1810:\nL.1808:\nlda $12,5\nlda $27,2\nstb $27,-61+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nlda $25,-61+256($sp)\nldb $25,($25)\nsra $27,$25,$27\naddl $27,0,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,1,$23\nbne $23,L.1812\nlda $13,271\ncmpeq $14,$31,$23\nbne $23,L.1814\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1814:\nL.1812:\nlda $12,5\nlda $27,2\nstw $27,-64+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nlda $25,-64+256($sp)\nldw $25,($25)\nsra $27,$25,$27\naddl $27,0,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,1,$23\nbne $23,L.1816\nlda $13,272\ncmpeq $14,$31,$23\nbne $23,L.1818\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1818:\nL.1816:\nlda $12,5\nlda $27,2\nstl $27,-68+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldl $25,-68+256($sp)\nsra $27,$25,$27\naddl $27,0,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,1,$23\nbne $23,L.1820\nlda $13,273\ncmpeq $14,$31,$23\nbne $23,L.1822\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1822:\nL.1820:\nlda $12,5\nlda $27,2\nstq $27,-80+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldq $25,-80+256($sp)\nsra $27,$25,$27\naddl $27,0,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,1,$23\nbne $23,L.1824\nlda $13,274\ncmpeq $14,$31,$23\nbne $23,L.1826\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1826:\nL.1824:\nlda $12,5\nlda $27,2\nstl $27,-84+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nsra $27,$25,$27\naddl $27,0,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,1,$23\nbne $23,L.1828\nlda $13,275\ncmpeq $14,$31,$23\nbne $23,L.1830\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1830:\nL.1828:\nlda $11,5\nlda $27,2\nstb $27,-61+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-61+256($sp)\nldb $25,($25)\nsra $27,$25,$27\naddl $27,0,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,1,$23\nbne $23,L.1832\nlda $13,276\ncmpeq $14,$31,$23\nbne $23,L.1834\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1834:\nL.1832:\nlda $11,5\nlda $27,2\nstw $27,-64+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-64+256($sp)\nldw $25,($25)\nsra $27,$25,$27\naddl $27,0,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,1,$23\nbne $23,L.1836\nlda $13,277\ncmpeq $14,$31,$23\nbne $23,L.1838\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1838:\nL.1836:\nlda $11,5\nlda $27,2\nstl $27,-68+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldl $25,-68+256($sp)\nsra $27,$25,$27\naddl $27,0,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,1,$23\nbne $23,L.1840\nlda $13,278\ncmpeq $14,$31,$23\nbne $23,L.1842\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1842:\nL.1840:\nlda $11,5\nlda $27,2\nstq $27,-80+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldq $25,-80+256($sp)\nsra $27,$25,$27\naddl $27,0,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,1,$23\nbne $23,L.1844\nlda $13,279\ncmpeq $14,$31,$23\nbne $23,L.1846\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1846:\nL.1844:\nlda $11,5\nlda $27,2\nstl $27,-84+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nsra $27,$25,$27\naddl $27,0,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,1,$23\nbne $23,L.1848\nlda $13,280\ncmpeq $14,$31,$23\nbne $23,L.1850\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1850:\nL.1848:\nlda $10,5\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nsra $10,$27,$10\naddl $10,0,$10\ncmpeq $10,1,$23\nbne $23,L.1852\nlda $13,281\ncmpeq $14,$31,$23\nbne $23,L.1854\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1854:\nL.1852:\nlda $10,5\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nsra $10,$27,$10\naddl $10,0,$10\ncmpeq $10,1,$23\nbne $23,L.1856\nlda $13,282\ncmpeq $14,$31,$23\nbne $23,L.1858\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1858:\nL.1856:\nlda $10,5\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\nsra $10,$27,$10\naddl $10,0,$10\ncmpeq $10,1,$23\nbne $23,L.1860\nlda $13,283\ncmpeq $14,$31,$23\nbne $23,L.1862\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1862:\nL.1860:\nlda $10,5\nlda $27,2\nstq $27,-80+256($sp)\nldq $27,-80+256($sp)\nsra $10,$27,$10\naddl $10,0,$10\ncmpeq $10,1,$23\nbne $23,L.1864\nlda $13,284\ncmpeq $14,$31,$23\nbne $23,L.1866\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1866:\nL.1864:\nlda $10,5\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nsra $10,$27,$10\naddl $10,0,$10\ncmpeq $10,1,$23\nbne $23,L.1868\nlda $13,285\ncmpeq $14,$31,$23\nbne $23,L.1870\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1870:\nL.1868:\nlda $9,5\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nsra $9,$27,$9\ncmpeq $9,1,$23\nbne $23,L.1872\nlda $13,286\ncmpeq $14,$31,$23\nbne $23,L.1874\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1874:\nL.1872:\nlda $9,5\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nsra $9,$27,$9\ncmpeq $9,1,$23\nbne $23,L.1876\nlda $13,287\ncmpeq $14,$31,$23\nbne $23,L.1878\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1878:\nL.1876:\nlda $9,5\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\nsra $9,$27,$9\ncmpeq $9,1,$23\nbne $23,L.1880\nlda $13,288\ncmpeq $14,$31,$23\nbne $23,L.1882\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1882:\nL.1880:\nlda $9,5\nlda $27,2\nstq $27,-80+256($sp)\nldq $27,-80+256($sp)\nsra $9,$27,$9\ncmpeq $9,1,$23\nbne $23,L.1884\nlda $13,289\ncmpeq $14,$31,$23\nbne $23,L.1886\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1886:\nL.1884:\nlda $9,5\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nsra $9,$27,$9\ncmpeq $9,1,$23\nbne $23,L.1888\nlda $13,290\ncmpeq $14,$31,$23\nbne $23,L.1890\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1890:\nL.1888:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstb $27,-61+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,-61+256($sp)\nldb $25,($25)\nsrl $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,1\ncmpeq $27,$25,$23\nbne $23,L.1892\nlda $13,291\ncmpeq $14,$31,$23\nbne $23,L.1894\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1894:\nL.1892:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstw $27,-64+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,-64+256($sp)\nldw $25,($25)\nsrl $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,1\ncmpeq $27,$25,$23\nbne $23,L.1896\nlda $13,292\ncmpeq $14,$31,$23\nbne $23,L.1898\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1898:\nL.1896:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldl $25,-68+256($sp)\nsrl $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,1\ncmpeq $27,$25,$23\nbne $23,L.1900\nlda $13,293\ncmpeq $14,$31,$23\nbne $23,L.1902\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1902:\nL.1900:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstq $27,-80+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldq $25,-80+256($sp)\nsrl $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,1\ncmpeq $27,$25,$23\nbne $23,L.1904\nlda $13,294\ncmpeq $14,$31,$23\nbne $23,L.1906\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1906:\nL.1904:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nsrl $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,1\ncmpeq $27,$25,$23\nbne $23,L.1908\nlda $13,295\ncmpeq $14,$31,$23\nbne $23,L.1910\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1910:\nL.1908:\nlda $12,5\nlda $27,2\nstb $27,-61+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nlda $25,-61+256($sp)\nldb $25,($25)\nsll $27,$25,$27\naddl $27,0,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,20,$23\nbne $23,L.1912\nlda $13,296\ncmpeq $14,$31,$23\nbne $23,L.1914\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1914:\nL.1912:\nlda $12,5\nlda $27,2\nstw $27,-64+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nlda $25,-64+256($sp)\nldw $25,($25)\nsll $27,$25,$27\naddl $27,0,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,20,$23\nbne $23,L.1916\nlda $13,297\ncmpeq $14,$31,$23\nbne $23,L.1918\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1918:\nL.1916:\nlda $12,5\nlda $27,2\nstl $27,-68+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldl $25,-68+256($sp)\nsll $27,$25,$27\naddl $27,0,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,20,$23\nbne $23,L.1920\nlda $13,298\ncmpeq $14,$31,$23\nbne $23,L.1922\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1922:\nL.1920:\nlda $12,5\nlda $27,2\nstq $27,-80+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldq $25,-80+256($sp)\nsll $27,$25,$27\naddl $27,0,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,20,$23\nbne $23,L.1924\nlda $13,299\ncmpeq $14,$31,$23\nbne $23,L.1926\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1926:\nL.1924:\nlda $12,5\nlda $27,2\nstl $27,-84+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nsll $27,$25,$27\naddl $27,0,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,20,$23\nbne $23,L.1928\nlda $13,300\ncmpeq $14,$31,$23\nbne $23,L.1930\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1930:\nL.1928:\nlda $11,5\nlda $27,2\nstb $27,-61+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-61+256($sp)\nldb $25,($25)\nsll $27,$25,$27\naddl $27,0,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,20,$23\nbne $23,L.1932\nlda $13,301\ncmpeq $14,$31,$23\nbne $23,L.1934\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1934:\nL.1932:\nlda $11,5\nlda $27,2\nstw $27,-64+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-64+256($sp)\nldw $25,($25)\nsll $27,$25,$27\naddl $27,0,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,20,$23\nbne $23,L.1936\nlda $13,302\ncmpeq $14,$31,$23\nbne $23,L.1938\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1938:\nL.1936:\nlda $11,5\nlda $27,2\nstl $27,-68+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldl $25,-68+256($sp)\nsll $27,$25,$27\naddl $27,0,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,20,$23\nbne $23,L.1940\nlda $13,303\ncmpeq $14,$31,$23\nbne $23,L.1942\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1942:\nL.1940:\nlda $11,5\nlda $27,2\nstq $27,-80+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldq $25,-80+256($sp)\nsll $27,$25,$27\naddl $27,0,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,20,$23\nbne $23,L.1944\nlda $13,304\ncmpeq $14,$31,$23\nbne $23,L.1946\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1946:\nL.1944:\nlda $11,5\nlda $27,2\nstl $27,-84+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nsll $27,$25,$27\naddl $27,0,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,20,$23\nbne $23,L.1948\nlda $13,305\ncmpeq $14,$31,$23\nbne $23,L.1950\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1950:\nL.1948:\nlda $10,5\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nsll $10,$27,$10\naddl $10,0,$10\ncmpeq $10,20,$23\nbne $23,L.1952\nlda $13,306\ncmpeq $14,$31,$23\nbne $23,L.1954\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1954:\nL.1952:\nlda $10,5\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nsll $10,$27,$10\naddl $10,0,$10\ncmpeq $10,20,$23\nbne $23,L.1956\nlda $13,307\ncmpeq $14,$31,$23\nbne $23,L.1958\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1958:\nL.1956:\nlda $10,5\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\nsll $10,$27,$10\naddl $10,0,$10\ncmpeq $10,20,$23\nbne $23,L.1960\nlda $13,308\ncmpeq $14,$31,$23\nbne $23,L.1962\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1962:\nL.1960:\nlda $10,5\nlda $27,2\nstq $27,-80+256($sp)\nldq $27,-80+256($sp)\nsll $10,$27,$10\naddl $10,0,$10\ncmpeq $10,20,$23\nbne $23,L.1964\nlda $13,309\ncmpeq $14,$31,$23\nbne $23,L.1966\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1966:\nL.1964:\nlda $10,5\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nsll $10,$27,$10\naddl $10,0,$10\ncmpeq $10,20,$23\nbne $23,L.1968\nlda $13,310\ncmpeq $14,$31,$23\nbne $23,L.1970\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1970:\nL.1968:\nlda $9,5\nlda $27,2\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nsll $9,$27,$9\ncmpeq $9,20,$23\nbne $23,L.1972\nlda $13,311\ncmpeq $14,$31,$23\nbne $23,L.1974\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1974:\nL.1972:\nlda $9,5\nlda $27,2\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nsll $9,$27,$9\ncmpeq $9,20,$23\nbne $23,L.1976\nlda $13,312\ncmpeq $14,$31,$23\nbne $23,L.1978\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1978:\nL.1976:\nlda $9,5\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\nsll $9,$27,$9\ncmpeq $9,20,$23\nbne $23,L.1980\nlda $13,313\ncmpeq $14,$31,$23\nbne $23,L.1982\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1982:\nL.1980:\nlda $9,5\nlda $27,2\nstq $27,-80+256($sp)\nldq $27,-80+256($sp)\nsll $9,$27,$9\ncmpeq $9,20,$23\nbne $23,L.1984\nlda $13,314\ncmpeq $14,$31,$23\nbne $23,L.1986\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1986:\nL.1984:\nlda $9,5\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nsll $9,$27,$9\ncmpeq $9,20,$23\nbne $23,L.1988\nlda $13,315\ncmpeq $14,$31,$23\nbne $23,L.1990\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1990:\nL.1988:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstb $27,-61+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,-61+256($sp)\nldb $25,($25)\nsll $27,$25,$27\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,20\ncmpeq $27,$25,$23\nbne $23,L.1992\nlda $13,316\ncmpeq $14,$31,$23\nbne $23,L.1994\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1994:\nL.1992:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstw $27,-64+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,-64+256($sp)\nldw $25,($25)\nsll $27,$25,$27\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,20\ncmpeq $27,$25,$23\nbne $23,L.1996\nlda $13,317\ncmpeq $14,$31,$23\nbne $23,L.1998\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.1998:\nL.1996:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstl $27,-68+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldl $25,-68+256($sp)\nsll $27,$25,$27\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,20\ncmpeq $27,$25,$23\nbne $23,L.2000\nlda $13,318\ncmpeq $14,$31,$23\nbne $23,L.2002\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2002:\nL.2000:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstq $27,-80+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldq $25,-80+256($sp)\nsll $27,$25,$27\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,20\ncmpeq $27,$25,$23\nbne $23,L.2004\nlda $13,319\ncmpeq $14,$31,$23\nbne $23,L.2006\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2006:\nL.2004:\nlda $27,5\nstl $27,-60+256($sp)\nlda $27,2\nstl $27,-84+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nsll $27,$25,$27\nzap $27,240,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,20\ncmpeq $27,$25,$23\nbne $23,L.2008\nlda $13,320\ncmpeq $14,$31,$23\nbne $23,L.2010\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2010:\nL.2008:\nlda $12,12\nlda $27,10\nstb $27,-61+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nlda $25,-61+256($sp)\nldb $25,($25)\nand $27,$25,$27\naddl $27,0,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,8,$23\nbne $23,L.2012\nlda $13,321\ncmpeq $14,$31,$23\nbne $23,L.2014\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2014:\nL.2012:\nlda $12,12\nlda $27,10\nstw $27,-64+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nlda $25,-64+256($sp)\nldw $25,($25)\nand $27,$25,$27\naddl $27,0,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,8,$23\nbne $23,L.2016\nlda $13,322\ncmpeq $14,$31,$23\nbne $23,L.2018\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2018:\nL.2016:\nlda $12,12\nlda $27,10\nstl $27,-68+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldl $25,-68+256($sp)\nand $27,$25,$27\naddl $27,0,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,8,$23\nbne $23,L.2020\nlda $13,323\ncmpeq $14,$31,$23\nbne $23,L.2022\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2022:\nL.2020:\nlda $12,12\nlda $27,10\nstq $27,-80+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\nand $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,8,$23\nbne $23,L.2024\nlda $13,324\ncmpeq $14,$31,$23\nbne $23,L.2026\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2026:\nL.2024:\nlda $12,12\nlda $27,10\nstl $27,-84+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nand $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,8,$23\nbne $23,L.2028\nlda $13,325\ncmpeq $14,$31,$23\nbne $23,L.2030\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2030:\nL.2028:\nlda $11,12\nlda $27,10\nstb $27,-61+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-61+256($sp)\nldb $25,($25)\nand $27,$25,$27\naddl $27,0,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,8,$23\nbne $23,L.2032\nlda $13,326\ncmpeq $14,$31,$23\nbne $23,L.2034\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2034:\nL.2032:\nlda $11,12\nlda $27,10\nstw $27,-64+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-64+256($sp)\nldw $25,($25)\nand $27,$25,$27\naddl $27,0,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,8,$23\nbne $23,L.2036\nlda $13,327\ncmpeq $14,$31,$23\nbne $23,L.2038\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2038:\nL.2036:\nlda $11,12\nlda $27,10\nstl $27,-68+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldl $25,-68+256($sp)\nand $27,$25,$27\naddl $27,0,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,8,$23\nbne $23,L.2040\nlda $13,328\ncmpeq $14,$31,$23\nbne $23,L.2042\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2042:\nL.2040:\nlda $11,12\nlda $27,10\nstq $27,-80+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\nand $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,8,$23\nbne $23,L.2044\nlda $13,329\ncmpeq $14,$31,$23\nbne $23,L.2046\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2046:\nL.2044:\nlda $11,12\nlda $27,10\nstl $27,-84+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nand $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,8,$23\nbne $23,L.2048\nlda $13,330\ncmpeq $14,$31,$23\nbne $23,L.2050\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2050:\nL.2048:\nlda $10,12\nlda $27,10\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nand $10,$27,$10\naddl $10,0,$10\ncmpeq $10,8,$23\nbne $23,L.2052\nlda $13,331\ncmpeq $14,$31,$23\nbne $23,L.2054\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2054:\nL.2052:\nlda $10,12\nlda $27,10\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nand $10,$27,$10\naddl $10,0,$10\ncmpeq $10,8,$23\nbne $23,L.2056\nlda $13,332\ncmpeq $14,$31,$23\nbne $23,L.2058\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2058:\nL.2056:\nlda $10,12\nlda $27,10\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\nand $10,$27,$10\naddl $10,0,$10\ncmpeq $10,8,$23\nbne $23,L.2060\nlda $13,333\ncmpeq $14,$31,$23\nbne $23,L.2062\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2062:\nL.2060:\nlda $10,12\nlda $27,10\nstq $27,-80+256($sp)\nsll $10,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\nand $27,$25,$27\nmov $27,$10\ncmpeq $10,8,$23\nbne $23,L.2064\nlda $13,334\ncmpeq $14,$31,$23\nbne $23,L.2066\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2066:\nL.2064:\nlda $10,12\nlda $27,10\nstl $27,-84+256($sp)\nmov $10,$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nand $27,$25,$27\nmov $27,$10\ncmpeq $10,8,$23\nbne $23,L.2068\nlda $13,335\ncmpeq $14,$31,$23\nbne $23,L.2070\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2070:\nL.2068:\nlda $9,12\nlda $27,10\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nand $9,$27,$9\ncmpeq $9,8,$23\nbne $23,L.2072\nlda $13,336\ncmpeq $14,$31,$23\nbne $23,L.2074\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2074:\nL.2072:\nlda $9,12\nlda $27,10\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nand $9,$27,$9\ncmpeq $9,8,$23\nbne $23,L.2076\nlda $13,337\ncmpeq $14,$31,$23\nbne $23,L.2078\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2078:\nL.2076:\nlda $9,12\nlda $27,10\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\nand $9,$27,$9\ncmpeq $9,8,$23\nbne $23,L.2080\nlda $13,338\ncmpeq $14,$31,$23\nbne $23,L.2082\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2082:\nL.2080:\nlda $9,12\nlda $27,10\nstq $27,-80+256($sp)\nldq $27,-80+256($sp)\nand $9,$27,$9\ncmpeq $9,8,$23\nbne $23,L.2084\nlda $13,339\ncmpeq $14,$31,$23\nbne $23,L.2086\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2086:\nL.2084:\nlda $9,12\nlda $27,10\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nand $9,$27,$9\ncmpeq $9,8,$23\nbne $23,L.2088\nlda $13,340\ncmpeq $14,$31,$23\nbne $23,L.2090\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2090:\nL.2088:\nlda $27,12\nstl $27,-60+256($sp)\nlda $27,10\nstb $27,-61+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,-61+256($sp)\nldb $25,($25)\nand $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,8\ncmpeq $27,$25,$23\nbne $23,L.2092\nlda $13,341\ncmpeq $14,$31,$23\nbne $23,L.2094\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2094:\nL.2092:\nlda $27,12\nstl $27,-60+256($sp)\nlda $27,10\nstw $27,-64+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,-64+256($sp)\nldw $25,($25)\nand $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,8\ncmpeq $27,$25,$23\nbne $23,L.2096\nlda $13,342\ncmpeq $14,$31,$23\nbne $23,L.2098\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2098:\nL.2096:\nlda $27,12\nstl $27,-60+256($sp)\nlda $27,10\nstl $27,-68+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldl $25,-68+256($sp)\nand $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,8\ncmpeq $27,$25,$23\nbne $23,L.2100\nlda $13,343\ncmpeq $14,$31,$23\nbne $23,L.2102\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2102:\nL.2100:\nlda $27,12\nstl $27,-60+256($sp)\nlda $27,10\nstq $27,-80+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldq $25,-80+256($sp)\nand $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,8\ncmpeq $27,$25,$23\nbne $23,L.2104\nlda $13,344\ncmpeq $14,$31,$23\nbne $23,L.2106\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2106:\nL.2104:\nlda $27,12\nstl $27,-60+256($sp)\nlda $27,10\nstl $27,-84+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nand $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,8\ncmpeq $27,$25,$23\nbne $23,L.2108\nlda $13,345\ncmpeq $14,$31,$23\nbne $23,L.2110\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2110:\nL.2108:\nlda $12,12\nlda $27,10\nstb $27,-61+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nlda $25,-61+256($sp)\nldb $25,($25)\nxor $27,$25,$27\naddl $27,0,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,6,$23\nbne $23,L.2112\nlda $13,346\ncmpeq $14,$31,$23\nbne $23,L.2114\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2114:\nL.2112:\nlda $12,12\nlda $27,10\nstw $27,-64+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nlda $25,-64+256($sp)\nldw $25,($25)\nxor $27,$25,$27\naddl $27,0,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,6,$23\nbne $23,L.2116\nlda $13,347\ncmpeq $14,$31,$23\nbne $23,L.2118\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2118:\nL.2116:\nlda $12,12\nlda $27,10\nstl $27,-68+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldl $25,-68+256($sp)\nxor $27,$25,$27\naddl $27,0,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,6,$23\nbne $23,L.2120\nlda $13,348\ncmpeq $14,$31,$23\nbne $23,L.2122\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2122:\nL.2120:\nlda $12,12\nlda $27,10\nstq $27,-80+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\nxor $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,6,$23\nbne $23,L.2124\nlda $13,349\ncmpeq $14,$31,$23\nbne $23,L.2126\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2126:\nL.2124:\nlda $12,12\nlda $27,10\nstl $27,-84+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nxor $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,6,$23\nbne $23,L.2128\nlda $13,350\ncmpeq $14,$31,$23\nbne $23,L.2130\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2130:\nL.2128:\nlda $11,12\nlda $27,10\nstb $27,-61+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-61+256($sp)\nldb $25,($25)\nxor $27,$25,$27\naddl $27,0,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,6,$23\nbne $23,L.2132\nlda $13,351\ncmpeq $14,$31,$23\nbne $23,L.2134\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2134:\nL.2132:\nlda $11,12\nlda $27,10\nstw $27,-64+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-64+256($sp)\nldw $25,($25)\nxor $27,$25,$27\naddl $27,0,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,6,$23\nbne $23,L.2136\nlda $13,352\ncmpeq $14,$31,$23\nbne $23,L.2138\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2138:\nL.2136:\nlda $11,12\nlda $27,10\nstl $27,-68+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldl $25,-68+256($sp)\nxor $27,$25,$27\naddl $27,0,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,6,$23\nbne $23,L.2140\nlda $13,353\ncmpeq $14,$31,$23\nbne $23,L.2142\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2142:\nL.2140:\nlda $11,12\nlda $27,10\nstq $27,-80+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\nxor $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,6,$23\nbne $23,L.2144\nlda $13,354\ncmpeq $14,$31,$23\nbne $23,L.2146\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2146:\nL.2144:\nlda $11,12\nlda $27,10\nstl $27,-84+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nxor $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,6,$23\nbne $23,L.2148\nlda $13,355\ncmpeq $14,$31,$23\nbne $23,L.2150\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2150:\nL.2148:\nlda $10,12\nlda $27,10\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nxor $10,$27,$10\naddl $10,0,$10\ncmpeq $10,6,$23\nbne $23,L.2152\nlda $13,356\ncmpeq $14,$31,$23\nbne $23,L.2154\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2154:\nL.2152:\nlda $10,12\nlda $27,10\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nxor $10,$27,$10\naddl $10,0,$10\ncmpeq $10,6,$23\nbne $23,L.2156\nlda $13,357\ncmpeq $14,$31,$23\nbne $23,L.2158\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2158:\nL.2156:\nlda $10,12\nlda $27,10\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\nxor $10,$27,$10\naddl $10,0,$10\ncmpeq $10,6,$23\nbne $23,L.2160\nlda $13,358\ncmpeq $14,$31,$23\nbne $23,L.2162\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2162:\nL.2160:\nlda $10,12\nlda $27,10\nstq $27,-80+256($sp)\nsll $10,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\nxor $27,$25,$27\nmov $27,$10\ncmpeq $10,6,$23\nbne $23,L.2164\nlda $13,359\ncmpeq $14,$31,$23\nbne $23,L.2166\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2166:\nL.2164:\nlda $10,12\nlda $27,10\nstl $27,-84+256($sp)\nmov $10,$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nxor $27,$25,$27\nmov $27,$10\ncmpeq $10,6,$23\nbne $23,L.2168\nlda $13,360\ncmpeq $14,$31,$23\nbne $23,L.2170\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2170:\nL.2168:\nlda $9,12\nlda $27,10\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nxor $9,$27,$9\ncmpeq $9,6,$23\nbne $23,L.2172\nlda $13,361\ncmpeq $14,$31,$23\nbne $23,L.2174\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2174:\nL.2172:\nlda $9,12\nlda $27,10\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nxor $9,$27,$9\ncmpeq $9,6,$23\nbne $23,L.2176\nlda $13,362\ncmpeq $14,$31,$23\nbne $23,L.2178\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2178:\nL.2176:\nlda $9,12\nlda $27,10\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\nxor $9,$27,$9\ncmpeq $9,6,$23\nbne $23,L.2180\nlda $13,363\ncmpeq $14,$31,$23\nbne $23,L.2182\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2182:\nL.2180:\nlda $9,12\nlda $27,10\nstq $27,-80+256($sp)\nldq $27,-80+256($sp)\nxor $9,$27,$9\ncmpeq $9,6,$23\nbne $23,L.2184\nlda $13,364\ncmpeq $14,$31,$23\nbne $23,L.2186\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2186:\nL.2184:\nlda $9,12\nlda $27,10\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nxor $9,$27,$9\ncmpeq $9,6,$23\nbne $23,L.2188\nlda $13,365\ncmpeq $14,$31,$23\nbne $23,L.2190\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2190:\nL.2188:\nlda $27,12\nstl $27,-60+256($sp)\nlda $27,10\nstb $27,-61+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,-61+256($sp)\nldb $25,($25)\nxor $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,6\ncmpeq $27,$25,$23\nbne $23,L.2192\nlda $13,366\ncmpeq $14,$31,$23\nbne $23,L.2194\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2194:\nL.2192:\nlda $27,12\nstl $27,-60+256($sp)\nlda $27,10\nstw $27,-64+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,-64+256($sp)\nldw $25,($25)\nxor $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,6\ncmpeq $27,$25,$23\nbne $23,L.2196\nlda $13,367\ncmpeq $14,$31,$23\nbne $23,L.2198\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2198:\nL.2196:\nlda $27,12\nstl $27,-60+256($sp)\nlda $27,10\nstl $27,-68+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldl $25,-68+256($sp)\nxor $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,6\ncmpeq $27,$25,$23\nbne $23,L.2200\nlda $13,368\ncmpeq $14,$31,$23\nbne $23,L.2202\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2202:\nL.2200:\nlda $27,12\nstl $27,-60+256($sp)\nlda $27,10\nstq $27,-80+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldq $25,-80+256($sp)\nxor $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,6\ncmpeq $27,$25,$23\nbne $23,L.2204\nlda $13,369\ncmpeq $14,$31,$23\nbne $23,L.2206\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2206:\nL.2204:\nlda $27,12\nstl $27,-60+256($sp)\nlda $27,10\nstl $27,-84+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nxor $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,6\ncmpeq $27,$25,$23\nbne $23,L.2208\nlda $13,370\ncmpeq $14,$31,$23\nbne $23,L.2210\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2210:\nL.2208:\nlda $12,12\nlda $27,10\nstb $27,-61+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nlda $25,-61+256($sp)\nldb $25,($25)\nor $27,$25,$27\naddl $27,0,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,14,$23\nbne $23,L.2212\nlda $13,371\ncmpeq $14,$31,$23\nbne $23,L.2214\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2214:\nL.2212:\nlda $12,12\nlda $27,10\nstw $27,-64+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nlda $25,-64+256($sp)\nldw $25,($25)\nor $27,$25,$27\naddl $27,0,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,14,$23\nbne $23,L.2216\nlda $13,372\ncmpeq $14,$31,$23\nbne $23,L.2218\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2218:\nL.2216:\nlda $12,12\nlda $27,10\nstl $27,-68+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldl $25,-68+256($sp)\nor $27,$25,$27\naddl $27,0,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,14,$23\nbne $23,L.2220\nlda $13,373\ncmpeq $14,$31,$23\nbne $23,L.2222\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2222:\nL.2220:\nlda $12,12\nlda $27,10\nstq $27,-80+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\nor $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,14,$23\nbne $23,L.2224\nlda $13,374\ncmpeq $14,$31,$23\nbne $23,L.2226\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2226:\nL.2224:\nlda $12,12\nlda $27,10\nstl $27,-84+256($sp)\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nor $27,$25,$27\nmov $27,$12\nsll $12,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,14,$23\nbne $23,L.2228\nlda $13,375\ncmpeq $14,$31,$23\nbne $23,L.2230\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2230:\nL.2228:\nlda $11,12\nlda $27,10\nstb $27,-61+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-61+256($sp)\nldb $25,($25)\nor $27,$25,$27\naddl $27,0,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,14,$23\nbne $23,L.2232\nlda $13,376\ncmpeq $14,$31,$23\nbne $23,L.2234\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2234:\nL.2232:\nlda $11,12\nlda $27,10\nstw $27,-64+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-64+256($sp)\nldw $25,($25)\nor $27,$25,$27\naddl $27,0,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,14,$23\nbne $23,L.2236\nlda $13,377\ncmpeq $14,$31,$23\nbne $23,L.2238\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2238:\nL.2236:\nlda $11,12\nlda $27,10\nstl $27,-68+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldl $25,-68+256($sp)\nor $27,$25,$27\naddl $27,0,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,14,$23\nbne $23,L.2240\nlda $13,378\ncmpeq $14,$31,$23\nbne $23,L.2242\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2242:\nL.2240:\nlda $11,12\nlda $27,10\nstq $27,-80+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\nor $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,14,$23\nbne $23,L.2244\nlda $13,379\ncmpeq $14,$31,$23\nbne $23,L.2246\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2246:\nL.2244:\nlda $11,12\nlda $27,10\nstl $27,-84+256($sp)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nor $27,$25,$27\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,14,$23\nbne $23,L.2248\nlda $13,380\ncmpeq $14,$31,$23\nbne $23,L.2250\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2250:\nL.2248:\nlda $10,12\nlda $27,10\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nor $10,$27,$10\naddl $10,0,$10\ncmpeq $10,14,$23\nbne $23,L.2252\nlda $13,381\ncmpeq $14,$31,$23\nbne $23,L.2254\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2254:\nL.2252:\nlda $10,12\nlda $27,10\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nor $10,$27,$10\naddl $10,0,$10\ncmpeq $10,14,$23\nbne $23,L.2256\nlda $13,382\ncmpeq $14,$31,$23\nbne $23,L.2258\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2258:\nL.2256:\nlda $10,12\nlda $27,10\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\nor $10,$27,$10\naddl $10,0,$10\ncmpeq $10,14,$23\nbne $23,L.2260\nlda $13,383\ncmpeq $14,$31,$23\nbne $23,L.2262\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2262:\nL.2260:\nlda $10,12\nlda $27,10\nstq $27,-80+256($sp)\nsll $10,8*(8-4),$27\nsra $27,8*(8-4),$27\nldq $25,-80+256($sp)\nor $27,$25,$27\nmov $27,$10\ncmpeq $10,14,$23\nbne $23,L.2264\nlda $13,384\ncmpeq $14,$31,$23\nbne $23,L.2266\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2266:\nL.2264:\nlda $10,12\nlda $27,10\nstl $27,-84+256($sp)\nmov $10,$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nor $27,$25,$27\nmov $27,$10\ncmpeq $10,14,$23\nbne $23,L.2268\nlda $13,385\ncmpeq $14,$31,$23\nbne $23,L.2270\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2270:\nL.2268:\nlda $9,12\nlda $27,10\nstb $27,-61+256($sp)\nlda $27,-61+256($sp)\nldb $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nor $9,$27,$9\ncmpeq $9,14,$23\nbne $23,L.2272\nlda $13,386\ncmpeq $14,$31,$23\nbne $23,L.2274\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2274:\nL.2272:\nlda $9,12\nlda $27,10\nstw $27,-64+256($sp)\nlda $27,-64+256($sp)\nldw $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nor $9,$27,$9\ncmpeq $9,14,$23\nbne $23,L.2276\nlda $13,387\ncmpeq $14,$31,$23\nbne $23,L.2278\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2278:\nL.2276:\nlda $9,12\nlda $27,10\nstl $27,-68+256($sp)\nldl $27,-68+256($sp)\nor $9,$27,$9\ncmpeq $9,14,$23\nbne $23,L.2280\nlda $13,388\ncmpeq $14,$31,$23\nbne $23,L.2282\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2282:\nL.2280:\nlda $9,12\nlda $27,10\nstq $27,-80+256($sp)\nldq $27,-80+256($sp)\nor $9,$27,$9\ncmpeq $9,14,$23\nbne $23,L.2284\nlda $13,389\ncmpeq $14,$31,$23\nbne $23,L.2286\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2286:\nL.2284:\nlda $9,12\nlda $27,10\nstl $27,-84+256($sp)\nldl $27,-84+256($sp)\nzap $27,240,$27\nor $9,$27,$9\ncmpeq $9,14,$23\nbne $23,L.2288\nlda $13,390\ncmpeq $14,$31,$23\nbne $23,L.2290\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2290:\nL.2288:\nlda $27,12\nstl $27,-60+256($sp)\nlda $27,10\nstb $27,-61+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,-61+256($sp)\nldb $25,($25)\nor $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,14\ncmpeq $27,$25,$23\nbne $23,L.2292\nlda $13,391\ncmpeq $14,$31,$23\nbne $23,L.2294\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2294:\nL.2292:\nlda $27,12\nstl $27,-60+256($sp)\nlda $27,10\nstw $27,-64+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,-64+256($sp)\nldw $25,($25)\nor $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,14\ncmpeq $27,$25,$23\nbne $23,L.2296\nlda $13,392\ncmpeq $14,$31,$23\nbne $23,L.2298\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2298:\nL.2296:\nlda $27,12\nstl $27,-60+256($sp)\nlda $27,10\nstl $27,-68+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldl $25,-68+256($sp)\nor $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,14\ncmpeq $27,$25,$23\nbne $23,L.2300\nlda $13,393\ncmpeq $14,$31,$23\nbne $23,L.2302\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2302:\nL.2300:\nlda $27,12\nstl $27,-60+256($sp)\nlda $27,10\nstq $27,-80+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldq $25,-80+256($sp)\nor $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,14\ncmpeq $27,$25,$23\nbne $23,L.2304\nlda $13,394\ncmpeq $14,$31,$23\nbne $23,L.2306\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2306:\nL.2304:\nlda $27,12\nstl $27,-60+256($sp)\nlda $27,10\nstl $27,-84+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nldl $25,-84+256($sp)\nzap $25,240,$25\nor $27,$25,$27\nstl $27,-60+256($sp)\nldl $27,-60+256($sp)\nzap $27,240,$27\nlda $25,14\ncmpeq $27,$25,$23\nbne $23,L.2308\nlda $13,395\ncmpeq $14,$31,$23\nbne $23,L.2310\nlda $16,L.685\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2310:\nL.2308:\ncmpeq $13,$31,$23\nbne $23,L.2312\nlda $27,1\nstl $27,-108+256($sp)\nldq $27,-48+256($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.2314\nlda $16,L.686\nlda $17,1\njsr $26,printf\nldgp $gp,0($26)\nL.2314:\nL.2312:\nldl $0,-108+256($sp)\nL.684:\nldt $f6,0($sp)\nldt $f7,8($sp)\nldt $f8,16($sp)\nldt $f9,24($sp)\nldq $9,32($sp)\nldq $10,40($sp)\nldq $11,48($sp)\nldq $12,56($sp)\nldq $13,64($sp)\nldq $14,72($sp)\nldq $24,80($sp)\nldq $26,88($sp)\nlda $sp,256($sp)\nret\n.end s714\n.sdata\n.align 0\nL.2317:\n.byte 115\n.byte 55\n.byte 49\n.byte 53\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.2318:\n.byte 115\n.byte 55\n.byte 49\n.byte 53\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s715\n.text\n.text\n.ent s715\ns715:\nldgp $gp,0($27)\nlda $sp,-128($sp)\n.mask 0x5007800,-88\n.frame $sp,128,$26,48\nstq $11,0($sp)\nstq $12,8($sp)\nstq $13,16($sp)\nstq $14,24($sp)\nstq $24,32($sp)\nstq $26,40($sp)\nstq $16,80($sp)\n.prologue 1\nstl $31,-68+128($sp)\nstl $31,-60+128($sp)\nlda $14,L.2318\nldq $25,-48+128($sp)\nlda $13,60($25)\nmov $31,$11\nL.2319:\nL.2320:\nmov $13,$27\nlda $13,1($27)\nmov $14,$25\nlda $14,1($25)\nldb $25,($25)\nstb $25,($27)\nsll $25,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbeq $23,L.2319\nlda $27,1\nmov $27,$12\nlda $12,1($12)\nlda $12,1($12)\nlda $12,1($12)\nlda $12,1($12)\nlda $27,1($12)\nmov $27,$12\ncmpeq $27,6,$23\nbne $23,L.2322\nldq $27,-48+128($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.2324\nlda $16,L.2317\nlda $17,1\njsr $26,printf\nldgp $gp,0($26)\nL.2324:\nlda $11,1($11)\nL.2322:\nldl $16,-60+128($sp)\nlda $27,3\nstl $27,-64+128($sp)\nldl $27,-64+128($sp)\nlda $17,2($27)\nldl $18,-68+128($sp)\njsr $26,s715f\nldgp $gp,0($26)\ncmpeq $0,5,$23\nbne $23,L.2326\nldq $27,-48+128($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.2328\nlda $16,L.2317\nlda $17,2\njsr $26,printf\nldgp $gp,0($26)\nL.2328:\nlda $11,2($11)\nL.2326:\nmov $11,$0\nL.2316:\nldq $11,0($sp)\nldq $12,8($sp)\nldq $13,16($sp)\nldq $14,24($sp)\nldq $24,32($sp)\nldq $26,40($sp)\nlda $sp,128($sp)\nret\n.end s715\n.globl s715f\n.text\n.ent s715f\ns715f:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.frame $sp,64,$26,48\n.prologue 1\nmov $17,$0\nL.2330:\nlda $sp,64($sp)\nret\n.end s715f\n.sdata\n.align 0\nL.2332:\n.byte 115\n.byte 55\n.byte 50\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.2333:\n.byte 115\n.byte 55\n.byte 50\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s72\n.text\n.text\n.ent s72\ns72:\nldgp $gp,0($27)\nlda $sp,-176($sp)\n.fmask 0x300,-168\n.mask 0x5007e00,-104\n.frame $sp,176,$26,48\nstt $f8,0($sp)\nstt $f9,8($sp)\nstq $9,16($sp)\nstq $10,24($sp)\nstq $11,32($sp)\nstq $12,40($sp)\nstq $13,48($sp)\nstq $14,56($sp)\nstq $24,64($sp)\nstq $26,72($sp)\nmov $16,$14\n.prologue 1\nlda $12,L.2333\nlda $11,60($14)\nmov $31,$9\nL.2334:\nL.2335:\nmov $11,$27\nlda $11,1($27)\nmov $12,$25\nlda $12,1($25)\nldb $25,($25)\nstb $25,($27)\nsll $25,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbeq $23,L.2334\nlda $27,2\nstl $27,-60+176($sp)\nldl $27,-60+176($sp)\ncmpeq $27,2,$23\nbne $23,L.2337\nlda $27,1\nlda $9,1($9)\nlda $16,L.2332\nmov $27,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2337:\nldl $27,-60+176($sp)\nnegl $27,$25\naddl $27,$25,$27\ncmpeq $27,$31,$23\nbne $23,L.2339\nlda $27,2\nlda $9,2($9)\nlda $16,L.2332\nmov $27,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2339:\nstl $31,-60+176($sp)\nmov $31,$13\nbr L.2344\nL.2341:\nldl $27,-60+176($sp)\nsll $27,1,$27\naddl $27,0,$27\nor $27,1,$27\naddl $27,0,$27\nstl $27,-60+176($sp)\nL.2342:\nlda $13,1($13)\nL.2344:\nldl $27,4($14)\ncmplt $13,$27,$23\nbne $23,L.2341\nldl $27,-60+176($sp)\nnot $27,$27\naddl $27,0,$27\ncmpeq $27,$31,$23\nbne $23,L.2345\nlda $27,4\nlda $9,4($9)\nlda $16,L.2332\nmov $27,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2345:\nlda $27,5\nstl $27,-60+176($sp)\nldl $27,-60+176($sp)\nlda $27,1($27)\nstl $27,-60+176($sp)\ncmpeq $27,6,$23\nbeq $23,L.2352\nldl $27,-60+176($sp)\nsubl $27,1,$27\nstl $27,-60+176($sp)\ncmpeq $27,5,$23\nbeq $23,L.2352\nldl $27,-60+176($sp)\nlda $25,1($27)\nstl $25,-60+176($sp)\ncmpeq $27,5,$23\nbeq $23,L.2352\nldl $27,-60+176($sp)\nsubl $27,1,$25\nstl $25,-60+176($sp)\ncmpeq $27,6,$23\nbeq $23,L.2352\nldl $27,-60+176($sp)\ncmpeq $27,5,$23\nbne $23,L.2347\nL.2352:\nlda $27,8\nlda $9,8($9)\nlda $16,L.2332\nmov $27,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2347:\nlda $27,26\nstb $27,-65+176($sp)\nlda $27,26\nstq $27,-80+176($sp)\nldt $f9,L.2353\nlda $27,26\nstw $27,-68+176($sp)\nlda $27,26\nstl $27,-84+176($sp)\nlda $27,26\nstl $27,-64+176($sp)\nlds $f8,L.2354\nmov $31,$10\nlda $27,-68+176($sp)\nldw $27,($27)\nsll $27,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,26,$23\nbeq $23,L.2361\nldl $27,-64+176($sp)\nsll $27,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,26,$23\nbeq $23,L.2361\nldq $27,-80+176($sp)\nsll $27,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,26,$23\nbeq $23,L.2361\nldl $27,-84+176($sp)\nzap $27,240,$27\nsll $27,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,26,$23\nbeq $23,L.2361\ncvttqc $f8,$f1\ncvtql $f1,$f1\nsts $f1,-56+176($sp)\nldl $27,-56+176($sp)\nsll $27,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,26,$23\nbeq $23,L.2361\ncvttqc $f9,$f1\ncvtql $f1,$f1\nsts $f1,-56+176($sp)\nldl $27,-56+176($sp)\nsll $27,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,26,$23\nbne $23,L.2355\nL.2361:\nlda $10,1($10)\nL.2355:\nlda $27,-65+176($sp)\nldb $27,($27)\nsll $27,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,26,$23\nbeq $23,L.2368\nldl $27,-64+176($sp)\nsll $27,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,26,$23\nbeq $23,L.2368\nldq $27,-80+176($sp)\nsll $27,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,26,$23\nbeq $23,L.2368\nldl $27,-84+176($sp)\nzap $27,240,$27\nsll $27,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,26,$23\nbeq $23,L.2368\ncvttqc $f8,$f1\ncvtql $f1,$f1\nsts $f1,-56+176($sp)\nldl $27,-56+176($sp)\nsll $27,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,26,$23\nbeq $23,L.2368\ncvttqc $f9,$f1\ncvtql $f1,$f1\nsts $f1,-56+176($sp)\nldl $27,-56+176($sp)\nsll $27,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,26,$23\nbne $23,L.2362\nL.2368:\nlda $10,2($10)\nL.2362:\nlda $27,-65+176($sp)\nldb $27,($27)\ncmpeq $27,26,$23\nbeq $23,L.2375\nlda $27,-68+176($sp)\nldw $27,($27)\ncmpeq $27,26,$23\nbeq $23,L.2375\nldq $27,-80+176($sp)\ncmpeq $27,26,$23\nbeq $23,L.2375\nldl $27,-84+176($sp)\nzap $27,240,$27\ncmpeq $27,26,$23\nbeq $23,L.2375\ncvttqc $f8,$f1\ncvtql $f1,$f1\nsts $f1,-56+176($sp)\nldl $27,-56+176($sp)\ncmpeq $27,26,$23\nbeq $23,L.2375\ncvttqc $f9,$f1\ncvtql $f1,$f1\nsts $f1,-56+176($sp)\nldl $27,-56+176($sp)\ncmpeq $27,26,$23\nbne $23,L.2369\nL.2375:\nlda $10,4($10)\nL.2369:\nlda $27,-65+176($sp)\nldb $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\ncmpeq $27,26,$23\nbeq $23,L.2382\nlda $27,-68+176($sp)\nldw $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\ncmpeq $27,26,$23\nbeq $23,L.2382\nldl $27,-64+176($sp)\ncmpeq $27,26,$23\nbeq $23,L.2382\nldl $27,-84+176($sp)\nzap $27,240,$27\ncmpeq $27,26,$23\nbeq $23,L.2382\ncvttqc $f8,$f1\nstt $f1,-56+176($sp)\nldq $27,-56+176($sp)\ncmpeq $27,26,$23\nbeq $23,L.2382\ncvttqc $f9,$f1\nstt $f1,-56+176($sp)\nldq $27,-56+176($sp)\ncmpeq $27,26,$23\nbne $23,L.2376\nL.2382:\nlda $10,8($10)\nL.2376:\nlda $27,26\nlda $25,-65+176($sp)\nldb $25,($25)\ncmpeq $25,$27,$23\nbeq $23,L.2391\nlda $25,-68+176($sp)\nldw $25,($25)\ncmpeq $25,$27,$23\nbeq $23,L.2391\nldl $25,-64+176($sp)\ncmpeq $25,$27,$23\nbeq $23,L.2391\nldq $25,-80+176($sp)\ncmpeq $25,$27,$23\nbeq $23,L.2391\nlds $f30,L.826\ncmptlt $f8,$f30,$f1\nfbne $f1,L.2392\nsubs $f8,$f30,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+176($sp)\nldl $27,-56+176($sp)\naddl $27,0x80000000,$27\nzap $27,240,$27\nstl $27,-88+176($sp)\nbr L.2393\nL.2392:\ncvttqc $f8,$f1\ncvtql $f1,$f1\nsts $f1,-56+176($sp)\nldl $27,-56+176($sp)\nstl $27,-88+176($sp)\nL.2393:\nldl $27,-88+176($sp)\nzap $27,240,$27\nlda $25,26\ncmpeq $27,$25,$23\nbeq $23,L.2391\nldt $f30,L.834\ncmptlt $f9,$f30,$f1\nfbne $f1,L.2394\nsubt $f9,$f30,$f30\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+176($sp)\nldl $27,-56+176($sp)\naddl $27,0x80000000,$27\nzap $27,240,$27\nstl $27,-92+176($sp)\nbr L.2395\nL.2394:\ncvttqc $f9,$f1\ncvtql $f1,$f1\nsts $f1,-56+176($sp)\nldl $27,-56+176($sp)\nstl $27,-92+176($sp)\nL.2395:\nldl $27,-92+176($sp)\nzap $27,240,$27\nlda $25,26\ncmpeq $27,$25,$23\nbne $23,L.2383\nL.2391:\nlda $10,16($10)\nL.2383:\nldt $f30,L.2353\nlda $27,-65+176($sp)\nldb $27,($27)\nstq $27,-56+176($sp)\nldt $f29,-56+176($sp)\ncvtqs $f29,$f29\ncvtst $f29,$f29\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.2402\nlda $27,-68+176($sp)\nldw $27,($27)\nstq $27,-56+176($sp)\nldt $f29,-56+176($sp)\ncvtqs $f29,$f29\ncvtst $f29,$f29\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.2402\nlds $f29,-64+176($sp)\ncvtlq $f29,$f29\ncvtqs $f29,$f29\ncvtst $f29,$f29\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.2402\nldt $f29,-80+176($sp)\ncvtqs $f29,$f29\ncvtst $f29,$f29\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.2402\nldl $27,-84+176($sp)\nzap $27,240,$27\nldt $f29,L.594\nsrl $27,1,$25\nstq $25,-56+176($sp)\nldt $f28,-56+176($sp)\ncvtqt $f28,$f28\nmult $f29,$f28,$f29\nand $27,1,$27\nstq $27,-56+176($sp)\nldt $f28,-56+176($sp)\ncvtqt $f28,$f28\naddt $f29,$f28,$f29\ncvtts $f29,$f29\ncvtst $f29,$f29\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.2402\ncvtts $f9,$f29\ncvtst $f29,$f29\ncmpteq $f29,$f30,$f1\nfbne $f1,L.2396\nL.2402:\nlda $10,32($10)\nL.2396:\nldt $f30,L.2353\nlda $27,-65+176($sp)\nldb $27,($27)\nstq $27,-56+176($sp)\nldt $f29,-56+176($sp)\ncvtqt $f29,$f29\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.2409\nlda $27,-68+176($sp)\nldw $27,($27)\nstq $27,-56+176($sp)\nldt $f29,-56+176($sp)\ncvtqt $f29,$f29\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.2409\nlds $f29,-64+176($sp)\ncvtlq $f29,$f29\ncvtqt $f29,$f29\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.2409\nldt $f29,-80+176($sp)\ncvtqt $f29,$f29\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.2409\nldl $27,-84+176($sp)\nzap $27,240,$27\nldt $f29,L.594\nsrl $27,1,$25\nstq $25,-56+176($sp)\nldt $f28,-56+176($sp)\ncvtqt $f28,$f28\nmult $f29,$f28,$f29\nand $27,1,$27\nstq $27,-56+176($sp)\nldt $f28,-56+176($sp)\ncvtqt $f28,$f28\naddt $f29,$f28,$f29\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.2409\ncvtst $f8,$f29\ncmpteq $f29,$f30,$f1\nfbne $f1,L.2403\nL.2409:\nlda $10,64($10)\nL.2403:\ncmpeq $10,$31,$23\nbne $23,L.2410\nlda $27,16\nlda $9,16($9)\nlda $16,L.2332\nmov $27,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2410:\nmov $9,$0\nL.2331:\nldt $f8,0($sp)\nldt $f9,8($sp)\nldq $9,16($sp)\nldq $10,24($sp)\nldq $11,32($sp)\nldq $12,40($sp)\nldq $13,48($sp)\nldq $14,56($sp)\nldq $24,64($sp)\nldq $26,72($sp)\nlda $sp,176($sp)\nret\n.end s72\n.sdata\n.align 0\nL.2413:\n.byte 115\n.byte 55\n.byte 53\n.byte 55\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.2414:\n.byte 115\n.byte 55\n.byte 53\n.byte 55\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s757\n.text\n.text\n.ent s757\ns757:\nldgp $gp,0($27)\nlda $sp,-272($sp)\n.mask 0x5007e00,-216\n.frame $sp,272,$26,48\nstq $9,0($sp)\nstq $10,8($sp)\nstq $11,16($sp)\nstq $12,24($sp)\nstq $13,32($sp)\nstq $14,40($sp)\nstq $24,48($sp)\nstq $26,56($sp)\nmov $16,$14\n.prologue 1\nlda $27,L.2414\nstq $27,-152+272($sp)\nlda $27,60($14)\nstq $27,-160+272($sp)\nstl $31,-164+272($sp)\nL.2415:\nL.2416:\nldq $27,-160+272($sp)\nlda $25,1($27)\nstq $25,-160+272($sp)\nldq $25,-152+272($sp)\nlda $22,1($25)\nstq $22,-152+272($sp)\nldb $25,($25)\nstb $25,($27)\nsll $25,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbeq $23,L.2415\nlda $27,40\nstl $27,-168+272($sp)\nldl $27,-168+272($sp)\nsll $27,3,$25\naddl $25,0,$25\nsll $25,2,$25\naddl $25,0,$25\nlda $22,1280\ncmpeq $25,$22,$23\nbeq $23,L.2420\nsra $27,3,$27\naddl $27,0,$27\nsra $27,2,$27\naddl $27,0,$27\ncmpeq $27,1,$23\nbne $23,L.2418\nL.2420:\nldl $27,-164+272($sp)\nlda $27,1($27)\nstl $27,-164+272($sp)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.2421\nlda $16,L.2413\nlda $17,1\njsr $26,printf\nldgp $gp,0($26)\nL.2421:\nL.2418:\nmov $31,$9\nstl $31,-136+272($sp)\nbr L.2426\nL.2423:\nlda $27,1\nstl $27,-128+272($sp)\nldl $27,-128+272($sp)\nzap $27,240,$27\nldl $25,16($14)\nsubl $25,1,$25\nsll $27,$25,$27\nzap $27,240,$27\nstl $27,-132+272($sp)\nstl $31,-140+272($sp)\nldl $27,-140+272($sp)\nzap $27,240,$27\nnot $27,$27\nzap $27,240,$27\nldl $25,-136+272($sp)\nsrl $27,$25,$22\nstl $22,-144+272($sp)\nsll $27,$25,$27\nzap $27,240,$27\nstl $27,-140+272($sp)\nstl $31,-124+272($sp)\nbr L.2430\nL.2427:\nldl $27,-124+272($sp)\nldl $25,-136+272($sp)\ncmplt $27,$25,$23\nbeq $23,L.2438\nlda $27,1\nstl $27,-180+272($sp)\nbr L.2439\nL.2438:\nstl $31,-180+272($sp)\nL.2439:\nldl $27,-128+272($sp)\nzap $27,240,$27\nldl $25,-140+272($sp)\nzap $25,240,$25\nand $27,$25,$27\ncmpeq $27,$31,$23\nbeq $23,L.2440\nlda $27,1\nstl $27,-184+272($sp)\nbr L.2441\nL.2440:\nstl $31,-184+272($sp)\nL.2441:\nldl $27,-180+272($sp)\nldl $25,-184+272($sp)\ncmpeq $27,$25,$23\nbeq $23,L.2437\nldl $27,-124+272($sp)\nldl $25,-136+272($sp)\ncmplt $27,$25,$23\nbeq $23,L.2442\nlda $27,1\nstl $27,-188+272($sp)\nbr L.2443\nL.2442:\nstl $31,-188+272($sp)\nL.2443:\nldl $27,-132+272($sp)\nzap $27,240,$27\nldl $25,-144+272($sp)\nzap $25,240,$25\nand $27,$25,$27\ncmpeq $27,$31,$23\nbeq $23,L.2444\nlda $27,1\nstl $27,-192+272($sp)\nbr L.2445\nL.2444:\nstl $31,-192+272($sp)\nL.2445:\nldl $27,-188+272($sp)\nldl $25,-192+272($sp)\ncmpeq $27,$25,$23\nbne $23,L.2431\nL.2437:\nlda $9,1\nL.2431:\nldl $27,-128+272($sp)\nzap $27,240,$27\nsll $27,1,$27\nzap $27,240,$27\nstl $27,-128+272($sp)\nldl $27,-132+272($sp)\nzap $27,240,$27\nsrl $27,1,$27\nstl $27,-132+272($sp)\nL.2428:\nldl $27,-124+272($sp)\nlda $27,1($27)\nstl $27,-124+272($sp)\nL.2430:\nldl $27,-124+272($sp)\nldl $25,16($14)\ncmplt $27,$25,$23\nbne $23,L.2427\nL.2424:\nldl $27,-136+272($sp)\nlda $27,1($27)\nstl $27,-136+272($sp)\nL.2426:\nldl $27,-136+272($sp)\nldl $25,16($14)\ncmplt $27,$25,$23\nbne $23,L.2423\ncmpeq $9,$31,$23\nbne $23,L.2446\nldl $27,-164+272($sp)\nlda $27,2($27)\nstl $27,-164+272($sp)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.2448\nlda $16,L.2413\nlda $17,2\njsr $26,printf\nldgp $gp,0($26)\nL.2448:\nL.2446:\nlda $10,3\nlda $11,2\nlda $12,1\ncmplt $10,$11,$23\nbeq $23,L.2456\nlda $27,1\nstl $27,-184+272($sp)\nbr L.2457\nL.2456:\nstl $31,-184+272($sp)\nL.2457:\nldl $27,-184+272($sp)\ncmplt $27,$12,$23\nbeq $23,L.2454\nlda $27,1\nstl $27,-180+272($sp)\nbr L.2455\nL.2454:\nstl $31,-180+272($sp)\nL.2455:\nldl $27,-180+272($sp)\ncmpeq $27,1,$23\nbne $23,L.2450\nldl $27,-164+272($sp)\nlda $27,4($27)\nstl $27,-164+272($sp)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.2458\nlda $16,L.2413\nlda $17,4\njsr $26,printf\nldgp $gp,0($26)\nL.2458:\nL.2450:\nlda $27,-116+272($sp)\nlda $25,-120+272($sp)\ncmpeq $27,$25,$23\nbeq $23,L.2460\nldl $27,-164+272($sp)\nlda $27,8($27)\nstl $27,-164+272($sp)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.2463\nlda $16,L.2413\nlda $17,8\njsr $26,printf\nldgp $gp,0($26)\nL.2463:\nL.2460:\nlda $27,-116+272($sp)\nlda $25,-120+272($sp)\ncmpult $27,$25,$23\nbeq $23,L.2465\nldl $27,40($14)\ncmpeq $27,$31,$23\nbne $23,L.2468\nlda $16,L.2470\njsr $26,printf\nldgp $gp,0($26)\nL.2468:\nL.2465:\nmov $31,$9\nstl $31,-124+272($sp)\nL.2471:\nldl $27,-124+272($sp)\nsll $27,2,$27\nlda $25,-120+272($sp)\naddq $27,$25,$27\nlda $25,1\nstl $25,($27)\nL.2472:\nldl $27,-124+272($sp)\nlda $27,1($27)\nstl $27,-124+272($sp)\nldl $27,-124+272($sp)\ncmplt $27,16,$23\nbne $23,L.2471\nstl $31,-116+272($sp)\nstl $31,-104+272($sp)\nstl $31,-96+272($sp)\nstl $31,-92+272($sp)\nstl $31,-84+272($sp)\nstl $31,-68+272($sp)\nmov $31,$10\nL.2481:\nmov $31,$11\nL.2485:\nmov $31,$12\nL.2489:\nmov $31,$13\nL.2493:\ncmplt $10,$11,$23\nbeq $23,L.2504\nlda $27,1\nstl $27,-192+272($sp)\nbr L.2505\nL.2504:\nstl $31,-192+272($sp)\nL.2505:\ncmplt $12,$13,$23\nbeq $23,L.2506\nlda $27,1\nstl $27,-196+272($sp)\nbr L.2507\nL.2506:\nstl $31,-196+272($sp)\nL.2507:\nldl $27,-192+272($sp)\nldl $25,-196+272($sp)\ncmpeq $27,$25,$23\nbeq $23,L.2502\nlda $27,1\nstl $27,-188+272($sp)\nbr L.2503\nL.2502:\nstl $31,-188+272($sp)\nL.2503:\nldl $27,-188+272($sp)\nsll $10,3,$25\naddl $25,0,$25\nsll $11,2,$22\naddl $22,0,$22\naddl $25,$22,$25\nsll $12,1,$22\naddl $22,0,$22\naddl $25,$22,$25\naddl $25,$13,$25\nsll $25,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,2,$25\nlda $22,-120+272($sp)\naddq $25,$22,$25\nldl $25,($25)\ncmpeq $27,$25,$23\nbne $23,L.2497\nlda $9,1\nL.2497:\nL.2494:\nlda $13,1($13)\ncmplt $13,2,$23\nbne $23,L.2493\nL.2490:\nlda $12,1($12)\ncmplt $12,2,$23\nbne $23,L.2489\nL.2486:\nlda $11,1($11)\ncmplt $11,2,$23\nbne $23,L.2485\nL.2482:\nlda $10,1($10)\ncmplt $10,2,$23\nbne $23,L.2481\ncmpeq $9,$31,$23\nbne $23,L.2508\nldl $27,-164+272($sp)\nlda $27,16($27)\nstl $27,-164+272($sp)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.2510\nlda $16,L.2413\nlda $17,16\njsr $26,printf\nldgp $gp,0($26)\nL.2510:\nL.2508:\nstq $31,-176+272($sp)\nldq $27,-176+272($sp)\ncmpeq $27,$31,$23\nbne $23,L.2512\nldl $27,-164+272($sp)\nlda $27,32($27)\nstl $27,-164+272($sp)\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.2514\nlda $16,L.2413\nlda $17,32\njsr $26,printf\nldgp $gp,0($26)\nL.2514:\nL.2512:\nldl $0,-164+272($sp)\nL.2412:\nldq $9,0($sp)\nldq $10,8($sp)\nldq $11,16($sp)\nldq $12,24($sp)\nldq $13,32($sp)\nldq $14,40($sp)\nldq $24,48($sp)\nldq $26,56($sp)\nlda $sp,272($sp)\nret\n.end s757\n.sdata\n.align 0\nL.2517:\n.byte 76\n.byte 111\n.byte 99\n.byte 97\n.byte 108\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 37\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.2518:\n.byte 115\n.byte 55\n.byte 56\n.byte 49\n.byte 51\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.2519:\n.byte 115\n.byte 55\n.byte 56\n.byte 49\n.byte 51\n.byte 32\n.byte 32\n.byte 0\n.globl s7813\n.text\n.text\n.ent s7813\ns7813:\nldgp $gp,0($27)\nlda $sp,-192($sp)\n.mask 0x5007e00,-136\n.frame $sp,192,$26,48\nstq $9,0($sp)\nstq $10,8($sp)\nstq $11,16($sp)\nstq $12,24($sp)\nstq $13,32($sp)\nstq $14,40($sp)\nstq $24,48($sp)\nstq $26,56($sp)\nstq $16,144($sp)\n.prologue 1\nlda $9,L.2519\nldq $27,-48+192($sp)\nlda $25,60($27)\nstq $25,-64+192($sp)\nmov $31,$13\nstl $31,-68+192($sp)\nldl $14,48($27)\nL.2520:\nL.2521:\nldq $27,-64+192($sp)\nlda $25,1($27)\nstq $25,-64+192($sp)\nmov $9,$25\nlda $9,1($25)\nldb $25,($25)\nstb $25,($27)\nsll $25,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbeq $23,L.2520\nbr L.2523\nlda $13,1\ncmpeq $14,$31,$23\nbne $23,L.2525\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2525:\nL.2523:\nbr L.2527\nlda $13,2\ncmpeq $14,$31,$23\nbne $23,L.2529\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2529:\nL.2527:\nbr L.2531\nlda $13,3\ncmpeq $14,$31,$23\nbne $23,L.2533\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2533:\nL.2531:\nbr L.2535\nlda $13,4\ncmpeq $14,$31,$23\nbne $23,L.2537\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2537:\nL.2535:\nbr L.2539\nlda $13,5\ncmpeq $14,$31,$23\nbne $23,L.2541\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2541:\nL.2539:\nbr L.2543\nlda $13,6\ncmpeq $14,$31,$23\nbne $23,L.2545\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2545:\nL.2543:\nbr L.2547\nlda $13,7\ncmpeq $14,$31,$23\nbne $23,L.2549\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2549:\nL.2547:\nbr L.2551\nlda $13,8\ncmpeq $14,$31,$23\nbne $23,L.2553\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2553:\nL.2551:\nbr L.2555\nlda $13,9\ncmpeq $14,$31,$23\nbne $23,L.2557\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2557:\nL.2555:\nbr L.2559\nlda $13,10\ncmpeq $14,$31,$23\nbne $23,L.2561\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2561:\nL.2559:\nbr L.2563\nlda $13,11\ncmpeq $14,$31,$23\nbne $23,L.2565\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2565:\nL.2563:\nbr L.2567\nlda $13,12\ncmpeq $14,$31,$23\nbne $23,L.2569\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2569:\nL.2567:\nbr L.2571\nlda $13,13\ncmpeq $14,$31,$23\nbne $23,L.2573\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2573:\nL.2571:\nbr L.2575\nlda $13,14\ncmpeq $14,$31,$23\nbne $23,L.2577\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2577:\nL.2575:\nbr L.2579\nlda $13,15\ncmpeq $14,$31,$23\nbne $23,L.2581\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2581:\nL.2579:\nbr L.2583\nlda $13,16\ncmpeq $14,$31,$23\nbne $23,L.2585\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2585:\nL.2583:\nbr L.2587\nlda $13,17\ncmpeq $14,$31,$23\nbne $23,L.2589\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2589:\nL.2587:\nbr L.2591\nlda $13,18\ncmpeq $14,$31,$23\nbne $23,L.2593\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2593:\nL.2591:\nbr L.2595\nlda $13,16\ncmpeq $14,$31,$23\nbne $23,L.2597\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2597:\nL.2595:\nbr L.2599\nlda $13,20\ncmpeq $14,$31,$23\nbne $23,L.2601\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2601:\nL.2599:\nbr L.2603\nlda $13,21\ncmpeq $14,$31,$23\nbne $23,L.2605\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2605:\nL.2603:\nbr L.2607\nlda $13,22\ncmpeq $14,$31,$23\nbne $23,L.2609\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2609:\nL.2607:\nbr L.2611\nlda $13,23\ncmpeq $14,$31,$23\nbne $23,L.2613\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2613:\nL.2611:\nbr L.2615\nlda $13,24\ncmpeq $14,$31,$23\nbne $23,L.2617\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2617:\nL.2615:\nbr L.2619\nlda $13,25\ncmpeq $14,$31,$23\nbne $23,L.2621\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2621:\nL.2619:\nbr L.2623\nlda $13,26\ncmpeq $14,$31,$23\nbne $23,L.2625\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2625:\nL.2623:\nbr L.2627\nlda $13,27\ncmpeq $14,$31,$23\nbne $23,L.2629\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2629:\nL.2627:\nbr L.2631\nlda $13,28\ncmpeq $14,$31,$23\nbne $23,L.2633\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2633:\nL.2631:\nbr L.2635\nlda $13,26\ncmpeq $14,$31,$23\nbne $23,L.2637\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2637:\nL.2635:\nbr L.2639\nlda $13,30\ncmpeq $14,$31,$23\nbne $23,L.2641\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2641:\nL.2639:\nbr L.2643\nlda $13,31\ncmpeq $14,$31,$23\nbne $23,L.2645\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2645:\nL.2643:\nbr L.2647\nlda $13,32\ncmpeq $14,$31,$23\nbne $23,L.2649\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2649:\nL.2647:\nbr L.2651\nlda $13,33\ncmpeq $14,$31,$23\nbne $23,L.2653\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2653:\nL.2651:\nbr L.2655\nlda $13,34\ncmpeq $14,$31,$23\nbne $23,L.2657\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2657:\nL.2655:\nbr L.2659\nlda $13,35\ncmpeq $14,$31,$23\nbne $23,L.2661\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2661:\nL.2659:\nbr L.2663\nlda $13,36\ncmpeq $14,$31,$23\nbne $23,L.2665\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2665:\nL.2663:\nbr L.2667\nlda $13,37\ncmpeq $14,$31,$23\nbne $23,L.2669\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2669:\nL.2667:\nbr L.2671\nlda $13,38\ncmpeq $14,$31,$23\nbne $23,L.2673\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2673:\nL.2671:\nbr L.2675\nlda $13,39\ncmpeq $14,$31,$23\nbne $23,L.2677\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2677:\nL.2675:\nbr L.2679\nlda $13,40\ncmpeq $14,$31,$23\nbne $23,L.2681\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2681:\nL.2679:\nbr L.2683\nlda $13,41\ncmpeq $14,$31,$23\nbne $23,L.2685\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2685:\nL.2683:\nbr L.2687\nlda $13,42\ncmpeq $14,$31,$23\nbne $23,L.2689\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2689:\nL.2687:\nbr L.2691\nlda $13,43\ncmpeq $14,$31,$23\nbne $23,L.2693\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2693:\nL.2691:\nbr L.2695\nlda $13,44\ncmpeq $14,$31,$23\nbne $23,L.2697\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2697:\nL.2695:\nbr L.2699\nlda $13,45\ncmpeq $14,$31,$23\nbne $23,L.2701\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2701:\nL.2699:\nbr L.2703\nlda $13,46\ncmpeq $14,$31,$23\nbne $23,L.2705\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2705:\nL.2703:\nbr L.2707\nlda $13,47\ncmpeq $14,$31,$23\nbne $23,L.2709\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2709:\nL.2707:\nbr L.2711\nlda $13,48\ncmpeq $14,$31,$23\nbne $23,L.2713\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2713:\nL.2711:\nbr L.2715\nlda $13,49\ncmpeq $14,$31,$23\nbne $23,L.2717\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2717:\nL.2715:\nbr L.2719\nlda $13,50\ncmpeq $14,$31,$23\nbne $23,L.2721\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2721:\nL.2719:\nbr L.2723\nlda $13,51\ncmpeq $14,$31,$23\nbne $23,L.2725\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2725:\nL.2723:\nbr L.2727\nlda $13,52\ncmpeq $14,$31,$23\nbne $23,L.2729\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2729:\nL.2727:\nbr L.2731\nlda $13,53\ncmpeq $14,$31,$23\nbne $23,L.2733\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2733:\nL.2731:\nbr L.2735\nlda $13,54\ncmpeq $14,$31,$23\nbne $23,L.2737\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2737:\nL.2735:\nbr L.2739\nlda $13,55\ncmpeq $14,$31,$23\nbne $23,L.2741\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2741:\nL.2739:\nbr L.2743\nlda $13,56\ncmpeq $14,$31,$23\nbne $23,L.2745\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2745:\nL.2743:\nbr L.2747\nlda $13,57\ncmpeq $14,$31,$23\nbne $23,L.2749\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2749:\nL.2747:\nbr L.2751\nlda $13,58\ncmpeq $14,$31,$23\nbne $23,L.2753\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2753:\nL.2751:\nbr L.2755\nlda $13,56\ncmpeq $14,$31,$23\nbne $23,L.2757\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2757:\nL.2755:\nbr L.2759\nlda $13,60\ncmpeq $14,$31,$23\nbne $23,L.2761\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2761:\nL.2759:\nbr L.2763\nlda $13,61\ncmpeq $14,$31,$23\nbne $23,L.2765\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2765:\nL.2763:\nbr L.2767\nlda $13,62\ncmpeq $14,$31,$23\nbne $23,L.2769\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2769:\nL.2767:\nbr L.2771\nlda $13,63\ncmpeq $14,$31,$23\nbne $23,L.2773\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2773:\nL.2771:\nbr L.2775\nlda $13,64\ncmpeq $14,$31,$23\nbne $23,L.2777\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2777:\nL.2775:\nbr L.2779\nlda $13,65\ncmpeq $14,$31,$23\nbne $23,L.2781\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2781:\nL.2779:\nbr L.2783\nlda $13,66\ncmpeq $14,$31,$23\nbne $23,L.2785\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2785:\nL.2783:\nbr L.2787\nlda $13,67\ncmpeq $14,$31,$23\nbne $23,L.2789\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2789:\nL.2787:\nbr L.2791\nlda $13,68\ncmpeq $14,$31,$23\nbne $23,L.2793\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2793:\nL.2791:\nbr L.2795\nlda $13,69\ncmpeq $14,$31,$23\nbne $23,L.2797\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2797:\nL.2795:\nbr L.2799\nlda $13,70\ncmpeq $14,$31,$23\nbne $23,L.2801\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2801:\nL.2799:\nbr L.2803\nlda $13,71\ncmpeq $14,$31,$23\nbne $23,L.2805\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2805:\nL.2803:\nbr L.2807\nlda $13,72\ncmpeq $14,$31,$23\nbne $23,L.2809\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2809:\nL.2807:\nbr L.2811\nlda $13,73\ncmpeq $14,$31,$23\nbne $23,L.2813\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2813:\nL.2811:\nbr L.2815\nlda $13,74\ncmpeq $14,$31,$23\nbne $23,L.2817\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2817:\nL.2815:\nbr L.2819\nlda $13,75\ncmpeq $14,$31,$23\nbne $23,L.2821\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2821:\nL.2819:\ncmpeq $13,$31,$23\nbne $23,L.2823\nldq $27,-48+192($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.2825\nlda $16,L.2518\nlda $17,1\njsr $26,printf\nldgp $gp,0($26)\nL.2825:\nldl $27,-68+192($sp)\nlda $27,1($27)\nstl $27,-68+192($sp)\nL.2823:\nmov $31,$13\nmov $31,$11\nmov $31,$12\nmov $12,$27\nlda $12,1($27)\nmov $31,$25\ncmpeq $27,$25,$23\nbne $23,L.2828\nmov $11,$27\nlda $11,1($27)\ncmpeq $27,$25,$23\nbne $23,L.2828\nlda $27,1\nstl $27,-80+192($sp)\nbr L.2829\nL.2828:\nstl $31,-80+192($sp)\nL.2829:\nldl $10,-80+192($sp)\ncmpeq $12,1,$23\nbne $23,L.2830\nlda $13,1\ncmpeq $14,$31,$23\nbne $23,L.2832\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2832:\nL.2830:\ncmpeq $11,$31,$23\nbne $23,L.2834\nlda $13,2\ncmpeq $14,$31,$23\nbne $23,L.2836\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2836:\nL.2834:\ncmpeq $10,$31,$23\nbne $23,L.2838\nlda $13,3\ncmpeq $14,$31,$23\nbne $23,L.2840\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2840:\nL.2838:\ncmpeq $12,$31,$23\nbne $23,L.2843\nmov $11,$25\nlda $11,1($25)\ncmpeq $25,$31,$23\nbne $23,L.2843\nlda $27,1\nstl $27,-84+192($sp)\nbr L.2844\nL.2843:\nstl $31,-84+192($sp)\nL.2844:\nldl $10,-84+192($sp)\ncmpeq $12,1,$23\nbne $23,L.2845\nlda $13,4\ncmpeq $14,$31,$23\nbne $23,L.2847\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2847:\nL.2845:\ncmpeq $11,1,$23\nbne $23,L.2849\nlda $13,5\ncmpeq $14,$31,$23\nbne $23,L.2851\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2851:\nL.2849:\ncmpeq $10,$31,$23\nbne $23,L.2853\nlda $13,6\ncmpeq $14,$31,$23\nbne $23,L.2855\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2855:\nL.2853:\nmov $12,$27\nsubl $27,1,$12\nmov $31,$25\ncmpeq $27,$25,$23\nbne $23,L.2858\ncmpeq $11,$25,$23\nbne $23,L.2858\nlda $27,1\nstl $27,-88+192($sp)\nbr L.2859\nL.2858:\nstl $31,-88+192($sp)\nL.2859:\nldl $10,-88+192($sp)\ncmpeq $12,$31,$23\nbne $23,L.2860\nlda $13,7\ncmpeq $14,$31,$23\nbne $23,L.2862\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2862:\nL.2860:\ncmpeq $11,1,$23\nbne $23,L.2864\nlda $13,8\ncmpeq $14,$31,$23\nbne $23,L.2866\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2866:\nL.2864:\ncmpeq $10,1,$23\nbne $23,L.2868\nlda $13,9\ncmpeq $14,$31,$23\nbne $23,L.2870\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2870:\nL.2868:\ncmpeq $12,$31,$23\nbne $23,L.2873\nmov $11,$25\nsubl $25,1,$11\ncmpeq $25,$31,$23\nbne $23,L.2873\nlda $27,1\nstl $27,-92+192($sp)\nbr L.2874\nL.2873:\nstl $31,-92+192($sp)\nL.2874:\nldl $10,-92+192($sp)\ncmpeq $12,$31,$23\nbne $23,L.2875\nlda $13,10\ncmpeq $14,$31,$23\nbne $23,L.2877\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2877:\nL.2875:\ncmpeq $11,1,$23\nbne $23,L.2879\nlda $13,11\ncmpeq $14,$31,$23\nbne $23,L.2881\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2881:\nL.2879:\ncmpeq $10,$31,$23\nbne $23,L.2883\nlda $13,12\ncmpeq $14,$31,$23\nbne $23,L.2885\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2885:\nL.2883:\ncmpeq $13,$31,$23\nbne $23,L.2887\nldq $27,-48+192($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.2889\nlda $16,L.2518\nlda $17,2\njsr $26,printf\nldgp $gp,0($26)\nL.2889:\nldl $27,-68+192($sp)\nlda $27,2($27)\nstl $27,-68+192($sp)\nL.2887:\nmov $31,$13\nmov $31,$11\nmov $31,$12\nmov $12,$27\nlda $12,1($27)\nmov $31,$25\ncmpeq $27,$25,$23\nbeq $23,L.2894\ncmpeq $11,$25,$23\nbne $23,L.2892\nL.2894:\nlda $27,1\nstl $27,-96+192($sp)\nbr L.2893\nL.2892:\nstl $31,-96+192($sp)\nL.2893:\nldl $10,-96+192($sp)\ncmpeq $12,1,$23\nbne $23,L.2895\nlda $13,1\ncmpeq $14,$31,$23\nbne $23,L.2897\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2897:\nL.2895:\ncmpeq $11,$31,$23\nbne $23,L.2899\nlda $13,2\ncmpeq $14,$31,$23\nbne $23,L.2901\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2901:\nL.2899:\ncmpeq $10,$31,$23\nbne $23,L.2903\nlda $13,3\ncmpeq $14,$31,$23\nbne $23,L.2905\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2905:\nL.2903:\nmov $11,$27\nlda $11,1($27)\nmov $31,$25\ncmpeq $27,$25,$23\nbeq $23,L.2910\ncmpeq $12,$25,$23\nbne $23,L.2908\nL.2910:\nlda $27,1\nstl $27,-100+192($sp)\nbr L.2909\nL.2908:\nstl $31,-100+192($sp)\nL.2909:\nldl $10,-100+192($sp)\ncmpeq $12,1,$23\nbne $23,L.2911\nlda $13,4\ncmpeq $14,$31,$23\nbne $23,L.2913\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2913:\nL.2911:\ncmpeq $11,1,$23\nbne $23,L.2915\nlda $13,5\ncmpeq $14,$31,$23\nbne $23,L.2917\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2917:\nL.2915:\ncmpeq $10,1,$23\nbne $23,L.2919\nlda $13,6\ncmpeq $14,$31,$23\nbne $23,L.2921\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2921:\nL.2919:\nmov $12,$27\nsubl $27,1,$12\nmov $31,$25\ncmpeq $27,$25,$23\nbeq $23,L.2926\nmov $11,$27\nsubl $27,1,$11\ncmpeq $27,$25,$23\nbne $23,L.2924\nL.2926:\nlda $27,1\nstl $27,-104+192($sp)\nbr L.2925\nL.2924:\nstl $31,-104+192($sp)\nL.2925:\nldl $10,-104+192($sp)\ncmpeq $12,$31,$23\nbne $23,L.2927\nlda $13,7\ncmpeq $14,$31,$23\nbne $23,L.2929\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2929:\nL.2927:\ncmpeq $11,1,$23\nbne $23,L.2931\nlda $13,8\ncmpeq $14,$31,$23\nbne $23,L.2933\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2933:\nL.2931:\ncmpeq $10,1,$23\nbne $23,L.2935\nlda $13,9\ncmpeq $14,$31,$23\nbne $23,L.2937\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2937:\nL.2935:\nmov $31,$27\ncmpeq $12,$27,$23\nbeq $23,L.2942\nmov $11,$25\nsubl $25,1,$11\ncmpeq $25,$27,$23\nbne $23,L.2940\nL.2942:\nlda $27,1\nstl $27,-108+192($sp)\nbr L.2941\nL.2940:\nstl $31,-108+192($sp)\nL.2941:\nldl $10,-108+192($sp)\ncmpeq $12,$31,$23\nbne $23,L.2943\nlda $13,10\ncmpeq $14,$31,$23\nbne $23,L.2945\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2945:\nL.2943:\ncmpeq $11,$31,$23\nbne $23,L.2947\nlda $13,11\ncmpeq $14,$31,$23\nbne $23,L.2949\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2949:\nL.2947:\ncmpeq $10,1,$23\nbne $23,L.2951\nlda $13,12\ncmpeq $14,$31,$23\nbne $23,L.2953\nlda $16,L.2517\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.2953:\nL.2951:\ncmpeq $13,$31,$23\nbne $23,L.2955\nldq $27,-48+192($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.2957\nlda $16,L.2518\nlda $17,4\njsr $26,printf\nldgp $gp,0($26)\nL.2957:\nldl $27,-68+192($sp)\nlda $27,4($27)\nstl $27,-68+192($sp)\nL.2955:\nmov $31,$11\nmov $31,$12\nstl $31,-72+192($sp)\nlda $25,1\nstl $25,-76+192($sp)\nldl $25,-76+192($sp)\ncmpeq $25,$31,$23\nbne $23,L.2961\nldl $27,-72+192($sp)\nstl $27,-112+192($sp)\nbr L.2962\nL.2961:\nldl $27,-76+192($sp)\ncmpeq $27,$31,$23\nbne $23,L.2963\nmov $12,$27\nlda $12,1($27)\nstl $27,-116+192($sp)\nbr L.2964\nL.2963:\nmov $11,$27\nlda $11,1($27)\nstl $27,-116+192($sp)\nL.2964:\nldl $27,-116+192($sp)\nstl $27,-112+192($sp)\nL.2962:\nldl $10,-112+192($sp)\ncmpeq $10,$31,$23\nbeq $23,L.2968\ncmpeq $12,$31,$23\nbeq $23,L.2968\ncmpeq $11,$31,$23\nbne $23,L.2965\nL.2968:\nldq $27,-48+192($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.2969\nlda $16,L.2518\nlda $17,8\njsr $26,printf\nldgp $gp,0($26)\nL.2969:\nldl $27,-68+192($sp)\nlda $27,8($27)\nstl $27,-68+192($sp)\nL.2965:\nldl $27,-76+192($sp)\ncmpeq $27,$31,$23\nbne $23,L.2976\nldl $27,-72+192($sp)\nstl $27,-120+192($sp)\nbr L.2977\nL.2976:\nlda $27,1\nstl $27,-120+192($sp)\nL.2977:\nldl $25,-120+192($sp)\ncmpeq $25,$31,$23\nbeq $23,L.2975\nldl $25,-72+192($sp)\ncmpeq $25,$31,$23\nbne $23,L.2978\nlda $27,1\nstl $27,-124+192($sp)\nbr L.2979\nL.2978:\nldl $27,-72+192($sp)\nstl $27,-124+192($sp)\nL.2979:\nldl $27,-124+192($sp)\ncmpeq $27,$31,$23\nbne $23,L.2971\nL.2975:\nldq $27,-48+192($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.2980\nlda $16,L.2518\nlda $17,16\njsr $26,printf\nldgp $gp,0($26)\nL.2980:\nldl $27,-68+192($sp)\nlda $27,16($27)\nstl $27,-68+192($sp)\nL.2971:\nldl $0,-68+192($sp)\nL.2516:\nldq $9,0($sp)\nldq $10,8($sp)\nldq $11,16($sp)\nldq $12,24($sp)\nldq $13,32($sp)\nldq $14,40($sp)\nldq $24,48($sp)\nldq $26,56($sp)\nlda $sp,192($sp)\nret\n.end s7813\n.sdata\n.align 0\nL.2983:\n.byte 115\n.byte 56\n.byte 49\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.2984:\n.byte 115\n.byte 56\n.byte 49\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.align 0\nL.2985:\n.byte 82\n.byte 101\n.byte 103\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 117\n.byte 110\n.byte 116\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 37\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 117\n.byte 110\n.byte 114\n.byte 101\n.byte 108\n.byte 105\n.byte 97\n.byte 98\n.byte 108\n.byte 101\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.2986:\n.byte 37\n.byte 100\n.byte 32\n.byte 114\n.byte 101\n.byte 103\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 97\n.byte 115\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 37\n.byte 115\n.byte 32\n.byte 118\n.byte 97\n.byte 114\n.byte 105\n.byte 97\n.byte 98\n.byte 108\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.globl s81\n.text\n.text\n.ent s81\ns81:\nldgp $gp,0($27)\nlda $sp,-160($sp)\n.mask 0x5007e00,-104\n.frame $sp,160,$26,48\nstq $9,0($sp)\nstq $10,8($sp)\nstq $11,16($sp)\nstq $12,24($sp)\nstq $13,32($sp)\nstq $14,40($sp)\nstq $24,48($sp)\nstq $26,56($sp)\nstq $16,112($sp)\n.prologue 1\nstl $31,-96+160($sp)\nstl $31,-84+160($sp)\nstl $31,-88+160($sp)\nstl $31,-92+160($sp)\nlda $27,L.2984\nstq $27,-72+160($sp)\nldq $27,-48+160($sp)\nlda $27,60($27)\nstq $27,-80+160($sp)\nL.2987:\nL.2988:\nldq $27,-80+160($sp)\nlda $25,1($27)\nstq $25,-80+160($sp)\nldq $25,-72+160($sp)\nlda $22,1($25)\nstq $22,-72+160($sp)\nldb $25,($25)\nstb $25,($27)\nsll $25,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbeq $23,L.2987\nlda $27,1\nstl $27,-60+160($sp)\nmov $31,$11\nL.2990:\nldl $27,-60+160($sp)\nmov $27,$25\nmov $25,$14\nmov $25,$10\nlda $13,-60+160($sp)\nlda $9,-60+160($sp)\nmov $27,$12\nstl $27,-64+160($sp)\nsll $14,8*(8-1),$27\nsra $27,8*(8-1),$27\nsll $10,8*(8-1),$25\nsra $25,8*(8-1),$25\ncmpeq $27,$25,$23\nbne $23,L.2994\nlda $27,1\nstl $27,-84+160($sp)\nL.2994:\nmov $13,$27\nmov $9,$25\ncmpeq $27,$25,$23\nbne $23,L.2996\nlda $27,1\nstl $27,-88+160($sp)\nL.2996:\nldl $27,-64+160($sp)\ncmpeq $12,$27,$23\nbne $23,L.2998\nlda $27,1\nstl $27,-92+160($sp)\nL.2998:\nldl $27,-60+160($sp)\nsll $27,1,$27\naddl $27,0,$27\nstl $27,-60+160($sp)\nL.2991:\nlda $11,1($11)\ncmplt $11,50,$23\nbne $23,L.2990\nldl $27,-84+160($sp)\ncmpeq $27,$31,$23\nbne $23,L.3000\nldl $27,-96+160($sp)\nlda $27,1($27)\nstl $27,-96+160($sp)\nldq $27,-48+160($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.3002\nlda $16,L.2983\nlda $17,1\njsr $26,printf\nldgp $gp,0($26)\nL.3002:\nL.3000:\nldl $27,-88+160($sp)\ncmpeq $27,$31,$23\nbne $23,L.3004\nldl $27,-96+160($sp)\nlda $27,2($27)\nstl $27,-96+160($sp)\nldq $27,-48+160($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.3006\nlda $16,L.2983\nlda $17,2\njsr $26,printf\nldgp $gp,0($26)\nL.3006:\nL.3004:\nldl $27,-92+160($sp)\ncmpeq $27,$31,$23\nbne $23,L.3008\nldl $27,-96+160($sp)\nlda $27,4($27)\nstl $27,-96+160($sp)\nldq $27,-48+160($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.3010\nlda $16,L.2983\nlda $17,4\njsr $26,printf\nldgp $gp,0($26)\nL.3010:\nL.3008:\njsr $26,regc\nldgp $gp,0($26)\nstl $0,-60+160($sp)\nldq $27,-48+160($sp)\nldl $27,40($27)\ncmpeq $27,$31,$23\nbne $23,L.3012\nldl $27,-60+160($sp)\ncmplt $27,$31,$23\nbeq $23,L.3014\nlda $16,L.2985\nlda $17,L.423\njsr $26,printf\nldgp $gp,0($26)\nbr L.3015\nL.3014:\nlda $16,L.2986\nldl $17,-60+160($sp)\nlda $18,L.423\njsr $26,printf\nldgp $gp,0($26)\nL.3015:\nL.3012:\njsr $26,regp\nldgp $gp,0($26)\nstl $0,-60+160($sp)\nldq $27,-48+160($sp)\nldl $27,40($27)\ncmpeq $27,$31,$23\nbne $23,L.3016\nldl $27,-60+160($sp)\ncmplt $27,$31,$23\nbeq $23,L.3018\nlda $16,L.2985\nlda $17,L.3020\njsr $26,printf\nldgp $gp,0($26)\nbr L.3019\nL.3018:\nlda $16,L.2986\nldl $17,-60+160($sp)\nlda $18,L.3020\njsr $26,printf\nldgp $gp,0($26)\nL.3019:\nL.3016:\njsr $26,regi\nldgp $gp,0($26)\nstl $0,-60+160($sp)\nldq $27,-48+160($sp)\nldl $27,40($27)\ncmpeq $27,$31,$23\nbne $23,L.3021\nldl $27,-60+160($sp)\ncmplt $27,$31,$23\nbeq $23,L.3023\nlda $16,L.2985\nlda $17,L.424\njsr $26,printf\nldgp $gp,0($26)\nbr L.3024\nL.3023:\nlda $16,L.2986\nldl $17,-60+160($sp)\nlda $18,L.424\njsr $26,printf\nldgp $gp,0($26)\nL.3024:\nL.3021:\nldl $0,-96+160($sp)\nL.2982:\nldq $9,0($sp)\nldq $10,8($sp)\nldq $11,16($sp)\nldq $12,24($sp)\nldq $13,32($sp)\nldq $14,40($sp)\nldq $24,48($sp)\nldq $26,56($sp)\nlda $sp,160($sp)\nret\n.end s81\n.globl regc\n.text\n.ent regc\nregc:\nldgp $gp,0($27)\nlda $sp,-272($sp)\n.mask 0x5007e00,-216\n.frame $sp,272,$26,48\nstq $9,0($sp)\nstq $10,8($sp)\nstq $11,16($sp)\nstq $12,24($sp)\nstq $13,32($sp)\nstq $14,40($sp)\nstq $24,48($sp)\nstq $26,56($sp)\n.prologue 1\nstb $31,-190+272($sp)\nlda $27,1\nstb $27,-169+272($sp)\nlda $27,2\nstb $27,-170+272($sp)\nlda $27,3\nstb $27,-171+272($sp)\nlda $14,4\nlda $27,5\nstb $27,-172+272($sp)\nlda $13,6\nlda $27,7\nstb $27,-173+272($sp)\nlda $12,8\nlda $27,9\nstb $27,-174+272($sp)\nlda $11,10\nlda $27,11\nstb $27,-175+272($sp)\nlda $10,12\nlda $27,13\nstb $27,-176+272($sp)\nlda $9,14\nlda $27,15\nstb $27,-177+272($sp)\nlda $27,16\nstb $27,-57+272($sp)\nlda $27,17\nstb $27,-178+272($sp)\nlda $27,18\nstb $27,-58+272($sp)\nlda $27,19\nstb $27,-179+272($sp)\nlda $27,20\nstb $27,-59+272($sp)\nlda $27,21\nstb $27,-180+272($sp)\nlda $27,22\nstb $27,-60+272($sp)\nlda $27,23\nstb $27,-181+272($sp)\nlda $27,24\nstb $27,-61+272($sp)\nlda $27,25\nstb $27,-182+272($sp)\nlda $27,26\nstb $27,-62+272($sp)\nlda $27,27\nstb $27,-183+272($sp)\nlda $27,28\nstb $27,-63+272($sp)\nlda $27,29\nstb $27,-184+272($sp)\nlda $27,30\nstb $27,-64+272($sp)\nlda $27,31\nstb $27,-185+272($sp)\nlda $27,32\nstb $27,-65+272($sp)\nlda $27,33\nstb $27,-186+272($sp)\nlda $27,34\nstb $27,-66+272($sp)\nlda $27,35\nstb $27,-187+272($sp)\nlda $27,36\nstb $27,-188+272($sp)\nlda $27,37\nstb $27,-189+272($sp)\nlda $27,38\nstb $27,-191+272($sp)\nlda $27,-169+272($sp)\nlda $25,-190+272($sp)\nsubq $27,$25,$25\nstl $25,-156+272($sp)\nlda $25,-170+272($sp)\nsubq $25,$27,$27\nstl $27,-152+272($sp)\nlda $27,-171+272($sp)\nlda $25,-170+272($sp)\nsubq $27,$25,$27\nstl $27,-148+272($sp)\nlda $27,-172+272($sp)\nlda $25,-171+272($sp)\nsubq $27,$25,$27\nstl $27,-144+272($sp)\nlda $27,-173+272($sp)\nlda $25,-172+272($sp)\nsubq $27,$25,$27\nstl $27,-140+272($sp)\nlda $27,-174+272($sp)\nlda $25,-173+272($sp)\nsubq $27,$25,$27\nstl $27,-136+272($sp)\nlda $27,-175+272($sp)\nlda $25,-174+272($sp)\nsubq $27,$25,$27\nstl $27,-132+272($sp)\nlda $27,-176+272($sp)\nlda $25,-175+272($sp)\nsubq $27,$25,$27\nstl $27,-128+272($sp)\nlda $27,-177+272($sp)\nlda $25,-176+272($sp)\nsubq $27,$25,$27\nstl $27,-124+272($sp)\nlda $27,-178+272($sp)\nlda $25,-177+272($sp)\nsubq $27,$25,$27\nstl $27,-120+272($sp)\nlda $27,-179+272($sp)\nlda $25,-178+272($sp)\nsubq $27,$25,$27\nstl $27,-116+272($sp)\nlda $27,-180+272($sp)\nlda $25,-179+272($sp)\nsubq $27,$25,$27\nstl $27,-112+272($sp)\nlda $27,-181+272($sp)\nlda $25,-180+272($sp)\nsubq $27,$25,$27\nstl $27,-108+272($sp)\nlda $27,-182+272($sp)\nlda $25,-181+272($sp)\nsubq $27,$25,$27\nstl $27,-104+272($sp)\nlda $27,-183+272($sp)\nlda $25,-182+272($sp)\nsubq $27,$25,$27\nstl $27,-100+272($sp)\nlda $27,-184+272($sp)\nlda $25,-183+272($sp)\nsubq $27,$25,$27\nstl $27,-96+272($sp)\nlda $27,-185+272($sp)\nlda $25,-184+272($sp)\nsubq $27,$25,$27\nstl $27,-92+272($sp)\nlda $27,-186+272($sp)\nlda $25,-185+272($sp)\nsubq $27,$25,$27\nstl $27,-88+272($sp)\nlda $27,-187+272($sp)\nlda $25,-186+272($sp)\nsubq $27,$25,$27\nstl $27,-84+272($sp)\nlda $27,-188+272($sp)\nlda $25,-187+272($sp)\nsubq $27,$25,$27\nstl $27,-80+272($sp)\nlda $27,-189+272($sp)\nlda $25,-188+272($sp)\nsubq $27,$25,$27\nstl $27,-76+272($sp)\nlda $27,-191+272($sp)\nlda $25,-189+272($sp)\nsubq $27,$25,$27\nstl $27,-72+272($sp)\nldl $27,-156+272($sp)\nstl $27,-168+272($sp)\nlda $27,1\nstl $27,-164+272($sp)\nstl $31,-160+272($sp)\nL.3047:\nldl $27,-164+272($sp)\ncmpeq $27,1,$23\nbne $23,L.3053\ncmpeq $27,2,$23\nbne $23,L.3056\ncmpeq $27,3,$23\nbne $23,L.3061\nbr L.3051\nL.3053:\nldl $27,-160+272($sp)\nsll $27,2,$27\nlda $25,-156+272($sp)\naddq $27,$25,$27\nldl $27,($27)\nldl $25,-168+272($sp)\ncmpeq $27,$25,$23\nbne $23,L.3052\nlda $27,2\nldl $25,-160+272($sp)\nsll $25,2,$25\nlda $22,-156+272($sp)\naddq $25,$22,$25\nldl $25,($25)\nstl $25,-200+272($sp)\nstl $27,-164+272($sp)\nlda $27,1\nstl $27,-196+272($sp)\nbr L.3052\nL.3056:\nldl $27,-160+272($sp)\nsll $27,2,$27\nlda $25,-156+272($sp)\naddq $27,$25,$27\nldl $27,($27)\nldl $25,-168+272($sp)\ncmpeq $27,$25,$23\nbeq $23,L.3057\nlda $27,3\nstl $27,-164+272($sp)\nbr L.3052\nL.3057:\nldl $27,-160+272($sp)\nsll $27,2,$27\nlda $25,-156+272($sp)\naddq $27,$25,$27\nldl $27,($27)\nldl $25,-200+272($sp)\ncmpeq $27,$25,$23\nbeq $23,L.3059\nldl $27,-196+272($sp)\nlda $27,1($27)\nstl $27,-196+272($sp)\nbr L.3052\nL.3059:\nlda $27,4\nstl $27,-164+272($sp)\nbr L.3052\nL.3061:\nldl $27,-160+272($sp)\nsll $27,2,$27\nlda $25,-156+272($sp)\naddq $27,$25,$27\nldl $27,($27)\nldl $25,-168+272($sp)\ncmpeq $27,$25,$23\nbne $23,L.3052\nlda $27,4\nstl $27,-164+272($sp)\nL.3051:\nL.3052:\nL.3048:\nldl $27,-160+272($sp)\nlda $27,1($27)\nstl $27,-160+272($sp)\nldl $27,-160+272($sp)\ncmplt $27,22,$23\nbne $23,L.3047\nldl $27,-164+272($sp)\ncmpeq $27,3,$23\nbeq $23,L.3064\nlda $27,16\nldl $25,-196+272($sp)\nsubl $27,$25,$0\nbr L.3025\nL.3064:\nlda $0,-1\nL.3025:\nldq $9,0($sp)\nldq $10,8($sp)\nldq $11,16($sp)\nldq $12,24($sp)\nldq $13,32($sp)\nldq $14,40($sp)\nldq $24,48($sp)\nldq $26,56($sp)\nlda $sp,272($sp)\nret\n.end regc\n.globl regi\n.text\n.ent regi\nregi:\nldgp $gp,0($27)\nlda $sp,-368($sp)\n.mask 0x5007e00,-312\n.frame $sp,368,$26,48\nstq $9,0($sp)\nstq $10,8($sp)\nstq $11,16($sp)\nstq $12,24($sp)\nstq $13,32($sp)\nstq $14,40($sp)\nstq $24,48($sp)\nstq $26,56($sp)\n.prologue 1\nstl $31,-284+368($sp)\nlda $27,1\nstl $27,-200+368($sp)\nlda $27,2\nstl $27,-204+368($sp)\nlda $27,3\nstl $27,-208+368($sp)\nlda $14,4\nlda $27,5\nstl $27,-212+368($sp)\nlda $13,6\nlda $27,7\nstl $27,-216+368($sp)\nlda $12,8\nlda $27,9\nstl $27,-220+368($sp)\nlda $11,10\nlda $27,11\nstl $27,-224+368($sp)\nlda $10,12\nlda $27,13\nstl $27,-228+368($sp)\nlda $9,14\nlda $27,15\nstl $27,-232+368($sp)\nlda $27,16\nstl $27,-60+368($sp)\nlda $27,17\nstl $27,-236+368($sp)\nlda $27,18\nstl $27,-64+368($sp)\nlda $27,19\nstl $27,-240+368($sp)\nlda $27,20\nstl $27,-68+368($sp)\nlda $27,21\nstl $27,-244+368($sp)\nlda $27,22\nstl $27,-72+368($sp)\nlda $27,23\nstl $27,-248+368($sp)\nlda $27,24\nstl $27,-76+368($sp)\nlda $27,25\nstl $27,-252+368($sp)\nlda $27,26\nstl $27,-80+368($sp)\nlda $27,27\nstl $27,-256+368($sp)\nlda $27,28\nstl $27,-84+368($sp)\nlda $27,29\nstl $27,-260+368($sp)\nlda $27,30\nstl $27,-88+368($sp)\nlda $27,31\nstl $27,-264+368($sp)\nlda $27,32\nstl $27,-92+368($sp)\nlda $27,33\nstl $27,-268+368($sp)\nlda $27,34\nstl $27,-96+368($sp)\nlda $27,35\nstl $27,-272+368($sp)\nlda $27,36\nstl $27,-276+368($sp)\nlda $27,37\nstl $27,-280+368($sp)\nlda $27,38\nstl $27,-288+368($sp)\nlda $27,-200+368($sp)\nstq $27,-304+368($sp)\nlda $25,-284+368($sp)\nsubq $27,$25,$25\ndivq $25,4,$25\nmov $25,$27\nstl $27,-184+368($sp)\nlda $27,-204+368($sp)\nldq $25,-304+368($sp)\nsubq $27,$25,$27\ndivq $27,4,$27\nstl $27,-180+368($sp)\nlda $27,-208+368($sp)\nlda $25,-204+368($sp)\nsubq $27,$25,$27\ndivq $27,4,$27\nstl $27,-176+368($sp)\nlda $27,-212+368($sp)\nlda $25,-208+368($sp)\nsubq $27,$25,$27\ndivq $27,4,$27\nstl $27,-172+368($sp)\nlda $27,-216+368($sp)\nlda $25,-212+368($sp)\nsubq $27,$25,$27\ndivq $27,4,$27\nstl $27,-168+368($sp)\nlda $27,-220+368($sp)\nlda $25,-216+368($sp)\nsubq $27,$25,$27\ndivq $27,4,$27\nstl $27,-164+368($sp)\nlda $27,-224+368($sp)\nlda $25,-220+368($sp)\nsubq $27,$25,$27\ndivq $27,4,$27\nstl $27,-160+368($sp)\nlda $27,-228+368($sp)\nlda $25,-224+368($sp)\nsubq $27,$25,$27\ndivq $27,4,$27\nstl $27,-156+368($sp)\nlda $27,-232+368($sp)\nlda $25,-228+368($sp)\nsubq $27,$25,$27\ndivq $27,4,$27\nstl $27,-152+368($sp)\nlda $27,-236+368($sp)\nlda $25,-232+368($sp)\nsubq $27,$25,$27\ndivq $27,4,$27\nstl $27,-148+368($sp)\nlda $27,-240+368($sp)\nlda $25,-236+368($sp)\nsubq $27,$25,$27\ndivq $27,4,$27\nstl $27,-144+368($sp)\nlda $27,-244+368($sp)\nlda $25,-240+368($sp)\nsubq $27,$25,$27\ndivq $27,4,$27\nstl $27,-140+368($sp)\nlda $27,-248+368($sp)\nlda $25,-244+368($sp)\nsubq $27,$25,$27\ndivq $27,4,$27\nstl $27,-136+368($sp)\nlda $27,-252+368($sp)\nlda $25,-248+368($sp)\nsubq $27,$25,$27\ndivq $27,4,$27\nstl $27,-132+368($sp)\nlda $27,-256+368($sp)\nlda $25,-252+368($sp)\nsubq $27,$25,$27\ndivq $27,4,$27\nstl $27,-128+368($sp)\nlda $27,-260+368($sp)\nlda $25,-256+368($sp)\nsubq $27,$25,$27\ndivq $27,4,$27\nstl $27,-124+368($sp)\nlda $27,-264+368($sp)\nlda $25,-260+368($sp)\nsubq $27,$25,$27\ndivq $27,4,$27\nstl $27,-120+368($sp)\nlda $27,-268+368($sp)\nlda $25,-264+368($sp)\nsubq $27,$25,$27\ndivq $27,4,$27\nstl $27,-116+368($sp)\nlda $27,-272+368($sp)\nlda $25,-268+368($sp)\nsubq $27,$25,$27\ndivq $27,4,$27\nstl $27,-112+368($sp)\nlda $27,-276+368($sp)\nlda $25,-272+368($sp)\nsubq $27,$25,$27\ndivq $27,4,$27\nstl $27,-108+368($sp)\nlda $27,-280+368($sp)\nlda $25,-276+368($sp)\nsubq $27,$25,$27\ndivq $27,4,$27\nstl $27,-104+368($sp)\nlda $27,-288+368($sp)\nlda $25,-280+368($sp)\nsubq $27,$25,$27\ndivq $27,4,$27\nstl $27,-100+368($sp)\nldl $27,-184+368($sp)\nstl $27,-196+368($sp)\nlda $27,1\nstl $27,-192+368($sp)\nstl $31,-188+368($sp)\nL.3088:\nldl $27,-192+368($sp)\ncmpeq $27,1,$23\nbne $23,L.3094\ncmpeq $27,2,$23\nbne $23,L.3097\ncmpeq $27,3,$23\nbne $23,L.3102\nbr L.3092\nL.3094:\nldl $27,-188+368($sp)\nsll $27,2,$27\nlda $25,-184+368($sp)\naddq $27,$25,$27\nldl $27,($27)\nldl $25,-196+368($sp)\ncmpeq $27,$25,$23\nbne $23,L.3093\nlda $27,2\nldl $25,-188+368($sp)\nsll $25,2,$25\nlda $22,-184+368($sp)\naddq $25,$22,$25\nldl $25,($25)\nstl $25,-296+368($sp)\nstl $27,-192+368($sp)\nlda $27,1\nstl $27,-292+368($sp)\nbr L.3093\nL.3097:\nldl $27,-188+368($sp)\nsll $27,2,$27\nlda $25,-184+368($sp)\naddq $27,$25,$27\nldl $27,($27)\nldl $25,-196+368($sp)\ncmpeq $27,$25,$23\nbeq $23,L.3098\nlda $27,3\nstl $27,-192+368($sp)\nbr L.3093\nL.3098:\nldl $27,-188+368($sp)\nsll $27,2,$27\nlda $25,-184+368($sp)\naddq $27,$25,$27\nldl $27,($27)\nldl $25,-296+368($sp)\ncmpeq $27,$25,$23\nbeq $23,L.3100\nldl $27,-292+368($sp)\nlda $27,1($27)\nstl $27,-292+368($sp)\nbr L.3093\nL.3100:\nlda $27,4\nstl $27,-192+368($sp)\nbr L.3093\nL.3102:\nldl $27,-188+368($sp)\nsll $27,2,$27\nlda $25,-184+368($sp)\naddq $27,$25,$27\nldl $27,($27)\nldl $25,-196+368($sp)\ncmpeq $27,$25,$23\nbne $23,L.3093\nlda $27,4\nstl $27,-192+368($sp)\nL.3092:\nL.3093:\nL.3089:\nldl $27,-188+368($sp)\nlda $27,1($27)\nstl $27,-188+368($sp)\nldl $27,-188+368($sp)\ncmplt $27,22,$23\nbne $23,L.3088\nldl $27,-192+368($sp)\ncmpeq $27,3,$23\nbeq $23,L.3105\nlda $27,16\nldl $25,-292+368($sp)\nsubl $27,$25,$0\nbr L.3066\nL.3105:\nlda $0,-1\nL.3066:\nldq $9,0($sp)\nldq $10,8($sp)\nldq $11,16($sp)\nldq $12,24($sp)\nldq $13,32($sp)\nldq $14,40($sp)\nldq $24,48($sp)\nldq $26,56($sp)\nlda $sp,368($sp)\nret\n.end regi\n.globl regp\n.text\n.ent regp\nregp:\nldgp $gp,0($27)\nlda $sp,-512($sp)\n.mask 0x5007e00,-456\n.frame $sp,512,$26,48\nstq $9,0($sp)\nstq $10,8($sp)\nstq $11,16($sp)\nstq $12,24($sp)\nstq $13,32($sp)\nstq $14,40($sp)\nstq $24,48($sp)\nstq $26,56($sp)\n.prologue 1\nlda $27,-416+512($sp)\nstq $27,-416+512($sp)\nlda $27,-368+512($sp)\nstq $27,-368+512($sp)\nlda $27,-376+512($sp)\nstq $27,-376+512($sp)\nlda $27,-384+512($sp)\nstq $27,-384+512($sp)\nlda $14,-240+512($sp)\nlda $27,-240+512($sp)\nstq $27,-240+512($sp)\nlda $13,-248+512($sp)\nlda $27,-248+512($sp)\nstq $27,-248+512($sp)\nlda $12,-256+512($sp)\nlda $27,-256+512($sp)\nstq $27,-256+512($sp)\nlda $11,-264+512($sp)\nlda $27,-264+512($sp)\nstq $27,-264+512($sp)\nlda $10,-272+512($sp)\nlda $27,-272+512($sp)\nstq $27,-272+512($sp)\nlda $9,-280+512($sp)\nlda $27,-280+512($sp)\nstq $27,-280+512($sp)\nlda $27,-288+512($sp)\nstq $27,-64+512($sp)\nlda $27,-288+512($sp)\nstq $27,-288+512($sp)\nlda $27,-296+512($sp)\nstq $27,-72+512($sp)\nlda $27,-296+512($sp)\nstq $27,-296+512($sp)\nlda $27,-304+512($sp)\nstq $27,-80+512($sp)\nlda $27,-304+512($sp)\nstq $27,-304+512($sp)\nlda $27,-312+512($sp)\nstq $27,-88+512($sp)\nlda $27,-312+512($sp)\nstq $27,-312+512($sp)\nlda $27,-320+512($sp)\nstq $27,-96+512($sp)\nlda $27,-320+512($sp)\nstq $27,-320+512($sp)\nlda $27,-328+512($sp)\nstq $27,-104+512($sp)\nlda $27,-328+512($sp)\nstq $27,-328+512($sp)\nlda $27,-336+512($sp)\nstq $27,-112+512($sp)\nlda $27,-336+512($sp)\nstq $27,-336+512($sp)\nlda $27,-344+512($sp)\nstq $27,-120+512($sp)\nlda $27,-344+512($sp)\nstq $27,-344+512($sp)\nlda $27,-352+512($sp)\nstq $27,-128+512($sp)\nlda $27,-352+512($sp)\nstq $27,-352+512($sp)\nlda $27,-360+512($sp)\nstq $27,-136+512($sp)\nlda $27,-360+512($sp)\nstq $27,-360+512($sp)\nlda $27,-392+512($sp)\nstq $27,-392+512($sp)\nlda $27,-400+512($sp)\nstq $27,-400+512($sp)\nlda $27,-424+512($sp)\nstq $27,-424+512($sp)\nlda $27,-368+512($sp)\nstq $27,-440+512($sp)\nlda $25,-416+512($sp)\nsubq $27,$25,$25\ndivq $25,8,$25\nmov $25,$27\nstl $27,-224+512($sp)\nlda $27,-376+512($sp)\nldq $25,-440+512($sp)\nsubq $27,$25,$27\ndivq $27,8,$27\nstl $27,-220+512($sp)\nlda $27,-384+512($sp)\nlda $25,-376+512($sp)\nsubq $27,$25,$27\ndivq $27,8,$27\nstl $27,-216+512($sp)\nlda $27,-240+512($sp)\nlda $25,-384+512($sp)\nsubq $27,$25,$27\ndivq $27,8,$27\nstl $27,-212+512($sp)\nlda $27,-248+512($sp)\nlda $25,-240+512($sp)\nsubq $27,$25,$27\ndivq $27,8,$27\nstl $27,-208+512($sp)\nlda $27,-256+512($sp)\nlda $25,-248+512($sp)\nsubq $27,$25,$27\ndivq $27,8,$27\nstl $27,-204+512($sp)\nlda $27,-264+512($sp)\nlda $25,-256+512($sp)\nsubq $27,$25,$27\ndivq $27,8,$27\nstl $27,-200+512($sp)\nlda $27,-272+512($sp)\nlda $25,-264+512($sp)\nsubq $27,$25,$27\ndivq $27,8,$27\nstl $27,-196+512($sp)\nlda $27,-280+512($sp)\nlda $25,-272+512($sp)\nsubq $27,$25,$27\ndivq $27,8,$27\nstl $27,-192+512($sp)\nlda $27,-288+512($sp)\nlda $25,-280+512($sp)\nsubq $27,$25,$27\ndivq $27,8,$27\nstl $27,-188+512($sp)\nlda $27,-296+512($sp)\nlda $25,-288+512($sp)\nsubq $27,$25,$27\ndivq $27,8,$27\nstl $27,-184+512($sp)\nlda $27,-304+512($sp)\nlda $25,-296+512($sp)\nsubq $27,$25,$27\ndivq $27,8,$27\nstl $27,-180+512($sp)\nlda $27,-312+512($sp)\nlda $25,-304+512($sp)\nsubq $27,$25,$27\ndivq $27,8,$27\nstl $27,-176+512($sp)\nlda $27,-320+512($sp)\nlda $25,-312+512($sp)\nsubq $27,$25,$27\ndivq $27,8,$27\nstl $27,-172+512($sp)\nlda $27,-328+512($sp)\nlda $25,-320+512($sp)\nsubq $27,$25,$27\ndivq $27,8,$27\nstl $27,-168+512($sp)\nlda $27,-336+512($sp)\nlda $25,-328+512($sp)\nsubq $27,$25,$27\ndivq $27,8,$27\nstl $27,-164+512($sp)\nlda $27,-344+512($sp)\nlda $25,-336+512($sp)\nsubq $27,$25,$27\ndivq $27,8,$27\nstl $27,-160+512($sp)\nlda $27,-352+512($sp)\nlda $25,-344+512($sp)\nsubq $27,$25,$27\ndivq $27,8,$27\nstl $27,-156+512($sp)\nlda $27,-360+512($sp)\nlda $25,-352+512($sp)\nsubq $27,$25,$27\ndivq $27,8,$27\nstl $27,-152+512($sp)\nlda $27,-392+512($sp)\nlda $25,-360+512($sp)\nsubq $27,$25,$27\ndivq $27,8,$27\nstl $27,-148+512($sp)\nlda $27,-400+512($sp)\nlda $25,-392+512($sp)\nsubq $27,$25,$27\ndivq $27,8,$27\nstl $27,-144+512($sp)\nlda $27,-424+512($sp)\nlda $25,-400+512($sp)\nsubq $27,$25,$27\ndivq $27,8,$27\nstl $27,-140+512($sp)\nldl $27,-224+512($sp)\nstl $27,-404+512($sp)\nlda $27,1\nstl $27,-232+512($sp)\nstl $31,-228+512($sp)\nL.3129:\nldl $27,-232+512($sp)\ncmpeq $27,1,$23\nbne $23,L.3135\ncmpeq $27,2,$23\nbne $23,L.3138\ncmpeq $27,3,$23\nbne $23,L.3143\nbr L.3133\nL.3135:\nldl $27,-228+512($sp)\nsll $27,2,$27\nlda $25,-224+512($sp)\naddq $27,$25,$27\nldl $27,($27)\nldl $25,-404+512($sp)\ncmpeq $27,$25,$23\nbne $23,L.3134\nlda $27,2\nldl $25,-228+512($sp)\nsll $25,2,$25\nlda $22,-224+512($sp)\naddq $25,$22,$25\nldl $25,($25)\nstl $25,-432+512($sp)\nstl $27,-232+512($sp)\nlda $27,1\nstl $27,-428+512($sp)\nbr L.3134\nL.3138:\nldl $27,-228+512($sp)\nsll $27,2,$27\nlda $25,-224+512($sp)\naddq $27,$25,$27\nldl $27,($27)\nldl $25,-404+512($sp)\ncmpeq $27,$25,$23\nbeq $23,L.3139\nlda $27,3\nstl $27,-232+512($sp)\nbr L.3134\nL.3139:\nldl $27,-228+512($sp)\nsll $27,2,$27\nlda $25,-224+512($sp)\naddq $27,$25,$27\nldl $27,($27)\nldl $25,-432+512($sp)\ncmpeq $27,$25,$23\nbeq $23,L.3141\nldl $27,-428+512($sp)\nlda $27,1($27)\nstl $27,-428+512($sp)\nbr L.3134\nL.3141:\nlda $27,4\nstl $27,-232+512($sp)\nbr L.3134\nL.3143:\nldl $27,-228+512($sp)\nsll $27,2,$27\nlda $25,-224+512($sp)\naddq $27,$25,$27\nldl $27,($27)\nldl $25,-404+512($sp)\ncmpeq $27,$25,$23\nbne $23,L.3134\nlda $27,4\nstl $27,-232+512($sp)\nL.3133:\nL.3134:\nL.3130:\nldl $27,-228+512($sp)\nlda $27,1($27)\nstl $27,-228+512($sp)\nldl $27,-228+512($sp)\ncmplt $27,22,$23\nbne $23,L.3129\nldl $27,-232+512($sp)\ncmpeq $27,3,$23\nbeq $23,L.3146\nlda $27,16\nldl $25,-428+512($sp)\nsubl $27,$25,$0\nbr L.3107\nL.3146:\nlda $0,-1\nL.3107:\nldq $9,0($sp)\nldq $10,8($sp)\nldq $11,16($sp)\nldq $12,24($sp)\nldq $13,32($sp)\nldq $14,40($sp)\nldq $24,48($sp)\nldq $26,56($sp)\nlda $sp,512($sp)\nret\n.end regp\n.lcomm L.3149,420\n.sdata\n.align 0\nL.3150:\n.byte 115\n.byte 56\n.byte 52\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.3151:\n.byte 115\n.byte 56\n.byte 52\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s84\n.text\n.text\n.ent s84\ns84:\nldgp $gp,0($27)\nlda $sp,-368($sp)\n.fmask 0x200,-368\n.mask 0x5007e00,-304\n.frame $sp,368,$26,48\nstt $f9,0($sp)\nstq $9,8($sp)\nstq $10,16($sp)\nstq $11,24($sp)\nstq $12,32($sp)\nstq $13,40($sp)\nstq $14,48($sp)\nstq $24,56($sp)\nstq $26,64($sp)\nmov $16,$14\n.prologue 1\nlda $10,L.3151\nlda $9,60($14)\nstl $31,-268+368($sp)\nL.3152:\nL.3153:\nmov $9,$27\nlda $9,1($27)\nmov $10,$25\nlda $10,1($25)\nldb $25,($25)\nstb $25,($27)\nsll $25,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbeq $23,L.3152\nlda $16,3\njsr $26,fip\nldgp $gp,0($26)\nstq $0,-280+368($sp)\nldq $27,-280+368($sp)\nldl $27,($27)\ncmpeq $27,3,$23\nbne $23,L.3155\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.3157\nlda $16,L.3150\nlda $17,1\njsr $26,printf\nldgp $gp,0($26)\nL.3157:\nldl $27,-268+368($sp)\nlda $27,1($27)\nstl $27,-268+368($sp)\nL.3155:\nlda $27,glork\nstq $27,-288+368($sp)\nlda $16,4\nldq $27,-288+368($sp)\njsr $26,($27)\nldgp $gp,0($26)\ncmpeq $0,4,$23\nbne $23,L.3159\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.3161\nlda $16,L.3150\nlda $17,2\njsr $26,printf\nldgp $gp,0($26)\nL.3161:\nldl $27,-268+368($sp)\nlda $27,2($27)\nstl $27,-268+368($sp)\nL.3159:\nmov $31,$12\nL.3163:\nsll $12,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nlda $25,-124+368($sp)\naddq $27,$25,$27\nstq $12,-56+368($sp)\nldt $f30,-56+368($sp)\ncvtqs $f30,$f30\nsts $f30,($27)\nsll $12,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,3,$25\nlda $22,-264+368($sp)\naddq $25,$22,$25\nsll $27,2,$27\nlda $22,-124+368($sp)\naddq $27,$22,$27\nstq $27,($25)\nL.3164:\nlda $12,1($12)\ncmplt $12,17,$23\nbne $23,L.3163\nlds $f9,L.410\nmov $31,$12\nL.3167:\nsll $12,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,3,$27\nlda $25,-264+368($sp)\naddq $27,$25,$27\nldq $27,($27)\nlds $f30,($27)\nadds $f9,$f30,$f9\nL.3168:\nlda $12,1($12)\ncmplt $12,17,$23\nbne $23,L.3167\nlds $f30,L.3173\ncmpteq $f9,$f30,$f1\nfbne $f1,L.3171\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.3174\nlda $16,L.3150\nlda $17,4\njsr $26,printf\nldgp $gp,0($26)\nL.3174:\nldl $27,-268+368($sp)\nlda $27,4($27)\nstl $27,-268+368($sp)\nL.3171:\nmov $31,$11\nL.3176:\nmov $31,$12\nL.3180:\nmov $31,$13\nL.3184:\nsll $13,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nlda $25,28\nsll $12,8*(8-4),$22\nsra $22,8*(8-4),$22\nmulq $25,$22,$25\nlda $22,140\nsll $11,8*(8-4),$8\nsra $8,8*(8-4),$8\nmulq $22,$8,$22\nlda $22,L.3149($22)\naddq $25,$22,$25\naddq $27,$25,$27\nlda $25,35\nmull $25,$11,$25\nlda $22,7\nmull $22,$12,$22\naddl $25,$22,$25\naddl $25,$13,$25\nstl $25,($27)\nL.3185:\nlda $13,1($13)\ncmplt $13,7,$23\nbne $23,L.3184\nL.3181:\nlda $12,1($12)\ncmplt $12,5,$23\nbne $23,L.3180\nL.3177:\nlda $11,1($11)\ncmplt $11,3,$23\nbne $23,L.3176\nlda $11,1\nlda $12,2\nlda $13,3\nlda $16,L.3149\nlda $17,105\nmov $31,$18\njsr $26,array\nldgp $gp,0($26)\nmov $0,$27\nstl $27,-292+368($sp)\nlda $25,140\nsll $11,8*(8-4),$22\nsra $22,8*(8-4),$22\nmulq $25,$22,$25\nlda $16,L.3149($25)\nlda $25,35\nmov $25,$17\nmov $25,$18\njsr $26,array\nldgp $gp,0($26)\nmov $0,$27\nstl $27,-296+368($sp)\nlda $25,28\nsll $12,8*(8-4),$22\nsra $22,8*(8-4),$22\nmulq $25,$22,$25\nlda $22,140\nsll $11,8*(8-4),$8\nsra $8,8*(8-4),$8\nmulq $22,$8,$22\nlda $22,L.3149($22)\naddq $25,$22,$16\nlda $17,7\nlda $18,49\njsr $26,array\nldgp $gp,0($26)\nldl $25,-292+368($sp)\nldl $22,-296+368($sp)\naddl $25,$22,$25\naddl $25,$0,$27\nsll $13,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,2,$25\nlda $22,28\nsll $12,8*(8-4),$8\nsra $8,8*(8-4),$8\nmulq $22,$8,$22\nlda $8,140\nsll $11,8*(8-4),$7\nsra $7,8*(8-4),$7\nmulq $8,$7,$8\nlda $8,L.3149($8)\naddq $22,$8,$22\naddq $25,$22,$25\nldl $25,($25)\naddl $27,$25,$27\nsubl $27,52,$27\ncmpeq $27,$31,$23\nbne $23,L.3188\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.3190\nlda $16,L.3150\nlda $17,8\njsr $26,printf\nldgp $gp,0($26)\nL.3190:\nldl $27,-268+368($sp)\nlda $27,8($27)\nstl $27,-268+368($sp)\nL.3188:\nldl $0,-268+368($sp)\nL.3148:\nldt $f9,0($sp)\nldq $9,8($sp)\nldq $10,16($sp)\nldq $11,24($sp)\nldq $12,32($sp)\nldq $13,40($sp)\nldq $14,48($sp)\nldq $24,56($sp)\nldq $26,64($sp)\nlda $sp,368($sp)\nret\n.end s84\n.globl array\n.text\n.ent array\narray:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4004000,-72\n.frame $sp,80,$26,48\nstq $14,0($sp)\nstq $26,8($sp)\n.prologue 1\nmov $31,$14\nbr L.3196\nL.3193:\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\naddq $27,$16,$27\nldl $27,($27)\naddl $14,$18,$25\ncmpeq $27,$25,$23\nbne $23,L.3197\nlda $0,1\nbr L.3192\nL.3197:\nL.3194:\nlda $14,1($14)\nL.3196:\ncmplt $14,$17,$23\nbne $23,L.3193\nmov $31,$0\nL.3192:\nldq $14,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end array\n.lcomm L.3200,4\n.globl fip\n.text\n.text\n.ent fip\nfip:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.frame $sp,64,$26,48\n.prologue 1\nlda $27,L.3200\nstl $16,L.3200\nmov $27,$0\nL.3199:\nlda $sp,64($sp)\nret\n.end fip\n.globl glork\n.text\n.ent glork\nglork:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.frame $sp,64,$26,48\n.prologue 1\nmov $16,$0\nL.3201:\nlda $sp,64($sp)\nret\n.end glork\n.sdata\n.align 0\nL.3203:\n.byte 115\n.byte 56\n.byte 53\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.3204:\n.byte 115\n.byte 56\n.byte 53\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.align 3\nL.3212:\n.quad L.423\n.quad L.425\n.quad L.424\n.quad L.426\n.quad L.427\n.quad L.428\n.quad L.429\n.align 0\nL.3213:\n.byte 32\n.byte 97\n.byte 108\n.byte 105\n.byte 103\n.byte 110\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 58\n.byte 32\n.byte 0\n.globl s85\n.text\n.text\n.ent s85\ns85:\nldgp $gp,0($27)\nlda $sp,-528($sp)\n.mask 0x5007c00,-480\n.frame $sp,528,$26,48\nstq $10,0($sp)\nstq $11,8($sp)\nstq $12,16($sp)\nstq $13,24($sp)\nstq $14,32($sp)\nstq $24,40($sp)\nstq $26,48($sp)\nmov $16,$14\n.prologue 1\nlda $12,L.3204\nlda $11,60($14)\nmov $31,$10\nL.3217:\nL.3218:\nmov $11,$27\nlda $11,1($27)\nmov $12,$25\nlda $12,1($25)\nldb $25,($25)\nstb $25,($27)\nsll $25,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbeq $23,L.3217\nlda $25,-348+528($sp)\nlda $22,-368+528($sp)\nsubq $25,$22,$25\ncmple $25,$31,$23\nbne $23,L.3228\nlda $25,-344+528($sp)\nlda $22,-348+528($sp)\nsubq $25,$22,$25\ncmple $25,$31,$23\nbne $23,L.3228\nlda $25,-336+528($sp)\nlda $22,-344+528($sp)\nsubq $25,$22,$25\ncmple $25,$31,$23\nbeq $23,L.3220\nL.3228:\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.3229\nlda $16,L.3203\nlda $17,1\njsr $26,printf\nldgp $gp,0($26)\nL.3229:\nlda $10,1($10)\nL.3220:\nlda $27,-409+528($sp)\nlda $25,-410+528($sp)\nsubq $27,$25,$27\nstl $27,-324+528($sp)\nlda $27,-412+528($sp)\nlda $25,-414+528($sp)\nsubq $27,$25,$27\nstl $27,-320+528($sp)\nlda $27,-420+528($sp)\nlda $25,-424+528($sp)\nsubq $27,$25,$27\nstl $27,-316+528($sp)\nlda $27,-432+528($sp)\nlda $25,-440+528($sp)\nsubq $27,$25,$27\nstl $27,-312+528($sp)\nlda $27,-444+528($sp)\nlda $25,-448+528($sp)\nsubq $27,$25,$27\nstl $27,-308+528($sp)\nlda $27,-452+528($sp)\nlda $25,-456+528($sp)\nsubq $27,$25,$27\nstl $27,-304+528($sp)\nlda $27,-464+528($sp)\nlda $25,-472+528($sp)\nsubq $27,$25,$27\nstl $27,-300+528($sp)\nldl $27,40($14)\ncmpeq $27,$31,$23\nbne $23,L.3244\nmov $31,$13\nL.3246:\nlda $16,L.3250\nsll $13,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,3,$25\nldq $17,L.3212($25)\nlda $18,L.3213\nsll $27,2,$27\nlda $25,-324+528($sp)\naddq $27,$25,$27\nldl $19,($27)\njsr $26,printf\nldgp $gp,0($26)\nL.3247:\nlda $13,1($13)\ncmplt $13,7,$23\nbne $23,L.3246\nL.3244:\nldl $27,-328+528($sp)\nor $27,56,$27\nstl $27,-328+528($sp)\nldl $27,-328+528($sp)\nmov $27,$25\nand $25,0xfffffffc,$25\nsll $27,26,$27\naddl $27,0,$27\nsra $27,29,$27\naddl $27,0,$27\nsll $27,30,$27\naddl $27,0,$27\nsra $27,30,$27\naddl $27,0,$27\nand $27,3,$27\nor $25,$27,$27\nstl $27,-328+528($sp)\nldl $27,-328+528($sp)\nmov $27,$25\nand $25,0xffffffc7,$25\nsll $27,30,$27\naddl $27,0,$27\nsra $27,30,$27\naddl $27,0,$27\nsll $27,29,$27\naddl $27,0,$27\nsra $27,29,$27\naddl $27,0,$27\nsll $27,3,$27\nzap $27,240,$27\nand $27,56,$27\nor $25,$27,$27\nstl $27,-328+528($sp)\nldl $27,-328+528($sp)\nsll $27,26,$27\naddl $27,0,$27\nsra $27,29,$27\naddl $27,0,$27\ncmpeq $27,3,$23\nbne $23,L.3251\nldl $27,-328+528($sp)\nsll $27,26,$27\naddl $27,0,$27\nsra $27,29,$27\naddl $27,0,$27\nlda $25,-1\ncmpeq $27,$25,$23\nbeq $23,L.3253\nldl $27,40($14)\ncmpeq $27,$31,$23\nbne $23,L.3254\nlda $16,L.3257\njsr $26,printf\nldgp $gp,0($26)\nbr L.3254\nL.3253:\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.3258\nlda $16,L.3203\nlda $17,2\njsr $26,printf\nldgp $gp,0($26)\nL.3258:\nlda $10,2($10)\nL.3254:\nL.3251:\nldl $27,-328+528($sp)\nor $27,64,$27\nstl $27,-328+528($sp)\nldl $27,-328+528($sp)\nsll $27,25,$27\naddl $27,0,$27\nsra $27,31,$27\naddl $27,0,$27\ncmpeq $27,1,$23\nbne $23,L.3260\nldl $27,40($14)\ncmpeq $27,$31,$23\nbne $23,L.3262\nlda $16,L.3264\njsr $26,printf\nldgp $gp,0($26)\nL.3262:\nL.3260:\nlda $27,-296+528($sp)\nsubq $27,$27,$27\ncmpeq $27,$31,$23\nbeq $23,L.3272\ncmpeq $27,$31,$23\nbeq $23,L.3272\ncmpeq $27,$31,$23\nbeq $23,L.3272\ncmpeq $27,$31,$23\nbeq $23,L.3272\ncmpeq $27,$31,$23\nbeq $23,L.3272\ncmpeq $27,$31,$23\nbeq $23,L.3272\ncmpeq $27,$31,$23\nbne $23,L.3265\nL.3272:\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.3273\nlda $16,L.3203\nlda $17,4\njsr $26,printf\nldgp $gp,0($26)\nL.3273:\nlda $10,4($10)\nL.3265:\nbr L.3275\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.3277\nlda $16,L.3203\nlda $17,8\njsr $26,printf\nldgp $gp,0($26)\nL.3277:\nlda $10,8($10)\nL.3275:\nlda $27,-408+528($sp)\nstq $27,-336+528($sp)\nlda $27,2\nstb $27,-408+528($sp)\nldq $27,-336+528($sp)\nldb $25,($27)\nlda $25,1($25)\nstb $25,($27)\nlda $27,-408+528($sp)\nldb $27,($27)\ncmpeq $27,3,$23\nbne $23,L.3281\nldl $27,44($14)\ncmpeq $27,$31,$23\nbne $23,L.3283\nlda $16,L.3203\nlda $17,16\njsr $26,printf\nldgp $gp,0($26)\nL.3283:\nlda $10,16($10)\nL.3281:\nmov $10,$0\nL.3202:\nldq $10,0($sp)\nldq $11,8($sp)\nldq $12,16($sp)\nldq $13,24($sp)\nldq $14,32($sp)\nldq $24,40($sp)\nldq $26,48($sp)\nlda $sp,528($sp)\nret\n.end s85\n.sdata\n.align 0\nL.3286:\n.byte 115\n.byte 56\n.byte 54\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.3287:\n.byte 115\n.byte 56\n.byte 54\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.align 2\nL.3288:\n.long 0x1\n.long 0x3\n.long 0x5\n.align 3\nL.3289:\n.quad L.3288+8\n.lcomm L.3291,40\n.sdata\n.align 2\nL.3292:\n.long 0x3f800000\n.long 0x40400000\n.long 0x40a00000\n.long 0x40000000\n.long 0x40800000\n.long 0x40c00000\n.long 0x40400000\n.long 0x40a00000\n.long 0x40e00000\n.long 0x0\n.long 0x0\n.long 0x0\n.align 2\nL.3293:\n.long 0x3f800000\n.long 0x40400000\n.long 0x40a00000\n.long 0x40000000\n.long 0x40800000\n.long 0x40c00000\n.long 0x40400000\n.long 0x40a00000\n.long 0x40e00000\n.space 12\n.align 2\nL.3294:\n.long 0x3f800000\n.long 0x40400000\n.long 0x40a00000\n.long 0x40000000\n.long 0x40800000\n.long 0x40c00000\n.long 0x40400000\n.long 0x40a00000\n.long 0x40e00000\n.space 12\n.align 2\nL.3295:\n.long 0x3f800000\n.space 8\n.long 0x40000000\n.space 8\n.long 0x40400000\n.space 8\n.long 0x40800000\n.space 8\n.globl s86\n.text\n.text\n.ent s86\ns86:\nldgp $gp,0($27)\nlda $sp,-144($sp)\n.mask 0x5007e00,-88\n.frame $sp,144,$26,48\nstq $9,0($sp)\nstq $10,8($sp)\nstq $11,16($sp)\nstq $12,24($sp)\nstq $13,32($sp)\nstq $14,40($sp)\nstq $24,48($sp)\nstq $26,56($sp)\nstq $16,96($sp)\n.prologue 1\nldq $27,L.3289\nlda $27,-4($27)\nstq $27,-80+144($sp)\njsr $26,one\nldgp $gp,0($26)\nsll $0,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nldq $25,-80+144($sp)\naddq $27,$25,$14\nlda $9,L.3287\nldq $27,-48+144($sp)\nlda $27,60($27)\nstq $27,-64+144($sp)\nstl $31,-68+144($sp)\nL.3296:\nL.3297:\nldq $27,-64+144($sp)\nlda $25,1($27)\nstq $25,-64+144($sp)\nmov $9,$25\nlda $9,1($25)\nldb $25,($25)\nstb $25,($27)\nsll $25,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbeq $23,L.3296\nldq $27,L.3289\nldl $27,($27)\ncmpeq $27,5,$23\nbne $23,L.3299\nldq $27,-48+144($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.3301\nlda $16,L.3286\nlda $17,1\njsr $26,printf\nldgp $gp,0($26)\nL.3301:\nldl $27,-68+144($sp)\nlda $27,1($27)\nstl $27,-68+144($sp)\nL.3299:\nldq $27,-80+144($sp)\nldl $27,($27)\ncmpeq $27,3,$23\nbne $23,L.3303\nldq $27,-48+144($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.3305\nlda $16,L.3286\nlda $17,2\njsr $26,printf\nldgp $gp,0($26)\nL.3305:\nldl $27,-68+144($sp)\nlda $27,2($27)\nstl $27,-68+144($sp)\nL.3303:\nldl $27,($14)\ncmpeq $27,5,$23\nbne $23,L.3307\nldq $27,-48+144($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.3309\nlda $16,L.3286\nlda $17,4\njsr $26,printf\nldgp $gp,0($26)\nL.3309:\nldl $27,-68+144($sp)\nlda $27,4($27)\nstl $27,-68+144($sp)\nL.3307:\nmov $31,$10\nmov $31,$13\nL.3311:\nsll $13,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nldl $27,L.3291($27)\ncmpeq $27,$31,$23\nbne $23,L.3315\nlda $10,1\nL.3315:\nL.3312:\nlda $13,1($13)\ncmplt $13,10,$23\nbne $23,L.3311\ncmpeq $10,$31,$23\nbne $23,L.3317\nldq $27,-48+144($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.3319\nlda $16,L.3286\nlda $17,8\njsr $26,printf\nldgp $gp,0($26)\nL.3319:\nldl $27,-68+144($sp)\nlda $27,8($27)\nstl $27,-68+144($sp)\nL.3317:\nmov $31,$10\nmov $31,$12\nL.3321:\nmov $31,$13\nL.3325:\nlda $27,3\nmull $27,$12,$27\naddl $27,$13,$11\nsll $13,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nlda $25,12\nsll $12,8*(8-4),$22\nsra $22,8*(8-4),$22\nmulq $25,$22,$25\nlda $22,L.3293($25)\naddq $27,$22,$22\nlds $f30,($22)\nlda $25,L.3294($25)\naddq $27,$25,$27\nlds $f29,($27)\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.3331\nsll $11,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nlds $f29,L.3292($27)\ncmpteq $f30,$f29,$f1\nfbne $f1,L.3329\nL.3331:\nlda $10,1\nL.3329:\nL.3326:\nlda $13,1($13)\ncmplt $13,3,$23\nbne $23,L.3325\nL.3322:\nlda $12,1($12)\ncmplt $12,4,$23\nbne $23,L.3321\ncmpeq $10,$31,$23\nbne $23,L.3332\nldq $27,-48+144($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.3334\nlda $16,L.3286\nlda $17,16\njsr $26,printf\nldgp $gp,0($26)\nL.3334:\nldl $27,-68+144($sp)\nlda $27,16($27)\nstl $27,-68+144($sp)\nL.3332:\nmov $31,$10\nmov $31,$13\nL.3336:\nlda $27,12\nsll $13,8*(8-4),$25\nsra $25,8*(8-4),$25\nmulq $27,$25,$27\nlds $f30,L.3295($27)\nlda $27,1($13)\nstq $27,-56+144($sp)\nldt $f29,-56+144($sp)\ncvtqs $f29,$f29\ncmpteq $f30,$f29,$f1\nfbne $f1,L.3340\nlda $10,1\nL.3340:\nL.3337:\nlda $13,1($13)\ncmplt $13,4,$23\nbne $23,L.3336\ncmpeq $10,$31,$23\nbne $23,L.3342\nldq $27,-48+144($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.3344\nlda $16,L.3286\nlda $17,32\njsr $26,printf\nldgp $gp,0($26)\nL.3344:\nldl $27,-68+144($sp)\nlda $27,32($27)\nstl $27,-68+144($sp)\nL.3342:\nldl $0,-68+144($sp)\nL.3285:\nldq $9,0($sp)\nldq $10,8($sp)\nldq $11,16($sp)\nldq $12,24($sp)\nldq $13,32($sp)\nldq $14,40($sp)\nldq $24,48($sp)\nldq $26,56($sp)\nlda $sp,144($sp)\nret\n.end s86\n.globl one\n.text\n.ent one\none:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.frame $sp,64,$26,48\n.prologue 1\nlda $0,1\nL.3346:\nlda $sp,64($sp)\nret\n.end one\n.sdata\n.align 0\nL.3348:\n.byte 115\n.byte 56\n.byte 56\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.3349:\n.byte 115\n.byte 56\n.byte 56\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s88\n.text\n.text\n.ent s88\ns88:\nldgp $gp,0($27)\nlda $sp,-128($sp)\n.mask 0x5007800,-88\n.frame $sp,128,$26,48\nstq $11,0($sp)\nstq $12,8($sp)\nstq $13,16($sp)\nstq $14,24($sp)\nstq $24,32($sp)\nstq $26,40($sp)\nstq $16,80($sp)\n.prologue 1\nlda $14,L.3349\nldq $27,-48+128($sp)\nlda $13,60($27)\nmov $31,$12\nL.3351:\nL.3352:\nmov $13,$27\nlda $13,1($27)\nmov $14,$25\nlda $14,1($25)\nldb $25,($25)\nstb $25,($27)\nsll $25,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbeq $23,L.3351\nbr L.3354\nldq $27,-48+128($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.3356\nlda $16,L.3348\nlda $17,1\njsr $26,printf\nldgp $gp,0($26)\nL.3356:\nlda $12,1($12)\nL.3354:\nlda $27,-76+128($sp)\nstq $27,metricp\nlda $27,2\nstl $27,-76+128($sp)\nldq $27,metricp\nlda $25,3\nstl $25,($27)\nldl $27,-76+128($sp)\ncmpeq $27,3,$23\nbne $23,L.3358\nldq $27,-48+128($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.3360\nlda $16,L.3348\nlda $17,2\njsr $26,printf\nldgp $gp,0($26)\nL.3360:\nlda $12,2($12)\nL.3358:\nldt $f30,L.417\nstt $f30,-72+128($sp)\nstt $f30,-64+128($sp)\nlda $11,-72+128($sp)\nldt $f30,L.416\nstt $f30,($11)\nldt $f30,L.416\nstt $f30,8($11)\nldt $f30,-72+128($sp)\nldt $f29,-64+128($sp)\naddt $f30,$f29,$f30\nldt $f29,L.414\ncmpteq $f30,$f29,$f1\nfbne $f1,L.3363\nldq $27,-48+128($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.3366\nlda $16,L.3348\nlda $17,4\njsr $26,printf\nldgp $gp,0($26)\nL.3366:\nlda $12,4($12)\nL.3363:\nmov $12,$0\nL.3347:\nldq $11,0($sp)\nldq $12,8($sp)\nldq $13,16($sp)\nldq $14,24($sp)\nldq $24,32($sp)\nldq $26,40($sp)\nlda $sp,128($sp)\nret\n.end s88\n.sdata\n.align 0\nL.3369:\n.byte 115\n.byte 57\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.3370:\n.byte 115\n.byte 57\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s9\n.text\n.text\n.ent s9\ns9:\nldgp $gp,0($27)\nlda $sp,-144($sp)\n.mask 0x5007e00,-88\n.frame $sp,144,$26,48\nstq $9,0($sp)\nstq $10,8($sp)\nstq $11,16($sp)\nstq $12,24($sp)\nstq $13,32($sp)\nstq $14,40($sp)\nstq $24,48($sp)\nstq $26,56($sp)\nstq $16,96($sp)\n.prologue 1\nlda $12,L.3370\nldq $27,-48+144($sp)\nlda $11,60($27)\nmov $31,$10\nL.3371:\nL.3372:\nmov $11,$27\nlda $11,1($27)\nmov $12,$25\nlda $12,1($25)\nldb $25,($25)\nstb $25,($27)\nsll $25,8*(8-1),$27\nsra $27,8*(8-1),$27\ncmpeq $27,$31,$23\nbeq $23,L.3371\nmov $31,$13\nmov $31,$14\nL.3374:\nlda $27,2\nmov $27,$9\nstl $27,-60+144($sp)\nlda $27,3\nstl $27,-64+144($sp)\nstl $27,-68+144($sp)\nldl $27,-68+144($sp)\ncmpeq $27,3,$23\nbeq $23,L.3380\nldl $27,-64+144($sp)\ncmpeq $27,3,$23\nbne $23,L.3378\nL.3380:\nlda $13,1\nL.3378:\nldl $27,-60+144($sp)\ncmpeq $27,2,$23\nbeq $23,L.3383\ncmpeq $9,2,$23\nbne $23,L.3381\nL.3383:\nlda $13,1\nL.3381:\nL.3375:\nlda $14,1($14)\ncmplt $14,2,$23\nbne $23,L.3374\ncmpeq $13,$31,$23\nbne $23,L.3388\nldq $27,-48+144($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.3386\nlda $16,L.3369\nlda $17,1\njsr $26,printf\nldgp $gp,0($26)\nL.3386:\nlda $10,1($10)\nbr L.3388\nldq $27,-48+144($sp)\nldl $27,44($27)\ncmpeq $27,$31,$23\nbne $23,L.3389\nlda $16,L.3369\nlda $17,2\njsr $26,printf\nldgp $gp,0($26)\nL.3389:\nlda $10,2($10)\nL.3388:\nmov $10,$0\nL.3368:\nldq $9,0($sp)\nldq $10,8($sp)\nldq $11,16($sp)\nldq $12,24($sp)\nldq $13,32($sp)\nldq $14,40($sp)\nldq $24,48($sp)\nldq $26,56($sp)\nlda $sp,144($sp)\nret\n.end s9\n.globl setev\n.text\n.ent setev\nsetev:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.frame $sp,64,$26,48\n.prologue 1\nlda $27,1066\nstl $27,extvar\nmov $31,$0\nL.3391:\nlda $sp,64($sp)\nret\n.end setev\n.globl rfs\n.comm rfs,8\n.globl crc\n.comm crc,4\n.globl rrc\n.comm rrc,4\n.globl flgl\n.comm flgl,4\n.globl flgd\n.comm flgd,4\n.globl flgm\n.comm flgm,4\n.globl flgs\n.comm flgs,4\n.globl dprec\n.comm dprec,4\n.globl fprec\n.comm fprec,4\n.globl dbits\n.comm dbits,4\n.globl fbits\n.comm fbits,4\n.globl ubits\n.comm ubits,4\n.globl lbits\n.comm lbits,4\n.globl metricp\n.comm metricp,8\n.globl extvar\n.comm extvar,4\n.rdata\n.align 0\nL.3264:\n.byte 66\n.byte 101\n.byte 32\n.byte 101\n.byte 115\n.byte 112\n.byte 101\n.byte 99\n.byte 105\n.byte 97\n.byte 108\n.byte 108\n.byte 121\n.byte 32\n.byte 99\n.byte 97\n.byte 114\n.byte 101\n.byte 102\n.byte 117\n.byte 108\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 49\n.byte 45\n.byte 98\n.byte 105\n.byte 116\n.byte 32\n.byte 102\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 115\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.3257:\n.byte 83\n.byte 105\n.byte 103\n.byte 110\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 101\n.byte 110\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 102\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.3250:\n.byte 37\n.byte 115\n.byte 37\n.byte 115\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 2\nL.3173:\n.long 0x43080000\n.align 0\nL.3020:\n.byte 112\n.byte 111\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 0\n.align 0\nL.2470:\n.byte 73\n.byte 110\n.byte 99\n.byte 114\n.byte 101\n.byte 97\n.byte 115\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 97\n.byte 114\n.byte 114\n.byte 97\n.byte 121\n.byte 32\n.byte 101\n.byte 108\n.byte 101\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 97\n.byte 115\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 100\n.byte 101\n.byte 99\n.byte 114\n.byte 101\n.byte 97\n.byte 115\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 108\n.byte 111\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 10\n.byte 0\n.align 2\nL.2354:\n.long 0x41d00000\n.align 3\nL.2353:\n.long 0x0\n.long 0x403a0000\n.align 3\nL.1657:\n.long 0x0\n.long 0x40040000\n.align 3\nL.1482:\n.long 0x0\n.long 0x40240000\n.align 2\nL.1453:\n.long 0x41200000\n.align 3\nL.1278:\n.long 0x0\n.long 0x40080000\n.align 2\nL.1249:\n.long 0x40400000\n.align 3\nL.1074:\n.long 0x0\n.long 0x401c0000\n.align 2\nL.1045:\n.long 0x40e00000\n.align 3\nL.868:\n.long 0x0\n.long 0x40140000\n.align 2\nL.839:\n.long 0x40a00000\n.align 3\nL.834:\n.long 0x0\n.long 0x41e00000\n.align 2\nL.826:\n.long 0x4f000000\n.align 0\nL.651:\n.byte 113\n.byte 117\n.byte 101\n.byte 101\n.byte 112\n.byte 0\n.align 0\nL.637:\n.byte 10\n.byte 0\n.align 0\nL.636:\n.byte 37\n.byte 100\n.byte 0\n.align 0\nL.631:\n.byte 32\n.byte 32\n.byte 32\n.byte 107\n.byte 101\n.byte 121\n.byte 61\n.byte 0\n.align 3\nL.594:\n.long 0x0\n.long 0x40000000\n.align 3\nL.534:\n.long 0x0\n.long 0x40ce8480\n.align 3\nL.533:\n.long 0x0\n.long 0x405f4000\n.align 2\nL.532:\n.long 0x42fa0000\n.align 2\nL.527:\n.long 0x40000000\n.align 0\nL.429:\n.byte 100\n.byte 111\n.byte 117\n.byte 98\n.byte 108\n.byte 101\n.byte 0\n.align 0\nL.428:\n.byte 102\n.byte 108\n.byte 111\n.byte 97\n.byte 116\n.byte 0\n.align 0\nL.427:\n.byte 117\n.byte 110\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 101\n.byte 100\n.byte 0\n.align 0\nL.426:\n.byte 108\n.byte 111\n.byte 110\n.byte 103\n.byte 0\n.align 0\nL.425:\n.byte 115\n.byte 104\n.byte 111\n.byte 114\n.byte 116\n.byte 0\n.align 0\nL.424:\n.byte 105\n.byte 110\n.byte 116\n.byte 0\n.align 0\nL.423:\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 0\n.align 3\nL.417:\n.long 0x0\n.long 0x0\n.align 3\nL.416:\n.long 0x0\n.long 0x3ff00000\n.align 3\nL.415:\n.long 0x0\n.long 0x40100000\n.align 3\nL.414:\n.long 0x0\n.long 0x40000000\n.align 2\nL.410:\n.long 0x0\n.align 2\nL.409:\n.long 0x3f800000\n.align 0\nL.388:\n.byte 113\n.byte 117\n.byte 101\n.byte 101\n.byte 112\n.byte 33\n.byte 0\n.align 0\nL.377:\n.byte 10\n.byte 9\n.byte 8\n.byte 13\n.byte 12\n.byte 92\n.byte 39\n.byte 0\n.align 0\nL.373:\n.byte 46\n.byte 34\n.byte 46\n.byte 0\n.align 0\nL.360:\n.byte 46\n.byte 46\n.byte 46\n.byte 0\n.align 3\nL.332:\n.long 0x0\n.long 0x40938800\n.align 0\nL.198:\n.byte 32\n.byte 32\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 114\n.byte 101\n.byte 115\n.byte 117\n.byte 108\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 110\n.byte 32\n.byte 97\n.byte 115\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 108\n.byte 111\n.byte 110\n.byte 103\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.197:\n.byte 68\n.byte 101\n.byte 99\n.byte 105\n.byte 109\n.byte 97\n.byte 108\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 111\n.byte 99\n.byte 116\n.byte 97\n.byte 108\n.byte 47\n.byte 104\n.byte 101\n.byte 120\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 115\n.byte 116\n.byte 97\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 115\n.byte 111\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 109\n.byte 101\n.byte 115\n.byte 32\n.byte 103\n.byte 105\n.byte 118\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.27:\n.byte 10\n.byte 70\n.byte 97\n.byte 105\n.byte 108\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.26:\n.byte 10\n.byte 78\n.byte 111\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 115\n.byte 32\n.byte 100\n.byte 101\n.byte 116\n.byte 101\n.byte 99\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.20:\n.byte 83\n.byte 101\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 37\n.byte 115\n.byte 32\n.byte 114\n.byte 101\n.byte 116\n.byte 117\n.byte 114\n.byte 110\n.byte 101\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/alpha/osf/tst/cvt.1bk",
    "content": "1 1 1 1 1 1 1 1 1.000000 1.000000 1.000000\n2 2 2 2 2 2 2 2 2.000000 2.000000 2.000000\n3 3 3 3 3 3 3 3 3.000000 3.000000 3.000000\n4 4 4 4 4 4 4 4 4.000000 4.000000 4.000000\n5 5 5 5 5 5 5 5 5.000000 5.000000 5.000000\n6 6 6 6 6 6 6 6 6.000000 6.000000 6.000000\n7 7 7 7 7 7 7 7 7.000000 7.000000 7.000000\n8 8 8 8 8 8 8 8 8.000000 8.000000 8.000000\n9 9 9 9 9 9 9 9 9.000000 9.000000 9.000000\n10 10 10 10 10 10 10 10 10.000000 10.000000 10.000000\n11 11 11 11 11 11 11 11 11.000000 11.000000 11.000000\n"
  },
  {
    "path": "lcc/alpha/osf/tst/cvt.2bk",
    "content": "tst/cvt.c:32: warning: conversion from `pointer to void function(void)' to `pointer to void' is compiler dependent\ntst/cvt.c:33: warning: conversion from `pointer to void' to `pointer to void function(void)' is compiler dependent\n"
  },
  {
    "path": "lcc/alpha/osf/tst/cvt.sbk",
    "content": ".globl print\n.text\n.text\n.ent print\nprint:\nldgp $gp,0($27)\nlda $sp,-112($sp)\n.mask 0x4000000,-64\n.frame $sp,112,$26,48\nstq $26,48($sp)\n.prologue 1\nlda $16,L.2\nlda $27,c\nldb $17,($27)\nlda $27,s\nldw $18,($27)\nldl $19,i\nldq $20,l\nlda $27,C\nldbu $21,($27)\nlda $27,S\nldwu $27,($27)\nstq $27,0($sp)\nldl $27,I\nzap $27,240,$27\nstq $27,8($sp)\nldq $27,L\nstq $27,16($sp)\nlds $f30,f\ncvtst $f30,$f30\nstt $f30,24($sp)\nldt $f30,d\nstt $f30,32($sp)\nldt $f30,D\nstt $f30,40($sp)\njsr $26,printf\nldgp $gp,0($26)\nL.1:\nldq $26,48($sp)\nlda $sp,112($sp)\nret\n.end print\n.globl main\n.text\n.ent main\nmain:\nldgp $gp,0($27)\nlda $sp,-160($sp)\n.mask 0x5007e00,-104\n.frame $sp,160,$26,48\nstq $9,0($sp)\nstq $10,8($sp)\nstq $11,16($sp)\nstq $12,24($sp)\nstq $13,32($sp)\nstq $14,40($sp)\nstq $24,48($sp)\nstq $26,56($sp)\n.prologue 1\nlda $27,c\nlda $25,1\nstb $25,c\nldb $27,($27)\nmov $27,$25\nstw $25,s\nstl $27,i\nsll $27,8*(8-4),$25\nsra $25,8*(8-4),$25\nstq $25,l\nmov $27,$25\nmov $25,$22\nstb $22,C\nmov $25,$22\nstw $22,S\nstl $25,I\nmov $27,$25\nstq $25,L\nstq $27,-56+160($sp)\nldt $f30,-56+160($sp)\ncvtqs $f30,$f30\nsts $f30,f\nstq $27,-56+160($sp)\nldt $f30,-56+160($sp)\ncvtqt $f30,$f30\nstt $f30,d\nstt $f30,D\njsr $26,print\nldgp $gp,0($26)\nlda $27,s\nlda $25,2\nstw $25,s\nldw $27,($27)\nmov $27,$25\nstb $25,c\nstl $27,i\nsll $27,8*(8-4),$25\nsra $25,8*(8-4),$25\nstq $25,l\nmov $27,$25\nmov $25,$22\nstb $22,C\nmov $25,$22\nstw $22,S\nstl $25,I\nmov $27,$25\nstq $25,L\nstq $27,-56+160($sp)\nldt $f30,-56+160($sp)\ncvtqs $f30,$f30\nsts $f30,f\nstq $27,-56+160($sp)\nldt $f30,-56+160($sp)\ncvtqt $f30,$f30\nstt $f30,d\nstt $f30,D\njsr $26,print\nldgp $gp,0($26)\nlda $27,3\nstl $27,i\nldl $27,i\nmov $27,$25\nstb $25,c\nmov $27,$25\nstw $25,s\nsll $27,8*(8-4),$25\nsra $25,8*(8-4),$25\nstq $25,l\nmov $27,$25\nmov $25,$22\nstb $22,C\nmov $25,$22\nstw $22,S\nstl $25,I\nmov $27,$25\nstq $25,L\nstq $27,-56+160($sp)\nldt $f30,-56+160($sp)\ncvtqs $f30,$f30\nsts $f30,f\nstq $27,-56+160($sp)\nldt $f30,-56+160($sp)\ncvtqt $f30,$f30\nstt $f30,d\nstt $f30,D\njsr $26,print\nldgp $gp,0($26)\nlda $27,4\nstq $27,l\nldq $27,l\nmov $27,$25\nstb $25,c\nmov $27,$25\nstw $25,s\nmov $27,$25\nstl $25,i\nmov $27,$25\nmov $25,$22\nstb $22,C\nmov $25,$22\nstw $22,S\nstl $25,I\nmov $27,$25\nstq $25,L\nstq $27,-56+160($sp)\nldt $f30,-56+160($sp)\ncvtqs $f30,$f30\nsts $f30,f\nstq $27,-56+160($sp)\nldt $f30,-56+160($sp)\ncvtqt $f30,$f30\nstt $f30,d\nstt $f30,D\njsr $26,print\nldgp $gp,0($26)\nlda $27,C\nlda $25,5\nstb $25,C\nldbu $27,($27)\nmov $27,$25\nstb $25,c\nmov $27,$25\nstw $25,s\nstl $27,i\nsll $27,8*(8-4),$25\nsra $25,8*(8-4),$25\nstq $25,l\nmov $27,$25\nmov $25,$22\nstw $22,S\nstl $25,I\nmov $27,$25\nstq $25,L\nstq $27,-56+160($sp)\nldt $f30,-56+160($sp)\ncvtqs $f30,$f30\nsts $f30,f\nstq $27,-56+160($sp)\nldt $f30,-56+160($sp)\ncvtqt $f30,$f30\nstt $f30,d\nstt $f30,D\njsr $26,print\nldgp $gp,0($26)\nlda $27,S\nlda $25,6\nstw $25,S\nldwu $27,($27)\nmov $27,$25\nstb $25,c\nmov $27,$25\nstw $25,s\nstl $27,i\nsll $27,8*(8-4),$25\nsra $25,8*(8-4),$25\nstq $25,l\nmov $27,$25\nmov $25,$22\nstb $22,C\nstl $25,I\nmov $27,$25\nstq $25,L\nstq $27,-56+160($sp)\nldt $f30,-56+160($sp)\ncvtqs $f30,$f30\nsts $f30,f\nstq $27,-56+160($sp)\nldt $f30,-56+160($sp)\ncvtqt $f30,$f30\nstt $f30,d\nstt $f30,D\njsr $26,print\nldgp $gp,0($26)\nlda $27,7\nstl $27,I\nldl $27,I\nzap $27,240,$27\nmov $27,$25\nmov $25,$22\nstb $22,c\nmov $25,$22\nstw $22,s\nstl $25,i\nand $27,(1<<(8*4))-1,$25\nstq $25,l\nmov $27,$25\nstb $25,C\nmov $27,$25\nstw $25,S\nand $27,(1<<(8*4))-1,$25\nstq $25,L\nldt $f30,L.4\nsrl $27,1,$25\nstq $25,-56+160($sp)\nldt $f29,-56+160($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+160($sp)\nldt $f29,-56+160($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f30\ncvtts $f30,$f29\nsts $f29,f\nstt $f30,d\nstt $f30,D\njsr $26,print\nldgp $gp,0($26)\nlda $27,8\nstq $27,L\nldq $27,L\nmov $27,$25\nmov $25,$22\nstb $22,c\nmov $25,$22\nstw $22,s\nstl $25,i\nmov $27,$25\nstq $25,l\nmov $27,$25\nstb $25,C\nlda $25,S\nmov $27,$22\nstw $22,S\nldwu $25,($25)\nstl $25,I\nldt $f30,L.4\nsrl $27,1,$25\nstq $25,-56+160($sp)\nldt $f29,-56+160($sp)\ncvtqt $f29,$f29\nmult $f30,$f29,$f30\nand $27,1,$27\nstq $27,-56+160($sp)\nldt $f29,-56+160($sp)\ncvtqt $f29,$f29\naddt $f30,$f29,$f30\ncvtts $f30,$f29\nsts $f29,f\nstt $f30,d\nstt $f30,D\njsr $26,print\nldgp $gp,0($26)\nlds $f30,L.5\nsts $f30,f\nlds $f30,f\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+160($sp)\nldl $27,-56+160($sp)\nmov $27,$25\nstb $25,c\nmov $27,$25\nstw $25,s\nstl $27,i\ncvttqc $f30,$f1\nstt $f1,-56+160($sp)\nldq $27,-56+160($sp)\nstq $27,l\nlds $f29,L.9\ncmptlt $f30,$f29,$f1\nfbne $f1,L.7\nsubs $f30,$f29,$f29\ncvttqc $f29,$f1\ncvtql $f1,$f1\nsts $f1,-56+160($sp)\nldl $27,-56+160($sp)\naddl $27,0x80000000,$14\nzap $14,240,$14\nbr L.8\nL.7:\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+160($sp)\nldl $27,-56+160($sp)\nmov $27,$14\nL.8:\nmov $14,$27\nstb $27,C\nlds $f30,f\nlds $f29,L.9\ncmptlt $f30,$f29,$f1\nfbne $f1,L.11\nsubs $f30,$f29,$f29\ncvttqc $f29,$f1\ncvtql $f1,$f1\nsts $f1,-56+160($sp)\nldl $27,-56+160($sp)\naddl $27,0x80000000,$13\nzap $13,240,$13\nbr L.12\nL.11:\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+160($sp)\nldl $27,-56+160($sp)\nmov $27,$13\nL.12:\nmov $13,$27\nstw $27,S\nlds $f30,f\nlds $f29,L.9\ncmptlt $f30,$f29,$f1\nfbne $f1,L.14\nsubs $f30,$f29,$f29\ncvttqc $f29,$f1\ncvtql $f1,$f1\nsts $f1,-56+160($sp)\nldl $27,-56+160($sp)\naddl $27,0x80000000,$12\nzap $12,240,$12\nbr L.15\nL.14:\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+160($sp)\nldl $27,-56+160($sp)\nmov $27,$12\nL.15:\nstl $12,I\nlds $f30,f\nlds $f29,L.19\ncmptlt $f30,$f29,$f1\nfbne $f1,L.17\nsubs $f30,$f29,$f29\ncvttqc $f29,$f1\nstt $f1,-56+160($sp)\nldq $27,-56+160($sp)\nlda $11,0x8000000000000000($27)\nbr L.18\nL.17:\ncvttqc $f30,$f1\nstt $f1,-56+160($sp)\nldq $27,-56+160($sp)\nmov $27,$11\nL.18:\nstq $11,L\nlds $f30,f\ncvtst $f30,$f30\nstt $f30,d\nstt $f30,D\njsr $26,print\nldgp $gp,0($26)\nldt $f30,L.20\nstt $f30,d\nldt $f30,d\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+160($sp)\nldl $27,-56+160($sp)\nmov $27,$25\nstb $25,c\nmov $27,$25\nstw $25,s\nstl $27,i\ncvttqc $f30,$f1\nstt $f1,-56+160($sp)\nldq $27,-56+160($sp)\nstq $27,l\nldt $f29,L.24\ncmptlt $f30,$f29,$f1\nfbne $f1,L.22\nsubt $f30,$f29,$f29\ncvttqc $f29,$f1\ncvtql $f1,$f1\nsts $f1,-56+160($sp)\nldl $27,-56+160($sp)\naddl $27,0x80000000,$10\nzap $10,240,$10\nbr L.23\nL.22:\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+160($sp)\nldl $27,-56+160($sp)\nmov $27,$10\nL.23:\nmov $10,$27\nstb $27,C\nldt $f30,d\nldt $f29,L.24\ncmptlt $f30,$f29,$f1\nfbne $f1,L.26\nsubt $f30,$f29,$f29\ncvttqc $f29,$f1\ncvtql $f1,$f1\nsts $f1,-56+160($sp)\nldl $27,-56+160($sp)\naddl $27,0x80000000,$9\nzap $9,240,$9\nbr L.27\nL.26:\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+160($sp)\nldl $27,-56+160($sp)\nmov $27,$9\nL.27:\nmov $9,$27\nstw $27,S\nldt $f30,d\nldt $f29,L.24\ncmptlt $f30,$f29,$f1\nfbne $f1,L.29\nsubt $f30,$f29,$f29\ncvttqc $f29,$f1\ncvtql $f1,$f1\nsts $f1,-56+160($sp)\nldl $27,-56+160($sp)\naddl $27,0x80000000,$27\nzap $27,240,$27\nstl $27,-60+160($sp)\nbr L.30\nL.29:\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+160($sp)\nldl $27,-56+160($sp)\nstl $27,-60+160($sp)\nL.30:\nldl $27,-60+160($sp)\nzap $27,240,$27\nstl $27,I\nldt $f30,d\nldt $f29,L.34\ncmptlt $f30,$f29,$f1\nfbne $f1,L.32\nsubt $f30,$f29,$f29\ncvttqc $f29,$f1\nstt $f1,-56+160($sp)\nldq $27,-56+160($sp)\nlda $27,0x8000000000000000($27)\nstq $27,-72+160($sp)\nbr L.33\nL.32:\ncvttqc $f30,$f1\nstt $f1,-56+160($sp)\nldq $27,-56+160($sp)\nstq $27,-72+160($sp)\nL.33:\nldq $27,-72+160($sp)\nstq $27,L\nldt $f30,d\ncvtts $f30,$f29\nsts $f29,f\nstt $f30,D\njsr $26,print\nldgp $gp,0($26)\nldt $f30,L.35\nstt $f30,D\nldt $f30,D\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+160($sp)\nldl $27,-56+160($sp)\nmov $27,$25\nstb $25,c\nmov $27,$25\nstw $25,s\nstl $27,i\ncvttqc $f30,$f1\nstt $f1,-56+160($sp)\nldq $27,-56+160($sp)\nstq $27,l\nldt $f29,L.39\ncmptlt $f30,$f29,$f1\nfbne $f1,L.37\nsubt $f30,$f29,$f29\ncvttqc $f29,$f1\ncvtql $f1,$f1\nsts $f1,-56+160($sp)\nldl $27,-56+160($sp)\naddl $27,0x80000000,$27\nzap $27,240,$27\nstl $27,-76+160($sp)\nbr L.38\nL.37:\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+160($sp)\nldl $27,-56+160($sp)\nstl $27,-76+160($sp)\nL.38:\nldl $27,-76+160($sp)\nzap $27,240,$27\nstb $27,C\nldt $f30,D\nldt $f29,L.39\ncmptlt $f30,$f29,$f1\nfbne $f1,L.41\nsubt $f30,$f29,$f29\ncvttqc $f29,$f1\ncvtql $f1,$f1\nsts $f1,-56+160($sp)\nldl $27,-56+160($sp)\naddl $27,0x80000000,$27\nzap $27,240,$27\nstl $27,-80+160($sp)\nbr L.42\nL.41:\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+160($sp)\nldl $27,-56+160($sp)\nstl $27,-80+160($sp)\nL.42:\nldl $27,-80+160($sp)\nzap $27,240,$27\nstw $27,S\nldt $f30,D\nldt $f29,L.39\ncmptlt $f30,$f29,$f1\nfbne $f1,L.44\nsubt $f30,$f29,$f29\ncvttqc $f29,$f1\ncvtql $f1,$f1\nsts $f1,-56+160($sp)\nldl $27,-56+160($sp)\naddl $27,0x80000000,$27\nzap $27,240,$27\nstl $27,-84+160($sp)\nbr L.45\nL.44:\ncvttqc $f30,$f1\ncvtql $f1,$f1\nsts $f1,-56+160($sp)\nldl $27,-56+160($sp)\nstl $27,-84+160($sp)\nL.45:\nldl $27,-84+160($sp)\nzap $27,240,$27\nstl $27,I\nldt $f30,D\nldt $f29,L.49\ncmptlt $f30,$f29,$f1\nfbne $f1,L.47\nsubt $f30,$f29,$f29\ncvttqc $f29,$f1\nstt $f1,-56+160($sp)\nldq $27,-56+160($sp)\nlda $27,0x8000000000000000($27)\nstq $27,-96+160($sp)\nbr L.48\nL.47:\ncvttqc $f30,$f1\nstt $f1,-56+160($sp)\nldq $27,-56+160($sp)\nstq $27,-96+160($sp)\nL.48:\nldq $27,-96+160($sp)\nstq $27,L\nldt $f30,D\ncvtts $f30,$f29\nsts $f29,f\nstt $f30,d\njsr $26,print\nldgp $gp,0($26)\nstq $31,p\nstq $31,p\nstq $31,p\nstq $31,p\nldq $27,P\nstq $27,p\nstq $31,P\nstq $31,P\nstq $31,P\nstq $31,P\nldq $27,p\nstq $27,P\nmov $31,$0\nL.3:\nldq $9,0($sp)\nldq $10,8($sp)\nldq $11,16($sp)\nldq $12,24($sp)\nldq $13,32($sp)\nldq $14,40($sp)\nldq $24,48($sp)\nldq $26,56($sp)\nlda $sp,160($sp)\nret\n.end main\n.globl P\n.comm P,8\n.globl p\n.comm p,8\n.globl D\n.comm D,8\n.globl d\n.comm d,8\n.globl f\n.comm f,4\n.globl L\n.comm L,8\n.globl I\n.comm I,4\n.globl S\n.comm S,2\n.globl C\n.comm C,1\n.globl l\n.comm l,8\n.globl i\n.comm i,4\n.globl s\n.comm s,2\n.globl c\n.comm c,1\n.rdata\n.align 3\nL.49:\n.long 0x0\n.long 0x43e00000\n.align 3\nL.39:\n.long 0x0\n.long 0x41e00000\n.align 3\nL.35:\n.long 0x0\n.long 0x40260000\n.align 3\nL.34:\n.long 0x0\n.long 0x43e00000\n.align 3\nL.24:\n.long 0x0\n.long 0x41e00000\n.align 3\nL.20:\n.long 0x0\n.long 0x40240000\n.align 2\nL.19:\n.long 0x5f000000\n.align 2\nL.9:\n.long 0x4f000000\n.align 2\nL.5:\n.long 0x41100000\n.align 3\nL.4:\n.long 0x0\n.long 0x40000000\n.align 0\nL.2:\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 108\n.byte 100\n.byte 32\n.byte 37\n.byte 117\n.byte 32\n.byte 37\n.byte 117\n.byte 32\n.byte 37\n.byte 117\n.byte 32\n.byte 37\n.byte 108\n.byte 117\n.byte 32\n.byte 37\n.byte 102\n.byte 32\n.byte 37\n.byte 102\n.byte 32\n.byte 37\n.byte 108\n.byte 102\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/alpha/osf/tst/fields.1bk",
    "content": "x = 1 2 3 4 -3 6\ny = 3 8 9\nx = 1 2 3 0 0 6\ny = 2 8 16\np->a = 0x3, p->b = 0xf\n"
  },
  {
    "path": "lcc/alpha/osf/tst/fields.2bk",
    "content": "tst/fields.c:6: warning: initializer exceeds bit-field width\ntst/fields.c:8: warning: initializer exceeds bit-field width\ntst/fields.c:30: warning: missing return value\ntst/fields.c:34: warning: missing return value\n"
  },
  {
    "path": "lcc/alpha/osf/tst/fields.sbk",
    "content": ".sdata\n.globl x\n.align 2\nx:\n.long 0x1\n.byte 0x2\n.space 3\n.byte 0x3\n.byte 0x40\n.space 2\n.byte 0x50\n.byte 0x6\n.space 2\n.globl i\n.align 2\ni:\n.long 0x10\n.globl y\n.align 2\ny:\n.byte 0x23\n.space 3\n.byte 0x9\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.globl main\n.text\n.text\n.ent main\nmain:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4000000,-72\n.frame $sp,80,$26,48\nstq $26,8($sp)\n.prologue 1\nlda $16,L.4\nldl $17,x\nlda $27,x+4\nldb $18,($27)\nldl $27,x+8\nsll $27,20,$27\naddl $27,0,$27\nsra $27,20,$19\naddl $19,0,$19\nldl $27,x+8\nsll $27,16,$27\naddl $27,0,$27\nsra $27,28,$20\naddl $20,0,$20\nldl $27,x+12\nsll $27,25,$27\naddl $27,0,$27\nsra $27,29,$21\naddl $21,0,$21\nlda $27,x+13\nldb $27,($27)\nstq $27,0($sp)\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.10\nldl $27,y\nzap $27,240,$27\nand $27,3,$17\nsrl $27,2,$27\nand $27,15,$18\nldl $19,y+4\nzap $19,240,$19\njsr $26,printf\nldgp $gp,0($26)\nldl $27,x+8\nand $27,0xffff0fff,$27\nldl $25,i\nsll $25,28,$25\naddl $25,0,$25\nsra $25,28,$25\naddl $25,0,$25\nsll $25,12,$25\nzap $25,240,$25\nand $25,0xf000,$25\nor $27,$25,$27\nstl $27,x+8\nldl $27,x+12\nand $27,0xffffff8f,$27\nstl $27,x+12\nlda $16,L.4\nldl $17,x\nlda $27,x+4\nldb $18,($27)\nldl $27,x+8\nsll $27,20,$27\naddl $27,0,$27\nsra $27,20,$19\naddl $19,0,$19\nldl $27,x+8\nsll $27,16,$27\naddl $27,0,$27\nsra $27,28,$20\naddl $20,0,$20\nldl $27,x+12\nsll $27,25,$27\naddl $27,0,$27\nsra $27,29,$21\naddl $21,0,$21\nlda $27,x+13\nldb $27,($27)\nstq $27,0($sp)\njsr $26,printf\nldgp $gp,0($26)\nldl $27,y\nzap $27,240,$27\nand $27,0xfffffffc,$27\nor $27,2,$27\nstl $27,y\nldl $27,i\nstl $27,y+4\nlda $16,L.10\nldl $27,y\nzap $27,240,$27\nand $27,3,$17\nsrl $27,2,$27\nand $27,15,$18\nldl $19,y+4\nzap $19,240,$19\njsr $26,printf\nldgp $gp,0($26)\nlda $16,x\njsr $26,f2\nldgp $gp,0($26)\nmov $31,$0\nL.3:\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end main\n.globl f1\n.text\n.ent f1\nf1:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4004000,-72\n.frame $sp,80,$26,48\nstq $14,0($sp)\nstq $26,8($sp)\nmov $16,$14\n.prologue 1\nldl $27,($14)\nzap $27,240,$27\nand $27,0xffffffc3,$27\nstl $27,($14)\nldl $27,($14)\nzap $27,240,$27\nand $27,0xfffffffc,$27\nand $31,3,$25\nand $25,3,$25\nor $27,$25,$27\nstl $27,($14)\nldl $27,($14)\nzap $27,240,$27\nand $27,60,$27\ncmpeq $27,$31,$23\nbne $23,L.22\nlda $16,L.24\njsr $26,printf\nldgp $gp,0($26)\nL.22:\nldl $27,($14)\nzap $27,240,$27\nor $27,3,$27\nstl $27,($14)\nldl $27,($14)\nzap $27,240,$27\nor $27,60,$27\nstl $27,($14)\nlda $16,L.25\nldl $27,($14)\nzap $27,240,$27\nand $27,3,$17\nsrl $27,2,$27\nand $27,15,$18\njsr $26,printf\nldgp $gp,0($26)\nmov $31,$0\nL.21:\nldq $14,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end f1\n.globl f2\n.text\n.ent f2\nf2:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4006000,-64\n.frame $sp,80,$26,48\nstq $13,0($sp)\nstq $14,8($sp)\nstq $26,16($sp)\nmov $16,$14\n.prologue 1\nldl $27,i\ncmpeq $27,$31,$23\nbeq $23,L.28\nlda $13,1\nbr L.29\nL.28:\nmov $31,$13\nL.29:\nldl $27,($14)\nzap $27,240,$27\nand $27,0xfffffffc,$27\nmov $13,$25\nand $25,3,$25\nand $25,3,$25\nor $27,$25,$27\nstl $27,($14)\nmov $14,$16\njsr $26,f1\nldgp $gp,0($26)\nldl $27,($14)\nzap $27,240,$27\nand $27,0xffffffc3,$27\nmov $31,$25\nand $25,15,$25\nsll $25,2,$25\nzap $25,240,$25\nand $25,60,$25\nor $27,$25,$27\nstl $27,($14)\nmov $31,$0\nL.26:\nldq $13,0($sp)\nldq $14,8($sp)\nldq $26,16($sp)\nlda $sp,80($sp)\nret\n.end f2\n.rdata\n.align 0\nL.25:\n.byte 112\n.byte 45\n.byte 62\n.byte 97\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 120\n.byte 37\n.byte 120\n.byte 44\n.byte 32\n.byte 112\n.byte 45\n.byte 62\n.byte 98\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 120\n.byte 37\n.byte 120\n.byte 10\n.byte 0\n.align 0\nL.24:\n.byte 112\n.byte 45\n.byte 62\n.byte 98\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.10:\n.byte 121\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.4:\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/alpha/osf/tst/front.2bk",
    "content": "tst/front.c:3: warning: missing return value\ntst/front.c:10: warning: missing return value\ntst/front.c:20: type error in argument 1 to `s'; found `pointer to struct D' expected `pointer to incomplete struct D defined at tst/front.c:14'\ntst/front.c:21: warning: missing return value\ntst/front.c:32: warning: missing return value\ntst/front.c:36: operands of = have illegal types `pointer to int' and `pointer to const int'\ntst/front.c:38: warning: missing return value\ntst/front.c:62: operands of = have illegal types `pointer to char' and `pointer to const void'\ntst/front.c:63: warning: missing return value\ntst/front.c:68: warning: missing return value\ntst/front.c:69: warning: inconsistent linkage for `yy' previously declared at tst/front.c:68\ntst/front.c:69: warning: missing return value\ntst/front.c:71: invalid storage class `static' for `int function goo'\ntst/front.c:71: warning: declaration of `goo' does not match previous declaration at tst/front.c:70\ntst/front.c:71: warning: missing return value\ntst/front.c:74: warning: declaration of `xr' does not match previous declaration at tst/front.c:72\ntst/front.c:74: warning: missing return value\ntst/front.c:81: warning: missing return value\ntst/front.c:82: warning: declaration of `ss2' does not match previous declaration at tst/front.c:81\ntst/front.c:84: warning: inconsistent linkage for `ss5' previously declared at tst/front.c:80\ntst/front.c:92: type error in argument 1 to `gx1'; found `pointer to double' expected `double'\ntst/front.c:92: warning: missing return value\ntst/front.c:95: redeclaration of `hx1' previously declared at tst/front.c:94\ntst/front.c:98: warning: missing return value\ntst/front.c:101: conflicting argument declarations for function `gg1'\ntst/front.c:101: warning: missing return value\ntst/front.c:112: type error in argument 4 to `qsort'; found `pointer to int function(pointer to pointer to char,pointer to pointer to char)' expected `pointer to int function(pointer to const void,pointer to const void)'\ntst/front.c:113: warning: missing return value\ntst/front.c:120: warning: missing return value\n"
  },
  {
    "path": "lcc/alpha/osf/tst/front.sbk",
    "content": ".globl main\n.text\n.text\n.ent main\nmain:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\n.prologue 1\nmov $31,$16\njsr $26,exit\nldgp $gp,0($26)\nmov $31,$0\nL.1:\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end main\n.globl nested\n.text\n.ent nested\nnested:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.frame $sp,64,$26,48\n.prologue 1\ncmplt $16,4,$23\nbeq $23,L.6\nlda $27,114\ncmpeq $17,$27,$23\nbne $23,L.9\nL.6:\ncmpeq $16,1,$23\nbeq $23,L.8\nlda $27,104\ncmpeq $17,$27,$23\nbne $23,L.9\nlda $27,105\ncmpeq $17,$27,$23\nbne $23,L.9\nL.8:\ncmpeq $16,2,$23\nbeq $23,L.3\nlda $27,111\ncmpeq $17,$27,$23\nbne $23,L.9\nlda $27,121\ncmpeq $17,$27,$23\nbeq $23,L.3\nL.9:\nmov $17,$16\nL.3:\nmov $31,$0\nL.2:\nlda $sp,64($sp)\nret\n.end nested\n.globl s\n.text\n.ent s\ns:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.frame $sp,64,$26,48\n.prologue 1\nL.10:\nlda $sp,64($sp)\nret\n.end s\n.sdata\n.globl Dy\n.align 2\nDy:\n.long 0x0\n.space 4\n.globl Dz\n.align 2\nDz:\n.long 0x1\n.space 4\n.globl Dfunc\n.text\n.text\n.ent Dfunc\nDfunc:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\n.prologue 1\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end Dfunc\n.globl f\n.text\n.ent f\nf:\nldgp $gp,0($27)\nlda $sp,-48($sp)\n.frame $sp,48,$26,48\n.prologue 1\nlda $sp,48($sp)\nret\n.end f\n.globl f1\n.text\n.ent f1\nf1:\nldgp $gp,0($27)\nlda $sp,-48($sp)\n.frame $sp,48,$26,48\n.prologue 1\nlda $sp,48($sp)\nret\n.end f1\n.globl f2\n.text\n.ent f2\nf2:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\nstq $16,16($sp)\nstq $17,24($sp)\n.prologue 1\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end f2\n.globl g\n.text\n.ent g\ng:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\nstq $16,16($sp)\n.prologue 1\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end g\n.globl h\n.text\n.ent h\nh:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\nstq $16,16($sp)\n.prologue 1\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end h\n.globl h1\n.text\n.ent h1\nh1:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\nstq $16,16($sp)\nstq $17,24($sp)\n.prologue 1\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end h1\n.globl h2\n.text\n.ent h2\nh2:\nldgp $gp,0($27)\nlda $sp,-48($sp)\n.frame $sp,48,$26,48\n.prologue 1\nlda $sp,48($sp)\nret\n.end h2\n.sdata\n.align 2\nL.21:\n.long 0x1\n.globl set1\n.text\n.text\n.ent set1\nset1:\nldgp $gp,0($27)\nlda $sp,-48($sp)\n.frame $sp,48,$26,48\n.prologue 1\nlda $sp,48($sp)\nret\n.end set1\n.sdata\n.align 2\nL.23:\n.long 0x2\n.globl set2\n.text\n.text\n.ent set2\nset2:\nldgp $gp,0($27)\nlda $sp,-48($sp)\n.frame $sp,48,$26,48\n.prologue 1\nlda $sp,48($sp)\nret\n.end set2\n.text\n.ent goo\ngoo:\nldgp $gp,0($27)\nlda $sp,-48($sp)\n.frame $sp,48,$26,48\n.prologue 1\nlda $sp,48($sp)\nret\n.end goo\n.globl sss\n.text\n.ent sss\nsss:\nldgp $gp,0($27)\nlda $sp,-48($sp)\n.frame $sp,48,$26,48\n.prologue 1\nlda $sp,48($sp)\nret\n.end sss\n.lcomm L.27,4\n.globl rrr\n.text\n.text\n.ent rrr\nrrr:\nldgp $gp,0($27)\nlda $sp,-48($sp)\n.frame $sp,48,$26,48\n.prologue 1\nlda $sp,48($sp)\nret\n.end rrr\n.globl setstatic\n.text\n.ent setstatic\nsetstatic:\nldgp $gp,0($27)\nlda $sp,-48($sp)\n.frame $sp,48,$26,48\n.prologue 1\nlda $sp,48($sp)\nret\n.end setstatic\n.globl gx1\n.text\n.ent gx1\ngx1:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\nstt $f16,16($sp)\n.prologue 1\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end gx1\n.globl ff1\n.text\n.ent ff1\nff1:\nldgp $gp,0($27)\nlda $sp,-48($sp)\n.frame $sp,48,$26,48\n.prologue 1\nlda $sp,48($sp)\nret\n.end ff1\n.globl gg1\n.text\n.ent gg1\ngg1:\nldgp $gp,0($27)\nlda $sp,-48($sp)\n.frame $sp,48,$26,48\n.prologue 1\nlda $sp,48($sp)\nret\n.end gg1\n.globl hh1\n.text\n.ent hh1\nhh1:\nldgp $gp,0($27)\nlda $sp,-48($sp)\n.frame $sp,48,$26,48\n.prologue 1\nlda $sp,48($sp)\nret\n.end hh1\n.globl cmp\n.text\n.ent cmp\ncmp:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\nstq $16,16($sp)\nstq $17,24($sp)\n.prologue 1\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end cmp\n.globl sort\n.text\n.ent sort\nsort:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\n.prologue 1\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end sort\n.globl onearg\n.text\n.ent onearg\nonearg:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\n.prologue 1\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end onearg\n.extern xr 4\n.globl ss4\n.comm ss4,4\n.lcomm ss2,4\n.lcomm ss5,4\n.globl ss3\n.comm ss3,4\n.lcomm ss1,4\n.lcomm yy,4\n.globl z\n.comm z,4\n.globl y\n.comm y,8\n.globl x\n.comm x,8\n.globl b\n.comm b,4\n.globl a\n.comm a,4\n"
  },
  {
    "path": "lcc/alpha/osf/tst/incr.1bk",
    "content": ""
  },
  {
    "path": "lcc/alpha/osf/tst/incr.2bk",
    "content": "tst/incr.c:1: warning: missing return value\ntst/incr.c:6: warning: expression with no effect elided\ntst/incr.c:6: warning: expression with no effect elided\ntst/incr.c:11: warning: missing return value\ntst/incr.c:16: warning: expression with no effect elided\ntst/incr.c:16: warning: expression with no effect elided\ntst/incr.c:21: warning: missing return value\ntst/incr.c:30: warning: missing return value\ntst/incr.c:39: warning: missing return value\n"
  },
  {
    "path": "lcc/alpha/osf/tst/incr.sbk",
    "content": ".globl main\n.text\n.text\n.ent main\nmain:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.frame $sp,64,$26,48\n.prologue 1\nmov $31,$0\nL.1:\nlda $sp,64($sp)\nret\n.end main\n.globl memchar\n.text\n.ent memchar\nmemchar:\nldgp $gp,0($27)\nlda $sp,-96($sp)\n.mask 0x5000000,-88\n.frame $sp,96,$26,48\nstq $24,0($sp)\nstq $26,8($sp)\n.prologue 1\nldq $27,-72+96($sp)\nlda $25,1($27)\nstq $25,-72+96($sp)\nldb $27,($27)\nstb $27,-57+96($sp)\nldq $27,-72+96($sp)\nlda $27,1($27)\nstq $27,-72+96($sp)\nldb $27,($27)\nstb $27,-57+96($sp)\nldq $27,-72+96($sp)\nlda $25,-1($27)\nstq $25,-72+96($sp)\nldb $27,($27)\nstb $27,-57+96($sp)\nldq $27,-72+96($sp)\nlda $27,-1($27)\nstq $27,-72+96($sp)\nldb $27,($27)\nstb $27,-57+96($sp)\nmov $31,$0\nL.2:\nldq $24,0($sp)\nldq $26,8($sp)\nlda $sp,96($sp)\nret\n.end memchar\n.globl memint\n.text\n.ent memint\nmemint:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.frame $sp,80,$26,48\n.prologue 1\nldq $27,-72+80($sp)\nlda $25,4($27)\nstq $25,-72+80($sp)\nldl $27,($27)\nstl $27,-60+80($sp)\nldq $27,-72+80($sp)\nlda $27,4($27)\nstq $27,-72+80($sp)\nldl $27,($27)\nstl $27,-60+80($sp)\nldq $27,-72+80($sp)\nlda $25,-4($27)\nstq $25,-72+80($sp)\nldl $27,($27)\nstl $27,-60+80($sp)\nldq $27,-72+80($sp)\nlda $27,-4($27)\nstq $27,-72+80($sp)\nldl $27,($27)\nstl $27,-60+80($sp)\nmov $31,$0\nL.3:\nlda $sp,80($sp)\nret\n.end memint\n.globl regchar\n.text\n.ent regchar\nregchar:\nldgp $gp,0($27)\nlda $sp,-96($sp)\n.mask 0x5006000,-72\n.frame $sp,96,$26,48\nstq $13,0($sp)\nstq $14,8($sp)\nstq $24,16($sp)\nstq $26,24($sp)\n.prologue 1\nmov $13,$27\nlda $13,1($27)\nldb $14,($27)\nlda $27,1($13)\nmov $27,$13\nldb $14,($27)\nmov $13,$27\nlda $13,-1($27)\nldb $14,($27)\nlda $27,-1($13)\nmov $27,$13\nldb $14,($27)\nmov $31,$0\nL.4:\nldq $13,0($sp)\nldq $14,8($sp)\nldq $24,16($sp)\nldq $26,24($sp)\nlda $sp,96($sp)\nret\n.end regchar\n.globl regint\n.text\n.ent regint\nregint:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4006000,-64\n.frame $sp,80,$26,48\nstq $13,0($sp)\nstq $14,8($sp)\nstq $26,16($sp)\n.prologue 1\nmov $13,$27\nlda $13,4($27)\nldl $14,($27)\nlda $27,4($13)\nmov $27,$13\nldl $14,($27)\nmov $13,$27\nlda $13,-4($27)\nldl $14,($27)\nlda $27,-4($13)\nmov $27,$13\nldl $14,($27)\nmov $31,$0\nL.5:\nldq $13,0($sp)\nldq $14,8($sp)\nldq $26,16($sp)\nlda $sp,80($sp)\nret\n.end regint\n"
  },
  {
    "path": "lcc/alpha/osf/tst/init.1bk",
    "content": " 1 2 3 4\n 5 6\n 7\nif\nfor\nelse\nwhile\n1 2 3 if\n4 5 0 for\n6 7 8 else\n9 10 11 while\n1 2 3 if\n4 5 0 for\n6 7 8 else\n9 10 11 while\n0 0 0 \n"
  },
  {
    "path": "lcc/alpha/osf/tst/init.2bk",
    "content": "tst/init.c:36: warning: missing return value\ntst/init.c:49: warning: missing return value\ntst/init.c:59: warning: missing return value\n"
  },
  {
    "path": "lcc/alpha/osf/tst/init.sbk",
    "content": ".sdata\n.globl words\n.align 2\nwords:\n.long 0x1\n.long 0x2\n.long 0x3\n.byte 105\n.byte 102\n.byte 0\n.space 3\n.space 2\n.long 0x4\n.long 0x5\n.space 4\n.byte 102\n.byte 111\n.byte 114\n.space 3\n.space 2\n.long 0x6\n.long 0x7\n.long 0x8\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 0\n.space 1\n.space 2\n.long 0x9\n.long 0xa\n.long 0xb\n.byte 119\n.byte 104\n.byte 105\n.byte 108\n.byte 101\n.space 1\n.space 2\n.long 0x0\n.space 8\n.space 8\n.globl wordlist\n.align 3\nwordlist:\n.quad words\n.globl x\n.align 2\nx:\n.long 0x1\n.long 0x2\n.long 0x3\n.long 0x4\n.long 0x0\n.long 0x5\n.long 0x6\n.space 12\n.long 0x7\n.space 16\n.globl y\n.align 3\ny:\n.quad x\n.quad x+20\n.quad x+40\n.quad 0x0\n.globl main\n.text\n.text\n.ent main\nmain:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4006000,-64\n.frame $sp,80,$26,48\nstq $13,0($sp)\nstq $14,8($sp)\nstq $26,16($sp)\n.prologue 1\nmov $31,$13\nbr L.8\nL.5:\nmov $31,$14\nbr L.12\nL.9:\nlda $16,L.13\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nsll $13,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,3,$25\nldq $25,y($25)\naddq $27,$25,$27\nldl $17,($27)\njsr $26,printf\nldgp $gp,0($26)\nL.10:\nlda $14,1($14)\nL.12:\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nsll $13,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,3,$25\nldq $25,y($25)\naddq $27,$25,$27\nldl $27,($27)\ncmpeq $27,$31,$23\nbeq $23,L.9\nlda $16,L.14\njsr $26,printf\nldgp $gp,0($26)\nL.6:\nlda $13,1($13)\nL.8:\nsll $13,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,3,$27\nldq $27,y($27)\ncmpeq $27,$31,$23\nbeq $23,L.5\njsr $26,f\nldgp $gp,0($26)\nldq $16,wordlist\njsr $26,g\nldgp $gp,0($26)\nmov $31,$0\nL.4:\nldq $13,0($sp)\nldq $14,8($sp)\nldq $26,16($sp)\nlda $sp,80($sp)\nret\n.end main\n.sdata\n.align 3\nL.16:\n.quad L.17\n.quad L.18\n.quad L.19\n.quad L.20\n.quad 0x0\n.globl f\n.text\n.text\n.ent f\nf:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4004000,-72\n.frame $sp,80,$26,48\nstq $14,0($sp)\nstq $26,8($sp)\n.prologue 1\nlda $14,L.16\nbr L.24\nL.21:\nlda $16,L.25\nldq $17,($14)\njsr $26,printf\nldgp $gp,0($26)\nL.22:\nlda $14,8($14)\nL.24:\nldq $27,($14)\ncmpeq $27,$31,$23\nbeq $23,L.21\nmov $31,$0\nL.15:\nldq $14,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end f\n.globl g\n.text\n.ent g\ng:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4006000,-64\n.frame $sp,80,$26,48\nstq $13,0($sp)\nstq $14,8($sp)\nstq $26,16($sp)\nmov $16,$14\n.prologue 1\nbr L.30\nL.27:\nmov $31,$13\nbr L.34\nL.31:\nlda $16,L.35\nsll $13,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\naddq $27,$14,$27\nldl $17,($27)\njsr $26,printf\nldgp $gp,0($26)\nL.32:\nlda $13,1($13)\nL.34:\nmov $13,$27\nlda $25,3\ncmpult $27,$25,$23\nbne $23,L.31\nlda $16,L.25\nlda $17,12($14)\njsr $26,printf\nldgp $gp,0($26)\nL.28:\nlda $14,20($14)\nL.30:\nldl $27,($14)\ncmpeq $27,$31,$23\nbeq $23,L.27\njsr $26,h\nldgp $gp,0($26)\nmov $31,$0\nL.26:\nldq $13,0($sp)\nldq $14,8($sp)\nldq $26,16($sp)\nlda $sp,80($sp)\nret\n.end g\n.globl h\n.text\n.ent h\nh:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4004000,-72\n.frame $sp,80,$26,48\nstq $14,0($sp)\nstq $26,8($sp)\n.prologue 1\nmov $31,$14\nbr L.40\nL.37:\nlda $16,L.41\nlda $27,20\nsll $14,8*(8-4),$25\nsra $25,8*(8-4),$25\nmulq $27,$25,$27\nldl $17,words($27)\nldl $18,words+4($27)\nldl $19,words+8($27)\nlda $20,words+12($27)\njsr $26,printf\nldgp $gp,0($26)\nL.38:\nlda $14,1($14)\nL.40:\nmov $14,$27\nlda $25,5\ncmpult $27,$25,$23\nbne $23,L.37\nmov $31,$0\nL.36:\nldq $14,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end h\n.rdata\n.align 0\nL.41:\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.35:\n.byte 37\n.byte 100\n.byte 32\n.byte 0\n.align 0\nL.25:\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.20:\n.byte 119\n.byte 104\n.byte 105\n.byte 108\n.byte 101\n.byte 0\n.align 0\nL.19:\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 0\n.align 0\nL.18:\n.byte 102\n.byte 111\n.byte 114\n.byte 0\n.align 0\nL.17:\n.byte 105\n.byte 102\n.byte 0\n.align 0\nL.14:\n.byte 10\n.byte 0\n.align 0\nL.13:\n.byte 32\n.byte 37\n.byte 100\n.byte 0\n"
  },
  {
    "path": "lcc/alpha/osf/tst/limits.1bk",
    "content": "UCHAR_MAX:\t000000ff=255\nUSHRT_MAX:\t0000ffff=65535\nUINT_MAX:\tffffffff=-1\nULONG_MAX:\tffffffffffffffff=-1\nCHAR_MAX:\t0000007f=127\nSCHAR_MAX:\t0000007f=127\nSHRT_MAX:\t00007fff=32767\nINT_MAX:\t7fffffff=2147483647\nLONG_MAX:\t7fffffffffffffff=9223372036854775807\nCHAR_MIN:\tffffff80=-128\nSCHAR_MIN:\tffffff80=-128\nSHRT_MIN:\tffff8000=-32768\nINT_MIN:\t80000000=-2147483648\nLONG_MIN:\t8000000000000000=-9223372036854775808\n"
  },
  {
    "path": "lcc/alpha/osf/tst/limits.2bk",
    "content": ""
  },
  {
    "path": "lcc/alpha/osf/tst/limits.sbk",
    "content": ".globl main\n.text\n.text\n.ent main\nmain:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\n.prologue 1\nlda $16,L.2\nlda $27,255\nmov $27,$17\nmov $27,$18\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.3\nlda $27,65535\nmov $27,$17\nmov $27,$18\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.4\nlda $27,0xffffffff\nmov $27,$17\nmov $27,$18\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.5\nlda $27,0xffffffffffffffff\nmov $27,$17\nmov $27,$18\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.6\nlda $27,127\nmov $27,$17\nmov $27,$18\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.7\nlda $27,127\nmov $27,$17\nmov $27,$18\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.8\nlda $27,32767\nmov $27,$17\nmov $27,$18\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.9\nlda $27,2147483647\nmov $27,$17\nmov $27,$18\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.10\nlda $27,9223372036854775807\nmov $27,$17\nmov $27,$18\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.11\nlda $27,-128\nmov $27,$17\nmov $27,$18\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.12\nlda $27,-128\nmov $27,$17\nmov $27,$18\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.13\nlda $27,-32768\nmov $27,$17\nmov $27,$18\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.14\nlda $27,-2147483648\nmov $27,$17\nmov $27,$18\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.15\nlda $27,-9223372036854775808\nmov $27,$17\nmov $27,$18\njsr $26,printf\nldgp $gp,0($26)\nmov $31,$0\nL.1:\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end main\n.rdata\n.align 0\nL.15:\n.byte 76\n.byte 79\n.byte 78\n.byte 71\n.byte 95\n.byte 77\n.byte 73\n.byte 78\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 108\n.byte 120\n.byte 61\n.byte 37\n.byte 108\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.14:\n.byte 73\n.byte 78\n.byte 84\n.byte 95\n.byte 77\n.byte 73\n.byte 78\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.13:\n.byte 83\n.byte 72\n.byte 82\n.byte 84\n.byte 95\n.byte 77\n.byte 73\n.byte 78\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.12:\n.byte 83\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 95\n.byte 77\n.byte 73\n.byte 78\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.11:\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 95\n.byte 77\n.byte 73\n.byte 78\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.10:\n.byte 76\n.byte 79\n.byte 78\n.byte 71\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 108\n.byte 120\n.byte 61\n.byte 37\n.byte 108\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.9:\n.byte 73\n.byte 78\n.byte 84\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.8:\n.byte 83\n.byte 72\n.byte 82\n.byte 84\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.7:\n.byte 83\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.6:\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.5:\n.byte 85\n.byte 76\n.byte 79\n.byte 78\n.byte 71\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 108\n.byte 120\n.byte 61\n.byte 37\n.byte 108\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.4:\n.byte 85\n.byte 73\n.byte 78\n.byte 84\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.3:\n.byte 85\n.byte 83\n.byte 72\n.byte 82\n.byte 84\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.2:\n.byte 85\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/alpha/osf/tst/paranoia.1bk",
    "content": "Lest this program stop prematurely, i.e. before displaying\n\n    `END OF TEST',\n\ntry to persuade the computer NOT to terminate execution when an\nerror like Over/Underflow or Division by Zero occurs, but rather\nto persevere with a surrogate value after, perhaps, displaying some\nwarning.  If persuasion avails naught, don't despair but run this\nprogram anyway to see how many milestones it passes, and then\namend it to make further progress.\n\nAnswer questions with Y, y, N or n (unless otherwise indicated).\n\n\nDiagnosis resumes after milestone Number 0          Page: 1\n\nUsers are invited to help debug and augment this program so it will\ncope with unanticipated and newly uncovered arithmetic pathologies.\n\nPlease send suggestions and interesting results to\n\tRichard Karpinski\n\tComputer Center U-76\n\tUniversity of California\n\tSan Francisco, CA 94143-0704, USA\n\nIn doing so, please include the following information:\n\tPrecision:\tdouble;\n\tVersion:\t10 February 1989;\n\tComputer:\n\n\tCompiler:\n\n\tOptimization level:\n\n\tOther relevant compiler options:\n\nDiagnosis resumes after milestone Number 1          Page: 2\n\nRunning this program should reveal these characteristics:\n     Radix = 1, 2, 4, 8, 10, 16, 100, 256 ...\n     Precision = number of significant digits carried.\n     U2 = Radix/Radix^Precision = One Ulp\n\t(OneUlpnit in the Last Place) of 1.000xxx .\n     U1 = 1/Radix^Precision = One Ulp of numbers a little less than 1.0 .\n     Adequacy of guard digits for Mult., Div. and Subt.\n     Whether arithmetic is chopped, correctly rounded, or something else\n\tfor Mult., Div., Add/Subt. and Sqrt.\n     Whether a Sticky Bit used correctly for rounding.\n     UnderflowThreshold = an underflow threshold.\n     E0 and PseudoZero tell whether underflow is abrupt, gradual, or fuzzy.\n     V = an overflow threshold, roughly.\n     V0  tells, roughly, whether  Infinity  is represented.\n     Comparisions are checked for consistency with subtraction\n\tand for contamination with pseudo-zeros.\n     Sqrt is tested.  Y^X is not tested.\n     Extra-precise subexpressions are revealed but NOT YET tested.\n     Decimal-Binary conversion is NOT YET tested for accuracy.\n\nDiagnosis resumes after milestone Number 2          Page: 3\n\nThe program attempts to discriminate among\n   FLAWs, like lack of a sticky bit,\n   Serious DEFECTs, like lack of a guard digit, and\n   FAILUREs, like 2+2 == 5 .\nFailures may confound subsequent diagnoses.\n\nThe diagnostic capabilities of this program go beyond an earlier\nprogram called `MACHAR', which can be found at the end of the\nbook  `Software Manual for the Elementary Functions' (1980) by\nW. J. Cody and W. Waite. Although both programs try to discover\nthe Radix, Precision and range (over/underflow thresholds)\nof the arithmetic, this program tries to cope with a wider variety\nof pathologies, and to say how well the arithmetic is implemented.\n\nThe program is based upon a conventional radix representation for\nfloating-point numbers, but also allows logarithmic encoding\nas used by certain early WANG machines.\n\nBASIC version of this program (C) 1983 by Prof. W. M. Kahan;\nsee source comments for more history.\n\nDiagnosis resumes after milestone Number 3          Page: 4\n\nProgram is now RUNNING tests on small integers:\n-1, 0, 1/2, 1, 2, 3, 4, 5, 9, 27, 32 & 240 are O.K.\n\nSearching for Radix and Precision.\nRadix = 2.000000 .\nClosest relative separation found is U1 = 1.1102230e-16 .\n\nRecalculating radix and precision\n confirms closest relative separation U1 .\nRadix confirmed.\nThe number of significant digits of the Radix is 53.000000 .\n\nDiagnosis resumes after milestone Number 30          Page: 5\n\nSubtraction appears to be normalized, as it should be.\nChecking for guard digit in *, /, and -.\n     *, /, and - appear to have guard digits, as they should.\n\nDiagnosis resumes after milestone Number 40          Page: 6\n\nChecking rounding on multiply, divide and add/subtract.\nMultiplication appears to round correctly.\nDivision appears to round correctly.\nAddition/Subtraction appears to round correctly.\nChecking for sticky bit.\nSticky bit apparently used correctly.\n\nDoes Multiplication commute?  Testing on 20 random pairs.\n     No failures found in 20 integer pairs.\n\nRunning test of square root(x).\nTesting if sqrt(X * X) == X for 20 Integers X.\nTest for sqrt monotonicity.\nsqrt has passed a test for Monotonicity.\nTesting whether sqrt is rounded or chopped.\nSquare root appears to be correctly rounded.\n\nDiagnosis resumes after milestone Number 90          Page: 7\n\nTesting powers Z^i for small Integers Z and i.\n... no discrepancis found.\n\nSeeking Underflow thresholds UfThold and E0.\nSmallest strictly positive number found is E0 = 2.22507e-308 .\nSince comparison denies Z = 0, evaluating (Z + Z) / Z should be safe.\nWhat the machine gets for (Z + Z) / Z is  2.00000000000000000e+00 .\nThis is O.K., provided Over/Underflow has NOT just been signaled.\n\nDiagnosis resumes after milestone Number 120          Page: 8\n\n\nFLAW:  X = 3.05947655544740190e-308\n\tis not equal to Z = 2.22507385850720140e-308 .\nyet X - Z yields 0.00000000000000000e+00 .\n    Should this NOT signal Underflow, this is a SERIOUS DEFECT\nthat causes confusion when innocent statements like\n    if (X == Z)  ...  else  ... (f(X) - f(Z)) / (X - Z) ...\nencounter Division by Zero although actually\nX / Z = 1 + 0.375 .\nThe Underflow threshold is 2.22507385850720140e-308,  below which\ncalculation may suffer larger Relative error than merely roundoff.\nSince underflow occurs below the threshold\nUfThold = (2.00000000000000000e+00) ^ (-1.02200000000000000e+03)\nonly underflow should afflict the expression\n\t(2.00000000000000000e+00) ^ (-1.02200000000000000e+03);\nactually calculating yields: 0.00000000000000000e+00 .\nThis computed value is O.K.\n\nTesting X^((X + 1) / (X - 1)) vs. exp(2) = 7.38905609893065220e+00 as X -> 1.\nAccuracy seems adequate.\nTesting powers Z^Q at four nearly extreme values.\n ... no discrepancies found.\n\n\nDiagnosis resumes after milestone Number 160          Page: 9\n\nSearching for Overflow threshold:\nThis may generate an error.\n\n* * * FLOATING-POINT ERROR * * *\nCan `Z = -Y' overflow?\nTrying it on Y = -8.98846567431157950e+307 .\nSeems O.K.\nOverflow threshold is V  = 1.79769313486231570e+308 .\nThere is no saturation value because the system traps on overflow.\nNo Overflow should be signaled for V * 1 = 1.79769313486231570e+308\n                           nor for V / 1 = 1.79769313486231570e+308 .\nAny overflow signal separating this * from the one\nabove is a DEFECT.\n\n\nDiagnosis resumes after milestone Number 190          Page: 10\n\n\nWhat message and/or values does Division by Zero produce?\n    Trying to compute 1 / 0 produces ...\n* * * FLOATING-POINT ERROR * * *\n\n    Trying to compute 0 / 0 produces ...\n* * * FLOATING-POINT ERROR * * *\n\nDiagnosis resumes after milestone Number 220          Page: 11\n\n\n\nNo failures, defects nor flaws have been discovered.\nRounding appears to conform to the proposed IEEE standard P754,\nexcept for possibly Double Rounding during Gradual Underflow.\nThe arithmetic diagnosed appears to be Excellent!\n\nA total of 3 floating point exceptions were registered.\nEND OF TEST.\n"
  },
  {
    "path": "lcc/alpha/osf/tst/paranoia.2bk",
    "content": "tst/paranoia.c:1867: warning: missing return value\ntst/paranoia.c:1874: warning: missing return value\ntst/paranoia.c:1884: warning: missing return value\ntst/paranoia.c:1924: warning: missing return value\ntst/paranoia.c:1939: warning: missing return value\ntst/paranoia.c:1956: warning: missing return value\ntst/paranoia.c:1975: warning: missing return value\ntst/paranoia.c:1988: warning: missing return value\ntst/paranoia.c:1995: warning: missing return value\ntst/paranoia.c:2055: warning: missing return value\ntst/paranoia.c:2062: warning: missing return value\ntst/paranoia.c:2070: warning: missing return value\ntst/paranoia.c:2087: warning: missing return value\ntst/paranoia.c:2115: warning: missing return value\ntst/paranoia.c:2144: warning: missing return value\ntst/paranoia.c:2173: warning: missing return value\n"
  },
  {
    "path": "lcc/alpha/osf/tst/paranoia.sbk",
    "content": ".sdata\n.globl Zero\n.align 3\nZero:\n.long 0x0\n.long 0x0\n.globl Half\n.align 3\nHalf:\n.long 0x0\n.long 0x3fe00000\n.globl One\n.align 3\nOne:\n.long 0x0\n.long 0x3ff00000\n.globl Two\n.align 3\nTwo:\n.long 0x0\n.long 0x40000000\n.globl Three\n.align 3\nThree:\n.long 0x0\n.long 0x40080000\n.globl Four\n.align 3\nFour:\n.long 0x0\n.long 0x40100000\n.globl Five\n.align 3\nFive:\n.long 0x0\n.long 0x40140000\n.globl Eight\n.align 3\nEight:\n.long 0x0\n.long 0x40200000\n.globl Nine\n.align 3\nNine:\n.long 0x0\n.long 0x40220000\n.globl TwentySeven\n.align 3\nTwentySeven:\n.long 0x0\n.long 0x403b0000\n.globl ThirtyTwo\n.align 3\nThirtyTwo:\n.long 0x0\n.long 0x40400000\n.globl TwoForty\n.align 3\nTwoForty:\n.long 0x0\n.long 0x406e0000\n.globl MinusOne\n.align 3\nMinusOne:\n.long 0x0\n.long 0xbff00000\n.globl OneAndHalf\n.align 3\nOneAndHalf:\n.long 0x0\n.long 0x3ff80000\n.globl NoTrials\n.align 2\nNoTrials:\n.long 0x14\n.globl sigfpe\n.text\n.text\n.ent sigfpe\nsigfpe:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\nstq $16,16($sp)\n.prologue 1\nldl $27,fpecount\nlda $27,1($27)\nstl $27,fpecount\nlda $16,L.3\njsr $26,printf\nldgp $gp,0($26)\nlda $16,_iob+56\njsr $26,fflush\nldgp $gp,0($26)\nldq $27,sigsave\ncmpeq $27,$31,$23\nbne $23,L.5\nlda $16,8\nldq $17,sigsave\njsr $26,signal\nldgp $gp,0($26)\nstq $31,sigsave\nlda $16,ovfl_buf\nlda $17,1\njsr $26,longjmp\nldgp $gp,0($26)\nL.5:\njsr $26,abort\nldgp $gp,0($26)\nL.2:\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end sigfpe\n.sdata\n.align 3\nL.756:\n.quad L.757\n.quad L.758\n.quad L.759\n.quad L.760\n.globl main\n.text\n.text\n.ent main\nmain:\nldgp $gp,0($27)\nlda $sp,-256($sp)\n.mask 0x4007e00,-208\n.frame $sp,256,$26,48\nstq $9,0($sp)\nstq $10,8($sp)\nstq $11,16($sp)\nstq $12,24($sp)\nstq $13,32($sp)\nstq $14,40($sp)\nstq $26,48($sp)\n.prologue 1\nldt $f30,L.8\nstt $f30,Zero\nldt $f30,L.9\nstt $f30,One\nldt $f30,One\naddt $f30,$f30,$f29\nstt $f29,Two\nldt $f29,Two\naddt $f29,$f30,$f28\nstt $f28,Three\nldt $f28,Three\naddt $f28,$f30,$f27\nstt $f27,Four\nldt $f27,Four\naddt $f27,$f30,$f26\nstt $f26,Five\naddt $f27,$f27,$f26\nstt $f26,Eight\nmult $f28,$f28,$f26\nstt $f26,Nine\nldt $f26,Nine\nmult $f26,$f28,$f26\nstt $f26,TwentySeven\nldt $f26,Eight\nmult $f27,$f26,$f26\nstt $f26,ThirtyTwo\nldt $f26,Five\nmult $f27,$f26,$f26\nmult $f26,$f28,$f28\nmult $f28,$f27,$f28\nstt $f28,TwoForty\nnegt $f30,$f28\nstt $f28,MinusOne\ndivt $f30,$f29,$f29\nstt $f29,Half\nldt $f29,Half\naddt $f30,$f29,$f30\nstt $f30,OneAndHalf\nstl $31,ErrCnt\nstl $31,ErrCnt+4\nstl $31,ErrCnt+8\nstl $31,ErrCnt+12\nlda $27,1\nstl $27,PageNo\nstl $31,Milestone\nlda $16,8\nlda $17,sigfpe\njsr $26,signal\nldgp $gp,0($26)\njsr $26,Instructions\nldgp $gp,0($26)\njsr $26,Pause\nldgp $gp,0($26)\njsr $26,Heading\nldgp $gp,0($26)\njsr $26,Pause\nldgp $gp,0($26)\njsr $26,Characteristics\nldgp $gp,0($26)\njsr $26,Pause\nldgp $gp,0($26)\njsr $26,History\nldgp $gp,0($26)\njsr $26,Pause\nldgp $gp,0($26)\nlda $27,7\nstl $27,Milestone\nlda $16,L.13\njsr $26,printf\nldgp $gp,0($26)\nmov $31,$16\nldt $f30,Zero\naddt $f30,$f30,$f29\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.16\nldt $f29,One\nsubt $f29,$f29,$f28\ncmpteq $f28,$f30,$f1\nfbeq $f1,L.16\ncmptle $f29,$f30,$f1\nfbne $f1,L.16\naddt $f29,$f29,$f30\nldt $f29,Two\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.16\nlda $14,1\nbr L.17\nL.16:\nmov $31,$14\nL.17:\nmov $14,$17\nlda $18,L.15\njsr $26,TstCond\nldgp $gp,0($26)\nldt $f30,Zero\nnegt $f30,$f30\nstt $f30,Z\nldt $f30,Z\nldt $f29,L.8\ncmpteq $f30,$f29,$f1\nfbne $f1,L.18\nldl $27,ErrCnt\nlda $27,1($27)\nstl $27,ErrCnt\nlda $16,L.20\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,L.21\nstt $f30,U1\nldt $f30,L.9\nstt $f30,Radix\njsr $26,TstPtUf\nldgp $gp,0($26)\nL.18:\nmov $31,$16\nldt $f30,Three\nldt $f29,Two\nldt $f28,One\naddt $f29,$f28,$f27\ncmpteq $f30,$f27,$f1\nfbeq $f1,L.24\nldt $f27,Four\naddt $f30,$f28,$f26\ncmpteq $f27,$f26,$f1\nfbeq $f1,L.24\nldt $f26,Zero\nnegt $f29,$f25\nmult $f29,$f25,$f29\naddt $f27,$f29,$f29\ncmpteq $f29,$f26,$f1\nfbeq $f1,L.24\nsubt $f27,$f30,$f30\nsubt $f30,$f28,$f30\ncmpteq $f30,$f26,$f1\nfbeq $f1,L.24\nlda $13,1\nbr L.25\nL.24:\nmov $31,$13\nL.25:\nmov $13,$17\nlda $18,L.23\njsr $26,TstCond\nldgp $gp,0($26)\nldt $f30,MinusOne\nstt $f30,-64+256($sp)\nldt $f29,One\nldt $f28,L.8\nsubt $f28,$f29,$f28\ncmpteq $f30,$f28,$f1\nfbeq $f1,L.28\nldt $f28,Zero\naddt $f30,$f29,$f27\ncmpteq $f27,$f28,$f1\nfbeq $f1,L.28\naddt $f29,$f30,$f27\ncmpteq $f27,$f28,$f1\nfbeq $f1,L.28\nfmov $f29,$f16\njsr $26,fabs\nldgp $gp,0($26)\nldt $f29,Zero\nldt $f28,-64+256($sp)\naddt $f28,$f0,$f30\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.28\nldt $f30,MinusOne\nmult $f30,$f30,$f28\naddt $f30,$f28,$f30\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.28\nlda $12,1\nbr L.29\nL.28:\nmov $31,$12\nL.29:\nmov $31,$16\nmov $12,$17\nlda $18,L.27\njsr $26,TstCond\nldgp $gp,0($26)\nmov $31,$16\nldt $f30,Half\nldt $f29,MinusOne\naddt $f30,$f29,$f29\naddt $f29,$f30,$f30\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.32\nlda $11,1\nbr L.33\nL.32:\nmov $31,$11\nL.33:\nmov $11,$17\nlda $18,L.31\njsr $26,TstCond\nldgp $gp,0($26)\nlda $27,10\nstl $27,Milestone\nmov $31,$16\nldt $f30,Nine\nldt $f29,Three\nmult $f29,$f29,$f28\ncmpteq $f30,$f28,$f1\nfbeq $f1,L.36\nldt $f28,TwentySeven\nmult $f30,$f29,$f30\ncmpteq $f28,$f30,$f1\nfbeq $f1,L.36\nldt $f30,Eight\nldt $f29,Four\naddt $f29,$f29,$f27\ncmpteq $f30,$f27,$f1\nfbeq $f1,L.36\nldt $f27,ThirtyTwo\nmult $f30,$f29,$f30\ncmpteq $f27,$f30,$f1\nfbeq $f1,L.36\nsubt $f27,$f28,$f30\nsubt $f30,$f29,$f30\nldt $f29,One\nsubt $f30,$f29,$f30\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.36\nlda $10,1\nbr L.37\nL.36:\nmov $31,$10\nL.37:\nmov $10,$17\nlda $18,L.35\njsr $26,TstCond\nldgp $gp,0($26)\nmov $31,$16\nldt $f30,Five\nldt $f29,Four\nldt $f28,One\naddt $f29,$f28,$f28\ncmpteq $f30,$f28,$f1\nfbeq $f1,L.40\nldt $f28,TwoForty\nldt $f27,Three\nmult $f29,$f30,$f26\nmult $f26,$f27,$f26\nmult $f26,$f29,$f26\ncmpteq $f28,$f26,$f1\nfbeq $f1,L.40\nldt $f26,Zero\ndivt $f28,$f27,$f25\nmult $f29,$f29,$f24\nmult $f24,$f30,$f24\nsubt $f25,$f24,$f25\ncmpteq $f25,$f26,$f1\nfbeq $f1,L.40\ndivt $f28,$f29,$f25\nmult $f30,$f27,$f24\nmult $f24,$f29,$f24\nsubt $f25,$f24,$f25\ncmpteq $f25,$f26,$f1\nfbeq $f1,L.40\ndivt $f28,$f30,$f30\nmult $f29,$f27,$f28\nmult $f28,$f29,$f29\nsubt $f30,$f29,$f30\ncmpteq $f30,$f26,$f1\nfbeq $f1,L.40\nlda $9,1\nbr L.41\nL.40:\nmov $31,$9\nL.41:\nmov $9,$17\nlda $18,L.39\njsr $26,TstCond\nldgp $gp,0($26)\nldl $27,ErrCnt\ncmpeq $27,$31,$23\nbeq $23,L.42\nlda $16,L.44\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.45\njsr $26,printf\nldgp $gp,0($26)\nL.42:\nlda $16,L.46\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,One\nstt $f30,W\nL.47:\nldt $f30,W\naddt $f30,$f30,$f30\nstt $f30,W\nldt $f30,W\nldt $f29,One\naddt $f30,$f29,$f28\nstt $f28,Y\nldt $f28,Y\nsubt $f28,$f30,$f30\nstt $f30,Z\nldt $f30,Z\nsubt $f30,$f29,$f30\nstt $f30,Y\nL.48:\nldt $f16,Y\njsr $26,fabs\nldgp $gp,0($26)\nldt $f29,MinusOne\naddt $f29,$f0,$f30\nldt $f29,Zero\ncmptlt $f30,$f29,$f1\nfbne $f1,L.47\nldt $f30,Zero\nstt $f30,Precision\nldt $f30,One\nstt $f30,Y\nL.50:\nldt $f30,W\nldt $f29,Y\naddt $f30,$f29,$f28\nstt $f28,Radix\naddt $f29,$f29,$f29\nstt $f29,Y\nldt $f29,Radix\nsubt $f29,$f30,$f30\nstt $f30,Radix\nL.51:\nldt $f30,Radix\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbne $f1,L.50\nldt $f30,Radix\nldt $f29,Two\ncmptlt $f30,$f29,$f1\nfbeq $f1,L.53\nldt $f30,One\nstt $f30,Radix\nL.53:\nlda $16,L.55\nldt $f17,Radix\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,Radix\nldt $f29,L.9\ncmpteq $f30,$f29,$f1\nfbne $f1,L.56\nldt $f30,One\nstt $f30,W\nL.58:\nldt $f30,One\nldt $f29,Precision\naddt $f29,$f30,$f29\nstt $f29,Precision\nldt $f29,W\nldt $f28,Radix\nmult $f29,$f28,$f29\nstt $f29,W\nldt $f29,W\naddt $f29,$f30,$f30\nstt $f30,Y\nL.59:\nldt $f30,Y\nldt $f29,W\nsubt $f30,$f29,$f30\nldt $f29,One\ncmpteq $f30,$f29,$f1\nfbne $f1,L.58\nL.56:\nldt $f30,One\nldt $f29,W\ndivt $f30,$f29,$f30\nstt $f30,U1\nldt $f30,U1\nldt $f29,Radix\nmult $f29,$f30,$f29\nstt $f29,U2\nlda $16,L.61\nfmov $f30,$f17\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.62\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,Radix\nstt $f30,E0\nldt $f30,U1\nstt $f30,E1\nldt $f30,U2\nstt $f30,E9\nldt $f30,Precision\nstt $f30,E3\nldt $f30,Four\nldt $f29,Three\ndivt $f30,$f29,$f30\nstt $f30,X\nldt $f30,X\nldt $f29,One\nsubt $f30,$f29,$f30\nstt $f30,Third\nldt $f30,Third\nldt $f29,Half\nsubt $f29,$f30,$f29\nstt $f29,F6\nldt $f29,F6\naddt $f29,$f29,$f29\nstt $f29,X\nldt $f29,X\nsubt $f29,$f30,$f16\njsr $26,fabs\nldgp $gp,0($26)\nstt $f0,X\nldt $f30,X\nldt $f29,U2\ncmptlt $f30,$f29,$f1\nfbeq $f1,L.63\nldt $f30,U2\nstt $f30,X\nL.63:\nL.65:\nldt $f30,X\nstt $f30,U2\nldt $f30,U2\nldt $f29,Half\nmult $f29,$f30,$f29\nldt $f28,ThirtyTwo\nmult $f28,$f30,$f28\nmult $f28,$f30,$f30\naddt $f29,$f30,$f30\nstt $f30,Y\nldt $f30,One\nldt $f29,Y\naddt $f30,$f29,$f29\nstt $f29,Y\nldt $f29,Y\nsubt $f29,$f30,$f30\nstt $f30,X\nL.66:\nldt $f30,X\nldt $f29,U2\ncmptle $f29,$f30,$f1\nfbne $f1,L.68\nldt $f29,Zero\ncmptle $f30,$f29,$f1\nfbeq $f1,L.65\nL.68:\nldt $f30,Two\nldt $f29,Three\ndivt $f30,$f29,$f30\nstt $f30,X\nldt $f30,Half\nldt $f29,X\nsubt $f29,$f30,$f29\nstt $f29,F6\nldt $f29,F6\naddt $f29,$f29,$f28\nstt $f28,Third\nldt $f28,Third\nsubt $f28,$f30,$f30\nstt $f30,X\nldt $f30,X\naddt $f30,$f29,$f16\njsr $26,fabs\nldgp $gp,0($26)\nstt $f0,X\nldt $f30,X\nldt $f29,U1\ncmptlt $f30,$f29,$f1\nfbeq $f1,L.69\nldt $f30,U1\nstt $f30,X\nL.69:\nL.71:\nldt $f30,X\nstt $f30,U1\nldt $f30,Half\nldt $f29,U1\nmult $f30,$f29,$f28\nldt $f27,ThirtyTwo\nmult $f27,$f29,$f27\nmult $f27,$f29,$f29\naddt $f28,$f29,$f29\nstt $f29,Y\nldt $f29,Y\nsubt $f30,$f29,$f29\nstt $f29,Y\nldt $f29,Y\naddt $f30,$f29,$f29\nstt $f29,X\nldt $f29,X\nsubt $f30,$f29,$f29\nstt $f29,Y\nldt $f29,Y\naddt $f30,$f29,$f30\nstt $f30,X\nL.72:\nldt $f30,X\nldt $f29,U1\ncmptle $f29,$f30,$f1\nfbne $f1,L.74\nldt $f29,Zero\ncmptle $f30,$f29,$f1\nfbeq $f1,L.71\nL.74:\nldt $f30,U1\nldt $f29,E1\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.75\nlda $16,L.77\njsr $26,printf\nldgp $gp,0($26)\nbr L.76\nL.75:\nlda $16,L.78\nldt $f17,U1\njsr $26,printf\nldgp $gp,0($26)\nL.76:\nldt $f30,U1\nldt $f29,One\ndivt $f29,$f30,$f29\nstt $f29,W\nldt $f29,Half\nsubt $f29,$f30,$f28\naddt $f28,$f29,$f29\nstt $f29,F9\nldt $f29,U2\ndivt $f29,$f30,$f30\nldt $f29,L.79\naddt $f30,$f29,$f16\njsr $26,floor\nldgp $gp,0($26)\nstt $f0,Radix\nldt $f30,Radix\nldt $f29,E0\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.80\nlda $16,L.82\njsr $26,printf\nldgp $gp,0($26)\nbr L.81\nL.80:\nlda $16,L.83\nldt $f17,Radix\njsr $26,printf\nldgp $gp,0($26)\nL.81:\nlda $16,2\nldt $f30,Eight\nldt $f29,Radix\naddt $f30,$f30,$f30\ncmptle $f29,$f30,$f1\nfbeq $f1,L.86\nlda $27,1\nstl $27,-68+256($sp)\nbr L.87\nL.86:\nstl $31,-68+256($sp)\nL.87:\nldl $17,-68+256($sp)\nlda $18,L.85\njsr $26,TstCond\nldgp $gp,0($26)\nlda $16,3\nldt $f30,Radix\nldt $f29,Two\ncmpteq $f30,$f29,$f1\nfbne $f1,L.93\nldt $f29,L.94\ncmpteq $f30,$f29,$f1\nfbne $f1,L.93\nldt $f29,One\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.90\nL.93:\nlda $27,1\nstl $27,-72+256($sp)\nbr L.91\nL.90:\nstl $31,-72+256($sp)\nL.91:\nldl $17,-72+256($sp)\nlda $18,L.89\njsr $26,TstCond\nldgp $gp,0($26)\nlda $27,20\nstl $27,Milestone\nmov $31,$16\nldt $f30,Half\nldt $f29,F9\nsubt $f29,$f30,$f29\ncmptlt $f29,$f30,$f1\nfbeq $f1,L.97\nlda $27,1\nstl $27,-76+256($sp)\nbr L.98\nL.97:\nstl $31,-76+256($sp)\nL.98:\nldl $17,-76+256($sp)\nlda $18,L.96\njsr $26,TstCond\nldgp $gp,0($26)\nldt $f30,F9\nstt $f30,X\nlda $27,1\nstl $27,I\nldt $f30,Half\nldt $f29,X\nsubt $f29,$f30,$f29\nstt $f29,Y\nldt $f29,Y\nsubt $f29,$f30,$f30\nstt $f30,Z\nmov $31,$16\nldt $f30,X\nldt $f29,One\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.103\nldt $f30,Z\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.101\nL.103:\nlda $27,1\nstl $27,-80+256($sp)\nbr L.102\nL.101:\nstl $31,-80+256($sp)\nL.102:\nldl $17,-80+256($sp)\nlda $18,L.100\njsr $26,TstCond\nldgp $gp,0($26)\nldt $f30,One\nldt $f29,U2\naddt $f30,$f29,$f28\nstt $f28,X\nstl $31,I\nlda $27,25\nstl $27,Milestone\nldt $f28,Radix\nsubt $f28,$f30,$f27\nstt $f27,BMinusU2\nldt $f27,BMinusU2\nsubt $f27,$f29,$f29\naddt $f29,$f30,$f29\nstt $f29,BMinusU2\ncmpteq $f28,$f30,$f1\nfbne $f1,L.104\nldt $f16,U1\njsr $26,log\nldgp $gp,0($26)\nfmov $f0,$f30\nstt $f30,-88+256($sp)\nldt $f16,Radix\njsr $26,log\nldgp $gp,0($26)\nldt $f29,TwoForty\nnegt $f29,$f29\nldt $f28,-88+256($sp)\nmult $f29,$f28,$f29\ndivt $f29,$f0,$f30\nstt $f30,X\nldt $f30,Half\nldt $f29,X\naddt $f30,$f29,$f16\njsr $26,floor\nldgp $gp,0($26)\nstt $f0,Y\nldt $f30,X\nldt $f29,Y\nsubt $f30,$f29,$f16\njsr $26,fabs\nldgp $gp,0($26)\nldt $f29,Four\nmult $f0,$f29,$f30\nldt $f29,One\ncmptlt $f30,$f29,$f1\nfbeq $f1,L.106\nldt $f30,Y\nstt $f30,X\nL.106:\nldt $f30,X\nldt $f29,TwoForty\ndivt $f30,$f29,$f30\nstt $f30,Precision\nldt $f30,Half\nldt $f29,Precision\naddt $f30,$f29,$f16\njsr $26,floor\nldgp $gp,0($26)\nstt $f0,Y\nldt $f30,Precision\nldt $f29,Y\nsubt $f30,$f29,$f16\njsr $26,fabs\nldgp $gp,0($26)\nldt $f29,TwoForty\nmult $f0,$f29,$f30\nldt $f29,Half\ncmptlt $f30,$f29,$f1\nfbeq $f1,L.108\nldt $f30,Y\nstt $f30,Precision\nL.108:\nL.104:\nldt $f30,Precision\nstt $f30,-88+256($sp)\nfmov $f30,$f16\njsr $26,floor\nldgp $gp,0($26)\nldt $f29,-88+256($sp)\ncmpteq $f29,$f0,$f1\nfbeq $f1,L.112\nldt $f30,Radix\nldt $f29,One\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.110\nL.112:\nlda $16,L.113\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.114\njsr $26,printf\nldgp $gp,0($26)\nL.110:\nldt $f30,Radix\nldt $f29,One\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.115\nlda $16,L.117\njsr $26,printf\nldgp $gp,0($26)\nbr L.116\nL.115:\nlda $16,L.118\nldt $f17,Precision\njsr $26,printf\nldgp $gp,0($26)\nL.116:\nlda $16,1\nldt $f30,Nine\nldt $f29,U2\nmult $f29,$f30,$f29\nmult $f29,$f30,$f30\nldt $f29,TwoForty\nmult $f30,$f29,$f30\nldt $f29,One\ncmptlt $f30,$f29,$f1\nfbeq $f1,L.121\nlda $27,1\nstl $27,-92+256($sp)\nbr L.122\nL.121:\nstl $31,-92+256($sp)\nL.122:\nldl $17,-92+256($sp)\nlda $18,L.120\njsr $26,TstCond\nldgp $gp,0($26)\nlda $27,30\nstl $27,Milestone\nldt $f30,Four\nldt $f29,Three\nldt $f28,One\ndivt $f28,$f30,$f27\ndivt $f30,$f29,$f30\nsubt $f30,$f28,$f30\nsubt $f30,$f27,$f30\nmult $f30,$f29,$f30\nsubt $f30,$f27,$f16\njsr $26,fabs\nldgp $gp,0($26)\nstt $f0,X\nL.123:\nldt $f30,X\nstt $f30,Z2\nldt $f30,One\nldt $f29,Z2\nldt $f28,Half\nmult $f28,$f29,$f28\nldt $f27,ThirtyTwo\nmult $f27,$f29,$f27\nmult $f27,$f29,$f29\naddt $f28,$f29,$f29\naddt $f30,$f29,$f29\nsubt $f29,$f30,$f30\nstt $f30,X\nL.124:\nldt $f30,X\nldt $f29,Z2\ncmptle $f29,$f30,$f1\nfbne $f1,L.126\nldt $f29,Zero\ncmptle $f30,$f29,$f1\nfbeq $f1,L.123\nL.126:\nldt $f30,Three\nldt $f29,Four\ndivt $f30,$f29,$f28\nldt $f27,Two\ndivt $f27,$f30,$f27\nsubt $f28,$f27,$f28\nmult $f28,$f30,$f30\nldt $f28,One\ndivt $f28,$f29,$f29\nsubt $f30,$f29,$f16\njsr $26,fabs\nldgp $gp,0($26)\nstt $f0,Z\nstt $f0,Y\nstt $f0,X\nL.127:\nldt $f30,Z\nstt $f30,Z1\nldt $f30,One\nldt $f29,Two\ndivt $f30,$f29,$f30\nldt $f29,Z1\nldt $f28,Half\nmult $f28,$f29,$f28\nldt $f27,ThirtyTwo\nmult $f27,$f29,$f27\nmult $f27,$f29,$f29\naddt $f28,$f29,$f29\nsubt $f30,$f29,$f29\naddt $f29,$f30,$f29\nsubt $f30,$f29,$f29\naddt $f29,$f30,$f30\nstt $f30,Z\nL.128:\nldt $f30,Z\nldt $f29,Z1\ncmptle $f29,$f30,$f1\nfbne $f1,L.130\nldt $f29,Zero\ncmptle $f30,$f29,$f1\nfbeq $f1,L.127\nL.130:\nL.131:\nL.134:\nldt $f30,Y\nstt $f30,Y1\nldt $f30,Half\nldt $f29,Y1\nmult $f30,$f29,$f28\nldt $f27,ThirtyTwo\nmult $f27,$f29,$f27\nmult $f27,$f29,$f29\naddt $f28,$f29,$f29\nsubt $f30,$f29,$f29\naddt $f29,$f30,$f29\nsubt $f30,$f29,$f29\naddt $f29,$f30,$f30\nstt $f30,Y\nL.135:\nldt $f30,Y\nldt $f29,Y1\ncmptle $f29,$f30,$f1\nfbne $f1,L.137\nldt $f29,Zero\ncmptle $f30,$f29,$f1\nfbeq $f1,L.134\nL.137:\nldt $f30,X\nstt $f30,X1\nldt $f30,X1\nldt $f29,F9\nldt $f28,Half\nmult $f28,$f30,$f28\nldt $f27,ThirtyTwo\nmult $f27,$f30,$f27\nmult $f27,$f30,$f30\naddt $f28,$f30,$f30\nsubt $f30,$f29,$f30\naddt $f30,$f29,$f30\nstt $f30,X\nL.132:\nldt $f30,X\nldt $f29,X1\ncmptle $f29,$f30,$f1\nfbne $f1,L.138\nldt $f29,Zero\ncmptle $f30,$f29,$f1\nfbeq $f1,L.131\nL.138:\nldt $f30,X1\nldt $f29,Y1\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.141\nldt $f29,Z1\ncmpteq $f30,$f29,$f1\nfbne $f1,L.139\nL.141:\nlda $16,1\nlda $17,L.142\njsr $26,BadCond\nldgp $gp,0($26)\nlda $16,L.143\nldt $f17,X1\nldt $f18,Y1\nldt $f19,Z1\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.144\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.145\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.146\njsr $26,notify\nldgp $gp,0($26)\nldt $f30,U1\nldt $f29,X1\ncmpteq $f29,$f30,$f1\nfbne $f1,L.150\nldt $f29,Y1\ncmpteq $f29,$f30,$f1\nfbne $f1,L.150\nldt $f29,Z1\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.140\nL.150:\nlda $16,L.151\njsr $26,printf\nldgp $gp,0($26)\nbr L.140\nL.139:\nldt $f30,Z1\nldt $f29,U1\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.154\nldt $f30,Z2\nldt $f29,U2\ncmpteq $f30,$f29,$f1\nfbne $f1,L.152\nL.154:\nldt $f30,Z1\nldt $f29,U1\ncmptlt $f30,$f29,$f1\nfbeq $f1,L.157\nldt $f30,Z2\nldt $f29,U2\ncmptlt $f30,$f29,$f1\nfbne $f1,L.155\nL.157:\nmov $31,$16\nlda $17,L.158\njsr $26,BadCond\nldgp $gp,0($26)\nlda $16,L.159\njsr $26,notify\nldgp $gp,0($26)\nlda $16,L.160\nldt $f30,U1\nfmov $f30,$f17\nldt $f29,Z1\nsubt $f29,$f30,$f18\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.161\nldt $f30,U2\nfmov $f30,$f17\nldt $f29,Z2\nsubt $f29,$f30,$f18\njsr $26,printf\nldgp $gp,0($26)\nbr L.156\nL.155:\nldt $f30,Zero\nldt $f29,Z1\ncmptle $f29,$f30,$f1\nfbne $f1,L.164\nldt $f29,Z2\ncmptle $f29,$f30,$f1\nfbeq $f1,L.162\nL.164:\nlda $16,L.165\nldt $f17,Radix\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.166\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.167\nldt $f17,Z1\nldt $f18,Z2\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.168\njsr $26,notify\nldgp $gp,0($26)\nL.162:\nldt $f30,Z1\nldt $f29,Z2\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.171\nldt $f29,Zero\ncmptle $f30,$f29,$f1\nfbne $f1,L.169\nL.171:\nldt $f30,Z1\nldt $f29,U1\ndivt $f30,$f29,$f30\nstt $f30,X\nldt $f30,Z2\nldt $f29,U2\ndivt $f30,$f29,$f30\nstt $f30,Y\nldt $f30,Y\nldt $f29,X\ncmptle $f30,$f29,$f1\nfbne $f1,L.172\nldt $f30,Y\nstt $f30,X\nL.172:\nldt $f16,X\njsr $26,log\nldgp $gp,0($26)\nnegt $f0,$f30\nstt $f30,Q\nlda $16,L.174\njsr $26,printf\nldgp $gp,0($26)\nldt $f16,Radix\njsr $26,log\nldgp $gp,0($26)\nfmov $f0,$f30\nlda $16,L.175\nldt $f29,Q\ndivt $f29,$f30,$f17\njsr $26,printf\nldgp $gp,0($26)\nldt $f16,L.94\njsr $26,log\nldgp $gp,0($26)\nfmov $f0,$f30\nlda $16,L.176\nldt $f29,Q\ndivt $f29,$f30,$f17\njsr $26,printf\nldgp $gp,0($26)\nL.169:\nlda $16,L.151\njsr $26,printf\nldgp $gp,0($26)\nL.156:\nL.152:\nL.140:\njsr $26,Pause\nldgp $gp,0($26)\nlda $27,35\nstl $27,Milestone\nldt $f30,Radix\nldt $f29,Two\ncmptlt $f30,$f29,$f1\nfbne $f1,L.177\nldt $f30,Radix\nldt $f29,W\nmult $f30,$f30,$f30\ndivt $f29,$f30,$f30\nstt $f30,X\nldt $f30,X\nldt $f29,One\naddt $f30,$f29,$f29\nstt $f29,Y\nldt $f29,Y\nsubt $f29,$f30,$f30\nstt $f30,Z\nldt $f30,Z\nldt $f29,U2\naddt $f30,$f29,$f28\nstt $f28,T\nldt $f28,T\nsubt $f28,$f30,$f30\nstt $f30,X\nmov $31,$16\nldt $f30,X\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.181\nlda $27,1\nstl $27,-96+256($sp)\nbr L.182\nL.181:\nstl $31,-96+256($sp)\nL.182:\nldl $17,-96+256($sp)\nlda $18,L.180\njsr $26,TstCond\nldgp $gp,0($26)\nldt $f30,X\nldt $f29,U2\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.183\nlda $16,L.185\njsr $26,printf\nldgp $gp,0($26)\nL.183:\nL.177:\nlda $16,L.186\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,F9\nldt $f29,One\nmult $f30,$f29,$f28\nstt $f28,Y\nmult $f29,$f30,$f28\nstt $f28,Z\nldt $f28,Half\nsubt $f30,$f28,$f30\nstt $f30,X\nldt $f30,X\nldt $f27,Y\nsubt $f27,$f28,$f27\nsubt $f27,$f30,$f27\nstt $f27,Y\nldt $f27,Z\nsubt $f27,$f28,$f28\nsubt $f28,$f30,$f30\nstt $f30,Z\nldt $f30,U2\naddt $f29,$f30,$f28\nstt $f28,X\nldt $f28,X\nldt $f27,Radix\nmult $f28,$f27,$f26\nstt $f26,T\nmult $f27,$f28,$f28\nstt $f28,R\nldt $f28,T\nsubt $f28,$f27,$f28\nstt $f28,X\nmult $f27,$f30,$f30\nldt $f28,X\nsubt $f28,$f30,$f28\nstt $f28,X\nldt $f28,R\nsubt $f28,$f27,$f28\nstt $f28,T\nldt $f28,T\nsubt $f28,$f30,$f30\nstt $f30,T\nsubt $f27,$f29,$f30\nldt $f29,X\nmult $f29,$f30,$f29\nstt $f29,X\nldt $f29,T\nmult $f29,$f30,$f30\nstt $f30,T\nldt $f30,Zero\nldt $f29,X\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.187\nldt $f29,Y\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.187\nldt $f29,Z\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.187\nldt $f29,T\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.187\nlda $27,1\nstl $27,GMult\nbr L.188\nL.187:\nmov $31,$27\nstl $27,GMult\nlda $16,1\nmov $27,$17\nlda $18,L.189\njsr $26,TstCond\nldgp $gp,0($26)\nL.188:\nldt $f30,Radix\nldt $f29,U2\nmult $f30,$f29,$f30\nstt $f30,Z\nldt $f30,Z\nldt $f29,One\naddt $f29,$f30,$f29\nstt $f29,X\nldt $f29,X\naddt $f29,$f30,$f30\nmult $f29,$f29,$f29\nsubt $f30,$f29,$f16\njsr $26,fabs\nldgp $gp,0($26)\nldt $f29,U2\nsubt $f0,$f29,$f30\nstt $f30,Y\nldt $f30,One\nsubt $f30,$f29,$f30\nstt $f30,X\nldt $f30,X\nsubt $f30,$f29,$f29\nmult $f30,$f30,$f30\nsubt $f29,$f30,$f16\njsr $26,fabs\nldgp $gp,0($26)\nldt $f29,U1\nsubt $f0,$f29,$f30\nstt $f30,Z\nmov $31,$16\nldt $f30,Zero\nldt $f29,Y\ncmptle $f29,$f30,$f1\nfbeq $f1,L.192\nldt $f29,Z\ncmptle $f29,$f30,$f1\nfbeq $f1,L.192\nlda $27,1\nstl $27,-96+256($sp)\nbr L.193\nL.192:\nstl $31,-96+256($sp)\nL.193:\nldl $17,-96+256($sp)\nlda $18,L.191\njsr $26,TstCond\nldgp $gp,0($26)\nldt $f30,One\nldt $f29,U2\nsubt $f30,$f29,$f28\nstt $f28,Y\naddt $f30,$f29,$f29\nstt $f29,X\nldt $f29,Y\ndivt $f30,$f29,$f29\nstt $f29,Z\nldt $f29,Z\nldt $f28,X\nsubt $f29,$f28,$f29\nstt $f29,Y\nldt $f29,Three\ndivt $f30,$f29,$f30\nstt $f30,X\nldt $f30,Nine\ndivt $f29,$f30,$f29\nstt $f29,Z\nldt $f29,Z\nldt $f28,X\nsubt $f28,$f29,$f28\nstt $f28,X\nldt $f28,TwentySeven\ndivt $f30,$f28,$f30\nstt $f30,T\nldt $f30,T\nsubt $f29,$f30,$f30\nstt $f30,Z\nlda $16,2\nldt $f30,Zero\nldt $f29,X\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.196\nldt $f29,Y\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.196\nldt $f29,Z\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.196\nlda $27,1\nstl $27,-100+256($sp)\nbr L.197\nL.196:\nstl $31,-100+256($sp)\nL.197:\nldl $17,-100+256($sp)\nlda $18,L.195\njsr $26,TstCond\nldgp $gp,0($26)\nldt $f30,F9\nldt $f29,One\ndivt $f30,$f29,$f28\nstt $f28,Y\nldt $f28,Half\nsubt $f30,$f28,$f30\nstt $f30,X\nldt $f30,Y\nsubt $f30,$f28,$f30\nldt $f28,X\nsubt $f30,$f28,$f30\nstt $f30,Y\nldt $f30,U2\naddt $f29,$f30,$f30\nstt $f30,X\nldt $f30,X\ndivt $f30,$f29,$f29\nstt $f29,T\nldt $f29,T\nsubt $f29,$f30,$f30\nstt $f30,X\nldt $f30,Zero\nldt $f29,X\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.198\nldt $f29,Y\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.198\nldt $f29,Z\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.198\nlda $27,1\nstl $27,GDiv\nbr L.199\nL.198:\nmov $31,$27\nstl $27,GDiv\nlda $16,1\nmov $27,$17\nlda $18,L.200\njsr $26,TstCond\nldgp $gp,0($26)\nL.199:\nldt $f30,One\nldt $f29,U2\naddt $f30,$f29,$f29\ndivt $f30,$f29,$f30\nstt $f30,X\nldt $f30,Half\nldt $f29,X\nsubt $f29,$f30,$f29\nsubt $f29,$f30,$f30\nstt $f30,Y\nlda $16,1\nldt $f30,Y\nldt $f29,Zero\ncmptlt $f30,$f29,$f1\nfbeq $f1,L.203\nlda $27,1\nstl $27,-104+256($sp)\nbr L.204\nL.203:\nstl $31,-104+256($sp)\nL.204:\nldl $17,-104+256($sp)\nlda $18,L.202\njsr $26,TstCond\nldgp $gp,0($26)\nldt $f30,One\nldt $f29,U2\nsubt $f30,$f29,$f28\nstt $f28,X\nldt $f28,Radix\nmult $f28,$f29,$f29\naddt $f30,$f29,$f30\nstt $f30,Y\nldt $f30,X\nmult $f30,$f28,$f29\nstt $f29,Z\nldt $f29,Y\nmult $f29,$f28,$f27\nstt $f27,T\nldt $f27,Z\ndivt $f27,$f28,$f27\nstt $f27,R\nldt $f27,T\ndivt $f27,$f28,$f28\nstt $f28,StickyBit\nldt $f28,R\nsubt $f28,$f30,$f30\nstt $f30,X\nldt $f30,StickyBit\nsubt $f30,$f29,$f30\nstt $f30,Y\nmov $31,$16\nldt $f30,Zero\nldt $f29,X\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.207\nldt $f29,Y\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.207\nlda $27,1\nstl $27,-108+256($sp)\nbr L.208\nL.207:\nstl $31,-108+256($sp)\nL.208:\nldl $17,-108+256($sp)\nlda $18,L.206\njsr $26,TstCond\nldgp $gp,0($26)\nldt $f30,One\nldt $f29,U1\nsubt $f30,$f29,$f29\nstt $f29,Y\nldt $f29,F9\nsubt $f30,$f29,$f29\nstt $f29,X\nldt $f29,Y\nsubt $f30,$f29,$f30\nstt $f30,Y\nldt $f30,Radix\nldt $f29,U2\nsubt $f30,$f29,$f29\nstt $f29,T\nldt $f29,BMinusU2\nsubt $f30,$f29,$f29\nstt $f29,Z\nldt $f29,T\nsubt $f30,$f29,$f30\nstt $f30,T\nldt $f30,U1\nldt $f29,X\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.209\nldt $f29,Y\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.209\nldt $f30,U2\nldt $f29,Z\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.209\nldt $f29,T\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.209\nlda $27,1\nstl $27,GAddSub\nbr L.210\nL.209:\nmov $31,$27\nstl $27,GAddSub\nlda $16,1\nmov $27,$17\nlda $18,L.211\njsr $26,TstCond\nldgp $gp,0($26)\nL.210:\nldt $f30,F9\nldt $f29,One\ncmpteq $f30,$f29,$f1\nfbne $f1,L.212\nsubt $f30,$f29,$f30\nldt $f29,Zero\ncmptlt $f30,$f29,$f1\nfbne $f1,L.212\nlda $16,1\nlda $17,L.214\njsr $26,BadCond\nldgp $gp,0($26)\nlda $16,L.215\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.216\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.217\njsr $26,printf\nldgp $gp,0($26)\nL.212:\nldl $27,GMult\ncmpeq $27,1,$23\nbeq $23,L.218\nldl $27,GDiv\ncmpeq $27,1,$23\nbeq $23,L.218\nldl $27,GAddSub\ncmpeq $27,1,$23\nbeq $23,L.218\nlda $16,L.220\njsr $26,printf\nldgp $gp,0($26)\nL.218:\nlda $27,40\nstl $27,Milestone\njsr $26,Pause\nldgp $gp,0($26)\nlda $16,L.221\njsr $26,printf\nldgp $gp,0($26)\nstl $31,RMult\nstl $31,RDiv\nstl $31,RAddSub\nldt $f30,Two\nldt $f29,Radix\ndivt $f29,$f30,$f29\nstt $f29,RadixD2\nstt $f30,A1\nstl $31,Done\nL.222:\nldt $f30,Radix\nstt $f30,AInvrse\nL.225:\nldt $f30,AInvrse\nstt $f30,X\nldt $f29,A1\ndivt $f30,$f29,$f30\nstt $f30,AInvrse\nL.226:\nldt $f16,AInvrse\njsr $26,floor\nldgp $gp,0($26)\nldt $f29,AInvrse\ncmpteq $f0,$f29,$f1\nfbne $f1,L.225\nldt $f30,X\nldt $f29,One\ncmpteq $f30,$f29,$f1\nfbne $f1,L.231\nldt $f30,A1\nldt $f29,Three\ncmptle $f30,$f29,$f1\nfbne $f1,L.229\nL.231:\nlda $27,1\nstl $27,-112+256($sp)\nbr L.230\nL.229:\nstl $31,-112+256($sp)\nL.230:\nldl $27,-112+256($sp)\nstl $27,Done\nldl $27,Done\ncmpeq $27,$31,$23\nbeq $23,L.232\nldt $f30,Nine\nldt $f29,One\naddt $f30,$f29,$f30\nstt $f30,A1\nL.232:\nL.223:\nldl $27,Done\ncmpeq $27,$31,$23\nbne $23,L.222\nldt $f30,X\nldt $f29,One\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.234\nldt $f30,Radix\nstt $f30,A1\nL.234:\nldt $f30,A1\nldt $f29,One\ndivt $f29,$f30,$f29\nstt $f29,AInvrse\nstt $f30,X\nldt $f30,AInvrse\nstt $f30,Y\nstl $31,Done\nL.236:\nldt $f30,Half\nldt $f29,X\nldt $f28,Y\nmult $f29,$f28,$f29\nsubt $f29,$f30,$f29\nstt $f29,Z\nmov $31,$16\nldt $f29,Z\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.241\nlda $27,1\nstl $27,-112+256($sp)\nbr L.242\nL.241:\nstl $31,-112+256($sp)\nL.242:\nldl $17,-112+256($sp)\nlda $18,L.240\njsr $26,TstCond\nldgp $gp,0($26)\nldt $f30,X\nldt $f29,Radix\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.244\nlda $27,1\nstl $27,-116+256($sp)\nbr L.245\nL.244:\nstl $31,-116+256($sp)\nL.245:\nldl $27,-116+256($sp)\nstl $27,Done\nldt $f30,Radix\nstt $f30,X\nldt $f30,One\nldt $f29,X\ndivt $f30,$f29,$f30\nstt $f30,Y\nL.237:\nldl $27,Done\ncmpeq $27,$31,$23\nbne $23,L.236\nldt $f30,One\nldt $f29,U2\naddt $f30,$f29,$f28\nstt $f28,Y2\nsubt $f30,$f29,$f30\nstt $f30,Y1\nldt $f30,OneAndHalf\nsubt $f30,$f29,$f28\nstt $f28,X\naddt $f30,$f29,$f28\nstt $f28,Y\nldt $f28,X\nldt $f27,Y2\nsubt $f28,$f29,$f26\nmult $f26,$f27,$f26\nstt $f26,Z\nldt $f26,Y\nldt $f25,Y1\nmult $f26,$f25,$f24\nstt $f24,T\nldt $f24,Z\nsubt $f24,$f28,$f24\nstt $f24,Z\nldt $f24,T\nsubt $f24,$f28,$f24\nstt $f24,T\nmult $f28,$f27,$f28\nstt $f28,X\naddt $f26,$f29,$f29\nmult $f29,$f25,$f29\nstt $f29,Y\nldt $f29,X\nsubt $f29,$f30,$f29\nstt $f29,X\nldt $f29,Y\nsubt $f29,$f30,$f30\nstt $f30,Y\nldt $f30,Zero\nldt $f29,X\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.246\nldt $f29,Y\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.246\nldt $f29,Z\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.246\nldt $f29,T\ncmptle $f29,$f30,$f1\nfbeq $f1,L.246\nldt $f30,OneAndHalf\nldt $f29,U2\naddt $f30,$f29,$f28\nldt $f27,Y2\nmult $f28,$f27,$f26\nstt $f26,X\nsubt $f30,$f29,$f30\nsubt $f30,$f29,$f26\nstt $f26,Y\naddt $f28,$f29,$f28\nstt $f28,Z\nldt $f28,Y1\nmult $f30,$f28,$f30\nstt $f30,T\nldt $f30,Z\naddt $f30,$f29,$f26\nldt $f25,X\nsubt $f25,$f26,$f25\nstt $f25,X\nldt $f25,Y\nmult $f25,$f28,$f24\nstt $f24,StickyBit\nmult $f30,$f27,$f30\nstt $f30,S\nldt $f30,T\nsubt $f30,$f25,$f30\nstt $f30,T\nsubt $f29,$f25,$f30\nldt $f25,StickyBit\naddt $f30,$f25,$f30\nstt $f30,Y\nldt $f30,S\naddt $f26,$f29,$f26\nsubt $f30,$f26,$f30\nstt $f30,Z\naddt $f27,$f29,$f30\nmult $f30,$f28,$f30\nstt $f30,StickyBit\nmult $f27,$f28,$f30\nstt $f30,Y1\nldt $f30,StickyBit\nsubt $f30,$f27,$f30\nstt $f30,StickyBit\nldt $f30,Y1\nldt $f29,Half\nsubt $f30,$f29,$f30\nstt $f30,Y1\nldt $f30,Zero\nldt $f29,X\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.248\nldt $f29,Y\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.248\nldt $f29,Z\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.248\nldt $f29,T\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.248\nldt $f29,StickyBit\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.248\nldt $f30,Y1\nldt $f29,Half\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.248\nlda $27,1\nstl $27,RMult\nlda $16,L.250\njsr $26,printf\nldgp $gp,0($26)\nbr L.249\nL.248:\nldt $f30,U2\nldt $f29,Zero\nldt $f28,X\naddt $f28,$f30,$f28\ncmpteq $f28,$f29,$f1\nfbeq $f1,L.251\nldt $f28,Y\ncmptlt $f28,$f29,$f1\nfbeq $f1,L.251\nldt $f28,Z\naddt $f28,$f30,$f28\ncmpteq $f28,$f29,$f1\nfbeq $f1,L.251\nldt $f28,T\ncmptlt $f28,$f29,$f1\nfbeq $f1,L.251\nldt $f28,StickyBit\naddt $f28,$f30,$f30\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.251\nldt $f30,Y1\nldt $f29,Half\ncmptlt $f30,$f29,$f1\nfbeq $f1,L.251\nlda $27,2\nstl $27,RMult\nlda $16,L.253\njsr $26,printf\nldgp $gp,0($26)\nbr L.252\nL.251:\nlda $16,L.254\njsr $26,printf\nldgp $gp,0($26)\nL.252:\nL.249:\nldl $27,RMult\ncmpeq $27,1,$23\nbeq $23,L.247\nldl $27,GMult\ncmpeq $27,$31,$23\nbeq $23,L.247\nlda $16,L.257\njsr $26,notify\nldgp $gp,0($26)\nbr L.247\nL.246:\nlda $16,L.254\njsr $26,printf\nldgp $gp,0($26)\nL.247:\nlda $27,45\nstl $27,Milestone\nldt $f30,One\nldt $f29,U2\naddt $f30,$f29,$f28\nstt $f28,Y2\nsubt $f30,$f29,$f30\nstt $f30,Y1\nldt $f30,OneAndHalf\naddt $f30,$f29,$f28\naddt $f28,$f29,$f27\nstt $f27,Z\nldt $f27,Z\nldt $f26,Y2\ndivt $f27,$f26,$f25\nstt $f25,X\nsubt $f30,$f29,$f25\nsubt $f25,$f29,$f25\nstt $f25,T\nldt $f25,T\nldt $f24,Y1\nsubt $f25,$f29,$f23\ndivt $f23,$f24,$f23\nstt $f23,Y\naddt $f27,$f29,$f27\ndivt $f27,$f26,$f27\nstt $f27,Z\nldt $f27,X\nsubt $f27,$f30,$f27\nstt $f27,X\nldt $f27,Y\nsubt $f27,$f25,$f27\nstt $f27,Y\ndivt $f25,$f24,$f27\nstt $f27,T\nldt $f27,Z\nsubt $f27,$f28,$f28\nstt $f28,Z\nsubt $f29,$f30,$f30\nldt $f29,T\naddt $f30,$f29,$f30\nstt $f30,T\nldt $f30,Zero\nldt $f29,X\ncmptle $f29,$f30,$f1\nfbeq $f1,L.258\nldt $f29,Y\ncmptle $f29,$f30,$f1\nfbeq $f1,L.258\nldt $f29,Z\ncmptle $f29,$f30,$f1\nfbeq $f1,L.258\nldt $f29,T\ncmptle $f29,$f30,$f1\nfbeq $f1,L.258\nldt $f30,OneAndHalf\nldt $f29,Y2\ndivt $f30,$f29,$f28\nstt $f28,X\nldt $f28,U2\nsubt $f30,$f28,$f27\nstt $f27,Y\naddt $f30,$f28,$f27\nstt $f27,Z\nldt $f27,Y\nldt $f26,X\nsubt $f26,$f27,$f26\nstt $f26,X\nldt $f26,Y1\ndivt $f30,$f26,$f25\nstt $f25,T\ndivt $f27,$f26,$f27\nstt $f27,Y\nldt $f27,Z\nldt $f26,T\naddt $f27,$f28,$f25\nsubt $f26,$f25,$f26\nstt $f26,T\nldt $f26,Y\nsubt $f26,$f27,$f26\nstt $f26,Y\ndivt $f27,$f29,$f27\nstt $f27,Z\naddt $f29,$f28,$f28\ndivt $f28,$f29,$f28\nstt $f28,Y1\nldt $f28,Z\nsubt $f28,$f30,$f30\nstt $f30,Z\nldt $f30,Y1\nsubt $f30,$f29,$f30\nstt $f30,Y2\nldt $f30,F9\nldt $f29,U1\nsubt $f30,$f29,$f29\ndivt $f29,$f30,$f30\nstt $f30,Y1\nldt $f30,Zero\nldt $f29,X\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.260\nldt $f29,Y\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.260\nldt $f29,Z\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.260\nldt $f29,T\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.260\nldt $f29,Y2\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.260\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.260\nldt $f30,Half\nldt $f29,Y1\nsubt $f29,$f30,$f29\nldt $f28,F9\nsubt $f28,$f30,$f30\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.260\nlda $27,1\nstl $27,RDiv\nlda $16,L.262\njsr $26,printf\nldgp $gp,0($26)\nldl $27,GDiv\ncmpeq $27,$31,$23\nbeq $23,L.261\nlda $16,L.265\njsr $26,notify\nldgp $gp,0($26)\nbr L.261\nL.260:\nldt $f30,Zero\nldt $f29,X\ncmptlt $f29,$f30,$f1\nfbeq $f1,L.266\nldt $f29,Y\ncmptlt $f29,$f30,$f1\nfbeq $f1,L.266\nldt $f29,Z\ncmptlt $f29,$f30,$f1\nfbeq $f1,L.266\nldt $f29,T\ncmptlt $f29,$f30,$f1\nfbeq $f1,L.266\nldt $f29,Y2\ncmptlt $f29,$f30,$f1\nfbeq $f1,L.266\nldt $f30,Half\nldt $f29,Y1\nsubt $f29,$f30,$f29\nldt $f28,F9\nsubt $f28,$f30,$f30\ncmptlt $f29,$f30,$f1\nfbeq $f1,L.266\nlda $27,2\nstl $27,RDiv\nlda $16,L.268\njsr $26,printf\nldgp $gp,0($26)\nL.266:\nL.261:\nL.258:\nldl $27,RDiv\ncmpeq $27,$31,$23\nbeq $23,L.269\nlda $16,L.271\njsr $26,printf\nldgp $gp,0($26)\nL.269:\nldt $f30,Radix\nldt $f29,One\ndivt $f29,$f30,$f29\nstt $f29,BInvrse\nmov $31,$16\nldt $f29,Half\nldt $f28,BInvrse\nmult $f28,$f30,$f30\nsubt $f30,$f29,$f30\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.274\nlda $27,1\nstl $27,-112+256($sp)\nbr L.275\nL.274:\nstl $31,-112+256($sp)\nL.275:\nldl $17,-112+256($sp)\nlda $18,L.273\njsr $26,TstCond\nldgp $gp,0($26)\nlda $27,50\nstl $27,Milestone\nmov $31,$16\nldt $f30,Half\nldt $f29,F9\nldt $f28,U1\naddt $f29,$f28,$f29\nsubt $f29,$f30,$f29\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.278\nldt $f30,One\nldt $f29,BMinusU2\nldt $f28,U2\naddt $f29,$f28,$f29\nsubt $f29,$f30,$f29\nldt $f28,Radix\nsubt $f28,$f30,$f30\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.278\nlda $27,1\nstl $27,-116+256($sp)\nbr L.279\nL.278:\nstl $31,-116+256($sp)\nL.279:\nldl $17,-116+256($sp)\nlda $18,L.277\njsr $26,TstCond\nldgp $gp,0($26)\nldt $f30,One\nldt $f29,U1\nmult $f29,$f29,$f29\nsubt $f30,$f29,$f29\nstt $f29,X\nldt $f29,U2\nsubt $f30,$f29,$f28\nmult $f29,$f28,$f29\naddt $f30,$f29,$f29\nstt $f29,Y\nldt $f29,Half\nldt $f28,F9\nsubt $f28,$f29,$f28\nstt $f28,Z\nldt $f28,X\nsubt $f28,$f29,$f29\nldt $f28,Z\nsubt $f29,$f28,$f29\nstt $f29,X\nldt $f29,Y\nsubt $f29,$f30,$f30\nstt $f30,Y\nldt $f30,Zero\nldt $f29,X\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.280\nldt $f29,Y\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.280\nlda $27,2\nstl $27,RAddSub\nlda $16,L.282\njsr $26,printf\nldgp $gp,0($26)\nL.280:\nldl $27,GAddSub\ncmpeq $27,1,$23\nbeq $23,L.283\nldt $f30,Half\nldt $f29,U2\naddt $f30,$f29,$f28\nmult $f28,$f29,$f28\nstt $f28,X\nsubt $f30,$f29,$f30\nmult $f30,$f29,$f30\nstt $f30,Y\nldt $f30,One\nldt $f28,X\naddt $f30,$f28,$f28\nstt $f28,X\nldt $f28,Y\naddt $f30,$f28,$f28\nstt $f28,Y\naddt $f30,$f29,$f29\nldt $f28,X\nsubt $f29,$f28,$f29\nstt $f29,X\nldt $f29,Y\nsubt $f30,$f29,$f30\nstt $f30,Y\nldt $f30,Zero\nldt $f29,X\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.285\nldt $f29,Y\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.285\nldt $f30,Half\nldt $f29,U2\nldt $f28,U1\naddt $f30,$f29,$f27\nmult $f27,$f28,$f27\nstt $f27,X\nsubt $f30,$f29,$f30\nmult $f30,$f28,$f30\nstt $f30,Y\nldt $f30,One\nldt $f29,X\nsubt $f30,$f29,$f29\nstt $f29,X\nldt $f29,Y\nsubt $f30,$f29,$f29\nstt $f29,Y\nldt $f29,F9\nldt $f28,X\nsubt $f29,$f28,$f29\nstt $f29,X\nldt $f29,Y\nsubt $f30,$f29,$f30\nstt $f30,Y\nldt $f30,Zero\nldt $f29,X\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.287\nldt $f29,Y\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.287\nlda $27,1\nstl $27,RAddSub\nlda $16,L.289\njsr $26,printf\nldgp $gp,0($26)\nldl $27,GAddSub\ncmpeq $27,$31,$23\nbeq $23,L.284\nlda $16,L.292\njsr $26,notify\nldgp $gp,0($26)\nbr L.284\nL.287:\nlda $16,L.293\njsr $26,printf\nldgp $gp,0($26)\nbr L.284\nL.285:\nlda $16,L.293\njsr $26,printf\nldgp $gp,0($26)\nbr L.284\nL.283:\nlda $16,L.293\njsr $26,printf\nldgp $gp,0($26)\nL.284:\nldt $f30,One\nstt $f30,S\nldt $f29,Half\naddt $f30,$f29,$f28\nmult $f29,$f28,$f28\naddt $f30,$f28,$f28\nstt $f28,X\nldt $f28,U2\naddt $f30,$f28,$f30\nmult $f30,$f29,$f30\nstt $f30,Y\nldt $f30,X\nldt $f29,Y\nsubt $f30,$f29,$f28\nstt $f28,Z\nsubt $f29,$f30,$f30\nstt $f30,T\nldt $f30,Z\nldt $f29,T\naddt $f30,$f29,$f30\nstt $f30,StickyBit\nldt $f30,StickyBit\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbne $f1,L.294\nldt $f30,Zero\nstt $f30,S\nlda $16,3\nlda $17,L.296\njsr $26,BadCond\nldgp $gp,0($26)\nL.294:\nldt $f30,Zero\nstt $f30,StickyBit\nldl $27,GMult\ncmpeq $27,1,$23\nbeq $23,L.297\nldl $27,GDiv\ncmpeq $27,1,$23\nbeq $23,L.297\nldl $27,GAddSub\ncmpeq $27,1,$23\nbeq $23,L.297\nldl $27,RMult\ncmpeq $27,1,$23\nbeq $23,L.297\nldl $27,RDiv\ncmpeq $27,1,$23\nbeq $23,L.297\nldl $27,RAddSub\ncmpeq $27,1,$23\nbeq $23,L.297\nldt $f16,RadixD2\njsr $26,floor\nldgp $gp,0($26)\nldt $f29,RadixD2\ncmpteq $f0,$f29,$f1\nfbeq $f1,L.297\nlda $16,L.299\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,Half\nldt $f29,U2\nldt $f28,U1\naddt $f30,$f28,$f28\nmult $f28,$f29,$f28\nstt $f28,X\nmult $f30,$f29,$f30\nstt $f30,Y\nldt $f30,One\nldt $f29,Y\naddt $f30,$f29,$f29\nstt $f29,Z\nldt $f29,X\naddt $f30,$f29,$f30\nstt $f30,T\nldt $f30,One\nldt $f29,Z\nsubt $f29,$f30,$f29\nldt $f28,Zero\ncmptle $f29,$f28,$f1\nfbeq $f1,L.300\nldt $f29,T\nsubt $f29,$f30,$f30\nldt $f29,U2\ncmptlt $f30,$f29,$f1\nfbne $f1,L.300\nldt $f30,T\nldt $f29,Y\naddt $f30,$f29,$f30\nstt $f30,Z\nldt $f30,Z\nldt $f29,X\nsubt $f30,$f29,$f30\nstt $f30,Y\nldt $f30,T\nldt $f29,Z\nsubt $f29,$f30,$f29\nldt $f28,U2\ncmptlt $f29,$f28,$f1\nfbne $f1,L.302\nldt $f29,Y\nsubt $f29,$f30,$f30\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.302\nldt $f30,Half\nldt $f29,U1\naddt $f30,$f29,$f28\nmult $f28,$f29,$f28\nstt $f28,X\nmult $f30,$f29,$f30\nstt $f30,Y\nldt $f30,One\nldt $f29,Y\nsubt $f30,$f29,$f29\nstt $f29,Z\nldt $f29,X\nsubt $f30,$f29,$f30\nstt $f30,T\nldt $f30,Zero\nldt $f29,Z\nldt $f28,One\nsubt $f29,$f28,$f29\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.304\nldt $f29,T\nldt $f28,F9\nsubt $f29,$f28,$f29\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.304\nldt $f30,U1\nldt $f29,Half\nsubt $f29,$f30,$f29\nmult $f29,$f30,$f30\nstt $f30,Z\nldt $f30,F9\nldt $f29,Z\nsubt $f30,$f29,$f29\nstt $f29,T\nldt $f29,Y\nsubt $f30,$f29,$f30\nstt $f30,Q\nldt $f30,F9\nldt $f29,Zero\nldt $f28,T\nsubt $f28,$f30,$f28\ncmpteq $f28,$f29,$f1\nfbeq $f1,L.306\nldt $f28,U1\nsubt $f30,$f28,$f30\nldt $f28,Q\nsubt $f30,$f28,$f30\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.306\nldt $f30,One\nldt $f29,U2\nldt $f28,OneAndHalf\naddt $f30,$f29,$f27\nmult $f27,$f28,$f27\nstt $f27,Z\naddt $f28,$f29,$f28\nldt $f27,Z\nsubt $f28,$f27,$f28\naddt $f28,$f29,$f28\nstt $f28,T\nldt $f28,Radix\nldt $f27,Half\ndivt $f27,$f28,$f27\naddt $f30,$f27,$f27\nstt $f27,X\nmult $f28,$f29,$f29\naddt $f30,$f29,$f30\nstt $f30,Y\nldt $f30,X\nldt $f29,Y\nmult $f30,$f29,$f30\nstt $f30,Z\nldt $f30,Zero\nldt $f29,T\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.308\nldt $f29,X\nldt $f28,Radix\nldt $f27,U2\nmult $f28,$f27,$f28\naddt $f29,$f28,$f29\nldt $f28,Z\nsubt $f29,$f28,$f29\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.308\nldt $f30,Radix\nldt $f29,Two\ncmpteq $f30,$f29,$f1\nfbne $f1,L.310\nldt $f30,Two\nldt $f29,U2\naddt $f30,$f29,$f29\nstt $f29,X\nldt $f29,X\ndivt $f29,$f30,$f30\nstt $f30,Y\nldt $f30,Y\nldt $f29,One\nsubt $f30,$f29,$f30\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.311\nldt $f30,S\nstt $f30,StickyBit\nbr L.311\nL.310:\nldt $f30,S\nstt $f30,StickyBit\nL.311:\nL.308:\nL.306:\nL.304:\nL.302:\nL.300:\nL.297:\nldt $f30,StickyBit\nldt $f29,One\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.314\nlda $16,L.316\njsr $26,printf\nldgp $gp,0($26)\nbr L.315\nL.314:\nlda $16,L.317\njsr $26,printf\nldgp $gp,0($26)\nL.315:\nlda $16,3\nldl $25,GMult\ncmpeq $25,$31,$23\nbne $23,L.320\nldl $25,GDiv\ncmpeq $25,$31,$23\nbne $23,L.320\nldl $25,GAddSub\ncmpeq $25,$31,$23\nbne $23,L.320\nldl $25,RMult\ncmpeq $25,$31,$23\nbne $23,L.320\nldl $25,RDiv\ncmpeq $25,$31,$23\nbne $23,L.320\nldl $25,RAddSub\ncmpeq $25,$31,$23\nbne $23,L.320\nlda $27,1\nstl $27,-120+256($sp)\nbr L.321\nL.320:\nstl $31,-120+256($sp)\nL.321:\nldl $17,-120+256($sp)\nlda $18,L.319\njsr $26,TstCond\nldgp $gp,0($26)\nlda $27,60\nstl $27,Milestone\nlda $16,L.45\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.322\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.323\nldl $17,NoTrials\njsr $26,printf\nldgp $gp,0($26)\nldt $f16,L.324\njsr $26,sqrt\nldgp $gp,0($26)\nstt $f0,Random9\nldt $f30,Third\nstt $f30,Random1\nlda $27,1\nstl $27,I\nL.325:\njsr $26,Random\nldgp $gp,0($26)\nstt $f0,X\njsr $26,Random\nldgp $gp,0($26)\nstt $f0,Y\nldt $f30,Y\nldt $f29,X\nmult $f30,$f29,$f28\nstt $f28,Z9\nmult $f29,$f30,$f30\nstt $f30,Z\nldt $f30,Z\nldt $f29,Z9\nsubt $f30,$f29,$f30\nstt $f30,Z9\nldl $27,I\nlda $27,1($27)\nstl $27,I\nL.326:\nldl $27,I\nldl $25,NoTrials\ncmple $27,$25,$23\nbeq $23,L.328\nldt $f30,Z9\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbne $f1,L.325\nL.328:\nldl $27,I\nldl $25,NoTrials\ncmpeq $27,$25,$23\nbeq $23,L.329\nldt $f30,One\nldt $f29,Half\nldt $f28,Three\ndivt $f29,$f28,$f29\naddt $f30,$f29,$f29\nstt $f29,Random1\nldt $f28,U2\nldt $f27,U1\naddt $f28,$f27,$f28\naddt $f28,$f30,$f30\nstt $f30,Random2\nldt $f28,Random1\nldt $f27,Random2\nmult $f28,$f27,$f26\nstt $f26,Z\nmult $f27,$f28,$f28\nstt $f28,Y\nmult $f29,$f30,$f30\nsubt $f30,$f30,$f30\nstt $f30,Z9\nL.329:\nldl $27,I\nldl $25,NoTrials\ncmpeq $27,$25,$23\nbne $23,L.331\nldt $f30,Z9\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbne $f1,L.331\nlda $16,2\nlda $17,L.333\njsr $26,BadCond\nldgp $gp,0($26)\nbr L.332\nL.331:\nlda $16,L.334\nldl $17,NoTrials\njsr $26,printf\nldgp $gp,0($26)\nL.332:\nlda $27,70\nstl $27,Milestone\nlda $16,L.335\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,Zero\nstt $f30,-136+256($sp)\nfmov $f30,$f16\njsr $26,sqrt\nldgp $gp,0($26)\nldt $f29,-136+256($sp)\ncmpteq $f29,$f0,$f1\nfbeq $f1,L.338\nldt $f30,Zero\nnegt $f30,$f30\nstt $f30,-144+256($sp)\nfmov $f30,$f16\njsr $26,sqrt\nldgp $gp,0($26)\nldt $f29,-144+256($sp)\ncmpteq $f29,$f0,$f1\nfbeq $f1,L.338\nldt $f30,One\nstt $f30,-152+256($sp)\nfmov $f30,$f16\njsr $26,sqrt\nldgp $gp,0($26)\nfmov $f0,$f30\nldt $f29,-152+256($sp)\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.338\nlda $27,1\nstl $27,-124+256($sp)\nbr L.339\nL.338:\nstl $31,-124+256($sp)\nL.339:\nmov $31,$16\nldl $17,-124+256($sp)\nlda $18,L.337\njsr $26,TstCond\nldgp $gp,0($26)\nldt $f30,Zero\nstt $f30,MinSqEr\nstt $f30,MaxSqEr\nstt $f30,J\nldt $f30,Radix\nstt $f30,X\nldt $f30,U2\nstt $f30,OneUlp\nlda $16,1\njsr $26,SqXMinX\nldgp $gp,0($26)\nldt $f30,BInvrse\nstt $f30,X\nldt $f29,U1\nmult $f30,$f29,$f30\nstt $f30,OneUlp\nlda $16,1\njsr $26,SqXMinX\nldgp $gp,0($26)\nldt $f30,U1\nstt $f30,X\nmult $f30,$f30,$f30\nstt $f30,OneUlp\nlda $16,1\njsr $26,SqXMinX\nldgp $gp,0($26)\nldt $f30,J\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbne $f1,L.340\njsr $26,Pause\nldgp $gp,0($26)\nL.340:\nlda $16,L.342\nldl $17,NoTrials\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,Zero\nstt $f30,J\nldt $f30,Two\nstt $f30,X\nldt $f30,Radix\nstt $f30,Y\nldt $f29,One\ncmpteq $f30,$f29,$f1\nfbne $f1,L.343\nL.345:\nldt $f30,Y\nstt $f30,X\nldt $f29,Radix\nmult $f29,$f30,$f30\nstt $f30,Y\nL.346:\nldt $f30,Y\nldt $f29,X\nsubt $f30,$f29,$f30\nlds $f29,NoTrials\ncvtlq $f29,$f29\ncvtqt $f29,$f29\ncmptlt $f30,$f29,$f1\nfbne $f1,L.345\nL.343:\nldt $f30,X\nldt $f29,U2\nmult $f30,$f29,$f30\nstt $f30,OneUlp\nlda $27,1\nstl $27,I\nbr L.349\nL.348:\nldt $f30,X\nldt $f29,One\naddt $f30,$f29,$f30\nstt $f30,X\nlda $16,2\njsr $26,SqXMinX\nldgp $gp,0($26)\nldt $f30,J\nldt $f29,Zero\ncmptle $f30,$f29,$f1\nfbne $f1,L.351\nbr L.350\nL.351:\nldl $27,I\nlda $27,1($27)\nstl $27,I\nL.349:\nldl $27,I\nldl $25,NoTrials\ncmple $27,$25,$23\nbne $23,L.348\nL.350:\nlda $16,L.353\njsr $26,printf\nldgp $gp,0($26)\nlda $27,-1\nstl $27,I\nldt $f30,BMinusU2\nstt $f30,X\nldt $f30,Radix\nstt $f30,Y\nldt $f29,U2\nmult $f30,$f29,$f29\naddt $f30,$f29,$f30\nstt $f30,Z\nstl $31,NotMonot\nstl $31,Monot\nbr L.355\nL.354:\nldl $27,I\nlda $27,1($27)\nstl $27,I\nldt $f16,X\njsr $26,sqrt\nldgp $gp,0($26)\nstt $f0,X\nldt $f16,Y\njsr $26,sqrt\nldgp $gp,0($26)\nstt $f0,Q\nldt $f16,Z\njsr $26,sqrt\nldgp $gp,0($26)\nstt $f0,Z\nldt $f30,Q\nldt $f29,X\ncmptle $f29,$f30,$f1\nfbeq $f1,L.359\nldt $f29,Z\ncmptle $f30,$f29,$f1\nfbne $f1,L.357\nL.359:\nlda $27,1\nstl $27,NotMonot\nbr L.358\nL.357:\nldt $f30,Q\nldt $f29,Half\naddt $f30,$f29,$f16\njsr $26,floor\nldgp $gp,0($26)\nstt $f0,Q\nldl $27,I\ncmple $27,$31,$23\nbeq $23,L.362\nldt $f30,Q\nldt $f29,Radix\nmult $f30,$f30,$f30\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.360\nL.362:\nlda $27,1\nstl $27,Monot\nbr L.361\nL.360:\nldl $27,I\ncmple $27,$31,$23\nbne $23,L.363\nldl $27,I\ncmple $27,1,$23\nbne $23,L.365\nlda $27,1\nstl $27,Monot\nbr L.364\nL.365:\nldt $f30,Y\nldt $f29,BInvrse\nmult $f30,$f29,$f30\nstt $f30,Y\nldt $f30,Y\nldt $f29,U1\nsubt $f30,$f29,$f28\nstt $f28,X\naddt $f30,$f29,$f30\nstt $f30,Z\nbr L.364\nL.363:\nldt $f30,Q\nstt $f30,Y\nldt $f30,Y\nldt $f29,U2\nsubt $f30,$f29,$f28\nstt $f28,X\naddt $f30,$f29,$f30\nstt $f30,Z\nL.364:\nL.361:\nL.358:\nL.355:\nldl $25,NotMonot\ncmpeq $25,$31,$23\nbeq $23,L.367\nldl $25,Monot\ncmpeq $25,$31,$23\nbne $23,L.354\nL.367:\nldl $27,Monot\ncmpeq $27,$31,$23\nbne $23,L.368\nlda $16,L.370\njsr $26,printf\nldgp $gp,0($26)\nbr L.369\nL.368:\nlda $16,2\nlda $17,L.158\njsr $26,BadCond\nldgp $gp,0($26)\nlda $16,L.371\nldt $f17,Y\njsr $26,printf\nldgp $gp,0($26)\nL.369:\nlda $27,80\nstl $27,Milestone\nldt $f30,Half\nldt $f29,MinSqEr\naddt $f29,$f30,$f29\nstt $f29,MinSqEr\nldt $f29,MaxSqEr\nsubt $f29,$f30,$f30\nstt $f30,MaxSqEr\nldt $f30,One\nldt $f29,U2\naddt $f30,$f29,$f16\njsr $26,sqrt\nldgp $gp,0($26)\nldt $f29,One\nldt $f28,U2\nsubt $f0,$f29,$f30\ndivt $f30,$f28,$f30\nstt $f30,Y\nldt $f30,Y\nsubt $f30,$f29,$f30\nldt $f29,Eight\ndivt $f28,$f29,$f29\naddt $f30,$f29,$f30\nstt $f30,SqEr\nldt $f30,SqEr\nldt $f29,MaxSqEr\ncmptle $f30,$f29,$f1\nfbne $f1,L.372\nldt $f30,SqEr\nstt $f30,MaxSqEr\nL.372:\nldt $f30,Y\nldt $f29,U2\nldt $f28,Eight\ndivt $f29,$f28,$f29\naddt $f30,$f29,$f30\nstt $f30,SqEr\nldt $f30,SqEr\nldt $f29,MinSqEr\ncmptlt $f30,$f29,$f1\nfbeq $f1,L.374\nldt $f30,SqEr\nstt $f30,MinSqEr\nL.374:\nldt $f16,F9\njsr $26,sqrt\nldgp $gp,0($26)\nldt $f29,U2\nldt $f28,U1\nsubt $f0,$f29,$f30\nldt $f27,One\nsubt $f27,$f29,$f29\nsubt $f30,$f29,$f30\ndivt $f30,$f28,$f30\nstt $f30,Y\nldt $f30,Y\nldt $f29,Eight\ndivt $f28,$f29,$f29\naddt $f30,$f29,$f30\nstt $f30,SqEr\nldt $f30,SqEr\nldt $f29,MaxSqEr\ncmptle $f30,$f29,$f1\nfbne $f1,L.376\nldt $f30,SqEr\nstt $f30,MaxSqEr\nL.376:\nldt $f30,Y\nldt $f29,One\naddt $f30,$f29,$f30\nldt $f29,U1\nldt $f28,Eight\ndivt $f29,$f28,$f29\naddt $f30,$f29,$f30\nstt $f30,SqEr\nldt $f30,SqEr\nldt $f29,MinSqEr\ncmptlt $f30,$f29,$f1\nfbeq $f1,L.378\nldt $f30,SqEr\nstt $f30,MinSqEr\nL.378:\nldt $f30,U2\nstt $f30,OneUlp\nldt $f30,OneUlp\nstt $f30,X\nlda $27,1\nstl $27,Indx\nL.380:\nldt $f30,X\nldt $f29,U1\naddt $f30,$f29,$f29\naddt $f29,$f30,$f30\nldt $f29,F9\naddt $f30,$f29,$f16\njsr $26,sqrt\nldgp $gp,0($26)\nstt $f0,Y\nldt $f30,U2\nldt $f29,X\nldt $f28,OneUlp\nldt $f27,Y\nsubt $f27,$f30,$f27\nldt $f26,One\nsubt $f26,$f30,$f30\naddt $f30,$f29,$f30\nsubt $f27,$f30,$f30\ndivt $f30,$f28,$f30\nstt $f30,Y\nldt $f30,Half\nldt $f27,U1\nsubt $f27,$f29,$f27\nldt $f26,F9\naddt $f27,$f26,$f27\nmult $f27,$f30,$f27\nmult $f27,$f29,$f27\nmult $f27,$f29,$f29\ndivt $f29,$f28,$f29\nstt $f29,Z\nldt $f29,Y\naddt $f29,$f30,$f30\nldt $f29,Z\naddt $f30,$f29,$f30\nstt $f30,SqEr\nldt $f30,SqEr\nldt $f29,MinSqEr\ncmptlt $f30,$f29,$f1\nfbeq $f1,L.384\nldt $f30,SqEr\nstt $f30,MinSqEr\nL.384:\nldt $f30,Y\nldt $f29,Half\nsubt $f30,$f29,$f30\nldt $f29,Z\naddt $f30,$f29,$f30\nstt $f30,SqEr\nldt $f30,SqEr\nldt $f29,MaxSqEr\ncmptle $f30,$f29,$f1\nfbne $f1,L.386\nldt $f30,SqEr\nstt $f30,MaxSqEr\nL.386:\nldl $27,Indx\ncmpeq $27,1,$23\nbne $23,L.390\ncmpeq $27,3,$23\nbeq $23,L.388\nL.390:\nldt $f16,X\njsr $26,Sign\nldgp $gp,0($26)\nfmov $f0,$f30\nstt $f30,-160+256($sp)\nldt $f16,OneUlp\njsr $26,sqrt\nldgp $gp,0($26)\nldt $f29,Eight\nldt $f28,Nine\nmult $f28,$f0,$f30\ndivt $f29,$f30,$f16\njsr $26,floor\nldgp $gp,0($26)\nldt $f29,OneUlp\nldt $f28,-160+256($sp)\nmult $f29,$f28,$f29\nmult $f29,$f0,$f30\nstt $f30,X\nbr L.389\nL.388:\nldt $f30,U1\nstt $f30,OneUlp\nldt $f30,OneUlp\nnegt $f30,$f30\nstt $f30,X\nL.389:\nL.381:\nldl $27,Indx\nlda $27,1($27)\nstl $27,Indx\nldl $27,Indx\ncmple $27,3,$23\nbne $23,L.380\nlda $27,85\nstl $27,Milestone\nstl $31,SqRWrng\nstl $31,Anomaly\nstl $31,RSqrt\nldt $f30,Radix\nldt $f29,One\ncmpteq $f30,$f29,$f1\nfbne $f1,L.391\nlda $16,L.393\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,Precision\nstt $f30,-160+256($sp)\nfmov $f30,$f16\njsr $26,floor\nldgp $gp,0($26)\nfmov $f0,$f30\nldt $f16,Radix\nldt $f29,One\nldt $f28,-160+256($sp)\naddt $f29,$f28,$f29\nsubt $f29,$f30,$f17\njsr $26,pow\nldgp $gp,0($26)\nfmov $f0,$f30\nldt $f29,Half\naddt $f29,$f30,$f16\njsr $26,floor\nldgp $gp,0($26)\nstt $f0,D\nldt $f30,D\nldt $f29,Radix\ndivt $f30,$f29,$f29\nstt $f29,X\nldt $f29,A1\ndivt $f30,$f29,$f30\nstt $f30,Y\nldt $f30,X\nstt $f30,-168+256($sp)\nfmov $f30,$f16\njsr $26,floor\nldgp $gp,0($26)\nldt $f29,-168+256($sp)\ncmpteq $f29,$f0,$f1\nfbeq $f1,L.396\nldt $f30,Y\nstt $f30,-176+256($sp)\nfmov $f30,$f16\njsr $26,floor\nldgp $gp,0($26)\nldt $f29,-176+256($sp)\ncmpteq $f29,$f0,$f1\nfbne $f1,L.394\nL.396:\nlda $27,1\nstl $27,Anomaly\nbr L.395\nL.394:\nldt $f30,Zero\nstt $f30,X\nldt $f30,X\nstt $f30,Z2\nldt $f30,One\nstt $f30,Y\nldt $f29,Y\nstt $f29,Y2\nldt $f29,Radix\nsubt $f29,$f30,$f30\nstt $f30,Z1\nldt $f30,Four\nldt $f29,D\nmult $f30,$f29,$f30\nstt $f30,FourD\nL.397:\nldt $f30,Y2\nldt $f29,Z2\ncmptle $f30,$f29,$f1\nfbne $f1,L.400\nldt $f30,Radix\nstt $f30,Q\nldt $f30,Y\nstt $f30,Y1\nL.402:\nldt $f30,Q\nstt $f30,-184+256($sp)\nldt $f29,Half\nldt $f28,Y1\ndivt $f30,$f28,$f28\nsubt $f29,$f28,$f16\njsr $26,floor\nldgp $gp,0($26)\nldt $f29,Y1\nmult $f0,$f29,$f30\nldt $f29,-184+256($sp)\naddt $f29,$f30,$f16\njsr $26,fabs\nldgp $gp,0($26)\nstt $f0,X1\nldt $f30,Y1\nstt $f30,Q\nldt $f30,X1\nstt $f30,Y1\nL.403:\nldt $f30,X1\nldt $f29,Zero\ncmptle $f30,$f29,$f1\nfbeq $f1,L.402\nldt $f30,Q\nldt $f29,One\ncmptle $f30,$f29,$f1\nfbeq $f1,L.405\nldt $f30,Y2\nstt $f30,Z2\nldt $f30,Y\nstt $f30,Z\nL.405:\nL.400:\nldt $f30,Y\nldt $f29,Two\naddt $f30,$f29,$f30\nstt $f30,Y\nldt $f30,X\nldt $f29,Eight\naddt $f30,$f29,$f30\nstt $f30,X\nldt $f30,Y2\nldt $f29,X\naddt $f30,$f29,$f30\nstt $f30,Y2\nldt $f30,Y2\nldt $f29,FourD\ncmptlt $f30,$f29,$f1\nfbne $f1,L.407\nldt $f30,Y2\nldt $f29,FourD\nsubt $f30,$f29,$f30\nstt $f30,Y2\nL.407:\nL.398:\nldt $f30,Y\nldt $f29,D\ncmptlt $f30,$f29,$f1\nfbne $f1,L.397\nldt $f30,FourD\nldt $f29,Z2\nsubt $f30,$f29,$f29\nstt $f29,X8\nldt $f29,X8\nldt $f28,Z\nmult $f28,$f28,$f28\naddt $f29,$f28,$f28\ndivt $f28,$f30,$f30\nstt $f30,Q\nldt $f30,Eight\ndivt $f29,$f30,$f30\nstt $f30,X8\nldt $f30,Q\nstt $f30,-184+256($sp)\nfmov $f30,$f16\njsr $26,floor\nldgp $gp,0($26)\nldt $f29,-184+256($sp)\ncmpteq $f29,$f0,$f1\nfbne $f1,L.409\nlda $27,1\nstl $27,Anomaly\nbr L.410\nL.409:\nstl $31,Break\nL.411:\nldt $f30,Z1\nldt $f29,Z\nmult $f30,$f29,$f30\nstt $f30,X\nldt $f30,X\nstt $f30,-192+256($sp)\nldt $f29,Radix\ndivt $f30,$f29,$f16\njsr $26,floor\nldgp $gp,0($26)\nldt $f29,Radix\nmult $f0,$f29,$f30\nldt $f29,-192+256($sp)\nsubt $f29,$f30,$f30\nstt $f30,X\nldt $f30,X\nldt $f29,One\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.414\nlda $27,1\nstl $27,Break\nbr L.415\nL.414:\nldt $f30,Z1\nldt $f29,One\nsubt $f30,$f29,$f30\nstt $f30,Z1\nL.415:\nL.412:\nldl $27,Break\ncmpeq $27,$31,$23\nbeq $23,L.416\nldt $f30,Z1\nldt $f29,Zero\ncmptle $f30,$f29,$f1\nfbeq $f1,L.411\nL.416:\nldt $f30,Z1\nldt $f29,Zero\ncmptle $f30,$f29,$f1\nfbeq $f1,L.417\nldl $27,Break\ncmpeq $27,$31,$23\nbeq $23,L.417\nlda $27,1\nstl $27,Anomaly\nbr L.418\nL.417:\nldt $f30,Z1\nldt $f29,RadixD2\ncmptle $f30,$f29,$f1\nfbne $f1,L.419\nldt $f30,Z1\nldt $f29,Radix\nsubt $f30,$f29,$f30\nstt $f30,Z1\nL.419:\nL.421:\njsr $26,NewD\nldgp $gp,0($26)\nL.422:\nldt $f30,U2\nldt $f29,D\nmult $f30,$f29,$f30\nldt $f29,F9\ncmptlt $f30,$f29,$f1\nfbne $f1,L.421\nldt $f30,D\nldt $f29,Radix\nmult $f30,$f29,$f29\nsubt $f29,$f30,$f29\nldt $f28,W\nsubt $f28,$f30,$f30\ncmpteq $f29,$f30,$f1\nfbne $f1,L.424\nlda $27,1\nstl $27,Anomaly\nbr L.425\nL.424:\nldt $f30,D\nstt $f30,Z2\nstl $31,I\nldt $f29,Z\nldt $f28,One\naddt $f28,$f29,$f28\nldt $f27,Half\nmult $f28,$f27,$f28\naddt $f30,$f28,$f28\nstt $f28,Y\naddt $f30,$f29,$f30\nldt $f29,Q\naddt $f30,$f29,$f30\nstt $f30,X\njsr $26,SR3750\nldgp $gp,0($26)\nldt $f30,D\nldt $f29,Z\nldt $f28,One\nsubt $f28,$f29,$f28\nldt $f27,Half\nmult $f28,$f27,$f28\naddt $f30,$f28,$f28\naddt $f28,$f30,$f28\nstt $f28,Y\nsubt $f30,$f29,$f29\naddt $f29,$f30,$f30\nstt $f30,X\nldt $f30,X\nldt $f29,Q\naddt $f30,$f29,$f29\naddt $f29,$f30,$f30\nstt $f30,X\njsr $26,SR3750\nldgp $gp,0($26)\njsr $26,NewD\nldgp $gp,0($26)\nldt $f30,Z2\nldt $f29,D\nsubt $f29,$f30,$f29\nldt $f28,W\nsubt $f28,$f30,$f30\ncmpteq $f29,$f30,$f1\nfbne $f1,L.426\nlda $27,1\nstl $27,Anomaly\nbr L.427\nL.426:\nldt $f30,Z2\nldt $f29,D\nsubt $f29,$f30,$f29\nldt $f28,Z\nldt $f27,One\nsubt $f27,$f28,$f27\nldt $f26,Half\nmult $f27,$f26,$f27\naddt $f30,$f27,$f27\naddt $f29,$f27,$f27\nstt $f27,Y\nsubt $f30,$f28,$f30\nldt $f28,Q\naddt $f30,$f28,$f30\naddt $f29,$f30,$f30\nstt $f30,X\njsr $26,SR3750\nldgp $gp,0($26)\nldt $f30,One\nldt $f29,Z\naddt $f30,$f29,$f30\nldt $f29,Half\nmult $f30,$f29,$f30\nstt $f30,Y\nldt $f30,Q\nstt $f30,X\njsr $26,SR3750\nldgp $gp,0($26)\nldl $27,I\ncmpeq $27,$31,$23\nbeq $23,L.428\nlda $27,1\nstl $27,Anomaly\nL.428:\nL.427:\nL.425:\nL.418:\nL.410:\nL.395:\nldl $25,I\ncmpeq $25,$31,$23\nbne $23,L.432\nldl $25,Anomaly\ncmpeq $25,$31,$23\nbne $23,L.430\nL.432:\nmov $31,$16\nlda $17,L.433\njsr $26,BadCond\nldgp $gp,0($26)\nlda $16,L.434\nldt $f17,W\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.435\njsr $26,printf\nldgp $gp,0($26)\nlda $27,1\nstl $27,SqRWrng\nL.430:\nL.391:\nldl $27,Anomaly\ncmpeq $27,$31,$23\nbeq $23,L.436\nldt $f30,Zero\nldt $f29,MinSqEr\ncmptlt $f29,$f30,$f1\nfbne $f1,L.438\nldt $f29,MaxSqEr\ncmptle $f29,$f30,$f1\nfbeq $f1,L.438\nlda $27,1\nstl $27,RSqrt\nlda $16,L.440\njsr $26,printf\nldgp $gp,0($26)\nbr L.439\nL.438:\nldt $f30,U2\nldt $f29,Half\nldt $f28,MaxSqEr\naddt $f28,$f30,$f28\nsubt $f30,$f29,$f30\ncmptle $f28,$f30,$f1\nfbeq $f1,L.444\nldt $f30,MinSqEr\ncmptle $f30,$f29,$f1\nfbeq $f1,L.444\nldt $f28,Radix\naddt $f30,$f28,$f30\ncmptlt $f30,$f29,$f1\nfbeq $f1,L.441\nL.444:\nlda $27,1\nstl $27,SqRWrng\nbr L.442\nL.441:\nlda $27,2\nstl $27,RSqrt\nlda $16,L.445\njsr $26,printf\nldgp $gp,0($26)\nL.442:\nL.439:\nL.436:\nldl $27,SqRWrng\ncmpeq $27,$31,$23\nbne $23,L.446\nlda $16,L.448\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.449\nldt $f30,MinSqEr\nldt $f29,Half\nsubt $f30,$f29,$f17\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.450\nldt $f30,Half\nldt $f29,MaxSqEr\naddt $f30,$f29,$f17\njsr $26,printf\nldgp $gp,0($26)\nlda $16,1\nldt $f30,Radix\nldt $f29,MaxSqEr\nldt $f28,MinSqEr\nsubt $f29,$f28,$f29\nmult $f30,$f30,$f30\ncmptlt $f29,$f30,$f1\nfbeq $f1,L.453\nlda $27,1\nstl $27,-156+256($sp)\nbr L.454\nL.453:\nstl $31,-156+256($sp)\nL.454:\nldl $17,-156+256($sp)\nlda $18,L.452\njsr $26,TstCond\nldgp $gp,0($26)\nL.446:\nlda $27,90\nstl $27,Milestone\njsr $26,Pause\nldgp $gp,0($26)\nlda $16,L.455\njsr $26,printf\nldgp $gp,0($26)\nstl $31,N\nstl $31,I\nldt $f30,Zero\nnegt $f30,$f30\nstt $f30,Z\nlda $25,3\nstl $25,M\nstl $31,Break\nL.456:\nldt $f30,One\nstt $f30,X\njsr $26,SR3980\nldgp $gp,0($26)\nldl $27,I\ncmple $27,10,$23\nbeq $23,L.459\nlda $27,1023\nstl $27,I\njsr $26,SR3980\nldgp $gp,0($26)\nL.459:\nldt $f30,Z\nldt $f29,MinusOne\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.461\nlda $27,1\nstl $27,Break\nbr L.462\nL.461:\nldt $f30,MinusOne\nstt $f30,Z\njsr $26,PrintIfNPositive\nldgp $gp,0($26)\nstl $31,N\nlda $27,-4\nstl $27,I\nL.462:\nL.457:\nldl $27,Break\ncmpeq $27,$31,$23\nbne $23,L.456\njsr $26,PrintIfNPositive\nldgp $gp,0($26)\nldl $27,N\nstl $27,N1\nstl $31,N\nldt $f30,A1\nstt $f30,Z\nldt $f16,W\njsr $26,log\nldgp $gp,0($26)\nfmov $f0,$f30\nstt $f30,-160+256($sp)\nldt $f16,A1\njsr $26,log\nldgp $gp,0($26)\nfmov $f0,$f30\nldt $f29,Two\nldt $f28,-160+256($sp)\nmult $f29,$f28,$f29\ndivt $f29,$f30,$f16\njsr $26,floor\nldgp $gp,0($26)\ncvttqc $f0,$f1\ncvtql $f1,$f1\nsts $f1,-56+256($sp)\nldl $27,-56+256($sp)\nstl $27,M\nstl $31,Break\nL.463:\nldt $f30,Z\nstt $f30,X\nlda $27,1\nstl $27,I\njsr $26,SR3980\nldgp $gp,0($26)\nldt $f30,Z\nldt $f29,AInvrse\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.466\nlda $27,1\nstl $27,Break\nbr L.467\nL.466:\nldt $f30,AInvrse\nstt $f30,Z\nL.467:\nL.464:\nldl $27,Break\ncmpeq $27,$31,$23\nbne $23,L.463\nlda $27,100\nstl $27,Milestone\nldl $27,NoTrials\nstl $27,M\nldt $f30,Three\nstt $f30,Z\nL.468:\nldt $f30,Z\nstt $f30,X\nlda $27,1\nstl $27,I\njsr $26,SR3980\nldgp $gp,0($26)\nL.471:\nldt $f30,Z\nldt $f29,Two\naddt $f30,$f29,$f30\nstt $f30,Z\nL.472:\nldt $f30,Three\nstt $f30,-168+256($sp)\nldt $f29,Z\ndivt $f29,$f30,$f16\njsr $26,floor\nldgp $gp,0($26)\nldt $f29,-168+256($sp)\nmult $f29,$f0,$f30\nldt $f29,Z\ncmpteq $f30,$f29,$f1\nfbne $f1,L.471\nL.469:\nldt $f30,Z\nldt $f29,Eight\nldt $f28,Three\nmult $f29,$f28,$f29\ncmptlt $f30,$f29,$f1\nfbne $f1,L.468\nldl $27,N\ncmple $27,$31,$23\nbne $23,L.474\nlda $16,L.476\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.477\njsr $26,printf\nldgp $gp,0($26)\nL.474:\njsr $26,PrintIfNPositive\nldgp $gp,0($26)\nldl $27,N\nldl $25,N1\naddl $27,$25,$27\nstl $27,N\nldl $27,N\ncmpeq $27,$31,$23\nbeq $23,L.478\nlda $16,L.480\njsr $26,printf\nldgp $gp,0($26)\nL.478:\nldl $27,N\ncmple $27,$31,$23\nbne $23,L.481\njsr $26,Pause\nldgp $gp,0($26)\nbr L.482\nL.481:\nlda $16,L.45\njsr $26,printf\nldgp $gp,0($26)\nL.482:\nlda $27,110\nstl $27,Milestone\nlda $16,L.483\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,U1\nstt $f30,D\nldt $f30,Precision\nstt $f30,-168+256($sp)\nfmov $f30,$f16\njsr $26,floor\nldgp $gp,0($26)\nldt $f29,-168+256($sp)\ncmpteq $f29,$f0,$f1\nfbne $f1,L.484\nldt $f30,BInvrse\nstt $f30,D\nldt $f30,Precision\nstt $f30,X\nL.486:\nldt $f30,D\nldt $f29,BInvrse\nmult $f30,$f29,$f30\nstt $f30,D\nldt $f30,X\nldt $f29,One\nsubt $f30,$f29,$f30\nstt $f30,X\nL.487:\nldt $f30,X\nldt $f29,Zero\ncmptle $f30,$f29,$f1\nfbeq $f1,L.486\nL.484:\nldt $f30,One\nstt $f30,Y\nldt $f30,D\nstt $f30,Z\nL.489:\nldt $f30,Y\nstt $f30,C\nldt $f30,Z\nstt $f30,Y\nldt $f30,Y\nmult $f30,$f30,$f30\nstt $f30,Z\nL.490:\nldt $f30,Z\nldt $f29,Y\ncmptle $f29,$f30,$f1\nfbne $f1,L.492\naddt $f30,$f30,$f29\ncmptle $f29,$f30,$f1\nfbeq $f1,L.489\nL.492:\nldt $f30,C\nstt $f30,Y\nldt $f30,Y\nldt $f29,D\nmult $f30,$f29,$f30\nstt $f30,Z\nL.493:\nldt $f30,Y\nstt $f30,C\nldt $f30,Z\nstt $f30,Y\nldt $f30,Y\nldt $f29,D\nmult $f30,$f29,$f30\nstt $f30,Z\nL.494:\nldt $f30,Z\nldt $f29,Y\ncmptle $f29,$f30,$f1\nfbne $f1,L.496\naddt $f30,$f30,$f29\ncmptle $f29,$f30,$f1\nfbeq $f1,L.493\nL.496:\nldt $f30,Radix\nldt $f29,Two\ncmptlt $f30,$f29,$f1\nfbeq $f1,L.497\nldt $f30,Two\nstt $f30,HInvrse\nbr L.498\nL.497:\nldt $f30,Radix\nstt $f30,HInvrse\nL.498:\nldt $f30,One\nldt $f29,HInvrse\ndivt $f30,$f29,$f29\nstt $f29,H\nldt $f29,C\ndivt $f30,$f29,$f30\nstt $f30,CInvrse\nstt $f29,E0\nldt $f30,E0\nldt $f29,H\nmult $f30,$f29,$f30\nstt $f30,Z\nL.499:\nldt $f30,E0\nstt $f30,Y\nldt $f30,Z\nstt $f30,E0\nldt $f30,E0\nldt $f29,H\nmult $f30,$f29,$f30\nstt $f30,Z\nL.500:\nldt $f30,Z\nldt $f29,E0\ncmptle $f29,$f30,$f1\nfbne $f1,L.502\naddt $f30,$f30,$f29\ncmptle $f29,$f30,$f1\nfbeq $f1,L.499\nL.502:\nldt $f30,E0\nstt $f30,UfThold\nldt $f30,Zero\nstt $f30,E1\nstt $f30,Q\nldt $f30,U2\nstt $f30,E9\nldt $f30,One\nldt $f29,E9\naddt $f30,$f29,$f30\nstt $f30,S\nldt $f30,C\nldt $f29,S\nmult $f30,$f29,$f29\nstt $f29,D\nldt $f29,D\ncmptle $f29,$f30,$f1\nfbeq $f1,L.503\nldt $f30,Radix\nldt $f29,U2\nmult $f30,$f29,$f30\nstt $f30,E9\nldt $f30,One\nldt $f29,E9\naddt $f30,$f29,$f30\nstt $f30,S\nldt $f30,C\nldt $f29,S\nmult $f30,$f29,$f29\nstt $f29,D\nldt $f29,D\ncmptle $f29,$f30,$f1\nfbeq $f1,L.504\nmov $31,$16\nlda $17,L.507\njsr $26,BadCond\nldgp $gp,0($26)\nldt $f30,E0\nstt $f30,Underflow\nldt $f30,Zero\nstt $f30,Y1\nldt $f30,Z\nstt $f30,PseudoZero\njsr $26,Pause\nldgp $gp,0($26)\nbr L.504\nL.503:\nldt $f30,D\nstt $f30,Underflow\nldt $f30,Underflow\nldt $f29,H\nmult $f30,$f29,$f30\nstt $f30,PseudoZero\nldt $f30,Zero\nstt $f30,UfThold\nL.508:\nldt $f30,Underflow\nstt $f30,Y1\nldt $f30,PseudoZero\nstt $f30,Underflow\nldt $f30,E1\naddt $f30,$f30,$f29\ncmptle $f29,$f30,$f1\nfbeq $f1,L.511\nldt $f30,Underflow\nldt $f29,HInvrse\nmult $f30,$f29,$f30\nstt $f30,Y2\nldt $f30,Y1\nldt $f29,Y2\nsubt $f30,$f29,$f16\njsr $26,fabs\nldgp $gp,0($26)\nstt $f0,E1\nldt $f30,Y1\nstt $f30,Q\nldt $f30,UfThold\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.513\nldt $f30,Y1\nldt $f29,Y2\ncmpteq $f30,$f29,$f1\nfbne $f1,L.513\nldt $f30,Y1\nstt $f30,UfThold\nL.513:\nL.511:\nldt $f30,PseudoZero\nldt $f29,H\nmult $f30,$f29,$f30\nstt $f30,PseudoZero\nL.509:\nldt $f30,PseudoZero\nldt $f29,Underflow\ncmptle $f29,$f30,$f1\nfbne $f1,L.515\naddt $f30,$f30,$f29\ncmptle $f29,$f30,$f1\nfbeq $f1,L.508\nL.515:\nL.504:\nldt $f30,PseudoZero\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbne $f1,L.516\nlda $16,L.45\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,PseudoZero\nstt $f30,Z\nldt $f29,Zero\ncmptle $f30,$f29,$f1\nfbeq $f1,L.518\nmov $31,$16\nlda $17,L.520\njsr $26,BadCond\nldgp $gp,0($26)\nlda $16,L.521\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.522\nldt $f17,PseudoZero\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,PseudoZero\nnegt $f30,$f30\nstt $f30,X\nldt $f30,X\nldt $f29,Zero\ncmptle $f30,$f29,$f1\nfbeq $f1,L.519\nlda $16,L.525\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.526\nldt $f17,X\njsr $26,printf\nldgp $gp,0($26)\nbr L.519\nL.518:\nlda $16,3\nlda $17,L.527\njsr $26,BadCond\nldgp $gp,0($26)\nlda $16,L.528\nldt $f17,PseudoZero\njsr $26,printf\nldgp $gp,0($26)\nL.519:\njsr $26,TstPtUf\nldgp $gp,0($26)\nL.516:\nlda $27,120\nstl $27,Milestone\nldt $f30,CInvrse\nldt $f29,Y\nmult $f30,$f29,$f29\nldt $f28,Y1\nmult $f30,$f28,$f30\ncmptle $f29,$f30,$f1\nfbne $f1,L.529\nldt $f30,H\nldt $f29,S\nmult $f30,$f29,$f30\nstt $f30,S\nldt $f30,Underflow\nstt $f30,E0\nL.529:\nldt $f30,E1\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbne $f1,L.531\nldt $f29,E0\ncmpteq $f30,$f29,$f1\nfbne $f1,L.531\nlda $16,2\nlda $17,L.158\njsr $26,BadCond\nldgp $gp,0($26)\nldt $f30,E1\nldt $f29,E0\ncmptlt $f30,$f29,$f1\nfbeq $f1,L.533\nlda $16,L.535\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.536\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,PseudoZero\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.534\nldt $f30,E1\nstt $f30,E0\nbr L.534\nL.533:\nlda $16,L.539\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.540\njsr $26,printf\nldgp $gp,0($26)\nL.534:\nL.531:\nlda $16,L.541\nldt $f17,E0\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,E0\nstt $f30,Z\njsr $26,TstPtUf\nldgp $gp,0($26)\nldt $f30,E0\nstt $f30,Underflow\nldl $27,N\ncmpeq $27,1,$23\nbeq $23,L.542\nldt $f30,Y\nstt $f30,Underflow\nL.542:\nlda $27,4\nstl $27,I\nldt $f30,E1\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.544\nlda $27,3\nstl $27,I\nL.544:\nldt $f30,UfThold\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.546\nldl $27,I\nsubl $27,2,$27\nstl $27,I\nL.546:\nlda $27,1\nstl $27,UfNGrad\nldl $27,I\ncmplt $27,1,$23\nbne $23,L.548\ncmple $27,4,$23\nbeq $23,L.548\nsubl $27,1,$27\nsll $27,3,$27\nldq $27,L.571($27)\njmp ($27)\n.rdata\n.align 3\nL.571:\n.quad L.550\n.quad L.557\n.quad L.562\n.quad L.563\n.text\nL.550:\nldt $f30,Underflow\nstt $f30,UfThold\nldt $f30,CInvrse\nldt $f29,Q\nmult $f30,$f29,$f29\nldt $f28,Y\nmult $f30,$f28,$f30\nldt $f28,S\nmult $f30,$f28,$f30\ncmpteq $f29,$f30,$f1\nfbne $f1,L.551\nldt $f30,Y\nstt $f30,UfThold\nmov $31,$16\nlda $17,L.553\njsr $26,BadCond\nldgp $gp,0($26)\nlda $16,L.554\nldt $f17,UfThold\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.555\nldt $f17,C\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.556\njsr $26,printf\nldgp $gp,0($26)\nL.551:\njsr $26,Pause\nldgp $gp,0($26)\nbr L.549\nL.557:\nmov $31,$16\nlda $17,L.558\njsr $26,BadCond\nldgp $gp,0($26)\nlda $16,L.559\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.560\nldt $f17,Q\nldt $f18,Y2\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,Q\nldt $f29,Y2\nsubt $f30,$f29,$f16\njsr $26,fabs\nldgp $gp,0($26)\nfmov $f0,$f30\nlda $16,L.561\nfmov $f30,$f17\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,Q\nstt $f30,UfThold\nbr L.549\nL.562:\nldt $f30,X\nstt $f30,X\nbr L.549\nL.563:\nldt $f30,UfThold\nldt $f29,Q\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.564\nldt $f29,E1\nldt $f28,E0\ncmpteq $f29,$f28,$f1\nfbeq $f1,L.564\nldt $f28,E9\ndivt $f29,$f28,$f29\nsubt $f30,$f29,$f16\njsr $26,fabs\nldgp $gp,0($26)\nldt $f29,E1\ncmptle $f0,$f29,$f1\nfbeq $f1,L.564\nstl $31,UfNGrad\nlda $16,L.566\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.567\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,E0\nldt $f29,CInvrse\nmult $f30,$f29,$f28\nstt $f28,Y\nldt $f28,U2\nldt $f27,Y\nldt $f26,OneAndHalf\naddt $f26,$f28,$f26\nmult $f27,$f26,$f27\nstt $f27,Y\nldt $f27,One\naddt $f27,$f28,$f28\nmult $f29,$f28,$f29\nstt $f29,X\nldt $f29,Y\nldt $f28,X\ndivt $f29,$f28,$f29\nstt $f29,Y\nldt $f29,Y\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.569\nlda $27,1\nstl $27,-172+256($sp)\nbr L.570\nL.569:\nstl $31,-172+256($sp)\nL.570:\nldl $27,-172+256($sp)\nstl $27,IEEE\nL.564:\nL.548:\nL.549:\nldl $27,UfNGrad\ncmpeq $27,$31,$23\nbne $23,L.572\nlda $16,L.45\njsr $26,printf\nldgp $gp,0($26)\nlda $27,sigfpe\nstq $27,sigsave\nlda $16,ovfl_buf\njsr $26,setjmp\nldgp $gp,0($26)\ncmpeq $0,$31,$23\nbne $23,L.574\nlda $16,L.576\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,H\naddt $f30,$f30,$f30\nstt $f30,R\nbr L.575\nL.574:\nldt $f30,Underflow\nldt $f29,UfThold\ndivt $f30,$f29,$f16\njsr $26,sqrt\nldgp $gp,0($26)\nstt $f0,R\nL.575:\nstq $31,sigsave\nldt $f30,R\nldt $f29,H\ncmptle $f30,$f29,$f1\nfbeq $f1,L.577\nldt $f30,R\nldt $f29,UfThold\nmult $f30,$f29,$f29\nstt $f29,Z\nldt $f29,One\nldt $f28,H\nldt $f27,Z\nmult $f30,$f28,$f30\naddt $f29,$f28,$f28\nmult $f30,$f28,$f30\naddt $f29,$f30,$f30\nmult $f27,$f30,$f30\nstt $f30,X\nbr L.578\nL.577:\nldt $f30,UfThold\nstt $f30,Z\nldt $f30,One\nldt $f29,H\nldt $f28,Z\nmult $f29,$f29,$f27\naddt $f30,$f29,$f29\nmult $f27,$f29,$f29\naddt $f30,$f29,$f30\nmult $f28,$f30,$f30\nstt $f30,X\nL.578:\nldt $f30,X\nldt $f29,Z\ncmpteq $f30,$f29,$f1\nfbne $f1,L.579\nsubt $f30,$f29,$f30\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.579\nlda $16,3\nlda $17,L.158\njsr $26,BadCond\nldgp $gp,0($26)\nlda $16,L.581\nldt $f17,X\nldt $f18,Z\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,X\nldt $f29,Z\nsubt $f30,$f29,$f30\nstt $f30,Z9\nlda $16,L.582\nldt $f17,Z9\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.583\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.584\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.585\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.586\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.587\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.588\njsr $26,printf\nldgp $gp,0($26)\nlda $27,sigfpe\nstq $27,sigsave\nlda $16,ovfl_buf\njsr $26,setjmp\nldgp $gp,0($26)\ncmpeq $0,$31,$23\nbne $23,L.589\nlda $16,L.591\njsr $26,printf\nldgp $gp,0($26)\nbr L.590\nL.589:\nlda $16,L.592\nldt $f30,Half\nldt $f29,X\nldt $f28,Z\ndivt $f29,$f28,$f29\nsubt $f29,$f30,$f29\nsubt $f29,$f30,$f17\njsr $26,printf\nldgp $gp,0($26)\nL.590:\nstq $31,sigsave\nL.579:\nL.572:\nlda $16,L.593\nldt $f17,UfThold\nlda $18,L.594\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.595\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.596\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,U1\nmult $f30,$f30,$f29\nstt $f29,Y2\nldt $f29,Y2\nmult $f29,$f29,$f29\nstt $f29,Y\nldt $f29,Y\nmult $f29,$f30,$f30\nstt $f30,Y2\nldt $f30,Y2\nldt $f29,UfThold\ncmptle $f30,$f29,$f1\nfbeq $f1,L.597\nldt $f30,Y\nldt $f29,E0\ncmptle $f30,$f29,$f1\nfbne $f1,L.599\nlda $16,2\nlda $17,L.158\njsr $26,BadCond\nldgp $gp,0($26)\nlda $27,5\nstl $27,I\nbr L.600\nL.599:\nlda $16,1\nlda $17,L.158\njsr $26,BadCond\nldgp $gp,0($26)\nlda $27,4\nstl $27,I\nL.600:\nlda $16,L.601\nldl $17,I\njsr $26,printf\nldgp $gp,0($26)\nL.597:\nlda $27,130\nstl $27,Milestone\nldt $f16,UfThold\njsr $26,log\nldgp $gp,0($26)\nfmov $f0,$f30\nstt $f30,-176+256($sp)\nldt $f16,HInvrse\njsr $26,log\nldgp $gp,0($26)\nldt $f29,Half\nldt $f28,TwoForty\nldt $f27,-176+256($sp)\nmult $f28,$f27,$f28\ndivt $f28,$f0,$f30\nsubt $f29,$f30,$f16\njsr $26,floor\nldgp $gp,0($26)\nnegt $f0,$f30\nldt $f29,TwoForty\ndivt $f30,$f29,$f30\nstt $f30,Y\nldt $f30,Y\naddt $f30,$f30,$f30\nstt $f30,Y2\nlda $16,L.602\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.603\nldt $f17,HInvrse\nldt $f18,Y\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.604\nldt $f17,HInvrse\nldt $f18,Y\njsr $26,printf\nldgp $gp,0($26)\nldt $f16,HInvrse\nldt $f17,Y2\njsr $26,pow\nldgp $gp,0($26)\nstt $f0,V9\nlda $16,L.605\nldt $f17,V9\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,V9\nldt $f29,Zero\ncmptlt $f30,$f29,$f1\nfbne $f1,L.608\nldt $f29,Radix\naddt $f29,$f29,$f29\nldt $f28,E9\naddt $f29,$f28,$f29\nldt $f28,UfThold\nmult $f29,$f28,$f29\ncmptle $f30,$f29,$f1\nfbne $f1,L.606\nL.608:\nlda $16,1\nlda $17,L.609\njsr $26,BadCond\nldgp $gp,0($26)\nlda $16,L.610\nldt $f17,UfThold\njsr $26,printf\nldgp $gp,0($26)\nbr L.607\nL.606:\nldt $f30,V9\nldt $f29,UfThold\nldt $f28,One\nldt $f27,E9\naddt $f28,$f27,$f28\nmult $f29,$f28,$f29\ncmptle $f30,$f29,$f1\nfbeq $f1,L.611\nlda $16,L.613\njsr $26,printf\nldgp $gp,0($26)\nbr L.612\nL.611:\nlda $16,2\nlda $17,L.609\njsr $26,BadCond\nldgp $gp,0($26)\nlda $16,L.610\nldt $f17,UfThold\njsr $26,printf\nldgp $gp,0($26)\nL.612:\nL.607:\nlda $27,140\nstl $27,Milestone\nlda $16,L.45\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,Zero\nstt $f30,X\nlda $27,2\nstl $27,I\nldt $f29,Two\nldt $f28,Three\nmult $f29,$f28,$f29\nstt $f29,Y\nstt $f30,Q\nstl $31,N\nL.614:\nldt $f30,X\nstt $f30,Z\nldl $27,I\nlda $27,1($27)\nstl $27,I\nldl $27,I\nldt $f30,Y\naddl $27,$27,$27\nstq $27,-56+256($sp)\nldt $f29,-56+256($sp)\ncvtqt $f29,$f29\ndivt $f30,$f29,$f30\nstt $f30,Y\nldt $f30,Y\nldt $f29,Q\naddt $f30,$f29,$f30\nstt $f30,R\nldt $f30,Z\nldt $f29,R\naddt $f30,$f29,$f28\nstt $f28,X\nldt $f28,X\nsubt $f30,$f28,$f30\naddt $f30,$f29,$f30\nstt $f30,Q\nL.615:\nldt $f30,X\nldt $f29,Z\ncmptle $f30,$f29,$f1\nfbeq $f1,L.614\nldt $f30,OneAndHalf\nldt $f29,One\nldt $f28,Eight\ndivt $f29,$f28,$f29\naddt $f30,$f29,$f29\nldt $f28,X\nldt $f27,ThirtyTwo\nmult $f30,$f27,$f30\ndivt $f28,$f30,$f30\naddt $f29,$f30,$f30\nstt $f30,Z\nldt $f30,Z\nmult $f30,$f30,$f30\nstt $f30,X\nldt $f30,X\nmult $f30,$f30,$f30\nstt $f30,Exp2\nldt $f30,F9\nstt $f30,X\nldt $f30,X\nldt $f29,U1\nsubt $f30,$f29,$f30\nstt $f30,Y\nlda $16,L.617\nldt $f17,Exp2\njsr $26,printf\nldgp $gp,0($26)\nlda $27,1\nstl $27,I\nL.618:\nldt $f30,X\nldt $f29,BInvrse\nsubt $f30,$f29,$f28\nstt $f28,Z\nldt $f28,One\naddt $f30,$f28,$f27\nldt $f26,Z\nsubt $f28,$f29,$f29\nsubt $f26,$f29,$f29\ndivt $f27,$f29,$f29\nstt $f29,Z\nfmov $f30,$f16\nldt $f17,Z\njsr $26,pow\nldgp $gp,0($26)\nldt $f29,Exp2\nsubt $f0,$f29,$f30\nstt $f30,Q\nldt $f16,Q\njsr $26,fabs\nldgp $gp,0($26)\nldt $f29,TwoForty\nldt $f28,U2\nmult $f29,$f28,$f29\ncmptle $f0,$f29,$f1\nfbne $f1,L.622\nlda $27,1\nstl $27,N\nldt $f30,BInvrse\nldt $f29,X\nsubt $f29,$f30,$f29\nldt $f28,One\nsubt $f28,$f30,$f30\nsubt $f29,$f30,$f30\nstt $f30,V9\nlda $16,2\nlda $17,L.624\njsr $26,BadCond\nldgp $gp,0($26)\nldt $f16,X\nldt $f17,Z\njsr $26,pow\nldgp $gp,0($26)\nfmov $f0,$f30\nlda $16,L.625\nfmov $f30,$f17\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.626\nldt $f17,V9\nldt $f18,Z\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.627\nldt $f17,Q\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.628\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.629\njsr $26,printf\nldgp $gp,0($26)\nbr L.620\nL.622:\nldt $f30,Y\nldt $f29,X\nsubt $f30,$f29,$f29\nldt $f28,Two\nmult $f29,$f28,$f29\naddt $f29,$f30,$f29\nstt $f29,Z\nstt $f30,X\nldt $f30,Z\nstt $f30,Y\nldt $f30,X\nldt $f29,F9\nsubt $f30,$f29,$f30\nldt $f29,One\nmult $f30,$f30,$f30\naddt $f29,$f30,$f30\nstt $f30,Z\nldt $f30,Z\nldt $f29,One\ncmptle $f30,$f29,$f1\nfbne $f1,L.630\nldl $27,I\nldl $25,NoTrials\ncmplt $27,$25,$23\nbeq $23,L.630\nldl $27,I\nlda $27,1($27)\nstl $27,I\nbr L.618\nL.630:\nldt $f30,X\nldt $f29,One\ncmptle $f30,$f29,$f1\nfbne $f1,L.632\nldl $27,N\ncmpeq $27,$31,$23\nbeq $23,L.620\nlda $16,L.636\njsr $26,printf\nldgp $gp,0($26)\nbr L.620\nL.632:\nldt $f30,U2\nldt $f29,One\naddt $f29,$f30,$f29\nstt $f29,X\naddt $f30,$f30,$f30\nstt $f30,Y\nldt $f30,Y\nldt $f29,X\naddt $f30,$f29,$f30\nstt $f30,Y\nlda $27,1\nstl $27,I\nbr L.618\nL.620:\nlda $27,150\nstl $27,Milestone\nlda $16,L.637\njsr $26,printf\nldgp $gp,0($26)\nstl $31,N\nldt $f30,A1\nstt $f30,Z\nldt $f16,C\njsr $26,log\nldgp $gp,0($26)\nfmov $f0,$f30\nstt $f30,-184+256($sp)\nldt $f16,A1\njsr $26,log\nldgp $gp,0($26)\nldt $f29,Half\nldt $f28,-184+256($sp)\ndivt $f28,$f0,$f30\nsubt $f29,$f30,$f16\njsr $26,floor\nldgp $gp,0($26)\nstt $f0,Q\nstl $31,Break\nL.638:\nldt $f30,CInvrse\nstt $f30,X\nldt $f16,Z\nldt $f17,Q\njsr $26,pow\nldgp $gp,0($26)\nstt $f0,Y\njsr $26,IsYeqX\nldgp $gp,0($26)\nldt $f30,Q\nnegt $f30,$f30\nstt $f30,Q\nldt $f30,C\nstt $f30,X\nldt $f16,Z\nldt $f17,Q\njsr $26,pow\nldgp $gp,0($26)\nstt $f0,Y\njsr $26,IsYeqX\nldgp $gp,0($26)\nldt $f30,Z\nldt $f29,One\ncmptlt $f30,$f29,$f1\nfbeq $f1,L.641\nlda $27,1\nstl $27,Break\nbr L.642\nL.641:\nldt $f30,AInvrse\nstt $f30,Z\nL.642:\nL.639:\nldl $27,Break\ncmpeq $27,$31,$23\nbne $23,L.638\njsr $26,PrintIfNPositive\nldgp $gp,0($26)\nldl $27,N\ncmpeq $27,$31,$23\nbeq $23,L.643\nlda $16,L.645\njsr $26,printf\nldgp $gp,0($26)\nL.643:\nlda $16,L.45\njsr $26,printf\nldgp $gp,0($26)\nlda $27,160\nstl $27,Milestone\njsr $26,Pause\nldgp $gp,0($26)\nlda $16,L.646\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.647\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,CInvrse\nnegt $f30,$f30\nstt $f30,Y\nldt $f30,HInvrse\nldt $f29,Y\nmult $f30,$f29,$f30\nstt $f30,V9\nlda $27,sigfpe\nstq $27,sigsave\nlda $16,ovfl_buf\njsr $26,setjmp\nldgp $gp,0($26)\ncmpeq $0,$31,$23\nbne $23,L.648\nstl $31,I\nldt $f30,Y\nstt $f30,V9\nbr L.650\nL.648:\nL.651:\nldt $f30,Y\nstt $f30,V\nldt $f30,V9\nstt $f30,Y\nldt $f30,HInvrse\nldt $f29,Y\nmult $f30,$f29,$f30\nstt $f30,V9\nL.652:\nldt $f30,V9\nldt $f29,Y\ncmptlt $f30,$f29,$f1\nfbne $f1,L.651\nlda $27,1\nstl $27,I\nL.650:\nstq $31,sigsave\nldt $f30,V9\nstt $f30,Z\nlda $16,L.654\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.655\nldt $f17,Y\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,Y\nnegt $f30,$f29\nstt $f29,V9\nldt $f29,V9\nstt $f29,V0\nldt $f29,V\nsubt $f29,$f30,$f30\nldt $f28,V0\naddt $f29,$f28,$f29\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.656\nlda $16,L.658\njsr $26,printf\nldgp $gp,0($26)\nbr L.657\nL.656:\nlda $16,L.659\njsr $26,printf\nldgp $gp,0($26)\nlda $16,3\nlda $17,L.660\njsr $26,BadCond\nldgp $gp,0($26)\nL.657:\nldt $f30,Z\nldt $f29,Y\ncmpteq $f30,$f29,$f1\nfbne $f1,L.661\nlda $16,1\nlda $17,L.158\njsr $26,BadCond\nldgp $gp,0($26)\nlda $16,L.663\nldt $f17,Y\nldt $f18,Z\njsr $26,printf\nldgp $gp,0($26)\nL.661:\nldl $27,I\ncmpeq $27,$31,$23\nbne $23,L.664\nldt $f30,V\nldt $f29,HInvrse\nldt $f28,U2\nmult $f29,$f28,$f27\nsubt $f27,$f29,$f27\nmult $f30,$f27,$f27\nstt $f27,Y\nldt $f27,Y\nldt $f26,One\nsubt $f26,$f29,$f29\nmult $f29,$f28,$f29\nmult $f29,$f30,$f30\naddt $f27,$f30,$f30\nstt $f30,Z\nldt $f30,Z\nldt $f29,V0\ncmptlt $f30,$f29,$f1\nfbeq $f1,L.666\nldt $f30,Z\nstt $f30,Y\nL.666:\nldt $f30,Y\nldt $f29,V0\ncmptlt $f30,$f29,$f1\nfbeq $f1,L.668\nldt $f30,Y\nstt $f30,V\nL.668:\nldt $f30,V0\nldt $f29,V\nsubt $f30,$f29,$f29\ncmptlt $f29,$f30,$f1\nfbeq $f1,L.665\nldt $f30,V0\nstt $f30,V\nbr L.665\nL.664:\nldt $f30,Y\nldt $f29,HInvrse\nldt $f28,U2\nmult $f29,$f28,$f27\nsubt $f27,$f29,$f27\nmult $f30,$f27,$f27\nstt $f27,V\nldt $f27,V\nldt $f26,One\nsubt $f26,$f29,$f29\nmult $f29,$f28,$f29\nmult $f29,$f30,$f30\naddt $f27,$f30,$f30\nstt $f30,V\nL.665:\nlda $16,L.672\nldt $f17,V\njsr $26,printf\nldgp $gp,0($26)\nldl $27,I\ncmpeq $27,$31,$23\nbne $23,L.673\nlda $16,L.675\nldt $f17,V0\njsr $26,printf\nldgp $gp,0($26)\nbr L.674\nL.673:\nlda $16,L.676\njsr $26,printf\nldgp $gp,0($26)\nL.674:\nldt $f30,V\nldt $f29,One\nmult $f30,$f29,$f30\nstt $f30,V9\nlda $16,L.677\nldt $f17,V9\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,V\nldt $f29,One\ndivt $f30,$f29,$f30\nstt $f30,V9\nlda $16,L.678\nldt $f17,V9\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.679\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.680\njsr $26,printf\nldgp $gp,0($26)\nlda $27,170\nstl $27,Milestone\nldt $f30,V\nnegt $f30,$f29\ncmptlt $f29,$f30,$f1\nfbeq $f1,L.685\nldt $f29,V0\nnegt $f29,$f28\ncmptlt $f28,$f29,$f1\nfbeq $f1,L.685\nldt $f29,UfThold\nnegt $f29,$f28\ncmptlt $f28,$f30,$f1\nfbeq $f1,L.685\ncmptlt $f29,$f30,$f1\nfbne $f1,L.681\nL.685:\nmov $31,$16\nlda $17,L.686\njsr $26,BadCond\nldgp $gp,0($26)\nlda $16,L.687\nldt $f17,V\nldt $f18,V0\nldt $f19,UfThold\njsr $26,printf\nldgp $gp,0($26)\nL.681:\nlda $27,175\nstl $27,Milestone\nlda $16,L.45\njsr $26,printf\nldgp $gp,0($26)\nlda $27,1\nstl $27,Indx\nL.688:\nldl $27,Indx\ncmpeq $27,1,$23\nbne $23,L.694\ncmpeq $27,2,$23\nbne $23,L.695\ncmpeq $27,3,$23\nbne $23,L.696\nbr L.692\nL.694:\nldt $f30,UfThold\nstt $f30,Z\nbr L.693\nL.695:\nldt $f30,E0\nstt $f30,Z\nbr L.693\nL.696:\nldt $f30,PseudoZero\nstt $f30,Z\nL.692:\nL.693:\nldt $f30,Z\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbne $f1,L.697\nldt $f16,Z\njsr $26,sqrt\nldgp $gp,0($26)\nstt $f0,V9\nldt $f30,V9\nmult $f30,$f30,$f30\nstt $f30,Y\nldt $f30,Y\nldt $f29,One\nldt $f28,Radix\nldt $f27,E9\nmult $f28,$f27,$f28\nldt $f27,Z\nsubt $f29,$f28,$f26\ndivt $f30,$f26,$f26\ncmptlt $f26,$f27,$f1\nfbne $f1,L.701\naddt $f29,$f28,$f29\nmult $f29,$f27,$f29\ncmptle $f30,$f29,$f1\nfbne $f1,L.699\nL.701:\nldt $f30,V9\nldt $f29,U1\ncmptle $f30,$f29,$f1\nfbne $f1,L.702\nlda $16,1\nlda $17,L.158\njsr $26,BadCond\nldgp $gp,0($26)\nbr L.703\nL.702:\nlda $16,2\nlda $17,L.158\njsr $26,BadCond\nldgp $gp,0($26)\nL.703:\nlda $16,L.704\nldt $f17,Z\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.705\nldt $f17,Y\njsr $26,printf\nldgp $gp,0($26)\nL.699:\nL.697:\nL.689:\nldl $27,Indx\nlda $27,1($27)\nstl $27,Indx\nldl $27,Indx\ncmple $27,3,$23\nbne $23,L.688\nlda $27,180\nstl $27,Milestone\nlda $27,1\nstl $27,Indx\nL.706:\nldl $27,Indx\ncmpeq $27,1,$23\nbeq $23,L.710\nldt $f30,V\nstt $f30,Z\nbr L.711\nL.710:\nldt $f30,V0\nstt $f30,Z\nL.711:\nldt $f16,Z\njsr $26,sqrt\nldgp $gp,0($26)\nstt $f0,V9\nldt $f30,V9\nldt $f29,One\nldt $f28,Radix\nldt $f27,E9\nmult $f28,$f27,$f28\nsubt $f29,$f28,$f29\nmult $f29,$f30,$f29\nstt $f29,X\nldt $f29,X\nmult $f30,$f29,$f30\nstt $f30,V9\nldt $f30,V9\nldt $f29,Z\nldt $f28,One\nldt $f27,Two\nldt $f26,Radix\nmult $f27,$f26,$f27\nldt $f26,E9\nmult $f27,$f26,$f27\nsubt $f28,$f27,$f28\nmult $f28,$f29,$f28\ncmptlt $f30,$f28,$f1\nfbne $f1,L.714\ncmptle $f30,$f29,$f1\nfbne $f1,L.712\nL.714:\nldt $f30,V9\nstt $f30,Y\nldt $f30,X\nldt $f29,W\ncmptlt $f30,$f29,$f1\nfbeq $f1,L.715\nlda $16,1\nlda $17,L.158\njsr $26,BadCond\nldgp $gp,0($26)\nbr L.716\nL.715:\nlda $16,2\nlda $17,L.158\njsr $26,BadCond\nldgp $gp,0($26)\nL.716:\nlda $16,L.717\nldt $f17,Z\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.718\nldt $f17,Y\njsr $26,printf\nldgp $gp,0($26)\nL.712:\nL.707:\nldl $27,Indx\nlda $27,1($27)\nstl $27,Indx\nldl $27,Indx\ncmple $27,2,$23\nbne $23,L.706\nlda $27,190\nstl $27,Milestone\njsr $26,Pause\nldgp $gp,0($26)\nldt $f30,UfThold\nldt $f29,V\nmult $f30,$f29,$f30\nstt $f30,X\nldt $f30,Radix\nmult $f30,$f30,$f30\nstt $f30,Y\nldt $f30,X\nldt $f29,Y\nmult $f30,$f29,$f28\nldt $f27,One\ncmptlt $f28,$f27,$f1\nfbne $f1,L.721\ncmptle $f30,$f29,$f1\nfbne $f1,L.719\nL.721:\nldt $f30,X\nldt $f29,Y\nldt $f28,U1\nmult $f30,$f29,$f27\ncmptlt $f27,$f28,$f1\nfbne $f1,L.724\ndivt $f29,$f28,$f29\ncmptle $f30,$f29,$f1\nfbne $f1,L.722\nL.724:\nlda $16,2\nlda $17,L.725\njsr $26,BadCond\nldgp $gp,0($26)\nbr L.723\nL.722:\nlda $16,3\nlda $17,L.158\njsr $26,BadCond\nldgp $gp,0($26)\nL.723:\nlda $16,L.726\nldt $f17,X\nlda $18,L.727\njsr $26,printf\nldgp $gp,0($26)\nL.719:\nlda $27,200\nstl $27,Milestone\nlda $27,1\nstl $27,Indx\nL.728:\nldt $f30,F9\nstt $f30,X\nldl $27,Indx\ncmplt $27,2,$23\nbne $23,L.732\ncmple $27,5,$23\nbeq $23,L.732\nsubl $27,2,$27\nsll $27,3,$27\nldq $27,L.738($27)\njmp ($27)\n.rdata\n.align 3\nL.738:\n.quad L.734\n.quad L.735\n.quad L.736\n.quad L.737\n.text\nL.734:\nldt $f30,One\nldt $f29,U2\naddt $f30,$f29,$f30\nstt $f30,X\nbr L.733\nL.735:\nldt $f30,V\nstt $f30,X\nbr L.733\nL.736:\nldt $f30,UfThold\nstt $f30,X\nbr L.733\nL.737:\nldt $f30,Radix\nstt $f30,X\nL.732:\nL.733:\nldt $f30,X\nstt $f30,Y\nlda $27,sigfpe\nstq $27,sigsave\nlda $16,ovfl_buf\njsr $26,setjmp\nldgp $gp,0($26)\ncmpeq $0,$31,$23\nbne $23,L.739\nlda $16,L.741\nldt $f17,X\njsr $26,printf\nldgp $gp,0($26)\nbr L.740\nL.739:\nldt $f30,Half\nldt $f29,Y\nldt $f28,X\ndivt $f29,$f28,$f29\nsubt $f29,$f30,$f29\nsubt $f29,$f30,$f30\nstt $f30,V9\nldt $f30,V9\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.742\nbr L.729\nL.742:\nldt $f30,V9\nldt $f29,U1\nnegt $f29,$f29\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.744\nldl $27,Indx\ncmplt $27,5,$23\nbeq $23,L.744\nlda $16,3\nlda $17,L.158\njsr $26,BadCond\nldgp $gp,0($26)\nbr L.745\nL.744:\nlda $16,1\nlda $17,L.158\njsr $26,BadCond\nldgp $gp,0($26)\nL.745:\nlda $16,L.746\nldt $f17,X\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.747\nldt $f17,V9\njsr $26,printf\nldgp $gp,0($26)\nL.740:\nstq $31,sigsave\nL.729:\nldl $27,Indx\nlda $27,1($27)\nstl $27,Indx\nldl $27,Indx\ncmple $27,5,$23\nbne $23,L.728\nlda $27,210\nstl $27,Milestone\nldt $f30,Zero\nstt $f30,MyZero\nlda $16,L.45\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.748\njsr $26,printf\nldgp $gp,0($26)\nlda $27,sigfpe\nstq $27,sigsave\nlda $16,L.749\njsr $26,printf\nldgp $gp,0($26)\nlda $16,ovfl_buf\njsr $26,setjmp\nldgp $gp,0($26)\ncmpeq $0,$31,$23\nbeq $23,L.750\nlda $16,L.752\nldt $f30,One\nldt $f29,MyZero\ndivt $f30,$f29,$f17\njsr $26,printf\nldgp $gp,0($26)\nL.750:\nstq $31,sigsave\nlda $27,sigfpe\nstq $27,sigsave\nlda $16,L.753\njsr $26,printf\nldgp $gp,0($26)\nlda $16,ovfl_buf\njsr $26,setjmp\nldgp $gp,0($26)\ncmpeq $0,$31,$23\nbeq $23,L.754\nlda $16,L.752\nldt $f30,Zero\nldt $f29,MyZero\ndivt $f30,$f29,$f17\njsr $26,printf\nldgp $gp,0($26)\nL.754:\nstq $31,sigsave\nlda $27,220\nstl $27,Milestone\njsr $26,Pause\nldgp $gp,0($26)\nlda $16,L.45\njsr $26,printf\nldgp $gp,0($26)\nstl $31,-188+256($sp)\nL.761:\nldl $27,-188+256($sp)\nsll $27,2,$27\nldl $27,ErrCnt($27)\ncmpeq $27,$31,$23\nbne $23,L.765\nlda $16,L.767\nldl $27,-188+256($sp)\nsll $27,3,$25\nldq $17,L.756($25)\nsll $27,2,$27\nldl $18,ErrCnt($27)\njsr $26,printf\nldgp $gp,0($26)\nL.765:\nL.762:\nldl $27,-188+256($sp)\nlda $27,1($27)\nstl $27,-188+256($sp)\nldl $27,-188+256($sp)\ncmplt $27,4,$23\nbne $23,L.761\nlda $16,L.45\njsr $26,printf\nldgp $gp,0($26)\nldl $27,ErrCnt\nldl $25,ErrCnt+4\naddl $27,$25,$27\nldl $25,ErrCnt+8\naddl $27,$25,$27\nldl $25,ErrCnt+12\naddl $27,$25,$27\ncmple $27,$31,$23\nbne $23,L.768\nldl $25,ErrCnt\nldl $22,ErrCnt+4\naddl $25,$22,$25\nldl $22,ErrCnt+8\naddl $25,$22,$25\ncmpeq $25,$31,$23\nbeq $23,L.773\nldl $25,ErrCnt+12\ncmple $25,$31,$23\nbne $23,L.773\nlda $16,L.778\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.779\njsr $26,printf\nldgp $gp,0($26)\nL.773:\nldl $25,ErrCnt\nldl $22,ErrCnt+4\naddl $25,$22,$25\ncmpeq $25,$31,$23\nbeq $23,L.780\nldl $25,ErrCnt+8\ncmple $25,$31,$23\nbne $23,L.780\nlda $16,L.784\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.785\njsr $26,printf\nldgp $gp,0($26)\nL.780:\nldl $27,ErrCnt\nldl $25,ErrCnt+4\naddl $27,$25,$27\ncmple $27,$31,$23\nbne $23,L.786\nlda $16,L.789\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.790\njsr $26,printf\nldgp $gp,0($26)\nL.786:\nldl $27,ErrCnt\ncmple $27,$31,$23\nbne $23,L.769\nlda $16,L.793\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.794\njsr $26,printf\nldgp $gp,0($26)\nbr L.769\nL.768:\nlda $16,L.795\njsr $26,printf\nldgp $gp,0($26)\nldl $27,RMult\ncmpeq $27,1,$23\nbeq $23,L.800\nldl $27,RDiv\ncmpeq $27,1,$23\nbeq $23,L.800\nldl $27,RAddSub\ncmpeq $27,1,$23\nbeq $23,L.800\nldl $27,RSqrt\ncmpeq $27,1,$23\nbne $23,L.796\nL.800:\nlda $16,L.801\njsr $26,printf\nldgp $gp,0($26)\nbr L.797\nL.796:\nldt $f30,One\nldt $f29,StickyBit\ncmptlt $f29,$f30,$f1\nfbne $f1,L.802\nldt $f29,Radix\nldt $f28,Two\nsubt $f29,$f28,$f28\nldt $f27,Nine\nsubt $f29,$f27,$f29\nsubt $f29,$f30,$f30\nmult $f28,$f30,$f30\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.802\nlda $16,L.804\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.805\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,Two\nldt $f29,Radix\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.806\nldt $f29,Precision\nldt $f28,TwentySeven\nldt $f27,Four\nldt $f26,Three\nmult $f27,$f26,$f27\nmult $f27,$f30,$f30\nsubt $f29,$f30,$f30\nsubt $f29,$f28,$f29\nsubt $f29,$f28,$f29\nldt $f28,One\naddt $f29,$f28,$f29\nmult $f30,$f29,$f30\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.806\nlda $16,L.808\njsr $26,printf\nldgp $gp,0($26)\nbr L.807\nL.806:\nlda $16,L.809\njsr $26,printf\nldgp $gp,0($26)\nL.807:\nldl $27,IEEE\ncmpeq $27,$31,$23\nbne $23,L.810\nlda $16,L.812\njsr $26,printf\nldgp $gp,0($26)\nbr L.811\nL.810:\nlda $16,L.813\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.814\njsr $26,printf\nldgp $gp,0($26)\nL.811:\nL.802:\nlda $16,L.815\njsr $26,printf\nldgp $gp,0($26)\nL.797:\nL.769:\nldl $27,fpecount\ncmpeq $27,$31,$23\nbne $23,L.816\nlda $16,L.818\nldl $17,fpecount\njsr $26,printf\nldgp $gp,0($26)\nL.816:\nlda $16,L.819\njsr $26,printf\nldgp $gp,0($26)\nmov $31,$0\nL.7:\nldq $9,0($sp)\nldq $10,8($sp)\nldq $11,16($sp)\nldq $12,24($sp)\nldq $13,32($sp)\nldq $14,40($sp)\nldq $26,48($sp)\nlda $sp,256($sp)\nret\n.end main\n.globl Sign\n.text\n.ent Sign\nSign:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.fmask 0x200,-80\n.mask 0x4000000,-72\n.frame $sp,80,$26,48\nstt $f9,0($sp)\nstq $26,8($sp)\n.prologue 1\nldt $f30,L.8\ncmptlt $f16,$f30,$f1\nfbne $f1,L.822\nldt $f9,L.9\nbr L.823\nL.822:\nldt $f9,L.824\nL.823:\nfmov $f9,$f0\nL.820:\nldt $f9,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end Sign\n.globl Pause\n.text\n.ent Pause\nPause:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\n.prologue 1\nlda $16,L.826\nldl $17,Milestone\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.827\nldl $17,PageNo\njsr $26,printf\nldgp $gp,0($26)\nldl $27,Milestone\nlda $27,1($27)\nstl $27,Milestone\nldl $27,PageNo\nlda $27,1($27)\nstl $27,PageNo\nmov $31,$0\nL.825:\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end Pause\n.globl TstCond\n.text\n.ent TstCond\nTstCond:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\nstq $16,16($sp)\nstq $17,24($sp)\nstq $18,32($sp)\n.prologue 1\nldl $27,-40+64($sp)\ncmpeq $27,$31,$23\nbeq $23,L.829\nldl $16,-48+64($sp)\nldq $17,-32+64($sp)\njsr $26,BadCond\nldgp $gp,0($26)\nlda $16,L.812\njsr $26,printf\nldgp $gp,0($26)\nL.829:\nmov $31,$0\nL.828:\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end TstCond\n.sdata\n.align 3\nL.832:\n.quad L.833\n.quad L.834\n.quad L.835\n.quad L.836\n.globl BadCond\n.text\n.text\n.ent BadCond\nBadCond:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4004000,-72\n.frame $sp,80,$26,48\nstq $14,0($sp)\nstq $26,8($sp)\nmov $16,$14\nstq $17,40($sp)\n.prologue 1\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nlda $27,ErrCnt($27)\nldl $25,($27)\nlda $25,1($25)\nstl $25,($27)\nlda $16,L.837\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,3,$27\nldq $17,L.832($27)\nldq $18,-40+80($sp)\njsr $26,printf\nldgp $gp,0($26)\nmov $31,$0\nL.831:\nldq $14,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end BadCond\n.globl Random\n.text\n.ent Random\nRandom:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.fmask 0x300,-72\n.mask 0x4000000,-64\n.frame $sp,80,$26,48\nstt $f8,0($sp)\nstt $f9,8($sp)\nstq $26,16($sp)\n.prologue 1\nldt $f30,Random1\nldt $f29,Random9\naddt $f30,$f29,$f9\nmult $f9,$f9,$f8\nmult $f8,$f8,$f8\nmult $f9,$f8,$f9\nfmov $f9,$f16\njsr $26,floor\nldgp $gp,0($26)\nsubt $f9,$f0,$f8\nldt $f30,L.839\nmult $f30,$f9,$f30\naddt $f8,$f30,$f30\nstt $f30,Random1\nldt $f0,Random1\nL.838:\nldt $f8,0($sp)\nldt $f9,8($sp)\nldq $26,16($sp)\nlda $sp,80($sp)\nret\n.end Random\n.globl SqXMinX\n.text\n.ent SqXMinX\nSqXMinX:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.fmask 0x200,-80\n.mask 0x4000000,-72\n.frame $sp,80,$26,48\nstt $f9,0($sp)\nstq $26,8($sp)\nstq $16,32($sp)\n.prologue 1\nldt $f30,X\nldt $f29,BInvrse\nmult $f30,$f29,$f9\nsubt $f30,$f9,$f29\nstt $f29,-64+80($sp)\nmult $f30,$f30,$f16\njsr $26,sqrt\nldgp $gp,0($26)\nsubt $f0,$f9,$f30\nldt $f29,-64+80($sp)\nsubt $f30,$f29,$f30\nldt $f29,OneUlp\ndivt $f30,$f29,$f30\nstt $f30,SqEr\nldt $f30,SqEr\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbne $f1,L.841\nldt $f30,SqEr\nldt $f29,MinSqEr\ncmptlt $f30,$f29,$f1\nfbeq $f1,L.843\nldt $f30,SqEr\nstt $f30,MinSqEr\nL.843:\nldt $f30,SqEr\nldt $f29,MaxSqEr\ncmptle $f30,$f29,$f1\nfbne $f1,L.845\nldt $f30,SqEr\nstt $f30,MaxSqEr\nL.845:\nldt $f30,J\nldt $f29,L.9\naddt $f30,$f29,$f30\nstt $f30,J\nldl $16,-48+80($sp)\nlda $17,L.45\njsr $26,BadCond\nldgp $gp,0($26)\nlda $16,L.847\nldt $f30,X\nmult $f30,$f30,$f17\nfmov $f30,$f18\nldt $f30,OneUlp\nldt $f29,SqEr\nmult $f30,$f29,$f19\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.848\njsr $26,printf\nldgp $gp,0($26)\nL.841:\nmov $31,$0\nL.840:\nldt $f9,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end SqXMinX\n.globl NewD\n.text\n.ent NewD\nNewD:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\n.prologue 1\nldt $f30,Z1\nldt $f29,Q\nmult $f30,$f29,$f30\nstt $f30,X\nldt $f30,Half\nldt $f29,X\nldt $f28,Radix\ndivt $f29,$f28,$f29\nsubt $f30,$f29,$f16\njsr $26,floor\nldgp $gp,0($26)\nldt $f29,Radix\nmult $f0,$f29,$f30\nldt $f28,X\naddt $f30,$f28,$f30\nstt $f30,X\nldt $f30,X\nldt $f28,Z\nldt $f27,D\nldt $f26,Q\nmult $f30,$f28,$f25\nsubt $f26,$f25,$f26\ndivt $f26,$f29,$f26\nmult $f30,$f30,$f25\ndivt $f27,$f29,$f29\nmult $f25,$f29,$f29\naddt $f26,$f29,$f29\nstt $f29,Q\nldt $f29,Two\nmult $f29,$f30,$f30\nmult $f30,$f27,$f30\nsubt $f28,$f30,$f30\nstt $f30,Z\nldt $f30,Z\nldt $f29,Zero\ncmptle $f30,$f29,$f1\nfbeq $f1,L.850\nldt $f30,Z\nnegt $f30,$f30\nstt $f30,Z\nldt $f30,Z1\nnegt $f30,$f30\nstt $f30,Z1\nL.850:\nldt $f30,Radix\nldt $f29,D\nmult $f30,$f29,$f30\nstt $f30,D\nmov $31,$0\nL.849:\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end NewD\n.globl SR3750\n.text\n.ent SR3750\nSR3750:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\n.prologue 1\nldt $f30,X\nldt $f29,Radix\nldt $f28,Z2\nsubt $f30,$f29,$f27\nsubt $f28,$f29,$f29\ncmptlt $f27,$f29,$f1\nfbne $f1,L.853\nsubt $f30,$f28,$f30\nldt $f29,W\nsubt $f29,$f28,$f29\ncmptle $f30,$f29,$f1\nfbeq $f1,L.853\nldl $27,I\nlda $27,1($27)\nstl $27,I\nldt $f30,X\nldt $f29,D\nmult $f30,$f29,$f16\njsr $26,sqrt\nldgp $gp,0($26)\nstt $f0,X2\nldt $f30,Z2\nldt $f29,Y\nldt $f28,X2\nsubt $f28,$f30,$f28\nsubt $f29,$f30,$f30\nsubt $f28,$f30,$f30\nstt $f30,Y2\nldt $f30,Half\nldt $f28,X8\nsubt $f29,$f30,$f29\ndivt $f28,$f29,$f29\nstt $f29,X2\nldt $f29,X2\nmult $f30,$f29,$f28\nmult $f28,$f29,$f28\nsubt $f29,$f28,$f29\nstt $f29,X2\nldt $f29,Y2\naddt $f29,$f30,$f29\nldt $f28,X2\nsubt $f30,$f28,$f30\naddt $f29,$f30,$f30\nstt $f30,SqEr\nldt $f30,SqEr\nldt $f29,MinSqEr\ncmptlt $f30,$f29,$f1\nfbeq $f1,L.855\nldt $f30,SqEr\nstt $f30,MinSqEr\nL.855:\nldt $f30,Y2\nldt $f29,X2\nsubt $f30,$f29,$f30\nstt $f30,SqEr\nldt $f30,SqEr\nldt $f29,MaxSqEr\ncmptle $f30,$f29,$f1\nfbne $f1,L.857\nldt $f30,SqEr\nstt $f30,MaxSqEr\nL.857:\nL.853:\nmov $31,$0\nL.852:\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end SR3750\n.globl IsYeqX\n.text\n.ent IsYeqX\nIsYeqX:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\n.prologue 1\nldt $f30,Y\nldt $f29,X\ncmpteq $f30,$f29,$f1\nfbne $f1,L.860\nldl $27,N\ncmple $27,$31,$23\nbeq $23,L.862\nldt $f30,Zero\nldt $f29,Z\ncmpteq $f29,$f30,$f1\nfbeq $f1,L.864\nldt $f29,Q\ncmptle $f29,$f30,$f1\nfbeq $f1,L.864\nlda $16,L.866\njsr $26,printf\nldgp $gp,0($26)\nbr L.865\nL.864:\nlda $16,2\nlda $17,L.867\njsr $26,BadCond\nldgp $gp,0($26)\nL.865:\nlda $16,L.868\nldt $f17,Z\nldt $f18,Q\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.869\nldt $f17,Y\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.870\nldt $f17,X\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.871\nldt $f30,Y\nldt $f29,X\nsubt $f30,$f29,$f17\njsr $26,printf\nldgp $gp,0($26)\nL.862:\nldl $27,N\nlda $27,1($27)\nstl $27,N\nL.860:\nmov $31,$0\nL.859:\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end IsYeqX\n.globl SR3980\n.text\n.ent SR3980\nSR3980:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\n.prologue 1\nL.873:\nlds $f30,I\ncvtlq $f30,$f30\ncvtqt $f30,$f30\nstt $f30,Q\nldt $f16,Z\nldt $f17,Q\njsr $26,pow\nldgp $gp,0($26)\nstt $f0,Y\njsr $26,IsYeqX\nldgp $gp,0($26)\nldl $27,I\nlda $27,1($27)\nstl $27,I\nldl $25,M\ncmple $27,$25,$23\nbne $23,L.876\nbr L.875\nL.876:\nldt $f30,Z\nldt $f29,X\nmult $f30,$f29,$f30\nstt $f30,X\nL.874:\nldt $f30,X\nldt $f29,W\ncmptlt $f30,$f29,$f1\nfbne $f1,L.873\nL.875:\nmov $31,$0\nL.872:\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end SR3980\n.globl PrintIfNPositive\n.text\n.ent PrintIfNPositive\nPrintIfNPositive:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\n.prologue 1\nldl $27,N\ncmple $27,$31,$23\nbne $23,L.879\nlda $16,L.881\nldl $17,N\njsr $26,printf\nldgp $gp,0($26)\nL.879:\nmov $31,$0\nL.878:\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end PrintIfNPositive\n.globl TstPtUf\n.text\n.ent TstPtUf\nTstPtUf:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\n.prologue 1\nstl $31,N\nldt $f30,Z\nldt $f29,Zero\ncmpteq $f30,$f29,$f1\nfbne $f1,L.883\nlda $16,L.885\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.886\njsr $26,printf\nldgp $gp,0($26)\nlda $27,sigfpe\nstq $27,sigsave\nlda $16,ovfl_buf\njsr $26,setjmp\nldgp $gp,0($26)\ncmpeq $0,$31,$23\nbne $23,L.887\nbr L.889\nL.887:\nldt $f30,Z\naddt $f30,$f30,$f29\ndivt $f29,$f30,$f30\nstt $f30,Q9\nlda $16,L.890\nldt $f17,Q9\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,Q9\nldt $f29,Two\nsubt $f30,$f29,$f16\njsr $26,fabs\nldgp $gp,0($26)\nldt $f29,Radix\nldt $f28,U2\nmult $f29,$f28,$f29\ncmptlt $f0,$f29,$f1\nfbeq $f1,L.891\nlda $16,L.893\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.894\njsr $26,printf\nldgp $gp,0($26)\nbr L.892\nL.891:\nldt $f30,Q9\nldt $f29,One\ncmptlt $f30,$f29,$f1\nfbne $f1,L.897\nldt $f29,Two\ncmptle $f30,$f29,$f1\nfbne $f1,L.895\nL.897:\nL.889:\nlda $27,1\nstl $27,N\nldl $27,ErrCnt+4\nlda $27,1($27)\nstl $27,ErrCnt+4\nlda $16,L.900\njsr $26,printf\nldgp $gp,0($26)\nbr L.896\nL.895:\nlda $27,1\nstl $27,N\nldl $27,ErrCnt+8\nlda $27,1($27)\nstl $27,ErrCnt+8\nlda $16,L.903\njsr $26,printf\nldgp $gp,0($26)\nL.896:\nL.892:\nstq $31,sigsave\nldt $f30,Z\nldt $f29,One\nmult $f30,$f29,$f28\nstt $f28,V9\nldt $f28,V9\nstt $f28,Random1\nmult $f29,$f30,$f28\nstt $f28,V9\nldt $f28,V9\nstt $f28,Random2\ndivt $f30,$f29,$f30\nstt $f30,V9\nldt $f30,Z\nldt $f29,Random1\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.904\nldt $f29,Random2\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.904\nldt $f29,V9\ncmpteq $f30,$f29,$f1\nfbeq $f1,L.904\nldl $27,N\ncmple $27,$31,$23\nbne $23,L.905\njsr $26,Pause\nldgp $gp,0($26)\nbr L.905\nL.904:\nlda $27,1\nstl $27,N\nlda $16,2\nlda $17,L.908\njsr $26,BadCond\nldgp $gp,0($26)\nlda $16,L.909\nldt $f17,Z\njsr $26,printf\nldgp $gp,0($26)\nldt $f30,Z\nldt $f29,Random1\ncmpteq $f30,$f29,$f1\nfbne $f1,L.910\nlda $16,L.912\nldt $f17,Random1\njsr $26,printf\nldgp $gp,0($26)\nL.910:\nldt $f30,Random2\nldt $f29,Z\ncmpteq $f29,$f30,$f1\nfbne $f1,L.913\nldt $f29,Random1\ncmpteq $f30,$f29,$f1\nfbne $f1,L.913\nlda $16,L.915\nldt $f17,Random2\njsr $26,printf\nldgp $gp,0($26)\nL.913:\nldt $f30,Z\nldt $f29,V9\ncmpteq $f30,$f29,$f1\nfbne $f1,L.916\nlda $16,L.918\nldt $f17,V9\njsr $26,printf\nldgp $gp,0($26)\nL.916:\nldt $f30,Random2\nldt $f29,Random1\ncmpteq $f30,$f29,$f1\nfbne $f1,L.919\nldl $27,ErrCnt+8\nlda $27,1($27)\nstl $27,ErrCnt+8\nlda $16,2\nlda $17,L.923\njsr $26,BadCond\nldgp $gp,0($26)\nlda $16,L.924\nldt $f17,Random2\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.925\nldt $f17,Random1\njsr $26,printf\nldgp $gp,0($26)\nL.919:\njsr $26,Pause\nldgp $gp,0($26)\nL.905:\nL.883:\nmov $31,$0\nL.882:\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end TstPtUf\n.globl notify\n.text\n.ent notify\nnotify:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\nstq $16,16($sp)\n.prologue 1\nlda $16,L.927\nldq $17,-48+64($sp)\njsr $26,printf\nldgp $gp,0($26)\nlda $16,L.928\njsr $26,printf\nldgp $gp,0($26)\nmov $31,$0\nL.926:\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end notify\n.globl msglist\n.text\n.ent msglist\nmsglist:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4004000,-72\n.frame $sp,80,$26,48\nstq $14,0($sp)\nstq $26,8($sp)\nmov $16,$14\n.prologue 1\nbr L.931\nL.930:\nlda $16,L.933\nmov $14,$27\nlda $14,8($27)\nldq $17,($27)\njsr $26,printf\nldgp $gp,0($26)\nL.931:\nldq $27,($14)\ncmpeq $27,$31,$23\nbeq $23,L.930\nmov $31,$0\nL.929:\nldq $14,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end msglist\n.sdata\n.align 3\nL.935:\n.quad L.936\n.quad L.937\n.quad L.938\n.quad L.939\n.quad L.940\n.quad L.941\n.quad L.942\n.quad L.943\n.quad L.944\n.quad 0x0\n.globl Instructions\n.text\n.text\n.ent Instructions\nInstructions:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\n.prologue 1\nlda $16,L.935\njsr $26,msglist\nldgp $gp,0($26)\nmov $31,$0\nL.934:\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end Instructions\n.sdata\n.align 3\nL.946:\n.quad L.947\n.quad L.948\n.quad L.949\n.quad L.950\n.quad L.951\n.quad L.952\n.quad L.953\n.quad L.954\n.quad L.955\n.quad L.956\n.quad L.957\n.quad L.958\n.quad L.959\n.quad L.960\n.quad 0x0\n.globl Heading\n.text\n.text\n.ent Heading\nHeading:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\n.prologue 1\nlda $16,L.946\njsr $26,msglist\nldgp $gp,0($26)\nmov $31,$0\nL.945:\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end Heading\n.sdata\n.align 3\nL.962:\n.quad L.963\n.quad L.964\n.quad L.965\n.quad L.966\n.quad L.967\n.quad L.968\n.quad L.969\n.quad L.970\n.quad L.971\n.quad L.972\n.quad L.973\n.quad L.974\n.quad L.975\n.quad L.976\n.quad L.977\n.quad L.978\n.quad L.979\n.quad L.980\n.quad L.981\n.quad 0x0\n.globl Characteristics\n.text\n.text\n.ent Characteristics\nCharacteristics:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\n.prologue 1\nlda $16,L.962\njsr $26,msglist\nldgp $gp,0($26)\nmov $31,$0\nL.961:\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end Characteristics\n.sdata\n.align 3\nL.983:\n.quad L.984\n.quad L.985\n.quad L.986\n.quad L.987\n.quad L.988\n.quad L.989\n.quad L.990\n.quad L.991\n.quad L.992\n.quad L.993\n.quad L.994\n.quad L.995\n.quad L.996\n.quad L.997\n.quad L.998\n.quad L.999\n.quad L.1000\n.quad 0x0\n.globl History\n.text\n.text\n.ent History\nHistory:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\n.prologue 1\nlda $16,L.983\njsr $26,msglist\nldgp $gp,0($26)\nmov $31,$0\nL.982:\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end History\n.globl pow\n.text\n.ent pow\npow:\nldgp $gp,0($27)\nlda $sp,-128($sp)\n.fmask 0x380,-112\n.mask 0x4006000,-88\n.frame $sp,128,$26,48\nstt $f7,0($sp)\nstt $f8,8($sp)\nstt $f9,16($sp)\nstq $13,24($sp)\nstq $14,32($sp)\nstq $26,40($sp)\nfmov $f16,$f9\nfmov $f17,$f8\n.prologue 1\nmov $31,$13\nstl $31,-64+128($sp)\nldt $f30,L.8\ncmpteq $f8,$f30,$f1\nfbeq $f1,L.1002\nldt $f0,L.9\nbr L.1001\nL.1002:\nldt $f30,L.1007\ncmptlt $f8,$f30,$f1\nfbne $f1,L.1006\nldt $f30,L.1008\ncmptle $f8,$f30,$f1\nfbne $f1,L.1004\nL.1006:\nldt $f30,L.824\ncmpteq $f9,$f30,$f1\nfbne $f1,L.1004\nfmov $f9,$f16\njsr $26,log\nldgp $gp,0($26)\nfmov $f0,$f30\nmult $f8,$f30,$f16\njsr $26,exp\nldgp $gp,0($26)\nfmov $f0,$f30\nbr L.1001\nL.1004:\nldt $f30,L.8\ncmptlt $f8,$f30,$f1\nfbeq $f1,L.1009\nnegt $f8,$f8\nlda $27,1\nstl $27,-64+128($sp)\nL.1009:\nfmov $f8,$f16\nlda $17,-72+128($sp)\njsr $26,modf\nldgp $gp,0($26)\nfmov $f0,$f8\nldt $f30,L.8\ncmpteq $f8,$f30,$f1\nfbne $f1,L.1011\nfmov $f9,$f16\njsr $26,log\nldgp $gp,0($26)\nfmov $f0,$f30\nmult $f8,$f30,$f16\njsr $26,exp\nldgp $gp,0($26)\nfmov $f0,$f7\nbr L.1012\nL.1011:\nldt $f7,L.9\nL.1012:\nfmov $f9,$f16\nlda $17,-60+128($sp)\njsr $26,frexp\nldgp $gp,0($26)\nfmov $f0,$f9\nldt $f30,-72+128($sp)\ncvttqc $f30,$f1\nstt $f1,-56+128($sp)\nldq $27,-56+128($sp)\nmov $27,$14\ncmpeq $27,$31,$23\nbne $23,L.1013\nL.1015:\nand $14,1,$27\ncmpeq $27,$31,$23\nbne $23,L.1019\nmult $f7,$f9,$f7\nldl $27,-60+128($sp)\naddl $13,$27,$13\nL.1019:\nsra $14,1,$27\nmov $27,$14\ncmpeq $27,$31,$23\nbeq $23,L.1021\nbr L.1017\nL.1021:\nmult $f9,$f9,$f9\nldl $27,-60+128($sp)\nsll $27,1,$27\naddl $27,0,$27\nstl $27,-60+128($sp)\nldt $f30,L.1025\ncmptlt $f9,$f30,$f1\nfbeq $f1,L.1015\nldt $f30,L.1026\nmult $f30,$f9,$f9\nldl $27,-60+128($sp)\nsubl $27,1,$27\nstl $27,-60+128($sp)\nbr L.1015\nL.1017:\nL.1013:\nldl $27,-64+128($sp)\ncmpeq $27,$31,$23\nbne $23,L.1027\nldt $f30,L.9\ndivt $f30,$f7,$f7\nnegl $13,$13\nL.1027:\nfmov $f7,$f16\nmov $13,$17\njsr $26,ldexp\nldgp $gp,0($26)\nfmov $f0,$f30\nL.1001:\nldt $f7,0($sp)\nldt $f8,8($sp)\nldt $f9,16($sp)\nldq $13,24($sp)\nldq $14,32($sp)\nldq $26,40($sp)\nlda $sp,128($sp)\nret\n.end pow\n.globl UfNGrad\n.comm UfNGrad,4\n.globl SqRWrng\n.comm SqRWrng,4\n.globl IEEE\n.comm IEEE,4\n.globl Anomaly\n.comm Anomaly,4\n.globl Monot\n.comm Monot,4\n.globl NotMonot\n.comm NotMonot,4\n.globl Done\n.comm Done,4\n.globl Break\n.comm Break,4\n.globl RSqrt\n.comm RSqrt,4\n.globl RAddSub\n.comm RAddSub,4\n.globl RDiv\n.comm RDiv,4\n.globl RMult\n.comm RMult,4\n.globl GAddSub\n.comm GAddSub,4\n.globl GDiv\n.comm GDiv,4\n.globl GMult\n.comm GMult,4\n.globl N1\n.comm N1,4\n.globl N\n.comm N,4\n.globl M\n.comm M,4\n.globl PageNo\n.comm PageNo,4\n.globl Milestone\n.comm Milestone,4\n.globl fpecount\n.comm fpecount,4\n.globl ErrCnt\n.comm ErrCnt,16\n.globl Z9\n.comm Z9,8\n.globl Z2\n.comm Z2,8\n.globl Z1\n.comm Z1,8\n.globl PseudoZero\n.comm PseudoZero,8\n.globl Z\n.comm Z,8\n.globl Random2\n.comm Random2,8\n.globl Y2\n.comm Y2,8\n.globl Y1\n.comm Y1,8\n.globl Y\n.comm Y,8\n.globl Random1\n.comm Random1,8\n.globl X8\n.comm X8,8\n.globl X2\n.comm X2,8\n.globl X1\n.comm X1,8\n.globl X\n.comm X,8\n.globl W\n.comm W,8\n.globl V9\n.comm V9,8\n.globl V0\n.comm V0,8\n.globl V\n.comm V,8\n.globl U2\n.comm U2,8\n.globl U1\n.comm U1,8\n.globl UfThold\n.comm UfThold,8\n.globl OneUlp\n.comm OneUlp,8\n.globl S\n.comm S,8\n.globl Underflow\n.comm Underflow,8\n.globl T\n.comm T,8\n.globl Random9\n.comm Random9,8\n.globl R\n.comm R,8\n.globl Q9\n.comm Q9,8\n.globl Q\n.comm Q,8\n.globl Precision\n.comm Precision,8\n.globl MyZero\n.comm MyZero,8\n.globl J\n.comm J,8\n.globl StickyBit\n.comm StickyBit,8\n.globl I\n.comm I,4\n.globl HInvrse\n.comm HInvrse,8\n.globl H\n.comm H,8\n.globl F9\n.comm F9,8\n.globl F6\n.comm F6,8\n.globl Third\n.comm Third,8\n.globl E9\n.comm E9,8\n.globl MaxSqEr\n.comm MaxSqEr,8\n.globl SqEr\n.comm SqEr,8\n.globl MinSqEr\n.comm MinSqEr,8\n.globl E3\n.comm E3,8\n.globl Exp2\n.comm Exp2,8\n.globl E1\n.comm E1,8\n.globl E0\n.comm E0,8\n.globl FourD\n.comm FourD,8\n.globl D\n.comm D,8\n.globl CInvrse\n.comm CInvrse,8\n.globl C\n.comm C,8\n.globl A1\n.comm A1,8\n.globl AInvrse\n.comm AInvrse,8\n.globl ch\n.comm ch,8\n.globl Indx\n.comm Indx,4\n.globl BMinusU2\n.comm BMinusU2,8\n.globl RadixD2\n.comm RadixD2,8\n.globl BInvrse\n.comm BInvrse,8\n.globl Radix\n.comm Radix,8\n.globl sigsave\n.comm sigsave,8\n.globl ovfl_buf\n.comm ovfl_buf,336\n.extern _iob 0\n.rdata\n.align 3\nL.1026:\n.long 0x0\n.long 0x40000000\n.align 3\nL.1025:\n.long 0x0\n.long 0x3fe00000\n.align 3\nL.1008:\n.long 0x0\n.long 0x40913000\n.align 3\nL.1007:\n.long 0x0\n.long 0xc0913000\n.align 0\nL.1000:\n.byte 115\n.byte 101\n.byte 101\n.byte 32\n.byte 115\n.byte 111\n.byte 117\n.byte 114\n.byte 99\n.byte 101\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 109\n.byte 111\n.byte 114\n.byte 101\n.byte 32\n.byte 104\n.byte 105\n.byte 115\n.byte 116\n.byte 111\n.byte 114\n.byte 121\n.byte 46\n.byte 0\n.align 0\nL.999:\n.byte 66\n.byte 65\n.byte 83\n.byte 73\n.byte 67\n.byte 32\n.byte 118\n.byte 101\n.byte 114\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 40\n.byte 67\n.byte 41\n.byte 32\n.byte 49\n.byte 57\n.byte 56\n.byte 51\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 80\n.byte 114\n.byte 111\n.byte 102\n.byte 46\n.byte 32\n.byte 87\n.byte 46\n.byte 32\n.byte 77\n.byte 46\n.byte 32\n.byte 75\n.byte 97\n.byte 104\n.byte 97\n.byte 110\n.byte 59\n.byte 0\n.align 0\nL.998:\n.byte 97\n.byte 115\n.byte 32\n.byte 117\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 99\n.byte 101\n.byte 114\n.byte 116\n.byte 97\n.byte 105\n.byte 110\n.byte 32\n.byte 101\n.byte 97\n.byte 114\n.byte 108\n.byte 121\n.byte 32\n.byte 87\n.byte 65\n.byte 78\n.byte 71\n.byte 32\n.byte 109\n.byte 97\n.byte 99\n.byte 104\n.byte 105\n.byte 110\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.997:\n.byte 102\n.byte 108\n.byte 111\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 45\n.byte 112\n.byte 111\n.byte 105\n.byte 110\n.byte 116\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 115\n.byte 44\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 32\n.byte 97\n.byte 108\n.byte 115\n.byte 111\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 111\n.byte 119\n.byte 115\n.byte 32\n.byte 108\n.byte 111\n.byte 103\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 105\n.byte 99\n.byte 32\n.byte 101\n.byte 110\n.byte 99\n.byte 111\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 0\n.align 0\nL.996:\n.byte 10\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 98\n.byte 97\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 117\n.byte 112\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 118\n.byte 101\n.byte 110\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 114\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 114\n.byte 101\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 101\n.byte 110\n.byte 116\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 0\n.align 0\nL.995:\n.byte 111\n.byte 102\n.byte 32\n.byte 112\n.byte 97\n.byte 116\n.byte 104\n.byte 111\n.byte 108\n.byte 111\n.byte 103\n.byte 105\n.byte 101\n.byte 115\n.byte 44\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 115\n.byte 97\n.byte 121\n.byte 32\n.byte 104\n.byte 111\n.byte 119\n.byte 32\n.byte 119\n.byte 101\n.byte 108\n.byte 108\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 109\n.byte 112\n.byte 108\n.byte 101\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 0\n.align 0\nL.994:\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 44\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 116\n.byte 114\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 112\n.byte 101\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 97\n.byte 32\n.byte 119\n.byte 105\n.byte 100\n.byte 101\n.byte 114\n.byte 32\n.byte 118\n.byte 97\n.byte 114\n.byte 105\n.byte 101\n.byte 116\n.byte 121\n.byte 0\n.align 0\nL.993:\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 44\n.byte 32\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 114\n.byte 97\n.byte 110\n.byte 103\n.byte 101\n.byte 32\n.byte 40\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 47\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 115\n.byte 41\n.byte 0\n.align 0\nL.992:\n.byte 87\n.byte 46\n.byte 32\n.byte 74\n.byte 46\n.byte 32\n.byte 67\n.byte 111\n.byte 100\n.byte 121\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 87\n.byte 46\n.byte 32\n.byte 87\n.byte 97\n.byte 105\n.byte 116\n.byte 101\n.byte 46\n.byte 32\n.byte 65\n.byte 108\n.byte 116\n.byte 104\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 32\n.byte 98\n.byte 111\n.byte 116\n.byte 104\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 115\n.byte 32\n.byte 116\n.byte 114\n.byte 121\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 0\n.align 0\nL.991:\n.byte 98\n.byte 111\n.byte 111\n.byte 107\n.byte 32\n.byte 32\n.byte 96\n.byte 83\n.byte 111\n.byte 102\n.byte 116\n.byte 119\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 77\n.byte 97\n.byte 110\n.byte 117\n.byte 97\n.byte 108\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 69\n.byte 108\n.byte 101\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 97\n.byte 114\n.byte 121\n.byte 32\n.byte 70\n.byte 117\n.byte 110\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 39\n.byte 32\n.byte 40\n.byte 49\n.byte 57\n.byte 56\n.byte 48\n.byte 41\n.byte 32\n.byte 98\n.byte 121\n.byte 0\n.align 0\nL.990:\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 99\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 100\n.byte 32\n.byte 96\n.byte 77\n.byte 65\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 39\n.byte 44\n.byte 32\n.byte 119\n.byte 104\n.byte 105\n.byte 99\n.byte 104\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 101\n.byte 110\n.byte 100\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 0\n.align 0\nL.989:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 99\n.byte 97\n.byte 112\n.byte 97\n.byte 98\n.byte 105\n.byte 108\n.byte 105\n.byte 116\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 103\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 121\n.byte 111\n.byte 110\n.byte 100\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 101\n.byte 97\n.byte 114\n.byte 108\n.byte 105\n.byte 101\n.byte 114\n.byte 0\n.align 0\nL.988:\n.byte 70\n.byte 97\n.byte 105\n.byte 108\n.byte 117\n.byte 114\n.byte 101\n.byte 115\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 115\n.byte 101\n.byte 113\n.byte 117\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.987:\n.byte 32\n.byte 32\n.byte 32\n.byte 70\n.byte 65\n.byte 73\n.byte 76\n.byte 85\n.byte 82\n.byte 69\n.byte 115\n.byte 44\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 32\n.byte 50\n.byte 43\n.byte 50\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 53\n.byte 32\n.byte 46\n.byte 0\n.align 0\nL.986:\n.byte 32\n.byte 32\n.byte 32\n.byte 83\n.byte 101\n.byte 114\n.byte 105\n.byte 111\n.byte 117\n.byte 115\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 115\n.byte 44\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 97\n.byte 32\n.byte 103\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 44\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 0\n.align 0\nL.985:\n.byte 32\n.byte 32\n.byte 32\n.byte 70\n.byte 76\n.byte 65\n.byte 87\n.byte 115\n.byte 44\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 97\n.byte 32\n.byte 115\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 121\n.byte 32\n.byte 98\n.byte 105\n.byte 116\n.byte 44\n.byte 0\n.align 0\nL.984:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 97\n.byte 116\n.byte 116\n.byte 101\n.byte 109\n.byte 112\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 114\n.byte 105\n.byte 109\n.byte 105\n.byte 110\n.byte 97\n.byte 116\n.byte 101\n.byte 32\n.byte 97\n.byte 109\n.byte 111\n.byte 110\n.byte 103\n.byte 0\n.align 0\nL.981:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 68\n.byte 101\n.byte 99\n.byte 105\n.byte 109\n.byte 97\n.byte 108\n.byte 45\n.byte 66\n.byte 105\n.byte 110\n.byte 97\n.byte 114\n.byte 121\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 118\n.byte 101\n.byte 114\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 32\n.byte 89\n.byte 69\n.byte 84\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 97\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 97\n.byte 99\n.byte 121\n.byte 46\n.byte 0\n.align 0\nL.980:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 69\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 45\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 101\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 101\n.byte 120\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 101\n.byte 118\n.byte 101\n.byte 97\n.byte 108\n.byte 101\n.byte 100\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 32\n.byte 89\n.byte 69\n.byte 84\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 0\n.align 0\nL.979:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 83\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 32\n.byte 32\n.byte 89\n.byte 94\n.byte 88\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 0\n.align 0\nL.978:\n.byte 9\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 116\n.byte 97\n.byte 109\n.byte 105\n.byte 110\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 112\n.byte 115\n.byte 101\n.byte 117\n.byte 100\n.byte 111\n.byte 45\n.byte 122\n.byte 101\n.byte 114\n.byte 111\n.byte 115\n.byte 46\n.byte 0\n.align 0\nL.977:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 99\n.byte 104\n.byte 101\n.byte 99\n.byte 107\n.byte 101\n.byte 100\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 115\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 110\n.byte 99\n.byte 121\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 0\nL.976:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 86\n.byte 48\n.byte 32\n.byte 32\n.byte 116\n.byte 101\n.byte 108\n.byte 108\n.byte 115\n.byte 44\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 108\n.byte 121\n.byte 44\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 32\n.byte 73\n.byte 110\n.byte 102\n.byte 105\n.byte 110\n.byte 105\n.byte 116\n.byte 121\n.byte 32\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 114\n.byte 101\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 101\n.byte 110\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 0\n.align 0\nL.975:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 86\n.byte 32\n.byte 61\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 44\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 108\n.byte 121\n.byte 46\n.byte 0\n.align 0\nL.974:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 69\n.byte 48\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 80\n.byte 115\n.byte 101\n.byte 117\n.byte 100\n.byte 111\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 116\n.byte 101\n.byte 108\n.byte 108\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 98\n.byte 114\n.byte 117\n.byte 112\n.byte 116\n.byte 44\n.byte 32\n.byte 103\n.byte 114\n.byte 97\n.byte 100\n.byte 117\n.byte 97\n.byte 108\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 102\n.byte 117\n.byte 122\n.byte 122\n.byte 121\n.byte 46\n.byte 0\n.align 0\nL.973:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 84\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 61\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 46\n.byte 0\n.align 0\nL.972:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 87\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 97\n.byte 32\n.byte 83\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 121\n.byte 32\n.byte 66\n.byte 105\n.byte 116\n.byte 32\n.byte 117\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 46\n.byte 0\n.align 0\nL.971:\n.byte 9\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 46\n.byte 44\n.byte 32\n.byte 68\n.byte 105\n.byte 118\n.byte 46\n.byte 44\n.byte 32\n.byte 65\n.byte 100\n.byte 100\n.byte 47\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 46\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 83\n.byte 113\n.byte 114\n.byte 116\n.byte 46\n.byte 0\n.align 0\nL.970:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 87\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 44\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 115\n.byte 111\n.byte 109\n.byte 101\n.byte 116\n.byte 104\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 0\n.align 0\nL.969:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 65\n.byte 100\n.byte 101\n.byte 113\n.byte 117\n.byte 97\n.byte 99\n.byte 121\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 103\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 46\n.byte 44\n.byte 32\n.byte 68\n.byte 105\n.byte 118\n.byte 46\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 46\n.byte 0\n.align 0\nL.968:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 85\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 49\n.byte 47\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 94\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 61\n.byte 32\n.byte 79\n.byte 110\n.byte 101\n.byte 32\n.byte 85\n.byte 108\n.byte 112\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 108\n.byte 105\n.byte 116\n.byte 116\n.byte 108\n.byte 101\n.byte 32\n.byte 108\n.byte 101\n.byte 115\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 110\n.byte 32\n.byte 49\n.byte 46\n.byte 48\n.byte 32\n.byte 46\n.byte 0\n.align 0\nL.967:\n.byte 9\n.byte 40\n.byte 79\n.byte 110\n.byte 101\n.byte 85\n.byte 108\n.byte 112\n.byte 110\n.byte 105\n.byte 116\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 76\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 80\n.byte 108\n.byte 97\n.byte 99\n.byte 101\n.byte 41\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 49\n.byte 46\n.byte 48\n.byte 48\n.byte 48\n.byte 120\n.byte 120\n.byte 120\n.byte 32\n.byte 46\n.byte 0\n.align 0\nL.966:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 85\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 47\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 94\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 61\n.byte 32\n.byte 79\n.byte 110\n.byte 101\n.byte 32\n.byte 85\n.byte 108\n.byte 112\n.byte 0\n.align 0\nL.965:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 61\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 105\n.byte 102\n.byte 105\n.byte 99\n.byte 97\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 99\n.byte 97\n.byte 114\n.byte 114\n.byte 105\n.byte 101\n.byte 100\n.byte 46\n.byte 0\n.align 0\nL.964:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 49\n.byte 44\n.byte 32\n.byte 50\n.byte 44\n.byte 32\n.byte 52\n.byte 44\n.byte 32\n.byte 56\n.byte 44\n.byte 32\n.byte 49\n.byte 48\n.byte 44\n.byte 32\n.byte 49\n.byte 54\n.byte 44\n.byte 32\n.byte 49\n.byte 48\n.byte 48\n.byte 44\n.byte 32\n.byte 50\n.byte 53\n.byte 54\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 0\n.align 0\nL.963:\n.byte 82\n.byte 117\n.byte 110\n.byte 110\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 114\n.byte 101\n.byte 118\n.byte 101\n.byte 97\n.byte 108\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 115\n.byte 101\n.byte 32\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 101\n.byte 114\n.byte 105\n.byte 115\n.byte 116\n.byte 105\n.byte 99\n.byte 115\n.byte 58\n.byte 0\n.align 0\nL.960:\n.byte 9\n.byte 79\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 114\n.byte 101\n.byte 108\n.byte 101\n.byte 118\n.byte 97\n.byte 110\n.byte 116\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 105\n.byte 108\n.byte 101\n.byte 114\n.byte 32\n.byte 111\n.byte 112\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 58\n.byte 0\n.align 0\nL.959:\n.byte 9\n.byte 79\n.byte 112\n.byte 116\n.byte 105\n.byte 109\n.byte 105\n.byte 122\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 108\n.byte 101\n.byte 118\n.byte 101\n.byte 108\n.byte 58\n.byte 10\n.byte 0\n.align 0\nL.958:\n.byte 9\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 105\n.byte 108\n.byte 101\n.byte 114\n.byte 58\n.byte 10\n.byte 0\n.align 0\nL.957:\n.byte 9\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 114\n.byte 58\n.byte 10\n.byte 0\n.align 0\nL.956:\n.byte 9\n.byte 86\n.byte 101\n.byte 114\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 58\n.byte 9\n.byte 49\n.byte 48\n.byte 32\n.byte 70\n.byte 101\n.byte 98\n.byte 114\n.byte 117\n.byte 97\n.byte 114\n.byte 121\n.byte 32\n.byte 49\n.byte 57\n.byte 56\n.byte 57\n.byte 59\n.byte 0\n.align 0\nL.955:\n.byte 9\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 58\n.byte 9\n.byte 100\n.byte 111\n.byte 117\n.byte 98\n.byte 108\n.byte 101\n.byte 59\n.byte 0\n.align 0\nL.954:\n.byte 73\n.byte 110\n.byte 32\n.byte 100\n.byte 111\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 115\n.byte 111\n.byte 44\n.byte 32\n.byte 112\n.byte 108\n.byte 101\n.byte 97\n.byte 115\n.byte 101\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 108\n.byte 117\n.byte 100\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 102\n.byte 111\n.byte 108\n.byte 108\n.byte 111\n.byte 119\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 105\n.byte 110\n.byte 102\n.byte 111\n.byte 114\n.byte 109\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 58\n.byte 0\n.align 0\nL.953:\n.byte 9\n.byte 83\n.byte 97\n.byte 110\n.byte 32\n.byte 70\n.byte 114\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 44\n.byte 32\n.byte 67\n.byte 65\n.byte 32\n.byte 57\n.byte 52\n.byte 49\n.byte 52\n.byte 51\n.byte 45\n.byte 48\n.byte 55\n.byte 48\n.byte 52\n.byte 44\n.byte 32\n.byte 85\n.byte 83\n.byte 65\n.byte 10\n.byte 0\n.align 0\nL.952:\n.byte 9\n.byte 85\n.byte 110\n.byte 105\n.byte 118\n.byte 101\n.byte 114\n.byte 115\n.byte 105\n.byte 116\n.byte 121\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 67\n.byte 97\n.byte 108\n.byte 105\n.byte 102\n.byte 111\n.byte 114\n.byte 110\n.byte 105\n.byte 97\n.byte 0\n.align 0\nL.951:\n.byte 9\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 67\n.byte 101\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 85\n.byte 45\n.byte 55\n.byte 54\n.byte 0\n.align 0\nL.950:\n.byte 9\n.byte 82\n.byte 105\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 75\n.byte 97\n.byte 114\n.byte 112\n.byte 105\n.byte 110\n.byte 115\n.byte 107\n.byte 105\n.byte 0\n.align 0\nL.949:\n.byte 80\n.byte 108\n.byte 101\n.byte 97\n.byte 115\n.byte 101\n.byte 32\n.byte 115\n.byte 101\n.byte 110\n.byte 100\n.byte 32\n.byte 115\n.byte 117\n.byte 103\n.byte 103\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 114\n.byte 101\n.byte 115\n.byte 117\n.byte 108\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 0\n.align 0\nL.948:\n.byte 99\n.byte 111\n.byte 112\n.byte 101\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 117\n.byte 110\n.byte 97\n.byte 110\n.byte 116\n.byte 105\n.byte 99\n.byte 105\n.byte 112\n.byte 97\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 110\n.byte 101\n.byte 119\n.byte 108\n.byte 121\n.byte 32\n.byte 117\n.byte 110\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 112\n.byte 97\n.byte 116\n.byte 104\n.byte 111\n.byte 108\n.byte 111\n.byte 103\n.byte 105\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.947:\n.byte 85\n.byte 115\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 105\n.byte 110\n.byte 118\n.byte 105\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 104\n.byte 101\n.byte 108\n.byte 112\n.byte 32\n.byte 100\n.byte 101\n.byte 98\n.byte 117\n.byte 103\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 97\n.byte 117\n.byte 103\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 115\n.byte 111\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 119\n.byte 105\n.byte 108\n.byte 108\n.byte 0\n.align 0\nL.944:\n.byte 65\n.byte 110\n.byte 115\n.byte 119\n.byte 101\n.byte 114\n.byte 32\n.byte 113\n.byte 117\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 89\n.byte 44\n.byte 32\n.byte 121\n.byte 44\n.byte 32\n.byte 78\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 110\n.byte 32\n.byte 40\n.byte 117\n.byte 110\n.byte 108\n.byte 101\n.byte 115\n.byte 115\n.byte 32\n.byte 111\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 119\n.byte 105\n.byte 115\n.byte 101\n.byte 32\n.byte 105\n.byte 110\n.byte 100\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 101\n.byte 100\n.byte 41\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.943:\n.byte 97\n.byte 109\n.byte 101\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 107\n.byte 101\n.byte 32\n.byte 102\n.byte 117\n.byte 114\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.942:\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 97\n.byte 110\n.byte 121\n.byte 119\n.byte 97\n.byte 121\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 115\n.byte 101\n.byte 101\n.byte 32\n.byte 104\n.byte 111\n.byte 119\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 109\n.byte 105\n.byte 108\n.byte 101\n.byte 115\n.byte 116\n.byte 111\n.byte 110\n.byte 101\n.byte 115\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 112\n.byte 97\n.byte 115\n.byte 115\n.byte 101\n.byte 115\n.byte 44\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 110\n.byte 0\n.align 0\nL.941:\n.byte 119\n.byte 97\n.byte 114\n.byte 110\n.byte 105\n.byte 110\n.byte 103\n.byte 46\n.byte 32\n.byte 32\n.byte 73\n.byte 102\n.byte 32\n.byte 112\n.byte 101\n.byte 114\n.byte 115\n.byte 117\n.byte 97\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 118\n.byte 97\n.byte 105\n.byte 108\n.byte 115\n.byte 32\n.byte 110\n.byte 97\n.byte 117\n.byte 103\n.byte 104\n.byte 116\n.byte 44\n.byte 32\n.byte 100\n.byte 111\n.byte 110\n.byte 39\n.byte 116\n.byte 32\n.byte 100\n.byte 101\n.byte 115\n.byte 112\n.byte 97\n.byte 105\n.byte 114\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 32\n.byte 114\n.byte 117\n.byte 110\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 0\n.align 0\nL.940:\n.byte 116\n.byte 111\n.byte 32\n.byte 112\n.byte 101\n.byte 114\n.byte 115\n.byte 101\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 97\n.byte 32\n.byte 115\n.byte 117\n.byte 114\n.byte 114\n.byte 111\n.byte 103\n.byte 97\n.byte 116\n.byte 101\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 97\n.byte 102\n.byte 116\n.byte 101\n.byte 114\n.byte 44\n.byte 32\n.byte 112\n.byte 101\n.byte 114\n.byte 104\n.byte 97\n.byte 112\n.byte 115\n.byte 44\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 112\n.byte 108\n.byte 97\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 115\n.byte 111\n.byte 109\n.byte 101\n.byte 0\n.align 0\nL.939:\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 32\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 47\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 111\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 115\n.byte 44\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 32\n.byte 114\n.byte 97\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 0\n.align 0\nL.938:\n.byte 116\n.byte 114\n.byte 121\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 112\n.byte 101\n.byte 114\n.byte 115\n.byte 117\n.byte 97\n.byte 100\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 116\n.byte 101\n.byte 114\n.byte 109\n.byte 105\n.byte 110\n.byte 97\n.byte 116\n.byte 101\n.byte 32\n.byte 101\n.byte 120\n.byte 101\n.byte 99\n.byte 117\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 110\n.byte 32\n.byte 97\n.byte 110\n.byte 0\n.align 0\nL.937:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 96\n.byte 69\n.byte 78\n.byte 68\n.byte 32\n.byte 79\n.byte 70\n.byte 32\n.byte 84\n.byte 69\n.byte 83\n.byte 84\n.byte 39\n.byte 44\n.byte 10\n.byte 0\n.align 0\nL.936:\n.byte 76\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 115\n.byte 116\n.byte 111\n.byte 112\n.byte 32\n.byte 112\n.byte 114\n.byte 101\n.byte 109\n.byte 97\n.byte 116\n.byte 117\n.byte 114\n.byte 101\n.byte 108\n.byte 121\n.byte 44\n.byte 32\n.byte 105\n.byte 46\n.byte 101\n.byte 46\n.byte 32\n.byte 98\n.byte 101\n.byte 102\n.byte 111\n.byte 114\n.byte 101\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 112\n.byte 108\n.byte 97\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 10\n.byte 0\n.align 0\nL.933:\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.928:\n.byte 32\n.byte 32\n.byte 32\n.byte 80\n.byte 76\n.byte 69\n.byte 65\n.byte 83\n.byte 69\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 73\n.byte 70\n.byte 89\n.byte 32\n.byte 75\n.byte 65\n.byte 82\n.byte 80\n.byte 73\n.byte 78\n.byte 75\n.byte 83\n.byte 73\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.927:\n.byte 37\n.byte 115\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 111\n.byte 110\n.byte 115\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 110\n.byte 116\n.byte 46\n.byte 46\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.925:\n.byte 9\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 90\n.byte 32\n.byte 42\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.924:\n.byte 9\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 49\n.byte 32\n.byte 42\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.923:\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 100\n.byte 111\n.byte 101\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 109\n.byte 117\n.byte 116\n.byte 101\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.918:\n.byte 90\n.byte 32\n.byte 47\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.915:\n.byte 49\n.byte 32\n.byte 42\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 37\n.byte 103\n.byte 10\n.byte 0\n.align 0\nL.912:\n.byte 90\n.byte 32\n.byte 42\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 0\n.align 0\nL.909:\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 9\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 101\n.byte 115\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 32\n.byte 0\n.align 0\nL.908:\n.byte 87\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 0\n.align 0\nL.903:\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.900:\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 86\n.byte 69\n.byte 82\n.byte 89\n.byte 32\n.byte 83\n.byte 69\n.byte 82\n.byte 73\n.byte 79\n.byte 85\n.byte 83\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.894:\n.byte 32\n.byte 104\n.byte 97\n.byte 115\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 32\n.byte 106\n.byte 117\n.byte 115\n.byte 116\n.byte 32\n.byte 98\n.byte 101\n.byte 101\n.byte 110\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 97\n.byte 108\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.893:\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 79\n.byte 46\n.byte 75\n.byte 46\n.byte 44\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 118\n.byte 105\n.byte 100\n.byte 101\n.byte 100\n.byte 32\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 47\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 0\n.align 0\nL.890:\n.byte 87\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 109\n.byte 97\n.byte 99\n.byte 104\n.byte 105\n.byte 110\n.byte 101\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 40\n.byte 90\n.byte 32\n.byte 43\n.byte 32\n.byte 90\n.byte 41\n.byte 32\n.byte 47\n.byte 32\n.byte 90\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.886:\n.byte 40\n.byte 90\n.byte 32\n.byte 43\n.byte 32\n.byte 90\n.byte 41\n.byte 32\n.byte 47\n.byte 32\n.byte 90\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 115\n.byte 97\n.byte 102\n.byte 101\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.885:\n.byte 83\n.byte 105\n.byte 110\n.byte 99\n.byte 101\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 100\n.byte 101\n.byte 110\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 101\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 0\n.align 0\nL.881:\n.byte 83\n.byte 105\n.byte 109\n.byte 105\n.byte 108\n.byte 97\n.byte 114\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 114\n.byte 101\n.byte 112\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 104\n.byte 97\n.byte 118\n.byte 101\n.byte 32\n.byte 111\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 116\n.byte 105\n.byte 109\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.871:\n.byte 9\n.byte 9\n.byte 116\n.byte 104\n.byte 101\n.byte 121\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.870:\n.byte 9\n.byte 119\n.byte 104\n.byte 105\n.byte 99\n.byte 104\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 117\n.byte 110\n.byte 101\n.byte 113\n.byte 117\n.byte 97\n.byte 108\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 59\n.byte 10\n.byte 0\n.align 0\nL.869:\n.byte 9\n.byte 121\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 101\n.byte 100\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 59\n.byte 10\n.byte 0\n.align 0\nL.868:\n.byte 9\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 10\n.byte 0\n.align 0\nL.867:\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 10\n.byte 0\n.align 0\nL.866:\n.byte 87\n.byte 65\n.byte 82\n.byte 78\n.byte 73\n.byte 78\n.byte 71\n.byte 58\n.byte 32\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 10\n.byte 0\n.align 0\nL.848:\n.byte 9\n.byte 105\n.byte 110\n.byte 115\n.byte 116\n.byte 101\n.byte 97\n.byte 100\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 48\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.847:\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 40\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 45\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 3\nL.839:\n.long 0x88e368f1\n.long 0x3ed4f8b5\n.align 0\nL.837:\n.byte 37\n.byte 115\n.byte 58\n.byte 32\n.byte 32\n.byte 37\n.byte 115\n.byte 0\n.align 0\nL.836:\n.byte 70\n.byte 76\n.byte 65\n.byte 87\n.byte 0\n.align 0\nL.835:\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 0\n.align 0\nL.834:\n.byte 83\n.byte 69\n.byte 82\n.byte 73\n.byte 79\n.byte 85\n.byte 83\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 0\n.align 0\nL.833:\n.byte 70\n.byte 65\n.byte 73\n.byte 76\n.byte 85\n.byte 82\n.byte 69\n.byte 0\n.align 0\nL.827:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 80\n.byte 97\n.byte 103\n.byte 101\n.byte 58\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 10\n.byte 0\n.align 0\nL.826:\n.byte 10\n.byte 68\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 105\n.byte 115\n.byte 32\n.byte 114\n.byte 101\n.byte 115\n.byte 117\n.byte 109\n.byte 101\n.byte 115\n.byte 32\n.byte 97\n.byte 102\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 109\n.byte 105\n.byte 108\n.byte 101\n.byte 115\n.byte 116\n.byte 111\n.byte 110\n.byte 101\n.byte 32\n.byte 78\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 37\n.byte 100\n.byte 0\n.align 3\nL.824:\n.long 0x0\n.long 0xbff00000\n.align 0\nL.819:\n.byte 69\n.byte 78\n.byte 68\n.byte 32\n.byte 79\n.byte 70\n.byte 32\n.byte 84\n.byte 69\n.byte 83\n.byte 84\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.818:\n.byte 10\n.byte 65\n.byte 32\n.byte 116\n.byte 111\n.byte 116\n.byte 97\n.byte 108\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 102\n.byte 108\n.byte 111\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 112\n.byte 111\n.byte 105\n.byte 110\n.byte 116\n.byte 32\n.byte 101\n.byte 120\n.byte 99\n.byte 101\n.byte 112\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 119\n.byte 101\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 101\n.byte 103\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.815:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 69\n.byte 120\n.byte 99\n.byte 101\n.byte 108\n.byte 108\n.byte 101\n.byte 110\n.byte 116\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.814:\n.byte 32\n.byte 100\n.byte 117\n.byte 114\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 71\n.byte 114\n.byte 97\n.byte 100\n.byte 117\n.byte 97\n.byte 108\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.813:\n.byte 44\n.byte 10\n.byte 101\n.byte 120\n.byte 99\n.byte 101\n.byte 112\n.byte 116\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 112\n.byte 111\n.byte 115\n.byte 115\n.byte 105\n.byte 98\n.byte 108\n.byte 121\n.byte 32\n.byte 68\n.byte 111\n.byte 117\n.byte 98\n.byte 108\n.byte 101\n.byte 32\n.byte 82\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 0\n.align 0\nL.812:\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.809:\n.byte 56\n.byte 53\n.byte 52\n.byte 0\n.align 0\nL.808:\n.byte 55\n.byte 53\n.byte 52\n.byte 0\n.align 0\nL.805:\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 112\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 73\n.byte 69\n.byte 69\n.byte 69\n.byte 32\n.byte 115\n.byte 116\n.byte 97\n.byte 110\n.byte 100\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 80\n.byte 0\n.align 0\nL.804:\n.byte 82\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 111\n.byte 114\n.byte 109\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 0\n.align 0\nL.801:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 115\n.byte 101\n.byte 101\n.byte 109\n.byte 115\n.byte 32\n.byte 83\n.byte 97\n.byte 116\n.byte 105\n.byte 115\n.byte 102\n.byte 97\n.byte 99\n.byte 116\n.byte 111\n.byte 114\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.795:\n.byte 78\n.byte 111\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 117\n.byte 114\n.byte 101\n.byte 115\n.byte 44\n.byte 32\n.byte 100\n.byte 101\n.byte 102\n.byte 101\n.byte 99\n.byte 116\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 102\n.byte 108\n.byte 97\n.byte 119\n.byte 115\n.byte 32\n.byte 104\n.byte 97\n.byte 118\n.byte 101\n.byte 32\n.byte 98\n.byte 101\n.byte 101\n.byte 110\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.794:\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 39\n.byte 115\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 115\n.byte 101\n.byte 113\n.byte 117\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.793:\n.byte 80\n.byte 111\n.byte 116\n.byte 101\n.byte 110\n.byte 116\n.byte 105\n.byte 97\n.byte 108\n.byte 108\n.byte 121\n.byte 32\n.byte 102\n.byte 97\n.byte 116\n.byte 97\n.byte 108\n.byte 32\n.byte 70\n.byte 65\n.byte 73\n.byte 76\n.byte 85\n.byte 82\n.byte 69\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 104\n.byte 97\n.byte 118\n.byte 101\n.byte 32\n.byte 115\n.byte 112\n.byte 111\n.byte 105\n.byte 108\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 0\n.align 0\nL.790:\n.byte 117\n.byte 110\n.byte 97\n.byte 99\n.byte 99\n.byte 101\n.byte 112\n.byte 116\n.byte 97\n.byte 98\n.byte 108\n.byte 101\n.byte 32\n.byte 83\n.byte 101\n.byte 114\n.byte 105\n.byte 111\n.byte 117\n.byte 115\n.byte 32\n.byte 68\n.byte 101\n.byte 102\n.byte 101\n.byte 99\n.byte 116\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.789:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 104\n.byte 97\n.byte 115\n.byte 32\n.byte 0\n.align 0\nL.785:\n.byte 100\n.byte 101\n.byte 115\n.byte 112\n.byte 105\n.byte 116\n.byte 101\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 111\n.byte 110\n.byte 118\n.byte 101\n.byte 110\n.byte 105\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 68\n.byte 101\n.byte 102\n.byte 101\n.byte 99\n.byte 116\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.784:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 65\n.byte 99\n.byte 99\n.byte 101\n.byte 112\n.byte 116\n.byte 97\n.byte 98\n.byte 108\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.779:\n.byte 83\n.byte 97\n.byte 116\n.byte 105\n.byte 115\n.byte 102\n.byte 97\n.byte 99\n.byte 116\n.byte 111\n.byte 114\n.byte 121\n.byte 32\n.byte 116\n.byte 104\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 32\n.byte 102\n.byte 108\n.byte 97\n.byte 119\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.778:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 115\n.byte 101\n.byte 101\n.byte 109\n.byte 115\n.byte 32\n.byte 0\n.align 0\nL.767:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 32\n.byte 37\n.byte 45\n.byte 50\n.byte 57\n.byte 115\n.byte 32\n.byte 37\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.760:\n.byte 70\n.byte 76\n.byte 65\n.byte 87\n.byte 115\n.byte 32\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 61\n.byte 0\n.align 0\nL.759:\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 115\n.byte 32\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 61\n.byte 0\n.align 0\nL.758:\n.byte 83\n.byte 69\n.byte 82\n.byte 73\n.byte 79\n.byte 85\n.byte 83\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 115\n.byte 32\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 61\n.byte 0\n.align 0\nL.757:\n.byte 70\n.byte 65\n.byte 73\n.byte 76\n.byte 85\n.byte 82\n.byte 69\n.byte 115\n.byte 32\n.byte 32\n.byte 101\n.byte 110\n.byte 99\n.byte 111\n.byte 117\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 61\n.byte 0\n.align 0\nL.753:\n.byte 10\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 84\n.byte 114\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 32\n.byte 48\n.byte 32\n.byte 47\n.byte 32\n.byte 48\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 101\n.byte 115\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 0\n.align 0\nL.752:\n.byte 32\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.749:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 84\n.byte 114\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 32\n.byte 49\n.byte 32\n.byte 47\n.byte 32\n.byte 48\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 101\n.byte 115\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 0\n.align 0\nL.748:\n.byte 87\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 109\n.byte 101\n.byte 115\n.byte 115\n.byte 97\n.byte 103\n.byte 101\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 47\n.byte 111\n.byte 114\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 115\n.byte 32\n.byte 100\n.byte 111\n.byte 101\n.byte 115\n.byte 32\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 101\n.byte 63\n.byte 10\n.byte 0\n.align 0\nL.747:\n.byte 32\n.byte 32\n.byte 105\n.byte 110\n.byte 115\n.byte 116\n.byte 101\n.byte 97\n.byte 100\n.byte 44\n.byte 32\n.byte 88\n.byte 32\n.byte 47\n.byte 32\n.byte 88\n.byte 32\n.byte 45\n.byte 32\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 45\n.byte 32\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.746:\n.byte 32\n.byte 32\n.byte 88\n.byte 32\n.byte 47\n.byte 32\n.byte 88\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 49\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 110\n.byte 32\n.byte 88\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.741:\n.byte 32\n.byte 32\n.byte 88\n.byte 32\n.byte 47\n.byte 32\n.byte 88\n.byte 32\n.byte 32\n.byte 116\n.byte 114\n.byte 97\n.byte 112\n.byte 115\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 110\n.byte 32\n.byte 88\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 103\n.byte 10\n.byte 0\n.align 0\nL.727:\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 102\n.byte 97\n.byte 114\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 49\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.726:\n.byte 32\n.byte 117\n.byte 110\n.byte 98\n.byte 97\n.byte 108\n.byte 97\n.byte 110\n.byte 99\n.byte 101\n.byte 100\n.byte 32\n.byte 114\n.byte 97\n.byte 110\n.byte 103\n.byte 101\n.byte 59\n.byte 32\n.byte 85\n.byte 102\n.byte 84\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 42\n.byte 32\n.byte 86\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 9\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.725:\n.byte 66\n.byte 97\n.byte 100\n.byte 108\n.byte 121\n.byte 0\n.align 0\nL.718:\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 102\n.byte 97\n.byte 114\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 40\n.byte 90\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 50\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.717:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.705:\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 102\n.byte 97\n.byte 114\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 40\n.byte 90\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.704:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 119\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.687:\n.byte 43\n.byte 45\n.byte 37\n.byte 103\n.byte 44\n.byte 32\n.byte 43\n.byte 45\n.byte 37\n.byte 103\n.byte 10\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 43\n.byte 45\n.byte 37\n.byte 103\n.byte 32\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 117\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 46\n.byte 0\n.align 0\nL.686:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 105\n.byte 110\n.byte 118\n.byte 111\n.byte 108\n.byte 118\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 0\n.align 0\nL.680:\n.byte 97\n.byte 98\n.byte 111\n.byte 118\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.679:\n.byte 65\n.byte 110\n.byte 121\n.byte 32\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 115\n.byte 101\n.byte 112\n.byte 97\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 42\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 111\n.byte 110\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.678:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 86\n.byte 32\n.byte 47\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.677:\n.byte 78\n.byte 111\n.byte 32\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 97\n.byte 108\n.byte 101\n.byte 100\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 86\n.byte 32\n.byte 42\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.676:\n.byte 84\n.byte 104\n.byte 101\n.byte 114\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 32\n.byte 115\n.byte 97\n.byte 116\n.byte 117\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 98\n.byte 101\n.byte 99\n.byte 97\n.byte 117\n.byte 115\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 115\n.byte 121\n.byte 115\n.byte 116\n.byte 101\n.byte 109\n.byte 32\n.byte 116\n.byte 114\n.byte 97\n.byte 112\n.byte 115\n.byte 32\n.byte 111\n.byte 110\n.byte 32\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.675:\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 115\n.byte 97\n.byte 116\n.byte 117\n.byte 114\n.byte 97\n.byte 116\n.byte 101\n.byte 115\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 86\n.byte 48\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.672:\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 86\n.byte 32\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.663:\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 112\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 9\n.byte 115\n.byte 104\n.byte 114\n.byte 105\n.byte 110\n.byte 107\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.660:\n.byte 45\n.byte 40\n.byte 45\n.byte 89\n.byte 41\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 89\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.659:\n.byte 102\n.byte 105\n.byte 110\n.byte 100\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 0\n.align 0\nL.658:\n.byte 83\n.byte 101\n.byte 101\n.byte 109\n.byte 115\n.byte 32\n.byte 79\n.byte 46\n.byte 75\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.655:\n.byte 84\n.byte 114\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 111\n.byte 110\n.byte 32\n.byte 89\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.654:\n.byte 67\n.byte 97\n.byte 110\n.byte 32\n.byte 96\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 45\n.byte 89\n.byte 39\n.byte 32\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 63\n.byte 10\n.byte 0\n.align 0\nL.647:\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 103\n.byte 101\n.byte 110\n.byte 101\n.byte 114\n.byte 97\n.byte 116\n.byte 101\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.646:\n.byte 83\n.byte 101\n.byte 97\n.byte 114\n.byte 99\n.byte 104\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 58\n.byte 10\n.byte 0\n.align 0\nL.645:\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 32\n.byte 110\n.byte 111\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 114\n.byte 101\n.byte 112\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.637:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 112\n.byte 111\n.byte 119\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 90\n.byte 94\n.byte 81\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 114\n.byte 32\n.byte 110\n.byte 101\n.byte 97\n.byte 114\n.byte 108\n.byte 121\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 101\n.byte 109\n.byte 101\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.636:\n.byte 65\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 97\n.byte 99\n.byte 121\n.byte 32\n.byte 115\n.byte 101\n.byte 101\n.byte 109\n.byte 115\n.byte 32\n.byte 97\n.byte 100\n.byte 101\n.byte 113\n.byte 117\n.byte 97\n.byte 116\n.byte 101\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.629:\n.byte 9\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 105\n.byte 110\n.byte 118\n.byte 111\n.byte 108\n.byte 118\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 105\n.byte 110\n.byte 121\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 114\n.byte 97\n.byte 116\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.628:\n.byte 9\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 109\n.byte 117\n.byte 99\n.byte 104\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 115\n.byte 112\n.byte 111\n.byte 105\n.byte 108\n.byte 32\n.byte 102\n.byte 105\n.byte 110\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 97\n.byte 108\n.byte 10\n.byte 0\n.align 0\nL.627:\n.byte 9\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.626:\n.byte 9\n.byte 40\n.byte 49\n.byte 32\n.byte 43\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 59\n.byte 10\n.byte 0\n.align 0\nL.625:\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 10\n.byte 0\n.align 0\nL.624:\n.byte 67\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 101\n.byte 100\n.byte 0\n.align 0\nL.617:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 88\n.byte 94\n.byte 40\n.byte 40\n.byte 88\n.byte 32\n.byte 43\n.byte 32\n.byte 49\n.byte 41\n.byte 32\n.byte 47\n.byte 32\n.byte 40\n.byte 88\n.byte 32\n.byte 45\n.byte 32\n.byte 49\n.byte 41\n.byte 41\n.byte 32\n.byte 118\n.byte 115\n.byte 46\n.byte 32\n.byte 101\n.byte 120\n.byte 112\n.byte 40\n.byte 50\n.byte 41\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 88\n.byte 32\n.byte 45\n.byte 62\n.byte 32\n.byte 49\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.613:\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 79\n.byte 46\n.byte 75\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.610:\n.byte 32\n.byte 32\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.609:\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 98\n.byte 101\n.byte 116\n.byte 119\n.byte 101\n.byte 101\n.byte 110\n.byte 32\n.byte 48\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 10\n.byte 0\n.align 0\nL.605:\n.byte 97\n.byte 99\n.byte 116\n.byte 117\n.byte 97\n.byte 108\n.byte 108\n.byte 121\n.byte 32\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 121\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 115\n.byte 58\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.604:\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 97\n.byte 102\n.byte 102\n.byte 108\n.byte 105\n.byte 99\n.byte 116\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 101\n.byte 120\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 10\n.byte 9\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 59\n.byte 10\n.byte 0\n.align 0\nL.603:\n.byte 85\n.byte 102\n.byte 84\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 61\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 10\n.byte 111\n.byte 110\n.byte 108\n.byte 121\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 0\n.align 0\nL.602:\n.byte 83\n.byte 105\n.byte 110\n.byte 99\n.byte 101\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 111\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 115\n.byte 32\n.byte 98\n.byte 101\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.601:\n.byte 82\n.byte 97\n.byte 110\n.byte 103\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 110\n.byte 97\n.byte 114\n.byte 114\n.byte 111\n.byte 119\n.byte 59\n.byte 32\n.byte 85\n.byte 49\n.byte 94\n.byte 37\n.byte 100\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.596:\n.byte 109\n.byte 101\n.byte 114\n.byte 101\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 111\n.byte 102\n.byte 102\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.595:\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 115\n.byte 117\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 32\n.byte 108\n.byte 97\n.byte 114\n.byte 103\n.byte 101\n.byte 114\n.byte 32\n.byte 82\n.byte 101\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 110\n.byte 32\n.byte 0\n.align 0\nL.594:\n.byte 32\n.byte 98\n.byte 101\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 119\n.byte 104\n.byte 105\n.byte 99\n.byte 104\n.byte 0\n.align 0\nL.593:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.592:\n.byte 88\n.byte 32\n.byte 47\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 49\n.byte 32\n.byte 43\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.591:\n.byte 88\n.byte 32\n.byte 47\n.byte 32\n.byte 90\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 115\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.588:\n.byte 101\n.byte 110\n.byte 99\n.byte 111\n.byte 117\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 97\n.byte 108\n.byte 116\n.byte 104\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 32\n.byte 97\n.byte 99\n.byte 116\n.byte 117\n.byte 97\n.byte 108\n.byte 108\n.byte 121\n.byte 10\n.byte 0\n.align 0\nL.587:\n.byte 32\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 32\n.byte 40\n.byte 102\n.byte 40\n.byte 88\n.byte 41\n.byte 32\n.byte 45\n.byte 32\n.byte 102\n.byte 40\n.byte 90\n.byte 41\n.byte 41\n.byte 32\n.byte 47\n.byte 32\n.byte 40\n.byte 88\n.byte 32\n.byte 45\n.byte 32\n.byte 90\n.byte 41\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.586:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 105\n.byte 102\n.byte 32\n.byte 40\n.byte 88\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 90\n.byte 41\n.byte 32\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 32\n.byte 32\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 0\n.align 0\nL.585:\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 117\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 110\n.byte 32\n.byte 105\n.byte 110\n.byte 110\n.byte 111\n.byte 99\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 115\n.byte 116\n.byte 97\n.byte 116\n.byte 101\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.584:\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 83\n.byte 69\n.byte 82\n.byte 73\n.byte 79\n.byte 85\n.byte 83\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 10\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 99\n.byte 97\n.byte 117\n.byte 115\n.byte 101\n.byte 115\n.byte 32\n.byte 0\n.align 0\nL.583:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 83\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 44\n.byte 32\n.byte 0\n.align 0\nL.582:\n.byte 121\n.byte 101\n.byte 116\n.byte 32\n.byte 88\n.byte 32\n.byte 45\n.byte 32\n.byte 90\n.byte 32\n.byte 121\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 115\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.581:\n.byte 88\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 9\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 101\n.byte 113\n.byte 117\n.byte 97\n.byte 108\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.576:\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 47\n.byte 32\n.byte 85\n.byte 102\n.byte 84\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 101\n.byte 100\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.567:\n.byte 40\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 111\n.byte 102\n.byte 102\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 85\n.byte 102\n.byte 84\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 41\n.byte 32\n.byte 60\n.byte 32\n.byte 69\n.byte 48\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.566:\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 103\n.byte 114\n.byte 97\n.byte 100\n.byte 117\n.byte 97\n.byte 108\n.byte 59\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 117\n.byte 114\n.byte 115\n.byte 32\n.byte 65\n.byte 98\n.byte 115\n.byte 111\n.byte 108\n.byte 117\n.byte 116\n.byte 101\n.byte 32\n.byte 69\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 61\n.byte 10\n.byte 0\n.align 0\nL.561:\n.byte 124\n.byte 81\n.byte 32\n.byte 45\n.byte 32\n.byte 89\n.byte 124\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.560:\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 32\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 81\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 89\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.559:\n.byte 81\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 89\n.byte 32\n.byte 119\n.byte 104\n.byte 105\n.byte 108\n.byte 101\n.byte 32\n.byte 100\n.byte 101\n.byte 110\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 124\n.byte 81\n.byte 32\n.byte 45\n.byte 32\n.byte 89\n.byte 124\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 48\n.byte 59\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 115\n.byte 101\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.558:\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 117\n.byte 115\n.byte 101\n.byte 115\n.byte 32\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 44\n.byte 32\n.byte 119\n.byte 104\n.byte 105\n.byte 99\n.byte 104\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 10\n.byte 0\n.align 0\nL.556:\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 32\n.byte 109\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 108\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.555:\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 100\n.byte 111\n.byte 119\n.byte 110\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.554:\n.byte 97\n.byte 112\n.byte 112\n.byte 114\n.byte 111\n.byte 97\n.byte 99\n.byte 104\n.byte 32\n.byte 97\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.553:\n.byte 69\n.byte 105\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 97\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 97\n.byte 99\n.byte 121\n.byte 32\n.byte 100\n.byte 101\n.byte 116\n.byte 101\n.byte 114\n.byte 105\n.byte 111\n.byte 114\n.byte 97\n.byte 116\n.byte 101\n.byte 115\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.541:\n.byte 83\n.byte 109\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 115\n.byte 116\n.byte 114\n.byte 105\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 112\n.byte 111\n.byte 115\n.byte 105\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 69\n.byte 48\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.540:\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 110\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 116\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.539:\n.byte 68\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 101\n.byte 110\n.byte 99\n.byte 101\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 115\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 97\n.byte 32\n.byte 104\n.byte 105\n.byte 103\n.byte 104\n.byte 101\n.byte 114\n.byte 0\n.align 0\nL.536:\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 110\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 101\n.byte 110\n.byte 99\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.535:\n.byte 80\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 116\n.byte 115\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 97\n.byte 32\n.byte 104\n.byte 105\n.byte 103\n.byte 104\n.byte 101\n.byte 114\n.byte 0\n.align 0\nL.528:\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 80\n.byte 115\n.byte 101\n.byte 117\n.byte 100\n.byte 111\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.527:\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 32\n.byte 115\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 100\n.byte 108\n.byte 121\n.byte 32\n.byte 112\n.byte 111\n.byte 115\n.byte 105\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.526:\n.byte 112\n.byte 111\n.byte 115\n.byte 105\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 44\n.byte 32\n.byte 105\n.byte 115\n.byte 110\n.byte 39\n.byte 116\n.byte 59\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.525:\n.byte 66\n.byte 117\n.byte 116\n.byte 32\n.byte 45\n.byte 80\n.byte 115\n.byte 101\n.byte 117\n.byte 100\n.byte 111\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 44\n.byte 32\n.byte 119\n.byte 104\n.byte 105\n.byte 99\n.byte 104\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 98\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.522:\n.byte 80\n.byte 115\n.byte 101\n.byte 117\n.byte 100\n.byte 111\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 58\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.521:\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 100\n.byte 108\n.byte 121\n.byte 32\n.byte 110\n.byte 101\n.byte 103\n.byte 97\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.520:\n.byte 80\n.byte 111\n.byte 115\n.byte 105\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 101\n.byte 120\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 97\n.byte 110\n.byte 10\n.byte 0\n.align 0\nL.507:\n.byte 109\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 108\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.483:\n.byte 83\n.byte 101\n.byte 101\n.byte 107\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 115\n.byte 32\n.byte 85\n.byte 102\n.byte 84\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 69\n.byte 48\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.480:\n.byte 46\n.byte 46\n.byte 46\n.byte 32\n.byte 110\n.byte 111\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 114\n.byte 101\n.byte 112\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.477:\n.byte 9\n.byte 105\n.byte 110\n.byte 118\n.byte 111\n.byte 108\n.byte 118\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 114\n.byte 97\n.byte 116\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.476:\n.byte 69\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 115\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 105\n.byte 110\n.byte 118\n.byte 97\n.byte 108\n.byte 105\n.byte 100\n.byte 97\n.byte 116\n.byte 101\n.byte 32\n.byte 102\n.byte 105\n.byte 110\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 97\n.byte 108\n.byte 32\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.455:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 112\n.byte 111\n.byte 119\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 90\n.byte 94\n.byte 105\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 115\n.byte 109\n.byte 97\n.byte 108\n.byte 108\n.byte 32\n.byte 73\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 90\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.452:\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 108\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 0\n.align 0\nL.450:\n.byte 116\n.byte 111\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 117\n.byte 108\n.byte 112\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.449:\n.byte 79\n.byte 98\n.byte 115\n.byte 101\n.byte 114\n.byte 118\n.byte 101\n.byte 100\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 115\n.byte 32\n.byte 114\n.byte 117\n.byte 110\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 0\n.align 0\nL.448:\n.byte 83\n.byte 113\n.byte 117\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 111\n.byte 111\n.byte 116\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 101\n.byte 105\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.445:\n.byte 83\n.byte 113\n.byte 117\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 111\n.byte 111\n.byte 116\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.440:\n.byte 83\n.byte 113\n.byte 117\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 111\n.byte 111\n.byte 116\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.435:\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 115\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 115\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.434:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 94\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.433:\n.byte 65\n.byte 110\n.byte 111\n.byte 109\n.byte 97\n.byte 108\n.byte 111\n.byte 117\n.byte 115\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 73\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 32\n.byte 60\n.byte 32\n.byte 0\n.align 0\nL.393:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.371:\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 40\n.byte 88\n.byte 41\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 110\n.byte 45\n.byte 109\n.byte 111\n.byte 110\n.byte 111\n.byte 116\n.byte 111\n.byte 110\n.byte 105\n.byte 99\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 88\n.byte 32\n.byte 110\n.byte 101\n.byte 97\n.byte 114\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.370:\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 104\n.byte 97\n.byte 115\n.byte 32\n.byte 112\n.byte 97\n.byte 115\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 97\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 77\n.byte 111\n.byte 110\n.byte 111\n.byte 116\n.byte 111\n.byte 110\n.byte 105\n.byte 99\n.byte 105\n.byte 116\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.353:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 109\n.byte 111\n.byte 110\n.byte 111\n.byte 116\n.byte 111\n.byte 110\n.byte 105\n.byte 99\n.byte 105\n.byte 116\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.342:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 105\n.byte 102\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 40\n.byte 88\n.byte 32\n.byte 42\n.byte 32\n.byte 88\n.byte 41\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 88\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 73\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 88\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.337:\n.byte 83\n.byte 113\n.byte 117\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 111\n.byte 111\n.byte 116\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 48\n.byte 46\n.byte 48\n.byte 44\n.byte 32\n.byte 45\n.byte 48\n.byte 46\n.byte 48\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 49\n.byte 46\n.byte 48\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 0\n.align 0\nL.335:\n.byte 10\n.byte 82\n.byte 117\n.byte 110\n.byte 110\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 115\n.byte 113\n.byte 117\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 111\n.byte 111\n.byte 116\n.byte 40\n.byte 120\n.byte 41\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.334:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 78\n.byte 111\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 117\n.byte 114\n.byte 101\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 32\n.byte 112\n.byte 97\n.byte 105\n.byte 114\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.333:\n.byte 88\n.byte 32\n.byte 42\n.byte 32\n.byte 89\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 89\n.byte 32\n.byte 42\n.byte 32\n.byte 88\n.byte 32\n.byte 116\n.byte 114\n.byte 105\n.byte 97\n.byte 108\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 3\nL.324:\n.long 0x0\n.long 0x40080000\n.align 0\nL.323:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 111\n.byte 110\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 114\n.byte 97\n.byte 110\n.byte 100\n.byte 111\n.byte 109\n.byte 32\n.byte 112\n.byte 97\n.byte 105\n.byte 114\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.322:\n.byte 68\n.byte 111\n.byte 101\n.byte 115\n.byte 32\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 109\n.byte 117\n.byte 116\n.byte 101\n.byte 63\n.byte 32\n.byte 32\n.byte 0\n.align 0\nL.319:\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 40\n.byte 115\n.byte 41\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 103\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 117\n.byte 114\n.byte 101\n.byte 40\n.byte 115\n.byte 41\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 10\n.byte 40\n.byte 110\n.byte 111\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 97\n.byte 98\n.byte 111\n.byte 118\n.byte 101\n.byte 41\n.byte 32\n.byte 99\n.byte 111\n.byte 117\n.byte 110\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 111\n.byte 110\n.byte 101\n.byte 32\n.byte 102\n.byte 108\n.byte 97\n.byte 119\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 102\n.byte 105\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 116\n.byte 97\n.byte 108\n.byte 108\n.byte 121\n.byte 32\n.byte 98\n.byte 101\n.byte 108\n.byte 111\n.byte 119\n.byte 0\n.align 0\nL.317:\n.byte 83\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 121\n.byte 32\n.byte 98\n.byte 105\n.byte 116\n.byte 32\n.byte 117\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.316:\n.byte 83\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 121\n.byte 32\n.byte 98\n.byte 105\n.byte 116\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 97\n.byte 114\n.byte 101\n.byte 110\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 117\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.299:\n.byte 67\n.byte 104\n.byte 101\n.byte 99\n.byte 107\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 115\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 121\n.byte 32\n.byte 98\n.byte 105\n.byte 116\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.296:\n.byte 40\n.byte 88\n.byte 32\n.byte 45\n.byte 32\n.byte 89\n.byte 41\n.byte 32\n.byte 43\n.byte 32\n.byte 40\n.byte 89\n.byte 32\n.byte 45\n.byte 32\n.byte 88\n.byte 41\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 110\n.byte 32\n.byte 122\n.byte 101\n.byte 114\n.byte 111\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.293:\n.byte 65\n.byte 100\n.byte 100\n.byte 105\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 47\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 110\n.byte 101\n.byte 105\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.292:\n.byte 65\n.byte 100\n.byte 100\n.byte 47\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 0\n.align 0\nL.289:\n.byte 65\n.byte 100\n.byte 100\n.byte 105\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 47\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.282:\n.byte 65\n.byte 100\n.byte 100\n.byte 47\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.277:\n.byte 73\n.byte 110\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 108\n.byte 101\n.byte 116\n.byte 101\n.byte 32\n.byte 99\n.byte 97\n.byte 114\n.byte 114\n.byte 121\n.byte 45\n.byte 112\n.byte 114\n.byte 111\n.byte 112\n.byte 97\n.byte 103\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 65\n.byte 100\n.byte 100\n.byte 105\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 0\nL.273:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 42\n.byte 32\n.byte 40\n.byte 32\n.byte 49\n.byte 32\n.byte 47\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 41\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 49\n.byte 0\n.align 0\nL.271:\n.byte 47\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 101\n.byte 105\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.268:\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.265:\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 0\nL.262:\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.257:\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 0\nL.254:\n.byte 42\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 101\n.byte 105\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.253:\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.250:\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.240:\n.byte 88\n.byte 32\n.byte 42\n.byte 32\n.byte 40\n.byte 49\n.byte 47\n.byte 88\n.byte 41\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 49\n.byte 0\n.align 0\nL.221:\n.byte 67\n.byte 104\n.byte 101\n.byte 99\n.byte 107\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 111\n.byte 110\n.byte 32\n.byte 109\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 121\n.byte 44\n.byte 32\n.byte 100\n.byte 105\n.byte 118\n.byte 105\n.byte 100\n.byte 101\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 97\n.byte 100\n.byte 100\n.byte 47\n.byte 115\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.220:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 42\n.byte 44\n.byte 32\n.byte 47\n.byte 44\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 45\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 104\n.byte 97\n.byte 118\n.byte 101\n.byte 32\n.byte 103\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 44\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 121\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.217:\n.byte 32\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 32\n.byte 32\n.byte 105\n.byte 102\n.byte 32\n.byte 40\n.byte 88\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 49\n.byte 46\n.byte 48\n.byte 41\n.byte 32\n.byte 123\n.byte 46\n.byte 46\n.byte 46\n.byte 46\n.byte 46\n.byte 125\n.byte 32\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 32\n.byte 123\n.byte 46\n.byte 46\n.byte 46\n.byte 47\n.byte 40\n.byte 88\n.byte 45\n.byte 49\n.byte 46\n.byte 48\n.byte 41\n.byte 46\n.byte 46\n.byte 46\n.byte 125\n.byte 10\n.byte 0\n.align 0\nL.216:\n.byte 32\n.byte 32\n.byte 115\n.byte 117\n.byte 99\n.byte 104\n.byte 32\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 97\n.byte 117\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 97\n.byte 103\n.byte 97\n.byte 105\n.byte 110\n.byte 115\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 122\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 97\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.215:\n.byte 32\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 121\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 115\n.byte 32\n.byte 32\n.byte 40\n.byte 49\n.byte 45\n.byte 85\n.byte 49\n.byte 41\n.byte 32\n.byte 45\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 32\n.byte 44\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 101\n.byte 98\n.byte 121\n.byte 32\n.byte 118\n.byte 105\n.byte 116\n.byte 105\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 10\n.byte 0\n.align 0\nL.214:\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 32\n.byte 40\n.byte 49\n.byte 45\n.byte 85\n.byte 49\n.byte 41\n.byte 32\n.byte 60\n.byte 32\n.byte 49\n.byte 32\n.byte 32\n.byte 97\n.byte 108\n.byte 116\n.byte 104\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 10\n.byte 0\n.align 0\nL.211:\n.byte 45\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 115\n.byte 32\n.byte 71\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 68\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 44\n.byte 32\n.byte 115\n.byte 111\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 99\n.byte 101\n.byte 108\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 111\n.byte 98\n.byte 115\n.byte 99\n.byte 117\n.byte 114\n.byte 101\n.byte 100\n.byte 0\n.align 0\nL.206:\n.byte 42\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 47\n.byte 111\n.byte 114\n.byte 32\n.byte 47\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 108\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 0\n.align 0\nL.202:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 49\n.byte 47\n.byte 49\n.byte 46\n.byte 48\n.byte 48\n.byte 48\n.byte 46\n.byte 46\n.byte 49\n.byte 32\n.byte 62\n.byte 61\n.byte 32\n.byte 49\n.byte 0\n.align 0\nL.200:\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 71\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 68\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 44\n.byte 32\n.byte 115\n.byte 111\n.byte 32\n.byte 88\n.byte 47\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 88\n.byte 0\n.align 0\nL.195:\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 71\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 68\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 44\n.byte 32\n.byte 115\n.byte 111\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 32\n.byte 101\n.byte 120\n.byte 99\n.byte 101\n.byte 101\n.byte 100\n.byte 32\n.byte 49\n.byte 32\n.byte 117\n.byte 108\n.byte 112\n.byte 10\n.byte 111\n.byte 114\n.byte 32\n.byte 32\n.byte 49\n.byte 47\n.byte 51\n.byte 32\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 32\n.byte 51\n.byte 47\n.byte 57\n.byte 32\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 32\n.byte 57\n.byte 47\n.byte 50\n.byte 55\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 97\n.byte 103\n.byte 114\n.byte 101\n.byte 101\n.byte 0\n.align 0\nL.191:\n.byte 42\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 102\n.byte 105\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.189:\n.byte 42\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 71\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 68\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 44\n.byte 32\n.byte 115\n.byte 111\n.byte 32\n.byte 49\n.byte 42\n.byte 88\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 88\n.byte 0\n.align 0\nL.186:\n.byte 10\n.byte 67\n.byte 104\n.byte 101\n.byte 99\n.byte 107\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 103\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 42\n.byte 44\n.byte 32\n.byte 47\n.byte 44\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 45\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.185:\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 109\n.byte 97\n.byte 108\n.byte 105\n.byte 122\n.byte 101\n.byte 100\n.byte 44\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 98\n.byte 101\n.byte 46\n.byte 0\n.align 0\nL.180:\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 109\n.byte 97\n.byte 108\n.byte 105\n.byte 122\n.byte 101\n.byte 100\n.byte 32\n.byte 88\n.byte 61\n.byte 89\n.byte 44\n.byte 88\n.byte 43\n.byte 90\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 89\n.byte 43\n.byte 90\n.byte 33\n.byte 0\n.align 0\nL.176:\n.byte 114\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 108\n.byte 121\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 105\n.byte 102\n.byte 105\n.byte 99\n.byte 97\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 101\n.byte 99\n.byte 105\n.byte 109\n.byte 97\n.byte 108\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.175:\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 101\n.byte 108\n.byte 121\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 97\n.byte 98\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 32\n.byte 66\n.byte 45\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 44\n.byte 32\n.byte 105\n.byte 46\n.byte 101\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.174:\n.byte 83\n.byte 111\n.byte 109\n.byte 101\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 101\n.byte 120\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 10\n.byte 0\n.align 0\nL.168:\n.byte 111\n.byte 102\n.byte 32\n.byte 97\n.byte 110\n.byte 10\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 45\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 0\nL.167:\n.byte 90\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 90\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 0\n.align 0\nL.166:\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 101\n.byte 120\n.byte 97\n.byte 99\n.byte 116\n.byte 32\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 97\n.byte 32\n.byte 114\n.byte 101\n.byte 115\n.byte 117\n.byte 108\n.byte 116\n.byte 10\n.byte 0\n.align 0\nL.165:\n.byte 66\n.byte 101\n.byte 99\n.byte 97\n.byte 117\n.byte 115\n.byte 101\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 117\n.byte 110\n.byte 117\n.byte 115\n.byte 117\n.byte 97\n.byte 108\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 102\n.byte 0\n.align 0\nL.161:\n.byte 9\n.byte 85\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 90\n.byte 50\n.byte 32\n.byte 45\n.byte 32\n.byte 85\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.160:\n.byte 9\n.byte 85\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 90\n.byte 49\n.byte 32\n.byte 45\n.byte 32\n.byte 85\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.159:\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 0\nL.158:\n.byte 0\n.align 0\nL.151:\n.byte 84\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 102\n.byte 101\n.byte 97\n.byte 116\n.byte 117\n.byte 114\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 102\n.byte 117\n.byte 114\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.146:\n.byte 80\n.byte 111\n.byte 115\n.byte 115\n.byte 105\n.byte 98\n.byte 108\n.byte 121\n.byte 32\n.byte 115\n.byte 111\n.byte 109\n.byte 101\n.byte 32\n.byte 112\n.byte 97\n.byte 114\n.byte 116\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 0\n.align 0\nL.145:\n.byte 98\n.byte 121\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 45\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 101\n.byte 32\n.byte 101\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 101\n.byte 120\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.144:\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 115\n.byte 121\n.byte 109\n.byte 112\n.byte 116\n.byte 111\n.byte 109\n.byte 115\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 111\n.byte 110\n.byte 115\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 110\n.byte 99\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 101\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.143:\n.byte 114\n.byte 101\n.byte 115\n.byte 112\n.byte 101\n.byte 99\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 108\n.byte 121\n.byte 32\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 10\n.byte 0\n.align 0\nL.142:\n.byte 68\n.byte 105\n.byte 115\n.byte 97\n.byte 103\n.byte 114\n.byte 101\n.byte 101\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 97\n.byte 109\n.byte 111\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 115\n.byte 32\n.byte 88\n.byte 49\n.byte 44\n.byte 32\n.byte 89\n.byte 49\n.byte 44\n.byte 32\n.byte 90\n.byte 49\n.byte 44\n.byte 10\n.byte 0\n.align 0\nL.120:\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 119\n.byte 111\n.byte 114\n.byte 115\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 110\n.byte 32\n.byte 53\n.byte 32\n.byte 100\n.byte 101\n.byte 99\n.byte 105\n.byte 109\n.byte 97\n.byte 108\n.byte 32\n.byte 102\n.byte 105\n.byte 103\n.byte 117\n.byte 114\n.byte 101\n.byte 115\n.byte 32\n.byte 32\n.byte 0\n.align 0\nL.118:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 105\n.byte 102\n.byte 105\n.byte 99\n.byte 97\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 37\n.byte 102\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.117:\n.byte 108\n.byte 111\n.byte 103\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 105\n.byte 99\n.byte 32\n.byte 101\n.byte 110\n.byte 99\n.byte 111\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 104\n.byte 97\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 101\n.byte 114\n.byte 105\n.byte 122\n.byte 101\n.byte 100\n.byte 32\n.byte 115\n.byte 111\n.byte 108\n.byte 101\n.byte 108\n.byte 121\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 85\n.byte 49\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.114:\n.byte 111\n.byte 102\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 105\n.byte 102\n.byte 105\n.byte 99\n.byte 97\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 44\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 105\n.byte 116\n.byte 115\n.byte 101\n.byte 108\n.byte 102\n.byte 44\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 109\n.byte 105\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 102\n.byte 108\n.byte 97\n.byte 119\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.113:\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 101\n.byte 114\n.byte 105\n.byte 122\n.byte 101\n.byte 100\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 73\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 10\n.byte 0\n.align 0\nL.100:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 102\n.byte 117\n.byte 122\n.byte 122\n.byte 121\n.byte 44\n.byte 88\n.byte 61\n.byte 49\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 32\n.byte 88\n.byte 45\n.byte 49\n.byte 47\n.byte 50\n.byte 45\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 0\n.align 0\nL.96:\n.byte 40\n.byte 49\n.byte 45\n.byte 85\n.byte 49\n.byte 41\n.byte 45\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 60\n.byte 32\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 70\n.byte 65\n.byte 76\n.byte 83\n.byte 69\n.byte 44\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 46\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 115\n.byte 63\n.byte 0\n.align 3\nL.94:\n.long 0x0\n.long 0x40240000\n.align 0\nL.89:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 103\n.byte 111\n.byte 111\n.byte 100\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 50\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 49\n.byte 48\n.byte 0\n.align 0\nL.85:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 98\n.byte 105\n.byte 103\n.byte 58\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 111\n.byte 102\n.byte 102\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 98\n.byte 108\n.byte 101\n.byte 109\n.byte 115\n.byte 0\n.align 0\nL.83:\n.byte 77\n.byte 89\n.byte 83\n.byte 84\n.byte 69\n.byte 82\n.byte 89\n.byte 58\n.byte 32\n.byte 114\n.byte 101\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.82:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 105\n.byte 114\n.byte 109\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 3\nL.79:\n.long 0x47ae147b\n.long 0x3f847ae1\n.align 0\nL.78:\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 98\n.byte 101\n.byte 116\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 99\n.byte 108\n.byte 111\n.byte 115\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 114\n.byte 101\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 115\n.byte 101\n.byte 112\n.byte 97\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 85\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.77:\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 105\n.byte 114\n.byte 109\n.byte 115\n.byte 32\n.byte 99\n.byte 108\n.byte 111\n.byte 115\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 114\n.byte 101\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 115\n.byte 101\n.byte 112\n.byte 97\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 85\n.byte 49\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.62:\n.byte 82\n.byte 101\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 114\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 10\n.byte 32\n.byte 0\n.align 0\nL.61:\n.byte 67\n.byte 108\n.byte 111\n.byte 115\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 114\n.byte 101\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 115\n.byte 101\n.byte 112\n.byte 97\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 85\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 10\n.byte 0\n.align 0\nL.55:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 102\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.46:\n.byte 83\n.byte 101\n.byte 97\n.byte 114\n.byte 99\n.byte 104\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.45:\n.byte 10\n.byte 0\n.align 0\nL.44:\n.byte 45\n.byte 49\n.byte 44\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 49\n.byte 47\n.byte 50\n.byte 44\n.byte 32\n.byte 49\n.byte 44\n.byte 32\n.byte 50\n.byte 44\n.byte 32\n.byte 51\n.byte 44\n.byte 32\n.byte 52\n.byte 44\n.byte 32\n.byte 53\n.byte 44\n.byte 32\n.byte 57\n.byte 44\n.byte 32\n.byte 50\n.byte 55\n.byte 44\n.byte 32\n.byte 51\n.byte 50\n.byte 32\n.byte 38\n.byte 32\n.byte 50\n.byte 52\n.byte 48\n.byte 32\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 79\n.byte 46\n.byte 75\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.39:\n.byte 53\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 52\n.byte 43\n.byte 49\n.byte 44\n.byte 32\n.byte 50\n.byte 52\n.byte 48\n.byte 47\n.byte 51\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 56\n.byte 48\n.byte 44\n.byte 32\n.byte 50\n.byte 52\n.byte 48\n.byte 47\n.byte 52\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 54\n.byte 48\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 50\n.byte 52\n.byte 48\n.byte 47\n.byte 53\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 52\n.byte 56\n.byte 0\n.align 0\nL.35:\n.byte 57\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 51\n.byte 42\n.byte 51\n.byte 44\n.byte 32\n.byte 50\n.byte 55\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 57\n.byte 42\n.byte 51\n.byte 44\n.byte 32\n.byte 51\n.byte 50\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 56\n.byte 42\n.byte 52\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 51\n.byte 50\n.byte 45\n.byte 50\n.byte 55\n.byte 45\n.byte 52\n.byte 45\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 0\n.align 0\nL.31:\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 43\n.byte 32\n.byte 40\n.byte 45\n.byte 49\n.byte 41\n.byte 32\n.byte 43\n.byte 32\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 0\n.align 0\nL.27:\n.byte 45\n.byte 49\n.byte 43\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 40\n.byte 45\n.byte 49\n.byte 41\n.byte 43\n.byte 97\n.byte 98\n.byte 115\n.byte 40\n.byte 49\n.byte 41\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 45\n.byte 49\n.byte 43\n.byte 40\n.byte 45\n.byte 49\n.byte 41\n.byte 42\n.byte 40\n.byte 45\n.byte 49\n.byte 41\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 0\n.align 0\nL.23:\n.byte 51\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 50\n.byte 43\n.byte 49\n.byte 44\n.byte 32\n.byte 52\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 51\n.byte 43\n.byte 49\n.byte 44\n.byte 32\n.byte 52\n.byte 43\n.byte 50\n.byte 42\n.byte 40\n.byte 45\n.byte 50\n.byte 41\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 52\n.byte 45\n.byte 51\n.byte 45\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 0\n.align 3\nL.21:\n.long 0xd2f1a9fc\n.long 0x3f50624d\n.align 0\nL.20:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 45\n.byte 48\n.byte 46\n.byte 48\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 78\n.byte 111\n.byte 110\n.byte 45\n.byte 122\n.byte 101\n.byte 114\n.byte 111\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.15:\n.byte 48\n.byte 43\n.byte 48\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 49\n.byte 45\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 49\n.byte 32\n.byte 60\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 49\n.byte 43\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 50\n.byte 0\n.align 0\nL.13:\n.byte 80\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 119\n.byte 32\n.byte 82\n.byte 85\n.byte 78\n.byte 78\n.byte 73\n.byte 78\n.byte 71\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 110\n.byte 32\n.byte 115\n.byte 109\n.byte 97\n.byte 108\n.byte 108\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 115\n.byte 58\n.byte 10\n.byte 0\n.align 3\nL.9:\n.long 0x0\n.long 0x3ff00000\n.align 3\nL.8:\n.long 0x0\n.long 0x0\n.align 0\nL.3:\n.byte 10\n.byte 42\n.byte 32\n.byte 42\n.byte 32\n.byte 42\n.byte 32\n.byte 70\n.byte 76\n.byte 79\n.byte 65\n.byte 84\n.byte 73\n.byte 78\n.byte 71\n.byte 45\n.byte 80\n.byte 79\n.byte 73\n.byte 78\n.byte 84\n.byte 32\n.byte 69\n.byte 82\n.byte 82\n.byte 79\n.byte 82\n.byte 32\n.byte 42\n.byte 32\n.byte 42\n.byte 32\n.byte 42\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/alpha/osf/tst/sort.1bk",
    "content": "exchange(1,9)\nexchange(3,7)\nexchange(5,6)\nexchange(0,5)\nexchange(0,3)\nexchange(0,0)\nexchange(1,2)\nexchange(6,6)\nexchange(8,9)\nexchange(7,8)\n-51\n-1\n0\n1\n3\n10\n18\n32\n567\n789\n"
  },
  {
    "path": "lcc/alpha/osf/tst/sort.2bk",
    "content": "tst/sort.c:23: warning: missing return value\ntst/sort.c:30: warning: missing return value\ntst/sort.c:37: warning: missing return value\ntst/sort.c:41: warning: missing return value\ntst/sort.c:65: warning: missing return value\n"
  },
  {
    "path": "lcc/alpha/osf/tst/sort.sbk",
    "content": ".sdata\n.globl in\n.align 2\nin:\n.long 0xa\n.long 0x20\n.long 0xffffffff\n.long 0x237\n.long 0x3\n.long 0x12\n.long 0x1\n.long 0xffffffcd\n.long 0x315\n.long 0x0\n.globl main\n.text\n.text\n.ent main\nmain:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4004000,-72\n.frame $sp,80,$26,48\nstq $14,0($sp)\nstq $26,8($sp)\n.prologue 1\nlda $16,in\nlda $17,10\njsr $26,sort\nldgp $gp,0($26)\nmov $31,$14\nbr L.5\nL.2:\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\nldl $16,in($27)\njsr $26,putd\nldgp $gp,0($26)\nlda $16,10\njsr $26,putchar\nldgp $gp,0($26)\nL.3:\nlda $14,1($14)\nL.5:\nmov $14,$27\nlda $25,10\ncmpult $27,$25,$23\nbne $23,L.2\nmov $31,$0\nL.1:\nldq $14,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end main\n.globl putd\n.text\n.ent putd\nputd:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x5004000,-64\n.frame $sp,80,$26,48\nstq $14,0($sp)\nstq $24,8($sp)\nstq $26,16($sp)\nmov $16,$14\n.prologue 1\ncmplt $14,$31,$23\nbeq $23,L.7\nlda $16,45\njsr $26,putchar\nldgp $gp,0($26)\nnegl $14,$14\nL.7:\ndivl $14,10,$27\ncmpeq $27,$31,$23\nbne $23,L.9\ndivl $14,10,$16\njsr $26,putd\nldgp $gp,0($26)\nL.9:\nreml $14,10,$27\nlda $16,48($27)\njsr $26,putchar\nldgp $gp,0($26)\nmov $31,$0\nL.6:\nldq $14,0($sp)\nldq $24,8($sp)\nldq $26,16($sp)\nlda $sp,80($sp)\nret\n.end putd\n.globl sort\n.text\n.ent sort\nsort:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\nstq $16,16($sp)\nstq $17,24($sp)\n.prologue 1\nldq $27,-48+64($sp)\nstq $27,xx\nmov $27,$16\nmov $31,$17\nldl $27,-40+64($sp)\nsubl $27,1,$27\nstl $27,-40+64($sp)\nmov $27,$18\njsr $26,quick\nldgp $gp,0($26)\nmov $31,$0\nL.11:\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end sort\n.globl quick\n.text\n.ent quick\nquick:\nldgp $gp,0($27)\nlda $sp,-96($sp)\n.mask 0x4007800,-64\n.frame $sp,96,$26,48\nstq $11,0($sp)\nstq $12,8($sp)\nstq $13,16($sp)\nstq $14,24($sp)\nstq $26,32($sp)\nmov $16,$14\nmov $17,$13\nmov $18,$12\n.prologue 1\ncmplt $13,$12,$23\nbne $23,L.13\nbr L.12\nL.13:\nmov $14,$16\nmov $13,$17\nmov $12,$18\njsr $26,partition\nldgp $gp,0($26)\nmov $0,$11\nmov $14,$16\nmov $13,$17\nsubl $11,1,$18\njsr $26,quick\nldgp $gp,0($26)\nmov $14,$16\nlda $17,1($11)\nmov $12,$18\njsr $26,quick\nldgp $gp,0($26)\nmov $31,$0\nL.12:\nldq $11,0($sp)\nldq $12,8($sp)\nldq $13,16($sp)\nldq $14,24($sp)\nldq $26,32($sp)\nlda $sp,96($sp)\nret\n.end quick\n.globl partition\n.text\n.ent partition\npartition:\nldgp $gp,0($27)\nlda $sp,-112($sp)\n.mask 0x4007c00,-72\n.frame $sp,112,$26,48\nstq $10,0($sp)\nstq $11,8($sp)\nstq $12,16($sp)\nstq $13,24($sp)\nstq $14,32($sp)\nstq $26,40($sp)\nmov $16,$14\nmov $17,$13\nmov $18,$12\n.prologue 1\nlda $12,1($12)\nmov $13,$10\nsll $10,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\naddq $27,$14,$27\nldl $11,($27)\nbr L.17\nL.16:\nlda $13,1($13)\nbr L.20\nL.19:\nlda $13,1($13)\nL.20:\nsll $13,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\naddq $27,$14,$27\nldl $27,($27)\ncmplt $27,$11,$23\nbne $23,L.19\nsubl $12,1,$12\nbr L.23\nL.22:\nsubl $12,1,$12\nL.23:\nsll $12,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\naddq $27,$14,$27\nldl $27,($27)\ncmple $27,$11,$23\nbeq $23,L.22\ncmplt $13,$12,$23\nbeq $23,L.25\nsll $13,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\naddq $27,$14,$16\nsll $12,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\naddq $27,$14,$17\njsr $26,exchange\nldgp $gp,0($26)\nL.25:\nL.17:\ncmplt $13,$12,$23\nbne $23,L.16\nsll $10,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\naddq $27,$14,$16\nsll $12,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,2,$27\naddq $27,$14,$17\njsr $26,exchange\nldgp $gp,0($26)\nmov $12,$0\nL.15:\nldq $10,0($sp)\nldq $11,8($sp)\nldq $12,16($sp)\nldq $13,24($sp)\nldq $14,32($sp)\nldq $26,40($sp)\nlda $sp,112($sp)\nret\n.end partition\n.globl exchange\n.text\n.ent exchange\nexchange:\nldgp $gp,0($27)\nlda $sp,-112($sp)\n.mask 0x5006000,-88\n.frame $sp,112,$26,48\nstq $13,0($sp)\nstq $14,8($sp)\nstq $24,16($sp)\nstq $26,24($sp)\nmov $16,$14\nmov $17,$13\n.prologue 1\nlda $16,L.28\nldq $27,xx\nstq $27,-80+112($sp)\nmov $14,$25\nsubq $25,$27,$25\nstq $25,-72+112($sp)\ndivq $25,4,$17\nmov $13,$27\nldq $25,-80+112($sp)\nsubq $27,$25,$27\ndivq $27,4,$18\njsr $26,printf\nldgp $gp,0($26)\nldl $27,($14)\nstl $27,-60+112($sp)\nldl $27,($13)\nstl $27,($14)\nldl $27,-60+112($sp)\nstl $27,($13)\nmov $31,$0\nL.27:\nldq $13,0($sp)\nldq $14,8($sp)\nldq $24,16($sp)\nldq $26,24($sp)\nlda $sp,112($sp)\nret\n.end exchange\n.globl xx\n.comm xx,8\n.rdata\n.align 0\nL.28:\n.byte 101\n.byte 120\n.byte 99\n.byte 104\n.byte 97\n.byte 110\n.byte 103\n.byte 101\n.byte 40\n.byte 37\n.byte 100\n.byte 44\n.byte 37\n.byte 100\n.byte 41\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/alpha/osf/tst/spill.1bk",
    "content": ""
  },
  {
    "path": "lcc/alpha/osf/tst/spill.2bk",
    "content": "tst/spill.c:1: warning: missing return value\ntst/spill.c:3: warning: missing return value\ntst/spill.c:5: warning: missing return value\ntst/spill.c:7: warning: missing return value\ntst/spill.c:9: warning: missing return value\ntst/spill.c:17: warning: missing return value\n"
  },
  {
    "path": "lcc/alpha/osf/tst/spill.sbk",
    "content": ".globl main\n.text\n.text\n.ent main\nmain:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.frame $sp,64,$26,48\n.prologue 1\nmov $31,$0\nL.1:\nlda $sp,64($sp)\nret\n.end main\n.globl f\n.text\n.ent f\nf:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4000000,-80\n.frame $sp,80,$26,48\nstq $26,0($sp)\nstq $16,32($sp)\n.prologue 1\njsr $26,f\nldgp $gp,0($26)\nmov $0,$27\nstl $27,-60+80($sp)\njsr $26,f\nldgp $gp,0($26)\nldl $25,-60+80($sp)\naddl $25,$0,$27\nstl $27,-48+80($sp)\nmov $31,$0\nL.2:\nldq $26,0($sp)\nlda $sp,80($sp)\nret\n.end f\n.globl f2\n.text\n.ent f2\nf2:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4004000,-72\n.frame $sp,80,$26,48\nstq $14,0($sp)\nstq $26,8($sp)\nstq $16,32($sp)\n.prologue 1\njsr $26,f\nldgp $gp,0($26)\nmov $0,$27\nstl $27,-60+80($sp)\nldl $25,-48+80($sp)\ncmpeq $25,$31,$23\nbne $23,L.5\njsr $26,f\nldgp $gp,0($26)\nmov $0,$27\nmov $27,$14\nbr L.6\nL.5:\nlda $14,1\nL.6:\nldl $27,-60+80($sp)\naddl $27,$14,$27\nstl $27,-48+80($sp)\nmov $31,$0\nL.3:\nldq $14,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end f2\n.globl f3\n.text\n.ent f3\nf3:\nldgp $gp,0($27)\nlda $sp,-144($sp)\n.mask 0x4007e00,-96\n.frame $sp,144,$26,48\nstq $9,0($sp)\nstq $10,8($sp)\nstq $11,16($sp)\nstq $12,24($sp)\nstq $13,32($sp)\nstq $14,40($sp)\nstq $26,48($sp)\nstq $16,96($sp)\nstq $17,104($sp)\n.prologue 1\nmov $31,$14\nmov $31,$13\nmov $31,$12\nmov $31,$11\nmov $31,$10\nmov $31,$9\nstl $31,-60+144($sp)\nstl $31,-64+144($sp)\nstl $31,-68+144($sp)\nstl $31,-72+144($sp)\nldq $27,-40+144($sp)\nstq $27,-88+144($sp)\nlda $25,4($27)\nstq $25,-40+144($sp)\nldl $25,-48+144($sp)\ncmpeq $25,$31,$23\nbne $23,L.9\njsr $26,f\nldgp $gp,0($26)\nmov $0,$27\nstl $27,-76+144($sp)\nbr L.10\nL.9:\nstl $31,-76+144($sp)\nL.10:\nldl $27,-76+144($sp)\nldq $25,-88+144($sp)\nstl $27,($25)\nmov $31,$0\nL.7:\nldq $9,0($sp)\nldq $10,8($sp)\nldq $11,16($sp)\nldq $12,24($sp)\nldq $13,32($sp)\nldq $14,40($sp)\nldq $26,48($sp)\nlda $sp,144($sp)\nret\n.end f3\n.globl f4\n.text\n.ent f4\nf4:\nldgp $gp,0($27)\nlda $sp,-128($sp)\n.mask 0x4007e00,-80\n.frame $sp,128,$26,48\nstq $9,0($sp)\nstq $10,8($sp)\nstq $11,16($sp)\nstq $12,24($sp)\nstq $13,32($sp)\nstq $14,40($sp)\nstq $26,48($sp)\n.prologue 1\nmov $31,$14\nmov $31,$13\nmov $31,$12\nmov $31,$11\nmov $31,$10\nmov $31,$9\nldl $27,i\nsll $27,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,3,$25\nldt $f30,a($25)\nldt $f29,b($25)\nldt $f28,L.15\naddt $f30,$f29,$f27\ncmpteq $f27,$f28,$f1\nfbne $f1,L.13\ncmpeq $27,$31,$23\nbne $23,L.13\nsubt $f30,$f29,$f30\ncmpteq $f30,$f28,$f1\nfbne $f1,L.13\nlda $27,1\nstl $27,-60+128($sp)\nbr L.14\nL.13:\nstl $31,-60+128($sp)\nL.14:\nldl $27,-60+128($sp)\nstl $27,i\nmov $31,$0\nL.11:\nldq $9,0($sp)\nldq $10,8($sp)\nldq $11,16($sp)\nldq $12,24($sp)\nldq $13,32($sp)\nldq $14,40($sp)\nldq $26,48($sp)\nlda $sp,128($sp)\nret\n.end f4\n.globl f5\n.text\n.ent f5\nf5:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.frame $sp,64,$26,48\n.prologue 1\nldl $27,k\nldl $25,m\nldq $22,A\nmull $27,$25,$8\nsll $8,8*(8-4),$8\nsra $8,8*(8-4),$8\nsll $8,3,$8\naddq $8,$22,$8\nldl $7,j\nmull $7,$25,$25\nsll $25,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,3,$25\naddq $25,$22,$25\nldl $22,n\nldq $6,B\nmull $27,$22,$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,3,$27\naddq $27,$6,$27\nmull $7,$22,$22\nsll $22,8*(8-4),$22\nsra $22,8*(8-4),$22\nsll $22,3,$22\naddq $22,$6,$22\nldt $f30,($8)\nldt $f29,($25)\nmult $f30,$f29,$f30\nldt $f29,($27)\nldt $f28,($22)\nmult $f29,$f28,$f29\naddt $f30,$f29,$f30\nstt $f30,x\nldt $f30,($8)\nldt $f29,($22)\nmult $f30,$f29,$f30\nldt $f29,($27)\nldt $f28,($25)\nmult $f29,$f28,$f29\nsubt $f30,$f29,$f30\nstt $f30,x\nmov $31,$0\nL.16:\nlda $sp,64($sp)\nret\n.end f5\n.globl x\n.comm x,8\n.globl B\n.comm B,8\n.globl A\n.comm A,8\n.globl n\n.comm n,4\n.globl m\n.comm m,4\n.globl k\n.comm k,4\n.globl j\n.comm j,4\n.globl i\n.comm i,4\n.globl b\n.comm b,80\n.globl a\n.comm a,80\n.rdata\n.align 3\nL.15:\n.long 0x0\n.long 0x0\n"
  },
  {
    "path": "lcc/alpha/osf/tst/stdarg.1bk",
    "content": "test 1\ntest 2\ntest 3\ntest 4\ntest 5.000000\n{1 2 3 4} {1 2 3 4} {1 2 3 4} {1 2 3 4} {1 2 3 4} {1 2 3 4}\n"
  },
  {
    "path": "lcc/alpha/osf/tst/stdarg.2bk",
    "content": "tst/stdarg.c:51: warning: missing return value\n"
  },
  {
    "path": "lcc/alpha/osf/tst/stdarg.sbk",
    "content": ".sdata\n.globl x\n.align 2\nx:\n.long 0x1\n.long 0x2\n.long 0x3\n.long 0x4\n.globl main\n.text\n.text\n.ent main\nmain:\nldgp $gp,0($27)\nlda $sp,-128($sp)\n.mask 0x4000000,-72\n.frame $sp,128,$26,48\nstq $26,56($sp)\n.prologue 1\nlda $16,L.3\njsr $26,print\nldgp $gp,0($26)\nlda $16,L.4\nlda $17,L.5\njsr $26,print\nldgp $gp,0($26)\nlda $16,L.6\nlda $17,3\nlda $18,10\njsr $26,print\nldgp $gp,0($26)\nlda $16,L.7\nlda $17,L.8\nlda $18,L.9\nlda $19,4\nlda $20,10\njsr $26,print\nldgp $gp,0($26)\nlda $16,L.10\nlda $17,L.8\nlda $18,L.9\nldt $f19,L.11\nlda $20,10\njsr $26,print\nldgp $gp,0($26)\nlda $16,L.12\nlda $27,x\nmov $27,$1\nuldq $17,0($1)\nuldq $18,8($1)\nmov $27,$1\nuldq $19,0($1)\nuldq $20,8($1)\nmov $27,$1\nuldq $21,0($1)\nldl $4,8($1)\nldl $2,12($1)\nstl $4,0($30)\nstl $2,4($30)\nmov $27,$1\nldl $4,0($1)\nldl $2,4($1)\nstl $4,8($30)\nstl $2,12($30)\nldl $4,8($1)\nldl $2,12($1)\nstl $4,16($30)\nstl $2,20($30)\nmov $27,$1\nldl $4,0($1)\nldl $2,4($1)\nstl $4,24($30)\nstl $2,28($30)\nldl $4,8($1)\nldl $2,12($1)\nstl $4,32($30)\nstl $2,36($30)\nmov $27,$1\nldl $4,0($1)\nldl $2,4($1)\nstl $4,40($30)\nstl $2,44($30)\nldl $4,8($1)\nldl $2,12($1)\nstl $4,48($30)\nstl $2,52($30)\njsr $26,print\nldgp $gp,0($26)\nmov $31,$0\nL.2:\nldq $26,56($sp)\nlda $sp,128($sp)\nret\n.end main\n.globl print\n.text\n.ent print\nprint:\nldgp $gp,0($27)\nlda $sp,-160($sp)\n.mask 0x4006000,-144\n.frame $sp,160,$26,96\nstq $13,0($sp)\nstq $14,8($sp)\nstq $26,16($sp)\nstq $16,112($sp)\nstq $17,120($sp)\nstt $f17,72($sp)\nstq $18,128($sp)\nstt $f18,80($sp)\nstq $19,136($sp)\nstt $f19,88($sp)\nstq $20,144($sp)\nstt $f20,96($sp)\nstq $21,152($sp)\nstt $f21,104($sp)\n.prologue 1\nlda $27,-48+160($sp)\nstq $27,-120+160($sp)\nlda $27,-40+160($sp)\nldq $25,-120+160($sp)\nsubq $27,$25,$27\nstl $27,-112+160($sp)\nbr L.21\nL.18:\nldq $27,-48+160($sp)\nldb $27,($27)\ncmpeq $27,37,$23\nbeq $23,L.22\nldq $27,-48+160($sp)\nlda $27,1($27)\nstq $27,-48+160($sp)\nldb $14,($27)\nlda $27,115\ncmpeq $14,$27,$23\nbne $23,L.74\ncmple $14,$27,$23\nbeq $23,L.100\nL.99:\nlda $27,98\ncmplt $14,$27,$23\nbne $23,L.24\nlda $27,102\ncmple $14,$27,$23\nbeq $23,L.24\nsubl $14,98,$27\nsll $27,3,$27\nldq $27,L.101($27)\njmp ($27)\n.rdata\n.align 3\nL.101:\n.quad L.27\n.quad L.41\n.quad L.52\n.quad L.24\n.quad L.85\n.text\nL.100:\nlda $27,119\ncmpeq $14,$27,$23\nbne $23,L.63\nbr L.24\nL.27:\nldl $27,-112+160($sp)\nlda $27,16($27)\nstl $27,-112+160($sp)\nlda $27,-136+160($sp)\nldl $25,-112+160($sp)\nldq $22,-120+160($sp)\naddq $25,$22,$25\nlda $1,-16($25)\nldl $4,0($1)\nldl $2,4($1)\nstl $4,0($27)\nstl $2,4($27)\nldl $4,8($1)\nldl $2,12($1)\nstl $4,8($27)\nstl $2,12($27)\nlda $16,L.37\nldl $17,-136+160($sp)\nldl $18,-132+160($sp)\nldl $19,-128+160($sp)\nldl $20,-124+160($sp)\njsr $26,printf\nldgp $gp,0($26)\nbr L.23\nL.41:\nlda $16,L.42\nldl $27,-112+160($sp)\nlda $27,8($27)\nstl $27,-112+160($sp)\nldl $27,-112+160($sp)\nldq $25,-120+160($sp)\naddq $27,$25,$27\nlda $27,-8($27)\nldb $17,($27)\njsr $26,printf\nldgp $gp,0($26)\nbr L.23\nL.52:\nlda $16,L.53\nldl $27,-112+160($sp)\nlda $27,8($27)\nstl $27,-112+160($sp)\nldl $27,-112+160($sp)\nldq $25,-120+160($sp)\naddq $27,$25,$27\nldl $17,-8($27)\njsr $26,printf\nldgp $gp,0($26)\nbr L.23\nL.63:\nlda $16,L.64\nldl $27,-112+160($sp)\nlda $27,8($27)\nstl $27,-112+160($sp)\nldl $27,-112+160($sp)\nldq $25,-120+160($sp)\naddq $27,$25,$27\nlda $27,-8($27)\nldw $17,($27)\njsr $26,printf\nldgp $gp,0($26)\nbr L.23\nL.74:\nlda $16,L.75\nldl $27,-112+160($sp)\nlda $27,8($27)\nstl $27,-112+160($sp)\nldl $27,-112+160($sp)\nldq $25,-120+160($sp)\naddq $27,$25,$27\nldq $17,-8($27)\njsr $26,printf\nldgp $gp,0($26)\nbr L.23\nL.85:\nlda $16,L.86\nldl $27,-112+160($sp)\nlda $27,8($27)\nstl $27,-112+160($sp)\nldl $27,-112+160($sp)\ncmple $27,48,$23\nbeq $23,L.97\nldl $27,-112+160($sp)\nldq $25,-120+160($sp)\naddq $27,$25,$27\nlda $13,-56($27)\nbr L.98\nL.97:\nldl $27,-112+160($sp)\nldq $25,-120+160($sp)\naddq $27,$25,$27\nlda $13,-8($27)\nL.98:\nldt $f17,($13)\njsr $26,printf\nldgp $gp,0($26)\nbr L.23\nL.24:\nlda $16,L.42\nldq $27,-48+160($sp)\nldb $17,($27)\njsr $26,printf\nldgp $gp,0($26)\nbr L.23\nL.22:\nlda $16,L.42\nldq $27,-48+160($sp)\nldb $17,($27)\njsr $26,printf\nldgp $gp,0($26)\nL.23:\nL.19:\nldq $27,-48+160($sp)\nlda $27,1($27)\nstq $27,-48+160($sp)\nL.21:\nldq $27,-48+160($sp)\nldb $27,($27)\ncmpeq $27,$31,$23\nbeq $23,L.18\nmov $31,$0\nL.13:\nldq $13,0($sp)\nldq $14,8($sp)\nldq $26,16($sp)\nlda $sp,160($sp)\nret\n.end print\n.rdata\n.align 0\nL.86:\n.byte 37\n.byte 102\n.byte 0\n.align 0\nL.75:\n.byte 37\n.byte 115\n.byte 0\n.align 0\nL.64:\n.byte 37\n.byte 120\n.byte 0\n.align 0\nL.53:\n.byte 37\n.byte 100\n.byte 0\n.align 0\nL.42:\n.byte 37\n.byte 99\n.byte 0\n.align 0\nL.37:\n.byte 123\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 125\n.byte 0\n.align 0\nL.12:\n.byte 37\n.byte 98\n.byte 32\n.byte 37\n.byte 98\n.byte 32\n.byte 37\n.byte 98\n.byte 32\n.byte 37\n.byte 98\n.byte 32\n.byte 37\n.byte 98\n.byte 32\n.byte 37\n.byte 98\n.byte 10\n.byte 0\n.align 3\nL.11:\n.long 0x0\n.long 0x40140000\n.align 0\nL.10:\n.byte 37\n.byte 115\n.byte 37\n.byte 115\n.byte 32\n.byte 37\n.byte 102\n.byte 37\n.byte 99\n.byte 0\n.align 0\nL.9:\n.byte 115\n.byte 116\n.byte 0\n.align 0\nL.8:\n.byte 116\n.byte 101\n.byte 0\n.align 0\nL.7:\n.byte 37\n.byte 115\n.byte 37\n.byte 115\n.byte 32\n.byte 37\n.byte 119\n.byte 37\n.byte 99\n.byte 0\n.align 0\nL.6:\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 37\n.byte 100\n.byte 37\n.byte 99\n.byte 0\n.align 0\nL.5:\n.byte 50\n.byte 0\n.align 0\nL.4:\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.3:\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 49\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/alpha/osf/tst/struct.1bk",
    "content": "(-1,-1) is not within [10,10; 310,310]\n(1,1) is not within [10,10; 310,310]\n(20,300) is within [10,10; 310,310]\n(500,400) is not within [10,10; 310,310]\nab\n"
  },
  {
    "path": "lcc/alpha/osf/tst/struct.2bk",
    "content": "tst/struct.c:49: warning: missing return value\ntst/struct.c:68: warning: missing return value\n"
  },
  {
    "path": "lcc/alpha/osf/tst/struct.sbk",
    "content": ".globl addpoint\n.text\n.text\n.ent addpoint\naddpoint:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.frame $sp,64,$26,48\nstq $17,24($sp)\nstq $18,32($sp)\n.prologue 1\nldl $27,-40+64($sp)\nldl $25,-32+64($sp)\naddl $27,$25,$27\nstl $27,-40+64($sp)\nldl $27,-36+64($sp)\nldl $25,-28+64($sp)\naddl $27,$25,$27\nstl $27,-36+64($sp)\nlda $1,-40+64($sp)\nldl $4,0($1)\nldl $2,4($1)\nstl $4,0($16)\nstl $2,4($16)\nL.1:\nlda $sp,64($sp)\nret\n.end addpoint\n.globl canonrect\n.text\n.ent canonrect\ncanonrect:\nldgp $gp,0($27)\nlda $sp,-112($sp)\n.mask 0x4007800,-80\n.frame $sp,112,$26,48\nstq $11,0($sp)\nstq $12,8($sp)\nstq $13,16($sp)\nstq $14,24($sp)\nstq $26,32($sp)\nstq $17,72($sp)\nstq $18,80($sp)\n.prologue 1\nldl $27,-40+112($sp)\nldl $25,-32+112($sp)\ncmplt $27,$25,$23\nbeq $23,L.10\nldl $14,-40+112($sp)\nbr L.11\nL.10:\nldl $14,-32+112($sp)\nL.11:\nstl $14,-72+112($sp)\nldl $27,-36+112($sp)\nldl $25,-28+112($sp)\ncmplt $27,$25,$23\nbeq $23,L.20\nldl $13,-36+112($sp)\nbr L.21\nL.20:\nldl $13,-28+112($sp)\nL.21:\nstl $13,-68+112($sp)\nldl $27,-40+112($sp)\nldl $25,-32+112($sp)\ncmple $27,$25,$23\nbne $23,L.26\nldl $12,-40+112($sp)\nbr L.27\nL.26:\nldl $12,-32+112($sp)\nL.27:\nstl $12,-64+112($sp)\nldl $27,-36+112($sp)\nldl $25,-28+112($sp)\ncmple $27,$25,$23\nbne $23,L.37\nldl $11,-36+112($sp)\nbr L.38\nL.37:\nldl $11,-28+112($sp)\nL.38:\nstl $11,-60+112($sp)\nlda $1,-72+112($sp)\nldl $4,0($1)\nldl $2,4($1)\nstl $4,0($16)\nstl $2,4($16)\nldl $4,8($1)\nldl $2,12($1)\nstl $4,8($16)\nstl $2,12($16)\nL.5:\nldq $11,0($sp)\nldq $12,8($sp)\nldq $13,16($sp)\nldq $14,24($sp)\nldq $26,32($sp)\nlda $sp,112($sp)\nret\n.end canonrect\n.globl makepoint\n.text\n.ent makepoint\nmakepoint:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.frame $sp,64,$26,48\n.prologue 1\nstl $17,-64+64($sp)\nstl $18,-60+64($sp)\nlda $1,-64+64($sp)\nldl $4,0($1)\nldl $2,4($1)\nstl $4,0($16)\nstl $2,4($16)\nL.39:\nlda $sp,64($sp)\nret\n.end makepoint\n.globl makerect\n.text\n.ent makerect\nmakerect:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4000000,-80\n.frame $sp,80,$26,48\nstq $26,0($sp)\nstq $16,32($sp)\nstq $17,40($sp)\nstq $18,48($sp)\n.prologue 1\nlda $27,-72+80($sp)\nlda $1,-40+80($sp)\nldl $4,0($1)\nldl $2,4($1)\nstl $4,0($27)\nstl $2,4($27)\nlda $27,-64+80($sp)\nlda $1,-32+80($sp)\nldl $4,0($1)\nldl $2,4($1)\nstl $4,0($27)\nstl $2,4($27)\nldq $16,-48+80($sp)\nlda $1,-72+80($sp)\nuldq $17,0($1)\nuldq $18,8($1)\njsr $26,canonrect\nldgp $gp,0($26)\nL.42:\nldq $26,0($sp)\nlda $sp,80($sp)\nret\n.end makerect\n.globl ptinrect\n.text\n.ent ptinrect\nptinrect:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4004000,-72\n.frame $sp,80,$26,48\nstq $14,0($sp)\nstq $26,8($sp)\nstq $16,32($sp)\nstq $17,40($sp)\nstq $18,48($sp)\n.prologue 1\nldl $27,-48+80($sp)\nldl $25,-40+80($sp)\ncmplt $27,$25,$23\nbne $23,L.53\nldl $25,-32+80($sp)\ncmplt $27,$25,$23\nbeq $23,L.53\nldl $27,-44+80($sp)\nldl $25,-36+80($sp)\ncmplt $27,$25,$23\nbne $23,L.53\nldl $27,-44+80($sp)\nldl $25,-28+80($sp)\ncmplt $27,$25,$23\nbeq $23,L.53\nlda $14,1\nbr L.54\nL.53:\nmov $31,$14\nL.54:\nmov $14,$0\nL.45:\nldq $14,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end ptinrect\n.sdata\n.globl y\n.align 0\ny:\n.byte 97\n.byte 98\n.byte 0\n.globl odd\n.text\n.text\n.ent odd\nodd:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4000000,-80\n.frame $sp,80,$26,48\nstq $26,0($sp)\nstq $16,32($sp)\n.prologue 1\nlda $27,-59+80($sp)\nlda $1,-48+80($sp)\nldb $4,0($1)\nldb $2,1($1)\nstb $4,0($27)\nstb $2,1($27)\nldb $4,2($1)\nstb $4,2($27)\nlda $16,L.56\nlda $17,-59+80($sp)\njsr $26,printf\nldgp $gp,0($26)\nmov $31,$0\nL.55:\nldq $26,0($sp)\nlda $sp,80($sp)\nret\n.end odd\n.rdata\n.align 2\nL.58:\n.long 0x0\n.long 0x0\n.align 2\nL.59:\n.long 0x140\n.long 0x140\n.align 2\nL.60:\n.long 0xffffffff\n.long 0xffffffff\n.long 0x1\n.long 0x1\n.long 0x14\n.long 0x12c\n.long 0x1f4\n.long 0x190\n.globl main\n.text\n.text\n.ent main\nmain:\nldgp $gp,0($27)\nlda $sp,-176($sp)\n.mask 0x4004000,-168\n.frame $sp,176,$26,48\nstq $14,0($sp)\nstq $26,8($sp)\n.prologue 1\nlda $27,-120+176($sp)\nlda $1,L.58\nldl $4,0($1)\nldl $2,4($1)\nstl $4,0($27)\nstl $2,4($27)\nlda $27,-128+176($sp)\nlda $1,L.59\nldl $4,0($1)\nldl $2,4($1)\nstl $4,0($27)\nstl $2,4($27)\nlda $27,-88+176($sp)\nlda $1,L.60\naddq $1,32,$1\naddq $27,32,$3\nL.76:\naddq $1,-8,$1\naddq $3,-8,$3\nldl $4,0($1)\nldl $2,4($1)\nstl $4,0($3)\nstl $2,4($3)\ncmpult $27,$3,$23\nbne $23,L.76\nlda $16,-136+176($sp)\nlda $27,-10\nmov $27,$17\nmov $27,$18\njsr $26,makepoint\nldgp $gp,0($26)\nlda $16,-144+176($sp)\nlda $1,-128+176($sp)\nuldq $17,0($1)\nlda $1,-136+176($sp)\nuldq $18,0($1)\njsr $26,addpoint\nldgp $gp,0($26)\nlda $16,-152+176($sp)\nlda $27,10\nmov $27,$17\nmov $27,$18\njsr $26,makepoint\nldgp $gp,0($26)\nlda $16,-160+176($sp)\nlda $1,-120+176($sp)\nuldq $17,0($1)\nlda $1,-152+176($sp)\nuldq $18,0($1)\njsr $26,addpoint\nldgp $gp,0($26)\nlda $16,-104+176($sp)\nlda $1,-144+176($sp)\nuldq $17,0($1)\nlda $1,-160+176($sp)\nuldq $18,0($1)\njsr $26,makerect\nldgp $gp,0($26)\nmov $31,$14\nbr L.64\nL.61:\nlda $16,-112+176($sp)\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,3,$27\nlda $25,-88+176($sp)\naddq $27,$25,$25\nldl $17,($25)\nlda $25,-84+176($sp)\naddq $27,$25,$27\nldl $18,($27)\njsr $26,makepoint\nldgp $gp,0($26)\nlda $16,L.65\nsll $14,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,3,$27\nlda $25,-88+176($sp)\naddq $27,$25,$27\nldl $17,($27)\nldl $18,-108+176($sp)\njsr $26,printf\nldgp $gp,0($26)\nlda $1,-112+176($sp)\nuldq $16,0($1)\nlda $1,-104+176($sp)\nuldq $17,0($1)\nuldq $18,8($1)\njsr $26,ptinrect\nldgp $gp,0($26)\ncmpeq $0,$31,$23\nbeq $23,L.68\nlda $16,L.70\njsr $26,printf\nldgp $gp,0($26)\nL.68:\nlda $16,L.71\nldl $17,-104+176($sp)\nldl $18,-100+176($sp)\nldl $19,-96+176($sp)\nldl $20,-92+176($sp)\njsr $26,printf\nldgp $gp,0($26)\nL.62:\nlda $14,1($14)\nL.64:\nmov $14,$27\nlda $25,4\ncmpult $27,$25,$23\nbne $23,L.61\nlda $1,y\nuldq $16,0($1)\njsr $26,odd\nldgp $gp,0($26)\nmov $31,$16\njsr $26,exit\nldgp $gp,0($26)\nmov $31,$0\nL.57:\nldq $14,0($sp)\nldq $26,8($sp)\nlda $sp,176($sp)\nret\n.end main\n.rdata\n.align 0\nL.71:\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 105\n.byte 110\n.byte 32\n.byte 91\n.byte 37\n.byte 100\n.byte 44\n.byte 37\n.byte 100\n.byte 59\n.byte 32\n.byte 37\n.byte 100\n.byte 44\n.byte 37\n.byte 100\n.byte 93\n.byte 10\n.byte 0\n.align 0\nL.70:\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 0\n.align 0\nL.65:\n.byte 40\n.byte 37\n.byte 100\n.byte 44\n.byte 37\n.byte 100\n.byte 41\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 0\n.align 0\nL.56:\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/alpha/osf/tst/switch.1bk",
    "content": "b = 0x8\nf = 0xc\nn = 0xa\nr = 0xd\nt = 0x9\nv = 0xb\nx = 0x78\nf:\nx = 0\nx = 1\nx = 2\nx = 2\nx = 2\nx = 2\nx = 2\nx = 7\nx = 8\nx = 9\nx = 9\nx = 9\nx = 9\nx = 9\nx = 9\nx = 9\nx = 16\nx = 17\nx = 18\nx = 19\nx = 20\ng:\n1 1\n1 2\n2 3\n2 4\n2 5\n3 6\nd 6\n3 7\nd 7\n3 8\nd 8\nd 9\nd 10\nh:\ni = 8\ni = 16\ni = 120\ni = 128\ni = 248\ni = 264\ni = 272\ni = 280\ni = 288\ni = 296\ni = 304\ni = 312\n488 defaults\nx = 0x1000000\nx = 0x2000000\nx = 0x3000000\nx = 0x4000000\nx = 0x5000000\nx = 0x6000000 (default)\nx = 0x7000000 (default)\n0\n1\n2\n3\n4\n5\n0\n1\n2\n3\n4\n5\n"
  },
  {
    "path": "lcc/alpha/osf/tst/switch.2bk",
    "content": "tst/switch.c:55: warning: missing return value\ntst/switch.c:73: warning: missing return value\ntst/switch.c:97: warning: missing return value\ntst/switch.c:101: warning: overflow in converting constant expression from `int' to `unsigned int'\ntst/switch.c:102: warning: overflow in converting constant expression from `int' to `unsigned int'\ntst/switch.c:112: warning: missing return value\ntst/switch.c:137: warning: missing return value\n"
  },
  {
    "path": "lcc/alpha/osf/tst/switch.sbk",
    "content": ".globl main\n.text\n.text\n.ent main\nmain:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4006000,-64\n.frame $sp,80,$26,48\nstq $13,0($sp)\nstq $14,8($sp)\nstq $26,16($sp)\n.prologue 1\nlda $14,L.6\nbr L.5\nL.2:\nldb $16,($14)\njsr $26,backslash\nldgp $gp,0($26)\nmov $0,$27\nlda $16,L.7\nldb $17,($14)\nmov $27,$18\njsr $26,printf\nldgp $gp,0($26)\nL.3:\nlda $14,1($14)\nL.5:\nldb $27,($14)\ncmpeq $27,$31,$23\nbeq $23,L.2\njsr $26,f\nldgp $gp,0($26)\njsr $26,g\nldgp $gp,0($26)\njsr $26,h\nldgp $gp,0($26)\nlda $13,16777216\nbr L.11\nL.8:\nmov $13,$16\njsr $26,big\nldgp $gp,0($26)\nL.9:\nlda $13,16777216($13)\nL.11:\nand $13,117440512,$27\naddl $27,0,$27\ncmpeq $27,$31,$23\nbeq $23,L.8\njsr $26,limit\nldgp $gp,0($26)\nmov $31,$0\nL.1:\nldq $13,0($sp)\nldq $14,8($sp)\nldq $26,16($sp)\nlda $sp,80($sp)\nret\n.end main\n.globl backslash\n.text\n.ent backslash\nbackslash:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.frame $sp,64,$26,48\n.prologue 1\nlda $27,102\ncmpeq $16,$27,$23\nbne $23,L.16\ncmple $16,$27,$23\nbeq $23,L.22\nL.21:\nlda $27,98\ncmpeq $16,$27,$23\nbne $23,L.15\nbr L.13\nL.22:\nlda $27,110\ncmpeq $16,$27,$23\nbne $23,L.17\ncmplt $16,$27,$23\nbne $23,L.13\nL.23:\nlda $27,114\ncmpeq $16,$27,$23\nbne $23,L.18\nlda $27,116\ncmpeq $16,$27,$23\nbne $23,L.19\nlda $27,118\ncmpeq $16,$27,$23\nbne $23,L.20\nbr L.13\nL.15:\nlda $0,8\nbr L.12\nL.16:\nlda $0,12\nbr L.12\nL.17:\nlda $0,10\nbr L.12\nL.18:\nlda $0,13\nbr L.12\nL.19:\nlda $0,9\nbr L.12\nL.20:\nlda $0,11\nbr L.12\nL.13:\nmov $16,$0\nL.12:\nlda $sp,64($sp)\nret\n.end backslash\n.globl f\n.text\n.ent f\nf:\nldgp $gp,0($27)\nlda $sp,-96($sp)\n.mask 0x4007000,-72\n.frame $sp,96,$26,48\nstq $12,0($sp)\nstq $13,8($sp)\nstq $14,16($sp)\nstq $26,24($sp)\n.prologue 1\nmov $31,$13\nlda $16,L.25\njsr $26,printf\nldgp $gp,0($26)\nmov $31,$14\nL.26:\nmov $14,$12\ncmplt $14,1,$23\nbne $23,L.30\ncmple $14,20,$23\nbeq $23,L.30\nsubl $14,1,$27\nsll $27,3,$27\nldq $27,L.42($27)\njmp ($27)\n.rdata\n.align 3\nL.42:\n.quad L.32\n.quad L.33\n.quad L.30\n.quad L.30\n.quad L.30\n.quad L.30\n.quad L.34\n.quad L.35\n.quad L.36\n.quad L.30\n.quad L.30\n.quad L.30\n.quad L.30\n.quad L.30\n.quad L.30\n.quad L.37\n.quad L.38\n.quad L.39\n.quad L.40\n.quad L.41\n.text\nL.32:\nmov $14,$13\nbr L.31\nL.33:\nmov $14,$13\nbr L.31\nL.34:\nmov $14,$13\nbr L.31\nL.35:\nmov $14,$13\nbr L.31\nL.36:\nmov $14,$13\nbr L.31\nL.37:\nmov $14,$13\nbr L.31\nL.38:\nmov $14,$13\nbr L.31\nL.39:\nmov $14,$13\nbr L.31\nL.40:\nmov $14,$13\nbr L.31\nL.41:\nmov $14,$13\nL.30:\nL.31:\nlda $16,L.43\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nL.27:\nlda $14,1($14)\ncmple $14,20,$23\nbne $23,L.26\nmov $31,$0\nL.24:\nldq $12,0($sp)\nldq $13,8($sp)\nldq $14,16($sp)\nldq $26,24($sp)\nlda $sp,96($sp)\nret\n.end f\n.globl g\n.text\n.ent g\ng:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4004000,-72\n.frame $sp,80,$26,48\nstq $14,0($sp)\nstq $26,8($sp)\n.prologue 1\nlda $16,L.45\njsr $26,printf\nldgp $gp,0($26)\nlda $14,1\nL.46:\nlda $27,1001\ncmplt $14,$27,$23\nbne $23,L.63\nlda $27,1004\ncmple $14,$27,$23\nbeq $23,L.64\nsubl $14,1001,$27\nsll $27,3,$27\nldq $27,L.65($27)\njmp ($27)\n.rdata\n.align 3\nL.65:\n.quad L.59\n.quad L.59\n.quad L.59\n.quad L.59\n.text\nL.63:\ncmplt $14,1,$23\nbne $23,L.50\ncmple $14,8,$23\nbeq $23,L.50\nsubl $14,1,$27\nsll $27,3,$27\nldq $27,L.66($27)\njmp ($27)\n.rdata\n.align 3\nL.66:\n.quad L.52\n.quad L.52\n.quad L.54\n.quad L.54\n.quad L.54\n.quad L.56\n.quad L.56\n.quad L.56\n.text\nL.64:\nlda $27,3001\ncmplt $14,$27,$23\nbne $23,L.50\nlda $27,3004\ncmple $14,$27,$23\nbeq $23,L.50\nsubl $14,3001,$27\nsll $27,3,$27\nldq $27,L.67($27)\njmp ($27)\n.rdata\n.align 3\nL.67:\n.quad L.61\n.quad L.61\n.quad L.61\n.quad L.61\n.text\nL.52:\nlda $16,L.53\nmov $14,$17\njsr $26,printf\nldgp $gp,0($26)\nbr L.51\nL.54:\nlda $16,L.55\nmov $14,$17\njsr $26,printf\nldgp $gp,0($26)\nbr L.51\nL.56:\nlda $16,L.57\nmov $14,$17\njsr $26,printf\nldgp $gp,0($26)\nL.50:\nlda $16,L.58\nmov $14,$17\njsr $26,printf\nldgp $gp,0($26)\nbr L.51\nL.59:\nlda $16,L.60\nmov $14,$17\njsr $26,printf\nldgp $gp,0($26)\nbr L.51\nL.61:\nlda $16,L.62\nmov $14,$17\njsr $26,printf\nldgp $gp,0($26)\nL.51:\nL.47:\nlda $14,1($14)\ncmple $14,10,$23\nbne $23,L.46\nmov $31,$0\nL.44:\nldq $14,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end g\n.globl h\n.text\n.ent h\nh:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4006000,-64\n.frame $sp,80,$26,48\nstq $13,0($sp)\nstq $14,8($sp)\nstq $26,16($sp)\n.prologue 1\nmov $31,$13\nlda $16,L.69\njsr $26,printf\nldgp $gp,0($26)\nlda $14,1\nL.70:\nlda $27,264\ncmpeq $14,$27,$23\nbne $23,L.82\ncmple $14,$27,$23\nbeq $23,L.90\nL.89:\nlda $27,120\ncmpeq $14,$27,$23\nbne $23,L.80\ncmple $14,$27,$23\nbeq $23,L.92\nL.91:\ncmpeq $14,8,$23\nbne $23,L.79\ncmplt $14,8,$23\nbne $23,L.74\nL.93:\ncmpeq $14,16,$23\nbne $23,L.78\nbr L.74\nL.92:\nlda $27,128\ncmpeq $14,$27,$23\nbne $23,L.76\ncmplt $14,$27,$23\nbne $23,L.74\nL.94:\nlda $27,248\ncmpeq $14,$27,$23\nbne $23,L.83\nbr L.74\nL.90:\nlda $27,288\ncmpeq $14,$27,$23\nbne $23,L.87\ncmple $14,$27,$23\nbeq $23,L.96\nL.95:\nlda $27,272\ncmpeq $14,$27,$23\nbne $23,L.84\ncmplt $14,$27,$23\nbne $23,L.74\nL.97:\nlda $27,280\ncmpeq $14,$27,$23\nbne $23,L.81\nbr L.74\nL.96:\nlda $27,304\ncmpeq $14,$27,$23\nbne $23,L.85\ncmple $14,$27,$23\nbeq $23,L.99\nL.98:\nlda $27,296\ncmpeq $14,$27,$23\nbne $23,L.86\nbr L.74\nL.99:\nlda $27,312\ncmpeq $14,$27,$23\nbne $23,L.88\nbr L.74\nL.74:\nlda $13,1($13)\nbr L.71\nL.76:\nlda $16,L.77\nmov $14,$17\njsr $26,printf\nldgp $gp,0($26)\nbr L.75\nL.78:\nlda $16,L.77\nmov $14,$17\njsr $26,printf\nldgp $gp,0($26)\nbr L.75\nL.79:\nlda $16,L.77\nmov $14,$17\njsr $26,printf\nldgp $gp,0($26)\nbr L.75\nL.80:\nlda $16,L.77\nmov $14,$17\njsr $26,printf\nldgp $gp,0($26)\nbr L.75\nL.81:\nlda $16,L.77\nmov $14,$17\njsr $26,printf\nldgp $gp,0($26)\nbr L.75\nL.82:\nlda $16,L.77\nmov $14,$17\njsr $26,printf\nldgp $gp,0($26)\nbr L.75\nL.83:\nlda $16,L.77\nmov $14,$17\njsr $26,printf\nldgp $gp,0($26)\nbr L.75\nL.84:\nlda $16,L.77\nmov $14,$17\njsr $26,printf\nldgp $gp,0($26)\nbr L.75\nL.85:\nlda $16,L.77\nmov $14,$17\njsr $26,printf\nldgp $gp,0($26)\nbr L.75\nL.86:\nlda $16,L.77\nmov $14,$17\njsr $26,printf\nldgp $gp,0($26)\nbr L.75\nL.87:\nlda $16,L.77\nmov $14,$17\njsr $26,printf\nldgp $gp,0($26)\nbr L.75\nL.88:\nlda $16,L.77\nmov $14,$17\njsr $26,printf\nldgp $gp,0($26)\nL.75:\nL.71:\nlda $14,1($14)\nlda $27,500\ncmple $14,$27,$23\nbne $23,L.70\nlda $16,L.100\nmov $13,$17\njsr $26,printf\nldgp $gp,0($26)\nmov $31,$0\nL.68:\nldq $13,0($sp)\nldq $14,8($sp)\nldq $26,16($sp)\nlda $sp,80($sp)\nret\n.end h\n.globl big\n.text\n.ent big\nbig:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4004000,-72\n.frame $sp,80,$26,48\nstq $14,0($sp)\nstq $26,8($sp)\nstq $16,32($sp)\n.prologue 1\nldl $27,-48+80($sp)\nzap $27,240,$27\nand $27,0x6000000,$14\nlda $25,33554432\ncmpeq $14,$25,$23\nbne $23,L.107\ncmple $14,$25,$23\nbeq $23,L.111\nL.110:\nlda $25,-2\ncmpeq $14,$25,$23\nbne $23,L.105\nlda $25,-1\ncmpeq $14,$25,$23\nbne $23,L.105\ncmpeq $14,$31,$23\nbne $23,L.105\nbr L.102\nL.111:\nmov $14,$27\nlda $25,67108864\ncmpeq $27,$25,$23\nbne $23,L.108\nbr L.102\nL.105:\nlda $16,L.106\nldl $17,-48+80($sp)\nzap $17,240,$17\njsr $26,printf\nldgp $gp,0($26)\nbr L.103\nL.107:\nlda $16,L.106\nldl $17,-48+80($sp)\nzap $17,240,$17\njsr $26,printf\nldgp $gp,0($26)\nbr L.103\nL.108:\nlda $16,L.106\nldl $17,-48+80($sp)\nzap $17,240,$17\njsr $26,printf\nldgp $gp,0($26)\nbr L.103\nL.102:\nlda $16,L.109\nldl $17,-48+80($sp)\nzap $17,240,$17\njsr $26,printf\nldgp $gp,0($26)\nL.103:\nmov $31,$0\nL.101:\nldq $14,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end big\n.globl limit\n.text\n.ent limit\nlimit:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4004000,-72\n.frame $sp,80,$26,48\nstq $14,0($sp)\nstq $26,8($sp)\n.prologue 1\nlda $14,-2147483648\nL.113:\nlda $27,-2147483648\ncmplt $14,$27,$23\nbne $23,L.117\nlda $27,-2147483644\ncmple $14,$27,$23\nbeq $23,L.117\nsubl $14,-2147483648,$27\nsll $27,3,$27\nldq $27,L.130($27)\njmp ($27)\n.rdata\n.align 3\nL.130:\n.quad L.119\n.quad L.121\n.quad L.123\n.quad L.125\n.quad L.127\n.text\nL.119:\nlda $16,L.120\njsr $26,printf\nldgp $gp,0($26)\nbr L.118\nL.121:\nlda $16,L.122\njsr $26,printf\nldgp $gp,0($26)\nbr L.118\nL.123:\nlda $16,L.124\njsr $26,printf\nldgp $gp,0($26)\nbr L.118\nL.125:\nlda $16,L.126\njsr $26,printf\nldgp $gp,0($26)\nbr L.118\nL.127:\nlda $16,L.128\njsr $26,printf\nldgp $gp,0($26)\nbr L.118\nL.117:\nlda $16,L.129\njsr $26,printf\nldgp $gp,0($26)\nL.118:\nL.114:\nlda $14,1($14)\nlda $27,-2147483643\ncmple $14,$27,$23\nbne $23,L.113\nlda $14,2147483647\nL.131:\nlda $27,2147483643\ncmplt $14,$27,$23\nbne $23,L.135\nlda $27,2147483647\ncmple $14,$27,$23\nbeq $23,L.135\nsubl $14,2147483643,$27\nsll $27,3,$27\nldq $27,L.142($27)\njmp ($27)\n.rdata\n.align 3\nL.142:\n.quad L.141\n.quad L.140\n.quad L.139\n.quad L.138\n.quad L.137\n.text\nL.137:\nlda $16,L.120\njsr $26,printf\nldgp $gp,0($26)\nbr L.136\nL.138:\nlda $16,L.122\njsr $26,printf\nldgp $gp,0($26)\nbr L.136\nL.139:\nlda $16,L.124\njsr $26,printf\nldgp $gp,0($26)\nbr L.136\nL.140:\nlda $16,L.126\njsr $26,printf\nldgp $gp,0($26)\nbr L.136\nL.141:\nlda $16,L.128\njsr $26,printf\nldgp $gp,0($26)\nbr L.136\nL.135:\nlda $16,L.129\njsr $26,printf\nldgp $gp,0($26)\nL.136:\nL.132:\nsubl $14,1,$14\nlda $27,2147483642\ncmplt $14,$27,$23\nbeq $23,L.131\nmov $31,$0\nL.112:\nldq $14,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end limit\n.rdata\n.align 0\nL.129:\n.byte 53\n.byte 10\n.byte 0\n.align 0\nL.128:\n.byte 52\n.byte 10\n.byte 0\n.align 0\nL.126:\n.byte 51\n.byte 10\n.byte 0\n.align 0\nL.124:\n.byte 50\n.byte 10\n.byte 0\n.align 0\nL.122:\n.byte 49\n.byte 10\n.byte 0\n.align 0\nL.120:\n.byte 48\n.byte 10\n.byte 0\n.align 0\nL.109:\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 120\n.byte 37\n.byte 120\n.byte 32\n.byte 40\n.byte 100\n.byte 101\n.byte 102\n.byte 97\n.byte 117\n.byte 108\n.byte 116\n.byte 41\n.byte 10\n.byte 0\n.align 0\nL.106:\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 120\n.byte 37\n.byte 120\n.byte 10\n.byte 0\n.align 0\nL.100:\n.byte 37\n.byte 100\n.byte 32\n.byte 100\n.byte 101\n.byte 102\n.byte 97\n.byte 117\n.byte 108\n.byte 116\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.77:\n.byte 105\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.69:\n.byte 104\n.byte 58\n.byte 10\n.byte 0\n.align 0\nL.62:\n.byte 54\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.60:\n.byte 53\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.58:\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.57:\n.byte 51\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.55:\n.byte 50\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.53:\n.byte 49\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.45:\n.byte 103\n.byte 58\n.byte 10\n.byte 0\n.align 0\nL.43:\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.25:\n.byte 102\n.byte 58\n.byte 10\n.byte 0\n.align 0\nL.7:\n.byte 37\n.byte 99\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 120\n.byte 37\n.byte 120\n.byte 10\n.byte 0\n.align 0\nL.6:\n.byte 98\n.byte 102\n.byte 110\n.byte 114\n.byte 116\n.byte 118\n.byte 120\n.byte 0\n"
  },
  {
    "path": "lcc/alpha/osf/tst/wf1.1bk",
    "content": "5\ta\n2\tand\n5\tbuf\n16\tc\n8\tchar\n1\tcompare\n4\tcond\n5\tcount\n1\td\n1\tdie\n3\telse\n1\tentry\n1\teof\n4\terr\n1\terror\n1\texit\n1\tfolded\n1\tfor\n1\tfree\n1\tfrequencies\n1\tfrequency\n1\tget\n2\tgetchar\n3\tgetword\n14\tif\n2\tin\n1\tindex\n1\tinput\n1\tinstall\n8\tint\n1\tinto\n1\tis\n4\tisletter\n1\tit\n1\titself\n5\tleft\n1\tletter\n7\tlookup\n1\tmain\n2\tmalloc\n1\tmessage\n2\tn\n1\tnecessary\n12\tnext\n9\tnode\n4\tof\n1\ton\n1\tor\n1\totherwise\n2\tout\n8\tp\n3\tprint\n2\tprintf\n16\treturn\n5\tright\n4\troot\n25\ts\n2\tstorage\n3\tstrcmp\n1\tstrcpy\n1\tstrlen\n8\tstruct\n1\tstructures\n2\tsubtree\n1\tt\n5\ttprint\n9\ttree\n1\tuses\n1\tversion\n1\twf\n3\twhile\n21\tword\n9\twords\n2\tz\n"
  },
  {
    "path": "lcc/alpha/osf/tst/wf1.2bk",
    "content": "tst/wf1.c:29: warning: missing return value\ntst/wf1.c:87: warning: missing return value\n"
  },
  {
    "path": "lcc/alpha/osf/tst/wf1.sbk",
    "content": ".globl main\n.text\n.text\n.ent main\nmain:\nldgp $gp,0($27)\nlda $sp,-96($sp)\n.mask 0x4000000,-96\n.frame $sp,96,$26,48\nstq $26,0($sp)\n.prologue 1\nstq $31,-88+96($sp)\nstl $31,next\nbr L.3\nL.2:\nlda $16,-76+96($sp)\nlda $17,-88+96($sp)\njsr $26,lookup\nldgp $gp,0($26)\nldl $25,($0)\nlda $25,1($25)\nstl $25,($0)\nL.3:\nlda $16,-76+96($sp)\njsr $26,getword\nldgp $gp,0($26)\ncmpeq $0,$31,$23\nbeq $23,L.2\nldq $16,-88+96($sp)\njsr $26,tprint\nldgp $gp,0($26)\nmov $31,$0\nL.1:\nldq $26,0($sp)\nlda $sp,96($sp)\nret\n.end main\n.globl err\n.text\n.ent err\nerr:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\nstq $16,16($sp)\n.prologue 1\nlda $16,L.6\nldq $17,-48+64($sp)\njsr $26,printf\nldgp $gp,0($26)\nlda $16,1\njsr $26,exit\nldgp $gp,0($26)\nmov $31,$0\nL.5:\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end err\n.globl getword\n.text\n.ent getword\ngetword:\nldgp $gp,0($27)\nlda $sp,-96($sp)\n.mask 0x5006000,-72\n.frame $sp,96,$26,48\nstq $13,0($sp)\nstq $14,8($sp)\nstq $24,16($sp)\nstq $26,24($sp)\nstq $16,48($sp)\n.prologue 1\nL.8:\nL.9:\njsr $26,getchar\nldgp $gp,0($26)\nmov $0,$27\nmov $27,$14\nlda $25,-1\ncmpeq $27,$25,$23\nbne $23,L.11\nmov $14,$16\njsr $26,isletter\nldgp $gp,0($26)\ncmpeq $0,$31,$23\nbne $23,L.8\nL.11:\nldq $13,-48+96($sp)\nbr L.15\nL.12:\nmov $13,$27\nlda $13,1($27)\nmov $14,$25\nstb $25,($27)\nL.13:\njsr $26,getchar\nldgp $gp,0($26)\nmov $0,$14\nL.15:\nmov $14,$16\njsr $26,isletter\nldgp $gp,0($26)\nmov $0,$14\ncmpeq $0,$31,$23\nbeq $23,L.12\nstb $31,($13)\nmov $13,$27\nldq $25,-48+96($sp)\ncmpule $27,$25,$23\nbne $23,L.16\nlda $0,1\nbr L.7\nL.16:\nmov $31,$0\nL.7:\nldq $13,0($sp)\nldq $14,8($sp)\nldq $24,16($sp)\nldq $26,24($sp)\nlda $sp,96($sp)\nret\n.end getword\n.globl isletter\n.text\n.ent isletter\nisletter:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.frame $sp,64,$26,48\n.prologue 1\nlda $27,65\ncmplt $16,$27,$23\nbne $23,L.19\nlda $27,90\ncmple $16,$27,$23\nbeq $23,L.19\nlda $16,32($16)\nL.19:\nlda $27,97\ncmplt $16,$27,$23\nbne $23,L.21\nlda $27,122\ncmple $16,$27,$23\nbeq $23,L.21\nmov $16,$0\nbr L.18\nL.21:\nmov $31,$0\nL.18:\nlda $sp,64($sp)\nret\n.end isletter\n.globl lookup\n.text\n.ent lookup\nlookup:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4004000,-72\n.frame $sp,80,$26,48\nstq $14,0($sp)\nstq $26,8($sp)\nstq $16,32($sp)\nmov $17,$14\n.prologue 1\nldq $27,($14)\ncmpeq $27,$31,$23\nbne $23,L.24\nldq $16,-48+80($sp)\nldq $27,($14)\nldq $17,24($27)\njsr $26,strcmp\nldgp $gp,0($26)\nstl $0,-60+80($sp)\nldl $27,-60+80($sp)\ncmplt $27,$31,$23\nbeq $23,L.26\nldq $16,-48+80($sp)\nldq $27,($14)\nlda $17,8($27)\njsr $26,lookup\nldgp $gp,0($26)\nmov $0,$27\nbr L.23\nL.26:\nldl $27,-60+80($sp)\ncmple $27,$31,$23\nbne $23,L.28\nldq $16,-48+80($sp)\nldq $27,($14)\nlda $17,16($27)\njsr $26,lookup\nldgp $gp,0($26)\nmov $0,$27\nbr L.23\nL.28:\nldq $0,($14)\nbr L.23\nL.24:\nldl $27,next\nlda $25,2000\ncmplt $27,$25,$23\nbne $23,L.30\nlda $16,L.32\njsr $26,err\nldgp $gp,0($26)\nL.30:\nldl $27,next\nsll $27,5,$27\nstl $31,words($27)\nldl $27,next\nsll $27,5,$27\nstq $31,words+16($27)\nstq $31,words+8($27)\nldq $16,-48+80($sp)\njsr $26,strlen\nldgp $gp,0($26)\nmov $0,$27\nlda $16,1($27)\njsr $26,malloc\nldgp $gp,0($26)\nldl $25,next\nsll $25,5,$25\nstq $0,words+24($25)\nldl $27,next\nsll $27,5,$27\nldq $27,words+24($27)\ncmpeq $27,$31,$23\nbeq $23,L.36\nlda $16,L.39\njsr $26,err\nldgp $gp,0($26)\nL.36:\nldl $27,next\nsll $27,5,$27\nldq $16,words+24($27)\nldq $17,-48+80($sp)\njsr $26,strcpy\nldgp $gp,0($26)\nldl $27,next\nlda $25,1($27)\nstl $25,next\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,5,$27\nlda $27,words($27)\nstq $27,($14)\nmov $27,$0\nL.23:\nldq $14,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end lookup\n.globl tprint\n.text\n.ent tprint\ntprint:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4004000,-72\n.frame $sp,80,$26,48\nstq $14,0($sp)\nstq $26,8($sp)\nmov $16,$14\n.prologue 1\nmov $14,$27\ncmpeq $27,$31,$23\nbne $23,L.42\nldq $16,8($14)\njsr $26,tprint\nldgp $gp,0($26)\nlda $16,L.44\nldl $17,($14)\nldq $18,24($14)\njsr $26,printf\nldgp $gp,0($26)\nldq $16,16($14)\njsr $26,tprint\nldgp $gp,0($26)\nL.42:\nmov $31,$0\nL.41:\nldq $14,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end tprint\n.globl strcmp\n.text\n.ent strcmp\nstrcmp:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.frame $sp,64,$26,48\n.prologue 1\nbr L.47\nL.46:\nmov $16,$27\nlda $16,1($27)\nldb $27,($27)\ncmpeq $27,$31,$23\nbeq $23,L.49\nmov $31,$0\nbr L.45\nL.49:\nlda $17,1($17)\nL.47:\nldb $27,($16)\nldb $25,($17)\ncmpeq $27,$25,$23\nbne $23,L.46\nldb $27,($16)\ncmpeq $27,$31,$23\nbeq $23,L.51\nlda $0,-1\nbr L.45\nL.51:\nldb $27,($17)\ncmpeq $27,$31,$23\nbeq $23,L.53\nlda $0,1\nbr L.45\nL.53:\nldb $27,($16)\nldb $25,($17)\nsubl $27,$25,$0\nL.45:\nlda $sp,64($sp)\nret\n.end strcmp\n.globl next\n.comm next,4\n.globl words\n.comm words,64000\n.rdata\n.align 0\nL.44:\n.byte 37\n.byte 100\n.byte 9\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.39:\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 119\n.byte 111\n.byte 114\n.byte 100\n.byte 32\n.byte 115\n.byte 116\n.byte 111\n.byte 114\n.byte 97\n.byte 103\n.byte 101\n.byte 0\n.align 0\nL.32:\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 110\n.byte 111\n.byte 100\n.byte 101\n.byte 32\n.byte 115\n.byte 116\n.byte 111\n.byte 114\n.byte 97\n.byte 103\n.byte 101\n.byte 0\n.align 0\nL.6:\n.byte 63\n.byte 32\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/alpha/osf/tst/yacc.1bk",
    "content": "a\nb\nload\nnegate\npush 5\nc\nload\nmultiply\nadd\nstore\n"
  },
  {
    "path": "lcc/alpha/osf/tst/yacc.2bk",
    "content": "tst/yacc.c:345: warning: missing return value\ntst/yacc.c:349: warning: missing return value\ntst/yacc.c:359: warning: missing return value\n"
  },
  {
    "path": "lcc/alpha/osf/tst/yacc.sbk",
    "content": ".sdata\n.globl yyin\n.align 3\nyyin:\n.quad _iob\n.globl yyout\n.align 3\nyyout:\n.quad _iob+56\n.globl yylex\n.text\n.text\n.ent yylex\nyylex:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x4004000,-72\n.frame $sp,80,$26,48\nstq $14,0($sp)\nstq $26,8($sp)\n.prologue 1\nbr L.5\nL.4:\nL.7:\nlda $27,-1\ncmplt $14,$27,$23\nbne $23,L.8\ncmple $14,4,$23\nbeq $23,L.8\nsubl $14,-1,$27\nsll $27,3,$27\nldq $27,L.19($27)\njmp ($27)\n.rdata\n.align 3\nL.19:\n.quad L.9\n.quad L.10\n.quad L.13\n.quad L.14\n.quad L.9\n.quad L.16\n.text\nL.10:\njsr $26,yywrap\nldgp $gp,0($26)\ncmpeq $0,$31,$23\nbne $23,L.9\nmov $31,$0\nbr L.3\nL.13:\nlda $0,257\nbr L.3\nL.14:\nlda $0,258\nbr L.3\nL.16:\nlda $27,yytext\nldb $0,($27)\nbr L.3\nL.8:\nldq $16,yyout\nlda $17,L.18\nmov $14,$18\njsr $26,fprintf\nldgp $gp,0($26)\nL.9:\nL.5:\njsr $26,yylook\nldgp $gp,0($26)\nmov $0,$14\ncmplt $0,$31,$23\nbeq $23,L.4\nmov $31,$0\nL.3:\nldq $14,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end yylex\n.sdata\n.globl yyvstop\n.align 2\nyyvstop:\n.long 0x0\n.long 0x4\n.long 0x0\n.long 0x3\n.long 0x4\n.long 0x0\n.long 0x2\n.long 0x4\n.long 0x0\n.long 0x1\n.long 0x4\n.long 0x0\n.long 0x2\n.long 0x0\n.long 0x1\n.long 0x0\n.long 0x0\n.globl yycrank\n.align 0\nyycrank:\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x1\n.byte 0x3\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x1\n.byte 0x4\n.byte 0x1\n.byte 0x3\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x1\n.byte 0x5\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x1\n.byte 0x6\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x6\n.byte 0x8\n.byte 0x0\n.byte 0x0\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.globl yysvec\n.align 3\nyysvec:\n.quad 0x0\n.quad 0x0\n.quad 0x0\n.quad yycrank-2\n.quad 0x0\n.quad 0x0\n.quad yycrank\n.quad yysvec+24\n.quad 0x0\n.quad yycrank\n.quad 0x0\n.quad yyvstop+4\n.quad yycrank\n.quad 0x0\n.quad yyvstop+12\n.quad yycrank+4\n.quad 0x0\n.quad yyvstop+24\n.quad yycrank+38\n.quad 0x0\n.quad yyvstop+36\n.quad yycrank\n.quad yysvec+120\n.quad yyvstop+48\n.quad yycrank\n.quad yysvec+144\n.quad yyvstop+56\n.quad 0x0\n.quad 0x0\n.quad 0x0\n.globl yytop\n.align 3\nyytop:\n.quad yycrank+282\n.globl yybgin\n.align 3\nyybgin:\n.quad yysvec+24\n.globl yymatch\n.align 0\nyymatch:\n.byte 0\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 9\n.byte 10\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 9\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 65\n.byte 1\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 0\n.globl yyextra\n.align 0\nyyextra:\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.globl yylineno\n.align 2\nyylineno:\n.long 0x1\n.globl yysptr\n.align 3\nyysptr:\n.quad yysbuf\n.globl yyprevious\n.align 2\nyyprevious:\n.long 0xa\n.globl yylook\n.text\n.text\n.ent yylook\nyylook:\nldgp $gp,0($27)\nlda $sp,-160($sp)\n.mask 0x5007e00,-104\n.frame $sp,160,$26,48\nstq $9,0($sp)\nstq $10,8($sp)\nstq $11,16($sp)\nstq $12,24($sp)\nstq $13,32($sp)\nstq $14,40($sp)\nstq $24,48($sp)\nstq $26,56($sp)\n.prologue 1\nldl $27,yymorfg\ncmpeq $27,$31,$23\nbeq $23,L.35\nlda $11,yytext\nbr L.36\nL.35:\nstl $31,yymorfg\nldl $27,yyleng\nlda $11,yytext($27)\nL.36:\nL.37:\nlda $13,yylstate\nldq $27,yybgin\nmov $27,$14\nstq $27,yyestate\nldl $27,yyprevious\ncmpeq $27,10,$23\nbeq $23,L.41\nlda $14,24($14)\nL.41:\nL.43:\nldq $12,($14)\nmov $12,$27\nlda $25,yycrank\ncmpeq $27,$25,$23\nbeq $23,L.47\nldq $27,8($14)\nstq $27,-64+160($sp)\nldq $27,-64+160($sp)\ncmpeq $27,$31,$23\nbeq $23,L.49\nbr L.94\nL.49:\nldq $27,-64+160($sp)\nldq $27,($27)\nlda $25,yycrank\ncmpeq $27,$25,$23\nbeq $23,L.51\nbr L.94\nL.51:\nL.47:\nmov $11,$27\nstq $27,-88+160($sp)\nlda $11,1($27)\nldq $25,yysptr\nlda $22,yysbuf\ncmpule $25,$22,$23\nbne $23,L.61\nldq $25,yysptr\nlda $25,-1($25)\nstq $25,yysptr\nldb $25,($25)\nstl $25,-76+160($sp)\nbr L.62\nL.61:\nldq $25,yyin\nldl $22,($25)\nsubl $22,1,$22\nstl $22,($25)\ncmplt $22,$31,$23\nbeq $23,L.63\nldq $16,yyin\njsr $26,_filbuf\nldgp $gp,0($26)\nmov $0,$27\nstl $27,-80+160($sp)\nbr L.64\nL.63:\nldq $27,yyin\nlda $27,8($27)\nldq $25,($27)\nlda $22,1($25)\nstq $22,($27)\nldbu $27,($25)\nstl $27,-80+160($sp)\nL.64:\nldl $27,-80+160($sp)\nstl $27,-76+160($sp)\nL.62:\nldl $27,-76+160($sp)\nstl $27,yytchar\ncmpeq $27,10,$23\nbeq $23,L.59\nldl $27,yylineno\nlda $27,1($27)\nstl $27,yylineno\nldl $27,yytchar\nstl $27,-72+160($sp)\nbr L.60\nL.59:\nldl $27,yytchar\nstl $27,-72+160($sp)\nL.60:\nldl $27,-72+160($sp)\nlda $25,-1\ncmpeq $27,$25,$23\nbeq $23,L.57\nstl $31,-68+160($sp)\nbr L.58\nL.57:\nldl $27,yytchar\nstl $27,-68+160($sp)\nL.58:\nldl $27,-68+160($sp)\nmov $27,$10\nldq $25,-88+160($sp)\nstb $27,($25)\nL.65:\nmov $12,$9\nmov $12,$27\nlda $25,yycrank\ncmpule $27,$25,$23\nbne $23,L.66\nsll $10,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,1,$27\naddq $27,$9,$12\nmov $12,$27\nldq $25,yytop\ncmpule $27,$25,$23\nbeq $23,L.67\nlda $27,24\nldb $25,($12)\nsll $25,8*(8-4),$25\nsra $25,8*(8-4),$25\nmulq $27,$25,$27\nlda $27,yysvec($27)\nmov $14,$25\ncmpeq $27,$25,$23\nbeq $23,L.67\nlda $27,yysvec\nlda $25,24\nlda $22,1($12)\nldb $22,($22)\nsll $22,8*(8-4),$22\nsra $22,8*(8-4),$22\nmulq $25,$22,$25\nlda $25,yysvec($25)\ncmpeq $25,$27,$23\nbeq $23,L.70\nlda $27,-1($11)\nmov $27,$11\nldb $27,($27)\nstl $27,yytchar\nldl $27,yytchar\ncmpeq $27,10,$23\nbeq $23,L.72\nldl $27,yylineno\nsubl $27,1,$27\nstl $27,yylineno\nL.72:\nldq $27,yysptr\nlda $25,1($27)\nstq $25,yysptr\nldl $25,yytchar\nstb $25,($27)\nbr L.94\nL.70:\nmov $13,$27\nlda $13,8($27)\nlda $25,24\nlda $22,1($12)\nldb $22,($22)\nsll $22,8*(8-4),$22\nsra $22,8*(8-4),$22\nmulq $25,$22,$25\nlda $25,yysvec($25)\nmov $25,$14\nstq $25,($27)\nbr L.43\nL.66:\nmov $12,$27\nlda $25,yycrank\ncmpult $27,$25,$23\nbeq $23,L.75\nlda $27,yycrank\nmov $12,$25\nsubq $27,$25,$27\ndivq $27,2,$27\nsll $27,1,$27\nlda $27,yycrank($27)\nmov $27,$9\nmov $27,$12\nsll $10,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,1,$27\naddq $27,$12,$12\nmov $12,$27\nldq $25,yytop\ncmpule $27,$25,$23\nbeq $23,L.77\nlda $27,24\nldb $25,($12)\nsll $25,8*(8-4),$25\nsra $25,8*(8-4),$25\nmulq $27,$25,$27\nlda $27,yysvec($27)\nmov $14,$25\ncmpeq $27,$25,$23\nbeq $23,L.77\nlda $27,yysvec\nlda $25,24\nlda $22,1($12)\nldb $22,($22)\nsll $22,8*(8-4),$22\nsra $22,8*(8-4),$22\nmulq $25,$22,$25\nlda $25,yysvec($25)\ncmpeq $25,$27,$23\nbeq $23,L.79\nlda $27,-1($11)\nmov $27,$11\nldb $27,($27)\nstl $27,yytchar\nldl $27,yytchar\ncmpeq $27,10,$23\nbeq $23,L.81\nldl $27,yylineno\nsubl $27,1,$27\nstl $27,yylineno\nL.81:\nldq $27,yysptr\nlda $25,1($27)\nstq $25,yysptr\nldl $25,yytchar\nstb $25,($27)\nbr L.94\nL.79:\nmov $13,$27\nlda $13,8($27)\nlda $25,24\nlda $22,1($12)\nldb $22,($22)\nsll $22,8*(8-4),$22\nsra $22,8*(8-4),$22\nmulq $25,$22,$25\nlda $25,yysvec($25)\nmov $25,$14\nstq $25,($27)\nbr L.43\nL.77:\nlda $27,yymatch($10)\nldb $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,1,$27\naddq $27,$9,$12\nmov $12,$27\nldq $25,yytop\ncmpule $27,$25,$23\nbeq $23,L.83\nlda $27,24\nldb $25,($12)\nsll $25,8*(8-4),$25\nsra $25,8*(8-4),$25\nmulq $27,$25,$27\nlda $27,yysvec($27)\nmov $14,$25\ncmpeq $27,$25,$23\nbeq $23,L.83\nlda $27,yysvec\nlda $25,24\nlda $22,1($12)\nldb $22,($22)\nsll $22,8*(8-4),$22\nsra $22,8*(8-4),$22\nmulq $25,$22,$25\nlda $25,yysvec($25)\ncmpeq $25,$27,$23\nbeq $23,L.85\nlda $27,-1($11)\nmov $27,$11\nldb $27,($27)\nstl $27,yytchar\nldl $27,yytchar\ncmpeq $27,10,$23\nbeq $23,L.87\nldl $27,yylineno\nsubl $27,1,$27\nstl $27,yylineno\nL.87:\nldq $27,yysptr\nlda $25,1($27)\nstq $25,yysptr\nldl $25,yytchar\nstb $25,($27)\nbr L.94\nL.85:\nmov $13,$27\nlda $13,8($27)\nlda $25,24\nlda $22,1($12)\nldb $22,($22)\nsll $22,8*(8-4),$22\nsra $22,8*(8-4),$22\nmulq $25,$22,$25\nlda $25,yysvec($25)\nmov $25,$14\nstq $25,($27)\nbr L.43\nL.83:\nL.75:\nL.67:\nldq $27,8($14)\nmov $27,$14\ncmpeq $27,$31,$23\nbne $23,L.89\nldq $27,($14)\nmov $27,$12\nlda $25,yycrank\ncmpeq $27,$25,$23\nbne $23,L.89\nbr L.65\nL.89:\nlda $27,-1($11)\nmov $27,$11\nldb $27,($27)\nstl $27,yytchar\nldl $27,yytchar\ncmpeq $27,10,$23\nbeq $23,L.91\nldl $27,yylineno\nsubl $27,1,$27\nstl $27,yylineno\nL.91:\nldq $27,yysptr\nlda $25,1($27)\nstq $25,yysptr\nldl $25,yytchar\nstb $25,($27)\nbr L.94\nL.93:\nmov $11,$27\nlda $11,-1($27)\nstb $31,($27)\nldq $27,($13)\nmov $31,$25\nmov $27,$22\ncmpeq $22,$25,$23\nbne $23,L.96\nldq $27,16($27)\nstq $27,yyfnd\ncmpeq $27,$25,$23\nbne $23,L.96\nldq $27,yyfnd\nldl $27,($27)\ncmple $27,$31,$23\nbne $23,L.96\nstq $13,yyolsp\nldq $27,yyfnd\nldl $27,($27)\nlda $27,yyextra($27)\nldb $27,($27)\ncmpeq $27,$31,$23\nbne $23,L.98\nbr L.101\nL.100:\nlda $13,-8($13)\nmov $11,$27\nlda $11,-1($27)\nldb $27,($27)\nstl $27,yytchar\nldl $27,yytchar\ncmpeq $27,10,$23\nbeq $23,L.103\nldl $27,yylineno\nsubl $27,1,$27\nstl $27,yylineno\nL.103:\nldq $27,yysptr\nlda $25,1($27)\nstq $25,yysptr\nldl $25,yytchar\nstb $25,($27)\nL.101:\nldq $27,($13)\nldq $16,16($27)\nldq $27,yyfnd\nldl $27,($27)\nnegl $27,$17\njsr $26,yyback\nldgp $gp,0($26)\ncmpeq $0,1,$23\nbne $23,L.105\nmov $13,$27\nlda $25,yylstate\ncmpule $27,$25,$23\nbeq $23,L.100\nL.105:\nL.98:\nldb $27,($11)\nstl $27,yyprevious\nstq $13,yylsp\nlda $27,yytext\nmov $11,$25\nsubq $25,$27,$27\nlda $27,1($27)\nstl $27,yyleng\nldl $27,yyleng\nstb $31,yytext($27)\nldq $27,yyfnd\nlda $25,4($27)\nstq $25,yyfnd\nldl $0,($27)\nbr L.34\nL.96:\nldb $27,($11)\nstl $27,yytchar\nldl $27,yytchar\ncmpeq $27,10,$23\nbeq $23,L.106\nldl $27,yylineno\nsubl $27,1,$27\nstl $27,yylineno\nL.106:\nldq $27,yysptr\nlda $25,1($27)\nstq $25,yysptr\nldl $25,yytchar\nstb $25,($27)\nL.94:\nmov $13,$27\nlda $13,-8($27)\nlda $25,yylstate\ncmpule $27,$25,$23\nbeq $23,L.93\nlda $27,yytext\nldb $27,($27)\ncmpeq $27,$31,$23\nbeq $23,L.108\nlda $27,yysbuf\nstq $27,yysptr\nmov $31,$0\nbr L.34\nL.108:\nldq $27,yysptr\nlda $25,yysbuf\ncmpule $27,$25,$23\nbne $23,L.118\nldq $27,yysptr\nlda $27,-1($27)\nstq $27,yysptr\nldb $27,($27)\nstl $27,-76+160($sp)\nbr L.119\nL.118:\nldq $27,yyin\nldl $25,($27)\nsubl $25,1,$25\nstl $25,($27)\ncmplt $25,$31,$23\nbeq $23,L.120\nldq $16,yyin\njsr $26,_filbuf\nldgp $gp,0($26)\nmov $0,$27\nstl $27,-80+160($sp)\nbr L.121\nL.120:\nldq $27,yyin\nlda $27,8($27)\nldq $25,($27)\nlda $22,1($25)\nstq $22,($27)\nldbu $27,($25)\nstl $27,-80+160($sp)\nL.121:\nldl $27,-80+160($sp)\nstl $27,-76+160($sp)\nL.119:\nldl $27,-76+160($sp)\nstl $27,yytchar\ncmpeq $27,10,$23\nbeq $23,L.116\nldl $27,yylineno\nlda $27,1($27)\nstl $27,yylineno\nldl $27,yytchar\nstl $27,-72+160($sp)\nbr L.117\nL.116:\nldl $27,yytchar\nstl $27,-72+160($sp)\nL.117:\nldl $27,-72+160($sp)\nlda $25,-1\ncmpeq $27,$25,$23\nbeq $23,L.114\nstl $31,-68+160($sp)\nbr L.115\nL.114:\nldl $27,yytchar\nstl $27,-68+160($sp)\nL.115:\nldl $27,-68+160($sp)\nstb $27,yytext\nsll $27,8*(8-1),$27\nsra $27,8*(8-1),$27\nstl $27,yyprevious\nldl $27,yyprevious\ncmple $27,$31,$23\nbne $23,L.122\nldq $27,yyout\nldl $25,($27)\nsubl $25,1,$25\nstl $25,($27)\ncmplt $25,$31,$23\nbeq $23,L.125\nldl $27,yyprevious\nand $27,(1<<(8*1))-1,$27\nmov $27,$16\nldq $17,yyout\njsr $26,_flsbuf\nldgp $gp,0($26)\nbr L.126\nL.125:\nldq $27,yyout\nlda $27,8($27)\nldq $25,($27)\nlda $22,1($25)\nstq $22,($27)\nldl $27,yyprevious\nstb $27,($25)\nL.126:\nL.122:\nlda $11,yytext\nbr L.37\nL.34:\nldq $9,0($sp)\nldq $10,8($sp)\nldq $11,16($sp)\nldq $12,24($sp)\nldq $13,32($sp)\nldq $14,40($sp)\nldq $24,48($sp)\nldq $26,56($sp)\nlda $sp,160($sp)\nret\n.end yylook\n.globl yyback\n.text\n.ent yyback\nyyback:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.frame $sp,64,$26,48\n.prologue 1\nmov $16,$27\ncmpeq $27,$31,$23\nbeq $23,L.131\nmov $31,$0\nbr L.127\nL.130:\nmov $16,$27\nlda $16,4($27)\nldl $27,($27)\ncmpeq $27,$17,$23\nbeq $23,L.133\nlda $0,1\nbr L.127\nL.133:\nL.131:\nldl $27,($16)\ncmpeq $27,$31,$23\nbeq $23,L.130\nmov $31,$0\nL.127:\nlda $sp,64($sp)\nret\n.end yyback\n.globl yyinput\n.text\n.ent yyinput\nyyinput:\nldgp $gp,0($27)\nlda $sp,-96($sp)\n.mask 0x4007800,-64\n.frame $sp,96,$26,48\nstq $11,0($sp)\nstq $12,8($sp)\nstq $13,16($sp)\nstq $14,24($sp)\nstq $26,32($sp)\n.prologue 1\nldq $27,yysptr\nlda $25,yysbuf\ncmpule $27,$25,$23\nbne $23,L.144\nldq $27,yysptr\nlda $27,-1($27)\nstq $27,yysptr\nldb $12,($27)\nbr L.145\nL.144:\nldq $27,yyin\nldl $25,($27)\nsubl $25,1,$25\nstl $25,($27)\ncmplt $25,$31,$23\nbeq $23,L.146\nldq $16,yyin\njsr $26,_filbuf\nldgp $gp,0($26)\nmov $0,$27\nmov $27,$11\nbr L.147\nL.146:\nldq $27,yyin\nlda $27,8($27)\nldq $25,($27)\nlda $22,1($25)\nstq $22,($27)\nldbu $11,($25)\nL.147:\nmov $11,$12\nL.145:\nstl $12,yytchar\ncmpeq $12,10,$23\nbeq $23,L.142\nldl $27,yylineno\nlda $27,1($27)\nstl $27,yylineno\nldl $13,yytchar\nbr L.143\nL.142:\nldl $13,yytchar\nL.143:\nlda $27,-1\ncmpeq $13,$27,$23\nbeq $23,L.140\nmov $31,$14\nbr L.141\nL.140:\nldl $14,yytchar\nL.141:\nmov $14,$0\nL.135:\nldq $11,0($sp)\nldq $12,8($sp)\nldq $13,16($sp)\nldq $14,24($sp)\nldq $26,32($sp)\nlda $sp,96($sp)\nret\n.end yyinput\n.globl yyoutput\n.text\n.ent yyoutput\nyyoutput:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x5000000,-72\n.frame $sp,80,$26,48\nstq $24,0($sp)\nstq $26,8($sp)\nstq $16,32($sp)\n.prologue 1\nldq $27,yyout\nldl $25,($27)\nsubl $25,1,$25\nstl $25,($27)\ncmplt $25,$31,$23\nbeq $23,L.150\nldl $27,-48+80($sp)\nand $27,(1<<(8*1))-1,$27\nmov $27,$16\nldq $17,yyout\njsr $26,_flsbuf\nldgp $gp,0($26)\nbr L.151\nL.150:\nldq $27,yyout\nlda $27,8($27)\nldq $25,($27)\nlda $22,1($25)\nstq $22,($27)\nldl $27,-48+80($sp)\nstb $27,($25)\nL.151:\nmov $31,$0\nL.148:\nldq $24,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end yyoutput\n.globl yyunput\n.text\n.ent yyunput\nyyunput:\nldgp $gp,0($27)\nlda $sp,-80($sp)\n.mask 0x5000000,-72\n.frame $sp,80,$26,48\nstq $24,0($sp)\nstq $26,8($sp)\n.prologue 1\nstl $16,yytchar\nldl $27,yytchar\ncmpeq $27,10,$23\nbeq $23,L.153\nldl $27,yylineno\nsubl $27,1,$27\nstl $27,yylineno\nL.153:\nldq $27,yysptr\nlda $25,1($27)\nstq $25,yysptr\nldl $25,yytchar\nstb $25,($27)\nmov $31,$0\nL.152:\nldq $24,0($sp)\nldq $26,8($sp)\nlda $sp,80($sp)\nret\n.end yyunput\n.globl main\n.text\n.ent main\nmain:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\n.prologue 1\njsr $26,yyparse\nldgp $gp,0($26)\nmov $31,$0\nL.155:\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end main\n.globl yyerror\n.text\n.ent yyerror\nyyerror:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.mask 0x4000000,-64\n.frame $sp,64,$26,48\nstq $26,0($sp)\nstq $16,16($sp)\n.prologue 1\nlda $16,L.157\nldq $17,-48+64($sp)\njsr $26,printf\nldgp $gp,0($26)\nmov $31,$0\nL.156:\nldq $26,0($sp)\nlda $sp,64($sp)\nret\n.end yyerror\n.sdata\n.globl yyexca\n.align 1\nyyexca:\n.word 0xffff\n.word 0x1\n.word 0x0\n.word 0xffff\n.word 0xfffe\n.word 0x0\n.globl yyact\n.align 1\nyyact:\n.word 0xc\n.word 0x2\n.word 0x9\n.word 0x8\n.word 0x11\n.word 0xb\n.word 0x19\n.word 0x11\n.word 0xf\n.word 0x12\n.word 0x10\n.word 0xa\n.word 0x12\n.word 0x11\n.word 0xf\n.word 0x7\n.word 0x10\n.word 0xd\n.word 0x12\n.word 0x5\n.word 0x3\n.word 0x1\n.word 0x0\n.word 0x13\n.word 0x14\n.word 0x0\n.word 0x0\n.word 0x15\n.word 0x16\n.word 0x17\n.word 0x18\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x6\n.word 0xe\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x4\n.word 0x6\n.globl yypact\n.align 1\nyypact:\n.word 0xfc18\n.word 0xfff7\n.word 0xfc18\n.word 0x5\n.word 0xfff9\n.word 0xffc5\n.word 0xfc18\n.word 0xfc18\n.word 0xfc18\n.word 0xffd8\n.word 0xffe3\n.word 0xffd8\n.word 0xffd8\n.word 0xfc18\n.word 0xfc18\n.word 0xffd8\n.word 0xffd8\n.word 0xffd8\n.word 0xffd8\n.word 0xffda\n.word 0xffdd\n.word 0xffda\n.word 0xffda\n.word 0xfc18\n.word 0xfc18\n.word 0xfc18\n.globl yypgo\n.align 1\nyypgo:\n.word 0x0\n.word 0x15\n.word 0x14\n.word 0x11\n.word 0xb\n.globl yyr1\n.align 1\nyyr1:\n.word 0x0\n.word 0x1\n.word 0x1\n.word 0x1\n.word 0x1\n.word 0x2\n.word 0x4\n.word 0x4\n.word 0x4\n.word 0x4\n.word 0x4\n.word 0x4\n.word 0x4\n.word 0x4\n.word 0x3\n.globl yyr2\n.align 1\nyyr2:\n.word 0x0\n.word 0x0\n.word 0x2\n.word 0x3\n.word 0x3\n.word 0x3\n.word 0x3\n.word 0x3\n.word 0x3\n.word 0x3\n.word 0x2\n.word 0x3\n.word 0x1\n.word 0x1\n.word 0x1\n.globl yychk\n.align 1\nyychk:\n.word 0xfc18\n.word 0xffff\n.word 0xa\n.word 0xfffe\n.word 0x100\n.word 0xfffd\n.word 0x101\n.word 0xa\n.word 0xa\n.word 0x3d\n.word 0xfffc\n.word 0x2d\n.word 0x28\n.word 0xfffd\n.word 0x102\n.word 0x2b\n.word 0x2d\n.word 0x2a\n.word 0x2f\n.word 0xfffc\n.word 0xfffc\n.word 0xfffc\n.word 0xfffc\n.word 0xfffc\n.word 0xfffc\n.word 0x29\n.globl yydef\n.align 1\nyydef:\n.word 0x1\n.word 0xfffe\n.word 0x2\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0xe\n.word 0x3\n.word 0x4\n.word 0x0\n.word 0x5\n.word 0x0\n.word 0x0\n.word 0xc\n.word 0xd\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0xa\n.word 0x0\n.word 0x6\n.word 0x7\n.word 0x8\n.word 0x9\n.word 0xb\n.globl yychar\n.align 2\nyychar:\n.long 0xffffffff\n.globl yynerrs\n.align 2\nyynerrs:\n.long 0x0\n.globl yyerrflag\n.align 1\nyyerrflag:\n.word 0x0\n.globl yyparse\n.text\n.text\n.ent yyparse\nyyparse:\nldgp $gp,0($27)\nlda $sp,-432($sp)\n.mask 0x5007e00,-376\n.frame $sp,432,$26,48\nstq $9,0($sp)\nstq $10,8($sp)\nstq $11,16($sp)\nstq $12,24($sp)\nstq $13,32($sp)\nstq $14,40($sp)\nstq $24,48($sp)\nstq $26,56($sp)\n.prologue 1\nmov $31,$27\nmov $27,$13\nlda $25,-1\nstl $25,yychar\nstl $31,yynerrs\nstw $27,yyerrflag\nlda $12,-360+432($sp)\nlda $10,yyv-4\nL.161:\nlda $27,2($12)\nmov $27,$12\nlda $25,-58+432($sp)\ncmpule $27,$25,$23\nbne $23,L.162\nlda $16,L.165\njsr $26,yyerror\nldgp $gp,0($26)\nlda $0,1\nbr L.158\nL.162:\nstw $13,($12)\nlda $10,4($10)\nldl $27,yyval\nstl $27,($10)\nL.166:\nsll $13,8*(8-2),$27\nsra $27,8*(8-2),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,1,$27\nlda $27,yypact($27)\nldw $11,($27)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-1000\ncmple $27,$25,$23\nbeq $23,L.167\nbr L.169\nL.167:\nldl $27,yychar\ncmplt $27,$31,$23\nbeq $23,L.170\njsr $26,yylex\nldgp $gp,0($26)\nstl $0,yychar\ncmplt $0,$31,$23\nbeq $23,L.172\nstl $31,yychar\nL.172:\nL.170:\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nldl $25,yychar\naddl $27,$25,$27\nmov $27,$11\nsll $27,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmplt $27,$31,$23\nbne $23,L.176\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,249\ncmplt $27,$25,$23\nbne $23,L.174\nL.176:\nbr L.169\nL.174:\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,1,$27\nlda $27,yyact($27)\nldw $27,($27)\nmov $27,$11\nsll $27,8*(8-2),$27\nsra $27,8*(8-2),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,1,$27\nlda $27,yychk($27)\nldw $27,($27)\nldl $25,yychar\ncmpeq $27,$25,$23\nbeq $23,L.177\nlda $27,-1\nstl $27,yychar\nldl $27,yylval\nstl $27,yyval\nmov $11,$13\nlda $27,yyerrflag\nldw $27,($27)\ncmple $27,$31,$23\nbne $23,L.161\nlda $27,yyerrflag\nldw $27,($27)\nsubl $27,1,$27\nstw $27,yyerrflag\nbr L.161\nL.177:\nL.169:\nsll $13,8*(8-2),$27\nsra $27,8*(8-2),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,1,$27\nlda $27,yydef($27)\nldw $27,($27)\nmov $27,$11\nsll $27,8*(8-2),$27\nsra $27,8*(8-2),$27\nlda $25,-2\ncmpeq $27,$25,$23\nbeq $23,L.181\nldl $27,yychar\ncmplt $27,$31,$23\nbeq $23,L.183\njsr $26,yylex\nldgp $gp,0($26)\nstl $0,yychar\ncmplt $0,$31,$23\nbeq $23,L.185\nstl $31,yychar\nL.185:\nL.183:\nlda $9,yyexca\nbr L.190\nL.187:\nL.188:\nlda $9,4($9)\nL.190:\nldw $27,($9)\nlda $25,-1\ncmpeq $27,$25,$23\nbeq $23,L.187\nlda $27,2($9)\nldw $27,($27)\nsll $13,8*(8-2),$25\nsra $25,8*(8-2),$25\ncmpeq $27,$25,$23\nbeq $23,L.187\nbr L.192\nL.191:\nldw $27,($9)\nldl $25,yychar\ncmpeq $27,$25,$23\nbeq $23,L.194\nbr L.193\nL.194:\nL.192:\nlda $27,4($9)\nmov $27,$9\nldw $27,($27)\ncmplt $27,$31,$23\nbeq $23,L.191\nL.193:\nlda $27,2($9)\nldw $27,($27)\nmov $27,$11\nsll $27,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmplt $27,$31,$23\nbeq $23,L.196\nmov $31,$0\nbr L.158\nL.196:\nL.181:\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmpeq $27,$31,$23\nbeq $23,L.198\nlda $27,yyerrflag\nldw $27,($27)\nstl $27,-364+432($sp)\nldl $27,-364+432($sp)\ncmplt $27,$31,$23\nbne $23,L.200\ncmple $27,3,$23\nbeq $23,L.200\nsll $27,3,$27\nldq $27,L.216($27)\njmp ($27)\n.rdata\n.align 3\nL.216:\n.quad L.203\n.quad L.206\n.quad L.206\n.quad L.213\n.text\nL.203:\nlda $16,L.204\njsr $26,yyerror\nldgp $gp,0($26)\nL.205:\nldl $27,yynerrs\nlda $27,1($27)\nstl $27,yynerrs\nL.206:\nlda $27,3\nstw $27,yyerrflag\nbr L.208\nL.207:\nldw $27,($12)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,1,$27\nlda $27,yypact($27)\nldw $27,($27)\nlda $27,256($27)\nmov $27,$11\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\ncmplt $27,$31,$23\nbne $23,L.210\nlda $25,249\ncmplt $27,$25,$23\nbeq $23,L.210\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,1,$27\nlda $27,yyact($27)\nldw $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,1,$27\nlda $27,yychk($27)\nldw $27,($27)\nlda $25,256\ncmpeq $27,$25,$23\nbeq $23,L.210\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,1,$27\nlda $27,yyact($27)\nldw $13,($27)\nbr L.161\nL.210:\nldw $27,($12)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,1,$27\nlda $27,yypact($27)\nldw $11,($27)\nlda $12,-2($12)\nlda $10,-4($10)\nL.208:\nmov $12,$27\nlda $25,-358+432($sp)\ncmpult $27,$25,$23\nbeq $23,L.207\nL.212:\nlda $0,1\nbr L.158\nL.213:\nldl $27,yychar\ncmpeq $27,$31,$23\nbeq $23,L.214\nbr L.212\nL.214:\nlda $27,-1\nstl $27,yychar\nbr L.166\nL.200:\nL.198:\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,1,$27\nlda $25,yyr2($27)\nldw $22,($25)\nsll $22,8*(8-4),$22\nsra $22,8*(8-4),$22\nsll $22,1,$22\nsubq $12,$22,$12\nmov $10,$14\nldw $25,($25)\nsll $25,8*(8-4),$25\nsra $25,8*(8-4),$25\nsll $25,2,$25\nsubq $10,$25,$10\nldl $25,4($10)\nstl $25,yyval\nstw $11,-360+432($sp)\nlda $27,yyr1($27)\nldw $11,($27)\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,1,$27\nlda $27,yypgo($27)\nldw $27,($27)\nldw $25,($12)\naddl $27,$25,$27\nlda $27,1($27)\nstw $27,-58+432($sp)\nlda $27,-58+432($sp)\nldw $27,($27)\nlda $25,249\ncmplt $27,$25,$23\nbeq $23,L.219\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,1,$27\nlda $27,yyact($27)\nldw $27,($27)\nmov $27,$13\nsll $27,8*(8-2),$27\nsra $27,8*(8-2),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,1,$27\nlda $27,yychk($27)\nldw $27,($27)\nsll $11,8*(8-2),$25\nsra $25,8*(8-2),$25\nnegl $25,$25\ncmpeq $27,$25,$23\nbne $23,L.217\nL.219:\nsll $11,8*(8-2),$27\nsra $27,8*(8-2),$27\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,1,$27\nlda $27,yypgo($27)\nldw $27,($27)\nsll $27,8*(8-4),$27\nsra $27,8*(8-4),$27\nsll $27,1,$27\nlda $27,yyact($27)\nldw $13,($27)\nL.217:\nlda $27,-360+432($sp)\nldw $27,($27)\nstl $27,-364+432($sp)\nldl $27,-364+432($sp)\ncmplt $27,4,$23\nbne $23,L.161\ncmple $27,14,$23\nbeq $23,L.161\nsubl $27,4,$27\nsll $27,3,$27\nldq $27,L.241($27)\njmp ($27)\n.rdata\n.align 3\nL.241:\n.quad L.223\n.quad L.224\n.quad L.226\n.quad L.228\n.quad L.230\n.quad L.232\n.quad L.234\n.quad L.161\n.quad L.236\n.quad L.238\n.quad L.240\n.text\nL.223:\nstw $31,yyerrflag\nbr L.161\nL.224:\nlda $16,L.225\njsr $26,printf\nldgp $gp,0($26)\nbr L.161\nL.226:\nlda $16,L.227\njsr $26,printf\nldgp $gp,0($26)\nbr L.161\nL.228:\nlda $16,L.229\njsr $26,printf\nldgp $gp,0($26)\nbr L.161\nL.230:\nlda $16,L.231\njsr $26,printf\nldgp $gp,0($26)\nbr L.161\nL.232:\nlda $16,L.233\njsr $26,printf\nldgp $gp,0($26)\nbr L.161\nL.234:\nlda $16,L.235\njsr $26,printf\nldgp $gp,0($26)\nbr L.161\nL.236:\nlda $16,L.237\njsr $26,printf\nldgp $gp,0($26)\nbr L.161\nL.238:\nlda $16,L.239\nlda $17,yytext\njsr $26,printf\nldgp $gp,0($26)\nbr L.161\nL.240:\nlda $16,L.157\nlda $17,yytext\njsr $26,printf\nldgp $gp,0($26)\nbr L.161\nL.158:\nldq $9,0($sp)\nldq $10,8($sp)\nldq $11,16($sp)\nldq $12,24($sp)\nldq $13,32($sp)\nldq $14,40($sp)\nldq $24,48($sp)\nldq $26,56($sp)\nlda $sp,432($sp)\nret\n.end yyparse\n.globl yywrap\n.text\n.ent yywrap\nyywrap:\nldgp $gp,0($27)\nlda $sp,-64($sp)\n.frame $sp,64,$26,48\n.prologue 1\nlda $0,1\nL.242:\nlda $sp,64($sp)\nret\n.end yywrap\n.globl yyv\n.comm yyv,600\n.globl yyfnd\n.comm yyfnd,8\n.globl yyolsp\n.comm yyolsp,8\n.globl yylsp\n.comm yylsp,8\n.globl yylstate\n.comm yylstate,1600\n.globl yyestate\n.comm yyestate,8\n.globl yytchar\n.comm yytchar,4\n.globl yysbuf\n.comm yysbuf,200\n.globl yymorfg\n.comm yymorfg,4\n.globl yytext\n.comm yytext,200\n.globl yyleng\n.comm yyleng,4\n.extern _iob 0\n.globl yyval\n.comm yyval,4\n.globl yylval\n.comm yylval,4\n.rdata\n.align 0\nL.239:\n.byte 112\n.byte 117\n.byte 115\n.byte 104\n.byte 32\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.237:\n.byte 108\n.byte 111\n.byte 97\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.235:\n.byte 110\n.byte 101\n.byte 103\n.byte 97\n.byte 116\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.233:\n.byte 100\n.byte 105\n.byte 118\n.byte 105\n.byte 100\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.231:\n.byte 109\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 121\n.byte 10\n.byte 0\n.align 0\nL.229:\n.byte 110\n.byte 101\n.byte 103\n.byte 97\n.byte 116\n.byte 101\n.byte 10\n.byte 97\n.byte 100\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.227:\n.byte 97\n.byte 100\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.225:\n.byte 115\n.byte 116\n.byte 111\n.byte 114\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.204:\n.byte 115\n.byte 121\n.byte 110\n.byte 116\n.byte 97\n.byte 120\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 0\n.align 0\nL.165:\n.byte 121\n.byte 97\n.byte 99\n.byte 99\n.byte 32\n.byte 115\n.byte 116\n.byte 97\n.byte 99\n.byte 107\n.byte 32\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 0\n.align 0\nL.157:\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.18:\n.byte 98\n.byte 97\n.byte 100\n.byte 32\n.byte 115\n.byte 119\n.byte 105\n.byte 116\n.byte 99\n.byte 104\n.byte 32\n.byte 121\n.byte 121\n.byte 108\n.byte 111\n.byte 111\n.byte 107\n.byte 32\n.byte 37\n.byte 100\n.byte 0\n"
  },
  {
    "path": "lcc/buildnt.bat",
    "content": "call vcvars32\nset BUILDDIR=bin\nnmake -f makefile.nt all\n"
  },
  {
    "path": "lcc/buildnt.sh",
    "content": "#!/bin/sh\nexport BUILDDIR=.\\\\out\nmkdir out\nnmake -f makefile.nt all\n"
  },
  {
    "path": "lcc/cpp/cpp.c",
    "content": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <time.h>\n#include <stdarg.h>\n#include \"cpp.h\"\n\nchar rcsid[] = \"cpp.c - faked rcsid\";\n\n#define\tOUTS\t16384\nchar\toutbuf[OUTS];\nchar\t*outp = outbuf;\nSource\t*cursource;\nint\tnerrs;\nstruct\ttoken nltoken = { NL, 0, 0, 0, 1, (uchar*)\"\\n\" };\nchar\t*curtime;\nint\tincdepth;\nint\tifdepth;\nint\tifsatisfied[NIF];\nint\tskipping;\n\n\nint\nmain(int argc, char **argv)\n{\n\tTokenrow tr;\n\ttime_t t;\n\tchar ebuf[BUFSIZ];\n\n\tsetbuf(stderr, ebuf);\n\tt = time(NULL);\n\tcurtime = ctime(&t);\n\tmaketokenrow(3, &tr);\n\texpandlex();\n\tsetup(argc, argv);\n\tfixlex();\n\tiniths();\n\tgenline();\n\tprocess(&tr);\n\tflushout();\n\tfflush(stderr);\n\texit(nerrs > 0);\n\treturn 0;\n}\n\nvoid\nprocess(Tokenrow *trp)\n{\n\tint anymacros = 0;\n\n\tfor (;;) {\n\t\tif (trp->tp >= trp->lp) {\n\t\t\ttrp->tp = trp->lp = trp->bp;\n\t\t\toutp = outbuf;\n\t\t\tanymacros |= gettokens(trp, 1);\n\t\t\ttrp->tp = trp->bp;\n\t\t}\n\t\tif (trp->tp->type == END) {\n\t\t\tif (--incdepth>=0) {\n\t\t\t\tif (cursource->ifdepth)\n\t\t\t\t\terror(ERROR,\n\t\t\t\t\t \"Unterminated conditional in #include\");\n\t\t\t\tunsetsource();\n\t\t\t\tcursource->line += cursource->lineinc;\n\t\t\t\ttrp->tp = trp->lp;\n\t\t\t\tgenline();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (ifdepth)\n\t\t\t\terror(ERROR, \"Unterminated #if/#ifdef/#ifndef\");\n\t\t\tbreak;\n\t\t}\n\t\tif (trp->tp->type==SHARP) {\n\t\t\ttrp->tp += 1;\n\t\t\tcontrol(trp);\n\t\t} else if (!skipping && anymacros)\n\t\t\texpandrow(trp, NULL);\n\t\tif (skipping)\n\t\t\tsetempty(trp);\n\t\tputtokens(trp);\n\t\tanymacros = 0;\n\t\tcursource->line += cursource->lineinc;\n\t\tif (cursource->lineinc>1) {\n\t\t\tgenline();\n\t\t}\n\t}\n}\n\t\nvoid\ncontrol(Tokenrow *trp)\n{\n\tNlist *np;\n\tToken *tp;\n\n\ttp = trp->tp;\n\tif (tp->type!=NAME) {\n\t\tif (tp->type==NUMBER)\n\t\t\tgoto kline;\n\t\tif (tp->type != NL)\n\t\t\terror(ERROR, \"Unidentifiable control line\");\n\t\treturn;\t\t\t/* else empty line */\n\t}\n\tif ((np = lookup(tp, 0))==NULL || (np->flag&ISKW)==0 && !skipping) {\n\t\terror(WARNING, \"Unknown preprocessor control %t\", tp);\n\t\treturn;\n\t}\n\tif (skipping) {\n\t\tswitch (np->val) {\n\t\tcase KENDIF:\n\t\t\tif (--ifdepth<skipping)\n\t\t\t\tskipping = 0;\n\t\t\t--cursource->ifdepth;\n\t\t\tsetempty(trp);\n\t\t\treturn;\n\n\t\tcase KIFDEF:\n\t\tcase KIFNDEF:\n\t\tcase KIF:\n\t\t\tif (++ifdepth >= NIF)\n\t\t\t\terror(FATAL, \"#if too deeply nested\");\n\t\t\t++cursource->ifdepth;\n\t\t\treturn;\n\n\t\tcase KELIF:\n\t\tcase KELSE:\n\t\t\tif (ifdepth<=skipping)\n\t\t\t\tbreak;\n\t\t\treturn;\n\n\t\tdefault:\n\t\t\treturn;\n\t\t}\n\t}\n\tswitch (np->val) {\n\tcase KDEFINE:\n\t\tdodefine(trp);\n\t\tbreak;\n\n\tcase KUNDEF:\n\t\ttp += 1;\n\t\tif (tp->type!=NAME || trp->lp - trp->bp != 4) {\n\t\t\terror(ERROR, \"Syntax error in #undef\");\n\t\t\tbreak;\n\t\t}\n\t\tif ((np = lookup(tp, 0)) != NULL)\n\t\t\tnp->flag &= ~ISDEFINED;\n\t\tbreak;\n\n\tcase KPRAGMA:\n\t\treturn;\n\n\tcase KIFDEF:\n\tcase KIFNDEF:\n\tcase KIF:\n\t\tif (++ifdepth >= NIF)\n\t\t\terror(FATAL, \"#if too deeply nested\");\n\t\t++cursource->ifdepth;\n\t\tifsatisfied[ifdepth] = 0;\n\t\tif (eval(trp, np->val))\n\t\t\tifsatisfied[ifdepth] = 1;\n\t\telse\n\t\t\tskipping = ifdepth;\n\t\tbreak;\n\n\tcase KELIF:\n\t\tif (ifdepth==0) {\n\t\t\terror(ERROR, \"#elif with no #if\");\n\t\t\treturn;\n\t\t}\n\t\tif (ifsatisfied[ifdepth]==2)\n\t\t\terror(ERROR, \"#elif after #else\");\n\t\tif (eval(trp, np->val)) {\n\t\t\tif (ifsatisfied[ifdepth])\n\t\t\t\tskipping = ifdepth;\n\t\t\telse {\n\t\t\t\tskipping = 0;\n\t\t\t\tifsatisfied[ifdepth] = 1;\n\t\t\t}\n\t\t} else\n\t\t\tskipping = ifdepth;\n\t\tbreak;\n\n\tcase KELSE:\n\t\tif (ifdepth==0 || cursource->ifdepth==0) {\n\t\t\terror(ERROR, \"#else with no #if\");\n\t\t\treturn;\n\t\t}\n\t\tif (ifsatisfied[ifdepth]==2)\n\t\t\terror(ERROR, \"#else after #else\");\n\t\tif (trp->lp - trp->bp != 3)\n\t\t\terror(ERROR, \"Syntax error in #else\");\n\t\tskipping = ifsatisfied[ifdepth]? ifdepth: 0;\n\t\tifsatisfied[ifdepth] = 2;\n\t\tbreak;\n\n\tcase KENDIF:\n\t\tif (ifdepth==0 || cursource->ifdepth==0) {\n\t\t\terror(ERROR, \"#endif with no #if\");\n\t\t\treturn;\n\t\t}\n\t\t--ifdepth;\n\t\t--cursource->ifdepth;\n\t\tif (trp->lp - trp->bp != 3)\n\t\t\terror(WARNING, \"Syntax error in #endif\");\n\t\tbreak;\n\n\tcase KERROR:\n\t\ttrp->tp = tp+1;\n\t\terror(WARNING, \"#error directive: %r\", trp);\n\t\tbreak;\n\n\tcase KLINE:\n\t\ttrp->tp = tp+1;\n\t\texpandrow(trp, \"<line>\");\n\t\ttp = trp->bp+2;\n\tkline:\n\t\tif (tp+1>=trp->lp || tp->type!=NUMBER || tp+3<trp->lp\n\t\t || (tp+3==trp->lp && ((tp+1)->type!=STRING)||*(tp+1)->t=='L')){\n\t\t\terror(ERROR, \"Syntax error in #line\");\n\t\t\treturn;\n\t\t}\n\t\tcursource->line = atol((char*)tp->t)-1;\n\t\tif (cursource->line<0 || cursource->line>=32768)\n\t\t\terror(WARNING, \"#line specifies number out of range\");\n\t\ttp = tp+1;\n\t\tif (tp+1<trp->lp)\n\t\t\tcursource->filename=(char*)newstring(tp->t+1,tp->len-2,0);\n\t\treturn;\n\n\tcase KDEFINED:\n\t\terror(ERROR, \"Bad syntax for control line\");\n\t\tbreak;\n\n\tcase KINCLUDE:\n\t\tdoinclude(trp);\n\t\ttrp->lp = trp->bp;\n\t\treturn;\n\n\tcase KEVAL:\n\t\teval(trp, np->val);\n\t\tbreak;\n\n\tdefault:\n\t\terror(ERROR, \"Preprocessor control `%t' not yet implemented\", tp);\n\t\tbreak;\n\t}\n\tsetempty(trp);\n\treturn;\n}\n\nvoid *\ndomalloc(int size)\n{\n\tvoid *p = malloc(size);\n\n\tif (p==NULL)\n\t\terror(FATAL, \"Out of memory from malloc\");\n\treturn p;\n}\n\nvoid\ndofree(void *p)\n{\n\tfree(p);\n}\n\nvoid\nerror(enum errtype type, char *string, ...)\n{\n\tva_list ap;\n\tchar *cp, *ep;\n\tToken *tp;\n\tTokenrow *trp;\n\tSource *s;\n\tint i;\n\n\tfprintf(stderr, \"cpp: \");\n\tfor (s=cursource; s; s=s->next)\n\t\tif (*s->filename)\n\t\t\tfprintf(stderr, \"%s:%d \", s->filename, s->line);\n\tva_start(ap, string);\n\tfor (ep=string; *ep; ep++) {\n\t\tif (*ep=='%') {\n\t\t\tswitch (*++ep) {\n\n\t\t\tcase 's':\n\t\t\t\tcp = va_arg(ap, char *);\n\t\t\t\tfprintf(stderr, \"%s\", cp);\n\t\t\t\tbreak;\n\t\t\tcase 'd':\n\t\t\t\ti = va_arg(ap, int);\n\t\t\t\tfprintf(stderr, \"%d\", i);\n\t\t\t\tbreak;\n\t\t\tcase 't':\n\t\t\t\ttp = va_arg(ap, Token *);\n\t\t\t\tfprintf(stderr, \"%.*s\", tp->len, tp->t);\n\t\t\t\tbreak;\n\n\t\t\tcase 'r':\n\t\t\t\ttrp = va_arg(ap, Tokenrow *);\n\t\t\t\tfor (tp=trp->tp; tp<trp->lp&&tp->type!=NL; tp++) {\n\t\t\t\t\tif (tp>trp->tp && tp->wslen)\n\t\t\t\t\t\tfputc(' ', stderr);\n\t\t\t\t\tfprintf(stderr, \"%.*s\", tp->len, tp->t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tfputc(*ep, stderr);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else\n\t\t\tfputc(*ep, stderr);\n\t}\n\tva_end(ap);\n\tfputc('\\n', stderr);\n\tif (type==FATAL)\n\t\texit(1);\n\tif (type!=WARNING)\n\t\tnerrs = 1;\n\tfflush(stderr);\n}\n"
  },
  {
    "path": "lcc/cpp/cpp.h",
    "content": "#define\tINS\t32768\t\t/* input buffer */\n#define\tOBS\t4096\t\t/* outbut buffer */\n#define\tNARG\t32\t\t/* Max number arguments to a macro */\n#define\tNINCLUDE 32\t\t/* Max number of include directories (-I) */\n#define\tNIF\t32\t\t/* depth of nesting of #if */\n#ifndef EOF\n#define\tEOF\t(-1)\n#endif\n#ifndef NULL\n#define NULL\t0\n#endif\n\n#ifndef __alpha\ntypedef unsigned char uchar;\n#endif\n\nenum toktype { END, UNCLASS, NAME, NUMBER, STRING, CCON, NL, WS, DSHARP,\n\t\tEQ, NEQ, LEQ, GEQ, LSH, RSH, LAND, LOR, PPLUS, MMINUS,\n\t\tARROW, SBRA, SKET, LP, RP, DOT, AND, STAR, PLUS, MINUS,\n\t\tTILDE, NOT, SLASH, PCT, LT, GT, CIRC, OR, QUEST,\n\t\tCOLON, ASGN, COMMA, SHARP, SEMIC, CBRA, CKET,\n\t\tASPLUS, ASMINUS, ASSTAR, ASSLASH, ASPCT, ASCIRC, ASLSH,\n\t\tASRSH, ASOR, ASAND, ELLIPS,\n\t\tDSHARP1, NAME1, DEFINED, UMINUS };\n\nenum kwtype { KIF, KIFDEF, KIFNDEF, KELIF, KELSE, KENDIF, KINCLUDE, KDEFINE,\n\t\tKUNDEF, KLINE, KERROR, KPRAGMA, KDEFINED,\n\t\tKLINENO, KFILE, KDATE, KTIME, KSTDC, KEVAL };\n\n#define\tISDEFINED\t01\t/* has #defined value */\n#define\tISKW\t\t02\t/* is PP keyword */\n#define\tISUNCHANGE\t04\t/* can't be #defined in PP */\n#define\tISMAC\t\t010\t/* builtin macro, e.g. __LINE__ */\n\n#define\tEOB\t0xFE\t\t/* sentinel for end of input buffer */\n#define\tEOFC\t0xFD\t\t/* sentinel for end of input file */\n#define\tXPWS\t1\t\t/* token flag: white space to assure token sep. */\n\ntypedef struct token {\n\tunsigned char\ttype;\n\tunsigned char \tflag;\n\tunsigned short\thideset;\n\tunsigned int\twslen;\n\tunsigned int\tlen;\n\tuchar\t*t;\n} Token;\n\ntypedef struct tokenrow {\n\tToken\t*tp;\t\t/* current one to scan */\n\tToken\t*bp;\t\t/* base (allocated value) */\n\tToken\t*lp;\t\t/* last+1 token used */\n\tint\tmax;\t\t/* number allocated */\n} Tokenrow;\n\ntypedef struct source {\n\tchar\t*filename;\t/* name of file of the source */\n\tint\tline;\t\t/* current line number */\n\tint\tlineinc;\t/* adjustment for \\\\n lines */\n\tuchar\t*inb;\t\t/* input buffer */\n\tuchar\t*inp;\t\t/* input pointer */\n\tuchar\t*inl;\t\t/* end of input */\n\tint\tfd;\t\t/* input source */\n\tint\tifdepth;\t/* conditional nesting in include */\n\tstruct\tsource *next;\t/* stack for #include */\n} Source;\n\ntypedef struct nlist {\n\tstruct nlist *next;\n\tuchar\t*name;\n\tint\tlen;\n\tTokenrow *vp;\t\t/* value as macro */\n\tTokenrow *ap;\t\t/* list of argument names, if any */\n\tchar\tval;\t\t/* value as preprocessor name */\n\tchar\tflag;\t\t/* is defined, is pp name */\n} Nlist;\n\ntypedef\tstruct\tincludelist {\n\tchar\tdeleted;\n\tchar\talways;\n\tchar\t*file;\n} Includelist;\n\n#define\tnew(t)\t(t *)domalloc(sizeof(t))\n#define\tquicklook(a,b)\t(namebit[(a)&077] & (1<<((b)&037)))\n#define\tquickset(a,b)\tnamebit[(a)&077] |= (1<<((b)&037))\nextern\tunsigned long namebit[077+1];\n\nenum errtype { WARNING, ERROR, FATAL };\n\nvoid\texpandlex(void);\nvoid\tfixlex(void);\nvoid\tsetup(int, char **);\nint\tgettokens(Tokenrow *, int);\nint\tcomparetokens(Tokenrow *, Tokenrow *);\nSource\t*setsource(char *, int, char *);\nvoid\tunsetsource(void);\nvoid\tputtokens(Tokenrow *);\nvoid\tprocess(Tokenrow *);\nvoid\t*domalloc(int);\nvoid\tdofree(void *);\nvoid\terror(enum errtype, char *, ...);\nvoid\tflushout(void);\nint\tfillbuf(Source *);\nint\ttrigraph(Source *);\nint\tfoldline(Source *);\nNlist\t*lookup(Token *, int);\nvoid\tcontrol(Tokenrow *);\nvoid\tdodefine(Tokenrow *);\nvoid\tdoadefine(Tokenrow *, int);\nvoid\tdoinclude(Tokenrow *);\nvoid\tdoif(Tokenrow *, enum kwtype);\nvoid\texpand(Tokenrow *, Nlist *);\nvoid\tbuiltin(Tokenrow *, int);\nint\tgatherargs(Tokenrow *, Tokenrow **, int *);\nvoid\tsubstargs(Nlist *, Tokenrow *, Tokenrow **);\nvoid\texpandrow(Tokenrow *, char *);\nvoid\tmaketokenrow(int, Tokenrow *);\nTokenrow *copytokenrow(Tokenrow *, Tokenrow *);\nToken\t*growtokenrow(Tokenrow *);\nTokenrow *normtokenrow(Tokenrow *);\nvoid\tadjustrow(Tokenrow *, int);\nvoid\tmovetokenrow(Tokenrow *, Tokenrow *);\nvoid\tinsertrow(Tokenrow *, int, Tokenrow *);\nvoid\tpeektokens(Tokenrow *, char *);\nvoid\tdoconcat(Tokenrow *);\nTokenrow *stringify(Tokenrow *);\nint\tlookuparg(Nlist *, Token *);\nlong\teval(Tokenrow *, int);\nvoid\tgenline(void);\nvoid\tsetempty(Tokenrow *);\nvoid\tmakespace(Tokenrow *);\nchar\t*outnum(char *, int);\nint\tdigit(int);\nuchar\t*newstring(uchar *, int, int);\nint\tcheckhideset(int, Nlist *);\nvoid\tprhideset(int);\nint\tnewhideset(int, Nlist *);\nint\tunionhideset(int, int);\nvoid\tiniths(void);\nvoid\tsetobjname(char *);\n#define\trowlen(tokrow)\t((tokrow)->lp - (tokrow)->bp)\n\nextern\tchar *outp;\nextern\tToken\tnltoken;\nextern\tSource *cursource;\nextern\tchar *curtime;\nextern\tint incdepth;\nextern\tint ifdepth;\nextern\tint ifsatisfied[NIF];\nextern\tint Mflag;\nextern\tint skipping;\nextern\tint verbose;\nextern\tint Cplusplus;\nextern\tNlist *kwdefined;\nextern\tIncludelist includelist[NINCLUDE];\nextern\tchar wd[];\n\nextern int creat(char *, int);\nextern int open(char *, int);\nextern int close(int);\nextern int dup2(int, int);\nextern int write(int, char *, size_t);\nextern int read(int, char *, size_t);\n"
  },
  {
    "path": "lcc/cpp/eval.c",
    "content": "#include <stdlib.h>\n#include <string.h>\n#include \"cpp.h\"\n\n#define\tNSTAK\t32\n#define\tSGN\t0\n#define\tUNS\t1\n#define\tUND\t2\n\n#define\tUNSMARK\t0x1000\n\nstruct value {\n\tlong\tval;\n\tint\ttype;\n};\n\n/* conversion types */\n#define\tRELAT\t1\n#define\tARITH\t2\n#define\tLOGIC\t3\n#define\tSPCL\t4\n#define\tSHIFT\t5\n#define\tUNARY\t6\n\n/* operator priority, arity, and conversion type, indexed by tokentype */\nstruct pri {\n\tchar\tpri;\n\tchar\tarity;\n\tchar\tctype;\n} priority[] = {\n\t{ 0, 0, 0 },\t\t/* END */\n\t{ 0, 0, 0 },\t\t/* UNCLASS */\n\t{ 0, 0, 0 },\t\t/* NAME */\n\t{ 0, 0, 0 },\t\t/* NUMBER */\n\t{ 0, 0, 0 },\t\t/* STRING */\n\t{ 0, 0, 0 },\t\t/* CCON */\n\t{ 0, 0, 0 },\t\t/* NL */\n\t{ 0, 0, 0 },\t\t/* WS */\n\t{ 0, 0, 0 },\t\t/* DSHARP */\n\t{ 11, 2, RELAT },\t/* EQ */\n\t{ 11, 2, RELAT },\t/* NEQ */\n\t{ 12, 2, RELAT },\t/* LEQ */\n\t{ 12, 2, RELAT },\t/* GEQ */\n\t{ 13, 2, SHIFT },\t/* LSH */\n\t{ 13, 2, SHIFT },\t/* RSH */\n\t{ 7, 2, LOGIC },\t/* LAND */\n\t{ 6, 2, LOGIC },\t/* LOR */\n\t{ 0, 0, 0 },\t\t/* PPLUS */\n\t{ 0, 0, 0 },\t\t/* MMINUS */\n\t{ 0, 0, 0 },\t\t/* ARROW */\n\t{ 0, 0, 0 },\t\t/* SBRA */\n\t{ 0, 0, 0 },\t\t/* SKET */\n\t{ 3, 0, 0 },\t\t/* LP */\n\t{ 3, 0, 0 },\t\t/* RP */\n\t{ 0, 0, 0 },\t\t/* DOT */\n\t{ 10, 2, ARITH },\t/* AND */\n\t{ 15, 2, ARITH },\t/* STAR */\n\t{ 14, 2, ARITH },\t/* PLUS */\n\t{ 14, 2, ARITH },\t/* MINUS */\n\t{ 16, 1, UNARY },\t/* TILDE */\n\t{ 16, 1, UNARY },\t/* NOT */\n\t{ 15, 2, ARITH },\t/* SLASH */\n\t{ 15, 2, ARITH },\t/* PCT */\n\t{ 12, 2, RELAT },\t/* LT */\n\t{ 12, 2, RELAT },\t/* GT */\n\t{ 9, 2, ARITH },\t/* CIRC */\n\t{ 8, 2, ARITH },\t/* OR */\n\t{ 5, 2, SPCL },\t\t/* QUEST */\n\t{ 5, 2, SPCL },\t\t/* COLON */\n\t{ 0, 0, 0 },\t\t/* ASGN */\n\t{ 4, 2, 0 },\t\t/* COMMA */\n\t{ 0, 0, 0 },\t\t/* SHARP */\n\t{ 0, 0, 0 },\t\t/* SEMIC */\n\t{ 0, 0, 0 },\t\t/* CBRA */\n\t{ 0, 0, 0 },\t\t/* CKET */\n\t{ 0, 0, 0 },\t\t/* ASPLUS */\n \t{ 0, 0, 0 },\t\t/* ASMINUS */\n \t{ 0, 0, 0 },\t\t/* ASSTAR */\n \t{ 0, 0, 0 },\t\t/* ASSLASH */\n \t{ 0, 0, 0 },\t\t/* ASPCT */\n \t{ 0, 0, 0 },\t\t/* ASCIRC */\n \t{ 0, 0, 0 },\t\t/* ASLSH */\n\t{ 0, 0, 0 },\t\t/* ASRSH */\n \t{ 0, 0, 0 },\t\t/* ASOR */\n \t{ 0, 0, 0 },\t\t/* ASAND */\n\t{ 0, 0, 0 },\t\t/* ELLIPS */\n\t{ 0, 0, 0 },\t\t/* DSHARP1 */\n\t{ 0, 0, 0 },\t\t/* NAME1 */\n\t{ 16, 1, UNARY },\t/* DEFINED */\n\t{ 16, 0, UNARY },\t/* UMINUS */\n};\n\nint\tevalop(struct pri);\nstruct\tvalue tokval(Token *);\nstruct value vals[NSTAK], *vp;\nenum toktype ops[NSTAK], *op;\n\n/*\n * Evaluate an #if #elif #ifdef #ifndef line.  trp->tp points to the keyword.\n */\nlong\neval(Tokenrow *trp, int kw)\n{\n\tToken *tp;\n\tNlist *np;\n\tint ntok, rand;\n\n\ttrp->tp++;\n\tif (kw==KIFDEF || kw==KIFNDEF) {\n\t\tif (trp->lp - trp->bp != 4 || trp->tp->type!=NAME) {\n\t\t\terror(ERROR, \"Syntax error in #ifdef/#ifndef\");\n\t\t\treturn 0;\n\t\t}\n\t\tnp = lookup(trp->tp, 0);\n\t\treturn (kw==KIFDEF) == (np && np->flag&(ISDEFINED|ISMAC));\n\t}\n\tntok = trp->tp - trp->bp;\n\tkwdefined->val = KDEFINED;\t/* activate special meaning of defined */\n\texpandrow(trp, \"<if>\");\n\tkwdefined->val = NAME;\n\tvp = vals;\n\top = ops;\n\t*op++ = END;\n\tfor (rand=0, tp = trp->bp+ntok; tp < trp->lp; tp++) {\n\t\tswitch(tp->type) {\n\t\tcase WS:\n\t\tcase NL:\n\t\t\tcontinue;\n\n\t\t/* nilary */\n\t\tcase NAME:\n\t\tcase NAME1:\n\t\tcase NUMBER:\n\t\tcase CCON:\n\t\tcase STRING:\n\t\t\tif (rand)\n\t\t\t\tgoto syntax;\n\t\t\t*vp++ = tokval(tp);\n\t\t\trand = 1;\n\t\t\tcontinue;\n\n\t\t/* unary */\n\t\tcase DEFINED:\n\t\tcase TILDE:\n\t\tcase NOT:\n\t\t\tif (rand)\n\t\t\t\tgoto syntax;\n\t\t\t*op++ = tp->type;\n\t\t\tcontinue;\n\n\t\t/* unary-binary */\n\t\tcase PLUS: case MINUS: case STAR: case AND:\n\t\t\tif (rand==0) {\n\t\t\t\tif (tp->type==MINUS)\n\t\t\t\t\t*op++ = UMINUS;\n\t\t\t\tif (tp->type==STAR || tp->type==AND) {\n\t\t\t\t\terror(ERROR, \"Illegal operator * or & in #if/#elsif\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t/* flow through */\n\n\t\t/* plain binary */\n\t\tcase EQ: case NEQ: case LEQ: case GEQ: case LSH: case RSH:\n\t\tcase LAND: case LOR: case SLASH: case PCT:\n\t\tcase LT: case GT: case CIRC: case OR: case QUEST:\n\t\tcase COLON: case COMMA:\n\t\t\tif (rand==0)\n\t\t\t\tgoto syntax;\n\t\t\tif (evalop(priority[tp->type])!=0)\n\t\t\t\treturn 0;\n\t\t\t*op++ = tp->type;\n\t\t\trand = 0;\n\t\t\tcontinue;\n\n\t\tcase LP:\n\t\t\tif (rand)\n\t\t\t\tgoto syntax;\n\t\t\t*op++ = LP;\n\t\t\tcontinue;\n\n\t\tcase RP:\n\t\t\tif (!rand)\n\t\t\t\tgoto syntax;\n\t\t\tif (evalop(priority[RP])!=0)\n\t\t\t\treturn 0;\n\t\t\tif (op<=ops || op[-1]!=LP) {\n\t\t\t\tgoto syntax;\n\t\t\t}\n\t\t\top--;\n\t\t\tcontinue;\n\n\t\tdefault:\n\t\t\terror(ERROR,\"Bad operator (%t) in #if/#elsif\", tp);\n\t\t\treturn 0;\n\t\t}\n\t}\n\tif (rand==0)\n\t\tgoto syntax;\n\tif (evalop(priority[END])!=0)\n\t\treturn 0;\n\tif (op!=&ops[1] || vp!=&vals[1]) {\n\t\terror(ERROR, \"Botch in #if/#elsif\");\n\t\treturn 0;\n\t}\n\tif (vals[0].type==UND)\n\t\terror(ERROR, \"Undefined expression value\");\n\treturn vals[0].val;\nsyntax:\n\terror(ERROR, \"Syntax error in #if/#elsif\");\n\treturn 0;\n}\n\nint\nevalop(struct pri pri)\n{\n\tstruct value v1, v2;\n\tlong rv1, rv2;\n\tint rtype, oper;\n\n\trv2=0;\n\trtype=0;\n\twhile (pri.pri < priority[op[-1]].pri) {\n\t\toper = *--op;\n\t\tif (priority[oper].arity==2) {\n\t\t\tv2 = *--vp;\n\t\t\trv2 = v2.val;\n\t\t}\n\t\tv1 = *--vp;\n\t\trv1 = v1.val;\n/*lint -e574 -e644 */\n\t\tswitch (priority[oper].ctype) {\n\t\tcase 0:\n\t\tdefault:\n\t\t\terror(WARNING, \"Syntax error in #if/#endif\");\n\t\t\treturn 1;\n\t\tcase ARITH:\n\t\tcase RELAT:\n\t\t\tif (v1.type==UNS || v2.type==UNS)\n\t\t\t\trtype = UNS;\n\t\t\telse\n\t\t\t\trtype = SGN;\n\t\t\tif (v1.type==UND || v2.type==UND)\n\t\t\t\trtype = UND;\n\t\t\tif (priority[oper].ctype==RELAT && rtype==UNS) {\n\t\t\t\toper |= UNSMARK;\n\t\t\t\trtype = SGN;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase SHIFT:\n\t\t\tif (v1.type==UND || v2.type==UND)\n\t\t\t\trtype = UND;\n\t\t\telse\n\t\t\t\trtype = v1.type;\n\t\t\tif (rtype==UNS)\n\t\t\t\toper |= UNSMARK;\n\t\t\tbreak;\n\t\tcase UNARY:\n\t\t\trtype = v1.type;\n\t\t\tbreak;\n\t\tcase LOGIC:\n\t\tcase SPCL:\n\t\t\tbreak;\n\t\t}\n\t\tswitch (oper) {\n\t\tcase EQ: case EQ|UNSMARK:\n\t\t\trv1 = rv1==rv2; break;\n\t\tcase NEQ: case NEQ|UNSMARK:\n\t\t\trv1 = rv1!=rv2; break;\n\t\tcase LEQ:\n\t\t\trv1 = rv1<=rv2; break;\n\t\tcase GEQ:\n\t\t\trv1 = rv1>=rv2; break;\n\t\tcase LT:\n\t\t\trv1 = rv1<rv2; break;\n\t\tcase GT:\n\t\t\trv1 = rv1>rv2; break;\n\t\tcase LEQ|UNSMARK:\n\t\t\trv1 = (unsigned long)rv1<=rv2; break;\n\t\tcase GEQ|UNSMARK:\n\t\t\trv1 = (unsigned long)rv1>=rv2; break;\n\t\tcase LT|UNSMARK:\n\t\t\trv1 = (unsigned long)rv1<rv2; break;\n\t\tcase GT|UNSMARK:\n\t\t\trv1 = (unsigned long)rv1>rv2; break;\n\t\tcase LSH:\n\t\t\trv1 <<= rv2; break;\n\t\tcase LSH|UNSMARK:\n\t\t\trv1 = (unsigned long)rv1<<rv2; break;\n\t\tcase RSH:\n\t\t\trv1 >>= rv2; break;\n\t\tcase RSH|UNSMARK:\n\t\t\trv1 = (unsigned long)rv1>>rv2; break;\n\t\tcase LAND:\n\t\t\trtype = UND;\n\t\t\tif (v1.type==UND)\n\t\t\t\tbreak;\n\t\t\tif (rv1!=0) {\n\t\t\t\tif (v2.type==UND)\n\t\t\t\t\tbreak;\n\t\t\t\trv1 = rv2!=0;\n\t\t\t} else\n\t\t\t\trv1 = 0;\n\t\t\trtype = SGN;\n\t\t\tbreak;\n\t\tcase LOR:\n\t\t\trtype = UND;\n\t\t\tif (v1.type==UND)\n\t\t\t\tbreak;\n\t\t\tif (rv1==0) {\n\t\t\t\tif (v2.type==UND)\n\t\t\t\t\tbreak;\n\t\t\t\trv1 = rv2!=0;\n\t\t\t} else\n\t\t\t\trv1 = 1;\n\t\t\trtype = SGN;\n\t\t\tbreak;\n\t\tcase AND:\n\t\t\trv1 &= rv2; break;\n\t\tcase STAR:\n\t\t\trv1 *= rv2; break;\n\t\tcase PLUS:\n\t\t\trv1 += rv2; break;\n\t\tcase MINUS:\n\t\t\trv1 -= rv2; break;\n\t\tcase UMINUS:\n\t\t\tif (v1.type==UND)\n\t\t\t\trtype = UND;\n\t\t\trv1 = -rv1; break;\n\t\tcase OR:\n\t\t\trv1 |= rv2; break;\n\t\tcase CIRC:\n\t\t\trv1 ^= rv2; break;\n\t\tcase TILDE:\n\t\t\trv1 = ~rv1; break;\n\t\tcase NOT:\n\t\t\trv1 = !rv1; if (rtype!=UND) rtype = SGN; break;\n\t\tcase SLASH:\n\t\t\tif (rv2==0) {\n\t\t\t\trtype = UND;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (rtype==UNS)\n\t\t\t\trv1 /= (unsigned long)rv2;\n\t\t\telse\n\t\t\t\trv1 /= rv2;\n\t\t\tbreak;\n\t\tcase PCT:\n\t\t\tif (rv2==0) {\n\t\t\t\trtype = UND;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (rtype==UNS)\n\t\t\t\trv1 %= (unsigned long)rv2;\n\t\t\telse\n\t\t\t\trv1 %= rv2;\n\t\t\tbreak;\n\t\tcase COLON:\n\t\t\tif (op[-1] != QUEST)\n\t\t\t\terror(ERROR, \"Bad ?: in #if/endif\");\n\t\t\telse {\n\t\t\t\top--;\n\t\t\t\tif ((--vp)->val==0)\n\t\t\t\t\tv1 = v2;\n\t\t\t\trtype = v1.type;\n\t\t\t\trv1 = v1.val;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase DEFINED:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\terror(ERROR, \"Eval botch (unknown operator)\");\n\t\t\treturn 1;\n\t\t}\n/*lint +e574 +e644 */\n\t\tv1.val = rv1;\n\t\tv1.type = rtype;\n\t\t*vp++ = v1;\n\t}\n\treturn 0;\n}\n\nstruct value\ntokval(Token *tp)\n{\n\tstruct value v;\n\tNlist *np;\n\tint i, base, c;\n\tunsigned long n;\n\tuchar *p;\n\n\tv.type = SGN;\n\tv.val = 0;\n\tswitch (tp->type) {\n\n\tcase NAME:\n\t\tv.val = 0;\n\t\tbreak;\n\n\tcase NAME1:\n\t\tif ((np = lookup(tp, 0)) != NULL && np->flag&(ISDEFINED|ISMAC))\n\t\t\tv.val = 1;\n\t\tbreak;\n\n\tcase NUMBER:\n\t\tn = 0;\n\t\tbase = 10;\n\t\tp = tp->t;\n\t\tc = p[tp->len];\n\t\tp[tp->len] = '\\0';\n\t\tif (*p=='0') {\n\t\t\tbase = 8;\n\t\t\tif (p[1]=='x' || p[1]=='X') {\n\t\t\t\tbase = 16;\n\t\t\t\tp++;\n\t\t\t}\n\t\t\tp++;\n\t\t}\n\t\tfor (;; p++) {\n\t\t\tif ((i = digit(*p)) < 0)\n\t\t\t\tbreak;\n\t\t\tif (i>=base)\n\t\t\t\terror(WARNING,\n\t\t\t\t  \"Bad digit in number %t\", tp);\n\t\t\tn *= base;\n\t\t\tn += i;\n\t\t}\n\t\tif (n>=0x80000000 && base!=10)\n\t\t\tv.type = UNS;\n\t\tfor (; *p; p++) {\n\t\t\tif (*p=='u' || *p=='U')\n\t\t\t\tv.type = UNS;\n\t\t\telse if (*p=='l' || *p=='L')\n\t\t\t\t;\n\t\t\telse {\n\t\t\t\terror(ERROR,\n\t\t\t\t  \"Bad number %t in #if/#elsif\", tp);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tv.val = n;\n\t\ttp->t[tp->len] = c;\n\t\tbreak;\n\n\tcase CCON:\n\t\tn = 0;\n\t\tp = tp->t;\n\t\tif (*p=='L') {\n\t\t\tp += 1;\n\t\t\terror(WARNING, \"Wide char constant value undefined\");\n\t\t}\n\t\tp += 1;\n\t\tif (*p=='\\\\') {\n\t\t\tp += 1;\n\t\t\tif ((i = digit(*p))>=0 && i<=7) {\n\t\t\t\tn = i;\n\t\t\t\tp += 1;\n\t\t\t\tif ((i = digit(*p))>=0 && i<=7) {\n\t\t\t\t\tp += 1;\n\t\t\t\t\tn <<= 3;\n\t\t\t\t\tn += i;\n\t\t\t\t\tif ((i = digit(*p))>=0 && i<=7) {\n\t\t\t\t\t\tp += 1;\n\t\t\t\t\t\tn <<= 3;\n\t\t\t\t\t\tn += i;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (*p=='x') {\n\t\t\t\tp += 1;\n\t\t\t\twhile ((i = digit(*p))>=0 && i<=15) {\n\t\t\t\t\tp += 1;\n\t\t\t\t\tn <<= 4;\n\t\t\t\t\tn += i;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tstatic char cvcon[]\n\t\t\t\t  = \"b\\bf\\fn\\nr\\rt\\tv\\v''\\\"\\\"??\\\\\\\\\";\n\t\t\t\tfor (i=0; i<sizeof(cvcon); i+=2) {\n\t\t\t\t\tif (*p == cvcon[i]) {\n\t\t\t\t\t\tn = cvcon[i+1];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tp += 1;\n\t\t\t\tif (i>=sizeof(cvcon))\n\t\t\t\t\terror(WARNING,\n\t\t\t\t\t \"Undefined escape in character constant\");\n\t\t\t}\n\t\t} else if (*p=='\\'')\n\t\t\terror(ERROR, \"Empty character constant\");\n\t\telse\n\t\t\tn = *p++;\n\t\tif (*p!='\\'')\n\t\t\terror(WARNING, \"Multibyte character constant undefined\");\n\t\telse if (n>127)\n\t\t\terror(WARNING, \"Character constant taken as not signed\");\n\t\tv.val = n;\n\t\tbreak;\n\n\tcase STRING:\n\t\terror(ERROR, \"String in #if/#elsif\");\n\t\tbreak;\n\t}\n\treturn v;\n}\n\nint\ndigit(int i)\n{\n\tif ('0'<=i && i<='9')\n\t\ti -= '0';\n\telse if ('a'<=i && i<='f')\n\t\ti -= 'a'-10;\n\telse if ('A'<=i && i<='F')\n\t\ti -= 'A'-10;\n\telse\n\t\ti = -1;\n\treturn i;\n}\n"
  },
  {
    "path": "lcc/cpp/getopt.c",
    "content": "#include\t<stdio.h>\n#define EPR                 fprintf(stderr,\n#define ERR(str, chr)       if(opterr){EPR \"%s%c\\n\", str, chr);}\nint     opterr = 1;\nint     optind = 1;\nint\toptopt;\nchar    *optarg;\nchar    *strchr();\n\nint\ngetopt (int argc, char *const argv[], const char *opts)\n{\n\tstatic int sp = 1;\n\tint c;\n\tchar *cp;\n\n\tif (sp == 1)\n\t\tif (optind >= argc ||\n\t\t   argv[optind][0] != '-' || argv[optind][1] == '\\0')\n\t\t\treturn -1;\n\t\telse if (strcmp(argv[optind], \"--\") == 0) {\n\t\t\toptind++;\n\t\t\treturn -1;\n\t\t}\n\toptopt = c = argv[optind][sp];\n\tif (c == ':' || (cp=strchr(opts, c)) == 0) {\n\t\tERR (\": illegal option -- \", c);\n\t\tif (argv[optind][++sp] == '\\0') {\n\t\t\toptind++;\n\t\t\tsp = 1;\n\t\t}\n\t\treturn '?';\n\t}\n\tif (*++cp == ':') {\n\t\tif (argv[optind][sp+1] != '\\0')\n\t\t\toptarg = &argv[optind++][sp+1];\n\t\telse if (++optind >= argc) {\n\t\t\tERR (\": option requires an argument -- \", c);\n\t\t\tsp = 1;\n\t\t\treturn '?';\n\t\t} else\n\t\t\toptarg = argv[optind++];\n\t\tsp = 1;\n\t} else {\n\t\tif (argv[optind][++sp] == '\\0') {\n\t\t\tsp = 1;\n\t\t\toptind++;\n\t\t}\n\t\toptarg = 0;\n\t}\n\treturn c;\n}\n"
  },
  {
    "path": "lcc/cpp/hideset.c",
    "content": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include \"cpp.h\"\n\n/*\n * A hideset is a null-terminated array of Nlist pointers.\n * They are referred to by indices in the hidesets array.\n * Hideset 0 is empty.\n */\n\n#define\tHSSIZ\t32\ntypedef\tNlist\t**Hideset;\nHideset\t*hidesets;\nint\tnhidesets = 0;\nint\tmaxhidesets = 3;\nint\tinserths(Hideset, Hideset, Nlist *);\n\n/*\n * Test for membership in a hideset\n */\nint\ncheckhideset(int hs, Nlist *np)\n{\n\tHideset hsp;\n\n\tif (hs>=nhidesets)\n\t\tabort();\n\tfor (hsp = hidesets[hs]; *hsp; hsp++) {\n\t\tif (*hsp == np)\n\t\t\treturn 1;\n\t}\n\treturn 0;\n}\n\n/*\n * Return the (possibly new) hideset obtained by adding np to hs.\n */\nint\nnewhideset(int hs, Nlist *np)\n{\n\tint i, len;\n\tNlist *nhs[HSSIZ+3];\n\tHideset hs1, hs2;\n\n\tlen = inserths(nhs, hidesets[hs], np);\n\tfor (i=0; i<nhidesets; i++) {\n\t\tfor (hs1=nhs, hs2=hidesets[i]; *hs1==*hs2; hs1++, hs2++)\n\t\t\tif (*hs1 == NULL)\n\t\t\t\treturn i;\n\t}\n\tif (len>=HSSIZ)\n\t\treturn hs;\n\tif (nhidesets >= maxhidesets) {\n\t\tmaxhidesets = 3*maxhidesets/2+1;\n\t\thidesets = (Hideset *)realloc(hidesets, (sizeof (Hideset *))*maxhidesets);\n\t\tif (hidesets == NULL)\n\t\t\terror(FATAL, \"Out of memory from realloc\");\n\t}\n\ths1 = (Hideset)domalloc(len*sizeof(Hideset));\n\tmemmove(hs1, nhs, len*sizeof(Hideset));\n\thidesets[nhidesets] = hs1;\n\treturn nhidesets++;\n}\n\nint\ninserths(Hideset dhs, Hideset shs, Nlist *np)\n{\n\tHideset odhs = dhs;\n\n\twhile (*shs && *shs < np)\n\t\t*dhs++ = *shs++;\n\tif (*shs != np)\n\t\t*dhs++ = np;\n\tdo {\n\t\t*dhs++ = *shs;\n\t} while (*shs++);\n\treturn dhs - odhs;\n}\n\n/*\n * Hideset union\n */\nint\nunionhideset(int hs1, int hs2)\n{\n\tHideset hp;\n\n\tfor (hp = hidesets[hs2]; *hp; hp++)\n\t\ths1 = newhideset(hs1, *hp);\n\treturn hs1;\n}\n\nvoid\niniths(void)\n{\n\thidesets = (Hideset *)domalloc(maxhidesets*sizeof(Hideset *));\n\thidesets[0] = (Hideset)domalloc(sizeof(Hideset));\n\t*hidesets[0] = NULL;\n\tnhidesets++;\n}\n\nvoid\nprhideset(int hs)\n{\n\tHideset np;\n\n\tfor (np = hidesets[hs]; *np; np++) {\n\t\tfprintf(stderr, (char*)(*np)->name, (*np)->len);\n\t\tfprintf(stderr, \" \");\n\t}\n}\n"
  },
  {
    "path": "lcc/cpp/include.c",
    "content": "#include <stdlib.h>\n#include <string.h>\n#include \"cpp.h\"\n\nIncludelist\tincludelist[NINCLUDE];\n\nextern char\t*objname;\n\nvoid\ndoinclude(Tokenrow *trp)\n{\n\tchar fname[256], iname[256];\n\tIncludelist *ip;\n\tint angled, len, fd, i;\n\n\ttrp->tp += 1;\n\tif (trp->tp>=trp->lp)\n\t\tgoto syntax;\n\tif (trp->tp->type!=STRING && trp->tp->type!=LT) {\n\t\tlen = trp->tp - trp->bp;\n\t\texpandrow(trp, \"<include>\");\n\t\ttrp->tp = trp->bp+len;\n\t}\n\tif (trp->tp->type==STRING) {\n\t\tlen = trp->tp->len-2;\n\t\tif (len > sizeof(fname) - 1)\n\t\t\tlen = sizeof(fname) - 1;\n\t\tstrncpy(fname, (char*)trp->tp->t+1, len);\n\t\tangled = 0;\n\t} else if (trp->tp->type==LT) {\n\t\tlen = 0;\n\t\ttrp->tp++;\n\t\twhile (trp->tp->type!=GT) {\n\t\t\tif (trp->tp>trp->lp || len+trp->tp->len+2 >= sizeof(fname))\n\t\t\t\tgoto syntax;\n\t\t\tstrncpy(fname+len, (char*)trp->tp->t, trp->tp->len);\n\t\t\tlen += trp->tp->len;\n\t\t\ttrp->tp++;\n\t\t}\n\t\tangled = 1;\n\t} else\n\t\tgoto syntax;\n\ttrp->tp += 2;\n\tif (trp->tp < trp->lp || len==0)\n\t\tgoto syntax;\n\tfname[len] = '\\0';\n\tif (fname[0]=='/') {\n\t\tfd = open(fname, 0);\n\t\tstrcpy(iname, fname);\n\t} else for (fd = -1,i=NINCLUDE-1; i>=0; i--) {\n\t\tip = &includelist[i];\n\t\tif (ip->file==NULL || ip->deleted || (angled && ip->always==0))\n\t\t\tcontinue;\n\t\tif (strlen(fname)+strlen(ip->file)+2 > sizeof(iname))\n\t\t\tcontinue;\n\t\tstrcpy(iname, ip->file);\n\t\tstrcat(iname, \"/\");\n\t\tstrcat(iname, fname);\n\t\tif ((fd = open(iname, 0)) >= 0)\n\t\t\tbreak;\n\t}\n\tif ( Mflag>1 || !angled&&Mflag==1 ) {\n\t\twrite(1,objname,strlen(objname));\n\t\twrite(1,iname,strlen(iname));\n\t\twrite(1,\"\\n\",1);\n\t}\n\tif (fd >= 0) {\n\t\tif (++incdepth > 10)\n\t\t\terror(FATAL, \"#include too deeply nested\");\n\t\tsetsource((char*)newstring((uchar*)iname, strlen(iname), 0), fd, NULL);\n\t\tgenline();\n\t} else {\n\t\ttrp->tp = trp->bp+2;\n\t\terror(ERROR, \"Could not find include file %r\", trp);\n\t}\n\treturn;\nsyntax:\n\terror(ERROR, \"Syntax error in #include\");\n\treturn;\n}\n\n/*\n * Generate a line directive for cursource\n */\nvoid\ngenline(void)\n{\n\tstatic Token ta = { UNCLASS };\n\tstatic Tokenrow tr = { &ta, &ta, &ta+1, 1 };\n\tuchar *p;\n\n\tta.t = p = (uchar*)outp;\n\tstrcpy((char*)p, \"#line \");\n\tp += sizeof(\"#line \")-1;\n\tp = (uchar*)outnum((char*)p, cursource->line);\n\t*p++ = ' '; *p++ = '\"';\n\tif (cursource->filename[0]!='/' && wd[0]) {\n\t\tstrcpy((char*)p, wd);\n\t\tp += strlen(wd);\n\t\t*p++ = '/';\n\t}\n\tstrcpy((char*)p, cursource->filename);\n\tp += strlen((char*)p);\n\t*p++ = '\"'; *p++ = '\\n';\n\tta.len = (char*)p-outp;\n\toutp = (char*)p;\n\ttr.tp = tr.bp;\n\tputtokens(&tr);\n}\n\nvoid\nsetobjname(char *f)\n{\n\tint n = strlen(f);\n\tobjname = (char*)domalloc(n+5);\n\tstrcpy(objname,f);\n\tif(objname[n-2]=='.'){\n\t\tstrcpy(objname+n-1,\"$O: \");\n\t}else{\n\t\tstrcpy(objname+n,\"$O: \");\n\t}\n}\n"
  },
  {
    "path": "lcc/cpp/lex.c",
    "content": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include \"cpp.h\"\n\n/*\n * lexical FSM encoding\n *   when in state state, and one of the characters\n *   in ch arrives, enter nextstate.\n *   States >= S_SELF are either final, or at least require special action.\n *   In 'fsm' there is a line for each state X charset X nextstate.\n *   List chars that overwrite previous entries later (e.g. C_ALPH\n *   can be overridden by '_' by a later entry; and C_XX is the\n *   the universal set, and should always be first.\n *   States above S_SELF are represented in the big table as negative values.\n *   S_SELF and S_SELFB encode the resulting token type in the upper bits.\n *   These actions differ in that S_SELF doesn't have a lookahead char,\n *   S_SELFB does.\n *\n *   The encoding is blown out into a big table for time-efficiency.\n *   Entries have\n *      nextstate: 6 bits; ?\\ marker: 1 bit; tokentype: 9 bits.\n */\n\n#define\tMAXSTATE 32\n#define\tACT(tok,act)\t((tok<<7)+act)\n#define\tQBSBIT\t0100\n#define\tGETACT(st)\t(st>>7)&0x1ff\n\n/* character classes */\n#define\tC_WS\t1\n#define\tC_ALPH\t2\n#define\tC_NUM\t3\n#define\tC_EOF\t4\n#define\tC_XX\t5\n\nenum state {\n\tSTART=0, NUM1, NUM2, NUM3, ID1, ST1, ST2, ST3, COM1, COM2, COM3, COM4,\n\tCC1, CC2, WS1, PLUS1, MINUS1, STAR1, SLASH1, PCT1, SHARP1,\n\tCIRC1, GT1, GT2, LT1, LT2, OR1, AND1, ASG1, NOT1, DOTS1,\n\tS_SELF=MAXSTATE, S_SELFB, S_EOF, S_NL, S_EOFSTR,\n\tS_STNL, S_COMNL, S_EOFCOM, S_COMMENT, S_EOB, S_WS, S_NAME\n};\n\nint\ttottok;\nint\ttokkind[256];\nstruct\tfsm {\n\tint\tstate;\t\t/* if in this state */\n\tuchar\tch[4];\t\t/* and see one of these characters */\n\tint\tnextstate;\t/* enter this state if +ve */\n};\n\n/*const*/ struct fsm fsm[] = {\n\t/* start state */\n\tSTART,\t{ C_XX },\tACT(UNCLASS,S_SELF),\n\tSTART,\t{ ' ', '\\t', '\\v' },\tWS1,\n\tSTART,\t{ C_NUM },\tNUM1,\n\tSTART,\t{ '.' },\tNUM3,\n\tSTART,\t{ C_ALPH },\tID1,\n\tSTART,\t{ 'L' },\tST1,\n\tSTART,\t{ '\"' },\tST2,\n\tSTART,\t{ '\\'' },\tCC1,\n\tSTART,\t{ '/' },\tCOM1,\n\tSTART,\t{ EOFC },\tS_EOF,\n\tSTART,\t{ '\\n' },\tS_NL,\n\tSTART,\t{ '-' },\tMINUS1,\n\tSTART,\t{ '+' },\tPLUS1,\n\tSTART,\t{ '<' },\tLT1,\n\tSTART,\t{ '>' },\tGT1,\n\tSTART,\t{ '=' },\tASG1,\n\tSTART,\t{ '!' },\tNOT1,\n\tSTART,\t{ '&' },\tAND1,\n\tSTART,\t{ '|' },\tOR1,\n\tSTART,\t{ '#' },\tSHARP1,\n\tSTART,\t{ '%' },\tPCT1,\n\tSTART,\t{ '[' },\tACT(SBRA,S_SELF),\n\tSTART,\t{ ']' },\tACT(SKET,S_SELF),\n\tSTART,\t{ '(' },\tACT(LP,S_SELF),\n\tSTART,\t{ ')' },\tACT(RP,S_SELF),\n\tSTART,\t{ '*' },\tSTAR1,\n\tSTART,\t{ ',' },\tACT(COMMA,S_SELF),\n\tSTART,\t{ '?' },\tACT(QUEST,S_SELF),\n\tSTART,\t{ ':' },\tACT(COLON,S_SELF),\n\tSTART,\t{ ';' },\tACT(SEMIC,S_SELF),\n\tSTART,\t{ '{' },\tACT(CBRA,S_SELF),\n\tSTART,\t{ '}' },\tACT(CKET,S_SELF),\n\tSTART,\t{ '~' },\tACT(TILDE,S_SELF),\n\tSTART,\t{ '^' },\tCIRC1,\n\n\t/* saw a digit */\n\tNUM1,\t{ C_XX },\tACT(NUMBER,S_SELFB),\n\tNUM1,\t{ C_NUM, C_ALPH, '.' },\tNUM1,\n\tNUM1,\t{ 'E', 'e' },\tNUM2,\n\tNUM1,\t{ '_' },\tACT(NUMBER,S_SELFB),\n\n\t/* saw possible start of exponent, digits-e */\n\tNUM2,\t{ C_XX },\tACT(NUMBER,S_SELFB),\n\tNUM2,\t{ '+', '-' },\tNUM1,\n\tNUM2,\t{ C_NUM, C_ALPH },\tNUM1,\n\tNUM2,\t{ '_' },\tACT(NUMBER,S_SELFB),\n\n\t/* saw a '.', which could be a number or an operator */\n\tNUM3,\t{ C_XX },\tACT(DOT,S_SELFB),\n\tNUM3,\t{ '.' },\tDOTS1,\n\tNUM3,\t{ C_NUM },\tNUM1,\n\n\tDOTS1,\t{ C_XX },\tACT(UNCLASS, S_SELFB),\n\tDOTS1,\t{ C_NUM },\tNUM1,\n\tDOTS1,\t{ '.' },\tACT(ELLIPS, S_SELF),\n\n\t/* saw a letter or _ */\n\tID1,\t{ C_XX },\tACT(NAME,S_NAME),\n\tID1,\t{ C_ALPH, C_NUM },\tID1,\n\n\t/* saw L (start of wide string?) */\n\tST1,\t{ C_XX },\tACT(NAME,S_NAME),\n\tST1,\t{ C_ALPH, C_NUM },\tID1,\n\tST1,\t{ '\"' },\tST2,\n\tST1,\t{ '\\'' },\tCC1,\n\n\t/* saw \" beginning string */\n\tST2,\t{ C_XX },\tST2,\n\tST2,\t{ '\"' },\tACT(STRING, S_SELF),\n\tST2,\t{ '\\\\' },\tST3,\n\tST2,\t{ '\\n' },\tS_STNL,\n\tST2,\t{ EOFC },\tS_EOFSTR,\n\n\t/* saw \\ in string */\n\tST3,\t{ C_XX },\tST2,\n\tST3,\t{ '\\n' },\tS_STNL,\n\tST3,\t{ EOFC },\tS_EOFSTR,\n\n\t/* saw ' beginning character const */\n\tCC1,\t{ C_XX },\tCC1,\n\tCC1,\t{ '\\'' },\tACT(CCON, S_SELF),\n\tCC1,\t{ '\\\\' },\tCC2,\n\tCC1,\t{ '\\n' },\tS_STNL,\n\tCC1,\t{ EOFC },\tS_EOFSTR,\n\n\t/* saw \\ in ccon */\n\tCC2,\t{ C_XX },\tCC1,\n\tCC2,\t{ '\\n' },\tS_STNL,\n\tCC2,\t{ EOFC },\tS_EOFSTR,\n\n\t/* saw /, perhaps start of comment */\n\tCOM1,\t{ C_XX },\tACT(SLASH, S_SELFB),\n\tCOM1,\t{ '=' },\tACT(ASSLASH, S_SELF),\n\tCOM1,\t{ '*' },\tCOM2,\n\tCOM1,\t{ '/' },\tCOM4,\n\n\t/* saw / then *, start of comment */\n\tCOM2,\t{ C_XX },\tCOM2,\n\tCOM2,\t{ '\\n' },\tS_COMNL,\n\tCOM2,\t{ '*' },\tCOM3,\n\tCOM2,\t{ EOFC },\tS_EOFCOM,\n\n\t/* saw the * possibly ending a comment */\n\tCOM3,\t{ C_XX },\tCOM2,\n\tCOM3,\t{ '\\n' },\tS_COMNL,\n\tCOM3,\t{ '*' },\tCOM3,\n\tCOM3,\t{ '/' },\tS_COMMENT,\n\n\t/* // comment */\n\tCOM4,\t{ C_XX },\tCOM4,\n\tCOM4,\t{ '\\n' },\tS_NL,\n\tCOM4,\t{ EOFC },\tS_EOFCOM,\n\n\t/* saw white space, eat it up */\n\tWS1,\t{ C_XX },\tS_WS,\n\tWS1,\t{ ' ', '\\t', '\\v' },\tWS1,\n\n\t/* saw -, check --, -=, -> */\n\tMINUS1,\t{ C_XX },\tACT(MINUS, S_SELFB),\n\tMINUS1,\t{ '-' },\tACT(MMINUS, S_SELF),\n\tMINUS1,\t{ '=' },\tACT(ASMINUS,S_SELF),\n\tMINUS1,\t{ '>' },\tACT(ARROW,S_SELF),\n\n\t/* saw +, check ++, += */\n\tPLUS1,\t{ C_XX },\tACT(PLUS, S_SELFB),\n\tPLUS1,\t{ '+' },\tACT(PPLUS, S_SELF),\n\tPLUS1,\t{ '=' },\tACT(ASPLUS, S_SELF),\n\n\t/* saw <, check <<, <<=, <= */\n\tLT1,\t{ C_XX },\tACT(LT, S_SELFB),\n\tLT1,\t{ '<' },\tLT2,\n\tLT1,\t{ '=' },\tACT(LEQ, S_SELF),\n\tLT2,\t{ C_XX },\tACT(LSH, S_SELFB),\n\tLT2,\t{ '=' },\tACT(ASLSH, S_SELF),\n\n\t/* saw >, check >>, >>=, >= */\n\tGT1,\t{ C_XX },\tACT(GT, S_SELFB),\n\tGT1,\t{ '>' },\tGT2,\n\tGT1,\t{ '=' },\tACT(GEQ, S_SELF),\n\tGT2,\t{ C_XX },\tACT(RSH, S_SELFB),\n\tGT2,\t{ '=' },\tACT(ASRSH, S_SELF),\n\n\t/* = */\n\tASG1,\t{ C_XX },\tACT(ASGN, S_SELFB),\n\tASG1,\t{ '=' },\tACT(EQ, S_SELF),\n\n\t/* ! */\n\tNOT1,\t{ C_XX },\tACT(NOT, S_SELFB),\n\tNOT1,\t{ '=' },\tACT(NEQ, S_SELF),\n\n\t/* & */\n\tAND1,\t{ C_XX },\tACT(AND, S_SELFB),\n\tAND1,\t{ '&' },\tACT(LAND, S_SELF),\n\tAND1,\t{ '=' },\tACT(ASAND, S_SELF),\n\n\t/* | */\n\tOR1,\t{ C_XX },\tACT(OR, S_SELFB),\n\tOR1,\t{ '|' },\tACT(LOR, S_SELF),\n\tOR1,\t{ '=' },\tACT(ASOR, S_SELF),\n\n\t/* # */\n\tSHARP1,\t{ C_XX },\tACT(SHARP, S_SELFB),\n\tSHARP1,\t{ '#' },\tACT(DSHARP, S_SELF),\n\n\t/* % */\n\tPCT1,\t{ C_XX },\tACT(PCT, S_SELFB),\n\tPCT1,\t{ '=' },\tACT(ASPCT, S_SELF),\n\n\t/* * */\n\tSTAR1,\t{ C_XX },\tACT(STAR, S_SELFB),\n\tSTAR1,\t{ '=' },\tACT(ASSTAR, S_SELF),\n\n\t/* ^ */\n\tCIRC1,\t{ C_XX },\tACT(CIRC, S_SELFB),\n\tCIRC1,\t{ '=' },\tACT(ASCIRC, S_SELF),\n\n\t-1\n};\n\n/* first index is char, second is state */\n/* increase #states to power of 2 to encourage use of shift */\nshort\tbigfsm[256][MAXSTATE];\n\nvoid\nexpandlex(void)\n{\n\t/*const*/ struct fsm *fp;\n\tint i, j, nstate;\n\n\tfor (fp = fsm; fp->state>=0; fp++) {\n\t\tfor (i=0; fp->ch[i]; i++) {\n\t\t\tnstate = fp->nextstate;\n\t\t\tif (nstate >= S_SELF)\n\t\t\t\tnstate = ~nstate;\n\t\t\tswitch (fp->ch[i]) {\n\n\t\t\tcase C_XX:\t\t/* random characters */\n\t\t\t\tfor (j=0; j<256; j++)\n\t\t\t\t\tbigfsm[j][fp->state] = nstate;\n\t\t\t\tcontinue;\n\t\t\tcase C_ALPH:\n\t\t\t\tfor (j=0; j<=256; j++)\n\t\t\t\t\tif ('a'<=j&&j<='z' || 'A'<=j&&j<='Z'\n\t\t\t\t\t  || j=='_')\n\t\t\t\t\t\tbigfsm[j][fp->state] = nstate;\n\t\t\t\tcontinue;\n\t\t\tcase C_NUM:\n\t\t\t\tfor (j='0'; j<='9'; j++)\n\t\t\t\t\tbigfsm[j][fp->state] = nstate;\n\t\t\t\tcontinue;\n\t\t\tdefault:\n\t\t\t\tbigfsm[fp->ch[i]][fp->state] = nstate;\n\t\t\t}\n\t\t}\n\t}\n\t/* install special cases for ? (trigraphs),  \\ (splicing), runes, and EOB */\n\tfor (i=0; i<MAXSTATE; i++) {\n\t\tfor (j=0; j<0xFF; j++)\n\t\t\tif (j=='?' || j=='\\\\') {\n\t\t\t\tif (bigfsm[j][i]>0)\n\t\t\t\t\tbigfsm[j][i] = ~bigfsm[j][i];\n\t\t\t\tbigfsm[j][i] &= ~QBSBIT;\n\t\t\t}\n\t\tbigfsm[EOB][i] = ~S_EOB;\n\t\tif (bigfsm[EOFC][i]>=0)\n\t\t\tbigfsm[EOFC][i] = ~S_EOF;\n\t}\n}\n\nvoid\nfixlex(void)\n{\n\t/* do C++ comments? */\n\tif (Cplusplus==0)\n\t\tbigfsm['/'][COM1] = bigfsm['x'][COM1];\n}\n\n/*\n * fill in a row of tokens from input, terminated by NL or END\n * First token is put at trp->lp.\n * Reset is non-zero when the input buffer can be \"rewound.\"\n * The value is a flag indicating that possible macros have\n * been seen in the row.\n */\nint\ngettokens(Tokenrow *trp, int reset)\n{\n\tregister int c, state, oldstate;\n\tregister uchar *ip;\n\tregister Token *tp, *maxp;\n\tint runelen;\n\tSource *s = cursource;\n\tint nmac = 0;\n\textern char outbuf[];\n\n\ttp = trp->lp;\n\tip = s->inp;\n\tif (reset) {\n\t\ts->lineinc = 0;\n\t\tif (ip>=s->inl) {\t\t/* nothing in buffer */\n\t\t\ts->inl = s->inb;\n\t\t\tfillbuf(s);\n\t\t\tip = s->inp = s->inb;\n\t\t} else if (ip >= s->inb+(3*INS/4)) {\n\t\t\tmemmove(s->inb, ip, 4+s->inl-ip);\n\t\t\ts->inl = s->inb+(s->inl-ip);\n\t\t\tip = s->inp = s->inb;\n\t\t}\n\t}\n\tmaxp = &trp->bp[trp->max];\n\trunelen = 1;\n\tfor (;;) {\n\t   continue2:\n\t\tif (tp>=maxp) {\n\t\t\ttrp->lp = tp;\n\t\t\ttp = growtokenrow(trp);\n\t\t\tmaxp = &trp->bp[trp->max];\n\t\t}\n\t\ttp->type = UNCLASS;\n\t\ttp->hideset = 0;\n\t\ttp->t = ip;\n\t\ttp->wslen = 0;\n\t\ttp->flag = 0;\n\t\tstate = START;\n\t\tfor (;;) {\n\t\t\toldstate = state;\n\t\t\tc = *ip;\n\t\t\tif ((state = bigfsm[c][state]) >= 0) {\n\t\t\t\tip += runelen;\n\t\t\t\trunelen = 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tstate = ~state;\n\t\treswitch:\n\t\t\tswitch (state&0177) {\n\t\t\tcase S_SELF:\n\t\t\t\tip += runelen;\n\t\t\t\trunelen = 1;\n\t\t\tcase S_SELFB:\n\t\t\t\ttp->type = GETACT(state);\n\t\t\t\ttp->len = ip - tp->t;\n\t\t\t\ttp++;\n\t\t\t\tgoto continue2;\n\n\t\t\tcase S_NAME:\t/* like S_SELFB but with nmac check */\n\t\t\t\ttp->type = NAME;\n\t\t\t\ttp->len = ip - tp->t;\n\t\t\t\tnmac |= quicklook(tp->t[0], tp->len>1?tp->t[1]:0);\n\t\t\t\ttp++;\n\t\t\t\tgoto continue2;\n\n\t\t\tcase S_WS:\n\t\t\t\ttp->wslen = ip - tp->t;\n\t\t\t\ttp->t = ip;\n\t\t\t\tstate = START;\n\t\t\t\tcontinue;\n\n\t\t\tdefault:\n\t\t\t\tif ((state&QBSBIT)==0) {\n\t\t\t\t\tip += runelen;\n\t\t\t\t\trunelen = 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tstate &= ~QBSBIT;\n\t\t\t\ts->inp = ip;\n\t\t\t\tif (c=='?') { \t/* check trigraph */\n\t\t\t\t\tif (trigraph(s)) {\n\t\t\t\t\t\tstate = oldstate;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tgoto reswitch;\n\t\t\t\t}\n\t\t\t\tif (c=='\\\\') { /* line-folding */\n\t\t\t\t\tif (foldline(s)) {\n\t\t\t\t\t\ts->lineinc++;\n\t\t\t\t\t\tstate = oldstate;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tgoto reswitch;\n\t\t\t\t}\n\t\t\t\terror(WARNING, \"Lexical botch in cpp\");\n\t\t\t\tip += runelen;\n\t\t\t\trunelen = 1;\n\t\t\t\tcontinue;\n\n\t\t\tcase S_EOB:\n\t\t\t\ts->inp = ip;\n\t\t\t\tfillbuf(cursource);\n\t\t\t\tstate = oldstate;\n\t\t\t\tcontinue;\n\n\t\t\tcase S_EOF:\n\t\t\t\ttp->type = END;\n\t\t\t\ttp->len = 0;\n\t\t\t\ts->inp = ip;\n\t\t\t\tif (tp!=trp->bp && (tp-1)->type!=NL && cursource->fd!=-1)\n\t\t\t\t\terror(WARNING,\"No newline at end of file\");\n\t\t\t\ttrp->lp = tp+1;\n\t\t\t\treturn nmac;\n\n\t\t\tcase S_STNL:\n\t\t\t\terror(ERROR, \"Unterminated string or char const\");\n\t\t\tcase S_NL:\n\t\t\t\ttp->t = ip;\n\t\t\t\ttp->type = NL;\n\t\t\t\ttp->len = 1;\n\t\t\t\ttp->wslen = 0;\n\t\t\t\ts->lineinc++;\n\t\t\t\ts->inp = ip+1;\n\t\t\t\ttrp->lp = tp+1;\n\t\t\t\treturn nmac;\n\n\t\t\tcase S_EOFSTR:\n\t\t\t\terror(FATAL, \"EOF in string or char constant\");\n\t\t\t\tbreak;\n\n\t\t\tcase S_COMNL:\n\t\t\t\ts->lineinc++;\n\t\t\t\tstate = COM2;\n\t\t\t\tip += runelen;\n\t\t\t\trunelen = 1;\n\t\t\t\tif (ip >= s->inb+(7*INS/8)) { /* very long comment */\n\t\t\t\t\tmemmove(tp->t, ip, 4+s->inl-ip);\n\t\t\t\t\ts->inl -= ip-tp->t;\n\t\t\t\t\tip = tp->t+1;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\n\t\t\tcase S_EOFCOM:\n\t\t\t\terror(WARNING, \"EOF inside comment\");\n\t\t\t\t--ip;\n\t\t\tcase S_COMMENT:\n\t\t\t\t++ip;\n\t\t\t\ttp->t = ip;\n\t\t\t\ttp->t[-1] = ' ';\n\t\t\t\ttp->wslen = 1;\n\t\t\t\tstate = START;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tip += runelen;\n\t\trunelen = 1;\n\t\ttp->len = ip - tp->t;\n\t\ttp++;\n\t}\n}\n\n/* have seen ?; handle the trigraph it starts (if any) else 0 */\nint\ntrigraph(Source *s)\n{\n\tint c;\n\n\twhile (s->inp+2 >= s->inl && fillbuf(s)!=EOF)\n\t\t;\n\tif (s->inp[1]!='?')\n\t\treturn 0;\n\tc = 0;\n\tswitch(s->inp[2]) {\n\tcase '=':\n\t\tc = '#'; break;\n\tcase '(':\n\t\tc = '['; break;\n\tcase '/':\n\t\tc = '\\\\'; break;\n\tcase ')':\n\t\tc = ']'; break;\n\tcase '\\'':\n\t\tc = '^'; break;\n\tcase '<':\n\t\tc = '{'; break;\n\tcase '!':\n\t\tc = '|'; break;\n\tcase '>':\n\t\tc = '}'; break;\n\tcase '-':\n\t\tc = '~'; break;\n\t}\n\tif (c) {\n\t\t*s->inp = c;\n\t\tmemmove(s->inp+1, s->inp+3, s->inl-s->inp+2);\n\t\ts->inl -= 2;\n\t}\n\treturn c;\n}\n\nint\nfoldline(Source *s)\n{\n\twhile (s->inp+1 >= s->inl && fillbuf(s)!=EOF)\n\t\t;\n\tif (s->inp[1] == '\\n') {\n\t\tmemmove(s->inp, s->inp+2, s->inl-s->inp+3);\n\t\ts->inl -= 2;\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\nint\nfillbuf(Source *s)\n{\n\tint n, nr;\n\n\tnr = INS/8;\n\tif ((char *)s->inl+nr > (char *)s->inb+INS)\n\t\terror(FATAL, \"Input buffer overflow\");\n\tif (s->fd<0 || (n=read(s->fd, (char *)s->inl, INS/8)) <= 0)\n\t\tn = 0;\n\tif ((*s->inp&0xff) == EOB) /* sentinel character appears in input */\n\t\t*s->inp = EOFC;\n\ts->inl += n;\n\ts->inl[0] = s->inl[1]= s->inl[2]= s->inl[3] = EOB;\n\tif (n==0) {\n\t\ts->inl[0] = s->inl[1]= s->inl[2]= s->inl[3] = EOFC;\n\t\treturn EOF;\n\t}\n\treturn 0;\n}\n\n/*\n * Push down to new source of characters.\n * If fd>0 and str==NULL, then from a file `name';\n * if fd==-1 and str, then from the string.\n */\nSource *\nsetsource(char *name, int fd, char *str)\n{\n\tSource *s = new(Source);\n\tint len;\n\n\ts->line = 1;\n\ts->lineinc = 0;\n\ts->fd = fd;\n\ts->filename = name;\n\ts->next = cursource;\n\ts->ifdepth = 0;\n\tcursource = s;\n\t/* slop at right for EOB */\n\tif (str) {\n\t\tlen = strlen(str);\n\t\ts->inb = domalloc(len+4);\n\t\ts->inp = s->inb;\n\t\tstrncpy((char *)s->inp, str, len);\n\t} else {\n\t\ts->inb = domalloc(INS+4);\n\t\ts->inp = s->inb;\n\t\tlen = 0;\n\t}\n\ts->inl = s->inp+len;\n\ts->inl[0] = s->inl[1] = EOB;\n\treturn s;\n}\n\nvoid\nunsetsource(void)\n{\n\tSource *s = cursource;\n\n\tif (s->fd>=0) {\n\t\tclose(s->fd);\n\t\tdofree(s->inb);\n\t}\n\tcursource = s->next;\n\tdofree(s);\n}\n"
  },
  {
    "path": "lcc/cpp/macro.c",
    "content": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include \"cpp.h\"\n\n/*\n * do a macro definition.  tp points to the name being defined in the line\n */\nvoid\ndodefine(Tokenrow *trp)\n{\n\tToken *tp;\n\tNlist *np;\n\tTokenrow *def, *args;\n\n\ttp = trp->tp+1;\n\tif (tp>=trp->lp || tp->type!=NAME) {\n\t\terror(ERROR, \"#defined token is not a name\");\n\t\treturn;\n\t}\n\tnp = lookup(tp, 1);\n\tif (np->flag&ISUNCHANGE) {\n\t\terror(ERROR, \"#defined token %t can't be redefined\", tp);\n\t\treturn;\n\t}\n\t/* collect arguments */\n\ttp += 1;\n\targs = NULL;\n\tif (tp<trp->lp && tp->type==LP && tp->wslen==0) {\n\t\t/* macro with args */\n\t\tint narg = 0;\n\t\ttp += 1;\n\t\targs = new(Tokenrow);\n\t\tmaketokenrow(2, args);\n\t\tif (tp->type!=RP) {\n\t\t\tint err = 0;\n\t\t\tfor (;;) {\n\t\t\t\tToken *atp;\n\t\t\t\tif (tp->type!=NAME) {\n\t\t\t\t\terr++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (narg>=args->max)\n\t\t\t\t\tgrowtokenrow(args);\n\t\t\t\tfor (atp=args->bp; atp<args->lp; atp++)\n\t\t\t\t\tif (atp->len==tp->len\n\t\t\t\t\t && strncmp((char*)atp->t, (char*)tp->t, tp->len)==0)\n\t\t\t\t\t\terror(ERROR, \"Duplicate macro argument\");\n\t\t\t\t*args->lp++ = *tp;\n\t\t\t\tnarg++;\n\t\t\t\ttp += 1;\n\t\t\t\tif (tp->type==RP)\n\t\t\t\t\tbreak;\n\t\t\t\tif (tp->type!=COMMA) {\n\t\t\t\t\terr++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\ttp += 1;\n\t\t\t}\n\t\t\tif (err) {\n\t\t\t\terror(ERROR, \"Syntax error in macro parameters\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\ttp += 1;\n\t}\n\ttrp->tp = tp;\n\tif (((trp->lp)-1)->type==NL)\n\t\ttrp->lp -= 1;\n\tdef = normtokenrow(trp);\n\tif (np->flag&ISDEFINED) {\n\t\tif (comparetokens(def, np->vp)\n\t\t || (np->ap==NULL) != (args==NULL)\n\t\t || np->ap && comparetokens(args, np->ap))\n\t\t\terror(ERROR, \"Macro redefinition of %t\", trp->bp+2);\n\t}\n\tif (args) {\n\t\tTokenrow *tap;\n\t\ttap = normtokenrow(args);\n\t\tdofree(args->bp);\n\t\targs = tap;\n\t}\n\tnp->ap = args;\n\tnp->vp = def;\n\tnp->flag |= ISDEFINED;\n}\n\n/*\n * Definition received via -D or -U\n */\nvoid\ndoadefine(Tokenrow *trp, int type)\n{\n\tNlist *np;\n\tstatic Token onetoken[1] = {{ NUMBER, 0, 0, 0, 1, (uchar*)\"1\" }};\n\tstatic Tokenrow onetr = { onetoken, onetoken, onetoken+1, 1 };\n\n\ttrp->tp = trp->bp;\n\tif (type=='U') {\n\t\tif (trp->lp-trp->tp != 2 || trp->tp->type!=NAME)\n\t\t\tgoto syntax;\n\t\tif ((np = lookup(trp->tp, 0)) == NULL)\n\t\t\treturn;\n\t\tnp->flag &= ~ISDEFINED;\n\t\treturn;\n\t}\n\tif (trp->tp >= trp->lp || trp->tp->type!=NAME)\n\t\tgoto syntax;\n\tnp = lookup(trp->tp, 1);\n\tnp->flag |= ISDEFINED;\n\ttrp->tp += 1;\n\tif (trp->tp >= trp->lp || trp->tp->type==END) {\n\t\tnp->vp = &onetr;\n\t\treturn;\n\t}\n\tif (trp->tp->type!=ASGN)\n\t\tgoto syntax;\n\ttrp->tp += 1;\n\tif ((trp->lp-1)->type == END)\n\t\ttrp->lp -= 1;\n\tnp->vp = normtokenrow(trp);\n\treturn;\nsyntax:\n\terror(FATAL, \"Illegal -D or -U argument %r\", trp);\n}\n\t\t\t\n/*\n * Do macro expansion in a row of tokens.\n * Flag is NULL if more input can be gathered.\n */\nvoid\nexpandrow(Tokenrow *trp, char *flag)\n{\n\tToken *tp;\n\tNlist *np;\n\n\tif (flag)\n\t\tsetsource(flag, -1, \"\");\n\tfor (tp = trp->tp; tp<trp->lp; ) {\n\t\tif (tp->type!=NAME\n\t\t || quicklook(tp->t[0], tp->len>1?tp->t[1]:0)==0\n\t\t || (np = lookup(tp, 0))==NULL\n\t\t || (np->flag&(ISDEFINED|ISMAC))==0\n\t\t || tp->hideset && checkhideset(tp->hideset, np)) {\n\t\t\ttp++;\n\t\t\tcontinue;\n\t\t}\n\t\ttrp->tp = tp;\n\t\tif (np->val==KDEFINED) {\n\t\t\ttp->type = DEFINED;\n\t\t\tif ((tp+1)<trp->lp && (tp+1)->type==NAME)\n\t\t\t\t(tp+1)->type = NAME1;\n\t\t\telse if ((tp+3)<trp->lp && (tp+1)->type==LP\n\t\t\t && (tp+2)->type==NAME && (tp+3)->type==RP)\n\t\t\t\t(tp+2)->type = NAME1;\n\t\t\telse\n\t\t\t\terror(ERROR, \"Incorrect syntax for `defined'\");\n\t\t\ttp++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (np->flag&ISMAC)\n\t\t\tbuiltin(trp, np->val);\n\t\telse {\n\t\t\texpand(trp, np);\n\t\t}\n\t\ttp = trp->tp;\n\t}\n\tif (flag)\n\t\tunsetsource();\n}\n\n/*\n * Expand the macro whose name is np, at token trp->tp, in the tokenrow.\n * Return trp->tp at the first token next to be expanded\n * (ordinarily the beginning of the expansion)\n */\nvoid\nexpand(Tokenrow *trp, Nlist *np)\n{\n\tTokenrow ntr;\n\tint ntokc, narg, i;\n\tToken *tp;\n\tTokenrow *atr[NARG+1];\n\tint hs;\n\n\tcopytokenrow(&ntr, np->vp);\t\t/* copy macro value */\n\tif (np->ap==NULL)\t\t\t/* parameterless */\n\t\tntokc = 1;\n\telse {\n\t\tntokc = gatherargs(trp, atr, &narg);\n\t\tif (narg<0) {\t\t\t/* not actually a call (no '(') */\n\t\t\ttrp->tp++;\n\t\t\treturn;\n\t\t}\n\t\tif (narg != rowlen(np->ap)) {\n\t\t\terror(ERROR, \"Disagreement in number of macro arguments\");\n\t\t\ttrp->tp->hideset = newhideset(trp->tp->hideset, np);\n\t\t\ttrp->tp += ntokc;\n\t\t\treturn;\n\t\t}\n\t\tsubstargs(np, &ntr, atr);\t/* put args into replacement */\n\t\tfor (i=0; i<narg; i++) {\n\t\t\tdofree(atr[i]->bp);\n\t\t\tdofree(atr[i]);\n\t\t}\n\t}\n\tdoconcat(&ntr);\t\t\t\t/* execute ## operators */\n\ths = newhideset(trp->tp->hideset, np);\n\tfor (tp=ntr.bp; tp<ntr.lp; tp++) {\t/* distribute hidesets */\n\t\tif (tp->type==NAME) {\n\t\t\tif (tp->hideset==0)\n\t\t\t\ttp->hideset = hs;\n\t\t\telse\n\t\t\t\ttp->hideset = unionhideset(tp->hideset, hs);\n\t\t}\n\t}\n\tntr.tp = ntr.bp;\n\tinsertrow(trp, ntokc, &ntr);\n\ttrp->tp -= rowlen(&ntr);\n\tdofree(ntr.bp);\n\treturn;\n}\t\n\n/*\n * Gather an arglist, starting in trp with tp pointing at the macro name.\n * Return total number of tokens passed, stash number of args found.\n * trp->tp is not changed relative to the tokenrow.\n */\nint\ngatherargs(Tokenrow *trp, Tokenrow **atr, int *narg)\n{\n\tint parens = 1;\n\tint ntok = 0;\n\tToken *bp, *lp;\n\tTokenrow ttr;\n\tint ntokp;\n\tint needspace;\n\n\t*narg = -1;\t\t\t/* means that there is no macro call */\n\t/* look for the ( */\n\tfor (;;) {\n\t\ttrp->tp++;\n\t\tntok++;\n\t\tif (trp->tp >= trp->lp) {\n\t\t\tgettokens(trp, 0);\n\t\t\tif ((trp->lp-1)->type==END) {\n\t\t\t\ttrp->lp -= 1;\n\t\t\t\ttrp->tp -= ntok;\n\t\t\t\treturn ntok;\n\t\t\t}\n\t\t}\n\t\tif (trp->tp->type==LP)\n\t\t\tbreak;\n\t\tif (trp->tp->type!=NL)\n\t\t\treturn ntok;\n\t}\n\t*narg = 0;\n\tntok++;\n\tntokp = ntok;\n\ttrp->tp++;\n\t/* search for the terminating ), possibly extending the row */\n\tneedspace = 0;\n\twhile (parens>0) {\n\t\tif (trp->tp >= trp->lp)\n\t\t\tgettokens(trp, 0);\n\t\tif (needspace) {\n\t\t\tneedspace = 0;\n\t\t\tmakespace(trp);\n\t\t}\n\t\tif (trp->tp->type==END) {\n\t\t\ttrp->lp -= 1;\n\t\t\ttrp->tp -= ntok;\n\t\t\terror(ERROR, \"EOF in macro arglist\");\n\t\t\treturn ntok;\n\t\t}\n\t\tif (trp->tp->type==NL) {\n\t\t\ttrp->tp += 1;\n\t\t\tadjustrow(trp, -1);\n\t\t\ttrp->tp -= 1;\n\t\t\tmakespace(trp);\n\t\t\tneedspace = 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (trp->tp->type==LP)\n\t\t\tparens++;\n\t\telse if (trp->tp->type==RP)\n\t\t\tparens--;\n\t\ttrp->tp++;\n\t\tntok++;\n\t}\n\ttrp->tp -= ntok;\n\t/* Now trp->tp won't move underneath us */\n\tlp = bp = trp->tp+ntokp;\n\tfor (; parens>=0; lp++) {\n\t\tif (lp->type == LP) {\n\t\t\tparens++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (lp->type==RP)\n\t\t\tparens--;\n\t\tif (lp->type==DSHARP)\n\t\t\tlp->type = DSHARP1;\t/* ## not special in arg */\n\t\tif (lp->type==COMMA && parens==0 || parens<0 && (lp-1)->type!=LP) {\n\t\t\tif (*narg>=NARG-1)\n\t\t\t\terror(FATAL, \"Sorry, too many macro arguments\");\n\t\t\tttr.bp = ttr.tp = bp;\n\t\t\tttr.lp = lp;\n\t\t\tatr[(*narg)++] = normtokenrow(&ttr);\n\t\t\tbp = lp+1;\n\t\t}\n\t}\n\treturn ntok;\n}\n\n/*\n * substitute the argument list into the replacement string\n *  This would be simple except for ## and #\n */\nvoid\nsubstargs(Nlist *np, Tokenrow *rtr, Tokenrow **atr)\n{\n\tTokenrow tatr;\n\tToken *tp;\n\tint ntok, argno;\n\n\tfor (rtr->tp=rtr->bp; rtr->tp<rtr->lp; ) {\n\t\tif (rtr->tp->type==SHARP) {\t/* string operator */\n\t\t\ttp = rtr->tp;\n\t\t\trtr->tp += 1;\n\t\t\tif ((argno = lookuparg(np, rtr->tp))<0) {\n\t\t\t\terror(ERROR, \"# not followed by macro parameter\");\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tntok = 1 + (rtr->tp - tp);\n\t\t\trtr->tp = tp;\n\t\t\tinsertrow(rtr, ntok, stringify(atr[argno]));\n\t\t\tcontinue;\n\t\t}\n\t\tif (rtr->tp->type==NAME\n\t\t && (argno = lookuparg(np, rtr->tp)) >= 0) {\n\t\t\tif ((rtr->tp+1)->type==DSHARP\n\t\t\t || rtr->tp!=rtr->bp && (rtr->tp-1)->type==DSHARP)\n\t\t\t\tinsertrow(rtr, 1, atr[argno]);\n\t\t\telse {\n\t\t\t\tcopytokenrow(&tatr, atr[argno]);\n\t\t\t\texpandrow(&tatr, \"<macro>\");\n\t\t\t\tinsertrow(rtr, 1, &tatr);\n\t\t\t\tdofree(tatr.bp);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\trtr->tp++;\n\t}\n}\n\n/*\n * Evaluate the ## operators in a tokenrow\n */\nvoid\ndoconcat(Tokenrow *trp)\n{\n\tToken *ltp, *ntp;\n\tTokenrow ntr;\n\tint len;\n\n\tfor (trp->tp=trp->bp; trp->tp<trp->lp; trp->tp++) {\n\t\tif (trp->tp->type==DSHARP1)\n\t\t\ttrp->tp->type = DSHARP;\n\t\telse if (trp->tp->type==DSHARP) {\n\t\t\tchar tt[128];\n\t\t\tltp = trp->tp-1;\n\t\t\tntp = trp->tp+1;\n\t\t\tif (ltp<trp->bp || ntp>=trp->lp) {\n\t\t\t\terror(ERROR, \"## occurs at border of replacement\");\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlen = ltp->len + ntp->len;\n\t\t\tstrncpy((char*)tt, (char*)ltp->t, ltp->len);\n\t\t\tstrncpy((char*)tt+ltp->len, (char*)ntp->t, ntp->len);\n\t\t\ttt[len] = '\\0';\n\t\t\tsetsource(\"<##>\", -1, tt);\n\t\t\tmaketokenrow(3, &ntr);\n\t\t\tgettokens(&ntr, 1);\n\t\t\tunsetsource();\n\t\t\tif (ntr.lp-ntr.bp!=2 || ntr.bp->type==UNCLASS)\n\t\t\t\terror(WARNING, \"Bad token %r produced by ##\", &ntr);\n\t\t\tntr.lp = ntr.bp+1;\n\t\t\ttrp->tp = ltp;\n\t\t\tmakespace(&ntr);\n\t\t\tinsertrow(trp, (ntp-ltp)+1, &ntr);\n\t\t\tdofree(ntr.bp);\n\t\t\ttrp->tp--;\n\t\t}\n\t}\n}\n\n/*\n * tp is a potential parameter name of macro mac;\n * look it up in mac's arglist, and if found, return the\n * corresponding index in the argname array.  Return -1 if not found.\n */\nint\nlookuparg(Nlist *mac, Token *tp)\n{\n\tToken *ap;\n\n\tif (tp->type!=NAME || mac->ap==NULL)\n\t\treturn -1;\n\tfor (ap=mac->ap->bp; ap<mac->ap->lp; ap++) {\n\t\tif (ap->len==tp->len && strncmp((char*)ap->t,(char*)tp->t,ap->len)==0)\n\t\t\treturn ap - mac->ap->bp;\n\t}\n\treturn -1;\n}\n\n/*\n * Return a quoted version of the tokenrow (from # arg)\n */\n#define\tSTRLEN\t512\nTokenrow *\nstringify(Tokenrow *vp)\n{\n\tstatic Token t = { STRING };\n\tstatic Tokenrow tr = { &t, &t, &t+1, 1 };\n\tToken *tp;\n\tuchar s[STRLEN];\n\tuchar *sp = s, *cp;\n\tint i, instring;\n\n\t*sp++ = '\"';\n\tfor (tp = vp->bp; tp < vp->lp; tp++) {\n\t\tinstring = tp->type==STRING || tp->type==CCON;\n\t\tif (sp+2*tp->len >= &s[STRLEN-10]) {\n\t\t\terror(ERROR, \"Stringified macro arg is too long\");\n\t\t\tbreak;\n\t\t}\n\t\tif (tp->wslen && (tp->flag&XPWS)==0)\n\t\t\t*sp++ = ' ';\n\t\tfor (i=0, cp=tp->t; i<tp->len; i++) {\t\n\t\t\tif (instring && (*cp=='\"' || *cp=='\\\\'))\n\t\t\t\t*sp++ = '\\\\';\n\t\t\t*sp++ = *cp++;\n\t\t}\n\t}\n\t*sp++ = '\"';\n\t*sp = '\\0';\n\tsp = s;\n\tt.len = strlen((char*)sp);\n\tt.t = newstring(sp, t.len, 0);\n\treturn &tr;\n}\n\n/*\n * expand a builtin name\n */\nvoid\nbuiltin(Tokenrow *trp, int biname)\n{\n\tchar *op;\n\tToken *tp;\n\tSource *s;\n\n\ttp = trp->tp;\n\ttrp->tp++;\n\t/* need to find the real source */\n\ts = cursource;\n\twhile (s && s->fd==-1)\n\t\ts = s->next;\n\tif (s==NULL)\n\t\ts = cursource;\n\t/* most are strings */\n\ttp->type = STRING;\n\tif (tp->wslen) {\n\t\t*outp++ = ' ';\n\t\ttp->wslen = 1;\n\t}\n\top = outp;\n\t*op++ = '\"';\n\tswitch (biname) {\n\n\tcase KLINENO:\n\t\ttp->type = NUMBER;\n\t\top = outnum(op-1, s->line);\n\t\tbreak;\n\n\tcase KFILE: {\n\t\tchar *src = s->filename;\n\t\twhile ((*op++ = *src++) != 0)\n\t\t\tif (src[-1] == '\\\\')\n\t\t\t\t*op++ = '\\\\';\n\t\top--;\n\t\tbreak;\n\t\t}\n\n\tcase KDATE:\n\t\tstrncpy(op, curtime+4, 7);\n\t\tstrncpy(op+7, curtime+20, 4);\n\t\top += 11;\n\t\tbreak;\n\n\tcase KTIME:\n\t\tstrncpy(op, curtime+11, 8);\n\t\top += 8;\n\t\tbreak;\n\n\tdefault:\n\t\terror(ERROR, \"cpp botch: unknown internal macro\");\n\t\treturn;\n\t}\n\tif (tp->type==STRING)\n\t\t*op++ = '\"';\n\ttp->t = (uchar*)outp;\n\ttp->len = op - outp;\n\toutp = op;\n}\n"
  },
  {
    "path": "lcc/cpp/nlist.c",
    "content": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include \"cpp.h\"\n\nextern\tint getopt(int, char *const *, const char *);\nextern\tchar\t*optarg;\nextern\tint\toptind;\nextern\tint\tverbose;\nextern\tint\tCplusplus;\nNlist\t*kwdefined;\nchar\twd[128];\n\n#define\tNLSIZE\t128\n\nstatic Nlist\t*nlist[NLSIZE];\n\nstruct\tkwtab {\n\tchar\t*kw;\n\tint\tval;\n\tint\tflag;\n} kwtab[] = {\n\t\"if\",\t\tKIF,\t\tISKW,\n\t\"ifdef\",\tKIFDEF,\t\tISKW,\n\t\"ifndef\",\tKIFNDEF,\tISKW,\n\t\"elif\",\t\tKELIF,\t\tISKW,\n\t\"else\",\t\tKELSE,\t\tISKW,\n\t\"endif\",\tKENDIF,\t\tISKW,\n\t\"include\",\tKINCLUDE,\tISKW,\n\t\"define\",\tKDEFINE,\tISKW,\n\t\"undef\",\tKUNDEF,\t\tISKW,\n\t\"line\",\t\tKLINE,\t\tISKW,\n\t\"error\",\tKERROR,\t\tISKW,\n\t\"pragma\",\tKPRAGMA,\tISKW,\n\t\"eval\",\t\tKEVAL,\t\tISKW,\n\t\"defined\",\tKDEFINED,\tISDEFINED+ISUNCHANGE,\n\t\"__LINE__\",\tKLINENO,\tISMAC+ISUNCHANGE,\n\t\"__FILE__\",\tKFILE,\t\tISMAC+ISUNCHANGE,\n\t\"__DATE__\",\tKDATE,\t\tISMAC+ISUNCHANGE,\n\t\"__TIME__\",\tKTIME,\t\tISMAC+ISUNCHANGE,\n\t\"__STDC__\",\tKSTDC,\t\tISUNCHANGE,\n\tNULL\n};\n\nunsigned long\tnamebit[077+1];\nNlist \t*np;\n\nvoid\nsetup_kwtab(void)\n{\n\tstruct kwtab *kp;\n\tNlist *np;\n\tToken t;\n\tstatic Token deftoken[1] = {{ NAME, 0, 0, 0, 7, (uchar*)\"defined\" }};\n\tstatic Tokenrow deftr = { deftoken, deftoken, deftoken+1, 1 };\n\n\tfor (kp=kwtab; kp->kw; kp++) {\n\t\tt.t = (uchar*)kp->kw;\n\t\tt.len = strlen(kp->kw);\n\t\tnp = lookup(&t, 1);\n\t\tnp->flag = kp->flag;\n\t\tnp->val = kp->val;\n\t\tif (np->val == KDEFINED) {\n\t\t\tkwdefined = np;\n\t\t\tnp->val = NAME;\n\t\t\tnp->vp = &deftr;\n\t\t\tnp->ap = 0;\n\t\t}\n\t}\n}\n\nNlist *\nlookup(Token *tp, int install)\n{\n\tunsigned int h;\n\tNlist *np;\n\tuchar *cp, *cpe;\n\n\th = 0;\n\tfor (cp=tp->t, cpe=cp+tp->len; cp<cpe; )\n\t\th += *cp++;\n\th %= NLSIZE;\n\tnp = nlist[h];\n\twhile (np) {\n\t\tif (*tp->t==*np->name && tp->len==np->len \n\t\t && strncmp((char*)tp->t, (char*)np->name, tp->len)==0)\n\t\t\treturn np;\n\t\tnp = np->next;\n\t}\n\tif (install) {\n\t\tnp = new(Nlist);\n\t\tnp->vp = NULL;\n\t\tnp->ap = NULL;\n\t\tnp->flag = 0;\n\t\tnp->val = 0;\n\t\tnp->len = tp->len;\n\t\tnp->name = newstring(tp->t, tp->len, 0);\n\t\tnp->next = nlist[h];\n\t\tnlist[h] = np;\n\t\tquickset(tp->t[0], tp->len>1? tp->t[1]:0);\n\t\treturn np;\n\t}\n\treturn NULL;\n}\n"
  },
  {
    "path": "lcc/cpp/tokens.c",
    "content": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include \"cpp.h\"\n\nstatic char wbuf[2*OBS];\nstatic char *wbp = wbuf;\n\n/*\n * 1 for tokens that don't need whitespace when they get inserted\n * by macro expansion\n */\nstatic const char wstab[] = {\n\t0,\t/* END */\n\t0,\t/* UNCLASS */\n\t0,\t/* NAME */\n\t0,\t/* NUMBER */\n\t0,\t/* STRING */\n\t0,\t/* CCON */\n\t1,\t/* NL */\n\t0,\t/* WS */\n\t0,\t/* DSHARP */\n\t0,\t/* EQ */\n\t0,\t/* NEQ */\n\t0,\t/* LEQ */\n\t0,\t/* GEQ */\n\t0,\t/* LSH */\n\t0,\t/* RSH */\n\t0,\t/* LAND */\n\t0,\t/* LOR */\n\t0,\t/* PPLUS */\n\t0,\t/* MMINUS */\n\t0,\t/* ARROW */\n\t1,\t/* SBRA */\n\t1,\t/* SKET */\n\t1,\t/* LP */\n\t1,\t/* RP */\n\t0,\t/* DOT */\n\t0,\t/* AND */\n\t0,\t/* STAR */\n\t0,\t/* PLUS */\n\t0,\t/* MINUS */\n\t0,\t/* TILDE */\n\t0,\t/* NOT */\n\t0,\t/* SLASH */\n\t0,\t/* PCT */\n\t0,\t/* LT */\n\t0,\t/* GT */\n\t0,\t/* CIRC */\n\t0,\t/* OR */\n\t0,\t/* QUEST */\n\t0,\t/* COLON */\n\t0,\t/* ASGN */\n\t1,\t/* COMMA */\n\t0,\t/* SHARP */\n\t1,\t/* SEMIC */\n\t1,\t/* CBRA */\n\t1,\t/* CKET */\n\t0,\t/* ASPLUS */\n \t0,\t/* ASMINUS */\n \t0,\t/* ASSTAR */\n \t0,\t/* ASSLASH */\n \t0,\t/* ASPCT */\n \t0,\t/* ASCIRC */\n \t0,\t/* ASLSH */\n\t0,\t/* ASRSH */\n \t0,\t/* ASOR */\n \t0,\t/* ASAND */\n\t0,\t/* ELLIPS */\n\t0,\t/* DSHARP1 */\n\t0,\t/* NAME1 */\n\t0,\t/* DEFINED */\n\t0,\t/* UMINUS */\n};\n\nvoid\nmaketokenrow(int size, Tokenrow *trp)\n{\n\ttrp->max = size;\n\tif (size>0)\n\t\ttrp->bp = (Token *)domalloc(size*sizeof(Token));\n\telse\n\t\ttrp->bp = NULL;\n\ttrp->tp = trp->bp;\n\ttrp->lp = trp->bp;\n}\n\nToken *\ngrowtokenrow(Tokenrow *trp)\n{\n\tint ncur = trp->tp - trp->bp;\n\tint nlast = trp->lp - trp->bp;\n\n\ttrp->max = 3*trp->max/2 + 1;\n\ttrp->bp = (Token *)realloc(trp->bp, trp->max*sizeof(Token));\n\tif (trp->bp == NULL)\n\t\terror(FATAL, \"Out of memory from realloc\");\n\ttrp->lp = &trp->bp[nlast];\n\ttrp->tp = &trp->bp[ncur];\n\treturn trp->lp;\n}\n\n/*\n * Compare a row of tokens, ignoring the content of WS; return !=0 if different\n */\nint\ncomparetokens(Tokenrow *tr1, Tokenrow *tr2)\n{\n\tToken *tp1, *tp2;\n\n\ttp1 = tr1->tp;\n\ttp2 = tr2->tp;\n\tif (tr1->lp-tp1 != tr2->lp-tp2)\n\t\treturn 1;\n\tfor (; tp1<tr1->lp ; tp1++, tp2++) {\n\t\tif (tp1->type != tp2->type\n\t\t || (tp1->wslen==0) != (tp2->wslen==0)\n\t\t || tp1->len != tp2->len\n\t\t || strncmp((char*)tp1->t, (char*)tp2->t, tp1->len)!=0)\n\t\t\treturn 1;\n\t}\n\treturn 0;\n}\n\n/*\n * replace ntok tokens starting at dtr->tp with the contents of str.\n * tp ends up pointing just beyond the replacement.\n * Canonical whitespace is assured on each side.\n */\nvoid\ninsertrow(Tokenrow *dtr, int ntok, Tokenrow *str)\n{\n\tint nrtok = rowlen(str);\n\n\tdtr->tp += ntok;\n\tadjustrow(dtr, nrtok-ntok);\n\tdtr->tp -= ntok;\n\tmovetokenrow(dtr, str);\n\tmakespace(dtr);\n\tdtr->tp += nrtok;\n\tmakespace(dtr);\n}\n\n/*\n * make sure there is WS before trp->tp, if tokens might merge in the output\n */\nvoid\nmakespace(Tokenrow *trp)\n{\n\tuchar *tt;\n\tToken *tp = trp->tp;\n\n\tif (tp >= trp->lp)\n\t\treturn;\n\tif (tp->wslen) {\n\t\tif (tp->flag&XPWS\n\t\t && (wstab[tp->type] || trp->tp>trp->bp && wstab[(tp-1)->type])) {\n\t\t\ttp->wslen = 0;\n\t\t\treturn;\n\t\t}\n\t\ttp->t[-1] = ' ';\n\t\treturn;\n\t}\n\tif (wstab[tp->type] || trp->tp>trp->bp && wstab[(tp-1)->type])\n\t\treturn;\n\ttt = newstring(tp->t, tp->len, 1);\n\t*tt++ = ' ';\n\ttp->t = tt;\n\ttp->wslen = 1;\n\ttp->flag |= XPWS;\n}\n\n/*\n * Copy an entire tokenrow into another, at tp.\n * It is assumed that there is enough space.\n *  Not strictly conforming.\n */\nvoid\nmovetokenrow(Tokenrow *dtr, Tokenrow *str)\n{\n\tint nby;\n\n\t/* nby = sizeof(Token) * (str->lp - str->bp); */\n\tnby = (char *)str->lp - (char *)str->bp;\n\tmemmove(dtr->tp, str->bp, nby);\n}\n\n/*\n * Move the tokens in a row, starting at tr->tp, rightward by nt tokens;\n * nt may be negative (left move).\n * The row may need to be grown.\n * Non-strictly conforming because of the (char *), but easily fixed\n */\nvoid\nadjustrow(Tokenrow *trp, int nt)\n{\n\tint nby, size;\n\n\tif (nt==0)\n\t\treturn;\n\tsize = (trp->lp - trp->bp) + nt;\n\twhile (size > trp->max)\n\t\tgrowtokenrow(trp);\n\t/* nby = sizeof(Token) * (trp->lp - trp->tp); */\n\tnby = (char *)trp->lp - (char *)trp->tp;\n\tif (nby)\n\t\tmemmove(trp->tp+nt, trp->tp, nby);\n\ttrp->lp += nt;\n}\n\n/*\n * Copy a row of tokens into the destination holder, allocating\n * the space for the contents.  Return the destination.\n */\nTokenrow *\ncopytokenrow(Tokenrow *dtr, Tokenrow *str)\n{\n\tint len = rowlen(str);\n\n\tmaketokenrow(len, dtr);\n\tmovetokenrow(dtr, str);\n\tdtr->lp += len;\n\treturn dtr;\n}\n\n/*\n * Produce a copy of a row of tokens.  Start at trp->tp.\n * The value strings are copied as well.  The first token\n * has WS available.\n */\nTokenrow *\nnormtokenrow(Tokenrow *trp)\n{\n\tToken *tp;\n\tTokenrow *ntrp = new(Tokenrow);\n\tint len;\n\n\tlen = trp->lp - trp->tp;\n\tif (len<=0)\n\t\tlen = 1;\n\tmaketokenrow(len, ntrp);\n\tfor (tp=trp->tp; tp < trp->lp; tp++) {\n\t\t*ntrp->lp = *tp;\n\t\tif (tp->len) {\n\t\t\tntrp->lp->t = newstring(tp->t, tp->len, 1);\n\t\t\t*ntrp->lp->t++ = ' ';\n\t\t\tif (tp->wslen)\n\t\t\t\tntrp->lp->wslen = 1;\n\t\t}\n\t\tntrp->lp++;\n\t}\n\tif (ntrp->lp > ntrp->bp)\n\t\tntrp->bp->wslen = 0;\n\treturn ntrp;\n}\n\n/*\n * Debugging\n */\nvoid\npeektokens(Tokenrow *trp, char *str)\n{\n\tToken *tp;\n\n\ttp = trp->tp;\n\tflushout();\n\tif (str)\n\t\tfprintf(stderr, \"%s \", str);\n\tif (tp<trp->bp || tp>trp->lp)\n\t\tfprintf(stderr, \"(tp offset %d) \", tp-trp->bp);\n\tfor (tp=trp->bp; tp<trp->lp && tp<trp->bp+32; tp++) {\n\t\tif (tp->type!=NL) {\n\t\t\tint c = tp->t[tp->len];\n\t\t\ttp->t[tp->len] = 0;\n\t\t\tfprintf(stderr, \"%s\", tp->t);\n\t\t\ttp->t[tp->len] = c;\n\t\t}\n\t\tif (tp->type==NAME) {\n\t\t\tfprintf(stderr, tp==trp->tp?\"{*\":\"{\");\n\t\t\tprhideset(tp->hideset);\n\t\t\tfprintf(stderr, \"} \");\n\t\t} else\n\t\t\tfprintf(stderr, tp==trp->tp?\"{%x*} \":\"{%x} \", tp->type);\n\t}\n\tfprintf(stderr, \"\\n\");\n\tfflush(stderr);\n}\n\nvoid\nputtokens(Tokenrow *trp)\n{\n\tToken *tp;\n\tint len;\n\tuchar *p;\n\n\tif (verbose)\n\t\tpeektokens(trp, \"\");\n\ttp = trp->bp;\n\tfor (; tp<trp->lp; tp++) {\n\t\tlen = tp->len+tp->wslen;\n\t\tp = tp->t-tp->wslen;\n\t\twhile (tp<trp->lp-1 && p+len == (tp+1)->t - (tp+1)->wslen) {\n\t\t\ttp++;\n\t\t\tlen += tp->wslen+tp->len;\n\t\t}\n\t\tif (len>OBS/2) {\t\t/* handle giant token */\n\t\t\tif (wbp > wbuf)\n\t\t\t\twrite(1, wbuf, wbp-wbuf);\n\t\t\twrite(1, (char *)p, len);\n\t\t\twbp = wbuf;\n\t\t} else {\t\n\t\t\tmemcpy(wbp, p, len);\n\t\t\twbp += len;\n\t\t}\n\t\tif (wbp >= &wbuf[OBS]) {\n\t\t\twrite(1, wbuf, OBS);\n\t\t\tif (wbp > &wbuf[OBS])\n\t\t\t\tmemcpy(wbuf, wbuf+OBS, wbp - &wbuf[OBS]);\n\t\t\twbp -= OBS;\n\t\t}\n\t}\n\ttrp->tp = tp;\n\tif (cursource->fd==0)\n\t\tflushout();\n}\n\nvoid\nflushout(void)\n{\n\tif (wbp>wbuf) {\n\t\twrite(1, wbuf, wbp-wbuf);\n\t\twbp = wbuf;\n\t}\n}\n\n/*\n * turn a row into just a newline\n */\nvoid\nsetempty(Tokenrow *trp)\n{\n\ttrp->tp = trp->bp;\n\ttrp->lp = trp->bp+1;\n\t*trp->bp = nltoken;\n}\n\n/*\n * generate a number\n */\nchar *\noutnum(char *p, int n)\n{\n\tif (n>=10)\n\t\tp = outnum(p, n/10);\n\t*p++ = n%10 + '0';\n\treturn p;\n}\n\n/*\n * allocate and initialize a new string from s, of length l, at offset o\n * Null terminated.\n */\nuchar *\nnewstring(uchar *s, int l, int o)\n{\n\tuchar *ns = (uchar *)domalloc(l+o+1);\n\n\tns[l+o] = '\\0';\n\treturn (uchar*)strncpy((char*)ns+o, (char*)s, l) - o;\n}\n"
  },
  {
    "path": "lcc/cpp/unix.c",
    "content": "#include <stdio.h>\n#include <stddef.h>\n#include <stdlib.h>\n#include <string.h>\n#include \"cpp.h\"\n\nextern\tint getopt(int, char *const *, const char *);\nextern\tchar\t*optarg, rcsid[];\nextern\tint\toptind;\nint\tverbose;\nint\tMflag;\t/* only print active include files */\nchar\t*objname; /* \"src.$O: \" */\nint\tCplusplus = 1;\n\nvoid\nsetup(int argc, char **argv)\n{\n\tint c, fd, i;\n\tchar *fp, *dp;\n\tTokenrow tr;\n\textern void setup_kwtab(void);\n\n\tsetup_kwtab();\n\twhile ((c = getopt(argc, argv, \"MNOVv+I:D:U:F:lg\")) != -1)\n\t\tswitch (c) {\n\t\tcase 'N':\n\t\t\tfor (i=0; i<NINCLUDE; i++)\n\t\t\t\tif (includelist[i].always==1)\n\t\t\t\t\tincludelist[i].deleted = 1;\n\t\t\tbreak;\n\t\tcase 'I':\n\t\t\tfor (i=NINCLUDE-2; i>=0; i--) {\n\t\t\t\tif (includelist[i].file==NULL) {\n\t\t\t\t\tincludelist[i].always = 1;\n\t\t\t\t\tincludelist[i].file = optarg;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (i<0)\n\t\t\t\terror(FATAL, \"Too many -I directives\");\n\t\t\tbreak;\n\t\tcase 'D':\n\t\tcase 'U':\n\t\t\tsetsource(\"<cmdarg>\", -1, optarg);\n\t\t\tmaketokenrow(3, &tr);\n\t\t\tgettokens(&tr, 1);\n\t\t\tdoadefine(&tr, c);\n\t\t\tunsetsource();\n\t\t\tbreak;\n\t\tcase 'M':\n\t\t\tMflag++;\n\t\t\tbreak;\n\t\tcase 'v':\n\t\t\tfprintf(stderr, \"%s %s\\n\", argv[0], rcsid);\n\t\t\tbreak;\n\t\tcase 'V':\n\t\t\tverbose++;\n\t\t\tbreak;\n\t\tcase '+':\n\t\t\tCplusplus++;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\tdp = \".\";\n\tfp = \"<stdin>\";\n\tfd = 0;\n\tif (optind<argc) {\n\t\tif ((fp = strrchr(argv[optind], '/')) != NULL) {\n\t\t\tint len = fp - argv[optind];\n\t\t\tdp = (char*)newstring((uchar*)argv[optind], len+1, 0);\n\t\t\tdp[len] = '\\0';\n\t\t}\n\t\tfp = (char*)newstring((uchar*)argv[optind], strlen(argv[optind]), 0);\n\t\tif ((fd = open(fp, 0)) <= 0)\n\t\t\terror(FATAL, \"Can't open input file %s\", fp);\n\t}\n\tif (optind+1<argc) {\n\t\tint fdo = creat(argv[optind+1], 0666);\n\t\tif (fdo<0)\n\t\t\terror(FATAL, \"Can't open output file %s\", argv[optind+1]);\n\t\tdup2(fdo, 1);\n\t}\n\tif(Mflag)\n\t\tsetobjname(fp);\n\tincludelist[NINCLUDE-1].always = 0;\n\tincludelist[NINCLUDE-1].file = dp;\n\tsetsource(fp, fd, NULL);\n}\n\n\n\n/* memmove is defined here because some vendors don't provide it at\n   all and others do a terrible job (like calling malloc) */\nvoid *\nmemmove(void *dp, const void *sp, size_t n)\n{\n\tunsigned char *cdp, *csp;\n\n\tif (n<=0)\n\t\treturn 0;\n\tcdp = dp;\n\tcsp = (unsigned char *)sp;\n\tif (cdp < csp) {\n\t\tdo {\n\t\t\t*cdp++ = *csp++;\n\t\t} while (--n);\n\t} else {\n\t\tcdp += n;\n\t\tcsp += n;\n\t\tdo {\n\t\t\t*--cdp = *--csp;\n\t\t} while (--n);\n\t}\n\treturn 0;\n}\n"
  },
  {
    "path": "lcc/custom.mk",
    "content": "BUILDDIR=/tmp\n"
  },
  {
    "path": "lcc/doc/4.html",
    "content": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n<html>\n\n<head>\n<link HREF=\"mailto:drh@microsoft.com\" REV=\"made\" TITLE=\"David R. Hanson\">\n<title>The lcc 4.1 Code-Generation Interface</title>\n</head>\n\n<body>\n\n<h1>The lcc 4.1 Code-Generation Interface</h1>\n\n<p ALIGN=\"LEFT\"><strong><a HREF=\"http://www.research.microsoft.com/~cwfraser/\">Christopher\nW. Fraser</a> and <a HREF=\"http://www.research.microsoft.com/~drh/\">David R. Hanson</a>, <a\nHREF=\"http://www.research.microsoft.com/\">Microsoft Research</a></strong></p>\n\n<h2>Contents</h2>\n\n<dir>\n  <li><a HREF=\"#intro\">Introduction</a> </li>\n  <li><a HREF=\"#metrics\">5.1 Type Metrics</a></li>\n  <li><a HREF=\"#symbols\">5.3 Symbols</a> </li>\n  <li><a HREF=\"#operators\">5.5 Dag Operators</a></li>\n  <li><a HREF=\"#flags\">5.6 Interface Flags</a></li>\n  <li><a HREF=\"#definitions\">5.8 Definitions</a></li>\n  <li><a HREF=\"#constants\">5.9 Constants</a></li>\n  <li><a HREF=\"#upcalls\">5.12 Upcalls</a></li>\n</dir>\n\n<h2><a NAME=\"intro\">Introduction</a></h2>\n\n<p>Version 4.1 is the latest release of <a\nHREF=\"http://www.cs.princeton.edu/software/lcc/\">lcc</a>, the ANSI C compiler described in\nour book <cite>A Retargetable C Compiler: Design and Implementation</cite>\n(Addison-Wesley, 1995, ISBN 0-8053-1670-1). This document summarizes the differences\nbetween the 4.1 code-generation interface and the 3.x interface described in Chap. 5 of <cite>A\nRetargetable C Compiler</cite>.</p>\n\n<p>Previous versions of lcc supported only three sizes of integers, two sizes of floats,\nand insisted that pointers fit in unsigned integers (see Sec. 5.1 of <cite>A Retargetable\nC Compiler</cite>). These assumptions simplified the compiler, and were suitable for\n32-bit architectures. But on 64-bit architectures, such as the DEC ALPHA, it's natural to\nhave four sizes of integers and perhaps three sizes of floats, and on 16-bit\narchitectures, 32-bit pointers don't fit in unsigned integers. Also, the 3.x constaints\nlimited the use of lcc's back ends for other languages, such as Java.</p>\n\n<p>Version 4.x removes all of these restrictions: It supports any number of sizes for\nintegers and floats, and the size of pointers need not be related to the size of any of\nthe integer types. The major changes in the code-generation interface are: \n\n<ul>\n  <li>The number of type suffixes has been reduced to 6.</li>\n  <li>Dag operators are composed of a generic operator, a type suffix, and a size.</li>\n  <li>Unsigned variants of several operators have been added.</li>\n  <li>Several interface functions have new signatures.</li>\n</ul>\n\n<p>In addition, version 4.x is written in ANSI C and uses the standard I/O library and\nother standard C functions.</p>\n\n<p>The sections below parallel the subsections of Chap. 5 of <cite>A Retargetable C\nCompiler</cite> and summarize the differences between the 3.x and 4.x code-generation\ninterface. Unaffected subsections are omitted. Page citations refer to pages in <cite>A\nRetargetable C Compiler</cite>.</p>\n\n<h2><a NAME=\"metrics\">5.1 Type Metrics</a></h2>\n\n<p>There are now 10 metrics in an interface record:</p>\n\n<pre>Metrics charmetric;\nMetrics shortmetric;\nMetrics intmetric;\nMetrics longmetric;\nMetrics longlongmetric;\nMetrics floatmetric;\nMetrics doublemetric;\nMetrics longdoublemetric;\nMetrics ptrmetric;\nMetrics structmetric;</pre>\n\n<p>Each of these specifies the size and alignment of the corresponding type. <code>ptrmetric</code>\ndescribes all pointers.</p>\n\n<h2><a NAME=\"symbols\">5.3 Symbols</a></h2>\n\n<p>The actual value of a constant is stored in the <code>u.c.v</code> field of a symbol,\nwhich holds a <code>Value</code>:</p>\n\n<pre>typedef union value {\n\tlong i;\n\tunsigned long u;\n\tlong double d;\n\tvoid *p;\n\tvoid (*g)(void);\n} Value;</pre>\n\n<p>The value is stored in the appropriate field according to its type, which is given by\nthe symbol's <code>type</code> field.</p>\n\n<h2><a NAME=\"operators\">5.5 Dag Operators</a></h2>\n\n<p>The <code>op</code> field a of <code>node</code> structure holds a dag operator, which\nconsists of a generic operator, a type suffix, and a size indicator. The type suffixes\nare:</p>\n\n<pre>enum {\n\tF=FLOAT,\n\tI=INT,\n\tU=UNSIGNED,\n\tP=POINTER,\n\tV=VOID,\n\tB=STRUCT\n};\n\n#define sizeop(n) ((n)&lt;&lt;10)</pre>\n\n<p>Given a generic operator <code>o</code>, a type suffix <code>t</code>, and a size <code>s</code>,\na type- and size-specific operator is formed by <code>o+t+sizeop(s)</code>. For example, <code>ADD+F+sizeop(4)</code>\nforms the operator <code>ADDF4</code>, which denotes the sum of two 4-byte floats.\nSimilarly, <code>ADD+F+sizeop(8)</code> forms <code>ADDF8</code>, which denotes 8-byte\nfloating addition. In the 3.x code-generation interface, <code>ADDF</code> and <code>ADDD</code>\ndenoted these operations. There was no size indicator in the 3.x operators because the\ntype suffix supplied both a type and a size.</p>\n\n<p>Table 5.1 lists each generic operator, its valid type suffixes, and the number of <code>kids</code>\nand <code>syms</code> that it uses; multiple values for <code>kids</code> indicate\ntype-specific variants. The notations in the <strong>syms</strong> column give the number\nof <code>syms</code> values and a one-letter code that suggests their uses: 1V indicates\nthat <code>syms[0]</code> points to a symbol for a variable, 1C indicates that <code>syms[0]</code>\nis a constant, and 1L indicates that <code>syms[0]</code> is a label. For 1S, <code>syms[0]</code>\nis a constant whose value is a size in bytes; 2S adds <code>syms[1]</code>, which is a\nconstant whose value is an alignment. For most operators, the type suffix and size\nindicator denote the type and size of operation to perform and the type and size of the\nresult.</p>\n\n<table WIDTH=\"100%\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\">\n  <tr>\n    <td COLSPAN=\"6\" ALIGN=\"CENTER\"><strong>Table 5.1<img SRC=\"/~drh/resources/dot_clear.gif\"\n    ALT=\"|\" WIDTH=\"18\" HEIGHT=\"1\">Node Operators.</strong></td>\n  </tr>\n  <tr>\n    <td><strong>syms</strong></td>\n    <td><strong>kids</strong></td>\n    <td><strong>Operator</strong></td>\n    <td><strong>Type Suffixes</strong></td>\n    <td><strong>Sizes</strong></td>\n    <td><strong>Operation</strong></td>\n  </tr>\n  <tr>\n    <td>1V</td>\n    <td>0</td>\n    <td><code>ADDRF</code></td>\n    <td><code>...P..</code></td>\n    <td>p</td>\n    <td>address of a parameter</td>\n  </tr>\n  <tr>\n    <td>1V</td>\n    <td>0</td>\n    <td><code>ADDRG</code></td>\n    <td><code>...P..</code></td>\n    <td>p</td>\n    <td>address of a global</td>\n  </tr>\n  <tr>\n    <td>1V</td>\n    <td>0</td>\n    <td><code>ADDRL</code></td>\n    <td><code>...P..</code></td>\n    <td>p</td>\n    <td>address of a local</td>\n  </tr>\n  <tr>\n    <td>1C</td>\n    <td>0</td>\n    <td><code>CNST</code></td>\n    <td><code>FIUP..</code></td>\n    <td>fdx csilh p</td>\n    <td>constant</td>\n  </tr>\n  <tr ALIGN=\"LEFT\" VALIGN=\"TOP\">\n    <td><img SRC=\"/~drh/resources/dot_clear.gif\" ALT=\"|\" WIDTH=\"1\" HEIGHT=\"12\"></td>\n    <td></td>\n    <td></td>\n    <td></td>\n    <td></td>\n    <td></td>\n  </tr>\n  <tr>\n    <td></td>\n    <td>1</td>\n    <td><code>BCOM</code></td>\n    <td><code>.IU...</code></td>\n    <td>ilh</td>\n    <td>bitwise complement</td>\n  </tr>\n  <tr>\n    <td>1S</td>\n    <td>1</td>\n    <td><code>CVF</code></td>\n    <td><code>FI....</code></td>\n    <td>fdx ilh</td>\n    <td>convert from float</td>\n  </tr>\n  <tr>\n    <td>1S</td>\n    <td>1</td>\n    <td><code>CVI</code></td>\n    <td><code>FIU...</code></td>\n    <td>fdx csilh csilhp</td>\n    <td>convert from signed integer</td>\n  </tr>\n  <tr>\n    <td>1S</td>\n    <td>1</td>\n    <td><code>CVP</code></td>\n    <td><code>..U..</code></td>\n    <td>p</td>\n    <td>convert from pointer</td>\n  </tr>\n  <tr>\n    <td>1S</td>\n    <td>1</td>\n    <td><code>CVU</code></td>\n    <td><code>.IUP..</code></td>\n    <td>csilh p</td>\n    <td>convert from unsigned integer</td>\n  </tr>\n  <tr>\n    <td></td>\n    <td>1</td>\n    <td><code>INDIR</code></td>\n    <td><code>FIUP.B</code></td>\n    <td>fdx csilh p</td>\n    <td>fetch</td>\n  </tr>\n  <tr>\n    <td></td>\n    <td>1</td>\n    <td><code>NEG</code></td>\n    <td><code>FI....</code></td>\n    <td>fdx ilh</td>\n    <td>negation</td>\n  </tr>\n  <tr>\n    <td><img SRC=\"/~drh/resources/dot_clear.gif\" ALT=\"|\" WIDTH=\"1\" HEIGHT=\"12\"></td>\n    <td></td>\n    <td></td>\n    <td></td>\n    <td></td>\n    <td></td>\n  </tr>\n  <tr>\n    <td></td>\n    <td>2</td>\n    <td><code>ADD</code></td>\n    <td><code>FIUP..</code></td>\n    <td>fdx ilh ilhp p</td>\n    <td>addition</td>\n  </tr>\n  <tr>\n    <td></td>\n    <td>2</td>\n    <td><code>BAND</code></td>\n    <td><code>.IU...</code></td>\n    <td>ilh</td>\n    <td>bitwise AND</td>\n  </tr>\n  <tr>\n    <td></td>\n    <td>2</td>\n    <td><code>BOR</code></td>\n    <td><code>.IU...</code></td>\n    <td>ilh</td>\n    <td>bitwise inclusive OR</td>\n  </tr>\n  <tr>\n    <td></td>\n    <td>2</td>\n    <td><code>BXOR</code></td>\n    <td><code>.IU...</code></td>\n    <td>ilh</td>\n    <td>bitwise exclusive OR</td>\n  </tr>\n  <tr>\n    <td></td>\n    <td>2</td>\n    <td><code>DIV</code></td>\n    <td><code>FIU...</code></td>\n    <td>fdx ilh</td>\n    <td>division</td>\n  </tr>\n  <tr>\n    <td></td>\n    <td>2</td>\n    <td><code>LSH</code></td>\n    <td><code>.IU...</code></td>\n    <td>ilh</td>\n    <td>left shift</td>\n  </tr>\n  <tr>\n    <td></td>\n    <td>2</td>\n    <td><code>MOD</code></td>\n    <td><code>.IU...</code></td>\n    <td>ilh</td>\n    <td>modulus</td>\n  </tr>\n  <tr>\n    <td></td>\n    <td>2</td>\n    <td><code>MUL</code></td>\n    <td><code>FIU...</code></td>\n    <td>fdx ilh</td>\n    <td>multiplication</td>\n  </tr>\n  <tr>\n    <td></td>\n    <td>2</td>\n    <td><code>RSH</code></td>\n    <td><code>.IU...</code></td>\n    <td>ilh</td>\n    <td>right shift</td>\n  </tr>\n  <tr>\n    <td></td>\n    <td>2</td>\n    <td><code>SUB</code></td>\n    <td><code>FIUP..</code></td>\n    <td>fdx ilh ilhp p</td>\n    <td>subtraction</td>\n  </tr>\n  <tr>\n    <td><img SRC=\"/~drh/resources/dot_clear.gif\" ALT=\"|\" WIDTH=\"1\" HEIGHT=\"12\"></td>\n    <td></td>\n    <td></td>\n    <td></td>\n    <td></td>\n    <td></td>\n  </tr>\n  <tr>\n    <td>2S</td>\n    <td>2</td>\n    <td><code>ASGN</code></td>\n    <td><code>FIUP.B</code></td>\n    <td>fdx csilh p</td>\n    <td>assignment</td>\n  </tr>\n  <tr>\n    <td>1L</td>\n    <td>2</td>\n    <td><code>EQ</code></td>\n    <td><code>FIU...</code></td>\n    <td>fdx ilh ilhp</td>\n    <td>jump if equal</td>\n  </tr>\n  <tr>\n    <td>1L</td>\n    <td>2</td>\n    <td><code>GE</code></td>\n    <td><code>FIU...</code></td>\n    <td>fdx ilh ilhp</td>\n    <td>jump if greater than or equal</td>\n  </tr>\n  <tr>\n    <td>1L</td>\n    <td>2</td>\n    <td><code>GT</code></td>\n    <td><code>FIU...</code></td>\n    <td>fdx ilh ilhp</td>\n    <td>jump if greater than</td>\n  </tr>\n  <tr>\n    <td>1L</td>\n    <td>2</td>\n    <td><code>LE</code></td>\n    <td><code>FIU...</code></td>\n    <td>fdx ilh ilhp</td>\n    <td>jump if less than or equal</td>\n  </tr>\n  <tr>\n    <td>1L</td>\n    <td>2</td>\n    <td><code>LT</code></td>\n    <td><code>FIU...</code></td>\n    <td>fdx ilh ilhp</td>\n    <td>jump if less than</td>\n  </tr>\n  <tr>\n    <td>1L</td>\n    <td>2</td>\n    <td><code>NE</code></td>\n    <td><code>FIU...</code></td>\n    <td>fdx ilh ilhp</td>\n    <td>jump if not equal</td>\n  </tr>\n  <tr>\n    <td></td>\n    <td></td>\n    <td></td>\n    <td></td>\n    <td></td>\n    <td></td>\n  </tr>\n  <tr>\n    <td>2S</td>\n    <td>1</td>\n    <td><code>ARG</code></td>\n    <td><code>FIUP.B</code></td>\n    <td>fdx ilh p</td>\n    <td>argument</td>\n  </tr>\n  <tr>\n    <td>1</td>\n    <td>1 or 2</td>\n    <td><code>CALL</code></td>\n    <td><code>FIUPVB</code></td>\n    <td>fdx ilh p</td>\n    <td>function call</td>\n  </tr>\n  <tr>\n    <td></td>\n    <td>1</td>\n    <td><code>RET</code></td>\n    <td><code>FIUPV.</code></td>\n    <td>fdx ilh p</td>\n    <td>return from function</td>\n  </tr>\n  <tr>\n    <td><img SRC=\"/~drh/resources/dot_clear.gif\" ALT=\"|\" WIDTH=\"1\" HEIGHT=\"12\"></td>\n    <td></td>\n    <td></td>\n    <td></td>\n    <td></td>\n    <td></td>\n  </tr>\n  <tr>\n    <td></td>\n    <td>1</td>\n    <td><code>JUMP</code></td>\n    <td><code>....V.</code></td>\n    <td></td>\n    <td>unconditional jump</td>\n  </tr>\n  <tr>\n    <td>1L</td>\n    <td>0</td>\n    <td><code>LABEL</code></td>\n    <td><code>....V.</code></td>\n    <td></td>\n    <td>label definition</td>\n  </tr>\n</table>\n\n<p>The entries in the <strong>Sizes</strong> column indicate sizes of the operators that\nback ends must implement. Letters denote the size of float (f), double (d), long double\n(x), character (c), short integer (s), integer (i), long integer (l), &quot;long\nlong&quot; integer (h) , and pointer (p). These sizes are separated into sets for each\ntype suffix, except that a single set is used for both I and U when the set for I is\nidentical to the set for U.</p>\n\n<p>The actual values for the size indicators, fdxcsilhp, depend on the target. A\nspecification like <code>ADDF</code>f denotes the operator <code>ADD+F+sizeop(</code>f<code>)</code>,\nwhere &quot;f&quot; is replaced by a target-dependent value, e.g., <code>ADDF4</code> and <code>ADDF8</code>.\nFor example, back ends must implement the following <code>CVI</code> and <code>MUL</code>\noperators.</p>\n\n<blockquote>\n  <p><code>CVIF</code>f <code>CVIF</code>d <code>CVIF</code>x<br>\n  <code>CVII</code>c <code>CVII</code>s <code>CVII</code>i <code>CVII</code>l <code>CVII</code>h<br>\n  <code>CVIU</code>c <code>CVIU</code>s <code>CVIU</code>i <code>CVIU</code>l <code>CVIU</code>h\n  <code>CVIU</code>p<br>\n  <br>\n  <code>MULF</code>f <code>MULF</code>d <code>MULF</code>x<br>\n  <code>MULI</code>i <code>MULI</code>l <code>MULI</code>h<br>\n  <code>MULU</code>i <code>MULU</code>l <code>MULU</code>h</p>\n</blockquote>\n\n<p>On most platforms, there are fewer than three sizes of floats and six sizes of\nintegers, and pointers are usually the same size as one of the integers. And lcc doesn't\nsupport the &quot;long long&quot; type, so h is not currently used. So the set of\nplatform-specific operators is usually smaller than the list above suggests. For example,\nthe X86, SPARC, and MIPS back ends implement the following <code>CVI</code> and <code>MUL</code>\noperators.</p>\n\n<blockquote>\n  <p><code>CVIF</code>4 <code>CVIF</code>8<br>\n  <code>CVII</code>1 <code>CVII</code>2 <code>CVII</code>4<br>\n  <code>CVIU</code>1 <code>CVIU</code>2 <code>CVIU</code>4 <br>\n  <br>\n  <code>MULF</code>4 <code>MULF</code>8<br>\n  <code>MULI</code>4<br>\n  <code>MULU</code>4</p>\n</blockquote>\n\n<p>The set of operators is thus target-dependent; for example, <code>ADDI8</code> appears\nonly if the target supports an 8-byte integer type. <a\nHREF=\"ftp://ftp.cs.princeton.edu/pub/packages/lcc/contrib/ops.c\"><code>ops.c</code></a> is\na program that, given a set of sizes, prints the required operators and their values,\ne.g.,</p>\n\n<blockquote>\n  <pre>% <em>ops c=1 s=2 i=4 l=4 h=4 f=4 d=8 x=8 p=4</em>\n...\n CVIF4=4225 CVIF8=8321\n CVII1=1157 CVII2=2181 CVII4=4229\n CVIU1=1158 CVIU2=2182 CVIU4=4230\n...\n MULF4=4561 MULF8=8657\n MULI4=4565\n MULU4=4566\n...\n131 operators</pre>\n</blockquote>\n\n<p>The type suffix for a conversion operator denotes the type of the result and the size\nindicator gives the size of the result. For example, <code>CVUI4</code> converts an\nunsigned (<code>U</code>) to a 4-byte signed integer (<code>I4</code>). The <code>syms[0]</code>\nfield points to a symbol-table entry for a integer constant that gives the size of the\nsource operand. For example, if <code>syms[0]</code> in a <code>CVUI4</code> points to a\nsymbol-table entry for 2, the conversion widens a 2-byte unsigned integer to a 4-byte\nsigned integer. Conversions that widen unsigned integers zero-extend; those that widen\nsigned integers sign-extend.</p>\n\n<p>The front end composes conversions between types <em>T</em><sub>1</sub> and <em>T</em><sub>2</sub>\nby widening <em>T</em><sub>1</sub> to it's &quot;supertype&quot;, if necessary, converting\nthat result to <em>T</em><sub>2</sub>'s supertype, then narrowing the result to <em>T</em><sub>2</sub>,\nif necessary. The following table lists the supertypes; omitted entries are their own\nsupertypes.</p>\n\n<blockquote>\n  <table BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\">\n    <tr>\n      <td><strong>Type</strong></td>\n      <td><img SRC=\"/~drh/resources/dot_clear.gif\" ALT=\"|\" WIDTH=\"24\" HEIGHT=\"1\"></td>\n      <td><strong>Supertype</strong></td>\n    </tr>\n    <tr>\n      <td>signed char</td>\n      <td></td>\n      <td>int</td>\n    </tr>\n    <tr>\n      <td>signed short</td>\n      <td></td>\n      <td>int</td>\n    </tr>\n    <tr ALIGN=\"LEFT\" VALIGN=\"TOP\">\n      <td>unsigned char</td>\n      <td></td>\n      <td>int, if sizeof (char) &lt; sizeof (int)<br>\n      unsigned, otherwise</td>\n    </tr>\n    <tr ALIGN=\"LEFT\" VALIGN=\"TOP\">\n      <td>unsigned short</td>\n      <td></td>\n      <td>int, if sizeof (short) &lt; sizeof (int)<br>\n      unsigned, otherwise</td>\n    </tr>\n    <tr ALIGN=\"LEFT\" VALIGN=\"TOP\">\n      <td>void *</td>\n      <td></td>\n      <td>an unsigned type as large as a pointer</td>\n    </tr>\n  </table>\n</blockquote>\n\n<p>Pointers are converted to an unsigned type of the same size, even when that type is not\none of the integer types.</p>\n\n<p>For example, the front end converts a signed short to a float by first converting it to\nan int and then to a float. It converts an unsigned short to an int with a single <code>CVUI</code>i\nconversion, when shorts are smaller than ints.</p>\n\n<p>There are now signed and unsigned variants of <code>ASGN</code>, <code>INDIR</code>, <code>BCOM</code>,\n<code>BOR</code>, <code>BXOR</code>, <code>BAND</code>, <code>ARG</code>, <code>CALL</code>,\nand <code>RET</code> to simplify code generation on platforms that use different\ninstructions or register set for signed and unsigned operations. Likewise there are now\npointer variants of <code>ASGN</code>, <code>INDIR</code>, <code>ARG</code>, <code>CALL</code>,\nand <code>RET</code>.</p>\n\n<h2><a NAME=\"flags\">5.6 Interface Flags</a></h2>\n\n<pre>unsigned unsigned_char:1;</pre>\n\n<p>tells the front end whether plain characters are signed or unsigned. If it's zero, char\nis a signed type; otherwise, char is an unsigned type.</p>\n\n<p>All the interface flags can be set by command-line options, e.g., <code>-Wf-unsigned_char=1</code>\ncauses plain characters to be unsigned.</p>\n\n<h2><a NAME=\"definitions\">5.8 Definitions</a></h2>\n\n<p>The front end announces local variables by calling</p>\n\n<pre>void (*local)(Symbol);</pre>\n\n<p>It announces temporaries likewise; these have the symbol's <code>temporary</code> flag\nset, which indicates that the symbol will be used only in the next call to <code>gen</code>.\nIf a temporary's <code>u.t.cse</code> field is nonnull, it points to the node that\ncomputes the value assigned to the temporary; see page 346.</p>\n\n<p>The front end calls</p>\n\n<pre>void (*address)(Symbol p, Symbol q, long n);</pre>\n\n<p>to initialize <code>q</code> to a symbol that represents an address of the form <em>x</em>+<code>n</code>,\nwhere <em>x</em> is the address represented by <code>p</code> and the long integer <code>n</code>\nis positive or negative.</p>\n\n<h2><a NAME=\"constants\">5.9 Constants</a></h2>\n\n<p>The interface function</p>\n\n<pre>void (*defconst)(int suffix, int size, Value v);</pre>\n\n<p>initializes constants. defconst emits directives to define a cell and initialize it to\na constant value. v is the constant value, suffix identifies the type of the value, and\nsize is the size of the value in bytes. The value of suffix indicates which field of v\nholds the value, as shown in the following table.</p>\n\n<blockquote>\n  <table BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n    <tr>\n      <td><strong>suffix</strong></td>\n      <td><img SRC=\"/~drh/resources/dot_clear.gif\" ALT=\"|\" WIDTH=\"24\" HEIGHT=\"1\"></td>\n      <td><strong>v Field</strong></td>\n      <td><img SRC=\"/~drh/resources/dot_clear.gif\" ALT=\"|\" WIDTH=\"24\" HEIGHT=\"1\"></td>\n      <td><strong>size</strong></td>\n    </tr>\n    <tr>\n      <td><code>F</code></td>\n      <td></td>\n      <td><code>v.d</code></td>\n      <td></td>\n      <td>float, double, long double</td>\n    </tr>\n    <tr>\n      <td><code>I</code></td>\n      <td></td>\n      <td><code>v.i</code></td>\n      <td></td>\n      <td>signed char, signed short, signed int, signed long</td>\n    </tr>\n    <tr>\n      <td><code>U</code></td>\n      <td></td>\n      <td><code>v.u</code></td>\n      <td></td>\n      <td>unsigned char, unsigned short, unsigned int, unsigned long</td>\n    </tr>\n    <tr>\n      <td><code>P</code></td>\n      <td></td>\n      <td><code>v.p</code></td>\n      <td></td>\n      <td>void *</td>\n    </tr>\n  </table>\n</blockquote>\n\n<p><code>defconst</code> must narrow <code>v.</code>x when <code>size</code> is less than <code>sizeof</code>\n<code>v.</code>x; e.g., to emit an unsigned char, <code>defconst</code> should emit <code>(unsigned\nchar)v.i</code>.</p>\n\n<h2><a NAME=\"upcalls\">5.12 Upcalls</a></h2>\n\n<p>lcc 4.x uses standard I/O and its I/O functions have been changed accordingly. lcc\nreads input from the standard input, emits code to the standard output, and writes\ndiagnostics to the standard error output. It uses <code>freopen</code> to redirect these\nstreams to explicit files, when necessary.</p>\n\n<p><code>bp</code>, <code>outflush</code>, and <code>outs</code> have been eliminated.</p>\n\n<pre>extern void fprint(FILE *f, const char *fmt, ...);\nextern void  print(const char *fmt, ...);</pre>\n\n<p>print formatted data to file <code>f</code> (<code>fprint</code>) or the standard\noutput (<code>print</code>). These functions are like standard C's <code>printf</code> and\n<code>fprintf</code>, but support only some of the standard conversion specifiers and do\nnot support flags, precision, and field-width specifications. They support the following\nnew conversion specifiers in addition to those described on page 99.</p>\n\n<blockquote>\n  <table BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\">\n    <tr>\n      <td><strong>Specifiers</strong></td>\n      <td><img SRC=\"/~drh/resources/dot_clear.gif\" ALT=\"|\" WIDTH=\"24\" HEIGHT=\"1\"></td>\n      <td><strong>Corresponding printf Specifiers</strong></td>\n    </tr>\n    <tr>\n      <td><code>%c</code></td>\n      <td></td>\n      <td><code>%c</code></td>\n    </tr>\n    <tr>\n      <td><code>%d %D</code></td>\n      <td></td>\n      <td><code>%d %ld</code></td>\n    </tr>\n    <tr>\n      <td><code>%u %U</code></td>\n      <td></td>\n      <td><code>%u %lu</code></td>\n    </tr>\n    <tr>\n      <td><code>%x %X</code></td>\n      <td></td>\n      <td><code>%x %lx</code></td>\n    </tr>\n    <tr>\n      <td><code>%f %e %g</code></td>\n      <td></td>\n      <td><code>%e %f %g</code></td>\n    </tr>\n    <tr ALIGN=\"LEFT\" VALIGN=\"TOP\">\n      <td><code>%p</code></td>\n      <td></td>\n      <td>Converts the corresponding void * argument to unsigned long and prints it with the <code>printf</code>\n      <code>%#x</code> specifier or just <code>%x</code> when the argument is null.</td>\n    </tr>\n    <tr ALIGN=\"LEFT\" VALIGN=\"TOP\">\n      <td><code>%I</code></td>\n      <td></td>\n      <td>Prints the number of spaces given by the corresponding argument.</td>\n    </tr>\n  </table>\n</blockquote>\n\n<pre>#define generic(op)  ((op)&amp;0x3F0)\n#define specific(op) ((op)&amp;0x3FF)</pre>\n\n<p><code>generic(op)</code> returns the generic variant of <code>op</code>; that is,\nwithout its type suffix and size indicator. <code>specific(op)</code> returns the\ntype-specific variant of <code>op</code>; that is, without its size indicator.</p>\n\n<p><code>newconst</code> has been replaced by</p>\n\n<pre>extern Symbol intconst(int n);</pre>\n\n<p>which installs the integer constant <code>n</code> in the symbol table, if necessary,\nand returns a pointer to the symbol-table entry.</p>\n\n<hr>\n\n<address>\n  <a HREF=\"http://www.research.microsoft.com/~cwfraser/\">Chris Fraser</a> / <a\n  HREF=\"mailto:cwfraser@microsoft.com\">cwfraser@microsoft.com</a><br>\n  <a HREF=\"http://www.research.microsoft.com/~drh/\">David Hanson</a> / <a\n  HREF=\"mailto:drh@microsoft.com\">drh@microsoft.com</a><br>\n  $Revision: 145 $ $Date: 2001-10-17 16:53:10 -0500 (Wed, 17 Oct 2001) $ \n</address>\n</body>\n</html>\n"
  },
  {
    "path": "lcc/doc/bprint.1",
    "content": ".\\\" $Id: bprint.1 145 2001-10-17 21:53:10Z timo $\n.TH BPRINT 1 \"local \\- $Date: 2001-10-17 16:53:10 -0500 (Wed, 17 Oct 2001) $\"\n.SH NAME\nbprint \\- expression profiler\n.SH SYNOPSIS\n.B bprint\n[\n.I option ...\n]\n[\n.I file ...\n]\n.SH DESCRIPTION\n.I bprint\nproduces on the standard output a listing of the programs compiled by\n.I lcc\nwith the\n.B \\-b\noption.\nExecuting an\n.B a.out\nso compiled appends profiling data to\n.BR prof.out .\nThe first token of each expression in the listing is preceded\nby the number of times it was executed\nenclosed in angle brackets as determined from the data in\n.BR prof.out .\n.I bprint\ninterprets the following options.\n.TP\n.B \\-c\nCompress the\n.B prof.out\nfile, which otherwise grows with every execution of\n.BR a.out .\n.TP\n.B \\-b\nPrint an annotated listing as described above.\n.TP\n.B \\-n\nInclude line numbers in the listing.\n.TP\n.B \\-f\nPrint only the number of invocations of each function.\nA second\n.B \\-f\nsummarizes call sites instead of callers.\n.TP\n.BI \\-I \\*Sdir\nspecifies additional directories in which to seek\nfiles given in\n.B prof.out\nthat do not begin with `/'.\n.PP\nIf any file names are given, only the requested data for those files are printed\nin the order presented.\nIf no options are given,\n.B \\-b\nis assumed.\n.SH FILES\n.PP\n.ta \\w'$LCCDIR/liblcc.{a,lib}XX'u\n.nf\nprof.out\tprofiling data\n$LCCDIR/liblcc.{a,lib}\t\\fIlcc\\fP-specific library\n.SH \"SEE ALSO\"\n.IR lcc (1), \n.IR prof (1)\n.SH BUGS\nMacros and comments can confuse\n.I bprint\nbecause it uses post-expansion source coordinates\nto annotate pre-expansion source files.\nIf\n.I bprint\nsees that it's about to print a statement count\n.I inside\na number or identifier, it moves the count to just\n.I before\nthe token.\n.PP\nCan't cope with an ill-formed\n.BR prof.out .\n"
  },
  {
    "path": "lcc/doc/install.html",
    "content": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n<html>\n\n<head>\n<link HREF=\"mailto:drh@cs.princeton.edu\" REV=\"made\" TITLE=\"David R. Hanson\">\n<title>Installing lcc</title>\n</head>\n\n<body>\n\n<h1>Installing lcc</h1>\n\n<p ALIGN=\"LEFT\"><strong><a HREF=\"http://www.research.microsoft.com/~cwfraser/\">Christopher\nW. Fraser</a> and <a HREF=\"http://www.research.microsoft.com/~drh/\">David R. Hanson</a>, <a\nHREF=\"http://www.research.microsoft.com/\">Microsoft Research</a></strong></p>\n\n<h2>Contents</h2>\n\n<dir>\n  <li><a HREF=\"#intro\">Introduction</a></li>\n  <li><a HREF=\"#unix\">Installation on UNIX</a></li>\n  <li><a HREF=\"#driver\">Building the Driver</a></li>\n  <li><a HREF=\"#rcc\">Building the Compiler and Accessories</a></li>\n  <li><a HREF=\"#win32\">Installation on Windows NT 4.0 and Windows 95/98</a></li>\n  <li><a HREF=\"#bugs\">Reporting Bugs</a></li>\n  <li><a HREF=\"#mailinglist\">Keeping in Touch</a></li>\n</dir>\n\n<h2><a NAME=\"intro\">Introduction</a></h2>\n\n<p><a HREF=\"http://www.cs.princeton.edu/software/lcc/\">lcc</a> is the ANSI C compiler\ndescribed in our book <cite>A Retargetable C Compiler: Design and Implementation</cite>\n(Addison-Wesley, 1995, ISBN 0-8053-1670-1).</p>\n\n<p>If you're installing lcc on a UNIX system, read the remainder of this section and\ncontinue with the next section. If you're installing lcc on a Windows NT 4.0 or Windows\n95/98 system, and you intend only to <u>use</u> lcc, you can run the <a\nhref=\"ftp://ftp.cs.princeton.edu/pub/packages/lcc/lcc41.exe\">InstallShield executable</a>,\nwhich installs the binaries and the documentation. If you want to <u>modify</u> lcc or <u>rebuild</u>\nit from the source files, you need the <a\nhref=\"ftp://ftp.cs.princeton.edu/packages/lcc/lcc41.zip\">complete distribution</a>, and\nyou should read the rest of the section, the following three sections, and the <a\nHREF=\"#win32\">Windows NT/95/98</a> section.</p>\n\n<p>Extract the distribution into its own directory. All non-absolute paths below are\nrelative to this directory. The distribution holds the following subdirectories.</p>\n\n<blockquote>\n  <table BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\" WIDTH=\"80%\">\n    <tr>\n      <td><a HREF=\"../src\"><code>src</code></a></td>\n      <td></td>\n      <td>source code</td>\n    </tr>\n    <tr>\n      <td><a HREF=\"../etc\"><code>etc</code></a></td>\n      <td></td>\n      <td>driver, accessories</td>\n    </tr>\n    <tr>\n      <td><a HREF=\"../lib\"><code>lib</code></a></td>\n      <td></td>\n      <td>runtime library source code</td>\n    </tr>\n    <tr>\n      <td><a HREF=\"../cpp\"><code>cpp</code></a></td>\n      <td></td>\n      <td>preprocessor source code</td>\n    </tr>\n    <tr>\n      <td><a HREF=\"../lburg\"><code>lburg</code></a></td>\n      <td></td>\n      <td>code-generator generator source code</td>\n    </tr>\n    <tr>\n      <td><a HREF=\"../doc\"><code>doc</code></a></td>\n      <td></td>\n      <td>this document, man pages</td>\n    </tr>\n    <tr>\n      <td><code><a HREF=\"../include\">include</a>/*/*</code></td>\n      <td></td>\n      <td>include files</td>\n    </tr>\n    <tr>\n      <td><a HREF=\"../tst\"><code>tst</code></a></td>\n      <td></td>\n      <td>test suite</td>\n    </tr>\n    <tr>\n      <td><code><a HREF=\"../alpha\">alpha</a>/*/tst</code></td>\n      <td></td>\n      <td>ALPHA test outputs</td>\n    </tr>\n    <tr>\n      <td><code><a HREF=\"../mips\">mips</a>/*/tst</code></td>\n      <td></td>\n      <td>MIPS test outputs</td>\n    </tr>\n    <tr>\n      <td><code><a HREF=\"../sparc\">sparc</a>/*/tst</code></td>\n      <td></td>\n      <td>SPARC test outputs</td>\n    </tr>\n    <tr>\n      <td><code><a HREF=\"../x86\">x86</a>/*/tst</code></td>\n      <td></td>\n      <td>X86 test outputs</td>\n    </tr>\n  </table>\n</blockquote>\n\n<p><code>doc/install.html</code> is the HTML file for this document. <a HREF=\"4.html\"><code>doc/4.html</code></a>\ndescribes the internal differences between lcc 3.x and 4.1.</p>\n\n<p>The installation makefile is designed so that lcc can be installed from a read-only\nfile system or directory, which is common in networked environments, so the distribution\ncan be unloaded on a central file server. <strong>You will need an existing ANSI/ISO C\ncompiler to build and install lcc.</strong></p>\n\n<h2><a NAME=\"unix\">Installation on UNIX</a></h2>\n\n<p>The compilation components (the preprocessor, include files, and compiler proper, etc.)\nare installed in a single <em>build directory</em>. On multi-platform systems supported by\na central file server, it's common to store the build directory in a location specific to\nthe platform and to the version of lcc, and to point a symbolic link to this location. For\nexample,</p>\n\n<blockquote>\n  <pre>% ln -s /usr/local/lib/lcc-4.1/sparc-solaris /usr/local/lib/lcc</pre>\n</blockquote>\n\n<p>points <code>/usr/local/lib/lcc</code> to a build directory for lcc version 4.1 on the\nSPARC under Solaris. Links into <code>/usr/local/lib</code> are created for the programs <code>lcc</code>\nand <code>bprint</code>. Thus, a new distribution can be installed by building it in its\nown build directory and changing one symbolic link to point to that directory. If these\nconventions or their equivalents are followed, the host-specific parts of the driver\nprogram, <code>lcc</code>, can be used unmodified.</p>\n\n<p>Installation on a UNIX system involves the following steps. Below, the build directory\nis referred to as <code>BUILDDIR</code>. \n\n<ol>\n  <li>Create the build directory, using a version- and platform-specific naming convention as\n    suggested above, and record the name of this directory in the <code>BUILDDIR</code>\n    environment variable:<blockquote>\n      <pre>% setenv BUILDDIR /usr/local/lib/lcc-4.1/sparc-solaris\n% mkdir -p $BUILDDIR</pre>\n    </blockquote>\n    <p>Here and below, commands assume the C shell. Also, you'll need a version of <code>mkdir</code>\n    that supports the <code>-p</code> option, which creates intermediate directories as\n    necessary.</p>\n  </li>\n  <li>Copy the man pages to the repository for local man pages, e.g.,<blockquote>\n      <pre>% cp doc/*.1 /usr/local/man/man1</pre>\n    </blockquote>\n    <p>Some users copy the man pages to the build directory and create the appropriate\n    symbolic links, e.g., </p>\n    <blockquote>\n      <pre>% cp doc/*.1 $BUILDDIR\n% ln -s $BUILDDIR/*.1 /usr/local/man/man1</pre>\n    </blockquote>\n  </li>\n  <li>Platform-specific include files are in directories named <code>include/</code><em>target</em><code>/</code><em>os</em>.\n    Create the include directory in the build directory, and copy the include hierarchy for\n    your platform to this directory, e.g.,<blockquote>\n      <pre>% mkdir $BUILDDIR/include\n% cp -p -R include/sparc/solaris/* $BUILDDIR/include</pre>\n    </blockquote>\n    <p>Again, some users create a symbolic link to the appropriate directory in the\n    distribution instead of copying the include files. For example, at Princeton, the\n    distributions are stored under <code>/proj/pkg/lcc</code>, so the included files are\n    &quot;installed&quot; by creating one symbolic link: </p>\n    <blockquote>\n      <pre>% ln -s /proj/pkg/lcc/4.1/include/sparc/solaris $BUILDDIR/include</pre>\n    </blockquote>\n    <p>If you're installing lcc on Linux, you <em>must</em> also plant a symbolic link named <code>gcc</code>\n    to gcc's library directory, because lcc uses gcc's C preprocessor and most of gcc's header\n    files:</p>\n    <blockquote>\n      <pre>% ln -s /usr/lib/gcc-lib/i486-linux/2.7.2.2 $BUILDDIR/gcc</pre>\n    </blockquote>\n    <p>The library directory shown above may be different on your Linux machine; to determine\n    the correct directory, browse <code>/usr/lib/gcc-lib</code>, or execute</p>\n    <blockquote>\n      <pre>% cc -v tst/8q.c</pre>\n    </blockquote>\n    <p>and examine the diagnostic output. Make sure that <code>$BUILDDIR/gcc/cpp</code> and <code>$BUILDDIR/gcc/include</code>\n    point to, respectively, gcc's C preprocessor and header files. On Linux, lcc looks for\n    include files in <code>$BUILDDIR/include</code>, <code>$BUILDDIR/gcc/include</code>, and <code>/usr/include</code>,\n    in that order; see <a HREF=\"#driver\"><em>Building the Driver</em></a> and <a\n    href=\"../etc/linux.c\"><code>etc/linux.c</code></a> for details.</p>\n  </li>\n  <li>The <a HREF=\"../makefile\"><code>makefile</code></a> includes the file named by the <code>CUSTOM</code>\n    macro; the default is <code>custom.mk</code>, and an empty <code>custom.mk</code> is\n    included in the distribution. If desired, prepare a site-specification customization file\n    and define <code>CUSTOM</code> to the path of that file when invoking make in steps 5 and\n    6, e.g.,<blockquote>\n      <pre>make CUSTOM=/users/drh/solaris.mk</pre>\n    </blockquote>\n    <p>You can, for example, use customization files to record site-specific values for macros\n    instead of using environment variables, and to record targets for the steps in this list.</p>\n  </li>\n  <li>Build the host-specific driver, creating a custom host-specific part, if necessary. See <a\n    HREF=\"#driver\"><em>Building the Driver</em></a>.</li>\n  <li>Build the preprocessor, compiler proper, library, and other accessories. See <a\n    HREF=\"#rcc\"><em>Building the Compiler</em></a>.</li>\n  <li>Plant symbolic links to the build directory and to the installed programs, e.g.,<blockquote>\n      <pre>% ln -s $BUILDDIR /usr/local/lib/lcc\n% ln -s /usr/local/lib/{lcc,bprint} /usr/local/bin</pre>\n    </blockquote>\n    <p>Some users copy <code>bprint</code> and <code>lcc</code> into <code>/usr/local/bin</code>\n    instead of creating symbolic links. The advantange of creating the links for <code>lcc</code>\n    and <code>bprint</code> as shown is that, once established, they point indirectly to\n    whatever <code>/usr/local/lib/lcc</code> points to; installing a new version of lcc, say,\n    4.2, can be done by changing <code>/usr/local/lib/lcc</code> to point to the 4.2 build\n    directory.</p>\n  </li>\n</ol>\n\n<h2><a NAME=\"driver\">Building the Driver</a></h2>\n\n<p>The preprocessor, compiler, assembler, and loader are invoked by a driver program, <code>lcc</code>,\nwhich is similar to <code>cc</code> on most systems. It's described in the man page <code>doc/lcc.1</code>.\nThe driver is built by combining the host-independent part, <a href=\"../etc/lcc.c\"><code>etc/lcc.c</code></a>,\nwith a small host-specific part. Distributed host-specific parts are named <code>etc/</code><em>os</em><code>.c</code>,\nwhere <em>os</em> is the name of the operating system for the host on which <code>lcc</code>\nis being installed. If you're following the installations conventions described above, you\ncan probably use one of the host-specific parts unmodified; otherwise, pick one that is\nclosely related to your platform, copy it to <em>whatever</em><code>.c</code>, and edit it\nas described below. You should not have to edit <code>etc/lcc.c</code>.</p>\n\n<p>We'll use <a HREF=\"../etc/solaris.c\"><code>etc/solaris.c</code></a> as an example in\ndescribing how the host-specific part works. This example illustrates all the important\nfeatures. Make sure you have the environment variable <code>BUILDDIR</code> set correctly,\nand build the driver with a <code>make</code> command, e.g.,</p>\n\n<blockquote>\n  <pre>% make HOSTFILE=etc/solaris.c lcc\ncc -g -c -DTEMPDIR=\\&quot;/tmp\\&quot; -o /usr/local/lib/lcc-4.1/sparc-solaris/lcc.o etc/lcc.c\ncc -g -c -o /usr/local/lib/lcc-4.1/sparc-solaris/host.o etc/solaris.c\ncc -g -o /usr/local/lib/lcc-4.1/sparc-solaris/lcc /usr/local/lib/lcc-4.1/sparc-solaris/lcc.o /usr/local/lib/lcc-4.1/sparc-solaris/host.o</pre>\n</blockquote>\n\n<p>The symbolic name <code>HOSTFILE</code> specifies the path to the host-specific part,\neither one in the distribution or <em>whatever</em><code>.c</code>. Some versions of make\nmay require the <code>-e</code> option in order to read the environment.</p>\n\n<p>Here's <code>etc/solaris.c</code>:</p>\n\n<blockquote>\n  <pre>/* Sparcs running Solaris 2.5.1 at CS Dept., Princeton University */\n\n#include &lt;string.h&gt;\n\nstatic char rcsid[] = &quot;$ Id: solaris.c,v 1.10 1998/09/14 20:36:33 drh Exp $&quot;;\n\n#ifndef LCCDIR\n#define LCCDIR &quot;/usr/local/lib/lcc/&quot;\n#endif\n#ifndef SUNDIR\n#define SUNDIR &quot;/opt/SUNWspro/SC4.2/lib/&quot;\n#endif\n\nchar *suffixes[] = { &quot;.c&quot;, &quot;.i&quot;, &quot;.s&quot;, &quot;.o&quot;, &quot;.out&quot;, 0 };\nchar inputs[256] = &quot;&quot;;\nchar *cpp[] = { LCCDIR &quot;cpp&quot;,\n\t&quot;-D__STDC__=1&quot;, &quot;-Dsparc&quot;, &quot;-D__sparc__&quot;, &quot;-Dsun&quot;, &quot;-D__sun__&quot;, &quot;-Dunix&quot;,\n\t&quot;$1&quot;, &quot;$2&quot;, &quot;$3&quot;, 0 };\nchar *include[] = { &quot;-I&quot; LCCDIR &quot;include&quot;, &quot;-I/usr/local/include&quot;,\n\t&quot;-I/usr/include&quot;, 0 };\nchar *com[] = { LCCDIR &quot;rcc&quot;, &quot;-target=sparc/solaris&quot;,\n\t&quot;$1&quot;, &quot;$2&quot;, &quot;$3&quot;, 0 };\nchar *as[] = { &quot;/usr/ccs/bin/as&quot;, &quot;-Qy&quot;, &quot;-s&quot;, &quot;-o&quot;, &quot;$3&quot;, &quot;$1&quot;, &quot;$2&quot;, 0 };\nchar *ld[] = { &quot;/usr/ccs/bin/ld&quot;, &quot;-o&quot;, &quot;$3&quot;, &quot;$1&quot;,\n\tSUNDIR &quot;crti.o&quot;, SUNDIR &quot;crt1.o&quot;,\n\tSUNDIR &quot;values-xa.o&quot;, &quot;$2&quot;, &quot;&quot;,\n\t&quot;-Y&quot;, &quot;P,&quot; SUNDIR &quot;:/usr/ccs/lib:/usr/lib&quot;, &quot;-Qy&quot;,\n\t&quot;-L&quot; LCCDIR, &quot;-llcc&quot;, &quot;-lm&quot;, &quot;-lc&quot;, SUNDIR &quot;crtn.o&quot;, 0 };\n\nextern char *concat(char *, char *);\n\nint option(char *arg) {\n\tif (strncmp(arg, &quot;-lccdir=&quot;, 8) == 0) {\n\t\tcpp[0] = concat(&amp;arg[8], &quot;/cpp&quot;);\n\t\tinclude[0] = concat(&quot;-I&quot;, concat(&amp;arg[8], &quot;/include&quot;));\n\t\tld[12] = concat(&quot;-L&quot;, &amp;arg[8]);\n\t\tcom[0] = concat(&amp;arg[8], &quot;/rcc&quot;);\n\t} else if (strcmp(arg, &quot;-p&quot;) == 0) {\n\t\tld[5] = SUNDIR &quot;mcrt1.o&quot;;\n\t\tld[10] = &quot;P,&quot; SUNDIR &quot;libp:/usr/ccs/lib/libp:/usr/lib/libp:&quot;\n\t\t\t SUNDIR &quot;:/usr/ccs/lib:/usr/lib&quot;;\n\t} else if (strcmp(arg, &quot;-b&quot;) == 0)\n\t\t;\n\telse if (strncmp(arg, &quot;-ld=&quot;, 4) == 0)\n\t\tld[0] = &amp;arg[4];\n\telse\n\t\treturn 0;\n\treturn 1;\n}</pre>\n</blockquote>\n\n<p><code>LCCDIR</code> defaults to <code>&quot;/usr/local/lib/lcc/&quot;</code> unless\nit's defined by a <code>-D</code> option as part of <code>CFLAGS</code> in the make\ncommand, e.g.,</p>\n\n<blockquote>\n  <pre>% make HOSTFILE=etc/solaris.c CFLAGS='-DLCCDIR=\\&quot;/v/lib/lcc/\\&quot;' lcc</pre>\n</blockquote>\n\n<p>Note the trailing slash; <code>SUNDIR</code> is provided so you can use <code>etc/solaris.c</code>\neven if you have a different version of the Sun Pro compiler suite. If you're using the\ngcc compiler tools instead of the Sun Pro tools, see <a HREF=\"../etc/gcc-solaris.c\"><code>etc/gcc-solaris.c</code></a>.</p>\n\n<p>Most of the host-specific code is platform-specific data and templates for the commands\nthat invoke the preprocessor, compiler, assembler, and loader. The <code>suffixes</code>\narray lists the file name suffixes for C source files, preprocessed source files, assembly\nlanguage source files, object files, and executable files. <code>suffixes</code> must be\nterminated with a null pointer, as shown above. The initialization of <code>suffixes</code>\nin <code><a HREF=\"../etc/solaris.c\">etc/solaris.c</a></code> are the typical ones for UNIX\nsystems. Each element of <code>suffixes</code> is actually a list of suffixes, separated\nby semicolons; <code><a HREF=\"../etc/win32.c\">etc/win32.c</a></code> holds an example:</p>\n\n<blockquote>\n  <pre>char *suffixes[] = { &quot;.c;.C&quot;, &quot;.i;.I&quot;, &quot;.asm;.ASM;.s;.S&quot;, &quot;.obj;.OBJ&quot;, &quot;.exe&quot;, 0 };</pre>\n</blockquote>\n\n<p>When a list is given, the first suffix is used whenever lcc needs to generate a file\nname. For example, with <code><a HREF=\"../etc/win32.c\">etc/win32.c</a></code>, lcc emits\nthe generated assembly code into <code>.asm</code> files.</p>\n\n<p>The <code>inputs</code> array holds a null-terminated string of directories separated\nby colons or semicolons. These are used as the default value of <code>LCCINPUTS</code>, if\nthe environment variable <code>LCCINPUTS</code> is not set; see the <a HREF=\"lcc.pdf\">man\npage</a>.</p>\n\n<p>Each command template is an array of pointers to strings terminated with a null\npointer; the strings are full path names of commands, arguments, or argument placeholders,\nwhich are described below. Commands are executed in a child process, and templates can\ncontain multiple commands by separating commands with newlines. The driver runs each\ncommand in a new process.</p>\n\n<p>The <code>cpp</code> array gives the command for running lcc's preprocessor, <code>cpp</code>.\nLiteral arguments specified in templates, e.g., <code>&quot;-Dsparc&quot;</code> in the <code>cpp</code>\ncommand above, are passed to the command as given.</p>\n\n<p>The strings <code>&quot;$1&quot;</code>, <code>&quot;$2&quot;</code>, and <code>&quot;$3&quot;</code>\nin templates are placeholders for <em>lists</em> of arguments that are substituted in a\ncopy of the template before the command is executed. <code>$1</code> is replaced by the <em>options</em>\nspecified by the user; for the preprocessor, this list always contains at least <code>-D__LCC__</code>.\n<code>$2</code> is replaced by the <em>input</em> files, and <code>$3</code> is replaced\nby the <em>output</em> file.</p>\n\n<p>Zero-length arguments after replacement are removed from the argument list before the\ncommand is invoked. So, for example, if the preprocessor is invoked without an output\nfile, <code>&quot;$3&quot;</code> becomes <code>&quot;&quot;</code>, which is removed from\nthe final argument list.</p>\n\n<p>The <code>include</code> array is a list of <code>-I</code> options that specify which\ndirectives should be searched to satisfy include directives. These directories are\nsearched in the order given. The first directory should be the one to which the ANSI\nheader files were copied as described in <a HREF=\"#unix\">UNIX</a> or <a HREF=\"#win32\">Windows</a>\ninstallation instructions. The driver adds these options to <code>cpp</code>'s arguments\nwhen it invokes the preprocessor, except when <code>-N</code> is specified.</p>\n\n<p><code>com</code> gives the command for invoking the compiler. This template can appear\nas shown above in a custom host-specific part, but the option <code>-target=sparc/solaris</code>\nshould be edited to the <em>target</em><code>/</code><em>os</em> for your platform. If <code>com[1]</code>\nincludes the string &quot;<code>win32</code>&quot;, the driver assumes it's running on\nWindows. lcc can generate code for <em>all</em> of the <em>target</em><code>/</code><em>os</em>\ncombinations listed in the file <code>src/bind.c</code>. The <code>-target</code> option\nspecifies the default combination. The driver's <code>-Wf</code> option can be used to\nspecify other combinations; the <a HREF=\"lcc.pdf\">man page</a> elaborates.</p>\n\n<p><code>as</code> gives the command for invoking the assembler. On Linux, you must be\nrunning at least version 2.8.1 of the GNU assembler; earlier versions mis-assemble some\ninstructions emitted by lcc.</p>\n\n<p><code>ld</code> gives the command for invoking the loader. For the other commands, the\nlist <code>$2</code> contains a single file; for <code>ld</code>, <code>$2</code> contains\nall &quot;.o&quot; files and libraries, and <code>$3</code> is <code>a.out</code>, unless\nthe <code>-o</code> option is specified. As suggested in the code above, <code>ld</code>\nmust also specify the appropriate startup code and default libraries, including the lcc\nlibrary, <code>liblcc.a</code>.</p>\n\n<p>The <code>option</code> function is described below; the minimal <code>option</code>\nfunction just returns 0.</p>\n\n<p>You can test <code>lcc</code> with the options <code>-v -v</code> to display the\ncommands that would be executed, e.g.,</p>\n\n<blockquote>\n  <pre>% $BUILDDIR/lcc -v -v foo.c baz.c mylib.a -lX11\n/usr/local/lib/lcc-4.1/lcc $ Id: solaris.c,v 1.10 1998/09/14 20:36:33 drh Exp $\nfoo.c:\n/usr/local/lib/lcc/cpp -D__STDC__=1 -Dsparc -D__sparc__ -Dsun -D__sun__ -Dunix -D__LCC__ -I/usr/local/lib/lcc/include -I/usr/local/include -I/usr/include foo.c /tmp/lcc266290.i\n/usr/local/lib/lcc/rcc -target=sparc/solaris -v /tmp/lcc266290.i /tmp/lcc266291.\ns\n/usr/ccs/bin/as -Qy -s -o /tmp/lcc266292.o /tmp/lcc266291.s\nbaz.c:\n/usr/local/lib/lcc/cpp -D__STDC__=1 -Dsparc -D__sparc__ -Dsun -D__sun__ -Dunix -D__LCC__ -I/usr/local/lib/lcc/include -I/usr/local/include -I/usr/include baz.c /tmp/lcc266290.i\n/usr/local/lib/lcc/rcc -target=sparc/solaris -v /tmp/lcc266290.i /tmp/lcc266291.s\n/usr/ccs/bin/as -Qy -s -o /tmp/lcc266293.o /tmp/lcc266291.s\n/usr/ccs/bin/ld -o a.out /opt/SUNWspro/SC4.2/lib/crti.o /opt/SUNWspro/SC4.2/lib/crt1.o /opt/SUNWspro/SC4.2/lib/values-xa.o /tmp/lcc266292.o /tmp/lcc266293.o mylib.a -lX11 -Y P,/opt/SUNWspro/SC4.2/lib/:/usr/ccs/lib:/usr/lib -Qy -L/usr/local/lib/lcc/ -llcc -lm -lc /opt/SUNWspro/SC4.2/lib/crtn.o\nrm /tmp/lcc266293.o /tmp/lcc266290.i /tmp/lcc266291.s /tmp/lcc266292.o</pre>\n</blockquote>\n\n<p>As the output shows, <code>lcc</code> places temporary files in <code>/tmp</code>; if\nany of the environment variables <code>TMP</code>, <code>TEMP</code>, and <code>TMPDIR</code>\nare set, they override this default (in the order shown) as does the <code>-tempdir=</code><em>dir</em>\noption. The default can be changed by defining <code>TEMPDIR</code> in <code>CFLAGS</code>\nwhen building the driver.</p>\n\n<p>The <code>option</code> function is called for the options <code>-Wo</code>, <code>-g</code>,\n<code>-p</code>, <code>-pg</code>, and <code>-b</code> because these compiler options\nmight also affect the loader's arguments. For these options, the driver calls <code>option(arg)</code>\nto give the host-specific code an opportunity to edit the <code>ld</code> command, if\nnecessary. <code>option</code> can change <code>ld</code>, if necessary, and return 1 to\nannounce its acceptance of the option. If the option is unsupported, <code>option</code>\nshould return 0.</p>\n\n<p>For example, in response to <code>-g</code>, the <code>option</code> function shown\nabove accepts the option but does nothing else, because the <code>ld</code> and <code>as</code>\ncommands don't need to be modified on the SPARC. <code>-g</code> will also be added to the\ncompiler's options by the host-independent part of the driver. The <code>-p</code> causes <code>option</code>\nto change the name of the startup code and changed the list of libraries. The <code>-b</code>\noption turns on <code>lcc</code>'s per-expression profiling, the code for which is in <code>liblcc.a</code>,\nso <code>option</code> need no nothing.</p>\n\n<p>On SPARCs, the driver also recognizes <code>-Bstatic</code> and <code>-Bdynamic</code>\nas linker options. The driver recognizes but ignores &quot;<code>-target</code> <em>name</em>&quot;\noption.</p>\n\n<p>The option <code>-Wo</code><em>arg</em> causes the driver to pass <em>arg</em> to <code>option</code>.\nSuch options have no other effect; this mechanism is provided to support system-specific\noptions that affect the commands executed by the driver. As illustrated above,\nhost-specific parts should support the <code>-Wo-lccdir=</code><em>dir</em> option, which\ncauses lcc's compilation components to be found in <em>dir</em>, because this option is\nused by the test scripts, and because the driver simulates a <code>-Wo-lccdir</code>\noption with the value of the environment variable <code>LCCDIR</code>, if it's defined.\nThe code above rebuilds the paths to the include files, preprocessor, compiler, and\nlibrary by calling <code>concat</code>, which is defined in <code>etc/lcc.c</code>.</p>\n\n<h2><a NAME=\"rcc\">Building the Compiler and Accessories</a></h2>\n\n<p>To build the rest of compilation components make sure <code>BUILDDIR</code> is set\nappropriately and type &quot;<code>make all</code>&quot;. This command builds <code>librcc.a</code>\n(the compiler's private library), <code>rcc</code> (the compiler proper), <code>lburg</code>\n(the code-generator generator), <code>cpp</code> (the preprocessor), <code>liblcc.a</code>\n(the runtime library), and <code>bprint</code> (the profile printer), all in <code>BUILDDIR</code>.\nThere may be warnings, but there should be no errors. If you're using an ANSI/ISO compiler\nother than <code>cc</code>, specify its name with the <code>CC=</code> option, e.g.,\n&quot;<code>make CC=gcc all</code>&quot;. If you're running on a DEC ALPHA, use &quot;<code>make\nCC='cc -std1' all</code>&quot;; the <code>-std1</code> option is essential on the ALPHA.\nIf you're on a DEC 5000 running Ultrix 4.3, use &quot;<code>make CC=c89 all</code>&quot;.</p>\n\n<p>Once <code>rcc</code> is built with the host C compiler, run the test suite to verify\nthat <code>rcc</code> is working correctly. If any of the steps below fail, contact us\n(see <a HREF=\"#bugs\"><em>Reporting Bugs</em></a>). The commands in the makefile run the\nshell script <code>src/run.sh</code> on each C program in the test suite, <code>tst/*.c</code>.\nIt uses the driver, <code>$BUILDDIR/lcc</code>, so you must have the driver in the build\ndirectory before testing <code>rcc</code>. The <em>target</em><code>/</code><em>os</em>\ncombination is read from the variable <code>TARGET</code>, which must be specified when\ninvoking <code>make</code>:</p>\n\n<blockquote>\n  <pre>% make TARGET=sparc/solaris test\nmkdir -p /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst\n/usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/8q.s:\n/usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/array.s:\n/usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/cf.s:\n/usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/cq.s:\n/usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/cvt.s:\n/usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/fields.s:\n/usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/front.s:\n/usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/incr.s:\n/usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/init.s:\n/usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/limits.s:\n/usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/paranoia.s:\n/usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/sort.s:\n/usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/spill.s:\n/usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/stdarg.s:\n/usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/struct.s:\n/usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/switch.s:\n/usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/wf1.s:\n/usr/local/lib/lcc-4.1/sparc-solaris/rcc -target=sparc/solaris /usr/local/lib/lcc-4.1/sparc-solaris/sparc/solaris/tst/yacc.s:</pre>\n</blockquote>\n\n<p>Each line in the output above is of the form</p>\n\n<blockquote>\n  <p><code>$BUILDDIR/rcc -target=</code><em>target</em><code>/</code><em>os</em><code>$BUILDDIR/</code><em>target</em><code>/</code><em>os</em><code>/</code><em>X</em><code>.s:</code></p>\n</blockquote>\n\n<p>where <em>X</em> is the base name of the C program <em>X</em><code>.c</code> in the\ntest suite. This output identifies the compiler and the target, e.g., &quot;<code>$BUILDDIR/rcc</code>\nis generating code for a <code>sparc</code> running the <code>solaris</code> operating\nsystem.&quot;</p>\n\n<p>For each program in the test suite, <code>src/run.sh</code> compiles the program, drops\nthe generated assembly language code in <code>BUILDDIR</code>/<em>target</em><code>/</code><em>os</em>,\nand uses <code>diff</code> to compare the generated assembly code with the expected code\n(the code expected for <code>tst/8q.c</code> on the SPARC under Solaris is in <code>sparc/solaris/tst/8q.sbk</code>,\netc.). If there are differences, the script executes the generated code with the input\ngiven in <code>tst</code> (the input for <code>tst/8q.c</code> is in <code>tst/8q.0</code>,\netc.) and compares the output with the expected output (the expected output from <code>tst/8q.c</code>\non the SPARC under Solaris is in <code>sparc/solaris/tst/8q.1bk</code>, etc.). The script\nalso compares the diagnostics from the compiler with the expected diagnostics.</p>\n\n<p>On some systems, there may be a few differences between the generated code and the\nexpected code. These differences occur because the expected code is generated by cross\ncompilation and the least significant bits of some floating-point constants differ from\nthose bits in constants generated on your system. On Linux, there may be differences\nbecause of differences in the header files between our system and yours. There should be\nno differences in the output from executing the test programs.</p>\n\n<p>Next, run the &quot;triple test&quot;, which builds <code>rcc</code> using itself:</p>\n\n<blockquote>\n  <pre>% make triple\n/usr/local/lib/lcc-4.1/sparc-solaris/lcc -o /usr/local/lib/lcc-4.1/sparc-solaris/1rcc -d0.6 -Wo-lccdir=/usr/local/lib/lcc-4.1/sparc-solaris -B/usr/local/lib/lcc-4.1/sparc-solaris/  -Isrc src/*.c\nsrc/alloc.c:\n...\nsrc/x86.c:\n/usr/local/lib/lcc-4.1/sparc-solaris/lcc -o /usr/local/lib/lcc-4.1/sparc-solaris/1rcc -d0.6 -Wo-lccdir=/usr/local/lib/lcc-4.1/sparc-solaris -B/usr/local/lib/lcc-4.1/sparc-solaris/  -Isrc src/*.c\nsrc/alloc.c:\n...\nsrc/x86.c:\nstrip /usr/local/lib/lcc-4.1/sparc-solaris/[12]rcc\ndd if=/usr/local/lib/lcc-4.1/sparc-solaris/1rcc of=/usr/local/lib/lcc-4.1/sparc-solaris/rcc1 bs=512 skip=1\n769+1 records in\n769+1 records out\ndd if=/usr/local/lib/lcc-4.1/sparc-solaris/2rcc of=/usr/local/lib/lcc-4.1/sparc-solaris/rcc2 bs=512 skip=1\n769+1 records in\n769+1 records out\nif cmp /usr/local/lib/lcc-4.1/sparc-solaris/rcc[12]; then \\\n        mv /usr/local/lib/lcc-4.1/sparc-solaris/2rcc /usr/local/lib/lcc-4.1/sparc-solaris/rcc; \\\n        rm -f /usr/local/lib/lcc-4.1/sparc-solaris/1rcc /usr/local/lib/lcc-4.1/sparc-solaris/rcc[12]; fi</pre>\n</blockquote>\n\n<p>This command builds <code>rcc</code> twice; once using the <code>rcc</code> built by <code>cc</code>\nand again using the <code>rcc</code> built by <code>lcc</code>. The resulting binaries are\ncompared. They should be identical, as shown at the end of the output above. If they\naren't, our compiler is generating incorrect code; <a HREF=\"#bugs\">contact</a> us.</p>\n\n<p>The final version of <code>rcc</code> should also pass the test suite; that is, the\noutput from</p>\n\n<blockquote>\n  <pre>% make TARGET=sparc/solaris test</pre>\n</blockquote>\n\n<p>should be identical to that from the previous <code>make test</code>.</p>\n\n<p>The command &quot;<code>make clean</code>&quot; cleans up, but does not remove <code>rcc</code>,\netc., and &quot;<code>make clobber</code>&quot; cleans up and removes <code>lcc</code>, <code>rcc</code>,\nand the other accessories. Test directories under <code>BUILDDIR</code> are <em>not</em>\nremoved; you'll need to remove these by hand, e.g.,</p>\n\n<blockquote>\n  <pre>% rm -fr $BUILDDIR/sparc</pre>\n</blockquote>\n\n<p>The code generators for the other targets can be tested by specifying the desired <em>target</em><code>/</code><em>os</em>\nand setting an environment variable that controls what <code>src/run.sh</code> does. For\nexample, to test the MIPS code generator, type</p>\n\n<blockquote>\n  <pre>% setenv REMOTEHOST noexecute\n% make TARGET=mips/irix test</pre>\n</blockquote>\n\n<p>As above, <code>src/run.sh</code> compares the MIPS code generated with what's\nexpected. There should be no differences. Setting <code>REMOTEHOST</code> to <code>noexecute</code>\nsuppresses the assembly and execution of the generated code. If you set <code>REMOTEHOST</code>\nto the name of a MIPS machine to which you can <code>rlogin</code>, <code>src/run.sh</code>\nwill <code>rcp</code> the generated code to that machine and execute it there, if\nnecessary. See <code>src/run.sh</code> for the details.</p>\n\n<p>You can use lcc as a cross compiler. The options <code>-S</code> and <code>-Wf-target=</code><em>target/os</em>\ngenerate assembly code for the specified target, which is any of those listed in the file <code>src/bind.c</code>.\nFor example, </p>\n\n<blockquote>\n  <pre>% lcc -Wf-target=mips/irix -S tst/8q.c</pre>\n</blockquote>\n\n<p>generates MIPS code for <code>tst/8q.c</code> in <code>8q.s</code>.</p>\n\n<p>lcc can also generate code for a &quot;symbolic&quot; target. This target is used\nroutinely in front-end development, and its output is a printable representation of the\ninput program, e.g., the dags constructed by the front end are printed, and other\ninterface functions print their arguments. You can specify this target with the option <code>-Wf-target=symbolic</code>.\nFor example,</p>\n\n<blockquote>\n  <pre>% lcc -Wf-target=symbolic -S tst/8q.c</pre>\n</blockquote>\n\n<p>generates symbolic output for <code>tst/8q.c</code> in <code>8q.s</code>. Adding <code>-Wf-html</code>\ncauses the symbolic target to emit HTML instead of plain text. Finally, the option <code>-Wf-target=null</code>\nspecifies the &quot;null&quot; target for which lcc emits nothing and thus only checks the\nsyntax and semantics of its input files.</p>\n\n<h2><a NAME=\"win32\">Installation on Windows NT 4.0 or Windows 95/98</a></h2>\n\n<p>On Windows NT 4.0 and Windows 95/98, lcc is designed to work with Microsoft's Visual\nC++ 5.0 (VC) and Microsoft's Assembler, MASM 6.11d. It uses the VC header files,\nlibraries, and command-line tools, and it uses MASM to assemble the code it generates. If\nyou have MASM 6.11, make sure you <a\nHREF=\"http://support.microsoft.com/support/kb/articles/Q138/9/83.asp\">upgrade to 6.11d</a>,\nbecause earlier 6.11 releases do not generate correct COFF object files.</p>\n\n<p>Building the distribution components from the ground up requires Microsoft's Visual\nC/C++ 5.0 compiler, Microsoft's make, <code>nmake</code>, and the standard Windows command\ninterpreter. <a HREF=\"../makefile.nt\"><code>makefile.nt</code></a> is written to use only <code>nmake</code>.\nAs on UNIX systems, the compilation components are installed in a single <em>build\ndirectory</em>, and the top-level programs, <code>lcc.exe</code> and <code>bprint.exe</code>,\nare installed in a directory on the PATH. If the conventions used below are followed, the\nWindows-specific parts of the driver program, <code>lcc.exe</code>, can be used\nunmodified.</p>\n\n<p>Building from the source distribution on a Windows system involves the following steps.\nBelow, the build directory is referred to as <code>BUILDDIR</code>, and the distribution\nis in <code>\\dist\\lcc\\4.1</code>. \n\n<ol>\n  <li>Create the build directory, perhaps using a version- and platform-specific naming\n    convention as suggested in <a HREF=\"#unix\"><em>Installation on UNIX</em></a>, and record\n    the name of this directory in the <code>BUILDDIR</code> environment variable:<blockquote>\n      <pre>C:\\dist\\lcc\\4.1&gt;set BUILDDIR=\\progra~1\\lcc\\4.1\\bin\nC:\\dist\\lcc\\4.1&gt;mkdir %BUILDDIR%</pre>\n    </blockquote>\n    <p>The default build, or installation, directory is <code>\\Program Files\\lcc\\4.1\\bin</code>,\n    but the <code>nmake</code> commands require that you use the corresponding 8.3 file name, <code>progra~1</code>,\n    instead of <code>Program Files</code>.</p>\n  </li>\n  <li><a HREF=\"../etc/win32.c\"><code>etc\\win32.c</code></a> is the Windows-specific part of\n    the driver. It assumes that environment variable <code>include</code> gives the locations\n    of the VC header files and that the linker (<code>link.exe</code>) and the assembler (<code>ml.exe</code>)\n    are on the PATH. It also assumes that the macro <code>LCCDIR</code> gives the build\n    directory. If necessary, revise a copy of <a HREF=\"../etc/win32.c\"><code>etc\\win32.c</code></a>\n    to reflect the conventions on your computer (see <a HREF=\"#driver\"><em>Building the Driver</em></a>),\n    then build the driver, specifying the default temporary directory, if necessary:<blockquote>\n      <pre>C:\\dist\\lcc\\4.1&gt;nmake -f makefile.nt TEMPDIR=\\\\temp HOSTFILE=etc/win32.c lcc\n...\n        cl -nologo -Zi -MLd -Fd\\progra~1\\lcc\\4.1\\bin\\ -c -DTEMPDIR=\\&quot;\\\\temp\\&quot; -Fo\\progra~1\\lcc\\4.1\\bin\\lcc.obj etc/lcc.c\nlcc.c\n        cl -nologo -Zi -MLd -Fd\\progra~1\\lcc\\4.1\\bin\\ -c -Fo\\progra~1\\lcc\\4.1\\bin\\host.obj etc/win32.c\nwin32.c\n        cl -nologo -Zi -MLd -Fd\\progra~1\\lcc\\4.1\\bin\\ -Fe\\progra~1\\lcc\\4.1\\bin\\lcc.exe \\progra~1\\lcc\\4.1\\bin\\lcc.obj \\progra~1\\lcc\\4.1\\bin\\host.obj</pre>\n    </blockquote>\n    <p>If you make a copy of <code>etc\\win32.c</code>, specify the path of the copy as the\n    value of <code>HOSTFILE</code>. For example, if you copy <code>etc\\win32.c</code> to <code>BUILDDIR</code>\n    and edit it, use the command</p>\n    <blockquote>\n      <pre>C:\\dist\\lcc\\4.1&gt;nmake -f makefile.nt TEMPDIR=\\\\temp HOSTFILE=%BUILDDIR%\\win32.c lcc</pre>\n    </blockquote>\n  </li>\n  <li>Build the preprocessor, compiler proper, library, and other accessories (see <a\n    HREF=\"#rcc\"><em>Building the Compiler</em></a>):<blockquote>\n      <pre>C:\\dist\\lcc\\4.1&gt;nmake -f makefile.nt all</pre>\n    </blockquote>\n    <p>This command uses the VC command-line tools <code>cl</code> and <code>lib</code> to\n    build <code>bprint.exe</code>, <code>cpp.exe</code>, <code>lburg.exe</code>, <code>liblcc.lib</code>,\n    <code>librcc.lib</code>, and <code>rcc.exe</code>, all in <code>BUILDDIR</code>. There may\n    be some warnings, but there should be no warnings.</p>\n  </li>\n  <li>Create a test directory and run the test suite:<blockquote>\n      <pre>C:\\dist\\lcc\\4.1&gt;mkdir %BUILDDIR%\\x86\\win32\\tst\nC:\\dist\\lcc\\4.1&gt;nmake -f makefile.nt test</pre>\n    </blockquote>\n    <p>This command compiles each program in <a HREF=\"../tst\">tst</a>, compares the generated\n    assembly code and diagnostics with the expected assembly code and diagnostics, executes\n    the program, and compares the output with the expected output (using <code>fc</code>). For\n    example, when the nmake command compiles <a HREF=\"../tst/8q.c\"><code>tst\\8q.c</code></a>,\n    it leaves the generated assembly code and diagnostic output in <code>%BUILDDIR%\\x86\\win32\\tst\\8q.s</code>\n    and <code>%BUILDDIR%\\x86\\win32\\tst\\8q.2</code>, and it compares them with the expected\n    results in <code>x86\\win32\\tst\\8q.sbk</code>. It builds the executable program in <code>%BUILDDIR%\\x86\\win32\\tst\\8q.exe</code>,\n    runs it, and redirects the output to <code>%BUILDDIR%\\x86\\win32\\tst\\8q.1</code>, which it\n    compares with <code>x86\\win32\\tst\\8q.1bk</code>. The output from this step is voluminous,\n    but there should be no differences and no errors.</p>\n  </li>\n  <li>Run the &quot;triple&quot; test, which compiles <code>rcc</code> with itself and\n    verifies the results:<blockquote>\n      <pre>C:\\dist\\lcc\\4.1&gt;nmake -f makefile.nt triple\n...\n\\progra~1\\lcc\\4.1\\bin\\x86.c:\n Assembling: C:/TEMP/lcc2001.asm\n        fc /b \\progra~1\\lcc\\4.1\\bin\\1rcc.exe \\progra~1\\lcc\\4.1\\bin\\2rcc.exe\nComparing files \\progra~1\\lcc\\4.1\\bin\\1rcc.exe and \\progra~1\\lcc\\4.1\\bin\\2RCC.EXE\n00000088: B4 D5</pre>\n    </blockquote>\n    <p>This command builds <code>rcc</code> twice; once using the <code>rcc</code> built by VC\n    and again using the <code>rcc</code> built by <code>lcc</code>. The resulting binaries are\n    compared using <code>fc</code>. They should be identical, except for one or two bytes of\n    timestamp data, as shown at the end of the output above. If they aren't, our compiler is\n    generating incorrect code; <a HREF=\"#bugs\">contact</a> us.</p>\n  </li>\n  <li>Copy <code>lcc.exe</code> and <code>bprint.exe</code> to a directory on your PATH, e.g.,<blockquote>\n      <pre>C:\\dist\\lcc\\4.1&gt;copy %BUILDDIR%\\lcc.exe \\bin\n        1 file(s) copied.\n\nC:\\dist\\lcc\\4.1&gt;copy %BUILDDIR%\\bprint.exe \\bin\n        1 file(s) copied.</pre>\n    </blockquote>\n  </li>\n  <li>Finally, clean up:<blockquote>\n      <pre>C:\\dist\\lcc\\4.1&gt;nmake -f makefile.nt clean</pre>\n    </blockquote>\n    <p>This command removes the derived files in <code>BUILDDIR</code>, but does not remove <code>rcc.exe</code>,\n    etc.; &quot;<code>nmake -f makefile.nt clobber</code>&quot; cleans up and removes all\n    executables and libraries. Test directories under <code>BUILDDIR</code> are <em>not</em>\n    removed; you'll need to remove these by hand, e.g.,</p>\n    <blockquote>\n      <pre>C:\\dist\\lcc\\4.1&gt;rmdir %BUILDDIR%\\x86 /s\n\\progra~1\\lcc\\4.1\\bin\\x86, Are you sure (Y/N)? y</pre>\n    </blockquote>\n  </li>\n</ol>\n\n<h2><a NAME=\"bugs\">Reporting Bugs</a></h2>\n\n<p>lcc is a large, complex program. We find and repair errors routinely. If you think that\nyou've found a error, follow the steps below, which are adapted from the instructions in\nChapter 1 of <cite>A Retargetable C Compiler: Design and Implementation</cite>. \n\n<ol>\n  <li>If you don't have a source file that displays the error, create one. Most errors are\n    exposed when programmers try to compile a program they think is valid, so you probably\n    have a demonstration program already.</li>\n  <li>Preprocess the source file and capture the preprocessor output. Discard the original\n    code.</li>\n  <li>Prune your source code until it can be pruned no more without sending the error into\n    hiding. We prune most error demonstrations to fewer than five lines.</li>\n  <li>Confirm that the source file displays the error with the <em>distributed</em> version of\n    lcc. If you've changed lcc and the error appears only in your version, then you'll have to\n    chase the error yourself, even if it turns out to be our fault, because we can't work on\n    your code.</li>\n  <li>Annotate your code with comments that explain why you think that lcc is wrong. If lcc\n    dies with an assertion failure, please tell us where it died. If lcc crashes, please\n    report the last part of the call chain if you can. If lcc is rejecting a program you think\n    is valid, please tell us why you think it's valid, and include supporting page numbers in\n    the ANSI Standard, Appendix A in <cite>The C Programming Language</cite>, or the\n    appropriate section in <cite>C: A Reference Manual</cite>, 4th edition by S. B. Harbison\n    and G. L. Steele, Jr. (Prentice Hall, 1995). If lcc silently generates incorrect code for\n    some construct, please include the corrupt assembly code in the comments and flag the\n    incorrect instructions if you can.</li>\n  <li>Confirm that your error hasn't been fixed already. The latest version of lcc is always\n    available for anonymous <code>ftp</code> from <code>ftp.cs.princeton.edu</code> in <a\n    HREF=\"ftp://ftp.cs.princeton.edu/pub/lcc\"><code>pub/lcc</code></a>. A <a\n    HREF=\"ftp://ftp.cs.princeton.edu/pub/lcc/README\"><code>README</code></a> file there gives\n    acquistion details, and the <a HREF=\"../LOG\"><code>LOG</code></a> file reports what errors\n    were fixed and when they were fixed. If you report a error that's been fixed, you might\n    get a canned reply.</li>\n  <li>Send your program by electronic mail to <code>lcc-bugs@cs.princeton.edu</code>. Please\n    send only valid C programs; put all remarks in C comments so that we can process reports\n    semiautomatically.</li>\n</ol>\n\n<h2><a NAME=\"mailinglist\">Keeping in Touch</a></h2>\n\n<p>There is an lcc mailing list for general information about lcc. To be added to the\nlist, send a message with the 1-line body</p>\n\n<blockquote>\n  <pre>subscribe lcc</pre>\n</blockquote>\n\n<p>to <code>majordomo@cs.princeton.edu</code>. This line must appear in the message body;\n&quot;Subject:&quot; lines are ignored. To learn more about mailing lists served by <code>majordomo</code>,\nsend a message with the 1-word body &quot;<code>help</code>&quot; to <code>majordomo@cs.princeton.edu</code>.\nMail sent to <code>lcc@cs.princeton.edu</code> is forwarded to everyone on the mailing\nlist.</p>\n\n<p>There is also an <code>lcc-bugs</code> mailing list for reporting bugs; subscribe to it\nby sending a message with the 1-line body </p>\n\n<blockquote>\n  <pre>subscribe lcc-bugs</pre>\n</blockquote>\n\n<p>to <code>majordomo@cs.princeton.edu</code>. Mail addressed to <var>lcc-bugs@cs.princeton.edu</var>\nis forwarded to everyone on this list.</p>\n\n<hr>\n\n<address>\n  <a HREF=\"http://www.research.microsoft.com/~cwfraser/\">Chris Fraser</a> / <a\n  HREF=\"mailto:cwfraser@microsoft.com\">cwfraser@microsoft.com</a><br>\n  <a HREF=\"http://www.research.microsoft.com/~drh/\">David Hanson</a> / <a\n  HREF=\"mailto:drh@microsoft.com\">drh@microsoft.com</a><br>\n  $Revision: 145 $ $Date: 2001-10-17 16:53:10 -0500 (Wed, 17 Oct 2001) $ \n</address>\n</body>\n</html>\n"
  },
  {
    "path": "lcc/doc/lcc.1",
    "content": ".\\\" $Id: lcc.1 145 2001-10-17 21:53:10Z timo $\n.TH LCC 1 \"local \\- $Date: 2001-10-17 16:53:10 -0500 (Wed, 17 Oct 2001) $\"\n.SH NAME\nlcc \\- ANSI C compiler\n.SH SYNOPSIS\n.B lcc\n[\n.I option\n|\n.I file\n]...\n.br\n.SH DESCRIPTION\n.PP\n.I lcc\nis an ANSI C compiler for a variety of platforms.\n.PP\nArguments whose names end with `.c' (plus `.C' under Windows) are taken to be\nC source programs; they are preprocessed, compiled, and\neach object program is left on the file\nwhose name is that of the source with `.o' (UNIX) or `.obj' (Windows)\nsubstituted for the extension.\nArguments whose names end with `.i' are treated similarly,\nexcept they are not preprocessed.\nIn the same way,\narguments ending with `.s' (plus `.S', `.asm', and `.ASM', under Windows)\nare taken to be assembly source programs\nand are assembled, producing an object file.\nIf there are no arguments,\n.I lcc\nsummarizes its options on the standard error.\n.PP\n.I lcc\ndeletes an object file if and only if exactly one\nsource file is mentioned and no other file\n(source, object, library) or\n.B \\-l\noption is mentioned.\n.PP\nIf the environment variable\n.B LCCINPUTS\nis set,\n.I lcc\nassumes it gives a semicolon- or colon-separated list of directories in which to\nlook for source and object files whose names do not begin with `/'.\nThese directories are also added to the list of directories\nsearched for libraries.\nIf\n.B LCCINPUTS\nis defined, it must contain `.' in order for the current directory\nto be searched for input files.\n.PP\n.I lcc\nuses ANSI standard header files (see `FILES' below).\nInclude files not found in the ANSI header files\nare taken from the normal default include areas,\nwhich usually includes\n.BR /usr/include .\nUnder Windows, if the environment variable\n.B include\nis defined, it gives a semicolon-separated list of directories in which to search for\nheader files.\n.PP\n.I lcc\ninterprets the following options; unrecognized options are\ntaken as loader options (see\n.IR ld (1))\nunless\n.BR \\-c ,\n.BR \\-S ,\nor\n.B \\-E\nprecedes them.\nExcept for\n.BR \\-l ,\nall options are processed before any of the files\nand apply to all of the files.\nApplicable options are passed to each compilation phase in the order given.\n.TP\n.B \\-c\nSuppress the loading phase of the compilation, and force\nan object file to be produced even if only one program is compiled.\n.TP\n.B \\-g\nProduce additional symbol table information for the local debuggers.\n.I lcc\nwarns when\n.B \\-g\nis unsupported.\n.TP\n.BI \\-Wf\\-g n , x\nSet the debugging level to\n.I n\nand emit source code as comments into the generated assembly code;\n.I x\nmust be the assembly language comment character.\nIf\n.I n\nis omitted, it defaults to 1, which is similar to\n.BR \\-g .\nOmitting\n.BI , x\njust sets the debugging level to\n.IR n .\n.TP\n.B \\-w\nSuppress warning diagnostics, such as those\nannouncing unreferenced statics, locals, and parameters.\nThe line\n.I\n#pragma ref id\nsimulates a reference to the variable \n.IR id .\n.TP\n.BI \\-d n\nGenerate jump tables for switches whose density is at least\n.IR n ,\na floating point constant between zero and one.\nThe default is 0.5.\n.TP\n.B \\-A\nWarns about\ndeclarations and casts of function types without prototypes,\nassignments between pointers to ints and pointers to enums, and\nconversions from pointers to smaller integral types.\nA second\n.B \\-A\nwarns about\nunrecognized control lines,\nnonANSI language extensions and source characters in literals,\nunreferenced variables and static functions,\ndeclaring arrays of incomplete types,\nand exceeding\n.I some\nANSI environmental limits, like more than 257 cases in switches.\nIt also arranges for duplicate global definitions in separately compiled\nfiles to cause loader errors.\n.TP\n.B \\-P\nWrites declarations for all defined globals on standard error.\nFunction declarations include prototypes;\nediting this output can simplify conversion to ANSI C.\nThis output may not correspond to the input when\nthere are several typedefs for the same type.\n.TP\n.B \\-n\nArrange for the compiler to produce code\nthat tests for dereferencing zero pointers.\nThe code reports the offending file and line number and calls\n.IR abort (3).\n.TP\n.B \\-O\nis ignored.\n.TP\n.B \\-S\nCompile the named C programs, and leave the\nassembler-language output on corresponding files suffixed `.s' or `.asm'.\n.TP\n.B \\-E\nRun only the preprocessor on the named C programs\nand unsuffixed file arguments,\nand send the result to the standard output.\n.TP\n.BI \\-o \"  output\"\nName the output file\n.IR output .\nIf\n.B \\-c\nor\n.B \\-S\nis specified and there is exactly one source file,\nthis option names the object or assembly file, respectively.\nOtherwise, this option names the final executable\nfile generated by the loader, and `a.out' (UNIX) or `a.exe' (Windows) is left undisturbed.\n.I lcc\nwarns if\n.B \\-o\nand\n.B \\-c\nor\n.B \\-S\nare given with more than one source file and ignores the\n.B \\-o\noption.\n.TP\n.BI \\-D name=def\nDefine the\n.I name\nto the preprocessor, as if by `#define'.\nIf\n.I =def\nis omitted, the name is defined as \"1\".\n.TP\n.BI \\-U name\nRemove any initial definition of\n.IR name .\n.TP\n.BI \\-I dir\n`#include' files\nwhose names do not begin with `/' are always\nsought first in the directory of the\n.I file\narguments, then in directories named in\n.B \\-I\noptions, then in directories on a standard list.\n.TP\n.B \\-N\nDo not search\n.I any\nof the standard directories for `#include' files.\nOnly those directories specified by subsequent explicit\n.B \\-I\noptions will be searched, in the order given.\n.TP\n.BI \\-B str\nUse the compiler\n.BI \"\" str rcc\ninstead of the default version.\nNote that\n.I str\noften requires a trailing slash.\nOn Sparcs only,\n.B \\-Bstatic\nand\n.BI \\-Bdynamic\nare passed to the loader; see\n.IR ld (1).\n.TP\n.BI \\-Wo\\-lccdir= dir\nFind the preprocessor, compiler proper, and include directory\nin the directory\n.I dir/\nor\n.I\ndir\\\\.\nIf the environment variable\n.B LCCDIR\nis defined, it gives this directory.\n.I lcc\nwarns when this option is unsupported.\n.TP\n.B \\-Wf-unsigned_char=1\n.br\n.ns\n.TP\n.B \\-Wf-unsigned_char=0 \nmakes plain\n.B char\nan unsigned (1) or signed (0) type; by default,\n.B char\nis signed.\n.TP\n.B \\-Wf\\-wchar_t=unsigned_char\n.br\n.ns\n.TP\n.B \\-Wf\\-wchar_t=unsigned_short\n.br\n.ns\n.TP\n.B \\-Wf\\-wchar_t=unsigned_int\nMakes wide characters the type indicated; by default,\nwide characters are unsigned short ints, and\n.B wchar_t\nis a typedef for unsigned short defined in stddef.h.\nThe definition for\n.B wchar_t\nin stddef.h must correspond to the type specified.\n.TP\n.B \\-v\nPrint commands as they are executed; some of the executed\nprograms are directed to print their version numbers.\nMore than one occurrence of\n.B \\-v\ncauses the commands to be printed, but\n.I not\nexecuted.\n.TP\n.BR \\-help \" or \" \\-?\nPrint a message on the standard error summarizing\n.IR lcc 's\noptions and giving the values of the environment variables\n.B LCCINPUTS\nand\n.BR LCCDIR ,\nif they are defined.\nUnder Windows, the values of\n.B include\nand\n.B lib\nare also given, if they are defined.\n.TP\n.B \\-b\nProduce code that counts the number of times each expression is executed.\nIf loading takes place, arrange for a\n.B prof.out\nfile to be written when the object program terminates.\nA listing annotated with execution counts can then be generated with\n.IR bprint (1).\n.I lcc\nwarns when\n.B \\-b\nis unsupported.\n.B \\-Wf\\-C\nis similar, but counts only the number of function calls.\n.TP\n.B \\-p\nProduce code that counts the number of times each function is called.\nIf loading takes place, replace the standard startup\nfunction by one that automatically calls\n.IR monitor (3)\nat the start and arranges to write a\n.B mon.out\nfile when the object program terminates normally.\nAn execution profile can then be generated with\n.IR prof (1).\n.I lcc\nwarns when\n.B \\-p\nis unsupported.\n.TP\n.B \\-pg\nCauses the compiler to produce counting code like\n.BR \\-p ,\nbut invokes a run-time recording mechanism that keeps more\nextensive statistics and produces a \n.B gmon.out\nfile at normal termination.\nAlso, a profiling library is searched, in lieu of the standard C library.\nAn execution profile can then be generated with\n.IR gprof (1).\n.I lcc\nwarns when\n.B \\-pg\nis unsupported.\n.TP\n.BI \\-t name\n.br\n.ns\n.TP\n.BI \\-t\nProduce code to print the name of the function, an activation number,\nand the name and value of each argument at function entry.\nAt function exit, produce code to print\nthe name of the function, the activation number, and the return value.\nBy default,\n.I printf\ndoes the printing; if\n.I name\nappears, it does.\nFor null\n.I char*\nvalues, \"(null)\" is printed. \n.BI \\-target\n.I name\nis accepted, but ignored.\n.TP\n.BI \\-tempdir= dir\nStore temporary files in the directory\n.I dir/\nor\n.I\ndir\\\\.\nThe default is usually\n.BR /tmp .\n.TP\n.BI \\-W xarg\npass argument\n.I arg\nto the program indicated by\n.IR x ;\n.I x\ncan be one of\n.BR p ,\n.BR f ,\n.BR a ,\nor\n.BR l ,\nwhich refer, respectively, to the preprocessor, the compiler proper,\nthe assembler, and the loader.\n.I arg\nis passed as given; if a\n.B \\-\nis expected, it must be given explicitly.\n.BI \\-Wo arg\nspecifies a system-specific option,\n.IR arg .\n.PP\nOther arguments\nare taken to be either loader option arguments, or C-compatible\nobject programs, typically produced by an earlier\n.I lcc\nrun, or perhaps libraries of C-compatible routines.\nDuplicate object files are ignored.\nThese programs, together with the results of any\ncompilations specified, are loaded (in the order\ngiven) to produce an executable program with name\n.BR a.out\n(UNIX) or\n.BR a.exe\n(Windows).\n.PP\n.I lcc\nassigns the most frequently referenced scalar parameters and\nlocals to registers whenever possible.\nFor each block,\nexplicit register declarations are obeyed first;\nremaining registers are assigned to automatic locals if they\nare `referenced' at least 3 times.\nEach top-level occurrence of an identifier\ncounts as 1 reference. Occurrences in a loop,\neither of the then/else arms of an if statement, or a case\nin a switch statement each count, respectively, as 10, 1/2, or 1/10 references.\nThese values are adjusted accordingly for nested control structures.\n.B \\-Wf\\-a\ncauses\n.I lcc\nto read a\n.B prof.out\nfile from a previous execution and to use the data therein\nto compute reference counts (see\n.BR \\-b ).\n.PP\n.I lcc\nis a cross compiler;\n.BI \\-Wf\\-target= target/os\ncauses\n.I lcc\nto generate code for\n.I target\nrunning the operating system denoted by\n.IR os .\nThe supported\n.I target/os\ncombinations may include\n.PP\n.RS\n.ta \\w'sparc/solarisxx'u\n.nf\nalpha/osf\tALPHA, OSF 3.2\nmips/irix\tbig-endian MIPS, IRIX 5.2\nmips/ultrix\tlittle-endian MIPS, ULTRIX 4.3\nsparc/solaris\tSPARC, Solaris 2.3\nx86/win32\tx86, Windows NT 4.0/Windows 95/98\nx86/linux\tx86, Linux\nsymbolic\ttext rendition of the generated code\nnull\t\tno output\n.fi\n.RE\n.PP\nFor\n.BR \\-Wf\\-target=symbolic ,\nthe option\n.B \\-Wf-html\ncauses the text rendition to be emitted as HTML.\n.B \n.SH LIMITATIONS\n.PP\n.I lcc\naccepts the C programming language\nas described in the ANSI standard.\nIf\n.I lcc\nis used with the GNU C preprocessor, the\n.B \\-Wp\\-trigraphs\noption is required to enable trigraph sequences.\n.PP\nPlain int bit fields are signed.\nBit fields are aligned like unsigned integers but are otherwise laid out\nas by most standard C compilers.\nSome compilers, such as the GNU C compiler,\nmay choose other, incompatible layouts.\n.PP\nLikewise, calling conventions are intended to be compatible with\nthe host C compiler,\nexcept possibly for passing and returning structures.\nSpecifically,\n.I lcc\npasses and returns structures like host ANSI C compilers\non most targets, but some older host C compilers use different conventions.\nConsequently, calls to/from such functions compiled with\nolder C compilers may not work.\nCalling a function that returns\na structure without declaring it as such violates\nthe ANSI standard and may cause a fault.\n.SH FILES\n.PP\nThe file names listed below are\n.IR typical ,\nbut vary among installations; installation-dependent variants\ncan be displayed by running\n.I lcc\nwith the\n.B \\-v\noption.\n.PP\n.RS\n.ta \\w'$LCCDIR/liblcc.{a,lib}XX'u\n.nf\nfile.{c,C}\tinput file\nfile.{s,asm}\tassembly-language file\nfile.{o,obj}\tobject file\na.{out,exe}\tloaded output\n/tmp/lcc*\ttemporary files\n$LCCDIR/cpp\tpreprocessor\n$LCCDIR/rcc\tcompiler\n$LCCDIR/liblcc.{a,lib}\t\\fIlcc\\fP-specific library\n/lib/crt0.o\truntime startup (UNIX)\n/lib/[gm]crt0.o\tstartups for profiling (UNIX)\n/lib/libc.a\tstandard library (UNIX)\n$LCCDIR/include\tANSI standard headers\n/usr/local/include\tlocal headers\n/usr/include\ttraditional headers\nprof.out\tfile produced for \\fIbprint\\fR(1)\nmon.out\tfile produced for \\fIprof\\fR(1)\ngmon.out\tfile produced for \\fIgprof\\fR(1)\n.fi\n.RE\n.PP\n.I lcc\npredefines the macro\n.B __LCC__\non all systems.\nIt may also predefine some installation-dependent symbols; option\n.B \\-v\nexposes them.\n.SH \"SEE ALSO\"\n.PP\nC. W. Fraser and D. R. Hanson,\n.I A Retargetable C Compiler: Design and Implementation,\nAddison-Wesley, 1995. ISBN 0-8053-1670-1.\n.PP\nThe World-Wide Web page at http://www.cs.princeton.edu/software/lcc/.\n.PP\nS. P. Harbison and G. L. Steele, Jr.,\n.I C: A Reference Manual,\n4th ed., Prentice-Hall, 1995.\n.PP\nB. W. Kernighan and D. M. Ritchie,\n.I The C Programming Language,\n2nd ed., Prentice-Hall, 1988.\n.PP\nAmerican National Standards Inst.,\n.I American National Standard for Information Systems\\(emProgramming\n.IR Language\\(emC ,\nANSI X3.159-1989, New York, 1990.\n.br\n.SH BUGS\nMail bug reports along with the shortest preprocessed program\nthat exposes them and the details reported by\n.IR lcc 's\n.B \\-v\noption to lcc-bugs@princeton.edu. The WWW page at\nURL http://www.cs.princeton.edu/software/lcc/\nincludes detailed instructions for reporting bugs.\n.PP\nThe ANSI standard headers conform to the specifications in\nthe Standard, which may be too restrictive for some applications,\nbut necessary for portability.\nFunctions given in the ANSI headers may be missing from\nsome local C libraries (e.g., wide-character functions)\nor may not correspond exactly to the local versions;\nfor example, the ANSI standard\nstdio.h\nspecifies that\n.IR printf ,\n.IR fprintf ,\nand\n.I sprintf\nreturn the number of characters written to the file or array,\nbut some existing libraries don't implement this convention.\n.PP\nOn the MIPS and SPARC, old-style variadic functions must use\nvarargs.h\nfrom MIPS or Sun. New-style is recommended.\n.PP\nWith\n.BR \\-b ,\nfiles compiled\n.I without\n.B \\-b\nmay cause\n.I bprint\nto print erroneous call graphs.\nFor example, if\n.B f\ncalls\n.B g\ncalls\n.B h\nand\n.B f\nand\n.B h\nare compiled with\n.BR \\-b ,\nbut\n.B g\nis not,\n.B bprint\nwill report that\n.B f\ncalled\n.BR h .\nThe total number of calls is correct, however.\n"
  },
  {
    "path": "lcc/etc/bprint.c",
    "content": "#include <assert.h>\n#include <ctype.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n/* bprint [ -c | -Idir... | -f | -b | -n ] [ file... ]\n * annotate listings of files with prof.out data\n */\n\n\n#define NDIRS (sizeof dirs/sizeof dirs[0] - 1)\n#define NEW(p,a) ((p) = alloc(sizeof *(p)))\n#define newarray(m,n,a) alloc((m)*(n))\n#define NELEMS(a) ((int)(sizeof (a)/sizeof ((a)[0])))\n\n#define MAXTOKEN 64\n\nstruct count {\t\t\t/* count data: */\n\tint x, y;\t\t\t/* source coordinate */\n\tint count;\t\t\t/* associated execution count */\n};\n\nchar *progname;\nint number;\nchar *dirs[20];\nint fcount;\n\nstruct file {\t\t\t/* per-file prof.out data: */\n\tstruct file *link;\t\t/* link to next file */\n\tchar *name;\t\t\t/* file name */\n\tint size;\t\t\t/* size of counts[] */\n\tint count;\t\t\t/* counts[0..count-1] hold valid data */\n\tstruct count *counts;\t\t/* count data */\n\tstruct func {\t\t\t/* function data: */\n\t\tstruct func *link;\t\t/* link to next function */\n\t\tchar *name;\t\t\t/* function name */\n\t\tstruct count count;\t\t/* total number of calls */\n\t\tstruct caller {\t\t/* caller data: */\n\t\t\tstruct caller *link;\t/* link to next caller */\n\t\t\tchar *name;\t\t/* caller's name */\n\t\t\tchar *file;\t\t/* call site: file, x, y */\n\t\t\tint x, y;\n\t\t\tint count;\t\t/* number of calls from this site */\n\t\t} *callers;\n\t} *funcs;\t\t\t/* list of functions */\n} *filelist;\nFILE *fp;\n\nextern int process(char *);\nextern int findfunc(char *, char *);\nextern int findcount(char *, int, int);\n\nvoid *alloc(unsigned);\nchar *string(char *);\nint process(char *);\nvoid emitdata(char *);\nvoid printfile(struct file *, int);\nvoid printfuncs(struct file *, int);\n\n/* alloc - allocate n bytes or die */\nvoid *alloc(unsigned n) {\n\tvoid *new = malloc(n);\n\n\tassert(new);\n\treturn new;\n}\n\n/* emitdata - write prof.out data to file */\nvoid emitdata(char *file) {\n\tFILE *fp;\n\n\tif (fp = fopen(file, \"w\")) {\n\t\tstruct file *p;\n\t\tfor (p = filelist; p; p = p->link) {\n\t\t\tint i;\n\t\t\tstruct func *q;\n\t\t\tstruct caller *r;\n\t\t\tfprintf(fp, \"1\\n%s\\n\", p->name);\n\t\t\tfor (i = 0, q = p->funcs; q; i++, q = q->link)\n\t\t\t\tif (r = q->callers)\n\t\t\t\t\tfor (i--; r; r = r->link)\n\t\t\t\t\t\ti++;\n\t\t\tfprintf(fp, \"%d\\n\", i);\n\t\t\tfor (q = p->funcs; q; q = q->link)\n\t\t\t\tif (q->count.count == 0 || !q->callers)\n\t\t\t\t\tfprintf(fp, \"%s 1 %d %d %d ? ? 0 0\\n\", q->name, q->count.x,\n\t\t\t\t\t\tq->count.y, q->count.count);\n\t\t\t\telse\n\t\t\t\t\tfor (r = q->callers; r; r = r->link)\n\t\t\t\t\t\tfprintf(fp, \"%s 1 %d %d %d %s %s %d %d\\n\", q->name, q->count.x,\n\t\t\t\t\t\t\tq->count.y, r->count, r->name, r->file, r->x, r->y);\n\t\t\tfprintf(fp, \"%d\\n\", p->count);\n\t\t\tfor (i = 0; i < p->count; i++)\n\t\t\t\tfprintf(fp, \"1 %d %d %d\\n\", p->counts[i].x,\n\t\t\t\t\tp->counts[i].y, p->counts[i].count);\n\t\t}\n\t\tfclose(fp);\n\t} else\n\t\tfprintf(stderr, \"%s: can't create `%s'\\n\", progname, file);\n}\n\n/* openfile - open name for reading, searching -I directories */\nFILE *openfile(char *name) {\n\tint i;\n\tFILE *fp;\n\n\tif (*name != '/')\t\n\t\tfor (i = 0; dirs[i]; i++) {\n\t\t\tchar buf[200];\n\t\t\tsprintf(buf, \"%s/%s\", dirs[i], name);\n\t\t\tif (fp = fopen(buf, \"r\"))\n\t\t\t\treturn fp;\n\t\t}\n\treturn fopen(name, \"r\");\n}\n\n/* printfile - print annotated listing for p */\nvoid printfile(struct file *p, int nf) {\n\tint lineno;\n\tFILE *fp;\n\tchar *s, buf[512];\n\tstruct count *u = p->counts, *r, *uend;\n\n\tif (u == 0 || p->count <= 0)\n\t\treturn;\n\tuend = &p->counts[p->count];\n\tif ((fp = openfile(p->name)) == NULL) {\n\t\tfprintf(stderr, \"%s: can't open `%s'\\n\", progname, p->name);\n\t\treturn;\n\t}\n\tif (nf)\n\t\tprintf(\"%s%s:\\n\\n\", nf == 1 ? \"\" : \"\\f\", p->name);\n\tfor (lineno = 1; fgets(buf, sizeof buf, fp); lineno++) {\n\t\tif (number)\n\t\t\tprintf(\"%d\\t\", lineno);\n\t\twhile (u < uend && u->y < lineno)\n\t\t\tu++;\n\t\tfor (s = buf; *s; ) {\n\t\t\tchar *t = s + 1;\n\t\t\twhile (u < uend && u->y == lineno && u->x < s - buf)\n\t\t\t\tu++;\n\t\t\tif (isalnum(*s) || *s == '_')\n\t\t\t\twhile (isalnum(*t) || *t == '_')\n\t\t\t\t\tt++;\n\t\t\twhile (u < uend && u->y == lineno && u->x < t - buf) {\n\t\t\t\tprintf(\"<%d>\", u->count);\n\t\t\t\tfor (r = u++; u < uend && u->x == r->x && u->y == r->y && u->count == r->count; u++)\n\t\t\t\t\t;\n\t\t\t}\n\t\t\twhile (s < t)\n\t\t\t\tputchar(*s++);\n\t\t}\n\t\tif (*s)\n\t\t\tprintf(\"%s\", s);\n\t}\n\tfclose(fp);\n}\n\n/* printfuncs - summarize data for functions in p */\nvoid printfuncs(struct file *p, int nf) {\n\tstruct func *q;\n\n\tif (nf)\n\t\tprintf(\"%s:\\n\", p->name);\n\tfor (q = p->funcs; q; q = q->link)\n\t\tif (fcount <= 1 || q->count.count == 0 || !q->callers)\n\t\t\tprintf(\"%d\\t%s\\n\", q->count.count, q->name);\n\t\telse {\n\t\t\tstruct caller *r;\n\t\t\tfor (r = q->callers; r; r = r->link)\n\t\t\t\tprintf(\"%d\\t%s\\tfrom %s\\tin %s:%d.%d\\n\", r->count, q->name, r->name,\n\t\t\t\t\tr->file, r->y, r->x + 1);\n\t\t}\n\t\t\n}\n\n/* string - save a copy of str, if necessary */\nchar *string(char *str) {\n\tstatic struct string { struct string *link; char str[1]; } *list;\n\tstruct string *p;\n\n\tfor (p = list; p; p = p->link)\n\t\tif (strcmp(p->str, str) == 0)\n\t\t\treturn p->str;\n\tp = (struct string *)alloc(strlen(str) + sizeof *p);\n\tstrcpy(p->str, str);\n\tp->link = list;\n\tlist = p;\n\treturn p->str;\n}\n/* acaller - add caller and site (file,x,y) to callee's callers list */\nstatic void acaller(char *caller, char *file, int x, int y, int count, struct func *callee) {\n\tstruct caller *q;\n\n\tassert(callee);\n\tfor (q = callee->callers; q && (caller != q->name\n\t\t|| file != q->file || x != q->x || y != q->y); q = q->link)\n\t\t;\n\tif (!q) {\n\t\tstruct caller **r;\n\t\tNEW(q, PERM);\n\t\tq->name = caller;\n\t\tq->file = file;\n\t\tq->x = x;\n\t\tq->y = y;\n\t\tq->count = 0;\n\t\tfor (r = &callee->callers; *r && (strcmp(q->name, (*r)->name) > 0\n\t\t\t|| strcmp(q->file, (*r)->file) > 0 || q->y > (*r)->y || q->y > (*r)->y); r = &(*r)->link)\n\t\t\t;\n\t\tq->link = *r;\n\t\t*r = q;\n\t}\n\tq->count += count;\n}\n\n/* compare - return <0, 0, >0 if a<b, a==b, a>b, resp. */\nstatic int compare(struct count *a, struct count *b) {\n\tif (a->y == b->y)\n\t\treturn a->x - b->x;\n\treturn a->y - b->y;\n}\n\n/* findfile - return file name's file list entry, or 0 */\nstatic struct file *findfile(char *name) {\n\tstruct file *p;\n\n\tfor (p = filelist; p; p = p->link)\n\t\tif (p->name == name)\n\t\t\treturn p;\n\treturn 0;\n}\n\n/* afunction - add function name and its data to file's function list */\nstatic struct func *afunction(char *name, char *file, int x, int y, int count) {\n\tstruct file *p = findfile(file);\n\tstruct func *q;\n\n\tassert(p);\n\tfor (q = p->funcs; q && name != q->name; q = q->link)\n\t\t;\n\tif (!q) {\n\t\tstruct func **r;\n\t\tNEW(q, PERM);\n\t\tq->name = name;\n\t\tq->count.x = x;\n\t\tq->count.y = y;\n\t\tq->count.count = 0;\n\t\tq->callers = 0;\n\t\tfor (r = &p->funcs; *r && compare(&q->count, &(*r)->count) > 0; r = &(*r)->link)\n\t\t\t;\n\t\tq->link = *r;\n\t\t*r = q;\n\t}\n\tq->count.count += count;\n\treturn q;\n}\n\n/* apoint - append execution point i to file's data */ \nstatic void apoint(int i, char *file, int x, int y, int count) {\n\tstruct file *p = findfile(file);\n\n\tassert(p);\n\tif (i >= p->size) {\n\t\tint j;\n\t\tif (p->size == 0) {\n\t\t\tp->size = i >= 200 ? 2*i : 200;\n\t\t\tp->counts = newarray(p->size, sizeof *p->counts, PERM);\n\t\t} else {\n\t\t\tstruct count *new;\n\t\t\tp->size = 2*i;\n\t\t\tnew = newarray(p->size, sizeof *new, PERM);\n\t\t\tfor (j = 0; j < p->count; j++)\n\t\t\t\tnew[j] = p->counts[j];\n\t\t\tp->counts = new;\n\t\t}\n\t\tfor (j = p->count; j < p->size; j++) {\n\t\t\tstatic struct count z;\n\t\t\tp->counts[j] = z;\n\t\t}\n\t}\n\tp->counts[i].x = x;\n\tp->counts[i].y = y;\n\tp->counts[i].count += count;\n\tif (i >= p->count)\n\t\tp->count = i + 1;\n}\n\n/* findcount - return count associated with (file,x,y) or -1 */\nint findcount(char *file, int x, int y) {\n\tstatic struct file *cursor;\n\n\tif (cursor == 0 || cursor->name != file)\n\t\tcursor = findfile(file);\n\tif (cursor) {\n\t\tint l, u;\n\t\tstruct count *c = cursor->counts;\n\t\tfor (l = 0, u = cursor->count - 1; l <= u; ) {\n\t\t\tint k = (l + u)/2;\n\t\t\tif (c[k].y > y || c[k].y == y && c[k].x > x)\n\t\t\t\tu = k - 1;\n\t\t\telse if (c[k].y < y || c[k].y == y && c[k].x < x)\n\t\t\t\tl = k + 1;\n\t\t\telse\n\t\t\t\treturn c[k].count;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/* findfunc - return count associated with function name in file or -1 */\nint findfunc(char *name, char *file) {\n\tstatic struct file *cursor;\n\n\tif (cursor == 0 || cursor->name != file)\n\t\tcursor = findfile(file);\n\tif (cursor) {\n\t\tstruct func *p;\n\t\tfor (p = cursor->funcs; p; p = p->link)\n\t\t\tif (p->name == name)\n\t\t\t\treturn p->count.count;\n\t}\n\treturn -1;\n}\n\n/* getd - read a nonnegative number */\nstatic int getd(void) {\n\tint c, n = 0;\n\n\twhile ((c = getc(fp)) != EOF && (c == ' ' || c == '\\n' || c == '\\t'))\n\t\t;\n\tif (c >= '0' && c <= '9') {\n\t\tdo\n\t\t\tn = 10*n + (c - '0');\n\t\twhile ((c = getc(fp)) >= '0' && c <= '9');\n\t\treturn n;\n\t}\n\treturn -1;\n}\n\n/* getstr - read a string */\nstatic char *getstr(void) {\n\tint c;\n\tchar buf[MAXTOKEN], *s = buf;\n\n\twhile ((c = getc(fp)) != EOF && c != ' ' && c != '\\n' && c != '\\t')\n\t\tif (s - buf < (int)sizeof buf - 2)\n\t\t\t*s++ = c;\n\t*s = 0;\n\treturn s == buf ? (char *)0 : string(buf);\n}\n\n/* gather - read prof.out data from fd */\nstatic int gather(void) {\n\tint i, nfiles, nfuncs, npoints;\n\tchar *files[64];\n\n\tif ((nfiles = getd()) < 0)\n\t\treturn 0;\n\tassert(nfiles < NELEMS(files));\n\tfor (i = 0; i < nfiles; i++) {\n\t\tif ((files[i] = getstr()) == 0)\n\t\t\treturn -1;\n\t\tif (!findfile(files[i])) {\n\t\t\tstruct file *new;\n\t\t\tNEW(new, PERM);\n\t\t\tnew->name = files[i];\n\t\t\tnew->size = new->count = 0;\n\t\t\tnew->counts = 0;\n\t\t\tnew->funcs = 0;\n\t\t\tnew->link = filelist;\n\t\t\tfilelist = new;\n\t\t}\n\t}\n\tif ((nfuncs = getd()) < 0)\n\t\treturn -1;\n\tfor (i = 0; i < nfuncs; i++) {\n\t\tstruct func *q;\n\t\tchar *name, *file;\n\t\tint f, x, y, count;\n\t\tif ((name = getstr()) == 0 || (f = getd()) <= 0\n\t\t|| (x = getd()) < 0 || (y = getd()) < 0 || (count = getd()) < 0)\n\t\t\treturn -1;\n\t\tq = afunction(name, files[f-1], x, y, count);\n\t\tif ((name = getstr()) == 0 || (file = getstr()) == 0\n\t\t|| (x = getd()) < 0 || (y = getd()) < 0)\n\t\t\treturn -1;\n\t\tif (*name != '?')\n\t\t\tacaller(name, file, x, y, count, q);\n\t}\n\tif ((npoints = getd()) < 0)\n\t\treturn -1;\n\tfor (i = 0; i < npoints; i++) {\n\t\tint f, x, y, count;\n\t\tif ((f = getd()) < 0 || (x = getd()) < 0 || (y = getd()) < 0\n\t\t|| (count = getd()) < 0)\n\t\t\treturn -1;\n\t\tif (f)\n\t\t\tapoint(i, files[f-1], x, y, count);\n\t}\n\treturn 1;\n}\n\n/* process - read prof.out data from file */\nint process(char *file) {\n\tint more;\n\n\tif ((fp = fopen(file, \"r\")) != NULL) {\n\t\tstruct file *p;\n\t\twhile ((more = gather()) > 0)\n\t\t\t;\n\t\tfclose(fp);\n\t\tif (more < 0)\n\t\t\treturn more;\n\t\tfor (p = filelist; p; p = p->link)\n\t\t\tqsort(p->counts, p->count, sizeof *p->counts,\n\t\t\t\t(int (*)(const void *, const void *))\n\t\t\t\tcompare);\n\t\t\n\t\treturn 1;\n\t}\n\treturn 0;\n}\nint main(int argc, char *argv[]) {\n\tint i;\n\tstruct file *p;\n\tvoid (*f)(struct file *, int) = printfile;\n\n\tprogname = argv[0];\n\tif ((i = process(\"prof.out\")) <= 0) {\n\t\tfprintf(stderr, \"%s: can't %s `%s'\\n\", progname,\n\t\t\ti == 0 ? \"open\" : \"interpret\", \"prof.out\");\n\t\texit(1);\n\t}\n\tfor (i = 1; i < argc && *argv[i] == '-'; i++)\n\t\tif (strcmp(argv[i], \"-c\") == 0) {\n\t\t\temitdata(\"prof.out\"); \n\t\t\texit(0);\n\t\t} else if (strcmp(argv[i], \"-b\") == 0)\n\t\t\tf = printfile;\n\t\telse if (strcmp(argv[i], \"-f\") == 0) {\n\t\t\tfcount++;\n\t\t\tf = printfuncs;\n\t\t} else if (strcmp(argv[i], \"-n\") == 0)\n\t\t\tnumber++;\n\t\telse if (strncmp(argv[i], \"-I\", 2) == 0) {\n\t\t\tint j;\n\t\t\tfor (j = 0; j < NDIRS && dirs[j]; j++)\n\t\t\t\t;\n\t\t\tif (j < NDIRS)\n\t\t\t\tdirs[j] = &argv[i][2];\n\t\t\telse\n\t\t\t\tfprintf(stderr, \"%s: too many -I options\\n\", progname);\n\t\t} else {\n\t\t\tfprintf(stderr, \"usage: %s [ -c | -b | -n | -f | -Idir... ] [ file... ]\\n\", progname);\n\t\t\texit(1);\n\t\t}\n\tfor (p = filelist; p; p = p->link)\n\t\tqsort(p->counts, p->count, sizeof *p->counts,\n\t\t\t(int (*)(const void *, const void *))compare);\n\tif (i < argc) {\n\t\tint nf = i < argc - 1 ? 1 : 0;\n\t\tfor ( ; i < argc; i++, nf ? nf++ : 0)\n\t\t\tif (p = findfile(string(argv[i])))\n\t\t\t\t(*f)(p, nf);\n\t\t\telse\n\t\t\t\tfprintf(stderr, \"%s: no data for `%s'\\n\", progname, argv[i]);\n\t} else {\n\t\tint nf = filelist && filelist->link ? 1 : 0;\n\t\tfor (p = filelist; p; p = p->link, nf ? nf++ : 0)\n\t\t\t(*f)(p, nf);\n\t}\n\treturn 0;\n}\n\n"
  },
  {
    "path": "lcc/etc/gcc-solaris.c",
    "content": "/* SPARCs running Solaris 2.5.1 w/GCC tools\n   at CS Dept., Princeton University */\n\n#include <string.h>\n\n\n#ifndef LCCDIR\n#define LCCDIR \"/usr/local/lib/lcc/\"\n#endif\n#ifndef GCCDIR\n#define GCCDIR \"/usr/local/gnu/bin/\"\n#endif\n#ifndef GCCLIB\n#define GCCLIB \"/usr/local/gnu/lib/gcc-lib/sparc-sun-solaris2.5/2.7.2/\"\n#endif\n\nchar *suffixes[] = { \".c\", \".i\", \".s\", \".o\", \".out\", 0 };\nchar inputs[256] = \"\";\nchar *cpp[] = { LCCDIR \"cpp\",\n\t\"-D__STDC__=1\", \"-Dsparc\", \"-D__sparc__\", \"-Dsun\", \"-D__sun__\", \"-Dunix\",\n\t\"$1\", \"$2\", \"$3\", 0 };\nchar *include[] = { \"-I\" LCCDIR \"include\", \"-I/usr/local/include\",\n\t\"-I\" GCCLIB \"include\", \"-I/usr/include\", 0 };\nchar *com[] = { LCCDIR \"rcc\", \"-target=sparc/solaris\",\n\t\"$1\", \"$2\", \"$3\", 0 };\nchar *as[] = { GCCDIR \"as\", \"-f\", \"-o\", \"$3\", \"$1\", \"$2\", 0 };\nchar *ld[] = { GCCDIR \"ld\", \"-o\", \"$3\", \"$1\",\n\tGCCLIB \"crti.o\", GCCLIB \"crt1.o\",\n\tGCCLIB \"crtbegin.o\", \"$2\", \"\", \"\", \"-L\" LCCDIR, \"-llcc\",\n\t\"-L\" GCCLIB, \"-lgcc\", \"-lm\", \"-lc\", \"\",\n\tGCCLIB \"crtend.o\", GCCLIB \"crtn.o\", 0 };\n\nextern char *concat(char *, char *);\n\nint option(char *arg) {\n\tif (strncmp(arg, \"-lccdir=\", 8) == 0) {\n\t\tcpp[0] = concat(&arg[8], \"/cpp\");\n\t\tinclude[0] = concat(\"-I\", concat(&arg[8], \"/include\"));\n\t\tld[10] = concat(\"-L\", &arg[8]);\n\t\tcom[0] = concat(&arg[8], \"/rcc\");\n\t} else if (strcmp(arg, \"-g\") == 0)\n\t\t;\n\telse if (strcmp(arg, \"-pg\") == 0) {\n\t\tld[8] = GCCLIB \"gmon.o\";\n\t} else if (strcmp(arg, \"-b\") == 0)\n\t\t;\n\telse\n\t\treturn 0;\n\treturn 1;\n}\n"
  },
  {
    "path": "lcc/etc/irix.c",
    "content": "/* SGI big endian MIPSes running IRIX 5.2 at CS Dept., Princeton University */\n\n#include <string.h>\n\n\n#ifndef LCCDIR\n#define LCCDIR \"/usr/local/lib/lcc/\"\n#endif\n\nchar *suffixes[] = { \".c\", \".i\", \".s\", \".o\", \".out\", 0 };\nchar inputs[256] = \"\";\nchar *cpp[] = { LCCDIR \"cpp\", \"-D__STDC__=1\",\n\t\"-DLANGUAGE_C\",\n\t\"-DMIPSEB\",\n\t\"-DSYSTYPE_SVR4\",\n\t\"-D_CFE\",\n\t\"-D_LANGUAGE_C\",\n\t\"-D_MIPSEB\",\n\t\"-D_MIPS_FPSET=16\",\n\t\"-D_MIPS_ISA=_MIPS_ISA_MIPS1\",\n\t\"-D_MIPS_SIM=_MIPS_SIM_ABI32\",\n\t\"-D_MIPS_SZINT=32\",\n\t\"-D_MIPS_SZLONG=32\",\n\t\"-D_MIPS_SZPTR=32\",\n\t\"-D_SGI_SOURCE\",\n\t\"-D_SVR4_SOURCE\",\n\t\"-D_SYSTYPE_SVR4\",\n\t\"-D__host_mips\",\n\t\"-D__mips=1\",\n\t\"-D__sgi\",\n\t\"-D__unix\",\n\t\"-Dhost_mips\",\n\t\"-Dmips\",\n\t\"-Dsgi\",\n\t\"-Dunix\",\n\t\"$1\", \"$2\", \"$3\", 0 };\nchar *com[] =  { LCCDIR \"rcc\", \"-target=mips/irix\", \"$1\", \"$2\", \"$3\", \"\", 0 };\nchar *include[] = { \"-I\" LCCDIR \"include\", \"-I/usr/local/include\",\n\t\"-I/usr/include\", 0 };\nchar *as[] = { \"/usr/bin/as\", \"-o\", \"$3\", \"$1\", \"-nocpp\", \"-KPIC\", \"$2\", 0 };\nchar *ld[] = { \"/usr/bin/ld\", \"-require_dynamic_link\", \"_rld_new_interface\",\n\t\"-elf\", \"-_SYSTYPE_SVR4\", \"-Wx,-G\", \"0\", \"-g0\", \"-KPIC\", \"-dont_warn_unused\",\n\t\"-o\", \"$3\", \"/usr/lib/crt1.o\", \"-L/usr/local/lib\",\n\t\"$1\", \"$2\", \"\", \"-L\" LCCDIR, \"-llcc\", \"-lc\", \"-lm\", \"/usr/lib/crtn.o\", 0\n};\n\nextern char *concat(char *, char *);\n\nint option(char *arg) {\n\tif (strncmp(arg, \"-lccdir=\", 8) == 0) {\n\t\tcpp[0] = concat(&arg[8], \"/cpp\");\n\t\tinclude[0] = concat(\"-I\", concat(&arg[8], \"/include\"));\n\t\tcom[0] = concat(&arg[8], \"/rcc\");\n\t\tld[17] = concat(\"-L\", &arg[8]);\n\t} else if (strcmp(arg, \"-g\") == 0)\n\t\t;\n\telse if (strcmp(arg, \"-p\") == 0)\n\t\tld[12] = \"/usr/lib/mcrt1.o\";\n\telse if (strcmp(arg, \"-b\") == 0)\n\t\t;\n\telse\n\t\treturn 0;\n\treturn 1;\n}\n"
  },
  {
    "path": "lcc/etc/lcc.c",
    "content": "/*\n * lcc [ option ]... [ file | -llib ]...\n * front end for the ANSI C compiler\n */\nstatic char rcsid[] = \"Id: dummy rcsid\";\n\n#include <stdio.h>\n#include <stdarg.h>\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n#include <ctype.h>\n#include <signal.h>\n\n#ifndef TEMPDIR\n#define TEMPDIR \"/tmp\"\n#endif\n\ntypedef struct list *List;\nstruct list {\t\t/* circular list nodes: */\n\tchar *str;\t\t/* option or file name */\n\tList link;\t\t/* next list element */\n};\n\nstatic void *alloc(int);\nstatic List append(char *,List);\nextern char *basepath(char *);\nstatic int callsys(char *[]);\nextern char *concat(char *, char *);\nstatic int compile(char *, char *);\nstatic void compose(char *[], List, List, List);\nstatic void error(char *, char *);\nstatic char *exists(char *);\nstatic char *first(char *);\nstatic int filename(char *, char *);\nstatic List find(char *, List);\nstatic void help(void);\nstatic void initinputs(void);\nstatic void interrupt(int);\nstatic void opt(char *);\nstatic List path2list(const char *);\nextern int main(int, char *[]);\nextern char *replace(const char *, int, int);\nstatic void rm(List);\nextern char *strsave(const char *);\nextern char *stringf(const char *, ...);\nextern int suffix(char *, char *[], int);\nextern char *tempname(char *);\n\nextern int access(char *, int);\nextern int getpid(void);\n\nextern char *cpp[], *include[], *com[], *as[],*ld[], inputs[], *suffixes[];\nextern int option(char *);\n\nstatic int errcnt;\t\t/* number of errors */\nstatic int Eflag;\t\t/* -E specified */\nstatic int Sflag;\t\t/* -S specified */\nstatic int cflag;\t\t/* -c specified */\nstatic int verbose;\t\t/* incremented for each -v */\nstatic List llist[2];\t\t/* loader files, flags */\nstatic List alist;\t\t/* assembler flags */\nstatic List clist;\t\t/* compiler flags */\nstatic List plist;\t\t/* preprocessor flags */\nstatic List ilist;\t\t/* list of additional includes from LCCINPUTS */\nstatic List rmlist;\t\t/* list of files to remove */\nstatic char *outfile;\t\t/* ld output file or -[cS] object file */\nstatic int ac;\t\t\t/* argument count */\nstatic char **av;\t\t/* argument vector */\nchar *tempdir = TEMPDIR;\t/* directory for temporary files */\nstatic char *progname;\nstatic List lccinputs;\t\t/* list of input directories */\n\nmain(int argc, char *argv[]) {\n\tint i, j, nf;\n\t\n\tprogname = argv[0];\n\tac = argc + 50;\n\tav = alloc(ac*sizeof(char *));\n\tif (signal(SIGINT, SIG_IGN) != SIG_IGN)\n\t\tsignal(SIGINT, interrupt);\n\tif (signal(SIGTERM, SIG_IGN) != SIG_IGN)\n\t\tsignal(SIGTERM, interrupt);\n#ifdef SIGHUP\n\tif (signal(SIGHUP, SIG_IGN) != SIG_IGN)\n\t\tsignal(SIGHUP, interrupt);\n#endif\n\tif (getenv(\"TMP\"))\n\t\ttempdir = getenv(\"TMP\");\n\telse if (getenv(\"TEMP\"))\n\t\ttempdir = getenv(\"TEMP\");\n\telse if (getenv(\"TMPDIR\"))\n\t\ttempdir = getenv(\"TMPDIR\");\n\tassert(tempdir);\n\ti = strlen(tempdir);\n\tfor (; i > 0 && tempdir[i-1] == '/' || tempdir[i-1] == '\\\\'; i--)\n\t\ttempdir[i-1] = '\\0';\n\tif (argc <= 1) {\n\t\thelp();\n\t\texit(0);\n\t}\n\tplist = append(\"-D__LCC__\", 0);\n\tinitinputs();\n\tif (getenv(\"LCCDIR\"))\n\t\toption(stringf(\"-lccdir=%s\", getenv(\"LCCDIR\")));\n\tfor (nf = 0, i = j = 1; i < argc; i++) {\n\t\tif (strcmp(argv[i], \"-o\") == 0) {\n\t\t\tif (++i < argc) {\n\t\t\t\tif (suffix(argv[i], suffixes, 2) >= 0) {\n\t\t\t\t\terror(\"-o would overwrite %s\", argv[i]);\n\t\t\t\t\texit(8);\n\t\t\t\t}\n\t\t\t\toutfile = argv[i];\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\terror(\"unrecognized option `%s'\", argv[i-1]);\n\t\t\t\texit(8);\n\t\t\t}\n\t\t} else if (strcmp(argv[i], \"-target\") == 0) {\n\t\t\tif (argv[i+1] && *argv[i+1] != '-')\n\t\t\t\ti++;\n\t\t\tcontinue;\n\t\t} else if (*argv[i] == '-' && argv[i][1] != 'l') {\n\t\t\topt(argv[i]);\n\t\t\tcontinue;\n\t\t} else if (*argv[i] != '-' && suffix(argv[i], suffixes, 3) >= 0)\n\t\t\tnf++;\n\t\targv[j++] = argv[i];\n\t}\n\tif ((cflag || Sflag) && outfile && nf != 1) {\n\t\tfprintf(stderr, \"%s: -o %s ignored\\n\", progname, outfile);\n\t\toutfile = 0;\n\t}\n\targv[j] = 0;\n\tfor (i = 0; include[i]; i++)\n\t\tplist = append(include[i], plist);\n\tif (ilist) {\n\t\tList b = ilist;\n\t\tdo {\n\t\t\tb = b->link;\n\t\t\tplist = append(b->str, plist);\n\t\t} while (b != ilist);\n\t}\n\tilist = 0;\n\tfor (i = 1; argv[i]; i++)\n\t\tif (*argv[i] == '-')\n\t\t\topt(argv[i]);\n\t\telse {\n\t\t\tchar *name = exists(argv[i]);\n\t\t\tif (name) {\n\t\t\t\tif (strcmp(name, argv[i]) != 0\n\t\t\t\t|| nf > 1 && suffix(name, suffixes, 3) >= 0)\n\t\t\t\t\tfprintf(stderr, \"%s:\\n\", name);\n\t\t\t\tfilename(name, 0);\n\t\t\t} else\n\t\t\t\terror(\"can't find `%s'\", argv[i]);\n\t\t}\n\tif (errcnt == 0 && !Eflag && !Sflag && !cflag && llist[1]) {\n\t\tcompose(ld, llist[0], llist[1],\n\t\t\tappend(outfile ? outfile : concat(\"a\", first(suffixes[4])), 0));\n\t\tif (callsys(av))\n\t\t\terrcnt++;\n\t}\n\trm(rmlist);\t\n\treturn errcnt ? EXIT_FAILURE : EXIT_SUCCESS;\n}\n\n/* alloc - allocate n bytes or die */\nstatic void *alloc(int n) {\n\tstatic char *avail, *limit;\n\t\n\tn = (n + sizeof(char *) - 1)&~(sizeof(char *) - 1);\n\tif (n >= limit - avail) {\n\t\tavail = malloc(n + 4*1024);\n\t\tassert(avail);\n\t\tlimit = avail + n + 4*1024;\n\t}\n\tavail += n;\n\treturn avail - n;\n}\n\n/* append - append a node with string str onto list, return new list */\t\nstatic List append(char *str, List list) {\n\tList p = alloc(sizeof *p);\n\n\tp->str = str;\n\tif (list) {\n\t\tp->link = list->link;\n\t\tlist->link = p;\n\t} else\n\t\tp->link = p;\n\treturn p;\n}\n\n/* basepath - return base name for name, e.g. /usr/drh/foo.c => foo */\nchar *basepath(char *name) {\n\tchar *s, *b, *t = 0;\n\n\tfor (b = s = name; *s; s++)\n\t\tif (*s == '/' || *s == '\\\\') {\n\t\t\tb = s + 1;\n\t\t\tt = 0;\n\t\t} else if (*s == '.')\n\t\t\tt = s;\n\ts = strsave(b);\n\tif (t)\n\t\ts[t-b] = 0;\n\treturn s;\n}\n\n#ifdef WIN32\n#include <process.h>\n#else\n#define _P_WAIT 0\nextern int fork(void);\nextern int wait(int *);\nextern void execv(const char *, char *[]);\n\nstatic int _spawnvp(int mode, const char *cmdname, char *argv[]) {\n\tint pid, n, status;\n\n\tswitch (pid = fork()) {\n\tcase -1:\n\t\tfprintf(stderr, \"%s: no more processes\\n\", progname);\n\t\treturn 100;\n\tcase 0:\n\t\t// TTimo removing hardcoded paths, searching in $PATH\n\t\texecvp(cmdname, argv);\n\t\tfprintf(stderr, \"%s: \", progname);\n\t\tperror(cmdname);\n\t\tfflush(stdout);\n\t\texit(100);\n\t}\n\twhile ((n = wait(&status)) != pid && n != -1)\n\t\t;\n\tif (n == -1)\n\t\tstatus = -1;\n\tif (status&0377) {\n\t\tfprintf(stderr, \"%s: fatal error in %s\\n\", progname, cmdname);\n\t\tstatus |= 0400;\n\t}\n\treturn (status>>8)&0377;\n}\n#endif\n\n/* callsys - execute the command described by av[0...], return status */\nstatic int callsys(char **av) {\n\tint i, status = 0;\n\tstatic char **argv;\n\tstatic int argc;\n\n\tfor (i = 0; av[i] != NULL; i++)\n\t\t;\n\tif (i + 1 > argc) {\n\t\targc = i + 1;\n\t\tif (argv == NULL)\n\t\t\targv = malloc(argc*sizeof *argv);\n\t\telse\n\t\t\targv = realloc(argv, argc*sizeof *argv);\n\t\tassert(argv);\n\t}\n\tfor (i = 0; status == 0 && av[i] != NULL; ) {\n\t\tint j = 0;\n\t\tchar *s;\n\t\tfor ( ; av[i] != NULL && (s = strchr(av[i], '\\n')) == NULL; i++)\n\t\t\targv[j++] = av[i];\n\t\tif (s != NULL) {\n\t\t\tif (s > av[i])\n\t\t\t\targv[j++] = stringf(\"%.*s\", s - av[i], av[i]);\n\t\t\tif (s[1] != '\\0')\n\t\t\t\tav[i] = s + 1;\n\t\t\telse\n\t\t\t\ti++;\n\t\t}\n\t\targv[j] = NULL;\n\t\tif (verbose > 0) {\n\t\t\tint k;\n\t\t\tfprintf(stderr, \"%s\", argv[0]);\n\t\t\tfor (k = 1; argv[k] != NULL; k++)\n\t\t\t\tfprintf(stderr, \" %s\", argv[k]);\n\t\t\tfprintf(stderr, \"\\n\");\n\t\t}\n\t\tif (verbose < 2)\n\t\t\tstatus = _spawnvp(_P_WAIT, argv[0], argv);\n\t\tif (status == -1) {\n\t\t\tfprintf(stderr, \"%s: \", progname);\n\t\t\tperror(argv[0]);\n\t\t}\n\t}\n\treturn status;\n}\n\n/* concat - return concatenation of strings s1 and s2 */\nchar *concat(char *s1, char *s2) {\n\tint n = strlen(s1);\n\tchar *s = alloc(n + strlen(s2) + 1);\n\n\tstrcpy(s, s1);\n\tstrcpy(s + n, s2);\n\treturn s;\n}\n\n/* compile - compile src into dst, return status */\nstatic int compile(char *src, char *dst) {\n\tcompose(com, clist, append(src, 0), append(dst, 0));\n\treturn callsys(av);\n}\n\n/* compose - compose cmd into av substituting a, b, c for $1, $2, $3, resp. */\nstatic void compose(char *cmd[], List a, List b, List c) {\n\tint i, j;\n\tList lists[3];\n\n\tlists[0] = a;\n\tlists[1] = b;\n\tlists[2] = c;\n\tfor (i = j = 0; cmd[i]; i++) {\n\t\tchar *s = strchr(cmd[i], '$');\n\t\tif (s && isdigit(s[1])) {\n\t\t\tint k = s[1] - '0';\n\t\t\tassert(k >=1 && k <= 3);\n\t\t\tif (b = lists[k-1]) {\n\t\t\t\tb = b->link;\n\t\t\t\tav[j] = alloc(strlen(cmd[i]) + strlen(b->str) - 1);\n\t\t\t\tstrncpy(av[j], cmd[i], s - cmd[i]);\n\t\t\t\tav[j][s-cmd[i]] = '\\0';\n\t\t\t\tstrcat(av[j], b->str);\n\t\t\t\tstrcat(av[j++], s + 2);\n\t\t\t\twhile (b != lists[k-1]) {\n\t\t\t\t\tb = b->link;\n\t\t\t\t\tassert(j < ac);\n\t\t\t\t\tav[j++] = b->str;\n\t\t\t\t};\n\t\t\t}\n\t\t} else if (*cmd[i]) {\n\t\t\tassert(j < ac);\n\t\t\tav[j++] = cmd[i];\n\t\t}\n\t}\n\tav[j] = NULL;\n}\n\n/* error - issue error msg according to fmt, bump error count */\nstatic void error(char *fmt, char *msg) {\n\tfprintf(stderr, \"%s: \", progname);\n\tfprintf(stderr, fmt, msg);\n\tfprintf(stderr, \"\\n\");\n\terrcnt++;\n}\n\n/* exists - if `name' readable return its path name or return null */\nstatic char *exists(char *name) {\n\tList b;\n\n\tif ( (name[0] == '/' || name[0] == '\\\\' || name[2] == ':')\n\t&& access(name, 4) == 0)\n\t\treturn name;\n\tif (!(name[0] == '/' || name[0] == '\\\\' || name[2] == ':')\n\t&& (b = lccinputs))\t\t\n\t\tdo {\n\t\t\tb = b->link;\n\t\t\tif (b->str[0]) {\n\t\t\t\tchar buf[1024];\n\t\t\t\tsprintf(buf, \"%s/%s\", b->str, name);\n\t\t\t\tif (access(buf, 4) == 0)\n\t\t\t\t\treturn strsave(buf);\n\t\t\t} else if (access(name, 4) == 0)\n\t\t\t\treturn name;\n\t\t} while (b != lccinputs);\n\tif (verbose > 1)\n\t\treturn name;\n\treturn 0;\n}\n\n/* first - return first component in semicolon separated list */\nstatic char *first(char *list) {\n\tchar *s = strchr(list, ';');\n\n\tif (s) {\n\t\tchar buf[1024];\n\t\tstrncpy(buf, list, s-list);\n\t\tbuf[s-list] = '\\0';\n\t\treturn strsave(buf);\n\t} else\n\t\treturn list;\n}\n\n/* filename - process file name argument `name', return status */\nstatic int filename(char *name, char *base) {\n\tint status = 0;\n\tstatic char *stemp, *itemp;\n\n\tif (base == 0)\n\t\tbase = basepath(name);\n\tswitch (suffix(name, suffixes, 4)) {\n\tcase 0:\t/* C source files */\n\t\tcompose(cpp, plist, append(name, 0), 0);\n\t\tif (Eflag) {\n\t\t\tstatus = callsys(av);\n\t\t\tbreak;\n\t\t}\n\t\tif (itemp == NULL)\n\t\t\titemp = tempname(first(suffixes[1]));\n\t\tcompose(cpp, plist, append(name, 0), append(itemp, 0));\n\t\tstatus = callsys(av);\n\t\tif (status == 0)\n\t\t\treturn filename(itemp, base);\n\t\tbreak;\n\tcase 1:\t/* preprocessed source files */\n\t\tif (Eflag)\n\t\t\tbreak;\n\t\tif (Sflag)\n\t\t\tstatus = compile(name, outfile ? outfile : concat(base, first(suffixes[2])));\n\t\telse if ((status = compile(name, stemp?stemp:(stemp=tempname(first(suffixes[2]))))) == 0)\n\t\t\treturn filename(stemp, base);\n\t\tbreak;\n\tcase 2:\t/* assembly language files */\n\t\tif (Eflag)\n\t\t\tbreak;\n\t\tif (!Sflag) {\n\t\t\tchar *ofile;\n\t\t\tif (cflag && outfile)\n\t\t\t\tofile = outfile;\n\t\t\telse if (cflag)\n\t\t\t\tofile = concat(base, first(suffixes[3]));\n\t\t\telse\n\t\t\t\tofile = tempname(first(suffixes[3]));\n\t\t\tcompose(as, alist, append(name, 0), append(ofile, 0));\n\t\t\tstatus = callsys(av);\n\t\t\tif (!find(ofile, llist[1]))\n\t\t\t\tllist[1] = append(ofile, llist[1]);\n\t\t}\n\t\tbreak;\n\tcase 3:\t/* object files */\n\t\tif (!find(name, llist[1]))\n\t\t\tllist[1] = append(name, llist[1]);\n\t\tbreak;\n\tdefault:\n\t\tif (Eflag) {\n\t\t\tcompose(cpp, plist, append(name, 0), 0);\n\t\t\tstatus = callsys(av);\n\t\t}\n\t\tllist[1] = append(name, llist[1]);\n\t\tbreak;\n\t}\n\tif (status)\n\t\terrcnt++;\n\treturn status;\n}\n\n/* find - find 1st occurrence of str in list, return list node or 0 */\nstatic List find(char *str, List list) {\n\tList b;\n\t\n\tif (b = list)\n\t\tdo {\n\t\t\tif (strcmp(str, b->str) == 0)\n\t\t\t\treturn b;\n\t\t} while ((b = b->link) != list);\n\treturn 0;\n}\n\n/* help - print help message */\nstatic void help(void) {\n\tstatic char *msgs[] = {\n\"\", \" [ option | file ]...\\n\",\n\"\texcept for -l, options are processed left-to-right before files\\n\",\n\"\tunrecognized options are taken to be linker options\\n\",\n\"-A\twarn about nonANSI usage; 2nd -A warns more\\n\",\n\"-b\temit expression-level profiling code; see bprint(1)\\n\",\n#ifdef sparc\n\"-Bstatic -Bdynamic\tspecify static or dynamic libraries\\n\",\n#endif\n\"-Bdir/\tuse the compiler named `dir/rcc'\\n\",\n\"-c\tcompile only\\n\",\n\"-dn\tset switch statement density to `n'\\n\",\n\"-Dname -Dname=def\tdefine the preprocessor symbol `name'\\n\",\n\"-E\trun only the preprocessor on the named C programs and unsuffixed files\\n\",\n\"-g\tproduce symbol table information for debuggers\\n\",\n\"-help or -?\tprint this message\\n\",\n\"-Idir\tadd `dir' to the beginning of the list of #include directories\\n\",\t\n\"-lx\tsearch library `x'\\n\",\n\"-N\tdo not search the standard directories for #include files\\n\",\n\"-n\temit code to check for dereferencing zero pointers\\n\",\n\"-O\tis ignored\\n\",\n\"-o file\tleave the output in `file'\\n\",\n\"-P\tprint ANSI-style declarations for globals\\n\",\n\"-p -pg\temit profiling code; see prof(1) and gprof(1)\\n\",\n\"-S\tcompile to assembly language\\n\",\n#ifdef linux\n\"-static\tspecify static libraries (default is dynamic)\\n\",\n#endif\n\"-t -tname\temit function tracing calls to printf or to `name'\\n\",\n\"-target name\tis ignored\\n\",\n\"-tempdir=dir\tplace temporary files in `dir/'\", \"\\n\"\n\"-Uname\tundefine the preprocessor symbol `name'\\n\",\n\"-v\tshow commands as they are executed; 2nd -v suppresses execution\\n\",\n\"-w\tsuppress warnings\\n\",\n\"-Woarg\tspecify system-specific `arg'\\n\",\n\"-W[pfal]arg\tpass `arg' to the preprocessor, compiler, assembler, or linker\\n\",\n\t0 };\n\tint i;\n\tchar *s;\n\n\tmsgs[0] = progname;\n\tfor (i = 0; msgs[i]; i++) {\n\t\tfprintf(stderr, \"%s\", msgs[i]);\n\t\tif (strncmp(\"-tempdir\", msgs[i], 8) == 0 && tempdir)\n\t\t\tfprintf(stderr, \"; default=%s\", tempdir);\n\t}\n#define xx(v) if (s = getenv(#v)) fprintf(stderr, #v \"=%s\\n\", s)\n\txx(LCCINPUTS);\n\txx(LCCDIR);\n#ifdef WIN32\n\txx(include);\n\txx(lib);\n#endif\n#undef xx\n}\n\n/* initinputs - if LCCINPUTS or include is defined, use them to initialize various lists */\nstatic void initinputs(void) {\n\tchar *s = getenv(\"LCCINPUTS\");\n\tList list, b;\n\n\tif (s == 0 || (s = inputs)[0] == 0)\n\t\ts = \".\";\n\tif (s) {\n\t\tlccinputs = path2list(s);\n\t\tif (b = lccinputs)\n\t\t\tdo {\n\t\t\t\tb = b->link;\n\t\t\t\tif (strcmp(b->str, \".\") != 0) {\n\t\t\t\t\tilist = append(concat(\"-I\", b->str), ilist);\n\t\t\t\t\tif (strstr(com[1], \"win32\") == NULL)\n\t\t\t\t\t\tllist[0] = append(concat(\"-L\", b->str), llist[0]);\n\t\t\t\t} else\n\t\t\t\t\tb->str = \"\";\n\t\t\t} while (b != lccinputs);\n\t}\n#ifdef WIN32\n\tif (list = b = path2list(getenv(\"include\")))\n\t\tdo {\n\t\t\tb = b->link;\n\t\t\tilist = append(stringf(\"-I\\\"%s\\\"\", b->str), ilist);\n\t\t} while (b != list);\n#endif\n}\n\n/* interrupt - catch interrupt signals */\nstatic void interrupt(int n) {\n\trm(rmlist);\n\texit(n = 100);\n}\n\n/* opt - process option in arg */\nstatic void opt(char *arg) {\n\tswitch (arg[1]) {\t/* multi-character options */\n\tcase 'W':\t/* -Wxarg */\n\t\tif (arg[2] && arg[3])\n\t\t\tswitch (arg[2]) {\n\t\t\tcase 'o':\n\t\t\t\tif (option(&arg[3]))\n\t\t\t\t\treturn;\n\t\t\t\tbreak;\n\t\t\tcase 'p':\n\t\t\t\tplist = append(&arg[3], plist);\n\t\t\t\treturn;\n\t\t\tcase 'f':\n\t\t\t\tif (strcmp(&arg[3], \"-C\") || option(\"-b\")) {\n\t\t\t\t\tclist = append(&arg[3], clist);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tbreak; /* and fall thru */\n\t\t\tcase 'a':\n\t\t\t\talist = append(&arg[3], alist);\n\t\t\t\treturn;\n\t\t\tcase 'l':\n\t\t\t\tllist[0] = append(&arg[3], llist[0]);\n\t\t\t\treturn;\n\t\t\t}\n\t\tfprintf(stderr, \"%s: %s ignored\\n\", progname, arg);\n\t\treturn;\n\tcase 'd':\t/* -dn */\n\t\targ[1] = 's';\n\t\tclist = append(arg, clist);\n\t\treturn;\n\tcase 't':\t/* -t -tname -tempdir=dir */\n\t\tif (strncmp(arg, \"-tempdir=\", 9) == 0)\n\t\t\ttempdir = arg + 9;\n\t\telse\n\t\t\tclist = append(arg, clist);\n\t\treturn;\n\tcase 'p':\t/* -p -pg */\n\t\tif (option(arg))\n\t\t\tclist = append(arg, clist);\n\t\telse\n\t\t\tfprintf(stderr, \"%s: %s ignored\\n\", progname, arg);\n\t\treturn;\n\tcase 'D':\t/* -Dname -Dname=def */\n\tcase 'U':\t/* -Uname */\n\tcase 'I':\t/* -Idir */\n\t\tplist = append(arg, plist);\n\t\treturn;\n\tcase 'B':\t/* -Bdir -Bstatic -Bdynamic */\n#ifdef sparc\n\t\tif (strcmp(arg, \"-Bstatic\") == 0 || strcmp(arg, \"-Bdynamic\") == 0)\n\t\t\tllist[1] = append(arg, llist[1]);\n\t\telse\n#endif\t\n\t\t{\n\t\tstatic char *path;\n\t\tif (path)\n\t\t\terror(\"-B overwrites earlier option\", 0);\n\t\tpath = arg + 2;\n\t\tif (strstr(com[1], \"win32\") != NULL)\n\t\t\tcom[0] = concat(replace(path, '/', '\\\\'), concat(\"rcc\", first(suffixes[4])));\n\t\telse\n\t\t\tcom[0] = concat(path, \"rcc\");\n\t\tif (path[0] == 0)\n\t\t\terror(\"missing directory in -B option\", 0);\n\t\t}\n\t\treturn;\n\tcase 'h':\n\t\tif (strcmp(arg, \"-help\") == 0) {\n\t\t\tstatic int printed = 0;\n\tcase '?':\n\t\t\tif (!printed)\n\t\t\t\thelp();\n\t\t\tprinted = 1;\n\t\t\treturn;\n\t\t}\n#ifdef linux\n\tcase 's':\n\t\tif (strcmp(arg,\"-static\") == 0) {\n\t\t\tif (!option(arg))\n\t\t\t\tfprintf(stderr, \"%s: %s ignored\\n\", progname, arg);\n\t\t\treturn;\n\t\t}\n#endif         \n\t}\n\tif (arg[2] == 0)\n\t\tswitch (arg[1]) {\t/* single-character options */\n\t\tcase 'S':\n\t\t\tSflag++;\n\t\t\treturn;\n\t\tcase 'O':\n\t\t\tfprintf(stderr, \"%s: %s ignored\\n\", progname, arg);\n\t\t\treturn;\n\t\tcase 'A': case 'n': case 'w': case 'P':\n\t\t\tclist = append(arg, clist);\n\t\t\treturn;\n\t\tcase 'g': case 'b':\n\t\t\tif (option(arg))\n\t\t\t\tclist = append(arg[1] == 'g' ? \"-g2\" : arg, clist);\n\t\t\telse\n\t\t\t\tfprintf(stderr, \"%s: %s ignored\\n\", progname, arg);\n\t\t\treturn;\n\t\tcase 'G':\n\t\t\tif (option(arg)) {\n\t\t\t\tclist = append(\"-g3\", clist);\n\t\t\t\tllist[0] = append(\"-N\", llist[0]);\n\t\t\t} else\n\t\t\t\tfprintf(stderr, \"%s: %s ignored\\n\", progname, arg);\n\t\t\treturn;\n\t\tcase 'E':\n\t\t\tEflag++;\n\t\t\treturn;\n\t\tcase 'c':\n\t\t\tcflag++;\n\t\t\treturn;\n\t\tcase 'N':\n\t\t\tif (strcmp(basepath(cpp[0]), \"gcc-cpp\") == 0)\n\t\t\t\tplist = append(\"-nostdinc\", plist);\n\t\t\tinclude[0] = 0;\n\t\t\tilist = 0;\n\t\t\treturn;\n\t\tcase 'v':\n\t\t\tif (verbose++ == 0) {\n\t\t\t\tif (strcmp(basepath(cpp[0]), \"gcc-cpp\") == 0)\n\t\t\t\t\tplist = append(arg, plist);\n\t\t\t\tclist = append(arg, clist);\n\t\t\t\tfprintf(stderr, \"%s %s\\n\", progname, rcsid);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\tif (cflag || Sflag || Eflag)\n\t\tfprintf(stderr, \"%s: %s ignored\\n\", progname, arg);\n\telse\n\t\tllist[1] = append(arg, llist[1]);\n}\n\n/* path2list - convert a colon- or semicolon-separated list to a list */\nstatic List path2list(const char *path) {\n\tList list = NULL;\n\tchar sep = ':';\n\n\tif (path == NULL)\n\t\treturn NULL;\n\tif (strchr(path, ';'))\n\t\tsep = ';';\n\twhile (*path) {\n\t\tchar *p, buf[512];\n\t\tif (p = strchr(path, sep)) {\n\t\t\tassert(p - path < sizeof buf);\n\t\t\tstrncpy(buf, path, p - path);\n\t\t\tbuf[p-path] = '\\0';\n\t\t} else {\n\t\t\tassert(strlen(path) < sizeof buf);\n\t\t\tstrcpy(buf, path);\n\t\t}\n\t\tif (!find(buf, list))\n\t\t\tlist = append(strsave(buf), list);\n\t\tif (p == 0)\n\t\t\tbreak;\n\t\tpath = p + 1;\n\t}\n\treturn list;\n}\n\n/* replace - copy str, then replace occurrences of from with to, return the copy */\nchar *replace(const char *str, int from, int to) {\n\tchar *s = strsave(str), *p = s;\n\n\tfor ( ; (p = strchr(p, from)) != NULL; p++)\n\t\t*p = to;\n\treturn s;\n}\n\n/* rm - remove files in list */\nstatic void rm(List list) {\n\tif (list) {\n\t\tList b = list;\n\t\tif (verbose)\n\t\t\tfprintf(stderr, \"rm\");\n\t\tdo {\n\t\t\tif (verbose)\n\t\t\t\tfprintf(stderr, \" %s\", b->str);\n\t\t\tif (verbose < 2)\n\t\t\t\tremove(b->str);\n\t\t} while ((b = b->link) != list);\n\t\tif (verbose)\n\t\t\tfprintf(stderr, \"\\n\");\n\t}\n}\n\n/* strsave - return a saved copy of string str */\nchar *strsave(const char *str) {\n\treturn strcpy(alloc(strlen(str)+1), str);\n}\n\n/* stringf - format and return a string */\nchar *stringf(const char *fmt, ...) {\n\tchar buf[1024];\n\tva_list ap;\n\tint n;\n\n\tva_start(ap, fmt);\n\tn = vsprintf(buf, fmt, ap);\n\tva_end(ap);\n\treturn strsave(buf);\n}\n\n/* suffix - if one of tails[0..n-1] holds a proper suffix of name, return its index */\nint suffix(char *name, char *tails[], int n) {\n\tint i, len = strlen(name);\n\n\tfor (i = 0; i < n; i++) {\n\t\tchar *s = tails[i], *t;\n\t\tfor ( ; t = strchr(s, ';'); s = t + 1) {\n\t\t\tint m = t - s;\n\t\t\tif (len > m && strncmp(&name[len-m], s, m) == 0)\n\t\t\t\treturn i;\n\t\t}\n\t\tif (*s) {\n\t\t\tint m = strlen(s);\n\t\t\tif (len > m && strncmp(&name[len-m], s, m) == 0)\n\t\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/* tempname - generate a temporary file name in tempdir with given suffix */\nchar *tempname(char *suffix) {\n\tstatic int n;\n\tchar *name = stringf(\"%s/lcc%d%d%s\", tempdir, getpid(), n++, suffix);\n\n\tif (strstr(com[1], \"win32\") != NULL)\n\t\tname = replace(name, '/', '\\\\');\n\trmlist = append(name, rmlist);\n\treturn name;\n}\n"
  },
  {
    "path": "lcc/etc/linux.c",
    "content": "/* x86s running Linux */\n\n#include <string.h>\n\nstatic char rcsid[] = \"Dummy rcsid\";\n\n/*\nTTimo - 10-18-2001\nour binaries are named q3lcc q3rcc and q3cpp\nremoved hardcoded paths\nremoved __linux__ preprocessor define (confuses the preprocessor, we are doing bytecode!)\n*/\n\n#ifndef LCCDIR\n#define LCCDIR \"\"\n//#define LCCDIR \"/usr/local/lib/lcc/\"\n#endif\n\nchar *suffixes[] = { \".c\", \".i\", \".asm\", \".o\", \".out\", 0 };\nchar inputs[256] = \"\";\n// TTimo experimental: do not compile with the __linux__ define, we are doing bytecode!\nchar *cpp[] = { LCCDIR \"q3cpp\",\n\t\"-U__GNUC__\", \"-D_POSIX_SOURCE\", \"-D__STDC__=1\", \"-D__STRICT_ANSI__\",\n\t\"-Dunix\", \"-Di386\", \"-Dlinux\",\n\t\"-D__unix__\", \"-D__i386__\", \"-D__signed__=signed\",\n\t\"$1\", \"$2\", \"$3\", 0 };\nchar *include[] = {\"-I\" LCCDIR \"include\", \"-I\" LCCDIR \"gcc/include\", \"-I/usr/include\",\n\t\t   \"-I\" SYSTEM \"include\", 0 };\nchar *com[] = {LCCDIR \"q3rcc\", \"-target=x86/linux\", \"$1\", \"$2\", \"$3\", 0 };\nchar *as[] = { \"/usr/bin/as\", \"-o\", \"$3\", \"$1\", \"$2\", 0 };\n// NOTE TTimo I don't think we have any use with the native linkage\n// our target is always bytecode..\nchar *ld[] = {\n\t/*  0 */ \"/usr/bin/ld\", \"-m\", \"elf_i386\", \"-dynamic-linker\",\n\t/*  4 */ \"/lib/ld-linux.so.2\", \"-o\", \"$3\",\n\t/*  7 */ \"/usr/lib/crt1.o\", \"/usr/lib/crti.o\",\n\t/*  9 */ SYSTEM \"crtbegin.o\", \n                 \"$1\", \"$2\",\n\t/* 12 */ \"-L\" LCCDIR,\n\t/* 13 */ \"-llcc\",\n\t/* 14 */ \"-L\" LCCDIR \"/gcc\", \"-lgcc\", \"-lc\", \"-lm\",\n\t/* 18 */ \"\",\n\t/* 19 */ SYSTEM \"crtend.o\", \"/usr/lib/crtn.o\",\n\t/* 20 */ \"-L\" SYSTEM,\n\t0 };\n\nextern char *concat(char *, char *);\n\nint option(char *arg) {\n  \tif (strncmp(arg, \"-lccdir=\", 8) == 0) {\n\t\tcpp[0] = concat(&arg[8], \"/gcc/cpp\");\n\t\tinclude[0] = concat(\"-I\", concat(&arg[8], \"/include\"));\n\t\tinclude[1] = concat(\"-I\", concat(&arg[8], \"/gcc/include\"));\n\t\tld[9]  = concat(&arg[8], \"/gcc/crtbegin.o\");\n\t\tld[12] = concat(\"-L\", &arg[8]);\n\t\tld[14] = concat(\"-L\", concat(&arg[8], \"/gcc\"));\n\t\tld[19] = concat(&arg[8], \"/gcc/crtend.o\");\n\t\tcom[0] = concat(&arg[8], \"/rcc\");\n\t} else if (strcmp(arg, \"-p\") == 0 || strcmp(arg, \"-pg\") == 0) {\n\t\tld[7] = \"/usr/lib/gcrt1.o\";\n\t\tld[18] = \"-lgmon\";\n\t} else if (strcmp(arg, \"-b\") == 0) \n\t\t;\n\telse if (strcmp(arg, \"-g\") == 0)\n\t\t;\n\telse if (strncmp(arg, \"-ld=\", 4) == 0)\n\t\tld[0] = &arg[4];\n\telse if (strcmp(arg, \"-static\") == 0) {\n\t        ld[3] = \"-static\";\n\t        ld[4] = \"\";\n\t} else\n\t\treturn 0;\n\treturn 1;\n}\n"
  },
  {
    "path": "lcc/etc/ops.c",
    "content": "#include \"c.h\"\n\n/* ops [ {csilhfdxp}=n ]...\n * prints lcc dag operator set for a given set of type sizes.\n */\n\n\nstatic char list[] = { 'c', 's', 'i', 'l', 'h', 'f', 'd', 'x', 'p', 0 };\nstatic int sizes[] = {  1,   2,   4,   4,   8,   4,   8,  16,   8 };\n\nstatic int doop(int op, int type, const char *sz, const char *opname) {\n\tint count = 0;\n\tstatic int last;\n\n\tif (op == LOAD)\n\t\treturn 0;\n\tif (last != 0 && last != op)\n\t\tprintf(\"\\n\");\n\tlast = op;\n\tif (type == B || type == V) {\n\t\tprintf(\" %s=%d\", opname, op + type);\n\t\tcount++;\n\t} else {\n\t\tint i, done = 0;\n\t\tconst char *s;\n\t\tfor (i = 0; sz[i] != '\\0' && (s = strchr(list, sz[i])) != NULL; i++) {\n\t\t\tint n = sizes[s-list];\n\t\t\tif ((done&(1<<n)) == 0) {\n\t\t\t\tprintf(\" %s%d=%d\", opname, n, op + type + sizeop(n));\n\t\t\t\tcount++;\n\t\t\t}\n\t\t\tdone |= 1<<n;\n\t\t}\n\t}\n\tprintf(\"\\n\");\n\treturn count;\n}\n\nint main(int argc, char *argv[]) {\n\tint i, count = 0;\n\n\tfor (i = 1; i < argc; i++) {\n\t\tchar c, *s;\n\t\tint n;\n\t\tif (sscanf(argv[i], \"%c=%d\", &c, &n) == 2\n\t\t&& n > 0 && (s = strchr(list, c)) != NULL)\n\t\t\tsizes[s-list] = n;\n\t\telse {\n\t\t\tfprintf(stderr, \"usage: %s [ {csilhfdxp}=n ]...\\n\", argv[0]);\n\t\t\texit(EXIT_FAILURE);\n\t\t}\n\t}\n#define gop(x,n)\n#define op(x,t,s) count += doop(x,t,#s,#x #t);\ngop(CNST,1)\n\top(CNST,F,fdx)\n\top(CNST,I,csilh)\n\top(CNST,P,p)\n\top(CNST,U,csilh)\ngop(ARG,2)\n\top(ARG,B,-)\n\top(ARG,F,fdx)\n\top(ARG,I,ilh)\n\top(ARG,P,p)\n\top(ARG,U,ilh)\ngop(ASGN,3)\n\top(ASGN,B,-)\n\top(ASGN,F,fdx)\n\top(ASGN,I,csilh)\n\top(ASGN,P,p)\n\top(ASGN,U,csilh)\ngop(INDIR,4)\n\top(INDIR,B,-)\n\top(INDIR,F,fdx)\n\top(INDIR,I,csilh)\n\top(INDIR,P,p)\n\top(INDIR,U,csilh)\ngop(CVF,7)\n\top(CVF,F,fdx)\n\top(CVF,I,ilh)\ngop(CVI,8)\n\top(CVI,F,fdx)\n\top(CVI,I,csilh)\n\top(CVI,U,csilhp)\ngop(CVP,9)\n\top(CVP,U,p)\ngop(CVU,11)\n\top(CVU,I,csilh)\n\top(CVU,P,p)\n\top(CVU,U,csilh)\ngop(NEG,12)\n\top(NEG,F,fdx)\n\top(NEG,I,ilh)\ngop(CALL,13)\n\top(CALL,B,-)\n\top(CALL,F,fdx)\n\top(CALL,I,ilh)\n\top(CALL,P,p)\n\top(CALL,U,ilh)\n\top(CALL,V,-)\ngop(RET,15)\n\top(RET,F,fdx)\n\top(RET,I,ilh)\n\top(RET,P,p)\n\top(RET,U,ilh)\n\top(RET,V,-)\ngop(ADDRG,16)\n\top(ADDRG,P,p)\ngop(ADDRF,17)\n\top(ADDRF,P,p)\ngop(ADDRL,18)\n\top(ADDRL,P,p)\ngop(ADD,19)\n\top(ADD,F,fdx)\n\top(ADD,I,ilh)\n\top(ADD,P,p)\n\top(ADD,U,ilhp)\ngop(SUB,20)\n\top(SUB,F,fdx)\n\top(SUB,I,ilh)\n\top(SUB,P,p)\n\top(SUB,U,ilhp)\ngop(LSH,21)\n\top(LSH,I,ilh)\n\top(LSH,U,ilh)\ngop(MOD,22)\n\top(MOD,I,ilh)\n\top(MOD,U,ilh)\ngop(RSH,23)\n\top(RSH,I,ilh)\n\top(RSH,U,ilh)\ngop(BAND,24)\n\top(BAND,I,ilh)\n\top(BAND,U,ilh)\ngop(BCOM,25)\n\top(BCOM,I,ilh)\n\top(BCOM,U,ilh)\ngop(BOR,26)\n\top(BOR,I,ilh)\n\top(BOR,U,ilh)\ngop(BXOR,27)\n\top(BXOR,I,ilh)\n\top(BXOR,U,ilh)\ngop(DIV,28)\n\top(DIV,F,fdx)\n\top(DIV,I,ilh)\n\top(DIV,U,ilh)\ngop(MUL,29)\n\top(MUL,F,fdx)\n\top(MUL,I,ilh)\n\top(MUL,U,ilh)\ngop(EQ,30)\n\top(EQ,F,fdx)\n\top(EQ,I,ilh)\n\top(EQ,U,ilhp)\ngop(GE,31)\n\top(GE,F,fdx)\n\top(GE,I,ilh)\n\top(GE,U,ilhp)\ngop(GT,32)\n\top(GT,F,fdx)\n\top(GT,I,ilh)\n\top(GT,U,ilhp)\ngop(LE,33)\n\top(LE,F,fdx)\n\top(LE,I,ilh)\n\top(LE,U,ilhp)\ngop(LT,34)\n\top(LT,F,fdx)\n\top(LT,I,ilh)\n\top(LT,U,ilhp)\ngop(NE,35)\n\top(NE,F,fdx)\n\top(NE,I,ilh)\n\top(NE,U,ilhp)\ngop(JUMP,36)\n\top(JUMP,V,-)\ngop(LABEL,37)\n\top(LABEL,V,-)\ngop(LOAD,14)\n\top(LOAD,B,-)\n\top(LOAD,F,fdx)\n\top(LOAD,I,csilh)\n\top(LOAD,P,p)\n\top(LOAD,U,csilhp)\n#undef gop\n#undef op\n\tfprintf(stderr, \"%d operators\\n\", count);\n\treturn EXIT_SUCCESS;\n}\n"
  },
  {
    "path": "lcc/etc/osf.c",
    "content": "/* DEC ALPHAs running OSF/1 V3.2A (Rev. 17) at Princeton University */\n\n#include <string.h>\n\n\n#ifndef LCCDIR\n#define LCCDIR \"/usr/local/lib/lcc/\"\n#endif\n\nchar *suffixes[] = { \".c\", \".i\", \".s\", \".o\", \".out\", 0 };\nchar inputs[256] = \"\";\nchar *cpp[] = {\n\tLCCDIR \"cpp\", \"-D__STDC__=1\",\n\t\"-DLANGUAGE_C\", \"-D__LANGUAGE_C__\",\n \t\"-D_unix\", \"-D__unix__\", \"-D_osf\", \"-D__osf__\", \"-Dunix\",\n\t\"-Dalpha\", \"-D_alpha\", \"-D__alpha\",\n\t\"-D__SYSTYPE_BSD\",  \"-D_SYSTYPE_BSD\",\n\t\"$1\", \"$2\", \"$3\", 0 };\nchar *com[] =  { LCCDIR \"rcc\", \"-target=alpha/osf\", \"$1\", \"$2\", \"$3\", \"\", 0 };\nchar *include[] = { \"-I\" LCCDIR \"include\", \"-I/usr/local/include\",\n\t\"-I/usr/include\", 0 };\nchar *as[] =  { \"/bin/as\", \"-o\", \"$3\", \"\", \"$1\", \"-nocpp\", \"$2\", 0 };\nchar *ld[] =  { \"/usr/bin/ld\", \"-o\", \"$3\", \"/usr/lib/cmplrs/cc/crt0.o\",\n\t\"$1\", \"$2\", \"\", \"\", \"-L\" LCCDIR, \"-llcc\", \"-lm\", \"-lc\", 0 };\n\nextern char *concat(char *, char *);\nextern int access(const char *, int);\n\nint option(char *arg) {\n\tif (strncmp(arg, \"-lccdir=\", 8) == 0) {\n\t\tcpp[0] = concat(&arg[8], \"/cpp\");\n\t\tinclude[0] = concat(\"-I\", concat(&arg[8], \"/include\"));\n\t\tcom[0] = concat(&arg[8], \"/rcc\");\n\t\tld[8] = concat(\"-L\", &arg[8]);\n\t} else if (strcmp(arg, \"-g4\") == 0\n\t&& access(\"/u/drh/lib/alpha/rcc\", 4) == 0\n\t&& access(\"/u/drh/book/cdb/alpha/osf/cdbld\", 4) == 0) {\n\t\tcom[0] = \"/u/drh/lib/alpha/rcc\";\n\t\tcom[5] = \"-g4\";\n\t\tld[0] = \"/u/drh/book/cdb/alpha/osf/cdbld\";\n\t\tld[1] = \"-o\";\n\t\tld[2] = \"$3\";\n\t\tld[3] = \"$1\";\n\t\tld[4] = \"$2\";\n\t\tld[5] = 0;\n\t} else if (strcmp(arg, \"-g\") == 0)\n\t\treturn 1;\n\telse if (strcmp(arg, \"-b\") == 0)\n\t\t;\n\telse\n\t\treturn 0;\n\treturn 1;\n}\n"
  },
  {
    "path": "lcc/etc/solaris.c",
    "content": "/* SPARCs running Solaris 2.5.1 at CS Dept., Princeton University */\n\n#include <string.h>\n\n\n#ifndef LCCDIR\n#define LCCDIR \"/usr/local/lib/lcc/\"\n#endif\n#ifndef SUNDIR\n#define SUNDIR \"/opt/SUNWspro/SC4.2/lib/\"\n#endif\n\nchar *suffixes[] = { \".c\", \".i\", \".s\", \".o\", \".out\", 0 };\nchar inputs[256] = \"\";\nchar *cpp[] = { LCCDIR \"cpp\",\n\t\"-D__STDC__=1\", \"-Dsparc\", \"-D__sparc__\", \"-Dsun\", \"-D__sun__\", \"-Dunix\",\n\t\"$1\", \"$2\", \"$3\", 0 };\nchar *include[] = { \"-I\" LCCDIR \"include\", \"-I/usr/local/include\",\n\t\"-I/usr/include\", 0 };\nchar *com[] = { LCCDIR \"rcc\", \"-target=sparc/solaris\",\n\t\"$1\", \"$2\", \"$3\", 0 };\nchar *as[] = { \"/usr/ccs/bin/as\", \"-Qy\", \"-s\", \"-o\", \"$3\", \"$1\", \"$2\", 0 };\nchar *ld[] = { \"/usr/ccs/bin/ld\", \"-o\", \"$3\", \"$1\",\n\tSUNDIR \"crti.o\", SUNDIR \"crt1.o\",\n\tSUNDIR \"values-xa.o\", \"$2\", \"\",\n\t\"-Y\", \"P,\" SUNDIR \":/usr/ccs/lib:/usr/lib\", \"-Qy\",\n\t\"-L\" LCCDIR, \"-llcc\", \"-lm\", \"-lc\", SUNDIR \"crtn.o\", 0 };\n\nextern char *concat(char *, char *);\n\nint option(char *arg) {\n\tif (strncmp(arg, \"-lccdir=\", 8) == 0) {\n\t\tcpp[0] = concat(&arg[8], \"/cpp\");\n\t\tinclude[0] = concat(\"-I\", concat(&arg[8], \"/include\"));\n\t\tld[12] = concat(\"-L\", &arg[8]);\n\t\tcom[0] = concat(&arg[8], \"/rcc\");\n\t} else if (strcmp(arg, \"-g\") == 0)\n\t\t;\n\telse if (strcmp(arg, \"-p\") == 0) {\n\t\tld[5] = SUNDIR \"mcrt1.o\";\n\t\tld[10] = \"P,\" SUNDIR \"libp:/usr/ccs/lib/libp:/usr/lib/libp:\"\n\t\t\t SUNDIR \":/usr/ccs/lib:/usr/lib\";\n\t} else if (strcmp(arg, \"-b\") == 0)\n\t\t;\n\telse if (strncmp(arg, \"-ld=\", 4) == 0)\n\t\tld[0] = &arg[4];\n\telse\n\t\treturn 0;\n\treturn 1;\n}\n"
  },
  {
    "path": "lcc/etc/win32.c",
    "content": "/* x86s running MS Windows NT 4.0 */\n\n#include <string.h>\n\n\n#ifndef LCCDIR\n// JDC #define LCCDIR \"\\\\progra~1\\\\lcc\\\\4.1\\\\bin\\\\\"\n//#define LCCDIR \"\\\\quake3\\\\source\\\\lcc\\\\bin\\\\\"\t// JDC\n// TTimo: q3cpp q3rcc & no hardcoded paths\n#define LCCDIR \"\"\n#endif\n\nchar *suffixes[] = { \".c;.C\", \".i;.I\", \".asm;.ASM;.s;.S\", \".obj;.OBJ\", \".exe\", 0 };\nchar inputs[256] = \"\";\nchar *cpp[] = { LCCDIR \"q3cpp\", \"-D__STDC__=1\", \"-Dwin32\", \"-D_WIN32\", \"-D_M_IX86\",\n\t\"$1\", \"$2\", \"$3\", 0 };\nchar *include[] = { \"-I\" LCCDIR \"include\", 0 };\nchar *com[] = { LCCDIR \"q3rcc\", \"-target=x86/win32\", \"$1\", \"$2\", \"$3\", 0 };\nchar *as[] = { \"ml\", \"-nologo\", \"-c\", \"-Cp\", \"-coff\", \"-Fo$3\", \"$1\", \"$2\", 0 };\nchar *ld[] = { \"link\", \"-nologo\", \n\t\"-align:0x1000\", \"-subsystem:console\", \"-entry:mainCRTStartup\",\n\t\"$2\", \"-OUT:$3\", \"$1\", LCCDIR \"liblcc.lib\", \"libc.lib\", \"kernel32.lib\", 0 };\n\nextern char *concat(char *, char *);\nextern char *replace(const char *, int, int);\n\nint option(char *arg) {\n\tif (strncmp(arg, \"-lccdir=\", 8) == 0) {\n\t\targ = replace(arg + 8, '/', '\\\\');\n\t\tif (arg[strlen(arg)-1] == '\\\\')\n\t\t\targ[strlen(arg)-1] = '\\0';\n\t\tcpp[0] = concat(arg, \"\\\\cpp.exe\");\n\t\tinclude[0] = concat(\"-I\", concat(arg, \"\\\\include\"));\n\t\tcom[0] = concat(arg, \"\\\\rcc.exe\");\n\t\tld[8] = concat(arg, \"\\\\liblcc.lib\");\n\t} else if (strcmp(arg, \"-b\") == 0)\n\t\t;\n\telse if (strncmp(arg, \"-ld=\", 4) == 0)\n\t\tld[0] = &arg[4];\n\telse\n\t\treturn 0;\n\treturn 1;\n}\n"
  },
  {
    "path": "lcc/include/alpha/osf/assert.h",
    "content": "#ifndef __ASSERT\n#define __ASSERT\n\nvoid assert(int);\n\n#endif /* __ASSERT */\n\n#undef assert\n#ifdef NDEBUG\n#define assert(ignore) ((void)0)\n#else\nextern void __assert(char *, char *, unsigned);\n#define assert(e) ((void)((e)||(__assert(#e, __FILE__, __LINE__),0)))\n#endif /* NDEBUG */\n"
  },
  {
    "path": "lcc/include/alpha/osf/ctype.h",
    "content": "#ifndef __CTYPE\n#define __CTYPE\n\nextern int isalnum(int);\nextern int isalpha(int);\nextern int iscntrl(int);\nextern int isdigit(int);\nextern int isgraph(int);\nextern int islower(int);\nextern int isprint(int);\nextern int ispunct(int);\nextern int isspace(int);\nextern int isupper(int);\nextern int isxdigit(int);\nextern int tolower(int);\nextern int toupper(int);\n\n#define\t__U\t01\n#define\t__L\t02\n#define\t__N\t04\n#define\t__S\t010\n#define\t__P\t020\n#define\t__C\t040\n\n#endif /* __CTYPE */\n"
  },
  {
    "path": "lcc/include/alpha/osf/errno.h",
    "content": "#ifndef __ERRNO\n#define __ERRNO\n\n#define EDOM\t33\n#define ERANGE\t34\nextern int errno;\n\n#endif /* __ERRNO */\n"
  },
  {
    "path": "lcc/include/alpha/osf/float.h",
    "content": "#ifndef __FLOAT\n#define __FLOAT\n\n#define FLT_ROUNDS\t1\n#define FLT_RADIX\t2\n\n#define FLT_DIG\t\t6\n#define FLT_EPSILON\t1.19209289550781250000e-07\n#define FLT_MANT_DIG\t24\n#define FLT_MAX\t\t3.40282346638528860000e+38\n#define FLT_MAX_10_EXP\t38\n#define FLT_MAX_EXP\t128\n#define FLT_MIN\t\t1.17549435082228750000e-38\n#define FLT_MIN_10_EXP\t-37\n#define FLT_MIN_EXP\t-125\n\n#define DBL_DIG\t\t15\n#define DBL_EPSILON\t2.22044604925031310000e-16\n#define DBL_MANT_DIG\t53\n#define DBL_MAX\t\t1.79769313486231570000e+308\n#define DBL_MAX_10_EXP\t308\n#define DBL_MAX_EXP\t1024\n#define DBL_MIN\t\t2.22507385850720140000e-308\n#define DBL_MIN_10_EXP\t-307\n#define DBL_MIN_EXP\t-1021\n\n#define LDBL_MANT_DIG\tDBL_MANT_DIG\n#define LDBL_EPSILON\tDBL_EPSILON\n#define LDBL_DIG\tDBL_DIG\n#define LDBL_MIN_EXP\tDBL_MIN_EXP\n#define LDBL_MIN\tDBL_MIN\n#define LDBL_MIN_10_EXP\tDBL_MIN_10_EXP\n#define LDBL_MAX_EXP\tDBL_MAX_EXP\n#define LDBL_MAX\tDBL_MAX\n#define LDBL_MAX_10_EXP\tDBL_MAX_10_EXP\n\n#endif /* __FLOAT */\n"
  },
  {
    "path": "lcc/include/alpha/osf/limits.h",
    "content": "#ifndef __LIMITS\n#define __LIMITS\n\n#define CHAR_BIT\t8\n#define MB_LEN_MAX\t1\n\n#define UCHAR_MAX\t0xff\n#define USHRT_MAX\t0xffff\n#define UINT_MAX\t(~0U)\n#define ULONG_MAX\t(~0UL)\n\n#define CHAR_MAX\tSCHAR_MAX\n#define SCHAR_MAX\t0x7f\n#define SHRT_MAX\t0x7fff\n#define INT_MAX\t\t0x7fffffff\n#define LONG_MAX\t0x7fffffffffffffffL\n\n#define CHAR_MIN\tSCHAR_MIN\n#define SCHAR_MIN\t(-SCHAR_MAX-1)\n#define SHRT_MIN\t(-SHRT_MAX-1)\n#define INT_MIN\t\t(-INT_MAX-1)\n#define LONG_MIN\t(-LONG_MAX-1)\n\n#endif /* __LIMITS */\n"
  },
  {
    "path": "lcc/include/alpha/osf/locale.h",
    "content": "#ifndef __LOCALE\n#define __LOCALE\n\n#define LC_ALL\t\t0\n#define LC_COLLATE\t1\n#define LC_CTYPE\t2\n#define LC_MONETARY\t3\n#define LC_NUMERIC\t4\n#define LC_TIME\t\t5\n#define NULL\t0\n\nstruct lconv {\n\tchar *decimal_point;\n\tchar *thousands_sep;\n\tchar *grouping;\n\tchar *int_curr_symbol;\n\tchar *currency_symbol;\n\tchar *mon_decimal_point;\n\tchar *mon_thousands_sep;\n\tchar *mon_grouping;\n\tchar *positive_sign;\n\tchar *negative_sign;\n\tchar int_frac_digits;\n\tchar frac_digits;\n\tchar p_cs_precedes;\n\tchar p_sep_by_space;\n\tchar n_cs_precedes;\n\tchar n_sep_by_space;\n\tchar p_sign_posn;\n\tchar n_sign_posn;\n};\n\nchar *setlocale(int, const char *);\nstruct lconv *localeconv(void);\n\n#endif /* __LOCALE */\n"
  },
  {
    "path": "lcc/include/alpha/osf/math.h",
    "content": "#ifndef __MATH\n#define __MATH\n\n#define HUGE_VAL 1.79769313486231570000e+308\n\nextern double acos(double);\nextern double asin(double);\nextern double atan(double);\nextern double atan2(double, double);\nextern double cos(double);\nextern double sin(double);\nextern double tan(double);\nextern double cosh(double);\nextern double sinh(double);\nextern double tanh(double);\nextern double exp(double);\nextern double frexp(double, int *);\nextern double ldexp(double, int);\nextern double log(double);\nextern double log10(double);\nextern double modf(double, double *);\nextern double pow(double, double);\nextern double sqrt(double);\nextern double ceil(double);\nextern double fabs(double);\nextern double floor(double);\nextern double fmod(double, double);\n\n#endif /* __MATH */\n"
  },
  {
    "path": "lcc/include/alpha/osf/setjmp.h",
    "content": "#ifndef __SETJMP\n#define __SETJMP\n\n\n\ntypedef int jmp_buf[35+1+48];\nint setjmp(jmp_buf);\nvoid longjmp(jmp_buf, int);\n\n#endif /* __SETJMP */\n"
  },
  {
    "path": "lcc/include/alpha/osf/signal.h",
    "content": "#ifndef __SIGNAL\n#define __SIGNAL\n\ntypedef int sig_atomic_t;\n\n#define SIG_DFL ((void (*)(int))0)\n#define SIG_ERR ((void (*)(int))-1)\n#define SIG_IGN ((void (*)(int))1)\n\n#define SIGABRT\t6\n#define SIGFPE\t8\n#define SIGILL\t4\n#define SIGINT\t2\n#define SIGSEGV\t11\n#define SIGTERM\t15\n\nvoid (*signal(int, void (*)(int)))(int);\nint raise(int);\n\n#endif /* __SIGNAL */\n"
  },
  {
    "path": "lcc/include/alpha/osf/stdarg.h",
    "content": "#ifndef __STDARG\n#define __STDARG\n\n#if !defined(_VA_LIST)\n#define _VA_LIST\ntypedef struct {\n\tchar\t*_a0;\t\t/* pointer to first homed integer arg */\n\tint\t_offset;\t/* byte offset of next param */\n\tfloat\t_tmp;\n} __va_list;\n#endif\ntypedef __va_list va_list;\n\n#define va_start(list, start) ((void)( \\\n\t(list)._a0 = (__typecode(__firstarg)==1 ? \\\n\t\t(char*)&__firstarg+48 : (char *)&__firstarg), \\\n\t(list)._offset = (__typecode(start)==1 ? \\\n\t\t(char*)&start+56 : (char *)&start+8)-(list)._a0))\n#define va_arg(list, mode) (*(mode *)( \\\n\t(list)._offset += (int)((sizeof(mode)+7)&~7), \\\n\t(__typecode(mode)==1 && sizeof(mode)==4) ? \\\n\t\t((list)._tmp = (float)*(double *)((list)._a0 + (list)._offset - \\\n\t\t\t((list)._offset <= 48 ? 56 : 8))), (char *)&(list)._tmp : \\\n\t(__typecode(mode)==1 && (list)._offset <= 48) ? \\\n\t\t(list)._a0 + (list)._offset - 56 : \\\n\t(list)._a0 + (list)._offset - (int)((sizeof(mode)+7)&~7)))\n#define va_end(list) ((void)0)\n#endif\n"
  },
  {
    "path": "lcc/include/alpha/osf/stddef.h",
    "content": "#ifndef __STDDEF\n#define __STDDEF\n\n\n#define NULL 0\n#define offsetof(ty,mem) ((size_t)((char*)&((ty*)0)->mem - (char*)0))\n\ntypedef long ptrdiff_t;\n\n#if !defined(_SIZE_T) && !defined(_SIZE_T_)\n#define _SIZE_T\n#define _SIZE_T_\ntypedef unsigned long size_t;\n#endif\n\n#if !defined(_WCHAR_T) && !defined(_WCHAR_T_)\n#define _WCHAR_T\n#define _WCHAR_T_\ntypedef unsigned short wchar_t;\n#endif\n\n#endif /* __STDDEF */\n"
  },
  {
    "path": "lcc/include/alpha/osf/stdio.h",
    "content": "#ifndef __STDIO\n#define __STDIO\n\n#define _IOFBF 0\n#define _IOLBF 0200\n#define _IONBF 04\n#define BUFSIZ 8192\n#define EOF (-1)\n\ntypedef struct _iobuf {\n\tint\t_cnt;\n\tunsigned char\t*_ptr;\n\tunsigned char\t*_base;\n\tint\t_bufsiz;\n\tshort\t_flag;\n\tshort\t_file;\n\tchar    *__newbase;\n\tvoid    *_lock;\n\tunsigned char\t*_bufendp;\n} FILE;\nextern FILE _iob[];\n#define FILENAME_MAX 255\n#define FOPEN_MAX 64\n\n#if !defined(_FPOS_T) && !defined(_FPOS_T_)\n#define _FPOS_T\n#define _FPOS_T_\ntypedef long fpos_t;\n#endif\n\n#define L_tmpnam 21\n#define NULL 0\n#define SEEK_CUR 1\n#define SEEK_END 2\n#define SEEK_SET 0\n\n#if !defined(_SIZE_T) && !defined(_SIZE_T_)\n#define _SIZE_T\n#define _SIZE_T_\ntypedef unsigned long size_t;\n#endif\n\n#if !defined(_VA_LIST)\n#define _VA_LIST\ntypedef struct {\n\tchar\t*_a0;\t\t/* pointer to first homed integer arg */\n\tint\t_offset;\t/* byte offset of next param */\n\tfloat\t_tmp;\n} __va_list;\n#endif\n\n#define stderr (&_iob[2])\n#define stdin  (&_iob[0])\n#define stdout (&_iob[1])\n#define TMP_MAX 16384\n\nextern int remove(const char *);\nextern int rename(const char *, const char *);\nextern FILE *tmpfile(void);\nextern char *tmpnam(char *);\nextern int fclose(FILE *);\nextern int fflush(FILE *);\nextern FILE *fopen(const char *, const char *);\nextern FILE *freopen(const char *, const char *, FILE *);\nextern void setbuf(FILE *, char *);\nextern int setvbuf(FILE *, char *, int, size_t);\nextern int fprintf(FILE *, const char *, ...);\nextern int fscanf(FILE *, const char *, ...);\nextern int printf(const char *, ...);\nextern int scanf(const char *, ...);\nextern int sprintf(char *, const char *, ...);\nextern int sscanf(const char *, const char *, ...);\nextern int vfprintf(FILE *, const char *, __va_list);\nextern int vprintf(const char *, __va_list);\nextern int vsprintf(char *, const char *, __va_list);\nextern int fgetc(FILE *);\nextern char *fgets(char *, int, FILE *);\nextern int fputc(int, FILE *);\nextern int fputs(const char *, FILE *);\nextern int getc(FILE *);\nextern int getchar(void);\nextern char *gets(char *);\nextern int putc(int, FILE *);\nextern int putchar(int);\nextern int puts(const char *);\nextern int ungetc(int, FILE *);\nextern size_t fread(void *, size_t, size_t, FILE *);\nextern size_t fwrite(const void *, size_t, size_t, FILE *);\nextern int fgetpos(FILE *, fpos_t *);\nextern int fseek(FILE *, long int, int);\nextern int fsetpos(FILE *, const fpos_t *);\nextern long int ftell(FILE *);\nextern void rewind(FILE *);\nextern void clearerr(FILE *);\nextern int feof(FILE *);\nextern int ferror(FILE *);\nextern void perror(const char *);\n\n#define\t_IOEOF 020\n#define\t_IOERR 040\n\n#define getc(p) (--(p)->_cnt < 0 ? _filbuf(p) : (int) *(p)->_ptr++)\n#define putc(x, p) (--(p)->_cnt < 0 ? \\\n\t_flsbuf((unsigned char) (x), p) : \\\n\t(int) (*(p)->_ptr++ = (unsigned char) (x)))\nextern int _filbuf(FILE *), _flsbuf(unsigned, FILE *);\n#define feof(p) ((p)->_flag&_IOEOF)\n#define ferror(p) ((p)->_flag&_IOERR)\n#define\tclearerr(p) ((p)->_flag &= ~(_IOERR|_IOEOF))\n#define\tgetchar() getc(stdin)\n#define\tputchar(x) putc((x),stdout)\n\n#endif /* __STDIO */\n"
  },
  {
    "path": "lcc/include/alpha/osf/stdlib.h",
    "content": "#ifndef __STDLIB\n#define __STDLIB\n\n#define EXIT_FAILURE 1\n#define EXIT_SUCCESS 0\n#define MB_CUR_MAX 1\n#define NULL 0\n#define RAND_MAX 32767\n\ntypedef struct { int quot, rem; } div_t;\ntypedef struct { long quot, rem; } ldiv_t;\n\n#if !defined(_SIZE_T) && !defined(_SIZE_T_)\n#define _SIZE_T\n#define _SIZE_T_\ntypedef unsigned long size_t;\n#endif\n\n#if !defined(_WCHAR_T) && !defined(_WCHAR_T_)\n#define _WCHAR_T\n#define _WCHAR_T_\ntypedef unsigned char wchar_t;\n#endif\n\nextern double atof(const char *);\nextern int atoi(const char *);\nextern long int atol(const char *);\nextern double strtod(const char *, char **);\nextern long int strtol(const char *, char **, int);\nextern unsigned long int strtoul(const char *, char **, int);\nextern int rand(void);\nextern void srand(unsigned int);\nextern void *calloc(size_t, size_t);\nextern void free(void *);\nextern void *malloc(size_t);\nextern void *realloc(void *, size_t);\nextern void abort(void);\nextern int atexit(void (*)(void));\nextern void exit(int);\nextern char *getenv(const char *);\nextern int system(const char *);\nextern void *bsearch(const void *, const void *, size_t, size_t, int (*)(const void *, const void *));\nextern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));\nextern int abs(int);\nextern div_t div(int, int);\nextern long int labs(long int);\nextern ldiv_t ldiv(long int, long int);\nextern int mblen(const char *, size_t);\nextern int mbtowc(wchar_t *, const char *, size_t);\nextern int wctomb(char *, wchar_t);\nextern size_t mbstowcs(wchar_t *, const char *, size_t);\nextern size_t wcstombs(char *, const wchar_t *, size_t);\n\n#endif /* __STDLIB */\n"
  },
  {
    "path": "lcc/include/alpha/osf/string.h",
    "content": "#ifndef __STRING\n#define __STRING\n\n#define NULL 0\n\n#if !defined(_SIZE_T) && !defined(_SIZE_T_)\n#define _SIZE_T\n#define _SIZE_T_\ntypedef unsigned long size_t;\n#endif\n\nvoid *memcpy(void *, const void *, size_t);\nvoid *memmove(void *, const void *, size_t);\nchar *strcpy(char *, const char *);\nchar *strncpy(char *, const char *, size_t);\nchar *strcat(char *, const char *);\nchar *strncat(char *, const char *, size_t);\nint memcmp(const void *, const void *, size_t);\nint strcmp(const char *, const char *);\nint strcoll(const char *, const char *);\nint strncmp(const char *, const char *, size_t);\nsize_t strxfrm(char *, const char *, size_t);\nvoid *memchr(const void *, int, size_t);\nchar *strchr(const char *, int);\nsize_t strcspn(const char *, const char *);\nchar *strpbrk(const char *, const char *);\nchar *strrchr(const char *, int);\nsize_t strspn(const char *, const char *);\nchar *strstr(const char *, const char *);\nchar *strtok(char *, const char *);\nvoid *memset(void *, int, size_t);\nchar *strerror(int);\nsize_t strlen(const char *);\n\n#endif /* __STRING */\n"
  },
  {
    "path": "lcc/include/alpha/osf/time.h",
    "content": "#ifndef __TIME\n#define __TIME\n\n#define CLOCKS_PER_SEC 1000000\n#ifndef NULL\n#define NULL 0\n#endif\n\n#if !defined(_CLOCK_T) && !defined(_CLOCK_T_)\n#define _CLOCK_T\n#define _CLOCK_T_\ntypedef long clock_t;\n#endif\n\n#if !defined(_TIME_T) && !defined(_TIME_T_)\n#define _TIME_T\n#define _TIME_T_\ntypedef long time_t;\n#endif\n\n#if !defined(_SIZE_T) && !defined(_SIZE_T_)\n#define _SIZE_T\n#define _SIZE_T_\ntypedef unsigned long size_t;\n#endif\n\nstruct tm {\n\tint\ttm_sec;\n\tint\ttm_min;\n\tint\ttm_hour;\n\tint\ttm_mday;\n\tint\ttm_mon;\n\tint\ttm_year;\n\tint\ttm_wday;\n\tint\ttm_yday;\n\tint\ttm_isdst;\nlong __tm_gmtoff;\n\tchar *__tm_zone;\n};\nextern clock_t clock(void);\nextern double difftime(time_t, time_t);\nextern time_t mktime(struct tm *);\nextern time_t time(time_t *);\nextern char *asctime(const struct tm *);\nextern char *ctime(const time_t *);\nextern struct tm *gmtime(const time_t *);\nextern struct tm *localtime(const time_t *);\nextern size_t strftime(char *, size_t, const char *, const struct tm *);\n\n#endif /* __TIME */\n"
  },
  {
    "path": "lcc/include/mips/irix/assert.h",
    "content": "#ifndef __ASSERT\n#define __ASSERT\n\nvoid assert(int);\n\n#endif /* __ASSERT */\n\n#undef assert\n#ifdef NDEBUG\n#define assert(ignore) ((void)0)\n#else\nextern int _assert(char *, char *, unsigned);\n#define assert(e) ((void)((e)||_assert(#e, __FILE__, __LINE__)))\n#endif /* NDEBUG */\n"
  },
  {
    "path": "lcc/include/mips/irix/ctype.h",
    "content": "#ifndef __CTYPE\n#define __CTYPE\n\nextern int isalnum(int);\nextern int isalpha(int);\nextern int iscntrl(int);\nextern int isdigit(int);\nextern int isgraph(int);\nextern int islower(int);\nextern int isprint(int);\nextern int ispunct(int);\nextern int isspace(int);\nextern int isupper(int);\nextern int isxdigit(int);\nextern int tolower(int);\nextern int toupper(int);\n\n#define\t__U\t01\n#define\t__L\t02\n#define\t__N\t04\n#define\t__S\t010\n#define\t__P\t020\n#define\t__C\t040\n#define\t__B\t0100\n#define\t__X\t0200\n\nextern unsigned char _ctype[];\n#define\tisalnum(c)\t((_ctype+1)[c]&(__U|__L|__N))\n#define\tisalpha(c)\t((_ctype+1)[c]&(__U|__L))\n#define\tiscntrl(c)\t((_ctype+1)[c]&__C)\n#define\tisdigit(c)\t((_ctype+1)[c]&__N)\n#define\tisgraph(c)\t((_ctype+1)[c]&(__P|__U|__L|__N))\n#define\tislower(c)\t((_ctype+1)[c]&__L)\n#define\tisprint(c)\t((_ctype+1)[c]&(__P|__U|__L|__N|__B))\n#define\tispunct(c)\t((_ctype+1)[c]&__P)\n#define\tisspace(c)\t((_ctype+1)[c]&__S)\n#define\tisupper(c)\t((_ctype+1)[c]&__U)\n#define\tisxdigit(c)\t((_ctype+1)[c]&__X)\n\n#endif /* __CTYPE */\n"
  },
  {
    "path": "lcc/include/mips/irix/errno.h",
    "content": "#ifndef __ERRNO\n#define __ERRNO\n\n#define EDOM\t33\n#define ERANGE\t34\nextern int errno;\n\n#endif /* __ERRNO */\n"
  },
  {
    "path": "lcc/include/mips/irix/float.h",
    "content": "#ifndef __FLOAT\n#define __FLOAT\n\n#define FLT_ROUNDS\t1\n#define FLT_RADIX\t2\n\n#define FLT_DIG\t\t6\n#define FLT_EPSILON\t1.19209289550781250000e-07\n#define FLT_MANT_DIG\t24\n#define FLT_MAX\t\t3.40282346638528860000e+38\n#define FLT_MAX_10_EXP\t38\n#define FLT_MAX_EXP\t128\n#define FLT_MIN\t\t1.17549435082228750000e-38\n#define FLT_MIN_10_EXP\t-37\n#define FLT_MIN_EXP\t-125\n\n#define DBL_DIG\t\t15\n#define DBL_EPSILON\t2.22044604925031310000e-16\n#define DBL_MANT_DIG\t53\n#define DBL_MAX\t\t1.79769313486231570000e+308\n#define DBL_MAX_10_EXP\t308\n#define DBL_MAX_EXP\t1024\n#define DBL_MIN\t\t2.22507385850720140000e-308\n#define DBL_MIN_10_EXP\t-307\n#define DBL_MIN_EXP\t-1021\n\n#define LDBL_MANT_DIG\tDBL_MANT_DIG\n#define LDBL_EPSILON\tDBL_EPSILON\n#define LDBL_DIG\tDBL_DIG\n#define LDBL_MIN_EXP\tDBL_MIN_EXP\n#define LDBL_MIN\tDBL_MIN\n#define LDBL_MIN_10_EXP\tDBL_MIN_10_EXP\n#define LDBL_MAX_EXP\tDBL_MAX_EXP\n#define LDBL_MAX\tDBL_MAX\n#define LDBL_MAX_10_EXP\tDBL_MAX_10_EXP\n\n#endif /* __FLOAT */\n"
  },
  {
    "path": "lcc/include/mips/irix/limits.h",
    "content": "#ifndef __LIMITS\n#define __LIMITS\n\n#define CHAR_BIT\t8\n#define MB_LEN_MAX\t1\n\n#define UCHAR_MAX\t0xff\n#define USHRT_MAX\t0xffff\n#define UINT_MAX\t(~0U)\n#define ULONG_MAX\t(~0UL)\n\n#define CHAR_MAX\tSCHAR_MAX\n#define SCHAR_MAX\t0x7f\n#define SHRT_MAX\t0x7fff\n#define INT_MAX\t\t0x7fffffff\n#define LONG_MAX\t0x7fffffffL\n\n#define CHAR_MIN\tSCHAR_MIN\n#define SCHAR_MIN\t(-SCHAR_MAX-1)\n#define SHRT_MIN\t(-SHRT_MAX-1)\n#define INT_MIN\t\t(-INT_MAX-1)\n#define LONG_MIN\t(-LONG_MAX-1)\n\n#endif /* __LIMITS */\n"
  },
  {
    "path": "lcc/include/mips/irix/locale.h",
    "content": "#ifndef __LOCALE\n#define __LOCALE\n\n#define LC_ALL\t\t0\n#define LC_COLLATE\t1\n#define LC_CTYPE\t2\n#define LC_MONETARY\t3\n#define LC_NUMERIC\t4\n#define LC_TIME\t\t5\n#define NULL\t0\n\nstruct lconv {\n\tchar *decimal_point;\n\tchar *thousands_sep;\n\tchar *grouping;\n\tchar *int_curr_symbol;\n\tchar *currency_symbol;\n\tchar *mon_decimal_point;\n\tchar *mon_thousands_sep;\n\tchar *mon_grouping;\n\tchar *positive_sign;\n\tchar *negative_sign;\n\tchar int_frac_digits;\n\tchar frac_digits;\n\tchar p_cs_precedes;\n\tchar p_sep_by_space;\n\tchar n_cs_precedes;\n\tchar n_sep_by_space;\n\tchar p_sign_posn;\n\tchar n_sign_posn;\n};\n\nchar *setlocale(int, const char *);\nstruct lconv *localeconv(void);\n\n#endif /* __LOCALE */\n"
  },
  {
    "path": "lcc/include/mips/irix/math.h",
    "content": "#ifndef __MATH\n#define __MATH\n\n#define HUGE_VAL 1.79769313486231570000e+308\n\nextern double acos(double);\nextern double asin(double);\nextern double atan(double);\nextern double atan2(double, double);\nextern double cos(double);\nextern double sin(double);\nextern double tan(double);\nextern double cosh(double);\nextern double sinh(double);\nextern double tanh(double);\nextern double exp(double);\nextern double frexp(double, int *);\nextern double ldexp(double, int);\nextern double log(double);\nextern double log10(double);\nextern double modf(double, double *);\nextern double pow(double, double);\nextern double sqrt(double);\nextern double ceil(double);\nextern double fabs(double);\nextern double floor(double);\nextern double fmod(double, double);\n\n#endif /* __MATH */\n"
  },
  {
    "path": "lcc/include/mips/irix/setjmp.h",
    "content": "#ifndef __SETJMP\n#define __SETJMP\n\n\n\ntypedef int jmp_buf[28];\nint setjmp(jmp_buf);\nvoid longjmp(jmp_buf, int);\n\n#endif /* __SETJMP */\n"
  },
  {
    "path": "lcc/include/mips/irix/signal.h",
    "content": "#ifndef __SIGNAL\n#define __SIGNAL\n\ntypedef int sig_atomic_t;\n\n#define SIG_DFL ((void (*)(int))0)\n#define SIG_ERR ((void (*)(int))-1)\n#define SIG_IGN ((void (*)(int))1)\n\n#define SIGABRT\t6\n#define SIGFPE\t8\n#define SIGILL\t4\n#define SIGINT\t2\n#define SIGSEGV\t11\n#define SIGTERM\t15\n\nvoid (*signal(int, void (*)(int)))(int);\nint raise(int);\n\n#endif /* __SIGNAL */\n"
  },
  {
    "path": "lcc/include/mips/irix/stdarg.h",
    "content": "#ifndef __STDARG\n#define __STDARG\n\n#if !defined(_VA_LIST)\n#define _VA_LIST\ntypedef char *__va_list;\n#endif\ntypedef __va_list va_list;\n\n#define va_start(list, start) ((void)((list) = (sizeof(start)<4 ? \\\n\t(char *)((int *)&(start)+1) : (char *)(&(start)+1))))\n#define __va_arg(list, mode, n) \\\n\t(*(mode *)(&(list += ((sizeof(mode)+n)&~n))[-(int)((sizeof(mode)+n)&~n)]))\n#define _bigendian_va_arg(list, mode, n) (\\\n\tsizeof(mode)==1 ? *(mode *)(&(list += 4)[-1]) : \\\n\tsizeof(mode)==2 ? *(mode *)(&(list += 4)[-2]) : __va_arg(list, mode, n))\n#define _littleendian_va_arg(list, mode, n) __va_arg(list, mode, n)\n#define va_end(list) ((void)0)\n#define va_arg(list, mode) (sizeof(mode)==8 ? \\\n\t*(mode *)(&(list = (char*)(((int)list + 15)&~7U))[-8]) : \\\n\t_bigendian_va_arg(list, mode, 3U))\n#endif\n"
  },
  {
    "path": "lcc/include/mips/irix/stddef.h",
    "content": "#ifndef __STDDEF\n#define __STDDEF\n\n\n#define NULL 0\n#define offsetof(ty,mem) ((size_t)((char*)&((ty*)0)->mem - (char*)0))\n\ntypedef long ptrdiff_t;\n\n#if !defined(_SIZE_T) && !defined(_SIZE_T_)\n#define _SIZE_T\n#define _SIZE_T_\ntypedef unsigned long size_t;\n#endif\n\n#if !defined(_WCHAR_T) && !defined(_WCHAR_T_)\n#define _WCHAR_T\n#define _WCHAR_T_\ntypedef unsigned short wchar_t;\n#endif\n\n#endif /* __STDDEF */\n"
  },
  {
    "path": "lcc/include/mips/irix/stdio.h",
    "content": "#ifndef __STDIO\n#define __STDIO\n\n#define _IOFBF 0\n#define _IOLBF 0100\n#define _IONBF 04\n#define BUFSIZ 1024\n#define EOF (-1)\n\nextern struct _iobuf {\n\tint\t_cnt;\n\tunsigned char\t*_ptr;\n\tunsigned char\t*_base;\n\tchar\t_flag;\n\tchar\t_file;\n} _iob[];\n#define FILE struct _iobuf\n#define FILENAME_MAX 256\n#define FOPEN_MAX 100\n\n#if !defined(_FPOS_T) && !defined(_FPOS_T_)\n#define _FPOS_T\n#define _FPOS_T_\ntypedef long fpos_t;\n#endif\n\n#define L_tmpnam 25\n#define NULL 0\n#define SEEK_CUR 1\n#define SEEK_END 2\n#define SEEK_SET 0\n\n#if !defined(_SIZE_T) && !defined(_SIZE_T_)\n#define _SIZE_T\n#define _SIZE_T_\ntypedef unsigned long size_t;\n#endif\n\n#if !defined(_VA_LIST)\n#define _VA_LIST\ntypedef char *__va_list;\n#endif\n\n#define stderr (&_iob[2])\n#define stdin  (&_iob[0])\n#define stdout (&_iob[1])\n#define TMP_MAX 17576\n\nextern int remove(const char *);\nextern int rename(const char *, const char *);\nextern FILE *tmpfile(void);\nextern char *tmpnam(char *);\nextern int fclose(FILE *);\nextern int fflush(FILE *);\nextern FILE *fopen(const char *, const char *);\nextern FILE *freopen(const char *, const char *, FILE *);\nextern void setbuf(FILE *, char *);\nextern int setvbuf(FILE *, char *, int, size_t);\nextern int fprintf(FILE *, const char *, ...);\nextern int fscanf(FILE *, const char *, ...);\nextern int printf(const char *, ...);\nextern int scanf(const char *, ...);\nextern int sprintf(char *, const char *, ...);\nextern int sscanf(const char *, const char *, ...);\nextern int vfprintf(FILE *, const char *, __va_list);\nextern int vprintf(const char *, __va_list);\nextern int vsprintf(char *, const char *, __va_list);\nextern int fgetc(FILE *);\nextern char *fgets(char *, int, FILE *);\nextern int fputc(int, FILE *);\nextern int fputs(const char *, FILE *);\nextern int getc(FILE *);\nextern int getchar(void);\nextern char *gets(char *);\nextern int putc(int, FILE *);\nextern int putchar(int);\nextern int puts(const char *);\nextern int ungetc(int, FILE *);\nextern size_t fread(void *, size_t, size_t, FILE *);\nextern size_t fwrite(const void *, size_t, size_t, FILE *);\nextern int fgetpos(FILE *, fpos_t *);\nextern int fseek(FILE *, long int, int);\nextern int fsetpos(FILE *, const fpos_t *);\nextern long int ftell(FILE *);\nextern void rewind(FILE *);\nextern void clearerr(FILE *);\nextern int feof(FILE *);\nextern int ferror(FILE *);\nextern void perror(const char *);\n\n#define\t_IOEOF 020\n#define\t_IOERR 040\n\n#define getc(p) (--(p)->_cnt < 0 ? _filbuf(p) : (int) *(p)->_ptr++)\n#define putc(x, p) (--(p)->_cnt < 0 ? _flsbuf((unsigned char) (x), p) : (int) (*(p)->_ptr++ = (unsigned char) (x)))\nextern int _filbuf(FILE *), _flsbuf(unsigned, FILE *);\n#define feof(p) ((p)->_flag&_IOEOF)\n#define ferror(p) ((p)->_flag&_IOERR)\n#define\tclearerr(p) ((p)->_flag &= ~(_IOERR|_IOEOF))\n#define\tgetchar() getc(stdin)\n#define\tputchar(x) putc((x),stdout)\n\n#endif /* __STDIO */\n"
  },
  {
    "path": "lcc/include/mips/irix/stdlib.h",
    "content": "#ifndef __STDLIB\n#define __STDLIB\n\n#define EXIT_FAILURE 1\n#define EXIT_SUCCESS 0\n#define MB_CUR_MAX 1\n#define NULL 0\n#define RAND_MAX 32767\n\ntypedef struct { int quot, rem; } div_t;\ntypedef struct { long quot, rem; } ldiv_t;\n\n#if !defined(_SIZE_T) && !defined(_SIZE_T_)\n#define _SIZE_T\n#define _SIZE_T_\ntypedef unsigned long size_t;\n#endif\n\n#if !defined(_WCHAR_T) && !defined(_WCHAR_T_)\n#define _WCHAR_T\n#define _WCHAR_T_\ntypedef unsigned char wchar_t;\n#endif\n\nextern double atof(const char *);\nextern int atoi(const char *);\nextern long int atol(const char *);\nextern double strtod(const char *, char **);\nextern long int strtol(const char *, char **, int);\nextern unsigned long int strtoul(const char *, char **, int);\nextern int rand(void);\nextern void srand(unsigned int);\nextern void *calloc(size_t, size_t);\nextern void free(void *);\nextern void *malloc(size_t);\nextern void *realloc(void *, size_t);\nextern void abort(void);\nextern int atexit(void (*)(void));\nextern void exit(int);\nextern char *getenv(const char *);\nextern int system(const char *);\nextern void *bsearch(const void *, const void *, size_t, size_t, int (*)(const void *, const void *));\nextern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));\nextern int abs(int);\nextern div_t div(int, int);\nextern long int labs(long int);\nextern ldiv_t ldiv(long int, long int);\nextern int mblen(const char *, size_t);\nextern int mbtowc(wchar_t *, const char *, size_t);\nextern int wctomb(char *, wchar_t);\nextern size_t mbstowcs(wchar_t *, const char *, size_t);\nextern size_t wcstombs(char *, const wchar_t *, size_t);\n\n#endif /* __STDLIB */\n"
  },
  {
    "path": "lcc/include/mips/irix/string.h",
    "content": "#ifndef __STRING\n#define __STRING\n\n#define NULL 0\n\n#if !defined(_SIZE_T) && !defined(_SIZE_T_)\n#define _SIZE_T\n#define _SIZE_T_\ntypedef unsigned long size_t;\n#endif\n\nvoid *memcpy(void *, const void *, size_t);\nvoid *memmove(void *, const void *, size_t);\nchar *strcpy(char *, const char *);\nchar *strncpy(char *, const char *, size_t);\nchar *strcat(char *, const char *);\nchar *strncat(char *, const char *, size_t);\nint memcmp(const void *, const void *, size_t);\nint strcmp(const char *, const char *);\nint strcoll(const char *, const char *);\nint strncmp(const char *, const char *, size_t);\nsize_t strxfrm(char *, const char *, size_t);\nvoid *memchr(const void *, int, size_t);\nchar *strchr(const char *, int);\nsize_t strcspn(const char *, const char *);\nchar *strpbrk(const char *, const char *);\nchar *strrchr(const char *, int);\nsize_t strspn(const char *, const char *);\nchar *strstr(const char *, const char *);\nchar *strtok(char *, const char *);\nvoid *memset(void *, int, size_t);\nchar *strerror(int);\nsize_t strlen(const char *);\n\n#endif /* __STRING */\n"
  },
  {
    "path": "lcc/include/mips/irix/time.h",
    "content": "#ifndef __TIME\n#define __TIME\n\n#define CLOCKS_PER_SEC 1000000\n#ifndef NULL\n#define NULL 0\n#endif\n\n#if !defined(_CLOCK_T) && !defined(_CLOCK_T_)\n#define _CLOCK_T\n#define _CLOCK_T_\ntypedef long clock_t;\n#endif\n\n#if !defined(_TIME_T) && !defined(_TIME_T_)\n#define _TIME_T\n#define _TIME_T_\ntypedef long time_t;\n#endif\n\n#if !defined(_SIZE_T) && !defined(_SIZE_T_)\n#define _SIZE_T\n#define _SIZE_T_\ntypedef unsigned long size_t;\n#endif\n\nstruct tm {\n\tint\ttm_sec;\n\tint\ttm_min;\n\tint\ttm_hour;\n\tint\ttm_mday;\n\tint\ttm_mon;\n\tint\ttm_year;\n\tint\ttm_wday;\n\tint\ttm_yday;\n\tint\ttm_isdst;\n};\nextern clock_t clock(void);\nextern double difftime(time_t, time_t);\nextern time_t mktime(struct tm *);\nextern time_t time(time_t *);\nextern char *asctime(const struct tm *);\nextern char *ctime(const time_t *);\nextern struct tm *gmtime(const time_t *);\nextern struct tm *localtime(const time_t *);\nextern size_t strftime(char *, size_t, const char *, const struct tm *);\n\n#endif /* __TIME */\n"
  },
  {
    "path": "lcc/include/sparc/solaris/assert.h",
    "content": "#ifndef __ASSERT\n#define __ASSERT\n\nvoid assert(int);\n\n#endif /* __ASSERT */\n\n#undef assert\n#ifdef NDEBUG\n#define assert(ignore) ((void)0)\n#else\nextern void __assert(char *, char *, unsigned);\n#define assert(e) ((void)((e)||(__assert(#e, __FILE__, __LINE__),0)))\n#endif /* NDEBUG */\n"
  },
  {
    "path": "lcc/include/sparc/solaris/ctype.h",
    "content": "#ifndef __CTYPE\n#define __CTYPE\n\nextern int isalnum(int);\nextern int isalpha(int);\nextern int iscntrl(int);\nextern int isdigit(int);\nextern int isgraph(int);\nextern int islower(int);\nextern int isprint(int);\nextern int ispunct(int);\nextern int isspace(int);\nextern int isupper(int);\nextern int isxdigit(int);\nextern int tolower(int);\nextern int toupper(int);\n\n#define\t__U\t01\n#define\t__L\t02\n#define\t__N\t04\n#define\t__S\t010\n#define\t__P\t020\n#define\t__C\t040\n#define\t_U\t01\n#define\t_L\t02\n#define\t_N\t04\n#define\t_S\t010\n#define\t_P\t020\n#define\t_C\t040\n#define\t_B\t0100\n#define\t_X\t0200\n\nextern unsigned char __ctype[];\n#define\tisalpha(c)\t((__ctype + 1)[c] & (_U | _L))\n#define\tisupper(c)\t((__ctype + 1)[c] & _U)\n#define\tislower(c)\t((__ctype + 1)[c] & _L)\n#define\tisdigit(c)\t((__ctype + 1)[c] & _N)\n#define\tisxdigit(c)\t((__ctype + 1)[c] & _X)\n#define\tisalnum(c)\t((__ctype + 1)[c] & (_U | _L | _N))\n#define\tisspace(c)\t((__ctype + 1)[c] & _S)\n#define\tispunct(c)\t((__ctype + 1)[c] & _P)\n#define\tisprint(c)\t((__ctype + 1)[c] & (_P | _U | _L | _N | _B))\n#define\tisgraph(c)\t((__ctype + 1)[c] & (_P | _U | _L | _N))\n#define\tiscntrl(c)\t((__ctype + 1)[c] & _C)\n\n#endif /* __CTYPE */\n"
  },
  {
    "path": "lcc/include/sparc/solaris/errno.h",
    "content": "#ifndef __ERRNO\n#define __ERRNO\n\n#define EDOM\t33\n#define ERANGE\t34\nextern int errno;\n\n#endif /* __ERRNO */\n"
  },
  {
    "path": "lcc/include/sparc/solaris/float.h",
    "content": "#ifndef __FLOAT\n#define __FLOAT\n\n#define FLT_ROUNDS\t1\n#define FLT_RADIX\t2\n\n#define FLT_DIG\t\t6\n#define FLT_EPSILON\t1.19209289550781250000e-07\n#define FLT_MANT_DIG\t24\n#define FLT_MAX\t\t3.40282346638528860000e+38\n#define FLT_MAX_10_EXP\t38\n#define FLT_MAX_EXP\t128\n#define FLT_MIN\t\t1.17549435082228750000e-38\n#define FLT_MIN_10_EXP\t-37\n#define FLT_MIN_EXP\t-125\n\n#define DBL_DIG\t\t15\n#define DBL_EPSILON\t2.22044604925031310000e-16\n#define DBL_MANT_DIG\t53\n#define DBL_MAX\t\t1.79769313486231570000e+308\n#define DBL_MAX_10_EXP\t308\n#define DBL_MAX_EXP\t1024\n#define DBL_MIN\t\t2.22507385850720140000e-308\n#define DBL_MIN_10_EXP\t-307\n#define DBL_MIN_EXP\t-1021\n\n#define LDBL_MANT_DIG\tDBL_MANT_DIG\n#define LDBL_EPSILON\tDBL_EPSILON\n#define LDBL_DIG\tDBL_DIG\n#define LDBL_MIN_EXP\tDBL_MIN_EXP\n#define LDBL_MIN\tDBL_MIN\n#define LDBL_MIN_10_EXP\tDBL_MIN_10_EXP\n#define LDBL_MAX_EXP\tDBL_MAX_EXP\n#define LDBL_MAX\tDBL_MAX\n#define LDBL_MAX_10_EXP\tDBL_MAX_10_EXP\n\n#endif /* __FLOAT */\n"
  },
  {
    "path": "lcc/include/sparc/solaris/limits.h",
    "content": "#ifndef __LIMITS\n#define __LIMITS\n\n#define CHAR_BIT\t8\n#define MB_LEN_MAX\t1\n\n#define UCHAR_MAX\t0xff\n#define USHRT_MAX\t0xffff\n#define UINT_MAX\t(~0U)\n#define ULONG_MAX\t(~0UL)\n\n#define CHAR_MAX\tSCHAR_MAX\n#define SCHAR_MAX\t0x7f\n#define SHRT_MAX\t0x7fff\n#define INT_MAX\t\t0x7fffffff\n#define LONG_MAX\t0x7fffffffL\n\n#define CHAR_MIN\tSCHAR_MIN\n#define SCHAR_MIN\t(-SCHAR_MAX-1)\n#define SHRT_MIN\t(-SHRT_MAX-1)\n#define INT_MIN\t\t(-INT_MAX-1)\n#define LONG_MIN\t(-LONG_MAX-1)\n\n#endif /* __LIMITS */\n"
  },
  {
    "path": "lcc/include/sparc/solaris/locale.h",
    "content": "#ifndef __LOCALE\n#define __LOCALE\n\n#define LC_ALL\t\t0\n#define LC_COLLATE\t1\n#define LC_CTYPE\t2\n#define LC_MONETARY\t3\n#define LC_NUMERIC\t4\n#define LC_TIME\t\t5\n#define NULL\t0\n\nstruct lconv {\n\tchar *decimal_point;\n\tchar *thousands_sep;\n\tchar *grouping;\n\tchar *int_curr_symbol;\n\tchar *currency_symbol;\n\tchar *mon_decimal_point;\n\tchar *mon_thousands_sep;\n\tchar *mon_grouping;\n\tchar *positive_sign;\n\tchar *negative_sign;\n\tchar int_frac_digits;\n\tchar frac_digits;\n\tchar p_cs_precedes;\n\tchar p_sep_by_space;\n\tchar n_cs_precedes;\n\tchar n_sep_by_space;\n\tchar p_sign_posn;\n\tchar n_sign_posn;\n};\n\nchar *setlocale(int, const char *);\nstruct lconv *localeconv(void);\n\n#endif /* __LOCALE */\n"
  },
  {
    "path": "lcc/include/sparc/solaris/math.h",
    "content": "#ifndef __MATH\n#define __MATH\n\nextern double infinity(void);\n#define HUGE_VAL (infinity())\n\nextern double acos(double);\nextern double asin(double);\nextern double atan(double);\nextern double atan2(double, double);\nextern double cos(double);\nextern double sin(double);\nextern double tan(double);\nextern double cosh(double);\nextern double sinh(double);\nextern double tanh(double);\nextern double exp(double);\nextern double frexp(double, int *);\nextern double ldexp(double, int);\nextern double log(double);\nextern double log10(double);\nextern double modf(double, double *);\nextern double pow(double, double);\nextern double sqrt(double);\nextern double ceil(double);\nextern double fabs(double);\nextern double floor(double);\nextern double fmod(double, double);\n\n#endif /* __MATH */\n"
  },
  {
    "path": "lcc/include/sparc/solaris/setjmp.h",
    "content": "#ifndef __SETJMP\n#define __SETJMP\n\n\n\ntypedef int jmp_buf[12];\nint setjmp(jmp_buf);\nvoid longjmp(jmp_buf, int);\n\n#endif /* __SETJMP */\n"
  },
  {
    "path": "lcc/include/sparc/solaris/signal.h",
    "content": "#ifndef __SIGNAL\n#define __SIGNAL\n\ntypedef int sig_atomic_t;\n\n#define SIG_DFL ((void (*)(int))0)\n#define SIG_ERR ((void (*)(int))-1)\n#define SIG_IGN ((void (*)(int))1)\n\n#define SIGABRT\t6\n#define SIGFPE\t8\n#define SIGILL\t4\n#define SIGINT\t2\n#define SIGSEGV\t11\n#define SIGTERM\t15\n\nvoid (*signal(int, void (*)(int)))(int);\nint raise(int);\n\n#endif /* __SIGNAL */\n"
  },
  {
    "path": "lcc/include/sparc/solaris/stdarg.h",
    "content": "#ifndef __STDARG\n#define __STDARG\n\n#if !defined(_VA_LIST)\n#define _VA_LIST\ntypedef char *__va_list;\n#endif\ntypedef __va_list va_list;\n\n#define va_start(list, start) ((void)((list) = (sizeof(start)<4 ? \\\n\t(char *)((int *)&(start)+1) : (char *)(&(start)+1))))\n#define __va_arg(list, mode, n) \\\n\t(*(mode *)(&(list += ((sizeof(mode)+n)&~n))[-(int)((sizeof(mode)+n)&~n)]))\n#define _bigendian_va_arg(list, mode, n) (\\\n\tsizeof(mode)==1 ? *(mode *)(&(list += 4)[-1]) : \\\n\tsizeof(mode)==2 ? *(mode *)(&(list += 4)[-2]) : __va_arg(list, mode, n))\n#define _littleendian_va_arg(list, mode, n) __va_arg(list, mode, n)\n#define va_end(list) ((void)0)\n#define va_arg(list, mode) (sizeof(mode)>8 ? \\\n\t**(mode **)(&(list += 4)[-4]) : \\\n\t_bigendian_va_arg(list, mode, 3U))\n#endif\n"
  },
  {
    "path": "lcc/include/sparc/solaris/stddef.h",
    "content": "#ifndef __STDDEF\n#define __STDDEF\n\n\n#define NULL 0\n#define offsetof(ty,mem) ((size_t)((char*)&((ty*)0)->mem - (char*)0))\n\ntypedef long ptrdiff_t;\n\n#if !defined(_SIZE_T) && !defined(_SIZE_T_)\n#define _SIZE_T\n#define _SIZE_T_\ntypedef unsigned long size_t;\n#endif\n\n#if !defined(_WCHAR_T) && !defined(_WCHAR_T_)\n#define _WCHAR_T\n#define _WCHAR_T_\ntypedef unsigned short wchar_t;\n#endif\n\n#endif /* __STDDEF */\n"
  },
  {
    "path": "lcc/include/sparc/solaris/stdio.h",
    "content": "#ifndef __STDIO\n#define __STDIO\n\n#define _IOFBF 0\n#define _IOLBF 0100\n#define _IONBF 04\n#define BUFSIZ 1024\n#define EOF (-1)\n\ntypedef struct {\n\tint\t_cnt;\n\tunsigned char *_ptr;\n\tunsigned char *_base;\n\tunsigned char _flag;\n\tunsigned char _file;\n} FILE;\nextern FILE __iob[];\n#define FILENAME_MAX 1024\n#define FOPEN_MAX 20\n\n#if !defined(_FPOS_T) && !defined(_FPOS_T_)\n#define _FPOS_T\n#define _FPOS_T_\ntypedef long fpos_t;\n#endif\n\n#define L_tmpnam 25\n#define NULL 0\n#define SEEK_CUR 1\n#define SEEK_END 2\n#define SEEK_SET 0\n\n#if !defined(_SIZE_T) && !defined(_SIZE_T_)\n#define _SIZE_T\n#define _SIZE_T_\ntypedef unsigned long size_t;\n#endif\n\n#if !defined(_VA_LIST)\n#define _VA_LIST\ntypedef char *__va_list;\n#endif\n\n#define stderr (&__iob[2])\n#define stdin  (&__iob[0])\n#define stdout (&__iob[1])\n#define TMP_MAX 17576\n\nextern int remove(const char *);\nextern int rename(const char *, const char *);\nextern FILE *tmpfile(void);\nextern char *tmpnam(char *);\nextern int fclose(FILE *);\nextern int fflush(FILE *);\nextern FILE *fopen(const char *, const char *);\nextern FILE *freopen(const char *, const char *, FILE *);\nextern void setbuf(FILE *, char *);\nextern int setvbuf(FILE *, char *, int, size_t);\nextern int fprintf(FILE *, const char *, ...);\nextern int fscanf(FILE *, const char *, ...);\nextern int printf(const char *, ...);\nextern int scanf(const char *, ...);\nextern int sprintf(char *, const char *, ...);\nextern int sscanf(const char *, const char *, ...);\nextern int vfprintf(FILE *, const char *, __va_list);\nextern int vprintf(const char *, __va_list);\nextern int vsprintf(char *, const char *, __va_list);\nextern int fgetc(FILE *);\nextern char *fgets(char *, int, FILE *);\nextern int fputc(int, FILE *);\nextern int fputs(const char *, FILE *);\nextern int getc(FILE *);\nextern int getchar(void);\nextern char *gets(char *);\nextern int putc(int, FILE *);\nextern int putchar(int);\nextern int puts(const char *);\nextern int ungetc(int, FILE *);\nextern size_t fread(void *, size_t, size_t, FILE *);\nextern size_t fwrite(const void *, size_t, size_t, FILE *);\nextern int fgetpos(FILE *, fpos_t *);\nextern int fseek(FILE *, long int, int);\nextern int fsetpos(FILE *, const fpos_t *);\nextern long int ftell(FILE *);\nextern void rewind(FILE *);\nextern void clearerr(FILE *);\nextern int feof(FILE *);\nextern int ferror(FILE *);\nextern void perror(const char *);\n\n#define\t_IOEOF 020\n#define\t_IOERR 040\n\n#define\tgetc(p) (--(p)->_cnt < 0 ? __filbuf(p) : (int)*(p)->_ptr++)\n#define putc(x, p) (--(p)->_cnt < 0 ? __flsbuf((unsigned char) (x), (p)) \\\n\t\t\t: (int)(*(p)->_ptr++ = (x)))\nextern int __filbuf(FILE *), __flsbuf(unsigned, FILE *);\n#define feof(p) ((p)->_flag&_IOEOF)\n#define ferror(p) ((p)->_flag&_IOERR)\n#define\tclearerr(p) ((p)->_flag &= ~(_IOERR|_IOEOF))\n#define\tgetchar() getc(stdin)\n#define\tputchar(x) putc((x),stdout)\n\n#endif /* __STDIO */\n"
  },
  {
    "path": "lcc/include/sparc/solaris/stdlib.h",
    "content": "#ifndef __STDLIB\n#define __STDLIB\n\n#define EXIT_FAILURE 1\n#define EXIT_SUCCESS 0\n#define MB_CUR_MAX 1\n#define NULL 0\n#define RAND_MAX 32767\n\ntypedef struct { int quot, rem; } div_t;\ntypedef struct { long quot, rem; } ldiv_t;\n\n#if !defined(_SIZE_T) && !defined(_SIZE_T_)\n#define _SIZE_T\n#define _SIZE_T_\ntypedef unsigned long size_t;\n#endif\n\n#if !defined(_WCHAR_T) && !defined(_WCHAR_T_)\n#define _WCHAR_T\n#define _WCHAR_T_\ntypedef unsigned char wchar_t;\n#endif\n\nextern double atof(const char *);\nextern int atoi(const char *);\nextern long int atol(const char *);\nextern double strtod(const char *, char **);\nextern long int strtol(const char *, char **, int);\nextern unsigned long int strtoul(const char *, char **, int);\nextern int rand(void);\nextern void srand(unsigned int);\nextern void *calloc(size_t, size_t);\nextern void free(void *);\nextern void *malloc(size_t);\nextern void *realloc(void *, size_t);\nextern void abort(void);\nextern int atexit(void (*)(void));\nextern void exit(int);\nextern char *getenv(const char *);\nextern int system(const char *);\nextern void *bsearch(const void *, const void *, size_t, size_t, int (*)(const void *, const void *));\nextern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));\nextern int abs(int);\nextern div_t div(int, int);\nextern long int labs(long int);\nextern ldiv_t ldiv(long int, long int);\nextern int mblen(const char *, size_t);\nextern int mbtowc(wchar_t *, const char *, size_t);\nextern int wctomb(char *, wchar_t);\nextern size_t mbstowcs(wchar_t *, const char *, size_t);\nextern size_t wcstombs(char *, const wchar_t *, size_t);\n\n#endif /* __STDLIB */\n"
  },
  {
    "path": "lcc/include/sparc/solaris/string.h",
    "content": "#ifndef __STRING\n#define __STRING\n\n#define NULL 0\n\n#if !defined(_SIZE_T) && !defined(_SIZE_T_)\n#define _SIZE_T\n#define _SIZE_T_\ntypedef unsigned long size_t;\n#endif\n\nvoid *memcpy(void *, const void *, size_t);\nvoid *memmove(void *, const void *, size_t);\nchar *strcpy(char *, const char *);\nchar *strncpy(char *, const char *, size_t);\nchar *strcat(char *, const char *);\nchar *strncat(char *, const char *, size_t);\nint memcmp(const void *, const void *, size_t);\nint strcmp(const char *, const char *);\nint strcoll(const char *, const char *);\nint strncmp(const char *, const char *, size_t);\nsize_t strxfrm(char *, const char *, size_t);\nvoid *memchr(const void *, int, size_t);\nchar *strchr(const char *, int);\nsize_t strcspn(const char *, const char *);\nchar *strpbrk(const char *, const char *);\nchar *strrchr(const char *, int);\nsize_t strspn(const char *, const char *);\nchar *strstr(const char *, const char *);\nchar *strtok(char *, const char *);\nvoid *memset(void *, int, size_t);\nchar *strerror(int);\nsize_t strlen(const char *);\n\n#endif /* __STRING */\n"
  },
  {
    "path": "lcc/include/sparc/solaris/time.h",
    "content": "#ifndef __TIME\n#define __TIME\n\n#define CLOCKS_PER_SEC 1000000\n#ifndef NULL\n#define NULL 0\n#endif\n\n#if !defined(_CLOCK_T) && !defined(_CLOCK_T_)\n#define _CLOCK_T\n#define _CLOCK_T_\ntypedef long clock_t;\n#endif\n\n#if !defined(_TIME_T) && !defined(_TIME_T_)\n#define _TIME_T\n#define _TIME_T_\ntypedef long time_t;\n#endif\n\n#if !defined(_SIZE_T) && !defined(_SIZE_T_)\n#define _SIZE_T\n#define _SIZE_T_\ntypedef unsigned long size_t;\n#endif\n\nstruct tm {\n\tint\ttm_sec;\n\tint\ttm_min;\n\tint\ttm_hour;\n\tint\ttm_mday;\n\tint\ttm_mon;\n\tint\ttm_year;\n\tint\ttm_wday;\n\tint\ttm_yday;\n\tint\ttm_isdst;\n};\nextern clock_t clock(void);\nextern double difftime(time_t, time_t);\nextern time_t mktime(struct tm *);\nextern time_t time(time_t *);\nextern char *asctime(const struct tm *);\nextern char *ctime(const time_t *);\nextern struct tm *gmtime(const time_t *);\nextern struct tm *localtime(const time_t *);\nextern size_t strftime(char *, size_t, const char *, const struct tm *);\n\n#endif /* __TIME */\n"
  },
  {
    "path": "lcc/include/x86/linux/assert.h",
    "content": "#ifndef __ASSERT\n#define __ASSERT\n\nvoid assert(int);\n\n#endif /* __ASSERT */\n\n#undef assert\n#ifdef NDEBUG\n#define assert(ignore) ((void)0)\n#else\nextern int _assert(char *, char *, unsigned);\n#define assert(e) ((void)((e)||_assert(#e, __FILE__, __LINE__)))\n#endif /* NDEBUG */\n"
  },
  {
    "path": "lcc/include/x86/linux/float.h",
    "content": "#ifndef __FLOAT\n#define __FLOAT\n\n#define FLT_ROUNDS\t(__flt_rounds())\n#define FLT_RADIX\t2\n\n#define FLT_DIG\t\t6\n#define FLT_EPSILON\t1.19209289550781250000e-07\n#define FLT_MANT_DIG\t24\n#define FLT_MAX\t\t3.40282346638528860000e+38\n#define FLT_MAX_10_EXP\t38\n#define FLT_MAX_EXP\t128\n#define FLT_MIN\t\t1.17549435082228750000e-38\n#define FLT_MIN_10_EXP\t-37\n#define FLT_MIN_EXP\t-125\n\n#define DBL_DIG\t\t15\n#define DBL_EPSILON\t2.22044604925031310000e-16\n#define DBL_MANT_DIG\t53\n#define DBL_MAX\t\t1.79769313486231570000e+308\n#define DBL_MAX_10_EXP\t308\n#define DBL_MAX_EXP\t1024\n#define DBL_MIN\t\t2.22507385850720140000e-308\n#define DBL_MIN_10_EXP\t-307\n#define DBL_MIN_EXP\t-1021\n\n#define LDBL_MANT_DIG\tDBL_MANT_DIG\n#define LDBL_EPSILON\tDBL_EPSILON\n#define LDBL_DIG\tDBL_DIG\n#define LDBL_MIN_EXP\tDBL_MIN_EXP\n#define LDBL_MIN\tDBL_MIN\n#define LDBL_MIN_10_EXP\tDBL_MIN_10_EXP\n#define LDBL_MAX_EXP\tDBL_MAX_EXP\n#define LDBL_MAX\tDBL_MAX\n#define LDBL_MAX_10_EXP\tDBL_MAX_10_EXP\n\n#endif /* __FLOAT */\n"
  },
  {
    "path": "lcc/include/x86/linux/stdarg.h",
    "content": "#ifndef __STDARG\n#define __STDARG\n\n#if !defined(_VA_LIST)\n#define _VA_LIST\ntypedef char *__va_list;\n#endif\ntypedef __va_list va_list;\n\n#define va_start(list, start) ((void)((list) = (sizeof(start)<4 ? \\\n\t(char *)((int *)&(start)+1) : (char *)(&(start)+1))))\n#define __va_arg(list, mode, n) \\\n\t(*(mode *)(&(list += ((sizeof(mode)+n)&~n))[-(int)((sizeof(mode)+n)&~n)]))\n#define _bigendian_va_arg(list, mode, n) (\\\n\tsizeof(mode)==1 ? *(mode *)(&(list += 4)[-1]) : \\\n\tsizeof(mode)==2 ? *(mode *)(&(list += 4)[-2]) : __va_arg(list, mode, n))\n#define _littleendian_va_arg(list, mode, n) __va_arg(list, mode, n)\n#define va_end(list) ((void)0)\n#define va_arg(list, mode) _littleendian_va_arg(list, mode, 3U)\ntypedef void *__gnuc_va_list;\n#endif\n"
  },
  {
    "path": "lcc/lburg/gram.c",
    "content": "#if defined(__STDC__) || defined(__cplusplus)\n#define YYCONST const\n#define YYPARAMS(x) x\n#define YYDEFUN(name, arglist, args) name(args)\n#define YYAND ,\n#define YYPTR void *\n#else\n#define YYCONST\n#define YYPARAMS(x) ()\n#define YYDEFUN(name, arglist, args) name arglist args;\n#define YYAND ;\n#define YYPTR char *\n#endif\n#ifndef lint\nYYCONST static char yysccsid[] = \"@(#)yaccpar\t1.8 (Berkeley +Cygnus.28) 01/20/91\";\n#endif\n#define YYBYACC 1\n#ifndef YYDONT_INCLUDE_STDIO\n#include <stdio.h>\n#endif\n#ifdef __cplusplus\n#include <stdlib.h> /* for malloc/realloc/free */\n#endif\n#line 2 \"lburg/gram.y\"\n#include <stdio.h>\n#include \"lburg.h\"\n/*lint -e616 -e527 -e652 -esym(552,yynerrs) -esym(563,yynewstate,yyerrlab) */\nstatic int yylineno = 0;\n#line 8 \"lburg/gram.y\"\ntypedef union {\n\tint n;\n\tchar *string;\n\tTree tree;\n} YYSTYPE;\n#line 37 \"y.tab.c\"\n#define TERMINAL 257\n#define START 258\n#define PPERCENT 259\n#define ID 260\n#define TEMPLATE 261\n#define CODE 262\n#define INT 263\n#define YYERRCODE 256\nstatic YYCONST short yylhs[] = {                                        -1,\n    0,    0,    4,    4,    6,    6,    6,    6,    7,    7,\n    5,    5,    5,    5,    1,    3,    3,    3,    2,\n};\nstatic YYCONST short yylen[] = {                                         2,\n    3,    1,    0,    2,    3,    3,    1,    2,    0,    4,\n    0,    7,    2,    3,    1,    1,    4,    6,    1,\n};\nstatic YYCONST short yydefred[] = {                                      3,\n    0,    0,    0,    9,    0,   11,    7,    4,    8,    0,\n   15,    0,    0,    0,    5,    6,    0,   13,    0,    0,\n   14,    0,   10,    0,    0,    0,    0,    0,   19,    0,\n   17,    0,   12,    0,   18,\n};\nstatic YYCONST short yydgoto[] = {                                       1,\n   12,   30,   25,    2,   13,    8,   10,\n};\nstatic YYCONST short yysindex[] = {                                      0,\n    0,   -4,   -2,    0, -250,    0,    0,    0,    0,   -9,\n    0,    1,  -10,  -49,    0,    0,    3,    0,  -44, -248,\n    0, -244,    0,  -22, -242, -244, -245,  -37,    0,   10,\n    0, -244,    0,  -20,    0,\n};\nstatic YYCONST short yyrindex[] = {                                      0,\n    0,   22,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,   23,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,  -39,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,\n};\nstatic YYCONST short yygindex[] = {                                      0,\n   11,    0,  -23,    0,    0,    0,    0,\n};\n#define YYTABLESIZE 255\nstatic YYCONST short yytable[] = {                                      18,\n   15,   16,   28,   31,   16,    7,   32,    9,   34,   11,\n   16,   20,   21,   22,   23,   24,   29,   26,   27,   33,\n   35,    2,    1,   19,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,   16,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n    0,    0,    0,    0,    0,   17,    0,    0,    0,   11,\n   14,    3,    4,    5,    6,\n};\nstatic YYCONST short yycheck[] = {                                      10,\n   10,   41,   26,   41,   44,   10,   44,   10,   32,  260,\n   10,   61,   10,   58,  263,  260,  262,   40,  261,   10,\n   41,    0,    0,   13,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,  261,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,\n   -1,   -1,   -1,   -1,   -1,  256,   -1,   -1,   -1,  260,\n  260,  256,  257,  258,  259,\n};\n#define YYFINAL 1\n#ifndef YYDEBUG\n#define YYDEBUG 0\n#endif\n#define YYMAXTOKEN 263\n#if YYDEBUG\nstatic YYCONST char *YYCONST yyname[] = {\n\"end-of-file\",0,0,0,0,0,0,0,0,0,\"'\\\\n'\",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n0,0,0,0,0,0,0,0,0,\"'('\",\"')'\",0,0,\"','\",0,0,0,0,0,0,0,0,0,0,0,0,0,\"':'\",0,0,\n\"'='\",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n\"TERMINAL\",\"START\",\"PPERCENT\",\"ID\",\"TEMPLATE\",\"CODE\",\"INT\",\n};\nstatic YYCONST char *YYCONST yyrule[] = {\n\"$accept : spec\",\n\"spec : decls PPERCENT rules\",\n\"spec : decls\",\n\"decls :\",\n\"decls : decls decl\",\n\"decl : TERMINAL blist '\\\\n'\",\n\"decl : START nonterm '\\\\n'\",\n\"decl : '\\\\n'\",\n\"decl : error '\\\\n'\",\n\"blist :\",\n\"blist : blist ID '=' INT\",\n\"rules :\",\n\"rules : rules nonterm ':' tree TEMPLATE cost '\\\\n'\",\n\"rules : rules '\\\\n'\",\n\"rules : rules error '\\\\n'\",\n\"nonterm : ID\",\n\"tree : ID\",\n\"tree : ID '(' tree ')'\",\n\"tree : ID '(' tree ',' tree ')'\",\n\"cost : CODE\",\n};\n#endif\n#define YYLEX yylex()\n#define YYEMPTY -1\n#define yyclearin (yychar=(YYEMPTY))\n#define yyerrok (yyerrflag=0)\n#ifndef YYINITDEPTH\n#define YYINITDEPTH 200\n#endif\n#ifdef YYSTACKSIZE\n#ifndef YYMAXDEPTH\n#define YYMAXDEPTH YYSTACKSIZE\n#endif\n#else\n#ifdef YYMAXDEPTH\n#define YYSTACKSIZE YYMAXDEPTH\n#else\n#define YYSTACKSIZE 500\n#define YYMAXDEPTH 500\n#endif\n#endif\n#ifndef YYMAXSTACKSIZE\n#define YYMAXSTACKSIZE 10000\n#endif\nint yydebug;\nint yynerrs;\nint yyerrflag;\nint yychar;\nYYSTYPE yyval;\nYYSTYPE yylval;\nstatic short *yyss;\nstatic YYSTYPE *yyvs;\nstatic int yystacksize;\n#define yyfree(x) free(x)\nextern int yylex();\n\nstatic YYPTR\nYYDEFUN (yymalloc, (bytes), unsigned bytes)\n{\n    YYPTR ptr = (YYPTR) malloc (bytes);\n    if (ptr != 0) return (ptr);\n    yyerror (\"yyparse: memory exhausted\");\n    return (0);\n}\n\nstatic YYPTR\nYYDEFUN (yyrealloc, (old, bytes), YYPTR old YYAND unsigned bytes)\n{\n    YYPTR ptr = (YYPTR) realloc (old, bytes);\n    if (ptr != 0) return (ptr);\n    yyerror (\"yyparse: memory exhausted\");\n    return (0);\n}\n\nstatic int\n#ifdef __GNUC__\ninline\n#endif\nyygrow ()\n{\n    int old_stacksize = yystacksize;\n    short *new_yyss;\n    YYSTYPE *new_yyvs;\n\n    if (yystacksize == YYMAXSTACKSIZE)\n        return (1);\n    yystacksize += (yystacksize + 1 ) / 2;\n    if (yystacksize > YYMAXSTACKSIZE)\n        yystacksize = YYMAXSTACKSIZE;\n#if YYDEBUG\n    if (yydebug)\n        printf(\"yydebug: growing stack size from %d to %d\\n\",\n               old_stacksize, yystacksize);\n#endif\n    new_yyss = (short *) yyrealloc ((char *)yyss, yystacksize * sizeof (short));\n    if (new_yyss == 0)\n        return (1);\n    new_yyvs = (YYSTYPE *) yyrealloc ((char *)yyvs, yystacksize * sizeof (YYSTYPE));\n    if (new_yyvs == 0)\n    {\n        yyfree (new_yyss);\n        return (1);\n    }\n    yyss = new_yyss;\n    yyvs = new_yyvs;\n    return (0);\n}\n#line 60 \"lburg/gram.y\"\n#include <assert.h>\n#include <stdarg.h>\n#include <ctype.h>\n#include <string.h>\n#include <limits.h>\n\nint errcnt = 0;\nFILE *infp = NULL;\nFILE *outfp = NULL;\nstatic char buf[BUFSIZ], *bp = buf;\nstatic int ppercent = 0;\nstatic int code = 0;\n\nstatic int get(void) {\n\tif (*bp == 0) {\n\t\tbp = buf;\n\t\t*bp = 0;\n\t\tif (fgets(buf, sizeof buf, infp) == NULL)\n\t\t\treturn EOF;\n\t\tyylineno++;\n\t\twhile (buf[0] == '%' && buf[1] == '{' && buf[2] == '\\n') {\n\t\t\tfor (;;) {\n\t\t\t\tif (fgets(buf, sizeof buf, infp) == NULL) {\n\t\t\t\t\tyywarn(\"unterminated %{...%}\\n\");\n\t\t\t\t\treturn EOF;\n\t\t\t\t}\n\t\t\t\tyylineno++;\n\t\t\t\tif (strcmp(buf, \"%}\\n\") == 0)\n\t\t\t\t\tbreak;\n\t\t\t\tfputs(buf, outfp);\n\t\t\t}\n\t\t\tif (fgets(buf, sizeof buf, infp) == NULL)\n\t\t\t\treturn EOF;\n\t\t\tyylineno++;\n\t\t}\n\t}\n\treturn *bp++;\n}\n\nvoid yyerror(char *fmt, ...) {\n\tva_list ap;\n\n\tva_start(ap, fmt);\n\tif (yylineno > 0)\n\t\tfprintf(stderr, \"line %d: \", yylineno);\n\tvfprintf(stderr, fmt, ap);\n\tif (fmt[strlen(fmt)-1] != '\\n')\n\t\t fprintf(stderr, \"\\n\");\n\terrcnt++;\n\tva_end(ap);\n}\n\nint yylex(void) {\n\tint c;\n\n\tif (code) {\n\t\tchar *p;\n\t\tbp += strspn(bp, \" \\t\\f\");\n\t\tp = strchr(bp, '\\n');\n\t\tif (p == NULL)\n\t\t\tp = strchr(bp, '\\n');\n\t\twhile (p > bp && isspace(p[-1]))\n\t\t\tp--;\n\t\tyylval.string = alloc(p - bp + 1);\n\t\tstrncpy(yylval.string, bp, p - bp);\n\t\tyylval.string[p - bp] = 0;\n\t\tbp = p;\n\t\tcode--;\n\t\treturn CODE;\n\t}\n\twhile ((c = get()) != EOF) {\n\t\tswitch (c) {\n\t\tcase ' ': case '\\f': case '\\t':\n\t\t\tcontinue;\n\t\tcase '\\n':\n\t\tcase '(': case ')': case ',':\n\t\tcase ':': case '=':\n\t\t\treturn c;\n\t\t}\n\t\tif (c == '%' && *bp == '%') {\n\t\t\tbp++;\n\t\t\treturn ppercent++ ? 0 : PPERCENT;\n\t\t} else if (c == '%' && strncmp(bp, \"term\", 4) == 0\n\t\t&& isspace(bp[4])) {\n\t\t\tbp += 4;\n\t\t\treturn TERMINAL;\n\t\t} else if (c == '%' && strncmp(bp, \"start\", 5) == 0\n\t\t&& isspace(bp[5])) {\n\t\t\tbp += 5;\n\t\t\treturn START;\n\t\t} else if (c == '\"') {\n\t\t\tchar *p = strchr(bp, '\"');\n\t\t\tif (p == NULL) {\n\t\t\t\tyyerror(\"missing \\\" in assembler template\\n\");\n\t\t\t\tp = strchr(bp, '\\n');\n\t\t\t\tif (p == NULL)\n\t\t\t\t\tp = strchr(bp, '\\0');\n\t\t\t}\n\t\t\tassert(p);\n\t\t\tyylval.string = alloc(p - bp + 1);\n\t\t\tstrncpy(yylval.string, bp, p - bp);\n\t\t\tyylval.string[p - bp] = 0;\n\t\t\tbp = *p == '\"' ? p + 1 : p;\n\t\t\tcode++;\n\t\t\treturn TEMPLATE;\n\t\t} else if (isdigit(c)) {\n\t\t\tint n = 0;\n\t\t\tdo {\n\t\t\t\tint d = c - '0';\n\t\t\t\tif (n > (INT_MAX - d)/10)\n\t\t\t\t\tyyerror(\"integer greater than %d\\n\", INT_MAX);\n\t\t\t\telse\n\t\t\t\t\tn = 10*n + d;\n\t\t\t\tc = get();\n\t\t\t} while (c != EOF && isdigit(c));\n\t\t\tbp--;\n\t\t\tyylval.n = n;\n\t\t\treturn INT;\n\t\t} else if (isalpha(c)) {\n\t\t\tchar *p = bp - 1;\n\t\t\twhile (isalpha(*bp) || isdigit(*bp) || *bp == '_')\n\t\t\t\tbp++;\n\t\t\tyylval.string = alloc(bp - p + 1);\n\t\t\tstrncpy(yylval.string, p, bp - p);\n\t\t\tyylval.string[bp - p] = 0;\n\t\t\treturn ID;\n\t\t} else if (isprint(c))\n\t\t\tyyerror(\"invalid character `%c'\\n\", c);\n\t\telse\n\t\t\tyyerror(\"invalid character `\\\\%03o'\\n\", (unsigned char)c);\n\t}\n\treturn 0;\n}\n\nvoid yywarn(char *fmt, ...) {\n\tva_list ap;\n\n\tva_start(ap, fmt);\n\tif (yylineno > 0)\n\t\tfprintf(stderr, \"line %d: \", yylineno);\n\tfprintf(stderr, \"warning: \");\n\tvfprintf(stderr, fmt, ap);\n}\n#line 403 \"y.tab.c\"\n#define YYABORT goto yyabort\n#define YYACCEPT goto yyaccept\n#define YYERROR goto yyerrlab\n\n#if YYDEBUG\n#ifdef __cplusplus\nextern \"C\" char *getenv();\n#else\nextern char *getenv();\n#endif\n#endif\n\nint\nyyparse()\n{\n    register int yym, yyn, yystate;\n    register YYSTYPE *yyvsp;\n    register short *yyssp;\n    short *yysse;\n#if YYDEBUG\n    register YYCONST char *yys;\n\n    if (yys = getenv(\"YYDEBUG\"))\n    {\n        yyn = *yys;\n        if (yyn >= '0' && yyn <= '9')\n            yydebug = yyn - '0';\n    }\n#endif\n\n    yynerrs = 0;\n    yyerrflag = 0;\n    yychar = (-1);\n\n    if (yyss == 0)\n    {\n        yyss = (short *) yymalloc (YYSTACKSIZE * sizeof (short));\n        if (yyss == 0)\n          goto yyabort;\n        yyvs = (YYSTYPE *) yymalloc (YYSTACKSIZE * sizeof (YYSTYPE));\n        if (yyvs == 0)\n        {\n            yyfree (yyss);\n            goto yyabort;\n        }\n        yystacksize = YYSTACKSIZE;\n    }\n    yysse = yyss + yystacksize - 1;\n    yyssp = yyss;\n    yyvsp = yyvs;\n    *yyssp = yystate = 0;\n    goto yyloop;\n\nyypush_lex:\n    yyval = yylval;\n    yystate = yytable[yyn];\nyypush:\n    if (yyssp >= yysse)\n    {\n        int depth = yyssp - yyss;\n        if (yygrow() != 0)\n             goto yyoverflow;\n        yysse = yyss + yystacksize -1;\n        yyssp = depth + yyss;\n        yyvsp = depth + yyvs;\n    }\n    *++yyssp = yystate;\n    *++yyvsp = yyval;\n\nyyloop:\n    if (yyn = yydefred[yystate]) goto yyreduce;\n    yyn = yysindex[yystate];\n    if (yychar < 0)\n    {\n        if ((yychar = yylex()) < 0) yychar = 0;\n#if YYDEBUG\n        if (yydebug)\n        {\n            yys = 0;\n            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];\n            if (!yys) yys = \"illegal-symbol\";\n            printf(\"yydebug: state %d, reading %d (%s)\\n\", yystate,\n                    yychar, yys);\n        }\n#endif\n    }\n    if (yyn != 0\n        && ((yyn += yychar), ((unsigned)yyn <= (unsigned)YYTABLESIZE))\n        && yycheck[yyn] == yychar)\n    {\n#if YYDEBUG\n        if (yydebug)\n            printf(\"yydebug: state %d, shifting to state %d\\n\",\n                    yystate, yytable[yyn]);\n#endif\n        if (yyerrflag > 0)  --yyerrflag;\n        yychar = (-1);\n        goto yypush_lex;\n    }\n    yyn = yyrindex[yystate];\n    if (yyn != 0\n        && ((yyn += yychar), ((unsigned)yyn <= (unsigned)YYTABLESIZE))\n        && yycheck[yyn] == yychar)\n    {\n        yyn = yytable[yyn];\n        goto yyreduce;\n    }\n    if (yyerrflag) goto yyinrecovery;\n#ifdef lint\n    goto yynewerror;\n#endif\nyynewerror:\n    yyerror(\"syntax error\");\n#ifdef lint\n    goto yyerrlab;\n#endif\nyyerrlab:\n    ++yynerrs;\nyyinrecovery:\n    if (yyerrflag < 3)\n    {\n        yyerrflag = 3;\n        for (;;)\n        {\n            yyn = yysindex[*yyssp];\n            if (yyn != 0\n                && ((yyn += YYERRCODE), ((unsigned)yyn <= (unsigned)YYTABLESIZE))\n                && yycheck[yyn] == YYERRCODE)\n            {\n#if YYDEBUG\n                if (yydebug)\n                    printf(\"yydebug: state %d, error recovery shifting\\\n to state %d\\n\", *yyssp, yytable[yyn]);\n#endif\n                goto yypush_lex;\n            }\n            else\n            {\n#if YYDEBUG\n                if (yydebug)\n                    printf(\"yydebug: error recovery discarding state %d\\n\",\n                            *yyssp);\n#endif\n                if (yyssp <= yyss) goto yyabort;\n                --yyssp;\n                --yyvsp;\n            }\n        }\n    }\n    else\n    {\n        if (yychar == 0) goto yyabort;\n#if YYDEBUG\n        if (yydebug)\n        {\n            yys = 0;\n            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];\n            if (!yys) yys = \"illegal-symbol\";\n            printf(\"yydebug: state %d, error recovery discards token %d (%s)\\n\",\n                    yystate, yychar, yys);\n        }\n#endif\n        yychar = (-1);\n        goto yyloop;\n    }\nyyreduce:\n#if YYDEBUG\n    if (yydebug)\n        printf(\"yydebug: state %d, reducing by rule %d (%s)\\n\",\n                yystate, yyn, yyrule[yyn]);\n#endif\n    yym = yylen[yyn];\n    yyval = yyvsp[1-yym];\n    switch (yyn)\n    {\ncase 1:\n#line 22 \"lburg/gram.y\"\n{ yylineno = 0; }\nbreak;\ncase 2:\n#line 23 \"lburg/gram.y\"\n{ yylineno = 0; }\nbreak;\ncase 6:\n#line 31 \"lburg/gram.y\"\n{\n\t\tif (nonterm(yyvsp[-1].string)->number != 1)\n\t\t\tyyerror(\"redeclaration of the start symbol\\n\");\n\t\t}\nbreak;\ncase 8:\n#line 36 \"lburg/gram.y\"\n{ yyerrok; }\nbreak;\ncase 10:\n#line 40 \"lburg/gram.y\"\n{ term(yyvsp[-2].string, yyvsp[0].n); }\nbreak;\ncase 12:\n#line 44 \"lburg/gram.y\"\n{ rule(yyvsp[-5].string, yyvsp[-3].tree, yyvsp[-2].string, yyvsp[-1].string); }\nbreak;\ncase 14:\n#line 46 \"lburg/gram.y\"\n{ yyerrok; }\nbreak;\ncase 15:\n#line 49 \"lburg/gram.y\"\n{ nonterm(yyval.string = yyvsp[0].string); }\nbreak;\ncase 16:\n#line 52 \"lburg/gram.y\"\n{ yyval.tree = tree(yyvsp[0].string,  0,  0); }\nbreak;\ncase 17:\n#line 53 \"lburg/gram.y\"\n{ yyval.tree = tree(yyvsp[-3].string, yyvsp[-1].tree,  0); }\nbreak;\ncase 18:\n#line 54 \"lburg/gram.y\"\n{ yyval.tree = tree(yyvsp[-5].string, yyvsp[-3].tree, yyvsp[-1].tree); }\nbreak;\ncase 19:\n#line 57 \"lburg/gram.y\"\n{ if (*yyvsp[0].string == 0) yyval.string = \"0\"; }\nbreak;\n#line 630 \"y.tab.c\"\n    }\n    yyssp -= yym;\n    yyvsp -= yym;\n    yym = yylhs[yyn];\n    yystate = *yyssp;\n    if (yystate == 0 && yym == 0)\n    {\n#if YYDEBUG\n        if (yydebug)\n            printf(\"yydebug: after reduction, shifting from state 0 to\\\n state %d\\n\", YYFINAL);\n#endif\n        yystate = YYFINAL;\n        *++yyssp = YYFINAL;\n        *++yyvsp = yyval;\n        if (yychar < 0)\n        {\n            if ((yychar = yylex()) < 0) yychar = 0;\n#if YYDEBUG\n            if (yydebug)\n            {\n                yys = 0;\n                if (yychar <= YYMAXTOKEN) yys = yyname[yychar];\n                if (!yys) yys = \"illegal-symbol\";\n                printf(\"yydebug: state %d, reading %d (%s)\\n\",\n                        YYFINAL, yychar, yys);\n            }\n#endif\n        }\n        if (yychar == 0) goto yyaccept;\n        goto yyloop;\n    }\n    yyn = yygindex[yym];\n\t if (yyn != 0\n        && ((yyn += yystate), ((unsigned)yyn <= (unsigned)YYTABLESIZE))\n        && yycheck[yyn] == yystate)\n        yystate = yytable[yyn];\n    else\n        yystate = yydgoto[yym];\n#if YYDEBUG\n    if (yydebug)\n        printf(\"yydebug: after reduction, shifting from state %d \\\nto state %d\\n\", *yyssp, yystate);\n#endif\n    goto yypush;\nyyoverflow:\n    yyerror(\"yacc stack overflow\");\nyyabort:\n    return (1);\nyyaccept:\n    return (0);\n}\n"
  },
  {
    "path": "lcc/lburg/gram.y",
    "content": "%{\n#include <stdio.h>\n#include \"lburg.h\"\nstatic char rcsid[] = \"$Id: gram.y 145 2001-10-17 21:53:10Z timo $\";\n/*lint -e616 -e527 -e652 -esym(552,yynerrs) -esym(563,yynewstate,yyerrlab) */\nstatic int yylineno = 0;\n%}\n%union {\n\tint n;\n\tchar *string;\n\tTree tree;\n}\n%term TERMINAL\n%term START\n%term PPERCENT\n\n%token  <string>        ID TEMPLATE CODE\n%token  <n>             INT\n%type\t<string>\tnonterm cost\n%type   <tree>          tree\n%%\nspec\t: decls PPERCENT rules\t\t{ yylineno = 0; }\n\t| decls\t\t\t\t{ yylineno = 0; }\n\t;\n\ndecls\t: /* lambda */\n\t| decls decl\n\t;\n\ndecl\t: TERMINAL  blist '\\n'\n\t| START nonterm '\\n'\t\t{\n\t\tif (nonterm($2)->number != 1)\n\t\t\tyyerror(\"redeclaration of the start symbol\\n\");\n\t\t}\n\t| '\\n'\n\t| error '\\n'\t\t\t{ yyerrok; }\n\t;\n\nblist\t: /* lambda */\n\t| blist ID '=' INT      \t{ term($2, $4); }\n\t;\n\nrules\t: /* lambda */\n\t| rules nonterm ':' tree TEMPLATE cost '\\n'\t{ rule($2, $4, $5, $6); }\n\t| rules '\\n'\n\t| rules error '\\n'\t\t{ yyerrok; }\n\t;\n\nnonterm\t: ID\t\t\t\t{ nonterm($$ = $1); }\n\t;\n\ntree\t: ID                            { $$ = tree($1,  0,  0); }\n\t| ID '(' tree ')'               { $$ = tree($1, $3,  0); }\n\t| ID '(' tree ',' tree ')'      { $$ = tree($1, $3, $5); }\n\t;\n\ncost\t: CODE\t\t\t\t{ if (*$1 == 0) $$ = \"0\"; }\n\t;\n%%\n#include <assert.h>\n#include <stdarg.h>\n#include <ctype.h>\n#include <string.h>\n#include <limits.h>\n\nint errcnt = 0;\nFILE *infp = NULL;\nFILE *outfp = NULL;\nstatic char buf[BUFSIZ], *bp = buf;\nstatic int ppercent = 0;\nstatic int code = 0;\n\nstatic int get(void) {\n\tif (*bp == 0) {\n\t\tbp = buf;\n\t\t*bp = 0;\n\t\tif (fgets(buf, sizeof buf, infp) == NULL)\n\t\t\treturn EOF;\n\t\tyylineno++;\n\t\twhile (buf[0] == '%' && buf[1] == '{' && buf[2] == '\\n') {\n\t\t\tfor (;;) {\n\t\t\t\tif (fgets(buf, sizeof buf, infp) == NULL) {\n\t\t\t\t\tyywarn(\"unterminated %{...%}\\n\");\n\t\t\t\t\treturn EOF;\n\t\t\t\t}\n\t\t\t\tyylineno++;\n\t\t\t\tif (strcmp(buf, \"%}\\n\") == 0)\n\t\t\t\t\tbreak;\n\t\t\t\tfputs(buf, outfp);\n\t\t\t}\n\t\t\tif (fgets(buf, sizeof buf, infp) == NULL)\n\t\t\t\treturn EOF;\n\t\t\tyylineno++;\n\t\t}\n\t}\n\treturn *bp++;\n}\n\nvoid yyerror(char *fmt, ...) {\n\tva_list ap;\n\n\tva_start(ap, fmt);\n\tif (yylineno > 0)\n\t\tfprintf(stderr, \"line %d: \", yylineno);\n\tvfprintf(stderr, fmt, ap);\n\tif (fmt[strlen(fmt)-1] != '\\n')\n\t\t fprintf(stderr, \"\\n\");\n\terrcnt++;\n\tva_end(ap);\n}\n\nint yylex(void) {\n\tint c;\n\n\tif (code) {\n\t\tchar *p;\n\t\tbp += strspn(bp, \" \\t\\f\");\n\t\tp = strchr(bp, '\\n');\n\t\tif (p == NULL)\n\t\t\tp = strchr(bp, '\\n');\n\t\twhile (p > bp && isspace(p[-1]))\n\t\t\tp--;\n\t\tyylval.string = alloc(p - bp + 1);\n\t\tstrncpy(yylval.string, bp, p - bp);\n\t\tyylval.string[p - bp] = 0;\n\t\tbp = p;\n\t\tcode--;\n\t\treturn CODE;\n\t}\n\twhile ((c = get()) != EOF) {\n\t\tswitch (c) {\n\t\tcase ' ': case '\\f': case '\\t':\n\t\t\tcontinue;\n\t\tcase '\\n':\n\t\tcase '(': case ')': case ',':\n\t\tcase ':': case '=':\n\t\t\treturn c;\n\t\t}\n\t\tif (c == '%' && *bp == '%') {\n\t\t\tbp++;\n\t\t\treturn ppercent++ ? 0 : PPERCENT;\n\t\t} else if (c == '%' && strncmp(bp, \"term\", 4) == 0\n\t\t&& isspace(bp[4])) {\n\t\t\tbp += 4;\n\t\t\treturn TERMINAL;\n\t\t} else if (c == '%' && strncmp(bp, \"start\", 5) == 0\n\t\t&& isspace(bp[5])) {\n\t\t\tbp += 5;\n\t\t\treturn START;\n\t\t} else if (c == '\"') {\n\t\t\tchar *p = strchr(bp, '\"');\n\t\t\tif (p == NULL) {\n\t\t\t\tyyerror(\"missing \\\" in assembler template\\n\");\n\t\t\t\tp = strchr(bp, '\\n');\n\t\t\t\tif (p == NULL)\n\t\t\t\t\tp = strchr(bp, '\\0');\n\t\t\t}\n\t\t\tassert(p);\n\t\t\tyylval.string = alloc(p - bp + 1);\n\t\t\tstrncpy(yylval.string, bp, p - bp);\n\t\t\tyylval.string[p - bp] = 0;\n\t\t\tbp = *p == '\"' ? p + 1 : p;\n\t\t\tcode++;\n\t\t\treturn TEMPLATE;\n\t\t} else if (isdigit(c)) {\n\t\t\tint n = 0;\n\t\t\tdo {\n\t\t\t\tint d = c - '0';\n\t\t\t\tif (n > (INT_MAX - d)/10)\n\t\t\t\t\tyyerror(\"integer greater than %d\\n\", INT_MAX);\n\t\t\t\telse\n\t\t\t\t\tn = 10*n + d;\n\t\t\t\tc = get();\n\t\t\t} while (c != EOF && isdigit(c));\n\t\t\tbp--;\n\t\t\tyylval.n = n;\n\t\t\treturn INT;\n\t\t} else if (isalpha(c)) {\n\t\t\tchar *p = bp - 1;\n\t\t\twhile (isalpha(*bp) || isdigit(*bp) || *bp == '_')\n\t\t\t\tbp++;\n\t\t\tyylval.string = alloc(bp - p + 1);\n\t\t\tstrncpy(yylval.string, p, bp - p);\n\t\t\tyylval.string[bp - p] = 0;\n\t\t\treturn ID;\n\t\t} else if (isprint(c))\n\t\t\tyyerror(\"invalid character `%c'\\n\", c);\n\t\telse\n\t\t\tyyerror(\"invalid character `\\\\%03o'\\n\", (unsigned char)c);\n\t}\n\treturn 0;\n}\n\nvoid yywarn(char *fmt, ...) {\n\tva_list ap;\n\n\tva_start(ap, fmt);\n\tif (yylineno > 0)\n\t\tfprintf(stderr, \"line %d: \", yylineno);\n\tfprintf(stderr, \"warning: \");\n\tvfprintf(stderr, fmt, ap);\n}\n"
  },
  {
    "path": "lcc/lburg/lburg.1",
    "content": ".TH LBURG 1 \"local \\- 11/30/94\"\n.\\\" $Id: lburg.1 145 2001-10-17 21:53:10Z timo $\n.SH NAME\nlburg \\- lcc's code-generator generator\n.SH SYNOPSIS\n.B lburg\n[\n.I option\n]...\n[ [\n.I input\n]\n.I output\n]\n.br\n.SH DESCRIPTION\n.PP\n.I lburg\nreads an lcc-style BURG specification from\n.I input\nand writes a pattern-matching code generator to\n.IR output .\nIf\n.I input\nis `\\-' or is omitted,\n.I lburg\nreads the standard input;\nIf\n.I output\nis `\\-' or is omitted,\n.I lburg\nwrites to the standard output.\n.PP\n.I lburg\naccepts specifications that conform to the following EBNF grammar.\nTerminals are enclosed in single quotes or are\ngiven in uppercase, all other symbols are nonterminals or English phrases,\n{X} denotes zero or more instances of X, and [X] denotes an optional X.\n.PP\n.nf\n.RS\n.ft CW\nspec:     `%{' configuration `%}' { dcl } `%%' { rule }\n               [ `%%' C code ]\n\ndcl:      `%start' nonterm\n          `%term' { ID `=' INT }\n\nrule:     nonterm `:' tree template [ C expression ]\n\ntree:     term `(' tree `,' tree `)'\n          term `(' tree `)'\n          term\n          nonterm\n\nnonterm:  ID\n\ntemplate: `\"' { any character except double quote } `\"'\n.RE\n.fi\n.PP\nSpecifications are structurally similar to\n.IR yacc 's.\nText between\n`\\f(CW%{\\fP'\nand\n`\\f(CW%}\\fP'\nis called the configuration section; there may be several such segments.\nAll are concatenated and copied verbatim into the head of the output.\nText after the second\n`\\f(CW%%\\fP',\nif any, is also copied verbatim into the output, at the end.\n.PP\nSpecifications consist of declarations, a\n`\\f(CW%%\\fP'\nseparator, and rules.\nInput is line-oriented; each declaration and rule must appear on a separate line,\nand declarations must begin in column 1.\nDeclarations declare terminals \\(em the operators in subject\ntrees \\(em and associate a unique, positive external symbol\nnumber with each one.\nNonterminals are declared by their presence\non the left side of rules.  The\n\\f(CW%start\\fP\ndeclaration optionally declares a nonterminal as the start symbol.\nIn the grammar above,\n\\f(CWterm\\fP\nand\n\\f(CWnonterm\\fP\ndenote identifiers that are terminals and nonterminals.\n.PP\nRules define tree patterns in a fully parenthesized prefix\nform. Every nonterminal denotes a tree.\nEach operator has a fixed\narity, which is inferred from the rules in which it is used.\nA chain rule is a rule whose pattern is another nonterminal.\nIf no start symbol is declared, the nonterminal defined by the first rule is used.\n.PP\nEach rule ends with an expression that computes the cost of matching\nthat rule; omitted costs\ndefault to zero. Costs of chain rules must be constants.\n.PP\nThe configuration section configures the output\nfor the trees being parsed and the client's environment.\nAs shown, this section must define\n\\f(CWNODEPTR_TYPE\\fP\nto be a visible typedef symbol for a pointer to a\nnode in the subject tree.\nThe labeller invokes\n\\f(CWOP_LABEL(p)\\fP,\n\\f(CWLEFT\\_CHILD(p)\\fP, and\n\\f(CWRIGHT\\_CHILD(p)\\fP\nto read the operator and children from the node pointed to by \\f(CWp\\fP.\nIf the configuration section defines these operations as macros, they are implemented in-line;\notherwise, they must be implemented as functions.\n.PP\nThe matcher\ncomputes and stores a single integral state in each node of the subject tree.\nThe configuration section must define a macro\n\\f(CWSTATE_LABEL(p)\\fP\nto access the state field of the node pointed to\nby \\f(CWp\\fP. It must be large enough to hold a pointer, and\na macro is required because it is used as an lvalue.\n.PP\n.SH OPTIONS\n.TP\n.BI \\-p \\ prefix\n.br\n.ns\n.TP\n.BI \\-p prefix\nUse\n.I prefix\nas the disambiquating prefix for visible names and fields.\nThe default is `\\f(CW_\\fP'.\n.TP\n.B \\-T\nArrange for\n.sp\n.nf\n.ft CW\n    void _trace(NODEPTR_TYPE p, int eruleno,\n                    int cost, int bestcost);\n.sp\n.fi\n.ft R\nto be called at each successful match.\n\\f(CWp\\fP\nidentifies the node and\n\\f(CWeruleno\\fP\nidentifies the matching rule; the rules are numbered\nbeginning at 1 in the order they appear in the input.\n\\f(CWcost\\fP\nis the cost of the match and\n\\f(CWbestcost\\fP\nis the cost of the best previous match. The current match\nwins only if\n\\f(CWcost\\fP\nis less than \\f(CWbestcost\\fP.\n32767 represents the infinite cost of no previous match.\n\\f(CW_trace\\fP must be declared in the configuration section.\n.SH \"SEE ALSO\"\n.IR lcc (1)\n.PP\nC. W. Fraser and D. R. Hanson,\n.IR A Retargetable C Compiler: Design and Implementation ,\nBenjamin/Cummings, Redwood City, CA, 1995,\nISBN 0-8053-1670-1. Chapter 14.\n.PP\nC. W. Fraser, D. R. Hanson and T. A. Proebsting,\n`Engineering a simple, efficient code generator generator,'\n.I\nACM Letters on Programming Languages and Systems\n.BR 1 ,\n3 (Sep. 1992), 213-226.\n.br\n.SH BUGS\nMail bug reports along with the shortest input\nthat exposes them to drh@cs.princeton.edu.\n"
  },
  {
    "path": "lcc/lburg/lburg.c",
    "content": "#include <assert.h>\n#include <ctype.h>\n#include <stdarg.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#include <time.h>\n#include \"lburg.h\"\n\nstatic char rcsid[] = \"lburg.c - faked rcsid\";\n\nstatic char *prefix = \"\";\nstatic int Tflag = 0;\nstatic int ntnumber = 0;\nstatic Nonterm start = 0;\nstatic Term terms;\nstatic Nonterm nts;\nstatic Rule rules;\nstatic int nrules;\nstatic struct block {\n\tstruct block *link;\n} *memlist;\t\t\t/* list of allocated blocks */\n\nstatic char *stringf(char *fmt, ...);\nstatic void print(char *fmt, ...);\nstatic void ckreach(Nonterm p);\nstatic void emitclosure(Nonterm nts);\nstatic void emitcost(Tree t, char *v);\nstatic void emitdefs(Nonterm nts, int ntnumber);\nstatic void emitheader(void);\nstatic void emitkids(Rule rules, int nrules);\nstatic void emitnts(Rule rules, int nrules);\nstatic void emitrecalc(char *pre, Term root, Term kid);\nstatic void emitrecord(char *pre, Rule r, char *c, int cost);\nstatic void emitrule(Nonterm nts);\nstatic void emitlabel(Term terms, Nonterm start, int ntnumber);\nstatic void emitstring(Rule rules);\nstatic void emitstruct(Nonterm nts, int ntnumber);\nstatic void emittest(Tree t, char *v, char *suffix);\n\nint main(int argc, char *argv[]) {\n\tint c, i;\n\tNonterm p;\n\t\n\tfor (i = 1; i < argc; i++)\n\t\tif (strcmp(argv[i], \"-T\") == 0)\n\t\t\tTflag = 1;\n\t\telse if (strncmp(argv[i], \"-p\", 2) == 0 && argv[i][2])\n\t\t\tprefix = &argv[i][2];\n\t\telse if (strncmp(argv[i], \"-p\", 2) == 0 && i + 1 < argc)\n\t\t\tprefix = argv[++i];\n\t\telse if (*argv[i] == '-' && argv[i][1]) {\n\t\t\tyyerror(\"usage: %s [-T | -p prefix]... [ [ input ] output ] \\n\",\n\t\t\t\targv[0]);\n\t\t\texit(1);\n\t\t} else if (infp == NULL) {\n\t\t\tif (strcmp(argv[i], \"-\") == 0)\n\t\t\t\tinfp = stdin;\n\t\t\telse if ((infp = fopen(argv[i], \"r\")) == NULL) {\n\t\t\t\tyyerror(\"%s: can't read `%s'\\n\", argv[0], argv[i]);\n\t\t\t\texit(1);\n\t\t\t}\n\t\t} else if (outfp == NULL) {\n\t\t\tif (strcmp(argv[i], \"-\") == 0)\n\t\t\t\toutfp = stdout;\n\t\t\tif ((outfp = fopen(argv[i], \"w\")) == NULL) {\n\t\t\t\tyyerror(\"%s: can't write `%s'\\n\", argv[0], argv[i]);\n\t\t\t\texit(1);\n\t\t\t}\n\t\t}\n\tif (infp == NULL)\n\t\tinfp = stdin;\n\tif (outfp == NULL)\n\t\toutfp = stdout;\n\tyyparse();\n\tif (start)\n\t\tckreach(start);\n\tfor (p = nts; p; p = p->link) {\n\t\tif (p->rules == NULL)\n\t\t\tyyerror(\"undefined nonterminal `%s'\\n\", p->name);\n\t\tif (!p->reached)\n\t\t\tyyerror(\"can't reach nonterminal `%s'\\n\", p->name);\n\t}\n\temitheader();\n\temitdefs(nts, ntnumber);\n\temitstruct(nts, ntnumber);\n\temitnts(rules, nrules);\n\temitstring(rules);\n\temitrule(nts);\n\temitclosure(nts);\n\tif (start)\n\t\temitlabel(terms, start, ntnumber);\n\temitkids(rules, nrules);\n\tif (!feof(infp))\n\t\twhile ((c = getc(infp)) != EOF)\n\t\t\tputc(c, outfp);\n\twhile (memlist) {\t/* for purify */\n\t\tstruct block *q = memlist->link;\n\t\tfree(memlist);\n\t\tmemlist = q;\n\t}\n\treturn errcnt > 0;\n}\n\n/* alloc - allocate nbytes or issue fatal error */\nvoid *alloc(int nbytes) {\n\tstruct block *p = calloc(1, sizeof *p + nbytes);\n\n\tif (p == NULL) {\n\t\tyyerror(\"out of memory\\n\");\n\t\texit(1);\n\t}\n\tp->link = memlist;\n\tmemlist = p;\n\treturn p + 1;\n}\n\n/* stringf - format and save a string */\nstatic char *stringf(char *fmt, ...) {\n\tva_list ap;\n\tchar buf[512];\n\n\tva_start(ap, fmt);\n\tvsprintf(buf, fmt, ap);\n\tva_end(ap);\n\treturn strcpy(alloc(strlen(buf) + 1), buf);\n}\t\n\nstruct entry {\n\tunion {\n\t\tchar *name;\n\t\tstruct term t;\n\t\tstruct nonterm nt;\n\t} sym;\n\tstruct entry *link;\n} *table[211];\n#define HASHSIZE (sizeof table/sizeof table[0])\n\n/* hash - return hash number for str */\nstatic unsigned hash(char *str) {\n\tunsigned h = 0;\n\n\twhile (*str)\n\t\th = (h<<1) + *str++;\n\treturn h;\n}\n\n/* lookup - lookup symbol name */\nstatic void *lookup(char *name) {\n\tstruct entry *p = table[hash(name)%HASHSIZE];\n\n\tfor ( ; p; p = p->link)\n\t\tif (strcmp(name, p->sym.name) == 0)\n\t\t\treturn &p->sym;\n\treturn 0;\n}\n\n/* install - install symbol name */\nstatic void *install(char *name) {\n\tstruct entry *p = alloc(sizeof *p);\n\tint i = hash(name)%HASHSIZE;\n\n\tp->sym.name = name;\n\tp->link = table[i];\n\ttable[i] = p;\n\treturn &p->sym;\n}\n\n/* nonterm - create a new terminal id, if necessary */\nNonterm nonterm(char *id) {\n\tNonterm p = lookup(id), *q = &nts;\n\n\tif (p && p->kind == NONTERM)\n\t\treturn p;\n\tif (p && p->kind == TERM)\n\t\tyyerror(\"`%s' is a terminal\\n\", id);\n\tp = install(id);\n\tp->kind = NONTERM;\n\tp->number = ++ntnumber;\n\tif (p->number == 1)\n\t\tstart = p;\n\twhile (*q && (*q)->number < p->number)\n\t\tq = &(*q)->link;\n\tassert(*q == 0 || (*q)->number != p->number);\n\tp->link = *q;\n\t*q = p;\n\treturn p;\n}\n\n/* term - create a new terminal id with external symbol number esn */\nTerm term(char *id, int esn) {\n\tTerm p = lookup(id), *q = &terms;\n\n\tif (p)\n\t\tyyerror(\"redefinition of terminal `%s'\\n\", id);\n\telse\n\t\tp = install(id);\n\tp->kind = TERM;\n\tp->esn = esn;\n\tp->arity = -1;\n\twhile (*q && (*q)->esn < p->esn)\n\t\tq = &(*q)->link;\n\tif (*q && (*q)->esn == p->esn)\n\t\tyyerror(\"duplicate external symbol number `%s=%d'\\n\",\n\t\t\tp->name, p->esn);\n\tp->link = *q;\n\t*q = p;\n\treturn p;\n}\n\n/* tree - create & initialize a tree node with the given fields */\nTree tree(char *id, Tree left, Tree right) {\n\tTree t = alloc(sizeof *t);\n\tTerm p = lookup(id);\n\tint arity = 0;\n\n\tif (left && right)\n\t\tarity = 2;\n\telse if (left)\n\t\tarity = 1;\n\tif (p == NULL && arity > 0) {\n\t\tyyerror(\"undefined terminal `%s'\\n\", id);\n\t\tp = term(id, -1);\n\t} else if (p == NULL && arity == 0)\n\t\tp = (Term)nonterm(id);\n\telse if (p && p->kind == NONTERM && arity > 0) {\n\t\tyyerror(\"`%s' is a nonterminal\\n\", id);\n\t\tp = term(id, -1);\n\t}\n\tif (p->kind == TERM && p->arity == -1)\n\t\tp->arity = arity;\n\tif (p->kind == TERM && arity != p->arity)\n\t\tyyerror(\"inconsistent arity for terminal `%s'\\n\", id);\n\tt->op = p;\n\tt->nterms = p->kind == TERM;\n\tif ((t->left = left) != NULL)\n\t\tt->nterms += left->nterms;\n\tif ((t->right = right) != NULL)\n\t\tt->nterms += right->nterms;\n\treturn t;\n}\n\n/* rule - create & initialize a rule with the given fields */\nRule rule(char *id, Tree pattern, char *template, char *code) {\n\tRule r = alloc(sizeof *r), *q;\n\tTerm p = pattern->op;\n\tchar *end;\n\n\tr->lhs = nonterm(id);\n\tr->packed = ++r->lhs->lhscount;\n\tfor (q = &r->lhs->rules; *q; q = &(*q)->decode)\n\t\t;\n\t*q = r;\n\tr->pattern = pattern;\n\tr->ern = ++nrules;\n\tr->template = template;\n\tr->code = code;\n\tr->cost = strtol(code, &end, 10);\n\tif (*end) {\n\t\tr->cost = -1;\n\t\tr->code = stringf(\"(%s)\", code);\n\t}\n\tif (p->kind == TERM) {\n\t\tfor (q = &p->rules; *q; q = &(*q)->next)\n\t\t\t;\n\t\t*q = r;\n\t} else if (pattern->left == NULL && pattern->right == NULL) {\n\t\tNonterm p = pattern->op;\n\t\tr->chain = p->chain;\n\t        p->chain = r;\n\t\tif (r->cost == -1)\n\t\t\tyyerror(\"illegal nonconstant cost `%s'\\n\", code);\n\t}\n\tfor (q = &rules; *q; q = &(*q)->link)\n\t\t;\n\tr->link = *q;\n\t*q = r;\n\treturn r;\n}\n\n/* print - formatted output */\nstatic void print(char *fmt, ...) {\n\tva_list ap;\n\n\tva_start(ap, fmt);\n\tfor ( ; *fmt; fmt++)\n\t\tif (*fmt == '%')\n\t\t\tswitch (*++fmt) {\n\t\t\tcase 'd': fprintf(outfp, \"%d\", va_arg(ap, int)); break;\n\t\t\tcase 's': fputs(va_arg(ap, char *), outfp); break;\n\t\t\tcase 'P': fprintf(outfp, \"%s_\", prefix); break;\n\t\t\tcase 'T': {\n\t\t\t\tTree t = va_arg(ap, Tree);\n\t\t\t\tprint(\"%S\", t->op);\n\t\t\t\tif (t->left && t->right)\n\t\t\t\t\tprint(\"(%T,%T)\", t->left, t->right);\n\t\t\t\telse if (t->left)\n\t\t\t\t\tprint(\"(%T)\", t->left);\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\tcase 'R': {\n\t\t\t\tRule r = va_arg(ap, Rule);\n\t\t\t\tprint(\"%S: %T\", r->lhs, r->pattern);\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\tcase 'S': fputs(va_arg(ap, Term)->name, outfp); break;\n\t\t\tcase '1': case '2': case '3': case '4': case '5': {\n\t\t\t\tint n = *fmt - '0';\n\t\t\t\twhile (n-- > 0)\n\t\t\t\t\tputc('\\t', outfp);\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\tdefault: putc(*fmt, outfp); break;\t\t\t\n\t\t\t}\n\t\telse\n\t\t\tputc(*fmt, outfp);\n\tva_end(ap);\n}\n\n/* reach - mark all nonterminals in tree t as reachable */\nstatic void reach(Tree t) {\n\tNonterm p = t->op;\n\n\tif (p->kind == NONTERM)\n\t\tif (!p->reached)\n\t\t\tckreach(p);\n\tif (t->left)\n\t\treach(t->left);\n\tif (t->right)\n\t\treach(t->right);\n}\n\n/* ckreach - mark all nonterminals reachable from p */\nstatic void ckreach(Nonterm p) {\n\tRule r;\n\n        p->reached = 1;\n\tfor (r = p->rules; r; r = r->decode)\n\t\treach(r->pattern);\n}\n\n/* emitcase - emit one case in function state */\nstatic void emitcase(Term p, int ntnumber) {\n\tRule r;\n\n\tprint(\"%1case %d: /* %S */\\n\", p->esn, p);\n\tswitch (p->arity) {\n\tcase 0: case -1:\n\t\tbreak;\n\tcase 1:\n\t\tprint(\"%2%Plabel(LEFT_CHILD(a));\\n\");\n\t\tbreak;\n\tcase 2:\n\t\tprint(\"%2%Plabel(LEFT_CHILD(a));\\n\");\n\t\tprint(\"%2%Plabel(RIGHT_CHILD(a));\\n\");\n\t\tbreak;\n\tdefault: assert(0);\n\t}\n\tfor (r = p->rules; r; r = r->next) {\n\t\tchar *indent = \"\\t\\t\\0\";\n\t\tswitch (p->arity) {\n\t\tcase 0: case -1:\n\t\t\tprint(\"%2/* %R */\\n\", r);\n\t\t\tif (r->cost == -1) {\n\t\t\t\tprint(\"%2c = %s;\\n\", r->code);\n\t\t\t\temitrecord(\"\\t\\t\", r, \"c\", 0);\n\t\t\t} else\n\t\t\t\temitrecord(\"\\t\\t\", r, r->code, 0);\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\tif (r->pattern->nterms > 1) {\n\t\t\t\tprint(\"%2if (%1/* %R */\\n\", r);\n\t\t\t\temittest(r->pattern->left, \"LEFT_CHILD(a)\", \" \");\n\t\t\t\tprint(\"%2) {\\n\");\n\t\t\t\tindent = \"\\t\\t\\t\";\n\t\t\t} else\n\t\t\t\tprint(\"%2/* %R */\\n\", r);\n\t\t\tif (r->pattern->nterms == 2 && r->pattern->left\n\t\t\t&&  r->pattern->right == NULL)\n\t\t\t\temitrecalc(indent, r->pattern->op, r->pattern->left->op);\n\t\t\tprint(\"%sc = \", indent);\n\t\t\temitcost(r->pattern->left, \"LEFT_CHILD(a)\");\n\t\t\tprint(\"%s;\\n\", r->code);\n\t\t\temitrecord(indent, r, \"c\", 0);\n\t\t\tif (indent[2])\n\t\t\t\tprint(\"%2}\\n\");\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tif (r->pattern->nterms > 1) {\n\t\t\t\tprint(\"%2if (%1/* %R */\\n\", r);\n\t\t\t\temittest(r->pattern->left,  \"LEFT_CHILD(a)\",\n\t\t\t\t\tr->pattern->right->nterms ? \" && \" : \" \");\n\t\t\t\temittest(r->pattern->right, \"RIGHT_CHILD(a)\", \" \");\n\t\t\t\tprint(\"%2) {\\n\");\n\t\t\t\tindent = \"\\t\\t\\t\";\n\t\t\t} else\n\t\t\t\tprint(\"%2/* %R */\\n\", r);\n\t\t\tprint(\"%sc = \", indent);\n\t\t\temitcost(r->pattern->left,  \"LEFT_CHILD(a)\");\n\t\t\temitcost(r->pattern->right, \"RIGHT_CHILD(a)\");\n\t\t\tprint(\"%s;\\n\", r->code);\n\t\t\temitrecord(indent, r, \"c\", 0);\n\t\t\tif (indent[2])\n\t\t\t\tprint(\"%2}\\n\");\n\t\t\tbreak;\n\t\tdefault: assert(0);\n\t\t}\n\t}\n\tprint(\"%2break;\\n\");\n}\n\n/* emitclosure - emit the closure functions */\nstatic void emitclosure(Nonterm nts) {\n\tNonterm p;\n\n\tfor (p = nts; p; p = p->link)\n\t\tif (p->chain)\n\t\t\tprint(\"static void %Pclosure_%S(NODEPTR_TYPE, int);\\n\", p);\n\tprint(\"\\n\");\n\tfor (p = nts; p; p = p->link)\n\t\tif (p->chain) {\n\t\t\tRule r;\n\t\t\tprint(\"static void %Pclosure_%S(NODEPTR_TYPE a, int c) {\\n\"\n\"%1struct %Pstate *p = STATE_LABEL(a);\\n\", p);\n\t\t\tfor (r = p->chain; r; r = r->chain)\n\t\t\t\temitrecord(\"\\t\", r, \"c\", r->cost);\n\t\t\tprint(\"}\\n\\n\");\n\t\t}\n}\n\n/* emitcost - emit cost computation for tree t */\nstatic void emitcost(Tree t, char *v) {\n\tNonterm p = t->op;\n\n\tif (p->kind == TERM) {\n\t\tif (t->left)\n\t\t\temitcost(t->left,  stringf(\"LEFT_CHILD(%s)\",  v));\n\t\tif (t->right)\n\t\t\temitcost(t->right, stringf(\"RIGHT_CHILD(%s)\", v));\n\t} else\n\t\tprint(\"((struct %Pstate *)(%s->x.state))->cost[%P%S_NT] + \", v, p);\n}\n\n/* emitdefs - emit nonterminal defines and data structures */\nstatic void emitdefs(Nonterm nts, int ntnumber) {\n\tNonterm p;\n\n\tfor (p = nts; p; p = p->link)\n\t\tprint(\"#define %P%S_NT %d\\n\", p, p->number);\n\tprint(\"\\n\");\n\tprint(\"static char *%Pntname[] = {\\n%10,\\n\");\n\tfor (p = nts; p; p = p->link)\n\t\tprint(\"%1\\\"%S\\\",\\n\", p);\n\tprint(\"%10\\n};\\n\\n\");\n}\n\n/* emitheader - emit initial definitions */\nstatic void emitheader(void) {\n\ttime_t timer = time(NULL);\n\n\tprint(\"/*\\ngenerated at %sby %s\\n*/\\n\", ctime(&timer), rcsid);\n\tprint(\"static void %Pkids(NODEPTR_TYPE, int, NODEPTR_TYPE[]);\\n\");\n\tprint(\"static void %Plabel(NODEPTR_TYPE);\\n\");\n\tprint(\"static int %Prule(void*, int);\\n\\n\");\n}\n\n/* computekids - compute paths to kids in tree t */\nstatic char *computekids(Tree t, char *v, char *bp, int *ip) {\n\tTerm p = t->op;\n\n\tif (p->kind == NONTERM) {\n\t\tsprintf(bp, \"\\t\\tkids[%d] = %s;\\n\", (*ip)++, v);\n\t\tbp += strlen(bp);\n\t} else if (p->arity > 0) {\n\t\tbp = computekids(t->left, stringf(\"LEFT_CHILD(%s)\", v), bp, ip);\n\t\tif (p->arity == 2)\n\t\t\tbp = computekids(t->right, stringf(\"RIGHT_CHILD(%s)\", v), bp, ip);\n\t}\n\treturn bp;\n}\n\n/* emitkids - emit _kids */\nstatic void emitkids(Rule rules, int nrules) {\n\tint i;\n\tRule r, *rc = alloc((nrules + 1 + 1)*sizeof *rc);\n\tchar **str  = alloc((nrules + 1 + 1)*sizeof *str);\n\n\tfor (i = 0, r = rules; r; r = r->link) {\n\t\tint j = 0;\n\t\tchar buf[1024], *bp = buf;\n\t\t*computekids(r->pattern, \"p\", bp, &j) = 0;\n\t\tfor (j = 0; str[j] && strcmp(str[j], buf); j++)\n\t\t\t;\n\t\tif (str[j] == NULL)\n\t\t\tstr[j] = strcpy(alloc(strlen(buf) + 1), buf);\n\t\tr->kids = rc[j];\n\t\trc[j] = r;\n\t}\n\tprint(\"static void %Pkids(NODEPTR_TYPE p, int eruleno, NODEPTR_TYPE kids[]) {\\n\"\n\"%1if (!p)\\n%2fatal(\\\"%Pkids\\\", \\\"Null tree\\\\n\\\", 0);\\n\"\n\"%1if (!kids)\\n%2fatal(\\\"%Pkids\\\", \\\"Null kids\\\\n\\\", 0);\\n\"\n\"%1switch (eruleno) {\\n\");\n\tfor (i = 0; (r = rc[i]) != NULL; i++) {\n\t\tfor ( ; r; r = r->kids)\n\t\t\tprint(\"%1case %d: /* %R */\\n\", r->ern, r);\n\t\tprint(\"%s%2break;\\n\", str[i]);\n\t}\n\tprint(\"%1default:\\n%2fatal(\\\"%Pkids\\\", \\\"Bad rule number %%d\\\\n\\\", eruleno);\\n%1}\\n}\\n\\n\");\n}\n\n/* emitlabel - emit label function */\nstatic void emitlabel(Term terms, Nonterm start, int ntnumber) {\n\tint i;\n\tTerm p;\n\n\tprint(\"static void %Plabel(NODEPTR_TYPE a) {\\n%1int c;\\n\"\n\"%1struct %Pstate *p;\\n\\n\"\n\"%1if (!a)\\n%2fatal(\\\"%Plabel\\\", \\\"Null tree\\\\n\\\", 0);\\n\");\n\tprint(\"%1STATE_LABEL(a) = p = allocate(sizeof *p, FUNC);\\n\"\n\"%1p->rule._stmt = 0;\\n\");\n\tfor (i = 1; i <= ntnumber; i++)\n\t\tprint(\"%1p->cost[%d] =\\n\", i);\n\tprint(\"%20x7fff;\\n%1switch (OP_LABEL(a)) {\\n\");\n\tfor (p = terms; p; p = p->link)\n\t\temitcase(p, ntnumber);\n\tprint(\"%1default:\\n\"\n\"%2fatal(\\\"%Plabel\\\", \\\"Bad terminal %%d\\\\n\\\", OP_LABEL(a));\\n%1}\\n}\\n\\n\");\n}\n\n/* computents - fill in bp with _nts vector for tree t */\nstatic char *computents(Tree t, char *bp) {\n\tif (t) {\n\t\tNonterm p = t->op;\n\t\tif (p->kind == NONTERM) {\n\t\t\tsprintf(bp, \"%s_%s_NT, \", prefix, p->name);\n\t\t\tbp += strlen(bp);\n\t\t} else\n\t\t\tbp = computents(t->right, computents(t->left,  bp));\n\t}\n\treturn bp;\n}\n\n/* emitnts - emit _nts ragged array */\nstatic void emitnts(Rule rules, int nrules) {\n\tRule r;\n\tint i, j, *nts = alloc((nrules + 1)*sizeof *nts);\n\tchar **str = alloc((nrules + 1)*sizeof *str);\n\n\tfor (i = 0, r = rules; r; r = r->link) {\n\t\tchar buf[1024];\n\t\t*computents(r->pattern, buf) = 0;\n\t\tfor (j = 0; str[j] && strcmp(str[j], buf); j++)\n\t\t\t;\n\t\tif (str[j] == NULL) {\n\t\t\tprint(\"static short %Pnts_%d[] = { %s0 };\\n\", j, buf);\n\t\t\tstr[j] = strcpy(alloc(strlen(buf) + 1), buf);\n\t\t}\n\t\tnts[i++] = j;\n\t}\n\tprint(\"\\nstatic short *%Pnts[] = {\\n\");\n\tfor (i = j = 0, r = rules; r; r = r->link) {\n\t\tfor ( ; j < r->ern; j++)\n\t\t\tprint(\"%10,%1/* %d */\\n\", j);\n\t\tprint(\"%1%Pnts_%d,%1/* %d */\\n\", nts[i++], j++);\n\t}\n\tprint(\"};\\n\\n\");\n}\n\n/* emitrecalc - emit code that tests for recalculation of INDIR?(VREGP) */\nstatic void emitrecalc(char *pre, Term root, Term kid) {\n\tif (root->kind == TERM && strncmp(root->name, \"INDIR\", 5) == 0\n\t&&   kid->kind == TERM &&  strcmp(kid->name,  \"VREGP\"   ) == 0) {\n\t\tNonterm p;\n\t\tprint(\"%sif (mayrecalc(a)) {\\n\", pre);\n\t\tprint(\"%s%1struct %Pstate *q = a->syms[RX]->u.t.cse->x.state;\\n\", pre);\n\t\tfor (p = nts; p; p = p->link) {\n\t\t\tprint(\"%s%1if (q->cost[%P%S_NT] == 0) {\\n\", pre, p);\n\t\t\tprint(\"%s%2p->cost[%P%S_NT] = 0;\\n\", pre, p);\n\t\t\tprint(\"%s%2p->rule.%P%S = q->rule.%P%S;\\n\", pre, p, p);\n\t\t\tprint(\"%s%1}\\n\", pre);\n\t\t}\n\t\tprint(\"%s}\\n\", pre);\n\t}\n}\n\n/* emitrecord - emit code that tests for a winning match of rule r */\nstatic void emitrecord(char *pre, Rule r, char *c, int cost) {\n\tif (Tflag)\n\t\tprint(\"%s%Ptrace(a, %d, %s + %d, p->cost[%P%S_NT]);\\n\",\n\t\t\tpre, r->ern, c, cost, r->lhs);\n\tprint(\"%sif (\", pre);\n\tprint(\"%s + %d < p->cost[%P%S_NT]) {\\n\"\n\"%s%1p->cost[%P%S_NT] = %s + %d;\\n%s%1p->rule.%P%S = %d;\\n\",\n\t\tc, cost, r->lhs, pre, r->lhs, c, cost, pre, r->lhs,\n\t\tr->packed);\n\tif (r->lhs->chain)\n\t\tprint(\"%s%1%Pclosure_%S(a, %s + %d);\\n\", pre, r->lhs, c, cost);\n\tprint(\"%s}\\n\", pre);\n}\n\n/* emitrule - emit decoding vectors and _rule */\nstatic void emitrule(Nonterm nts) {\n\tNonterm p;\n\n\tfor (p = nts; p; p = p->link) {\n\t\tRule r;\n\t\tprint(\"static short %Pdecode_%S[] = {\\n%10,\\n\", p);\n\t\tfor (r = p->rules; r; r = r->decode)\n\t\t\tprint(\"%1%d,\\n\", r->ern);\n\t\tprint(\"};\\n\\n\");\n\t}\n\tprint(\"static int %Prule(void *state, int goalnt) {\\n\"\n\"%1if (goalnt < 1 || goalnt > %d)\\n%2fatal(\\\"%Prule\\\", \\\"Bad goal nonterminal %%d\\\\n\\\", goalnt);\\n\"\n\"%1if (!state)\\n%2return 0;\\n%1switch (goalnt) {\\n\", ntnumber);\n\tfor (p = nts; p; p = p->link)\n\t\tprint(\"%1case %P%S_NT:\"\n\"%1return %Pdecode_%S[((struct %Pstate *)state)->rule.%P%S];\\n\", p, p, p);\n\tprint(\"%1default:\\n%2fatal(\\\"%Prule\\\", \\\"Bad goal nonterminal %%d\\\\n\\\", goalnt);\\n%2return 0;\\n%1}\\n}\\n\\n\");\n}\n\n/* emitstring - emit arrays of templates, instruction flags, and rules */\nstatic void emitstring(Rule rules) {\n\tRule r;\n\n\tprint(\"static char *%Ptemplates[] = {\\n\");\n\tprint(\"/* 0 */%10,\\n\");\n\tfor (r = rules; r; r = r->link)\n\t\tprint(\"/* %d */%1\\\"%s\\\",%1/* %R */\\n\", r->ern, r->template, r);\n\tprint(\"};\\n\");\n\tprint(\"\\nstatic char %Pisinstruction[] = {\\n\");\n\tprint(\"/* 0 */%10,\\n\");\n\tfor (r = rules; r; r = r->link) {\n\t\tint len = strlen(r->template);\n\t\tprint(\"/* %d */%1%d,%1/* %s */\\n\", r->ern,\n\t\t\tlen >= 2 && r->template[len-2] == '\\\\' && r->template[len-1] == 'n',\n\t\t\tr->template);\n\t}\n\tprint(\"};\\n\");\n\tprint(\"\\nstatic char *%Pstring[] = {\\n\");\n\tprint(\"/* 0 */%10,\\n\");\n\tfor (r = rules; r; r = r->link)\n\t\tprint(\"/* %d */%1\\\"%R\\\",\\n\", r->ern, r);\n\tprint(\"};\\n\\n\");\n}\n\n/* emitstruct - emit the definition of the state structure */\nstatic void emitstruct(Nonterm nts, int ntnumber) {\n\tprint(\"struct %Pstate {\\n%1short cost[%d];\\n%1struct {\\n\", ntnumber + 1);\n\tfor ( ; nts; nts = nts->link) {\n\t\tint n = 1, m = nts->lhscount;\n\t\twhile ((m >>= 1) != 0)\n\t\t\tn++;\t\t\n\t\tprint(\"%2unsigned int %P%S:%d;\\n\", nts, n);\n\t}\n\tprint(\"%1} rule;\\n};\\n\\n\");\n}\n\n/* emittest - emit clause for testing a match */\nstatic void emittest(Tree t, char *v, char *suffix) {\n\tTerm p = t->op;\n\n\tif (p->kind == TERM) {\n\t\tprint(\"%3%s->op == %d%s/* %S */\\n\", v, p->esn,\n\t\t\tt->nterms > 1 ? \" && \" : suffix, p);\n\t\tif (t->left)\n\t\t\temittest(t->left, stringf(\"LEFT_CHILD(%s)\",  v),\n\t\t\t\tt->right && t->right->nterms ? \" && \" : suffix);\n\t\tif (t->right)\n\t\t\temittest(t->right, stringf(\"RIGHT_CHILD(%s)\", v), suffix);\n\t}\n}\n"
  },
  {
    "path": "lcc/lburg/lburg.h",
    "content": "#ifndef BURG_INCLUDED\n#define BURG_INCLUDED\n\n/* iburg.c: */\nextern void *alloc(int nbytes);\n\ntypedef enum { TERM=1, NONTERM } Kind;\ntypedef struct rule *Rule;\ntypedef struct term *Term;\nstruct term {\t\t/* terminals: */\n\tchar *name;\t\t/* terminal name */\n\tKind kind;\t\t/* TERM */\n\tint esn;\t\t/* external symbol number */\n\tint arity;\t\t/* operator arity */\n\tTerm link;\t\t/* next terminal in esn order */\n\tRule rules;\t\t/* rules whose pattern starts with term */\n};\n\ntypedef struct nonterm *Nonterm;\nstruct nonterm {\t/* nonterminals: */\n\tchar *name;\t\t/* nonterminal name */\n\tKind kind;\t\t/* NONTERM */\n\tint number;\t\t/* identifying number */\n\tint lhscount;\t\t/* # times nt appears in a rule lhs */\n\tint reached;\t\t/* 1 iff reached from start nonterminal */\n\tRule rules;\t\t/* rules w/nonterminal on lhs */\n\tRule chain;\t\t/* chain rules w/nonterminal on rhs */\n\tNonterm link;\t\t/* next terminal in number order */\n};\nextern Nonterm nonterm(char *id);\nextern Term term(char *id, int esn);\n\ntypedef struct tree *Tree;\nstruct tree {\t\t/* tree patterns: */\n\tvoid *op;\t\t/* a terminal or nonterminal */\n\tTree left, right;\t/* operands */\n\tint nterms;\t\t/* number of terminal nodes in this tree */\n};\nextern Tree tree(char *op, Tree left, Tree right);\n\nstruct rule {\t\t/* rules: */\n\tNonterm lhs;\t\t/* lefthand side nonterminal */\n\tTree pattern;\t\t/* rule pattern */\n\tint ern;\t\t/* external rule number */\n\tint packed;\t\t/* packed external rule number */\n\tint cost;\t\t/* cost, if a constant */\n\tchar *code;\t\t/* cost, if an expression */\n\tchar *template;\t\t/* assembler template */\n\tRule link;\t\t/* next rule in ern order */\n\tRule next;\t\t/* next rule with same pattern root */\n\tRule chain;\t\t/* next chain rule with same rhs */\n\tRule decode;\t\t/* next rule with same lhs */\n\tRule kids;\t\t/* next rule with same _kids pattern */\n};\nextern Rule rule(char *id, Tree pattern, char *template, char *code);\n\n/* gram.y: */\nvoid yyerror(char *fmt, ...);\nint yyparse(void);\nvoid yywarn(char *fmt, ...);\nextern int errcnt;\nextern FILE *infp;\nextern FILE *outfp;\n\n#endif\n"
  },
  {
    "path": "lcc/lib/assert.c",
    "content": "#include <stdio.h>\n#include <stdlib.h>\n\n\nint _assert(char *e, char *file, int line) {\n\tfprintf(stderr, \"assertion failed:\");\n\tif (e)\n\t\tfprintf(stderr, \" %s\", e);\n\tif (file)\n\t\tfprintf(stderr, \" file %s\", file);\n\tfprintf(stderr, \" line %d\\n\", line);\n\tfflush(stderr);\n\tabort();\n\treturn 0;\n}\n"
  },
  {
    "path": "lcc/lib/bbexit.c",
    "content": "#include <stdio.h>\n#include <stdlib.h>\n\n\nstruct callsite {\n\tchar *file, *name;\n\tunion coordinate {\n\t\tstruct { unsigned int index:6,x:10,y:16; } be;\n\t\tstruct { unsigned int y:16,x:10,index:6; } le;\n\t\tunsigned int coord;\n\t} u;\n} *_caller;\n\nstatic struct _bbdata {\n\tstruct _bbdata *link;\n\tunsigned npoints, *counts;\n\tunion coordinate *coords;\n\tchar **files;\n\tstruct func {\n\t\tstruct func *link;\n\t\tstruct caller {\n\t\t\tstruct caller *link;\n\t\t\tstruct callsite *caller;\n\t\t\tunsigned count;\n\t\t} *callers;\n\t\tchar *name;\n\t\tunion coordinate src;\n\t} *funcs;\n} tail, *_bblist = &tail;\n\nstatic void unpack(unsigned int coord, int *index, int *x, int *y) {\n\tstatic union { int x; char endian; } little = { 1 };\n\tunion coordinate u;\n\n\tu.coord = coord;\n\tif (little.endian) {\n\t\t*index = u.le.index;\n\t\t*x = u.le.x;\n\t\t*y = u.le.y;\n\t} else {\n\t\t*index = u.be.index;\n\t\t*x = u.be.x;\n\t\t*y = u.be.y;\n\t}\n}\t\t\t\t\n\nstatic void profout(struct _bbdata *p, FILE *fp) {\n\tint i, index, x, y;\n\tstruct func *f;\n\tstruct caller *q;\n\n\tfor (i = 0; p->files[i]; i++)\n\t\t;\n\tfprintf(fp, \"%d\\n\", i);\n\tfor (i = 0; p->files[i]; i++)\n\t\tfprintf(fp, \"%s\\n\", p->files[i]);\n\tfor (i = 0, f = p->funcs; f; i++, f = f->link)\n\t\tif (q = f->callers)\n\t\t\tfor (i--; q; q = q->link)\n\t\t\t\ti++;\n\tfprintf(fp, \"%d\\n\", i);\n\tfor (f = p->funcs; f; f = f->link) {\n\t\tint n = 0;\n\t\tfor (q = f->callers; q; n += q->count, q = q->link) {\n\t\t\tunpack(f->src.coord, &index, &x, &y);\n\t\t\tfprintf(fp, \"%s %d %d %d %d\", f->name, index, x, y, q->count);\n\t\t\tif (q->caller) {\n\t\t\t\tunpack(q->caller->u.coord, &index, &x, &y);\n\t\t\t\tfprintf(fp, \" %s %s %d %d\\n\", q->caller->name, q->caller->file, x, y);\n\t\t\t} else\n\t\t\t\tfprintf(fp, \" ? ? 0 0\\n\");\n\t\t}\n\t\tif (n == 0) {\n\t\t\tunpack(f->src.coord, &index, &x, &y);\n\t\t\tfprintf(fp, \"%s %d %d %d 0 ? ? 0 0\\n\", f->name, index, x, y);\n\t\t}\n\t}\t\t\n\tfprintf(fp, \"%d\\n\", p->npoints);\n\tfor (i = 0; i < p->npoints; i++) {\n\t\tunpack(p->coords[i].coord, &index, &x, &y);\n\t\tfprintf(fp, \"%d %d %d %d\\n\", index, x, y, p->counts[i]);\n\t}\n}\n\nstatic void bbexit(void) {\n\tFILE *fp;\n\n\tif (_bblist != &tail && (fp = fopen(\"prof.out\", \"a\"))) {\n\t\tfor ( ; _bblist != &tail; _bblist = _bblist->link)\n\t\t\tprofout(_bblist, fp);\n\t\tfclose(fp);\n\t}\n}\n\nvoid _epilogue(struct func *callee) {\n\t_caller = 0;\n}\n\nvoid _prologue(struct func *callee, struct _bbdata *yylink) {\n\tstatic struct caller callers[4096];\n\tstatic int next;\n\tstruct caller *p;\n\n\tif (!yylink->link) {\n\t\tyylink->link = _bblist;\n\t\t_bblist = yylink;\n\t\tif (next == 0)\n\t\t\tatexit(bbexit);\n\t}\n\tfor (p = callee->callers; p; p = p->link)\n\t\tif (p->caller == _caller) {\n\t\t\tp->count++;\n\t\t\tbreak;\n\t\t}\n\tif (!p && next < sizeof callers/sizeof callers[0]) {\n\t\tp = &callers[next++];\n\t\tp->caller = _caller;\n\t\tp->count = 1;\n\t\tp->link = callee->callers;\n\t\tcallee->callers = p;\n\t}\n\t_caller = 0;\n}\n"
  },
  {
    "path": "lcc/lib/yynull.c",
    "content": "#include <stdio.h>\n#include <stdlib.h>\n\n\nvoid _YYnull(char *file, int line) {\n\tfprintf(stderr, \"null pointer dereferenced:\");\n\tif (file)\n\t\tfprintf(stderr, \" file %s,\", file);\n\tfprintf(stderr, \" line %d\\n\", line);\n\tfflush(stderr);\n\tabort();\n}\n"
  },
  {
    "path": "lcc/makefile",
    "content": "# $Id: makefile 145 2001-10-17 21:53:10Z timo $\nHOSTFILE=etc/linux.c\nTEMPDIR=/tmp\nA=.a\nO=.o\nE=\nCC=cc\nCFLAGS=-g\nLDFLAGS=\nLD=cc\nAR=ar ruv\nRANLIB=ranlib\nDIFF=diff\nRM=rm -f\nRMDIR=rmdir\nTSTDIR=$(BUILDDIR)/$(TARGET)/tst\nCUSTOM=custom.mk\ninclude $(CUSTOM)\nB=$(BUILDDIR)/\nT=$(TSTDIR)/\n\n# $Id: makefile 145 2001-10-17 21:53:10Z timo $\n\nwhat:\n\t-@echo make all rcc lburg cpp lcc bprint liblcc triple clean clobber\n\nall::\trcc lburg cpp lcc bprint liblcc\n\nrcc:\t$Brcc$E\nlburg:\t$Blburg$E\ncpp:\t$Bcpp$E\nlcc:\t$Blcc$E\nbprint:\t$Bbprint$E\nliblcc:\t$Bliblcc$A\n\nRCCOBJS=$Balloc$O \\\n\t$Bbind$O \\\n\t$Bdag$O \\\n\t$Bdagcheck$O \\\n\t$Bdecl$O \\\n\t$Benode$O \\\n\t$Berror$O \\\n\t$Bexpr$O \\\n\t$Bevent$O \\\n\t$Binit$O \\\n\t$Binits$O \\\n\t$Binput$O \\\n\t$Blex$O \\\n\t$Blist$O \\\n\t$Bmain$O \\\n\t$Boutput$O \\\n\t$Bprof$O \\\n\t$Bprofio$O \\\n\t$Bsimp$O \\\n\t$Bstmt$O \\\n\t$Bstring$O \\\n\t$Bsym$O \\\n\t$Btrace$O \\\n\t$Btree$O \\\n\t$Btypes$O \\\n\t$Bnull$O \\\n\t$Bsymbolic$O \\\n\t$Bgen$O \\\n\t$Bbytecode$O \\\n\t$Balpha$O \\\n\t$Bmips$O \\\n\t$Bsparc$O \\\n\t$Bstab$O \\\n\t$Bx86$O \\\n\t$Bx86linux$O\n\n$Brcc$E::\t$Bmain$O $Blibrcc$A $(EXTRAOBJS)\n\t\t$(LD) $(LDFLAGS) -o $@ $Bmain$O $(EXTRAOBJS) $Blibrcc$A $(EXTRALIBS)\n\n$Blibrcc$A:\t$(RCCOBJS)\n\t\t$(AR) $@ $(RCCOBJS); $(RANLIB) $@ || true\n\n$(RCCOBJS):\tsrc/c.h src/token.h src/config.h\n\n$Balloc$O:\tsrc/alloc.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/alloc.c\n$Bbind$O:\tsrc/bind.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/bind.c\n$Bdag$O:\tsrc/dag.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/dag.c\n$Bdecl$O:\tsrc/decl.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/decl.c\n$Benode$O:\tsrc/enode.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/enode.c\n$Berror$O:\tsrc/error.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/error.c\n$Bevent$O:\tsrc/event.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/event.c\n$Bexpr$O:\tsrc/expr.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/expr.c\n$Bgen$O:\tsrc/gen.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/gen.c\n$Binit$O:\tsrc/init.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/init.c\n$Binits$O:\tsrc/inits.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/inits.c\n$Binput$O:\tsrc/input.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/input.c\n$Blex$O:\tsrc/lex.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/lex.c\n$Blist$O:\tsrc/list.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/list.c\n$Bmain$O:\tsrc/main.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/main.c\n$Bnull$O:\tsrc/null.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/null.c\n$Boutput$O:\tsrc/output.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/output.c\n$Bprof$O:\tsrc/prof.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/prof.c\n$Bprofio$O:\tsrc/profio.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/profio.c\n$Bsimp$O:\tsrc/simp.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/simp.c\n$Bstmt$O:\tsrc/stmt.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/stmt.c\n$Bstring$O:\tsrc/string.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/string.c\n$Bsym$O:\tsrc/sym.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/sym.c\n$Bsymbolic$O:\tsrc/symbolic.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/symbolic.c\n$Bbytecode$O:\tsrc/bytecode.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/bytecode.c\n$Btrace$O:\tsrc/trace.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/trace.c\n$Btree$O:\tsrc/tree.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/tree.c\n$Btypes$O:\tsrc/types.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/types.c\n$Bstab$O:\tsrc/stab.c src/stab.h;\t$(CC) $(CFLAGS) -c -Isrc -o $@ src/stab.c\n\n$Bdagcheck$O:\t$Bdagcheck.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ $Bdagcheck.c\n$Balpha$O:\t$Balpha.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ $Balpha.c\n$Bmips$O:\t$Bmips.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ $Bmips.c\n$Bsparc$O:\t$Bsparc.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ $Bsparc.c\n$Bx86$O:\t$Bx86.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ $Bx86.c\n$Bx86linux$O:\t$Bx86linux.c;\t$(CC) $(CFLAGS) -c -Isrc -o $@ $Bx86linux.c\n\n$Bdagcheck.c:\t$Blburg$E src/dagcheck.md; $Blburg src/dagcheck.md $@\n$Balpha.c:\t$Blburg$E src/alpha.md;    $Blburg src/alpha.md    $@\n$Bmips.c:\t$Blburg$E src/mips.md;     $Blburg src/mips.md     $@\n$Bsparc.c:\t$Blburg$E src/sparc.md;    $Blburg src/sparc.md    $@\n$Bx86.c:\t$Blburg$E src/x86.md;      $Blburg src/x86.md      $@\n$Bx86linux.c:\t$Blburg$E src/x86linux.md; $Blburg src/x86linux.md $@\n\n$Brcc.h:\tsrc/rcc.asdl;\t\t\t$(ASDL_HOME)/bin/asdlGen --c -d $B src/rcc.asdl\n$Brcc$O:\t$Brcc.h;\t\t\t$(CC) $(CFLAGS) -c -Isrc -I$B -I$(ASDL_HOME)/include/asdlGen -o $@ $Brcc.c\n$Basdl$O:\tsrc/asdl.c $Brcc.h src/c.h;\t$(CC) $(CFLAGS) -c -Isrc -I$B -I$(ASDL_HOME)/include/asdlGen -o $@ src/asdl.c\n$Bpass2$O:\tsrc/pass2.c $Brcc.h src/c.h;\t$(CC) $(CFLAGS) -c -Isrc -I$B -I$(ASDL_HOME)/include/asdlGen -o $@ src/pass2.c\n$B2html$O:\tsrc/2html.c $Brcc.h src/c.h;\t$(CC) $(CFLAGS) -c -Isrc -I$B -I$(ASDL_HOME)/include/asdlGen -o $@ src/2html.c\n\n$Bpass2$E:\t$Bpass2$O $(EXTRAOBJS) $Blibrcc$A;\t$(LD) $(LDFLAGS) -o $@ $Bpass2$O $(EXTRAOBJS) $Blibrcc$A $(EXTRALIBS)\n$B2html$E:\t$B2html$O $Brcc$O;\t\t\t$(LD) $(LDFLAGS) -o $@ $B2html$O $Brcc$O $(EXTRALIBS)\n\n$Bbprint$E:\t$Bbprint$O;\t\t$(LD) $(LDFLAGS) -o $@ $Bbprint$O \n\n$Bbprint$O:\tetc/bprint.c;\t\t$(CC) $(CFLAGS) -c -Isrc -o $@ etc/bprint.c\n\n$Blcc$E:\t$Blcc$O $Bhost$O;\t$(LD) $(LDFLAGS) -o $@ $Blcc$O $Bhost$O \n\nSYSTEM=$(shell cc -print-search-dirs | head -n 1 | cut -b 10-)\n\n$Blcc$O:\tetc/lcc.c;\t$(CC) $(CFLAGS) -c -DTEMPDIR=\\\"$(TEMPDIR)\\\" -o $@ etc/lcc.c\n$Bhost$O:\t$(HOSTFILE);\t$(CC) $(CFLAGS) -c -DSYSTEM=\\\"$(SYSTEM)\\\" -o $@ $(HOSTFILE)\n\nLIBOBJS=$Bassert$O $Bbbexit$O $Byynull$O\n\n$Bliblcc$A:\t$(LIBOBJS);\t$(AR) $@ $Bassert$O $Bbbexit$O $Byynull$O; $(RANLIB) $@ || true\n\n$Bassert$O:\tlib/assert.c;\t$(CC) $(CFLAGS) -c -o $@ lib/assert.c\n$Byynull$O:\tlib/yynull.c;\t$(CC) $(CFLAGS) -c -o $@ lib/yynull.c\n$Bbbexit$O:\tlib/bbexit.c;\t$(CC) $(CFLAGS) -c -o $@ lib/bbexit.c\n\n$Blburg$E:\t$Blburg$O $Bgram$O;\t$(LD) $(LDFLAGS) -o $@ $Blburg$O $Bgram$O \n\n$Blburg$O $Bgram$O:\tlburg/lburg.h\n\n$Blburg$O:\tlburg/lburg.c;\t$(CC) $(CFLAGS) -c -Ilburg -o $@ lburg/lburg.c\n$Bgram$O:\tlburg/gram.c;\t$(CC) $(CFLAGS) -c -Ilburg -o $@ lburg/gram.c\n\nCPPOBJS=$Bcpp$O $Blexer$O $Bnlist$O $Btokens$O $Bmacro$O $Beval$O \\\n\t$Binclude$O $Bhideset$O $Bgetopt$O $Bunix$O\n\n$Bcpp$E:\t$(CPPOBJS)\n\t\t$(LD) $(LDFLAGS) -o $@ $(CPPOBJS) \n\n$(CPPOBJS):\tcpp/cpp.h\n\n$Bcpp$O:\tcpp/cpp.c;\t$(CC) $(CFLAGS) -c -Icpp -o $@ cpp/cpp.c\n$Blexer$O:\tcpp/lex.c;\t$(CC) $(CFLAGS) -c -Icpp -o $@ cpp/lex.c\n$Bnlist$O:\tcpp/nlist.c;\t$(CC) $(CFLAGS) -c -Icpp -o $@ cpp/nlist.c\n$Btokens$O:\tcpp/tokens.c;\t$(CC) $(CFLAGS) -c -Icpp -o $@ cpp/tokens.c\n$Bmacro$O:\tcpp/macro.c;\t$(CC) $(CFLAGS) -c -Icpp -o $@ cpp/macro.c\n$Beval$O:\tcpp/eval.c;\t$(CC) $(CFLAGS) -c -Icpp -o $@ cpp/eval.c\n$Binclude$O:\tcpp/include.c;\t$(CC) $(CFLAGS) -c -Icpp -o $@ cpp/include.c\n$Bhideset$O:\tcpp/hideset.c;\t$(CC) $(CFLAGS) -c -Icpp -o $@ cpp/hideset.c\n$Bgetopt$O:\tcpp/getopt.c;\t$(CC) $(CFLAGS) -c -Icpp -o $@ cpp/getopt.c\n$Bunix$O:\tcpp/unix.c;\t$(CC) $(CFLAGS) -c -Icpp -o $@ cpp/unix.c\n\ntest:\t$T8q.s \\\n\t$Tarray.s \\\n\t$Tcf.s \\\n\t$Tcq.s \\\n\t$Tcvt.s \\\n\t$Tfields.s \\\n\t$Tfront.s \\\n\t$Tincr.s \\\n\t$Tinit.s \\\n\t$Tlimits.s \\\n\t$Tparanoia.s \\\n\t$Tsort.s \\\n\t$Tspill.s \\\n\t$Tstdarg.s \\\n\t$Tstruct.s \\\n\t$Tswitch.s \\\n\t$Twf1.s \\\n\t$Tyacc.s\n\n$T8q.s:\ttst/8q.c tst/8q.0 all;\t@env BUILDDIR=$(BUILDDIR) TSTDIR=$(TSTDIR) src/run.sh $@\n$Tarray.s:\ttst/array.c tst/array.0 all;\t@env BUILDDIR=$(BUILDDIR) TSTDIR=$(TSTDIR) src/run.sh $@\n$Tcf.s:\ttst/cf.c tst/cf.0 all;\t@env BUILDDIR=$(BUILDDIR) TSTDIR=$(TSTDIR) src/run.sh $@\n$Tcq.s:\ttst/cq.c tst/cq.0 all;\t@env BUILDDIR=$(BUILDDIR) TSTDIR=$(TSTDIR) src/run.sh $@\n$Tcvt.s:\ttst/cvt.c tst/cvt.0 all;\t@env BUILDDIR=$(BUILDDIR) TSTDIR=$(TSTDIR) src/run.sh $@\n$Tfields.s:\ttst/fields.c tst/fields.0 all;\t@env BUILDDIR=$(BUILDDIR) TSTDIR=$(TSTDIR) src/run.sh $@\n$Tfront.s:\ttst/front.c tst/front.0 all;\t@env BUILDDIR=$(BUILDDIR) TSTDIR=$(TSTDIR) src/run.sh $@\n$Tincr.s:\ttst/incr.c tst/incr.0 all;\t@env BUILDDIR=$(BUILDDIR) TSTDIR=$(TSTDIR) src/run.sh $@\n$Tinit.s:\ttst/init.c tst/init.0 all;\t@env BUILDDIR=$(BUILDDIR) TSTDIR=$(TSTDIR) src/run.sh $@\n$Tlimits.s:\ttst/limits.c tst/limits.0 all;\t@env BUILDDIR=$(BUILDDIR) TSTDIR=$(TSTDIR) src/run.sh $@\n$Tparanoia.s:\ttst/paranoia.c tst/paranoia.0 all;\t@env BUILDDIR=$(BUILDDIR) TSTDIR=$(TSTDIR) src/run.sh $@\n$Tsort.s:\ttst/sort.c tst/sort.0 all;\t@env BUILDDIR=$(BUILDDIR) TSTDIR=$(TSTDIR) src/run.sh $@\n$Tspill.s:\ttst/spill.c tst/spill.0 all;\t@env BUILDDIR=$(BUILDDIR) TSTDIR=$(TSTDIR) src/run.sh $@\n$Tstdarg.s:\ttst/stdarg.c tst/stdarg.0 all;\t@env BUILDDIR=$(BUILDDIR) TSTDIR=$(TSTDIR) src/run.sh $@\n$Tstruct.s:\ttst/struct.c tst/struct.0 all;\t@env BUILDDIR=$(BUILDDIR) TSTDIR=$(TSTDIR) src/run.sh $@\n$Tswitch.s:\ttst/switch.c tst/switch.0 all;\t@env BUILDDIR=$(BUILDDIR) TSTDIR=$(TSTDIR) src/run.sh $@\n$Twf1.s:\ttst/wf1.c tst/wf1.0 all;\t@env BUILDDIR=$(BUILDDIR) TSTDIR=$(TSTDIR) src/run.sh $@\n$Tyacc.s:\ttst/yacc.c tst/yacc.0 all;\t@env BUILDDIR=$(BUILDDIR) TSTDIR=$(TSTDIR) src/run.sh $@\n\ntestclean:\n\t$(RM) $T8q$E $T8q.s $T8q.2 $T8q.1\n\t$(RM) $Tarray$E $Tarray.s $Tarray.2 $Tarray.1\n\t$(RM) $Tcf$E $Tcf.s $Tcf.2 $Tcf.1\n\t$(RM) $Tcq$E $Tcq.s $Tcq.2 $Tcq.1\n\t$(RM) $Tcvt$E $Tcvt.s $Tcvt.2 $Tcvt.1\n\t$(RM) $Tfields$E $Tfields.s $Tfields.2 $Tfields.1\n\t$(RM) $Tfront$E $Tfront.s $Tfront.2 $Tfront.1\n\t$(RM) $Tincr$E $Tincr.s $Tincr.2 $Tincr.1\n\t$(RM) $Tinit$E $Tinit.s $Tinit.2 $Tinit.1\n\t$(RM) $Tlimits$E $Tlimits.s $Tlimits.2 $Tlimits.1\n\t$(RM) $Tparanoia$E $Tparanoia.s $Tparanoia.2 $Tparanoia.1\n\t$(RM) $Tsort$E $Tsort.s $Tsort.2 $Tsort.1\n\t$(RM) $Tspill$E $Tspill.s $Tspill.2 $Tspill.1\n\t$(RM) $Tstdarg$E $Tstdarg.s $Tstdarg.2 $Tstdarg.1\n\t$(RM) $Tstruct$E $Tstruct.s $Tstruct.2 $Tstruct.1\n\t$(RM) $Tswitch$E $Tswitch.s $Tswitch.2 $Tswitch.1\n\t$(RM) $Twf1$E $Twf1.s $Twf1.2 $Twf1.1\n\t$(RM) $Tyacc$E $Tyacc.s $Tyacc.2 $Tyacc.1\n\ninstall::\tall\n\t\tinstall -d /usr/local/lib/lcc\n\t\tinstall -d /usr/local/lib/lcc/gcc\n\t\tinstall $Blcc$E /usr/local/bin\n\t\tinstall $Bcpp$E /usr/local/lib/lcc/gcc\n\t\tinstall $Brcc$E /usr/local/lib/lcc\n\t\tinstall $Bliblcc$A /usr/local/lib/lcc\n\t\tinstall $Blibrcc$A /usr/local/lib/lcc\n\nuninstall::\n\t\t$(RM) /usr/local/lib/lcc/librcc$A\n\t\t$(RM) /usr/local/lib/lcc/liblcc$A\n\t\t$(RM) /usr/local/lib/lcc/rcc$E\n\t\t$(RM) /usr/local/lib/lcc/gcc/cpp$E\n\t\t$(RM) /usr/local/bin/lcc$E\n\t\t$(RMDIR) /usr/local/lib/lcc/gcc\n\t\t$(RMDIR) /usr/local/lib/lcc\n\nclean::\t\ttestclean\n\t\t$(RM) $B*$O\n\t\t$(RM) $Bdagcheck.c $Balpha.c $Bmips.c $Bx86.c $Bsparc.c $Bx86linux.c $Bgram.c\n\t\t$(RM) $Brcc.c $Brcc.h\n\t\t$(RM) $Brcc1$E $Brcc1$E $B1rcc$E $B2rcc$E\n\t\t$(RM) $B*.ilk\n\nclobber::\tclean\n\t\t$(RM) $Brcc$E $B2html$E $Bpass2$E $Blburg$E $Bcpp$E $Blcc$E $Bbprint$E $B*$A\n\t\t$(RM) $B*.pdb $B*.pch\n\nRCCSRCS=src/alloc.c \\\n\tsrc/bind.c \\\n\tsrc/dag.c \\\n\tsrc/decl.c \\\n\tsrc/enode.c \\\n\tsrc/error.c \\\n\tsrc/expr.c \\\n\tsrc/event.c \\\n\tsrc/init.c \\\n\tsrc/inits.c \\\n\tsrc/input.c \\\n\tsrc/lex.c \\\n\tsrc/list.c \\\n\tsrc/main.c \\\n\tsrc/output.c \\\n\tsrc/prof.c \\\n\tsrc/profio.c \\\n\tsrc/simp.c \\\n\tsrc/stmt.c \\\n\tsrc/string.c \\\n\tsrc/sym.c \\\n\tsrc/trace.c \\\n\tsrc/tree.c \\\n\tsrc/types.c \\\n\tsrc/null.c \\\n\tsrc/symbolic.c \\\n\tsrc/bytecode.c \\\n\tsrc/gen.c \\\n\tsrc/stab.c \\\n\t$Bdagcheck.c \\\n\t$Balpha.c \\\n\t$Bmips.c \\\n\t$Bsparc.c \\\n\t$Bx86linux.c \\\n\t$Bx86.c\n\nC=$Blcc -A -d0.6 -Wo-lccdir=$(BUILDDIR) -Isrc -I$(BUILDDIR)\ntriple:\t$Brcc$E $Blcc$E $Bcpp$E\n\t$C -o $B1rcc$E -B$B  $(RCCSRCS)\n\t$C -o $B2rcc$E -B$B1 $(RCCSRCS)\n\tstrip $B1rcc$E $B2rcc$E\n\tdd if=$B1rcc$E of=$Brcc1$E bs=512 skip=1\n\tdd if=$B2rcc$E of=$Brcc2$E bs=512 skip=1\n\tif cmp $Brcc1$E $Brcc2$E; then \\\n\t\tmv $B2rcc$E $Brcc$E; \\\n\t\t$(RM) $B1rcc$E $Brcc[12]$E; fi\n"
  },
  {
    "path": "lcc/makefile.nt",
    "content": "# $Id: makefile.nt 314 2002-10-05 17:07:57Z timo $\nHOSTFILE=etc/win32.c\nTARGET=x86\\win32\nTEMPDIR=\\\\temp\nA=.lib\nO=.obj\nE=.exe\nCC=cl -nologo\nCFLAGS=-DWIN32 -Zi -MLd -Fd$(BUILDDIR)^\\\nLD=cl -nologo\nLDFLAGS=-Zi -MLd -Fd$(BUILDDIR)^\\\nB=$(BUILDDIR)^\\\nT=$B$(TARGET)\\tst^\\\nC=$Blcc -Wo-lccdir=$(BUILDDIR) -Wf-target=$(TARGET) -I$B$(TARGET)/include\n# $Id: makefile.nt 314 2002-10-05 17:07:57Z timo $\n\nwhat:\n\t-@echo make all q3rcc lburg q3cpp lcc bprint liblcc triple clean clobber\n\nall::\tq3rcc lburg q3cpp lcc bprint liblcc\n\nq3rcc:\t$Bq3rcc$E\nlburg:\t$Blburg$E\nq3cpp:\t$Bq3cpp$E\nlcc:\t$Blcc$E\nbprint:\t$Bbprint$E\nliblcc:\t$Bliblcc$A\n\nRCCOBJS=$Balloc$O \\\n\t$Bbind$O \\\n\t$Bdag$O \\\n\t$Bdagcheck$O \\\n\t$Bdecl$O \\\n\t$Benode$O \\\n\t$Berror$O \\\n\t$Bexpr$O \\\n\t$Bevent$O \\\n\t$Binit$O \\\n\t$Binits$O \\\n\t$Binput$O \\\n\t$Blex$O \\\n\t$Blist$O \\\n\t$Bmain$O \\\n\t$Boutput$O \\\n\t$Bprof$O \\\n\t$Bprofio$O \\\n\t$Bsimp$O \\\n\t$Bstmt$O \\\n\t$Bstring$O \\\n\t$Bsym$O \\\n\t$Btrace$O \\\n\t$Btree$O \\\n\t$Btypes$O \\\n\t$Bnull$O \\\n\t$Bsymbolic$O \\\n\t$Bgen$O \\\n\t$Bbytecode$O \\\n\t$Balpha$O \\\n\t$Bmips$O \\\n\t$Bsparc$O \\\n\t$Bstab$O \\\n\t$Bx86$O \\\n\t$Bx86linux$O\n\n$Bq3rcc$E::\t$Bmain$O $Blibrcc$A $(EXTRAOBJS)\n\t\t$(LD) $(LDFLAGS) -Fe$@ $Bmain$O $(EXTRAOBJS) $Blibrcc$A $(EXTRALIBS)\n\n$Blibrcc$A:\t$(RCCOBJS)\n\t\tlib -out:$@ $(RCCOBJS)\n\n$(RCCOBJS):\tsrc/c.h src/token.h src/config.h\n\n$Balloc$O:\tsrc/alloc.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/alloc.c\n$Bbind$O:\tsrc/bind.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/bind.c\n$Bdag$O:\tsrc/dag.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/dag.c\n$Bdecl$O:\tsrc/decl.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/decl.c\n$Benode$O:\tsrc/enode.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/enode.c\n$Berror$O:\tsrc/error.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/error.c\n$Bevent$O:\tsrc/event.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/event.c\n$Bexpr$O:\tsrc/expr.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/expr.c\n$Bgen$O:\tsrc/gen.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/gen.c\n$Binit$O:\tsrc/init.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/init.c\n$Binits$O:\tsrc/inits.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/inits.c\n$Binput$O:\tsrc/input.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/input.c\n$Blex$O:\tsrc/lex.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/lex.c\n$Blist$O:\tsrc/list.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/list.c\n$Bmain$O:\tsrc/main.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/main.c\n$Bnull$O:\tsrc/null.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/null.c\n$Boutput$O:\tsrc/output.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/output.c\n$Bprof$O:\tsrc/prof.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/prof.c\n$Bprofio$O:\tsrc/profio.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/profio.c\n$Bsimp$O:\tsrc/simp.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/simp.c\n$Bstmt$O:\tsrc/stmt.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/stmt.c\n$Bstring$O:\tsrc/string.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/string.c\n$Bsym$O:\tsrc/sym.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/sym.c\n$Bsymbolic$O:\tsrc/symbolic.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/symbolic.c\n$Bbytecode$O:\tsrc/bytecode.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/bytecode.c\n$Btrace$O:\tsrc/trace.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/trace.c\n$Btree$O:\tsrc/tree.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/tree.c\n$Btypes$O:\tsrc/types.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/types.c\n$Bstab$O:\tsrc/stab.c src/stab.h;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ src/stab.c\n\n$Bdagcheck$O:\t$Bdagcheck.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ $Bdagcheck.c\n$Balpha$O:\t$Balpha.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ $Balpha.c\n$Bmips$O:\t$Bmips.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ $Bmips.c\n$Bsparc$O:\t$Bsparc.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ $Bsparc.c\n$Bx86$O:\t$Bx86.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ $Bx86.c\n$Bx86linux$O:\t$Bx86linux.c;\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ $Bx86linux.c\n\n$Bdagcheck.c:\t$Blburg$E src/dagcheck.md; $Blburg src/dagcheck.md $@\n$Balpha.c:\t$Blburg$E src/alpha.md;    $Blburg src/alpha.md    $@\n$Bmips.c:\t$Blburg$E src/mips.md;     $Blburg src/mips.md     $@\n$Bsparc.c:\t$Blburg$E src/sparc.md;    $Blburg src/sparc.md    $@\n$Bx86.c:\t$Blburg$E src/x86.md;      $Blburg src/x86.md      $@\n$Bx86linux.c:\t$Blburg$E src/x86linux.md; $Blburg src/x86linux.md $@\n\n$Brcc.h:\tsrc/rcc.asdl;\t\t\t$(ASDL_HOME)/bin/asdlGen --c -d $B src/rcc.asdl\n$Brcc$O:\t$Brcc.h;\t\t\t$(CC) $(CFLAGS) -c -Isrc -I$B -I$(ASDL_HOME)/include/asdlGen -Fo$@ $Brcc.c\n$Basdl$O:\tsrc/asdl.c $Brcc.h src/c.h;\t$(CC) $(CFLAGS) -c -Isrc -I$B -I$(ASDL_HOME)/include/asdlGen -Fo$@ src/asdl.c\n$Bpass2$O:\tsrc/pass2.c $Brcc.h src/c.h;\t$(CC) $(CFLAGS) -c -Isrc -I$B -I$(ASDL_HOME)/include/asdlGen -Fo$@ src/pass2.c\n$B2html$O:\tsrc/2html.c $Brcc.h src/c.h;\t$(CC) $(CFLAGS) -c -Isrc -I$B -I$(ASDL_HOME)/include/asdlGen -Fo$@ src/2html.c\n\n$Bpass2$E:\t$Bpass2$O $(EXTRAOBJS) $Blibrcc$A;\t$(LD) $(LDFLAGS) -Fe$@ $Bpass2$O $(EXTRAOBJS) $Blibrcc$A $(EXTRALIBS)\n$B2html$E:\t$B2html$O $Brcc$O;\t\t\t$(LD) $(LDFLAGS) -Fe$@ $B2html$O $Brcc$O $(EXTRALIBS)\n\n$Bbprint$E:\t$Bbprint$O;\t\t$(LD) $(LDFLAGS) -Fe$@ $Bbprint$O \n\n$Bbprint$O:\tetc/bprint.c;\t\t$(CC) $(CFLAGS) -c -Isrc -Fo$@ etc/bprint.c\n\n$Blcc$E:\t$Blcc$O $Bhost$O;\t$(LD) $(LDFLAGS) -Fe$@ $Blcc$O $Bhost$O \n\n$Blcc$O:\tetc/lcc.c;\t$(CC) $(CFLAGS) -c -DTEMPDIR=\\\"$(TEMPDIR)\\\" -Fo$@ etc/lcc.c\n$Bhost$O:\t$(HOSTFILE);\t$(CC) $(CFLAGS) -c -Fo$@ $(HOSTFILE)\n\nLIBOBJS=$Bassert$O $Bbbexit$O $Byynull$O\n\n$Bliblcc$A:\t$(LIBOBJS);\tlib -out:$@ $Bassert$O $Bbbexit$O $Byynull$O\n\n$Bassert$O:\tlib/assert.c;\t$(CC) -c -Fo$@ lib/assert.c\n$Byynull$O:\tlib/yynull.c;\t$(CC) -c -Fo$@ lib/yynull.c\n$Bbbexit$O:\tlib/bbexit.c;\t$(CC) -c -Fo$@ lib/bbexit.c\n\n$Blburg$E:\t$Blburg$O $Bgram$O;\t$(LD) $(LDFLAGS) -Fe$@ $Blburg$O $Bgram$O \n\n$Blburg$O $Bgram$O:\tlburg/lburg.h\n\n$Blburg$O:\tlburg/lburg.c;\t$(CC) $(CFLAGS) -c -Ilburg -Fo$@ lburg/lburg.c\n$Bgram$O:\tlburg/gram.c;\t$(CC) $(CFLAGS) -c -Ilburg -Fo$@ lburg/gram.c\n\nCPPOBJS=$Bcpp$O $Blexer$O $Bnlist$O $Btokens$O $Bmacro$O $Beval$O \\\n\t$Binclude$O $Bhideset$O $Bgetopt$O $Bunix$O\n\n$Bq3cpp$E:\t$(CPPOBJS)\n\t\t$(LD) $(LDFLAGS) -Fe$@ $(CPPOBJS) \n\n$(CPPOBJS):\tcpp/cpp.h\n\n$Bcpp$O:\tcpp/cpp.c;\t$(CC) $(CFLAGS) -c -Icpp -Fo$@ cpp/cpp.c\n$Blexer$O:\tcpp/lex.c;\t$(CC) $(CFLAGS) -c -Icpp -Fo$@ cpp/lex.c\n$Bnlist$O:\tcpp/nlist.c;\t$(CC) $(CFLAGS) -c -Icpp -Fo$@ cpp/nlist.c\n$Btokens$O:\tcpp/tokens.c;\t$(CC) $(CFLAGS) -c -Icpp -Fo$@ cpp/tokens.c\n$Bmacro$O:\tcpp/macro.c;\t$(CC) $(CFLAGS) -c -Icpp -Fo$@ cpp/macro.c\n$Beval$O:\tcpp/eval.c;\t$(CC) $(CFLAGS) -c -Icpp -Fo$@ cpp/eval.c\n$Binclude$O:\tcpp/include.c;\t$(CC) $(CFLAGS) -c -Icpp -Fo$@ cpp/include.c\n$Bhideset$O:\tcpp/hideset.c;\t$(CC) $(CFLAGS) -c -Icpp -Fo$@ cpp/hideset.c\n$Bgetopt$O:\tcpp/getopt.c;\t$(CC) $(CFLAGS) -c -Icpp -Fo$@ cpp/getopt.c\n$Bunix$O:\tcpp/unix.c;\t$(CC) $(CFLAGS) -c -Icpp -Fo$@ cpp/unix.c\n\ntest:\t$T8q.s \\\n\t$Tarray.s \\\n\t$Tcf.s \\\n\t$Tcq.s \\\n\t$Tcvt.s \\\n\t$Tfields.s \\\n\t$Tfront.s \\\n\t$Tincr.s \\\n\t$Tinit.s \\\n\t$Tlimits.s \\\n\t$Tparanoia.s \\\n\t$Tsort.s \\\n\t$Tspill.s \\\n\t$Tstdarg.s \\\n\t$Tstruct.s \\\n\t$Tswitch.s \\\n\t$Twf1.s \\\n\t$Tyacc.s\n\n$T8q.s:\ttst\\8q.c tst\\8q.0 all\n\t-$C -S -Wf-errout=$T8q.2 -o $T8q.s tst/8q.c\n\tfc $(TARGET)\\tst\\8q.sbk $T8q.s\n\tfc $(TARGET)\\tst\\8q.2bk $T8q.2\n\t$C -o $T8q$E $T8q.s\n\t-$T8q$E <tst/8q.0 >$T8q.1\n\tfc $(TARGET)\\tst\\8q.1bk $T8q.1\n$Tarray.s:\ttst\\array.c tst\\array.0 all\n\t-$C -S -Wf-errout=$Tarray.2 -o $Tarray.s tst/array.c\n\tfc $(TARGET)\\tst\\array.sbk $Tarray.s\n\tfc $(TARGET)\\tst\\array.2bk $Tarray.2\n\t$C -o $Tarray$E $Tarray.s\n\t-$Tarray$E <tst/array.0 >$Tarray.1\n\tfc $(TARGET)\\tst\\array.1bk $Tarray.1\n$Tcf.s:\ttst\\cf.c tst\\cf.0 all\n\t-$C -S -Wf-errout=$Tcf.2 -o $Tcf.s tst/cf.c\n\tfc $(TARGET)\\tst\\cf.sbk $Tcf.s\n\tfc $(TARGET)\\tst\\cf.2bk $Tcf.2\n\t$C -o $Tcf$E $Tcf.s\n\t-$Tcf$E <tst/cf.0 >$Tcf.1\n\tfc $(TARGET)\\tst\\cf.1bk $Tcf.1\n$Tcq.s:\ttst\\cq.c tst\\cq.0 all\n\t-$C -S -Wf-errout=$Tcq.2 -o $Tcq.s tst/cq.c\n\tfc $(TARGET)\\tst\\cq.sbk $Tcq.s\n\tfc $(TARGET)\\tst\\cq.2bk $Tcq.2\n\t$C -o $Tcq$E $Tcq.s\n\t-$Tcq$E <tst/cq.0 >$Tcq.1\n\tfc $(TARGET)\\tst\\cq.1bk $Tcq.1\n$Tcvt.s:\ttst\\cvt.c tst\\cvt.0 all\n\t-$C -S -Wf-errout=$Tcvt.2 -o $Tcvt.s tst/cvt.c\n\tfc $(TARGET)\\tst\\cvt.sbk $Tcvt.s\n\tfc $(TARGET)\\tst\\cvt.2bk $Tcvt.2\n\t$C -o $Tcvt$E $Tcvt.s\n\t-$Tcvt$E <tst/cvt.0 >$Tcvt.1\n\tfc $(TARGET)\\tst\\cvt.1bk $Tcvt.1\n$Tfields.s:\ttst\\fields.c tst\\fields.0 all\n\t-$C -S -Wf-errout=$Tfields.2 -o $Tfields.s tst/fields.c\n\tfc $(TARGET)\\tst\\fields.sbk $Tfields.s\n\tfc $(TARGET)\\tst\\fields.2bk $Tfields.2\n\t$C -o $Tfields$E $Tfields.s\n\t-$Tfields$E <tst/fields.0 >$Tfields.1\n\tfc $(TARGET)\\tst\\fields.1bk $Tfields.1\n$Tfront.s:\ttst\\front.c tst\\front.0 all\n\t-$C -S -Wf-errout=$Tfront.2 -o $Tfront.s tst/front.c\n\tfc $(TARGET)\\tst\\front.sbk $Tfront.s\n\tfc $(TARGET)\\tst\\front.2bk $Tfront.2\n$Tincr.s:\ttst\\incr.c tst\\incr.0 all\n\t-$C -S -Wf-errout=$Tincr.2 -o $Tincr.s tst/incr.c\n\tfc $(TARGET)\\tst\\incr.sbk $Tincr.s\n\tfc $(TARGET)\\tst\\incr.2bk $Tincr.2\n\t$C -o $Tincr$E $Tincr.s\n\t-$Tincr$E <tst/incr.0 >$Tincr.1\n\tfc $(TARGET)\\tst\\incr.1bk $Tincr.1\n$Tinit.s:\ttst\\init.c tst\\init.0 all\n\t-$C -S -Wf-errout=$Tinit.2 -o $Tinit.s tst/init.c\n\tfc $(TARGET)\\tst\\init.sbk $Tinit.s\n\tfc $(TARGET)\\tst\\init.2bk $Tinit.2\n\t$C -o $Tinit$E $Tinit.s\n\t-$Tinit$E <tst/init.0 >$Tinit.1\n\tfc $(TARGET)\\tst\\init.1bk $Tinit.1\n$Tlimits.s:\ttst\\limits.c tst\\limits.0 all\n\t-$C -S -Wf-errout=$Tlimits.2 -o $Tlimits.s tst/limits.c\n\tfc $(TARGET)\\tst\\limits.sbk $Tlimits.s\n\tfc $(TARGET)\\tst\\limits.2bk $Tlimits.2\n\t$C -o $Tlimits$E $Tlimits.s\n\t-$Tlimits$E <tst/limits.0 >$Tlimits.1\n\tfc $(TARGET)\\tst\\limits.1bk $Tlimits.1\n$Tparanoia.s:\ttst\\paranoia.c tst\\paranoia.0 all\n\t-$C -S -Wf-errout=$Tparanoia.2 -o $Tparanoia.s tst/paranoia.c\n\tfc $(TARGET)\\tst\\paranoia.sbk $Tparanoia.s\n\tfc $(TARGET)\\tst\\paranoia.2bk $Tparanoia.2\n\t$C -o $Tparanoia$E $Tparanoia.s\n\t-$Tparanoia$E <tst/paranoia.0 >$Tparanoia.1\n\tfc $(TARGET)\\tst\\paranoia.1bk $Tparanoia.1\n$Tsort.s:\ttst\\sort.c tst\\sort.0 all\n\t-$C -S -Wf-errout=$Tsort.2 -o $Tsort.s tst/sort.c\n\tfc $(TARGET)\\tst\\sort.sbk $Tsort.s\n\tfc $(TARGET)\\tst\\sort.2bk $Tsort.2\n\t$C -o $Tsort$E $Tsort.s\n\t-$Tsort$E <tst/sort.0 >$Tsort.1\n\tfc $(TARGET)\\tst\\sort.1bk $Tsort.1\n$Tspill.s:\ttst\\spill.c tst\\spill.0 all\n\t-$C -S -Wf-errout=$Tspill.2 -o $Tspill.s tst/spill.c\n\tfc $(TARGET)\\tst\\spill.sbk $Tspill.s\n\tfc $(TARGET)\\tst\\spill.2bk $Tspill.2\n\t$C -o $Tspill$E $Tspill.s\n\t-$Tspill$E <tst/spill.0 >$Tspill.1\n\tfc $(TARGET)\\tst\\spill.1bk $Tspill.1\n$Tstdarg.s:\ttst\\stdarg.c tst\\stdarg.0 all\n\t-$C -S -Wf-errout=$Tstdarg.2 -o $Tstdarg.s tst/stdarg.c\n\tfc $(TARGET)\\tst\\stdarg.sbk $Tstdarg.s\n\tfc $(TARGET)\\tst\\stdarg.2bk $Tstdarg.2\n\t$C -o $Tstdarg$E $Tstdarg.s\n\t-$Tstdarg$E <tst/stdarg.0 >$Tstdarg.1\n\tfc $(TARGET)\\tst\\stdarg.1bk $Tstdarg.1\n$Tstruct.s:\ttst\\struct.c tst\\struct.0 all\n\t-$C -S -Wf-errout=$Tstruct.2 -o $Tstruct.s tst/struct.c\n\tfc $(TARGET)\\tst\\struct.sbk $Tstruct.s\n\tfc $(TARGET)\\tst\\struct.2bk $Tstruct.2\n\t$C -o $Tstruct$E $Tstruct.s\n\t-$Tstruct$E <tst/struct.0 >$Tstruct.1\n\tfc $(TARGET)\\tst\\struct.1bk $Tstruct.1\n$Tswitch.s:\ttst\\switch.c tst\\switch.0 all\n\t-$C -S -Wf-errout=$Tswitch.2 -o $Tswitch.s tst/switch.c\n\tfc $(TARGET)\\tst\\switch.sbk $Tswitch.s\n\tfc $(TARGET)\\tst\\switch.2bk $Tswitch.2\n\t$C -o $Tswitch$E $Tswitch.s\n\t-$Tswitch$E <tst/switch.0 >$Tswitch.1\n\tfc $(TARGET)\\tst\\switch.1bk $Tswitch.1\n$Twf1.s:\ttst\\wf1.c tst\\wf1.0 all\n\t-$C -S -Wf-errout=$Twf1.2 -o $Twf1.s tst/wf1.c\n\tfc $(TARGET)\\tst\\wf1.sbk $Twf1.s\n\tfc $(TARGET)\\tst\\wf1.2bk $Twf1.2\n\t$C -o $Twf1$E $Twf1.s\n\t-$Twf1$E <tst/wf1.0 >$Twf1.1\n\tfc $(TARGET)\\tst\\wf1.1bk $Twf1.1\n$Tyacc.s:\ttst\\yacc.c tst\\yacc.0 all\n\t-$C -S -Wf-errout=$Tyacc.2 -o $Tyacc.s tst/yacc.c\n\tfc $(TARGET)\\tst\\yacc.sbk $Tyacc.s\n\tfc $(TARGET)\\tst\\yacc.2bk $Tyacc.2\n\t$C -o $Tyacc$E $Tyacc.s\n\t-$Tyacc$E <tst/yacc.0 >$Tyacc.1\n\tfc $(TARGET)\\tst\\yacc.1bk $Tyacc.1\n\ntestclean:\n\t-del /q $T8q$E $T8q.s $T8q.2 $T8q.1\n\t-del /q $Tarray$E $Tarray.s $Tarray.2 $Tarray.1\n\t-del /q $Tcf$E $Tcf.s $Tcf.2 $Tcf.1\n\t-del /q $Tcq$E $Tcq.s $Tcq.2 $Tcq.1\n\t-del /q $Tcvt$E $Tcvt.s $Tcvt.2 $Tcvt.1\n\t-del /q $Tfields$E $Tfields.s $Tfields.2 $Tfields.1\n\t-del /q $Tfront$E $Tfront.s $Tfront.2 $Tfront.1\n\t-del /q $Tincr$E $Tincr.s $Tincr.2 $Tincr.1\n\t-del /q $Tinit$E $Tinit.s $Tinit.2 $Tinit.1\n\t-del /q $Tlimits$E $Tlimits.s $Tlimits.2 $Tlimits.1\n\t-del /q $Tparanoia$E $Tparanoia.s $Tparanoia.2 $Tparanoia.1\n\t-del /q $Tsort$E $Tsort.s $Tsort.2 $Tsort.1\n\t-del /q $Tspill$E $Tspill.s $Tspill.2 $Tspill.1\n\t-del /q $Tstdarg$E $Tstdarg.s $Tstdarg.2 $Tstdarg.1\n\t-del /q $Tstruct$E $Tstruct.s $Tstruct.2 $Tstruct.1\n\t-del /q $Tswitch$E $Tswitch.s $Tswitch.2 $Tswitch.1\n\t-del /q $Twf1$E $Twf1.s $Twf1.2 $Twf1.1\n\t-del /q $Tyacc$E $Tyacc.s $Tyacc.2 $Tyacc.1\n\nclean::\t\ttestclean\n\t\t-del /q $B*$O\n\t\t-del /q $Bdagcheck.c $Balpha.c $Bmips.c $Bx86.c $Bsparc.c $Bx86linux.c $Bgram.c\n\t\t-del /q $Brcc.c $Brcc.h\n\t\t-del /q $Bq3rcc1$E $Brcc1$E $B1rcc$E $B2rcc$E\n\t\t-del /q $B*.ilk\n\nclobber::\tclean\n\t\t-del /q $Bq3rcc$E $B2html$E $Bpass2$E $Blburg$E $Bq3cpp$E $Blcc$E $Bbprint$E $B*$A\n\t\t-del /q $B*.pdb $B*.pch\n\nRCCSRCS=src/alloc.c \\\n\tsrc/bind.c \\\n\tsrc/dag.c \\\n\tsrc/decl.c \\\n\tsrc/enode.c \\\n\tsrc/error.c \\\n\tsrc/expr.c \\\n\tsrc/event.c \\\n\tsrc/init.c \\\n\tsrc/inits.c \\\n\tsrc/input.c \\\n\tsrc/lex.c \\\n\tsrc/list.c \\\n\tsrc/main.c \\\n\tsrc/output.c \\\n\tsrc/prof.c \\\n\tsrc/profio.c \\\n\tsrc/simp.c \\\n\tsrc/stmt.c \\\n\tsrc/string.c \\\n\tsrc/sym.c \\\n\tsrc/trace.c \\\n\tsrc/tree.c \\\n\tsrc/types.c \\\n\tsrc/null.c \\\n\tsrc/symbolic.c \\\n\tsrc/bytecode.c \\\n\tsrc/gen.c \\\n\tsrc/stab.c \\\n\t$Bdagcheck.c \\\n\t$Balpha.c \\\n\t$Bmips.c \\\n\t$Bsparc.c \\\n\t$Bx86linux.c \\\n\t$Bx86.c\n\nC=$Blcc -A -d0.6 -Wo-lccdir=$(BUILDDIR) -Isrc -I$(BUILDDIR)\ntriple:\t$Bq3rcc$E $Blcc$E $Bq3cpp$E\n\t$C -o $B1rcc$E -B$B  $(RCCSRCS)\n\t$C -o $B2rcc$E -B$B1 $(RCCSRCS)\n\tfc /b $B1rcc$E $B2rcc$E\n"
  },
  {
    "path": "lcc/mips/irix/tst/8q.1bk",
    "content": "1 5 8 6 3 7 2 4 \n1 6 8 3 7 4 2 5 \n1 7 4 6 8 2 5 3 \n1 7 5 8 2 4 6 3 \n2 4 6 8 3 1 7 5 \n2 5 7 1 3 8 6 4 \n2 5 7 4 1 8 6 3 \n2 6 1 7 4 8 3 5 \n2 6 8 3 1 4 7 5 \n2 7 3 6 8 5 1 4 \n2 7 5 8 1 4 6 3 \n2 8 6 1 3 5 7 4 \n3 1 7 5 8 2 4 6 \n3 5 2 8 1 7 4 6 \n3 5 2 8 6 4 7 1 \n3 5 7 1 4 2 8 6 \n3 5 8 4 1 7 2 6 \n3 6 2 5 8 1 7 4 \n3 6 2 7 1 4 8 5 \n3 6 2 7 5 1 8 4 \n3 6 4 1 8 5 7 2 \n3 6 4 2 8 5 7 1 \n3 6 8 1 4 7 5 2 \n3 6 8 1 5 7 2 4 \n3 6 8 2 4 1 7 5 \n3 7 2 8 5 1 4 6 \n3 7 2 8 6 4 1 5 \n3 8 4 7 1 6 2 5 \n4 1 5 8 2 7 3 6 \n4 1 5 8 6 3 7 2 \n4 2 5 8 6 1 3 7 \n4 2 7 3 6 8 1 5 \n4 2 7 3 6 8 5 1 \n4 2 7 5 1 8 6 3 \n4 2 8 5 7 1 3 6 \n4 2 8 6 1 3 5 7 \n4 6 1 5 2 8 3 7 \n4 6 8 2 7 1 3 5 \n4 6 8 3 1 7 5 2 \n4 7 1 8 5 2 6 3 \n4 7 3 8 2 5 1 6 \n4 7 5 2 6 1 3 8 \n4 7 5 3 1 6 8 2 \n4 8 1 3 6 2 7 5 \n4 8 1 5 7 2 6 3 \n4 8 5 3 1 7 2 6 \n5 1 4 6 8 2 7 3 \n5 1 8 4 2 7 3 6 \n5 1 8 6 3 7 2 4 \n5 2 4 6 8 3 1 7 \n5 2 4 7 3 8 6 1 \n5 2 6 1 7 4 8 3 \n5 2 8 1 4 7 3 6 \n5 3 1 6 8 2 4 7 \n5 3 1 7 2 8 6 4 \n5 3 8 4 7 1 6 2 \n5 7 1 3 8 6 4 2 \n5 7 1 4 2 8 6 3 \n5 7 2 4 8 1 3 6 \n5 7 2 6 3 1 4 8 \n5 7 2 6 3 1 8 4 \n5 7 4 1 3 8 6 2 \n5 8 4 1 3 6 2 7 \n5 8 4 1 7 2 6 3 \n6 1 5 2 8 3 7 4 \n6 2 7 1 3 5 8 4 \n6 2 7 1 4 8 5 3 \n6 3 1 7 5 8 2 4 \n6 3 1 8 4 2 7 5 \n6 3 1 8 5 2 4 7 \n6 3 5 7 1 4 2 8 \n6 3 5 8 1 4 2 7 \n6 3 7 2 4 8 1 5 \n6 3 7 2 8 5 1 4 \n6 3 7 4 1 8 2 5 \n6 4 1 5 8 2 7 3 \n6 4 2 8 5 7 1 3 \n6 4 7 1 3 5 2 8 \n6 4 7 1 8 2 5 3 \n6 8 2 4 1 7 5 3 \n7 1 3 8 6 4 2 5 \n7 2 4 1 8 5 3 6 \n7 2 6 3 1 4 8 5 \n7 3 1 6 8 5 2 4 \n7 3 8 2 5 1 6 4 \n7 4 2 5 8 1 3 6 \n7 4 2 8 6 1 3 5 \n7 5 3 1 6 8 2 4 \n8 2 4 1 7 5 3 6 \n8 2 5 3 1 7 4 6 \n8 3 1 6 2 5 7 4 \n8 4 1 3 6 2 7 5 \n"
  },
  {
    "path": "lcc/mips/irix/tst/8q.2bk",
    "content": "tst/8q.c:30: warning: missing return value\ntst/8q.c:39: warning: missing return value\n"
  },
  {
    "path": "lcc/mips/irix/tst/8q.sbk",
    "content": ".set reorder\n.globl main\n.text\n.text\n.align 2\n.ent main\nmain:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2000000,-8\n.cprestore 16\nsw $30,20($sp)\nsw $31,24($sp)\nmove $30,$0\nL.2:\nsll $24,$30,2\nla $15,1\nsw $15,down($24)\nsw $15,up($24)\nL.3:\nla $30,1($30)\nla $24,15\nblt $30,$24,L.2\nmove $30,$0\nL.6:\nsll $24,$30,2\nla $15,1\nsw $15,rows($24)\nL.7:\nla $30,1($30)\nla $24,8\nblt $30,$24,L.6\nmove $4,$0\njal queens\nmove $2,$0\nL.1:\nlw $25,16($sp)\nlw $30,20($sp)\nlw $31,24($sp)\naddu $sp,$sp,32\nj $31\n.end main\n.globl queens\n.text\n.align 2\n.ent queens\nqueens:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2800000,-4\nsw $23,16($sp)\n.cprestore 20\nsw $30,24($sp)\nsw $31,28($sp)\nmove $30,$4\nmove $23,$0\nL.11:\nsll $15,$23,2\nlw $15,rows($15)\nbeq $15,$0,L.15\nsubu $15,$23,$30\nsll $15,$15,2\nlw $15,up+28($15)\nbeq $15,$0,L.15\naddu $15,$23,$30\nsll $15,$15,2\nlw $15,down($15)\nbeq $15,$0,L.15\naddu $15,$23,$30\nsll $15,$15,2\nsw $0,down($15)\nsubu $15,$23,$30\nsll $15,$15,2\nsw $0,up+28($15)\nsll $15,$23,2\nsw $0,rows($15)\nsll $24,$30,2\nsw $23,x($24)\nla $24,7\nbne $30,$24,L.19\njal print\nb L.20\nL.19:\nla $4,1($30)\njal queens\nL.20:\nla $24,1\naddu $15,$23,$30\nsll $15,$15,2\nsw $24,down($15)\nsubu $15,$23,$30\nsll $15,$15,2\nsw $24,up+28($15)\nsll $15,$23,2\nsw $24,rows($15)\nL.15:\nL.12:\nla $23,1($23)\nla $24,8\nblt $23,$24,L.11\nmove $2,$0\nL.10:\nlw $23,16($sp)\nlw $25,20($sp)\nlw $30,24($sp)\nlw $31,28($sp)\naddu $sp,$sp,32\nj $31\n.end queens\n.globl print\n.text\n.align 2\n.ent print\nprint:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2000000,-8\n.cprestore 16\nsw $30,20($sp)\nsw $31,24($sp)\nmove $30,$0\nL.23:\nla $4,L.27\nsll $24,$30,2\nlw $24,x($24)\nla $5,49($24)\njal printf\nL.24:\nla $30,1($30)\nla $24,8\nblt $30,$24,L.23\nla $4,L.28\njal printf\nmove $2,$0\nL.22:\nlw $25,16($sp)\nlw $30,20($sp)\nlw $31,24($sp)\naddu $sp,$sp,32\nj $31\n.end print\n.globl x\n.comm x,32\n.globl rows\n.comm rows,32\n.globl down\n.comm down,60\n.globl up\n.comm up,60\n.rdata\n.align 0\nL.28:\n.byte 10\n.byte 0\n.align 0\nL.27:\n.byte 37\n.byte 99\n.byte 32\n.byte 0\n"
  },
  {
    "path": "lcc/mips/irix/tst/array.1bk",
    "content": " 0 1 2 3 1000 1001 1002 1003 2000 2001 2002 2003\n 0 1 2 3 1000 1001 1002 1003 2000 2001 2002 2003\n 0 1 2 3 1000 1001 1002 1003 2000 2001 2002 2003\n 0 1 2 3 1000 1001 1002 1003 2000 2001 2002 2003\n"
  },
  {
    "path": "lcc/mips/irix/tst/array.2bk",
    "content": "tst/array.c:33: warning: missing return value\ntst/array.c:48: warning: missing return value\n"
  },
  {
    "path": "lcc/mips/irix/tst/array.sbk",
    "content": ".set reorder\n.globl main\n.text\n.text\n.align 2\n.ent main\nmain:\n.frame $sp,88,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-88\n.mask 0xc2c00000,-56\nsw $22,16($sp)\nsw $23,20($sp)\n.cprestore 24\nsw $30,28($sp)\nsw $31,32($sp)\nmove $23,$0\nL.2:\nmove $30,$0\nL.6:\nsll $24,$30,2\nsll $15,$23,4\nla $15,x($15)\naddu $24,$24,$15\nla $15,1000\nmul $15,$15,$23\naddu $15,$15,$30\nsw $15,($24)\nL.7:\nla $30,1($30)\nla $24,4\nblt $30,$24,L.6\nsll $24,$23,2\nsll $15,$23,4\nla $15,x($15)\nsw $15,y($24)\nL.3:\nla $23,1($23)\nla $24,3\nblt $23,$24,L.2\njal f\nmove $23,$0\nL.10:\nsll $24,$23,4\nla $15,-48+88($sp)\naddu $24,$24,$15\nmove $22,$24\nsll $15,$23,2\nsw $24,y($15)\nmove $30,$0\nL.14:\nsll $24,$30,2\naddu $15,$24,$22\nsll $14,$23,4\nla $14,x($14)\naddu $24,$24,$14\nlw $24,($24)\nsw $24,($15)\nL.15:\nla $30,1($30)\nla $24,4\nblt $30,$24,L.14\nL.11:\nla $23,1($23)\nla $24,3\nblt $23,$24,L.10\nla $4,-48+88($sp)\nla $5,y\njal g\nmove $2,$0\nL.1:\nlw $22,16($sp)\nlw $23,20($sp)\nlw $25,24($sp)\nlw $30,28($sp)\nlw $31,32($sp)\naddu $sp,$sp,88\nj $31\n.end main\n.globl f\n.text\n.align 2\n.ent f\nf:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2800000,-4\nsw $23,16($sp)\n.cprestore 20\nsw $30,24($sp)\nsw $31,28($sp)\nmove $23,$0\nL.19:\nmove $30,$0\nL.23:\nla $4,L.27\nsll $24,$30,2\nsll $15,$23,4\nla $15,x($15)\naddu $24,$24,$15\nlw $5,($24)\njal printf\nL.24:\nla $30,1($30)\nla $24,4\nblt $30,$24,L.23\nL.20:\nla $23,1($23)\nla $24,3\nblt $23,$24,L.19\nla $4,L.28\njal printf\nmove $23,$0\nL.29:\nmove $30,$0\nL.33:\nla $4,L.27\nsll $24,$30,2\nsll $15,$23,2\nlw $15,y($15)\naddu $24,$24,$15\nlw $5,($24)\njal printf\nL.34:\nla $30,1($30)\nla $24,4\nblt $30,$24,L.33\nL.30:\nla $23,1($23)\nla $24,3\nblt $23,$24,L.29\nla $4,L.28\njal printf\nmove $2,$0\nL.18:\nlw $23,16($sp)\nlw $25,20($sp)\nlw $30,24($sp)\nlw $31,28($sp)\naddu $sp,$sp,32\nj $31\n.end f\n.globl g\n.text\n.align 2\n.ent g\ng:\n.frame $sp,40,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-40\n.mask 0xc2e00000,-4\nsw $21,16($sp)\nsw $22,20($sp)\nsw $23,24($sp)\n.cprestore 28\nsw $30,32($sp)\nsw $31,36($sp)\nmove $30,$4\nmove $23,$5\nmove $21,$0\nL.38:\nmove $22,$0\nL.42:\nla $4,L.27\nsll $24,$22,2\nsll $15,$21,4\naddu $15,$15,$30\naddu $24,$24,$15\nlw $5,($24)\njal printf\nL.43:\nla $22,1($22)\nla $24,4\nblt $22,$24,L.42\nL.39:\nla $21,1($21)\nla $24,3\nblt $21,$24,L.38\nla $4,L.28\njal printf\nmove $21,$0\nL.46:\nmove $22,$0\nL.50:\nla $4,L.27\nsll $24,$22,2\nsll $15,$21,2\naddu $15,$15,$23\nlw $15,($15)\naddu $24,$24,$15\nlw $5,($24)\njal printf\nL.51:\nla $22,1($22)\nla $24,4\nblt $22,$24,L.50\nL.47:\nla $21,1($21)\nla $24,3\nblt $21,$24,L.46\nla $4,L.28\njal printf\nmove $2,$0\nL.37:\nlw $21,16($sp)\nlw $22,20($sp)\nlw $23,24($sp)\nlw $25,28($sp)\nlw $30,32($sp)\nlw $31,36($sp)\naddu $sp,$sp,40\nj $31\n.end g\n.globl y\n.comm y,12\n.globl x\n.comm x,48\n.rdata\n.align 0\nL.28:\n.byte 10\n.byte 0\n.align 0\nL.27:\n.byte 32\n.byte 37\n.byte 100\n.byte 0\n"
  },
  {
    "path": "lcc/mips/irix/tst/cf.1bk",
    "content": "char\tfreq\n011\t8.1\n012\t6.1\n040\t11.9\n!\t0.2\n\"\t1.5\n%\t0.6\n&\t0.4\n'\t0.4\n(\t2.9\n)\t2.9\n*\t0.8\n+\t1.3\n,\t1.3\n-\t0.4\n.\t0.6\n/\t1.0\n0\t2.5\n1\t1.9\n2\t0.6\n3\t0.2\n7\t0.4\n8\t0.2\n;\t3.8\n<\t0.8\n=\t2.7\n>\t0.2\n[\t1.5\n\\\t0.8\n]\t1.5\na\t3.1\nc\t4.4\ne\t2.3\nf\t6.0\ng\t1.3\nh\t1.0\ni\t5.0\nl\t1.0\nm\t0.2\nn\t3.3\no\t2.1\np\t1.0\nq\t0.4\nr\t4.2\ns\t0.6\nt\t3.8\nu\t1.2\nv\t0.6\nw\t0.2\n{\t0.6\n}\t0.6\n"
  },
  {
    "path": "lcc/mips/irix/tst/cf.2bk",
    "content": ""
  },
  {
    "path": "lcc/mips/irix/tst/cf.sbk",
    "content": ".set reorder\n.globl main\n.text\n.text\n.align 2\n.ent main\nmain:\n.frame $sp,48,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-48\n.fmask 0xc0000000,-32\n.mask 0xc2c00000,-8\ns.d $f30,16($sp)\nsw $22,24($sp)\nsw $23,28($sp)\n.cprestore 32\nsw $30,36($sp)\nsw $31,40($sp)\nsw $4,48($sp)\nsw $5,52($sp)\nlw $24,0+48($sp)\nla $15,1\nbgt $24,$15,L.2\nl.s $f30,L.4\nb L.3\nL.2:\nlw $24,4+48($sp)\nlw $4,4($24)\njal atof\nl.s $f16,L.5\ndiv.s $f30,$f0,$f16\nL.3:\nmove $30,$0\nL.6:\nmove $24,$30\nla $30,1($24)\nsll $24,$24,2\nl.s $f18,L.4\ns.s $f18,f($24)\nL.7:\nla $24,127\nble $30,$24,L.6\nmove $23,$0\nb L.11\nL.10:\nsll $24,$22,2\nla $24,f($24)\nl.s $f18,($24)\nl.s $f16,L.13\nadd.s $f18,$f18,$f16\ns.s $f18,($24)\nla $23,1($23)\nL.11:\njal getchar\nmove $22,$2\nla $15,-1\nbne $2,$15,L.10\nla $4,L.14\njal printf\nmove $30,$0\nL.15:\nsll $24,$30,2\nl.s $f18,f($24)\nl.s $f16,L.4\nc.eq.s $f18,$f16; bc1t L.19\nmtc1 $23,$f16; cvt.s.w $f16,$f16\ndiv.s $f18,$f18,$f16\nc.lt.s $f18,$f30; bc1t L.19\nla $24,32\nbgt $30,$24,L.21\nla $4,L.23\nmove $5,$30\njal printf\nb L.22\nL.21:\nla $4,L.24\nmove $5,$30\njal printf\nL.22:\nla $4,L.25\nl.s $f18,L.5\nsll $24,$30,2\nl.s $f16,f($24)\nmul.s $f18,$f18,$f16\nmtc1 $23,$f16; cvt.s.w $f16,$f16\ndiv.s $f18,$f18,$f16\ncvt.d.s $f18,$f18\nmfc1.d $6,$f18\njal printf\nL.19:\nL.16:\nla $30,1($30)\nla $24,127\nble $30,$24,L.15\nmove $2,$0\nL.1:\nl.d $f30,16($sp)\nlw $22,24($sp)\nlw $23,28($sp)\nlw $25,32($sp)\nlw $30,36($sp)\nlw $31,40($sp)\naddu $sp,$sp,48\nj $31\n.end main\n.globl f\n.comm f,512\n.rdata\n.align 0\nL.25:\n.byte 9\n.byte 37\n.byte 46\n.byte 49\n.byte 102\n.byte 10\n.byte 0\n.align 0\nL.24:\n.byte 37\n.byte 99\n.byte 0\n.align 0\nL.23:\n.byte 37\n.byte 48\n.byte 51\n.byte 111\n.byte 0\n.align 0\nL.14:\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 9\n.byte 102\n.byte 114\n.byte 101\n.byte 113\n.byte 10\n.byte 0\n.align 2\nL.13:\n.word 0x3f800000\n.align 2\nL.5:\n.word 0x42c80000\n.align 2\nL.4:\n.word 0x0\n"
  },
  {
    "path": "lcc/mips/irix/tst/cq.1bk",
    "content": "Section s22     returned 0.\nDecimal and octal/hex constants sometimes give\n   different results when assigned to longs.\nDecimal and octal/hex constants sometimes give\n   different results when assigned to longs.\nSection s241    returned 0.\nSection s243    returned 0.\nSection s244    returned 0.\nSection s25     returned 0.\n  8 bits in chars.\n 32 bits in ints.\n 16 bits in shorts.\n 32 bits in longs.\n 32 bits in unsigneds.\n 32 bits in floats.\n 64 bits in doubles.\n1.192093e-07 is the least number that can be added to 1. (float).\n2.220446e-16 is the least number that can be added to 1. (double).\nSection s26     returned 0.\nSection s4      returned 0.\nSection s61     returned 0.\nSection s626    returned 0.\nSection s71     returned 0.\nSection s72     returned 0.\nSection s757    returned 0.\nSection s7813   returned 0.\nSection s714    returned 0.\nSection s715    returned 0.\nRegister count for char is unreliable.\nRegister count for pointer is unreliable.\nRegister count for int is unreliable.\nSection s81     returned 0.\nSection s84     returned 0.\nchar alignment: 1\nshort alignment: 2\nint alignment: 4\nlong alignment: 4\nunsigned alignment: 4\nfloat alignment: 4\ndouble alignment: 8\nSign extension in fields\nBe especially careful with 1-bit fields!\nSection s85     returned 0.\nSection s86     returned 0.\nSection s88     returned 0.\nSection s9      returned 0.\n\nNo errors detected.\n"
  },
  {
    "path": "lcc/mips/irix/tst/cq.2bk",
    "content": "tst/cq.c:394: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:394: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:394: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:395: warning: overflow in constant `4294967296'\ntst/cq.c:395: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:395: warning: overflow in constant `040000000000'\ntst/cq.c:395: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:395: warning: overflow in constant `0x100000000'\ntst/cq.c:395: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:396: warning: overflow in constant `68719476735'\ntst/cq.c:396: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:396: warning: overflow in constant `0777777777777'\ntst/cq.c:396: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:396: warning: overflow in constant `0xfffffffff'\ntst/cq.c:396: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:397: warning: overflow in constant `68719476736'\ntst/cq.c:397: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:397: warning: overflow in constant `01000000000000'\ntst/cq.c:397: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:397: warning: overflow in constant `0x1000000000'\ntst/cq.c:397: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:533: warning: missing return value\ntst/cq.c:1169: warning: missing return value\ntst/cq.c:5294: warning: unreachable code\ntst/cq.c:5303: warning: missing return value\n"
  },
  {
    "path": "lcc/mips/irix/tst/cq.sbk",
    "content": ".set reorder\n.data\n.align 2\nL.2:\n.word s22\n.word s241\n.word s243\n.word s244\n.word s25\n.word s26\n.word s4\n.word s61\n.word s626\n.word s71\n.word s72\n.word s757\n.word s7813\n.word s714\n.word s715\n.word s81\n.word s84\n.word s85\n.word s86\n.word s88\n.word s9\n.lcomm L.3,68\n.lcomm L.4,4\n.globl main\n.text\n.text\n.align 2\n.ent main\nmain:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2000000,-8\n.cprestore 16\nsw $30,20($sp)\nsw $31,24($sp)\nsw $4,32($sp)\nsw $5,36($sp)\nla $24,1\nsw $24,L.3+36\nla $24,1\nsw $24,L.3+40\nla $24,1\nsw $24,L.3+44\nla $24,1\nsw $24,L.3+48\nla $24,L.3\nsw $24,L.4\nmove $30,$0\nb L.12\nL.9:\nlw $4,L.4\nsll $24,$30,2\nlw $25,L.2($24)\njal $25\nsw $2,L.3+52\nlw $24,L.3+56\nlw $15,L.3+52\naddu $24,$24,$15\nsw $24,L.3+56\nlw $24,L.3+36\nbeq $24,$0,L.17\nla $4,L.20\nla $5,L.3+60\nlw $6,L.3+52\njal printf\nL.17:\nL.10:\nla $30,1($30)\nL.12:\nmove $24,$30\nla $15,21\nbltu $24,$15,L.9\nlw $24,L.3+56\nbne $24,$0,L.23\nla $4,L.26\njal printf\nb L.24\nL.23:\nla $4,L.27\njal printf\nL.24:\nmove $2,$0\nL.1:\nlw $25,16($sp)\nlw $30,20($sp)\nlw $31,24($sp)\naddu $sp,$sp,32\nj $31\n.end main\n.data\n.align 0\nL.29:\n.byte 115\n.byte 50\n.byte 50\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.sdata\n.align 0\nL.30:\n.byte 115\n.byte 50\n.byte 50\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s22\n.text\n.text\n.align 2\n.ent s22\ns22:\n.frame $sp,56,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-56\n.mask 0xc2e00000,-20\nsw $21,16($sp)\nsw $22,20($sp)\nsw $23,24($sp)\n.cprestore 28\nsw $30,32($sp)\nsw $31,36($sp)\nsw $4,56($sp)\nmove $22,$0\nla $30,L.30\nlw $24,0+56($sp)\nla $23,60($24)\nL.31:\nL.32:\nmove $24,$23\nla $23,1($24)\nmove $15,$30\nla $30,1($15)\nlb $15,($15)\nsb $15,($24)\nsll $24,$15,8*(4-1); sra $24,$24,8*(4-1)\nbne $24,$0,L.31\nla $21,1\nla $24,2\nsw $24,-8+56($sp)\nla $24,3\nsw $24,-12+56($sp)\nla $24,4\nsw $24,-4+56($sp)\nlw $24,-8+56($sp)\naddu $24,$21,$24\nlw $15,-12+56($sp)\naddu $24,$24,$15\nlw $15,-4+56($sp)\naddu $24,$24,$15\nla $15,10\nbeq $24,$15,L.34\nla $22,1($22)\nlw $24,0+56($sp)\nlw $24,44($24)\nbeq $24,$0,L.36\nla $4,L.29\nla $5,1\njal printf\nL.36:\nL.34:\nla $24,2\nsw $24,-16+56($sp)\nlw $24,-16+56($sp)\nbne $24,$21,L.38\nla $22,4($22)\nlw $24,0+56($sp)\nlw $24,44($24)\nbeq $24,$0,L.40\nla $4,L.29\nla $5,4\njal printf\nL.40:\nL.38:\nmove $2,$22\nL.28:\nlw $21,16($sp)\nlw $22,20($sp)\nlw $23,24($sp)\nlw $25,28($sp)\nlw $30,32($sp)\nlw $31,36($sp)\naddu $sp,$sp,56\nj $31\n.end s22\n.data\n.align 0\nL.43:\n.byte 115\n.byte 50\n.byte 52\n.byte 49\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.sdata\n.align 0\nL.44:\n.byte 115\n.byte 50\n.byte 52\n.byte 49\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.data\n.align 2\nL.45:\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x6\n.word 0x0\n.word 0x8\n.word 0x0\n.word 0xc\n.word 0x0\n.word 0x10\n.word 0x0\n.word 0x12\n.word 0x0\n.word 0x14\n.word 0x0\n.word 0x18\n.word 0x0\n.word 0x1c\n.word 0x0\n.word 0x1e\n.word 0x0\n.word 0x20\n.word 0x0\n.word 0x24\n.globl s241\n.text\n.text\n.align 2\n.ent s241\ns241:\n.frame $sp,520,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-520\n.mask 0xc2f00000,-480\nsw $20,16($sp)\nsw $21,20($sp)\nsw $22,24($sp)\nsw $23,28($sp)\n.cprestore 32\nsw $30,36($sp)\nsw $31,40($sp)\nmove $30,$4\nmove $20,$0\nsw $0,-472+520($sp)\nla $22,L.44\nla $21,60($30)\nL.46:\nL.47:\nmove $24,$21\nla $21,1($24)\nmove $15,$22\nla $22,1($15)\nlb $15,($15)\nsb $15,($24)\nsll $24,$15,8*(4-1); sra $24,$24,8*(4-1)\nbne $24,$0,L.46\nb L.49\nla $20,1($20)\nlw $24,44($30)\nbeq $24,$0,L.51\nla $4,L.43\nla $5,1\njal printf\nL.51:\nL.49:\nb L.53\nla $20,2($20)\nlw $24,44($30)\nbeq $24,$0,L.55\nla $4,L.43\nla $5,2\njal printf\nL.55:\nL.53:\nb L.57\nla $20,4($20)\nlw $24,44($30)\nbeq $24,$0,L.59\nla $4,L.43\nla $5,4\njal printf\nL.59:\nL.57:\nb L.61\nla $20,8($20)\nlw $24,44($30)\nbeq $24,$0,L.63\nla $4,L.43\nla $5,8\njal printf\nL.63:\nL.61:\nmove $23,$0\nL.65:\nsll $24,$23,2\nsw $23,L.45($24)\nL.66:\nla $23,1($23)\nla $24,17\nblt $23,$24,L.65\nla $23,18\nL.69:\nsll $24,$23,2\nla $24,L.45($24)\nsw $24,-476+520($sp)\nlw $4,($24)\njal pow2\nlw $15,-476+520($sp)\nsw $2,($15)\nsll $24,$23,2\nlw $15,L.45($24)\nsubu $15,$15,1\nsw $15,L.45-4($24)\nla $23,2($23)\nL.70:\nla $24,39\nblt $23,$24,L.69\nsw $0,-156+520($sp)\nsw $0,-312+520($sp)\nsw $0,-468+520($sp)\nla $24,1\nsw $24,-152+520($sp)\nla $24,1\nsw $24,-308+520($sp)\nla $24,1\nsw $24,-464+520($sp)\nla $24,2\nsw $24,-148+520($sp)\nla $24,2\nsw $24,-304+520($sp)\nla $24,2\nsw $24,-460+520($sp)\nla $24,3\nsw $24,-144+520($sp)\nla $24,3\nsw $24,-300+520($sp)\nla $24,3\nsw $24,-456+520($sp)\nla $24,4\nsw $24,-140+520($sp)\nla $24,4\nsw $24,-296+520($sp)\nla $24,4\nsw $24,-452+520($sp)\nla $24,5\nsw $24,-136+520($sp)\nla $24,5\nsw $24,-292+520($sp)\nla $24,5\nsw $24,-448+520($sp)\nla $24,6\nsw $24,-132+520($sp)\nla $24,6\nsw $24,-288+520($sp)\nla $24,6\nsw $24,-444+520($sp)\nla $24,7\nsw $24,-128+520($sp)\nla $24,7\nsw $24,-284+520($sp)\nla $24,7\nsw $24,-440+520($sp)\nla $24,8\nsw $24,-124+520($sp)\nla $24,8\nsw $24,-280+520($sp)\nla $24,8\nsw $24,-436+520($sp)\nla $24,9\nsw $24,-120+520($sp)\nla $24,9\nsw $24,-276+520($sp)\nla $24,9\nsw $24,-432+520($sp)\nla $24,10\nsw $24,-116+520($sp)\nla $24,10\nsw $24,-272+520($sp)\nla $24,10\nsw $24,-428+520($sp)\nla $24,11\nsw $24,-112+520($sp)\nla $24,11\nsw $24,-268+520($sp)\nla $24,11\nsw $24,-424+520($sp)\nla $24,12\nsw $24,-108+520($sp)\nla $24,12\nsw $24,-264+520($sp)\nla $24,12\nsw $24,-420+520($sp)\nla $24,13\nsw $24,-104+520($sp)\nla $24,13\nsw $24,-260+520($sp)\nla $24,13\nsw $24,-416+520($sp)\nla $24,14\nsw $24,-100+520($sp)\nla $24,14\nsw $24,-256+520($sp)\nla $24,14\nsw $24,-412+520($sp)\nla $24,15\nsw $24,-96+520($sp)\nla $24,15\nsw $24,-252+520($sp)\nla $24,15\nsw $24,-408+520($sp)\nla $24,16\nsw $24,-92+520($sp)\nla $24,16\nsw $24,-248+520($sp)\nla $24,16\nsw $24,-404+520($sp)\nla $24,63\nsw $24,-88+520($sp)\nla $24,63\nsw $24,-244+520($sp)\nla $24,63\nsw $24,-400+520($sp)\nla $24,64\nsw $24,-84+520($sp)\nla $24,64\nsw $24,-240+520($sp)\nla $24,64\nsw $24,-396+520($sp)\nla $24,255\nsw $24,-80+520($sp)\nla $24,255\nsw $24,-236+520($sp)\nla $24,255\nsw $24,-392+520($sp)\nla $24,256\nsw $24,-76+520($sp)\nla $24,256\nsw $24,-232+520($sp)\nla $24,256\nsw $24,-388+520($sp)\nla $24,4095\nsw $24,-72+520($sp)\nla $24,4095\nsw $24,-228+520($sp)\nla $24,4095\nsw $24,-384+520($sp)\nla $24,4096\nsw $24,-68+520($sp)\nla $24,4096\nsw $24,-224+520($sp)\nla $24,4096\nsw $24,-380+520($sp)\nla $24,65535\nsw $24,-64+520($sp)\nla $24,65535\nsw $24,-220+520($sp)\nla $24,65535\nsw $24,-376+520($sp)\nla $24,65536\nsw $24,-60+520($sp)\nla $24,65536\nsw $24,-216+520($sp)\nla $24,65536\nsw $24,-372+520($sp)\nla $24,262143\nsw $24,-56+520($sp)\nla $24,262143\nsw $24,-212+520($sp)\nla $24,262143\nsw $24,-368+520($sp)\nla $24,262144\nsw $24,-52+520($sp)\nla $24,262144\nsw $24,-208+520($sp)\nla $24,262144\nsw $24,-364+520($sp)\nla $24,1048575\nsw $24,-48+520($sp)\nla $24,1048575\nsw $24,-204+520($sp)\nla $24,1048575\nsw $24,-360+520($sp)\nla $24,1048576\nsw $24,-44+520($sp)\nla $24,1048576\nsw $24,-200+520($sp)\nla $24,1048576\nsw $24,-356+520($sp)\nla $24,16777215\nsw $24,-40+520($sp)\nla $24,16777215\nsw $24,-196+520($sp)\nla $24,16777215\nsw $24,-352+520($sp)\nla $24,16777216\nsw $24,-36+520($sp)\nla $24,16777216\nsw $24,-192+520($sp)\nla $24,16777216\nsw $24,-348+520($sp)\nla $24,268435455\nsw $24,-32+520($sp)\nla $24,268435455\nsw $24,-188+520($sp)\nla $24,268435455\nsw $24,-344+520($sp)\nla $24,268435456\nsw $24,-28+520($sp)\nla $24,268435456\nsw $24,-184+520($sp)\nla $24,268435456\nsw $24,-340+520($sp)\nla $24,1073741823\nsw $24,-24+520($sp)\nla $24,1073741823\nsw $24,-180+520($sp)\nla $24,1073741823\nsw $24,-336+520($sp)\nla $24,1073741824\nsw $24,-20+520($sp)\nla $24,1073741824\nsw $24,-176+520($sp)\nla $24,1073741824\nsw $24,-332+520($sp)\nla $24,0xffffffff\nsw $24,-16+520($sp)\nla $24,0xffffffff\nsw $24,-172+520($sp)\nla $24,0xffffffff\nsw $24,-328+520($sp)\nla $24,0xffffffff\nsw $24,-12+520($sp)\nla $24,0xffffffff\nsw $24,-168+520($sp)\nla $24,0xffffffff\nsw $24,-324+520($sp)\nla $24,0xffffffff\nsw $24,-8+520($sp)\nla $24,0xffffffff\nsw $24,-164+520($sp)\nla $24,0xffffffff\nsw $24,-320+520($sp)\nla $24,0xffffffff\nsw $24,-4+520($sp)\nla $24,0xffffffff\nsw $24,-160+520($sp)\nla $24,0xffffffff\nsw $24,-316+520($sp)\nmove $23,$0\nL.188:\nsll $24,$23,2\nla $15,-156+520($sp)\naddu $15,$24,$15\nlw $15,($15)\nlw $14,L.45($24)\nbne $14,$15,L.195\nla $14,-312+520($sp)\naddu $14,$24,$14\nlw $14,($14)\nbne $15,$14,L.195\nla $15,-468+520($sp)\naddu $24,$24,$15\nlw $24,($24)\nbeq $14,$24,L.192\nL.195:\nlw $24,40($30)\nbeq $24,$0,L.196\nla $4,L.198\njal printf\nla $4,L.199\njal printf\nL.196:\nL.192:\nL.189:\nla $23,1($23)\nla $24,39\nblt $23,$24,L.188\nlw $24,-472+520($sp)\nbeq $24,$0,L.200\nla $20,16\nL.200:\nmove $2,$20\nL.42:\nlw $20,16($sp)\nlw $21,20($sp)\nlw $22,24($sp)\nlw $23,28($sp)\nlw $25,32($sp)\nlw $30,36($sp)\nlw $31,40($sp)\naddu $sp,$sp,520\nj $31\n.end s241\n.globl pow2\n.text\n.align 2\n.ent pow2\npow2:\n.frame $sp,8,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-8\n.mask 0x40000000,-8\nsw $30,0($sp)\nla $30,1\nb L.204\nL.203:\nsll $30,$30,1\nL.204:\nmove $24,$4\nsubu $4,$24,1\nbne $24,$0,L.203\nmove $2,$30\nL.202:\nlw $30,0($sp)\naddu $sp,$sp,8\nj $31\n.end pow2\n.data\n.align 0\nL.207:\n.byte 115\n.byte 50\n.byte 52\n.byte 51\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.sdata\n.align 0\nL.208:\n.byte 115\n.byte 50\n.byte 52\n.byte 51\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s243\n.text\n.text\n.align 2\n.ent s243\ns243:\n.frame $sp,296,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-296\n.mask 0xc2c00000,-264\nsw $22,16($sp)\nsw $23,20($sp)\n.cprestore 24\nsw $30,28($sp)\nsw $31,32($sp)\nsw $4,296($sp)\nmove $22,$0\nla $30,L.208\nlw $24,0+296($sp)\nla $23,60($24)\nL.209:\nL.210:\nmove $24,$23\nla $23,1($24)\nmove $15,$30\nla $30,1($15)\nlb $15,($15)\nsb $15,($24)\nsll $24,$15,8*(4-1); sra $24,$24,8*(4-1)\nbne $24,$0,L.209\nla $4,-256+296($sp)\njal zerofill\nla $24,1\nsb $24,-159+296($sp)\nla $24,1\nsb $24,-191+296($sp)\nla $24,1\nsb $24,-130+296($sp)\nla $24,1\nsb $24,-208+296($sp)\nla $24,1\nsb $24,-158+296($sp)\nla $24,1\nsb $24,-190+296($sp)\nla $24,1\nsb $24,-223+296($sp)\nla $24,1\nsb $24,-207+296($sp)\nla $24,1\nsb $24,-157+296($sp)\nla $24,1\nsb $24,-189+296($sp)\nla $24,1\nsb $24,-222+296($sp)\nla $24,1\nsb $24,-206+296($sp)\nla $24,1\nsb $24,-156+296($sp)\nla $24,1\nsb $24,-188+296($sp)\nla $24,1\nsb $24,-221+296($sp)\nla $24,1\nsb $24,-205+296($sp)\nla $24,1\nsb $24,-155+296($sp)\nla $24,1\nsb $24,-187+296($sp)\nla $24,1\nsb $24,-219+296($sp)\nla $24,1\nsb $24,-204+296($sp)\nla $24,1\nsb $24,-154+296($sp)\nla $24,1\nsb $24,-186+296($sp)\nla $24,1\nsb $24,-218+296($sp)\nla $24,1\nsb $24,-203+296($sp)\nla $24,1\nsb $24,-153+296($sp)\nla $24,1\nsb $24,-185+296($sp)\nla $24,1\nsb $24,-216+296($sp)\nla $24,1\nsb $24,-202+296($sp)\nla $24,1\nsb $24,-152+296($sp)\nla $24,1\nsb $24,-184+296($sp)\nla $24,1\nsb $24,-215+296($sp)\nla $24,1\nsb $24,-201+296($sp)\nla $24,1\nsb $24,-151+296($sp)\nla $24,1\nsb $24,-183+296($sp)\nla $24,1\nsb $24,-161+296($sp)\nla $24,1\nsb $24,-200+296($sp)\nla $24,1\nsb $24,-150+296($sp)\nla $24,1\nsb $24,-182+296($sp)\nla $24,1\nsb $24,-195+296($sp)\nla $24,1\nsb $24,-199+296($sp)\nla $24,1\nsb $24,-149+296($sp)\nla $24,1\nsb $24,-181+296($sp)\nla $24,1\nsb $24,-211+296($sp)\nla $24,1\nsb $24,-148+296($sp)\nla $24,1\nsb $24,-180+296($sp)\nla $24,1\nsb $24,-162+296($sp)\nla $24,1\nsb $24,-147+296($sp)\nla $24,1\nsb $24,-179+296($sp)\nla $24,1\nsb $24,-132+296($sp)\nla $24,1\nsb $24,-246+296($sp)\nla $24,1\nsb $24,-146+296($sp)\nla $24,1\nsb $24,-178+296($sp)\nla $24,1\nsb $24,-247+296($sp)\nla $24,1\nsb $24,-145+296($sp)\nla $24,1\nsb $24,-177+296($sp)\nla $24,1\nsb $24,-133+296($sp)\nla $24,1\nsb $24,-248+296($sp)\nla $24,1\nsb $24,-144+296($sp)\nla $24,1\nsb $24,-176+296($sp)\nla $24,1\nsb $24,-131+296($sp)\nla $24,1\nsb $24,-243+296($sp)\nla $24,1\nsb $24,-143+296($sp)\nla $24,1\nsb $24,-175+296($sp)\nla $24,1\nsb $24,-165+296($sp)\nla $24,1\nsb $24,-244+296($sp)\nla $24,1\nsb $24,-142+296($sp)\nla $24,1\nsb $24,-174+296($sp)\nla $24,1\nsb $24,-163+296($sp)\nla $24,1\nsb $24,-141+296($sp)\nla $24,1\nsb $24,-173+296($sp)\nla $24,1\nsb $24,-213+296($sp)\nla $24,1\nsb $24,-164+296($sp)\nla $24,1\nsb $24,-140+296($sp)\nla $24,1\nsb $24,-172+296($sp)\nla $24,1\nsb $24,-197+296($sp)\nla $24,1\nsb $24,-217+296($sp)\nla $24,1\nsb $24,-139+296($sp)\nla $24,1\nsb $24,-171+296($sp)\nla $24,1\nsb $24,-214+296($sp)\nla $24,1\nsb $24,-138+296($sp)\nla $24,1\nsb $24,-170+296($sp)\nla $24,1\nsb $24,-198+296($sp)\nla $24,1\nsb $24,-256+296($sp)\nsb $24,-137+296($sp)\nla $24,1\nsb $24,-169+296($sp)\nla $24,1\nsb $24,-196+296($sp)\nla $24,1\nsb $24,-224+296($sp)\nla $24,1\nsb $24,-136+296($sp)\nla $24,1\nsb $24,-168+296($sp)\nla $24,1\nsb $24,-194+296($sp)\nla $24,1\nsb $24,-135+296($sp)\nla $24,1\nsb $24,-167+296($sp)\nla $24,1\nsb $24,-212+296($sp)\nla $24,1\nsb $24,-134+296($sp)\nla $24,1\nsb $24,-166+296($sp)\nla $24,1\nsb $24,-210+296($sp)\nla $24,1\nsb $24,-193+296($sp)\nla $24,1\nsb $24,-209+296($sp)\nla $4,-256+296($sp)\njal sumof\nla $15,98\nbeq $2,$15,L.309\nla $22,1($22)\nlw $24,0+296($sp)\nlw $24,44($24)\nbeq $24,$0,L.311\nla $4,L.207\nla $5,1\njal printf\nL.311:\nL.309:\nb L.313\nla $22,8($22)\nlw $24,0+296($sp)\nlw $24,44($24)\nbeq $24,$0,L.315\nla $4,L.207\nla $5,8\njal printf\nL.315:\nL.313:\nmove $2,$22\nL.206:\nlw $22,16($sp)\nlw $23,20($sp)\nlw $25,24($sp)\nlw $30,28($sp)\nlw $31,32($sp)\naddu $sp,$sp,296\nj $31\n.end s243\n.globl zerofill\n.text\n.align 2\n.ent zerofill\nzerofill:\n.frame $sp,8,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-8\n.mask 0x40000000,-8\nsw $30,0($sp)\nmove $30,$0\nL.318:\nmove $24,$4\nla $4,1($24)\nsb $0,($24)\nL.319:\nla $30,1($30)\nla $24,256\nblt $30,$24,L.318\nmove $2,$0\nL.317:\nlw $30,0($sp)\naddu $sp,$sp,8\nj $31\n.end zerofill\n.globl sumof\n.text\n.align 2\n.ent sumof\nsumof:\n.frame $sp,16,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-16\n.mask 0x40c00000,-8\nsw $22,0($sp)\nsw $23,4($sp)\nsw $30,8($sp)\nmove $22,$4\nmove $30,$0\nmove $23,$0\nL.323:\nmove $24,$22\nla $22,1($24)\nlb $24,($24)\naddu $30,$30,$24\nL.324:\nla $23,1($23)\nla $24,256\nblt $23,$24,L.323\nmove $2,$30\nL.322:\nlw $22,0($sp)\nlw $23,4($sp)\nlw $30,8($sp)\naddu $sp,$sp,16\nj $31\n.end sumof\n.data\n.align 0\nL.328:\n.byte 115\n.byte 50\n.byte 52\n.byte 52\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.sdata\n.align 0\nL.329:\n.byte 115\n.byte 50\n.byte 52\n.byte 52\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s244\n.text\n.text\n.align 2\n.ent s244\ns244:\n.frame $sp,112,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-112\n.mask 0xc2f00000,-72\nsw $20,16($sp)\nsw $21,20($sp)\nsw $22,24($sp)\nsw $23,28($sp)\n.cprestore 32\nsw $30,36($sp)\nsw $31,40($sp)\nsw $4,112($sp)\nla $23,L.329\nlw $24,0+112($sp)\nla $22,60($24)\nL.330:\nL.331:\nmove $24,$22\nla $22,1($24)\nmove $15,$23\nla $23,1($15)\nlb $15,($15)\nsb $15,($24)\nsll $24,$15,8*(4-1); sra $24,$24,8*(4-1)\nbne $24,$0,L.330\nmove $20,$0\nmove $21,$0\nl.d $f18,L.333\ns.d $f18,-64+112($sp)\ns.d $f18,-56+112($sp)\nl.d $f18,L.333\ns.d $f18,-48+112($sp)\nl.d $f18,L.333\ns.d $f18,-40+112($sp)\nl.d $f18,L.333\ns.d $f18,-32+112($sp)\nl.d $f18,L.333\ns.d $f18,-24+112($sp)\nl.d $f18,L.333\ns.d $f18,-16+112($sp)\nl.d $f18,L.333\ns.d $f18,-8+112($sp)\nmove $21,$0\nmove $30,$0\nL.341:\nsll $24,$30,3\nla $15,-64+112($sp)\naddu $15,$24,$15\nl.d $f18,($15)\nla $15,-56+112($sp)\naddu $24,$24,$15\nl.d $f16,($24)\nc.eq.d $f18,$f16; bc1t L.345\nla $21,1\nL.345:\nL.342:\nla $30,1($30)\nla $24,7\nblt $30,$24,L.341\nbeq $21,$0,L.348\nlw $24,0+112($sp)\nlw $24,44($24)\nbeq $24,$0,L.350\nla $4,L.328\nla $5,1\njal printf\nL.350:\nla $20,1($20)\nL.348:\nb L.352\nlw $24,0+112($sp)\nlw $24,44($24)\nbeq $24,$0,L.354\nla $4,L.328\nla $5,2\njal printf\nL.354:\nla $20,2($20)\nL.352:\nmove $2,$20\nL.327:\nlw $20,16($sp)\nlw $21,20($sp)\nlw $22,24($sp)\nlw $23,28($sp)\nlw $25,32($sp)\nlw $30,36($sp)\nlw $31,40($sp)\naddu $sp,$sp,112\nj $31\n.end s244\n.data\n.align 0\nL.357:\n.byte 115\n.byte 50\n.byte 53\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.sdata\n.align 0\nL.358:\n.byte 115\n.byte 50\n.byte 53\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s25\n.text\n.text\n.align 2\n.ent s25\ns25:\n.frame $sp,56,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-56\n.mask 0xc2fe0000,-4\nsw $17,16($sp)\nsw $18,20($sp)\nsw $19,24($sp)\nsw $20,28($sp)\nsw $21,32($sp)\nsw $22,36($sp)\nsw $23,40($sp)\n.cprestore 44\nsw $30,48($sp)\nsw $31,52($sp)\nmove $30,$4\nla $20,L.358\nla $19,60($30)\nL.359:\nL.360:\nmove $24,$19\nla $19,1($24)\nmove $15,$20\nla $20,1($15)\nlb $15,($15)\nsb $15,($24)\nsll $24,$15,8*(4-1); sra $24,$24,8*(4-1)\nbne $24,$0,L.359\nmove $18,$0\nla $22,L.362\nlb $24,1($22)\nlb $15,($22)\nbne $15,$24,L.366\nlb $15,2($22)\nbne $24,$15,L.366\nla $24,46\nbeq $15,$24,L.363\nL.366:\nla $18,1($18)\nlw $24,44($30)\nbeq $24,$0,L.367\nla $4,L.357\nla $5,1\njal printf\nL.367:\nL.363:\nlb $24,3($22)\nbeq $24,$0,L.369\nla $18,4($18)\nlw $24,44($30)\nbeq $24,$0,L.371\nla $4,L.357\nla $5,4\njal printf\nL.371:\nL.369:\nlb $24,L.375+1\nla $15,34\nbeq $24,$15,L.373\nla $18,8($18)\nlw $24,44($30)\nbeq $24,$0,L.377\nla $4,L.357\nla $5,8\njal printf\nL.377:\nL.373:\nla $22,L.379\nlb $24,($22)\nla $15,10\nbne $24,$15,L.387\nlb $24,1($22)\nla $15,9\nbne $24,$15,L.387\nlb $24,2($22)\nla $15,8\nbne $24,$15,L.387\nlb $24,3($22)\nla $15,13\nbne $24,$15,L.387\nlb $24,4($22)\nla $15,12\nbne $24,$15,L.387\nlb $24,5($22)\nla $15,92\nbne $24,$15,L.387\nlb $24,6($22)\nla $15,39\nbeq $24,$15,L.380\nL.387:\nla $18,16($18)\nlw $24,44($30)\nbeq $24,$0,L.388\nla $4,L.357\nla $5,16\njal printf\nL.388:\nL.380:\nla $24,L.390\nmove $21,$24\nmove $22,$24\nmove $17,$0\nmove $23,$0\nb L.394\nL.391:\naddu $24,$23,$22\nlb $24,($24)\naddu $15,$23,$21\nlb $15,($15)\nbeq $24,$15,L.395\nla $17,1\nL.395:\nL.392:\nla $23,1($23)\nL.394:\nmove $24,$23\nla $15,7\nbltu $24,$15,L.391\nbeq $17,$0,L.397\nla $18,32($18)\nlw $24,44($30)\nbeq $24,$0,L.399\nla $4,L.357\nla $5,32\njal printf\nL.399:\nL.397:\nmove $2,$18\nL.356:\nlw $17,16($sp)\nlw $18,20($sp)\nlw $19,24($sp)\nlw $20,28($sp)\nlw $21,32($sp)\nlw $22,36($sp)\nlw $23,40($sp)\nlw $25,44($sp)\nlw $30,48($sp)\nlw $31,52($sp)\naddu $sp,$sp,56\nj $31\n.end s25\n.sdata\n.align 0\nL.402:\n.byte 115\n.byte 50\n.byte 54\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.data\n.align 0\nL.403:\n.byte 37\n.byte 51\n.byte 100\n.byte 32\n.byte 98\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 37\n.byte 115\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.data\n.align 0\nL.404:\n.byte 37\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 108\n.byte 101\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 97\n.byte 100\n.byte 100\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 49\n.byte 46\n.byte 32\n.byte 40\n.byte 37\n.byte 115\n.byte 41\n.byte 46\n.byte 10\n.byte 0\n.globl s26\n.text\n.text\n.align 2\n.ent s26\ns26:\n.frame $sp,96,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-96\n.fmask 0xffc00000,-40\n.mask 0xc2f00000,-8\ns.d $f22,24($sp)\ns.d $f24,32($sp)\ns.d $f26,40($sp)\ns.d $f28,48($sp)\ns.d $f30,56($sp)\nsw $20,64($sp)\nsw $21,68($sp)\nsw $22,72($sp)\nsw $23,76($sp)\n.cprestore 80\nsw $30,84($sp)\nsw $31,88($sp)\nmove $30,$4\nla $22,L.402\nla $21,60($30)\nL.405:\nL.406:\nmove $24,$21\nla $21,1($24)\nmove $15,$22\nla $22,1($15)\nlb $15,($15)\nsb $15,($24)\nsll $24,$15,8*(4-1); sra $24,$24,8*(4-1)\nbne $24,$0,L.405\nsw $0,($30)\nmove $20,$0\nla $23,1\nb L.409\nL.408:\nsll $24,$23,8*(4-1); sra $24,$24,8*(4-1)\nsll $24,$24,1\nmove $23,$24\nlw $24,($30)\nla $24,1($24)\nsw $24,($30)\nL.409:\nsll $24,$20,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$23,8*(4-1); sra $15,$15,8*(4-1)\nbne $24,$15,L.408\nlw $24,($30)\nsll $24,$24,2\nsw $24,4($30)\nlw $24,($30)\nsll $24,$24,1\nsw $24,8($30)\nlw $24,($30)\nsll $24,$24,2\nsw $24,12($30)\nlw $24,($30)\nsll $24,$24,2\nsw $24,16($30)\nlw $24,($30)\nsll $24,$24,2\nsw $24,20($30)\nlw $24,($30)\nsll $24,$24,3\nsw $24,24($30)\nl.s $f18,L.411\nmov.s $f26,$f18\nmov.s $f30,$f18\nl.s $f28,L.412\nb L.414\nL.413:\nadd.s $f28,$f26,$f30\ncvt.d.s $f18,$f30\nl.d $f16,L.416\ndiv.d $f18,$f18,$f16\ncvt.s.d $f30,$f18\nL.414:\nc.eq.s $f28,$f26; bc1f L.413\nl.d $f18,L.417\ncvt.d.s $f16,$f30\nmul.d $f18,$f18,$f16\ncvt.s.d $f18,$f18\ns.s $f18,28($30)\nl.d $f22,L.418\nl.s $f30,L.411\nl.d $f24,L.419\nb L.421\nL.420:\ncvt.d.s $f18,$f30\nadd.d $f24,$f22,$f18\nl.d $f16,L.416\ndiv.d $f18,$f18,$f16\ncvt.s.d $f30,$f18\nL.421:\nc.eq.d $f24,$f22; bc1f L.420\nl.d $f18,L.417\ncvt.d.s $f16,$f30\nmul.d $f18,$f18,$f16\ncvt.s.d $f18,$f18\ns.s $f18,32($30)\nlw $24,40($30)\nbeq $24,$0,L.423\nla $4,L.403\nlw $5,($30)\nla $6,L.425\njal printf\nla $4,L.403\nlw $5,4($30)\nla $6,L.426\njal printf\nla $4,L.403\nlw $5,8($30)\nla $6,L.427\njal printf\nla $4,L.403\nlw $5,12($30)\nla $6,L.428\njal printf\nla $4,L.403\nlw $5,16($30)\nla $6,L.429\njal printf\nla $4,L.403\nlw $5,20($30)\nla $6,L.430\njal printf\nla $4,L.403\nlw $5,24($30)\nla $6,L.431\njal printf\nla $4,L.404\nl.s $f18,28($30)\ncvt.d.s $f18,$f18\nmfc1.d $6,$f18\nla $24,L.430\nsw $24,16($sp)\njal printf\nla $4,L.404\nl.s $f18,32($30)\ncvt.d.s $f18,$f18\nmfc1.d $6,$f18\nla $24,L.431\nsw $24,16($sp)\njal printf\nL.423:\nmove $2,$0\nL.401:\nl.d $f22,24($sp)\nl.d $f24,32($sp)\nl.d $f26,40($sp)\nl.d $f28,48($sp)\nl.d $f30,56($sp)\nlw $20,64($sp)\nlw $21,68($sp)\nlw $22,72($sp)\nlw $23,76($sp)\nlw $25,80($sp)\nlw $30,84($sp)\nlw $31,88($sp)\naddu $sp,$sp,96\nj $31\n.end s26\n.data\n.align 0\nL.433:\n.byte 115\n.byte 52\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.sdata\n.align 0\nL.434:\n.byte 115\n.byte 52\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s4\n.text\n.text\n.align 2\n.ent s4\ns4:\n.frame $sp,72,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-72\n.mask 0xc2fc0000,-24\nsw $18,16($sp)\nsw $19,20($sp)\nsw $20,24($sp)\nsw $21,28($sp)\nsw $22,32($sp)\nsw $23,36($sp)\n.cprestore 40\nsw $30,44($sp)\nsw $31,48($sp)\nmove $30,$4\nmove $18,$0\nla $20,L.434\nla $19,60($30)\nL.435:\nL.436:\nmove $24,$19\nla $19,1($24)\nmove $15,$20\nla $20,1($15)\nlb $15,($15)\nsb $15,($24)\nsll $24,$15,8*(4-1); sra $24,$24,8*(4-1)\nbne $24,$0,L.435\nmove $23,$0\nL.438:\nmove $4,$23\njal svtest\nmove $24,$2\nsw $24,-16+72($sp)\njal zero\nlw $15,-16+72($sp)\nbeq $15,$2,L.442\nla $18,1\nlw $24,44($30)\nbeq $24,$0,L.444\nla $4,L.433\nla $5,1\njal printf\nL.444:\nL.442:\nL.439:\nla $23,1($23)\nla $24,3\nblt $23,$24,L.438\njal setev\njal testev\nbeq $2,$0,L.446\nla $18,2($18)\nlw $24,44($30)\nbeq $24,$0,L.448\nla $4,L.433\nla $5,2\njal printf\nL.448:\nL.446:\nb L.450\nla $18,4($18)\nlw $24,44($30)\nbeq $24,$0,L.452\nla $4,L.433\nla $5,4\njal printf\nL.452:\nL.450:\nla $22,0xffffffff\nla $21,1\nmove $23,$0\nb L.457\nL.454:\nand $21,$21,$22\nsrl $22,$22,1\nL.455:\nla $23,1($23)\nL.457:\nmove $24,$23\nlw $15,($30)\nsll $15,$15,2\nbltu $24,$15,L.454\nla $24,1\nbne $21,$24,L.460\nbeq $22,$0,L.458\nL.460:\nla $18,8($18)\nlw $24,44($30)\nbeq $24,$0,L.461\nla $4,L.433\nla $5,8\njal printf\nL.461:\nL.458:\nmove $2,$18\nL.432:\nlw $18,16($sp)\nlw $19,20($sp)\nlw $20,24($sp)\nlw $21,28($sp)\nlw $22,32($sp)\nlw $23,36($sp)\nlw $25,40($sp)\nlw $30,44($sp)\nlw $31,48($sp)\naddu $sp,$sp,72\nj $31\n.end s4\n.lcomm L.464,4\n.globl svtest\n.text\n.text\n.align 2\n.ent svtest\nsvtest:\n.frame $sp,8,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-8\nbeq $4,$0,L.467\nla $24,1\nbeq $4,$24,L.468\nla $24,2\nbeq $4,$24,L.471\nb L.465\nL.467:\nla $24,1978\nsw $24,L.464\nsw $0,-4+8($sp)\nb L.466\nL.468:\nlw $24,L.464\nla $15,1978\nbeq $24,$15,L.469\nla $24,1\nsw $24,-4+8($sp)\nb L.466\nL.469:\nla $24,1929\nsw $24,L.464\nsw $0,-4+8($sp)\nb L.466\nL.471:\nlw $24,L.464\nla $15,1929\nbeq $24,$15,L.472\nla $24,1\nsw $24,-4+8($sp)\nb L.466\nL.472:\nsw $0,-4+8($sp)\nL.465:\nL.466:\nlw $2,-4+8($sp)\nL.463:\naddu $sp,$sp,8\nj $31\n.end svtest\n.lcomm L.475,4\n.globl zero\n.text\n.text\n.align 2\n.ent zero\nzero:\n.frame $sp,8,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-8\nla $24,2\nsw $24,L.475\nsw $0,-4+8($sp)\nlw $2,-4+8($sp)\nL.474:\naddu $sp,$sp,8\nj $31\n.end zero\n.globl testev\n.text\n.align 2\n.ent testev\ntestev:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nlw $24,extvar\nla $15,1066\nbeq $24,$15,L.477\nla $2,1\nb L.476\nL.477:\nmove $2,$0\nL.476:\nj $31\n.end testev\n.data\n.align 0\nL.480:\n.byte 115\n.byte 54\n.byte 49\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.sdata\n.align 0\nL.481:\n.byte 115\n.byte 54\n.byte 49\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.data\n.align 0\nL.482:\n.byte 65\n.byte 66\n.byte 67\n.byte 68\n.byte 69\n.byte 70\n.byte 71\n.byte 72\n.byte 73\n.byte 74\n.byte 75\n.byte 76\n.byte 77\n.byte 78\n.byte 79\n.byte 80\n.byte 81\n.byte 82\n.byte 83\n.byte 84\n.byte 85\n.byte 86\n.byte 87\n.byte 88\n.byte 89\n.byte 90\n.byte 0\n.data\n.align 0\nL.483:\n.byte 97\n.byte 98\n.byte 99\n.byte 100\n.byte 101\n.byte 102\n.byte 103\n.byte 104\n.byte 105\n.byte 106\n.byte 107\n.byte 108\n.byte 109\n.byte 110\n.byte 111\n.byte 112\n.byte 113\n.byte 114\n.byte 115\n.byte 116\n.byte 117\n.byte 118\n.byte 119\n.byte 120\n.byte 121\n.byte 122\n.byte 0\n.data\n.align 0\nL.484:\n.byte 48\n.byte 49\n.byte 50\n.byte 51\n.byte 52\n.byte 53\n.byte 54\n.byte 55\n.byte 56\n.byte 57\n.byte 0\n.data\n.align 0\nL.485:\n.byte 126\n.byte 33\n.byte 34\n.byte 35\n.byte 37\n.byte 38\n.byte 40\n.byte 41\n.byte 95\n.byte 61\n.byte 45\n.byte 94\n.byte 124\n.byte 123\n.byte 125\n.byte 91\n.byte 93\n.byte 43\n.byte 59\n.byte 42\n.byte 58\n.byte 60\n.byte 62\n.byte 44\n.byte 46\n.byte 63\n.byte 47\n.byte 0\n.data\n.align 0\nL.486:\n.byte 10\n.byte 9\n.byte 8\n.byte 13\n.byte 12\n.byte 92\n.byte 39\n.byte 0\n.data\n.align 0\nL.487:\n.byte 32\n.byte 0\n.byte 0\n.globl s61\n.text\n.text\n.align 2\n.ent s61\ns61:\n.frame $sp,88,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-88\n.mask 0xc2fe0000,-36\nsw $17,16($sp)\nsw $18,20($sp)\nsw $19,24($sp)\nsw $20,28($sp)\nsw $21,32($sp)\nsw $22,36($sp)\nsw $23,40($sp)\n.cprestore 44\nsw $30,48($sp)\nsw $31,52($sp)\nsw $4,88($sp)\nla $22,L.481\nlw $24,0+88($sp)\nla $21,60($24)\nmove $19,$0\nL.488:\nL.489:\nmove $24,$21\nla $21,1($24)\nmove $15,$22\nla $22,1($15)\nlb $15,($15)\nsb $15,($24)\nsll $24,$15,8*(4-1); sra $24,$24,8*(4-1)\nbne $24,$0,L.488\nla $24,-19\nsh $24,-26+88($sp)\nlh $24,-26+88($sp)\nsw $24,-32+88($sp)\nlw $24,-32+88($sp)\nla $15,-19\nbeq $24,$15,L.491\nla $19,1($19)\nlw $24,0+88($sp)\nlw $24,44($24)\nbeq $24,$0,L.493\nla $4,L.480\nla $5,1\njal printf\nL.493:\nL.491:\nla $24,L.482\nsw $24,-24+88($sp)\nla $24,L.483\nsw $24,-20+88($sp)\nla $24,L.484\nsw $24,-16+88($sp)\nla $24,L.485\nsw $24,-12+88($sp)\nla $24,L.486\nsw $24,-8+88($sp)\nla $24,L.487\nsw $24,-4+88($sp)\nmove $23,$0\nmove $30,$0\nb L.505\nL.504:\nsll $24,$30,2\nla $15,-24+88($sp)\naddu $24,$24,$15\nlw $15,($24)\nla $14,1($15)\nsw $14,($24)\nlb $24,($15)\nbge $24,$0,L.507\nla $23,1\nL.507:\nL.505:\nsll $24,$30,2\nla $15,-24+88($sp)\naddu $24,$24,$15\nlw $24,($24)\nlb $24,($24)\nbne $24,$0,L.504\nL.501:\nla $30,1($30)\nla $24,6\nblt $30,$24,L.505\nbeq $23,$0,L.509\nla $19,2($19)\nlw $24,0+88($sp)\nlw $24,44($24)\nbeq $24,$0,L.511\nla $4,L.480\nla $5,2\njal printf\nL.511:\nL.509:\nla $20,1048579\nmove $18,$20\nmove $17,$20\nsll $24,$18,8*(4-2); sra $24,$24,8*(4-2)\nbeq $24,$20,L.516\nla $15,3\nbne $24,$15,L.515\nL.516:\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nbeq $24,$20,L.513\nla $15,3\nbeq $24,$15,L.513\nL.515:\nla $19,8($19)\nlw $24,0+88($sp)\nlw $24,44($24)\nbeq $24,$0,L.517\nla $4,L.480\nla $5,8\njal printf\nL.517:\nL.513:\nmove $2,$19\nL.479:\nlw $17,16($sp)\nlw $18,20($sp)\nlw $19,24($sp)\nlw $20,28($sp)\nlw $21,32($sp)\nlw $22,36($sp)\nlw $23,40($sp)\nlw $25,44($sp)\nlw $30,48($sp)\nlw $31,52($sp)\naddu $sp,$sp,88\nj $31\n.end s61\n.data\n.align 0\nL.520:\n.byte 115\n.byte 54\n.byte 50\n.byte 54\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.sdata\n.align 0\nL.521:\n.byte 115\n.byte 54\n.byte 50\n.byte 54\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s626\n.text\n.text\n.align 2\n.ent s626\ns626:\n.frame $sp,152,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-152\n.fmask 0xff000000,-112\n.mask 0xc2ff0000,-64\ns.d $f24,16($sp)\ns.d $f26,24($sp)\ns.d $f28,32($sp)\ns.d $f30,40($sp)\nsw $16,48($sp)\nsw $17,52($sp)\nsw $18,56($sp)\nsw $19,60($sp)\nsw $20,64($sp)\nsw $21,68($sp)\nsw $22,72($sp)\nsw $23,76($sp)\n.cprestore 80\nsw $30,84($sp)\nsw $31,88($sp)\nmove $30,$4\nla $20,L.521\nla $19,60($30)\nsw $0,-52+152($sp)\nL.522:\nL.523:\nmove $24,$19\nla $19,1($24)\nmove $15,$20\nla $20,1($15)\nlb $15,($15)\nsb $15,($24)\nsll $24,$15,8*(4-1); sra $24,$24,8*(4-1)\nbne $24,$0,L.522\nl.s $f30,L.411\nla $24,1\nmove $18,$24\nmove $22,$24\nmove $23,$0\nb L.528\nL.525:\nl.s $f18,L.529\nmul.s $f30,$f18,$f30\nsll $24,$22,1\nor $22,$24,$18\nL.526:\nla $23,1($23)\nL.528:\nlw $24,12($30)\nsubu $24,$24,2\nblt $23,$24,L.525\nmtc1 $22,$f18; cvt.s.w $f18,$f18\ns.s $f18,-60+152($sp)\nl.s $f18,-60+152($sp)\nsub.s $f18,$f30,$f18\ndiv.s $f30,$f18,$f30\ncvt.d.s $f18,$f30\nl.d $f16,L.416\nl.s $f10,28($30)\ncvt.d.s $f10,$f10\nmul.d $f16,$f16,$f10\nc.le.d $f18,$f16; bc1t L.530\nlw $24,-52+152($sp)\nla $24,2($24)\nsw $24,-52+152($sp)\nlw $24,44($30)\nbeq $24,$0,L.532\nla $4,L.520\nla $5,2\njal printf\nL.532:\nL.530:\nla $16,125\nla $24,125\nsh $24,-30+152($sp)\nla $24,125\nsw $24,-36+152($sp)\nla $24,15625\nsw $24,-44+152($sp)\nla $24,125\nsw $24,-40+152($sp)\nla $24,15625\nsw $24,-48+152($sp)\nla $17,125\nla $24,15625\nsw $24,-56+152($sp)\nl.s $f26,L.534\nl.d $f24,L.535\nl.d $f28,L.536\nmove $23,$0\nL.537:\nla $24,-28+152($sp)\naddu $24,$23,$24\nsb $0,($24)\nL.538:\nla $23,1($23)\nla $24,28\nblt $23,$24,L.537\nsll $24,$16,8*(4-1); sra $24,$24,8*(4-1)\nmul $24,$24,$24\nlw $15,-44+152($sp)\nbeq $24,$15,L.541\nla $24,1\nsb $24,-28+152($sp)\nL.541:\nlh $24,-30+152($sp)\nsll $15,$16,8*(4-1); sra $15,$15,8*(4-1)\nmul $24,$24,$15\nlw $15,-44+152($sp)\nbeq $24,$15,L.543\nla $24,1\nsb $24,-27+152($sp)\nL.543:\nlh $24,-30+152($sp)\nmul $24,$24,$24\nlw $15,-44+152($sp)\nbeq $24,$15,L.546\nla $24,1\nsb $24,-26+152($sp)\nL.546:\nlw $24,-36+152($sp)\nsll $15,$16,8*(4-1); sra $15,$15,8*(4-1)\nmul $24,$24,$15\nlw $15,-44+152($sp)\nbeq $24,$15,L.549\nla $24,1\nsb $24,-25+152($sp)\nL.549:\nlw $24,-36+152($sp)\nlh $15,-30+152($sp)\nmul $24,$24,$15\nlw $15,-44+152($sp)\nbeq $24,$15,L.552\nla $24,1\nsb $24,-24+152($sp)\nL.552:\nlw $24,-36+152($sp)\nmul $24,$24,$24\nlw $15,-44+152($sp)\nbeq $24,$15,L.555\nla $24,1\nsb $24,-23+152($sp)\nL.555:\nlw $24,-40+152($sp)\nsll $15,$16,8*(4-1); sra $15,$15,8*(4-1)\nmul $24,$24,$15\nlw $15,-48+152($sp)\nbeq $24,$15,L.558\nla $24,1\nsb $24,-22+152($sp)\nL.558:\nlw $24,-40+152($sp)\nlh $15,-30+152($sp)\nmul $24,$24,$15\nlw $15,-48+152($sp)\nbeq $24,$15,L.561\nla $24,1\nsb $24,-21+152($sp)\nL.561:\nlw $24,-40+152($sp)\nlw $15,-36+152($sp)\nmul $24,$24,$15\nlw $15,-48+152($sp)\nbeq $24,$15,L.564\nla $24,1\nsb $24,-20+152($sp)\nL.564:\nlw $24,-40+152($sp)\nmul $24,$24,$24\nlw $15,-48+152($sp)\nbeq $24,$15,L.567\nla $24,1\nsb $24,-19+152($sp)\nL.567:\nsll $24,$16,8*(4-1); sra $24,$24,8*(4-1)\nmul $24,$17,$24\nlw $15,-56+152($sp)\nbeq $24,$15,L.570\nla $24,1\nsb $24,-18+152($sp)\nL.570:\nlh $24,-30+152($sp)\nmul $24,$17,$24\nlw $15,-56+152($sp)\nbeq $24,$15,L.573\nla $24,1\nsb $24,-17+152($sp)\nL.573:\nlw $24,-36+152($sp)\nmul $24,$17,$24\nlw $15,-56+152($sp)\nbeq $24,$15,L.576\nla $24,1\nsb $24,-16+152($sp)\nL.576:\nmove $24,$17\nlw $15,-40+152($sp)\nmul $24,$24,$15\nlw $15,-48+152($sp)\nbeq $24,$15,L.579\nla $24,1\nsb $24,-15+152($sp)\nL.579:\nmul $24,$17,$17\nlw $15,-56+152($sp)\nbeq $24,$15,L.582\nla $24,1\nsb $24,-14+152($sp)\nL.582:\nsll $24,$16,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\nmul.s $f18,$f26,$f18\ncvt.d.s $f18,$f18\nc.eq.d $f18,$f28; bc1t L.585\nla $24,1\nsb $24,-13+152($sp)\nL.585:\nlh $24,-30+152($sp)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\nmul.s $f18,$f26,$f18\ncvt.d.s $f18,$f18\nc.eq.d $f18,$f28; bc1t L.588\nla $24,1\nsb $24,-12+152($sp)\nL.588:\nlw $24,-36+152($sp)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\nmul.s $f18,$f26,$f18\ncvt.d.s $f18,$f18\nc.eq.d $f18,$f28; bc1t L.591\nla $24,1\nsb $24,-11+152($sp)\nL.591:\nlw $24,-40+152($sp)\nl.d $f18,L.596\nsrl $15,$24,1\nmtc1 $15,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$24,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f18,$f18,$f16\ncvt.s.d $f18,$f18\nmul.s $f18,$f26,$f18\ncvt.d.s $f18,$f18\nc.eq.d $f18,$f28; bc1t L.594\nla $24,1\nsb $24,-10+152($sp)\nL.594:\nmtc1 $17,$f18; cvt.s.w $f18,$f18\nmul.s $f18,$f26,$f18\ncvt.d.s $f18,$f18\nc.eq.d $f18,$f28; bc1t L.598\nla $24,1\nsb $24,-9+152($sp)\nL.598:\nmul.s $f18,$f26,$f26\ncvt.d.s $f18,$f18\nc.eq.d $f18,$f28; bc1t L.601\nla $24,1\nsb $24,-8+152($sp)\nL.601:\nsll $24,$16,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\nmul.d $f18,$f24,$f18\nc.eq.d $f18,$f28; bc1t L.604\nla $24,1\nsb $24,-7+152($sp)\nL.604:\nlh $24,-30+152($sp)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\nmul.d $f18,$f24,$f18\nc.eq.d $f18,$f28; bc1t L.607\nla $24,1\nsb $24,-6+152($sp)\nL.607:\nlw $24,-36+152($sp)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\nmul.d $f18,$f24,$f18\nc.eq.d $f18,$f28; bc1t L.610\nla $24,1\nsb $24,-5+152($sp)\nL.610:\nlw $24,-40+152($sp)\nl.d $f18,L.596\nsrl $15,$24,1\nmtc1 $15,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$24,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f18,$f18,$f16\nmul.d $f18,$f24,$f18\nc.eq.d $f18,$f28; bc1t L.613\nla $24,1\nsb $24,-4+152($sp)\nL.613:\nmtc1 $17,$f18; cvt.d.w $f18,$f18\nmul.d $f18,$f24,$f18\nc.eq.d $f18,$f28; bc1t L.616\nla $24,1\nsb $24,-3+152($sp)\nL.616:\ncvt.d.s $f18,$f26\nmul.d $f18,$f24,$f18\nc.eq.d $f18,$f28; bc1t L.619\nla $24,1\nsb $24,-2+152($sp)\nL.619:\nmul.d $f18,$f24,$f24\nc.eq.d $f18,$f28; bc1t L.622\nla $24,1\nsb $24,-1+152($sp)\nL.622:\nmove $21,$0\nmove $23,$0\nL.625:\nsll $24,$21,8*(4-1); sra $24,$24,8*(4-1)\nla $15,-28+152($sp)\naddu $15,$23,$15\nlb $15,($15)\naddu $24,$24,$15\nmove $21,$24\nL.626:\nla $23,1($23)\nla $24,28\nblt $23,$24,L.625\nsll $24,$21,8*(4-1); sra $24,$24,8*(4-1)\nbeq $24,$0,L.629\nlw $24,-52+152($sp)\nla $24,4($24)\nsw $24,-52+152($sp)\nlw $24,44($30)\nbeq $24,$0,L.631\nla $4,L.520\nla $5,4\njal printf\nla $4,L.633\njal printf\nmove $23,$0\nL.634:\nla $4,L.638\nla $24,-28+152($sp)\naddu $24,$23,$24\nlb $5,($24)\njal printf\nL.635:\nla $23,1($23)\nla $24,28\nblt $23,$24,L.634\nla $4,L.639\njal printf\nL.631:\nL.629:\nla $17,32768\nmove $24,$17\nla $15,0x8000\nbleu $24,$15,L.640\nlw $24,-52+152($sp)\nla $24,8($24)\nsw $24,-52+152($sp)\nlw $24,44($30)\nbeq $24,$0,L.642\nla $4,L.520\nla $5,8\njal printf\nL.642:\nL.640:\nlw $2,-52+152($sp)\nL.519:\nl.d $f24,16($sp)\nl.d $f26,24($sp)\nl.d $f28,32($sp)\nl.d $f30,40($sp)\nlw $16,48($sp)\nlw $17,52($sp)\nlw $18,56($sp)\nlw $19,60($sp)\nlw $20,64($sp)\nlw $21,68($sp)\nlw $22,72($sp)\nlw $23,76($sp)\nlw $25,80($sp)\nlw $30,84($sp)\nlw $31,88($sp)\naddu $sp,$sp,152\nj $31\n.end s626\n.data\n.align 0\nL.645:\n.byte 115\n.byte 55\n.byte 49\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.sdata\n.align 0\nL.646:\n.byte 115\n.byte 55\n.byte 49\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.sdata\n.align 0\nL.647:\n.byte 0x71\n.globl s71\n.text\n.text\n.align 2\n.ent s71\ns71:\n.frame $sp,96,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-96\n.mask 0xc2f00000,-56\nsw $20,16($sp)\nsw $21,20($sp)\nsw $22,24($sp)\nsw $23,28($sp)\n.cprestore 32\nsw $30,36($sp)\nsw $31,40($sp)\nmove $30,$4\nla $23,L.646\nla $22,60($30)\nmove $21,$0\nL.648:\nL.649:\nmove $24,$22\nla $22,1($24)\nmove $15,$23\nla $23,1($15)\nlb $15,($15)\nsb $15,($24)\nsll $24,$15,8*(4-1); sra $24,$24,8*(4-1)\nbne $24,$0,L.648\nlb $24,L.653\nlb $15,L.647\nbeq $24,$15,L.651\nla $21,1($21)\nlw $24,44($30)\nbeq $24,$0,L.654\nla $4,L.645\nla $5,1\njal printf\nL.654:\nL.651:\nb L.656\nla $21,2($21)\nlw $24,44($30)\nbeq $24,$0,L.658\nla $4,L.645\nla $5,2\njal printf\nL.658:\nL.656:\nla $24,1942\nsw $24,-20+96($sp)\nlw $24,-20+96($sp)\nla $15,1942\nbne $24,$15,L.666\nlw $24,-20+96($sp)\nlw $15,-20+96($sp)\nbeq $24,$15,L.661\nL.666:\nla $21,4($21)\nlw $24,44($30)\nbeq $24,$0,L.667\nla $4,L.645\nla $5,4\njal printf\nL.667:\nL.661:\nla $4,-5\njal McCarthy\nla $15,91\nbeq $2,$15,L.669\nla $21,8($21)\nlw $24,44($30)\nbeq $24,$0,L.671\nla $4,L.645\nla $5,8\njal printf\nL.671:\nL.669:\nla $20,2\nla $24,3\nsw $24,-44+96($sp)\nla $24,-44+96($sp)\nsw $24,-48+96($sp)\nmove $4,$20\nlw $5,-48+96($sp)\njal clobber\nla $24,2\nbne $20,$24,L.675\nlw $15,-44+96($sp)\nbeq $15,$24,L.673\nL.675:\nla $21,16($21)\nlw $24,44($30)\nbeq $24,$0,L.676\nla $4,L.645\nla $5,16\njal printf\nL.676:\nL.673:\nl.s $f18,32($30)\nc.eq.s $f18,$f18; bc1t L.678\nla $21,32($21)\nlw $24,44($30)\nbeq $24,$0,L.680\nla $4,L.645\nla $5,32\njal printf\nL.680:\nL.678:\nmove $2,$21\nL.644:\nlw $20,16($sp)\nlw $21,20($sp)\nlw $22,24($sp)\nlw $23,28($sp)\nlw $25,32($sp)\nlw $30,36($sp)\nlw $31,40($sp)\naddu $sp,$sp,96\nj $31\n.end s71\n.globl McCarthy\n.text\n.align 2\n.ent McCarthy\nMcCarthy:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nsw $4,24($sp)\nlw $24,0+24($sp)\nla $15,100\nble $24,$15,L.683\nlw $24,0+24($sp)\nsubu $2,$24,10\nb L.682\nL.683:\nlw $24,0+24($sp)\nla $4,11($24)\njal McCarthy\nmove $24,$2\nmove $4,$24\njal McCarthy\nmove $24,$2\nL.682:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end McCarthy\n.globl clobber\n.text\n.align 2\n.ent clobber\nclobber:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nla $4,3\nla $24,2\nsw $24,($5)\nmove $2,$0\nL.685:\nj $31\n.end clobber\n.data\n.align 0\nL.687:\n.byte 76\n.byte 111\n.byte 99\n.byte 97\n.byte 108\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 37\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.data\n.align 0\nL.688:\n.byte 115\n.byte 55\n.byte 49\n.byte 52\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.sdata\n.align 0\nL.689:\n.byte 115\n.byte 55\n.byte 49\n.byte 52\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s714\n.text\n.text\n.align 2\n.ent s714\ns714:\n.frame $sp,160,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-160\n.fmask 0xff000000,-120\n.mask 0xc2ff0000,-72\ns.d $f24,16($sp)\ns.d $f26,24($sp)\ns.d $f28,32($sp)\ns.d $f30,40($sp)\nsw $16,48($sp)\nsw $17,52($sp)\nsw $18,56($sp)\nsw $19,60($sp)\nsw $20,64($sp)\nsw $21,68($sp)\nsw $22,72($sp)\nsw $23,76($sp)\n.cprestore 80\nsw $30,84($sp)\nsw $31,88($sp)\nsw $4,160($sp)\nla $24,L.689\nsw $24,-16+160($sp)\nlw $24,0+160($sp)\nla $15,60($24)\nsw $15,-20+160($sp)\nsw $0,-24+160($sp)\nmove $23,$0\nlw $30,48($24)\nL.690:\nL.691:\nlw $24,-20+160($sp)\nla $15,1($24)\nsw $15,-20+160($sp)\nlw $15,-16+160($sp)\nla $14,1($15)\nsw $14,-16+160($sp)\nlb $15,($15)\nsb $15,($24)\nsll $24,$15,8*(4-1); sra $24,$24,8*(4-1)\nbne $24,$0,L.690\nla $22,5\nla $17,2\nmove $22,$17\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,2\nbeq $24,$15,L.693\nla $23,1\nbeq $30,$0,L.695\nla $4,L.687\nmove $5,$23\njal printf\nL.695:\nL.693:\nla $22,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,2\nbeq $24,$15,L.697\nla $23,2\nbeq $30,$0,L.699\nla $4,L.687\nmove $5,$23\njal printf\nL.699:\nL.697:\nla $22,5\nla $24,2\nsw $24,-4+160($sp)\nlw $15,-4+160($sp)\nmove $22,$15\nsll $15,$22,8*(4-1); sra $15,$15,8*(4-1)\nbeq $15,$24,L.701\nla $23,3\nbeq $30,$0,L.703\nla $4,L.687\nmove $5,$23\njal printf\nL.703:\nL.701:\nla $22,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,2\nbeq $24,$15,L.705\nla $23,4\nbeq $30,$0,L.707\nla $4,L.687\nmove $5,$23\njal printf\nL.707:\nL.705:\nla $22,5\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,2\nbeq $24,$15,L.709\nla $23,5\nbeq $30,$0,L.711\nla $4,L.687\nmove $5,$23\njal printf\nL.711:\nL.709:\nla $22,5\nl.s $f26,L.529\ntrunc.w.s $f2,$f26,$24; mfc1 $24,$f2\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,2\nbeq $24,$15,L.713\nla $23,6\nbeq $30,$0,L.715\nla $4,L.687\nmove $5,$23\njal printf\nL.715:\nL.713:\nla $22,5\nl.d $f24,L.416\ntrunc.w.d $f2,$f24,$24; mfc1 $24,$f2\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,2\nbeq $24,$15,L.717\nla $23,7\nbeq $30,$0,L.719\nla $4,L.687\nmove $5,$23\njal printf\nL.719:\nL.717:\nla $21,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,2\nbeq $24,$15,L.721\nla $23,8\nbeq $30,$0,L.723\nla $4,L.687\nmove $5,$23\njal printf\nL.723:\nL.721:\nla $21,5\nla $16,2\nmove $21,$16\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,2\nbeq $24,$15,L.725\nla $23,9\nbeq $30,$0,L.727\nla $4,L.687\nmove $5,$23\njal printf\nL.727:\nL.725:\nla $21,5\nla $24,2\nsw $24,-4+160($sp)\nlw $15,-4+160($sp)\nmove $21,$15\nsll $15,$21,8*(4-2); sra $15,$15,8*(4-2)\nbeq $15,$24,L.729\nla $23,10\nbeq $30,$0,L.731\nla $4,L.687\nmove $5,$23\njal printf\nL.731:\nL.729:\nla $21,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,2\nbeq $24,$15,L.733\nla $23,11\nbeq $30,$0,L.735\nla $4,L.687\nmove $5,$23\njal printf\nL.735:\nL.733:\nla $21,5\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,2\nbeq $24,$15,L.737\nla $23,12\nbeq $30,$0,L.739\nla $4,L.687\nmove $5,$23\njal printf\nL.739:\nL.737:\nla $21,5\nl.s $f26,L.529\ntrunc.w.s $f2,$f26,$24; mfc1 $24,$f2\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,2\nbeq $24,$15,L.741\nla $23,13\nbeq $30,$0,L.743\nla $4,L.687\nmove $5,$23\njal printf\nL.743:\nL.741:\nla $21,5\nl.d $f24,L.416\ntrunc.w.d $f2,$f24,$24; mfc1 $24,$f2\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,2\nbeq $24,$15,L.745\nla $23,14\nbeq $30,$0,L.747\nla $4,L.687\nmove $5,$23\njal printf\nL.747:\nL.745:\nla $20,5\nla $17,2\nsll $20,$17,8*(4-1); sra $20,$20,8*(4-1)\nla $24,2\nbeq $20,$24,L.749\nla $23,15\nbeq $30,$0,L.751\nla $4,L.687\nmove $5,$23\njal printf\nL.751:\nL.749:\nla $20,5\nla $16,2\nsll $20,$16,8*(4-2); sra $20,$20,8*(4-2)\nla $24,2\nbeq $20,$24,L.753\nla $23,16\nbeq $30,$0,L.755\nla $4,L.687\nmove $5,$23\njal printf\nL.755:\nL.753:\nla $20,5\nla $24,2\nsw $24,-4+160($sp)\nlw $20,-4+160($sp)\nbeq $20,$24,L.757\nla $23,17\nbeq $30,$0,L.759\nla $4,L.687\nmove $5,$23\njal printf\nL.759:\nL.757:\nla $20,5\nla $24,2\nsw $24,-8+160($sp)\nlw $20,-8+160($sp)\nla $24,2\nbeq $20,$24,L.761\nla $23,18\nbeq $30,$0,L.763\nla $4,L.687\nmove $5,$23\njal printf\nL.763:\nL.761:\nla $20,5\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nmove $20,$24\nla $24,2\nbeq $20,$24,L.765\nla $23,19\nbeq $30,$0,L.767\nla $4,L.687\nmove $5,$23\njal printf\nL.767:\nL.765:\nla $20,5\nl.s $f26,L.529\ntrunc.w.s $f2,$f26,$20; mfc1 $20,$f2\nla $24,2\nbeq $20,$24,L.769\nla $23,20\nbeq $30,$0,L.771\nla $4,L.687\nmove $5,$23\njal printf\nL.771:\nL.769:\nla $20,5\nl.d $f24,L.416\ntrunc.w.d $f2,$f24,$20; mfc1 $20,$f2\nla $24,2\nbeq $20,$24,L.773\nla $23,21\nbeq $30,$0,L.775\nla $4,L.687\nmove $5,$23\njal printf\nL.775:\nL.773:\nla $19,5\nla $17,2\nsll $19,$17,8*(4-1); sra $19,$19,8*(4-1)\nla $24,2\nbeq $19,$24,L.777\nla $23,22\nbeq $30,$0,L.779\nla $4,L.687\nmove $5,$23\njal printf\nL.779:\nL.777:\nla $19,5\nla $16,2\nsll $19,$16,8*(4-2); sra $19,$19,8*(4-2)\nla $24,2\nbeq $19,$24,L.781\nla $23,23\nbeq $30,$0,L.783\nla $4,L.687\nmove $5,$23\njal printf\nL.783:\nL.781:\nla $19,5\nla $24,2\nsw $24,-4+160($sp)\nlw $19,-4+160($sp)\nla $24,2\nbeq $19,$24,L.785\nla $23,24\nbeq $30,$0,L.787\nla $4,L.687\nmove $5,$23\njal printf\nL.787:\nL.785:\nla $19,5\nla $24,2\nsw $24,-8+160($sp)\nlw $19,-8+160($sp)\nbeq $19,$24,L.789\nla $23,25\nbeq $30,$0,L.791\nla $4,L.687\nmove $5,$23\njal printf\nL.791:\nL.789:\nla $19,5\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nmove $19,$24\nla $24,2\nbeq $19,$24,L.793\nla $23,26\nbeq $30,$0,L.795\nla $4,L.687\nmove $5,$23\njal printf\nL.795:\nL.793:\nla $19,5\nl.s $f26,L.529\ntrunc.w.s $f2,$f26,$19; mfc1 $19,$f2\nla $24,2\nbeq $19,$24,L.797\nla $23,27\nbeq $30,$0,L.799\nla $4,L.687\nmove $5,$23\njal printf\nL.799:\nL.797:\nla $19,5\nl.d $f24,L.416\ntrunc.w.d $f2,$f24,$19; mfc1 $19,$f2\nla $24,2\nbeq $19,$24,L.801\nla $23,28\nbeq $30,$0,L.803\nla $4,L.687\nmove $5,$23\njal printf\nL.803:\nL.801:\nla $18,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nmove $18,$24\nla $24,2\nbeq $18,$24,L.805\nla $23,29\nbeq $30,$0,L.807\nla $4,L.687\nmove $5,$23\njal printf\nL.807:\nL.805:\nla $18,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nmove $18,$24\nla $24,2\nbeq $18,$24,L.809\nla $23,30\nbeq $30,$0,L.811\nla $4,L.687\nmove $5,$23\njal printf\nL.811:\nL.809:\nla $18,5\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nmove $18,$24\nla $24,2\nbeq $18,$24,L.813\nla $23,31\nbeq $30,$0,L.815\nla $4,L.687\nmove $5,$23\njal printf\nL.815:\nL.813:\nla $18,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nmove $18,$24\nla $24,2\nbeq $18,$24,L.817\nla $23,32\nbeq $30,$0,L.819\nla $4,L.687\nmove $5,$23\njal printf\nL.819:\nL.817:\nla $18,5\nla $24,2\nsw $24,-12+160($sp)\nlw $18,-12+160($sp)\nbeq $18,$24,L.821\nla $23,33\nbeq $30,$0,L.823\nla $4,L.687\nmove $5,$23\njal printf\nL.823:\nL.821:\nla $18,5\nl.s $f26,L.529\nl.s $f18,L.828\nc.lt.s $f26,$f18; bc1t L.826\nsub.s $f18,$f26,$f18\ntrunc.w.s $f2,$f18,$24; mfc1 $24,$f2\nla $24,0x80000000($24)\nsw $24,-28+160($sp)\nb L.827\nL.826:\ntrunc.w.s $f2,$f26,$24; mfc1 $24,$f2\nsw $24,-28+160($sp)\nL.827:\nlw $18,-28+160($sp)\nla $24,2\nbeq $18,$24,L.829\nla $23,34\nbeq $30,$0,L.831\nla $4,L.687\nmove $5,$23\njal printf\nL.831:\nL.829:\nla $18,5\nl.d $f24,L.416\nl.d $f18,L.836\nc.lt.d $f24,$f18; bc1t L.834\nsub.d $f18,$f24,$f18\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nla $24,0x80000000($24)\nsw $24,-32+160($sp)\nb L.835\nL.834:\ntrunc.w.d $f2,$f24,$24; mfc1 $24,$f2\nsw $24,-32+160($sp)\nL.835:\nlw $18,-32+160($sp)\nla $24,2\nbeq $18,$24,L.837\nla $23,35\nbeq $30,$0,L.839\nla $4,L.687\nmove $5,$23\njal printf\nL.839:\nL.837:\nl.s $f30,L.841\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f30; cvt.s.w $f30,$f30\nl.s $f18,L.529\nc.eq.s $f30,$f18; bc1t L.842\nla $23,36\nbeq $30,$0,L.844\nla $4,L.687\nmove $5,$23\njal printf\nL.844:\nL.842:\nl.s $f30,L.841\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nmtc1 $24,$f30; cvt.s.w $f30,$f30\nl.s $f18,L.529\nc.eq.s $f30,$f18; bc1t L.846\nla $23,37\nbeq $30,$0,L.848\nla $4,L.687\nmove $5,$23\njal printf\nL.848:\nL.846:\nl.s $f30,L.841\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nmtc1 $24,$f30; cvt.s.w $f30,$f30\nl.s $f18,L.529\nc.eq.s $f30,$f18; bc1t L.850\nla $23,38\nbeq $30,$0,L.852\nla $4,L.687\nmove $5,$23\njal printf\nL.852:\nL.850:\nl.s $f30,L.841\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nmtc1 $24,$f30; cvt.s.w $f30,$f30\nl.s $f18,L.529\nc.eq.s $f30,$f18; bc1t L.854\nla $23,39\nbeq $30,$0,L.856\nla $4,L.687\nmove $5,$23\njal printf\nL.856:\nL.854:\nl.s $f30,L.841\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nl.d $f18,L.596\nsrl $15,$24,1\nmtc1 $15,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$24,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f18,$f18,$f16\ncvt.s.d $f30,$f18\nl.s $f18,L.529\nc.eq.s $f30,$f18; bc1t L.858\nla $23,40\nbeq $30,$0,L.860\nla $4,L.687\nmove $5,$23\njal printf\nL.860:\nL.858:\nl.s $f30,L.841\nl.s $f18,L.529\nmov.s $f26,$f18\nmov.s $f30,$f26\nc.eq.s $f30,$f18; bc1t L.862\nla $23,41\nbeq $30,$0,L.864\nla $4,L.687\nmove $5,$23\njal printf\nL.864:\nL.862:\nl.s $f30,L.841\nl.d $f24,L.416\ncvt.s.d $f30,$f24\nl.s $f18,L.529\nc.eq.s $f30,$f18; bc1t L.866\nla $23,42\nbeq $30,$0,L.868\nla $4,L.687\nmove $5,$23\njal printf\nL.868:\nL.866:\nl.d $f28,L.870\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f28; cvt.d.w $f28,$f28\nl.d $f18,L.416\nc.eq.d $f28,$f18; bc1t L.871\nla $23,43\nbeq $30,$0,L.873\nla $4,L.687\nmove $5,$23\njal printf\nL.873:\nL.871:\nl.d $f28,L.870\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nmtc1 $24,$f28; cvt.d.w $f28,$f28\nl.d $f18,L.416\nc.eq.d $f28,$f18; bc1t L.875\nla $23,44\nbeq $30,$0,L.877\nla $4,L.687\nmove $5,$23\njal printf\nL.877:\nL.875:\nl.d $f28,L.870\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nmtc1 $24,$f28; cvt.d.w $f28,$f28\nl.d $f18,L.416\nc.eq.d $f28,$f18; bc1t L.879\nla $23,45\nbeq $30,$0,L.881\nla $4,L.687\nmove $5,$23\njal printf\nL.881:\nL.879:\nl.d $f28,L.870\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nmtc1 $24,$f28; cvt.d.w $f28,$f28\nl.d $f18,L.416\nc.eq.d $f28,$f18; bc1t L.883\nla $23,46\nbeq $30,$0,L.885\nla $4,L.687\nmove $5,$23\njal printf\nL.885:\nL.883:\nl.d $f28,L.870\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nl.d $f18,L.596\nsrl $15,$24,1\nmtc1 $15,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$24,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f28,$f18,$f16\nl.d $f18,L.416\nc.eq.d $f28,$f18; bc1t L.887\nla $23,47\nbeq $30,$0,L.889\nla $4,L.687\nmove $5,$23\njal printf\nL.889:\nL.887:\nl.d $f28,L.870\nl.s $f26,L.529\ncvt.d.s $f28,$f26\nl.d $f18,L.416\nc.eq.d $f28,$f18; bc1t L.891\nla $23,48\nbeq $30,$0,L.893\nla $4,L.687\nmove $5,$23\njal printf\nL.893:\nL.891:\nl.d $f28,L.870\nl.d $f18,L.416\nmov.d $f24,$f18\nmov.d $f28,$f24\nc.eq.d $f28,$f18; bc1t L.895\nla $23,49\nbeq $30,$0,L.897\nla $4,L.687\nmove $5,$23\njal printf\nL.897:\nL.895:\nla $22,5\nla $17,2\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\naddu $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,7\nbeq $24,$15,L.899\nla $23,50\nbeq $30,$0,L.901\nla $4,L.687\nmove $5,$23\njal printf\nL.901:\nL.899:\nla $22,5\nla $16,2\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\naddu $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,7\nbeq $24,$15,L.903\nla $23,51\nbeq $30,$0,L.905\nla $4,L.687\nmove $5,$23\njal printf\nL.905:\nL.903:\nla $22,5\nla $24,2\nsw $24,-4+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-4+160($sp)\naddu $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,7\nbeq $24,$15,L.907\nla $23,52\nbeq $30,$0,L.909\nla $4,L.687\nmove $5,$23\njal printf\nL.909:\nL.907:\nla $22,5\nla $24,2\nsw $24,-8+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-8+160($sp)\naddu $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,7\nbeq $24,$15,L.911\nla $23,53\nbeq $30,$0,L.913\nla $4,L.687\nmove $5,$23\njal printf\nL.913:\nL.911:\nla $22,5\nla $24,2\nsw $24,-12+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-12+160($sp)\naddu $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,7\nbeq $24,$15,L.915\nla $23,54\nbeq $30,$0,L.917\nla $4,L.687\nmove $5,$23\njal printf\nL.917:\nL.915:\nla $22,5\nl.s $f26,L.529\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\nadd.s $f18,$f18,$f26\ntrunc.w.s $f2,$f18,$24; mfc1 $24,$f2\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,7\nbeq $24,$15,L.919\nla $23,55\nbeq $30,$0,L.921\nla $4,L.687\nmove $5,$23\njal printf\nL.921:\nL.919:\nla $22,5\nl.d $f24,L.416\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\nadd.d $f18,$f18,$f24\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,7\nbeq $24,$15,L.923\nla $23,56\nbeq $30,$0,L.925\nla $4,L.687\nmove $5,$23\njal printf\nL.925:\nL.923:\nla $21,5\nla $17,2\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\naddu $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,7\nbeq $24,$15,L.927\nla $23,57\nbeq $30,$0,L.929\nla $4,L.687\nmove $5,$23\njal printf\nL.929:\nL.927:\nla $21,5\nla $16,2\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\naddu $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,7\nbeq $24,$15,L.931\nla $23,58\nbeq $30,$0,L.933\nla $4,L.687\nmove $5,$23\njal printf\nL.933:\nL.931:\nla $21,5\nla $24,2\nsw $24,-4+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-4+160($sp)\naddu $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,7\nbeq $24,$15,L.935\nla $23,59\nbeq $30,$0,L.937\nla $4,L.687\nmove $5,$23\njal printf\nL.937:\nL.935:\nla $21,5\nla $24,2\nsw $24,-8+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-8+160($sp)\naddu $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,7\nbeq $24,$15,L.939\nla $23,60\nbeq $30,$0,L.941\nla $4,L.687\nmove $5,$23\njal printf\nL.941:\nL.939:\nla $21,5\nla $24,2\nsw $24,-12+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-12+160($sp)\naddu $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,7\nbeq $24,$15,L.943\nla $23,61\nbeq $30,$0,L.945\nla $4,L.687\nmove $5,$23\njal printf\nL.945:\nL.943:\nla $21,5\nl.s $f26,L.529\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\nadd.s $f18,$f18,$f26\ntrunc.w.s $f2,$f18,$24; mfc1 $24,$f2\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,7\nbeq $24,$15,L.947\nla $23,62\nbeq $30,$0,L.949\nla $4,L.687\nmove $5,$23\njal printf\nL.949:\nL.947:\nla $21,5\nl.d $f24,L.416\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\nadd.d $f18,$f18,$f24\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,7\nbeq $24,$15,L.951\nla $23,63\nbeq $30,$0,L.953\nla $4,L.687\nmove $5,$23\njal printf\nL.953:\nL.951:\nla $20,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\naddu $20,$20,$24\nla $24,7\nbeq $20,$24,L.955\nla $23,64\nbeq $30,$0,L.957\nla $4,L.687\nmove $5,$23\njal printf\nL.957:\nL.955:\nla $20,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\naddu $20,$20,$24\nla $24,7\nbeq $20,$24,L.959\nla $23,65\nbeq $30,$0,L.961\nla $4,L.687\nmove $5,$23\njal printf\nL.961:\nL.959:\nla $20,5\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\naddu $20,$20,$24\nla $24,7\nbeq $20,$24,L.963\nla $23,66\nbeq $30,$0,L.965\nla $4,L.687\nmove $5,$23\njal printf\nL.965:\nL.963:\nla $20,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\naddu $20,$20,$24\nla $24,7\nbeq $20,$24,L.967\nla $23,67\nbeq $30,$0,L.969\nla $4,L.687\nmove $5,$23\njal printf\nL.969:\nL.967:\nla $20,5\nla $24,2\nsw $24,-12+160($sp)\nmove $24,$20\nlw $15,-12+160($sp)\naddu $24,$24,$15\nmove $20,$24\nla $24,7\nbeq $20,$24,L.971\nla $23,68\nbeq $30,$0,L.973\nla $4,L.687\nmove $5,$23\njal printf\nL.973:\nL.971:\nla $20,5\nl.s $f26,L.529\nmtc1 $20,$f18; cvt.s.w $f18,$f18\nadd.s $f18,$f18,$f26\ntrunc.w.s $f2,$f18,$20; mfc1 $20,$f2\nla $24,7\nbeq $20,$24,L.975\nla $23,69\nbeq $30,$0,L.977\nla $4,L.687\nmove $5,$23\njal printf\nL.977:\nL.975:\nla $20,5\nl.d $f24,L.416\nmtc1 $20,$f18; cvt.d.w $f18,$f18\nadd.d $f18,$f18,$f24\ntrunc.w.d $f2,$f18,$20; mfc1 $20,$f2\nla $24,7\nbeq $20,$24,L.979\nla $23,70\nbeq $30,$0,L.981\nla $4,L.687\nmove $5,$23\njal printf\nL.981:\nL.979:\nla $19,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\naddu $19,$19,$24\nla $24,7\nbeq $19,$24,L.983\nla $23,71\nbeq $30,$0,L.985\nla $4,L.687\nmove $5,$23\njal printf\nL.985:\nL.983:\nla $19,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\naddu $19,$19,$24\nla $24,7\nbeq $19,$24,L.987\nla $23,72\nbeq $30,$0,L.989\nla $4,L.687\nmove $5,$23\njal printf\nL.989:\nL.987:\nla $19,5\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\naddu $19,$19,$24\nla $24,7\nbeq $19,$24,L.991\nla $23,73\nbeq $30,$0,L.993\nla $4,L.687\nmove $5,$23\njal printf\nL.993:\nL.991:\nla $19,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\naddu $19,$19,$24\nla $24,7\nbeq $19,$24,L.995\nla $23,74\nbeq $30,$0,L.997\nla $4,L.687\nmove $5,$23\njal printf\nL.997:\nL.995:\nla $19,5\nla $24,2\nsw $24,-12+160($sp)\nmove $24,$19\nlw $15,-12+160($sp)\naddu $24,$24,$15\nmove $19,$24\nla $24,7\nbeq $19,$24,L.999\nla $23,75\nbeq $30,$0,L.1001\nla $4,L.687\nmove $5,$23\njal printf\nL.1001:\nL.999:\nla $19,5\nl.s $f26,L.529\nmtc1 $19,$f18; cvt.s.w $f18,$f18\nadd.s $f18,$f18,$f26\ntrunc.w.s $f2,$f18,$19; mfc1 $19,$f2\nla $24,7\nbeq $19,$24,L.1003\nla $23,76\nbeq $30,$0,L.1005\nla $4,L.687\nmove $5,$23\njal printf\nL.1005:\nL.1003:\nla $19,5\nl.d $f24,L.416\nmtc1 $19,$f18; cvt.d.w $f18,$f18\nadd.d $f18,$f18,$f24\ntrunc.w.d $f2,$f18,$19; mfc1 $19,$f2\nla $24,7\nbeq $19,$24,L.1007\nla $23,77\nbeq $30,$0,L.1009\nla $4,L.687\nmove $5,$23\njal printf\nL.1009:\nL.1007:\nla $18,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\naddu $18,$18,$24\nla $24,7\nbeq $18,$24,L.1011\nla $23,78\nbeq $30,$0,L.1013\nla $4,L.687\nmove $5,$23\njal printf\nL.1013:\nL.1011:\nla $18,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\naddu $18,$18,$24\nla $24,7\nbeq $18,$24,L.1015\nla $23,79\nbeq $30,$0,L.1017\nla $4,L.687\nmove $5,$23\njal printf\nL.1017:\nL.1015:\nla $18,5\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\naddu $18,$18,$24\nla $24,7\nbeq $18,$24,L.1019\nla $23,80\nbeq $30,$0,L.1021\nla $4,L.687\nmove $5,$23\njal printf\nL.1021:\nL.1019:\nla $18,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\naddu $18,$18,$24\nla $24,7\nbeq $18,$24,L.1023\nla $23,81\nbeq $30,$0,L.1025\nla $4,L.687\nmove $5,$23\njal printf\nL.1025:\nL.1023:\nla $18,5\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\naddu $18,$18,$24\nla $24,7\nbeq $18,$24,L.1027\nla $23,82\nbeq $30,$0,L.1029\nla $4,L.687\nmove $5,$23\njal printf\nL.1029:\nL.1027:\nla $18,5\nl.s $f26,L.529\nl.d $f18,L.596\nsrl $24,$18,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$18,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f18,$f18,$f16\ncvt.s.d $f18,$f18\nadd.s $f18,$f18,$f26\nl.s $f16,L.828\nc.lt.s $f18,$f16; bc1t L.1032\nsub.s $f16,$f18,$f16\ntrunc.w.s $f2,$f16,$24; mfc1 $24,$f2\nla $24,0x80000000($24)\nsw $24,-36+160($sp)\nb L.1033\nL.1032:\ntrunc.w.s $f2,$f18,$24; mfc1 $24,$f2\nsw $24,-36+160($sp)\nL.1033:\nlw $18,-36+160($sp)\nla $24,7\nbeq $18,$24,L.1034\nla $23,83\nbeq $30,$0,L.1036\nla $4,L.687\nmove $5,$23\njal printf\nL.1036:\nL.1034:\nla $18,5\nl.d $f24,L.416\nl.d $f18,L.596\nsrl $24,$18,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$18,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f18,$f18,$f16\nadd.d $f18,$f18,$f24\nl.d $f16,L.836\nc.lt.d $f18,$f16; bc1t L.1039\nsub.d $f16,$f18,$f16\ntrunc.w.d $f2,$f16,$24; mfc1 $24,$f2\nla $24,0x80000000($24)\nsw $24,-40+160($sp)\nb L.1040\nL.1039:\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nsw $24,-40+160($sp)\nL.1040:\nlw $18,-40+160($sp)\nla $24,7\nbeq $18,$24,L.1041\nla $23,84\nbeq $30,$0,L.1043\nla $4,L.687\nmove $5,$23\njal printf\nL.1043:\nL.1041:\nl.s $f30,L.841\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\nadd.s $f30,$f30,$f18\nl.s $f18,L.1047\nc.eq.s $f30,$f18; bc1t L.1045\nla $23,85\nbeq $30,$0,L.1048\nla $4,L.687\nmove $5,$23\njal printf\nL.1048:\nL.1045:\nl.s $f30,L.841\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\nadd.s $f30,$f30,$f18\nl.s $f18,L.1047\nc.eq.s $f30,$f18; bc1t L.1050\nla $23,86\nbeq $30,$0,L.1052\nla $4,L.687\nmove $5,$23\njal printf\nL.1052:\nL.1050:\nl.s $f30,L.841\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\nadd.s $f30,$f30,$f18\nl.s $f18,L.1047\nc.eq.s $f30,$f18; bc1t L.1054\nla $23,87\nbeq $30,$0,L.1056\nla $4,L.687\nmove $5,$23\njal printf\nL.1056:\nL.1054:\nl.s $f30,L.841\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\nadd.s $f30,$f30,$f18\nl.s $f18,L.1047\nc.eq.s $f30,$f18; bc1t L.1058\nla $23,88\nbeq $30,$0,L.1060\nla $4,L.687\nmove $5,$23\njal printf\nL.1060:\nL.1058:\nl.s $f30,L.841\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nl.d $f18,L.596\nsrl $15,$24,1\nmtc1 $15,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$24,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f18,$f18,$f16\ncvt.s.d $f18,$f18\nadd.s $f30,$f30,$f18\nl.s $f18,L.1047\nc.eq.s $f30,$f18; bc1t L.1062\nla $23,89\nbeq $30,$0,L.1064\nla $4,L.687\nmove $5,$23\njal printf\nL.1064:\nL.1062:\nl.s $f30,L.841\nl.s $f26,L.529\nadd.s $f30,$f30,$f26\nl.s $f18,L.1047\nc.eq.s $f30,$f18; bc1t L.1066\nla $23,90\nbeq $30,$0,L.1068\nla $4,L.687\nmove $5,$23\njal printf\nL.1068:\nL.1066:\nl.s $f30,L.841\nl.d $f24,L.416\ncvt.d.s $f18,$f30\nadd.d $f18,$f18,$f24\ncvt.s.d $f30,$f18\nl.s $f18,L.1047\nc.eq.s $f30,$f18; bc1t L.1070\nla $23,91\nbeq $30,$0,L.1072\nla $4,L.687\nmove $5,$23\njal printf\nL.1072:\nL.1070:\nl.d $f28,L.870\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\nadd.d $f28,$f28,$f18\nl.d $f18,L.1076\nc.eq.d $f28,$f18; bc1t L.1074\nla $23,92\nbeq $30,$0,L.1077\nla $4,L.687\nmove $5,$23\njal printf\nL.1077:\nL.1074:\nl.d $f28,L.870\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\nadd.d $f28,$f28,$f18\nl.d $f18,L.1076\nc.eq.d $f28,$f18; bc1t L.1079\nla $23,93\nbeq $30,$0,L.1081\nla $4,L.687\nmove $5,$23\njal printf\nL.1081:\nL.1079:\nl.d $f28,L.870\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\nadd.d $f28,$f28,$f18\nl.d $f18,L.1076\nc.eq.d $f28,$f18; bc1t L.1083\nla $23,94\nbeq $30,$0,L.1085\nla $4,L.687\nmove $5,$23\njal printf\nL.1085:\nL.1083:\nl.d $f28,L.870\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\nadd.d $f28,$f28,$f18\nl.d $f18,L.1076\nc.eq.d $f28,$f18; bc1t L.1087\nla $23,95\nbeq $30,$0,L.1089\nla $4,L.687\nmove $5,$23\njal printf\nL.1089:\nL.1087:\nl.d $f28,L.870\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nl.d $f18,L.596\nsrl $15,$24,1\nmtc1 $15,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$24,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f18,$f18,$f16\nadd.d $f28,$f28,$f18\nl.d $f18,L.1076\nc.eq.d $f28,$f18; bc1t L.1091\nla $23,96\nbeq $30,$0,L.1093\nla $4,L.687\nmove $5,$23\njal printf\nL.1093:\nL.1091:\nl.d $f28,L.870\nl.s $f26,L.529\ncvt.d.s $f18,$f26\nadd.d $f28,$f28,$f18\nl.d $f18,L.1076\nc.eq.d $f28,$f18; bc1t L.1095\nla $23,97\nbeq $30,$0,L.1097\nla $4,L.687\nmove $5,$23\njal printf\nL.1097:\nL.1095:\nl.d $f28,L.870\nl.d $f24,L.416\nadd.d $f28,$f28,$f24\nl.d $f18,L.1076\nc.eq.d $f28,$f18; bc1t L.1099\nla $23,98\nbeq $30,$0,L.1101\nla $4,L.687\nmove $5,$23\njal printf\nL.1101:\nL.1099:\nla $22,5\nla $17,2\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\nsubu $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,3\nbeq $24,$15,L.1103\nla $23,99\nbeq $30,$0,L.1105\nla $4,L.687\nmove $5,$23\njal printf\nL.1105:\nL.1103:\nla $22,5\nla $16,2\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\nsubu $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,3\nbeq $24,$15,L.1107\nla $23,100\nbeq $30,$0,L.1109\nla $4,L.687\nmove $5,$23\njal printf\nL.1109:\nL.1107:\nla $22,5\nla $24,2\nsw $24,-4+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-4+160($sp)\nsubu $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,3\nbeq $24,$15,L.1111\nla $23,101\nbeq $30,$0,L.1113\nla $4,L.687\nmove $5,$23\njal printf\nL.1113:\nL.1111:\nla $22,5\nla $24,2\nsw $24,-8+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-8+160($sp)\nsubu $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,3\nbeq $24,$15,L.1115\nla $23,102\nbeq $30,$0,L.1117\nla $4,L.687\nmove $5,$23\njal printf\nL.1117:\nL.1115:\nla $22,5\nla $24,2\nsw $24,-12+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-12+160($sp)\nsubu $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,3\nbeq $24,$15,L.1119\nla $23,103\nbeq $30,$0,L.1121\nla $4,L.687\nmove $5,$23\njal printf\nL.1121:\nL.1119:\nla $22,5\nl.s $f26,L.529\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\nsub.s $f18,$f18,$f26\ntrunc.w.s $f2,$f18,$24; mfc1 $24,$f2\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,3\nbeq $24,$15,L.1123\nla $23,104\nbeq $30,$0,L.1125\nla $4,L.687\nmove $5,$23\njal printf\nL.1125:\nL.1123:\nla $22,5\nl.d $f24,L.416\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\nsub.d $f18,$f18,$f24\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,3\nbeq $24,$15,L.1127\nla $23,105\nbeq $30,$0,L.1129\nla $4,L.687\nmove $5,$23\njal printf\nL.1129:\nL.1127:\nla $21,5\nla $17,2\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\nsubu $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,3\nbeq $24,$15,L.1131\nla $23,106\nbeq $30,$0,L.1133\nla $4,L.687\nmove $5,$23\njal printf\nL.1133:\nL.1131:\nla $21,5\nla $16,2\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\nsubu $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,3\nbeq $24,$15,L.1135\nla $23,107\nbeq $30,$0,L.1137\nla $4,L.687\nmove $5,$23\njal printf\nL.1137:\nL.1135:\nla $21,5\nla $24,2\nsw $24,-4+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-4+160($sp)\nsubu $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,3\nbeq $24,$15,L.1139\nla $23,108\nbeq $30,$0,L.1141\nla $4,L.687\nmove $5,$23\njal printf\nL.1141:\nL.1139:\nla $21,5\nla $24,2\nsw $24,-8+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-8+160($sp)\nsubu $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,3\nbeq $24,$15,L.1143\nla $23,109\nbeq $30,$0,L.1145\nla $4,L.687\nmove $5,$23\njal printf\nL.1145:\nL.1143:\nla $21,5\nla $24,2\nsw $24,-12+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-12+160($sp)\nsubu $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,3\nbeq $24,$15,L.1147\nla $23,110\nbeq $30,$0,L.1149\nla $4,L.687\nmove $5,$23\njal printf\nL.1149:\nL.1147:\nla $21,5\nl.s $f26,L.529\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\nsub.s $f18,$f18,$f26\ntrunc.w.s $f2,$f18,$24; mfc1 $24,$f2\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,3\nbeq $24,$15,L.1151\nla $23,111\nbeq $30,$0,L.1153\nla $4,L.687\nmove $5,$23\njal printf\nL.1153:\nL.1151:\nla $21,5\nl.d $f24,L.416\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\nsub.d $f18,$f18,$f24\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,3\nbeq $24,$15,L.1155\nla $23,112\nbeq $30,$0,L.1157\nla $4,L.687\nmove $5,$23\njal printf\nL.1157:\nL.1155:\nla $20,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nsubu $20,$20,$24\nla $24,3\nbeq $20,$24,L.1159\nla $23,113\nbeq $30,$0,L.1161\nla $4,L.687\nmove $5,$23\njal printf\nL.1161:\nL.1159:\nla $20,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nsubu $20,$20,$24\nla $24,3\nbeq $20,$24,L.1163\nla $23,114\nbeq $30,$0,L.1165\nla $4,L.687\nmove $5,$23\njal printf\nL.1165:\nL.1163:\nla $20,5\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nsubu $20,$20,$24\nla $24,3\nbeq $20,$24,L.1167\nla $23,115\nbeq $30,$0,L.1169\nla $4,L.687\nmove $5,$23\njal printf\nL.1169:\nL.1167:\nla $20,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nsubu $20,$20,$24\nla $24,3\nbeq $20,$24,L.1171\nla $23,116\nbeq $30,$0,L.1173\nla $4,L.687\nmove $5,$23\njal printf\nL.1173:\nL.1171:\nla $20,5\nla $24,2\nsw $24,-12+160($sp)\nmove $24,$20\nlw $15,-12+160($sp)\nsubu $24,$24,$15\nmove $20,$24\nla $24,3\nbeq $20,$24,L.1175\nla $23,117\nbeq $30,$0,L.1177\nla $4,L.687\nmove $5,$23\njal printf\nL.1177:\nL.1175:\nla $20,5\nl.s $f26,L.529\nmtc1 $20,$f18; cvt.s.w $f18,$f18\nsub.s $f18,$f18,$f26\ntrunc.w.s $f2,$f18,$20; mfc1 $20,$f2\nla $24,3\nbeq $20,$24,L.1179\nla $23,118\nbeq $30,$0,L.1181\nla $4,L.687\nmove $5,$23\njal printf\nL.1181:\nL.1179:\nla $20,5\nl.d $f24,L.416\nmtc1 $20,$f18; cvt.d.w $f18,$f18\nsub.d $f18,$f18,$f24\ntrunc.w.d $f2,$f18,$20; mfc1 $20,$f2\nla $24,3\nbeq $20,$24,L.1183\nla $23,119\nbeq $30,$0,L.1185\nla $4,L.687\nmove $5,$23\njal printf\nL.1185:\nL.1183:\nla $19,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nsubu $19,$19,$24\nla $24,3\nbeq $19,$24,L.1187\nla $23,120\nbeq $30,$0,L.1189\nla $4,L.687\nmove $5,$23\njal printf\nL.1189:\nL.1187:\nla $19,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nsubu $19,$19,$24\nla $24,3\nbeq $19,$24,L.1191\nla $23,121\nbeq $30,$0,L.1193\nla $4,L.687\nmove $5,$23\njal printf\nL.1193:\nL.1191:\nla $19,5\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nsubu $19,$19,$24\nla $24,3\nbeq $19,$24,L.1195\nla $23,122\nbeq $30,$0,L.1197\nla $4,L.687\nmove $5,$23\njal printf\nL.1197:\nL.1195:\nla $19,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nsubu $19,$19,$24\nla $24,3\nbeq $19,$24,L.1199\nla $23,123\nbeq $30,$0,L.1201\nla $4,L.687\nmove $5,$23\njal printf\nL.1201:\nL.1199:\nla $19,5\nla $24,2\nsw $24,-12+160($sp)\nmove $24,$19\nlw $15,-12+160($sp)\nsubu $24,$24,$15\nmove $19,$24\nla $24,3\nbeq $19,$24,L.1203\nla $23,124\nbeq $30,$0,L.1205\nla $4,L.687\nmove $5,$23\njal printf\nL.1205:\nL.1203:\nla $19,5\nl.s $f26,L.529\nmtc1 $19,$f18; cvt.s.w $f18,$f18\nsub.s $f18,$f18,$f26\ntrunc.w.s $f2,$f18,$19; mfc1 $19,$f2\nla $24,3\nbeq $19,$24,L.1207\nla $23,125\nbeq $30,$0,L.1209\nla $4,L.687\nmove $5,$23\njal printf\nL.1209:\nL.1207:\nla $19,5\nl.d $f24,L.416\nmtc1 $19,$f18; cvt.d.w $f18,$f18\nsub.d $f18,$f18,$f24\ntrunc.w.d $f2,$f18,$19; mfc1 $19,$f2\nla $24,3\nbeq $19,$24,L.1211\nla $23,126\nbeq $30,$0,L.1213\nla $4,L.687\nmove $5,$23\njal printf\nL.1213:\nL.1211:\nla $18,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nsubu $18,$18,$24\nla $24,3\nbeq $18,$24,L.1215\nla $23,127\nbeq $30,$0,L.1217\nla $4,L.687\nmove $5,$23\njal printf\nL.1217:\nL.1215:\nla $18,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nsubu $18,$18,$24\nla $24,3\nbeq $18,$24,L.1219\nla $23,128\nbeq $30,$0,L.1221\nla $4,L.687\nmove $5,$23\njal printf\nL.1221:\nL.1219:\nla $18,5\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nsubu $18,$18,$24\nla $24,3\nbeq $18,$24,L.1223\nla $23,129\nbeq $30,$0,L.1225\nla $4,L.687\nmove $5,$23\njal printf\nL.1225:\nL.1223:\nla $18,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nsubu $18,$18,$24\nla $24,3\nbeq $18,$24,L.1227\nla $23,130\nbeq $30,$0,L.1229\nla $4,L.687\nmove $5,$23\njal printf\nL.1229:\nL.1227:\nla $18,5\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nsubu $18,$18,$24\nla $24,3\nbeq $18,$24,L.1231\nla $23,131\nbeq $30,$0,L.1233\nla $4,L.687\nmove $5,$23\njal printf\nL.1233:\nL.1231:\nla $18,5\nl.s $f26,L.529\nl.d $f18,L.596\nsrl $24,$18,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$18,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f18,$f18,$f16\ncvt.s.d $f18,$f18\nsub.s $f18,$f18,$f26\nl.s $f16,L.828\nc.lt.s $f18,$f16; bc1t L.1236\nsub.s $f16,$f18,$f16\ntrunc.w.s $f2,$f16,$24; mfc1 $24,$f2\nla $24,0x80000000($24)\nsw $24,-44+160($sp)\nb L.1237\nL.1236:\ntrunc.w.s $f2,$f18,$24; mfc1 $24,$f2\nsw $24,-44+160($sp)\nL.1237:\nlw $18,-44+160($sp)\nla $24,3\nbeq $18,$24,L.1238\nla $23,132\nbeq $30,$0,L.1240\nla $4,L.687\nmove $5,$23\njal printf\nL.1240:\nL.1238:\nla $18,5\nl.d $f24,L.416\nl.d $f18,L.596\nsrl $24,$18,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$18,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f18,$f18,$f16\nsub.d $f18,$f18,$f24\nl.d $f16,L.836\nc.lt.d $f18,$f16; bc1t L.1243\nsub.d $f16,$f18,$f16\ntrunc.w.d $f2,$f16,$24; mfc1 $24,$f2\nla $24,0x80000000($24)\nsw $24,-48+160($sp)\nb L.1244\nL.1243:\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nsw $24,-48+160($sp)\nL.1244:\nlw $18,-48+160($sp)\nla $24,3\nbeq $18,$24,L.1245\nla $23,133\nbeq $30,$0,L.1247\nla $4,L.687\nmove $5,$23\njal printf\nL.1247:\nL.1245:\nl.s $f30,L.841\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\nsub.s $f30,$f30,$f18\nl.s $f18,L.1251\nc.eq.s $f30,$f18; bc1t L.1249\nla $23,134\nbeq $30,$0,L.1252\nla $4,L.687\nmove $5,$23\njal printf\nL.1252:\nL.1249:\nl.s $f30,L.841\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\nsub.s $f30,$f30,$f18\nl.s $f18,L.1251\nc.eq.s $f30,$f18; bc1t L.1254\nla $23,135\nbeq $30,$0,L.1256\nla $4,L.687\nmove $5,$23\njal printf\nL.1256:\nL.1254:\nl.s $f30,L.841\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\nsub.s $f30,$f30,$f18\nl.s $f18,L.1251\nc.eq.s $f30,$f18; bc1t L.1258\nla $23,136\nbeq $30,$0,L.1260\nla $4,L.687\nmove $5,$23\njal printf\nL.1260:\nL.1258:\nl.s $f30,L.841\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\nsub.s $f30,$f30,$f18\nl.s $f18,L.1251\nc.eq.s $f30,$f18; bc1t L.1262\nla $23,137\nbeq $30,$0,L.1264\nla $4,L.687\nmove $5,$23\njal printf\nL.1264:\nL.1262:\nl.s $f30,L.841\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nl.d $f18,L.596\nsrl $15,$24,1\nmtc1 $15,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$24,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f18,$f18,$f16\ncvt.s.d $f18,$f18\nsub.s $f30,$f30,$f18\nl.s $f18,L.1251\nc.eq.s $f30,$f18; bc1t L.1266\nla $23,138\nbeq $30,$0,L.1268\nla $4,L.687\nmove $5,$23\njal printf\nL.1268:\nL.1266:\nl.s $f30,L.841\nl.s $f26,L.529\nsub.s $f30,$f30,$f26\nl.s $f18,L.1251\nc.eq.s $f30,$f18; bc1t L.1270\nla $23,139\nbeq $30,$0,L.1272\nla $4,L.687\nmove $5,$23\njal printf\nL.1272:\nL.1270:\nl.s $f30,L.841\nl.d $f24,L.416\ncvt.d.s $f18,$f30\nsub.d $f18,$f18,$f24\ncvt.s.d $f30,$f18\nl.s $f18,L.1251\nc.eq.s $f30,$f18; bc1t L.1274\nla $23,140\nbeq $30,$0,L.1276\nla $4,L.687\nmove $5,$23\njal printf\nL.1276:\nL.1274:\nl.d $f28,L.870\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\nsub.d $f28,$f28,$f18\nl.d $f18,L.1280\nc.eq.d $f28,$f18; bc1t L.1278\nla $23,141\nbeq $30,$0,L.1281\nla $4,L.687\nmove $5,$23\njal printf\nL.1281:\nL.1278:\nl.d $f28,L.870\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\nsub.d $f28,$f28,$f18\nl.d $f18,L.1280\nc.eq.d $f28,$f18; bc1t L.1283\nla $23,142\nbeq $30,$0,L.1285\nla $4,L.687\nmove $5,$23\njal printf\nL.1285:\nL.1283:\nl.d $f28,L.870\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\nsub.d $f28,$f28,$f18\nl.d $f18,L.1280\nc.eq.d $f28,$f18; bc1t L.1287\nla $23,143\nbeq $30,$0,L.1289\nla $4,L.687\nmove $5,$23\njal printf\nL.1289:\nL.1287:\nl.d $f28,L.870\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\nsub.d $f28,$f28,$f18\nl.d $f18,L.1280\nc.eq.d $f28,$f18; bc1t L.1291\nla $23,144\nbeq $30,$0,L.1293\nla $4,L.687\nmove $5,$23\njal printf\nL.1293:\nL.1291:\nl.d $f28,L.870\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nl.d $f18,L.596\nsrl $15,$24,1\nmtc1 $15,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$24,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f18,$f18,$f16\nsub.d $f28,$f28,$f18\nl.d $f18,L.1280\nc.eq.d $f28,$f18; bc1t L.1295\nla $23,145\nbeq $30,$0,L.1297\nla $4,L.687\nmove $5,$23\njal printf\nL.1297:\nL.1295:\nl.d $f28,L.870\nl.s $f26,L.529\ncvt.d.s $f18,$f26\nsub.d $f28,$f28,$f18\nl.d $f18,L.1280\nc.eq.d $f28,$f18; bc1t L.1299\nla $23,146\nbeq $30,$0,L.1301\nla $4,L.687\nmove $5,$23\njal printf\nL.1301:\nL.1299:\nl.d $f28,L.870\nl.d $f24,L.416\nsub.d $f28,$f28,$f24\nl.d $f18,L.1280\nc.eq.d $f28,$f18; bc1t L.1303\nla $23,147\nbeq $30,$0,L.1305\nla $4,L.687\nmove $5,$23\njal printf\nL.1305:\nL.1303:\nla $22,5\nla $17,2\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\nmul $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,10\nbeq $24,$15,L.1307\nla $23,148\nbeq $30,$0,L.1309\nla $4,L.687\nmove $5,$23\njal printf\nL.1309:\nL.1307:\nla $22,5\nla $16,2\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\nmul $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,10\nbeq $24,$15,L.1311\nla $23,149\nbeq $30,$0,L.1313\nla $4,L.687\nmove $5,$23\njal printf\nL.1313:\nL.1311:\nla $22,5\nla $24,2\nsw $24,-4+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-4+160($sp)\nmul $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,10\nbeq $24,$15,L.1315\nla $23,150\nbeq $30,$0,L.1317\nla $4,L.687\nmove $5,$23\njal printf\nL.1317:\nL.1315:\nla $22,5\nla $24,2\nsw $24,-8+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-8+160($sp)\nmul $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,10\nbeq $24,$15,L.1319\nla $23,151\nbeq $30,$0,L.1321\nla $4,L.687\nmove $5,$23\njal printf\nL.1321:\nL.1319:\nla $22,5\nla $24,2\nsw $24,-12+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-12+160($sp)\nmul $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,10\nbeq $24,$15,L.1323\nla $23,152\nbeq $30,$0,L.1325\nla $4,L.687\nmove $5,$23\njal printf\nL.1325:\nL.1323:\nla $22,5\nl.s $f26,L.529\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\nmul.s $f18,$f18,$f26\ntrunc.w.s $f2,$f18,$24; mfc1 $24,$f2\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,10\nbeq $24,$15,L.1327\nla $23,153\nbeq $30,$0,L.1329\nla $4,L.687\nmove $5,$23\njal printf\nL.1329:\nL.1327:\nla $22,5\nl.d $f24,L.416\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\nmul.d $f18,$f18,$f24\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,10\nbeq $24,$15,L.1331\nla $23,154\nbeq $30,$0,L.1333\nla $4,L.687\nmove $5,$23\njal printf\nL.1333:\nL.1331:\nla $21,5\nla $17,2\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\nmul $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,10\nbeq $24,$15,L.1335\nla $23,155\nbeq $30,$0,L.1337\nla $4,L.687\nmove $5,$23\njal printf\nL.1337:\nL.1335:\nla $21,5\nla $16,2\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\nmul $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,10\nbeq $24,$15,L.1339\nla $23,156\nbeq $30,$0,L.1341\nla $4,L.687\nmove $5,$23\njal printf\nL.1341:\nL.1339:\nla $21,5\nla $24,2\nsw $24,-4+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-4+160($sp)\nmul $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,10\nbeq $24,$15,L.1343\nla $23,157\nbeq $30,$0,L.1345\nla $4,L.687\nmove $5,$23\njal printf\nL.1345:\nL.1343:\nla $21,5\nla $24,2\nsw $24,-8+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-8+160($sp)\nmul $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,10\nbeq $24,$15,L.1347\nla $23,158\nbeq $30,$0,L.1349\nla $4,L.687\nmove $5,$23\njal printf\nL.1349:\nL.1347:\nla $21,5\nla $24,2\nsw $24,-12+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-12+160($sp)\nmul $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,10\nbeq $24,$15,L.1351\nla $23,159\nbeq $30,$0,L.1353\nla $4,L.687\nmove $5,$23\njal printf\nL.1353:\nL.1351:\nla $21,5\nl.s $f26,L.529\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\nmul.s $f18,$f18,$f26\ntrunc.w.s $f2,$f18,$24; mfc1 $24,$f2\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,10\nbeq $24,$15,L.1355\nla $23,160\nbeq $30,$0,L.1357\nla $4,L.687\nmove $5,$23\njal printf\nL.1357:\nL.1355:\nla $21,5\nl.d $f24,L.416\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\nmul.d $f18,$f18,$f24\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,10\nbeq $24,$15,L.1359\nla $23,161\nbeq $30,$0,L.1361\nla $4,L.687\nmove $5,$23\njal printf\nL.1361:\nL.1359:\nla $20,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nmul $20,$20,$24\nla $24,10\nbeq $20,$24,L.1363\nla $23,162\nbeq $30,$0,L.1365\nla $4,L.687\nmove $5,$23\njal printf\nL.1365:\nL.1363:\nla $20,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nmul $20,$20,$24\nla $24,10\nbeq $20,$24,L.1367\nla $23,163\nbeq $30,$0,L.1369\nla $4,L.687\nmove $5,$23\njal printf\nL.1369:\nL.1367:\nla $20,5\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nmul $20,$20,$24\nla $24,10\nbeq $20,$24,L.1371\nla $23,164\nbeq $30,$0,L.1373\nla $4,L.687\nmove $5,$23\njal printf\nL.1373:\nL.1371:\nla $20,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nmul $20,$20,$24\nla $24,10\nbeq $20,$24,L.1375\nla $23,165\nbeq $30,$0,L.1377\nla $4,L.687\nmove $5,$23\njal printf\nL.1377:\nL.1375:\nla $20,5\nla $24,2\nsw $24,-12+160($sp)\nmove $24,$20\nlw $15,-12+160($sp)\nmul $24,$24,$15\nmove $20,$24\nla $24,10\nbeq $20,$24,L.1379\nla $23,166\nbeq $30,$0,L.1381\nla $4,L.687\nmove $5,$23\njal printf\nL.1381:\nL.1379:\nla $20,5\nl.s $f26,L.529\nmtc1 $20,$f18; cvt.s.w $f18,$f18\nmul.s $f18,$f18,$f26\ntrunc.w.s $f2,$f18,$20; mfc1 $20,$f2\nla $24,10\nbeq $20,$24,L.1383\nla $23,167\nbeq $30,$0,L.1385\nla $4,L.687\nmove $5,$23\njal printf\nL.1385:\nL.1383:\nla $20,5\nl.d $f24,L.416\nmtc1 $20,$f18; cvt.d.w $f18,$f18\nmul.d $f18,$f18,$f24\ntrunc.w.d $f2,$f18,$20; mfc1 $20,$f2\nla $24,10\nbeq $20,$24,L.1387\nla $23,168\nbeq $30,$0,L.1389\nla $4,L.687\nmove $5,$23\njal printf\nL.1389:\nL.1387:\nla $19,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nmul $19,$19,$24\nla $24,10\nbeq $19,$24,L.1391\nla $23,169\nbeq $30,$0,L.1393\nla $4,L.687\nmove $5,$23\njal printf\nL.1393:\nL.1391:\nla $19,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nmul $19,$19,$24\nla $24,10\nbeq $19,$24,L.1395\nla $23,170\nbeq $30,$0,L.1397\nla $4,L.687\nmove $5,$23\njal printf\nL.1397:\nL.1395:\nla $19,5\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nmul $19,$19,$24\nla $24,10\nbeq $19,$24,L.1399\nla $23,171\nbeq $30,$0,L.1401\nla $4,L.687\nmove $5,$23\njal printf\nL.1401:\nL.1399:\nla $19,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nmul $19,$19,$24\nla $24,10\nbeq $19,$24,L.1403\nla $23,172\nbeq $30,$0,L.1405\nla $4,L.687\nmove $5,$23\njal printf\nL.1405:\nL.1403:\nla $19,5\nla $24,2\nsw $24,-12+160($sp)\nmove $24,$19\nlw $15,-12+160($sp)\nmul $24,$24,$15\nmove $19,$24\nla $24,10\nbeq $19,$24,L.1407\nla $23,173\nbeq $30,$0,L.1409\nla $4,L.687\nmove $5,$23\njal printf\nL.1409:\nL.1407:\nla $19,5\nl.s $f26,L.529\nmtc1 $19,$f18; cvt.s.w $f18,$f18\nmul.s $f18,$f18,$f26\ntrunc.w.s $f2,$f18,$19; mfc1 $19,$f2\nla $24,10\nbeq $19,$24,L.1411\nla $23,174\nbeq $30,$0,L.1413\nla $4,L.687\nmove $5,$23\njal printf\nL.1413:\nL.1411:\nla $19,5\nl.d $f24,L.416\nmtc1 $19,$f18; cvt.d.w $f18,$f18\nmul.d $f18,$f18,$f24\ntrunc.w.d $f2,$f18,$19; mfc1 $19,$f2\nla $24,10\nbeq $19,$24,L.1415\nla $23,175\nbeq $30,$0,L.1417\nla $4,L.687\nmove $5,$23\njal printf\nL.1417:\nL.1415:\nla $18,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nmul $18,$18,$24\nla $24,10\nbeq $18,$24,L.1419\nla $23,176\nbeq $30,$0,L.1421\nla $4,L.687\nmove $5,$23\njal printf\nL.1421:\nL.1419:\nla $18,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nmul $18,$18,$24\nla $24,10\nbeq $18,$24,L.1423\nla $23,177\nbeq $30,$0,L.1425\nla $4,L.687\nmove $5,$23\njal printf\nL.1425:\nL.1423:\nla $18,5\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nmul $18,$18,$24\nla $24,10\nbeq $18,$24,L.1427\nla $23,178\nbeq $30,$0,L.1429\nla $4,L.687\nmove $5,$23\njal printf\nL.1429:\nL.1427:\nla $18,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nmul $18,$18,$24\nla $24,10\nbeq $18,$24,L.1431\nla $23,179\nbeq $30,$0,L.1433\nla $4,L.687\nmove $5,$23\njal printf\nL.1433:\nL.1431:\nla $18,5\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nmul $18,$18,$24\nla $24,10\nbeq $18,$24,L.1435\nla $23,180\nbeq $30,$0,L.1437\nla $4,L.687\nmove $5,$23\njal printf\nL.1437:\nL.1435:\nla $18,5\nl.s $f26,L.529\nl.d $f18,L.596\nsrl $24,$18,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$18,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f18,$f18,$f16\ncvt.s.d $f18,$f18\nmul.s $f18,$f18,$f26\nl.s $f16,L.828\nc.lt.s $f18,$f16; bc1t L.1440\nsub.s $f16,$f18,$f16\ntrunc.w.s $f2,$f16,$24; mfc1 $24,$f2\nla $24,0x80000000($24)\nsw $24,-52+160($sp)\nb L.1441\nL.1440:\ntrunc.w.s $f2,$f18,$24; mfc1 $24,$f2\nsw $24,-52+160($sp)\nL.1441:\nlw $18,-52+160($sp)\nla $24,10\nbeq $18,$24,L.1442\nla $23,181\nbeq $30,$0,L.1444\nla $4,L.687\nmove $5,$23\njal printf\nL.1444:\nL.1442:\nla $18,5\nl.d $f24,L.416\nl.d $f18,L.596\nsrl $24,$18,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$18,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f18,$f18,$f16\nmul.d $f18,$f18,$f24\nl.d $f16,L.836\nc.lt.d $f18,$f16; bc1t L.1447\nsub.d $f16,$f18,$f16\ntrunc.w.d $f2,$f16,$24; mfc1 $24,$f2\nla $24,0x80000000($24)\nsw $24,-56+160($sp)\nb L.1448\nL.1447:\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nsw $24,-56+160($sp)\nL.1448:\nlw $18,-56+160($sp)\nla $24,10\nbeq $18,$24,L.1449\nla $23,182\nbeq $30,$0,L.1451\nla $4,L.687\nmove $5,$23\njal printf\nL.1451:\nL.1449:\nl.s $f30,L.841\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\nmul.s $f30,$f30,$f18\nl.s $f18,L.1455\nc.eq.s $f30,$f18; bc1t L.1453\nla $23,183\nbeq $30,$0,L.1456\nla $4,L.687\nmove $5,$23\njal printf\nL.1456:\nL.1453:\nl.s $f30,L.841\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\nmul.s $f30,$f30,$f18\nl.s $f18,L.1455\nc.eq.s $f30,$f18; bc1t L.1458\nla $23,184\nbeq $30,$0,L.1460\nla $4,L.687\nmove $5,$23\njal printf\nL.1460:\nL.1458:\nl.s $f30,L.841\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\nmul.s $f30,$f30,$f18\nl.s $f18,L.1455\nc.eq.s $f30,$f18; bc1t L.1462\nla $23,185\nbeq $30,$0,L.1464\nla $4,L.687\nmove $5,$23\njal printf\nL.1464:\nL.1462:\nl.s $f30,L.841\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\nmul.s $f30,$f30,$f18\nl.s $f18,L.1455\nc.eq.s $f30,$f18; bc1t L.1466\nla $23,186\nbeq $30,$0,L.1468\nla $4,L.687\nmove $5,$23\njal printf\nL.1468:\nL.1466:\nl.s $f30,L.841\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nl.d $f18,L.596\nsrl $15,$24,1\nmtc1 $15,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$24,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f18,$f18,$f16\ncvt.s.d $f18,$f18\nmul.s $f30,$f30,$f18\nl.s $f18,L.1455\nc.eq.s $f30,$f18; bc1t L.1470\nla $23,187\nbeq $30,$0,L.1472\nla $4,L.687\nmove $5,$23\njal printf\nL.1472:\nL.1470:\nl.s $f30,L.841\nl.s $f26,L.529\nmul.s $f30,$f30,$f26\nl.s $f18,L.1455\nc.eq.s $f30,$f18; bc1t L.1474\nla $23,188\nbeq $30,$0,L.1476\nla $4,L.687\nmove $5,$23\njal printf\nL.1476:\nL.1474:\nl.s $f30,L.841\nl.d $f24,L.416\ncvt.d.s $f18,$f30\nmul.d $f18,$f18,$f24\ncvt.s.d $f30,$f18\nl.s $f18,L.1455\nc.eq.s $f30,$f18; bc1t L.1478\nla $23,189\nbeq $30,$0,L.1480\nla $4,L.687\nmove $5,$23\njal printf\nL.1480:\nL.1478:\nl.d $f28,L.870\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\nmul.d $f28,$f28,$f18\nl.d $f18,L.1484\nc.eq.d $f28,$f18; bc1t L.1482\nla $23,190\nbeq $30,$0,L.1485\nla $4,L.687\nmove $5,$23\njal printf\nL.1485:\nL.1482:\nl.d $f28,L.870\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\nmul.d $f28,$f28,$f18\nl.d $f18,L.1484\nc.eq.d $f28,$f18; bc1t L.1487\nla $23,191\nbeq $30,$0,L.1489\nla $4,L.687\nmove $5,$23\njal printf\nL.1489:\nL.1487:\nl.d $f28,L.870\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\nmul.d $f28,$f28,$f18\nl.d $f18,L.1484\nc.eq.d $f28,$f18; bc1t L.1491\nla $23,192\nbeq $30,$0,L.1493\nla $4,L.687\nmove $5,$23\njal printf\nL.1493:\nL.1491:\nl.d $f28,L.870\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\nmul.d $f28,$f28,$f18\nl.d $f18,L.1484\nc.eq.d $f28,$f18; bc1t L.1495\nla $23,193\nbeq $30,$0,L.1497\nla $4,L.687\nmove $5,$23\njal printf\nL.1497:\nL.1495:\nl.d $f28,L.870\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nl.d $f18,L.596\nsrl $15,$24,1\nmtc1 $15,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$24,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f18,$f18,$f16\nmul.d $f28,$f28,$f18\nl.d $f18,L.1484\nc.eq.d $f28,$f18; bc1t L.1499\nla $23,194\nbeq $30,$0,L.1501\nla $4,L.687\nmove $5,$23\njal printf\nL.1501:\nL.1499:\nl.d $f28,L.870\nl.s $f26,L.529\ncvt.d.s $f18,$f26\nmul.d $f28,$f28,$f18\nl.d $f18,L.1484\nc.eq.d $f28,$f18; bc1t L.1503\nla $23,195\nbeq $30,$0,L.1505\nla $4,L.687\nmove $5,$23\njal printf\nL.1505:\nL.1503:\nl.d $f28,L.870\nl.d $f24,L.416\nmul.d $f28,$f28,$f24\nl.d $f18,L.1484\nc.eq.d $f28,$f18; bc1t L.1507\nla $23,196\nbeq $30,$0,L.1509\nla $4,L.687\nmove $5,$23\njal printf\nL.1509:\nL.1507:\nla $22,5\nla $17,2\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\ndiv $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,2\nbeq $24,$15,L.1511\nla $23,197\nbeq $30,$0,L.1513\nla $4,L.687\nmove $5,$23\njal printf\nL.1513:\nL.1511:\nla $22,5\nla $16,2\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\ndiv $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,2\nbeq $24,$15,L.1515\nla $23,198\nbeq $30,$0,L.1517\nla $4,L.687\nmove $5,$23\njal printf\nL.1517:\nL.1515:\nla $22,5\nla $24,2\nsw $24,-4+160($sp)\nsll $15,$22,8*(4-1); sra $15,$15,8*(4-1)\nlw $14,-4+160($sp)\ndiv $15,$15,$14\nmove $22,$15\nsll $15,$22,8*(4-1); sra $15,$15,8*(4-1)\nbeq $15,$24,L.1519\nla $23,199\nbeq $30,$0,L.1521\nla $4,L.687\nmove $5,$23\njal printf\nL.1521:\nL.1519:\nla $22,5\nla $24,2\nsw $24,-8+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-8+160($sp)\ndiv $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,2\nbeq $24,$15,L.1523\nla $23,200\nbeq $30,$0,L.1525\nla $4,L.687\nmove $5,$23\njal printf\nL.1525:\nL.1523:\nla $22,5\nla $24,2\nsw $24,-12+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-12+160($sp)\ndivu $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,2\nbeq $24,$15,L.1527\nla $23,201\nbeq $30,$0,L.1529\nla $4,L.687\nmove $5,$23\njal printf\nL.1529:\nL.1527:\nla $22,5\nl.s $f26,L.529\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\ndiv.s $f18,$f18,$f26\ntrunc.w.s $f2,$f18,$24; mfc1 $24,$f2\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,2\nbeq $24,$15,L.1531\nla $23,202\nbeq $30,$0,L.1533\nla $4,L.687\nmove $5,$23\njal printf\nL.1533:\nL.1531:\nla $22,5\nl.d $f24,L.416\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\ndiv.d $f18,$f18,$f24\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,2\nbeq $24,$15,L.1535\nla $23,203\nbeq $30,$0,L.1537\nla $4,L.687\nmove $5,$23\njal printf\nL.1537:\nL.1535:\nla $21,5\nla $17,2\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\ndiv $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,2\nbeq $24,$15,L.1539\nla $23,204\nbeq $30,$0,L.1541\nla $4,L.687\nmove $5,$23\njal printf\nL.1541:\nL.1539:\nla $21,5\nla $16,2\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\ndiv $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,2\nbeq $24,$15,L.1543\nla $23,205\nbeq $30,$0,L.1545\nla $4,L.687\nmove $5,$23\njal printf\nL.1545:\nL.1543:\nla $21,5\nla $24,2\nsw $24,-4+160($sp)\nsll $15,$21,8*(4-2); sra $15,$15,8*(4-2)\nlw $14,-4+160($sp)\ndiv $15,$15,$14\nmove $21,$15\nsll $15,$21,8*(4-2); sra $15,$15,8*(4-2)\nbeq $15,$24,L.1547\nla $23,206\nbeq $30,$0,L.1549\nla $4,L.687\nmove $5,$23\njal printf\nL.1549:\nL.1547:\nla $21,5\nla $24,2\nsw $24,-8+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-8+160($sp)\ndiv $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,2\nbeq $24,$15,L.1551\nla $23,207\nbeq $30,$0,L.1553\nla $4,L.687\nmove $5,$23\njal printf\nL.1553:\nL.1551:\nla $21,5\nla $24,2\nsw $24,-12+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-12+160($sp)\ndivu $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,2\nbeq $24,$15,L.1555\nla $23,208\nbeq $30,$0,L.1557\nla $4,L.687\nmove $5,$23\njal printf\nL.1557:\nL.1555:\nla $21,5\nl.s $f26,L.529\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\ndiv.s $f18,$f18,$f26\ntrunc.w.s $f2,$f18,$24; mfc1 $24,$f2\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,2\nbeq $24,$15,L.1559\nla $23,209\nbeq $30,$0,L.1561\nla $4,L.687\nmove $5,$23\njal printf\nL.1561:\nL.1559:\nla $21,5\nl.d $f24,L.416\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\ndiv.d $f18,$f18,$f24\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,2\nbeq $24,$15,L.1563\nla $23,210\nbeq $30,$0,L.1565\nla $4,L.687\nmove $5,$23\njal printf\nL.1565:\nL.1563:\nla $20,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\ndiv $20,$20,$24\nla $24,2\nbeq $20,$24,L.1567\nla $23,211\nbeq $30,$0,L.1569\nla $4,L.687\nmove $5,$23\njal printf\nL.1569:\nL.1567:\nla $20,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\ndiv $20,$20,$24\nla $24,2\nbeq $20,$24,L.1571\nla $23,212\nbeq $30,$0,L.1573\nla $4,L.687\nmove $5,$23\njal printf\nL.1573:\nL.1571:\nla $20,5\nla $24,2\nsw $24,-4+160($sp)\nlw $15,-4+160($sp)\ndiv $20,$20,$15\nbeq $20,$24,L.1575\nla $23,213\nbeq $30,$0,L.1577\nla $4,L.687\nmove $5,$23\njal printf\nL.1577:\nL.1575:\nla $20,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\ndiv $20,$20,$24\nla $24,2\nbeq $20,$24,L.1579\nla $23,214\nbeq $30,$0,L.1581\nla $4,L.687\nmove $5,$23\njal printf\nL.1581:\nL.1579:\nla $20,5\nla $24,2\nsw $24,-12+160($sp)\nmove $24,$20\nlw $15,-12+160($sp)\ndivu $24,$24,$15\nmove $20,$24\nla $24,2\nbeq $20,$24,L.1583\nla $23,215\nbeq $30,$0,L.1585\nla $4,L.687\nmove $5,$23\njal printf\nL.1585:\nL.1583:\nla $20,5\nl.s $f26,L.529\nmtc1 $20,$f18; cvt.s.w $f18,$f18\ndiv.s $f18,$f18,$f26\ntrunc.w.s $f2,$f18,$20; mfc1 $20,$f2\nla $24,2\nbeq $20,$24,L.1587\nla $23,216\nbeq $30,$0,L.1589\nla $4,L.687\nmove $5,$23\njal printf\nL.1589:\nL.1587:\nla $20,5\nl.d $f24,L.416\nmtc1 $20,$f18; cvt.d.w $f18,$f18\ndiv.d $f18,$f18,$f24\ntrunc.w.d $f2,$f18,$20; mfc1 $20,$f2\nla $24,2\nbeq $20,$24,L.1591\nla $23,217\nbeq $30,$0,L.1593\nla $4,L.687\nmove $5,$23\njal printf\nL.1593:\nL.1591:\nla $19,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\ndiv $19,$19,$24\nla $24,2\nbeq $19,$24,L.1595\nla $23,218\nbeq $30,$0,L.1597\nla $4,L.687\nmove $5,$23\njal printf\nL.1597:\nL.1595:\nla $19,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\ndiv $19,$19,$24\nla $24,2\nbeq $19,$24,L.1599\nla $23,219\nbeq $30,$0,L.1601\nla $4,L.687\nmove $5,$23\njal printf\nL.1601:\nL.1599:\nla $19,5\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\ndiv $19,$19,$24\nla $24,2\nbeq $19,$24,L.1603\nla $23,220\nbeq $30,$0,L.1605\nla $4,L.687\nmove $5,$23\njal printf\nL.1605:\nL.1603:\nla $19,5\nla $24,2\nsw $24,-8+160($sp)\nlw $15,-8+160($sp)\ndiv $19,$19,$15\nbeq $19,$24,L.1607\nla $23,221\nbeq $30,$0,L.1609\nla $4,L.687\nmove $5,$23\njal printf\nL.1609:\nL.1607:\nla $19,5\nla $24,2\nsw $24,-12+160($sp)\nmove $24,$19\nlw $15,-12+160($sp)\ndivu $24,$24,$15\nmove $19,$24\nla $24,2\nbeq $19,$24,L.1611\nla $23,222\nbeq $30,$0,L.1613\nla $4,L.687\nmove $5,$23\njal printf\nL.1613:\nL.1611:\nla $19,5\nl.s $f26,L.529\nmtc1 $19,$f18; cvt.s.w $f18,$f18\ndiv.s $f18,$f18,$f26\ntrunc.w.s $f2,$f18,$19; mfc1 $19,$f2\nla $24,2\nbeq $19,$24,L.1615\nla $23,223\nbeq $30,$0,L.1617\nla $4,L.687\nmove $5,$23\njal printf\nL.1617:\nL.1615:\nla $19,5\nl.d $f24,L.416\nmtc1 $19,$f18; cvt.d.w $f18,$f18\ndiv.d $f18,$f18,$f24\ntrunc.w.d $f2,$f18,$19; mfc1 $19,$f2\nla $24,2\nbeq $19,$24,L.1619\nla $23,224\nbeq $30,$0,L.1621\nla $4,L.687\nmove $5,$23\njal printf\nL.1621:\nL.1619:\nla $18,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\ndivu $18,$18,$24\nla $24,2\nbeq $18,$24,L.1623\nla $23,225\nbeq $30,$0,L.1625\nla $4,L.687\nmove $5,$23\njal printf\nL.1625:\nL.1623:\nla $18,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\ndivu $18,$18,$24\nla $24,2\nbeq $18,$24,L.1627\nla $23,226\nbeq $30,$0,L.1629\nla $4,L.687\nmove $5,$23\njal printf\nL.1629:\nL.1627:\nla $18,5\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\ndivu $18,$18,$24\nla $24,2\nbeq $18,$24,L.1631\nla $23,227\nbeq $30,$0,L.1633\nla $4,L.687\nmove $5,$23\njal printf\nL.1633:\nL.1631:\nla $18,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\ndivu $18,$18,$24\nla $24,2\nbeq $18,$24,L.1635\nla $23,228\nbeq $30,$0,L.1637\nla $4,L.687\nmove $5,$23\njal printf\nL.1637:\nL.1635:\nla $18,5\nla $24,2\nsw $24,-12+160($sp)\nlw $15,-12+160($sp)\ndivu $18,$18,$15\nbeq $18,$24,L.1639\nla $23,229\nbeq $30,$0,L.1641\nla $4,L.687\nmove $5,$23\njal printf\nL.1641:\nL.1639:\nla $18,5\nl.s $f26,L.529\nl.d $f18,L.596\nsrl $24,$18,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$18,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f18,$f18,$f16\ncvt.s.d $f18,$f18\ndiv.s $f18,$f18,$f26\nl.s $f16,L.828\nc.lt.s $f18,$f16; bc1t L.1644\nsub.s $f16,$f18,$f16\ntrunc.w.s $f2,$f16,$24; mfc1 $24,$f2\nla $24,0x80000000($24)\nsw $24,-60+160($sp)\nb L.1645\nL.1644:\ntrunc.w.s $f2,$f18,$24; mfc1 $24,$f2\nsw $24,-60+160($sp)\nL.1645:\nlw $18,-60+160($sp)\nla $24,2\nbeq $18,$24,L.1646\nla $23,230\nbeq $30,$0,L.1648\nla $4,L.687\nmove $5,$23\njal printf\nL.1648:\nL.1646:\nla $18,5\nl.d $f24,L.416\nl.d $f18,L.596\nsrl $24,$18,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$18,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f18,$f18,$f16\ndiv.d $f18,$f18,$f24\nl.d $f16,L.836\nc.lt.d $f18,$f16; bc1t L.1651\nsub.d $f16,$f18,$f16\ntrunc.w.d $f2,$f16,$24; mfc1 $24,$f2\nla $24,0x80000000($24)\nsw $24,-64+160($sp)\nb L.1652\nL.1651:\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nsw $24,-64+160($sp)\nL.1652:\nlw $18,-64+160($sp)\nla $24,2\nbeq $18,$24,L.1653\nla $23,231\nbeq $30,$0,L.1655\nla $4,L.687\nmove $5,$23\njal printf\nL.1655:\nL.1653:\nl.s $f30,L.841\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\ndiv.s $f30,$f30,$f18\ncvt.d.s $f18,$f30\nl.d $f16,L.1659\nc.eq.d $f18,$f16; bc1t L.1657\nla $23,232\nbeq $30,$0,L.1660\nla $4,L.687\nmove $5,$23\njal printf\nL.1660:\nL.1657:\nl.s $f30,L.841\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\ndiv.s $f30,$f30,$f18\ncvt.d.s $f18,$f30\nl.d $f16,L.1659\nc.eq.d $f18,$f16; bc1t L.1662\nla $23,233\nbeq $30,$0,L.1664\nla $4,L.687\nmove $5,$23\njal printf\nL.1664:\nL.1662:\nl.s $f30,L.841\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\ndiv.s $f30,$f30,$f18\ncvt.d.s $f18,$f30\nl.d $f16,L.1659\nc.eq.d $f18,$f16; bc1t L.1666\nla $23,234\nbeq $30,$0,L.1668\nla $4,L.687\nmove $5,$23\njal printf\nL.1668:\nL.1666:\nl.s $f30,L.841\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nmtc1 $24,$f18; cvt.s.w $f18,$f18\ndiv.s $f30,$f30,$f18\ncvt.d.s $f18,$f30\nl.d $f16,L.1659\nc.eq.d $f18,$f16; bc1t L.1670\nla $23,235\nbeq $30,$0,L.1672\nla $4,L.687\nmove $5,$23\njal printf\nL.1672:\nL.1670:\nl.s $f30,L.841\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nl.d $f18,L.596\nsrl $15,$24,1\nmtc1 $15,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$24,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f18,$f18,$f16\ncvt.s.d $f18,$f18\ndiv.s $f30,$f30,$f18\ncvt.d.s $f18,$f30\nl.d $f16,L.1659\nc.eq.d $f18,$f16; bc1t L.1674\nla $23,236\nbeq $30,$0,L.1676\nla $4,L.687\nmove $5,$23\njal printf\nL.1676:\nL.1674:\nl.s $f30,L.841\nl.s $f26,L.529\ndiv.s $f30,$f30,$f26\ncvt.d.s $f18,$f30\nl.d $f16,L.1659\nc.eq.d $f18,$f16; bc1t L.1678\nla $23,237\nbeq $30,$0,L.1680\nla $4,L.687\nmove $5,$23\njal printf\nL.1680:\nL.1678:\nl.s $f30,L.841\nl.d $f24,L.416\ncvt.d.s $f18,$f30\ndiv.d $f18,$f18,$f24\ncvt.s.d $f30,$f18\ncvt.d.s $f18,$f30\nl.d $f16,L.1659\nc.eq.d $f18,$f16; bc1t L.1682\nla $23,238\nbeq $30,$0,L.1684\nla $4,L.687\nmove $5,$23\njal printf\nL.1684:\nL.1682:\nl.d $f28,L.870\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\ndiv.d $f28,$f28,$f18\nl.d $f18,L.1659\nc.eq.d $f28,$f18; bc1t L.1686\nla $23,239\nbeq $30,$0,L.1688\nla $4,L.687\nmove $5,$23\njal printf\nL.1688:\nL.1686:\nl.d $f28,L.870\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\ndiv.d $f28,$f28,$f18\nl.d $f18,L.1659\nc.eq.d $f28,$f18; bc1t L.1690\nla $23,240\nbeq $30,$0,L.1692\nla $4,L.687\nmove $5,$23\njal printf\nL.1692:\nL.1690:\nl.d $f28,L.870\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\ndiv.d $f28,$f28,$f18\nl.d $f18,L.1659\nc.eq.d $f28,$f18; bc1t L.1694\nla $23,241\nbeq $30,$0,L.1696\nla $4,L.687\nmove $5,$23\njal printf\nL.1696:\nL.1694:\nl.d $f28,L.870\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nmtc1 $24,$f18; cvt.d.w $f18,$f18\ndiv.d $f28,$f28,$f18\nl.d $f18,L.1659\nc.eq.d $f28,$f18; bc1t L.1698\nla $23,242\nbeq $30,$0,L.1700\nla $4,L.687\nmove $5,$23\njal printf\nL.1700:\nL.1698:\nl.d $f28,L.870\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nl.d $f18,L.596\nsrl $15,$24,1\nmtc1 $15,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$24,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f18,$f18,$f16\ndiv.d $f28,$f28,$f18\nl.d $f18,L.1659\nc.eq.d $f28,$f18; bc1t L.1702\nla $23,243\nbeq $30,$0,L.1704\nla $4,L.687\nmove $5,$23\njal printf\nL.1704:\nL.1702:\nl.d $f28,L.870\nl.s $f26,L.529\ncvt.d.s $f18,$f26\ndiv.d $f28,$f28,$f18\nl.d $f18,L.1659\nc.eq.d $f28,$f18; bc1t L.1706\nla $23,244\nbeq $30,$0,L.1708\nla $4,L.687\nmove $5,$23\njal printf\nL.1708:\nL.1706:\nl.d $f28,L.870\nl.d $f24,L.416\ndiv.d $f28,$f28,$f24\nl.d $f18,L.1659\nc.eq.d $f28,$f18; bc1t L.1710\nla $23,245\nbeq $30,$0,L.1712\nla $4,L.687\nmove $5,$23\njal printf\nL.1712:\nL.1710:\nla $22,5\nla $17,2\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\nrem $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,1\nbeq $24,$15,L.1714\nla $23,246\nbeq $30,$0,L.1716\nla $4,L.687\nmove $5,$23\njal printf\nL.1716:\nL.1714:\nla $22,5\nla $16,2\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\nrem $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,1\nbeq $24,$15,L.1718\nla $23,247\nbeq $30,$0,L.1720\nla $4,L.687\nmove $5,$23\njal printf\nL.1720:\nL.1718:\nla $22,5\nla $24,2\nsw $24,-4+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-4+160($sp)\nrem $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,1\nbeq $24,$15,L.1722\nla $23,248\nbeq $30,$0,L.1724\nla $4,L.687\nmove $5,$23\njal printf\nL.1724:\nL.1722:\nla $22,5\nla $24,2\nsw $24,-8+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-8+160($sp)\nrem $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,1\nbeq $24,$15,L.1726\nla $23,249\nbeq $30,$0,L.1728\nla $4,L.687\nmove $5,$23\njal printf\nL.1728:\nL.1726:\nla $22,5\nla $24,2\nsw $24,-12+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-12+160($sp)\nremu $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,1\nbeq $24,$15,L.1730\nla $23,250\nbeq $30,$0,L.1732\nla $4,L.687\nmove $5,$23\njal printf\nL.1732:\nL.1730:\nla $21,5\nla $17,2\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\nrem $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,1\nbeq $24,$15,L.1734\nla $23,251\nbeq $30,$0,L.1736\nla $4,L.687\nmove $5,$23\njal printf\nL.1736:\nL.1734:\nla $21,5\nla $16,2\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\nrem $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,1\nbeq $24,$15,L.1738\nla $23,252\nbeq $30,$0,L.1740\nla $4,L.687\nmove $5,$23\njal printf\nL.1740:\nL.1738:\nla $21,5\nla $24,2\nsw $24,-4+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-4+160($sp)\nrem $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,1\nbeq $24,$15,L.1742\nla $23,253\nbeq $30,$0,L.1744\nla $4,L.687\nmove $5,$23\njal printf\nL.1744:\nL.1742:\nla $21,5\nla $24,2\nsw $24,-8+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-8+160($sp)\nrem $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,1\nbeq $24,$15,L.1746\nla $23,254\nbeq $30,$0,L.1748\nla $4,L.687\nmove $5,$23\njal printf\nL.1748:\nL.1746:\nla $21,5\nla $24,2\nsw $24,-12+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-12+160($sp)\nremu $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,1\nbeq $24,$15,L.1750\nla $23,255\nbeq $30,$0,L.1752\nla $4,L.687\nmove $5,$23\njal printf\nL.1752:\nL.1750:\nla $20,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nrem $20,$20,$24\nla $24,1\nbeq $20,$24,L.1754\nla $23,256\nbeq $30,$0,L.1756\nla $4,L.687\nmove $5,$23\njal printf\nL.1756:\nL.1754:\nla $20,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nrem $20,$20,$24\nla $24,1\nbeq $20,$24,L.1758\nla $23,257\nbeq $30,$0,L.1760\nla $4,L.687\nmove $5,$23\njal printf\nL.1760:\nL.1758:\nla $20,5\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nrem $20,$20,$24\nla $24,1\nbeq $20,$24,L.1762\nla $23,258\nbeq $30,$0,L.1764\nla $4,L.687\nmove $5,$23\njal printf\nL.1764:\nL.1762:\nla $20,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nrem $20,$20,$24\nla $24,1\nbeq $20,$24,L.1766\nla $23,259\nbeq $30,$0,L.1768\nla $4,L.687\nmove $5,$23\njal printf\nL.1768:\nL.1766:\nla $20,5\nla $24,2\nsw $24,-12+160($sp)\nmove $24,$20\nlw $15,-12+160($sp)\nremu $24,$24,$15\nmove $20,$24\nla $24,1\nbeq $20,$24,L.1770\nla $23,260\nbeq $30,$0,L.1772\nla $4,L.687\nmove $5,$23\njal printf\nL.1772:\nL.1770:\nla $19,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nrem $19,$19,$24\nla $24,1\nbeq $19,$24,L.1774\nla $23,261\nbeq $30,$0,L.1776\nla $4,L.687\nmove $5,$23\njal printf\nL.1776:\nL.1774:\nla $19,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nrem $19,$19,$24\nla $24,1\nbeq $19,$24,L.1778\nla $23,262\nbeq $30,$0,L.1780\nla $4,L.687\nmove $5,$23\njal printf\nL.1780:\nL.1778:\nla $19,5\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nrem $19,$19,$24\nla $24,1\nbeq $19,$24,L.1782\nla $23,263\nbeq $30,$0,L.1784\nla $4,L.687\nmove $5,$23\njal printf\nL.1784:\nL.1782:\nla $19,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nrem $19,$19,$24\nla $24,1\nbeq $19,$24,L.1786\nla $23,264\nbeq $30,$0,L.1788\nla $4,L.687\nmove $5,$23\njal printf\nL.1788:\nL.1786:\nla $19,5\nla $24,2\nsw $24,-12+160($sp)\nmove $24,$19\nlw $15,-12+160($sp)\nremu $24,$24,$15\nmove $19,$24\nla $24,1\nbeq $19,$24,L.1790\nla $23,265\nbeq $30,$0,L.1792\nla $4,L.687\nmove $5,$23\njal printf\nL.1792:\nL.1790:\nla $18,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nremu $18,$18,$24\nla $24,1\nbeq $18,$24,L.1794\nla $23,266\nbeq $30,$0,L.1796\nla $4,L.687\nmove $5,$23\njal printf\nL.1796:\nL.1794:\nla $18,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nremu $18,$18,$24\nla $24,1\nbeq $18,$24,L.1798\nla $23,267\nbeq $30,$0,L.1800\nla $4,L.687\nmove $5,$23\njal printf\nL.1800:\nL.1798:\nla $18,5\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nremu $18,$18,$24\nla $24,1\nbeq $18,$24,L.1802\nla $23,268\nbeq $30,$0,L.1804\nla $4,L.687\nmove $5,$23\njal printf\nL.1804:\nL.1802:\nla $18,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nremu $18,$18,$24\nla $24,1\nbeq $18,$24,L.1806\nla $23,269\nbeq $30,$0,L.1808\nla $4,L.687\nmove $5,$23\njal printf\nL.1808:\nL.1806:\nla $18,5\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nremu $18,$18,$24\nla $24,1\nbeq $18,$24,L.1810\nla $23,270\nbeq $30,$0,L.1812\nla $4,L.687\nmove $5,$23\njal printf\nL.1812:\nL.1810:\nla $22,5\nla $17,2\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\nsra $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,1\nbeq $24,$15,L.1814\nla $23,271\nbeq $30,$0,L.1816\nla $4,L.687\nmove $5,$23\njal printf\nL.1816:\nL.1814:\nla $22,5\nla $16,2\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\nsra $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,1\nbeq $24,$15,L.1818\nla $23,272\nbeq $30,$0,L.1820\nla $4,L.687\nmove $5,$23\njal printf\nL.1820:\nL.1818:\nla $22,5\nla $24,2\nsw $24,-4+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-4+160($sp)\nsra $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,1\nbeq $24,$15,L.1822\nla $23,273\nbeq $30,$0,L.1824\nla $4,L.687\nmove $5,$23\njal printf\nL.1824:\nL.1822:\nla $22,5\nla $24,2\nsw $24,-8+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-8+160($sp)\nsra $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,1\nbeq $24,$15,L.1826\nla $23,274\nbeq $30,$0,L.1828\nla $4,L.687\nmove $5,$23\njal printf\nL.1828:\nL.1826:\nla $22,5\nla $24,2\nsw $24,-12+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-12+160($sp)\nsra $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,1\nbeq $24,$15,L.1830\nla $23,275\nbeq $30,$0,L.1832\nla $4,L.687\nmove $5,$23\njal printf\nL.1832:\nL.1830:\nla $21,5\nla $17,2\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\nsra $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,1\nbeq $24,$15,L.1834\nla $23,276\nbeq $30,$0,L.1836\nla $4,L.687\nmove $5,$23\njal printf\nL.1836:\nL.1834:\nla $21,5\nla $16,2\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\nsra $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,1\nbeq $24,$15,L.1838\nla $23,277\nbeq $30,$0,L.1840\nla $4,L.687\nmove $5,$23\njal printf\nL.1840:\nL.1838:\nla $21,5\nla $24,2\nsw $24,-4+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-4+160($sp)\nsra $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,1\nbeq $24,$15,L.1842\nla $23,278\nbeq $30,$0,L.1844\nla $4,L.687\nmove $5,$23\njal printf\nL.1844:\nL.1842:\nla $21,5\nla $24,2\nsw $24,-8+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-8+160($sp)\nsra $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,1\nbeq $24,$15,L.1846\nla $23,279\nbeq $30,$0,L.1848\nla $4,L.687\nmove $5,$23\njal printf\nL.1848:\nL.1846:\nla $21,5\nla $24,2\nsw $24,-12+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-12+160($sp)\nsra $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,1\nbeq $24,$15,L.1850\nla $23,280\nbeq $30,$0,L.1852\nla $4,L.687\nmove $5,$23\njal printf\nL.1852:\nL.1850:\nla $20,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nsra $20,$20,$24\nla $24,1\nbeq $20,$24,L.1854\nla $23,281\nbeq $30,$0,L.1856\nla $4,L.687\nmove $5,$23\njal printf\nL.1856:\nL.1854:\nla $20,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nsra $20,$20,$24\nla $24,1\nbeq $20,$24,L.1858\nla $23,282\nbeq $30,$0,L.1860\nla $4,L.687\nmove $5,$23\njal printf\nL.1860:\nL.1858:\nla $20,5\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nsra $20,$20,$24\nla $24,1\nbeq $20,$24,L.1862\nla $23,283\nbeq $30,$0,L.1864\nla $4,L.687\nmove $5,$23\njal printf\nL.1864:\nL.1862:\nla $20,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nsra $20,$20,$24\nla $24,1\nbeq $20,$24,L.1866\nla $23,284\nbeq $30,$0,L.1868\nla $4,L.687\nmove $5,$23\njal printf\nL.1868:\nL.1866:\nla $20,5\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nsra $20,$20,$24\nla $24,1\nbeq $20,$24,L.1870\nla $23,285\nbeq $30,$0,L.1872\nla $4,L.687\nmove $5,$23\njal printf\nL.1872:\nL.1870:\nla $19,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nsra $19,$19,$24\nla $24,1\nbeq $19,$24,L.1874\nla $23,286\nbeq $30,$0,L.1876\nla $4,L.687\nmove $5,$23\njal printf\nL.1876:\nL.1874:\nla $19,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nsra $19,$19,$24\nla $24,1\nbeq $19,$24,L.1878\nla $23,287\nbeq $30,$0,L.1880\nla $4,L.687\nmove $5,$23\njal printf\nL.1880:\nL.1878:\nla $19,5\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nsra $19,$19,$24\nla $24,1\nbeq $19,$24,L.1882\nla $23,288\nbeq $30,$0,L.1884\nla $4,L.687\nmove $5,$23\njal printf\nL.1884:\nL.1882:\nla $19,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nsra $19,$19,$24\nla $24,1\nbeq $19,$24,L.1886\nla $23,289\nbeq $30,$0,L.1888\nla $4,L.687\nmove $5,$23\njal printf\nL.1888:\nL.1886:\nla $19,5\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nsra $19,$19,$24\nla $24,1\nbeq $19,$24,L.1890\nla $23,290\nbeq $30,$0,L.1892\nla $4,L.687\nmove $5,$23\njal printf\nL.1892:\nL.1890:\nla $18,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nsrl $18,$18,$24\nla $24,1\nbeq $18,$24,L.1894\nla $23,291\nbeq $30,$0,L.1896\nla $4,L.687\nmove $5,$23\njal printf\nL.1896:\nL.1894:\nla $18,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nsrl $18,$18,$24\nla $24,1\nbeq $18,$24,L.1898\nla $23,292\nbeq $30,$0,L.1900\nla $4,L.687\nmove $5,$23\njal printf\nL.1900:\nL.1898:\nla $18,5\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nsrl $18,$18,$24\nla $24,1\nbeq $18,$24,L.1902\nla $23,293\nbeq $30,$0,L.1904\nla $4,L.687\nmove $5,$23\njal printf\nL.1904:\nL.1902:\nla $18,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nsrl $18,$18,$24\nla $24,1\nbeq $18,$24,L.1906\nla $23,294\nbeq $30,$0,L.1908\nla $4,L.687\nmove $5,$23\njal printf\nL.1908:\nL.1906:\nla $18,5\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nsrl $18,$18,$24\nla $24,1\nbeq $18,$24,L.1910\nla $23,295\nbeq $30,$0,L.1912\nla $4,L.687\nmove $5,$23\njal printf\nL.1912:\nL.1910:\nla $22,5\nla $17,2\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\nsll $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,20\nbeq $24,$15,L.1914\nla $23,296\nbeq $30,$0,L.1916\nla $4,L.687\nmove $5,$23\njal printf\nL.1916:\nL.1914:\nla $22,5\nla $16,2\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\nsll $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,20\nbeq $24,$15,L.1918\nla $23,297\nbeq $30,$0,L.1920\nla $4,L.687\nmove $5,$23\njal printf\nL.1920:\nL.1918:\nla $22,5\nla $24,2\nsw $24,-4+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-4+160($sp)\nsll $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,20\nbeq $24,$15,L.1922\nla $23,298\nbeq $30,$0,L.1924\nla $4,L.687\nmove $5,$23\njal printf\nL.1924:\nL.1922:\nla $22,5\nla $24,2\nsw $24,-8+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-8+160($sp)\nsll $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,20\nbeq $24,$15,L.1926\nla $23,299\nbeq $30,$0,L.1928\nla $4,L.687\nmove $5,$23\njal printf\nL.1928:\nL.1926:\nla $22,5\nla $24,2\nsw $24,-12+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-12+160($sp)\nsll $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,20\nbeq $24,$15,L.1930\nla $23,300\nbeq $30,$0,L.1932\nla $4,L.687\nmove $5,$23\njal printf\nL.1932:\nL.1930:\nla $21,5\nla $17,2\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\nsll $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,20\nbeq $24,$15,L.1934\nla $23,301\nbeq $30,$0,L.1936\nla $4,L.687\nmove $5,$23\njal printf\nL.1936:\nL.1934:\nla $21,5\nla $16,2\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\nsll $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,20\nbeq $24,$15,L.1938\nla $23,302\nbeq $30,$0,L.1940\nla $4,L.687\nmove $5,$23\njal printf\nL.1940:\nL.1938:\nla $21,5\nla $24,2\nsw $24,-4+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-4+160($sp)\nsll $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,20\nbeq $24,$15,L.1942\nla $23,303\nbeq $30,$0,L.1944\nla $4,L.687\nmove $5,$23\njal printf\nL.1944:\nL.1942:\nla $21,5\nla $24,2\nsw $24,-8+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-8+160($sp)\nsll $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,20\nbeq $24,$15,L.1946\nla $23,304\nbeq $30,$0,L.1948\nla $4,L.687\nmove $5,$23\njal printf\nL.1948:\nL.1946:\nla $21,5\nla $24,2\nsw $24,-12+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-12+160($sp)\nsll $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,20\nbeq $24,$15,L.1950\nla $23,305\nbeq $30,$0,L.1952\nla $4,L.687\nmove $5,$23\njal printf\nL.1952:\nL.1950:\nla $20,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nsll $20,$20,$24\nla $24,20\nbeq $20,$24,L.1954\nla $23,306\nbeq $30,$0,L.1956\nla $4,L.687\nmove $5,$23\njal printf\nL.1956:\nL.1954:\nla $20,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nsll $20,$20,$24\nla $24,20\nbeq $20,$24,L.1958\nla $23,307\nbeq $30,$0,L.1960\nla $4,L.687\nmove $5,$23\njal printf\nL.1960:\nL.1958:\nla $20,5\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nsll $20,$20,$24\nla $24,20\nbeq $20,$24,L.1962\nla $23,308\nbeq $30,$0,L.1964\nla $4,L.687\nmove $5,$23\njal printf\nL.1964:\nL.1962:\nla $20,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nsll $20,$20,$24\nla $24,20\nbeq $20,$24,L.1966\nla $23,309\nbeq $30,$0,L.1968\nla $4,L.687\nmove $5,$23\njal printf\nL.1968:\nL.1966:\nla $20,5\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nsll $20,$20,$24\nla $24,20\nbeq $20,$24,L.1970\nla $23,310\nbeq $30,$0,L.1972\nla $4,L.687\nmove $5,$23\njal printf\nL.1972:\nL.1970:\nla $19,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nsll $19,$19,$24\nla $24,20\nbeq $19,$24,L.1974\nla $23,311\nbeq $30,$0,L.1976\nla $4,L.687\nmove $5,$23\njal printf\nL.1976:\nL.1974:\nla $19,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nsll $19,$19,$24\nla $24,20\nbeq $19,$24,L.1978\nla $23,312\nbeq $30,$0,L.1980\nla $4,L.687\nmove $5,$23\njal printf\nL.1980:\nL.1978:\nla $19,5\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nsll $19,$19,$24\nla $24,20\nbeq $19,$24,L.1982\nla $23,313\nbeq $30,$0,L.1984\nla $4,L.687\nmove $5,$23\njal printf\nL.1984:\nL.1982:\nla $19,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nsll $19,$19,$24\nla $24,20\nbeq $19,$24,L.1986\nla $23,314\nbeq $30,$0,L.1988\nla $4,L.687\nmove $5,$23\njal printf\nL.1988:\nL.1986:\nla $19,5\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nsll $19,$19,$24\nla $24,20\nbeq $19,$24,L.1990\nla $23,315\nbeq $30,$0,L.1992\nla $4,L.687\nmove $5,$23\njal printf\nL.1992:\nL.1990:\nla $18,5\nla $17,2\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nsll $18,$18,$24\nla $24,20\nbeq $18,$24,L.1994\nla $23,316\nbeq $30,$0,L.1996\nla $4,L.687\nmove $5,$23\njal printf\nL.1996:\nL.1994:\nla $18,5\nla $16,2\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nsll $18,$18,$24\nla $24,20\nbeq $18,$24,L.1998\nla $23,317\nbeq $30,$0,L.2000\nla $4,L.687\nmove $5,$23\njal printf\nL.2000:\nL.1998:\nla $18,5\nla $24,2\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nsll $18,$18,$24\nla $24,20\nbeq $18,$24,L.2002\nla $23,318\nbeq $30,$0,L.2004\nla $4,L.687\nmove $5,$23\njal printf\nL.2004:\nL.2002:\nla $18,5\nla $24,2\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nsll $18,$18,$24\nla $24,20\nbeq $18,$24,L.2006\nla $23,319\nbeq $30,$0,L.2008\nla $4,L.687\nmove $5,$23\njal printf\nL.2008:\nL.2006:\nla $18,5\nla $24,2\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nsll $18,$18,$24\nla $24,20\nbeq $18,$24,L.2010\nla $23,320\nbeq $30,$0,L.2012\nla $4,L.687\nmove $5,$23\njal printf\nL.2012:\nL.2010:\nla $22,12\nla $17,10\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\nand $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,8\nbeq $24,$15,L.2014\nla $23,321\nbeq $30,$0,L.2016\nla $4,L.687\nmove $5,$23\njal printf\nL.2016:\nL.2014:\nla $22,12\nla $16,10\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\nand $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,8\nbeq $24,$15,L.2018\nla $23,322\nbeq $30,$0,L.2020\nla $4,L.687\nmove $5,$23\njal printf\nL.2020:\nL.2018:\nla $22,12\nla $24,10\nsw $24,-4+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-4+160($sp)\nand $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,8\nbeq $24,$15,L.2022\nla $23,323\nbeq $30,$0,L.2024\nla $4,L.687\nmove $5,$23\njal printf\nL.2024:\nL.2022:\nla $22,12\nla $24,10\nsw $24,-8+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-8+160($sp)\nand $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,8\nbeq $24,$15,L.2026\nla $23,324\nbeq $30,$0,L.2028\nla $4,L.687\nmove $5,$23\njal printf\nL.2028:\nL.2026:\nla $22,12\nla $24,10\nsw $24,-12+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-12+160($sp)\nand $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,8\nbeq $24,$15,L.2030\nla $23,325\nbeq $30,$0,L.2032\nla $4,L.687\nmove $5,$23\njal printf\nL.2032:\nL.2030:\nla $21,12\nla $17,10\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\nand $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,8\nbeq $24,$15,L.2034\nla $23,326\nbeq $30,$0,L.2036\nla $4,L.687\nmove $5,$23\njal printf\nL.2036:\nL.2034:\nla $21,12\nla $16,10\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\nand $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,8\nbeq $24,$15,L.2038\nla $23,327\nbeq $30,$0,L.2040\nla $4,L.687\nmove $5,$23\njal printf\nL.2040:\nL.2038:\nla $21,12\nla $24,10\nsw $24,-4+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-4+160($sp)\nand $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,8\nbeq $24,$15,L.2042\nla $23,328\nbeq $30,$0,L.2044\nla $4,L.687\nmove $5,$23\njal printf\nL.2044:\nL.2042:\nla $21,12\nla $24,10\nsw $24,-8+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-8+160($sp)\nand $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,8\nbeq $24,$15,L.2046\nla $23,329\nbeq $30,$0,L.2048\nla $4,L.687\nmove $5,$23\njal printf\nL.2048:\nL.2046:\nla $21,12\nla $24,10\nsw $24,-12+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-12+160($sp)\nand $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,8\nbeq $24,$15,L.2050\nla $23,330\nbeq $30,$0,L.2052\nla $4,L.687\nmove $5,$23\njal printf\nL.2052:\nL.2050:\nla $20,12\nla $17,10\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nand $20,$20,$24\nla $24,8\nbeq $20,$24,L.2054\nla $23,331\nbeq $30,$0,L.2056\nla $4,L.687\nmove $5,$23\njal printf\nL.2056:\nL.2054:\nla $20,12\nla $16,10\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nand $20,$20,$24\nla $24,8\nbeq $20,$24,L.2058\nla $23,332\nbeq $30,$0,L.2060\nla $4,L.687\nmove $5,$23\njal printf\nL.2060:\nL.2058:\nla $20,12\nla $24,10\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nand $20,$20,$24\nla $24,8\nbeq $20,$24,L.2062\nla $23,333\nbeq $30,$0,L.2064\nla $4,L.687\nmove $5,$23\njal printf\nL.2064:\nL.2062:\nla $20,12\nla $24,10\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nand $20,$20,$24\nla $24,8\nbeq $20,$24,L.2066\nla $23,334\nbeq $30,$0,L.2068\nla $4,L.687\nmove $5,$23\njal printf\nL.2068:\nL.2066:\nla $20,12\nla $24,10\nsw $24,-12+160($sp)\nmove $24,$20\nlw $15,-12+160($sp)\nand $24,$24,$15\nmove $20,$24\nla $24,8\nbeq $20,$24,L.2070\nla $23,335\nbeq $30,$0,L.2072\nla $4,L.687\nmove $5,$23\njal printf\nL.2072:\nL.2070:\nla $19,12\nla $17,10\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nand $19,$19,$24\nla $24,8\nbeq $19,$24,L.2074\nla $23,336\nbeq $30,$0,L.2076\nla $4,L.687\nmove $5,$23\njal printf\nL.2076:\nL.2074:\nla $19,12\nla $16,10\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nand $19,$19,$24\nla $24,8\nbeq $19,$24,L.2078\nla $23,337\nbeq $30,$0,L.2080\nla $4,L.687\nmove $5,$23\njal printf\nL.2080:\nL.2078:\nla $19,12\nla $24,10\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nand $19,$19,$24\nla $24,8\nbeq $19,$24,L.2082\nla $23,338\nbeq $30,$0,L.2084\nla $4,L.687\nmove $5,$23\njal printf\nL.2084:\nL.2082:\nla $19,12\nla $24,10\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nand $19,$19,$24\nla $24,8\nbeq $19,$24,L.2086\nla $23,339\nbeq $30,$0,L.2088\nla $4,L.687\nmove $5,$23\njal printf\nL.2088:\nL.2086:\nla $19,12\nla $24,10\nsw $24,-12+160($sp)\nmove $24,$19\nlw $15,-12+160($sp)\nand $24,$24,$15\nmove $19,$24\nla $24,8\nbeq $19,$24,L.2090\nla $23,340\nbeq $30,$0,L.2092\nla $4,L.687\nmove $5,$23\njal printf\nL.2092:\nL.2090:\nla $18,12\nla $17,10\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nand $18,$18,$24\nla $24,8\nbeq $18,$24,L.2094\nla $23,341\nbeq $30,$0,L.2096\nla $4,L.687\nmove $5,$23\njal printf\nL.2096:\nL.2094:\nla $18,12\nla $16,10\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nand $18,$18,$24\nla $24,8\nbeq $18,$24,L.2098\nla $23,342\nbeq $30,$0,L.2100\nla $4,L.687\nmove $5,$23\njal printf\nL.2100:\nL.2098:\nla $18,12\nla $24,10\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nand $18,$18,$24\nla $24,8\nbeq $18,$24,L.2102\nla $23,343\nbeq $30,$0,L.2104\nla $4,L.687\nmove $5,$23\njal printf\nL.2104:\nL.2102:\nla $18,12\nla $24,10\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nand $18,$18,$24\nla $24,8\nbeq $18,$24,L.2106\nla $23,344\nbeq $30,$0,L.2108\nla $4,L.687\nmove $5,$23\njal printf\nL.2108:\nL.2106:\nla $18,12\nla $24,10\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nand $18,$18,$24\nla $24,8\nbeq $18,$24,L.2110\nla $23,345\nbeq $30,$0,L.2112\nla $4,L.687\nmove $5,$23\njal printf\nL.2112:\nL.2110:\nla $22,12\nla $17,10\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\nxor $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,6\nbeq $24,$15,L.2114\nla $23,346\nbeq $30,$0,L.2116\nla $4,L.687\nmove $5,$23\njal printf\nL.2116:\nL.2114:\nla $22,12\nla $16,10\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\nxor $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,6\nbeq $24,$15,L.2118\nla $23,347\nbeq $30,$0,L.2120\nla $4,L.687\nmove $5,$23\njal printf\nL.2120:\nL.2118:\nla $22,12\nla $24,10\nsw $24,-4+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-4+160($sp)\nxor $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,6\nbeq $24,$15,L.2122\nla $23,348\nbeq $30,$0,L.2124\nla $4,L.687\nmove $5,$23\njal printf\nL.2124:\nL.2122:\nla $22,12\nla $24,10\nsw $24,-8+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-8+160($sp)\nxor $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,6\nbeq $24,$15,L.2126\nla $23,349\nbeq $30,$0,L.2128\nla $4,L.687\nmove $5,$23\njal printf\nL.2128:\nL.2126:\nla $22,12\nla $24,10\nsw $24,-12+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-12+160($sp)\nxor $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,6\nbeq $24,$15,L.2130\nla $23,350\nbeq $30,$0,L.2132\nla $4,L.687\nmove $5,$23\njal printf\nL.2132:\nL.2130:\nla $21,12\nla $17,10\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\nxor $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,6\nbeq $24,$15,L.2134\nla $23,351\nbeq $30,$0,L.2136\nla $4,L.687\nmove $5,$23\njal printf\nL.2136:\nL.2134:\nla $21,12\nla $16,10\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\nxor $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,6\nbeq $24,$15,L.2138\nla $23,352\nbeq $30,$0,L.2140\nla $4,L.687\nmove $5,$23\njal printf\nL.2140:\nL.2138:\nla $21,12\nla $24,10\nsw $24,-4+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-4+160($sp)\nxor $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,6\nbeq $24,$15,L.2142\nla $23,353\nbeq $30,$0,L.2144\nla $4,L.687\nmove $5,$23\njal printf\nL.2144:\nL.2142:\nla $21,12\nla $24,10\nsw $24,-8+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-8+160($sp)\nxor $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,6\nbeq $24,$15,L.2146\nla $23,354\nbeq $30,$0,L.2148\nla $4,L.687\nmove $5,$23\njal printf\nL.2148:\nL.2146:\nla $21,12\nla $24,10\nsw $24,-12+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-12+160($sp)\nxor $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,6\nbeq $24,$15,L.2150\nla $23,355\nbeq $30,$0,L.2152\nla $4,L.687\nmove $5,$23\njal printf\nL.2152:\nL.2150:\nla $20,12\nla $17,10\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nxor $20,$20,$24\nla $24,6\nbeq $20,$24,L.2154\nla $23,356\nbeq $30,$0,L.2156\nla $4,L.687\nmove $5,$23\njal printf\nL.2156:\nL.2154:\nla $20,12\nla $16,10\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nxor $20,$20,$24\nla $24,6\nbeq $20,$24,L.2158\nla $23,357\nbeq $30,$0,L.2160\nla $4,L.687\nmove $5,$23\njal printf\nL.2160:\nL.2158:\nla $20,12\nla $24,10\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nxor $20,$20,$24\nla $24,6\nbeq $20,$24,L.2162\nla $23,358\nbeq $30,$0,L.2164\nla $4,L.687\nmove $5,$23\njal printf\nL.2164:\nL.2162:\nla $20,12\nla $24,10\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nxor $20,$20,$24\nla $24,6\nbeq $20,$24,L.2166\nla $23,359\nbeq $30,$0,L.2168\nla $4,L.687\nmove $5,$23\njal printf\nL.2168:\nL.2166:\nla $20,12\nla $24,10\nsw $24,-12+160($sp)\nmove $24,$20\nlw $15,-12+160($sp)\nxor $24,$24,$15\nmove $20,$24\nla $24,6\nbeq $20,$24,L.2170\nla $23,360\nbeq $30,$0,L.2172\nla $4,L.687\nmove $5,$23\njal printf\nL.2172:\nL.2170:\nla $19,12\nla $17,10\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nxor $19,$19,$24\nla $24,6\nbeq $19,$24,L.2174\nla $23,361\nbeq $30,$0,L.2176\nla $4,L.687\nmove $5,$23\njal printf\nL.2176:\nL.2174:\nla $19,12\nla $16,10\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nxor $19,$19,$24\nla $24,6\nbeq $19,$24,L.2178\nla $23,362\nbeq $30,$0,L.2180\nla $4,L.687\nmove $5,$23\njal printf\nL.2180:\nL.2178:\nla $19,12\nla $24,10\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nxor $19,$19,$24\nla $24,6\nbeq $19,$24,L.2182\nla $23,363\nbeq $30,$0,L.2184\nla $4,L.687\nmove $5,$23\njal printf\nL.2184:\nL.2182:\nla $19,12\nla $24,10\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nxor $19,$19,$24\nla $24,6\nbeq $19,$24,L.2186\nla $23,364\nbeq $30,$0,L.2188\nla $4,L.687\nmove $5,$23\njal printf\nL.2188:\nL.2186:\nla $19,12\nla $24,10\nsw $24,-12+160($sp)\nmove $24,$19\nlw $15,-12+160($sp)\nxor $24,$24,$15\nmove $19,$24\nla $24,6\nbeq $19,$24,L.2190\nla $23,365\nbeq $30,$0,L.2192\nla $4,L.687\nmove $5,$23\njal printf\nL.2192:\nL.2190:\nla $18,12\nla $17,10\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nxor $18,$18,$24\nla $24,6\nbeq $18,$24,L.2194\nla $23,366\nbeq $30,$0,L.2196\nla $4,L.687\nmove $5,$23\njal printf\nL.2196:\nL.2194:\nla $18,12\nla $16,10\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nxor $18,$18,$24\nla $24,6\nbeq $18,$24,L.2198\nla $23,367\nbeq $30,$0,L.2200\nla $4,L.687\nmove $5,$23\njal printf\nL.2200:\nL.2198:\nla $18,12\nla $24,10\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nxor $18,$18,$24\nla $24,6\nbeq $18,$24,L.2202\nla $23,368\nbeq $30,$0,L.2204\nla $4,L.687\nmove $5,$23\njal printf\nL.2204:\nL.2202:\nla $18,12\nla $24,10\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nxor $18,$18,$24\nla $24,6\nbeq $18,$24,L.2206\nla $23,369\nbeq $30,$0,L.2208\nla $4,L.687\nmove $5,$23\njal printf\nL.2208:\nL.2206:\nla $18,12\nla $24,10\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nxor $18,$18,$24\nla $24,6\nbeq $18,$24,L.2210\nla $23,370\nbeq $30,$0,L.2212\nla $4,L.687\nmove $5,$23\njal printf\nL.2212:\nL.2210:\nla $22,12\nla $17,10\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\nor $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,14\nbeq $24,$15,L.2214\nla $23,371\nbeq $30,$0,L.2216\nla $4,L.687\nmove $5,$23\njal printf\nL.2216:\nL.2214:\nla $22,12\nla $16,10\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\nor $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,14\nbeq $24,$15,L.2218\nla $23,372\nbeq $30,$0,L.2220\nla $4,L.687\nmove $5,$23\njal printf\nL.2220:\nL.2218:\nla $22,12\nla $24,10\nsw $24,-4+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-4+160($sp)\nor $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,14\nbeq $24,$15,L.2222\nla $23,373\nbeq $30,$0,L.2224\nla $4,L.687\nmove $5,$23\njal printf\nL.2224:\nL.2222:\nla $22,12\nla $24,10\nsw $24,-8+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-8+160($sp)\nor $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,14\nbeq $24,$15,L.2226\nla $23,374\nbeq $30,$0,L.2228\nla $4,L.687\nmove $5,$23\njal printf\nL.2228:\nL.2226:\nla $22,12\nla $24,10\nsw $24,-12+160($sp)\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nlw $15,-12+160($sp)\nor $24,$24,$15\nmove $22,$24\nsll $24,$22,8*(4-1); sra $24,$24,8*(4-1)\nla $15,14\nbeq $24,$15,L.2230\nla $23,375\nbeq $30,$0,L.2232\nla $4,L.687\nmove $5,$23\njal printf\nL.2232:\nL.2230:\nla $21,12\nla $17,10\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\nor $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,14\nbeq $24,$15,L.2234\nla $23,376\nbeq $30,$0,L.2236\nla $4,L.687\nmove $5,$23\njal printf\nL.2236:\nL.2234:\nla $21,12\nla $16,10\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\nor $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,14\nbeq $24,$15,L.2238\nla $23,377\nbeq $30,$0,L.2240\nla $4,L.687\nmove $5,$23\njal printf\nL.2240:\nL.2238:\nla $21,12\nla $24,10\nsw $24,-4+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-4+160($sp)\nor $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,14\nbeq $24,$15,L.2242\nla $23,378\nbeq $30,$0,L.2244\nla $4,L.687\nmove $5,$23\njal printf\nL.2244:\nL.2242:\nla $21,12\nla $24,10\nsw $24,-8+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-8+160($sp)\nor $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,14\nbeq $24,$15,L.2246\nla $23,379\nbeq $30,$0,L.2248\nla $4,L.687\nmove $5,$23\njal printf\nL.2248:\nL.2246:\nla $21,12\nla $24,10\nsw $24,-12+160($sp)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,-12+160($sp)\nor $24,$24,$15\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,14\nbeq $24,$15,L.2250\nla $23,380\nbeq $30,$0,L.2252\nla $4,L.687\nmove $5,$23\njal printf\nL.2252:\nL.2250:\nla $20,12\nla $17,10\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nor $20,$20,$24\nla $24,14\nbeq $20,$24,L.2254\nla $23,381\nbeq $30,$0,L.2256\nla $4,L.687\nmove $5,$23\njal printf\nL.2256:\nL.2254:\nla $20,12\nla $16,10\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nor $20,$20,$24\nla $24,14\nbeq $20,$24,L.2258\nla $23,382\nbeq $30,$0,L.2260\nla $4,L.687\nmove $5,$23\njal printf\nL.2260:\nL.2258:\nla $20,12\nla $24,10\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nor $20,$20,$24\nla $24,14\nbeq $20,$24,L.2262\nla $23,383\nbeq $30,$0,L.2264\nla $4,L.687\nmove $5,$23\njal printf\nL.2264:\nL.2262:\nla $20,12\nla $24,10\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nor $20,$20,$24\nla $24,14\nbeq $20,$24,L.2266\nla $23,384\nbeq $30,$0,L.2268\nla $4,L.687\nmove $5,$23\njal printf\nL.2268:\nL.2266:\nla $20,12\nla $24,10\nsw $24,-12+160($sp)\nmove $24,$20\nlw $15,-12+160($sp)\nor $24,$24,$15\nmove $20,$24\nla $24,14\nbeq $20,$24,L.2270\nla $23,385\nbeq $30,$0,L.2272\nla $4,L.687\nmove $5,$23\njal printf\nL.2272:\nL.2270:\nla $19,12\nla $17,10\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nor $19,$19,$24\nla $24,14\nbeq $19,$24,L.2274\nla $23,386\nbeq $30,$0,L.2276\nla $4,L.687\nmove $5,$23\njal printf\nL.2276:\nL.2274:\nla $19,12\nla $16,10\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nor $19,$19,$24\nla $24,14\nbeq $19,$24,L.2278\nla $23,387\nbeq $30,$0,L.2280\nla $4,L.687\nmove $5,$23\njal printf\nL.2280:\nL.2278:\nla $19,12\nla $24,10\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nor $19,$19,$24\nla $24,14\nbeq $19,$24,L.2282\nla $23,388\nbeq $30,$0,L.2284\nla $4,L.687\nmove $5,$23\njal printf\nL.2284:\nL.2282:\nla $19,12\nla $24,10\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nor $19,$19,$24\nla $24,14\nbeq $19,$24,L.2286\nla $23,389\nbeq $30,$0,L.2288\nla $4,L.687\nmove $5,$23\njal printf\nL.2288:\nL.2286:\nla $19,12\nla $24,10\nsw $24,-12+160($sp)\nmove $24,$19\nlw $15,-12+160($sp)\nor $24,$24,$15\nmove $19,$24\nla $24,14\nbeq $19,$24,L.2290\nla $23,390\nbeq $30,$0,L.2292\nla $4,L.687\nmove $5,$23\njal printf\nL.2292:\nL.2290:\nla $18,12\nla $17,10\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nor $18,$18,$24\nla $24,14\nbeq $18,$24,L.2294\nla $23,391\nbeq $30,$0,L.2296\nla $4,L.687\nmove $5,$23\njal printf\nL.2296:\nL.2294:\nla $18,12\nla $16,10\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nor $18,$18,$24\nla $24,14\nbeq $18,$24,L.2298\nla $23,392\nbeq $30,$0,L.2300\nla $4,L.687\nmove $5,$23\njal printf\nL.2300:\nL.2298:\nla $18,12\nla $24,10\nsw $24,-4+160($sp)\nlw $24,-4+160($sp)\nor $18,$18,$24\nla $24,14\nbeq $18,$24,L.2302\nla $23,393\nbeq $30,$0,L.2304\nla $4,L.687\nmove $5,$23\njal printf\nL.2304:\nL.2302:\nla $18,12\nla $24,10\nsw $24,-8+160($sp)\nlw $24,-8+160($sp)\nor $18,$18,$24\nla $24,14\nbeq $18,$24,L.2306\nla $23,394\nbeq $30,$0,L.2308\nla $4,L.687\nmove $5,$23\njal printf\nL.2308:\nL.2306:\nla $18,12\nla $24,10\nsw $24,-12+160($sp)\nlw $24,-12+160($sp)\nor $18,$18,$24\nla $24,14\nbeq $18,$24,L.2310\nla $23,395\nbeq $30,$0,L.2312\nla $4,L.687\nmove $5,$23\njal printf\nL.2312:\nL.2310:\nbeq $23,$0,L.2314\nla $24,1\nsw $24,-24+160($sp)\nlw $24,0+160($sp)\nlw $24,44($24)\nbeq $24,$0,L.2316\nla $4,L.688\nla $5,1\njal printf\nL.2316:\nL.2314:\nlw $2,-24+160($sp)\nL.686:\nl.d $f24,16($sp)\nl.d $f26,24($sp)\nl.d $f28,32($sp)\nl.d $f30,40($sp)\nlw $16,48($sp)\nlw $17,52($sp)\nlw $18,56($sp)\nlw $19,60($sp)\nlw $20,64($sp)\nlw $21,68($sp)\nlw $22,72($sp)\nlw $23,76($sp)\nlw $25,80($sp)\nlw $30,84($sp)\nlw $31,88($sp)\naddu $sp,$sp,160\nj $31\n.end s714\n.data\n.align 0\nL.2319:\n.byte 115\n.byte 55\n.byte 49\n.byte 53\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.sdata\n.align 0\nL.2320:\n.byte 115\n.byte 55\n.byte 49\n.byte 53\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s715\n.text\n.text\n.align 2\n.ent s715\ns715:\n.frame $sp,56,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-56\n.mask 0xc2e00000,-20\nsw $21,16($sp)\nsw $22,20($sp)\nsw $23,24($sp)\n.cprestore 28\nsw $30,32($sp)\nsw $31,36($sp)\nsw $4,56($sp)\nsw $0,-12+56($sp)\nsw $0,-4+56($sp)\nla $30,L.2320\nlw $15,0+56($sp)\nla $23,60($15)\nmove $21,$0\nL.2321:\nL.2322:\nmove $24,$23\nla $23,1($24)\nmove $15,$30\nla $30,1($15)\nlb $15,($15)\nsb $15,($24)\nsll $24,$15,8*(4-1); sra $24,$24,8*(4-1)\nbne $24,$0,L.2321\nla $24,1\nmove $22,$24\nla $22,1($22)\nla $22,1($22)\nla $22,1($22)\nla $22,1($22)\nla $24,1($22)\nmove $22,$24\nla $15,6\nbeq $24,$15,L.2324\nlw $24,0+56($sp)\nlw $24,44($24)\nbeq $24,$0,L.2326\nla $4,L.2319\nla $5,1\njal printf\nL.2326:\nla $21,1($21)\nL.2324:\nlw $4,-4+56($sp)\nla $24,3\nsw $24,-8+56($sp)\nlw $24,-8+56($sp)\nla $5,2($24)\nlw $6,-12+56($sp)\njal s715f\nla $15,5\nbeq $2,$15,L.2328\nlw $24,0+56($sp)\nlw $24,44($24)\nbeq $24,$0,L.2330\nla $4,L.2319\nla $5,2\njal printf\nL.2330:\nla $21,2($21)\nL.2328:\nmove $2,$21\nL.2318:\nlw $21,16($sp)\nlw $22,20($sp)\nlw $23,24($sp)\nlw $25,28($sp)\nlw $30,32($sp)\nlw $31,36($sp)\naddu $sp,$sp,56\nj $31\n.end s715\n.globl s715f\n.text\n.align 2\n.ent s715f\ns715f:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nmove $2,$5\nL.2332:\nj $31\n.end s715f\n.data\n.align 0\nL.2334:\n.byte 115\n.byte 55\n.byte 50\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.sdata\n.align 0\nL.2335:\n.byte 115\n.byte 55\n.byte 50\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s72\n.text\n.text\n.align 2\n.ent s72\ns72:\n.frame $sp,96,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-96\n.fmask 0xf0000000,-72\n.mask 0xc2ff0000,-24\ns.d $f28,16($sp)\ns.d $f30,24($sp)\nsw $16,32($sp)\nsw $17,36($sp)\nsw $18,40($sp)\nsw $19,44($sp)\nsw $20,48($sp)\nsw $21,52($sp)\nsw $22,56($sp)\nsw $23,60($sp)\n.cprestore 64\nsw $30,68($sp)\nsw $31,72($sp)\nmove $30,$4\nla $22,L.2335\nla $21,60($30)\nmove $19,$0\nL.2336:\nL.2337:\nmove $24,$21\nla $21,1($24)\nmove $15,$22\nla $22,1($15)\nlb $15,($15)\nsb $15,($24)\nsll $24,$15,8*(4-1); sra $24,$24,8*(4-1)\nbne $24,$0,L.2336\nla $24,2\nsw $24,-4+96($sp)\nlw $15,-4+96($sp)\nbeq $15,$24,L.2339\nla $24,1\nla $19,1($19)\nla $4,L.2334\nmove $5,$24\njal printf\nL.2339:\nlw $24,-4+96($sp)\nnegu $15,$24\naddu $24,$24,$15\nbeq $24,$0,L.2341\nla $24,2\nla $19,2($19)\nla $4,L.2334\nmove $5,$24\njal printf\nL.2341:\nsw $0,-4+96($sp)\nmove $23,$0\nb L.2346\nL.2343:\nlw $24,-4+96($sp)\nsll $24,$24,1\nor $24,$24,1\nsw $24,-4+96($sp)\nL.2344:\nla $23,1($23)\nL.2346:\nlw $24,4($30)\nblt $23,$24,L.2343\nlw $24,-4+96($sp)\nnot $24,$24\nbeq $24,$0,L.2347\nla $24,4\nla $19,4($19)\nla $4,L.2334\nmove $5,$24\njal printf\nL.2347:\nla $24,5\nsw $24,-4+96($sp)\nlw $24,-4+96($sp)\nla $24,1($24)\nsw $24,-4+96($sp)\nla $15,6\nbne $24,$15,L.2354\nlw $24,-4+96($sp)\nsubu $24,$24,1\nsw $24,-4+96($sp)\nla $14,5\nbne $24,$14,L.2354\nlw $24,-4+96($sp)\nla $13,1($24)\nsw $13,-4+96($sp)\nbne $24,$14,L.2354\nlw $24,-4+96($sp)\nsubu $13,$24,1\nsw $13,-4+96($sp)\nbne $24,$15,L.2354\nlw $24,-4+96($sp)\nbeq $24,$14,L.2349\nL.2354:\nla $24,8\nla $19,8($19)\nla $4,L.2334\nmove $5,$24\njal printf\nL.2349:\nla $17,26\nla $24,26\nsw $24,-8+96($sp)\nl.d $f30,L.2355\nla $16,26\nla $24,26\nsw $24,-12+96($sp)\nla $18,26\nl.s $f28,L.2356\nmove $20,$0\nla $24,26\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\nsll $15,$15,8*(4-1); sra $15,$15,8*(4-1)\nbne $15,$24,L.2363\nmove $15,$18\nsll $15,$15,8*(4-1); sra $15,$15,8*(4-1)\nbne $15,$24,L.2363\nlw $15,-8+96($sp)\nsll $15,$15,8*(4-1); sra $15,$15,8*(4-1)\nbne $15,$24,L.2363\nlw $15,-12+96($sp)\nsll $15,$15,8*(4-1); sra $15,$15,8*(4-1)\nbne $15,$24,L.2363\ntrunc.w.s $f2,$f28,$15; mfc1 $15,$f2\nsll $15,$15,8*(4-1); sra $15,$15,8*(4-1)\nbne $15,$24,L.2363\ntrunc.w.d $f2,$f30,$15; mfc1 $15,$f2\nsll $15,$15,8*(4-1); sra $15,$15,8*(4-1)\nbeq $15,$24,L.2357\nL.2363:\nla $20,1($20)\nL.2357:\nla $24,26\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\nsll $15,$15,8*(4-2); sra $15,$15,8*(4-2)\nbne $15,$24,L.2370\nmove $15,$18\nsll $15,$15,8*(4-2); sra $15,$15,8*(4-2)\nbne $15,$24,L.2370\nlw $15,-8+96($sp)\nsll $15,$15,8*(4-2); sra $15,$15,8*(4-2)\nbne $15,$24,L.2370\nlw $15,-12+96($sp)\nsll $15,$15,8*(4-2); sra $15,$15,8*(4-2)\nbne $15,$24,L.2370\ntrunc.w.s $f2,$f28,$15; mfc1 $15,$f2\nsll $15,$15,8*(4-2); sra $15,$15,8*(4-2)\nbne $15,$24,L.2370\ntrunc.w.d $f2,$f30,$15; mfc1 $15,$f2\nsll $15,$15,8*(4-2); sra $15,$15,8*(4-2)\nbeq $15,$24,L.2364\nL.2370:\nla $20,2($20)\nL.2364:\nla $24,26\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\nbne $15,$24,L.2377\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\nbne $15,$24,L.2377\nlw $15,-8+96($sp)\nbne $15,$24,L.2377\nlw $15,-12+96($sp)\nbne $15,$24,L.2377\ntrunc.w.s $f2,$f28,$15; mfc1 $15,$f2\nbne $15,$24,L.2377\ntrunc.w.d $f2,$f30,$15; mfc1 $15,$f2\nbeq $15,$24,L.2371\nL.2377:\nla $20,4($20)\nL.2371:\nla $24,26\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\nbne $15,$24,L.2384\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\nbne $15,$24,L.2384\nbne $18,$24,L.2384\nlw $15,-12+96($sp)\nbne $15,$24,L.2384\ntrunc.w.s $f2,$f28,$15; mfc1 $15,$f2\nbne $15,$24,L.2384\ntrunc.w.d $f2,$f30,$15; mfc1 $15,$f2\nbeq $15,$24,L.2378\nL.2384:\nla $20,8($20)\nL.2378:\nla $24,26\nsll $15,$17,8*(4-1); sra $15,$15,8*(4-1)\nbne $15,$24,L.2393\nsll $15,$16,8*(4-2); sra $15,$15,8*(4-2)\nbne $15,$24,L.2393\nmove $15,$18\nbne $15,$24,L.2393\nlw $15,-8+96($sp)\nbne $15,$24,L.2393\nl.s $f18,L.828\nc.lt.s $f28,$f18; bc1t L.2394\nsub.s $f18,$f28,$f18\ntrunc.w.s $f2,$f18,$24; mfc1 $24,$f2\nla $24,0x80000000($24)\nsw $24,-16+96($sp)\nb L.2395\nL.2394:\ntrunc.w.s $f2,$f28,$24; mfc1 $24,$f2\nsw $24,-16+96($sp)\nL.2395:\nlw $24,-16+96($sp)\nla $15,26\nbne $24,$15,L.2393\nl.d $f18,L.836\nc.lt.d $f30,$f18; bc1t L.2396\nsub.d $f18,$f30,$f18\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nla $24,0x80000000($24)\nsw $24,-20+96($sp)\nb L.2397\nL.2396:\ntrunc.w.d $f2,$f30,$24; mfc1 $24,$f2\nsw $24,-20+96($sp)\nL.2397:\nlw $24,-20+96($sp)\nla $15,26\nbeq $24,$15,L.2385\nL.2393:\nla $20,16($20)\nL.2385:\nl.d $f18,L.2355\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f16; cvt.s.w $f16,$f16\ncvt.d.s $f16,$f16\nc.eq.d $f16,$f18; bc1f L.2404\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nmtc1 $24,$f16; cvt.s.w $f16,$f16\ncvt.d.s $f16,$f16\nc.eq.d $f16,$f18; bc1f L.2404\nmtc1 $18,$f16; cvt.s.w $f16,$f16\ncvt.d.s $f16,$f16\nc.eq.d $f16,$f18; bc1f L.2404\nlw $24,-8+96($sp)\nmtc1 $24,$f16; cvt.s.w $f16,$f16\ncvt.d.s $f16,$f16\nc.eq.d $f16,$f18; bc1f L.2404\nlw $24,-12+96($sp)\nl.d $f16,L.596\nsrl $15,$24,1\nmtc1 $15,$f10; cvt.d.w $f10,$f10\nmul.d $f16,$f16,$f10\nand $24,$24,1\nmtc1 $24,$f10; cvt.d.w $f10,$f10\nadd.d $f16,$f16,$f10\ncvt.s.d $f16,$f16\ncvt.d.s $f16,$f16\nc.eq.d $f16,$f18; bc1f L.2404\ncvt.s.d $f16,$f30\ncvt.d.s $f16,$f16\nc.eq.d $f16,$f18; bc1t L.2398\nL.2404:\nla $20,32($20)\nL.2398:\nl.d $f18,L.2355\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nc.eq.d $f16,$f18; bc1f L.2411\nsll $24,$16,8*(4-2); sra $24,$24,8*(4-2)\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nc.eq.d $f16,$f18; bc1f L.2411\nmtc1 $18,$f16; cvt.d.w $f16,$f16\nc.eq.d $f16,$f18; bc1f L.2411\nlw $24,-8+96($sp)\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nc.eq.d $f16,$f18; bc1f L.2411\nlw $24,-12+96($sp)\nl.d $f16,L.596\nsrl $15,$24,1\nmtc1 $15,$f10; cvt.d.w $f10,$f10\nmul.d $f16,$f16,$f10\nand $24,$24,1\nmtc1 $24,$f10; cvt.d.w $f10,$f10\nadd.d $f16,$f16,$f10\nc.eq.d $f16,$f18; bc1f L.2411\ncvt.d.s $f16,$f28\nc.eq.d $f16,$f18; bc1t L.2405\nL.2411:\nla $20,64($20)\nL.2405:\nbeq $20,$0,L.2412\nla $24,16\nla $19,16($19)\nla $4,L.2334\nmove $5,$24\njal printf\nL.2412:\nmove $2,$19\nL.2333:\nl.d $f28,16($sp)\nl.d $f30,24($sp)\nlw $16,32($sp)\nlw $17,36($sp)\nlw $18,40($sp)\nlw $19,44($sp)\nlw $20,48($sp)\nlw $21,52($sp)\nlw $22,56($sp)\nlw $23,60($sp)\nlw $25,64($sp)\nlw $30,68($sp)\nlw $31,72($sp)\naddu $sp,$sp,96\nj $31\n.end s72\n.data\n.align 0\nL.2415:\n.byte 115\n.byte 55\n.byte 53\n.byte 55\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.sdata\n.align 0\nL.2416:\n.byte 115\n.byte 55\n.byte 53\n.byte 55\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s757\n.text\n.text\n.align 2\n.ent s757\ns757:\n.frame $sp,176,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-176\n.mask 0xc2ff0000,-120\nsw $16,16($sp)\nsw $17,20($sp)\nsw $18,24($sp)\nsw $19,28($sp)\nsw $20,32($sp)\nsw $21,36($sp)\nsw $22,40($sp)\nsw $23,44($sp)\n.cprestore 48\nsw $30,52($sp)\nsw $31,56($sp)\nmove $30,$4\nla $24,L.2416\nsw $24,-80+176($sp)\nla $24,60($30)\nsw $24,-84+176($sp)\nsw $0,-88+176($sp)\nL.2417:\nL.2418:\nlw $24,-84+176($sp)\nla $15,1($24)\nsw $15,-84+176($sp)\nlw $15,-80+176($sp)\nla $14,1($15)\nsw $14,-80+176($sp)\nlb $15,($15)\nsb $15,($24)\nsll $24,$15,8*(4-1); sra $24,$24,8*(4-1)\nbne $24,$0,L.2417\nla $24,40\nsw $24,-92+176($sp)\nlw $24,-92+176($sp)\nsll $15,$24,3\nsll $15,$15,2\nla $14,1280\nbne $15,$14,L.2422\nsra $24,$24,3\nsra $24,$24,2\nla $15,1\nbeq $24,$15,L.2420\nL.2422:\nlw $24,-88+176($sp)\nla $24,1($24)\nsw $24,-88+176($sp)\nlw $24,44($30)\nbeq $24,$0,L.2423\nla $4,L.2415\nla $5,1\njal printf\nL.2423:\nL.2420:\nmove $19,$0\nsw $0,-68+176($sp)\nb L.2428\nL.2425:\nla $17,1\nlw $24,16($30)\nsubu $24,$24,1\nsll $16,$17,$24\nsw $0,-72+176($sp)\nlw $24,-72+176($sp)\nnot $24,$24\nlw $15,-68+176($sp)\nsrl $14,$24,$15\nsw $14,-76+176($sp)\nsll $24,$24,$15\nsw $24,-72+176($sp)\nmove $18,$0\nb L.2432\nL.2429:\nlw $24,-68+176($sp)\nbge $18,$24,L.2440\nla $24,1\nsw $24,-100+176($sp)\nb L.2441\nL.2440:\nsw $0,-100+176($sp)\nL.2441:\nlw $24,-72+176($sp)\nand $24,$17,$24\nbne $24,$0,L.2442\nla $24,1\nsw $24,-104+176($sp)\nb L.2443\nL.2442:\nsw $0,-104+176($sp)\nL.2443:\nlw $24,-100+176($sp)\nlw $15,-104+176($sp)\nbne $24,$15,L.2439\nlw $24,-68+176($sp)\nbge $18,$24,L.2444\nla $24,1\nsw $24,-108+176($sp)\nb L.2445\nL.2444:\nsw $0,-108+176($sp)\nL.2445:\nlw $24,-76+176($sp)\nand $24,$16,$24\nbne $24,$0,L.2446\nla $24,1\nsw $24,-112+176($sp)\nb L.2447\nL.2446:\nsw $0,-112+176($sp)\nL.2447:\nlw $24,-108+176($sp)\nlw $15,-112+176($sp)\nbeq $24,$15,L.2433\nL.2439:\nla $19,1\nL.2433:\nsll $17,$17,1\nsrl $16,$16,1\nL.2430:\nla $18,1($18)\nL.2432:\nlw $24,16($30)\nblt $18,$24,L.2429\nL.2426:\nlw $24,-68+176($sp)\nla $24,1($24)\nsw $24,-68+176($sp)\nL.2428:\nlw $24,-68+176($sp)\nlw $15,16($30)\nblt $24,$15,L.2425\nbeq $19,$0,L.2448\nlw $24,-88+176($sp)\nla $24,2($24)\nsw $24,-88+176($sp)\nlw $24,44($30)\nbeq $24,$0,L.2450\nla $4,L.2415\nla $5,2\njal printf\nL.2450:\nL.2448:\nla $20,3\nla $21,2\nla $22,1\nbge $20,$21,L.2458\nla $24,1\nsw $24,-104+176($sp)\nb L.2459\nL.2458:\nsw $0,-104+176($sp)\nL.2459:\nlw $24,-104+176($sp)\nbge $24,$22,L.2456\nla $24,1\nsw $24,-100+176($sp)\nb L.2457\nL.2456:\nsw $0,-100+176($sp)\nL.2457:\nlw $24,-100+176($sp)\nla $15,1\nbeq $24,$15,L.2452\nlw $24,-88+176($sp)\nla $24,4($24)\nsw $24,-88+176($sp)\nlw $24,44($30)\nbeq $24,$0,L.2460\nla $4,L.2415\nla $5,4\njal printf\nL.2460:\nL.2452:\nla $24,-60+176($sp)\nla $15,-64+176($sp)\nbne $24,$15,L.2462\nlw $24,-88+176($sp)\nla $24,8($24)\nsw $24,-88+176($sp)\nlw $24,44($30)\nbeq $24,$0,L.2465\nla $4,L.2415\nla $5,8\njal printf\nL.2465:\nL.2462:\nla $24,-60+176($sp)\nla $15,-64+176($sp)\nbgeu $24,$15,L.2467\nlw $24,40($30)\nbeq $24,$0,L.2470\nla $4,L.2472\njal printf\nL.2470:\nL.2467:\nmove $19,$0\nmove $18,$0\nL.2473:\nsll $24,$18,2\nla $15,-64+176($sp)\naddu $24,$24,$15\nla $15,1\nsw $15,($24)\nL.2474:\nla $18,1($18)\nla $24,16\nblt $18,$24,L.2473\nsw $0,-60+176($sp)\nsw $0,-48+176($sp)\nsw $0,-40+176($sp)\nsw $0,-36+176($sp)\nsw $0,-28+176($sp)\nsw $0,-12+176($sp)\nmove $20,$0\nL.2483:\nmove $21,$0\nL.2487:\nmove $22,$0\nL.2491:\nmove $23,$0\nL.2495:\nbge $20,$21,L.2506\nla $24,1\nsw $24,-112+176($sp)\nb L.2507\nL.2506:\nsw $0,-112+176($sp)\nL.2507:\nbge $22,$23,L.2508\nla $24,1\nsw $24,-116+176($sp)\nb L.2509\nL.2508:\nsw $0,-116+176($sp)\nL.2509:\nlw $24,-112+176($sp)\nlw $15,-116+176($sp)\nbne $24,$15,L.2504\nla $24,1\nsw $24,-108+176($sp)\nb L.2505\nL.2504:\nsw $0,-108+176($sp)\nL.2505:\nlw $24,-108+176($sp)\nsll $15,$20,3\nsll $14,$21,2\naddu $15,$15,$14\nsll $14,$22,1\naddu $15,$15,$14\naddu $15,$15,$23\nsll $15,$15,2\nla $14,-64+176($sp)\naddu $15,$15,$14\nlw $15,($15)\nbeq $24,$15,L.2499\nla $19,1\nL.2499:\nL.2496:\nla $23,1($23)\nla $24,2\nblt $23,$24,L.2495\nL.2492:\nla $22,1($22)\nla $24,2\nblt $22,$24,L.2491\nL.2488:\nla $21,1($21)\nla $24,2\nblt $21,$24,L.2487\nL.2484:\nla $20,1($20)\nla $24,2\nblt $20,$24,L.2483\nbeq $19,$0,L.2510\nlw $24,-88+176($sp)\nla $24,16($24)\nsw $24,-88+176($sp)\nlw $24,44($30)\nbeq $24,$0,L.2512\nla $4,L.2415\nla $5,16\njal printf\nL.2512:\nL.2510:\nsw $0,-96+176($sp)\nlw $24,-96+176($sp)\nbeq $24,$0,L.2514\nlw $24,-88+176($sp)\nla $24,32($24)\nsw $24,-88+176($sp)\nlw $24,44($30)\nbeq $24,$0,L.2516\nla $4,L.2415\nla $5,32\njal printf\nL.2516:\nL.2514:\nlw $2,-88+176($sp)\nL.2414:\nlw $16,16($sp)\nlw $17,20($sp)\nlw $18,24($sp)\nlw $19,28($sp)\nlw $20,32($sp)\nlw $21,36($sp)\nlw $22,40($sp)\nlw $23,44($sp)\nlw $25,48($sp)\nlw $30,52($sp)\nlw $31,56($sp)\naddu $sp,$sp,176\nj $31\n.end s757\n.data\n.align 0\nL.2519:\n.byte 76\n.byte 111\n.byte 99\n.byte 97\n.byte 108\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 37\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.data\n.align 0\nL.2520:\n.byte 115\n.byte 55\n.byte 56\n.byte 49\n.byte 51\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.sdata\n.align 0\nL.2521:\n.byte 115\n.byte 55\n.byte 56\n.byte 49\n.byte 51\n.byte 32\n.byte 32\n.byte 0\n.globl s7813\n.text\n.text\n.align 2\n.ent s7813\ns7813:\n.frame $sp,112,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-112\n.mask 0xc2ff0000,-56\nsw $16,16($sp)\nsw $17,20($sp)\nsw $18,24($sp)\nsw $19,28($sp)\nsw $20,32($sp)\nsw $21,36($sp)\nsw $22,40($sp)\nsw $23,44($sp)\n.cprestore 48\nsw $30,52($sp)\nsw $31,56($sp)\nsw $4,112($sp)\nla $19,L.2521\nlw $24,0+112($sp)\nla $18,60($24)\nmove $23,$0\nmove $17,$0\nlw $30,48($24)\nL.2522:\nL.2523:\nmove $24,$18\nla $18,1($24)\nmove $15,$19\nla $19,1($15)\nlb $15,($15)\nsb $15,($24)\nsll $24,$15,8*(4-1); sra $24,$24,8*(4-1)\nbne $24,$0,L.2522\nb L.2525\nla $23,1\nbeq $30,$0,L.2527\nla $4,L.2519\nmove $5,$23\njal printf\nL.2527:\nL.2525:\nb L.2529\nla $23,2\nbeq $30,$0,L.2531\nla $4,L.2519\nmove $5,$23\njal printf\nL.2531:\nL.2529:\nb L.2533\nla $23,3\nbeq $30,$0,L.2535\nla $4,L.2519\nmove $5,$23\njal printf\nL.2535:\nL.2533:\nb L.2537\nla $23,4\nbeq $30,$0,L.2539\nla $4,L.2519\nmove $5,$23\njal printf\nL.2539:\nL.2537:\nb L.2541\nla $23,5\nbeq $30,$0,L.2543\nla $4,L.2519\nmove $5,$23\njal printf\nL.2543:\nL.2541:\nb L.2545\nla $23,6\nbeq $30,$0,L.2547\nla $4,L.2519\nmove $5,$23\njal printf\nL.2547:\nL.2545:\nb L.2549\nla $23,7\nbeq $30,$0,L.2551\nla $4,L.2519\nmove $5,$23\njal printf\nL.2551:\nL.2549:\nb L.2553\nla $23,8\nbeq $30,$0,L.2555\nla $4,L.2519\nmove $5,$23\njal printf\nL.2555:\nL.2553:\nb L.2557\nla $23,9\nbeq $30,$0,L.2559\nla $4,L.2519\nmove $5,$23\njal printf\nL.2559:\nL.2557:\nb L.2561\nla $23,10\nbeq $30,$0,L.2563\nla $4,L.2519\nmove $5,$23\njal printf\nL.2563:\nL.2561:\nb L.2565\nla $23,11\nbeq $30,$0,L.2567\nla $4,L.2519\nmove $5,$23\njal printf\nL.2567:\nL.2565:\nb L.2569\nla $23,12\nbeq $30,$0,L.2571\nla $4,L.2519\nmove $5,$23\njal printf\nL.2571:\nL.2569:\nb L.2573\nla $23,13\nbeq $30,$0,L.2575\nla $4,L.2519\nmove $5,$23\njal printf\nL.2575:\nL.2573:\nb L.2577\nla $23,14\nbeq $30,$0,L.2579\nla $4,L.2519\nmove $5,$23\njal printf\nL.2579:\nL.2577:\nb L.2581\nla $23,15\nbeq $30,$0,L.2583\nla $4,L.2519\nmove $5,$23\njal printf\nL.2583:\nL.2581:\nb L.2585\nla $23,16\nbeq $30,$0,L.2587\nla $4,L.2519\nmove $5,$23\njal printf\nL.2587:\nL.2585:\nb L.2589\nla $23,17\nbeq $30,$0,L.2591\nla $4,L.2519\nmove $5,$23\njal printf\nL.2591:\nL.2589:\nb L.2593\nla $23,18\nbeq $30,$0,L.2595\nla $4,L.2519\nmove $5,$23\njal printf\nL.2595:\nL.2593:\nb L.2597\nla $23,16\nbeq $30,$0,L.2599\nla $4,L.2519\nmove $5,$23\njal printf\nL.2599:\nL.2597:\nb L.2601\nla $23,20\nbeq $30,$0,L.2603\nla $4,L.2519\nmove $5,$23\njal printf\nL.2603:\nL.2601:\nb L.2605\nla $23,21\nbeq $30,$0,L.2607\nla $4,L.2519\nmove $5,$23\njal printf\nL.2607:\nL.2605:\nb L.2609\nla $23,22\nbeq $30,$0,L.2611\nla $4,L.2519\nmove $5,$23\njal printf\nL.2611:\nL.2609:\nb L.2613\nla $23,23\nbeq $30,$0,L.2615\nla $4,L.2519\nmove $5,$23\njal printf\nL.2615:\nL.2613:\nb L.2617\nla $23,24\nbeq $30,$0,L.2619\nla $4,L.2519\nmove $5,$23\njal printf\nL.2619:\nL.2617:\nb L.2621\nla $23,25\nbeq $30,$0,L.2623\nla $4,L.2519\nmove $5,$23\njal printf\nL.2623:\nL.2621:\nb L.2625\nla $23,26\nbeq $30,$0,L.2627\nla $4,L.2519\nmove $5,$23\njal printf\nL.2627:\nL.2625:\nb L.2629\nla $23,27\nbeq $30,$0,L.2631\nla $4,L.2519\nmove $5,$23\njal printf\nL.2631:\nL.2629:\nb L.2633\nla $23,28\nbeq $30,$0,L.2635\nla $4,L.2519\nmove $5,$23\njal printf\nL.2635:\nL.2633:\nb L.2637\nla $23,26\nbeq $30,$0,L.2639\nla $4,L.2519\nmove $5,$23\njal printf\nL.2639:\nL.2637:\nb L.2641\nla $23,30\nbeq $30,$0,L.2643\nla $4,L.2519\nmove $5,$23\njal printf\nL.2643:\nL.2641:\nb L.2645\nla $23,31\nbeq $30,$0,L.2647\nla $4,L.2519\nmove $5,$23\njal printf\nL.2647:\nL.2645:\nb L.2649\nla $23,32\nbeq $30,$0,L.2651\nla $4,L.2519\nmove $5,$23\njal printf\nL.2651:\nL.2649:\nb L.2653\nla $23,33\nbeq $30,$0,L.2655\nla $4,L.2519\nmove $5,$23\njal printf\nL.2655:\nL.2653:\nb L.2657\nla $23,34\nbeq $30,$0,L.2659\nla $4,L.2519\nmove $5,$23\njal printf\nL.2659:\nL.2657:\nb L.2661\nla $23,35\nbeq $30,$0,L.2663\nla $4,L.2519\nmove $5,$23\njal printf\nL.2663:\nL.2661:\nb L.2665\nla $23,36\nbeq $30,$0,L.2667\nla $4,L.2519\nmove $5,$23\njal printf\nL.2667:\nL.2665:\nb L.2669\nla $23,37\nbeq $30,$0,L.2671\nla $4,L.2519\nmove $5,$23\njal printf\nL.2671:\nL.2669:\nb L.2673\nla $23,38\nbeq $30,$0,L.2675\nla $4,L.2519\nmove $5,$23\njal printf\nL.2675:\nL.2673:\nb L.2677\nla $23,39\nbeq $30,$0,L.2679\nla $4,L.2519\nmove $5,$23\njal printf\nL.2679:\nL.2677:\nb L.2681\nla $23,40\nbeq $30,$0,L.2683\nla $4,L.2519\nmove $5,$23\njal printf\nL.2683:\nL.2681:\nb L.2685\nla $23,41\nbeq $30,$0,L.2687\nla $4,L.2519\nmove $5,$23\njal printf\nL.2687:\nL.2685:\nb L.2689\nla $23,42\nbeq $30,$0,L.2691\nla $4,L.2519\nmove $5,$23\njal printf\nL.2691:\nL.2689:\nb L.2693\nla $23,43\nbeq $30,$0,L.2695\nla $4,L.2519\nmove $5,$23\njal printf\nL.2695:\nL.2693:\nb L.2697\nla $23,44\nbeq $30,$0,L.2699\nla $4,L.2519\nmove $5,$23\njal printf\nL.2699:\nL.2697:\nb L.2701\nla $23,45\nbeq $30,$0,L.2703\nla $4,L.2519\nmove $5,$23\njal printf\nL.2703:\nL.2701:\nb L.2705\nla $23,46\nbeq $30,$0,L.2707\nla $4,L.2519\nmove $5,$23\njal printf\nL.2707:\nL.2705:\nb L.2709\nla $23,47\nbeq $30,$0,L.2711\nla $4,L.2519\nmove $5,$23\njal printf\nL.2711:\nL.2709:\nb L.2713\nla $23,48\nbeq $30,$0,L.2715\nla $4,L.2519\nmove $5,$23\njal printf\nL.2715:\nL.2713:\nb L.2717\nla $23,49\nbeq $30,$0,L.2719\nla $4,L.2519\nmove $5,$23\njal printf\nL.2719:\nL.2717:\nb L.2721\nla $23,50\nbeq $30,$0,L.2723\nla $4,L.2519\nmove $5,$23\njal printf\nL.2723:\nL.2721:\nb L.2725\nla $23,51\nbeq $30,$0,L.2727\nla $4,L.2519\nmove $5,$23\njal printf\nL.2727:\nL.2725:\nb L.2729\nla $23,52\nbeq $30,$0,L.2731\nla $4,L.2519\nmove $5,$23\njal printf\nL.2731:\nL.2729:\nb L.2733\nla $23,53\nbeq $30,$0,L.2735\nla $4,L.2519\nmove $5,$23\njal printf\nL.2735:\nL.2733:\nb L.2737\nla $23,54\nbeq $30,$0,L.2739\nla $4,L.2519\nmove $5,$23\njal printf\nL.2739:\nL.2737:\nb L.2741\nla $23,55\nbeq $30,$0,L.2743\nla $4,L.2519\nmove $5,$23\njal printf\nL.2743:\nL.2741:\nb L.2745\nla $23,56\nbeq $30,$0,L.2747\nla $4,L.2519\nmove $5,$23\njal printf\nL.2747:\nL.2745:\nb L.2749\nla $23,57\nbeq $30,$0,L.2751\nla $4,L.2519\nmove $5,$23\njal printf\nL.2751:\nL.2749:\nb L.2753\nla $23,58\nbeq $30,$0,L.2755\nla $4,L.2519\nmove $5,$23\njal printf\nL.2755:\nL.2753:\nb L.2757\nla $23,56\nbeq $30,$0,L.2759\nla $4,L.2519\nmove $5,$23\njal printf\nL.2759:\nL.2757:\nb L.2761\nla $23,60\nbeq $30,$0,L.2763\nla $4,L.2519\nmove $5,$23\njal printf\nL.2763:\nL.2761:\nb L.2765\nla $23,61\nbeq $30,$0,L.2767\nla $4,L.2519\nmove $5,$23\njal printf\nL.2767:\nL.2765:\nb L.2769\nla $23,62\nbeq $30,$0,L.2771\nla $4,L.2519\nmove $5,$23\njal printf\nL.2771:\nL.2769:\nb L.2773\nla $23,63\nbeq $30,$0,L.2775\nla $4,L.2519\nmove $5,$23\njal printf\nL.2775:\nL.2773:\nb L.2777\nla $23,64\nbeq $30,$0,L.2779\nla $4,L.2519\nmove $5,$23\njal printf\nL.2779:\nL.2777:\nb L.2781\nla $23,65\nbeq $30,$0,L.2783\nla $4,L.2519\nmove $5,$23\njal printf\nL.2783:\nL.2781:\nb L.2785\nla $23,66\nbeq $30,$0,L.2787\nla $4,L.2519\nmove $5,$23\njal printf\nL.2787:\nL.2785:\nb L.2789\nla $23,67\nbeq $30,$0,L.2791\nla $4,L.2519\nmove $5,$23\njal printf\nL.2791:\nL.2789:\nb L.2793\nla $23,68\nbeq $30,$0,L.2795\nla $4,L.2519\nmove $5,$23\njal printf\nL.2795:\nL.2793:\nb L.2797\nla $23,69\nbeq $30,$0,L.2799\nla $4,L.2519\nmove $5,$23\njal printf\nL.2799:\nL.2797:\nb L.2801\nla $23,70\nbeq $30,$0,L.2803\nla $4,L.2519\nmove $5,$23\njal printf\nL.2803:\nL.2801:\nb L.2805\nla $23,71\nbeq $30,$0,L.2807\nla $4,L.2519\nmove $5,$23\njal printf\nL.2807:\nL.2805:\nb L.2809\nla $23,72\nbeq $30,$0,L.2811\nla $4,L.2519\nmove $5,$23\njal printf\nL.2811:\nL.2809:\nb L.2813\nla $23,73\nbeq $30,$0,L.2815\nla $4,L.2519\nmove $5,$23\njal printf\nL.2815:\nL.2813:\nb L.2817\nla $23,74\nbeq $30,$0,L.2819\nla $4,L.2519\nmove $5,$23\njal printf\nL.2819:\nL.2817:\nb L.2821\nla $23,75\nbeq $30,$0,L.2823\nla $4,L.2519\nmove $5,$23\njal printf\nL.2823:\nL.2821:\nbeq $23,$0,L.2825\nlw $24,0+112($sp)\nlw $24,44($24)\nbeq $24,$0,L.2827\nla $4,L.2520\nla $5,1\njal printf\nL.2827:\nla $17,1($17)\nL.2825:\nmove $23,$0\nmove $21,$0\nmove $22,$0\nmove $24,$22\nla $22,1($24)\nmove $15,$0\nbeq $24,$15,L.2830\nmove $24,$21\nla $21,1($24)\nbeq $24,$15,L.2830\nla $24,1\nsw $24,-8+112($sp)\nb L.2831\nL.2830:\nsw $0,-8+112($sp)\nL.2831:\nlw $20,-8+112($sp)\nla $24,1\nbeq $22,$24,L.2832\nla $23,1\nbeq $30,$0,L.2834\nla $4,L.2519\nmove $5,$23\njal printf\nL.2834:\nL.2832:\nbeq $21,$0,L.2836\nla $23,2\nbeq $30,$0,L.2838\nla $4,L.2519\nmove $5,$23\njal printf\nL.2838:\nL.2836:\nbeq $20,$0,L.2840\nla $23,3\nbeq $30,$0,L.2842\nla $4,L.2519\nmove $5,$23\njal printf\nL.2842:\nL.2840:\nbeq $22,$0,L.2845\nmove $15,$21\nla $21,1($15)\nbeq $15,$0,L.2845\nla $24,1\nsw $24,-12+112($sp)\nb L.2846\nL.2845:\nsw $0,-12+112($sp)\nL.2846:\nlw $20,-12+112($sp)\nla $24,1\nbeq $22,$24,L.2847\nla $23,4\nbeq $30,$0,L.2849\nla $4,L.2519\nmove $5,$23\njal printf\nL.2849:\nL.2847:\nla $24,1\nbeq $21,$24,L.2851\nla $23,5\nbeq $30,$0,L.2853\nla $4,L.2519\nmove $5,$23\njal printf\nL.2853:\nL.2851:\nbeq $20,$0,L.2855\nla $23,6\nbeq $30,$0,L.2857\nla $4,L.2519\nmove $5,$23\njal printf\nL.2857:\nL.2855:\nmove $24,$22\nsubu $22,$24,1\nmove $15,$0\nbeq $24,$15,L.2860\nbeq $21,$15,L.2860\nla $24,1\nsw $24,-16+112($sp)\nb L.2861\nL.2860:\nsw $0,-16+112($sp)\nL.2861:\nlw $20,-16+112($sp)\nbeq $22,$0,L.2862\nla $23,7\nbeq $30,$0,L.2864\nla $4,L.2519\nmove $5,$23\njal printf\nL.2864:\nL.2862:\nla $24,1\nbeq $21,$24,L.2866\nla $23,8\nbeq $30,$0,L.2868\nla $4,L.2519\nmove $5,$23\njal printf\nL.2868:\nL.2866:\nla $24,1\nbeq $20,$24,L.2870\nla $23,9\nbeq $30,$0,L.2872\nla $4,L.2519\nmove $5,$23\njal printf\nL.2872:\nL.2870:\nbeq $22,$0,L.2875\nmove $15,$21\nsubu $21,$15,1\nbeq $15,$0,L.2875\nla $24,1\nsw $24,-20+112($sp)\nb L.2876\nL.2875:\nsw $0,-20+112($sp)\nL.2876:\nlw $20,-20+112($sp)\nbeq $22,$0,L.2877\nla $23,10\nbeq $30,$0,L.2879\nla $4,L.2519\nmove $5,$23\njal printf\nL.2879:\nL.2877:\nla $24,1\nbeq $21,$24,L.2881\nla $23,11\nbeq $30,$0,L.2883\nla $4,L.2519\nmove $5,$23\njal printf\nL.2883:\nL.2881:\nbeq $20,$0,L.2885\nla $23,12\nbeq $30,$0,L.2887\nla $4,L.2519\nmove $5,$23\njal printf\nL.2887:\nL.2885:\nbeq $23,$0,L.2889\nlw $24,0+112($sp)\nlw $24,44($24)\nbeq $24,$0,L.2891\nla $4,L.2520\nla $5,2\njal printf\nL.2891:\nla $17,2($17)\nL.2889:\nmove $23,$0\nmove $21,$0\nmove $22,$0\nmove $24,$22\nla $22,1($24)\nmove $15,$0\nbne $24,$15,L.2896\nbeq $21,$15,L.2894\nL.2896:\nla $24,1\nsw $24,-24+112($sp)\nb L.2895\nL.2894:\nsw $0,-24+112($sp)\nL.2895:\nlw $20,-24+112($sp)\nla $24,1\nbeq $22,$24,L.2897\nla $23,1\nbeq $30,$0,L.2899\nla $4,L.2519\nmove $5,$23\njal printf\nL.2899:\nL.2897:\nbeq $21,$0,L.2901\nla $23,2\nbeq $30,$0,L.2903\nla $4,L.2519\nmove $5,$23\njal printf\nL.2903:\nL.2901:\nbeq $20,$0,L.2905\nla $23,3\nbeq $30,$0,L.2907\nla $4,L.2519\nmove $5,$23\njal printf\nL.2907:\nL.2905:\nmove $24,$21\nla $21,1($24)\nmove $15,$0\nbne $24,$15,L.2912\nbeq $22,$15,L.2910\nL.2912:\nla $24,1\nsw $24,-28+112($sp)\nb L.2911\nL.2910:\nsw $0,-28+112($sp)\nL.2911:\nlw $20,-28+112($sp)\nla $24,1\nbeq $22,$24,L.2913\nla $23,4\nbeq $30,$0,L.2915\nla $4,L.2519\nmove $5,$23\njal printf\nL.2915:\nL.2913:\nla $24,1\nbeq $21,$24,L.2917\nla $23,5\nbeq $30,$0,L.2919\nla $4,L.2519\nmove $5,$23\njal printf\nL.2919:\nL.2917:\nla $24,1\nbeq $20,$24,L.2921\nla $23,6\nbeq $30,$0,L.2923\nla $4,L.2519\nmove $5,$23\njal printf\nL.2923:\nL.2921:\nmove $24,$22\nsubu $22,$24,1\nmove $15,$0\nbne $24,$15,L.2928\nmove $24,$21\nsubu $21,$24,1\nbeq $24,$15,L.2926\nL.2928:\nla $24,1\nsw $24,-32+112($sp)\nb L.2927\nL.2926:\nsw $0,-32+112($sp)\nL.2927:\nlw $20,-32+112($sp)\nbeq $22,$0,L.2929\nla $23,7\nbeq $30,$0,L.2931\nla $4,L.2519\nmove $5,$23\njal printf\nL.2931:\nL.2929:\nla $24,1\nbeq $21,$24,L.2933\nla $23,8\nbeq $30,$0,L.2935\nla $4,L.2519\nmove $5,$23\njal printf\nL.2935:\nL.2933:\nla $24,1\nbeq $20,$24,L.2937\nla $23,9\nbeq $30,$0,L.2939\nla $4,L.2519\nmove $5,$23\njal printf\nL.2939:\nL.2937:\nmove $24,$0\nbne $22,$24,L.2944\nmove $15,$21\nsubu $21,$15,1\nbeq $15,$24,L.2942\nL.2944:\nla $24,1\nsw $24,-36+112($sp)\nb L.2943\nL.2942:\nsw $0,-36+112($sp)\nL.2943:\nlw $20,-36+112($sp)\nbeq $22,$0,L.2945\nla $23,10\nbeq $30,$0,L.2947\nla $4,L.2519\nmove $5,$23\njal printf\nL.2947:\nL.2945:\nbeq $21,$0,L.2949\nla $23,11\nbeq $30,$0,L.2951\nla $4,L.2519\nmove $5,$23\njal printf\nL.2951:\nL.2949:\nla $24,1\nbeq $20,$24,L.2953\nla $23,12\nbeq $30,$0,L.2955\nla $4,L.2519\nmove $5,$23\njal printf\nL.2955:\nL.2953:\nbeq $23,$0,L.2957\nlw $24,0+112($sp)\nlw $24,44($24)\nbeq $24,$0,L.2959\nla $4,L.2520\nla $5,4\njal printf\nL.2959:\nla $17,4($17)\nL.2957:\nmove $24,$0\nmove $21,$24\nmove $22,$24\nmove $16,$24\nla $15,1\nsw $15,-4+112($sp)\nlw $15,-4+112($sp)\nbeq $15,$24,L.2963\nsw $16,-40+112($sp)\nb L.2964\nL.2963:\nlw $24,-4+112($sp)\nbeq $24,$0,L.2965\nmove $24,$22\nla $22,1($24)\nsw $24,-44+112($sp)\nb L.2966\nL.2965:\nmove $24,$21\nla $21,1($24)\nsw $24,-44+112($sp)\nL.2966:\nlw $24,-44+112($sp)\nsw $24,-40+112($sp)\nL.2964:\nlw $20,-40+112($sp)\nbne $20,$0,L.2970\nbne $22,$0,L.2970\nbeq $21,$0,L.2967\nL.2970:\nlw $24,0+112($sp)\nlw $24,44($24)\nbeq $24,$0,L.2971\nla $4,L.2520\nla $5,8\njal printf\nL.2971:\nla $17,8($17)\nL.2967:\nlw $24,-4+112($sp)\nbeq $24,$0,L.2978\nsw $16,-48+112($sp)\nb L.2979\nL.2978:\nla $24,1\nsw $24,-48+112($sp)\nL.2979:\nlw $15,-48+112($sp)\nbne $15,$0,L.2977\nbeq $16,$0,L.2980\nla $24,1\nsw $24,-52+112($sp)\nb L.2981\nL.2980:\nsw $16,-52+112($sp)\nL.2981:\nlw $24,-52+112($sp)\nbeq $24,$0,L.2973\nL.2977:\nlw $24,0+112($sp)\nlw $24,44($24)\nbeq $24,$0,L.2982\nla $4,L.2520\nla $5,16\njal printf\nL.2982:\nla $17,16($17)\nL.2973:\nmove $2,$17\nL.2518:\nlw $16,16($sp)\nlw $17,20($sp)\nlw $18,24($sp)\nlw $19,28($sp)\nlw $20,32($sp)\nlw $21,36($sp)\nlw $22,40($sp)\nlw $23,44($sp)\nlw $25,48($sp)\nlw $30,52($sp)\nlw $31,56($sp)\naddu $sp,$sp,112\nj $31\n.end s7813\n.data\n.align 0\nL.2985:\n.byte 115\n.byte 56\n.byte 49\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.sdata\n.align 0\nL.2986:\n.byte 115\n.byte 56\n.byte 49\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.data\n.align 0\nL.2987:\n.byte 82\n.byte 101\n.byte 103\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 117\n.byte 110\n.byte 116\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 37\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 117\n.byte 110\n.byte 114\n.byte 101\n.byte 108\n.byte 105\n.byte 97\n.byte 98\n.byte 108\n.byte 101\n.byte 46\n.byte 10\n.byte 0\n.data\n.align 0\nL.2988:\n.byte 37\n.byte 100\n.byte 32\n.byte 114\n.byte 101\n.byte 103\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 97\n.byte 115\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 37\n.byte 115\n.byte 32\n.byte 118\n.byte 97\n.byte 114\n.byte 105\n.byte 97\n.byte 98\n.byte 108\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.globl s81\n.text\n.text\n.align 2\n.ent s81\ns81:\n.frame $sp,80,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-80\n.mask 0xc2ff0000,-24\nsw $16,16($sp)\nsw $17,20($sp)\nsw $18,24($sp)\nsw $19,28($sp)\nsw $20,32($sp)\nsw $21,36($sp)\nsw $22,40($sp)\nsw $23,44($sp)\n.cprestore 48\nsw $30,52($sp)\nsw $31,56($sp)\nsw $4,80($sp)\nsw $0,-20+80($sp)\nsw $0,-8+80($sp)\nsw $0,-12+80($sp)\nsw $0,-16+80($sp)\nla $17,L.2986\nlw $24,0+80($sp)\nla $16,60($24)\nL.2989:\nL.2990:\nmove $24,$16\nla $16,1($24)\nmove $15,$17\nla $17,1($15)\nlb $15,($15)\nsb $15,($24)\nsll $24,$15,8*(4-1); sra $24,$24,8*(4-1)\nbne $24,$0,L.2989\nla $24,1\nsw $24,-4+80($sp)\nmove $21,$0\nL.2992:\nlw $24,-4+80($sp)\nmove $15,$24\nmove $30,$15\nmove $20,$15\nla $23,-4+80($sp)\nla $19,-4+80($sp)\nmove $22,$24\nmove $18,$24\nsll $24,$30,8*(4-1); sra $24,$24,8*(4-1)\nsll $15,$20,8*(4-1); sra $15,$15,8*(4-1)\nbeq $24,$15,L.2996\nla $24,1\nsw $24,-8+80($sp)\nL.2996:\nmove $24,$23\nmove $15,$19\nbeq $24,$15,L.2998\nla $24,1\nsw $24,-12+80($sp)\nL.2998:\nbeq $22,$18,L.3000\nla $24,1\nsw $24,-16+80($sp)\nL.3000:\nlw $24,-4+80($sp)\nsll $24,$24,1\nsw $24,-4+80($sp)\nL.2993:\nla $21,1($21)\nla $24,50\nblt $21,$24,L.2992\nlw $24,-8+80($sp)\nbeq $24,$0,L.3002\nlw $24,-20+80($sp)\nla $24,1($24)\nsw $24,-20+80($sp)\nlw $24,0+80($sp)\nlw $24,44($24)\nbeq $24,$0,L.3004\nla $4,L.2985\nla $5,1\njal printf\nL.3004:\nL.3002:\nlw $24,-12+80($sp)\nbeq $24,$0,L.3006\nlw $24,-20+80($sp)\nla $24,2($24)\nsw $24,-20+80($sp)\nlw $24,0+80($sp)\nlw $24,44($24)\nbeq $24,$0,L.3008\nla $4,L.2985\nla $5,2\njal printf\nL.3008:\nL.3006:\nlw $24,-16+80($sp)\nbeq $24,$0,L.3010\nlw $24,-20+80($sp)\nla $24,4($24)\nsw $24,-20+80($sp)\nlw $24,0+80($sp)\nlw $24,44($24)\nbeq $24,$0,L.3012\nla $4,L.2985\nla $5,4\njal printf\nL.3012:\nL.3010:\njal regc\nsw $2,-4+80($sp)\nlw $24,0+80($sp)\nlw $24,40($24)\nbeq $24,$0,L.3014\nlw $24,-4+80($sp)\nbge $24,$0,L.3016\nla $4,L.2987\nla $5,L.425\njal printf\nb L.3017\nL.3016:\nla $4,L.2988\nlw $5,-4+80($sp)\nla $6,L.425\njal printf\nL.3017:\nL.3014:\njal regp\nsw $2,-4+80($sp)\nlw $24,0+80($sp)\nlw $24,40($24)\nbeq $24,$0,L.3018\nlw $24,-4+80($sp)\nbge $24,$0,L.3020\nla $4,L.2987\nla $5,L.3022\njal printf\nb L.3021\nL.3020:\nla $4,L.2988\nlw $5,-4+80($sp)\nla $6,L.3022\njal printf\nL.3021:\nL.3018:\njal regi\nsw $2,-4+80($sp)\nlw $24,0+80($sp)\nlw $24,40($24)\nbeq $24,$0,L.3023\nlw $24,-4+80($sp)\nbge $24,$0,L.3025\nla $4,L.2987\nla $5,L.426\njal printf\nb L.3026\nL.3025:\nla $4,L.2988\nlw $5,-4+80($sp)\nla $6,L.426\njal printf\nL.3026:\nL.3023:\nlw $2,-20+80($sp)\nL.2984:\nlw $16,16($sp)\nlw $17,20($sp)\nlw $18,24($sp)\nlw $19,28($sp)\nlw $20,32($sp)\nlw $21,36($sp)\nlw $22,40($sp)\nlw $23,44($sp)\nlw $25,48($sp)\nlw $30,52($sp)\nlw $31,56($sp)\naddu $sp,$sp,80\nj $31\n.end s81\n.globl regc\n.text\n.align 2\n.ent regc\nregc:\n.frame $sp,176,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-176\n.mask 0x40ff0000,-144\nsw $16,0($sp)\nsw $17,4($sp)\nsw $18,8($sp)\nsw $19,12($sp)\nsw $20,16($sp)\nsw $21,20($sp)\nsw $22,24($sp)\nsw $23,28($sp)\nsw $30,32($sp)\nsb $0,-130+176($sp)\nla $24,1\nsb $24,-109+176($sp)\nla $24,2\nsb $24,-110+176($sp)\nla $24,3\nsb $24,-111+176($sp)\nla $30,4\nla $24,5\nsb $24,-112+176($sp)\nla $23,6\nla $24,7\nsb $24,-113+176($sp)\nla $22,8\nla $24,9\nsb $24,-114+176($sp)\nla $21,10\nla $24,11\nsb $24,-115+176($sp)\nla $20,12\nla $24,13\nsb $24,-116+176($sp)\nla $19,14\nla $24,15\nsb $24,-117+176($sp)\nla $18,16\nla $24,17\nsb $24,-118+176($sp)\nla $17,18\nla $24,19\nsb $24,-119+176($sp)\nla $16,20\nla $24,21\nsb $24,-120+176($sp)\nla $24,22\nsb $24,-1+176($sp)\nla $24,23\nsb $24,-121+176($sp)\nla $24,24\nsb $24,-2+176($sp)\nla $24,25\nsb $24,-122+176($sp)\nla $24,26\nsb $24,-3+176($sp)\nla $24,27\nsb $24,-123+176($sp)\nla $24,28\nsb $24,-4+176($sp)\nla $24,29\nsb $24,-124+176($sp)\nla $24,30\nsb $24,-5+176($sp)\nla $24,31\nsb $24,-125+176($sp)\nla $24,32\nsb $24,-6+176($sp)\nla $24,33\nsb $24,-126+176($sp)\nla $24,34\nsb $24,-7+176($sp)\nla $24,35\nsb $24,-127+176($sp)\nla $24,36\nsb $24,-128+176($sp)\nla $24,37\nsb $24,-129+176($sp)\nla $24,38\nsb $24,-131+176($sp)\nla $24,-109+176($sp)\nla $15,-130+176($sp)\nsubu $15,$24,$15\nsw $15,-96+176($sp)\nla $15,-110+176($sp)\nsubu $24,$15,$24\nsw $24,-92+176($sp)\nla $24,-111+176($sp)\nla $15,-110+176($sp)\nsubu $24,$24,$15\nsw $24,-88+176($sp)\nla $24,-112+176($sp)\nla $15,-111+176($sp)\nsubu $24,$24,$15\nsw $24,-84+176($sp)\nla $24,-113+176($sp)\nla $15,-112+176($sp)\nsubu $24,$24,$15\nsw $24,-80+176($sp)\nla $24,-114+176($sp)\nla $15,-113+176($sp)\nsubu $24,$24,$15\nsw $24,-76+176($sp)\nla $24,-115+176($sp)\nla $15,-114+176($sp)\nsubu $24,$24,$15\nsw $24,-72+176($sp)\nla $24,-116+176($sp)\nla $15,-115+176($sp)\nsubu $24,$24,$15\nsw $24,-68+176($sp)\nla $24,-117+176($sp)\nla $15,-116+176($sp)\nsubu $24,$24,$15\nsw $24,-64+176($sp)\nla $24,-118+176($sp)\nla $15,-117+176($sp)\nsubu $24,$24,$15\nsw $24,-60+176($sp)\nla $24,-119+176($sp)\nla $15,-118+176($sp)\nsubu $24,$24,$15\nsw $24,-56+176($sp)\nla $24,-120+176($sp)\nla $15,-119+176($sp)\nsubu $24,$24,$15\nsw $24,-52+176($sp)\nla $24,-121+176($sp)\nla $15,-120+176($sp)\nsubu $24,$24,$15\nsw $24,-48+176($sp)\nla $24,-122+176($sp)\nla $15,-121+176($sp)\nsubu $24,$24,$15\nsw $24,-44+176($sp)\nla $24,-123+176($sp)\nla $15,-122+176($sp)\nsubu $24,$24,$15\nsw $24,-40+176($sp)\nla $24,-124+176($sp)\nla $15,-123+176($sp)\nsubu $24,$24,$15\nsw $24,-36+176($sp)\nla $24,-125+176($sp)\nla $15,-124+176($sp)\nsubu $24,$24,$15\nsw $24,-32+176($sp)\nla $24,-126+176($sp)\nla $15,-125+176($sp)\nsubu $24,$24,$15\nsw $24,-28+176($sp)\nla $24,-127+176($sp)\nla $15,-126+176($sp)\nsubu $24,$24,$15\nsw $24,-24+176($sp)\nla $24,-128+176($sp)\nla $15,-127+176($sp)\nsubu $24,$24,$15\nsw $24,-20+176($sp)\nla $24,-129+176($sp)\nla $15,-128+176($sp)\nsubu $24,$24,$15\nsw $24,-16+176($sp)\nla $24,-131+176($sp)\nla $15,-129+176($sp)\nsubu $24,$24,$15\nsw $24,-12+176($sp)\nlw $24,-96+176($sp)\nsw $24,-108+176($sp)\nla $24,1\nsw $24,-104+176($sp)\nsw $0,-100+176($sp)\nL.3049:\nlw $24,-104+176($sp)\nla $15,1\nbeq $24,$15,L.3055\nla $15,2\nbeq $24,$15,L.3058\nla $15,3\nbeq $24,$15,L.3063\nb L.3053\nL.3055:\nlw $24,-100+176($sp)\nsll $24,$24,2\nla $15,-96+176($sp)\naddu $24,$24,$15\nlw $24,($24)\nlw $15,-108+176($sp)\nbeq $24,$15,L.3054\nla $24,2\nlw $15,-100+176($sp)\nsll $15,$15,2\nla $14,-96+176($sp)\naddu $15,$15,$14\nlw $15,($15)\nsw $15,-140+176($sp)\nsw $24,-104+176($sp)\nla $24,1\nsw $24,-136+176($sp)\nb L.3054\nL.3058:\nlw $24,-100+176($sp)\nsll $24,$24,2\nla $15,-96+176($sp)\naddu $24,$24,$15\nlw $24,($24)\nlw $15,-108+176($sp)\nbne $24,$15,L.3059\nla $24,3\nsw $24,-104+176($sp)\nb L.3054\nL.3059:\nlw $24,-100+176($sp)\nsll $24,$24,2\nla $15,-96+176($sp)\naddu $24,$24,$15\nlw $24,($24)\nlw $15,-140+176($sp)\nbne $24,$15,L.3061\nlw $24,-136+176($sp)\nla $24,1($24)\nsw $24,-136+176($sp)\nb L.3054\nL.3061:\nla $24,4\nsw $24,-104+176($sp)\nb L.3054\nL.3063:\nlw $24,-100+176($sp)\nsll $24,$24,2\nla $15,-96+176($sp)\naddu $24,$24,$15\nlw $24,($24)\nlw $15,-108+176($sp)\nbeq $24,$15,L.3054\nla $24,4\nsw $24,-104+176($sp)\nL.3053:\nL.3054:\nL.3050:\nlw $24,-100+176($sp)\nla $24,1($24)\nsw $24,-100+176($sp)\nlw $24,-100+176($sp)\nla $15,22\nblt $24,$15,L.3049\nlw $24,-104+176($sp)\nla $15,3\nbne $24,$15,L.3066\nla $24,16\nlw $15,-136+176($sp)\nsubu $2,$24,$15\nb L.3027\nL.3066:\nla $2,-1\nL.3027:\nlw $16,0($sp)\nlw $17,4($sp)\nlw $18,8($sp)\nlw $19,12($sp)\nlw $20,16($sp)\nlw $21,20($sp)\nlw $22,24($sp)\nlw $23,28($sp)\nlw $30,32($sp)\naddu $sp,$sp,176\nj $31\n.end regc\n.globl regi\n.text\n.align 2\n.ent regi\nregi:\n.frame $sp,264,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-264\n.mask 0x40ff0000,-232\nsw $16,0($sp)\nsw $17,4($sp)\nsw $18,8($sp)\nsw $19,12($sp)\nsw $20,16($sp)\nsw $21,20($sp)\nsw $22,24($sp)\nsw $23,28($sp)\nsw $30,32($sp)\nsw $0,-216+264($sp)\nla $24,1\nsw $24,-132+264($sp)\nla $24,2\nsw $24,-136+264($sp)\nla $24,3\nsw $24,-140+264($sp)\nla $30,4\nla $24,5\nsw $24,-144+264($sp)\nla $23,6\nla $24,7\nsw $24,-148+264($sp)\nla $22,8\nla $24,9\nsw $24,-152+264($sp)\nla $21,10\nla $24,11\nsw $24,-156+264($sp)\nla $20,12\nla $24,13\nsw $24,-160+264($sp)\nla $19,14\nla $24,15\nsw $24,-164+264($sp)\nla $18,16\nla $24,17\nsw $24,-168+264($sp)\nla $17,18\nla $24,19\nsw $24,-172+264($sp)\nla $16,20\nla $24,21\nsw $24,-176+264($sp)\nla $24,22\nsw $24,-4+264($sp)\nla $24,23\nsw $24,-180+264($sp)\nla $24,24\nsw $24,-8+264($sp)\nla $24,25\nsw $24,-184+264($sp)\nla $24,26\nsw $24,-12+264($sp)\nla $24,27\nsw $24,-188+264($sp)\nla $24,28\nsw $24,-16+264($sp)\nla $24,29\nsw $24,-192+264($sp)\nla $24,30\nsw $24,-20+264($sp)\nla $24,31\nsw $24,-196+264($sp)\nla $24,32\nsw $24,-24+264($sp)\nla $24,33\nsw $24,-200+264($sp)\nla $24,34\nsw $24,-28+264($sp)\nla $24,35\nsw $24,-204+264($sp)\nla $24,36\nsw $24,-208+264($sp)\nla $24,37\nsw $24,-212+264($sp)\nla $24,38\nsw $24,-220+264($sp)\nla $24,-132+264($sp)\nla $15,4\nla $14,-216+264($sp)\nsubu $14,$24,$14\ndiv $14,$14,$15\nsw $14,-116+264($sp)\nla $14,-136+264($sp)\nsubu $24,$14,$24\ndiv $24,$24,$15\nsw $24,-112+264($sp)\nla $24,-140+264($sp)\nla $15,-136+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-108+264($sp)\nla $24,-144+264($sp)\nla $15,-140+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-104+264($sp)\nla $24,-148+264($sp)\nla $15,-144+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-100+264($sp)\nla $24,-152+264($sp)\nla $15,-148+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-96+264($sp)\nla $24,-156+264($sp)\nla $15,-152+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-92+264($sp)\nla $24,-160+264($sp)\nla $15,-156+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-88+264($sp)\nla $24,-164+264($sp)\nla $15,-160+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-84+264($sp)\nla $24,-168+264($sp)\nla $15,-164+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-80+264($sp)\nla $24,-172+264($sp)\nla $15,-168+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-76+264($sp)\nla $24,-176+264($sp)\nla $15,-172+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-72+264($sp)\nla $24,-180+264($sp)\nla $15,-176+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-68+264($sp)\nla $24,-184+264($sp)\nla $15,-180+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-64+264($sp)\nla $24,-188+264($sp)\nla $15,-184+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-60+264($sp)\nla $24,-192+264($sp)\nla $15,-188+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-56+264($sp)\nla $24,-196+264($sp)\nla $15,-192+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-52+264($sp)\nla $24,-200+264($sp)\nla $15,-196+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-48+264($sp)\nla $24,-204+264($sp)\nla $15,-200+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-44+264($sp)\nla $24,-208+264($sp)\nla $15,-204+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-40+264($sp)\nla $24,-212+264($sp)\nla $15,-208+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-36+264($sp)\nla $24,-220+264($sp)\nla $15,-212+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-32+264($sp)\nlw $24,-116+264($sp)\nsw $24,-128+264($sp)\nla $24,1\nsw $24,-124+264($sp)\nsw $0,-120+264($sp)\nL.3090:\nlw $24,-124+264($sp)\nla $15,1\nbeq $24,$15,L.3096\nla $15,2\nbeq $24,$15,L.3099\nla $15,3\nbeq $24,$15,L.3104\nb L.3094\nL.3096:\nlw $24,-120+264($sp)\nsll $24,$24,2\nla $15,-116+264($sp)\naddu $24,$24,$15\nlw $24,($24)\nlw $15,-128+264($sp)\nbeq $24,$15,L.3095\nla $24,2\nlw $15,-120+264($sp)\nsll $15,$15,2\nla $14,-116+264($sp)\naddu $15,$15,$14\nlw $15,($15)\nsw $15,-228+264($sp)\nsw $24,-124+264($sp)\nla $24,1\nsw $24,-224+264($sp)\nb L.3095\nL.3099:\nlw $24,-120+264($sp)\nsll $24,$24,2\nla $15,-116+264($sp)\naddu $24,$24,$15\nlw $24,($24)\nlw $15,-128+264($sp)\nbne $24,$15,L.3100\nla $24,3\nsw $24,-124+264($sp)\nb L.3095\nL.3100:\nlw $24,-120+264($sp)\nsll $24,$24,2\nla $15,-116+264($sp)\naddu $24,$24,$15\nlw $24,($24)\nlw $15,-228+264($sp)\nbne $24,$15,L.3102\nlw $24,-224+264($sp)\nla $24,1($24)\nsw $24,-224+264($sp)\nb L.3095\nL.3102:\nla $24,4\nsw $24,-124+264($sp)\nb L.3095\nL.3104:\nlw $24,-120+264($sp)\nsll $24,$24,2\nla $15,-116+264($sp)\naddu $24,$24,$15\nlw $24,($24)\nlw $15,-128+264($sp)\nbeq $24,$15,L.3095\nla $24,4\nsw $24,-124+264($sp)\nL.3094:\nL.3095:\nL.3091:\nlw $24,-120+264($sp)\nla $24,1($24)\nsw $24,-120+264($sp)\nlw $24,-120+264($sp)\nla $15,22\nblt $24,$15,L.3090\nlw $24,-124+264($sp)\nla $15,3\nbne $24,$15,L.3107\nla $24,16\nlw $15,-224+264($sp)\nsubu $2,$24,$15\nb L.3068\nL.3107:\nla $2,-1\nL.3068:\nlw $16,0($sp)\nlw $17,4($sp)\nlw $18,8($sp)\nlw $19,12($sp)\nlw $20,16($sp)\nlw $21,20($sp)\nlw $22,24($sp)\nlw $23,28($sp)\nlw $30,32($sp)\naddu $sp,$sp,264\nj $31\n.end regi\n.globl regp\n.text\n.align 2\n.ent regp\nregp:\n.frame $sp,264,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-264\n.mask 0x40ff0000,-232\nsw $16,0($sp)\nsw $17,4($sp)\nsw $18,8($sp)\nsw $19,12($sp)\nsw $20,16($sp)\nsw $21,20($sp)\nsw $22,24($sp)\nsw $23,28($sp)\nsw $30,32($sp)\nla $24,-216+264($sp)\nsw $24,-216+264($sp)\nla $24,-192+264($sp)\nsw $24,-192+264($sp)\nla $24,-196+264($sp)\nsw $24,-196+264($sp)\nla $24,-200+264($sp)\nsw $24,-200+264($sp)\nla $30,-128+264($sp)\nla $24,-128+264($sp)\nsw $24,-128+264($sp)\nla $23,-132+264($sp)\nla $24,-132+264($sp)\nsw $24,-132+264($sp)\nla $22,-136+264($sp)\nla $24,-136+264($sp)\nsw $24,-136+264($sp)\nla $21,-140+264($sp)\nla $24,-140+264($sp)\nsw $24,-140+264($sp)\nla $20,-144+264($sp)\nla $24,-144+264($sp)\nsw $24,-144+264($sp)\nla $19,-148+264($sp)\nla $24,-148+264($sp)\nsw $24,-148+264($sp)\nla $18,-152+264($sp)\nla $24,-152+264($sp)\nsw $24,-152+264($sp)\nla $17,-156+264($sp)\nla $24,-156+264($sp)\nsw $24,-156+264($sp)\nla $16,-160+264($sp)\nla $24,-160+264($sp)\nsw $24,-160+264($sp)\nla $24,-164+264($sp)\nsw $24,-4+264($sp)\nla $24,-164+264($sp)\nsw $24,-164+264($sp)\nla $24,-168+264($sp)\nsw $24,-8+264($sp)\nla $24,-168+264($sp)\nsw $24,-168+264($sp)\nla $24,-172+264($sp)\nsw $24,-12+264($sp)\nla $24,-172+264($sp)\nsw $24,-172+264($sp)\nla $24,-176+264($sp)\nsw $24,-16+264($sp)\nla $24,-176+264($sp)\nsw $24,-176+264($sp)\nla $24,-180+264($sp)\nsw $24,-20+264($sp)\nla $24,-180+264($sp)\nsw $24,-180+264($sp)\nla $24,-184+264($sp)\nsw $24,-24+264($sp)\nla $24,-184+264($sp)\nsw $24,-184+264($sp)\nla $24,-188+264($sp)\nsw $24,-28+264($sp)\nla $24,-188+264($sp)\nsw $24,-188+264($sp)\nla $24,-204+264($sp)\nsw $24,-204+264($sp)\nla $24,-208+264($sp)\nsw $24,-208+264($sp)\nla $24,-220+264($sp)\nsw $24,-220+264($sp)\nla $24,-192+264($sp)\nla $15,4\nla $14,-216+264($sp)\nsubu $14,$24,$14\ndiv $14,$14,$15\nsw $14,-116+264($sp)\nla $14,-196+264($sp)\nsubu $24,$14,$24\ndiv $24,$24,$15\nsw $24,-112+264($sp)\nla $24,-200+264($sp)\nla $15,-196+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-108+264($sp)\nla $24,-128+264($sp)\nla $15,-200+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-104+264($sp)\nla $24,-132+264($sp)\nla $15,-128+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-100+264($sp)\nla $24,-136+264($sp)\nla $15,-132+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-96+264($sp)\nla $24,-140+264($sp)\nla $15,-136+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-92+264($sp)\nla $24,-144+264($sp)\nla $15,-140+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-88+264($sp)\nla $24,-148+264($sp)\nla $15,-144+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-84+264($sp)\nla $24,-152+264($sp)\nla $15,-148+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-80+264($sp)\nla $24,-156+264($sp)\nla $15,-152+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-76+264($sp)\nla $24,-160+264($sp)\nla $15,-156+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-72+264($sp)\nla $24,-164+264($sp)\nla $15,-160+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-68+264($sp)\nla $24,-168+264($sp)\nla $15,-164+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-64+264($sp)\nla $24,-172+264($sp)\nla $15,-168+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-60+264($sp)\nla $24,-176+264($sp)\nla $15,-172+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-56+264($sp)\nla $24,-180+264($sp)\nla $15,-176+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-52+264($sp)\nla $24,-184+264($sp)\nla $15,-180+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-48+264($sp)\nla $24,-188+264($sp)\nla $15,-184+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-44+264($sp)\nla $24,-204+264($sp)\nla $15,-188+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-40+264($sp)\nla $24,-208+264($sp)\nla $15,-204+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-36+264($sp)\nla $24,-220+264($sp)\nla $15,-208+264($sp)\nsubu $24,$24,$15\nla $15,4\ndiv $24,$24,$15\nsw $24,-32+264($sp)\nlw $24,-116+264($sp)\nsw $24,-212+264($sp)\nla $24,1\nsw $24,-124+264($sp)\nsw $0,-120+264($sp)\nL.3131:\nlw $24,-124+264($sp)\nla $15,1\nbeq $24,$15,L.3137\nla $15,2\nbeq $24,$15,L.3140\nla $15,3\nbeq $24,$15,L.3145\nb L.3135\nL.3137:\nlw $24,-120+264($sp)\nsll $24,$24,2\nla $15,-116+264($sp)\naddu $24,$24,$15\nlw $24,($24)\nlw $15,-212+264($sp)\nbeq $24,$15,L.3136\nla $24,2\nlw $15,-120+264($sp)\nsll $15,$15,2\nla $14,-116+264($sp)\naddu $15,$15,$14\nlw $15,($15)\nsw $15,-228+264($sp)\nsw $24,-124+264($sp)\nla $24,1\nsw $24,-224+264($sp)\nb L.3136\nL.3140:\nlw $24,-120+264($sp)\nsll $24,$24,2\nla $15,-116+264($sp)\naddu $24,$24,$15\nlw $24,($24)\nlw $15,-212+264($sp)\nbne $24,$15,L.3141\nla $24,3\nsw $24,-124+264($sp)\nb L.3136\nL.3141:\nlw $24,-120+264($sp)\nsll $24,$24,2\nla $15,-116+264($sp)\naddu $24,$24,$15\nlw $24,($24)\nlw $15,-228+264($sp)\nbne $24,$15,L.3143\nlw $24,-224+264($sp)\nla $24,1($24)\nsw $24,-224+264($sp)\nb L.3136\nL.3143:\nla $24,4\nsw $24,-124+264($sp)\nb L.3136\nL.3145:\nlw $24,-120+264($sp)\nsll $24,$24,2\nla $15,-116+264($sp)\naddu $24,$24,$15\nlw $24,($24)\nlw $15,-212+264($sp)\nbeq $24,$15,L.3136\nla $24,4\nsw $24,-124+264($sp)\nL.3135:\nL.3136:\nL.3132:\nlw $24,-120+264($sp)\nla $24,1($24)\nsw $24,-120+264($sp)\nlw $24,-120+264($sp)\nla $15,22\nblt $24,$15,L.3131\nlw $24,-124+264($sp)\nla $15,3\nbne $24,$15,L.3148\nla $24,16\nlw $15,-224+264($sp)\nsubu $2,$24,$15\nb L.3109\nL.3148:\nla $2,-1\nL.3109:\nlw $16,0($sp)\nlw $17,4($sp)\nlw $18,8($sp)\nlw $19,12($sp)\nlw $20,16($sp)\nlw $21,20($sp)\nlw $22,24($sp)\nlw $23,28($sp)\nlw $30,32($sp)\naddu $sp,$sp,264\nj $31\n.end regp\n.lcomm L.3151,420\n.data\n.align 0\nL.3152:\n.byte 115\n.byte 56\n.byte 52\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.sdata\n.align 0\nL.3153:\n.byte 115\n.byte 56\n.byte 52\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s84\n.text\n.text\n.align 2\n.ent s84\ns84:\n.frame $sp,216,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-216\n.fmask 0xc0000000,-200\n.mask 0xc2fc0000,-160\ns.d $f30,16($sp)\nsw $18,24($sp)\nsw $19,28($sp)\nsw $20,32($sp)\nsw $21,36($sp)\nsw $22,40($sp)\nsw $23,44($sp)\n.cprestore 48\nsw $30,52($sp)\nsw $31,56($sp)\nmove $30,$4\nla $20,L.3153\nla $19,60($30)\nmove $18,$0\nL.3154:\nL.3155:\nmove $24,$19\nla $19,1($24)\nmove $15,$20\nla $20,1($15)\nlb $15,($15)\nsb $15,($24)\nsll $24,$15,8*(4-1); sra $24,$24,8*(4-1)\nbne $24,$0,L.3154\nla $4,3\njal fip\nsw $2,-140+216($sp)\nlw $24,-140+216($sp)\nlw $24,($24)\nla $15,3\nbeq $24,$15,L.3157\nlw $24,44($30)\nbeq $24,$0,L.3159\nla $4,L.3152\nla $5,1\njal printf\nL.3159:\nla $18,1($18)\nL.3157:\nla $24,glork\nsw $24,-144+216($sp)\nla $4,4\nlw $25,-144+216($sp)\njal $25\nla $15,4\nbeq $2,$15,L.3161\nlw $24,44($30)\nbeq $24,$0,L.3163\nla $4,L.3152\nla $5,2\njal printf\nL.3163:\nla $18,2($18)\nL.3161:\nmove $22,$0\nL.3165:\nsll $24,$22,2\nla $15,-68+216($sp)\naddu $24,$24,$15\nmtc1 $22,$f18; cvt.s.w $f18,$f18\ns.s $f18,($24)\nsll $24,$22,2\nla $15,-136+216($sp)\naddu $15,$24,$15\nla $14,-68+216($sp)\naddu $24,$24,$14\nsw $24,($15)\nL.3166:\nla $22,1($22)\nla $24,17\nblt $22,$24,L.3165\nl.s $f30,L.412\nmove $22,$0\nL.3169:\nsll $24,$22,2\nla $15,-136+216($sp)\naddu $24,$24,$15\nlw $24,($24)\nl.s $f18,($24)\nadd.s $f30,$f30,$f18\nL.3170:\nla $22,1($22)\nla $24,17\nblt $22,$24,L.3169\nl.s $f18,L.3175\nc.eq.s $f30,$f18; bc1t L.3173\nlw $24,44($30)\nbeq $24,$0,L.3176\nla $4,L.3152\nla $5,4\njal printf\nL.3176:\nla $18,4($18)\nL.3173:\nmove $21,$0\nL.3178:\nmove $22,$0\nL.3182:\nmove $23,$0\nL.3186:\nsll $24,$23,2\nla $15,28\nmul $15,$15,$22\nla $14,140\nmul $14,$14,$21\nla $14,L.3151($14)\naddu $15,$15,$14\naddu $24,$24,$15\nla $15,35\nmul $15,$15,$21\nla $14,7\nmul $14,$14,$22\naddu $15,$15,$14\naddu $15,$15,$23\nsw $15,($24)\nL.3187:\nla $23,1($23)\nla $24,7\nblt $23,$24,L.3186\nL.3183:\nla $22,1($22)\nla $24,5\nblt $22,$24,L.3182\nL.3179:\nla $21,1($21)\nla $24,3\nblt $21,$24,L.3178\nla $21,1\nla $22,2\nla $23,3\nla $4,L.3151\nla $5,105\nmove $6,$0\njal array\nmove $24,$2\nsw $24,-148+216($sp)\nla $15,140\nmul $15,$15,$21\nla $4,L.3151($15)\nla $15,35\nmove $5,$15\nmove $6,$15\njal array\nmove $24,$2\nsw $24,-152+216($sp)\nla $15,28\nmul $15,$15,$22\nla $14,140\nmul $14,$14,$21\nla $14,L.3151($14)\naddu $4,$15,$14\nla $5,7\nla $6,49\njal array\nlw $15,-148+216($sp)\nlw $14,-152+216($sp)\naddu $15,$15,$14\naddu $24,$15,$2\nsll $15,$23,2\nla $14,28\nmul $14,$14,$22\nla $13,140\nmul $13,$13,$21\nla $13,L.3151($13)\naddu $14,$14,$13\naddu $15,$15,$14\nlw $15,($15)\naddu $24,$24,$15\nsubu $24,$24,52\nbeq $24,$0,L.3190\nlw $24,44($30)\nbeq $24,$0,L.3192\nla $4,L.3152\nla $5,8\njal printf\nL.3192:\nla $18,8($18)\nL.3190:\nmove $2,$18\nL.3150:\nl.d $f30,16($sp)\nlw $18,24($sp)\nlw $19,28($sp)\nlw $20,32($sp)\nlw $21,36($sp)\nlw $22,40($sp)\nlw $23,44($sp)\nlw $25,48($sp)\nlw $30,52($sp)\nlw $31,56($sp)\naddu $sp,$sp,216\nj $31\n.end s84\n.globl array\n.text\n.align 2\n.ent array\narray:\n.frame $sp,8,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-8\n.mask 0x40000000,-8\nsw $30,0($sp)\nmove $30,$0\nb L.3198\nL.3195:\nsll $24,$30,2\naddu $24,$24,$4\nlw $24,($24)\naddu $15,$30,$6\nbeq $24,$15,L.3199\nla $2,1\nb L.3194\nL.3199:\nL.3196:\nla $30,1($30)\nL.3198:\nblt $30,$5,L.3195\nmove $2,$0\nL.3194:\nlw $30,0($sp)\naddu $sp,$sp,8\nj $31\n.end array\n.lcomm L.3202,4\n.globl fip\n.text\n.text\n.align 2\n.ent fip\nfip:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nla $24,L.3202\nsw $4,L.3202\nmove $2,$24\nL.3201:\nj $31\n.end fip\n.globl glork\n.text\n.align 2\n.ent glork\nglork:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nmove $2,$4\nL.3203:\nj $31\n.end glork\n.data\n.align 0\nL.3205:\n.byte 115\n.byte 56\n.byte 53\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.sdata\n.align 0\nL.3206:\n.byte 115\n.byte 56\n.byte 53\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.data\n.align 2\nL.3214:\n.word L.425\n.word L.427\n.word L.426\n.word L.428\n.word L.429\n.word L.430\n.word L.431\n.data\n.align 0\nL.3215:\n.byte 32\n.byte 97\n.byte 108\n.byte 105\n.byte 103\n.byte 110\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 58\n.byte 32\n.byte 0\n.globl s85\n.text\n.text\n.align 2\n.ent s85\ns85:\n.frame $sp,440,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-440\n.mask 0xc2f00000,-400\nsw $20,16($sp)\nsw $21,20($sp)\nsw $22,24($sp)\nsw $23,28($sp)\n.cprestore 32\nsw $30,36($sp)\nsw $31,40($sp)\nmove $30,$4\nla $22,L.3206\nla $21,60($30)\nmove $20,$0\nL.3219:\nL.3220:\nmove $24,$21\nla $21,1($24)\nmove $15,$22\nla $22,1($15)\nlb $15,($15)\nsb $15,($24)\nsll $24,$15,8*(4-1); sra $24,$24,8*(4-1)\nbne $24,$0,L.3219\nla $15,-284+440($sp)\nla $14,-304+440($sp)\nsubu $15,$15,$14\nble $15,$0,L.3230\nla $15,-280+440($sp)\nla $14,-284+440($sp)\nsubu $15,$15,$14\nble $15,$0,L.3230\nla $15,-276+440($sp)\nla $14,-280+440($sp)\nsubu $15,$15,$14\nbgt $15,$0,L.3222\nL.3230:\nlw $24,44($30)\nbeq $24,$0,L.3231\nla $4,L.3205\nla $5,1\njal printf\nL.3231:\nla $20,1($20)\nL.3222:\nla $24,-337+440($sp)\nla $15,-338+440($sp)\nsubu $24,$24,$15\nsw $24,-268+440($sp)\nla $24,-340+440($sp)\nla $15,-342+440($sp)\nsubu $24,$24,$15\nsw $24,-264+440($sp)\nla $24,-348+440($sp)\nla $15,-352+440($sp)\nsubu $24,$24,$15\nsw $24,-260+440($sp)\nla $24,-356+440($sp)\nla $15,-360+440($sp)\nsubu $24,$24,$15\nsw $24,-256+440($sp)\nla $24,-364+440($sp)\nla $15,-368+440($sp)\nsubu $24,$24,$15\nsw $24,-252+440($sp)\nla $24,-372+440($sp)\nla $15,-376+440($sp)\nsubu $24,$24,$15\nsw $24,-248+440($sp)\nla $24,-384+440($sp)\nla $15,-392+440($sp)\nsubu $24,$24,$15\nsw $24,-244+440($sp)\nlw $24,40($30)\nbeq $24,$0,L.3246\nmove $23,$0\nL.3248:\nla $4,L.3252\nsll $24,$23,2\nlw $5,L.3214($24)\nla $6,L.3215\nla $15,-268+440($sp)\naddu $24,$24,$15\nlw $7,($24)\njal printf\nL.3249:\nla $23,1($23)\nla $24,7\nblt $23,$24,L.3248\nL.3246:\nlw $24,-272+440($sp)\nor $24,$24,0x1c000000\nsw $24,-272+440($sp)\nlw $24,-272+440($sp)\nmove $15,$24\nand $15,$15,0x3fffffff\nsll $24,$24,3\nsra $24,$24,29\nsll $24,$24,30\nsra $24,$24,30\nsll $24,$24,30\nand $24,$24,0xc0000000\nor $24,$15,$24\nsw $24,-272+440($sp)\nlw $24,-272+440($sp)\nmove $15,$24\nand $15,$15,0xe3ffffff\nsra $24,$24,30\nsll $24,$24,29\nsra $24,$24,29\nsll $24,$24,26\nand $24,$24,0x1c000000\nor $24,$15,$24\nsw $24,-272+440($sp)\nla $24,3\nlw $15,-272+440($sp)\nsll $15,$15,3\nsra $15,$15,29\nbeq $15,$24,L.3253\nlw $24,-272+440($sp)\nsll $24,$24,3\nsra $24,$24,29\nla $15,-1\nbne $24,$15,L.3255\nlw $24,40($30)\nbeq $24,$0,L.3256\nla $4,L.3259\njal printf\nb L.3256\nL.3255:\nlw $24,44($30)\nbeq $24,$0,L.3260\nla $4,L.3205\nla $5,2\njal printf\nL.3260:\nla $20,2($20)\nL.3256:\nL.3253:\nlw $24,-272+440($sp)\nor $24,$24,0x2000000\nsw $24,-272+440($sp)\nlw $24,-272+440($sp)\nsll $24,$24,6\nsra $24,$24,31\nla $15,1\nbeq $24,$15,L.3262\nlw $24,40($30)\nbeq $24,$0,L.3264\nla $4,L.3266\njal printf\nL.3264:\nL.3262:\nla $24,-240+440($sp)\nsubu $24,$24,$24\nbne $24,$0,L.3274\nbne $24,$0,L.3274\nbne $24,$0,L.3274\nbne $24,$0,L.3274\nbne $24,$0,L.3274\nbne $24,$0,L.3274\nbeq $24,$0,L.3267\nL.3274:\nlw $24,44($30)\nbeq $24,$0,L.3275\nla $4,L.3205\nla $5,4\njal printf\nL.3275:\nla $20,4($20)\nL.3267:\nb L.3277\nlw $24,44($30)\nbeq $24,$0,L.3279\nla $4,L.3205\nla $5,8\njal printf\nL.3279:\nla $20,8($20)\nL.3277:\nla $24,-336+440($sp)\nsw $24,-276+440($sp)\nla $24,2\nsb $24,-336+440($sp)\nlw $24,-276+440($sp)\nlb $15,($24)\nla $15,1($15)\nsb $15,($24)\nlb $24,-336+440($sp)\nla $15,3\nbeq $24,$15,L.3283\nlw $24,44($30)\nbeq $24,$0,L.3285\nla $4,L.3205\nla $5,16\njal printf\nL.3285:\nla $20,16($20)\nL.3283:\nmove $2,$20\nL.3204:\nlw $20,16($sp)\nlw $21,20($sp)\nlw $22,24($sp)\nlw $23,28($sp)\nlw $25,32($sp)\nlw $30,36($sp)\nlw $31,40($sp)\naddu $sp,$sp,440\nj $31\n.end s85\n.data\n.align 0\nL.3288:\n.byte 115\n.byte 56\n.byte 54\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.sdata\n.align 0\nL.3289:\n.byte 115\n.byte 56\n.byte 54\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.data\n.align 2\nL.3290:\n.word 0x1\n.word 0x3\n.word 0x5\n.sdata\n.align 2\nL.3291:\n.word L.3290+8\n.lcomm L.3293,40\n.data\n.align 2\nL.3294:\n.word 0x3f800000\n.word 0x40400000\n.word 0x40a00000\n.word 0x40000000\n.word 0x40800000\n.word 0x40c00000\n.word 0x40400000\n.word 0x40a00000\n.word 0x40e00000\n.word 0x0\n.word 0x0\n.word 0x0\n.data\n.align 2\nL.3295:\n.word 0x3f800000\n.word 0x40400000\n.word 0x40a00000\n.word 0x40000000\n.word 0x40800000\n.word 0x40c00000\n.word 0x40400000\n.word 0x40a00000\n.word 0x40e00000\n.space 12\n.data\n.align 2\nL.3296:\n.word 0x3f800000\n.word 0x40400000\n.word 0x40a00000\n.word 0x40000000\n.word 0x40800000\n.word 0x40c00000\n.word 0x40400000\n.word 0x40a00000\n.word 0x40e00000\n.space 12\n.data\n.align 2\nL.3297:\n.word 0x3f800000\n.space 8\n.word 0x40000000\n.space 8\n.word 0x40400000\n.space 8\n.word 0x40800000\n.space 8\n.globl s86\n.text\n.text\n.align 2\n.ent s86\ns86:\n.frame $sp,64,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-64\n.mask 0xc2ff0000,-8\nsw $16,16($sp)\nsw $17,20($sp)\nsw $18,24($sp)\nsw $19,28($sp)\nsw $20,32($sp)\nsw $21,36($sp)\nsw $22,40($sp)\nsw $23,44($sp)\n.cprestore 48\nsw $30,52($sp)\nsw $31,56($sp)\nsw $4,64($sp)\nlw $24,L.3291\nla $16,-4($24)\njal one\nsll $24,$2,2\naddu $30,$24,$16\nla $19,L.3289\nlw $24,0+64($sp)\nla $18,60($24)\nmove $17,$0\nL.3298:\nL.3299:\nmove $24,$18\nla $18,1($24)\nmove $15,$19\nla $19,1($15)\nlb $15,($15)\nsb $15,($24)\nsll $24,$15,8*(4-1); sra $24,$24,8*(4-1)\nbne $24,$0,L.3298\nlw $24,L.3291\nlw $24,($24)\nla $15,5\nbeq $24,$15,L.3301\nlw $24,0+64($sp)\nlw $24,44($24)\nbeq $24,$0,L.3303\nla $4,L.3288\nla $5,1\njal printf\nL.3303:\nla $17,1($17)\nL.3301:\nlw $24,($16)\nla $15,3\nbeq $24,$15,L.3305\nlw $24,0+64($sp)\nlw $24,44($24)\nbeq $24,$0,L.3307\nla $4,L.3288\nla $5,2\njal printf\nL.3307:\nla $17,2($17)\nL.3305:\nlw $24,($30)\nla $15,5\nbeq $24,$15,L.3309\nlw $24,0+64($sp)\nlw $24,44($24)\nbeq $24,$0,L.3311\nla $4,L.3288\nla $5,4\njal printf\nL.3311:\nla $17,4($17)\nL.3309:\nmove $20,$0\nmove $23,$0\nL.3313:\nsll $24,$23,2\nlw $24,L.3293($24)\nbeq $24,$0,L.3317\nla $20,1\nL.3317:\nL.3314:\nla $23,1($23)\nla $24,10\nblt $23,$24,L.3313\nbeq $20,$0,L.3319\nlw $24,0+64($sp)\nlw $24,44($24)\nbeq $24,$0,L.3321\nla $4,L.3288\nla $5,8\njal printf\nL.3321:\nla $17,8($17)\nL.3319:\nmove $20,$0\nmove $22,$0\nL.3323:\nmove $23,$0\nL.3327:\nla $24,3\nmul $24,$24,$22\naddu $21,$24,$23\nsll $24,$23,2\nla $15,12\nmul $15,$15,$22\nla $14,L.3295($15)\naddu $14,$24,$14\nl.s $f18,($14)\nla $15,L.3296($15)\naddu $24,$24,$15\nl.s $f16,($24)\nc.eq.s $f18,$f16; bc1f L.3333\nsll $24,$21,2\nl.s $f16,L.3294($24)\nc.eq.s $f18,$f16; bc1t L.3331\nL.3333:\nla $20,1\nL.3331:\nL.3328:\nla $23,1($23)\nla $24,3\nblt $23,$24,L.3327\nL.3324:\nla $22,1($22)\nla $24,4\nblt $22,$24,L.3323\nbeq $20,$0,L.3334\nlw $24,0+64($sp)\nlw $24,44($24)\nbeq $24,$0,L.3336\nla $4,L.3288\nla $5,16\njal printf\nL.3336:\nla $17,16($17)\nL.3334:\nmove $20,$0\nmove $23,$0\nL.3338:\nla $24,12\nmul $24,$24,$23\nl.s $f18,L.3297($24)\nla $24,1($23)\nmtc1 $24,$f16; cvt.s.w $f16,$f16\nc.eq.s $f18,$f16; bc1t L.3342\nla $20,1\nL.3342:\nL.3339:\nla $23,1($23)\nla $24,4\nblt $23,$24,L.3338\nbeq $20,$0,L.3344\nlw $24,0+64($sp)\nlw $24,44($24)\nbeq $24,$0,L.3346\nla $4,L.3288\nla $5,32\njal printf\nL.3346:\nla $17,32($17)\nL.3344:\nmove $2,$17\nL.3287:\nlw $16,16($sp)\nlw $17,20($sp)\nlw $18,24($sp)\nlw $19,28($sp)\nlw $20,32($sp)\nlw $21,36($sp)\nlw $22,40($sp)\nlw $23,44($sp)\nlw $25,48($sp)\nlw $30,52($sp)\nlw $31,56($sp)\naddu $sp,$sp,64\nj $31\n.end s86\n.globl one\n.text\n.align 2\n.ent one\none:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nla $2,1\nL.3348:\nj $31\n.end one\n.data\n.align 0\nL.3350:\n.byte 115\n.byte 56\n.byte 56\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.sdata\n.align 0\nL.3351:\n.byte 115\n.byte 56\n.byte 56\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s88\n.text\n.text\n.align 2\n.ent s88\ns88:\n.frame $sp,64,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-64\n.mask 0xc2e00000,-28\nsw $21,16($sp)\nsw $22,20($sp)\nsw $23,24($sp)\n.cprestore 28\nsw $30,32($sp)\nsw $31,36($sp)\nsw $4,64($sp)\nla $30,L.3351\nlw $24,0+64($sp)\nla $23,60($24)\nmove $22,$0\nL.3353:\nL.3354:\nmove $24,$23\nla $23,1($24)\nmove $15,$30\nla $30,1($15)\nlb $15,($15)\nsb $15,($24)\nsll $24,$15,8*(4-1); sra $24,$24,8*(4-1)\nbne $24,$0,L.3353\nb L.3356\nlw $24,0+64($sp)\nlw $24,44($24)\nbeq $24,$0,L.3358\nla $4,L.3350\nla $5,1\njal printf\nL.3358:\nla $22,1($22)\nL.3356:\nla $24,-20+64($sp)\nsw $24,metricp\nla $24,2\nsw $24,-20+64($sp)\nlw $24,metricp\nla $15,3\nsw $15,($24)\nlw $24,-20+64($sp)\nla $15,3\nbeq $24,$15,L.3360\nlw $24,0+64($sp)\nlw $24,44($24)\nbeq $24,$0,L.3362\nla $4,L.3350\nla $5,2\njal printf\nL.3362:\nla $22,2($22)\nL.3360:\nl.d $f18,L.419\ns.d $f18,-16+64($sp)\ns.d $f18,-8+64($sp)\nla $21,-16+64($sp)\nl.d $f18,L.418\ns.d $f18,($21)\nl.d $f18,L.418\ns.d $f18,8($21)\nl.d $f18,-16+64($sp)\nl.d $f16,-8+64($sp)\nadd.d $f18,$f18,$f16\nl.d $f16,L.416\nc.eq.d $f18,$f16; bc1t L.3365\nlw $24,0+64($sp)\nlw $24,44($24)\nbeq $24,$0,L.3368\nla $4,L.3350\nla $5,4\njal printf\nL.3368:\nla $22,4($22)\nL.3365:\nmove $2,$22\nL.3349:\nlw $21,16($sp)\nlw $22,20($sp)\nlw $23,24($sp)\nlw $25,28($sp)\nlw $30,32($sp)\nlw $31,36($sp)\naddu $sp,$sp,64\nj $31\n.end s88\n.data\n.align 0\nL.3371:\n.byte 115\n.byte 57\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.sdata\n.align 0\nL.3372:\n.byte 115\n.byte 57\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s9\n.text\n.text\n.align 2\n.ent s9\ns9:\n.frame $sp,64,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-64\n.mask 0xc2ff0000,-8\nsw $16,16($sp)\nsw $17,20($sp)\nsw $18,24($sp)\nsw $19,28($sp)\nsw $20,32($sp)\nsw $21,36($sp)\nsw $22,40($sp)\nsw $23,44($sp)\n.cprestore 48\nsw $30,52($sp)\nsw $31,56($sp)\nsw $4,64($sp)\nla $22,L.3372\nlw $24,0+64($sp)\nla $21,60($24)\nmove $20,$0\nL.3373:\nL.3374:\nmove $24,$21\nla $21,1($24)\nmove $15,$22\nla $22,1($15)\nlb $15,($15)\nsb $15,($24)\nsll $24,$15,8*(4-1); sra $24,$24,8*(4-1)\nbne $24,$0,L.3373\nmove $23,$0\nmove $30,$0\nL.3376:\nla $24,2\nmove $19,$24\nmove $18,$24\nla $24,3\nmove $17,$24\nmove $16,$24\nla $24,3\nbne $16,$24,L.3382\nbeq $17,$24,L.3380\nL.3382:\nla $23,1\nL.3380:\nla $24,2\nbne $18,$24,L.3385\nbeq $19,$24,L.3383\nL.3385:\nla $23,1\nL.3383:\nL.3377:\nla $30,1($30)\nla $24,2\nblt $30,$24,L.3376\nbeq $23,$0,L.3390\nlw $24,0+64($sp)\nlw $24,44($24)\nbeq $24,$0,L.3388\nla $4,L.3371\nla $5,1\njal printf\nL.3388:\nla $20,1($20)\nb L.3390\nlw $24,0+64($sp)\nlw $24,44($24)\nbeq $24,$0,L.3391\nla $4,L.3371\nla $5,2\njal printf\nL.3391:\nla $20,2($20)\nL.3390:\nmove $2,$20\nL.3370:\nlw $16,16($sp)\nlw $17,20($sp)\nlw $18,24($sp)\nlw $19,28($sp)\nlw $20,32($sp)\nlw $21,36($sp)\nlw $22,40($sp)\nlw $23,44($sp)\nlw $25,48($sp)\nlw $30,52($sp)\nlw $31,56($sp)\naddu $sp,$sp,64\nj $31\n.end s9\n.globl setev\n.text\n.align 2\n.ent setev\nsetev:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nla $24,1066\nsw $24,extvar\nmove $2,$0\nL.3393:\nj $31\n.end setev\n.globl rfs\n.comm rfs,8\n.globl crc\n.comm crc,4\n.globl rrc\n.comm rrc,4\n.globl flgl\n.comm flgl,4\n.globl flgd\n.comm flgd,4\n.globl flgm\n.comm flgm,4\n.globl flgs\n.comm flgs,4\n.globl dprec\n.comm dprec,4\n.globl fprec\n.comm fprec,4\n.globl dbits\n.comm dbits,4\n.globl fbits\n.comm fbits,4\n.globl ubits\n.comm ubits,4\n.globl lbits\n.comm lbits,4\n.globl metricp\n.comm metricp,4\n.globl extvar\n.comm extvar,4\n.rdata\n.align 0\nL.3266:\n.byte 66\n.byte 101\n.byte 32\n.byte 101\n.byte 115\n.byte 112\n.byte 101\n.byte 99\n.byte 105\n.byte 97\n.byte 108\n.byte 108\n.byte 121\n.byte 32\n.byte 99\n.byte 97\n.byte 114\n.byte 101\n.byte 102\n.byte 117\n.byte 108\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 49\n.byte 45\n.byte 98\n.byte 105\n.byte 116\n.byte 32\n.byte 102\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 115\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.3259:\n.byte 83\n.byte 105\n.byte 103\n.byte 110\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 101\n.byte 110\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 102\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.3252:\n.byte 37\n.byte 115\n.byte 37\n.byte 115\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 2\nL.3175:\n.word 0x43080000\n.align 0\nL.3022:\n.byte 112\n.byte 111\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 0\n.align 0\nL.2472:\n.byte 73\n.byte 110\n.byte 99\n.byte 114\n.byte 101\n.byte 97\n.byte 115\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 97\n.byte 114\n.byte 114\n.byte 97\n.byte 121\n.byte 32\n.byte 101\n.byte 108\n.byte 101\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 97\n.byte 115\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 100\n.byte 101\n.byte 99\n.byte 114\n.byte 101\n.byte 97\n.byte 115\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 108\n.byte 111\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 10\n.byte 0\n.align 2\nL.2356:\n.word 0x41d00000\n.align 3\nL.2355:\n.word 0x403a0000\n.word 0x0\n.align 3\nL.1659:\n.word 0x40040000\n.word 0x0\n.align 3\nL.1484:\n.word 0x40240000\n.word 0x0\n.align 2\nL.1455:\n.word 0x41200000\n.align 3\nL.1280:\n.word 0x40080000\n.word 0x0\n.align 2\nL.1251:\n.word 0x40400000\n.align 3\nL.1076:\n.word 0x401c0000\n.word 0x0\n.align 2\nL.1047:\n.word 0x40e00000\n.align 3\nL.870:\n.word 0x40140000\n.word 0x0\n.align 2\nL.841:\n.word 0x40a00000\n.align 3\nL.836:\n.word 0x41e00000\n.word 0x0\n.align 2\nL.828:\n.word 0x4f000000\n.align 0\nL.653:\n.byte 113\n.byte 117\n.byte 101\n.byte 101\n.byte 112\n.byte 0\n.align 0\nL.639:\n.byte 10\n.byte 0\n.align 0\nL.638:\n.byte 37\n.byte 100\n.byte 0\n.align 0\nL.633:\n.byte 32\n.byte 32\n.byte 32\n.byte 107\n.byte 101\n.byte 121\n.byte 61\n.byte 0\n.align 3\nL.596:\n.word 0x40000000\n.word 0x0\n.align 3\nL.536:\n.word 0x40ce8480\n.word 0x0\n.align 3\nL.535:\n.word 0x405f4000\n.word 0x0\n.align 2\nL.534:\n.word 0x42fa0000\n.align 2\nL.529:\n.word 0x40000000\n.align 0\nL.431:\n.byte 100\n.byte 111\n.byte 117\n.byte 98\n.byte 108\n.byte 101\n.byte 0\n.align 0\nL.430:\n.byte 102\n.byte 108\n.byte 111\n.byte 97\n.byte 116\n.byte 0\n.align 0\nL.429:\n.byte 117\n.byte 110\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 101\n.byte 100\n.byte 0\n.align 0\nL.428:\n.byte 108\n.byte 111\n.byte 110\n.byte 103\n.byte 0\n.align 0\nL.427:\n.byte 115\n.byte 104\n.byte 111\n.byte 114\n.byte 116\n.byte 0\n.align 0\nL.426:\n.byte 105\n.byte 110\n.byte 116\n.byte 0\n.align 0\nL.425:\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 0\n.align 3\nL.419:\n.word 0x0\n.word 0x0\n.align 3\nL.418:\n.word 0x3ff00000\n.word 0x0\n.align 3\nL.417:\n.word 0x40100000\n.word 0x0\n.align 3\nL.416:\n.word 0x40000000\n.word 0x0\n.align 2\nL.412:\n.word 0x0\n.align 2\nL.411:\n.word 0x3f800000\n.align 0\nL.390:\n.byte 113\n.byte 117\n.byte 101\n.byte 101\n.byte 112\n.byte 33\n.byte 0\n.align 0\nL.379:\n.byte 10\n.byte 9\n.byte 8\n.byte 13\n.byte 12\n.byte 92\n.byte 39\n.byte 0\n.align 0\nL.375:\n.byte 46\n.byte 34\n.byte 46\n.byte 0\n.align 0\nL.362:\n.byte 46\n.byte 46\n.byte 46\n.byte 0\n.align 3\nL.333:\n.word 0x40938800\n.word 0x0\n.align 0\nL.199:\n.byte 32\n.byte 32\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 114\n.byte 101\n.byte 115\n.byte 117\n.byte 108\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 110\n.byte 32\n.byte 97\n.byte 115\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 108\n.byte 111\n.byte 110\n.byte 103\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.198:\n.byte 68\n.byte 101\n.byte 99\n.byte 105\n.byte 109\n.byte 97\n.byte 108\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 111\n.byte 99\n.byte 116\n.byte 97\n.byte 108\n.byte 47\n.byte 104\n.byte 101\n.byte 120\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 115\n.byte 116\n.byte 97\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 115\n.byte 111\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 109\n.byte 101\n.byte 115\n.byte 32\n.byte 103\n.byte 105\n.byte 118\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.27:\n.byte 10\n.byte 70\n.byte 97\n.byte 105\n.byte 108\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.26:\n.byte 10\n.byte 78\n.byte 111\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 115\n.byte 32\n.byte 100\n.byte 101\n.byte 116\n.byte 101\n.byte 99\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.20:\n.byte 83\n.byte 101\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 37\n.byte 115\n.byte 32\n.byte 114\n.byte 101\n.byte 116\n.byte 117\n.byte 114\n.byte 110\n.byte 101\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/mips/irix/tst/cvt.1bk",
    "content": "1 1 1 1 1 1 1 1 1.000000 1.000000 1.000000\n2 2 2 2 2 2 2 2 2.000000 2.000000 2.000000\n3 3 3 3 3 3 3 3 3.000000 3.000000 3.000000\n4 4 4 4 4 4 4 4 4.000000 4.000000 4.000000\n5 5 5 5 5 5 5 5 5.000000 5.000000 5.000000\n6 6 6 6 6 6 6 6 6.000000 6.000000 6.000000\n7 7 7 7 7 7 7 7 7.000000 7.000000 7.000000\n8 8 8 8 8 8 8 8 8.000000 8.000000 8.000000\n9 9 9 9 9 9 9 9 9.000000 9.000000 9.000000\n10 10 10 10 10 10 10 10 10.000000 10.000000 10.000000\n11 11 11 11 11 11 11 11 11.000000 11.000000 11.000000\n"
  },
  {
    "path": "lcc/mips/irix/tst/cvt.2bk",
    "content": "tst/cvt.c:32: warning: conversion from `pointer to void function(void)' to `pointer to void' is compiler dependent\ntst/cvt.c:33: warning: conversion from `pointer to void' to `pointer to void function(void)' is compiler dependent\n"
  },
  {
    "path": "lcc/mips/irix/tst/cvt.sbk",
    "content": ".set reorder\n.globl print\n.text\n.text\n.align 2\n.ent print\nprint:\n.frame $sp,72,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-72\n.mask 0x82000000,-4\n.cprestore 64\nsw $31,68($sp)\nla $4,L.2\nlb $5,c\nlh $6,s\nlw $7,i\nlw $24,l\nsw $24,16($sp)\nlbu $24,C\nsw $24,20($sp)\nlhu $24,S\nsw $24,24($sp)\nlw $24,I\nsw $24,28($sp)\nlw $24,L\nsw $24,32($sp)\nl.s $f18,f\ncvt.d.s $f18,$f18\ns.d $f18,40($sp)\nl.d $f18,d\ns.d $f18,48($sp)\nl.d $f18,D\ns.d $f18,56($sp)\njal printf\nL.1:\nlw $25,64($sp)\nlw $31,68($sp)\naddu $sp,$sp,72\nj $31\n.end print\n.globl main\n.text\n.align 2\n.ent main\nmain:\n.frame $sp,72,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-72\n.mask 0xc2ff0000,-16\nsw $16,16($sp)\nsw $17,20($sp)\nsw $18,24($sp)\nsw $19,28($sp)\nsw $20,32($sp)\nsw $21,36($sp)\nsw $22,40($sp)\nsw $23,44($sp)\n.cprestore 48\nsw $30,52($sp)\nsw $31,56($sp)\nla $24,1\nsb $24,c\nlb $24,c\nmove $15,$24\nsh $15,s\nsw $24,i\nsw $24,l\nmove $15,$24\nmove $14,$15\nsb $14,C\nmove $14,$15\nsh $14,S\nsw $15,I\nsw $15,L\nmtc1 $24,$f18; cvt.s.w $f18,$f18\ns.s $f18,f\nmtc1 $24,$f18; cvt.d.w $f18,$f18\ns.d $f18,d\ns.d $f18,D\njal print\nla $24,2\nsh $24,s\nlh $24,s\nmove $15,$24\nsb $15,c\nsw $24,i\nsw $24,l\nmove $15,$24\nmove $14,$15\nsb $14,C\nmove $14,$15\nsh $14,S\nsw $15,I\nsw $15,L\nmtc1 $24,$f18; cvt.s.w $f18,$f18\ns.s $f18,f\nmtc1 $24,$f18; cvt.d.w $f18,$f18\ns.d $f18,d\ns.d $f18,D\njal print\nla $24,3\nsw $24,i\nlw $24,i\nmove $15,$24\nsb $15,c\nmove $15,$24\nsh $15,s\nsw $24,l\nmove $15,$24\nmove $14,$15\nsb $14,C\nmove $14,$15\nsh $14,S\nsw $15,I\nsw $15,L\nmtc1 $24,$f18; cvt.s.w $f18,$f18\ns.s $f18,f\nmtc1 $24,$f18; cvt.d.w $f18,$f18\ns.d $f18,d\ns.d $f18,D\njal print\nla $24,4\nsw $24,l\nlw $24,l\nmove $15,$24\nsb $15,c\nmove $15,$24\nsh $15,s\nsw $24,i\nmove $15,$24\nmove $14,$15\nsb $14,C\nmove $14,$15\nsh $14,S\nsw $15,I\nsw $15,L\nmtc1 $24,$f18; cvt.s.w $f18,$f18\ns.s $f18,f\nmtc1 $24,$f18; cvt.d.w $f18,$f18\ns.d $f18,d\ns.d $f18,D\njal print\nla $24,5\nsb $24,C\nlbu $24,C\nmove $15,$24\nsb $15,c\nmove $15,$24\nsh $15,s\nsw $24,i\nsw $24,l\nmove $15,$24\nmove $14,$15\nsh $14,S\nsw $15,I\nsw $15,L\nmtc1 $24,$f18; cvt.s.w $f18,$f18\ns.s $f18,f\nmtc1 $24,$f18; cvt.d.w $f18,$f18\ns.d $f18,d\ns.d $f18,D\njal print\nla $24,6\nsh $24,S\nlhu $24,S\nmove $15,$24\nsb $15,c\nmove $15,$24\nsh $15,s\nsw $24,i\nsw $24,l\nmove $15,$24\nmove $14,$15\nsb $14,C\nsw $15,I\nsw $15,L\nmtc1 $24,$f18; cvt.s.w $f18,$f18\ns.s $f18,f\nmtc1 $24,$f18; cvt.d.w $f18,$f18\ns.d $f18,d\ns.d $f18,D\njal print\nla $24,7\nsw $24,I\nlw $24,I\nmove $14,$24\nsb $14,c\nmove $14,$24\nsh $14,s\nsw $24,i\nsw $24,l\nmove $15,$24\nsb $15,C\nmove $15,$24\nsh $15,S\nsw $24,L\nl.d $f18,L.4\nsrl $15,$24,1\nmtc1 $15,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$24,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f18,$f18,$f16\ncvt.s.d $f16,$f18\ns.s $f16,f\ns.d $f18,d\ns.d $f18,D\njal print\nla $24,8\nsw $24,L\nlw $24,L\nmove $14,$24\nsb $14,c\nmove $14,$24\nsh $14,s\nsw $24,i\nsw $24,l\nmove $15,$24\nsb $15,C\nmove $15,$24\nsh $15,S\nlhu $15,S\nsw $15,I\nl.d $f18,L.4\nsrl $15,$24,1\nmtc1 $15,$f16; cvt.d.w $f16,$f16\nmul.d $f18,$f18,$f16\nand $24,$24,1\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nadd.d $f18,$f18,$f16\ncvt.s.d $f16,$f18\ns.s $f16,f\ns.d $f18,d\ns.d $f18,D\njal print\nl.s $f18,L.5\ns.s $f18,f\nl.s $f18,f\ntrunc.w.s $f2,$f18,$24; mfc1 $24,$f2\nmove $15,$24\nsb $15,c\nmove $15,$24\nsh $15,s\nsw $24,i\nsw $24,l\nl.s $f16,L.9\nc.lt.s $f18,$f16; bc1t L.7\nsub.s $f16,$f18,$f16\ntrunc.w.s $f2,$f16,$24; mfc1 $24,$f2\nla $30,0x80000000($24)\nb L.8\nL.7:\ntrunc.w.s $f2,$f18,$24; mfc1 $24,$f2\nmove $30,$24\nL.8:\nmove $24,$30\nsb $24,C\nl.s $f18,f\nl.s $f16,L.9\nc.lt.s $f18,$f16; bc1t L.11\nsub.s $f16,$f18,$f16\ntrunc.w.s $f2,$f16,$24; mfc1 $24,$f2\nla $23,0x80000000($24)\nb L.12\nL.11:\ntrunc.w.s $f2,$f18,$24; mfc1 $24,$f2\nmove $23,$24\nL.12:\nmove $24,$23\nsh $24,S\nl.s $f18,f\nl.s $f16,L.9\nc.lt.s $f18,$f16; bc1t L.14\nsub.s $f16,$f18,$f16\ntrunc.w.s $f2,$f16,$24; mfc1 $24,$f2\nla $22,0x80000000($24)\nb L.15\nL.14:\ntrunc.w.s $f2,$f18,$24; mfc1 $24,$f2\nmove $22,$24\nL.15:\nsw $22,I\nl.s $f18,f\nl.s $f16,L.9\nc.lt.s $f18,$f16; bc1t L.17\nsub.s $f16,$f18,$f16\ntrunc.w.s $f2,$f16,$24; mfc1 $24,$f2\nla $21,0x80000000($24)\nb L.18\nL.17:\ntrunc.w.s $f2,$f18,$24; mfc1 $24,$f2\nmove $21,$24\nL.18:\nsw $21,L\nl.s $f18,f\ncvt.d.s $f18,$f18\ns.d $f18,d\ns.d $f18,D\njal print\nl.d $f18,L.19\ns.d $f18,d\nl.d $f18,d\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nmove $15,$24\nsb $15,c\nmove $15,$24\nsh $15,s\nsw $24,i\nsw $24,l\nl.d $f16,L.23\nc.lt.d $f18,$f16; bc1t L.21\nsub.d $f16,$f18,$f16\ntrunc.w.d $f2,$f16,$24; mfc1 $24,$f2\nla $20,0x80000000($24)\nb L.22\nL.21:\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nmove $20,$24\nL.22:\nmove $24,$20\nsb $24,C\nl.d $f18,d\nl.d $f16,L.23\nc.lt.d $f18,$f16; bc1t L.25\nsub.d $f16,$f18,$f16\ntrunc.w.d $f2,$f16,$24; mfc1 $24,$f2\nla $19,0x80000000($24)\nb L.26\nL.25:\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nmove $19,$24\nL.26:\nmove $24,$19\nsh $24,S\nl.d $f18,d\nl.d $f16,L.23\nc.lt.d $f18,$f16; bc1t L.28\nsub.d $f16,$f18,$f16\ntrunc.w.d $f2,$f16,$24; mfc1 $24,$f2\nla $18,0x80000000($24)\nb L.29\nL.28:\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nmove $18,$24\nL.29:\nsw $18,I\nl.d $f18,d\nl.d $f16,L.23\nc.lt.d $f18,$f16; bc1t L.31\nsub.d $f16,$f18,$f16\ntrunc.w.d $f2,$f16,$24; mfc1 $24,$f2\nla $17,0x80000000($24)\nb L.32\nL.31:\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nmove $17,$24\nL.32:\nsw $17,L\nl.d $f18,d\ncvt.s.d $f16,$f18\ns.s $f16,f\ns.d $f18,D\njal print\nl.d $f18,L.33\ns.d $f18,D\nl.d $f18,D\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nmove $15,$24\nsb $15,c\nmove $15,$24\nsh $15,s\nsw $24,i\nsw $24,l\nl.d $f16,L.37\nc.lt.d $f18,$f16; bc1t L.35\nsub.d $f16,$f18,$f16\ntrunc.w.d $f2,$f16,$24; mfc1 $24,$f2\nla $16,0x80000000($24)\nb L.36\nL.35:\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nmove $16,$24\nL.36:\nmove $24,$16\nsb $24,C\nl.d $f18,D\nl.d $f16,L.37\nc.lt.d $f18,$f16; bc1t L.39\nsub.d $f16,$f18,$f16\ntrunc.w.d $f2,$f16,$24; mfc1 $24,$f2\nla $24,0x80000000($24)\nsw $24,-4+72($sp)\nb L.40\nL.39:\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nsw $24,-4+72($sp)\nL.40:\nlw $24,-4+72($sp)\nsh $24,S\nl.d $f18,D\nl.d $f16,L.37\nc.lt.d $f18,$f16; bc1t L.42\nsub.d $f16,$f18,$f16\ntrunc.w.d $f2,$f16,$24; mfc1 $24,$f2\nla $24,0x80000000($24)\nsw $24,-8+72($sp)\nb L.43\nL.42:\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nsw $24,-8+72($sp)\nL.43:\nlw $24,-8+72($sp)\nsw $24,I\nl.d $f18,D\nl.d $f16,L.37\nc.lt.d $f18,$f16; bc1t L.45\nsub.d $f16,$f18,$f16\ntrunc.w.d $f2,$f16,$24; mfc1 $24,$f2\nla $24,0x80000000($24)\nsw $24,-12+72($sp)\nb L.46\nL.45:\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nsw $24,-12+72($sp)\nL.46:\nlw $24,-12+72($sp)\nsw $24,L\nl.d $f18,D\ncvt.s.d $f16,$f18\ns.s $f16,f\ns.d $f18,d\njal print\nsw $0,p\nsw $0,p\nsw $0,p\nsw $0,p\nlw $24,P\nsw $24,p\nsw $0,P\nsw $0,P\nsw $0,P\nsw $0,P\nlw $24,p\nsw $24,P\nmove $2,$0\nL.3:\nlw $16,16($sp)\nlw $17,20($sp)\nlw $18,24($sp)\nlw $19,28($sp)\nlw $20,32($sp)\nlw $21,36($sp)\nlw $22,40($sp)\nlw $23,44($sp)\nlw $25,48($sp)\nlw $30,52($sp)\nlw $31,56($sp)\naddu $sp,$sp,72\nj $31\n.end main\n.globl P\n.comm P,4\n.globl p\n.comm p,4\n.globl D\n.comm D,8\n.globl d\n.comm d,8\n.globl f\n.comm f,4\n.globl L\n.comm L,4\n.globl I\n.comm I,4\n.globl S\n.comm S,2\n.globl C\n.comm C,1\n.globl l\n.comm l,4\n.globl i\n.comm i,4\n.globl s\n.comm s,2\n.globl c\n.comm c,1\n.rdata\n.align 3\nL.37:\n.word 0x41e00000\n.word 0x0\n.align 3\nL.33:\n.word 0x40260000\n.word 0x0\n.align 3\nL.23:\n.word 0x41e00000\n.word 0x0\n.align 3\nL.19:\n.word 0x40240000\n.word 0x0\n.align 2\nL.9:\n.word 0x4f000000\n.align 2\nL.5:\n.word 0x41100000\n.align 3\nL.4:\n.word 0x40000000\n.word 0x0\n.align 0\nL.2:\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 108\n.byte 100\n.byte 32\n.byte 37\n.byte 117\n.byte 32\n.byte 37\n.byte 117\n.byte 32\n.byte 37\n.byte 117\n.byte 32\n.byte 37\n.byte 108\n.byte 117\n.byte 32\n.byte 37\n.byte 102\n.byte 32\n.byte 37\n.byte 102\n.byte 32\n.byte 37\n.byte 108\n.byte 102\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/mips/irix/tst/fields.1bk",
    "content": "x = 1 2 3 4 -3 6\ny = 3 8 9\nx = 1 2 3 0 0 6\ny = 2 8 16\np->a = 0x3, p->b = 0xf\n"
  },
  {
    "path": "lcc/mips/irix/tst/fields.2bk",
    "content": "tst/fields.c:6: warning: initializer exceeds bit-field width\ntst/fields.c:8: warning: initializer exceeds bit-field width\ntst/fields.c:30: warning: missing return value\ntst/fields.c:34: warning: missing return value\n"
  },
  {
    "path": "lcc/mips/irix/tst/fields.sbk",
    "content": ".set reorder\n.globl x\n.data\n.align 2\nx:\n.word 0x1\n.byte 0x2\n.space 3\n.byte 0x0\n.byte 0x34\n.space 2\n.byte 0xa\n.byte 0x6\n.space 2\n.globl i\n.sdata\n.align 2\ni:\n.word 0x10\n.globl y\n.sdata\n.align 2\ny:\n.byte 0xe0\n.space 3\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x9\n.globl main\n.text\n.text\n.align 2\n.ent main\nmain:\n.frame $sp,40,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-40\n.mask 0x82000000,-8\n.cprestore 28\nsw $31,32($sp)\nla $4,L.4\nlw $5,x\nlb $6,x+4\nlw $24,x+8\nsra $7,$24,20\nlw $24,x+8\nsll $24,$24,12\nsra $24,$24,28\nsw $24,16($sp)\nlw $24,x+12\nsll $24,$24,4\nsra $24,$24,29\nsw $24,20($sp)\nlb $24,x+13\nsw $24,24($sp)\njal printf\nla $4,L.10\nlw $24,y\nsrl $15,$24,30\nand $5,$15,3\nsrl $24,$24,26\nand $6,$24,15\nlw $7,y+4\njal printf\nlw $24,x+8\nand $24,$24,0xfff0ffff\nlw $15,i\nsll $15,$15,28\nsra $15,$15,28\nsll $15,$15,16\nand $15,$15,0xf0000\nor $24,$24,$15\nsw $24,x+8\nlw $24,x+12\nand $24,$24,0xf1ffffff\nsw $24,x+12\nla $4,L.4\nlw $5,x\nlb $6,x+4\nlw $24,x+8\nsra $7,$24,20\nlw $24,x+8\nsll $24,$24,12\nsra $24,$24,28\nsw $24,16($sp)\nlw $24,x+12\nsll $24,$24,4\nsra $24,$24,29\nsw $24,20($sp)\nlb $24,x+13\nsw $24,24($sp)\njal printf\nlw $24,y\nand $24,$24,0x3fffffff\nor $24,$24,0x80000000\nsw $24,y\nlw $24,i\nsw $24,y+4\nla $4,L.10\nlw $24,y\nsrl $15,$24,30\nand $5,$15,3\nsrl $24,$24,26\nand $6,$24,15\nlw $7,y+4\njal printf\nla $4,x\njal f2\nmove $2,$0\nL.3:\nlw $25,28($sp)\nlw $31,32($sp)\naddu $sp,$sp,40\nj $31\n.end main\n.globl f1\n.text\n.align 2\n.ent f1\nf1:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2000000,-8\n.cprestore 16\nsw $30,20($sp)\nsw $31,24($sp)\nmove $30,$4\nlw $24,($30)\nand $24,$24,0xc3ffffff\nsw $24,($30)\nlw $24,($30)\nand $24,$24,0x3fffffff\nand $15,$0,3\nsll $15,$15,30\nand $15,$15,0xc0000000\nor $24,$24,$15\nsw $24,($30)\nlw $24,($30)\nand $24,$24,0x3c000000\nbeq $24,$0,L.22\nla $4,L.24\njal printf\nL.22:\nlw $24,($30)\nor $24,$24,0xc0000000\nsw $24,($30)\nlw $24,($30)\nor $24,$24,0x3c000000\nsw $24,($30)\nla $4,L.25\nlw $24,($30)\nsrl $15,$24,30\nand $5,$15,3\nsrl $24,$24,26\nand $6,$24,15\njal printf\nmove $2,$0\nL.21:\nlw $25,16($sp)\nlw $30,20($sp)\nlw $31,24($sp)\naddu $sp,$sp,32\nj $31\n.end f1\n.globl f2\n.text\n.align 2\n.ent f2\nf2:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2800000,-4\nsw $23,16($sp)\n.cprestore 20\nsw $30,24($sp)\nsw $31,28($sp)\nmove $30,$4\nlw $24,i\nbne $24,$0,L.28\nla $23,1\nb L.29\nL.28:\nmove $23,$0\nL.29:\nlw $24,($30)\nand $24,$24,0x3fffffff\nmove $15,$23\nand $15,$15,3\nsll $15,$15,30\nand $15,$15,0xc0000000\nor $24,$24,$15\nsw $24,($30)\nmove $4,$30\njal f1\nlw $24,($30)\nand $24,$24,0xc3ffffff\nmove $15,$0\nand $15,$15,15\nsll $15,$15,26\nand $15,$15,0x3c000000\nor $24,$24,$15\nsw $24,($30)\nmove $2,$0\nL.26:\nlw $23,16($sp)\nlw $25,20($sp)\nlw $30,24($sp)\nlw $31,28($sp)\naddu $sp,$sp,32\nj $31\n.end f2\n.rdata\n.align 0\nL.25:\n.byte 112\n.byte 45\n.byte 62\n.byte 97\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 120\n.byte 37\n.byte 120\n.byte 44\n.byte 32\n.byte 112\n.byte 45\n.byte 62\n.byte 98\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 120\n.byte 37\n.byte 120\n.byte 10\n.byte 0\n.align 0\nL.24:\n.byte 112\n.byte 45\n.byte 62\n.byte 98\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.10:\n.byte 121\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.4:\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/mips/irix/tst/front.2bk",
    "content": "tst/front.c:3: warning: missing return value\ntst/front.c:10: warning: missing return value\ntst/front.c:20: type error in argument 1 to `s'; found `pointer to struct D' expected `pointer to incomplete struct D defined at tst/front.c:14'\ntst/front.c:21: warning: missing return value\ntst/front.c:32: warning: missing return value\ntst/front.c:36: operands of = have illegal types `pointer to int' and `pointer to const int'\ntst/front.c:38: warning: missing return value\ntst/front.c:62: operands of = have illegal types `pointer to char' and `pointer to const void'\ntst/front.c:63: warning: missing return value\ntst/front.c:68: warning: missing return value\ntst/front.c:69: warning: inconsistent linkage for `yy' previously declared at tst/front.c:68\ntst/front.c:69: warning: missing return value\ntst/front.c:71: invalid storage class `static' for `int function goo'\ntst/front.c:71: warning: declaration of `goo' does not match previous declaration at tst/front.c:70\ntst/front.c:71: warning: missing return value\ntst/front.c:74: warning: declaration of `xr' does not match previous declaration at tst/front.c:72\ntst/front.c:74: warning: missing return value\ntst/front.c:81: warning: missing return value\ntst/front.c:82: warning: declaration of `ss2' does not match previous declaration at tst/front.c:81\ntst/front.c:84: warning: inconsistent linkage for `ss5' previously declared at tst/front.c:80\ntst/front.c:92: type error in argument 1 to `gx1'; found `pointer to double' expected `double'\ntst/front.c:92: warning: missing return value\ntst/front.c:95: redeclaration of `hx1' previously declared at tst/front.c:94\ntst/front.c:98: warning: missing return value\ntst/front.c:101: conflicting argument declarations for function `gg1'\ntst/front.c:101: warning: missing return value\ntst/front.c:112: type error in argument 4 to `qsort'; found `pointer to int function(pointer to pointer to char,pointer to pointer to char)' expected `pointer to int function(pointer to const void,pointer to const void)'\ntst/front.c:113: warning: missing return value\ntst/front.c:120: warning: missing return value\n"
  },
  {
    "path": "lcc/mips/irix/tst/front.sbk",
    "content": ".set reorder\n.globl main\n.text\n.text\n.align 2\n.ent main\nmain:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nmove $4,$0\njal exit\nmove $2,$0\nL.1:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end main\n.globl nested\n.text\n.align 2\n.ent nested\nnested:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nla $24,4\nbge $4,$24,L.6\nla $24,114\nbeq $5,$24,L.9\nL.6:\nla $24,1\nbne $4,$24,L.8\nla $24,104\nbeq $5,$24,L.9\nla $24,105\nbeq $5,$24,L.9\nL.8:\nla $24,2\nbne $4,$24,L.3\nla $24,111\nbeq $5,$24,L.9\nla $24,121\nbne $5,$24,L.3\nL.9:\nmove $4,$5\nL.3:\nmove $2,$0\nL.2:\nj $31\n.end nested\n.globl s\n.text\n.align 2\n.ent s\ns:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nL.10:\nj $31\n.end s\n.globl Dy\n.sdata\n.align 2\nDy:\n.word 0x0\n.space 4\n.globl Dz\n.sdata\n.align 2\nDz:\n.word 0x1\n.space 4\n.globl Dfunc\n.text\n.text\n.align 2\n.ent Dfunc\nDfunc:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end Dfunc\n.globl f\n.text\n.align 2\n.ent f\nf:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nj $31\n.end f\n.globl f1\n.text\n.align 2\n.ent f1\nf1:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nj $31\n.end f1\n.globl f2\n.text\n.align 2\n.ent f2\nf2:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nsw $4,24($sp)\nsw $5,28($sp)\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end f2\n.globl g\n.text\n.align 2\n.ent g\ng:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nsw $4,24($sp)\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end g\n.globl h\n.text\n.align 2\n.ent h\nh:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nsw $4,24($sp)\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end h\n.globl h1\n.text\n.align 2\n.ent h1\nh1:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nsw $4,24($sp)\nsw $5,28($sp)\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end h1\n.globl h2\n.text\n.align 2\n.ent h2\nh2:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nj $31\n.end h2\n.sdata\n.align 2\nL.21:\n.word 0x1\n.globl set1\n.text\n.text\n.align 2\n.ent set1\nset1:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nj $31\n.end set1\n.sdata\n.align 2\nL.23:\n.word 0x2\n.globl set2\n.text\n.text\n.align 2\n.ent set2\nset2:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nj $31\n.end set2\n.text\n.align 2\n.ent goo\ngoo:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nj $31\n.end goo\n.globl sss\n.text\n.align 2\n.ent sss\nsss:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nj $31\n.end sss\n.lcomm L.27,4\n.globl rrr\n.text\n.text\n.align 2\n.ent rrr\nrrr:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nj $31\n.end rrr\n.globl setstatic\n.text\n.align 2\n.ent setstatic\nsetstatic:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nj $31\n.end setstatic\n.globl gx1\n.text\n.align 2\n.ent gx1\ngx1:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\ns.d $f12,24($sp)\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end gx1\n.globl ff1\n.text\n.align 2\n.ent ff1\nff1:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nj $31\n.end ff1\n.globl gg1\n.text\n.align 2\n.ent gg1\ngg1:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nj $31\n.end gg1\n.globl hh1\n.text\n.align 2\n.ent hh1\nhh1:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nj $31\n.end hh1\n.globl cmp\n.text\n.align 2\n.ent cmp\ncmp:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nsw $4,24($sp)\nsw $5,28($sp)\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end cmp\n.globl sort\n.text\n.align 2\n.ent sort\nsort:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end sort\n.globl onearg\n.text\n.align 2\n.ent onearg\nonearg:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end onearg\n.extern xr 4\n.globl ss4\n.comm ss4,4\n.lcomm ss2,4\n.lcomm ss5,4\n.globl ss3\n.comm ss3,4\n.lcomm ss1,4\n.lcomm yy,4\n.globl z\n.comm z,4\n.globl y\n.comm y,4\n.globl x\n.comm x,4\n.globl b\n.comm b,4\n.globl a\n.comm a,4\n"
  },
  {
    "path": "lcc/mips/irix/tst/incr.2bk",
    "content": "tst/incr.c:1: warning: missing return value\ntst/incr.c:6: warning: expression with no effect elided\ntst/incr.c:6: warning: expression with no effect elided\ntst/incr.c:11: warning: missing return value\ntst/incr.c:16: warning: expression with no effect elided\ntst/incr.c:16: warning: expression with no effect elided\ntst/incr.c:21: warning: missing return value\ntst/incr.c:30: warning: missing return value\ntst/incr.c:39: warning: missing return value\n"
  },
  {
    "path": "lcc/mips/irix/tst/incr.sbk",
    "content": ".set reorder\n.globl main\n.text\n.text\n.align 2\n.ent main\nmain:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nmove $2,$0\nL.1:\nj $31\n.end main\n.globl memchar\n.text\n.align 2\n.ent memchar\nmemchar:\n.frame $sp,8,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-8\nlw $24,-8+8($sp)\nla $15,1($24)\nsw $15,-8+8($sp)\nlb $24,($24)\nsb $24,-1+8($sp)\nlw $24,-8+8($sp)\nla $24,1($24)\nsw $24,-8+8($sp)\nlb $24,($24)\nsb $24,-1+8($sp)\nlw $24,-8+8($sp)\nla $15,-1($24)\nsw $15,-8+8($sp)\nlb $24,($24)\nsb $24,-1+8($sp)\nlw $24,-8+8($sp)\nla $24,-1($24)\nsw $24,-8+8($sp)\nlb $24,($24)\nsb $24,-1+8($sp)\nmove $2,$0\nL.2:\naddu $sp,$sp,8\nj $31\n.end memchar\n.globl memint\n.text\n.align 2\n.ent memint\nmemint:\n.frame $sp,8,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-8\nlw $24,-8+8($sp)\nla $15,4($24)\nsw $15,-8+8($sp)\nlw $24,($24)\nsw $24,-4+8($sp)\nlw $24,-8+8($sp)\nla $24,4($24)\nsw $24,-8+8($sp)\nlw $24,($24)\nsw $24,-4+8($sp)\nlw $24,-8+8($sp)\nla $15,-4($24)\nsw $15,-8+8($sp)\nlw $24,($24)\nsw $24,-4+8($sp)\nlw $24,-8+8($sp)\nla $24,-4($24)\nsw $24,-8+8($sp)\nlw $24,($24)\nsw $24,-4+8($sp)\nmove $2,$0\nL.3:\naddu $sp,$sp,8\nj $31\n.end memint\n.globl regchar\n.text\n.align 2\n.ent regchar\nregchar:\n.frame $sp,8,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-8\n.mask 0x40800000,-4\nsw $23,0($sp)\nsw $30,4($sp)\nmove $24,$23\nla $23,1($24)\nlb $30,($24)\nla $24,1($23)\nmove $23,$24\nlb $30,($24)\nmove $24,$23\nla $23,-1($24)\nlb $30,($24)\nla $24,-1($23)\nmove $23,$24\nlb $30,($24)\nmove $2,$0\nL.4:\nlw $23,0($sp)\nlw $30,4($sp)\naddu $sp,$sp,8\nj $31\n.end regchar\n.globl regint\n.text\n.align 2\n.ent regint\nregint:\n.frame $sp,8,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-8\n.mask 0x40800000,-4\nsw $23,0($sp)\nsw $30,4($sp)\nmove $24,$23\nla $23,4($24)\nlw $30,($24)\nla $24,4($23)\nmove $23,$24\nlw $30,($24)\nmove $24,$23\nla $23,-4($24)\nlw $30,($24)\nla $24,-4($23)\nmove $23,$24\nlw $30,($24)\nmove $2,$0\nL.5:\nlw $23,0($sp)\nlw $30,4($sp)\naddu $sp,$sp,8\nj $31\n.end regint\n"
  },
  {
    "path": "lcc/mips/irix/tst/init.1bk",
    "content": " 1 2 3 4\n 5 6\n 7\nif\nfor\nelse\nwhile\n1 2 3 if\n4 5 0 for\n6 7 8 else\n9 10 11 while\n1 2 3 if\n4 5 0 for\n6 7 8 else\n9 10 11 while\n0 0 0 \n"
  },
  {
    "path": "lcc/mips/irix/tst/init.2bk",
    "content": "tst/init.c:36: warning: missing return value\ntst/init.c:49: warning: missing return value\ntst/init.c:59: warning: missing return value\n"
  },
  {
    "path": "lcc/mips/irix/tst/init.sbk",
    "content": ".set reorder\n.globl words\n.data\n.align 2\nwords:\n.word 0x1\n.word 0x2\n.word 0x3\n.byte 105\n.byte 102\n.byte 0\n.space 3\n.space 2\n.word 0x4\n.word 0x5\n.space 4\n.byte 102\n.byte 111\n.byte 114\n.space 3\n.space 2\n.word 0x6\n.word 0x7\n.word 0x8\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 0\n.space 1\n.space 2\n.word 0x9\n.word 0xa\n.word 0xb\n.byte 119\n.byte 104\n.byte 105\n.byte 108\n.byte 101\n.space 1\n.space 2\n.word 0x0\n.space 8\n.space 8\n.globl wordlist\n.sdata\n.align 2\nwordlist:\n.word words\n.globl x\n.data\n.align 2\nx:\n.word 0x1\n.word 0x2\n.word 0x3\n.word 0x4\n.word 0x0\n.word 0x5\n.word 0x6\n.space 12\n.word 0x7\n.space 16\n.globl y\n.data\n.align 2\ny:\n.word x\n.word x+20\n.word x+40\n.word 0x0\n.globl main\n.text\n.text\n.align 2\n.ent main\nmain:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2800000,-4\nsw $23,16($sp)\n.cprestore 20\nsw $30,24($sp)\nsw $31,28($sp)\nmove $23,$0\nb L.8\nL.5:\nmove $30,$0\nb L.12\nL.9:\nla $4,L.13\nsll $24,$30,2\nsll $15,$23,2\nlw $15,y($15)\naddu $24,$24,$15\nlw $5,($24)\njal printf\nL.10:\nla $30,1($30)\nL.12:\nsll $24,$30,2\nsll $15,$23,2\nlw $15,y($15)\naddu $24,$24,$15\nlw $24,($24)\nbne $24,$0,L.9\nla $4,L.14\njal printf\nL.6:\nla $23,1($23)\nL.8:\nsll $24,$23,2\nlw $24,y($24)\nbne $24,$0,L.5\njal f\nlw $4,wordlist\njal g\nmove $2,$0\nL.4:\nlw $23,16($sp)\nlw $25,20($sp)\nlw $30,24($sp)\nlw $31,28($sp)\naddu $sp,$sp,32\nj $31\n.end main\n.data\n.align 2\nL.16:\n.word L.17\n.word L.18\n.word L.19\n.word L.20\n.word 0x0\n.globl f\n.text\n.text\n.align 2\n.ent f\nf:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2000000,-8\n.cprestore 16\nsw $30,20($sp)\nsw $31,24($sp)\nla $30,L.16\nb L.24\nL.21:\nla $4,L.25\nlw $5,($30)\njal printf\nL.22:\nla $30,4($30)\nL.24:\nlw $24,($30)\nbne $24,$0,L.21\nmove $2,$0\nL.15:\nlw $25,16($sp)\nlw $30,20($sp)\nlw $31,24($sp)\naddu $sp,$sp,32\nj $31\n.end f\n.globl g\n.text\n.align 2\n.ent g\ng:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2800000,-4\nsw $23,16($sp)\n.cprestore 20\nsw $30,24($sp)\nsw $31,28($sp)\nmove $30,$4\nb L.30\nL.27:\nmove $23,$0\nb L.34\nL.31:\nla $4,L.35\nsll $24,$23,2\naddu $24,$24,$30\nlw $5,($24)\njal printf\nL.32:\nla $23,1($23)\nL.34:\nmove $24,$23\nla $15,3\nbltu $24,$15,L.31\nla $4,L.25\nla $5,12($30)\njal printf\nL.28:\nla $30,20($30)\nL.30:\nlw $24,($30)\nbne $24,$0,L.27\njal h\nmove $2,$0\nL.26:\nlw $23,16($sp)\nlw $25,20($sp)\nlw $30,24($sp)\nlw $31,28($sp)\naddu $sp,$sp,32\nj $31\n.end g\n.globl h\n.text\n.align 2\n.ent h\nh:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2000000,-4\n.cprestore 20\nsw $30,24($sp)\nsw $31,28($sp)\nmove $30,$0\nb L.40\nL.37:\nla $4,L.41\nla $24,20\nmul $24,$24,$30\nlw $5,words($24)\nlw $6,words+4($24)\nlw $7,words+8($24)\nla $24,words+12($24)\nsw $24,16($sp)\njal printf\nL.38:\nla $30,1($30)\nL.40:\nmove $24,$30\nla $15,5\nbltu $24,$15,L.37\nmove $2,$0\nL.36:\nlw $25,20($sp)\nlw $30,24($sp)\nlw $31,28($sp)\naddu $sp,$sp,32\nj $31\n.end h\n.rdata\n.align 0\nL.41:\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.35:\n.byte 37\n.byte 100\n.byte 32\n.byte 0\n.align 0\nL.25:\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.20:\n.byte 119\n.byte 104\n.byte 105\n.byte 108\n.byte 101\n.byte 0\n.align 0\nL.19:\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 0\n.align 0\nL.18:\n.byte 102\n.byte 111\n.byte 114\n.byte 0\n.align 0\nL.17:\n.byte 105\n.byte 102\n.byte 0\n.align 0\nL.14:\n.byte 10\n.byte 0\n.align 0\nL.13:\n.byte 32\n.byte 37\n.byte 100\n.byte 0\n"
  },
  {
    "path": "lcc/mips/irix/tst/limits.1bk",
    "content": "UCHAR_MAX:\t000000ff=255\nUSHRT_MAX:\t0000ffff=65535\nUINT_MAX:\tffffffff=-1\nULONG_MAX:\tffffffff=-1\nCHAR_MAX:\t0000007f=127\nSCHAR_MAX:\t0000007f=127\nSHRT_MAX:\t00007fff=32767\nINT_MAX:\t7fffffff=2147483647\nLONG_MAX:\t7fffffff=2147483647\nCHAR_MIN:\tffffff80=-128\nSCHAR_MIN:\tffffff80=-128\nSHRT_MIN:\tffff8000=-32768\nINT_MIN:\t80000000=-2147483648\nLONG_MIN:\t80000000=-2147483648\n"
  },
  {
    "path": "lcc/mips/irix/tst/limits.2bk",
    "content": ""
  },
  {
    "path": "lcc/mips/irix/tst/limits.sbk",
    "content": ".set reorder\n.globl main\n.text\n.text\n.align 2\n.ent main\nmain:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nla $4,L.2\nla $24,255\nmove $5,$24\nmove $6,$24\njal printf\nla $4,L.3\nla $24,65535\nmove $5,$24\nmove $6,$24\njal printf\nla $4,L.4\nla $24,0xffffffff\nmove $5,$24\nmove $6,$24\njal printf\nla $4,L.5\nla $24,0xffffffff\nmove $5,$24\nmove $6,$24\njal printf\nla $4,L.6\nla $24,127\nmove $5,$24\nmove $6,$24\njal printf\nla $4,L.7\nla $24,127\nmove $5,$24\nmove $6,$24\njal printf\nla $4,L.8\nla $24,32767\nmove $5,$24\nmove $6,$24\njal printf\nla $4,L.9\nla $24,2147483647\nmove $5,$24\nmove $6,$24\njal printf\nla $4,L.10\nla $24,2147483647\nmove $5,$24\nmove $6,$24\njal printf\nla $4,L.11\nla $24,-128\nmove $5,$24\nmove $6,$24\njal printf\nla $4,L.12\nla $24,-128\nmove $5,$24\nmove $6,$24\njal printf\nla $4,L.13\nla $24,-32768\nmove $5,$24\nmove $6,$24\njal printf\nla $4,L.14\nla $24,-2147483648\nmove $5,$24\nmove $6,$24\njal printf\nla $4,L.15\nla $24,-2147483648\nmove $5,$24\nmove $6,$24\njal printf\nmove $2,$0\nL.1:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end main\n.rdata\n.align 0\nL.15:\n.byte 76\n.byte 79\n.byte 78\n.byte 71\n.byte 95\n.byte 77\n.byte 73\n.byte 78\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 108\n.byte 120\n.byte 61\n.byte 37\n.byte 108\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.14:\n.byte 73\n.byte 78\n.byte 84\n.byte 95\n.byte 77\n.byte 73\n.byte 78\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.13:\n.byte 83\n.byte 72\n.byte 82\n.byte 84\n.byte 95\n.byte 77\n.byte 73\n.byte 78\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.12:\n.byte 83\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 95\n.byte 77\n.byte 73\n.byte 78\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.11:\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 95\n.byte 77\n.byte 73\n.byte 78\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.10:\n.byte 76\n.byte 79\n.byte 78\n.byte 71\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 108\n.byte 120\n.byte 61\n.byte 37\n.byte 108\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.9:\n.byte 73\n.byte 78\n.byte 84\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.8:\n.byte 83\n.byte 72\n.byte 82\n.byte 84\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.7:\n.byte 83\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.6:\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.5:\n.byte 85\n.byte 76\n.byte 79\n.byte 78\n.byte 71\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 108\n.byte 120\n.byte 61\n.byte 37\n.byte 108\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.4:\n.byte 85\n.byte 73\n.byte 78\n.byte 84\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.3:\n.byte 85\n.byte 83\n.byte 72\n.byte 82\n.byte 84\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.2:\n.byte 85\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/mips/irix/tst/paranoia.1bk",
    "content": "Lest this program stop prematurely, i.e. before displaying\n\n    `END OF TEST',\n\ntry to persuade the computer NOT to terminate execution when an\nerror like Over/Underflow or Division by Zero occurs, but rather\nto persevere with a surrogate value after, perhaps, displaying some\nwarning.  If persuasion avails naught, don't despair but run this\nprogram anyway to see how many milestones it passes, and then\namend it to make further progress.\n\nAnswer questions with Y, y, N or n (unless otherwise indicated).\n\n\nDiagnosis resumes after milestone Number 0          Page: 1\n\nUsers are invited to help debug and augment this program so it will\ncope with unanticipated and newly uncovered arithmetic pathologies.\n\nPlease send suggestions and interesting results to\n\tRichard Karpinski\n\tComputer Center U-76\n\tUniversity of California\n\tSan Francisco, CA 94143-0704, USA\n\nIn doing so, please include the following information:\n\tPrecision:\tdouble;\n\tVersion:\t10 February 1989;\n\tComputer:\n\n\tCompiler:\n\n\tOptimization level:\n\n\tOther relevant compiler options:\n\nDiagnosis resumes after milestone Number 1          Page: 2\n\nRunning this program should reveal these characteristics:\n     Radix = 1, 2, 4, 8, 10, 16, 100, 256 ...\n     Precision = number of significant digits carried.\n     U2 = Radix/Radix^Precision = One Ulp\n\t(OneUlpnit in the Last Place) of 1.000xxx .\n     U1 = 1/Radix^Precision = One Ulp of numbers a little less than 1.0 .\n     Adequacy of guard digits for Mult., Div. and Subt.\n     Whether arithmetic is chopped, correctly rounded, or something else\n\tfor Mult., Div., Add/Subt. and Sqrt.\n     Whether a Sticky Bit used correctly for rounding.\n     UnderflowThreshold = an underflow threshold.\n     E0 and PseudoZero tell whether underflow is abrupt, gradual, or fuzzy.\n     V = an overflow threshold, roughly.\n     V0  tells, roughly, whether  Infinity  is represented.\n     Comparisions are checked for consistency with subtraction\n\tand for contamination with pseudo-zeros.\n     Sqrt is tested.  Y^X is not tested.\n     Extra-precise subexpressions are revealed but NOT YET tested.\n     Decimal-Binary conversion is NOT YET tested for accuracy.\n\nDiagnosis resumes after milestone Number 2          Page: 3\n\nThe program attempts to discriminate among\n   FLAWs, like lack of a sticky bit,\n   Serious DEFECTs, like lack of a guard digit, and\n   FAILUREs, like 2+2 == 5 .\nFailures may confound subsequent diagnoses.\n\nThe diagnostic capabilities of this program go beyond an earlier\nprogram called `MACHAR', which can be found at the end of the\nbook  `Software Manual for the Elementary Functions' (1980) by\nW. J. Cody and W. Waite. Although both programs try to discover\nthe Radix, Precision and range (over/underflow thresholds)\nof the arithmetic, this program tries to cope with a wider variety\nof pathologies, and to say how well the arithmetic is implemented.\n\nThe program is based upon a conventional radix representation for\nfloating-point numbers, but also allows logarithmic encoding\nas used by certain early WANG machines.\n\nBASIC version of this program (C) 1983 by Prof. W. M. Kahan;\nsee source comments for more history.\n\nDiagnosis resumes after milestone Number 3          Page: 4\n\nProgram is now RUNNING tests on small integers:\n-1, 0, 1/2, 1, 2, 3, 4, 5, 9, 27, 32 & 240 are O.K.\n\nSearching for Radix and Precision.\nRadix = 2.000000 .\nClosest relative separation found is U1 = 1.1102230e-16 .\n\nRecalculating radix and precision\n confirms closest relative separation U1 .\nRadix confirmed.\nThe number of significant digits of the Radix is 53.000000 .\n\nDiagnosis resumes after milestone Number 30          Page: 5\n\nSubtraction appears to be normalized, as it should be.\nChecking for guard digit in *, /, and -.\n     *, /, and - appear to have guard digits, as they should.\n\nDiagnosis resumes after milestone Number 40          Page: 6\n\nChecking rounding on multiply, divide and add/subtract.\nMultiplication appears to round correctly.\nDivision appears to round correctly.\nAddition/Subtraction appears to round correctly.\nChecking for sticky bit.\nSticky bit apparently used correctly.\n\nDoes Multiplication commute?  Testing on 20 random pairs.\n     No failures found in 20 integer pairs.\n\nRunning test of square root(x).\nTesting if sqrt(X * X) == X for 20 Integers X.\nTest for sqrt monotonicity.\nsqrt has passed a test for Monotonicity.\nTesting whether sqrt is rounded or chopped.\nSquare root appears to be correctly rounded.\n\nDiagnosis resumes after milestone Number 90          Page: 7\n\nTesting powers Z^i for small Integers Z and i.\n... no discrepancis found.\n\nSeeking Underflow thresholds UfThold and E0.\nSmallest strictly positive number found is E0 = 4.94066e-324 .\nSince comparison denies Z = 0, evaluating (Z + Z) / Z should be safe.\nWhat the machine gets for (Z + Z) / Z is  2.00000000000000000e+00 .\nThis is O.K., provided Over/Underflow has NOT just been signaled.\nUnderflow is gradual; it incurs Absolute Error =\n(roundoff in UfThold) < E0.\nThe Underflow threshold is 2.22507385850720190e-308,  below which\ncalculation may suffer larger Relative error than merely roundoff.\nSince underflow occurs below the threshold\nUfThold = (2.00000000000000000e+00) ^ (-1.02200000000000000e+03)\nonly underflow should afflict the expression\n\t(2.00000000000000000e+00) ^ (-1.02200000000000000e+03);\nactually calculating yields: 0.00000000000000000e+00 .\nThis computed value is O.K.\n\nTesting X^((X + 1) / (X - 1)) vs. exp(2) = 7.38905609893065220e+00 as X -> 1.\nAccuracy seems adequate.\nTesting powers Z^Q at four nearly extreme values.\n ... no discrepancies found.\n\n\nDiagnosis resumes after milestone Number 160          Page: 8\n\nSearching for Overflow threshold:\nThis may generate an error.\nCan `Z = -Y' overflow?\nTrying it on Y = -inf .\nSeems O.K.\nOverflow threshold is V  = 1.79769313486231570e+308 .\nOverflow saturates at V0 = inf .\nNo Overflow should be signaled for V * 1 = 1.79769313486231570e+308\n                           nor for V / 1 = 1.79769313486231570e+308 .\nAny overflow signal separating this * from the one\nabove is a DEFECT.\n\n\nDiagnosis resumes after milestone Number 190          Page: 9\n\n\nWhat message and/or values does Division by Zero produce?\n    Trying to compute 1 / 0 produces ...  inf .\n\n    Trying to compute 0 / 0 produces ...  nan .\n\nDiagnosis resumes after milestone Number 220          Page: 10\n\n\n\nNo failures, defects nor flaws have been discovered.\nRounding appears to conform to the proposed IEEE standard P754.\nThe arithmetic diagnosed appears to be Excellent!\nEND OF TEST.\n"
  },
  {
    "path": "lcc/mips/irix/tst/paranoia.2bk",
    "content": "tst/paranoia.c:1867: warning: missing return value\ntst/paranoia.c:1874: warning: missing return value\ntst/paranoia.c:1884: warning: missing return value\ntst/paranoia.c:1924: warning: missing return value\ntst/paranoia.c:1939: warning: missing return value\ntst/paranoia.c:1956: warning: missing return value\ntst/paranoia.c:1975: warning: missing return value\ntst/paranoia.c:1988: warning: missing return value\ntst/paranoia.c:1995: warning: missing return value\ntst/paranoia.c:2055: warning: missing return value\ntst/paranoia.c:2062: warning: missing return value\ntst/paranoia.c:2070: warning: missing return value\ntst/paranoia.c:2087: warning: missing return value\ntst/paranoia.c:2115: warning: missing return value\ntst/paranoia.c:2144: warning: missing return value\ntst/paranoia.c:2173: warning: missing return value\n"
  },
  {
    "path": "lcc/mips/irix/tst/paranoia.sbk",
    "content": ".set reorder\n.globl Zero\n.sdata\n.align 3\nZero:\n.word 0x0\n.word 0x0\n.globl Half\n.sdata\n.align 3\nHalf:\n.word 0x3fe00000\n.word 0x0\n.globl One\n.sdata\n.align 3\nOne:\n.word 0x3ff00000\n.word 0x0\n.globl Two\n.sdata\n.align 3\nTwo:\n.word 0x40000000\n.word 0x0\n.globl Three\n.sdata\n.align 3\nThree:\n.word 0x40080000\n.word 0x0\n.globl Four\n.sdata\n.align 3\nFour:\n.word 0x40100000\n.word 0x0\n.globl Five\n.sdata\n.align 3\nFive:\n.word 0x40140000\n.word 0x0\n.globl Eight\n.sdata\n.align 3\nEight:\n.word 0x40200000\n.word 0x0\n.globl Nine\n.sdata\n.align 3\nNine:\n.word 0x40220000\n.word 0x0\n.globl TwentySeven\n.sdata\n.align 3\nTwentySeven:\n.word 0x403b0000\n.word 0x0\n.globl ThirtyTwo\n.sdata\n.align 3\nThirtyTwo:\n.word 0x40400000\n.word 0x0\n.globl TwoForty\n.sdata\n.align 3\nTwoForty:\n.word 0x406e0000\n.word 0x0\n.globl MinusOne\n.sdata\n.align 3\nMinusOne:\n.word 0xbff00000\n.word 0x0\n.globl OneAndHalf\n.sdata\n.align 3\nOneAndHalf:\n.word 0x3ff80000\n.word 0x0\n.globl NoTrials\n.sdata\n.align 2\nNoTrials:\n.word 0x14\n.globl sigfpe\n.text\n.text\n.align 2\n.ent sigfpe\nsigfpe:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nsw $4,24($sp)\nlw $24,fpecount\nla $24,1($24)\nsw $24,fpecount\nla $4,L.2\njal printf\nla $4,_iob+16\njal fflush\nlw $24,sigsave\nbeq $24,$0,L.4\nla $4,8\nlw $5,sigsave\njal signal\nsw $0,sigsave\nla $4,ovfl_buf\nla $5,1\njal longjmp\nL.4:\njal abort\nL.1:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end sigfpe\n.data\n.align 2\nL.757:\n.word L.758\n.word L.759\n.word L.760\n.word L.761\n.globl main\n.text\n.text\n.align 2\n.ent main\nmain:\n.frame $sp,240,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-240\n.mask 0xc2ff0000,-168\nsw $16,32($sp)\nsw $17,36($sp)\nsw $18,40($sp)\nsw $19,44($sp)\nsw $20,48($sp)\nsw $21,52($sp)\nsw $22,56($sp)\nsw $23,60($sp)\n.cprestore 64\nsw $30,68($sp)\nsw $31,72($sp)\nl.d $f18,L.7\ns.d $f18,Zero\nl.d $f18,L.8\ns.d $f18,One\nl.d $f18,One\nadd.d $f16,$f18,$f18\ns.d $f16,Two\nl.d $f16,Two\nadd.d $f10,$f16,$f18\ns.d $f10,Three\nl.d $f10,Three\nadd.d $f8,$f10,$f18\ns.d $f8,Four\nl.d $f8,Four\nadd.d $f6,$f8,$f18\ns.d $f6,Five\nadd.d $f6,$f8,$f8\ns.d $f6,Eight\nmul.d $f6,$f10,$f10\ns.d $f6,Nine\nl.d $f6,Nine\nmul.d $f6,$f6,$f10\ns.d $f6,TwentySeven\nl.d $f6,Eight\nmul.d $f6,$f8,$f6\ns.d $f6,ThirtyTwo\nl.d $f6,Five\nmul.d $f6,$f8,$f6\nmul.d $f10,$f6,$f10\nmul.d $f10,$f10,$f8\ns.d $f10,TwoForty\nneg.d $f10,$f18\ns.d $f10,MinusOne\ndiv.d $f16,$f18,$f16\ns.d $f16,Half\nl.d $f16,Half\nadd.d $f18,$f18,$f16\ns.d $f18,OneAndHalf\nsw $0,ErrCnt\nsw $0,ErrCnt+4\nsw $0,ErrCnt+8\nsw $0,ErrCnt+12\nla $24,1\nsw $24,PageNo\nsw $0,Milestone\nla $4,8\nla $5,sigfpe\njal signal\njal Instructions\njal Pause\njal Heading\njal Pause\njal Characteristics\njal Pause\njal History\njal Pause\nla $24,7\nsw $24,Milestone\nla $4,L.12\njal printf\nmove $4,$0\nl.d $f18,Zero\nadd.d $f16,$f18,$f18\nc.eq.d $f16,$f18; bc1f L.15\nl.d $f16,One\nsub.d $f10,$f16,$f16\nc.eq.d $f10,$f18; bc1f L.15\nc.le.d $f16,$f18; bc1t L.15\nadd.d $f18,$f16,$f16\nl.d $f16,Two\nc.eq.d $f18,$f16; bc1f L.15\nla $30,1\nb L.16\nL.15:\nmove $30,$0\nL.16:\nmove $5,$30\nla $6,L.14\njal TstCond\nl.d $f18,Zero\nneg.d $f18,$f18\ns.d $f18,Z\nl.d $f18,Z\nl.d $f16,L.7\nc.eq.d $f18,$f16; bc1t L.17\nlw $24,ErrCnt\nla $24,1($24)\nsw $24,ErrCnt\nla $4,L.19\njal printf\nl.d $f18,L.20\ns.d $f18,U1\nl.d $f18,L.8\ns.d $f18,Radix\njal TstPtUf\nL.17:\nmove $4,$0\nl.d $f18,Three\nl.d $f16,Two\nl.d $f10,One\nadd.d $f8,$f16,$f10\nc.eq.d $f18,$f8; bc1f L.23\nl.d $f8,Four\nadd.d $f6,$f18,$f10\nc.eq.d $f8,$f6; bc1f L.23\nl.d $f6,Zero\nneg.d $f4,$f16\nmul.d $f16,$f16,$f4\nadd.d $f16,$f8,$f16\nc.eq.d $f16,$f6; bc1f L.23\nsub.d $f18,$f8,$f18\nsub.d $f18,$f18,$f10\nc.eq.d $f18,$f6; bc1f L.23\nla $23,1\nb L.24\nL.23:\nmove $23,$0\nL.24:\nmove $5,$23\nla $6,L.22\njal TstCond\nl.d $f18,MinusOne\ns.d $f18,-8+240($sp)\nl.d $f16,One\nl.d $f10,L.7\nsub.d $f10,$f10,$f16\nc.eq.d $f18,$f10; bc1f L.27\nl.d $f10,Zero\nadd.d $f8,$f18,$f16\nc.eq.d $f8,$f10; bc1f L.27\nadd.d $f8,$f16,$f18\nc.eq.d $f8,$f10; bc1f L.27\nmov.d $f12,$f16\njal fabs\nl.d $f16,Zero\nl.d $f10,-8+240($sp)\nadd.d $f18,$f10,$f0\nc.eq.d $f18,$f16; bc1f L.27\nl.d $f18,MinusOne\nmul.d $f10,$f18,$f18\nadd.d $f18,$f18,$f10\nc.eq.d $f18,$f16; bc1f L.27\nla $22,1\nb L.28\nL.27:\nmove $22,$0\nL.28:\nmove $4,$0\nmove $5,$22\nla $6,L.26\njal TstCond\nmove $4,$0\nl.d $f18,Half\nl.d $f16,MinusOne\nadd.d $f16,$f18,$f16\nadd.d $f18,$f16,$f18\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1f L.31\nla $21,1\nb L.32\nL.31:\nmove $21,$0\nL.32:\nmove $5,$21\nla $6,L.30\njal TstCond\nla $24,10\nsw $24,Milestone\nmove $4,$0\nl.d $f18,Nine\nl.d $f16,Three\nmul.d $f10,$f16,$f16\nc.eq.d $f18,$f10; bc1f L.35\nl.d $f10,TwentySeven\nmul.d $f18,$f18,$f16\nc.eq.d $f10,$f18; bc1f L.35\nl.d $f18,Eight\nl.d $f16,Four\nadd.d $f8,$f16,$f16\nc.eq.d $f18,$f8; bc1f L.35\nl.d $f8,ThirtyTwo\nmul.d $f18,$f18,$f16\nc.eq.d $f8,$f18; bc1f L.35\nsub.d $f18,$f8,$f10\nsub.d $f18,$f18,$f16\nl.d $f16,One\nsub.d $f18,$f18,$f16\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1f L.35\nla $20,1\nb L.36\nL.35:\nmove $20,$0\nL.36:\nmove $5,$20\nla $6,L.34\njal TstCond\nmove $4,$0\nl.d $f18,Five\nl.d $f16,Four\nl.d $f10,One\nadd.d $f10,$f16,$f10\nc.eq.d $f18,$f10; bc1f L.39\nl.d $f10,TwoForty\nl.d $f8,Three\ns.d $f8,-16+240($sp)\nmul.d $f6,$f16,$f18\nmul.d $f6,$f6,$f8\nmul.d $f6,$f6,$f16\nc.eq.d $f10,$f6; bc1f L.39\nl.d $f6,Zero\ndiv.d $f4,$f10,$f8\nmul.d $f8,$f16,$f16\nmul.d $f8,$f8,$f18\nsub.d $f8,$f4,$f8\nc.eq.d $f8,$f6; bc1f L.39\ndiv.d $f8,$f10,$f16\nl.d $f4,-16+240($sp)\nmul.d $f4,$f18,$f4\nmul.d $f4,$f4,$f16\nsub.d $f8,$f8,$f4\nc.eq.d $f8,$f6; bc1f L.39\ndiv.d $f18,$f10,$f18\nl.d $f10,-16+240($sp)\nmul.d $f10,$f16,$f10\nmul.d $f16,$f10,$f16\nsub.d $f18,$f18,$f16\nc.eq.d $f18,$f6; bc1f L.39\nla $19,1\nb L.40\nL.39:\nmove $19,$0\nL.40:\nmove $5,$19\nla $6,L.38\njal TstCond\nlw $24,ErrCnt\nbne $24,$0,L.41\nla $4,L.43\njal printf\nla $4,L.44\njal printf\nL.41:\nla $4,L.45\njal printf\nl.d $f18,One\ns.d $f18,W\nL.46:\nl.d $f18,W\nadd.d $f18,$f18,$f18\ns.d $f18,W\nl.d $f18,W\nl.d $f16,One\nadd.d $f10,$f18,$f16\ns.d $f10,Y\nl.d $f10,Y\nsub.d $f18,$f10,$f18\ns.d $f18,Z\nl.d $f18,Z\nsub.d $f18,$f18,$f16\ns.d $f18,Y\nL.47:\nl.d $f12,Y\njal fabs\nl.d $f16,MinusOne\nadd.d $f18,$f16,$f0\nl.d $f16,Zero\nc.lt.d $f18,$f16; bc1t L.46\nl.d $f18,Zero\ns.d $f18,Precision\nl.d $f18,One\ns.d $f18,Y\nL.49:\nl.d $f18,W\nl.d $f16,Y\nadd.d $f10,$f18,$f16\ns.d $f10,Radix\nadd.d $f16,$f16,$f16\ns.d $f16,Y\nl.d $f16,Radix\nsub.d $f18,$f16,$f18\ns.d $f18,Radix\nL.50:\nl.d $f18,Radix\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1t L.49\nl.d $f18,Radix\nl.d $f16,Two\nc.lt.d $f18,$f16; bc1f L.52\nl.d $f18,One\ns.d $f18,Radix\nL.52:\nla $4,L.54\nl.d $f18,Radix\nmfc1.d $6,$f18\njal printf\nl.d $f18,Radix\nl.d $f16,L.8\nc.eq.d $f18,$f16; bc1t L.55\nl.d $f18,One\ns.d $f18,W\nL.57:\nl.d $f18,One\nl.d $f16,Precision\nadd.d $f16,$f16,$f18\ns.d $f16,Precision\nl.d $f16,W\nl.d $f10,Radix\nmul.d $f16,$f16,$f10\ns.d $f16,W\nl.d $f16,W\nadd.d $f18,$f16,$f18\ns.d $f18,Y\nL.58:\nl.d $f18,Y\nl.d $f16,W\nsub.d $f18,$f18,$f16\nl.d $f16,One\nc.eq.d $f18,$f16; bc1t L.57\nL.55:\nl.d $f18,One\nl.d $f16,W\ndiv.d $f18,$f18,$f16\ns.d $f18,U1\nl.d $f18,U1\nl.d $f16,Radix\nmul.d $f16,$f16,$f18\ns.d $f16,U2\nla $4,L.60\nmfc1.d $6,$f18\njal printf\nla $4,L.61\njal printf\nl.d $f18,Radix\ns.d $f18,E0\nl.d $f18,U1\ns.d $f18,E1\nl.d $f18,U2\ns.d $f18,E9\nl.d $f18,Precision\ns.d $f18,E3\nl.d $f18,Four\nl.d $f16,Three\ndiv.d $f18,$f18,$f16\ns.d $f18,X\nl.d $f18,X\nl.d $f16,One\nsub.d $f18,$f18,$f16\ns.d $f18,Third\nl.d $f18,Third\nl.d $f16,Half\nsub.d $f16,$f16,$f18\ns.d $f16,F6\nl.d $f16,F6\nadd.d $f16,$f16,$f16\ns.d $f16,X\nl.d $f16,X\nsub.d $f12,$f16,$f18\njal fabs\ns.d $f0,X\nl.d $f18,X\nl.d $f16,U2\nc.lt.d $f18,$f16; bc1f L.62\nl.d $f18,U2\ns.d $f18,X\nL.62:\nL.64:\nl.d $f18,X\ns.d $f18,U2\nl.d $f18,U2\nl.d $f16,Half\nmul.d $f16,$f16,$f18\nl.d $f10,ThirtyTwo\nmul.d $f10,$f10,$f18\nmul.d $f18,$f10,$f18\nadd.d $f18,$f16,$f18\ns.d $f18,Y\nl.d $f18,One\nl.d $f16,Y\nadd.d $f16,$f18,$f16\ns.d $f16,Y\nl.d $f16,Y\nsub.d $f18,$f16,$f18\ns.d $f18,X\nL.65:\nl.d $f18,X\nl.d $f16,U2\nc.le.d $f16,$f18; bc1t L.67\nl.d $f16,Zero\nc.le.d $f18,$f16; bc1f L.64\nL.67:\nl.d $f18,Two\nl.d $f16,Three\ndiv.d $f18,$f18,$f16\ns.d $f18,X\nl.d $f18,Half\nl.d $f16,X\nsub.d $f16,$f16,$f18\ns.d $f16,F6\nl.d $f16,F6\nadd.d $f10,$f16,$f16\ns.d $f10,Third\nl.d $f10,Third\nsub.d $f18,$f10,$f18\ns.d $f18,X\nl.d $f18,X\nadd.d $f12,$f18,$f16\njal fabs\ns.d $f0,X\nl.d $f18,X\nl.d $f16,U1\nc.lt.d $f18,$f16; bc1f L.68\nl.d $f18,U1\ns.d $f18,X\nL.68:\nL.70:\nl.d $f18,X\ns.d $f18,U1\nl.d $f18,Half\nl.d $f16,U1\nmul.d $f10,$f18,$f16\nl.d $f8,ThirtyTwo\nmul.d $f8,$f8,$f16\nmul.d $f16,$f8,$f16\nadd.d $f16,$f10,$f16\ns.d $f16,Y\nl.d $f16,Y\nsub.d $f16,$f18,$f16\ns.d $f16,Y\nl.d $f16,Y\nadd.d $f16,$f18,$f16\ns.d $f16,X\nl.d $f16,X\nsub.d $f16,$f18,$f16\ns.d $f16,Y\nl.d $f16,Y\nadd.d $f18,$f18,$f16\ns.d $f18,X\nL.71:\nl.d $f18,X\nl.d $f16,U1\nc.le.d $f16,$f18; bc1t L.73\nl.d $f16,Zero\nc.le.d $f18,$f16; bc1f L.70\nL.73:\nl.d $f18,U1\nl.d $f16,E1\nc.eq.d $f18,$f16; bc1f L.74\nla $4,L.76\njal printf\nb L.75\nL.74:\nla $4,L.77\nl.d $f18,U1\nmfc1.d $6,$f18\njal printf\nL.75:\nl.d $f18,U1\nl.d $f16,One\ndiv.d $f16,$f16,$f18\ns.d $f16,W\nl.d $f16,Half\nsub.d $f10,$f16,$f18\nadd.d $f16,$f10,$f16\ns.d $f16,F9\nl.d $f16,U2\ndiv.d $f18,$f16,$f18\nl.d $f16,L.78\nadd.d $f12,$f18,$f16\njal floor\ns.d $f0,Radix\nl.d $f18,Radix\nl.d $f16,E0\nc.eq.d $f18,$f16; bc1f L.79\nla $4,L.81\njal printf\nb L.80\nL.79:\nla $4,L.82\nl.d $f18,Radix\nmfc1.d $6,$f18\njal printf\nL.80:\nla $4,2\nl.d $f18,Eight\nl.d $f16,Radix\nadd.d $f18,$f18,$f18\nc.le.d $f16,$f18; bc1f L.85\nla $18,1\nb L.86\nL.85:\nmove $18,$0\nL.86:\nmove $5,$18\nla $6,L.84\njal TstCond\nla $4,3\nl.d $f18,Radix\nl.d $f16,Two\nc.eq.d $f18,$f16; bc1t L.92\nl.d $f16,L.93\nc.eq.d $f18,$f16; bc1t L.92\nl.d $f16,One\nc.eq.d $f18,$f16; bc1f L.89\nL.92:\nla $17,1\nb L.90\nL.89:\nmove $17,$0\nL.90:\nmove $5,$17\nla $6,L.88\njal TstCond\nla $24,20\nsw $24,Milestone\nmove $4,$0\nl.d $f18,Half\nl.d $f16,F9\nsub.d $f16,$f16,$f18\nc.lt.d $f16,$f18; bc1f L.96\nla $16,1\nb L.97\nL.96:\nmove $16,$0\nL.97:\nmove $5,$16\nla $6,L.95\njal TstCond\nl.d $f18,F9\ns.d $f18,X\nla $24,1\nsw $24,I\nl.d $f18,Half\nl.d $f16,X\nsub.d $f16,$f16,$f18\ns.d $f16,Y\nl.d $f16,Y\nsub.d $f18,$f16,$f18\ns.d $f18,Z\nmove $4,$0\nl.d $f18,X\nl.d $f16,One\nc.eq.d $f18,$f16; bc1f L.102\nl.d $f18,Z\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1f L.100\nL.102:\nla $24,1\nsw $24,-20+240($sp)\nb L.101\nL.100:\nsw $0,-20+240($sp)\nL.101:\nlw $5,-20+240($sp)\nla $6,L.99\njal TstCond\nl.d $f18,One\nl.d $f16,U2\nadd.d $f10,$f18,$f16\ns.d $f10,X\nsw $0,I\nla $24,25\nsw $24,Milestone\nl.d $f10,Radix\nsub.d $f8,$f10,$f18\ns.d $f8,BMinusU2\nl.d $f8,BMinusU2\nsub.d $f16,$f8,$f16\nadd.d $f16,$f16,$f18\ns.d $f16,BMinusU2\nc.eq.d $f10,$f18; bc1t L.103\nl.d $f12,U1\njal log\nmov.d $f18,$f0\ns.d $f18,-32+240($sp)\nl.d $f12,Radix\njal log\nl.d $f16,TwoForty\nneg.d $f16,$f16\nl.d $f10,-32+240($sp)\nmul.d $f16,$f16,$f10\ndiv.d $f18,$f16,$f0\ns.d $f18,X\nl.d $f18,Half\nl.d $f16,X\nadd.d $f12,$f18,$f16\njal floor\ns.d $f0,Y\nl.d $f18,X\nl.d $f16,Y\nsub.d $f12,$f18,$f16\njal fabs\nl.d $f16,Four\nmul.d $f18,$f0,$f16\nl.d $f16,One\nc.lt.d $f18,$f16; bc1f L.105\nl.d $f18,Y\ns.d $f18,X\nL.105:\nl.d $f18,X\nl.d $f16,TwoForty\ndiv.d $f18,$f18,$f16\ns.d $f18,Precision\nl.d $f18,Half\nl.d $f16,Precision\nadd.d $f12,$f18,$f16\njal floor\ns.d $f0,Y\nl.d $f18,Precision\nl.d $f16,Y\nsub.d $f12,$f18,$f16\njal fabs\nl.d $f16,TwoForty\nmul.d $f18,$f0,$f16\nl.d $f16,Half\nc.lt.d $f18,$f16; bc1f L.107\nl.d $f18,Y\ns.d $f18,Precision\nL.107:\nL.103:\nl.d $f18,Precision\ns.d $f18,-32+240($sp)\nmov.d $f12,$f18\njal floor\nl.d $f16,-32+240($sp)\nc.eq.d $f16,$f0; bc1f L.111\nl.d $f18,Radix\nl.d $f16,One\nc.eq.d $f18,$f16; bc1f L.109\nL.111:\nla $4,L.112\njal printf\nla $4,L.113\njal printf\nL.109:\nl.d $f18,Radix\nl.d $f16,One\nc.eq.d $f18,$f16; bc1f L.114\nla $4,L.116\njal printf\nb L.115\nL.114:\nla $4,L.117\nl.d $f18,Precision\nmfc1.d $6,$f18\njal printf\nL.115:\nla $4,1\nl.d $f18,Nine\nl.d $f16,U2\nmul.d $f16,$f16,$f18\nmul.d $f18,$f16,$f18\nl.d $f16,TwoForty\nmul.d $f18,$f18,$f16\nl.d $f16,One\nc.lt.d $f18,$f16; bc1f L.120\nla $24,1\nsw $24,-36+240($sp)\nb L.121\nL.120:\nsw $0,-36+240($sp)\nL.121:\nlw $5,-36+240($sp)\nla $6,L.119\njal TstCond\nla $24,30\nsw $24,Milestone\nl.d $f18,Four\nl.d $f16,Three\nl.d $f10,One\ndiv.d $f8,$f10,$f18\ndiv.d $f18,$f18,$f16\nsub.d $f18,$f18,$f10\nsub.d $f18,$f18,$f8\nmul.d $f18,$f18,$f16\nsub.d $f12,$f18,$f8\njal fabs\ns.d $f0,X\nL.122:\nl.d $f18,X\ns.d $f18,Z2\nl.d $f18,One\nl.d $f16,Z2\nl.d $f10,Half\nmul.d $f10,$f10,$f16\nl.d $f8,ThirtyTwo\nmul.d $f8,$f8,$f16\nmul.d $f16,$f8,$f16\nadd.d $f16,$f10,$f16\nadd.d $f16,$f18,$f16\nsub.d $f18,$f16,$f18\ns.d $f18,X\nL.123:\nl.d $f18,X\nl.d $f16,Z2\nc.le.d $f16,$f18; bc1t L.125\nl.d $f16,Zero\nc.le.d $f18,$f16; bc1f L.122\nL.125:\nl.d $f18,Three\nl.d $f16,Four\ndiv.d $f10,$f18,$f16\nl.d $f8,Two\ndiv.d $f8,$f8,$f18\nsub.d $f10,$f10,$f8\nmul.d $f18,$f10,$f18\nl.d $f10,One\ndiv.d $f16,$f10,$f16\nsub.d $f12,$f18,$f16\njal fabs\ns.d $f0,Z\ns.d $f0,Y\ns.d $f0,X\nL.126:\nl.d $f18,Z\ns.d $f18,Z1\nl.d $f18,One\nl.d $f16,Two\ndiv.d $f18,$f18,$f16\nl.d $f16,Z1\nl.d $f10,Half\nmul.d $f10,$f10,$f16\nl.d $f8,ThirtyTwo\nmul.d $f8,$f8,$f16\nmul.d $f16,$f8,$f16\nadd.d $f16,$f10,$f16\nsub.d $f16,$f18,$f16\nadd.d $f16,$f16,$f18\nsub.d $f16,$f18,$f16\nadd.d $f18,$f16,$f18\ns.d $f18,Z\nL.127:\nl.d $f18,Z\nl.d $f16,Z1\nc.le.d $f16,$f18; bc1t L.129\nl.d $f16,Zero\nc.le.d $f18,$f16; bc1f L.126\nL.129:\nL.130:\nL.133:\nl.d $f18,Y\ns.d $f18,Y1\nl.d $f18,Half\nl.d $f16,Y1\nmul.d $f10,$f18,$f16\nl.d $f8,ThirtyTwo\nmul.d $f8,$f8,$f16\nmul.d $f16,$f8,$f16\nadd.d $f16,$f10,$f16\nsub.d $f16,$f18,$f16\nadd.d $f16,$f16,$f18\nsub.d $f16,$f18,$f16\nadd.d $f18,$f16,$f18\ns.d $f18,Y\nL.134:\nl.d $f18,Y\nl.d $f16,Y1\nc.le.d $f16,$f18; bc1t L.136\nl.d $f16,Zero\nc.le.d $f18,$f16; bc1f L.133\nL.136:\nl.d $f18,X\ns.d $f18,X1\nl.d $f18,X1\nl.d $f16,F9\nl.d $f10,Half\nmul.d $f10,$f10,$f18\nl.d $f8,ThirtyTwo\nmul.d $f8,$f8,$f18\nmul.d $f18,$f8,$f18\nadd.d $f18,$f10,$f18\nsub.d $f18,$f18,$f16\nadd.d $f18,$f18,$f16\ns.d $f18,X\nL.131:\nl.d $f18,X\nl.d $f16,X1\nc.le.d $f16,$f18; bc1t L.137\nl.d $f16,Zero\nc.le.d $f18,$f16; bc1f L.130\nL.137:\nl.d $f18,X1\nl.d $f16,Y1\nc.eq.d $f18,$f16; bc1f L.140\nl.d $f16,Z1\nc.eq.d $f18,$f16; bc1t L.138\nL.140:\nla $4,1\nla $5,L.141\njal BadCond\nla $4,L.142\nl.d $f18,X1\nmfc1.d $6,$f18\nl.d $f18,Y1\ns.d $f18,16($sp)\nl.d $f18,Z1\ns.d $f18,24($sp)\njal printf\nla $4,L.143\njal printf\nla $4,L.144\njal printf\nla $4,L.145\njal notify\nl.d $f18,U1\nl.d $f16,X1\nc.eq.d $f16,$f18; bc1t L.149\nl.d $f16,Y1\nc.eq.d $f16,$f18; bc1t L.149\nl.d $f16,Z1\nc.eq.d $f16,$f18; bc1f L.139\nL.149:\nla $4,L.150\njal printf\nb L.139\nL.138:\nl.d $f18,Z1\nl.d $f16,U1\nc.eq.d $f18,$f16; bc1f L.153\nl.d $f18,Z2\nl.d $f16,U2\nc.eq.d $f18,$f16; bc1t L.151\nL.153:\nl.d $f18,Z1\nl.d $f16,U1\nc.lt.d $f18,$f16; bc1f L.156\nl.d $f18,Z2\nl.d $f16,U2\nc.lt.d $f18,$f16; bc1t L.154\nL.156:\nmove $4,$0\nla $5,L.157\njal BadCond\nla $4,L.158\njal notify\nla $4,L.159\nl.d $f18,U1\nmfc1.d $6,$f18\nl.d $f16,Z1\nsub.d $f18,$f16,$f18\ns.d $f18,16($sp)\njal printf\nla $4,L.160\nl.d $f18,U2\nmfc1.d $6,$f18\nl.d $f16,Z2\nsub.d $f18,$f16,$f18\ns.d $f18,16($sp)\njal printf\nb L.155\nL.154:\nl.d $f18,Zero\nl.d $f16,Z1\nc.le.d $f16,$f18; bc1t L.163\nl.d $f16,Z2\nc.le.d $f16,$f18; bc1f L.161\nL.163:\nla $4,L.164\nl.d $f18,Radix\nmfc1.d $6,$f18\njal printf\nla $4,L.165\njal printf\nla $4,L.166\nl.d $f18,Z1\nmfc1.d $6,$f18\nl.d $f18,Z2\ns.d $f18,16($sp)\njal printf\nla $4,L.167\njal notify\nL.161:\nl.d $f18,Z1\nl.d $f16,Z2\nc.eq.d $f18,$f16; bc1f L.170\nl.d $f16,Zero\nc.le.d $f18,$f16; bc1t L.168\nL.170:\nl.d $f18,Z1\nl.d $f16,U1\ndiv.d $f18,$f18,$f16\ns.d $f18,X\nl.d $f18,Z2\nl.d $f16,U2\ndiv.d $f18,$f18,$f16\ns.d $f18,Y\nl.d $f18,Y\nl.d $f16,X\nc.le.d $f18,$f16; bc1t L.171\nl.d $f18,Y\ns.d $f18,X\nL.171:\nl.d $f12,X\njal log\nneg.d $f18,$f0\ns.d $f18,Q\nla $4,L.173\njal printf\nl.d $f12,Radix\njal log\nla $4,L.174\nl.d $f16,Q\ndiv.d $f18,$f16,$f0\nmfc1.d $6,$f18\njal printf\nl.d $f12,L.93\njal log\nla $4,L.175\nl.d $f16,Q\ndiv.d $f18,$f16,$f0\nmfc1.d $6,$f18\njal printf\nL.168:\nla $4,L.150\njal printf\nL.155:\nL.151:\nL.139:\njal Pause\nla $24,35\nsw $24,Milestone\nl.d $f18,Radix\nl.d $f16,Two\nc.lt.d $f18,$f16; bc1t L.176\nl.d $f18,Radix\nl.d $f16,W\nmul.d $f18,$f18,$f18\ndiv.d $f18,$f16,$f18\ns.d $f18,X\nl.d $f18,X\nl.d $f16,One\nadd.d $f16,$f18,$f16\ns.d $f16,Y\nl.d $f16,Y\nsub.d $f18,$f16,$f18\ns.d $f18,Z\nl.d $f18,Z\nl.d $f16,U2\nadd.d $f10,$f18,$f16\ns.d $f10,T\nl.d $f10,T\nsub.d $f18,$f10,$f18\ns.d $f18,X\nmove $4,$0\nl.d $f18,X\nc.eq.d $f18,$f16; bc1f L.180\nla $24,1\nsw $24,-40+240($sp)\nb L.181\nL.180:\nsw $0,-40+240($sp)\nL.181:\nlw $5,-40+240($sp)\nla $6,L.179\njal TstCond\nl.d $f18,X\nl.d $f16,U2\nc.eq.d $f18,$f16; bc1f L.182\nla $4,L.184\njal printf\nL.182:\nL.176:\nla $4,L.185\njal printf\nl.d $f18,F9\nl.d $f16,One\nmul.d $f10,$f18,$f16\ns.d $f10,Y\nmul.d $f10,$f16,$f18\ns.d $f10,Z\nl.d $f10,Half\nsub.d $f18,$f18,$f10\ns.d $f18,X\nl.d $f18,X\nl.d $f8,Y\nsub.d $f8,$f8,$f10\nsub.d $f8,$f8,$f18\ns.d $f8,Y\nl.d $f8,Z\nsub.d $f10,$f8,$f10\nsub.d $f18,$f10,$f18\ns.d $f18,Z\nl.d $f18,U2\nadd.d $f10,$f16,$f18\ns.d $f10,X\nl.d $f10,X\nl.d $f8,Radix\nmul.d $f6,$f10,$f8\ns.d $f6,T\nmul.d $f10,$f8,$f10\ns.d $f10,R\nl.d $f10,T\nsub.d $f10,$f10,$f8\ns.d $f10,X\nmul.d $f18,$f8,$f18\nl.d $f10,X\nsub.d $f10,$f10,$f18\ns.d $f10,X\nl.d $f10,R\nsub.d $f10,$f10,$f8\ns.d $f10,T\nl.d $f10,T\nsub.d $f18,$f10,$f18\ns.d $f18,T\nsub.d $f18,$f8,$f16\nl.d $f16,X\nmul.d $f16,$f16,$f18\ns.d $f16,X\nl.d $f16,T\nmul.d $f18,$f16,$f18\ns.d $f18,T\nl.d $f18,Zero\nl.d $f16,X\nc.eq.d $f16,$f18; bc1f L.186\nl.d $f16,Y\nc.eq.d $f16,$f18; bc1f L.186\nl.d $f16,Z\nc.eq.d $f16,$f18; bc1f L.186\nl.d $f16,T\nc.eq.d $f16,$f18; bc1f L.186\nla $24,1\nsw $24,GMult\nb L.187\nL.186:\nmove $24,$0\nsw $24,GMult\nla $4,1\nmove $5,$24\nla $6,L.188\njal TstCond\nL.187:\nl.d $f18,Radix\nl.d $f16,U2\nmul.d $f18,$f18,$f16\ns.d $f18,Z\nl.d $f18,Z\nl.d $f16,One\nadd.d $f16,$f16,$f18\ns.d $f16,X\nl.d $f16,X\nadd.d $f18,$f16,$f18\nmul.d $f16,$f16,$f16\nsub.d $f12,$f18,$f16\njal fabs\nl.d $f16,U2\nsub.d $f18,$f0,$f16\ns.d $f18,Y\nl.d $f18,One\nsub.d $f18,$f18,$f16\ns.d $f18,X\nl.d $f18,X\nsub.d $f16,$f18,$f16\nmul.d $f18,$f18,$f18\nsub.d $f12,$f16,$f18\njal fabs\nl.d $f16,U1\nsub.d $f18,$f0,$f16\ns.d $f18,Z\nmove $4,$0\nl.d $f18,Zero\nl.d $f16,Y\nc.le.d $f16,$f18; bc1f L.191\nl.d $f16,Z\nc.le.d $f16,$f18; bc1f L.191\nla $24,1\nsw $24,-40+240($sp)\nb L.192\nL.191:\nsw $0,-40+240($sp)\nL.192:\nlw $5,-40+240($sp)\nla $6,L.190\njal TstCond\nl.d $f18,One\nl.d $f16,U2\nsub.d $f10,$f18,$f16\ns.d $f10,Y\nadd.d $f16,$f18,$f16\ns.d $f16,X\nl.d $f16,Y\ndiv.d $f16,$f18,$f16\ns.d $f16,Z\nl.d $f16,Z\nl.d $f10,X\nsub.d $f16,$f16,$f10\ns.d $f16,Y\nl.d $f16,Three\ndiv.d $f18,$f18,$f16\ns.d $f18,X\nl.d $f18,Nine\ndiv.d $f16,$f16,$f18\ns.d $f16,Z\nl.d $f16,Z\nl.d $f10,X\nsub.d $f10,$f10,$f16\ns.d $f10,X\nl.d $f10,TwentySeven\ndiv.d $f18,$f18,$f10\ns.d $f18,T\nl.d $f18,T\nsub.d $f18,$f16,$f18\ns.d $f18,Z\nla $4,2\nl.d $f18,Zero\nl.d $f16,X\nc.eq.d $f16,$f18; bc1f L.195\nl.d $f16,Y\nc.eq.d $f16,$f18; bc1f L.195\nl.d $f16,Z\nc.eq.d $f16,$f18; bc1f L.195\nla $24,1\nsw $24,-44+240($sp)\nb L.196\nL.195:\nsw $0,-44+240($sp)\nL.196:\nlw $5,-44+240($sp)\nla $6,L.194\njal TstCond\nl.d $f18,F9\nl.d $f16,One\ndiv.d $f10,$f18,$f16\ns.d $f10,Y\nl.d $f10,Half\nsub.d $f18,$f18,$f10\ns.d $f18,X\nl.d $f18,Y\nsub.d $f18,$f18,$f10\nl.d $f10,X\nsub.d $f18,$f18,$f10\ns.d $f18,Y\nl.d $f18,U2\nadd.d $f18,$f16,$f18\ns.d $f18,X\nl.d $f18,X\ndiv.d $f16,$f18,$f16\ns.d $f16,T\nl.d $f16,T\nsub.d $f18,$f16,$f18\ns.d $f18,X\nl.d $f18,Zero\nl.d $f16,X\nc.eq.d $f16,$f18; bc1f L.197\nl.d $f16,Y\nc.eq.d $f16,$f18; bc1f L.197\nl.d $f16,Z\nc.eq.d $f16,$f18; bc1f L.197\nla $24,1\nsw $24,GDiv\nb L.198\nL.197:\nmove $24,$0\nsw $24,GDiv\nla $4,1\nmove $5,$24\nla $6,L.199\njal TstCond\nL.198:\nl.d $f18,One\nl.d $f16,U2\nadd.d $f16,$f18,$f16\ndiv.d $f18,$f18,$f16\ns.d $f18,X\nl.d $f18,Half\nl.d $f16,X\nsub.d $f16,$f16,$f18\nsub.d $f18,$f16,$f18\ns.d $f18,Y\nla $4,1\nl.d $f18,Y\nl.d $f16,Zero\nc.lt.d $f18,$f16; bc1f L.202\nla $24,1\nsw $24,-48+240($sp)\nb L.203\nL.202:\nsw $0,-48+240($sp)\nL.203:\nlw $5,-48+240($sp)\nla $6,L.201\njal TstCond\nl.d $f18,One\nl.d $f16,U2\nsub.d $f10,$f18,$f16\ns.d $f10,X\nl.d $f10,Radix\nmul.d $f16,$f10,$f16\nadd.d $f18,$f18,$f16\ns.d $f18,Y\nl.d $f18,X\nmul.d $f16,$f18,$f10\ns.d $f16,Z\nl.d $f16,Y\nmul.d $f8,$f16,$f10\ns.d $f8,T\nl.d $f8,Z\ndiv.d $f8,$f8,$f10\ns.d $f8,R\nl.d $f8,T\ndiv.d $f10,$f8,$f10\ns.d $f10,StickyBit\nl.d $f10,R\nsub.d $f18,$f10,$f18\ns.d $f18,X\nl.d $f18,StickyBit\nsub.d $f18,$f18,$f16\ns.d $f18,Y\nmove $4,$0\nl.d $f18,Zero\nl.d $f16,X\nc.eq.d $f16,$f18; bc1f L.206\nl.d $f16,Y\nc.eq.d $f16,$f18; bc1f L.206\nla $24,1\nsw $24,-52+240($sp)\nb L.207\nL.206:\nsw $0,-52+240($sp)\nL.207:\nlw $5,-52+240($sp)\nla $6,L.205\njal TstCond\nl.d $f18,One\nl.d $f16,U1\nsub.d $f16,$f18,$f16\ns.d $f16,Y\nl.d $f16,F9\nsub.d $f16,$f18,$f16\ns.d $f16,X\nl.d $f16,Y\nsub.d $f18,$f18,$f16\ns.d $f18,Y\nl.d $f18,Radix\nl.d $f16,U2\nsub.d $f16,$f18,$f16\ns.d $f16,T\nl.d $f16,BMinusU2\nsub.d $f16,$f18,$f16\ns.d $f16,Z\nl.d $f16,T\nsub.d $f18,$f18,$f16\ns.d $f18,T\nl.d $f18,U1\nl.d $f16,X\nc.eq.d $f16,$f18; bc1f L.208\nl.d $f16,Y\nc.eq.d $f16,$f18; bc1f L.208\nl.d $f18,U2\nl.d $f16,Z\nc.eq.d $f16,$f18; bc1f L.208\nl.d $f16,T\nc.eq.d $f16,$f18; bc1f L.208\nla $24,1\nsw $24,GAddSub\nb L.209\nL.208:\nmove $24,$0\nsw $24,GAddSub\nla $4,1\nmove $5,$24\nla $6,L.210\njal TstCond\nL.209:\nl.d $f18,F9\nl.d $f16,One\nc.eq.d $f18,$f16; bc1t L.211\nsub.d $f18,$f18,$f16\nl.d $f16,Zero\nc.lt.d $f18,$f16; bc1t L.211\nla $4,1\nla $5,L.213\njal BadCond\nla $4,L.214\njal printf\nla $4,L.215\njal printf\nla $4,L.216\njal printf\nL.211:\nla $24,1\nlw $15,GMult\nbne $15,$24,L.217\nlw $15,GDiv\nbne $15,$24,L.217\nlw $15,GAddSub\nbne $15,$24,L.217\nla $4,L.219\njal printf\nL.217:\nla $24,40\nsw $24,Milestone\njal Pause\nla $4,L.220\njal printf\nsw $0,RMult\nsw $0,RDiv\nsw $0,RAddSub\nl.d $f18,Two\nl.d $f16,Radix\ndiv.d $f16,$f16,$f18\ns.d $f16,RadixD2\ns.d $f18,A1\nsw $0,Done\nL.221:\nl.d $f18,Radix\ns.d $f18,AInvrse\nL.224:\nl.d $f18,AInvrse\ns.d $f18,X\nl.d $f16,A1\ndiv.d $f18,$f18,$f16\ns.d $f18,AInvrse\nL.225:\nl.d $f12,AInvrse\njal floor\nl.d $f16,AInvrse\nc.eq.d $f0,$f16; bc1t L.224\nl.d $f18,X\nl.d $f16,One\nc.eq.d $f18,$f16; bc1t L.230\nl.d $f18,A1\nl.d $f16,Three\nc.le.d $f18,$f16; bc1t L.228\nL.230:\nla $24,1\nsw $24,-56+240($sp)\nb L.229\nL.228:\nsw $0,-56+240($sp)\nL.229:\nlw $24,-56+240($sp)\nsw $24,Done\nlw $24,Done\nbne $24,$0,L.231\nl.d $f18,Nine\nl.d $f16,One\nadd.d $f18,$f18,$f16\ns.d $f18,A1\nL.231:\nL.222:\nlw $24,Done\nbeq $24,$0,L.221\nl.d $f18,X\nl.d $f16,One\nc.eq.d $f18,$f16; bc1f L.233\nl.d $f18,Radix\ns.d $f18,A1\nL.233:\nl.d $f18,A1\nl.d $f16,One\ndiv.d $f16,$f16,$f18\ns.d $f16,AInvrse\ns.d $f18,X\nl.d $f18,AInvrse\ns.d $f18,Y\nsw $0,Done\nL.235:\nl.d $f18,Half\nl.d $f16,X\nl.d $f10,Y\nmul.d $f16,$f16,$f10\nsub.d $f16,$f16,$f18\ns.d $f16,Z\nmove $4,$0\nl.d $f16,Z\nc.eq.d $f16,$f18; bc1f L.240\nla $24,1\nsw $24,-56+240($sp)\nb L.241\nL.240:\nsw $0,-56+240($sp)\nL.241:\nlw $5,-56+240($sp)\nla $6,L.239\njal TstCond\nl.d $f18,X\nl.d $f16,Radix\nc.eq.d $f18,$f16; bc1f L.243\nla $24,1\nsw $24,-60+240($sp)\nb L.244\nL.243:\nsw $0,-60+240($sp)\nL.244:\nlw $24,-60+240($sp)\nsw $24,Done\nl.d $f18,Radix\ns.d $f18,X\nl.d $f18,One\nl.d $f16,X\ndiv.d $f18,$f18,$f16\ns.d $f18,Y\nL.236:\nlw $24,Done\nbeq $24,$0,L.235\nl.d $f18,One\nl.d $f16,U2\nadd.d $f10,$f18,$f16\ns.d $f10,Y2\nsub.d $f18,$f18,$f16\ns.d $f18,Y1\nl.d $f18,OneAndHalf\ns.d $f18,-64+240($sp)\nsub.d $f10,$f18,$f16\ns.d $f10,X\nadd.d $f10,$f18,$f16\ns.d $f10,Y\nl.d $f10,X\nl.d $f8,Y2\nsub.d $f6,$f10,$f16\nmul.d $f6,$f6,$f8\ns.d $f6,Z\nl.d $f6,Y\nl.d $f4,Y1\nmul.d $f18,$f6,$f4\ns.d $f18,T\nl.d $f18,Z\nsub.d $f18,$f18,$f10\ns.d $f18,Z\nl.d $f18,T\nsub.d $f18,$f18,$f10\ns.d $f18,T\nmul.d $f18,$f10,$f8\ns.d $f18,X\nadd.d $f18,$f6,$f16\nmul.d $f18,$f18,$f4\ns.d $f18,Y\nl.d $f18,X\nl.d $f16,-64+240($sp)\nsub.d $f18,$f18,$f16\ns.d $f18,X\nl.d $f18,Y\nl.d $f16,-64+240($sp)\nsub.d $f18,$f18,$f16\ns.d $f18,Y\nl.d $f18,Zero\nl.d $f16,X\nc.eq.d $f16,$f18; bc1f L.245\nl.d $f16,Y\nc.eq.d $f16,$f18; bc1f L.245\nl.d $f16,Z\nc.eq.d $f16,$f18; bc1f L.245\nl.d $f16,T\nc.le.d $f16,$f18; bc1f L.245\nl.d $f18,OneAndHalf\nl.d $f16,U2\nadd.d $f10,$f18,$f16\nl.d $f8,Y2\nmul.d $f6,$f10,$f8\ns.d $f6,X\nsub.d $f18,$f18,$f16\nsub.d $f6,$f18,$f16\ns.d $f6,Y\nadd.d $f10,$f10,$f16\ns.d $f10,Z\nl.d $f10,Y1\nmul.d $f18,$f18,$f10\ns.d $f18,T\nl.d $f18,Z\nadd.d $f6,$f18,$f16\ns.d $f6,-72+240($sp)\nl.d $f4,X\nsub.d $f4,$f4,$f6\ns.d $f4,X\nl.d $f4,Y\nmul.d $f6,$f4,$f10\ns.d $f6,StickyBit\nmul.d $f18,$f18,$f8\ns.d $f18,S\nl.d $f18,T\nsub.d $f18,$f18,$f4\ns.d $f18,T\nsub.d $f18,$f16,$f4\nl.d $f6,StickyBit\nadd.d $f18,$f18,$f6\ns.d $f18,Y\nl.d $f18,S\nl.d $f6,-72+240($sp)\nadd.d $f6,$f6,$f16\nsub.d $f18,$f18,$f6\ns.d $f18,Z\nadd.d $f18,$f8,$f16\nmul.d $f18,$f18,$f10\ns.d $f18,StickyBit\nmul.d $f18,$f8,$f10\ns.d $f18,Y1\nl.d $f18,StickyBit\nsub.d $f18,$f18,$f8\ns.d $f18,StickyBit\nl.d $f18,Y1\nl.d $f16,Half\nsub.d $f18,$f18,$f16\ns.d $f18,Y1\nl.d $f18,Zero\nl.d $f16,X\nc.eq.d $f16,$f18; bc1f L.247\nl.d $f16,Y\nc.eq.d $f16,$f18; bc1f L.247\nl.d $f16,Z\nc.eq.d $f16,$f18; bc1f L.247\nl.d $f16,T\nc.eq.d $f16,$f18; bc1f L.247\nl.d $f16,StickyBit\nc.eq.d $f16,$f18; bc1f L.247\nl.d $f18,Y1\nl.d $f16,Half\nc.eq.d $f18,$f16; bc1f L.247\nla $24,1\nsw $24,RMult\nla $4,L.249\njal printf\nb L.248\nL.247:\nl.d $f18,U2\nl.d $f16,Zero\nl.d $f10,X\nadd.d $f10,$f10,$f18\nc.eq.d $f10,$f16; bc1f L.250\nl.d $f10,Y\nc.lt.d $f10,$f16; bc1f L.250\nl.d $f10,Z\nadd.d $f10,$f10,$f18\nc.eq.d $f10,$f16; bc1f L.250\nl.d $f10,T\nc.lt.d $f10,$f16; bc1f L.250\nl.d $f10,StickyBit\nadd.d $f18,$f10,$f18\nc.eq.d $f18,$f16; bc1f L.250\nl.d $f18,Y1\nl.d $f16,Half\nc.lt.d $f18,$f16; bc1f L.250\nla $24,2\nsw $24,RMult\nla $4,L.252\njal printf\nb L.251\nL.250:\nla $4,L.253\njal printf\nL.251:\nL.248:\nlw $24,RMult\nla $15,1\nbne $24,$15,L.246\nlw $24,GMult\nbne $24,$0,L.246\nla $4,L.256\njal notify\nb L.246\nL.245:\nla $4,L.253\njal printf\nL.246:\nla $24,45\nsw $24,Milestone\nl.d $f18,One\nl.d $f16,U2\nadd.d $f10,$f18,$f16\ns.d $f10,Y2\nsub.d $f18,$f18,$f16\ns.d $f18,Y1\nl.d $f18,OneAndHalf\ns.d $f18,-80+240($sp)\nadd.d $f10,$f18,$f16\ns.d $f10,-72+240($sp)\nadd.d $f8,$f10,$f16\ns.d $f8,Z\nl.d $f8,Z\nl.d $f6,Y2\ndiv.d $f4,$f8,$f6\ns.d $f4,X\nsub.d $f4,$f18,$f16\nsub.d $f4,$f4,$f16\ns.d $f4,T\nl.d $f4,T\nl.d $f10,Y1\nsub.d $f18,$f4,$f16\ndiv.d $f18,$f18,$f10\ns.d $f18,Y\nadd.d $f18,$f8,$f16\ndiv.d $f18,$f18,$f6\ns.d $f18,Z\nl.d $f18,X\nl.d $f8,-80+240($sp)\nsub.d $f18,$f18,$f8\ns.d $f18,X\nl.d $f18,Y\nsub.d $f18,$f18,$f4\ns.d $f18,Y\ndiv.d $f18,$f4,$f10\ns.d $f18,T\nl.d $f18,Z\nl.d $f10,-72+240($sp)\nsub.d $f18,$f18,$f10\ns.d $f18,Z\nl.d $f18,-80+240($sp)\nsub.d $f18,$f16,$f18\nl.d $f16,T\nadd.d $f18,$f18,$f16\ns.d $f18,T\nl.d $f18,Zero\nl.d $f16,X\nc.le.d $f16,$f18; bc1f L.257\nl.d $f16,Y\nc.le.d $f16,$f18; bc1f L.257\nl.d $f16,Z\nc.le.d $f16,$f18; bc1f L.257\nl.d $f16,T\nc.le.d $f16,$f18; bc1f L.257\nl.d $f18,OneAndHalf\nl.d $f16,Y2\ndiv.d $f10,$f18,$f16\ns.d $f10,X\nl.d $f10,U2\nsub.d $f8,$f18,$f10\ns.d $f8,Y\nadd.d $f8,$f18,$f10\ns.d $f8,Z\nl.d $f8,Y\nl.d $f6,X\nsub.d $f6,$f6,$f8\ns.d $f6,X\nl.d $f6,Y1\ndiv.d $f4,$f18,$f6\ns.d $f4,T\ndiv.d $f8,$f8,$f6\ns.d $f8,Y\nl.d $f8,Z\nl.d $f6,T\nadd.d $f4,$f8,$f10\nsub.d $f6,$f6,$f4\ns.d $f6,T\nl.d $f6,Y\nsub.d $f6,$f6,$f8\ns.d $f6,Y\ndiv.d $f8,$f8,$f16\ns.d $f8,Z\nadd.d $f10,$f16,$f10\ndiv.d $f10,$f10,$f16\ns.d $f10,Y1\nl.d $f10,Z\nsub.d $f18,$f10,$f18\ns.d $f18,Z\nl.d $f18,Y1\nsub.d $f18,$f18,$f16\ns.d $f18,Y2\nl.d $f18,F9\nl.d $f16,U1\nsub.d $f16,$f18,$f16\ndiv.d $f18,$f16,$f18\ns.d $f18,Y1\nl.d $f18,Zero\nl.d $f16,X\nc.eq.d $f16,$f18; bc1f L.259\nl.d $f16,Y\nc.eq.d $f16,$f18; bc1f L.259\nl.d $f16,Z\nc.eq.d $f16,$f18; bc1f L.259\nl.d $f16,T\nc.eq.d $f16,$f18; bc1f L.259\nl.d $f16,Y2\nc.eq.d $f16,$f18; bc1f L.259\nc.eq.d $f16,$f18; bc1f L.259\nl.d $f18,Half\nl.d $f16,Y1\nsub.d $f16,$f16,$f18\nl.d $f10,F9\nsub.d $f18,$f10,$f18\nc.eq.d $f16,$f18; bc1f L.259\nla $24,1\nsw $24,RDiv\nla $4,L.261\njal printf\nlw $24,GDiv\nbne $24,$0,L.260\nla $4,L.264\njal notify\nb L.260\nL.259:\nl.d $f18,Zero\nl.d $f16,X\nc.lt.d $f16,$f18; bc1f L.265\nl.d $f16,Y\nc.lt.d $f16,$f18; bc1f L.265\nl.d $f16,Z\nc.lt.d $f16,$f18; bc1f L.265\nl.d $f16,T\nc.lt.d $f16,$f18; bc1f L.265\nl.d $f16,Y2\nc.lt.d $f16,$f18; bc1f L.265\nl.d $f18,Half\nl.d $f16,Y1\nsub.d $f16,$f16,$f18\nl.d $f10,F9\nsub.d $f18,$f10,$f18\nc.lt.d $f16,$f18; bc1f L.265\nla $24,2\nsw $24,RDiv\nla $4,L.267\njal printf\nL.265:\nL.260:\nL.257:\nlw $24,RDiv\nbne $24,$0,L.268\nla $4,L.270\njal printf\nL.268:\nl.d $f18,Radix\nl.d $f16,One\ndiv.d $f16,$f16,$f18\ns.d $f16,BInvrse\nmove $4,$0\nl.d $f16,Half\nl.d $f10,BInvrse\nmul.d $f18,$f10,$f18\nsub.d $f18,$f18,$f16\nc.eq.d $f18,$f16; bc1f L.273\nla $24,1\nsw $24,-84+240($sp)\nb L.274\nL.273:\nsw $0,-84+240($sp)\nL.274:\nlw $5,-84+240($sp)\nla $6,L.272\njal TstCond\nla $24,50\nsw $24,Milestone\nmove $4,$0\nl.d $f18,Half\nl.d $f16,F9\nl.d $f10,U1\nadd.d $f16,$f16,$f10\nsub.d $f16,$f16,$f18\nc.eq.d $f16,$f18; bc1f L.277\nl.d $f18,One\nl.d $f16,BMinusU2\nl.d $f10,U2\nadd.d $f16,$f16,$f10\nsub.d $f16,$f16,$f18\nl.d $f10,Radix\nsub.d $f18,$f10,$f18\nc.eq.d $f16,$f18; bc1f L.277\nla $24,1\nsw $24,-88+240($sp)\nb L.278\nL.277:\nsw $0,-88+240($sp)\nL.278:\nlw $5,-88+240($sp)\nla $6,L.276\njal TstCond\nl.d $f18,One\nl.d $f16,U1\nmul.d $f16,$f16,$f16\nsub.d $f16,$f18,$f16\ns.d $f16,X\nl.d $f16,U2\nsub.d $f10,$f18,$f16\nmul.d $f16,$f16,$f10\nadd.d $f16,$f18,$f16\ns.d $f16,Y\nl.d $f16,Half\nl.d $f10,F9\nsub.d $f10,$f10,$f16\ns.d $f10,Z\nl.d $f10,X\nsub.d $f16,$f10,$f16\nl.d $f10,Z\nsub.d $f16,$f16,$f10\ns.d $f16,X\nl.d $f16,Y\nsub.d $f18,$f16,$f18\ns.d $f18,Y\nl.d $f18,Zero\nl.d $f16,X\nc.eq.d $f16,$f18; bc1f L.279\nl.d $f16,Y\nc.eq.d $f16,$f18; bc1f L.279\nla $24,2\nsw $24,RAddSub\nla $4,L.281\njal printf\nL.279:\nlw $24,GAddSub\nla $15,1\nbne $24,$15,L.282\nl.d $f18,Half\nl.d $f16,U2\nadd.d $f10,$f18,$f16\nmul.d $f10,$f10,$f16\ns.d $f10,X\nsub.d $f18,$f18,$f16\nmul.d $f18,$f18,$f16\ns.d $f18,Y\nl.d $f18,One\nl.d $f10,X\nadd.d $f10,$f18,$f10\ns.d $f10,X\nl.d $f10,Y\nadd.d $f10,$f18,$f10\ns.d $f10,Y\nadd.d $f16,$f18,$f16\nl.d $f10,X\nsub.d $f16,$f16,$f10\ns.d $f16,X\nl.d $f16,Y\nsub.d $f18,$f18,$f16\ns.d $f18,Y\nl.d $f18,Zero\nl.d $f16,X\nc.eq.d $f16,$f18; bc1f L.284\nl.d $f16,Y\nc.eq.d $f16,$f18; bc1f L.284\nl.d $f18,Half\nl.d $f16,U2\nl.d $f10,U1\nadd.d $f8,$f18,$f16\nmul.d $f8,$f8,$f10\ns.d $f8,X\nsub.d $f18,$f18,$f16\nmul.d $f18,$f18,$f10\ns.d $f18,Y\nl.d $f18,One\nl.d $f16,X\nsub.d $f16,$f18,$f16\ns.d $f16,X\nl.d $f16,Y\nsub.d $f16,$f18,$f16\ns.d $f16,Y\nl.d $f16,F9\nl.d $f10,X\nsub.d $f16,$f16,$f10\ns.d $f16,X\nl.d $f16,Y\nsub.d $f18,$f18,$f16\ns.d $f18,Y\nl.d $f18,Zero\nl.d $f16,X\nc.eq.d $f16,$f18; bc1f L.286\nl.d $f16,Y\nc.eq.d $f16,$f18; bc1f L.286\nla $24,1\nsw $24,RAddSub\nla $4,L.288\njal printf\nlw $24,GAddSub\nbne $24,$0,L.283\nla $4,L.291\njal notify\nb L.283\nL.286:\nla $4,L.292\njal printf\nb L.283\nL.284:\nla $4,L.292\njal printf\nb L.283\nL.282:\nla $4,L.292\njal printf\nL.283:\nl.d $f18,One\ns.d $f18,S\nl.d $f16,Half\nadd.d $f10,$f18,$f16\nmul.d $f10,$f16,$f10\nadd.d $f10,$f18,$f10\ns.d $f10,X\nl.d $f10,U2\nadd.d $f18,$f18,$f10\nmul.d $f18,$f18,$f16\ns.d $f18,Y\nl.d $f18,X\nl.d $f16,Y\nsub.d $f10,$f18,$f16\ns.d $f10,Z\nsub.d $f18,$f16,$f18\ns.d $f18,T\nl.d $f18,Z\nl.d $f16,T\nadd.d $f18,$f18,$f16\ns.d $f18,StickyBit\nl.d $f18,StickyBit\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1t L.293\nl.d $f18,Zero\ns.d $f18,S\nla $4,3\nla $5,L.295\njal BadCond\nL.293:\nl.d $f18,Zero\ns.d $f18,StickyBit\nla $24,1\nlw $15,GMult\nbne $15,$24,L.296\nlw $15,GDiv\nbne $15,$24,L.296\nlw $15,GAddSub\nbne $15,$24,L.296\nlw $15,RMult\nbne $15,$24,L.296\nlw $15,RDiv\nbne $15,$24,L.296\nlw $15,RAddSub\nbne $15,$24,L.296\nl.d $f12,RadixD2\njal floor\nl.d $f16,RadixD2\nc.eq.d $f0,$f16; bc1f L.296\nla $4,L.298\njal printf\nl.d $f18,Half\nl.d $f16,U2\nl.d $f10,U1\nadd.d $f10,$f18,$f10\nmul.d $f10,$f10,$f16\ns.d $f10,X\nmul.d $f18,$f18,$f16\ns.d $f18,Y\nl.d $f18,One\nl.d $f16,Y\nadd.d $f16,$f18,$f16\ns.d $f16,Z\nl.d $f16,X\nadd.d $f18,$f18,$f16\ns.d $f18,T\nl.d $f18,One\nl.d $f16,Z\nsub.d $f16,$f16,$f18\nl.d $f10,Zero\nc.le.d $f16,$f10; bc1f L.299\nl.d $f16,T\nsub.d $f18,$f16,$f18\nl.d $f16,U2\nc.lt.d $f18,$f16; bc1t L.299\nl.d $f18,T\nl.d $f16,Y\nadd.d $f18,$f18,$f16\ns.d $f18,Z\nl.d $f18,Z\nl.d $f16,X\nsub.d $f18,$f18,$f16\ns.d $f18,Y\nl.d $f18,T\nl.d $f16,Z\nsub.d $f16,$f16,$f18\nl.d $f10,U2\nc.lt.d $f16,$f10; bc1t L.301\nl.d $f16,Y\nsub.d $f18,$f16,$f18\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1f L.301\nl.d $f18,Half\nl.d $f16,U1\nadd.d $f10,$f18,$f16\nmul.d $f10,$f10,$f16\ns.d $f10,X\nmul.d $f18,$f18,$f16\ns.d $f18,Y\nl.d $f18,One\nl.d $f16,Y\nsub.d $f16,$f18,$f16\ns.d $f16,Z\nl.d $f16,X\nsub.d $f18,$f18,$f16\ns.d $f18,T\nl.d $f18,Zero\nl.d $f16,Z\nl.d $f10,One\nsub.d $f16,$f16,$f10\nc.eq.d $f16,$f18; bc1f L.303\nl.d $f16,T\nl.d $f10,F9\nsub.d $f16,$f16,$f10\nc.eq.d $f16,$f18; bc1f L.303\nl.d $f18,U1\nl.d $f16,Half\nsub.d $f16,$f16,$f18\nmul.d $f18,$f16,$f18\ns.d $f18,Z\nl.d $f18,F9\nl.d $f16,Z\nsub.d $f16,$f18,$f16\ns.d $f16,T\nl.d $f16,Y\nsub.d $f18,$f18,$f16\ns.d $f18,Q\nl.d $f18,F9\nl.d $f16,Zero\nl.d $f10,T\nsub.d $f10,$f10,$f18\nc.eq.d $f10,$f16; bc1f L.305\nl.d $f10,U1\nsub.d $f18,$f18,$f10\nl.d $f10,Q\nsub.d $f18,$f18,$f10\nc.eq.d $f18,$f16; bc1f L.305\nl.d $f18,One\nl.d $f16,U2\nl.d $f10,OneAndHalf\nadd.d $f8,$f18,$f16\nmul.d $f8,$f8,$f10\ns.d $f8,Z\nadd.d $f10,$f10,$f16\nl.d $f8,Z\nsub.d $f10,$f10,$f8\nadd.d $f10,$f10,$f16\ns.d $f10,T\nl.d $f10,Radix\nl.d $f8,Half\ndiv.d $f8,$f8,$f10\nadd.d $f8,$f18,$f8\ns.d $f8,X\nmul.d $f16,$f10,$f16\nadd.d $f18,$f18,$f16\ns.d $f18,Y\nl.d $f18,X\nl.d $f16,Y\nmul.d $f18,$f18,$f16\ns.d $f18,Z\nl.d $f18,Zero\nl.d $f16,T\nc.eq.d $f16,$f18; bc1f L.307\nl.d $f16,X\nl.d $f10,Radix\nl.d $f8,U2\nmul.d $f10,$f10,$f8\nadd.d $f16,$f16,$f10\nl.d $f10,Z\nsub.d $f16,$f16,$f10\nc.eq.d $f16,$f18; bc1f L.307\nl.d $f18,Radix\nl.d $f16,Two\nc.eq.d $f18,$f16; bc1t L.309\nl.d $f18,Two\nl.d $f16,U2\nadd.d $f16,$f18,$f16\ns.d $f16,X\nl.d $f16,X\ndiv.d $f18,$f16,$f18\ns.d $f18,Y\nl.d $f18,Y\nl.d $f16,One\nsub.d $f18,$f18,$f16\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1f L.310\nl.d $f18,S\ns.d $f18,StickyBit\nb L.310\nL.309:\nl.d $f18,S\ns.d $f18,StickyBit\nL.310:\nL.307:\nL.305:\nL.303:\nL.301:\nL.299:\nL.296:\nl.d $f18,StickyBit\nl.d $f16,One\nc.eq.d $f18,$f16; bc1f L.313\nla $4,L.315\njal printf\nb L.314\nL.313:\nla $4,L.316\njal printf\nL.314:\nla $4,3\nlw $15,GMult\nbeq $15,$0,L.319\nlw $15,GDiv\nbeq $15,$0,L.319\nlw $15,GAddSub\nbeq $15,$0,L.319\nlw $15,RMult\nbeq $15,$0,L.319\nlw $15,RDiv\nbeq $15,$0,L.319\nlw $15,RAddSub\nbeq $15,$0,L.319\nla $24,1\nsw $24,-92+240($sp)\nb L.320\nL.319:\nsw $0,-92+240($sp)\nL.320:\nlw $5,-92+240($sp)\nla $6,L.318\njal TstCond\nla $24,60\nsw $24,Milestone\nla $4,L.44\njal printf\nla $4,L.321\njal printf\nla $4,L.322\nlw $5,NoTrials\njal printf\nl.d $f12,L.323\njal sqrt\ns.d $f0,Random9\nl.d $f18,Third\ns.d $f18,Random1\nla $24,1\nsw $24,I\nL.324:\njal Random\ns.d $f0,X\njal Random\ns.d $f0,Y\nl.d $f18,Y\nl.d $f16,X\nmul.d $f10,$f18,$f16\ns.d $f10,Z9\nmul.d $f18,$f16,$f18\ns.d $f18,Z\nl.d $f18,Z\nl.d $f16,Z9\nsub.d $f18,$f18,$f16\ns.d $f18,Z9\nlw $24,I\nla $24,1($24)\nsw $24,I\nL.325:\nlw $24,I\nlw $15,NoTrials\nbgt $24,$15,L.327\nl.d $f18,Z9\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1t L.324\nL.327:\nlw $24,I\nlw $15,NoTrials\nbne $24,$15,L.328\nl.d $f18,One\nl.d $f16,Half\nl.d $f10,Three\ndiv.d $f16,$f16,$f10\nadd.d $f16,$f18,$f16\ns.d $f16,Random1\nl.d $f10,U2\nl.d $f8,U1\nadd.d $f10,$f10,$f8\nadd.d $f18,$f10,$f18\ns.d $f18,Random2\nl.d $f10,Random1\nl.d $f8,Random2\nmul.d $f6,$f10,$f8\ns.d $f6,Z\nmul.d $f10,$f8,$f10\ns.d $f10,Y\nmul.d $f18,$f16,$f18\nsub.d $f18,$f18,$f18\ns.d $f18,Z9\nL.328:\nlw $24,I\nlw $15,NoTrials\nbeq $24,$15,L.330\nl.d $f18,Z9\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1t L.330\nla $4,2\nla $5,L.332\njal BadCond\nb L.331\nL.330:\nla $4,L.333\nlw $5,NoTrials\njal printf\nL.331:\nla $24,70\nsw $24,Milestone\nla $4,L.334\njal printf\nl.d $f18,Zero\ns.d $f18,-104+240($sp)\nmov.d $f12,$f18\njal sqrt\nl.d $f16,-104+240($sp)\nc.eq.d $f16,$f0; bc1f L.337\nl.d $f18,Zero\nneg.d $f18,$f18\ns.d $f18,-112+240($sp)\nmov.d $f12,$f18\njal sqrt\nl.d $f16,-112+240($sp)\nc.eq.d $f16,$f0; bc1f L.337\nl.d $f18,One\ns.d $f18,-120+240($sp)\nmov.d $f12,$f18\njal sqrt\nmov.d $f18,$f0\nl.d $f16,-120+240($sp)\nc.eq.d $f16,$f18; bc1f L.337\nla $24,1\nsw $24,-96+240($sp)\nb L.338\nL.337:\nsw $0,-96+240($sp)\nL.338:\nmove $4,$0\nlw $5,-96+240($sp)\nla $6,L.336\njal TstCond\nl.d $f18,Zero\ns.d $f18,MinSqEr\ns.d $f18,MaxSqEr\ns.d $f18,J\nl.d $f18,Radix\ns.d $f18,X\nl.d $f18,U2\ns.d $f18,OneUlp\nla $4,1\njal SqXMinX\nl.d $f18,BInvrse\ns.d $f18,X\nl.d $f16,U1\nmul.d $f18,$f18,$f16\ns.d $f18,OneUlp\nla $4,1\njal SqXMinX\nl.d $f18,U1\ns.d $f18,X\nmul.d $f18,$f18,$f18\ns.d $f18,OneUlp\nla $4,1\njal SqXMinX\nl.d $f18,J\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1t L.339\njal Pause\nL.339:\nla $4,L.341\nlw $5,NoTrials\njal printf\nl.d $f18,Zero\ns.d $f18,J\nl.d $f18,Two\ns.d $f18,X\nl.d $f18,Radix\ns.d $f18,Y\nl.d $f16,One\nc.eq.d $f18,$f16; bc1t L.342\nL.344:\nl.d $f18,Y\ns.d $f18,X\nl.d $f16,Radix\nmul.d $f18,$f16,$f18\ns.d $f18,Y\nL.345:\nl.d $f18,Y\nl.d $f16,X\nsub.d $f18,$f18,$f16\nlw $24,NoTrials\nmtc1 $24,$f16; cvt.d.w $f16,$f16\nc.lt.d $f18,$f16; bc1t L.344\nL.342:\nl.d $f18,X\nl.d $f16,U2\nmul.d $f18,$f18,$f16\ns.d $f18,OneUlp\nla $24,1\nsw $24,I\nb L.348\nL.347:\nl.d $f18,X\nl.d $f16,One\nadd.d $f18,$f18,$f16\ns.d $f18,X\nla $4,2\njal SqXMinX\nl.d $f18,J\nl.d $f16,Zero\nc.le.d $f18,$f16; bc1t L.350\nb L.349\nL.350:\nlw $24,I\nla $24,1($24)\nsw $24,I\nL.348:\nlw $24,I\nlw $15,NoTrials\nble $24,$15,L.347\nL.349:\nla $4,L.352\njal printf\nla $24,-1\nsw $24,I\nl.d $f18,BMinusU2\ns.d $f18,X\nl.d $f18,Radix\ns.d $f18,Y\nl.d $f16,U2\nmul.d $f16,$f18,$f16\nadd.d $f18,$f18,$f16\ns.d $f18,Z\nsw $0,NotMonot\nsw $0,Monot\nb L.354\nL.353:\nlw $24,I\nla $24,1($24)\nsw $24,I\nl.d $f12,X\njal sqrt\ns.d $f0,X\nl.d $f12,Y\njal sqrt\ns.d $f0,Q\nl.d $f12,Z\njal sqrt\ns.d $f0,Z\nl.d $f18,Q\nl.d $f16,X\nc.le.d $f16,$f18; bc1f L.358\nl.d $f16,Z\nc.le.d $f18,$f16; bc1t L.356\nL.358:\nla $24,1\nsw $24,NotMonot\nb L.357\nL.356:\nl.d $f18,Q\nl.d $f16,Half\nadd.d $f12,$f18,$f16\njal floor\ns.d $f0,Q\nlw $24,I\nbgt $24,$0,L.361\nl.d $f18,Q\nl.d $f16,Radix\nmul.d $f18,$f18,$f18\nc.eq.d $f16,$f18; bc1f L.359\nL.361:\nla $24,1\nsw $24,Monot\nb L.360\nL.359:\nlw $24,I\nble $24,$0,L.362\nlw $24,I\nla $15,1\nble $24,$15,L.364\nla $24,1\nsw $24,Monot\nb L.363\nL.364:\nl.d $f18,Y\nl.d $f16,BInvrse\nmul.d $f18,$f18,$f16\ns.d $f18,Y\nl.d $f18,Y\nl.d $f16,U1\nsub.d $f10,$f18,$f16\ns.d $f10,X\nadd.d $f18,$f18,$f16\ns.d $f18,Z\nb L.363\nL.362:\nl.d $f18,Q\ns.d $f18,Y\nl.d $f18,Y\nl.d $f16,U2\nsub.d $f10,$f18,$f16\ns.d $f10,X\nadd.d $f18,$f18,$f16\ns.d $f18,Z\nL.363:\nL.360:\nL.357:\nL.354:\nlw $15,NotMonot\nbne $15,$0,L.366\nlw $15,Monot\nbeq $15,$0,L.353\nL.366:\nlw $24,Monot\nbeq $24,$0,L.367\nla $4,L.369\njal printf\nb L.368\nL.367:\nla $4,2\nla $5,L.157\njal BadCond\nla $4,L.370\nl.d $f18,Y\nmfc1.d $6,$f18\njal printf\nL.368:\nla $24,80\nsw $24,Milestone\nl.d $f18,Half\nl.d $f16,MinSqEr\nadd.d $f16,$f16,$f18\ns.d $f16,MinSqEr\nl.d $f16,MaxSqEr\nsub.d $f18,$f16,$f18\ns.d $f18,MaxSqEr\nl.d $f18,One\nl.d $f16,U2\nadd.d $f12,$f18,$f16\njal sqrt\nl.d $f16,One\nl.d $f10,U2\nsub.d $f18,$f0,$f16\ndiv.d $f18,$f18,$f10\ns.d $f18,Y\nl.d $f18,Y\nsub.d $f18,$f18,$f16\nl.d $f16,Eight\ndiv.d $f16,$f10,$f16\nadd.d $f18,$f18,$f16\ns.d $f18,SqEr\nl.d $f18,SqEr\nl.d $f16,MaxSqEr\nc.le.d $f18,$f16; bc1t L.371\nl.d $f18,SqEr\ns.d $f18,MaxSqEr\nL.371:\nl.d $f18,Y\nl.d $f16,U2\nl.d $f10,Eight\ndiv.d $f16,$f16,$f10\nadd.d $f18,$f18,$f16\ns.d $f18,SqEr\nl.d $f18,SqEr\nl.d $f16,MinSqEr\nc.lt.d $f18,$f16; bc1f L.373\nl.d $f18,SqEr\ns.d $f18,MinSqEr\nL.373:\nl.d $f12,F9\njal sqrt\nl.d $f16,U2\nl.d $f10,U1\nsub.d $f18,$f0,$f16\nl.d $f8,One\nsub.d $f16,$f8,$f16\nsub.d $f18,$f18,$f16\ndiv.d $f18,$f18,$f10\ns.d $f18,Y\nl.d $f18,Y\nl.d $f16,Eight\ndiv.d $f16,$f10,$f16\nadd.d $f18,$f18,$f16\ns.d $f18,SqEr\nl.d $f18,SqEr\nl.d $f16,MaxSqEr\nc.le.d $f18,$f16; bc1t L.375\nl.d $f18,SqEr\ns.d $f18,MaxSqEr\nL.375:\nl.d $f18,Y\nl.d $f16,One\nadd.d $f18,$f18,$f16\nl.d $f16,U1\nl.d $f10,Eight\ndiv.d $f16,$f16,$f10\nadd.d $f18,$f18,$f16\ns.d $f18,SqEr\nl.d $f18,SqEr\nl.d $f16,MinSqEr\nc.lt.d $f18,$f16; bc1f L.377\nl.d $f18,SqEr\ns.d $f18,MinSqEr\nL.377:\nl.d $f18,U2\ns.d $f18,OneUlp\nl.d $f18,OneUlp\ns.d $f18,X\nla $24,1\nsw $24,Indx\nL.379:\nl.d $f18,X\nl.d $f16,U1\nadd.d $f16,$f18,$f16\nadd.d $f18,$f16,$f18\nl.d $f16,F9\nadd.d $f12,$f18,$f16\njal sqrt\ns.d $f0,Y\nl.d $f18,U2\nl.d $f16,X\nl.d $f10,OneUlp\nl.d $f8,Y\nsub.d $f8,$f8,$f18\nl.d $f6,One\nsub.d $f18,$f6,$f18\nadd.d $f18,$f18,$f16\nsub.d $f18,$f8,$f18\ndiv.d $f18,$f18,$f10\ns.d $f18,Y\nl.d $f18,Half\nl.d $f8,U1\nsub.d $f8,$f8,$f16\nl.d $f6,F9\nadd.d $f8,$f8,$f6\nmul.d $f8,$f8,$f18\nmul.d $f8,$f8,$f16\nmul.d $f16,$f8,$f16\ndiv.d $f16,$f16,$f10\ns.d $f16,Z\nl.d $f16,Y\nadd.d $f18,$f16,$f18\nl.d $f16,Z\nadd.d $f18,$f18,$f16\ns.d $f18,SqEr\nl.d $f18,SqEr\nl.d $f16,MinSqEr\nc.lt.d $f18,$f16; bc1f L.383\nl.d $f18,SqEr\ns.d $f18,MinSqEr\nL.383:\nl.d $f18,Y\nl.d $f16,Half\nsub.d $f18,$f18,$f16\nl.d $f16,Z\nadd.d $f18,$f18,$f16\ns.d $f18,SqEr\nl.d $f18,SqEr\nl.d $f16,MaxSqEr\nc.le.d $f18,$f16; bc1t L.385\nl.d $f18,SqEr\ns.d $f18,MaxSqEr\nL.385:\nlw $24,Indx\nla $15,1\nbeq $24,$15,L.389\nla $15,3\nbne $24,$15,L.387\nL.389:\nl.d $f12,X\njal Sign\nmov.d $f18,$f0\ns.d $f18,-128+240($sp)\nl.d $f12,OneUlp\njal sqrt\nl.d $f16,Eight\nl.d $f10,Nine\nmul.d $f18,$f10,$f0\ndiv.d $f12,$f16,$f18\njal floor\nl.d $f16,OneUlp\nl.d $f10,-128+240($sp)\nmul.d $f16,$f16,$f10\nmul.d $f18,$f16,$f0\ns.d $f18,X\nb L.388\nL.387:\nl.d $f18,U1\ns.d $f18,OneUlp\nl.d $f18,OneUlp\nneg.d $f18,$f18\ns.d $f18,X\nL.388:\nL.380:\nlw $24,Indx\nla $24,1($24)\nsw $24,Indx\nlw $24,Indx\nla $15,3\nble $24,$15,L.379\nla $24,85\nsw $24,Milestone\nsw $0,SqRWrng\nsw $0,Anomaly\nsw $0,RSqrt\nl.d $f18,Radix\nl.d $f16,One\nc.eq.d $f18,$f16; bc1t L.390\nla $4,L.392\njal printf\nl.d $f18,Precision\ns.d $f18,-128+240($sp)\nmov.d $f12,$f18\njal floor\nmov.d $f18,$f0\nl.d $f12,Radix\nl.d $f16,One\nl.d $f10,-128+240($sp)\nadd.d $f16,$f16,$f10\nsub.d $f14,$f16,$f18\njal pow\nmov.d $f18,$f0\nl.d $f16,Half\nadd.d $f12,$f16,$f18\njal floor\ns.d $f0,D\nl.d $f18,D\nl.d $f16,Radix\ndiv.d $f16,$f18,$f16\ns.d $f16,X\nl.d $f16,A1\ndiv.d $f18,$f18,$f16\ns.d $f18,Y\nl.d $f18,X\ns.d $f18,-136+240($sp)\nmov.d $f12,$f18\njal floor\nl.d $f16,-136+240($sp)\nc.eq.d $f16,$f0; bc1f L.395\nl.d $f18,Y\ns.d $f18,-144+240($sp)\nmov.d $f12,$f18\njal floor\nl.d $f16,-144+240($sp)\nc.eq.d $f16,$f0; bc1t L.393\nL.395:\nla $24,1\nsw $24,Anomaly\nb L.394\nL.393:\nl.d $f18,Zero\ns.d $f18,X\nl.d $f18,X\ns.d $f18,Z2\nl.d $f18,One\ns.d $f18,Y\nl.d $f16,Y\ns.d $f16,Y2\nl.d $f16,Radix\nsub.d $f18,$f16,$f18\ns.d $f18,Z1\nl.d $f18,Four\nl.d $f16,D\nmul.d $f18,$f18,$f16\ns.d $f18,FourD\nL.396:\nl.d $f18,Y2\nl.d $f16,Z2\nc.le.d $f18,$f16; bc1t L.399\nl.d $f18,Radix\ns.d $f18,Q\nl.d $f18,Y\ns.d $f18,Y1\nL.401:\nl.d $f18,Q\ns.d $f18,-152+240($sp)\nl.d $f16,Half\nl.d $f10,Y1\ndiv.d $f10,$f18,$f10\nsub.d $f12,$f16,$f10\njal floor\nl.d $f16,Y1\nmul.d $f18,$f0,$f16\nl.d $f16,-152+240($sp)\nadd.d $f12,$f16,$f18\njal fabs\ns.d $f0,X1\nl.d $f18,Y1\ns.d $f18,Q\nl.d $f18,X1\ns.d $f18,Y1\nL.402:\nl.d $f18,X1\nl.d $f16,Zero\nc.le.d $f18,$f16; bc1f L.401\nl.d $f18,Q\nl.d $f16,One\nc.le.d $f18,$f16; bc1f L.404\nl.d $f18,Y2\ns.d $f18,Z2\nl.d $f18,Y\ns.d $f18,Z\nL.404:\nL.399:\nl.d $f18,Y\nl.d $f16,Two\nadd.d $f18,$f18,$f16\ns.d $f18,Y\nl.d $f18,X\nl.d $f16,Eight\nadd.d $f18,$f18,$f16\ns.d $f18,X\nl.d $f18,Y2\nl.d $f16,X\nadd.d $f18,$f18,$f16\ns.d $f18,Y2\nl.d $f18,Y2\nl.d $f16,FourD\nc.lt.d $f18,$f16; bc1t L.406\nl.d $f18,Y2\nl.d $f16,FourD\nsub.d $f18,$f18,$f16\ns.d $f18,Y2\nL.406:\nL.397:\nl.d $f18,Y\nl.d $f16,D\nc.lt.d $f18,$f16; bc1t L.396\nl.d $f18,FourD\nl.d $f16,Z2\nsub.d $f16,$f18,$f16\ns.d $f16,X8\nl.d $f16,X8\nl.d $f10,Z\nmul.d $f10,$f10,$f10\nadd.d $f10,$f16,$f10\ndiv.d $f18,$f10,$f18\ns.d $f18,Q\nl.d $f18,Eight\ndiv.d $f18,$f16,$f18\ns.d $f18,X8\nl.d $f18,Q\ns.d $f18,-152+240($sp)\nmov.d $f12,$f18\njal floor\nl.d $f16,-152+240($sp)\nc.eq.d $f16,$f0; bc1t L.408\nla $24,1\nsw $24,Anomaly\nb L.409\nL.408:\nsw $0,Break\nL.410:\nl.d $f18,Z1\nl.d $f16,Z\nmul.d $f18,$f18,$f16\ns.d $f18,X\nl.d $f18,X\ns.d $f18,-160+240($sp)\nl.d $f16,Radix\ndiv.d $f12,$f18,$f16\njal floor\nl.d $f16,Radix\nmul.d $f18,$f0,$f16\nl.d $f16,-160+240($sp)\nsub.d $f18,$f16,$f18\ns.d $f18,X\nl.d $f18,X\nl.d $f16,One\nc.eq.d $f18,$f16; bc1f L.413\nla $24,1\nsw $24,Break\nb L.414\nL.413:\nl.d $f18,Z1\nl.d $f16,One\nsub.d $f18,$f18,$f16\ns.d $f18,Z1\nL.414:\nL.411:\nlw $24,Break\nbne $24,$0,L.415\nl.d $f18,Z1\nl.d $f16,Zero\nc.le.d $f18,$f16; bc1f L.410\nL.415:\nl.d $f18,Z1\nl.d $f16,Zero\nc.le.d $f18,$f16; bc1f L.416\nlw $24,Break\nbne $24,$0,L.416\nla $24,1\nsw $24,Anomaly\nb L.417\nL.416:\nl.d $f18,Z1\nl.d $f16,RadixD2\nc.le.d $f18,$f16; bc1t L.418\nl.d $f18,Z1\nl.d $f16,Radix\nsub.d $f18,$f18,$f16\ns.d $f18,Z1\nL.418:\nL.420:\njal NewD\nL.421:\nl.d $f18,U2\nl.d $f16,D\nmul.d $f18,$f18,$f16\nl.d $f16,F9\nc.lt.d $f18,$f16; bc1t L.420\nl.d $f18,D\nl.d $f16,Radix\nmul.d $f16,$f18,$f16\nsub.d $f16,$f16,$f18\nl.d $f10,W\nsub.d $f18,$f10,$f18\nc.eq.d $f16,$f18; bc1t L.423\nla $24,1\nsw $24,Anomaly\nb L.424\nL.423:\nl.d $f18,D\ns.d $f18,Z2\nsw $0,I\nl.d $f16,Z\nl.d $f10,One\nadd.d $f10,$f10,$f16\nl.d $f8,Half\nmul.d $f10,$f10,$f8\nadd.d $f10,$f18,$f10\ns.d $f10,Y\nadd.d $f18,$f18,$f16\nl.d $f16,Q\nadd.d $f18,$f18,$f16\ns.d $f18,X\njal SR3750\nl.d $f18,D\nl.d $f16,Z\nl.d $f10,One\nsub.d $f10,$f10,$f16\nl.d $f8,Half\nmul.d $f10,$f10,$f8\nadd.d $f10,$f18,$f10\nadd.d $f10,$f10,$f18\ns.d $f10,Y\nsub.d $f16,$f18,$f16\nadd.d $f18,$f16,$f18\ns.d $f18,X\nl.d $f18,X\nl.d $f16,Q\nadd.d $f16,$f18,$f16\nadd.d $f18,$f16,$f18\ns.d $f18,X\njal SR3750\njal NewD\nl.d $f18,Z2\nl.d $f16,D\nsub.d $f16,$f16,$f18\nl.d $f10,W\nsub.d $f18,$f10,$f18\nc.eq.d $f16,$f18; bc1t L.425\nla $24,1\nsw $24,Anomaly\nb L.426\nL.425:\nl.d $f18,Z2\nl.d $f16,D\nsub.d $f16,$f16,$f18\nl.d $f10,Z\nl.d $f8,One\nsub.d $f8,$f8,$f10\nl.d $f6,Half\nmul.d $f8,$f8,$f6\nadd.d $f8,$f18,$f8\nadd.d $f8,$f16,$f8\ns.d $f8,Y\nsub.d $f18,$f18,$f10\nl.d $f10,Q\nadd.d $f18,$f18,$f10\nadd.d $f18,$f16,$f18\ns.d $f18,X\njal SR3750\nl.d $f18,One\nl.d $f16,Z\nadd.d $f18,$f18,$f16\nl.d $f16,Half\nmul.d $f18,$f18,$f16\ns.d $f18,Y\nl.d $f18,Q\ns.d $f18,X\njal SR3750\nlw $24,I\nbne $24,$0,L.427\nla $24,1\nsw $24,Anomaly\nL.427:\nL.426:\nL.424:\nL.417:\nL.409:\nL.394:\nlw $15,I\nbeq $15,$0,L.431\nlw $15,Anomaly\nbeq $15,$0,L.429\nL.431:\nmove $4,$0\nla $5,L.432\njal BadCond\nla $4,L.433\nl.d $f18,W\nmfc1.d $6,$f18\njal printf\nla $4,L.434\njal printf\nla $24,1\nsw $24,SqRWrng\nL.429:\nL.390:\nlw $24,Anomaly\nbne $24,$0,L.435\nl.d $f18,Zero\nl.d $f16,MinSqEr\nc.lt.d $f16,$f18; bc1t L.437\nl.d $f16,MaxSqEr\nc.le.d $f16,$f18; bc1f L.437\nla $24,1\nsw $24,RSqrt\nla $4,L.439\njal printf\nb L.438\nL.437:\nl.d $f18,U2\nl.d $f16,Half\nl.d $f10,MaxSqEr\nadd.d $f10,$f10,$f18\nsub.d $f18,$f18,$f16\nc.le.d $f10,$f18; bc1f L.443\nl.d $f18,MinSqEr\nc.le.d $f18,$f16; bc1f L.443\nl.d $f10,Radix\nadd.d $f18,$f18,$f10\nc.lt.d $f18,$f16; bc1f L.440\nL.443:\nla $24,1\nsw $24,SqRWrng\nb L.441\nL.440:\nla $24,2\nsw $24,RSqrt\nla $4,L.444\njal printf\nL.441:\nL.438:\nL.435:\nlw $24,SqRWrng\nbeq $24,$0,L.445\nla $4,L.447\njal printf\nla $4,L.448\nl.d $f18,MinSqEr\nl.d $f16,Half\nsub.d $f18,$f18,$f16\nmfc1.d $6,$f18\njal printf\nla $4,L.449\nl.d $f18,Half\nl.d $f16,MaxSqEr\nadd.d $f18,$f18,$f16\nmfc1.d $6,$f18\njal printf\nla $4,1\nl.d $f18,Radix\nl.d $f16,MaxSqEr\nl.d $f10,MinSqEr\nsub.d $f16,$f16,$f10\nmul.d $f18,$f18,$f18\nc.lt.d $f16,$f18; bc1f L.452\nla $24,1\nsw $24,-124+240($sp)\nb L.453\nL.452:\nsw $0,-124+240($sp)\nL.453:\nlw $5,-124+240($sp)\nla $6,L.451\njal TstCond\nL.445:\nla $24,90\nsw $24,Milestone\njal Pause\nla $4,L.454\njal printf\nsw $0,N\nsw $0,I\nl.d $f18,Zero\nneg.d $f18,$f18\ns.d $f18,Z\nla $15,3\nsw $15,M\nsw $0,Break\nL.455:\nl.d $f18,One\ns.d $f18,X\njal SR3980\nlw $24,I\nla $15,10\nbgt $24,$15,L.458\nla $24,1023\nsw $24,I\njal SR3980\nL.458:\nl.d $f18,Z\nl.d $f16,MinusOne\nc.eq.d $f18,$f16; bc1f L.460\nla $24,1\nsw $24,Break\nb L.461\nL.460:\nl.d $f18,MinusOne\ns.d $f18,Z\njal PrintIfNPositive\nsw $0,N\nla $24,-4\nsw $24,I\nL.461:\nL.456:\nlw $24,Break\nbeq $24,$0,L.455\njal PrintIfNPositive\nlw $24,N\nsw $24,N1\nsw $0,N\nl.d $f18,A1\ns.d $f18,Z\nl.d $f12,W\njal log\nmov.d $f18,$f0\ns.d $f18,-128+240($sp)\nl.d $f12,A1\njal log\nmov.d $f18,$f0\nl.d $f16,Two\nl.d $f10,-128+240($sp)\nmul.d $f16,$f16,$f10\ndiv.d $f12,$f16,$f18\njal floor\ntrunc.w.d $f2,$f0,$24; mfc1 $24,$f2\nsw $24,M\nsw $0,Break\nL.462:\nl.d $f18,Z\ns.d $f18,X\nla $24,1\nsw $24,I\njal SR3980\nl.d $f18,Z\nl.d $f16,AInvrse\nc.eq.d $f18,$f16; bc1f L.465\nla $24,1\nsw $24,Break\nb L.466\nL.465:\nl.d $f18,AInvrse\ns.d $f18,Z\nL.466:\nL.463:\nlw $24,Break\nbeq $24,$0,L.462\nla $24,100\nsw $24,Milestone\nlw $24,NoTrials\nsw $24,M\nl.d $f18,Three\ns.d $f18,Z\nL.467:\nl.d $f18,Z\ns.d $f18,X\nla $24,1\nsw $24,I\njal SR3980\nL.470:\nl.d $f18,Z\nl.d $f16,Two\nadd.d $f18,$f18,$f16\ns.d $f18,Z\nL.471:\nl.d $f18,Three\ns.d $f18,-136+240($sp)\nl.d $f16,Z\ndiv.d $f12,$f16,$f18\njal floor\nl.d $f16,-136+240($sp)\nmul.d $f18,$f16,$f0\nl.d $f16,Z\nc.eq.d $f18,$f16; bc1t L.470\nL.468:\nl.d $f18,Z\nl.d $f16,Eight\nl.d $f10,Three\nmul.d $f16,$f16,$f10\nc.lt.d $f18,$f16; bc1t L.467\nlw $24,N\nble $24,$0,L.473\nla $4,L.475\njal printf\nla $4,L.476\njal printf\nL.473:\njal PrintIfNPositive\nlw $24,N\nlw $15,N1\naddu $24,$24,$15\nsw $24,N\nlw $24,N\nbne $24,$0,L.477\nla $4,L.479\njal printf\nL.477:\nlw $24,N\nble $24,$0,L.480\njal Pause\nb L.481\nL.480:\nla $4,L.44\njal printf\nL.481:\nla $24,110\nsw $24,Milestone\nla $4,L.482\njal printf\nl.d $f18,U1\ns.d $f18,D\nl.d $f18,Precision\ns.d $f18,-136+240($sp)\nmov.d $f12,$f18\njal floor\nl.d $f16,-136+240($sp)\nc.eq.d $f16,$f0; bc1t L.483\nl.d $f18,BInvrse\ns.d $f18,D\nl.d $f18,Precision\ns.d $f18,X\nL.485:\nl.d $f18,D\nl.d $f16,BInvrse\nmul.d $f18,$f18,$f16\ns.d $f18,D\nl.d $f18,X\nl.d $f16,One\nsub.d $f18,$f18,$f16\ns.d $f18,X\nL.486:\nl.d $f18,X\nl.d $f16,Zero\nc.le.d $f18,$f16; bc1f L.485\nL.483:\nl.d $f18,One\ns.d $f18,Y\nl.d $f18,D\ns.d $f18,Z\nL.488:\nl.d $f18,Y\ns.d $f18,C\nl.d $f18,Z\ns.d $f18,Y\nl.d $f18,Y\nmul.d $f18,$f18,$f18\ns.d $f18,Z\nL.489:\nl.d $f18,Z\nl.d $f16,Y\nc.le.d $f16,$f18; bc1t L.491\nadd.d $f16,$f18,$f18\nc.le.d $f16,$f18; bc1f L.488\nL.491:\nl.d $f18,C\ns.d $f18,Y\nl.d $f18,Y\nl.d $f16,D\nmul.d $f18,$f18,$f16\ns.d $f18,Z\nL.492:\nl.d $f18,Y\ns.d $f18,C\nl.d $f18,Z\ns.d $f18,Y\nl.d $f18,Y\nl.d $f16,D\nmul.d $f18,$f18,$f16\ns.d $f18,Z\nL.493:\nl.d $f18,Z\nl.d $f16,Y\nc.le.d $f16,$f18; bc1t L.495\nadd.d $f16,$f18,$f18\nc.le.d $f16,$f18; bc1f L.492\nL.495:\nl.d $f18,Radix\nl.d $f16,Two\nc.lt.d $f18,$f16; bc1f L.496\nl.d $f18,Two\ns.d $f18,HInvrse\nb L.497\nL.496:\nl.d $f18,Radix\ns.d $f18,HInvrse\nL.497:\nl.d $f18,One\nl.d $f16,HInvrse\ndiv.d $f16,$f18,$f16\ns.d $f16,H\nl.d $f16,C\ndiv.d $f18,$f18,$f16\ns.d $f18,CInvrse\ns.d $f16,E0\nl.d $f18,E0\nl.d $f16,H\nmul.d $f18,$f18,$f16\ns.d $f18,Z\nL.498:\nl.d $f18,E0\ns.d $f18,Y\nl.d $f18,Z\ns.d $f18,E0\nl.d $f18,E0\nl.d $f16,H\nmul.d $f18,$f18,$f16\ns.d $f18,Z\nL.499:\nl.d $f18,Z\nl.d $f16,E0\nc.le.d $f16,$f18; bc1t L.501\nadd.d $f16,$f18,$f18\nc.le.d $f16,$f18; bc1f L.498\nL.501:\nl.d $f18,E0\ns.d $f18,UfThold\nl.d $f18,Zero\ns.d $f18,E1\ns.d $f18,Q\nl.d $f18,U2\ns.d $f18,E9\nl.d $f18,One\nl.d $f16,E9\nadd.d $f18,$f18,$f16\ns.d $f18,S\nl.d $f18,C\nl.d $f16,S\nmul.d $f16,$f18,$f16\ns.d $f16,D\nl.d $f16,D\nc.le.d $f16,$f18; bc1f L.502\nl.d $f18,Radix\nl.d $f16,U2\nmul.d $f18,$f18,$f16\ns.d $f18,E9\nl.d $f18,One\nl.d $f16,E9\nadd.d $f18,$f18,$f16\ns.d $f18,S\nl.d $f18,C\nl.d $f16,S\nmul.d $f16,$f18,$f16\ns.d $f16,D\nl.d $f16,D\nc.le.d $f16,$f18; bc1f L.503\nmove $4,$0\nla $5,L.506\njal BadCond\nl.d $f18,E0\ns.d $f18,Underflow\nl.d $f18,Zero\ns.d $f18,Y1\nl.d $f18,Z\ns.d $f18,PseudoZero\njal Pause\nb L.503\nL.502:\nl.d $f18,D\ns.d $f18,Underflow\nl.d $f18,Underflow\nl.d $f16,H\nmul.d $f18,$f18,$f16\ns.d $f18,PseudoZero\nl.d $f18,Zero\ns.d $f18,UfThold\nL.507:\nl.d $f18,Underflow\ns.d $f18,Y1\nl.d $f18,PseudoZero\ns.d $f18,Underflow\nl.d $f18,E1\nadd.d $f16,$f18,$f18\nc.le.d $f16,$f18; bc1f L.510\nl.d $f18,Underflow\nl.d $f16,HInvrse\nmul.d $f18,$f18,$f16\ns.d $f18,Y2\nl.d $f18,Y1\nl.d $f16,Y2\nsub.d $f12,$f18,$f16\njal fabs\ns.d $f0,E1\nl.d $f18,Y1\ns.d $f18,Q\nl.d $f18,UfThold\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1f L.512\nl.d $f18,Y1\nl.d $f16,Y2\nc.eq.d $f18,$f16; bc1t L.512\nl.d $f18,Y1\ns.d $f18,UfThold\nL.512:\nL.510:\nl.d $f18,PseudoZero\nl.d $f16,H\nmul.d $f18,$f18,$f16\ns.d $f18,PseudoZero\nL.508:\nl.d $f18,PseudoZero\nl.d $f16,Underflow\nc.le.d $f16,$f18; bc1t L.514\nadd.d $f16,$f18,$f18\nc.le.d $f16,$f18; bc1f L.507\nL.514:\nL.503:\nl.d $f18,PseudoZero\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1t L.515\nla $4,L.44\njal printf\nl.d $f18,PseudoZero\ns.d $f18,Z\nl.d $f16,Zero\nc.le.d $f18,$f16; bc1f L.517\nmove $4,$0\nla $5,L.519\njal BadCond\nla $4,L.520\njal printf\nla $4,L.521\nl.d $f18,PseudoZero\nmfc1.d $6,$f18\njal printf\nl.d $f18,PseudoZero\nneg.d $f18,$f18\ns.d $f18,X\nl.d $f18,X\nl.d $f16,Zero\nc.le.d $f18,$f16; bc1f L.518\nla $4,L.524\njal printf\nla $4,L.525\nl.d $f18,X\nmfc1.d $6,$f18\njal printf\nb L.518\nL.517:\nla $4,3\nla $5,L.526\njal BadCond\nla $4,L.527\nl.d $f18,PseudoZero\nmfc1.d $6,$f18\njal printf\nL.518:\njal TstPtUf\nL.515:\nla $24,120\nsw $24,Milestone\nl.d $f18,CInvrse\nl.d $f16,Y\nmul.d $f16,$f18,$f16\nl.d $f10,Y1\nmul.d $f18,$f18,$f10\nc.le.d $f16,$f18; bc1t L.528\nl.d $f18,H\nl.d $f16,S\nmul.d $f18,$f18,$f16\ns.d $f18,S\nl.d $f18,Underflow\ns.d $f18,E0\nL.528:\nl.d $f18,E1\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1t L.530\nl.d $f16,E0\nc.eq.d $f18,$f16; bc1t L.530\nla $4,2\nla $5,L.157\njal BadCond\nl.d $f18,E1\nl.d $f16,E0\nc.lt.d $f18,$f16; bc1f L.532\nla $4,L.534\njal printf\nla $4,L.535\njal printf\nl.d $f18,PseudoZero\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1f L.533\nl.d $f18,E1\ns.d $f18,E0\nb L.533\nL.532:\nla $4,L.538\njal printf\nla $4,L.539\njal printf\nL.533:\nL.530:\nla $4,L.540\nl.d $f18,E0\nmfc1.d $6,$f18\njal printf\nl.d $f18,E0\ns.d $f18,Z\njal TstPtUf\nl.d $f18,E0\ns.d $f18,Underflow\nlw $24,N\nla $15,1\nbne $24,$15,L.541\nl.d $f18,Y\ns.d $f18,Underflow\nL.541:\nla $24,4\nsw $24,I\nl.d $f18,E1\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1f L.543\nla $24,3\nsw $24,I\nL.543:\nl.d $f18,UfThold\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1f L.545\nlw $24,I\nsubu $24,$24,2\nsw $24,I\nL.545:\nla $24,1\nsw $24,UfNGrad\nlw $24,I\nla $15,1\nblt $24,$15,L.547\nla $15,4\nbgt $24,$15,L.547\nsll $24,$24,2\nlw $24,L.570-4($24)\n.cpadd $24\nj $24\n.rdata\n.align 2\nL.570:\n.gpword L.549\n.gpword L.556\n.gpword L.561\n.gpword L.562\n.text\nL.549:\nl.d $f18,Underflow\ns.d $f18,UfThold\nl.d $f18,CInvrse\nl.d $f16,Q\nmul.d $f16,$f18,$f16\nl.d $f10,Y\nmul.d $f18,$f18,$f10\nl.d $f10,S\nmul.d $f18,$f18,$f10\nc.eq.d $f16,$f18; bc1t L.550\nl.d $f18,Y\ns.d $f18,UfThold\nmove $4,$0\nla $5,L.552\njal BadCond\nla $4,L.553\nl.d $f18,UfThold\nmfc1.d $6,$f18\njal printf\nla $4,L.554\nl.d $f18,C\nmfc1.d $6,$f18\njal printf\nla $4,L.555\njal printf\nL.550:\njal Pause\nb L.548\nL.556:\nmove $4,$0\nla $5,L.557\njal BadCond\nla $4,L.558\njal printf\nla $4,L.559\nl.d $f18,Q\nmfc1.d $6,$f18\nl.d $f18,Y2\ns.d $f18,16($sp)\njal printf\nl.d $f18,Q\nl.d $f16,Y2\nsub.d $f12,$f18,$f16\njal fabs\nmov.d $f18,$f0\nla $4,L.560\nmfc1.d $6,$f18\njal printf\nl.d $f18,Q\ns.d $f18,UfThold\nb L.548\nL.561:\nl.d $f18,X\ns.d $f18,X\nb L.548\nL.562:\nl.d $f18,UfThold\nl.d $f16,Q\nc.eq.d $f16,$f18; bc1f L.563\nl.d $f16,E1\nl.d $f10,E0\nc.eq.d $f16,$f10; bc1f L.563\nl.d $f10,E9\ndiv.d $f16,$f16,$f10\nsub.d $f12,$f18,$f16\njal fabs\nl.d $f16,E1\nc.le.d $f0,$f16; bc1f L.563\nsw $0,UfNGrad\nla $4,L.565\njal printf\nla $4,L.566\njal printf\nl.d $f18,E0\nl.d $f16,CInvrse\nmul.d $f10,$f18,$f16\ns.d $f10,Y\nl.d $f10,U2\nl.d $f8,Y\nl.d $f6,OneAndHalf\nadd.d $f6,$f6,$f10\nmul.d $f8,$f8,$f6\ns.d $f8,Y\nl.d $f8,One\nadd.d $f10,$f8,$f10\nmul.d $f16,$f16,$f10\ns.d $f16,X\nl.d $f16,Y\nl.d $f10,X\ndiv.d $f16,$f16,$f10\ns.d $f16,Y\nl.d $f16,Y\nc.eq.d $f16,$f18; bc1f L.568\nla $24,1\nsw $24,-140+240($sp)\nb L.569\nL.568:\nsw $0,-140+240($sp)\nL.569:\nlw $24,-140+240($sp)\nsw $24,IEEE\nL.563:\nL.547:\nL.548:\nlw $24,UfNGrad\nbeq $24,$0,L.572\nla $4,L.44\njal printf\nla $24,sigfpe\nsw $24,sigsave\nla $4,ovfl_buf\njal setjmp\nbeq $2,$0,L.574\nla $4,L.576\njal printf\nl.d $f18,H\nadd.d $f18,$f18,$f18\ns.d $f18,R\nb L.575\nL.574:\nl.d $f18,Underflow\nl.d $f16,UfThold\ndiv.d $f12,$f18,$f16\njal sqrt\ns.d $f0,R\nL.575:\nsw $0,sigsave\nl.d $f18,R\nl.d $f16,H\nc.le.d $f18,$f16; bc1f L.577\nl.d $f18,R\nl.d $f16,UfThold\nmul.d $f16,$f18,$f16\ns.d $f16,Z\nl.d $f16,One\nl.d $f10,H\nl.d $f8,Z\nmul.d $f18,$f18,$f10\nadd.d $f10,$f16,$f10\nmul.d $f18,$f18,$f10\nadd.d $f18,$f16,$f18\nmul.d $f18,$f8,$f18\ns.d $f18,X\nb L.578\nL.577:\nl.d $f18,UfThold\ns.d $f18,Z\nl.d $f18,One\nl.d $f16,H\nl.d $f10,Z\nmul.d $f8,$f16,$f16\nadd.d $f16,$f18,$f16\nmul.d $f16,$f8,$f16\nadd.d $f18,$f18,$f16\nmul.d $f18,$f10,$f18\ns.d $f18,X\nL.578:\nl.d $f18,X\nl.d $f16,Z\nc.eq.d $f18,$f16; bc1t L.579\nsub.d $f18,$f18,$f16\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1f L.579\nla $4,3\nla $5,L.157\njal BadCond\nla $4,L.581\nl.d $f18,X\nmfc1.d $6,$f18\nl.d $f18,Z\ns.d $f18,16($sp)\njal printf\nl.d $f18,X\nl.d $f16,Z\nsub.d $f18,$f18,$f16\ns.d $f18,Z9\nla $4,L.582\nl.d $f18,Z9\nmfc1.d $6,$f18\njal printf\nla $4,L.583\njal printf\nla $4,L.584\njal printf\nla $4,L.585\njal printf\nla $4,L.586\njal printf\nla $4,L.587\njal printf\nla $4,L.588\njal printf\nla $24,sigfpe\nsw $24,sigsave\nla $4,ovfl_buf\njal setjmp\nbeq $2,$0,L.589\nla $4,L.591\njal printf\nb L.590\nL.589:\nla $4,L.592\nl.d $f18,Half\nl.d $f16,X\nl.d $f10,Z\ndiv.d $f16,$f16,$f10\nsub.d $f16,$f16,$f18\nsub.d $f18,$f16,$f18\nmfc1.d $6,$f18\njal printf\nL.590:\nsw $0,sigsave\nL.579:\nL.572:\nla $4,L.593\nl.d $f18,UfThold\nmfc1.d $6,$f18\nla $24,L.594\nsw $24,16($sp)\njal printf\nla $4,L.595\njal printf\nla $4,L.596\njal printf\nl.d $f18,U1\nmul.d $f16,$f18,$f18\ns.d $f16,Y2\nl.d $f16,Y2\nmul.d $f16,$f16,$f16\ns.d $f16,Y\nl.d $f16,Y\nmul.d $f18,$f16,$f18\ns.d $f18,Y2\nl.d $f18,Y2\nl.d $f16,UfThold\nc.le.d $f18,$f16; bc1f L.597\nl.d $f18,Y\nl.d $f16,E0\nc.le.d $f18,$f16; bc1t L.599\nla $4,2\nla $5,L.157\njal BadCond\nla $24,5\nsw $24,I\nb L.600\nL.599:\nla $4,1\nla $5,L.157\njal BadCond\nla $24,4\nsw $24,I\nL.600:\nla $4,L.601\nlw $5,I\njal printf\nL.597:\nla $24,130\nsw $24,Milestone\nl.d $f12,UfThold\njal log\nmov.d $f18,$f0\ns.d $f18,-144+240($sp)\nl.d $f12,HInvrse\njal log\nl.d $f16,Half\nl.d $f10,TwoForty\nl.d $f8,-144+240($sp)\nmul.d $f10,$f10,$f8\ndiv.d $f18,$f10,$f0\nsub.d $f12,$f16,$f18\njal floor\nneg.d $f18,$f0\nl.d $f16,TwoForty\ndiv.d $f18,$f18,$f16\ns.d $f18,Y\nl.d $f18,Y\nadd.d $f18,$f18,$f18\ns.d $f18,Y2\nla $4,L.602\njal printf\nla $4,L.603\nl.d $f18,HInvrse\nmfc1.d $6,$f18\nl.d $f18,Y\ns.d $f18,16($sp)\njal printf\nla $4,L.604\nl.d $f18,HInvrse\nmfc1.d $6,$f18\nl.d $f18,Y\ns.d $f18,16($sp)\njal printf\nl.d $f12,HInvrse\nl.d $f14,Y2\njal pow\ns.d $f0,V9\nla $4,L.605\nl.d $f18,V9\nmfc1.d $6,$f18\njal printf\nl.d $f18,V9\nl.d $f16,Zero\nc.lt.d $f18,$f16; bc1t L.608\nl.d $f16,Radix\nadd.d $f16,$f16,$f16\nl.d $f10,E9\nadd.d $f16,$f16,$f10\nl.d $f10,UfThold\nmul.d $f16,$f16,$f10\nc.le.d $f18,$f16; bc1t L.606\nL.608:\nla $4,1\nla $5,L.609\njal BadCond\nla $4,L.610\nl.d $f18,UfThold\nmfc1.d $6,$f18\njal printf\nb L.607\nL.606:\nl.d $f18,V9\nl.d $f16,UfThold\nl.d $f10,One\nl.d $f8,E9\nadd.d $f10,$f10,$f8\nmul.d $f16,$f16,$f10\nc.le.d $f18,$f16; bc1f L.611\nla $4,L.613\njal printf\nb L.612\nL.611:\nla $4,2\nla $5,L.609\njal BadCond\nla $4,L.610\nl.d $f18,UfThold\nmfc1.d $6,$f18\njal printf\nL.612:\nL.607:\nla $24,140\nsw $24,Milestone\nla $4,L.44\njal printf\nl.d $f18,Zero\ns.d $f18,X\nla $24,2\nsw $24,I\nl.d $f16,Two\nl.d $f10,Three\nmul.d $f16,$f16,$f10\ns.d $f16,Y\ns.d $f18,Q\nsw $0,N\nL.614:\nl.d $f18,X\ns.d $f18,Z\nlw $24,I\nla $24,1($24)\nsw $24,I\nlw $24,I\nl.d $f18,Y\naddu $24,$24,$24\nmtc1 $24,$f16; cvt.d.w $f16,$f16\ndiv.d $f18,$f18,$f16\ns.d $f18,Y\nl.d $f18,Y\nl.d $f16,Q\nadd.d $f18,$f18,$f16\ns.d $f18,R\nl.d $f18,Z\nl.d $f16,R\nadd.d $f10,$f18,$f16\ns.d $f10,X\nl.d $f10,X\nsub.d $f18,$f18,$f10\nadd.d $f18,$f18,$f16\ns.d $f18,Q\nL.615:\nl.d $f18,X\nl.d $f16,Z\nc.le.d $f18,$f16; bc1f L.614\nl.d $f18,OneAndHalf\nl.d $f16,One\nl.d $f10,Eight\ndiv.d $f16,$f16,$f10\nadd.d $f16,$f18,$f16\nl.d $f10,X\nl.d $f8,ThirtyTwo\nmul.d $f18,$f18,$f8\ndiv.d $f18,$f10,$f18\nadd.d $f18,$f16,$f18\ns.d $f18,Z\nl.d $f18,Z\nmul.d $f18,$f18,$f18\ns.d $f18,X\nl.d $f18,X\nmul.d $f18,$f18,$f18\ns.d $f18,Exp2\nl.d $f18,F9\ns.d $f18,X\nl.d $f18,X\nl.d $f16,U1\nsub.d $f18,$f18,$f16\ns.d $f18,Y\nla $4,L.617\nl.d $f18,Exp2\nmfc1.d $6,$f18\njal printf\nla $24,1\nsw $24,I\nL.618:\nl.d $f18,X\nl.d $f16,BInvrse\nsub.d $f10,$f18,$f16\ns.d $f10,Z\nl.d $f10,One\nadd.d $f8,$f18,$f10\nl.d $f6,Z\nsub.d $f16,$f10,$f16\nsub.d $f16,$f6,$f16\ndiv.d $f16,$f8,$f16\ns.d $f16,Z\nmov.d $f12,$f18\nl.d $f14,Z\njal pow\nl.d $f16,Exp2\nsub.d $f18,$f0,$f16\ns.d $f18,Q\nl.d $f12,Q\njal fabs\nl.d $f16,TwoForty\nl.d $f10,U2\nmul.d $f16,$f16,$f10\nc.le.d $f0,$f16; bc1t L.622\nla $24,1\nsw $24,N\nl.d $f18,BInvrse\nl.d $f16,X\nsub.d $f16,$f16,$f18\nl.d $f10,One\nsub.d $f18,$f10,$f18\nsub.d $f18,$f16,$f18\ns.d $f18,V9\nla $4,2\nla $5,L.624\njal BadCond\nl.d $f12,X\nl.d $f14,Z\njal pow\nmov.d $f18,$f0\nla $4,L.625\nmfc1.d $6,$f18\njal printf\nla $4,L.626\nl.d $f18,V9\nmfc1.d $6,$f18\nl.d $f18,Z\ns.d $f18,16($sp)\njal printf\nla $4,L.627\nl.d $f18,Q\nmfc1.d $6,$f18\njal printf\nla $4,L.628\njal printf\nla $4,L.629\njal printf\nb L.620\nL.622:\nl.d $f18,Y\nl.d $f16,X\nsub.d $f16,$f18,$f16\nl.d $f10,Two\nmul.d $f16,$f16,$f10\nadd.d $f16,$f16,$f18\ns.d $f16,Z\ns.d $f18,X\nl.d $f18,Z\ns.d $f18,Y\nl.d $f18,X\nl.d $f16,F9\nsub.d $f18,$f18,$f16\nl.d $f16,One\nmul.d $f18,$f18,$f18\nadd.d $f18,$f16,$f18\ns.d $f18,Z\nl.d $f18,Z\nl.d $f16,One\nc.le.d $f18,$f16; bc1t L.630\nlw $24,I\nlw $15,NoTrials\nbge $24,$15,L.630\nlw $24,I\nla $24,1($24)\nsw $24,I\nb L.618\nL.630:\nl.d $f18,X\nl.d $f16,One\nc.le.d $f18,$f16; bc1t L.632\nlw $24,N\nbne $24,$0,L.620\nla $4,L.636\njal printf\nb L.620\nL.632:\nl.d $f18,U2\nl.d $f16,One\nadd.d $f16,$f16,$f18\ns.d $f16,X\nadd.d $f18,$f18,$f18\ns.d $f18,Y\nl.d $f18,Y\nl.d $f16,X\nadd.d $f18,$f18,$f16\ns.d $f18,Y\nla $24,1\nsw $24,I\nb L.618\nL.620:\nla $24,150\nsw $24,Milestone\nla $4,L.637\njal printf\nsw $0,N\nl.d $f18,A1\ns.d $f18,Z\nl.d $f12,C\njal log\nmov.d $f18,$f0\ns.d $f18,-152+240($sp)\nl.d $f12,A1\njal log\nl.d $f16,Half\nl.d $f10,-152+240($sp)\ndiv.d $f18,$f10,$f0\nsub.d $f12,$f16,$f18\njal floor\ns.d $f0,Q\nsw $0,Break\nL.638:\nl.d $f18,CInvrse\ns.d $f18,X\nl.d $f12,Z\nl.d $f14,Q\njal pow\ns.d $f0,Y\njal IsYeqX\nl.d $f18,Q\nneg.d $f18,$f18\ns.d $f18,Q\nl.d $f18,C\ns.d $f18,X\nl.d $f12,Z\nl.d $f14,Q\njal pow\ns.d $f0,Y\njal IsYeqX\nl.d $f18,Z\nl.d $f16,One\nc.lt.d $f18,$f16; bc1f L.641\nla $24,1\nsw $24,Break\nb L.642\nL.641:\nl.d $f18,AInvrse\ns.d $f18,Z\nL.642:\nL.639:\nlw $24,Break\nbeq $24,$0,L.638\njal PrintIfNPositive\nlw $24,N\nbne $24,$0,L.643\nla $4,L.645\njal printf\nL.643:\nla $4,L.44\njal printf\nla $24,160\nsw $24,Milestone\njal Pause\nla $4,L.646\njal printf\nla $4,L.647\njal printf\nl.d $f18,CInvrse\nneg.d $f18,$f18\ns.d $f18,Y\nl.d $f18,HInvrse\nl.d $f16,Y\nmul.d $f18,$f18,$f16\ns.d $f18,V9\nla $24,sigfpe\nsw $24,sigsave\nla $4,ovfl_buf\njal setjmp\nbeq $2,$0,L.648\nsw $0,I\nl.d $f18,Y\ns.d $f18,V9\nb L.650\nL.648:\nL.651:\nl.d $f18,Y\ns.d $f18,V\nl.d $f18,V9\ns.d $f18,Y\nl.d $f18,HInvrse\nl.d $f16,Y\nmul.d $f18,$f18,$f16\ns.d $f18,V9\nL.652:\nl.d $f18,V9\nl.d $f16,Y\nc.lt.d $f18,$f16; bc1t L.651\nla $24,1\nsw $24,I\nL.650:\nsw $0,sigsave\nl.d $f18,V9\ns.d $f18,Z\nla $4,L.654\njal printf\nla $4,L.655\nl.d $f18,Y\nmfc1.d $6,$f18\njal printf\nl.d $f18,Y\nneg.d $f16,$f18\ns.d $f16,V9\nl.d $f16,V9\ns.d $f16,V0\nl.d $f16,V\nsub.d $f18,$f16,$f18\nl.d $f10,V0\nadd.d $f16,$f16,$f10\nc.eq.d $f18,$f16; bc1f L.656\nla $4,L.658\njal printf\nb L.657\nL.656:\nla $4,L.659\njal printf\nla $4,3\nla $5,L.660\njal BadCond\nL.657:\nl.d $f18,Z\nl.d $f16,Y\nc.eq.d $f18,$f16; bc1t L.661\nla $4,1\nla $5,L.157\njal BadCond\nla $4,L.663\nl.d $f18,Y\nmfc1.d $6,$f18\nl.d $f18,Z\ns.d $f18,16($sp)\njal printf\nL.661:\nlw $24,I\nbeq $24,$0,L.664\nl.d $f18,V\nl.d $f16,HInvrse\nl.d $f10,U2\nmul.d $f8,$f16,$f10\nsub.d $f8,$f8,$f16\nmul.d $f8,$f18,$f8\ns.d $f8,Y\nl.d $f8,Y\nl.d $f6,One\nsub.d $f16,$f6,$f16\nmul.d $f16,$f16,$f10\nmul.d $f18,$f16,$f18\nadd.d $f18,$f8,$f18\ns.d $f18,Z\nl.d $f18,Z\nl.d $f16,V0\nc.lt.d $f18,$f16; bc1f L.666\nl.d $f18,Z\ns.d $f18,Y\nL.666:\nl.d $f18,Y\nl.d $f16,V0\nc.lt.d $f18,$f16; bc1f L.668\nl.d $f18,Y\ns.d $f18,V\nL.668:\nl.d $f18,V0\nl.d $f16,V\nsub.d $f16,$f18,$f16\nc.lt.d $f16,$f18; bc1f L.665\nl.d $f18,V0\ns.d $f18,V\nb L.665\nL.664:\nl.d $f18,Y\nl.d $f16,HInvrse\nl.d $f10,U2\nmul.d $f8,$f16,$f10\nsub.d $f8,$f8,$f16\nmul.d $f8,$f18,$f8\ns.d $f8,V\nl.d $f8,V\nl.d $f6,One\nsub.d $f16,$f6,$f16\nmul.d $f16,$f16,$f10\nmul.d $f18,$f16,$f18\nadd.d $f18,$f8,$f18\ns.d $f18,V\nL.665:\nla $4,L.672\nl.d $f18,V\nmfc1.d $6,$f18\njal printf\nlw $24,I\nbeq $24,$0,L.673\nla $4,L.675\nl.d $f18,V0\nmfc1.d $6,$f18\njal printf\nb L.674\nL.673:\nla $4,L.676\njal printf\nL.674:\nl.d $f18,V\nl.d $f16,One\nmul.d $f18,$f18,$f16\ns.d $f18,V9\nla $4,L.677\nl.d $f18,V9\nmfc1.d $6,$f18\njal printf\nl.d $f18,V\nl.d $f16,One\ndiv.d $f18,$f18,$f16\ns.d $f18,V9\nla $4,L.678\nl.d $f18,V9\nmfc1.d $6,$f18\njal printf\nla $4,L.679\njal printf\nla $4,L.680\njal printf\nla $24,170\nsw $24,Milestone\nl.d $f18,V\nneg.d $f16,$f18\nc.lt.d $f16,$f18; bc1f L.685\nl.d $f16,V0\nneg.d $f10,$f16\nc.lt.d $f10,$f16; bc1f L.685\nl.d $f16,UfThold\nneg.d $f10,$f16\nc.lt.d $f10,$f18; bc1f L.685\nc.lt.d $f16,$f18; bc1t L.681\nL.685:\nmove $4,$0\nla $5,L.686\njal BadCond\nla $4,L.687\nl.d $f18,V\nmfc1.d $6,$f18\nl.d $f18,V0\ns.d $f18,16($sp)\nl.d $f18,UfThold\ns.d $f18,24($sp)\njal printf\nL.681:\nla $24,175\nsw $24,Milestone\nla $4,L.44\njal printf\nla $24,1\nsw $24,Indx\nL.688:\nlw $24,Indx\nla $15,1\nbeq $24,$15,L.694\nla $15,2\nbeq $24,$15,L.695\nla $15,3\nbeq $24,$15,L.696\nb L.692\nL.694:\nl.d $f18,UfThold\ns.d $f18,Z\nb L.693\nL.695:\nl.d $f18,E0\ns.d $f18,Z\nb L.693\nL.696:\nl.d $f18,PseudoZero\ns.d $f18,Z\nL.692:\nL.693:\nl.d $f18,Z\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1t L.697\nl.d $f12,Z\njal sqrt\ns.d $f0,V9\nl.d $f18,V9\nmul.d $f18,$f18,$f18\ns.d $f18,Y\nl.d $f18,Y\nl.d $f16,One\nl.d $f10,Radix\nl.d $f8,E9\nmul.d $f10,$f10,$f8\nl.d $f8,Z\nsub.d $f6,$f16,$f10\ndiv.d $f6,$f18,$f6\nc.lt.d $f6,$f8; bc1t L.701\nadd.d $f16,$f16,$f10\nmul.d $f16,$f16,$f8\nc.le.d $f18,$f16; bc1t L.699\nL.701:\nl.d $f18,V9\nl.d $f16,U1\nc.le.d $f18,$f16; bc1t L.702\nla $4,1\nla $5,L.157\njal BadCond\nb L.703\nL.702:\nla $4,2\nla $5,L.157\njal BadCond\nL.703:\nla $4,L.704\nl.d $f18,Z\nmfc1.d $6,$f18\njal printf\nla $4,L.705\nl.d $f18,Y\nmfc1.d $6,$f18\njal printf\nL.699:\nL.697:\nL.689:\nlw $24,Indx\nla $24,1($24)\nsw $24,Indx\nlw $24,Indx\nla $15,3\nble $24,$15,L.688\nla $24,180\nsw $24,Milestone\nla $24,1\nsw $24,Indx\nL.706:\nlw $24,Indx\nla $15,1\nbne $24,$15,L.710\nl.d $f18,V\ns.d $f18,Z\nb L.711\nL.710:\nl.d $f18,V0\ns.d $f18,Z\nL.711:\nl.d $f12,Z\njal sqrt\ns.d $f0,V9\nl.d $f18,V9\nl.d $f16,One\nl.d $f10,Radix\nl.d $f8,E9\nmul.d $f10,$f10,$f8\nsub.d $f16,$f16,$f10\nmul.d $f16,$f16,$f18\ns.d $f16,X\nl.d $f16,X\nmul.d $f18,$f18,$f16\ns.d $f18,V9\nl.d $f18,V9\nl.d $f16,Z\nl.d $f10,One\nl.d $f8,Two\nl.d $f6,Radix\nmul.d $f8,$f8,$f6\nl.d $f6,E9\nmul.d $f8,$f8,$f6\nsub.d $f10,$f10,$f8\nmul.d $f10,$f10,$f16\nc.lt.d $f18,$f10; bc1t L.714\nc.le.d $f18,$f16; bc1t L.712\nL.714:\nl.d $f18,V9\ns.d $f18,Y\nl.d $f18,X\nl.d $f16,W\nc.lt.d $f18,$f16; bc1f L.715\nla $4,1\nla $5,L.157\njal BadCond\nb L.716\nL.715:\nla $4,2\nla $5,L.157\njal BadCond\nL.716:\nla $4,L.717\nl.d $f18,Z\nmfc1.d $6,$f18\njal printf\nla $4,L.718\nl.d $f18,Y\nmfc1.d $6,$f18\njal printf\nL.712:\nL.707:\nlw $24,Indx\nla $24,1($24)\nsw $24,Indx\nlw $24,Indx\nla $15,2\nble $24,$15,L.706\nla $24,190\nsw $24,Milestone\njal Pause\nl.d $f18,UfThold\nl.d $f16,V\nmul.d $f18,$f18,$f16\ns.d $f18,X\nl.d $f18,Radix\nmul.d $f18,$f18,$f18\ns.d $f18,Y\nl.d $f18,X\nl.d $f16,Y\nmul.d $f10,$f18,$f16\nl.d $f8,One\nc.lt.d $f10,$f8; bc1t L.721\nc.le.d $f18,$f16; bc1t L.719\nL.721:\nl.d $f18,X\nl.d $f16,Y\nl.d $f10,U1\nmul.d $f8,$f18,$f16\nc.lt.d $f8,$f10; bc1t L.724\ndiv.d $f16,$f16,$f10\nc.le.d $f18,$f16; bc1t L.722\nL.724:\nla $4,2\nla $5,L.725\njal BadCond\nb L.723\nL.722:\nla $4,3\nla $5,L.157\njal BadCond\nL.723:\nla $4,L.726\nl.d $f18,X\nmfc1.d $6,$f18\nla $24,L.727\nsw $24,16($sp)\njal printf\nL.719:\nla $24,200\nsw $24,Milestone\nla $24,1\nsw $24,Indx\nL.728:\nl.d $f18,F9\ns.d $f18,X\nlw $24,Indx\nla $15,2\nblt $24,$15,L.732\nla $15,5\nbgt $24,$15,L.732\nsll $24,$24,2\nlw $24,L.738-8($24)\n.cpadd $24\nj $24\n.rdata\n.align 2\nL.738:\n.gpword L.734\n.gpword L.735\n.gpword L.736\n.gpword L.737\n.text\nL.734:\nl.d $f18,One\nl.d $f16,U2\nadd.d $f18,$f18,$f16\ns.d $f18,X\nb L.733\nL.735:\nl.d $f18,V\ns.d $f18,X\nb L.733\nL.736:\nl.d $f18,UfThold\ns.d $f18,X\nb L.733\nL.737:\nl.d $f18,Radix\ns.d $f18,X\nL.732:\nL.733:\nl.d $f18,X\ns.d $f18,Y\nla $24,sigfpe\nsw $24,sigsave\nla $4,ovfl_buf\njal setjmp\nbeq $2,$0,L.740\nla $4,L.742\nl.d $f18,X\nmfc1.d $6,$f18\njal printf\nb L.741\nL.740:\nl.d $f18,Half\nl.d $f16,Y\nl.d $f10,X\ndiv.d $f16,$f16,$f10\nsub.d $f16,$f16,$f18\nsub.d $f18,$f16,$f18\ns.d $f18,V9\nl.d $f18,V9\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1f L.743\nb L.729\nL.743:\nl.d $f18,V9\nl.d $f16,U1\nneg.d $f16,$f16\nc.eq.d $f18,$f16; bc1f L.745\nlw $24,Indx\nla $15,5\nbge $24,$15,L.745\nla $4,3\nla $5,L.157\njal BadCond\nb L.746\nL.745:\nla $4,1\nla $5,L.157\njal BadCond\nL.746:\nla $4,L.747\nl.d $f18,X\nmfc1.d $6,$f18\njal printf\nla $4,L.748\nl.d $f18,V9\nmfc1.d $6,$f18\njal printf\nL.741:\nsw $0,sigsave\nL.729:\nlw $24,Indx\nla $24,1($24)\nsw $24,Indx\nlw $24,Indx\nla $15,5\nble $24,$15,L.728\nla $24,210\nsw $24,Milestone\nl.d $f18,Zero\ns.d $f18,MyZero\nla $4,L.44\njal printf\nla $4,L.749\njal printf\nla $24,sigfpe\nsw $24,sigsave\nla $4,L.750\njal printf\nla $4,ovfl_buf\njal setjmp\nbne $2,$0,L.751\nla $4,L.753\nl.d $f18,One\nl.d $f16,MyZero\ndiv.d $f18,$f18,$f16\nmfc1.d $6,$f18\njal printf\nL.751:\nsw $0,sigsave\nla $24,sigfpe\nsw $24,sigsave\nla $4,L.754\njal printf\nla $4,ovfl_buf\njal setjmp\nbne $2,$0,L.755\nla $4,L.753\nl.d $f18,Zero\nl.d $f16,MyZero\ndiv.d $f18,$f18,$f16\nmfc1.d $6,$f18\njal printf\nL.755:\nsw $0,sigsave\nla $24,220\nsw $24,Milestone\njal Pause\nla $4,L.44\njal printf\nsw $0,-156+240($sp)\nL.762:\nlw $24,-156+240($sp)\nsll $24,$24,2\nlw $24,ErrCnt($24)\nbeq $24,$0,L.766\nla $4,L.768\nlw $24,-156+240($sp)\nsll $24,$24,2\nlw $5,L.757($24)\nlw $6,ErrCnt($24)\njal printf\nL.766:\nL.763:\nlw $24,-156+240($sp)\nla $24,1($24)\nsw $24,-156+240($sp)\nlw $24,-156+240($sp)\nla $15,4\nblt $24,$15,L.762\nla $4,L.44\njal printf\nlw $24,ErrCnt\nlw $15,ErrCnt+4\naddu $24,$24,$15\nlw $15,ErrCnt+8\naddu $24,$24,$15\nlw $15,ErrCnt+12\naddu $24,$24,$15\nble $24,$0,L.769\nlw $15,ErrCnt\nlw $14,ErrCnt+4\naddu $15,$15,$14\nlw $14,ErrCnt+8\naddu $15,$15,$14\nbne $15,$0,L.774\nlw $15,ErrCnt+12\nble $15,$0,L.774\nla $4,L.779\njal printf\nla $4,L.780\njal printf\nL.774:\nlw $15,ErrCnt\nlw $14,ErrCnt+4\naddu $15,$15,$14\nbne $15,$0,L.781\nlw $15,ErrCnt+8\nble $15,$0,L.781\nla $4,L.785\njal printf\nla $4,L.786\njal printf\nL.781:\nlw $24,ErrCnt\nlw $15,ErrCnt+4\naddu $24,$24,$15\nble $24,$0,L.787\nla $4,L.790\njal printf\nla $4,L.791\njal printf\nL.787:\nlw $24,ErrCnt\nble $24,$0,L.770\nla $4,L.794\njal printf\nla $4,L.795\njal printf\nb L.770\nL.769:\nla $4,L.796\njal printf\nla $24,1\nlw $15,RMult\nbne $15,$24,L.801\nlw $15,RDiv\nbne $15,$24,L.801\nlw $15,RAddSub\nbne $15,$24,L.801\nlw $15,RSqrt\nbeq $15,$24,L.797\nL.801:\nla $4,L.802\njal printf\nb L.798\nL.797:\nl.d $f18,One\nl.d $f16,StickyBit\nc.lt.d $f16,$f18; bc1t L.803\nl.d $f16,Radix\nl.d $f10,Two\nsub.d $f10,$f16,$f10\nl.d $f8,Nine\nsub.d $f16,$f16,$f8\nsub.d $f18,$f16,$f18\nmul.d $f18,$f10,$f18\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1f L.803\nla $4,L.805\njal printf\nla $4,L.806\njal printf\nl.d $f18,Two\nl.d $f16,Radix\nc.eq.d $f16,$f18; bc1f L.807\nl.d $f16,Precision\nl.d $f10,TwentySeven\nl.d $f8,Four\nl.d $f6,Three\nmul.d $f8,$f8,$f6\nmul.d $f18,$f8,$f18\nsub.d $f18,$f16,$f18\nsub.d $f16,$f16,$f10\nsub.d $f16,$f16,$f10\nl.d $f10,One\nadd.d $f16,$f16,$f10\nmul.d $f18,$f18,$f16\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1f L.807\nla $4,L.809\njal printf\nb L.808\nL.807:\nla $4,L.810\njal printf\nL.808:\nlw $24,IEEE\nbeq $24,$0,L.811\nla $4,L.813\njal printf\nb L.812\nL.811:\nla $4,L.814\njal printf\nla $4,L.815\njal printf\nL.812:\nL.803:\nla $4,L.816\njal printf\nL.798:\nL.770:\nlw $24,fpecount\nbeq $24,$0,L.817\nla $4,L.819\nlw $5,fpecount\njal printf\nL.817:\nla $4,L.820\njal printf\nmove $2,$0\nL.6:\nlw $16,32($sp)\nlw $17,36($sp)\nlw $18,40($sp)\nlw $19,44($sp)\nlw $20,48($sp)\nlw $21,52($sp)\nlw $22,56($sp)\nlw $23,60($sp)\nlw $25,64($sp)\nlw $30,68($sp)\nlw $31,72($sp)\naddu $sp,$sp,240\nj $31\n.end main\n.globl Sign\n.text\n.align 2\n.ent Sign\nSign:\n.frame $sp,8,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-8\n.fmask 0xc0000000,-8\ns.d $f30,0($sp)\nl.d $f18,L.7\nc.lt.d $f12,$f18; bc1t L.823\nl.d $f30,L.8\nb L.824\nL.823:\nl.d $f30,L.825\nL.824:\nmov.d $f0,$f30\nL.821:\nl.d $f30,0($sp)\naddu $sp,$sp,8\nj $31\n.end Sign\n.globl Pause\n.text\n.align 2\n.ent Pause\nPause:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nla $4,L.827\nlw $5,Milestone\njal printf\nla $4,L.828\nlw $5,PageNo\njal printf\nlw $24,Milestone\nla $24,1($24)\nsw $24,Milestone\nlw $24,PageNo\nla $24,1($24)\nsw $24,PageNo\nmove $2,$0\nL.826:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end Pause\n.globl TstCond\n.text\n.align 2\n.ent TstCond\nTstCond:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nsw $4,24($sp)\nsw $5,28($sp)\nsw $6,32($sp)\nlw $24,4+24($sp)\nbne $24,$0,L.830\nlw $4,0+24($sp)\nlw $5,8+24($sp)\njal BadCond\nla $4,L.813\njal printf\nL.830:\nmove $2,$0\nL.829:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end TstCond\n.data\n.align 2\nL.833:\n.word L.834\n.word L.835\n.word L.836\n.word L.837\n.globl BadCond\n.text\n.text\n.align 2\n.ent BadCond\nBadCond:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2000000,-8\n.cprestore 16\nsw $30,20($sp)\nsw $31,24($sp)\nmove $30,$4\nsw $5,36($sp)\nsll $24,$30,2\nla $24,ErrCnt($24)\nlw $15,($24)\nla $15,1($15)\nsw $15,($24)\nla $4,L.838\nsll $24,$30,2\nlw $5,L.833($24)\nlw $6,4+32($sp)\njal printf\nmove $2,$0\nL.832:\nlw $25,16($sp)\nlw $30,20($sp)\nlw $31,24($sp)\naddu $sp,$sp,32\nj $31\n.end BadCond\n.globl Random\n.text\n.align 2\n.ent Random\nRandom:\n.frame $sp,40,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-40\n.fmask 0xf0000000,-16\n.mask 0x82000000,-4\ns.d $f28,16($sp)\ns.d $f30,24($sp)\n.cprestore 32\nsw $31,36($sp)\nl.d $f18,Random1\nl.d $f16,Random9\nadd.d $f30,$f18,$f16\nmul.d $f28,$f30,$f30\nmul.d $f28,$f28,$f28\nmul.d $f30,$f30,$f28\nmov.d $f12,$f30\njal floor\nsub.d $f28,$f30,$f0\nl.d $f18,L.840\nmul.d $f18,$f18,$f30\nadd.d $f18,$f28,$f18\ns.d $f18,Random1\nl.d $f0,Random1\nL.839:\nl.d $f28,16($sp)\nl.d $f30,24($sp)\nlw $25,32($sp)\nlw $31,36($sp)\naddu $sp,$sp,40\nj $31\n.end Random\n.globl SqXMinX\n.text\n.align 2\n.ent SqXMinX\nSqXMinX:\n.frame $sp,56,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-56\n.fmask 0xc0000000,-24\n.mask 0x82000000,-12\ns.d $f30,32($sp)\n.cprestore 40\nsw $31,44($sp)\nsw $4,56($sp)\nl.d $f18,X\nl.d $f16,BInvrse\nmul.d $f30,$f18,$f16\nsub.d $f16,$f18,$f30\ns.d $f16,-8+56($sp)\nmul.d $f12,$f18,$f18\njal sqrt\nsub.d $f18,$f0,$f30\nl.d $f16,-8+56($sp)\nsub.d $f18,$f18,$f16\nl.d $f16,OneUlp\ndiv.d $f18,$f18,$f16\ns.d $f18,SqEr\nl.d $f18,SqEr\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1t L.842\nl.d $f18,SqEr\nl.d $f16,MinSqEr\nc.lt.d $f18,$f16; bc1f L.844\nl.d $f18,SqEr\ns.d $f18,MinSqEr\nL.844:\nl.d $f18,SqEr\nl.d $f16,MaxSqEr\nc.le.d $f18,$f16; bc1t L.846\nl.d $f18,SqEr\ns.d $f18,MaxSqEr\nL.846:\nl.d $f18,J\nl.d $f16,L.8\nadd.d $f18,$f18,$f16\ns.d $f18,J\nlw $4,0+56($sp)\nla $5,L.44\njal BadCond\nla $4,L.848\nl.d $f18,X\nmul.d $f16,$f18,$f18\nmfc1.d $6,$f16\ns.d $f18,16($sp)\nl.d $f18,OneUlp\nl.d $f16,SqEr\nmul.d $f18,$f18,$f16\ns.d $f18,24($sp)\njal printf\nla $4,L.849\njal printf\nL.842:\nmove $2,$0\nL.841:\nl.d $f30,32($sp)\nlw $25,40($sp)\nlw $31,44($sp)\naddu $sp,$sp,56\nj $31\n.end SqXMinX\n.globl NewD\n.text\n.align 2\n.ent NewD\nNewD:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nl.d $f18,Z1\nl.d $f16,Q\nmul.d $f18,$f18,$f16\ns.d $f18,X\nl.d $f18,Half\nl.d $f16,X\nl.d $f10,Radix\ndiv.d $f16,$f16,$f10\nsub.d $f12,$f18,$f16\njal floor\nl.d $f16,Radix\nmul.d $f18,$f0,$f16\nl.d $f10,X\nadd.d $f18,$f18,$f10\ns.d $f18,X\nl.d $f18,X\nl.d $f10,Z\nl.d $f8,D\nl.d $f6,Q\nmul.d $f4,$f18,$f10\nsub.d $f6,$f6,$f4\ndiv.d $f6,$f6,$f16\nmul.d $f4,$f18,$f18\ndiv.d $f16,$f8,$f16\nmul.d $f16,$f4,$f16\nadd.d $f16,$f6,$f16\ns.d $f16,Q\nl.d $f16,Two\nmul.d $f18,$f16,$f18\nmul.d $f18,$f18,$f8\nsub.d $f18,$f10,$f18\ns.d $f18,Z\nl.d $f18,Z\nl.d $f16,Zero\nc.le.d $f18,$f16; bc1f L.851\nl.d $f18,Z\nneg.d $f18,$f18\ns.d $f18,Z\nl.d $f18,Z1\nneg.d $f18,$f18\ns.d $f18,Z1\nL.851:\nl.d $f18,Radix\nl.d $f16,D\nmul.d $f18,$f18,$f16\ns.d $f18,D\nmove $2,$0\nL.850:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end NewD\n.globl SR3750\n.text\n.align 2\n.ent SR3750\nSR3750:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nl.d $f18,X\nl.d $f16,Radix\nl.d $f10,Z2\nsub.d $f8,$f18,$f16\nsub.d $f16,$f10,$f16\nc.lt.d $f8,$f16; bc1t L.854\nsub.d $f18,$f18,$f10\nl.d $f16,W\nsub.d $f16,$f16,$f10\nc.le.d $f18,$f16; bc1f L.854\nlw $24,I\nla $24,1($24)\nsw $24,I\nl.d $f18,X\nl.d $f16,D\nmul.d $f12,$f18,$f16\njal sqrt\ns.d $f0,X2\nl.d $f18,Z2\nl.d $f16,Y\nl.d $f10,X2\nsub.d $f10,$f10,$f18\nsub.d $f18,$f16,$f18\nsub.d $f18,$f10,$f18\ns.d $f18,Y2\nl.d $f18,Half\nl.d $f10,X8\nsub.d $f16,$f16,$f18\ndiv.d $f16,$f10,$f16\ns.d $f16,X2\nl.d $f16,X2\nmul.d $f10,$f18,$f16\nmul.d $f10,$f10,$f16\nsub.d $f16,$f16,$f10\ns.d $f16,X2\nl.d $f16,Y2\nadd.d $f16,$f16,$f18\nl.d $f10,X2\nsub.d $f18,$f18,$f10\nadd.d $f18,$f16,$f18\ns.d $f18,SqEr\nl.d $f18,SqEr\nl.d $f16,MinSqEr\nc.lt.d $f18,$f16; bc1f L.856\nl.d $f18,SqEr\ns.d $f18,MinSqEr\nL.856:\nl.d $f18,Y2\nl.d $f16,X2\nsub.d $f18,$f18,$f16\ns.d $f18,SqEr\nl.d $f18,SqEr\nl.d $f16,MaxSqEr\nc.le.d $f18,$f16; bc1t L.858\nl.d $f18,SqEr\ns.d $f18,MaxSqEr\nL.858:\nL.854:\nmove $2,$0\nL.853:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end SR3750\n.globl IsYeqX\n.text\n.align 2\n.ent IsYeqX\nIsYeqX:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0x82000000,-4\n.cprestore 24\nsw $31,28($sp)\nl.d $f18,Y\nl.d $f16,X\nc.eq.d $f18,$f16; bc1t L.861\nlw $24,N\nbgt $24,$0,L.863\nl.d $f18,Zero\nl.d $f16,Z\nc.eq.d $f16,$f18; bc1f L.865\nl.d $f16,Q\nc.le.d $f16,$f18; bc1f L.865\nla $4,L.867\njal printf\nb L.866\nL.865:\nla $4,2\nla $5,L.868\njal BadCond\nL.866:\nla $4,L.869\nl.d $f18,Z\nmfc1.d $6,$f18\nl.d $f18,Q\ns.d $f18,16($sp)\njal printf\nla $4,L.870\nl.d $f18,Y\nmfc1.d $6,$f18\njal printf\nla $4,L.871\nl.d $f18,X\nmfc1.d $6,$f18\njal printf\nla $4,L.872\nl.d $f18,Y\nl.d $f16,X\nsub.d $f18,$f18,$f16\nmfc1.d $6,$f18\njal printf\nL.863:\nlw $24,N\nla $24,1($24)\nsw $24,N\nL.861:\nmove $2,$0\nL.860:\nlw $25,24($sp)\nlw $31,28($sp)\naddu $sp,$sp,32\nj $31\n.end IsYeqX\n.globl SR3980\n.text\n.align 2\n.ent SR3980\nSR3980:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nL.874:\nlw $24,I\nmtc1 $24,$f18; cvt.d.w $f18,$f18\ns.d $f18,Q\nl.d $f12,Z\nl.d $f14,Q\njal pow\ns.d $f0,Y\njal IsYeqX\nlw $24,I\nla $24,1($24)\nsw $24,I\nlw $15,M\nble $24,$15,L.877\nb L.876\nL.877:\nl.d $f18,Z\nl.d $f16,X\nmul.d $f18,$f18,$f16\ns.d $f18,X\nL.875:\nl.d $f18,X\nl.d $f16,W\nc.lt.d $f18,$f16; bc1t L.874\nL.876:\nmove $2,$0\nL.873:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end SR3980\n.globl PrintIfNPositive\n.text\n.align 2\n.ent PrintIfNPositive\nPrintIfNPositive:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nlw $24,N\nble $24,$0,L.880\nla $4,L.882\nlw $5,N\njal printf\nL.880:\nmove $2,$0\nL.879:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end PrintIfNPositive\n.globl TstPtUf\n.text\n.align 2\n.ent TstPtUf\nTstPtUf:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nsw $0,N\nl.d $f18,Z\nl.d $f16,Zero\nc.eq.d $f18,$f16; bc1t L.884\nla $4,L.886\njal printf\nla $4,L.887\njal printf\nla $24,sigfpe\nsw $24,sigsave\nla $4,ovfl_buf\njal setjmp\nbeq $2,$0,L.888\nb L.890\nL.888:\nl.d $f18,Z\nadd.d $f16,$f18,$f18\ndiv.d $f18,$f16,$f18\ns.d $f18,Q9\nla $4,L.891\nl.d $f18,Q9\nmfc1.d $6,$f18\njal printf\nl.d $f18,Q9\nl.d $f16,Two\nsub.d $f12,$f18,$f16\njal fabs\nl.d $f16,Radix\nl.d $f10,U2\nmul.d $f16,$f16,$f10\nc.lt.d $f0,$f16; bc1f L.892\nla $4,L.894\njal printf\nla $4,L.895\njal printf\nb L.893\nL.892:\nl.d $f18,Q9\nl.d $f16,One\nc.lt.d $f18,$f16; bc1t L.898\nl.d $f16,Two\nc.le.d $f18,$f16; bc1t L.896\nL.898:\nL.890:\nla $24,1\nsw $24,N\nlw $24,ErrCnt+4\nla $24,1($24)\nsw $24,ErrCnt+4\nla $4,L.901\njal printf\nb L.897\nL.896:\nla $24,1\nsw $24,N\nlw $24,ErrCnt+8\nla $24,1($24)\nsw $24,ErrCnt+8\nla $4,L.904\njal printf\nL.897:\nL.893:\nsw $0,sigsave\nl.d $f18,Z\nl.d $f16,One\nmul.d $f10,$f18,$f16\ns.d $f10,V9\nl.d $f10,V9\ns.d $f10,Random1\nmul.d $f10,$f16,$f18\ns.d $f10,V9\nl.d $f10,V9\ns.d $f10,Random2\ndiv.d $f18,$f18,$f16\ns.d $f18,V9\nl.d $f18,Z\nl.d $f16,Random1\nc.eq.d $f18,$f16; bc1f L.905\nl.d $f16,Random2\nc.eq.d $f18,$f16; bc1f L.905\nl.d $f16,V9\nc.eq.d $f18,$f16; bc1f L.905\nlw $24,N\nble $24,$0,L.906\njal Pause\nb L.906\nL.905:\nla $24,1\nsw $24,N\nla $4,2\nla $5,L.909\njal BadCond\nla $4,L.910\nl.d $f18,Z\nmfc1.d $6,$f18\njal printf\nl.d $f18,Z\nl.d $f16,Random1\nc.eq.d $f18,$f16; bc1t L.911\nla $4,L.913\nl.d $f18,Random1\nmfc1.d $6,$f18\njal printf\nL.911:\nl.d $f18,Random2\nl.d $f16,Z\nc.eq.d $f16,$f18; bc1t L.914\nl.d $f16,Random1\nc.eq.d $f18,$f16; bc1t L.914\nla $4,L.916\nl.d $f18,Random2\nmfc1.d $6,$f18\njal printf\nL.914:\nl.d $f18,Z\nl.d $f16,V9\nc.eq.d $f18,$f16; bc1t L.917\nla $4,L.919\nl.d $f18,V9\nmfc1.d $6,$f18\njal printf\nL.917:\nl.d $f18,Random2\nl.d $f16,Random1\nc.eq.d $f18,$f16; bc1t L.920\nlw $24,ErrCnt+8\nla $24,1($24)\nsw $24,ErrCnt+8\nla $4,2\nla $5,L.924\njal BadCond\nla $4,L.925\nl.d $f18,Random2\nmfc1.d $6,$f18\njal printf\nla $4,L.926\nl.d $f18,Random1\nmfc1.d $6,$f18\njal printf\nL.920:\njal Pause\nL.906:\nL.884:\nmove $2,$0\nL.883:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end TstPtUf\n.globl notify\n.text\n.align 2\n.ent notify\nnotify:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nsw $4,24($sp)\nla $4,L.928\nlw $5,0+24($sp)\njal printf\nla $4,L.929\njal printf\nmove $2,$0\nL.927:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end notify\n.globl msglist\n.text\n.align 2\n.ent msglist\nmsglist:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2000000,-8\n.cprestore 16\nsw $30,20($sp)\nsw $31,24($sp)\nmove $30,$4\nb L.932\nL.931:\nla $4,L.934\nmove $24,$30\nla $30,4($24)\nlw $5,($24)\njal printf\nL.932:\nlw $24,($30)\nbne $24,$0,L.931\nmove $2,$0\nL.930:\nlw $25,16($sp)\nlw $30,20($sp)\nlw $31,24($sp)\naddu $sp,$sp,32\nj $31\n.end msglist\n.data\n.align 2\nL.936:\n.word L.937\n.word L.938\n.word L.939\n.word L.940\n.word L.941\n.word L.942\n.word L.943\n.word L.944\n.word L.945\n.word 0x0\n.globl Instructions\n.text\n.text\n.align 2\n.ent Instructions\nInstructions:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nla $4,L.936\njal msglist\nmove $2,$0\nL.935:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end Instructions\n.data\n.align 2\nL.947:\n.word L.948\n.word L.949\n.word L.950\n.word L.951\n.word L.952\n.word L.953\n.word L.954\n.word L.955\n.word L.956\n.word L.957\n.word L.958\n.word L.959\n.word L.960\n.word L.961\n.word 0x0\n.globl Heading\n.text\n.text\n.align 2\n.ent Heading\nHeading:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nla $4,L.947\njal msglist\nmove $2,$0\nL.946:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end Heading\n.data\n.align 2\nL.963:\n.word L.964\n.word L.965\n.word L.966\n.word L.967\n.word L.968\n.word L.969\n.word L.970\n.word L.971\n.word L.972\n.word L.973\n.word L.974\n.word L.975\n.word L.976\n.word L.977\n.word L.978\n.word L.979\n.word L.980\n.word L.981\n.word L.982\n.word 0x0\n.globl Characteristics\n.text\n.text\n.align 2\n.ent Characteristics\nCharacteristics:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nla $4,L.963\njal msglist\nmove $2,$0\nL.962:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end Characteristics\n.data\n.align 2\nL.984:\n.word L.985\n.word L.986\n.word L.987\n.word L.988\n.word L.989\n.word L.990\n.word L.991\n.word L.992\n.word L.993\n.word L.994\n.word L.995\n.word L.996\n.word L.997\n.word L.998\n.word L.999\n.word L.1000\n.word L.1001\n.word 0x0\n.globl History\n.text\n.text\n.align 2\n.ent History\nHistory:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nla $4,L.984\njal msglist\nmove $2,$0\nL.983:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end History\n.globl pow\n.text\n.align 2\n.ent pow\npow:\n.frame $sp,72,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-72\n.fmask 0xfc000000,-40\n.mask 0xc2800000,-20\ns.d $f26,16($sp)\ns.d $f28,24($sp)\ns.d $f30,32($sp)\nsw $23,40($sp)\n.cprestore 44\nsw $30,48($sp)\nsw $31,52($sp)\nmov.d $f30,$f12\nmov.d $f28,$f14\nmove $23,$0\nsw $0,-8+72($sp)\nl.d $f18,L.7\nc.eq.d $f28,$f18; bc1f L.1003\nl.d $f0,L.8\nb L.1002\nL.1003:\nl.d $f18,L.1008\nc.lt.d $f28,$f18; bc1t L.1007\nl.d $f18,L.1009\nc.le.d $f28,$f18; bc1t L.1005\nL.1007:\nl.d $f18,L.825\nc.eq.d $f30,$f18; bc1t L.1005\nmov.d $f12,$f30\njal log\nmov.d $f18,$f0\nmul.d $f12,$f28,$f18\njal exp\nmov.d $f18,$f0\nb L.1002\nL.1005:\nl.d $f18,L.7\nc.lt.d $f28,$f18; bc1f L.1010\nneg.d $f28,$f28\nla $24,1\nsw $24,-8+72($sp)\nL.1010:\nmov.d $f12,$f28\nla $6,-16+72($sp)\njal modf\nmov.d $f28,$f0\nl.d $f18,L.7\nc.eq.d $f28,$f18; bc1t L.1012\nmov.d $f12,$f30\njal log\nmov.d $f18,$f0\nmul.d $f12,$f28,$f18\njal exp\nmov.d $f26,$f0\nb L.1013\nL.1012:\nl.d $f26,L.8\nL.1013:\nmov.d $f12,$f30\nla $6,-4+72($sp)\njal frexp\nmov.d $f30,$f0\nl.d $f18,-16+72($sp)\ntrunc.w.d $f2,$f18,$24; mfc1 $24,$f2\nmove $30,$24\nbeq $24,$0,L.1014\nL.1016:\nand $24,$30,1\nbeq $24,$0,L.1020\nmul.d $f26,$f26,$f30\nlw $24,-4+72($sp)\naddu $23,$23,$24\nL.1020:\nsra $24,$30,1\nmove $30,$24\nbne $24,$0,L.1022\nb L.1018\nL.1022:\nmul.d $f30,$f30,$f30\nlw $24,-4+72($sp)\nsll $24,$24,1\nsw $24,-4+72($sp)\nl.d $f18,L.1026\nc.lt.d $f30,$f18; bc1f L.1016\nl.d $f18,L.1027\nmul.d $f30,$f18,$f30\nlw $24,-4+72($sp)\nsubu $24,$24,1\nsw $24,-4+72($sp)\nb L.1016\nL.1018:\nL.1014:\nlw $24,-8+72($sp)\nbeq $24,$0,L.1028\nl.d $f18,L.8\ndiv.d $f26,$f18,$f26\nnegu $23,$23\nL.1028:\nmov.d $f12,$f26\nmove $6,$23\njal ldexp\nmov.d $f18,$f0\nL.1002:\nl.d $f26,16($sp)\nl.d $f28,24($sp)\nl.d $f30,32($sp)\nlw $23,40($sp)\nlw $25,44($sp)\nlw $30,48($sp)\nlw $31,52($sp)\naddu $sp,$sp,72\nj $31\n.end pow\n.globl UfNGrad\n.comm UfNGrad,4\n.globl SqRWrng\n.comm SqRWrng,4\n.globl IEEE\n.comm IEEE,4\n.globl Anomaly\n.comm Anomaly,4\n.globl Monot\n.comm Monot,4\n.globl NotMonot\n.comm NotMonot,4\n.globl Done\n.comm Done,4\n.globl Break\n.comm Break,4\n.globl RSqrt\n.comm RSqrt,4\n.globl RAddSub\n.comm RAddSub,4\n.globl RDiv\n.comm RDiv,4\n.globl RMult\n.comm RMult,4\n.globl GAddSub\n.comm GAddSub,4\n.globl GDiv\n.comm GDiv,4\n.globl GMult\n.comm GMult,4\n.globl N1\n.comm N1,4\n.globl N\n.comm N,4\n.globl M\n.comm M,4\n.globl PageNo\n.comm PageNo,4\n.globl Milestone\n.comm Milestone,4\n.globl fpecount\n.comm fpecount,4\n.globl ErrCnt\n.comm ErrCnt,16\n.globl Z9\n.comm Z9,8\n.globl Z2\n.comm Z2,8\n.globl Z1\n.comm Z1,8\n.globl PseudoZero\n.comm PseudoZero,8\n.globl Z\n.comm Z,8\n.globl Random2\n.comm Random2,8\n.globl Y2\n.comm Y2,8\n.globl Y1\n.comm Y1,8\n.globl Y\n.comm Y,8\n.globl Random1\n.comm Random1,8\n.globl X8\n.comm X8,8\n.globl X2\n.comm X2,8\n.globl X1\n.comm X1,8\n.globl X\n.comm X,8\n.globl W\n.comm W,8\n.globl V9\n.comm V9,8\n.globl V0\n.comm V0,8\n.globl V\n.comm V,8\n.globl U2\n.comm U2,8\n.globl U1\n.comm U1,8\n.globl UfThold\n.comm UfThold,8\n.globl OneUlp\n.comm OneUlp,8\n.globl S\n.comm S,8\n.globl Underflow\n.comm Underflow,8\n.globl T\n.comm T,8\n.globl Random9\n.comm Random9,8\n.globl R\n.comm R,8\n.globl Q9\n.comm Q9,8\n.globl Q\n.comm Q,8\n.globl Precision\n.comm Precision,8\n.globl MyZero\n.comm MyZero,8\n.globl J\n.comm J,8\n.globl StickyBit\n.comm StickyBit,8\n.globl I\n.comm I,4\n.globl HInvrse\n.comm HInvrse,8\n.globl H\n.comm H,8\n.globl F9\n.comm F9,8\n.globl F6\n.comm F6,8\n.globl Third\n.comm Third,8\n.globl E9\n.comm E9,8\n.globl MaxSqEr\n.comm MaxSqEr,8\n.globl SqEr\n.comm SqEr,8\n.globl MinSqEr\n.comm MinSqEr,8\n.globl E3\n.comm E3,8\n.globl Exp2\n.comm Exp2,8\n.globl E1\n.comm E1,8\n.globl E0\n.comm E0,8\n.globl FourD\n.comm FourD,8\n.globl D\n.comm D,8\n.globl CInvrse\n.comm CInvrse,8\n.globl C\n.comm C,8\n.globl A1\n.comm A1,8\n.globl AInvrse\n.comm AInvrse,8\n.globl ch\n.comm ch,8\n.globl Indx\n.comm Indx,4\n.globl BMinusU2\n.comm BMinusU2,8\n.globl RadixD2\n.comm RadixD2,8\n.globl BInvrse\n.comm BInvrse,8\n.globl Radix\n.comm Radix,8\n.globl sigsave\n.comm sigsave,4\n.globl ovfl_buf\n.comm ovfl_buf,112\n.extern _iob 0\n.rdata\n.align 3\nL.1027:\n.word 0x40000000\n.word 0x0\n.align 3\nL.1026:\n.word 0x3fe00000\n.word 0x0\n.align 3\nL.1009:\n.word 0x40913000\n.word 0x0\n.align 3\nL.1008:\n.word 0xc0913000\n.word 0x0\n.align 0\nL.1001:\n.byte 115\n.byte 101\n.byte 101\n.byte 32\n.byte 115\n.byte 111\n.byte 117\n.byte 114\n.byte 99\n.byte 101\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 109\n.byte 111\n.byte 114\n.byte 101\n.byte 32\n.byte 104\n.byte 105\n.byte 115\n.byte 116\n.byte 111\n.byte 114\n.byte 121\n.byte 46\n.byte 0\n.align 0\nL.1000:\n.byte 66\n.byte 65\n.byte 83\n.byte 73\n.byte 67\n.byte 32\n.byte 118\n.byte 101\n.byte 114\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 40\n.byte 67\n.byte 41\n.byte 32\n.byte 49\n.byte 57\n.byte 56\n.byte 51\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 80\n.byte 114\n.byte 111\n.byte 102\n.byte 46\n.byte 32\n.byte 87\n.byte 46\n.byte 32\n.byte 77\n.byte 46\n.byte 32\n.byte 75\n.byte 97\n.byte 104\n.byte 97\n.byte 110\n.byte 59\n.byte 0\n.align 0\nL.999:\n.byte 97\n.byte 115\n.byte 32\n.byte 117\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 99\n.byte 101\n.byte 114\n.byte 116\n.byte 97\n.byte 105\n.byte 110\n.byte 32\n.byte 101\n.byte 97\n.byte 114\n.byte 108\n.byte 121\n.byte 32\n.byte 87\n.byte 65\n.byte 78\n.byte 71\n.byte 32\n.byte 109\n.byte 97\n.byte 99\n.byte 104\n.byte 105\n.byte 110\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.998:\n.byte 102\n.byte 108\n.byte 111\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 45\n.byte 112\n.byte 111\n.byte 105\n.byte 110\n.byte 116\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 115\n.byte 44\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 32\n.byte 97\n.byte 108\n.byte 115\n.byte 111\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 111\n.byte 119\n.byte 115\n.byte 32\n.byte 108\n.byte 111\n.byte 103\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 105\n.byte 99\n.byte 32\n.byte 101\n.byte 110\n.byte 99\n.byte 111\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 0\n.align 0\nL.997:\n.byte 10\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 98\n.byte 97\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 117\n.byte 112\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 118\n.byte 101\n.byte 110\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 114\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 114\n.byte 101\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 101\n.byte 110\n.byte 116\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 0\n.align 0\nL.996:\n.byte 111\n.byte 102\n.byte 32\n.byte 112\n.byte 97\n.byte 116\n.byte 104\n.byte 111\n.byte 108\n.byte 111\n.byte 103\n.byte 105\n.byte 101\n.byte 115\n.byte 44\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 115\n.byte 97\n.byte 121\n.byte 32\n.byte 104\n.byte 111\n.byte 119\n.byte 32\n.byte 119\n.byte 101\n.byte 108\n.byte 108\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 109\n.byte 112\n.byte 108\n.byte 101\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 0\n.align 0\nL.995:\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 44\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 116\n.byte 114\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 112\n.byte 101\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 97\n.byte 32\n.byte 119\n.byte 105\n.byte 100\n.byte 101\n.byte 114\n.byte 32\n.byte 118\n.byte 97\n.byte 114\n.byte 105\n.byte 101\n.byte 116\n.byte 121\n.byte 0\n.align 0\nL.994:\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 44\n.byte 32\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 114\n.byte 97\n.byte 110\n.byte 103\n.byte 101\n.byte 32\n.byte 40\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 47\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 115\n.byte 41\n.byte 0\n.align 0\nL.993:\n.byte 87\n.byte 46\n.byte 32\n.byte 74\n.byte 46\n.byte 32\n.byte 67\n.byte 111\n.byte 100\n.byte 121\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 87\n.byte 46\n.byte 32\n.byte 87\n.byte 97\n.byte 105\n.byte 116\n.byte 101\n.byte 46\n.byte 32\n.byte 65\n.byte 108\n.byte 116\n.byte 104\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 32\n.byte 98\n.byte 111\n.byte 116\n.byte 104\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 115\n.byte 32\n.byte 116\n.byte 114\n.byte 121\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 0\n.align 0\nL.992:\n.byte 98\n.byte 111\n.byte 111\n.byte 107\n.byte 32\n.byte 32\n.byte 96\n.byte 83\n.byte 111\n.byte 102\n.byte 116\n.byte 119\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 77\n.byte 97\n.byte 110\n.byte 117\n.byte 97\n.byte 108\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 69\n.byte 108\n.byte 101\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 97\n.byte 114\n.byte 121\n.byte 32\n.byte 70\n.byte 117\n.byte 110\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 39\n.byte 32\n.byte 40\n.byte 49\n.byte 57\n.byte 56\n.byte 48\n.byte 41\n.byte 32\n.byte 98\n.byte 121\n.byte 0\n.align 0\nL.991:\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 99\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 100\n.byte 32\n.byte 96\n.byte 77\n.byte 65\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 39\n.byte 44\n.byte 32\n.byte 119\n.byte 104\n.byte 105\n.byte 99\n.byte 104\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 101\n.byte 110\n.byte 100\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 0\n.align 0\nL.990:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 99\n.byte 97\n.byte 112\n.byte 97\n.byte 98\n.byte 105\n.byte 108\n.byte 105\n.byte 116\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 103\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 121\n.byte 111\n.byte 110\n.byte 100\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 101\n.byte 97\n.byte 114\n.byte 108\n.byte 105\n.byte 101\n.byte 114\n.byte 0\n.align 0\nL.989:\n.byte 70\n.byte 97\n.byte 105\n.byte 108\n.byte 117\n.byte 114\n.byte 101\n.byte 115\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 115\n.byte 101\n.byte 113\n.byte 117\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.988:\n.byte 32\n.byte 32\n.byte 32\n.byte 70\n.byte 65\n.byte 73\n.byte 76\n.byte 85\n.byte 82\n.byte 69\n.byte 115\n.byte 44\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 32\n.byte 50\n.byte 43\n.byte 50\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 53\n.byte 32\n.byte 46\n.byte 0\n.align 0\nL.987:\n.byte 32\n.byte 32\n.byte 32\n.byte 83\n.byte 101\n.byte 114\n.byte 105\n.byte 111\n.byte 117\n.byte 115\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 115\n.byte 44\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 97\n.byte 32\n.byte 103\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 44\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 0\n.align 0\nL.986:\n.byte 32\n.byte 32\n.byte 32\n.byte 70\n.byte 76\n.byte 65\n.byte 87\n.byte 115\n.byte 44\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 97\n.byte 32\n.byte 115\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 121\n.byte 32\n.byte 98\n.byte 105\n.byte 116\n.byte 44\n.byte 0\n.align 0\nL.985:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 97\n.byte 116\n.byte 116\n.byte 101\n.byte 109\n.byte 112\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 114\n.byte 105\n.byte 109\n.byte 105\n.byte 110\n.byte 97\n.byte 116\n.byte 101\n.byte 32\n.byte 97\n.byte 109\n.byte 111\n.byte 110\n.byte 103\n.byte 0\n.align 0\nL.982:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 68\n.byte 101\n.byte 99\n.byte 105\n.byte 109\n.byte 97\n.byte 108\n.byte 45\n.byte 66\n.byte 105\n.byte 110\n.byte 97\n.byte 114\n.byte 121\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 118\n.byte 101\n.byte 114\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 32\n.byte 89\n.byte 69\n.byte 84\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 97\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 97\n.byte 99\n.byte 121\n.byte 46\n.byte 0\n.align 0\nL.981:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 69\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 45\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 101\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 101\n.byte 120\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 101\n.byte 118\n.byte 101\n.byte 97\n.byte 108\n.byte 101\n.byte 100\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 32\n.byte 89\n.byte 69\n.byte 84\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 0\n.align 0\nL.980:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 83\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 32\n.byte 32\n.byte 89\n.byte 94\n.byte 88\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 0\n.align 0\nL.979:\n.byte 9\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 116\n.byte 97\n.byte 109\n.byte 105\n.byte 110\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 112\n.byte 115\n.byte 101\n.byte 117\n.byte 100\n.byte 111\n.byte 45\n.byte 122\n.byte 101\n.byte 114\n.byte 111\n.byte 115\n.byte 46\n.byte 0\n.align 0\nL.978:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 99\n.byte 104\n.byte 101\n.byte 99\n.byte 107\n.byte 101\n.byte 100\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 115\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 110\n.byte 99\n.byte 121\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 0\nL.977:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 86\n.byte 48\n.byte 32\n.byte 32\n.byte 116\n.byte 101\n.byte 108\n.byte 108\n.byte 115\n.byte 44\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 108\n.byte 121\n.byte 44\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 32\n.byte 73\n.byte 110\n.byte 102\n.byte 105\n.byte 110\n.byte 105\n.byte 116\n.byte 121\n.byte 32\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 114\n.byte 101\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 101\n.byte 110\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 0\n.align 0\nL.976:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 86\n.byte 32\n.byte 61\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 44\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 108\n.byte 121\n.byte 46\n.byte 0\n.align 0\nL.975:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 69\n.byte 48\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 80\n.byte 115\n.byte 101\n.byte 117\n.byte 100\n.byte 111\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 116\n.byte 101\n.byte 108\n.byte 108\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 98\n.byte 114\n.byte 117\n.byte 112\n.byte 116\n.byte 44\n.byte 32\n.byte 103\n.byte 114\n.byte 97\n.byte 100\n.byte 117\n.byte 97\n.byte 108\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 102\n.byte 117\n.byte 122\n.byte 122\n.byte 121\n.byte 46\n.byte 0\n.align 0\nL.974:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 84\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 61\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 46\n.byte 0\n.align 0\nL.973:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 87\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 97\n.byte 32\n.byte 83\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 121\n.byte 32\n.byte 66\n.byte 105\n.byte 116\n.byte 32\n.byte 117\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 46\n.byte 0\n.align 0\nL.972:\n.byte 9\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 46\n.byte 44\n.byte 32\n.byte 68\n.byte 105\n.byte 118\n.byte 46\n.byte 44\n.byte 32\n.byte 65\n.byte 100\n.byte 100\n.byte 47\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 46\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 83\n.byte 113\n.byte 114\n.byte 116\n.byte 46\n.byte 0\n.align 0\nL.971:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 87\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 44\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 115\n.byte 111\n.byte 109\n.byte 101\n.byte 116\n.byte 104\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 0\n.align 0\nL.970:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 65\n.byte 100\n.byte 101\n.byte 113\n.byte 117\n.byte 97\n.byte 99\n.byte 121\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 103\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 46\n.byte 44\n.byte 32\n.byte 68\n.byte 105\n.byte 118\n.byte 46\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 46\n.byte 0\n.align 0\nL.969:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 85\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 49\n.byte 47\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 94\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 61\n.byte 32\n.byte 79\n.byte 110\n.byte 101\n.byte 32\n.byte 85\n.byte 108\n.byte 112\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 108\n.byte 105\n.byte 116\n.byte 116\n.byte 108\n.byte 101\n.byte 32\n.byte 108\n.byte 101\n.byte 115\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 110\n.byte 32\n.byte 49\n.byte 46\n.byte 48\n.byte 32\n.byte 46\n.byte 0\n.align 0\nL.968:\n.byte 9\n.byte 40\n.byte 79\n.byte 110\n.byte 101\n.byte 85\n.byte 108\n.byte 112\n.byte 110\n.byte 105\n.byte 116\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 76\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 80\n.byte 108\n.byte 97\n.byte 99\n.byte 101\n.byte 41\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 49\n.byte 46\n.byte 48\n.byte 48\n.byte 48\n.byte 120\n.byte 120\n.byte 120\n.byte 32\n.byte 46\n.byte 0\n.align 0\nL.967:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 85\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 47\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 94\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 61\n.byte 32\n.byte 79\n.byte 110\n.byte 101\n.byte 32\n.byte 85\n.byte 108\n.byte 112\n.byte 0\n.align 0\nL.966:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 61\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 105\n.byte 102\n.byte 105\n.byte 99\n.byte 97\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 99\n.byte 97\n.byte 114\n.byte 114\n.byte 105\n.byte 101\n.byte 100\n.byte 46\n.byte 0\n.align 0\nL.965:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 49\n.byte 44\n.byte 32\n.byte 50\n.byte 44\n.byte 32\n.byte 52\n.byte 44\n.byte 32\n.byte 56\n.byte 44\n.byte 32\n.byte 49\n.byte 48\n.byte 44\n.byte 32\n.byte 49\n.byte 54\n.byte 44\n.byte 32\n.byte 49\n.byte 48\n.byte 48\n.byte 44\n.byte 32\n.byte 50\n.byte 53\n.byte 54\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 0\n.align 0\nL.964:\n.byte 82\n.byte 117\n.byte 110\n.byte 110\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 114\n.byte 101\n.byte 118\n.byte 101\n.byte 97\n.byte 108\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 115\n.byte 101\n.byte 32\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 101\n.byte 114\n.byte 105\n.byte 115\n.byte 116\n.byte 105\n.byte 99\n.byte 115\n.byte 58\n.byte 0\n.align 0\nL.961:\n.byte 9\n.byte 79\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 114\n.byte 101\n.byte 108\n.byte 101\n.byte 118\n.byte 97\n.byte 110\n.byte 116\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 105\n.byte 108\n.byte 101\n.byte 114\n.byte 32\n.byte 111\n.byte 112\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 58\n.byte 0\n.align 0\nL.960:\n.byte 9\n.byte 79\n.byte 112\n.byte 116\n.byte 105\n.byte 109\n.byte 105\n.byte 122\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 108\n.byte 101\n.byte 118\n.byte 101\n.byte 108\n.byte 58\n.byte 10\n.byte 0\n.align 0\nL.959:\n.byte 9\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 105\n.byte 108\n.byte 101\n.byte 114\n.byte 58\n.byte 10\n.byte 0\n.align 0\nL.958:\n.byte 9\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 114\n.byte 58\n.byte 10\n.byte 0\n.align 0\nL.957:\n.byte 9\n.byte 86\n.byte 101\n.byte 114\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 58\n.byte 9\n.byte 49\n.byte 48\n.byte 32\n.byte 70\n.byte 101\n.byte 98\n.byte 114\n.byte 117\n.byte 97\n.byte 114\n.byte 121\n.byte 32\n.byte 49\n.byte 57\n.byte 56\n.byte 57\n.byte 59\n.byte 0\n.align 0\nL.956:\n.byte 9\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 58\n.byte 9\n.byte 100\n.byte 111\n.byte 117\n.byte 98\n.byte 108\n.byte 101\n.byte 59\n.byte 0\n.align 0\nL.955:\n.byte 73\n.byte 110\n.byte 32\n.byte 100\n.byte 111\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 115\n.byte 111\n.byte 44\n.byte 32\n.byte 112\n.byte 108\n.byte 101\n.byte 97\n.byte 115\n.byte 101\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 108\n.byte 117\n.byte 100\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 102\n.byte 111\n.byte 108\n.byte 108\n.byte 111\n.byte 119\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 105\n.byte 110\n.byte 102\n.byte 111\n.byte 114\n.byte 109\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 58\n.byte 0\n.align 0\nL.954:\n.byte 9\n.byte 83\n.byte 97\n.byte 110\n.byte 32\n.byte 70\n.byte 114\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 44\n.byte 32\n.byte 67\n.byte 65\n.byte 32\n.byte 57\n.byte 52\n.byte 49\n.byte 52\n.byte 51\n.byte 45\n.byte 48\n.byte 55\n.byte 48\n.byte 52\n.byte 44\n.byte 32\n.byte 85\n.byte 83\n.byte 65\n.byte 10\n.byte 0\n.align 0\nL.953:\n.byte 9\n.byte 85\n.byte 110\n.byte 105\n.byte 118\n.byte 101\n.byte 114\n.byte 115\n.byte 105\n.byte 116\n.byte 121\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 67\n.byte 97\n.byte 108\n.byte 105\n.byte 102\n.byte 111\n.byte 114\n.byte 110\n.byte 105\n.byte 97\n.byte 0\n.align 0\nL.952:\n.byte 9\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 67\n.byte 101\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 85\n.byte 45\n.byte 55\n.byte 54\n.byte 0\n.align 0\nL.951:\n.byte 9\n.byte 82\n.byte 105\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 75\n.byte 97\n.byte 114\n.byte 112\n.byte 105\n.byte 110\n.byte 115\n.byte 107\n.byte 105\n.byte 0\n.align 0\nL.950:\n.byte 80\n.byte 108\n.byte 101\n.byte 97\n.byte 115\n.byte 101\n.byte 32\n.byte 115\n.byte 101\n.byte 110\n.byte 100\n.byte 32\n.byte 115\n.byte 117\n.byte 103\n.byte 103\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 114\n.byte 101\n.byte 115\n.byte 117\n.byte 108\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 0\n.align 0\nL.949:\n.byte 99\n.byte 111\n.byte 112\n.byte 101\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 117\n.byte 110\n.byte 97\n.byte 110\n.byte 116\n.byte 105\n.byte 99\n.byte 105\n.byte 112\n.byte 97\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 110\n.byte 101\n.byte 119\n.byte 108\n.byte 121\n.byte 32\n.byte 117\n.byte 110\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 112\n.byte 97\n.byte 116\n.byte 104\n.byte 111\n.byte 108\n.byte 111\n.byte 103\n.byte 105\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.948:\n.byte 85\n.byte 115\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 105\n.byte 110\n.byte 118\n.byte 105\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 104\n.byte 101\n.byte 108\n.byte 112\n.byte 32\n.byte 100\n.byte 101\n.byte 98\n.byte 117\n.byte 103\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 97\n.byte 117\n.byte 103\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 115\n.byte 111\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 119\n.byte 105\n.byte 108\n.byte 108\n.byte 0\n.align 0\nL.945:\n.byte 65\n.byte 110\n.byte 115\n.byte 119\n.byte 101\n.byte 114\n.byte 32\n.byte 113\n.byte 117\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 89\n.byte 44\n.byte 32\n.byte 121\n.byte 44\n.byte 32\n.byte 78\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 110\n.byte 32\n.byte 40\n.byte 117\n.byte 110\n.byte 108\n.byte 101\n.byte 115\n.byte 115\n.byte 32\n.byte 111\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 119\n.byte 105\n.byte 115\n.byte 101\n.byte 32\n.byte 105\n.byte 110\n.byte 100\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 101\n.byte 100\n.byte 41\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.944:\n.byte 97\n.byte 109\n.byte 101\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 107\n.byte 101\n.byte 32\n.byte 102\n.byte 117\n.byte 114\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.943:\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 97\n.byte 110\n.byte 121\n.byte 119\n.byte 97\n.byte 121\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 115\n.byte 101\n.byte 101\n.byte 32\n.byte 104\n.byte 111\n.byte 119\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 109\n.byte 105\n.byte 108\n.byte 101\n.byte 115\n.byte 116\n.byte 111\n.byte 110\n.byte 101\n.byte 115\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 112\n.byte 97\n.byte 115\n.byte 115\n.byte 101\n.byte 115\n.byte 44\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 110\n.byte 0\n.align 0\nL.942:\n.byte 119\n.byte 97\n.byte 114\n.byte 110\n.byte 105\n.byte 110\n.byte 103\n.byte 46\n.byte 32\n.byte 32\n.byte 73\n.byte 102\n.byte 32\n.byte 112\n.byte 101\n.byte 114\n.byte 115\n.byte 117\n.byte 97\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 118\n.byte 97\n.byte 105\n.byte 108\n.byte 115\n.byte 32\n.byte 110\n.byte 97\n.byte 117\n.byte 103\n.byte 104\n.byte 116\n.byte 44\n.byte 32\n.byte 100\n.byte 111\n.byte 110\n.byte 39\n.byte 116\n.byte 32\n.byte 100\n.byte 101\n.byte 115\n.byte 112\n.byte 97\n.byte 105\n.byte 114\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 32\n.byte 114\n.byte 117\n.byte 110\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 0\n.align 0\nL.941:\n.byte 116\n.byte 111\n.byte 32\n.byte 112\n.byte 101\n.byte 114\n.byte 115\n.byte 101\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 97\n.byte 32\n.byte 115\n.byte 117\n.byte 114\n.byte 114\n.byte 111\n.byte 103\n.byte 97\n.byte 116\n.byte 101\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 97\n.byte 102\n.byte 116\n.byte 101\n.byte 114\n.byte 44\n.byte 32\n.byte 112\n.byte 101\n.byte 114\n.byte 104\n.byte 97\n.byte 112\n.byte 115\n.byte 44\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 112\n.byte 108\n.byte 97\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 115\n.byte 111\n.byte 109\n.byte 101\n.byte 0\n.align 0\nL.940:\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 32\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 47\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 111\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 115\n.byte 44\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 32\n.byte 114\n.byte 97\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 0\n.align 0\nL.939:\n.byte 116\n.byte 114\n.byte 121\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 112\n.byte 101\n.byte 114\n.byte 115\n.byte 117\n.byte 97\n.byte 100\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 116\n.byte 101\n.byte 114\n.byte 109\n.byte 105\n.byte 110\n.byte 97\n.byte 116\n.byte 101\n.byte 32\n.byte 101\n.byte 120\n.byte 101\n.byte 99\n.byte 117\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 110\n.byte 32\n.byte 97\n.byte 110\n.byte 0\n.align 0\nL.938:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 96\n.byte 69\n.byte 78\n.byte 68\n.byte 32\n.byte 79\n.byte 70\n.byte 32\n.byte 84\n.byte 69\n.byte 83\n.byte 84\n.byte 39\n.byte 44\n.byte 10\n.byte 0\n.align 0\nL.937:\n.byte 76\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 115\n.byte 116\n.byte 111\n.byte 112\n.byte 32\n.byte 112\n.byte 114\n.byte 101\n.byte 109\n.byte 97\n.byte 116\n.byte 117\n.byte 114\n.byte 101\n.byte 108\n.byte 121\n.byte 44\n.byte 32\n.byte 105\n.byte 46\n.byte 101\n.byte 46\n.byte 32\n.byte 98\n.byte 101\n.byte 102\n.byte 111\n.byte 114\n.byte 101\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 112\n.byte 108\n.byte 97\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 10\n.byte 0\n.align 0\nL.934:\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.929:\n.byte 32\n.byte 32\n.byte 32\n.byte 80\n.byte 76\n.byte 69\n.byte 65\n.byte 83\n.byte 69\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 73\n.byte 70\n.byte 89\n.byte 32\n.byte 75\n.byte 65\n.byte 82\n.byte 80\n.byte 73\n.byte 78\n.byte 75\n.byte 83\n.byte 73\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.928:\n.byte 37\n.byte 115\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 111\n.byte 110\n.byte 115\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 110\n.byte 116\n.byte 46\n.byte 46\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.926:\n.byte 9\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 90\n.byte 32\n.byte 42\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.925:\n.byte 9\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 49\n.byte 32\n.byte 42\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.924:\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 100\n.byte 111\n.byte 101\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 109\n.byte 117\n.byte 116\n.byte 101\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.919:\n.byte 90\n.byte 32\n.byte 47\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.916:\n.byte 49\n.byte 32\n.byte 42\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 37\n.byte 103\n.byte 10\n.byte 0\n.align 0\nL.913:\n.byte 90\n.byte 32\n.byte 42\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 0\n.align 0\nL.910:\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 9\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 101\n.byte 115\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 32\n.byte 0\n.align 0\nL.909:\n.byte 87\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 0\n.align 0\nL.904:\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.901:\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 86\n.byte 69\n.byte 82\n.byte 89\n.byte 32\n.byte 83\n.byte 69\n.byte 82\n.byte 73\n.byte 79\n.byte 85\n.byte 83\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.895:\n.byte 32\n.byte 104\n.byte 97\n.byte 115\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 32\n.byte 106\n.byte 117\n.byte 115\n.byte 116\n.byte 32\n.byte 98\n.byte 101\n.byte 101\n.byte 110\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 97\n.byte 108\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.894:\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 79\n.byte 46\n.byte 75\n.byte 46\n.byte 44\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 118\n.byte 105\n.byte 100\n.byte 101\n.byte 100\n.byte 32\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 47\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 0\n.align 0\nL.891:\n.byte 87\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 109\n.byte 97\n.byte 99\n.byte 104\n.byte 105\n.byte 110\n.byte 101\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 40\n.byte 90\n.byte 32\n.byte 43\n.byte 32\n.byte 90\n.byte 41\n.byte 32\n.byte 47\n.byte 32\n.byte 90\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.887:\n.byte 40\n.byte 90\n.byte 32\n.byte 43\n.byte 32\n.byte 90\n.byte 41\n.byte 32\n.byte 47\n.byte 32\n.byte 90\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 115\n.byte 97\n.byte 102\n.byte 101\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.886:\n.byte 83\n.byte 105\n.byte 110\n.byte 99\n.byte 101\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 100\n.byte 101\n.byte 110\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 101\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 0\n.align 0\nL.882:\n.byte 83\n.byte 105\n.byte 109\n.byte 105\n.byte 108\n.byte 97\n.byte 114\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 114\n.byte 101\n.byte 112\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 104\n.byte 97\n.byte 118\n.byte 101\n.byte 32\n.byte 111\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 116\n.byte 105\n.byte 109\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.872:\n.byte 9\n.byte 9\n.byte 116\n.byte 104\n.byte 101\n.byte 121\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.871:\n.byte 9\n.byte 119\n.byte 104\n.byte 105\n.byte 99\n.byte 104\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 117\n.byte 110\n.byte 101\n.byte 113\n.byte 117\n.byte 97\n.byte 108\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 59\n.byte 10\n.byte 0\n.align 0\nL.870:\n.byte 9\n.byte 121\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 101\n.byte 100\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 59\n.byte 10\n.byte 0\n.align 0\nL.869:\n.byte 9\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 10\n.byte 0\n.align 0\nL.868:\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 10\n.byte 0\n.align 0\nL.867:\n.byte 87\n.byte 65\n.byte 82\n.byte 78\n.byte 73\n.byte 78\n.byte 71\n.byte 58\n.byte 32\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 10\n.byte 0\n.align 0\nL.849:\n.byte 9\n.byte 105\n.byte 110\n.byte 115\n.byte 116\n.byte 101\n.byte 97\n.byte 100\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 48\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.848:\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 40\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 45\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 3\nL.840:\n.word 0x3ed4f8b5\n.word 0x88e368f1\n.align 0\nL.838:\n.byte 37\n.byte 115\n.byte 58\n.byte 32\n.byte 32\n.byte 37\n.byte 115\n.byte 0\n.align 0\nL.837:\n.byte 70\n.byte 76\n.byte 65\n.byte 87\n.byte 0\n.align 0\nL.836:\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 0\n.align 0\nL.835:\n.byte 83\n.byte 69\n.byte 82\n.byte 73\n.byte 79\n.byte 85\n.byte 83\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 0\n.align 0\nL.834:\n.byte 70\n.byte 65\n.byte 73\n.byte 76\n.byte 85\n.byte 82\n.byte 69\n.byte 0\n.align 0\nL.828:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 80\n.byte 97\n.byte 103\n.byte 101\n.byte 58\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 10\n.byte 0\n.align 0\nL.827:\n.byte 10\n.byte 68\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 105\n.byte 115\n.byte 32\n.byte 114\n.byte 101\n.byte 115\n.byte 117\n.byte 109\n.byte 101\n.byte 115\n.byte 32\n.byte 97\n.byte 102\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 109\n.byte 105\n.byte 108\n.byte 101\n.byte 115\n.byte 116\n.byte 111\n.byte 110\n.byte 101\n.byte 32\n.byte 78\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 37\n.byte 100\n.byte 0\n.align 3\nL.825:\n.word 0xbff00000\n.word 0x0\n.align 0\nL.820:\n.byte 69\n.byte 78\n.byte 68\n.byte 32\n.byte 79\n.byte 70\n.byte 32\n.byte 84\n.byte 69\n.byte 83\n.byte 84\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.819:\n.byte 10\n.byte 65\n.byte 32\n.byte 116\n.byte 111\n.byte 116\n.byte 97\n.byte 108\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 102\n.byte 108\n.byte 111\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 112\n.byte 111\n.byte 105\n.byte 110\n.byte 116\n.byte 32\n.byte 101\n.byte 120\n.byte 99\n.byte 101\n.byte 112\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 119\n.byte 101\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 101\n.byte 103\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.816:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 69\n.byte 120\n.byte 99\n.byte 101\n.byte 108\n.byte 108\n.byte 101\n.byte 110\n.byte 116\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.815:\n.byte 32\n.byte 100\n.byte 117\n.byte 114\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 71\n.byte 114\n.byte 97\n.byte 100\n.byte 117\n.byte 97\n.byte 108\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.814:\n.byte 44\n.byte 10\n.byte 101\n.byte 120\n.byte 99\n.byte 101\n.byte 112\n.byte 116\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 112\n.byte 111\n.byte 115\n.byte 115\n.byte 105\n.byte 98\n.byte 108\n.byte 121\n.byte 32\n.byte 68\n.byte 111\n.byte 117\n.byte 98\n.byte 108\n.byte 101\n.byte 32\n.byte 82\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 0\n.align 0\nL.813:\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.810:\n.byte 56\n.byte 53\n.byte 52\n.byte 0\n.align 0\nL.809:\n.byte 55\n.byte 53\n.byte 52\n.byte 0\n.align 0\nL.806:\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 112\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 73\n.byte 69\n.byte 69\n.byte 69\n.byte 32\n.byte 115\n.byte 116\n.byte 97\n.byte 110\n.byte 100\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 80\n.byte 0\n.align 0\nL.805:\n.byte 82\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 111\n.byte 114\n.byte 109\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 0\n.align 0\nL.802:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 115\n.byte 101\n.byte 101\n.byte 109\n.byte 115\n.byte 32\n.byte 83\n.byte 97\n.byte 116\n.byte 105\n.byte 115\n.byte 102\n.byte 97\n.byte 99\n.byte 116\n.byte 111\n.byte 114\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.796:\n.byte 78\n.byte 111\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 117\n.byte 114\n.byte 101\n.byte 115\n.byte 44\n.byte 32\n.byte 100\n.byte 101\n.byte 102\n.byte 101\n.byte 99\n.byte 116\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 102\n.byte 108\n.byte 97\n.byte 119\n.byte 115\n.byte 32\n.byte 104\n.byte 97\n.byte 118\n.byte 101\n.byte 32\n.byte 98\n.byte 101\n.byte 101\n.byte 110\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.795:\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 39\n.byte 115\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 115\n.byte 101\n.byte 113\n.byte 117\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.794:\n.byte 80\n.byte 111\n.byte 116\n.byte 101\n.byte 110\n.byte 116\n.byte 105\n.byte 97\n.byte 108\n.byte 108\n.byte 121\n.byte 32\n.byte 102\n.byte 97\n.byte 116\n.byte 97\n.byte 108\n.byte 32\n.byte 70\n.byte 65\n.byte 73\n.byte 76\n.byte 85\n.byte 82\n.byte 69\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 104\n.byte 97\n.byte 118\n.byte 101\n.byte 32\n.byte 115\n.byte 112\n.byte 111\n.byte 105\n.byte 108\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 0\n.align 0\nL.791:\n.byte 117\n.byte 110\n.byte 97\n.byte 99\n.byte 99\n.byte 101\n.byte 112\n.byte 116\n.byte 97\n.byte 98\n.byte 108\n.byte 101\n.byte 32\n.byte 83\n.byte 101\n.byte 114\n.byte 105\n.byte 111\n.byte 117\n.byte 115\n.byte 32\n.byte 68\n.byte 101\n.byte 102\n.byte 101\n.byte 99\n.byte 116\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.790:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 104\n.byte 97\n.byte 115\n.byte 32\n.byte 0\n.align 0\nL.786:\n.byte 100\n.byte 101\n.byte 115\n.byte 112\n.byte 105\n.byte 116\n.byte 101\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 111\n.byte 110\n.byte 118\n.byte 101\n.byte 110\n.byte 105\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 68\n.byte 101\n.byte 102\n.byte 101\n.byte 99\n.byte 116\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.785:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 65\n.byte 99\n.byte 99\n.byte 101\n.byte 112\n.byte 116\n.byte 97\n.byte 98\n.byte 108\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.780:\n.byte 83\n.byte 97\n.byte 116\n.byte 105\n.byte 115\n.byte 102\n.byte 97\n.byte 99\n.byte 116\n.byte 111\n.byte 114\n.byte 121\n.byte 32\n.byte 116\n.byte 104\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 32\n.byte 102\n.byte 108\n.byte 97\n.byte 119\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.779:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 115\n.byte 101\n.byte 101\n.byte 109\n.byte 115\n.byte 32\n.byte 0\n.align 0\nL.768:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 32\n.byte 37\n.byte 45\n.byte 50\n.byte 57\n.byte 115\n.byte 32\n.byte 37\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.761:\n.byte 70\n.byte 76\n.byte 65\n.byte 87\n.byte 115\n.byte 32\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 61\n.byte 0\n.align 0\nL.760:\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 115\n.byte 32\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 61\n.byte 0\n.align 0\nL.759:\n.byte 83\n.byte 69\n.byte 82\n.byte 73\n.byte 79\n.byte 85\n.byte 83\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 115\n.byte 32\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 61\n.byte 0\n.align 0\nL.758:\n.byte 70\n.byte 65\n.byte 73\n.byte 76\n.byte 85\n.byte 82\n.byte 69\n.byte 115\n.byte 32\n.byte 32\n.byte 101\n.byte 110\n.byte 99\n.byte 111\n.byte 117\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 61\n.byte 0\n.align 0\nL.754:\n.byte 10\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 84\n.byte 114\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 32\n.byte 48\n.byte 32\n.byte 47\n.byte 32\n.byte 48\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 101\n.byte 115\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 0\n.align 0\nL.753:\n.byte 32\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.750:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 84\n.byte 114\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 32\n.byte 49\n.byte 32\n.byte 47\n.byte 32\n.byte 48\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 101\n.byte 115\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 0\n.align 0\nL.749:\n.byte 87\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 109\n.byte 101\n.byte 115\n.byte 115\n.byte 97\n.byte 103\n.byte 101\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 47\n.byte 111\n.byte 114\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 115\n.byte 32\n.byte 100\n.byte 111\n.byte 101\n.byte 115\n.byte 32\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 101\n.byte 63\n.byte 10\n.byte 0\n.align 0\nL.748:\n.byte 32\n.byte 32\n.byte 105\n.byte 110\n.byte 115\n.byte 116\n.byte 101\n.byte 97\n.byte 100\n.byte 44\n.byte 32\n.byte 88\n.byte 32\n.byte 47\n.byte 32\n.byte 88\n.byte 32\n.byte 45\n.byte 32\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 45\n.byte 32\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.747:\n.byte 32\n.byte 32\n.byte 88\n.byte 32\n.byte 47\n.byte 32\n.byte 88\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 49\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 110\n.byte 32\n.byte 88\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.742:\n.byte 32\n.byte 32\n.byte 88\n.byte 32\n.byte 47\n.byte 32\n.byte 88\n.byte 32\n.byte 32\n.byte 116\n.byte 114\n.byte 97\n.byte 112\n.byte 115\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 110\n.byte 32\n.byte 88\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 103\n.byte 10\n.byte 0\n.align 0\nL.727:\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 102\n.byte 97\n.byte 114\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 49\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.726:\n.byte 32\n.byte 117\n.byte 110\n.byte 98\n.byte 97\n.byte 108\n.byte 97\n.byte 110\n.byte 99\n.byte 101\n.byte 100\n.byte 32\n.byte 114\n.byte 97\n.byte 110\n.byte 103\n.byte 101\n.byte 59\n.byte 32\n.byte 85\n.byte 102\n.byte 84\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 42\n.byte 32\n.byte 86\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 9\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.725:\n.byte 66\n.byte 97\n.byte 100\n.byte 108\n.byte 121\n.byte 0\n.align 0\nL.718:\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 102\n.byte 97\n.byte 114\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 40\n.byte 90\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 50\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.717:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.705:\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 102\n.byte 97\n.byte 114\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 40\n.byte 90\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.704:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 119\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.687:\n.byte 43\n.byte 45\n.byte 37\n.byte 103\n.byte 44\n.byte 32\n.byte 43\n.byte 45\n.byte 37\n.byte 103\n.byte 10\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 43\n.byte 45\n.byte 37\n.byte 103\n.byte 32\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 117\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 46\n.byte 0\n.align 0\nL.686:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 105\n.byte 110\n.byte 118\n.byte 111\n.byte 108\n.byte 118\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 0\n.align 0\nL.680:\n.byte 97\n.byte 98\n.byte 111\n.byte 118\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.679:\n.byte 65\n.byte 110\n.byte 121\n.byte 32\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 115\n.byte 101\n.byte 112\n.byte 97\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 42\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 111\n.byte 110\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.678:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 86\n.byte 32\n.byte 47\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.677:\n.byte 78\n.byte 111\n.byte 32\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 97\n.byte 108\n.byte 101\n.byte 100\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 86\n.byte 32\n.byte 42\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.676:\n.byte 84\n.byte 104\n.byte 101\n.byte 114\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 32\n.byte 115\n.byte 97\n.byte 116\n.byte 117\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 98\n.byte 101\n.byte 99\n.byte 97\n.byte 117\n.byte 115\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 115\n.byte 121\n.byte 115\n.byte 116\n.byte 101\n.byte 109\n.byte 32\n.byte 116\n.byte 114\n.byte 97\n.byte 112\n.byte 115\n.byte 32\n.byte 111\n.byte 110\n.byte 32\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.675:\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 115\n.byte 97\n.byte 116\n.byte 117\n.byte 114\n.byte 97\n.byte 116\n.byte 101\n.byte 115\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 86\n.byte 48\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.672:\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 86\n.byte 32\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.663:\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 112\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 9\n.byte 115\n.byte 104\n.byte 114\n.byte 105\n.byte 110\n.byte 107\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.660:\n.byte 45\n.byte 40\n.byte 45\n.byte 89\n.byte 41\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 89\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.659:\n.byte 102\n.byte 105\n.byte 110\n.byte 100\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 0\n.align 0\nL.658:\n.byte 83\n.byte 101\n.byte 101\n.byte 109\n.byte 115\n.byte 32\n.byte 79\n.byte 46\n.byte 75\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.655:\n.byte 84\n.byte 114\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 111\n.byte 110\n.byte 32\n.byte 89\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.654:\n.byte 67\n.byte 97\n.byte 110\n.byte 32\n.byte 96\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 45\n.byte 89\n.byte 39\n.byte 32\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 63\n.byte 10\n.byte 0\n.align 0\nL.647:\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 103\n.byte 101\n.byte 110\n.byte 101\n.byte 114\n.byte 97\n.byte 116\n.byte 101\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.646:\n.byte 83\n.byte 101\n.byte 97\n.byte 114\n.byte 99\n.byte 104\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 58\n.byte 10\n.byte 0\n.align 0\nL.645:\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 32\n.byte 110\n.byte 111\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 114\n.byte 101\n.byte 112\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.637:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 112\n.byte 111\n.byte 119\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 90\n.byte 94\n.byte 81\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 114\n.byte 32\n.byte 110\n.byte 101\n.byte 97\n.byte 114\n.byte 108\n.byte 121\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 101\n.byte 109\n.byte 101\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.636:\n.byte 65\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 97\n.byte 99\n.byte 121\n.byte 32\n.byte 115\n.byte 101\n.byte 101\n.byte 109\n.byte 115\n.byte 32\n.byte 97\n.byte 100\n.byte 101\n.byte 113\n.byte 117\n.byte 97\n.byte 116\n.byte 101\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.629:\n.byte 9\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 105\n.byte 110\n.byte 118\n.byte 111\n.byte 108\n.byte 118\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 105\n.byte 110\n.byte 121\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 114\n.byte 97\n.byte 116\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.628:\n.byte 9\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 109\n.byte 117\n.byte 99\n.byte 104\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 115\n.byte 112\n.byte 111\n.byte 105\n.byte 108\n.byte 32\n.byte 102\n.byte 105\n.byte 110\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 97\n.byte 108\n.byte 10\n.byte 0\n.align 0\nL.627:\n.byte 9\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.626:\n.byte 9\n.byte 40\n.byte 49\n.byte 32\n.byte 43\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 59\n.byte 10\n.byte 0\n.align 0\nL.625:\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 10\n.byte 0\n.align 0\nL.624:\n.byte 67\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 101\n.byte 100\n.byte 0\n.align 0\nL.617:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 88\n.byte 94\n.byte 40\n.byte 40\n.byte 88\n.byte 32\n.byte 43\n.byte 32\n.byte 49\n.byte 41\n.byte 32\n.byte 47\n.byte 32\n.byte 40\n.byte 88\n.byte 32\n.byte 45\n.byte 32\n.byte 49\n.byte 41\n.byte 41\n.byte 32\n.byte 118\n.byte 115\n.byte 46\n.byte 32\n.byte 101\n.byte 120\n.byte 112\n.byte 40\n.byte 50\n.byte 41\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 88\n.byte 32\n.byte 45\n.byte 62\n.byte 32\n.byte 49\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.613:\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 79\n.byte 46\n.byte 75\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.610:\n.byte 32\n.byte 32\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.609:\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 98\n.byte 101\n.byte 116\n.byte 119\n.byte 101\n.byte 101\n.byte 110\n.byte 32\n.byte 48\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 10\n.byte 0\n.align 0\nL.605:\n.byte 97\n.byte 99\n.byte 116\n.byte 117\n.byte 97\n.byte 108\n.byte 108\n.byte 121\n.byte 32\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 121\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 115\n.byte 58\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.604:\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 97\n.byte 102\n.byte 102\n.byte 108\n.byte 105\n.byte 99\n.byte 116\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 101\n.byte 120\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 10\n.byte 9\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 59\n.byte 10\n.byte 0\n.align 0\nL.603:\n.byte 85\n.byte 102\n.byte 84\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 61\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 10\n.byte 111\n.byte 110\n.byte 108\n.byte 121\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 0\n.align 0\nL.602:\n.byte 83\n.byte 105\n.byte 110\n.byte 99\n.byte 101\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 111\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 115\n.byte 32\n.byte 98\n.byte 101\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.601:\n.byte 82\n.byte 97\n.byte 110\n.byte 103\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 110\n.byte 97\n.byte 114\n.byte 114\n.byte 111\n.byte 119\n.byte 59\n.byte 32\n.byte 85\n.byte 49\n.byte 94\n.byte 37\n.byte 100\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.596:\n.byte 109\n.byte 101\n.byte 114\n.byte 101\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 111\n.byte 102\n.byte 102\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.595:\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 115\n.byte 117\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 32\n.byte 108\n.byte 97\n.byte 114\n.byte 103\n.byte 101\n.byte 114\n.byte 32\n.byte 82\n.byte 101\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 110\n.byte 32\n.byte 0\n.align 0\nL.594:\n.byte 32\n.byte 98\n.byte 101\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 119\n.byte 104\n.byte 105\n.byte 99\n.byte 104\n.byte 0\n.align 0\nL.593:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.592:\n.byte 88\n.byte 32\n.byte 47\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 49\n.byte 32\n.byte 43\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.591:\n.byte 88\n.byte 32\n.byte 47\n.byte 32\n.byte 90\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 115\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.588:\n.byte 101\n.byte 110\n.byte 99\n.byte 111\n.byte 117\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 97\n.byte 108\n.byte 116\n.byte 104\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 32\n.byte 97\n.byte 99\n.byte 116\n.byte 117\n.byte 97\n.byte 108\n.byte 108\n.byte 121\n.byte 10\n.byte 0\n.align 0\nL.587:\n.byte 32\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 32\n.byte 40\n.byte 102\n.byte 40\n.byte 88\n.byte 41\n.byte 32\n.byte 45\n.byte 32\n.byte 102\n.byte 40\n.byte 90\n.byte 41\n.byte 41\n.byte 32\n.byte 47\n.byte 32\n.byte 40\n.byte 88\n.byte 32\n.byte 45\n.byte 32\n.byte 90\n.byte 41\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.586:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 105\n.byte 102\n.byte 32\n.byte 40\n.byte 88\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 90\n.byte 41\n.byte 32\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 32\n.byte 32\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 0\n.align 0\nL.585:\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 117\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 110\n.byte 32\n.byte 105\n.byte 110\n.byte 110\n.byte 111\n.byte 99\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 115\n.byte 116\n.byte 97\n.byte 116\n.byte 101\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.584:\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 83\n.byte 69\n.byte 82\n.byte 73\n.byte 79\n.byte 85\n.byte 83\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 10\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 99\n.byte 97\n.byte 117\n.byte 115\n.byte 101\n.byte 115\n.byte 32\n.byte 0\n.align 0\nL.583:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 83\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 44\n.byte 32\n.byte 0\n.align 0\nL.582:\n.byte 121\n.byte 101\n.byte 116\n.byte 32\n.byte 88\n.byte 32\n.byte 45\n.byte 32\n.byte 90\n.byte 32\n.byte 121\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 115\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.581:\n.byte 88\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 9\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 101\n.byte 113\n.byte 117\n.byte 97\n.byte 108\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.576:\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 47\n.byte 32\n.byte 85\n.byte 102\n.byte 84\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 101\n.byte 100\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.566:\n.byte 40\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 111\n.byte 102\n.byte 102\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 85\n.byte 102\n.byte 84\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 41\n.byte 32\n.byte 60\n.byte 32\n.byte 69\n.byte 48\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.565:\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 103\n.byte 114\n.byte 97\n.byte 100\n.byte 117\n.byte 97\n.byte 108\n.byte 59\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 117\n.byte 114\n.byte 115\n.byte 32\n.byte 65\n.byte 98\n.byte 115\n.byte 111\n.byte 108\n.byte 117\n.byte 116\n.byte 101\n.byte 32\n.byte 69\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 61\n.byte 10\n.byte 0\n.align 0\nL.560:\n.byte 124\n.byte 81\n.byte 32\n.byte 45\n.byte 32\n.byte 89\n.byte 124\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.559:\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 32\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 81\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 89\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.558:\n.byte 81\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 89\n.byte 32\n.byte 119\n.byte 104\n.byte 105\n.byte 108\n.byte 101\n.byte 32\n.byte 100\n.byte 101\n.byte 110\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 124\n.byte 81\n.byte 32\n.byte 45\n.byte 32\n.byte 89\n.byte 124\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 48\n.byte 59\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 115\n.byte 101\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.557:\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 117\n.byte 115\n.byte 101\n.byte 115\n.byte 32\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 44\n.byte 32\n.byte 119\n.byte 104\n.byte 105\n.byte 99\n.byte 104\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 10\n.byte 0\n.align 0\nL.555:\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 32\n.byte 109\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 108\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.554:\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 100\n.byte 111\n.byte 119\n.byte 110\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.553:\n.byte 97\n.byte 112\n.byte 112\n.byte 114\n.byte 111\n.byte 97\n.byte 99\n.byte 104\n.byte 32\n.byte 97\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.552:\n.byte 69\n.byte 105\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 97\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 97\n.byte 99\n.byte 121\n.byte 32\n.byte 100\n.byte 101\n.byte 116\n.byte 101\n.byte 114\n.byte 105\n.byte 111\n.byte 114\n.byte 97\n.byte 116\n.byte 101\n.byte 115\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.540:\n.byte 83\n.byte 109\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 115\n.byte 116\n.byte 114\n.byte 105\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 112\n.byte 111\n.byte 115\n.byte 105\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 69\n.byte 48\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.539:\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 110\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 116\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.538:\n.byte 68\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 101\n.byte 110\n.byte 99\n.byte 101\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 115\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 97\n.byte 32\n.byte 104\n.byte 105\n.byte 103\n.byte 104\n.byte 101\n.byte 114\n.byte 0\n.align 0\nL.535:\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 110\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 101\n.byte 110\n.byte 99\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.534:\n.byte 80\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 116\n.byte 115\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 97\n.byte 32\n.byte 104\n.byte 105\n.byte 103\n.byte 104\n.byte 101\n.byte 114\n.byte 0\n.align 0\nL.527:\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 80\n.byte 115\n.byte 101\n.byte 117\n.byte 100\n.byte 111\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.526:\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 32\n.byte 115\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 100\n.byte 108\n.byte 121\n.byte 32\n.byte 112\n.byte 111\n.byte 115\n.byte 105\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.525:\n.byte 112\n.byte 111\n.byte 115\n.byte 105\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 44\n.byte 32\n.byte 105\n.byte 115\n.byte 110\n.byte 39\n.byte 116\n.byte 59\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.524:\n.byte 66\n.byte 117\n.byte 116\n.byte 32\n.byte 45\n.byte 80\n.byte 115\n.byte 101\n.byte 117\n.byte 100\n.byte 111\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 44\n.byte 32\n.byte 119\n.byte 104\n.byte 105\n.byte 99\n.byte 104\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 98\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.521:\n.byte 80\n.byte 115\n.byte 101\n.byte 117\n.byte 100\n.byte 111\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 58\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.520:\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 100\n.byte 108\n.byte 121\n.byte 32\n.byte 110\n.byte 101\n.byte 103\n.byte 97\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.519:\n.byte 80\n.byte 111\n.byte 115\n.byte 105\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 101\n.byte 120\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 97\n.byte 110\n.byte 10\n.byte 0\n.align 0\nL.506:\n.byte 109\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 108\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.482:\n.byte 83\n.byte 101\n.byte 101\n.byte 107\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 115\n.byte 32\n.byte 85\n.byte 102\n.byte 84\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 69\n.byte 48\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.479:\n.byte 46\n.byte 46\n.byte 46\n.byte 32\n.byte 110\n.byte 111\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 114\n.byte 101\n.byte 112\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.476:\n.byte 9\n.byte 105\n.byte 110\n.byte 118\n.byte 111\n.byte 108\n.byte 118\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 114\n.byte 97\n.byte 116\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.475:\n.byte 69\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 115\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 105\n.byte 110\n.byte 118\n.byte 97\n.byte 108\n.byte 105\n.byte 100\n.byte 97\n.byte 116\n.byte 101\n.byte 32\n.byte 102\n.byte 105\n.byte 110\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 97\n.byte 108\n.byte 32\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.454:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 112\n.byte 111\n.byte 119\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 90\n.byte 94\n.byte 105\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 115\n.byte 109\n.byte 97\n.byte 108\n.byte 108\n.byte 32\n.byte 73\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 90\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.451:\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 108\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 0\n.align 0\nL.449:\n.byte 116\n.byte 111\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 117\n.byte 108\n.byte 112\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.448:\n.byte 79\n.byte 98\n.byte 115\n.byte 101\n.byte 114\n.byte 118\n.byte 101\n.byte 100\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 115\n.byte 32\n.byte 114\n.byte 117\n.byte 110\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 0\n.align 0\nL.447:\n.byte 83\n.byte 113\n.byte 117\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 111\n.byte 111\n.byte 116\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 101\n.byte 105\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.444:\n.byte 83\n.byte 113\n.byte 117\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 111\n.byte 111\n.byte 116\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.439:\n.byte 83\n.byte 113\n.byte 117\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 111\n.byte 111\n.byte 116\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.434:\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 115\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 115\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.433:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 94\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.432:\n.byte 65\n.byte 110\n.byte 111\n.byte 109\n.byte 97\n.byte 108\n.byte 111\n.byte 117\n.byte 115\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 73\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 32\n.byte 60\n.byte 32\n.byte 0\n.align 0\nL.392:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.370:\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 40\n.byte 88\n.byte 41\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 110\n.byte 45\n.byte 109\n.byte 111\n.byte 110\n.byte 111\n.byte 116\n.byte 111\n.byte 110\n.byte 105\n.byte 99\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 88\n.byte 32\n.byte 110\n.byte 101\n.byte 97\n.byte 114\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.369:\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 104\n.byte 97\n.byte 115\n.byte 32\n.byte 112\n.byte 97\n.byte 115\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 97\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 77\n.byte 111\n.byte 110\n.byte 111\n.byte 116\n.byte 111\n.byte 110\n.byte 105\n.byte 99\n.byte 105\n.byte 116\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.352:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 109\n.byte 111\n.byte 110\n.byte 111\n.byte 116\n.byte 111\n.byte 110\n.byte 105\n.byte 99\n.byte 105\n.byte 116\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.341:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 105\n.byte 102\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 40\n.byte 88\n.byte 32\n.byte 42\n.byte 32\n.byte 88\n.byte 41\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 88\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 73\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 88\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.336:\n.byte 83\n.byte 113\n.byte 117\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 111\n.byte 111\n.byte 116\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 48\n.byte 46\n.byte 48\n.byte 44\n.byte 32\n.byte 45\n.byte 48\n.byte 46\n.byte 48\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 49\n.byte 46\n.byte 48\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 0\n.align 0\nL.334:\n.byte 10\n.byte 82\n.byte 117\n.byte 110\n.byte 110\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 115\n.byte 113\n.byte 117\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 111\n.byte 111\n.byte 116\n.byte 40\n.byte 120\n.byte 41\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.333:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 78\n.byte 111\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 117\n.byte 114\n.byte 101\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 32\n.byte 112\n.byte 97\n.byte 105\n.byte 114\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.332:\n.byte 88\n.byte 32\n.byte 42\n.byte 32\n.byte 89\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 89\n.byte 32\n.byte 42\n.byte 32\n.byte 88\n.byte 32\n.byte 116\n.byte 114\n.byte 105\n.byte 97\n.byte 108\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 3\nL.323:\n.word 0x40080000\n.word 0x0\n.align 0\nL.322:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 111\n.byte 110\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 114\n.byte 97\n.byte 110\n.byte 100\n.byte 111\n.byte 109\n.byte 32\n.byte 112\n.byte 97\n.byte 105\n.byte 114\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.321:\n.byte 68\n.byte 111\n.byte 101\n.byte 115\n.byte 32\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 109\n.byte 117\n.byte 116\n.byte 101\n.byte 63\n.byte 32\n.byte 32\n.byte 0\n.align 0\nL.318:\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 40\n.byte 115\n.byte 41\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 103\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 117\n.byte 114\n.byte 101\n.byte 40\n.byte 115\n.byte 41\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 10\n.byte 40\n.byte 110\n.byte 111\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 97\n.byte 98\n.byte 111\n.byte 118\n.byte 101\n.byte 41\n.byte 32\n.byte 99\n.byte 111\n.byte 117\n.byte 110\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 111\n.byte 110\n.byte 101\n.byte 32\n.byte 102\n.byte 108\n.byte 97\n.byte 119\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 102\n.byte 105\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 116\n.byte 97\n.byte 108\n.byte 108\n.byte 121\n.byte 32\n.byte 98\n.byte 101\n.byte 108\n.byte 111\n.byte 119\n.byte 0\n.align 0\nL.316:\n.byte 83\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 121\n.byte 32\n.byte 98\n.byte 105\n.byte 116\n.byte 32\n.byte 117\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.315:\n.byte 83\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 121\n.byte 32\n.byte 98\n.byte 105\n.byte 116\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 97\n.byte 114\n.byte 101\n.byte 110\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 117\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.298:\n.byte 67\n.byte 104\n.byte 101\n.byte 99\n.byte 107\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 115\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 121\n.byte 32\n.byte 98\n.byte 105\n.byte 116\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.295:\n.byte 40\n.byte 88\n.byte 32\n.byte 45\n.byte 32\n.byte 89\n.byte 41\n.byte 32\n.byte 43\n.byte 32\n.byte 40\n.byte 89\n.byte 32\n.byte 45\n.byte 32\n.byte 88\n.byte 41\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 110\n.byte 32\n.byte 122\n.byte 101\n.byte 114\n.byte 111\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.292:\n.byte 65\n.byte 100\n.byte 100\n.byte 105\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 47\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 110\n.byte 101\n.byte 105\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.291:\n.byte 65\n.byte 100\n.byte 100\n.byte 47\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 0\n.align 0\nL.288:\n.byte 65\n.byte 100\n.byte 100\n.byte 105\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 47\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.281:\n.byte 65\n.byte 100\n.byte 100\n.byte 47\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.276:\n.byte 73\n.byte 110\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 108\n.byte 101\n.byte 116\n.byte 101\n.byte 32\n.byte 99\n.byte 97\n.byte 114\n.byte 114\n.byte 121\n.byte 45\n.byte 112\n.byte 114\n.byte 111\n.byte 112\n.byte 97\n.byte 103\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 65\n.byte 100\n.byte 100\n.byte 105\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 0\nL.272:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 42\n.byte 32\n.byte 40\n.byte 32\n.byte 49\n.byte 32\n.byte 47\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 41\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 49\n.byte 0\n.align 0\nL.270:\n.byte 47\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 101\n.byte 105\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.267:\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.264:\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 0\nL.261:\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.256:\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 0\nL.253:\n.byte 42\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 101\n.byte 105\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.252:\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.249:\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.239:\n.byte 88\n.byte 32\n.byte 42\n.byte 32\n.byte 40\n.byte 49\n.byte 47\n.byte 88\n.byte 41\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 49\n.byte 0\n.align 0\nL.220:\n.byte 67\n.byte 104\n.byte 101\n.byte 99\n.byte 107\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 111\n.byte 110\n.byte 32\n.byte 109\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 121\n.byte 44\n.byte 32\n.byte 100\n.byte 105\n.byte 118\n.byte 105\n.byte 100\n.byte 101\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 97\n.byte 100\n.byte 100\n.byte 47\n.byte 115\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.219:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 42\n.byte 44\n.byte 32\n.byte 47\n.byte 44\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 45\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 104\n.byte 97\n.byte 118\n.byte 101\n.byte 32\n.byte 103\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 44\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 121\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.216:\n.byte 32\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 32\n.byte 32\n.byte 105\n.byte 102\n.byte 32\n.byte 40\n.byte 88\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 49\n.byte 46\n.byte 48\n.byte 41\n.byte 32\n.byte 123\n.byte 46\n.byte 46\n.byte 46\n.byte 46\n.byte 46\n.byte 125\n.byte 32\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 32\n.byte 123\n.byte 46\n.byte 46\n.byte 46\n.byte 47\n.byte 40\n.byte 88\n.byte 45\n.byte 49\n.byte 46\n.byte 48\n.byte 41\n.byte 46\n.byte 46\n.byte 46\n.byte 125\n.byte 10\n.byte 0\n.align 0\nL.215:\n.byte 32\n.byte 32\n.byte 115\n.byte 117\n.byte 99\n.byte 104\n.byte 32\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 97\n.byte 117\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 97\n.byte 103\n.byte 97\n.byte 105\n.byte 110\n.byte 115\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 122\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 97\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.214:\n.byte 32\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 121\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 115\n.byte 32\n.byte 32\n.byte 40\n.byte 49\n.byte 45\n.byte 85\n.byte 49\n.byte 41\n.byte 32\n.byte 45\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 32\n.byte 44\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 101\n.byte 98\n.byte 121\n.byte 32\n.byte 118\n.byte 105\n.byte 116\n.byte 105\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 10\n.byte 0\n.align 0\nL.213:\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 32\n.byte 40\n.byte 49\n.byte 45\n.byte 85\n.byte 49\n.byte 41\n.byte 32\n.byte 60\n.byte 32\n.byte 49\n.byte 32\n.byte 32\n.byte 97\n.byte 108\n.byte 116\n.byte 104\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 10\n.byte 0\n.align 0\nL.210:\n.byte 45\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 115\n.byte 32\n.byte 71\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 68\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 44\n.byte 32\n.byte 115\n.byte 111\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 99\n.byte 101\n.byte 108\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 111\n.byte 98\n.byte 115\n.byte 99\n.byte 117\n.byte 114\n.byte 101\n.byte 100\n.byte 0\n.align 0\nL.205:\n.byte 42\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 47\n.byte 111\n.byte 114\n.byte 32\n.byte 47\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 108\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 0\n.align 0\nL.201:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 49\n.byte 47\n.byte 49\n.byte 46\n.byte 48\n.byte 48\n.byte 48\n.byte 46\n.byte 46\n.byte 49\n.byte 32\n.byte 62\n.byte 61\n.byte 32\n.byte 49\n.byte 0\n.align 0\nL.199:\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 71\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 68\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 44\n.byte 32\n.byte 115\n.byte 111\n.byte 32\n.byte 88\n.byte 47\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 88\n.byte 0\n.align 0\nL.194:\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 71\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 68\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 44\n.byte 32\n.byte 115\n.byte 111\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 32\n.byte 101\n.byte 120\n.byte 99\n.byte 101\n.byte 101\n.byte 100\n.byte 32\n.byte 49\n.byte 32\n.byte 117\n.byte 108\n.byte 112\n.byte 10\n.byte 111\n.byte 114\n.byte 32\n.byte 32\n.byte 49\n.byte 47\n.byte 51\n.byte 32\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 32\n.byte 51\n.byte 47\n.byte 57\n.byte 32\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 32\n.byte 57\n.byte 47\n.byte 50\n.byte 55\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 97\n.byte 103\n.byte 114\n.byte 101\n.byte 101\n.byte 0\n.align 0\nL.190:\n.byte 42\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 102\n.byte 105\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.188:\n.byte 42\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 71\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 68\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 44\n.byte 32\n.byte 115\n.byte 111\n.byte 32\n.byte 49\n.byte 42\n.byte 88\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 88\n.byte 0\n.align 0\nL.185:\n.byte 10\n.byte 67\n.byte 104\n.byte 101\n.byte 99\n.byte 107\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 103\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 42\n.byte 44\n.byte 32\n.byte 47\n.byte 44\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 45\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.184:\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 109\n.byte 97\n.byte 108\n.byte 105\n.byte 122\n.byte 101\n.byte 100\n.byte 44\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 98\n.byte 101\n.byte 46\n.byte 0\n.align 0\nL.179:\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 109\n.byte 97\n.byte 108\n.byte 105\n.byte 122\n.byte 101\n.byte 100\n.byte 32\n.byte 88\n.byte 61\n.byte 89\n.byte 44\n.byte 88\n.byte 43\n.byte 90\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 89\n.byte 43\n.byte 90\n.byte 33\n.byte 0\n.align 0\nL.175:\n.byte 114\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 108\n.byte 121\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 105\n.byte 102\n.byte 105\n.byte 99\n.byte 97\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 101\n.byte 99\n.byte 105\n.byte 109\n.byte 97\n.byte 108\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.174:\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 101\n.byte 108\n.byte 121\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 97\n.byte 98\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 32\n.byte 66\n.byte 45\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 44\n.byte 32\n.byte 105\n.byte 46\n.byte 101\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.173:\n.byte 83\n.byte 111\n.byte 109\n.byte 101\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 101\n.byte 120\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 10\n.byte 0\n.align 0\nL.167:\n.byte 111\n.byte 102\n.byte 32\n.byte 97\n.byte 110\n.byte 10\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 45\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 0\nL.166:\n.byte 90\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 90\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 0\n.align 0\nL.165:\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 101\n.byte 120\n.byte 97\n.byte 99\n.byte 116\n.byte 32\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 97\n.byte 32\n.byte 114\n.byte 101\n.byte 115\n.byte 117\n.byte 108\n.byte 116\n.byte 10\n.byte 0\n.align 0\nL.164:\n.byte 66\n.byte 101\n.byte 99\n.byte 97\n.byte 117\n.byte 115\n.byte 101\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 117\n.byte 110\n.byte 117\n.byte 115\n.byte 117\n.byte 97\n.byte 108\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 102\n.byte 0\n.align 0\nL.160:\n.byte 9\n.byte 85\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 90\n.byte 50\n.byte 32\n.byte 45\n.byte 32\n.byte 85\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.159:\n.byte 9\n.byte 85\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 90\n.byte 49\n.byte 32\n.byte 45\n.byte 32\n.byte 85\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.158:\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 0\nL.157:\n.byte 0\n.align 0\nL.150:\n.byte 84\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 102\n.byte 101\n.byte 97\n.byte 116\n.byte 117\n.byte 114\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 102\n.byte 117\n.byte 114\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.145:\n.byte 80\n.byte 111\n.byte 115\n.byte 115\n.byte 105\n.byte 98\n.byte 108\n.byte 121\n.byte 32\n.byte 115\n.byte 111\n.byte 109\n.byte 101\n.byte 32\n.byte 112\n.byte 97\n.byte 114\n.byte 116\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 0\n.align 0\nL.144:\n.byte 98\n.byte 121\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 45\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 101\n.byte 32\n.byte 101\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 101\n.byte 120\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.143:\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 115\n.byte 121\n.byte 109\n.byte 112\n.byte 116\n.byte 111\n.byte 109\n.byte 115\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 111\n.byte 110\n.byte 115\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 110\n.byte 99\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 101\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.142:\n.byte 114\n.byte 101\n.byte 115\n.byte 112\n.byte 101\n.byte 99\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 108\n.byte 121\n.byte 32\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 10\n.byte 0\n.align 0\nL.141:\n.byte 68\n.byte 105\n.byte 115\n.byte 97\n.byte 103\n.byte 114\n.byte 101\n.byte 101\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 97\n.byte 109\n.byte 111\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 115\n.byte 32\n.byte 88\n.byte 49\n.byte 44\n.byte 32\n.byte 89\n.byte 49\n.byte 44\n.byte 32\n.byte 90\n.byte 49\n.byte 44\n.byte 10\n.byte 0\n.align 0\nL.119:\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 119\n.byte 111\n.byte 114\n.byte 115\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 110\n.byte 32\n.byte 53\n.byte 32\n.byte 100\n.byte 101\n.byte 99\n.byte 105\n.byte 109\n.byte 97\n.byte 108\n.byte 32\n.byte 102\n.byte 105\n.byte 103\n.byte 117\n.byte 114\n.byte 101\n.byte 115\n.byte 32\n.byte 32\n.byte 0\n.align 0\nL.117:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 105\n.byte 102\n.byte 105\n.byte 99\n.byte 97\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 37\n.byte 102\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.116:\n.byte 108\n.byte 111\n.byte 103\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 105\n.byte 99\n.byte 32\n.byte 101\n.byte 110\n.byte 99\n.byte 111\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 104\n.byte 97\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 101\n.byte 114\n.byte 105\n.byte 122\n.byte 101\n.byte 100\n.byte 32\n.byte 115\n.byte 111\n.byte 108\n.byte 101\n.byte 108\n.byte 121\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 85\n.byte 49\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.113:\n.byte 111\n.byte 102\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 105\n.byte 102\n.byte 105\n.byte 99\n.byte 97\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 44\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 105\n.byte 116\n.byte 115\n.byte 101\n.byte 108\n.byte 102\n.byte 44\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 109\n.byte 105\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 102\n.byte 108\n.byte 97\n.byte 119\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.112:\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 101\n.byte 114\n.byte 105\n.byte 122\n.byte 101\n.byte 100\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 73\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 10\n.byte 0\n.align 0\nL.99:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 102\n.byte 117\n.byte 122\n.byte 122\n.byte 121\n.byte 44\n.byte 88\n.byte 61\n.byte 49\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 32\n.byte 88\n.byte 45\n.byte 49\n.byte 47\n.byte 50\n.byte 45\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 0\n.align 0\nL.95:\n.byte 40\n.byte 49\n.byte 45\n.byte 85\n.byte 49\n.byte 41\n.byte 45\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 60\n.byte 32\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 70\n.byte 65\n.byte 76\n.byte 83\n.byte 69\n.byte 44\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 46\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 115\n.byte 63\n.byte 0\n.align 3\nL.93:\n.word 0x40240000\n.word 0x0\n.align 0\nL.88:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 103\n.byte 111\n.byte 111\n.byte 100\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 50\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 49\n.byte 48\n.byte 0\n.align 0\nL.84:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 98\n.byte 105\n.byte 103\n.byte 58\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 111\n.byte 102\n.byte 102\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 98\n.byte 108\n.byte 101\n.byte 109\n.byte 115\n.byte 0\n.align 0\nL.82:\n.byte 77\n.byte 89\n.byte 83\n.byte 84\n.byte 69\n.byte 82\n.byte 89\n.byte 58\n.byte 32\n.byte 114\n.byte 101\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.81:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 105\n.byte 114\n.byte 109\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 3\nL.78:\n.word 0x3f847ae1\n.word 0x47ae147b\n.align 0\nL.77:\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 98\n.byte 101\n.byte 116\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 99\n.byte 108\n.byte 111\n.byte 115\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 114\n.byte 101\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 115\n.byte 101\n.byte 112\n.byte 97\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 85\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.76:\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 105\n.byte 114\n.byte 109\n.byte 115\n.byte 32\n.byte 99\n.byte 108\n.byte 111\n.byte 115\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 114\n.byte 101\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 115\n.byte 101\n.byte 112\n.byte 97\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 85\n.byte 49\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.61:\n.byte 82\n.byte 101\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 114\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 10\n.byte 32\n.byte 0\n.align 0\nL.60:\n.byte 67\n.byte 108\n.byte 111\n.byte 115\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 114\n.byte 101\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 115\n.byte 101\n.byte 112\n.byte 97\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 85\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 10\n.byte 0\n.align 0\nL.54:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 102\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.45:\n.byte 83\n.byte 101\n.byte 97\n.byte 114\n.byte 99\n.byte 104\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.44:\n.byte 10\n.byte 0\n.align 0\nL.43:\n.byte 45\n.byte 49\n.byte 44\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 49\n.byte 47\n.byte 50\n.byte 44\n.byte 32\n.byte 49\n.byte 44\n.byte 32\n.byte 50\n.byte 44\n.byte 32\n.byte 51\n.byte 44\n.byte 32\n.byte 52\n.byte 44\n.byte 32\n.byte 53\n.byte 44\n.byte 32\n.byte 57\n.byte 44\n.byte 32\n.byte 50\n.byte 55\n.byte 44\n.byte 32\n.byte 51\n.byte 50\n.byte 32\n.byte 38\n.byte 32\n.byte 50\n.byte 52\n.byte 48\n.byte 32\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 79\n.byte 46\n.byte 75\n.byte 46\n.byte 10\n.byte 0\n.align 0\nL.38:\n.byte 53\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 52\n.byte 43\n.byte 49\n.byte 44\n.byte 32\n.byte 50\n.byte 52\n.byte 48\n.byte 47\n.byte 51\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 56\n.byte 48\n.byte 44\n.byte 32\n.byte 50\n.byte 52\n.byte 48\n.byte 47\n.byte 52\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 54\n.byte 48\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 50\n.byte 52\n.byte 48\n.byte 47\n.byte 53\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 52\n.byte 56\n.byte 0\n.align 0\nL.34:\n.byte 57\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 51\n.byte 42\n.byte 51\n.byte 44\n.byte 32\n.byte 50\n.byte 55\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 57\n.byte 42\n.byte 51\n.byte 44\n.byte 32\n.byte 51\n.byte 50\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 56\n.byte 42\n.byte 52\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 51\n.byte 50\n.byte 45\n.byte 50\n.byte 55\n.byte 45\n.byte 52\n.byte 45\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 0\n.align 0\nL.30:\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 43\n.byte 32\n.byte 40\n.byte 45\n.byte 49\n.byte 41\n.byte 32\n.byte 43\n.byte 32\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 0\n.align 0\nL.26:\n.byte 45\n.byte 49\n.byte 43\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 40\n.byte 45\n.byte 49\n.byte 41\n.byte 43\n.byte 97\n.byte 98\n.byte 115\n.byte 40\n.byte 49\n.byte 41\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 45\n.byte 49\n.byte 43\n.byte 40\n.byte 45\n.byte 49\n.byte 41\n.byte 42\n.byte 40\n.byte 45\n.byte 49\n.byte 41\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 0\n.align 0\nL.22:\n.byte 51\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 50\n.byte 43\n.byte 49\n.byte 44\n.byte 32\n.byte 52\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 51\n.byte 43\n.byte 49\n.byte 44\n.byte 32\n.byte 52\n.byte 43\n.byte 50\n.byte 42\n.byte 40\n.byte 45\n.byte 50\n.byte 41\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 52\n.byte 45\n.byte 51\n.byte 45\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 0\n.align 3\nL.20:\n.word 0x3f50624d\n.word 0xd2f1a9fc\n.align 0\nL.19:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 45\n.byte 48\n.byte 46\n.byte 48\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 78\n.byte 111\n.byte 110\n.byte 45\n.byte 122\n.byte 101\n.byte 114\n.byte 111\n.byte 33\n.byte 10\n.byte 0\n.align 0\nL.14:\n.byte 48\n.byte 43\n.byte 48\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 49\n.byte 45\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 49\n.byte 32\n.byte 60\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 49\n.byte 43\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 50\n.byte 0\n.align 0\nL.12:\n.byte 80\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 119\n.byte 32\n.byte 82\n.byte 85\n.byte 78\n.byte 78\n.byte 73\n.byte 78\n.byte 71\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 110\n.byte 32\n.byte 115\n.byte 109\n.byte 97\n.byte 108\n.byte 108\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 115\n.byte 58\n.byte 10\n.byte 0\n.align 3\nL.8:\n.word 0x3ff00000\n.word 0x0\n.align 3\nL.7:\n.word 0x0\n.word 0x0\n.align 0\nL.2:\n.byte 10\n.byte 42\n.byte 32\n.byte 42\n.byte 32\n.byte 42\n.byte 32\n.byte 70\n.byte 76\n.byte 79\n.byte 65\n.byte 84\n.byte 73\n.byte 78\n.byte 71\n.byte 45\n.byte 80\n.byte 79\n.byte 73\n.byte 78\n.byte 84\n.byte 32\n.byte 69\n.byte 82\n.byte 82\n.byte 79\n.byte 82\n.byte 32\n.byte 42\n.byte 32\n.byte 42\n.byte 32\n.byte 42\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/mips/irix/tst/sort.1bk",
    "content": "exchange(1,9)\nexchange(3,7)\nexchange(5,6)\nexchange(0,5)\nexchange(0,3)\nexchange(0,0)\nexchange(1,2)\nexchange(6,6)\nexchange(8,9)\nexchange(7,8)\n-51\n-1\n0\n1\n3\n10\n18\n32\n567\n789\n"
  },
  {
    "path": "lcc/mips/irix/tst/sort.2bk",
    "content": "tst/sort.c:23: warning: missing return value\ntst/sort.c:30: warning: missing return value\ntst/sort.c:37: warning: missing return value\ntst/sort.c:41: warning: missing return value\ntst/sort.c:65: warning: missing return value\n"
  },
  {
    "path": "lcc/mips/irix/tst/sort.sbk",
    "content": ".set reorder\n.globl in\n.data\n.align 2\nin:\n.word 0xa\n.word 0x20\n.word 0xffffffff\n.word 0x237\n.word 0x3\n.word 0x12\n.word 0x1\n.word 0xffffffcd\n.word 0x315\n.word 0x0\n.globl main\n.text\n.text\n.align 2\n.ent main\nmain:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2000000,-8\n.cprestore 16\nsw $30,20($sp)\nsw $31,24($sp)\nla $4,in\nla $5,10\njal sort\nmove $30,$0\nb L.5\nL.2:\nsll $24,$30,2\nlw $4,in($24)\njal putd\nla $4,10\njal putchar\nL.3:\nla $30,1($30)\nL.5:\nmove $24,$30\nla $15,10\nbltu $24,$15,L.2\nmove $2,$0\nL.1:\nlw $25,16($sp)\nlw $30,20($sp)\nlw $31,24($sp)\naddu $sp,$sp,32\nj $31\n.end main\n.globl putd\n.text\n.align 2\n.ent putd\nputd:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2000000,-8\n.cprestore 16\nsw $30,20($sp)\nsw $31,24($sp)\nmove $30,$4\nbge $30,$0,L.7\nla $4,45\njal putchar\nnegu $30,$30\nL.7:\nla $24,10\ndiv $24,$30,$24\nbeq $24,$0,L.9\nla $24,10\ndiv $4,$30,$24\njal putd\nL.9:\nla $24,10\nrem $24,$30,$24\nla $4,48($24)\njal putchar\nmove $2,$0\nL.6:\nlw $25,16($sp)\nlw $30,20($sp)\nlw $31,24($sp)\naddu $sp,$sp,32\nj $31\n.end putd\n.globl sort\n.text\n.align 2\n.ent sort\nsort:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nsw $4,24($sp)\nsw $5,28($sp)\nlw $24,0+24($sp)\nsw $24,xx\nmove $4,$24\nmove $5,$0\nlw $24,4+24($sp)\nsubu $24,$24,1\nsw $24,4+24($sp)\nmove $6,$24\njal quick\nmove $2,$0\nL.11:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end sort\n.globl quick\n.text\n.align 2\n.ent quick\nquick:\n.frame $sp,40,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-40\n.mask 0xc2e00000,-4\nsw $21,16($sp)\nsw $22,20($sp)\nsw $23,24($sp)\n.cprestore 28\nsw $30,32($sp)\nsw $31,36($sp)\nmove $30,$4\nmove $23,$5\nmove $22,$6\nblt $23,$22,L.13\nb L.12\nL.13:\nmove $4,$30\nmove $5,$23\nmove $6,$22\njal partition\nmove $21,$2\nmove $4,$30\nmove $5,$23\nsubu $6,$21,1\njal quick\nmove $4,$30\nla $5,1($21)\nmove $6,$22\njal quick\nmove $2,$0\nL.12:\nlw $21,16($sp)\nlw $22,20($sp)\nlw $23,24($sp)\nlw $25,28($sp)\nlw $30,32($sp)\nlw $31,36($sp)\naddu $sp,$sp,40\nj $31\n.end quick\n.globl partition\n.text\n.align 2\n.ent partition\npartition:\n.frame $sp,48,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-48\n.mask 0xc2f00000,-8\nsw $20,16($sp)\nsw $21,20($sp)\nsw $22,24($sp)\nsw $23,28($sp)\n.cprestore 32\nsw $30,36($sp)\nsw $31,40($sp)\nmove $30,$4\nmove $23,$5\nmove $22,$6\nla $22,1($22)\nmove $20,$23\nsll $24,$20,2\naddu $24,$24,$30\nlw $21,($24)\nb L.17\nL.16:\nla $23,1($23)\nb L.20\nL.19:\nla $23,1($23)\nL.20:\nsll $24,$23,2\naddu $24,$24,$30\nlw $24,($24)\nblt $24,$21,L.19\nsubu $22,$22,1\nb L.23\nL.22:\nsubu $22,$22,1\nL.23:\nsll $24,$22,2\naddu $24,$24,$30\nlw $24,($24)\nbgt $24,$21,L.22\nbge $23,$22,L.25\nsll $24,$23,2\naddu $4,$24,$30\nsll $24,$22,2\naddu $5,$24,$30\njal exchange\nL.25:\nL.17:\nblt $23,$22,L.16\nsll $24,$20,2\naddu $4,$24,$30\nsll $24,$22,2\naddu $5,$24,$30\njal exchange\nmove $2,$22\nL.15:\nlw $20,16($sp)\nlw $21,20($sp)\nlw $22,24($sp)\nlw $23,28($sp)\nlw $25,32($sp)\nlw $30,36($sp)\nlw $31,40($sp)\naddu $sp,$sp,48\nj $31\n.end partition\n.globl exchange\n.text\n.align 2\n.ent exchange\nexchange:\n.frame $sp,40,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-40\n.mask 0xc2800000,-12\nsw $23,16($sp)\n.cprestore 20\nsw $30,24($sp)\nsw $31,28($sp)\nmove $30,$4\nmove $23,$5\nla $4,L.28\nlw $24,xx\nla $15,4\nmove $14,$30\nsubu $14,$14,$24\ndiv $5,$14,$15\nmove $14,$23\nsubu $24,$14,$24\ndiv $6,$24,$15\njal printf\nlw $24,($30)\nsw $24,-4+40($sp)\nlw $24,($23)\nsw $24,($30)\nlw $24,-4+40($sp)\nsw $24,($23)\nmove $2,$0\nL.27:\nlw $23,16($sp)\nlw $25,20($sp)\nlw $30,24($sp)\nlw $31,28($sp)\naddu $sp,$sp,40\nj $31\n.end exchange\n.globl xx\n.comm xx,4\n.rdata\n.align 0\nL.28:\n.byte 101\n.byte 120\n.byte 99\n.byte 104\n.byte 97\n.byte 110\n.byte 103\n.byte 101\n.byte 40\n.byte 37\n.byte 100\n.byte 44\n.byte 37\n.byte 100\n.byte 41\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/mips/irix/tst/spill.2bk",
    "content": "tst/spill.c:1: warning: missing return value\ntst/spill.c:3: warning: missing return value\ntst/spill.c:5: warning: missing return value\ntst/spill.c:7: warning: missing return value\ntst/spill.c:9: warning: missing return value\ntst/spill.c:17: warning: missing return value\n"
  },
  {
    "path": "lcc/mips/irix/tst/spill.sbk",
    "content": ".set reorder\n.globl main\n.text\n.text\n.align 2\n.ent main\nmain:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nmove $2,$0\nL.1:\nj $31\n.end main\n.globl f\n.text\n.align 2\n.ent f\nf:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0x82000000,-12\n.cprestore 16\nsw $31,20($sp)\nsw $4,32($sp)\njal f\nmove $24,$2\nsw $24,-4+32($sp)\njal f\nlw $15,-4+32($sp)\naddu $24,$15,$2\nsw $24,0+32($sp)\nmove $2,$0\nL.2:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,32\nj $31\n.end f\n.globl f2\n.text\n.align 2\n.ent f2\nf2:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2000000,-8\n.cprestore 16\nsw $30,20($sp)\nsw $31,24($sp)\nsw $4,32($sp)\njal f\nmove $24,$2\nsw $24,-4+32($sp)\nlw $15,0+32($sp)\nbeq $15,$0,L.5\njal f\nmove $24,$2\nmove $30,$24\nb L.6\nL.5:\nla $30,1\nL.6:\nlw $24,-4+32($sp)\naddu $24,$24,$30\nsw $24,0+32($sp)\nmove $2,$0\nL.3:\nlw $25,16($sp)\nlw $30,20($sp)\nlw $31,24($sp)\naddu $sp,$sp,32\nj $31\n.end f2\n.globl f3\n.text\n.align 2\n.ent f3\nf3:\n.frame $sp,72,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-72\n.mask 0xc2ff0000,-16\nsw $16,16($sp)\nsw $17,20($sp)\nsw $18,24($sp)\nsw $19,28($sp)\nsw $20,32($sp)\nsw $21,36($sp)\nsw $22,40($sp)\nsw $23,44($sp)\n.cprestore 48\nsw $30,52($sp)\nsw $31,56($sp)\nsw $4,72($sp)\nsw $5,76($sp)\nmove $30,$0\nmove $23,$0\nmove $22,$0\nmove $21,$0\nmove $20,$0\nmove $19,$0\nmove $18,$0\nmove $17,$0\nmove $16,$0\nsw $0,-4+72($sp)\nlw $24,4+72($sp)\nsw $24,-12+72($sp)\nla $15,4($24)\nsw $15,4+72($sp)\nlw $15,0+72($sp)\nbeq $15,$0,L.9\njal f\nmove $24,$2\nsw $24,-8+72($sp)\nb L.10\nL.9:\nsw $0,-8+72($sp)\nL.10:\nlw $24,-8+72($sp)\nlw $15,-12+72($sp)\nsw $24,($15)\nmove $2,$0\nL.7:\nlw $16,16($sp)\nlw $17,20($sp)\nlw $18,24($sp)\nlw $19,28($sp)\nlw $20,32($sp)\nlw $21,36($sp)\nlw $22,40($sp)\nlw $23,44($sp)\nlw $25,48($sp)\nlw $30,52($sp)\nlw $31,56($sp)\naddu $sp,$sp,72\nj $31\n.end f3\n.globl f4\n.text\n.align 2\n.ent f4\nf4:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0x40fc0000,-8\nsw $18,0($sp)\nsw $19,4($sp)\nsw $20,8($sp)\nsw $21,12($sp)\nsw $22,16($sp)\nsw $23,20($sp)\nsw $30,24($sp)\nmove $30,$0\nmove $23,$0\nmove $22,$0\nmove $21,$0\nmove $20,$0\nmove $19,$0\nlw $24,i\nsll $15,$24,3\nl.d $f18,a($15)\nl.d $f16,b($15)\nl.d $f10,L.15\nadd.d $f8,$f18,$f16\nc.eq.d $f8,$f10; bc1t L.13\nbeq $24,$0,L.13\nsub.d $f18,$f18,$f16\nc.eq.d $f18,$f10; bc1t L.13\nla $18,1\nb L.14\nL.13:\nmove $18,$0\nL.14:\nsw $18,i\nmove $2,$0\nL.11:\nlw $18,0($sp)\nlw $19,4($sp)\nlw $20,8($sp)\nlw $21,12($sp)\nlw $22,16($sp)\nlw $23,20($sp)\nlw $30,24($sp)\naddu $sp,$sp,32\nj $31\n.end f4\n.globl f5\n.text\n.align 2\n.ent f5\nf5:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nlw $24,k\nlw $15,m\nlw $14,A\nmul $13,$24,$15\nsll $13,$13,3\naddu $13,$13,$14\nlw $12,j\nmul $15,$12,$15\nsll $15,$15,3\naddu $15,$15,$14\nlw $14,n\nlw $11,B\nmul $24,$24,$14\nsll $24,$24,3\naddu $24,$24,$11\nmul $14,$12,$14\nsll $14,$14,3\naddu $14,$14,$11\nl.d $f18,($13)\nl.d $f16,($15)\nmul.d $f18,$f18,$f16\nl.d $f16,($24)\nl.d $f10,($14)\nmul.d $f16,$f16,$f10\nadd.d $f18,$f18,$f16\ns.d $f18,x\nl.d $f18,($13)\nl.d $f16,($14)\nmul.d $f18,$f18,$f16\nl.d $f16,($24)\nl.d $f10,($15)\nmul.d $f16,$f16,$f10\nsub.d $f18,$f18,$f16\ns.d $f18,x\nmove $2,$0\nL.16:\nj $31\n.end f5\n.globl x\n.comm x,8\n.globl B\n.comm B,4\n.globl A\n.comm A,4\n.globl n\n.comm n,4\n.globl m\n.comm m,4\n.globl k\n.comm k,4\n.globl j\n.comm j,4\n.globl i\n.comm i,4\n.globl b\n.comm b,80\n.globl a\n.comm a,80\n.rdata\n.align 3\nL.15:\n.word 0x0\n.word 0x0\n"
  },
  {
    "path": "lcc/mips/irix/tst/stdarg.1bk",
    "content": "test 1\ntest 2\ntest 3\ntest 4\ntest 5.000000\n{1 2 3 4} {1 2 3 4} {1 2 3 4} {1 2 3 4} {1 2 3 4} {1 2 3 4}\n"
  },
  {
    "path": "lcc/mips/irix/tst/stdarg.2bk",
    "content": "tst/stdarg.c:51: warning: missing return value\n"
  },
  {
    "path": "lcc/mips/irix/tst/stdarg.sbk",
    "content": ".set reorder\n.globl x\n.data\n.align 2\nx:\n.word 0x1\n.word 0x2\n.word 0x3\n.word 0x4\n.globl main\n.text\n.text\n.align 2\n.ent main\nmain:\n.frame $sp,112,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-112\n.mask 0x82000000,-8\n.cprestore 100\nsw $31,104($sp)\nla $4,L.2\njal print\nla $4,L.3\nla $5,L.4\njal print\nla $4,L.5\nla $5,3\nla $6,10\njal print\nla $4,L.6\nla $5,L.7\nla $6,L.8\nla $7,4\nla $24,10\nsw $24,16($sp)\njal print\nla $4,L.9\nla $5,L.7\nla $6,L.8\nl.d $f18,L.10\ns.d $f18,16($sp)\nla $24,10\nsw $24,24($sp)\njal print\nla $4,L.11\nla $24,x\nmove $8,$24\nlw $3,0($8)\nlw $9,4($8)\nsw $3,4($29)\nsw $9,8($29)\nlw $3,8($8)\nlw $9,12($8)\nsw $3,12($29)\nsw $9,16($29)\nlw $5,4($sp)\nlw $6,8($sp)\nlw $7,12($sp)\nmove $8,$24\nlw $3,0($8)\nlw $9,4($8)\nsw $3,20($29)\nsw $9,24($29)\nlw $3,8($8)\nlw $9,12($8)\nsw $3,28($29)\nsw $9,32($29)\nmove $8,$24\nlw $3,0($8)\nlw $9,4($8)\nsw $3,36($29)\nsw $9,40($29)\nlw $3,8($8)\nlw $9,12($8)\nsw $3,44($29)\nsw $9,48($29)\nmove $8,$24\nlw $3,0($8)\nlw $9,4($8)\nsw $3,52($29)\nsw $9,56($29)\nlw $3,8($8)\nlw $9,12($8)\nsw $3,60($29)\nsw $9,64($29)\nmove $8,$24\nlw $3,0($8)\nlw $9,4($8)\nsw $3,68($29)\nsw $9,72($29)\nlw $3,8($8)\nlw $9,12($8)\nsw $3,76($29)\nsw $9,80($29)\nmove $8,$24\nlw $3,0($8)\nlw $9,4($8)\nsw $3,84($29)\nsw $9,88($29)\nlw $3,8($8)\nlw $9,12($8)\nsw $3,92($29)\nsw $9,96($29)\njal print\nmove $2,$0\nL.1:\nlw $25,100($sp)\nlw $31,104($sp)\naddu $sp,$sp,112\nj $31\n.end main\n.globl print\n.text\n.align 2\n.ent print\nprint:\n.frame $sp,56,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-56\n.mask 0xc2800000,-24\nsw $23,20($sp)\n.cprestore 24\nsw $30,28($sp)\nsw $31,32($sp)\nsw $4,56($sp)\nsw $5,60($sp)\nsw $6,64($sp)\nsw $7,68($sp)\nla $30,4+56($sp)\nb L.18\nL.15:\nlw $24,0+56($sp)\nlb $24,($24)\nla $15,37\nbne $24,$15,L.19\nlw $24,0+56($sp)\nla $24,1($24)\nsw $24,0+56($sp)\nlb $23,($24)\nla $24,115\nbeq $23,$24,L.35\nbgt $23,$24,L.40\nL.39:\nla $24,98\nblt $23,$24,L.21\nla $24,102\nbgt $23,$24,L.21\nsll $24,$23,2\nlw $24,L.41-392($24)\n.cpadd $24\nj $24\n.rdata\n.align 2\nL.41:\n.gpword L.24\n.gpword L.29\n.gpword L.31\n.gpword L.21\n.gpword L.37\n.text\nL.40:\nla $24,119\nbeq $23,$24,L.33\nb L.21\nL.24:\nla $24,16($30)\nmove $30,$24\nla $15,-16+56($sp)\nla $8,-16($24)\nlw $3,0($8)\nlw $9,4($8)\nsw $3,0($15)\nsw $9,4($15)\nlw $3,8($8)\nlw $9,12($8)\nsw $3,8($15)\nsw $9,12($15)\nla $4,L.25\nlw $5,-16+56($sp)\nlw $6,-12+56($sp)\nlw $7,-8+56($sp)\nlw $24,-4+56($sp)\nsw $24,16($sp)\njal printf\nb L.20\nL.29:\nla $4,L.30\nla $24,4($30)\nmove $30,$24\nlb $5,-1($24)\njal printf\nb L.20\nL.31:\nla $4,L.32\nla $24,4($30)\nmove $30,$24\nlw $5,-4($24)\njal printf\nb L.20\nL.33:\nla $4,L.34\nla $24,4($30)\nmove $30,$24\nlh $5,-2($24)\njal printf\nb L.20\nL.35:\nla $4,L.36\nla $24,4($30)\nmove $30,$24\nlw $5,-4($24)\njal printf\nb L.20\nL.37:\nla $4,L.38\nmove $24,$30\nla $24,15($24)\nand $24,$24,0xfffffff8\nmove $30,$24\nl.d $f18,-8($24)\nmfc1.d $6,$f18\njal printf\nb L.20\nL.21:\nla $4,L.30\nlw $24,0+56($sp)\nlb $5,($24)\njal printf\nb L.20\nL.19:\nla $4,L.30\nlw $24,0+56($sp)\nlb $5,($24)\njal printf\nL.20:\nL.16:\nlw $24,0+56($sp)\nla $24,1($24)\nsw $24,0+56($sp)\nL.18:\nlw $24,0+56($sp)\nlb $24,($24)\nbne $24,$0,L.15\nmove $2,$0\nL.12:\nlw $23,20($sp)\nlw $25,24($sp)\nlw $30,28($sp)\nlw $31,32($sp)\naddu $sp,$sp,56\nj $31\n.end print\n.rdata\n.align 0\nL.38:\n.byte 37\n.byte 102\n.byte 0\n.align 0\nL.36:\n.byte 37\n.byte 115\n.byte 0\n.align 0\nL.34:\n.byte 37\n.byte 120\n.byte 0\n.align 0\nL.32:\n.byte 37\n.byte 100\n.byte 0\n.align 0\nL.30:\n.byte 37\n.byte 99\n.byte 0\n.align 0\nL.25:\n.byte 123\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 125\n.byte 0\n.align 0\nL.11:\n.byte 37\n.byte 98\n.byte 32\n.byte 37\n.byte 98\n.byte 32\n.byte 37\n.byte 98\n.byte 32\n.byte 37\n.byte 98\n.byte 32\n.byte 37\n.byte 98\n.byte 32\n.byte 37\n.byte 98\n.byte 10\n.byte 0\n.align 3\nL.10:\n.word 0x40140000\n.word 0x0\n.align 0\nL.9:\n.byte 37\n.byte 115\n.byte 37\n.byte 115\n.byte 32\n.byte 37\n.byte 102\n.byte 37\n.byte 99\n.byte 0\n.align 0\nL.8:\n.byte 115\n.byte 116\n.byte 0\n.align 0\nL.7:\n.byte 116\n.byte 101\n.byte 0\n.align 0\nL.6:\n.byte 37\n.byte 115\n.byte 37\n.byte 115\n.byte 32\n.byte 37\n.byte 119\n.byte 37\n.byte 99\n.byte 0\n.align 0\nL.5:\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 37\n.byte 100\n.byte 37\n.byte 99\n.byte 0\n.align 0\nL.4:\n.byte 50\n.byte 0\n.align 0\nL.3:\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.2:\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 49\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/mips/irix/tst/struct.1bk",
    "content": "(-1,-1) is not within [10,10; 310,310]\n(1,1) is not within [10,10; 310,310]\n(20,300) is within [10,10; 310,310]\n(500,400) is not within [10,10; 310,310]\nab\n"
  },
  {
    "path": "lcc/mips/irix/tst/struct.2bk",
    "content": "tst/struct.c:49: warning: missing return value\ntst/struct.c:68: warning: missing return value\n"
  },
  {
    "path": "lcc/mips/irix/tst/struct.sbk",
    "content": ".set reorder\n.globl addpoint\n.text\n.text\n.align 2\n.ent addpoint\naddpoint:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nsw $5,4($sp)\nsw $6,8($sp)\nsw $7,12($sp)\nlw $24,4+0($sp)\nlw $15,12+0($sp)\naddu $24,$24,$15\nsw $24,4+0($sp)\nlw $24,8+0($sp)\nlw $15,16+0($sp)\naddu $24,$24,$15\nsw $24,8+0($sp)\nla $8,4+0($sp)\nlw $3,0($8)\nlw $9,4($8)\nsw $3,0($4)\nsw $9,4($4)\nL.1:\nj $31\n.end addpoint\n.globl canonrect\n.text\n.align 2\n.ent canonrect\ncanonrect:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0x40e00000,-20\nsw $21,0($sp)\nsw $22,4($sp)\nsw $23,8($sp)\nsw $30,12($sp)\nsw $5,36($sp)\nsw $6,40($sp)\nsw $7,44($sp)\nlw $24,4+32($sp)\nlw $15,12+32($sp)\nbge $24,$15,L.10\nlw $30,4+32($sp)\nb L.11\nL.10:\nlw $30,12+32($sp)\nL.11:\nsw $30,-16+32($sp)\nlw $24,8+32($sp)\nlw $15,16+32($sp)\nbge $24,$15,L.20\nlw $23,8+32($sp)\nb L.21\nL.20:\nlw $23,16+32($sp)\nL.21:\nsw $23,-12+32($sp)\nlw $24,4+32($sp)\nlw $15,12+32($sp)\nble $24,$15,L.26\nlw $22,4+32($sp)\nb L.27\nL.26:\nlw $22,12+32($sp)\nL.27:\nsw $22,-8+32($sp)\nlw $24,8+32($sp)\nlw $15,16+32($sp)\nble $24,$15,L.37\nlw $21,8+32($sp)\nb L.38\nL.37:\nlw $21,16+32($sp)\nL.38:\nsw $21,-4+32($sp)\nla $8,-16+32($sp)\nlw $3,0($8)\nlw $9,4($8)\nsw $3,0($4)\nsw $9,4($4)\nlw $3,8($8)\nlw $9,12($8)\nsw $3,8($4)\nsw $9,12($4)\nL.5:\nlw $21,0($sp)\nlw $22,4($sp)\nlw $23,8($sp)\nlw $30,12($sp)\naddu $sp,$sp,32\nj $31\n.end canonrect\n.globl makepoint\n.text\n.align 2\n.ent makepoint\nmakepoint:\n.frame $sp,8,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-8\nsw $5,-8+8($sp)\nsw $6,-4+8($sp)\nla $8,-8+8($sp)\nlw $3,0($8)\nlw $9,4($8)\nsw $3,0($4)\nsw $9,4($4)\nL.39:\naddu $sp,$sp,8\nj $31\n.end makepoint\n.globl makerect\n.text\n.align 2\n.ent makerect\nmakerect:\n.frame $sp,48,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-48\n.mask 0x82000000,-24\n.cprestore 20\nsw $31,24($sp)\nsw $4,48($sp)\nsw $5,52($sp)\nsw $6,56($sp)\nsw $7,60($sp)\nla $24,-16+48($sp)\nla $8,4+48($sp)\nlw $3,0($8)\nlw $9,4($8)\nsw $3,0($24)\nsw $9,4($24)\nla $24,-8+48($sp)\nla $8,12+48($sp)\nlw $3,0($8)\nlw $9,4($8)\nsw $3,0($24)\nsw $9,4($24)\nlw $4,0+48($sp)\nla $8,-16+48($sp)\nlw $3,0($8)\nlw $9,4($8)\nsw $3,4($29)\nsw $9,8($29)\nlw $3,8($8)\nlw $9,12($8)\nsw $3,12($29)\nsw $9,16($29)\nlw $5,4($sp)\nlw $6,8($sp)\nlw $7,12($sp)\njal canonrect\nL.42:\nlw $25,20($sp)\nlw $31,24($sp)\naddu $sp,$sp,48\nj $31\n.end makerect\n.globl ptinrect\n.text\n.align 2\n.ent ptinrect\nptinrect:\n.frame $sp,8,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-8\n.mask 0x40000000,-8\nsw $30,0($sp)\nsw $4,8($sp)\nsw $5,12($sp)\nsw $6,16($sp)\nsw $7,20($sp)\nlw $24,0+8($sp)\nlw $15,8+8($sp)\nblt $24,$15,L.53\nlw $15,16+8($sp)\nbge $24,$15,L.53\nlw $24,4+8($sp)\nlw $15,12+8($sp)\nblt $24,$15,L.53\nlw $24,4+8($sp)\nlw $15,20+8($sp)\nbge $24,$15,L.53\nla $30,1\nb L.54\nL.53:\nmove $30,$0\nL.54:\nmove $2,$30\nL.45:\nlw $30,0($sp)\naddu $sp,$sp,8\nj $31\n.end ptinrect\n.globl y\n.sdata\n.align 0\ny:\n.byte 97\n.byte 98\n.byte 0\n.globl odd\n.text\n.text\n.align 2\n.ent odd\nodd:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0x82000000,-12\n.cprestore 16\nsw $31,20($sp)\nsw $4,32($sp)\nla $24,-3+32($sp)\nla $8,0+32($sp)\nulhu $3,0($8)\nush $3,0($24)\nlbu $3,2($8)\nsb $3,2($24)\nla $4,L.56\nla $5,-3+32($sp)\njal printf\nmove $2,$0\nL.55:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,32\nj $31\n.end odd\n.rdata\n.align 2\nL.58:\n.word 0x0\n.word 0x0\n.align 2\nL.59:\n.word 0x140\n.word 0x140\n.align 2\nL.60:\n.word 0xffffffff\n.word 0xffffffff\n.word 0x1\n.word 0x1\n.word 0x14\n.word 0x12c\n.word 0x1f4\n.word 0x190\n.globl main\n.text\n.text\n.align 2\n.ent main\nmain:\n.frame $sp,144,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-144\n.mask 0xc2000000,-112\n.cprestore 24\nsw $30,28($sp)\nsw $31,32($sp)\nla $24,-64+144($sp)\nla $8,L.58\nlw $3,0($8)\nlw $9,4($8)\nsw $3,0($24)\nsw $9,4($24)\nla $24,-72+144($sp)\nla $8,L.59\nlw $3,0($8)\nlw $9,4($8)\nsw $3,0($24)\nsw $9,4($24)\nla $24,-32+144($sp)\nla $8,L.60\naddu $8,$8,32\naddu $10,$24,32\nL.76:\naddu $8,$8,-8\naddu $10,$10,-8\nlw $3,0($8)\nlw $9,4($8)\nsw $3,0($10)\nsw $9,4($10)\nbltu $24,$10,L.76\nla $4,-80+144($sp)\nla $24,-10\nmove $5,$24\nmove $6,$24\njal makepoint\nla $4,-88+144($sp)\nla $8,-72+144($sp)\nlw $3,0($8)\nlw $9,4($8)\nsw $3,4($29)\nsw $9,8($29)\nlw $5,4($sp)\nlw $6,8($sp)\nla $8,-80+144($sp)\nlw $3,0($8)\nlw $9,4($8)\nsw $3,12($29)\nsw $9,16($29)\nlw $7,12($sp)\njal addpoint\nla $4,-96+144($sp)\nla $24,10\nmove $5,$24\nmove $6,$24\njal makepoint\nla $4,-104+144($sp)\nla $8,-64+144($sp)\nlw $3,0($8)\nlw $9,4($8)\nsw $3,4($29)\nsw $9,8($29)\nlw $5,4($sp)\nlw $6,8($sp)\nla $8,-96+144($sp)\nlw $3,0($8)\nlw $9,4($8)\nsw $3,12($29)\nsw $9,16($29)\nlw $7,12($sp)\njal addpoint\nla $4,-48+144($sp)\nla $8,-88+144($sp)\nlw $3,0($8)\nlw $9,4($8)\nsw $3,4($29)\nsw $9,8($29)\nlw $5,4($sp)\nlw $6,8($sp)\nla $8,-104+144($sp)\nlw $3,0($8)\nlw $9,4($8)\nsw $3,12($29)\nsw $9,16($29)\nlw $7,12($sp)\njal makerect\nmove $30,$0\nb L.64\nL.61:\nla $4,-56+144($sp)\nsll $24,$30,3\nla $15,-32+144($sp)\naddu $15,$24,$15\nlw $5,($15)\nla $15,-28+144($sp)\naddu $24,$24,$15\nlw $6,($24)\njal makepoint\nla $4,L.65\nsll $24,$30,3\nla $15,-32+144($sp)\naddu $24,$24,$15\nlw $5,($24)\nlw $6,-52+144($sp)\njal printf\nla $8,-56+144($sp)\nlw $3,0($8)\nlw $9,4($8)\nsw $3,0($29)\nsw $9,4($29)\nlw $4,0($sp)\nlw $5,4($sp)\nla $8,-48+144($sp)\nlw $3,0($8)\nlw $9,4($8)\nsw $3,8($29)\nsw $9,12($29)\nlw $3,8($8)\nlw $9,12($8)\nsw $3,16($29)\nsw $9,20($29)\nlw $6,8($sp)\nlw $7,12($sp)\njal ptinrect\nbne $2,$0,L.68\nla $4,L.70\njal printf\nL.68:\nla $4,L.71\nlw $5,-48+144($sp)\nlw $6,-44+144($sp)\nlw $7,-40+144($sp)\nlw $24,-36+144($sp)\nsw $24,16($sp)\njal printf\nL.62:\nla $30,1($30)\nL.64:\nmove $24,$30\nla $15,4\nbltu $24,$15,L.61\nla $8,y\nulhu $3,0($8)\nsh $3,0($29)\nlbu $3,2($8)\nsb $3,2($29)\nlw $4,0($sp)\njal odd\nmove $4,$0\njal exit\nmove $2,$0\nL.57:\nlw $25,24($sp)\nlw $30,28($sp)\nlw $31,32($sp)\naddu $sp,$sp,144\nj $31\n.end main\n.rdata\n.align 0\nL.71:\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 105\n.byte 110\n.byte 32\n.byte 91\n.byte 37\n.byte 100\n.byte 44\n.byte 37\n.byte 100\n.byte 59\n.byte 32\n.byte 37\n.byte 100\n.byte 44\n.byte 37\n.byte 100\n.byte 93\n.byte 10\n.byte 0\n.align 0\nL.70:\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 0\n.align 0\nL.65:\n.byte 40\n.byte 37\n.byte 100\n.byte 44\n.byte 37\n.byte 100\n.byte 41\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 0\n.align 0\nL.56:\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/mips/irix/tst/switch.1bk",
    "content": "b = 0x8\nf = 0xc\nn = 0xa\nr = 0xd\nt = 0x9\nv = 0xb\nx = 0x78\nf:\nx = 0\nx = 1\nx = 2\nx = 2\nx = 2\nx = 2\nx = 2\nx = 7\nx = 8\nx = 9\nx = 9\nx = 9\nx = 9\nx = 9\nx = 9\nx = 9\nx = 16\nx = 17\nx = 18\nx = 19\nx = 20\ng:\n1 1\n1 2\n2 3\n2 4\n2 5\n3 6\nd 6\n3 7\nd 7\n3 8\nd 8\nd 9\nd 10\nh:\ni = 8\ni = 16\ni = 120\ni = 128\ni = 248\ni = 264\ni = 272\ni = 280\ni = 288\ni = 296\ni = 304\ni = 312\n488 defaults\nx = 0x1000000\nx = 0x2000000\nx = 0x3000000\nx = 0x4000000\nx = 0x5000000\nx = 0x6000000 (default)\nx = 0x7000000 (default)\n0\n1\n2\n3\n4\n5\n0\n1\n2\n3\n4\n5\n"
  },
  {
    "path": "lcc/mips/irix/tst/switch.2bk",
    "content": "tst/switch.c:55: warning: missing return value\ntst/switch.c:73: warning: missing return value\ntst/switch.c:97: warning: missing return value\ntst/switch.c:112: warning: missing return value\ntst/switch.c:137: warning: missing return value\n"
  },
  {
    "path": "lcc/mips/irix/tst/switch.sbk",
    "content": ".set reorder\n.globl main\n.text\n.text\n.align 2\n.ent main\nmain:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2800000,-4\nsw $23,16($sp)\n.cprestore 20\nsw $30,24($sp)\nsw $31,28($sp)\nla $30,L.6\nb L.5\nL.2:\nlb $4,($30)\njal backslash\nmove $24,$2\nla $4,L.7\nlb $5,($30)\nmove $6,$24\njal printf\nL.3:\nla $30,1($30)\nL.5:\nlb $24,($30)\nbne $24,$0,L.2\njal f\njal g\njal h\nla $23,16777216\nb L.11\nL.8:\nmove $4,$23\njal big\nL.9:\nla $23,16777216($23)\nL.11:\nand $24,$23,117440512\nbne $24,$0,L.8\njal limit\nmove $2,$0\nL.1:\nlw $23,16($sp)\nlw $25,20($sp)\nlw $30,24($sp)\nlw $31,28($sp)\naddu $sp,$sp,32\nj $31\n.end main\n.globl backslash\n.text\n.align 2\n.ent backslash\nbackslash:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nla $24,102\nbeq $4,$24,L.16\nbgt $4,$24,L.22\nL.21:\nla $24,98\nbeq $4,$24,L.15\nb L.13\nL.22:\nla $24,110\nbeq $4,$24,L.17\nblt $4,$24,L.13\nL.23:\nla $24,114\nbeq $4,$24,L.18\nla $24,116\nbeq $4,$24,L.19\nla $24,118\nbeq $4,$24,L.20\nb L.13\nL.15:\nla $2,8\nb L.12\nL.16:\nla $2,12\nb L.12\nL.17:\nla $2,10\nb L.12\nL.18:\nla $2,13\nb L.12\nL.19:\nla $2,9\nb L.12\nL.20:\nla $2,11\nb L.12\nL.13:\nmove $2,$4\nL.12:\nj $31\n.end backslash\n.globl f\n.text\n.align 2\n.ent f\nf:\n.frame $sp,40,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-40\n.mask 0xc2c00000,-8\nsw $22,16($sp)\nsw $23,20($sp)\n.cprestore 24\nsw $30,28($sp)\nsw $31,32($sp)\nmove $23,$0\nla $4,L.25\njal printf\nmove $30,$0\nL.26:\nmove $22,$30\nla $24,1\nblt $30,$24,L.30\nla $24,20\nbgt $30,$24,L.30\nsll $24,$30,2\nlw $24,L.42-4($24)\n.cpadd $24\nj $24\n.rdata\n.align 2\nL.42:\n.gpword L.32\n.gpword L.33\n.gpword L.30\n.gpword L.30\n.gpword L.30\n.gpword L.30\n.gpword L.34\n.gpword L.35\n.gpword L.36\n.gpword L.30\n.gpword L.30\n.gpword L.30\n.gpword L.30\n.gpword L.30\n.gpword L.30\n.gpword L.37\n.gpword L.38\n.gpword L.39\n.gpword L.40\n.gpword L.41\n.text\nL.32:\nmove $23,$30\nb L.31\nL.33:\nmove $23,$30\nb L.31\nL.34:\nmove $23,$30\nb L.31\nL.35:\nmove $23,$30\nb L.31\nL.36:\nmove $23,$30\nb L.31\nL.37:\nmove $23,$30\nb L.31\nL.38:\nmove $23,$30\nb L.31\nL.39:\nmove $23,$30\nb L.31\nL.40:\nmove $23,$30\nb L.31\nL.41:\nmove $23,$30\nL.30:\nL.31:\nla $4,L.44\nmove $5,$23\njal printf\nL.27:\nla $30,1($30)\nla $24,20\nble $30,$24,L.26\nmove $2,$0\nL.24:\nlw $22,16($sp)\nlw $23,20($sp)\nlw $25,24($sp)\nlw $30,28($sp)\nlw $31,32($sp)\naddu $sp,$sp,40\nj $31\n.end f\n.globl g\n.text\n.align 2\n.ent g\ng:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2000000,-8\n.cprestore 16\nsw $30,20($sp)\nsw $31,24($sp)\nla $4,L.46\njal printf\nla $30,1\nL.47:\nla $24,1001\nblt $30,$24,L.64\nla $24,1004\nbgt $30,$24,L.65\nsll $24,$30,2\nlw $24,L.66-4004($24)\n.cpadd $24\nj $24\n.rdata\n.align 2\nL.66:\n.gpword L.60\n.gpword L.60\n.gpword L.60\n.gpword L.60\n.text\nL.64:\nla $24,1\nblt $30,$24,L.51\nla $24,8\nbgt $30,$24,L.51\nsll $24,$30,2\nlw $24,L.68-4($24)\n.cpadd $24\nj $24\n.rdata\n.align 2\nL.68:\n.gpword L.53\n.gpword L.53\n.gpword L.55\n.gpword L.55\n.gpword L.55\n.gpword L.57\n.gpword L.57\n.gpword L.57\n.text\nL.65:\nla $24,3001\nblt $30,$24,L.51\nla $24,3004\nbgt $30,$24,L.51\nsll $24,$30,2\nlw $24,L.70-12004($24)\n.cpadd $24\nj $24\n.rdata\n.align 2\nL.70:\n.gpword L.62\n.gpword L.62\n.gpword L.62\n.gpword L.62\n.text\nL.53:\nla $4,L.54\nmove $5,$30\njal printf\nb L.52\nL.55:\nla $4,L.56\nmove $5,$30\njal printf\nb L.52\nL.57:\nla $4,L.58\nmove $5,$30\njal printf\nL.51:\nla $4,L.59\nmove $5,$30\njal printf\nb L.52\nL.60:\nla $4,L.61\nmove $5,$30\njal printf\nb L.52\nL.62:\nla $4,L.63\nmove $5,$30\njal printf\nL.52:\nL.48:\nla $30,1($30)\nla $24,10\nble $30,$24,L.47\nmove $2,$0\nL.45:\nlw $25,16($sp)\nlw $30,20($sp)\nlw $31,24($sp)\naddu $sp,$sp,32\nj $31\n.end g\n.globl h\n.text\n.align 2\n.ent h\nh:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2800000,-4\nsw $23,16($sp)\n.cprestore 20\nsw $30,24($sp)\nsw $31,28($sp)\nmove $23,$0\nla $4,L.73\njal printf\nla $30,1\nL.74:\nla $24,264\nbeq $30,$24,L.86\nbgt $30,$24,L.94\nL.93:\nla $24,120\nbeq $30,$24,L.84\nbgt $30,$24,L.96\nL.95:\nla $24,8\nbeq $30,$24,L.83\nblt $30,$24,L.78\nL.97:\nla $24,16\nbeq $30,$24,L.82\nb L.78\nL.96:\nla $24,128\nbeq $30,$24,L.80\nblt $30,$24,L.78\nL.98:\nla $24,248\nbeq $30,$24,L.87\nb L.78\nL.94:\nla $24,288\nbeq $30,$24,L.91\nbgt $30,$24,L.100\nL.99:\nla $24,272\nbeq $30,$24,L.88\nblt $30,$24,L.78\nL.101:\nla $24,280\nbeq $30,$24,L.85\nb L.78\nL.100:\nla $24,304\nbeq $30,$24,L.89\nbgt $30,$24,L.103\nL.102:\nla $24,296\nbeq $30,$24,L.90\nb L.78\nL.103:\nla $24,312\nbeq $30,$24,L.92\nb L.78\nL.78:\nla $23,1($23)\nb L.75\nL.80:\nla $4,L.81\nmove $5,$30\njal printf\nb L.79\nL.82:\nla $4,L.81\nmove $5,$30\njal printf\nb L.79\nL.83:\nla $4,L.81\nmove $5,$30\njal printf\nb L.79\nL.84:\nla $4,L.81\nmove $5,$30\njal printf\nb L.79\nL.85:\nla $4,L.81\nmove $5,$30\njal printf\nb L.79\nL.86:\nla $4,L.81\nmove $5,$30\njal printf\nb L.79\nL.87:\nla $4,L.81\nmove $5,$30\njal printf\nb L.79\nL.88:\nla $4,L.81\nmove $5,$30\njal printf\nb L.79\nL.89:\nla $4,L.81\nmove $5,$30\njal printf\nb L.79\nL.90:\nla $4,L.81\nmove $5,$30\njal printf\nb L.79\nL.91:\nla $4,L.81\nmove $5,$30\njal printf\nb L.79\nL.92:\nla $4,L.81\nmove $5,$30\njal printf\nL.79:\nL.75:\nla $30,1($30)\nla $24,500\nble $30,$24,L.74\nla $4,L.104\nmove $5,$23\njal printf\nmove $2,$0\nL.72:\nlw $23,16($sp)\nlw $25,20($sp)\nlw $30,24($sp)\nlw $31,28($sp)\naddu $sp,$sp,32\nj $31\n.end h\n.globl big\n.text\n.align 2\n.ent big\nbig:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2000000,-8\n.cprestore 16\nsw $30,20($sp)\nsw $31,24($sp)\nsw $4,32($sp)\nlw $24,0+32($sp)\nand $30,$24,0x6000000\nla $15,33554432\nbeq $30,$15,L.111\nbgt $30,$15,L.115\nL.114:\nla $15,-2\nbeq $30,$15,L.109\nla $15,-1\nbeq $30,$15,L.109\nbeq $30,$0,L.109\nb L.106\nL.115:\nmove $24,$30\nla $15,67108864\nbeq $24,$15,L.112\nb L.106\nL.109:\nla $4,L.110\nlw $5,0+32($sp)\njal printf\nb L.107\nL.111:\nla $4,L.110\nlw $5,0+32($sp)\njal printf\nb L.107\nL.112:\nla $4,L.110\nlw $5,0+32($sp)\njal printf\nb L.107\nL.106:\nla $4,L.113\nlw $5,0+32($sp)\njal printf\nL.107:\nmove $2,$0\nL.105:\nlw $25,16($sp)\nlw $30,20($sp)\nlw $31,24($sp)\naddu $sp,$sp,32\nj $31\n.end big\n.globl limit\n.text\n.align 2\n.ent limit\nlimit:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2000000,-8\n.cprestore 16\nsw $30,20($sp)\nsw $31,24($sp)\nla $30,-2147483648\nL.117:\nla $24,-2147483648\nblt $30,$24,L.121\nla $15,-2147483644\nbgt $30,$15,L.121\nsll $15,$30,2\nsll $24,$24,2\nsubu $24,$15,$24\nlw $24,L.134($24)\n.cpadd $24\nj $24\n.rdata\n.align 2\nL.134:\n.gpword L.123\n.gpword L.125\n.gpword L.127\n.gpword L.129\n.gpword L.131\n.text\nL.123:\nla $4,L.124\njal printf\nb L.122\nL.125:\nla $4,L.126\njal printf\nb L.122\nL.127:\nla $4,L.128\njal printf\nb L.122\nL.129:\nla $4,L.130\njal printf\nb L.122\nL.131:\nla $4,L.132\njal printf\nb L.122\nL.121:\nla $4,L.133\njal printf\nL.122:\nL.118:\nla $30,1($30)\nla $24,-2147483643\nble $30,$24,L.117\nla $30,2147483647\nL.135:\nla $24,2147483643\nblt $30,$24,L.139\nla $15,2147483647\nbgt $30,$15,L.139\nsll $15,$30,2\nsll $24,$24,2\nsubu $24,$15,$24\nlw $24,L.146($24)\n.cpadd $24\nj $24\n.rdata\n.align 2\nL.146:\n.gpword L.145\n.gpword L.144\n.gpword L.143\n.gpword L.142\n.gpword L.141\n.text\nL.141:\nla $4,L.124\njal printf\nb L.140\nL.142:\nla $4,L.126\njal printf\nb L.140\nL.143:\nla $4,L.128\njal printf\nb L.140\nL.144:\nla $4,L.130\njal printf\nb L.140\nL.145:\nla $4,L.132\njal printf\nb L.140\nL.139:\nla $4,L.133\njal printf\nL.140:\nL.136:\nsubu $30,$30,1\nla $24,2147483642\nbge $30,$24,L.135\nmove $2,$0\nL.116:\nlw $25,16($sp)\nlw $30,20($sp)\nlw $31,24($sp)\naddu $sp,$sp,32\nj $31\n.end limit\n.rdata\n.align 0\nL.133:\n.byte 53\n.byte 10\n.byte 0\n.align 0\nL.132:\n.byte 52\n.byte 10\n.byte 0\n.align 0\nL.130:\n.byte 51\n.byte 10\n.byte 0\n.align 0\nL.128:\n.byte 50\n.byte 10\n.byte 0\n.align 0\nL.126:\n.byte 49\n.byte 10\n.byte 0\n.align 0\nL.124:\n.byte 48\n.byte 10\n.byte 0\n.align 0\nL.113:\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 120\n.byte 37\n.byte 120\n.byte 32\n.byte 40\n.byte 100\n.byte 101\n.byte 102\n.byte 97\n.byte 117\n.byte 108\n.byte 116\n.byte 41\n.byte 10\n.byte 0\n.align 0\nL.110:\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 120\n.byte 37\n.byte 120\n.byte 10\n.byte 0\n.align 0\nL.104:\n.byte 37\n.byte 100\n.byte 32\n.byte 100\n.byte 101\n.byte 102\n.byte 97\n.byte 117\n.byte 108\n.byte 116\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.81:\n.byte 105\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.73:\n.byte 104\n.byte 58\n.byte 10\n.byte 0\n.align 0\nL.63:\n.byte 54\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.61:\n.byte 53\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.59:\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.58:\n.byte 51\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.56:\n.byte 50\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.54:\n.byte 49\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.46:\n.byte 103\n.byte 58\n.byte 10\n.byte 0\n.align 0\nL.44:\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.25:\n.byte 102\n.byte 58\n.byte 10\n.byte 0\n.align 0\nL.7:\n.byte 37\n.byte 99\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 120\n.byte 37\n.byte 120\n.byte 10\n.byte 0\n.align 0\nL.6:\n.byte 98\n.byte 102\n.byte 110\n.byte 114\n.byte 116\n.byte 118\n.byte 120\n.byte 0\n"
  },
  {
    "path": "lcc/mips/irix/tst/wf1.1bk",
    "content": "5\ta\n2\tand\n5\tbuf\n16\tc\n8\tchar\n1\tcompare\n4\tcond\n5\tcount\n1\td\n1\tdie\n3\telse\n1\tentry\n1\teof\n4\terr\n1\terror\n1\texit\n1\tfolded\n1\tfor\n1\tfree\n1\tfrequencies\n1\tfrequency\n1\tget\n2\tgetchar\n3\tgetword\n14\tif\n2\tin\n1\tindex\n1\tinput\n1\tinstall\n8\tint\n1\tinto\n1\tis\n4\tisletter\n1\tit\n1\titself\n5\tleft\n1\tletter\n7\tlookup\n1\tmain\n2\tmalloc\n1\tmessage\n2\tn\n1\tnecessary\n12\tnext\n9\tnode\n4\tof\n1\ton\n1\tor\n1\totherwise\n2\tout\n8\tp\n3\tprint\n2\tprintf\n16\treturn\n5\tright\n4\troot\n25\ts\n2\tstorage\n3\tstrcmp\n1\tstrcpy\n1\tstrlen\n8\tstruct\n1\tstructures\n2\tsubtree\n1\tt\n5\ttprint\n9\ttree\n1\tuses\n1\tversion\n1\twf\n3\twhile\n21\tword\n9\twords\n2\tz\n"
  },
  {
    "path": "lcc/mips/irix/tst/wf1.2bk",
    "content": "tst/wf1.c:29: warning: missing return value\ntst/wf1.c:87: warning: missing return value\n"
  },
  {
    "path": "lcc/mips/irix/tst/wf1.sbk",
    "content": ".set reorder\n.globl main\n.text\n.text\n.align 2\n.ent main\nmain:\n.frame $sp,48,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-48\n.mask 0x82000000,-28\n.cprestore 16\nsw $31,20($sp)\nsw $0,-24+48($sp)\nsw $0,next\nb L.3\nL.2:\nla $4,-20+48($sp)\nla $5,-24+48($sp)\njal lookup\nlw $15,($2)\nla $15,1($15)\nsw $15,($2)\nL.3:\nla $4,-20+48($sp)\njal getword\nbne $2,$0,L.2\nlw $4,-24+48($sp)\njal tprint\nmove $2,$0\nL.1:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,48\nj $31\n.end main\n.globl err\n.text\n.align 2\n.ent err\nerr:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nsw $4,24($sp)\nla $4,L.6\nlw $5,0+24($sp)\njal printf\nla $4,1\njal exit\nmove $2,$0\nL.5:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end err\n.globl getword\n.text\n.align 2\n.ent getword\ngetword:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2800000,-4\nsw $23,16($sp)\n.cprestore 20\nsw $30,24($sp)\nsw $31,28($sp)\nsw $4,32($sp)\nL.8:\nL.9:\njal getchar\nmove $24,$2\nmove $30,$24\nla $15,-1\nbeq $24,$15,L.11\nmove $4,$30\njal isletter\nbeq $2,$0,L.8\nL.11:\nlw $23,0+32($sp)\nb L.15\nL.12:\nmove $24,$23\nla $23,1($24)\nmove $15,$30\nsb $15,($24)\nL.13:\njal getchar\nmove $30,$2\nL.15:\nmove $4,$30\njal isletter\nmove $30,$2\nbne $2,$0,L.12\nsb $0,($23)\nmove $24,$23\nlw $15,0+32($sp)\nbleu $24,$15,L.16\nla $2,1\nb L.7\nL.16:\nmove $2,$0\nL.7:\nlw $23,16($sp)\nlw $25,20($sp)\nlw $30,24($sp)\nlw $31,28($sp)\naddu $sp,$sp,32\nj $31\n.end getword\n.globl isletter\n.text\n.align 2\n.ent isletter\nisletter:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nla $24,65\nblt $4,$24,L.19\nla $24,90\nbgt $4,$24,L.19\nla $4,32($4)\nL.19:\nla $24,97\nblt $4,$24,L.21\nla $24,122\nbgt $4,$24,L.21\nmove $2,$4\nb L.18\nL.21:\nmove $2,$0\nL.18:\nj $31\n.end isletter\n.globl lookup\n.text\n.align 2\n.ent lookup\nlookup:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2000000,-8\n.cprestore 16\nsw $30,20($sp)\nsw $31,24($sp)\nsw $4,32($sp)\nmove $30,$5\nlw $24,($30)\nbeq $24,$0,L.24\nlw $4,0+32($sp)\nlw $24,($30)\nlw $5,12($24)\njal strcmp\nsw $2,-4+32($sp)\nlw $24,-4+32($sp)\nbge $24,$0,L.26\nlw $4,0+32($sp)\nlw $24,($30)\nla $5,4($24)\njal lookup\nmove $24,$2\nb L.23\nL.26:\nlw $24,-4+32($sp)\nble $24,$0,L.28\nlw $4,0+32($sp)\nlw $24,($30)\nla $5,8($24)\njal lookup\nmove $24,$2\nb L.23\nL.28:\nlw $2,($30)\nb L.23\nL.24:\nlw $24,next\nla $15,2000\nblt $24,$15,L.30\nla $4,L.32\njal err\nL.30:\nlw $24,next\nsll $24,$24,4\nsw $0,words($24)\nlw $24,next\nsll $24,$24,4\nsw $0,words+8($24)\nsw $0,words+4($24)\nlw $4,0+32($sp)\njal strlen\nmove $24,$2\nla $4,1($24)\njal malloc\nlw $15,next\nsll $15,$15,4\nsw $2,words+12($15)\nlw $24,next\nsll $24,$24,4\nlw $24,words+12($24)\nbne $24,$0,L.36\nla $4,L.39\njal err\nL.36:\nlw $24,next\nsll $24,$24,4\nlw $4,words+12($24)\nlw $5,0+32($sp)\njal strcpy\nlw $24,next\nla $15,1($24)\nsw $15,next\nsll $24,$24,4\nla $24,words($24)\nsw $24,($30)\nmove $2,$24\nL.23:\nlw $25,16($sp)\nlw $30,20($sp)\nlw $31,24($sp)\naddu $sp,$sp,32\nj $31\n.end lookup\n.globl tprint\n.text\n.align 2\n.ent tprint\ntprint:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2000000,-8\n.cprestore 16\nsw $30,20($sp)\nsw $31,24($sp)\nmove $30,$4\nmove $24,$30\nbeq $24,$0,L.42\nlw $4,4($30)\njal tprint\nla $4,L.44\nlw $5,($30)\nlw $6,12($30)\njal printf\nlw $4,8($30)\njal tprint\nL.42:\nmove $2,$0\nL.41:\nlw $25,16($sp)\nlw $30,20($sp)\nlw $31,24($sp)\naddu $sp,$sp,32\nj $31\n.end tprint\n.globl strcmp\n.text\n.align 2\n.ent strcmp\nstrcmp:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nb L.47\nL.46:\nmove $24,$4\nla $4,1($24)\nlb $24,($24)\nbne $24,$0,L.49\nmove $2,$0\nb L.45\nL.49:\nla $5,1($5)\nL.47:\nlb $24,($4)\nlb $15,($5)\nbeq $24,$15,L.46\nlb $24,($4)\nbne $24,$0,L.51\nla $2,-1\nb L.45\nL.51:\nlb $24,($5)\nbne $24,$0,L.53\nla $2,1\nb L.45\nL.53:\nlb $24,($4)\nlb $15,($5)\nsubu $2,$24,$15\nL.45:\nj $31\n.end strcmp\n.globl next\n.comm next,4\n.globl words\n.comm words,32000\n.rdata\n.align 0\nL.44:\n.byte 37\n.byte 100\n.byte 9\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.39:\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 119\n.byte 111\n.byte 114\n.byte 100\n.byte 32\n.byte 115\n.byte 116\n.byte 111\n.byte 114\n.byte 97\n.byte 103\n.byte 101\n.byte 0\n.align 0\nL.32:\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 110\n.byte 111\n.byte 100\n.byte 101\n.byte 32\n.byte 115\n.byte 116\n.byte 111\n.byte 114\n.byte 97\n.byte 103\n.byte 101\n.byte 0\n.align 0\nL.6:\n.byte 63\n.byte 32\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/mips/irix/tst/yacc.1bk",
    "content": "a\nb\nload\nnegate\npush 5\nc\nload\nmultiply\nadd\nstore\n"
  },
  {
    "path": "lcc/mips/irix/tst/yacc.2bk",
    "content": "tst/yacc.c:345: warning: missing return value\ntst/yacc.c:349: warning: missing return value\ntst/yacc.c:359: warning: missing return value\n"
  },
  {
    "path": "lcc/mips/irix/tst/yacc.sbk",
    "content": ".set reorder\n.globl yyin\n.sdata\n.align 2\nyyin:\n.word _iob\n.globl yyout\n.sdata\n.align 2\nyyout:\n.word _iob+16\n.globl yylex\n.text\n.text\n.align 2\n.ent yylex\nyylex:\n.frame $sp,32,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-32\n.mask 0xc2000000,-8\n.cprestore 16\nsw $30,20($sp)\nsw $31,24($sp)\nb L.4\nL.3:\nL.6:\nla $24,-1\nblt $30,$24,L.7\nla $24,4\nbgt $30,$24,L.7\nsll $24,$30,2\nlw $24,L.18+4($24)\n.cpadd $24\nj $24\n.rdata\n.align 2\nL.18:\n.gpword L.8\n.gpword L.9\n.gpword L.12\n.gpword L.13\n.gpword L.8\n.gpword L.15\n.text\nL.9:\njal yywrap\nbeq $2,$0,L.8\nmove $2,$0\nb L.2\nL.12:\nla $2,257\nb L.2\nL.13:\nla $2,258\nb L.2\nL.15:\nlb $2,yytext\nb L.2\nL.7:\nlw $4,yyout\nla $5,L.17\nmove $6,$30\njal fprintf\nL.8:\nL.4:\njal yylook\nmove $30,$2\nbge $2,$0,L.3\nmove $2,$0\nL.2:\nlw $25,16($sp)\nlw $30,20($sp)\nlw $31,24($sp)\naddu $sp,$sp,32\nj $31\n.end yylex\n.globl yyvstop\n.data\n.align 2\nyyvstop:\n.word 0x0\n.word 0x4\n.word 0x0\n.word 0x3\n.word 0x4\n.word 0x0\n.word 0x2\n.word 0x4\n.word 0x0\n.word 0x1\n.word 0x4\n.word 0x0\n.word 0x2\n.word 0x0\n.word 0x1\n.word 0x0\n.word 0x0\n.globl yycrank\n.data\n.align 0\nyycrank:\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x1\n.byte 0x3\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x1\n.byte 0x4\n.byte 0x1\n.byte 0x3\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x1\n.byte 0x5\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x1\n.byte 0x6\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x6\n.byte 0x8\n.byte 0x0\n.byte 0x0\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.globl yysvec\n.data\n.align 2\nyysvec:\n.word 0x0\n.word 0x0\n.word 0x0\n.word yycrank-2\n.word 0x0\n.word 0x0\n.word yycrank\n.word yysvec+12\n.word 0x0\n.word yycrank\n.word 0x0\n.word yyvstop+4\n.word yycrank\n.word 0x0\n.word yyvstop+12\n.word yycrank+4\n.word 0x0\n.word yyvstop+24\n.word yycrank+38\n.word 0x0\n.word yyvstop+36\n.word yycrank\n.word yysvec+60\n.word yyvstop+48\n.word yycrank\n.word yysvec+72\n.word yyvstop+56\n.word 0x0\n.word 0x0\n.word 0x0\n.globl yytop\n.sdata\n.align 2\nyytop:\n.word yycrank+282\n.globl yybgin\n.sdata\n.align 2\nyybgin:\n.word yysvec+12\n.globl yymatch\n.data\n.align 0\nyymatch:\n.byte 0\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 9\n.byte 10\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 9\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 65\n.byte 1\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 0\n.globl yyextra\n.data\n.align 0\nyyextra:\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.globl yylineno\n.sdata\n.align 2\nyylineno:\n.word 0x1\n.globl yysptr\n.sdata\n.align 2\nyysptr:\n.word yysbuf\n.globl yyprevious\n.sdata\n.align 2\nyyprevious:\n.word 0xa\n.globl yylook\n.text\n.text\n.align 2\n.ent yylook\nyylook:\n.frame $sp,72,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-72\n.mask 0xc2ff0000,-16\nsw $16,16($sp)\nsw $17,20($sp)\nsw $18,24($sp)\nsw $19,28($sp)\nsw $20,32($sp)\nsw $21,36($sp)\nsw $22,40($sp)\nsw $23,44($sp)\n.cprestore 48\nsw $30,52($sp)\nsw $31,56($sp)\nlw $24,yymorfg\nbne $24,$0,L.35\nla $21,yytext\nb L.36\nL.35:\nsw $0,yymorfg\nlw $24,yyleng\nla $21,yytext($24)\nL.36:\nL.37:\nla $23,yylstate\nlw $24,yybgin\nmove $30,$24\nsw $24,yyestate\nlw $24,yyprevious\nla $15,10\nbne $24,$15,L.41\nla $30,12($30)\nL.41:\nL.43:\nlw $22,($30)\nmove $24,$22\nla $15,yycrank\nbne $24,$15,L.47\nlw $18,4($30)\nmove $24,$18\nbne $24,$0,L.49\nb L.94\nL.49:\nlw $24,($18)\nla $15,yycrank\nbne $24,$15,L.51\nb L.94\nL.51:\nL.47:\nmove $24,$21\nsw $24,-12+72($sp)\nla $21,1($24)\nlw $15,yysptr\nla $14,yysbuf\nbleu $15,$14,L.61\nlw $15,yysptr\nla $15,-1($15)\nsw $15,yysptr\nlb $15,($15)\nsw $15,-4+72($sp)\nb L.62\nL.61:\nlw $15,yyin\nlw $14,($15)\nsubu $14,$14,1\nsw $14,($15)\nbge $14,$0,L.63\nlw $4,yyin\njal _filbuf\nmove $24,$2\nsw $24,-8+72($sp)\nb L.64\nL.63:\nlw $24,yyin\nla $24,4($24)\nlw $15,($24)\nla $14,1($15)\nsw $14,($24)\nlbu $24,($15)\nsw $24,-8+72($sp)\nL.64:\nlw $24,-8+72($sp)\nsw $24,-4+72($sp)\nL.62:\nlw $24,-4+72($sp)\nsw $24,yytchar\nla $15,10\nbne $24,$15,L.59\nlw $24,yylineno\nla $24,1($24)\nsw $24,yylineno\nlw $16,yytchar\nb L.60\nL.59:\nlw $16,yytchar\nL.60:\nla $24,-1\nbne $16,$24,L.57\nmove $17,$0\nb L.58\nL.57:\nlw $17,yytchar\nL.58:\nmove $20,$17\nmove $24,$17\nlw $15,-12+72($sp)\nsb $24,($15)\nL.65:\nmove $19,$22\nmove $24,$22\nla $15,yycrank\nbleu $24,$15,L.66\nsll $24,$20,1\naddu $22,$24,$19\nmove $24,$22\nlw $15,yytop\nbgtu $24,$15,L.67\nla $24,12\nlb $15,($22)\nmul $24,$24,$15\nla $24,yysvec($24)\nmove $15,$30\nbne $24,$15,L.67\nla $24,yysvec\nla $15,12\nlb $14,1($22)\nmul $15,$15,$14\nla $15,yysvec($15)\nbne $15,$24,L.70\nla $24,-1($21)\nmove $21,$24\nlb $24,($24)\nsw $24,yytchar\nlw $24,yytchar\nla $15,10\nbne $24,$15,L.72\nlw $24,yylineno\nsubu $24,$24,1\nsw $24,yylineno\nL.72:\nlw $24,yysptr\nla $15,1($24)\nsw $15,yysptr\nlw $15,yytchar\nsb $15,($24)\nb L.94\nL.70:\nmove $24,$23\nla $23,4($24)\nla $15,12\nlb $14,1($22)\nmul $15,$15,$14\nla $15,yysvec($15)\nmove $30,$15\nsw $15,($24)\nb L.43\nL.66:\nmove $24,$22\nla $15,yycrank\nbgeu $24,$15,L.75\nla $24,yycrank\nmove $15,$22\nsubu $24,$24,$15\nla $15,2\ndiv $24,$24,$15\nsll $24,$24,1\nla $24,yycrank($24)\nmove $19,$24\nmove $22,$24\nsll $24,$20,1\naddu $22,$24,$22\nmove $24,$22\nlw $15,yytop\nbgtu $24,$15,L.77\nla $24,12\nlb $15,($22)\nmul $24,$24,$15\nla $24,yysvec($24)\nmove $15,$30\nbne $24,$15,L.77\nla $24,yysvec\nla $15,12\nlb $14,1($22)\nmul $15,$15,$14\nla $15,yysvec($15)\nbne $15,$24,L.79\nla $24,-1($21)\nmove $21,$24\nlb $24,($24)\nsw $24,yytchar\nlw $24,yytchar\nla $15,10\nbne $24,$15,L.81\nlw $24,yylineno\nsubu $24,$24,1\nsw $24,yylineno\nL.81:\nlw $24,yysptr\nla $15,1($24)\nsw $15,yysptr\nlw $15,yytchar\nsb $15,($24)\nb L.94\nL.79:\nmove $24,$23\nla $23,4($24)\nla $15,12\nlb $14,1($22)\nmul $15,$15,$14\nla $15,yysvec($15)\nmove $30,$15\nsw $15,($24)\nb L.43\nL.77:\nlb $24,yymatch($20)\nsll $24,$24,1\naddu $22,$24,$19\nmove $24,$22\nlw $15,yytop\nbgtu $24,$15,L.83\nla $24,12\nlb $15,($22)\nmul $24,$24,$15\nla $24,yysvec($24)\nmove $15,$30\nbne $24,$15,L.83\nla $24,yysvec\nla $15,12\nlb $14,1($22)\nmul $15,$15,$14\nla $15,yysvec($15)\nbne $15,$24,L.85\nla $24,-1($21)\nmove $21,$24\nlb $24,($24)\nsw $24,yytchar\nlw $24,yytchar\nla $15,10\nbne $24,$15,L.87\nlw $24,yylineno\nsubu $24,$24,1\nsw $24,yylineno\nL.87:\nlw $24,yysptr\nla $15,1($24)\nsw $15,yysptr\nlw $15,yytchar\nsb $15,($24)\nb L.94\nL.85:\nmove $24,$23\nla $23,4($24)\nla $15,12\nlb $14,1($22)\nmul $15,$15,$14\nla $15,yysvec($15)\nmove $30,$15\nsw $15,($24)\nb L.43\nL.83:\nL.75:\nL.67:\nlw $24,4($30)\nmove $30,$24\nbeq $24,$0,L.89\nlw $24,($30)\nmove $22,$24\nla $15,yycrank\nbeq $24,$15,L.89\nb L.65\nL.89:\nla $24,-1($21)\nmove $21,$24\nlb $24,($24)\nsw $24,yytchar\nlw $24,yytchar\nla $15,10\nbne $24,$15,L.91\nlw $24,yylineno\nsubu $24,$24,1\nsw $24,yylineno\nL.91:\nlw $24,yysptr\nla $15,1($24)\nsw $15,yysptr\nlw $15,yytchar\nsb $15,($24)\nb L.94\nL.93:\nmove $24,$21\nla $21,-1($24)\nsb $0,($24)\nlw $24,($23)\nmove $15,$0\nmove $14,$24\nbeq $14,$15,L.96\nlw $24,8($24)\nsw $24,yyfnd\nbeq $24,$15,L.96\nlw $24,yyfnd\nlw $24,($24)\nble $24,$0,L.96\nsw $23,yyolsp\nlw $24,yyfnd\nlw $24,($24)\nlb $24,yyextra($24)\nbeq $24,$0,L.98\nb L.101\nL.100:\nla $23,-4($23)\nmove $24,$21\nla $21,-1($24)\nlb $24,($24)\nsw $24,yytchar\nlw $24,yytchar\nla $15,10\nbne $24,$15,L.103\nlw $24,yylineno\nsubu $24,$24,1\nsw $24,yylineno\nL.103:\nlw $24,yysptr\nla $15,1($24)\nsw $15,yysptr\nlw $15,yytchar\nsb $15,($24)\nL.101:\nlw $24,($23)\nlw $4,8($24)\nlw $24,yyfnd\nlw $24,($24)\nnegu $5,$24\njal yyback\nla $15,1\nbeq $2,$15,L.105\nmove $24,$23\nla $15,yylstate\nbgtu $24,$15,L.100\nL.105:\nL.98:\nlb $24,($21)\nsw $24,yyprevious\nsw $23,yylsp\nla $24,yytext\nmove $15,$21\nsubu $24,$15,$24\nla $24,1($24)\nsw $24,yyleng\nlw $24,yyleng\nsb $0,yytext($24)\nlw $24,yyfnd\nla $15,4($24)\nsw $15,yyfnd\nlw $2,($24)\nb L.34\nL.96:\nlb $24,($21)\nsw $24,yytchar\nlw $24,yytchar\nla $15,10\nbne $24,$15,L.106\nlw $24,yylineno\nsubu $24,$24,1\nsw $24,yylineno\nL.106:\nlw $24,yysptr\nla $15,1($24)\nsw $15,yysptr\nlw $15,yytchar\nsb $15,($24)\nL.94:\nmove $24,$23\nla $23,-4($24)\nla $15,yylstate\nbgtu $24,$15,L.93\nlb $24,yytext\nbne $24,$0,L.108\nla $24,yysbuf\nsw $24,yysptr\nmove $2,$0\nb L.34\nL.108:\nlw $24,yysptr\nla $15,yysbuf\nbleu $24,$15,L.118\nlw $24,yysptr\nla $24,-1($24)\nsw $24,yysptr\nlb $24,($24)\nsw $24,-4+72($sp)\nb L.119\nL.118:\nlw $24,yyin\nlw $15,($24)\nsubu $15,$15,1\nsw $15,($24)\nbge $15,$0,L.120\nlw $4,yyin\njal _filbuf\nmove $24,$2\nsw $24,-8+72($sp)\nb L.121\nL.120:\nlw $24,yyin\nla $24,4($24)\nlw $15,($24)\nla $14,1($15)\nsw $14,($24)\nlbu $24,($15)\nsw $24,-8+72($sp)\nL.121:\nlw $24,-8+72($sp)\nsw $24,-4+72($sp)\nL.119:\nlw $24,-4+72($sp)\nsw $24,yytchar\nla $15,10\nbne $24,$15,L.116\nlw $24,yylineno\nla $24,1($24)\nsw $24,yylineno\nlw $16,yytchar\nb L.117\nL.116:\nlw $16,yytchar\nL.117:\nla $24,-1\nbne $16,$24,L.114\nmove $17,$0\nb L.115\nL.114:\nlw $17,yytchar\nL.115:\nsb $17,yytext\nsll $24,$17,8*(4-1); sra $24,$24,8*(4-1)\nsw $24,yyprevious\nlw $24,yyprevious\nble $24,$0,L.122\nlw $24,yyout\nlw $15,($24)\nsubu $15,$15,1\nsw $15,($24)\nbge $15,$0,L.125\nlw $24,yyprevious\nand $24,$24,(1<<(8*1))-1\nmove $4,$24\nlw $5,yyout\njal _flsbuf\nb L.126\nL.125:\nlw $24,yyout\nla $24,4($24)\nlw $15,($24)\nla $14,1($15)\nsw $14,($24)\nlw $24,yyprevious\nsb $24,($15)\nL.126:\nL.122:\nla $21,yytext\nb L.37\nL.34:\nlw $16,16($sp)\nlw $17,20($sp)\nlw $18,24($sp)\nlw $19,28($sp)\nlw $20,32($sp)\nlw $21,36($sp)\nlw $22,40($sp)\nlw $23,44($sp)\nlw $25,48($sp)\nlw $30,52($sp)\nlw $31,56($sp)\naddu $sp,$sp,72\nj $31\n.end yylook\n.globl yyback\n.text\n.align 2\n.ent yyback\nyyback:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nmove $24,$4\nbne $24,$0,L.131\nmove $2,$0\nb L.127\nL.130:\nmove $24,$4\nla $4,4($24)\nlw $24,($24)\nbne $24,$5,L.133\nla $2,1\nb L.127\nL.133:\nL.131:\nlw $24,($4)\nbne $24,$0,L.130\nmove $2,$0\nL.127:\nj $31\n.end yyback\n.globl yyinput\n.text\n.align 2\n.ent yyinput\nyyinput:\n.frame $sp,40,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-40\n.mask 0xc2e00000,-4\nsw $21,16($sp)\nsw $22,20($sp)\nsw $23,24($sp)\n.cprestore 28\nsw $30,32($sp)\nsw $31,36($sp)\nlw $24,yysptr\nla $15,yysbuf\nbleu $24,$15,L.144\nlw $24,yysptr\nla $24,-1($24)\nsw $24,yysptr\nlb $22,($24)\nb L.145\nL.144:\nlw $24,yyin\nlw $15,($24)\nsubu $15,$15,1\nsw $15,($24)\nbge $15,$0,L.146\nlw $4,yyin\njal _filbuf\nmove $24,$2\nmove $21,$24\nb L.147\nL.146:\nlw $24,yyin\nla $24,4($24)\nlw $15,($24)\nla $14,1($15)\nsw $14,($24)\nlbu $21,($15)\nL.147:\nmove $22,$21\nL.145:\nsw $22,yytchar\nla $24,10\nbne $22,$24,L.142\nlw $24,yylineno\nla $24,1($24)\nsw $24,yylineno\nlw $23,yytchar\nb L.143\nL.142:\nlw $23,yytchar\nL.143:\nla $24,-1\nbne $23,$24,L.140\nmove $30,$0\nb L.141\nL.140:\nlw $30,yytchar\nL.141:\nmove $2,$30\nL.135:\nlw $21,16($sp)\nlw $22,20($sp)\nlw $23,24($sp)\nlw $25,28($sp)\nlw $30,32($sp)\nlw $31,36($sp)\naddu $sp,$sp,40\nj $31\n.end yyinput\n.globl yyoutput\n.text\n.align 2\n.ent yyoutput\nyyoutput:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nsw $4,24($sp)\nlw $24,yyout\nlw $15,($24)\nsubu $15,$15,1\nsw $15,($24)\nbge $15,$0,L.150\nlw $24,0+24($sp)\nand $24,$24,(1<<(8*1))-1\nmove $4,$24\nlw $5,yyout\njal _flsbuf\nb L.151\nL.150:\nlw $24,yyout\nla $24,4($24)\nlw $15,($24)\nla $14,1($15)\nsw $14,($24)\nlw $24,0+24($sp)\nsb $24,($15)\nL.151:\nmove $2,$0\nL.148:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end yyoutput\n.globl yyunput\n.text\n.align 2\n.ent yyunput\nyyunput:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nsw $4,yytchar\nlw $24,yytchar\nla $15,10\nbne $24,$15,L.153\nlw $24,yylineno\nsubu $24,$24,1\nsw $24,yylineno\nL.153:\nlw $24,yysptr\nla $15,1($24)\nsw $15,yysptr\nlw $15,yytchar\nsb $15,($24)\nmove $2,$0\nL.152:\nj $31\n.end yyunput\n.globl main\n.text\n.align 2\n.ent main\nmain:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\njal yyparse\nmove $2,$0\nL.155:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end main\n.globl yyerror\n.text\n.align 2\n.ent yyerror\nyyerror:\n.frame $sp,24,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-24\n.mask 0x82000000,-4\n.cprestore 16\nsw $31,20($sp)\nsw $4,24($sp)\nla $4,L.157\nlw $5,0+24($sp)\njal printf\nmove $2,$0\nL.156:\nlw $25,16($sp)\nlw $31,20($sp)\naddu $sp,$sp,24\nj $31\n.end yyerror\n.globl yyexca\n.data\n.align 1\nyyexca:\n.half 0xffffffff\n.half 0x1\n.half 0x0\n.half 0xffffffff\n.half 0xfffffffe\n.half 0x0\n.globl yyact\n.data\n.align 1\nyyact:\n.half 0xc\n.half 0x2\n.half 0x9\n.half 0x8\n.half 0x11\n.half 0xb\n.half 0x19\n.half 0x11\n.half 0xf\n.half 0x12\n.half 0x10\n.half 0xa\n.half 0x12\n.half 0x11\n.half 0xf\n.half 0x7\n.half 0x10\n.half 0xd\n.half 0x12\n.half 0x5\n.half 0x3\n.half 0x1\n.half 0x0\n.half 0x13\n.half 0x14\n.half 0x0\n.half 0x0\n.half 0x15\n.half 0x16\n.half 0x17\n.half 0x18\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x6\n.half 0xe\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x4\n.half 0x6\n.globl yypact\n.data\n.align 1\nyypact:\n.half 0xfffffc18\n.half 0xfffffff7\n.half 0xfffffc18\n.half 0x5\n.half 0xfffffff9\n.half 0xffffffc5\n.half 0xfffffc18\n.half 0xfffffc18\n.half 0xfffffc18\n.half 0xffffffd8\n.half 0xffffffe3\n.half 0xffffffd8\n.half 0xffffffd8\n.half 0xfffffc18\n.half 0xfffffc18\n.half 0xffffffd8\n.half 0xffffffd8\n.half 0xffffffd8\n.half 0xffffffd8\n.half 0xffffffda\n.half 0xffffffdd\n.half 0xffffffda\n.half 0xffffffda\n.half 0xfffffc18\n.half 0xfffffc18\n.half 0xfffffc18\n.globl yypgo\n.data\n.align 1\nyypgo:\n.half 0x0\n.half 0x15\n.half 0x14\n.half 0x11\n.half 0xb\n.globl yyr1\n.data\n.align 1\nyyr1:\n.half 0x0\n.half 0x1\n.half 0x1\n.half 0x1\n.half 0x1\n.half 0x2\n.half 0x4\n.half 0x4\n.half 0x4\n.half 0x4\n.half 0x4\n.half 0x4\n.half 0x4\n.half 0x4\n.half 0x3\n.globl yyr2\n.data\n.align 1\nyyr2:\n.half 0x0\n.half 0x0\n.half 0x2\n.half 0x3\n.half 0x3\n.half 0x3\n.half 0x3\n.half 0x3\n.half 0x3\n.half 0x3\n.half 0x2\n.half 0x3\n.half 0x1\n.half 0x1\n.half 0x1\n.globl yychk\n.data\n.align 1\nyychk:\n.half 0xfffffc18\n.half 0xffffffff\n.half 0xa\n.half 0xfffffffe\n.half 0x100\n.half 0xfffffffd\n.half 0x101\n.half 0xa\n.half 0xa\n.half 0x3d\n.half 0xfffffffc\n.half 0x2d\n.half 0x28\n.half 0xfffffffd\n.half 0x102\n.half 0x2b\n.half 0x2d\n.half 0x2a\n.half 0x2f\n.half 0xfffffffc\n.half 0xfffffffc\n.half 0xfffffffc\n.half 0xfffffffc\n.half 0xfffffffc\n.half 0xfffffffc\n.half 0x29\n.globl yydef\n.data\n.align 1\nyydef:\n.half 0x1\n.half 0xfffffffe\n.half 0x2\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0xe\n.half 0x3\n.half 0x4\n.half 0x0\n.half 0x5\n.half 0x0\n.half 0x0\n.half 0xc\n.half 0xd\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0xa\n.half 0x0\n.half 0x6\n.half 0x7\n.half 0x8\n.half 0x9\n.half 0xb\n.globl yychar\n.sdata\n.align 2\nyychar:\n.word 0xffffffff\n.globl yynerrs\n.sdata\n.align 2\nyynerrs:\n.word 0x0\n.globl yyerrflag\n.sdata\n.align 1\nyyerrflag:\n.half 0x0\n.globl yyparse\n.text\n.text\n.align 2\n.ent yyparse\nyyparse:\n.frame $sp,360,$31\n.set noreorder\n.cpload $25\n.set reorder\naddu $sp,$sp,-360\n.mask 0xc2fe0000,-308\nsw $17,16($sp)\nsw $18,20($sp)\nsw $19,24($sp)\nsw $20,28($sp)\nsw $21,32($sp)\nsw $22,36($sp)\nsw $23,40($sp)\n.cprestore 44\nsw $30,48($sp)\nsw $31,52($sp)\nmove $24,$0\nmove $23,$24\nla $15,-1\nsw $15,yychar\nsw $0,yynerrs\nsh $24,yyerrflag\nla $22,-302+360($sp)\nla $20,yyv-4\nL.161:\nla $24,2($22)\nmove $22,$24\nla $15,0+360($sp)\nbleu $24,$15,L.162\nla $4,L.165\njal yyerror\nla $2,1\nb L.158\nL.162:\nsh $23,($22)\nla $20,4($20)\nlw $24,yyval\nsw $24,($20)\nL.166:\nsll $24,$23,8*(4-2); sra $24,$24,8*(4-2)\nsll $24,$24,1\nlh $21,yypact($24)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,-1000\nbgt $24,$15,L.167\nb L.169\nL.167:\nlw $24,yychar\nbge $24,$0,L.170\njal yylex\nsw $2,yychar\nbge $2,$0,L.172\nsw $0,yychar\nL.172:\nL.170:\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nlw $15,yychar\naddu $24,$24,$15\nmove $21,$24\nsll $24,$24,8*(4-2); sra $24,$24,8*(4-2)\nblt $24,$0,L.176\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nla $15,249\nblt $24,$15,L.174\nL.176:\nb L.169\nL.174:\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $24,$24,1\nlh $24,yyact($24)\nmove $21,$24\nsll $24,$24,8*(4-2); sra $24,$24,8*(4-2)\nsll $24,$24,1\nlh $24,yychk($24)\nlw $15,yychar\nbne $24,$15,L.177\nla $24,-1\nsw $24,yychar\nlw $24,yylval\nsw $24,yyval\nmove $23,$21\nlh $24,yyerrflag\nble $24,$0,L.161\nlh $24,yyerrflag\nsubu $24,$24,1\nsh $24,yyerrflag\nb L.161\nL.177:\nL.169:\nsll $24,$23,8*(4-2); sra $24,$24,8*(4-2)\nsll $24,$24,1\nlh $24,yydef($24)\nmove $21,$24\nsll $24,$24,8*(4-2); sra $24,$24,8*(4-2)\nla $15,-2\nbne $24,$15,L.181\nlw $24,yychar\nbge $24,$0,L.183\njal yylex\nsw $2,yychar\nbge $2,$0,L.185\nsw $0,yychar\nL.185:\nL.183:\nla $19,yyexca\nb L.190\nL.187:\nL.188:\nla $19,4($19)\nL.190:\nlh $24,($19)\nla $15,-1\nbne $24,$15,L.187\nlh $24,2($19)\nsll $15,$23,8*(4-2); sra $15,$15,8*(4-2)\nbne $24,$15,L.187\nb L.192\nL.191:\nlh $24,($19)\nlw $15,yychar\nbne $24,$15,L.194\nb L.193\nL.194:\nL.192:\nla $24,4($19)\nmove $19,$24\nlh $24,($24)\nbge $24,$0,L.191\nL.193:\nlh $24,2($19)\nmove $21,$24\nsll $24,$24,8*(4-2); sra $24,$24,8*(4-2)\nbge $24,$0,L.196\nmove $2,$0\nb L.158\nL.196:\nL.181:\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nbne $24,$0,L.198\nlh $17,yyerrflag\nblt $17,$0,L.200\nla $24,3\nbgt $17,$24,L.200\nsll $24,$17,2\nlw $24,L.216($24)\n.cpadd $24\nj $24\n.rdata\n.align 2\nL.216:\n.gpword L.203\n.gpword L.206\n.gpword L.206\n.gpword L.213\n.text\nL.203:\nla $4,L.204\njal yyerror\nL.205:\nlw $24,yynerrs\nla $24,1($24)\nsw $24,yynerrs\nL.206:\nla $24,3\nsh $24,yyerrflag\nb L.208\nL.207:\nlh $24,($22)\nsll $24,$24,1\nlh $24,yypact($24)\nla $24,256($24)\nmove $21,$24\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nblt $24,$0,L.210\nla $15,249\nbge $24,$15,L.210\nsll $24,$24,1\nlh $24,yyact($24)\nsll $24,$24,1\nlh $24,yychk($24)\nla $15,256\nbne $24,$15,L.210\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $24,$24,1\nlh $23,yyact($24)\nb L.161\nL.210:\nlh $24,($22)\nsll $24,$24,1\nlh $21,yypact($24)\nla $22,-2($22)\nla $20,-4($20)\nL.208:\nmove $24,$22\nla $15,-300+360($sp)\nbgeu $24,$15,L.207\nL.212:\nla $2,1\nb L.158\nL.213:\nlw $24,yychar\nbne $24,$0,L.214\nb L.212\nL.214:\nla $24,-1\nsw $24,yychar\nb L.166\nL.200:\nL.198:\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $24,$24,1\nla $15,yyr2($24)\nlh $14,($15)\nsll $14,$14,1\nsubu $22,$22,$14\nmove $30,$20\nlh $15,($15)\nsll $15,$15,2\nsubu $20,$20,$15\nlw $15,4($20)\nsw $15,yyval\nsh $21,-302+360($sp)\nlh $21,yyr1($24)\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $24,$24,1\nlh $24,yypgo($24)\nlh $15,($22)\naddu $24,$24,$15\nla $24,1($24)\nmove $18,$24\nsll $24,$18,8*(4-2); sra $24,$24,8*(4-2)\nla $15,249\nbge $24,$15,L.219\nsll $24,$24,1\nlh $24,yyact($24)\nmove $23,$24\nsll $24,$24,8*(4-2); sra $24,$24,8*(4-2)\nsll $24,$24,1\nlh $24,yychk($24)\nsll $15,$21,8*(4-2); sra $15,$15,8*(4-2)\nnegu $15,$15\nbeq $24,$15,L.217\nL.219:\nsll $24,$21,8*(4-2); sra $24,$24,8*(4-2)\nsll $24,$24,1\nlh $24,yypgo($24)\nsll $24,$24,1\nlh $23,yyact($24)\nL.217:\nlh $17,-302+360($sp)\nla $24,4\nblt $17,$24,L.161\nla $24,14\nbgt $17,$24,L.161\nsll $24,$17,2\nlw $24,L.241-16($24)\n.cpadd $24\nj $24\n.rdata\n.align 2\nL.241:\n.gpword L.223\n.gpword L.224\n.gpword L.226\n.gpword L.228\n.gpword L.230\n.gpword L.232\n.gpword L.234\n.gpword L.161\n.gpword L.236\n.gpword L.238\n.gpword L.240\n.text\nL.223:\nsh $0,yyerrflag\nb L.161\nL.224:\nla $4,L.225\njal printf\nb L.161\nL.226:\nla $4,L.227\njal printf\nb L.161\nL.228:\nla $4,L.229\njal printf\nb L.161\nL.230:\nla $4,L.231\njal printf\nb L.161\nL.232:\nla $4,L.233\njal printf\nb L.161\nL.234:\nla $4,L.235\njal printf\nb L.161\nL.236:\nla $4,L.237\njal printf\nb L.161\nL.238:\nla $4,L.239\nla $5,yytext\njal printf\nb L.161\nL.240:\nla $4,L.157\nla $5,yytext\njal printf\nb L.161\nL.158:\nlw $17,16($sp)\nlw $18,20($sp)\nlw $19,24($sp)\nlw $20,28($sp)\nlw $21,32($sp)\nlw $22,36($sp)\nlw $23,40($sp)\nlw $25,44($sp)\nlw $30,48($sp)\nlw $31,52($sp)\naddu $sp,$sp,360\nj $31\n.end yyparse\n.globl yywrap\n.text\n.align 2\n.ent yywrap\nyywrap:\n.frame $sp,0,$31\n.set noreorder\n.cpload $25\n.set reorder\nla $2,1\nL.243:\nj $31\n.end yywrap\n.globl yyv\n.comm yyv,600\n.globl yyfnd\n.comm yyfnd,4\n.globl yyolsp\n.comm yyolsp,4\n.globl yylsp\n.comm yylsp,4\n.globl yylstate\n.comm yylstate,800\n.globl yyestate\n.comm yyestate,4\n.globl yytchar\n.comm yytchar,4\n.globl yysbuf\n.comm yysbuf,200\n.globl yymorfg\n.comm yymorfg,4\n.globl yytext\n.comm yytext,200\n.globl yyleng\n.comm yyleng,4\n.extern _iob 0\n.globl yyval\n.comm yyval,4\n.globl yylval\n.comm yylval,4\n.rdata\n.align 0\nL.239:\n.byte 112\n.byte 117\n.byte 115\n.byte 104\n.byte 32\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.237:\n.byte 108\n.byte 111\n.byte 97\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.235:\n.byte 110\n.byte 101\n.byte 103\n.byte 97\n.byte 116\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.233:\n.byte 100\n.byte 105\n.byte 118\n.byte 105\n.byte 100\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.231:\n.byte 109\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 121\n.byte 10\n.byte 0\n.align 0\nL.229:\n.byte 110\n.byte 101\n.byte 103\n.byte 97\n.byte 116\n.byte 101\n.byte 10\n.byte 97\n.byte 100\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.227:\n.byte 97\n.byte 100\n.byte 100\n.byte 10\n.byte 0\n.align 0\nL.225:\n.byte 115\n.byte 116\n.byte 111\n.byte 114\n.byte 101\n.byte 10\n.byte 0\n.align 0\nL.204:\n.byte 115\n.byte 121\n.byte 110\n.byte 116\n.byte 97\n.byte 120\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 0\n.align 0\nL.165:\n.byte 121\n.byte 97\n.byte 99\n.byte 99\n.byte 32\n.byte 115\n.byte 116\n.byte 97\n.byte 99\n.byte 107\n.byte 32\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 0\n.align 0\nL.157:\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 0\nL.17:\n.byte 98\n.byte 97\n.byte 100\n.byte 32\n.byte 115\n.byte 119\n.byte 105\n.byte 116\n.byte 99\n.byte 104\n.byte 32\n.byte 121\n.byte 121\n.byte 108\n.byte 111\n.byte 111\n.byte 107\n.byte 32\n.byte 37\n.byte 100\n.byte 0\n"
  },
  {
    "path": "lcc/msdev/rcc.dsp",
    "content": "# Microsoft Developer Studio Project File - Name=\"rcc\" - Package Owner=<4>\n# Microsoft Developer Studio Generated Build File, Format Version 6.00\n# ** DO NOT EDIT **\n\n# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\n\nCFG=rcc - Win32 Debug\n!MESSAGE This is not a valid makefile. To build this project using NMAKE,\n!MESSAGE use the Export Makefile command and run\n!MESSAGE \n!MESSAGE NMAKE /f \"rcc.mak\".\n!MESSAGE \n!MESSAGE You can specify a configuration when running NMAKE\n!MESSAGE by defining the macro CFG on the command line. For example:\n!MESSAGE \n!MESSAGE NMAKE /f \"rcc.mak\" CFG=\"rcc - Win32 Debug\"\n!MESSAGE \n!MESSAGE Possible choices for configuration are:\n!MESSAGE \n!MESSAGE \"rcc - Win32 Release\" (based on \"Win32 (x86) Console Application\")\n!MESSAGE \"rcc - Win32 Debug\" (based on \"Win32 (x86) Console Application\")\n!MESSAGE \n\n# Begin Project\n# PROP AllowPerConfigDependencies 0\n# PROP Scc_ProjName \"\"\n# PROP Scc_LocalPath \"\"\nCPP=cl.exe\nRSC=rc.exe\n\n!IF  \"$(CFG)\" == \"rcc - Win32 Release\"\n\n# PROP BASE Use_MFC 0\n# PROP BASE Use_Debug_Libraries 0\n# PROP BASE Output_Dir \"Release\"\n# PROP BASE Intermediate_Dir \"Release\"\n# PROP BASE Target_Dir \"\"\n# PROP Use_MFC 0\n# PROP Use_Debug_Libraries 0\n# PROP Output_Dir \"Release\"\n# PROP Intermediate_Dir \"Release\"\n# PROP Target_Dir \"\"\n# ADD BASE CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n# ADD CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n# ADD BASE RSC /l 0x409 /d \"NDEBUG\"\n# ADD RSC /l 0x409 /d \"NDEBUG\"\nBSC32=bscmake.exe\n# ADD BASE BSC32 /nologo\n# ADD BSC32 /nologo\nLINK32=link.exe\n# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\n# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\n\n!ELSEIF  \"$(CFG)\" == \"rcc - Win32 Debug\"\n\n# PROP BASE Use_MFC 0\n# PROP BASE Use_Debug_Libraries 1\n# PROP BASE Output_Dir \"Debug\"\n# PROP BASE Intermediate_Dir \"Debug\"\n# PROP BASE Target_Dir \"\"\n# PROP Use_MFC 0\n# PROP Use_Debug_Libraries 1\n# PROP Output_Dir \"Debug\"\n# PROP Intermediate_Dir \"Debug\"\n# PROP Target_Dir \"\"\n# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ /c\n# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ /c\n# ADD BASE RSC /l 0x409 /d \"_DEBUG\"\n# ADD RSC /l 0x409 /d \"_DEBUG\"\nBSC32=bscmake.exe\n# ADD BASE BSC32 /nologo\n# ADD BSC32 /nologo\nLINK32=link.exe\n# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\n# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\n\n!ENDIF \n\n# Begin Target\n\n# Name \"rcc - Win32 Release\"\n# Name \"rcc - Win32 Debug\"\n# Begin Group \"Source Files\"\n\n# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\n# Begin Source File\n\nSOURCE=..\\src\\2html.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\alloc.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\asdl.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\bind.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\bytecode.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\c.h\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\config.h\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\dag.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\decl.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\enode.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\error.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\event.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\expr.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\gen.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\init.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\inits.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\input.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\lex.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\list.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\main.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\null.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\output.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\pass2.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\prof.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\profio.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\simp.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\stab.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\stab.h\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\stmt.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\string.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\sym.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\symbolic.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\token.h\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\trace.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\tree.c\n# End Source File\n# Begin Source File\n\nSOURCE=..\\src\\types.c\n# End Source File\n# End Group\n# Begin Group \"Header Files\"\n\n# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\n# End Group\n# Begin Group \"Resource Files\"\n\n# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\n# End Group\n# End Target\n# End Project\n"
  },
  {
    "path": "lcc/msdev/rcc.dsw",
    "content": "Microsoft Developer Studio Workspace File, Format Version 6.00\n# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\n\n###############################################################################\n\nProject: \"rcc\"=.\\rcc.dsp - Package Owner=<4>\n\nPackage=<5>\n{{{\n}}}\n\nPackage=<4>\n{{{\n}}}\n\n###############################################################################\n\nGlobal:\n\nPackage=<5>\n{{{\n}}}\n\nPackage=<3>\n{{{\n}}}\n\n###############################################################################\n\n"
  },
  {
    "path": "lcc/packing.lst",
    "content": "README\nCPYRIGHT\nLOG\nmakefile\nmakefile.nt\nsrc/2html.c\nsrc/alloc.c\nsrc/asdl.c\nsrc/bind.c\nsrc/bytecode.c\nsrc/c.h\nsrc/config.h\nsrc/dag.c\nsrc/decl.c\nsrc/enode.c\nsrc/error.c\nsrc/event.c\nsrc/expr.c\nsrc/gen.c\nsrc/init.c\nsrc/inits.c\nsrc/input.c\nsrc/lex.c\nsrc/list.c\nsrc/main.c\nsrc/null.c\nsrc/output.c\nsrc/pass2.c\nsrc/prof.c\nsrc/profio.c\nsrc/simp.c\nsrc/stab.c\nsrc/stab.h\nsrc/stmt.c\nsrc/string.c\nsrc/sym.c\nsrc/symbolic.c\nsrc/token.h\nsrc/trace.c\nsrc/tree.c\nsrc/types.c\nsrc/alpha.md\nsrc/dagcheck.md\nsrc/mips.md\nsrc/sparc.md\nsrc/x86.md\nsrc/x86linux.md\nsrc/run.sh\nsrc/rcc.asdl\nlib/assert.c\nlib/bbexit.c\nlib/yynull.c\ntst/8q.0\ntst/8q.c\ntst/array.0\ntst/array.c\ntst/cf.0\ntst/cf.c\ntst/cq.0\ntst/cq.c\ntst/cvt.0\ntst/cvt.c\ntst/fields.0\ntst/fields.c\ntst/front.0\ntst/front.c\ntst/incr.0\ntst/incr.c\ntst/init.0\ntst/init.c\ntst/limits.0\ntst/limits.c\ntst/paranoia.0\ntst/paranoia.c\ntst/sort.0\ntst/sort.c\ntst/spill.0\ntst/spill.c\ntst/stdarg.0\ntst/stdarg.c\ntst/struct.0\ntst/struct.c\ntst/switch.0\ntst/switch.c\ntst/wf1.0\ntst/wf1.c\ntst/yacc.0\ntst/yacc.c\netc/bprint.c\netc/gcc-solaris.c\netc/irix.c\netc/lcc.c\netc/linux.c\netc/ops.c\netc/osf.c\netc/solaris.c\netc/win32.c\ncpp/cpp.c\ncpp/cpp.h\ncpp/eval.c\ncpp/getopt.c\ncpp/hideset.c\ncpp/include.c\ncpp/lex.c\ncpp/macro.c\ncpp/nlist.c\ncpp/tokens.c\ncpp/unix.c\nlburg/gram.c\nlburg/gram.y\nlburg/lburg.1\nlburg/lburg.c\nlburg/lburg.h\ninclude/alpha/osf/assert.h\ninclude/alpha/osf/ctype.h\ninclude/alpha/osf/errno.h\ninclude/alpha/osf/float.h\ninclude/alpha/osf/limits.h\ninclude/alpha/osf/locale.h\ninclude/alpha/osf/math.h\ninclude/alpha/osf/setjmp.h\ninclude/alpha/osf/signal.h\ninclude/alpha/osf/stdarg.h\ninclude/alpha/osf/stddef.h\ninclude/alpha/osf/stdio.h\ninclude/alpha/osf/stdlib.h\ninclude/alpha/osf/string.h\ninclude/alpha/osf/time.h\ninclude/sparc/solaris/assert.h\ninclude/sparc/solaris/ctype.h\ninclude/sparc/solaris/errno.h\ninclude/sparc/solaris/float.h\ninclude/sparc/solaris/limits.h\ninclude/sparc/solaris/locale.h\ninclude/sparc/solaris/math.h\ninclude/sparc/solaris/setjmp.h\ninclude/sparc/solaris/signal.h\ninclude/sparc/solaris/stdarg.h\ninclude/sparc/solaris/stddef.h\ninclude/sparc/solaris/stdio.h\ninclude/sparc/solaris/stdlib.h\ninclude/sparc/solaris/string.h\ninclude/sparc/solaris/time.h\ninclude/mips/irix/assert.h\ninclude/mips/irix/ctype.h\ninclude/mips/irix/errno.h\ninclude/mips/irix/float.h\ninclude/mips/irix/limits.h\ninclude/mips/irix/locale.h\ninclude/mips/irix/math.h\ninclude/mips/irix/setjmp.h\ninclude/mips/irix/signal.h\ninclude/mips/irix/stdarg.h\ninclude/mips/irix/stddef.h\ninclude/mips/irix/stdio.h\ninclude/mips/irix/stdlib.h\ninclude/mips/irix/string.h\ninclude/mips/irix/time.h\ninclude/x86/linux/assert.h\ninclude/x86/linux/float.h\ninclude/x86/linux/stdarg.h\ndoc/4.html\ndoc/install.html\ndoc/bprint.1\ndoc/lcc.1\ndoc/bprint.pdf\ndoc/lcc.pdf\nalpha/osf/tst/8q.1bk\nalpha/osf/tst/8q.2bk\nalpha/osf/tst/8q.sbk\nalpha/osf/tst/array.1bk\nalpha/osf/tst/array.2bk\nalpha/osf/tst/array.sbk\nalpha/osf/tst/cf.1bk\nalpha/osf/tst/cf.2bk\nalpha/osf/tst/cf.sbk\nalpha/osf/tst/cq.1bk\nalpha/osf/tst/cq.2bk\nalpha/osf/tst/cq.sbk\nalpha/osf/tst/cvt.1bk\nalpha/osf/tst/cvt.2bk\nalpha/osf/tst/cvt.sbk\nalpha/osf/tst/fields.1bk\nalpha/osf/tst/fields.2bk\nalpha/osf/tst/fields.sbk\nalpha/osf/tst/front.2bk\nalpha/osf/tst/front.sbk\nalpha/osf/tst/incr.1bk\nalpha/osf/tst/incr.2bk\nalpha/osf/tst/incr.sbk\nalpha/osf/tst/init.1bk\nalpha/osf/tst/init.2bk\nalpha/osf/tst/init.sbk\nalpha/osf/tst/limits.1bk\nalpha/osf/tst/limits.2bk\nalpha/osf/tst/limits.sbk\nalpha/osf/tst/paranoia.1bk\nalpha/osf/tst/paranoia.2bk\nalpha/osf/tst/paranoia.sbk\nalpha/osf/tst/sort.1bk\nalpha/osf/tst/sort.2bk\nalpha/osf/tst/sort.sbk\nalpha/osf/tst/spill.1bk\nalpha/osf/tst/spill.2bk\nalpha/osf/tst/spill.sbk\nalpha/osf/tst/stdarg.1bk\nalpha/osf/tst/stdarg.2bk\nalpha/osf/tst/stdarg.sbk\nalpha/osf/tst/struct.1bk\nalpha/osf/tst/struct.2bk\nalpha/osf/tst/struct.sbk\nalpha/osf/tst/switch.1bk\nalpha/osf/tst/switch.2bk\nalpha/osf/tst/switch.sbk\nalpha/osf/tst/wf1.1bk\nalpha/osf/tst/wf1.2bk\nalpha/osf/tst/wf1.sbk\nalpha/osf/tst/yacc.1bk\nalpha/osf/tst/yacc.2bk\nalpha/osf/tst/yacc.sbk\nsparc/solaris/tst/8q.1bk\nsparc/solaris/tst/8q.2bk\nsparc/solaris/tst/8q.sbk\nsparc/solaris/tst/array.1bk\nsparc/solaris/tst/array.2bk\nsparc/solaris/tst/array.sbk\nsparc/solaris/tst/cf.1bk\nsparc/solaris/tst/cf.2bk\nsparc/solaris/tst/cf.sbk\nsparc/solaris/tst/cq.1bk\nsparc/solaris/tst/cq.2bk\nsparc/solaris/tst/cq.sbk\nsparc/solaris/tst/cvt.1bk\nsparc/solaris/tst/cvt.2bk\nsparc/solaris/tst/cvt.sbk\nsparc/solaris/tst/fields.1bk\nsparc/solaris/tst/fields.2bk\nsparc/solaris/tst/fields.sbk\nsparc/solaris/tst/front.2bk\nsparc/solaris/tst/front.sbk\nsparc/solaris/tst/incr.1bk\nsparc/solaris/tst/incr.2bk\nsparc/solaris/tst/incr.sbk\nsparc/solaris/tst/init.1bk\nsparc/solaris/tst/init.2bk\nsparc/solaris/tst/init.sbk\nsparc/solaris/tst/limits.1bk\nsparc/solaris/tst/limits.2bk\nsparc/solaris/tst/limits.sbk\nsparc/solaris/tst/paranoia.1bk\nsparc/solaris/tst/paranoia.2bk\nsparc/solaris/tst/paranoia.sbk\nsparc/solaris/tst/sort.1bk\nsparc/solaris/tst/sort.2bk\nsparc/solaris/tst/sort.sbk\nsparc/solaris/tst/spill.1bk\nsparc/solaris/tst/spill.2bk\nsparc/solaris/tst/spill.sbk\nsparc/solaris/tst/stdarg.1bk\nsparc/solaris/tst/stdarg.2bk\nsparc/solaris/tst/stdarg.sbk\nsparc/solaris/tst/struct.1bk\nsparc/solaris/tst/struct.2bk\nsparc/solaris/tst/struct.sbk\nsparc/solaris/tst/switch.1bk\nsparc/solaris/tst/switch.2bk\nsparc/solaris/tst/switch.sbk\nsparc/solaris/tst/wf1.1bk\nsparc/solaris/tst/wf1.2bk\nsparc/solaris/tst/wf1.sbk\nsparc/solaris/tst/yacc.1bk\nsparc/solaris/tst/yacc.2bk\nsparc/solaris/tst/yacc.sbk\nmips/irix/tst/8q.1bk\nmips/irix/tst/8q.2bk\nmips/irix/tst/8q.sbk\nmips/irix/tst/array.1bk\nmips/irix/tst/array.2bk\nmips/irix/tst/array.sbk\nmips/irix/tst/cf.1bk\nmips/irix/tst/cf.2bk\nmips/irix/tst/cf.sbk\nmips/irix/tst/cq.1bk\nmips/irix/tst/cq.2bk\nmips/irix/tst/cq.sbk\nmips/irix/tst/cvt.1bk\nmips/irix/tst/cvt.2bk\nmips/irix/tst/cvt.sbk\nmips/irix/tst/fields.1bk\nmips/irix/tst/fields.2bk\nmips/irix/tst/fields.sbk\nmips/irix/tst/front.2bk\nmips/irix/tst/front.sbk\nmips/irix/tst/incr.2bk\nmips/irix/tst/incr.sbk\nmips/irix/tst/init.1bk\nmips/irix/tst/init.2bk\nmips/irix/tst/init.sbk\nmips/irix/tst/limits.1bk\nmips/irix/tst/limits.2bk\nmips/irix/tst/limits.sbk\nmips/irix/tst/paranoia.1bk\nmips/irix/tst/paranoia.2bk\nmips/irix/tst/paranoia.sbk\nmips/irix/tst/sort.1bk\nmips/irix/tst/sort.2bk\nmips/irix/tst/sort.sbk\nmips/irix/tst/spill.2bk\nmips/irix/tst/spill.sbk\nmips/irix/tst/stdarg.1bk\nmips/irix/tst/stdarg.2bk\nmips/irix/tst/stdarg.sbk\nmips/irix/tst/struct.1bk\nmips/irix/tst/struct.2bk\nmips/irix/tst/struct.sbk\nmips/irix/tst/switch.1bk\nmips/irix/tst/switch.2bk\nmips/irix/tst/switch.sbk\nmips/irix/tst/wf1.1bk\nmips/irix/tst/wf1.2bk\nmips/irix/tst/wf1.sbk\nmips/irix/tst/yacc.1bk\nmips/irix/tst/yacc.2bk\nmips/irix/tst/yacc.sbk\nx86/linux/tst/8q.1bk\nx86/linux/tst/8q.2bk\nx86/linux/tst/8q.sbk\nx86/linux/tst/array.1bk\nx86/linux/tst/array.2bk\nx86/linux/tst/array.sbk\nx86/linux/tst/cf.1bk\nx86/linux/tst/cf.2bk\nx86/linux/tst/cf.sbk\nx86/linux/tst/cq.1bk\nx86/linux/tst/cq.2bk\nx86/linux/tst/cq.sbk\nx86/linux/tst/cvt.1bk\nx86/linux/tst/cvt.2bk\nx86/linux/tst/cvt.sbk\nx86/linux/tst/fields.1bk\nx86/linux/tst/fields.2bk\nx86/linux/tst/fields.sbk\nx86/linux/tst/front.2bk\nx86/linux/tst/front.sbk\nx86/linux/tst/incr.1bk\nx86/linux/tst/incr.2bk\nx86/linux/tst/incr.sbk\nx86/linux/tst/init.1bk\nx86/linux/tst/init.2bk\nx86/linux/tst/init.sbk\nx86/linux/tst/limits.1bk\nx86/linux/tst/limits.2bk\nx86/linux/tst/limits.sbk\nx86/linux/tst/paranoia.1bk\nx86/linux/tst/paranoia.2bk\nx86/linux/tst/paranoia.sbk\nx86/linux/tst/sort.1bk\nx86/linux/tst/sort.2bk\nx86/linux/tst/sort.sbk\nx86/linux/tst/spill.1bk\nx86/linux/tst/spill.2bk\nx86/linux/tst/spill.sbk\nx86/linux/tst/stdarg.1bk\nx86/linux/tst/stdarg.2bk\nx86/linux/tst/stdarg.sbk\nx86/linux/tst/struct.1bk\nx86/linux/tst/struct.2bk\nx86/linux/tst/struct.sbk\nx86/linux/tst/switch.1bk\nx86/linux/tst/switch.2bk\nx86/linux/tst/switch.sbk\nx86/linux/tst/wf1.1bk\nx86/linux/tst/wf1.2bk\nx86/linux/tst/wf1.sbk\nx86/linux/tst/yacc.1bk\nx86/linux/tst/yacc.2bk\nx86/linux/tst/yacc.sbk\nx86/win32/tst/8q.1bk\nx86/win32/tst/8q.2bk\nx86/win32/tst/8q.sbk\nx86/win32/tst/array.1bk\nx86/win32/tst/array.2bk\nx86/win32/tst/array.sbk\nx86/win32/tst/cf.1bk\nx86/win32/tst/cf.2bk\nx86/win32/tst/cf.sbk\nx86/win32/tst/cq.1bk\nx86/win32/tst/cq.2bk\nx86/win32/tst/cq.sbk\nx86/win32/tst/cvt.1bk\nx86/win32/tst/cvt.2bk\nx86/win32/tst/cvt.sbk\nx86/win32/tst/fields.1bk\nx86/win32/tst/fields.2bk\nx86/win32/tst/fields.sbk\nx86/win32/tst/front.2bk\nx86/win32/tst/front.sbk\nx86/win32/tst/incr.1bk\nx86/win32/tst/incr.2bk\nx86/win32/tst/incr.sbk\nx86/win32/tst/init.1bk\nx86/win32/tst/init.2bk\nx86/win32/tst/init.sbk\nx86/win32/tst/limits.1bk\nx86/win32/tst/limits.2bk\nx86/win32/tst/limits.sbk\nx86/win32/tst/paranoia.1bk\nx86/win32/tst/paranoia.2bk\nx86/win32/tst/paranoia.sbk\nx86/win32/tst/sort.1bk\nx86/win32/tst/sort.2bk\nx86/win32/tst/sort.sbk\nx86/win32/tst/spill.1bk\nx86/win32/tst/spill.2bk\nx86/win32/tst/spill.sbk\nx86/win32/tst/stdarg.1bk\nx86/win32/tst/stdarg.2bk\nx86/win32/tst/stdarg.sbk\nx86/win32/tst/struct.1bk\nx86/win32/tst/struct.2bk\nx86/win32/tst/struct.sbk\nx86/win32/tst/switch.1bk\nx86/win32/tst/switch.2bk\nx86/win32/tst/switch.sbk\nx86/win32/tst/wf1.1bk\nx86/win32/tst/wf1.2bk\nx86/win32/tst/wf1.sbk\nx86/win32/tst/yacc.1bk\nx86/win32/tst/yacc.2bk\nx86/win32/tst/yacc.sbk\ncustom.mk\npacking.lst\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/8q.1bk",
    "content": "1 5 8 6 3 7 2 4 \n1 6 8 3 7 4 2 5 \n1 7 4 6 8 2 5 3 \n1 7 5 8 2 4 6 3 \n2 4 6 8 3 1 7 5 \n2 5 7 1 3 8 6 4 \n2 5 7 4 1 8 6 3 \n2 6 1 7 4 8 3 5 \n2 6 8 3 1 4 7 5 \n2 7 3 6 8 5 1 4 \n2 7 5 8 1 4 6 3 \n2 8 6 1 3 5 7 4 \n3 1 7 5 8 2 4 6 \n3 5 2 8 1 7 4 6 \n3 5 2 8 6 4 7 1 \n3 5 7 1 4 2 8 6 \n3 5 8 4 1 7 2 6 \n3 6 2 5 8 1 7 4 \n3 6 2 7 1 4 8 5 \n3 6 2 7 5 1 8 4 \n3 6 4 1 8 5 7 2 \n3 6 4 2 8 5 7 1 \n3 6 8 1 4 7 5 2 \n3 6 8 1 5 7 2 4 \n3 6 8 2 4 1 7 5 \n3 7 2 8 5 1 4 6 \n3 7 2 8 6 4 1 5 \n3 8 4 7 1 6 2 5 \n4 1 5 8 2 7 3 6 \n4 1 5 8 6 3 7 2 \n4 2 5 8 6 1 3 7 \n4 2 7 3 6 8 1 5 \n4 2 7 3 6 8 5 1 \n4 2 7 5 1 8 6 3 \n4 2 8 5 7 1 3 6 \n4 2 8 6 1 3 5 7 \n4 6 1 5 2 8 3 7 \n4 6 8 2 7 1 3 5 \n4 6 8 3 1 7 5 2 \n4 7 1 8 5 2 6 3 \n4 7 3 8 2 5 1 6 \n4 7 5 2 6 1 3 8 \n4 7 5 3 1 6 8 2 \n4 8 1 3 6 2 7 5 \n4 8 1 5 7 2 6 3 \n4 8 5 3 1 7 2 6 \n5 1 4 6 8 2 7 3 \n5 1 8 4 2 7 3 6 \n5 1 8 6 3 7 2 4 \n5 2 4 6 8 3 1 7 \n5 2 4 7 3 8 6 1 \n5 2 6 1 7 4 8 3 \n5 2 8 1 4 7 3 6 \n5 3 1 6 8 2 4 7 \n5 3 1 7 2 8 6 4 \n5 3 8 4 7 1 6 2 \n5 7 1 3 8 6 4 2 \n5 7 1 4 2 8 6 3 \n5 7 2 4 8 1 3 6 \n5 7 2 6 3 1 4 8 \n5 7 2 6 3 1 8 4 \n5 7 4 1 3 8 6 2 \n5 8 4 1 3 6 2 7 \n5 8 4 1 7 2 6 3 \n6 1 5 2 8 3 7 4 \n6 2 7 1 3 5 8 4 \n6 2 7 1 4 8 5 3 \n6 3 1 7 5 8 2 4 \n6 3 1 8 4 2 7 5 \n6 3 1 8 5 2 4 7 \n6 3 5 7 1 4 2 8 \n6 3 5 8 1 4 2 7 \n6 3 7 2 4 8 1 5 \n6 3 7 2 8 5 1 4 \n6 3 7 4 1 8 2 5 \n6 4 1 5 8 2 7 3 \n6 4 2 8 5 7 1 3 \n6 4 7 1 3 5 2 8 \n6 4 7 1 8 2 5 3 \n6 8 2 4 1 7 5 3 \n7 1 3 8 6 4 2 5 \n7 2 4 1 8 5 3 6 \n7 2 6 3 1 4 8 5 \n7 3 1 6 8 5 2 4 \n7 3 8 2 5 1 6 4 \n7 4 2 5 8 1 3 6 \n7 4 2 8 6 1 3 5 \n7 5 3 1 6 8 2 4 \n8 2 4 1 7 5 3 6 \n8 2 5 3 1 7 4 6 \n8 3 1 6 2 5 7 4 \n8 4 1 3 6 2 7 5 \n"
  },
  {
    "path": "lcc/sparc/solaris/tst/8q.2bk",
    "content": "tst/8q.c:30: warning: missing return value\ntst/8q.c:39: warning: missing return value\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/8q.sbk",
    "content": ".global main\n.section \".text\"\n.align 4\nmain:\nsave %sp,-96,%sp\nmov %g0,%i5\n.L2:\nsll %i5,2,%i4\nset 1,%i3\nset down,%i2\nst %i3,[%i4+%i2]\nset up,%i2\nst %i3,[%i4+%i2]\n.L3:\nadd %i5,1,%i5\ncmp %i5,15; bl .L2; nop\nmov %g0,%i5\n.L6:\nsll %i5,2,%i4\nset rows,%i3\nset 1,%i2\nst %i2,[%i4+%i3]\n.L7:\nadd %i5,1,%i5\ncmp %i5,8; bl .L6; nop\nmov %g0,%o0\ncall queens; nop\nmov %g0,%i0\n.L1:\nret; restore\n.type main,#function\n.size main,.-main\n.global queens\n.align 4\nqueens:\nsave %sp,-96,%sp\nmov %g0,%i5\n.L11:\nsll %i5,2,%i3\nset rows,%i2\nld [%i3+%i2],%i3\ncmp %i3,%g0; be .L15; nop\nsub %i5,%i0,%i3\nsll %i3,2,%i3\nset up+28,%i2\nld [%i3+%i2],%i3\ncmp %i3,%g0; be .L15; nop\nadd %i5,%i0,%i3\nsll %i3,2,%i3\nset down,%i2\nld [%i3+%i2],%i3\ncmp %i3,%g0; be .L15; nop\nadd %i5,%i0,%i3\nsll %i3,2,%i3\nset down,%i2\nst %g0,[%i3+%i2]\nsub %i5,%i0,%i3\nsll %i3,2,%i3\nset up+28,%i2\nst %g0,[%i3+%i2]\nsll %i5,2,%i3\nset rows,%i2\nst %g0,[%i3+%i2]\nsll %i0,2,%i4\nset x,%i3\nst %i5,[%i4+%i3]\ncmp %i0,7; bne .L19; nop\ncall print; nop\nba .L20; nop\n.L19:\nadd %i0,1,%o0\ncall queens; nop\n.L20:\nset 1,%i4\nadd %i5,%i0,%i3\nsll %i3,2,%i3\nset down,%i2\nst %i4,[%i3+%i2]\nsub %i5,%i0,%i3\nsll %i3,2,%i3\nset up+28,%i2\nst %i4,[%i3+%i2]\nsll %i5,2,%i3\nset rows,%i2\nst %i4,[%i3+%i2]\n.L15:\n.L12:\nadd %i5,1,%i5\ncmp %i5,8; bl .L11; nop\nmov %g0,%i0\n.L10:\nret; restore\n.type queens,#function\n.size queens,.-queens\n.global print\n.align 4\nprint:\nsave %sp,-96,%sp\nmov %g0,%i5\n.L23:\nset .L27,%o0\nsll %i5,2,%i4\nset x,%i3\nld [%i4+%i3],%i4\nadd %i4,49,%o1\ncall printf; nop\n.L24:\nadd %i5,1,%i5\ncmp %i5,8; bl .L23; nop\nset .L28,%o0\ncall printf; nop\nmov %g0,%i0\n.L22:\nret; restore\n.type print,#function\n.size print,.-print\n.section \".bss\"\n.global x\n.type x,#object\n.size x,32\n.common x,32,4\n.global rows\n.type rows,#object\n.size rows,32\n.common rows,32,4\n.global down\n.type down,#object\n.size down,60\n.common down,60,4\n.global up\n.type up,#object\n.size up,60\n.common up,60,4\n.section \".rodata\"\n.align 1\n.L28:\n.byte 10\n.byte 0\n.align 1\n.L27:\n.byte 37\n.byte 99\n.byte 32\n.byte 0\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/array.1bk",
    "content": " 0 1 2 3 1000 1001 1002 1003 2000 2001 2002 2003\n 0 1 2 3 1000 1001 1002 1003 2000 2001 2002 2003\n 0 1 2 3 1000 1001 1002 1003 2000 2001 2002 2003\n 0 1 2 3 1000 1001 1002 1003 2000 2001 2002 2003\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/array.2bk",
    "content": "tst/array.c:33: warning: missing return value\ntst/array.c:48: warning: missing return value\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/array.sbk",
    "content": ".global main\n.section \".text\"\n.align 4\nmain:\nsave %sp,-144,%sp\nmov %g0,%i4\n.L2:\nmov %g0,%i5\n.L6:\nsll %i5,2,%i2\nsll %i4,4,%i1\nset x,%i0\nadd %i1,%i0,%i1\nsmul %i4,1000,%i0\nadd %i0,%i5,%i0\nst %i0,[%i2+%i1]\n.L7:\nadd %i5,1,%i5\ncmp %i5,4; bl .L6; nop\nsll %i4,2,%i2\nset y,%i1\nsll %i4,4,%i0\nset x,%l7\nadd %i0,%l7,%i0\nst %i0,[%i2+%i1]\n.L3:\nadd %i4,1,%i4\ncmp %i4,3; bl .L2; nop\ncall f; nop\nmov %g0,%i4\n.L10:\nsll %i4,4,%i2\nadd -48,%fp,%i1\nadd %i2,%i1,%i2\nmov %i2,%i3\nsll %i4,2,%i1\nset y,%i0\nst %i2,[%i1+%i0]\nmov %g0,%i5\n.L14:\nsll %i5,2,%i2\nsll %i4,4,%i1\nset x,%i0\nadd %i1,%i0,%i1\nld [%i2+%i1],%i1\nst %i1,[%i2+%i3]\n.L15:\nadd %i5,1,%i5\ncmp %i5,4; bl .L14; nop\n.L11:\nadd %i4,1,%i4\ncmp %i4,3; bl .L10; nop\nadd -48,%fp,%o0\nset y,%o1\ncall g; nop\nmov %g0,%i0\n.L1:\nret; restore\n.type main,#function\n.size main,.-main\n.global f\n.align 4\nf:\nsave %sp,-96,%sp\nmov %g0,%i4\n.L19:\nmov %g0,%i5\n.L23:\nset .L27,%o0\nsll %i5,2,%i3\nsll %i4,4,%i2\nset x,%i1\nadd %i2,%i1,%i2\nld [%i3+%i2],%o1\ncall printf; nop\n.L24:\nadd %i5,1,%i5\ncmp %i5,4; bl .L23; nop\n.L20:\nadd %i4,1,%i4\ncmp %i4,3; bl .L19; nop\nset .L28,%o0\ncall printf; nop\nmov %g0,%i4\n.L29:\nmov %g0,%i5\n.L33:\nset .L27,%o0\nsll %i5,2,%i3\nsll %i4,2,%i2\nset y,%i1\nld [%i2+%i1],%i2\nld [%i3+%i2],%o1\ncall printf; nop\n.L34:\nadd %i5,1,%i5\ncmp %i5,4; bl .L33; nop\n.L30:\nadd %i4,1,%i4\ncmp %i4,3; bl .L29; nop\nset .L28,%o0\ncall printf; nop\nmov %g0,%i0\n.L18:\nret; restore\n.type f,#function\n.size f,.-f\n.global g\n.align 4\ng:\nsave %sp,-96,%sp\nmov %g0,%i4\n.L38:\nmov %g0,%i5\n.L42:\nset .L27,%o0\nsll %i5,2,%i3\nsll %i4,4,%i2\nadd %i2,%i0,%i2\nld [%i3+%i2],%o1\ncall printf; nop\n.L43:\nadd %i5,1,%i5\ncmp %i5,4; bl .L42; nop\n.L39:\nadd %i4,1,%i4\ncmp %i4,3; bl .L38; nop\nset .L28,%o0\ncall printf; nop\nmov %g0,%i4\n.L46:\nmov %g0,%i5\n.L50:\nset .L27,%o0\nsll %i5,2,%i3\nsll %i4,2,%i2\nld [%i2+%i1],%i2\nld [%i3+%i2],%o1\ncall printf; nop\n.L51:\nadd %i5,1,%i5\ncmp %i5,4; bl .L50; nop\n.L47:\nadd %i4,1,%i4\ncmp %i4,3; bl .L46; nop\nset .L28,%o0\ncall printf; nop\nmov %g0,%i0\n.L37:\nret; restore\n.type g,#function\n.size g,.-g\n.section \".bss\"\n.global y\n.type y,#object\n.size y,12\n.common y,12,4\n.global x\n.type x,#object\n.size x,48\n.common x,48,4\n.section \".rodata\"\n.align 1\n.L28:\n.byte 10\n.byte 0\n.align 1\n.L27:\n.byte 32\n.byte 37\n.byte 100\n.byte 0\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/cf.1bk",
    "content": "char\tfreq\n011\t8.1\n012\t6.1\n040\t11.9\n!\t0.2\n\"\t1.5\n%\t0.6\n&\t0.4\n'\t0.4\n(\t2.9\n)\t2.9\n*\t0.8\n+\t1.3\n,\t1.3\n-\t0.4\n.\t0.6\n/\t1.0\n0\t2.5\n1\t1.9\n2\t0.6\n3\t0.2\n7\t0.4\n8\t0.2\n;\t3.8\n<\t0.8\n=\t2.7\n>\t0.2\n[\t1.5\n\\\t0.8\n]\t1.5\na\t3.1\nc\t4.4\ne\t2.3\nf\t6.0\ng\t1.3\nh\t1.0\ni\t5.0\nl\t1.0\nm\t0.2\nn\t3.3\no\t2.1\np\t1.0\nq\t0.4\nr\t4.2\ns\t0.6\nt\t3.8\nu\t1.2\nv\t0.6\nw\t0.2\n{\t0.6\n}\t0.6\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/cf.2bk",
    "content": ""
  },
  {
    "path": "lcc/sparc/solaris/tst/cf.sbk",
    "content": ".global main\n.section \".text\"\n.align 4\nmain:\nsave %sp,-96,%sp\ncmp %i0,1; bg .L2; nop\nset .L4,%i2\nld [%i2],%f31\nst %f31,[%fp+-4]\nba .L3; nop\n.L2:\nld [%i1+4],%o0\ncall atof; nop\nfmovs %f0,%f31\nset .L5,%i2\nld [%i2],%f30\nfdivs %f31,%f30,%f31\nst %f31,[%fp+-4]\n.L3:\nmov %g0,%i5\n.L6:\nmov %i5,%i2\nadd %i2,1,%i5\nsll %i2,2,%i2\nset f,%l7\nset .L4,%l6\nld [%l6],%f31\nst %f31,[%i2+%l7]\n.L7:\ncmp %i5,127; ble .L6; nop\nmov %g0,%i4\nba .L11; nop\n.L10:\nsll %i3,2,%i2\nset f,%l7\nadd %i2,%l7,%i2\nld [%i2],%f31\nset .L13,%l7\nld [%l7],%f30\nfadds %f31,%f30,%f31\nst %f31,[%i2]\nadd %i4,1,%i4\n.L11:\ncall getchar; nop\nmov %o0,%i3\ncmp %o0,-1; bne .L10; nop\nset .L14,%o0\ncall printf; nop\nmov %g0,%i5\n.L15:\nsll %i5,2,%i2\nset f,%l7\nld [%i2+%l7],%f31\nset .L4,%i2\nld [%i2],%f30\nfcmpes %f31,%f30; nop; fbue .L19; nop\nst %i4,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfdivs %f31,%f30,%f31\nld [%fp+-4],%f30\nfcmpes %f31,%f30; nop; fbul .L19; nop\ncmp %i5,32; bg .L21; nop\nset .L23,%o0\nmov %i5,%o1\ncall printf; nop\nba .L22; nop\n.L21:\nset .L24,%o0\nmov %i5,%o1\ncall printf; nop\n.L22:\nset .L25,%o0\nset .L5,%i2\nld [%i2],%f31\nsll %i5,2,%i2\nset f,%l7\nld [%i2+%l7],%f30\nfmuls %f31,%f30,%f31\nst %i4,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfdivs %f31,%f30,%f31\nfstod %f31,%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\n.L19:\n.L16:\nadd %i5,1,%i5\ncmp %i5,127; ble .L15; nop\nmov %g0,%i0\n.L1:\nret; restore\n.type main,#function\n.size main,.-main\n.section \".bss\"\n.global f\n.type f,#object\n.size f,512\n.common f,512,4\n.section \".rodata\"\n.align 1\n.L25:\n.byte 9\n.byte 37\n.byte 46\n.byte 49\n.byte 102\n.byte 10\n.byte 0\n.align 1\n.L24:\n.byte 37\n.byte 99\n.byte 0\n.align 1\n.L23:\n.byte 37\n.byte 48\n.byte 51\n.byte 111\n.byte 0\n.align 1\n.L14:\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 9\n.byte 102\n.byte 114\n.byte 101\n.byte 113\n.byte 10\n.byte 0\n.align 4\n.L13:\n.word 0x3f800000\n.align 4\n.L5:\n.word 0x42c80000\n.align 4\n.L4:\n.word 0x0\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/cq.1bk",
    "content": "Section s22     returned 0.\nDecimal and octal/hex constants sometimes give\n   different results when assigned to longs.\nDecimal and octal/hex constants sometimes give\n   different results when assigned to longs.\nSection s241    returned 0.\nSection s243    returned 0.\nSection s244    returned 0.\nSection s25     returned 0.\n  8 bits in chars.\n 32 bits in ints.\n 16 bits in shorts.\n 32 bits in longs.\n 32 bits in unsigneds.\n 32 bits in floats.\n 64 bits in doubles.\n1.192093e-07 is the least number that can be added to 1. (float).\n2.220446e-16 is the least number that can be added to 1. (double).\nSection s26     returned 0.\nSection s4      returned 0.\nSection s61     returned 0.\nSection s626    returned 0.\nSection s71     returned 0.\nSection s72     returned 0.\nSection s757    returned 0.\nSection s7813   returned 0.\nSection s714    returned 0.\nSection s715    returned 0.\nRegister count for char is unreliable.\nRegister count for pointer is unreliable.\nRegister count for int is unreliable.\nSection s81     returned 0.\nSection s84     returned 0.\nchar alignment: 1\nshort alignment: 2\nint alignment: 4\nlong alignment: 4\nunsigned alignment: 4\nfloat alignment: 4\ndouble alignment: 8\nSign extension in fields\nBe especially careful with 1-bit fields!\nSection s85     returned 0.\nSection s86     returned 0.\nSection s88     returned 0.\nSection s9      returned 0.\n\nNo errors detected.\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/cq.2bk",
    "content": "tst/cq.c:394: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:394: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:394: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:395: warning: overflow in constant `4294967296'\ntst/cq.c:395: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:395: warning: overflow in constant `040000000000'\ntst/cq.c:395: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:395: warning: overflow in constant `0x100000000'\ntst/cq.c:395: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:396: warning: overflow in constant `68719476735'\ntst/cq.c:396: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:396: warning: overflow in constant `0777777777777'\ntst/cq.c:396: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:396: warning: overflow in constant `0xfffffffff'\ntst/cq.c:396: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:397: warning: overflow in constant `68719476736'\ntst/cq.c:397: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:397: warning: overflow in constant `01000000000000'\ntst/cq.c:397: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:397: warning: overflow in constant `0x1000000000'\ntst/cq.c:397: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:533: warning: missing return value\ntst/cq.c:1169: warning: missing return value\ntst/cq.c:5294: warning: unreachable code\ntst/cq.c:5303: warning: missing return value\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/cq.sbk",
    "content": ".section \".data\"\n.type .2,#object\n.align 4\n.2:\n.word s22\n.word s241\n.word s243\n.word s244\n.word s25\n.word s26\n.word s4\n.word s61\n.word s626\n.word s71\n.word s72\n.word s757\n.word s7813\n.word s714\n.word s715\n.word s81\n.word s84\n.word s85\n.word s86\n.word s88\n.word s9\n.section \".bss\"\n.size .2,84\n.type .3,#object\n.size .3,68\n.local .3\n.common .3,68,4\n.type .4,#object\n.size .4,4\n.local .4\n.common .4,4,4\n.global main\n.section \".text\"\n.align 4\nmain:\nsave %sp,-96,%sp\nset .3+36,%i4\nset 1,%i3\nst %i3,[%i4]\nset .3+40,%i4\nset 1,%i3\nst %i3,[%i4]\nset .3+44,%i4\nset 1,%i3\nst %i3,[%i4]\nset .3+48,%i4\nset 1,%i3\nst %i3,[%i4]\nset .4,%i4\nset .3,%i3\nst %i3,[%i4]\nmov %g0,%i5\nba .L12; nop\n.L9:\nset .4,%i4\nld [%i4],%o0\nsll %i5,2,%i4\nset .2,%i3\nld [%i4+%i3],%i4\ncall %i4; nop\nset .3+52,%i3\nst %o0,[%i3]\nset .3+56,%i4\nset .3+56,%i3\nld [%i3],%i3\nset .3+52,%i2\nld [%i2],%i2\nadd %i3,%i2,%i3\nst %i3,[%i4]\nset .3+36,%i4\nld [%i4],%i4\ncmp %i4,0; be .L17; nop\nset .L20,%o0\nset .3+60,%o1\nset .3+52,%i4\nld [%i4],%o2\ncall printf; nop\n.L17:\n.L10:\nadd %i5,1,%i5\n.L12:\nmov %i5,%i4\nset 21,%i3\ncmp %i4,%i3; blu .L9; nop\nset .3+56,%i4\nld [%i4],%i4\ncmp %i4,0; bne .L23; nop\nset .L26,%o0\ncall printf; nop\nba .L24; nop\n.L23:\nset .L27,%o0\ncall printf; nop\n.L24:\nmov %g0,%i0\n.L1:\nret; restore\n.type main,#function\n.size main,.-main\n.section \".data\"\n.type .29,#object\n.align 1\n.29:\n.byte 115\n.byte 50\n.byte 50\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size .29,10\n.type .30,#object\n.size .30,8\n.align 1\n.30:\n.byte 115\n.byte 50\n.byte 50\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.global s22\n.section \".text\"\n.align 4\ns22:\nsave %sp,-96,%sp\nmov %g0,%i3\nset .30,%i5\nadd %i0,60,%i4\n.L31:\n.L32:\nmov %i4,%l4\nadd %l4,1,%i4\nmov %i5,%l3\nadd %l3,1,%i5\nldsb [%l3],%l3\nstb %l3,[%l4]\nsll %l3,8*(4-1),%l4; sra %l4,8*(4-1),%l4\ncmp %l4,0; bne .L31; nop\nset 1,%i2\nset 2,%l7\nset 3,%l6\nset 4,%i1\nadd %i2,%l7,%l4\nadd %l4,%l6,%l4\nadd %l4,%i1,%l4\ncmp %l4,10; be .L34; nop\nadd %i3,1,%i3\nld [%i0+44],%l4\ncmp %l4,0; be .L36; nop\nset .29,%o0\nset 1,%o1\ncall printf; nop\n.L36:\n.L34:\nset 2,%l5\ncmp %l5,%i2; bne .L38; nop\nadd %i3,4,%i3\nld [%i0+44],%l4\ncmp %l4,0; be .L40; nop\nset .29,%o0\nset 4,%o1\ncall printf; nop\n.L40:\n.L38:\nmov %i3,%i0\n.L28:\nret; restore\n.type s22,#function\n.size s22,.-s22\n.section \".data\"\n.type .43,#object\n.align 1\n.43:\n.byte 115\n.byte 50\n.byte 52\n.byte 49\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size .43,11\n.type .44,#object\n.size .44,8\n.align 1\n.44:\n.byte 115\n.byte 50\n.byte 52\n.byte 49\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.type .45,#object\n.size .45,156\n.align 4\n.45:\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x0\n.word 0x6\n.word 0x0\n.word 0x8\n.word 0x0\n.word 0xc\n.word 0x0\n.word 0x10\n.word 0x0\n.word 0x12\n.word 0x0\n.word 0x14\n.word 0x0\n.word 0x18\n.word 0x0\n.word 0x1c\n.word 0x0\n.word 0x1e\n.word 0x0\n.word 0x20\n.word 0x0\n.word 0x24\n.global s241\n.section \".text\"\n.align 4\ns241:\nsave %sp,-560,%sp\nmov %g0,%i2\nmov %g0,%i1\nset .44,%i4\nadd %i0,60,%i3\n.L46:\n.L47:\nmov %i3,%l7\nadd %l7,1,%i3\nmov %i4,%l6\nadd %l6,1,%i4\nldsb [%l6],%l6\nstb %l6,[%l7]\nsll %l6,8*(4-1),%l7; sra %l7,8*(4-1),%l7\ncmp %l7,0; bne .L46; nop\nba .L49; nop\nadd %i2,1,%i2\nld [%i0+44],%l7\ncmp %l7,0; be .L51; nop\nset .43,%o0\nset 1,%o1\ncall printf; nop\n.L51:\n.L49:\nba .L53; nop\nadd %i2,2,%i2\nld [%i0+44],%l7\ncmp %l7,0; be .L55; nop\nset .43,%o0\nset 2,%o1\ncall printf; nop\n.L55:\n.L53:\nba .L57; nop\nadd %i2,4,%i2\nld [%i0+44],%l7\ncmp %l7,0; be .L59; nop\nset .43,%o0\nset 4,%o1\ncall printf; nop\n.L59:\n.L57:\nba .L61; nop\nadd %i2,8,%i2\nld [%i0+44],%l7\ncmp %l7,0; be .L63; nop\nset .43,%o0\nset 8,%o1\ncall printf; nop\n.L63:\n.L61:\nmov %g0,%i5\n.L65:\nsll %i5,2,%l7\nset .45,%l6\nst %i5,[%l7+%l6]\n.L66:\nadd %i5,1,%i5\ncmp %i5,17; bl .L65; nop\nset 18,%i5\n.L69:\nsll %i5,2,%l7\nset .45,%l6\nadd %l7,%l6,%l7\nld [%l7],%o0\ncall pow2; nop\nst %o0,[%l7]\nsll %i5,2,%l7\nset .45-4,%l6\nset .45,%l5\nld [%l7+%l5],%l5\nsub %l5,1,%l5\nst %l5,[%l7+%l6]\nadd %i5,2,%i5\n.L70:\ncmp %i5,39; bl .L69; nop\nst %g0,[%fp+-156]\nst %g0,[%fp+-312]\nst %g0,[%fp+-468]\nset 1,%l7\nst %l7,[%fp+-152]\nset 1,%l7\nst %l7,[%fp+-308]\nset 1,%l7\nst %l7,[%fp+-464]\nset 2,%l7\nst %l7,[%fp+-148]\nset 2,%l7\nst %l7,[%fp+-304]\nset 2,%l7\nst %l7,[%fp+-460]\nset 3,%l7\nst %l7,[%fp+-144]\nset 3,%l7\nst %l7,[%fp+-300]\nset 3,%l7\nst %l7,[%fp+-456]\nset 4,%l7\nst %l7,[%fp+-140]\nset 4,%l7\nst %l7,[%fp+-296]\nset 4,%l7\nst %l7,[%fp+-452]\nset 5,%l7\nst %l7,[%fp+-136]\nset 5,%l7\nst %l7,[%fp+-292]\nset 5,%l7\nst %l7,[%fp+-448]\nset 6,%l7\nst %l7,[%fp+-132]\nset 6,%l7\nst %l7,[%fp+-288]\nset 6,%l7\nst %l7,[%fp+-444]\nset 7,%l7\nst %l7,[%fp+-128]\nset 7,%l7\nst %l7,[%fp+-284]\nset 7,%l7\nst %l7,[%fp+-440]\nset 8,%l7\nst %l7,[%fp+-124]\nset 8,%l7\nst %l7,[%fp+-280]\nset 8,%l7\nst %l7,[%fp+-436]\nset 9,%l7\nst %l7,[%fp+-120]\nset 9,%l7\nst %l7,[%fp+-276]\nset 9,%l7\nst %l7,[%fp+-432]\nset 10,%l7\nst %l7,[%fp+-116]\nset 10,%l7\nst %l7,[%fp+-272]\nset 10,%l7\nst %l7,[%fp+-428]\nset 11,%l7\nst %l7,[%fp+-112]\nset 11,%l7\nst %l7,[%fp+-268]\nset 11,%l7\nst %l7,[%fp+-424]\nset 12,%l7\nst %l7,[%fp+-108]\nset 12,%l7\nst %l7,[%fp+-264]\nset 12,%l7\nst %l7,[%fp+-420]\nset 13,%l7\nst %l7,[%fp+-104]\nset 13,%l7\nst %l7,[%fp+-260]\nset 13,%l7\nst %l7,[%fp+-416]\nset 14,%l7\nst %l7,[%fp+-100]\nset 14,%l7\nst %l7,[%fp+-256]\nset 14,%l7\nst %l7,[%fp+-412]\nset 15,%l7\nst %l7,[%fp+-96]\nset 15,%l7\nst %l7,[%fp+-252]\nset 15,%l7\nst %l7,[%fp+-408]\nset 16,%l7\nst %l7,[%fp+-92]\nset 16,%l7\nst %l7,[%fp+-248]\nset 16,%l7\nst %l7,[%fp+-404]\nset 63,%l7\nst %l7,[%fp+-88]\nset 63,%l7\nst %l7,[%fp+-244]\nset 63,%l7\nst %l7,[%fp+-400]\nset 64,%l7\nst %l7,[%fp+-84]\nset 64,%l7\nst %l7,[%fp+-240]\nset 64,%l7\nst %l7,[%fp+-396]\nset 255,%l7\nst %l7,[%fp+-80]\nset 255,%l7\nst %l7,[%fp+-236]\nset 255,%l7\nst %l7,[%fp+-392]\nset 256,%l7\nst %l7,[%fp+-76]\nset 256,%l7\nst %l7,[%fp+-232]\nset 256,%l7\nst %l7,[%fp+-388]\nset 4095,%l7\nst %l7,[%fp+-72]\nset 4095,%l7\nst %l7,[%fp+-228]\nset 4095,%l7\nst %l7,[%fp+-384]\nset 4096,%l7\nst %l7,[%fp+-68]\nset 4096,%l7\nst %l7,[%fp+-224]\nset 4096,%l7\nst %l7,[%fp+-380]\nset 65535,%l7\nst %l7,[%fp+-64]\nset 65535,%l7\nst %l7,[%fp+-220]\nset 65535,%l7\nst %l7,[%fp+-376]\nset 65536,%l7\nst %l7,[%fp+-60]\nset 65536,%l7\nst %l7,[%fp+-216]\nset 65536,%l7\nst %l7,[%fp+-372]\nset 262143,%l7\nst %l7,[%fp+-56]\nset 262143,%l7\nst %l7,[%fp+-212]\nset 262143,%l7\nst %l7,[%fp+-368]\nset 262144,%l7\nst %l7,[%fp+-52]\nset 262144,%l7\nst %l7,[%fp+-208]\nset 262144,%l7\nst %l7,[%fp+-364]\nset 1048575,%l7\nst %l7,[%fp+-48]\nset 1048575,%l7\nst %l7,[%fp+-204]\nset 1048575,%l7\nst %l7,[%fp+-360]\nset 1048576,%l7\nst %l7,[%fp+-44]\nset 1048576,%l7\nst %l7,[%fp+-200]\nset 1048576,%l7\nst %l7,[%fp+-356]\nset 16777215,%l7\nst %l7,[%fp+-40]\nset 16777215,%l7\nst %l7,[%fp+-196]\nset 16777215,%l7\nst %l7,[%fp+-352]\nset 16777216,%l7\nst %l7,[%fp+-36]\nset 16777216,%l7\nst %l7,[%fp+-192]\nset 16777216,%l7\nst %l7,[%fp+-348]\nset 268435455,%l7\nst %l7,[%fp+-32]\nset 268435455,%l7\nst %l7,[%fp+-188]\nset 268435455,%l7\nst %l7,[%fp+-344]\nset 268435456,%l7\nst %l7,[%fp+-28]\nset 268435456,%l7\nst %l7,[%fp+-184]\nset 268435456,%l7\nst %l7,[%fp+-340]\nset 1073741823,%l7\nst %l7,[%fp+-24]\nset 1073741823,%l7\nst %l7,[%fp+-180]\nset 1073741823,%l7\nst %l7,[%fp+-336]\nset 1073741824,%l7\nst %l7,[%fp+-20]\nset 1073741824,%l7\nst %l7,[%fp+-176]\nset 1073741824,%l7\nst %l7,[%fp+-332]\nset 0xffffffff,%l7\nst %l7,[%fp+-16]\nset 0xffffffff,%l7\nst %l7,[%fp+-172]\nset 0xffffffff,%l7\nst %l7,[%fp+-328]\nset 0xffffffff,%l7\nst %l7,[%fp+-12]\nset 0xffffffff,%l7\nst %l7,[%fp+-168]\nset 0xffffffff,%l7\nst %l7,[%fp+-324]\nset 0xffffffff,%l7\nst %l7,[%fp+-8]\nset 0xffffffff,%l7\nst %l7,[%fp+-164]\nset 0xffffffff,%l7\nst %l7,[%fp+-320]\nset 0xffffffff,%l7\nst %l7,[%fp+-4]\nset 0xffffffff,%l7\nst %l7,[%fp+-160]\nset 0xffffffff,%l7\nst %l7,[%fp+-316]\nmov %g0,%i5\n.L188:\nsll %i5,2,%l7\nadd -156,%fp,%l6\nld [%l7+%l6],%l6\nset .45,%l5\nld [%l7+%l5],%l5\ncmp %l5,%l6; bne .L195; nop\nadd -312,%fp,%l5\nld [%l7+%l5],%l5\ncmp %l6,%l5; bne .L195; nop\nadd -468,%fp,%l6\nld [%l7+%l6],%l7\ncmp %l5,%l7; be .L192; nop\n.L195:\nld [%i0+40],%l7\ncmp %l7,0; be .L196; nop\nset .L198,%o0\ncall printf; nop\nset .L199,%o0\ncall printf; nop\n.L196:\n.L192:\n.L189:\nadd %i5,1,%i5\ncmp %i5,39; bl .L188; nop\ncmp %i1,0; be .L200; nop\nset 16,%i2\n.L200:\nmov %i2,%i0\n.L42:\nret; restore\n.type s241,#function\n.size s241,.-s241\n.global pow2\n.align 4\npow2:\nset 1,%o5\nba .L204; nop\n.L203:\nsll %o5,1,%o5\n.L204:\nmov %o0,%o4\nsub %o4,1,%o0\ncmp %o4,0; bne .L203; nop\nmov %o5,%o0\n.L202:\nretl; nop\n.type pow2,#function\n.size pow2,.-pow2\n.section \".data\"\n.type .207,#object\n.align 1\n.207:\n.byte 115\n.byte 50\n.byte 52\n.byte 51\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size .207,11\n.type .208,#object\n.size .208,8\n.align 1\n.208:\n.byte 115\n.byte 50\n.byte 52\n.byte 51\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.global s243\n.section \".text\"\n.align 4\ns243:\nsave %sp,-352,%sp\nmov %g0,%i3\nset .208,%i5\nadd %i0,60,%i4\n.L209:\n.L210:\nmov %i4,%i2\nadd %i2,1,%i4\nmov %i5,%i1\nadd %i1,1,%i5\nldsb [%i1],%i1\nstb %i1,[%i2]\nsll %i1,8*(4-1),%i2; sra %i2,8*(4-1),%i2\ncmp %i2,0; bne .L209; nop\nadd -256,%fp,%o0\ncall zerofill; nop\nset 1,%i2\nstb %i2,[%fp+-159]\nset 1,%i2\nstb %i2,[%fp+-191]\nset 1,%i2\nstb %i2,[%fp+-130]\nset 1,%i2\nstb %i2,[%fp+-208]\nset 1,%i2\nstb %i2,[%fp+-158]\nset 1,%i2\nstb %i2,[%fp+-190]\nset 1,%i2\nstb %i2,[%fp+-223]\nset 1,%i2\nstb %i2,[%fp+-207]\nset 1,%i2\nstb %i2,[%fp+-157]\nset 1,%i2\nstb %i2,[%fp+-189]\nset 1,%i2\nstb %i2,[%fp+-222]\nset 1,%i2\nstb %i2,[%fp+-206]\nset 1,%i2\nstb %i2,[%fp+-156]\nset 1,%i2\nstb %i2,[%fp+-188]\nset 1,%i2\nstb %i2,[%fp+-221]\nset 1,%i2\nstb %i2,[%fp+-205]\nset 1,%i2\nstb %i2,[%fp+-155]\nset 1,%i2\nstb %i2,[%fp+-187]\nset 1,%i2\nstb %i2,[%fp+-219]\nset 1,%i2\nstb %i2,[%fp+-204]\nset 1,%i2\nstb %i2,[%fp+-154]\nset 1,%i2\nstb %i2,[%fp+-186]\nset 1,%i2\nstb %i2,[%fp+-218]\nset 1,%i2\nstb %i2,[%fp+-203]\nset 1,%i2\nstb %i2,[%fp+-153]\nset 1,%i2\nstb %i2,[%fp+-185]\nset 1,%i2\nstb %i2,[%fp+-216]\nset 1,%i2\nstb %i2,[%fp+-202]\nset 1,%i2\nstb %i2,[%fp+-152]\nset 1,%i2\nstb %i2,[%fp+-184]\nset 1,%i2\nstb %i2,[%fp+-215]\nset 1,%i2\nstb %i2,[%fp+-201]\nset 1,%i2\nstb %i2,[%fp+-151]\nset 1,%i2\nstb %i2,[%fp+-183]\nset 1,%i2\nstb %i2,[%fp+-161]\nset 1,%i2\nstb %i2,[%fp+-200]\nset 1,%i2\nstb %i2,[%fp+-150]\nset 1,%i2\nstb %i2,[%fp+-182]\nset 1,%i2\nstb %i2,[%fp+-195]\nset 1,%i2\nstb %i2,[%fp+-199]\nset 1,%i2\nstb %i2,[%fp+-149]\nset 1,%i2\nstb %i2,[%fp+-181]\nset 1,%i2\nstb %i2,[%fp+-211]\nset 1,%i2\nstb %i2,[%fp+-148]\nset 1,%i2\nstb %i2,[%fp+-180]\nset 1,%i2\nstb %i2,[%fp+-162]\nset 1,%i2\nstb %i2,[%fp+-147]\nset 1,%i2\nstb %i2,[%fp+-179]\nset 1,%i2\nstb %i2,[%fp+-132]\nset 1,%i2\nstb %i2,[%fp+-246]\nset 1,%i2\nstb %i2,[%fp+-146]\nset 1,%i2\nstb %i2,[%fp+-178]\nset 1,%i2\nstb %i2,[%fp+-247]\nset 1,%i2\nstb %i2,[%fp+-145]\nset 1,%i2\nstb %i2,[%fp+-177]\nset 1,%i2\nstb %i2,[%fp+-133]\nset 1,%i2\nstb %i2,[%fp+-248]\nset 1,%i2\nstb %i2,[%fp+-144]\nset 1,%i2\nstb %i2,[%fp+-176]\nset 1,%i2\nstb %i2,[%fp+-131]\nset 1,%i2\nstb %i2,[%fp+-243]\nset 1,%i2\nstb %i2,[%fp+-143]\nset 1,%i2\nstb %i2,[%fp+-175]\nset 1,%i2\nstb %i2,[%fp+-165]\nset 1,%i2\nstb %i2,[%fp+-244]\nset 1,%i2\nstb %i2,[%fp+-142]\nset 1,%i2\nstb %i2,[%fp+-174]\nset 1,%i2\nstb %i2,[%fp+-163]\nset 1,%i2\nstb %i2,[%fp+-141]\nset 1,%i2\nstb %i2,[%fp+-173]\nset 1,%i2\nstb %i2,[%fp+-213]\nset 1,%i2\nstb %i2,[%fp+-164]\nset 1,%i2\nstb %i2,[%fp+-140]\nset 1,%i2\nstb %i2,[%fp+-172]\nset 1,%i2\nstb %i2,[%fp+-197]\nset 1,%i2\nstb %i2,[%fp+-217]\nset 1,%i2\nstb %i2,[%fp+-139]\nset 1,%i2\nstb %i2,[%fp+-171]\nset 1,%i2\nstb %i2,[%fp+-214]\nset 1,%i2\nstb %i2,[%fp+-138]\nset 1,%i2\nstb %i2,[%fp+-170]\nset 1,%i2\nstb %i2,[%fp+-198]\nset 1,%i2\nstb %i2,[%fp+-256]\nstb %i2,[%fp+-137]\nset 1,%i2\nstb %i2,[%fp+-169]\nset 1,%i2\nstb %i2,[%fp+-196]\nset 1,%i2\nstb %i2,[%fp+-224]\nset 1,%i2\nstb %i2,[%fp+-136]\nset 1,%i2\nstb %i2,[%fp+-168]\nset 1,%i2\nstb %i2,[%fp+-194]\nset 1,%i2\nstb %i2,[%fp+-135]\nset 1,%i2\nstb %i2,[%fp+-167]\nset 1,%i2\nstb %i2,[%fp+-212]\nset 1,%i2\nstb %i2,[%fp+-134]\nset 1,%i2\nstb %i2,[%fp+-166]\nset 1,%i2\nstb %i2,[%fp+-210]\nset 1,%i2\nstb %i2,[%fp+-193]\nset 1,%i2\nstb %i2,[%fp+-209]\nadd -256,%fp,%o0\ncall sumof; nop\ncmp %o0,98; be .L309; nop\nadd %i3,1,%i3\nld [%i0+44],%i2\ncmp %i2,0; be .L311; nop\nset .207,%o0\nset 1,%o1\ncall printf; nop\n.L311:\n.L309:\nba .L313; nop\nadd %i3,8,%i3\nld [%i0+44],%i2\ncmp %i2,0; be .L315; nop\nset .207,%o0\nset 8,%o1\ncall printf; nop\n.L315:\n.L313:\nmov %i3,%i0\n.L206:\nret; restore\n.type s243,#function\n.size s243,.-s243\n.global zerofill\n.align 4\nzerofill:\nmov %g0,%o5\n.L318:\nmov %o0,%o4\nadd %o4,1,%o0\nstb %g0,[%o4]\n.L319:\nadd %o5,1,%o5\ncmp %o5,256; bl .L318; nop\nmov %g0,%o0\n.L317:\nretl; nop\n.type zerofill,#function\n.size zerofill,.-zerofill\n.global sumof\n.align 4\nsumof:\nmov %o0,%o3\nmov %g0,%o5\nmov %g0,%o4\n.L323:\nmov %o3,%o2\nadd %o2,1,%o3\nldsb [%o2],%o2\nadd %o5,%o2,%o5\n.L324:\nadd %o4,1,%o4\ncmp %o4,256; bl .L323; nop\nmov %o5,%o0\n.L322:\nretl; nop\n.type sumof,#function\n.size sumof,.-sumof\n.section \".data\"\n.type .328,#object\n.align 1\n.328:\n.byte 115\n.byte 50\n.byte 52\n.byte 52\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size .328,11\n.type .329,#object\n.size .329,8\n.align 1\n.329:\n.byte 115\n.byte 50\n.byte 52\n.byte 52\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.global s244\n.section \".text\"\n.align 4\ns244:\nsave %sp,-160,%sp\nset .329,%i4\nadd %i0,60,%i3\n.L330:\n.L331:\nmov %i3,%l7\nadd %l7,1,%i3\nmov %i4,%l6\nadd %l6,1,%i4\nldsb [%l6],%l6\nstb %l6,[%l7]\nsll %l6,8*(4-1),%l7; sra %l7,8*(4-1),%l7\ncmp %l7,0; bne .L330; nop\nmov %g0,%i1\nmov %g0,%i2\nset .L333,%l7\nld2 [%l7],%f30\nstd %f30,[%fp+-64]\nstd %f30,[%fp+-56]\nset .L333,%l7\nld2 [%l7],%f30\nstd %f30,[%fp+-48]\nset .L333,%l7\nld2 [%l7],%f30\nstd %f30,[%fp+-40]\nset .L333,%l7\nld2 [%l7],%f30\nstd %f30,[%fp+-32]\nset .L333,%l7\nld2 [%l7],%f30\nstd %f30,[%fp+-24]\nset .L333,%l7\nld2 [%l7],%f30\nstd %f30,[%fp+-16]\nset .L333,%l7\nld2 [%l7],%f30\nstd %f30,[%fp+-8]\nmov %g0,%i2\nmov %g0,%i5\n.L341:\nsll %i5,3,%l7\nadd -64,%fp,%l6\nadd %l7,%l6,%l6\nld2 [%l6],%f30\nadd -56,%fp,%l6\nadd %l7,%l6,%l7\nld2 [%l7],%f28\nfcmped %f30,%f28; nop; fbue .L345; nop\nset 1,%i2\n.L345:\n.L342:\nadd %i5,1,%i5\ncmp %i5,7; bl .L341; nop\ncmp %i2,0; be .L348; nop\nld [%i0+44],%l7\ncmp %l7,0; be .L350; nop\nset .328,%o0\nset 1,%o1\ncall printf; nop\n.L350:\nadd %i1,1,%i1\n.L348:\nba .L352; nop\nld [%i0+44],%l7\ncmp %l7,0; be .L354; nop\nset .328,%o0\nset 2,%o1\ncall printf; nop\n.L354:\nadd %i1,2,%i1\n.L352:\nmov %i1,%i0\n.L327:\nret; restore\n.type s244,#function\n.size s244,.-s244\n.section \".data\"\n.type .357,#object\n.align 1\n.357:\n.byte 115\n.byte 50\n.byte 53\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size .357,10\n.type .358,#object\n.size .358,8\n.align 1\n.358:\n.byte 115\n.byte 50\n.byte 53\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.global s25\n.section \".text\"\n.align 4\ns25:\nsave %sp,-96,%sp\nset .358,%i2\nadd %i0,60,%i1\n.L359:\n.L360:\nmov %i1,%l5\nadd %l5,1,%i1\nmov %i2,%l4\nadd %l4,1,%i2\nldsb [%l4],%l4\nstb %l4,[%l5]\nsll %l4,8*(4-1),%l5; sra %l5,8*(4-1),%l5\ncmp %l5,0; bne .L359; nop\nmov %g0,%l7\nset .L362,%i4\nldsb [%i4+1],%l5\nldsb [%i4],%l4\ncmp %l4,%l5; bne .L366; nop\nldsb [%i4+2],%l4\ncmp %l5,%l4; bne .L366; nop\ncmp %l4,46; be .L363; nop\n.L366:\nadd %l7,1,%l7\nld [%i0+44],%l5\ncmp %l5,0; be .L367; nop\nset .357,%o0\nset 1,%o1\ncall printf; nop\n.L367:\n.L363:\nldsb [%i4+3],%l5\ncmp %l5,0; be .L369; nop\nadd %l7,4,%l7\nld [%i0+44],%l5\ncmp %l5,0; be .L371; nop\nset .357,%o0\nset 4,%o1\ncall printf; nop\n.L371:\n.L369:\nset .L375+1,%l5\nldsb [%l5],%l5\ncmp %l5,34; be .L373; nop\nadd %l7,8,%l7\nld [%i0+44],%l5\ncmp %l5,0; be .L377; nop\nset .357,%o0\nset 8,%o1\ncall printf; nop\n.L377:\n.L373:\nset .L379,%i4\nldsb [%i4],%l5\ncmp %l5,10; bne .L387; nop\nldsb [%i4+1],%l5\ncmp %l5,9; bne .L387; nop\nldsb [%i4+2],%l5\ncmp %l5,8; bne .L387; nop\nldsb [%i4+3],%l5\ncmp %l5,13; bne .L387; nop\nldsb [%i4+4],%l5\ncmp %l5,12; bne .L387; nop\nldsb [%i4+5],%l5\ncmp %l5,92; bne .L387; nop\nldsb [%i4+6],%l5\ncmp %l5,39; be .L380; nop\n.L387:\nadd %l7,16,%l7\nld [%i0+44],%l5\ncmp %l5,0; be .L388; nop\nset .357,%o0\nset 16,%o1\ncall printf; nop\n.L388:\n.L380:\nset .L390,%l5\nmov %l5,%i3\nmov %l5,%i4\nmov %g0,%l6\nmov %g0,%i5\nba .L394; nop\n.L391:\nldsb [%i5+%i4],%l5\nldsb [%i5+%i3],%l4\ncmp %l5,%l4; be .L395; nop\nset 1,%l6\n.L395:\n.L392:\nadd %i5,1,%i5\n.L394:\nmov %i5,%l5\nset 7,%l4\ncmp %l5,%l4; blu .L391; nop\ncmp %l6,0; be .L397; nop\nadd %l7,32,%l7\nld [%i0+44],%l5\ncmp %l5,0; be .L399; nop\nset .357,%o0\nset 32,%o1\ncall printf; nop\n.L399:\n.L397:\nmov %l7,%i0\n.L356:\nret; restore\n.type s25,#function\n.size s25,.-s25\n.section \".data\"\n.type .402,#object\n.size .402,8\n.align 1\n.402:\n.byte 115\n.byte 50\n.byte 54\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.type .403,#object\n.align 1\n.403:\n.byte 37\n.byte 51\n.byte 100\n.byte 32\n.byte 98\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 37\n.byte 115\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.size .403,18\n.type .404,#object\n.align 1\n.404:\n.byte 37\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 108\n.byte 101\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 97\n.byte 100\n.byte 100\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 49\n.byte 46\n.byte 32\n.byte 40\n.byte 37\n.byte 115\n.byte 41\n.byte 46\n.byte 10\n.byte 0\n.size .404,54\n.global s26\n.section \".text\"\n.align 4\ns26:\nsave %sp,-128,%sp\nset .402,%i4\nadd %i0,60,%i3\n.L405:\n.L406:\nmov %i3,%i1\nadd %i1,1,%i3\nmov %i4,%l7\nadd %l7,1,%i4\nldsb [%l7],%l7\nstb %l7,[%i1]\nsll %l7,8*(4-1),%i1; sra %i1,8*(4-1),%i1\ncmp %i1,0; bne .L405; nop\nst %g0,[%i0]\nmov %g0,%i2\nset 1,%i5\nba .L409; nop\n.L408:\nsll %i5,8*(4-1),%i1; sra %i1,8*(4-1),%i1\nsll %i1,1,%i1\nmov %i1,%i5\nld [%i0],%i1\nadd %i1,1,%i1\nst %i1,[%i0]\n.L409:\nsll %i2,8*(4-1),%i1; sra %i1,8*(4-1),%i1\nsll %i5,8*(4-1),%l7; sra %l7,8*(4-1),%l7\ncmp %i1,%l7; bne .L408; nop\nld [%i0],%i1\nsll %i1,2,%i1\nst %i1,[%i0+4]\nld [%i0],%i1\nsll %i1,1,%i1\nst %i1,[%i0+8]\nld [%i0],%i1\nsll %i1,2,%i1\nst %i1,[%i0+12]\nld [%i0],%i1\nsll %i1,2,%i1\nst %i1,[%i0+16]\nld [%i0],%i1\nsll %i1,2,%i1\nst %i1,[%i0+20]\nld [%i0],%i1\nsll %i1,3,%i1\nst %i1,[%i0+24]\nset .L411,%i1\nld [%i1],%f31\nst %f31,[%fp+-12]\nst %f31,[%fp+-4]\nset .L412,%i1\nld [%i1],%f31\nst %f31,[%fp+-8]\nba .L414; nop\n.L413:\nld [%fp+-4],%f31\nld [%fp+-12],%f30\nfadds %f30,%f31,%f30\nst %f30,[%fp+-8]\nfstod %f31,%f30\nset .L416,%i1\nld2 [%i1],%f28\nfdivd %f30,%f28,%f30\nfdtos %f30,%f31\nst %f31,[%fp+-4]\n.L414:\nld [%fp+-8],%f31\nld [%fp+-12],%f30\nfcmpes %f31,%f30; nop; fbne .L413; nop\nset .L417,%i1\nld2 [%i1],%f30\nld [%fp+-4],%f29\nfstod %f29,%f28\nfmuld %f30,%f28,%f30\nfdtos %f30,%f31\nst %f31,[%i0+28]\nset .L418,%i1\nld2 [%i1],%f30\nstd %f30,[%fp+-32]\nset .L411,%i1\nld [%i1],%f31\nst %f31,[%fp+-4]\nset .L419,%i1\nld2 [%i1],%f30\nstd %f30,[%fp+-24]\nba .L421; nop\n.L420:\nld [%fp+-4],%f31\nfstod %f31,%f30\nldd [%fp+-32],%f28\nfaddd %f28,%f30,%f28\nstd %f28,[%fp+-24]\nset .L416,%i1\nld2 [%i1],%f28\nfdivd %f30,%f28,%f30\nfdtos %f30,%f31\nst %f31,[%fp+-4]\n.L421:\nldd [%fp+-24],%f30\nldd [%fp+-32],%f28\nfcmped %f30,%f28; nop; fbne .L420; nop\nset .L417,%i1\nld2 [%i1],%f30\nld [%fp+-4],%f29\nfstod %f29,%f28\nfmuld %f30,%f28,%f30\nfdtos %f30,%f31\nst %f31,[%i0+32]\nld [%i0+40],%i1\ncmp %i1,0; be .L423; nop\nset .403,%o0\nld [%i0],%o1\nset .L425,%o2\ncall printf; nop\nset .403,%o0\nld [%i0+4],%o1\nset .L426,%o2\ncall printf; nop\nset .403,%o0\nld [%i0+8],%o1\nset .L427,%o2\ncall printf; nop\nset .403,%o0\nld [%i0+12],%o1\nset .L428,%o2\ncall printf; nop\nset .403,%o0\nld [%i0+16],%o1\nset .L429,%o2\ncall printf; nop\nset .403,%o0\nld [%i0+20],%o1\nset .L430,%o2\ncall printf; nop\nset .403,%o0\nld [%i0+24],%o1\nset .L431,%o2\ncall printf; nop\nset .404,%o0\nld [%i0+28],%f31\nfstod %f31,%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\nset .L430,%o3\ncall printf; nop\nset .404,%o0\nld [%i0+32],%f31\nfstod %f31,%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\nset .L431,%o3\ncall printf; nop\n.L423:\nmov %g0,%i0\n.L401:\nret; restore\n.type s26,#function\n.size s26,.-s26\n.section \".data\"\n.type .433,#object\n.align 1\n.433:\n.byte 115\n.byte 52\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size .433,9\n.type .434,#object\n.size .434,8\n.align 1\n.434:\n.byte 115\n.byte 52\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.global s4\n.section \".text\"\n.align 4\ns4:\nsave %sp,-96,%sp\nmov %g0,%l7\nset .434,%i2\nadd %i0,60,%i1\n.L435:\n.L436:\nmov %i1,%l3\nadd %l3,1,%i1\nmov %i2,%l2\nadd %l2,1,%i2\nldsb [%l2],%l2\nstb %l2,[%l3]\nsll %l2,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,0; bne .L435; nop\nmov %g0,%i5\n.L438:\nmov %i5,%o0\ncall svtest; nop\nmov %o0,%l3\ncall zero; nop\ncmp %l3,%o0; be .L442; nop\nset 1,%l7\nld [%i0+44],%l3\ncmp %l3,0; be .L444; nop\nset .433,%o0\nset 1,%o1\ncall printf; nop\n.L444:\n.L442:\n.L439:\nadd %i5,1,%i5\ncmp %i5,3; bl .L438; nop\ncall setev; nop\ncall testev; nop\ncmp %o0,0; be .L446; nop\nadd %l7,2,%l7\nld [%i0+44],%l3\ncmp %l3,0; be .L448; nop\nset .433,%o0\nset 2,%o1\ncall printf; nop\n.L448:\n.L446:\nba .L450; nop\nadd %l7,4,%l7\nld [%i0+44],%l3\ncmp %l3,0; be .L452; nop\nset .433,%o0\nset 4,%o1\ncall printf; nop\n.L452:\n.L450:\nset 0xffffffff,%i4\nset 1,%i3\nmov %g0,%i5\nba .L457; nop\n.L454:\nand %i3,%i4,%i3\nsrl %i4,1,%i4\n.L455:\nadd %i5,1,%i5\n.L457:\nmov %i5,%l3\nld [%i0],%l2\nsll %l2,2,%l2\ncmp %l3,%l2; blu .L454; nop\nset 1,%l3\ncmp %i3,%l3; bne .L460; nop\ncmp %i4,%g0; be .L458; nop\n.L460:\nadd %l7,8,%l7\nld [%i0+44],%l3\ncmp %l3,0; be .L461; nop\nset .433,%o0\nset 8,%o1\ncall printf; nop\n.L461:\n.L458:\nmov %l7,%i0\n.L432:\nret; restore\n.type s4,#function\n.size s4,.-s4\n.section \".bss\"\n.type .464,#object\n.size .464,4\n.local .464\n.common .464,4,4\n.global svtest\n.section \".text\"\n.align 4\nsvtest:\ncmp %o0,0; be .L467; nop\ncmp %o0,1; be .L468; nop\ncmp %o0,2; be .L471; nop\nba .L465; nop\n.L467:\nset .464,%o4\nset 1978,%o3\nst %o3,[%o4]\nmov %g0,%o5\nba .L466; nop\n.L468:\nset .464,%o4\nld [%o4],%o4\ncmp %o4,1978; be .L469; nop\nset 1,%o5\nba .L466; nop\n.L469:\nset .464,%o4\nset 1929,%o3\nst %o3,[%o4]\nmov %g0,%o5\nba .L466; nop\n.L471:\nset .464,%o4\nld [%o4],%o4\ncmp %o4,1929; be .L472; nop\nset 1,%o5\nba .L466; nop\n.L472:\nmov %g0,%o5\n.L465:\n.L466:\nmov %o5,%o0\n.L463:\nretl; nop\n.type svtest,#function\n.size svtest,.-svtest\n.section \".bss\"\n.type .475,#object\n.size .475,4\n.local .475\n.common .475,4,4\n.global zero\n.section \".text\"\n.align 4\nzero:\nset .475,%o4\nset 2,%o3\nst %o3,[%o4]\nmov %g0,%o5\nmov %o5,%o0\n.L474:\nretl; nop\n.type zero,#function\n.size zero,.-zero\n.global testev\n.align 4\ntestev:\nset extvar,%o5\nld [%o5],%o5\ncmp %o5,1066; be .L477; nop\nset 1,%o0\nba .L476; nop\n.L477:\nmov %g0,%o0\n.L476:\nretl; nop\n.type testev,#function\n.size testev,.-testev\n.section \".data\"\n.type .480,#object\n.align 1\n.480:\n.byte 115\n.byte 54\n.byte 49\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size .480,10\n.type .481,#object\n.size .481,8\n.align 1\n.481:\n.byte 115\n.byte 54\n.byte 49\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.type .482,#object\n.align 1\n.482:\n.byte 65\n.byte 66\n.byte 67\n.byte 68\n.byte 69\n.byte 70\n.byte 71\n.byte 72\n.byte 73\n.byte 74\n.byte 75\n.byte 76\n.byte 77\n.byte 78\n.byte 79\n.byte 80\n.byte 81\n.byte 82\n.byte 83\n.byte 84\n.byte 85\n.byte 86\n.byte 87\n.byte 88\n.byte 89\n.byte 90\n.byte 0\n.size .482,27\n.type .483,#object\n.align 1\n.483:\n.byte 97\n.byte 98\n.byte 99\n.byte 100\n.byte 101\n.byte 102\n.byte 103\n.byte 104\n.byte 105\n.byte 106\n.byte 107\n.byte 108\n.byte 109\n.byte 110\n.byte 111\n.byte 112\n.byte 113\n.byte 114\n.byte 115\n.byte 116\n.byte 117\n.byte 118\n.byte 119\n.byte 120\n.byte 121\n.byte 122\n.byte 0\n.size .483,27\n.type .484,#object\n.align 1\n.484:\n.byte 48\n.byte 49\n.byte 50\n.byte 51\n.byte 52\n.byte 53\n.byte 54\n.byte 55\n.byte 56\n.byte 57\n.byte 0\n.size .484,11\n.type .485,#object\n.align 1\n.485:\n.byte 126\n.byte 33\n.byte 34\n.byte 35\n.byte 37\n.byte 38\n.byte 40\n.byte 41\n.byte 95\n.byte 61\n.byte 45\n.byte 94\n.byte 124\n.byte 123\n.byte 125\n.byte 91\n.byte 93\n.byte 43\n.byte 59\n.byte 42\n.byte 58\n.byte 60\n.byte 62\n.byte 44\n.byte 46\n.byte 63\n.byte 47\n.byte 0\n.size .485,28\n.type .486,#object\n.align 1\n.486:\n.byte 10\n.byte 9\n.byte 8\n.byte 13\n.byte 12\n.byte 92\n.byte 39\n.byte 0\n.size .486,8\n.type .487,#object\n.align 1\n.487:\n.byte 32\n.byte 0\n.byte 0\n.size .487,3\n.global s61\n.section \".text\"\n.align 4\ns61:\nsave %sp,-120,%sp\nset .481,%i3\nadd %i0,60,%i2\nmov %g0,%l7\n.L488:\n.L489:\nmov %i2,%l3\nadd %l3,1,%i2\nmov %i3,%l2\nadd %l2,1,%i3\nldsb [%l2],%l2\nstb %l2,[%l3]\nsll %l2,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,0; bne .L488; nop\nset -19,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%fp+-28]\nld [%fp+-28],%l3\ncmp %l3,-19; be .L491; nop\nadd %l7,1,%l7\nld [%i0+44],%l3\ncmp %l3,0; be .L493; nop\nset .480,%o0\nset 1,%o1\ncall printf; nop\n.L493:\n.L491:\nset .482,%l3\nst %l3,[%fp+-24]\nset .483,%l3\nst %l3,[%fp+-20]\nset .484,%l3\nst %l3,[%fp+-16]\nset .485,%l3\nst %l3,[%fp+-12]\nset .486,%l3\nst %l3,[%fp+-8]\nset .487,%l3\nst %l3,[%fp+-4]\nmov %g0,%i4\nmov %g0,%i5\nba .L505; nop\n.L504:\nsll %i5,2,%l3\nadd -24,%fp,%l2\nadd %l3,%l2,%l3\nld [%l3],%l2\nadd %l2,1,%l1\nst %l1,[%l3]\nldsb [%l2],%l3\ncmp %l3,0; bge .L507; nop\nset 1,%i4\n.L507:\n.L505:\nsll %i5,2,%l3\nadd -24,%fp,%l2\nld [%l3+%l2],%l3\nldsb [%l3],%l3\ncmp %l3,0; bne .L504; nop\n.L501:\nadd %i5,1,%i5\ncmp %i5,6; bl .L505; nop\ncmp %i4,0; be .L509; nop\nadd %l7,2,%l7\nld [%i0+44],%l3\ncmp %l3,0; be .L511; nop\nset .480,%o0\nset 2,%o1\ncall printf; nop\n.L511:\n.L509:\nset 1048579,%i1\nmov %i1,%l6\nmov %i1,%l5\nsll %l6,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,%i1; be .L516; nop\ncmp %l3,3; bne .L515; nop\n.L516:\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,%i1; be .L513; nop\ncmp %l3,3; be .L513; nop\n.L515:\nadd %l7,8,%l7\nld [%i0+44],%l3\ncmp %l3,0; be .L517; nop\nset .480,%o0\nset 8,%o1\ncall printf; nop\n.L517:\n.L513:\nmov %l7,%i0\n.L479:\nret; restore\n.type s61,#function\n.size s61,.-s61\n.section \".data\"\n.type .520,#object\n.align 1\n.520:\n.byte 115\n.byte 54\n.byte 50\n.byte 54\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size .520,11\n.type .521,#object\n.size .521,8\n.align 1\n.521:\n.byte 115\n.byte 54\n.byte 50\n.byte 54\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.global s626\n.section \".text\"\n.align 4\ns626:\nsave %sp,-176,%sp\nset .521,%i2\nadd %i0,60,%i1\nst %g0,[%fp+-76]\n.L522:\n.L523:\nmov %i1,%l3\nadd %l3,1,%i1\nmov %i2,%l2\nadd %l2,1,%i2\nldsb [%l2],%l2\nstb %l2,[%l3]\nsll %l2,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,0; bne .L522; nop\nset .L411,%l3\nld [%l3],%f31\nst %f31,[%fp+-32]\nset 1,%l3\nmov %l3,%l7\nmov %l3,%i4\nmov %g0,%i5\nba .L528; nop\n.L525:\nset .L529,%l3\nld [%l3],%f31\nld [%fp+-32],%f30\nfmuls %f31,%f30,%f31\nst %f31,[%fp+-32]\nsll %i4,1,%l3\nor %l3,%l7,%i4\n.L526:\nadd %i5,1,%i5\n.L528:\nld [%i0+12],%l3\nsub %l3,2,%l3\ncmp %i5,%l3; bl .L525; nop\nst %i4,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nst %f31,[%fp+-84]\nld [%fp+-32],%f31\nld [%fp+-84],%f30\nfsubs %f31,%f30,%f30\nfdivs %f30,%f31,%f31\nst %f31,[%fp+-32]\nld [%fp+-32],%f31\nfstod %f31,%f30\nset .L416,%l3\nld2 [%l3],%f28\nld [%i0+28],%f27\nfstod %f27,%f26\nfmuld %f28,%f26,%f28\nfcmped %f30,%f28; nop; fbule .L530; nop\nld [%fp+-76],%l3\nadd %l3,2,%l3\nst %l3,[%fp+-76]\nld [%i0+44],%l3\ncmp %l3,0; be .L532; nop\nset .520,%o0\nset 2,%o1\ncall printf; nop\n.L532:\n.L530:\nset 125,%l5\nset 125,%l4\nset 125,%l3\nst %l3,[%fp+-48]\nset 15625,%l3\nst %l3,[%fp+-68]\nset 125,%l3\nst %l3,[%fp+-52]\nset 15625,%l3\nst %l3,[%fp+-72]\nset 125,%l6\nset 15625,%l3\nst %l3,[%fp+-80]\nset .L534,%l3\nld [%l3],%f31\nst %f31,[%fp+-44]\nset .L535,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-64]\nset .L536,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nmov %g0,%i5\n.L537:\nadd -28,%fp,%l3\nstb %g0,[%i5+%l3]\n.L538:\nadd %i5,1,%i5\ncmp %i5,28; bl .L537; nop\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsmul %l3,%l3,%l3\nld [%fp+-68],%l2\ncmp %l3,%l2; be .L541; nop\nset 1,%l3\nstb %l3,[%fp+-28]\n.L541:\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nsmul %l2,%l3,%l3\nld [%fp+-68],%l2\ncmp %l3,%l2; be .L543; nop\nset 1,%l3\nstb %l3,[%fp+-27]\n.L543:\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsmul %l3,%l3,%l3\nld [%fp+-68],%l2\ncmp %l3,%l2; be .L546; nop\nset 1,%l3\nstb %l3,[%fp+-26]\n.L546:\nld [%fp+-48],%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nsmul %l2,%l3,%l3\nld [%fp+-68],%l2\ncmp %l3,%l2; be .L549; nop\nset 1,%l3\nstb %l3,[%fp+-25]\n.L549:\nld [%fp+-48],%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\nsmul %l2,%l3,%l3\nld [%fp+-68],%l2\ncmp %l3,%l2; be .L552; nop\nset 1,%l3\nstb %l3,[%fp+-24]\n.L552:\nld [%fp+-48],%l3\nsmul %l3,%l3,%l3\nld [%fp+-68],%l2\ncmp %l3,%l2; be .L555; nop\nset 1,%l3\nstb %l3,[%fp+-23]\n.L555:\nld [%fp+-52],%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\numul %l2,%l3,%l3\nld [%fp+-72],%l2\ncmp %l3,%l2; be .L558; nop\nset 1,%l3\nstb %l3,[%fp+-22]\n.L558:\nld [%fp+-52],%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\numul %l2,%l3,%l3\nld [%fp+-72],%l2\ncmp %l3,%l2; be .L561; nop\nset 1,%l3\nstb %l3,[%fp+-21]\n.L561:\nld [%fp+-52],%l3\nld [%fp+-48],%l2\numul %l2,%l3,%l3\nld [%fp+-72],%l2\ncmp %l3,%l2; be .L564; nop\nset 1,%l3\nstb %l3,[%fp+-20]\n.L564:\nld [%fp+-52],%l3\numul %l3,%l3,%l3\nld [%fp+-72],%l2\ncmp %l3,%l2; be .L567; nop\nset 1,%l3\nstb %l3,[%fp+-19]\n.L567:\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsmul %l3,%l6,%l3\nld [%fp+-80],%l2\ncmp %l3,%l2; be .L570; nop\nset 1,%l3\nstb %l3,[%fp+-18]\n.L570:\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsmul %l3,%l6,%l3\nld [%fp+-80],%l2\ncmp %l3,%l2; be .L573; nop\nset 1,%l3\nstb %l3,[%fp+-17]\n.L573:\nld [%fp+-48],%l3\nsmul %l3,%l6,%l3\nld [%fp+-80],%l2\ncmp %l3,%l2; be .L576; nop\nset 1,%l3\nstb %l3,[%fp+-16]\n.L576:\nmov %l6,%l3\nld [%fp+-52],%l2\numul %l2,%l3,%l3\nld [%fp+-72],%l2\ncmp %l3,%l2; be .L579; nop\nset 1,%l3\nstb %l3,[%fp+-15]\n.L579:\nsmul %l6,%l6,%l3\nld [%fp+-80],%l2\ncmp %l3,%l2; be .L582; nop\nset 1,%l3\nstb %l3,[%fp+-14]\n.L582:\nld [%fp+-44],%f31\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfmuls %f31,%f30,%f31\nfstod %f31,%f30\nldd [%fp+-40],%f28\nfcmped %f30,%f28; nop; fbue .L585; nop\nset 1,%l3\nstb %l3,[%fp+-13]\n.L585:\nld [%fp+-44],%f31\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfmuls %f31,%f30,%f31\nfstod %f31,%f30\nldd [%fp+-40],%f28\nfcmped %f30,%f28; nop; fbue .L588; nop\nset 1,%l3\nstb %l3,[%fp+-12]\n.L588:\nld [%fp+-44],%f31\nld [%fp+-48],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfmuls %f31,%f30,%f31\nfstod %f31,%f30\nldd [%fp+-40],%f28\nfcmped %f30,%f28; nop; fbue .L591; nop\nset 1,%l3\nstb %l3,[%fp+-11]\n.L591:\nld [%fp+-52],%l3\nld [%fp+-44],%f31\nset .L596,%l2\nld2 [%l2],%f28\nsrl %l3,1,%l2\nst %l2,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfmuld %f28,%f26,%f28\nset 1,%l2\nand %l3,%l2,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfaddd %f28,%f26,%f28\nfdtos %f28,%f30\nfmuls %f31,%f30,%f31\nfstod %f31,%f30\nldd [%fp+-40],%f28\nfcmped %f30,%f28; nop; fbue .L594; nop\nset 1,%l3\nstb %l3,[%fp+-10]\n.L594:\nld [%fp+-44],%f31\nst %l6,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfmuls %f31,%f30,%f31\nfstod %f31,%f30\nldd [%fp+-40],%f28\nfcmped %f30,%f28; nop; fbue .L598; nop\nset 1,%l3\nstb %l3,[%fp+-9]\n.L598:\nld [%fp+-44],%f31\nfmuls %f31,%f31,%f31\nfstod %f31,%f30\nldd [%fp+-40],%f28\nfcmped %f30,%f28; nop; fbue .L601; nop\nset 1,%l3\nstb %l3,[%fp+-8]\n.L601:\nldd [%fp+-64],%f30\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfmuld %f30,%f28,%f30\nldd [%fp+-40],%f28\nfcmped %f30,%f28; nop; fbue .L604; nop\nset 1,%l3\nstb %l3,[%fp+-7]\n.L604:\nldd [%fp+-64],%f30\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfmuld %f30,%f28,%f30\nldd [%fp+-40],%f28\nfcmped %f30,%f28; nop; fbue .L607; nop\nset 1,%l3\nstb %l3,[%fp+-6]\n.L607:\nldd [%fp+-64],%f30\nld [%fp+-48],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfmuld %f30,%f28,%f30\nldd [%fp+-40],%f28\nfcmped %f30,%f28; nop; fbue .L610; nop\nset 1,%l3\nstb %l3,[%fp+-5]\n.L610:\nld [%fp+-52],%l3\nldd [%fp+-64],%f30\nset .L596,%l2\nld2 [%l2],%f28\nsrl %l3,1,%l2\nst %l2,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfmuld %f28,%f26,%f28\nset 1,%l2\nand %l3,%l2,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfaddd %f28,%f26,%f28\nfmuld %f30,%f28,%f30\nldd [%fp+-40],%f28\nfcmped %f30,%f28; nop; fbue .L613; nop\nset 1,%l3\nstb %l3,[%fp+-4]\n.L613:\nldd [%fp+-64],%f30\nst %l6,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfmuld %f30,%f28,%f30\nldd [%fp+-40],%f28\nfcmped %f30,%f28; nop; fbue .L616; nop\nset 1,%l3\nstb %l3,[%fp+-3]\n.L616:\nldd [%fp+-64],%f30\nld [%fp+-44],%f29\nfstod %f29,%f28\nfmuld %f30,%f28,%f30\nldd [%fp+-40],%f28\nfcmped %f30,%f28; nop; fbue .L619; nop\nset 1,%l3\nstb %l3,[%fp+-2]\n.L619:\nldd [%fp+-64],%f30\nfmuld %f30,%f30,%f30\nldd [%fp+-40],%f28\nfcmped %f30,%f28; nop; fbue .L622; nop\nset 1,%l3\nstb %l3,[%fp+-1]\n.L622:\nmov %g0,%i3\nmov %g0,%i5\n.L625:\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nadd -28,%fp,%l2\nldsb [%i5+%l2],%l2\nadd %l3,%l2,%l3\nmov %l3,%i3\n.L626:\nadd %i5,1,%i5\ncmp %i5,28; bl .L625; nop\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,0; be .L629; nop\nld [%fp+-76],%l3\nadd %l3,4,%l3\nst %l3,[%fp+-76]\nld [%i0+44],%l3\ncmp %l3,0; be .L631; nop\nset .520,%o0\nset 4,%o1\ncall printf; nop\nset .L633,%o0\ncall printf; nop\nmov %g0,%i5\n.L634:\nset .L638,%o0\nadd -28,%fp,%l3\nldsb [%i5+%l3],%o1\ncall printf; nop\n.L635:\nadd %i5,1,%i5\ncmp %i5,28; bl .L634; nop\nset .L639,%o0\ncall printf; nop\n.L631:\n.L629:\nset 32768,%l6\nmov %l6,%l3\nset 0x8000,%l2\ncmp %l3,%l2; bleu .L640; nop\nld [%fp+-76],%l3\nadd %l3,8,%l3\nst %l3,[%fp+-76]\nld [%i0+44],%l3\ncmp %l3,0; be .L642; nop\nset .520,%o0\nset 8,%o1\ncall printf; nop\n.L642:\n.L640:\nld [%fp+-76],%i0\n.L519:\nret; restore\n.type s626,#function\n.size s626,.-s626\n.section \".data\"\n.type .645,#object\n.align 1\n.645:\n.byte 115\n.byte 55\n.byte 49\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size .645,10\n.type .646,#object\n.size .646,8\n.align 1\n.646:\n.byte 115\n.byte 55\n.byte 49\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.type .647,#object\n.size .647,1\n.align 1\n.647:\n.byte 0x71\n.global s71\n.section \".text\"\n.align 4\ns71:\nsave %sp,-136,%sp\nset .646,%i5\nadd %i0,60,%i4\nmov %g0,%i3\n.L648:\n.L649:\nmov %i4,%l7\nadd %l7,1,%i4\nmov %i5,%l6\nadd %l6,1,%i5\nldsb [%l6],%l6\nstb %l6,[%l7]\nsll %l6,8*(4-1),%l7; sra %l7,8*(4-1),%l7\ncmp %l7,0; bne .L648; nop\nset .L653,%l7\nldsb [%l7],%l7\nset .647,%l6\nldsb [%l6],%l6\ncmp %l7,%l6; be .L651; nop\nadd %i3,1,%i3\nld [%i0+44],%l7\ncmp %l7,0; be .L654; nop\nset .645,%o0\nset 1,%o1\ncall printf; nop\n.L654:\n.L651:\nba .L656; nop\nadd %i3,2,%i3\nld [%i0+44],%l7\ncmp %l7,0; be .L658; nop\nset .645,%o0\nset 2,%o1\ncall printf; nop\n.L658:\n.L656:\nset 1942,%l7\nst %l7,[%fp+-20]\nld [%fp+-20],%l7\ncmp %l7,1942; bne .L666; nop\nld [%fp+-20],%l7\nld [%fp+-20],%l6\ncmp %l7,%l6; be .L661; nop\n.L666:\nadd %i3,4,%i3\nld [%i0+44],%l7\ncmp %l7,0; be .L667; nop\nset .645,%o0\nset 4,%o1\ncall printf; nop\n.L667:\n.L661:\nset -5,%o0\ncall McCarthy; nop\ncmp %o0,91; be .L669; nop\nadd %i3,8,%i3\nld [%i0+44],%l7\ncmp %l7,0; be .L671; nop\nset .645,%o0\nset 8,%o1\ncall printf; nop\n.L671:\n.L669:\nset 2,%i2\nset 3,%l7\nst %l7,[%fp+-44]\nadd -44,%fp,%i1\nmov %i2,%o0\nmov %i1,%o1\ncall clobber; nop\ncmp %i2,2; bne .L675; nop\nld [%fp+-44],%l7\ncmp %l7,2; be .L673; nop\n.L675:\nadd %i3,16,%i3\nld [%i0+44],%l7\ncmp %l7,0; be .L676; nop\nset .645,%o0\nset 16,%o1\ncall printf; nop\n.L676:\n.L673:\nld [%i0+32],%f31\nfcmpes %f31,%f31; nop; fbue .L678; nop\nadd %i3,32,%i3\nld [%i0+44],%l7\ncmp %l7,0; be .L680; nop\nset .645,%o0\nset 32,%o1\ncall printf; nop\n.L680:\n.L678:\nmov %i3,%i0\n.L644:\nret; restore\n.type s71,#function\n.size s71,.-s71\n.global McCarthy\n.align 4\nMcCarthy:\nsave %sp,-96,%sp\ncmp %i0,100; ble .L683; nop\nsub %i0,10,%i0\nba .L682; nop\n.L683:\nadd %i0,11,%o0\ncall McCarthy; nop\nmov %o0,%i5\ncall McCarthy; nop\nmov %o0,%i0\n.L682:\nret; restore\n.type McCarthy,#function\n.size McCarthy,.-McCarthy\n.global clobber\n.align 4\nclobber:\nset 3,%o0\nset 2,%o5\nst %o5,[%o1]\nmov %g0,%o0\n.L685:\nretl; nop\n.type clobber,#function\n.size clobber,.-clobber\n.section \".data\"\n.type .687,#object\n.align 1\n.687:\n.byte 76\n.byte 111\n.byte 99\n.byte 97\n.byte 108\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 37\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.size .687,17\n.type .688,#object\n.align 1\n.688:\n.byte 115\n.byte 55\n.byte 49\n.byte 52\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size .688,11\n.type .689,#object\n.size .689,8\n.align 1\n.689:\n.byte 115\n.byte 55\n.byte 49\n.byte 52\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.global s714\n.section \".text\"\n.align 4\ns714:\nsave %sp,-184,%sp\nset .689,%l3\nst %l3,[%fp+-44]\nadd %i0,60,%l3\nst %l3,[%fp+-48]\nst %g0,[%fp+-52]\nmov %g0,%i4\nld [%i0+48],%i5\n.L690:\n.L691:\nld [%fp+-48],%l3\nadd %l3,1,%l2\nst %l2,[%fp+-48]\nld [%fp+-44],%l2\nadd %l2,1,%l1\nst %l1,[%fp+-44]\nldsb [%l2],%l2\nstb %l2,[%l3]\nsll %l2,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,0; bne .L690; nop\nset 5,%i3\nset 2,%l5\nmov %l5,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,2; be .L693; nop\nset 1,%i4\ncmp %i5,0; be .L695; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L695:\n.L693:\nset 5,%i3\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,2; be .L697; nop\nset 2,%i4\ncmp %i5,0; be .L699; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L699:\n.L697:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,2; be .L701; nop\nset 3,%i4\ncmp %i5,0; be .L703; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L703:\n.L701:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,2; be .L705; nop\nset 4,%i4\ncmp %i5,0; be .L707; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L707:\n.L705:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,2; be .L709; nop\nset 5,%i4\ncmp %i5,0; be .L711; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L711:\n.L709:\nset 5,%i3\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nld [%fp+-28],%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,2; be .L713; nop\nset 6,%i4\ncmp %i5,0; be .L715; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L715:\n.L713:\nset 5,%i3\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nldd [%fp+-40],%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,2; be .L717; nop\nset 7,%i4\ncmp %i5,0; be .L719; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L719:\n.L717:\nset 5,%i2\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,2; be .L721; nop\nset 8,%i4\ncmp %i5,0; be .L723; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L723:\n.L721:\nset 5,%i2\nset 2,%l4\nmov %l4,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,2; be .L725; nop\nset 9,%i4\ncmp %i5,0; be .L727; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L727:\n.L725:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,2; be .L729; nop\nset 10,%i4\ncmp %i5,0; be .L731; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L731:\n.L729:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,2; be .L733; nop\nset 11,%i4\ncmp %i5,0; be .L735; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L735:\n.L733:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,2; be .L737; nop\nset 12,%i4\ncmp %i5,0; be .L739; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L739:\n.L737:\nset 5,%i2\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nld [%fp+-28],%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,2; be .L741; nop\nset 13,%i4\ncmp %i5,0; be .L743; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L743:\n.L741:\nset 5,%i2\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nldd [%fp+-40],%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,2; be .L745; nop\nset 14,%i4\ncmp %i5,0; be .L747; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L747:\n.L745:\nset 5,%i1\nset 2,%l5\nsll %l5,8*(4-1),%i1; sra %i1,8*(4-1),%i1\ncmp %i1,2; be .L749; nop\nset 15,%i4\ncmp %i5,0; be .L751; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L751:\n.L749:\nset 5,%i1\nset 2,%l4\nsll %l4,8*(4-2),%i1; sra %i1,8*(4-2),%i1\ncmp %i1,2; be .L753; nop\nset 16,%i4\ncmp %i5,0; be .L755; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L755:\n.L753:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%i1\ncmp %i1,2; be .L757; nop\nset 17,%i4\ncmp %i5,0; be .L759; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L759:\n.L757:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%i1\ncmp %i1,2; be .L761; nop\nset 18,%i4\ncmp %i5,0; be .L763; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L763:\n.L761:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nmov %l3,%i1\ncmp %i1,2; be .L765; nop\nset 19,%i4\ncmp %i5,0; be .L767; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L767:\n.L765:\nset 5,%i1\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nld [%fp+-28],%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%i1\ncmp %i1,2; be .L769; nop\nset 20,%i4\ncmp %i5,0; be .L771; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L771:\n.L769:\nset 5,%i1\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nldd [%fp+-40],%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%i1\ncmp %i1,2; be .L773; nop\nset 21,%i4\ncmp %i5,0; be .L775; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L775:\n.L773:\nset 5,%l7\nset 2,%l5\nsll %l5,8*(4-1),%l7; sra %l7,8*(4-1),%l7\ncmp %l7,2; be .L777; nop\nset 22,%i4\ncmp %i5,0; be .L779; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L779:\n.L777:\nset 5,%l7\nset 2,%l4\nsll %l4,8*(4-2),%l7; sra %l7,8*(4-2),%l7\ncmp %l7,2; be .L781; nop\nset 23,%i4\ncmp %i5,0; be .L783; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L783:\n.L781:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l7\ncmp %l7,2; be .L785; nop\nset 24,%i4\ncmp %i5,0; be .L787; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L787:\n.L785:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l7\ncmp %l7,2; be .L789; nop\nset 25,%i4\ncmp %i5,0; be .L791; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L791:\n.L789:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nmov %l3,%l7\ncmp %l7,2; be .L793; nop\nset 26,%i4\ncmp %i5,0; be .L795; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L795:\n.L793:\nset 5,%l7\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nld [%fp+-28],%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l7\ncmp %l7,2; be .L797; nop\nset 27,%i4\ncmp %i5,0; be .L799; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L799:\n.L797:\nset 5,%l7\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nldd [%fp+-40],%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l7\ncmp %l7,2; be .L801; nop\nset 28,%i4\ncmp %i5,0; be .L803; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L803:\n.L801:\nset 5,%l6\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nmov %l3,%l6\nset 2,%l3\ncmp %l6,%l3; be .L805; nop\nset 29,%i4\ncmp %i5,0; be .L807; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L807:\n.L805:\nset 5,%l6\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nmov %l3,%l6\nset 2,%l3\ncmp %l6,%l3; be .L809; nop\nset 30,%i4\ncmp %i5,0; be .L811; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L811:\n.L809:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nmov %l3,%l6\nset 2,%l3\ncmp %l6,%l3; be .L813; nop\nset 31,%i4\ncmp %i5,0; be .L815; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L815:\n.L813:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nmov %l3,%l6\nset 2,%l3\ncmp %l6,%l3; be .L817; nop\nset 32,%i4\ncmp %i5,0; be .L819; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L819:\n.L817:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l6\ncmp %l6,%l3; be .L821; nop\nset 33,%i4\ncmp %i5,0; be .L823; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L823:\n.L821:\nset 5,%l6\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nld [%fp+-28],%f31\nset .L828,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbul .L826; nop\nfsubs %f31,%f30,%f30\nfstoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nset 0x80000000,%l2\nadd %l3,%l2,%l3\nst %l3,[%fp+-56]\nba .L827; nop\n.L826:\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nst %l3,[%fp+-56]\n.L827:\nld [%fp+-56],%l6\nset 2,%l3\ncmp %l6,%l3; be .L829; nop\nset 34,%i4\ncmp %i5,0; be .L831; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L831:\n.L829:\nset 5,%l6\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nldd [%fp+-40],%f30\nset .L836,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbul .L834; nop\nfsubd %f30,%f28,%f28\nfdtoi %f28,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nset 0x80000000,%l2\nadd %l3,%l2,%l3\nst %l3,[%fp+-60]\nba .L835; nop\n.L834:\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nst %l3,[%fp+-60]\n.L835:\nld [%fp+-60],%l6\nset 2,%l3\ncmp %l6,%l3; be .L837; nop\nset 35,%i4\ncmp %i5,0; be .L839; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L839:\n.L837:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L529,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L842; nop\nset 36,%i4\ncmp %i5,0; be .L844; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L844:\n.L842:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L529,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L846; nop\nset 37,%i4\ncmp %i5,0; be .L848; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L848:\n.L846:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L529,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L850; nop\nset 38,%i4\ncmp %i5,0; be .L852; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L852:\n.L850:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L529,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L854; nop\nset 39,%i4\ncmp %i5,0; be .L856; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L856:\n.L854:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nset .L596,%l2\nld2 [%l2],%f30\nsrl %l3,1,%l2\nst %l2,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfmuld %f30,%f28,%f30\nset 1,%l2\nand %l3,%l2,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfaddd %f30,%f28,%f30\nfdtos %f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L529,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L858; nop\nset 40,%i4\ncmp %i5,0; be .L860; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L860:\n.L858:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nld [%fp+-28],%f30\nst %f30,[%fp+-16]\nld [%fp+-16],%f30\nfcmpes %f30,%f31; nop; fbue .L862; nop\nset 41,%i4\ncmp %i5,0; be .L864; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L864:\n.L862:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nldd [%fp+-40],%f30\nfdtos %f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L529,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L866; nop\nset 42,%i4\ncmp %i5,0; be .L868; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L868:\n.L866:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L416,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L871; nop\nset 43,%i4\ncmp %i5,0; be .L873; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L873:\n.L871:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L416,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L875; nop\nset 44,%i4\ncmp %i5,0; be .L877; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L877:\n.L875:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L416,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L879; nop\nset 45,%i4\ncmp %i5,0; be .L881; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L881:\n.L879:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L416,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L883; nop\nset 46,%i4\ncmp %i5,0; be .L885; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L885:\n.L883:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nset .L596,%l2\nld2 [%l2],%f30\nsrl %l3,1,%l2\nst %l2,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfmuld %f30,%f28,%f30\nset 1,%l2\nand %l3,%l2,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfaddd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L416,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L887; nop\nset 47,%i4\ncmp %i5,0; be .L889; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L889:\n.L887:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nld [%fp+-28],%f31\nfstod %f31,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L416,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L891; nop\nset 48,%i4\ncmp %i5,0; be .L893; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L893:\n.L891:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nldd [%fp+-40],%f28\nstd %f28,[%fp+-24]\nldd [%fp+-24],%f28\nfcmped %f28,%f30; nop; fbue .L895; nop\nset 49,%i4\ncmp %i5,0; be .L897; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L897:\n.L895:\nset 5,%i3\nset 2,%l5\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nadd %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,7; be .L899; nop\nset 50,%i4\ncmp %i5,0; be .L901; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L901:\n.L899:\nset 5,%i3\nset 2,%l4\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\nadd %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,7; be .L903; nop\nset 51,%i4\ncmp %i5,0; be .L905; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L905:\n.L903:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-4]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-4],%l2\nadd %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,7; be .L907; nop\nset 52,%i4\ncmp %i5,0; be .L909; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L909:\n.L907:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-8]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-8],%l2\nadd %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,7; be .L911; nop\nset 53,%i4\ncmp %i5,0; be .L913; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L913:\n.L911:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-12]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-12],%l2\nadd %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,7; be .L915; nop\nset 54,%i4\ncmp %i5,0; be .L917; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L917:\n.L915:\nset 5,%i3\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nld [%fp+-28],%f30\nfadds %f31,%f30,%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,7; be .L919; nop\nset 55,%i4\ncmp %i5,0; be .L921; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L921:\n.L919:\nset 5,%i3\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nldd [%fp+-40],%f28\nfaddd %f30,%f28,%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,7; be .L923; nop\nset 56,%i4\ncmp %i5,0; be .L925; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L925:\n.L923:\nset 5,%i2\nset 2,%l5\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nadd %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,7; be .L927; nop\nset 57,%i4\ncmp %i5,0; be .L929; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L929:\n.L927:\nset 5,%i2\nset 2,%l4\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\nadd %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,7; be .L931; nop\nset 58,%i4\ncmp %i5,0; be .L933; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L933:\n.L931:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-4]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-4],%l2\nadd %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,7; be .L935; nop\nset 59,%i4\ncmp %i5,0; be .L937; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L937:\n.L935:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-8]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-8],%l2\nadd %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,7; be .L939; nop\nset 60,%i4\ncmp %i5,0; be .L941; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L941:\n.L939:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-12]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-12],%l2\nadd %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,7; be .L943; nop\nset 61,%i4\ncmp %i5,0; be .L945; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L945:\n.L943:\nset 5,%i2\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nld [%fp+-28],%f30\nfadds %f31,%f30,%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,7; be .L947; nop\nset 62,%i4\ncmp %i5,0; be .L949; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L949:\n.L947:\nset 5,%i2\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nldd [%fp+-40],%f28\nfaddd %f30,%f28,%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,7; be .L951; nop\nset 63,%i4\ncmp %i5,0; be .L953; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L953:\n.L951:\nset 5,%i1\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nadd %i1,%l3,%i1\ncmp %i1,7; be .L955; nop\nset 64,%i4\ncmp %i5,0; be .L957; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L957:\n.L955:\nset 5,%i1\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nadd %i1,%l3,%i1\ncmp %i1,7; be .L959; nop\nset 65,%i4\ncmp %i5,0; be .L961; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L961:\n.L959:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nadd %i1,%l3,%i1\ncmp %i1,7; be .L963; nop\nset 66,%i4\ncmp %i5,0; be .L965; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L965:\n.L963:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nadd %i1,%l3,%i1\ncmp %i1,7; be .L967; nop\nset 67,%i4\ncmp %i5,0; be .L969; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L969:\n.L967:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-12]\nmov %i1,%l3\nld [%fp+-12],%l2\nadd %l3,%l2,%l3\nmov %l3,%i1\ncmp %i1,7; be .L971; nop\nset 68,%i4\ncmp %i5,0; be .L973; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L973:\n.L971:\nset 5,%i1\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nst %i1,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nld [%fp+-28],%f30\nfadds %f31,%f30,%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%i1\ncmp %i1,7; be .L975; nop\nset 69,%i4\ncmp %i5,0; be .L977; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L977:\n.L975:\nset 5,%i1\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nst %i1,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nldd [%fp+-40],%f28\nfaddd %f30,%f28,%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%i1\ncmp %i1,7; be .L979; nop\nset 70,%i4\ncmp %i5,0; be .L981; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L981:\n.L979:\nset 5,%l7\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nadd %l7,%l3,%l7\ncmp %l7,7; be .L983; nop\nset 71,%i4\ncmp %i5,0; be .L985; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L985:\n.L983:\nset 5,%l7\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nadd %l7,%l3,%l7\ncmp %l7,7; be .L987; nop\nset 72,%i4\ncmp %i5,0; be .L989; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L989:\n.L987:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nadd %l7,%l3,%l7\ncmp %l7,7; be .L991; nop\nset 73,%i4\ncmp %i5,0; be .L993; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L993:\n.L991:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nadd %l7,%l3,%l7\ncmp %l7,7; be .L995; nop\nset 74,%i4\ncmp %i5,0; be .L997; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L997:\n.L995:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-12]\nmov %l7,%l3\nld [%fp+-12],%l2\nadd %l3,%l2,%l3\nmov %l3,%l7\ncmp %l7,7; be .L999; nop\nset 75,%i4\ncmp %i5,0; be .L1001; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1001:\n.L999:\nset 5,%l7\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nst %l7,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nld [%fp+-28],%f30\nfadds %f31,%f30,%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l7\ncmp %l7,7; be .L1003; nop\nset 76,%i4\ncmp %i5,0; be .L1005; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1005:\n.L1003:\nset 5,%l7\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nst %l7,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nldd [%fp+-40],%f28\nfaddd %f30,%f28,%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l7\ncmp %l7,7; be .L1007; nop\nset 77,%i4\ncmp %i5,0; be .L1009; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1009:\n.L1007:\nset 5,%l6\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nadd %l6,%l3,%l6\nset 7,%l3\ncmp %l6,%l3; be .L1011; nop\nset 78,%i4\ncmp %i5,0; be .L1013; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1013:\n.L1011:\nset 5,%l6\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nadd %l6,%l3,%l6\nset 7,%l3\ncmp %l6,%l3; be .L1015; nop\nset 79,%i4\ncmp %i5,0; be .L1017; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1017:\n.L1015:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nadd %l6,%l3,%l6\nset 7,%l3\ncmp %l6,%l3; be .L1019; nop\nset 80,%i4\ncmp %i5,0; be .L1021; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1021:\n.L1019:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nadd %l6,%l3,%l6\nset 7,%l3\ncmp %l6,%l3; be .L1023; nop\nset 81,%i4\ncmp %i5,0; be .L1025; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1025:\n.L1023:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nadd %l6,%l3,%l6\nset 7,%l3\ncmp %l6,%l3; be .L1027; nop\nset 82,%i4\ncmp %i5,0; be .L1029; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1029:\n.L1027:\nset 5,%l6\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nset .L596,%l3\nld2 [%l3],%f30\nsrl %l6,1,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfmuld %f30,%f28,%f30\nset 1,%l3\nand %l6,%l3,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfaddd %f30,%f28,%f30\nfdtos %f30,%f31\nld [%fp+-28],%f30\nfadds %f31,%f30,%f31\nset .L828,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbul .L1032; nop\nfsubs %f31,%f30,%f30\nfstoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nset 0x80000000,%l2\nadd %l3,%l2,%l3\nst %l3,[%fp+-64]\nba .L1033; nop\n.L1032:\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nst %l3,[%fp+-64]\n.L1033:\nld [%fp+-64],%l6\nset 7,%l3\ncmp %l6,%l3; be .L1034; nop\nset 83,%i4\ncmp %i5,0; be .L1036; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1036:\n.L1034:\nset 5,%l6\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nset .L596,%l3\nld2 [%l3],%f30\nsrl %l6,1,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfmuld %f30,%f28,%f30\nset 1,%l3\nand %l6,%l3,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfaddd %f30,%f28,%f30\nldd [%fp+-40],%f28\nfaddd %f30,%f28,%f30\nset .L836,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbul .L1039; nop\nfsubd %f30,%f28,%f28\nfdtoi %f28,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nset 0x80000000,%l2\nadd %l3,%l2,%l3\nst %l3,[%fp+-68]\nba .L1040; nop\n.L1039:\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nst %l3,[%fp+-68]\n.L1040:\nld [%fp+-68],%l6\nset 7,%l3\ncmp %l6,%l3; be .L1041; nop\nset 84,%i4\ncmp %i5,0; be .L1043; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1043:\n.L1041:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l5\nld [%fp+-16],%f31\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfadds %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L1047,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L1045; nop\nset 85,%i4\ncmp %i5,0; be .L1048; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1048:\n.L1045:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l4\nld [%fp+-16],%f31\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfadds %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L1047,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L1050; nop\nset 86,%i4\ncmp %i5,0; be .L1052; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1052:\n.L1050:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-16],%f31\nld [%fp+-4],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfadds %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L1047,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L1054; nop\nset 87,%i4\ncmp %i5,0; be .L1056; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1056:\n.L1054:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-16],%f31\nld [%fp+-8],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfadds %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L1047,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L1058; nop\nset 88,%i4\ncmp %i5,0; be .L1060; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1060:\n.L1058:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nld [%fp+-16],%f31\nset .L596,%l2\nld2 [%l2],%f28\nsrl %l3,1,%l2\nst %l2,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfmuld %f28,%f26,%f28\nset 1,%l2\nand %l3,%l2,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfaddd %f28,%f26,%f28\nfdtos %f28,%f30\nfadds %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L1047,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L1062; nop\nset 89,%i4\ncmp %i5,0; be .L1064; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1064:\n.L1062:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nld [%fp+-16],%f31\nld [%fp+-28],%f30\nfadds %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L1047,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L1066; nop\nset 90,%i4\ncmp %i5,0; be .L1068; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1068:\n.L1066:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nld [%fp+-16],%f31\nfstod %f31,%f30\nldd [%fp+-40],%f28\nfaddd %f30,%f28,%f30\nfdtos %f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L1047,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L1070; nop\nset 91,%i4\ncmp %i5,0; be .L1072; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1072:\n.L1070:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l5\nldd [%fp+-24],%f30\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfaddd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1076,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1074; nop\nset 92,%i4\ncmp %i5,0; be .L1077; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1077:\n.L1074:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l4\nldd [%fp+-24],%f30\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfaddd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1076,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1079; nop\nset 93,%i4\ncmp %i5,0; be .L1081; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1081:\n.L1079:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l3\nst %l3,[%fp+-4]\nldd [%fp+-24],%f30\nld [%fp+-4],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfaddd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1076,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1083; nop\nset 94,%i4\ncmp %i5,0; be .L1085; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1085:\n.L1083:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l3\nst %l3,[%fp+-8]\nldd [%fp+-24],%f30\nld [%fp+-8],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfaddd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1076,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1087; nop\nset 95,%i4\ncmp %i5,0; be .L1089; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1089:\n.L1087:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nldd [%fp+-24],%f30\nset .L596,%l2\nld2 [%l2],%f28\nsrl %l3,1,%l2\nst %l2,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfmuld %f28,%f26,%f28\nset 1,%l2\nand %l3,%l2,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfaddd %f28,%f26,%f28\nfaddd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1076,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1091; nop\nset 96,%i4\ncmp %i5,0; be .L1093; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1093:\n.L1091:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nldd [%fp+-24],%f30\nld [%fp+-28],%f29\nfstod %f29,%f28\nfaddd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1076,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1095; nop\nset 97,%i4\ncmp %i5,0; be .L1097; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1097:\n.L1095:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nldd [%fp+-24],%f30\nldd [%fp+-40],%f28\nfaddd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1076,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1099; nop\nset 98,%i4\ncmp %i5,0; be .L1101; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1101:\n.L1099:\nset 5,%i3\nset 2,%l5\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nsub %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,3; be .L1103; nop\nset 99,%i4\ncmp %i5,0; be .L1105; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1105:\n.L1103:\nset 5,%i3\nset 2,%l4\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\nsub %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,3; be .L1107; nop\nset 100,%i4\ncmp %i5,0; be .L1109; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1109:\n.L1107:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-4]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-4],%l2\nsub %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,3; be .L1111; nop\nset 101,%i4\ncmp %i5,0; be .L1113; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1113:\n.L1111:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-8]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-8],%l2\nsub %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,3; be .L1115; nop\nset 102,%i4\ncmp %i5,0; be .L1117; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1117:\n.L1115:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-12]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-12],%l2\nsub %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,3; be .L1119; nop\nset 103,%i4\ncmp %i5,0; be .L1121; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1121:\n.L1119:\nset 5,%i3\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nld [%fp+-28],%f30\nfsubs %f31,%f30,%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,3; be .L1123; nop\nset 104,%i4\ncmp %i5,0; be .L1125; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1125:\n.L1123:\nset 5,%i3\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nldd [%fp+-40],%f28\nfsubd %f30,%f28,%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,3; be .L1127; nop\nset 105,%i4\ncmp %i5,0; be .L1129; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1129:\n.L1127:\nset 5,%i2\nset 2,%l5\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nsub %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,3; be .L1131; nop\nset 106,%i4\ncmp %i5,0; be .L1133; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1133:\n.L1131:\nset 5,%i2\nset 2,%l4\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\nsub %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,3; be .L1135; nop\nset 107,%i4\ncmp %i5,0; be .L1137; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1137:\n.L1135:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-4]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-4],%l2\nsub %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,3; be .L1139; nop\nset 108,%i4\ncmp %i5,0; be .L1141; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1141:\n.L1139:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-8]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-8],%l2\nsub %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,3; be .L1143; nop\nset 109,%i4\ncmp %i5,0; be .L1145; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1145:\n.L1143:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-12]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-12],%l2\nsub %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,3; be .L1147; nop\nset 110,%i4\ncmp %i5,0; be .L1149; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1149:\n.L1147:\nset 5,%i2\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nld [%fp+-28],%f30\nfsubs %f31,%f30,%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,3; be .L1151; nop\nset 111,%i4\ncmp %i5,0; be .L1153; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1153:\n.L1151:\nset 5,%i2\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nldd [%fp+-40],%f28\nfsubd %f30,%f28,%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,3; be .L1155; nop\nset 112,%i4\ncmp %i5,0; be .L1157; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1157:\n.L1155:\nset 5,%i1\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsub %i1,%l3,%i1\ncmp %i1,3; be .L1159; nop\nset 113,%i4\ncmp %i5,0; be .L1161; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1161:\n.L1159:\nset 5,%i1\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsub %i1,%l3,%i1\ncmp %i1,3; be .L1163; nop\nset 114,%i4\ncmp %i5,0; be .L1165; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1165:\n.L1163:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nsub %i1,%l3,%i1\ncmp %i1,3; be .L1167; nop\nset 115,%i4\ncmp %i5,0; be .L1169; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1169:\n.L1167:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nsub %i1,%l3,%i1\ncmp %i1,3; be .L1171; nop\nset 116,%i4\ncmp %i5,0; be .L1173; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1173:\n.L1171:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-12]\nmov %i1,%l3\nld [%fp+-12],%l2\nsub %l3,%l2,%l3\nmov %l3,%i1\ncmp %i1,3; be .L1175; nop\nset 117,%i4\ncmp %i5,0; be .L1177; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1177:\n.L1175:\nset 5,%i1\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nst %i1,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nld [%fp+-28],%f30\nfsubs %f31,%f30,%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%i1\ncmp %i1,3; be .L1179; nop\nset 118,%i4\ncmp %i5,0; be .L1181; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1181:\n.L1179:\nset 5,%i1\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nst %i1,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nldd [%fp+-40],%f28\nfsubd %f30,%f28,%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%i1\ncmp %i1,3; be .L1183; nop\nset 119,%i4\ncmp %i5,0; be .L1185; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1185:\n.L1183:\nset 5,%l7\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsub %l7,%l3,%l7\ncmp %l7,3; be .L1187; nop\nset 120,%i4\ncmp %i5,0; be .L1189; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1189:\n.L1187:\nset 5,%l7\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsub %l7,%l3,%l7\ncmp %l7,3; be .L1191; nop\nset 121,%i4\ncmp %i5,0; be .L1193; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1193:\n.L1191:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nsub %l7,%l3,%l7\ncmp %l7,3; be .L1195; nop\nset 122,%i4\ncmp %i5,0; be .L1197; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1197:\n.L1195:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nsub %l7,%l3,%l7\ncmp %l7,3; be .L1199; nop\nset 123,%i4\ncmp %i5,0; be .L1201; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1201:\n.L1199:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-12]\nmov %l7,%l3\nld [%fp+-12],%l2\nsub %l3,%l2,%l3\nmov %l3,%l7\ncmp %l7,3; be .L1203; nop\nset 124,%i4\ncmp %i5,0; be .L1205; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1205:\n.L1203:\nset 5,%l7\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nst %l7,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nld [%fp+-28],%f30\nfsubs %f31,%f30,%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l7\ncmp %l7,3; be .L1207; nop\nset 125,%i4\ncmp %i5,0; be .L1209; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1209:\n.L1207:\nset 5,%l7\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nst %l7,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nldd [%fp+-40],%f28\nfsubd %f30,%f28,%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l7\ncmp %l7,3; be .L1211; nop\nset 126,%i4\ncmp %i5,0; be .L1213; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1213:\n.L1211:\nset 5,%l6\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsub %l6,%l3,%l6\nset 3,%l3\ncmp %l6,%l3; be .L1215; nop\nset 127,%i4\ncmp %i5,0; be .L1217; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1217:\n.L1215:\nset 5,%l6\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsub %l6,%l3,%l6\nset 3,%l3\ncmp %l6,%l3; be .L1219; nop\nset 128,%i4\ncmp %i5,0; be .L1221; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1221:\n.L1219:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nsub %l6,%l3,%l6\nset 3,%l3\ncmp %l6,%l3; be .L1223; nop\nset 129,%i4\ncmp %i5,0; be .L1225; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1225:\n.L1223:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nsub %l6,%l3,%l6\nset 3,%l3\ncmp %l6,%l3; be .L1227; nop\nset 130,%i4\ncmp %i5,0; be .L1229; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1229:\n.L1227:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nsub %l6,%l3,%l6\nset 3,%l3\ncmp %l6,%l3; be .L1231; nop\nset 131,%i4\ncmp %i5,0; be .L1233; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1233:\n.L1231:\nset 5,%l6\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nset .L596,%l3\nld2 [%l3],%f30\nsrl %l6,1,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfmuld %f30,%f28,%f30\nset 1,%l3\nand %l6,%l3,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfaddd %f30,%f28,%f30\nfdtos %f30,%f31\nld [%fp+-28],%f30\nfsubs %f31,%f30,%f31\nset .L828,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbul .L1236; nop\nfsubs %f31,%f30,%f30\nfstoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nset 0x80000000,%l2\nadd %l3,%l2,%l3\nst %l3,[%fp+-72]\nba .L1237; nop\n.L1236:\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nst %l3,[%fp+-72]\n.L1237:\nld [%fp+-72],%l6\nset 3,%l3\ncmp %l6,%l3; be .L1238; nop\nset 132,%i4\ncmp %i5,0; be .L1240; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1240:\n.L1238:\nset 5,%l6\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nset .L596,%l3\nld2 [%l3],%f30\nsrl %l6,1,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfmuld %f30,%f28,%f30\nset 1,%l3\nand %l6,%l3,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfaddd %f30,%f28,%f30\nldd [%fp+-40],%f28\nfsubd %f30,%f28,%f30\nset .L836,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbul .L1243; nop\nfsubd %f30,%f28,%f28\nfdtoi %f28,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nset 0x80000000,%l2\nadd %l3,%l2,%l3\nst %l3,[%fp+-76]\nba .L1244; nop\n.L1243:\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nst %l3,[%fp+-76]\n.L1244:\nld [%fp+-76],%l6\nset 3,%l3\ncmp %l6,%l3; be .L1245; nop\nset 133,%i4\ncmp %i5,0; be .L1247; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1247:\n.L1245:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l5\nld [%fp+-16],%f31\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfsubs %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L1251,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L1249; nop\nset 134,%i4\ncmp %i5,0; be .L1252; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1252:\n.L1249:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l4\nld [%fp+-16],%f31\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfsubs %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L1251,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L1254; nop\nset 135,%i4\ncmp %i5,0; be .L1256; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1256:\n.L1254:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-16],%f31\nld [%fp+-4],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfsubs %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L1251,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L1258; nop\nset 136,%i4\ncmp %i5,0; be .L1260; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1260:\n.L1258:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-16],%f31\nld [%fp+-8],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfsubs %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L1251,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L1262; nop\nset 137,%i4\ncmp %i5,0; be .L1264; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1264:\n.L1262:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nld [%fp+-16],%f31\nset .L596,%l2\nld2 [%l2],%f28\nsrl %l3,1,%l2\nst %l2,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfmuld %f28,%f26,%f28\nset 1,%l2\nand %l3,%l2,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfaddd %f28,%f26,%f28\nfdtos %f28,%f30\nfsubs %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L1251,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L1266; nop\nset 138,%i4\ncmp %i5,0; be .L1268; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1268:\n.L1266:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nld [%fp+-16],%f31\nld [%fp+-28],%f30\nfsubs %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L1251,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L1270; nop\nset 139,%i4\ncmp %i5,0; be .L1272; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1272:\n.L1270:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nld [%fp+-16],%f31\nfstod %f31,%f30\nldd [%fp+-40],%f28\nfsubd %f30,%f28,%f30\nfdtos %f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L1251,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L1274; nop\nset 140,%i4\ncmp %i5,0; be .L1276; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1276:\n.L1274:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l5\nldd [%fp+-24],%f30\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfsubd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1280,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1278; nop\nset 141,%i4\ncmp %i5,0; be .L1281; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1281:\n.L1278:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l4\nldd [%fp+-24],%f30\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfsubd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1280,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1283; nop\nset 142,%i4\ncmp %i5,0; be .L1285; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1285:\n.L1283:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l3\nst %l3,[%fp+-4]\nldd [%fp+-24],%f30\nld [%fp+-4],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfsubd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1280,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1287; nop\nset 143,%i4\ncmp %i5,0; be .L1289; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1289:\n.L1287:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l3\nst %l3,[%fp+-8]\nldd [%fp+-24],%f30\nld [%fp+-8],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfsubd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1280,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1291; nop\nset 144,%i4\ncmp %i5,0; be .L1293; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1293:\n.L1291:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nldd [%fp+-24],%f30\nset .L596,%l2\nld2 [%l2],%f28\nsrl %l3,1,%l2\nst %l2,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfmuld %f28,%f26,%f28\nset 1,%l2\nand %l3,%l2,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfaddd %f28,%f26,%f28\nfsubd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1280,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1295; nop\nset 145,%i4\ncmp %i5,0; be .L1297; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1297:\n.L1295:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nldd [%fp+-24],%f30\nld [%fp+-28],%f29\nfstod %f29,%f28\nfsubd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1280,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1299; nop\nset 146,%i4\ncmp %i5,0; be .L1301; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1301:\n.L1299:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nldd [%fp+-24],%f30\nldd [%fp+-40],%f28\nfsubd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1280,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1303; nop\nset 147,%i4\ncmp %i5,0; be .L1305; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1305:\n.L1303:\nset 5,%i3\nset 2,%l5\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nsmul %l2,%l3,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,10; be .L1307; nop\nset 148,%i4\ncmp %i5,0; be .L1309; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1309:\n.L1307:\nset 5,%i3\nset 2,%l4\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\nsmul %l2,%l3,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,10; be .L1311; nop\nset 149,%i4\ncmp %i5,0; be .L1313; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1313:\n.L1311:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-4]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-4],%l2\nsmul %l2,%l3,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,10; be .L1315; nop\nset 150,%i4\ncmp %i5,0; be .L1317; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1317:\n.L1315:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-8]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-8],%l2\nsmul %l2,%l3,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,10; be .L1319; nop\nset 151,%i4\ncmp %i5,0; be .L1321; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1321:\n.L1319:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-12]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-12],%l2\numul %l2,%l3,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,10; be .L1323; nop\nset 152,%i4\ncmp %i5,0; be .L1325; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1325:\n.L1323:\nset 5,%i3\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nld [%fp+-28],%f30\nfmuls %f31,%f30,%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,10; be .L1327; nop\nset 153,%i4\ncmp %i5,0; be .L1329; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1329:\n.L1327:\nset 5,%i3\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nldd [%fp+-40],%f28\nfmuld %f30,%f28,%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,10; be .L1331; nop\nset 154,%i4\ncmp %i5,0; be .L1333; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1333:\n.L1331:\nset 5,%i2\nset 2,%l5\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nsmul %l2,%l3,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,10; be .L1335; nop\nset 155,%i4\ncmp %i5,0; be .L1337; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1337:\n.L1335:\nset 5,%i2\nset 2,%l4\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\nsmul %l2,%l3,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,10; be .L1339; nop\nset 156,%i4\ncmp %i5,0; be .L1341; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1341:\n.L1339:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-4]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-4],%l2\nsmul %l2,%l3,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,10; be .L1343; nop\nset 157,%i4\ncmp %i5,0; be .L1345; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1345:\n.L1343:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-8]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-8],%l2\nsmul %l2,%l3,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,10; be .L1347; nop\nset 158,%i4\ncmp %i5,0; be .L1349; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1349:\n.L1347:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-12]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-12],%l2\numul %l2,%l3,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,10; be .L1351; nop\nset 159,%i4\ncmp %i5,0; be .L1353; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1353:\n.L1351:\nset 5,%i2\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nld [%fp+-28],%f30\nfmuls %f31,%f30,%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,10; be .L1355; nop\nset 160,%i4\ncmp %i5,0; be .L1357; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1357:\n.L1355:\nset 5,%i2\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nldd [%fp+-40],%f28\nfmuld %f30,%f28,%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,10; be .L1359; nop\nset 161,%i4\ncmp %i5,0; be .L1361; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1361:\n.L1359:\nset 5,%i1\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsmul %l3,%i1,%i1\ncmp %i1,10; be .L1363; nop\nset 162,%i4\ncmp %i5,0; be .L1365; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1365:\n.L1363:\nset 5,%i1\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsmul %l3,%i1,%i1\ncmp %i1,10; be .L1367; nop\nset 163,%i4\ncmp %i5,0; be .L1369; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1369:\n.L1367:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nsmul %l3,%i1,%i1\ncmp %i1,10; be .L1371; nop\nset 164,%i4\ncmp %i5,0; be .L1373; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1373:\n.L1371:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nsmul %l3,%i1,%i1\ncmp %i1,10; be .L1375; nop\nset 165,%i4\ncmp %i5,0; be .L1377; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1377:\n.L1375:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-12]\nmov %i1,%l3\nld [%fp+-12],%l2\numul %l2,%l3,%l3\nmov %l3,%i1\ncmp %i1,10; be .L1379; nop\nset 166,%i4\ncmp %i5,0; be .L1381; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1381:\n.L1379:\nset 5,%i1\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nst %i1,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nld [%fp+-28],%f30\nfmuls %f31,%f30,%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%i1\ncmp %i1,10; be .L1383; nop\nset 167,%i4\ncmp %i5,0; be .L1385; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1385:\n.L1383:\nset 5,%i1\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nst %i1,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nldd [%fp+-40],%f28\nfmuld %f30,%f28,%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%i1\ncmp %i1,10; be .L1387; nop\nset 168,%i4\ncmp %i5,0; be .L1389; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1389:\n.L1387:\nset 5,%l7\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsmul %l3,%l7,%l7\ncmp %l7,10; be .L1391; nop\nset 169,%i4\ncmp %i5,0; be .L1393; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1393:\n.L1391:\nset 5,%l7\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsmul %l3,%l7,%l7\ncmp %l7,10; be .L1395; nop\nset 170,%i4\ncmp %i5,0; be .L1397; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1397:\n.L1395:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nsmul %l3,%l7,%l7\ncmp %l7,10; be .L1399; nop\nset 171,%i4\ncmp %i5,0; be .L1401; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1401:\n.L1399:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nsmul %l3,%l7,%l7\ncmp %l7,10; be .L1403; nop\nset 172,%i4\ncmp %i5,0; be .L1405; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1405:\n.L1403:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-12]\nmov %l7,%l3\nld [%fp+-12],%l2\numul %l2,%l3,%l3\nmov %l3,%l7\ncmp %l7,10; be .L1407; nop\nset 173,%i4\ncmp %i5,0; be .L1409; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1409:\n.L1407:\nset 5,%l7\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nst %l7,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nld [%fp+-28],%f30\nfmuls %f31,%f30,%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l7\ncmp %l7,10; be .L1411; nop\nset 174,%i4\ncmp %i5,0; be .L1413; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1413:\n.L1411:\nset 5,%l7\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nst %l7,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nldd [%fp+-40],%f28\nfmuld %f30,%f28,%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l7\ncmp %l7,10; be .L1415; nop\nset 175,%i4\ncmp %i5,0; be .L1417; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1417:\n.L1415:\nset 5,%l6\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\numul %l3,%l6,%l6\nset 10,%l3\ncmp %l6,%l3; be .L1419; nop\nset 176,%i4\ncmp %i5,0; be .L1421; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1421:\n.L1419:\nset 5,%l6\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\numul %l3,%l6,%l6\nset 10,%l3\ncmp %l6,%l3; be .L1423; nop\nset 177,%i4\ncmp %i5,0; be .L1425; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1425:\n.L1423:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\numul %l3,%l6,%l6\nset 10,%l3\ncmp %l6,%l3; be .L1427; nop\nset 178,%i4\ncmp %i5,0; be .L1429; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1429:\n.L1427:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\numul %l3,%l6,%l6\nset 10,%l3\ncmp %l6,%l3; be .L1431; nop\nset 179,%i4\ncmp %i5,0; be .L1433; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1433:\n.L1431:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\numul %l3,%l6,%l6\nset 10,%l3\ncmp %l6,%l3; be .L1435; nop\nset 180,%i4\ncmp %i5,0; be .L1437; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1437:\n.L1435:\nset 5,%l6\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nset .L596,%l3\nld2 [%l3],%f30\nsrl %l6,1,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfmuld %f30,%f28,%f30\nset 1,%l3\nand %l6,%l3,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfaddd %f30,%f28,%f30\nfdtos %f30,%f31\nld [%fp+-28],%f30\nfmuls %f31,%f30,%f31\nset .L828,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbul .L1440; nop\nfsubs %f31,%f30,%f30\nfstoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nset 0x80000000,%l2\nadd %l3,%l2,%l3\nst %l3,[%fp+-80]\nba .L1441; nop\n.L1440:\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nst %l3,[%fp+-80]\n.L1441:\nld [%fp+-80],%l6\nset 10,%l3\ncmp %l6,%l3; be .L1442; nop\nset 181,%i4\ncmp %i5,0; be .L1444; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1444:\n.L1442:\nset 5,%l6\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nset .L596,%l3\nld2 [%l3],%f30\nsrl %l6,1,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfmuld %f30,%f28,%f30\nset 1,%l3\nand %l6,%l3,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfaddd %f30,%f28,%f30\nldd [%fp+-40],%f28\nfmuld %f30,%f28,%f30\nset .L836,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbul .L1447; nop\nfsubd %f30,%f28,%f28\nfdtoi %f28,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nset 0x80000000,%l2\nadd %l3,%l2,%l3\nst %l3,[%fp+-84]\nba .L1448; nop\n.L1447:\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nst %l3,[%fp+-84]\n.L1448:\nld [%fp+-84],%l6\nset 10,%l3\ncmp %l6,%l3; be .L1449; nop\nset 182,%i4\ncmp %i5,0; be .L1451; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1451:\n.L1449:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l5\nld [%fp+-16],%f31\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfmuls %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L1455,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L1453; nop\nset 183,%i4\ncmp %i5,0; be .L1456; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1456:\n.L1453:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l4\nld [%fp+-16],%f31\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfmuls %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L1455,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L1458; nop\nset 184,%i4\ncmp %i5,0; be .L1460; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1460:\n.L1458:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-16],%f31\nld [%fp+-4],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfmuls %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L1455,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L1462; nop\nset 185,%i4\ncmp %i5,0; be .L1464; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1464:\n.L1462:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-16],%f31\nld [%fp+-8],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfmuls %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L1455,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L1466; nop\nset 186,%i4\ncmp %i5,0; be .L1468; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1468:\n.L1466:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nld [%fp+-16],%f31\nset .L596,%l2\nld2 [%l2],%f28\nsrl %l3,1,%l2\nst %l2,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfmuld %f28,%f26,%f28\nset 1,%l2\nand %l3,%l2,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfaddd %f28,%f26,%f28\nfdtos %f28,%f30\nfmuls %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L1455,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L1470; nop\nset 187,%i4\ncmp %i5,0; be .L1472; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1472:\n.L1470:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nld [%fp+-16],%f31\nld [%fp+-28],%f30\nfmuls %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L1455,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L1474; nop\nset 188,%i4\ncmp %i5,0; be .L1476; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1476:\n.L1474:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nld [%fp+-16],%f31\nfstod %f31,%f30\nldd [%fp+-40],%f28\nfmuld %f30,%f28,%f30\nfdtos %f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nset .L1455,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbue .L1478; nop\nset 189,%i4\ncmp %i5,0; be .L1480; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1480:\n.L1478:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l5\nldd [%fp+-24],%f30\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfmuld %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1484,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1482; nop\nset 190,%i4\ncmp %i5,0; be .L1485; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1485:\n.L1482:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l4\nldd [%fp+-24],%f30\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfmuld %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1484,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1487; nop\nset 191,%i4\ncmp %i5,0; be .L1489; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1489:\n.L1487:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l3\nst %l3,[%fp+-4]\nldd [%fp+-24],%f30\nld [%fp+-4],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfmuld %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1484,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1491; nop\nset 192,%i4\ncmp %i5,0; be .L1493; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1493:\n.L1491:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l3\nst %l3,[%fp+-8]\nldd [%fp+-24],%f30\nld [%fp+-8],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfmuld %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1484,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1495; nop\nset 193,%i4\ncmp %i5,0; be .L1497; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1497:\n.L1495:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nldd [%fp+-24],%f30\nset .L596,%l2\nld2 [%l2],%f28\nsrl %l3,1,%l2\nst %l2,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfmuld %f28,%f26,%f28\nset 1,%l2\nand %l3,%l2,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfaddd %f28,%f26,%f28\nfmuld %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1484,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1499; nop\nset 194,%i4\ncmp %i5,0; be .L1501; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1501:\n.L1499:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nldd [%fp+-24],%f30\nld [%fp+-28],%f29\nfstod %f29,%f28\nfmuld %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1484,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1503; nop\nset 195,%i4\ncmp %i5,0; be .L1505; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1505:\n.L1503:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nldd [%fp+-24],%f30\nldd [%fp+-40],%f28\nfmuld %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1484,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1507; nop\nset 196,%i4\ncmp %i5,0; be .L1509; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1509:\n.L1507:\nset 5,%i3\nset 2,%l5\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,2; be .L1511; nop\nset 197,%i4\ncmp %i5,0; be .L1513; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1513:\n.L1511:\nset 5,%i3\nset 2,%l4\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,2; be .L1515; nop\nset 198,%i4\ncmp %i5,0; be .L1517; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1517:\n.L1515:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-4]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-4],%l2\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,2; be .L1519; nop\nset 199,%i4\ncmp %i5,0; be .L1521; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1521:\n.L1519:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-8]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-8],%l2\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,2; be .L1523; nop\nset 200,%i4\ncmp %i5,0; be .L1525; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1525:\n.L1523:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-12]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-12],%l2\nwr %g0,%g0,%y; nop; nop; nop; udiv %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,2; be .L1527; nop\nset 201,%i4\ncmp %i5,0; be .L1529; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1529:\n.L1527:\nset 5,%i3\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nld [%fp+-28],%f30\nfdivs %f31,%f30,%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,2; be .L1531; nop\nset 202,%i4\ncmp %i5,0; be .L1533; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1533:\n.L1531:\nset 5,%i3\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nldd [%fp+-40],%f28\nfdivd %f30,%f28,%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,2; be .L1535; nop\nset 203,%i4\ncmp %i5,0; be .L1537; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1537:\n.L1535:\nset 5,%i2\nset 2,%l5\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,2; be .L1539; nop\nset 204,%i4\ncmp %i5,0; be .L1541; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1541:\n.L1539:\nset 5,%i2\nset 2,%l4\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,2; be .L1543; nop\nset 205,%i4\ncmp %i5,0; be .L1545; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1545:\n.L1543:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-4]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-4],%l2\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,2; be .L1547; nop\nset 206,%i4\ncmp %i5,0; be .L1549; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1549:\n.L1547:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-8]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-8],%l2\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,2; be .L1551; nop\nset 207,%i4\ncmp %i5,0; be .L1553; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1553:\n.L1551:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-12]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-12],%l2\nwr %g0,%g0,%y; nop; nop; nop; udiv %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,2; be .L1555; nop\nset 208,%i4\ncmp %i5,0; be .L1557; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1557:\n.L1555:\nset 5,%i2\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nld [%fp+-28],%f30\nfdivs %f31,%f30,%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,2; be .L1559; nop\nset 209,%i4\ncmp %i5,0; be .L1561; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1561:\n.L1559:\nset 5,%i2\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nldd [%fp+-40],%f28\nfdivd %f30,%f28,%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,2; be .L1563; nop\nset 210,%i4\ncmp %i5,0; be .L1565; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1565:\n.L1563:\nset 5,%i1\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsra %i1,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %i1,%l3,%i1\ncmp %i1,2; be .L1567; nop\nset 211,%i4\ncmp %i5,0; be .L1569; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1569:\n.L1567:\nset 5,%i1\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsra %i1,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %i1,%l3,%i1\ncmp %i1,2; be .L1571; nop\nset 212,%i4\ncmp %i5,0; be .L1573; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1573:\n.L1571:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nsra %i1,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %i1,%l3,%i1\ncmp %i1,2; be .L1575; nop\nset 213,%i4\ncmp %i5,0; be .L1577; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1577:\n.L1575:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nsra %i1,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %i1,%l3,%i1\ncmp %i1,2; be .L1579; nop\nset 214,%i4\ncmp %i5,0; be .L1581; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1581:\n.L1579:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-12]\nmov %i1,%l3\nld [%fp+-12],%l2\nwr %g0,%g0,%y; nop; nop; nop; udiv %l3,%l2,%l3\nmov %l3,%i1\ncmp %i1,2; be .L1583; nop\nset 215,%i4\ncmp %i5,0; be .L1585; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1585:\n.L1583:\nset 5,%i1\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nst %i1,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nld [%fp+-28],%f30\nfdivs %f31,%f30,%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%i1\ncmp %i1,2; be .L1587; nop\nset 216,%i4\ncmp %i5,0; be .L1589; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1589:\n.L1587:\nset 5,%i1\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nst %i1,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nldd [%fp+-40],%f28\nfdivd %f30,%f28,%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%i1\ncmp %i1,2; be .L1591; nop\nset 217,%i4\ncmp %i5,0; be .L1593; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1593:\n.L1591:\nset 5,%l7\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsra %l7,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l7,%l3,%l7\ncmp %l7,2; be .L1595; nop\nset 218,%i4\ncmp %i5,0; be .L1597; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1597:\n.L1595:\nset 5,%l7\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsra %l7,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l7,%l3,%l7\ncmp %l7,2; be .L1599; nop\nset 219,%i4\ncmp %i5,0; be .L1601; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1601:\n.L1599:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nsra %l7,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l7,%l3,%l7\ncmp %l7,2; be .L1603; nop\nset 220,%i4\ncmp %i5,0; be .L1605; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1605:\n.L1603:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nsra %l7,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l7,%l3,%l7\ncmp %l7,2; be .L1607; nop\nset 221,%i4\ncmp %i5,0; be .L1609; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1609:\n.L1607:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-12]\nmov %l7,%l3\nld [%fp+-12],%l2\nwr %g0,%g0,%y; nop; nop; nop; udiv %l3,%l2,%l3\nmov %l3,%l7\ncmp %l7,2; be .L1611; nop\nset 222,%i4\ncmp %i5,0; be .L1613; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1613:\n.L1611:\nset 5,%l7\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nst %l7,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nld [%fp+-28],%f30\nfdivs %f31,%f30,%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l7\ncmp %l7,2; be .L1615; nop\nset 223,%i4\ncmp %i5,0; be .L1617; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1617:\n.L1615:\nset 5,%l7\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nst %l7,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nldd [%fp+-40],%f28\nfdivd %f30,%f28,%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l7\ncmp %l7,2; be .L1619; nop\nset 224,%i4\ncmp %i5,0; be .L1621; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1621:\n.L1619:\nset 5,%l6\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nwr %g0,%g0,%y; nop; nop; nop; udiv %l6,%l3,%l6\nset 2,%l3\ncmp %l6,%l3; be .L1623; nop\nset 225,%i4\ncmp %i5,0; be .L1625; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1625:\n.L1623:\nset 5,%l6\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nwr %g0,%g0,%y; nop; nop; nop; udiv %l6,%l3,%l6\nset 2,%l3\ncmp %l6,%l3; be .L1627; nop\nset 226,%i4\ncmp %i5,0; be .L1629; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1629:\n.L1627:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nwr %g0,%g0,%y; nop; nop; nop; udiv %l6,%l3,%l6\nset 2,%l3\ncmp %l6,%l3; be .L1631; nop\nset 227,%i4\ncmp %i5,0; be .L1633; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1633:\n.L1631:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nwr %g0,%g0,%y; nop; nop; nop; udiv %l6,%l3,%l6\nset 2,%l3\ncmp %l6,%l3; be .L1635; nop\nset 228,%i4\ncmp %i5,0; be .L1637; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1637:\n.L1635:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l2\nwr %g0,%g0,%y; nop; nop; nop; udiv %l6,%l2,%l6\ncmp %l6,%l3; be .L1639; nop\nset 229,%i4\ncmp %i5,0; be .L1641; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1641:\n.L1639:\nset 5,%l6\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nset .L596,%l3\nld2 [%l3],%f30\nsrl %l6,1,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfmuld %f30,%f28,%f30\nset 1,%l3\nand %l6,%l3,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfaddd %f30,%f28,%f30\nfdtos %f30,%f31\nld [%fp+-28],%f30\nfdivs %f31,%f30,%f31\nset .L828,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbul .L1644; nop\nfsubs %f31,%f30,%f30\nfstoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nset 0x80000000,%l2\nadd %l3,%l2,%l3\nst %l3,[%fp+-88]\nba .L1645; nop\n.L1644:\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nst %l3,[%fp+-88]\n.L1645:\nld [%fp+-88],%l6\nset 2,%l3\ncmp %l6,%l3; be .L1646; nop\nset 230,%i4\ncmp %i5,0; be .L1648; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1648:\n.L1646:\nset 5,%l6\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nset .L596,%l3\nld2 [%l3],%f30\nsrl %l6,1,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfmuld %f30,%f28,%f30\nset 1,%l3\nand %l6,%l3,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfaddd %f30,%f28,%f30\nldd [%fp+-40],%f28\nfdivd %f30,%f28,%f30\nset .L836,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbul .L1651; nop\nfsubd %f30,%f28,%f28\nfdtoi %f28,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nset 0x80000000,%l2\nadd %l3,%l2,%l3\nst %l3,[%fp+-92]\nba .L1652; nop\n.L1651:\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nst %l3,[%fp+-92]\n.L1652:\nld [%fp+-92],%l6\nset 2,%l3\ncmp %l6,%l3; be .L1653; nop\nset 231,%i4\ncmp %i5,0; be .L1655; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1655:\n.L1653:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l5\nld [%fp+-16],%f31\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfdivs %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nfstod %f31,%f30\nset .L1659,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1657; nop\nset 232,%i4\ncmp %i5,0; be .L1660; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1660:\n.L1657:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l4\nld [%fp+-16],%f31\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfdivs %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nfstod %f31,%f30\nset .L1659,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1662; nop\nset 233,%i4\ncmp %i5,0; be .L1664; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1664:\n.L1662:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-16],%f31\nld [%fp+-4],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfdivs %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nfstod %f31,%f30\nset .L1659,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1666; nop\nset 234,%i4\ncmp %i5,0; be .L1668; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1668:\n.L1666:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-16],%f31\nld [%fp+-8],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfdivs %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nfstod %f31,%f30\nset .L1659,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1670; nop\nset 235,%i4\ncmp %i5,0; be .L1672; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1672:\n.L1670:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nld [%fp+-16],%f31\nset .L596,%l2\nld2 [%l2],%f28\nsrl %l3,1,%l2\nst %l2,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfmuld %f28,%f26,%f28\nset 1,%l2\nand %l3,%l2,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfaddd %f28,%f26,%f28\nfdtos %f28,%f30\nfdivs %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nfstod %f31,%f30\nset .L1659,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1674; nop\nset 236,%i4\ncmp %i5,0; be .L1676; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1676:\n.L1674:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nld [%fp+-16],%f31\nld [%fp+-28],%f30\nfdivs %f31,%f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nfstod %f31,%f30\nset .L1659,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1678; nop\nset 237,%i4\ncmp %i5,0; be .L1680; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1680:\n.L1678:\nset .L841,%l3\nld [%l3],%f31\nst %f31,[%fp+-16]\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nld [%fp+-16],%f31\nfstod %f31,%f30\nldd [%fp+-40],%f28\nfdivd %f30,%f28,%f30\nfdtos %f30,%f31\nst %f31,[%fp+-16]\nld [%fp+-16],%f31\nfstod %f31,%f30\nset .L1659,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1682; nop\nset 238,%i4\ncmp %i5,0; be .L1684; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1684:\n.L1682:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l5\nldd [%fp+-24],%f30\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfdivd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1659,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1686; nop\nset 239,%i4\ncmp %i5,0; be .L1688; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1688:\n.L1686:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l4\nldd [%fp+-24],%f30\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfdivd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1659,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1690; nop\nset 240,%i4\ncmp %i5,0; be .L1692; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1692:\n.L1690:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l3\nst %l3,[%fp+-4]\nldd [%fp+-24],%f30\nld [%fp+-4],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfdivd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1659,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1694; nop\nset 241,%i4\ncmp %i5,0; be .L1696; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1696:\n.L1694:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l3\nst %l3,[%fp+-8]\nldd [%fp+-24],%f30\nld [%fp+-8],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfdivd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1659,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1698; nop\nset 242,%i4\ncmp %i5,0; be .L1700; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1700:\n.L1698:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nldd [%fp+-24],%f30\nset .L596,%l2\nld2 [%l2],%f28\nsrl %l3,1,%l2\nst %l2,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfmuld %f28,%f26,%f28\nset 1,%l2\nand %l3,%l2,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfaddd %f28,%f26,%f28\nfdivd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1659,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1702; nop\nset 243,%i4\ncmp %i5,0; be .L1704; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1704:\n.L1702:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset .L529,%l3\nld [%l3],%f31\nst %f31,[%fp+-28]\nldd [%fp+-24],%f30\nld [%fp+-28],%f29\nfstod %f29,%f28\nfdivd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1659,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1706; nop\nset 244,%i4\ncmp %i5,0; be .L1708; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1708:\n.L1706:\nset .L870,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-24]\nset .L416,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-40]\nldd [%fp+-24],%f30\nldd [%fp+-40],%f28\nfdivd %f30,%f28,%f30\nstd %f30,[%fp+-24]\nldd [%fp+-24],%f30\nset .L1659,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L1710; nop\nset 245,%i4\ncmp %i5,0; be .L1712; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1712:\n.L1710:\nset 5,%i3\nset 2,%l5\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,%l2,%g1\n; smul %g1,%l2,%g1; sub %l3,%g1,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,1; be .L1714; nop\nset 246,%i4\ncmp %i5,0; be .L1716; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1716:\n.L1714:\nset 5,%i3\nset 2,%l4\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,%l2,%g1\n; smul %g1,%l2,%g1; sub %l3,%g1,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,1; be .L1718; nop\nset 247,%i4\ncmp %i5,0; be .L1720; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1720:\n.L1718:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-4]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-4],%l2\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,%l2,%g1\n; smul %g1,%l2,%g1; sub %l3,%g1,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,1; be .L1722; nop\nset 248,%i4\ncmp %i5,0; be .L1724; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1724:\n.L1722:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-8]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-8],%l2\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,%l2,%g1\n; smul %g1,%l2,%g1; sub %l3,%g1,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,1; be .L1726; nop\nset 249,%i4\ncmp %i5,0; be .L1728; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1728:\n.L1726:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-12]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-12],%l2\nwr %g0,%g0,%y; nop; nop; nop; udiv %l3,%l2,%g1\n; umul %g1,%l2,%g1; sub %l3,%g1,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,1; be .L1730; nop\nset 250,%i4\ncmp %i5,0; be .L1732; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1732:\n.L1730:\nset 5,%i2\nset 2,%l5\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,%l2,%g1\n; smul %g1,%l2,%g1; sub %l3,%g1,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,1; be .L1734; nop\nset 251,%i4\ncmp %i5,0; be .L1736; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1736:\n.L1734:\nset 5,%i2\nset 2,%l4\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,%l2,%g1\n; smul %g1,%l2,%g1; sub %l3,%g1,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,1; be .L1738; nop\nset 252,%i4\ncmp %i5,0; be .L1740; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1740:\n.L1738:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-4]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-4],%l2\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,%l2,%g1\n; smul %g1,%l2,%g1; sub %l3,%g1,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,1; be .L1742; nop\nset 253,%i4\ncmp %i5,0; be .L1744; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1744:\n.L1742:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-8]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-8],%l2\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,%l2,%g1\n; smul %g1,%l2,%g1; sub %l3,%g1,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,1; be .L1746; nop\nset 254,%i4\ncmp %i5,0; be .L1748; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1748:\n.L1746:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-12]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-12],%l2\nwr %g0,%g0,%y; nop; nop; nop; udiv %l3,%l2,%g1\n; umul %g1,%l2,%g1; sub %l3,%g1,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,1; be .L1750; nop\nset 255,%i4\ncmp %i5,0; be .L1752; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1752:\n.L1750:\nset 5,%i1\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsra %i1,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %i1,%l3,%g1\n; smul %g1,%l3,%g1; sub %i1,%g1,%i1\ncmp %i1,1; be .L1754; nop\nset 256,%i4\ncmp %i5,0; be .L1756; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1756:\n.L1754:\nset 5,%i1\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsra %i1,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %i1,%l3,%g1\n; smul %g1,%l3,%g1; sub %i1,%g1,%i1\ncmp %i1,1; be .L1758; nop\nset 257,%i4\ncmp %i5,0; be .L1760; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1760:\n.L1758:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nsra %i1,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %i1,%l3,%g1\n; smul %g1,%l3,%g1; sub %i1,%g1,%i1\ncmp %i1,1; be .L1762; nop\nset 258,%i4\ncmp %i5,0; be .L1764; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1764:\n.L1762:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nsra %i1,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %i1,%l3,%g1\n; smul %g1,%l3,%g1; sub %i1,%g1,%i1\ncmp %i1,1; be .L1766; nop\nset 259,%i4\ncmp %i5,0; be .L1768; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1768:\n.L1766:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-12]\nmov %i1,%l3\nld [%fp+-12],%l2\nwr %g0,%g0,%y; nop; nop; nop; udiv %l3,%l2,%g1\n; umul %g1,%l2,%g1; sub %l3,%g1,%l3\nmov %l3,%i1\ncmp %i1,1; be .L1770; nop\nset 260,%i4\ncmp %i5,0; be .L1772; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1772:\n.L1770:\nset 5,%l7\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsra %l7,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l7,%l3,%g1\n; smul %g1,%l3,%g1; sub %l7,%g1,%l7\ncmp %l7,1; be .L1774; nop\nset 261,%i4\ncmp %i5,0; be .L1776; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1776:\n.L1774:\nset 5,%l7\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsra %l7,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l7,%l3,%g1\n; smul %g1,%l3,%g1; sub %l7,%g1,%l7\ncmp %l7,1; be .L1778; nop\nset 262,%i4\ncmp %i5,0; be .L1780; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1780:\n.L1778:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nsra %l7,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l7,%l3,%g1\n; smul %g1,%l3,%g1; sub %l7,%g1,%l7\ncmp %l7,1; be .L1782; nop\nset 263,%i4\ncmp %i5,0; be .L1784; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1784:\n.L1782:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nsra %l7,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l7,%l3,%g1\n; smul %g1,%l3,%g1; sub %l7,%g1,%l7\ncmp %l7,1; be .L1786; nop\nset 264,%i4\ncmp %i5,0; be .L1788; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1788:\n.L1786:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-12]\nmov %l7,%l3\nld [%fp+-12],%l2\nwr %g0,%g0,%y; nop; nop; nop; udiv %l3,%l2,%g1\n; umul %g1,%l2,%g1; sub %l3,%g1,%l3\nmov %l3,%l7\ncmp %l7,1; be .L1790; nop\nset 265,%i4\ncmp %i5,0; be .L1792; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1792:\n.L1790:\nset 5,%l6\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nwr %g0,%g0,%y; nop; nop; nop; udiv %l6,%l3,%g1\n; umul %g1,%l3,%g1; sub %l6,%g1,%l6\nset 1,%l3\ncmp %l6,%l3; be .L1794; nop\nset 266,%i4\ncmp %i5,0; be .L1796; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1796:\n.L1794:\nset 5,%l6\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nwr %g0,%g0,%y; nop; nop; nop; udiv %l6,%l3,%g1\n; umul %g1,%l3,%g1; sub %l6,%g1,%l6\nset 1,%l3\ncmp %l6,%l3; be .L1798; nop\nset 267,%i4\ncmp %i5,0; be .L1800; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1800:\n.L1798:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nwr %g0,%g0,%y; nop; nop; nop; udiv %l6,%l3,%g1\n; umul %g1,%l3,%g1; sub %l6,%g1,%l6\nset 1,%l3\ncmp %l6,%l3; be .L1802; nop\nset 268,%i4\ncmp %i5,0; be .L1804; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1804:\n.L1802:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nwr %g0,%g0,%y; nop; nop; nop; udiv %l6,%l3,%g1\n; umul %g1,%l3,%g1; sub %l6,%g1,%l6\nset 1,%l3\ncmp %l6,%l3; be .L1806; nop\nset 269,%i4\ncmp %i5,0; be .L1808; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1808:\n.L1806:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nwr %g0,%g0,%y; nop; nop; nop; udiv %l6,%l3,%g1\n; umul %g1,%l3,%g1; sub %l6,%g1,%l6\nset 1,%l3\ncmp %l6,%l3; be .L1810; nop\nset 270,%i4\ncmp %i5,0; be .L1812; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1812:\n.L1810:\nset 5,%i3\nset 2,%l5\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nsra %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,1; be .L1814; nop\nset 271,%i4\ncmp %i5,0; be .L1816; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1816:\n.L1814:\nset 5,%i3\nset 2,%l4\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\nsra %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,1; be .L1818; nop\nset 272,%i4\ncmp %i5,0; be .L1820; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1820:\n.L1818:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-4]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-4],%l2\nsra %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,1; be .L1822; nop\nset 273,%i4\ncmp %i5,0; be .L1824; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1824:\n.L1822:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-8]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-8],%l2\nsra %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,1; be .L1826; nop\nset 274,%i4\ncmp %i5,0; be .L1828; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1828:\n.L1826:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-12]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-12],%l2\nsra %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,1; be .L1830; nop\nset 275,%i4\ncmp %i5,0; be .L1832; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1832:\n.L1830:\nset 5,%i2\nset 2,%l5\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nsra %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,1; be .L1834; nop\nset 276,%i4\ncmp %i5,0; be .L1836; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1836:\n.L1834:\nset 5,%i2\nset 2,%l4\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\nsra %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,1; be .L1838; nop\nset 277,%i4\ncmp %i5,0; be .L1840; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1840:\n.L1838:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-4]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-4],%l2\nsra %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,1; be .L1842; nop\nset 278,%i4\ncmp %i5,0; be .L1844; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1844:\n.L1842:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-8]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-8],%l2\nsra %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,1; be .L1846; nop\nset 279,%i4\ncmp %i5,0; be .L1848; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1848:\n.L1846:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-12]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-12],%l2\nsra %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,1; be .L1850; nop\nset 280,%i4\ncmp %i5,0; be .L1852; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1852:\n.L1850:\nset 5,%i1\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsra %i1,%l3,%i1\ncmp %i1,1; be .L1854; nop\nset 281,%i4\ncmp %i5,0; be .L1856; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1856:\n.L1854:\nset 5,%i1\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsra %i1,%l3,%i1\ncmp %i1,1; be .L1858; nop\nset 282,%i4\ncmp %i5,0; be .L1860; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1860:\n.L1858:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nsra %i1,%l3,%i1\ncmp %i1,1; be .L1862; nop\nset 283,%i4\ncmp %i5,0; be .L1864; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1864:\n.L1862:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nsra %i1,%l3,%i1\ncmp %i1,1; be .L1866; nop\nset 284,%i4\ncmp %i5,0; be .L1868; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1868:\n.L1866:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nsra %i1,%l3,%i1\ncmp %i1,1; be .L1870; nop\nset 285,%i4\ncmp %i5,0; be .L1872; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1872:\n.L1870:\nset 5,%l7\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsra %l7,%l3,%l7\ncmp %l7,1; be .L1874; nop\nset 286,%i4\ncmp %i5,0; be .L1876; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1876:\n.L1874:\nset 5,%l7\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsra %l7,%l3,%l7\ncmp %l7,1; be .L1878; nop\nset 287,%i4\ncmp %i5,0; be .L1880; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1880:\n.L1878:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nsra %l7,%l3,%l7\ncmp %l7,1; be .L1882; nop\nset 288,%i4\ncmp %i5,0; be .L1884; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1884:\n.L1882:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nsra %l7,%l3,%l7\ncmp %l7,1; be .L1886; nop\nset 289,%i4\ncmp %i5,0; be .L1888; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1888:\n.L1886:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nsra %l7,%l3,%l7\ncmp %l7,1; be .L1890; nop\nset 290,%i4\ncmp %i5,0; be .L1892; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1892:\n.L1890:\nset 5,%l6\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsrl %l6,%l3,%l6\nset 1,%l3\ncmp %l6,%l3; be .L1894; nop\nset 291,%i4\ncmp %i5,0; be .L1896; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1896:\n.L1894:\nset 5,%l6\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsrl %l6,%l3,%l6\nset 1,%l3\ncmp %l6,%l3; be .L1898; nop\nset 292,%i4\ncmp %i5,0; be .L1900; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1900:\n.L1898:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nsrl %l6,%l3,%l6\nset 1,%l3\ncmp %l6,%l3; be .L1902; nop\nset 293,%i4\ncmp %i5,0; be .L1904; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1904:\n.L1902:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nsrl %l6,%l3,%l6\nset 1,%l3\ncmp %l6,%l3; be .L1906; nop\nset 294,%i4\ncmp %i5,0; be .L1908; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1908:\n.L1906:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nsrl %l6,%l3,%l6\nset 1,%l3\ncmp %l6,%l3; be .L1910; nop\nset 295,%i4\ncmp %i5,0; be .L1912; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1912:\n.L1910:\nset 5,%i3\nset 2,%l5\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nsll %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,20; be .L1914; nop\nset 296,%i4\ncmp %i5,0; be .L1916; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1916:\n.L1914:\nset 5,%i3\nset 2,%l4\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\nsll %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,20; be .L1918; nop\nset 297,%i4\ncmp %i5,0; be .L1920; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1920:\n.L1918:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-4]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-4],%l2\nsll %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,20; be .L1922; nop\nset 298,%i4\ncmp %i5,0; be .L1924; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1924:\n.L1922:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-8]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-8],%l2\nsll %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,20; be .L1926; nop\nset 299,%i4\ncmp %i5,0; be .L1928; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1928:\n.L1926:\nset 5,%i3\nset 2,%l3\nst %l3,[%fp+-12]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-12],%l2\nsll %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,20; be .L1930; nop\nset 300,%i4\ncmp %i5,0; be .L1932; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1932:\n.L1930:\nset 5,%i2\nset 2,%l5\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nsll %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,20; be .L1934; nop\nset 301,%i4\ncmp %i5,0; be .L1936; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1936:\n.L1934:\nset 5,%i2\nset 2,%l4\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\nsll %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,20; be .L1938; nop\nset 302,%i4\ncmp %i5,0; be .L1940; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1940:\n.L1938:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-4]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-4],%l2\nsll %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,20; be .L1942; nop\nset 303,%i4\ncmp %i5,0; be .L1944; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1944:\n.L1942:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-8]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-8],%l2\nsll %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,20; be .L1946; nop\nset 304,%i4\ncmp %i5,0; be .L1948; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1948:\n.L1946:\nset 5,%i2\nset 2,%l3\nst %l3,[%fp+-12]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-12],%l2\nsll %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,20; be .L1950; nop\nset 305,%i4\ncmp %i5,0; be .L1952; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1952:\n.L1950:\nset 5,%i1\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %i1,%l3,%i1\ncmp %i1,20; be .L1954; nop\nset 306,%i4\ncmp %i5,0; be .L1956; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1956:\n.L1954:\nset 5,%i1\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %i1,%l3,%i1\ncmp %i1,20; be .L1958; nop\nset 307,%i4\ncmp %i5,0; be .L1960; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1960:\n.L1958:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nsll %i1,%l3,%i1\ncmp %i1,20; be .L1962; nop\nset 308,%i4\ncmp %i5,0; be .L1964; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1964:\n.L1962:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nsll %i1,%l3,%i1\ncmp %i1,20; be .L1966; nop\nset 309,%i4\ncmp %i5,0; be .L1968; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1968:\n.L1966:\nset 5,%i1\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nsll %i1,%l3,%i1\ncmp %i1,20; be .L1970; nop\nset 310,%i4\ncmp %i5,0; be .L1972; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1972:\n.L1970:\nset 5,%l7\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l7,%l3,%l7\ncmp %l7,20; be .L1974; nop\nset 311,%i4\ncmp %i5,0; be .L1976; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1976:\n.L1974:\nset 5,%l7\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l7,%l3,%l7\ncmp %l7,20; be .L1978; nop\nset 312,%i4\ncmp %i5,0; be .L1980; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1980:\n.L1978:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nsll %l7,%l3,%l7\ncmp %l7,20; be .L1982; nop\nset 313,%i4\ncmp %i5,0; be .L1984; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1984:\n.L1982:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nsll %l7,%l3,%l7\ncmp %l7,20; be .L1986; nop\nset 314,%i4\ncmp %i5,0; be .L1988; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1988:\n.L1986:\nset 5,%l7\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nsll %l7,%l3,%l7\ncmp %l7,20; be .L1990; nop\nset 315,%i4\ncmp %i5,0; be .L1992; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1992:\n.L1990:\nset 5,%l6\nset 2,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l6,%l3,%l6\nset 20,%l3\ncmp %l6,%l3; be .L1994; nop\nset 316,%i4\ncmp %i5,0; be .L1996; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L1996:\n.L1994:\nset 5,%l6\nset 2,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l6,%l3,%l6\nset 20,%l3\ncmp %l6,%l3; be .L1998; nop\nset 317,%i4\ncmp %i5,0; be .L2000; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2000:\n.L1998:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nsll %l6,%l3,%l6\nset 20,%l3\ncmp %l6,%l3; be .L2002; nop\nset 318,%i4\ncmp %i5,0; be .L2004; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2004:\n.L2002:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nsll %l6,%l3,%l6\nset 20,%l3\ncmp %l6,%l3; be .L2006; nop\nset 319,%i4\ncmp %i5,0; be .L2008; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2008:\n.L2006:\nset 5,%l6\nset 2,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nsll %l6,%l3,%l6\nset 20,%l3\ncmp %l6,%l3; be .L2010; nop\nset 320,%i4\ncmp %i5,0; be .L2012; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2012:\n.L2010:\nset 12,%i3\nset 10,%l5\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nand %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,8; be .L2014; nop\nset 321,%i4\ncmp %i5,0; be .L2016; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2016:\n.L2014:\nset 12,%i3\nset 10,%l4\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\nand %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,8; be .L2018; nop\nset 322,%i4\ncmp %i5,0; be .L2020; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2020:\n.L2018:\nset 12,%i3\nset 10,%l3\nst %l3,[%fp+-4]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-4],%l2\nand %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,8; be .L2022; nop\nset 323,%i4\ncmp %i5,0; be .L2024; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2024:\n.L2022:\nset 12,%i3\nset 10,%l3\nst %l3,[%fp+-8]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-8],%l2\nand %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,8; be .L2026; nop\nset 324,%i4\ncmp %i5,0; be .L2028; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2028:\n.L2026:\nset 12,%i3\nset 10,%l3\nst %l3,[%fp+-12]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-12],%l2\nand %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,8; be .L2030; nop\nset 325,%i4\ncmp %i5,0; be .L2032; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2032:\n.L2030:\nset 12,%i2\nset 10,%l5\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nand %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,8; be .L2034; nop\nset 326,%i4\ncmp %i5,0; be .L2036; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2036:\n.L2034:\nset 12,%i2\nset 10,%l4\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\nand %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,8; be .L2038; nop\nset 327,%i4\ncmp %i5,0; be .L2040; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2040:\n.L2038:\nset 12,%i2\nset 10,%l3\nst %l3,[%fp+-4]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-4],%l2\nand %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,8; be .L2042; nop\nset 328,%i4\ncmp %i5,0; be .L2044; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2044:\n.L2042:\nset 12,%i2\nset 10,%l3\nst %l3,[%fp+-8]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-8],%l2\nand %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,8; be .L2046; nop\nset 329,%i4\ncmp %i5,0; be .L2048; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2048:\n.L2046:\nset 12,%i2\nset 10,%l3\nst %l3,[%fp+-12]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-12],%l2\nand %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,8; be .L2050; nop\nset 330,%i4\ncmp %i5,0; be .L2052; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2052:\n.L2050:\nset 12,%i1\nset 10,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nand %i1,%l3,%i1\ncmp %i1,8; be .L2054; nop\nset 331,%i4\ncmp %i5,0; be .L2056; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2056:\n.L2054:\nset 12,%i1\nset 10,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nand %i1,%l3,%i1\ncmp %i1,8; be .L2058; nop\nset 332,%i4\ncmp %i5,0; be .L2060; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2060:\n.L2058:\nset 12,%i1\nset 10,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nand %i1,%l3,%i1\ncmp %i1,8; be .L2062; nop\nset 333,%i4\ncmp %i5,0; be .L2064; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2064:\n.L2062:\nset 12,%i1\nset 10,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nand %i1,%l3,%i1\ncmp %i1,8; be .L2066; nop\nset 334,%i4\ncmp %i5,0; be .L2068; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2068:\n.L2066:\nset 12,%i1\nset 10,%l3\nst %l3,[%fp+-12]\nmov %i1,%l3\nld [%fp+-12],%l2\nand %l3,%l2,%l3\nmov %l3,%i1\ncmp %i1,8; be .L2070; nop\nset 335,%i4\ncmp %i5,0; be .L2072; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2072:\n.L2070:\nset 12,%l7\nset 10,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nand %l7,%l3,%l7\ncmp %l7,8; be .L2074; nop\nset 336,%i4\ncmp %i5,0; be .L2076; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2076:\n.L2074:\nset 12,%l7\nset 10,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nand %l7,%l3,%l7\ncmp %l7,8; be .L2078; nop\nset 337,%i4\ncmp %i5,0; be .L2080; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2080:\n.L2078:\nset 12,%l7\nset 10,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nand %l7,%l3,%l7\ncmp %l7,8; be .L2082; nop\nset 338,%i4\ncmp %i5,0; be .L2084; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2084:\n.L2082:\nset 12,%l7\nset 10,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nand %l7,%l3,%l7\ncmp %l7,8; be .L2086; nop\nset 339,%i4\ncmp %i5,0; be .L2088; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2088:\n.L2086:\nset 12,%l7\nset 10,%l3\nst %l3,[%fp+-12]\nmov %l7,%l3\nld [%fp+-12],%l2\nand %l3,%l2,%l3\nmov %l3,%l7\ncmp %l7,8; be .L2090; nop\nset 340,%i4\ncmp %i5,0; be .L2092; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2092:\n.L2090:\nset 12,%l6\nset 10,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nand %l6,%l3,%l6\nset 8,%l3\ncmp %l6,%l3; be .L2094; nop\nset 341,%i4\ncmp %i5,0; be .L2096; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2096:\n.L2094:\nset 12,%l6\nset 10,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nand %l6,%l3,%l6\nset 8,%l3\ncmp %l6,%l3; be .L2098; nop\nset 342,%i4\ncmp %i5,0; be .L2100; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2100:\n.L2098:\nset 12,%l6\nset 10,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nand %l6,%l3,%l6\nset 8,%l3\ncmp %l6,%l3; be .L2102; nop\nset 343,%i4\ncmp %i5,0; be .L2104; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2104:\n.L2102:\nset 12,%l6\nset 10,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nand %l6,%l3,%l6\nset 8,%l3\ncmp %l6,%l3; be .L2106; nop\nset 344,%i4\ncmp %i5,0; be .L2108; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2108:\n.L2106:\nset 12,%l6\nset 10,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nand %l6,%l3,%l6\nset 8,%l3\ncmp %l6,%l3; be .L2110; nop\nset 345,%i4\ncmp %i5,0; be .L2112; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2112:\n.L2110:\nset 12,%i3\nset 10,%l5\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nxor %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,6; be .L2114; nop\nset 346,%i4\ncmp %i5,0; be .L2116; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2116:\n.L2114:\nset 12,%i3\nset 10,%l4\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\nxor %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,6; be .L2118; nop\nset 347,%i4\ncmp %i5,0; be .L2120; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2120:\n.L2118:\nset 12,%i3\nset 10,%l3\nst %l3,[%fp+-4]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-4],%l2\nxor %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,6; be .L2122; nop\nset 348,%i4\ncmp %i5,0; be .L2124; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2124:\n.L2122:\nset 12,%i3\nset 10,%l3\nst %l3,[%fp+-8]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-8],%l2\nxor %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,6; be .L2126; nop\nset 349,%i4\ncmp %i5,0; be .L2128; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2128:\n.L2126:\nset 12,%i3\nset 10,%l3\nst %l3,[%fp+-12]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-12],%l2\nxor %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,6; be .L2130; nop\nset 350,%i4\ncmp %i5,0; be .L2132; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2132:\n.L2130:\nset 12,%i2\nset 10,%l5\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nxor %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,6; be .L2134; nop\nset 351,%i4\ncmp %i5,0; be .L2136; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2136:\n.L2134:\nset 12,%i2\nset 10,%l4\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\nxor %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,6; be .L2138; nop\nset 352,%i4\ncmp %i5,0; be .L2140; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2140:\n.L2138:\nset 12,%i2\nset 10,%l3\nst %l3,[%fp+-4]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-4],%l2\nxor %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,6; be .L2142; nop\nset 353,%i4\ncmp %i5,0; be .L2144; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2144:\n.L2142:\nset 12,%i2\nset 10,%l3\nst %l3,[%fp+-8]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-8],%l2\nxor %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,6; be .L2146; nop\nset 354,%i4\ncmp %i5,0; be .L2148; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2148:\n.L2146:\nset 12,%i2\nset 10,%l3\nst %l3,[%fp+-12]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-12],%l2\nxor %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,6; be .L2150; nop\nset 355,%i4\ncmp %i5,0; be .L2152; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2152:\n.L2150:\nset 12,%i1\nset 10,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nxor %i1,%l3,%i1\ncmp %i1,6; be .L2154; nop\nset 356,%i4\ncmp %i5,0; be .L2156; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2156:\n.L2154:\nset 12,%i1\nset 10,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nxor %i1,%l3,%i1\ncmp %i1,6; be .L2158; nop\nset 357,%i4\ncmp %i5,0; be .L2160; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2160:\n.L2158:\nset 12,%i1\nset 10,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nxor %i1,%l3,%i1\ncmp %i1,6; be .L2162; nop\nset 358,%i4\ncmp %i5,0; be .L2164; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2164:\n.L2162:\nset 12,%i1\nset 10,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nxor %i1,%l3,%i1\ncmp %i1,6; be .L2166; nop\nset 359,%i4\ncmp %i5,0; be .L2168; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2168:\n.L2166:\nset 12,%i1\nset 10,%l3\nst %l3,[%fp+-12]\nmov %i1,%l3\nld [%fp+-12],%l2\nxor %l3,%l2,%l3\nmov %l3,%i1\ncmp %i1,6; be .L2170; nop\nset 360,%i4\ncmp %i5,0; be .L2172; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2172:\n.L2170:\nset 12,%l7\nset 10,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nxor %l7,%l3,%l7\ncmp %l7,6; be .L2174; nop\nset 361,%i4\ncmp %i5,0; be .L2176; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2176:\n.L2174:\nset 12,%l7\nset 10,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nxor %l7,%l3,%l7\ncmp %l7,6; be .L2178; nop\nset 362,%i4\ncmp %i5,0; be .L2180; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2180:\n.L2178:\nset 12,%l7\nset 10,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nxor %l7,%l3,%l7\ncmp %l7,6; be .L2182; nop\nset 363,%i4\ncmp %i5,0; be .L2184; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2184:\n.L2182:\nset 12,%l7\nset 10,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nxor %l7,%l3,%l7\ncmp %l7,6; be .L2186; nop\nset 364,%i4\ncmp %i5,0; be .L2188; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2188:\n.L2186:\nset 12,%l7\nset 10,%l3\nst %l3,[%fp+-12]\nmov %l7,%l3\nld [%fp+-12],%l2\nxor %l3,%l2,%l3\nmov %l3,%l7\ncmp %l7,6; be .L2190; nop\nset 365,%i4\ncmp %i5,0; be .L2192; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2192:\n.L2190:\nset 12,%l6\nset 10,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nxor %l6,%l3,%l6\nset 6,%l3\ncmp %l6,%l3; be .L2194; nop\nset 366,%i4\ncmp %i5,0; be .L2196; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2196:\n.L2194:\nset 12,%l6\nset 10,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nxor %l6,%l3,%l6\nset 6,%l3\ncmp %l6,%l3; be .L2198; nop\nset 367,%i4\ncmp %i5,0; be .L2200; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2200:\n.L2198:\nset 12,%l6\nset 10,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nxor %l6,%l3,%l6\nset 6,%l3\ncmp %l6,%l3; be .L2202; nop\nset 368,%i4\ncmp %i5,0; be .L2204; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2204:\n.L2202:\nset 12,%l6\nset 10,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nxor %l6,%l3,%l6\nset 6,%l3\ncmp %l6,%l3; be .L2206; nop\nset 369,%i4\ncmp %i5,0; be .L2208; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2208:\n.L2206:\nset 12,%l6\nset 10,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nxor %l6,%l3,%l6\nset 6,%l3\ncmp %l6,%l3; be .L2210; nop\nset 370,%i4\ncmp %i5,0; be .L2212; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2212:\n.L2210:\nset 12,%i3\nset 10,%l5\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nor %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,14; be .L2214; nop\nset 371,%i4\ncmp %i5,0; be .L2216; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2216:\n.L2214:\nset 12,%i3\nset 10,%l4\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\nor %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,14; be .L2218; nop\nset 372,%i4\ncmp %i5,0; be .L2220; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2220:\n.L2218:\nset 12,%i3\nset 10,%l3\nst %l3,[%fp+-4]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-4],%l2\nor %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,14; be .L2222; nop\nset 373,%i4\ncmp %i5,0; be .L2224; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2224:\n.L2222:\nset 12,%i3\nset 10,%l3\nst %l3,[%fp+-8]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-8],%l2\nor %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,14; be .L2226; nop\nset 374,%i4\ncmp %i5,0; be .L2228; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2228:\n.L2226:\nset 12,%i3\nset 10,%l3\nst %l3,[%fp+-12]\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nld [%fp+-12],%l2\nor %l3,%l2,%l3\nmov %l3,%i3\nsll %i3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,14; be .L2230; nop\nset 375,%i4\ncmp %i5,0; be .L2232; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2232:\n.L2230:\nset 12,%i2\nset 10,%l5\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l5,8*(4-1),%l2; sra %l2,8*(4-1),%l2\nor %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,14; be .L2234; nop\nset 376,%i4\ncmp %i5,0; be .L2236; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2236:\n.L2234:\nset 12,%i2\nset 10,%l4\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l4,8*(4-2),%l2; sra %l2,8*(4-2),%l2\nor %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,14; be .L2238; nop\nset 377,%i4\ncmp %i5,0; be .L2240; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2240:\n.L2238:\nset 12,%i2\nset 10,%l3\nst %l3,[%fp+-4]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-4],%l2\nor %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,14; be .L2242; nop\nset 378,%i4\ncmp %i5,0; be .L2244; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2244:\n.L2242:\nset 12,%i2\nset 10,%l3\nst %l3,[%fp+-8]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-8],%l2\nor %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,14; be .L2246; nop\nset 379,%i4\ncmp %i5,0; be .L2248; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2248:\n.L2246:\nset 12,%i2\nset 10,%l3\nst %l3,[%fp+-12]\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nld [%fp+-12],%l2\nor %l3,%l2,%l3\nmov %l3,%i2\nsll %i2,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,14; be .L2250; nop\nset 380,%i4\ncmp %i5,0; be .L2252; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2252:\n.L2250:\nset 12,%i1\nset 10,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nor %i1,%l3,%i1\ncmp %i1,14; be .L2254; nop\nset 381,%i4\ncmp %i5,0; be .L2256; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2256:\n.L2254:\nset 12,%i1\nset 10,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nor %i1,%l3,%i1\ncmp %i1,14; be .L2258; nop\nset 382,%i4\ncmp %i5,0; be .L2260; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2260:\n.L2258:\nset 12,%i1\nset 10,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nor %i1,%l3,%i1\ncmp %i1,14; be .L2262; nop\nset 383,%i4\ncmp %i5,0; be .L2264; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2264:\n.L2262:\nset 12,%i1\nset 10,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nor %i1,%l3,%i1\ncmp %i1,14; be .L2266; nop\nset 384,%i4\ncmp %i5,0; be .L2268; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2268:\n.L2266:\nset 12,%i1\nset 10,%l3\nst %l3,[%fp+-12]\nmov %i1,%l3\nld [%fp+-12],%l2\nor %l3,%l2,%l3\nmov %l3,%i1\ncmp %i1,14; be .L2270; nop\nset 385,%i4\ncmp %i5,0; be .L2272; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2272:\n.L2270:\nset 12,%l7\nset 10,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nor %l7,%l3,%l7\ncmp %l7,14; be .L2274; nop\nset 386,%i4\ncmp %i5,0; be .L2276; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2276:\n.L2274:\nset 12,%l7\nset 10,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nor %l7,%l3,%l7\ncmp %l7,14; be .L2278; nop\nset 387,%i4\ncmp %i5,0; be .L2280; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2280:\n.L2278:\nset 12,%l7\nset 10,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nor %l7,%l3,%l7\ncmp %l7,14; be .L2282; nop\nset 388,%i4\ncmp %i5,0; be .L2284; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2284:\n.L2282:\nset 12,%l7\nset 10,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nor %l7,%l3,%l7\ncmp %l7,14; be .L2286; nop\nset 389,%i4\ncmp %i5,0; be .L2288; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2288:\n.L2286:\nset 12,%l7\nset 10,%l3\nst %l3,[%fp+-12]\nmov %l7,%l3\nld [%fp+-12],%l2\nor %l3,%l2,%l3\nmov %l3,%l7\ncmp %l7,14; be .L2290; nop\nset 390,%i4\ncmp %i5,0; be .L2292; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2292:\n.L2290:\nset 12,%l6\nset 10,%l5\nsll %l5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nor %l6,%l3,%l6\nset 14,%l3\ncmp %l6,%l3; be .L2294; nop\nset 391,%i4\ncmp %i5,0; be .L2296; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2296:\n.L2294:\nset 12,%l6\nset 10,%l4\nsll %l4,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nor %l6,%l3,%l6\nset 14,%l3\ncmp %l6,%l3; be .L2298; nop\nset 392,%i4\ncmp %i5,0; be .L2300; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2300:\n.L2298:\nset 12,%l6\nset 10,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nor %l6,%l3,%l6\nset 14,%l3\ncmp %l6,%l3; be .L2302; nop\nset 393,%i4\ncmp %i5,0; be .L2304; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2304:\n.L2302:\nset 12,%l6\nset 10,%l3\nst %l3,[%fp+-8]\nld [%fp+-8],%l3\nor %l6,%l3,%l6\nset 14,%l3\ncmp %l6,%l3; be .L2306; nop\nset 394,%i4\ncmp %i5,0; be .L2308; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2308:\n.L2306:\nset 12,%l6\nset 10,%l3\nst %l3,[%fp+-12]\nld [%fp+-12],%l3\nor %l6,%l3,%l6\nset 14,%l3\ncmp %l6,%l3; be .L2310; nop\nset 395,%i4\ncmp %i5,0; be .L2312; nop\nset .687,%o0\nmov %i4,%o1\ncall printf; nop\n.L2312:\n.L2310:\ncmp %i4,0; be .L2314; nop\nset 1,%l3\nst %l3,[%fp+-52]\nld [%i0+44],%l3\ncmp %l3,0; be .L2316; nop\nset .688,%o0\nset 1,%o1\ncall printf; nop\n.L2316:\n.L2314:\nld [%fp+-52],%i0\n.L686:\nret; restore\n.type s714,#function\n.size s714,.-s714\n.section \".data\"\n.type .2319,#object\n.align 1\n.2319:\n.byte 115\n.byte 55\n.byte 49\n.byte 53\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size .2319,11\n.type .2320,#object\n.size .2320,8\n.align 1\n.2320:\n.byte 115\n.byte 55\n.byte 49\n.byte 53\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.global s715\n.section \".text\"\n.align 4\ns715:\nsave %sp,-96,%sp\nmov %g0,%l6\nmov %g0,%i1\nset .2320,%i5\nadd %i0,60,%i4\nmov %g0,%i2\n.L2321:\n.L2322:\nmov %i4,%l5\nadd %l5,1,%i4\nmov %i5,%l4\nadd %l4,1,%i5\nldsb [%l4],%l4\nstb %l4,[%l5]\nsll %l4,8*(4-1),%l5; sra %l5,8*(4-1),%l5\ncmp %l5,0; bne .L2321; nop\nset 1,%l5\nmov %l5,%i3\nadd %i3,1,%i3\nadd %i3,1,%i3\nadd %i3,1,%i3\nadd %i3,1,%i3\nadd %i3,1,%l5\nmov %l5,%i3\ncmp %l5,6; be .L2324; nop\nld [%i0+44],%l5\ncmp %l5,0; be .L2326; nop\nset .2319,%o0\nset 1,%o1\ncall printf; nop\n.L2326:\nadd %i2,1,%i2\n.L2324:\nmov %i1,%o0\nset 3,%l7\nadd %l7,2,%o1\nmov %l6,%o2\ncall s715f; nop\ncmp %o0,5; be .L2328; nop\nld [%i0+44],%l5\ncmp %l5,0; be .L2330; nop\nset .2319,%o0\nset 2,%o1\ncall printf; nop\n.L2330:\nadd %i2,2,%i2\n.L2328:\nmov %i2,%i0\n.L2318:\nret; restore\n.type s715,#function\n.size s715,.-s715\n.global s715f\n.align 4\ns715f:\nmov %o1,%o0\n.L2332:\nretl; nop\n.type s715f,#function\n.size s715f,.-s715f\n.section \".data\"\n.type .2334,#object\n.align 1\n.2334:\n.byte 115\n.byte 55\n.byte 50\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size .2334,10\n.type .2335,#object\n.size .2335,8\n.align 1\n.2335:\n.byte 115\n.byte 55\n.byte 50\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.global s72\n.section \".text\"\n.align 4\ns72:\nsave %sp,-120,%sp\nset .2335,%i4\nadd %i0,60,%i3\nmov %g0,%i1\n.L2336:\n.L2337:\nmov %i3,%l3\nadd %l3,1,%i3\nmov %i4,%l2\nadd %l2,1,%i4\nldsb [%l2],%l2\nstb %l2,[%l3]\nsll %l2,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,0; bne .L2336; nop\nset 2,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\ncmp %l3,2; be .L2339; nop\nset 1,%l3\nadd %i1,1,%i1\nset .2334,%o0\nmov %l3,%o1\ncall printf; nop\n.L2339:\nld [%fp+-4],%l3\nneg %l3,%l2\nadd %l3,%l2,%l3\ncmp %l3,0; be .L2341; nop\nset 2,%l3\nadd %i1,2,%i1\nset .2334,%o0\nmov %l3,%o1\ncall printf; nop\n.L2341:\nst %g0,[%fp+-4]\nmov %g0,%i5\nba .L2346; nop\n.L2343:\nld [%fp+-4],%l3\nsll %l3,1,%l3\nor %l3,1,%l3\nst %l3,[%fp+-4]\n.L2344:\nadd %i5,1,%i5\n.L2346:\nld [%i0+4],%l3\ncmp %i5,%l3; bl .L2343; nop\nld [%fp+-4],%l3\nnot %l3,%l3\ncmp %l3,0; be .L2347; nop\nset 4,%l3\nadd %i1,4,%i1\nset .2334,%o0\nmov %l3,%o1\ncall printf; nop\n.L2347:\nset 5,%l3\nst %l3,[%fp+-4]\nld [%fp+-4],%l3\nadd %l3,1,%l3\nst %l3,[%fp+-4]\ncmp %l3,6; bne .L2354; nop\nld [%fp+-4],%l3\nsub %l3,1,%l3\nst %l3,[%fp+-4]\ncmp %l3,5; bne .L2354; nop\nld [%fp+-4],%l3\nadd %l3,1,%l2\nst %l2,[%fp+-4]\ncmp %l3,5; bne .L2354; nop\nld [%fp+-4],%l3\nsub %l3,1,%l2\nst %l2,[%fp+-4]\ncmp %l3,6; bne .L2354; nop\nld [%fp+-4],%l3\ncmp %l3,5; be .L2349; nop\n.L2354:\nset 8,%l3\nadd %i1,8,%i1\nset .2334,%o0\nmov %l3,%o1\ncall printf; nop\n.L2349:\nset 26,%l6\nset 26,%l4\nset .L2355,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-16]\nset 26,%l5\nset 26,%l3\nst %l3,[%fp+-8]\nset 26,%l7\nset .L2356,%l3\nld [%l3],%f31\nst %f31,[%fp+-20]\nmov %g0,%i2\nsll %l5,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nsll %l3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,26; bne .L2363; nop\nmov %l7,%l3\nsll %l3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,26; bne .L2363; nop\nmov %l4,%l3\nsll %l3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,26; bne .L2363; nop\nld [%fp+-8],%l3\nsll %l3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,26; bne .L2363; nop\nld [%fp+-20],%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nsll %l3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,26; bne .L2363; nop\nldd [%fp+-16],%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nsll %l3,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,26; be .L2357; nop\n.L2363:\nadd %i2,1,%i2\n.L2357:\nsll %l6,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %l3,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,26; bne .L2370; nop\nmov %l7,%l3\nsll %l3,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,26; bne .L2370; nop\nmov %l4,%l3\nsll %l3,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,26; bne .L2370; nop\nld [%fp+-8],%l3\nsll %l3,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,26; bne .L2370; nop\nld [%fp+-20],%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nsll %l3,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,26; bne .L2370; nop\nldd [%fp+-16],%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nsll %l3,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,26; be .L2364; nop\n.L2370:\nadd %i2,2,%i2\n.L2364:\nsll %l6,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,26; bne .L2377; nop\nsll %l5,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,26; bne .L2377; nop\ncmp %l4,26; bne .L2377; nop\nld [%fp+-8],%l3\ncmp %l3,26; bne .L2377; nop\nld [%fp+-20],%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\ncmp %l3,26; bne .L2377; nop\nldd [%fp+-16],%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\ncmp %l3,26; be .L2371; nop\n.L2377:\nadd %i2,4,%i2\n.L2371:\nsll %l6,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,26; bne .L2384; nop\nsll %l5,8*(4-2),%l3; sra %l3,8*(4-2),%l3\ncmp %l3,26; bne .L2384; nop\ncmp %l7,26; bne .L2384; nop\nld [%fp+-8],%l3\ncmp %l3,26; bne .L2384; nop\nld [%fp+-20],%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\ncmp %l3,26; bne .L2384; nop\nldd [%fp+-16],%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\ncmp %l3,26; be .L2378; nop\n.L2384:\nadd %i2,8,%i2\n.L2378:\nset 26,%l3\nsll %l6,8*(4-1),%l2; sra %l2,8*(4-1),%l2\ncmp %l2,%l3; bne .L2393; nop\nsll %l5,8*(4-2),%l2; sra %l2,8*(4-2),%l2\ncmp %l2,%l3; bne .L2393; nop\nmov %l7,%l2\ncmp %l2,%l3; bne .L2393; nop\nmov %l4,%l2\ncmp %l2,%l3; bne .L2393; nop\nld [%fp+-20],%f31\nset .L828,%l3\nld [%l3],%f30\nfcmpes %f31,%f30; nop; fbul .L2394; nop\nfsubs %f31,%f30,%f30\nfstoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nset 0x80000000,%l2\nadd %l3,%l2,%l3\nst %l3,[%fp+-24]\nba .L2395; nop\n.L2394:\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nst %l3,[%fp+-24]\n.L2395:\nld [%fp+-24],%l3\nset 26,%l2\ncmp %l3,%l2; bne .L2393; nop\nldd [%fp+-16],%f30\nset .L836,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbul .L2396; nop\nfsubd %f30,%f28,%f28\nfdtoi %f28,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nset 0x80000000,%l2\nadd %l3,%l2,%l3\nst %l3,[%fp+-28]\nba .L2397; nop\n.L2396:\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nst %l3,[%fp+-28]\n.L2397:\nld [%fp+-28],%l3\nset 26,%l2\ncmp %l3,%l2; be .L2385; nop\n.L2393:\nadd %i2,16,%i2\n.L2385:\nset .L2355,%l3\nld2 [%l3],%f30\nsll %l6,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f29; fitos %f29,%f29\nfstod %f29,%f28\nfcmped %f28,%f30; nop; fbne .L2404; nop\nsll %l5,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f29; fitos %f29,%f29\nfstod %f29,%f28\nfcmped %f28,%f30; nop; fbne .L2404; nop\nst %l7,[%sp+64]; ld [%sp+64],%f29; fitos %f29,%f29\nfstod %f29,%f28\nfcmped %f28,%f30; nop; fbne .L2404; nop\nst %l4,[%sp+64]; ld [%sp+64],%f29; fitos %f29,%f29\nfstod %f29,%f28\nfcmped %f28,%f30; nop; fbne .L2404; nop\nld [%fp+-8],%l3\nset .L596,%l2\nld2 [%l2],%f28\nsrl %l3,1,%l2\nst %l2,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfmuld %f28,%f26,%f28\nset 1,%l2\nand %l3,%l2,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfaddd %f28,%f26,%f28\nfdtos %f28,%f29\nfstod %f29,%f28\nfcmped %f28,%f30; nop; fbne .L2404; nop\nldd [%fp+-16],%f28\nfdtos %f28,%f29\nfstod %f29,%f28\nfcmped %f28,%f30; nop; fbue .L2398; nop\n.L2404:\nadd %i2,32,%i2\n.L2398:\nset .L2355,%l3\nld2 [%l3],%f30\nsll %l6,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfcmped %f28,%f30; nop; fbne .L2411; nop\nsll %l5,8*(4-2),%l3; sra %l3,8*(4-2),%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfcmped %f28,%f30; nop; fbne .L2411; nop\nst %l7,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfcmped %f28,%f30; nop; fbne .L2411; nop\nst %l4,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfcmped %f28,%f30; nop; fbne .L2411; nop\nld [%fp+-8],%l3\nset .L596,%l2\nld2 [%l2],%f28\nsrl %l3,1,%l2\nst %l2,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfmuld %f28,%f26,%f28\nset 1,%l2\nand %l3,%l2,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f26; fitod %f26,%f26\nfaddd %f28,%f26,%f28\nfcmped %f28,%f30; nop; fbne .L2411; nop\nld [%fp+-20],%f29\nfstod %f29,%f28\nfcmped %f28,%f30; nop; fbue .L2405; nop\n.L2411:\nadd %i2,64,%i2\n.L2405:\ncmp %i2,0; be .L2412; nop\nset 16,%l3\nadd %i1,16,%i1\nset .2334,%o0\nmov %l3,%o1\ncall printf; nop\n.L2412:\nmov %i1,%i0\n.L2333:\nret; restore\n.type s72,#function\n.size s72,.-s72\n.section \".data\"\n.type .2415,#object\n.align 1\n.2415:\n.byte 115\n.byte 55\n.byte 53\n.byte 55\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size .2415,11\n.type .2416,#object\n.size .2416,8\n.align 1\n.2416:\n.byte 115\n.byte 55\n.byte 53\n.byte 55\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.global s757\n.section \".text\"\n.align 4\ns757:\nsave %sp,-208,%sp\nset .2416,%l3\nst %l3,[%fp+-76]\nadd %i0,60,%l3\nst %l3,[%fp+-80]\nst %g0,[%fp+-84]\n.L2417:\n.L2418:\nld [%fp+-80],%l3\nadd %l3,1,%l2\nst %l2,[%fp+-80]\nld [%fp+-76],%l2\nadd %l2,1,%l1\nst %l1,[%fp+-76]\nldsb [%l2],%l2\nstb %l2,[%l3]\nsll %l2,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,0; bne .L2417; nop\nset 40,%l3\nst %l3,[%fp+-88]\nld [%fp+-88],%l3\nsll %l3,3,%l2\nsll %l2,2,%l2\ncmp %l2,1280; bne .L2422; nop\nsra %l3,3,%l3\nsra %l3,2,%l3\ncmp %l3,1; be .L2420; nop\n.L2422:\nld [%fp+-84],%l3\nadd %l3,1,%l3\nst %l3,[%fp+-84]\nld [%i0+44],%l3\ncmp %l3,0; be .L2423; nop\nset .2415,%o0\nset 1,%o1\ncall printf; nop\n.L2423:\n.L2420:\nmov %g0,%i1\nmov %g0,%l4\nba .L2428; nop\n.L2425:\nset 1,%l6\nld [%i0+16],%l3\nsub %l3,1,%l3\nsll %l6,%l3,%l5\nst %g0,[%fp+-68]\nld [%fp+-68],%l3\nnot %l3,%l3\nsrl %l3,%l4,%l2\nst %l2,[%fp+-72]\nsll %l3,%l4,%l3\nst %l3,[%fp+-68]\nmov %g0,%l7\nba .L2432; nop\n.L2429:\ncmp %l7,%l4; bge .L2440; nop\nset 1,%l3\nst %l3,[%fp+-96]\nba .L2441; nop\n.L2440:\nst %g0,[%fp+-96]\n.L2441:\nld [%fp+-68],%l3\nand %l6,%l3,%l3\ncmp %l3,%g0; bne .L2442; nop\nset 1,%l3\nst %l3,[%fp+-100]\nba .L2443; nop\n.L2442:\nst %g0,[%fp+-100]\n.L2443:\nld [%fp+-96],%l3\nld [%fp+-100],%l2\ncmp %l3,%l2; bne .L2439; nop\ncmp %l7,%l4; bge .L2444; nop\nset 1,%l3\nst %l3,[%fp+-104]\nba .L2445; nop\n.L2444:\nst %g0,[%fp+-104]\n.L2445:\nld [%fp+-72],%l3\nand %l5,%l3,%l3\ncmp %l3,%g0; bne .L2446; nop\nset 1,%l3\nst %l3,[%fp+-108]\nba .L2447; nop\n.L2446:\nst %g0,[%fp+-108]\n.L2447:\nld [%fp+-104],%l3\nld [%fp+-108],%l2\ncmp %l3,%l2; be .L2433; nop\n.L2439:\nset 1,%i1\n.L2433:\nsll %l6,1,%l6\nsrl %l5,1,%l5\n.L2430:\nadd %l7,1,%l7\n.L2432:\nld [%i0+16],%l3\ncmp %l7,%l3; bl .L2429; nop\n.L2426:\nadd %l4,1,%l4\n.L2428:\nld [%i0+16],%l3\ncmp %l4,%l3; bl .L2425; nop\ncmp %i1,0; be .L2448; nop\nld [%fp+-84],%l3\nadd %l3,2,%l3\nst %l3,[%fp+-84]\nld [%i0+44],%l3\ncmp %l3,0; be .L2450; nop\nset .2415,%o0\nset 2,%o1\ncall printf; nop\n.L2450:\n.L2448:\nset 3,%i2\nset 2,%i3\nset 1,%i4\ncmp %i2,%i3; bge .L2458; nop\nset 1,%l3\nst %l3,[%fp+-100]\nba .L2459; nop\n.L2458:\nst %g0,[%fp+-100]\n.L2459:\nld [%fp+-100],%l3\ncmp %l3,%i4; bge .L2456; nop\nset 1,%l3\nst %l3,[%fp+-96]\nba .L2457; nop\n.L2456:\nst %g0,[%fp+-96]\n.L2457:\nld [%fp+-96],%l3\ncmp %l3,1; be .L2452; nop\nld [%fp+-84],%l3\nadd %l3,4,%l3\nst %l3,[%fp+-84]\nld [%i0+44],%l3\ncmp %l3,0; be .L2460; nop\nset .2415,%o0\nset 4,%o1\ncall printf; nop\n.L2460:\n.L2452:\nadd -60,%fp,%l3\nadd -64,%fp,%l2\ncmp %l3,%l2; bne .L2462; nop\nld [%fp+-84],%l3\nadd %l3,8,%l3\nst %l3,[%fp+-84]\nld [%i0+44],%l3\ncmp %l3,0; be .L2465; nop\nset .2415,%o0\nset 8,%o1\ncall printf; nop\n.L2465:\n.L2462:\nadd -60,%fp,%l3\nadd -64,%fp,%l2\ncmp %l3,%l2; bgeu .L2467; nop\nld [%i0+40],%l3\ncmp %l3,0; be .L2470; nop\nset .L2472,%o0\ncall printf; nop\n.L2470:\n.L2467:\nmov %g0,%i1\nmov %g0,%l7\n.L2473:\nsll %l7,2,%l3\nadd -64,%fp,%l2\nset 1,%l1\nst %l1,[%l3+%l2]\n.L2474:\nadd %l7,1,%l7\ncmp %l7,16; bl .L2473; nop\nst %g0,[%fp+-60]\nst %g0,[%fp+-48]\nst %g0,[%fp+-40]\nst %g0,[%fp+-36]\nst %g0,[%fp+-28]\nst %g0,[%fp+-12]\nmov %g0,%i2\n.L2483:\nmov %g0,%i3\n.L2487:\nmov %g0,%i4\n.L2491:\nmov %g0,%i5\n.L2495:\ncmp %i2,%i3; bge .L2506; nop\nset 1,%l3\nst %l3,[%fp+-108]\nba .L2507; nop\n.L2506:\nst %g0,[%fp+-108]\n.L2507:\ncmp %i4,%i5; bge .L2508; nop\nset 1,%l3\nst %l3,[%fp+-112]\nba .L2509; nop\n.L2508:\nst %g0,[%fp+-112]\n.L2509:\nld [%fp+-108],%l3\nld [%fp+-112],%l2\ncmp %l3,%l2; bne .L2504; nop\nset 1,%l3\nst %l3,[%fp+-104]\nba .L2505; nop\n.L2504:\nst %g0,[%fp+-104]\n.L2505:\nld [%fp+-104],%l3\nsll %i2,3,%l2\nsll %i3,2,%l1\nadd %l2,%l1,%l2\nsll %i4,1,%l1\nadd %l2,%l1,%l2\nadd %l2,%i5,%l2\nsll %l2,2,%l2\nadd -64,%fp,%l1\nld [%l2+%l1],%l2\ncmp %l3,%l2; be .L2499; nop\nset 1,%i1\n.L2499:\n.L2496:\nadd %i5,1,%i5\ncmp %i5,2; bl .L2495; nop\n.L2492:\nadd %i4,1,%i4\ncmp %i4,2; bl .L2491; nop\n.L2488:\nadd %i3,1,%i3\ncmp %i3,2; bl .L2487; nop\n.L2484:\nadd %i2,1,%i2\ncmp %i2,2; bl .L2483; nop\ncmp %i1,0; be .L2510; nop\nld [%fp+-84],%l3\nadd %l3,16,%l3\nst %l3,[%fp+-84]\nld [%i0+44],%l3\ncmp %l3,0; be .L2512; nop\nset .2415,%o0\nset 16,%o1\ncall printf; nop\n.L2512:\n.L2510:\nst %g0,[%fp+-92]\nld [%fp+-92],%l3\ncmp %l3,%g0; be .L2514; nop\nld [%fp+-84],%l3\nadd %l3,32,%l3\nst %l3,[%fp+-84]\nld [%i0+44],%l3\ncmp %l3,0; be .L2516; nop\nset .2415,%o0\nset 32,%o1\ncall printf; nop\n.L2516:\n.L2514:\nld [%fp+-84],%i0\n.L2414:\nret; restore\n.type s757,#function\n.size s757,.-s757\n.section \".data\"\n.type .2519,#object\n.align 1\n.2519:\n.byte 76\n.byte 111\n.byte 99\n.byte 97\n.byte 108\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 37\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.size .2519,17\n.type .2520,#object\n.align 1\n.2520:\n.byte 115\n.byte 55\n.byte 56\n.byte 49\n.byte 51\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size .2520,12\n.type .2521,#object\n.size .2521,8\n.align 1\n.2521:\n.byte 115\n.byte 55\n.byte 56\n.byte 49\n.byte 51\n.byte 32\n.byte 32\n.byte 0\n.global s7813\n.section \".text\"\n.align 4\ns7813:\nsave %sp,-144,%sp\nset .2521,%l7\nadd %i0,60,%l6\nmov %g0,%i4\nmov %g0,%l5\nld [%i0+48],%i5\n.L2522:\n.L2523:\nmov %l6,%l3\nadd %l3,1,%l6\nmov %l7,%l2\nadd %l2,1,%l7\nldsb [%l2],%l2\nstb %l2,[%l3]\nsll %l2,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,0; bne .L2522; nop\nba .L2525; nop\nset 1,%i4\ncmp %i5,0; be .L2527; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2527:\n.L2525:\nba .L2529; nop\nset 2,%i4\ncmp %i5,0; be .L2531; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2531:\n.L2529:\nba .L2533; nop\nset 3,%i4\ncmp %i5,0; be .L2535; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2535:\n.L2533:\nba .L2537; nop\nset 4,%i4\ncmp %i5,0; be .L2539; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2539:\n.L2537:\nba .L2541; nop\nset 5,%i4\ncmp %i5,0; be .L2543; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2543:\n.L2541:\nba .L2545; nop\nset 6,%i4\ncmp %i5,0; be .L2547; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2547:\n.L2545:\nba .L2549; nop\nset 7,%i4\ncmp %i5,0; be .L2551; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2551:\n.L2549:\nba .L2553; nop\nset 8,%i4\ncmp %i5,0; be .L2555; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2555:\n.L2553:\nba .L2557; nop\nset 9,%i4\ncmp %i5,0; be .L2559; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2559:\n.L2557:\nba .L2561; nop\nset 10,%i4\ncmp %i5,0; be .L2563; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2563:\n.L2561:\nba .L2565; nop\nset 11,%i4\ncmp %i5,0; be .L2567; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2567:\n.L2565:\nba .L2569; nop\nset 12,%i4\ncmp %i5,0; be .L2571; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2571:\n.L2569:\nba .L2573; nop\nset 13,%i4\ncmp %i5,0; be .L2575; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2575:\n.L2573:\nba .L2577; nop\nset 14,%i4\ncmp %i5,0; be .L2579; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2579:\n.L2577:\nba .L2581; nop\nset 15,%i4\ncmp %i5,0; be .L2583; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2583:\n.L2581:\nba .L2585; nop\nset 16,%i4\ncmp %i5,0; be .L2587; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2587:\n.L2585:\nba .L2589; nop\nset 17,%i4\ncmp %i5,0; be .L2591; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2591:\n.L2589:\nba .L2593; nop\nset 18,%i4\ncmp %i5,0; be .L2595; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2595:\n.L2593:\nba .L2597; nop\nset 16,%i4\ncmp %i5,0; be .L2599; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2599:\n.L2597:\nba .L2601; nop\nset 20,%i4\ncmp %i5,0; be .L2603; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2603:\n.L2601:\nba .L2605; nop\nset 21,%i4\ncmp %i5,0; be .L2607; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2607:\n.L2605:\nba .L2609; nop\nset 22,%i4\ncmp %i5,0; be .L2611; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2611:\n.L2609:\nba .L2613; nop\nset 23,%i4\ncmp %i5,0; be .L2615; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2615:\n.L2613:\nba .L2617; nop\nset 24,%i4\ncmp %i5,0; be .L2619; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2619:\n.L2617:\nba .L2621; nop\nset 25,%i4\ncmp %i5,0; be .L2623; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2623:\n.L2621:\nba .L2625; nop\nset 26,%i4\ncmp %i5,0; be .L2627; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2627:\n.L2625:\nba .L2629; nop\nset 27,%i4\ncmp %i5,0; be .L2631; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2631:\n.L2629:\nba .L2633; nop\nset 28,%i4\ncmp %i5,0; be .L2635; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2635:\n.L2633:\nba .L2637; nop\nset 26,%i4\ncmp %i5,0; be .L2639; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2639:\n.L2637:\nba .L2641; nop\nset 30,%i4\ncmp %i5,0; be .L2643; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2643:\n.L2641:\nba .L2645; nop\nset 31,%i4\ncmp %i5,0; be .L2647; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2647:\n.L2645:\nba .L2649; nop\nset 32,%i4\ncmp %i5,0; be .L2651; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2651:\n.L2649:\nba .L2653; nop\nset 33,%i4\ncmp %i5,0; be .L2655; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2655:\n.L2653:\nba .L2657; nop\nset 34,%i4\ncmp %i5,0; be .L2659; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2659:\n.L2657:\nba .L2661; nop\nset 35,%i4\ncmp %i5,0; be .L2663; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2663:\n.L2661:\nba .L2665; nop\nset 36,%i4\ncmp %i5,0; be .L2667; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2667:\n.L2665:\nba .L2669; nop\nset 37,%i4\ncmp %i5,0; be .L2671; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2671:\n.L2669:\nba .L2673; nop\nset 38,%i4\ncmp %i5,0; be .L2675; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2675:\n.L2673:\nba .L2677; nop\nset 39,%i4\ncmp %i5,0; be .L2679; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2679:\n.L2677:\nba .L2681; nop\nset 40,%i4\ncmp %i5,0; be .L2683; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2683:\n.L2681:\nba .L2685; nop\nset 41,%i4\ncmp %i5,0; be .L2687; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2687:\n.L2685:\nba .L2689; nop\nset 42,%i4\ncmp %i5,0; be .L2691; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2691:\n.L2689:\nba .L2693; nop\nset 43,%i4\ncmp %i5,0; be .L2695; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2695:\n.L2693:\nba .L2697; nop\nset 44,%i4\ncmp %i5,0; be .L2699; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2699:\n.L2697:\nba .L2701; nop\nset 45,%i4\ncmp %i5,0; be .L2703; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2703:\n.L2701:\nba .L2705; nop\nset 46,%i4\ncmp %i5,0; be .L2707; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2707:\n.L2705:\nba .L2709; nop\nset 47,%i4\ncmp %i5,0; be .L2711; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2711:\n.L2709:\nba .L2713; nop\nset 48,%i4\ncmp %i5,0; be .L2715; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2715:\n.L2713:\nba .L2717; nop\nset 49,%i4\ncmp %i5,0; be .L2719; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2719:\n.L2717:\nba .L2721; nop\nset 50,%i4\ncmp %i5,0; be .L2723; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2723:\n.L2721:\nba .L2725; nop\nset 51,%i4\ncmp %i5,0; be .L2727; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2727:\n.L2725:\nba .L2729; nop\nset 52,%i4\ncmp %i5,0; be .L2731; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2731:\n.L2729:\nba .L2733; nop\nset 53,%i4\ncmp %i5,0; be .L2735; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2735:\n.L2733:\nba .L2737; nop\nset 54,%i4\ncmp %i5,0; be .L2739; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2739:\n.L2737:\nba .L2741; nop\nset 55,%i4\ncmp %i5,0; be .L2743; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2743:\n.L2741:\nba .L2745; nop\nset 56,%i4\ncmp %i5,0; be .L2747; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2747:\n.L2745:\nba .L2749; nop\nset 57,%i4\ncmp %i5,0; be .L2751; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2751:\n.L2749:\nba .L2753; nop\nset 58,%i4\ncmp %i5,0; be .L2755; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2755:\n.L2753:\nba .L2757; nop\nset 56,%i4\ncmp %i5,0; be .L2759; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2759:\n.L2757:\nba .L2761; nop\nset 60,%i4\ncmp %i5,0; be .L2763; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2763:\n.L2761:\nba .L2765; nop\nset 61,%i4\ncmp %i5,0; be .L2767; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2767:\n.L2765:\nba .L2769; nop\nset 62,%i4\ncmp %i5,0; be .L2771; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2771:\n.L2769:\nba .L2773; nop\nset 63,%i4\ncmp %i5,0; be .L2775; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2775:\n.L2773:\nba .L2777; nop\nset 64,%i4\ncmp %i5,0; be .L2779; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2779:\n.L2777:\nba .L2781; nop\nset 65,%i4\ncmp %i5,0; be .L2783; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2783:\n.L2781:\nba .L2785; nop\nset 66,%i4\ncmp %i5,0; be .L2787; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2787:\n.L2785:\nba .L2789; nop\nset 67,%i4\ncmp %i5,0; be .L2791; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2791:\n.L2789:\nba .L2793; nop\nset 68,%i4\ncmp %i5,0; be .L2795; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2795:\n.L2793:\nba .L2797; nop\nset 69,%i4\ncmp %i5,0; be .L2799; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2799:\n.L2797:\nba .L2801; nop\nset 70,%i4\ncmp %i5,0; be .L2803; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2803:\n.L2801:\nba .L2805; nop\nset 71,%i4\ncmp %i5,0; be .L2807; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2807:\n.L2805:\nba .L2809; nop\nset 72,%i4\ncmp %i5,0; be .L2811; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2811:\n.L2809:\nba .L2813; nop\nset 73,%i4\ncmp %i5,0; be .L2815; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2815:\n.L2813:\nba .L2817; nop\nset 74,%i4\ncmp %i5,0; be .L2819; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2819:\n.L2817:\nba .L2821; nop\nset 75,%i4\ncmp %i5,0; be .L2823; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2823:\n.L2821:\ncmp %i4,0; be .L2825; nop\nld [%i0+44],%l3\ncmp %l3,0; be .L2827; nop\nset .2520,%o0\nset 1,%o1\ncall printf; nop\n.L2827:\nadd %l5,1,%l5\n.L2825:\nmov %g0,%i4\nmov %g0,%i2\nmov %g0,%i3\nmov %i3,%l3\nadd %l3,1,%i3\nmov %g0,%l2\ncmp %l3,%l2; be .L2830; nop\nmov %i2,%l3\nadd %l3,1,%i2\ncmp %l3,%l2; be .L2830; nop\nset 1,%l3\nst %l3,[%fp+-8]\nba .L2831; nop\n.L2830:\nst %g0,[%fp+-8]\n.L2831:\nld [%fp+-8],%i1\ncmp %i3,1; be .L2832; nop\nset 1,%i4\ncmp %i5,0; be .L2834; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2834:\n.L2832:\ncmp %i2,0; be .L2836; nop\nset 2,%i4\ncmp %i5,0; be .L2838; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2838:\n.L2836:\ncmp %i1,0; be .L2840; nop\nset 3,%i4\ncmp %i5,0; be .L2842; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2842:\n.L2840:\ncmp %i3,%g0; be .L2845; nop\nmov %i2,%l2\nadd %l2,1,%i2\ncmp %l2,%g0; be .L2845; nop\nset 1,%l3\nst %l3,[%fp+-12]\nba .L2846; nop\n.L2845:\nst %g0,[%fp+-12]\n.L2846:\nld [%fp+-12],%i1\ncmp %i3,1; be .L2847; nop\nset 4,%i4\ncmp %i5,0; be .L2849; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2849:\n.L2847:\ncmp %i2,1; be .L2851; nop\nset 5,%i4\ncmp %i5,0; be .L2853; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2853:\n.L2851:\ncmp %i1,0; be .L2855; nop\nset 6,%i4\ncmp %i5,0; be .L2857; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2857:\n.L2855:\nmov %i3,%l3\nsub %l3,1,%i3\nmov %g0,%l2\ncmp %l3,%l2; be .L2860; nop\ncmp %i2,%l2; be .L2860; nop\nset 1,%l3\nst %l3,[%fp+-16]\nba .L2861; nop\n.L2860:\nst %g0,[%fp+-16]\n.L2861:\nld [%fp+-16],%i1\ncmp %i3,0; be .L2862; nop\nset 7,%i4\ncmp %i5,0; be .L2864; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2864:\n.L2862:\ncmp %i2,1; be .L2866; nop\nset 8,%i4\ncmp %i5,0; be .L2868; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2868:\n.L2866:\ncmp %i1,1; be .L2870; nop\nset 9,%i4\ncmp %i5,0; be .L2872; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2872:\n.L2870:\ncmp %i3,%g0; be .L2875; nop\nmov %i2,%l2\nsub %l2,1,%i2\ncmp %l2,%g0; be .L2875; nop\nset 1,%l3\nst %l3,[%fp+-20]\nba .L2876; nop\n.L2875:\nst %g0,[%fp+-20]\n.L2876:\nld [%fp+-20],%i1\ncmp %i3,0; be .L2877; nop\nset 10,%i4\ncmp %i5,0; be .L2879; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2879:\n.L2877:\ncmp %i2,1; be .L2881; nop\nset 11,%i4\ncmp %i5,0; be .L2883; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2883:\n.L2881:\ncmp %i1,0; be .L2885; nop\nset 12,%i4\ncmp %i5,0; be .L2887; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2887:\n.L2885:\ncmp %i4,0; be .L2889; nop\nld [%i0+44],%l3\ncmp %l3,0; be .L2891; nop\nset .2520,%o0\nset 2,%o1\ncall printf; nop\n.L2891:\nadd %l5,2,%l5\n.L2889:\nmov %g0,%i4\nmov %g0,%i2\nmov %g0,%i3\nmov %i3,%l3\nadd %l3,1,%i3\nmov %g0,%l2\ncmp %l3,%l2; bne .L2896; nop\ncmp %i2,%l2; be .L2894; nop\n.L2896:\nset 1,%l3\nst %l3,[%fp+-24]\nba .L2895; nop\n.L2894:\nst %g0,[%fp+-24]\n.L2895:\nld [%fp+-24],%i1\ncmp %i3,1; be .L2897; nop\nset 1,%i4\ncmp %i5,0; be .L2899; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2899:\n.L2897:\ncmp %i2,0; be .L2901; nop\nset 2,%i4\ncmp %i5,0; be .L2903; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2903:\n.L2901:\ncmp %i1,0; be .L2905; nop\nset 3,%i4\ncmp %i5,0; be .L2907; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2907:\n.L2905:\nmov %i2,%l3\nadd %l3,1,%i2\nmov %g0,%l2\ncmp %l3,%l2; bne .L2912; nop\ncmp %i3,%l2; be .L2910; nop\n.L2912:\nset 1,%l3\nst %l3,[%fp+-28]\nba .L2911; nop\n.L2910:\nst %g0,[%fp+-28]\n.L2911:\nld [%fp+-28],%i1\ncmp %i3,1; be .L2913; nop\nset 4,%i4\ncmp %i5,0; be .L2915; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2915:\n.L2913:\ncmp %i2,1; be .L2917; nop\nset 5,%i4\ncmp %i5,0; be .L2919; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2919:\n.L2917:\ncmp %i1,1; be .L2921; nop\nset 6,%i4\ncmp %i5,0; be .L2923; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2923:\n.L2921:\nmov %i3,%l3\nsub %l3,1,%i3\nmov %g0,%l2\ncmp %l3,%l2; bne .L2928; nop\nmov %i2,%l3\nsub %l3,1,%i2\ncmp %l3,%l2; be .L2926; nop\n.L2928:\nset 1,%l3\nst %l3,[%fp+-32]\nba .L2927; nop\n.L2926:\nst %g0,[%fp+-32]\n.L2927:\nld [%fp+-32],%i1\ncmp %i3,0; be .L2929; nop\nset 7,%i4\ncmp %i5,0; be .L2931; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2931:\n.L2929:\ncmp %i2,1; be .L2933; nop\nset 8,%i4\ncmp %i5,0; be .L2935; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2935:\n.L2933:\ncmp %i1,1; be .L2937; nop\nset 9,%i4\ncmp %i5,0; be .L2939; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2939:\n.L2937:\nmov %g0,%l3\ncmp %i3,%l3; bne .L2944; nop\nmov %i2,%l2\nsub %l2,1,%i2\ncmp %l2,%l3; be .L2942; nop\n.L2944:\nset 1,%l3\nst %l3,[%fp+-36]\nba .L2943; nop\n.L2942:\nst %g0,[%fp+-36]\n.L2943:\nld [%fp+-36],%i1\ncmp %i3,0; be .L2945; nop\nset 10,%i4\ncmp %i5,0; be .L2947; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2947:\n.L2945:\ncmp %i2,0; be .L2949; nop\nset 11,%i4\ncmp %i5,0; be .L2951; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2951:\n.L2949:\ncmp %i1,1; be .L2953; nop\nset 12,%i4\ncmp %i5,0; be .L2955; nop\nset .2519,%o0\nmov %i4,%o1\ncall printf; nop\n.L2955:\n.L2953:\ncmp %i4,0; be .L2957; nop\nld [%i0+44],%l3\ncmp %l3,0; be .L2959; nop\nset .2520,%o0\nset 4,%o1\ncall printf; nop\n.L2959:\nadd %l5,4,%l5\n.L2957:\nmov %g0,%l3\nmov %l3,%i2\nmov %l3,%i3\nmov %l3,%l4\nset 1,%l2\nst %l2,[%fp+-4]\nld [%fp+-4],%l2\ncmp %l2,%l3; be .L2963; nop\nst %l4,[%fp+-40]\nba .L2964; nop\n.L2963:\nld [%fp+-4],%l3\ncmp %l3,0; be .L2965; nop\nmov %i3,%l3\nadd %l3,1,%i3\nst %l3,[%fp+-44]\nba .L2966; nop\n.L2965:\nmov %i2,%l3\nadd %l3,1,%i2\nst %l3,[%fp+-44]\n.L2966:\nld [%fp+-44],%l3\nst %l3,[%fp+-40]\n.L2964:\nld [%fp+-40],%i1\ncmp %i1,%g0; bne .L2970; nop\ncmp %i3,%g0; bne .L2970; nop\ncmp %i2,%g0; be .L2967; nop\n.L2970:\nld [%i0+44],%l3\ncmp %l3,0; be .L2971; nop\nset .2520,%o0\nset 8,%o1\ncall printf; nop\n.L2971:\nadd %l5,8,%l5\n.L2967:\nld [%fp+-4],%l3\ncmp %l3,0; be .L2978; nop\nst %l4,[%fp+-48]\nba .L2979; nop\n.L2978:\nset 1,%l3\nst %l3,[%fp+-48]\n.L2979:\nld [%fp+-48],%l2\ncmp %l2,%g0; bne .L2977; nop\ncmp %l4,%g0; be .L2980; nop\nset 1,%l3\nst %l3,[%fp+-52]\nba .L2981; nop\n.L2980:\nst %l4,[%fp+-52]\n.L2981:\nld [%fp+-52],%l3\ncmp %l3,0; be .L2973; nop\n.L2977:\nld [%i0+44],%l3\ncmp %l3,0; be .L2982; nop\nset .2520,%o0\nset 16,%o1\ncall printf; nop\n.L2982:\nadd %l5,16,%l5\n.L2973:\nmov %l5,%i0\n.L2518:\nret; restore\n.type s7813,#function\n.size s7813,.-s7813\n.section \".data\"\n.type .2985,#object\n.align 1\n.2985:\n.byte 115\n.byte 56\n.byte 49\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size .2985,10\n.type .2986,#object\n.size .2986,8\n.align 1\n.2986:\n.byte 115\n.byte 56\n.byte 49\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.type .2987,#object\n.align 1\n.2987:\n.byte 82\n.byte 101\n.byte 103\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 117\n.byte 110\n.byte 116\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 37\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 117\n.byte 110\n.byte 114\n.byte 101\n.byte 108\n.byte 105\n.byte 97\n.byte 98\n.byte 108\n.byte 101\n.byte 46\n.byte 10\n.byte 0\n.size .2987,38\n.type .2988,#object\n.align 1\n.2988:\n.byte 37\n.byte 100\n.byte 32\n.byte 114\n.byte 101\n.byte 103\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 97\n.byte 115\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 37\n.byte 115\n.byte 32\n.byte 118\n.byte 97\n.byte 114\n.byte 105\n.byte 97\n.byte 98\n.byte 108\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.size .2988,40\n.global s81\n.section \".text\"\n.align 4\ns81:\nsave %sp,-112,%sp\nst %g0,[%fp+-20]\nst %g0,[%fp+-8]\nst %g0,[%fp+-12]\nst %g0,[%fp+-16]\nset .2986,%l5\nadd %i0,60,%l4\n.L2989:\n.L2990:\nmov %l4,%l3\nadd %l3,1,%l4\nmov %l5,%l2\nadd %l2,1,%l5\nldsb [%l2],%l2\nstb %l2,[%l3]\nsll %l2,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,0; bne .L2989; nop\nset 1,%l3\nst %l3,[%fp+-4]\nmov %g0,%i2\n.L2992:\nld [%fp+-4],%l3\nmov %l3,%l2\nmov %l2,%i5\nmov %l2,%i1\nadd -4,%fp,%i4\nadd -4,%fp,%l7\nmov %l3,%i3\nmov %l3,%l6\nsll %i5,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nsll %i1,8*(4-1),%l2; sra %l2,8*(4-1),%l2\ncmp %l3,%l2; be .L2996; nop\nset 1,%l3\nst %l3,[%fp+-8]\n.L2996:\nmov %i4,%l3\nmov %l7,%l2\ncmp %l3,%l2; be .L2998; nop\nset 1,%l3\nst %l3,[%fp+-12]\n.L2998:\ncmp %i3,%l6; be .L3000; nop\nset 1,%l3\nst %l3,[%fp+-16]\n.L3000:\nld [%fp+-4],%l3\nsll %l3,1,%l3\nst %l3,[%fp+-4]\n.L2993:\nadd %i2,1,%i2\ncmp %i2,50; bl .L2992; nop\nld [%fp+-8],%l3\ncmp %l3,0; be .L3002; nop\nld [%fp+-20],%l3\nadd %l3,1,%l3\nst %l3,[%fp+-20]\nld [%i0+44],%l3\ncmp %l3,0; be .L3004; nop\nset .2985,%o0\nset 1,%o1\ncall printf; nop\n.L3004:\n.L3002:\nld [%fp+-12],%l3\ncmp %l3,0; be .L3006; nop\nld [%fp+-20],%l3\nadd %l3,2,%l3\nst %l3,[%fp+-20]\nld [%i0+44],%l3\ncmp %l3,0; be .L3008; nop\nset .2985,%o0\nset 2,%o1\ncall printf; nop\n.L3008:\n.L3006:\nld [%fp+-16],%l3\ncmp %l3,0; be .L3010; nop\nld [%fp+-20],%l3\nadd %l3,4,%l3\nst %l3,[%fp+-20]\nld [%i0+44],%l3\ncmp %l3,0; be .L3012; nop\nset .2985,%o0\nset 4,%o1\ncall printf; nop\n.L3012:\n.L3010:\ncall regc; nop\nst %o0,[%fp+-4]\nld [%i0+40],%l3\ncmp %l3,0; be .L3014; nop\nld [%fp+-4],%l3\ncmp %l3,0; bge .L3016; nop\nset .2987,%o0\nset .L425,%o1\ncall printf; nop\nba .L3017; nop\n.L3016:\nset .2988,%o0\nld [%fp+-4],%o1\nset .L425,%o2\ncall printf; nop\n.L3017:\n.L3014:\ncall regp; nop\nst %o0,[%fp+-4]\nld [%i0+40],%l3\ncmp %l3,0; be .L3018; nop\nld [%fp+-4],%l3\ncmp %l3,0; bge .L3020; nop\nset .2987,%o0\nset .L3022,%o1\ncall printf; nop\nba .L3021; nop\n.L3020:\nset .2988,%o0\nld [%fp+-4],%o1\nset .L3022,%o2\ncall printf; nop\n.L3021:\n.L3018:\ncall regi; nop\nst %o0,[%fp+-4]\nld [%i0+40],%l3\ncmp %l3,0; be .L3023; nop\nld [%fp+-4],%l3\ncmp %l3,0; bge .L3025; nop\nset .2987,%o0\nset .L426,%o1\ncall printf; nop\nba .L3026; nop\n.L3025:\nset .2988,%o0\nld [%fp+-4],%o1\nset .L426,%o2\ncall printf; nop\n.L3026:\n.L3023:\nld [%fp+-20],%i0\n.L2984:\nret; restore\n.type s81,#function\n.size s81,.-s81\n.global regc\n.align 4\nregc:\nsave %sp,-232,%sp\nstb %g0,[%fp+-130]\nset 1,%l3\nstb %l3,[%fp+-109]\nset 2,%l3\nstb %l3,[%fp+-110]\nset 3,%l3\nstb %l3,[%fp+-111]\nset 4,%i5\nset 5,%l3\nstb %l3,[%fp+-112]\nset 6,%i4\nset 7,%l3\nstb %l3,[%fp+-113]\nset 8,%i3\nset 9,%l3\nstb %l3,[%fp+-114]\nset 10,%i2\nset 11,%l3\nstb %l3,[%fp+-115]\nset 12,%i1\nset 13,%l3\nstb %l3,[%fp+-116]\nset 14,%i0\nset 15,%l3\nstb %l3,[%fp+-117]\nset 16,%l7\nset 17,%l3\nstb %l3,[%fp+-118]\nset 18,%l6\nset 19,%l3\nstb %l3,[%fp+-119]\nset 20,%l5\nset 21,%l3\nstb %l3,[%fp+-120]\nset 22,%l4\nset 23,%l3\nstb %l3,[%fp+-121]\nset 24,%l3\nstb %l3,[%fp+-1]\nset 25,%l3\nstb %l3,[%fp+-122]\nset 26,%l3\nstb %l3,[%fp+-2]\nset 27,%l3\nstb %l3,[%fp+-123]\nset 28,%l3\nstb %l3,[%fp+-3]\nset 29,%l3\nstb %l3,[%fp+-124]\nset 30,%l3\nstb %l3,[%fp+-4]\nset 31,%l3\nstb %l3,[%fp+-125]\nset 32,%l3\nstb %l3,[%fp+-5]\nset 33,%l3\nstb %l3,[%fp+-126]\nset 34,%l3\nstb %l3,[%fp+-6]\nset 35,%l3\nstb %l3,[%fp+-127]\nset 36,%l3\nstb %l3,[%fp+-128]\nset 37,%l3\nstb %l3,[%fp+-129]\nset 38,%l3\nstb %l3,[%fp+-131]\nadd -109,%fp,%l3\nadd -130,%fp,%l2\nsub %l3,%l2,%l2\nst %l2,[%fp+-96]\nadd -110,%fp,%l2\nsub %l2,%l3,%l3\nst %l3,[%fp+-92]\nadd -111,%fp,%l3\nadd -110,%fp,%l2\nsub %l3,%l2,%l3\nst %l3,[%fp+-88]\nadd -112,%fp,%l3\nadd -111,%fp,%l2\nsub %l3,%l2,%l3\nst %l3,[%fp+-84]\nadd -113,%fp,%l3\nadd -112,%fp,%l2\nsub %l3,%l2,%l3\nst %l3,[%fp+-80]\nadd -114,%fp,%l3\nadd -113,%fp,%l2\nsub %l3,%l2,%l3\nst %l3,[%fp+-76]\nadd -115,%fp,%l3\nadd -114,%fp,%l2\nsub %l3,%l2,%l3\nst %l3,[%fp+-72]\nadd -116,%fp,%l3\nadd -115,%fp,%l2\nsub %l3,%l2,%l3\nst %l3,[%fp+-68]\nadd -117,%fp,%l3\nadd -116,%fp,%l2\nsub %l3,%l2,%l3\nst %l3,[%fp+-64]\nadd -118,%fp,%l3\nadd -117,%fp,%l2\nsub %l3,%l2,%l3\nst %l3,[%fp+-60]\nadd -119,%fp,%l3\nadd -118,%fp,%l2\nsub %l3,%l2,%l3\nst %l3,[%fp+-56]\nadd -120,%fp,%l3\nadd -119,%fp,%l2\nsub %l3,%l2,%l3\nst %l3,[%fp+-52]\nadd -121,%fp,%l3\nadd -120,%fp,%l2\nsub %l3,%l2,%l3\nst %l3,[%fp+-48]\nadd -122,%fp,%l3\nadd -121,%fp,%l2\nsub %l3,%l2,%l3\nst %l3,[%fp+-44]\nadd -123,%fp,%l3\nadd -122,%fp,%l2\nsub %l3,%l2,%l3\nst %l3,[%fp+-40]\nadd -124,%fp,%l3\nadd -123,%fp,%l2\nsub %l3,%l2,%l3\nst %l3,[%fp+-36]\nadd -125,%fp,%l3\nadd -124,%fp,%l2\nsub %l3,%l2,%l3\nst %l3,[%fp+-32]\nadd -126,%fp,%l3\nadd -125,%fp,%l2\nsub %l3,%l2,%l3\nst %l3,[%fp+-28]\nadd -127,%fp,%l3\nadd -126,%fp,%l2\nsub %l3,%l2,%l3\nst %l3,[%fp+-24]\nadd -128,%fp,%l3\nadd -127,%fp,%l2\nsub %l3,%l2,%l3\nst %l3,[%fp+-20]\nadd -129,%fp,%l3\nadd -128,%fp,%l2\nsub %l3,%l2,%l3\nst %l3,[%fp+-16]\nadd -131,%fp,%l3\nadd -129,%fp,%l2\nsub %l3,%l2,%l3\nst %l3,[%fp+-12]\nld [%fp+-96],%l3\nst %l3,[%fp+-108]\nset 1,%l3\nst %l3,[%fp+-104]\nst %g0,[%fp+-100]\n.L3049:\nld [%fp+-104],%l3\ncmp %l3,1; be .L3055; nop\ncmp %l3,2; be .L3058; nop\ncmp %l3,3; be .L3063; nop\nba .L3053; nop\n.L3055:\nld [%fp+-100],%l3\nsll %l3,2,%l3\nadd -96,%fp,%l2\nld [%l3+%l2],%l3\nld [%fp+-108],%l2\ncmp %l3,%l2; be .L3054; nop\nset 2,%l3\nld [%fp+-100],%l2\nsll %l2,2,%l2\nadd -96,%fp,%l1\nld [%l2+%l1],%l2\nst %l2,[%fp+-140]\nst %l3,[%fp+-104]\nset 1,%l3\nst %l3,[%fp+-136]\nba .L3054; nop\n.L3058:\nld [%fp+-100],%l3\nsll %l3,2,%l3\nadd -96,%fp,%l2\nld [%l3+%l2],%l3\nld [%fp+-108],%l2\ncmp %l3,%l2; bne .L3059; nop\nset 3,%l3\nst %l3,[%fp+-104]\nba .L3054; nop\n.L3059:\nld [%fp+-100],%l3\nsll %l3,2,%l3\nadd -96,%fp,%l2\nld [%l3+%l2],%l3\nld [%fp+-140],%l2\ncmp %l3,%l2; bne .L3061; nop\nld [%fp+-136],%l3\nadd %l3,1,%l3\nst %l3,[%fp+-136]\nba .L3054; nop\n.L3061:\nset 4,%l3\nst %l3,[%fp+-104]\nba .L3054; nop\n.L3063:\nld [%fp+-100],%l3\nsll %l3,2,%l3\nadd -96,%fp,%l2\nld [%l3+%l2],%l3\nld [%fp+-108],%l2\ncmp %l3,%l2; be .L3054; nop\nset 4,%l3\nst %l3,[%fp+-104]\n.L3053:\n.L3054:\n.L3050:\nld [%fp+-100],%l3\nadd %l3,1,%l3\nst %l3,[%fp+-100]\nld [%fp+-100],%l3\ncmp %l3,22; bl .L3049; nop\nld [%fp+-104],%l3\ncmp %l3,3; bne .L3066; nop\nset 16,%l3\nld [%fp+-136],%l2\nsub %l3,%l2,%i0\nba .L3027; nop\n.L3066:\nset -1,%i0\n.L3027:\nret; restore\n.type regc,#function\n.size regc,.-regc\n.global regi\n.align 4\nregi:\nsave %sp,-320,%sp\nst %g0,[%fp+-212]\nset 1,%l3\nst %l3,[%fp+-128]\nset 2,%l3\nst %l3,[%fp+-132]\nset 3,%l3\nst %l3,[%fp+-136]\nset 4,%i5\nset 5,%l3\nst %l3,[%fp+-140]\nset 6,%i4\nset 7,%l3\nst %l3,[%fp+-144]\nset 8,%i3\nset 9,%l3\nst %l3,[%fp+-148]\nset 10,%i2\nset 11,%l3\nst %l3,[%fp+-152]\nset 12,%i1\nset 13,%l3\nst %l3,[%fp+-156]\nset 14,%i0\nset 15,%l3\nst %l3,[%fp+-160]\nset 16,%l7\nset 17,%l3\nst %l3,[%fp+-164]\nset 18,%l6\nset 19,%l3\nst %l3,[%fp+-168]\nset 20,%l5\nset 21,%l3\nst %l3,[%fp+-172]\nset 22,%l4\nset 23,%l3\nst %l3,[%fp+-176]\nset 24,%l3\nst %l3,[%fp+-4]\nset 25,%l3\nst %l3,[%fp+-180]\nset 26,%l3\nst %l3,[%fp+-8]\nset 27,%l3\nst %l3,[%fp+-184]\nset 28,%l3\nst %l3,[%fp+-12]\nset 29,%l3\nst %l3,[%fp+-188]\nset 30,%l3\nst %l3,[%fp+-16]\nset 31,%l3\nst %l3,[%fp+-192]\nset 32,%l3\nst %l3,[%fp+-20]\nset 33,%l3\nst %l3,[%fp+-196]\nset 34,%l3\nst %l3,[%fp+-24]\nset 35,%l3\nst %l3,[%fp+-200]\nset 36,%l3\nst %l3,[%fp+-204]\nset 37,%l3\nst %l3,[%fp+-208]\nset 38,%l3\nst %l3,[%fp+-216]\nadd -128,%fp,%l3\nadd -212,%fp,%l2\nsub %l3,%l2,%l2\nsra %l2,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l2,4,%l2\nst %l2,[%fp+-112]\nadd -132,%fp,%l2\nsub %l2,%l3,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-108]\nadd -136,%fp,%l3\nadd -132,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-104]\nadd -140,%fp,%l3\nadd -136,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-100]\nadd -144,%fp,%l3\nadd -140,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-96]\nadd -148,%fp,%l3\nadd -144,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-92]\nadd -152,%fp,%l3\nadd -148,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-88]\nadd -156,%fp,%l3\nadd -152,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-84]\nadd -160,%fp,%l3\nadd -156,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-80]\nadd -164,%fp,%l3\nadd -160,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-76]\nadd -168,%fp,%l3\nadd -164,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-72]\nadd -172,%fp,%l3\nadd -168,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-68]\nadd -176,%fp,%l3\nadd -172,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-64]\nadd -180,%fp,%l3\nadd -176,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-60]\nadd -184,%fp,%l3\nadd -180,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-56]\nadd -188,%fp,%l3\nadd -184,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-52]\nadd -192,%fp,%l3\nadd -188,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-48]\nadd -196,%fp,%l3\nadd -192,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-44]\nadd -200,%fp,%l3\nadd -196,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-40]\nadd -204,%fp,%l3\nadd -200,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-36]\nadd -208,%fp,%l3\nadd -204,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-32]\nadd -216,%fp,%l3\nadd -208,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-28]\nld [%fp+-112],%l3\nst %l3,[%fp+-124]\nset 1,%l3\nst %l3,[%fp+-120]\nst %g0,[%fp+-116]\n.L3090:\nld [%fp+-120],%l3\ncmp %l3,1; be .L3096; nop\ncmp %l3,2; be .L3099; nop\ncmp %l3,3; be .L3104; nop\nba .L3094; nop\n.L3096:\nld [%fp+-116],%l3\nsll %l3,2,%l3\nadd -112,%fp,%l2\nld [%l3+%l2],%l3\nld [%fp+-124],%l2\ncmp %l3,%l2; be .L3095; nop\nset 2,%l3\nld [%fp+-116],%l2\nsll %l2,2,%l2\nadd -112,%fp,%l1\nld [%l2+%l1],%l2\nst %l2,[%fp+-224]\nst %l3,[%fp+-120]\nset 1,%l3\nst %l3,[%fp+-220]\nba .L3095; nop\n.L3099:\nld [%fp+-116],%l3\nsll %l3,2,%l3\nadd -112,%fp,%l2\nld [%l3+%l2],%l3\nld [%fp+-124],%l2\ncmp %l3,%l2; bne .L3100; nop\nset 3,%l3\nst %l3,[%fp+-120]\nba .L3095; nop\n.L3100:\nld [%fp+-116],%l3\nsll %l3,2,%l3\nadd -112,%fp,%l2\nld [%l3+%l2],%l3\nld [%fp+-224],%l2\ncmp %l3,%l2; bne .L3102; nop\nld [%fp+-220],%l3\nadd %l3,1,%l3\nst %l3,[%fp+-220]\nba .L3095; nop\n.L3102:\nset 4,%l3\nst %l3,[%fp+-120]\nba .L3095; nop\n.L3104:\nld [%fp+-116],%l3\nsll %l3,2,%l3\nadd -112,%fp,%l2\nld [%l3+%l2],%l3\nld [%fp+-124],%l2\ncmp %l3,%l2; be .L3095; nop\nset 4,%l3\nst %l3,[%fp+-120]\n.L3094:\n.L3095:\n.L3091:\nld [%fp+-116],%l3\nadd %l3,1,%l3\nst %l3,[%fp+-116]\nld [%fp+-116],%l3\ncmp %l3,22; bl .L3090; nop\nld [%fp+-120],%l3\ncmp %l3,3; bne .L3107; nop\nset 16,%l3\nld [%fp+-220],%l2\nsub %l3,%l2,%i0\nba .L3068; nop\n.L3107:\nset -1,%i0\n.L3068:\nret; restore\n.type regi,#function\n.size regi,.-regi\n.global regp\n.align 4\nregp:\nsave %sp,-320,%sp\nadd -212,%fp,%l3\nst %l3,[%fp+-212]\nadd -188,%fp,%l3\nst %l3,[%fp+-188]\nadd -192,%fp,%l3\nst %l3,[%fp+-192]\nadd -196,%fp,%l3\nst %l3,[%fp+-196]\nadd -124,%fp,%i5\nadd -124,%fp,%l3\nst %l3,[%fp+-124]\nadd -128,%fp,%i4\nadd -128,%fp,%l3\nst %l3,[%fp+-128]\nadd -132,%fp,%i3\nadd -132,%fp,%l3\nst %l3,[%fp+-132]\nadd -136,%fp,%i2\nadd -136,%fp,%l3\nst %l3,[%fp+-136]\nadd -140,%fp,%i1\nadd -140,%fp,%l3\nst %l3,[%fp+-140]\nadd -144,%fp,%i0\nadd -144,%fp,%l3\nst %l3,[%fp+-144]\nadd -148,%fp,%l7\nadd -148,%fp,%l3\nst %l3,[%fp+-148]\nadd -152,%fp,%l6\nadd -152,%fp,%l3\nst %l3,[%fp+-152]\nadd -156,%fp,%l5\nadd -156,%fp,%l3\nst %l3,[%fp+-156]\nadd -160,%fp,%l4\nadd -160,%fp,%l3\nst %l3,[%fp+-160]\nadd -164,%fp,%l3\nst %l3,[%fp+-4]\nadd -164,%fp,%l3\nst %l3,[%fp+-164]\nadd -168,%fp,%l3\nst %l3,[%fp+-8]\nadd -168,%fp,%l3\nst %l3,[%fp+-168]\nadd -172,%fp,%l3\nst %l3,[%fp+-12]\nadd -172,%fp,%l3\nst %l3,[%fp+-172]\nadd -176,%fp,%l3\nst %l3,[%fp+-16]\nadd -176,%fp,%l3\nst %l3,[%fp+-176]\nadd -180,%fp,%l3\nst %l3,[%fp+-20]\nadd -180,%fp,%l3\nst %l3,[%fp+-180]\nadd -184,%fp,%l3\nst %l3,[%fp+-24]\nadd -184,%fp,%l3\nst %l3,[%fp+-184]\nadd -200,%fp,%l3\nst %l3,[%fp+-200]\nadd -204,%fp,%l3\nst %l3,[%fp+-204]\nadd -216,%fp,%l3\nst %l3,[%fp+-216]\nadd -188,%fp,%l3\nadd -212,%fp,%l2\nsub %l3,%l2,%l2\nsra %l2,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l2,4,%l2\nst %l2,[%fp+-112]\nadd -192,%fp,%l2\nsub %l2,%l3,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-108]\nadd -196,%fp,%l3\nadd -192,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-104]\nadd -124,%fp,%l3\nadd -196,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-100]\nadd -128,%fp,%l3\nadd -124,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-96]\nadd -132,%fp,%l3\nadd -128,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-92]\nadd -136,%fp,%l3\nadd -132,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-88]\nadd -140,%fp,%l3\nadd -136,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-84]\nadd -144,%fp,%l3\nadd -140,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-80]\nadd -148,%fp,%l3\nadd -144,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-76]\nadd -152,%fp,%l3\nadd -148,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-72]\nadd -156,%fp,%l3\nadd -152,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-68]\nadd -160,%fp,%l3\nadd -156,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-64]\nadd -164,%fp,%l3\nadd -160,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-60]\nadd -168,%fp,%l3\nadd -164,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-56]\nadd -172,%fp,%l3\nadd -168,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-52]\nadd -176,%fp,%l3\nadd -172,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-48]\nadd -180,%fp,%l3\nadd -176,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-44]\nadd -184,%fp,%l3\nadd -180,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-40]\nadd -200,%fp,%l3\nadd -184,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-36]\nadd -204,%fp,%l3\nadd -200,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-32]\nadd -216,%fp,%l3\nadd -204,%fp,%l2\nsub %l3,%l2,%l3\nsra %l3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l3,4,%l3\nst %l3,[%fp+-28]\nld [%fp+-112],%l3\nst %l3,[%fp+-208]\nset 1,%l3\nst %l3,[%fp+-120]\nst %g0,[%fp+-116]\n.L3131:\nld [%fp+-120],%l3\ncmp %l3,1; be .L3137; nop\ncmp %l3,2; be .L3140; nop\ncmp %l3,3; be .L3145; nop\nba .L3135; nop\n.L3137:\nld [%fp+-116],%l3\nsll %l3,2,%l3\nadd -112,%fp,%l2\nld [%l3+%l2],%l3\nld [%fp+-208],%l2\ncmp %l3,%l2; be .L3136; nop\nset 2,%l3\nld [%fp+-116],%l2\nsll %l2,2,%l2\nadd -112,%fp,%l1\nld [%l2+%l1],%l2\nst %l2,[%fp+-224]\nst %l3,[%fp+-120]\nset 1,%l3\nst %l3,[%fp+-220]\nba .L3136; nop\n.L3140:\nld [%fp+-116],%l3\nsll %l3,2,%l3\nadd -112,%fp,%l2\nld [%l3+%l2],%l3\nld [%fp+-208],%l2\ncmp %l3,%l2; bne .L3141; nop\nset 3,%l3\nst %l3,[%fp+-120]\nba .L3136; nop\n.L3141:\nld [%fp+-116],%l3\nsll %l3,2,%l3\nadd -112,%fp,%l2\nld [%l3+%l2],%l3\nld [%fp+-224],%l2\ncmp %l3,%l2; bne .L3143; nop\nld [%fp+-220],%l3\nadd %l3,1,%l3\nst %l3,[%fp+-220]\nba .L3136; nop\n.L3143:\nset 4,%l3\nst %l3,[%fp+-120]\nba .L3136; nop\n.L3145:\nld [%fp+-116],%l3\nsll %l3,2,%l3\nadd -112,%fp,%l2\nld [%l3+%l2],%l3\nld [%fp+-208],%l2\ncmp %l3,%l2; be .L3136; nop\nset 4,%l3\nst %l3,[%fp+-120]\n.L3135:\n.L3136:\n.L3132:\nld [%fp+-116],%l3\nadd %l3,1,%l3\nst %l3,[%fp+-116]\nld [%fp+-116],%l3\ncmp %l3,22; bl .L3131; nop\nld [%fp+-120],%l3\ncmp %l3,3; bne .L3148; nop\nset 16,%l3\nld [%fp+-220],%l2\nsub %l3,%l2,%i0\nba .L3109; nop\n.L3148:\nset -1,%i0\n.L3109:\nret; restore\n.type regp,#function\n.size regp,.-regp\n.section \".bss\"\n.type .3151,#object\n.size .3151,420\n.local .3151\n.common .3151,420,4\n.section \".data\"\n.type .3152,#object\n.align 1\n.3152:\n.byte 115\n.byte 56\n.byte 52\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size .3152,10\n.type .3153,#object\n.size .3153,8\n.align 1\n.3153:\n.byte 115\n.byte 56\n.byte 52\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.global s84\n.section \".text\"\n.align 4\ns84:\nsave %sp,-232,%sp\nset .3153,%i2\nadd %i0,60,%i1\nmov %g0,%l7\n.L3154:\n.L3155:\nmov %i1,%l4\nadd %l4,1,%i1\nmov %i2,%l3\nadd %l3,1,%i2\nldsb [%l3],%l3\nstb %l3,[%l4]\nsll %l3,8*(4-1),%l4; sra %l4,8*(4-1),%l4\ncmp %l4,0; bne .L3154; nop\nset 3,%o0\ncall fip; nop\nmov %o0,%l6\nld [%l6],%l4\ncmp %l4,3; be .L3157; nop\nld [%i0+44],%l4\ncmp %l4,0; be .L3159; nop\nset .3152,%o0\nset 1,%o1\ncall printf; nop\n.L3159:\nadd %l7,1,%l7\n.L3157:\nset glork,%l5\nset 4,%o0\ncall %l5; nop\ncmp %o0,4; be .L3161; nop\nld [%i0+44],%l4\ncmp %l4,0; be .L3163; nop\nset .3152,%o0\nset 2,%o1\ncall printf; nop\n.L3163:\nadd %l7,2,%l7\n.L3161:\nmov %g0,%i4\n.L3165:\nsll %i4,2,%l4\nadd -68,%fp,%l3\nst %i4,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nst %f31,[%l4+%l3]\nsll %i4,2,%l4\nadd -136,%fp,%l3\nadd -68,%fp,%l2\nadd %l4,%l2,%l2\nst %l2,[%l4+%l3]\n.L3166:\nadd %i4,1,%i4\ncmp %i4,17; bl .L3165; nop\nset .L412,%l4\nld [%l4],%f31\nst %f31,[%fp+-140]\nmov %g0,%i4\n.L3169:\nld [%fp+-140],%f31\nsll %i4,2,%l4\nadd -136,%fp,%l3\nld [%l4+%l3],%l4\nld [%l4],%f30\nfadds %f31,%f30,%f31\nst %f31,[%fp+-140]\n.L3170:\nadd %i4,1,%i4\ncmp %i4,17; bl .L3169; nop\nld [%fp+-140],%f31\nset .L3175,%l4\nld [%l4],%f30\nfcmpes %f31,%f30; nop; fbue .L3173; nop\nld [%i0+44],%l4\ncmp %l4,0; be .L3176; nop\nset .3152,%o0\nset 4,%o1\ncall printf; nop\n.L3176:\nadd %l7,4,%l7\n.L3173:\nmov %g0,%i3\n.L3178:\nmov %g0,%i4\n.L3182:\nmov %g0,%i5\n.L3186:\nsll %i5,2,%l4\nsmul %i4,28,%l3\nsmul %i3,140,%l2\nset .3151,%l1\nadd %l2,%l1,%l2\nadd %l3,%l2,%l3\nsmul %i3,35,%l2\nsmul %i4,7,%l1\nadd %l2,%l1,%l2\nadd %l2,%i5,%l2\nst %l2,[%l4+%l3]\n.L3187:\nadd %i5,1,%i5\ncmp %i5,7; bl .L3186; nop\n.L3183:\nadd %i4,1,%i4\ncmp %i4,5; bl .L3182; nop\n.L3179:\nadd %i3,1,%i3\ncmp %i3,3; bl .L3178; nop\nset 1,%i3\nset 2,%i4\nset 3,%i5\nset .3151,%o0\nset 105,%o1\nmov %g0,%o2\ncall array; nop\nmov %o0,%l4\nsmul %i3,140,%l3\nset .3151,%l2\nadd %l3,%l2,%o0\nset 35,%l3\nmov %l3,%o1\nmov %l3,%o2\ncall array; nop\nmov %o0,%l3\nsmul %i4,28,%l2\nsmul %i3,140,%l1\nset .3151,%l0\nadd %l1,%l0,%l1\nadd %l2,%l1,%o0\nset 7,%o1\nset 49,%o2\ncall array; nop\nadd %l4,%l3,%l4\nadd %l4,%o0,%l4\nsll %i5,2,%l3\nsmul %i4,28,%l2\nsmul %i3,140,%l1\nset .3151,%l0\nadd %l1,%l0,%l1\nadd %l2,%l1,%l2\nld [%l3+%l2],%l3\nadd %l4,%l3,%l4\nsub %l4,52,%l4\ncmp %l4,0; be .L3190; nop\nld [%i0+44],%l4\ncmp %l4,0; be .L3192; nop\nset .3152,%o0\nset 8,%o1\ncall printf; nop\n.L3192:\nadd %l7,8,%l7\n.L3190:\nmov %l7,%i0\n.L3150:\nret; restore\n.type s84,#function\n.size s84,.-s84\n.global array\n.align 4\narray:\nmov %g0,%o5\nba .L3198; nop\n.L3195:\nsll %o5,2,%o4\nld [%o4+%o0],%o4\nadd %o5,%o2,%o3\ncmp %o4,%o3; be .L3199; nop\nset 1,%o0\nba .L3194; nop\n.L3199:\n.L3196:\nadd %o5,1,%o5\n.L3198:\ncmp %o5,%o1; bl .L3195; nop\nmov %g0,%o0\n.L3194:\nretl; nop\n.type array,#function\n.size array,.-array\n.section \".bss\"\n.type .3202,#object\n.size .3202,4\n.local .3202\n.common .3202,4,4\n.global fip\n.section \".text\"\n.align 4\nfip:\nset .3202,%o5\nst %o0,[%o5]\nmov %o5,%o0\n.L3201:\nretl; nop\n.type fip,#function\n.size fip,.-fip\n.global glork\n.align 4\nglork:\n.L3203:\nretl; nop\n.type glork,#function\n.size glork,.-glork\n.section \".data\"\n.type .3205,#object\n.align 1\n.3205:\n.byte 115\n.byte 56\n.byte 53\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size .3205,10\n.type .3206,#object\n.size .3206,8\n.align 1\n.3206:\n.byte 115\n.byte 56\n.byte 53\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.type .3214,#object\n.align 4\n.3214:\n.word .L425\n.word .L427\n.word .L426\n.word .L428\n.word .L429\n.word .L430\n.word .L431\n.size .3214,28\n.type .3215,#object\n.align 1\n.3215:\n.byte 32\n.byte 97\n.byte 108\n.byte 105\n.byte 103\n.byte 110\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 58\n.byte 32\n.byte 0\n.size .3215,13\n.global s85\n.section \".text\"\n.align 4\ns85:\nsave %sp,-488,%sp\nset .3206,%i4\nadd %i0,60,%i3\nmov %g0,%i2\n.L3219:\n.L3220:\nmov %i3,%i1\nadd %i1,1,%i3\nmov %i4,%l7\nadd %l7,1,%i4\nldsb [%l7],%l7\nstb %l7,[%i1]\nsll %l7,8*(4-1),%i1; sra %i1,8*(4-1),%i1\ncmp %i1,0; bne .L3219; nop\nadd -284,%fp,%l7\nadd -304,%fp,%l6\nsub %l7,%l6,%l7\ncmp %l7,%g0; ble .L3230; nop\nadd -280,%fp,%l7\nadd -284,%fp,%l6\nsub %l7,%l6,%l7\ncmp %l7,%g0; ble .L3230; nop\nadd -276,%fp,%l7\nadd -280,%fp,%l6\nsub %l7,%l6,%l7\ncmp %l7,%g0; bg .L3222; nop\n.L3230:\nld [%i0+44],%i1\ncmp %i1,0; be .L3231; nop\nset .3205,%o0\nset 1,%o1\ncall printf; nop\n.L3231:\nadd %i2,1,%i2\n.L3222:\nadd -337,%fp,%i1\nadd -338,%fp,%l7\nsub %i1,%l7,%i1\nst %i1,[%fp+-268]\nadd -340,%fp,%i1\nadd -342,%fp,%l7\nsub %i1,%l7,%i1\nst %i1,[%fp+-264]\nadd -348,%fp,%i1\nadd -352,%fp,%l7\nsub %i1,%l7,%i1\nst %i1,[%fp+-260]\nadd -356,%fp,%i1\nadd -360,%fp,%l7\nsub %i1,%l7,%i1\nst %i1,[%fp+-256]\nadd -364,%fp,%i1\nadd -368,%fp,%l7\nsub %i1,%l7,%i1\nst %i1,[%fp+-252]\nadd -372,%fp,%i1\nadd -376,%fp,%l7\nsub %i1,%l7,%i1\nst %i1,[%fp+-248]\nadd -384,%fp,%i1\nadd -392,%fp,%l7\nsub %i1,%l7,%i1\nst %i1,[%fp+-244]\nld [%i0+40],%i1\ncmp %i1,0; be .L3246; nop\nmov %g0,%i5\n.L3248:\nset .L3252,%o0\nsll %i5,2,%i1\nset .3214,%l7\nld [%i1+%l7],%o1\nset .3215,%o2\nadd -268,%fp,%l7\nld [%i1+%l7],%o3\ncall printf; nop\n.L3249:\nadd %i5,1,%i5\ncmp %i5,7; bl .L3248; nop\n.L3246:\nld [%fp+-272],%i1\nset 0x1c000000,%l7\nor %i1,%l7,%i1\nst %i1,[%fp+-272]\nld [%fp+-272],%i1\nmov %i1,%l7\nset 0x3fffffff,%l6\nand %l7,%l6,%l7\nsll %i1,3,%i1\nsra %i1,29,%i1\nsll %i1,30,%i1\nsra %i1,30,%i1\nsll %i1,30,%i1\nset 0xc0000000,%l6\nand %i1,%l6,%i1\nor %l7,%i1,%i1\nst %i1,[%fp+-272]\nld [%fp+-272],%i1\nmov %i1,%l7\nset 0xe3ffffff,%l6\nand %l7,%l6,%l7\nsra %i1,30,%i1\nsll %i1,29,%i1\nsra %i1,29,%i1\nsll %i1,26,%i1\nset 0x1c000000,%l6\nand %i1,%l6,%i1\nor %l7,%i1,%i1\nst %i1,[%fp+-272]\nld [%fp+-272],%i1\nsll %i1,3,%i1\nsra %i1,29,%i1\ncmp %i1,3; be .L3253; nop\nld [%fp+-272],%i1\nsll %i1,3,%i1\nsra %i1,29,%i1\ncmp %i1,-1; bne .L3255; nop\nld [%i0+40],%i1\ncmp %i1,0; be .L3256; nop\nset .L3259,%o0\ncall printf; nop\nba .L3256; nop\n.L3255:\nld [%i0+44],%i1\ncmp %i1,0; be .L3260; nop\nset .3205,%o0\nset 2,%o1\ncall printf; nop\n.L3260:\nadd %i2,2,%i2\n.L3256:\n.L3253:\nld [%fp+-272],%i1\nset 0x2000000,%l7\nor %i1,%l7,%i1\nst %i1,[%fp+-272]\nld [%fp+-272],%i1\nsll %i1,6,%i1\nsra %i1,31,%i1\ncmp %i1,1; be .L3262; nop\nld [%i0+40],%i1\ncmp %i1,0; be .L3264; nop\nset .L3266,%o0\ncall printf; nop\n.L3264:\n.L3262:\nadd -240,%fp,%i1\nsub %i1,%i1,%i1\ncmp %i1,%g0; bne .L3274; nop\ncmp %i1,%g0; bne .L3274; nop\ncmp %i1,%g0; bne .L3274; nop\ncmp %i1,%g0; bne .L3274; nop\ncmp %i1,%g0; bne .L3274; nop\ncmp %i1,%g0; bne .L3274; nop\ncmp %i1,%g0; be .L3267; nop\n.L3274:\nld [%i0+44],%i1\ncmp %i1,0; be .L3275; nop\nset .3205,%o0\nset 4,%o1\ncall printf; nop\n.L3275:\nadd %i2,4,%i2\n.L3267:\nba .L3277; nop\nld [%i0+44],%i1\ncmp %i1,0; be .L3279; nop\nset .3205,%o0\nset 8,%o1\ncall printf; nop\n.L3279:\nadd %i2,8,%i2\n.L3277:\nadd -336,%fp,%i1\nst %i1,[%fp+-276]\nset 2,%i1\nstb %i1,[%fp+-336]\nld [%fp+-276],%i1\nldsb [%i1],%l7\nadd %l7,1,%l7\nstb %l7,[%i1]\nldsb [%fp+-336],%i1\ncmp %i1,3; be .L3283; nop\nld [%i0+44],%i1\ncmp %i1,0; be .L3285; nop\nset .3205,%o0\nset 16,%o1\ncall printf; nop\n.L3285:\nadd %i2,16,%i2\n.L3283:\nmov %i2,%i0\n.L3204:\nret; restore\n.type s85,#function\n.size s85,.-s85\n.section \".data\"\n.type .3288,#object\n.align 1\n.3288:\n.byte 115\n.byte 56\n.byte 54\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size .3288,10\n.type .3289,#object\n.size .3289,8\n.align 1\n.3289:\n.byte 115\n.byte 56\n.byte 54\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.type .3290,#object\n.align 4\n.3290:\n.word 0x1\n.word 0x3\n.word 0x5\n.size .3290,12\n.type .3291,#object\n.size .3291,4\n.align 4\n.3291:\n.word .3290+8\n.section \".bss\"\n.type .3293,#object\n.size .3293,40\n.local .3293\n.common .3293,40,4\n.section \".data\"\n.type .3294,#object\n.align 4\n.3294:\n.word 0x3f800000\n.word 0x40400000\n.word 0x40a00000\n.word 0x40000000\n.word 0x40800000\n.word 0x40c00000\n.word 0x40400000\n.word 0x40a00000\n.word 0x40e00000\n.word 0x0\n.word 0x0\n.word 0x0\n.size .3294,48\n.type .3295,#object\n.size .3295,48\n.align 4\n.3295:\n.word 0x3f800000\n.word 0x40400000\n.word 0x40a00000\n.word 0x40000000\n.word 0x40800000\n.word 0x40c00000\n.word 0x40400000\n.word 0x40a00000\n.word 0x40e00000\n.skip 12\n.type .3296,#object\n.size .3296,48\n.align 4\n.3296:\n.word 0x3f800000\n.word 0x40400000\n.word 0x40a00000\n.word 0x40000000\n.word 0x40800000\n.word 0x40c00000\n.word 0x40400000\n.word 0x40a00000\n.word 0x40e00000\n.skip 12\n.type .3297,#object\n.size .3297,48\n.align 4\n.3297:\n.word 0x3f800000\n.skip 8\n.word 0x40000000\n.skip 8\n.word 0x40400000\n.skip 8\n.word 0x40800000\n.skip 8\n.global s86\n.section \".text\"\n.align 4\ns86:\nsave %sp,-96,%sp\nset .3291,%l3\nld [%l3],%l3\nadd %l3,-4,%l4\ncall one; nop\nsll %o0,2,%l3\nadd %l3,%l4,%i5\nset .3289,%l7\nadd %i0,60,%l6\nmov %g0,%l5\n.L3298:\n.L3299:\nmov %l6,%l3\nadd %l3,1,%l6\nmov %l7,%l2\nadd %l2,1,%l7\nldsb [%l2],%l2\nstb %l2,[%l3]\nsll %l2,8*(4-1),%l3; sra %l3,8*(4-1),%l3\ncmp %l3,0; bne .L3298; nop\nset .3291,%l3\nld [%l3],%l3\nld [%l3],%l3\ncmp %l3,5; be .L3301; nop\nld [%i0+44],%l3\ncmp %l3,0; be .L3303; nop\nset .3288,%o0\nset 1,%o1\ncall printf; nop\n.L3303:\nadd %l5,1,%l5\n.L3301:\nld [%l4],%l3\ncmp %l3,3; be .L3305; nop\nld [%i0+44],%l3\ncmp %l3,0; be .L3307; nop\nset .3288,%o0\nset 2,%o1\ncall printf; nop\n.L3307:\nadd %l5,2,%l5\n.L3305:\nld [%i5],%l3\ncmp %l3,5; be .L3309; nop\nld [%i0+44],%l3\ncmp %l3,0; be .L3311; nop\nset .3288,%o0\nset 4,%o1\ncall printf; nop\n.L3311:\nadd %l5,4,%l5\n.L3309:\nmov %g0,%i1\nmov %g0,%i4\n.L3313:\nsll %i4,2,%l3\nset .3293,%l2\nld [%l3+%l2],%l3\ncmp %l3,0; be .L3317; nop\nset 1,%i1\n.L3317:\n.L3314:\nadd %i4,1,%i4\ncmp %i4,10; bl .L3313; nop\ncmp %i1,0; be .L3319; nop\nld [%i0+44],%l3\ncmp %l3,0; be .L3321; nop\nset .3288,%o0\nset 8,%o1\ncall printf; nop\n.L3321:\nadd %l5,8,%l5\n.L3319:\nmov %g0,%i1\nmov %g0,%i3\n.L3323:\nmov %g0,%i4\n.L3327:\nsmul %i3,3,%l3\nadd %l3,%i4,%i2\nsll %i4,2,%l3\nsmul %i3,12,%l2\nset .3295,%l1\nadd %l2,%l1,%l1\nld [%l3+%l1],%f31\nset .3296,%l1\nadd %l2,%l1,%l2\nld [%l3+%l2],%f30\nfcmpes %f31,%f30; nop; fbne .L3333; nop\nsll %i2,2,%l3\nset .3294,%l2\nld [%l3+%l2],%f30\nfcmpes %f31,%f30; nop; fbue .L3331; nop\n.L3333:\nset 1,%i1\n.L3331:\n.L3328:\nadd %i4,1,%i4\ncmp %i4,3; bl .L3327; nop\n.L3324:\nadd %i3,1,%i3\ncmp %i3,4; bl .L3323; nop\ncmp %i1,0; be .L3334; nop\nld [%i0+44],%l3\ncmp %l3,0; be .L3336; nop\nset .3288,%o0\nset 16,%o1\ncall printf; nop\n.L3336:\nadd %l5,16,%l5\n.L3334:\nmov %g0,%i1\nmov %g0,%i4\n.L3338:\nsmul %i4,12,%l3\nset .3297,%l2\nld [%l3+%l2],%f31\nadd %i4,1,%l3\nst %l3,[%sp+64]; ld [%sp+64],%f30; fitos %f30,%f30\nfcmpes %f31,%f30; nop; fbue .L3342; nop\nset 1,%i1\n.L3342:\n.L3339:\nadd %i4,1,%i4\ncmp %i4,4; bl .L3338; nop\ncmp %i1,0; be .L3344; nop\nld [%i0+44],%l3\ncmp %l3,0; be .L3346; nop\nset .3288,%o0\nset 32,%o1\ncall printf; nop\n.L3346:\nadd %l5,32,%l5\n.L3344:\nmov %l5,%i0\n.L3287:\nret; restore\n.type s86,#function\n.size s86,.-s86\n.global one\n.align 4\none:\nset 1,%o0\n.L3348:\nretl; nop\n.type one,#function\n.size one,.-one\n.section \".data\"\n.type .3350,#object\n.align 1\n.3350:\n.byte 115\n.byte 56\n.byte 56\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size .3350,10\n.type .3351,#object\n.size .3351,8\n.align 1\n.3351:\n.byte 115\n.byte 56\n.byte 56\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.global s88\n.section \".text\"\n.align 4\ns88:\nsave %sp,-112,%sp\nset .3351,%i5\nadd %i0,60,%i4\nmov %g0,%i3\n.L3353:\n.L3354:\nmov %i4,%i1\nadd %i1,1,%i4\nmov %i5,%l7\nadd %l7,1,%i5\nldsb [%l7],%l7\nstb %l7,[%i1]\nsll %l7,8*(4-1),%i1; sra %i1,8*(4-1),%i1\ncmp %i1,0; bne .L3353; nop\nba .L3356; nop\nld [%i0+44],%i1\ncmp %i1,0; be .L3358; nop\nset .3350,%o0\nset 1,%o1\ncall printf; nop\n.L3358:\nadd %i3,1,%i3\n.L3356:\nset metricp,%i1\nadd -20,%fp,%l7\nst %l7,[%i1]\nset 2,%l7\nst %l7,[%fp+-20]\nld [%i1],%i1\nset 3,%l7\nst %l7,[%i1]\nld [%fp+-20],%i1\ncmp %i1,3; be .L3360; nop\nld [%i0+44],%i1\ncmp %i1,0; be .L3362; nop\nset .3350,%o0\nset 2,%o1\ncall printf; nop\n.L3362:\nadd %i3,2,%i3\n.L3360:\nset .L419,%i1\nld2 [%i1],%f30\nstd %f30,[%fp+-16]\nstd %f30,[%fp+-8]\nadd -16,%fp,%i2\nset .L418,%i1\nld2 [%i1],%f30\nst2 %f30,[%i2]\nset .L418,%i1\nld2 [%i1],%f30\nst2 %f30,[%i2+8]\nldd [%fp+-16],%f30\nldd [%fp+-8],%f28\nfaddd %f30,%f28,%f30\nset .L416,%i1\nld2 [%i1],%f28\nfcmped %f30,%f28; nop; fbue .L3365; nop\nld [%i0+44],%i1\ncmp %i1,0; be .L3368; nop\nset .3350,%o0\nset 4,%o1\ncall printf; nop\n.L3368:\nadd %i3,4,%i3\n.L3365:\nmov %i3,%i0\n.L3349:\nret; restore\n.type s88,#function\n.size s88,.-s88\n.section \".data\"\n.type .3371,#object\n.align 1\n.3371:\n.byte 115\n.byte 57\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size .3371,9\n.type .3372,#object\n.size .3372,8\n.align 1\n.3372:\n.byte 115\n.byte 57\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.global s9\n.section \".text\"\n.align 4\ns9:\nsave %sp,-96,%sp\nset .3372,%i3\nadd %i0,60,%i2\nmov %g0,%i1\n.L3373:\n.L3374:\nmov %i2,%l7\nadd %l7,1,%i2\nmov %i3,%l6\nadd %l6,1,%i3\nldsb [%l6],%l6\nstb %l6,[%l7]\nsll %l6,8*(4-1),%l7; sra %l7,8*(4-1),%l7\ncmp %l7,0; bne .L3373; nop\nmov %g0,%i4\nmov %g0,%i5\n.L3376:\nset 2,%l5\nmov %l5,%l7\nmov %l5,%l6\nset 3,%l3\nmov %l3,%l5\nmov %l3,%l4\ncmp %l4,3; bne .L3382; nop\ncmp %l5,3; be .L3380; nop\n.L3382:\nset 1,%i4\n.L3380:\ncmp %l6,2; bne .L3385; nop\ncmp %l7,2; be .L3383; nop\n.L3385:\nset 1,%i4\n.L3383:\n.L3377:\nadd %i5,1,%i5\ncmp %i5,2; bl .L3376; nop\ncmp %i4,0; be .L3390; nop\nld [%i0+44],%l7\ncmp %l7,0; be .L3388; nop\nset .3371,%o0\nset 1,%o1\ncall printf; nop\n.L3388:\nadd %i1,1,%i1\nba .L3390; nop\nld [%i0+44],%l7\ncmp %l7,0; be .L3391; nop\nset .3371,%o0\nset 2,%o1\ncall printf; nop\n.L3391:\nadd %i1,2,%i1\n.L3390:\nmov %i1,%i0\n.L3370:\nret; restore\n.type s9,#function\n.size s9,.-s9\n.global setev\n.align 4\nsetev:\nset extvar,%o5\nset 1066,%o4\nst %o4,[%o5]\nmov %g0,%o0\n.L3393:\nretl; nop\n.type setev,#function\n.size setev,.-setev\n.section \".bss\"\n.global rfs\n.type rfs,#object\n.size rfs,8\n.common rfs,8,1\n.global crc\n.type crc,#object\n.size crc,4\n.common crc,4,4\n.global rrc\n.type rrc,#object\n.size rrc,4\n.common rrc,4,4\n.global flgl\n.type flgl,#object\n.size flgl,4\n.common flgl,4,4\n.global flgd\n.type flgd,#object\n.size flgd,4\n.common flgd,4,4\n.global flgm\n.type flgm,#object\n.size flgm,4\n.common flgm,4,4\n.global flgs\n.type flgs,#object\n.size flgs,4\n.common flgs,4,4\n.global dprec\n.type dprec,#object\n.size dprec,4\n.common dprec,4,4\n.global fprec\n.type fprec,#object\n.size fprec,4\n.common fprec,4,4\n.global dbits\n.type dbits,#object\n.size dbits,4\n.common dbits,4,4\n.global fbits\n.type fbits,#object\n.size fbits,4\n.common fbits,4,4\n.global ubits\n.type ubits,#object\n.size ubits,4\n.common ubits,4,4\n.global lbits\n.type lbits,#object\n.size lbits,4\n.common lbits,4,4\n.global metricp\n.type metricp,#object\n.size metricp,4\n.common metricp,4,4\n.global extvar\n.type extvar,#object\n.size extvar,4\n.common extvar,4,4\n.section \".rodata\"\n.align 1\n.L3266:\n.byte 66\n.byte 101\n.byte 32\n.byte 101\n.byte 115\n.byte 112\n.byte 101\n.byte 99\n.byte 105\n.byte 97\n.byte 108\n.byte 108\n.byte 121\n.byte 32\n.byte 99\n.byte 97\n.byte 114\n.byte 101\n.byte 102\n.byte 117\n.byte 108\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 49\n.byte 45\n.byte 98\n.byte 105\n.byte 116\n.byte 32\n.byte 102\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 115\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.L3259:\n.byte 83\n.byte 105\n.byte 103\n.byte 110\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 101\n.byte 110\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 102\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.L3252:\n.byte 37\n.byte 115\n.byte 37\n.byte 115\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 4\n.L3175:\n.word 0x43080000\n.align 1\n.L3022:\n.byte 112\n.byte 111\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 0\n.align 1\n.L2472:\n.byte 73\n.byte 110\n.byte 99\n.byte 114\n.byte 101\n.byte 97\n.byte 115\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 97\n.byte 114\n.byte 114\n.byte 97\n.byte 121\n.byte 32\n.byte 101\n.byte 108\n.byte 101\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 97\n.byte 115\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 100\n.byte 101\n.byte 99\n.byte 114\n.byte 101\n.byte 97\n.byte 115\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 108\n.byte 111\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 10\n.byte 0\n.align 4\n.L2356:\n.word 0x41d00000\n.align 8\n.L2355:\n.word 0x403a0000\n.word 0x0\n.align 8\n.L1659:\n.word 0x40040000\n.word 0x0\n.align 8\n.L1484:\n.word 0x40240000\n.word 0x0\n.align 4\n.L1455:\n.word 0x41200000\n.align 8\n.L1280:\n.word 0x40080000\n.word 0x0\n.align 4\n.L1251:\n.word 0x40400000\n.align 8\n.L1076:\n.word 0x401c0000\n.word 0x0\n.align 4\n.L1047:\n.word 0x40e00000\n.align 8\n.L870:\n.word 0x40140000\n.word 0x0\n.align 4\n.L841:\n.word 0x40a00000\n.align 8\n.L836:\n.word 0x41e00000\n.word 0x0\n.align 4\n.L828:\n.word 0x4f000000\n.align 1\n.L653:\n.byte 113\n.byte 117\n.byte 101\n.byte 101\n.byte 112\n.byte 0\n.align 1\n.L639:\n.byte 10\n.byte 0\n.align 1\n.L638:\n.byte 37\n.byte 100\n.byte 0\n.align 1\n.L633:\n.byte 32\n.byte 32\n.byte 32\n.byte 107\n.byte 101\n.byte 121\n.byte 61\n.byte 0\n.align 8\n.L596:\n.word 0x40000000\n.word 0x0\n.align 8\n.L536:\n.word 0x40ce8480\n.word 0x0\n.align 8\n.L535:\n.word 0x405f4000\n.word 0x0\n.align 4\n.L534:\n.word 0x42fa0000\n.align 4\n.L529:\n.word 0x40000000\n.align 1\n.L431:\n.byte 100\n.byte 111\n.byte 117\n.byte 98\n.byte 108\n.byte 101\n.byte 0\n.align 1\n.L430:\n.byte 102\n.byte 108\n.byte 111\n.byte 97\n.byte 116\n.byte 0\n.align 1\n.L429:\n.byte 117\n.byte 110\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 101\n.byte 100\n.byte 0\n.align 1\n.L428:\n.byte 108\n.byte 111\n.byte 110\n.byte 103\n.byte 0\n.align 1\n.L427:\n.byte 115\n.byte 104\n.byte 111\n.byte 114\n.byte 116\n.byte 0\n.align 1\n.L426:\n.byte 105\n.byte 110\n.byte 116\n.byte 0\n.align 1\n.L425:\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 0\n.align 8\n.L419:\n.word 0x0\n.word 0x0\n.align 8\n.L418:\n.word 0x3ff00000\n.word 0x0\n.align 8\n.L417:\n.word 0x40100000\n.word 0x0\n.align 8\n.L416:\n.word 0x40000000\n.word 0x0\n.align 4\n.L412:\n.word 0x0\n.align 4\n.L411:\n.word 0x3f800000\n.align 1\n.L390:\n.byte 113\n.byte 117\n.byte 101\n.byte 101\n.byte 112\n.byte 33\n.byte 0\n.align 1\n.L379:\n.byte 10\n.byte 9\n.byte 8\n.byte 13\n.byte 12\n.byte 92\n.byte 39\n.byte 0\n.align 1\n.L375:\n.byte 46\n.byte 34\n.byte 46\n.byte 0\n.align 1\n.L362:\n.byte 46\n.byte 46\n.byte 46\n.byte 0\n.align 8\n.L333:\n.word 0x40938800\n.word 0x0\n.align 1\n.L199:\n.byte 32\n.byte 32\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 114\n.byte 101\n.byte 115\n.byte 117\n.byte 108\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 110\n.byte 32\n.byte 97\n.byte 115\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 108\n.byte 111\n.byte 110\n.byte 103\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L198:\n.byte 68\n.byte 101\n.byte 99\n.byte 105\n.byte 109\n.byte 97\n.byte 108\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 111\n.byte 99\n.byte 116\n.byte 97\n.byte 108\n.byte 47\n.byte 104\n.byte 101\n.byte 120\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 115\n.byte 116\n.byte 97\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 115\n.byte 111\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 109\n.byte 101\n.byte 115\n.byte 32\n.byte 103\n.byte 105\n.byte 118\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L27:\n.byte 10\n.byte 70\n.byte 97\n.byte 105\n.byte 108\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L26:\n.byte 10\n.byte 78\n.byte 111\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 115\n.byte 32\n.byte 100\n.byte 101\n.byte 116\n.byte 101\n.byte 99\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L20:\n.byte 83\n.byte 101\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 37\n.byte 115\n.byte 32\n.byte 114\n.byte 101\n.byte 116\n.byte 117\n.byte 114\n.byte 110\n.byte 101\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/cvt.1bk",
    "content": "1 1 1 1 1 1 1 1 1.000000 1.000000 1.000000\n2 2 2 2 2 2 2 2 2.000000 2.000000 2.000000\n3 3 3 3 3 3 3 3 3.000000 3.000000 3.000000\n4 4 4 4 4 4 4 4 4.000000 4.000000 4.000000\n5 5 5 5 5 5 5 5 5.000000 5.000000 5.000000\n6 6 6 6 6 6 6 6 6.000000 6.000000 6.000000\n7 7 7 7 7 7 7 7 7.000000 7.000000 7.000000\n8 8 8 8 8 8 8 8 8.000000 8.000000 8.000000\n9 9 9 9 9 9 9 9 9.000000 9.000000 9.000000\n10 10 10 10 10 10 10 10 10.000000 10.000000 10.000000\n11 11 11 11 11 11 11 11 11.000000 11.000000 11.000000\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/cvt.2bk",
    "content": "tst/cvt.c:32: warning: conversion from `pointer to void function(void)' to `pointer to void' is compiler dependent\ntst/cvt.c:33: warning: conversion from `pointer to void' to `pointer to void function(void)' is compiler dependent\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/cvt.sbk",
    "content": ".global print\n.section \".text\"\n.align 4\nprint:\nsave %sp,-128,%sp\nset .L2,%o0\nset c,%i5\nldsb [%i5],%o1\nset s,%i5\nldsh [%i5],%o2\nset i,%i5\nld [%i5],%o3\nset l,%i5\nld [%i5],%o4\nset C,%i5\nldub [%i5],%o5\nset S,%i5\nlduh [%i5],%i5\nst %i5,[%sp+4*6+68]\nset I,%i5\nld [%i5],%i5\nst %i5,[%sp+4*7+68]\nset L,%i5\nld [%i5],%i5\nst %i5,[%sp+4*8+68]\nset f,%i5\nld [%i5],%f31\nfstod %f31,%f30\nst %f30,[%sp+4*9+68]\nst %f31,[%sp+4*10+68]\nset d,%i5\nld2 [%i5],%f30\nst %f30,[%sp+4*11+68]\nst %f31,[%sp+4*12+68]\nset D,%i5\nld2 [%i5],%f30\nst %f30,[%sp+4*13+68]\nst %f31,[%sp+4*14+68]\ncall printf; nop\n.L1:\nret; restore\n.type print,#function\n.size print,.-print\n.global main\n.align 4\nmain:\nsave %sp,-104,%sp\nset c,%i5\nset 1,%i4\nstb %i4,[%i5]\nldsb [%i5],%i5\nset s,%i4\nmov %i5,%i3\nsth %i3,[%i4]\nset i,%i4\nst %i5,[%i4]\nset l,%i4\nst %i5,[%i4]\nset C,%i3\nmov %i5,%i2\nstb %i2,[%i3]\nset S,%i3\nmov %i5,%i2\nsth %i2,[%i3]\nset I,%i3\nst %i5,[%i3]\nset L,%i3\nst %i5,[%i3]\nset f,%i4\nst %i5,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nst %f31,[%i4]\nst %i5,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nset d,%i5\nst2 %f30,[%i5]\nset D,%i5\nst2 %f30,[%i5]\ncall print; nop\nset s,%i5\nset 2,%i4\nsth %i4,[%i5]\nldsh [%i5],%i5\nset c,%i4\nmov %i5,%i3\nstb %i3,[%i4]\nset i,%i4\nst %i5,[%i4]\nset l,%i4\nst %i5,[%i4]\nset C,%i3\nmov %i5,%i2\nstb %i2,[%i3]\nset S,%i3\nmov %i5,%i2\nsth %i2,[%i3]\nset I,%i3\nst %i5,[%i3]\nset L,%i3\nst %i5,[%i3]\nset f,%i4\nst %i5,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nst %f31,[%i4]\nst %i5,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nset d,%i5\nst2 %f30,[%i5]\nset D,%i5\nst2 %f30,[%i5]\ncall print; nop\nset i,%i5\nset 3,%i4\nst %i4,[%i5]\nld [%i5],%i5\nset c,%i4\nmov %i5,%i3\nstb %i3,[%i4]\nset s,%i4\nmov %i5,%i3\nsth %i3,[%i4]\nset l,%i4\nst %i5,[%i4]\nset C,%i3\nmov %i5,%i2\nstb %i2,[%i3]\nset S,%i3\nmov %i5,%i2\nsth %i2,[%i3]\nset I,%i3\nst %i5,[%i3]\nset L,%i3\nst %i5,[%i3]\nset f,%i4\nst %i5,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nst %f31,[%i4]\nst %i5,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nset d,%i5\nst2 %f30,[%i5]\nset D,%i5\nst2 %f30,[%i5]\ncall print; nop\nset l,%i5\nset 4,%i4\nst %i4,[%i5]\nld [%i5],%i5\nset c,%i4\nmov %i5,%i3\nstb %i3,[%i4]\nset s,%i4\nmov %i5,%i3\nsth %i3,[%i4]\nset i,%i4\nst %i5,[%i4]\nset C,%i3\nmov %i5,%i2\nstb %i2,[%i3]\nset S,%i3\nmov %i5,%i2\nsth %i2,[%i3]\nset I,%i3\nst %i5,[%i3]\nset L,%i3\nst %i5,[%i3]\nset f,%i4\nst %i5,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nst %f31,[%i4]\nst %i5,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nset d,%i5\nst2 %f30,[%i5]\nset D,%i5\nst2 %f30,[%i5]\ncall print; nop\nset C,%i5\nset 5,%i4\nstb %i4,[%i5]\nldub [%i5],%i5\nset c,%i4\nmov %i5,%i3\nstb %i3,[%i4]\nset s,%i4\nmov %i5,%i3\nsth %i3,[%i4]\nset i,%i4\nst %i5,[%i4]\nset l,%i4\nst %i5,[%i4]\nset S,%i3\nmov %i5,%i2\nsth %i2,[%i3]\nset I,%i3\nst %i5,[%i3]\nset L,%i3\nst %i5,[%i3]\nset f,%i4\nst %i5,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nst %f31,[%i4]\nst %i5,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nset d,%i5\nst2 %f30,[%i5]\nset D,%i5\nst2 %f30,[%i5]\ncall print; nop\nset S,%i5\nset 6,%i4\nsth %i4,[%i5]\nlduh [%i5],%i5\nset c,%i4\nmov %i5,%i3\nstb %i3,[%i4]\nset s,%i4\nmov %i5,%i3\nsth %i3,[%i4]\nset i,%i4\nst %i5,[%i4]\nset l,%i4\nst %i5,[%i4]\nset C,%i3\nmov %i5,%i2\nstb %i2,[%i3]\nset I,%i3\nst %i5,[%i3]\nset L,%i3\nst %i5,[%i3]\nset f,%i4\nst %i5,[%sp+64]; ld [%sp+64],%f31; fitos %f31,%f31\nst %f31,[%i4]\nst %i5,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nset d,%i5\nst2 %f30,[%i5]\nset D,%i5\nst2 %f30,[%i5]\ncall print; nop\nset I,%i5\nset 7,%i4\nst %i4,[%i5]\nld [%i5],%i5\nset c,%i3\nmov %i5,%i2\nstb %i2,[%i3]\nset s,%i3\nmov %i5,%i2\nsth %i2,[%i3]\nset i,%i3\nst %i5,[%i3]\nset l,%i3\nst %i5,[%i3]\nset C,%i4\nmov %i5,%i3\nstb %i3,[%i4]\nset S,%i4\nmov %i5,%i3\nsth %i3,[%i4]\nset L,%i4\nst %i5,[%i4]\nset .L4,%i4\nld2 [%i4],%f30\nsrl %i5,1,%i4\nst %i4,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfmuld %f30,%f28,%f30\nset 1,%i4\nand %i5,%i4,%i5\nst %i5,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfaddd %f30,%f28,%f30\nset f,%i5\nfdtos %f30,%f29\nst %f29,[%i5]\nset d,%i5\nst2 %f30,[%i5]\nset D,%i5\nst2 %f30,[%i5]\ncall print; nop\nset L,%i5\nset 8,%i4\nst %i4,[%i5]\nld [%i5],%i5\nset c,%i3\nmov %i5,%i2\nstb %i2,[%i3]\nset s,%i3\nmov %i5,%i2\nsth %i2,[%i3]\nset i,%i3\nst %i5,[%i3]\nset l,%i3\nst %i5,[%i3]\nset C,%i4\nmov %i5,%i3\nstb %i3,[%i4]\nset S,%i4\nmov %i5,%i3\nsth %i3,[%i4]\nset I,%i3\nlduh [%i4],%i4\nst %i4,[%i3]\nset .L4,%i4\nld2 [%i4],%f30\nsrl %i5,1,%i4\nst %i4,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfmuld %f30,%f28,%f30\nset 1,%i4\nand %i5,%i4,%i5\nst %i5,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfaddd %f30,%f28,%f30\nset f,%i5\nfdtos %f30,%f29\nst %f29,[%i5]\nset d,%i5\nst2 %f30,[%i5]\nset D,%i5\nst2 %f30,[%i5]\ncall print; nop\nset f,%i1\nset .L5,%i0\nld [%i0],%f31\nst %f31,[%i1]\nld [%i1],%f31\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%i1\nset c,%i0\nmov %i1,%l7\nstb %l7,[%i0]\nset s,%i0\nmov %i1,%l7\nsth %l7,[%i0]\nset i,%i0\nst %i1,[%i0]\nset l,%i0\nst %i1,[%i0]\nset .L9,%i1\nld [%i1],%f30\nfcmpes %f31,%f30; nop; fbul .L7; nop\nfsubs %f31,%f30,%f30\nfstoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%i1\nset 0x80000000,%i0\nadd %i1,%i0,%i5\nba .L8; nop\n.L7:\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%i1\nmov %i1,%i5\n.L8:\nset C,%i1\nmov %i5,%i0\nstb %i0,[%i1]\nset f,%i1\nld [%i1],%f31\nset .L9,%i1\nld [%i1],%f30\nfcmpes %f31,%f30; nop; fbul .L11; nop\nfsubs %f31,%f30,%f30\nfstoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%i1\nset 0x80000000,%i0\nadd %i1,%i0,%i4\nba .L12; nop\n.L11:\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%i1\nmov %i1,%i4\n.L12:\nset S,%i1\nmov %i4,%i0\nsth %i0,[%i1]\nset f,%i1\nld [%i1],%f31\nset .L9,%i1\nld [%i1],%f30\nfcmpes %f31,%f30; nop; fbul .L14; nop\nfsubs %f31,%f30,%f30\nfstoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%i1\nset 0x80000000,%i0\nadd %i1,%i0,%i3\nba .L15; nop\n.L14:\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%i1\nmov %i1,%i3\n.L15:\nset I,%i1\nst %i3,[%i1]\nset f,%i1\nld [%i1],%f31\nset .L9,%i1\nld [%i1],%f30\nfcmpes %f31,%f30; nop; fbul .L17; nop\nfsubs %f31,%f30,%f30\nfstoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%i1\nset 0x80000000,%i0\nadd %i1,%i0,%i2\nba .L18; nop\n.L17:\nfstoi %f31,%f0; st %f0,[%sp+64]; ld [%sp+64],%i1\nmov %i1,%i2\n.L18:\nset L,%i1\nst %i2,[%i1]\nset f,%i1\nld [%i1],%f31\nfstod %f31,%f30\nset d,%i1\nst2 %f30,[%i1]\nset D,%i1\nst2 %f30,[%i1]\ncall print; nop\nset d,%l5\nset .L19,%l4\nld2 [%l4],%f30\nst2 %f30,[%l5]\nld2 [%l5],%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l5\nset c,%l4\nmov %l5,%l3\nstb %l3,[%l4]\nset s,%l4\nmov %l5,%l3\nsth %l3,[%l4]\nset i,%l4\nst %l5,[%l4]\nset l,%l4\nst %l5,[%l4]\nset .L23,%l5\nld2 [%l5],%f28\nfcmped %f30,%f28; nop; fbul .L21; nop\nfsubd %f30,%f28,%f28\nfdtoi %f28,%f0; st %f0,[%sp+64]; ld [%sp+64],%l5\nset 0x80000000,%l4\nadd %l5,%l4,%i1\nba .L22; nop\n.L21:\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l5\nmov %l5,%i1\n.L22:\nset C,%l5\nmov %i1,%l4\nstb %l4,[%l5]\nset d,%l5\nld2 [%l5],%f30\nset .L23,%l5\nld2 [%l5],%f28\nfcmped %f30,%f28; nop; fbul .L25; nop\nfsubd %f30,%f28,%f28\nfdtoi %f28,%f0; st %f0,[%sp+64]; ld [%sp+64],%l5\nset 0x80000000,%l4\nadd %l5,%l4,%i0\nba .L26; nop\n.L25:\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l5\nmov %l5,%i0\n.L26:\nset S,%l5\nmov %i0,%l4\nsth %l4,[%l5]\nset d,%l5\nld2 [%l5],%f30\nset .L23,%l5\nld2 [%l5],%f28\nfcmped %f30,%f28; nop; fbul .L28; nop\nfsubd %f30,%f28,%f28\nfdtoi %f28,%f0; st %f0,[%sp+64]; ld [%sp+64],%l5\nset 0x80000000,%l4\nadd %l5,%l4,%l7\nba .L29; nop\n.L28:\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l5\nmov %l5,%l7\n.L29:\nset I,%l5\nst %l7,[%l5]\nset d,%l5\nld2 [%l5],%f30\nset .L23,%l5\nld2 [%l5],%f28\nfcmped %f30,%f28; nop; fbul .L31; nop\nfsubd %f30,%f28,%f28\nfdtoi %f28,%f0; st %f0,[%sp+64]; ld [%sp+64],%l5\nset 0x80000000,%l4\nadd %l5,%l4,%l6\nba .L32; nop\n.L31:\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l5\nmov %l5,%l6\n.L32:\nset L,%l5\nst %l6,[%l5]\nset d,%l5\nld2 [%l5],%f30\nset f,%l5\nfdtos %f30,%f29\nst %f29,[%l5]\nset D,%l5\nst2 %f30,[%l5]\ncall print; nop\nset D,%l3\nset .L33,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nld2 [%l3],%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nset c,%l2\nmov %l3,%l1\nstb %l1,[%l2]\nset s,%l2\nmov %l3,%l1\nsth %l1,[%l2]\nset i,%l2\nst %l3,[%l2]\nset l,%l2\nst %l3,[%l2]\nset .L37,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbul .L35; nop\nfsubd %f30,%f28,%f28\nfdtoi %f28,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nset 0x80000000,%l2\nadd %l3,%l2,%l5\nba .L36; nop\n.L35:\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%l5\n.L36:\nset C,%l3\nmov %l5,%l2\nstb %l2,[%l3]\nset D,%l3\nld2 [%l3],%f30\nset .L37,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbul .L39; nop\nfsubd %f30,%f28,%f28\nfdtoi %f28,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nset 0x80000000,%l2\nadd %l3,%l2,%l4\nba .L40; nop\n.L39:\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nmov %l3,%l4\n.L40:\nset S,%l3\nmov %l4,%l2\nsth %l2,[%l3]\nset D,%l3\nld2 [%l3],%f30\nset .L37,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbul .L42; nop\nfsubd %f30,%f28,%f28\nfdtoi %f28,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nset 0x80000000,%l2\nadd %l3,%l2,%l3\nst %l3,[%fp+-4]\nba .L43; nop\n.L42:\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nst %l3,[%fp+-4]\n.L43:\nset I,%l3\nld [%fp+-4],%l2\nst %l2,[%l3]\nset D,%l3\nld2 [%l3],%f30\nset .L37,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbul .L45; nop\nfsubd %f30,%f28,%f28\nfdtoi %f28,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nset 0x80000000,%l2\nadd %l3,%l2,%l3\nst %l3,[%fp+-8]\nba .L46; nop\n.L45:\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l3\nst %l3,[%fp+-8]\n.L46:\nset L,%l3\nld [%fp+-8],%l2\nst %l2,[%l3]\nset D,%l3\nld2 [%l3],%f30\nset f,%l3\nfdtos %f30,%f29\nst %f29,[%l3]\nset d,%l3\nst2 %f30,[%l3]\ncall print; nop\nset p,%l3\nst %g0,[%l3]\nst %g0,[%l3]\nst %g0,[%l3]\nst %g0,[%l3]\nset P,%l2\nld [%l2],%l1\nst %l1,[%l3]\nmov %g0,%l1\nst %l1,[%l2]\nst %l1,[%l2]\nst %l1,[%l2]\nst %l1,[%l2]\nld [%l3],%l3\nst %l3,[%l2]\nmov %g0,%i0\n.L3:\nret; restore\n.type main,#function\n.size main,.-main\n.section \".bss\"\n.global P\n.type P,#object\n.size P,4\n.common P,4,4\n.global p\n.type p,#object\n.size p,4\n.common p,4,4\n.global D\n.type D,#object\n.size D,8\n.common D,8,8\n.global d\n.type d,#object\n.size d,8\n.common d,8,8\n.global f\n.type f,#object\n.size f,4\n.common f,4,4\n.global L\n.type L,#object\n.size L,4\n.common L,4,4\n.global I\n.type I,#object\n.size I,4\n.common I,4,4\n.global S\n.type S,#object\n.size S,2\n.common S,2,2\n.global C\n.type C,#object\n.size C,1\n.common C,1,1\n.global l\n.type l,#object\n.size l,4\n.common l,4,4\n.global i\n.type i,#object\n.size i,4\n.common i,4,4\n.global s\n.type s,#object\n.size s,2\n.common s,2,2\n.global c\n.type c,#object\n.size c,1\n.common c,1,1\n.section \".rodata\"\n.align 8\n.L37:\n.word 0x41e00000\n.word 0x0\n.align 8\n.L33:\n.word 0x40260000\n.word 0x0\n.align 8\n.L23:\n.word 0x41e00000\n.word 0x0\n.align 8\n.L19:\n.word 0x40240000\n.word 0x0\n.align 4\n.L9:\n.word 0x4f000000\n.align 4\n.L5:\n.word 0x41100000\n.align 8\n.L4:\n.word 0x40000000\n.word 0x0\n.align 1\n.L2:\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 108\n.byte 100\n.byte 32\n.byte 37\n.byte 117\n.byte 32\n.byte 37\n.byte 117\n.byte 32\n.byte 37\n.byte 117\n.byte 32\n.byte 37\n.byte 108\n.byte 117\n.byte 32\n.byte 37\n.byte 102\n.byte 32\n.byte 37\n.byte 102\n.byte 32\n.byte 37\n.byte 108\n.byte 102\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/fields.1bk",
    "content": "x = 1 2 3 4 -3 6\ny = 3 8 9\nx = 1 2 3 0 0 6\ny = 2 8 16\np->a = 0x3, p->b = 0xf\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/fields.2bk",
    "content": "tst/fields.c:6: warning: initializer exceeds bit-field width\ntst/fields.c:8: warning: initializer exceeds bit-field width\ntst/fields.c:30: warning: missing return value\ntst/fields.c:34: warning: missing return value\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/fields.sbk",
    "content": ".section \".data\"\n.global x\n.type x,#object\n.size x,16\n.align 4\nx:\n.word 0x1\n.byte 0x2\n.skip 3\n.byte 0x0\n.byte 0x34\n.skip 2\n.byte 0xa\n.byte 0x6\n.skip 2\n.global i\n.type i,#object\n.size i,4\n.align 4\ni:\n.word 0x10\n.global y\n.type y,#object\n.size y,8\n.align 4\ny:\n.byte 0xe0\n.skip 3\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x9\n.global main\n.section \".text\"\n.align 4\nmain:\nsave %sp,-96,%sp\nset .L4,%o0\nset x,%i5\nld [%i5],%o1\nset x+4,%i5\nldsb [%i5],%o2\nset x+8,%i5\nld [%i5],%i5\nsra %i5,20,%o3\nset x+8,%i5\nld [%i5],%i5\nsll %i5,12,%i5\nsra %i5,28,%o4\nset x+12,%i5\nld [%i5],%i5\nsll %i5,4,%i5\nsra %i5,29,%o5\nset x+13,%i5\nldsb [%i5],%i5\nst %i5,[%sp+4*6+68]\ncall printf; nop\nset .L10,%o0\nset y,%i5\nld [%i5],%i5\nsrl %i5,30,%i4\nset 3,%i3\nand %i4,%i3,%o1\nsrl %i5,26,%i5\nset 15,%i4\nand %i5,%i4,%o2\nset y+4,%i5\nld [%i5],%o3\ncall printf; nop\nset x+8,%i5\nld [%i5],%i4\nset 0xfff0ffff,%i3\nand %i4,%i3,%i4\nset i,%i3\nld [%i3],%i3\nsll %i3,28,%i3\nsra %i3,28,%i3\nsll %i3,16,%i3\nset 0xf0000,%i2\nand %i3,%i2,%i3\nor %i4,%i3,%i4\nst %i4,[%i5]\nset x+12,%i5\nld [%i5],%i4\nset 0xf1ffffff,%i3\nand %i4,%i3,%i4\nst %i4,[%i5]\nset .L4,%o0\nset x,%i5\nld [%i5],%o1\nset x+4,%i5\nldsb [%i5],%o2\nset x+8,%i5\nld [%i5],%i5\nsra %i5,20,%o3\nset x+8,%i5\nld [%i5],%i5\nsll %i5,12,%i5\nsra %i5,28,%o4\nset x+12,%i5\nld [%i5],%i5\nsll %i5,4,%i5\nsra %i5,29,%o5\nset x+13,%i5\nldsb [%i5],%i5\nst %i5,[%sp+4*6+68]\ncall printf; nop\nset y,%i5\nld [%i5],%i4\nset 0x3fffffff,%i3\nand %i4,%i3,%i4\nset 0x80000000,%i3\nor %i4,%i3,%i4\nst %i4,[%i5]\nset y+4,%i5\nset i,%i4\nld [%i4],%i4\nst %i4,[%i5]\nset .L10,%o0\nset y,%i5\nld [%i5],%i5\nsrl %i5,30,%i4\nset 3,%i3\nand %i4,%i3,%o1\nsrl %i5,26,%i5\nset 15,%i4\nand %i5,%i4,%o2\nset y+4,%i5\nld [%i5],%o3\ncall printf; nop\nset x,%o0\ncall f2; nop\nmov %g0,%i0\n.L3:\nret; restore\n.type main,#function\n.size main,.-main\n.global f1\n.align 4\nf1:\nsave %sp,-96,%sp\nld [%i0],%i5\nset 0xc3ffffff,%i4\nand %i5,%i4,%i5\nst %i5,[%i0]\nld [%i0],%i5\nset 0x3fffffff,%i4\nand %i5,%i4,%i5\nset 3,%i4\nand %g0,%i4,%i4\nsll %i4,30,%i4\nset 0xc0000000,%i3\nand %i4,%i3,%i4\nor %i5,%i4,%i5\nst %i5,[%i0]\nld [%i0],%i5\nset 0x3c000000,%i4\nand %i5,%i4,%i5\ncmp %i5,%g0; be .L22; nop\nset .L24,%o0\ncall printf; nop\n.L22:\nld [%i0],%i5\nset 0xc0000000,%i4\nor %i5,%i4,%i5\nst %i5,[%i0]\nld [%i0],%i5\nset 0x3c000000,%i4\nor %i5,%i4,%i5\nst %i5,[%i0]\nset .L25,%o0\nld [%i0],%i5\nsrl %i5,30,%i4\nset 3,%i3\nand %i4,%i3,%o1\nsrl %i5,26,%i5\nset 15,%i4\nand %i5,%i4,%o2\ncall printf; nop\nmov %g0,%i0\n.L21:\nret; restore\n.type f1,#function\n.size f1,.-f1\n.global f2\n.align 4\nf2:\nsave %sp,-96,%sp\nset i,%i4\nld [%i4],%i4\ncmp %i4,0; bne .L28; nop\nset 1,%i5\nba .L29; nop\n.L28:\nmov %g0,%i5\n.L29:\nld [%i0],%i4\nset 0x3fffffff,%i3\nand %i4,%i3,%i4\nmov %i5,%i3\nset 3,%i2\nand %i3,%i2,%i3\nsll %i3,30,%i3\nset 0xc0000000,%i2\nand %i3,%i2,%i3\nor %i4,%i3,%i4\nst %i4,[%i0]\nmov %i0,%o0\ncall f1; nop\nld [%i0],%i4\nset 0xc3ffffff,%i3\nand %i4,%i3,%i4\nmov %g0,%i3\nset 15,%i2\nand %i3,%i2,%i3\nsll %i3,26,%i3\nset 0x3c000000,%i2\nand %i3,%i2,%i3\nor %i4,%i3,%i4\nst %i4,[%i0]\nmov %g0,%i0\n.L26:\nret; restore\n.type f2,#function\n.size f2,.-f2\n.section \".rodata\"\n.align 1\n.L25:\n.byte 112\n.byte 45\n.byte 62\n.byte 97\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 120\n.byte 37\n.byte 120\n.byte 44\n.byte 32\n.byte 112\n.byte 45\n.byte 62\n.byte 98\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 120\n.byte 37\n.byte 120\n.byte 10\n.byte 0\n.align 1\n.L24:\n.byte 112\n.byte 45\n.byte 62\n.byte 98\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.L10:\n.byte 121\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L4:\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/front.2bk",
    "content": "tst/front.c:3: warning: missing return value\ntst/front.c:10: warning: missing return value\ntst/front.c:20: type error in argument 1 to `s'; found `pointer to struct D' expected `pointer to incomplete struct D defined at tst/front.c:14'\ntst/front.c:21: warning: missing return value\ntst/front.c:32: warning: missing return value\ntst/front.c:36: operands of = have illegal types `pointer to int' and `pointer to const int'\ntst/front.c:38: warning: missing return value\ntst/front.c:62: operands of = have illegal types `pointer to char' and `pointer to const void'\ntst/front.c:63: warning: missing return value\ntst/front.c:68: warning: missing return value\ntst/front.c:69: warning: inconsistent linkage for `yy' previously declared at tst/front.c:68\ntst/front.c:69: warning: missing return value\ntst/front.c:71: invalid storage class `static' for `int function goo'\ntst/front.c:71: warning: declaration of `goo' does not match previous declaration at tst/front.c:70\ntst/front.c:71: warning: missing return value\ntst/front.c:74: warning: declaration of `xr' does not match previous declaration at tst/front.c:72\ntst/front.c:74: warning: missing return value\ntst/front.c:81: warning: missing return value\ntst/front.c:82: warning: declaration of `ss2' does not match previous declaration at tst/front.c:81\ntst/front.c:84: warning: inconsistent linkage for `ss5' previously declared at tst/front.c:80\ntst/front.c:92: type error in argument 1 to `gx1'; found `pointer to double' expected `double'\ntst/front.c:92: warning: missing return value\ntst/front.c:95: redeclaration of `hx1' previously declared at tst/front.c:94\ntst/front.c:98: warning: missing return value\ntst/front.c:101: conflicting argument declarations for function `gg1'\ntst/front.c:101: warning: missing return value\ntst/front.c:112: type error in argument 4 to `qsort'; found `pointer to int function(pointer to pointer to char,pointer to pointer to char)' expected `pointer to int function(pointer to const void,pointer to const void)'\ntst/front.c:113: warning: missing return value\ntst/front.c:120: warning: missing return value\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/front.sbk",
    "content": ".global main\n.section \".text\"\n.align 4\nmain:\nsave %sp,-96,%sp\nmov %g0,%o0\ncall exit; nop\nmov %g0,%i0\n.L1:\nret; restore\n.type main,#function\n.size main,.-main\n.global nested\n.align 4\nnested:\ncmp %o0,4; bge .L6; nop\ncmp %o1,114; be .L9; nop\n.L6:\ncmp %o0,1; bne .L8; nop\ncmp %o1,104; be .L9; nop\ncmp %o1,105; be .L9; nop\n.L8:\ncmp %o0,2; bne .L3; nop\ncmp %o1,111; be .L9; nop\ncmp %o1,121; bne .L3; nop\n.L9:\nmov %o1,%o0\n.L3:\nmov %g0,%o0\n.L2:\nretl; nop\n.type nested,#function\n.size nested,.-nested\n.global s\n.align 4\ns:\n.L10:\nretl; nop\n.type s,#function\n.size s,.-s\n.section \".data\"\n.global Dy\n.type Dy,#object\n.size Dy,8\n.align 4\nDy:\n.word 0x0\n.skip 4\n.global Dz\n.type Dz,#object\n.size Dz,8\n.align 4\nDz:\n.word 0x1\n.skip 4\n.global Dfunc\n.section \".text\"\n.align 4\nDfunc:\nsave %sp,-96,%sp\nret; restore\n.type Dfunc,#function\n.size Dfunc,.-Dfunc\n.global f\n.align 4\nf:\nretl; nop\n.type f,#function\n.size f,.-f\n.global f1\n.align 4\nf1:\nretl; nop\n.type f1,#function\n.size f1,.-f1\n.global f2\n.align 4\nf2:\nsave %sp,-96,%sp\nret; restore\n.type f2,#function\n.size f2,.-f2\n.global g\n.align 4\ng:\nsave %sp,-96,%sp\nret; restore\n.type g,#function\n.size g,.-g\n.global h\n.align 4\nh:\nsave %sp,-96,%sp\nret; restore\n.type h,#function\n.size h,.-h\n.global h1\n.align 4\nh1:\nsave %sp,-96,%sp\nret; restore\n.type h1,#function\n.size h1,.-h1\n.global h2\n.align 4\nh2:\nretl; nop\n.type h2,#function\n.size h2,.-h2\n.section \".data\"\n.type .21,#object\n.size .21,4\n.align 4\n.21:\n.word 0x1\n.global set1\n.section \".text\"\n.align 4\nset1:\nretl; nop\n.type set1,#function\n.size set1,.-set1\n.section \".data\"\n.type .23,#object\n.size .23,4\n.align 4\n.23:\n.word 0x2\n.global set2\n.section \".text\"\n.align 4\nset2:\nretl; nop\n.type set2,#function\n.size set2,.-set2\n.align 4\ngoo:\nretl; nop\n.type goo,#function\n.size goo,.-goo\n.global sss\n.align 4\nsss:\nretl; nop\n.type sss,#function\n.size sss,.-sss\n.section \".bss\"\n.type .27,#object\n.size .27,4\n.local .27\n.common .27,4,4\n.global rrr\n.section \".text\"\n.align 4\nrrr:\nretl; nop\n.type rrr,#function\n.size rrr,.-rrr\n.global setstatic\n.align 4\nsetstatic:\nretl; nop\n.type setstatic,#function\n.size setstatic,.-setstatic\n.global gx1\n.align 4\ngx1:\nsave %sp,-96,%sp\nst %r24,[%fp+68]\nst %r25,[%fp+72]\nret; restore\n.type gx1,#function\n.size gx1,.-gx1\n.global ff1\n.align 4\nff1:\nsave %sp,-96,%sp\nst %r24,[%fp+68]\nst %r25,[%fp+72]\nret; restore\n.type ff1,#function\n.size ff1,.-ff1\n.global gg1\n.align 4\ngg1:\nretl; nop\n.type gg1,#function\n.size gg1,.-gg1\n.global hh1\n.align 4\nhh1:\nretl; nop\n.type hh1,#function\n.size hh1,.-hh1\n.global cmp\n.align 4\ncmp:\nsave %sp,-96,%sp\nret; restore\n.type cmp,#function\n.size cmp,.-cmp\n.global sort\n.align 4\nsort:\nsave %sp,-96,%sp\nret; restore\n.type sort,#function\n.size sort,.-sort\n.global onearg\n.align 4\nonearg:\nsave %sp,-96,%sp\nret; restore\n.type onearg,#function\n.size onearg,.-onearg\n.section \".bss\"\n.global ss4\n.type ss4,#object\n.size ss4,4\n.common ss4,4,4\n.type ss2,#object\n.size ss2,4\n.local ss2\n.common ss2,4,4\n.type ss5,#object\n.size ss5,4\n.local ss5\n.common ss5,4,4\n.global ss3\n.type ss3,#object\n.size ss3,4\n.common ss3,4,4\n.type ss1,#object\n.size ss1,4\n.local ss1\n.common ss1,4,4\n.type yy,#object\n.size yy,4\n.local yy\n.common yy,4,4\n.global z\n.type z,#object\n.size z,4\n.common z,4,4\n.global y\n.type y,#object\n.size y,4\n.common y,4,4\n.global x\n.type x,#object\n.size x,4\n.common x,4,4\n.global b\n.type b,#object\n.size b,4\n.common b,4,4\n.global a\n.type a,#object\n.size a,4\n.common a,4,4\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/incr.1bk",
    "content": ""
  },
  {
    "path": "lcc/sparc/solaris/tst/incr.2bk",
    "content": "tst/incr.c:1: warning: missing return value\ntst/incr.c:6: warning: expression with no effect elided\ntst/incr.c:6: warning: expression with no effect elided\ntst/incr.c:11: warning: missing return value\ntst/incr.c:16: warning: expression with no effect elided\ntst/incr.c:16: warning: expression with no effect elided\ntst/incr.c:21: warning: missing return value\ntst/incr.c:30: warning: missing return value\ntst/incr.c:39: warning: missing return value\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/incr.sbk",
    "content": ".global main\n.section \".text\"\n.align 4\nmain:\nmov %g0,%o0\n.L1:\nretl; nop\n.type main,#function\n.size main,.-main\n.global memchar\n.align 4\nmemchar:\nsave %sp,-104,%sp\nld [%fp+-8],%i5\nadd %i5,1,%i4\nst %i4,[%fp+-8]\nldsb [%i5],%i5\nstb %i5,[%fp+-1]\nld [%fp+-8],%i5\nadd %i5,1,%i5\nst %i5,[%fp+-8]\nldsb [%i5],%i5\nstb %i5,[%fp+-1]\nld [%fp+-8],%i5\nadd %i5,-1,%i4\nst %i4,[%fp+-8]\nldsb [%i5],%i5\nstb %i5,[%fp+-1]\nld [%fp+-8],%i5\nadd %i5,-1,%i5\nst %i5,[%fp+-8]\nldsb [%i5],%i5\nstb %i5,[%fp+-1]\nmov %g0,%i0\n.L2:\nret; restore\n.type memchar,#function\n.size memchar,.-memchar\n.global memint\n.align 4\nmemint:\nsave %sp,-104,%sp\nld [%fp+-8],%i5\nadd %i5,4,%i4\nst %i4,[%fp+-8]\nld [%i5],%i5\nst %i5,[%fp+-4]\nld [%fp+-8],%i5\nadd %i5,4,%i5\nst %i5,[%fp+-8]\nld [%i5],%i5\nst %i5,[%fp+-4]\nld [%fp+-8],%i5\nadd %i5,-4,%i4\nst %i4,[%fp+-8]\nld [%i5],%i5\nst %i5,[%fp+-4]\nld [%fp+-8],%i5\nadd %i5,-4,%i5\nst %i5,[%fp+-8]\nld [%i5],%i5\nst %i5,[%fp+-4]\nmov %g0,%i0\n.L3:\nret; restore\n.type memint,#function\n.size memint,.-memint\n.global regchar\n.align 4\nregchar:\nmov %o4,%o3\nadd %o3,1,%o4\nldsb [%o3],%o5\nadd %o4,1,%o3\nmov %o3,%o4\nldsb [%o3],%o5\nmov %o4,%o3\nadd %o3,-1,%o4\nldsb [%o3],%o5\nadd %o4,-1,%o3\nmov %o3,%o4\nldsb [%o3],%o5\nmov %g0,%o0\n.L4:\nretl; nop\n.type regchar,#function\n.size regchar,.-regchar\n.global regint\n.align 4\nregint:\nmov %o4,%o3\nadd %o3,4,%o4\nld [%o3],%o5\nadd %o4,4,%o3\nmov %o3,%o4\nld [%o3],%o5\nmov %o4,%o3\nadd %o3,-4,%o4\nld [%o3],%o5\nadd %o4,-4,%o3\nmov %o3,%o4\nld [%o3],%o5\nmov %g0,%o0\n.L5:\nretl; nop\n.type regint,#function\n.size regint,.-regint\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/init.1bk",
    "content": " 1 2 3 4\n 5 6\n 7\nif\nfor\nelse\nwhile\n1 2 3 if\n4 5 0 for\n6 7 8 else\n9 10 11 while\n1 2 3 if\n4 5 0 for\n6 7 8 else\n9 10 11 while\n0 0 0 \n"
  },
  {
    "path": "lcc/sparc/solaris/tst/init.2bk",
    "content": "tst/init.c:36: warning: missing return value\ntst/init.c:49: warning: missing return value\ntst/init.c:59: warning: missing return value\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/init.sbk",
    "content": ".section \".data\"\n.global words\n.type words,#object\n.align 4\nwords:\n.word 0x1\n.word 0x2\n.word 0x3\n.byte 105\n.byte 102\n.byte 0\n.skip 3\n.skip 2\n.word 0x4\n.word 0x5\n.skip 4\n.byte 102\n.byte 111\n.byte 114\n.skip 3\n.skip 2\n.word 0x6\n.word 0x7\n.word 0x8\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 0\n.skip 1\n.skip 2\n.word 0x9\n.word 0xa\n.word 0xb\n.byte 119\n.byte 104\n.byte 105\n.byte 108\n.byte 101\n.skip 1\n.skip 2\n.word 0x0\n.skip 8\n.skip 8\n.size words,100\n.global wordlist\n.type wordlist,#object\n.size wordlist,4\n.align 4\nwordlist:\n.word words\n.global x\n.type x,#object\n.align 4\nx:\n.word 0x1\n.word 0x2\n.word 0x3\n.word 0x4\n.word 0x0\n.word 0x5\n.word 0x6\n.skip 12\n.word 0x7\n.skip 16\n.size x,60\n.global y\n.type y,#object\n.align 4\ny:\n.word x\n.word x+20\n.word x+40\n.word 0x0\n.size y,16\n.global main\n.section \".text\"\n.align 4\nmain:\nsave %sp,-96,%sp\nmov %g0,%i4\nba .L8; nop\n.L5:\nmov %g0,%i5\nba .L12; nop\n.L9:\nset .L13,%o0\nsll %i5,2,%i3\nsll %i4,2,%i2\nset y,%i1\nld [%i2+%i1],%i2\nld [%i3+%i2],%o1\ncall printf; nop\n.L10:\nadd %i5,1,%i5\n.L12:\nsll %i5,2,%i3\nsll %i4,2,%i2\nset y,%i1\nld [%i2+%i1],%i2\nld [%i3+%i2],%i3\ncmp %i3,0; bne .L9; nop\nset .L14,%o0\ncall printf; nop\n.L6:\nadd %i4,1,%i4\n.L8:\nsll %i4,2,%i3\nset y,%i2\nld [%i3+%i2],%i3\ncmp %i3,%g0; bne .L5; nop\ncall f; nop\nset wordlist,%i3\nld [%i3],%o0\ncall g; nop\nmov %g0,%i0\n.L4:\nret; restore\n.type main,#function\n.size main,.-main\n.section \".data\"\n.type .16,#object\n.align 4\n.16:\n.word .L17\n.word .L18\n.word .L19\n.word .L20\n.word 0x0\n.size .16,20\n.global f\n.section \".text\"\n.align 4\nf:\nsave %sp,-96,%sp\nset .16,%i5\nba .L24; nop\n.L21:\nset .L25,%o0\nld [%i5],%o1\ncall printf; nop\n.L22:\nadd %i5,4,%i5\n.L24:\nld [%i5],%i4\ncmp %i4,%g0; bne .L21; nop\nmov %g0,%i0\n.L15:\nret; restore\n.type f,#function\n.size f,.-f\n.global g\n.align 4\ng:\nsave %sp,-96,%sp\nba .L30; nop\n.L27:\nmov %g0,%i5\nba .L34; nop\n.L31:\nset .L35,%o0\nsll %i5,2,%i4\nld [%i4+%i0],%o1\ncall printf; nop\n.L32:\nadd %i5,1,%i5\n.L34:\nmov %i5,%i4\nset 3,%i3\ncmp %i4,%i3; blu .L31; nop\nset .L25,%o0\nadd %i0,12,%o1\ncall printf; nop\n.L28:\nadd %i0,20,%i0\n.L30:\nld [%i0],%i4\ncmp %i4,0; bne .L27; nop\ncall h; nop\nmov %g0,%i0\n.L26:\nret; restore\n.type g,#function\n.size g,.-g\n.global h\n.align 4\nh:\nsave %sp,-96,%sp\nmov %g0,%i5\nba .L40; nop\n.L37:\nset .L41,%o0\nsmul %i5,20,%i4\nset words,%i3\nld [%i4+%i3],%o1\nset words+4,%i3\nld [%i4+%i3],%o2\nset words+8,%i3\nld [%i4+%i3],%o3\nset words+12,%i3\nadd %i4,%i3,%o4\ncall printf; nop\n.L38:\nadd %i5,1,%i5\n.L40:\nmov %i5,%i4\nset 5,%i3\ncmp %i4,%i3; blu .L37; nop\nmov %g0,%i0\n.L36:\nret; restore\n.type h,#function\n.size h,.-h\n.section \".rodata\"\n.align 1\n.L41:\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.L35:\n.byte 37\n.byte 100\n.byte 32\n.byte 0\n.align 1\n.L25:\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.L20:\n.byte 119\n.byte 104\n.byte 105\n.byte 108\n.byte 101\n.byte 0\n.align 1\n.L19:\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 0\n.align 1\n.L18:\n.byte 102\n.byte 111\n.byte 114\n.byte 0\n.align 1\n.L17:\n.byte 105\n.byte 102\n.byte 0\n.align 1\n.L14:\n.byte 10\n.byte 0\n.align 1\n.L13:\n.byte 32\n.byte 37\n.byte 100\n.byte 0\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/limits.1bk",
    "content": "UCHAR_MAX:\t000000ff=255\nUSHRT_MAX:\t0000ffff=65535\nUINT_MAX:\tffffffff=-1\nULONG_MAX:\tffffffff=-1\nCHAR_MAX:\t0000007f=127\nSCHAR_MAX:\t0000007f=127\nSHRT_MAX:\t00007fff=32767\nINT_MAX:\t7fffffff=2147483647\nLONG_MAX:\t7fffffff=2147483647\nCHAR_MIN:\tffffff80=-128\nSCHAR_MIN:\tffffff80=-128\nSHRT_MIN:\tffff8000=-32768\nINT_MIN:\t80000000=-2147483648\nLONG_MIN:\t80000000=-2147483648\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/limits.2bk",
    "content": ""
  },
  {
    "path": "lcc/sparc/solaris/tst/limits.sbk",
    "content": ".global main\n.section \".text\"\n.align 4\nmain:\nsave %sp,-96,%sp\nset .L2,%o0\nset 255,%i5\nmov %i5,%o1\nmov %i5,%o2\ncall printf; nop\nset .L3,%o0\nset 65535,%i5\nmov %i5,%o1\nmov %i5,%o2\ncall printf; nop\nset .L4,%o0\nset 0xffffffff,%i5\nmov %i5,%o1\nmov %i5,%o2\ncall printf; nop\nset .L5,%o0\nset 0xffffffff,%i5\nmov %i5,%o1\nmov %i5,%o2\ncall printf; nop\nset .L6,%o0\nset 127,%i5\nmov %i5,%o1\nmov %i5,%o2\ncall printf; nop\nset .L7,%o0\nset 127,%i5\nmov %i5,%o1\nmov %i5,%o2\ncall printf; nop\nset .L8,%o0\nset 32767,%i5\nmov %i5,%o1\nmov %i5,%o2\ncall printf; nop\nset .L9,%o0\nset 2147483647,%i5\nmov %i5,%o1\nmov %i5,%o2\ncall printf; nop\nset .L10,%o0\nset 2147483647,%i5\nmov %i5,%o1\nmov %i5,%o2\ncall printf; nop\nset .L11,%o0\nset -128,%i5\nmov %i5,%o1\nmov %i5,%o2\ncall printf; nop\nset .L12,%o0\nset -128,%i5\nmov %i5,%o1\nmov %i5,%o2\ncall printf; nop\nset .L13,%o0\nset -32768,%i5\nmov %i5,%o1\nmov %i5,%o2\ncall printf; nop\nset .L14,%o0\nset -2147483648,%i5\nmov %i5,%o1\nmov %i5,%o2\ncall printf; nop\nset .L15,%o0\nset -2147483648,%i5\nmov %i5,%o1\nmov %i5,%o2\ncall printf; nop\nmov %g0,%i0\n.L1:\nret; restore\n.type main,#function\n.size main,.-main\n.section \".rodata\"\n.align 1\n.L15:\n.byte 76\n.byte 79\n.byte 78\n.byte 71\n.byte 95\n.byte 77\n.byte 73\n.byte 78\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 108\n.byte 120\n.byte 61\n.byte 37\n.byte 108\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L14:\n.byte 73\n.byte 78\n.byte 84\n.byte 95\n.byte 77\n.byte 73\n.byte 78\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L13:\n.byte 83\n.byte 72\n.byte 82\n.byte 84\n.byte 95\n.byte 77\n.byte 73\n.byte 78\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L12:\n.byte 83\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 95\n.byte 77\n.byte 73\n.byte 78\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L11:\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 95\n.byte 77\n.byte 73\n.byte 78\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L10:\n.byte 76\n.byte 79\n.byte 78\n.byte 71\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 108\n.byte 120\n.byte 61\n.byte 37\n.byte 108\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L9:\n.byte 73\n.byte 78\n.byte 84\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L8:\n.byte 83\n.byte 72\n.byte 82\n.byte 84\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L7:\n.byte 83\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L6:\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L5:\n.byte 85\n.byte 76\n.byte 79\n.byte 78\n.byte 71\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 108\n.byte 120\n.byte 61\n.byte 37\n.byte 108\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L4:\n.byte 85\n.byte 73\n.byte 78\n.byte 84\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L3:\n.byte 85\n.byte 83\n.byte 72\n.byte 82\n.byte 84\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L2:\n.byte 85\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/paranoia.1bk",
    "content": "Lest this program stop prematurely, i.e. before displaying\n\n    `END OF TEST',\n\ntry to persuade the computer NOT to terminate execution when an\nerror like Over/Underflow or Division by Zero occurs, but rather\nto persevere with a surrogate value after, perhaps, displaying some\nwarning.  If persuasion avails naught, don't despair but run this\nprogram anyway to see how many milestones it passes, and then\namend it to make further progress.\n\nAnswer questions with Y, y, N or n (unless otherwise indicated).\n\n\nDiagnosis resumes after milestone Number 0          Page: 1\n\nUsers are invited to help debug and augment this program so it will\ncope with unanticipated and newly uncovered arithmetic pathologies.\n\nPlease send suggestions and interesting results to\n\tRichard Karpinski\n\tComputer Center U-76\n\tUniversity of California\n\tSan Francisco, CA 94143-0704, USA\n\nIn doing so, please include the following information:\n\tPrecision:\tdouble;\n\tVersion:\t10 February 1989;\n\tComputer:\n\n\tCompiler:\n\n\tOptimization level:\n\n\tOther relevant compiler options:\n\nDiagnosis resumes after milestone Number 1          Page: 2\n\nRunning this program should reveal these characteristics:\n     Radix = 1, 2, 4, 8, 10, 16, 100, 256 ...\n     Precision = number of significant digits carried.\n     U2 = Radix/Radix^Precision = One Ulp\n\t(OneUlpnit in the Last Place) of 1.000xxx .\n     U1 = 1/Radix^Precision = One Ulp of numbers a little less than 1.0 .\n     Adequacy of guard digits for Mult., Div. and Subt.\n     Whether arithmetic is chopped, correctly rounded, or something else\n\tfor Mult., Div., Add/Subt. and Sqrt.\n     Whether a Sticky Bit used correctly for rounding.\n     UnderflowThreshold = an underflow threshold.\n     E0 and PseudoZero tell whether underflow is abrupt, gradual, or fuzzy.\n     V = an overflow threshold, roughly.\n     V0  tells, roughly, whether  Infinity  is represented.\n     Comparisions are checked for consistency with subtraction\n\tand for contamination with pseudo-zeros.\n     Sqrt is tested.  Y^X is not tested.\n     Extra-precise subexpressions are revealed but NOT YET tested.\n     Decimal-Binary conversion is NOT YET tested for accuracy.\n\nDiagnosis resumes after milestone Number 2          Page: 3\n\nThe program attempts to discriminate among\n   FLAWs, like lack of a sticky bit,\n   Serious DEFECTs, like lack of a guard digit, and\n   FAILUREs, like 2+2 == 5 .\nFailures may confound subsequent diagnoses.\n\nThe diagnostic capabilities of this program go beyond an earlier\nprogram called `MACHAR', which can be found at the end of the\nbook  `Software Manual for the Elementary Functions' (1980) by\nW. J. Cody and W. Waite. Although both programs try to discover\nthe Radix, Precision and range (over/underflow thresholds)\nof the arithmetic, this program tries to cope with a wider variety\nof pathologies, and to say how well the arithmetic is implemented.\n\nThe program is based upon a conventional radix representation for\nfloating-point numbers, but also allows logarithmic encoding\nas used by certain early WANG machines.\n\nBASIC version of this program (C) 1983 by Prof. W. M. Kahan;\nsee source comments for more history.\n\nDiagnosis resumes after milestone Number 3          Page: 4\n\nProgram is now RUNNING tests on small integers:\n-1, 0, 1/2, 1, 2, 3, 4, 5, 9, 27, 32 & 240 are O.K.\n\nSearching for Radix and Precision.\nRadix = 2.000000 .\nClosest relative separation found is U1 = 1.1102230e-16 .\n\nRecalculating radix and precision\n confirms closest relative separation U1 .\nRadix confirmed.\nThe number of significant digits of the Radix is 53.000000 .\n\nDiagnosis resumes after milestone Number 30          Page: 5\n\nSubtraction appears to be normalized, as it should be.\nChecking for guard digit in *, /, and -.\n     *, /, and - appear to have guard digits, as they should.\n\nDiagnosis resumes after milestone Number 40          Page: 6\n\nChecking rounding on multiply, divide and add/subtract.\nMultiplication appears to round correctly.\nDivision appears to round correctly.\nAddition/Subtraction appears to round correctly.\nChecking for sticky bit.\nSticky bit apparently used correctly.\n\nDoes Multiplication commute?  Testing on 20 random pairs.\n     No failures found in 20 integer pairs.\n\nRunning test of square root(x).\nTesting if sqrt(X * X) == X for 20 Integers X.\nTest for sqrt monotonicity.\nsqrt has passed a test for Monotonicity.\nTesting whether sqrt is rounded or chopped.\nSquare root appears to be correctly rounded.\n\nDiagnosis resumes after milestone Number 90          Page: 7\n\nTesting powers Z^i for small Integers Z and i.\n... no discrepancis found.\n\nSeeking Underflow thresholds UfThold and E0.\nSmallest strictly positive number found is E0 = 4.94066e-324 .\nSince comparison denies Z = 0, evaluating (Z + Z) / Z should be safe.\nWhat the machine gets for (Z + Z) / Z is  2.00000000000000000e+00 .\nThis is O.K., provided Over/Underflow has NOT just been signaled.\nUnderflow is gradual; it incurs Absolute Error =\n(roundoff in UfThold) < E0.\nThe Underflow threshold is 2.22507385850720188e-308,  below which\ncalculation may suffer larger Relative error than merely roundoff.\nSince underflow occurs below the threshold\nUfThold = (2.00000000000000000e+00) ^ (-1.02200000000000000e+03)\nonly underflow should afflict the expression\n\t(2.00000000000000000e+00) ^ (-1.02200000000000000e+03);\nactually calculating yields: 0.00000000000000000e+00 .\nThis computed value is O.K.\n\nTesting X^((X + 1) / (X - 1)) vs. exp(2) = 7.38905609893065218e+00 as X -> 1.\nAccuracy seems adequate.\nTesting powers Z^Q at four nearly extreme values.\n ... no discrepancies found.\n\n\nDiagnosis resumes after milestone Number 160          Page: 8\n\nSearching for Overflow threshold:\nThis may generate an error.\nCan `Z = -Y' overflow?\nTrying it on Y = -Infinity .\nSeems O.K.\nOverflow threshold is V  = 1.79769313486231571e+308 .\nOverflow saturates at V0 = Infinity .\nNo Overflow should be signaled for V * 1 = 1.79769313486231571e+308\n                           nor for V / 1 = 1.79769313486231571e+308 .\nAny overflow signal separating this * from the one\nabove is a DEFECT.\n\n\nDiagnosis resumes after milestone Number 190          Page: 9\n\n\nWhat message and/or values does Division by Zero produce?\n    Trying to compute 1 / 0 produces ...  Infinity .\n\n    Trying to compute 0 / 0 produces ...  NaN .\n\nDiagnosis resumes after milestone Number 220          Page: 10\n\n\n\nNo failures, defects nor flaws have been discovered.\nRounding appears to conform to the proposed IEEE standard P754.\nThe arithmetic diagnosed appears to be Excellent!\nEND OF TEST.\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/paranoia.2bk",
    "content": "tst/paranoia.c:1867: warning: missing return value\ntst/paranoia.c:1874: warning: missing return value\ntst/paranoia.c:1884: warning: missing return value\ntst/paranoia.c:1924: warning: missing return value\ntst/paranoia.c:1939: warning: missing return value\ntst/paranoia.c:1956: warning: missing return value\ntst/paranoia.c:1975: warning: missing return value\ntst/paranoia.c:1988: warning: missing return value\ntst/paranoia.c:1995: warning: missing return value\ntst/paranoia.c:2055: warning: missing return value\ntst/paranoia.c:2062: warning: missing return value\ntst/paranoia.c:2070: warning: missing return value\ntst/paranoia.c:2087: warning: missing return value\ntst/paranoia.c:2115: warning: missing return value\ntst/paranoia.c:2144: warning: missing return value\ntst/paranoia.c:2173: warning: missing return value\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/paranoia.sbk",
    "content": ".section \".data\"\n.global Zero\n.type Zero,#object\n.size Zero,8\n.align 8\nZero:\n.word 0x0\n.word 0x0\n.global Half\n.type Half,#object\n.size Half,8\n.align 8\nHalf:\n.word 0x3fe00000\n.word 0x0\n.global One\n.type One,#object\n.size One,8\n.align 8\nOne:\n.word 0x3ff00000\n.word 0x0\n.global Two\n.type Two,#object\n.size Two,8\n.align 8\nTwo:\n.word 0x40000000\n.word 0x0\n.global Three\n.type Three,#object\n.size Three,8\n.align 8\nThree:\n.word 0x40080000\n.word 0x0\n.global Four\n.type Four,#object\n.size Four,8\n.align 8\nFour:\n.word 0x40100000\n.word 0x0\n.global Five\n.type Five,#object\n.size Five,8\n.align 8\nFive:\n.word 0x40140000\n.word 0x0\n.global Eight\n.type Eight,#object\n.size Eight,8\n.align 8\nEight:\n.word 0x40200000\n.word 0x0\n.global Nine\n.type Nine,#object\n.size Nine,8\n.align 8\nNine:\n.word 0x40220000\n.word 0x0\n.global TwentySeven\n.type TwentySeven,#object\n.size TwentySeven,8\n.align 8\nTwentySeven:\n.word 0x403b0000\n.word 0x0\n.global ThirtyTwo\n.type ThirtyTwo,#object\n.size ThirtyTwo,8\n.align 8\nThirtyTwo:\n.word 0x40400000\n.word 0x0\n.global TwoForty\n.type TwoForty,#object\n.size TwoForty,8\n.align 8\nTwoForty:\n.word 0x406e0000\n.word 0x0\n.global MinusOne\n.type MinusOne,#object\n.size MinusOne,8\n.align 8\nMinusOne:\n.word 0xbff00000\n.word 0x0\n.global OneAndHalf\n.type OneAndHalf,#object\n.size OneAndHalf,8\n.align 8\nOneAndHalf:\n.word 0x3ff80000\n.word 0x0\n.global NoTrials\n.type NoTrials,#object\n.size NoTrials,4\n.align 4\nNoTrials:\n.word 0x14\n.global sigfpe\n.section \".text\"\n.align 4\nsigfpe:\nsave %sp,-96,%sp\nset fpecount,%i5\nld [%i5],%i4\nadd %i4,1,%i4\nst %i4,[%i5]\nset .L3,%o0\ncall printf; nop\nset __iob+16,%o0\ncall fflush; nop\nset sigsave,%i5\nld [%i5],%i5\ncmp %i5,%g0; be .L5; nop\nset 8,%o0\nset sigsave,%i5\nld [%i5],%o1\ncall signal; nop\nset sigsave,%i5\nst %g0,[%i5]\nset ovfl_buf,%o0\nset 1,%o1\ncall longjmp; nop\n.L5:\ncall abort; nop\n.L2:\nret; restore\n.type sigfpe,#function\n.size sigfpe,.-sigfpe\n.section \".data\"\n.type .758,#object\n.align 4\n.758:\n.word .L759\n.word .L760\n.word .L761\n.word .L762\n.size .758,16\n.global main\n.section \".text\"\n.align 4\nmain:\nsave %sp,-216,%sp\nset Zero,%i5\nset .L8,%i4\nld2 [%i4],%f30\nst2 %f30,[%i5]\nset One,%i5\nset .L9,%i4\nld2 [%i4],%f30\nst2 %f30,[%i5]\nset Two,%i4\nld2 [%i5],%f30\nfaddd %f30,%f30,%f28\nst2 %f28,[%i4]\nset Three,%i5\nld2 [%i4],%f28\nfaddd %f28,%f30,%f26\nst2 %f26,[%i5]\nset Four,%i4\nld2 [%i5],%f26\nfaddd %f26,%f30,%f24\nst2 %f24,[%i4]\nset Five,%i5\nld2 [%i4],%f24\nfaddd %f24,%f30,%f22\nst2 %f22,[%i5]\nset Eight,%i4\nfaddd %f24,%f24,%f22\nst2 %f22,[%i4]\nset Nine,%i3\nfmuld %f26,%f26,%f22\nst2 %f22,[%i3]\nset TwentySeven,%i2\nld2 [%i3],%f22\nfmuld %f22,%f26,%f22\nst2 %f22,[%i2]\nset ThirtyTwo,%i3\nld2 [%i4],%f22\nfmuld %f24,%f22,%f22\nst2 %f22,[%i3]\nset TwoForty,%i4\nld2 [%i5],%f22\nfmuld %f24,%f22,%f22\nfmuld %f22,%f26,%f26\nfmuld %f26,%f24,%f26\nst2 %f26,[%i4]\nset MinusOne,%i5\nfnegs %f30,%f26; fmovs %f31,%f27\nst2 %f26,[%i5]\nset Half,%i5\nfdivd %f30,%f28,%f28\nst2 %f28,[%i5]\nset OneAndHalf,%i4\nld2 [%i5],%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%i4]\nset ErrCnt,%i4\nst %g0,[%i4]\nset ErrCnt+4,%i4\nst %g0,[%i4]\nset ErrCnt+8,%i5\nst %g0,[%i5]\nset ErrCnt+12,%i5\nst %g0,[%i5]\nset PageNo,%i5\nset 1,%i4\nst %i4,[%i5]\nset Milestone,%i5\nst %g0,[%i5]\nset 8,%o0\nset sigfpe,%o1\ncall signal; nop\ncall Instructions; nop\ncall Pause; nop\ncall Heading; nop\ncall Pause; nop\ncall Characteristics; nop\ncall Pause; nop\ncall History; nop\ncall Pause; nop\nset Milestone,%i5\nset 7,%i4\nst %i4,[%i5]\nset .L13,%o0\ncall printf; nop\nmov %g0,%o0\nset Zero,%i4\nld2 [%i4],%f30\nfaddd %f30,%f30,%f28\nfcmped %f28,%f30; nop; fbne .L16; nop\nset One,%i4\nld2 [%i4],%f28\nfsubd %f28,%f28,%f26\nfcmped %f26,%f30; nop; fbne .L16; nop\nfcmped %f28,%f30; nop; fbule .L16; nop\nfaddd %f28,%f28,%f30\nset Two,%i4\nld2 [%i4],%f28\nfcmped %f30,%f28; nop; fbne .L16; nop\nset 1,%i5\nba .L17; nop\n.L16:\nmov %g0,%i5\n.L17:\nmov %i5,%o1\nset .L15,%o2\ncall TstCond; nop\nset Z,%i4\nset Zero,%i3\nld2 [%i3],%f30\nfnegs %f30,%f30; fmovs %f31,%f31\nst2 %f30,[%i4]\nld2 [%i4],%f30\nset .L8,%i4\nld2 [%i4],%f28\nfcmped %f30,%f28; nop; fbue .L18; nop\nset ErrCnt,%i4\nld [%i4],%i3\nadd %i3,1,%i3\nst %i3,[%i4]\nset .L20,%o0\ncall printf; nop\nset U1,%i4\nset .L21,%i3\nld2 [%i3],%f30\nst2 %f30,[%i4]\nset Radix,%i4\nset .L9,%i3\nld2 [%i3],%f30\nst2 %f30,[%i4]\ncall TstPtUf; nop\n.L18:\nmov %g0,%o0\nset Three,%i3\nld2 [%i3],%f30\nset Two,%i3\nld2 [%i3],%f28\nset One,%i3\nld2 [%i3],%f26\nfaddd %f28,%f26,%f24\nfcmped %f30,%f24; nop; fbne .L24; nop\nset Four,%i3\nld2 [%i3],%f24\nfaddd %f30,%f26,%f22\nfcmped %f24,%f22; nop; fbne .L24; nop\nset Zero,%i3\nld2 [%i3],%f22\nfnegs %f28,%f20; fmovs %f29,%f21\nfmuld %f28,%f20,%f28\nfaddd %f24,%f28,%f28\nfcmped %f28,%f22; nop; fbne .L24; nop\nfsubd %f24,%f30,%f30\nfsubd %f30,%f26,%f30\nfcmped %f30,%f22; nop; fbne .L24; nop\nset 1,%i4\nba .L25; nop\n.L24:\nmov %g0,%i4\n.L25:\nmov %i4,%o1\nset .L23,%o2\ncall TstCond; nop\nset MinusOne,%i2\nld2 [%i2],%f30\nstd %f30,[%fp+-8]\nset One,%i2\nld2 [%i2],%f28\nset .L8,%i2\nld2 [%i2],%f26\nfsubd %f26,%f28,%f26\nfcmped %f30,%f26; nop; fbne .L28; nop\nset Zero,%i2\nld2 [%i2],%f26\nfaddd %f30,%f28,%f24\nfcmped %f24,%f26; nop; fbne .L28; nop\nfaddd %f28,%f30,%f24\nfcmped %f24,%f26; nop; fbne .L28; nop\nst %f28,[%sp+4*0+68]\nst %f29,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall fabs; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Zero,%i2\nld2 [%i2],%f28\nldd [%fp+-8],%f26\nfaddd %f26,%f30,%f30\nfcmped %f30,%f28; nop; fbne .L28; nop\nset MinusOne,%i2\nld2 [%i2],%f30\nfmuld %f30,%f30,%f26\nfaddd %f30,%f26,%f30\nfcmped %f30,%f28; nop; fbne .L28; nop\nset 1,%i3\nba .L29; nop\n.L28:\nmov %g0,%i3\n.L29:\nmov %g0,%o0\nmov %i3,%o1\nset .L27,%o2\ncall TstCond; nop\nmov %g0,%o0\nset Half,%i1\nld2 [%i1],%f30\nset MinusOne,%i1\nld2 [%i1],%f28\nfaddd %f30,%f28,%f28\nfaddd %f28,%f30,%f30\nset Zero,%i1\nld2 [%i1],%f28\nfcmped %f30,%f28; nop; fbne .L32; nop\nset 1,%i2\nba .L33; nop\n.L32:\nmov %g0,%i2\n.L33:\nmov %i2,%o1\nset .L31,%o2\ncall TstCond; nop\nset Milestone,%i0\nset 10,%l7\nst %l7,[%i0]\nmov %g0,%o0\nset Nine,%i0\nld2 [%i0],%f30\nset Three,%i0\nld2 [%i0],%f28\nfmuld %f28,%f28,%f26\nfcmped %f30,%f26; nop; fbne .L36; nop\nset TwentySeven,%i0\nld2 [%i0],%f26\nfmuld %f30,%f28,%f30\nfcmped %f26,%f30; nop; fbne .L36; nop\nset Eight,%i0\nld2 [%i0],%f30\nset Four,%i0\nld2 [%i0],%f28\nfaddd %f28,%f28,%f24\nfcmped %f30,%f24; nop; fbne .L36; nop\nset ThirtyTwo,%i0\nld2 [%i0],%f24\nfmuld %f30,%f28,%f30\nfcmped %f24,%f30; nop; fbne .L36; nop\nfsubd %f24,%f26,%f30\nfsubd %f30,%f28,%f30\nset One,%i0\nld2 [%i0],%f28\nfsubd %f30,%f28,%f30\nset Zero,%i0\nld2 [%i0],%f28\nfcmped %f30,%f28; nop; fbne .L36; nop\nset 1,%i1\nba .L37; nop\n.L36:\nmov %g0,%i1\n.L37:\nmov %i1,%o1\nset .L35,%o2\ncall TstCond; nop\nmov %g0,%o0\nset Five,%l7\nld2 [%l7],%f30\nset Four,%l7\nld2 [%l7],%f28\nset One,%l7\nld2 [%l7],%f26\nfaddd %f28,%f26,%f26\nfcmped %f30,%f26; nop; fbne .L40; nop\nset TwoForty,%l7\nld2 [%l7],%f26\nset Three,%l7\nld2 [%l7],%f24\nfmuld %f28,%f30,%f22\nfmuld %f22,%f24,%f22\nfmuld %f22,%f28,%f22\nfcmped %f26,%f22; nop; fbne .L40; nop\nset Zero,%l7\nld2 [%l7],%f22\nfdivd %f26,%f24,%f20\nfmuld %f28,%f28,%f18\nfmuld %f18,%f30,%f18\nfsubd %f20,%f18,%f20\nfcmped %f20,%f22; nop; fbne .L40; nop\nfdivd %f26,%f28,%f20\nfmuld %f30,%f24,%f18\nfmuld %f18,%f28,%f18\nfsubd %f20,%f18,%f20\nfcmped %f20,%f22; nop; fbne .L40; nop\nfdivd %f26,%f30,%f30\nfmuld %f28,%f24,%f26\nfmuld %f26,%f28,%f28\nfsubd %f30,%f28,%f30\nfcmped %f30,%f22; nop; fbne .L40; nop\nset 1,%i0\nba .L41; nop\n.L40:\nmov %g0,%i0\n.L41:\nmov %i0,%o1\nset .L39,%o2\ncall TstCond; nop\nset ErrCnt,%l7\nld [%l7],%l7\ncmp %l7,0; bne .L42; nop\nset .L44,%o0\ncall printf; nop\nset .L45,%o0\ncall printf; nop\n.L42:\nset .L46,%o0\ncall printf; nop\nset W,%l7\nset One,%l6\nld2 [%l6],%f30\nst2 %f30,[%l7]\n.L47:\nset W,%l7\nld2 [%l7],%f30\nfaddd %f30,%f30,%f30\nst2 %f30,[%l7]\nset Y,%l6\nld2 [%l7],%f30\nset One,%l7\nld2 [%l7],%f28\nfaddd %f30,%f28,%f26\nst2 %f26,[%l6]\nset Z,%l7\nld2 [%l6],%f26\nfsubd %f26,%f30,%f30\nst2 %f30,[%l7]\nld2 [%l7],%f30\nfsubd %f30,%f28,%f30\nst2 %f30,[%l6]\n.L48:\nset Y,%l7\nld2 [%l7],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall fabs; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset MinusOne,%l7\nld2 [%l7],%f28\nfaddd %f28,%f30,%f30\nset Zero,%l7\nld2 [%l7],%f28\nfcmped %f30,%f28; nop; fbul .L47; nop\nset Precision,%l7\nset Zero,%l6\nld2 [%l6],%f30\nst2 %f30,[%l7]\nset Y,%l7\nset One,%l6\nld2 [%l6],%f30\nst2 %f30,[%l7]\n.L50:\nset Radix,%l7\nset W,%l6\nld2 [%l6],%f30\nset Y,%l6\nld2 [%l6],%f28\nfaddd %f30,%f28,%f26\nst2 %f26,[%l7]\nfaddd %f28,%f28,%f28\nst2 %f28,[%l6]\nld2 [%l7],%f28\nfsubd %f28,%f30,%f30\nst2 %f30,[%l7]\n.L51:\nset Radix,%l7\nld2 [%l7],%f30\nset Zero,%l7\nld2 [%l7],%f28\nfcmped %f30,%f28; nop; fbue .L50; nop\nset Radix,%l7\nld2 [%l7],%f30\nset Two,%l7\nld2 [%l7],%f28\nfcmped %f30,%f28; nop; fbuge .L53; nop\nset Radix,%l7\nset One,%l6\nld2 [%l6],%f30\nst2 %f30,[%l7]\n.L53:\nset .L55,%o0\nset Radix,%l7\nld2 [%l7],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset Radix,%l7\nld2 [%l7],%f30\nset .L9,%l7\nld2 [%l7],%f28\nfcmped %f30,%f28; nop; fbue .L56; nop\nset W,%l7\nset One,%l6\nld2 [%l6],%f30\nst2 %f30,[%l7]\n.L58:\nset Precision,%l7\nset One,%l6\nld2 [%l6],%f30\nld2 [%l7],%f28\nfaddd %f28,%f30,%f28\nst2 %f28,[%l7]\nset W,%l7\nld2 [%l7],%f28\nset Radix,%l6\nld2 [%l6],%f26\nfmuld %f28,%f26,%f28\nst2 %f28,[%l7]\nset Y,%l6\nld2 [%l7],%f28\nfaddd %f28,%f30,%f30\nst2 %f30,[%l6]\n.L59:\nset Y,%l7\nld2 [%l7],%f30\nset W,%l7\nld2 [%l7],%f28\nfsubd %f30,%f28,%f30\nset One,%l7\nld2 [%l7],%f28\nfcmped %f30,%f28; nop; fbue .L58; nop\n.L56:\nset U1,%l7\nset One,%l6\nld2 [%l6],%f30\nset W,%l6\nld2 [%l6],%f28\nfdivd %f30,%f28,%f30\nst2 %f30,[%l7]\nld2 [%l7],%f30\nset U2,%l7\nset Radix,%l6\nld2 [%l6],%f28\nfmuld %f28,%f30,%f28\nst2 %f28,[%l7]\nset .L61,%o0\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset .L62,%o0\ncall printf; nop\nset E0,%l7\nset Radix,%l6\nld2 [%l6],%f30\nst2 %f30,[%l7]\nset E1,%l7\nset U1,%l6\nld2 [%l6],%f30\nst2 %f30,[%l7]\nset E9,%l7\nset U2,%l6\nld2 [%l6],%f30\nst2 %f30,[%l7]\nset E3,%l7\nset Precision,%l6\nld2 [%l6],%f30\nst2 %f30,[%l7]\nset X,%l7\nset Four,%l6\nld2 [%l6],%f30\nset Three,%l6\nld2 [%l6],%f28\nfdivd %f30,%f28,%f30\nst2 %f30,[%l7]\nset Third,%l6\nld2 [%l7],%f30\nset One,%l5\nld2 [%l5],%f28\nfsubd %f30,%f28,%f30\nst2 %f30,[%l6]\nset F6,%l5\nld2 [%l6],%f30\nset Half,%l6\nld2 [%l6],%f28\nfsubd %f28,%f30,%f28\nst2 %f28,[%l5]\nld2 [%l5],%f28\nfaddd %f28,%f28,%f28\nst2 %f28,[%l7]\nld2 [%l7],%f28\nfsubd %f28,%f30,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall fabs; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nst2 %f30,[%l7]\nset X,%l7\nld2 [%l7],%f30\nset U2,%l7\nld2 [%l7],%f28\nfcmped %f30,%f28; nop; fbuge .L63; nop\nset X,%l7\nset U2,%l6\nld2 [%l6],%f30\nst2 %f30,[%l7]\n.L63:\n.L65:\nset U2,%l7\nset X,%l6\nld2 [%l6],%f30\nst2 %f30,[%l7]\nset Y,%l5\nld2 [%l7],%f30\nset Half,%l7\nld2 [%l7],%f28\nfmuld %f28,%f30,%f28\nset ThirtyTwo,%l7\nld2 [%l7],%f26\nfmuld %f26,%f30,%f26\nfmuld %f26,%f30,%f30\nfaddd %f28,%f30,%f30\nst2 %f30,[%l5]\nset One,%l7\nld2 [%l7],%f30\nld2 [%l5],%f28\nfaddd %f30,%f28,%f28\nst2 %f28,[%l5]\nld2 [%l5],%f28\nfsubd %f28,%f30,%f30\nst2 %f30,[%l6]\n.L66:\nset X,%l7\nld2 [%l7],%f30\nset U2,%l7\nld2 [%l7],%f28\nfcmped %f28,%f30; nop; fbule .L68; nop\nset Zero,%l7\nld2 [%l7],%f28\nfcmped %f30,%f28; nop; fbug .L65; nop\n.L68:\nset X,%l7\nset Two,%l6\nld2 [%l6],%f30\nset Three,%l6\nld2 [%l6],%f28\nfdivd %f30,%f28,%f30\nst2 %f30,[%l7]\nset F6,%l6\nset Half,%l5\nld2 [%l5],%f30\nld2 [%l7],%f28\nfsubd %f28,%f30,%f28\nst2 %f28,[%l6]\nset Third,%l5\nld2 [%l6],%f28\nfaddd %f28,%f28,%f26\nst2 %f26,[%l5]\nld2 [%l5],%f26\nfsubd %f26,%f30,%f30\nst2 %f30,[%l7]\nld2 [%l7],%f30\nfaddd %f30,%f28,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall fabs; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nst2 %f30,[%l7]\nset X,%l7\nld2 [%l7],%f30\nset U1,%l7\nld2 [%l7],%f28\nfcmped %f30,%f28; nop; fbuge .L69; nop\nset X,%l7\nset U1,%l6\nld2 [%l6],%f30\nst2 %f30,[%l7]\n.L69:\n.L71:\nset U1,%l7\nset X,%l6\nld2 [%l6],%f30\nst2 %f30,[%l7]\nset Y,%l5\nset Half,%l4\nld2 [%l4],%f30\nld2 [%l7],%f28\nfmuld %f30,%f28,%f26\nset ThirtyTwo,%l7\nld2 [%l7],%f24\nfmuld %f24,%f28,%f24\nfmuld %f24,%f28,%f28\nfaddd %f26,%f28,%f28\nst2 %f28,[%l5]\nld2 [%l5],%f28\nfsubd %f30,%f28,%f28\nst2 %f28,[%l5]\nld2 [%l5],%f28\nfaddd %f30,%f28,%f28\nst2 %f28,[%l6]\nld2 [%l6],%f28\nfsubd %f30,%f28,%f28\nst2 %f28,[%l5]\nld2 [%l5],%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l6]\n.L72:\nset X,%l7\nld2 [%l7],%f30\nset U1,%l7\nld2 [%l7],%f28\nfcmped %f28,%f30; nop; fbule .L74; nop\nset Zero,%l7\nld2 [%l7],%f28\nfcmped %f30,%f28; nop; fbug .L71; nop\n.L74:\nset U1,%l7\nld2 [%l7],%f30\nset E1,%l7\nld2 [%l7],%f28\nfcmped %f30,%f28; nop; fbne .L75; nop\nset .L77,%o0\ncall printf; nop\nba .L76; nop\n.L75:\nset .L78,%o0\nset U1,%l7\nld2 [%l7],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\n.L76:\nset U1,%l7\nld2 [%l7],%f30\nset W,%l7\nset One,%l6\nld2 [%l6],%f28\nfdivd %f28,%f30,%f28\nst2 %f28,[%l7]\nset Half,%l7\nld2 [%l7],%f28\nset F9,%l7\nfsubd %f28,%f30,%f26\nfaddd %f26,%f28,%f28\nst2 %f28,[%l7]\nset U2,%l7\nld2 [%l7],%f28\nfdivd %f28,%f30,%f30\nset .L79,%l7\nld2 [%l7],%f28\nfaddd %f30,%f28,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Radix,%l7\nst2 %f30,[%l7]\nset Radix,%l7\nld2 [%l7],%f30\nset E0,%l7\nld2 [%l7],%f28\nfcmped %f30,%f28; nop; fbne .L80; nop\nset .L82,%o0\ncall printf; nop\nba .L81; nop\n.L80:\nset .L83,%o0\nset Radix,%l7\nld2 [%l7],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\n.L81:\nset 2,%o0\nset Eight,%l6\nld2 [%l6],%f30\nset Radix,%l6\nld2 [%l6],%f28\nfaddd %f30,%f30,%f30\nfcmped %f28,%f30; nop; fbug .L86; nop\nset 1,%l7\nba .L87; nop\n.L86:\nmov %g0,%l7\n.L87:\nmov %l7,%o1\nset .L85,%o2\ncall TstCond; nop\nset 3,%o0\nset Radix,%l5\nld2 [%l5],%f30\nset Two,%l5\nld2 [%l5],%f28\nfcmped %f30,%f28; nop; fbue .L93; nop\nset .L94,%l5\nld2 [%l5],%f28\nfcmped %f30,%f28; nop; fbue .L93; nop\nset One,%l5\nld2 [%l5],%f28\nfcmped %f30,%f28; nop; fbne .L90; nop\n.L93:\nset 1,%l6\nba .L91; nop\n.L90:\nmov %g0,%l6\n.L91:\nmov %l6,%o1\nset .L89,%o2\ncall TstCond; nop\nset Milestone,%l4\nset 20,%l3\nst %l3,[%l4]\nmov %g0,%o0\nset Half,%l4\nld2 [%l4],%f30\nset F9,%l4\nld2 [%l4],%f28\nfsubd %f28,%f30,%f28\nfcmped %f28,%f30; nop; fbuge .L97; nop\nset 1,%l5\nba .L98; nop\n.L97:\nmov %g0,%l5\n.L98:\nmov %l5,%o1\nset .L96,%o2\ncall TstCond; nop\nset X,%l3\nset F9,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset I,%l2\nset 1,%l1\nst %l1,[%l2]\nset Y,%l2\nset Half,%l1\nld2 [%l1],%f30\nld2 [%l3],%f28\nfsubd %f28,%f30,%f28\nst2 %f28,[%l2]\nset Z,%l3\nld2 [%l2],%f28\nfsubd %f28,%f30,%f30\nst2 %f30,[%l3]\nmov %g0,%o0\nset X,%l3\nld2 [%l3],%f30\nset One,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L103; nop\nset Z,%l3\nld2 [%l3],%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L101; nop\n.L103:\nset 1,%l4\nba .L102; nop\n.L101:\nmov %g0,%l4\n.L102:\nmov %l4,%o1\nset .L100,%o2\ncall TstCond; nop\nset One,%l3\nld2 [%l3],%f30\nset U2,%l3\nld2 [%l3],%f28\nset X,%l3\nfaddd %f30,%f28,%f26\nst2 %f26,[%l3]\nset I,%l3\nst %g0,[%l3]\nset Milestone,%l3\nset 25,%l2\nst %l2,[%l3]\nset BMinusU2,%l3\nset Radix,%l2\nld2 [%l2],%f26\nfsubd %f26,%f30,%f24\nst2 %f24,[%l3]\nld2 [%l3],%f24\nfsubd %f24,%f28,%f28\nfaddd %f28,%f30,%f28\nst2 %f28,[%l3]\nfcmped %f26,%f30; nop; fbue .L104; nop\nset U1,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall log; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nstd %f30,[%fp+-16]\nset Radix,%l3\nld2 [%l3],%f28\nst %f28,[%sp+4*0+68]\nst %f29,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall log; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset X,%l3\nset TwoForty,%l2\nld2 [%l2],%f28\nfnegs %f28,%f28; fmovs %f29,%f29\nldd [%fp+-16],%f26\nfmuld %f28,%f26,%f28\nfdivd %f28,%f30,%f30\nst2 %f30,[%l3]\nset Half,%l3\nld2 [%l3],%f30\nset X,%l3\nld2 [%l3],%f28\nfaddd %f30,%f28,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Y,%l3\nst2 %f30,[%l3]\nset X,%l3\nld2 [%l3],%f30\nset Y,%l3\nld2 [%l3],%f28\nfsubd %f30,%f28,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall fabs; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Four,%l3\nld2 [%l3],%f28\nfmuld %f30,%f28,%f30\nset One,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbuge .L106; nop\nset X,%l3\nset Y,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L106:\nset Precision,%l3\nset X,%l2\nld2 [%l2],%f30\nset TwoForty,%l2\nld2 [%l2],%f28\nfdivd %f30,%f28,%f30\nst2 %f30,[%l3]\nset Half,%l2\nld2 [%l2],%f30\nld2 [%l3],%f28\nfaddd %f30,%f28,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Y,%l3\nst2 %f30,[%l3]\nset Precision,%l3\nld2 [%l3],%f30\nset Y,%l3\nld2 [%l3],%f28\nfsubd %f30,%f28,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall fabs; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset TwoForty,%l3\nld2 [%l3],%f28\nfmuld %f30,%f28,%f30\nset Half,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbuge .L108; nop\nset Precision,%l3\nset Y,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L108:\n.L104:\nset Precision,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-16]\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nldd [%fp+-16],%f28\nfcmped %f28,%f30; nop; fbne .L112; nop\nset Radix,%l3\nld2 [%l3],%f30\nset One,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L110; nop\n.L112:\nset .L113,%o0\ncall printf; nop\nset .L114,%o0\ncall printf; nop\n.L110:\nset Radix,%l3\nld2 [%l3],%f30\nset One,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L115; nop\nset .L117,%o0\ncall printf; nop\nba .L116; nop\n.L115:\nset .L118,%o0\nset Precision,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\n.L116:\nset 1,%o0\nset Nine,%l3\nld2 [%l3],%f30\nset U2,%l3\nld2 [%l3],%f28\nfmuld %f28,%f30,%f28\nfmuld %f28,%f30,%f30\nset TwoForty,%l3\nld2 [%l3],%f28\nfmuld %f30,%f28,%f30\nset One,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbuge .L121; nop\nset 1,%l3\nst %l3,[%fp+-20]\nba .L122; nop\n.L121:\nst %g0,[%fp+-20]\n.L122:\nld [%fp+-20],%o1\nset .L120,%o2\ncall TstCond; nop\nset Milestone,%l3\nset 30,%l2\nst %l2,[%l3]\nset Four,%l3\nld2 [%l3],%f30\nset Three,%l3\nld2 [%l3],%f28\nset One,%l3\nld2 [%l3],%f26\nfdivd %f26,%f30,%f24\nfdivd %f30,%f28,%f30\nfsubd %f30,%f26,%f30\nfsubd %f30,%f24,%f30\nfmuld %f30,%f28,%f30\nfsubd %f30,%f24,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall fabs; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset X,%l3\nst2 %f30,[%l3]\n.L123:\nset Z2,%l3\nset X,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset One,%l1\nld2 [%l1],%f30\nld2 [%l3],%f28\nset Half,%l3\nld2 [%l3],%f26\nfmuld %f26,%f28,%f26\nset ThirtyTwo,%l3\nld2 [%l3],%f24\nfmuld %f24,%f28,%f24\nfmuld %f24,%f28,%f28\nfaddd %f26,%f28,%f28\nfaddd %f30,%f28,%f28\nfsubd %f28,%f30,%f30\nst2 %f30,[%l2]\n.L124:\nset X,%l3\nld2 [%l3],%f30\nset Z2,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbule .L126; nop\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbug .L123; nop\n.L126:\nset Three,%l3\nld2 [%l3],%f30\nset Four,%l3\nld2 [%l3],%f28\nfdivd %f30,%f28,%f26\nset Two,%l3\nld2 [%l3],%f24\nfdivd %f24,%f30,%f24\nfsubd %f26,%f24,%f26\nfmuld %f26,%f30,%f30\nset One,%l3\nld2 [%l3],%f26\nfdivd %f26,%f28,%f28\nfsubd %f30,%f28,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall fabs; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Z,%l3\nst2 %f30,[%l3]\nset Y,%l3\nst2 %f30,[%l3]\nset X,%l3\nst2 %f30,[%l3]\n.L127:\nset Z1,%l3\nset Z,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset One,%l1\nld2 [%l1],%f30\nset Two,%l1\nld2 [%l1],%f28\nfdivd %f30,%f28,%f30\nld2 [%l3],%f28\nset Half,%l3\nld2 [%l3],%f26\nfmuld %f26,%f28,%f26\nset ThirtyTwo,%l3\nld2 [%l3],%f24\nfmuld %f24,%f28,%f24\nfmuld %f24,%f28,%f28\nfaddd %f26,%f28,%f28\nfsubd %f30,%f28,%f28\nfaddd %f28,%f30,%f28\nfsubd %f30,%f28,%f28\nfaddd %f28,%f30,%f30\nst2 %f30,[%l2]\n.L128:\nset Z,%l3\nld2 [%l3],%f30\nset Z1,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbule .L130; nop\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbug .L127; nop\n.L130:\n.L131:\n.L134:\nset Y1,%l3\nset Y,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset Half,%l1\nld2 [%l1],%f30\nld2 [%l3],%f28\nfmuld %f30,%f28,%f26\nset ThirtyTwo,%l3\nld2 [%l3],%f24\nfmuld %f24,%f28,%f24\nfmuld %f24,%f28,%f28\nfaddd %f26,%f28,%f28\nfsubd %f30,%f28,%f28\nfaddd %f28,%f30,%f28\nfsubd %f30,%f28,%f28\nfaddd %f28,%f30,%f30\nst2 %f30,[%l2]\n.L135:\nset Y,%l3\nld2 [%l3],%f30\nset Y1,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbule .L137; nop\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbug .L134; nop\n.L137:\nset X1,%l3\nset X,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nld2 [%l3],%f30\nset F9,%l3\nld2 [%l3],%f28\nset Half,%l3\nld2 [%l3],%f26\nfmuld %f26,%f30,%f26\nset ThirtyTwo,%l3\nld2 [%l3],%f24\nfmuld %f24,%f30,%f24\nfmuld %f24,%f30,%f30\nfaddd %f26,%f30,%f30\nfsubd %f30,%f28,%f30\nfaddd %f30,%f28,%f30\nst2 %f30,[%l2]\n.L132:\nset X,%l3\nld2 [%l3],%f30\nset X1,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbule .L138; nop\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbug .L131; nop\n.L138:\nset X1,%l3\nld2 [%l3],%f30\nset Y1,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L141; nop\nset Z1,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L139; nop\n.L141:\nset 1,%o0\nset .L142,%o1\ncall BadCond; nop\nset .L143,%o0\nset X1,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\nset Y1,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*3+68]\nst %f31,[%sp+4*4+68]\nld [%sp+4*3+68],%o3\nld [%sp+4*4+68],%o4\nset Z1,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*5+68]\nst %f31,[%sp+4*6+68]\nld [%sp+4*5+68],%o5\ncall printf; nop\nset .L144,%o0\ncall printf; nop\nset .L145,%o0\ncall printf; nop\nset .L146,%o0\ncall notify; nop\nset U1,%l3\nld2 [%l3],%f30\nset X1,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbue .L150; nop\nset Y1,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbue .L150; nop\nset Z1,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L140; nop\n.L150:\nset .L151,%o0\ncall printf; nop\nba .L140; nop\n.L139:\nset Z1,%l3\nld2 [%l3],%f30\nset U1,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L154; nop\nset Z2,%l3\nld2 [%l3],%f30\nset U2,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L152; nop\n.L154:\nset Z1,%l3\nld2 [%l3],%f30\nset U1,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbuge .L157; nop\nset Z2,%l3\nld2 [%l3],%f30\nset U2,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbul .L155; nop\n.L157:\nmov %g0,%o0\nset .L158,%o1\ncall BadCond; nop\nset .L159,%o0\ncall notify; nop\nset .L160,%o0\nset U1,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\nset Z1,%l3\nld2 [%l3],%f28\nfsubd %f28,%f30,%f30\nst %f30,[%sp+4*3+68]\nst %f31,[%sp+4*4+68]\nld [%sp+4*3+68],%o3\nld [%sp+4*4+68],%o4\ncall printf; nop\nset .L161,%o0\nset U2,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\nset Z2,%l3\nld2 [%l3],%f28\nfsubd %f28,%f30,%f30\nst %f30,[%sp+4*3+68]\nst %f31,[%sp+4*4+68]\nld [%sp+4*3+68],%o3\nld [%sp+4*4+68],%o4\ncall printf; nop\nba .L156; nop\n.L155:\nset Zero,%l3\nld2 [%l3],%f30\nset Z1,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbule .L164; nop\nset Z2,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbug .L162; nop\n.L164:\nset .L165,%o0\nset Radix,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset .L166,%o0\ncall printf; nop\nset .L167,%o0\nset Z1,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\nset Z2,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*3+68]\nst %f31,[%sp+4*4+68]\nld [%sp+4*3+68],%o3\nld [%sp+4*4+68],%o4\ncall printf; nop\nset .L168,%o0\ncall notify; nop\n.L162:\nset Z1,%l3\nld2 [%l3],%f30\nset Z2,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L171; nop\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbule .L169; nop\n.L171:\nset X,%l3\nset Z1,%l2\nld2 [%l2],%f30\nset U1,%l2\nld2 [%l2],%f28\nfdivd %f30,%f28,%f30\nst2 %f30,[%l3]\nset Y,%l2\nset Z2,%l1\nld2 [%l1],%f30\nset U2,%l1\nld2 [%l1],%f28\nfdivd %f30,%f28,%f30\nst2 %f30,[%l2]\nld2 [%l2],%f30\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbule .L172; nop\nset X,%l3\nset Y,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L172:\nset X,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall log; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Q,%l3\nfnegs %f30,%f30; fmovs %f31,%f31\nst2 %f30,[%l3]\nset .L174,%o0\ncall printf; nop\nset Radix,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall log; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset .L175,%o0\nset Q,%l3\nld2 [%l3],%f28\nfdivd %f28,%f30,%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset .L94,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall log; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset .L176,%o0\nset Q,%l3\nld2 [%l3],%f28\nfdivd %f28,%f30,%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\n.L169:\nset .L151,%o0\ncall printf; nop\n.L156:\n.L152:\n.L140:\ncall Pause; nop\nset Milestone,%l3\nset 35,%l2\nst %l2,[%l3]\nset Radix,%l3\nld2 [%l3],%f30\nset Two,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbul .L177; nop\nset X,%l3\nset Radix,%l2\nld2 [%l2],%f30\nset W,%l2\nld2 [%l2],%f28\nfmuld %f30,%f30,%f30\nfdivd %f28,%f30,%f30\nst2 %f30,[%l3]\nset Y,%l2\nld2 [%l3],%f30\nset One,%l1\nld2 [%l1],%f28\nfaddd %f30,%f28,%f28\nst2 %f28,[%l2]\nset Z,%l1\nld2 [%l2],%f28\nfsubd %f28,%f30,%f30\nst2 %f30,[%l1]\nset T,%l2\nld2 [%l1],%f30\nset U2,%l1\nld2 [%l1],%f28\nfaddd %f30,%f28,%f26\nst2 %f26,[%l2]\nld2 [%l2],%f26\nfsubd %f26,%f30,%f30\nst2 %f30,[%l3]\nmov %g0,%o0\nld2 [%l3],%f30\nfcmped %f30,%f28; nop; fbne .L181; nop\nset 1,%l3\nst %l3,[%fp+-24]\nba .L182; nop\n.L181:\nst %g0,[%fp+-24]\n.L182:\nld [%fp+-24],%o1\nset .L180,%o2\ncall TstCond; nop\nset X,%l3\nld2 [%l3],%f30\nset U2,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L183; nop\nset .L185,%o0\ncall printf; nop\n.L183:\n.L177:\nset .L186,%o0\ncall printf; nop\nset Y,%l3\nset F9,%l2\nld2 [%l2],%f30\nset One,%l2\nld2 [%l2],%f28\nfmuld %f30,%f28,%f26\nst2 %f26,[%l3]\nset Z,%l2\nfmuld %f28,%f30,%f26\nst2 %f26,[%l2]\nset X,%l1\nset Half,%l0\nld2 [%l0],%f26\nfsubd %f30,%f26,%f30\nst2 %f30,[%l1]\nld2 [%l1],%f30\nld2 [%l3],%f24\nfsubd %f24,%f26,%f24\nfsubd %f24,%f30,%f24\nst2 %f24,[%l3]\nld2 [%l2],%f24\nfsubd %f24,%f26,%f26\nfsubd %f26,%f30,%f30\nst2 %f30,[%l2]\nset U2,%l3\nld2 [%l3],%f30\nfaddd %f28,%f30,%f26\nst2 %f26,[%l1]\nset T,%l3\nld2 [%l1],%f26\nset Radix,%l2\nld2 [%l2],%f24\nfmuld %f26,%f24,%f22\nst2 %f22,[%l3]\nset R,%l2\nfmuld %f24,%f26,%f26\nst2 %f26,[%l2]\nld2 [%l3],%f26\nfsubd %f26,%f24,%f26\nst2 %f26,[%l1]\nfmuld %f24,%f30,%f30\nld2 [%l1],%f26\nfsubd %f26,%f30,%f26\nst2 %f26,[%l1]\nld2 [%l2],%f26\nfsubd %f26,%f24,%f26\nst2 %f26,[%l3]\nld2 [%l3],%f26\nfsubd %f26,%f30,%f30\nst2 %f30,[%l3]\nfsubd %f24,%f28,%f30\nld2 [%l1],%f28\nfmuld %f28,%f30,%f28\nst2 %f28,[%l1]\nld2 [%l3],%f28\nfmuld %f28,%f30,%f30\nst2 %f30,[%l3]\nset Zero,%l3\nld2 [%l3],%f30\nset X,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L187; nop\nset Y,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L187; nop\nset Z,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L187; nop\nset T,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L187; nop\nset GMult,%l3\nset 1,%l2\nst %l2,[%l3]\nba .L188; nop\n.L187:\nmov %g0,%l3\nset GMult,%l2\nst %l3,[%l2]\nset 1,%o0\nmov %l3,%o1\nset .L189,%o2\ncall TstCond; nop\n.L188:\nset Z,%l3\nset Radix,%l2\nld2 [%l2],%f30\nset U2,%l2\nld2 [%l2],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l3]\nset X,%l2\nld2 [%l3],%f30\nset One,%l3\nld2 [%l3],%f28\nfaddd %f28,%f30,%f28\nst2 %f28,[%l2]\nld2 [%l2],%f28\nfaddd %f28,%f30,%f30\nfmuld %f28,%f28,%f28\nfsubd %f30,%f28,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall fabs; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset U2,%l3\nld2 [%l3],%f28\nset Y,%l3\nfsubd %f30,%f28,%f30\nst2 %f30,[%l3]\nset X,%l3\nset One,%l2\nld2 [%l2],%f30\nfsubd %f30,%f28,%f30\nst2 %f30,[%l3]\nld2 [%l3],%f30\nfsubd %f30,%f28,%f28\nfmuld %f30,%f30,%f30\nfsubd %f28,%f30,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall fabs; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Z,%l3\nset U1,%l2\nld2 [%l2],%f28\nfsubd %f30,%f28,%f30\nst2 %f30,[%l3]\nmov %g0,%o0\nset Zero,%l3\nld2 [%l3],%f30\nset Y,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbug .L192; nop\nset Z,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbug .L192; nop\nset 1,%l3\nst %l3,[%fp+-24]\nba .L193; nop\n.L192:\nst %g0,[%fp+-24]\n.L193:\nld [%fp+-24],%o1\nset .L191,%o2\ncall TstCond; nop\nset Y,%l3\nset One,%l2\nld2 [%l2],%f30\nset U2,%l2\nld2 [%l2],%f28\nfsubd %f30,%f28,%f26\nst2 %f26,[%l3]\nset X,%l2\nfaddd %f30,%f28,%f28\nst2 %f28,[%l2]\nset Z,%l1\nld2 [%l3],%f28\nfdivd %f30,%f28,%f28\nst2 %f28,[%l1]\nld2 [%l1],%f28\nld2 [%l2],%f26\nfsubd %f28,%f26,%f28\nst2 %f28,[%l3]\nset Three,%l3\nld2 [%l3],%f28\nfdivd %f30,%f28,%f30\nst2 %f30,[%l2]\nset Nine,%l3\nld2 [%l3],%f30\nfdivd %f28,%f30,%f28\nst2 %f28,[%l1]\nld2 [%l1],%f28\nld2 [%l2],%f26\nfsubd %f26,%f28,%f26\nst2 %f26,[%l2]\nset T,%l3\nset TwentySeven,%l2\nld2 [%l2],%f26\nfdivd %f30,%f26,%f30\nst2 %f30,[%l3]\nld2 [%l3],%f30\nfsubd %f28,%f30,%f30\nst2 %f30,[%l1]\nset 2,%o0\nset Zero,%l3\nld2 [%l3],%f30\nset X,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L196; nop\nset Y,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L196; nop\nset Z,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L196; nop\nset 1,%l3\nst %l3,[%fp+-28]\nba .L197; nop\n.L196:\nst %g0,[%fp+-28]\n.L197:\nld [%fp+-28],%o1\nset .L195,%o2\ncall TstCond; nop\nset Y,%l3\nset F9,%l2\nld2 [%l2],%f30\nset One,%l2\nld2 [%l2],%f28\nfdivd %f30,%f28,%f26\nst2 %f26,[%l3]\nset X,%l2\nset Half,%l1\nld2 [%l1],%f26\nfsubd %f30,%f26,%f30\nst2 %f30,[%l2]\nld2 [%l3],%f30\nfsubd %f30,%f26,%f30\nld2 [%l2],%f26\nfsubd %f30,%f26,%f30\nst2 %f30,[%l3]\nset U2,%l3\nld2 [%l3],%f30\nfaddd %f28,%f30,%f30\nst2 %f30,[%l2]\nset T,%l3\nld2 [%l2],%f30\nfdivd %f30,%f28,%f28\nst2 %f28,[%l3]\nld2 [%l3],%f28\nfsubd %f28,%f30,%f30\nst2 %f30,[%l2]\nset Zero,%l3\nld2 [%l3],%f30\nset X,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L198; nop\nset Y,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L198; nop\nset Z,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L198; nop\nset GDiv,%l3\nset 1,%l2\nst %l2,[%l3]\nba .L199; nop\n.L198:\nmov %g0,%l3\nset GDiv,%l2\nst %l3,[%l2]\nset 1,%o0\nmov %l3,%o1\nset .L200,%o2\ncall TstCond; nop\n.L199:\nset X,%l3\nset One,%l2\nld2 [%l2],%f30\nset U2,%l2\nld2 [%l2],%f28\nfaddd %f30,%f28,%f28\nfdivd %f30,%f28,%f30\nst2 %f30,[%l3]\nset Y,%l2\nset Half,%l1\nld2 [%l1],%f30\nld2 [%l3],%f28\nfsubd %f28,%f30,%f28\nfsubd %f28,%f30,%f30\nst2 %f30,[%l2]\nset 1,%o0\nld2 [%l2],%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbuge .L203; nop\nset 1,%l3\nst %l3,[%fp+-32]\nba .L204; nop\n.L203:\nst %g0,[%fp+-32]\n.L204:\nld [%fp+-32],%o1\nset .L202,%o2\ncall TstCond; nop\nset X,%l3\nset One,%l2\nld2 [%l2],%f30\nset U2,%l2\nld2 [%l2],%f28\nfsubd %f30,%f28,%f26\nst2 %f26,[%l3]\nset Y,%l2\nset Radix,%l1\nld2 [%l1],%f26\nfmuld %f26,%f28,%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l2]\nset Z,%l1\nld2 [%l3],%f30\nfmuld %f30,%f26,%f28\nst2 %f28,[%l1]\nset T,%l0\nld2 [%l2],%f28\nfmuld %f28,%f26,%f24\nst2 %f24,[%l0]\nset R,%o5\nld2 [%l1],%f24\nfdivd %f24,%f26,%f24\nst2 %f24,[%o5]\nset StickyBit,%l1\nld2 [%l0],%f24\nfdivd %f24,%f26,%f26\nst2 %f26,[%l1]\nld2 [%o5],%f26\nfsubd %f26,%f30,%f30\nst2 %f30,[%l3]\nld2 [%l1],%f30\nfsubd %f30,%f28,%f30\nst2 %f30,[%l2]\nmov %g0,%o0\nset Zero,%l3\nld2 [%l3],%f30\nset X,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L207; nop\nset Y,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L207; nop\nset 1,%l3\nst %l3,[%fp+-36]\nba .L208; nop\n.L207:\nst %g0,[%fp+-36]\n.L208:\nld [%fp+-36],%o1\nset .L206,%o2\ncall TstCond; nop\nset Y,%l3\nset One,%l2\nld2 [%l2],%f30\nset U1,%l2\nld2 [%l2],%f28\nfsubd %f30,%f28,%f28\nst2 %f28,[%l3]\nset X,%l2\nset F9,%l1\nld2 [%l1],%f28\nfsubd %f30,%f28,%f28\nst2 %f28,[%l2]\nld2 [%l3],%f28\nfsubd %f30,%f28,%f30\nst2 %f30,[%l3]\nset T,%l3\nset Radix,%l2\nld2 [%l2],%f30\nset U2,%l2\nld2 [%l2],%f28\nfsubd %f30,%f28,%f28\nst2 %f28,[%l3]\nset Z,%l2\nset BMinusU2,%l1\nld2 [%l1],%f28\nfsubd %f30,%f28,%f28\nst2 %f28,[%l2]\nld2 [%l3],%f28\nfsubd %f30,%f28,%f30\nst2 %f30,[%l3]\nset U1,%l3\nld2 [%l3],%f30\nset X,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L209; nop\nset Y,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L209; nop\nset U2,%l3\nld2 [%l3],%f30\nset Z,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L209; nop\nset T,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L209; nop\nset GAddSub,%l3\nset 1,%l2\nst %l2,[%l3]\nba .L210; nop\n.L209:\nmov %g0,%l3\nset GAddSub,%l2\nst %l3,[%l2]\nset 1,%o0\nmov %l3,%o1\nset .L211,%o2\ncall TstCond; nop\n.L210:\nset F9,%l3\nld2 [%l3],%f30\nset One,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L212; nop\nfsubd %f30,%f28,%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbul .L212; nop\nset 1,%o0\nset .L214,%o1\ncall BadCond; nop\nset .L215,%o0\ncall printf; nop\nset .L216,%o0\ncall printf; nop\nset .L217,%o0\ncall printf; nop\n.L212:\nset GMult,%l3\nld [%l3],%l3\ncmp %l3,1; bne .L218; nop\nset GDiv,%l3\nld [%l3],%l3\ncmp %l3,1; bne .L218; nop\nset GAddSub,%l3\nld [%l3],%l3\ncmp %l3,1; bne .L218; nop\nset .L220,%o0\ncall printf; nop\n.L218:\nset Milestone,%l3\nset 40,%l2\nst %l2,[%l3]\ncall Pause; nop\nset .L221,%o0\ncall printf; nop\nset RMult,%l2\nst %g0,[%l2]\nset RDiv,%l2\nst %g0,[%l2]\nset RAddSub,%l2\nst %g0,[%l2]\nset Two,%l2\nld2 [%l2],%f30\nset RadixD2,%l2\nset Radix,%l1\nld2 [%l1],%f28\nfdivd %f28,%f30,%f28\nst2 %f28,[%l2]\nset A1,%l2\nst2 %f30,[%l2]\nset Done,%l2\nst %g0,[%l2]\n.L222:\nset AInvrse,%l3\nset Radix,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L225:\nset AInvrse,%l3\nld2 [%l3],%f30\nset X,%l2\nst2 %f30,[%l2]\nset A1,%l2\nld2 [%l2],%f28\nfdivd %f30,%f28,%f30\nst2 %f30,[%l3]\n.L226:\nset AInvrse,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset AInvrse,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L225; nop\nset X,%l3\nld2 [%l3],%f30\nset One,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L231; nop\nset A1,%l3\nld2 [%l3],%f30\nset Three,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbule .L229; nop\n.L231:\nset 1,%l3\nst %l3,[%fp+-40]\nba .L230; nop\n.L229:\nst %g0,[%fp+-40]\n.L230:\nset Done,%l3\nld [%fp+-40],%l2\nst %l2,[%l3]\nset Done,%l3\nld [%l3],%l3\ncmp %l3,0; bne .L232; nop\nset A1,%l3\nset Nine,%l2\nld2 [%l2],%f30\nset One,%l2\nld2 [%l2],%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l3]\n.L232:\n.L223:\nset Done,%l3\nld [%l3],%l3\ncmp %l3,0; be .L222; nop\nset X,%l3\nld2 [%l3],%f30\nset One,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L234; nop\nset A1,%l3\nset Radix,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L234:\nset AInvrse,%l3\nset A1,%l2\nld2 [%l2],%f30\nset One,%l2\nld2 [%l2],%f28\nfdivd %f28,%f30,%f28\nst2 %f28,[%l3]\nset X,%l2\nst2 %f30,[%l2]\nset Y,%l2\nld2 [%l3],%f30\nst2 %f30,[%l2]\nset Done,%l3\nst %g0,[%l3]\n.L236:\nset Z,%l3\nset Half,%l2\nld2 [%l2],%f30\nset X,%l2\nld2 [%l2],%f28\nset Y,%l2\nld2 [%l2],%f26\nfmuld %f28,%f26,%f28\nfsubd %f28,%f30,%f28\nst2 %f28,[%l3]\nmov %g0,%o0\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L241; nop\nset 1,%l3\nst %l3,[%fp+-40]\nba .L242; nop\n.L241:\nst %g0,[%fp+-40]\n.L242:\nld [%fp+-40],%o1\nset .L240,%o2\ncall TstCond; nop\nset X,%l3\nld2 [%l3],%f30\nset Radix,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L244; nop\nset 1,%l3\nst %l3,[%fp+-44]\nba .L245; nop\n.L244:\nst %g0,[%fp+-44]\n.L245:\nset Done,%l3\nld [%fp+-44],%l2\nst %l2,[%l3]\nset X,%l3\nset Radix,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset Y,%l2\nset One,%l1\nld2 [%l1],%f30\nld2 [%l3],%f28\nfdivd %f30,%f28,%f30\nst2 %f30,[%l2]\n.L237:\nset Done,%l3\nld [%l3],%l3\ncmp %l3,0; be .L236; nop\nset Y2,%l3\nset One,%l2\nld2 [%l2],%f30\nset U2,%l2\nld2 [%l2],%f28\nfaddd %f30,%f28,%f26\nst2 %f26,[%l3]\nset Y1,%l2\nfsubd %f30,%f28,%f30\nst2 %f30,[%l2]\nset X,%l1\nset OneAndHalf,%l0\nld2 [%l0],%f30\nfsubd %f30,%f28,%f26\nst2 %f26,[%l1]\nset Y,%l0\nfaddd %f30,%f28,%f26\nst2 %f26,[%l0]\nset Z,%o5\nld2 [%l1],%f26\nld2 [%l3],%f24\nfsubd %f26,%f28,%f22\nfmuld %f22,%f24,%f22\nst2 %f22,[%o5]\nset T,%l3\nld2 [%l0],%f22\nld2 [%l2],%f20\nfmuld %f22,%f20,%f18\nst2 %f18,[%l3]\nld2 [%o5],%f18\nfsubd %f18,%f26,%f18\nst2 %f18,[%o5]\nld2 [%l3],%f18\nfsubd %f18,%f26,%f18\nst2 %f18,[%l3]\nfmuld %f26,%f24,%f26\nst2 %f26,[%l1]\nfaddd %f22,%f28,%f28\nfmuld %f28,%f20,%f28\nst2 %f28,[%l0]\nld2 [%l1],%f28\nfsubd %f28,%f30,%f28\nst2 %f28,[%l1]\nld2 [%l0],%f28\nfsubd %f28,%f30,%f30\nst2 %f30,[%l0]\nset Zero,%l3\nld2 [%l3],%f30\nset X,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L246; nop\nset Y,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L246; nop\nset Z,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L246; nop\nset T,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbug .L246; nop\nset X,%l3\nset OneAndHalf,%l2\nld2 [%l2],%f30\nset U2,%l2\nld2 [%l2],%f28\nfaddd %f30,%f28,%f26\nset Y2,%l2\nld2 [%l2],%f24\nfmuld %f26,%f24,%f22\nst2 %f22,[%l3]\nset Y,%l2\nfsubd %f30,%f28,%f30\nfsubd %f30,%f28,%f22\nst2 %f22,[%l2]\nset Z,%l1\nfaddd %f26,%f28,%f26\nst2 %f26,[%l1]\nset T,%l0\nset Y1,%o5\nld2 [%o5],%f26\nfmuld %f30,%f26,%f30\nst2 %f30,[%l0]\nld2 [%l1],%f30\nfaddd %f30,%f28,%f22\nld2 [%l3],%f20\nfsubd %f20,%f22,%f20\nst2 %f20,[%l3]\nset StickyBit,%l3\nld2 [%l2],%f20\nfmuld %f20,%f26,%f18\nst2 %f18,[%l3]\nset S,%o4\nfmuld %f30,%f24,%f30\nst2 %f30,[%o4]\nld2 [%l0],%f30\nfsubd %f30,%f20,%f30\nst2 %f30,[%l0]\nfsubd %f28,%f20,%f30\nld2 [%l3],%f20\nfaddd %f30,%f20,%f30\nst2 %f30,[%l2]\nld2 [%o4],%f30\nfaddd %f22,%f28,%f22\nfsubd %f30,%f22,%f30\nst2 %f30,[%l1]\nfaddd %f24,%f28,%f30\nfmuld %f30,%f26,%f30\nst2 %f30,[%l3]\nfmuld %f24,%f26,%f30\nst2 %f30,[%o5]\nld2 [%l3],%f30\nfsubd %f30,%f24,%f30\nst2 %f30,[%l3]\nld2 [%o5],%f30\nset Half,%l3\nld2 [%l3],%f28\nfsubd %f30,%f28,%f30\nst2 %f30,[%o5]\nset Zero,%l3\nld2 [%l3],%f30\nset X,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L248; nop\nset Y,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L248; nop\nset Z,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L248; nop\nset T,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L248; nop\nset StickyBit,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L248; nop\nset Y1,%l3\nld2 [%l3],%f30\nset Half,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L248; nop\nset RMult,%l3\nset 1,%l2\nst %l2,[%l3]\nset .L250,%o0\ncall printf; nop\nba .L249; nop\n.L248:\nset U2,%l3\nld2 [%l3],%f30\nset Zero,%l3\nld2 [%l3],%f28\nset X,%l3\nld2 [%l3],%f26\nfaddd %f26,%f30,%f26\nfcmped %f26,%f28; nop; fbne .L251; nop\nset Y,%l3\nld2 [%l3],%f26\nfcmped %f26,%f28; nop; fbuge .L251; nop\nset Z,%l3\nld2 [%l3],%f26\nfaddd %f26,%f30,%f26\nfcmped %f26,%f28; nop; fbne .L251; nop\nset T,%l3\nld2 [%l3],%f26\nfcmped %f26,%f28; nop; fbuge .L251; nop\nset StickyBit,%l3\nld2 [%l3],%f26\nfaddd %f26,%f30,%f30\nfcmped %f30,%f28; nop; fbne .L251; nop\nset Y1,%l3\nld2 [%l3],%f30\nset Half,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbuge .L251; nop\nset RMult,%l3\nset 2,%l2\nst %l2,[%l3]\nset .L253,%o0\ncall printf; nop\nba .L252; nop\n.L251:\nset .L254,%o0\ncall printf; nop\n.L252:\n.L249:\nset RMult,%l3\nld [%l3],%l3\ncmp %l3,1; bne .L247; nop\nset GMult,%l3\nld [%l3],%l3\ncmp %l3,0; bne .L247; nop\nset .L257,%o0\ncall notify; nop\nba .L247; nop\n.L246:\nset .L254,%o0\ncall printf; nop\n.L247:\nset Milestone,%l3\nset 45,%l2\nst %l2,[%l3]\nset Y2,%l3\nset One,%l2\nld2 [%l2],%f30\nset U2,%l2\nld2 [%l2],%f28\nfaddd %f30,%f28,%f26\nst2 %f26,[%l3]\nset Y1,%l2\nfsubd %f30,%f28,%f30\nst2 %f30,[%l2]\nset Z,%l1\nset OneAndHalf,%l0\nld2 [%l0],%f30\nfaddd %f30,%f28,%f26\nfaddd %f26,%f28,%f24\nst2 %f24,[%l1]\nset X,%l0\nld2 [%l1],%f24\nld2 [%l3],%f22\nfdivd %f24,%f22,%f20\nst2 %f20,[%l0]\nset T,%l3\nfsubd %f30,%f28,%f20\nfsubd %f20,%f28,%f20\nst2 %f20,[%l3]\nset Y,%o5\nld2 [%l3],%f20\nld2 [%l2],%f18\nfsubd %f20,%f28,%f16\nfdivd %f16,%f18,%f16\nst2 %f16,[%o5]\nfaddd %f24,%f28,%f24\nfdivd %f24,%f22,%f24\nst2 %f24,[%l1]\nld2 [%l0],%f24\nfsubd %f24,%f30,%f24\nst2 %f24,[%l0]\nld2 [%o5],%f24\nfsubd %f24,%f20,%f24\nst2 %f24,[%o5]\nfdivd %f20,%f18,%f24\nst2 %f24,[%l3]\nld2 [%l1],%f24\nfsubd %f24,%f26,%f26\nst2 %f26,[%l1]\nfsubd %f28,%f30,%f30\nld2 [%l3],%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l3]\nset Zero,%l3\nld2 [%l3],%f30\nset X,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbug .L258; nop\nset Y,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbug .L258; nop\nset Z,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbug .L258; nop\nset T,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbug .L258; nop\nset X,%l3\nset OneAndHalf,%l2\nld2 [%l2],%f30\nset Y2,%l2\nld2 [%l2],%f28\nfdivd %f30,%f28,%f26\nst2 %f26,[%l3]\nset Y,%l1\nset U2,%l0\nld2 [%l0],%f26\nfsubd %f30,%f26,%f24\nst2 %f24,[%l1]\nset Z,%l0\nfaddd %f30,%f26,%f24\nst2 %f24,[%l0]\nld2 [%l1],%f24\nld2 [%l3],%f22\nfsubd %f22,%f24,%f22\nst2 %f22,[%l3]\nset T,%l3\nset Y1,%o5\nld2 [%o5],%f22\nfdivd %f30,%f22,%f20\nst2 %f20,[%l3]\nfdivd %f24,%f22,%f24\nst2 %f24,[%l1]\nld2 [%l0],%f24\nld2 [%l3],%f22\nfaddd %f24,%f26,%f20\nfsubd %f22,%f20,%f22\nst2 %f22,[%l3]\nld2 [%l1],%f22\nfsubd %f22,%f24,%f22\nst2 %f22,[%l1]\nfdivd %f24,%f28,%f24\nst2 %f24,[%l0]\nfaddd %f28,%f26,%f26\nfdivd %f26,%f28,%f26\nst2 %f26,[%o5]\nld2 [%l0],%f26\nfsubd %f26,%f30,%f30\nst2 %f30,[%l0]\nld2 [%o5],%f30\nfsubd %f30,%f28,%f30\nst2 %f30,[%l2]\nset F9,%l3\nld2 [%l3],%f30\nset U1,%l3\nld2 [%l3],%f28\nfsubd %f30,%f28,%f28\nfdivd %f28,%f30,%f30\nst2 %f30,[%o5]\nset Zero,%l3\nld2 [%l3],%f30\nset X,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L260; nop\nset Y,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L260; nop\nset Z,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L260; nop\nset T,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L260; nop\nset Y2,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L260; nop\nfcmped %f28,%f30; nop; fbne .L260; nop\nset Half,%l3\nld2 [%l3],%f30\nset Y1,%l3\nld2 [%l3],%f28\nfsubd %f28,%f30,%f28\nset F9,%l3\nld2 [%l3],%f26\nfsubd %f26,%f30,%f30\nfcmped %f28,%f30; nop; fbne .L260; nop\nset RDiv,%l3\nset 1,%l2\nst %l2,[%l3]\nset .L262,%o0\ncall printf; nop\nset GDiv,%l3\nld [%l3],%l3\ncmp %l3,0; bne .L261; nop\nset .L265,%o0\ncall notify; nop\nba .L261; nop\n.L260:\nset Zero,%l3\nld2 [%l3],%f30\nset X,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbuge .L266; nop\nset Y,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbuge .L266; nop\nset Z,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbuge .L266; nop\nset T,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbuge .L266; nop\nset Y2,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbuge .L266; nop\nset Half,%l3\nld2 [%l3],%f30\nset Y1,%l3\nld2 [%l3],%f28\nfsubd %f28,%f30,%f28\nset F9,%l3\nld2 [%l3],%f26\nfsubd %f26,%f30,%f30\nfcmped %f28,%f30; nop; fbuge .L266; nop\nset RDiv,%l3\nset 2,%l2\nst %l2,[%l3]\nset .L268,%o0\ncall printf; nop\n.L266:\n.L261:\n.L258:\nset RDiv,%l3\nld [%l3],%l3\ncmp %l3,0; bne .L269; nop\nset .L271,%o0\ncall printf; nop\n.L269:\nset BInvrse,%l3\nset Radix,%l2\nld2 [%l2],%f30\nset One,%l2\nld2 [%l2],%f28\nfdivd %f28,%f30,%f28\nst2 %f28,[%l3]\nmov %g0,%o0\nset Half,%l2\nld2 [%l2],%f28\nld2 [%l3],%f26\nfmuld %f26,%f30,%f30\nfsubd %f30,%f28,%f30\nfcmped %f30,%f28; nop; fbne .L274; nop\nset 1,%l3\nst %l3,[%fp+-40]\nba .L275; nop\n.L274:\nst %g0,[%fp+-40]\n.L275:\nld [%fp+-40],%o1\nset .L273,%o2\ncall TstCond; nop\nset Milestone,%l3\nset 50,%l2\nst %l2,[%l3]\nmov %g0,%o0\nset Half,%l3\nld2 [%l3],%f30\nset F9,%l3\nld2 [%l3],%f28\nset U1,%l3\nld2 [%l3],%f26\nfaddd %f28,%f26,%f28\nfsubd %f28,%f30,%f28\nfcmped %f28,%f30; nop; fbne .L278; nop\nset One,%l3\nld2 [%l3],%f30\nset BMinusU2,%l3\nld2 [%l3],%f28\nset U2,%l3\nld2 [%l3],%f26\nfaddd %f28,%f26,%f28\nfsubd %f28,%f30,%f28\nset Radix,%l3\nld2 [%l3],%f26\nfsubd %f26,%f30,%f30\nfcmped %f28,%f30; nop; fbne .L278; nop\nset 1,%l3\nst %l3,[%fp+-44]\nba .L279; nop\n.L278:\nst %g0,[%fp+-44]\n.L279:\nld [%fp+-44],%o1\nset .L277,%o2\ncall TstCond; nop\nset X,%l3\nset One,%l2\nld2 [%l2],%f30\nset U1,%l2\nld2 [%l2],%f28\nfmuld %f28,%f28,%f28\nfsubd %f30,%f28,%f28\nst2 %f28,[%l3]\nset Y,%l2\nset U2,%l1\nld2 [%l1],%f28\nfsubd %f30,%f28,%f26\nfmuld %f28,%f26,%f28\nfaddd %f30,%f28,%f28\nst2 %f28,[%l2]\nset Z,%l1\nset Half,%l0\nld2 [%l0],%f28\nset F9,%l0\nld2 [%l0],%f26\nfsubd %f26,%f28,%f26\nst2 %f26,[%l1]\nld2 [%l3],%f26\nfsubd %f26,%f28,%f28\nld2 [%l1],%f26\nfsubd %f28,%f26,%f28\nst2 %f28,[%l3]\nld2 [%l2],%f28\nfsubd %f28,%f30,%f30\nst2 %f30,[%l2]\nset Zero,%l3\nld2 [%l3],%f30\nset X,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L280; nop\nset Y,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L280; nop\nset RAddSub,%l3\nset 2,%l2\nst %l2,[%l3]\nset .L282,%o0\ncall printf; nop\n.L280:\nset GAddSub,%l3\nld [%l3],%l3\ncmp %l3,1; bne .L283; nop\nset X,%l3\nset Half,%l2\nld2 [%l2],%f30\nset U2,%l2\nld2 [%l2],%f28\nfaddd %f30,%f28,%f26\nfmuld %f26,%f28,%f26\nst2 %f26,[%l3]\nset Y,%l2\nfsubd %f30,%f28,%f30\nfmuld %f30,%f28,%f30\nst2 %f30,[%l2]\nset One,%l1\nld2 [%l1],%f30\nld2 [%l3],%f26\nfaddd %f30,%f26,%f26\nst2 %f26,[%l3]\nld2 [%l2],%f26\nfaddd %f30,%f26,%f26\nst2 %f26,[%l2]\nfaddd %f30,%f28,%f28\nld2 [%l3],%f26\nfsubd %f28,%f26,%f28\nst2 %f28,[%l3]\nld2 [%l2],%f28\nfsubd %f30,%f28,%f30\nst2 %f30,[%l2]\nset Zero,%l3\nld2 [%l3],%f30\nset X,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L285; nop\nset Y,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L285; nop\nset X,%l3\nset Half,%l2\nld2 [%l2],%f30\nset U2,%l2\nld2 [%l2],%f28\nset U1,%l2\nld2 [%l2],%f26\nfaddd %f30,%f28,%f24\nfmuld %f24,%f26,%f24\nst2 %f24,[%l3]\nset Y,%l2\nfsubd %f30,%f28,%f30\nfmuld %f30,%f26,%f30\nst2 %f30,[%l2]\nset One,%l1\nld2 [%l1],%f30\nld2 [%l3],%f28\nfsubd %f30,%f28,%f28\nst2 %f28,[%l3]\nld2 [%l2],%f28\nfsubd %f30,%f28,%f28\nst2 %f28,[%l2]\nset F9,%l1\nld2 [%l1],%f28\nld2 [%l3],%f26\nfsubd %f28,%f26,%f28\nst2 %f28,[%l3]\nld2 [%l2],%f28\nfsubd %f30,%f28,%f30\nst2 %f30,[%l2]\nset Zero,%l3\nld2 [%l3],%f30\nset X,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L287; nop\nset Y,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L287; nop\nset RAddSub,%l3\nset 1,%l2\nst %l2,[%l3]\nset .L289,%o0\ncall printf; nop\nset GAddSub,%l3\nld [%l3],%l3\ncmp %l3,0; bne .L284; nop\nset .L292,%o0\ncall notify; nop\nba .L284; nop\n.L287:\nset .L293,%o0\ncall printf; nop\nba .L284; nop\n.L285:\nset .L293,%o0\ncall printf; nop\nba .L284; nop\n.L283:\nset .L293,%o0\ncall printf; nop\n.L284:\nset One,%l3\nld2 [%l3],%f30\nset S,%l3\nst2 %f30,[%l3]\nset X,%l3\nset Half,%l2\nld2 [%l2],%f28\nfaddd %f30,%f28,%f26\nfmuld %f28,%f26,%f26\nfaddd %f30,%f26,%f26\nst2 %f26,[%l3]\nset Y,%l2\nset U2,%l1\nld2 [%l1],%f26\nfaddd %f30,%f26,%f30\nfmuld %f30,%f28,%f30\nst2 %f30,[%l2]\nset Z,%l1\nld2 [%l3],%f30\nld2 [%l2],%f28\nfsubd %f30,%f28,%f26\nst2 %f26,[%l1]\nset T,%l3\nfsubd %f28,%f30,%f30\nst2 %f30,[%l3]\nset StickyBit,%l2\nld2 [%l1],%f30\nld2 [%l3],%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l2]\nld2 [%l2],%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L294; nop\nset S,%l3\nset Zero,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset 3,%o0\nset .L296,%o1\ncall BadCond; nop\n.L294:\nset StickyBit,%l3\nset Zero,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset GMult,%l3\nld [%l3],%l3\ncmp %l3,1; bne .L297; nop\nset GDiv,%l3\nld [%l3],%l3\ncmp %l3,1; bne .L297; nop\nset GAddSub,%l3\nld [%l3],%l3\ncmp %l3,1; bne .L297; nop\nset RMult,%l3\nld [%l3],%l3\ncmp %l3,1; bne .L297; nop\nset RDiv,%l3\nld [%l3],%l3\ncmp %l3,1; bne .L297; nop\nset RAddSub,%l3\nld [%l3],%l3\ncmp %l3,1; bne .L297; nop\nset RadixD2,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset RadixD2,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L297; nop\nset .L299,%o0\ncall printf; nop\nset X,%l3\nset Half,%l2\nld2 [%l2],%f30\nset U2,%l2\nld2 [%l2],%f28\nset U1,%l2\nld2 [%l2],%f26\nfaddd %f30,%f26,%f26\nfmuld %f26,%f28,%f26\nst2 %f26,[%l3]\nset Y,%l2\nfmuld %f30,%f28,%f30\nst2 %f30,[%l2]\nset One,%l1\nld2 [%l1],%f30\nset Z,%l1\nld2 [%l2],%f28\nfaddd %f30,%f28,%f28\nst2 %f28,[%l1]\nset T,%l2\nld2 [%l3],%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l2]\nset One,%l3\nld2 [%l3],%f30\nset Z,%l3\nld2 [%l3],%f28\nfsubd %f28,%f30,%f28\nset Zero,%l3\nld2 [%l3],%f26\nfcmped %f28,%f26; nop; fbug .L300; nop\nset T,%l3\nld2 [%l3],%f28\nfsubd %f28,%f30,%f30\nset U2,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbul .L300; nop\nset Z,%l3\nset Y,%l2\nset T,%l1\nld2 [%l1],%f30\nld2 [%l2],%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l3]\nld2 [%l3],%f30\nset X,%l3\nld2 [%l3],%f28\nfsubd %f30,%f28,%f30\nst2 %f30,[%l2]\nset T,%l3\nld2 [%l3],%f30\nset Z,%l3\nld2 [%l3],%f28\nfsubd %f28,%f30,%f28\nset U2,%l3\nld2 [%l3],%f26\nfcmped %f28,%f26; nop; fbul .L302; nop\nset Y,%l3\nld2 [%l3],%f28\nfsubd %f28,%f30,%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L302; nop\nset X,%l3\nset Half,%l2\nld2 [%l2],%f30\nset U1,%l2\nld2 [%l2],%f28\nfaddd %f30,%f28,%f26\nfmuld %f26,%f28,%f26\nst2 %f26,[%l3]\nset Y,%l2\nfmuld %f30,%f28,%f30\nst2 %f30,[%l2]\nset One,%l1\nld2 [%l1],%f30\nset Z,%l1\nld2 [%l2],%f28\nfsubd %f30,%f28,%f28\nst2 %f28,[%l1]\nset T,%l2\nld2 [%l3],%f28\nfsubd %f30,%f28,%f30\nst2 %f30,[%l2]\nset Zero,%l3\nld2 [%l3],%f30\nset Z,%l3\nld2 [%l3],%f28\nset One,%l3\nld2 [%l3],%f26\nfsubd %f28,%f26,%f28\nfcmped %f28,%f30; nop; fbne .L304; nop\nset T,%l3\nld2 [%l3],%f28\nset F9,%l3\nld2 [%l3],%f26\nfsubd %f28,%f26,%f28\nfcmped %f28,%f30; nop; fbne .L304; nop\nset Z,%l3\nset U1,%l2\nld2 [%l2],%f30\nset Half,%l2\nld2 [%l2],%f28\nfsubd %f28,%f30,%f28\nfmuld %f28,%f30,%f30\nst2 %f30,[%l3]\nset F9,%l2\nld2 [%l2],%f30\nset T,%l2\nld2 [%l3],%f28\nfsubd %f30,%f28,%f28\nst2 %f28,[%l2]\nset Q,%l3\nset Y,%l2\nld2 [%l2],%f28\nfsubd %f30,%f28,%f30\nst2 %f30,[%l3]\nset F9,%l3\nld2 [%l3],%f30\nset Zero,%l3\nld2 [%l3],%f28\nset T,%l3\nld2 [%l3],%f26\nfsubd %f26,%f30,%f26\nfcmped %f26,%f28; nop; fbne .L306; nop\nset U1,%l3\nld2 [%l3],%f26\nfsubd %f30,%f26,%f30\nset Q,%l3\nld2 [%l3],%f26\nfsubd %f30,%f26,%f30\nfcmped %f30,%f28; nop; fbne .L306; nop\nset Z,%l3\nset One,%l2\nld2 [%l2],%f30\nset U2,%l2\nld2 [%l2],%f28\nset OneAndHalf,%l2\nld2 [%l2],%f26\nfaddd %f30,%f28,%f24\nfmuld %f24,%f26,%f24\nst2 %f24,[%l3]\nset T,%l2\nfaddd %f26,%f28,%f26\nld2 [%l3],%f24\nfsubd %f26,%f24,%f26\nfaddd %f26,%f28,%f26\nst2 %f26,[%l2]\nset X,%l2\nset Radix,%l1\nld2 [%l1],%f26\nset Half,%l1\nld2 [%l1],%f24\nfdivd %f24,%f26,%f24\nfaddd %f30,%f24,%f24\nst2 %f24,[%l2]\nset Y,%l1\nfmuld %f26,%f28,%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l1]\nld2 [%l2],%f30\nld2 [%l1],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l3]\nset Zero,%l3\nld2 [%l3],%f30\nset T,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L308; nop\nset X,%l3\nld2 [%l3],%f28\nset Radix,%l3\nld2 [%l3],%f26\nset U2,%l3\nld2 [%l3],%f24\nfmuld %f26,%f24,%f26\nfaddd %f28,%f26,%f28\nset Z,%l3\nld2 [%l3],%f26\nfsubd %f28,%f26,%f28\nfcmped %f28,%f30; nop; fbne .L308; nop\nset Radix,%l3\nld2 [%l3],%f30\nset Two,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L310; nop\nset X,%l3\nset Two,%l2\nld2 [%l2],%f30\nset U2,%l2\nld2 [%l2],%f28\nfaddd %f30,%f28,%f28\nst2 %f28,[%l3]\nset Y,%l2\nld2 [%l3],%f28\nfdivd %f28,%f30,%f30\nst2 %f30,[%l2]\nld2 [%l2],%f30\nset One,%l3\nld2 [%l3],%f28\nfsubd %f30,%f28,%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L311; nop\nset StickyBit,%l3\nset S,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nba .L311; nop\n.L310:\nset StickyBit,%l3\nset S,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L311:\n.L308:\n.L306:\n.L304:\n.L302:\n.L300:\n.L297:\nset StickyBit,%l3\nld2 [%l3],%f30\nset One,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L314; nop\nset .L316,%o0\ncall printf; nop\nba .L315; nop\n.L314:\nset .L317,%o0\ncall printf; nop\n.L315:\nset 3,%o0\nset GMult,%l2\nld [%l2],%l2\ncmp %l2,%g0; be .L320; nop\nset GDiv,%l2\nld [%l2],%l2\ncmp %l2,%g0; be .L320; nop\nset GAddSub,%l2\nld [%l2],%l2\ncmp %l2,%g0; be .L320; nop\nset RMult,%l2\nld [%l2],%l2\ncmp %l2,%g0; be .L320; nop\nset RDiv,%l2\nld [%l2],%l2\ncmp %l2,%g0; be .L320; nop\nset RAddSub,%l2\nld [%l2],%l2\ncmp %l2,%g0; be .L320; nop\nset 1,%l3\nst %l3,[%fp+-48]\nba .L321; nop\n.L320:\nst %g0,[%fp+-48]\n.L321:\nld [%fp+-48],%o1\nset .L319,%o2\ncall TstCond; nop\nset Milestone,%l3\nset 60,%l2\nst %l2,[%l3]\nset .L45,%o0\ncall printf; nop\nset .L322,%o0\ncall printf; nop\nset .L323,%o0\nset NoTrials,%l3\nld [%l3],%o1\ncall printf; nop\nset .L324,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall sqrt; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Random9,%l3\nst2 %f30,[%l3]\nset Random1,%l3\nset Third,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset I,%l3\nset 1,%l2\nst %l2,[%l3]\n.L325:\ncall Random; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset X,%l3\nst2 %f30,[%l3]\ncall Random; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Y,%l3\nst2 %f30,[%l3]\nset Z9,%l3\nset Y,%l2\nld2 [%l2],%f30\nset X,%l2\nld2 [%l2],%f28\nfmuld %f30,%f28,%f26\nst2 %f26,[%l3]\nset Z,%l2\nfmuld %f28,%f30,%f30\nst2 %f30,[%l2]\nld2 [%l2],%f30\nld2 [%l3],%f28\nfsubd %f30,%f28,%f30\nst2 %f30,[%l3]\nset I,%l3\nld [%l3],%l2\nadd %l2,1,%l2\nst %l2,[%l3]\n.L326:\nset I,%l3\nld [%l3],%l3\nset NoTrials,%l2\nld [%l2],%l2\ncmp %l3,%l2; bg .L328; nop\nset Z9,%l3\nld2 [%l3],%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L325; nop\n.L328:\nset I,%l3\nld [%l3],%l3\nset NoTrials,%l2\nld [%l2],%l2\ncmp %l3,%l2; bne .L329; nop\nset Random1,%l3\nset One,%l2\nld2 [%l2],%f30\nset Half,%l2\nld2 [%l2],%f28\nset Three,%l2\nld2 [%l2],%f26\nfdivd %f28,%f26,%f28\nfaddd %f30,%f28,%f28\nst2 %f28,[%l3]\nset Random2,%l2\nset U2,%l1\nld2 [%l1],%f26\nset U1,%l1\nld2 [%l1],%f24\nfaddd %f26,%f24,%f26\nfaddd %f26,%f30,%f30\nst2 %f30,[%l2]\nld2 [%l3],%f26\nld2 [%l2],%f24\nset Z,%l3\nfmuld %f26,%f24,%f22\nst2 %f22,[%l3]\nset Y,%l3\nfmuld %f24,%f26,%f26\nst2 %f26,[%l3]\nfmuld %f28,%f30,%f30\nset Z9,%l3\nfsubd %f30,%f30,%f30\nst2 %f30,[%l3]\n.L329:\nset I,%l3\nld [%l3],%l3\nset NoTrials,%l2\nld [%l2],%l2\ncmp %l3,%l2; be .L331; nop\nset Z9,%l3\nld2 [%l3],%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L331; nop\nset 2,%o0\nset .L333,%o1\ncall BadCond; nop\nba .L332; nop\n.L331:\nset .L334,%o0\nset NoTrials,%l3\nld [%l3],%o1\ncall printf; nop\n.L332:\nset Milestone,%l3\nset 70,%l2\nst %l2,[%l3]\nset .L335,%o0\ncall printf; nop\nset Zero,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-64]\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall sqrt; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nldd [%fp+-64],%f28\nfcmped %f28,%f30; nop; fbne .L338; nop\nset Zero,%l3\nld2 [%l3],%f30\nfnegs %f30,%f30; fmovs %f31,%f31\nstd %f30,[%fp+-72]\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall sqrt; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nldd [%fp+-72],%f28\nfcmped %f28,%f30; nop; fbne .L338; nop\nset One,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-80]\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall sqrt; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nldd [%fp+-80],%f28\nfcmped %f28,%f30; nop; fbne .L338; nop\nset 1,%l3\nst %l3,[%fp+-52]\nba .L339; nop\n.L338:\nst %g0,[%fp+-52]\n.L339:\nmov %g0,%o0\nld [%fp+-52],%o1\nset .L337,%o2\ncall TstCond; nop\nset Zero,%l3\nld2 [%l3],%f30\nset MinSqEr,%l3\nst2 %f30,[%l3]\nset MaxSqEr,%l3\nst2 %f30,[%l3]\nset J,%l3\nst2 %f30,[%l3]\nset X,%l3\nset Radix,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset OneUlp,%l3\nset U2,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset 1,%o0\ncall SqXMinX; nop\nset BInvrse,%l3\nld2 [%l3],%f30\nset X,%l3\nst2 %f30,[%l3]\nset OneUlp,%l3\nset U1,%l2\nld2 [%l2],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l3]\nset 1,%o0\ncall SqXMinX; nop\nset U1,%l3\nld2 [%l3],%f30\nset X,%l3\nst2 %f30,[%l3]\nset OneUlp,%l3\nfmuld %f30,%f30,%f30\nst2 %f30,[%l3]\nset 1,%o0\ncall SqXMinX; nop\nset J,%l3\nld2 [%l3],%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L340; nop\ncall Pause; nop\n.L340:\nset .L342,%o0\nset NoTrials,%l3\nld [%l3],%o1\ncall printf; nop\nset J,%l3\nset Zero,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset X,%l3\nset Two,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset Radix,%l3\nld2 [%l3],%f30\nset Y,%l3\nst2 %f30,[%l3]\nset One,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L343; nop\n.L345:\nset Y,%l3\nld2 [%l3],%f30\nset X,%l2\nst2 %f30,[%l2]\nset Radix,%l2\nld2 [%l2],%f28\nfmuld %f28,%f30,%f30\nst2 %f30,[%l3]\n.L346:\nset Y,%l3\nld2 [%l3],%f30\nset X,%l3\nld2 [%l3],%f28\nfsubd %f30,%f28,%f30\nset NoTrials,%l3\nld [%l3],%l3\nst %l3,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfcmped %f30,%f28; nop; fbul .L345; nop\n.L343:\nset OneUlp,%l3\nset X,%l2\nld2 [%l2],%f30\nset U2,%l2\nld2 [%l2],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l3]\nset I,%l3\nset 1,%l2\nst %l2,[%l3]\nba .L349; nop\n.L348:\nset X,%l3\nld2 [%l3],%f30\nset One,%l2\nld2 [%l2],%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l3]\nset 2,%o0\ncall SqXMinX; nop\nset J,%l3\nld2 [%l3],%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbule .L351; nop\nba .L350; nop\n.L351:\nset I,%l3\nld [%l3],%l2\nadd %l2,1,%l2\nst %l2,[%l3]\n.L349:\nset I,%l3\nld [%l3],%l3\nset NoTrials,%l2\nld [%l2],%l2\ncmp %l3,%l2; ble .L348; nop\n.L350:\nset .L353,%o0\ncall printf; nop\nset I,%l3\nset -1,%l2\nst %l2,[%l3]\nset X,%l3\nset BMinusU2,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset Radix,%l3\nld2 [%l3],%f30\nset Y,%l3\nst2 %f30,[%l3]\nset Z,%l3\nset U2,%l2\nld2 [%l2],%f28\nfmuld %f30,%f28,%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l3]\nset NotMonot,%l2\nst %g0,[%l2]\nset Monot,%l2\nst %g0,[%l2]\nba .L355; nop\n.L354:\nset I,%l3\nld [%l3],%l2\nadd %l2,1,%l2\nst %l2,[%l3]\nset X,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall sqrt; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nst2 %f30,[%l3]\nset Y,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall sqrt; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Q,%l3\nst2 %f30,[%l3]\nset Z,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall sqrt; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nst2 %f30,[%l3]\nset Q,%l3\nld2 [%l3],%f30\nset X,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbug .L359; nop\nset Z,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbule .L357; nop\n.L359:\nset NotMonot,%l3\nset 1,%l2\nst %l2,[%l3]\nba .L358; nop\n.L357:\nset Q,%l3\nld2 [%l3],%f30\nset Half,%l2\nld2 [%l2],%f28\nfaddd %f30,%f28,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nst2 %f30,[%l3]\nset I,%l3\nld [%l3],%l3\ncmp %l3,0; bg .L362; nop\nset Q,%l3\nld2 [%l3],%f30\nset Radix,%l3\nld2 [%l3],%f28\nfmuld %f30,%f30,%f30\nfcmped %f28,%f30; nop; fbne .L360; nop\n.L362:\nset Monot,%l3\nset 1,%l2\nst %l2,[%l3]\nba .L361; nop\n.L360:\nset I,%l3\nld [%l3],%l3\ncmp %l3,0; ble .L363; nop\nset I,%l3\nld [%l3],%l3\ncmp %l3,1; ble .L365; nop\nset Monot,%l3\nset 1,%l2\nst %l2,[%l3]\nba .L364; nop\n.L365:\nset Y,%l3\nld2 [%l3],%f30\nset BInvrse,%l2\nld2 [%l2],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l3]\nld2 [%l3],%f30\nset U1,%l3\nld2 [%l3],%f28\nset X,%l3\nfsubd %f30,%f28,%f26\nst2 %f26,[%l3]\nset Z,%l3\nfaddd %f30,%f28,%f30\nst2 %f30,[%l3]\nba .L364; nop\n.L363:\nset Y,%l3\nset Q,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nld2 [%l3],%f30\nset U2,%l3\nld2 [%l3],%f28\nset X,%l3\nfsubd %f30,%f28,%f26\nst2 %f26,[%l3]\nset Z,%l3\nfaddd %f30,%f28,%f30\nst2 %f30,[%l3]\n.L364:\n.L361:\n.L358:\n.L355:\nset NotMonot,%l2\nld [%l2],%l2\ncmp %l2,%g0; bne .L367; nop\nset Monot,%l2\nld [%l2],%l2\ncmp %l2,%g0; be .L354; nop\n.L367:\nset Monot,%l3\nld [%l3],%l3\ncmp %l3,0; be .L368; nop\nset .L370,%o0\ncall printf; nop\nba .L369; nop\n.L368:\nset 2,%o0\nset .L158,%o1\ncall BadCond; nop\nset .L371,%o0\nset Y,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\n.L369:\nset Milestone,%l3\nset 80,%l2\nst %l2,[%l3]\nset MinSqEr,%l3\nset Half,%l2\nld2 [%l2],%f30\nld2 [%l3],%f28\nfaddd %f28,%f30,%f28\nst2 %f28,[%l3]\nset MaxSqEr,%l3\nld2 [%l3],%f28\nfsubd %f28,%f30,%f30\nst2 %f30,[%l3]\nset One,%l3\nld2 [%l3],%f30\nset U2,%l3\nld2 [%l3],%f28\nfaddd %f30,%f28,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall sqrt; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset One,%l3\nld2 [%l3],%f28\nset U2,%l3\nld2 [%l3],%f26\nset Y,%l3\nfsubd %f30,%f28,%f30\nfdivd %f30,%f26,%f30\nst2 %f30,[%l3]\nset SqEr,%l3\nset Y,%l2\nld2 [%l2],%f30\nfsubd %f30,%f28,%f30\nset Eight,%l2\nld2 [%l2],%f28\nfdivd %f26,%f28,%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l3]\nld2 [%l3],%f30\nset MaxSqEr,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbule .L372; nop\nset MaxSqEr,%l3\nset SqEr,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L372:\nset SqEr,%l3\nset Y,%l2\nld2 [%l2],%f30\nset U2,%l2\nld2 [%l2],%f28\nset Eight,%l2\nld2 [%l2],%f26\nfdivd %f28,%f26,%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l3]\nld2 [%l3],%f30\nset MinSqEr,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbuge .L374; nop\nset MinSqEr,%l3\nset SqEr,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L374:\nset F9,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall sqrt; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset U2,%l3\nld2 [%l3],%f28\nset U1,%l3\nld2 [%l3],%f26\nset Y,%l3\nfsubd %f30,%f28,%f30\nset One,%l2\nld2 [%l2],%f24\nfsubd %f24,%f28,%f28\nfsubd %f30,%f28,%f30\nfdivd %f30,%f26,%f30\nst2 %f30,[%l3]\nset SqEr,%l3\nset Y,%l2\nld2 [%l2],%f30\nset Eight,%l2\nld2 [%l2],%f28\nfdivd %f26,%f28,%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l3]\nld2 [%l3],%f30\nset MaxSqEr,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbule .L376; nop\nset MaxSqEr,%l3\nset SqEr,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L376:\nset SqEr,%l3\nset Y,%l2\nld2 [%l2],%f30\nset One,%l2\nld2 [%l2],%f28\nfaddd %f30,%f28,%f30\nset U1,%l2\nld2 [%l2],%f28\nset Eight,%l2\nld2 [%l2],%f26\nfdivd %f28,%f26,%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l3]\nld2 [%l3],%f30\nset MinSqEr,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbuge .L378; nop\nset MinSqEr,%l3\nset SqEr,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L378:\nset OneUlp,%l3\nset U2,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset X,%l2\nld2 [%l3],%f30\nst2 %f30,[%l2]\nset Indx,%l3\nset 1,%l2\nst %l2,[%l3]\n.L380:\nset X,%l3\nld2 [%l3],%f30\nset U1,%l3\nld2 [%l3],%f28\nfaddd %f30,%f28,%f28\nfaddd %f28,%f30,%f30\nset F9,%l3\nld2 [%l3],%f28\nfaddd %f30,%f28,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall sqrt; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Y,%l3\nst2 %f30,[%l3]\nset Y,%l3\nset U2,%l2\nld2 [%l2],%f30\nset X,%l2\nld2 [%l2],%f28\nset OneUlp,%l2\nld2 [%l2],%f26\nld2 [%l3],%f24\nfsubd %f24,%f30,%f24\nset One,%l2\nld2 [%l2],%f22\nfsubd %f22,%f30,%f30\nfaddd %f30,%f28,%f30\nfsubd %f24,%f30,%f30\nfdivd %f30,%f26,%f30\nst2 %f30,[%l3]\nset Z,%l2\nset Half,%l1\nld2 [%l1],%f30\nset U1,%l1\nld2 [%l1],%f24\nfsubd %f24,%f28,%f24\nset F9,%l1\nld2 [%l1],%f22\nfaddd %f24,%f22,%f24\nfmuld %f24,%f30,%f24\nfmuld %f24,%f28,%f24\nfmuld %f24,%f28,%f28\nfdivd %f28,%f26,%f28\nst2 %f28,[%l2]\nset SqEr,%l1\nld2 [%l3],%f28\nfaddd %f28,%f30,%f30\nld2 [%l2],%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l1]\nld2 [%l1],%f30\nset MinSqEr,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbuge .L384; nop\nset MinSqEr,%l3\nset SqEr,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L384:\nset SqEr,%l3\nset Y,%l2\nld2 [%l2],%f30\nset Half,%l2\nld2 [%l2],%f28\nfsubd %f30,%f28,%f30\nset Z,%l2\nld2 [%l2],%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l3]\nld2 [%l3],%f30\nset MaxSqEr,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbule .L386; nop\nset MaxSqEr,%l3\nset SqEr,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L386:\nset Indx,%l3\nld [%l3],%l3\ncmp %l3,1; be .L390; nop\ncmp %l3,3; bne .L388; nop\n.L390:\nset X,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall Sign; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nstd %f30,[%fp+-88]\nset OneUlp,%l2\nld2 [%l2],%f28\nst %f28,[%sp+4*0+68]\nst %f29,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall sqrt; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Eight,%l2\nld2 [%l2],%f28\nset Nine,%l2\nld2 [%l2],%f26\nfmuld %f26,%f30,%f30\nfdivd %f28,%f30,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset OneUlp,%l2\nld2 [%l2],%f28\nldd [%fp+-88],%f26\nfmuld %f28,%f26,%f28\nfmuld %f28,%f30,%f30\nst2 %f30,[%l3]\nba .L389; nop\n.L388:\nset OneUlp,%l3\nset U1,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset X,%l2\nld2 [%l3],%f30\nfnegs %f30,%f30; fmovs %f31,%f31\nst2 %f30,[%l2]\n.L389:\n.L381:\nset Indx,%l3\nld [%l3],%l2\nadd %l2,1,%l2\nst %l2,[%l3]\nset Indx,%l3\nld [%l3],%l3\ncmp %l3,3; ble .L380; nop\nset Milestone,%l3\nset 85,%l2\nst %l2,[%l3]\nset SqRWrng,%l2\nst %g0,[%l2]\nset Anomaly,%l2\nst %g0,[%l2]\nset RSqrt,%l2\nst %g0,[%l2]\nset Radix,%l3\nld2 [%l3],%f30\nset One,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L391; nop\nset .L393,%o0\ncall printf; nop\nset Precision,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-88]\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Radix,%l3\nld2 [%l3],%f28\nst %f28,[%sp+4*0+68]\nst %f29,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\nset One,%l3\nld2 [%l3],%f28\nldd [%fp+-88],%f26\nfaddd %f28,%f26,%f28\nfsubd %f28,%f30,%f30\nst %f30,[%sp+4*2+68]\nst %f31,[%sp+4*3+68]\nld [%sp+4*2+68],%o2\nld [%sp+4*3+68],%o3\ncall pow; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Half,%l3\nld2 [%l3],%f28\nfaddd %f28,%f30,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset D,%l3\nst2 %f30,[%l3]\nset D,%l3\nld2 [%l3],%f30\nset X,%l3\nset Radix,%l2\nld2 [%l2],%f28\nfdivd %f30,%f28,%f28\nst2 %f28,[%l3]\nset Y,%l3\nset A1,%l2\nld2 [%l2],%f28\nfdivd %f30,%f28,%f30\nst2 %f30,[%l3]\nset X,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-96]\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nldd [%fp+-96],%f28\nfcmped %f28,%f30; nop; fbne .L396; nop\nset Y,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-104]\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nldd [%fp+-104],%f28\nfcmped %f28,%f30; nop; fbue .L394; nop\n.L396:\nset Anomaly,%l3\nset 1,%l2\nst %l2,[%l3]\nba .L395; nop\n.L394:\nset X,%l3\nset Zero,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset Z2,%l2\nld2 [%l3],%f30\nst2 %f30,[%l2]\nset Y,%l3\nset One,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset Y2,%l2\nld2 [%l3],%f28\nst2 %f28,[%l2]\nset Z1,%l3\nset Radix,%l2\nld2 [%l2],%f28\nfsubd %f28,%f30,%f30\nst2 %f30,[%l3]\nset FourD,%l3\nset Four,%l2\nld2 [%l2],%f30\nset D,%l2\nld2 [%l2],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l3]\n.L397:\nset Y2,%l3\nld2 [%l3],%f30\nset Z2,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbule .L400; nop\nset Q,%l3\nset Radix,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset Y1,%l3\nset Y,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L402:\nset Q,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-112]\nset Half,%l3\nld2 [%l3],%f28\nset Y1,%l3\nld2 [%l3],%f26\nfdivd %f30,%f26,%f26\nfsubd %f28,%f26,%f28\nst %f28,[%sp+4*0+68]\nst %f29,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Y1,%l3\nld2 [%l3],%f28\nfmuld %f30,%f28,%f30\nldd [%fp+-112],%f28\nfaddd %f28,%f30,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall fabs; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset X1,%l3\nst2 %f30,[%l3]\nset Y1,%l3\nset Q,%l2\nld2 [%l3],%f30\nst2 %f30,[%l2]\nset X1,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L403:\nset X1,%l3\nld2 [%l3],%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbug .L402; nop\nset Q,%l3\nld2 [%l3],%f30\nset One,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbug .L405; nop\nset Z2,%l3\nset Y2,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset Z,%l3\nset Y,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L405:\n.L400:\nset Y,%l3\nld2 [%l3],%f30\nset Two,%l2\nld2 [%l2],%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l3]\nset X,%l3\nld2 [%l3],%f30\nset Eight,%l2\nld2 [%l2],%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l3]\nset Y2,%l2\nld2 [%l2],%f30\nld2 [%l3],%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l2]\nld2 [%l2],%f30\nset FourD,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbul .L407; nop\nset Y2,%l3\nld2 [%l3],%f30\nset FourD,%l2\nld2 [%l2],%f28\nfsubd %f30,%f28,%f30\nst2 %f30,[%l3]\n.L407:\n.L398:\nset Y,%l3\nld2 [%l3],%f30\nset D,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbul .L397; nop\nset X8,%l3\nset FourD,%l2\nld2 [%l2],%f30\nset Z2,%l2\nld2 [%l2],%f28\nfsubd %f30,%f28,%f28\nst2 %f28,[%l3]\nset Q,%l2\nld2 [%l3],%f28\nset Z,%l1\nld2 [%l1],%f26\nfmuld %f26,%f26,%f26\nfaddd %f28,%f26,%f26\nfdivd %f26,%f30,%f30\nst2 %f30,[%l2]\nset Eight,%l1\nld2 [%l1],%f30\nfdivd %f28,%f30,%f30\nst2 %f30,[%l3]\nld2 [%l2],%f30\nstd %f30,[%fp+-112]\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nldd [%fp+-112],%f28\nfcmped %f28,%f30; nop; fbue .L409; nop\nset Anomaly,%l3\nset 1,%l2\nst %l2,[%l3]\nba .L410; nop\n.L409:\nset Break,%l3\nst %g0,[%l3]\n.L411:\nset X,%l3\nset Z1,%l2\nld2 [%l2],%f30\nset Z,%l2\nld2 [%l2],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l3]\nld2 [%l3],%f30\nstd %f30,[%fp+-120]\nset Radix,%l2\nld2 [%l2],%f28\nfdivd %f30,%f28,%f28\nst %f28,[%sp+4*0+68]\nst %f29,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Radix,%l2\nld2 [%l2],%f28\nfmuld %f30,%f28,%f30\nldd [%fp+-120],%f28\nfsubd %f28,%f30,%f30\nst2 %f30,[%l3]\nset X,%l3\nld2 [%l3],%f30\nset One,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L414; nop\nset Break,%l3\nset 1,%l2\nst %l2,[%l3]\nba .L415; nop\n.L414:\nset Z1,%l3\nld2 [%l3],%f30\nset One,%l2\nld2 [%l2],%f28\nfsubd %f30,%f28,%f30\nst2 %f30,[%l3]\n.L415:\n.L412:\nset Break,%l3\nld [%l3],%l3\ncmp %l3,0; bne .L416; nop\nset Z1,%l3\nld2 [%l3],%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbug .L411; nop\n.L416:\nset Z1,%l3\nld2 [%l3],%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbug .L417; nop\nset Break,%l3\nld [%l3],%l3\ncmp %l3,0; bne .L417; nop\nset Anomaly,%l3\nset 1,%l2\nst %l2,[%l3]\nba .L418; nop\n.L417:\nset Z1,%l3\nld2 [%l3],%f30\nset RadixD2,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbule .L419; nop\nset Z1,%l3\nld2 [%l3],%f30\nset Radix,%l2\nld2 [%l2],%f28\nfsubd %f30,%f28,%f30\nst2 %f30,[%l3]\n.L419:\n.L421:\ncall NewD; nop\n.L422:\nset U2,%l3\nld2 [%l3],%f30\nset D,%l3\nld2 [%l3],%f28\nfmuld %f30,%f28,%f30\nset F9,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbul .L421; nop\nset D,%l3\nld2 [%l3],%f30\nset Radix,%l3\nld2 [%l3],%f28\nfmuld %f30,%f28,%f28\nfsubd %f28,%f30,%f28\nset W,%l3\nld2 [%l3],%f26\nfsubd %f26,%f30,%f30\nfcmped %f28,%f30; nop; fbue .L424; nop\nset Anomaly,%l3\nset 1,%l2\nst %l2,[%l3]\nba .L425; nop\n.L424:\nset D,%l3\nld2 [%l3],%f30\nset Z2,%l3\nst2 %f30,[%l3]\nset I,%l3\nst %g0,[%l3]\nset Z,%l3\nld2 [%l3],%f28\nset Y,%l3\nset One,%l2\nld2 [%l2],%f26\nfaddd %f26,%f28,%f26\nset Half,%l2\nld2 [%l2],%f24\nfmuld %f26,%f24,%f26\nfaddd %f30,%f26,%f26\nst2 %f26,[%l3]\nset X,%l3\nfaddd %f30,%f28,%f30\nset Q,%l2\nld2 [%l2],%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l3]\ncall SR3750; nop\nset D,%l3\nld2 [%l3],%f30\nset Z,%l3\nld2 [%l3],%f28\nset Y,%l3\nset One,%l2\nld2 [%l2],%f26\nfsubd %f26,%f28,%f26\nset Half,%l2\nld2 [%l2],%f24\nfmuld %f26,%f24,%f26\nfaddd %f30,%f26,%f26\nfaddd %f26,%f30,%f26\nst2 %f26,[%l3]\nset X,%l3\nfsubd %f30,%f28,%f28\nfaddd %f28,%f30,%f30\nst2 %f30,[%l3]\nld2 [%l3],%f30\nset Q,%l2\nld2 [%l2],%f28\nfaddd %f30,%f28,%f28\nfaddd %f28,%f30,%f30\nst2 %f30,[%l3]\ncall SR3750; nop\ncall NewD; nop\nset Z2,%l3\nld2 [%l3],%f30\nset D,%l3\nld2 [%l3],%f28\nfsubd %f28,%f30,%f28\nset W,%l3\nld2 [%l3],%f26\nfsubd %f26,%f30,%f30\nfcmped %f28,%f30; nop; fbue .L426; nop\nset Anomaly,%l3\nset 1,%l2\nst %l2,[%l3]\nba .L427; nop\n.L426:\nset Z2,%l3\nld2 [%l3],%f30\nset D,%l3\nld2 [%l3],%f28\nfsubd %f28,%f30,%f28\nset Z,%l3\nld2 [%l3],%f26\nset Y,%l3\nset One,%l2\nld2 [%l2],%f24\nfsubd %f24,%f26,%f24\nset Half,%l2\nld2 [%l2],%f22\nfmuld %f24,%f22,%f24\nfaddd %f30,%f24,%f24\nfaddd %f28,%f24,%f24\nst2 %f24,[%l3]\nset X,%l3\nfsubd %f30,%f26,%f30\nset Q,%l2\nld2 [%l2],%f26\nfaddd %f30,%f26,%f30\nfaddd %f28,%f30,%f30\nst2 %f30,[%l3]\ncall SR3750; nop\nset Y,%l3\nset One,%l2\nld2 [%l2],%f30\nset Z,%l2\nld2 [%l2],%f28\nfaddd %f30,%f28,%f30\nset Half,%l2\nld2 [%l2],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l3]\nset X,%l3\nset Q,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\ncall SR3750; nop\nset I,%l3\nld [%l3],%l3\ncmp %l3,0; bne .L428; nop\nset Anomaly,%l3\nset 1,%l2\nst %l2,[%l3]\n.L428:\n.L427:\n.L425:\n.L418:\n.L410:\n.L395:\nset I,%l2\nld [%l2],%l2\ncmp %l2,%g0; be .L432; nop\nset Anomaly,%l2\nld [%l2],%l2\ncmp %l2,%g0; be .L430; nop\n.L432:\nmov %g0,%o0\nset .L433,%o1\ncall BadCond; nop\nset .L434,%o0\nset W,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset .L435,%o0\ncall printf; nop\nset SqRWrng,%l3\nset 1,%l2\nst %l2,[%l3]\n.L430:\n.L391:\nset Anomaly,%l3\nld [%l3],%l3\ncmp %l3,0; bne .L436; nop\nset Zero,%l3\nld2 [%l3],%f30\nset MinSqEr,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbul .L438; nop\nset MaxSqEr,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbug .L438; nop\nset RSqrt,%l3\nset 1,%l2\nst %l2,[%l3]\nset .L440,%o0\ncall printf; nop\nba .L439; nop\n.L438:\nset U2,%l3\nld2 [%l3],%f30\nset Half,%l3\nld2 [%l3],%f28\nset MaxSqEr,%l3\nld2 [%l3],%f26\nfaddd %f26,%f30,%f26\nfsubd %f30,%f28,%f30\nfcmped %f26,%f30; nop; fbug .L444; nop\nset MinSqEr,%l3\nld2 [%l3],%f30\nfcmped %f30,%f28; nop; fbug .L444; nop\nset Radix,%l3\nld2 [%l3],%f26\nfaddd %f30,%f26,%f30\nfcmped %f30,%f28; nop; fbuge .L441; nop\n.L444:\nset SqRWrng,%l3\nset 1,%l2\nst %l2,[%l3]\nba .L442; nop\n.L441:\nset RSqrt,%l3\nset 2,%l2\nst %l2,[%l3]\nset .L445,%o0\ncall printf; nop\n.L442:\n.L439:\n.L436:\nset SqRWrng,%l3\nld [%l3],%l3\ncmp %l3,0; be .L446; nop\nset .L448,%o0\ncall printf; nop\nset .L449,%o0\nset MinSqEr,%l3\nld2 [%l3],%f30\nset Half,%l3\nld2 [%l3],%f28\nfsubd %f30,%f28,%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset .L450,%o0\nset Half,%l3\nld2 [%l3],%f30\nset MaxSqEr,%l3\nld2 [%l3],%f28\nfaddd %f30,%f28,%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset 1,%o0\nset Radix,%l3\nld2 [%l3],%f30\nset MaxSqEr,%l3\nld2 [%l3],%f28\nset MinSqEr,%l3\nld2 [%l3],%f26\nfsubd %f28,%f26,%f28\nfmuld %f30,%f30,%f30\nfcmped %f28,%f30; nop; fbuge .L453; nop\nset 1,%l3\nst %l3,[%fp+-84]\nba .L454; nop\n.L453:\nst %g0,[%fp+-84]\n.L454:\nld [%fp+-84],%o1\nset .L452,%o2\ncall TstCond; nop\n.L446:\nset Milestone,%l3\nset 90,%l2\nst %l2,[%l3]\ncall Pause; nop\nset .L455,%o0\ncall printf; nop\nset N,%l2\nst %g0,[%l2]\nset I,%l2\nst %g0,[%l2]\nset Z,%l2\nset Zero,%l1\nld2 [%l1],%f30\nfnegs %f30,%f30; fmovs %f31,%f31\nst2 %f30,[%l2]\nset M,%l2\nset 3,%l1\nst %l1,[%l2]\nset Break,%l2\nst %g0,[%l2]\n.L456:\nset X,%l3\nset One,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\ncall SR3980; nop\nset I,%l3\nld [%l3],%l3\ncmp %l3,10; bg .L459; nop\nset I,%l3\nset 1023,%l2\nst %l2,[%l3]\ncall SR3980; nop\n.L459:\nset Z,%l3\nld2 [%l3],%f30\nset MinusOne,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L461; nop\nset Break,%l3\nset 1,%l2\nst %l2,[%l3]\nba .L462; nop\n.L461:\nset Z,%l3\nset MinusOne,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\ncall PrintIfNPositive; nop\nset N,%l3\nst %g0,[%l3]\nset I,%l3\nset -4,%l2\nst %l2,[%l3]\n.L462:\n.L457:\nset Break,%l3\nld [%l3],%l3\ncmp %l3,0; be .L456; nop\ncall PrintIfNPositive; nop\nset N,%l3\nset N1,%l2\nld [%l3],%l1\nst %l1,[%l2]\nst %g0,[%l3]\nset Z,%l3\nset A1,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset W,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall log; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nstd %f30,[%fp+-88]\nset A1,%l3\nld2 [%l3],%f28\nst %f28,[%sp+4*0+68]\nst %f29,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall log; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Two,%l3\nld2 [%l3],%f28\nldd [%fp+-88],%f26\nfmuld %f28,%f26,%f28\nfdivd %f28,%f30,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset M,%l3\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%l2\nst %l2,[%l3]\nset Break,%l3\nst %g0,[%l3]\n.L463:\nset X,%l3\nset Z,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset I,%l3\nset 1,%l2\nst %l2,[%l3]\ncall SR3980; nop\nset Z,%l3\nld2 [%l3],%f30\nset AInvrse,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L466; nop\nset Break,%l3\nset 1,%l2\nst %l2,[%l3]\nba .L467; nop\n.L466:\nset Z,%l3\nset AInvrse,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L467:\n.L464:\nset Break,%l3\nld [%l3],%l3\ncmp %l3,0; be .L463; nop\nset Milestone,%l3\nset 100,%l2\nst %l2,[%l3]\nset M,%l3\nset NoTrials,%l2\nld [%l2],%l2\nst %l2,[%l3]\nset Z,%l3\nset Three,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L468:\nset X,%l3\nset Z,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset I,%l3\nset 1,%l2\nst %l2,[%l3]\ncall SR3980; nop\n.L471:\nset Z,%l3\nld2 [%l3],%f30\nset Two,%l2\nld2 [%l2],%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l3]\n.L472:\nset Three,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-96]\nset Z,%l3\nld2 [%l3],%f28\nfdivd %f28,%f30,%f28\nst %f28,[%sp+4*0+68]\nst %f29,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nldd [%fp+-96],%f28\nfmuld %f28,%f30,%f30\nset Z,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L471; nop\n.L469:\nset Z,%l3\nld2 [%l3],%f30\nset Eight,%l3\nld2 [%l3],%f28\nset Three,%l3\nld2 [%l3],%f26\nfmuld %f28,%f26,%f28\nfcmped %f30,%f28; nop; fbul .L468; nop\nset N,%l3\nld [%l3],%l3\ncmp %l3,0; ble .L474; nop\nset .L476,%o0\ncall printf; nop\nset .L477,%o0\ncall printf; nop\n.L474:\ncall PrintIfNPositive; nop\nset N,%l3\nld [%l3],%l2\nset N1,%l1\nld [%l1],%l1\nadd %l2,%l1,%l2\nst %l2,[%l3]\nld [%l3],%l3\ncmp %l3,0; bne .L478; nop\nset .L480,%o0\ncall printf; nop\n.L478:\nset N,%l3\nld [%l3],%l3\ncmp %l3,0; ble .L481; nop\ncall Pause; nop\nba .L482; nop\n.L481:\nset .L45,%o0\ncall printf; nop\n.L482:\nset Milestone,%l3\nset 110,%l2\nst %l2,[%l3]\nset .L483,%o0\ncall printf; nop\nset D,%l3\nset U1,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset Precision,%l3\nld2 [%l3],%f30\nstd %f30,[%fp+-96]\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nldd [%fp+-96],%f28\nfcmped %f28,%f30; nop; fbue .L484; nop\nset D,%l3\nset BInvrse,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset X,%l3\nset Precision,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L486:\nset D,%l3\nld2 [%l3],%f30\nset BInvrse,%l2\nld2 [%l2],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l3]\nset X,%l3\nld2 [%l3],%f30\nset One,%l2\nld2 [%l2],%f28\nfsubd %f30,%f28,%f30\nst2 %f30,[%l3]\n.L487:\nset X,%l3\nld2 [%l3],%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbug .L486; nop\n.L484:\nset Y,%l3\nset One,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset Z,%l3\nset D,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L489:\nset Y,%l3\nset C,%l2\nld2 [%l3],%f30\nst2 %f30,[%l2]\nset Z,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nld2 [%l3],%f30\nfmuld %f30,%f30,%f30\nst2 %f30,[%l2]\n.L490:\nset Z,%l3\nld2 [%l3],%f30\nset Y,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbule .L492; nop\nfaddd %f30,%f30,%f28\nfcmped %f28,%f30; nop; fbug .L489; nop\n.L492:\nset Y,%l3\nset C,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset Z,%l2\nld2 [%l3],%f30\nset D,%l3\nld2 [%l3],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l2]\n.L493:\nset Y,%l3\nset C,%l2\nld2 [%l3],%f30\nst2 %f30,[%l2]\nset Z,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nld2 [%l3],%f30\nset D,%l3\nld2 [%l3],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l2]\n.L494:\nset Z,%l3\nld2 [%l3],%f30\nset Y,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbule .L496; nop\nfaddd %f30,%f30,%f28\nfcmped %f28,%f30; nop; fbug .L493; nop\n.L496:\nset Radix,%l3\nld2 [%l3],%f30\nset Two,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbuge .L497; nop\nset HInvrse,%l3\nset Two,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nba .L498; nop\n.L497:\nset HInvrse,%l3\nset Radix,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L498:\nset H,%l3\nset One,%l2\nld2 [%l2],%f30\nset HInvrse,%l2\nld2 [%l2],%f28\nfdivd %f30,%f28,%f28\nst2 %f28,[%l3]\nset C,%l2\nld2 [%l2],%f28\nset CInvrse,%l2\nfdivd %f30,%f28,%f30\nst2 %f30,[%l2]\nset E0,%l2\nst2 %f28,[%l2]\nset Z,%l1\nld2 [%l2],%f30\nld2 [%l3],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l1]\n.L499:\nset E0,%l3\nset Y,%l2\nld2 [%l3],%f30\nst2 %f30,[%l2]\nset Z,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nld2 [%l3],%f30\nset H,%l3\nld2 [%l3],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l2]\n.L500:\nset Z,%l3\nld2 [%l3],%f30\nset E0,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbule .L502; nop\nfaddd %f30,%f30,%f28\nfcmped %f28,%f30; nop; fbug .L499; nop\n.L502:\nset UfThold,%l3\nset E0,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset Zero,%l3\nld2 [%l3],%f30\nset E1,%l3\nst2 %f30,[%l3]\nset Q,%l3\nst2 %f30,[%l3]\nset E9,%l3\nset U2,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset S,%l2\nset One,%l1\nld2 [%l1],%f30\nld2 [%l3],%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l2]\nset D,%l3\nset C,%l1\nld2 [%l1],%f30\nld2 [%l2],%f28\nfmuld %f30,%f28,%f28\nst2 %f28,[%l3]\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbug .L503; nop\nset E9,%l3\nset Radix,%l2\nld2 [%l2],%f30\nset U2,%l2\nld2 [%l2],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l3]\nset S,%l2\nset One,%l1\nld2 [%l1],%f30\nld2 [%l3],%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l2]\nset D,%l3\nset C,%l1\nld2 [%l1],%f30\nld2 [%l2],%f28\nfmuld %f30,%f28,%f28\nst2 %f28,[%l3]\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbug .L504; nop\nmov %g0,%o0\nset .L507,%o1\ncall BadCond; nop\nset Underflow,%l3\nset E0,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset Y1,%l3\nset Zero,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset PseudoZero,%l3\nset Z,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\ncall Pause; nop\nba .L504; nop\n.L503:\nset Underflow,%l3\nset D,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset PseudoZero,%l2\nld2 [%l3],%f30\nset H,%l3\nld2 [%l3],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l2]\nset UfThold,%l3\nset Zero,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L508:\nset Underflow,%l3\nset Y1,%l2\nld2 [%l3],%f30\nst2 %f30,[%l2]\nset PseudoZero,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset E1,%l3\nld2 [%l3],%f30\nfaddd %f30,%f30,%f28\nfcmped %f28,%f30; nop; fbug .L511; nop\nset Y2,%l3\nset Underflow,%l2\nld2 [%l2],%f30\nset HInvrse,%l2\nld2 [%l2],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l3]\nset Y1,%l2\nld2 [%l2],%f30\nld2 [%l3],%f28\nfsubd %f30,%f28,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall fabs; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset E1,%l3\nst2 %f30,[%l3]\nset Q,%l3\nset Y1,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset UfThold,%l3\nld2 [%l3],%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L513; nop\nset Y1,%l3\nld2 [%l3],%f30\nset Y2,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L513; nop\nset UfThold,%l3\nset Y1,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L513:\n.L511:\nset PseudoZero,%l3\nld2 [%l3],%f30\nset H,%l2\nld2 [%l2],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l3]\n.L509:\nset PseudoZero,%l3\nld2 [%l3],%f30\nset Underflow,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbule .L515; nop\nfaddd %f30,%f30,%f28\nfcmped %f28,%f30; nop; fbug .L508; nop\n.L515:\n.L504:\nset PseudoZero,%l3\nld2 [%l3],%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L516; nop\nset .L45,%o0\ncall printf; nop\nset PseudoZero,%l3\nld2 [%l3],%f30\nset Z,%l3\nst2 %f30,[%l3]\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbug .L518; nop\nmov %g0,%o0\nset .L520,%o1\ncall BadCond; nop\nset .L521,%o0\ncall printf; nop\nset .L522,%o0\nset PseudoZero,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset X,%l3\nset PseudoZero,%l2\nld2 [%l2],%f30\nfnegs %f30,%f30; fmovs %f31,%f31\nst2 %f30,[%l3]\nld2 [%l3],%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbug .L519; nop\nset .L525,%o0\ncall printf; nop\nset .L526,%o0\nset X,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nba .L519; nop\n.L518:\nset 3,%o0\nset .L527,%o1\ncall BadCond; nop\nset .L528,%o0\nset PseudoZero,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\n.L519:\ncall TstPtUf; nop\n.L516:\nset Milestone,%l3\nset 120,%l2\nst %l2,[%l3]\nset CInvrse,%l3\nld2 [%l3],%f30\nset Y,%l3\nld2 [%l3],%f28\nfmuld %f30,%f28,%f28\nset Y1,%l3\nld2 [%l3],%f26\nfmuld %f30,%f26,%f30\nfcmped %f28,%f30; nop; fbule .L529; nop\nset S,%l3\nset H,%l2\nld2 [%l2],%f30\nld2 [%l3],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l3]\nset E0,%l3\nset Underflow,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L529:\nset E1,%l3\nld2 [%l3],%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L531; nop\nset E0,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L531; nop\nset 2,%o0\nset .L158,%o1\ncall BadCond; nop\nset E1,%l3\nld2 [%l3],%f30\nset E0,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbuge .L533; nop\nset .L535,%o0\ncall printf; nop\nset .L536,%o0\ncall printf; nop\nset PseudoZero,%l3\nld2 [%l3],%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L534; nop\nset E0,%l3\nset E1,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nba .L534; nop\n.L533:\nset .L539,%o0\ncall printf; nop\nset .L540,%o0\ncall printf; nop\n.L534:\n.L531:\nset .L541,%o0\nset E0,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset Z,%l3\nset E0,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\ncall TstPtUf; nop\nset Underflow,%l3\nset E0,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset N,%l3\nld [%l3],%l3\ncmp %l3,1; bne .L542; nop\nset Underflow,%l3\nset Y,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L542:\nset I,%l3\nset 4,%l2\nst %l2,[%l3]\nset E1,%l3\nld2 [%l3],%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L544; nop\nset I,%l3\nset 3,%l2\nst %l2,[%l3]\n.L544:\nset UfThold,%l3\nld2 [%l3],%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L546; nop\nset I,%l3\nld [%l3],%l2\nsub %l2,2,%l2\nst %l2,[%l3]\n.L546:\nset UfNGrad,%l3\nset 1,%l2\nst %l2,[%l3]\nset I,%l3\nld [%l3],%l3\ncmp %l3,1; bl .L548; nop\ncmp %l3,4; bg .L548; nop\nsll %l3,2,%l3\nset .L571-4,%l2\nld [%l3+%l2],%l3\njmp %l3; nop\n.section \".rodata\"\n.align 4\n.L571:\n.word .L550\n.word .L557\n.word .L562\n.word .L563\n.section \".text\"\n.L550:\nset UfThold,%l3\nset Underflow,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset CInvrse,%l3\nld2 [%l3],%f30\nset Q,%l3\nld2 [%l3],%f28\nfmuld %f30,%f28,%f28\nset Y,%l3\nld2 [%l3],%f26\nfmuld %f30,%f26,%f30\nset S,%l3\nld2 [%l3],%f26\nfmuld %f30,%f26,%f30\nfcmped %f28,%f30; nop; fbue .L551; nop\nset UfThold,%l3\nset Y,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nmov %g0,%o0\nset .L553,%o1\ncall BadCond; nop\nset .L554,%o0\nset UfThold,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset .L555,%o0\nset C,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset .L556,%o0\ncall printf; nop\n.L551:\ncall Pause; nop\nba .L549; nop\n.L557:\nmov %g0,%o0\nset .L558,%o1\ncall BadCond; nop\nset .L559,%o0\ncall printf; nop\nset .L560,%o0\nset Q,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\nset Y2,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*3+68]\nst %f31,[%sp+4*4+68]\nld [%sp+4*3+68],%o3\nld [%sp+4*4+68],%o4\ncall printf; nop\nset Q,%l3\nld2 [%l3],%f30\nset Y2,%l3\nld2 [%l3],%f28\nfsubd %f30,%f28,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall fabs; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset .L561,%o0\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset UfThold,%l3\nset Q,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nba .L549; nop\n.L562:\nset X,%l3\nld2 [%l3],%f30\nst2 %f30,[%l3]\nba .L549; nop\n.L563:\nset UfThold,%l3\nld2 [%l3],%f30\nset Q,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L564; nop\nset E1,%l3\nld2 [%l3],%f28\nset E0,%l3\nld2 [%l3],%f26\nfcmped %f28,%f26; nop; fbne .L564; nop\nset E9,%l3\nld2 [%l3],%f26\nfdivd %f28,%f26,%f28\nfsubd %f30,%f28,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall fabs; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset E1,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbug .L564; nop\nset UfNGrad,%l3\nst %g0,[%l3]\nset .L566,%o0\ncall printf; nop\nset .L567,%o0\ncall printf; nop\nset Y,%l3\nset E0,%l2\nld2 [%l2],%f30\nset CInvrse,%l2\nld2 [%l2],%f28\nfmuld %f30,%f28,%f26\nst2 %f26,[%l3]\nset U2,%l2\nld2 [%l2],%f26\nld2 [%l3],%f24\nset OneAndHalf,%l2\nld2 [%l2],%f22\nfaddd %f22,%f26,%f22\nfmuld %f24,%f22,%f24\nst2 %f24,[%l3]\nset X,%l2\nset One,%l1\nld2 [%l1],%f24\nfaddd %f24,%f26,%f26\nfmuld %f28,%f26,%f28\nst2 %f28,[%l2]\nld2 [%l3],%f28\nld2 [%l2],%f26\nfdivd %f28,%f26,%f28\nst2 %f28,[%l3]\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L569; nop\nset 1,%l3\nst %l3,[%fp+-100]\nba .L570; nop\n.L569:\nst %g0,[%fp+-100]\n.L570:\nset IEEE,%l3\nld [%fp+-100],%l2\nst %l2,[%l3]\n.L564:\n.L548:\n.L549:\nset UfNGrad,%l3\nld [%l3],%l3\ncmp %l3,0; be .L573; nop\nset .L45,%o0\ncall printf; nop\nset sigsave,%l3\nset sigfpe,%l2\nst %l2,[%l3]\nset ovfl_buf,%o0\ncall setjmp; nop\ncmp %o0,0; be .L575; nop\nset .L577,%o0\ncall printf; nop\nset H,%l3\nld2 [%l3],%f30\nset R,%l3\nfaddd %f30,%f30,%f30\nst2 %f30,[%l3]\nba .L576; nop\n.L575:\nset Underflow,%l3\nld2 [%l3],%f30\nset UfThold,%l3\nld2 [%l3],%f28\nfdivd %f30,%f28,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall sqrt; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset R,%l3\nst2 %f30,[%l3]\n.L576:\nset sigsave,%l3\nst %g0,[%l3]\nset R,%l3\nld2 [%l3],%f30\nset H,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbug .L578; nop\nset Z,%l3\nset R,%l2\nld2 [%l2],%f30\nset UfThold,%l2\nld2 [%l2],%f28\nfmuld %f30,%f28,%f28\nst2 %f28,[%l3]\nset One,%l2\nld2 [%l2],%f28\nset H,%l2\nld2 [%l2],%f26\nset X,%l2\nld2 [%l3],%f24\nfmuld %f30,%f26,%f30\nfaddd %f28,%f26,%f26\nfmuld %f30,%f26,%f30\nfaddd %f28,%f30,%f30\nfmuld %f24,%f30,%f30\nst2 %f30,[%l2]\nba .L579; nop\n.L578:\nset Z,%l3\nset UfThold,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset One,%l2\nld2 [%l2],%f30\nset H,%l2\nld2 [%l2],%f28\nset X,%l2\nld2 [%l3],%f26\nfmuld %f28,%f28,%f24\nfaddd %f30,%f28,%f28\nfmuld %f24,%f28,%f28\nfaddd %f30,%f28,%f30\nfmuld %f26,%f30,%f30\nst2 %f30,[%l2]\n.L579:\nset X,%l3\nld2 [%l3],%f30\nset Z,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L580; nop\nfsubd %f30,%f28,%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L580; nop\nset 3,%o0\nset .L158,%o1\ncall BadCond; nop\nset .L582,%o0\nset X,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\nset Z,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*3+68]\nst %f31,[%sp+4*4+68]\nld [%sp+4*3+68],%o3\nld [%sp+4*4+68],%o4\ncall printf; nop\nset Z9,%l3\nset X,%l2\nld2 [%l2],%f30\nset Z,%l2\nld2 [%l2],%f28\nfsubd %f30,%f28,%f30\nst2 %f30,[%l3]\nset .L583,%o0\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset .L584,%o0\ncall printf; nop\nset .L585,%o0\ncall printf; nop\nset .L586,%o0\ncall printf; nop\nset .L587,%o0\ncall printf; nop\nset .L588,%o0\ncall printf; nop\nset .L589,%o0\ncall printf; nop\nset sigsave,%l3\nset sigfpe,%l2\nst %l2,[%l3]\nset ovfl_buf,%o0\ncall setjmp; nop\ncmp %o0,0; be .L590; nop\nset .L592,%o0\ncall printf; nop\nba .L591; nop\n.L590:\nset .L593,%o0\nset Half,%l3\nld2 [%l3],%f30\nset X,%l3\nld2 [%l3],%f28\nset Z,%l3\nld2 [%l3],%f26\nfdivd %f28,%f26,%f28\nfsubd %f28,%f30,%f28\nfsubd %f28,%f30,%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\n.L591:\nset sigsave,%l3\nst %g0,[%l3]\n.L580:\n.L573:\nset .L594,%o0\nset UfThold,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\nset .L595,%o3\ncall printf; nop\nset .L596,%o0\ncall printf; nop\nset .L597,%o0\ncall printf; nop\nset Y2,%l3\nset U1,%l2\nld2 [%l2],%f30\nfmuld %f30,%f30,%f28\nst2 %f28,[%l3]\nset Y,%l2\nld2 [%l3],%f28\nfmuld %f28,%f28,%f28\nst2 %f28,[%l2]\nld2 [%l2],%f28\nfmuld %f28,%f30,%f30\nst2 %f30,[%l3]\nld2 [%l3],%f30\nset UfThold,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbug .L598; nop\nset Y,%l3\nld2 [%l3],%f30\nset E0,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbule .L600; nop\nset 2,%o0\nset .L158,%o1\ncall BadCond; nop\nset I,%l3\nset 5,%l2\nst %l2,[%l3]\nba .L601; nop\n.L600:\nset 1,%o0\nset .L158,%o1\ncall BadCond; nop\nset I,%l3\nset 4,%l2\nst %l2,[%l3]\n.L601:\nset .L602,%o0\nset I,%l3\nld [%l3],%o1\ncall printf; nop\n.L598:\nset Milestone,%l3\nset 130,%l2\nst %l2,[%l3]\nset UfThold,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall log; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nstd %f30,[%fp+-104]\nset HInvrse,%l3\nld2 [%l3],%f28\nst %f28,[%sp+4*0+68]\nst %f29,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall log; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Half,%l3\nld2 [%l3],%f28\nset TwoForty,%l3\nld2 [%l3],%f26\nldd [%fp+-104],%f24\nfmuld %f26,%f24,%f26\nfdivd %f26,%f30,%f30\nfsubd %f28,%f30,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Y,%l3\nfnegs %f30,%f30; fmovs %f31,%f31\nset TwoForty,%l2\nld2 [%l2],%f28\nfdivd %f30,%f28,%f30\nst2 %f30,[%l3]\nset Y,%l3\nld2 [%l3],%f30\nset Y2,%l3\nfaddd %f30,%f30,%f30\nst2 %f30,[%l3]\nset .L603,%o0\ncall printf; nop\nset .L604,%o0\nset HInvrse,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\nset Y,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*3+68]\nst %f31,[%sp+4*4+68]\nld [%sp+4*3+68],%o3\nld [%sp+4*4+68],%o4\ncall printf; nop\nset .L605,%o0\nset HInvrse,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\nset Y,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*3+68]\nst %f31,[%sp+4*4+68]\nld [%sp+4*3+68],%o3\nld [%sp+4*4+68],%o4\ncall printf; nop\nset HInvrse,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\nset Y2,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*2+68]\nst %f31,[%sp+4*3+68]\nld [%sp+4*2+68],%o2\nld [%sp+4*3+68],%o3\ncall pow; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset V9,%l3\nst2 %f30,[%l3]\nset .L606,%o0\nset V9,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset V9,%l3\nld2 [%l3],%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbul .L609; nop\nset Radix,%l3\nld2 [%l3],%f28\nfaddd %f28,%f28,%f28\nset E9,%l3\nld2 [%l3],%f26\nfaddd %f28,%f26,%f28\nset UfThold,%l3\nld2 [%l3],%f26\nfmuld %f28,%f26,%f28\nfcmped %f30,%f28; nop; fbule .L607; nop\n.L609:\nset 1,%o0\nset .L610,%o1\ncall BadCond; nop\nset .L611,%o0\nset UfThold,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nba .L608; nop\n.L607:\nset V9,%l3\nld2 [%l3],%f30\nset UfThold,%l3\nld2 [%l3],%f28\nset One,%l3\nld2 [%l3],%f26\nset E9,%l3\nld2 [%l3],%f24\nfaddd %f26,%f24,%f26\nfmuld %f28,%f26,%f28\nfcmped %f30,%f28; nop; fbug .L612; nop\nset .L614,%o0\ncall printf; nop\nba .L613; nop\n.L612:\nset 2,%o0\nset .L610,%o1\ncall BadCond; nop\nset .L611,%o0\nset UfThold,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\n.L613:\n.L608:\nset Milestone,%l3\nset 140,%l2\nst %l2,[%l3]\nset .L45,%o0\ncall printf; nop\nset Zero,%l3\nld2 [%l3],%f30\nset X,%l3\nst2 %f30,[%l3]\nset I,%l3\nset 2,%l2\nst %l2,[%l3]\nset Y,%l3\nset Two,%l2\nld2 [%l2],%f28\nset Three,%l2\nld2 [%l2],%f26\nfmuld %f28,%f26,%f28\nst2 %f28,[%l3]\nset Q,%l3\nst2 %f30,[%l3]\nset N,%l3\nst %g0,[%l3]\n.L615:\nset Z,%l3\nset X,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset I,%l1\nld [%l1],%l0\nadd %l0,1,%l0\nst %l0,[%l1]\nset Y,%l0\nld [%l1],%l1\nld2 [%l0],%f30\nadd %l1,%l1,%l1\nst %l1,[%sp+64]; ld [%sp+64],%f28; fitod %f28,%f28\nfdivd %f30,%f28,%f30\nst2 %f30,[%l0]\nset R,%l1\nset Q,%o5\nld2 [%l0],%f30\nld2 [%o5],%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l1]\nld2 [%l3],%f30\nld2 [%l1],%f28\nfaddd %f30,%f28,%f26\nst2 %f26,[%l2]\nld2 [%l2],%f26\nfsubd %f30,%f26,%f30\nfaddd %f30,%f28,%f30\nst2 %f30,[%o5]\n.L616:\nset X,%l3\nld2 [%l3],%f30\nset Z,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbug .L615; nop\nset Z,%l3\nset OneAndHalf,%l2\nld2 [%l2],%f30\nset X,%l2\nset One,%l1\nld2 [%l1],%f28\nset Eight,%l1\nld2 [%l1],%f26\nfdivd %f28,%f26,%f28\nfaddd %f30,%f28,%f28\nld2 [%l2],%f26\nset ThirtyTwo,%l1\nld2 [%l1],%f24\nfmuld %f30,%f24,%f30\nfdivd %f26,%f30,%f30\nfaddd %f28,%f30,%f30\nst2 %f30,[%l3]\nld2 [%l3],%f30\nfmuld %f30,%f30,%f30\nst2 %f30,[%l2]\nset Exp2,%l3\nld2 [%l2],%f30\nfmuld %f30,%f30,%f30\nst2 %f30,[%l3]\nset F9,%l1\nld2 [%l1],%f30\nst2 %f30,[%l2]\nset Y,%l1\nld2 [%l2],%f30\nset U1,%l2\nld2 [%l2],%f28\nfsubd %f30,%f28,%f30\nst2 %f30,[%l1]\nset .L618,%o0\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset I,%l3\nset 1,%l2\nst %l2,[%l3]\n.L619:\nset Z,%l3\nset X,%l2\nld2 [%l2],%f30\nset BInvrse,%l2\nld2 [%l2],%f28\nfsubd %f30,%f28,%f26\nst2 %f26,[%l3]\nset One,%l2\nld2 [%l2],%f26\nfaddd %f30,%f26,%f24\nld2 [%l3],%f22\nfsubd %f26,%f28,%f28\nfsubd %f22,%f28,%f28\nfdivd %f24,%f28,%f28\nst2 %f28,[%l3]\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\nld2 [%l3],%f30\nst %f30,[%sp+4*2+68]\nst %f31,[%sp+4*3+68]\nld [%sp+4*2+68],%o2\nld [%sp+4*3+68],%o3\ncall pow; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Q,%l3\nset Exp2,%l2\nld2 [%l2],%f28\nfsubd %f30,%f28,%f30\nst2 %f30,[%l3]\nset Q,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall fabs; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset TwoForty,%l3\nld2 [%l3],%f28\nset U2,%l3\nld2 [%l3],%f26\nfmuld %f28,%f26,%f28\nfcmped %f30,%f28; nop; fbule .L623; nop\nset N,%l3\nset 1,%l2\nst %l2,[%l3]\nset BInvrse,%l3\nld2 [%l3],%f30\nset V9,%l3\nset X,%l2\nld2 [%l2],%f28\nfsubd %f28,%f30,%f28\nset One,%l2\nld2 [%l2],%f26\nfsubd %f26,%f30,%f30\nfsubd %f28,%f30,%f30\nst2 %f30,[%l3]\nset 2,%o0\nset .L625,%o1\ncall BadCond; nop\nset X,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\nset Z,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*2+68]\nst %f31,[%sp+4*3+68]\nld [%sp+4*2+68],%o2\nld [%sp+4*3+68],%o3\ncall pow; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset .L626,%o0\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset .L627,%o0\nset V9,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\nset Z,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*3+68]\nst %f31,[%sp+4*4+68]\nld [%sp+4*3+68],%o3\nld [%sp+4*4+68],%o4\ncall printf; nop\nset .L628,%o0\nset Q,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset .L629,%o0\ncall printf; nop\nset .L630,%o0\ncall printf; nop\nba .L621; nop\n.L623:\nset Z,%l3\nset Y,%l2\nld2 [%l2],%f30\nset X,%l1\nld2 [%l1],%f28\nfsubd %f30,%f28,%f28\nset Two,%l0\nld2 [%l0],%f26\nfmuld %f28,%f26,%f28\nfaddd %f28,%f30,%f28\nst2 %f28,[%l3]\nst2 %f30,[%l1]\nld2 [%l3],%f30\nst2 %f30,[%l2]\nld2 [%l1],%f30\nset F9,%l2\nld2 [%l2],%f28\nfsubd %f30,%f28,%f30\nset One,%l2\nld2 [%l2],%f28\nfmuld %f30,%f30,%f30\nfaddd %f28,%f30,%f30\nst2 %f30,[%l3]\nset Z,%l3\nld2 [%l3],%f30\nset One,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbule .L631; nop\nset I,%l3\nld [%l3],%l3\nset NoTrials,%l2\nld [%l2],%l2\ncmp %l3,%l2; bge .L631; nop\nset I,%l3\nld [%l3],%l2\nadd %l2,1,%l2\nst %l2,[%l3]\nba .L619; nop\n.L631:\nset X,%l3\nld2 [%l3],%f30\nset One,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbule .L633; nop\nset N,%l3\nld [%l3],%l3\ncmp %l3,0; bne .L621; nop\nset .L637,%o0\ncall printf; nop\nba .L621; nop\n.L633:\nset X,%l3\nset U2,%l2\nld2 [%l2],%f30\nset One,%l2\nld2 [%l2],%f28\nfaddd %f28,%f30,%f28\nst2 %f28,[%l3]\nset Y,%l2\nfaddd %f30,%f30,%f30\nst2 %f30,[%l2]\nld2 [%l2],%f30\nld2 [%l3],%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l2]\nset I,%l3\nset 1,%l2\nst %l2,[%l3]\nba .L619; nop\n.L621:\nset Milestone,%l3\nset 150,%l2\nst %l2,[%l3]\nset .L638,%o0\ncall printf; nop\nset N,%l3\nst %g0,[%l3]\nset Z,%l3\nset A1,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset C,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall log; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nstd %f30,[%fp+-112]\nset A1,%l3\nld2 [%l3],%f28\nst %f28,[%sp+4*0+68]\nst %f29,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall log; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Half,%l3\nld2 [%l3],%f28\nldd [%fp+-112],%f26\nfdivd %f26,%f30,%f30\nfsubd %f28,%f30,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Q,%l3\nst2 %f30,[%l3]\nset Break,%l3\nst %g0,[%l3]\n.L639:\nset X,%l3\nset CInvrse,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset Z,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\nset Q,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*2+68]\nst %f31,[%sp+4*3+68]\nld [%sp+4*2+68],%o2\nld [%sp+4*3+68],%o3\ncall pow; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Y,%l3\nst2 %f30,[%l3]\ncall IsYeqX; nop\nset Q,%l3\nld2 [%l3],%f30\nfnegs %f30,%f30; fmovs %f31,%f31\nst2 %f30,[%l3]\nset X,%l2\nset C,%l1\nld2 [%l1],%f30\nst2 %f30,[%l2]\nset Z,%l2\nld2 [%l2],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\nld2 [%l3],%f30\nst %f30,[%sp+4*2+68]\nst %f31,[%sp+4*3+68]\nld [%sp+4*2+68],%o2\nld [%sp+4*3+68],%o3\ncall pow; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Y,%l3\nst2 %f30,[%l3]\ncall IsYeqX; nop\nset Z,%l3\nld2 [%l3],%f30\nset One,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbuge .L642; nop\nset Break,%l3\nset 1,%l2\nst %l2,[%l3]\nba .L643; nop\n.L642:\nset Z,%l3\nset AInvrse,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L643:\n.L640:\nset Break,%l3\nld [%l3],%l3\ncmp %l3,0; be .L639; nop\ncall PrintIfNPositive; nop\nset N,%l3\nld [%l3],%l3\ncmp %l3,0; bne .L644; nop\nset .L646,%o0\ncall printf; nop\n.L644:\nset .L45,%o0\ncall printf; nop\nset Milestone,%l3\nset 160,%l2\nst %l2,[%l3]\ncall Pause; nop\nset .L647,%o0\ncall printf; nop\nset .L648,%o0\ncall printf; nop\nset Y,%l3\nset CInvrse,%l2\nld2 [%l2],%f30\nfnegs %f30,%f30; fmovs %f31,%f31\nst2 %f30,[%l3]\nset V9,%l2\nset HInvrse,%l1\nld2 [%l1],%f30\nld2 [%l3],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l2]\nset sigsave,%l3\nset sigfpe,%l2\nst %l2,[%l3]\nset ovfl_buf,%o0\ncall setjmp; nop\ncmp %o0,0; be .L649; nop\nset I,%l3\nst %g0,[%l3]\nset V9,%l3\nset Y,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nba .L651; nop\n.L649:\n.L652:\nset Y,%l3\nset V,%l2\nld2 [%l3],%f30\nst2 %f30,[%l2]\nset V9,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset HInvrse,%l1\nld2 [%l1],%f30\nld2 [%l3],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l2]\n.L653:\nset V9,%l3\nld2 [%l3],%f30\nset Y,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbul .L652; nop\nset I,%l3\nset 1,%l2\nst %l2,[%l3]\n.L651:\nset sigsave,%l3\nst %g0,[%l3]\nset Z,%l3\nset V9,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset .L655,%o0\ncall printf; nop\nset .L656,%o0\nset Y,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset V9,%l3\nset Y,%l2\nld2 [%l2],%f30\nfnegs %f30,%f28; fmovs %f31,%f29\nst2 %f28,[%l3]\nset V0,%l2\nld2 [%l3],%f28\nst2 %f28,[%l2]\nset V,%l3\nld2 [%l3],%f28\nfsubd %f28,%f30,%f30\nld2 [%l2],%f26\nfaddd %f28,%f26,%f28\nfcmped %f30,%f28; nop; fbne .L657; nop\nset .L659,%o0\ncall printf; nop\nba .L658; nop\n.L657:\nset .L660,%o0\ncall printf; nop\nset 3,%o0\nset .L661,%o1\ncall BadCond; nop\n.L658:\nset Z,%l3\nld2 [%l3],%f30\nset Y,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L662; nop\nset 1,%o0\nset .L158,%o1\ncall BadCond; nop\nset .L664,%o0\nset Y,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\nset Z,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*3+68]\nst %f31,[%sp+4*4+68]\nld [%sp+4*3+68],%o3\nld [%sp+4*4+68],%o4\ncall printf; nop\n.L662:\nset I,%l3\nld [%l3],%l3\ncmp %l3,0; be .L665; nop\nset Y,%l3\nset V,%l2\nld2 [%l2],%f30\nset HInvrse,%l2\nld2 [%l2],%f28\nset U2,%l2\nld2 [%l2],%f26\nfmuld %f28,%f26,%f24\nfsubd %f24,%f28,%f24\nfmuld %f30,%f24,%f24\nst2 %f24,[%l3]\nset Z,%l2\nld2 [%l3],%f24\nset One,%l3\nld2 [%l3],%f22\nfsubd %f22,%f28,%f28\nfmuld %f28,%f26,%f28\nfmuld %f28,%f30,%f30\nfaddd %f24,%f30,%f30\nst2 %f30,[%l2]\nld2 [%l2],%f30\nset V0,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbuge .L667; nop\nset Y,%l3\nset Z,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L667:\nset Y,%l3\nld2 [%l3],%f30\nset V0,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbuge .L669; nop\nset V,%l3\nset Y,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L669:\nset V0,%l3\nld2 [%l3],%f30\nset V,%l3\nld2 [%l3],%f28\nfsubd %f30,%f28,%f28\nfcmped %f28,%f30; nop; fbuge .L666; nop\nset V,%l3\nset V0,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nba .L666; nop\n.L665:\nset V,%l3\nset Y,%l2\nld2 [%l2],%f30\nset HInvrse,%l2\nld2 [%l2],%f28\nset U2,%l2\nld2 [%l2],%f26\nfmuld %f28,%f26,%f24\nfsubd %f24,%f28,%f24\nfmuld %f30,%f24,%f24\nst2 %f24,[%l3]\nld2 [%l3],%f24\nset One,%l2\nld2 [%l2],%f22\nfsubd %f22,%f28,%f28\nfmuld %f28,%f26,%f28\nfmuld %f28,%f30,%f30\nfaddd %f24,%f30,%f30\nst2 %f30,[%l3]\n.L666:\nset .L673,%o0\nset V,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset I,%l3\nld [%l3],%l3\ncmp %l3,0; be .L674; nop\nset .L676,%o0\nset V0,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nba .L675; nop\n.L674:\nset .L677,%o0\ncall printf; nop\n.L675:\nset V9,%l3\nset V,%l2\nld2 [%l2],%f30\nset One,%l2\nld2 [%l2],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l3]\nset .L678,%o0\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset V9,%l3\nset V,%l2\nld2 [%l2],%f30\nset One,%l2\nld2 [%l2],%f28\nfdivd %f30,%f28,%f30\nst2 %f30,[%l3]\nset .L679,%o0\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset .L680,%o0\ncall printf; nop\nset .L681,%o0\ncall printf; nop\nset Milestone,%l3\nset 170,%l2\nst %l2,[%l3]\nset V,%l3\nld2 [%l3],%f30\nfnegs %f30,%f28; fmovs %f31,%f29\nfcmped %f28,%f30; nop; fbuge .L686; nop\nset V0,%l3\nld2 [%l3],%f28\nfnegs %f28,%f26; fmovs %f29,%f27\nfcmped %f26,%f28; nop; fbuge .L686; nop\nset UfThold,%l3\nld2 [%l3],%f28\nfnegs %f28,%f26; fmovs %f29,%f27\nfcmped %f26,%f30; nop; fbuge .L686; nop\nfcmped %f28,%f30; nop; fbul .L682; nop\n.L686:\nmov %g0,%o0\nset .L687,%o1\ncall BadCond; nop\nset .L688,%o0\nset V,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\nset V0,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*3+68]\nst %f31,[%sp+4*4+68]\nld [%sp+4*3+68],%o3\nld [%sp+4*4+68],%o4\nset UfThold,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*5+68]\nst %f31,[%sp+4*6+68]\nld [%sp+4*5+68],%o5\ncall printf; nop\n.L682:\nset Milestone,%l3\nset 175,%l2\nst %l2,[%l3]\nset .L45,%o0\ncall printf; nop\nset Indx,%l3\nset 1,%l2\nst %l2,[%l3]\n.L689:\nset Indx,%l3\nld [%l3],%l3\ncmp %l3,1; be .L695; nop\ncmp %l3,2; be .L696; nop\ncmp %l3,3; be .L697; nop\nba .L693; nop\n.L695:\nset Z,%l3\nset UfThold,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nba .L694; nop\n.L696:\nset Z,%l3\nset E0,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nba .L694; nop\n.L697:\nset Z,%l3\nset PseudoZero,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L693:\n.L694:\nset Z,%l3\nld2 [%l3],%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbue .L698; nop\nset Z,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall sqrt; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset V9,%l3\nst2 %f30,[%l3]\nset V9,%l3\nld2 [%l3],%f30\nset Y,%l3\nfmuld %f30,%f30,%f30\nst2 %f30,[%l3]\nset Y,%l3\nld2 [%l3],%f30\nset One,%l3\nld2 [%l3],%f28\nset Radix,%l3\nld2 [%l3],%f26\nset E9,%l3\nld2 [%l3],%f24\nfmuld %f26,%f24,%f26\nset Z,%l3\nld2 [%l3],%f24\nfsubd %f28,%f26,%f22\nfdivd %f30,%f22,%f22\nfcmped %f22,%f24; nop; fbul .L702; nop\nfaddd %f28,%f26,%f28\nfmuld %f28,%f24,%f28\nfcmped %f30,%f28; nop; fbule .L700; nop\n.L702:\nset V9,%l3\nld2 [%l3],%f30\nset U1,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbule .L703; nop\nset 1,%o0\nset .L158,%o1\ncall BadCond; nop\nba .L704; nop\n.L703:\nset 2,%o0\nset .L158,%o1\ncall BadCond; nop\n.L704:\nset .L705,%o0\nset Z,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset .L706,%o0\nset Y,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\n.L700:\n.L698:\n.L690:\nset Indx,%l3\nld [%l3],%l2\nadd %l2,1,%l2\nst %l2,[%l3]\nset Indx,%l3\nld [%l3],%l3\ncmp %l3,3; ble .L689; nop\nset Milestone,%l3\nset 180,%l2\nst %l2,[%l3]\nset Indx,%l3\nset 1,%l2\nst %l2,[%l3]\n.L707:\nset Indx,%l3\nld [%l3],%l3\ncmp %l3,1; bne .L711; nop\nset Z,%l3\nset V,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nba .L712; nop\n.L711:\nset Z,%l3\nset V0,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L712:\nset Z,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall sqrt; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset V9,%l3\nst2 %f30,[%l3]\nset X,%l3\nset V9,%l2\nld2 [%l2],%f30\nset One,%l1\nld2 [%l1],%f28\nset Radix,%l1\nld2 [%l1],%f26\nset E9,%l1\nld2 [%l1],%f24\nfmuld %f26,%f24,%f26\nfsubd %f28,%f26,%f28\nfmuld %f28,%f30,%f28\nst2 %f28,[%l3]\nld2 [%l3],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l2]\nset V9,%l3\nld2 [%l3],%f30\nset Z,%l3\nld2 [%l3],%f28\nset One,%l3\nld2 [%l3],%f26\nset Two,%l3\nld2 [%l3],%f24\nset Radix,%l3\nld2 [%l3],%f22\nfmuld %f24,%f22,%f24\nset E9,%l3\nld2 [%l3],%f22\nfmuld %f24,%f22,%f24\nfsubd %f26,%f24,%f26\nfmuld %f26,%f28,%f26\nfcmped %f30,%f26; nop; fbul .L715; nop\nfcmped %f30,%f28; nop; fbule .L713; nop\n.L715:\nset Y,%l3\nset V9,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset X,%l3\nld2 [%l3],%f30\nset W,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbuge .L716; nop\nset 1,%o0\nset .L158,%o1\ncall BadCond; nop\nba .L717; nop\n.L716:\nset 2,%o0\nset .L158,%o1\ncall BadCond; nop\n.L717:\nset .L718,%o0\nset Z,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset .L719,%o0\nset Y,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\n.L713:\n.L708:\nset Indx,%l3\nld [%l3],%l2\nadd %l2,1,%l2\nst %l2,[%l3]\nset Indx,%l3\nld [%l3],%l3\ncmp %l3,2; ble .L707; nop\nset Milestone,%l3\nset 190,%l2\nst %l2,[%l3]\ncall Pause; nop\nset X,%l3\nset UfThold,%l2\nld2 [%l2],%f30\nset V,%l2\nld2 [%l2],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%l3]\nset Radix,%l3\nld2 [%l3],%f30\nset Y,%l3\nfmuld %f30,%f30,%f30\nst2 %f30,[%l3]\nset X,%l3\nld2 [%l3],%f30\nset Y,%l3\nld2 [%l3],%f28\nfmuld %f30,%f28,%f26\nset One,%l3\nld2 [%l3],%f24\nfcmped %f26,%f24; nop; fbul .L722; nop\nfcmped %f30,%f28; nop; fbule .L720; nop\n.L722:\nset X,%l3\nld2 [%l3],%f30\nset Y,%l3\nld2 [%l3],%f28\nset U1,%l3\nld2 [%l3],%f26\nfmuld %f30,%f28,%f24\nfcmped %f24,%f26; nop; fbul .L725; nop\nfdivd %f28,%f26,%f28\nfcmped %f30,%f28; nop; fbule .L723; nop\n.L725:\nset 2,%o0\nset .L726,%o1\ncall BadCond; nop\nba .L724; nop\n.L723:\nset 3,%o0\nset .L158,%o1\ncall BadCond; nop\n.L724:\nset .L727,%o0\nset X,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\nset .L728,%o3\ncall printf; nop\n.L720:\nset Milestone,%l3\nset 200,%l2\nst %l2,[%l3]\nset Indx,%l3\nset 1,%l2\nst %l2,[%l3]\n.L729:\nset X,%l3\nset F9,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset Indx,%l3\nld [%l3],%l3\ncmp %l3,2; bl .L733; nop\ncmp %l3,5; bg .L733; nop\nsll %l3,2,%l3\nset .L739-8,%l2\nld [%l3+%l2],%l3\njmp %l3; nop\n.section \".rodata\"\n.align 4\n.L739:\n.word .L735\n.word .L736\n.word .L737\n.word .L738\n.section \".text\"\n.L735:\nset X,%l3\nset One,%l2\nld2 [%l2],%f30\nset U2,%l2\nld2 [%l2],%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%l3]\nba .L734; nop\n.L736:\nset X,%l3\nset V,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nba .L734; nop\n.L737:\nset X,%l3\nset UfThold,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nba .L734; nop\n.L738:\nset X,%l3\nset Radix,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\n.L733:\n.L734:\nset Y,%l3\nset X,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset sigsave,%l3\nset sigfpe,%l2\nst %l2,[%l3]\nset ovfl_buf,%o0\ncall setjmp; nop\ncmp %o0,0; be .L741; nop\nset .L743,%o0\nset X,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nba .L742; nop\n.L741:\nset V9,%l3\nset Half,%l2\nld2 [%l2],%f30\nset Y,%l2\nld2 [%l2],%f28\nset X,%l2\nld2 [%l2],%f26\nfdivd %f28,%f26,%f28\nfsubd %f28,%f30,%f28\nfsubd %f28,%f30,%f30\nst2 %f30,[%l3]\nld2 [%l3],%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L744; nop\nba .L730; nop\n.L744:\nset V9,%l3\nld2 [%l3],%f30\nset U1,%l3\nld2 [%l3],%f28\nfnegs %f28,%f28; fmovs %f29,%f29\nfcmped %f30,%f28; nop; fbne .L746; nop\nset Indx,%l3\nld [%l3],%l3\ncmp %l3,5; bge .L746; nop\nset 3,%o0\nset .L158,%o1\ncall BadCond; nop\nba .L747; nop\n.L746:\nset 1,%o0\nset .L158,%o1\ncall BadCond; nop\n.L747:\nset .L748,%o0\nset X,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset .L749,%o0\nset V9,%l3\nld2 [%l3],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\n.L742:\nset sigsave,%l3\nst %g0,[%l3]\n.L730:\nset Indx,%l3\nld [%l3],%l2\nadd %l2,1,%l2\nst %l2,[%l3]\nset Indx,%l3\nld [%l3],%l3\ncmp %l3,5; ble .L729; nop\nset Milestone,%l3\nset 210,%l2\nst %l2,[%l3]\nset MyZero,%l3\nset Zero,%l2\nld2 [%l2],%f30\nst2 %f30,[%l3]\nset .L45,%o0\ncall printf; nop\nset .L750,%o0\ncall printf; nop\nset sigsave,%l3\nset sigfpe,%l2\nst %l2,[%l3]\nset .L751,%o0\ncall printf; nop\nset ovfl_buf,%o0\ncall setjmp; nop\ncmp %o0,0; bne .L752; nop\nset .L754,%o0\nset One,%l3\nld2 [%l3],%f30\nset MyZero,%l3\nld2 [%l3],%f28\nfdivd %f30,%f28,%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\n.L752:\nset sigsave,%l3\nst %g0,[%l3]\nset sigfpe,%l2\nst %l2,[%l3]\nset .L755,%o0\ncall printf; nop\nset ovfl_buf,%o0\ncall setjmp; nop\ncmp %o0,0; bne .L756; nop\nset .L754,%o0\nset Zero,%l3\nld2 [%l3],%f30\nset MyZero,%l3\nld2 [%l3],%f28\nfdivd %f30,%f28,%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\n.L756:\nset sigsave,%l3\nst %g0,[%l3]\nset Milestone,%l3\nset 220,%l2\nst %l2,[%l3]\ncall Pause; nop\nset .L45,%o0\ncall printf; nop\nst %g0,[%fp+-116]\n.L763:\nld [%fp+-116],%l3\nsll %l3,2,%l3\nset ErrCnt,%l2\nld [%l3+%l2],%l3\ncmp %l3,0; be .L767; nop\nset .L769,%o0\nld [%fp+-116],%l3\nsll %l3,2,%l3\nset .758,%l2\nld [%l3+%l2],%o1\nset ErrCnt,%l2\nld [%l3+%l2],%o2\ncall printf; nop\n.L767:\n.L764:\nld [%fp+-116],%l3\nadd %l3,1,%l3\nst %l3,[%fp+-116]\nld [%fp+-116],%l3\ncmp %l3,4; bl .L763; nop\nset .L45,%o0\ncall printf; nop\nset ErrCnt,%l3\nld [%l3],%l3\nset ErrCnt+4,%l2\nld [%l2],%l2\nadd %l3,%l2,%l3\nset ErrCnt+8,%l2\nld [%l2],%l2\nadd %l3,%l2,%l3\nset ErrCnt+12,%l2\nld [%l2],%l2\nadd %l3,%l2,%l3\ncmp %l3,0; ble .L770; nop\nset ErrCnt,%l2\nld [%l2],%l2\nset ErrCnt+4,%l1\nld [%l1],%l1\nadd %l2,%l1,%l2\nset ErrCnt+8,%l1\nld [%l1],%l1\nadd %l2,%l1,%l2\ncmp %l2,%g0; bne .L775; nop\nset ErrCnt+12,%l2\nld [%l2],%l2\ncmp %l2,%g0; ble .L775; nop\nset .L780,%o0\ncall printf; nop\nset .L781,%o0\ncall printf; nop\n.L775:\nset ErrCnt,%l2\nld [%l2],%l2\nset ErrCnt+4,%l1\nld [%l1],%l1\nadd %l2,%l1,%l2\ncmp %l2,%g0; bne .L782; nop\nset ErrCnt+8,%l2\nld [%l2],%l2\ncmp %l2,%g0; ble .L782; nop\nset .L786,%o0\ncall printf; nop\nset .L787,%o0\ncall printf; nop\n.L782:\nset ErrCnt,%l3\nld [%l3],%l3\nset ErrCnt+4,%l2\nld [%l2],%l2\nadd %l3,%l2,%l3\ncmp %l3,0; ble .L788; nop\nset .L791,%o0\ncall printf; nop\nset .L792,%o0\ncall printf; nop\n.L788:\nset ErrCnt,%l3\nld [%l3],%l3\ncmp %l3,0; ble .L771; nop\nset .L795,%o0\ncall printf; nop\nset .L796,%o0\ncall printf; nop\nba .L771; nop\n.L770:\nset .L797,%o0\ncall printf; nop\nset RMult,%l3\nld [%l3],%l3\ncmp %l3,1; bne .L802; nop\nset RDiv,%l3\nld [%l3],%l3\ncmp %l3,1; bne .L802; nop\nset RAddSub,%l3\nld [%l3],%l3\ncmp %l3,1; bne .L802; nop\nset RSqrt,%l3\nld [%l3],%l3\ncmp %l3,1; be .L798; nop\n.L802:\nset .L803,%o0\ncall printf; nop\nba .L799; nop\n.L798:\nset One,%l3\nld2 [%l3],%f30\nset StickyBit,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbul .L804; nop\nset Radix,%l3\nld2 [%l3],%f28\nset Two,%l3\nld2 [%l3],%f26\nfsubd %f28,%f26,%f26\nset Nine,%l3\nld2 [%l3],%f24\nfsubd %f28,%f24,%f28\nfsubd %f28,%f30,%f30\nfmuld %f26,%f30,%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L804; nop\nset .L806,%o0\ncall printf; nop\nset .L807,%o0\ncall printf; nop\nset Two,%l3\nld2 [%l3],%f30\nset Radix,%l3\nld2 [%l3],%f28\nfcmped %f28,%f30; nop; fbne .L808; nop\nset Precision,%l3\nld2 [%l3],%f28\nset TwentySeven,%l3\nld2 [%l3],%f26\nset Four,%l3\nld2 [%l3],%f24\nset Three,%l3\nld2 [%l3],%f22\nfmuld %f24,%f22,%f24\nfmuld %f24,%f30,%f30\nfsubd %f28,%f30,%f30\nfsubd %f28,%f26,%f28\nfsubd %f28,%f26,%f28\nset One,%l3\nld2 [%l3],%f26\nfaddd %f28,%f26,%f28\nfmuld %f30,%f28,%f30\nset Zero,%l3\nld2 [%l3],%f28\nfcmped %f30,%f28; nop; fbne .L808; nop\nset .L810,%o0\ncall printf; nop\nba .L809; nop\n.L808:\nset .L811,%o0\ncall printf; nop\n.L809:\nset IEEE,%l3\nld [%l3],%l3\ncmp %l3,0; be .L812; nop\nset .L814,%o0\ncall printf; nop\nba .L813; nop\n.L812:\nset .L815,%o0\ncall printf; nop\nset .L816,%o0\ncall printf; nop\n.L813:\n.L804:\nset .L817,%o0\ncall printf; nop\n.L799:\n.L771:\nset fpecount,%l3\nld [%l3],%l3\ncmp %l3,0; be .L818; nop\nset .L820,%o0\nset fpecount,%l3\nld [%l3],%o1\ncall printf; nop\n.L818:\nset .L821,%o0\ncall printf; nop\nmov %g0,%i0\n.L7:\nret; restore\n.type main,#function\n.size main,.-main\n.global Sign\n.align 4\nSign:\nsave %sp,-104,%sp\nst %r24,[%fp+68]\nst %r25,[%fp+72]\nld2 [%fp+68],%f30\nset .L8,%i5\nld2 [%i5],%f28\nfcmped %f30,%f28; nop; fbul .L824; nop\nset .L9,%i5\nld2 [%i5],%f30\nstd %f30,[%fp+-8]\nba .L825; nop\n.L824:\nset .L826,%i5\nld2 [%i5],%f30\nstd %f30,[%fp+-8]\n.L825:\nldd [%fp+-8],%f0\n.L822:\nret; restore\n.type Sign,#function\n.size Sign,.-Sign\n.global Pause\n.align 4\nPause:\nsave %sp,-96,%sp\nset .L828,%o0\nset Milestone,%i5\nld [%i5],%o1\ncall printf; nop\nset .L829,%o0\nset PageNo,%i5\nld [%i5],%o1\ncall printf; nop\nset Milestone,%i5\nld [%i5],%i4\nadd %i4,1,%i4\nst %i4,[%i5]\nset PageNo,%i5\nld [%i5],%i4\nadd %i4,1,%i4\nst %i4,[%i5]\nmov %g0,%i0\n.L827:\nret; restore\n.type Pause,#function\n.size Pause,.-Pause\n.global TstCond\n.align 4\nTstCond:\nsave %sp,-96,%sp\ncmp %i1,0; bne .L831; nop\nmov %i0,%o0\nmov %i2,%o1\ncall BadCond; nop\nset .L814,%o0\ncall printf; nop\n.L831:\nmov %g0,%i0\n.L830:\nret; restore\n.type TstCond,#function\n.size TstCond,.-TstCond\n.section \".data\"\n.type .834,#object\n.align 4\n.834:\n.word .L835\n.word .L836\n.word .L837\n.word .L838\n.size .834,16\n.global BadCond\n.section \".text\"\n.align 4\nBadCond:\nsave %sp,-96,%sp\nsll %i0,2,%i5\nset ErrCnt,%i4\nadd %i5,%i4,%i5\nld [%i5],%i4\nadd %i4,1,%i4\nst %i4,[%i5]\nset .L839,%o0\nsll %i0,2,%i5\nset .834,%i4\nld [%i5+%i4],%o1\nmov %i1,%o2\ncall printf; nop\nmov %g0,%i0\n.L833:\nret; restore\n.type BadCond,#function\n.size BadCond,.-BadCond\n.global Random\n.align 4\nRandom:\nsave %sp,-120,%sp\nset Random1,%i5\nld2 [%i5],%f30\nset Random9,%i5\nld2 [%i5],%f28\nfaddd %f30,%f28,%f30\nstd %f30,[%fp+-8]\nldd [%fp+-8],%f30\nfmuld %f30,%f30,%f28\nstd %f28,[%fp+-16]\nldd [%fp+-16],%f28\nfmuld %f28,%f28,%f28\nstd %f28,[%fp+-16]\nldd [%fp+-16],%f28\nfmuld %f30,%f28,%f30\nstd %f30,[%fp+-8]\nldd [%fp+-8],%f30\nstd %f30,[%fp+-24]\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nldd [%fp+-24],%f28\nfsubd %f28,%f30,%f30\nstd %f30,[%fp+-16]\nset Random1,%i5\nldd [%fp+-16],%f30\nset .L841,%i4\nld2 [%i4],%f28\nldd [%fp+-8],%f26\nfmuld %f28,%f26,%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%i5]\nld2 [%i5],%f0\n.L840:\nret; restore\n.type Random,#function\n.size Random,.-Random\n.global SqXMinX\n.align 4\nSqXMinX:\nsave %sp,-112,%sp\nset X,%i5\nld2 [%i5],%f30\nset BInvrse,%i5\nld2 [%i5],%f28\nfmuld %f30,%f28,%f28\nstd %f28,[%fp+-8]\nldd [%fp+-8],%f28\nfsubd %f30,%f28,%f28\nstd %f28,[%fp+-16]\nfmuld %f30,%f30,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall sqrt; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset SqEr,%i5\nldd [%fp+-8],%f28\nfsubd %f30,%f28,%f30\nldd [%fp+-16],%f28\nfsubd %f30,%f28,%f30\nset OneUlp,%i4\nld2 [%i4],%f28\nfdivd %f30,%f28,%f30\nst2 %f30,[%i5]\nset SqEr,%i5\nld2 [%i5],%f30\nset Zero,%i5\nld2 [%i5],%f28\nfcmped %f30,%f28; nop; fbue .L843; nop\nset SqEr,%i5\nld2 [%i5],%f30\nset MinSqEr,%i5\nld2 [%i5],%f28\nfcmped %f30,%f28; nop; fbuge .L845; nop\nset MinSqEr,%i5\nset SqEr,%i4\nld2 [%i4],%f30\nst2 %f30,[%i5]\n.L845:\nset SqEr,%i5\nld2 [%i5],%f30\nset MaxSqEr,%i5\nld2 [%i5],%f28\nfcmped %f30,%f28; nop; fbule .L847; nop\nset MaxSqEr,%i5\nset SqEr,%i4\nld2 [%i4],%f30\nst2 %f30,[%i5]\n.L847:\nset J,%i5\nld2 [%i5],%f30\nset .L9,%i4\nld2 [%i4],%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%i5]\nmov %i0,%o0\nset .L45,%o1\ncall BadCond; nop\nset .L849,%o0\nset X,%i5\nld2 [%i5],%f30\nfmuld %f30,%f30,%f28\nst %f28,[%sp+4*1+68]\nst %f29,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\nst %f30,[%sp+4*3+68]\nst %f31,[%sp+4*4+68]\nld [%sp+4*3+68],%o3\nld [%sp+4*4+68],%o4\nset OneUlp,%i5\nld2 [%i5],%f30\nset SqEr,%i5\nld2 [%i5],%f28\nfmuld %f30,%f28,%f30\nst %f30,[%sp+4*5+68]\nst %f31,[%sp+4*6+68]\nld [%sp+4*5+68],%o5\ncall printf; nop\nset .L850,%o0\ncall printf; nop\n.L843:\nmov %g0,%i0\n.L842:\nret; restore\n.type SqXMinX,#function\n.size SqXMinX,.-SqXMinX\n.global NewD\n.align 4\nNewD:\nsave %sp,-96,%sp\nset X,%i5\nset Z1,%i4\nld2 [%i4],%f30\nset Q,%i4\nld2 [%i4],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%i5]\nset Half,%i4\nld2 [%i4],%f30\nld2 [%i5],%f28\nset Radix,%i4\nld2 [%i4],%f26\nfdivd %f28,%f26,%f28\nfsubd %f30,%f28,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall floor; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Radix,%i4\nld2 [%i4],%f28\nset X,%i4\nfmuld %f30,%f28,%f30\nld2 [%i4],%f26\nfaddd %f30,%f26,%f30\nst2 %f30,[%i5]\nset Q,%i5\nld2 [%i4],%f30\nset Z,%i4\nld2 [%i4],%f26\nset D,%i3\nld2 [%i3],%f24\nld2 [%i5],%f22\nfmuld %f30,%f26,%f20\nfsubd %f22,%f20,%f22\nfdivd %f22,%f28,%f22\nfmuld %f30,%f30,%f20\nfdivd %f24,%f28,%f28\nfmuld %f20,%f28,%f28\nfaddd %f22,%f28,%f28\nst2 %f28,[%i5]\nset Two,%i5\nld2 [%i5],%f28\nfmuld %f28,%f30,%f30\nfmuld %f30,%f24,%f30\nfsubd %f26,%f30,%f30\nst2 %f30,[%i4]\nld2 [%i4],%f30\nset Zero,%i5\nld2 [%i5],%f28\nfcmped %f30,%f28; nop; fbug .L852; nop\nset Z,%i5\nld2 [%i5],%f30\nfnegs %f30,%f30; fmovs %f31,%f31\nst2 %f30,[%i5]\nset Z1,%i5\nld2 [%i5],%f30\nfnegs %f30,%f30; fmovs %f31,%f31\nst2 %f30,[%i5]\n.L852:\nset D,%i5\nset Radix,%i4\nld2 [%i4],%f30\nld2 [%i5],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%i5]\nmov %g0,%i0\n.L851:\nret; restore\n.type NewD,#function\n.size NewD,.-NewD\n.global SR3750\n.align 4\nSR3750:\nsave %sp,-96,%sp\nset X,%i5\nld2 [%i5],%f30\nset Radix,%i5\nld2 [%i5],%f28\nset Z2,%i5\nld2 [%i5],%f26\nfsubd %f30,%f28,%f24\nfsubd %f26,%f28,%f28\nfcmped %f24,%f28; nop; fbul .L855; nop\nfsubd %f30,%f26,%f30\nset W,%i5\nld2 [%i5],%f28\nfsubd %f28,%f26,%f28\nfcmped %f30,%f28; nop; fbug .L855; nop\nset I,%i5\nld [%i5],%i4\nadd %i4,1,%i4\nst %i4,[%i5]\nset X,%i5\nld2 [%i5],%f30\nset D,%i5\nld2 [%i5],%f28\nfmuld %f30,%f28,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall sqrt; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset X2,%i5\nst2 %f30,[%i5]\nset Y2,%i5\nset X2,%i4\nset Z2,%i3\nld2 [%i3],%f30\nset Y,%i3\nld2 [%i3],%f28\nld2 [%i4],%f26\nfsubd %f26,%f30,%f26\nfsubd %f28,%f30,%f30\nfsubd %f26,%f30,%f30\nst2 %f30,[%i5]\nset Half,%i3\nld2 [%i3],%f30\nset X8,%i3\nld2 [%i3],%f26\nfsubd %f28,%f30,%f28\nfdivd %f26,%f28,%f28\nst2 %f28,[%i4]\nld2 [%i4],%f28\nfmuld %f30,%f28,%f26\nfmuld %f26,%f28,%f26\nfsubd %f28,%f26,%f28\nst2 %f28,[%i4]\nset SqEr,%i3\nld2 [%i5],%f28\nfaddd %f28,%f30,%f28\nld2 [%i4],%f26\nfsubd %f30,%f26,%f30\nfaddd %f28,%f30,%f30\nst2 %f30,[%i3]\nld2 [%i3],%f30\nset MinSqEr,%i5\nld2 [%i5],%f28\nfcmped %f30,%f28; nop; fbuge .L857; nop\nset MinSqEr,%i5\nset SqEr,%i4\nld2 [%i4],%f30\nst2 %f30,[%i5]\n.L857:\nset SqEr,%i5\nset Y2,%i4\nld2 [%i4],%f30\nset X2,%i4\nld2 [%i4],%f28\nfsubd %f30,%f28,%f30\nst2 %f30,[%i5]\nld2 [%i5],%f30\nset MaxSqEr,%i5\nld2 [%i5],%f28\nfcmped %f30,%f28; nop; fbule .L859; nop\nset MaxSqEr,%i5\nset SqEr,%i4\nld2 [%i4],%f30\nst2 %f30,[%i5]\n.L859:\n.L855:\nmov %g0,%i0\n.L854:\nret; restore\n.type SR3750,#function\n.size SR3750,.-SR3750\n.global IsYeqX\n.align 4\nIsYeqX:\nsave %sp,-96,%sp\nset Y,%i5\nld2 [%i5],%f30\nset X,%i5\nld2 [%i5],%f28\nfcmped %f30,%f28; nop; fbue .L862; nop\nset N,%i5\nld [%i5],%i5\ncmp %i5,0; bg .L864; nop\nset Zero,%i5\nld2 [%i5],%f30\nset Z,%i5\nld2 [%i5],%f28\nfcmped %f28,%f30; nop; fbne .L866; nop\nset Q,%i5\nld2 [%i5],%f28\nfcmped %f28,%f30; nop; fbug .L866; nop\nset .L868,%o0\ncall printf; nop\nba .L867; nop\n.L866:\nset 2,%o0\nset .L869,%o1\ncall BadCond; nop\n.L867:\nset .L870,%o0\nset Z,%i5\nld2 [%i5],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\nset Q,%i5\nld2 [%i5],%f30\nst %f30,[%sp+4*3+68]\nst %f31,[%sp+4*4+68]\nld [%sp+4*3+68],%o3\nld [%sp+4*4+68],%o4\ncall printf; nop\nset .L871,%o0\nset Y,%i5\nld2 [%i5],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset .L872,%o0\nset X,%i5\nld2 [%i5],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset .L873,%o0\nset Y,%i5\nld2 [%i5],%f30\nset X,%i5\nld2 [%i5],%f28\nfsubd %f30,%f28,%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\n.L864:\nset N,%i5\nld [%i5],%i4\nadd %i4,1,%i4\nst %i4,[%i5]\n.L862:\nmov %g0,%i0\n.L861:\nret; restore\n.type IsYeqX,#function\n.size IsYeqX,.-IsYeqX\n.global SR3980\n.align 4\nSR3980:\nsave %sp,-96,%sp\n.L875:\nset Q,%i5\nset I,%i4\nld [%i4],%i4\nst %i4,[%sp+64]; ld [%sp+64],%f30; fitod %f30,%f30\nst2 %f30,[%i5]\nset Z,%i4\nld2 [%i4],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\nld2 [%i5],%f30\nst %f30,[%sp+4*2+68]\nst %f31,[%sp+4*3+68]\nld [%sp+4*2+68],%o2\nld [%sp+4*3+68],%o3\ncall pow; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Y,%i5\nst2 %f30,[%i5]\ncall IsYeqX; nop\nset I,%i5\nld [%i5],%i4\nadd %i4,1,%i4\nst %i4,[%i5]\nset M,%i5\nld [%i5],%i5\ncmp %i4,%i5; ble .L878; nop\nba .L877; nop\n.L878:\nset X,%i5\nset Z,%i4\nld2 [%i4],%f30\nld2 [%i5],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%i5]\n.L876:\nset X,%i5\nld2 [%i5],%f30\nset W,%i5\nld2 [%i5],%f28\nfcmped %f30,%f28; nop; fbul .L875; nop\n.L877:\nmov %g0,%i0\n.L874:\nret; restore\n.type SR3980,#function\n.size SR3980,.-SR3980\n.global PrintIfNPositive\n.align 4\nPrintIfNPositive:\nsave %sp,-96,%sp\nset N,%i5\nld [%i5],%i5\ncmp %i5,0; ble .L881; nop\nset .L883,%o0\nset N,%i5\nld [%i5],%o1\ncall printf; nop\n.L881:\nmov %g0,%i0\n.L880:\nret; restore\n.type PrintIfNPositive,#function\n.size PrintIfNPositive,.-PrintIfNPositive\n.global TstPtUf\n.align 4\nTstPtUf:\nsave %sp,-96,%sp\nset N,%i5\nst %g0,[%i5]\nset Z,%i5\nld2 [%i5],%f30\nset Zero,%i5\nld2 [%i5],%f28\nfcmped %f30,%f28; nop; fbue .L885; nop\nset .L887,%o0\ncall printf; nop\nset .L888,%o0\ncall printf; nop\nset sigsave,%i5\nset sigfpe,%i4\nst %i4,[%i5]\nset ovfl_buf,%o0\ncall setjmp; nop\ncmp %o0,0; be .L889; nop\nba .L891; nop\n.L889:\nset Q9,%i5\nset Z,%i4\nld2 [%i4],%f30\nfaddd %f30,%f30,%f28\nfdivd %f28,%f30,%f30\nst2 %f30,[%i5]\nset .L892,%o0\nld2 [%i5],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset Q9,%i5\nld2 [%i5],%f30\nset Two,%i5\nld2 [%i5],%f28\nfsubd %f30,%f28,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall fabs; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nset Radix,%i5\nld2 [%i5],%f28\nset U2,%i5\nld2 [%i5],%f26\nfmuld %f28,%f26,%f28\nfcmped %f30,%f28; nop; fbuge .L893; nop\nset .L895,%o0\ncall printf; nop\nset .L896,%o0\ncall printf; nop\nba .L894; nop\n.L893:\nset Q9,%i5\nld2 [%i5],%f30\nset One,%i5\nld2 [%i5],%f28\nfcmped %f30,%f28; nop; fbul .L899; nop\nset Two,%i5\nld2 [%i5],%f28\nfcmped %f30,%f28; nop; fbule .L897; nop\n.L899:\n.L891:\nset 1,%i5\nset N,%i4\nst %i5,[%i4]\nset ErrCnt+4,%i5\nset ErrCnt+4,%i4\nld [%i4],%i4\nadd %i4,1,%i4\nst %i4,[%i5]\nset .L902,%o0\ncall printf; nop\nba .L898; nop\n.L897:\nset 1,%i5\nset N,%i4\nst %i5,[%i4]\nset ErrCnt+8,%i5\nset ErrCnt+8,%i4\nld [%i4],%i4\nadd %i4,1,%i4\nst %i4,[%i5]\nset .L905,%o0\ncall printf; nop\n.L898:\n.L894:\nset sigsave,%i5\nst %g0,[%i5]\nset V9,%i5\nset Z,%i4\nld2 [%i4],%f30\nset One,%i4\nld2 [%i4],%f28\nfmuld %f30,%f28,%f26\nst2 %f26,[%i5]\nset Random1,%i4\nld2 [%i5],%f26\nst2 %f26,[%i4]\nfmuld %f28,%f30,%f26\nst2 %f26,[%i5]\nset Random2,%i4\nld2 [%i5],%f26\nst2 %f26,[%i4]\nfdivd %f30,%f28,%f30\nst2 %f30,[%i5]\nset Z,%i5\nld2 [%i5],%f30\nset Random1,%i5\nld2 [%i5],%f28\nfcmped %f30,%f28; nop; fbne .L906; nop\nset Random2,%i5\nld2 [%i5],%f28\nfcmped %f30,%f28; nop; fbne .L906; nop\nset V9,%i5\nld2 [%i5],%f28\nfcmped %f30,%f28; nop; fbne .L906; nop\nset N,%i5\nld [%i5],%i5\ncmp %i5,0; ble .L907; nop\ncall Pause; nop\nba .L907; nop\n.L906:\nset N,%i5\nset 1,%i4\nst %i4,[%i5]\nset 2,%o0\nset .L910,%o1\ncall BadCond; nop\nset .L911,%o0\nset Z,%i5\nld2 [%i5],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset Z,%i5\nld2 [%i5],%f30\nset Random1,%i5\nld2 [%i5],%f28\nfcmped %f30,%f28; nop; fbue .L912; nop\nset .L914,%o0\nset Random1,%i5\nld2 [%i5],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\n.L912:\nset Random2,%i5\nld2 [%i5],%f30\nset Z,%i5\nld2 [%i5],%f28\nfcmped %f28,%f30; nop; fbue .L915; nop\nset Random1,%i5\nld2 [%i5],%f28\nfcmped %f30,%f28; nop; fbue .L915; nop\nset .L917,%o0\nset Random2,%i5\nld2 [%i5],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\n.L915:\nset Z,%i5\nld2 [%i5],%f30\nset V9,%i5\nld2 [%i5],%f28\nfcmped %f30,%f28; nop; fbue .L918; nop\nset .L920,%o0\nset V9,%i5\nld2 [%i5],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\n.L918:\nset Random2,%i5\nld2 [%i5],%f30\nset Random1,%i5\nld2 [%i5],%f28\nfcmped %f30,%f28; nop; fbue .L921; nop\nset ErrCnt+8,%i5\nset ErrCnt+8,%i4\nld [%i4],%i4\nadd %i4,1,%i4\nst %i4,[%i5]\nset 2,%o0\nset .L925,%o1\ncall BadCond; nop\nset .L926,%o0\nset Random2,%i5\nld2 [%i5],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nset .L927,%o0\nset Random1,%i5\nld2 [%i5],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\n.L921:\ncall Pause; nop\n.L907:\n.L885:\nmov %g0,%i0\n.L884:\nret; restore\n.type TstPtUf,#function\n.size TstPtUf,.-TstPtUf\n.global notify\n.align 4\nnotify:\nsave %sp,-96,%sp\nset .L929,%o0\nmov %i0,%o1\ncall printf; nop\nset .L930,%o0\ncall printf; nop\nmov %g0,%i0\n.L928:\nret; restore\n.type notify,#function\n.size notify,.-notify\n.global msglist\n.align 4\nmsglist:\nsave %sp,-96,%sp\nba .L933; nop\n.L932:\nset .L935,%o0\nmov %i0,%i5\nadd %i5,4,%i0\nld [%i5],%o1\ncall printf; nop\n.L933:\nld [%i0],%i5\ncmp %i5,%g0; bne .L932; nop\nmov %g0,%i0\n.L931:\nret; restore\n.type msglist,#function\n.size msglist,.-msglist\n.section \".data\"\n.type .937,#object\n.align 4\n.937:\n.word .L938\n.word .L939\n.word .L940\n.word .L941\n.word .L942\n.word .L943\n.word .L944\n.word .L945\n.word .L946\n.word 0x0\n.size .937,40\n.global Instructions\n.section \".text\"\n.align 4\nInstructions:\nsave %sp,-96,%sp\nset .937,%o0\ncall msglist; nop\nmov %g0,%i0\n.L936:\nret; restore\n.type Instructions,#function\n.size Instructions,.-Instructions\n.section \".data\"\n.type .948,#object\n.align 4\n.948:\n.word .L949\n.word .L950\n.word .L951\n.word .L952\n.word .L953\n.word .L954\n.word .L955\n.word .L956\n.word .L957\n.word .L958\n.word .L959\n.word .L960\n.word .L961\n.word .L962\n.word 0x0\n.size .948,60\n.global Heading\n.section \".text\"\n.align 4\nHeading:\nsave %sp,-96,%sp\nset .948,%o0\ncall msglist; nop\nmov %g0,%i0\n.L947:\nret; restore\n.type Heading,#function\n.size Heading,.-Heading\n.section \".data\"\n.type .964,#object\n.align 4\n.964:\n.word .L965\n.word .L966\n.word .L967\n.word .L968\n.word .L969\n.word .L970\n.word .L971\n.word .L972\n.word .L973\n.word .L974\n.word .L975\n.word .L976\n.word .L977\n.word .L978\n.word .L979\n.word .L980\n.word .L981\n.word .L982\n.word .L983\n.word 0x0\n.size .964,80\n.global Characteristics\n.section \".text\"\n.align 4\nCharacteristics:\nsave %sp,-96,%sp\nset .964,%o0\ncall msglist; nop\nmov %g0,%i0\n.L963:\nret; restore\n.type Characteristics,#function\n.size Characteristics,.-Characteristics\n.section \".data\"\n.type .985,#object\n.align 4\n.985:\n.word .L986\n.word .L987\n.word .L988\n.word .L989\n.word .L990\n.word .L991\n.word .L992\n.word .L993\n.word .L994\n.word .L995\n.word .L996\n.word .L997\n.word .L998\n.word .L999\n.word .L1000\n.word .L1001\n.word .L1002\n.word 0x0\n.size .985,72\n.global History\n.section \".text\"\n.align 4\nHistory:\nsave %sp,-96,%sp\nset .985,%o0\ncall msglist; nop\nmov %g0,%i0\n.L984:\nret; restore\n.type History,#function\n.size History,.-History\n.global pow\n.align 4\npow:\nsave %sp,-120,%sp\nst %r24,[%fp+68]\nst %r25,[%fp+72]\nst %r26,[%fp+76]\nst %r27,[%fp+80]\nmov %g0,%i4\nmov %g0,%i3\nld2 [%fp+76],%f30\nset .L8,%i2\nld2 [%i2],%f28\nfcmped %f30,%f28; nop; fbne .L1004; nop\nset .L9,%i2\nld2 [%i2],%f0\nba .L1003; nop\n.L1004:\nld2 [%fp+76],%f30\nset .L1009,%i2\nld2 [%i2],%f28\nfcmped %f30,%f28; nop; fbul .L1008; nop\nset .L1010,%i2\nld2 [%i2],%f28\nfcmped %f30,%f28; nop; fbule .L1006; nop\n.L1008:\nld2 [%fp+68],%f30\nset .L826,%i2\nld2 [%i2],%f28\nfcmped %f30,%f28; nop; fbue .L1006; nop\nld2 [%fp+68],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall log; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nld2 [%fp+76],%f28\nfmuld %f28,%f30,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall exp; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nfmovs %f30,%f0; fmovs %f31,%f1\nba .L1003; nop\n.L1006:\nld2 [%fp+76],%f30\nset .L8,%i2\nld2 [%i2],%f28\nfcmped %f30,%f28; nop; fbuge .L1011; nop\nld2 [%fp+76],%f30\nfnegs %f30,%f30; fmovs %f31,%f31\nst2 %f30,[%fp+76]\nset 1,%i3\n.L1011:\nld2 [%fp+76],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\nadd -24,%fp,%o2\ncall modf; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nst2 %f30,[%fp+76]\nld2 [%fp+76],%f30\nset .L8,%i2\nld2 [%i2],%f28\nfcmped %f30,%f28; nop; fbue .L1013; nop\nld2 [%fp+68],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall log; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nld2 [%fp+76],%f28\nfmuld %f28,%f30,%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\ncall exp; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nstd %f30,[%fp+-16]\nba .L1014; nop\n.L1013:\nset .L9,%i2\nld2 [%i2],%f30\nstd %f30,[%fp+-16]\n.L1014:\nld2 [%fp+68],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\nadd -4,%fp,%o2\ncall frexp; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nst2 %f30,[%fp+68]\nldd [%fp+-24],%f30\nfdtoi %f30,%f0; st %f0,[%sp+64]; ld [%sp+64],%i2\nmov %i2,%i5\ncmp %i2,0; be .L1015; nop\n.L1017:\nand %i5,1,%i2\ncmp %i2,0; be .L1021; nop\nldd [%fp+-16],%f30\nld2 [%fp+68],%f28\nfmuld %f30,%f28,%f30\nstd %f30,[%fp+-16]\nld [%fp+-4],%i2\nadd %i4,%i2,%i4\n.L1021:\nsra %i5,1,%i2\nmov %i2,%i5\ncmp %i2,0; bne .L1023; nop\nba .L1019; nop\n.L1023:\nld2 [%fp+68],%f30\nfmuld %f30,%f30,%f30\nst2 %f30,[%fp+68]\nld [%fp+-4],%i2\nsll %i2,1,%i2\nst %i2,[%fp+-4]\nld2 [%fp+68],%f30\nset .L1027,%i2\nld2 [%i2],%f28\nfcmped %f30,%f28; nop; fbuge .L1017; nop\nset .L1028,%i2\nld2 [%i2],%f30\nld2 [%fp+68],%f28\nfmuld %f30,%f28,%f30\nst2 %f30,[%fp+68]\nld [%fp+-4],%i2\nsub %i2,1,%i2\nst %i2,[%fp+-4]\nba .L1017; nop\n.L1019:\n.L1015:\ncmp %i3,0; be .L1029; nop\nset .L9,%i2\nld2 [%i2],%f30\nldd [%fp+-16],%f28\nfdivd %f30,%f28,%f30\nstd %f30,[%fp+-16]\nneg %i4,%i4\n.L1029:\nldd [%fp+-16],%f30\nst %f30,[%sp+4*0+68]\nst %f31,[%sp+4*1+68]\nld [%sp+4*0+68],%o0\nld [%sp+4*1+68],%o1\nmov %i4,%o2\ncall ldexp; nop\nfmovs %f0,%f30; fmovs %f1,%f31\nfmovs %f30,%f0; fmovs %f31,%f1\n.L1003:\nret; restore\n.type pow,#function\n.size pow,.-pow\n.section \".bss\"\n.global UfNGrad\n.type UfNGrad,#object\n.size UfNGrad,4\n.common UfNGrad,4,4\n.global SqRWrng\n.type SqRWrng,#object\n.size SqRWrng,4\n.common SqRWrng,4,4\n.global IEEE\n.type IEEE,#object\n.size IEEE,4\n.common IEEE,4,4\n.global Anomaly\n.type Anomaly,#object\n.size Anomaly,4\n.common Anomaly,4,4\n.global Monot\n.type Monot,#object\n.size Monot,4\n.common Monot,4,4\n.global NotMonot\n.type NotMonot,#object\n.size NotMonot,4\n.common NotMonot,4,4\n.global Done\n.type Done,#object\n.size Done,4\n.common Done,4,4\n.global Break\n.type Break,#object\n.size Break,4\n.common Break,4,4\n.global RSqrt\n.type RSqrt,#object\n.size RSqrt,4\n.common RSqrt,4,4\n.global RAddSub\n.type RAddSub,#object\n.size RAddSub,4\n.common RAddSub,4,4\n.global RDiv\n.type RDiv,#object\n.size RDiv,4\n.common RDiv,4,4\n.global RMult\n.type RMult,#object\n.size RMult,4\n.common RMult,4,4\n.global GAddSub\n.type GAddSub,#object\n.size GAddSub,4\n.common GAddSub,4,4\n.global GDiv\n.type GDiv,#object\n.size GDiv,4\n.common GDiv,4,4\n.global GMult\n.type GMult,#object\n.size GMult,4\n.common GMult,4,4\n.global N1\n.type N1,#object\n.size N1,4\n.common N1,4,4\n.global N\n.type N,#object\n.size N,4\n.common N,4,4\n.global M\n.type M,#object\n.size M,4\n.common M,4,4\n.global PageNo\n.type PageNo,#object\n.size PageNo,4\n.common PageNo,4,4\n.global Milestone\n.type Milestone,#object\n.size Milestone,4\n.common Milestone,4,4\n.global fpecount\n.type fpecount,#object\n.size fpecount,4\n.common fpecount,4,4\n.global ErrCnt\n.type ErrCnt,#object\n.size ErrCnt,16\n.common ErrCnt,16,4\n.global Z9\n.type Z9,#object\n.size Z9,8\n.common Z9,8,8\n.global Z2\n.type Z2,#object\n.size Z2,8\n.common Z2,8,8\n.global Z1\n.type Z1,#object\n.size Z1,8\n.common Z1,8,8\n.global PseudoZero\n.type PseudoZero,#object\n.size PseudoZero,8\n.common PseudoZero,8,8\n.global Z\n.type Z,#object\n.size Z,8\n.common Z,8,8\n.global Random2\n.type Random2,#object\n.size Random2,8\n.common Random2,8,8\n.global Y2\n.type Y2,#object\n.size Y2,8\n.common Y2,8,8\n.global Y1\n.type Y1,#object\n.size Y1,8\n.common Y1,8,8\n.global Y\n.type Y,#object\n.size Y,8\n.common Y,8,8\n.global Random1\n.type Random1,#object\n.size Random1,8\n.common Random1,8,8\n.global X8\n.type X8,#object\n.size X8,8\n.common X8,8,8\n.global X2\n.type X2,#object\n.size X2,8\n.common X2,8,8\n.global X1\n.type X1,#object\n.size X1,8\n.common X1,8,8\n.global X\n.type X,#object\n.size X,8\n.common X,8,8\n.global W\n.type W,#object\n.size W,8\n.common W,8,8\n.global V9\n.type V9,#object\n.size V9,8\n.common V9,8,8\n.global V0\n.type V0,#object\n.size V0,8\n.common V0,8,8\n.global V\n.type V,#object\n.size V,8\n.common V,8,8\n.global U2\n.type U2,#object\n.size U2,8\n.common U2,8,8\n.global U1\n.type U1,#object\n.size U1,8\n.common U1,8,8\n.global UfThold\n.type UfThold,#object\n.size UfThold,8\n.common UfThold,8,8\n.global OneUlp\n.type OneUlp,#object\n.size OneUlp,8\n.common OneUlp,8,8\n.global S\n.type S,#object\n.size S,8\n.common S,8,8\n.global Underflow\n.type Underflow,#object\n.size Underflow,8\n.common Underflow,8,8\n.global T\n.type T,#object\n.size T,8\n.common T,8,8\n.global Random9\n.type Random9,#object\n.size Random9,8\n.common Random9,8,8\n.global R\n.type R,#object\n.size R,8\n.common R,8,8\n.global Q9\n.type Q9,#object\n.size Q9,8\n.common Q9,8,8\n.global Q\n.type Q,#object\n.size Q,8\n.common Q,8,8\n.global Precision\n.type Precision,#object\n.size Precision,8\n.common Precision,8,8\n.global MyZero\n.type MyZero,#object\n.size MyZero,8\n.common MyZero,8,8\n.global J\n.type J,#object\n.size J,8\n.common J,8,8\n.global StickyBit\n.type StickyBit,#object\n.size StickyBit,8\n.common StickyBit,8,8\n.global I\n.type I,#object\n.size I,4\n.common I,4,4\n.global HInvrse\n.type HInvrse,#object\n.size HInvrse,8\n.common HInvrse,8,8\n.global H\n.type H,#object\n.size H,8\n.common H,8,8\n.global F9\n.type F9,#object\n.size F9,8\n.common F9,8,8\n.global F6\n.type F6,#object\n.size F6,8\n.common F6,8,8\n.global Third\n.type Third,#object\n.size Third,8\n.common Third,8,8\n.global E9\n.type E9,#object\n.size E9,8\n.common E9,8,8\n.global MaxSqEr\n.type MaxSqEr,#object\n.size MaxSqEr,8\n.common MaxSqEr,8,8\n.global SqEr\n.type SqEr,#object\n.size SqEr,8\n.common SqEr,8,8\n.global MinSqEr\n.type MinSqEr,#object\n.size MinSqEr,8\n.common MinSqEr,8,8\n.global E3\n.type E3,#object\n.size E3,8\n.common E3,8,8\n.global Exp2\n.type Exp2,#object\n.size Exp2,8\n.common Exp2,8,8\n.global E1\n.type E1,#object\n.size E1,8\n.common E1,8,8\n.global E0\n.type E0,#object\n.size E0,8\n.common E0,8,8\n.global FourD\n.type FourD,#object\n.size FourD,8\n.common FourD,8,8\n.global D\n.type D,#object\n.size D,8\n.common D,8,8\n.global CInvrse\n.type CInvrse,#object\n.size CInvrse,8\n.common CInvrse,8,8\n.global C\n.type C,#object\n.size C,8\n.common C,8,8\n.global A1\n.type A1,#object\n.size A1,8\n.common A1,8,8\n.global AInvrse\n.type AInvrse,#object\n.size AInvrse,8\n.common AInvrse,8,8\n.global ch\n.type ch,#object\n.size ch,8\n.common ch,8,1\n.global Indx\n.type Indx,#object\n.size Indx,4\n.common Indx,4,4\n.global BMinusU2\n.type BMinusU2,#object\n.size BMinusU2,8\n.common BMinusU2,8,8\n.global RadixD2\n.type RadixD2,#object\n.size RadixD2,8\n.common RadixD2,8,8\n.global BInvrse\n.type BInvrse,#object\n.size BInvrse,8\n.common BInvrse,8,8\n.global Radix\n.type Radix,#object\n.size Radix,8\n.common Radix,8,8\n.global sigsave\n.type sigsave,#object\n.size sigsave,4\n.common sigsave,4,4\n.global ovfl_buf\n.type ovfl_buf,#object\n.size ovfl_buf,48\n.common ovfl_buf,48,4\n.section \".rodata\"\n.align 8\n.L1028:\n.word 0x40000000\n.word 0x0\n.align 8\n.L1027:\n.word 0x3fe00000\n.word 0x0\n.align 8\n.L1010:\n.word 0x40913000\n.word 0x0\n.align 8\n.L1009:\n.word 0xc0913000\n.word 0x0\n.align 1\n.L1002:\n.byte 115\n.byte 101\n.byte 101\n.byte 32\n.byte 115\n.byte 111\n.byte 117\n.byte 114\n.byte 99\n.byte 101\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 109\n.byte 111\n.byte 114\n.byte 101\n.byte 32\n.byte 104\n.byte 105\n.byte 115\n.byte 116\n.byte 111\n.byte 114\n.byte 121\n.byte 46\n.byte 0\n.align 1\n.L1001:\n.byte 66\n.byte 65\n.byte 83\n.byte 73\n.byte 67\n.byte 32\n.byte 118\n.byte 101\n.byte 114\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 40\n.byte 67\n.byte 41\n.byte 32\n.byte 49\n.byte 57\n.byte 56\n.byte 51\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 80\n.byte 114\n.byte 111\n.byte 102\n.byte 46\n.byte 32\n.byte 87\n.byte 46\n.byte 32\n.byte 77\n.byte 46\n.byte 32\n.byte 75\n.byte 97\n.byte 104\n.byte 97\n.byte 110\n.byte 59\n.byte 0\n.align 1\n.L1000:\n.byte 97\n.byte 115\n.byte 32\n.byte 117\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 99\n.byte 101\n.byte 114\n.byte 116\n.byte 97\n.byte 105\n.byte 110\n.byte 32\n.byte 101\n.byte 97\n.byte 114\n.byte 108\n.byte 121\n.byte 32\n.byte 87\n.byte 65\n.byte 78\n.byte 71\n.byte 32\n.byte 109\n.byte 97\n.byte 99\n.byte 104\n.byte 105\n.byte 110\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L999:\n.byte 102\n.byte 108\n.byte 111\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 45\n.byte 112\n.byte 111\n.byte 105\n.byte 110\n.byte 116\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 115\n.byte 44\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 32\n.byte 97\n.byte 108\n.byte 115\n.byte 111\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 111\n.byte 119\n.byte 115\n.byte 32\n.byte 108\n.byte 111\n.byte 103\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 105\n.byte 99\n.byte 32\n.byte 101\n.byte 110\n.byte 99\n.byte 111\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 0\n.align 1\n.L998:\n.byte 10\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 98\n.byte 97\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 117\n.byte 112\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 118\n.byte 101\n.byte 110\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 114\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 114\n.byte 101\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 101\n.byte 110\n.byte 116\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 0\n.align 1\n.L997:\n.byte 111\n.byte 102\n.byte 32\n.byte 112\n.byte 97\n.byte 116\n.byte 104\n.byte 111\n.byte 108\n.byte 111\n.byte 103\n.byte 105\n.byte 101\n.byte 115\n.byte 44\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 115\n.byte 97\n.byte 121\n.byte 32\n.byte 104\n.byte 111\n.byte 119\n.byte 32\n.byte 119\n.byte 101\n.byte 108\n.byte 108\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 109\n.byte 112\n.byte 108\n.byte 101\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 0\n.align 1\n.L996:\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 44\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 116\n.byte 114\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 112\n.byte 101\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 97\n.byte 32\n.byte 119\n.byte 105\n.byte 100\n.byte 101\n.byte 114\n.byte 32\n.byte 118\n.byte 97\n.byte 114\n.byte 105\n.byte 101\n.byte 116\n.byte 121\n.byte 0\n.align 1\n.L995:\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 44\n.byte 32\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 114\n.byte 97\n.byte 110\n.byte 103\n.byte 101\n.byte 32\n.byte 40\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 47\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 115\n.byte 41\n.byte 0\n.align 1\n.L994:\n.byte 87\n.byte 46\n.byte 32\n.byte 74\n.byte 46\n.byte 32\n.byte 67\n.byte 111\n.byte 100\n.byte 121\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 87\n.byte 46\n.byte 32\n.byte 87\n.byte 97\n.byte 105\n.byte 116\n.byte 101\n.byte 46\n.byte 32\n.byte 65\n.byte 108\n.byte 116\n.byte 104\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 32\n.byte 98\n.byte 111\n.byte 116\n.byte 104\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 115\n.byte 32\n.byte 116\n.byte 114\n.byte 121\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 0\n.align 1\n.L993:\n.byte 98\n.byte 111\n.byte 111\n.byte 107\n.byte 32\n.byte 32\n.byte 96\n.byte 83\n.byte 111\n.byte 102\n.byte 116\n.byte 119\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 77\n.byte 97\n.byte 110\n.byte 117\n.byte 97\n.byte 108\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 69\n.byte 108\n.byte 101\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 97\n.byte 114\n.byte 121\n.byte 32\n.byte 70\n.byte 117\n.byte 110\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 39\n.byte 32\n.byte 40\n.byte 49\n.byte 57\n.byte 56\n.byte 48\n.byte 41\n.byte 32\n.byte 98\n.byte 121\n.byte 0\n.align 1\n.L992:\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 99\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 100\n.byte 32\n.byte 96\n.byte 77\n.byte 65\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 39\n.byte 44\n.byte 32\n.byte 119\n.byte 104\n.byte 105\n.byte 99\n.byte 104\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 101\n.byte 110\n.byte 100\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 0\n.align 1\n.L991:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 99\n.byte 97\n.byte 112\n.byte 97\n.byte 98\n.byte 105\n.byte 108\n.byte 105\n.byte 116\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 103\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 121\n.byte 111\n.byte 110\n.byte 100\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 101\n.byte 97\n.byte 114\n.byte 108\n.byte 105\n.byte 101\n.byte 114\n.byte 0\n.align 1\n.L990:\n.byte 70\n.byte 97\n.byte 105\n.byte 108\n.byte 117\n.byte 114\n.byte 101\n.byte 115\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 115\n.byte 101\n.byte 113\n.byte 117\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L989:\n.byte 32\n.byte 32\n.byte 32\n.byte 70\n.byte 65\n.byte 73\n.byte 76\n.byte 85\n.byte 82\n.byte 69\n.byte 115\n.byte 44\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 32\n.byte 50\n.byte 43\n.byte 50\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 53\n.byte 32\n.byte 46\n.byte 0\n.align 1\n.L988:\n.byte 32\n.byte 32\n.byte 32\n.byte 83\n.byte 101\n.byte 114\n.byte 105\n.byte 111\n.byte 117\n.byte 115\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 115\n.byte 44\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 97\n.byte 32\n.byte 103\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 44\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 0\n.align 1\n.L987:\n.byte 32\n.byte 32\n.byte 32\n.byte 70\n.byte 76\n.byte 65\n.byte 87\n.byte 115\n.byte 44\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 97\n.byte 32\n.byte 115\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 121\n.byte 32\n.byte 98\n.byte 105\n.byte 116\n.byte 44\n.byte 0\n.align 1\n.L986:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 97\n.byte 116\n.byte 116\n.byte 101\n.byte 109\n.byte 112\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 114\n.byte 105\n.byte 109\n.byte 105\n.byte 110\n.byte 97\n.byte 116\n.byte 101\n.byte 32\n.byte 97\n.byte 109\n.byte 111\n.byte 110\n.byte 103\n.byte 0\n.align 1\n.L983:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 68\n.byte 101\n.byte 99\n.byte 105\n.byte 109\n.byte 97\n.byte 108\n.byte 45\n.byte 66\n.byte 105\n.byte 110\n.byte 97\n.byte 114\n.byte 121\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 118\n.byte 101\n.byte 114\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 32\n.byte 89\n.byte 69\n.byte 84\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 97\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 97\n.byte 99\n.byte 121\n.byte 46\n.byte 0\n.align 1\n.L982:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 69\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 45\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 101\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 101\n.byte 120\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 101\n.byte 118\n.byte 101\n.byte 97\n.byte 108\n.byte 101\n.byte 100\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 32\n.byte 89\n.byte 69\n.byte 84\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 0\n.align 1\n.L981:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 83\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 32\n.byte 32\n.byte 89\n.byte 94\n.byte 88\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 0\n.align 1\n.L980:\n.byte 9\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 116\n.byte 97\n.byte 109\n.byte 105\n.byte 110\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 112\n.byte 115\n.byte 101\n.byte 117\n.byte 100\n.byte 111\n.byte 45\n.byte 122\n.byte 101\n.byte 114\n.byte 111\n.byte 115\n.byte 46\n.byte 0\n.align 1\n.L979:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 99\n.byte 104\n.byte 101\n.byte 99\n.byte 107\n.byte 101\n.byte 100\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 115\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 110\n.byte 99\n.byte 121\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 1\n.L978:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 86\n.byte 48\n.byte 32\n.byte 32\n.byte 116\n.byte 101\n.byte 108\n.byte 108\n.byte 115\n.byte 44\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 108\n.byte 121\n.byte 44\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 32\n.byte 73\n.byte 110\n.byte 102\n.byte 105\n.byte 110\n.byte 105\n.byte 116\n.byte 121\n.byte 32\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 114\n.byte 101\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 101\n.byte 110\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 0\n.align 1\n.L977:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 86\n.byte 32\n.byte 61\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 44\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 108\n.byte 121\n.byte 46\n.byte 0\n.align 1\n.L976:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 69\n.byte 48\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 80\n.byte 115\n.byte 101\n.byte 117\n.byte 100\n.byte 111\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 116\n.byte 101\n.byte 108\n.byte 108\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 98\n.byte 114\n.byte 117\n.byte 112\n.byte 116\n.byte 44\n.byte 32\n.byte 103\n.byte 114\n.byte 97\n.byte 100\n.byte 117\n.byte 97\n.byte 108\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 102\n.byte 117\n.byte 122\n.byte 122\n.byte 121\n.byte 46\n.byte 0\n.align 1\n.L975:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 84\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 61\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 46\n.byte 0\n.align 1\n.L974:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 87\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 97\n.byte 32\n.byte 83\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 121\n.byte 32\n.byte 66\n.byte 105\n.byte 116\n.byte 32\n.byte 117\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 46\n.byte 0\n.align 1\n.L973:\n.byte 9\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 46\n.byte 44\n.byte 32\n.byte 68\n.byte 105\n.byte 118\n.byte 46\n.byte 44\n.byte 32\n.byte 65\n.byte 100\n.byte 100\n.byte 47\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 46\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 83\n.byte 113\n.byte 114\n.byte 116\n.byte 46\n.byte 0\n.align 1\n.L972:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 87\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 44\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 115\n.byte 111\n.byte 109\n.byte 101\n.byte 116\n.byte 104\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 0\n.align 1\n.L971:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 65\n.byte 100\n.byte 101\n.byte 113\n.byte 117\n.byte 97\n.byte 99\n.byte 121\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 103\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 46\n.byte 44\n.byte 32\n.byte 68\n.byte 105\n.byte 118\n.byte 46\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 46\n.byte 0\n.align 1\n.L970:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 85\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 49\n.byte 47\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 94\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 61\n.byte 32\n.byte 79\n.byte 110\n.byte 101\n.byte 32\n.byte 85\n.byte 108\n.byte 112\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 108\n.byte 105\n.byte 116\n.byte 116\n.byte 108\n.byte 101\n.byte 32\n.byte 108\n.byte 101\n.byte 115\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 110\n.byte 32\n.byte 49\n.byte 46\n.byte 48\n.byte 32\n.byte 46\n.byte 0\n.align 1\n.L969:\n.byte 9\n.byte 40\n.byte 79\n.byte 110\n.byte 101\n.byte 85\n.byte 108\n.byte 112\n.byte 110\n.byte 105\n.byte 116\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 76\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 80\n.byte 108\n.byte 97\n.byte 99\n.byte 101\n.byte 41\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 49\n.byte 46\n.byte 48\n.byte 48\n.byte 48\n.byte 120\n.byte 120\n.byte 120\n.byte 32\n.byte 46\n.byte 0\n.align 1\n.L968:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 85\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 47\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 94\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 61\n.byte 32\n.byte 79\n.byte 110\n.byte 101\n.byte 32\n.byte 85\n.byte 108\n.byte 112\n.byte 0\n.align 1\n.L967:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 61\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 105\n.byte 102\n.byte 105\n.byte 99\n.byte 97\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 99\n.byte 97\n.byte 114\n.byte 114\n.byte 105\n.byte 101\n.byte 100\n.byte 46\n.byte 0\n.align 1\n.L966:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 49\n.byte 44\n.byte 32\n.byte 50\n.byte 44\n.byte 32\n.byte 52\n.byte 44\n.byte 32\n.byte 56\n.byte 44\n.byte 32\n.byte 49\n.byte 48\n.byte 44\n.byte 32\n.byte 49\n.byte 54\n.byte 44\n.byte 32\n.byte 49\n.byte 48\n.byte 48\n.byte 44\n.byte 32\n.byte 50\n.byte 53\n.byte 54\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 0\n.align 1\n.L965:\n.byte 82\n.byte 117\n.byte 110\n.byte 110\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 114\n.byte 101\n.byte 118\n.byte 101\n.byte 97\n.byte 108\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 115\n.byte 101\n.byte 32\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 101\n.byte 114\n.byte 105\n.byte 115\n.byte 116\n.byte 105\n.byte 99\n.byte 115\n.byte 58\n.byte 0\n.align 1\n.L962:\n.byte 9\n.byte 79\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 114\n.byte 101\n.byte 108\n.byte 101\n.byte 118\n.byte 97\n.byte 110\n.byte 116\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 105\n.byte 108\n.byte 101\n.byte 114\n.byte 32\n.byte 111\n.byte 112\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 58\n.byte 0\n.align 1\n.L961:\n.byte 9\n.byte 79\n.byte 112\n.byte 116\n.byte 105\n.byte 109\n.byte 105\n.byte 122\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 108\n.byte 101\n.byte 118\n.byte 101\n.byte 108\n.byte 58\n.byte 10\n.byte 0\n.align 1\n.L960:\n.byte 9\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 105\n.byte 108\n.byte 101\n.byte 114\n.byte 58\n.byte 10\n.byte 0\n.align 1\n.L959:\n.byte 9\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 114\n.byte 58\n.byte 10\n.byte 0\n.align 1\n.L958:\n.byte 9\n.byte 86\n.byte 101\n.byte 114\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 58\n.byte 9\n.byte 49\n.byte 48\n.byte 32\n.byte 70\n.byte 101\n.byte 98\n.byte 114\n.byte 117\n.byte 97\n.byte 114\n.byte 121\n.byte 32\n.byte 49\n.byte 57\n.byte 56\n.byte 57\n.byte 59\n.byte 0\n.align 1\n.L957:\n.byte 9\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 58\n.byte 9\n.byte 100\n.byte 111\n.byte 117\n.byte 98\n.byte 108\n.byte 101\n.byte 59\n.byte 0\n.align 1\n.L956:\n.byte 73\n.byte 110\n.byte 32\n.byte 100\n.byte 111\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 115\n.byte 111\n.byte 44\n.byte 32\n.byte 112\n.byte 108\n.byte 101\n.byte 97\n.byte 115\n.byte 101\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 108\n.byte 117\n.byte 100\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 102\n.byte 111\n.byte 108\n.byte 108\n.byte 111\n.byte 119\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 105\n.byte 110\n.byte 102\n.byte 111\n.byte 114\n.byte 109\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 58\n.byte 0\n.align 1\n.L955:\n.byte 9\n.byte 83\n.byte 97\n.byte 110\n.byte 32\n.byte 70\n.byte 114\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 44\n.byte 32\n.byte 67\n.byte 65\n.byte 32\n.byte 57\n.byte 52\n.byte 49\n.byte 52\n.byte 51\n.byte 45\n.byte 48\n.byte 55\n.byte 48\n.byte 52\n.byte 44\n.byte 32\n.byte 85\n.byte 83\n.byte 65\n.byte 10\n.byte 0\n.align 1\n.L954:\n.byte 9\n.byte 85\n.byte 110\n.byte 105\n.byte 118\n.byte 101\n.byte 114\n.byte 115\n.byte 105\n.byte 116\n.byte 121\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 67\n.byte 97\n.byte 108\n.byte 105\n.byte 102\n.byte 111\n.byte 114\n.byte 110\n.byte 105\n.byte 97\n.byte 0\n.align 1\n.L953:\n.byte 9\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 67\n.byte 101\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 85\n.byte 45\n.byte 55\n.byte 54\n.byte 0\n.align 1\n.L952:\n.byte 9\n.byte 82\n.byte 105\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 75\n.byte 97\n.byte 114\n.byte 112\n.byte 105\n.byte 110\n.byte 115\n.byte 107\n.byte 105\n.byte 0\n.align 1\n.L951:\n.byte 80\n.byte 108\n.byte 101\n.byte 97\n.byte 115\n.byte 101\n.byte 32\n.byte 115\n.byte 101\n.byte 110\n.byte 100\n.byte 32\n.byte 115\n.byte 117\n.byte 103\n.byte 103\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 114\n.byte 101\n.byte 115\n.byte 117\n.byte 108\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 0\n.align 1\n.L950:\n.byte 99\n.byte 111\n.byte 112\n.byte 101\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 117\n.byte 110\n.byte 97\n.byte 110\n.byte 116\n.byte 105\n.byte 99\n.byte 105\n.byte 112\n.byte 97\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 110\n.byte 101\n.byte 119\n.byte 108\n.byte 121\n.byte 32\n.byte 117\n.byte 110\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 112\n.byte 97\n.byte 116\n.byte 104\n.byte 111\n.byte 108\n.byte 111\n.byte 103\n.byte 105\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L949:\n.byte 85\n.byte 115\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 105\n.byte 110\n.byte 118\n.byte 105\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 104\n.byte 101\n.byte 108\n.byte 112\n.byte 32\n.byte 100\n.byte 101\n.byte 98\n.byte 117\n.byte 103\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 97\n.byte 117\n.byte 103\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 115\n.byte 111\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 119\n.byte 105\n.byte 108\n.byte 108\n.byte 0\n.align 1\n.L946:\n.byte 65\n.byte 110\n.byte 115\n.byte 119\n.byte 101\n.byte 114\n.byte 32\n.byte 113\n.byte 117\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 89\n.byte 44\n.byte 32\n.byte 121\n.byte 44\n.byte 32\n.byte 78\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 110\n.byte 32\n.byte 40\n.byte 117\n.byte 110\n.byte 108\n.byte 101\n.byte 115\n.byte 115\n.byte 32\n.byte 111\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 119\n.byte 105\n.byte 115\n.byte 101\n.byte 32\n.byte 105\n.byte 110\n.byte 100\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 101\n.byte 100\n.byte 41\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L945:\n.byte 97\n.byte 109\n.byte 101\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 107\n.byte 101\n.byte 32\n.byte 102\n.byte 117\n.byte 114\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L944:\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 97\n.byte 110\n.byte 121\n.byte 119\n.byte 97\n.byte 121\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 115\n.byte 101\n.byte 101\n.byte 32\n.byte 104\n.byte 111\n.byte 119\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 109\n.byte 105\n.byte 108\n.byte 101\n.byte 115\n.byte 116\n.byte 111\n.byte 110\n.byte 101\n.byte 115\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 112\n.byte 97\n.byte 115\n.byte 115\n.byte 101\n.byte 115\n.byte 44\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 110\n.byte 0\n.align 1\n.L943:\n.byte 119\n.byte 97\n.byte 114\n.byte 110\n.byte 105\n.byte 110\n.byte 103\n.byte 46\n.byte 32\n.byte 32\n.byte 73\n.byte 102\n.byte 32\n.byte 112\n.byte 101\n.byte 114\n.byte 115\n.byte 117\n.byte 97\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 118\n.byte 97\n.byte 105\n.byte 108\n.byte 115\n.byte 32\n.byte 110\n.byte 97\n.byte 117\n.byte 103\n.byte 104\n.byte 116\n.byte 44\n.byte 32\n.byte 100\n.byte 111\n.byte 110\n.byte 39\n.byte 116\n.byte 32\n.byte 100\n.byte 101\n.byte 115\n.byte 112\n.byte 97\n.byte 105\n.byte 114\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 32\n.byte 114\n.byte 117\n.byte 110\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 0\n.align 1\n.L942:\n.byte 116\n.byte 111\n.byte 32\n.byte 112\n.byte 101\n.byte 114\n.byte 115\n.byte 101\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 97\n.byte 32\n.byte 115\n.byte 117\n.byte 114\n.byte 114\n.byte 111\n.byte 103\n.byte 97\n.byte 116\n.byte 101\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 97\n.byte 102\n.byte 116\n.byte 101\n.byte 114\n.byte 44\n.byte 32\n.byte 112\n.byte 101\n.byte 114\n.byte 104\n.byte 97\n.byte 112\n.byte 115\n.byte 44\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 112\n.byte 108\n.byte 97\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 115\n.byte 111\n.byte 109\n.byte 101\n.byte 0\n.align 1\n.L941:\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 32\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 47\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 111\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 115\n.byte 44\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 32\n.byte 114\n.byte 97\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 0\n.align 1\n.L940:\n.byte 116\n.byte 114\n.byte 121\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 112\n.byte 101\n.byte 114\n.byte 115\n.byte 117\n.byte 97\n.byte 100\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 116\n.byte 101\n.byte 114\n.byte 109\n.byte 105\n.byte 110\n.byte 97\n.byte 116\n.byte 101\n.byte 32\n.byte 101\n.byte 120\n.byte 101\n.byte 99\n.byte 117\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 110\n.byte 32\n.byte 97\n.byte 110\n.byte 0\n.align 1\n.L939:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 96\n.byte 69\n.byte 78\n.byte 68\n.byte 32\n.byte 79\n.byte 70\n.byte 32\n.byte 84\n.byte 69\n.byte 83\n.byte 84\n.byte 39\n.byte 44\n.byte 10\n.byte 0\n.align 1\n.L938:\n.byte 76\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 115\n.byte 116\n.byte 111\n.byte 112\n.byte 32\n.byte 112\n.byte 114\n.byte 101\n.byte 109\n.byte 97\n.byte 116\n.byte 117\n.byte 114\n.byte 101\n.byte 108\n.byte 121\n.byte 44\n.byte 32\n.byte 105\n.byte 46\n.byte 101\n.byte 46\n.byte 32\n.byte 98\n.byte 101\n.byte 102\n.byte 111\n.byte 114\n.byte 101\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 112\n.byte 108\n.byte 97\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 10\n.byte 0\n.align 1\n.L935:\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.L930:\n.byte 32\n.byte 32\n.byte 32\n.byte 80\n.byte 76\n.byte 69\n.byte 65\n.byte 83\n.byte 69\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 73\n.byte 70\n.byte 89\n.byte 32\n.byte 75\n.byte 65\n.byte 82\n.byte 80\n.byte 73\n.byte 78\n.byte 75\n.byte 83\n.byte 73\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.L929:\n.byte 37\n.byte 115\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 111\n.byte 110\n.byte 115\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 110\n.byte 116\n.byte 46\n.byte 46\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L927:\n.byte 9\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 90\n.byte 32\n.byte 42\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L926:\n.byte 9\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 49\n.byte 32\n.byte 42\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L925:\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 100\n.byte 111\n.byte 101\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 109\n.byte 117\n.byte 116\n.byte 101\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.L920:\n.byte 90\n.byte 32\n.byte 47\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L917:\n.byte 49\n.byte 32\n.byte 42\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 37\n.byte 103\n.byte 10\n.byte 0\n.align 1\n.L914:\n.byte 90\n.byte 32\n.byte 42\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 0\n.align 1\n.L911:\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 9\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 101\n.byte 115\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 32\n.byte 0\n.align 1\n.L910:\n.byte 87\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 0\n.align 1\n.L905:\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.L902:\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 86\n.byte 69\n.byte 82\n.byte 89\n.byte 32\n.byte 83\n.byte 69\n.byte 82\n.byte 73\n.byte 79\n.byte 85\n.byte 83\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.L896:\n.byte 32\n.byte 104\n.byte 97\n.byte 115\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 32\n.byte 106\n.byte 117\n.byte 115\n.byte 116\n.byte 32\n.byte 98\n.byte 101\n.byte 101\n.byte 110\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 97\n.byte 108\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L895:\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 79\n.byte 46\n.byte 75\n.byte 46\n.byte 44\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 118\n.byte 105\n.byte 100\n.byte 101\n.byte 100\n.byte 32\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 47\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 0\n.align 1\n.L892:\n.byte 87\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 109\n.byte 97\n.byte 99\n.byte 104\n.byte 105\n.byte 110\n.byte 101\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 40\n.byte 90\n.byte 32\n.byte 43\n.byte 32\n.byte 90\n.byte 41\n.byte 32\n.byte 47\n.byte 32\n.byte 90\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L888:\n.byte 40\n.byte 90\n.byte 32\n.byte 43\n.byte 32\n.byte 90\n.byte 41\n.byte 32\n.byte 47\n.byte 32\n.byte 90\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 115\n.byte 97\n.byte 102\n.byte 101\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L887:\n.byte 83\n.byte 105\n.byte 110\n.byte 99\n.byte 101\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 100\n.byte 101\n.byte 110\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 101\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 0\n.align 1\n.L883:\n.byte 83\n.byte 105\n.byte 109\n.byte 105\n.byte 108\n.byte 97\n.byte 114\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 114\n.byte 101\n.byte 112\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 104\n.byte 97\n.byte 118\n.byte 101\n.byte 32\n.byte 111\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 116\n.byte 105\n.byte 109\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L873:\n.byte 9\n.byte 9\n.byte 116\n.byte 104\n.byte 101\n.byte 121\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L872:\n.byte 9\n.byte 119\n.byte 104\n.byte 105\n.byte 99\n.byte 104\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 117\n.byte 110\n.byte 101\n.byte 113\n.byte 117\n.byte 97\n.byte 108\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 59\n.byte 10\n.byte 0\n.align 1\n.L871:\n.byte 9\n.byte 121\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 101\n.byte 100\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 59\n.byte 10\n.byte 0\n.align 1\n.L870:\n.byte 9\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 10\n.byte 0\n.align 1\n.L869:\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 10\n.byte 0\n.align 1\n.L868:\n.byte 87\n.byte 65\n.byte 82\n.byte 78\n.byte 73\n.byte 78\n.byte 71\n.byte 58\n.byte 32\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 10\n.byte 0\n.align 1\n.L850:\n.byte 9\n.byte 105\n.byte 110\n.byte 115\n.byte 116\n.byte 101\n.byte 97\n.byte 100\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 48\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L849:\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 40\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 45\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 8\n.L841:\n.word 0x3ed4f8b5\n.word 0x88e368f1\n.align 1\n.L839:\n.byte 37\n.byte 115\n.byte 58\n.byte 32\n.byte 32\n.byte 37\n.byte 115\n.byte 0\n.align 1\n.L838:\n.byte 70\n.byte 76\n.byte 65\n.byte 87\n.byte 0\n.align 1\n.L837:\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 0\n.align 1\n.L836:\n.byte 83\n.byte 69\n.byte 82\n.byte 73\n.byte 79\n.byte 85\n.byte 83\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 0\n.align 1\n.L835:\n.byte 70\n.byte 65\n.byte 73\n.byte 76\n.byte 85\n.byte 82\n.byte 69\n.byte 0\n.align 1\n.L829:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 80\n.byte 97\n.byte 103\n.byte 101\n.byte 58\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 10\n.byte 0\n.align 1\n.L828:\n.byte 10\n.byte 68\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 105\n.byte 115\n.byte 32\n.byte 114\n.byte 101\n.byte 115\n.byte 117\n.byte 109\n.byte 101\n.byte 115\n.byte 32\n.byte 97\n.byte 102\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 109\n.byte 105\n.byte 108\n.byte 101\n.byte 115\n.byte 116\n.byte 111\n.byte 110\n.byte 101\n.byte 32\n.byte 78\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 37\n.byte 100\n.byte 0\n.align 8\n.L826:\n.word 0xbff00000\n.word 0x0\n.align 1\n.L821:\n.byte 69\n.byte 78\n.byte 68\n.byte 32\n.byte 79\n.byte 70\n.byte 32\n.byte 84\n.byte 69\n.byte 83\n.byte 84\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L820:\n.byte 10\n.byte 65\n.byte 32\n.byte 116\n.byte 111\n.byte 116\n.byte 97\n.byte 108\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 102\n.byte 108\n.byte 111\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 112\n.byte 111\n.byte 105\n.byte 110\n.byte 116\n.byte 32\n.byte 101\n.byte 120\n.byte 99\n.byte 101\n.byte 112\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 119\n.byte 101\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 101\n.byte 103\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L817:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 69\n.byte 120\n.byte 99\n.byte 101\n.byte 108\n.byte 108\n.byte 101\n.byte 110\n.byte 116\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.L816:\n.byte 32\n.byte 100\n.byte 117\n.byte 114\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 71\n.byte 114\n.byte 97\n.byte 100\n.byte 117\n.byte 97\n.byte 108\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L815:\n.byte 44\n.byte 10\n.byte 101\n.byte 120\n.byte 99\n.byte 101\n.byte 112\n.byte 116\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 112\n.byte 111\n.byte 115\n.byte 115\n.byte 105\n.byte 98\n.byte 108\n.byte 121\n.byte 32\n.byte 68\n.byte 111\n.byte 117\n.byte 98\n.byte 108\n.byte 101\n.byte 32\n.byte 82\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 0\n.align 1\n.L814:\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L811:\n.byte 56\n.byte 53\n.byte 52\n.byte 0\n.align 1\n.L810:\n.byte 55\n.byte 53\n.byte 52\n.byte 0\n.align 1\n.L807:\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 112\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 73\n.byte 69\n.byte 69\n.byte 69\n.byte 32\n.byte 115\n.byte 116\n.byte 97\n.byte 110\n.byte 100\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 80\n.byte 0\n.align 1\n.L806:\n.byte 82\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 111\n.byte 114\n.byte 109\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 0\n.align 1\n.L803:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 115\n.byte 101\n.byte 101\n.byte 109\n.byte 115\n.byte 32\n.byte 83\n.byte 97\n.byte 116\n.byte 105\n.byte 115\n.byte 102\n.byte 97\n.byte 99\n.byte 116\n.byte 111\n.byte 114\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L797:\n.byte 78\n.byte 111\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 117\n.byte 114\n.byte 101\n.byte 115\n.byte 44\n.byte 32\n.byte 100\n.byte 101\n.byte 102\n.byte 101\n.byte 99\n.byte 116\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 102\n.byte 108\n.byte 97\n.byte 119\n.byte 115\n.byte 32\n.byte 104\n.byte 97\n.byte 118\n.byte 101\n.byte 32\n.byte 98\n.byte 101\n.byte 101\n.byte 110\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L796:\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 39\n.byte 115\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 115\n.byte 101\n.byte 113\n.byte 117\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L795:\n.byte 80\n.byte 111\n.byte 116\n.byte 101\n.byte 110\n.byte 116\n.byte 105\n.byte 97\n.byte 108\n.byte 108\n.byte 121\n.byte 32\n.byte 102\n.byte 97\n.byte 116\n.byte 97\n.byte 108\n.byte 32\n.byte 70\n.byte 65\n.byte 73\n.byte 76\n.byte 85\n.byte 82\n.byte 69\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 104\n.byte 97\n.byte 118\n.byte 101\n.byte 32\n.byte 115\n.byte 112\n.byte 111\n.byte 105\n.byte 108\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 0\n.align 1\n.L792:\n.byte 117\n.byte 110\n.byte 97\n.byte 99\n.byte 99\n.byte 101\n.byte 112\n.byte 116\n.byte 97\n.byte 98\n.byte 108\n.byte 101\n.byte 32\n.byte 83\n.byte 101\n.byte 114\n.byte 105\n.byte 111\n.byte 117\n.byte 115\n.byte 32\n.byte 68\n.byte 101\n.byte 102\n.byte 101\n.byte 99\n.byte 116\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L791:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 104\n.byte 97\n.byte 115\n.byte 32\n.byte 0\n.align 1\n.L787:\n.byte 100\n.byte 101\n.byte 115\n.byte 112\n.byte 105\n.byte 116\n.byte 101\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 111\n.byte 110\n.byte 118\n.byte 101\n.byte 110\n.byte 105\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 68\n.byte 101\n.byte 102\n.byte 101\n.byte 99\n.byte 116\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L786:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 65\n.byte 99\n.byte 99\n.byte 101\n.byte 112\n.byte 116\n.byte 97\n.byte 98\n.byte 108\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L781:\n.byte 83\n.byte 97\n.byte 116\n.byte 105\n.byte 115\n.byte 102\n.byte 97\n.byte 99\n.byte 116\n.byte 111\n.byte 114\n.byte 121\n.byte 32\n.byte 116\n.byte 104\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 32\n.byte 102\n.byte 108\n.byte 97\n.byte 119\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L780:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 115\n.byte 101\n.byte 101\n.byte 109\n.byte 115\n.byte 32\n.byte 0\n.align 1\n.L769:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 32\n.byte 37\n.byte 45\n.byte 50\n.byte 57\n.byte 115\n.byte 32\n.byte 37\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L762:\n.byte 70\n.byte 76\n.byte 65\n.byte 87\n.byte 115\n.byte 32\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 61\n.byte 0\n.align 1\n.L761:\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 115\n.byte 32\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 61\n.byte 0\n.align 1\n.L760:\n.byte 83\n.byte 69\n.byte 82\n.byte 73\n.byte 79\n.byte 85\n.byte 83\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 115\n.byte 32\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 61\n.byte 0\n.align 1\n.L759:\n.byte 70\n.byte 65\n.byte 73\n.byte 76\n.byte 85\n.byte 82\n.byte 69\n.byte 115\n.byte 32\n.byte 32\n.byte 101\n.byte 110\n.byte 99\n.byte 111\n.byte 117\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 61\n.byte 0\n.align 1\n.L755:\n.byte 10\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 84\n.byte 114\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 32\n.byte 48\n.byte 32\n.byte 47\n.byte 32\n.byte 48\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 101\n.byte 115\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 0\n.align 1\n.L754:\n.byte 32\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L751:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 84\n.byte 114\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 32\n.byte 49\n.byte 32\n.byte 47\n.byte 32\n.byte 48\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 101\n.byte 115\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 0\n.align 1\n.L750:\n.byte 87\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 109\n.byte 101\n.byte 115\n.byte 115\n.byte 97\n.byte 103\n.byte 101\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 47\n.byte 111\n.byte 114\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 115\n.byte 32\n.byte 100\n.byte 111\n.byte 101\n.byte 115\n.byte 32\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 101\n.byte 63\n.byte 10\n.byte 0\n.align 1\n.L749:\n.byte 32\n.byte 32\n.byte 105\n.byte 110\n.byte 115\n.byte 116\n.byte 101\n.byte 97\n.byte 100\n.byte 44\n.byte 32\n.byte 88\n.byte 32\n.byte 47\n.byte 32\n.byte 88\n.byte 32\n.byte 45\n.byte 32\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 45\n.byte 32\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L748:\n.byte 32\n.byte 32\n.byte 88\n.byte 32\n.byte 47\n.byte 32\n.byte 88\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 49\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 110\n.byte 32\n.byte 88\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L743:\n.byte 32\n.byte 32\n.byte 88\n.byte 32\n.byte 47\n.byte 32\n.byte 88\n.byte 32\n.byte 32\n.byte 116\n.byte 114\n.byte 97\n.byte 112\n.byte 115\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 110\n.byte 32\n.byte 88\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 103\n.byte 10\n.byte 0\n.align 1\n.L728:\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 102\n.byte 97\n.byte 114\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 49\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L727:\n.byte 32\n.byte 117\n.byte 110\n.byte 98\n.byte 97\n.byte 108\n.byte 97\n.byte 110\n.byte 99\n.byte 101\n.byte 100\n.byte 32\n.byte 114\n.byte 97\n.byte 110\n.byte 103\n.byte 101\n.byte 59\n.byte 32\n.byte 85\n.byte 102\n.byte 84\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 42\n.byte 32\n.byte 86\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 9\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.L726:\n.byte 66\n.byte 97\n.byte 100\n.byte 108\n.byte 121\n.byte 0\n.align 1\n.L719:\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 102\n.byte 97\n.byte 114\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 40\n.byte 90\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 50\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L718:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L706:\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 102\n.byte 97\n.byte 114\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 40\n.byte 90\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L705:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 119\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L688:\n.byte 43\n.byte 45\n.byte 37\n.byte 103\n.byte 44\n.byte 32\n.byte 43\n.byte 45\n.byte 37\n.byte 103\n.byte 10\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 43\n.byte 45\n.byte 37\n.byte 103\n.byte 32\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 117\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 46\n.byte 0\n.align 1\n.L687:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 105\n.byte 110\n.byte 118\n.byte 111\n.byte 108\n.byte 118\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 0\n.align 1\n.L681:\n.byte 97\n.byte 98\n.byte 111\n.byte 118\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L680:\n.byte 65\n.byte 110\n.byte 121\n.byte 32\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 115\n.byte 101\n.byte 112\n.byte 97\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 42\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 111\n.byte 110\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L679:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 86\n.byte 32\n.byte 47\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L678:\n.byte 78\n.byte 111\n.byte 32\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 97\n.byte 108\n.byte 101\n.byte 100\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 86\n.byte 32\n.byte 42\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L677:\n.byte 84\n.byte 104\n.byte 101\n.byte 114\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 32\n.byte 115\n.byte 97\n.byte 116\n.byte 117\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 98\n.byte 101\n.byte 99\n.byte 97\n.byte 117\n.byte 115\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 115\n.byte 121\n.byte 115\n.byte 116\n.byte 101\n.byte 109\n.byte 32\n.byte 116\n.byte 114\n.byte 97\n.byte 112\n.byte 115\n.byte 32\n.byte 111\n.byte 110\n.byte 32\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L676:\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 115\n.byte 97\n.byte 116\n.byte 117\n.byte 114\n.byte 97\n.byte 116\n.byte 101\n.byte 115\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 86\n.byte 48\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L673:\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 86\n.byte 32\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L664:\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 112\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 9\n.byte 115\n.byte 104\n.byte 114\n.byte 105\n.byte 110\n.byte 107\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L661:\n.byte 45\n.byte 40\n.byte 45\n.byte 89\n.byte 41\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 89\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L660:\n.byte 102\n.byte 105\n.byte 110\n.byte 100\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 0\n.align 1\n.L659:\n.byte 83\n.byte 101\n.byte 101\n.byte 109\n.byte 115\n.byte 32\n.byte 79\n.byte 46\n.byte 75\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L656:\n.byte 84\n.byte 114\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 111\n.byte 110\n.byte 32\n.byte 89\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L655:\n.byte 67\n.byte 97\n.byte 110\n.byte 32\n.byte 96\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 45\n.byte 89\n.byte 39\n.byte 32\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 63\n.byte 10\n.byte 0\n.align 1\n.L648:\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 103\n.byte 101\n.byte 110\n.byte 101\n.byte 114\n.byte 97\n.byte 116\n.byte 101\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L647:\n.byte 83\n.byte 101\n.byte 97\n.byte 114\n.byte 99\n.byte 104\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 58\n.byte 10\n.byte 0\n.align 1\n.L646:\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 32\n.byte 110\n.byte 111\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 114\n.byte 101\n.byte 112\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L638:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 112\n.byte 111\n.byte 119\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 90\n.byte 94\n.byte 81\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 114\n.byte 32\n.byte 110\n.byte 101\n.byte 97\n.byte 114\n.byte 108\n.byte 121\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 101\n.byte 109\n.byte 101\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L637:\n.byte 65\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 97\n.byte 99\n.byte 121\n.byte 32\n.byte 115\n.byte 101\n.byte 101\n.byte 109\n.byte 115\n.byte 32\n.byte 97\n.byte 100\n.byte 101\n.byte 113\n.byte 117\n.byte 97\n.byte 116\n.byte 101\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L630:\n.byte 9\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 105\n.byte 110\n.byte 118\n.byte 111\n.byte 108\n.byte 118\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 105\n.byte 110\n.byte 121\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 114\n.byte 97\n.byte 116\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L629:\n.byte 9\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 109\n.byte 117\n.byte 99\n.byte 104\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 115\n.byte 112\n.byte 111\n.byte 105\n.byte 108\n.byte 32\n.byte 102\n.byte 105\n.byte 110\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 97\n.byte 108\n.byte 10\n.byte 0\n.align 1\n.L628:\n.byte 9\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L627:\n.byte 9\n.byte 40\n.byte 49\n.byte 32\n.byte 43\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 59\n.byte 10\n.byte 0\n.align 1\n.L626:\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 10\n.byte 0\n.align 1\n.L625:\n.byte 67\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 101\n.byte 100\n.byte 0\n.align 1\n.L618:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 88\n.byte 94\n.byte 40\n.byte 40\n.byte 88\n.byte 32\n.byte 43\n.byte 32\n.byte 49\n.byte 41\n.byte 32\n.byte 47\n.byte 32\n.byte 40\n.byte 88\n.byte 32\n.byte 45\n.byte 32\n.byte 49\n.byte 41\n.byte 41\n.byte 32\n.byte 118\n.byte 115\n.byte 46\n.byte 32\n.byte 101\n.byte 120\n.byte 112\n.byte 40\n.byte 50\n.byte 41\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 88\n.byte 32\n.byte 45\n.byte 62\n.byte 32\n.byte 49\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L614:\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 79\n.byte 46\n.byte 75\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L611:\n.byte 32\n.byte 32\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L610:\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 98\n.byte 101\n.byte 116\n.byte 119\n.byte 101\n.byte 101\n.byte 110\n.byte 32\n.byte 48\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 10\n.byte 0\n.align 1\n.L606:\n.byte 97\n.byte 99\n.byte 116\n.byte 117\n.byte 97\n.byte 108\n.byte 108\n.byte 121\n.byte 32\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 121\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 115\n.byte 58\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L605:\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 97\n.byte 102\n.byte 102\n.byte 108\n.byte 105\n.byte 99\n.byte 116\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 101\n.byte 120\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 10\n.byte 9\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 59\n.byte 10\n.byte 0\n.align 1\n.L604:\n.byte 85\n.byte 102\n.byte 84\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 61\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 10\n.byte 111\n.byte 110\n.byte 108\n.byte 121\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 0\n.align 1\n.L603:\n.byte 83\n.byte 105\n.byte 110\n.byte 99\n.byte 101\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 111\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 115\n.byte 32\n.byte 98\n.byte 101\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L602:\n.byte 82\n.byte 97\n.byte 110\n.byte 103\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 110\n.byte 97\n.byte 114\n.byte 114\n.byte 111\n.byte 119\n.byte 59\n.byte 32\n.byte 85\n.byte 49\n.byte 94\n.byte 37\n.byte 100\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L597:\n.byte 109\n.byte 101\n.byte 114\n.byte 101\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 111\n.byte 102\n.byte 102\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L596:\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 115\n.byte 117\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 32\n.byte 108\n.byte 97\n.byte 114\n.byte 103\n.byte 101\n.byte 114\n.byte 32\n.byte 82\n.byte 101\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 110\n.byte 32\n.byte 0\n.align 1\n.L595:\n.byte 32\n.byte 98\n.byte 101\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 119\n.byte 104\n.byte 105\n.byte 99\n.byte 104\n.byte 0\n.align 1\n.L594:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.L593:\n.byte 88\n.byte 32\n.byte 47\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 49\n.byte 32\n.byte 43\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L592:\n.byte 88\n.byte 32\n.byte 47\n.byte 32\n.byte 90\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 115\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.L589:\n.byte 101\n.byte 110\n.byte 99\n.byte 111\n.byte 117\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 97\n.byte 108\n.byte 116\n.byte 104\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 32\n.byte 97\n.byte 99\n.byte 116\n.byte 117\n.byte 97\n.byte 108\n.byte 108\n.byte 121\n.byte 10\n.byte 0\n.align 1\n.L588:\n.byte 32\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 32\n.byte 40\n.byte 102\n.byte 40\n.byte 88\n.byte 41\n.byte 32\n.byte 45\n.byte 32\n.byte 102\n.byte 40\n.byte 90\n.byte 41\n.byte 41\n.byte 32\n.byte 47\n.byte 32\n.byte 40\n.byte 88\n.byte 32\n.byte 45\n.byte 32\n.byte 90\n.byte 41\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L587:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 105\n.byte 102\n.byte 32\n.byte 40\n.byte 88\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 90\n.byte 41\n.byte 32\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 32\n.byte 32\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 0\n.align 1\n.L586:\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 117\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 110\n.byte 32\n.byte 105\n.byte 110\n.byte 110\n.byte 111\n.byte 99\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 115\n.byte 116\n.byte 97\n.byte 116\n.byte 101\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L585:\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 83\n.byte 69\n.byte 82\n.byte 73\n.byte 79\n.byte 85\n.byte 83\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 10\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 99\n.byte 97\n.byte 117\n.byte 115\n.byte 101\n.byte 115\n.byte 32\n.byte 0\n.align 1\n.L584:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 83\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 44\n.byte 32\n.byte 0\n.align 1\n.L583:\n.byte 121\n.byte 101\n.byte 116\n.byte 32\n.byte 88\n.byte 32\n.byte 45\n.byte 32\n.byte 90\n.byte 32\n.byte 121\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 115\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L582:\n.byte 88\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 9\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 101\n.byte 113\n.byte 117\n.byte 97\n.byte 108\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L577:\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 47\n.byte 32\n.byte 85\n.byte 102\n.byte 84\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 101\n.byte 100\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.L567:\n.byte 40\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 111\n.byte 102\n.byte 102\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 85\n.byte 102\n.byte 84\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 41\n.byte 32\n.byte 60\n.byte 32\n.byte 69\n.byte 48\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L566:\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 103\n.byte 114\n.byte 97\n.byte 100\n.byte 117\n.byte 97\n.byte 108\n.byte 59\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 117\n.byte 114\n.byte 115\n.byte 32\n.byte 65\n.byte 98\n.byte 115\n.byte 111\n.byte 108\n.byte 117\n.byte 116\n.byte 101\n.byte 32\n.byte 69\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 61\n.byte 10\n.byte 0\n.align 1\n.L561:\n.byte 124\n.byte 81\n.byte 32\n.byte 45\n.byte 32\n.byte 89\n.byte 124\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L560:\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 32\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 81\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 89\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L559:\n.byte 81\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 89\n.byte 32\n.byte 119\n.byte 104\n.byte 105\n.byte 108\n.byte 101\n.byte 32\n.byte 100\n.byte 101\n.byte 110\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 124\n.byte 81\n.byte 32\n.byte 45\n.byte 32\n.byte 89\n.byte 124\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 48\n.byte 59\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 115\n.byte 101\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.L558:\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 117\n.byte 115\n.byte 101\n.byte 115\n.byte 32\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 44\n.byte 32\n.byte 119\n.byte 104\n.byte 105\n.byte 99\n.byte 104\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 10\n.byte 0\n.align 1\n.L556:\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 32\n.byte 109\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 108\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L555:\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 100\n.byte 111\n.byte 119\n.byte 110\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L554:\n.byte 97\n.byte 112\n.byte 112\n.byte 114\n.byte 111\n.byte 97\n.byte 99\n.byte 104\n.byte 32\n.byte 97\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L553:\n.byte 69\n.byte 105\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 97\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 97\n.byte 99\n.byte 121\n.byte 32\n.byte 100\n.byte 101\n.byte 116\n.byte 101\n.byte 114\n.byte 105\n.byte 111\n.byte 114\n.byte 97\n.byte 116\n.byte 101\n.byte 115\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.L541:\n.byte 83\n.byte 109\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 115\n.byte 116\n.byte 114\n.byte 105\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 112\n.byte 111\n.byte 115\n.byte 105\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 69\n.byte 48\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L540:\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 110\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 116\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L539:\n.byte 68\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 101\n.byte 110\n.byte 99\n.byte 101\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 115\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 97\n.byte 32\n.byte 104\n.byte 105\n.byte 103\n.byte 104\n.byte 101\n.byte 114\n.byte 0\n.align 1\n.L536:\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 110\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 101\n.byte 110\n.byte 99\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L535:\n.byte 80\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 116\n.byte 115\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 97\n.byte 32\n.byte 104\n.byte 105\n.byte 103\n.byte 104\n.byte 101\n.byte 114\n.byte 0\n.align 1\n.L528:\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 80\n.byte 115\n.byte 101\n.byte 117\n.byte 100\n.byte 111\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L527:\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 32\n.byte 115\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 100\n.byte 108\n.byte 121\n.byte 32\n.byte 112\n.byte 111\n.byte 115\n.byte 105\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L526:\n.byte 112\n.byte 111\n.byte 115\n.byte 105\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 44\n.byte 32\n.byte 105\n.byte 115\n.byte 110\n.byte 39\n.byte 116\n.byte 59\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L525:\n.byte 66\n.byte 117\n.byte 116\n.byte 32\n.byte 45\n.byte 80\n.byte 115\n.byte 101\n.byte 117\n.byte 100\n.byte 111\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 44\n.byte 32\n.byte 119\n.byte 104\n.byte 105\n.byte 99\n.byte 104\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 98\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L522:\n.byte 80\n.byte 115\n.byte 101\n.byte 117\n.byte 100\n.byte 111\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 58\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L521:\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 100\n.byte 108\n.byte 121\n.byte 32\n.byte 110\n.byte 101\n.byte 103\n.byte 97\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L520:\n.byte 80\n.byte 111\n.byte 115\n.byte 105\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 101\n.byte 120\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 97\n.byte 110\n.byte 10\n.byte 0\n.align 1\n.L507:\n.byte 109\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 108\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L483:\n.byte 83\n.byte 101\n.byte 101\n.byte 107\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 115\n.byte 32\n.byte 85\n.byte 102\n.byte 84\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 69\n.byte 48\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L480:\n.byte 46\n.byte 46\n.byte 46\n.byte 32\n.byte 110\n.byte 111\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 114\n.byte 101\n.byte 112\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L477:\n.byte 9\n.byte 105\n.byte 110\n.byte 118\n.byte 111\n.byte 108\n.byte 118\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 114\n.byte 97\n.byte 116\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L476:\n.byte 69\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 115\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 105\n.byte 110\n.byte 118\n.byte 97\n.byte 108\n.byte 105\n.byte 100\n.byte 97\n.byte 116\n.byte 101\n.byte 32\n.byte 102\n.byte 105\n.byte 110\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 97\n.byte 108\n.byte 32\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.L455:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 112\n.byte 111\n.byte 119\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 90\n.byte 94\n.byte 105\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 115\n.byte 109\n.byte 97\n.byte 108\n.byte 108\n.byte 32\n.byte 73\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 90\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L452:\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 108\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 0\n.align 1\n.L450:\n.byte 116\n.byte 111\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 117\n.byte 108\n.byte 112\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L449:\n.byte 79\n.byte 98\n.byte 115\n.byte 101\n.byte 114\n.byte 118\n.byte 101\n.byte 100\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 115\n.byte 32\n.byte 114\n.byte 117\n.byte 110\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 0\n.align 1\n.L448:\n.byte 83\n.byte 113\n.byte 117\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 111\n.byte 111\n.byte 116\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 101\n.byte 105\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L445:\n.byte 83\n.byte 113\n.byte 117\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 111\n.byte 111\n.byte 116\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L440:\n.byte 83\n.byte 113\n.byte 117\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 111\n.byte 111\n.byte 116\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L435:\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 115\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 115\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L434:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 94\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L433:\n.byte 65\n.byte 110\n.byte 111\n.byte 109\n.byte 97\n.byte 108\n.byte 111\n.byte 117\n.byte 115\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 73\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 32\n.byte 60\n.byte 32\n.byte 0\n.align 1\n.L393:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L371:\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 40\n.byte 88\n.byte 41\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 110\n.byte 45\n.byte 109\n.byte 111\n.byte 110\n.byte 111\n.byte 116\n.byte 111\n.byte 110\n.byte 105\n.byte 99\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 88\n.byte 32\n.byte 110\n.byte 101\n.byte 97\n.byte 114\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L370:\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 104\n.byte 97\n.byte 115\n.byte 32\n.byte 112\n.byte 97\n.byte 115\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 97\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 77\n.byte 111\n.byte 110\n.byte 111\n.byte 116\n.byte 111\n.byte 110\n.byte 105\n.byte 99\n.byte 105\n.byte 116\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L353:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 109\n.byte 111\n.byte 110\n.byte 111\n.byte 116\n.byte 111\n.byte 110\n.byte 105\n.byte 99\n.byte 105\n.byte 116\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L342:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 105\n.byte 102\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 40\n.byte 88\n.byte 32\n.byte 42\n.byte 32\n.byte 88\n.byte 41\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 88\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 73\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 88\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L337:\n.byte 83\n.byte 113\n.byte 117\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 111\n.byte 111\n.byte 116\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 48\n.byte 46\n.byte 48\n.byte 44\n.byte 32\n.byte 45\n.byte 48\n.byte 46\n.byte 48\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 49\n.byte 46\n.byte 48\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 0\n.align 1\n.L335:\n.byte 10\n.byte 82\n.byte 117\n.byte 110\n.byte 110\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 115\n.byte 113\n.byte 117\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 111\n.byte 111\n.byte 116\n.byte 40\n.byte 120\n.byte 41\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L334:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 78\n.byte 111\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 117\n.byte 114\n.byte 101\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 32\n.byte 112\n.byte 97\n.byte 105\n.byte 114\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L333:\n.byte 88\n.byte 32\n.byte 42\n.byte 32\n.byte 89\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 89\n.byte 32\n.byte 42\n.byte 32\n.byte 88\n.byte 32\n.byte 116\n.byte 114\n.byte 105\n.byte 97\n.byte 108\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 8\n.L324:\n.word 0x40080000\n.word 0x0\n.align 1\n.L323:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 111\n.byte 110\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 114\n.byte 97\n.byte 110\n.byte 100\n.byte 111\n.byte 109\n.byte 32\n.byte 112\n.byte 97\n.byte 105\n.byte 114\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L322:\n.byte 68\n.byte 111\n.byte 101\n.byte 115\n.byte 32\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 109\n.byte 117\n.byte 116\n.byte 101\n.byte 63\n.byte 32\n.byte 32\n.byte 0\n.align 1\n.L319:\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 40\n.byte 115\n.byte 41\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 103\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 117\n.byte 114\n.byte 101\n.byte 40\n.byte 115\n.byte 41\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 10\n.byte 40\n.byte 110\n.byte 111\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 97\n.byte 98\n.byte 111\n.byte 118\n.byte 101\n.byte 41\n.byte 32\n.byte 99\n.byte 111\n.byte 117\n.byte 110\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 111\n.byte 110\n.byte 101\n.byte 32\n.byte 102\n.byte 108\n.byte 97\n.byte 119\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 102\n.byte 105\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 116\n.byte 97\n.byte 108\n.byte 108\n.byte 121\n.byte 32\n.byte 98\n.byte 101\n.byte 108\n.byte 111\n.byte 119\n.byte 0\n.align 1\n.L317:\n.byte 83\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 121\n.byte 32\n.byte 98\n.byte 105\n.byte 116\n.byte 32\n.byte 117\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L316:\n.byte 83\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 121\n.byte 32\n.byte 98\n.byte 105\n.byte 116\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 97\n.byte 114\n.byte 101\n.byte 110\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 117\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L299:\n.byte 67\n.byte 104\n.byte 101\n.byte 99\n.byte 107\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 115\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 121\n.byte 32\n.byte 98\n.byte 105\n.byte 116\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L296:\n.byte 40\n.byte 88\n.byte 32\n.byte 45\n.byte 32\n.byte 89\n.byte 41\n.byte 32\n.byte 43\n.byte 32\n.byte 40\n.byte 89\n.byte 32\n.byte 45\n.byte 32\n.byte 88\n.byte 41\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 110\n.byte 32\n.byte 122\n.byte 101\n.byte 114\n.byte 111\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.L293:\n.byte 65\n.byte 100\n.byte 100\n.byte 105\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 47\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 110\n.byte 101\n.byte 105\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L292:\n.byte 65\n.byte 100\n.byte 100\n.byte 47\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 0\n.align 1\n.L289:\n.byte 65\n.byte 100\n.byte 100\n.byte 105\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 47\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L282:\n.byte 65\n.byte 100\n.byte 100\n.byte 47\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L277:\n.byte 73\n.byte 110\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 108\n.byte 101\n.byte 116\n.byte 101\n.byte 32\n.byte 99\n.byte 97\n.byte 114\n.byte 114\n.byte 121\n.byte 45\n.byte 112\n.byte 114\n.byte 111\n.byte 112\n.byte 97\n.byte 103\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 65\n.byte 100\n.byte 100\n.byte 105\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 1\n.L273:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 42\n.byte 32\n.byte 40\n.byte 32\n.byte 49\n.byte 32\n.byte 47\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 41\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 49\n.byte 0\n.align 1\n.L271:\n.byte 47\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 101\n.byte 105\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L268:\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L265:\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 1\n.L262:\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L257:\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 1\n.L254:\n.byte 42\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 101\n.byte 105\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L253:\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L250:\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L240:\n.byte 88\n.byte 32\n.byte 42\n.byte 32\n.byte 40\n.byte 49\n.byte 47\n.byte 88\n.byte 41\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 49\n.byte 0\n.align 1\n.L221:\n.byte 67\n.byte 104\n.byte 101\n.byte 99\n.byte 107\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 111\n.byte 110\n.byte 32\n.byte 109\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 121\n.byte 44\n.byte 32\n.byte 100\n.byte 105\n.byte 118\n.byte 105\n.byte 100\n.byte 101\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 97\n.byte 100\n.byte 100\n.byte 47\n.byte 115\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L220:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 42\n.byte 44\n.byte 32\n.byte 47\n.byte 44\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 45\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 104\n.byte 97\n.byte 118\n.byte 101\n.byte 32\n.byte 103\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 44\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 121\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L217:\n.byte 32\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 32\n.byte 32\n.byte 105\n.byte 102\n.byte 32\n.byte 40\n.byte 88\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 49\n.byte 46\n.byte 48\n.byte 41\n.byte 32\n.byte 123\n.byte 46\n.byte 46\n.byte 46\n.byte 46\n.byte 46\n.byte 125\n.byte 32\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 32\n.byte 123\n.byte 46\n.byte 46\n.byte 46\n.byte 47\n.byte 40\n.byte 88\n.byte 45\n.byte 49\n.byte 46\n.byte 48\n.byte 41\n.byte 46\n.byte 46\n.byte 46\n.byte 125\n.byte 10\n.byte 0\n.align 1\n.L216:\n.byte 32\n.byte 32\n.byte 115\n.byte 117\n.byte 99\n.byte 104\n.byte 32\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 97\n.byte 117\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 97\n.byte 103\n.byte 97\n.byte 105\n.byte 110\n.byte 115\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 122\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 97\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.L215:\n.byte 32\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 121\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 115\n.byte 32\n.byte 32\n.byte 40\n.byte 49\n.byte 45\n.byte 85\n.byte 49\n.byte 41\n.byte 32\n.byte 45\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 32\n.byte 44\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 101\n.byte 98\n.byte 121\n.byte 32\n.byte 118\n.byte 105\n.byte 116\n.byte 105\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 10\n.byte 0\n.align 1\n.L214:\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 32\n.byte 40\n.byte 49\n.byte 45\n.byte 85\n.byte 49\n.byte 41\n.byte 32\n.byte 60\n.byte 32\n.byte 49\n.byte 32\n.byte 32\n.byte 97\n.byte 108\n.byte 116\n.byte 104\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 10\n.byte 0\n.align 1\n.L211:\n.byte 45\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 115\n.byte 32\n.byte 71\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 68\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 44\n.byte 32\n.byte 115\n.byte 111\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 99\n.byte 101\n.byte 108\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 111\n.byte 98\n.byte 115\n.byte 99\n.byte 117\n.byte 114\n.byte 101\n.byte 100\n.byte 0\n.align 1\n.L206:\n.byte 42\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 47\n.byte 111\n.byte 114\n.byte 32\n.byte 47\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 108\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 0\n.align 1\n.L202:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 49\n.byte 47\n.byte 49\n.byte 46\n.byte 48\n.byte 48\n.byte 48\n.byte 46\n.byte 46\n.byte 49\n.byte 32\n.byte 62\n.byte 61\n.byte 32\n.byte 49\n.byte 0\n.align 1\n.L200:\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 71\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 68\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 44\n.byte 32\n.byte 115\n.byte 111\n.byte 32\n.byte 88\n.byte 47\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 88\n.byte 0\n.align 1\n.L195:\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 71\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 68\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 44\n.byte 32\n.byte 115\n.byte 111\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 32\n.byte 101\n.byte 120\n.byte 99\n.byte 101\n.byte 101\n.byte 100\n.byte 32\n.byte 49\n.byte 32\n.byte 117\n.byte 108\n.byte 112\n.byte 10\n.byte 111\n.byte 114\n.byte 32\n.byte 32\n.byte 49\n.byte 47\n.byte 51\n.byte 32\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 32\n.byte 51\n.byte 47\n.byte 57\n.byte 32\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 32\n.byte 57\n.byte 47\n.byte 50\n.byte 55\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 97\n.byte 103\n.byte 114\n.byte 101\n.byte 101\n.byte 0\n.align 1\n.L191:\n.byte 42\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 102\n.byte 105\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L189:\n.byte 42\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 71\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 68\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 44\n.byte 32\n.byte 115\n.byte 111\n.byte 32\n.byte 49\n.byte 42\n.byte 88\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 88\n.byte 0\n.align 1\n.L186:\n.byte 10\n.byte 67\n.byte 104\n.byte 101\n.byte 99\n.byte 107\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 103\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 42\n.byte 44\n.byte 32\n.byte 47\n.byte 44\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 45\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L185:\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 109\n.byte 97\n.byte 108\n.byte 105\n.byte 122\n.byte 101\n.byte 100\n.byte 44\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 98\n.byte 101\n.byte 46\n.byte 0\n.align 1\n.L180:\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 109\n.byte 97\n.byte 108\n.byte 105\n.byte 122\n.byte 101\n.byte 100\n.byte 32\n.byte 88\n.byte 61\n.byte 89\n.byte 44\n.byte 88\n.byte 43\n.byte 90\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 89\n.byte 43\n.byte 90\n.byte 33\n.byte 0\n.align 1\n.L176:\n.byte 114\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 108\n.byte 121\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 105\n.byte 102\n.byte 105\n.byte 99\n.byte 97\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 101\n.byte 99\n.byte 105\n.byte 109\n.byte 97\n.byte 108\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L175:\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 101\n.byte 108\n.byte 121\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 97\n.byte 98\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 32\n.byte 66\n.byte 45\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 44\n.byte 32\n.byte 105\n.byte 46\n.byte 101\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L174:\n.byte 83\n.byte 111\n.byte 109\n.byte 101\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 101\n.byte 120\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 10\n.byte 0\n.align 1\n.L168:\n.byte 111\n.byte 102\n.byte 32\n.byte 97\n.byte 110\n.byte 10\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 45\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 1\n.L167:\n.byte 90\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 90\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 0\n.align 1\n.L166:\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 101\n.byte 120\n.byte 97\n.byte 99\n.byte 116\n.byte 32\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 97\n.byte 32\n.byte 114\n.byte 101\n.byte 115\n.byte 117\n.byte 108\n.byte 116\n.byte 10\n.byte 0\n.align 1\n.L165:\n.byte 66\n.byte 101\n.byte 99\n.byte 97\n.byte 117\n.byte 115\n.byte 101\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 117\n.byte 110\n.byte 117\n.byte 115\n.byte 117\n.byte 97\n.byte 108\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 102\n.byte 0\n.align 1\n.L161:\n.byte 9\n.byte 85\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 90\n.byte 50\n.byte 32\n.byte 45\n.byte 32\n.byte 85\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L160:\n.byte 9\n.byte 85\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 90\n.byte 49\n.byte 32\n.byte 45\n.byte 32\n.byte 85\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L159:\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 1\n.L158:\n.byte 0\n.align 1\n.L151:\n.byte 84\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 102\n.byte 101\n.byte 97\n.byte 116\n.byte 117\n.byte 114\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 102\n.byte 117\n.byte 114\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L146:\n.byte 80\n.byte 111\n.byte 115\n.byte 115\n.byte 105\n.byte 98\n.byte 108\n.byte 121\n.byte 32\n.byte 115\n.byte 111\n.byte 109\n.byte 101\n.byte 32\n.byte 112\n.byte 97\n.byte 114\n.byte 116\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 0\n.align 1\n.L145:\n.byte 98\n.byte 121\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 45\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 101\n.byte 32\n.byte 101\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 101\n.byte 120\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L144:\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 115\n.byte 121\n.byte 109\n.byte 112\n.byte 116\n.byte 111\n.byte 109\n.byte 115\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 111\n.byte 110\n.byte 115\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 110\n.byte 99\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 101\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L143:\n.byte 114\n.byte 101\n.byte 115\n.byte 112\n.byte 101\n.byte 99\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 108\n.byte 121\n.byte 32\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 10\n.byte 0\n.align 1\n.L142:\n.byte 68\n.byte 105\n.byte 115\n.byte 97\n.byte 103\n.byte 114\n.byte 101\n.byte 101\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 97\n.byte 109\n.byte 111\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 115\n.byte 32\n.byte 88\n.byte 49\n.byte 44\n.byte 32\n.byte 89\n.byte 49\n.byte 44\n.byte 32\n.byte 90\n.byte 49\n.byte 44\n.byte 10\n.byte 0\n.align 1\n.L120:\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 119\n.byte 111\n.byte 114\n.byte 115\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 110\n.byte 32\n.byte 53\n.byte 32\n.byte 100\n.byte 101\n.byte 99\n.byte 105\n.byte 109\n.byte 97\n.byte 108\n.byte 32\n.byte 102\n.byte 105\n.byte 103\n.byte 117\n.byte 114\n.byte 101\n.byte 115\n.byte 32\n.byte 32\n.byte 0\n.align 1\n.L118:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 105\n.byte 102\n.byte 105\n.byte 99\n.byte 97\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 37\n.byte 102\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L117:\n.byte 108\n.byte 111\n.byte 103\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 105\n.byte 99\n.byte 32\n.byte 101\n.byte 110\n.byte 99\n.byte 111\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 104\n.byte 97\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 101\n.byte 114\n.byte 105\n.byte 122\n.byte 101\n.byte 100\n.byte 32\n.byte 115\n.byte 111\n.byte 108\n.byte 101\n.byte 108\n.byte 121\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 85\n.byte 49\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L114:\n.byte 111\n.byte 102\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 105\n.byte 102\n.byte 105\n.byte 99\n.byte 97\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 44\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 105\n.byte 116\n.byte 115\n.byte 101\n.byte 108\n.byte 102\n.byte 44\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 109\n.byte 105\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 102\n.byte 108\n.byte 97\n.byte 119\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L113:\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 101\n.byte 114\n.byte 105\n.byte 122\n.byte 101\n.byte 100\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 73\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 10\n.byte 0\n.align 1\n.L100:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 102\n.byte 117\n.byte 122\n.byte 122\n.byte 121\n.byte 44\n.byte 88\n.byte 61\n.byte 49\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 32\n.byte 88\n.byte 45\n.byte 49\n.byte 47\n.byte 50\n.byte 45\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 0\n.align 1\n.L96:\n.byte 40\n.byte 49\n.byte 45\n.byte 85\n.byte 49\n.byte 41\n.byte 45\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 60\n.byte 32\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 70\n.byte 65\n.byte 76\n.byte 83\n.byte 69\n.byte 44\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 46\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 115\n.byte 63\n.byte 0\n.align 8\n.L94:\n.word 0x40240000\n.word 0x0\n.align 1\n.L89:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 103\n.byte 111\n.byte 111\n.byte 100\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 50\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 49\n.byte 48\n.byte 0\n.align 1\n.L85:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 98\n.byte 105\n.byte 103\n.byte 58\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 111\n.byte 102\n.byte 102\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 98\n.byte 108\n.byte 101\n.byte 109\n.byte 115\n.byte 0\n.align 1\n.L83:\n.byte 77\n.byte 89\n.byte 83\n.byte 84\n.byte 69\n.byte 82\n.byte 89\n.byte 58\n.byte 32\n.byte 114\n.byte 101\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L82:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 105\n.byte 114\n.byte 109\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 8\n.L79:\n.word 0x3f847ae1\n.word 0x47ae147b\n.align 1\n.L78:\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 98\n.byte 101\n.byte 116\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 99\n.byte 108\n.byte 111\n.byte 115\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 114\n.byte 101\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 115\n.byte 101\n.byte 112\n.byte 97\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 85\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L77:\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 105\n.byte 114\n.byte 109\n.byte 115\n.byte 32\n.byte 99\n.byte 108\n.byte 111\n.byte 115\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 114\n.byte 101\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 115\n.byte 101\n.byte 112\n.byte 97\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 85\n.byte 49\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L62:\n.byte 82\n.byte 101\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 114\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 10\n.byte 32\n.byte 0\n.align 1\n.L61:\n.byte 67\n.byte 108\n.byte 111\n.byte 115\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 114\n.byte 101\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 115\n.byte 101\n.byte 112\n.byte 97\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 85\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 10\n.byte 0\n.align 1\n.L55:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 102\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L46:\n.byte 83\n.byte 101\n.byte 97\n.byte 114\n.byte 99\n.byte 104\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L45:\n.byte 10\n.byte 0\n.align 1\n.L44:\n.byte 45\n.byte 49\n.byte 44\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 49\n.byte 47\n.byte 50\n.byte 44\n.byte 32\n.byte 49\n.byte 44\n.byte 32\n.byte 50\n.byte 44\n.byte 32\n.byte 51\n.byte 44\n.byte 32\n.byte 52\n.byte 44\n.byte 32\n.byte 53\n.byte 44\n.byte 32\n.byte 57\n.byte 44\n.byte 32\n.byte 50\n.byte 55\n.byte 44\n.byte 32\n.byte 51\n.byte 50\n.byte 32\n.byte 38\n.byte 32\n.byte 50\n.byte 52\n.byte 48\n.byte 32\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 79\n.byte 46\n.byte 75\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.L39:\n.byte 53\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 52\n.byte 43\n.byte 49\n.byte 44\n.byte 32\n.byte 50\n.byte 52\n.byte 48\n.byte 47\n.byte 51\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 56\n.byte 48\n.byte 44\n.byte 32\n.byte 50\n.byte 52\n.byte 48\n.byte 47\n.byte 52\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 54\n.byte 48\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 50\n.byte 52\n.byte 48\n.byte 47\n.byte 53\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 52\n.byte 56\n.byte 0\n.align 1\n.L35:\n.byte 57\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 51\n.byte 42\n.byte 51\n.byte 44\n.byte 32\n.byte 50\n.byte 55\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 57\n.byte 42\n.byte 51\n.byte 44\n.byte 32\n.byte 51\n.byte 50\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 56\n.byte 42\n.byte 52\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 51\n.byte 50\n.byte 45\n.byte 50\n.byte 55\n.byte 45\n.byte 52\n.byte 45\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 0\n.align 1\n.L31:\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 43\n.byte 32\n.byte 40\n.byte 45\n.byte 49\n.byte 41\n.byte 32\n.byte 43\n.byte 32\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 0\n.align 1\n.L27:\n.byte 45\n.byte 49\n.byte 43\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 40\n.byte 45\n.byte 49\n.byte 41\n.byte 43\n.byte 97\n.byte 98\n.byte 115\n.byte 40\n.byte 49\n.byte 41\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 45\n.byte 49\n.byte 43\n.byte 40\n.byte 45\n.byte 49\n.byte 41\n.byte 42\n.byte 40\n.byte 45\n.byte 49\n.byte 41\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 0\n.align 1\n.L23:\n.byte 51\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 50\n.byte 43\n.byte 49\n.byte 44\n.byte 32\n.byte 52\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 51\n.byte 43\n.byte 49\n.byte 44\n.byte 32\n.byte 52\n.byte 43\n.byte 50\n.byte 42\n.byte 40\n.byte 45\n.byte 50\n.byte 41\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 52\n.byte 45\n.byte 51\n.byte 45\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 0\n.align 8\n.L21:\n.word 0x3f50624d\n.word 0xd2f1a9fc\n.align 1\n.L20:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 45\n.byte 48\n.byte 46\n.byte 48\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 78\n.byte 111\n.byte 110\n.byte 45\n.byte 122\n.byte 101\n.byte 114\n.byte 111\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.L15:\n.byte 48\n.byte 43\n.byte 48\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 49\n.byte 45\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 49\n.byte 32\n.byte 60\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 49\n.byte 43\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 50\n.byte 0\n.align 1\n.L13:\n.byte 80\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 119\n.byte 32\n.byte 82\n.byte 85\n.byte 78\n.byte 78\n.byte 73\n.byte 78\n.byte 71\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 110\n.byte 32\n.byte 115\n.byte 109\n.byte 97\n.byte 108\n.byte 108\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 115\n.byte 58\n.byte 10\n.byte 0\n.align 8\n.L9:\n.word 0x3ff00000\n.word 0x0\n.align 8\n.L8:\n.word 0x0\n.word 0x0\n.align 1\n.L3:\n.byte 10\n.byte 42\n.byte 32\n.byte 42\n.byte 32\n.byte 42\n.byte 32\n.byte 70\n.byte 76\n.byte 79\n.byte 65\n.byte 84\n.byte 73\n.byte 78\n.byte 71\n.byte 45\n.byte 80\n.byte 79\n.byte 73\n.byte 78\n.byte 84\n.byte 32\n.byte 69\n.byte 82\n.byte 82\n.byte 79\n.byte 82\n.byte 32\n.byte 42\n.byte 32\n.byte 42\n.byte 32\n.byte 42\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/sort.1bk",
    "content": "exchange(1,9)\nexchange(3,7)\nexchange(5,6)\nexchange(0,5)\nexchange(0,3)\nexchange(0,0)\nexchange(1,2)\nexchange(6,6)\nexchange(8,9)\nexchange(7,8)\n-51\n-1\n0\n1\n3\n10\n18\n32\n567\n789\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/sort.2bk",
    "content": "tst/sort.c:23: warning: missing return value\ntst/sort.c:30: warning: missing return value\ntst/sort.c:37: warning: missing return value\ntst/sort.c:41: warning: missing return value\ntst/sort.c:65: warning: missing return value\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/sort.sbk",
    "content": ".section \".data\"\n.global in\n.type in,#object\n.align 4\nin:\n.word 0xa\n.word 0x20\n.word 0xffffffff\n.word 0x237\n.word 0x3\n.word 0x12\n.word 0x1\n.word 0xffffffcd\n.word 0x315\n.word 0x0\n.size in,40\n.global main\n.section \".text\"\n.align 4\nmain:\nsave %sp,-96,%sp\nset in,%o0\nset 10,%o1\ncall sort; nop\nmov %g0,%i5\nba .L5; nop\n.L2:\nsll %i5,2,%i4\nset in,%i3\nld [%i4+%i3],%o0\ncall putd; nop\nset 10,%o0\ncall putchar; nop\n.L3:\nadd %i5,1,%i5\n.L5:\nmov %i5,%i4\nset 10,%i3\ncmp %i4,%i3; blu .L2; nop\nmov %g0,%i0\n.L1:\nret; restore\n.type main,#function\n.size main,.-main\n.global putd\n.align 4\nputd:\nsave %sp,-96,%sp\ncmp %i0,0; bge .L7; nop\nset 45,%o0\ncall putchar; nop\nneg %i0,%i0\n.L7:\nsra %i0,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %i0,10,%i5\ncmp %i5,0; be .L9; nop\nsra %i0,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %i0,10,%o0\ncall putd; nop\n.L9:\nsra %i0,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %i0,10,%g1\n; smul %g1,10,%g1; sub %i0,%g1,%i5\nadd %i5,48,%o0\ncall putchar; nop\nmov %g0,%i0\n.L6:\nret; restore\n.type putd,#function\n.size putd,.-putd\n.global sort\n.align 4\nsort:\nsave %sp,-96,%sp\nset xx,%i5\nst %i0,[%i5]\nmov %i0,%o0\nmov %g0,%o1\nsub %i1,1,%i5\nmov %i5,%i1\nmov %i5,%o2\ncall quick; nop\nmov %g0,%i0\n.L11:\nret; restore\n.type sort,#function\n.size sort,.-sort\n.global quick\n.align 4\nquick:\nsave %sp,-96,%sp\ncmp %i1,%i2; bl .L13; nop\nba .L12; nop\n.L13:\nmov %i0,%o0\nmov %i1,%o1\nmov %i2,%o2\ncall partition; nop\nmov %o0,%i5\nmov %i0,%o0\nmov %i1,%o1\nsub %i5,1,%o2\ncall quick; nop\nmov %i0,%o0\nadd %i5,1,%o1\nmov %i2,%o2\ncall quick; nop\nmov %g0,%i0\n.L12:\nret; restore\n.type quick,#function\n.size quick,.-quick\n.global partition\n.align 4\npartition:\nsave %sp,-96,%sp\nadd %i2,1,%i2\nmov %i1,%i4\nsll %i4,2,%i3\nld [%i3+%i0],%i5\nba .L17; nop\n.L16:\nadd %i1,1,%i1\nba .L20; nop\n.L19:\nadd %i1,1,%i1\n.L20:\nsll %i1,2,%i3\nld [%i3+%i0],%i3\ncmp %i3,%i5; bl .L19; nop\nsub %i2,1,%i2\nba .L23; nop\n.L22:\nsub %i2,1,%i2\n.L23:\nsll %i2,2,%i3\nld [%i3+%i0],%i3\ncmp %i3,%i5; bg .L22; nop\ncmp %i1,%i2; bge .L25; nop\nsll %i1,2,%i3\nadd %i3,%i0,%o0\nsll %i2,2,%i3\nadd %i3,%i0,%o1\ncall exchange; nop\n.L25:\n.L17:\ncmp %i1,%i2; bl .L16; nop\nsll %i4,2,%i3\nadd %i3,%i0,%o0\nsll %i2,2,%i3\nadd %i3,%i0,%o1\ncall exchange; nop\nmov %i2,%i0\n.L15:\nret; restore\n.type partition,#function\n.size partition,.-partition\n.global exchange\n.align 4\nexchange:\nsave %sp,-96,%sp\nset .L28,%o0\nset xx,%i4\nld [%i4],%i4\nmov %i0,%i3\nsub %i3,%i4,%i3\nsra %i3,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %i3,4,%o1\nmov %i1,%i3\nsub %i3,%i4,%i4\nsra %i4,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %i4,4,%o2\ncall printf; nop\nld [%i0],%i5\nld [%i1],%i4\nst %i4,[%i0]\nst %i5,[%i1]\nmov %g0,%i0\n.L27:\nret; restore\n.type exchange,#function\n.size exchange,.-exchange\n.section \".bss\"\n.global xx\n.type xx,#object\n.size xx,4\n.common xx,4,4\n.section \".rodata\"\n.align 1\n.L28:\n.byte 101\n.byte 120\n.byte 99\n.byte 104\n.byte 97\n.byte 110\n.byte 103\n.byte 101\n.byte 40\n.byte 37\n.byte 100\n.byte 44\n.byte 37\n.byte 100\n.byte 41\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/spill.1bk",
    "content": ""
  },
  {
    "path": "lcc/sparc/solaris/tst/spill.2bk",
    "content": "tst/spill.c:1: warning: missing return value\ntst/spill.c:3: warning: missing return value\ntst/spill.c:5: warning: missing return value\ntst/spill.c:7: warning: missing return value\ntst/spill.c:9: warning: missing return value\ntst/spill.c:17: warning: missing return value\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/spill.sbk",
    "content": ".global main\n.section \".text\"\n.align 4\nmain:\nmov %g0,%o0\n.L1:\nretl; nop\n.type main,#function\n.size main,.-main\n.global f\n.align 4\nf:\nsave %sp,-96,%sp\ncall f; nop\nmov %o0,%i5\ncall f; nop\nadd %i5,%o0,%i0\nmov %g0,%i0\n.L2:\nret; restore\n.type f,#function\n.size f,.-f\n.global f2\n.align 4\nf2:\nsave %sp,-96,%sp\ncall f; nop\nmov %o0,%i4\ncmp %i0,0; be .L5; nop\ncall f; nop\nmov %o0,%i3\nmov %i3,%i5\nba .L6; nop\n.L5:\nset 1,%i5\n.L6:\nadd %i4,%i5,%i0\nmov %g0,%i0\n.L3:\nret; restore\n.type f2,#function\n.size f2,.-f2\n.global f3\n.align 4\nf3:\nsave %sp,-104,%sp\nmov %g0,%i5\nmov %g0,%i4\nmov %g0,%i3\nmov %g0,%i2\nmov %g0,%l7\nmov %g0,%l6\nmov %g0,%l5\nmov %g0,%l4\nst %g0,[%fp+-4]\nst %g0,[%fp+-8]\nmov %i1,%l3\nadd %l3,4,%i1\ncmp %i0,0; be .L9; nop\ncall f; nop\nmov %o0,%l2\nst %l2,[%fp+-12]\nba .L10; nop\n.L9:\nst %g0,[%fp+-12]\n.L10:\nld [%fp+-12],%l2\nst %l2,[%l3]\nmov %g0,%i0\n.L7:\nret; restore\n.type f3,#function\n.size f3,.-f3\n.global f4\n.align 4\nf4:\nsave %sp,-96,%sp\nmov %g0,%i5\nmov %g0,%i4\nmov %g0,%i3\nmov %g0,%i2\nmov %g0,%i1\nmov %g0,%i0\nset i,%l6\nld [%l6],%l6\nsll %l6,3,%l5\nset a,%l4\nadd %l5,%l4,%l4\nld2 [%l4],%f30\nset b,%l4\nadd %l5,%l4,%l5\nld2 [%l5],%f28\nset .L15,%l5\nld2 [%l5],%f26\nfaddd %f30,%f28,%f24\nfcmped %f24,%f26; nop; fbue .L13; nop\ncmp %l6,0; be .L13; nop\nfsubd %f30,%f28,%f30\nfcmped %f30,%f26; nop; fbue .L13; nop\nset 1,%l7\nba .L14; nop\n.L13:\nmov %g0,%l7\n.L14:\nset i,%l6\nst %l7,[%l6]\nmov %g0,%i0\n.L11:\nret; restore\n.type f4,#function\n.size f4,.-f4\n.global f5\n.align 4\nf5:\nsave %sp,-96,%sp\nset x,%i5\nset k,%i4\nld [%i4],%i4\nset m,%i3\nld [%i3],%i3\nset A,%i2\nld [%i2],%i2\nsmul %i3,%i4,%i1\nsll %i1,3,%i1\nadd %i1,%i2,%i1\nset j,%i0\nld [%i0],%i0\nsmul %i3,%i0,%i3\nsll %i3,3,%i3\nadd %i3,%i2,%i3\nset n,%i2\nld [%i2],%i2\nset B,%l7\nld [%l7],%l7\nsmul %i2,%i4,%i4\nsll %i4,3,%i4\nadd %i4,%l7,%i4\nsmul %i2,%i0,%i2\nsll %i2,3,%i2\nadd %i2,%l7,%i2\nld2 [%i1],%f30\nld2 [%i3],%f28\nfmuld %f30,%f28,%f30\nld2 [%i4],%f28\nld2 [%i2],%f26\nfmuld %f28,%f26,%f28\nfaddd %f30,%f28,%f30\nst2 %f30,[%i5]\nld2 [%i1],%f30\nld2 [%i2],%f28\nfmuld %f30,%f28,%f30\nld2 [%i4],%f28\nld2 [%i3],%f26\nfmuld %f28,%f26,%f28\nfsubd %f30,%f28,%f30\nst2 %f30,[%i5]\nmov %g0,%i0\n.L16:\nret; restore\n.type f5,#function\n.size f5,.-f5\n.section \".bss\"\n.global x\n.type x,#object\n.size x,8\n.common x,8,8\n.global B\n.type B,#object\n.size B,4\n.common B,4,4\n.global A\n.type A,#object\n.size A,4\n.common A,4,4\n.global n\n.type n,#object\n.size n,4\n.common n,4,4\n.global m\n.type m,#object\n.size m,4\n.common m,4,4\n.global k\n.type k,#object\n.size k,4\n.common k,4,4\n.global j\n.type j,#object\n.size j,4\n.common j,4,4\n.global i\n.type i,#object\n.size i,4\n.common i,4,4\n.global b\n.type b,#object\n.size b,80\n.common b,80,8\n.global a\n.type a,#object\n.size a,80\n.common a,80,8\n.section \".rodata\"\n.align 8\n.L15:\n.word 0x0\n.word 0x0\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/stdarg.1bk",
    "content": "test 1\ntest 2\ntest 3\ntest 4\ntest 5.000000\n{1 2 3 4} {1 2 3 4} {1 2 3 4} {1 2 3 4} {1 2 3 4} {1 2 3 4}\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/stdarg.2bk",
    "content": "tst/stdarg.c:51: warning: missing return value\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/stdarg.sbk",
    "content": ".section \".data\"\n.global x\n.type x,#object\n.size x,16\n.align 4\nx:\n.word 0x1\n.word 0x2\n.word 0x3\n.word 0x4\n.global main\n.section \".text\"\n.align 4\nmain:\nsave %sp,-192,%sp\nset .L2,%o0\ncall print; nop\nset .L3,%o0\nset .L4,%o1\ncall print; nop\nset .L5,%o0\nset 3,%o1\nset 10,%o2\ncall print; nop\nset .L6,%o0\nset .L7,%o1\nset .L8,%o2\nset 4,%o3\nset 10,%o4\ncall print; nop\nset .L9,%o0\nset .L7,%o1\nset .L8,%o2\nset .L10,%i5\nld2 [%i5],%f30\nst %f30,[%sp+4*3+68]\nst %f31,[%sp+4*4+68]\nld [%sp+4*3+68],%o3\nld [%sp+4*4+68],%o4\nset 10,%o5\ncall print; nop\nset .L11,%o0\nset x,%i5\nadd -16,%fp,%i4\nld [%r29+0],%r1\nld [%r29+4],%r2\nst %r1,[%r28+0]\nst %r2,[%r28+4]\nld [%r29+8],%r1\nld [%r29+12],%r2\nst %r1,[%r28+8]\nst %r2,[%r28+12]\nadd -16,%fp,%o1\nadd -32,%fp,%i4\nld [%r29+0],%r1\nld [%r29+4],%r2\nst %r1,[%r28+0]\nst %r2,[%r28+4]\nld [%r29+8],%r1\nld [%r29+12],%r2\nst %r1,[%r28+8]\nst %r2,[%r28+12]\nadd -32,%fp,%o2\nadd -48,%fp,%i4\nld [%r29+0],%r1\nld [%r29+4],%r2\nst %r1,[%r28+0]\nst %r2,[%r28+4]\nld [%r29+8],%r1\nld [%r29+12],%r2\nst %r1,[%r28+8]\nst %r2,[%r28+12]\nadd -48,%fp,%o3\nadd -64,%fp,%i4\nld [%r29+0],%r1\nld [%r29+4],%r2\nst %r1,[%r28+0]\nst %r2,[%r28+4]\nld [%r29+8],%r1\nld [%r29+12],%r2\nst %r1,[%r28+8]\nst %r2,[%r28+12]\nadd -64,%fp,%o4\nadd -80,%fp,%i4\nld [%r29+0],%r1\nld [%r29+4],%r2\nst %r1,[%r28+0]\nst %r2,[%r28+4]\nld [%r29+8],%r1\nld [%r29+12],%r2\nst %r1,[%r28+8]\nst %r2,[%r28+12]\nadd -80,%fp,%o5\nadd -96,%fp,%i4\nld [%r29+0],%r1\nld [%r29+4],%r2\nst %r1,[%r28+0]\nst %r2,[%r28+4]\nld [%r29+8],%r1\nld [%r29+12],%r2\nst %r1,[%r28+8]\nst %r2,[%r28+12]\nadd -96,%fp,%i5\nst %i5,[%sp+4*6+68]\ncall print; nop\nmov %g0,%i0\n.L1:\nret; restore\n.type main,#function\n.size main,.-main\n.global print\n.align 4\nprint:\nsave %sp,-112,%sp\nst %i1,[%fp+72]\nst %i2,[%fp+76]\nst %i3,[%fp+80]\nst %i4,[%fp+84]\nst %i5,[%fp+88]\nst %i0,[%fp+68]\nadd 72,%fp,%i5\nba .L18; nop\n.L15:\nld [%fp+68],%i4\nldsb [%i4],%i4\ncmp %i4,37; bne .L19; nop\nld [%fp+68],%i3\nadd %i3,1,%i3\nst %i3,[%fp+68]\nldsb [%i3],%i4\ncmp %i4,115; be .L35; nop\ncmp %i4,115; bg .L40; nop\n.L39:\ncmp %i4,98; bl .L21; nop\ncmp %i4,102; bg .L21; nop\nsll %i4,2,%i3\nset .L41-392,%i2\nld [%i3+%i2],%i3\njmp %i3; nop\n.section \".rodata\"\n.align 4\n.L41:\n.word .L24\n.word .L29\n.word .L31\n.word .L21\n.word .L37\n.section \".text\"\n.L40:\ncmp %i4,119; be .L33; nop\nba .L21; nop\n.L24:\nadd %i5,4,%i3\nmov %i3,%i5\nadd -16,%fp,%i2\nld [%i3+-4],%i3\nld [%r27+0],%r1\nld [%r27+4],%r2\nst %r1,[%r26+0]\nst %r2,[%r26+4]\nld [%r27+8],%r1\nld [%r27+12],%r2\nst %r1,[%r26+8]\nst %r2,[%r26+12]\nset .L25,%o0\nld [%fp+-16],%o1\nld [%fp+-12],%o2\nld [%fp+-8],%o3\nld [%fp+-4],%o4\ncall printf; nop\nba .L20; nop\n.L29:\nset .L30,%o0\nadd %i5,4,%i3\nmov %i3,%i5\nldsb [%i3+-1],%o1\ncall printf; nop\nba .L20; nop\n.L31:\nset .L32,%o0\nset 4,%i3\nadd %i5,%i3,%i3\nmov %i3,%i5\nld [%i3+-4],%o1\ncall printf; nop\nba .L20; nop\n.L33:\nset .L34,%o0\nadd %i5,4,%i3\nmov %i3,%i5\nldsh [%i3+-2],%o1\ncall printf; nop\nba .L20; nop\n.L35:\nset .L36,%o0\nset 4,%i3\nadd %i5,%i3,%i3\nmov %i3,%i5\nld [%i3+-4],%o1\ncall printf; nop\nba .L20; nop\n.L37:\nset .L38,%o0\nset 8,%i3\nadd %i5,%i3,%i3\nmov %i3,%i5\nld2 [%i3+-8],%f30\nst %f30,[%sp+4*1+68]\nst %f31,[%sp+4*2+68]\nld [%sp+4*1+68],%o1\nld [%sp+4*2+68],%o2\ncall printf; nop\nba .L20; nop\n.L21:\nset .L30,%o0\nld [%fp+68],%i3\nldsb [%i3],%o1\ncall printf; nop\nba .L20; nop\n.L19:\nset .L30,%o0\nld [%fp+68],%i3\nldsb [%i3],%o1\ncall printf; nop\n.L20:\n.L16:\nld [%fp+68],%i3\nadd %i3,1,%i3\nst %i3,[%fp+68]\n.L18:\nld [%fp+68],%i3\nldsb [%i3],%i3\ncmp %i3,0; bne .L15; nop\nmov %g0,%i0\n.L12:\nret; restore\n.type print,#function\n.size print,.-print\n.section \".rodata\"\n.align 1\n.L38:\n.byte 37\n.byte 102\n.byte 0\n.align 1\n.L36:\n.byte 37\n.byte 115\n.byte 0\n.align 1\n.L34:\n.byte 37\n.byte 120\n.byte 0\n.align 1\n.L32:\n.byte 37\n.byte 100\n.byte 0\n.align 1\n.L30:\n.byte 37\n.byte 99\n.byte 0\n.align 1\n.L25:\n.byte 123\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 125\n.byte 0\n.align 1\n.L11:\n.byte 37\n.byte 98\n.byte 32\n.byte 37\n.byte 98\n.byte 32\n.byte 37\n.byte 98\n.byte 32\n.byte 37\n.byte 98\n.byte 32\n.byte 37\n.byte 98\n.byte 32\n.byte 37\n.byte 98\n.byte 10\n.byte 0\n.align 8\n.L10:\n.word 0x40140000\n.word 0x0\n.align 1\n.L9:\n.byte 37\n.byte 115\n.byte 37\n.byte 115\n.byte 32\n.byte 37\n.byte 102\n.byte 37\n.byte 99\n.byte 0\n.align 1\n.L8:\n.byte 115\n.byte 116\n.byte 0\n.align 1\n.L7:\n.byte 116\n.byte 101\n.byte 0\n.align 1\n.L6:\n.byte 37\n.byte 115\n.byte 37\n.byte 115\n.byte 32\n.byte 37\n.byte 119\n.byte 37\n.byte 99\n.byte 0\n.align 1\n.L5:\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 37\n.byte 100\n.byte 37\n.byte 99\n.byte 0\n.align 1\n.L4:\n.byte 50\n.byte 0\n.align 1\n.L3:\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.L2:\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 49\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/struct.1bk",
    "content": "(-1,-1) is not within [10,10; 310,310]\n(1,1) is not within [10,10; 310,310]\n(20,300) is within [10,10; 310,310]\n(500,400) is not within [10,10; 310,310]\nab\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/struct.2bk",
    "content": "tst/struct.c:49: warning: missing return value\ntst/struct.c:68: warning: missing return value\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/struct.sbk",
    "content": ".global addpoint\n.section \".text\"\n.align 4\naddpoint:\nsave %sp,-96,%sp\nld [%i0],%i5\nld [%i1],%i4\nadd %i5,%i4,%i5\nst %i5,[%i0]\nadd %i0,4,%i5\nld [%i5],%i4\nld [%i1+4],%i3\nadd %i4,%i3,%i4\nst %i4,[%i5]\nld [%fp+64],%i5\nld [%r24+0],%r1\nld [%r24+4],%r2\nst %r1,[%r29+0]\nst %r2,[%r29+4]\n.L1:\njmp %i7+12; restore\n.type addpoint,#function\n.size addpoint,.-addpoint\n.global canonrect\n.align 4\ncanonrect:\nsave %sp,-112,%sp\nld [%i0],%i3\nld [%i0+8],%i2\ncmp %i3,%i2; bge .L6; nop\nld [%i0],%i5\nba .L7; nop\n.L6:\nld [%i0+8],%i5\n.L7:\nst %i5,[%fp+-16]\nld [%i0+4],%i3\nld [%i0+12],%i2\ncmp %i3,%i2; bge .L10; nop\nld [%i0+4],%i4\nba .L11; nop\n.L10:\nld [%i0+12],%i4\n.L11:\nst %i4,[%fp+-12]\nld [%i0],%i2\nld [%i0+8],%i1\ncmp %i2,%i1; ble .L14; nop\nld [%i0],%i3\nba .L15; nop\n.L14:\nld [%i0+8],%i3\n.L15:\nst %i3,[%fp+-8]\nld [%i0+4],%i1\nld [%i0+12],%l7\ncmp %i1,%l7; ble .L19; nop\nld [%i0+4],%i2\nba .L20; nop\n.L19:\nld [%i0+12],%i2\n.L20:\nst %i2,[%fp+-4]\nld [%fp+64],%i1\nadd -16,%fp,%l7\nld [%r23+0],%r1\nld [%r23+4],%r2\nst %r1,[%r25+0]\nst %r2,[%r25+4]\nld [%r23+8],%r1\nld [%r23+12],%r2\nst %r1,[%r25+8]\nst %r2,[%r25+12]\n.L3:\njmp %i7+12; restore\n.type canonrect,#function\n.size canonrect,.-canonrect\n.global makepoint\n.align 4\nmakepoint:\nsave %sp,-104,%sp\nst %i0,[%fp+-8]\nst %i1,[%fp+-4]\nld [%fp+64],%i5\nadd -8,%fp,%i4\nld [%r28+0],%r1\nld [%r28+4],%r2\nst %r1,[%r29+0]\nst %r2,[%r29+4]\n.L21:\njmp %i7+12; restore\n.type makepoint,#function\n.size makepoint,.-makepoint\n.global makerect\n.align 4\nmakerect:\nsave %sp,-128,%sp\nadd -16,%fp,%i5\nld [%r24+0],%r1\nld [%r24+4],%r2\nst %r1,[%r29+0]\nst %r2,[%r29+4]\nadd -8,%fp,%i5\nld [%r25+0],%r1\nld [%r25+4],%r2\nst %r1,[%r29+0]\nst %r2,[%r29+4]\nadd -32,%fp,%i5\nadd -16,%fp,%i4\nld [%r28+0],%r1\nld [%r28+4],%r2\nst %r1,[%r29+0]\nst %r2,[%r29+4]\nld [%r28+8],%r1\nld [%r28+12],%r2\nst %r1,[%r29+8]\nst %r2,[%r29+12]\nadd -32,%fp,%o0\nld [%fp+64],%i5\ncall canonrect; st %i5,[%sp+64]; unimp 16&0xfff\n.L24:\njmp %i7+12; restore\n.type makerect,#function\n.size makerect,.-makerect\n.global ptinrect\n.align 4\nptinrect:\nld [%o0],%o4\nld [%o1],%o3\ncmp %o4,%o3; bl .L29; nop\nld [%o1+8],%o3\ncmp %o4,%o3; bge .L29; nop\nld [%o0+4],%o4\nld [%o1+4],%o3\ncmp %o4,%o3; bl .L29; nop\nld [%o1+12],%o3\ncmp %o4,%o3; bge .L29; nop\nset 1,%o5\nba .L30; nop\n.L29:\nmov %g0,%o5\n.L30:\nmov %o5,%o0\n.L27:\nretl; nop\n.type ptinrect,#function\n.size ptinrect,.-ptinrect\n.section \".data\"\n.global y\n.type y,#object\n.size y,3\n.align 1\ny:\n.byte 97\n.byte 98\n.byte 0\n.global odd\n.section \".text\"\n.align 4\nodd:\nsave %sp,-96,%sp\nadd -3,%fp,%i5\nldub [%r24+0],%r1\nldub [%r24+1],%r2\nstb %r1,[%r29+0]\nstb %r2,[%r29+1]\nldub [%r24+2],%r1\nstb %r1,[%r29+2]\nset .L32,%o0\nadd -3,%fp,%o1\ncall printf; nop\nmov %g0,%i0\n.L31:\nret; restore\n.type odd,#function\n.size odd,.-odd\n.section \".rodata\"\n.align 4\n.L34:\n.word 0x0\n.word 0x0\n.align 4\n.L35:\n.word 0x140\n.word 0x140\n.align 4\n.L36:\n.word 0xffffffff\n.word 0xffffffff\n.word 0x1\n.word 0x1\n.word 0x14\n.word 0x12c\n.word 0x1f4\n.word 0x190\n.global main\n.section \".text\"\n.align 4\nmain:\nsave %sp,-240,%sp\nadd -64,%fp,%i4\nset .L34,%i3\nld [%r27+0],%r1\nld [%r27+4],%r2\nst %r1,[%r28+0]\nst %r2,[%r28+4]\nadd -72,%fp,%i4\nset .L35,%i3\nld [%r27+0],%r1\nld [%r27+4],%r2\nst %r1,[%r28+0]\nst %r2,[%r28+4]\nadd -32,%fp,%i4\nset .L36,%i3\nadd %r27,32,%r27\nadd %r28,32,%r3\n1: dec 8,%r3\nld [%r27+-8],%r1\nld [%r27+-4],%r2\nst %r1,[%r3+0]\nst %r2,[%r3+4]\ncmp %r3,%r28; bgt 1b; dec 8,%r27\nset -10,%i4\nmov %i4,%o0\nmov %i4,%o1\nadd -80,%fp,%i4\ncall makepoint; st %i4,[%sp+64]; unimp 8&0xfff\nadd -88,%fp,%i4\nadd -72,%fp,%i3\nld [%r27+0],%r1\nld [%r27+4],%r2\nst %r1,[%r28+0]\nst %r2,[%r28+4]\nadd -88,%fp,%o0\nadd -80,%fp,%o1\nadd -96,%fp,%i4\ncall addpoint; st %i4,[%sp+64]; unimp 8&0xfff\nset 10,%i4\nmov %i4,%o0\nmov %i4,%o1\nadd -104,%fp,%i4\ncall makepoint; st %i4,[%sp+64]; unimp 8&0xfff\nadd -112,%fp,%i4\nadd -64,%fp,%i3\nld [%r27+0],%r1\nld [%r27+4],%r2\nst %r1,[%r28+0]\nst %r2,[%r28+4]\nadd -112,%fp,%o0\nadd -104,%fp,%o1\nadd -120,%fp,%i4\ncall addpoint; st %i4,[%sp+64]; unimp 8&0xfff\nadd -96,%fp,%o0\nadd -120,%fp,%o1\nadd -48,%fp,%i4\ncall makerect; st %i4,[%sp+64]; unimp 16&0xfff\nmov %g0,%i5\nba .L40; nop\n.L37:\nsll %i5,3,%i4\nadd -32,%fp,%i3\nld [%i4+%i3],%o0\nadd -28,%fp,%i3\nld [%i4+%i3],%o1\nadd -56,%fp,%i4\ncall makepoint; st %i4,[%sp+64]; unimp 8&0xfff\nset .L41,%o0\nsll %i5,3,%i4\nadd -32,%fp,%i3\nld [%i4+%i3],%o1\nld [%fp+-52],%o2\ncall printf; nop\nadd -128,%fp,%i4\nadd -56,%fp,%i3\nld [%r27+0],%r1\nld [%r27+4],%r2\nst %r1,[%r28+0]\nst %r2,[%r28+4]\nadd -128,%fp,%o0\nadd -144,%fp,%i4\nadd -48,%fp,%i3\nld [%r27+0],%r1\nld [%r27+4],%r2\nst %r1,[%r28+0]\nst %r2,[%r28+4]\nld [%r27+8],%r1\nld [%r27+12],%r2\nst %r1,[%r28+8]\nst %r2,[%r28+12]\nadd -144,%fp,%o1\ncall ptinrect; nop\ncmp %o0,0; bne .L44; nop\nset .L46,%o0\ncall printf; nop\n.L44:\nset .L47,%o0\nld [%fp+-48],%o1\nld [%fp+-44],%o2\nld [%fp+-40],%o3\nld [%fp+-36],%o4\ncall printf; nop\n.L38:\nadd %i5,1,%i5\n.L40:\nmov %i5,%i4\nset 4,%i3\ncmp %i4,%i3; blu .L37; nop\nadd -123,%fp,%i4\nset y,%i3\nldub [%r27+0],%r1\nldub [%r27+1],%r2\nstb %r1,[%r28+0]\nstb %r2,[%r28+1]\nldub [%r27+2],%r1\nstb %r1,[%r28+2]\nadd -123,%fp,%o0\ncall odd; nop\nmov %g0,%o0\ncall exit; nop\nmov %g0,%i0\n.L33:\nret; restore\n.type main,#function\n.size main,.-main\n.section \".rodata\"\n.align 1\n.L47:\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 105\n.byte 110\n.byte 32\n.byte 91\n.byte 37\n.byte 100\n.byte 44\n.byte 37\n.byte 100\n.byte 59\n.byte 32\n.byte 37\n.byte 100\n.byte 44\n.byte 37\n.byte 100\n.byte 93\n.byte 10\n.byte 0\n.align 1\n.L46:\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 0\n.align 1\n.L41:\n.byte 40\n.byte 37\n.byte 100\n.byte 44\n.byte 37\n.byte 100\n.byte 41\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 0\n.align 1\n.L32:\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/switch.1bk",
    "content": "b = 0x8\nf = 0xc\nn = 0xa\nr = 0xd\nt = 0x9\nv = 0xb\nx = 0x78\nf:\nx = 0\nx = 1\nx = 2\nx = 2\nx = 2\nx = 2\nx = 2\nx = 7\nx = 8\nx = 9\nx = 9\nx = 9\nx = 9\nx = 9\nx = 9\nx = 9\nx = 16\nx = 17\nx = 18\nx = 19\nx = 20\ng:\n1 1\n1 2\n2 3\n2 4\n2 5\n3 6\nd 6\n3 7\nd 7\n3 8\nd 8\nd 9\nd 10\nh:\ni = 8\ni = 16\ni = 120\ni = 128\ni = 248\ni = 264\ni = 272\ni = 280\ni = 288\ni = 296\ni = 304\ni = 312\n488 defaults\nx = 0x1000000\nx = 0x2000000\nx = 0x3000000\nx = 0x4000000\nx = 0x5000000\nx = 0x6000000 (default)\nx = 0x7000000 (default)\n0\n1\n2\n3\n4\n5\n0\n1\n2\n3\n4\n5\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/switch.2bk",
    "content": "tst/switch.c:55: warning: missing return value\ntst/switch.c:73: warning: missing return value\ntst/switch.c:97: warning: missing return value\ntst/switch.c:112: warning: missing return value\ntst/switch.c:137: warning: missing return value\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/switch.sbk",
    "content": ".global main\n.section \".text\"\n.align 4\nmain:\nsave %sp,-96,%sp\nset .L6,%i5\nba .L5; nop\n.L2:\nldsb [%i5],%o0\ncall backslash; nop\nmov %o0,%i3\nset .L7,%o0\nldsb [%i5],%o1\nmov %i3,%o2\ncall printf; nop\n.L3:\nadd %i5,1,%i5\n.L5:\nldsb [%i5],%i3\ncmp %i3,0; bne .L2; nop\ncall f; nop\ncall g; nop\ncall h; nop\nset 16777216,%i4\nba .L11; nop\n.L8:\nmov %i4,%o0\ncall big; nop\n.L9:\nset 16777216,%i3\nadd %i4,%i3,%i4\n.L11:\nset 117440512,%i3\nand %i4,%i3,%i3\ncmp %i3,0; bne .L8; nop\ncall limit; nop\nmov %g0,%i0\n.L1:\nret; restore\n.type main,#function\n.size main,.-main\n.global backslash\n.align 4\nbackslash:\ncmp %o0,102; be .L16; nop\ncmp %o0,102; bg .L22; nop\n.L21:\ncmp %o0,98; be .L15; nop\nba .L13; nop\n.L22:\ncmp %o0,110; be .L17; nop\ncmp %o0,110; bl .L13; nop\n.L23:\ncmp %o0,114; be .L18; nop\ncmp %o0,116; be .L19; nop\ncmp %o0,118; be .L20; nop\nba .L13; nop\n.L15:\nset 8,%o0\nba .L12; nop\n.L16:\nset 12,%o0\nba .L12; nop\n.L17:\nset 10,%o0\nba .L12; nop\n.L18:\nset 13,%o0\nba .L12; nop\n.L19:\nset 9,%o0\nba .L12; nop\n.L20:\nset 11,%o0\nba .L12; nop\n.L13:\n.L12:\nretl; nop\n.type backslash,#function\n.size backslash,.-backslash\n.global f\n.align 4\nf:\nsave %sp,-96,%sp\nmov %g0,%i4\nset .L25,%o0\ncall printf; nop\nmov %g0,%i5\n.L26:\nmov %i5,%i3\ncmp %i5,1; bl .L30; nop\ncmp %i5,20; bg .L30; nop\nsll %i5,2,%i2\nset .L42-4,%i1\nld [%i2+%i1],%i2\njmp %i2; nop\n.section \".rodata\"\n.align 4\n.L42:\n.word .L32\n.word .L33\n.word .L30\n.word .L30\n.word .L30\n.word .L30\n.word .L34\n.word .L35\n.word .L36\n.word .L30\n.word .L30\n.word .L30\n.word .L30\n.word .L30\n.word .L30\n.word .L37\n.word .L38\n.word .L39\n.word .L40\n.word .L41\n.section \".text\"\n.L32:\nmov %i5,%i4\nba .L31; nop\n.L33:\nmov %i5,%i4\nba .L31; nop\n.L34:\nmov %i5,%i4\nba .L31; nop\n.L35:\nmov %i5,%i4\nba .L31; nop\n.L36:\nmov %i5,%i4\nba .L31; nop\n.L37:\nmov %i5,%i4\nba .L31; nop\n.L38:\nmov %i5,%i4\nba .L31; nop\n.L39:\nmov %i5,%i4\nba .L31; nop\n.L40:\nmov %i5,%i4\nba .L31; nop\n.L41:\nmov %i5,%i4\n.L30:\n.L31:\nset .L44,%o0\nmov %i4,%o1\ncall printf; nop\n.L27:\nadd %i5,1,%i5\ncmp %i5,20; ble .L26; nop\nmov %g0,%i0\n.L24:\nret; restore\n.type f,#function\n.size f,.-f\n.global g\n.align 4\ng:\nsave %sp,-96,%sp\nset .L46,%o0\ncall printf; nop\nset 1,%i5\n.L47:\ncmp %i5,1001; bl .L64; nop\ncmp %i5,1004; bg .L65; nop\nsll %i5,2,%i4\nset .L66-4004,%i3\nld [%i4+%i3],%i4\njmp %i4; nop\n.section \".rodata\"\n.align 4\n.L66:\n.word .L60\n.word .L60\n.word .L60\n.word .L60\n.section \".text\"\n.L64:\ncmp %i5,1; bl .L51; nop\ncmp %i5,8; bg .L51; nop\nsll %i5,2,%i4\nset .L68-4,%i3\nld [%i4+%i3],%i4\njmp %i4; nop\n.section \".rodata\"\n.align 4\n.L68:\n.word .L53\n.word .L53\n.word .L55\n.word .L55\n.word .L55\n.word .L57\n.word .L57\n.word .L57\n.section \".text\"\n.L65:\ncmp %i5,3001; bl .L51; nop\ncmp %i5,3004; bg .L51; nop\nsll %i5,2,%i4\nset .L70-12004,%i3\nld [%i4+%i3],%i4\njmp %i4; nop\n.section \".rodata\"\n.align 4\n.L70:\n.word .L62\n.word .L62\n.word .L62\n.word .L62\n.section \".text\"\n.L53:\nset .L54,%o0\nmov %i5,%o1\ncall printf; nop\nba .L52; nop\n.L55:\nset .L56,%o0\nmov %i5,%o1\ncall printf; nop\nba .L52; nop\n.L57:\nset .L58,%o0\nmov %i5,%o1\ncall printf; nop\n.L51:\nset .L59,%o0\nmov %i5,%o1\ncall printf; nop\nba .L52; nop\n.L60:\nset .L61,%o0\nmov %i5,%o1\ncall printf; nop\nba .L52; nop\n.L62:\nset .L63,%o0\nmov %i5,%o1\ncall printf; nop\n.L52:\n.L48:\nadd %i5,1,%i5\ncmp %i5,10; ble .L47; nop\nmov %g0,%i0\n.L45:\nret; restore\n.type g,#function\n.size g,.-g\n.global h\n.align 4\nh:\nsave %sp,-96,%sp\nmov %g0,%i4\nset .L73,%o0\ncall printf; nop\nset 1,%i5\n.L74:\ncmp %i5,264; be .L86; nop\ncmp %i5,264; bg .L94; nop\n.L93:\ncmp %i5,120; be .L84; nop\ncmp %i5,120; bg .L96; nop\n.L95:\ncmp %i5,8; be .L83; nop\ncmp %i5,8; bl .L78; nop\n.L97:\ncmp %i5,16; be .L82; nop\nba .L78; nop\n.L96:\ncmp %i5,128; be .L80; nop\ncmp %i5,128; bl .L78; nop\n.L98:\ncmp %i5,248; be .L87; nop\nba .L78; nop\n.L94:\ncmp %i5,288; be .L91; nop\ncmp %i5,288; bg .L100; nop\n.L99:\ncmp %i5,272; be .L88; nop\ncmp %i5,272; bl .L78; nop\n.L101:\ncmp %i5,280; be .L85; nop\nba .L78; nop\n.L100:\ncmp %i5,304; be .L89; nop\ncmp %i5,304; bg .L103; nop\n.L102:\ncmp %i5,296; be .L90; nop\nba .L78; nop\n.L103:\ncmp %i5,312; be .L92; nop\nba .L78; nop\n.L78:\nadd %i4,1,%i4\nba .L75; nop\n.L80:\nset .L81,%o0\nmov %i5,%o1\ncall printf; nop\nba .L79; nop\n.L82:\nset .L81,%o0\nmov %i5,%o1\ncall printf; nop\nba .L79; nop\n.L83:\nset .L81,%o0\nmov %i5,%o1\ncall printf; nop\nba .L79; nop\n.L84:\nset .L81,%o0\nmov %i5,%o1\ncall printf; nop\nba .L79; nop\n.L85:\nset .L81,%o0\nmov %i5,%o1\ncall printf; nop\nba .L79; nop\n.L86:\nset .L81,%o0\nmov %i5,%o1\ncall printf; nop\nba .L79; nop\n.L87:\nset .L81,%o0\nmov %i5,%o1\ncall printf; nop\nba .L79; nop\n.L88:\nset .L81,%o0\nmov %i5,%o1\ncall printf; nop\nba .L79; nop\n.L89:\nset .L81,%o0\nmov %i5,%o1\ncall printf; nop\nba .L79; nop\n.L90:\nset .L81,%o0\nmov %i5,%o1\ncall printf; nop\nba .L79; nop\n.L91:\nset .L81,%o0\nmov %i5,%o1\ncall printf; nop\nba .L79; nop\n.L92:\nset .L81,%o0\nmov %i5,%o1\ncall printf; nop\n.L79:\n.L75:\nadd %i5,1,%i5\ncmp %i5,500; ble .L74; nop\nset .L104,%o0\nmov %i4,%o1\ncall printf; nop\nmov %g0,%i0\n.L72:\nret; restore\n.type h,#function\n.size h,.-h\n.global big\n.align 4\nbig:\nsave %sp,-96,%sp\nset 0x6000000,%i4\nand %i0,%i4,%i5\nset 33554432,%i3\ncmp %i5,%i3; be .L111; nop\ncmp %i5,%i3; bg .L115; nop\n.L114:\ncmp %i5,-2; be .L109; nop\ncmp %i5,-1; be .L109; nop\ncmp %i5,0; be .L109; nop\nba .L106; nop\n.L115:\nmov %i5,%i4\nset 67108864,%i3\ncmp %i4,%i3; be .L112; nop\nba .L106; nop\n.L109:\nset .L110,%o0\nmov %i0,%o1\ncall printf; nop\nba .L107; nop\n.L111:\nset .L110,%o0\nmov %i0,%o1\ncall printf; nop\nba .L107; nop\n.L112:\nset .L110,%o0\nmov %i0,%o1\ncall printf; nop\nba .L107; nop\n.L106:\nset .L113,%o0\nmov %i0,%o1\ncall printf; nop\n.L107:\nmov %g0,%i0\n.L105:\nret; restore\n.type big,#function\n.size big,.-big\n.global limit\n.align 4\nlimit:\nsave %sp,-96,%sp\nset -2147483648,%i5\n.L117:\nset -2147483648,%i4\ncmp %i5,%i4; bl .L121; nop\nset -2147483644,%i3\ncmp %i5,%i3; bg .L121; nop\nsll %i5,2,%i3\nsll %i4,2,%i4\nsub %i3,%i4,%i4\nset .L134,%i3\nld [%i4+%i3],%i4\njmp %i4; nop\n.section \".rodata\"\n.align 4\n.L134:\n.word .L123\n.word .L125\n.word .L127\n.word .L129\n.word .L131\n.section \".text\"\n.L123:\nset .L124,%o0\ncall printf; nop\nba .L122; nop\n.L125:\nset .L126,%o0\ncall printf; nop\nba .L122; nop\n.L127:\nset .L128,%o0\ncall printf; nop\nba .L122; nop\n.L129:\nset .L130,%o0\ncall printf; nop\nba .L122; nop\n.L131:\nset .L132,%o0\ncall printf; nop\nba .L122; nop\n.L121:\nset .L133,%o0\ncall printf; nop\n.L122:\n.L118:\nadd %i5,1,%i5\nset -2147483643,%i4\ncmp %i5,%i4; ble .L117; nop\nset 2147483647,%i5\n.L135:\nset 2147483643,%i4\ncmp %i5,%i4; bl .L139; nop\nset 2147483647,%i3\ncmp %i5,%i3; bg .L139; nop\nsll %i5,2,%i3\nsll %i4,2,%i4\nsub %i3,%i4,%i4\nset .L146,%i3\nld [%i4+%i3],%i4\njmp %i4; nop\n.section \".rodata\"\n.align 4\n.L146:\n.word .L145\n.word .L144\n.word .L143\n.word .L142\n.word .L141\n.section \".text\"\n.L141:\nset .L124,%o0\ncall printf; nop\nba .L140; nop\n.L142:\nset .L126,%o0\ncall printf; nop\nba .L140; nop\n.L143:\nset .L128,%o0\ncall printf; nop\nba .L140; nop\n.L144:\nset .L130,%o0\ncall printf; nop\nba .L140; nop\n.L145:\nset .L132,%o0\ncall printf; nop\nba .L140; nop\n.L139:\nset .L133,%o0\ncall printf; nop\n.L140:\n.L136:\nsub %i5,1,%i5\nset 2147483642,%i4\ncmp %i5,%i4; bge .L135; nop\nmov %g0,%i0\n.L116:\nret; restore\n.type limit,#function\n.size limit,.-limit\n.section \".rodata\"\n.align 1\n.L133:\n.byte 53\n.byte 10\n.byte 0\n.align 1\n.L132:\n.byte 52\n.byte 10\n.byte 0\n.align 1\n.L130:\n.byte 51\n.byte 10\n.byte 0\n.align 1\n.L128:\n.byte 50\n.byte 10\n.byte 0\n.align 1\n.L126:\n.byte 49\n.byte 10\n.byte 0\n.align 1\n.L124:\n.byte 48\n.byte 10\n.byte 0\n.align 1\n.L113:\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 120\n.byte 37\n.byte 120\n.byte 32\n.byte 40\n.byte 100\n.byte 101\n.byte 102\n.byte 97\n.byte 117\n.byte 108\n.byte 116\n.byte 41\n.byte 10\n.byte 0\n.align 1\n.L110:\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 120\n.byte 37\n.byte 120\n.byte 10\n.byte 0\n.align 1\n.L104:\n.byte 37\n.byte 100\n.byte 32\n.byte 100\n.byte 101\n.byte 102\n.byte 97\n.byte 117\n.byte 108\n.byte 116\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.L81:\n.byte 105\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L73:\n.byte 104\n.byte 58\n.byte 10\n.byte 0\n.align 1\n.L63:\n.byte 54\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L61:\n.byte 53\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L59:\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L58:\n.byte 51\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L56:\n.byte 50\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L54:\n.byte 49\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L46:\n.byte 103\n.byte 58\n.byte 10\n.byte 0\n.align 1\n.L44:\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L25:\n.byte 102\n.byte 58\n.byte 10\n.byte 0\n.align 1\n.L7:\n.byte 37\n.byte 99\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 120\n.byte 37\n.byte 120\n.byte 10\n.byte 0\n.align 1\n.L6:\n.byte 98\n.byte 102\n.byte 110\n.byte 114\n.byte 116\n.byte 118\n.byte 120\n.byte 0\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/wf1.1bk",
    "content": "5\ta\n2\tand\n5\tbuf\n16\tc\n8\tchar\n1\tcompare\n4\tcond\n5\tcount\n1\td\n1\tdie\n3\telse\n1\tentry\n1\teof\n4\terr\n1\terror\n1\texit\n1\tfolded\n1\tfor\n1\tfree\n1\tfrequencies\n1\tfrequency\n1\tget\n2\tgetchar\n3\tgetword\n14\tif\n2\tin\n1\tindex\n1\tinput\n1\tinstall\n8\tint\n1\tinto\n1\tis\n4\tisletter\n1\tit\n1\titself\n5\tleft\n1\tletter\n7\tlookup\n1\tmain\n2\tmalloc\n1\tmessage\n2\tn\n1\tnecessary\n12\tnext\n9\tnode\n4\tof\n1\ton\n1\tor\n1\totherwise\n2\tout\n8\tp\n3\tprint\n2\tprintf\n16\treturn\n5\tright\n4\troot\n25\ts\n2\tstorage\n3\tstrcmp\n1\tstrcpy\n1\tstrlen\n8\tstruct\n1\tstructures\n2\tsubtree\n1\tt\n5\ttprint\n9\ttree\n1\tuses\n1\tversion\n1\twf\n3\twhile\n21\tword\n9\twords\n2\tz\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/wf1.2bk",
    "content": "tst/wf1.c:29: warning: missing return value\ntst/wf1.c:87: warning: missing return value\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/wf1.sbk",
    "content": ".global main\n.section \".text\"\n.align 4\nmain:\nsave %sp,-120,%sp\nst %g0,[%fp+-24]\nset next,%i5\nst %g0,[%i5]\nba .L3; nop\n.L2:\nadd -20,%fp,%o0\nadd -24,%fp,%o1\ncall lookup; nop\nld [%o0],%i4\nadd %i4,1,%i4\nst %i4,[%o0]\n.L3:\nadd -20,%fp,%o0\ncall getword; nop\ncmp %o0,0; bne .L2; nop\nld [%fp+-24],%o0\ncall tprint; nop\nmov %g0,%i0\n.L1:\nret; restore\n.type main,#function\n.size main,.-main\n.global err\n.align 4\nerr:\nsave %sp,-96,%sp\nset .L6,%o0\nmov %i0,%o1\ncall printf; nop\nset 1,%o0\ncall exit; nop\nmov %g0,%i0\n.L5:\nret; restore\n.type err,#function\n.size err,.-err\n.global getword\n.align 4\ngetword:\nsave %sp,-96,%sp\n.L8:\n.L9:\ncall getchar; nop\nmov %o0,%i3\nmov %i3,%i5\ncmp %i3,-1; be .L11; nop\nmov %i5,%o0\ncall isletter; nop\ncmp %o0,0; be .L8; nop\n.L11:\nmov %i0,%i4\nba .L15; nop\n.L12:\nmov %i4,%i3\nadd %i3,1,%i4\nmov %i5,%i2\nstb %i2,[%i3]\n.L13:\ncall getchar; nop\nmov %o0,%i5\n.L15:\nmov %i5,%o0\ncall isletter; nop\nmov %o0,%i5\ncmp %o0,0; bne .L12; nop\nstb %g0,[%i4]\nmov %i4,%i3\nmov %i0,%i2\ncmp %i3,%i2; bleu .L16; nop\nset 1,%i0\nba .L7; nop\n.L16:\nmov %g0,%i0\n.L7:\nret; restore\n.type getword,#function\n.size getword,.-getword\n.global isletter\n.align 4\nisletter:\ncmp %o0,65; bl .L19; nop\ncmp %o0,90; bg .L19; nop\nadd %o0,32,%o0\n.L19:\ncmp %o0,97; bl .L21; nop\ncmp %o0,122; bg .L21; nop\nba .L18; nop\n.L21:\nmov %g0,%o0\n.L18:\nretl; nop\n.type isletter,#function\n.size isletter,.-isletter\n.global lookup\n.align 4\nlookup:\nsave %sp,-96,%sp\nld [%i1],%i4\ncmp %i4,%g0; be .L24; nop\nmov %i0,%o0\nld [%i1],%i4\nld [%i4+12],%o1\ncall strcmp; nop\nmov %o0,%i5\ncmp %i5,0; bge .L26; nop\nmov %i0,%o0\nld [%i1],%i4\nadd %i4,4,%o1\ncall lookup; nop\nmov %o0,%i0\nba .L23; nop\n.L26:\ncmp %i5,0; ble .L28; nop\nmov %i0,%o0\nld [%i1],%i4\nadd %i4,8,%o1\ncall lookup; nop\nmov %o0,%i0\nba .L23; nop\n.L28:\nld [%i1],%i0\nba .L23; nop\n.L24:\nset next,%i4\nld [%i4],%i4\ncmp %i4,2000; bl .L30; nop\nset .L32,%o0\ncall err; nop\n.L30:\nset next,%i4\nld [%i4],%i4\nsll %i4,4,%i4\nset words,%i3\nst %g0,[%i4+%i3]\nset next,%i4\nld [%i4],%i4\nsll %i4,4,%i4\nset words+8,%i2\nst %g0,[%i4+%i2]\nset words+4,%i2\nst %g0,[%i4+%i2]\nmov %i0,%o0\ncall strlen; nop\nmov %o0,%i4\nadd %i4,1,%o0\ncall malloc; nop\nset next,%i3\nld [%i3],%i3\nsll %i3,4,%i3\nset words+12,%i2\nst %o0,[%i3+%i2]\nset next,%i4\nld [%i4],%i4\nsll %i4,4,%i4\nset words+12,%i3\nld [%i4+%i3],%i4\ncmp %i4,%g0; bne .L36; nop\nset .L39,%o0\ncall err; nop\n.L36:\nset next,%i4\nld [%i4],%i4\nsll %i4,4,%i4\nset words+12,%i3\nld [%i4+%i3],%o0\nmov %i0,%o1\ncall strcpy; nop\nset next,%i4\nld [%i4],%i3\nadd %i3,1,%i2\nst %i2,[%i4]\nsll %i3,4,%i4\nset words,%i3\nadd %i4,%i3,%i4\nst %i4,[%i1]\nmov %i4,%i0\n.L23:\nret; restore\n.type lookup,#function\n.size lookup,.-lookup\n.global tprint\n.align 4\ntprint:\nsave %sp,-96,%sp\nmov %i0,%i5\ncmp %i5,%g0; be .L42; nop\nld [%i0+4],%o0\ncall tprint; nop\nset .L44,%o0\nld [%i0],%o1\nld [%i0+12],%o2\ncall printf; nop\nld [%i0+8],%o0\ncall tprint; nop\n.L42:\nmov %g0,%i0\n.L41:\nret; restore\n.type tprint,#function\n.size tprint,.-tprint\n.global strcmp\n.align 4\nstrcmp:\nsave %sp,-96,%sp\nba .L47; nop\n.L46:\nmov %i0,%i5\nadd %i5,1,%i0\nldsb [%i5],%i5\ncmp %i5,0; bne .L49; nop\nmov %g0,%i0\nba .L45; nop\n.L49:\nadd %i1,1,%i1\n.L47:\nldsb [%i0],%i5\nldsb [%i1],%i4\ncmp %i5,%i4; be .L46; nop\nldsb [%i0],%i5\ncmp %i5,0; bne .L51; nop\nset -1,%i0\nba .L45; nop\n.L51:\nldsb [%i1],%i5\ncmp %i5,0; bne .L53; nop\nset 1,%i0\nba .L45; nop\n.L53:\nldsb [%i0],%i5\nldsb [%i1],%i4\nsub %i5,%i4,%i0\n.L45:\nret; restore\n.type strcmp,#function\n.size strcmp,.-strcmp\n.section \".bss\"\n.global next\n.type next,#object\n.size next,4\n.common next,4,4\n.global words\n.type words,#object\n.size words,32000\n.common words,32000,4\n.section \".rodata\"\n.align 1\n.L44:\n.byte 37\n.byte 100\n.byte 9\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.L39:\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 119\n.byte 111\n.byte 114\n.byte 100\n.byte 32\n.byte 115\n.byte 116\n.byte 111\n.byte 114\n.byte 97\n.byte 103\n.byte 101\n.byte 0\n.align 1\n.L32:\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 110\n.byte 111\n.byte 100\n.byte 101\n.byte 32\n.byte 115\n.byte 116\n.byte 111\n.byte 114\n.byte 97\n.byte 103\n.byte 101\n.byte 0\n.align 1\n.L6:\n.byte 63\n.byte 32\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/yacc.1bk",
    "content": "a\nb\nload\nnegate\npush 5\nc\nload\nmultiply\nadd\nstore\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/yacc.2bk",
    "content": "tst/yacc.c:345: warning: missing return value\ntst/yacc.c:349: warning: missing return value\ntst/yacc.c:359: warning: missing return value\n"
  },
  {
    "path": "lcc/sparc/solaris/tst/yacc.sbk",
    "content": ".section \".data\"\n.global yyin\n.type yyin,#object\n.size yyin,4\n.align 4\nyyin:\n.word __iob\n.global yyout\n.type yyout,#object\n.size yyout,4\n.align 4\nyyout:\n.word __iob+16\n.global yylex\n.section \".text\"\n.align 4\nyylex:\nsave %sp,-96,%sp\nba .L5; nop\n.L4:\n.L7:\ncmp %i5,-1; bl .L8; nop\ncmp %i5,4; bg .L8; nop\nsll %i5,2,%i4\nset .L19+4,%i3\nld [%i4+%i3],%i4\njmp %i4; nop\n.section \".rodata\"\n.align 4\n.L19:\n.word .L9\n.word .L10\n.word .L13\n.word .L14\n.word .L9\n.word .L16\n.section \".text\"\n.L10:\ncall yywrap; nop\ncmp %o0,0; be .L9; nop\nmov %g0,%i0\nba .L3; nop\n.L13:\nset 257,%i0\nba .L3; nop\n.L14:\nset 258,%i0\nba .L3; nop\n.L16:\nset yytext,%i4\nldsb [%i4],%i0\nba .L3; nop\n.L8:\nset yyout,%i4\nld [%i4],%o0\nset .L18,%o1\nmov %i5,%o2\ncall fprintf; nop\n.L9:\n.L5:\ncall yylook; nop\nmov %o0,%i5\ncmp %o0,0; bge .L4; nop\nmov %g0,%i0\n.L3:\nret; restore\n.type yylex,#function\n.size yylex,.-yylex\n.section \".data\"\n.global yyvstop\n.type yyvstop,#object\n.align 4\nyyvstop:\n.word 0x0\n.word 0x4\n.word 0x0\n.word 0x3\n.word 0x4\n.word 0x0\n.word 0x2\n.word 0x4\n.word 0x0\n.word 0x1\n.word 0x4\n.word 0x0\n.word 0x2\n.word 0x0\n.word 0x1\n.word 0x0\n.word 0x0\n.size yyvstop,68\n.global yycrank\n.type yycrank,#object\n.align 1\nyycrank:\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x1\n.byte 0x3\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x1\n.byte 0x4\n.byte 0x1\n.byte 0x3\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x1\n.byte 0x5\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x5\n.byte 0x7\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x1\n.byte 0x6\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x6\n.byte 0x8\n.byte 0x0\n.byte 0x0\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x6\n.byte 0x8\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.byte 0x0\n.size yycrank,290\n.global yysvec\n.type yysvec,#object\n.align 4\nyysvec:\n.word 0x0\n.word 0x0\n.word 0x0\n.word yycrank-2\n.word 0x0\n.word 0x0\n.word yycrank\n.word yysvec+12\n.word 0x0\n.word yycrank\n.word 0x0\n.word yyvstop+4\n.word yycrank\n.word 0x0\n.word yyvstop+12\n.word yycrank+4\n.word 0x0\n.word yyvstop+24\n.word yycrank+38\n.word 0x0\n.word yyvstop+36\n.word yycrank\n.word yysvec+60\n.word yyvstop+48\n.word yycrank\n.word yysvec+72\n.word yyvstop+56\n.word 0x0\n.word 0x0\n.word 0x0\n.size yysvec,120\n.global yytop\n.type yytop,#object\n.size yytop,4\n.align 4\nyytop:\n.word yycrank+282\n.global yybgin\n.type yybgin,#object\n.size yybgin,4\n.align 4\nyybgin:\n.word yysvec+12\n.global yymatch\n.type yymatch,#object\n.align 1\nyymatch:\n.byte 0\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 9\n.byte 10\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 9\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 65\n.byte 1\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 0\n.size yymatch,129\n.global yyextra\n.type yyextra,#object\n.align 1\nyyextra:\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.size yyextra,9\n.global yylineno\n.type yylineno,#object\n.size yylineno,4\n.align 4\nyylineno:\n.word 0x1\n.global yysptr\n.type yysptr,#object\n.size yysptr,4\n.align 4\nyysptr:\n.word yysbuf\n.global yyprevious\n.type yyprevious,#object\n.size yyprevious,4\n.align 4\nyyprevious:\n.word 0xa\n.global yylook\n.section \".text\"\n.align 4\nyylook:\nsave %sp,-96,%sp\nset yymorfg,%l6\nld [%l6],%l6\ncmp %l6,0; bne .L36; nop\nset yytext,%i2\nba .L37; nop\n.L36:\nset yymorfg,%l6\nst %g0,[%l6]\nset yyleng,%l6\nld [%l6],%l6\nset yytext,%l5\nadd %l6,%l5,%i2\n.L37:\n.L38:\nset yylstate,%i4\nset yybgin,%l6\nld [%l6],%l6\nmov %l6,%i5\nset yyestate,%l5\nst %l6,[%l5]\nset yyprevious,%l6\nld [%l6],%l6\ncmp %l6,10; bne .L42; nop\nadd %i5,12,%i5\n.L42:\n.L44:\nld [%i5],%i3\nmov %i3,%l6\nset yycrank,%l5\ncmp %l6,%l5; bne .L48; nop\nld [%i5+4],%l7\nmov %l7,%l6\ncmp %l6,%g0; bne .L50; nop\nba .L95; nop\n.L50:\nld [%l7],%l6\nset yycrank,%l5\ncmp %l6,%l5; bne .L52; nop\nba .L95; nop\n.L52:\n.L48:\nmov %i2,%l3\nadd %l3,1,%i2\nset yysptr,%l2\nld [%l2],%l2\nset yysbuf,%l1\ncmp %l2,%l1; bleu .L62; nop\nset yysptr,%l2\nld [%l2],%l1\nadd %l1,-1,%l1\nst %l1,[%l2]\nldsb [%l1],%l4\nba .L63; nop\n.L62:\nset yyin,%l2\nld [%l2],%l2\nld [%l2],%l1\nsub %l1,1,%l1\nst %l1,[%l2]\ncmp %l1,0; bge .L64; nop\nset yyin,%l2\nld [%l2],%o0\ncall __filbuf; nop\nmov %o0,%l2\nst %l2,[%fp+-4]\nba .L65; nop\n.L64:\nset yyin,%l2\nld [%l2],%l2\nadd %l2,4,%l2\nld [%l2],%l1\nadd %l1,1,%l0\nst %l0,[%l2]\nldub [%l1],%l2\nst %l2,[%fp+-4]\n.L65:\nld [%fp+-4],%l4\n.L63:\nset yytchar,%l2\nst %l4,[%l2]\ncmp %l4,10; bne .L60; nop\nset yylineno,%l2\nld [%l2],%l1\nadd %l1,1,%l1\nst %l1,[%l2]\nset yytchar,%l2\nld [%l2],%l5\nba .L61; nop\n.L60:\nset yytchar,%l2\nld [%l2],%l5\n.L61:\ncmp %l5,-1; bne .L58; nop\nmov %g0,%l6\nba .L59; nop\n.L58:\nset yytchar,%l2\nld [%l2],%l6\n.L59:\nmov %l6,%i1\nmov %l6,%l2\nstb %l2,[%l3]\n.L66:\nmov %i3,%i0\nmov %i3,%l3\nset yycrank,%l2\ncmp %l3,%l2; bleu .L67; nop\nsll %i1,1,%l3\nadd %l3,%i0,%i3\nmov %i3,%l3\nset yytop,%l2\nld [%l2],%l2\ncmp %l3,%l2; bgu .L68; nop\nldsb [%i3],%l3\nsmul %l3,12,%l3\nset yysvec,%l2\nadd %l3,%l2,%l3\nmov %i5,%l2\ncmp %l3,%l2; bne .L68; nop\nset yysvec,%l3\nldsb [%i3+1],%l2\nsmul %l2,12,%l2\nadd %l2,%l3,%l2\ncmp %l2,%l3; bne .L71; nop\nadd %i2,-1,%l3\nmov %l3,%i2\nset yytchar,%l2\nldsb [%l3],%l3\nst %l3,[%l2]\nld [%l2],%l3\ncmp %l3,10; bne .L73; nop\nset yylineno,%l3\nld [%l3],%l2\nsub %l2,1,%l2\nst %l2,[%l3]\n.L73:\nset yysptr,%l3\nld [%l3],%l2\nadd %l2,1,%l1\nst %l1,[%l3]\nset yytchar,%l3\nld [%l3],%l3\nstb %l3,[%l2]\nba .L95; nop\n.L71:\nmov %i4,%l3\nadd %l3,4,%i4\nldsb [%i3+1],%l2\nsmul %l2,12,%l2\nset yysvec,%l1\nadd %l2,%l1,%l2\nmov %l2,%i5\nst %l2,[%l3]\nba .L44; nop\n.L67:\nmov %i3,%l3\nset yycrank,%l2\ncmp %l3,%l2; bgeu .L76; nop\nset yycrank,%l3\nmov %l3,%l2\nmov %i3,%l1\nsub %l2,%l1,%l2\nsra %l2,31,%g1; wr %g0,%g1,%y; nop; nop; nop; sdiv %l2,2,%l2\nsll %l2,1,%l2\nadd %l2,%l3,%l3\nmov %l3,%i0\nmov %l3,%i3\nsll %i1,1,%l3\nadd %l3,%i3,%i3\nmov %i3,%l3\nset yytop,%l2\nld [%l2],%l2\ncmp %l3,%l2; bgu .L78; nop\nldsb [%i3],%l3\nsmul %l3,12,%l3\nset yysvec,%l2\nadd %l3,%l2,%l3\nmov %i5,%l2\ncmp %l3,%l2; bne .L78; nop\nset yysvec,%l3\nldsb [%i3+1],%l2\nsmul %l2,12,%l2\nadd %l2,%l3,%l2\ncmp %l2,%l3; bne .L80; nop\nadd %i2,-1,%l3\nmov %l3,%i2\nset yytchar,%l2\nldsb [%l3],%l3\nst %l3,[%l2]\nld [%l2],%l3\ncmp %l3,10; bne .L82; nop\nset yylineno,%l3\nld [%l3],%l2\nsub %l2,1,%l2\nst %l2,[%l3]\n.L82:\nset yysptr,%l3\nld [%l3],%l2\nadd %l2,1,%l1\nst %l1,[%l3]\nset yytchar,%l3\nld [%l3],%l3\nstb %l3,[%l2]\nba .L95; nop\n.L80:\nmov %i4,%l3\nadd %l3,4,%i4\nldsb [%i3+1],%l2\nsmul %l2,12,%l2\nset yysvec,%l1\nadd %l2,%l1,%l2\nmov %l2,%i5\nst %l2,[%l3]\nba .L44; nop\n.L78:\nset yymatch,%l3\nldsb [%i1+%l3],%l3\nsll %l3,1,%l3\nadd %l3,%i0,%i3\nmov %i3,%l3\nset yytop,%l2\nld [%l2],%l2\ncmp %l3,%l2; bgu .L84; nop\nldsb [%i3],%l3\nsmul %l3,12,%l3\nset yysvec,%l2\nadd %l3,%l2,%l3\nmov %i5,%l2\ncmp %l3,%l2; bne .L84; nop\nset yysvec,%l3\nldsb [%i3+1],%l2\nsmul %l2,12,%l2\nadd %l2,%l3,%l2\ncmp %l2,%l3; bne .L86; nop\nadd %i2,-1,%l3\nmov %l3,%i2\nset yytchar,%l2\nldsb [%l3],%l3\nst %l3,[%l2]\nld [%l2],%l3\ncmp %l3,10; bne .L88; nop\nset yylineno,%l3\nld [%l3],%l2\nsub %l2,1,%l2\nst %l2,[%l3]\n.L88:\nset yysptr,%l3\nld [%l3],%l2\nadd %l2,1,%l1\nst %l1,[%l3]\nset yytchar,%l3\nld [%l3],%l3\nstb %l3,[%l2]\nba .L95; nop\n.L86:\nmov %i4,%l3\nadd %l3,4,%i4\nldsb [%i3+1],%l2\nsmul %l2,12,%l2\nset yysvec,%l1\nadd %l2,%l1,%l2\nmov %l2,%i5\nst %l2,[%l3]\nba .L44; nop\n.L84:\n.L76:\n.L68:\nld [%i5+4],%l3\nmov %l3,%i5\ncmp %l3,%g0; be .L90; nop\nld [%i5],%l3\nmov %l3,%i3\nset yycrank,%l2\ncmp %l3,%l2; be .L90; nop\nba .L66; nop\n.L90:\nadd %i2,-1,%l3\nmov %l3,%i2\nset yytchar,%l2\nldsb [%l3],%l3\nst %l3,[%l2]\nld [%l2],%l3\ncmp %l3,10; bne .L92; nop\nset yylineno,%l3\nld [%l3],%l2\nsub %l2,1,%l2\nst %l2,[%l3]\n.L92:\nset yysptr,%l3\nld [%l3],%l2\nadd %l2,1,%l1\nst %l1,[%l3]\nset yytchar,%l3\nld [%l3],%l3\nstb %l3,[%l2]\nba .L95; nop\n.L94:\nmov %i2,%l6\nadd %l6,-1,%i2\nstb %g0,[%l6]\nld [%i4],%l6\nmov %l6,%l4\ncmp %l4,%g0; be .L97; nop\nset yyfnd,%l4\nld [%l6+8],%l6\nst %l6,[%l4]\ncmp %l6,%g0; be .L97; nop\nld [%l4],%l6\nld [%l6],%l6\ncmp %l6,0; ble .L97; nop\nset yyolsp,%l6\nst %i4,[%l6]\nset yyfnd,%l6\nld [%l6],%l6\nld [%l6],%l6\nset yyextra,%l5\nldsb [%l6+%l5],%l6\ncmp %l6,0; be .L99; nop\nba .L102; nop\n.L101:\nadd %i4,-4,%i4\nmov %i2,%l6\nadd %l6,-1,%i2\nset yytchar,%l5\nldsb [%l6],%l6\nst %l6,[%l5]\nld [%l5],%l6\ncmp %l6,10; bne .L104; nop\nset yylineno,%l6\nld [%l6],%l5\nsub %l5,1,%l5\nst %l5,[%l6]\n.L104:\nset yysptr,%l6\nld [%l6],%l5\nadd %l5,1,%l4\nst %l4,[%l6]\nset yytchar,%l6\nld [%l6],%l6\nstb %l6,[%l5]\n.L102:\nld [%i4],%l6\nld [%l6+8],%o0\nset yyfnd,%l6\nld [%l6],%l6\nld [%l6],%l6\nneg %l6,%o1\ncall yyback; nop\ncmp %o0,1; be .L106; nop\nmov %i4,%l6\nset yylstate,%l5\ncmp %l6,%l5; bgu .L101; nop\n.L106:\n.L99:\nset yyprevious,%l6\nldsb [%i2],%l5\nst %l5,[%l6]\nset yylsp,%l6\nst %i4,[%l6]\nset yyleng,%l6\nset yytext,%l5\nmov %i2,%l4\nmov %l5,%l3\nsub %l4,%l3,%l4\nadd %l4,1,%l4\nst %l4,[%l6]\nld [%l6],%l6\nstb %g0,[%l6+%l5]\nset yyfnd,%l6\nld [%l6],%l5\nadd %l5,4,%l4\nst %l4,[%l6]\nld [%l5],%i0\nba .L35; nop\n.L97:\nset yytchar,%l6\nldsb [%i2],%l5\nst %l5,[%l6]\nld [%l6],%l6\ncmp %l6,10; bne .L107; nop\nset yylineno,%l6\nld [%l6],%l5\nsub %l5,1,%l5\nst %l5,[%l6]\n.L107:\nset yysptr,%l6\nld [%l6],%l5\nadd %l5,1,%l4\nst %l4,[%l6]\nset yytchar,%l6\nld [%l6],%l6\nstb %l6,[%l5]\n.L95:\nmov %i4,%l6\nadd %l6,-4,%i4\nset yylstate,%l5\ncmp %l6,%l5; bgu .L94; nop\nset yytext,%l6\nldsb [%l6],%l6\ncmp %l6,0; bne .L109; nop\nset yysptr,%l6\nset yysbuf,%l5\nst %l5,[%l6]\nmov %g0,%i0\nba .L35; nop\n.L109:\nset yysptr,%l3\nld [%l3],%l3\nset yysbuf,%l2\ncmp %l3,%l2; bleu .L119; nop\nset yysptr,%l3\nld [%l3],%l2\nadd %l2,-1,%l2\nst %l2,[%l3]\nldsb [%l2],%l4\nba .L120; nop\n.L119:\nset yyin,%l3\nld [%l3],%l3\nld [%l3],%l2\nsub %l2,1,%l2\nst %l2,[%l3]\ncmp %l2,0; bge .L121; nop\nset yyin,%l3\nld [%l3],%o0\ncall __filbuf; nop\nmov %o0,%l3\nst %l3,[%fp+-4]\nba .L122; nop\n.L121:\nset yyin,%l3\nld [%l3],%l3\nadd %l3,4,%l3\nld [%l3],%l2\nadd %l2,1,%l1\nst %l1,[%l3]\nldub [%l2],%l3\nst %l3,[%fp+-4]\n.L122:\nld [%fp+-4],%l4\n.L120:\nset yytchar,%l3\nst %l4,[%l3]\ncmp %l4,10; bne .L117; nop\nset yylineno,%l3\nld [%l3],%l2\nadd %l2,1,%l2\nst %l2,[%l3]\nset yytchar,%l3\nld [%l3],%l5\nba .L118; nop\n.L117:\nset yytchar,%l3\nld [%l3],%l5\n.L118:\ncmp %l5,-1; bne .L115; nop\nmov %g0,%l6\nba .L116; nop\n.L115:\nset yytchar,%l3\nld [%l3],%l6\n.L116:\nset yytext,%l2\nstb %l6,[%l2]\nset yyprevious,%l2\nsll %l6,8*(4-1),%l3; sra %l3,8*(4-1),%l3\nst %l3,[%l2]\nset yyprevious,%l3\nld [%l3],%l3\ncmp %l3,0; ble .L123; nop\nset yyout,%l3\nld [%l3],%l3\nld [%l3],%l2\nsub %l2,1,%l2\nst %l2,[%l3]\ncmp %l2,0; bge .L126; nop\nset yyprevious,%l3\nld [%l3],%l3\nand %l3,0xff,%l3\nmov %l3,%o0\nset yyout,%l3\nld [%l3],%o1\ncall __flsbuf; nop\nba .L127; nop\n.L126:\nset yyout,%l3\nld [%l3],%l3\nadd %l3,4,%l3\nld [%l3],%l2\nadd %l2,1,%l1\nst %l1,[%l3]\nset yyprevious,%l3\nld [%l3],%l3\nstb %l3,[%l2]\n.L127:\n.L123:\nset yytext,%i2\nba .L38; nop\n.L35:\nret; restore\n.type yylook,#function\n.size yylook,.-yylook\n.global yyback\n.align 4\nyyback:\nsave %sp,-96,%sp\nmov %i0,%i5\ncmp %i5,%g0; bne .L132; nop\nmov %g0,%i0\nba .L128; nop\n.L131:\nmov %i0,%i5\nadd %i5,4,%i0\nld [%i5],%i5\ncmp %i5,%i1; bne .L134; nop\nset 1,%i0\nba .L128; nop\n.L134:\n.L132:\nld [%i0],%i5\ncmp %i5,0; bne .L131; nop\nmov %g0,%i0\n.L128:\nret; restore\n.type yyback,#function\n.size yyback,.-yyback\n.global yyinput\n.align 4\nyyinput:\nsave %sp,-96,%sp\nset yysptr,%i1\nld [%i1],%i1\nset yysbuf,%i0\ncmp %i1,%i0; bleu .L145; nop\nset yysptr,%i1\nld [%i1],%i0\nadd %i0,-1,%i0\nst %i0,[%i1]\nldsb [%i0],%i3\nba .L146; nop\n.L145:\nset yyin,%i1\nld [%i1],%i1\nld [%i1],%i0\nsub %i0,1,%i0\nst %i0,[%i1]\ncmp %i0,0; bge .L147; nop\nset yyin,%i1\nld [%i1],%o0\ncall __filbuf; nop\nmov %o0,%i1\nmov %i1,%i2\nba .L148; nop\n.L147:\nset yyin,%i1\nld [%i1],%i1\nadd %i1,4,%i1\nld [%i1],%i0\nadd %i0,1,%l7\nst %l7,[%i1]\nldub [%i0],%i2\n.L148:\nmov %i2,%i3\n.L146:\nset yytchar,%i1\nst %i3,[%i1]\ncmp %i3,10; bne .L143; nop\nset yylineno,%i1\nld [%i1],%i0\nadd %i0,1,%i0\nst %i0,[%i1]\nset yytchar,%i1\nld [%i1],%i4\nba .L144; nop\n.L143:\nset yytchar,%i1\nld [%i1],%i4\n.L144:\ncmp %i4,-1; bne .L141; nop\nmov %g0,%i5\nba .L142; nop\n.L141:\nset yytchar,%i1\nld [%i1],%i5\n.L142:\nmov %i5,%i0\n.L136:\nret; restore\n.type yyinput,#function\n.size yyinput,.-yyinput\n.global yyoutput\n.align 4\nyyoutput:\nsave %sp,-96,%sp\nset yyout,%i5\nld [%i5],%i5\nld [%i5],%i4\nsub %i4,1,%i4\nst %i4,[%i5]\ncmp %i4,0; bge .L151; nop\nmov %i0,%i5\nand %i5,0xff,%i5\nmov %i5,%o0\nset yyout,%i5\nld [%i5],%o1\ncall __flsbuf; nop\nba .L152; nop\n.L151:\nset yyout,%i5\nld [%i5],%i5\nadd %i5,4,%i5\nld [%i5],%i4\nadd %i4,1,%i3\nst %i3,[%i5]\nmov %i0,%i5\nstb %i5,[%i4]\n.L152:\nmov %g0,%i0\n.L149:\nret; restore\n.type yyoutput,#function\n.size yyoutput,.-yyoutput\n.global yyunput\n.align 4\nyyunput:\nsave %sp,-96,%sp\nset yytchar,%i5\nst %i0,[%i5]\nld [%i5],%i5\ncmp %i5,10; bne .L154; nop\nset yylineno,%i5\nld [%i5],%i4\nsub %i4,1,%i4\nst %i4,[%i5]\n.L154:\nset yysptr,%i5\nld [%i5],%i4\nadd %i4,1,%i3\nst %i3,[%i5]\nset yytchar,%i5\nld [%i5],%i5\nstb %i5,[%i4]\nmov %g0,%i0\n.L153:\nret; restore\n.type yyunput,#function\n.size yyunput,.-yyunput\n.global main\n.align 4\nmain:\nsave %sp,-96,%sp\ncall yyparse; nop\nmov %g0,%i0\n.L156:\nret; restore\n.type main,#function\n.size main,.-main\n.global yyerror\n.align 4\nyyerror:\nsave %sp,-96,%sp\nset .L158,%o0\nmov %i0,%o1\ncall printf; nop\nmov %g0,%i0\n.L157:\nret; restore\n.type yyerror,#function\n.size yyerror,.-yyerror\n.section \".data\"\n.global yyexca\n.type yyexca,#object\n.align 2\nyyexca:\n.half 0xffffffff\n.half 0x1\n.half 0x0\n.half 0xffffffff\n.half 0xfffffffe\n.half 0x0\n.size yyexca,12\n.global yyact\n.type yyact,#object\n.align 2\nyyact:\n.half 0xc\n.half 0x2\n.half 0x9\n.half 0x8\n.half 0x11\n.half 0xb\n.half 0x19\n.half 0x11\n.half 0xf\n.half 0x12\n.half 0x10\n.half 0xa\n.half 0x12\n.half 0x11\n.half 0xf\n.half 0x7\n.half 0x10\n.half 0xd\n.half 0x12\n.half 0x5\n.half 0x3\n.half 0x1\n.half 0x0\n.half 0x13\n.half 0x14\n.half 0x0\n.half 0x0\n.half 0x15\n.half 0x16\n.half 0x17\n.half 0x18\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x6\n.half 0xe\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x4\n.half 0x6\n.size yyact,498\n.global yypact\n.type yypact,#object\n.align 2\nyypact:\n.half 0xfffffc18\n.half 0xfffffff7\n.half 0xfffffc18\n.half 0x5\n.half 0xfffffff9\n.half 0xffffffc5\n.half 0xfffffc18\n.half 0xfffffc18\n.half 0xfffffc18\n.half 0xffffffd8\n.half 0xffffffe3\n.half 0xffffffd8\n.half 0xffffffd8\n.half 0xfffffc18\n.half 0xfffffc18\n.half 0xffffffd8\n.half 0xffffffd8\n.half 0xffffffd8\n.half 0xffffffd8\n.half 0xffffffda\n.half 0xffffffdd\n.half 0xffffffda\n.half 0xffffffda\n.half 0xfffffc18\n.half 0xfffffc18\n.half 0xfffffc18\n.size yypact,52\n.global yypgo\n.type yypgo,#object\n.align 2\nyypgo:\n.half 0x0\n.half 0x15\n.half 0x14\n.half 0x11\n.half 0xb\n.size yypgo,10\n.global yyr1\n.type yyr1,#object\n.align 2\nyyr1:\n.half 0x0\n.half 0x1\n.half 0x1\n.half 0x1\n.half 0x1\n.half 0x2\n.half 0x4\n.half 0x4\n.half 0x4\n.half 0x4\n.half 0x4\n.half 0x4\n.half 0x4\n.half 0x4\n.half 0x3\n.size yyr1,30\n.global yyr2\n.type yyr2,#object\n.align 2\nyyr2:\n.half 0x0\n.half 0x0\n.half 0x2\n.half 0x3\n.half 0x3\n.half 0x3\n.half 0x3\n.half 0x3\n.half 0x3\n.half 0x3\n.half 0x2\n.half 0x3\n.half 0x1\n.half 0x1\n.half 0x1\n.size yyr2,30\n.global yychk\n.type yychk,#object\n.align 2\nyychk:\n.half 0xfffffc18\n.half 0xffffffff\n.half 0xa\n.half 0xfffffffe\n.half 0x100\n.half 0xfffffffd\n.half 0x101\n.half 0xa\n.half 0xa\n.half 0x3d\n.half 0xfffffffc\n.half 0x2d\n.half 0x28\n.half 0xfffffffd\n.half 0x102\n.half 0x2b\n.half 0x2d\n.half 0x2a\n.half 0x2f\n.half 0xfffffffc\n.half 0xfffffffc\n.half 0xfffffffc\n.half 0xfffffffc\n.half 0xfffffffc\n.half 0xfffffffc\n.half 0x29\n.size yychk,52\n.global yydef\n.type yydef,#object\n.align 2\nyydef:\n.half 0x1\n.half 0xfffffffe\n.half 0x2\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0xe\n.half 0x3\n.half 0x4\n.half 0x0\n.half 0x5\n.half 0x0\n.half 0x0\n.half 0xc\n.half 0xd\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0x0\n.half 0xa\n.half 0x0\n.half 0x6\n.half 0x7\n.half 0x8\n.half 0x9\n.half 0xb\n.size yydef,52\n.global yychar\n.type yychar,#object\n.size yychar,4\n.align 4\nyychar:\n.word 0xffffffff\n.global yynerrs\n.type yynerrs,#object\n.size yynerrs,4\n.align 4\nyynerrs:\n.word 0x0\n.global yyerrflag\n.type yyerrflag,#object\n.size yyerrflag,2\n.align 2\nyyerrflag:\n.half 0x0\n.global yyparse\n.section \".text\"\n.align 4\nyyparse:\nsave %sp,-392,%sp\nmov %g0,%l5\nmov %l5,%i4\nset yychar,%l4\nset -1,%l3\nst %l3,[%l4]\nset yynerrs,%l4\nst %g0,[%l4]\nset yyerrflag,%l4\nsth %l5,[%l4]\nadd -302,%fp,%i3\nset yyv-4,%i1\n.L162:\nadd %i3,2,%l5\nmov %l5,%i3\nadd 0,%fp,%l4\ncmp %l5,%l4; bleu .L163; nop\nset .L166,%o0\ncall yyerror; nop\nset 1,%i0\nba .L159; nop\n.L163:\nsth %i4,[%i3]\nadd %i1,4,%i1\nset yyval,%l5\nld [%l5],%l5\nst %l5,[%i1]\n.L167:\nsll %i4,8*(4-2),%l5; sra %l5,8*(4-2),%l5\nsll %l5,1,%l5\nset yypact,%l4\nldsh [%l5+%l4],%i2\nsll %i2,8*(4-2),%l5; sra %l5,8*(4-2),%l5\ncmp %l5,-1000; bg .L168; nop\nba .L170; nop\n.L168:\nset yychar,%l5\nld [%l5],%l5\ncmp %l5,0; bge .L171; nop\ncall yylex; nop\nset yychar,%l4\nst %o0,[%l4]\ncmp %o0,0; bge .L173; nop\nset yychar,%l5\nst %g0,[%l5]\n.L173:\n.L171:\nsll %i2,8*(4-2),%l5; sra %l5,8*(4-2),%l5\nset yychar,%l4\nld [%l4],%l4\nadd %l5,%l4,%l5\nmov %l5,%i2\nsll %l5,8*(4-2),%l5; sra %l5,8*(4-2),%l5\ncmp %l5,0; bl .L177; nop\nsll %i2,8*(4-2),%l5; sra %l5,8*(4-2),%l5\ncmp %l5,249; bl .L175; nop\n.L177:\nba .L170; nop\n.L175:\nsll %i2,8*(4-2),%l5; sra %l5,8*(4-2),%l5\nsll %l5,1,%l5\nset yyact,%l4\nldsh [%l5+%l4],%l5\nmov %l5,%i2\nsll %l5,8*(4-2),%l5; sra %l5,8*(4-2),%l5\nsll %l5,1,%l5\nset yychk,%l4\nldsh [%l5+%l4],%l5\nset yychar,%l4\nld [%l4],%l4\ncmp %l5,%l4; bne .L178; nop\nset yychar,%l5\nset -1,%l4\nst %l4,[%l5]\nset yyval,%l5\nset yylval,%l4\nld [%l4],%l4\nst %l4,[%l5]\nmov %i2,%i4\nset yyerrflag,%l5\nldsh [%l5],%l5\ncmp %l5,0; ble .L162; nop\nset yyerrflag,%l5\nldsh [%l5],%l4\nsub %l4,1,%l4\nsth %l4,[%l5]\nba .L162; nop\n.L178:\n.L170:\nsll %i4,8*(4-2),%l5; sra %l5,8*(4-2),%l5\nsll %l5,1,%l5\nset yydef,%l4\nldsh [%l5+%l4],%l5\nmov %l5,%i2\nsll %l5,8*(4-2),%l5; sra %l5,8*(4-2),%l5\ncmp %l5,-2; bne .L182; nop\nset yychar,%l5\nld [%l5],%l5\ncmp %l5,0; bge .L184; nop\ncall yylex; nop\nset yychar,%l4\nst %o0,[%l4]\ncmp %o0,0; bge .L186; nop\nset yychar,%l5\nst %g0,[%l5]\n.L186:\n.L184:\nset yyexca,%i0\nba .L191; nop\n.L188:\n.L189:\nadd %i0,4,%i0\n.L191:\nldsh [%i0],%l5\ncmp %l5,-1; bne .L188; nop\nldsh [%i0+2],%l5\nsll %i4,8*(4-2),%l4; sra %l4,8*(4-2),%l4\ncmp %l5,%l4; bne .L188; nop\nba .L193; nop\n.L192:\nldsh [%i0],%l5\nset yychar,%l4\nld [%l4],%l4\ncmp %l5,%l4; bne .L195; nop\nba .L194; nop\n.L195:\n.L193:\nadd %i0,4,%l5\nmov %l5,%i0\nldsh [%l5],%l5\ncmp %l5,0; bge .L192; nop\n.L194:\nldsh [%i0+2],%l5\nmov %l5,%i2\nsll %l5,8*(4-2),%l5; sra %l5,8*(4-2),%l5\ncmp %l5,0; bge .L197; nop\nmov %g0,%i0\nba .L159; nop\n.L197:\n.L182:\nsll %i2,8*(4-2),%l5; sra %l5,8*(4-2),%l5\ncmp %l5,0; bne .L199; nop\nset yyerrflag,%l4\nldsh [%l4],%l5\ncmp %l5,0; bl .L201; nop\ncmp %l5,3; bg .L201; nop\nsll %l5,2,%l4\nset .L217,%l3\nld [%l4+%l3],%l4\njmp %l4; nop\n.section \".rodata\"\n.align 4\n.L217:\n.word .L204\n.word .L207\n.word .L207\n.word .L214\n.section \".text\"\n.L204:\nset .L205,%o0\ncall yyerror; nop\n.L206:\nset yynerrs,%l4\nld [%l4],%l3\nadd %l3,1,%l3\nst %l3,[%l4]\n.L207:\nset yyerrflag,%l4\nset 3,%l3\nsth %l3,[%l4]\nba .L209; nop\n.L208:\nldsh [%i3],%l4\nsll %l4,1,%l4\nset yypact,%l3\nldsh [%l4+%l3],%l4\nadd %l4,256,%l4\nmov %l4,%i2\nsll %i2,8*(4-2),%l4; sra %l4,8*(4-2),%l4\ncmp %l4,0; bl .L211; nop\ncmp %l4,249; bge .L211; nop\nsll %l4,1,%l4\nset yyact,%l3\nldsh [%l4+%l3],%l4\nsll %l4,1,%l4\nset yychk,%l3\nldsh [%l4+%l3],%l4\ncmp %l4,256; bne .L211; nop\nsll %i2,8*(4-2),%l4; sra %l4,8*(4-2),%l4\nsll %l4,1,%l4\nset yyact,%l3\nldsh [%l4+%l3],%i4\nba .L162; nop\n.L211:\nldsh [%i3],%l4\nsll %l4,1,%l4\nset yypact,%l3\nldsh [%l4+%l3],%i2\nadd %i3,-2,%i3\nadd %i1,-4,%i1\n.L209:\nmov %i3,%l4\nadd -300,%fp,%l3\ncmp %l4,%l3; bgeu .L208; nop\n.L213:\nset 1,%i0\nba .L159; nop\n.L214:\nset yychar,%l4\nld [%l4],%l4\ncmp %l4,0; bne .L215; nop\nba .L213; nop\n.L215:\nset yychar,%l4\nset -1,%l3\nst %l3,[%l4]\nba .L167; nop\n.L201:\n.L199:\nsll %i2,8*(4-2),%l5; sra %l5,8*(4-2),%l5\nsll %l5,1,%l5\nset yyr2,%l4\nadd %l5,%l4,%l4\nldsh [%l4],%l3\nsll %l3,1,%l3\nsub %i3,%l3,%i3\nmov %i1,%i5\nldsh [%l4],%l4\nsll %l4,2,%l4\nsub %i1,%l4,%i1\nset yyval,%l4\nld [%i1+4],%l3\nst %l3,[%l4]\nmov %i2,%l6\nset yyr1,%l4\nldsh [%l5+%l4],%i2\nsll %i2,8*(4-2),%l5; sra %l5,8*(4-2),%l5\nsll %l5,1,%l5\nset yypgo,%l4\nldsh [%l5+%l4],%l5\nldsh [%i3],%l4\nadd %l5,%l4,%l5\nadd %l5,1,%l5\nmov %l5,%l7\nsll %l7,8*(4-2),%l5; sra %l5,8*(4-2),%l5\ncmp %l5,249; bge .L220; nop\nsll %l5,1,%l5\nset yyact,%l4\nldsh [%l5+%l4],%l5\nmov %l5,%i4\nsll %l5,8*(4-2),%l5; sra %l5,8*(4-2),%l5\nsll %l5,1,%l5\nset yychk,%l4\nldsh [%l5+%l4],%l5\nsll %i2,8*(4-2),%l4; sra %l4,8*(4-2),%l4\nneg %l4,%l4\ncmp %l5,%l4; be .L218; nop\n.L220:\nsll %i2,8*(4-2),%l5; sra %l5,8*(4-2),%l5\nsll %l5,1,%l5\nset yypgo,%l4\nldsh [%l5+%l4],%l5\nsll %l5,1,%l5\nset yyact,%l4\nldsh [%l5+%l4],%i4\n.L218:\nsll %l6,8*(4-2),%l5; sra %l5,8*(4-2),%l5\ncmp %l5,4; bl .L162; nop\ncmp %l5,14; bg .L162; nop\nsll %l5,2,%l4\nset .L242-16,%l3\nld [%l4+%l3],%l4\njmp %l4; nop\n.section \".rodata\"\n.align 4\n.L242:\n.word .L224\n.word .L225\n.word .L227\n.word .L229\n.word .L231\n.word .L233\n.word .L235\n.word .L162\n.word .L237\n.word .L239\n.word .L241\n.section \".text\"\n.L224:\nset yyerrflag,%l4\nsth %g0,[%l4]\nba .L162; nop\n.L225:\nset .L226,%o0\ncall printf; nop\nba .L162; nop\n.L227:\nset .L228,%o0\ncall printf; nop\nba .L162; nop\n.L229:\nset .L230,%o0\ncall printf; nop\nba .L162; nop\n.L231:\nset .L232,%o0\ncall printf; nop\nba .L162; nop\n.L233:\nset .L234,%o0\ncall printf; nop\nba .L162; nop\n.L235:\nset .L236,%o0\ncall printf; nop\nba .L162; nop\n.L237:\nset .L238,%o0\ncall printf; nop\nba .L162; nop\n.L239:\nset .L240,%o0\nset yytext,%o1\ncall printf; nop\nba .L162; nop\n.L241:\nset .L158,%o0\nset yytext,%o1\ncall printf; nop\nba .L162; nop\n.L159:\nret; restore\n.type yyparse,#function\n.size yyparse,.-yyparse\n.global yywrap\n.align 4\nyywrap:\nset 1,%o0\n.L244:\nretl; nop\n.type yywrap,#function\n.size yywrap,.-yywrap\n.section \".bss\"\n.global yyv\n.type yyv,#object\n.size yyv,600\n.common yyv,600,4\n.global yyfnd\n.type yyfnd,#object\n.size yyfnd,4\n.common yyfnd,4,4\n.global yyolsp\n.type yyolsp,#object\n.size yyolsp,4\n.common yyolsp,4,4\n.global yylsp\n.type yylsp,#object\n.size yylsp,4\n.common yylsp,4,4\n.global yylstate\n.type yylstate,#object\n.size yylstate,800\n.common yylstate,800,4\n.global yyestate\n.type yyestate,#object\n.size yyestate,4\n.common yyestate,4,4\n.global yytchar\n.type yytchar,#object\n.size yytchar,4\n.common yytchar,4,4\n.global yysbuf\n.type yysbuf,#object\n.size yysbuf,200\n.common yysbuf,200,1\n.global yymorfg\n.type yymorfg,#object\n.size yymorfg,4\n.common yymorfg,4,4\n.global yytext\n.type yytext,#object\n.size yytext,200\n.common yytext,200,1\n.global yyleng\n.type yyleng,#object\n.size yyleng,4\n.common yyleng,4,4\n.global yyval\n.type yyval,#object\n.size yyval,4\n.common yyval,4,4\n.global yylval\n.type yylval,#object\n.size yylval,4\n.common yylval,4,4\n.section \".rodata\"\n.align 1\n.L240:\n.byte 112\n.byte 117\n.byte 115\n.byte 104\n.byte 32\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.L238:\n.byte 108\n.byte 111\n.byte 97\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L236:\n.byte 110\n.byte 101\n.byte 103\n.byte 97\n.byte 116\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L234:\n.byte 100\n.byte 105\n.byte 118\n.byte 105\n.byte 100\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L232:\n.byte 109\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 121\n.byte 10\n.byte 0\n.align 1\n.L230:\n.byte 110\n.byte 101\n.byte 103\n.byte 97\n.byte 116\n.byte 101\n.byte 10\n.byte 97\n.byte 100\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L228:\n.byte 97\n.byte 100\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.L226:\n.byte 115\n.byte 116\n.byte 111\n.byte 114\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.L205:\n.byte 115\n.byte 121\n.byte 110\n.byte 116\n.byte 97\n.byte 120\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 0\n.align 1\n.L166:\n.byte 121\n.byte 97\n.byte 99\n.byte 99\n.byte 32\n.byte 115\n.byte 116\n.byte 97\n.byte 99\n.byte 107\n.byte 32\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 0\n.align 1\n.L158:\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.L18:\n.byte 98\n.byte 97\n.byte 100\n.byte 32\n.byte 115\n.byte 119\n.byte 105\n.byte 116\n.byte 99\n.byte 104\n.byte 32\n.byte 121\n.byte 121\n.byte 108\n.byte 111\n.byte 111\n.byte 107\n.byte 32\n.byte 37\n.byte 100\n.byte 0\n"
  },
  {
    "path": "lcc/src/2html.c",
    "content": "#include <assert.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <time.h>\n#include \"c.h\"\n#include \"rcc.h\"\n#if WIN32\n#include <fcntl.h>\n#include <io.h>\n#endif\n\n\nstatic void do_int(int x) {\n\tprintf(\"%d\", x);\n}\n\nstatic void do_scope(int x) {\n#define xx(c) if (x == c) { printf(#c); return; }\n\txx(CONSTANTS)\n\txx(LABELS)\n\txx(GLOBAL)\n\txx(PARAM)\n\txx(LOCAL)\n#undef xx\n\tif (x > LOCAL)\n\t\tprintf(\"LOCAL+%d\", x-LOCAL);\n\telse\n\t\tdo_int(x);\n}\n\nstatic void do_sclass(int x) {\n#define xx(c) if (x == c) { printf(#c); return; }\n\txx(REGISTER)\n\txx(AUTO)\n\txx(EXTERN)\n\txx(STATIC)\n\txx(TYPEDEF)\n#undef xx\n\tdo_int(x);\n}\n\nstatic void do_flags(int x) {\n\tchar *bar = \"\";\n#define xx(f,n) if ((x>>n)&1) { printf(\"%s\" #f, bar); bar = \"|\"; }\n\txx(structarg,0)\n\txx(addressed,1)\n\txx(computed,2)\n\txx(temporary,3)\n\txx(generated,4)\n#undef xx\n\tif (*bar == '\\0')\n\t\tdo_int(x);\n}\n\nstatic void do_seg(int x) {\n#define xx(s) if (x == s) { printf(#s); return; }\n\txx(CODE)\n\txx(BSS)\n\txx(DATA)\n\txx(LIT)\n#undef xx\n\tdo_int(x);\n}\n\n#define xx(ptr,field,type) do { printf(\"<li>\" #field \" = \"); do_##type(ptr->field); printf(\"</li>\\n\"); } while (0)\n\nstatic void do_op(int x) {\n\tstatic char *opnames[] = {\n\t\t\"\",\n\t\t\"CNST\",\n\t\t\"ARG\",\n\t\t\"ASGN\",\n\t\t\"INDIR\",\n\t\t\"CVC\",\n\t\t\"CVD\",\n\t\t\"CVF\",\n\t\t\"CVI\",\n\t\t\"CVP\",\n\t\t\"CVS\",\n\t\t\"CVU\",\n\t\t\"NEG\",\n\t\t\"CALL\",\n\t\t\"*LOAD*\",\n\t\t\"RET\",\n\t\t\"ADDRG\",\n\t\t\"ADDRF\",\n\t\t\"ADDRL\",\n\t\t\"ADD\",\n\t\t\"SUB\",\n\t\t\"LSH\",\n\t\t\"MOD\",\n\t\t\"RSH\",\n\t\t\"BAND\",\n\t\t\"BCOM\",\n\t\t\"BOR\",\n\t\t\"BXOR\",\n\t\t\"DIV\",\n\t\t\"MUL\",\n\t\t\"EQ\",\n\t\t\"GE\",\n\t\t\"GT\",\n\t\t\"LE\",\n\t\t\"LT\",\n\t\t\"NE\",\n\t\t\"JUMP\",\n\t\t\"LABEL\",\n\t\t\"AND\",\n\t\t\"NOT\",\n\t\t\"OR\",\n\t\t\"COND\",\n\t\t\"RIGHT\",\n\t\t\"FIELD\"\n\t};\n\tint op = opindex(x);\n\tif (op < 1 || op >= sizeof opnames/sizeof opnames[0])\n\t\tprintf(\"%d\", x);\n\telse\n\t\tprintf(\"%s\", opnames[op]);\n}\n\nstatic void do_define_uid(int x) {\n\tprintf(\"<strong id=uid%d>%d</strong>\", x, x);\n}\n\nstatic void do_define_label(int x) {\n\tprintf(\"<strong id=ll%d>%d</strong>\", x, x);\n}\n\nstatic void do_uid(int x) {\n\tprintf(\"<a href='#%d'>%d</a>\", x, x, x);\n}\n\nstatic void do_label(int x) {\n\tprintf(\"<a href='#L%d'>%d</a>\", x, x, x);\n}\n\nstatic int nextid;\n\nstatic void do_list(list_ty x, void do_one(void *), char *type, char *listhtml, char *separator) {\n\tint count = Seq_length(x);\n\n\tif (count == 0)\n\t\tprintf(\"<em>empty %s list</em>\\n\", type);\n\telse {\n\t\tint i;\n\t\tprintf(\"<em>%s list</em>\", type);\n\t\tif (listhtml != NULL)\n\t\t\tprintf(\"<%s>\\n\", listhtml);\n\t\tfor (i = 0; i < count; i++) {\n\t\t\tif (listhtml != NULL)\n\t\t\t\tprintf(\"<li>\");\n\t\t\tprintf(separator);\n\t\t\tdo_one(Seq_get(x, i));\n\t\t\tif (listhtml != NULL)\n\t\t\t\tprintf(\"</li>\\n\");\n\t\t}\n\t\tif (listhtml != NULL)\n\t\t\tprintf(\"</%s>\\n\", listhtml);\n\t}\n}\n\nstatic void do_uid_list(list_ty x) {\n\tint i, count = Seq_length(x);\n\n\tif (count == 0)\n\t\tprintf(\"<em>empty int list</em>\\n\");\n\telse {\n\t\tint i;\n\t\tprintf(\"<em>int list</em>\");\n\t\tfor (i= 0; i < count; i++) {\n\t\t\tprintf(\" \");\n\t\t\tdo_uid(*(int *)Seq_get(x, i));\n\t\t}\n\t}\n}\n\nstatic void do_identifier(const char *x) {\n\tprintf(\"%s\", x);\n}\n\nstatic void do_real(rcc_real_ty x) {\n\tdouble d;\n\tunsigned *p = (unsigned *)&d;\n\tstatic union { int x; char endian; } little = { 1 };\n\n\tp[1-little.endian] = x->msb;\n\tp[little.endian] = x->lsb;\n\tprintf(\"(%#X,%#X) = %g\", x->msb, x->lsb, d);\n}\n\nstatic void do_suffix(int x) {\n\tstatic char suffixes[] = \"0F234IUPVB\";\n\n\tif (x < 0 || x >= (sizeof suffixes/sizeof suffixes[0]) - 1)\n\t\tprintf(\"%d\", x);\n\telse\n\t\tprintf(\"%c\", suffixes[x]);\n}\n\nstatic void do_enum(void *x) {\n\trcc_enum__ty e = x;\n\n\tdo_identifier(e->id);\n\tprintf(\"=\");\n\tdo_int(e->value);\n}\n\nstatic void do_enum_list(list_ty x) {\n\tdo_list(x, do_enum, \"enum\", NULL, \" \");\n}\n\nstatic void do_field(void *x) {\n\trcc_field_ty f = x;\n\n\tprintf(\"<em>field</em><ul>\\n\");\n\txx(f,id,identifier);\n\txx(f,type,uid);\n\txx(f,offset,int);\n\txx(f,bitsize,int);\n\txx(f,lsb,int);\n\tprintf(\"</ul>\\n\");\n}\n\nstatic void do_field_list(list_ty x) {\n\tdo_list(x, do_field, \"field\", \"ol\", \"\");\n}\n\nstatic void do_symbol(rcc_symbol_ty x) {\n\tprintf(\"<em>symbol</em><ul>\\n\");\n\txx(x,id,identifier);\n\txx(x,type,uid);\n\txx(x,scope,scope);\n\txx(x,sclass,sclass);\n\txx(x,ref,int);\n\txx(x,flags,flags);\n\tprintf(\"</ul>\\n\");\n}\n\n#define caselabel(kind) case rcc_##kind##_enum: \\\n\tprintf(\"<strong>\" #kind \"</strong> : <em>%s</em>\", typename); \\\n\tprintf(\"<ul>\\n\"); attributes\n#define yy(kind,field,type) xx((&x->v.rcc_##kind),field,type)\n\nstatic void do_type(rcc_type_ty x) {\n#define attributes xx(x,size,int); xx(x,align,int)\n\tswitch (x->kind) {\n\tstatic char *typename = \"type\";\n\tcaselabel(INT); break;\n\tcaselabel(UNSIGNED); break;\n\tcaselabel(FLOAT); break;\n\tcaselabel(VOID); break;\n\tcaselabel(POINTER);\n\t\tyy(POINTER,type,uid);\n\t\tbreak;\n\tcaselabel(ENUM);\n\t\tyy(ENUM,tag,identifier);\n\t\tyy(ENUM,ids,enum_list);\n\t\tbreak;\n\tcaselabel(STRUCT);\n\t\tyy(STRUCT,tag,identifier);\n\t\tyy(STRUCT,fields,field_list);\n\t\tbreak;\n\tcaselabel(UNION);\n\t\tyy(UNION,tag,identifier);\n\t\tyy(UNION,fields,field_list);\n\t\tbreak;\n\tcaselabel(ARRAY);\n\t\tyy(ARRAY,type,uid);\n\t\tbreak;\n\tcaselabel(FUNCTION);\n\t\tyy(FUNCTION,type,uid);\n\t\tyy(FUNCTION,formals,uid_list);\n\t\tbreak;\n\tcaselabel(CONST);\n\t\tyy(CONST,type,uid);\n\t\tbreak;\n\tcaselabel(VOLATILE);\n\t\tyy(VOLATILE,type,uid);\n\t\tbreak;\n\tdefault: assert(0);\n\t}\n#undef attributes\n\tprintf(\"</ul>\\n\");\n}\n\nstatic void do_item(rcc_item_ty x) {\n\tprintf(\"<a name='%d'>\", x->uid);\n#define attributes xx(x,uid,define_uid)\n\tprintf(\"</a>\");\n\tswitch (x->kind) {\n\tstatic char *typename = \"item\";\n\tcaselabel(Symbol);\n\t\tyy(Symbol,symbol,symbol);\n\t\tbreak;\n\tcaselabel(Type);\n\t\tyy(Type,type,type);\n\t\tbreak;\n\tdefault: assert(0);\n\t}\n#undef attributes\n\tprintf(\"</ul>\\n\");\n}\n\nstatic void do_item_list(list_ty x) {\n\tint count = Seq_length(x);\n\n\tif (count == 0)\n\t\tprintf(\"<em>empty item list</em>\\n\");\n\telse {\n\t\tint i;\n\t\tprintf(\"<em>item list</em>\");\n\t\tprintf(\"<ol>\\n\");\n\t\tfor (i = 0; i < count; i++) {\n\t\t\trcc_item_ty item = Seq_get(x, i);\n\t\t\tprintf(\"<li value=%d>\", item->uid);\n\t\t\tdo_item(item);\n\t\t\tprintf(\"</li>\\n\");\n\t\t}\n\t\tprintf(\"</ol>\\n\");\n\t}\n}\n\nstatic void do_string(string_ty x) {\n\tprintf(\"%d,<code>'%s'</code>\", x.len, x.str);\n}\n\nstatic void do_generic_string(void *x) {\n\tdo_string(*(string_ty *)x);\n}\n\nstatic void do_string_list(list_ty x) {\n\tdo_list(x, do_generic_string, \"string\", \"ol\", \"\");\n}\n\nstatic void do_node(void *y) {\n\trcc_node_ty x = y;\n\n\tif (x->kind == rcc_LABEL_enum)\n\t\tprintf(\"<a name='L%d'></a>\", x->v.rcc_LABEL.label);\n#define attributes xx(x,suffix,suffix); xx(x,size,int)\n\tswitch (x->kind) {\n\tstatic char *typename = \"node\";\n\tcaselabel(CNST);\n\t\tyy(CNST,value,int);\n\t\tbreak;\n\tcaselabel(CNSTF);\n\t\tyy(CNSTF,value,real);\n\t\tbreak;\n\tcaselabel(ARG);\n\t\tyy(ARG,left,node);\n\t\tyy(ARG,len,int);\n\t\tyy(ARG,align,int);\n\t\tbreak;\n\tcaselabel(ASGN);\n\t\tyy(ASGN,left,node);\n\t\tyy(ASGN,right,node);\n\t\tyy(ASGN,len,int);\n\t\tyy(ASGN,align,int);\n\t\tbreak;\n\tcaselabel(CVT);\n\t\tyy(CVT,op,op);\n\t\tyy(CVT,left,node);\n\t\tyy(CVT,fromsize,int);\n\t\tbreak;\n\tcaselabel(CALL);\n\t\tyy(CALL,left,node);\n\t\tyy(CALL,type,uid);\n\t\tbreak;\n\tcaselabel(CALLB);\n\t\tyy(CALLB,left,node);\n\t\tyy(CALLB,right,node);\n\t\tyy(CALLB,type,uid);\n\t\tbreak;\n\tcaselabel(RET);\tbreak;\n\tcaselabel(ADDRG);\n\t\tyy(ADDRG,uid,uid);\n\t\tbreak;\n\tcaselabel(ADDRL);\n\t\tyy(ADDRL,uid,uid);\n\t\tbreak;\n\tcaselabel(ADDRF);\n\t\tyy(ADDRF,uid,uid);\n\t\tbreak;\n\tcaselabel(Unary);\n\t\tyy(Unary,op,op);\n\t\tyy(Unary,left,node);\n\t\tbreak;\n\tcaselabel(Binary);\n\t\tyy(Binary,op,op);\n\t\tyy(Binary,left,node);\n\t\tyy(Binary,right,node);\n\t\tbreak;\n\tcaselabel(Compare);\n\t\tyy(Compare,op,op);\n\t\tyy(Compare,left,node);\n\t\tyy(Compare,right,node);\n\t\tyy(Compare,label,label);\n\t\tbreak;\n\tcaselabel(LABEL);\n\t\tyy(LABEL,label,define_label);\n\t\tbreak;\n\tcaselabel(BRANCH);\n\t\tyy(BRANCH,label,label);\n\t\tbreak;\n\tcaselabel(CSE);\n\t\tyy(CSE,uid,uid);\n\t\tyy(CSE,node,node);\n\t\tbreak;\n\tdefault: assert(0);\n\t}\n#undef attributes\n\tprintf(\"</ul>\");\n}\n\nstatic void do_node_list(list_ty x) {\n\tdo_list(x, do_node, \"node\", \"ol\", \"\");\n}\n\nstatic void do_interface(void *);\n\nstatic void do_interface_list(list_ty x) {\n\tdo_list(x, do_interface, \"interface\", \"ol\", \"\");\n}\n\nstatic void do_interface(void *y) {\n\trcc_interface_ty x = y;\n\n\tif (x->kind == rcc_Address_enum)\n\t\tprintf(\"<a name='%d'></a>\", x->v.rcc_Address.uid);\n\telse if (x->kind == rcc_Local_enum)\n\t\tprintf(\"<a name='%d'></a>\", x->v.rcc_Local.uid);\n#define attributes\n\tswitch (x->kind) {\n\tstatic char *typename = \"interface\";\n\tcaselabel(Export);\n\t\tyy(Export,p,uid);\n\t\tbreak;\n\tcaselabel(Import);\n\t\tyy(Import,p,uid);\n\t\tbreak;\n\tcaselabel(Global);\n\t\tyy(Global,p,uid);\n\t\tyy(Global,seg,seg);\n\t\tbreak;\n\tcaselabel(Local);\n\t\tyy(Local,uid,define_uid);\n\t\tyy(Local,p,symbol);\n\t\tbreak;\n\tcaselabel(Address);\n\t\tyy(Address,uid,define_uid);\n\t\tyy(Address,q,symbol);\n\t\tyy(Address,p,uid);\n\t\tyy(Address,n,int);\n\t\tbreak;\n\tcaselabel(Segment);\n\t\tyy(Segment,seg,seg);\n\t\tbreak;\n\tcaselabel(Defaddress);\n\t\tyy(Defaddress,p,uid);\n\t\tbreak;\n\tcaselabel(Deflabel);\n\t\tyy(Deflabel,label,label);\n\t\tbreak;\n\tcaselabel(Defconst);\n\t\tyy(Defconst,suffix,suffix);\n\t\tyy(Defconst,size,int);\n\t\tyy(Defconst,value,int);\n\t\tbreak;\n\tcaselabel(Defconstf);\n\t\tyy(Defconstf,size,int);\n\t\tyy(Defconstf,value,real);\n\t\tbreak;\n\tcaselabel(Defstring);\n\t\tyy(Defstring,s,string);\n\t\tbreak;\n\tcaselabel(Space);\n\t\tyy(Space,n,int);\n\t\tbreak;\n\tcaselabel(Function);\n\t\tyy(Function,f,uid);\n\t\tyy(Function,caller,uid_list);\n\t\tyy(Function,callee,uid_list);\n\t\tyy(Function,ncalls,int);\n\t\tyy(Function,codelist,interface_list);\n\t\tbreak;\n\tcaselabel(Forest);\n\t\tyy(Forest,nodes,node_list);\n\t\tbreak;\n\tcase rcc_Blockbeg_enum: printf(\"<strong>Blockbeg</strong> : <em>%s</em>\", typename); return;\n\tcase rcc_Blockend_enum: printf(\"<strong>Blockend</strong> : <em>%s</em>\", typename); return;\n\tdefault: assert(0);\n\t}\n#undef attributes\n\tprintf(\"</ul>\\n\");\n}\n\nstatic void do_program(rcc_program_ty x) {\n\tprintf(\"<ul>\\n\");\n\txx(x,nuids,int);\n\txx(x,nlabels,int);\n\txx(x,items,item_list);\n\txx(x,interfaces,interface_list);\n\txx(x,argc,int);\n\txx(x,argv,string_list);\n\tprintf(\"</ul>\\n\");\n}\n\nint main(int argc, char *argv[]) {\n\tint i, version;\n\tfloat stamp = (assert(strstr(rcsid, \",v\")), strtod(strstr(rcsid, \",v\")+2, NULL))\n;\n\tchar *infile = NULL, *outfile = NULL;\n\trcc_program_ty pickle;\n\n\tfor (i = 1; i < argc; i++)\n\t\tif (*argv[i] != '-' || strcmp(argv[i], \"-\") == 0) {\n\t\t\tif (infile == NULL)\n\t\t\t\tinfile = argv[i];\n\t\t\telse if (outfile == NULL)\n\t\t\t\toutfile = argv[i];\n\t\t}\n\tif (infile != NULL && strcmp(infile, \"-\") != 0\n\t&& freopen(infile, \"rb\", stdin) == NULL) {\n\t\tfprintf(stderr, \"%s: can't read `%s'\\n\", argv[0], infile);\n\t\texit(EXIT_FAILURE);\n\t}\n\tif (infile == NULL || strcmp(infile, \"-\") == 0)\n\t\tinfile = \"Standard Input\";\n#if WIN32\n\telse\n\t\t_setmode(_fileno(stdin), _O_BINARY);\n#endif\n\tif (outfile != NULL && strcmp(outfile, \"-\") != 0\n\t&& freopen(outfile, \"w\", stdout) == NULL) {\n\t\tfprintf(stderr, \"%s: can't write `%s'\\n\", argv[0], outfile);\n\t\texit(EXIT_FAILURE);\n\t}\n\tversion = read_int(stdin);\n\tassert(version/100 == (int)stamp);\n\tpickle = rcc_read_program(stdin);\n\tprintf(\"<!DOCTYPE HTML PUBLIC \\\"-//W3C//DTD HTML 3.2 Final//EN\\\"\\n\");\n\tprintf(\"<html><head><title>%s</title>\\n\"\n\t\"<link rev=made href=\\\"mailto:drh@microsoft.com\\\">\\n\"\n\t\"</head><body>\\n<h1>%s</h1>\\n\",\tinfile, infile);\n\tprintf(\"<p>version = %d.%d</p>\", version/100, version%100);\n\tdo_program(pickle);\n\t{\n\t\ttime_t t;\n\t\ttime(&t);\n\t\tprintf(\"<hr><address>%s</address>\\n\", ctime(&t));\n\t}\n\tprintf(\"</body></html>\\n\");\n\treturn EXIT_SUCCESS;\n}\n"
  },
  {
    "path": "lcc/src/alloc.c",
    "content": "#include \"c.h\"\nstruct block {\n\tstruct block *next;\n\tchar *limit;\n\tchar *avail;\n};\nunion align {\n\tlong l;\n\tchar *p;\n\tdouble d;\n\tint (*f)(void);\n};\nunion header {\n\tstruct block b;\n\tunion align a;\n};\n#ifdef PURIFY\nunion header *arena[3];\n\nvoid *allocate(unsigned long n, unsigned a) {\n\tunion header *new = malloc(sizeof *new + n);\n\n\tassert(a < NELEMS(arena));\n\tif (new == NULL) {\n\t\terror(\"insufficient memory\\n\");\n\t\texit(1);\n\t}\n\tnew->b.next = (void *)arena[a];\n\tarena[a] = new;\n\treturn new + 1;\n}\n\nvoid deallocate(unsigned a) {\n\tunion header *p, *q;\n\n\tassert(a < NELEMS(arena));\n\tfor (p = arena[a]; p; p = q) {\n\t\tq = (void *)p->b.next;\n\t\tfree(p);\n\t}\n\tarena[a] = NULL;\n}\n\nvoid *newarray(unsigned long m, unsigned long n, unsigned a) {\n\treturn allocate(m*n, a);\n}\n#else\nstatic struct block\n\t first[] = {  { NULL },  { NULL },  { NULL } },\n\t*arena[] = { &first[0], &first[1], &first[2] };\nstatic struct block *freeblocks;\n\nvoid *allocate(unsigned long n, unsigned a) {\n\tstruct block *ap;\n\n\tassert(a < NELEMS(arena));\n\tassert(n > 0);\n\tap = arena[a];\n\tn = roundup(n, sizeof (union align));\n\twhile (n > ap->limit - ap->avail) {\n\t\tif ((ap->next = freeblocks) != NULL) {\n\t\t\tfreeblocks = freeblocks->next;\n\t\t\tap = ap->next;\n\t\t} else\n\t\t\t{\n\t\t\t\tunsigned m = sizeof (union header) + n + roundup(10*1024, sizeof (union align));\n\t\t\t\tap->next = malloc(m);\n\t\t\t\tap = ap->next;\n\t\t\t\tif (ap == NULL) {\n\t\t\t\t\terror(\"insufficient memory\\n\");\n\t\t\t\t\texit(1);\n\t\t\t\t}\n\t\t\t\tap->limit = (char *)ap + m;\n\t\t\t}\n\t\tap->avail = (char *)((union header *)ap + 1);\n\t\tap->next = NULL;\n\t\tarena[a] = ap;\n\n\t}\n\tap->avail += n;\n\treturn ap->avail - n;\n}\n\nvoid *newarray(unsigned long m, unsigned long n, unsigned a) {\n\treturn allocate(m*n, a);\n}\nvoid deallocate(unsigned a) {\n\tassert(a < NELEMS(arena));\n\tarena[a]->next = freeblocks;\n\tfreeblocks = first[a].next;\n\tfirst[a].next = NULL;\n\tarena[a] = &first[a];\n}\n#endif\n"
  },
  {
    "path": "lcc/src/alpha.md",
    "content": "%{\n#define INTTMP ((0xff<<1)|(1<<22)|(1<<25)|(1<<27))\n#define INTVAR (0x3f<<9)\n#define FLTTMP ((0x3f<<10)|(0x1ff<<22))\n#define FLTVAR (0xff<<2)\n\n#define INTRET 0x00000001\n#define FLTRET 0x00000003\n\n#define readsreg(p) \\\n        (generic((p)->op)==INDIR && (p)->kids[0]->op==VREG+P)\n#define setsrc(d) ((d) && (d)->x.regnode && \\\n        (d)->x.regnode->set == src->x.regnode->set && \\\n        (d)->x.regnode->mask&src->x.regnode->mask)\n\n#define relink(a, b) ((b)->x.prev = (a), (a)->x.next = (b))\n\n#include \"c.h\"\n#define NODEPTR_TYPE Node\n#define OP_LABEL(p) ((p)->op)\n#define LEFT_CHILD(p) ((p)->kids[0])\n#define RIGHT_CHILD(p) ((p)->kids[1])\n#define STATE_LABEL(p) ((p)->x.state)\nstatic void address(Symbol, Symbol, long);\nstatic void blkfetch(int, int, int, int);\nstatic void blkloop(int, int, int, int, int, int[]);\nstatic void blkstore(int, int, int, int);\nstatic void defaddress(Symbol);\nstatic void defconst(int, int, Value);\nstatic void defstring(int, char *);\nstatic void defsymbol(Symbol);\nstatic void doarg(Node);\nstatic void emit2(Node);\nstatic void export(Symbol);\nstatic void clobber(Node);\nstatic void function(Symbol, Symbol [], Symbol [], int);\nstatic void global(Symbol);\nstatic void import(Symbol);\nstatic void local(Symbol);\nstatic void progbeg(int, char **);\nstatic void progend(void);\nstatic void segment(int);\nstatic void space(int);\nstatic void target(Node);\nstatic Symbol ireg[32], freg[32];\nstatic Symbol iregw, fregw;\n\nstatic int tmpregs[] = {4, 2, 3};\nstatic Symbol blkreg;\n\nstatic int cseg;\n\nstatic char *currentfile;\n\n%}\n%start stmt\n%term CNSTF4=4113\n%term CNSTF8=8209\n%term CNSTF16=16401\n%term CNSTI1=1045\n%term CNSTI2=2069\n%term CNSTI4=4117\n%term CNSTI8=8213\n%term CNSTP4=4119\n%term CNSTP8=8215\n%term CNSTU1=1046\n%term CNSTU2=2070\n%term CNSTU4=4118\n%term CNSTU8=8214\n \n%term ARGB=41\n%term ARGF4=4129\n%term ARGF8=8225\n%term ARGF16=16417\n%term ARGI4=4133\n%term ARGI8=8229\n%term ARGP4=4135\n%term ARGP8=8231\n%term ARGU4=4134\n%term ARGU8=8230\n\n%term ASGNB=57\n%term ASGNF4=4145\n%term ASGNF8=8241\n%term ASGNF16=16433\n%term ASGNI1=1077\n%term ASGNI2=2101\n%term ASGNI4=4149\n%term ASGNI8=8245\n%term ASGNP4=4151\n%term ASGNP8=8247\n%term ASGNU1=1078\n%term ASGNU2=2102\n%term ASGNU4=4150\n%term ASGNU8=8246\n\n%term INDIRB=73\n%term INDIRF4=4161\n%term INDIRF8=8257\n%term INDIRF16=16449\n%term INDIRI1=1093\n%term INDIRI2=2117\n%term INDIRI4=4165\n%term INDIRI8=8261\n%term INDIRP4=4167\n%term INDIRP8=8263\n%term INDIRU1=1094\n%term INDIRU2=2118\n%term INDIRU4=4166\n%term INDIRU8=8262\n\n%term CVFF4=4209\n%term CVFF8=8305\n%term CVFF16=16497\n%term CVFI4=4213\n%term CVFI8=8309\n\n%term CVIF4=4225\n%term CVIF8=8321\n%term CVIF16=16513\n%term CVII1=1157\n%term CVII2=2181\n%term CVII4=4229\n%term CVII8=8325\n%term CVIU1=1158\n%term CVIU2=2182\n%term CVIU4=4230\n%term CVIU8=8326\n\n%term CVPP4=4247\n%term CVPP8=8343\n%term CVPP16=16535\n%term CVPU4=4246\n%term CVPU8=8342\n\n%term CVUI1=1205\n%term CVUI2=2229\n%term CVUI4=4277\n%term CVUI8=8373\n%term CVUP4=4279\n%term CVUP8=8375\n%term CVUP16=16567\n%term CVUU1=1206\n%term CVUU2=2230\n%term CVUU4=4278\n%term CVUU8=8374\n\n%term NEGF4=4289\n%term NEGF8=8385\n%term NEGF16=16577\n%term NEGI4=4293\n%term NEGI8=8389\n\n%term CALLB=217\n%term CALLF4=4305\n%term CALLF8=8401\n%term CALLF16=16593\n%term CALLI4=4309\n%term CALLI8=8405\n%term CALLP4=4311\n%term CALLP8=8407\n%term CALLU4=4310\n%term CALLU8=8406\n%term CALLV=216\n\n%term RETF4=4337\n%term RETF8=8433\n%term RETF16=16625\n%term RETI4=4341\n%term RETI8=8437\n%term RETP4=4343\n%term RETP8=8439\n%term RETU4=4342\n%term RETU8=8438\n%term RETV=248\n\n%term ADDRGP4=4359\n%term ADDRGP8=8455\n\n%term ADDRFP4=4375\n%term ADDRFP8=8471\n\n%term ADDRLP4=4391\n%term ADDRLP8=8487\n\n%term ADDF4=4401\n%term ADDF8=8497\n%term ADDF16=16689\n%term ADDI4=4405\n%term ADDI8=8501\n%term ADDP4=4407\n%term ADDP8=8503\n%term ADDU4=4406\n%term ADDU8=8502\n\n%term SUBF4=4417\n%term SUBF8=8513\n%term SUBF16=16705\n%term SUBI4=4421\n%term SUBI8=8517\n%term SUBP4=4423\n%term SUBP8=8519\n%term SUBU4=4422\n%term SUBU8=8518\n\n%term LSHI4=4437\n%term LSHI8=8533\n%term LSHU4=4438\n%term LSHU8=8534\n\n%term MODI4=4453\n%term MODI8=8549\n%term MODU4=4454\n%term MODU8=8550\n\n%term RSHI4=4469\n%term RSHI8=8565\n%term RSHU4=4470\n%term RSHU8=8566\n\n%term BANDI4=4485\n%term BANDI8=8581\n%term BANDU4=4486\n%term BANDU8=8582\n\n%term BCOMI4=4501\n%term BCOMI8=8597\n%term BCOMU4=4502\n%term BCOMU8=8598\n\n%term BORI4=4517\n%term BORI8=8613\n%term BORU4=4518\n%term BORU8=8614\n\n%term BXORI4=4533\n%term BXORI8=8629\n%term BXORU4=4534\n%term BXORU8=8630\n\n%term DIVF4=4545\n%term DIVF8=8641\n%term DIVF16=16833\n%term DIVI4=4549\n%term DIVI8=8645\n%term DIVU4=4550\n%term DIVU8=8646\n\n%term MULF4=4561\n%term MULF8=8657\n%term MULF16=16849\n%term MULI4=4565\n%term MULI8=8661\n%term MULU4=4566\n%term MULU8=8662\n\n%term EQF4=4577\n%term EQF8=8673\n%term EQF16=16865\n%term EQI4=4581\n%term EQI8=8677\n%term EQU4=4582\n%term EQU8=8678\n\n%term GEF4=4593\n%term GEF8=8689\n%term GEI4=4597\n%term GEI8=8693\n%term GEI16=16885\n%term GEU4=4598\n%term GEU8=8694\n\n%term GTF4=4609\n%term GTF8=8705\n%term GTF16=16897\n%term GTI4=4613\n%term GTI8=8709\n%term GTU4=4614\n%term GTU8=8710\n\n%term LEF4=4625\n%term LEF8=8721\n%term LEF16=16913\n%term LEI4=4629\n%term LEI8=8725\n%term LEU4=4630\n%term LEU8=8726\n\n%term LTF4=4641\n%term LTF8=8737\n%term LTF16=16929\n%term LTI4=4645\n%term LTI8=8741\n%term LTU4=4646\n%term LTU8=8742\n\n%term NEF4=4657\n%term NEF8=8753\n%term NEF16=16945\n%term NEI4=4661\n%term NEI8=8757\n%term NEU4=4662\n%term NEU8=8758\n\n%term JUMPV=584\n\n%term LABELV=600\n\n%term LOADB=233\n%term LOADF4=4321\n%term LOADF8=8417\n%term LOADF16=16609\n%term LOADI1=1253\n%term LOADI2=2277\n%term LOADI4=4325\n%term LOADI8=8421\n%term LOADP4=4327\n%term LOADP8=8423\n%term LOADU1=1254\n%term LOADU2=2278\n%term LOADU4=4326\n%term LOADU8=8422\n\n%term VREGP=711\n%%\nreg:  INDIRI1(VREGP)     \"# read register\\n\"\nreg:  INDIRU1(VREGP)     \"# read register\\n\"\n\nreg:  INDIRI2(VREGP)     \"# read register\\n\"\nreg:  INDIRU2(VREGP)     \"# read register\\n\"\n\nreg:  INDIRF4(VREGP)     \"# read register\\n\"\nreg:  INDIRI4(VREGP)     \"# read register\\n\"\nreg:  INDIRP4(VREGP)     \"# read register\\n\"\nreg:  INDIRU4(VREGP)     \"# read register\\n\"\n\nreg:  INDIRF8(VREGP)     \"# read register\\n\"\nreg:  INDIRI8(VREGP)     \"# read register\\n\"\nreg:  INDIRP8(VREGP)     \"# read register\\n\"\nreg:  INDIRU8(VREGP)     \"# read register\\n\"\n\nstmt: ASGNI1(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNU1(VREGP,reg)  \"# write register\\n\"\n\nstmt: ASGNI2(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNU2(VREGP,reg)  \"# write register\\n\"\n\nstmt: ASGNF4(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNI4(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNP4(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNU4(VREGP,reg)  \"# write register\\n\"\n\nstmt: ASGNF8(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNI8(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNP8(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNU8(VREGP,reg)  \"# write register\\n\"\ncon: CNSTI1  \"%a\"\ncon: CNSTU1  \"%a\"\n\ncon: CNSTI2  \"%a\"\ncon: CNSTU2  \"%a\"\n\ncon: CNSTI4  \"%a\"\ncon: CNSTU4  \"%a\"\ncon: CNSTP4  \"%a\"\n\ncon: CNSTI8  \"%a\"\ncon: CNSTU8  \"%a\"\ncon: CNSTP8  \"%a\"\nstmt: reg  \"\"\nacon: con     \"%0\"\nacon: ADDRGP8  \"%a\"\n\naddr: ADDI4(reg,acon)  \"%1($%0)\"\naddr: ADDI8(reg,acon)  \"%1($%0)\"\naddr: ADDU8(reg,acon)  \"%1($%0)\"\naddr: ADDP8(reg,acon)  \"%1($%0)\"\n\naddr: acon  \"%0\"\naddr: reg   \"($%0)\"\n\naddr: ADDRFP8  \"%a+%F($sp)\"\naddr: ADDRLP8  \"%a+%F($sp)\"\n\nreg: addr  \"lda $%c,%0\\n\"  1\n\nreg: CNSTI1  \"# reg\\n\"  range(a, 0, 0)\nreg: CNSTI2  \"# reg\\n\"  range(a, 0, 0)\nreg: CNSTI4  \"# reg\\n\"  range(a, 0, 0)\nreg: CNSTI8  \"# reg\\n\"  range(a, 0, 0)\nreg: CNSTU1  \"# reg\\n\"  range(a, 0, 0)\nreg: CNSTU2  \"# reg\\n\"  range(a, 0, 0)\nreg: CNSTU4  \"# reg\\n\"  range(a, 0, 0)\nreg: CNSTU8  \"# reg\\n\"  range(a, 0, 0)\nreg: CNSTP8  \"# reg\\n\"  range(a, 0, 0)\n\nstmt: ASGNI1(addr,reg)  \"stb $%1,%0\\n\"  1\nstmt: ASGNU1(addr,reg)  \"stb $%1,%0\\n\"  1\nstmt: ASGNI2(addr,reg)  \"stw $%1,%0\\n\"  1\nstmt: ASGNU2(addr,reg)  \"stw $%1,%0\\n\"  1\n\nstmt: ASGNI4(addr,reg)  \"stl $%1,%0\\n\"  1\nstmt: ASGNU4(addr,reg)  \"stl $%1,%0\\n\"  1\nstmt: ASGNI8(addr,reg)  \"stq $%1,%0\\n\"  1\nstmt: ASGNU8(addr,reg)  \"stq $%1,%0\\n\"  1\nstmt: ASGNP8(addr,reg)  \"stq $%1,%0\\n\"  1\n\nreg:  INDIRI1(reg)   \"ldb $%c,($%0)\\n\"  1\nreg:  INDIRI2(reg)   \"ldw $%c,($%0)\\n\"  1\nreg:  INDIRI4(addr)  \"ldl $%c,%0\\n\"  1\nreg:  INDIRI8(addr)  \"ldq $%c,%0\\n\"  1\nreg:  INDIRP8(addr)  \"ldq $%c,%0\\n\"  1\nreg:  INDIRU1(reg)   \"ldbu $%c,($%0)\\n\"  1\nreg:  INDIRU2(reg)   \"ldwu $%c,($%0)\\n\"  1\nreg:  INDIRU4(addr)  \"ldl $%c,%0\\nzap $%c,240,$%c\\n\"  2\nreg:  INDIRU8(addr)  \"ldq $%c,%0\\n\"  1\n\nreg:  CVII4(INDIRI1(reg))   \"ldb $%c,($%0)\\n\"  1\nreg:  CVII8(INDIRI1(reg))   \"ldb $%c,($%0)\\n\"  1\nreg:  CVII4(INDIRI2(reg))   \"ldw $%c,($%0)\\n\"  1\nreg:  CVII8(INDIRI2(reg))   \"ldw $%c,($%0)\\n\"  1\nreg:  CVII8(INDIRI4(addr))  \"ldl $%c,%0\\n\"  1\n\nreg:  CVUU4(INDIRU1(reg))   \"ldbu $%c,($%0)\\n\"  1\nreg:  CVUU8(INDIRU1(reg))   \"ldbu $%c,($%0)\\n\"  1\nreg:  CVUU4(INDIRU2(reg))   \"ldwu $%c,($%0)\\n\"  1\nreg:  CVUU8(INDIRU2(reg))   \"ldwu $%c,($%0)\\n\"  1\nreg:  CVUU8(INDIRU4(addr))  \"ldl $%c,%0\\nzap $%c,240,$%c\\n\"  2\n\nreg:  CVUI4(INDIRU1(reg))   \"ldbu $%c,($%0)\\n\"  1\nreg:  CVUI8(INDIRU1(reg))   \"ldbu $%c,($%0)\\n\"  1\nreg:  CVUI4(INDIRU2(reg))   \"ldwu $%c,($%0)\\n\"  1\nreg:  CVUI8(INDIRU2(reg))   \"ldwu $%c,($%0)\\n\"  1\nreg:  CVUI8(INDIRU4(addr))  \"ldl $%c,%0\\nzap $%c,240,$%c\\n\"  2\n\nreg:  CVIU8(reg)  \"mov $%0,$%c\\n\"  move(a)\n\nreg:  INDIRF4(addr)     \"lds $f%c,%0\\n\"  1\nreg:  INDIRF8(addr)     \"ldt $f%c,%0\\n\"  1\nstmt: ASGNF4(addr,reg)  \"sts $f%1,%0\\n\"  1\nstmt: ASGNF8(addr,reg)  \"stt $f%1,%0\\n\"  1\n\nreg: MULI4(reg,rc)  \"mull $%0,%1,$%c\\n\"   1\nreg: MULI8(reg,rc)  \"mulq $%0,%1,$%c\\n\"   1\nreg: MULU4(reg,rc)  \"mull $%0,%1,$%c\\nzap $%c,240,$%c\\n\"  2\nreg: MULU8(reg,rc)  \"mulq $%0,%1,$%c\\n\"   1\n\nreg: DIVI4(reg,rc)  \"divl $%0,%1,$%c\\n\"   1\nreg: DIVI8(reg,rc)  \"divq $%0,%1,$%c\\n\"   1\nreg: DIVU4(reg,rc)  \"divlu $%0,%1,$%c\\n\"  1\nreg: DIVU8(reg,rc)  \"divqu $%0,%1,$%c\\n\"  1\nreg: MODI4(reg,rc)  \"reml $%0,%1,$%c\\n\"   1\nreg: MODI8(reg,rc)  \"remq $%0,%1,$%c\\n\"   1\nreg: MODU4(reg,rc)  \"remlu $%0,%1,$%c\\n\"  1\nreg: MODU8(reg,rc)  \"remqu $%0,%1,$%c\\n\"  1\n\nrc:  con            \"%0\"\nrc:  reg            \"$%0\"\n\nreg: ADDI4(reg,rc)   \"addl $%0,%1,$%c\\n\"  1\nreg: ADDI8(reg,rc)   \"addq $%0,%1,$%c\\n\"  1\nreg: ADDP8(reg,rc)   \"addq $%0,%1,$%c\\n\"  1\nreg: ADDU4(reg,rc)   \"addl $%0,%1,$%c\\nzap $%c,240,$%c\\n\"  2\nreg: ADDU8(reg,rc)   \"addq $%0,%1,$%c\\n\"  1\nreg: SUBI4(reg,rc)   \"subl $%0,%1,$%c\\n\"  1\nreg: SUBI8(reg,rc)   \"subq $%0,%1,$%c\\n\"  1\nreg: SUBP8(reg,rc)   \"subq $%0,%1,$%c\\n\"  1\nreg: SUBU4(reg,rc)   \"subl $%0,%1,$%c\\nzap $%c,240,$%c\\n\"  2\nreg: SUBU8(reg,rc)   \"subq $%0,%1,$%c\\n\"  1\n\nreg: BANDI4(reg,rc)  \"and $%0,%1,$%c\\naddl $%c,0,$%c\\n\"   2\nreg: BANDI8(reg,rc)  \"and $%0,%1,$%c\\n\"   1\nreg: BANDU4(reg,rc)  \"and $%0,%1,$%c\\n\"   1\nreg: BANDU8(reg,rc)  \"and $%0,%1,$%c\\n\"   1\nreg: BORI4(reg,rc)   \"or $%0,%1,$%c\\naddl $%c,0,$%c\\n\"   2\nreg: BORI8(reg,rc)   \"or $%0,%1,$%c\\n\"    1\nreg: BORU4(reg,rc)   \"or $%0,%1,$%c\\n\"    1\nreg: BORU8(reg,rc)   \"or $%0,%1,$%c\\n\"    1\nreg: BXORI4(reg,rc)  \"xor $%0,%1,$%c\\naddl $%c,0,$%c\\n\"   2\nreg: BXORI8(reg,rc)  \"xor $%0,%1,$%c\\n\"   1\nreg: BXORU4(reg,rc)  \"xor $%0,%1,$%c\\n\"   1\nreg: BXORU8(reg,rc)  \"xor $%0,%1,$%c\\n\"   1\n\nrc6: CNSTI4         \"%a\"  range(a,0,63)\nrc6: CNSTI8         \"%a\"  range(a,0,63)\nrc6: reg            \"$%0\"\n\nreg: LSHI4(reg,rc6)  \"sll $%0,%1,$%c\\naddl $%c,0,$%c\\n\"   2\nreg: LSHI8(reg,rc6)  \"sll $%0,%1,$%c\\n\"  1\nreg: LSHU4(reg,rc6)  \"sll $%0,%1,$%c\\nzap $%c,240,$%c\\n\"  2\nreg: LSHU8(reg,rc6)  \"sll $%0,%1,$%c\\n\"  1\nreg: RSHI4(reg,rc6)  \"sra $%0,%1,$%c\\naddl $%c,0,$%c\\n\"   2\nreg: RSHI8(reg,rc6)  \"sra $%0,%1,$%c\\n\"  1\nreg: RSHU4(reg,rc6)  \"srl $%0,%1,$%c\\n\"  1\nreg: RSHU8(reg,rc6)  \"srl $%0,%1,$%c\\n\"  1\n\nreg: BCOMI4(reg)  \"not $%0,$%c\\naddl $%c,0,$%c\\n\"   2\nreg: BCOMU4(reg)  \"not $%0,$%c\\nzap $%c,240,$%c\\n\"  2\nreg: BCOMI8(reg)  \"not $%0,$%c\\n\"   1\nreg: BCOMU8(reg)  \"not $%0,$%c\\n\"   1\nreg: NEGI4(reg)   \"negl $%0,$%c\\n\"  1\nreg: NEGI8(reg)   \"negq $%0,$%c\\n\"  1\nreg: LOADI1(reg)  \"mov $%0,$%c\\n\"  move(a)\nreg: LOADI2(reg)  \"mov $%0,$%c\\n\"  move(a)\nreg: LOADI4(reg)  \"mov $%0,$%c\\n\"  move(a)\nreg: LOADI8(reg)  \"mov $%0,$%c\\n\"  move(a)\nreg: LOADP8(reg)  \"mov $%0,$%c\\n\"  move(a)\nreg: LOADU1(reg)  \"mov $%0,$%c\\n\"  move(a)\nreg: LOADU2(reg)  \"mov $%0,$%c\\n\"  move(a)\nreg: LOADU4(reg)  \"mov $%0,$%c\\n\"  move(a)\nreg: LOADU8(reg)  \"mov $%0,$%c\\n\"  move(a)\n\nreg: ADDF4(reg,reg)  \"adds $f%0,$f%1,$f%c\\n\"  1\nreg: ADDF8(reg,reg)  \"addt $f%0,$f%1,$f%c\\n\"  1\nreg: DIVF4(reg,reg)  \"divs $f%0,$f%1,$f%c\\n\"  1\nreg: DIVF8(reg,reg)  \"divt $f%0,$f%1,$f%c\\n\"  1\nreg: MULF4(reg,reg)  \"muls $f%0,$f%1,$f%c\\n\"  1\nreg: MULF8(reg,reg)  \"mult $f%0,$f%1,$f%c\\n\"  1\nreg: SUBF4(reg,reg)  \"subs $f%0,$f%1,$f%c\\n\"  1\nreg: SUBF8(reg,reg)  \"subt $f%0,$f%1,$f%c\\n\"  1\nreg: LOADF4(reg)     \"fmov $f%0,$f%c\\n\"       move(a)\nreg: LOADF8(reg)     \"fmov $f%0,$f%c\\n\"       move(a)\nreg: NEGF4(reg)      \"negs $f%0,$f%c\\n\"       1\nreg: NEGF8(reg)      \"negt $f%0,$f%c\\n\"       1\nreg: CVII4(reg)  \"sll $%0,8*(8-%a),$%c\\nsra $%c,8*(8-%a),$%c\\n\"  2\nreg: CVII8(reg)  \"sll $%0,8*(8-%a),$%c\\nsra $%c,8*(8-%a),$%c\\n\"  2\nreg: CVUI4(reg)  \"and $%0,(1<<(8*%a))-1,$%c\\n\"  1\nreg: CVUI8(reg)  \"and $%0,(1<<(8*%a))-1,$%c\\n\"  1\nreg: CVUU4(reg)  \"and $%0,(1<<(8*%a))-1,$%c\\n\"  1\nreg: CVUU8(reg)  \"and $%0,(1<<(8*%a))-1,$%c\\n\"  1\n\nreg: CVUP8(reg)  \"and $%0,(1<<(8*%a))-1,$%c\\n\"  1\n\nreg: CVFF4(reg)  \"cvtts $f%0,$f%c\\n\"  1\nreg: CVFF8(reg)  \"cvtst $f%0,$f%c\\n\"  1\n\nreg: CVIF4(reg)  \"stq $%0,-56+%F($sp)\\nldt $%f%c,-56+%F($sp)\\ncvtqs $f%c,$f%c\\n\"  3\nreg: CVIF8(reg)  \"stq $%0,-56+%F($sp)\\nldt $%f%c,-56+%F($sp)\\ncvtqt $f%c,$f%c\\n\"  3\nreg: CVIF4(INDIRI4(addr))  \"lds $f%c,%0\\ncvtlq $f%c,$f%c\\ncvtqs $f%c,$f%c\\n\"  3\nreg: CVIF4(INDIRI8(addr))  \"ldt $f%c,%0\\ncvtqs $f%c,$f%c\\n\"  2\nreg: CVIF8(INDIRI4(addr))  \"lds $f%c,%0\\ncvtlq $f%c,$f%c\\ncvtqt $f%c,$f%c\\n\"  3\nreg: CVIF8(INDIRI8(addr))  \"ldt $f%c,%0\\ncvtqt $f%c,$f%c\\n\"  2\n\nreg: CVFI4(reg)  \"cvttqc $f%0,$f1\\ncvtql $f1,$f1\\nsts $f1,-56+%F($sp)\\nldl $%c,-56+%F($sp)\\n\"  4\nreg: CVFI8(reg)  \"cvttqc $f%0,$f1\\nstt $f1,-56+%F($sp)\\nldq $%c,-56+%F($sp)\\n\"  3\n\nstmt: LABELV  \"%a:\\n\"\n\nstmt: JUMPV(acon)  \"br %0\\n\"   1\nstmt: JUMPV(reg)   \"jmp ($%0)\\n\"  1\n\nstmt: EQI4(reg,rc6)  \"cmpeq $%0,%1,$23\\nbne $23,%a\\n\"   2\nstmt: EQU4(reg,rc6)  \"cmpeq $%0,%1,$23\\nbne $23,%a\\n\"   2\nstmt: EQI8(reg,rc6)  \"cmpeq $%0,%1,$23\\nbne $23,%a\\n\"   2\nstmt: EQU8(reg,rc6)  \"cmpeq $%0,%1,$23\\nbne $23,%a\\n\"   2\nstmt: NEI4(reg,rc6)  \"cmpeq $%0,%1,$23\\nbeq $23,%a\\n\"   2\nstmt: NEU4(reg,rc6)  \"cmpeq $%0,%1,$23\\nbeq $23,%a\\n\"   2\nstmt: NEI8(reg,rc6)  \"cmpeq $%0,%1,$23\\nbeq $23,%a\\n\"   2\nstmt: NEU8(reg,rc6)  \"cmpeq $%0,%1,$23\\nbeq $23,%a\\n\"   2\nstmt: GEI4(reg,rc6)  \"cmplt $%0,%1,$23\\nbeq $23,%a\\n\"   2\nstmt: GEI8(reg,rc6)  \"cmplt $%0,%1,$23\\nbeq $23,%a\\n\"   2\nstmt: GEU4(reg,rc6)  \"cmpult $%0,%1,$23\\nbeq $23,%a\\n\"  1\nstmt: GEU8(reg,rc6)  \"cmpult $%0,%1,$23\\nbeq $23,%a\\n\"  1\nstmt: GTI4(reg,rc6)  \"cmple $%0,%1,$23\\nbeq $23,%a\\n\"   2\nstmt: GTI8(reg,rc6)  \"cmple $%0,%1,$23\\nbeq $23,%a\\n\"   2\nstmt: GTU4(reg,rc6)  \"cmpule $%0,%1,$23\\nbeq $23,%a\\n\"  1\nstmt: GTU8(reg,rc6)  \"cmpule $%0,%1,$23\\nbeq $23,%a\\n\"  1\nstmt: LEI4(reg,rc6)  \"cmple $%0,%1,$23\\nbne $23,%a\\n\"   2\nstmt: LEI8(reg,rc6)  \"cmple $%0,%1,$23\\nbne $23,%a\\n\"   2\nstmt: LEU4(reg,rc6)  \"cmpule $%0,%1,$23\\nbne $23,%a\\n\"  2\nstmt: LEU8(reg,rc6)  \"cmpule $%0,%1,$23\\nbne $23,%a\\n\"  2\nstmt: LTI4(reg,rc6)  \"cmplt $%0,%1,$23\\nbne $23,%a\\n\"   2\nstmt: LTI8(reg,rc6)  \"cmplt $%0,%1,$23\\nbne $23,%a\\n\"   2\nstmt: LTU4(reg,rc6)  \"cmpult $%0,%1,$23\\nbne $23,%a\\n\"  2\nstmt: LTU8(reg,rc6)  \"cmpult $%0,%1,$23\\nbne $23,%a\\n\"  2\n\nstmt: EQF4(reg,reg)  \"cmpteq $f%0,$f%1,$f1\\nfbne $f1,%a\\n\"  2\nstmt: EQF8(reg,reg)  \"cmpteq $f%0,$f%1,$f1\\nfbne $f1,%a\\n\"  2\nstmt: LEF4(reg,reg)  \"cmptle $f%0,$f%1,$f1\\nfbne $f1,%a\\n\"  2\nstmt: LEF8(reg,reg)  \"cmptle $f%0,$f%1,$f1\\nfbne $f1,%a\\n\"  2\nstmt: LTF4(reg,reg)  \"cmptlt $f%0,$f%1,$f1\\nfbne $f1,%a\\n\"  2\nstmt: LTF8(reg,reg)  \"cmptlt $f%0,$f%1,$f1\\nfbne $f1,%a\\n\"  2\n\nstmt: NEF4(reg,reg)  \"cmpteq $f%0,$f%1,$f1\\nfbeq $f1,%a\\n\"  2\nstmt: NEF8(reg,reg)  \"cmpteq $f%0,$f%1,$f1\\nfbeq $f1,%a\\n\"  2\nstmt: GEF4(reg,reg)  \"cmptlt $f%0,$f%1,$f1\\nfbeq $f1,%a\\n\"  2\nstmt: GEF8(reg,reg)  \"cmptlt $f%0,$f%1,$f1\\nfbeq $f1,%a\\n\"  2\nstmt: GTF4(reg,reg)  \"cmptle $f%0,$f%1,$f1\\nfbeq $f1,%a\\n\"  2\nstmt: GTF8(reg,reg)  \"cmptle $f%0,$f%1,$f1\\nfbeq $f1,%a\\n\"  2\n\nar:   ADDRGP8     \"%a\"\nar:   reg    \"($%0)\"\n\nreg:  CALLF4(ar)  \"jsr $26,%0\\nldgp $gp,0($26)\\n\"  2\nreg:  CALLF8(ar)  \"jsr $26,%0\\nldgp $gp,0($26)\\n\"  2\nreg:  CALLI4(ar)  \"jsr $26,%0\\nldgp $gp,0($26)\\n\"  2\nreg:  CALLI8(ar)  \"jsr $26,%0\\nldgp $gp,0($26)\\n\"  2\nreg:  CALLP8(ar)  \"jsr $26,%0\\nldgp $gp,0($26)\\n\"  2\nreg:  CALLU4(ar)  \"jsr $26,%0\\nldgp $gp,0($26)\\n\"  2\nreg:  CALLU8(ar)  \"jsr $26,%0\\nldgp $gp,0($26)\\n\"  2\nstmt: CALLV(ar)  \"jsr $26,%0\\nldgp $gp,0($26)\\n\"  2\n\nstmt: RETF4(reg)  \"# ret\\n\"  1\nstmt: RETF8(reg)  \"# ret\\n\"  1\nstmt: RETI4(reg)  \"# ret\\n\"  1\nstmt: RETU4(reg)  \"# ret\\n\"  1\nstmt: RETI8(reg)  \"# ret\\n\"  1\nstmt: RETU8(reg)  \"# ret\\n\"  1\nstmt: RETP8(reg)  \"# ret\\n\"  1\nstmt: RETV(reg)   \"# ret\\n\"  1\n\nstmt: ARGF4(reg)  \"# arg\\n\"  1\nstmt: ARGF8(reg)  \"# arg\\n\"  1\nstmt: ARGI4(reg)  \"# arg\\n\"  1\nstmt: ARGI8(reg)  \"# arg\\n\"  1\nstmt: ARGP8(reg)  \"# arg\\n\"  1\nstmt: ARGU4(reg)  \"# arg\\n\"  1\nstmt: ARGU8(reg)  \"# arg\\n\"  1\n\nstmt: ARGB(INDIRB(reg))       \"# argb %0\\n\"      1\nstmt: ASGNB(reg,INDIRB(reg))  \"# asgnb %0 %1\\n\"  1\n\n%%\nstatic void progend(void){}\n\nstatic void progbeg(int argc, char *argv[]) {\n        int i;\n\n        {\n                union {\n                        char c;\n                        int i;\n                } u;\n                u.i = 0;\n                u.c = 1;\n                swap = ((int)(u.i == 1)) != IR->little_endian;\n        }\n        parseflags(argc, argv);\n\n        for (i = 0; i < 32; i++)\n                freg[i] = mkreg(\"%d\", i, 1, FREG);\n        for (i = 0; i < 32; i++)\n                ireg[i]  = mkreg(\"%d\", i, 1, IREG);\n        ireg[29]->x.name = \"gp\";\n        ireg[30]->x.name = \"sp\";\n        fregw = mkwildcard(freg);\n        iregw = mkwildcard(ireg);\n\n        tmask[IREG] = INTTMP; tmask[FREG] = FLTTMP;\n        vmask[IREG] = INTVAR; vmask[FREG] = FLTVAR;\n\n        blkreg = mkreg(\"1\", 1, 0xf, IREG);\n\n}\n\nstatic Symbol rmap(int opk) {\n        switch (optype(opk)) {\n        case I: case U: case P: case B:\n                return iregw;\n        case F:\n                return fregw;\n        default:\n                return 0;\n        }\n}\n\nstatic Symbol argreg(int offset, int ty) {\n        if (offset >= 48)\n                return NULL;\n        else if (ty == F)\n                return freg[(offset/8) + 16];\n        else\n                return ireg[(offset/8) + 16];\n}\n\nstatic void target(Node p) {\n        assert(p);\n        switch (specific(p->op)) {\n        case CNST+I: case CNST+U: case CNST+P:\n                if (range(p, 0, 0) == 0) {\n                        setreg(p, ireg[31]);\n                        p->x.registered = 1;\n                }\n                break;\n        case CNST+F:\n                if (p->syms[0]->u.c.v.d == 0) {\n                        setreg(p, freg[31]);\n                        p->x.registered = 1;\n                }\n                break;\n\n        case CALL+V:\n                rtarget(p, 0, ireg[27]);\n                break;\n        case CALL+F:\n                rtarget(p, 0, ireg[27]);\n                setreg(p, freg[0]);\n                break;\n        case CALL+I: case CALL+P: case CALL+U:\n                rtarget(p, 0, ireg[27]);\n                setreg(p, ireg[0]);\n                break;\n        case RET+F:\n                rtarget(p, 0, freg[0]);\n                break;\n        case RET+I: case RET+U: case RET+P:\n                rtarget(p, 0, ireg[0]);\n                break;\n\n        case ARG+F: case ARG+I: case ARG+P: case ARG+U: {\n                Symbol q = argreg(p->syms[2]->u.c.v.i, optype(p->op));\n                if (q)\n                        rtarget(p, 0, q);\n                break;\n                }\n\n\n        case ASGN+B: rtarget(p->kids[1], 0, blkreg); break;\n        case ARG+B:  rtarget(p->kids[0], 0, blkreg); break;\n\n        }\n}\n\nstatic void clobber(Node p) {\n        assert(p);\n        switch (specific(p->op)) {\n        case ASGN+I: case ASGN+U:\n                if (opsize(p->op) <= 2)\n                        spill(1<<24, IREG, p);\n                break;\n\n        case DIV+I: case DIV+U: case MOD+I: case MOD+U:\n                spill(((1<<27)|(3<<24))&~p->syms[RX]->x.regnode->mask, IREG, p);\n                break;\n\n        case CALL+F:\n                spill(INTTMP | INTRET, IREG, p);\n                spill(FLTTMP,          FREG, p);\n                break;\n        case CALL+I: case CALL+P: case CALL+U:\n                spill(INTTMP,          IREG, p);\n                spill(FLTTMP | FLTRET, FREG, p);\n                break;\n        case CALL+V:\n                spill(INTTMP | INTRET, IREG, p);\n                spill(FLTTMP | FLTRET, FREG, p);\n                break;\n\n        }\n}\n\nstatic void emit2(Node p) {\n        int dst, n, src, sz, ty;\n        static int ty0;\n        Symbol q;\n\n        switch (specific(p->op)) {\n        case ARG+F: case ARG+I: case ARG+P: case ARG+U:\n                ty = optype(p->op);\n                sz = opsize(p->op);\n                q = argreg(p->syms[2]->u.c.v.i, ty);\n                src = getregnum(p->x.kids[0]);\n                if (q)\n                        break;\n                else if (ty == F && sz == 4)\n                        print(\"sts $f%d,%d($sp)\\n\", src, p->syms[2]->u.c.v.i - 48);\n                else if (ty == F && sz == 8)\n                        print(\"stt $f%d,%d($sp)\\n\", src, p->syms[2]->u.c.v.i - 48);\n                else if (sz == 4)\n                        print(\"stq $%d,%d($sp)\\n\", src, p->syms[2]->u.c.v.i - 48);\n                else if (sz == 8)\n                        print(\"stq $%d,%d($sp)\\n\", src, p->syms[2]->u.c.v.i - 48);\n                else\n                        assert(0);\n                break;\n\n        case ASGN+B:\n                dalign = salign = p->syms[1]->u.c.v.i;\n                blkcopy(getregnum(p->x.kids[0]), 0,\n                        getregnum(p->x.kids[1]), 0,\n                        p->syms[0]->u.c.v.i, tmpregs);\n                break;\n\n\n        case ARG+B: {\n                int doff = p->syms[2]->u.c.v.i, soff = 0, sreg = getregnum(p->x.kids[0]);\n                dalign = 8;\n                salign = p->syms[1]->u.c.v.i;\n                n = p->syms[0]->u.c.v.i;\n                for ( ; doff <= 40 && n > 0; doff += 8) {\n                        print(\"uldq $%d,%d($%d)\\n\", (doff/8)+16, soff, sreg);\n                        soff += 8;\n                        n -= 8;\n                }\n                if (n > 0)\n                        blkcopy(30, doff - 48, sreg, soff, n, tmpregs);\n                break;\n                }\n\n        }\n}\n\nstatic void doarg(Node p) {\n        p->syms[2] = intconst(mkactual(8, roundup(p->syms[0]->u.c.v.i,8)));\n}\n\nstatic void local(Symbol p) {\n        if (askregvar(p, rmap(ttob(p->type))) == 0)\n                mkauto(p);\n}\n\nstatic int bitcount(unsigned mask) {\n        unsigned i, n = 0;\n\n        for (i = 1; i; i <<= 1)\n                if (mask&i)\n                        n++;\n        return n;\n}\n\nstatic void function(Symbol f, Symbol caller[], Symbol callee[], int ncalls) {\n        int i, sizeargs, saved, sizefsave, sizeisave, varargs;\n        Symbol r, argregs[6];\n\n        usedmask[0] = usedmask[1] = 0;\n        freemask[0] = freemask[1] = ~(unsigned)0;\n        maxargoffset = offset = maxoffset = 0;\n\n        for (i = 0; callee[i]; i++)\n                ;\n        varargs = variadic(f->type)\n                || i > 0 && strcmp(callee[i-1]->name, \"va_alist\") == 0;\n        if (varargs)\n                sizeargs = 2*48;\n        else\n                sizeargs = 48;\n\n        for (i = 0; callee[i]; i++) {\n                Symbol p = callee[i];\n                Symbol q = caller[i];\n                assert(q);\n                if (isfloat(p->type) && varargs) {\n                        p->x.offset = q->x.offset = offset - 2*48;\n                        p->x.name = q->x.name = stringd(offset - 2*48);\n                } else {\n                        p->x.offset = q->x.offset = offset - 48;\n                        p->x.name = q->x.name = stringd(offset - 48);\n                }\n                offset = roundup(offset, q->type->align);\n                r = argreg(offset, optype(ttob(q->type)));\n                if (i < 6)\n                        argregs[i] = r;\n                offset = roundup(offset + q->type->size, 8);\n                if (varargs)\n                        p->sclass = AUTO;\n                else if (r && ncalls == 0 && !isstruct(q->type) && !p->addressed\n) {\n                        p->sclass = q->sclass = REGISTER;\n                        askregvar(p, r);\n                        assert(p->x.regnode && p->x.regnode->vbl == p);\n                        q->x = p->x;\n                        q->type = p->type;\n                } else if (askregvar(p, rmap(ttob(p->type)))\n                           && r != NULL /*\n                           && (isint(p->type) || p->type == q->type) */\n) {\n                        assert(q->sclass != REGISTER);\n                        p->sclass = q->sclass = REGISTER;\n                        q->type = p->type;\n                }\n\n        }\n        assert(!caller[i]);\n\n        offset = sizeargs + 8;\n        gencode(caller, callee);\n        usedmask[IREG] &= ~(INTTMP|(0x3f<<16)|INTRET);\n        usedmask[FREG] &= ~(FLTTMP|(0x3f<<16)|FLTRET);\n        if (ncalls || usedmask[IREG] || usedmask[FREG])\n                usedmask[IREG] |= 1<<26;\n        sizefsave = 8*bitcount(usedmask[FREG]);\n        sizeisave = 8*bitcount(usedmask[IREG]);\n        if (maxargoffset > 48)\n                maxargoffset -= 48;\n        else\n                maxargoffset = 0;\n        if (maxoffset < sizeargs)\n                maxoffset = sizeargs;\n        framesize = roundup(maxargoffset + sizefsave + sizeisave + maxoffset, 16);\n        segment(CODE);\n        print(\".ent %s\\n\", f->x.name);\n        print(\"%s:\\n\", f->x.name);\n        print(\"ldgp $gp,0($27)\\n\");\n        i = maxargoffset + sizefsave - framesize;\n        if (framesize > 0)\n                print(\"lda $sp,%d($sp)\\n\", -framesize);\n        if (usedmask[FREG])\n                print(\".fmask 0x%x,%d\\n\", usedmask[FREG], i - 8);\n        if (usedmask[IREG])\n                print(\".mask 0x%x,%d\\n\",  usedmask[IREG], i + sizeisave - 8);\n        print(\".frame $sp,%d,$26,%d\\n\", framesize, sizeargs);\n\n        saved = maxargoffset;\n        for (i = 2; i <= 9; i++)\n                if (usedmask[FREG]&(1<<i)) {\n                        print(\"stt $f%d,%d($sp)\\n\", i, saved);\n                        saved += 8;\n                }\n\n        for (i = 9; i <= 26; i++)\n                if (usedmask[IREG]&(1<<i)) {\n                        print(\"stq $%d,%d($sp)\\n\", i, saved);\n                        saved += 8;\n                }\n        for (i = 0; i < 6 && callee[i]; i++) {\n                r = argregs[i];\n                if (r && r->x.regnode != callee[i]->x.regnode) {\n                        Symbol out = callee[i];\n                        Symbol in  = caller[i];\n                        int rn = r->x.regnode->number;\n                        int rs = r->x.regnode->set;\n                        int tyin = ttob(in->type);\n\n                        assert(out && in && r && r->x.regnode);\n                        assert(out->sclass != REGISTER || out->x.regnode);\n                        if (out->sclass == REGISTER) {\n                                if (rs == FREG)\n                                        print(\"fmov $f%d,$f%d\\n\", rn, out->x.regnode->number);\n                                else\n                                        print(\"mov $%d,$%d\\n\", rn, out->x.regnode->number);\n\n                        } else {\n                                int off = in->x.offset + framesize;\n                                if (rs == FREG && tyin == F+sizeop(8))\n                                        print(\"stt $f%d,%d($sp)\\n\", rn, off);\n                                else if (rs == FREG && tyin == F+sizeop(4))\n                                        print(\"sts $f%d,%d($sp)\\n\", rn, off);\n                                else {\n                                        int i, n = (in->type->size + 7)/8;\n                                        for (i = rn; i < rn+n && i <= 21; i++)\n                                                print(\"stq $%d,%d($sp)\\n\", i, off + (i-rn)*8);\n                                }\n\n                        }\n\n                }\n        }\n        if (varargs && callee[i-1]) {\n                i = callee[i-1]->x.offset + roundup(callee[i-1]->type->size, 8);\n                for (i = (48+i)/8; i < 6; i++) {\n                        print(\"stq $%d,%d($sp)\\n\",  i + 16, framesize -   48 + 8*i);\n                        print(\"stt $f%d,%d($sp)\\n\", i + 16, framesize - 2*48 + 8*i);\n                }\n        }\n        print(\".prologue 1\\n\");\n\n        emitcode();\n        saved = maxargoffset;\n        for (i = 2; i <= 9; i++)\n                if (usedmask[FREG]&(1<<i)) {\n                        print(\"ldt $f%d,%d($sp)\\n\", i, saved);\n                        saved += 8;\n                }\n        for (i = 9; i <= 26; i++)\n                if (usedmask[IREG]&(1<<i)) {\n                        print(\"ldq $%d,%d($sp)\\n\", i, saved);\n                        saved += 8;\n                }\n        if (framesize > 0)\n                print(\"lda $sp,%d($sp)\\n\", framesize);\n        print(\"ret\\n\");\n        print(\".end %s\\n\", f->x.name);\n\n}\n\nstatic void defconst(int suffix, int size, Value v) {\n        if (suffix == F && size == 4) {\n                float f = v.d;\n                print(\".long 0x%x\\n\", *(unsigned *)&f);\n        } else if (suffix == F && size == 8) {\n                double d = v.d;\n                unsigned *p = (unsigned *)&d;\n                print(\".long 0x%x\\n.long 0x%x\\n\", p[swap], p[!swap]);\n        } else if (suffix == P)\n                print(\".quad 0x%X\\n\", v.p);\n        else if (size == 1)\n                print(\".byte 0x%x\\n\", suffix == I ? v.i : v.u);\n        else if (size == 2)\n                print(\".word 0x%x\\n\", suffix == I ? v.i&0xFFFF : v.u&0xFFFF);\n        else if (size == 4)\n                print(\".long 0x%x\\n\", suffix == I ? v.i : v.u);\n        else if (size == 8)\n                print(\".quad 0x%X\\n\", suffix == I ? v.i : v.u);\n\n}\n\nstatic void defaddress(Symbol p) {\n        print(\".quad %s\\n\", p->x.name);\n}\n\nstatic void defstring(int n, char *str) {\n        char *s;\n\n        for (s = str; s < str + n; s++)\n                print(\".byte %d\\n\", (*s)&0377);\n}\n\nstatic void export(Symbol p) {\n        print(\".globl %s\\n\", p->x.name);\n}\n\nstatic void import(Symbol p) {\n        if (!isfunc(p->type))\n                print(\".extern %s %d\\n\", p->name, p->type->size);\n}\n\nstatic void defsymbol(Symbol p) {\n        if (p->scope >= LOCAL && p->sclass == STATIC)\n                p->x.name = stringf(\"L.%d\", genlabel(1));\n        else if (p->generated)\n                p->x.name = stringf(\"L.%s\", p->name);\n        else\n                assert(p->scope != CONSTANTS || isint(p->type) || isptr(p->type)),\n                p->x.name = p->name;\n}\n\nstatic void address(Symbol q, Symbol p, long n) {\n        if (p->scope == GLOBAL\n        || p->sclass == STATIC || p->sclass == EXTERN)\n                q->x.name = stringf(\"%s%s%D\", p->x.name,\n                        n >= 0 ? \"+\" : \"\", n);\n        else {\n                assert(n <= INT_MAX && n >= INT_MIN);\n                q->x.offset = p->x.offset + n;\n                q->x.name = stringd(q->x.offset);\n        }\n}\n\nstatic void global(Symbol p) {\n        if (p->u.seg == DATA || p->u.seg == LIT) {\n                assert(p->type->align <= 8);\n                print(\".align %c\\n\", \".01.2...3\"[p->type->align]);\n                print(\"%s:\\n\", p->x.name);\n        } else if (p->sclass == STATIC || Aflag >= 2)\n                print(\".lcomm %s,%d\\n\", p->x.name, p->type->size);\n        else\n                print( \".comm %s,%d\\n\", p->x.name, p->type->size);\n}\n\nstatic void segment(int n) {\n        cseg = n;\n        switch (n) {\n        case DATA: print(\".sdata\\n\"); break;\n        case CODE: print(\".text\\n\");  break;\n        case LIT:  print(\".rdata\\n\"); break;\n        }\n}\n\nstatic void space(int n) {\n        if (cseg != BSS)\n                print(\".space %d\\n\", n);\n}\n\nstatic void blkloop(int dreg, int doff, int sreg, int soff, int size, int tmps[]) {\n        int lab = genlabel(1);\n\n        print(\"addq $%d,%d,$%d\\n\",   sreg, size&~7, sreg);\n        print(\"addq $%d,%d,$%d\\n\",   dreg, size&~7, tmps[2]);\n        blkcopy(tmps[2], doff, sreg, soff, size&7, tmps);\n        print(\"L.%d:\\n\", lab);\n        print(\"addq $%d,%d,$%d\\n\",    sreg, -8, sreg);\n        print(\"addq $%d,%d,$%d\\n\", tmps[2], -8, tmps[2]);\n        blkcopy(tmps[2], doff, sreg, soff, 8, tmps);\n        print(\"cmpult $%d,$%d,$23\\nbne $23,L.%d\\n\", dreg, tmps[2], lab);\n}\n\nstatic void blkfetch(int size, int off, int reg, int tmp) {\n        assert(size == 1 || size == 2 || size == 4 || size == 8);\n        if (size == 1)\n                print(\"ldb $%d,%d($%d)\\n\",  tmp, off, reg);\n        else if (size == 2)\n                print(\"ldw $%d,%d($%d)\\n\",  tmp, off, reg);\n        else if (salign >= size && size == 4)\n                print(\"ldl $%d,%d($%d)\\n\",  tmp, off, reg);\n        else if (salign >= size && size == 8)\n                print(\"ldq $%d,%d($%d)\\n\",  tmp, off, reg);\n        else if (size == 4)\n                print(\"uldl $%d,%d($%d)\\n\", tmp, off, reg);\n        else\n                print(\"uldq $%d,%d($%d)\\n\", tmp, off, reg);\n}\n\nstatic void blkstore(int size, int off, int reg, int tmp) {\n        assert(size == 1 || size == 2 || size == 4 || size == 8);\n        if (size == 1)\n                print(\"stb $%d,%d($%d)\\n\",  tmp, off, reg);\n        else if (size == 2)\n                print(\"stw $%d,%d($%d)\\n\",  tmp, off, reg);\n        else if (dalign >= size && size == 4)\n                print(\"stl $%d,%d($%d)\\n\",  tmp, off, reg);\n        else if (dalign >= size && size == 8)\n                print(\"stq $%d,%d($%d)\\n\",  tmp, off, reg);\n        else if (size == 4)\n                print(\"ustl $%d,%d($%d)\\n\", tmp, off, reg);\n        else\n                print(\"ustq $%d,%d($%d)\\n\", tmp, off, reg);\n}\n\n/* stabinit - initialize stab output */\nstatic void stabinit(char *file, int argc, char *argv[]) {\n        if (file) {\n                print(\".file 2,\\\"%s\\\"\\n\", file);\n                currentfile = file;\n        }\n}\n\n/* stabline - emit stab entry for source coordinate *cp */\nstatic void stabline(Coordinate *cp) {\n        if (cp->file && cp->file != currentfile) {\n                print(\".file 2,\\\"%s\\\"\\n\", cp->file);\n                currentfile = cp->file;\n        }\n        print(\".loc 2,%d\\n\", cp->y);\n}\n\n/* stabsym - output a stab entry for symbol p */\nstatic void stabsym(Symbol p) {\n        if (p == cfunc && IR->stabline)\n                (*IR->stabline)(&p->src);\n}\nInterface alphaIR = {\n        1, 1, 0,  /* char */\n        2, 2, 0,  /* short */\n        4, 4, 0,  /* int */\n        8, 8, 0,  /* long */\n        8, 8, 0,  /* long long */\n        4, 4, 1,  /* float */\n        8, 8, 1,  /* double */\n        8, 8, 1,  /* long double */\n        8, 8, 0,  /* T * */\n        0, 1, 0,  /* struct */\n\n        1,      /* little_endian */\n        0,  /* mulops_calls */\n        0,  /* wants_callb */\n        1,  /* wants_argb */\n        1,  /* left_to_right */\n        0,  /* wants_dag */\n        0,  /* unsigned_char */\n        address,\n        blockbeg,\n        blockend,\n        defaddress,\n        defconst,\n        defstring,\n        defsymbol,\n        emit,\n        export,\n        function,\n        gen,\n        global,\n        import,\n        local,\n        progbeg,\n        progend,\n        segment,\n        space,\n        0, 0, 0, stabinit, stabline, stabsym, 0,\n        {\n                1,      /* max_unaligned_load */\n                rmap,\n                blkfetch, blkstore, blkloop,\n                _label,\n                _rule,\n                _nts,\n                _kids,\n                _string,\n                _templates,\n                _isinstruction,\n                _ntname,\n                emit2,\n                doarg,\n                target,\n                clobber,\n\n        }\n\n};\n\n\nstatic char rcsid[] = \"$Id: alpha.md 145 2001-10-17 21:53:10Z timo $\";\n\n"
  },
  {
    "path": "lcc/src/asdl.c",
    "content": "#include \"c.h\"\n#include \"rcc.h\"\n#if WIN32\n#include <fcntl.h>\n#include <io.h>\n#endif\n\n\nstatic list_ty interfaces;\nstatic rcc_program_ty pickle;\n\nchar *string(const char *str) {\n\treturn (char *)Atom_string(str);\n}\n\nchar *stringd(long n) {\n\treturn (char *)Atom_int(n);\n}\n\nchar *stringn(const char *str, int len) {\n\treturn (char *)Atom_new(str, len);\n}\n\nstatic void put(rcc_interface_ty node) {\n\tSeq_addhi(interfaces, node);\n}\n\nstatic int typeuid(Type ty) {\n\trcc_type_ty type;\n\n\tassert(ty);\n\tif (ty->x.typeno != 0)\n\t\treturn ty->x.typeno;\n\tty->x.typeno = pickle->nuids++;\n\tswitch (ty->op) {\n#define xx(op) case op: type = rcc_##op(ty->size, ty->align); break\n\txx(INT);\n\txx(UNSIGNED);\n\txx(FLOAT);\n\txx(VOID);\n#undef xx\n#define xx(op) case op: type = rcc_##op(ty->size, ty->align, typeuid(ty->type)); break\n\txx(POINTER);\n\txx(ARRAY);\n\txx(CONST);\n\txx(VOLATILE);\n#undef xx\n\tcase CONST+VOLATILE:\n\t\ttype = rcc_CONST(ty->size, ty->align, typeuid(ty->type));\n\t\tbreak;\n\tcase ENUM: {\n\t\tlist_ty ids = Seq_new(0);\n\t\tint i;\n\t\tfor (i = 0; ty->u.sym->u.idlist[i] != NULL; i++)\n\t\t\tSeq_addhi(ids, rcc_enum_(ty->u.sym->u.idlist[i]->name,\n\t\t\t\tty->u.sym->u.idlist[i]->u.value));\n\t\tassert(i > 0);\n\t\ttype = rcc_ENUM(ty->size, ty->align, ty->u.sym->name, ids);\n\t\tbreak;\n\t\t}\n\tcase STRUCT: case UNION: {\n\t\tlist_ty fields = Seq_new(0);\n\t\tField p = fieldlist(ty);\n\t\tfor ( ; p != NULL; p = p->link)\n\t\t\tSeq_addhi(fields, rcc_field(p->name, typeuid(p->type), p->offset, p->bitsize, p->lsb));\n\t\tif (ty->op == STRUCT)\n\t\t\ttype = rcc_STRUCT(ty->size, ty->align, ty->u.sym->name, fields);\n\t\telse\n\t\t\ttype = rcc_UNION (ty->size, ty->align, ty->u.sym->name, fields);\n\t\tbreak;\n\t\t}\n\tcase FUNCTION: {\n\t\tlist_ty formals = Seq_new(0);\n\t\tif (ty->u.f.proto != NULL && ty->u.f.proto[0] != NULL) {\n\t\t\tint i;\n\t\t\tfor (i = 0; ty->u.f.proto[i] != NULL; i++)\n\t\t\t\tSeq_addhi(formals, to_generic_int(typeuid(ty->u.f.proto[i])));\n\t\t} else if (ty->u.f.proto != NULL && ty->u.f.proto[0] == NULL)\n\t\t\tSeq_addhi(formals, to_generic_int(typeuid(voidtype)));\n\t\ttype = rcc_FUNCTION(ty->size, ty->align, typeuid(ty->type), formals);\n\t\tbreak;\n\t\t}\n\tdefault: assert(0);\n\t}\n\tSeq_addhi(pickle->items, rcc_Type(ty->x.typeno, type));\n\treturn ty->x.typeno;\n}\n\nstatic int symboluid(Symbol p) {\n\tassert(p);\n\tassert(p->scope != CONSTANTS && p->scope != LABELS);\n\tif (p->x.offset == 0)\n\t\tp->x.offset = pickle->nuids++;\n\treturn p->x.offset;\n}\n\nstatic rcc_symbol_ty mk_symbol(Symbol p) {\n\tint flags = 0, ref = 10000*p->ref;\n\n\tif (p->ref > 0 && ref == 0)\n\t\tref++;\n#define xx(f,n) flags |= p->f<<n;\n\txx(structarg,0)\n\txx(addressed,1)\n\txx(computed,2)\n\txx(temporary,3)\n\txx(generated,4)\n#undef xx\n\treturn rcc_symbol(p->name, typeuid(p->type), p->scope, p->sclass, ref, flags);\n}\n\nstatic rcc_real_ty mk_real(int size, Value v) {\n\tunsigned *p = (unsigned *)&v.d;\n\treturn rcc_real(p[swap], p[1-swap]);\n}\n\nstatic void asdl_segment(int n) {\n\tstatic int cseg;\n\n\tif (cseg != n)\n\t\tput(rcc_Segment(cseg = n));\n}\n\nstatic void asdl_address(Symbol q, Symbol p, long n) {\n\tassert(q->x.offset == 0);\n\tput(rcc_Address(symboluid(q), mk_symbol(q), symboluid(p), n));\n}\n\nstatic void asdl_blockbeg(Env *e) {\n\tput(rcc_Blockbeg());\n}\n\nstatic void asdl_blockend(Env *e) {\n\tput(rcc_Blockend());\n}\n\nstatic void asdl_defaddress(Symbol p) {\n\tif (p->scope == LABELS)\n\t\tput(rcc_Deflabel(p->u.l.label));\n\telse\n\t\tput(rcc_Defaddress(symboluid(p)));\n}\n\nstatic void asdl_defconst(int suffix, int size, Value v) {\n\tswitch (suffix) {\n\tcase I: put(rcc_Defconst(suffix, size, v.i)); return;\n\tcase U: put(rcc_Defconst(suffix, size, v.u)); return;\n\tcase P: put(rcc_Defconst(suffix, size, (unsigned long)v.p)); return;\t/* FIXME */\n\tcase F: put(rcc_Defconstf(size, mk_real(size, v))); return;\n\tassert(0);\n\t}\n}\n\nstatic void asdl_defstring(int len, char *str) {\n\tput(rcc_Defstring(Text_box(stringn(str, len), len)));\n}\n\nstatic void asdl_defsymbol(Symbol p) {\n\tif (p->scope >= GLOBAL)\n\t\tsymboluid(p);\n}\n\nstatic Symbol temps;\n\nstatic rcc_node_ty visit(Node p) {\n\tSymbol q;\n\trcc_node_ty left = NULL, right = NULL;\n\tint suffix = optype(p->op), size = opsize(p->op);\n\n\tassert(p);\n\tfor (q = temps; q; q = q->u.t.next)\n\t\tif (q->u.t.cse == p) {\n\t\t\tq->u.t.cse = NULL;\n\t\t\treturn rcc_CSE(0, 0, symboluid(q), visit(p));\n\t\t}\n\tif (p->kids[0] != NULL)\n\t\tleft = visit(p->kids[0]);\n\tif (p->kids[1] != NULL)\n\t\tright = visit(p->kids[1]);\n\tswitch (specific(p->op)) {\n\tcase CNST+F:\n\t\tassert(p->syms[0]);\n\t\treturn rcc_CNSTF(suffix, size, mk_real(size, p->syms[0]->u.c.v));\n\tcase CALL+B:\n\t\tassert(p->syms[0]);\n\t\tassert(p->syms[0]->type);\n\t\treturn rcc_CALLB(suffix, size, left, right, typeuid(p->syms[0]->type));\n\tcase RET+V:\n\t\treturn rcc_RET(suffix, size);\n\tcase LABEL+V:\n\t\tassert(p->syms[0]);\n\t\treturn rcc_LABEL(suffix, size, p->syms[0]->u.l.label);\n\t}\n\tswitch (generic(p->op)) {\n\tcase CNST:\n\t\tassert(p->syms[0]);\n\t\treturn rcc_CNST(suffix, size, p->syms[0]->u.c.v.i);\t/* FIXME */\n\tcase ARG:\n\t\tassert(p->syms[0]);\n\t\treturn rcc_ARG(suffix, size, left, p->syms[0]->u.c.v.i, p->syms[1]->u.c.v.i);\n\tcase ASGN:\n\t\tassert(p->syms[0]);\n\t\tassert(p->syms[1]);\n\t\treturn rcc_ASGN(suffix, size, left, right, p->syms[0]->u.c.v.i, p->syms[1]->u.c.v.i);\n\tcase CVF: case CVI: case CVP: case CVU:\n\t\tassert(p->syms[0]);\n\t\treturn rcc_CVT(suffix, size, generic(p->op), left, p->syms[0]->u.c.v.i);\n\tcase CALL:\n\t\tassert(p->syms[0]);\n\t\tassert(p->syms[0]->type);\n\t\treturn rcc_CALL(suffix, size, left, typeuid(p->syms[0]->type));\n#define xx(op) case op: return rcc_##op(suffix, size, symboluid(p->syms[0]))\n\txx(ADDRG);\n\txx(ADDRF);\n#undef xx\n\tcase ADDRL:\n\t\tif (!p->syms[0]->defined)\n\t\t\t(*IR->local)(p->syms[0]);\n\t\tp->syms[0]->defined = 1;\n\t\treturn rcc_ADDRL(suffix, size, symboluid(p->syms[0]));\n\tcase JUMP:\n\t\tif (p->syms[0] != NULL)\n\t\t\treturn rcc_BRANCH(suffix, size, p->syms[0]->u.l.label);\n\t\treturn rcc_Unary(suffix, size, generic(p->op), left);\n\tcase INDIR: case RET: case NEG: case BCOM: \n\t\treturn rcc_Unary(suffix, size, generic(p->op), left);\n\tcase BOR: case BAND: case BXOR: case RSH: case LSH:\n\tcase ADD: case SUB: case DIV: case MUL: case MOD:\n\t\treturn rcc_Binary(suffix, size, generic(p->op), left, right);\n\tcase EQ: case NE: case GT: case GE: case LE: case LT:\n\t\tassert(p->syms[0]);\n\t\treturn rcc_Compare(suffix, size, generic(p->op), left, right, p->syms[0]->u.l.label);\n\t}\n\tassert(0);\n\treturn NULL;\n}\n\nstatic void asdl_emit(Node p) {}\n\nstatic void asdl_local(Symbol p) {\n\tassert(p->x.offset == 0);\n\tput(rcc_Local(symboluid(p), mk_symbol(p)));\n\tif (p->temporary && p->u.t.cse) {\n\t\tp->u.t.next = temps;\n\t\ttemps = p;\n\t}\n}\n\nstatic Symbol pending = NULL;\n\nstatic void dopending(Symbol p) {\n\tif (pending != NULL) {\n\t\tint uid = symboluid(pending);\n\t\trcc_symbol_ty symbol = mk_symbol(pending);\n\t\tSeq_addhi(pickle->items, rcc_Symbol(uid, symbol));\n\t}\n\tpending = p;\n}\n\n\nstatic void asdl_export(Symbol p) {\n\tput(rcc_Export(symboluid(p)));\n}\n\nstatic void asdl_function(Symbol f, Symbol caller[], Symbol callee[], int ncalls) {\n\tlist_ty codelist = Seq_new(0), save, calleelist = Seq_new(0), callerlist = Seq_new(0);\n\tint i;\n\n\tdopending(f);\n\tfor (i = 0; caller[i] != NULL; i++) {\n\t\tasdl_local(caller[i]);\n\t\tSeq_addhi(callerlist, to_generic_int(symboluid(caller[i])));\n\t}\n\tfor (i = 0; callee[i] != NULL; i++) {\n\t\tasdl_local(callee[i]);\n\t\tSeq_addhi(calleelist, to_generic_int(symboluid(callee[i])));\n\t}\n\tsave = interfaces;\n\tinterfaces = codelist;\n\tgencode(caller, callee);\n\tasdl_segment(CODE);\n\temitcode();\n\tinterfaces = save;\n\tput(rcc_Function(symboluid(f), callerlist, calleelist, ncalls, codelist));\n}\n\nstatic Node asdl_gen(Node p) {\n\tNode q;\n\tlist_ty forest = Seq_new(0);\n\n\tfor (q = p; p != NULL; p = p->link)\n\t\tif (specific(p->op) == JUMP+V && specific(p->kids[0]->op) == ADDRG+P\n\t\t&& p->kids[0]->syms[0]->scope == LABELS) {\n\t\t\tp->syms[0] = p->kids[0]->syms[0];\n\t\t\tp->kids[0] = NULL;\n\t\t}\n\tfor (p = q; p != NULL; p = p->link)\n\t\tSeq_addhi(forest, visit(p));\n\tput(rcc_Forest(forest));\n\ttemps = NULL;\n\treturn q;\n}\n\nstatic void asdl_global(Symbol p) {\n\tdopending(p);\n\tput(rcc_Global(symboluid(p), p->u.seg));\n}\n\nstatic void asdl_import(Symbol p) {\n\tdopending(p);\n\tput(rcc_Import(symboluid(p)));\n}\n\nstatic void asdl_progbeg(int argc, char *argv[]) {\n\tint i;\n\n#if WIN32\n\t_setmode(_fileno(stdout), _O_BINARY);\n#endif\n\tpickle = rcc_program(1, 0, Seq_new(0), Seq_new(0), argc, Seq_new(0));\n\tfor (i = 0; i < argc; i++)\n\t\tSeq_addhi(pickle->argv, to_generic_string(Text_box(argv[i], strlen(argv[i]) + 1)));\n\tinterfaces = pickle->interfaces;\n}\n\nstatic int checkuid(list_ty list) {\n\tint i, n = 0, count = Seq_length(list);\n\n\tfor (i = 0; i < count; i++) {\n\t\trcc_interface_ty in = Seq_get(list, i);\n\t\tif (in->kind == rcc_Local_enum\n\t\t||  in->kind == rcc_Address_enum)\n\t\t\tn++;\n\t\telse if (in->kind == rcc_Function_enum)\n\t\t\tn += checkuid(in->v.rcc_Function.codelist);\n\t}\n\treturn n;\n}\n\nstatic void asdl_progend(void) {\n\tdopending(NULL);\n\t{\n\t\tint n = checkuid(pickle->interfaces) + Seq_length(pickle->items);\n\t\tif (n != pickle->nuids - 1)\n\t\t\tfprintf(stderr, \"?bogus uid count: have %d should have %d\\n\",\n\t\t\t\tn, pickle->nuids-1);\n\t}\n\tpickle->nlabels = genlabel(0);\n\twrite_int((int)(100*(assert(strstr(rcsid, \",v\")), strtod(strstr(rcsid, \",v\")+2, NULL))\n), stdout);\n\trcc_write_program(pickle, stdout);\n}\nstatic void asdl_space(int n) {\n\tput(rcc_Space(n));\n}\n\nvoid asdl_init(int argc, char *argv[]) {\n\tint i;\n\tstatic int inited;\n\n\tif (inited)\n\t\treturn;\n\tinited = 1;\n\tfor (i = 1; i < argc; i++)\n\t\tif (strcmp(argv[i], \"-asdl\") == 0) {\n#define xx(f) IR->f = asdl_##f\n\t\txx(address);\n\t\txx(blockbeg);\n\t\txx(blockend);\n\t\txx(defaddress);\n\t\txx(defconst);\n\t\txx(defstring);\n\t\txx(defsymbol);\n\t\txx(emit);\n\t\txx(export);\n\t\txx(function);\n\t\txx(gen);\n\t\txx(global);\n\t\txx(import);\n\t\txx(local);\n\t\txx(progbeg);\n\t\txx(progend);\n\t\txx(segment);\n\t\txx(space);\n#undef xx\n#define xx(f) IR->f = 0\n\t\txx(stabblock);\n\t\txx(stabend);\n\t\txx(stabfend);\n\t\txx(stabinit);\n\t\txx(stabline);\n\t\txx(stabsym);\n\t\txx(stabtype);\n#undef xx\n\t\tIR->wants_dag = 0;\n\t\tprunetemps = 0;\t/* pass2 prunes useless temps */\n\t\tassignargs = 0;\t/* pass2 generates caller to callee assignments */\n\t\t}\n}\n"
  },
  {
    "path": "lcc/src/bind.c",
    "content": "#include \"c.h\"\nextern Interface alphaIR;\nextern Interface mipsebIR, mipselIR;\nextern Interface sparcIR, solarisIR;\nextern Interface x86IR, x86linuxIR;\nextern Interface symbolicIR, symbolic64IR;\nextern Interface nullIR;\nextern Interface bytecodeIR;\nBinding bindings[] = {\n\t\"alpha/osf\",     &alphaIR,\n\t\"mips/irix\",     &mipsebIR,\n\t\"mips/ultrix\",   &mipselIR,\n\t\"sparc/sun\",     &sparcIR,\n\t\"sparc/solaris\", &solarisIR,\n\t\"x86/win32\",\t &x86IR,\n\t\"x86/linux\",\t &x86linuxIR,\n\t\"symbolic/osf\",  &symbolic64IR,\n\t\"symbolic/irix\", &symbolicIR,\n\t\"symbolic\",      &symbolicIR,\n\t\"null\",          &nullIR,\n\t\"bytecode\",      &bytecodeIR,\n\tNULL,            NULL\n};\n"
  },
  {
    "path": "lcc/src/bytecode.c",
    "content": "#include \"c.h\"\n#define I(f) b_##f\n\n\nstatic void I(segment)(int n) {\n\tstatic int cseg;\n\n\tif (cseg != n)\n\t\tswitch (cseg = n) {\n\t\tcase CODE: print(\"code\\n\"); return;\n\t\tcase DATA: print(\"data\\n\"); return;\n\t\tcase BSS:  print(\"bss\\n\");  return;\n\t\tcase LIT:  print(\"lit\\n\");  return;\n\t\tdefault: assert(0);\n\t\t}\n}\n\nstatic void I(address)(Symbol q, Symbol p, long n) {\n\tq->x.name = stringf(\"%s%s%D\", p->x.name, n > 0 ? \"+\" : \"\", n);\n}\n\nstatic void I(defaddress)(Symbol p) {\n\tprint(\"address %s\\n\", p->x.name);\n}\n\nstatic void I(defconst)(int suffix, int size, Value v) {\n\tswitch (suffix) {\n\tcase I:\n\t\tif (size > sizeof (int))\n\t\t\tprint(\"byte %d %D\\n\", size, v.i);\n\t\telse\n\t\t\tprint(\"byte %d %d\\n\", size, v.i);\n\t\treturn;\n\tcase U:\n\t\tif (size > sizeof (unsigned))\n\t\t\tprint(\"byte %d %U\\n\", size, v.u);\n\t\telse\n\t\t\tprint(\"byte %d %u\\n\", size, v.u);\n\t\treturn;\n\tcase P: print(\"byte %d %U\\n\", size, (unsigned long)v.p); return;\n\tcase F:\n\t\tif (size == 4) {\n\t\t\tfloat f = v.d;\n\t\t\tprint(\"byte 4 %u\\n\", *(unsigned *)&f);\n\t\t} else {\n\t\t\tunsigned *p = (unsigned *)&v.d;\n\t\t\tprint(\"byte 4 %u\\n\", p[swap]);\n\t\t\tprint(\"byte 4 %u\\n\", p[1 - swap]);\n\t\t}\n\t\treturn;\n\t}\n\tassert(0);\n}\n\nstatic void I(defstring)(int len, char *str) {\n\tchar *s;\n\n\tfor (s = str; s < str + len; s++)\n\t\tprint(\"byte 1 %d\\n\", (*s)&0377);\n}\n\nstatic void I(defsymbol)(Symbol p) {\n\tif (p->scope == CONSTANTS)\n\t\tswitch (optype(ttob(p->type))) {\n\t\tcase I: p->x.name = stringf(\"%D\", p->u.c.v.i); break;\n\t\tcase U: p->x.name = stringf(\"%U\", p->u.c.v.u); break;\n\t\tcase P: p->x.name = stringf(\"%U\", p->u.c.v.p); break;\n\t\tcase F:\n\t\t\t{\t// JDC: added this to get inline floats\n\t\t\t\tunsigned temp;\n\n\t\t\t\t*(float *)&temp = p->u.c.v.d;\n\t\t\t\tp->x.name = stringf(\"%U\", temp );\n\t\t\t}\n\t\t\tbreak;// JDC: added this\n\t\tdefault: assert(0);\n\t\t}\n\telse if (p->scope >= LOCAL && p->sclass == STATIC)\n\t\tp->x.name = stringf(\"$%d\", genlabel(1));\n\telse if (p->scope == LABELS || p->generated)\n\t\tp->x.name = stringf(\"$%s\", p->name);\n\telse\n\t\tp->x.name = p->name;\n}\n\nstatic void dumptree(Node p) {\n\tswitch (specific(p->op)) {\n\tcase ASGN+B:\n\t\tassert(p->kids[0]);\n\t\tassert(p->kids[1]);\n\t\tassert(p->syms[0]);\n\t\tdumptree(p->kids[0]);\n\t\tdumptree(p->kids[1]);\n\t\tprint(\"%s %d\\n\", opname(p->op), p->syms[0]->u.c.v.u);\n\t\treturn;\n\tcase RET+V:\n\t\tassert(!p->kids[0]);\n\t\tassert(!p->kids[1]);\n\t\tprint(\"%s\\n\", opname(p->op));\n\t\treturn;\n\t}\n\tswitch (generic(p->op)) {\n\tcase CNST: case ADDRG: case ADDRF: case ADDRL: case LABEL:\n\t\tassert(!p->kids[0]);\n\t\tassert(!p->kids[1]);\n\t\tassert(p->syms[0] && p->syms[0]->x.name);\n\t\tprint(\"%s %s\\n\", opname(p->op), p->syms[0]->x.name);\n\t\treturn;\n\tcase CVF: case CVI: case CVP: case CVU:\n\t\tassert(p->kids[0]);\n\t\tassert(!p->kids[1]);\n\t\tassert(p->syms[0]);\n\t\tdumptree(p->kids[0]);\n\t\tprint(\"%s %d\\n\", opname(p->op), p->syms[0]->u.c.v.i);\n\t\treturn;\n\tcase ARG: case BCOM: case NEG: case INDIR: case JUMP: case RET:\n\t\tassert(p->kids[0]);\n\t\tassert(!p->kids[1]);\n\t\tdumptree(p->kids[0]);\n\t\tprint(\"%s\\n\", opname(p->op));\n\t\treturn;\n\tcase CALL:\n\t\tassert(p->kids[0]);\n\t\tassert(!p->kids[1]);\n\t\tassert(optype(p->op) != B);\n\t\tdumptree(p->kids[0]);\n\t\tprint(\"%s\\n\", opname(p->op));\n\t\tif ( !p->count ) { printf(\"pop\\n\"); };\t// JDC\n\t\treturn;\n\tcase ASGN: case BOR: case BAND: case BXOR: case RSH: case LSH:\n\tcase ADD: case SUB: case DIV: case MUL: case MOD:\n\t\tassert(p->kids[0]);\n\t\tassert(p->kids[1]);\n\t\tdumptree(p->kids[0]);\n\t\tdumptree(p->kids[1]);\n\t\tprint(\"%s\\n\", opname(p->op));\n\t\treturn;\n\tcase EQ: case NE: case GT: case GE: case LE: case LT:\n\t\tassert(p->kids[0]);\n\t\tassert(p->kids[1]);\n\t\tassert(p->syms[0]);\n\t\tassert(p->syms[0]->x.name);\n\t\tdumptree(p->kids[0]);\n\t\tdumptree(p->kids[1]);\n\t\tprint(\"%s %s\\n\", opname(p->op), p->syms[0]->x.name);\n\t\treturn;\n\t}\n\tassert(0);\n}\n\nstatic void I(emit)(Node p) {\n\tfor (; p; p = p->link)\n\t\tdumptree(p);\n}\n\nstatic void I(export)(Symbol p) {\n\tprint(\"export %s\\n\", p->x.name);\n}\n\nstatic void I(function)(Symbol f, Symbol caller[], Symbol callee[], int ncalls) {\n\tint i;\n\n\t(*IR->segment)(CODE);\n\toffset = 0;\n\tfor (i = 0; caller[i] && callee[i]; i++) {\n\t\toffset = roundup(offset, caller[i]->type->align);\n\t\tcaller[i]->x.name = callee[i]->x.name = stringf(\"%d\", offset);\n\t\tcaller[i]->x.offset = callee[i]->x.offset = offset;\n\t\toffset += caller[i]->type->size;\n\t}\n\tmaxargoffset = maxoffset = argoffset = offset = 0;\n\tgencode(caller, callee);\n\tprint(\"proc %s %d %d\\n\", f->x.name, maxoffset, maxargoffset);\n\temitcode();\n\tprint(\"endproc %s %d %d\\n\", f->x.name, maxoffset, maxargoffset);\n\n}\n\nstatic void gen02(Node p) {\n\tassert(p);\n\tif (generic(p->op) == ARG) {\n\t\tassert(p->syms[0]);\n\t\targoffset += (p->syms[0]->u.c.v.i < 4 ? 4 : p->syms[0]->u.c.v.i);\n\t} else if (generic(p->op) == CALL) {\n\t\tmaxargoffset = (argoffset > maxargoffset ? argoffset : maxargoffset);\n\t\targoffset = 0;\n\t}\n}\n\nstatic void gen01(Node p) {\n\tif (p) {\n\t\tgen01(p->kids[0]);\n\t\tgen01(p->kids[1]);\n\t\tgen02(p);\n\t}\n}\n\nstatic Node I(gen)(Node p) {\n\tNode q;\n\n\tassert(p);\n\tfor (q = p; q; q = q->link)\n\t\tgen01(q);\n\treturn p;\n}\n\nstatic void I(global)(Symbol p) {\n\tprint(\"align %d\\n\", p->type->align > 4 ? 4 : p->type->align);\n\tprint(\"LABELV %s\\n\", p->x.name);\n}\n\nstatic void I(import)(Symbol p) {\n\tprint(\"import %s\\n\", p->x.name);\n}\n\nstatic void I(local)(Symbol p) {\n\toffset = roundup(offset, p->type->align);\n\tp->x.name = stringf(\"%d\", offset);\n\tp->x.offset = offset;\n\toffset += p->type->size;\n}\n\nstatic void I(progbeg)(int argc, char *argv[]) {}\n\nstatic void I(progend)(void) {}\n\nstatic void I(space)(int n) {\n\tprint(\"skip %d\\n\", n);\n}\n\n//========================================================\n\n// JDC: hacked up to get interleaved source lines in asm code\nstatic char\t*sourceFile;\nstatic char *sourcePtr;\nstatic int sourceLine;\n\nstatic int filelength( FILE *f ) {\n\tint\t\tpos;\n\tint\t\tend;\n\n\tpos = ftell (f);\n\tfseek (f, 0, SEEK_END);\n\tend = ftell (f);\n\tfseek (f, pos, SEEK_SET);\n\n\treturn end;\n}\n\nstatic void LoadSourceFile( const char *filename ) {\n\tFILE\t*f;\n\tint\t\tlength;\n\n\tf = fopen( filename, \"r\" );\n\tif ( !f ) {\n\t\tprint( \";couldn't open %s\\n\", filename );\n\t\tsourceFile = NULL;\n\t\treturn;\n\t}\n\tlength = filelength( f );\n\tsourceFile = malloc( length + 1 );\n\tif ( sourceFile ) {\n\t\tfread( sourceFile, length, 1, f );\n\t\tsourceFile[length] = 0;\n\t}\n\n\tfclose( f );\n\tsourceLine = 1;\n\tsourcePtr = sourceFile;\n}\n\nstatic void PrintToSourceLine( int line ) {\n\tint\t\tc;\n\n\tif ( !sourceFile ) {\n\t\treturn;\n\t}\n\twhile ( sourceLine <= line ) {\n\t\tint\t\ti;\n\n\t\tfor ( i = 0 ; sourcePtr[i] && sourcePtr[i] != '\\n' ; i++ ) {\n\t\t}\n\t\tc = sourcePtr[i];\n\t\tif ( c == '\\n' ) {\n\t\t\tsourcePtr[i] = 0;\n\t\t}\n\t\tprint( \";%d:%s\\n\", sourceLine, sourcePtr );\n\t\tif ( c == 0 ) {\n\t\t\tsourcePtr += i;\t// end of file\n\t\t} else {\n\t\t\tsourcePtr += i+1;\n\t\t}\n\t\tsourceLine++;\n\t}\n}\n\nstatic void I(stabline)(Coordinate *cp) {\n\tstatic char *prevfile;\n\tstatic int prevline;\n\n\tif (cp->file && (prevfile == NULL || strcmp(prevfile, cp->file) != 0)) {\n\t\tprint(\"file \\\"%s\\\"\\n\", prevfile = cp->file);\n\t\tprevline = 0;\n\t\tif ( sourceFile ) {\n\t\t\tfree( sourceFile );\n\t\t\tsourceFile = NULL;\n\t\t}\n\t\t// load the new source file\n\t\tLoadSourceFile( cp->file );\n\t}\n\tif (cp->y != prevline) {\n\t\tprint(\"line %d\\n\", prevline = cp->y);\n\t\tPrintToSourceLine( cp->y );\n\t}\n}\n\n//========================================================\n\n#define b_blockbeg blockbeg\n#define b_blockend blockend\n\nInterface bytecodeIR = {\n\t1, 1, 0,\t/* char */\n\t2, 2, 0,\t/* short */\n\t4, 4, 0,\t/* int */\n\t4, 4, 0,\t/* long */\n\t4, 4, 0,\t/* long long */\n\t4, 4, 0,\t/* float */\t\t\t\t// JDC: use inline floats\n\t4, 4, 0,\t/* double */\t\t\t// JDC: don't ever emit 8 byte double code\n\t4, 4, 0,\t/* long double */\t\t// JDC: don't ever emit 8 byte double code\n\t4, 4, 0,\t/* T* */\n\t0, 4, 0,\t/* struct */\n\t0,\t\t/* little_endian */\n\t0,\t\t/* mulops_calls */\n\t0,\t\t/* wants_callb */\n\t0,\t\t/* wants_argb */\n\t1,\t\t/* left_to_right */\n\t0,\t\t/* wants_dag */\n\t0,\t\t/* unsigned_char */\n\tI(address),\n\tI(blockbeg),\n\tI(blockend),\n\tI(defaddress),\n\tI(defconst),\n\tI(defstring),\n\tI(defsymbol),\n\tI(emit),\n\tI(export),\n\tI(function),\n\tI(gen),\n\tI(global),\n\tI(import),\n\tI(local),\n\tI(progbeg),\n\tI(progend),\n\tI(segment),\n\tI(space),\n\t0,\t\t/* I(stabblock) */\n\t0,\t\t/* I(stabend) */\n\t0,\t\t/* I(stabfend) */\n\t0,\t\t/* I(stabinit) */\n\tI(stabline),\n\t0,\t\t/* I(stabsym) */\n\t0,\t\t/* I(stabtype) */\n};\n"
  },
  {
    "path": "lcc/src/c.h",
    "content": "#include <assert.h>\n#include <stdarg.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <limits.h>\n#include <string.h>\n\n#define NEW(p,a) ((p) = allocate(sizeof *(p), (a)))\n#define NEW0(p,a) memset(NEW((p),(a)), 0, sizeof *(p))\n#define isaddrop(op) (specific(op)==ADDRG+P || specific(op)==ADDRL+P \\\n\t|| specific(op)==ADDRF+P)\n\n#define\tMAXLINE  512\n#define\tBUFSIZE 4096\n\n#define istypename(t,tsym) (kind[t] == CHAR \\\n\t|| t == ID && tsym && tsym->sclass == TYPEDEF)\n#define sizeop(n) ((n)<<10)\n#define generic(op)  ((op)&0x3F0)\n#define specific(op) ((op)&0x3FF)\n#define opindex(op) (((op)>>4)&0x3F)\n#define opkind(op)  ((op)&~0x3F0)\n#define opsize(op)  ((op)>>10)\n#define optype(op)  ((op)&0xF)\n#ifdef __LCC__\n#ifndef __STDC__\n#define __STDC__\n#endif\n#endif\n#define NELEMS(a) ((int)(sizeof (a)/sizeof ((a)[0])))\n#undef roundup\n#define roundup(x,n) (((x)+((n)-1))&(~((n)-1)))\n#define mkop(op,ty) (specific((op) + ttob(ty)))\n\n#define extend(x,ty) ((x)&(1<<(8*(ty)->size-1)) ? (x)|((~0UL)<<(8*(ty)->size-1)) : (x)&ones(8*(ty)->size))\n#define ones(n) ((n)>=8*sizeof (unsigned long) ? ~0UL : ~((~0UL)<<(n)))\n\n#define isqual(t)     ((t)->op >= CONST)\n#define unqual(t)     (isqual(t) ? (t)->type : (t))\n\n#define isvolatile(t) ((t)->op == VOLATILE \\\n                    || (t)->op == CONST+VOLATILE)\n#define isconst(t)    ((t)->op == CONST \\\n                    || (t)->op == CONST+VOLATILE)\n#define isarray(t)    (unqual(t)->op == ARRAY)\n#define isstruct(t)   (unqual(t)->op == STRUCT \\\n                    || unqual(t)->op == UNION)\n#define isunion(t)    (unqual(t)->op == UNION)\n#define isfunc(t)     (unqual(t)->op == FUNCTION)\n#define isptr(t)      (unqual(t)->op == POINTER)\n#define ischar(t)     ((t)->size == 1 && isint(t))\n#define isint(t)      (unqual(t)->op == INT \\\n                    || unqual(t)->op == UNSIGNED)\n#define isfloat(t)    (unqual(t)->op == FLOAT)\n#define isarith(t)    (unqual(t)->op <= UNSIGNED)\n#define isunsigned(t) (unqual(t)->op == UNSIGNED)\n#define isscalar(t)   (unqual(t)->op <= POINTER \\\n                    || unqual(t)->op == ENUM)\n#define isenum(t)     (unqual(t)->op == ENUM)\n#define fieldsize(p)  (p)->bitsize\n#define fieldright(p) ((p)->lsb - 1)\n#define fieldleft(p)  (8*(p)->type->size - \\\n                        fieldsize(p) - fieldright(p))\n#define fieldmask(p)  (~(~(unsigned)0<<fieldsize(p)))\ntypedef struct node *Node;\n\ntypedef struct list *List;\n\ntypedef struct code *Code;\n\ntypedef struct swtch *Swtch;\n\ntypedef struct symbol *Symbol;\n\ntypedef struct coord {\n\tchar *file;\n\tunsigned x, y;\n} Coordinate;\ntypedef struct table *Table;\n\ntypedef union value {\n\tlong i;\n\tunsigned long u;\n\tlong double d;\n\tvoid *p;\n\tvoid (*g)(void);\n} Value;\ntypedef struct tree *Tree;\n\ntypedef struct type *Type;\n\ntypedef struct field *Field;\n\ntypedef struct {\n\tunsigned printed:1;\n\tunsigned marked;\n\tunsigned short typeno;\n\tvoid *xt;\n} Xtype;\n\n#include \"config.h\"\ntypedef struct metrics {\n\tunsigned char size, align, outofline;\n} Metrics;\ntypedef struct interface {\n\tMetrics charmetric;\n\tMetrics shortmetric;\n\tMetrics intmetric;\n\tMetrics longmetric;\n\tMetrics longlongmetric;\n\tMetrics floatmetric;\n\tMetrics doublemetric;\n\tMetrics longdoublemetric;\n\tMetrics ptrmetric;\n\tMetrics structmetric;\n\tunsigned little_endian:1;\n\tunsigned mulops_calls:1;\n\tunsigned wants_callb:1;\n\tunsigned wants_argb:1;\n\tunsigned left_to_right:1;\n\tunsigned wants_dag:1;\n\tunsigned unsigned_char:1;\nvoid (*address)(Symbol p, Symbol q, long n);\nvoid (*blockbeg)(Env *);\nvoid (*blockend)(Env *);\nvoid (*defaddress)(Symbol);\nvoid (*defconst)  (int suffix, int size, Value v);\nvoid (*defstring)(int n, char *s);\nvoid (*defsymbol)(Symbol);\nvoid (*emit)    (Node);\nvoid (*export)(Symbol);\nvoid (*function)(Symbol, Symbol[], Symbol[], int);\nNode (*gen)     (Node);\nvoid (*global)(Symbol);\nvoid (*import)(Symbol);\nvoid (*local)(Symbol);\nvoid (*progbeg)(int argc, char *argv[]);\nvoid (*progend)(void);\nvoid (*segment)(int);\nvoid (*space)(int);\nvoid (*stabblock)(int, int, Symbol*);\nvoid (*stabend)  (Coordinate *, Symbol, Coordinate **, Symbol *, Symbol *);\nvoid (*stabfend) (Symbol, int);\nvoid (*stabinit) (char *, int, char *[]);\nvoid (*stabline) (Coordinate *);\nvoid (*stabsym)  (Symbol);\nvoid (*stabtype) (Symbol);\n\tXinterface x;\n} Interface;\ntypedef struct binding {\n\tchar *name;\n\tInterface *ir;\n} Binding;\n\nextern Binding bindings[];\nextern Interface *IR;\ntypedef struct {\n\tList blockentry;\n\tList blockexit;\n\tList entry;\n\tList exit;\n\tList returns;\n\tList points;\n\tList calls;\n\tList end;\n} Events;\n\nenum {\n#define xx(a,b,c,d,e,f,g) a=b,\n#define yy(a,b,c,d,e,f,g)\n#include \"token.h\"\n\tLAST\n};\nstruct node {\n\tshort op;\n\tshort count;\n \tSymbol syms[3];\n\tNode kids[2];\n\tNode link;\n\tXnode x;\n};\nenum {\n\tF=FLOAT,\n\tI=INT,\n\tU=UNSIGNED,\n\tP=POINTER,\n\tV=VOID,\n\tB=STRUCT\n};\n#define gop(name,value) name=value<<4,\n#define op(name,type,sizes)\n\nenum { gop(CNST,1)\n       \top(CNST,F,fdx)\n       \top(CNST,I,csilh)\n       \top(CNST,P,p)\n       \top(CNST,U,csilh)\n       gop(ARG,2)\n       \top(ARG,B,-)\n       \top(ARG,F,fdx)\n       \top(ARG,I,ilh)\n       \top(ARG,P,p)\n       \top(ARG,U,ilh)\n       gop(ASGN,3)\n       \top(ASGN,B,-)\n       \top(ASGN,F,fdx)\n       \top(ASGN,I,csilh)\n       \top(ASGN,P,p)\n       \top(ASGN,U,csilh)\n       gop(INDIR,4)\n       \top(INDIR,B,-)\n       \top(INDIR,F,fdx)\n       \top(INDIR,I,csilh)\n       \top(INDIR,P,p)\n       \top(INDIR,U,csilh)\n       gop(CVF,7)\n       \top(CVF,F,fdx)\n       \top(CVF,I,ilh)\n       gop(CVI,8)\n       \top(CVI,F,fdx)\n       \top(CVI,I,csilh)\n       \top(CVI,U,csilhp)\n       gop(CVP,9)\n       \top(CVP,U,p)\n       gop(CVU,11)\n       \top(CVU,I,csilh)\n       \top(CVU,P,p)\n       \top(CVU,U,csilh)\n       gop(NEG,12)\n       \top(NEG,F,fdx)\n       \top(NEG,I,ilh)\n       gop(CALL,13)\n       \top(CALL,B,-)\n       \top(CALL,F,fdx)\n       \top(CALL,I,ilh)\n       \top(CALL,P,p)\n       \top(CALL,U,ilh)\n       \top(CALL,V,-)\n       gop(RET,15)\n       \top(RET,F,fdx)\n       \top(RET,I,ilh)\n       \top(RET,P,p)\n       \top(RET,U,ilh)\n       \top(RET,V,-)\n       gop(ADDRG,16)\n       \top(ADDRG,P,p)\n       gop(ADDRF,17)\n       \top(ADDRF,P,p)\n       gop(ADDRL,18)\n       \top(ADDRL,P,p)\n       gop(ADD,19)\n       \top(ADD,F,fdx)\n       \top(ADD,I,ilh)\n       \top(ADD,P,p)\n       \top(ADD,U,ilhp)\n       gop(SUB,20)\n       \top(SUB,F,fdx)\n       \top(SUB,I,ilh)\n       \top(SUB,P,p)\n       \top(SUB,U,ilhp)\n       gop(LSH,21)\n       \top(LSH,I,ilh)\n       \top(LSH,U,ilh)\n       gop(MOD,22)\n       \top(MOD,I,ilh)\n       \top(MOD,U,ilh)\n       gop(RSH,23)\n       \top(RSH,I,ilh)\n       \top(RSH,U,ilh)\n       gop(BAND,24)\n       \top(BAND,I,ilh)\n       \top(BAND,U,ilh)\n       gop(BCOM,25)\n       \top(BCOM,I,ilh)\n       \top(BCOM,U,ilh)\n       gop(BOR,26)\n       \top(BOR,I,ilh)\n       \top(BOR,U,ilh)\n       gop(BXOR,27)\n       \top(BXOR,I,ilh)\n       \top(BXOR,U,ilh)\n       gop(DIV,28)\n       \top(DIV,F,fdx)\n       \top(DIV,I,ilh)\n       \top(DIV,U,ilh)\n       gop(MUL,29)\n       \top(MUL,F,fdx)\n       \top(MUL,I,ilh)\n       \top(MUL,U,ilh)\n       gop(EQ,30)\n       \top(EQ,F,fdx)\n       \top(EQ,I,ilh)\n       \top(EQ,U,ilhp)\n       gop(GE,31)\n       \top(GE,F,fdx)\n       \top(GE,I,ilh)\n       \top(GE,U,ilhp)\n       gop(GT,32)\n       \top(GT,F,fdx)\n       \top(GT,I,ilh)\n       \top(GT,U,ilhp)\n       gop(LE,33)\n       \top(LE,F,fdx)\n       \top(LE,I,ilh)\n       \top(LE,U,ilhp)\n       gop(LT,34)\n       \top(LT,F,fdx)\n       \top(LT,I,ilh)\n       \top(LT,U,ilhp)\n       gop(NE,35)\n       \top(NE,F,fdx)\n       \top(NE,I,ilh)\n       \top(NE,U,ilhp)\n       gop(JUMP,36)\n       \top(JUMP,V,-)\n       gop(LABEL,37)\n       \top(LABEL,V,-)\n       gop(LOAD,14)\n       \top(LOAD,B,-)\n       \top(LOAD,F,fdx)\n       \top(LOAD,I,csilh)\n       \top(LOAD,P,p)\n       \top(LOAD,U,csilhp) LASTOP };\n\n#undef gop\n#undef op\nenum { CODE=1, BSS, DATA, LIT };\nenum { PERM=0, FUNC, STMT };\nstruct list {\n\tvoid *x;\n\tList link;\n};\n\nstruct code {\n\tenum { Blockbeg, Blockend, Local, Address, Defpoint,\n\t       Label,    Start,    Gen,   Jump,    Switch\n\t} kind;\n\tCode prev, next;\n\tunion {\n\t\tstruct {\n\t\t\tint level;\n\t\t\tSymbol *locals;\n\t\t\tTable identifiers, types;\n\t\t\tEnv x;\n\t\t} block;\n\t\tCode begin;\n\t\tSymbol var;\n\n\t\tstruct {\n\t\t\tSymbol sym;\n\t\t\tSymbol base;\n\t\t\tlong offset;\n\t\t} addr;\n\t\tstruct {\n\t\t\tCoordinate src;\n\t\t\tint point;\n\t\t} point; \n\t\tNode forest;\n\t\tstruct {\n\t\t\tSymbol sym;\n\t\t\tSymbol table;\n\t\t\tSymbol deflab;\n\t\t\tint size;\n\t\t\tlong *values;\n\t\t\tSymbol *labels;\n\t\t} swtch;\n\n\t} u;\n};\nstruct swtch {\n\tSymbol sym;\n\tint lab;\n\tSymbol deflab;\n\tint ncases;\n\tint size;\n\tlong *values;\n\tSymbol *labels;\n};\nstruct symbol {\n\tchar *name;\n\tint scope;\n\tCoordinate src;\n\tSymbol up;\n\tList uses;\n\tint sclass;\n\tunsigned structarg:1;\n\n\tunsigned addressed:1;\n\tunsigned computed:1;\n\tunsigned temporary:1;\n\tunsigned generated:1;\n\tunsigned defined:1;\n\tType type;\n\tfloat ref;\n\tunion {\n\t\tstruct {\n\t\t\tint label;\n\t\t\tSymbol equatedto;\n\t\t} l;\n\t\tstruct {\n\t\t\tunsigned cfields:1;\n\t\t\tunsigned vfields:1;\n\t\t\tTable ftab;\t\t/* omit */\n\t\t\tField flist;\n\t\t} s;\n\t\tint value;\n\t\tSymbol *idlist;\n\t\tstruct {\n\t\t\tValue min, max;\n\t\t} limits;\n\t\tstruct {\n\t\t\tValue v;\n\t\t\tSymbol loc;\n\t\t} c;\n\t\tstruct {\n\t\t\tCoordinate pt;\n\t\t\tint label;\n\t\t\tint ncalls;\n\t\t\tSymbol *callee;\n\t\t} f;\n\t\tint seg;\n\t\tSymbol alias;\n\t\tstruct {\n\t\t\tNode cse;\n\t\t\tint replace;\n\t\t\tSymbol next;\n\t\t} t;\n\t} u;\n\tXsymbol x;\n};\nenum { CONSTANTS=1, LABELS, GLOBAL, PARAM, LOCAL };\nstruct tree {\n\tint op;\n\tType type;\n\tTree kids[2];\n\tNode node;\n\tunion {\n\t\tValue v;\n\t\tSymbol sym;\n\n\t\tField field;\n\t} u;\n};\nenum {\n\tAND=38<<4,\n\tNOT=39<<4,\n\tOR=40<<4,\n\tCOND=41<<4,\n\tRIGHT=42<<4,\n\tFIELD=43<<4\n};\nstruct type {\n\tint op;\n\tType type;\n\tint align;\n\tint size;\n\tunion {\n\t\tSymbol sym;\n\t\tstruct {\n\t\t\tunsigned oldstyle:1;\n\t\t\tType *proto;\n\t\t} f;\n\t} u;\n\tXtype x;\n};\nstruct field {\n\tchar *name;\n\tType type;\n\tint offset;\n\tshort bitsize;\n\tshort lsb;\n\tField link;\n};\nextern int assignargs;\nextern int prunetemps;\nextern int nodecount;\nextern Symbol cfunc;\nextern Symbol retv;\nextern Tree (*optree[])(int, Tree, Tree);\n\nextern char kind[];\nextern int errcnt;\nextern int errlimit;\nextern int wflag;\nextern Events events;\nextern float refinc;\n\nextern unsigned char *cp;\nextern unsigned char *limit;\nextern char *firstfile;\nextern char *file;\nextern char *line;\nextern int lineno;\nextern int t;\nextern char *token;\nextern Symbol tsym;\nextern Coordinate src;\nextern int Aflag;\nextern int Pflag;\nextern Symbol YYnull;\nextern Symbol YYcheck;\nextern int glevel;\nextern int xref;\n\nextern int ncalled;\nextern int npoints;\n\nextern int needconst;\nextern int explicitCast;\nextern struct code codehead;\nextern Code codelist;\nextern Table stmtlabs;\nextern float density;\nextern Table constants;\nextern Table externals;\nextern Table globals;\nextern Table identifiers;\nextern Table labels;\nextern Table types;\nextern int level;\n\nextern List loci, symbols;\n\nextern List symbols;\n\nextern int where;\nextern Type chartype;\nextern Type doubletype;\nextern Type floattype;\nextern Type inttype;\nextern Type longdouble;\nextern Type longtype;\nextern Type longlong;\nextern Type shorttype;\nextern Type signedchar;\nextern Type unsignedchar;\nextern Type unsignedlonglong;\nextern Type unsignedlong;\nextern Type unsignedshort;\nextern Type unsignedtype;\nextern Type charptype;\nextern Type funcptype;\nextern Type voidptype;\nextern Type voidtype;\nextern Type unsignedptr;\nextern Type signedptr;\nextern Type widechar;\nextern void  *allocate(unsigned long n, unsigned a);\nextern void deallocate(unsigned a);\nextern void *newarray(unsigned long m, unsigned long n, unsigned a);\nextern void walk(Tree e, int tlab, int flab);\nextern Node listnodes(Tree e, int tlab, int flab);\nextern Node newnode(int op, Node left, Node right, Symbol p);\nextern Tree cvtconst(Tree);\nextern void printdag(Node, int);\nextern void compound(int, Swtch, int);\nextern void defglobal(Symbol, int);\nextern void finalize(void);\nextern void program(void);\n\nextern Tree vcall(Symbol func, Type ty, ...);\nextern Tree addrof(Tree);\nextern Tree asgn(Symbol, Tree);\nextern Tree asgntree(int, Tree, Tree);\nextern Type assign(Type, Tree);\nextern Tree bittree(int, Tree, Tree);\nextern Tree call(Tree, Type, Coordinate);\nextern Tree calltree(Tree, Type, Tree, Symbol);\nextern Tree condtree(Tree, Tree, Tree);\nextern Tree cnsttree(Type, ...);\nextern Tree consttree(unsigned int, Type);\nextern Tree eqtree(int, Tree, Tree);\nextern int iscallb(Tree);\nextern Tree shtree(int, Tree, Tree);\nextern void typeerror(int, Tree, Tree);\n\nextern void test(int tok, char set[]);\nextern void expect(int tok);\nextern void skipto(int tok, char set[]);\nextern void error(const char *, ...);\nextern int fatal(const char *, const char *, int);\nextern void warning(const char *, ...);\n\ntypedef void (*Apply)(void *, void *, void *);\nextern void attach(Apply, void *, List *);\nextern void apply(List event, void *arg1, void *arg2);\nextern Tree retype(Tree p, Type ty);\nextern Tree rightkid(Tree p);\nextern int hascall(Tree p);\nextern Type binary(Type, Type);\nextern Tree cast(Tree, Type);\nextern Tree cond(Tree);\nextern Tree expr0(int);\nextern Tree expr(int);\nextern Tree expr1(int);\nextern Tree field(Tree, const char *);\nextern char *funcname(Tree);\nextern Tree idtree(Symbol);\nextern Tree incr(int, Tree, Tree);\nextern Tree lvalue(Tree);\nextern Tree nullcall(Type, Symbol, Tree, Tree);\nextern Tree pointer(Tree);\nextern Tree rvalue(Tree);\nextern Tree value(Tree);\n\nextern void defpointer(Symbol);\nextern Type initializer(Type, int);\nextern void swtoseg(int);\n\nextern void input_init(int, char *[]);\nextern void fillbuf(void);\nextern void nextline(void);\n\nextern int getchr(void);\nextern int gettok(void);\n\nextern void emitcode(void);\nextern void gencode (Symbol[], Symbol[]);\nextern void fprint(FILE *f, const char *fmt, ...);\nextern char *stringf(const char *, ...);\nextern void check(Node);\nextern void print(const char *, ...);\n\nextern List append(void *x, List list);\nextern int  length(List list);\nextern void *ltov (List *list, unsigned a);\nextern void init(int, char *[]);\n\nextern Type typename(void);\nextern void checklab(Symbol p, void *cl);\nextern Type enumdcl(void);\nextern void main_init(int, char *[]);\nextern int main(int, char *[]);\n\nextern void vfprint(FILE *, char *, const char *, va_list);\n\nextern int process(char *);\nextern int findfunc(char *, char *);\nextern int findcount(char *, int, int);\n\nextern Tree constexpr(int);\nextern int intexpr(int, int);\nextern Tree simplify(int, Type, Tree, Tree);\nextern int ispow2(unsigned long u);\n\nextern int reachable(int);\n\nextern void addlocal(Symbol);\nextern void branch(int);\nextern Code code(int);\nextern void definelab(int);\nextern void definept(Coordinate *);\nextern void equatelab(Symbol, Symbol);\nextern Node jump(int);\nextern void retcode(Tree);\nextern void statement(int, Swtch, int);\nextern void swcode(Swtch, int *, int, int);\nextern void swgen(Swtch);\n\nextern char * string(const char *str);\nextern char *stringn(const char *str, int len);\nextern char *stringd(long n);\nextern Symbol relocate(const char *name, Table src, Table dst);\nextern void use(Symbol p, Coordinate src);\nextern void locus(Table tp, Coordinate *cp);\nextern Symbol allsymbols(Table);\n\nextern Symbol constant(Type, Value);\nextern void enterscope(void);\nextern void exitscope(void);\nextern Symbol findlabel(int);\nextern Symbol findtype(Type);\nextern void foreach(Table, int, void (*)(Symbol, void *), void *);\nextern Symbol genident(int, Type, int);\nextern int genlabel(int);\nextern Symbol install(const char *, Table *, int, int);\nextern Symbol intconst(int);\nextern Symbol lookup(const char *, Table);\nextern Symbol mkstr(char *);\nextern Symbol mksymbol(int, const char *, Type);\nextern Symbol newtemp(int, int, int);\nextern Table table(Table, int);\nextern Symbol temporary(int, Type);\nextern char *vtoa(Type, Value);\n\nextern int nodeid(Tree);\nextern char *opname(int);\nextern int *printed(int);\nextern void printtree(Tree, int);\nextern Tree root(Tree);\nextern Tree texpr(Tree (*)(int), int, int);\nextern Tree tree(int, Type, Tree, Tree);\n\nextern void type_init(int, char *[]);\n\nextern Type signedint(Type);\n\nextern int hasproto(Type);\nextern void outtype(Type, FILE *);\nextern void printdecl (Symbol p, Type ty);\nextern void printproto(Symbol p, Symbol args[]);\nextern char *typestring(Type ty, char *id);\nextern Field fieldref(const char *name, Type ty);\nextern Type array(Type, int, int);\nextern Type atop(Type);\nextern Type btot(int, int);\nextern Type compose(Type, Type);\nextern Type deref(Type);\nextern int eqtype(Type, Type, int);\nextern Field fieldlist(Type);\nextern Type freturn(Type);\nextern Type ftype(Type, Type);\nextern Type func(Type, Type *, int);\nextern Field newfield(char *, Type, Type);\nextern Type newstruct(int, char *);\nextern void printtype(Type, int);\nextern Type promote(Type);\nextern Type ptr(Type);\nextern Type qual(int, Type);\nextern void rmtypes(int);\nextern int ttob(Type);\nextern int variadic(Type);\n\n"
  },
  {
    "path": "lcc/src/config.h",
    "content": "typedef struct {\n\tunsigned char max_unaligned_load;\n\tSymbol (*rmap)(int);\n\n\tvoid (*blkfetch)(int size, int off, int reg, int tmp);\n\tvoid (*blkstore)(int size, int off, int reg, int tmp);\n\tvoid (*blkloop)(int dreg, int doff,\n\t                 int sreg, int soff,\n\t                 int size, int tmps[]);\n\tvoid (*_label)(Node);\n\tint (*_rule)(void*, int);\n\tshort **_nts;\n\tvoid (*_kids)(Node, int, Node*);\n\tchar **_string;\n\tchar **_templates;\n\tchar *_isinstruction;\n\tchar **_ntname;\n\tvoid (*emit2)(Node);\n\tvoid (*doarg)(Node);\n\tvoid (*target)(Node);\n\tvoid (*clobber)(Node);\n} Xinterface;\nextern int     askregvar(Symbol, Symbol);\nextern void    blkcopy(int, int, int, int, int, int[]);\nextern int     getregnum(Node);\nextern int     mayrecalc(Node);\nextern int     mkactual(int, int);\nextern void    mkauto(Symbol);\nextern Symbol  mkreg(char *, int, int, int);\nextern Symbol  mkwildcard(Symbol *);\nextern int     move(Node);\nextern int     notarget(Node);\nextern void    parseflags(int, char **);\nextern int     range(Node, int, int);\nextern unsigned regloc(Symbol);  /* omit */\nextern void    rtarget(Node, int, Symbol);\nextern void    setreg(Node, Symbol);\nextern void    spill(unsigned, int, Node);\nextern int     widens(Node);\n\nextern int      argoffset, maxargoffset;\nextern int      bflag, dflag;\nextern int      dalign, salign;\nextern int      framesize;\nextern unsigned freemask[], usedmask[];\nextern int      offset, maxoffset;\nextern int      swap;\nextern unsigned tmask[], vmask[];\ntypedef struct {\n\tunsigned listed:1;\n\tunsigned registered:1;\n\tunsigned emitted:1;\n\tunsigned copy:1;\n\tunsigned equatable:1;\n\tunsigned spills:1;\n\tunsigned mayrecalc:1;\n\tvoid *state;\n\tshort inst;\n\tNode kids[3];\n\tNode prev, next;\n\tNode prevuse;\n\tshort argno;\n} Xnode;\ntypedef struct {\n\tSymbol vbl;\n\tshort set;\n\tshort number;\n\tunsigned mask;\n} *Regnode;\nenum { IREG=0, FREG=1 };\ntypedef struct {\n\tchar *name;\n\tunsigned int eaddr;  /* omit */\n\tint offset;\n\tNode lastuse;\n\tint usecount;\n\tRegnode regnode;\n\tSymbol *wildcard;\n} Xsymbol;\nenum { RX=2 };\ntypedef struct {\n\tint offset;\n\tunsigned freemask[2];\n} Env;\n\n#define LBURG_MAX SHRT_MAX\n\nenum { VREG=(44<<4) };\n\n/* Exported for the front end */\nextern void             blockbeg(Env *);\nextern void             blockend(Env *);\nextern void             emit(Node);\nextern Node             gen(Node);\n\nextern unsigned         emitbin(Node, int);\n\n#ifdef NDEBUG\n#define debug(x) (void)0\n#else\n#define debug(x) (void)(dflag&&((x),0))\n#endif\n"
  },
  {
    "path": "lcc/src/dag.c",
    "content": "#include \"c.h\"\n\n\n#define iscall(op) (generic(op) == CALL \\\n\t|| IR->mulops_calls \\\n\t&& (generic(op)==DIV||generic(op)==MOD||generic(op)==MUL) \\\n\t&& ( optype(op)==U  || optype(op)==I))\nstatic Node forest;\nstatic struct dag {\n\tstruct node node;\n\tstruct dag *hlink;\n} *buckets[16];\nint nodecount;\nstatic Tree firstarg;\nint assignargs = 1;\nint prunetemps = -1;\nstatic Node *tail;\n\nstatic int depth = 0;\nstatic Node replace(Node);\nstatic Node prune(Node);\nstatic Node asgnnode(Symbol, Node);\nstatic struct dag *dagnode(int, Node, Node, Symbol);\nstatic Symbol equated(Symbol);\nstatic void fixup(Node);\nstatic void labelnode(int);\nstatic void list(Node);\nstatic void kill(Symbol);\nstatic Node node(int, Node, Node, Symbol);\nstatic void printdag1(Node, int, int);\nstatic void printnode(Node, int, int);\nstatic void reset(void);\nstatic Node tmpnode(Node);\nstatic void typestab(Symbol, void *);\nstatic Node undag(Node);\nstatic Node visit(Node, int);\nstatic void unlist(void);\nvoid walk(Tree tp, int tlab, int flab) {\n\tlistnodes(tp, tlab, flab);\n\tif (forest) {\n\t\tNode list = forest->link;\n\t\tforest->link = NULL;\n\t\tif (!IR->wants_dag)\n\t\t\tlist = undag(list);\n\t\tcode(Gen)->u.forest = list;\n\t\tforest = NULL;\n\t}\n\treset();\n\tdeallocate(STMT);\n}\n\nstatic Node node(int op, Node l, Node r, Symbol sym) {\n\tint i;\n\tstruct dag *p;\n\n\ti = (opindex(op)^((unsigned long)sym>>2))&(NELEMS(buckets)-1);\n\tfor (p = buckets[i]; p; p = p->hlink)\n\t\tif (p->node.op      == op && p->node.syms[0] == sym\n\t\t&&  p->node.kids[0] == l  && p->node.kids[1] == r)\n\t\t\treturn &p->node;\n\tp = dagnode(op, l, r, sym);\n\tp->hlink = buckets[i];\n\tbuckets[i] = p;\n\t++nodecount;\n\treturn &p->node;\n}\nstatic struct dag *dagnode(int op, Node l, Node r, Symbol sym) {\n\tstruct dag *p;\n\n\tNEW0(p, FUNC);\n\tp->node.op = op;\n\tif ((p->node.kids[0] = l) != NULL)\n\t\t++l->count;\n\tif ((p->node.kids[1] = r) != NULL)\n\t\t++r->count;\n\tp->node.syms[0] = sym;\n\treturn p;\n}\nNode newnode(int op, Node l, Node r, Symbol sym) {\n\treturn &dagnode(op, l, r, sym)->node;\n}\nstatic void kill(Symbol p) {\n\tint i;\n\tstruct dag **q;\n\n\tfor (i = 0; i < NELEMS(buckets); i++)\n\t\tfor (q = &buckets[i]; *q; )\n\t\t\tif (generic((*q)->node.op) == INDIR &&\n\t\t\t    (!isaddrop((*q)->node.kids[0]->op)\n\t\t\t     || (*q)->node.kids[0]->syms[0] == p)) {\n\t\t\t\t*q = (*q)->hlink;\n\t\t\t\t--nodecount;\n\t\t\t} else\n\t\t\t\tq = &(*q)->hlink;\n}\nstatic void reset(void) {\n\tif (nodecount > 0)\n\t\tmemset(buckets, 0, sizeof buckets);\n\tnodecount = 0;\n}\nNode listnodes(Tree tp, int tlab, int flab) {\n\tNode p = NULL, l, r;\n\tint op;\n\n\tassert(tlab || flab || tlab == 0 && flab == 0);\n\tif (tp == NULL)\n\t\treturn NULL;\n\tif (tp->node)\n\t\treturn tp->node;\n\top = tp->op + sizeop(tp->type->size);\n\tswitch (generic(tp->op)) {\n\tcase AND:   { if (depth++ == 0) reset();\n\t\t      if (flab) {\n\t\t      \tlistnodes(tp->kids[0], 0, flab);\n\t\t      \tlistnodes(tp->kids[1], 0, flab);\n\t\t      } else {\n\t\t      \tlistnodes(tp->kids[0], 0, flab = genlabel(1));\n\t\t      \tlistnodes(tp->kids[1], tlab, 0);\n\t\t      \tlabelnode(flab);\n\t\t      }\n\t\t      depth--; } break;\n\tcase OR:    { if (depth++ == 0)\n\t\t      \treset();\n\t\t      if (tlab) {\n\t\t      \tlistnodes(tp->kids[0], tlab, 0);\n\t\t      \tlistnodes(tp->kids[1], tlab, 0);\n\t\t      } else {\n\t\t      \ttlab = genlabel(1);\n\t\t      \tlistnodes(tp->kids[0], tlab, 0);\n\t\t      \tlistnodes(tp->kids[1], 0, flab);\n\t\t      \tlabelnode(tlab);\n\t\t      }\n\t\t      depth--;\n } break;\n\tcase NOT:   { return listnodes(tp->kids[0], flab, tlab); }\n\tcase COND:  { Tree q = tp->kids[1];\n\t\t      assert(tlab == 0 && flab == 0);\n\t\t      if (tp->u.sym)\n\t\t      \taddlocal(tp->u.sym);\n\t\t      flab = genlabel(2);\n\t\t      listnodes(tp->kids[0], 0, flab);\n\t\t      assert(q && q->op == RIGHT);\n\t\t      reset();\n\t\t      listnodes(q->kids[0], 0, 0);\n\t\t      if (forest->op == LABEL+V) {\n\t\t      \tequatelab(forest->syms[0], findlabel(flab + 1));\n\t\t      \tunlist();\n\t\t      }\n\t\t      list(jump(flab + 1));\n\t\t      labelnode(flab);\n\t\t      listnodes(q->kids[1], 0, 0);\n\t\t      if (forest->op == LABEL+V) {\n\t\t      \tequatelab(forest->syms[0], findlabel(flab + 1));\n\t\t      \tunlist();\n\t\t      }\n\t\t      labelnode(flab + 1);\n\n\t\t      if (tp->u.sym)\n\t\t      \tp = listnodes(idtree(tp->u.sym), 0, 0); } break;\n\tcase CNST:  { Type ty = unqual(tp->type);\n\t\t      assert(ty->u.sym);\n\t\t      if (tlab || flab) {\n\t\t      \tassert(ty == inttype);\n\t\t      \tif (tlab && tp->u.v.i != 0)\n\t\t      \t\tlist(jump(tlab));\n\t\t      \telse if (flab && tp->u.v.i == 0)\n\t\t      \t\tlist(jump(flab));\n\t\t      }\n\t\t      else if (ty->u.sym->addressed)\n\t\t      \tp = listnodes(cvtconst(tp), 0, 0);\n\t\t      else\n\t\t      \tp = node(op, NULL, NULL, constant(ty, tp->u.v)); } break;\n\tcase RIGHT: { if (   tp->kids[0] && tp->kids[1]\n\t\t\t  &&  generic(tp->kids[1]->op) == ASGN\n\t\t\t  && (generic(tp->kids[0]->op) == INDIR\n\t\t\t  && tp->kids[0]->kids[0] == tp->kids[1]->kids[0]\n\t\t\t  || (tp->kids[0]->op == FIELD\n\t\t\t  &&  tp->kids[0] == tp->kids[1]->kids[0]))) {\n\t\t      \tassert(tlab == 0 && flab == 0);\n\t\t\tif (generic(tp->kids[0]->op) == INDIR) {\n\t\t\t\tp = listnodes(tp->kids[0], 0, 0);\n\t\t\t\tlist(p);\n\t\t\t\tlistnodes(tp->kids[1], 0, 0);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tassert(generic(tp->kids[0]->kids[0]->op) == INDIR);\n\t\t\t\tlist(listnodes(tp->kids[0]->kids[0], 0, 0));\n\t\t\t\tp = listnodes(tp->kids[0], 0, 0);\n\t\t\t\tlistnodes(tp->kids[1], 0, 0);\n\t\t\t}\n\t\t      } else if (tp->kids[1]) {\n\t\t      \tlistnodes(tp->kids[0], 0, 0);\n\t\t      \tp = listnodes(tp->kids[1], tlab, flab);\n\t\t      } else\n\t\t      \tp = listnodes(tp->kids[0], tlab, flab); } break;\n\tcase JUMP:  { assert(tlab == 0 && flab == 0);\n\t\t      assert(tp->u.sym == 0);\n\t\t      assert(tp->kids[0]);\n\t\t      l = listnodes(tp->kids[0], 0, 0);\n\t\t      list(newnode(JUMP+V, l, NULL, NULL));\n\t\t      reset(); } break;\n\tcase CALL:  { Tree save = firstarg;\n\t\t      firstarg = NULL;\n\t\t      assert(tlab == 0 && flab == 0);\n\t\t      if (tp->op == CALL+B && !IR->wants_callb) {\n\t\t      \tTree arg0 = tree(ARG+P, tp->kids[1]->type,\n\t\t\t\ttp->kids[1], NULL);\n\t\t\tif (IR->left_to_right)\n\t\t\t\tfirstarg = arg0;\n\t\t\tl = listnodes(tp->kids[0], 0, 0);\n\t\t\tif (!IR->left_to_right || firstarg) {\n\t\t\t\tfirstarg = NULL;\n\t\t\t\tlistnodes(arg0, 0, 0);\n\t\t\t}\n\t\t      \tp = newnode(CALL+V, l, NULL, NULL);\n\t\t      } else {\n\t\t      \tl = listnodes(tp->kids[0], 0, 0);\n\t\t      \tr = listnodes(tp->kids[1], 0, 0);\n\t\t      \tp = newnode(tp->op == CALL+B ? tp->op : op, l, r, NULL);\n\t\t      }\n\t\t      NEW0(p->syms[0], FUNC);\n\t\t      assert(isptr(tp->kids[0]->type));\n\t\t      assert(isfunc(tp->kids[0]->type->type));\n\t\t      p->syms[0]->type = tp->kids[0]->type->type;\n\t\t      list(p);\n\t\t      reset();\n\t\t      cfunc->u.f.ncalls++;\n\t\t      firstarg = save;\n } break;\n\tcase ARG:   { assert(tlab == 0 && flab == 0);\n\t\t      if (IR->left_to_right)\n\t\t      \tlistnodes(tp->kids[1], 0, 0);\n\t\t      if (firstarg) {\n\t\t      \tTree arg = firstarg;\n\t\t      \tfirstarg = NULL;\n\t\t      \tlistnodes(arg, 0, 0);\n\t\t      }\n\t\t      l = listnodes(tp->kids[0], 0, 0);\n\t\t      list(newnode(tp->op == ARG+B ? tp->op : op, l, NULL, NULL));\n\t\t      forest->syms[0] = intconst(tp->type->size);\n\t\t      forest->syms[1] = intconst(tp->type->align);\n\t\t      if (!IR->left_to_right)\n\t\t      \tlistnodes(tp->kids[1], 0, 0); } break;\n\tcase EQ:  case NE: case GT: case GE: case LE:\n\tcase LT:    { assert(tp->u.sym == 0);\n\t\t      assert(errcnt || tlab || flab);\n\t\t      l = listnodes(tp->kids[0], 0, 0);\n\t\t      r = listnodes(tp->kids[1], 0, 0);\n\t\t      assert(errcnt || opkind(l->op) == opkind(r->op));\n\t\t      assert(errcnt || optype(op) == optype(l->op));\n\t\t      if (tlab)\n\t\t      \tassert(flab == 0),\n\t\t      \tlist(newnode(generic(tp->op) + opkind(l->op), l, r, findlabel(tlab)));\n\t\t      else if (flab) {\n\t\t      \tswitch (generic(tp->op)) {\n\t\t      \tcase EQ: op = NE; break;\n\t\t      \tcase NE: op = EQ; break;\n\t\t      \tcase GT: op = LE; break;\n\t\t      \tcase LT: op = GE; break;\n\t\t      \tcase GE: op = LT; break;\n\t\t      \tcase LE: op = GT; break;\n\t\t      \tdefault: assert(0);\n\t\t      \t}\n\t\t      \tlist(newnode(op + opkind(l->op), l, r, findlabel(flab)));\n\t\t      }\n\t\t      if (forest && forest->syms[0])\n\t\t      \tforest->syms[0]->ref++; } break;\n\tcase ASGN:  { assert(tlab == 0 && flab == 0);\n\t\t      if (tp->kids[0]->op == FIELD) {\n\t\t      \tTree  x = tp->kids[0]->kids[0];\n\t\t\tField f = tp->kids[0]->u.field;\n\t\t\tassert(generic(x->op) == INDIR);\n\t\t\treset();\n\t\t\tl = listnodes(lvalue(x), 0, 0);\n\t\t\tif (fieldsize(f) < 8*f->type->size) {\n\t\t\t\tunsigned int fmask = fieldmask(f);\n\t\t\t\tunsigned int  mask = fmask<<fieldright(f);\n\t\t\t\tTree q = tp->kids[1];\n\t\t\t\tif (q->op == CNST+I && q->u.v.i == 0\n\t\t\t\t||  q->op == CNST+U && q->u.v.u == 0)\n\t\t\t\t\tq = bittree(BAND, x, cnsttree(unsignedtype, (unsigned long)~mask));\n\t\t\t\telse if (q->op == CNST+I && (q->u.v.i&fmask) == fmask\n\t\t\t\t||       q->op == CNST+U && (q->u.v.u&fmask) == fmask)\n\t\t\t\t\tq = bittree(BOR, x, cnsttree(unsignedtype, (unsigned long)mask));\n\t\t\t\telse {\n\t\t\t\t\tlistnodes(q, 0, 0);\n\t\t\t\t\tq = bittree(BOR,\n\t\t\t\t\t\tbittree(BAND, rvalue(lvalue(x)),\n\t\t\t\t\t\t\tcnsttree(unsignedtype, (unsigned long)~mask)),\n\t\t\t\t\t\tbittree(BAND, shtree(LSH, cast(q, unsignedtype),\n\t\t\t\t\t\t\tcnsttree(unsignedtype, (unsigned long)fieldright(f))),\n\t\t\t\t\t\t\tcnsttree(unsignedtype, (unsigned long)mask)));\n\t\t\t\t}\n\t\t\t\tr = listnodes(q, 0, 0);\n\t\t\t\top = ASGN + ttob(q->type);\n\t\t\t} else {\n\t\t\t\tr = listnodes(tp->kids[1], 0, 0);\n\t\t\t\top = ASGN + ttob(tp->kids[1]->type);\n\t\t\t}\n\t\t      } else {\n\t\t      \tl = listnodes(tp->kids[0], 0, 0);\n\t\t      \tr = listnodes(tp->kids[1], 0, 0);\n\t\t      }\n\t\t      list(newnode(tp->op == ASGN+B ? tp->op : op, l, r, NULL));\n\t\t      forest->syms[0] = intconst(tp->kids[1]->type->size);\n\t\t      forest->syms[1] = intconst(tp->kids[1]->type->align);\n\t\t      if (isaddrop(tp->kids[0]->op)\n\t\t      && !tp->kids[0]->u.sym->computed)\n\t\t      \tkill(tp->kids[0]->u.sym);\n\t\t      else\n\t\t      \treset();\n\t\t      p = listnodes(tp->kids[1], 0, 0); } break;\n\tcase BOR: case BAND: case BXOR:\n\tcase ADD: case SUB:  case RSH:\n\tcase LSH:   { assert(tlab == 0 && flab == 0);\n\t\t      l = listnodes(tp->kids[0], 0, 0);\n\t\t      r = listnodes(tp->kids[1], 0, 0);\n\t\t      p = node(op, l, r, NULL); } break;\n\tcase DIV: case MUL:\n\tcase MOD:   { assert(tlab == 0 && flab == 0);\n\t\t      l = listnodes(tp->kids[0], 0, 0);\n\t\t      r = listnodes(tp->kids[1], 0, 0);\n\t\t      p = node(op, l, r, NULL);\n\t\t      if (IR->mulops_calls && isint(tp->type)) {\n\t\t      \tlist(p);\n\t\t      \tcfunc->u.f.ncalls++;\n\t\t      } } break;\n\tcase RET:   { assert(tlab == 0 && flab == 0);\n\t\t      l = listnodes(tp->kids[0], 0, 0);\n\t\t      list(newnode(op, l, NULL, NULL)); } break;\n\tcase CVF: case CVI: case CVP:\n\tcase CVU:   { assert(tlab == 0 && flab == 0);\n\t\t      assert(optype(tp->kids[0]->op) != optype(tp->op) || tp->kids[0]->type->size != tp->type->size);\n\t\t      l = listnodes(tp->kids[0], 0, 0);\n\t\t      p = node(op, l, NULL, intconst(tp->kids[0]->type->size));\n } break;\n\tcase BCOM:\n\tcase NEG:   { assert(tlab == 0 && flab == 0);\n\t\t      l = listnodes(tp->kids[0], 0, 0);\n\t\t      p = node(op, l, NULL, NULL); } break;\n\tcase INDIR: { Type ty = tp->kids[0]->type;\n\t\t      assert(tlab == 0 && flab == 0);\n\t\t      l = listnodes(tp->kids[0], 0, 0);\n\t\t      if (isptr(ty))\n\t\t      \tty = unqual(ty)->type;\n\t\t      if (isvolatile(ty)\n\t\t      || (isstruct(ty) && unqual(ty)->u.sym->u.s.vfields))\n\t\t      \tp = newnode(tp->op == INDIR+B ? tp->op : op, l, NULL, NULL);\n\t\t      else\n\t\t      \tp = node(tp->op == INDIR+B ? tp->op : op, l, NULL, NULL); } break;\n\tcase FIELD: { Tree q = tp->kids[0];\n\t\t      if (tp->type == inttype) {\n\t\t      \tlong n = fieldleft(tp->u.field);\n\t\t      \tq = shtree(RSH,\n\t\t      \t\tshtree(LSH, q, cnsttree(inttype, n)),\n\t\t      \t\tcnsttree(inttype, n + fieldright(tp->u.field)));\n\t\t      } else if (fieldsize(tp->u.field) < 8*tp->u.field->type->size)\n\t\t      \tq = bittree(BAND,\n\t\t      \t\tshtree(RSH, q, cnsttree(inttype, (long)fieldright(tp->u.field))),\n\t\t      \t\tcnsttree(unsignedtype, (unsigned long)fieldmask(tp->u.field)));\n\t\t      assert(tlab == 0 && flab == 0);\n\t\t      p = listnodes(q, 0, 0); } break;\n\tcase ADDRG:\n\tcase ADDRF: { assert(tlab == 0 && flab == 0);\n\t\t      p = node(tp->op + sizeop(voidptype->size), NULL, NULL, tp->u.sym);\n } break;\n\tcase ADDRL: { assert(tlab == 0 && flab == 0);\n\t\t      if (tp->u.sym->temporary)\n\t\t      \taddlocal(tp->u.sym);\n\t\t      p = node(tp->op + sizeop(voidptype->size), NULL, NULL, tp->u.sym); } break;\n\tdefault:assert(0);\n\t}\n\ttp->node = p;\n\treturn p;\n}\nstatic void list(Node p) {\n\tif (p && p->link == NULL) {\n\t\tif (forest) {\n\t\t\tp->link = forest->link;\n\t\t\tforest->link = p;\n\t\t} else\n\t\t\tp->link = p;\n\t\tforest = p;\n\t}\n}\nstatic void labelnode(int lab) {\n\tassert(lab);\n\tif (forest && forest->op == LABEL+V)\n\t\tequatelab(findlabel(lab), forest->syms[0]);\n\telse\n\t\tlist(newnode(LABEL+V, NULL, NULL, findlabel(lab)));\n\treset();\n}\nstatic void unlist(void) {\n\tNode p;\n\n\tassert(forest);\n\tassert(forest != forest->link);\n\tp = forest->link;\n\twhile (p->link != forest)\n\t\tp = p->link;\n\tp->link = forest->link;\n\tforest = p;\n}\nTree cvtconst(Tree p) {\n\tSymbol q = constant(p->type, p->u.v);\n\tTree e;\n\n\tif (q->u.c.loc == NULL)\n\t\tq->u.c.loc = genident(STATIC, p->type, GLOBAL);\n\tif (isarray(p->type)) {\n\t\te = simplify(ADDRG, atop(p->type), NULL, NULL);\n\t\te->u.sym = q->u.c.loc;\n\t} else\n\t\te = idtree(q->u.c.loc);\n\treturn e;\n}\nvoid gencode(Symbol caller[], Symbol callee[]) {\n\tCode cp;\n\tCoordinate save;\n\n\tif (prunetemps == -1)\n\t\tprunetemps = !IR->wants_dag;\n\tsave = src;\n\tif (assignargs) {\n\t\tint i;\n\t\tSymbol p, q;\n\t\tcp = codehead.next->next;\n\t\tcodelist = codehead.next;\n\t\tfor (i = 0; (p = callee[i]) != NULL\n\t\t         && (q = caller[i]) != NULL; i++)\n\t\t\tif (p->sclass != q->sclass || p->type != q->type)\n\t\t\t\twalk(asgn(p, idtree(q)), 0, 0);\n\t\tcodelist->next = cp;\n\t\tcp->prev = codelist;\n\t}\n\tif (glevel && IR->stabsym) {\n\t\tint i;\n\t\tSymbol p, q;\n\t\tfor (i = 0; (p = callee[i]) != NULL\n\t\t         && (q = caller[i]) != NULL; i++) {\n\t\t\t(*IR->stabsym)(p);\n\t\t\tif (p->sclass != q->sclass || p->type != q->type)\n\t\t\t\t(*IR->stabsym)(q);\n\t\t}\n\t\tswtoseg(CODE);\n\t}\n\tcp = codehead.next;\n\tfor ( ; errcnt <= 0 && cp; cp = cp->next)\n\t\tswitch (cp->kind) {\n\t\tcase Address:  (*IR->address)(cp->u.addr.sym, cp->u.addr.base,\n\t\t\t       \tcp->u.addr.offset); break;\n\t\tcase Blockbeg: {\n\t\t\t       \tSymbol *p = cp->u.block.locals;\n\t\t\t       \t(*IR->blockbeg)(&cp->u.block.x);\n\t\t\t       \tfor ( ; *p; p++)\n\t\t\t       \t\tif ((*p)->ref != 0.0)\n\t\t\t       \t\t\t(*IR->local)(*p);\n\t\t\t       \t\telse if (glevel) (*IR->local)(*p);\n\t\t\t       }\n break;\n\t\tcase Blockend: (*IR->blockend)(&cp->u.begin->u.block.x); break;\n\t\tcase Defpoint: src = cp->u.point.src; break;\n\t\tcase Gen: case Jump:\n\t\tcase Label:    if (prunetemps)\n\t\t\t       \tcp->u.forest = prune(cp->u.forest);\n\t\t\t       fixup(cp->u.forest);\n\t\t\t       cp->u.forest = (*IR->gen)(cp->u.forest); break;\n\t\tcase Local:    (*IR->local)(cp->u.var); break;\n\t\tcase Switch:   break;\n\t\tdefault: assert(0);\n\t\t}\n\tsrc = save;\n}\nstatic void fixup(Node p) {\n\tfor ( ; p; p = p->link)\n\t\tswitch (generic(p->op)) {\n\t\tcase JUMP:\n\t\t\tif (specific(p->kids[0]->op) == ADDRG+P)\n\t\t\t\tp->kids[0]->syms[0] =\n\t\t\t\t\tequated(p->kids[0]->syms[0]);\n\t\t\tbreak;\n\t\tcase LABEL: assert(p->syms[0] == equated(p->syms[0])); break;\n\t\tcase EQ: case GE: case GT: case LE: case LT: case NE:\n\t\t\tassert(p->syms[0]);\n\t\t\tp->syms[0] = equated(p->syms[0]);\n\t\t}\n}\nstatic Symbol equated(Symbol p) {\n\t{ Symbol q; for (q = p->u.l.equatedto; q; q = q->u.l.equatedto) assert(p != q); }\n\twhile (p->u.l.equatedto)\n\t\tp = p->u.l.equatedto;\n\treturn p;\n}\nvoid emitcode(void) {\n\tCode cp;\n\tCoordinate save;\n\n\tsave = src;\n\tcp = codehead.next;\n\tfor ( ; errcnt <= 0 && cp; cp = cp->next)\n\t\tswitch (cp->kind) {\n\t\tcase Address: break;\n\t\tcase Blockbeg: if (glevel && IR->stabblock) {\n\t\t\t       \t(*IR->stabblock)('{',  cp->u.block.level - LOCAL, cp->u.block.locals);\n\t\t\t       \tswtoseg(CODE);\n\t\t\t       }\n break;\n\t\tcase Blockend: if (glevel && IR->stabblock) {\n\t\t\t       \tCode bp = cp->u.begin;\n\t\t\t       \tforeach(bp->u.block.identifiers, bp->u.block.level, typestab, NULL);\n\t\t\t       \tforeach(bp->u.block.types,       bp->u.block.level, typestab, NULL);\n\t\t\t       \t(*IR->stabblock)('}', bp->u.block.level - LOCAL, bp->u.block.locals);\n\t\t\t       \tswtoseg(CODE);\n\t\t\t       }\n break;\n\t\tcase Defpoint: src = cp->u.point.src;\n\t\t\t       if (glevel > 0 && IR->stabline) {\n\t\t\t       \t(*IR->stabline)(&cp->u.point.src); swtoseg(CODE); } break;\n\t\tcase Gen: case Jump:\n\t\tcase Label:    if (cp->u.forest)\n\t\t\t       \t(*IR->emit)(cp->u.forest); break;\n\t\tcase Local:    if (glevel && IR->stabsym) {\n\t\t\t       \t(*IR->stabsym)(cp->u.var);\n\t\t\t       \tswtoseg(CODE);\n\t\t\t       } break;\n\t\tcase Switch:   {\tint i;\n\t\t\t       \tdefglobal(cp->u.swtch.table, LIT);\n\t\t\t       \t(*IR->defaddress)(equated(cp->u.swtch.labels[0]));\n\t\t\t       \tfor (i = 1; i < cp->u.swtch.size; i++) {\n\t\t\t       \t\tlong k = cp->u.swtch.values[i-1];\n\t\t\t       \t\twhile (++k < cp->u.swtch.values[i])\n\t\t\t       \t\t\tassert(k < LONG_MAX),\n\t\t\t       \t\t\t(*IR->defaddress)(equated(cp->u.swtch.deflab));\n\t\t\t       \t\t(*IR->defaddress)(equated(cp->u.swtch.labels[i]));\n\t\t\t       \t}\n\t\t\t       \tswtoseg(CODE);\n\t\t\t       } break;\n\t\tdefault: assert(0);\n\t\t}\n\tsrc = save;\n}\n\nstatic Node undag(Node forest) {\n\tNode p;\n\n\ttail = &forest;\n\tfor (p = forest; p; p = p->link)\n\t\tif (generic(p->op) == INDIR) {\n\t\t\tassert(p->count >= 1);\n\t\t\tvisit(p, 1);\n\t\t\tif (p->syms[2]) {\n\t\t\t\tassert(p->syms[2]->u.t.cse);\n\t\t\t\tp->syms[2]->u.t.cse = NULL;\n\t\t\t\taddlocal(p->syms[2]);\n\t\t\t}\n\t\t} else if (iscall(p->op) && p->count >= 1)\n\t\t\tvisit(p, 1);\n\t\telse {\n\t\t\tassert(p->count == 0),\n\t\t\tvisit(p, 1);\n\t\t\t*tail = p;\n\t\t\ttail = &p->link;\n\t\t}\n\t*tail = NULL;\n\treturn forest;\n}\nstatic Node replace(Node p) {\n\tif (p && (  generic(p->op) == INDIR\n\t\t && generic(p->kids[0]->op) == ADDRL\n\t\t && p->kids[0]->syms[0]->temporary\n\t\t && p->kids[0]->syms[0]->u.t.replace)) {\n\t\tp = p->kids[0]->syms[0]->u.t.cse;\n\t\tif (generic(p->op) == INDIR && isaddrop(p->kids[0]->op))\n\t\t\tp = newnode(p->op, newnode(p->kids[0]->op, NULL, NULL,\n\t\t\t\tp->kids[0]->syms[0]), NULL, NULL);\n\t\telse if (generic(p->op) == ADDRG)\n\t\t\tp = newnode(p->op, NULL, NULL, p->syms[0]);\n\t\telse\n\t\t\tassert(0);\n\t\tp->count = 1;\n\t} else if (p) {\n\t\tp->kids[0] = replace(p->kids[0]);\n\t\tp->kids[1] = replace(p->kids[1]);\n\t}\n\treturn p;\n}\nstatic Node prune(Node forest) {\n\tNode p, *tail = &forest;\n\tint count = 0;\n\n\tfor (p = forest; p; p = p->link) {\n\t\tif (count > 0) {\n\t\t\tp->kids[0] = replace(p->kids[0]);\n\t\t\tp->kids[1] = replace(p->kids[1]);\n\t\t}\n\t\tif ((  generic(p->op) == ASGN\n\t\t    && generic(p->kids[0]->op) == ADDRL\n\t\t    && p->kids[0]->syms[0]->temporary\n\t\t    && p->kids[0]->syms[0]->u.t.cse == p->kids[1])) {\n\t\t\tSymbol tmp = p->kids[0]->syms[0];\n\t\t\tif (!tmp->defined)\n\t\t\t\t(*IR->local)(tmp);\n\t\t\ttmp->defined = 1;\n\t\t\tif ((  generic(p->kids[1]->op) == INDIR\n\t\t\t    && isaddrop(p->kids[1]->kids[0]->op)\n\t\t\t    && p->kids[1]->kids[0]->syms[0]->sclass == REGISTER)\n\t\t\t|| ((  generic(p->kids[1]->op) == INDIR\n\t\t\t    && isaddrop(p->kids[1]->kids[0]->op)) && tmp->sclass == AUTO)\n\t\t\t|| (generic(p->kids[1]->op) == ADDRG && tmp->sclass == AUTO)) {\n\t\t\t\ttmp->u.t.replace = 1;\n\t\t\t\tcount++;\n\t\t\t\tcontinue;\t/* and omit the assignment */\n\t\t\t}\n\t\t}\n\t\t/* keep the assignment and other roots */\n\t\t*tail = p;\n\t\ttail = &(*tail)->link;\n\t}\n\tassert(*tail == NULL);\n\treturn forest;\n}\nstatic Node visit(Node p, int listed) {\n\tif (p)\n\t\tif (p->syms[2])\n\t\t\tp = tmpnode(p);\n\t\telse if (p->count <= 1 && !iscall(p->op)\n\t\t||       p->count == 0 &&  iscall(p->op)) {\n\t\t\tp->kids[0] = visit(p->kids[0], 0);\n\t\t\tp->kids[1] = visit(p->kids[1], 0);\n\t\t}\n\n\t\telse if (specific(p->op) == ADDRL+P || specific(p->op) == ADDRF+P) {\n\t\t\tassert(!listed);\n\t\t\tp = newnode(p->op, NULL, NULL, p->syms[0]);\n\t\t\tp->count = 1;\n\t\t}\n\t\telse if (p->op == INDIR+B) {\n\t\t\tp = newnode(p->op, p->kids[0], NULL, NULL);\n\t\t\tp->count = 1;\n\t\t\tp->kids[0] = visit(p->kids[0], 0);\n\t\t\tp->kids[1] = visit(p->kids[1], 0);\n\t\t}\n\t\telse {\n\t\t\tp->kids[0] = visit(p->kids[0], 0);\n\t\t\tp->kids[1] = visit(p->kids[1], 0);\n\t\t\tp->syms[2] = temporary(REGISTER, btot(p->op, opsize(p->op)));\n\t\t\tassert(!p->syms[2]->defined);\n\t\t\tp->syms[2]->ref = 1;\n\t\t\tp->syms[2]->u.t.cse = p;\n\n\t\t\t*tail = asgnnode(p->syms[2], p);\n\t\t\ttail = &(*tail)->link;\n\t\t\tif (!listed)\n\t\t\t\tp = tmpnode(p);\n\t\t};\n\treturn p;\n}\nstatic Node tmpnode(Node p) {\n\tSymbol tmp = p->syms[2];\n\n\tassert(tmp);\n\tif (--p->count == 0)\n\t\tp->syms[2] = NULL;\n\tp = newnode(INDIR + ttob(tmp->type),\n\t\tnewnode(ADDRL + ttob(voidptype), NULL, NULL, tmp), NULL, NULL);\n\tp->count = 1;\n\treturn p;\n}\nstatic Node asgnnode(Symbol tmp, Node p) {\n\tp = newnode(ASGN + ttob(tmp->type),\n\t\tnewnode(ADDRL + ttob(voidptype), NULL, NULL, tmp), p, NULL);\n\tp->syms[0] = intconst(tmp->type->size);\n\tp->syms[1] = intconst(tmp->type->align);\n\treturn p;\n}\n/* printdag - print dag p on fd, or the node list if p == 0 */\nvoid printdag(Node p, int fd) {\n\tFILE *f = fd == 1 ? stdout : stderr;\n\n\tprinted(0);\n\tif (p == 0) {\n\t\tif ((p = forest) != NULL)\n\t\t\tdo {\n\t\t\t\tp = p->link;\n\t\t\t\tprintdag1(p, fd, 0);\n\t\t\t} while (p != forest);\n\t} else if (*printed(nodeid((Tree)p)))\n\t\tfprint(f, \"node'%d printed above\\n\", nodeid((Tree)p));\n\telse\n\t\tprintdag1(p, fd, 0);\n}\n\n/* printdag1 - recursively print dag p */\nstatic void printdag1(Node p, int fd, int lev) {\n\tint id, i;\n\n\tif (p == 0 || *printed(id = nodeid((Tree)p)))\n\t\treturn;\n\t*printed(id) = 1;\n\tfor (i = 0; i < NELEMS(p->kids); i++)\n\t\tprintdag1(p->kids[i], fd, lev + 1);\n\tprintnode(p, fd, lev);\n}\n\n/* printnode - print fields of dag p */\nstatic void printnode(Node p, int fd, int lev) {\n\tif (p) {\n\t\tFILE *f = fd == 1 ? stdout : stderr;\n\t\tint i, id = nodeid((Tree)p);\n\t\tfprint(f, \"%c%d%s\", lev == 0 ? '\\'' : '#', id,\n\t\t\t&\"   \"[id < 10 ? 0 : id < 100 ? 1 : 2]);\n\t\tfprint(f, \"%s count=%d\", opname(p->op), p->count);\n\t\tfor (i = 0; i < NELEMS(p->kids) && p->kids[i]; i++)\n\t\t\tfprint(f, \" #%d\", nodeid((Tree)p->kids[i]));\n\t\tif (generic(p->op) == CALL && p->syms[0] && p->syms[0]->type)\n\t\t\tfprint(f, \" {%t}\", p->syms[0]->type);\n\t\telse\n\t\t\tfor (i = 0; i < NELEMS(p->syms) && p->syms[i]; i++)\n\t\t\t\tif (p->syms[i]->name)\n\t\t\t\t\tfprint(f, \" %s\", p->syms[i]->name);\n\t\t\t\telse\n\t\t\t\t\tfprint(f, \" %p\", p->syms[i]);\n\t\tfprint(f, \"\\n\");\n\t}\n}\n\n/* typestab - emit stab entries for p */\nstatic void typestab(Symbol p, void *cl) {\n\tif (!isfunc(p->type) && (p->sclass == EXTERN || p->sclass == STATIC) && IR->stabsym)\n\t\t(*IR->stabsym)(p);\n\telse if ((p->sclass == TYPEDEF || p->sclass == 0) && IR->stabtype)\n\t\t(*IR->stabtype)(p);\n}\n\n"
  },
  {
    "path": "lcc/src/dagcheck.md",
    "content": "%{\n#include \"c.h\"\ntypedef Node NODEPTR_TYPE;\n#define OP_LABEL(p)     (specific((p)->op))\n#define LEFT_CHILD(p)   ((p)->kids[0])\n#define RIGHT_CHILD(p)  ((p)->kids[1])\n#define STATE_LABEL(p)  ((p)->x.state)\n#define PANIC\t   error\n%}\n%term CNSTF=17 CNSTI=21 CNSTP=23 CNSTU=22\n%term ARGB=41 ARGF=33 ARGI=37 ARGP=39 ARGU=38\n%term ASGNB=57 ASGNF=49 ASGNI=53 ASGNP=55 ASGNU=54\n%term INDIRB=73 INDIRF=65 INDIRI=69 INDIRP=71 INDIRU=70\n%term CVFF=113 CVFI=117\n%term CVIF=129 CVII=133 CVIU=134\n%term CVPP=151 CVPU=150\n%term CVUI=181 CVUP=183 CVUU=182\n%term NEGF=193 NEGI=197\n%term CALLB=217 CALLF=209 CALLI=213 CALLP=215 CALLU=214 CALLV=216\n%term RETF=241 RETI=245 RETP=247 RETU=246 RETV=248\n%term ADDRGP=263\n%term ADDRFP=279\n%term ADDRLP=295\n%term ADDF=305 ADDI=309 ADDP=311 ADDU=310\n%term SUBF=321 SUBI=325 SUBP=327 SUBU=326\n%term LSHI=341 LSHU=342\n%term MODI=357 MODU=358\n%term RSHI=373 RSHU=374\n%term BANDI=389 BANDU=390\n%term BCOMI=405 BCOMU=406\n%term BORI=421 BORU=422\n%term BXORI=437 BXORU=438\n%term DIVF=449 DIVI=453 DIVU=454\n%term MULF=465 MULI=469 MULU=470\n%term EQF=481 EQI=485 EQU=486\n%term GEF=497 GEI=501 GEU=502\n%term GTF=513 GTI=517 GTU=518\n%term LEF=529 LEI=533 LEU=534\n%term LTF=545 LTI=549 LTU=550\n%term NEF=561 NEI=565 NEU=566\n%term JUMPV=584\n%term LABELV=600\n%%\nstmt: INDIRB(P) \"\"\nstmt: INDIRF(P) \"\"\nstmt: INDIRI(P) \"\"\nstmt: INDIRU(P) \"\"\nstmt: INDIRP(P) \"\"\nstmt: CALLF(P) \"\"\nstmt: CALLI(P) \"\"\nstmt: CALLU(P) \"\"\nstmt: CALLP(P) \"\"\nstmt: V \"\"\nbogus: I \"\" 1\nbogus: U \"\" 1\nbogus: P \"\" 1\nbogus: F \"\" 1\nbogus: B \"\" 1\nbogus: V \"\" 1\nI: bogus \"\" 1\nU: bogus \"\" 1\nP: bogus \"\" 1\nF: bogus \"\" 1\nB: bogus \"\" 1\nV: bogus \"\" 1\nF: CNSTF \"\"\nI: CNSTI \"\"\nP: CNSTP \"\"\nU: CNSTU \"\"\nV: ARGB(B) \"\"\nV: ARGF(F) \"\"\nV: ARGI(I) \"\"\nV: ARGU(U) \"\"\nV: ARGP(P) \"\"\nV: ASGNB(P,B) \"\"\nV: ASGNF(P,F) \"\"\nV: ASGNI(P,I) \"\"\nV: ASGNU(P,U) \"\"\nV: ASGNP(P,P) \"\"\nB: INDIRB(P) \"\"\nF: INDIRF(P) \"\"\nI: INDIRI(P) \"\"\nU: INDIRU(P) \"\"\nP: INDIRP(P) \"\"\nI: CVII(I) \"\"\nI: CVUI(U) \"\"\nI: CVFI(F) \"\"\nU: CVIU(I) \"\"\nU: CVUU(U) \"\"\nU: CVPU(P) \"\"\nF: CVIF(I) \"\"\nF: CVFF(F) \"\"\nP: CVUP(U) \"\"\nP: CVPP(P) \"\"\nF: NEGF(F) \"\"\nI: NEGI(I) \"\"\nV: CALLB(P,P) \"\"\nF: CALLF(P) \"\"\nI: CALLI(P) \"\"\nU: CALLU(P) \"\"\nP: CALLP(P) \"\"\nV: CALLV(P) \"\"\nV: RETF(F) \"\"\nV: RETI(I) \"\"\nV: RETU(U) \"\"\nV: RETP(P) \"\"\nV: RETV \"\"\nP: ADDRGP \"\"\nP: ADDRFP \"\"\nP: ADDRLP \"\"\nF: ADDF(F,F) \"\"\nI: ADDI(I,I) \"\"\nP: ADDP(P,I) \"\"\nP: ADDP(I,P) \"\"\nP: ADDP(U,P) \"\"\nP: ADDP(P,U) \"\"\nU: ADDU(U,U) \"\"\nF: SUBF(F,F) \"\"\nI: SUBI(I,I) \"\"\nP: SUBP(P,I) \"\"\nP: SUBP(P,U) \"\"\nU: SUBU(U,U) \"\"\nI: LSHI(I,I) \"\"\nU: LSHU(U,I) \"\"\nI: MODI(I,I) \"\"\nU: MODU(U,U) \"\"\nI: RSHI(I,I) \"\"\nU: RSHU(U,I) \"\"\nU: BANDU(U,U) \"\"\nI: BANDI(I,I) \"\"\nU: BCOMU(U) \"\"\nI: BCOMI(I) \"\"\nI: BORI(I,I) \"\"\nU: BORU(U,U) \"\"\nU: BXORU(U,U) \"\"\nI: BXORI(I,I) \"\"\nF: DIVF(F,F) \"\"\nI: DIVI(I,I) \"\"\nU: DIVU(U,U) \"\"\nF: MULF(F,F) \"\"\nI: MULI(I,I) \"\"\nU: MULU(U,U) \"\"\nV: EQF(F,F) \"\"\nV: EQI(I,I) \"\"\nV: EQU(U,U) \"\"\nV: GEF(F,F) \"\"\nV: GEI(I,I) \"\"\nV: GEU(U,U) \"\"\nV: GTF(F,F) \"\"\nV: GTI(I,I) \"\"\nV: GTU(U,U) \"\"\nV: LEF(F,F) \"\"\nV: LEI(I,I) \"\"\nV: LEU(U,U) \"\"\nV: LTF(F,F) \"\"\nV: LTI(I,I) \"\"\nV: LTU(U,U) \"\"\nV: NEF(F,F) \"\"\nV: NEI(I,I) \"\"\nV: NEU(U,U) \"\"\nV: JUMPV(P) \"\"\nV: LABELV \"\"\n%%\n\nstatic void reduce(NODEPTR_TYPE p, int goalnt) {\n\tint i, sz = opsize(p->op), rulenumber = _rule(p->x.state, goalnt);\n\tshort *nts = _nts[rulenumber];\n\tNODEPTR_TYPE kids[10];\n\n\tassert(rulenumber);\n\t_kids(p, rulenumber, kids);\n\tfor (i = 0; nts[i]; i++)\n\t\treduce(kids[i], nts[i]);\n\tswitch (optype(p->op)) {\n#define xx(ty) if (sz == ty->size) return\n\tcase I:\n\tcase U:\n\t\txx(chartype);\n\t\txx(shorttype);\n\t\txx(inttype);\n\t\txx(longtype);\n\t\txx(longlong);\n\t\tbreak;\n\tcase F:\n\t\txx(floattype);\n\t\txx(doubletype);\n\t\txx(longdouble);\n\t\tbreak;\n\tcase P:\n\t\txx(voidptype);\n\t\txx(funcptype);\n\t\tbreak;\n\tcase V:\n\tcase B: if (sz == 0) return;\n#undef xx\n\t}\n\tprintdag(p, 2);\n\tassert(0);\n}\n\nvoid check(Node p) {\n\tstruct _state { short cost[1]; };\n\n\t_label(p);\n\tif (((struct _state *)p->x.state)->cost[1] > 0) {\n\t\tprintdag(p, 2);\n\t\tassert(0);\n\t}\n\treduce(p, 1);\n}\n"
  },
  {
    "path": "lcc/src/decl.c",
    "content": "#include \"c.h\"\n\n\n#define add(x,n) (x > inttype->u.sym->u.limits.max.i-(n) ? (overflow=1,x) : x+(n))\n#define chkoverflow(x,n) ((void)add(x,n))\n#define bits2bytes(n) (((n) + 7)/8)\nstatic int regcount;\n\nstatic List autos, registers;\nSymbol cfunc;\t\t/* current function */\nSymbol retv;\t\t/* return value location for structs */\n\nstatic void checkref(Symbol, void *);\nstatic Symbol dclglobal(int, char *, Type, Coordinate *);\nstatic Symbol dcllocal(int, char *, Type, Coordinate *);\nstatic Symbol dclparam(int, char *, Type, Coordinate *);\nstatic Type dclr(Type, char **, Symbol **, int);\nstatic Type dclr1(char **, Symbol **, int);\nstatic void decl(Symbol (*)(int, char *, Type, Coordinate *));\nextern void doconst(Symbol, void *);\nstatic void doglobal(Symbol, void *);\nstatic void doextern(Symbol, void *);\nstatic void exitparams(Symbol []);\nstatic void fields(Type);\nstatic void funcdefn(int, char *, Type, Symbol [], Coordinate);\nstatic void initglobal(Symbol, int);\nstatic void oldparam(Symbol, void *);\nstatic Symbol *parameters(Type);\nstatic Type specifier(int *);\nstatic Type structdcl(int);\nstatic Type tnode(int, Type);\nvoid program(void) {\n\tint n;\n\t\n\tlevel = GLOBAL;\n\tfor (n = 0; t != EOI; n++)\n\t\tif (kind[t] == CHAR || kind[t] == STATIC\n\t\t|| t == ID || t == '*' || t == '(') {\n\t\t\tdecl(dclglobal);\n\t\t\tdeallocate(STMT);\n\t\t\tif (!(glevel >= 3 || xref))\n\t\t\tdeallocate(FUNC);\n\t\t} else if (t == ';') {\n\t\t\twarning(\"empty declaration\\n\");\n\t\t\tt = gettok();\n\t\t} else {\n\t\t\terror(\"unrecognized declaration\\n\");\n\t\t\tt = gettok();\n\t\t}\n\tif (n == 0)\n\t\twarning(\"empty input file\\n\");\n}\nstatic Type specifier(int *sclass) {\n\tint cls, cons, sign, size, type, vol;\n\tType ty = NULL;\n\n\tcls = vol = cons = sign = size = type = 0;\n\tif (sclass == NULL)\n\t\tcls = AUTO;\n\tfor (;;) {\n\t\tint *p, tt = t;\n\t\tswitch (t) {\n\t\tcase AUTO:\n\t\tcase REGISTER: if (level <= GLOBAL && cls == 0)\n\t\t               \terror(\"invalid use of `%k'\\n\", t);\n\t\t               p = &cls;  t = gettok();      break;\n\t\tcase STATIC: case EXTERN:\n\t\tcase TYPEDEF:  p = &cls;  t = gettok();      break;\n\t\tcase CONST:    p = &cons; t = gettok();      break;\n\t\tcase VOLATILE: p = &vol;  t = gettok();      break;\n\t\tcase SIGNED:\n\t\tcase UNSIGNED: p = &sign; t = gettok();      break;\n\t\tcase LONG:     if (size == LONG) {\n\t\t                       size = 0;\n\t\t                       tt = LONG+LONG;\n\t\t               }\n\t\t               p = &size; t = gettok();      break;\n\t\tcase SHORT:    p = &size; t = gettok();      break;\n\t\tcase VOID: case CHAR: case INT: case FLOAT:\n\t\tcase DOUBLE:   p = &type; ty = tsym->type;\n\t\t                          t = gettok();      break;\n\t\tcase ENUM:     p = &type; ty = enumdcl();    break;\n\t\tcase STRUCT:\n\t\tcase UNION:    p = &type; ty = structdcl(t); break;\n\t\tcase ID:\n\t\t\tif (istypename(t, tsym) && type == 0\n\t\t\t&& sign == 0 && size == 0) {\n\t\t\t\tuse(tsym, src);\n\t\t\t\tty = tsym->type;\n\t\t\t\tif (isqual(ty)\n\t\t\t\t&& ty->size != ty->type->size) {\n\t\t\t\t\tty = unqual(ty);\n\t\t\t\t\tif (isconst(tsym->type))\n\t\t\t\t\t\tty = qual(CONST, ty);\n\t\t\t\t\tif (isvolatile(tsym->type))\n\t\t\t\t\t\tty = qual(VOLATILE, ty);\n\t\t\t\t\ttsym->type = ty;\n\t\t\t\t}\n\t\t\t\tp = &type;\n\t\t\t\tt = gettok();\n\t\t\t} else\n\t\t\t\tp = NULL;\n\t\t\tbreak;\n\t\tdefault: p = NULL;\n\t\t}\n\t\tif (p == NULL)\n\t\t\tbreak;\n\t\tif (*p)\n\t\t\terror(\"invalid use of `%k'\\n\", tt);\n\t\t*p = tt;\n\t}\n\tif (sclass)\n\t\t*sclass = cls;\n\tif (type == 0) {\n\t\ttype = INT;\n\t\tty = inttype;\n\t}\n\tif (size == SHORT     && type != INT\n\t||  size == LONG+LONG && type != INT\n\t||  size == LONG      && type != INT && type != DOUBLE\n\t||  sign && type != INT && type != CHAR)\n\t\terror(\"invalid type specification\\n\");\n\tif (type == CHAR && sign)\n\t\tty = sign == UNSIGNED ? unsignedchar : signedchar;\n\telse if (size == SHORT)\n\t\tty = sign == UNSIGNED ? unsignedshort : shorttype;\n\telse if (size == LONG && type == DOUBLE)\n\t\tty = longdouble;\n\telse if (size == LONG+LONG) {\n\t\tty = sign == UNSIGNED ? unsignedlonglong : longlong;\n\t\tif (Aflag >= 1)\n\t\t\twarning(\"`%t' is a non-ANSI type\\n\", ty);\n\t} else if (size == LONG)\n\t\tty = sign == UNSIGNED ? unsignedlong : longtype;\n\telse if (sign == UNSIGNED && type == INT)\n\t\tty = unsignedtype;\n\tif (cons == CONST)\n\t\tty = qual(CONST, ty);\n\tif (vol  == VOLATILE)\n\t\tty = qual(VOLATILE, ty);\n\treturn ty;\n}\nstatic void decl(Symbol (*dcl)(int, char *, Type, Coordinate *)) {\n\tint sclass;\n\tType ty, ty1;\n\tstatic char stop[] = { CHAR, STATIC, ID, 0 };\n\n\tty = specifier(&sclass);\n\tif (t == ID || t == '*' || t == '(' || t == '[') {\n\t\tchar *id;\n\t\tCoordinate pos;\n\t\tid = NULL;\n\t\tpos = src;\n\t\tif (level == GLOBAL) {\n\t\t\tSymbol *params = NULL;\n\t\t\tty1 = dclr(ty, &id, &params, 0);\n\t\t\tif (params && id && isfunc(ty1)\n\t\t\t    && (t == '{' || istypename(t, tsym)\n\t\t\t    || (kind[t] == STATIC && t != TYPEDEF))) {\n\t\t\t\tif (sclass == TYPEDEF) {\n\t\t\t\t\terror(\"invalid use of `typedef'\\n\");\n\t\t\t\t\tsclass = EXTERN;\n\t\t\t\t}\n\t\t\t\tif (ty1->u.f.oldstyle)\n\t\t\t\t\texitscope();\n\t\t\t\tfuncdefn(sclass, id, ty1, params, pos);\n\t\t\t\treturn;\n\t\t\t} else if (params)\n\t\t\t\texitparams(params);\n\t\t} else\n\t\t\tty1 = dclr(ty, &id, NULL, 0);\n\t\tfor (;;) {\n\t\t\tif (Aflag >= 1 && !hasproto(ty1))\n\t\t\t\twarning(\"missing prototype\\n\");\n\t\t\tif (id == NULL)\n\t\t\t\terror(\"missing identifier\\n\");\n\t\t\telse if (sclass == TYPEDEF)\n\t\t\t\t{\n\t\t\t\t\tSymbol p = lookup(id, identifiers);\n\t\t\t\t\tif (p && p->scope == level)\n\t\t\t\t\t\terror(\"redeclaration of `%s'\\n\", id);\n\t\t\t\t\tp = install(id, &identifiers, level,\n\t\t\t\t\t\tlevel < LOCAL ? PERM : FUNC);\n\t\t\t\t\tp->type = ty1;\n\t\t\t\t\tp->sclass = TYPEDEF;\n\t\t\t\t\tp->src = pos;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t(void)(*dcl)(sclass, id, ty1, &pos);\n\t\t\tif (t != ',')\n\t\t\t\tbreak;\n\t\t\tt = gettok();\n\t\t\tid = NULL;\n\t\t\tpos = src;\n\t\t\tty1 = dclr(ty, &id, NULL, 0);\n\t\t}\n\t} else if (ty == NULL\n\t|| !(isenum(ty) ||\n\t     isstruct(ty) && (*unqual(ty)->u.sym->name < '1' || *unqual(ty)->u.sym->name > '9')))\n\t\terror(\"empty declaration\\n\");\n\ttest(';', stop);\n}\nstatic Symbol dclglobal(int sclass, char *id, Type ty, Coordinate *pos) {\n\tSymbol p;\n\n\tif (sclass == 0)\n\t\tsclass = AUTO;\n\telse if (sclass != EXTERN && sclass != STATIC) {\n\t\terror(\"invalid storage class `%k' for `%t %s'\\n\",\n\t\t\tsclass, ty, id);\n\t\tsclass = AUTO;\n\t}\n\tp = lookup(id, identifiers);\n\tif (p && p->scope == GLOBAL) {\n\t\tif (p->sclass != TYPEDEF && eqtype(ty, p->type, 1))\n\t\t\tty = compose(ty, p->type);\n\t\telse\n\t\t\terror(\"redeclaration of `%s' previously declared at %w\\n\", p->name, &p->src);\n\n\t\tif (!isfunc(ty) && p->defined && t == '=')\n\t\t\terror(\"redefinition of `%s' previously defined at %w\\n\", p->name, &p->src);\n\n\t\tif (p->sclass == EXTERN && sclass == STATIC\n\t\t||  p->sclass == STATIC && sclass == AUTO\n\t\t||  p->sclass == AUTO   && sclass == STATIC)\n\t\t\twarning(\"inconsistent linkage for `%s' previously declared at %w\\n\", p->name, &p->src);\n\n\t}\n\tif (p == NULL || p->scope != GLOBAL) {\n\t\tSymbol q = lookup(id, externals);\n\t\tif (q) {\n\t\t\tif (sclass == STATIC || !eqtype(ty, q->type, 1))\n\t\t\t\twarning(\"declaration of `%s' does not match previous declaration at %w\\n\", id, &q->src);\n\n\t\t\tp = relocate(id, externals, globals);\n\t\t\tp->sclass = sclass;\n\t\t} else {\n\t\t\tp = install(id, &globals, GLOBAL, PERM);\n\t\t\tp->sclass = sclass;\n\t\t\t(*IR->defsymbol)(p);\n\t\t}\n\t\tif (p->sclass != STATIC) {\n\t\t\tstatic int nglobals;\n\t\t\tnglobals++;\n\t\t\tif (Aflag >= 2 && nglobals == 512)\n\t\t\t\twarning(\"more than 511 external identifiers\\n\");\n\t\t}\n\t} else if (p->sclass == EXTERN)\n\t\tp->sclass = sclass;\n\tp->type = ty;\n\tp->src = *pos;\n\tif (t == '=' && isfunc(p->type)) {\n\t\terror(\"illegal initialization for `%s'\\n\", p->name);\n\t\tt = gettok();\n\t\tinitializer(p->type, 0);\n\t} else if (t == '=') {\n\t\tinitglobal(p, 0);\n\t\tif (glevel > 0 && IR->stabsym) {\n\t\t\t(*IR->stabsym)(p); swtoseg(p->u.seg); }\n\t} else if (p->sclass == STATIC && !isfunc(p->type)\n\t&& p->type->size == 0)\n\t\terror(\"undefined size for `%t %s'\\n\", p->type, p->name);\n\treturn p;\n}\nstatic void initglobal(Symbol p, int flag) {\n\tType ty;\n\n\tif (t == '=' || flag) {\n\t\tif (p->sclass == STATIC) {\n\t\t\tfor (ty = p->type; isarray(ty); ty = ty->type)\n\t\t\t\t;\n\t\t\tdefglobal(p, isconst(ty) ? LIT : DATA);\n\t\t} else\n\t\t\tdefglobal(p, DATA);\n\t\tif (t == '=')\n\t\t\tt = gettok();\n\t\tty = initializer(p->type, 0);\n\t\tif (isarray(p->type) && p->type->size == 0)\n\t\t\tp->type = ty;\n\t\tif (p->sclass == EXTERN)\n\t\t\tp->sclass = AUTO;\n\t}\n}\nvoid defglobal(Symbol p, int seg) {\n\tp->u.seg = seg;\n\tswtoseg(p->u.seg);\n\tif (p->sclass != STATIC)\n\t\t(*IR->export)(p);\n\t(*IR->global)(p);\n\tp->defined = 1;\n}\n\nstatic Type dclr(Type basety, char **id, Symbol **params, int abstract) {\n\tType ty = dclr1(id, params, abstract);\n\n\tfor ( ; ty; ty = ty->type)\n\t\tswitch (ty->op) {\n\t\tcase POINTER:\n\t\t\tbasety = ptr(basety);\n\t\t\tbreak;\n\t\tcase FUNCTION:\n\t\t\tbasety = func(basety, ty->u.f.proto,\n\t\t\t\tty->u.f.oldstyle);\n\t\t\tbreak;\n\t\tcase ARRAY:\n\t\t\tbasety = array(basety, ty->size, 0);\n\t\t\tbreak;\n\t\tcase CONST: case VOLATILE:\n\t\t\tbasety = qual(ty->op, basety);\n\t\t\tbreak;\n\t\tdefault: assert(0);\n\t\t}\n\tif (Aflag >= 2 && basety->size > 32767)\n\t\twarning(\"more than 32767 bytes in `%t'\\n\", basety);\n\treturn basety;\n}\nstatic Type tnode(int op, Type type) {\n\tType ty;\n\n\tNEW0(ty, STMT);\n\tty->op = op;\n\tty->type = type;\n\treturn ty;\n}\nstatic Type dclr1(char **id, Symbol **params, int abstract) {\n\tType ty = NULL;\n\n\tswitch (t) {\n\tcase ID:                if (id)\n\t\t\t\t\t*id = token;\n\t\t\t\telse\n\t\t\t\t\terror(\"extraneous identifier `%s'\\n\", token);\n\t\t\t\tt = gettok(); break;\n\tcase '*': t = gettok(); if (t == CONST || t == VOLATILE) {\n\t\t\t\t\tType ty1;\n\t\t\t\t\tty1 = ty = tnode(t, NULL);\n\t\t\t\t\twhile ((t = gettok()) == CONST || t == VOLATILE)\n\t\t\t\t\t\tty1 = tnode(t, ty1);\n\t\t\t\t\tty->type = dclr1(id, params, abstract);\n\t\t\t\t\tty = ty1;\n\t\t\t\t} else\n\t\t\t\t\tty = dclr1(id, params, abstract);\n\t\t\t\tty = tnode(POINTER, ty); break;\n\tcase '(': t = gettok(); if (abstract\n\t\t\t\t&& (t == REGISTER || istypename(t, tsym) || t == ')')) {\n\t\t\t\t\tSymbol *args;\n\t\t\t\t\tty = tnode(FUNCTION, ty);\n\t\t\t\t\tenterscope();\n\t\t\t\t\tif (level > PARAM)\n\t\t\t\t\t\tenterscope();\n\t\t\t\t\targs = parameters(ty);\n\t\t\t\t\texitparams(args);\n\t\t\t\t} else {\n\t\t\t\t\tty = dclr1(id, params, abstract);\n\t\t\t\t\texpect(')');\n\t\t\t\t\tif (abstract && ty == NULL\n\t\t\t\t\t&& (id == NULL || *id == NULL))\n\t\t\t\t\t\treturn tnode(FUNCTION, NULL);\n\t\t\t\t} break;\n\tcase '[': break;\n\tdefault:  return ty;\n\t}\n\twhile (t == '(' || t == '[')\n\t\tswitch (t) {\n\t\tcase '(': t = gettok(); { Symbol *args;\n\t\t\t\t\t  ty = tnode(FUNCTION, ty);\n\t\t\t\t\t  enterscope();\n\t\t\t\t\t  if (level > PARAM)\n\t\t\t\t\t  \tenterscope();\n\t\t\t\t\t  args = parameters(ty);\n\t\t\t\t\t  if (params && *params == NULL)\n\t\t\t\t\t  \t*params = args;\n\t\t\t\t\t  else\n\t\t\t\t\t  \texitparams(args);\n }\n\t\t          break;\n\t\tcase '[': t = gettok(); { int n = 0;\n\t\t\t\t\t  if (kind[t] == ID) {\n\t\t\t\t\t  \tn = intexpr(']', 1);\n\t\t\t\t\t  \tif (n <= 0) {\n\t\t\t\t\t  \t\terror(\"`%d' is an illegal array size\\n\", n);\n\t\t\t\t\t  \t\tn = 1;\n\t\t\t\t\t  \t}\n\t\t\t\t\t  } else\n\t\t\t\t\t  \texpect(']');\n\t\t\t\t\t  ty = tnode(ARRAY, ty);\n\t\t\t\t\t  ty->size = n; } break;\n\t\tdefault: assert(0);\n\t\t}\n\treturn ty;\n}\nstatic Symbol *parameters(Type fty) {\n\tList list = NULL;\n\tSymbol *params;\n\n\tif (kind[t] == STATIC || istypename(t, tsym)) {\n\t\tint n = 0;\n\t\tType ty1 = NULL;\n\t\tfor (;;) {\n\t\t\tType ty;\n\t\t\tint sclass = 0;\n\t\t\tchar *id = NULL;\n\t\t\tif (ty1 && t == ELLIPSIS) {\n\t\t\t\tstatic struct symbol sentinel;\n\t\t\t\tif (sentinel.type == NULL) {\n\t\t\t\t\tsentinel.type = voidtype;\n\t\t\t\t\tsentinel.defined = 1;\n\t\t\t\t}\n\t\t\t\tif (ty1 == voidtype)\n\t\t\t\t\terror(\"illegal formal parameter types\\n\");\n\t\t\t\tlist = append(&sentinel, list);\n\t\t\t\tt = gettok();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (!istypename(t, tsym) && t != REGISTER)\n\t\t\t\terror(\"missing parameter type\\n\");\n\t\t\tn++;\n\t\t\tty = dclr(specifier(&sclass), &id, NULL, 1);\n\t\t\tif ( ty == voidtype && (ty1 || id)\n\t\t\t||  ty1 == voidtype)\n\t\t\t\terror(\"illegal formal parameter types\\n\");\n\t\t\tif (id == NULL)\n\t\t\t\tid = stringd(n);\n\t\t\tif (ty != voidtype)\n\t\t\t\tlist = append(dclparam(sclass, id, ty, &src), list);\n\t\t\tif (Aflag >= 1 && !hasproto(ty))\n\t\t\t\twarning(\"missing prototype\\n\");\n\t\t\tif (ty1 == NULL)\n\t\t\t\tty1 = ty;\n\t\t\tif (t != ',')\n\t\t\t\tbreak;\n\t\t\tt = gettok();\n\t\t}\n\t\tfty->u.f.proto = newarray(length(list) + 1,\n\t\t\tsizeof (Type *), PERM);\n\t\tparams = ltov(&list, FUNC);\n\t\tfor (n = 0; params[n]; n++)\n\t\t\tfty->u.f.proto[n] = params[n]->type;\n\t\tfty->u.f.proto[n] = NULL;\n\t\tfty->u.f.oldstyle = 0;\n\t} else {\n\t\tif (t == ID)\n\t\t\tfor (;;) {\n\t\t\t\tSymbol p;\n\t\t\t\tif (t != ID) {\n\t\t\t\t\terror(\"expecting an identifier\\n\");\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tp = dclparam(0, token, inttype, &src);\n\t\t\t\tp->defined = 0;\n\t\t\t\tlist = append(p, list);\n\t\t\t\tt = gettok();\n\t\t\t\tif (t != ',')\n\t\t\t\t\tbreak;\n\t\t\t\tt = gettok();\n\t\t\t}\n\t\tparams = ltov(&list, FUNC);\n\t\tfty->u.f.proto = NULL;\n\t\tfty->u.f.oldstyle = 1;\n\t}\n\tif (t != ')') {\n\t\tstatic char stop[] = { CHAR, STATIC, IF, ')', 0 };\n\t\texpect(')');\n\t\tskipto('{', stop);\n\t}\n\tif (t == ')')\n\t\tt = gettok();\n\treturn params;\n}\nstatic void exitparams(Symbol params[]) {\n\tassert(params);\n\tif (params[0] && !params[0]->defined)\n\t\terror(\"extraneous old-style parameter list\\n\");\n\tif (level > PARAM)\n\t\texitscope();\n\texitscope();\n}\n\nstatic Symbol dclparam(int sclass, char *id, Type ty, Coordinate *pos) {\n\tSymbol p;\n\n\tif (isfunc(ty))\n\t\tty = ptr(ty);\n\telse if (isarray(ty))\n\t\tty = atop(ty);\n\tif (sclass == 0)\n\t\tsclass = AUTO;\n\telse if (sclass != REGISTER) {\n\t\terror(\"invalid storage class `%k' for `%t%s\\n\",\n\t\t\tsclass, ty, stringf(id ? \" %s'\" : \"' parameter\", id));\n\t\tsclass = AUTO;\n\t} else if (isvolatile(ty) || isstruct(ty)) {\n\t\twarning(\"register declaration ignored for `%t%s\\n\",\n\t\t\tty, stringf(id ? \" %s'\" : \"' parameter\", id));\n\t\tsclass = AUTO;\n\t}\n\n\tp = lookup(id, identifiers);\n\tif (p && p->scope == level)\n\t\terror(\"duplicate declaration for `%s' previously declared at %w\\n\", id, &p->src);\n\n\telse\n\t\tp = install(id, &identifiers, level, FUNC);\n\tp->sclass = sclass;\n\tp->src = *pos;\n\tp->type = ty;\n\tp->defined = 1;\n\tif (t == '=') {\n\t\terror(\"illegal initialization for parameter `%s'\\n\", id);\n\t\tt = gettok();\n\t\t(void)expr1(0);\n\t}\n\treturn p;\n}\nstatic Type structdcl(int op) {\n\tchar *tag;\n\tType ty;\n\tSymbol p;\n\tCoordinate pos;\n\n\tt = gettok();\n\tpos = src;\n\tif (t == ID) {\n\t\ttag = token;\n\t\tt = gettok();\n\t} else\n\t\ttag = \"\";\n\tif (t == '{') {\n\t\tstatic char stop[] = { IF, ',', 0 };\n\t\tty = newstruct(op, tag);\n\t\tty->u.sym->src = pos;\n\t\tty->u.sym->defined = 1;\n\t\tt = gettok();\n\t\tif (istypename(t, tsym))\n\t\t\tfields(ty);\n\t\telse\n\t\t\terror(\"invalid %k field declarations\\n\", op);\n\t\ttest('}', stop);\n\t}\n\telse if (*tag && (p = lookup(tag, types)) != NULL\n\t&& p->type->op == op) {\n\t\tty = p->type;\n\t\tif (t == ';' && p->scope < level)\n\t\t\tty = newstruct(op, tag);\n\t}\n\telse {\n\t\tif (*tag == 0)\n\t\t\terror(\"missing %k tag\\n\", op);\n\t\tty = newstruct(op, tag);\n\t}\n\tif (*tag && xref)\n\t\tuse(ty->u.sym, pos);\n\treturn ty;\n}\nstatic void fields(Type ty) {\n\t{ int n = 0;\n\t  while (istypename(t, tsym)) {\n\t  \tstatic char stop[] = { IF, CHAR, '}', 0 };\n\t  \tType ty1 = specifier(NULL);\n\t  \tfor (;;) {\n\t  \t\tField p;\n\t  \t\tchar *id = NULL;\n\t  \t\tType fty = dclr(ty1, &id, NULL, 0);\n\t\t\tp = newfield(id, ty, fty);\n\t\t\tif (Aflag >= 1 && !hasproto(p->type))\n\t\t\t\twarning(\"missing prototype\\n\");\n\t\t\tif (t == ':') {\n\t\t\t\tif (unqual(p->type) != inttype\n\t\t\t\t&&  unqual(p->type) != unsignedtype) {\n\t\t\t\t\terror(\"`%t' is an illegal bit-field type\\n\",\n\t\t\t\t\t\tp->type);\n\t\t\t\t\tp->type = inttype;\n\t\t\t\t}\n\t\t\t\tt = gettok();\n\t\t\t\tp->bitsize = intexpr(0, 0);\n\t\t\t\tif (p->bitsize > 8*inttype->size || p->bitsize < 0) {\n\t\t\t\t\terror(\"`%d' is an illegal bit-field size\\n\",\n\t\t\t\t\t\tp->bitsize);\n\t\t\t\t\tp->bitsize = 8*inttype->size;\n\t\t\t\t} else if (p->bitsize == 0 && id) {\n\t\t\t\t\twarning(\"extraneous 0-width bit field `%t %s' ignored\\n\", p->type, id);\n\n\t\t\t\t\tp->name = stringd(genlabel(1));\n\t\t\t\t}\n\t\t\t\tp->lsb = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (id == NULL)\n\t\t\t\t\terror(\"field name missing\\n\");\n\t\t\t\telse if (isfunc(p->type))\n\t\t\t\t\terror(\"`%t' is an illegal field type\\n\", p->type);\n\t\t\t\telse if (p->type->size == 0)\n\t\t\t\t\terror(\"undefined size for field `%t %s'\\n\",\n\t\t\t\t\t\tp->type, id);\n\t\t\t}\n\t\t\tif (isconst(p->type))\n\t\t\t\tty->u.sym->u.s.cfields = 1;\n\t\t\tif (isvolatile(p->type))\n\t\t\t\tty->u.sym->u.s.vfields = 1;\n\t  \t\tn++;\n\t  \t\tif (Aflag >= 2 && n == 128)\n\t  \t\t\twarning(\"more than 127 fields in `%t'\\n\", ty);\n\t  \t\tif (t != ',')\n\t  \t\t\tbreak;\n\t  \t\tt = gettok();\n\t  \t}\n\t  \ttest(';', stop);\n\t  } }\n\t{ int bits = 0, off = 0, overflow = 0;\n\t  Field p, *q = &ty->u.sym->u.s.flist;\n\t  ty->align = IR->structmetric.align;\n\t  for (p = *q; p; p = p->link) {\n\t  \tint a = p->type->align ? p->type->align : 1;\n\t\tif (p->lsb)\n\t\t\ta = unsignedtype->align;\n\t\tif (ty->op == UNION)\n\t\t\toff = bits = 0;\n\t\telse if (p->bitsize == 0 || bits == 0\n\t\t|| bits - 1 + p->bitsize > 8*unsignedtype->size) {\n\t\t\toff = add(off, bits2bytes(bits-1));\n\t\t\tbits = 0;\n\t\t\tchkoverflow(off, a - 1);\n\t\t\toff = roundup(off, a);\n\t\t}\n\t\tif (a > ty->align)\n\t\t\tty->align = a;\n\t\tp->offset = off;\n\n\t\tif (p->lsb) {\n\t\t\tif (bits == 0)\n\t\t\t\tbits = 1;\n\t\t\tif (IR->little_endian)\n\t\t\t\tp->lsb = bits;\n\t\t\telse\n\t\t\t\tp->lsb = 8*unsignedtype->size - bits + 1\n\t\t\t\t\t- p->bitsize + 1;\n\t\t\tbits += p->bitsize;\n\t\t} else\n\t\t\toff = add(off, p->type->size);\n\t\tif (off + bits2bytes(bits-1) > ty->size)\n\t\t\tty->size = off + bits2bytes(bits-1);\n\t  \tif (p->name == NULL\n\t  \t|| !('1' <= *p->name && *p->name <= '9')) {\n\t  \t\t*q = p;\n\t  \t\tq = &p->link;\n\t  \t}\n\t  }\n\t  *q = NULL;\n\t  chkoverflow(ty->size, ty->align - 1);\n\t  ty->size = roundup(ty->size, ty->align);\n\t  if (overflow) {\n\t  \terror(\"size of `%t' exceeds %d bytes\\n\", ty, inttype->u.sym->u.limits.max.i);\n\t  \tty->size = inttype->u.sym->u.limits.max.i&(~(ty->align - 1));\n\t  } }\n}\nstatic void funcdefn(int sclass, char *id, Type ty, Symbol params[], Coordinate pt) {\n\tint i, n;\n\tSymbol *callee, *caller, p;\n\tType rty = freturn(ty);\n\n\tif (isstruct(rty) && rty->size == 0)\n\t\terror(\"illegal use of incomplete type `%t'\\n\", rty);\n\tfor (n = 0; params[n]; n++)\n\t\t;\n\tif (n > 0 && params[n-1]->name == NULL)\n\t\tparams[--n] = NULL;\n\tif (Aflag >= 2 && n > 31)\n\t\twarning(\"more than 31 parameters in function `%s'\\n\", id);\n\tif (ty->u.f.oldstyle) {\n\t\tif (Aflag >= 1)\n\t\t\twarning(\"old-style function definition for `%s'\\n\", id);\n\t\tcaller = params;\n\t\tcallee = newarray(n + 1, sizeof *callee, FUNC);\n\t\tmemcpy(callee, caller, (n+1)*sizeof *callee);\n\t\tenterscope();\n\t\tassert(level == PARAM);\n\t\twhile (kind[t] == STATIC || istypename(t, tsym))\n\t\t\tdecl(dclparam);\n\t\tforeach(identifiers, PARAM, oldparam, callee);\n\n\t\tfor (i = 0; (p = callee[i]) != NULL; i++) {\n\t\t\tif (!p->defined)\n\t\t\t\tcallee[i] = dclparam(0, p->name, inttype, &p->src);\n\t\t\t*caller[i] = *p;\n\t\t\tcaller[i]->sclass = AUTO;\n\t\t\tcaller[i]->type = promote(p->type);\n\t\t}\n\t\tp = lookup(id, identifiers);\n\t\tif (p && p->scope == GLOBAL && isfunc(p->type)\n\t\t&& p->type->u.f.proto) {\n\t\t\tType *proto = p->type->u.f.proto;\n\t\t\tfor (i = 0; caller[i] && proto[i]; i++) {\n\t\t\t\tType ty = unqual(proto[i]);\n\t\t\t\tif (eqtype(isenum(ty) ? ty->type : ty,\n\t\t\t\t\tunqual(caller[i]->type), 1) == 0)\n\t\t\t\t\tbreak;\n\t\t\t\telse if (isenum(ty) && !isenum(unqual(caller[i]->type)))\n\t\t\t\t\twarning(\"compatibility of `%t' and `%t' is compiler dependent\\n\",\n\t\t\t\t\t\tproto[i], caller[i]->type);\n\t\t\t}\n\t\t\tif (proto[i] || caller[i])\n\t\t\t\terror(\"conflicting argument declarations for function `%s'\\n\", id);\n\n\t\t}\n\t\telse {\n\t\t\tType *proto = newarray(n + 1, sizeof *proto, PERM);\n\t\t\tif (Aflag >= 1)\n\t\t\t\twarning(\"missing prototype for `%s'\\n\", id);\n\t\t\tfor (i = 0; i < n; i++)\n\t\t\t\tproto[i] = caller[i]->type;\n\t\t\tproto[i] = NULL;\n\t\t\tty = func(rty, proto, 1);\n\t\t}\n\t} else {\n\t\tcallee = params;\n\t\tcaller = newarray(n + 1, sizeof *caller, FUNC);\n\t\tfor (i = 0; (p = callee[i]) != NULL && p->name; i++) {\n\t\t\tNEW(caller[i], FUNC);\n\t\t\t*caller[i] = *p;\n\t\t\tif (isint(p->type))\n\t\t\t\tcaller[i]->type = promote(p->type);\n\t\t\tcaller[i]->sclass = AUTO;\n\t\t\tif ('1' <= *p->name && *p->name <= '9')\n\t\t\t\terror(\"missing name for parameter %d to function `%s'\\n\", i + 1, id);\n\n\t\t}\n\t\tcaller[i] = NULL;\n\t}\n\tfor (i = 0; (p = callee[i]) != NULL; i++)\n\t\tif (p->type->size == 0) {\n\t\t\terror(\"undefined size for parameter `%t %s'\\n\",\n\t\t\t\tp->type, p->name);\n\t\t\tcaller[i]->type = p->type = inttype;\n\t\t}\n\tif (Aflag >= 2 && sclass != STATIC && strcmp(id, \"main\") == 0) {\n\t\tif (ty->u.f.oldstyle)\n\t\t\twarning(\"`%t %s()' is a non-ANSI definition\\n\", rty, id);\n\t\telse if (!(rty == inttype\n\t\t\t&& (n == 0 && callee[0] == NULL\n\t\t\t||  n == 2 && callee[0]->type == inttype\n\t\t\t&& isptr(callee[1]->type) && callee[1]->type->type == charptype\n\t\t\t&& !variadic(ty))))\n\t\t\twarning(\"`%s' is a non-ANSI definition\\n\", typestring(ty, id));\n\t}\n\tp = lookup(id, identifiers);\n\tif (p && isfunc(p->type) && p->defined)\n\t\terror(\"redefinition of `%s' previously defined at %w\\n\",\n\t\t\tp->name, &p->src);\n\tcfunc = dclglobal(sclass, id, ty, &pt);\n\tcfunc->u.f.label = genlabel(1);\n\tcfunc->u.f.callee = callee;\n\tcfunc->u.f.pt = src;\n\tcfunc->defined = 1;\n\tif (xref)\n\t\tuse(cfunc, cfunc->src);\n\tif (Pflag)\n\t\tprintproto(cfunc, cfunc->u.f.callee);\n\tif (ncalled >= 0)\n\t\tncalled = findfunc(cfunc->name, pt.file);\n\tlabels   = table(NULL, LABELS);\n\tstmtlabs = table(NULL, LABELS);\n\trefinc = 1.0;\n\tregcount = 0;\n\tcodelist = &codehead;\n\tcodelist->next = NULL;\n\tif (!IR->wants_callb && isstruct(rty))\n\t\tretv = genident(AUTO, ptr(rty), PARAM);\n\tcompound(0, NULL, 0);\n\n\t{\n\t\tCode cp;\n\t\tfor (cp = codelist; cp->kind < Label; cp = cp->prev)\n\t\t\t;\n\t\tif (cp->kind != Jump) {\n\t\t\tif (rty != voidtype) {\n\t\t\t\twarning(\"missing return value\\n\");\n\t\t\t\tretcode(cnsttree(inttype, 0L));\n\t\t\t} else\n\t\t\t\tretcode(NULL);\n\t\t}\n\t}\n\tdefinelab(cfunc->u.f.label);\n\tif (events.exit)\n\t\tapply(events.exit, cfunc, NULL);\n\twalk(NULL, 0, 0);\n\texitscope();\n\tassert(level == PARAM);\n\tforeach(identifiers, level, checkref, NULL);\n\tif (!IR->wants_callb && isstruct(rty)) {\n\t\tSymbol *a;\n\t\ta = newarray(n + 2, sizeof *a, FUNC);\n\t\ta[0] = retv;\n\t\tmemcpy(&a[1], callee, (n+1)*sizeof *callee);\n\t\tcallee = a;\n\t\ta = newarray(n + 2, sizeof *a, FUNC);\n\t\tNEW(a[0], FUNC);\n\t\t*a[0] = *retv;\n\t\tmemcpy(&a[1], caller, (n+1)*sizeof *callee);\n\t\tcaller = a;\n\t}\n\tif (!IR->wants_argb)\n\t\tfor (i = 0; caller[i]; i++)\n\t\t\tif (isstruct(caller[i]->type)) {\n\t\t\t\tcaller[i]->type = ptr(caller[i]->type);\n\t\t\t\tcallee[i]->type = ptr(callee[i]->type);\n\t\t\t\tcaller[i]->structarg = callee[i]->structarg = 1;\n\t\t\t}\n\tif (glevel > 1)\tfor (i = 0; callee[i]; i++) callee[i]->sclass = AUTO;\n\tif (cfunc->sclass != STATIC)\n\t\t(*IR->export)(cfunc);\n\tif (glevel && IR->stabsym) {\n\t\tswtoseg(CODE); (*IR->stabsym)(cfunc); }\n\tswtoseg(CODE);\n\t(*IR->function)(cfunc, caller, callee, cfunc->u.f.ncalls);\n\tif (glevel && IR->stabfend)\n\t\t(*IR->stabfend)(cfunc, lineno);\n\tforeach(stmtlabs, LABELS, checklab, NULL);\n\texitscope();\n\texpect('}');\n\tlabels = stmtlabs = NULL;\n\tretv  = NULL;\n\tcfunc = NULL;\n}\nstatic void oldparam(Symbol p, void *cl) {\n\tint i;\n\tSymbol *callee = cl;\n\n\tfor (i = 0; callee[i]; i++)\n\t\tif (p->name == callee[i]->name) {\n\t\t\tcallee[i] = p;\n\t\t\treturn;\n\t\t}\n\terror(\"declared parameter `%s' is missing\\n\", p->name);\n}\nvoid compound(int loop, struct swtch *swp, int lev) {\n\tCode cp;\n\tint nregs;\n\n\twalk(NULL, 0, 0);\n\tcp = code(Blockbeg);\n\tenterscope();\n\tassert(level >= LOCAL);\n\tif (level == LOCAL && events.entry)\n\t\tapply(events.entry, cfunc, NULL);\n\tdefinept(NULL);\n\texpect('{');\n\tautos = registers = NULL;\n\tif (level == LOCAL && IR->wants_callb\n\t&& isstruct(freturn(cfunc->type))) {\n\t\tretv = genident(AUTO, ptr(freturn(cfunc->type)), level);\n\t\tretv->defined = 1;\n\t\tretv->ref = 1;\n\t\tregisters = append(retv, registers);\n\t}\n\twhile (kind[t] == CHAR || kind[t] == STATIC\n\t|| istypename(t, tsym) && getchr() != ':')\n\t\tdecl(dcllocal);\n\t{\n\t\tint i;\n\t\tSymbol *a = ltov(&autos, STMT);\n\t\tnregs = length(registers);\n\t\tfor (i = 0; a[i]; i++)\n\t\t\tregisters = append(a[i], registers);\n\t\tcp->u.block.locals = ltov(&registers, FUNC);\n\t}\n\tif (events.blockentry)\n\t\tapply(events.blockentry, cp->u.block.locals, NULL);\n\twhile (kind[t] == IF || kind[t] == ID)\n\t\tstatement(loop, swp, lev);\n\twalk(NULL, 0, 0);\n\tforeach(identifiers, level, checkref, NULL);\n\t{\n\t\tint i = nregs, j;\n\t\tSymbol p;\n\t\tfor ( ; (p = cp->u.block.locals[i]) != NULL; i++) {\n\t\t\tfor (j = i; j > nregs\n\t\t\t\t&& cp->u.block.locals[j-1]->ref < p->ref; j--)\n\t\t\t\tcp->u.block.locals[j] = cp->u.block.locals[j-1];\n\t\t\tcp->u.block.locals[j] = p;\n\t\t}\n\t}\n\tif (events.blockexit)\n\t\tapply(events.blockexit, cp->u.block.locals, NULL);\n\tcp->u.block.level = level;\n\tcp->u.block.identifiers = identifiers;\n\tcp->u.block.types = types;\n\tcode(Blockend)->u.begin = cp;\n\tif (reachable(Gen))\n\t\tdefinept(NULL);\n\tif (level > LOCAL) {\n\t\texitscope();\n\t\texpect('}');\n\t}\n}\nstatic void checkref(Symbol p, void *cl) {\n\tif (p->scope >= PARAM\n\t&& (isvolatile(p->type) || isfunc(p->type)))\n\t\tp->addressed = 1;\n\tif (Aflag >= 2 && p->defined && p->ref == 0) {\n\t\tif (p->sclass == STATIC)\n\t\t\twarning(\"static `%t %s' is not referenced\\n\",\n\t\t\t\tp->type, p->name);\n\t\telse if (p->scope == PARAM)\n\t\t\twarning(\"parameter `%t %s' is not referenced\\n\",\n\t\t\t\tp->type, p->name);\n\t\telse if (p->scope >= LOCAL && p->sclass != EXTERN)\n\t\t\twarning(\"local `%t %s' is not referenced\\n\",\n\t\t\t\tp->type, p->name);\n\t}\n\tif (p->sclass == AUTO\n\t&& (p->scope  == PARAM && regcount == 0\n\t || p->scope  >= LOCAL)\n\t&& !p->addressed && isscalar(p->type) && p->ref >= 3.0)\n\t\tp->sclass = REGISTER;\n\tif (level == GLOBAL && p->sclass == STATIC && !p->defined\n\t&& isfunc(p->type) && p->ref)\n\t\terror(\"undefined static `%t %s'\\n\", p->type, p->name);\n\tassert(!(level == GLOBAL && p->sclass == STATIC && !p->defined && !isfunc(p->type)));\n}\nstatic Symbol dcllocal(int sclass, char *id, Type ty, Coordinate *pos) {\n\tSymbol p, q;\n\n\tif (sclass == 0)\n\t\tsclass = isfunc(ty) ? EXTERN : AUTO;\n\telse if (isfunc(ty) && sclass != EXTERN) {\n\t\terror(\"invalid storage class `%k' for `%t %s'\\n\",\n\t\t\tsclass, ty, id);\n\t\tsclass = EXTERN;\n\t} else if (sclass == REGISTER\n\t&& (isvolatile(ty) || isstruct(ty) || isarray(ty))) {\n\t\twarning(\"register declaration ignored for `%t %s'\\n\",\n\t\t\tty, id);\n\t\tsclass = AUTO;\n\t}\n\tq = lookup(id, identifiers);\n\tif (q && q->scope >= level\n\t||  q && q->scope == PARAM && level == LOCAL)\n\t\tif (sclass == EXTERN && q->sclass == EXTERN\n\t\t&& eqtype(q->type, ty, 1))\n\t\t\tty = compose(ty, q->type);\n\t\telse\n\t\t\terror(\"redeclaration of `%s' previously declared at %w\\n\", q->name, &q->src);\n\n\tassert(level >= LOCAL);\n\tp = install(id, &identifiers, level, sclass == STATIC || sclass == EXTERN ? PERM : FUNC);\n\tp->type = ty;\n\tp->sclass = sclass;\n\tp->src = *pos;\n\tswitch (sclass) {\n\tcase EXTERN:   q = lookup(id, globals);\n\t\t       if (q == NULL || q->sclass == TYPEDEF || q->sclass == ENUM) {\n\t\t       \tq = lookup(id, externals);\n\t\t       \tif (q == NULL) {\n\t\t       \t\tq = install(p->name, &externals, GLOBAL, PERM);\n\t\t       \t\tq->type = p->type;\n\t\t       \t\tq->sclass = EXTERN;\n\t\t       \t\tq->src = src;\n\t\t       \t\t(*IR->defsymbol)(q);\n\t\t       \t}\n\t\t       }\n\t\t       if (!eqtype(p->type, q->type, 1))\n\t\t       \twarning(\"declaration of `%s' does not match previous declaration at %w\\n\", q->name, &q->src);\n\n\t\t       p->u.alias = q; break;\n\tcase STATIC:   (*IR->defsymbol)(p);\n\t\t       initglobal(p, 0);\n\t\t       if (!p->defined)\n\t\t       \tif (p->type->size > 0) {\n\t\t       \t\tdefglobal(p, BSS);\n\t\t       \t\t(*IR->space)(p->type->size);\n\t\t       \t} else\n\t\t       \t\terror(\"undefined size for `%t %s'\\n\",\n\t\t       \t\t\tp->type, p->name);\n\t\t       p->defined = 1; break;\n\tcase REGISTER: registers = append(p, registers);\n\t\t       regcount++;\n\t\t       p->defined = 1;\n break;\n\tcase AUTO:     autos = append(p, autos);\n\t\t       p->defined = 1; break;\n\tdefault: assert(0);\n\t}\n\tif (t == '=') {\n\t\tTree e;\n\t\tif (sclass == EXTERN)\n\t\t\terror(\"illegal initialization of `extern %s'\\n\", id);\n\t\tt = gettok();\n\t\tdefinept(NULL);\n\t\tif (isscalar(p->type)\n\t\t||  isstruct(p->type) && t != '{') {\n\t\t\tif (t == '{') {\n\t\t\t\tt = gettok();\n\t\t\t\te = expr1(0);\n\t\t\t\texpect('}');\n\t\t\t} else\n\t\t\t\te = expr1(0);\n\t\t} else {\n\t\t\tSymbol t1;\n\t\t\tType ty = p->type, ty1 = ty;\n\t\t\twhile (isarray(ty1))\n\t\t\t\tty1 = ty1->type;\n\t\t\tif (!isconst(ty) && (!isarray(ty) || !isconst(ty1)))\n\t\t\t\tty = qual(CONST, ty);\n\t\t\tt1 = genident(STATIC, ty, GLOBAL);\n\t\t\tinitglobal(t1, 1);\n\t\t\tif (isarray(p->type) && p->type->size == 0\n\t\t\t&& t1->type->size > 0)\n\t\t\t\tp->type = array(p->type->type,\n\t\t\t\t\tt1->type->size/t1->type->type->size, 0);\n\t\t\te = idtree(t1);\n\t\t}\n\t\twalk(root(asgn(p, e)), 0, 0);\n\t\tp->ref = 1;\n\t}\n\tif (!isfunc(p->type) && p->defined && p->type->size <= 0)\n\t\terror(\"undefined size for `%t %s'\\n\", p->type, id);\n\treturn p;\n}\nvoid finalize(void) {\n\tforeach(externals,   GLOBAL,    doextern, NULL);\n\tforeach(identifiers, GLOBAL,    doglobal, NULL);\n\tforeach(identifiers, GLOBAL,    checkref, NULL);\n\tforeach(constants,   CONSTANTS, doconst,  NULL);\n}\nstatic void doextern(Symbol p, void *cl) {\n\t(*IR->import)(p);\n}\nstatic void doglobal(Symbol p, void *cl) {\n\tif (!p->defined && (p->sclass == EXTERN\n\t|| isfunc(p->type) && p->sclass == AUTO))\n\t\t(*IR->import)(p);\n\telse if (!p->defined && !isfunc(p->type)\n\t&& (p->sclass == AUTO || p->sclass == STATIC)) {\n\t\tif (isarray(p->type)\n\t\t&& p->type->size == 0 && p->type->type->size > 0)\n\t\t\tp->type = array(p->type->type, 1, 0);\n\t\tif (p->type->size > 0) {\n\t\t\tdefglobal(p, BSS);\n\t\t\t(*IR->space)(p->type->size);\n\t\t\tif (glevel > 0 && IR->stabsym)\n\t\t\t\t(*IR->stabsym)(p);\n\t\t} else\n\t\t\terror(\"undefined size for `%t %s'\\n\",\n\t\t\t\tp->type, p->name);\n\t\tp->defined = 1;\n\t}\n\tif (Pflag\n\t&& !isfunc(p->type)\n\t&& !p->generated && p->sclass != EXTERN)\n\t\tprintdecl(p, p->type);\n}\nvoid doconst(Symbol p, void *cl) {\n\tif (p->u.c.loc) {\n\t\tassert(p->u.c.loc->u.seg == 0); \n\t\tdefglobal(p->u.c.loc, LIT);\n\t\tif (isarray(p->type) && p->type->type == widechar) {\n\t\t\tunsigned int *s = p->u.c.v.p;\n\t\t\tint n = p->type->size/widechar->size;\n\t\t\twhile (n-- > 0) {\n\t\t\t\tValue v;\n\t\t\t\tv.u = *s++;\n\t\t\t\t(*IR->defconst)(widechar->op, widechar->size, v);\n\t\t\t}\n\t\t} else if (isarray(p->type))\n\t\t\t(*IR->defstring)(p->type->size, p->u.c.v.p);\n\t\telse\n\t\t\t(*IR->defconst)(p->type->op, p->type->size, p->u.c.v);\n\t\tp->u.c.loc = NULL;\n\t}\n}\nvoid checklab(Symbol p, void *cl) {\n\tif (!p->defined)\n\t\terror(\"undefined label `%s'\\n\", p->name);\n\tp->defined = 1;\n}\n\nType enumdcl(void) {\n\tchar *tag;\n\tType ty;\n\tSymbol p;\n\tCoordinate pos;\n\n\tt = gettok();\n\tpos = src;\n\tif (t == ID) {\n\t\ttag = token;\n\t\tt = gettok();\n\t} else\n\t\ttag = \"\";\n\tif (t == '{') {\n\t\tstatic char follow[] = { IF, 0 };\n\t\tint n = 0;\n\t\tlong k = -1;\n\t\tList idlist = 0;\n\t\tty = newstruct(ENUM, tag);\n\t\tt = gettok();\n\t\tif (t != ID)\n\t\t\terror(\"expecting an enumerator identifier\\n\");\n\t\twhile (t == ID) {\n\t\t\tchar *id = token;\n\t\t\tCoordinate s;\n\t\t\tif (tsym && tsym->scope == level)\n\t\t\t\terror(\"redeclaration of `%s' previously declared at %w\\n\",\n\t\t\t\t\ttoken, &tsym->src);\n\t\t\ts = src;\n\t\t\tt = gettok();\n\t\t\tif (t == '=') {\n\t\t\t\tt = gettok();\n\t\t\t\tk = intexpr(0, 0);\n\t\t\t} else {\n\t\t\t\tif (k == inttype->u.sym->u.limits.max.i)\n\t\t\t\t\terror(\"overflow in value for enumeration constant `%s'\\n\", id);\n\t\t\t\tk++;\n\t\t\t}\n\t\t\tp = install(id, &identifiers, level,  level < LOCAL ? PERM : FUNC);\n\t\t\tp->src = s;\n\t\t\tp->type = ty;\n\t\t\tp->sclass = ENUM;\n\t\t\tp->u.value = k;\n\t\t\tidlist = append(p, idlist);\n\t\t\tn++;\n\t\t\tif (Aflag >= 2 && n == 128)\n\t\t\t\twarning(\"more than 127 enumeration constants in `%t'\\n\", ty);\n\t\t\tif (t != ',')\n\t\t\t\tbreak;\n\t\t\tt = gettok();\n\t\t\tif (Aflag >= 2 && t == '}')\n\t\t\t\twarning(\"non-ANSI trailing comma in enumerator list\\n\");\n\t\t}\n\t\ttest('}', follow);\n\t\tty->type = inttype;\n\t\tty->size = ty->type->size;\n\t\tty->align = ty->type->align;\n\t\tty->u.sym->u.idlist = ltov(&idlist, PERM);\n\t\tty->u.sym->defined = 1;\n\t} else if ((p = lookup(tag, types)) != NULL && p->type->op == ENUM) {\n\t\tty = p->type;\n\t\tif (t == ';')\n\t\t\terror(\"empty declaration\\n\");\n\t} else {\n\t\terror(\"unknown enumeration `%s'\\n\",  tag);\n\t\tty = newstruct(ENUM, tag);\n\t\tty->type = inttype;\n\t}\n\tif (*tag && xref)\n\t\tuse(p, pos);\n\treturn ty;\n}\n\nType typename(void) {\n\tType ty = specifier(NULL);\n\n\tif (t == '*' || t == '(' || t == '[') {\n\t\tty = dclr(ty, NULL, NULL, 1);\n\t\tif (Aflag >= 1 && !hasproto(ty))\n\t\t\twarning(\"missing prototype\\n\");\n\t}\n\treturn ty;\n}\n\n"
  },
  {
    "path": "lcc/src/enode.c",
    "content": "#include \"c.h\"\n\n\nstatic Tree addtree(int, Tree, Tree);\nstatic Tree andtree(int, Tree, Tree);\nstatic Tree cmptree(int, Tree, Tree);\nstatic int compatible(Type, Type);\nstatic int isnullptr(Tree e);\nstatic Tree multree(int, Tree, Tree);\nstatic Tree subtree(int, Tree, Tree);\n#define isvoidptr(ty) \\\n\t(isptr(ty) && unqual(ty->type) == voidtype)\n\nTree (*optree[])(int, Tree, Tree) = {\n#define xx(a,b,c,d,e,f,g) e,\n#define yy(a,b,c,d,e,f,g) e,\n#include \"token.h\"\n};\nTree call(Tree f, Type fty, Coordinate src) {\n\tint n = 0;\n\tTree args = NULL, r = NULL, e;\n\tType *proto, rty = unqual(freturn(fty));\n\tSymbol t3 = NULL;\n\n\tif (fty->u.f.oldstyle)\n\t\tproto = NULL;\n\telse\n\t\tproto = fty->u.f.proto;\n\tif (hascall(f))\n\t\tr = f;\n\tif (isstruct(rty))\n\t\t{\n\t\t\tt3 = temporary(AUTO, unqual(rty));\n\t\t\tif (rty->size == 0)\n\t\t\t\terror(\"illegal use of incomplete type `%t'\\n\", rty);\n\t\t}\n\tif (t != ')')\n\t\tfor (;;) {\n\t\t\tTree q = pointer(expr1(0));\n\t\t\tif (proto && *proto && *proto != voidtype)\n\t\t\t\t{\n\t\t\t\t\tType aty;\n\t\t\t\t\tq = value(q);\n\t\t\t\t\taty = assign(*proto, q);\n\t\t\t\t\tif (aty)\n\t\t\t\t\t\tq = cast(q, aty);\n\t\t\t\t\telse\n\t\t\t\t\t\terror(\"type error in argument %d to %s; found `%t' expected `%t'\\n\", n + 1, funcname(f),\n\n\t\t\t\t\t\t\tq->type, *proto);\n\t\t\t\t\tif ((isint(q->type) || isenum(q->type))\n\t\t\t\t\t&& q->type->size != inttype->size)\n\t\t\t\t\t\tq = cast(q, promote(q->type));\n\t\t\t\t\t++proto;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (!fty->u.f.oldstyle && *proto == NULL)\n\t\t\t\t\t\terror(\"too many arguments to %s\\n\", funcname(f));\n\t\t\t\t\tq = value(q);\n\t\t\t\t\tif (isarray(q->type) || q->type->size == 0)\n\t\t\t\t\t\terror(\"type error in argument %d to %s; `%t' is illegal\\n\", n + 1, funcname(f), q->type);\n\n\t\t\t\t\telse\n\t\t\t\t\t\tq = cast(q, promote(q->type));\n\t\t\t\t}\n\t\t\tif (!IR->wants_argb && isstruct(q->type))\n\t\t\t\tif (iscallb(q))\n\t\t\t\t\tq = addrof(q);\n\t\t\t\telse {\n\t\t\t\t\tSymbol t1 = temporary(AUTO, unqual(q->type));\n\t\t\t\t\tq = asgn(t1, q);\n\t\t\t\t\tq = tree(RIGHT, ptr(t1->type),\n\t\t\t\t\t\troot(q), lvalue(idtree(t1)));\n\t\t\t\t}\n\t\t\tif (q->type->size == 0)\n\t\t\t\tq->type = inttype;\n\t\t\tif (hascall(q))\n\t\t\t\tr = r ? tree(RIGHT, voidtype, r, q) : q;\n\t\t\targs = tree(mkop(ARG, q->type), q->type, q, args);\n\t\t\tn++;\n\t\t\tif (Aflag >= 2 && n == 32)\n\t\t\t\twarning(\"more than 31 arguments in a call to %s\\n\",\n\t\t\t\t\tfuncname(f));\n\t\t\tif (t != ',')\n\t\t\t\tbreak;\n\t\t\tt = gettok();\n\t\t}\n\texpect(')');\n\tif (proto && *proto && *proto != voidtype)\n\t\terror(\"insufficient number of arguments to %s\\n\",\n\t\t\tfuncname(f));\n\tif (r)\n\t\targs = tree(RIGHT, voidtype, r, args);\n\te = calltree(f, rty, args, t3);\n\tif (events.calls)\n\t\tapply(events.calls, &src, &e);\n\treturn e;\n}\nTree calltree(Tree f, Type ty, Tree args, Symbol t3) {\n\tTree p;\n\n\tif (args)\n\t\tf = tree(RIGHT, f->type, args, f);\n\tif (isstruct(ty))\n\t\tassert(t3),\n\t\tp = tree(RIGHT, ty,\n\t\t\ttree(CALL+B, ty, f, addrof(idtree(t3))),\n\t\t\tidtree(t3));\n\telse {\n\t\tType rty = ty;\n\t\tif (isenum(ty))\n\t\t\trty = unqual(ty)->type;\n\t\tif (!isfloat(rty))\n\t\t\trty = promote(rty);\n\t\tp = tree(mkop(CALL, rty), rty, f, NULL);\n\t\tif (isptr(ty) || p->type->size > ty->size)\n\t\t\tp = cast(p, ty);\n\t}\n\treturn p;\n}\nTree vcall(Symbol func, Type ty, ...) {\n\tva_list ap;\n\tTree args = NULL, e, f = pointer(idtree(func)), r = NULL;\n\n\tassert(isfunc(func->type));\n\tif (ty == NULL)\n\t\tty = freturn(func->type);\n\tva_start(ap, ty);\n\twhile ((e = va_arg(ap, Tree)) != NULL) {\n\t\tif (hascall(e))\n\t\t\tr = r == NULL ? e : tree(RIGHT, voidtype, r, e);\n\t\targs = tree(mkop(ARG, e->type), e->type, e, args);\n\t}\n\tva_end(ap);\n\tif (r != NULL)\n\t\targs = tree(RIGHT, voidtype, r, args);\n\treturn calltree(f, ty, args, NULL);\n}\nint iscallb(Tree e) {\n\treturn e->op == RIGHT && e->kids[0] && e->kids[1]\n\t\t&& e->kids[0]->op == CALL+B\n\t\t&& e->kids[1]->op == INDIR+B\n\t\t&& isaddrop(e->kids[1]->kids[0]->op)\n\t\t&& e->kids[1]->kids[0]->u.sym->temporary;\n}\n\nstatic Tree addtree(int op, Tree l, Tree r) {\n\tType ty = inttype;\n\n\tif (isarith(l->type) && isarith(r->type)) {\n\t\tty = binary(l->type, r->type);\n\t\tl = cast(l, ty);\n\t\tr = cast(r, ty);\t\t\n\t} else if (isptr(l->type) && isint(r->type))\n\t\treturn addtree(ADD, r, l);\n\telse if (  isptr(r->type) && isint(l->type)\n\t&& !isfunc(r->type->type))\n\t\t{\n\t\t\tlong n;\n\t\t\tty = unqual(r->type);\n\t\t\tn = unqual(ty->type)->size;\n\t\t\tif (n == 0)\n\t\t\t\terror(\"unknown size for type `%t'\\n\", ty->type);\n\t\t\tl = cast(l, promote(l->type));\n\t\t\tif (n > 1)\n\t\t\t\tl = multree(MUL, cnsttree(signedptr, n), l);\n\t\t\tif (YYcheck && !isaddrop(r->op))\t\t/* omit */\n\t\t\t\treturn nullcall(ty, YYcheck, r, l);\t/* omit */\n\t\t\treturn simplify(ADD, ty, l, r);\n\t\t}\n\n\telse\n\t\ttypeerror(op, l, r);\n\treturn simplify(op, ty, l, r);\n}\n\nTree cnsttree(Type ty, ...) {\n\tTree p = tree(mkop(CNST,ty), ty, NULL, NULL);\n\tva_list ap;\n\n\tva_start(ap, ty);\n\tswitch (ty->op) {\n\tcase INT:     p->u.v.i = va_arg(ap, long); break;\n\tcase UNSIGNED:p->u.v.u = va_arg(ap, unsigned long)&ones(8*ty->size); break;\n\tcase FLOAT:   p->u.v.d = va_arg(ap, long double); break;\n\tcase POINTER: p->u.v.p = va_arg(ap, void *); break;\n\tdefault: assert(0);\n\t}\n\tva_end(ap);\n\treturn p;\n}\n\nTree consttree(unsigned n, Type ty) {\n\tif (isarray(ty))\n\t\tty = atop(ty);\n\telse assert(isint(ty));\n\treturn cnsttree(ty, (unsigned long)n);\n}\nstatic Tree cmptree(int op, Tree l, Tree r) {\n\tType ty;\n\n\tif (isarith(l->type) && isarith(r->type)) {\n\t\tty = binary(l->type, r->type);\n\t\tl = cast(l, ty);\n\t\tr = cast(r, ty);\n\t} else if (compatible(l->type, r->type)) {\n\t\tty = unsignedptr;\n\t\tl = cast(l, ty);\n\t\tr = cast(r, ty);\n\t} else {\n\t\tty = unsignedtype;\n\t\ttypeerror(op, l, r);\n\t}\n\treturn simplify(mkop(op,ty), inttype, l, r);\n}\nstatic int compatible(Type ty1, Type ty2) {\n\treturn isptr(ty1) && !isfunc(ty1->type)\n\t    && isptr(ty2) && !isfunc(ty2->type)\n\t    && eqtype(unqual(ty1->type), unqual(ty2->type), 0);\n}\nstatic int isnullptr(Tree e) {\n\tType ty = unqual(e->type);\n\n\treturn generic(e->op) == CNST\n\t    && (ty->op == INT      && e->u.v.i == 0\n\t     || ty->op == UNSIGNED && e->u.v.u == 0\n\t     || isvoidptr(ty)      && e->u.v.p == NULL);\n}\nTree eqtree(int op, Tree l, Tree r) {\n\tType xty = l->type, yty = r->type;\n\n\tif (isptr(xty) && isnullptr(r)\n\t||  isptr(xty) && !isfunc(xty->type) && isvoidptr(yty)\n\t||  (isptr(xty) && isptr(yty)\n\t    && eqtype(unqual(xty->type), unqual(yty->type), 1))) {\n\t\tType ty = unsignedptr;\n\t\tl = cast(l, ty);\n\t\tr = cast(r, ty);\n\t\treturn simplify(mkop(op,ty), inttype, l, r);\n\t}\n\tif (isptr(yty) && isnullptr(l)\n\t||  isptr(yty) && !isfunc(yty->type) && isvoidptr(xty))\n\t\treturn eqtree(op, r, l);\n\treturn cmptree(op, l, r);\n}\n\nType assign(Type xty, Tree e) {\n\tType yty = unqual(e->type);\n\n\txty = unqual(xty);\n\tif (isenum(xty))\n\t\txty = xty->type;\n\tif (xty->size == 0 || yty->size == 0)\n\t\treturn NULL;\n\tif ( isarith(xty) && isarith(yty)\n\t||  isstruct(xty) && xty == yty)\n\t\treturn xty;\n\tif (isptr(xty) && isnullptr(e))\n\t\treturn xty;\n\tif ((isvoidptr(xty) && isptr(yty)\n\t  || isptr(xty)     && isvoidptr(yty))\n\t&& (  (isconst(xty->type)    || !isconst(yty->type))\n\t   && (isvolatile(xty->type) || !isvolatile(yty->type))))\n\t\treturn xty;\n\n\tif ((isptr(xty) && isptr(yty)\n\t    && eqtype(unqual(xty->type), unqual(yty->type), 1))\n\t&&  (  (isconst(xty->type)    || !isconst(yty->type))\n\t    && (isvolatile(xty->type) || !isvolatile(yty->type))))\n\t\treturn xty;\n\tif (isptr(xty) && isptr(yty)\n\t&& (  (isconst(xty->type)    || !isconst(yty->type))\n\t   && (isvolatile(xty->type) || !isvolatile(yty->type)))) {\n\t\tType lty = unqual(xty->type), rty = unqual(yty->type);\n\t\tif (isenum(lty) && rty == inttype\n\t\t||  isenum(rty) && lty == inttype) {\n\t\t\tif (Aflag >= 1)\n\t\t\t\twarning(\"assignment between `%t' and `%t' is compiler-dependent\\n\",\n\t\t\t\t\txty, yty);\n\t\t\treturn xty;\n\t\t}\n\t}\n\treturn NULL;\n}\nTree asgntree(int op, Tree l, Tree r) {\n\tType aty, ty;\n\n\tr = pointer(r);\n\tty = assign(l->type, r);\n\tif (ty)\n\t\tr = cast(r, ty);\n\telse {\n\t\ttypeerror(ASGN, l, r);\n\t\tif (r->type == voidtype)\n\t\t\tr = retype(r, inttype);\n\t\tty = r->type;\n\t}\n\tif (l->op != FIELD)\n\t\tl = lvalue(l);\n\taty = l->type;\n\tif (isptr(aty))\n\t\taty = unqual(aty)->type;\n\tif ( isconst(aty)\n\t||  isstruct(aty) && unqual(aty)->u.sym->u.s.cfields)\n\t\tif (isaddrop(l->op)\n\t\t&& !l->u.sym->computed && !l->u.sym->generated)\n\t\t\terror(\"assignment to const identifier `%s'\\n\",\n\t\t\t\tl->u.sym->name);\n\t\telse\n\t\t\terror(\"assignment to const location\\n\");\n\tif (l->op == FIELD) {\n\t\tlong n = 8*l->u.field->type->size - fieldsize(l->u.field);\n\t\tif (n > 0 && isunsigned(l->u.field->type))\n\t\t\tr = bittree(BAND, r,\n\t\t\t\tcnsttree(r->type, (unsigned long)fieldmask(l->u.field)));\n\t\telse if (n > 0) {\n\t\t\tif (r->op == CNST+I) {\n\t\t\t\tn = r->u.v.i;\n\t\t\t\tif (n&(1<<(fieldsize(l->u.field)-1)))\n\t\t\t\t\tn |= ~0UL<<fieldsize(l->u.field);\n\t\t\t\tr = cnsttree(r->type, n);\n\t\t\t} else\n\t\t\t\tr = shtree(RSH,\n\t\t\t\t\tshtree(LSH, r, cnsttree(inttype, n)),\n\t\t\t\t\tcnsttree(inttype, n));\n\t\t}\n\t}\n\tif (isstruct(ty) && isaddrop(l->op) && iscallb(r))\n\t\treturn tree(RIGHT, ty,\n\t\t\ttree(CALL+B, ty, r->kids[0]->kids[0], l),\n\t\t\tidtree(l->u.sym));\n\treturn tree(mkop(op,ty), ty, l, r);\n}\nTree condtree(Tree e, Tree l, Tree r) {\n\tSymbol t1;\n\tType ty, xty = l->type, yty = r->type;\n\tTree p;\n\n\tif (isarith(xty) && isarith(yty))\n\t\tty = binary(xty, yty);\n\telse if (eqtype(xty, yty, 1))\n\t\tty = unqual(xty);\n\telse if (isptr(xty)   && isnullptr(r))\n\t\tty = xty;\n\telse if (isnullptr(l) && isptr(yty))\n\t\tty = yty;\n\telse if (isptr(xty) && !isfunc(xty->type) && isvoidptr(yty)\n\t||       isptr(yty) && !isfunc(yty->type) && isvoidptr(xty))\n\t\tty = voidptype;\n\telse if ((isptr(xty) && isptr(yty)\n\t\t && eqtype(unqual(xty->type), unqual(yty->type), 1)))\n\t\tty = xty;\n\telse {\n\t\ttypeerror(COND, l, r);\n\t\treturn consttree(0, inttype);\n\t}\n\tif (isptr(ty)) {\n\t\tty = unqual(unqual(ty)->type);\n\t\tif (isptr(xty) && isconst(unqual(xty)->type)\n\t\t||  isptr(yty) && isconst(unqual(yty)->type))\n\t\t\tty = qual(CONST, ty);\n\t\tif (isptr(xty) && isvolatile(unqual(xty)->type)\n\t\t||  isptr(yty) && isvolatile(unqual(yty)->type))\n\t\t\tty = qual(VOLATILE, ty);\n\t\tty = ptr(ty);\n\t}\n\tswitch (e->op) {\n\tcase CNST+I: return cast(e->u.v.i != 0   ? l : r, ty);\n\tcase CNST+U: return cast(e->u.v.u != 0   ? l : r, ty);\n\tcase CNST+P: return cast(e->u.v.p != 0   ? l : r, ty);\n\tcase CNST+F: return cast(e->u.v.d != 0.0 ? l : r, ty);\n\t}\n\tif (ty != voidtype && ty->size > 0) {\n\t\tt1 = genident(REGISTER, unqual(ty), level);\n\t/*\tt1 = temporary(REGISTER, unqual(ty)); */\n\t\tl = asgn(t1, l);\n\t\tr = asgn(t1, r);\n\t} else\n\t\tt1 = NULL;\n\tp = tree(COND, ty, cond(e),\n\t\ttree(RIGHT, ty, root(l), root(r)));\n\tp->u.sym = t1;\n\treturn p;\n}\n/* addrof - address of p */\nTree addrof(Tree p) {\n\tTree q = p;\n\n\tfor (;;)\n\t\tswitch (generic(q->op)) {\n\t\tcase RIGHT:\n\t\t\tassert(q->kids[0] || q->kids[1]);\n\t\t\tq = q->kids[1] ? q->kids[1] : q->kids[0];\n\t\t\tcontinue;\n\t\tcase ASGN:\n\t\t\tq = q->kids[1];\n\t\t\tcontinue;\n\t\tcase COND: {\n\t\t\tSymbol t1 = q->u.sym;\n\t\t\tq->u.sym = 0;\n\t\t\tq = idtree(t1);\n\t\t\t/* fall thru */\n\t\t\t}\n\t\tcase INDIR:\n\t\t\tif (p == q)\n\t\t\t\treturn q->kids[0];\n\t\t\tq = q->kids[0];\n\t\t\treturn tree(RIGHT, q->type, root(p), q);\n\t\tdefault:\n\t\t\terror(\"addressable object required\\n\");\n\t\t\treturn value(p);\n\t\t}\n}\n\n/* andtree - construct tree for l [&& ||] r */\nstatic Tree andtree(int op, Tree l, Tree r) {\n\tif (!isscalar(l->type) || !isscalar(r->type))\n\t\ttypeerror(op, l, r);\n\treturn simplify(op, inttype, cond(l), cond(r));\n}\n\n/* asgn - generate tree for assignment of expr e to symbol p sans qualifiers */\nTree asgn(Symbol p, Tree e) {\n\tif (isarray(p->type))\n\t\te = tree(ASGN+B, p->type, idtree(p),\n\t\t\ttree(INDIR+B, e->type, e, NULL));\n\telse {\n\t\tType ty = p->type;\n\t\tp->type = unqual(p->type);\n\t\tif (isstruct(p->type) && p->type->u.sym->u.s.cfields) {\n\t\t\tp->type->u.sym->u.s.cfields = 0;\n\t\t\te = asgntree(ASGN, idtree(p), e);\n\t\t\tp->type->u.sym->u.s.cfields = 1;\n\t\t} else\n\t\t\te = asgntree(ASGN, idtree(p), e);\n\t\tp->type = ty;\n\t}\n\treturn e;\n}\n\n/* bittree - construct tree for l [& | ^ %] r */\nTree bittree(int op, Tree l, Tree r) {\n\tType ty = inttype;\n\n\tif (isint(l->type) && isint(r->type)) {\n \t\tty = binary(l->type, r->type);\n\t\tl = cast(l, ty);\n\t\tr = cast(r, ty);\t\t\n\t} else\n\t\ttypeerror(op, l, r);\n\treturn simplify(op, ty, l, r);\n}\n\n/* multree - construct tree for l [* /] r */\nstatic Tree multree(int op, Tree l, Tree r) {\n\tType ty = inttype;\n\n\tif (isarith(l->type) && isarith(r->type)) {\n\t\tty = binary(l->type, r->type);\n\t\tl = cast(l, ty);\n\t\tr = cast(r, ty);\t\t\n\t} else\n\t\ttypeerror(op, l, r);\n\treturn simplify(op, ty, l, r);\n}\n\n/* shtree - construct tree for l [>> <<] r */\nTree shtree(int op, Tree l, Tree r) {\n\tType ty = inttype;\n\n\tif (isint(l->type) && isint(r->type)) {\n\t\tty = promote(l->type);\n\t\tl = cast(l, ty);\n\t\tr = cast(r, inttype);\n\t} else\n\t\ttypeerror(op, l, r);\n\treturn simplify(op, ty, l, r);\n}\n\n/* subtree - construct tree for l - r */\nstatic Tree subtree(int op, Tree l, Tree r) {\n\tlong n;\n\tType ty = inttype;\n\n\tif (isarith(l->type) && isarith(r->type)) {\n\t\tty = binary(l->type, r->type);\n\t\tl = cast(l, ty);\n\t\tr = cast(r, ty);\t\t\n\t} else if (isptr(l->type) && !isfunc(l->type->type) && isint(r->type)) {\n\t\tty = unqual(l->type);\n\t\tn = unqual(ty->type)->size;\n\t\tif (n == 0)\n\t\t\terror(\"unknown size for type `%t'\\n\", ty->type);\n\t\tr = cast(r, promote(r->type));\n\t\tif (n > 1)\n\t\t\tr = multree(MUL, cnsttree(signedptr, n), r);\n\t\tif (isunsigned(r->type))\n\t\t\tr = cast(r, unsignedptr);\n\t\telse\n\t\t\tr = cast(r, signedptr);\n\t\treturn simplify(SUB+P, ty, l, r);\n\t} else if (compatible(l->type, r->type)) {\n\t\tty = unqual(l->type);\n\t\tn = unqual(ty->type)->size;\n\t\tif (n == 0)\n\t\t\terror(\"unknown size for type `%t'\\n\", ty->type);\n\t\tl = simplify(SUB+U, unsignedptr,\n\t\t\tcast(l, unsignedptr), cast(r, unsignedptr));\n\t\treturn simplify(DIV+I, longtype,\n\t\t\tcast(l, longtype), cnsttree(longtype, n));\n\t} else\n\t\ttypeerror(op, l, r);\n\treturn simplify(op, ty, l, r);\n}\n\n/* typeerror - issue \"operands of op have illegal types `l' and `r'\" */\nvoid typeerror(int op, Tree l, Tree r) {\n\tint i;\n\tstatic struct { int op; char *name; } ops[] = {\n\t\tASGN, \"=\",\tINDIR, \"*\",\tNEG,  \"-\",\n\t\tADD,  \"+\",\tSUB,   \"-\",\tLSH,  \"<<\",\n\t\tMOD,  \"%\",\tRSH,   \">>\",\tBAND, \"&\",\n\t\tBCOM, \"~\",\tBOR,   \"|\",\tBXOR, \"^\",\n\t\tDIV,  \"/\",\tMUL,   \"*\",\tEQ,   \"==\",\n\t\tGE,   \">=\",\tGT,    \">\",\tLE,   \"<=\",\n\t\tLT,   \"<\",\tNE,    \"!=\",\tAND,  \"&&\",\n\t\tNOT,  \"!\",\tOR,    \"||\",\tCOND, \"?:\",\n\t\t0, 0\n\t};\n\n\top = generic(op);\n\tfor (i = 0; ops[i].op; i++)\n\t\tif (op == ops[i].op)\n\t\t\tbreak;\n\tassert(ops[i].name);\n\tif (r)\n\t\terror(\"operands of %s have illegal types `%t' and `%t'\\n\",\n\t\t\tops[i].name, l->type, r->type);\n\telse\n\t\terror(\"operand of unary %s has illegal type `%t'\\n\", ops[i].name,\n\t\t\tl->type);\n}\n"
  },
  {
    "path": "lcc/src/error.c",
    "content": "#include \"c.h\"\n\n\nstatic void printtoken(void);\nint errcnt   = 0;\nint errlimit = 20;\nchar kind[] = {\n#define xx(a,b,c,d,e,f,g) f,\n#define yy(a,b,c,d,e,f,g) f,\n#include \"token.h\"\n};\nint wflag;\t\t/* != 0 to suppress warning messages */\n\nvoid test(int tok, char set[]) {\n\tif (t == tok)\n\t\tt = gettok();\n\telse {\n\t\texpect(tok);\n\t\tskipto(tok, set);\n\t\tif (t == tok)\n\t\t\tt = gettok();\n\t}\n}\nvoid expect(int tok) {\n\tif (t == tok)\n\t\tt = gettok();\n\telse {\n\t\terror(\"syntax error; found\");\n\t\tprinttoken();\n\t\tfprint(stderr, \" expecting `%k'\\n\", tok);\n\t}\n}\nvoid error(const char *fmt, ...) {\n\tva_list ap;\n\n\tif (errcnt++ >= errlimit) {\n\t\terrcnt = -1;\n\t\terror(\"too many errors\\n\");\n\t\texit(1);\n\t}\n\tva_start(ap, fmt);\n\tif (firstfile != file && firstfile && *firstfile)\n\t\tfprint(stderr, \"%s: \", firstfile);\n\tfprint(stderr, \"%w: \", &src);\n\tvfprint(stderr, NULL, fmt, ap);\n\tva_end(ap);\n}\n\nvoid skipto(int tok, char set[]) {\n\tint n;\n\tchar *s;\n\n\tassert(set);\n\tfor (n = 0; t != EOI && t != tok; t = gettok()) {\n\t\tfor (s = set; *s && kind[t] != *s; s++)\n\t\t\t;\n\t\tif (kind[t] == *s)\n\t\t\tbreak;\n\t\tif (n++ == 0)\n\t\t\terror(\"skipping\");\n\t\tif (n <= 8)\n\t\t\tprinttoken();\n\t\telse if (n == 9)\n\t\t\tfprint(stderr, \" ...\");\n\t}\n\tif (n > 8) {\n\t\tfprint(stderr, \" up to\");\n\t\tprinttoken();\n\t}\n\tif (n > 0)\n\t\tfprint(stderr, \"\\n\");\n}\n/* fatal - issue fatal error message and exit */\nint fatal(const char *name, const char *fmt, int n) {\n\tprint(\"\\n\");\n\terrcnt = -1;\n\terror(\"compiler error in %s--\", name);\n\tfprint(stderr, fmt, n);\n\texit(EXIT_FAILURE);\n\treturn 0;\n}\n\n/* printtoken - print current token preceeded by a space */\nstatic void printtoken(void) {\n\tswitch (t) {\n\tcase ID: fprint(stderr, \" `%s'\", token); break;\n\tcase ICON:\n\t\tfprint(stderr, \" `%s'\", vtoa(tsym->type, tsym->u.c.v));\n\t\tbreak;\n\tcase SCON: {\n\t\tint i, n;\n\t\tif (ischar(tsym->type->type)) {\n\t\t\tchar *s = tsym->u.c.v.p;\n\t\t\tn = tsym->type->size;\n\t\t\tfprint(stderr, \" \\\"\");\n\t\t\tfor (i = 0; i < 20 && i < n && *s; s++, i++)\n\t\t\t\tif (*s < ' ' || *s >= 0177)\n\t\t\t\t\tfprint(stderr, \"\\\\%o\", *s);\n\t\t\t\telse\n\t\t\t\t\tfprint(stderr, \"%c\", *s);\n\t\t} else {\t/* wchar_t string */\n\t\t\tunsigned int *s = tsym->u.c.v.p;\n\t\t\tassert(tsym->type->type->size == widechar->size);\n\t\t\tn = tsym->type->size/widechar->size;\n\t\t\tfprint(stderr, \" L\\\"\");\n\t\t\tfor (i = 0; i < 20 && i < n && *s; s++, i++)\n\t\t\t\tif (*s < ' ' || *s >= 0177)\n\t\t\t\t\tfprint(stderr, \"\\\\x%x\", *s);\n\t\t\t\telse\n\t\t\t\t\tfprint(stderr, \"%c\", *s);\n\t\t}\n\t\tif (i < n)\n\t\t\tfprint(stderr, \" ...\");\n\t\telse\n\t\t\tfprint(stderr, \"\\\"\");\n\t\tbreak;\n\t\t}\n\tcase FCON:\n\t\tfprint(stderr, \" `%S'\", token, (char*)cp - token);\n\t\tbreak;\n\tcase '`': case '\\'': fprint(stderr, \" \\\"%k\\\"\", t); break;\n\tdefault: fprint(stderr, \" `%k'\", t);\n\t}\n}\n\n/* warning - issue warning error message */\nvoid warning(const char *fmt, ...) {\n\tva_list ap;\n\n\tva_start(ap, fmt);\n\tif (wflag == 0) {\n\t\terrcnt--;\n\t\terror(\"warning: \");\n\t\tvfprint(stderr, NULL, fmt, ap);\n\t}\n\tva_end(ap);\n}\n"
  },
  {
    "path": "lcc/src/event.c",
    "content": "#include \"c.h\"\n\n\nstruct entry {\n\tApply func;\n\tvoid *cl;\n};\n\nEvents events;\nvoid attach(Apply func, void *cl, List *list) {\n\tstruct entry *p;\n\n\tNEW(p, PERM);\n\tp->func = func;\n\tp->cl = cl;\n\t*list = append(p, *list);\n}\nvoid apply(List event, void *arg1, void *arg2) {\n\tif (event) {\n\t\tList lp = event;\n\t\tdo {\n\t\t\tstruct entry *p = lp->x;\n\t\t\t(*p->func)(p->cl, arg1, arg2);\n\t\t\tlp = lp->link;\n\t\t} while (lp != event);\n\t}\n}\n\n"
  },
  {
    "path": "lcc/src/expr.c",
    "content": "#include \"c.h\"\n\n\nstatic char prec[] = {\n#define xx(a,b,c,d,e,f,g) c,\n#define yy(a,b,c,d,e,f,g) c,\n#include \"token.h\"\n};\nstatic int oper[] = {\n#define xx(a,b,c,d,e,f,g) d,\n#define yy(a,b,c,d,e,f,g) d,\n#include \"token.h\"\n};\nfloat refinc = 1.0;\nstatic Tree expr2(void);\nstatic Tree expr3(int);\nstatic Tree nullcheck(Tree);\nstatic Tree postfix(Tree);\nstatic Tree unary(void);\nstatic Tree primary(void);\nstatic Type super(Type ty);\n\nstatic Type super(Type ty) {\n\tswitch (ty->op) {\n\tcase INT:\n\t\tif (ty->size < inttype->size)\n\t\t\treturn inttype;\n\t\tbreak;\n\tcase UNSIGNED:\n\t\tif (ty->size < unsignedtype->size)\n\t\t\treturn unsignedtype;\n\t\tbreak;\n\tcase POINTER:\n\t\treturn unsignedptr;\n\t}\n\treturn ty;\n}\nTree expr(int tok) {\n\tstatic char stop[] = { IF, ID, '}', 0 };\n\tTree p = expr1(0);\n\n\twhile (t == ',') {\n\t\tTree q;\n\t\tt = gettok();\n\t\tq = pointer(expr1(0));\n\t\tp = tree(RIGHT, q->type, root(value(p)), q);\n\t}\n\tif (tok)\t\n\t\ttest(tok, stop);\n\treturn p;\n}\nTree expr0(int tok) {\n\treturn root(expr(tok));\n}\nTree expr1(int tok) {\n\tstatic char stop[] = { IF, ID, 0 };\n\tTree p = expr2();\n\n\tif (t == '='\n\t|| (prec[t] >=  6 && prec[t] <=  8)\n\t|| (prec[t] >= 11 && prec[t] <= 13)) {\n\t\tint op = t;\n\t\tt = gettok();\n\t\tif (oper[op] == ASGN)\n\t\t\tp = asgntree(ASGN, p, value(expr1(0)));\n\t\telse\n\t\t\t{\n\t\t\t\texpect('=');\n\t\t\t\tp = incr(op, p, expr1(0));\n\t\t\t}\n\t}\n\tif (tok)\t\n\t\ttest(tok, stop);\n\treturn p;\n}\nTree incr(int op, Tree v, Tree e) {\n\treturn asgntree(ASGN, v, (*optree[op])(oper[op], v, e));\n}\nstatic Tree expr2(void) {\n\tTree p = expr3(4);\n\n\tif (t == '?') {\n\t\tTree l, r;\n\t\tCoordinate pts[2];\n\t\tif (Aflag > 1 && isfunc(p->type))\n\t\t\twarning(\"%s used in a conditional expression\\n\",\n\t\t\t\tfuncname(p));\n\t\tp = pointer(p);\n\t\tt = gettok();\n\t\tpts[0] = src;\n\t\tl = pointer(expr(':'));\n\t\tpts[1] = src;\n\t\tr = pointer(expr2());\n\t\tif (events.points)\n\t\t\t{\n\t\t\t\tapply(events.points, &pts[0], &l);\n\t\t\t\tapply(events.points, &pts[1], &r);\n\t\t\t}\n\t\tp = condtree(p, l, r);\n\t}\n\treturn p;\n}\nTree value(Tree p) {\n\tint op = generic(rightkid(p)->op);\n\n\tif (p->type != voidtype\n\t&& (op==AND || op==OR || op==NOT || op==EQ || op==NE\n\t||  op== LE || op==LT || op== GE || op==GT))\n\t\tp = condtree(p, consttree(1, inttype),\n\t\t\tconsttree(0, inttype));\n\treturn p;\n}\nstatic Tree expr3(int k) {\n\tint k1;\n\tTree p = unary();\n\n\tfor (k1 = prec[t]; k1 >= k; k1--)\n\t\twhile (prec[t] == k1 && *cp != '=') {\n\t\t\tTree r;\n\t\t\tCoordinate pt;\n\t\t\tint op = t;\n\t\t\tt = gettok();\n\t\t\tpt = src;\n\t\t\tp = pointer(p);\n\t\t\tif (op == ANDAND || op == OROR) {\n\t\t\t\tr = pointer(expr3(k1));\n\t\t\t\tif (events.points)\n\t\t\t\t\tapply(events.points, &pt, &r);\n\t\t\t} else\n\t\t\t\tr = pointer(expr3(k1 + 1));\n\t\t\tp = (*optree[op])(oper[op], p, r); \n\t\t}\n\treturn p;\n}\nstatic Tree unary(void) {\n\tTree p;\n\n\tswitch (t) {\n\tcase '*':    t = gettok(); p = unary(); p = pointer(p);\n\t\t\t\t\t\t  if (isptr(p->type)\n\t\t\t\t\t\t  && (isfunc(p->type->type) || isarray(p->type->type)))\n\t\t\t\t\t\t  \tp = retype(p, p->type->type);\n\t\t\t\t\t\t  else {\n\t\t\t\t\t\t  \tif (YYnull)\n\t\t\t\t\t\t  \t\tp = nullcheck(p);\n\t\t\t\t\t\t  \tp = rvalue(p);\n\t\t\t\t\t\t  } break;\n\tcase '&':    t = gettok(); p = unary(); if (isarray(p->type) || isfunc(p->type))\n\t\t\t\t\t\t  \tp = retype(p, ptr(p->type));\n\t\t\t\t\t\t  else\n\t\t\t\t\t\t  \tp = lvalue(p);\n\t\t\t\t\t\t  if (isaddrop(p->op) && p->u.sym->sclass == REGISTER)\n\t\t\t\t\t\t  \terror(\"invalid operand of unary &; `%s' is declared register\\n\", p->u.sym->name);\n\n\t\t\t\t\t\t  else if (isaddrop(p->op))\n\t\t\t\t\t\t  \tp->u.sym->addressed = 1;\n break;\n\tcase '+':    t = gettok(); p = unary(); p = pointer(p);\n\t\t\t\t\t\t  if (isarith(p->type))\n\t\t\t\t\t\t  \tp = cast(p, promote(p->type));\n\t\t\t\t\t\t  else\n\t\t\t\t\t\t  \ttypeerror(ADD, p, NULL);  break;\n\tcase '-':    t = gettok(); p = unary(); p = pointer(p);\n\t\t\t\t\t\t  if (isarith(p->type)) {\n\t\t\t\t\t\t  \tType ty = promote(p->type);\n\t\t\t\t\t\t  \tp = cast(p, ty);\n\t\t\t\t\t\t  \tif (isunsigned(ty)) {\n\t\t\t\t\t\t  \t\twarning(\"unsigned operand of unary -\\n\");\n\t\t\t\t\t\t  \t\tp = simplify(ADD, ty, simplify(BCOM, ty, p, NULL), cnsttree(ty, 1UL));\n\t\t\t\t\t\t  \t} else\n\t\t\t\t\t\t  \t\tp = simplify(NEG, ty, p, NULL);\n\t\t\t\t\t\t  } else\n\t\t\t\t\t\t  \ttypeerror(SUB, p, NULL); break;\n\tcase '~':    t = gettok(); p = unary(); p = pointer(p);\n\t\t\t\t\t\t  if (isint(p->type)) {\n\t\t\t\t\t\t  \tType ty = promote(p->type);\n\t\t\t\t\t\t  \tp = simplify(BCOM, ty, cast(p, ty), NULL);\n\t\t\t\t\t\t  } else\n\t\t\t\t\t\t  \ttypeerror(BCOM, p, NULL);  break;\n\tcase '!':    t = gettok(); p = unary(); p = pointer(p);\n\t\t\t\t\t\t  if (isscalar(p->type))\n\t\t\t\t\t\t  \tp = simplify(NOT, inttype, cond(p), NULL);\n\t\t\t\t\t\t  else\n\t\t\t\t\t\t  \ttypeerror(NOT, p, NULL); break;\n\tcase INCR:   t = gettok(); p = unary(); p = incr(INCR, pointer(p), consttree(1, inttype)); break;\n\tcase DECR:   t = gettok(); p = unary(); p = incr(DECR, pointer(p), consttree(1, inttype)); break;\n\tcase TYPECODE: case SIZEOF: { int op = t;\n\t\t\t\t      Type ty;\n\t\t\t\t      p = NULL;\n\t\t\t\t      t = gettok();\n\t\t\t\t      if (t == '(') {\n\t\t\t\t      \tt = gettok();\n\t\t\t\t      \tif (istypename(t, tsym)) {\n\t\t\t\t      \t\tty = typename();\n\t\t\t\t      \t\texpect(')');\n\t\t\t\t      \t} else {\n\t\t\t\t      \t\tp = postfix(expr(')'));\n\t\t\t\t      \t\tty = p->type;\n\t\t\t\t      \t}\n\t\t\t\t      } else {\n\t\t\t\t      \tp = unary();\n\t\t\t\t      \tty = p->type;\n\t\t\t\t      }\n\t\t\t\t      assert(ty);\n\t\t\t\t      if (op == TYPECODE)\n\t\t\t\t      \tp = cnsttree(inttype, (long)ty->op);\n\t\t\t\t      else {\n\t\t\t\t      \tif (isfunc(ty) || ty->size == 0)\n\t\t\t\t      \t\terror(\"invalid type argument `%t' to `sizeof'\\n\", ty);\n\t\t\t\t      \telse if (p && rightkid(p)->op == FIELD)\n\t\t\t\t      \t\terror(\"`sizeof' applied to a bit field\\n\");\n\t\t\t\t      \tp = cnsttree(unsignedlong, (unsigned long)ty->size);\n\t\t\t\t      } } break;\n\tcase '(':\n\t\tt = gettok();\n\t\tif (istypename(t, tsym)) {\n\t\t\tType ty, ty1 = typename(), pty;\n\t\t\texpect(')');\n\t\t\tty = unqual(ty1);\n\t\t\tif (isenum(ty)) {\n\t\t\t\tType ty2 = ty->type;\n\t\t\t\tif (isconst(ty1))\n\t\t\t\t\tty2 = qual(CONST, ty2);\n\t\t\t\tif (isvolatile(ty1))\n\t\t\t\t\tty2 = qual(VOLATILE, ty2);\n\t\t\t\tty1 = ty2;\n\t\t\t\tty = ty->type;\n\t\t\t}\n\t\t\tp = pointer(unary());\n\t\t\tpty = p->type;\n\t\t\tif (isenum(pty))\n\t\t\t\tpty = pty->type;\n\t\t\tif (isarith(pty) && isarith(ty)\n\t\t\t||  isptr(pty)   && isptr(ty)) {\n\t\t\t\texplicitCast++;\n\t\t\t\tp = cast(p, ty);\n\t\t\t\texplicitCast--;\n\t\t\t} else if (isptr(pty) && isint(ty)\n\t\t\t||       isint(pty) && isptr(ty)) {\n\t\t\t\tif (Aflag >= 1 && ty->size < pty->size)\n\t\t\t\t\twarning(\"conversion from `%t' to `%t' is compiler dependent\\n\", p->type, ty);\n\n\t\t\t\tp = cast(p, ty);\n\t\t\t} else if (ty != voidtype) {\n\t\t\t\terror(\"cast from `%t' to `%t' is illegal\\n\",\n\t\t\t\t\tp->type, ty1);\n\t\t\t\tty1 = inttype;\n\t\t\t}\n\t\t\tif (generic(p->op) == INDIR || ty->size == 0)\n\t\t\t\tp = tree(RIGHT, ty1, NULL, p);\n\t\t\telse\n\t\t\t\tp = retype(p, ty1);\n\t\t} else\n\t\t\tp = postfix(expr(')'));\n\t\tbreak;\n\tdefault:\n\t\tp = postfix(primary());\n\t}\n\treturn p;\n}\n\nstatic Tree postfix(Tree p) {\n\tfor (;;)\n\t\tswitch (t) {\n\t\tcase INCR:  p = tree(RIGHT, p->type,\n\t\t\t    \ttree(RIGHT, p->type,\n\t\t\t    \t\tp,\n\t\t\t    \t\tincr(t, p, consttree(1, inttype))),\n\t\t\t    \tp);\n\t\t\t    t = gettok(); break;\n\t\tcase DECR:  p = tree(RIGHT, p->type,\n\t\t\t    \ttree(RIGHT, p->type,\n\t\t\t    \t\tp,\n\t\t\t    \t\tincr(t, p, consttree(1, inttype))),\n\t\t\t    \tp);\n\t\t\t    t = gettok(); break;\n\t\tcase '[':   {\n\t\t\t    \tTree q;\n\t\t\t    \tt = gettok();\n\t\t\t    \tq = expr(']');\n\t\t\t    \tif (YYnull)\n\t\t\t    \t\tif (isptr(p->type))\n\t\t\t    \t\t\tp = nullcheck(p);\n\t\t\t    \t\telse if (isptr(q->type))\n\t\t\t    \t\t\tq = nullcheck(q);\n\t\t\t    \tp = (*optree['+'])(ADD, pointer(p), pointer(q));\n\t\t\t    \tif (isptr(p->type) && isarray(p->type->type))\n\t\t\t    \t\tp = retype(p, p->type->type);\n\t\t\t    \telse\n\t\t\t    \t\tp = rvalue(p);\n\t\t\t    } break;\n\t\tcase '(':   {\n\t\t\t    \tType ty;\n\t\t\t    \tCoordinate pt;\n\t\t\t    \tp = pointer(p);\n\t\t\t    \tif (isptr(p->type) && isfunc(p->type->type))\n\t\t\t    \t\tty = p->type->type;\n\t\t\t    \telse {\n\t\t\t    \t\terror(\"found `%t' expected a function\\n\", p->type);\n\t\t\t    \t\tty = func(voidtype, NULL, 1);\n\t\t\t    \t\tp = retype(p, ptr(ty));\n\t\t\t    \t}\n\t\t\t    \tpt = src;\n\t\t\t    \tt = gettok();\n\t\t\t    \tp = call(p, ty, pt);\n\t\t\t    } break;\n\t\tcase '.':   t = gettok();\n\t\t\t    if (t == ID) {\n\t\t\t    \tif (isstruct(p->type)) {\n\t\t\t    \t\tTree q = addrof(p);\n\t\t\t    \t\tp = field(q, token);\n\t\t\t    \t\tq = rightkid(q);\n\t\t\t    \t\tif (isaddrop(q->op) && q->u.sym->temporary)\n\t\t\t    \t\t\tp = tree(RIGHT, p->type, p, NULL);\n\t\t\t    \t} else\n\t\t\t    \t\terror(\"left operand of . has incompatible type `%t'\\n\",\n\t\t\t    \t\t\tp->type);\n\t\t\t    \tt = gettok();\n\t\t\t    } else\n\t\t\t    \terror(\"field name expected\\n\"); break;\n\t\tcase DEREF: t = gettok();\n\t\t\t    p = pointer(p);\n\t\t\t    if (t == ID) {\n\t\t\t    \tif (isptr(p->type) && isstruct(p->type->type)) {\n\t\t\t    \t\tif (YYnull)\n\t\t\t    \t\t\tp = nullcheck(p);\n\t\t\t    \t\tp = field(p, token);\n\t\t\t    \t} else\n\t\t\t    \t\terror(\"left operand of -> has incompatible type `%t'\\n\", p->type);\n\n\t\t\t    \tt = gettok();\n\t\t\t    } else\n\t\t\t    \terror(\"field name expected\\n\"); break;\n\t\tdefault:\n\t\t\treturn p;\n\t\t}\n}\nstatic Tree primary(void) {\n\tTree p;\n\n\tassert(t != '(');\n\tswitch (t) {\n\tcase ICON:\n\tcase FCON: p = tree(mkop(CNST,tsym->type), tsym->type, NULL, NULL);\n\t\t   p->u.v = tsym->u.c.v;\n break;\n\tcase SCON: if (ischar(tsym->type->type))\n\t\t   \ttsym->u.c.v.p = stringn(tsym->u.c.v.p, tsym->type->size);\n\t\t   else\n\t\t   \ttsym->u.c.v.p = memcpy(allocate(tsym->type->size, PERM), tsym->u.c.v.p, tsym->type->size);\n\t\t   tsym = constant(tsym->type, tsym->u.c.v); \n\t\t   if (tsym->u.c.loc == NULL)\n\t\t   \ttsym->u.c.loc = genident(STATIC, tsym->type, GLOBAL);\n\t\t   p = idtree(tsym->u.c.loc); break;\n\tcase ID:   if (tsym == NULL)\n\t\t   \t{\n\t\t\t\tSymbol p = install(token, &identifiers, level, FUNC);\n\t\t\t\tp->src = src;\n\t\t\t\tif (getchr() == '(') {\n\t\t\t\t\tSymbol q = lookup(token, externals);\n\t\t\t\t\tp->type = func(inttype, NULL, 1);\n\t\t\t\t\tp->sclass = EXTERN;\n\t\t\t\t\tif (Aflag >= 1)\n\t\t\t\t\t\twarning(\"missing prototype\\n\");\n\t\t\t\t\tif (q && !eqtype(q->type, p->type, 1))\n\t\t\t\t\t\twarning(\"implicit declaration of `%s' does not match previous declaration at %w\\n\", q->name, &q->src);\n\n\t\t\t\t\tif (q == NULL) {\n\t\t\t\t\t\tq = install(p->name, &externals, GLOBAL, PERM);\n\t\t\t\t\t\tq->type = p->type;\n\t\t\t\t\t\tq->sclass = EXTERN;\n\t\t\t\t\t\tq->src = src;\n\t\t\t\t\t\t(*IR->defsymbol)(q);\n\t\t\t\t\t}\n\t\t\t\t\tp->u.alias = q;\n\t\t\t\t} else {\n\t\t\t\t\terror(\"undeclared identifier `%s'\\n\", p->name);\n\t\t\t\t\tp->sclass = AUTO;\n\t\t\t\t\tp->type = inttype;\n\t\t\t\t\tif (p->scope == GLOBAL)\n\t\t\t\t\t\t(*IR->defsymbol)(p);\n\t\t\t\t\telse\n\t\t\t\t\t\taddlocal(p);\n\t\t\t\t}\n\t\t\t\tt = gettok();\n\t\t\t\tif (xref)\n\t\t\t\t\tuse(p, src);\n\t\t\t\treturn idtree(p);\n\t\t\t}\n\t\t   if (xref)\n\t\t   \tuse(tsym, src);\n\t\t   if (tsym->sclass == ENUM)\n\t\t   \tp = consttree(tsym->u.value, inttype);\n\t\t   else {\n\t\t   \tif (tsym->sclass == TYPEDEF)\n\t\t   \t\terror(\"illegal use of type name `%s'\\n\", tsym->name);\n\t\t   \tp = idtree(tsym);\n\t\t   } break;\n\tcase FIRSTARG:\n\t\tif (level > PARAM && cfunc && cfunc->u.f.callee[0])\n\t\t\tp = idtree(cfunc->u.f.callee[0]);\n\t\telse {\n\t\t\terror(\"illegal use of `%k'\\n\", FIRSTARG);\n\t\t\tp = cnsttree(inttype, 0L);\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\terror(\"illegal expression\\n\");\n\t\t\tp = cnsttree(inttype, 0L);\n\t}\n\tt = gettok();\n\treturn p;\n}\nTree idtree(Symbol p) {\n\tint op;\n\tTree e;\n\tType ty = p->type ? unqual(p->type) : voidptype;\n\n\tif (p->scope == GLOBAL || p->sclass == STATIC)\n\t\top = ADDRG;\n\telse if (p->scope == PARAM) {\n\t\top = ADDRF;\n\t\tif (isstruct(p->type) && !IR->wants_argb)\n\t\t\t{\n\t\t\t\te = tree(mkop(op,voidptype), ptr(ptr(p->type)), NULL, NULL);\n\t\t\t\te->u.sym = p;\n\t\t\t\treturn rvalue(rvalue(e));\n\t\t\t}\n\t} else if (p->sclass == EXTERN) {\n\t\tassert(p->u.alias);\n\t\tp = p->u.alias;\n\t\top = ADDRG;\n\t} else\n\t\top = ADDRL;\n\tp->ref += refinc;\n\tif (isarray(ty))\n\t\te = tree(mkop(op,voidptype), p->type,      NULL, NULL);\n\telse if (isfunc(ty))\n\t\te = tree(mkop(op,funcptype), p->type,      NULL, NULL);\n\telse\n\t\te = tree(mkop(op,voidptype), ptr(p->type), NULL, NULL);\n\te->u.sym = p;\n\tif (isptr(e->type))\n\t\te = rvalue(e);\n\treturn e;\n}\n\nTree rvalue(Tree p) {\n\tType ty = deref(p->type);\n\n\tty = unqual(ty);\n\treturn tree(mkop(INDIR,ty), ty, p, NULL);\n}\nTree lvalue(Tree p) {\n\tif (generic(p->op) != INDIR) {\n\t\terror(\"lvalue required\\n\");\n\t\treturn value(p);\n\t} else if (unqual(p->type) == voidtype)\n\t\twarning(\"`%t' used as an lvalue\\n\", p->type);\n\treturn p->kids[0];\n}\nTree retype(Tree p, Type ty) {\n\tTree q;\n\n\tif (p->type == ty)\n\t\treturn p;\n\tq = tree(p->op, ty, p->kids[0], p->kids[1]);\n\tq->node = p->node;\n\tq->u = p->u;\n\treturn q;\n}\nTree rightkid(Tree p) {\n\twhile (p && p->op == RIGHT)\n\t\tif (p->kids[1])\n\t\t\tp = p->kids[1];\n\t\telse if (p->kids[0])\n\t\t\tp = p->kids[0];\n\t\telse\n\t\t\tassert(0);\n\tassert(p);\n\treturn p;\n}\nint hascall(Tree p) {\n\tif (p == 0)\n\t\treturn 0;\n\tif (generic(p->op) == CALL || (IR->mulops_calls &&\n\t  (p->op == DIV+I || p->op == MOD+I || p->op == MUL+I\n\t|| p->op == DIV+U || p->op == MOD+U || p->op == MUL+U)))\n\t\treturn 1;\n\treturn hascall(p->kids[0]) || hascall(p->kids[1]);\n}\nType binary(Type xty, Type yty) {\n#define xx(t) if (xty == t || yty == t) return t\n\txx(longdouble);\n\txx(doubletype);\n\txx(floattype);\n\txx(unsignedlonglong);\n\txx(longlong);\n\txx(unsignedlong);\n\tif (xty == longtype     && yty == unsignedtype\n\t||  xty == unsignedtype && yty == longtype)\n\t\tif (longtype->size > unsignedtype->size)\n\t\t\treturn longtype;\n\t\telse\n\t\t\treturn unsignedlong;\n\txx(longtype);\n\txx(unsignedtype);\n\treturn inttype;\n#undef xx\n}\nTree pointer(Tree p) {\n\tif (isarray(p->type))\n\t\t/* assert(p->op != RIGHT || p->u.sym == NULL), */\n\t\tp = retype(p, atop(p->type));\n\telse if (isfunc(p->type))\n\t\tp = retype(p, ptr(p->type));\n\treturn p;\n}\nTree cond(Tree p) {\n\tint op = generic(rightkid(p)->op);\n\n\tif (op == AND || op == OR || op == NOT\n\t||  op == EQ  || op == NE\n\t||  op == LE  || op == LT || op == GE || op == GT)\n\t\treturn p;\n\tp = pointer(p);\n\treturn (*optree[NEQ])(NE, p, consttree(0, inttype));\n}\nTree cast(Tree p, Type type) {\n\tType src, dst;\n\n\tp = value(p);\n\tif (p->type == type)\n\t\treturn p;\n\tdst = unqual(type);\n\tsrc = unqual(p->type);\n\tif (src->op != dst->op || src->size != dst->size) {\n\t\tswitch (src->op) {\n\t\tcase INT:\n\t\t\tif (src->size < inttype->size)\n\t\t\t\tp = simplify(CVI, inttype, p, NULL);\n\t\t\tbreak;\n\t\tcase UNSIGNED:\n\t\t\tif (src->size < inttype->size)\n\t\t\t\tp = simplify(CVU, inttype, p, NULL);\n\t\t\telse if (src->size < unsignedtype->size)\n\t\t\t\tp = simplify(CVU, unsignedtype, p, NULL);\n\t\t\tbreak;\n\t\tcase ENUM:\n\t\t\tp = retype(p, inttype);\n\t\t\tbreak;\n\t\tcase POINTER:\n\t\t\tif (isint(dst) && src->size > dst->size)\n\t\t\t\twarning(\"conversion from `%t' to `%t' is undefined\\n\", p->type, type);\n\t\t\tp = simplify(CVP, super(src), p, NULL);\n\t\t\tbreak;\n\t\tcase FLOAT:\n\t\t\tbreak;\n\t\tdefault: assert(0);\n\t\t}\n\t\t{\n\t\t\tsrc = unqual(p->type);\n\t\t\tdst = super(dst);\n\t\t\tif (src->op != dst->op)\n\t\t\t\tswitch (src->op) {\n\t\t\t\tcase INT:\n\t\t\t\t\tp = simplify(CVI, dst, p, NULL);\n\t\t\t\t\tbreak;\n\t\t\t\tcase UNSIGNED:\n\t\t\t\t\tif (isfloat(dst)) {\n\t\t\t\t\t\tType ssrc = signedint(src);\n\t\t\t\t\t\tTree two = cnsttree(longdouble, (long double)2.0);\n\t\t\t\t\t\tp = (*optree['+'])(ADD,\n\t\t\t\t\t\t\t(*optree['*'])(MUL,\n\t\t\t\t\t\t\t\ttwo,\n\t\t\t\t\t\t\t\tsimplify(CVU, ssrc,\n\t\t\t\t\t\t\t\t\tsimplify(RSH, src,\n\t\t\t\t\t\t\t\t\t\tp, consttree(1, inttype)), NULL)),\n\t\t\t\t\t\t\tsimplify(CVU, ssrc,\n\t\t\t\t\t\t\t\tsimplify(BAND, src,\n\t\t\t\t\t\t\t\t\tp, consttree(1, unsignedtype)), NULL));\n\t\t\t\t\t} else\n\t\t\t\t\t\tp = simplify(CVU, dst, p, NULL);\n\t\t\t\t\tbreak;\n\t\t\t\tcase FLOAT:\n\t\t\t\t\tif (isunsigned(dst)) {\n\t\t\t\t\t\tType sdst = signedint(dst);\n\t\t\t\t\t\tTree c = cast(cnsttree(longdouble, (long double)sdst->u.sym->u.limits.max.i + 1), src);\n\t\t\t\t\t\tp = condtree(\n\t\t\t\t\t\t\tsimplify(GE, src, p, c),\n\t\t\t\t\t\t\t(*optree['+'])(ADD,\n\t\t\t\t\t\t\t\tcast(cast(simplify(SUB, src, p, c), sdst), dst),\n\t\t\t\t\t\t\t\tcast(cnsttree(unsignedlong, (unsigned long)sdst->u.sym->u.limits.max.i + 1), dst)),\n\t\t\t\t\t\t\tsimplify(CVF, sdst, p, NULL));\n\t\t\t\t\t} else\n\t\t\t\t\t\tp = simplify(CVF, dst, p, NULL);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault: assert(0);\n\t\t\t\t}\n\t\t\tdst = unqual(type);\n\t\t}\n\t}\n\tsrc = unqual(p->type);\n\tswitch (src->op) {\n\tcase INT:\n\t\tif (src->op != dst->op || src->size != dst->size)\n\t\t\tp = simplify(CVI, dst, p, NULL);\n\t\tbreak;\n\tcase UNSIGNED:\n\t\tif (src->op != dst->op || src->size != dst->size)\n\t\t\tp = simplify(CVU, dst, p, NULL);\n\t\tbreak;\n\tcase FLOAT:\n\t\tif (src->op != dst->op || src->size != dst->size)\n\t\t\tp = simplify(CVF, dst, p, NULL);\n\t\tbreak;\n\tcase POINTER:\n\t\tif (src->op != dst->op)\n\t\t\tp = simplify(CVP, dst, p, NULL);\n\t\telse {\n\t\t\tif (isfunc(src->type) && !isfunc(dst->type)\n\t\t\t|| !isfunc(src->type) &&  isfunc(dst->type))\n\t\t\t\twarning(\"conversion from `%t' to `%t' is compiler dependent\\n\", p->type, type);\n\n\t\t\tif (src->size != dst->size)\n\t\t\t\tp = simplify(CVP, dst, p, NULL);\n\t\t}\n\t\tbreak;\n\tdefault: assert(0);\n\t}\n\treturn retype(p, type);\n}\nTree field(Tree p, const char *name) {\n\tField q;\n\tType ty1, ty = p->type;\n\n\tif (isptr(ty))\n\t\tty = deref(ty);\n\tty1 = ty;\n\tty = unqual(ty);\n\tif ((q = fieldref(name, ty)) != NULL) {\n\t\tif (isarray(q->type)) {\n\t\t\tty = q->type->type;\n\t\t\tif (isconst(ty1) && !isconst(ty))\n\t\t\t\tty = qual(CONST, ty);\n\t\t\tif (isvolatile(ty1) && !isvolatile(ty))\n\t\t\t\tty = qual(VOLATILE, ty);\n\t\t\tty = array(ty, q->type->size/ty->size, q->type->align);\n\t\t} else {\n\t\t\tty = q->type;\n\t\t\tif (isconst(ty1) && !isconst(ty))\n\t\t\t\tty = qual(CONST, ty);\n\t\t\tif (isvolatile(ty1) && !isvolatile(ty))\n\t\t\t\tty = qual(VOLATILE, ty);\n\t\t\tty = ptr(ty);\n\t\t}\n\t\tif (YYcheck && !isaddrop(p->op) && q->offset > 0)\t/* omit */\n\t\t\tp = nullcall(ty, YYcheck, p, consttree(q->offset, inttype));\t/* omit */\n\t\telse\t\t\t\t\t/* omit */\n\t\tp = simplify(ADD+P, ty, p, consttree(q->offset, inttype));\n\n\t\tif (q->lsb) {\n\t\t\tp = tree(FIELD, ty->type, rvalue(p), NULL);\n\t\t\tp->u.field = q;\n\t\t} else if (!isarray(q->type))\n\t\t\tp = rvalue(p);\n\n\t} else {\n\t\terror(\"unknown field `%s' of `%t'\\n\", name, ty);\n\t\tp = rvalue(retype(p, ptr(inttype)));\n\t}\n\treturn p;\n}\n/* funcname - return name of function f or a function' */\nchar *funcname(Tree f) {\n\tif (isaddrop(f->op))\n\t\treturn stringf(\"`%s'\", f->u.sym->name);\n\treturn \"a function\";\n}\nstatic Tree nullcheck(Tree p) {\n\tif (!needconst && YYnull && isptr(p->type)) {\n\t\tp = value(p);\n\t\tif (strcmp(YYnull->name, \"_YYnull\") == 0) {\n\t\t\tSymbol t1 = temporary(REGISTER, voidptype);\n\t\t\tp = tree(RIGHT, p->type,\n\t\t\t\ttree(OR, voidtype,\n\t\t\t\t\tcond(asgn(t1, cast(p, voidptype))),\n\t\t\t\t\tvcall(YYnull, voidtype,\t(file && *file ? pointer(idtree(mkstr(file)->u.c.loc)) : cnsttree(voidptype, NULL)), cnsttree(inttype, (long)lineno)\t\t, NULL)),\n\t\t\t\tidtree(t1));\n\t\t}\n\n\t\telse\n\t\t\tp = nullcall(p->type, YYnull, p, cnsttree(inttype, 0L));\n\n\t}\n\treturn p;\n}\nTree nullcall(Type pty, Symbol f, Tree p, Tree e) {\n\tType ty;\n\n\tif (isarray(pty))\n\t\treturn retype(nullcall(atop(pty), f, p, e), pty);\n\tty = unqual(unqual(p->type)->type);\n\treturn vcall(f, pty,\n\t\tp, e,\n\t\tcnsttree(inttype, (long)ty->size),\n\t\tcnsttree(inttype, (long)ty->align),\n\t\t(file && *file ? pointer(idtree(mkstr(file)->u.c.loc)) : cnsttree(voidptype, NULL)), cnsttree(inttype, (long)lineno)\t\t, NULL);\n}\n"
  },
  {
    "path": "lcc/src/gen.c",
    "content": "#include \"c.h\"\n\n\n#define readsreg(p) \\\n\t(generic((p)->op)==INDIR && (p)->kids[0]->op==VREG+P)\n#define setsrc(d) ((d) && (d)->x.regnode && \\\n\t(d)->x.regnode->set == src->x.regnode->set && \\\n\t(d)->x.regnode->mask&src->x.regnode->mask)\n\n#define relink(a, b) ((b)->x.prev = (a), (a)->x.next = (b))\n\nstatic Symbol   askfixedreg(Symbol);\nstatic Symbol   askreg(Symbol, unsigned*);\nstatic void     blkunroll(int, int, int, int, int, int, int[]);\nstatic void     docall(Node);\nstatic void     dumpcover(Node, int, int);\nstatic void     dumpregs(char *, char *, char *);\nstatic void     dumprule(int);\nstatic void     dumptree(Node);\nstatic unsigned\temitasm(Node, int);\nstatic void     genreload(Node, Symbol, int);\nstatic void     genspill(Symbol, Node, Symbol);\nstatic Symbol   getreg(Symbol, unsigned*, Node);\nstatic int      getrule(Node, int);\nstatic void     linearize(Node, Node);\nstatic int      moveself(Node);\nstatic void     prelabel(Node);\nstatic Node*    prune(Node, Node*);\nstatic void     putreg(Symbol);\nstatic void     ralloc(Node);\nstatic void     reduce(Node, int);\nstatic int      reprune(Node*, int, int, Node);\nstatic int      requate(Node);\nstatic Node     reuse(Node, int);\nstatic void     rewrite(Node);\nstatic Symbol   spillee(Symbol, unsigned mask[], Node);\nstatic void     spillr(Symbol, Node);\nstatic int      uses(Node, Regnode);\n\nint offset;\n\nint maxoffset;\n\nint framesize;\nint argoffset;\n\nint maxargoffset;\n\nint dalign, salign;\nint bflag = 0;  /* omit */\nint dflag = 0;\n\nint swap;\n\nunsigned (*emitter)(Node, int) = emitasm;\nstatic char NeedsReg[] = {\n\t0,                      /* unused */\n\t1,                      /* CNST */\n\t0, 0,                   /* ARG ASGN */\n\t1,                      /* INDIR  */\n\t0, 0, 1, 1,             /*  -  - CVF CVI */\n\t1, 0, 1, 1,             /* CVP - CVU NEG */\n\t1,                      /* CALL */\n\t1,                      /* LOAD */\n\t0,                      /* RET */\n\t1, 1, 1,                /* ADDRG ADDRF ADDRL */\n\t1, 1, 1, 1, 1,          /* ADD SUB LSH MOD RSH */\n\t1, 1, 1, 1,             /* BAND BCOM BOR BXOR */\n\t1, 1,                   /* DIV MUL */\n\t0, 0, 0, 0, 0, 0,       /* EQ GE GT LE LT NE */\n\t0, 0                   /* JUMP LABEL   */\n};\nNode head;\n\nunsigned freemask[2];\nunsigned usedmask[2];\nunsigned tmask[2];\nunsigned vmask[2];\nSymbol mkreg(char *fmt, int n, int mask, int set) {\n\tSymbol p;\n\n\tNEW0(p, PERM);\n\tp->name = p->x.name = stringf(fmt, n);\n\tNEW0(p->x.regnode, PERM);\n\tp->x.regnode->number = n;\n\tp->x.regnode->mask = mask<<n;\n\tp->x.regnode->set = set;\n\treturn p;\n}\nSymbol mkwildcard(Symbol *syms) {\n\tSymbol p;\n\n\tNEW0(p, PERM);\n\tp->name = p->x.name = \"wildcard\";\n\tp->x.wildcard = syms;\n\treturn p;\n}\nvoid mkauto(Symbol p) {\n\tassert(p->sclass == AUTO);\n\toffset = roundup(offset + p->type->size, p->type->align);\n\tp->x.offset = -offset;\n\tp->x.name = stringd(-offset);\n}\nvoid blockbeg(Env *e) {\n\te->offset = offset;\n\te->freemask[IREG] = freemask[IREG];\n\te->freemask[FREG] = freemask[FREG];\n}\nvoid blockend(Env *e) {\n\tif (offset > maxoffset)\n\t\tmaxoffset = offset;\n\toffset = e->offset;\n\tfreemask[IREG] = e->freemask[IREG];\n\tfreemask[FREG] = e->freemask[FREG];\n}\nint mkactual(int align, int size) {\n\tint n = roundup(argoffset, align);\n\n\targoffset = n + size;\n\treturn n;\n}\nstatic void docall(Node p) {\n\tp->syms[1] = p->syms[0];\n\tp->syms[0] = intconst(argoffset);\n\tif (argoffset > maxargoffset)\n\t\tmaxargoffset = argoffset;\n\targoffset = 0;\n}\nvoid blkcopy(int dreg, int doff, int sreg, int soff, int size, int tmp[]) {\n\tassert(size >= 0);\n\tif (size == 0)\n\t\treturn;\n\telse if (size <= 2)\n\t\tblkunroll(size, dreg, doff, sreg, soff, size, tmp);\n\telse if (size == 3) {\n\t\tblkunroll(2, dreg, doff,   sreg, soff,   2, tmp);\n\t\tblkunroll(1, dreg, doff+2, sreg, soff+2, 1, tmp);\n\t}\n\telse if (size <= 16) {\n\t\tblkunroll(4, dreg, doff, sreg, soff, size&~3, tmp);\n\t\tblkcopy(dreg, doff+(size&~3),\n\t                sreg, soff+(size&~3), size&3, tmp);\n\t}\n\telse\n\t\t(*IR->x.blkloop)(dreg, doff, sreg, soff, size, tmp);\n}\nstatic void blkunroll(int k, int dreg, int doff, int sreg, int soff, int size, int tmp[]) {\n\tint i;\n\n\tassert(IR->x.max_unaligned_load);\n\tif (k > IR->x.max_unaligned_load\n\t&& (k > salign || k > dalign))\n\t\tk = IR->x.max_unaligned_load;\n\tfor (i = 0; i+k < size; i += 2*k) {\n\t\t(*IR->x.blkfetch)(k, soff+i,   sreg, tmp[0]);\n\t\t(*IR->x.blkfetch)(k, soff+i+k, sreg, tmp[1]);\n\t\t(*IR->x.blkstore)(k, doff+i,   dreg, tmp[0]);\n\t\t(*IR->x.blkstore)(k, doff+i+k, dreg, tmp[1]);\n\t}\n\tif (i < size) {\n\t\t(*IR->x.blkfetch)(k, i+soff, sreg, tmp[0]);\n\t\t(*IR->x.blkstore)(k, i+doff, dreg, tmp[0]);\n\t}\n}\nvoid parseflags(int argc, char *argv[]) {\n\tint i;\n\n\tfor (i = 0; i < argc; i++)\n\t\tif (strcmp(argv[i], \"-d\") == 0)\n\t\t\tdflag = 1;\n\t\telse if (strcmp(argv[i], \"-b\") == 0)\t/* omit */\n\t\t\tbflag = 1;\t\t\t/* omit */\n}\nstatic int getrule(Node p, int nt) {\n\tint rulenum;\n\n\tassert(p);\n\trulenum = (*IR->x._rule)(p->x.state, nt);\n\tif (!rulenum) {\n\t\tfprint(stderr, \"(%x->op=%s at %w is corrupt.)\\n\", p, opname(p->op), &src);\n\t\tassert(0);\n\t}\n\treturn rulenum;\n}\nstatic void reduce(Node p, int nt) {\n\tint rulenum, i;\n\tshort *nts;\n\tNode kids[10];\n\n\tp = reuse(p, nt);\n\trulenum = getrule(p, nt);\n\tnts = IR->x._nts[rulenum];\n\t(*IR->x._kids)(p, rulenum, kids);\n\tfor (i = 0; nts[i]; i++)\n\t\treduce(kids[i], nts[i]);\n\tif (IR->x._isinstruction[rulenum]) {\n\t\tassert(p->x.inst == 0 || p->x.inst == nt);\n\t\tp->x.inst = nt;\n\t\tif (p->syms[RX] && p->syms[RX]->temporary) {\n\t\t\tdebug(fprint(stderr, \"(using %s)\\n\", p->syms[RX]->name));\n\t\t\tp->syms[RX]->x.usecount++;\n\t\t}\n\t}\n}\nstatic Node reuse(Node p, int nt) {\n\tstruct _state {\n\t\tshort cost[1];\n\t};\n\tSymbol r = p->syms[RX];\n\n\tif (generic(p->op) == INDIR && p->kids[0]->op == VREG+P\n\t&& r->u.t.cse && p->x.mayrecalc\n\t&& ((struct _state*)r->u.t.cse->x.state)->cost[nt] == 0)\n\t\treturn r->u.t.cse;\n\telse\n\t\treturn p;\n}\n\nint mayrecalc(Node p) {\n\tint op;\n\n\tassert(p && p->syms[RX]);\n\tif (p->syms[RX]->u.t.cse == NULL)\n\t\treturn 0;\n\top = generic(p->syms[RX]->u.t.cse->op);\n\tif (op == CNST || op == ADDRF || op == ADDRG || op == ADDRL) {\n\t\tp->x.mayrecalc = 1;\n\t\treturn 1;\n\t} else\n\t\treturn 0;\n}\nstatic Node *prune(Node p, Node pp[]) {\n\tif (p == NULL)\n\t\treturn pp;\n\tp->x.kids[0] = p->x.kids[1] = p->x.kids[2] = NULL;\n\tif (p->x.inst == 0)\n\t\treturn prune(p->kids[1], prune(p->kids[0], pp));\n\telse if (p->syms[RX] && p->syms[RX]->temporary\n\t&& p->syms[RX]->x.usecount < 2) {\n\t\tp->x.inst = 0;\n\t\tdebug(fprint(stderr, \"(clobbering %s)\\n\", p->syms[RX]->name));\n\t\treturn prune(p->kids[1], prune(p->kids[0], pp));\n\t}\n\telse {\n\t\tprune(p->kids[1], prune(p->kids[0], &p->x.kids[0]));\n\t\t*pp = p;\n\t\treturn pp + 1;\n\t}\n}\n\n#define ck(i) return (i) ? 0 : LBURG_MAX\n\nint range(Node p, int lo, int hi) {\n\tSymbol s = p->syms[0];\n\n\tswitch (specific(p->op)) {\n\tcase ADDRF+P:\n\tcase ADDRL+P: ck(s->x.offset >= lo && s->x.offset <= hi);\n\tcase CNST+I:  ck(s->u.c.v.i  >= lo && s->u.c.v.i  <= hi);\n\tcase CNST+U:  ck(s->u.c.v.u  >= lo && s->u.c.v.u  <= hi);\n\tcase CNST+P:  ck(s->u.c.v.p  == 0  && lo <= 0 && hi >= 0);\n\t}\n\treturn LBURG_MAX;\n}\nstatic void dumptree(Node p) {\n\tif (p->op == VREG+P && p->syms[0]) {\n\t\tfprint(stderr, \"VREGP(%s)\", p->syms[0]->name);\n\t\treturn;\n\t} else if (generic(p->op) == LOAD) {\n\t\tfprint(stderr, \"LOAD(\");\n\t\tdumptree(p->kids[0]);\n\t\tfprint(stderr, \")\");\n\t\treturn;\n\t}\n\tfprint(stderr, \"%s(\", opname(p->op));\n\tswitch (generic(p->op)) {\n\tcase CNST: case LABEL:\n\tcase ADDRG: case ADDRF: case ADDRL:\n\t\tif (p->syms[0])\n\t\t\tfprint(stderr, \"%s\", p->syms[0]->name);\n\t\tbreak;\n\tcase RET:\n\t\tif (p->kids[0])\n\t\t\tdumptree(p->kids[0]);\n\t\tbreak;\n\tcase CVF: case CVI: case CVP: case CVU: case JUMP: \n\tcase ARG: case BCOM: case NEG: case INDIR:\n\t\tdumptree(p->kids[0]);\n\t\tbreak;\n\tcase CALL:\n\t\tif (optype(p->op) != B) {\n\t\t\tdumptree(p->kids[0]);\n\t\t\tbreak;\n\t\t}\n\t\t/* else fall thru */\n\tcase EQ: case NE: case GT: case GE: case LE: case LT:\n\tcase ASGN: case BOR: case BAND: case BXOR: case RSH: case LSH:\n\tcase ADD: case SUB:  case DIV: case MUL: case MOD:\n\t\tdumptree(p->kids[0]);\n\t\tfprint(stderr, \", \");\n\t\tdumptree(p->kids[1]);\n\t\tbreak;\n\tdefault: assert(0);\n\t}\n\tfprint(stderr, \")\");\n}\nstatic void dumpcover(Node p, int nt, int in) {\n\tint rulenum, i;\n\tshort *nts;\n\tNode kids[10];\n\n\tp = reuse(p, nt);\n\trulenum = getrule(p, nt);\n\tnts = IR->x._nts[rulenum];\n\tfprint(stderr, \"dumpcover(%x) = \", p);\n\tfor (i = 0; i < in; i++)\n\t\tfprint(stderr, \" \");\n\tdumprule(rulenum);\n\t(*IR->x._kids)(p, rulenum, kids);\n\tfor (i = 0; nts[i]; i++)\n\t\tdumpcover(kids[i], nts[i], in+1);\n}\n\nstatic void dumprule(int rulenum) {\n\tassert(rulenum);\n\tfprint(stderr, \"%s / %s\", IR->x._string[rulenum],\n\t\tIR->x._templates[rulenum]);\n\tif (!IR->x._isinstruction[rulenum])\n\t\tfprint(stderr, \"\\n\");\n}\nstatic unsigned emitasm(Node p, int nt) {\n\tint rulenum;\n\tshort *nts;\n\tchar *fmt;\n\tNode kids[10];\n\n\tp = reuse(p, nt);\n\trulenum = getrule(p, nt);\n\tnts = IR->x._nts[rulenum];\n\tfmt = IR->x._templates[rulenum];\n\tassert(fmt);\n\tif (IR->x._isinstruction[rulenum] && p->x.emitted)\n\t\tprint(\"%s\", p->syms[RX]->x.name);\n\telse if (*fmt == '#')\n\t\t(*IR->x.emit2)(p);\n\telse {\n\t\tif (*fmt == '?') {\n\t\t\tfmt++;\n\t\t\tassert(p->kids[0]);\n\t\t\tif (p->syms[RX] == p->x.kids[0]->syms[RX])\n\t\t\t\twhile (*fmt++ != '\\n')\n\t\t\t\t\t;\n\t\t}\n\t\tfor ((*IR->x._kids)(p, rulenum, kids); *fmt; fmt++)\n\t\t\tif (*fmt != '%')\n\t\t\t\t(void)putchar(*fmt);\n\t\t\telse if (*++fmt == 'F')\n\t\t\t\tprint(\"%d\", framesize);\n\t\t\telse if (*fmt >= '0' && *fmt <= '9')\n\t\t\t\temitasm(kids[*fmt - '0'], nts[*fmt - '0']);\n\t\t\telse if (*fmt >= 'a' && *fmt < 'a' + NELEMS(p->syms))\n\t\t\t\tfputs(p->syms[*fmt - 'a']->x.name, stdout);\n\t\t\telse\n\t\t\t\t(void)putchar(*fmt);\n\t}\n\treturn 0;\n}\nvoid emit(Node p) {\n\tfor (; p; p = p->x.next) {\n\t\tassert(p->x.registered);\n\t\tif (p->x.equatable && requate(p) || moveself(p))\n\t\t\t;\n\t\telse\n\t\t\t(*emitter)(p, p->x.inst);\n\t\tp->x.emitted = 1;\n\t}\n}\nstatic int moveself(Node p) {\n\treturn p->x.copy\n\t&& p->syms[RX]->x.name == p->x.kids[0]->syms[RX]->x.name;\n}\nint move(Node p) {\n\tp->x.copy = 1;\n\treturn 1;\n}\nstatic int requate(Node q) {\n\tSymbol src = q->x.kids[0]->syms[RX];\n\tSymbol tmp = q->syms[RX];\n\tNode p;\n\tint n = 0;\n\n\tdebug(fprint(stderr, \"(requate(%x): tmp=%s src=%s)\\n\", q, tmp->x.name, src->x.name));\n\tfor (p = q->x.next; p; p = p->x.next)\n\t\tif (p->x.copy && p->syms[RX] == src\n\t\t&&  p->x.kids[0]->syms[RX] == tmp)\n\t\t\tdebug(fprint(stderr, \"(requate arm 0 at %x)\\n\", p)),\n\t\t\tp->syms[RX] = tmp;\n\t\telse if (setsrc(p->syms[RX]) && !moveself(p) && !readsreg(p))\n\t\t\treturn 0;\n\t\telse if (p->x.spills)\n\t\t\treturn 0;\n\t\telse if (generic(p->op) == CALL && p->x.next)\n\t\t\treturn 0;\n\t\telse if (p->op == LABEL+V && p->x.next)\n\t\t\treturn 0;\n\t\telse if (p->syms[RX] == tmp && readsreg(p))\n\t\t\tdebug(fprint(stderr, \"(requate arm 5 at %x)\\n\", p)),\n\t\t\tn++;\n\t\telse if (p->syms[RX] == tmp)\n\t\t\tbreak;\n\tdebug(fprint(stderr, \"(requate arm 7 at %x)\\n\", p));\n\tassert(n > 0);\n\tfor (p = q->x.next; p; p = p->x.next)\n\t\tif (p->syms[RX] == tmp && readsreg(p)) {\n\t\t\tp->syms[RX] = src;\n\t\t\tif (--n <= 0)\n\t\t\t\tbreak;\n\t\t}\n\treturn 1;\n}\nstatic void prelabel(Node p) {\n\tif (p == NULL)\n\t\treturn;\n\tprelabel(p->kids[0]);\n\tprelabel(p->kids[1]);\n\tif (NeedsReg[opindex(p->op)])\n\t\tsetreg(p, (*IR->x.rmap)(opkind(p->op)));\n\tswitch (generic(p->op)) {\n\tcase ADDRF: case ADDRL:\n\t\tif (p->syms[0]->sclass == REGISTER)\n\t\t\tp->op = VREG+P;\n\t\tbreak;\n\tcase INDIR:\n\t\tif (p->kids[0]->op == VREG+P)\n\t\t\tsetreg(p, p->kids[0]->syms[0]);\n\t\tbreak;\n\tcase ASGN:\n\t\tif (p->kids[0]->op == VREG+P)\n\t\t\trtarget(p, 1, p->kids[0]->syms[0]);\n\t\tbreak;\n\tcase CVI: case CVU: case CVP:\n\t\tif (optype(p->op) != F\n\t\t&&  opsize(p->op) <= p->syms[0]->u.c.v.i)\n\t\t\tp->op = LOAD + opkind(p->op);\n\t\tbreak;\n\t}\n\t(IR->x.target)(p);\n}\nvoid setreg(Node p, Symbol r) {\n\tp->syms[RX] = r;\n}\nvoid rtarget(Node p, int n, Symbol r) {\n\tNode q = p->kids[n];\n\n\tassert(q);\n\tassert(r);\n\tassert(r->sclass == REGISTER || !r->x.wildcard);\n\tassert(q->syms[RX]);\n\tif (r != q->syms[RX] && !q->syms[RX]->x.wildcard) {\n\t\tq = newnode(LOAD + opkind(q->op),\n\t\t\tq, NULL, q->syms[0]);\n\t\tif (r->u.t.cse == p->kids[n])\n\t\t\tr->u.t.cse = q;\n\t\tp->kids[n] = p->x.kids[n] = q;\n\t\tq->x.kids[0] = q->kids[0];\n\t}\n\tsetreg(q, r);\n\tdebug(fprint(stderr, \"(targeting %x->x.kids[%d]=%x to %s)\\n\", p, n, p->kids[n], r->x.name));\n}\nstatic void rewrite(Node p) {\n\tassert(p->x.inst == 0);\n\tprelabel(p);\n\tdebug(dumptree(p));\n\tdebug(fprint(stderr, \"\\n\"));\n\t(*IR->x._label)(p);\n\tdebug(dumpcover(p, 1, 0));\n\treduce(p, 1);\n}\nNode gen(Node forest) {\n\tint i;\n\tstruct node sentinel;\n\tNode dummy, p;\n\n\thead = forest;\n\tfor (p = forest; p; p = p->link) {\n\t\tassert(p->count == 0);\n\t\tif (generic(p->op) == CALL)\n\t\t\tdocall(p);\n\t\telse if (   generic(p->op) == ASGN\n\t\t&& generic(p->kids[1]->op) == CALL)\n\t\t\tdocall(p->kids[1]);\n\t\telse if (generic(p->op) == ARG)\n\t\t\t(*IR->x.doarg)(p);\n\t\trewrite(p);\n\t\tp->x.listed = 1;\n\t}\n\tfor (p = forest; p; p = p->link)\n\t\tprune(p, &dummy);\n\trelink(&sentinel, &sentinel);\n\tfor (p = forest; p; p = p->link)\n\t\tlinearize(p, &sentinel);\n\tforest = sentinel.x.next;\n\tassert(forest);\n\tsentinel.x.next->x.prev = NULL;\n\tsentinel.x.prev->x.next = NULL;\n\tfor (p = forest; p; p = p->x.next)\n\t\tfor (i = 0; i < NELEMS(p->x.kids) && p->x.kids[i]; i++) {\n\t\t\tassert(p->x.kids[i]->syms[RX]);\n\t\t\tif (p->x.kids[i]->syms[RX]->temporary) {\n\t\t\t\tp->x.kids[i]->x.prevuse =\n\t\t\t\t\tp->x.kids[i]->syms[RX]->x.lastuse;\n\t\t\t\tp->x.kids[i]->syms[RX]->x.lastuse = p->x.kids[i];\n\t\t\t}\n\t\t}\n\tfor (p = forest; p; p = p->x.next) {\n\t\tralloc(p);\n\t\tif (p->x.listed && NeedsReg[opindex(p->op)]\n\t\t&& (*IR->x.rmap)(opkind(p->op))) {\n\t\t\tassert(generic(p->op) == CALL || generic(p->op) == LOAD);\n\t\t\tputreg(p->syms[RX]);\n\t\t}\n\t}\n\treturn forest;\n}\nint notarget(Node p) {\n\treturn p->syms[RX]->x.wildcard ? 0 : LBURG_MAX;\n}\nstatic void putreg(Symbol r) {\n\tassert(r && r->x.regnode);\n\tfreemask[r->x.regnode->set] |= r->x.regnode->mask;\n\tdebug(dumpregs(\"(freeing %s)\\n\", r->x.name, NULL));\n}\nstatic Symbol askfixedreg(Symbol s) {\n\tRegnode r = s->x.regnode;\n\tint n = r->set;\n\n\tif (r->mask&~freemask[n])\n\t\treturn NULL;\n\telse {\n\t\tfreemask[n] &= ~r->mask;\n\t\tusedmask[n] |=  r->mask;\n\t\treturn s;\n\t}\n}\nstatic Symbol askreg(Symbol rs, unsigned rmask[]) {\n\tint i;\n\n\tif (rs->x.wildcard == NULL)\n\t\treturn askfixedreg(rs);\n\tfor (i = 31; i >= 0; i--) {\n\t\tSymbol r = rs->x.wildcard[i];\n\t\tif (r != NULL\n\t\t&& !(r->x.regnode->mask&~rmask[r->x.regnode->set])\n\t\t&& askfixedreg(r))\n\t\t\treturn r;\n\t}\n\treturn NULL;\n}\n\nstatic Symbol getreg(Symbol s, unsigned mask[], Node p) {\n\tSymbol r = askreg(s, mask);\n\tif (r == NULL) {\n\t\tr = spillee(s, mask, p);\n\t\tassert(r && r->x.regnode);\n\t\tspill(r->x.regnode->mask, r->x.regnode->set, p);\n\t\tr = askreg(s, mask);\n\t}\n\tassert(r && r->x.regnode);\n\tr->x.regnode->vbl = NULL;\n\treturn r;\n}\nint askregvar(Symbol p, Symbol regs) {\n\tSymbol r;\n\n\tassert(p);\n\tif (p->sclass != REGISTER)\n\t\treturn 0;\n\telse if (!isscalar(p->type)) {\n\t\tp->sclass = AUTO;\n\t\treturn 0;\n\t}\n\telse if (p->temporary) {\n\t\tp->x.name = \"?\";\n\t\treturn 1;\n\t}\n\telse if ((r = askreg(regs, vmask)) != NULL) {\n\t\tp->x.regnode = r->x.regnode;\n\t\tp->x.regnode->vbl = p;\n\t\tp->x.name = r->x.name;\n\t\tdebug(dumpregs(\"(allocating %s to symbol %s)\\n\", p->x.name, p->name));\n\t\treturn 1;\n\t}\n\telse {\n\t\tp->sclass = AUTO;\n\t\treturn 0;\n\t}\n}\nstatic void linearize(Node p, Node next) {\n\tint i;\n\n\tfor (i = 0; i < NELEMS(p->x.kids) && p->x.kids[i]; i++)\n\t\tlinearize(p->x.kids[i], next);\n\trelink(next->x.prev, p);\n\trelink(p, next);\n\tdebug(fprint(stderr, \"(listing %x)\\n\", p));\n}\nstatic void ralloc(Node p) {\n\tint i;\n\tunsigned mask[2];\n\n\tmask[0] = tmask[0];\n\tmask[1] = tmask[1];\n\tassert(p);\n\tdebug(fprint(stderr, \"(rallocing %x)\\n\", p));\n\tfor (i = 0; i < NELEMS(p->x.kids) && p->x.kids[i]; i++) {\n\t\tNode kid = p->x.kids[i];\n\t\tSymbol r = kid->syms[RX];\n\t\tassert(r && kid->x.registered);\n\t\tif (r->sclass != REGISTER && r->x.lastuse == kid)\n\t\t\tputreg(r);\n\t}\n\tif (!p->x.registered && NeedsReg[opindex(p->op)]\n\t&& (*IR->x.rmap)(opkind(p->op))) {\n\t\tSymbol sym = p->syms[RX], set = sym;\n\t\tassert(sym);\n\t\tif (sym->temporary)\n\t\t\tset = (*IR->x.rmap)(opkind(p->op));\n\t\tassert(set);\n\t\tif (set->sclass != REGISTER) {\n\t\t\tSymbol r;\n\t\t\tif (*IR->x._templates[getrule(p, p->x.inst)] == '?')\n\t\t\t\tfor (i = 1; i < NELEMS(p->x.kids) && p->x.kids[i]; i++) {\n\t\t\t\t\tSymbol r = p->x.kids[i]->syms[RX];\n\t\t\t\t\tassert(p->x.kids[i]->x.registered);\n\t\t\t\t\tassert(r && r->x.regnode);\n\t\t\t\t\tassert(sym->x.wildcard || sym != r);\n\t\t\t\t\tmask[r->x.regnode->set] &= ~r->x.regnode->mask;\n\t\t\t\t}\n\t\t\tr = getreg(set, mask, p);\n\t\t\tif (sym->temporary) {\n\t\t\t\tNode q;\n\t\t\t\tr->x.lastuse = sym->x.lastuse;\n\t\t\t\tfor (q = sym->x.lastuse; q; q = q->x.prevuse) {\n\t\t\t\t\tq->syms[RX] = r;\n\t\t\t\t\tq->x.registered = 1;\n\t\t\t\t\tif (sym->u.t.cse && q->x.copy)\n\t\t\t\t\t\tq->x.equatable = 1;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tp->syms[RX] = r;\n\t\t\t\tr->x.lastuse = p;\n\t\t\t}\n\t\t\tdebug(dumpregs(\"(allocating %s to node %x)\\n\", r->x.name, (char *) p));\n\t\t}\n\t}\n\tp->x.registered = 1;\n\t(*IR->x.clobber)(p);\n}\nstatic Symbol spillee(Symbol set, unsigned mask[], Node here) {\n\tSymbol bestreg = NULL;\n\tint bestdist = -1, i;\n\n\tassert(set);\n\tif (!set->x.wildcard)\n\t\tbestreg = set;\n\telse {\n\t\tfor (i = 31; i >= 0; i--) {\n\t\t\tSymbol ri = set->x.wildcard[i];\n\t\t\tif (\n\t\t\t\tri != NULL &&\n\t\t\t\tri->x.lastuse &&\n\t\t\t\t(ri->x.regnode->mask&tmask[ri->x.regnode->set]&mask[ri->x.regnode->set])\n\t\t\t) {\n\t\t\t\tRegnode rn = ri->x.regnode;\n\t\t\t\tNode q = here;\n\t\t\t\tint dist = 0;\n\t\t\t\tfor (; q && !uses(q, rn); q = q->x.next)\n\t\t\t\t\tdist++;\n\t\t\t\tif (q && dist > bestdist) {\n\t\t\t\t\tbestdist = dist;\n\t\t\t\t\tbestreg = ri;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tassert(bestreg); /* Must be able to spill something. Reconfigure the register allocator\n\t\tto ensure that we can allocate a register for all nodes without spilling\n\t\tthe node's necessary input regs. */\t\n\tassert(bestreg->x.regnode->vbl == NULL); /* Can't spill register variables because\n\t\tthe reload site might be in other blocks. Reconfigure the register allocator\n\t\tto ensure that this register is never allocated to a variable. */\n\treturn bestreg;\n}\nstatic int uses(Node p, Regnode rn) {\n\tint i;\n\n\tfor (i = 0; i < NELEMS(p->x.kids); i++)\n\t\tif (\n\t\t\tp->x.kids[i] &&\n\t\t\tp->x.kids[i]->x.registered &&\n\t\t\trn->set == p->x.kids[i]->syms[RX]->x.regnode->set &&\n\t\t\t(rn->mask&p->x.kids[i]->syms[RX]->x.regnode->mask)\n\t\t)\n\t\t\treturn 1;\n\treturn 0;\n}\nstatic void spillr(Symbol r, Node here) {\n\tint i;\n\tSymbol tmp;\n\tNode p = r->x.lastuse;\n\tassert(p);\n\twhile (p->x.prevuse)\n\t\tassert(r == p->syms[RX]),\n\t\tp = p->x.prevuse;\n\tassert(p->x.registered && !readsreg(p));\n\ttmp = newtemp(AUTO, optype(p->op), opsize(p->op));\n\tgenspill(r, p, tmp);\n\tfor (p = here->x.next; p; p = p->x.next)\n\t\tfor (i = 0; i < NELEMS(p->x.kids) && p->x.kids[i]; i++) {\n\t\t\tNode k = p->x.kids[i];\n\t\t\tif (k->x.registered && k->syms[RX] == r)\n\t\t\t\tgenreload(p, tmp, i);\n\t\t}\n\tputreg(r);\n}\nstatic void genspill(Symbol r, Node last, Symbol tmp) {\n\tNode p, q;\n\tSymbol s;\n\tunsigned ty;\n\n\tdebug(fprint(stderr, \"(spilling %s to local %s)\\n\", r->x.name, tmp->x.name));\n\tdebug(fprint(stderr, \"(genspill: \"));\n\tdebug(dumptree(last));\n\tdebug(fprint(stderr, \")\\n\"));\n\tty = opkind(last->op);\n\tNEW0(s, FUNC);\n\ts->sclass = REGISTER;\n\ts->name = s->x.name = r->x.name;\n\ts->x.regnode = r->x.regnode;\n\tq = newnode(ADDRL+P + sizeop(IR->ptrmetric.size), NULL, NULL, s);\n\tq = newnode(INDIR + ty, q, NULL, NULL);\n\tp = newnode(ADDRL+P + sizeop(IR->ptrmetric.size), NULL, NULL, tmp);\n\tp = newnode(ASGN + ty, p, q, NULL);\n\tp->x.spills = 1;\n\trewrite(p);\n\tprune(p, &q);\n\tq = last->x.next;\n\tlinearize(p, q);\n\tfor (p = last->x.next; p != q; p = p->x.next) {\n\t\tralloc(p);\n\t\tassert(!p->x.listed || !NeedsReg[opindex(p->op)] || !(*IR->x.rmap)(opkind(p->op)));\n\t}\n}\n\nstatic void genreload(Node p, Symbol tmp, int i) {\n\tNode q;\n\tint ty;\n\n\tdebug(fprint(stderr, \"(replacing %x with a reload from %s)\\n\", p->x.kids[i], tmp->x.name));\n\tdebug(fprint(stderr, \"(genreload: \"));\n\tdebug(dumptree(p->x.kids[i]));\n\tdebug(fprint(stderr, \")\\n\"));\n\tty = opkind(p->x.kids[i]->op);\n\tq = newnode(ADDRL+P + sizeop(IR->ptrmetric.size), NULL, NULL, tmp);\n\tp->x.kids[i] = newnode(INDIR + ty, q, NULL, NULL);\n\trewrite(p->x.kids[i]);\n\tprune(p->x.kids[i], &q);\n\treprune(&p->kids[1], reprune(&p->kids[0], 0, i, p), i, p);\n\tprune(p, &q);\n\tlinearize(p->x.kids[i], p);\n}\nstatic int reprune(Node *pp, int k, int n, Node p) {\n\tstruct node x, *q = *pp;\n\n\tif (q == NULL || k > n)\n\t\treturn k;\n\telse if (q->x.inst == 0)\n\t\treturn reprune(&q->kids[1],\n\t\t\treprune(&q->kids[0], k, n, p), n, p);\n\tif (k == n) {\n\t\tdebug(fprint(stderr, \"(reprune changes %x from %x to %x)\\n\", pp, *pp, p->x.kids[n]));\n\t\t*pp = p->x.kids[n];\n\t\tx = *p;\n\t\t(IR->x.target)(&x);\n\t}\n\treturn k + 1;\n}\nvoid spill(unsigned mask, int n, Node here) {\n\tint i;\n\tNode p;\n\n\there->x.spills = 1;\n\tusedmask[n] |= mask;\n\tif (mask&~freemask[n]) {\n\n\t\tassert( /* It makes no sense for a node to clobber() its target. */\n\t\t\there->x.registered == 0 || /* call isn't coming through clobber() */\n\t\t\there->syms[RX] == NULL ||\n\t\t\there->syms[RX]->x.regnode == NULL ||\n\t\t\there->syms[RX]->x.regnode->set != n ||\n\t\t\t(here->syms[RX]->x.regnode->mask&mask) == 0\n\t\t);\n\n\t\tfor (p = here; p; p = p->x.next)\n\t\t\tfor (i = 0; i < NELEMS(p->x.kids) && p->x.kids[i]; i++) {\n\t\t\t\tSymbol r = p->x.kids[i]->syms[RX];\n\t\t\t\tassert(r);\n\t\t\t\tif (p->x.kids[i]->x.registered && r->x.regnode->set == n\n\t\t\t\t&& r->x.regnode->mask&mask)\n\t\t\t\t\tspillr(r, here);\n\t\t\t}\n\t}\n}\nstatic void dumpregs(char *msg, char *a, char *b) {\n\tfprint(stderr, msg, a, b);\n\tfprint(stderr, \"(free[0]=%x)\\n\", freemask[0]);\n\tfprint(stderr, \"(free[1]=%x)\\n\", freemask[1]);\n}\n\nint getregnum(Node p) {\n\tassert(p && p->syms[RX] && p->syms[RX]->x.regnode);\n\treturn p->syms[RX]->x.regnode->number;\n}\n\n\nunsigned regloc(Symbol p) {\n\tassert(p && p->sclass == REGISTER && p->sclass == REGISTER && p->x.regnode);\n\treturn p->x.regnode->set<<8 | p->x.regnode->number;\n}\n\n"
  },
  {
    "path": "lcc/src/init.c",
    "content": "#include \"c.h\"\n\n\nstatic int curseg;\t\t/* current segment */\n\n/* defpointer - initialize a pointer to p or to 0 if p==0 */\nvoid defpointer(Symbol p) {\n\tif (p) {\n\t\t(*IR->defaddress)(p);\n\t\tp->ref++;\n\t} else {\n\t\tstatic Value v;\n\t\t(*IR->defconst)(P, voidptype->size, v);\n\t}\n}\n\n/* genconst - generate/check constant expression e; return size */\nstatic int genconst(Tree e, int def) {\n\tfor (;;)\n\t\tswitch (generic(e->op)) {\n\t\tcase ADDRG:\n\t\t\tif (def)\n\t\t\t\t(*IR->defaddress)(e->u.sym);\n\t\t\treturn e->type->size;\n\t\tcase CNST:\n\t\t\tif (e->op == CNST+P && isarray(e->type)) {\n\t\t\t\te = cvtconst(e);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (def)\n\t\t\t\t(*IR->defconst)(e->type->op, e->type->size, e->u.v);\n\t\t\treturn e->type->size;\n\t\tcase RIGHT:\n\t\t\tassert(e->kids[0] || e->kids[1]);\n\t\t\tif (e->kids[1] && e->kids[0])\n\t\t\t\terror(\"initializer must be constant\\n\");\n\t\t\te = e->kids[1] ? e->kids[1] : e->kids[0];\n\t\t\tcontinue;\n\t\tcase CVP:\n\t\t\tif (isarith(e->type))\n\t\t\t\terror(\"cast from `%t' to `%t' is illegal in constant expressions\\n\",\n\t\t\t\t\te->kids[0]->type, e->type);\n\t\t\t/* fall thru */\n\t\tcase CVI: case CVU: case CVF:\n\t\t\te = e->kids[0];\n\t\t\tcontinue;\n\t\tdefault:\n\t\t\terror(\"initializer must be constant\\n\");\n\t\t\tif (def)\n\t\t\t\tgenconst(consttree(0, inttype), def);\n\t\t\treturn inttype->size;\n\t\t}\n}\n\n/* initvalue - evaluate a constant expression for a value of integer type ty */\nstatic Tree initvalue(Type ty) {\n\tType aty;\n\tTree e;\n\n\tneedconst++;\n\te = expr1(0);\n\tif ((aty = assign(ty, e)) != NULL)\n\t\te = cast(e, aty);\n\telse {\n\t\terror(\"invalid initialization type; found `%t' expected `%t'\\n\",\n\t\t\te->type,  ty);\n\t\te = retype(consttree(0, inttype), ty);\n\t}\n\tneedconst--;\n\tif (generic(e->op) != CNST) {\n\t\terror(\"initializer must be constant\\n\");\n\t\te = retype(consttree(0, inttype), ty);\n\t}\n\treturn e;\n}\n\n/* initarray - initialize array of ty of <= len bytes; if len == 0, go to } */\nstatic int initarray(int len, Type ty, int lev) {\n\tint n = 0;\n\n\tdo {\n\t\tinitializer(ty, lev);\n\t\tn += ty->size;\n\t\tif (len > 0 && n >= len || t != ',')\n\t\t\tbreak;\n\t\tt = gettok();\n\t} while (t != '}');\n\treturn n;\n}\n\n/* initchar - initialize array of <= len ty characters; if len == 0, go to } */\nstatic int initchar(int len, Type ty) {\n\tint n = 0;\n\tchar buf[16], *s = buf;\n\n\tdo {\n\t\t*s++ = initvalue(ty)->u.v.i;\n\t\tif (++n%inttype->size == 0) {\n\t\t\t(*IR->defstring)(inttype->size, buf);\n\t\t\ts = buf;\n\t\t}\n\t\tif (len > 0 && n >= len || t != ',')\n\t\t\tbreak;\n\t\tt = gettok();\n\t} while (t != '}');\n\tif (s > buf)\n\t\t(*IR->defstring)(s - buf, buf);\n\treturn n;\n}\n\n/* initend - finish off an initialization at level lev; accepts trailing comma */\nstatic void initend(int lev, char follow[]) {\n\tif (lev == 0 && t == ',')\n\t\tt = gettok();\n\ttest('}', follow);\n}\n\n/* initfields - initialize <= an unsigned's worth of bit fields in fields p to q */\nstatic int initfields(Field p, Field q) {\n\tunsigned int bits = 0;\n\tint i, n = 0;\n\n\tdo {\n\t\ti = initvalue(inttype)->u.v.i;\n\t\tif (fieldsize(p) < 8*p->type->size) {\n\t\t\tif (p->type == inttype &&\n\t\t\t   (i < -(int)(fieldmask(p)>>1)-1 || i > (int)(fieldmask(p)>>1))\n\t\t\t||  p->type == unsignedtype && (i&~fieldmask(p)) !=  0)\n\t\t\t\twarning(\"initializer exceeds bit-field width\\n\");\n\t\t\ti &= fieldmask(p);\n\t\t}\n\t\tbits |= i<<fieldright(p);\n\t\tif (IR->little_endian) {\n\t\t\tif (fieldsize(p) + fieldright(p) > n)\n\t\t\t\tn = fieldsize(p) + fieldright(p);\n\t\t} else {\n\t\t\tif (fieldsize(p) + fieldleft(p) > n)\n\t\t\t\tn = fieldsize(p) + fieldleft(p);\n\t\t}\n\t\tif (p->link == q)\n\t\t\tbreak;\n\t\tp = p->link;\n\t} while (t == ',' && (t = gettok()) != 0);\n\tn = (n + 7)/8;\n\tfor (i = 0; i < n; i++) {\n\t\tValue v;\n\t\tif (IR->little_endian) {\n\t\t\tv.u = (unsigned char)bits;\n\t\t\tbits >>= 8;\n\t\t} else {\t/* a big endian */\n\t\t\tv.u = (unsigned char)(bits>>(8*(unsignedtype->size - 1)));\n\t\t\tbits <<= 8;\n\t\t}\n\t\t(*IR->defconst)(U, unsignedchar->size, v);\n\t}\n\treturn n;\n}\n\n/* initstruct - initialize a struct ty of <= len bytes; if len == 0, go to } */\nstatic int initstruct(int len, Type ty, int lev) {\n\tint a, n = 0;\n\tField p = ty->u.sym->u.s.flist;\n\n\tdo {\n\t\tif (p->offset > n) {\n\t\t\t(*IR->space)(p->offset - n);\n\t\t\tn += p->offset - n;\n\t\t}\n\t\tif (p->lsb) {\n\t\t\tField q = p;\n\t\t\twhile (q->link && q->link->offset == p->offset)\n\t\t\t\tq = q->link;\n\t\t\tn += initfields(p, q->link);\n\t\t\tp = q;\n\t\t} else {\n\t\t\tinitializer(p->type, lev);\n\t\t\tn += p->type->size;\n\t\t}\n\t\tif (p->link) {\n\t\t\tp = p->link;\n\t\t\ta = p->type->align;\n\t\t} else\n\t\t\ta = ty->align;\n\t\tif (a && n%a) {\n\t\t\t(*IR->space)(a - n%a);\n\t\t\tn = roundup(n, a);\n\t\t}\n\t\tif (len > 0 && n >= len || t != ',')\n\t\t\tbreak;\n\t\tt = gettok();\n\t} while (t != '}');\n\treturn n;\n}\n\n/* initializer - constexpr | { constexpr ( , constexpr )* [ , ] } */\nType initializer(Type ty, int lev) {\n\tint n = 0;\n\tTree e;\n\tType aty = NULL;\n\tstatic char follow[] = { IF, CHAR, STATIC, 0 };\n\n\tty = unqual(ty);\n\tif (isscalar(ty)) {\n\t\tneedconst++;\n\t\tif (t == '{') {\n\t\t\tt = gettok();\n\t\t\te = expr1(0);\n\t\t\tinitend(lev, follow);\n\t\t} else\n\t\t\te = expr1(0);\n\t\te = pointer(e);\n\t\tif ((aty = assign(ty, e)) != NULL)\n\t\t\te = cast(e, aty);\n\t\telse\n\t\t\terror(\"invalid initialization type; found `%t' expected `%t'\\n\",\n\t\t\t\te->type, ty);\n\t\tn = genconst(e, 1);\n\t\tdeallocate(STMT);\n\t\tneedconst--;\n\t}\n\tif ((isunion(ty) || isstruct(ty)) && ty->size == 0) {\n\t\tstatic char follow[] = { CHAR, STATIC, 0 };\n\t\terror(\"cannot initialize undefined `%t'\\n\", ty);\n\t\tskipto(';', follow);\n\t\treturn ty;\n\t} else if (isunion(ty)) {\n\t\tif (t == '{') {\n\t\t\tt = gettok();\n\t\t\tn = initstruct(ty->u.sym->u.s.flist->type->size, ty, lev + 1);\n\t\t\tinitend(lev, follow);\n\t\t} else {\n\t\t\tif (lev == 0)\n\t\t\t\terror(\"missing { in initialization of `%t'\\n\", ty);\n\t\t\tn = initstruct(ty->u.sym->u.s.flist->type->size, ty, lev + 1);\n\t\t}\n\t} else if (isstruct(ty)) {\n\t\tif (t == '{') {\n\t\t\tt = gettok();\n\t\t\tn = initstruct(0, ty, lev + 1);\n\t\t\ttest('}', follow);\n\t\t} else if (lev > 0)\n\t\t\tn = initstruct(ty->size, ty, lev + 1);\n\t\telse {\n\t\t\terror(\"missing { in initialization of `%t'\\n\", ty);\n\t\t\tn = initstruct(ty->u.sym->u.s.flist->type->size, ty, lev + 1);\n\t\t}\n\t}\n\tif (isarray(ty))\n\t\taty = unqual(ty->type);\n\tif (isarray(ty) && ischar(aty)) {\n\t\tif (t == SCON) {\n\t\t\tif (ty->size > 0 && ty->size == tsym->type->size - 1)\n\t\t\t\ttsym->type = array(chartype, ty->size, 0);\n\t\t\tn = tsym->type->size;\n\t\t\t(*IR->defstring)(tsym->type->size, tsym->u.c.v.p);\n\t\t\tt = gettok();\n\t\t} else if (t == '{') {\n\t\t\tt = gettok();\n\t\t\tif (t == SCON) {\n\t\t\t\tty = initializer(ty, lev + 1);\n\t\t\t\tinitend(lev, follow);\n\t\t\t\treturn ty;\n\t\t\t}\n\t\t\tn = initchar(0, aty);\n\t\t\ttest('}', follow);\n\t\t} else if (lev > 0 && ty->size > 0)\n\t\t\tn = initchar(ty->size, aty);\n\t\telse {\t/* eg, char c[] = 0; */\n\t\t\terror(\"missing { in initialization of `%t'\\n\", ty);\n\t\t\tn = initchar(1, aty);\n\t\t}\n\t} else if (isarray(ty)) {\n\t\tif (t == SCON && aty == widechar) {\n\t\t\tint i;\n\t\t\tunsigned int *s = tsym->u.c.v.p;\n\t\t\tif (ty->size > 0 && ty->size == tsym->type->size - widechar->size)\n\t\t\t\ttsym->type = array(widechar, ty->size/widechar->size, 0);\n\t\t\tn = tsym->type->size;\n\t\t\tfor (i = 0; i < n; i += widechar->size) {\n\t\t\t\tValue v;\n\t\t\t\tv.u = *s++;\n\t\t\t\t(*IR->defconst)(widechar->op, widechar->size, v);\n\t\t\t}\n\t\t\tt = gettok();\n\t\t} else if (t == '{') {\n\t\t\tt = gettok();\n\t\t\tif (t == SCON && aty == widechar) {\n\t\t\t\tty = initializer(ty, lev + 1);\n\t\t\t\tinitend(lev, follow);\n\t\t\t\treturn ty;\n\t\t\t}\n\t\t\tn = initarray(0, aty, lev + 1);\n\t\t\ttest('}', follow);\n\t\t} else if (lev > 0 && ty->size > 0)\n\t\t\tn = initarray(ty->size, aty, lev + 1);\n\t\telse {\n\t\t\terror(\"missing { in initialization of `%t'\\n\", ty);\n\t\t\tn = initarray(aty->size, aty, lev + 1);\n\t\t}\n\t}\t\n\tif (ty->size) {\n\t\tif (n > ty->size)\n\t\t\terror(\"too many initializers\\n\");\n\t\telse if (n < ty->size)\n\t\t\t(*IR->space)(ty->size - n);\n\t} else if (isarray(ty) && ty->type->size > 0)\n\t\tty = array(ty->type, n/ty->type->size, 0);\n\telse\n\t\tty->size = n;\n\treturn ty;\n}\n\n/* swtoseg - switch to segment seg, if necessary */\nvoid swtoseg(int seg) {\n\tif (curseg != seg)\n\t\t(*IR->segment)(seg);\n\tcurseg = seg;\n}\n"
  },
  {
    "path": "lcc/src/inits.c",
    "content": "void init(int argc, char *argv[]) {\n\t{extern void input_init(int, char *[]); input_init(argc, argv);}\n\t{extern void main_init(int, char *[]); main_init(argc, argv);}\n\t{extern void prof_init(int, char *[]); prof_init(argc, argv);}\n\t{extern void trace_init(int, char *[]); trace_init(argc, argv);}\n\t{extern void type_init(int, char *[]); type_init(argc, argv);}\n\t{extern void x86linux_init(int, char *[]); x86linux_init(argc, argv);}\n}\n"
  },
  {
    "path": "lcc/src/input.c",
    "content": "#include \"c.h\"\n\n\nstatic void pragma(void);\nstatic void resynch(void);\n\nstatic int bsize;\nstatic unsigned char buffer[MAXLINE+1 + BUFSIZE+1];\nunsigned char *cp;\t/* current input character */\nchar *file;\t\t/* current input file name */\nchar *firstfile;\t/* first input file */\nunsigned char *limit;\t/* points to last character + 1 */\nchar *line;\t\t/* current line */\nint lineno;\t\t/* line number of current line */\n\nvoid nextline(void) {\n\tdo {\n\t\tif (cp >= limit) {\n\t\t\tfillbuf();\n\t\t\tif (cp >= limit)\n\t\t\t\tcp = limit;\n\t\t\tif (cp == limit)\n\t\t\t\treturn;\n\t\t} else {\n\t\t\tlineno++;\n\t\t\tfor (line = (char *)cp; *cp==' ' || *cp=='\\t'; cp++)\n\t\t\t\t;\n\t\t\tif (*cp == '#') {\n\t\t\t\tresynch();\n\t\t\t\tnextline();\n\t\t\t}\n\t\t}\n\t} while (*cp == '\\n' && cp == limit);\n}\nvoid fillbuf(void) {\n\tif (bsize == 0)\n\t\treturn;\n\tif (cp >= limit)\n\t\tcp = &buffer[MAXLINE+1];\n\telse\n\t\t{\n\t\t\tint n = limit - cp;\n\t\t\tunsigned char *s = &buffer[MAXLINE+1] - n;\n\t\t\tassert(s >= buffer);\n\t\t\tline = (char *)s - ((char *)cp - line);\n\t\t\twhile (cp < limit)\n\t\t\t\t*s++ = *cp++;\n\t\t\tcp = &buffer[MAXLINE+1] - n;\n\t\t}\n\tif (feof(stdin))\n\t\tbsize = 0;\n\telse\n\t\tbsize = fread(&buffer[MAXLINE+1], 1, BUFSIZE, stdin);\n\tif (bsize < 0) {\n\t\terror(\"read error\\n\");\n\t\texit(EXIT_FAILURE);\n\t}\n\tlimit = &buffer[MAXLINE+1+bsize];\n\t*limit = '\\n';\n}\nvoid input_init(int argc, char *argv[]) {\n\tstatic int inited;\n\n\tif (inited)\n\t\treturn;\n\tinited = 1;\n\tmain_init(argc, argv);\n\tlimit = cp = &buffer[MAXLINE+1];\n\tbsize = -1;\n\tlineno = 0;\n\tfile = NULL;\n\tfillbuf();\n\tif (cp >= limit)\n\t\tcp = limit;\n\tnextline();\n}\n\n/* pragma - handle #pragma ref id... */\nstatic void pragma(void) {\n\tif ((t = gettok()) == ID && strcmp(token, \"ref\") == 0)\n\t\tfor (;;) {\n\t\t\twhile (*cp == ' ' || *cp == '\\t')\n\t\t\t\tcp++;\n\t\t\tif (*cp == '\\n' || *cp == 0)\n\t\t\t\tbreak;\n\t\t\tif ((t = gettok()) == ID && tsym) {\n\t\t\t\ttsym->ref++;\n\t\t\t\tuse(tsym, src);\n\t\t\t}\t\n\t\t}\n}\n\n/* resynch - set line number/file name in # n [ \"file\" ] and #pragma ... */\nstatic void resynch(void) {\n\tfor (cp++; *cp == ' ' || *cp == '\\t'; )\n\t\tcp++;\n\tif (limit - cp < MAXLINE)\n\t\tfillbuf();\n\tif (strncmp((char *)cp, \"pragma\", 6) == 0) {\n\t\tcp += 6;\n\t\tpragma();\n\t} else if (*cp >= '0' && *cp <= '9') {\n\tline:\tfor (lineno = 0; *cp >= '0' && *cp <= '9'; )\n\t\t\tlineno = 10*lineno + *cp++ - '0';\n\t\tlineno--;\n\t\twhile (*cp == ' ' || *cp == '\\t')\n\t\t\tcp++;\n\t\tif (*cp == '\"') {\n\t\t\tfile = (char *)++cp;\n\t\t\twhile (*cp && *cp != '\"' && *cp != '\\n')\n\t\t\t\tcp++;\n\t\t\tfile = stringn(file, (char *)cp - file);\n\t\t\tif (*cp == '\\n')\n\t\t\t\twarning(\"missing \\\" in preprocessor line\\n\");\n\t\t\tif (firstfile == 0)\n\t\t\t\tfirstfile = file;\n\t\t}\n\t} else if (strncmp((char *)cp, \"line\", 4) == 0) {\n\t\tfor (cp += 4; *cp == ' ' || *cp == '\\t'; )\n\t\t\tcp++;\n\t\tif (*cp >= '0' && *cp <= '9')\n\t\t\tgoto line;\n\t\tif (Aflag >= 2)\n\t\t\twarning(\"unrecognized control line\\n\");\n\t} else if (Aflag >= 2 && *cp != '\\n')\n\t\twarning(\"unrecognized control line\\n\");\n\twhile (*cp)\n\t\tif (*cp++ == '\\n')\n\t\t\tif (cp == limit + 1)\n\t\t\t\tnextline();\n\t\t\telse\n\t\t\t\tbreak;\n}\n\n"
  },
  {
    "path": "lcc/src/lex.c",
    "content": "#include \"c.h\"\n#include <float.h>\n#include <errno.h>\n\n\n#define MAXTOKEN 32\n\nenum { BLANK=01,  NEWLINE=02, LETTER=04,\n       DIGIT=010, HEX=020,    OTHER=040 };\n\nstatic unsigned char map[256] = { /* 000 nul */\t0,\n\t\t\t\t   /* 001 soh */\t0,\n\t\t\t\t   /* 002 stx */\t0,\n\t\t\t\t   /* 003 etx */\t0,\n\t\t\t\t   /* 004 eot */\t0,\n\t\t\t\t   /* 005 enq */\t0,\n\t\t\t\t   /* 006 ack */\t0,\n\t\t\t\t   /* 007 bel */\t0,\n\t\t\t\t   /* 010 bs  */\t0,\n\t\t\t\t   /* 011 ht  */\tBLANK,\n\t\t\t\t   /* 012 nl  */\tNEWLINE,\n\t\t\t\t   /* 013 vt  */\tBLANK,\n\t\t\t\t   /* 014 ff  */\tBLANK,\n\t\t\t\t   /* 015 cr  */\t0,\n\t\t\t\t   /* 016 so  */\t0,\n\t\t\t\t   /* 017 si  */\t0,\n\t\t\t\t   /* 020 dle */\t0,\n\t\t\t\t   /* 021 dc1 */\t0,\n\t\t\t\t   /* 022 dc2 */\t0,\n\t\t\t\t   /* 023 dc3 */\t0,\n\t\t\t\t   /* 024 dc4 */\t0,\n\t\t\t\t   /* 025 nak */\t0,\n\t\t\t\t   /* 026 syn */\t0,\n\t\t\t\t   /* 027 etb */\t0,\n\t\t\t\t   /* 030 can */\t0,\n\t\t\t\t   /* 031 em  */\t0,\n\t\t\t\t   /* 032 sub */\t0,\n\t\t\t\t   /* 033 esc */\t0,\n\t\t\t\t   /* 034 fs  */\t0,\n\t\t\t\t   /* 035 gs  */\t0,\n\t\t\t\t   /* 036 rs  */\t0,\n\t\t\t\t   /* 037 us  */\t0,\n\t\t\t\t   /* 040 sp  */\tBLANK,\n\t\t\t\t   /* 041 !   */\tOTHER,\n\t\t\t\t   /* 042 \"   */\tOTHER,\n\t\t\t\t   /* 043 #   */\tOTHER,\n\t\t\t\t   /* 044 $   */\t0,\n\t\t\t\t   /* 045 %   */\tOTHER,\n\t\t\t\t   /* 046 &   */\tOTHER,\n\t\t\t\t   /* 047 '   */\tOTHER,\n\t\t\t\t   /* 050 (   */\tOTHER,\n\t\t\t\t   /* 051 )   */\tOTHER,\n\t\t\t\t   /* 052 *   */\tOTHER,\n\t\t\t\t   /* 053 +   */\tOTHER,\n\t\t\t\t   /* 054 ,   */\tOTHER,\n\t\t\t\t   /* 055 -   */\tOTHER,\n\t\t\t\t   /* 056 .   */\tOTHER,\n\t\t\t\t   /* 057 /   */\tOTHER,\n\t\t\t\t   /* 060 0   */\tDIGIT,\n\t\t\t\t   /* 061 1   */\tDIGIT,\n\t\t\t\t   /* 062 2   */\tDIGIT,\n\t\t\t\t   /* 063 3   */\tDIGIT,\n\t\t\t\t   /* 064 4   */\tDIGIT,\n\t\t\t\t   /* 065 5   */\tDIGIT,\n\t\t\t\t   /* 066 6   */\tDIGIT,\n\t\t\t\t   /* 067 7   */\tDIGIT,\n\t\t\t\t   /* 070 8   */\tDIGIT,\n\t\t\t\t   /* 071 9   */\tDIGIT,\n\t\t\t\t   /* 072 :   */\tOTHER,\n\t\t\t\t   /* 073 ;   */\tOTHER,\n\t\t\t\t   /* 074 <   */\tOTHER,\n\t\t\t\t   /* 075 =   */\tOTHER,\n\t\t\t\t   /* 076 >   */\tOTHER,\n\t\t\t\t   /* 077 ?   */\tOTHER,\n\t\t\t\t   /* 100 @   */\t0,\n\t\t\t\t   /* 101 A   */\tLETTER|HEX,\n\t\t\t\t   /* 102 B   */\tLETTER|HEX,\n\t\t\t\t   /* 103 C   */\tLETTER|HEX,\n\t\t\t\t   /* 104 D   */\tLETTER|HEX,\n\t\t\t\t   /* 105 E   */\tLETTER|HEX,\n\t\t\t\t   /* 106 F   */\tLETTER|HEX,\n\t\t\t\t   /* 107 G   */\tLETTER,\n\t\t\t\t   /* 110 H   */\tLETTER,\n\t\t\t\t   /* 111 I   */\tLETTER,\n\t\t\t\t   /* 112 J   */\tLETTER,\n\t\t\t\t   /* 113 K   */\tLETTER,\n\t\t\t\t   /* 114 L   */\tLETTER,\n\t\t\t\t   /* 115 M   */\tLETTER,\n\t\t\t\t   /* 116 N   */\tLETTER,\n\t\t\t\t   /* 117 O   */\tLETTER,\n\t\t\t\t   /* 120 P   */\tLETTER,\n\t\t\t\t   /* 121 Q   */\tLETTER,\n\t\t\t\t   /* 122 R   */\tLETTER,\n\t\t\t\t   /* 123 S   */\tLETTER,\n\t\t\t\t   /* 124 T   */\tLETTER,\n\t\t\t\t   /* 125 U   */\tLETTER,\n\t\t\t\t   /* 126 V   */\tLETTER,\n\t\t\t\t   /* 127 W   */\tLETTER,\n\t\t\t\t   /* 130 X   */\tLETTER,\n\t\t\t\t   /* 131 Y   */\tLETTER,\n\t\t\t\t   /* 132 Z   */\tLETTER,\n\t\t\t\t   /* 133 [   */\tOTHER,\n\t\t\t\t   /* 134 \\   */\tOTHER,\n\t\t\t\t   /* 135 ]   */\tOTHER,\n\t\t\t\t   /* 136 ^   */\tOTHER,\n\t\t\t\t   /* 137 _   */\tLETTER,\n\t\t\t\t   /* 140 `   */\t0,\n\t\t\t\t   /* 141 a   */\tLETTER|HEX,\n\t\t\t\t   /* 142 b   */\tLETTER|HEX,\n\t\t\t\t   /* 143 c   */\tLETTER|HEX,\n\t\t\t\t   /* 144 d   */\tLETTER|HEX,\n\t\t\t\t   /* 145 e   */\tLETTER|HEX,\n\t\t\t\t   /* 146 f   */\tLETTER|HEX,\n\t\t\t\t   /* 147 g   */\tLETTER,\n\t\t\t\t   /* 150 h   */\tLETTER,\n\t\t\t\t   /* 151 i   */\tLETTER,\n\t\t\t\t   /* 152 j   */\tLETTER,\n\t\t\t\t   /* 153 k   */\tLETTER,\n\t\t\t\t   /* 154 l   */\tLETTER,\n\t\t\t\t   /* 155 m   */\tLETTER,\n\t\t\t\t   /* 156 n   */\tLETTER,\n\t\t\t\t   /* 157 o   */\tLETTER,\n\t\t\t\t   /* 160 p   */\tLETTER,\n\t\t\t\t   /* 161 q   */\tLETTER,\n\t\t\t\t   /* 162 r   */\tLETTER,\n\t\t\t\t   /* 163 s   */\tLETTER,\n\t\t\t\t   /* 164 t   */\tLETTER,\n\t\t\t\t   /* 165 u   */\tLETTER,\n\t\t\t\t   /* 166 v   */\tLETTER,\n\t\t\t\t   /* 167 w   */\tLETTER,\n\t\t\t\t   /* 170 x   */\tLETTER,\n\t\t\t\t   /* 171 y   */\tLETTER,\n\t\t\t\t   /* 172 z   */\tLETTER,\n\t\t\t\t   /* 173 {   */\tOTHER,\n\t\t\t\t   /* 174 |   */\tOTHER,\n\t\t\t\t   /* 175 }   */\tOTHER,\n\t\t\t\t   /* 176 ~   */\tOTHER, };\nstatic struct symbol tval;\nstatic char cbuf[BUFSIZE+1];\nstatic unsigned int wcbuf[BUFSIZE+1];\n\nCoordinate src;\t\t/* current source coordinate */\nint t;\nchar *token;\t\t/* current token */\nSymbol tsym;\t\t/* symbol table entry for current token */\n\nstatic void *cput(int c, void *cl);\nstatic void *wcput(int c, void *cl);\nstatic void *scon(int q, void *put(int c, void *cl), void *cl);\nstatic int backslash(int q);\nstatic Symbol fcon(void);\nstatic Symbol icon(unsigned long, int, int);\nstatic void ppnumber(char *);\n\nint gettok(void) {\n\tfor (;;) {\n\t\tregister unsigned char *rcp = cp;\n\t\twhile (map[*rcp]&BLANK)\n\t\t\trcp++;\n\t\tif (limit - rcp < MAXTOKEN) {\n\t\t\tcp = rcp;\n\t\t\tfillbuf();\n\t\t\trcp = cp;\n\t\t}\n\t\tsrc.file = file;\n\t\tsrc.x = (char *)rcp - line;\n\t\tsrc.y = lineno;\n\t\tcp = rcp + 1;\n\t\tswitch (*rcp++) {\n\t\tcase '/': if (*rcp == '*') {\n\t\t\t  \tint c = 0;\n\t\t\t  \tfor (rcp++; *rcp != '/' || c != '*'; )\n\t\t\t  \t\tif (map[*rcp]&NEWLINE) {\n\t\t\t  \t\t\tif (rcp < limit)\n\t\t\t  \t\t\t\tc = *rcp;\n\t\t\t  \t\t\tcp = rcp + 1;\n\t\t\t  \t\t\tnextline();\n\t\t\t  \t\t\trcp = cp;\n\t\t\t  \t\t\tif (rcp == limit)\n\t\t\t  \t\t\t\tbreak;\n\t\t\t  \t\t} else\n\t\t\t  \t\t\tc = *rcp++;\n\t\t\t  \tif (rcp < limit)\n\t\t\t  \t\trcp++;\n\t\t\t  \telse\n\t\t\t  \t\terror(\"unclosed comment\\n\");\n\t\t\t  \tcp = rcp;\n\t\t\t  \tcontinue;\n\t\t\t  }\n\t\t\t  return '/';\n\t\tcase '<':\n\t\t\tif (*rcp == '=') return cp++, LEQ;\n\t\t\tif (*rcp == '<') return cp++, LSHIFT;\n\t\t\treturn '<';\n\t\tcase '>':\n\t\t\tif (*rcp == '=') return cp++, GEQ;\n\t\t\tif (*rcp == '>') return cp++, RSHIFT;\n\t\t\treturn '>';\n\t\tcase '-':\n\t\t\tif (*rcp == '>') return cp++, DEREF;\n\t\t\tif (*rcp == '-') return cp++, DECR;\n\t\t\treturn '-';\n\t\tcase '=': return *rcp == '=' ? cp++, EQL    : '=';\n\t\tcase '!': return *rcp == '=' ? cp++, NEQ    : '!';\n\t\tcase '|': return *rcp == '|' ? cp++, OROR   : '|';\n\t\tcase '&': return *rcp == '&' ? cp++, ANDAND : '&';\n\t\tcase '+': return *rcp == '+' ? cp++, INCR   : '+';\n\t\tcase ';': case ',': case ':':\n\t\tcase '*': case '~': case '%': case '^': case '?':\n\t\tcase '[': case ']': case '{': case '}': case '(': case ')': \n\t\t\treturn rcp[-1];\n\t\tcase '\\n': case '\\v': case '\\r': case '\\f':\n\t\t\tnextline();\n\t\t\tif (cp == limit) {\n\t\t\t\ttsym = NULL;\n\t\t\t\treturn EOI;\n\t\t\t}\n\t\t\tcontinue;\n\n\t\tcase 'i':\n\t\t\tif (rcp[0] == 'f'\n\t\t\t&& !(map[rcp[1]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 1;\n\t\t\t\treturn IF;\n\t\t\t}\n\t\t\tif (rcp[0] == 'n'\n\t\t\t&&  rcp[1] == 't'\n\t\t\t&& !(map[rcp[2]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 2;\n\t\t\t\ttsym = inttype->u.sym;\n\t\t\t\treturn INT;\n\t\t\t}\n\t\t\tgoto id;\n\t\tcase 'h': case 'j': case 'k': case 'm': case 'n': case 'o':\n\t\tcase 'p': case 'q': case 'x': case 'y': case 'z':\n\t\tcase 'A': case 'B': case 'C': case 'D': case 'E': case 'F':\n\t\tcase 'G': case 'H': case 'I': case 'J': case 'K':\n\t\tcase 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':\n\t\tcase 'S': case 'T': case 'U': case 'V': case 'W': case 'X':\n\t\tcase 'Y': case 'Z':\n\t\tid:\n\t\t\tif (limit - rcp < MAXLINE) {\n\t\t\t\tcp = rcp - 1;\n\t\t\t\tfillbuf();\n\t\t\t\trcp = ++cp;\n\t\t\t}\n\t\t\tassert(cp == rcp);\n\t\t\ttoken = (char *)rcp - 1;\n\t\t\twhile (map[*rcp]&(DIGIT|LETTER))\n\t\t\t\trcp++;\n\t\t\ttoken = stringn(token, (char *)rcp - token);\n\t\t\ttsym = lookup(token, identifiers);\n\t\t\tcp = rcp;\n\t\t\treturn ID;\n\t\tcase '0': case '1': case '2': case '3': case '4':\n\t\tcase '5': case '6': case '7': case '8': case '9': {\n\t\t\tunsigned long n = 0;\n\t\t\tif (limit - rcp < MAXLINE) {\n\t\t\t\tcp = rcp - 1;\n\t\t\t\tfillbuf();\n\t\t\t\trcp = ++cp;\n\t\t\t}\n\t\t\tassert(cp == rcp);\n\t\t\ttoken = (char *)rcp - 1;\n\t\t\tif (*token == '0' && (*rcp == 'x' || *rcp == 'X')) {\n\t\t\t\tint d, overflow = 0;\n\t\t\t\twhile (*++rcp) {\n\t\t\t\t\tif (map[*rcp]&DIGIT)\n\t\t\t\t\t\td = *rcp - '0';\n\t\t\t\t\telse if (*rcp >= 'a' && *rcp <= 'f')\n\t\t\t\t\t\td = *rcp - 'a' + 10;\n\t\t\t\t\telse if (*rcp >= 'A' && *rcp <= 'F')\n\t\t\t\t\t\td = *rcp - 'A' + 10;\n\t\t\t\t\telse\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tif (n&~(~0UL >> 4))\n\t\t\t\t\t\toverflow = 1;\n\t\t\t\t\telse\n\t\t\t\t\t\tn = (n<<4) + d;\n\t\t\t\t}\n\t\t\t\tif ((char *)rcp - token <= 2)\n\t\t\t\t\terror(\"invalid hexadecimal constant `%S'\\n\", token, (char *)rcp-token);\n\t\t\t\tcp = rcp;\n\t\t\t\ttsym = icon(n, overflow, 16);\n\t\t\t} else if (*token == '0') {\n\t\t\t\tint err = 0, overflow = 0;\n\t\t\t\tfor ( ; map[*rcp]&DIGIT; rcp++) {\n\t\t\t\t\tif (*rcp == '8' || *rcp == '9')\n\t\t\t\t\t\terr = 1;\n\t\t\t\t\tif (n&~(~0UL >> 3))\n\t\t\t\t\t\toverflow = 1;\n\t\t\t\t\telse\n\t\t\t\t\t\tn = (n<<3) + (*rcp - '0');\n\t\t\t\t}\n\t\t\t\tif (*rcp == '.' || *rcp == 'e' || *rcp == 'E') {\n\t\t\t\t\tcp = rcp;\n\t\t\t\t\ttsym = fcon();\n\t\t\t\t\treturn FCON;\n\t\t\t\t}\n\t\t\t\tcp = rcp;\n\t\t\t\ttsym = icon(n, overflow, 8);\n\t\t\t\tif (err)\n\t\t\t\t\terror(\"invalid octal constant `%S'\\n\", token, (char*)cp-token);\n\t\t\t} else {\n\t\t\t\tint overflow = 0;\n\t\t\t\tfor (n = *token - '0'; map[*rcp]&DIGIT; ) {\n\t\t\t\t\tint d = *rcp++ - '0';\n\t\t\t\t\tif (n > (ULONG_MAX - d)/10)\n\t\t\t\t\t\toverflow = 1;\n\t\t\t\t\telse\n\t\t\t\t\t\tn = 10*n + d;\n\t\t\t\t}\n\t\t\t\tif (*rcp == '.' || *rcp == 'e' || *rcp == 'E') {\n\t\t\t\t\tcp = rcp;\n\t\t\t\t\ttsym = fcon();\n\t\t\t\t\treturn FCON;\n\t\t\t\t}\n\t\t\t\tcp = rcp;\n\t\t\t\ttsym = icon(n, overflow, 10);\n\t\t\t}\n\t\t\treturn ICON;\n\t\t}\n\t\tcase '.':\n\t\t\tif (rcp[0] == '.' && rcp[1] == '.') {\n\t\t\t\tcp += 2;\n\t\t\t\treturn ELLIPSIS;\n\t\t\t}\n\t\t\tif ((map[*rcp]&DIGIT) == 0)\n\t\t\t\treturn '.';\n\t\t\tif (limit - rcp < MAXLINE) {\n\t\t\t\tcp = rcp - 1;\n\t\t\t\tfillbuf();\n\t\t\t\trcp = ++cp;\n\t\t\t}\n\t\t\tassert(cp == rcp);\n\t\t\tcp = rcp - 1;\n\t\t\ttoken = (char *)cp;\n\t\t\ttsym = fcon();\n\t\t\treturn FCON;\n\t\tcase 'L':\n\t\t\tif (*rcp == '\\'') {\n\t\t\t\tunsigned int *s = scon(*cp, wcput, wcbuf);\n\t\t\t\tif (s - wcbuf > 2)\n\t\t\t\t\twarning(\"excess characters in wide-character literal ignored\\n\");\n\t\t\t\ttval.type = widechar;\n\t\t\t\ttval.u.c.v.u = wcbuf[0];\n\t\t\t\ttsym = &tval;\n\t\t\t\treturn ICON;\n\t\t\t} else if (*rcp == '\"') {\n\t\t\t\tunsigned int *s = scon(*cp, wcput, wcbuf);\n\t\t\t\ttval.type = array(widechar, s - wcbuf, 0);\n\t\t\t\ttval.u.c.v.p = wcbuf;\n\t\t\t\ttsym = &tval;\n\t\t\t\treturn SCON;\n\t\t\t} else\n\t\t\t\tgoto id;\n\t\tcase '\\'': {\n\t\t\tchar *s = scon(*--cp, cput, cbuf);\n\t\t\tif (s - cbuf > 2)\n\t\t\t\twarning(\"excess characters in multibyte character literal ignored\\n\");\n\t\t\ttval.type = inttype;\n\t\t\tif (chartype->op == INT)\n\t\t\t\ttval.u.c.v.i = extend(cbuf[0], chartype);\n\t\t\telse\n\t\t\t\ttval.u.c.v.i = cbuf[0]&0xFF;\n\t\t\ttsym = &tval;\n\t\t\treturn ICON;\n\t\t\t}\n\t\tcase '\"': {\n\t\t\tchar *s = scon(*--cp, cput, cbuf);\n\t\t\ttval.type = array(chartype, s - cbuf, 0);\n\t\t\ttval.u.c.v.p = cbuf;\n\t\t\ttsym = &tval;\n\t\t\treturn SCON;\n\t\t\t}\n\t\tcase 'a':\n\t\t\tif (rcp[0] == 'u'\n\t\t\t&&  rcp[1] == 't'\n\t\t\t&&  rcp[2] == 'o'\n\t\t\t&& !(map[rcp[3]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 3;\n\t\t\t\treturn AUTO;\n\t\t\t}\n\t\t\tgoto id;\n\t\tcase 'b':\n\t\t\tif (rcp[0] == 'r'\n\t\t\t&&  rcp[1] == 'e'\n\t\t\t&&  rcp[2] == 'a'\n\t\t\t&&  rcp[3] == 'k'\n\t\t\t&& !(map[rcp[4]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 4;\n\t\t\t\treturn BREAK;\n\t\t\t}\n\t\t\tgoto id;\n\t\tcase 'c':\n\t\t\tif (rcp[0] == 'a'\n\t\t\t&&  rcp[1] == 's'\n\t\t\t&&  rcp[2] == 'e'\n\t\t\t&& !(map[rcp[3]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 3;\n\t\t\t\treturn CASE;\n\t\t\t}\n\t\t\tif (rcp[0] == 'h'\n\t\t\t&&  rcp[1] == 'a'\n\t\t\t&&  rcp[2] == 'r'\n\t\t\t&& !(map[rcp[3]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 3;\n\t\t\t\ttsym = chartype->u.sym;\n\t\t\t\treturn CHAR;\n\t\t\t}\n\t\t\tif (rcp[0] == 'o'\n\t\t\t&&  rcp[1] == 'n'\n\t\t\t&&  rcp[2] == 's'\n\t\t\t&&  rcp[3] == 't'\n\t\t\t&& !(map[rcp[4]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 4;\n\t\t\t\treturn CONST;\n\t\t\t}\n\t\t\tif (rcp[0] == 'o'\n\t\t\t&&  rcp[1] == 'n'\n\t\t\t&&  rcp[2] == 't'\n\t\t\t&&  rcp[3] == 'i'\n\t\t\t&&  rcp[4] == 'n'\n\t\t\t&&  rcp[5] == 'u'\n\t\t\t&&  rcp[6] == 'e'\n\t\t\t&& !(map[rcp[7]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 7;\n\t\t\t\treturn CONTINUE;\n\t\t\t}\n\t\t\tgoto id;\n\t\tcase 'd':\n\t\t\tif (rcp[0] == 'e'\n\t\t\t&&  rcp[1] == 'f'\n\t\t\t&&  rcp[2] == 'a'\n\t\t\t&&  rcp[3] == 'u'\n\t\t\t&&  rcp[4] == 'l'\n\t\t\t&&  rcp[5] == 't'\n\t\t\t&& !(map[rcp[6]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 6;\n\t\t\t\treturn DEFAULT;\n\t\t\t}\n\t\t\tif (rcp[0] == 'o'\n\t\t\t&&  rcp[1] == 'u'\n\t\t\t&&  rcp[2] == 'b'\n\t\t\t&&  rcp[3] == 'l'\n\t\t\t&&  rcp[4] == 'e'\n\t\t\t&& !(map[rcp[5]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 5;\n\t\t\t\ttsym = doubletype->u.sym;\n\t\t\t\treturn DOUBLE;\n\t\t\t}\n\t\t\tif (rcp[0] == 'o'\n\t\t\t&& !(map[rcp[1]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 1;\n\t\t\t\treturn DO;\n\t\t\t}\n\t\t\tgoto id;\n\t\tcase 'e':\n\t\t\tif (rcp[0] == 'l'\n\t\t\t&&  rcp[1] == 's'\n\t\t\t&&  rcp[2] == 'e'\n\t\t\t&& !(map[rcp[3]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 3;\n\t\t\t\treturn ELSE;\n\t\t\t}\n\t\t\tif (rcp[0] == 'n'\n\t\t\t&&  rcp[1] == 'u'\n\t\t\t&&  rcp[2] == 'm'\n\t\t\t&& !(map[rcp[3]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 3;\n\t\t\t\treturn ENUM;\n\t\t\t}\n\t\t\tif (rcp[0] == 'x'\n\t\t\t&&  rcp[1] == 't'\n\t\t\t&&  rcp[2] == 'e'\n\t\t\t&&  rcp[3] == 'r'\n\t\t\t&&  rcp[4] == 'n'\n\t\t\t&& !(map[rcp[5]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 5;\n\t\t\t\treturn EXTERN;\n\t\t\t}\n\t\t\tgoto id;\n\t\tcase 'f':\n\t\t\tif (rcp[0] == 'l'\n\t\t\t&&  rcp[1] == 'o'\n\t\t\t&&  rcp[2] == 'a'\n\t\t\t&&  rcp[3] == 't'\n\t\t\t&& !(map[rcp[4]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 4;\n\t\t\t\ttsym = floattype->u.sym;\n\t\t\t\treturn FLOAT;\n\t\t\t}\n\t\t\tif (rcp[0] == 'o'\n\t\t\t&&  rcp[1] == 'r'\n\t\t\t&& !(map[rcp[2]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 2;\n\t\t\t\treturn FOR;\n\t\t\t}\n\t\t\tgoto id;\n\t\tcase 'g':\n\t\t\tif (rcp[0] == 'o'\n\t\t\t&&  rcp[1] == 't'\n\t\t\t&&  rcp[2] == 'o'\n\t\t\t&& !(map[rcp[3]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 3;\n\t\t\t\treturn GOTO;\n\t\t\t}\n\t\t\tgoto id;\n\t\tcase 'l':\n\t\t\tif (rcp[0] == 'o'\n\t\t\t&&  rcp[1] == 'n'\n\t\t\t&&  rcp[2] == 'g'\n\t\t\t&& !(map[rcp[3]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 3;\n\t\t\t\treturn LONG;\n\t\t\t}\n\t\t\tgoto id;\n\t\tcase 'r':\n\t\t\tif (rcp[0] == 'e'\n\t\t\t&&  rcp[1] == 'g'\n\t\t\t&&  rcp[2] == 'i'\n\t\t\t&&  rcp[3] == 's'\n\t\t\t&&  rcp[4] == 't'\n\t\t\t&&  rcp[5] == 'e'\n\t\t\t&&  rcp[6] == 'r'\n\t\t\t&& !(map[rcp[7]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 7;\n\t\t\t\treturn REGISTER;\n\t\t\t}\n\t\t\tif (rcp[0] == 'e'\n\t\t\t&&  rcp[1] == 't'\n\t\t\t&&  rcp[2] == 'u'\n\t\t\t&&  rcp[3] == 'r'\n\t\t\t&&  rcp[4] == 'n'\n\t\t\t&& !(map[rcp[5]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 5;\n\t\t\t\treturn RETURN;\n\t\t\t}\n\t\t\tgoto id;\n\t\tcase 's':\n\t\t\tif (rcp[0] == 'h'\n\t\t\t&&  rcp[1] == 'o'\n\t\t\t&&  rcp[2] == 'r'\n\t\t\t&&  rcp[3] == 't'\n\t\t\t&& !(map[rcp[4]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 4;\n\t\t\t\treturn SHORT;\n\t\t\t}\n\t\t\tif (rcp[0] == 'i'\n\t\t\t&&  rcp[1] == 'g'\n\t\t\t&&  rcp[2] == 'n'\n\t\t\t&&  rcp[3] == 'e'\n\t\t\t&&  rcp[4] == 'd'\n\t\t\t&& !(map[rcp[5]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 5;\n\t\t\t\treturn SIGNED;\n\t\t\t}\n\t\t\tif (rcp[0] == 'i'\n\t\t\t&&  rcp[1] == 'z'\n\t\t\t&&  rcp[2] == 'e'\n\t\t\t&&  rcp[3] == 'o'\n\t\t\t&&  rcp[4] == 'f'\n\t\t\t&& !(map[rcp[5]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 5;\n\t\t\t\treturn SIZEOF;\n\t\t\t}\n\t\t\tif (rcp[0] == 't'\n\t\t\t&&  rcp[1] == 'a'\n\t\t\t&&  rcp[2] == 't'\n\t\t\t&&  rcp[3] == 'i'\n\t\t\t&&  rcp[4] == 'c'\n\t\t\t&& !(map[rcp[5]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 5;\n\t\t\t\treturn STATIC;\n\t\t\t}\n\t\t\tif (rcp[0] == 't'\n\t\t\t&&  rcp[1] == 'r'\n\t\t\t&&  rcp[2] == 'u'\n\t\t\t&&  rcp[3] == 'c'\n\t\t\t&&  rcp[4] == 't'\n\t\t\t&& !(map[rcp[5]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 5;\n\t\t\t\treturn STRUCT;\n\t\t\t}\n\t\t\tif (rcp[0] == 'w'\n\t\t\t&&  rcp[1] == 'i'\n\t\t\t&&  rcp[2] == 't'\n\t\t\t&&  rcp[3] == 'c'\n\t\t\t&&  rcp[4] == 'h'\n\t\t\t&& !(map[rcp[5]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 5;\n\t\t\t\treturn SWITCH;\n\t\t\t}\n\t\t\tgoto id;\n\t\tcase 't':\n\t\t\tif (rcp[0] == 'y'\n\t\t\t&&  rcp[1] == 'p'\n\t\t\t&&  rcp[2] == 'e'\n\t\t\t&&  rcp[3] == 'd'\n\t\t\t&&  rcp[4] == 'e'\n\t\t\t&&  rcp[5] == 'f'\n\t\t\t&& !(map[rcp[6]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 6;\n\t\t\t\treturn TYPEDEF;\n\t\t\t}\n\t\t\tgoto id;\n\t\tcase 'u':\n\t\t\tif (rcp[0] == 'n'\n\t\t\t&&  rcp[1] == 'i'\n\t\t\t&&  rcp[2] == 'o'\n\t\t\t&&  rcp[3] == 'n'\n\t\t\t&& !(map[rcp[4]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 4;\n\t\t\t\treturn UNION;\n\t\t\t}\n\t\t\tif (rcp[0] == 'n'\n\t\t\t&&  rcp[1] == 's'\n\t\t\t&&  rcp[2] == 'i'\n\t\t\t&&  rcp[3] == 'g'\n\t\t\t&&  rcp[4] == 'n'\n\t\t\t&&  rcp[5] == 'e'\n\t\t\t&&  rcp[6] == 'd'\n\t\t\t&& !(map[rcp[7]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 7;\n\t\t\t\treturn UNSIGNED;\n\t\t\t}\n\t\t\tgoto id;\n\t\tcase 'v':\n\t\t\tif (rcp[0] == 'o'\n\t\t\t&&  rcp[1] == 'i'\n\t\t\t&&  rcp[2] == 'd'\n\t\t\t&& !(map[rcp[3]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 3;\n\t\t\t\ttsym = voidtype->u.sym;\n\t\t\t\treturn VOID;\n\t\t\t}\n\t\t\tif (rcp[0] == 'o'\n\t\t\t&&  rcp[1] == 'l'\n\t\t\t&&  rcp[2] == 'a'\n\t\t\t&&  rcp[3] == 't'\n\t\t\t&&  rcp[4] == 'i'\n\t\t\t&&  rcp[5] == 'l'\n\t\t\t&&  rcp[6] == 'e'\n\t\t\t&& !(map[rcp[7]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 7;\n\t\t\t\treturn VOLATILE;\n\t\t\t}\n\t\t\tgoto id;\n\t\tcase 'w':\n\t\t\tif (rcp[0] == 'h'\n\t\t\t&&  rcp[1] == 'i'\n\t\t\t&&  rcp[2] == 'l'\n\t\t\t&&  rcp[3] == 'e'\n\t\t\t&& !(map[rcp[4]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 4;\n\t\t\t\treturn WHILE;\n\t\t\t}\n\t\t\tgoto id;\n\t\tcase '_':\n\t\t\tif (rcp[0] == '_'\n\t\t\t&&  rcp[1] == 't'\n\t\t\t&&  rcp[2] == 'y'\n\t\t\t&&  rcp[3] == 'p'\n\t\t\t&&  rcp[4] == 'e'\n\t\t\t&&  rcp[5] == 'c'\n\t\t\t&&  rcp[6] == 'o'\n\t\t\t&&  rcp[7] == 'd'\n\t\t\t&&  rcp[8] == 'e'\n\t\t\t&& !(map[rcp[9]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 9;\n\t\t\t\treturn TYPECODE;\n\t\t\t}\n\t\t\tif (rcp[0] == '_'\n\t\t\t&&  rcp[1] == 'f'\n\t\t\t&&  rcp[2] == 'i'\n\t\t\t&&  rcp[3] == 'r'\n\t\t\t&&  rcp[4] == 's'\n\t\t\t&&  rcp[5] == 't'\n\t\t\t&&  rcp[6] == 'a'\n\t\t\t&&  rcp[7] == 'r'\n\t\t\t&&  rcp[8] == 'g'\n\t\t\t&& !(map[rcp[9]]&(DIGIT|LETTER))) {\n\t\t\t\tcp = rcp + 9;\n\t\t\t\treturn FIRSTARG;\n\t\t\t}\n\t\t\tgoto id;\n\t\tdefault:\n\t\t\tif ((map[cp[-1]]&BLANK) == 0)\n\t\t\t\tif (cp[-1] < ' ' || cp[-1] >= 0177)\n\t\t\t\t\terror(\"illegal character `\\\\0%o'\\n\", cp[-1]);\n\t\t\t\telse\n\t\t\t\t\terror(\"illegal character `%c'\\n\", cp[-1]);\n\t\t}\n\t}\n}\nstatic Symbol icon(unsigned long n, int overflow, int base) {\n\tif ((*cp=='u'||*cp=='U') && (cp[1]=='l'||cp[1]=='L')\n\t||  (*cp=='l'||*cp=='L') && (cp[1]=='u'||cp[1]=='U')) {\n\t\ttval.type = unsignedlong;\n\t\tcp += 2;\n\t} else if (*cp == 'u' || *cp == 'U') {\n\t\tif (overflow || n > unsignedtype->u.sym->u.limits.max.i)\n\t\t\ttval.type = unsignedlong;\n\t\telse\n\t\t\ttval.type = unsignedtype;\n\t\tcp += 1;\n\t} else if (*cp == 'l' || *cp == 'L') {\n\t\tif (overflow || n > longtype->u.sym->u.limits.max.i)\n\t\t\ttval.type = unsignedlong;\n\t\telse\n\t\t\ttval.type = longtype;\n\t\tcp += 1;\n\t} else if (overflow || n > longtype->u.sym->u.limits.max.i)\n\t\ttval.type = unsignedlong;\n\telse if (n > inttype->u.sym->u.limits.max.i)\n\t\ttval.type = longtype;\n\telse if (base != 10 && n > inttype->u.sym->u.limits.max.i)\n\t\ttval.type = unsignedtype;\n\telse\n\t\ttval.type = inttype;\n\tswitch (tval.type->op) {\n\tcase INT:\n\t\tif (overflow || n > tval.type->u.sym->u.limits.max.i) {\n\t\t\twarning(\"overflow in constant `%S'\\n\", token,\n\t\t\t\t(char*)cp - token);\n\t\t\ttval.u.c.v.i = tval.type->u.sym->u.limits.max.i;\n\t\t} else\n\t\t\ttval.u.c.v.i = n;\n\t\tbreak;\n\tcase UNSIGNED:\n\t\tif (overflow || n > tval.type->u.sym->u.limits.max.u) {\n\t\t\twarning(\"overflow in constant `%S'\\n\", token,\n\t\t\t\t(char*)cp - token);\n\t\t\ttval.u.c.v.u = tval.type->u.sym->u.limits.max.u;\n\t\t} else\n\t\t\ttval.u.c.v.u = n;\n\t\tbreak;\n\tdefault: assert(0);\n\t}\n\tppnumber(\"integer\");\n\treturn &tval;\n}\nstatic void ppnumber(char *which) {\n\tunsigned char *rcp = cp--;\n\n\tfor ( ; (map[*cp]&(DIGIT|LETTER)) || *cp == '.'; cp++)\n\t\tif ((cp[0] == 'E' || cp[0] == 'e')\n\t\t&&  (cp[1] == '-' || cp[1] == '+'))\n\t\t\tcp++;\n\tif (cp > rcp)\n\t\terror(\"`%S' is a preprocessing number but an invalid %s constant\\n\", token,\n\n\t\t\t(char*)cp-token, which);\n}\nstatic Symbol fcon(void) {\n\tif (*cp == '.')\n\t\tdo\n\t\t\tcp++;\n\t\twhile (map[*cp]&DIGIT);\n\tif (*cp == 'e' || *cp == 'E') {\n\t\tif (*++cp == '-' || *cp == '+')\n\t\t\tcp++;\n\t\tif (map[*cp]&DIGIT)\n\t\t\tdo\n\t\t\t\tcp++;\n\t\t\twhile (map[*cp]&DIGIT);\n\t\telse\n\t\t\terror(\"invalid floating constant `%S'\\n\", token,\n\t\t\t\t(char*)cp - token);\n\t}\n\n\terrno = 0;\n\ttval.u.c.v.d = strtod(token, NULL);\n\tif (errno == ERANGE)\n\t\twarning(\"overflow in floating constant `%S'\\n\", token,\n\t\t\t(char*)cp - token);\n\tif (*cp == 'f' || *cp == 'F') {\n\t\t++cp;\n\t\tif (tval.u.c.v.d > floattype->u.sym->u.limits.max.d)\n\t\t\twarning(\"overflow in floating constant `%S'\\n\", token,\n\t\t\t\t(char*)cp - token);\n\t\ttval.type = floattype;\n\t} else if (*cp == 'l' || *cp == 'L') {\n\t\tcp++;\n\t\ttval.type = longdouble;\n\t} else {\n\t\tif (tval.u.c.v.d > doubletype->u.sym->u.limits.max.d)\n\t\t\twarning(\"overflow in floating constant `%S'\\n\", token,\n\t\t\t\t(char*)cp - token);\n\t\ttval.type = doubletype;\n\t}\n\tppnumber(\"floating\");\n\treturn &tval;\n}\n\nstatic void *cput(int c, void *cl) {\n\tchar *s = cl;\n\n\tif (c < 0 || c > 255)\n\t\twarning(\"overflow in escape sequence with resulting value `%d'\\n\", c);\n\t*s++ = c;\n\treturn s;\n}\n\nstatic void *wcput(int c, void *cl) {\n\tunsigned int *s = cl;\n\n\t*s++ = c;\n\treturn s;\n}\n\nstatic void *scon(int q, void *put(int c, void *cl), void *cl) {\n\tint n = 0, nbad = 0;\n\n\tdo {\n\t\tcp++;\n\t\twhile (*cp != q) {\n\t\t\tint c;\n\t\t\tif (map[*cp]&NEWLINE) {\n\t\t\t\tif (cp < limit)\n\t\t\t\t\tbreak;\n\t\t\t\tcp++;\n\t\t\t\tnextline();\n\t\t\t\tif (cp == limit)\n\t\t\t\t\tbreak;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tc = *cp++;\n\t\t\tif (c == '\\\\') {\n\t\t\t\tif (map[*cp]&NEWLINE) {\n\t\t\t\t\tif (cp < limit)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcp++;\n\t\t\t\t\tnextline();\n\t\t\t\t}\n\t\t\t\tif (limit - cp < MAXTOKEN)\n\t\t\t\t\tfillbuf();\n\t\t\t\tc = backslash(q);\n\t\t\t} else if (c < 0 || c > 255 || map[c] == 0)\n\t\t\t\tnbad++;\n\t\t\tif (n++ < BUFSIZE)\n\t\t\t\tcl = put(c, cl);\n\t\t}\n\t\tif (*cp == q)\n\t\t\tcp++;\n\t\telse\n\t\t\terror(\"missing %c\\n\", q);\n\t} while (q == '\"' && getchr() == '\"');\n\tcl = put(0, cl);\n\tif (n >= BUFSIZE)\n\t\terror(\"%s literal too long\\n\", q == '\"' ? \"string\" : \"character\");\n\tif (Aflag >= 2 && q == '\"' && n > 509)\n\t\twarning(\"more than 509 characters in a string literal\\n\");\n\tif (Aflag >= 2 && nbad > 0)\n\t\twarning(\"%s literal contains non-portable characters\\n\",\n\t\t\tq == '\"' ? \"string\" : \"character\");\n\treturn cl;\n}\nint getchr(void) {\n\tfor (;;) {\n\t\twhile (map[*cp]&BLANK)\n\t\t\tcp++;\n\t\tif (!(map[*cp]&NEWLINE))\n\t\t\treturn *cp;\n\t\tcp++;\n\t\tnextline();\n\t\tif (cp == limit)\n\t\t\treturn EOI;\n\t}\n}\nstatic int backslash(int q) {\n\tunsigned int c;\n\n\tswitch (*cp++) {\n\tcase 'a': return 7;\n\tcase 'b': return '\\b';\n\tcase 'f': return '\\f';\n\tcase 'n': return '\\n';\n\tcase 'r': return '\\r';\n\tcase 't': return '\\t';\n\tcase 'v': return '\\v';\n\tcase '\\'': case '\"': case '\\\\': case '\\?': break;\n\tcase 'x': {\n\t\tint overflow = 0;\n\t\tif ((map[*cp]&(DIGIT|HEX)) == 0) {\n\t\t\tif (*cp < ' ' || *cp == 0177)\n\t\t\t\terror(\"ill-formed hexadecimal escape sequence\\n\");\n\t\t\telse\n\t\t\t\terror(\"ill-formed hexadecimal escape sequence `\\\\x%c'\\n\", *cp);\n\t\t\tif (*cp != q)\n\t\t\t\tcp++;\n\t\t\treturn 0;\n\t\t}\n\t\tfor (c = 0; map[*cp]&(DIGIT|HEX); cp++) {\n\t\t\tif (c >> (8*widechar->size - 4))\n\t\t\t\toverflow = 1;\n\t\t\tif (map[*cp]&DIGIT)\n\t\t\t\tc = (c<<4) + *cp - '0';\n\t\t\telse\n\t\t\t\tc = (c<<4) + (*cp&~040) - 'A' + 10;\n\t\t}\n\t\tif (overflow)\n\t\t\twarning(\"overflow in hexadecimal escape sequence\\n\");\n\t\treturn c&ones(8*widechar->size);\n\t\t}\n\tcase '0': case '1': case '2': case '3':\n\tcase '4': case '5': case '6': case '7':\n\t\tc = *(cp-1) - '0';\n\t\tif (*cp >= '0' && *cp <= '7') {\n\t\t\tc = (c<<3) + *cp++ - '0';\n\t\t\tif (*cp >= '0' && *cp <= '7')\n\t\t\t\tc = (c<<3) + *cp++ - '0';\n\t\t}\n\t\treturn c;\n\tdefault:\n\t\tif (cp[-1] < ' ' || cp[-1] >= 0177)\n\t\t\twarning(\"unrecognized character escape sequence\\n\");\n\t\telse\n\t\t\twarning(\"unrecognized character escape sequence `\\\\%c'\\n\", cp[-1]);\n\t}\n\treturn cp[-1];\n}\n"
  },
  {
    "path": "lcc/src/list.c",
    "content": "#include \"c.h\"\n\n\nstatic List freenodes;\t\t/* free list nodes */\n\n/* append - append x to list, return new list */\nList append(void *x, List list) {\n\tList new;\n\n\tif ((new = freenodes) != NULL)\n\t\tfreenodes = freenodes->link;\n\telse\n\t\tNEW(new, PERM);\n\tif (list) {\n\t\tnew->link = list->link;\n\t\tlist->link = new;\n\t} else\n\t\tnew->link = new;\n\tnew->x = x;\n\treturn new;\n}\n\n/* length - # elements in list */\nint length(List list) {\n\tint n = 0;\n\n\tif (list) {\n\t\tList lp = list;\n\t\tdo\n\t\t\tn++;\n\t\twhile ((lp = lp->link) != list);\n\t}\n\treturn n;\n}\n\n/* ltov - convert list to an NULL-terminated vector allocated in arena */\nvoid *ltov(List *list, unsigned arena) {\n\tint i = 0;\n\tvoid **array = newarray(length(*list) + 1, sizeof array[0], arena);\n\n\tif (*list) {\n\t\tList lp = *list;\n\t\tdo {\n\t\t\tlp = lp->link;\n\t\t\tarray[i++] = lp->x;\n\t\t} while (lp != *list);\n#ifndef PURIFY\n\t\tlp = (*list)->link;\n\t\t(*list)->link = freenodes;\n\t\tfreenodes = lp;\n#endif\n\t}\n\t*list = NULL;\n\tarray[i] = NULL;\n\treturn array;\n}\n"
  },
  {
    "path": "lcc/src/main.c",
    "content": "#include \"c.h\"\n\nstatic char rcsid[] = \"main.c - faked rcsid\";\n\nstatic void typestab(Symbol, void *);\n\nstatic void stabline(Coordinate *);\nstatic void stabend(Coordinate *, Symbol, Coordinate **, Symbol *, Symbol *);\nInterface *IR = NULL;\n\nint Aflag;\t\t/* >= 0 if -A specified */\nint Pflag;\t\t/* != 0 if -P specified */\nint glevel;\t\t/* == [0-9] if -g[0-9] specified */\nint xref;\t\t/* != 0 for cross-reference data */\nSymbol YYnull;\t\t/* _YYnull  symbol if -n or -nvalidate specified */\nSymbol YYcheck;\t\t/* _YYcheck symbol if -nvalidate,check specified */\n\nstatic char *comment;\nstatic Interface stabIR;\nstatic char *currentfile;       /* current file name */\nstatic int currentline;\t\t/* current line number */\nstatic FILE *srcfp;\t\t/* stream for current file, if non-NULL */\nstatic int srcpos;\t\t/* position of srcfp, if srcfp is non-NULL */\nint main(int argc, char *argv[]) {\n\tint i, j;\n\tfor (i = argc - 1; i > 0; i--)\n\t\tif (strncmp(argv[i], \"-target=\", 8) == 0)\n\t\t\tbreak;\n\tif (i > 0) {\n\t\tchar *s = strchr(argv[i], '\\\\');\n\t\tif (s != NULL)\n\t\t\t*s = '/';\n\t\tfor (j = 0; bindings[j].name && bindings[j].ir; j++)\n\t\t\tif (strcmp(&argv[i][8], bindings[j].name) == 0) {\n\t\t\t\tIR = bindings[j].ir;\n\t\t\t\tbreak;\n\t\t\t}\n\t\tif (s != NULL)\n\t\t\t*s = '\\\\';\n\t}\n\tif (!IR) {\n\t\tfprint(stderr, \"%s: unknown target\", argv[0]);\n\t\tif (i > 0)\n\t\t\tfprint(stderr, \" `%s'\", &argv[i][8]);\n\t\tfprint(stderr, \"; must specify one of\\n\");\n\t\tfor (i = 0; bindings[i].name; i++)\n\t\t\tfprint(stderr, \"\\t-target=%s\\n\", bindings[i].name);\n\t\texit(EXIT_FAILURE);\n\t}\n\tinit(argc, argv);\n\tt = gettok();\n\t(*IR->progbeg)(argc, argv);\n\tif (glevel && IR->stabinit)\n\t\t(*IR->stabinit)(firstfile, argc, argv);\n\tprogram();\n\tif (events.end)\n\t\tapply(events.end, NULL, NULL);\n\tmemset(&events, 0, sizeof events);\n\tif (glevel || xref) {\n\t\tSymbol symroot = NULL;\n\t\tCoordinate src;\n\t\tforeach(types,       GLOBAL, typestab, &symroot);\n\t\tforeach(identifiers, GLOBAL, typestab, &symroot);\n\t\tsrc.file = firstfile;\n\t\tsrc.x = 0;\n\t\tsrc.y = lineno;\n\t\tif ((glevel > 2 || xref) && IR->stabend)\n\t\t\t(*IR->stabend)(&src, symroot,\n\t\t\t\tltov(&loci,    PERM),\n\t\t\t\tltov(&symbols, PERM), NULL);\n\t\telse if (IR->stabend)\n\t\t\t(*IR->stabend)(&src, NULL, NULL, NULL, NULL);\n\t}\n\tfinalize();\n\t(*IR->progend)();\n\tdeallocate(PERM);\n\treturn errcnt > 0;\n}\n/* main_init - process program arguments */\nvoid main_init(int argc, char *argv[]) {\n\tchar *infile = NULL, *outfile = NULL;\n\tint i;\n\tstatic int inited;\n\n\tif (inited)\n\t\treturn;\n\tinited = 1;\n\ttype_init(argc, argv);\n\tfor (i = 1; i < argc; i++)\n\t\tif (strcmp(argv[i], \"-g\") == 0 || strcmp(argv[i], \"-g2\") == 0)\n\t\t\tglevel = 2;\n\t\telse if (strncmp(argv[i], \"-g\", 2) == 0) {\t/* -gn[,x] */\n\t\t\tchar *p = strchr(argv[i], ',');\n\t\t\tglevel = atoi(argv[i]+2);\n\t\t\tif (p) {\n\t\t\t\tcomment = p + 1;\n\t\t\t\tif (glevel == 0)\n\t\t\t\t\tglevel = 1;\n\t\t\t\tif (stabIR.stabline == NULL) {\n\t\t\t\t\tstabIR.stabline = IR->stabline;\n\t\t\t\t\tstabIR.stabend = IR->stabend;\n\t\t\t\t\tIR->stabline = stabline;\n\t\t\t\t\tIR->stabend = stabend;\n\t\t\t\t}\n\t\t\t}\t\n\t\t} else if (strcmp(argv[i], \"-x\") == 0)\n\t\t\txref++;\n\t\telse if (strcmp(argv[i], \"-A\") == 0) {\n\t\t\t++Aflag;\n\t\t} else if (strcmp(argv[i], \"-P\") == 0)\n\t\t\tPflag++;\n\t\telse if (strcmp(argv[i], \"-w\") == 0)\n\t\t\twflag++;\n\t\telse if (strcmp(argv[i], \"-n\") == 0) {\n\t\t\tif (!YYnull) {\n\t\t\t\tYYnull = install(string(\"_YYnull\"), &globals, GLOBAL, PERM);\n\t\t\t\tYYnull->type = func(voidptype, NULL, 1);\n\t\t\t\tYYnull->sclass = EXTERN;\n\t\t\t\t(*IR->defsymbol)(YYnull);\n\t\t\t}\n\t\t} else if (strncmp(argv[i], \"-n\", 2) == 0) {\t/* -nvalid[,check] */\n\t\t\tchar *p = strchr(argv[i], ',');\n\t\t\tif (p) {\n\t\t\t\tYYcheck = install(string(p+1), &globals, GLOBAL, PERM);\n\t\t\t\tYYcheck->type = func(voidptype, NULL, 1);\n\t\t\t\tYYcheck->sclass = EXTERN;\n\t\t\t\t(*IR->defsymbol)(YYcheck);\n\t\t\t\tp = stringn(argv[i]+2, p - (argv[i]+2));\n\t\t\t} else\n\t\t\t\tp = string(argv[i]+2);\n\t\t\tYYnull = install(p, &globals, GLOBAL, PERM);\n\t\t\tYYnull->type = func(voidptype, NULL, 1);\n\t\t\tYYnull->sclass = EXTERN;\n\t\t\t(*IR->defsymbol)(YYnull);\n\t\t} else if (strcmp(argv[i], \"-v\") == 0)\n\t\t\tfprint(stderr, \"%s %s\\n\", argv[0], rcsid);\n\t\telse if (strncmp(argv[i], \"-s\", 2) == 0)\n\t\t\tdensity = strtod(&argv[i][2], NULL);\n\t\telse if (strncmp(argv[i], \"-errout=\", 8) == 0) {\n\t\t\tFILE *f = fopen(argv[i]+8, \"w\");\n\t\t\tif (f == NULL) {\n\t\t\t\tfprint(stderr, \"%s: can't write errors to `%s'\\n\", argv[0], argv[i]+8);\n\t\t\t\texit(EXIT_FAILURE);\n\t\t\t}\n\t\t\tfclose(f);\n\t\t\tf = freopen(argv[i]+8, \"w\", stderr);\n\t\t\tassert(f);\n\t\t} else if (strncmp(argv[i], \"-e\", 2) == 0) {\n\t\t\tint x;\n\t\t\tif ((x = strtol(&argv[i][2], NULL, 0)) > 0)\n\t\t\t\terrlimit = x;\n\t\t} else if (strncmp(argv[i], \"-little_endian=\", 15) == 0)\n\t\t\tIR->little_endian = argv[i][15] - '0';\n\t\telse if (strncmp(argv[i], \"-mulops_calls=\", 18) == 0)\n\t\t\tIR->mulops_calls = argv[i][18] - '0';\n\t\telse if (strncmp(argv[i], \"-wants_callb=\", 13) == 0)\n\t\t\tIR->wants_callb = argv[i][13] - '0';\n\t\telse if (strncmp(argv[i], \"-wants_argb=\", 12) == 0)\n\t\t\tIR->wants_argb = argv[i][12] - '0';\n\t\telse if (strncmp(argv[i], \"-left_to_right=\", 15) == 0)\n\t\t\tIR->left_to_right = argv[i][15] - '0';\n\t\telse if (strncmp(argv[i], \"-wants_dag=\", 11) == 0)\n\t\t\tIR->wants_dag = argv[i][11] - '0';\n\t\telse if (*argv[i] != '-' || strcmp(argv[i], \"-\") == 0) {\n\t\t\tif (infile == NULL)\n\t\t\t\tinfile = argv[i];\n\t\t\telse if (outfile == NULL)\n\t\t\t\toutfile = argv[i];\n\t\t}\n\n\tif (infile != NULL && strcmp(infile, \"-\") != 0\n\t&& freopen(infile, \"r\", stdin) == NULL) {\n\t\tfprint(stderr, \"%s: can't read `%s'\\n\", argv[0], infile);\n\t\texit(EXIT_FAILURE);\n\t}\n\tif (outfile != NULL && strcmp(outfile, \"-\") != 0\n\t&& freopen(outfile, \"w\", stdout) == NULL) {\n\t\tfprint(stderr, \"%s: can't write `%s'\\n\", argv[0], outfile);\n\t\texit(EXIT_FAILURE);\n\t}\n}\n/* typestab - emit stab entries for p */\nstatic void typestab(Symbol p, void *cl) {\n\tif (*(Symbol *)cl == 0 && p->sclass && p->sclass != TYPEDEF)\n\t\t*(Symbol *)cl = p;\n\tif ((p->sclass == TYPEDEF || p->sclass == 0) && IR->stabtype)\n\t\t(*IR->stabtype)(p);\n}\n\n/* stabline - emit source code for source coordinate *cp */\nstatic void stabline(Coordinate *cp) {\n\tif (cp->file && cp->file != currentfile) {\n\t\tif (srcfp)\n\t\t\tfclose(srcfp);\n\t\tcurrentfile = cp->file;\n\t\tsrcfp = fopen(currentfile, \"r\");\n\t\tsrcpos = 0;\n\t\tcurrentline = 0;\n\t}\n\tif (currentline != cp->y && srcfp) {\n\t\tchar buf[512];\n\t\tif (srcpos > cp->y) {\n\t\t\trewind(srcfp);\n\t\t\tsrcpos = 0;\n\t\t}\n\t\tfor ( ; srcpos < cp->y; srcpos++)\n\t\t\tif (fgets(buf, sizeof buf, srcfp) == NULL) {\n\t\t\t\tfclose(srcfp);\n\t\t\t\tsrcfp = NULL;\n\t\t\t\tbreak;\n\t\t\t}\n\t\tif (srcfp && srcpos == cp->y)\n\t\t\tprint(\"%s%s\", comment, buf);\n\t}\n\tcurrentline = cp->y;\n\tif (stabIR.stabline)\n\t\t(*stabIR.stabline)(cp);\n}\n\nstatic void stabend(Coordinate *cp, Symbol p, Coordinate **cpp, Symbol *sp, Symbol *stab) {\n\tif (stabIR.stabend)\n\t\t(*stabIR.stabend)(cp, p, cpp, sp, stab);\n\tif (srcfp)\n\t\tfclose(srcfp);\n}\n"
  },
  {
    "path": "lcc/src/mips.md",
    "content": "%{\n#define INTTMP 0x0100ff00\n#define INTVAR 0x40ff0000\n#define FLTTMP 0x000f0ff0\n#define FLTVAR 0xfff00000\n\n#define INTRET 0x00000004\n#define FLTRET 0x00000003\n\n#define readsreg(p) \\\n        (generic((p)->op)==INDIR && (p)->kids[0]->op==VREG+P)\n#define setsrc(d) ((d) && (d)->x.regnode && \\\n        (d)->x.regnode->set == src->x.regnode->set && \\\n        (d)->x.regnode->mask&src->x.regnode->mask)\n\n#define relink(a, b) ((b)->x.prev = (a), (a)->x.next = (b))\n\n#include \"c.h\"\n#define NODEPTR_TYPE Node\n#define OP_LABEL(p) ((p)->op)\n#define LEFT_CHILD(p) ((p)->kids[0])\n#define RIGHT_CHILD(p) ((p)->kids[1])\n#define STATE_LABEL(p) ((p)->x.state)\nstatic void address(Symbol, Symbol, long);\nstatic void blkfetch(int, int, int, int);\nstatic void blkloop(int, int, int, int, int, int[]);\nstatic void blkstore(int, int, int, int);\nstatic void defaddress(Symbol);\nstatic void defconst(int, int, Value);\nstatic void defstring(int, char *);\nstatic void defsymbol(Symbol);\nstatic void doarg(Node);\nstatic void emit2(Node);\nstatic void export(Symbol);\nstatic void clobber(Node);\nstatic void function(Symbol, Symbol [], Symbol [], int);\nstatic void global(Symbol);\nstatic void import(Symbol);\nstatic void local(Symbol);\nstatic void progbeg(int, char **);\nstatic void progend(void);\nstatic void segment(int);\nstatic void space(int);\nstatic void target(Node);\nstatic int      bitcount       (unsigned);\nstatic Symbol   argreg         (int, int, int, int, int);\n\nstatic Symbol ireg[32], freg2[32], d6;\nstatic Symbol iregw, freg2w;\nstatic int tmpregs[] = {3, 9, 10};\nstatic Symbol blkreg;\n\nstatic int gnum = 8;\nstatic int pic;\n\nstatic int cseg;\n%}\n%start stmt\n%term CNSTF4=4113\n%term CNSTF8=8209\n%term CNSTF16=16401\n%term CNSTI1=1045\n%term CNSTI2=2069\n%term CNSTI4=4117\n%term CNSTI8=8213\n%term CNSTP4=4119\n%term CNSTP8=8215\n%term CNSTU1=1046\n%term CNSTU2=2070\n%term CNSTU4=4118\n%term CNSTU8=8214\n \n%term ARGB=41\n%term ARGF4=4129\n%term ARGF8=8225\n%term ARGF16=16417\n%term ARGI4=4133\n%term ARGI8=8229\n%term ARGP4=4135\n%term ARGP8=8231\n%term ARGU4=4134\n%term ARGU8=8230\n\n%term ASGNB=57\n%term ASGNF4=4145\n%term ASGNF8=8241\n%term ASGNF16=16433\n%term ASGNI1=1077\n%term ASGNI2=2101\n%term ASGNI4=4149\n%term ASGNI8=8245\n%term ASGNP4=4151\n%term ASGNP8=8247\n%term ASGNU1=1078\n%term ASGNU2=2102\n%term ASGNU4=4150\n%term ASGNU8=8246\n\n%term INDIRB=73\n%term INDIRF4=4161\n%term INDIRF8=8257\n%term INDIRF16=16449\n%term INDIRI1=1093\n%term INDIRI2=2117\n%term INDIRI4=4165\n%term INDIRI8=8261\n%term INDIRP4=4167\n%term INDIRP8=8263\n%term INDIRU1=1094\n%term INDIRU2=2118\n%term INDIRU4=4166\n%term INDIRU8=8262\n\n%term CVFF4=4209\n%term CVFF8=8305\n%term CVFF16=16497\n%term CVFI4=4213\n%term CVFI8=8309\n\n%term CVIF4=4225\n%term CVIF8=8321\n%term CVIF16=16513\n%term CVII1=1157\n%term CVII2=2181\n%term CVII4=4229\n%term CVII8=8325\n%term CVIU1=1158\n%term CVIU2=2182\n%term CVIU4=4230\n%term CVIU8=8326\n\n%term CVPP4=4247\n%term CVPP8=8343\n%term CVPP16=16535\n%term CVPU4=4246\n%term CVPU8=8342\n\n%term CVUI1=1205\n%term CVUI2=2229\n%term CVUI4=4277\n%term CVUI8=8373\n%term CVUP4=4279\n%term CVUP8=8375\n%term CVUP16=16567\n%term CVUU1=1206\n%term CVUU2=2230\n%term CVUU4=4278\n%term CVUU8=8374\n\n%term NEGF4=4289\n%term NEGF8=8385\n%term NEGF16=16577\n%term NEGI4=4293\n%term NEGI8=8389\n\n%term CALLB=217\n%term CALLF4=4305\n%term CALLF8=8401\n%term CALLF16=16593\n%term CALLI4=4309\n%term CALLI8=8405\n%term CALLP4=4311\n%term CALLP8=8407\n%term CALLU4=4310\n%term CALLU8=8406\n%term CALLV=216\n\n%term RETF4=4337\n%term RETF8=8433\n%term RETF16=16625\n%term RETI4=4341\n%term RETI8=8437\n%term RETP4=4343\n%term RETP8=8439\n%term RETU4=4342\n%term RETU8=8438\n%term RETV=248\n\n%term ADDRGP4=4359\n%term ADDRGP8=8455\n\n%term ADDRFP4=4375\n%term ADDRFP8=8471\n\n%term ADDRLP4=4391\n%term ADDRLP8=8487\n\n%term ADDF4=4401\n%term ADDF8=8497\n%term ADDF16=16689\n%term ADDI4=4405\n%term ADDI8=8501\n%term ADDP4=4407\n%term ADDP8=8503\n%term ADDU4=4406\n%term ADDU8=8502\n\n%term SUBF4=4417\n%term SUBF8=8513\n%term SUBF16=16705\n%term SUBI4=4421\n%term SUBI8=8517\n%term SUBP4=4423\n%term SUBP8=8519\n%term SUBU4=4422\n%term SUBU8=8518\n\n%term LSHI4=4437\n%term LSHI8=8533\n%term LSHU4=4438\n%term LSHU8=8534\n\n%term MODI4=4453\n%term MODI8=8549\n%term MODU4=4454\n%term MODU8=8550\n\n%term RSHI4=4469\n%term RSHI8=8565\n%term RSHU4=4470\n%term RSHU8=8566\n\n%term BANDI4=4485\n%term BANDI8=8581\n%term BANDU4=4486\n%term BANDU8=8582\n\n%term BCOMI4=4501\n%term BCOMI8=8597\n%term BCOMU4=4502\n%term BCOMU8=8598\n\n%term BORI4=4517\n%term BORI8=8613\n%term BORU4=4518\n%term BORU8=8614\n\n%term BXORI4=4533\n%term BXORI8=8629\n%term BXORU4=4534\n%term BXORU8=8630\n\n%term DIVF4=4545\n%term DIVF8=8641\n%term DIVF16=16833\n%term DIVI4=4549\n%term DIVI8=8645\n%term DIVU4=4550\n%term DIVU8=8646\n\n%term MULF4=4561\n%term MULF8=8657\n%term MULF16=16849\n%term MULI4=4565\n%term MULI8=8661\n%term MULU4=4566\n%term MULU8=8662\n\n%term EQF4=4577\n%term EQF8=8673\n%term EQF16=16865\n%term EQI4=4581\n%term EQI8=8677\n%term EQU4=4582\n%term EQU8=8678\n\n%term GEF4=4593\n%term GEF8=8689\n%term GEI4=4597\n%term GEI8=8693\n%term GEI16=16885\n%term GEU4=4598\n%term GEU8=8694\n\n%term GTF4=4609\n%term GTF8=8705\n%term GTF16=16897\n%term GTI4=4613\n%term GTI8=8709\n%term GTU4=4614\n%term GTU8=8710\n\n%term LEF4=4625\n%term LEF8=8721\n%term LEF16=16913\n%term LEI4=4629\n%term LEI8=8725\n%term LEU4=4630\n%term LEU8=8726\n\n%term LTF4=4641\n%term LTF8=8737\n%term LTF16=16929\n%term LTI4=4645\n%term LTI8=8741\n%term LTU4=4646\n%term LTU8=8742\n\n%term NEF4=4657\n%term NEF8=8753\n%term NEF16=16945\n%term NEI4=4661\n%term NEI8=8757\n%term NEU4=4662\n%term NEU8=8758\n\n%term JUMPV=584\n\n%term LABELV=600\n\n%term LOADB=233\n%term LOADF4=4321\n%term LOADF8=8417\n%term LOADF16=16609\n%term LOADI1=1253\n%term LOADI2=2277\n%term LOADI4=4325\n%term LOADI8=8421\n%term LOADP4=4327\n%term LOADP8=8423\n%term LOADU1=1254\n%term LOADU2=2278\n%term LOADU4=4326\n%term LOADU8=8422\n\n%term VREGP=711\n%%\nreg:  INDIRI1(VREGP)     \"# read register\\n\"\nreg:  INDIRU1(VREGP)     \"# read register\\n\"\n\nreg:  INDIRI2(VREGP)     \"# read register\\n\"\nreg:  INDIRU2(VREGP)     \"# read register\\n\"\n\nreg:  INDIRF4(VREGP)     \"# read register\\n\"\nreg:  INDIRI4(VREGP)     \"# read register\\n\"\nreg:  INDIRP4(VREGP)     \"# read register\\n\"\nreg:  INDIRU4(VREGP)     \"# read register\\n\"\n\nreg:  INDIRF8(VREGP)     \"# read register\\n\"\nreg:  INDIRI8(VREGP)     \"# read register\\n\"\nreg:  INDIRP8(VREGP)     \"# read register\\n\"\nreg:  INDIRU8(VREGP)     \"# read register\\n\"\n\nstmt: ASGNI1(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNU1(VREGP,reg)  \"# write register\\n\"\n\nstmt: ASGNI2(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNU2(VREGP,reg)  \"# write register\\n\"\n\nstmt: ASGNF4(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNI4(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNP4(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNU4(VREGP,reg)  \"# write register\\n\"\n\nstmt: ASGNF8(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNI8(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNP8(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNU8(VREGP,reg)  \"# write register\\n\"\ncon: CNSTI1  \"%a\"\ncon: CNSTU1  \"%a\"\n\ncon: CNSTI2  \"%a\"\ncon: CNSTU2  \"%a\"\n\ncon: CNSTI4  \"%a\"\ncon: CNSTU4  \"%a\"\ncon: CNSTP4  \"%a\"\n\ncon: CNSTI8  \"%a\"\ncon: CNSTU8  \"%a\"\ncon: CNSTP8  \"%a\"\nstmt: reg  \"\"\nacon: con     \"%0\"\nacon: ADDRGP4  \"%a\"\naddr: ADDI4(reg,acon)  \"%1($%0)\"\naddr: ADDU4(reg,acon)  \"%1($%0)\"\naddr: ADDP4(reg,acon)  \"%1($%0)\"\naddr: acon  \"%0\"\naddr: reg   \"($%0)\"\naddr: ADDRFP4  \"%a+%F($sp)\"\naddr: ADDRLP4  \"%a+%F($sp)\"\nreg: addr  \"la $%c,%0\\n\"  1\nreg: CNSTI1  \"# reg\\n\"  range(a, 0, 0)\nreg: CNSTI2  \"# reg\\n\"  range(a, 0, 0)\nreg: CNSTI4  \"# reg\\n\"  range(a, 0, 0)\nreg: CNSTU1  \"# reg\\n\"  range(a, 0, 0)\nreg: CNSTU2  \"# reg\\n\"  range(a, 0, 0)\nreg: CNSTU4  \"# reg\\n\"  range(a, 0, 0)\nreg: CNSTP4  \"# reg\\n\"  range(a, 0, 0)\nstmt: ASGNI1(addr,reg)  \"sb $%1,%0\\n\"  1\nstmt: ASGNU1(addr,reg)  \"sb $%1,%0\\n\"  1\nstmt: ASGNI2(addr,reg)  \"sh $%1,%0\\n\"  1\nstmt: ASGNU2(addr,reg)  \"sh $%1,%0\\n\"  1\nstmt: ASGNI4(addr,reg)  \"sw $%1,%0\\n\"  1\nstmt: ASGNU4(addr,reg)  \"sw $%1,%0\\n\"  1\nstmt: ASGNP4(addr,reg)  \"sw $%1,%0\\n\"  1\nreg:  INDIRI1(addr)     \"lb $%c,%0\\n\"  1\nreg:  INDIRU1(addr)     \"lbu $%c,%0\\n\"  1\nreg:  INDIRI2(addr)     \"lh $%c,%0\\n\"  1\nreg:  INDIRU2(addr)     \"lhu $%c,%0\\n\"  1\nreg:  INDIRI4(addr)     \"lw $%c,%0\\n\"  1\nreg:  INDIRU4(addr)     \"lw $%c,%0\\n\"  1\nreg:  INDIRP4(addr)     \"lw $%c,%0\\n\"  1\n\nreg:  CVII4(INDIRI1(addr))     \"lb $%c,%0\\n\"  1\nreg:  CVII4(INDIRI2(addr))     \"lh $%c,%0\\n\"  1\nreg:  CVUU4(INDIRU1(addr))     \"lbu $%c,%0\\n\"  1\nreg:  CVUU4(INDIRU2(addr))     \"lhu $%c,%0\\n\"  1\nreg:  CVUI4(INDIRU1(addr))     \"lbu $%c,%0\\n\"  1\nreg:  CVUI4(INDIRU2(addr))     \"lhu $%c,%0\\n\"  1\nreg:  INDIRF4(addr)     \"l.s $f%c,%0\\n\"  1\nreg:  INDIRF8(addr)     \"l.d $f%c,%0\\n\"  1\nstmt: ASGNF4(addr,reg)  \"s.s $f%1,%0\\n\"  1\nstmt: ASGNF8(addr,reg)  \"s.d $f%1,%0\\n\"  1\nreg: DIVI4(reg,reg)  \"div $%c,$%0,$%1\\n\"   1\nreg: DIVU4(reg,reg)  \"divu $%c,$%0,$%1\\n\"  1\nreg: MODI4(reg,reg)  \"rem $%c,$%0,$%1\\n\"   1\nreg: MODU4(reg,reg)  \"remu $%c,$%0,$%1\\n\"  1\nreg: MULI4(reg,reg)  \"mul $%c,$%0,$%1\\n\"   1\nreg: MULU4(reg,reg)  \"mul $%c,$%0,$%1\\n\"   1\nrc:  con            \"%0\"\nrc:  reg            \"$%0\"\n\nreg: ADDI4(reg,rc)   \"addu $%c,$%0,%1\\n\"  1\nreg: ADDP4(reg,rc)   \"addu $%c,$%0,%1\\n\"  1\nreg: ADDU4(reg,rc)   \"addu $%c,$%0,%1\\n\"  1\nreg: BANDI4(reg,rc)  \"and $%c,$%0,%1\\n\"   1\nreg: BORI4(reg,rc)   \"or $%c,$%0,%1\\n\"    1\nreg: BXORI4(reg,rc)  \"xor $%c,$%0,%1\\n\"   1\nreg: BANDU4(reg,rc)  \"and $%c,$%0,%1\\n\"   1\nreg: BORU4(reg,rc)   \"or $%c,$%0,%1\\n\"    1\nreg: BXORU4(reg,rc)  \"xor $%c,$%0,%1\\n\"   1\nreg: SUBI4(reg,rc)   \"subu $%c,$%0,%1\\n\"  1\nreg: SUBP4(reg,rc)   \"subu $%c,$%0,%1\\n\"  1\nreg: SUBU4(reg,rc)   \"subu $%c,$%0,%1\\n\"  1\nrc5: CNSTI4         \"%a\"                range(a,0,31)\nrc5: reg            \"$%0\"\n\nreg: LSHI4(reg,rc5)  \"sll $%c,$%0,%1\\n\"  1\nreg: LSHU4(reg,rc5)  \"sll $%c,$%0,%1\\n\"  1\nreg: RSHI4(reg,rc5)  \"sra $%c,$%0,%1\\n\"  1\nreg: RSHU4(reg,rc5)  \"srl $%c,$%0,%1\\n\"  1\nreg: BCOMI4(reg)  \"not $%c,$%0\\n\"   1\nreg: BCOMU4(reg)  \"not $%c,$%0\\n\"   1\nreg: NEGI4(reg)   \"negu $%c,$%0\\n\"  1\nreg: LOADI1(reg)  \"move $%c,$%0\\n\"  move(a)\nreg: LOADU1(reg)  \"move $%c,$%0\\n\"  move(a)\nreg: LOADI2(reg)  \"move $%c,$%0\\n\"  move(a)\nreg: LOADU2(reg)  \"move $%c,$%0\\n\"  move(a)\nreg: LOADI4(reg)  \"move $%c,$%0\\n\"  move(a)\nreg: LOADP4(reg)  \"move $%c,$%0\\n\"  move(a)\nreg: LOADU4(reg)  \"move $%c,$%0\\n\"  move(a)\nreg: ADDF4(reg,reg)  \"add.s $f%c,$f%0,$f%1\\n\"  1\nreg: ADDF8(reg,reg)  \"add.d $f%c,$f%0,$f%1\\n\"  1\nreg: DIVF4(reg,reg)  \"div.s $f%c,$f%0,$f%1\\n\"  1\nreg: DIVF8(reg,reg)  \"div.d $f%c,$f%0,$f%1\\n\"  1\nreg: MULF4(reg,reg)  \"mul.s $f%c,$f%0,$f%1\\n\"  1\nreg: MULF8(reg,reg)  \"mul.d $f%c,$f%0,$f%1\\n\"  1\nreg: SUBF4(reg,reg)  \"sub.s $f%c,$f%0,$f%1\\n\"  1\nreg: SUBF8(reg,reg)  \"sub.d $f%c,$f%0,$f%1\\n\"  1\nreg: LOADF4(reg)     \"mov.s $f%c,$f%0\\n\"       move(a)\nreg: LOADF8(reg)     \"mov.d $f%c,$f%0\\n\"       move(a)\nreg: NEGF4(reg)      \"neg.s $f%c,$f%0\\n\"       1\nreg: NEGF8(reg)      \"neg.d $f%c,$f%0\\n\"       1\nreg: CVII4(reg)  \"sll $%c,$%0,8*(4-%a); sra $%c,$%c,8*(4-%a)\\n\"  2\nreg: CVUI4(reg)  \"and $%c,$%0,(1<<(8*%a))-1\\n\"  1\nreg: CVUU4(reg)  \"and $%c,$%0,(1<<(8*%a))-1\\n\"  1\nreg: CVFF4(reg)  \"cvt.s.d $f%c,$f%0\\n\"  1\nreg: CVFF8(reg)  \"cvt.d.s $f%c,$f%0\\n\"  1\nreg: CVIF4(reg)  \"mtc1 $%0,$f%c; cvt.s.w $f%c,$f%c\\n\"  2\nreg: CVIF8(reg)  \"mtc1 $%0,$f%c; cvt.d.w $f%c,$f%c\\n\"  2\nreg: CVFI4(reg)  \"trunc.w.s $f2,$f%0,$%c; mfc1 $%c,$f2\\n\"  (a->syms[0]->u.c.v.i==4?2:LBURG_MAX)\nreg: CVFI4(reg)  \"trunc.w.d $f2,$f%0,$%c; mfc1 $%c,$f2\\n\"  (a->syms[0]->u.c.v.i==8?2:LBURG_MAX)\nstmt: LABELV  \"%a:\\n\"\nstmt: JUMPV(acon)  \"b %0\\n\"   1\nstmt: JUMPV(reg)   \".cpadd $%0\\nj $%0\\n\"  !pic\nstmt: JUMPV(reg)   \"j $%0\\n\"  pic\nstmt: EQI4(reg,reg)  \"beq $%0,$%1,%a\\n\"   1\nstmt: EQU4(reg,reg)  \"beq $%0,$%1,%a\\n\"   1\nstmt: GEI4(reg,reg)  \"bge $%0,$%1,%a\\n\"   1\nstmt: GEU4(reg,reg)  \"bgeu $%0,$%1,%a\\n\"  1\nstmt: GTI4(reg,reg)  \"bgt $%0,$%1,%a\\n\"   1\nstmt: GTU4(reg,reg)  \"bgtu $%0,$%1,%a\\n\"  1\nstmt: LEI4(reg,reg)  \"ble $%0,$%1,%a\\n\"   1\nstmt: LEU4(reg,reg)  \"bleu $%0,$%1,%a\\n\"  1\nstmt: LTI4(reg,reg)  \"blt $%0,$%1,%a\\n\"   1\nstmt: LTU4(reg,reg)  \"bltu $%0,$%1,%a\\n\"  1\nstmt: NEI4(reg,reg)  \"bne $%0,$%1,%a\\n\"   1\nstmt: NEU4(reg,reg)  \"bne $%0,$%1,%a\\n\"   1\nstmt: EQF4(reg,reg)  \"c.eq.s $f%0,$f%1; bc1t %a\\n\"  2\nstmt: EQF8(reg,reg)  \"c.eq.d $f%0,$f%1; bc1t %a\\n\"  2\nstmt: LEF4(reg,reg)  \"c.le.s $f%0,$f%1; bc1t %a\\n\"  2\nstmt: LEF8(reg,reg)  \"c.le.d $f%0,$f%1; bc1t %a\\n\"  2\nstmt: LTF4(reg,reg)  \"c.lt.s $f%0,$f%1; bc1t %a\\n\"  2\nstmt: LTF8(reg,reg)  \"c.lt.d $f%0,$f%1; bc1t %a\\n\"  2\nstmt: GEF4(reg,reg)  \"c.lt.s $f%0,$f%1; bc1f %a\\n\"  2\nstmt: GEF8(reg,reg)  \"c.lt.d $f%0,$f%1; bc1f %a\\n\"  2\nstmt: GTF4(reg,reg)  \"c.le.s $f%0,$f%1; bc1f %a\\n\"  2\nstmt: GTF8(reg,reg)  \"c.le.d $f%0,$f%1; bc1f %a\\n\"  2\nstmt: NEF4(reg,reg)  \"c.eq.s $f%0,$f%1; bc1f %a\\n\"  2\nstmt: NEF8(reg,reg)  \"c.eq.d $f%0,$f%1; bc1f %a\\n\"  2\nar:   ADDRGP4     \"%a\"\n\nreg:  CALLF4(ar)  \"jal %0\\n\"  1\nreg:  CALLF8(ar)  \"jal %0\\n\"  1\nreg:  CALLI4(ar)  \"jal %0\\n\"  1\nreg:  CALLP4(ar)  \"jal %0\\n\"  1\nreg:  CALLU4(ar)  \"jal %0\\n\"  1\nstmt: CALLV(ar)  \"jal %0\\n\"  1\nar: reg    \"$%0\"\nar: CNSTP4  \"%a\"   range(a, 0, 0x0fffffff)\nstmt: RETF4(reg)  \"# ret\\n\"  1\nstmt: RETF8(reg)  \"# ret\\n\"  1\nstmt: RETI4(reg)  \"# ret\\n\"  1\nstmt: RETU4(reg)  \"# ret\\n\"  1\nstmt: RETP4(reg)  \"# ret\\n\"  1\nstmt: RETV(reg)   \"# ret\\n\"  1\nstmt: ARGF4(reg)  \"# arg\\n\"  1\nstmt: ARGF8(reg)  \"# arg\\n\"  1\nstmt: ARGI4(reg)  \"# arg\\n\"  1\nstmt: ARGP4(reg)  \"# arg\\n\"  1\nstmt: ARGU4(reg)  \"# arg\\n\"  1\n\nstmt: ARGB(INDIRB(reg))       \"# argb %0\\n\"      1\nstmt: ASGNB(reg,INDIRB(reg))  \"# asgnb %0 %1\\n\"  1\n%%\nstatic void progend(void){}\nstatic void progbeg(int argc, char *argv[]) {\n        int i;\n\n        {\n                union {\n                        char c;\n                        int i;\n                } u;\n                u.i = 0;\n                u.c = 1;\n                swap = ((int)(u.i == 1)) != IR->little_endian;\n        }\n        print(\".set reorder\\n\");\n        pic = !IR->little_endian;\n        parseflags(argc, argv);\n        for (i = 0; i < argc; i++)\n                if (strncmp(argv[i], \"-G\", 2) == 0)\n                        gnum = atoi(argv[i] + 2);\n                else if (strcmp(argv[i], \"-pic=1\") == 0\n                ||       strcmp(argv[i], \"-pic=0\") == 0)\n                        pic = argv[i][5]-'0';\n        for (i = 0; i < 31; i += 2)\n                freg2[i] = mkreg(\"%d\", i, 3, FREG);\n        for (i = 0; i < 32; i++)\n                ireg[i]  = mkreg(\"%d\", i, 1, IREG);\n        ireg[29]->x.name = \"sp\";\n        d6 = mkreg(\"6\", 6, 3, IREG);\n        freg2w = mkwildcard(freg2);\n        iregw = mkwildcard(ireg);\n        tmask[IREG] = INTTMP; tmask[FREG] = FLTTMP;\n        vmask[IREG] = INTVAR; vmask[FREG] = FLTVAR;\n        blkreg = mkreg(\"8\", 8, 7, IREG);\n}\nstatic Symbol rmap(int opk) {\n        switch (optype(opk)) {\n        case I: case U: case P: case B:\n                return iregw;\n        case F:\n                return freg2w;\n        default:\n                return 0;\n        }\n}\nstatic void target(Node p) {\n        assert(p);\n        switch (specific(p->op)) {\n        case CNST+I: case CNST+U: case CNST+P:\n                if (range(p, 0, 0) == 0) {\n                        setreg(p, ireg[0]);\n                        p->x.registered = 1;\n                }\n                break;\n        case CALL+V:\n                rtarget(p, 0, ireg[25]);\n                break;\n        case CALL+F:\n                rtarget(p, 0, ireg[25]);\n                setreg(p, freg2[0]);\n                break;\n        case CALL+I: case CALL+P: case CALL+U:\n                rtarget(p, 0, ireg[25]);\n                setreg(p, ireg[2]);\n                break;\n        case RET+F:\n                rtarget(p, 0, freg2[0]);\n                break;\n        case RET+I: case RET+U: case RET+P:\n                rtarget(p, 0, ireg[2]);\n                break;\n        case ARG+F: case ARG+I: case ARG+P: case ARG+U: {\n                static int ty0;\n                int ty = optype(p->op);\n                Symbol q;\n\n                q = argreg(p->x.argno, p->syms[2]->u.c.v.i, ty, opsize(p->op), ty0);\n                if (p->x.argno == 0)\n                        ty0 = ty;\n                if (q &&\n                !(ty == F && q->x.regnode->set == IREG))\n                        rtarget(p, 0, q);\n                break;\n                }\n        case ASGN+B: rtarget(p->kids[1], 0, blkreg); break;\n        case ARG+B:  rtarget(p->kids[0], 0, blkreg); break;\n        }\n}\nstatic void clobber(Node p) {\n        assert(p);\n        switch (specific(p->op)) {\n        case CALL+F:\n                spill(INTTMP | INTRET, IREG, p);\n                spill(FLTTMP,          FREG, p);\n                break;\n        case CALL+I: case CALL+P: case CALL+U:\n                spill(INTTMP,          IREG, p);\n                spill(FLTTMP | FLTRET, FREG, p);\n                break;\n        case CALL+V:\n                spill(INTTMP | INTRET, IREG, p);\n                spill(FLTTMP | FLTRET, FREG, p);\n                break;\n        }\n}\nstatic void emit2(Node p) {\n        int dst, n, src, sz, ty;\n        static int ty0;\n        Symbol q;\n\n        switch (specific(p->op)) {\n        case ARG+F: case ARG+I: case ARG+P: case ARG+U:\n                ty = optype(p->op);\n                sz = opsize(p->op);\n                if (p->x.argno == 0)\n                        ty0 = ty;\n                q = argreg(p->x.argno, p->syms[2]->u.c.v.i, ty, sz, ty0);\n                src = getregnum(p->x.kids[0]);\n                if (q == NULL && ty == F && sz == 4)\n                        print(\"s.s $f%d,%d($sp)\\n\", src, p->syms[2]->u.c.v.i);\n                else if (q == NULL && ty == F)\n                        print(\"s.d $f%d,%d($sp)\\n\", src, p->syms[2]->u.c.v.i);\n                else if (q == NULL)\n                        print(\"sw $%d,%d($sp)\\n\", src, p->syms[2]->u.c.v.i);\n                else if (ty == F && sz == 4 && q->x.regnode->set == IREG)\n                        print(\"mfc1 $%d,$f%d\\n\", q->x.regnode->number, src);\n                else if (ty == F && q->x.regnode->set == IREG)\n                        print(\"mfc1.d $%d,$f%d\\n\", q->x.regnode->number, src);\n                break;\n        case ASGN+B:\n                dalign = salign = p->syms[1]->u.c.v.i;\n                blkcopy(getregnum(p->x.kids[0]), 0,\n                        getregnum(p->x.kids[1]), 0,\n                        p->syms[0]->u.c.v.i, tmpregs);\n                break;\n        case ARG+B:\n                dalign = 4;\n                salign = p->syms[1]->u.c.v.i;\n                blkcopy(29, p->syms[2]->u.c.v.i,\n                        getregnum(p->x.kids[0]), 0,\n                        p->syms[0]->u.c.v.i, tmpregs);\n                n   = p->syms[2]->u.c.v.i + p->syms[0]->u.c.v.i;\n                dst = p->syms[2]->u.c.v.i;\n                for ( ; dst <= 12 && dst < n; dst += 4)\n                        print(\"lw $%d,%d($sp)\\n\", (dst/4)+4, dst);\n                break;\n        }\n}\nstatic Symbol argreg(int argno, int offset, int ty, int sz, int ty0) {\n        assert((offset&3) == 0);\n        if (offset > 12)\n                return NULL;\n        else if (argno == 0 && ty == F)\n                return freg2[12];\n        else if (argno == 1 && ty == F && ty0 == F)\n                return freg2[14];\n        else if (argno == 1 && ty == F && sz == 8)\n                return d6;  /* Pair! */\n        else\n                return ireg[(offset/4) + 4];\n}\nstatic void doarg(Node p) {\n        static int argno;\n        int align;\n\n        if (argoffset == 0)\n                argno = 0;\n        p->x.argno = argno++;\n        align = p->syms[1]->u.c.v.i < 4 ? 4 : p->syms[1]->u.c.v.i;\n        p->syms[2] = intconst(mkactual(align,\n                p->syms[0]->u.c.v.i));\n}\nstatic void local(Symbol p) {\n        if (askregvar(p, rmap(ttob(p->type))) == 0)\n                mkauto(p);\n}\nstatic void function(Symbol f, Symbol caller[], Symbol callee[], int ncalls) {\n        int i, saved, sizefsave, sizeisave, varargs;\n        Symbol r, argregs[4];\n\n        usedmask[0] = usedmask[1] = 0;\n        freemask[0] = freemask[1] = ~(unsigned)0;\n        offset = maxoffset = maxargoffset = 0;\n        for (i = 0; callee[i]; i++)\n                ;\n        varargs = variadic(f->type)\n                || i > 0 && strcmp(callee[i-1]->name, \"va_alist\") == 0;\n        for (i = 0; callee[i]; i++) {\n                Symbol p = callee[i];\n                Symbol q = caller[i];\n                assert(q);\n                offset = roundup(offset, q->type->align);\n                p->x.offset = q->x.offset = offset;\n                p->x.name = q->x.name = stringd(offset);\n                r = argreg(i, offset, optype(ttob(q->type)), q->type->size, optype(ttob(caller[0]->type)));\n                if (i < 4)\n                        argregs[i] = r;\n                offset = roundup(offset + q->type->size, 4);\n                if (varargs)\n                        p->sclass = AUTO;\n                else if (r && ncalls == 0 &&\n                         !isstruct(q->type) && !p->addressed &&\n                         !(isfloat(q->type) && r->x.regnode->set == IREG)\n) {\n                        p->sclass = q->sclass = REGISTER;\n                        askregvar(p, r);\n                        assert(p->x.regnode && p->x.regnode->vbl == p);\n                        q->x = p->x;\n                        q->type = p->type;\n                }\n                else if (askregvar(p, rmap(ttob(p->type)))\n                         && r != NULL\n                         && (isint(p->type) || p->type == q->type)) {\n                        assert(q->sclass != REGISTER);\n                        p->sclass = q->sclass = REGISTER;\n                        q->type = p->type;\n                }\n        }\n        assert(!caller[i]);\n        offset = 0;\n        gencode(caller, callee);\n        if (ncalls)\n                usedmask[IREG] |= ((unsigned)1)<<31;\n        usedmask[IREG] &= 0xc0ff0000;\n        usedmask[FREG] &= 0xfff00000;\n        if (pic && ncalls)\n                usedmask[IREG] |= 1<<25;\n        maxargoffset = roundup(maxargoffset, usedmask[FREG] ? 8 : 4);\n        if (ncalls && maxargoffset < 16)\n                maxargoffset = 16;\n        sizefsave = 4*bitcount(usedmask[FREG]);\n        sizeisave = 4*bitcount(usedmask[IREG]);\n        framesize = roundup(maxargoffset + sizefsave\n                + sizeisave + maxoffset, 8);\n        segment(CODE);\n        print(\".align 2\\n\");\n        print(\".ent %s\\n\", f->x.name);\n        print(\"%s:\\n\", f->x.name);\n        i = maxargoffset + sizefsave - framesize;\n        print(\".frame $sp,%d,$31\\n\", framesize);\n        if (pic)\n                print(\".set noreorder\\n.cpload $25\\n.set reorder\\n\");\n        if (framesize > 0)\n                print(\"addu $sp,$sp,%d\\n\", -framesize);\n        if (usedmask[FREG])\n                print(\".fmask 0x%x,%d\\n\", usedmask[FREG], i - 8);\n        if (usedmask[IREG])\n                print(\".mask 0x%x,%d\\n\",  usedmask[IREG],\n                        i + sizeisave - 4);\n        saved = maxargoffset;\n        for (i = 20; i <= 30; i += 2)\n                if (usedmask[FREG]&(3<<i)) {\n                        print(\"s.d $f%d,%d($sp)\\n\", i, saved);\n                        saved += 8;\n                }\n\n        for (i = 16; i <= 31; i++)\n                if (usedmask[IREG]&(1<<i)) {\n                        if (i == 25)\n                                print(\".cprestore %d\\n\", saved);\n                        else\n                                print(\"sw $%d,%d($sp)\\n\", i, saved);\n                        saved += 4;\n                }\n        for (i = 0; i < 4 && callee[i]; i++) {\n                r = argregs[i];\n                if (r && r->x.regnode != callee[i]->x.regnode) {\n                        Symbol out = callee[i];\n                        Symbol in  = caller[i];\n                        int rn = r->x.regnode->number;\n                        int rs = r->x.regnode->set;\n                        int tyin = ttob(in->type);\n\n                        assert(out && in && r && r->x.regnode);\n                        assert(out->sclass != REGISTER || out->x.regnode);\n                        if (out->sclass == REGISTER\n                        && (isint(out->type) || out->type == in->type)) {\n                                int outn = out->x.regnode->number;\n                                if (rs == FREG && tyin == F+sizeop(8))\n                                        print(\"mov.d $f%d,$f%d\\n\", outn, rn);\n                                else if (rs == FREG && tyin == F+sizeop(4))\n                                        print(\"mov.s $f%d,$f%d\\n\", outn, rn);\n                                else if (rs == IREG && tyin == F+sizeop(8))\n                                        print(\"mtc1.d $%d,$f%d\\n\", rn,   outn);\n                                else if (rs == IREG && tyin == F+sizeop(4))\n                                        print(\"mtc1 $%d,$f%d\\n\",   rn,   outn);\n                                else\n                                        print(\"move $%d,$%d\\n\",    outn, rn);\n                        } else {\n                                int off = in->x.offset + framesize;\n                                if (rs == FREG && tyin == F+sizeop(8))\n                                        print(\"s.d $f%d,%d($sp)\\n\", rn, off);\n                                else if (rs == FREG && tyin == F+sizeop(4))\n                                        print(\"s.s $f%d,%d($sp)\\n\", rn, off);\n                                else {\n                                        int i, n = (in->type->size + 3)/4;\n                                        for (i = rn; i < rn+n && i <= 7; i++)\n                                                print(\"sw $%d,%d($sp)\\n\", i, off + (i-rn)*4);\n                                }\n                        }\n                }\n        }\n        if (varargs && callee[i-1]) {\n                i = callee[i-1]->x.offset + callee[i-1]->type->size;\n                for (i = roundup(i, 4)/4; i <= 3; i++)\n                        print(\"sw $%d,%d($sp)\\n\", i + 4, framesize + 4*i);\n                }\n        emitcode();\n        saved = maxargoffset;\n        for (i = 20; i <= 30; i += 2)\n                if (usedmask[FREG]&(3<<i)) {\n                        print(\"l.d $f%d,%d($sp)\\n\", i, saved);\n                        saved += 8;\n                }\n        for (i = 16; i <= 31; i++)\n                if (usedmask[IREG]&(1<<i)) {\n                        print(\"lw $%d,%d($sp)\\n\", i, saved);\n                        saved += 4;\n                }\n        if (framesize > 0)\n                print(\"addu $sp,$sp,%d\\n\", framesize);\n        print(\"j $31\\n\");\n        print(\".end %s\\n\", f->x.name);\n}\nstatic void defconst(int suffix, int size, Value v) {\n        if (suffix == F && size == 4) {\n                float f = v.d;\n                print(\".word 0x%x\\n\", *(unsigned *)&f);\n        }\n        else if (suffix == F && size == 8) {\n                double d = v.d;\n                unsigned *p = (unsigned *)&d;\n                print(\".word 0x%x\\n.word 0x%x\\n\", p[swap], p[!swap]);\n        }\n        else if (suffix == P)\n                print(\".word 0x%x\\n\", v.p);\n        else if (size == 1)\n                print(\".byte 0x%x\\n\", suffix == I ? v.i : v.u);\n        else if (size == 2)\n                print(\".half 0x%x\\n\", suffix == I ? v.i : v.u);\n        else if (size == 4)\n                print(\".word 0x%x\\n\", suffix == I ? v.i : v.u);\n}\nstatic void defaddress(Symbol p) {\n        if (pic && p->scope == LABELS)\n                print(\".gpword %s\\n\", p->x.name);\n        else\n                print(\".word %s\\n\", p->x.name);\n}\nstatic void defstring(int n, char *str) {\n        char *s;\n\n        for (s = str; s < str + n; s++)\n                print(\".byte %d\\n\", (*s)&0377);\n}\nstatic void export(Symbol p) {\n        print(\".globl %s\\n\", p->x.name);\n}\nstatic void import(Symbol p) {\n        if (!isfunc(p->type))\n                print(\".extern %s %d\\n\", p->name, p->type->size);\n}\nstatic void defsymbol(Symbol p) {\n        if (p->scope >= LOCAL && p->sclass == STATIC)\n                p->x.name = stringf(\"L.%d\", genlabel(1));\n        else if (p->generated)\n                p->x.name = stringf(\"L.%s\", p->name);\n        else\n                assert(p->scope != CONSTANTS || isint(p->type) || isptr(p->type)),\n                p->x.name = p->name;\n}\nstatic void address(Symbol q, Symbol p, long n) {\n        if (p->scope == GLOBAL\n        || p->sclass == STATIC || p->sclass == EXTERN)\n                q->x.name = stringf(\"%s%s%D\", p->x.name,\n                        n >= 0 ? \"+\" : \"\", n);\n        else {\n                assert(n <= INT_MAX && n >= INT_MIN);\n                q->x.offset = p->x.offset + n;\n                q->x.name = stringd(q->x.offset);\n        }\n}\nstatic void global(Symbol p) {\n        if (p->u.seg == BSS) {\n                if (p->sclass == STATIC || Aflag >= 2)\n                        print(\".lcomm %s,%d\\n\", p->x.name, p->type->size);\n                else\n                        print( \".comm %s,%d\\n\", p->x.name, p->type->size);\n        } else {\n                if (p->u.seg == DATA\n                && (p->type->size == 0 || p->type->size > gnum))\n                        print(\".data\\n\");\n                else if (p->u.seg == DATA)\n                        print(\".sdata\\n\");\n                print(\".align %c\\n\", \".01.2...3\"[p->type->align]);\n                print(\"%s:\\n\", p->x.name);\n        }\n}\nstatic void segment(int n) {\n        cseg = n;\n        switch (n) {\n        case CODE: print(\".text\\n\");  break;\n        case LIT:  print(\".rdata\\n\"); break;\n        }\n}\nstatic void space(int n) {\n        if (cseg != BSS)\n                print(\".space %d\\n\", n);\n}\nstatic void blkloop(int dreg, int doff, int sreg, int soff, int size, int tmps[]) {\n        int lab = genlabel(1);\n\n        print(\"addu $%d,$%d,%d\\n\", sreg, sreg, size&~7);\n        print(\"addu $%d,$%d,%d\\n\", tmps[2], dreg, size&~7);\n        blkcopy(tmps[2], doff, sreg, soff, size&7, tmps);\n        print(\"L.%d:\\n\", lab);\n        print(\"addu $%d,$%d,%d\\n\", sreg, sreg, -8);\n        print(\"addu $%d,$%d,%d\\n\", tmps[2], tmps[2], -8);\n        blkcopy(tmps[2], doff, sreg, soff, 8, tmps);\n        print(\"bltu $%d,$%d,L.%d\\n\", dreg, tmps[2], lab);\n}\nstatic void blkfetch(int size, int off, int reg, int tmp) {\n        assert(size == 1 || size == 2 || size == 4);\n        if (size == 1)\n                print(\"lbu $%d,%d($%d)\\n\",  tmp, off, reg);\n        else if (salign >= size && size == 2)\n                print(\"lhu $%d,%d($%d)\\n\",  tmp, off, reg);\n        else if (salign >= size)\n                print(\"lw $%d,%d($%d)\\n\",   tmp, off, reg);\n        else if (size == 2)\n                print(\"ulhu $%d,%d($%d)\\n\", tmp, off, reg);\n        else\n                print(\"ulw $%d,%d($%d)\\n\",  tmp, off, reg);\n}\nstatic void blkstore(int size, int off, int reg, int tmp) {\n        if (size == 1)\n                print(\"sb $%d,%d($%d)\\n\",  tmp, off, reg);\n        else if (dalign >= size && size == 2)\n                print(\"sh $%d,%d($%d)\\n\",  tmp, off, reg);\n        else if (dalign >= size)\n                print(\"sw $%d,%d($%d)\\n\",  tmp, off, reg);\n        else if (size == 2)\n                print(\"ush $%d,%d($%d)\\n\", tmp, off, reg);\n        else\n                print(\"usw $%d,%d($%d)\\n\", tmp, off, reg);\n}\nstatic void stabinit(char *, int, char *[]);\nstatic void stabline(Coordinate *);\nstatic void stabsym(Symbol);\n\nstatic char *currentfile;\n\nstatic int bitcount(unsigned mask) {\n        unsigned i, n = 0;\n\n        for (i = 1; i; i <<= 1)\n                if (mask&i)\n                        n++;\n        return n;\n}\n\n/* stabinit - initialize stab output */\nstatic void stabinit(char *file, int argc, char *argv[]) {\n        if (file) {\n                print(\".file 2,\\\"%s\\\"\\n\", file);\n                currentfile = file;\n        }\n}\n\n/* stabline - emit stab entry for source coordinate *cp */\nstatic void stabline(Coordinate *cp) {\n        if (cp->file && cp->file != currentfile) {\n                print(\".file 2,\\\"%s\\\"\\n\", cp->file);\n                currentfile = cp->file;\n        }\n        print(\".loc 2,%d\\n\", cp->y);\n}\n\n/* stabsym - output a stab entry for symbol p */\nstatic void stabsym(Symbol p) {\n        if (p == cfunc && IR->stabline)\n                (*IR->stabline)(&p->src);\n}\nInterface mipsebIR = {\n        1, 1, 0,  /* char */\n        2, 2, 0,  /* short */\n        4, 4, 0,  /* int */\n        4, 4, 0,  /* long */\n        4, 4, 0,  /* long long */\n        4, 4, 1,  /* float */\n        8, 8, 1,  /* double */\n        8, 8, 1,  /* long double */\n        4, 4, 0,  /* T * */\n        0, 1, 0,  /* struct */\n        0,      /* little_endian */\n        0,  /* mulops_calls */\n        0,  /* wants_callb */\n        1,  /* wants_argb */\n        1,  /* left_to_right */\n        0,  /* wants_dag */\n        0,  /* unsigned_char */\n        address,\n        blockbeg,\n        blockend,\n        defaddress,\n        defconst,\n        defstring,\n        defsymbol,\n        emit,\n        export,\n        function,\n        gen,\n        global,\n        import,\n        local,\n        progbeg,\n        progend,\n        segment,\n        space,\n        0, 0, 0, stabinit, stabline, stabsym, 0,\n        {\n                4,      /* max_unaligned_load */\n                rmap,\n                blkfetch, blkstore, blkloop,\n                _label,\n                _rule,\n                _nts,\n                _kids,\n                _string,\n                _templates,\n                _isinstruction,\n                _ntname,\n                emit2,\n                doarg,\n                target,\n                clobber,\n\n        }\n}, mipselIR = {\n        1, 1, 0,  /* char */\n        2, 2, 0,  /* short */\n        4, 4, 0,  /* int */\n        4, 4, 0,  /* long */\n        4, 4, 0,  /* long long */\n        4, 4, 1,  /* float */\n        8, 8, 1,  /* double */\n        8, 8, 1,  /* long double */\n        4, 4, 0,  /* T * */\n        0, 1, 0,  /* struct */\n        1,      /* little_endian */\n        0,  /* mulops_calls */\n        0,  /* wants_callb */\n        1,  /* wants_argb */\n        1,  /* left_to_right */\n        0,  /* wants_dag */\n        0,  /* unsigned_char */\n        address,\n        blockbeg,\n        blockend,\n        defaddress,\n        defconst,\n        defstring,\n        defsymbol,\n        emit,\n        export,\n        function,\n        gen,\n        global,\n        import,\n        local,\n        progbeg,\n        progend,\n        segment,\n        space,\n        0, 0, 0, stabinit, stabline, stabsym, 0,\n        {\n                4,      /* max_unaligned_load */\n                rmap,\n                blkfetch, blkstore, blkloop,\n                _label,\n                _rule,\n                _nts,\n                _kids,\n                _string,\n                _templates,\n                _isinstruction,\n                _ntname,\n                emit2,\n                doarg,\n                target,\n                clobber,\n\n        }\n};\nstatic char rcsid[] = \"$Id: mips.md 145 2001-10-17 21:53:10Z timo $\";\n"
  },
  {
    "path": "lcc/src/null.c",
    "content": "#include \"c.h\"\n#define I(f) null_##f\n\nstatic Node I(gen)(Node p) { return p; }\nstatic void I(address)(Symbol q, Symbol p, long n) {}\nstatic void I(blockbeg)(Env *e) {}\nstatic void I(blockend)(Env *e) {}\nstatic void I(defaddress)(Symbol p) {}\nstatic void I(defconst)(int suffix, int size, Value v) {}\nstatic void I(defstring)(int len, char *s) {}\nstatic void I(defsymbol)(Symbol p) {}\nstatic void I(emit)(Node p) {}\nstatic void I(export)(Symbol p) {}\nstatic void I(function)(Symbol f, Symbol caller[], Symbol callee[], int ncalls) {}\nstatic void I(global)(Symbol p) {}\nstatic void I(import)(Symbol p) {}\nstatic void I(local)(Symbol p) {}\nstatic void I(progbeg)(int argc, char *argv[]) {}\nstatic void I(progend)(void) {}\nstatic void I(segment)(int s) {}\nstatic void I(space)(int n) {}\nstatic void I(stabblock)(int brace, int lev, Symbol *p) {}\nstatic void I(stabend)(Coordinate *cp, Symbol p, Coordinate **cpp, Symbol *sp, Symbol *stab) {}\nstatic void I(stabfend)(Symbol p, int lineno) {}\nstatic void I(stabinit)(char *file, int argc, char *argv[]) {}\nstatic void I(stabline)(Coordinate *cp) {}\nstatic void I(stabsym)(Symbol p) {}\nstatic void I(stabtype)(Symbol p) {}\n\n\nInterface nullIR = {\n\t1, 1, 0,\t/* char */\n\t2, 2, 0,\t/* short */\n\t4, 4, 0,\t/* int */\n\t8, 8, 1,\t/* long */\n\t8 ,8, 1,\t/* long long */\n\t4, 4, 1,\t/* float */\n\t8, 8, 1,\t/* double */\n\t16,16,1,\t/* long double */\n\t4, 4, 0,\t/* T* */\n\t0, 4, 0,\t/* struct */\n\t1,\t\t/* little_endian */\n\t0,\t\t/* mulops_calls */\n\t0,\t\t/* wants_callb */\n\t0,\t\t/* wants_argb */\n\t1,\t\t/* left_to_right */\n\t0,\t\t/* wants_dag */\n\t0,\t\t/* unsigned_char */\n\tI(address),\n\tI(blockbeg),\n\tI(blockend),\n\tI(defaddress),\n\tI(defconst),\n\tI(defstring),\n\tI(defsymbol),\n\tI(emit),\n\tI(export),\n\tI(function),\n\tI(gen),\n\tI(global),\n\tI(import),\n\tI(local),\n\tI(progbeg),\n\tI(progend),\n\tI(segment),\n\tI(space),\n\tI(stabblock),\n\tI(stabend),\n\tI(stabfend),\n\tI(stabinit),\n\tI(stabline),\n\tI(stabsym),\n\tI(stabtype)\n};\n"
  },
  {
    "path": "lcc/src/output.c",
    "content": "#include \"c.h\"\n\n\nstatic char *outs(const char *str, FILE *f, char *bp) {\n\tif (f)\n\t\tfputs(str, f);\n\telse\n\t\twhile (*bp = *str++)\n\t\t\tbp++;\n\treturn bp;\n}\n\nstatic char *outd(long n, FILE *f, char *bp) {\n\tunsigned long m;\n\tchar buf[25], *s = buf + sizeof buf;\n\n\t*--s = '\\0';\n\tif (n < 0)\n\t\tm = -n;\n\telse\n\t\tm = n;\n\tdo\n\t\t*--s = m%10 + '0';\n\twhile ((m /= 10) != 0);\n\tif (n < 0)\n\t\t*--s = '-';\n\treturn outs(s, f, bp);\n}\n\nstatic char *outu(unsigned long n, int base, FILE *f, char *bp) {\n\tchar buf[25], *s = buf + sizeof buf;\n\n\t*--s = '\\0';\n\tdo\n\t\t*--s = \"0123456789abcdef\"[n%base];\n\twhile ((n /= base) != 0);\n\treturn outs(s, f, bp);\n}\nvoid print(const char *fmt, ...) {\n\tva_list ap;\n\n\tva_start(ap, fmt);\n\tvfprint(stdout, NULL, fmt, ap);\n\tva_end(ap);\n}\n/* fprint - formatted output to  f */\nvoid fprint(FILE *f, const char *fmt, ...) {\n\tva_list ap;\n\n\tva_start(ap, fmt);\n\tvfprint(f, NULL, fmt, ap);\n\tva_end(ap);\n}\n\n/* stringf - formatted output to a saved string */\nchar *stringf(const char *fmt, ...) {\n\tchar buf[1024];\n\tva_list ap;\n\n\tva_start(ap, fmt);\n\tvfprint(NULL, buf, fmt, ap);\n\tva_end(ap);\n\treturn string(buf);\n}\n\n/* vfprint - formatted output to f or string bp */\nvoid vfprint(FILE *f, char *bp, const char *fmt, va_list ap) {\n\tfor (; *fmt; fmt++)\n\t\tif (*fmt == '%')\n\t\t\tswitch (*++fmt) {\n\t\t\tcase 'd': bp = outd(va_arg(ap, int), f, bp); break;\n\t\t\tcase 'D': bp = outd(va_arg(ap, long), f, bp); break;\n\t\t\tcase 'U': bp = outu(va_arg(ap, unsigned long), 10, f, bp); break;\n\t\t\tcase 'u': bp = outu(va_arg(ap, unsigned), 10, f, bp); break;\n\t\t\tcase 'o': bp = outu(va_arg(ap, unsigned), 8, f, bp); break;\n\t\t\tcase 'X': bp = outu(va_arg(ap, unsigned long), 16, f, bp); break;\n\t\t\tcase 'x': bp = outu(va_arg(ap, unsigned), 16, f, bp); break;\n\t\t\tcase 'f': case 'e':\n\t\t\tcase 'g': {\n\t\t\t\t  \tstatic char format[] = \"%f\";\n\t\t\t\t  \tchar buf[128];\n\t\t\t\t  \tformat[1] = *fmt;\n\t\t\t\t  \tsprintf(buf, format, va_arg(ap, double));\n\t\t\t\t  \tbp = outs(buf, f, bp);\n\t\t\t\t  }\n; break;\n\t\t\tcase 's': bp = outs(va_arg(ap, char *), f, bp); break;\n\t\t\tcase 'p': {\n\t\t\t\tvoid *p = va_arg(ap, void *);\n\t\t\t\tif (p)\n\t\t\t\t\tbp = outs(\"0x\", f, bp);\n\t\t\t\tbp = outu((unsigned long)p, 16, f, bp);\n\t\t\t\tbreak;\n\t\t\t\t  }\n\t\t\tcase 'c': if (f) fputc(va_arg(ap, int), f); else *bp++ = va_arg(ap, int); break;\n\t\t\tcase 'S': { char *s = va_arg(ap, char *);\n\t\t\t\t    int n = va_arg(ap, int);\n\t\t\t\t    if (s)\n\t\t\t\t    \tfor ( ; n-- > 0; s++)\n\t\t\t\t    \t\tif (f) (void)putc(*s, f); else *bp++ = *s;\n } break;\n\t\t\tcase 'k': { int t = va_arg(ap, int);\n\t\t\t\t    static char *tokens[] = {\n#define xx(a,b,c,d,e,f,g) g,\n#define yy(a,b,c,d,e,f,g) g,\n#include \"token.h\"\n\t\t\t\t    };\n\t\t\t\t    assert(tokens[t&0177]);\n\t\t\t\t    bp = outs(tokens[t&0177], f, bp);\n } break;\n\t\t\tcase 't': { Type ty = va_arg(ap, Type);\n\t\t\t\t    assert(f);\n\t\t\t\t    outtype(ty ? ty : voidtype, f);\n } break;\n\t\t\tcase 'w': { Coordinate *p = va_arg(ap, Coordinate *);\n\t\t\t\t    if (p->file && *p->file) {\n\t\t\t\t    \tbp = outs(p->file, f, bp);\n\t\t\t\t    \tbp = outs(\":\", f, bp);\n\t\t\t\t    }\n\t\t\t\t    bp = outd(p->y, f, bp);\n } break;\n\t\t\tcase 'I': { int n = va_arg(ap, int);\n\t\t\t\t    while (--n >= 0)\n\t\t\t\t    \tif (f) (void)putc(' ', f); else *bp++ = ' ';\n } break;\n\t\t\tdefault:  if (f) (void)putc(*fmt, f); else *bp++ = *fmt; break;\n\t\t\t}\n\t\telse if (f)\n\t\t\t(void)putc(*fmt, f);\n\t\telse\n\t\t\t*bp++ = *fmt;\n\tif (!f)\n\t\t*bp = '\\0';\n}\n"
  },
  {
    "path": "lcc/src/pass2.c",
    "content": "#include \"c.h\"\n#include \"rcc.h\"\n#if WIN32\n#include <fcntl.h>\n#include <io.h>\n#endif\n\n\nInterface *IR = NULL;\nint Aflag;\t\t/* >= 0 if -A specified */\nint Pflag;\t\t/* != 0 if -P specified */\nint glevel;\t\t/* == [0-9] if -g[0-9] specified */\nint xref;\t\t/* != 0 for cross-reference data */\nSymbol YYnull;\t\t/* _YYnull  symbol if -n or -nvalidate specified */\nSymbol YYcheck;\t\t/* _YYcheck symbol if -nvalidate,check specified */\n\nstatic int verbose = 1;\n#define VERBOSE(n,arg) (verbose >= n ? (void)(arg):(void)0)\nstatic int nuids;\nstatic rcc_item_ty *items;\nstatic void **itemmap;\n\nstatic void *uid2type(int uid) {\n\tassert(uid >= 0 && uid < nuids);\n\tif (itemmap[uid] == NULL) {\n\t\tType ty;\n\t\trcc_type_ty type = (void *)items[uid];\n\t\tassert(items[uid]);\n\t\tassert(items[uid]->uid == uid);\n\t\tassert(items[uid]->kind == rcc_Type_enum);\n\t\ttype = items[uid]->v.rcc_Type.type;\n\t\tassert(type);\n\t\tswitch (type->kind) {\n\t\tcase rcc_INT_enum:\n\t\t\tty = btot(INT, type->size);\n\t\t\tassert(ty->align == type->align);\n\t\t\tbreak;\n\t\tcase rcc_UNSIGNED_enum:\n\t\t\tty = btot(UNSIGNED, type->size);\n\t\t\tassert(ty->align == type->align);\n\t\t\tbreak;\n\t\tcase rcc_FLOAT_enum:\n\t\t\tty = btot(FLOAT, type->size);\n\t\t\tassert(ty->align == type->align);\n\t\t\tbreak;\n\t\tcase rcc_VOID_enum:\n\t\t\tty = voidtype;\n\t\t\tbreak;\n\t\tcase rcc_POINTER_enum:\n\t\t\tty = ptr(uid2type(type->v.rcc_POINTER.type));\n\t\t\tbreak;\n\t\tcase rcc_ARRAY_enum:\n\t\t\tty = uid2type(type->v.rcc_ARRAY.type);\n\t\t\tassert(ty->size > 0);\n\t\t\tty = array(ty, type->size/ty->size, 0);\n\t\t\tbreak;\n\t\tcase rcc_CONST_enum:\n\t\t\tty = qual(CONST, uid2type(type->v.rcc_CONST.type));\n\t\t\tbreak;\n\t\tcase rcc_VOLATILE_enum:\n\t\t\tty = qual(VOLATILE, uid2type(type->v.rcc_VOLATILE.type));\n\t\t\tbreak;\n\t\tcase rcc_ENUM_enum: {\n\t\t\tint i, n = Seq_length(type->v.rcc_ENUM.ids);\n\t\t\tty = newstruct(ENUM, string(type->v.rcc_ENUM.tag));\n\t\t\tty->type = inttype;\n\t\t\tty->size = ty->type->size;\n\t\t\tty->align = ty->type->align;\n\t\t\tty->u.sym->u.idlist = newarray(n + 1, sizeof *ty->u.sym->u.idlist, PERM);\n\t\t\tfor (i = 0; i < n; i++) {\n\t\t\t\trcc_enum__ty e = Seq_remlo(type->v.rcc_ENUM.ids);\n\t\t\t\tSymbol p = install(e->id, &identifiers, GLOBAL, PERM);\n\t\t\t\tp->type = ty;\n\t\t\t\tp->sclass = ENUM;\n\t\t\t\tp->u.value = e->value;\n\t\t\t\tty->u.sym->u.idlist[i] = p;\n\t\t\t\tfree(e);\n\t\t\t}\n\t\t\tty->u.sym->u.idlist[i] = NULL;\n\t\t\tSeq_free(&type->v.rcc_ENUM.ids);\n\t\t\tbreak;\n\t\t\t}\n\t\tcase rcc_STRUCT_enum: case rcc_UNION_enum: {\n\t\t\tint i, n;\n\t\t\tField *tail;\n\t\t\tlist_ty fields;\n\t\t\tif (type->kind == rcc_STRUCT_enum) {\n\t\t\t\tty = newstruct(STRUCT, string(type->v.rcc_STRUCT.tag));\n\t\t\t\tfields = type->v.rcc_STRUCT.fields;\n\t\t\t} else {\n\t\t\t\tty = newstruct(UNION, string(type->v.rcc_UNION.tag));\n\t\t\t\tfields = type->v.rcc_UNION.fields;\n\t\t\t}\n\t\t\titemmap[uid] = ty;\t/* recursive types */\n\t\t\tty->size = type->size;\n\t\t\tty->align = type->align;\n\t\t\ttail = &ty->u.sym->u.s.flist;\n\t\t\tn = Seq_length(fields);\n\t\t\tfor (i = 0; i < n; i++) {\n\t\t\t\trcc_field_ty field = Seq_remlo(fields);\n\t\t\t\tNEW0(*tail, PERM);\n\t\t\t\t(*tail)->name = (char *)field->id;\n\t\t\t\t(*tail)->type = uid2type(field->type);\n\t\t\t\t(*tail)->offset = field->offset;\n\t\t\t\t(*tail)->bitsize = field->bitsize;\n\t\t\t\t(*tail)->lsb = field->lsb;\n\t\t\t\tif (isconst((*tail)->type))\n\t\t\t\t\tty->u.sym->u.s.cfields = 1;\n\t\t\t\tif (isvolatile((*tail)->type))\n\t\t\t\t\tty->u.sym->u.s.vfields = 1;\n\t\t\t\ttail = &(*tail)->link;\n\t\t\t\tfree(field);\n\t\t\t}\n\t\t\tSeq_free(&fields);\n\t\t\tbreak;\n\t\t\t}\n\t\tcase rcc_FUNCTION_enum: {\n\t\t\tint n = Seq_length(type->v.rcc_FUNCTION.formals);\n\t\t\tif (n > 0) {\n\t\t\t\tint i;\n\t\t\t\tType *proto = newarray(n + 1, sizeof *proto, PERM);\n\t\t\t\tfor (i = 0; i < n; i++) {\n\t\t\t\t\tint *formal = Seq_remlo(type->v.rcc_FUNCTION.formals);\n\t\t\t\t\tproto[i] = uid2type(*formal);\n\t\t\t\t\tfree(formal);\n\t\t\t\t}\n\t\t\t\tproto[i] = NULL;\n\t\t\t\tty = func(uid2type(type->v.rcc_FUNCTION.type), proto, 0);\n\t\t\t} else\n\t\t\t\tty = func(uid2type(type->v.rcc_FUNCTION.type), NULL, 1);\n\t\t\tSeq_free(&type->v.rcc_FUNCTION.formals);\n\t\t\tbreak;\n\t\t\t}\n\t\tdefault: assert(0);\n\t\t}\n\t\tif (itemmap[uid] == NULL) {\n\t\t\titemmap[uid] = ty;\n\t\t\tfree(type);\n\t\t\tfree(items[uid]);\n\t\t\titems[uid] = NULL;\n\t\t} else\n\t\t\tassert(itemmap[uid] == ty);\n\t}\n\treturn itemmap[uid];\n}\n\nstatic Symbol uid2symbol(int uid) {\n\tassert(uid >= 0 && uid < nuids);\n\tif (itemmap[uid] == NULL) {\n\t\tSymbol p;\n\t\trcc_symbol_ty symbol;\n\t\tassert(items[uid]);\n\t\tassert(items[uid]->uid == uid);\n\t\tassert(items[uid]->kind == rcc_Symbol_enum);\n\t\tsymbol = items[uid]->v.rcc_Symbol.symbol;\n\t\tassert(symbol);\n\t\tNEW0(p, PERM);\n\t\tp->name = (char *)symbol->id;\n\t\tp->scope = symbol->scope;\n\t\tp->sclass = symbol->sclass;\n\t\tp->type = uid2type(symbol->type);\n#define xx(f,n) p->f = symbol->flags>>n;\n\t\txx(structarg,0)\n\t\txx(addressed,1)\n\t\txx(computed,2)\n\t\txx(temporary,3)\n\t\txx(generated,4)\n#undef xx\n\t\tp->ref = symbol->ref/10000.0;\n\t\tassert(p->scope != CONSTANTS && p->scope != LABELS);\n\t\tif (p->scope == GLOBAL || p->sclass == STATIC || p->sclass == EXTERN)\n\t\t\t(*IR->defsymbol)(p);\n\t\titemmap[uid] = p;\n\t\tfree(symbol);\n\t\tfree(items[uid]);\n\t\titems[uid] = NULL;\n\t}\n\treturn itemmap[uid];\n}\n\n#define xx(s) static void do##s(rcc_interface_ty);\nxx(Export)\nxx(Import)\nxx(Global)\nxx(Local)\nxx(Address)\nxx(Segment)\nxx(Defaddress)\nxx(Deflabel)\nxx(Defconst)\nxx(Defconstf)\nxx(Defstring)\nxx(Space)\nxx(Function)\nxx(Blockbeg)\nxx(Blockend)\nxx(Forest)\n#undef xx\nstatic void (*doX[])(rcc_interface_ty in) = {\n#define xx(s) 0,\nxx(Export)\nxx(Import)\nxx(Global)\nxx(Local)\nxx(Address)\nxx(Segment)\nxx(Defaddress)\nxx(Deflabel)\nxx(Defconst)\nxx(Defconstf)\nxx(Defstring)\nxx(Space)\nxx(Function)\nxx(Blockbeg)\nxx(Blockend)\nxx(Forest)\n\t0\n#undef xx\n};\n\nstatic void interface(rcc_interface_ty in) {\n\tassert(in);\n\t(*doX[in->kind])(in);\n\tfree(in);\n}\n\nstatic void doExport(rcc_interface_ty in) {\n\t(*IR->export)(uid2symbol(in->v.rcc_Export.p));\n}\n\nstatic void doImport(rcc_interface_ty in) {\n\tSymbol p = uid2symbol(in->v.rcc_Export.p);\n\n\t(*IR->import)(p);\n\tp->defined = 1;\n}\n\nstatic void doGlobal(rcc_interface_ty in) {\n\tSymbol p = uid2symbol(in->v.rcc_Global.p);\n\n\tp->u.seg = in->v.rcc_Global.seg;\n\t(*IR->global)(p);\n\tp->defined = 1;\n}\n\nstatic void doLocal(rcc_interface_ty in) {\n\tint uid = in->v.rcc_Local.uid;\n\n\tassert(uid >= 0 && uid < nuids);\n\tassert(items[uid] == NULL);\n\titems[uid] = rcc_Symbol(uid, in->v.rcc_Local.p);\n\tif (in->v.rcc_Local.p->scope >= LOCAL)\n\t\taddlocal(uid2symbol(uid));\n}\n\nstatic void doAddress(rcc_interface_ty in) {\n\tint uid = in->v.rcc_Address.uid;\n\tSymbol p = uid2symbol(in->v.rcc_Address.p);\n\n\tassert(uid >= 0 && uid < nuids);\n\tassert(items[uid] == NULL);\n\titems[uid] = rcc_Symbol(uid, in->v.rcc_Address.q);\n\tif (p->scope == GLOBAL || p->sclass == STATIC || p->sclass == EXTERN)\n\t\t(*IR->address)(uid2symbol(uid), p, in->v.rcc_Address.n);\n\telse {\n\t\tCode cp = code(Address);\n\t\tcp->u.addr.sym = uid2symbol(uid);\n\t\tcp->u.addr.base = p;\n\t\tcp->u.addr.offset = in->v.rcc_Address.n;\n\t}\n}\n\nstatic void doSegment(rcc_interface_ty in) {\n\t(*IR->segment)(in->v.rcc_Segment.seg);\n}\n\nstatic void doDefaddress(rcc_interface_ty in) {\n\t(*IR->defaddress)(uid2symbol(in->v.rcc_Defaddress.p));\n}\n\nstatic void doDeflabel(rcc_interface_ty in) {\n\t(*IR->defaddress)(findlabel(in->v.rcc_Deflabel.label));\n}\n\nstatic void doDefconst(rcc_interface_ty in) {\n\tValue v;\n\n\tv.i = in->v.rcc_Defconst.value;\n\t(*IR->defconst)(in->v.rcc_Defconst.suffix, in->v.rcc_Defconst.size, v);\n}\n\nstatic void doDefconstf(rcc_interface_ty in) {\n\tValue v;\n\tunsigned *p = (unsigned *)&v.d;\n\n\tp[swap]   = in->v.rcc_Defconstf.value->msb;\n\tp[1-swap] = in->v.rcc_Defconstf.value->lsb;\n\t(*IR->defconst)(F, in->v.rcc_Defconstf.size, v);\n\tfree(in->v.rcc_Defconstf.value);\n}\n\nstatic void doDefstring(rcc_interface_ty in) {\n\t(*IR->defstring)(in->v.rcc_Defstring.s.len, (char *)in->v.rcc_Defstring.s.str);\n\tfree((char *)in->v.rcc_Defstring.s.str);\n}\n\nstatic void doSpace(rcc_interface_ty in) {\n\t(*IR->space)(in->v.rcc_Space.n);\n}\n\nstatic void doFunction(rcc_interface_ty in) {\n\tint i, n;\n\tSymbol *caller, *callee;\n\n\t/*\n\t Initialize:\n\t  define the function symbol,\n\t  initialize callee and caller arrays.\n\t*/\n\tcfunc = uid2symbol(in->v.rcc_Function.f);\n\tlabels = table(NULL, LABELS);\n\tenterscope();\n\tn = Seq_length(in->v.rcc_Function.caller);\n\tcaller = newarray(n + 1, sizeof *caller, FUNC);\n\tfor (i = 0; i < n; i++) {\n\t\tint *uid = Seq_remlo(in->v.rcc_Function.caller);\n\t\tcaller[i] = uid2symbol(*uid);\n\t\tfree(uid);\n\t}\n\tcaller[i] = NULL;\n\tSeq_free(&in->v.rcc_Function.caller);\n\tcallee = newarray(n + 1, sizeof *callee, FUNC);\n\tfor (i = 0; i < n; i++) {\n\t\tint *uid = Seq_remlo(in->v.rcc_Function.callee);\n\t\tcallee[i] = uid2symbol(*uid);\n\t\tfree(uid);\n\t}\n\tcallee[i] = NULL;\n\tSeq_free(&in->v.rcc_Function.callee);\n\tcfunc->u.f.callee = callee;\n\tcfunc->defined = 1;\n\t/*\n\t Initialize the code list,\n\t  traverse the interfaces inside the function;\n\t  each call appends code list entries.\n\t*/\n\tcodelist = &codehead;\n\tcodelist->next = NULL;\n\tn = Seq_length(in->v.rcc_Function.codelist);\n\tfor (i = 0; i < n; i++)\n\t\tinterface(Seq_remlo(in->v.rcc_Function.codelist));\n\tSeq_free(&in->v.rcc_Function.codelist);\n\t/*\n\t Call the back end,\n\t Wrap-up.\n\t*/\n\texitscope();\n\t(*IR->function)(cfunc, caller, callee, in->v.rcc_Function.ncalls);\n\tcfunc = NULL;\n\tlabels = NULL;\n}\n\nstatic struct block {\n\tCode begin;\n\tstruct block *prev;\n} *blockstack = NULL;\n\nstatic void doBlockbeg(rcc_interface_ty in) {\n\tstruct block *b;\n\tCode cp = code(Blockbeg);\n\n\tenterscope();\n\tcp->u.block.level = level;\n\tcp->u.block.locals = newarray(1, sizeof *cp->u.block.locals, FUNC);\n\tcp->u.block.locals[0] = NULL;\n\tcp->u.block.identifiers = NULL;\n\tcp->u.block.types = NULL;\n\tNEW(b, FUNC);\n\tb->begin = cp;\n\tb->prev = blockstack;\n\tblockstack = b;\n}\n\nstatic void doBlockend(rcc_interface_ty in) {\n\tassert(blockstack);\n\tcode(Blockend)->u.begin = blockstack->begin;\n\tblockstack = blockstack->prev;\n\texitscope();\n}\n\nstatic Node visit(rcc_node_ty node) {\n\tint op;\n\tNode left = NULL, right = NULL, p = NULL;\n\tSymbol sym = NULL;\n\n\tswitch (node->kind) {\n#define T(x) rcc_##x##_enum\n\tcase T(CSE): {\n\t\tSymbol q = uid2symbol(node->v.rcc_CSE.uid);\n\t\tassert(q->temporary);\n\t\tq->u.t.cse = p = visit(node->v.rcc_CSE.node);\n\t\tbreak;\n\t\t}\n\tcase T(CNST): {\n\t\tValue v;\n\t\tv.i = node->v.rcc_CNST.value;\n\t\tsym = constant(btot(node->suffix, node->size), v);\n\t\top = CNST;\n\t\tbreak;\n\t\t}\n\tcase T(CNSTF): {\n\t\tValue v;\n\t\tunsigned *p = (unsigned *)&v.d;\n\t\tp[swap]   = node->v.rcc_CNSTF.value->msb;\n\t\tp[1-swap] = node->v.rcc_CNSTF.value->lsb;\n\t\tsym = constant(btot(node->suffix, node->size), v);\n\t\tfree(node->v.rcc_CNSTF.value);\n\t\top = CNST;\n\t\tbreak;\n\t\t}\n\tcase T(ARG):\n\t\tp = newnode(ARG + node->suffix + sizeop(node->size),\n\t\t\tvisit(node->v.rcc_ARG.left), NULL,\n\t\t\tintconst(node->v.rcc_ARG.len));\n\t\tp->syms[1] = intconst(node->v.rcc_ARG.align);\n\t\tbreak;\n\tcase T(ASGN):\n\t\tp = newnode(ASGN + node->suffix + sizeop(node->size),\n\t\t\tvisit(node->v.rcc_ASGN.left), visit(node->v.rcc_ASGN.right),\n\t\t\tintconst(node->v.rcc_ASGN.len));\n\t\tp->syms[1] = intconst(node->v.rcc_ASGN.align);\n\t\tbreak;\n\tcase T(CVT):\n\t\top = node->v.rcc_CVT.op;\n\t\tleft = visit(node->v.rcc_CVT.left);\n\t\tsym = intconst(node->v.rcc_CVT.fromsize);\n\t\tbreak;\n\tcase T(CALL):\n\t\top = CALL;\n\t\tleft = visit(node->v.rcc_CALL.left);\n\t\tNEW0(sym, FUNC);\n\t\tsym->type = uid2type(node->v.rcc_CALL.type);\n\t\tbreak;\n\tcase T(CALLB):\n\t\top = CALL;\n\t\tleft  = visit(node->v.rcc_CALLB.left);\n\t\tright = visit(node->v.rcc_CALLB.right);\n\t\tNEW0(sym, FUNC);\n\t\tsym->type = uid2type(node->v.rcc_CALLB.type);\n\t\tbreak;\n\tcase T(RET):\n\t\top = RET;\n\t\tbreak;\n\tcase T(ADDRG):\n\t\top = ADDRG;\n\t\tsym = uid2symbol(node->v.rcc_ADDRG.uid);\n\t\tbreak;\n\tcase T(ADDRL):\n\t\top = ADDRL;\n\t\tsym = uid2symbol(node->v.rcc_ADDRG.uid);\n\t\tbreak;\n\tcase T(ADDRF):\n\t\top = ADDRF;\n\t\tsym = uid2symbol(node->v.rcc_ADDRG.uid);\n\t\tbreak;\n\tcase T(Unary):\n\t\top = node->v.rcc_Unary.op;\n\t\tleft = visit(node->v.rcc_Unary.left);\n\t\tbreak;\n\tcase T(Binary):\n\t\top = node->v.rcc_Binary.op;\n\t\tleft  = visit(node->v.rcc_Binary.left);\n\t\tright = visit(node->v.rcc_Binary.right);\n\t\tbreak;\n\tcase T(Compare):\n\t\top = node->v.rcc_Compare.op;\n\t\tleft  = visit(node->v.rcc_Compare.left);\n\t\tright = visit(node->v.rcc_Compare.right);\n\t\tsym = findlabel(node->v.rcc_Compare.label);\n\t\tbreak;\n\tcase T(LABEL):\n\t\top = LABEL;\n\t\tsym = findlabel(node->v.rcc_LABEL.label);\n\t\tbreak;\n\tcase T(BRANCH):\n\t\top = JUMP;\n\t\tleft = newnode(ADDRG+P+sizeop(voidptype->size), NULL, NULL, findlabel(node->v.rcc_BRANCH.label));\n\t\tbreak;\n#undef T\n\tdefault: assert(0);\n\t}\n\tif (p == NULL)\n\t\tp = newnode(op + node->suffix + sizeop(node->size), left, right, sym);\n\tfree(node);\n\treturn p;\n}\n\nstatic void doForest(rcc_interface_ty in) {\n\tNode *tail = &code(Gen)->u.forest;\n\tint i, n = Seq_length(in->v.rcc_Forest.nodes);\n\n\tfor (i = 0; i < n; i++) {\n\t\t*tail = visit(Seq_remlo(in->v.rcc_Forest.nodes));\n\t\tassert(*tail);\n\t\ttail = &(*tail)->link;\n\t}\n\t*tail = NULL;\n\tSeq_free(&in->v.rcc_Forest.nodes);\n}\n\nint main(int argc, char *argv[]) {\n\tint i, version;\n\tfloat stamp = (assert(strstr(rcsid, \",v\")), strtod(strstr(rcsid, \",v\")+2, NULL))\n;\n\tchar *infile = NULL, *outfile = NULL;\n\trcc_program_ty pickle;\n\n\tfor (i = 1; i < argc; i++)\n\t\tif (*argv[i] != '-' || strcmp(argv[i], \"-\") == 0) {\n\t\t\tif (infile == NULL)\n\t\t\t\tinfile = argv[i];\n\t\t\telse if (outfile == NULL)\n\t\t\t\toutfile = argv[i];\n\t\t}\n\tif (infile != NULL && strcmp(infile, \"-\") != 0\n\t&& freopen(infile, \"rb\", stdin) == NULL) {\n\t\tfprint(stderr, \"%s: can't read `%s'\\n\", argv[0], infile);\n\t\texit(EXIT_FAILURE);\n\t}\n#if WIN32\n\telse\n\t\t_setmode(_fileno(stdin), _O_BINARY);\n#endif\n\tif (outfile != NULL && strcmp(outfile, \"-\") != 0\n\t&& freopen(outfile, \"w\", stdout) == NULL) {\n\t\tfprint(stderr, \"%s: can't write `%s'\\n\", argv[0], outfile);\n\t\texit(EXIT_FAILURE);\n\t}\n\tversion = read_int(stdin);\n\tassert(version/100 == (int)stamp);\n\tpickle = rcc_read_program(stdin);\n\targc = pickle->argc;\n\targv = newarray(argc + 1, sizeof *argv, PERM);\n\t{\n\t\tfor (i = 0; i < argc; i++) {\n\t\t\tstring_ty *arg = Seq_remlo(pickle->argv);\n\t\t\targv[i] = (char *)arg->str;\n\t\t\tfree(arg);\n\t\t}\n\t\targv[i] = NULL;\n\t\tassert(i == argc);\n\t\tSeq_free(&pickle->argv);\n\t}\n\tfor (i = argc - 1; i > 0; i--)\n\t\tif (strncmp(argv[i], \"-target=\", 8) == 0)\n\t\t\tbreak;\n\tif (i > 0) {\n\t\tint j;\n\t\tfor (j = 0; bindings[j].name && bindings[j].ir; j++)\n\t\t\tif (strcmp(&argv[i][8], bindings[j].name) == 0) {\n\t\t\t\tIR = bindings[j].ir;\n\t\t\t\tbreak;\n\t\t\t}\n\t}\n\tif (!IR) {\n\t\tfprint(stderr, \"%s: unknown target\", argv[0]);\n\t\tif (i > 0)\n\t\t\tfprint(stderr, \" `%s'\", &argv[i][8]);\n\t\tfprint(stderr, \"; must specify one of\\n\");\n\t\tfor (i = 0; bindings[i].name; i++)\n\t\t\tfprint(stderr, \"\\t-target=%s\\n\", bindings[i].name);\n\t\texit(EXIT_FAILURE);\n\t}\n\tIR->wants_dag = 0;\t/* pickle's hold trees */\n\tinit(argc, argv);\n\tgenlabel(pickle->nlabels);\n\tlevel = GLOBAL;\n\t{\n\t\tint i, count;\n\t\tnuids = pickle->nuids;\n\t\titems = newarray(nuids, sizeof *items, PERM);\n\t\titemmap = newarray(nuids, sizeof *items, PERM);\n\t\tfor (i = 0; i < nuids; i++) {\n\t\t\titemmap[i] = NULL;\n\t\t\titems[i] = NULL;\n\t\t}\n\t\t(*IR->progbeg)(argc, argv);\n\t\tcount = Seq_length(pickle->items);\n\t\tfor (i = 0; i < count; i++) {\n\t\t\trcc_item_ty item = Seq_remlo(pickle->items);\n\t\t\tint uid = item->uid;\n\t\t\tassert(uid >= 0 && uid < nuids);\n\t\t\tassert(items[uid] == NULL);\n\t\t\titems[uid] = item;\n\t\t}\n\t\tSeq_free(&pickle->items);\n#define xx(s) assert(rcc_##s##_enum < sizeof doX/sizeof doX[0] && doX[rcc_##s##_enum]==0); \\\n\t      doX[rcc_##s##_enum] = do##s;\n\t      xx(Export)\n\t      xx(Import)\n\t      xx(Global)\n\t      xx(Local)\n\t      xx(Address)\n\t      xx(Segment)\n\t      xx(Defaddress)\n\t      xx(Deflabel)\n\t      xx(Defconst)\n\t      xx(Defconstf)\n\t      xx(Defstring)\n\t      xx(Space)\n\t      xx(Function)\n\t      xx(Blockbeg)\n\t      xx(Blockend)\n\t      xx(Forest)\n#undef xx\n\t\tcount = Seq_length(pickle->interfaces);\n\t\tfor (i = 0; i < count; i++)\n\t\t\tinterface(Seq_remlo(pickle->interfaces));\n\t\tSeq_free(&pickle->interfaces);\n\t\tfree(pickle);\n\t\t(*IR->progend)();\n\t}\n\tdeallocate(PERM);\n\treturn errcnt > 0;\n}\n\n/* main_init - process program arguments */\nvoid main_init(int argc, char *argv[]) {\n\tint i;\n\tstatic int inited;\n\n\tif (inited)\n\t\treturn;\n\tinited = 1;\n\tfor (i = 1; i < argc; i++)\n\t\tif (strcmp(argv[i], \"-g\") == 0 || strcmp(argv[i], \"-g2\") == 0)\n\t\t\tglevel = 2;\n\t\telse if (strcmp(argv[i], \"-w\") == 0)\n\t\t\twflag++;\n\t\telse if (strcmp(argv[i], \"-v\") == 0) {\n\t\t\tfprint(stderr, \"%s %s\\n\", argv[0], rcsid);\n\t\t\tverbose++;\n\t\t} else if (strncmp(argv[i], \"-errout=\", 8) == 0) {\n\t\t\tFILE *f = fopen(argv[i]+8, \"w\");\n\t\t\tif (f == NULL) {\n\t\t\t\tfprint(stderr, \"%s: can't write errors to `%s'\\n\", argv[0], argv[i]+8);\n\t\t\t\texit(EXIT_FAILURE);\n\t\t\t}\n\t\t\tfclose(f);\n\t\t\tf = freopen(argv[i]+8, \"w\", stderr);\n\t\t\tassert(f);\n\t\t} else if (strncmp(argv[i], \"-e\", 2) == 0) {\n\t\t\tint x;\n\t\t\tif ((x = strtol(&argv[i][2], NULL, 0)) > 0)\n\t\t\t\terrlimit = x;\n\t\t}\n}\n\nvoid init(int argc, char *argv[]) {\n\t{extern void main_init(int, char *[]); main_init(argc, argv);}\n\t{extern void prof_init(int, char *[]); prof_init(argc, argv);}\n\t{extern void trace_init(int, char *[]); trace_init(argc, argv);}\n\t{extern void type_init(int, char *[]); type_init(argc, argv);}\n\t{extern void x86linux_init(int, char *[]); x86linux_init(argc, argv);}\n}\n"
  },
  {
    "path": "lcc/src/prof.c",
    "content": "#include \"c.h\"\n\n\nstruct callsite {\n\tchar *file, *name;\n\tunion coordinate {\n\t\tunsigned int coord;\n\t\tstruct { unsigned int y:16,x:10,index:6; } le;\n\t\tstruct { unsigned int index:6,x:10,y:16; } be;\n\t} u;\n};\nstruct func {\n\tstruct func *link;\n\tstruct caller *callers;\n\tchar *name;\n\tunion coordinate src;\n};\nstruct map {\t\t/* source code map; 200 coordinates/map */\n\tint size;\n\tunion coordinate u[200];\n};\n\nint npoints;\t\t/* # of execution points if -b specified */\nint ncalled = -1;\t/* #times prof.out says current function was called */\nstatic Symbol YYlink;\t/* symbol for file's struct _bbdata */\nstatic Symbol YYcounts;\t/* symbol for _YYcounts if -b specified */\nstatic List maplist;\t/* list of struct map *'s */\nstatic List filelist;\t/* list of file names */\nstatic Symbol funclist;\t/* list of struct func *'s */\nstatic Symbol afunc;\t/* current function's struct func */\n\n/* bbcall - build tree to set _callsite at call site *cp, emit call site data */\nstatic void bbcall(Symbol yycounts, Coordinate *cp, Tree *e) {\n\tstatic Symbol caller;\n\tValue v;\n\tunion coordinate u;\n\tSymbol p = genident(STATIC, array(voidptype, 0, 0), GLOBAL);\n\tTree t = *e;\n\n\tdefglobal(p, LIT);\n\tdefpointer(cp->file ? mkstr(cp->file)->u.c.loc : (Symbol)0);\n\tdefpointer(mkstr(cfunc->name)->u.c.loc);\n\tif (IR->little_endian) {\n\t\tu.le.x = cp->x;\n\t\tu.le.y = cp->y;\n\t} else {\n\t\tu.be.x = cp->x;\n\t\tu.be.y = cp->y;\n\t}\n\t(*IR->defconst)(U, unsignedtype->size, (v.u = u.coord, v));\n\tif (caller == 0) {\n\t\tcaller = mksymbol(EXTERN, \"_caller\", ptr(voidptype));\n\t\tcaller->defined = 0;\n\t}\n\tif (generic((*e)->op) != CALL)\n\t\tt = (*e)->kids[0];\n\tassert(generic(t->op) == CALL);\n\tt = tree(t->op, t->type,\n\t\ttree(RIGHT, t->kids[0]->type,\n\t\t\tt->kids[0],\n\t\t\ttree(RIGHT, t->kids[0]->type, asgn(caller, idtree(p)), t->kids[0])),\n\t\tt->kids[1]);\n\tif (generic((*e)->op) != CALL)\n\t\tt = tree((*e)->op, (*e)->type, t, (*e)->kids[1]);\n\t*e = t;\n}\n\n/* bbentry - return tree for _prologue(&afunc, &YYlink)' */\nstatic void bbentry(Symbol yylink, Symbol f) {\n\tstatic Symbol prologue;\n\t\n\tafunc = genident(STATIC, array(voidptype, 4, 0), GLOBAL);\n\tif (prologue == 0) {\n\t\tprologue = mksymbol(EXTERN, \"_prologue\", ftype(inttype, voidptype));\n\t\tprologue->defined = 0;\n\t}\n\twalk(vcall(prologue, voidtype, pointer(idtree(afunc)), pointer(idtree(yylink)), NULL), 0, 0);\n\n}\n\n/* bbexit - return tree for _epilogue(&afunc)' */\nstatic void bbexit(Symbol yylink, Symbol f, Tree e) {\n\tstatic Symbol epilogue;\n\t\n\tif (epilogue == 0) {\n\t\tepilogue = mksymbol(EXTERN, \"_epilogue\", ftype(inttype, voidptype));\n\t\tepilogue->defined = 0;\n\t}\n\twalk(vcall(epilogue, voidtype, pointer(idtree(afunc)), NULL), 0, 0);\n}\n\n/* bbfile - add file to list of file names, return its index */\nstatic int bbfile(char *file) {\n\tif (file) {\n\t\tList lp;\n\t\tint i = 1;\n\t\tif ((lp = filelist) != NULL)\n\t\t\tdo {\n\t\t\t\tlp = lp->link;\n\t\t\t\tif (((Symbol)lp->x)->u.c.v.p == file)\n\t\t\t\t\treturn i;\n\t\t\t\ti++;\n\t\t\t} while (lp != filelist);\n\t\tfilelist = append(mkstr(file), filelist);\n\t\treturn i;\n\t}\n\treturn 0;\n}\n\n/* bbfunc - emit function name and src coordinates */\nstatic void bbfunc(Symbol yylink, Symbol f) {\n\tValue v;\n\tunion coordinate u;\n\n\tdefglobal(afunc, DATA);\n\tdefpointer(funclist);\n\tdefpointer(NULL);\n\tdefpointer(mkstr(f->name)->u.c.loc);\n\tif (IR->little_endian) {\n\t\tu.le.x = f->u.f.pt.x;\n\t\tu.le.y = f->u.f.pt.y;\n\t\tu.le.index = bbfile(f->u.f.pt.file);\n\t} else {\n\t\tu.be.x = f->u.f.pt.x;\n\t\tu.be.y = f->u.f.pt.y;\n\t\tu.be.index = bbfile(f->u.f.pt.file);\n\t}\n\t(*IR->defconst)(U, unsignedtype->size, (v.u = u.coord, v));\n\tfunclist = afunc;\n}\n\n/* bbincr - build tree to increment execution point at *cp */\nstatic void bbincr(Symbol yycounts, Coordinate *cp, Tree *e) {\n\tstruct map *mp = maplist->x;\n\tTree t;\n\n\t/* append *cp to source map */\n\tif (mp->size >= NELEMS(mp->u)) {\n\t\tNEW(mp, PERM);\n\t\tmp->size = 0;\n\t\tmaplist = append(mp, maplist);\n\t}\n\tif (IR->little_endian) {\n\t\tmp->u[mp->size].le.x = cp->x;\n\t\tmp->u[mp->size].le.y = cp->y;\n\t\tmp->u[mp->size++].le.index = bbfile(cp->file);\n\t} else {\n\t\tmp->u[mp->size].be.x = cp->x;\n\t\tmp->u[mp->size].be.y = cp->y;\n\t\tmp->u[mp->size++].be.index = bbfile(cp->file);\n\t}\n\tt = incr('+', rvalue((*optree['+'])(ADD, pointer(idtree(yycounts)),\n\t\tconsttree(npoints++, inttype))), consttree(1, inttype));\n\tif (*e)\n\t\t*e = tree(RIGHT, (*e)->type, t, *e);\n\telse\n\t\t*e = t;\n}\n\n/* bbvars - emit definition for basic block counting data */\nstatic void bbvars(Symbol yylink) {\n\tint i, j, n = npoints;\n\tValue v;\n\tstruct map **mp;\n\tSymbol coords, files, *p;\n\n\tif (!YYcounts && !yylink)\n\t\treturn;\n\tif (YYcounts) {\n\t\tif (n <= 0)\n\t\t\tn = 1;\n\t\tYYcounts->type = array(unsignedtype, n, 0);\n\t\tdefglobal(YYcounts, BSS);\n\t}\n\tfiles = genident(STATIC, array(charptype, 1, 0), GLOBAL);\n\tdefglobal(files, LIT);\n\tfor (p = ltov(&filelist, PERM); *p; p++)\n\t\tdefpointer((*p)->u.c.loc);\n\tdefpointer(NULL);\n\tcoords = genident(STATIC, array(unsignedtype, n, 0), GLOBAL);\n\tdefglobal(coords, LIT);\n\tfor (i = n, mp = ltov(&maplist, PERM); *mp; i -= (*mp)->size, mp++)\n\t\tfor (j = 0; j < (*mp)->size; j++)\n\t\t\t(*IR->defconst)(U, unsignedtype->size, (v.u = (*mp)->u[j].coord, v));\n\tif (i > 0)\n\t\t(*IR->space)(i*coords->type->type->size);\n\tdefpointer(NULL);\n\tdefglobal(yylink, DATA);\n\tdefpointer(NULL);\n\t(*IR->defconst)(U, unsignedtype->size, (v.u = n, v));\n\tdefpointer(YYcounts);\n\tdefpointer(coords);\n\tdefpointer(files);\n\tdefpointer(funclist);\n}\n\n/* profInit - initialize basic block profiling options */\nvoid prof_init(int argc, char *argv[]) {\n\tint i;\n\tstatic int inited;\n\n\tif (inited)\n\t\treturn;\n\tinited = 1;\n\ttype_init(argc, argv);\n\tif (IR)\n\t\tfor (i = 1; i < argc; i++)\n\t\t\tif (strncmp(argv[i], \"-a\", 2) == 0) {\n\t\t\t\tif (ncalled == -1\n\t\t\t\t&& process(argv[i][2] ? &argv[i][2] : \"prof.out\") > 0)\n\t\t\t\t\tncalled = 0;\n\t\t\t} else if ((strcmp(argv[i], \"-b\") == 0\n\t\t\t         || strcmp(argv[i], \"-C\") == 0) && YYlink == 0) {\n\t\t\t\tYYlink = genident(STATIC, array(unsignedtype, 0, 0), GLOBAL);\n\t\t\t\tattach((Apply)bbentry, YYlink, &events.entry);\n\t\t\t\tattach((Apply)bbexit,  YYlink, &events.returns);\n\t\t\t\tattach((Apply)bbfunc,  YYlink, &events.exit);\n\t\t\t\tattach((Apply)bbvars,  YYlink, &events.end);\n\t\t\t\tif (strcmp(argv[i], \"-b\") == 0) {\n\t\t\t\t\tYYcounts = genident(STATIC, array(unsignedtype, 0, 0), GLOBAL);\n\t\t\t\t\tmaplist = append(allocate(sizeof (struct map), PERM), maplist);\n\t\t\t\t\t((struct map *)maplist->x)->size = 0;\n\t\t\t\t\tattach((Apply)bbcall, YYcounts, &events.calls);\n\t\t\t\t\tattach((Apply)bbincr, YYcounts, &events.points);\n\t\t\t\t}\n\t\t\t}\n}\n"
  },
  {
    "path": "lcc/src/profio.c",
    "content": "/* C compiler: prof.out input\n\nprof.out format:\n#files\n    name\n    ... (#files-1 times)\n#functions\n    name file# x y count caller file x y \n    ... (#functions-1 times)\n#points\n    file# x y count\n    ... (#points-1 times)\n*/\n#include \"c.h\"\n\n\nstruct count {\t\t\t/* count data: */\n\tint x, y;\t\t\t/* source coordinate */\n\tint count;\t\t\t/* associated execution count */\n};\n\n#define MAXTOKEN 64\n\nstruct file {\t\t\t/* per-file prof.out data: */\n\tstruct file *link;\t\t/* link to next file */\n\tchar *name;\t\t\t/* file name */\n\tint size;\t\t\t/* size of counts[] */\n\tint count;\t\t\t/* counts[0..count-1] hold valid data */\n\tstruct count *counts;\t\t/* count data */\n\tstruct func {\t\t\t/* function data: */\n\t\tstruct func *link;\t\t/* link to next function */\n\t\tchar *name;\t\t\t/* function name */\n\t\tstruct count count;\t\t/* total number of calls */\n\t\tstruct caller {\t\t/* caller data: */\n\t\t\tstruct caller *link;\t/* link to next caller */\n\t\t\tchar *name;\t\t/* caller's name */\n\t\t\tchar *file;\t\t/* call site: file, x, y */\n\t\t\tint x, y;\n\t\t\tint count;\t\t/* number of calls from this site */\n\t\t} *callers;\n\t} *funcs;\t\t\t/* list of functions */\n} *filelist;\nFILE *fp;\n\n/* acaller - add caller and site (file,x,y) to callee's callers list */\nstatic void acaller(char *caller, char *file, int x, int y, int count, struct func *callee) {\n\tstruct caller *q;\n\n\tassert(callee);\n\tfor (q = callee->callers; q && (caller != q->name\n\t\t|| file != q->file || x != q->x || y != q->y); q = q->link)\n\t\t;\n\tif (!q) {\n\t\tstruct caller **r;\n\t\tNEW(q, PERM);\n\t\tq->name = caller;\n\t\tq->file = file;\n\t\tq->x = x;\n\t\tq->y = y;\n\t\tq->count = 0;\n\t\tfor (r = &callee->callers; *r && (strcmp(q->name, (*r)->name) > 0\n\t\t\t|| strcmp(q->file, (*r)->file) > 0 || q->y > (*r)->y || q->y > (*r)->y); r = &(*r)->link)\n\t\t\t;\n\t\tq->link = *r;\n\t\t*r = q;\n\t}\n\tq->count += count;\n}\n\n/* compare - return <0, 0, >0 if a<b, a==b, a>b, resp. */\nstatic int compare(struct count *a, struct count *b) {\n\tif (a->y == b->y)\n\t\treturn a->x - b->x;\n\treturn a->y - b->y;\n}\n\n/* findfile - return file name's file list entry, or 0 */\nstatic struct file *findfile(char *name) {\n\tstruct file *p;\n\n\tfor (p = filelist; p; p = p->link)\n\t\tif (p->name == name)\n\t\t\treturn p;\n\treturn 0;\n}\n\n/* afunction - add function name and its data to file's function list */\nstatic struct func *afunction(char *name, char *file, int x, int y, int count) {\n\tstruct file *p = findfile(file);\n\tstruct func *q;\n\n\tassert(p);\n\tfor (q = p->funcs; q && name != q->name; q = q->link)\n\t\t;\n\tif (!q) {\n\t\tstruct func **r;\n\t\tNEW(q, PERM);\n\t\tq->name = name;\n\t\tq->count.x = x;\n\t\tq->count.y = y;\n\t\tq->count.count = 0;\n\t\tq->callers = 0;\n\t\tfor (r = &p->funcs; *r && compare(&q->count, &(*r)->count) > 0; r = &(*r)->link)\n\t\t\t;\n\t\tq->link = *r;\n\t\t*r = q;\n\t}\n\tq->count.count += count;\n\treturn q;\n}\n\n/* apoint - append execution point i to file's data */ \nstatic void apoint(int i, char *file, int x, int y, int count) {\n\tstruct file *p = findfile(file);\n\n\tassert(p);\n\tif (i >= p->size) {\n\t\tint j;\n\t\tif (p->size == 0) {\n\t\t\tp->size = i >= 200 ? 2*i : 200;\n\t\t\tp->counts = newarray(p->size, sizeof *p->counts, PERM);\n\t\t} else {\n\t\t\tstruct count *new;\n\t\t\tp->size = 2*i;\n\t\t\tnew = newarray(p->size, sizeof *new, PERM);\n\t\t\tfor (j = 0; j < p->count; j++)\n\t\t\t\tnew[j] = p->counts[j];\n\t\t\tp->counts = new;\n\t\t}\n\t\tfor (j = p->count; j < p->size; j++) {\n\t\t\tstatic struct count z;\n\t\t\tp->counts[j] = z;\n\t\t}\n\t}\n\tp->counts[i].x = x;\n\tp->counts[i].y = y;\n\tp->counts[i].count += count;\n\tif (i >= p->count)\n\t\tp->count = i + 1;\n}\n\n/* findcount - return count associated with (file,x,y) or -1 */\nint findcount(char *file, int x, int y) {\n\tstatic struct file *cursor;\n\n\tif (cursor == 0 || cursor->name != file)\n\t\tcursor = findfile(file);\n\tif (cursor) {\n\t\tint l, u;\n\t\tstruct count *c = cursor->counts;\n\t\tfor (l = 0, u = cursor->count - 1; l <= u; ) {\n\t\t\tint k = (l + u)/2;\n\t\t\tif (c[k].y > y || c[k].y == y && c[k].x > x)\n\t\t\t\tu = k - 1;\n\t\t\telse if (c[k].y < y || c[k].y == y && c[k].x < x)\n\t\t\t\tl = k + 1;\n\t\t\telse\n\t\t\t\treturn c[k].count;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/* findfunc - return count associated with function name in file or -1 */\nint findfunc(char *name, char *file) {\n\tstatic struct file *cursor;\n\n\tif (cursor == 0 || cursor->name != file)\n\t\tcursor = findfile(file);\n\tif (cursor) {\n\t\tstruct func *p;\n\t\tfor (p = cursor->funcs; p; p = p->link)\n\t\t\tif (p->name == name)\n\t\t\t\treturn p->count.count;\n\t}\n\treturn -1;\n}\n\n/* getd - read a nonnegative number */\nstatic int getd(void) {\n\tint c, n = 0;\n\n\twhile ((c = getc(fp)) != EOF && (c == ' ' || c == '\\n' || c == '\\t'))\n\t\t;\n\tif (c >= '0' && c <= '9') {\n\t\tdo\n\t\t\tn = 10*n + (c - '0');\n\t\twhile ((c = getc(fp)) >= '0' && c <= '9');\n\t\treturn n;\n\t}\n\treturn -1;\n}\n\n/* getstr - read a string */\nstatic char *getstr(void) {\n\tint c;\n\tchar buf[MAXTOKEN], *s = buf;\n\n\twhile ((c = getc(fp)) != EOF && c != ' ' && c != '\\n' && c != '\\t')\n\t\tif (s - buf < (int)sizeof buf - 2)\n\t\t\t*s++ = c;\n\t*s = 0;\n\treturn s == buf ? (char *)0 : string(buf);\n}\n\n/* gather - read prof.out data from fd */\nstatic int gather(void) {\n\tint i, nfiles, nfuncs, npoints;\n\tchar *files[64];\n\n\tif ((nfiles = getd()) < 0)\n\t\treturn 0;\n\tassert(nfiles < NELEMS(files));\n\tfor (i = 0; i < nfiles; i++) {\n\t\tif ((files[i] = getstr()) == 0)\n\t\t\treturn -1;\n\t\tif (!findfile(files[i])) {\n\t\t\tstruct file *new;\n\t\t\tNEW(new, PERM);\n\t\t\tnew->name = files[i];\n\t\t\tnew->size = new->count = 0;\n\t\t\tnew->counts = 0;\n\t\t\tnew->funcs = 0;\n\t\t\tnew->link = filelist;\n\t\t\tfilelist = new;\n\t\t}\n\t}\n\tif ((nfuncs = getd()) < 0)\n\t\treturn -1;\n\tfor (i = 0; i < nfuncs; i++) {\n\t\tstruct func *q;\n\t\tchar *name, *file;\n\t\tint f, x, y, count;\n\t\tif ((name = getstr()) == 0 || (f = getd()) <= 0\n\t\t|| (x = getd()) < 0 || (y = getd()) < 0 || (count = getd()) < 0)\n\t\t\treturn -1;\n\t\tq = afunction(name, files[f-1], x, y, count);\n\t\tif ((name = getstr()) == 0 || (file = getstr()) == 0\n\t\t|| (x = getd()) < 0 || (y = getd()) < 0)\n\t\t\treturn -1;\n\t\tif (*name != '?')\n\t\t\tacaller(name, file, x, y, count, q);\n\t}\n\tif ((npoints = getd()) < 0)\n\t\treturn -1;\n\tfor (i = 0; i < npoints; i++) {\n\t\tint f, x, y, count;\n\t\tif ((f = getd()) < 0 || (x = getd()) < 0 || (y = getd()) < 0\n\t\t|| (count = getd()) < 0)\n\t\t\treturn -1;\n\t\tif (f)\n\t\t\tapoint(i, files[f-1], x, y, count);\n\t}\n\treturn 1;\n}\n\n/* process - read prof.out data from file */\nint process(char *file) {\n\tint more;\n\n\tif ((fp = fopen(file, \"r\")) != NULL) {\n\t\tstruct file *p;\n\t\twhile ((more = gather()) > 0)\n\t\t\t;\n\t\tfclose(fp);\n\t\tif (more < 0)\n\t\t\treturn more;\n\t\tfor (p = filelist; p; p = p->link)\n\t\t\tqsort(p->counts, p->count, sizeof *p->counts,\n\t\t\t\t(int (*)(const void *, const void *))\n\t\t\t\tcompare);\n\t\t\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n"
  },
  {
    "path": "lcc/src/rcc.asdl",
    "content": "-- lcc IR\n-- $Id: rcc.asdl 145 2001-10-17 21:53:10Z timo $\nmodule rcc {\n\n-- Pickles start with an int version number, followed by rcc.program\n\nprogram = (int nuids,int nlabels,item* items,interface* interfaces,int argc,string *argv)\n\nreal\t= (int msb,int lsb)\n\nitem\t= Symbol(symbol symbol)\n\t| Type(type type)\n\tattributes(int uid)\n\nsymbol\t= (identifier id,int type,int scope,int sclass,int ref,int flags)\n\nfield\t= (identifier id,int type,int offset,int bitsize,int lsb)\n\nenum\t= (identifier id,int value)\n\ntype\t= INT\n\t| UNSIGNED\n\t| FLOAT\n\t| VOID\n\t| POINTER(int type)\n\t| ENUM(identifier tag,enum* ids)\n\t| STRUCT(identifier tag,field* fields)\n\t| UNION(identifier tag,field* fields)\n\t| ARRAY(int type)\n\t| FUNCTION(int type,int* formals)\n\t| CONST(int type)\n\t| VOLATILE(int type)\n\tattributes(int size,int align)\n\ninterface\t= Export(int p)\n\t\t| Import(int p)\n\t\t| Global(int p,int seg)\n\t\t| Local(int uid,symbol p)\t\t-- includes formals\n\t\t| Address(int uid,symbol q,int p,int n)\n\t\t| Segment(int seg)\n\t\t| Defaddress(int p)\n\t\t| Deflabel(int label)\n\t\t| Defconst(int suffix,int size,int value)\n\t\t| Defconstf(int size,real value)\n\t\t| Defstring(string s)\n\t\t| Space(int n)\n\t\t| Function(int f,int* caller,int* callee,int ncalls,interface* codelist)\n\t\t| Blockbeg\n\t\t| Blockend\n\t\t| Forest(node* nodes)\n\nnode\t= CNST(int value)\n\t| CNSTF(real value)\n\t| ARG(node left,int len,int align)\n\t| ASGN(node left,node right,int len,int align)\n\t| CVT(int op,node left,int fromsize)\n\t| CALL(node left,int type)\n\t| CALLB(node left,node right,int type)\n\t| RET\n\t| ADDRG(int uid)\n\t| ADDRL(int uid)\n\t| ADDRF(int uid)\n\t| Unary(int op,node left)\t\t\t\t-- INDIR RET JUMP NEG BCOM\n\t| Binary(int op,node left,node right)\t\t\t-- ADD SUB DIV MUL MOD BOR BAND BXOR RSH LSH\n\t| Compare(int op,node left,node right,int label)\t-- EQ NE GT GE LE LT\n\t| LABEL(int label)\n\t| BRANCH(int label)\n\t| CSE(int uid,node node)\n\tattributes(int suffix,int size)\n}\n"
  },
  {
    "path": "lcc/src/run.sh",
    "content": "#!/bin/sh\n# run .../target/os/tst/foo.s [ remotehost ]\n\n# set -x\ntarget=`echo $1 | awk -F/ '{ print $(NF-3) }'`\nos=`echo $1 | awk -F/ '{ print $(NF-2) }'`\ndir=$target/$os\n\ncase \"$1\" in\n*symbolic/irix*)\tidir=include/mips/irix; remotehost=noexecute ;;\n*symbolic/osf*)\t\tidir=include/alpha/osf;\tremotehost=noexecute ;;\n*)\t\t\tidir=include/$dir;      remotehost=${2-$REMOTEHOST} ;;\nesac\n\nif [ ! -d \"$target/$os\" -o ! -d \"$idir\" ]; then\n\techo 2>&1 $0: unknown combination '\"'$target/$os'\"'\n\texit 1\nfi\n\nC=`basename $1 .s`\nBUILDDIR=${BUILDDIR-.} LCC=\"${LCC-${BUILDDIR}/lcc} -Wo-lccdir=$BUILDDIR\"\nTSTDIR=${TSTDIR-${BUILDDIR}/$dir/tst}\nif [ ! -d $TSTDIR ]; then mkdir -p $TSTDIR; fi\n\necho ${BUILDDIR}/rcc$EXE -target=$target/$os $1: 1>&2\n$LCC -S -I$idir -Ualpha -Usun -Uvax -Umips -Ux86 \\\n\t-Wf-errout=$TSTDIR/$C.2 -D$target -Wf-g0 \\\n\t-Wf-target=$target/$os -o $1 tst/$C.c\nif [ $? != 0 ]; then remotehost=noexecute; fi\nif [ -r $dir/tst/$C.2bk ]; then\n\tdiff $dir/tst/$C.2bk $TSTDIR/$C.2\nfi\nif [ -r $dir/tst/$C.sbk ]; then\n\tif diff $dir/tst/$C.sbk $TSTDIR/$C.s; then exit 0; fi\nfi\n\ncase \"$remotehost\" in\nnoexecute)\texit 0 ;;\n\"\"|\"-\")\t$LCC -o $TSTDIR/$C$EXE $1; $TSTDIR/$C$EXE <tst/$C.0 >$TSTDIR/$C.1 ;;\n*)\trcp $1 $remotehost:\n\tif expr \"$remotehost\" : '.*@' >/dev/null ; then\n\t\tremotehost=\"`expr $remotehost : '.*@\\(.*\\)'` -l `expr $remotehost : '\\(.*\\)@'`\"\n\tfi\n\trsh $remotehost \"cc -o $C$EXE $C.s -lm;./$C$EXE;rm -f $C$EXE $C.[so]\" <tst/$C.0 >$TSTDIR/$C.1\n\t;;\nesac\nif [ -r $dir/tst/$C.1bk ]; then\n\tdiff $dir/tst/$C.1bk $TSTDIR/$C.1\n\texit $?\nfi\nexit 0\n"
  },
  {
    "path": "lcc/src/simp.c",
    "content": "#include \"c.h\"\n#include <float.h>\n\n\n#define foldcnst(TYPE,VAR,OP) \\\n\tif (l->op == CNST+TYPE && r->op == CNST+TYPE) \\\n\t\treturn cnsttree(ty, l->u.v.VAR OP r->u.v.VAR)\n#define commute(L,R) \\\n\tif (generic(R->op) == CNST && generic(L->op) != CNST) \\\n\t\tdo { Tree t = L; L = R; R = t; } while(0)\n#define xfoldcnst(TYPE,VAR,OP,FUNC)\\\n\tif (l->op == CNST+TYPE && r->op == CNST+TYPE\\\n\t&& FUNC(l->u.v.VAR,r->u.v.VAR,\\\n\t\tty->u.sym->u.limits.min.VAR,\\\n\t\tty->u.sym->u.limits.max.VAR, needconst)) \\\n\t\treturn cnsttree(ty, l->u.v.VAR OP r->u.v.VAR)\n#define xcvtcnst(FTYPE,SRC,DST,VAR,EXPR) \\\n\tif (l->op == CNST+FTYPE) do {\\\n\t\tif (!explicitCast\\\n\t\t&&  ((SRC) < DST->u.sym->u.limits.min.VAR || (SRC) > DST->u.sym->u.limits.max.VAR))\\\n\t\t\twarning(\"overflow in converting constant expression from `%t' to `%t'\\n\", l->type, DST);\\\n\t\tif (needconst\\\n\t\t|| !((SRC) < DST->u.sym->u.limits.min.VAR || (SRC) > DST->u.sym->u.limits.max.VAR))\\\n\t\t\treturn cnsttree(ty, (EXPR)); } while(0)\n#define identity(X,Y,TYPE,VAR,VAL) \\\n\tif (X->op == CNST+TYPE && X->u.v.VAR == VAL) return Y\n#define zerofield(OP,TYPE,VAR) \\\n\tif (l->op == FIELD \\\n\t&&  r->op == CNST+TYPE && r->u.v.VAR == 0)\\\n\t\treturn eqtree(OP, bittree(BAND, l->kids[0],\\\n\t\t\tcnsttree(unsignedtype, \\\n\t\t\t\t(unsigned long)fieldmask(l->u.field)<<fieldright(l->u.field))), r)\n#define cfoldcnst(TYPE,VAR,OP) \\\n\tif (l->op == CNST+TYPE && r->op == CNST+TYPE) \\\n\t\treturn cnsttree(inttype, (long)(l->u.v.VAR OP r->u.v.VAR))\n#define foldaddp(L,R,RTYPE,VAR) \\\n\tif (L->op == CNST+P && R->op == CNST+RTYPE) { \\\n\t\tTree e = tree(CNST+P, ty, NULL, NULL);\\\n\t\te->u.v.p = (char *)L->u.v.p + R->u.v.VAR;\\\n\t\treturn e; }\n#define ufoldcnst(TYPE,EXP) if (l->op == CNST+TYPE) return EXP\n#define sfoldcnst(OP) \\\n\tif (l->op == CNST+U && r->op == CNST+I \\\n\t&& r->u.v.i >= 0 && r->u.v.i < 8*l->type->size) \\\n\t\treturn cnsttree(ty, (unsigned long)(l->u.v.u OP r->u.v.i))\n#define geu(L,R,V) \\\n\tif (R->op == CNST+U && R->u.v.u == 0) do { \\\n\t\twarning(\"result of unsigned comparison is constant\\n\"); \\\n\t\treturn tree(RIGHT, inttype, root(L), cnsttree(inttype, (long)(V))); } while(0)\n#define idempotent(OP) if (l->op == OP) return l->kids[0]\n\nint needconst;\nint explicitCast;\nstatic int addi(long x, long y, long min, long max, int needconst) {\n\tint cond = x == 0 || y == 0\n\t|| x < 0 && y < 0 && x >= min - y\n\t|| x < 0 && y > 0\n\t|| x > 0 && y < 0\n\t|| x > 0 && y > 0 && x <= max - y;\n\tif (!cond && needconst) {\n\t\twarning(\"overflow in constant expression\\n\");\n\t\tcond = 1;\n\t}\n\treturn cond;\n\n\n}\n\nstatic int addd(double x, double y, double min, double max, int needconst) {\n\tint cond = x == 0 || y == 0\n\t|| x < 0 && y < 0 && x >= min - y\n\t|| x < 0 && y > 0\n\t|| x > 0 && y < 0\n\t|| x > 0 && y > 0 && x <= max - y;\n\tif (!cond && needconst) {\n\t\twarning(\"overflow in constant expression\\n\");\n\t\tcond = 1;\n\t}\n\treturn cond;\n\n\n}\n\nstatic Tree addrtree(Tree e, long n, Type ty) {\n\tSymbol p = e->u.sym, q;\n\n\tif (p->scope  == GLOBAL\n\t||  p->sclass == STATIC || p->sclass == EXTERN)\n\t\tNEW0(q, PERM);\n\telse\n\t\tNEW0(q, FUNC);\n\tq->name = stringd(genlabel(1));\n\tq->sclass = p->sclass;\n\tq->scope = p->scope;\n\tassert(isptr(ty) || isarray(ty));\n\tq->type = isptr(ty) ? ty->type : ty;\n\tq->temporary = p->temporary;\n\tq->generated = p->generated;\n\tq->addressed = p->addressed;\n\tq->computed = 1;\n\tq->defined = 1;\n\tq->ref = 1;\n\tif (p->scope  == GLOBAL\n\t||  p->sclass == STATIC || p->sclass == EXTERN) {\n\t\tif (p->sclass == AUTO)\n\t\t\tq->sclass = STATIC;\n\t\t(*IR->address)(q, p, n);\n\t} else {\n\t\tCode cp;\n\t\taddlocal(p);\n\t\tcp = code(Address);\n\t\tcp->u.addr.sym = q;\n\t\tcp->u.addr.base = p;\n\t\tcp->u.addr.offset = n;\n\t}\n\te = tree(e->op, ty, NULL, NULL);\n\te->u.sym = q;\n\treturn e;\n}\n\n/* div[id] - return 1 if min <= x/y <= max, 0 otherwise */\nstatic int divi(long x, long y, long min, long max, int needconst) {\n\tint cond = y != 0 && !(x == min && y == -1);\n\tif (!cond && needconst) {\n\t\twarning(\"overflow in constant expression\\n\");\n\t\tcond = 1;\n\t}\n\treturn cond;\n\n\n}\n\nstatic int divd(double x, double y, double min, double max, int needconst) {\n\tint cond;\n\n\tif (x < 0) x = -x;\n\tif (y < 0) y = -y;\n\tcond = y != 0 && !(y < 1 && x > max*y);\n\tif (!cond && needconst) {\n\t\twarning(\"overflow in constant expression\\n\");\n\t\tcond = 1;\n\t}\n\treturn cond;\n\n}\n\n/* mul[id] - return 1 if min <= x*y <= max, 0 otherwise */\nstatic int muli(long x, long y, long min, long max, int needconst) {\n\tint cond = x > -1 && x <= 1 || y > -1 && y <= 1\n\t|| x < 0 && y < 0 && -x <= max/-y\n\t|| x < 0 && y > 0 &&  x >= min/y\n\t|| x > 0 && y < 0 &&  y >= min/x\n\t|| x > 0 && y > 0 &&  x <= max/y;\n\tif (!cond && needconst) {\n\t\twarning(\"overflow in constant expression\\n\");\n\t\tcond = 1;\n\t}\n\treturn cond;\n\n\n}\n\nstatic int muld(double x, double y, double min, double max, int needconst) {\n\tint cond = x >= -1 && x <= 1 || y >= -1 && y <= 1\n\t|| x < 0 && y < 0 && -x <= max/-y\n\t|| x < 0 && y > 0 &&  x >= min/y\n\t|| x > 0 && y < 0 &&  y >= min/x\n\t|| x > 0 && y > 0 &&  x <= max/y;\n\tif (!cond && needconst) {\n\t\twarning(\"overflow in constant expression\\n\");\n\t\tcond = 1;\n\t}\n\treturn cond;\n\n\n}\n/* sub[id] - return 1 if min <= x-y <= max, 0 otherwise */\nstatic int subi(long x, long y, long min, long max, int needconst) {\n\treturn addi(x, -y, min, max, needconst);\n}\n\nstatic int subd(double x, double y, double min, double max, int needconst) {\n\treturn addd(x, -y, min, max, needconst);\n}\nTree constexpr(int tok) {\n\tTree p;\n\n\tneedconst++;\n\tp = expr1(tok);\n\tneedconst--;\n\treturn p;\n}\n\nint intexpr(int tok, int n) {\n\tTree p = constexpr(tok);\n\n\tneedconst++;\n\tif (p->op == CNST+I || p->op == CNST+U)\n\t\tn = cast(p, inttype)->u.v.i;\n\telse\n\t\terror(\"integer expression must be constant\\n\");\n\tneedconst--;\n\treturn n;\n}\nTree simplify(int op, Type ty, Tree l, Tree r) {\n\tint n;\n\tTree p;\n\n\tif (optype(op) == 0)\n\t\top = mkop(op, ty);\n\tswitch (op) {\n\t\tcase ADD+U:\n\t\t\tfoldcnst(U,u,+);\n\t\t\tcommute(r,l);\n\t\t\tidentity(r,l,U,u,0);\n\t\t\tbreak;\n\t\tcase ADD+I:\n\t\t\txfoldcnst(I,i,+,addi);\n\t\t\tcommute(r,l);\n\t\t\tidentity(r,l,I,i,0);\n\t\t\tbreak;\n\t\tcase CVI+I:\n\t\t\txcvtcnst(I,l->u.v.i,ty,i,(long)extend(l->u.v.i,ty));\n\t\t\tbreak;\n\t\tcase CVU+I:\n\t\t\tif (l->op == CNST+U) {\n\t\t\t\tif (!explicitCast && l->u.v.u > ty->u.sym->u.limits.max.i)\n\t\t\t\t\twarning(\"overflow in converting constant expression from `%t' to `%t'\\n\", l->type, ty);\n\t\t\t\tif (needconst || !(l->u.v.u > ty->u.sym->u.limits.max.i))\n\t\t\t\t\treturn cnsttree(ty, (long)extend(l->u.v.u,ty));\n\t\t\t}\n\t\t\tbreak;\n\t\tcase CVP+U:\n\t\t\txcvtcnst(P,(unsigned long)l->u.v.p,ty,u,(unsigned long)l->u.v.p);\n\t\t\tbreak;\n\t\tcase CVU+P:\n\t\t\txcvtcnst(U,(void*)l->u.v.u,ty,p,(void*)l->u.v.u);\n\t\t\tbreak;\n\t\tcase CVP+P:\n\t\t\txcvtcnst(P,l->u.v.p,ty,p,l->u.v.p);\n\t\t\tbreak;\n\t\tcase CVI+U:\n\t\t\txcvtcnst(I,l->u.v.i,ty,u,((unsigned long)l->u.v.i)&ones(8*ty->size));\n\t\t\tbreak;\n\t\tcase CVU+U:\n\t\t\txcvtcnst(U,l->u.v.u,ty,u,l->u.v.u&ones(8*ty->size));\n\t\t\tbreak;\n\n\t\tcase CVI+F:\n\t\t\txcvtcnst(I,l->u.v.i,ty,d,(long double)l->u.v.i);\n\t\tcase CVU+F:\n\t\t\txcvtcnst(U,l->u.v.u,ty,d,(long double)l->u.v.u);\n\t\t\tbreak;\n\t\tcase CVF+I:\n\t\t\txcvtcnst(F,l->u.v.d,ty,i,(long)l->u.v.d);\n\t\t\tbreak;\n\t\tcase CVF+F: {\n\t\t\tfloat d;\n\t\t\tif (l->op == CNST+F)\n\t\t\t\tif (l->u.v.d < ty->u.sym->u.limits.min.d)\n\t\t\t\t\td = ty->u.sym->u.limits.min.d;\n\t\t\t\telse if (l->u.v.d > ty->u.sym->u.limits.max.d)\n\t\t\t\t\td = ty->u.sym->u.limits.max.d;\n\t\t\t\telse\n\t\t\t\t\td = l->u.v.d;\n\t\t\txcvtcnst(F,l->u.v.d,ty,d,(long double)d);\n\t\t\tbreak;\n\t\t\t}\n\t\tcase BAND+U:\n\t\t\tfoldcnst(U,u,&);\n\t\t\tcommute(r,l);\n\t\t\tidentity(r,l,U,u,ones(8*ty->size));\n\t\t\tif (r->op == CNST+U && r->u.v.u == 0)\n\t\t\t\treturn tree(RIGHT, ty, root(l), cnsttree(ty, 0UL));\n\t\t\tbreak;\n\t\tcase BAND+I:\n\t\t\tfoldcnst(I,i,&);\n\t\t\tcommute(r,l);\n\t\t\tidentity(r,l,I,i,ones(8*ty->size));\n\t\t\tif (r->op == CNST+I && r->u.v.u == 0)\n\t\t\t\treturn tree(RIGHT, ty, root(l), cnsttree(ty, 0L));\n\t\t\tbreak;\n\n\t\tcase MUL+U:\n\t\t\tcommute(l,r);\n\t\t\tif (l->op == CNST+U && (n = ispow2(l->u.v.u)) != 0)\n\t\t\t\treturn simplify(LSH, ty, r, cnsttree(inttype, (long)n));\n\t\t\tfoldcnst(U,u,*);\n\t\t\tidentity(r,l,U,u,1);\n\t\t\tbreak;\n\t\tcase NE+I:\n\t\t\tcfoldcnst(I,i,!=);\n\t\t\tcommute(r,l);\n\t\t\tzerofield(NE,I,i);\n\t\t\tbreak;\n\n\t\tcase EQ+I:\n\t\t\tcfoldcnst(I,i,==);\n\t\t\tcommute(r,l);\n\t\t\tzerofield(EQ,I,i);\n\t\t\tbreak;\n\t\tcase ADD+P:\n\t\t\tfoldaddp(l,r,I,i);\n\t\t\tfoldaddp(l,r,U,u);\n\t\t\tfoldaddp(r,l,I,i);\n\t\t\tfoldaddp(r,l,U,u);\n\t\t\tcommute(r,l);\n\t\t\tidentity(r,retype(l,ty),I,i,0);\n\t\t\tidentity(r,retype(l,ty),U,u,0);\n\t\t\tif (isaddrop(l->op)\n\t\t\t&& (r->op == CNST+I && r->u.v.i <= longtype->u.sym->u.limits.max.i\n\t\t\t    && r->u.v.i >= longtype->u.sym->u.limits.min.i\n\t\t\t|| r->op == CNST+U && r->u.v.u <= longtype->u.sym->u.limits.max.i))\n\t\t\t\treturn addrtree(l, cast(r, longtype)->u.v.i, ty);\n\t\t\tif (l->op == ADD+P && isaddrop(l->kids[1]->op)\n\t\t\t&& (r->op == CNST+I && r->u.v.i <= longtype->u.sym->u.limits.max.i\n\t\t\t    && r->u.v.i >= longtype->u.sym->u.limits.min.i\n\t\t\t||  r->op == CNST+U && r->u.v.u <= longtype->u.sym->u.limits.max.i))\n\t\t\t\treturn simplify(ADD+P, ty, l->kids[0],\n\t\t\t\t\taddrtree(l->kids[1], cast(r, longtype)->u.v.i, ty));\n\t\t\tif ((l->op == ADD+I || l->op == SUB+I)\n\t\t\t&& l->kids[1]->op == CNST+I && isaddrop(r->op))\n\t\t\t\treturn simplify(ADD+P, ty, l->kids[0],\n\t\t\t\t\tsimplify(generic(l->op)+P, ty, r, l->kids[1]));\n\t\t\tif (l->op == ADD+P && generic(l->kids[1]->op) == CNST\n\t\t\t&& generic(r->op) == CNST)\n\t\t\t\treturn simplify(ADD+P, ty, l->kids[0],\n\t\t\t\t\tsimplify(ADD, l->kids[1]->type, l->kids[1], r));\n\t\t\tif (l->op == ADD+I && generic(l->kids[1]->op) == CNST\n\t\t\t&&  r->op == ADD+P && generic(r->kids[1]->op) == CNST)\n\t\t\t\treturn simplify(ADD+P, ty, l->kids[0],\n\t\t\t\t\tsimplify(ADD+P, ty, r->kids[0],\n\t\t\t\t\tsimplify(ADD, r->kids[1]->type, l->kids[1], r->kids[1])));\n\t\t\tif (l->op == RIGHT && l->kids[1])\n\t\t\t\treturn tree(RIGHT, ty, l->kids[0],\n\t\t\t\t\tsimplify(ADD+P, ty, l->kids[1], r));\n\t\t\telse if (l->op == RIGHT && l->kids[0])\n\t\t\t\treturn tree(RIGHT, ty,\n\t\t\t\t\tsimplify(ADD+P, ty, l->kids[0], r), NULL);\n\t\t\tbreak;\n\n\t\tcase ADD+F:\n\t\t\txfoldcnst(F,d,+,addd);\n\t\t\tcommute(r,l);\n\t\t\tbreak;\n\t\tcase AND+I:\n\t\t\top = AND;\n\t\t\tufoldcnst(I,l->u.v.i ? cond(r) : l);\t/* 0&&r => 0, 1&&r => r */\n\t\t\tbreak;\n\t\tcase OR+I:\n\t\t\top = OR;\n\t\t\t/* 0||r => r, 1||r => 1 */\n\t\t\tufoldcnst(I,l->u.v.i ? cnsttree(ty, 1L) : cond(r));\n\t\t\tbreak;\n\t\tcase BCOM+I:\n\t\t\tufoldcnst(I,cnsttree(ty, (long)extend((~l->u.v.i)&ones(8*ty->size), ty)));\n\t\t\tidempotent(BCOM+U);\n\t\t\tbreak;\n\t\tcase BCOM+U:\n\t\t\tufoldcnst(U,cnsttree(ty, (unsigned long)((~l->u.v.u)&ones(8*ty->size))));\n\t\t\tidempotent(BCOM+U);\n\t\t\tbreak;\n\t\tcase BOR+U:\n\t\t\tfoldcnst(U,u,|);\n\t\t\tcommute(r,l);\n\t\t\tidentity(r,l,U,u,0);\n\t\t\tbreak;\n\t\tcase BOR+I:\n\t\t\tfoldcnst(I,i,|);\n\t\t\tcommute(r,l);\n\t\t\tidentity(r,l,I,i,0);\n\t\t\tbreak;\n\t\tcase BXOR+U:\n\t\t\tfoldcnst(U,u,^);\n\t\t\tcommute(r,l);\n\t\t\tidentity(r,l,U,u,0);\n\t\t\tbreak;\n\t\tcase BXOR+I:\n\t\t\tfoldcnst(I,i,^);\n\t\t\tcommute(r,l);\n\t\t\tidentity(r,l,I,i,0);\n\t\t\tbreak;\n\t\tcase DIV+F:\n\t\t\txfoldcnst(F,d,/,divd);\n\t\t\tbreak;\n\t\tcase DIV+I:\n\t\t\tidentity(r,l,I,i,1);\n\t\t\tif (r->op == CNST+I && r->u.v.i == 0\n\t\t\t||  l->op == CNST+I && l->u.v.i == ty->u.sym->u.limits.min.i\n\t\t\t&&  r->op == CNST+I && r->u.v.i == -1)\n\t\t\t\tbreak;\n\t\t\txfoldcnst(I,i,/,divi);\n\t\t\tbreak;\n\t\tcase DIV+U:\t\t\n\t\t\tidentity(r,l,U,u,1);\n\t\t\tif (r->op == CNST+U && r->u.v.u == 0)\n\t\t\t\tbreak;\n\t\t\tif (r->op == CNST+U && (n = ispow2(r->u.v.u)) != 0)\n\t\t\t\treturn simplify(RSH, ty, l, cnsttree(inttype, (long)n));\n\t\t\tfoldcnst(U,u,/);\n\t\t\tbreak;\n\t\tcase EQ+F:\n\t\t\tcfoldcnst(F,d,==);\n\t\t\tcommute(r,l);\n\t\t\tbreak;\n\t\tcase EQ+U:\n\t\t\tcfoldcnst(U,u,==);\n\t\t\tcommute(r,l);\n\t\t\tzerofield(EQ,U,u);\n\t\t\tbreak;\n\t\tcase GE+F: cfoldcnst(F,d,>=); break;\n\t\tcase GE+I: cfoldcnst(I,i,>=); break;\n\t\tcase GE+U:\n\t\t\tgeu(l,r,1);\t/* l >= 0 => (l,1) */\n\t\t\tcfoldcnst(U,u,>=);\n\t\t\tif (l->op == CNST+U && l->u.v.u == 0)\t/* 0 >= r => r == 0 */\n\t\t\t\treturn eqtree(EQ, r, l);\n\t\t\tbreak;\n\t\tcase GT+F: cfoldcnst(F,d, >); break;\n\t\tcase GT+I: cfoldcnst(I,i, >); break;\n\t\tcase GT+U:\n\t\t\tgeu(r,l,0);\t/* 0 > r => (r,0) */\n\t\t\tcfoldcnst(U,u, >);\n\t\t\tif (r->op == CNST+U && r->u.v.u == 0)\t/* l > 0 => l != 0 */\n\t\t\t\treturn eqtree(NE, l, r);\n\t\t\tbreak;\n\t\tcase LE+F: cfoldcnst(F,d,<=); break;\n\t\tcase LE+I: cfoldcnst(I,i,<=); break;\n\t\tcase LE+U:\n\t\t\tgeu(r,l,1);\t/* 0 <= r => (r,1) */\n\t\t\tcfoldcnst(U,u,<=);\n\t\t\tif (r->op == CNST+U && r->u.v.u == 0)\t/* l <= 0 => l == 0 */\n\t\t\t\treturn eqtree(EQ, l, r);\n\t\t\tbreak;\n\t\tcase LSH+I:\n\t\t\tidentity(r,l,I,i,0);\n\t\t\tif (l->op == CNST+I && r->op == CNST+I\n\t\t\t&& r->u.v.i >= 0 && r->u.v.i < 8*l->type->size\n\t\t\t&& muli(l->u.v.i, 1<<r->u.v.i, ty->u.sym->u.limits.min.i, ty->u.sym->u.limits.max.i, needconst))\n\t\t\t\treturn cnsttree(ty, (long)(l->u.v.i<<r->u.v.i));\n\t\t\tif (r->op == CNST+I && (r->u.v.i >= 8*ty->size || r->u.v.i < 0)) {\n\t\t\t\twarning(\"shifting an `%t' by %d bits is undefined\\n\", ty, r->u.v.i);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tbreak;\n\t\tcase LSH+U:\n\t\t\tidentity(r,l,I,i,0);\n\t\t\tsfoldcnst(<<);\n\t\t\tif (r->op == CNST+I && (r->u.v.i >= 8*ty->size || r->u.v.i < 0)) {\n\t\t\t\twarning(\"shifting an `%t' by %d bits is undefined\\n\", ty, r->u.v.i);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tbreak;\n\n\t\tcase LT+F: cfoldcnst(F,d, <); break;\n\t\tcase LT+I: cfoldcnst(I,i, <); break;\n\t\tcase LT+U:\n\t\t\tgeu(l,r,0);\t/* l < 0 => (l,0) */\n\t\t\tcfoldcnst(U,u, <);\n\t\t\tif (l->op == CNST+U && l->u.v.u == 0)\t/* 0 < r => r != 0 */\n\t\t\t\treturn eqtree(NE, r, l);\n\t\t\tbreak;\n\t\tcase MOD+I:\n\t\t\tif (r->op == CNST+I && r->u.v.i == 1)\t/* l%1 => (l,0) */\n\t\t\t\treturn tree(RIGHT, ty, root(l), cnsttree(ty, 0L));\n\t\t\tif (r->op == CNST+I && r->u.v.i == 0\n\t\t\t||  l->op == CNST+I && l->u.v.i == ty->u.sym->u.limits.min.i\n\t\t\t&&  r->op == CNST+I && r->u.v.i == -1)\n\t\t\t\tbreak;\n\t\t\txfoldcnst(I,i,%,divi);\n\t\t\tbreak;\n\t\tcase MOD+U:\t\t\n\t\t\tif (r->op == CNST+U && ispow2(r->u.v.u)) /* l%2^n => l&(2^n-1) */\n\t\t\t\treturn bittree(BAND, l, cnsttree(ty, r->u.v.u - 1));\n\t\t\tif (r->op == CNST+U && r->u.v.u == 0)\n\t\t\t\tbreak;\n\t\t\tfoldcnst(U,u,%);\n\t\t\tbreak;\n\t\tcase MUL+F:\n\t\t\txfoldcnst(F,d,*,muld);\n\t\t\tcommute(l,r);\n\t\t\tbreak;\n\t\tcase MUL+I:\n\t\t\tcommute(l,r);\n\t\t\txfoldcnst(I,i,*,muli);\n\t\t\tif (l->op == CNST+I && r->op == ADD+I && r->kids[1]->op == CNST+I)\n\t\t\t\t/* c1*(x + c2) => c1*x + c1*c2 */\n\t\t\t\treturn simplify(ADD, ty, simplify(MUL, ty, l, r->kids[0]),\n\t\t\t\t\tsimplify(MUL, ty, l, r->kids[1]));\n\t\t\tif (l->op == CNST+I && r->op == SUB+I && r->kids[1]->op == CNST+I)\n\t\t\t\t/* c1*(x - c2) => c1*x - c1*c2 */\n\t\t\t\treturn simplify(SUB, ty, simplify(MUL, ty, l, r->kids[0]),\n\t\t\t\t\tsimplify(MUL, ty, l, r->kids[1]));\n\t\t\tif (l->op == CNST+I && l->u.v.i > 0 && (n = ispow2(l->u.v.i)) != 0)\n\t\t\t\t/* 2^n * r => r<<n */\n\t\t\t\treturn simplify(LSH, ty, r, cnsttree(inttype, (long)n));\n\t\t\tidentity(r,l,I,i,1);\n\t\t\tbreak;\n\t\tcase NE+F:\n\t\t\tcfoldcnst(F,d,!=);\n\t\t\tcommute(r,l);\n\t\t\tbreak;\n\t\tcase NE+U:\n\t\t\tcfoldcnst(U,u,!=);\n\t\t\tcommute(r,l);\n\t\t\tzerofield(NE,U,u);\n\t\t\tbreak;\n\t\tcase NEG+F:\n\t\t\tufoldcnst(F,cnsttree(ty, -l->u.v.d));\n\t\t\tidempotent(NEG+F);\n\t\t\tbreak;\n\t\tcase NEG+I:\n\t\t\tif (l->op == CNST+I) {\n\t\t\t\tif (needconst && l->u.v.i == ty->u.sym->u.limits.min.i)\n\t\t\t\t\twarning(\"overflow in constant expression\\n\");\n\t\t\t\tif (needconst || l->u.v.i != ty->u.sym->u.limits.min.i)\n\t\t\t\t\treturn cnsttree(ty, -l->u.v.i);\n\t\t\t}\n\t\t\tidempotent(NEG+I);\n\t\t\tbreak;\n\t\tcase NOT+I:\n\t\t\top = NOT;\n\t\t\tufoldcnst(I,cnsttree(ty, !l->u.v.i));\n\t\t\tbreak;\n\t\tcase RSH+I:\n\t\t\tidentity(r,l,I,i,0);\n\t\t\tif (l->op == CNST+I && r->op == CNST+I\n\t\t\t&& r->u.v.i >= 0 && r->u.v.i < 8*l->type->size) {\n\t\t\t\tlong n = l->u.v.i>>r->u.v.i;\n\t\t\t\tif (l->u.v.i < 0)\n\t\t\t\t\tn |= ~0UL<<(8*l->type->size - r->u.v.i);\n\t\t\t\treturn cnsttree(ty, n);\n\t\t\t}\n\t\t\tif (r->op == CNST+I && (r->u.v.i >= 8*ty->size || r->u.v.i < 0)) {\n\t\t\t\twarning(\"shifting an `%t' by %d bits is undefined\\n\", ty, r->u.v.i);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tbreak;\n\t\tcase RSH+U:\n\t\t\tidentity(r,l,I,i,0);\n\t\t\tsfoldcnst(>>);\n\t\t\tif (r->op == CNST+I && (r->u.v.i >= 8*ty->size || r->u.v.i < 0)) {\n\t\t\t\twarning(\"shifting an `%t' by %d bits is undefined\\n\", ty, r->u.v.i);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tbreak;\n\t\tcase SUB+F:\n\t\t\txfoldcnst(F,d,-,subd);\n\t\t\tbreak;\n\t\tcase SUB+I:\n\t\t\txfoldcnst(I,i,-,subi);\n\t\t\tidentity(r,l,I,i,0);\n\t\t\tbreak;\n\t\tcase SUB+U:\n\t\t\tfoldcnst(U,u,-);\n\t\t\tidentity(r,l,U,u,0);\n\t\t\tbreak;\n\t\tcase SUB+P:\n\t\t\tif (l->op == CNST+P && r->op == CNST+P)\n\t\t\t\treturn cnsttree(ty, (long)((char *)l->u.v.p - (char *)r->u.v.p));\n\t\t\tif (r->op == CNST+I || r->op == CNST+U)\n\t\t\t\treturn simplify(ADD, ty, l,\n\t\t\t\t\tcnsttree(inttype, r->op == CNST+I ? -r->u.v.i : -(long)r->u.v.u));\n\t\t\tif (isaddrop(l->op) && r->op == ADD+I && r->kids[1]->op == CNST+I)\n\t\t\t\t/* l - (x + c) => l-c - x */\n\t\t\t\treturn simplify(SUB, ty,\n\t\t\t\t\tsimplify(SUB, ty, l, r->kids[1]), r->kids[0]);\n\t\t\tbreak;\n\t\tdefault:assert(0);\n\t}\n\treturn tree(op, ty, l, r);\n}\n/* ispow2 - if u > 1 && u == 2^n, return n, otherwise return 0 */\nint ispow2(unsigned long u) {\n\tint n;\n\n\tif (u > 1 && (u&(u-1)) == 0)\n\t\tfor (n = 0; u; u >>= 1, n++)\n\t\t\tif (u&1)\n\t\t\t\treturn n;\n\treturn 0;\n}\n\n"
  },
  {
    "path": "lcc/src/sparc.md",
    "content": "%{\n#include \"c.h\"\n#define NODEPTR_TYPE Node\n#define OP_LABEL(p) ((p)->op)\n#define LEFT_CHILD(p) ((p)->kids[0])\n#define RIGHT_CHILD(p) ((p)->kids[1])\n#define STATE_LABEL(p) ((p)->x.state)\nstatic void address(Symbol, Symbol, long);\nstatic void blkfetch(int, int, int, int);\nstatic void blkloop(int, int, int, int, int, int[]);\nstatic void blkstore(int, int, int, int);\nstatic void defaddress(Symbol);\nstatic void defconst(int, int, Value);\nstatic void defstring(int, char *);\nstatic void defsymbol(Symbol);\nstatic void doarg(Node);\nstatic void emit2(Node);\nstatic void export(Symbol);\nstatic void clobber(Node);\nstatic void function(Symbol, Symbol [], Symbol [], int);\nstatic void global(Symbol);\nstatic void import(Symbol);\nstatic void local(Symbol);\nstatic void progbeg(int, char **);\nstatic void progend(void);\nstatic void segment(int);\nstatic void space(int);\nstatic void target(Node);\nstatic int imm(Node);\nstatic void renameregs(void);\nextern Interface sparcIR, solarisIR;\nstatic void defsymbol2(Symbol);\nstatic void export2(Symbol);\nstatic void globalend(void);\nstatic void global2(Symbol);\nstatic void segment2(int);\nstatic void progend2(void);\n\nextern char *stabprefix;\nextern void stabblock(int, int, Symbol*);\nextern void stabend(Coordinate *, Symbol, Coordinate **, Symbol *, Symbol *);\nextern void stabfend(Symbol, int);\nextern void stabinit(char *, int, char *[]);\nextern void stabline(Coordinate *);\nextern void stabsym(Symbol);\nextern void stabtype(Symbol);\nstatic Symbol greg[32], gregw;\nstatic Symbol *oreg = &greg[8], *ireg = &greg[24];\nstatic Symbol freg[32], freg2[32];\nstatic Symbol fregw, freg2w;\n\nstatic int regvars;\nstatic int retstruct;\n\nstatic int pflag = 0;\n\nstatic int cseg;\n\n%}\n%start stmt\n%term CNSTF4=4113\n%term CNSTF8=8209\n%term CNSTF16=16401\n%term CNSTI1=1045\n%term CNSTI2=2069\n%term CNSTI4=4117\n%term CNSTI8=8213\n%term CNSTP4=4119\n%term CNSTP8=8215\n%term CNSTU1=1046\n%term CNSTU2=2070\n%term CNSTU4=4118\n%term CNSTU8=8214\n \n%term ARGB=41\n%term ARGF4=4129\n%term ARGF8=8225\n%term ARGF16=16417\n%term ARGI4=4133\n%term ARGI8=8229\n%term ARGP4=4135\n%term ARGP8=8231\n%term ARGU4=4134\n%term ARGU8=8230\n\n%term ASGNB=57\n%term ASGNF4=4145\n%term ASGNF8=8241\n%term ASGNF16=16433\n%term ASGNI1=1077\n%term ASGNI2=2101\n%term ASGNI4=4149\n%term ASGNI8=8245\n%term ASGNP4=4151\n%term ASGNP8=8247\n%term ASGNU1=1078\n%term ASGNU2=2102\n%term ASGNU4=4150\n%term ASGNU8=8246\n\n%term INDIRB=73\n%term INDIRF4=4161\n%term INDIRF8=8257\n%term INDIRF16=16449\n%term INDIRI1=1093\n%term INDIRI2=2117\n%term INDIRI4=4165\n%term INDIRI8=8261\n%term INDIRP4=4167\n%term INDIRP8=8263\n%term INDIRU1=1094\n%term INDIRU2=2118\n%term INDIRU4=4166\n%term INDIRU8=8262\n\n%term CVFF4=4209\n%term CVFF8=8305\n%term CVFF16=16497\n%term CVFI4=4213\n%term CVFI8=8309\n\n%term CVIF4=4225\n%term CVIF8=8321\n%term CVIF16=16513\n%term CVII1=1157\n%term CVII2=2181\n%term CVII4=4229\n%term CVII8=8325\n%term CVIU1=1158\n%term CVIU2=2182\n%term CVIU4=4230\n%term CVIU8=8326\n\n%term CVPP4=4247\n%term CVPP8=8343\n%term CVPP16=16535\n%term CVPU4=4246\n%term CVPU8=8342\n\n%term CVUI1=1205\n%term CVUI2=2229\n%term CVUI4=4277\n%term CVUI8=8373\n%term CVUP4=4279\n%term CVUP8=8375\n%term CVUP16=16567\n%term CVUU1=1206\n%term CVUU2=2230\n%term CVUU4=4278\n%term CVUU8=8374\n\n%term NEGF4=4289\n%term NEGF8=8385\n%term NEGF16=16577\n%term NEGI4=4293\n%term NEGI8=8389\n\n%term CALLB=217\n%term CALLF4=4305\n%term CALLF8=8401\n%term CALLF16=16593\n%term CALLI4=4309\n%term CALLI8=8405\n%term CALLP4=4311\n%term CALLP8=8407\n%term CALLU4=4310\n%term CALLU8=8406\n%term CALLV=216\n\n%term RETF4=4337\n%term RETF8=8433\n%term RETF16=16625\n%term RETI4=4341\n%term RETI8=8437\n%term RETP4=4343\n%term RETP8=8439\n%term RETU4=4342\n%term RETU8=8438\n%term RETV=248\n\n%term ADDRGP4=4359\n%term ADDRGP8=8455\n\n%term ADDRFP4=4375\n%term ADDRFP8=8471\n\n%term ADDRLP4=4391\n%term ADDRLP8=8487\n\n%term ADDF4=4401\n%term ADDF8=8497\n%term ADDF16=16689\n%term ADDI4=4405\n%term ADDI8=8501\n%term ADDP4=4407\n%term ADDP8=8503\n%term ADDU4=4406\n%term ADDU8=8502\n\n%term SUBF4=4417\n%term SUBF8=8513\n%term SUBF16=16705\n%term SUBI4=4421\n%term SUBI8=8517\n%term SUBP4=4423\n%term SUBP8=8519\n%term SUBU4=4422\n%term SUBU8=8518\n\n%term LSHI4=4437\n%term LSHI8=8533\n%term LSHU4=4438\n%term LSHU8=8534\n\n%term MODI4=4453\n%term MODI8=8549\n%term MODU4=4454\n%term MODU8=8550\n\n%term RSHI4=4469\n%term RSHI8=8565\n%term RSHU4=4470\n%term RSHU8=8566\n\n%term BANDI4=4485\n%term BANDI8=8581\n%term BANDU4=4486\n%term BANDU8=8582\n\n%term BCOMI4=4501\n%term BCOMI8=8597\n%term BCOMU4=4502\n%term BCOMU8=8598\n\n%term BORI4=4517\n%term BORI8=8613\n%term BORU4=4518\n%term BORU8=8614\n\n%term BXORI4=4533\n%term BXORI8=8629\n%term BXORU4=4534\n%term BXORU8=8630\n\n%term DIVF4=4545\n%term DIVF8=8641\n%term DIVF16=16833\n%term DIVI4=4549\n%term DIVI8=8645\n%term DIVU4=4550\n%term DIVU8=8646\n\n%term MULF4=4561\n%term MULF8=8657\n%term MULF16=16849\n%term MULI4=4565\n%term MULI8=8661\n%term MULU4=4566\n%term MULU8=8662\n\n%term EQF4=4577\n%term EQF8=8673\n%term EQF16=16865\n%term EQI4=4581\n%term EQI8=8677\n%term EQU4=4582\n%term EQU8=8678\n\n%term GEF4=4593\n%term GEF8=8689\n%term GEI4=4597\n%term GEI8=8693\n%term GEI16=16885\n%term GEU4=4598\n%term GEU8=8694\n\n%term GTF4=4609\n%term GTF8=8705\n%term GTF16=16897\n%term GTI4=4613\n%term GTI8=8709\n%term GTU4=4614\n%term GTU8=8710\n\n%term LEF4=4625\n%term LEF8=8721\n%term LEF16=16913\n%term LEI4=4629\n%term LEI8=8725\n%term LEU4=4630\n%term LEU8=8726\n\n%term LTF4=4641\n%term LTF8=8737\n%term LTF16=16929\n%term LTI4=4645\n%term LTI8=8741\n%term LTU4=4646\n%term LTU8=8742\n\n%term NEF4=4657\n%term NEF8=8753\n%term NEF16=16945\n%term NEI4=4661\n%term NEI8=8757\n%term NEU4=4662\n%term NEU8=8758\n\n%term JUMPV=584\n\n%term LABELV=600\n\n%term LOADB=233\n%term LOADF4=4321\n%term LOADF8=8417\n%term LOADF16=16609\n%term LOADI1=1253\n%term LOADI2=2277\n%term LOADI4=4325\n%term LOADI8=8421\n%term LOADP4=4327\n%term LOADP8=8423\n%term LOADU1=1254\n%term LOADU2=2278\n%term LOADU4=4326\n%term LOADU8=8422\n\n%term VREGP=711\n%%\nreg:  INDIRI1(VREGP)     \"# read register\\n\"\nreg:  INDIRU1(VREGP)     \"# read register\\n\"\n\nreg:  INDIRI2(VREGP)     \"# read register\\n\"\nreg:  INDIRU2(VREGP)     \"# read register\\n\"\n\nreg:  INDIRF4(VREGP)     \"# read register\\n\"\nreg:  INDIRI4(VREGP)     \"# read register\\n\"\nreg:  INDIRP4(VREGP)     \"# read register\\n\"\nreg:  INDIRU4(VREGP)     \"# read register\\n\"\n\nreg:  INDIRF8(VREGP)     \"# read register\\n\"\nreg:  INDIRI8(VREGP)     \"# read register\\n\"\nreg:  INDIRP8(VREGP)     \"# read register\\n\"\nreg:  INDIRU8(VREGP)     \"# read register\\n\"\n\nstmt: ASGNI1(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNU1(VREGP,reg)  \"# write register\\n\"\n\nstmt: ASGNI2(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNU2(VREGP,reg)  \"# write register\\n\"\n\nstmt: ASGNF4(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNI4(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNP4(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNU4(VREGP,reg)  \"# write register\\n\"\n\nstmt: ASGNF8(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNI8(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNP8(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNU8(VREGP,reg)  \"# write register\\n\"\ncon: CNSTI1  \"%a\"\ncon: CNSTU1  \"%a\"\n\ncon: CNSTI2  \"%a\"\ncon: CNSTU2  \"%a\"\n\ncon: CNSTI4  \"%a\"\ncon: CNSTU4  \"%a\"\ncon: CNSTP4  \"%a\"\n\ncon: CNSTI8  \"%a\"\ncon: CNSTU8  \"%a\"\ncon: CNSTP8  \"%a\"\nstmt: reg  \"\"\nreg: ADDRGP4  \"set %a,%%%c\\n\"  1\nstk13: ADDRFP4  \"%a\"                  imm(a)\nstk13: ADDRLP4  \"%a\"                  imm(a)\nreg:   stk13   \"add %0,%%fp,%%%c\\n\"  1\nstk: ADDRFP4  \"set %a,%%%c\\n\"                      2\nstk: ADDRLP4  \"set %a,%%%c\\n\"                      2\nreg: ADDRFP4  \"set %a,%%%c\\nadd %%%c,%%fp,%%%c\\n\"  3\nreg: ADDRLP4  \"set %a,%%%c\\nadd %%%c,%%fp,%%%c\\n\"  3\ncon13: CNSTI1  \"%a\"  imm(a)\ncon13: CNSTI2  \"%a\"  imm(a)\ncon13: CNSTI4  \"%a\"  imm(a)\ncon13: CNSTU1  \"%a\"  imm(a)\ncon13: CNSTU2  \"%a\"  imm(a)\ncon13: CNSTU4  \"%a\"  imm(a)\ncon13: CNSTP4  \"%a\"  imm(a)\nbase: ADDI4(reg,con13)  \"%%%0+%1\"\nbase: ADDP4(reg,con13)  \"%%%0+%1\"\nbase: ADDU4(reg,con13)  \"%%%0+%1\"\nbase: reg    \"%%%0\"\nbase: con13  \"%0\"\nbase: stk13  \"%%fp+%0\"\naddr: base           \"%0\"\naddr: ADDI4(reg,reg)  \"%%%0+%%%1\"\naddr: ADDP4(reg,reg)  \"%%%0+%%%1\"\naddr: ADDU4(reg,reg)  \"%%%0+%%%1\"\naddr: stk            \"%%fp+%%%0\"\nreg:  INDIRI1(addr)     \"ldsb [%0],%%%c\\n\"  1\nreg:  INDIRI2(addr)     \"ldsh [%0],%%%c\\n\"  1\nreg:  INDIRI4(addr)     \"ld [%0],%%%c\\n\"    1\nreg:  INDIRU1(addr)     \"ldub [%0],%%%c\\n\"  1\nreg:  INDIRU2(addr)     \"lduh [%0],%%%c\\n\"  1\nreg:  INDIRU4(addr)     \"ld [%0],%%%c\\n\"    1\nreg:  INDIRP4(addr)     \"ld [%0],%%%c\\n\"    1\nreg:  INDIRF4(addr)     \"ld [%0],%%f%c\\n\"   1\nstmt: ASGNI1(addr,reg)  \"stb %%%1,[%0]\\n\"   1\nstmt: ASGNI2(addr,reg)  \"sth %%%1,[%0]\\n\"   1\nstmt: ASGNI4(addr,reg)  \"st %%%1,[%0]\\n\"    1\nstmt: ASGNU1(addr,reg)  \"stb %%%1,[%0]\\n\"   1\nstmt: ASGNU2(addr,reg)  \"sth %%%1,[%0]\\n\"   1\nstmt: ASGNU4(addr,reg)  \"st %%%1,[%0]\\n\"    1\nstmt: ASGNP4(addr,reg)  \"st %%%1,[%0]\\n\"    1\nstmt: ASGNF4(addr,reg)  \"st %%f%1,[%0]\\n\"   1\naddrl: ADDRLP4            \"%%%fp+%a\"          imm(a)\n\nreg:   INDIRF8(addrl)     \"ldd [%0],%%f%c\\n\"  1\nstmt:  ASGNF8(addrl,reg)  \"std %%f%1,[%0]\\n\"  1\nreg:  INDIRF8(base)     \"ld2 [%0],%%f%c\\n\"  2\nstmt: ASGNF8(base,reg)  \"st2 %%f%1,[%0]\\n\"  2\nspill:  ADDRLP4          \"%a\" !imm(a)\n\nstmt: ASGNI1(spill,reg)  \"set %0,%%g1\\nstb %%%1,[%%fp+%%g1]\\n\"\nstmt: ASGNI2(spill,reg)  \"set %0,%%g1\\nsth %%%1,[%%fp+%%g1]\\n\"\nstmt: ASGNI4(spill,reg)  \"set %0,%%g1\\nst %%%1,[%%fp+%%g1]\\n\"\nstmt: ASGNU1(spill,reg)  \"set %0,%%g1\\nstb %%%1,[%%fp+%%g1]\\n\"\nstmt: ASGNU2(spill,reg)  \"set %0,%%g1\\nsth %%%1,[%%fp+%%g1]\\n\"\nstmt: ASGNU4(spill,reg)  \"set %0,%%g1\\nst %%%1,[%%fp+%%g1]\\n\"\nstmt: ASGNP4(spill,reg)  \"set %0,%%g1\\nst %%%1,[%%fp+%%g1]\\n\"\nstmt: ASGNF4(spill,reg)  \"set %0,%%g1\\nst %%f%1,[%%fp+%%g1]\\n\"\nstmt: ASGNF8(spill,reg)  \"set %0,%%g1\\nstd %%f%1,[%%fp+%%g1]\\n\"\nreg: CVII4(INDIRI1(addr))  \"ldsb [%0],%%%c\\n\"  1\nreg: CVII4(INDIRI2(addr))  \"ldsh [%0],%%%c\\n\"  1\nreg: CVUU4(INDIRU1(addr))  \"ldub [%0],%%%c\\n\"  1\nreg: CVUU4(INDIRU2(addr))  \"lduh [%0],%%%c\\n\"  1\nreg: CVUI4(INDIRU1(addr))  \"ldub [%0],%%%c\\n\"  1\nreg: CVUI4(INDIRU2(addr))  \"lduh [%0],%%%c\\n\"  1\nreg: LOADI1(reg)  \"mov %%%0,%%%c\\n\"  move(a)\nreg: LOADI2(reg)  \"mov %%%0,%%%c\\n\"  move(a)\nreg: LOADI4(reg)  \"mov %%%0,%%%c\\n\"  move(a)\nreg: LOADP4(reg)  \"mov %%%0,%%%c\\n\"  move(a)\nreg: LOADU1(reg)  \"mov %%%0,%%%c\\n\"  move(a)\nreg: LOADU2(reg)  \"mov %%%0,%%%c\\n\"  move(a)\nreg: LOADU4(reg)  \"mov %%%0,%%%c\\n\"  move(a)\nreg: CNSTI1  \"# reg\\n\"  range(a, 0, 0)\nreg: CNSTI2  \"# reg\\n\"  range(a, 0, 0)\nreg: CNSTI4  \"# reg\\n\"  range(a, 0, 0)\nreg: CNSTP4  \"# reg\\n\"  range(a, 0, 0)\nreg: CNSTU1  \"# reg\\n\"  range(a, 0, 0)\nreg: CNSTU2  \"# reg\\n\"  range(a, 0, 0)\nreg: CNSTU4  \"# reg\\n\"  range(a, 0, 0)\nreg: con  \"set %0,%%%c\\n\"  1\nrc: con13  \"%0\"\nrc: reg    \"%%%0\"\nreg: ADDI4(reg,rc)   \"add %%%0,%1,%%%c\\n\"  1\nreg: ADDP4(reg,rc)   \"add %%%0,%1,%%%c\\n\"  1\nreg: ADDU4(reg,rc)   \"add %%%0,%1,%%%c\\n\"  1\nreg: BANDI4(reg,rc)  \"and %%%0,%1,%%%c\\n\"  1\nreg: BORI4(reg,rc)   \"or %%%0,%1,%%%c\\n\"   1\nreg: BXORI4(reg,rc)  \"xor %%%0,%1,%%%c\\n\"  1\nreg: BANDU4(reg,rc)  \"and %%%0,%1,%%%c\\n\"  1\nreg: BORU4(reg,rc)   \"or %%%0,%1,%%%c\\n\"   1\nreg: BXORU4(reg,rc)  \"xor %%%0,%1,%%%c\\n\"  1\nreg: SUBI4(reg,rc)   \"sub %%%0,%1,%%%c\\n\"  1\nreg: SUBP4(reg,rc)   \"sub %%%0,%1,%%%c\\n\"  1\nreg: SUBU4(reg,rc)   \"sub %%%0,%1,%%%c\\n\"  1\nrc5: CNSTI4  \"%a\"    range(a, 0, 31)\nrc5: reg    \"%%%0\"\nreg: LSHI4(reg,rc5)  \"sll %%%0,%1,%%%c\\n\"  1\nreg: LSHU4(reg,rc5)  \"sll %%%0,%1,%%%c\\n\"  1\nreg: RSHI4(reg,rc5)  \"sra %%%0,%1,%%%c\\n\"  1\nreg: RSHU4(reg,rc5)  \"srl %%%0,%1,%%%c\\n\"  1\nreg: BANDI4(reg,BCOMI4(rc))  \"andn %%%0,%1,%%%c\\n\"  1\nreg: BORI4(reg,BCOMI4(rc))   \"orn %%%0,%1,%%%c\\n\"   1\nreg: BXORI4(reg,BCOMI4(rc))  \"xnor %%%0,%1,%%%c\\n\"  1\nreg: BANDU4(reg,BCOMU4(rc))  \"andn %%%0,%1,%%%c\\n\"  1\nreg: BORU4(reg,BCOMU4(rc))   \"orn %%%0,%1,%%%c\\n\"   1\nreg: BXORU4(reg,BCOMU4(rc))  \"xnor %%%0,%1,%%%c\\n\"  1\nreg: NEGI4(reg)   \"neg %%%0,%%%c\\n\"  1\nreg: BCOMI4(reg)  \"not %%%0,%%%c\\n\"  1\nreg: BCOMU4(reg)  \"not %%%0,%%%c\\n\"  1\nreg: CVII4(reg)  \"sll %%%0,8*(4-%a),%%%c; sra %%%c,8*(4-%a),%%%c\\n\"  2\nreg: CVUU4(reg)  \"sll %%%0,8*(4-%a),%%%c; srl %%%c,8*(4-%a),%%%c\\n\"  2\nreg: CVUU4(reg)  \"and %%%0,0xff,%%%c\\n\" (a->syms[0]->u.c.v.i == 1 ? 1 : LBURG_MAX)\nreg: CVUU4(reg)  \"set 0xffff,%%g1; and %%%0,%%g1,%%%c\\n\"  2\nreg: CVUI4(reg)  \"and %%%0,0xff,%%%c\\n\" (a->syms[0]->u.c.v.i == 1 ? 1 : LBURG_MAX)\nreg: CVUI4(reg)  \"set 0xffff,%%g1; and %%%0,%%g1,%%%c\\n\"  2\naddrg: ADDRGP4        \"%a\"\nstmt:  JUMPV(addrg)  \"ba %0; nop\\n\"   2\nstmt:  JUMPV(addr)   \"jmp %0; nop\\n\"  2\nstmt:  LABELV        \"%a:\\n\"\nstmt: EQI4(reg,rc)  \"cmp %%%0,%1; be %a; nop\\n\"    3\nstmt: EQU4(reg,rc)  \"cmp %%%0,%1; be %a; nop\\n\"    3\nstmt: GEI4(reg,rc)  \"cmp %%%0,%1; bge %a; nop\\n\"   3\nstmt: GEU4(reg,rc)  \"cmp %%%0,%1; bgeu %a; nop\\n\"  3\nstmt: GTI4(reg,rc)  \"cmp %%%0,%1; bg %a; nop\\n\"    3\nstmt: GTU4(reg,rc)  \"cmp %%%0,%1; bgu %a; nop\\n\"   3\nstmt: LEI4(reg,rc)  \"cmp %%%0,%1; ble %a; nop\\n\"   3\nstmt: LEU4(reg,rc)  \"cmp %%%0,%1; bleu %a; nop\\n\"  3\nstmt: LTI4(reg,rc)  \"cmp %%%0,%1; bl %a; nop\\n\"    3\nstmt: LTU4(reg,rc)  \"cmp %%%0,%1; blu %a; nop\\n\"   3\nstmt: NEI4(reg,rc)  \"cmp %%%0,%1; bne %a; nop\\n\"   3\nstmt: NEU4(reg,rc)  \"cmp %%%0,%1; bne %a; nop\\n\"   3\ncall: ADDRGP4           \"%a\"\ncall: addr             \"%0\"\nreg:  CALLF8(call)      \"call %0; nop\\n\"                2\nreg:  CALLF4(call)      \"call %0; nop\\n\"                2\nreg:  CALLI4(call)      \"call %0; nop\\n\"                2\nreg:  CALLP4(call)      \"call %0; nop\\n\"                2\nreg:  CALLU4(call)      \"call %0; nop\\n\"                2\nstmt: CALLV(call)       \"call %0; nop\\n\"                2\nstmt: CALLB(call,reg)   \"call %0; st %%%1,[%%sp+64]; unimp %b&0xfff\\n\"  3\n\nstmt: RETF8(reg)  \"# ret\\n\"  1\nstmt: RETF4(reg)  \"# ret\\n\"  1\nstmt: RETI4(reg)  \"# ret\\n\"  1\nstmt: RETU4(reg)  \"# ret\\n\"  1\nstmt: RETP4(reg)  \"# ret\\n\"  1\nstmt: ARGI4(reg)  \"st %%%0,[%%sp+4*%c+68]\\n\"  1\nstmt: ARGU4(reg)  \"st %%%0,[%%sp+4*%c+68]\\n\"  1\nstmt: ARGP4(reg)  \"st %%%0,[%%sp+4*%c+68]\\n\"  1\nstmt: ARGF4(reg)  \"# ARGF4\\n\"  1\nstmt: ARGF8(reg)  \"# ARGF8\\n\"  1\n\nreg: DIVI4(reg,rc)   \"sra %%%0,31,%%g1; wr %%g0,%%g1,%%y; nop; nop; nop; sdiv %%%0,%1,%%%c\\n\"       6\n\nreg: DIVU4(reg,rc)   \"wr %%g0,%%g0,%%y; nop; nop; nop; udiv %%%0,%1,%%%c\\n\"       5\n\nreg: MODI4(reg,rc)   \"sra %%%0,31,%%g1; wr %%g0,%%g1,%%y; nop; nop; nop; sdiv %%%0,%1,%%g1\\n; smul %%g1,%1,%%g1; sub %%%0,%%g1,%%%c\\n\"  8\n\n\nreg: MODU4(reg,rc)   \"wr %%g0,%%g0,%%y; nop; nop; nop; udiv %%%0,%1,%%g1\\n; umul %%g1,%1,%%g1; sub %%%0,%%g1,%%%c\\n\"  7\n\n\nreg: MULI4(rc,reg)   \"smul %%%1,%0,%%%c\\n\"  1\nreg: MULU4(rc,reg)   \"umul %%%1,%0,%%%c\\n\"  1\nreg: ADDF8(reg,reg)  \"faddd %%f%0,%%f%1,%%f%c\\n\"  1\nreg: ADDF4(reg,reg)  \"fadds %%f%0,%%f%1,%%f%c\\n\"  1\nreg: DIVF8(reg,reg)  \"fdivd %%f%0,%%f%1,%%f%c\\n\"  1\nreg: DIVF4(reg,reg)  \"fdivs %%f%0,%%f%1,%%f%c\\n\"  1\nreg: MULF8(reg,reg)  \"fmuld %%f%0,%%f%1,%%f%c\\n\"  1\nreg: MULF4(reg,reg)  \"fmuls %%f%0,%%f%1,%%f%c\\n\"  1\nreg: SUBF8(reg,reg)  \"fsubd %%f%0,%%f%1,%%f%c\\n\"  1\nreg: SUBF4(reg,reg)  \"fsubs %%f%0,%%f%1,%%f%c\\n\"  1\nreg: NEGF4(reg)   \"fnegs %%f%0,%%f%c\\n\"  1\nreg: LOADF4(reg)  \"fmovs %%f%0,%%f%c\\n\"  1\nreg: CVFF4(reg)   \"fdtos %%f%0,%%f%c\\n\"  1\nreg: CVFF8(reg)   \"fstod %%f%0,%%f%c\\n\"  1\nreg: CVFI4(reg)  \"fstoi %%f%0,%%f0; st %%f0,[%%sp+64]; ld [%%sp+64],%%%c\\n\"  (a->syms[0]->u.c.v.i==4?3:LBURG_MAX)\n\nreg: CVFI4(reg)  \"fdtoi %%f%0,%%f0; st %%f0,[%%sp+64]; ld [%%sp+64],%%%c\\n\"  (a->syms[0]->u.c.v.i==8?3:LBURG_MAX)\n\nreg: CVIF4(reg)  \"st %%%0,[%%sp+64]; ld [%%sp+64],%%f%c; fitos %%f%c,%%f%c\\n\"  3\n\nreg: CVIF8(reg)  \"st %%%0,[%%sp+64]; ld [%%sp+64],%%f%c; fitod %%f%c,%%f%c\\n\"  3\n\nrel: EQF8(reg,reg)  \"fcmped %%f%0,%%f%1; nop; fbue\"\nrel: EQF4(reg,reg)  \"fcmpes %%f%0,%%f%1; nop; fbue\"\nrel: GEF8(reg,reg)  \"fcmped %%f%0,%%f%1; nop; fbuge\"\nrel: GEF4(reg,reg)  \"fcmpes %%f%0,%%f%1; nop; fbuge\"\nrel: GTF8(reg,reg)  \"fcmped %%f%0,%%f%1; nop; fbug\"\nrel: GTF4(reg,reg)  \"fcmpes %%f%0,%%f%1; nop; fbug\"\nrel: LEF8(reg,reg)  \"fcmped %%f%0,%%f%1; nop; fbule\"\nrel: LEF4(reg,reg)  \"fcmpes %%f%0,%%f%1; nop; fbule\"\nrel: LTF8(reg,reg)  \"fcmped %%f%0,%%f%1; nop; fbul\"\nrel: LTF4(reg,reg)  \"fcmpes %%f%0,%%f%1; nop; fbul\"\nrel: NEF8(reg,reg)  \"fcmped %%f%0,%%f%1; nop; fbne\"\nrel: NEF4(reg,reg)  \"fcmpes %%f%0,%%f%1; nop; fbne\"\n\nstmt: rel  \"%0 %a; nop\\n\"  4\nreg:  LOADF8(reg)  \"# LOADD\\n\"  2\n\nreg:  NEGF8(reg)  \"# NEGD\\n\"  2\n\nstmt:  ASGNB(reg,INDIRB(reg))  \"# ASGNB\\n\"\n\n%%\nstatic void progend(void){}\nstatic void progbeg(int argc, char *argv[]) {\n        int i;\n\n        {\n                union {\n                        char c;\n                        int i;\n                } u;\n                u.i = 0;\n                u.c = 1;\n                swap = ((int)(u.i == 1)) != IR->little_endian;\n        }\n        parseflags(argc, argv);\n        for (i = 0; i < argc; i++)\n                if (strcmp(argv[i], \"-p\") == 0 || strcmp(argv[i], \"-pg\") == 0)\n                        pflag = 1;\n        if (IR == &solarisIR)\n                stabprefix = \".LL\";\n        else\n                stabprefix = \"L\";\n        for (i = 0; i < 8; i++) {\n                greg[i +  0] = mkreg(stringf(\"g%d\", i), i +  0, 1, IREG);\n                greg[i +  8] = mkreg(stringf(\"o%d\", i), i +  8, 1, IREG);\n                greg[i + 16] = mkreg(stringf(\"l%d\", i), i + 16, 1, IREG);\n                greg[i + 24] = mkreg(stringf(\"i%d\", i), i + 24, 1, IREG);\n        }\n        gregw = mkwildcard(greg);\n        for (i = 0; i < 32; i++)\n                freg[i]  = mkreg(\"%d\", i, 1, FREG);\n        for (i = 0; i < 31; i += 2)\n                freg2[i] = mkreg(\"%d\", i, 3, FREG);\n        fregw = mkwildcard(freg);\n        freg2w = mkwildcard(freg2);\n        tmask[IREG] = 0x3fff3e00;\n        vmask[IREG] = 0x3ff00000;\n        tmask[FREG]  = ~(unsigned)0;\n        vmask[FREG]  = 0;\n}\nstatic Symbol rmap(int opk) {\n        switch (optype(opk)) {\n        case I: case U: case P: case B:\n                return gregw;\n        case F:\n                return opsize(opk) == 4 ? fregw : freg2w;\n        default:\n                return 0;\n        }\n}\nstatic void target(Node p) {\n        assert(p);\n        switch (specific(p->op)) {\n        case CNST+I: case CNST+U: case CNST+P:\n                if (range(p, 0, 0) == 0) {\n                        setreg(p, greg[0]);\n                        p->x.registered = 1;\n                }\n                break;\n        case CALL+B:\n                assert(p->syms[1] && p->syms[1]->type && isfunc(p->syms[1]->type));\n                p->syms[1] = intconst(freturn(p->syms[1]->type)->size);\n                break;\n        case CALL+F: setreg(p, opsize(p->op)==4?freg[0]:freg2[0]);     break;\n        case CALL+I: case CALL+P: case CALL+U:\n        case CALL+V: setreg(p, oreg[0]);      break;\n        case RET+F:  rtarget(p, 0, opsize(p->op)==4?freg[0]:freg2[0]);  break;\n        case RET+I: case RET+P: case RET+U:\n                rtarget(p, 0, ireg[0]);\n                p->kids[0]->x.registered = 1;\n                break;\n        case ARG+I: case ARG+P: case ARG+U:\n                if (p->syms[RX]->u.c.v.i < 6) {\n                        rtarget(p, 0, oreg[p->syms[RX]->u.c.v.i]);\n                        p->op = LOAD+opkind(p->op);\n                        setreg(p, oreg[p->syms[RX]->u.c.v.i]);\n                }\n                break;\n        }\n}\nstatic void clobber(Node p) {\n        assert(p);\n        switch (specific(p->op)) {\n        case CALL+B: case CALL+F: case CALL+I:\n                spill(~(unsigned)3, FREG, p);\n                break;\n        case CALL+V:\n                spill(oreg[0]->x.regnode->mask, IREG, p);\n                spill(~(unsigned)3, FREG, p);\n                break;\n        case ARG+F:\n                if (opsize(p->op) == 4 && p->syms[2]->u.c.v.i <= 6)\n                        spill((1<<(p->syms[2]->u.c.v.i + 8)), IREG, p);\n                else if (opsize(p->op) == 8 && p->syms[2]->u.c.v.i <= 5)\n                        spill((3<<(p->syms[2]->u.c.v.i + 8))&0xff00, IREG, p);\n                break;\n        }\n}\nstatic int imm(Node p) {\n        return range(p, -4096, 4091);\n}\nstatic void doarg(Node p) {\n        assert(p && p->syms[0] && p->op != ARG+B);\n        p->syms[RX] = intconst(mkactual(4,\n                p->syms[0]->u.c.v.i)/4);\n}\nstatic void emit2(Node p) {\n        switch (p->op) {\n        case ARG+F+sizeop(4): {\n                int n = p->syms[RX]->u.c.v.i;\n                print(\"st %%f%d,[%%sp+4*%d+68]\\n\",\n                        getregnum(p->x.kids[0]), n);\n                if (n <= 5)\n                        print(\"ld [%%sp+4*%d+68],%%o%d\\n\", n, n);\n                break;\n        }\n        case ARG+F+sizeop(8): {\n                int n = p->syms[RX]->u.c.v.i;\n                int src = getregnum(p->x.kids[0]);\n                print(\"st %%f%d,[%%sp+4*%d+68]\\n\", src, n);\n                print(\"st %%f%d,[%%sp+4*%d+68]\\n\", src+1, n+1);\n                if (n <= 5)\n                        print(\"ld [%%sp+4*%d+68],%%o%d\\n\", n, n);\n                if (n <= 4)\n                        print(\"ld [%%sp+4*%d+68],%%o%d\\n\", n+1, n+1);\n                break;\n        }\n        case LOAD+F+sizeop(8): {\n                int dst = getregnum(p);\n                int src = getregnum(p->x.kids[0]);\n                print(\"fmovs %%f%d,%%f%d; \", src,   dst);\n                print(\"fmovs %%f%d,%%f%d\\n\", src+1, dst+1);\n                break;\n        }\n        case NEG+F+sizeop(8): {\n                int dst = getregnum(p);\n                int src = getregnum(p->x.kids[0]);\n                print(\"fnegs %%f%d,%%f%d; \", src,   dst);\n                print(\"fmovs %%f%d,%%f%d\\n\", src+1, dst+1);\n                break;\n        }\n        case ASGN+B: {\n                static int tmpregs[] = { 1, 2, 3 };\n                dalign = salign = p->syms[1]->u.c.v.i;\n                blkcopy(getregnum(p->x.kids[0]), 0,\n                        getregnum(p->x.kids[1]), 0,\n                        p->syms[0]->u.c.v.i, tmpregs);\n                break;\n        }\n        }\n}\nstatic void local(Symbol p) {\n        if (retstruct) {\n                assert(p == retv);\n                p->x.name = stringd(4*16);\n                p->x.offset = 4*16;\n                p->sclass = AUTO;\n                retstruct = 0;\n                return;\n        }\n        if (isscalar(p->type) && !p->addressed && !isfloat(p->type))\n                p->sclass = REGISTER;\n        if (askregvar(p, rmap(ttob(p->type))) == 0)\n                mkauto(p);\n        else if (p->scope > LOCAL)\n                regvars++;\n}\nstatic void function(Symbol f, Symbol caller[], Symbol callee[], int ncalls) {\n        int autos = 0, i, leaf, reg, varargs;\n\n        if (IR == &solarisIR)\n                globalend();\n        regvars = 0;\n        for (i = 0; callee[i]; i++)\n                ;\n        varargs = variadic(f->type)\n                || i > 0 && strcmp(callee[i-1]->name,\n                        \"__builtin_va_alist\") == 0;\n        usedmask[0] = usedmask[1] = 0;\n        freemask[0] = freemask[1] = ~(unsigned)0;\n        for (i = 0; i < 8; i++)\n                ireg[i]->x.regnode->vbl = NULL;\n        offset = 68;\n        maxargoffset = 24;\n        reg = 0;\n        for (i = 0; callee[i]; i++) {\n                Symbol p = callee[i], q = caller[i];\n                int size = roundup(q->type->size, 4);\n                assert(q);\n                if (isfloat(p->type) || reg >= 6) {\n                        p->x.offset = q->x.offset = offset;\n                        p->x.name = q->x.name = stringd(offset);\n                        p->sclass = q->sclass = AUTO;\n                        autos++;\n                }\n                else if (p->addressed || varargs) {\n                        p->x.offset = offset;\n                        p->x.name = stringd(p->x.offset);\n                        p->sclass = AUTO;\n                        q->sclass = REGISTER;\n                        askregvar(q, ireg[reg]);\n                        assert(q->x.regnode);\n                        autos++;\n                }\n                else {\n                        p->sclass = q->sclass = REGISTER;\n                        askregvar(p, ireg[reg]);\n                        assert(p->x.regnode);\n                        q->x.name = p->x.name;\n                }\n                offset += size;\n                reg += isstruct(p->type) ? 1 : size/4;\n        }\n        assert(caller[i] == 0);\n        offset = maxoffset = 0;\n        retstruct = isstruct(freturn(f->type));\n        gencode(caller, callee);\n        maxargoffset = roundup(maxargoffset, 4);\n        framesize = roundup(maxoffset + maxargoffset + 4*(16+1), 8);\n        assert(!varargs || autos);\n        leaf = (!ncalls\n                && !maxoffset && !autos && !regvars\n                && !isstruct(freturn(f->type))\n                && !(usedmask[IREG]&0x00ffff01)\n                && !(usedmask[FREG]&~(unsigned)3)\n                && !pflag && !glevel);\n        print(\".align 4\\n%s:\\n\", f->x.name);\n        if (leaf) {\n                for (i = 0; caller[i] && callee[i]; i++) {\n                        Symbol p = caller[i], q = callee[i];\n                        if (p->sclass == REGISTER && q->sclass == REGISTER) {\n                                assert(q->x.regnode);\n                                assert(q->x.regnode->set == IREG);\n                                assert(q->x.regnode->number >= 24);\n                                assert(q->x.regnode->number <= 31);\n                                p->x.name = greg[q->x.regnode->number - 16]->x.name;\n                        }\n                }\n                renameregs();\n        } else if (framesize <= 4095)\n                print(\"save %%sp,%d,%%sp\\n\", -framesize);\n        else\n                print(\"set %d,%%g1; save %%sp,%%g1,%%sp\\n\", -framesize);\n        if (varargs)\n                for (; reg < 6; reg++)\n                        print(\"st %%i%d,[%%fp+%d]\\n\", reg, 4*reg + 68);\n        else {\n                offset = 4*(16 + 1);\n                reg = 0;\n                for (i = 0; caller[i]; i++) {\n                        Symbol p = caller[i];\n                        if (isfloat(p->type) && p->type->size == 8 && reg <= 4) {\n                                print(\"st %%r%d,[%%fp+%d]\\n\",\n                                        ireg[reg++]->x.regnode->number, offset);\n                                print(\"st %%r%d,[%%fp+%d]\\n\",\n                                        ireg[reg++]->x.regnode->number, offset + 4);\n                        } else if (isfloat(p->type) && p->type->size == 4 && reg <= 5)\n                                print(\"st %%r%d,[%%fp+%d]\\n\",\n                                        ireg[reg++]->x.regnode->number, offset);\n                        else\n                                reg++;\n                        offset += roundup(p->type->size, 4);\n                }\n        }\n        if (pflag) {\n                int lab = genlabel(1);\n                print(\"set L%d,%%o0; call mcount; nop\\n\", lab);\n                print(\".seg \\\"data\\\"\\n.align 4; L%d:.word 0\\n.seg \\\"text\\\"\\n\", lab);\n        }\n        emitcode();\n        if (isstruct(freturn(f->type)))\n                print(\"jmp %%i7+12; restore\\n\");\n        else if (!leaf)\n                print(\"ret; restore\\n\");\n        else {\n                renameregs();\n                print(\"retl; nop\\n\");\n        }\n        if (IR == &solarisIR) {\n                print(\".type %s,#function\\n\", f->x.name);\n                print(\".size %s,.-%s\\n\", f->x.name, f->x.name);\n        }\n}\n#define exch(x, y, t) (((t) = x), ((x) = (y)), ((y) = (t)))\n\nstatic void renameregs(void) {\n        int i;\n\n        for (i = 0; i < 8; i++) {\n                char *ptmp;\n                int itmp;\n                if (ireg[i]->x.regnode->vbl)\n                        ireg[i]->x.regnode->vbl->x.name = oreg[i]->x.name;\n                exch(ireg[i]->x.name, oreg[i]->x.name, ptmp);\n                exch(ireg[i]->x.regnode->number,\n                        oreg[i]->x.regnode->number, itmp);\n        }\n}\nstatic void defconst(int suffix, int size, Value v) {\n        if (suffix == F && size == 4) {\n                float f = v.d;\n                print(\".word 0x%x\\n\", *(unsigned *)&f);\n        } else if (suffix == F && size == 8) {\n                double d = v.d;\n                unsigned *p = (unsigned *)&d;\n                print(\".word 0x%x\\n.word 0x%x\\n\", p[swap], p[!swap]);\n        } else if (suffix == P)\n                print(\".word 0x%x\\n\", v.p);\n        else if (size == 1)\n                print(\".byte 0x%x\\n\", suffix == I ? v.i : v.u);\n        else if (size == 2)\n                print(\".half 0x%x\\n\", suffix == I ? v.i : v.u);\n        else if (size == 4)\n                print(\".word 0x%x\\n\", suffix == I ? v.i : v.u);\n        else assert(0);\n}\n\nstatic void defaddress(Symbol p) {\n        print(\".word %s\\n\", p->x.name);\n}\n\nstatic void defstring(int n, char *str) {\n        char *s;\n\n        for (s = str; s < str + n; s++)\n                print(\".byte %d\\n\", (*s)&0377);\n}\n\nstatic void address(Symbol q, Symbol p, long n) {\n        if (p->scope == GLOBAL || p->sclass == STATIC || p->sclass == EXTERN)\n                q->x.name = stringf(\"%s%s%D\", p->x.name, n >= 0 ? \"+\" : \"\", n);\n        else {\n                assert(n <= INT_MAX && n >= INT_MIN);\n                q->x.offset = p->x.offset + n;\n                q->x.name = stringd(q->x.offset);\n        }\n}\nstatic void export(Symbol p) {\n        print(\".global %s\\n\", p->x.name);\n}\nstatic void import(Symbol p) {}\nstatic void defsymbol(Symbol p) {\n        if (p->scope >= LOCAL && p->sclass == STATIC)\n                p->x.name = stringf(\"%d\", genlabel(1));\n        else\n                assert(p->scope != CONSTANTS || isint(p->type) || isptr(p->type)),\n                p->x.name = p->name;\n        if (p->scope >= LABELS)\n                p->x.name = stringf(p->generated ? \"L%s\" : \"_%s\",\n                        p->x.name);\n}\nstatic void segment(int n) {\n        cseg = n;\n        switch (n) {\n        case CODE: print(\".seg \\\"text\\\"\\n\"); break;\n        case BSS:  print(\".seg \\\"bss\\\"\\n\");  break;\n        case DATA: print(\".seg \\\"data\\\"\\n\"); break;\n        case LIT:  print(\".seg \\\"text\\\"\\n\"); break;\n        }\n}\nstatic void space(int n) {\n        if (cseg != BSS)\n                print(\".skip %d\\n\", n);\n}\nstatic void global(Symbol p) {\n        print(\".align %d\\n\", p->type->align);\n        assert(p->u.seg);\n        if (p->u.seg == BSS\n        && (p->sclass == STATIC || Aflag >= 2))\n                print(\".reserve %s,%d\\n\", p->x.name, p->type->size);\n        else if (p->u.seg == BSS)\n                print(\".common %s,%d\\n\",  p->x.name, p->type->size);\n        else\n                print(\"%s:\\n\", p->x.name);\n}\nstatic void blkfetch(int k, int off, int reg, int tmp) {\n        assert(k == 1 || k == 2 || k == 4);\n        assert(salign >= k);\n        if (k == 1)\n                print(\"ldub [%%r%d+%d],%%r%d\\n\", reg, off, tmp);\n        else if (k == 2)\n                print(\"lduh [%%r%d+%d],%%r%d\\n\", reg, off, tmp);\n        else\n                print(\"ld [%%r%d+%d],%%r%d\\n\",   reg, off, tmp);\n}\nstatic void blkstore(int k, int off, int reg, int tmp) {\n        assert(k == 1 || k == 2 || k == 4);\n        assert(dalign >= k);\n        if (k == 1)\n                print(\"stb %%r%d,[%%r%d+%d]\\n\", tmp, reg, off);\n        else if (k == 2)\n                print(\"sth %%r%d,[%%r%d+%d]\\n\", tmp, reg, off);\n        else\n                print(\"st %%r%d,[%%r%d+%d]\\n\",  tmp, reg, off);\n}\nstatic void blkloop(int dreg, int doff, int sreg, int soff, int size, int tmps[]) {\n        if ((size&~7) < 4096) {\n                print(\"add %%r%d,%d,%%r%d\\n\", sreg, size&~7, sreg);\n                print(\"add %%r%d,%d,%%r%d\\n\", dreg, size&~7, tmps[2]);\n        } else {\n                print(\"set %d,%%r%d\\n\", size&~7, tmps[2]);\n                print(\"add %%r%d,%%r%d,%%r%d\\n\", sreg, tmps[2], sreg);\n                print(\"add %%r%d,%%r%d,%%r%d\\n\", dreg, tmps[2], tmps[2]);\n        }\n        blkcopy(tmps[2], doff, sreg, soff, size&7, tmps);\n        print(\"1: dec 8,%%r%d\\n\", tmps[2]);\n        blkcopy(tmps[2], doff, sreg, soff - 8, 8, tmps);\n        print(\"cmp %%r%d,%%r%d; \", tmps[2], dreg);\n        print(\"bgt 1b; \");\n        print(\"dec 8,%%r%d\\n\", sreg);\n}\nstatic void defsymbol2(Symbol p) {\n        if (p->scope >= LOCAL && p->sclass == STATIC)\n                p->x.name = stringf(\".%d\", genlabel(1));\n        else\n                assert(p->scope != CONSTANTS || isint(p->type) || isptr(p->type)),\n                p->x.name = p->name;\n        if (p->scope >= LABELS)\n                p->x.name = stringf(p->generated ? \".L%s\" : \"%s\",\n                        p->x.name);\n}\n\nstatic Symbol prevg;\n\nstatic void globalend(void) {\n        if (prevg && prevg->type->size > 0)\n                print(\".size %s,%d\\n\", prevg->x.name, prevg->type->size);\n        prevg = NULL;\n}\n\nstatic void export2(Symbol p) {\n        globalend();\n        print(\".global %s\\n\", p->x.name);\n}\n\nstatic void progend2(void) {\n        globalend();\n}\n\nstatic void global2(Symbol p) {\n        globalend();\n        assert(p->u.seg);\n        if (!p->generated) {\n                print(\".type %s,#%s\\n\", p->x.name,\n                        isfunc(p->type) ? \"function\" : \"object\");\n                if (p->type->size > 0)\n                        print(\".size %s,%d\\n\", p->x.name, p->type->size);\n                else\n                        prevg = p;\n        }\n        if (p->u.seg == BSS && p->sclass == STATIC)\n                print(\".local %s\\n.common %s,%d,%d\\n\", p->x.name, p->x.name,\n                        p->type->size, p->type->align);\n        else if (p->u.seg == BSS && Aflag >= 2)\n                print(\".align %d\\n%s:.skip %d\\n\", p->type->align, p->x.name,\n                        p->type->size);\n        else if (p->u.seg == BSS)\n                print(\".common %s,%d,%d\\n\", p->x.name, p->type->size, p->type->align);\n        else\n                print(\".align %d\\n%s:\\n\", p->type->align, p->x.name);\n}\n\nstatic void segment2(int n) {\n        cseg = n;\n        switch (n) {\n        case CODE: print(\".section \\\".text\\\"\\n\");   break;\n        case BSS:  print(\".section \\\".bss\\\"\\n\");    break;\n        case DATA: print(\".section \\\".data\\\"\\n\");   break;\n        case LIT:  print(\".section \\\".rodata\\\"\\n\"); break;\n        }\n}\nInterface sparcIR = {\n        1, 1, 0,  /* char */\n        2, 2, 0,  /* short */\n        4, 4, 0,  /* int */\n        4, 4, 0,  /* long */\n        4, 4, 0,  /* long long */\n        4, 4, 1,  /* float */\n        8, 8, 1,  /* double */\n        8, 8, 1,  /* long double */\n        4, 4, 0,  /* T * */\n        0, 1, 0,  /* struct */\n        0,  /* little_endian */\n        0,  /* mulops_calls */\n        1,  /* wants_callb */\n        0,  /* wants_argb */\n        1,  /* left_to_right */\n        0,  /* wants_dag */\n        0,  /* unsigned_char */\n        address,\n        blockbeg,\n        blockend,\n        defaddress,\n        defconst,\n        defstring,\n        defsymbol,\n        emit,\n        export,\n        function,\n        gen,\n        global,\n        import,\n        local,\n        progbeg,\n        progend,\n        segment,\n        space,\n        stabblock, 0, 0, stabinit, stabline, stabsym, stabtype,\n        {\n                1,  /* max_unaligned_load */\n                rmap,\n                blkfetch, blkstore, blkloop,\n                _label,\n                _rule,\n                _nts,\n                _kids,\n                _string,\n                _templates,\n                _isinstruction,\n                _ntname,\n                emit2,\n                doarg,\n                target,\n                clobber,\n\n        }\n};\n\nInterface solarisIR = {\n        1, 1, 0,  /* char */\n        2, 2, 0,  /* short */\n        4, 4, 0,  /* int */\n        4, 4, 0,  /* long */\n        4, 4, 0,  /* long long */\n        4, 4, 1,  /* float */\n        8, 8, 1,  /* double */\n        8, 8, 1,  /* long double */\n        4, 4, 0,  /* T * */\n        0, 1, 0,  /* struct */\n        0,      /* little_endian */\n        0,      /* mulops_calls */\n        1,      /* wants_callb */\n        0,      /* wants_argb */\n        1,      /* left_to_right */\n        0,      /* wants_dag */\n        0,      /* unsigned_char */\n        address,\n        blockbeg,\n        blockend,\n        defaddress,\n        defconst,\n        defstring,\n        defsymbol2,\n        emit,\n        export2,\n        function,\n        gen,\n        global2,\n        import,\n        local,\n        progbeg,\n        progend2,\n        segment2,\n        space,\n        stabblock, 0, 0, stabinit, stabline, stabsym, stabtype,\n        {\n                1,      /* max_unaligned_load */\n                rmap,\n                blkfetch, blkstore, blkloop,\n                _label,\n                _rule,\n                _nts,\n                _kids,\n                _string,\n                _templates,\n                _isinstruction,\n                _ntname,\n                emit2,\n                doarg,\n                target,\n                clobber,\n\n        }\n};\nstatic char rcsid[] = \"$Id: sparc.md 145 2001-10-17 21:53:10Z timo $\";\n"
  },
  {
    "path": "lcc/src/stab.c",
    "content": "#include <string.h>\n#include <stdlib.h>\n#include \"c.h\"\n#include \"stab.h\"\n\n\nstatic char *currentfile;       /* current file name */\nstatic int ntypes;\n\nextern Interface sparcIR;\n\nchar *stabprefix = \"L\";\n\nextern char *stabprefix;\nextern void stabblock(int, int, Symbol*);\nextern void stabend(Coordinate *, Symbol, Coordinate **, Symbol *, Symbol *);\nextern void stabfend(Symbol, int);\nextern void stabinit(char *, int, char *[]);\nextern void stabline(Coordinate *);\nextern void stabsym(Symbol);\nextern void stabtype(Symbol);\n\nstatic void asgncode(Type, int);\nstatic void dbxout(Type);\nstatic int dbxtype(Type);\nstatic int emittype(Type, int, int);\n\n/* asgncode - assign type code to ty */\nstatic void asgncode(Type ty, int lev) {\n\tif (ty->x.marked || ty->x.typeno)\n\t\treturn;\n\tty->x.marked = 1;\n\tswitch (ty->op) {\n\tcase VOLATILE: case CONST: case VOLATILE+CONST:\n\t\tasgncode(ty->type, lev);\n\t\tty->x.typeno = ty->type->x.typeno;\n\t\tbreak;\n\tcase POINTER: case FUNCTION: case ARRAY:\n\t\tasgncode(ty->type, lev + 1);\n\t\t/* fall thru */\n\tcase VOID: case INT: case UNSIGNED: case FLOAT:\n\t\tbreak;\n\tcase STRUCT: case UNION: {\n\t\tField p;\n\t\tfor (p = fieldlist(ty); p; p = p->link)\n\t\t\tasgncode(p->type, lev + 1);\n\t\t/* fall thru */\n\tcase ENUM:\n\t\tif (ty->x.typeno == 0)\n\t\t\tty->x.typeno = ++ntypes;\n\t\tif (lev > 0 && (*ty->u.sym->name < '0' || *ty->u.sym->name > '9'))\n\t\t\tdbxout(ty);\n\t\tbreak;\n\t\t}\n\tdefault:\n\t\tassert(0);\n\t}\n}\n\n/* dbxout - output .stabs entry for type ty */\nstatic void dbxout(Type ty) {\n\tty = unqual(ty);\n\tif (!ty->x.printed) {\n\t\tint col = 0;\n\t\tprint(\".stabs \\\"\"), col += 8;\n\t\tif (ty->u.sym && !(isfunc(ty) || isarray(ty) || isptr(ty)))\n\t\t\tprint(\"%s\", ty->u.sym->name), col += strlen(ty->u.sym->name);\n\t\tprint(\":%c\", isstruct(ty) || isenum(ty) ? 'T' : 't'), col += 2;\n\t\temittype(ty, 0, col);\n\t\tprint(\"\\\",%d,0,0,0\\n\", N_LSYM);\n\t}\n}\n\n/* dbxtype - emit a stabs entry for type ty, return type code */\nstatic int dbxtype(Type ty) {\n\tasgncode(ty, 0);\n\tdbxout(ty);\n\treturn ty->x.typeno;\n}\n\n/*\n * emittype - emit ty's type number, emitting its definition if necessary.\n * Returns the output column number after emission; col is the approximate\n * output column before emission and is used to emit continuation lines for long\n * struct, union, and enum types. Continuations are not emitted for other types,\n * even if the definition is long. lev is the depth of calls to emittype.\n */\nstatic int emittype(Type ty, int lev, int col) {\n\tint tc = ty->x.typeno;\n\n\tif (isconst(ty) || isvolatile(ty)) {\n\t\tcol = emittype(ty->type, lev, col);\n\t\tty->x.typeno = ty->type->x.typeno;\n\t\tty->x.printed = 1;\n\t\treturn col;\n\t}\n\tif (tc == 0) {\n\t\tty->x.typeno = tc = ++ntypes;\n/*              fprint(2,\"`%t'=%d\\n\", ty, tc); */\n\t}\n\tprint(\"%d\", tc), col += 3;\n\tif (ty->x.printed)\n\t\treturn col;\n\tty->x.printed = 1;\n\tswitch (ty->op) {\n\tcase VOID:\t/* void is defined as itself */\n\t\tprint(\"=%d\", tc), col += 1+3;\n\t\tbreak;\n\tcase INT:\n\t\tif (ty == chartype)\t/* plain char is a subrange of itself */\n\t\t\tprint(\"=r%d;%d;%d;\", tc, ty->u.sym->u.limits.min.i, ty->u.sym->u.limits.max.i),\n\t\t\t\tcol += 2+3+2*2.408*ty->size+2;\n\t\telse\t\t\t/* other signed ints are subranges of int */\n\t\t\tprint(\"=r1;%D;%D;\", ty->u.sym->u.limits.min.i, ty->u.sym->u.limits.max.i),\n\t\t\t\tcol += 4+2*2.408*ty->size+2;\n\t\tbreak;\n\tcase UNSIGNED:\n\t\tif (ty == chartype)\t/* plain char is a subrange of itself */\n\t\t\tprint(\"=r%d;0;%u;\", tc, ty->u.sym->u.limits.max.i),\n\t\t\t\tcol += 2+3+2+2.408*ty->size+1;\n\t\telse\t\t\t/* other signed ints are subranges of int */\n\t\t\tprint(\"=r1;0;%U;\", ty->u.sym->u.limits.max.i),\n\t\t\t\tcol += 4+2.408*ty->size+1;\n\t\tbreak;\n\tcase FLOAT:\t/* float, double, long double get sizes, not ranges */\n\t\tprint(\"=r1;%d;0;\", ty->size), col += 4+1+3;\n\t\tbreak;\n\tcase POINTER:\n\t\tprint(\"=*\"), col += 2;\n\t\tcol = emittype(ty->type, lev + 1, col);\n\t\tbreak;\n\tcase FUNCTION:\n\t\tprint(\"=f\"), col += 2;\n\t\tcol = emittype(ty->type, lev + 1, col);\n\t\tbreak;\n\tcase ARRAY:\t/* array includes subscript as an int range */\n\t\tif (ty->size && ty->type->size)\n\t\t\tprint(\"=ar1;0;%d;\", ty->size/ty->type->size - 1), col += 7+3+1;\n\t\telse\n\t\t\tprint(\"=ar1;0;-1;\"), col += 10;\n\t\tcol = emittype(ty->type, lev + 1, col);\n\t\tbreak;\n\tcase STRUCT: case UNION: {\n\t\tField p;\n\t\tif (!ty->u.sym->defined) {\n\t\t\tprint(\"=x%c%s:\", ty->op == STRUCT ? 's' : 'u', ty->u.sym->name);\n\t\t\tcol += 2+1+strlen(ty->u.sym->name)+1;\n\t\t\tbreak;\n\t\t}\n\t\tif (lev > 0 && (*ty->u.sym->name < '0' || *ty->u.sym->name > '9')) {\n\t\t\tty->x.printed = 0;\n\t\t\tbreak;\n\t\t}\n\t\tprint(\"=%c%d\", ty->op == STRUCT ? 's' : 'u', ty->size), col += 1+1+3;\n\t\tfor (p = fieldlist(ty); p; p = p->link) {\n\t\t\tif (p->name)\n\t\t\t\tprint(\"%s:\", p->name), col += strlen(p->name)+1;\n\t\t\telse\n\t\t\t\tprint(\":\"), col += 1;\n\t\t\tcol = emittype(p->type, lev + 1, col);\n\t\t\tif (p->lsb)\n\t\t\t\tprint(\",%d,%d;\", 8*p->offset +\n\t\t\t\t\t(IR->little_endian ? fieldright(p) : fieldleft(p)),\n\t\t\t\t\tfieldsize(p));\n\t\t\telse\n\t\t\t\tprint(\",%d,%d;\", 8*p->offset, 8*p->type->size);\n\t\t\tcol += 1+3+1+3+1;\t/* accounts for ,%d,%d; */\n\t\t\tif (col >= 80 && p->link) {\n\t\t\t\tprint(\"\\\\\\\\\\\",%d,0,0,0\\n.stabs \\\"\", N_LSYM);\n\t\t\t\tcol = 8;\n\t\t\t}\n\t\t}\n\t\tprint(\";\"), col += 1;\n\t\tbreak;\n\t\t}\n\tcase ENUM: {\n\t\tSymbol *p;\n\t\tif (lev > 0 && (*ty->u.sym->name < '0' || *ty->u.sym->name > '9')) {\n\t\t\tty->x.printed = 0;\n\t\t\tbreak;\n\t\t}\n\t\tprint(\"=e\"), col += 2;\n\t\tfor (p = ty->u.sym->u.idlist; *p; p++) {\n\t\t\tprint(\"%s:%d,\", (*p)->name, (*p)->u.value), col += strlen((*p)->name)+3;\n\t\t\tif (col >= 80 && p[1]) {\n\t\t\t\tprint(\"\\\\\\\\\\\",%d,0,0,0\\n.stabs \\\"\", N_LSYM);\n\t\t\t\tcol = 8;\n\t\t\t}\n\t\t}\n\t\tprint(\";\"), col += 1;\n\t\tbreak;\n\t\t}\n\tdefault:\n\t\tassert(0);\n\t}\n\treturn col;\n}\n\n/* stabblock - output a stab entry for '{' or '}' at level lev */\nvoid stabblock(int brace, int lev, Symbol *p) {\n\tif (brace == '{')\n\t\twhile (*p)\n\t\t\tstabsym(*p++);\n\tif (IR == &sparcIR)\n\t\tprint(\".stabd 0x%x,0,%d\\n\", brace == '{' ? N_LBRAC : N_RBRAC, lev);\n\telse {\n\t\tint lab = genlabel(1);\n\t\tprint(\".stabn 0x%x,0,%d,%s%d-%s\\n\", brace == '{' ? N_LBRAC : N_RBRAC, lev,\n\t\t\tstabprefix, lab, cfunc->x.name);\n\t\tprint(\"%s%d:\\n\", stabprefix, lab);\n\t}\n}\n\n/* stabinit - initialize stab output */\nvoid stabinit(char *file, int argc, char *argv[]) {\n\ttypedef void (*Closure)(Symbol, void *);\n\textern char *getcwd(char *, size_t);\n\n\tprint(\".stabs \\\"lcc4_compiled.\\\",0x%x,0,0,0\\n\", N_OPT);\n\tif (file && *file) {\n\t\tchar buf[1024], *cwd = getcwd(buf, sizeof buf);\n\t\tif (cwd)\n\t\t\tprint(\".stabs \\\"%s/\\\",0x%x,0,3,%stext0\\n\", cwd, N_SO, stabprefix);\n\t\tprint(\".stabs \\\"%s\\\",0x%x,0,3,%stext0\\n\", file, N_SO, stabprefix);\n\t\t(*IR->segment)(CODE);\n\t\tprint(\"%stext0:\\n\", stabprefix, N_SO);\n\t\tcurrentfile = file;\n\t}\n\tdbxtype(inttype);\n\tdbxtype(chartype);\n\tdbxtype(doubletype);\n\tdbxtype(floattype);\n\tdbxtype(longdouble);\n\tdbxtype(longtype);\n\tdbxtype(longlong);\n\tdbxtype(shorttype);\n\tdbxtype(signedchar);\n\tdbxtype(unsignedchar);\n\tdbxtype(unsignedlong);\n\tdbxtype(unsignedlonglong);\n\tdbxtype(unsignedshort);\n\tdbxtype(unsignedtype);\n\tdbxtype(voidtype);\n\tforeach(types, GLOBAL, (Closure)stabtype, NULL);\n}\n\n/* stabline - emit stab entry for source coordinate *cp */\nvoid stabline(Coordinate *cp) {\n\tif (cp->file && cp->file != currentfile) {\n\t\tint lab = genlabel(1);\n\t\tprint(\".stabs \\\"%s\\\",0x%x,0,0,%s%d\\n\", cp->file, N_SOL, stabprefix, lab);\n\t\tprint(\"%s%d:\\n\", stabprefix, lab);\n\t\tcurrentfile = cp->file;\n\t}\n\tif (IR == &sparcIR)\n\t\tprint(\".stabd 0x%x,0,%d\\n\", N_SLINE, cp->y);\n\telse {\n\t\tint lab = genlabel(1);\n\t\tprint(\".stabn 0x%x,0,%d,%s%d-%s\\n\", N_SLINE, cp->y,\n\t\t\tstabprefix, lab, cfunc->x.name);\n\t\tprint(\"%s%d:\\n\", stabprefix, lab);\n\t}\n}\n\n/* stabsym - output a stab entry for symbol p */\nvoid stabsym(Symbol p) {\n\tint code, tc, sz = p->type->size;\n\n\tif (p->generated || p->computed)\n\t\treturn;\n\tif (isfunc(p->type)) {\n\t\tprint(\".stabs \\\"%s:%c%d\\\",%d,0,0,%s\\n\", p->name,\n\t\t\tp->sclass == STATIC ? 'f' : 'F', dbxtype(freturn(p->type)),\n\t\t\tN_FUN, p->x.name);\n\t\treturn;\n\t}\n\tif (!IR->wants_argb && p->scope == PARAM && p->structarg) {\n\t\tassert(isptr(p->type) && isstruct(p->type->type));\n\t\ttc = dbxtype(p->type->type);\n\t\tsz = p->type->type->size;\n\t} else\n\t\ttc = dbxtype(p->type);\n\tif (p->sclass == AUTO && p->scope == GLOBAL || p->sclass == EXTERN) {\n\t\tprint(\".stabs \\\"%s:G\", p->name);\n\t\tcode = N_GSYM;\n\t} else if (p->sclass == STATIC) {\n\t\tprint(\".stabs \\\"%s:%c%d\\\",%d,0,0,%s\\n\", p->name, p->scope == GLOBAL ? 'S' : 'V',\n\t\t\ttc, p->u.seg == BSS ? N_LCSYM : N_STSYM, p->x.name);\n\t\treturn;\n\t} else if (p->sclass == REGISTER) {\n\t\tif (p->x.regnode) {\n\t\t\tint r = p->x.regnode->number;\n\t\t\tif (p->x.regnode->set == FREG)\n\t\t\t\tr += 32;\t/* floating point */\n\t\t\t\tprint(\".stabs \\\"%s:%c%d\\\",%d,0,\", p->name,\n\t\t\t\t\tp->scope == PARAM ? 'P' : 'r', tc, N_RSYM);\n\t\t\tprint(\"%d,%d\\n\", sz, r);\n\t\t}\n\t\treturn;\n\t} else if (p->scope == PARAM) {\n\t\tprint(\".stabs \\\"%s:p\", p->name);\n\t\tcode = N_PSYM;\n\t} else if (p->scope >= LOCAL) {\n\t\tprint(\".stabs \\\"%s:\", p->name);\n\t\tcode = N_LSYM;\n\t} else\n\t\tassert(0);\n\tprint(\"%d\\\",%d,0,0,%s\\n\", tc, code,\n\t\tp->scope >= PARAM && p->sclass != EXTERN ? p->x.name : \"0\");\n}\n\n/* stabtype - output a stab entry for type *p */\nvoid stabtype(Symbol p) {\n\tif (p->type) {\n\t\tif (p->sclass == 0)\n\t\t\tdbxtype(p->type);\n\t\telse if (p->sclass == TYPEDEF)\n\t\t\tprint(\".stabs \\\"%s:t%d\\\",%d,0,0,0\\n\", p->name, dbxtype(p->type), N_LSYM);\n\t}\n}\n\n/* stabend - finalize a function */\nvoid stabfend(Symbol p, int lineno) {}\n\n/* stabend - finalize stab output */\nvoid stabend(Coordinate *cp, Symbol p, Coordinate **cpp, Symbol *sp, Symbol *stab) {\n\t(*IR->segment)(CODE);\n\tprint(\".stabs \\\"\\\", %d, 0, 0,%setext\\n\", N_SO, stabprefix);\n\tprint(\"%setext:\\n\", stabprefix);\n}\n"
  },
  {
    "path": "lcc/src/stab.h",
    "content": "/*      @(#)stab.h 1.11 92/05/11 SMI      */\n/*\n * Copyright (c) 1990 by Sun Microsystems, Inc.\n */\n\n/*\n * This file gives definitions supplementing <a.out.h>\n * for permanent symbol table entries.\n * These must have one of the N_STAB bits on,\n * and are subject to relocation according to the masks in <a.out.h>.\n */\n\n#ifndef _STAB_H\n#define _STAB_H\n\n\n#if !defined(_a_out_h) && !defined(_A_OUT_H)\n/* this file contains fragments of a.out.h and stab.h relevant to\n * support of stabX processing within ELF files - see the\n * Format of a symbol table entry\n */\nstruct  nlist {\n        union {\n                char    *n_name;     /* for use when in-core */\n                long    n_strx;      /* index into file string table */\n        } n_un;\n        unsigned char   n_type;      /* type flag (N_TEXT,..)  */\n        char    n_other;             /* unused */\n        short   n_desc;              /* see <stab.h> */\n        unsigned long   n_value;     /* value of symbol (or sdb offset) */ \n};\n \n/*\n * Simple values for n_type.\n */\n#define N_UNDF  0x0             /* undefined */\n#define N_ABS   0x2             /* absolute */\n#define N_TEXT  0x4             /* text */\n#define N_DATA  0x6             /* data */\n#define N_BSS   0x8             /* bss */\n#define N_COMM  0x12            /* common (internal to ld) */\n#define N_FN    0x1f            /* file name symbol */\n \n#define N_EXT   01              /* external bit, or'ed in */\n#define N_TYPE  0x1e            /* mask for all the type bits */\n\n#endif\n\n/*\n * for symbolic debugger, sdb(1):\n */\n#define\tN_GSYM\t0x20\t\t/* global symbol: name,,0,type,0 */\n#define\tN_FNAME\t0x22\t\t/* procedure name (f77 kludge): name,,0 */\n#define\tN_FUN\t0x24\t\t/* procedure: name,,0,linenumber,address */\n#define\tN_STSYM\t0x26\t\t/* static symbol: name,,0,type,address */\n#define\tN_LCSYM\t0x28\t\t/* .lcomm symbol: name,,0,type,address */\n#define N_MAIN  0x2a            /* name of main routine : name,,0,0,0 */\n#define N_ROSYM 0x2c\t\t/* ro_data objects */\n#define N_OBJ\t0x38\t\t/* object file path or name */\n#define N_OPT\t0x3c\t\t/* compiler options */\n#define\tN_RSYM\t0x40\t\t/* register sym: name,,0,type,register */\n#define\tN_SLINE\t0x44\t\t/* src line: 0,,0,linenumber,address */\n#define\tN_FLINE\t0x4c\t\t/* function start.end */\n#define\tN_SSYM\t0x60\t\t/* structure elt: name,,0,type,struct_offset */\n#define N_ENDM\t0x62\t\t/* last stab emitted for module */\n#define\tN_SO\t0x64\t\t/* source file name: name,,0,0,address */\n#define\tN_LSYM\t0x80\t\t/* local sym: name,,0,type,offset */\n#define\tN_BINCL 0x82\t\t/* header file: name,,0,0,0 */\n#define\tN_SOL\t0x84\t\t/* #included file name: name,,0,0,address */\n#define\tN_PSYM\t0xa0\t\t/* parameter: name,,0,type,offset */\n#define N_EINCL 0xa2\t\t/* end of include file */\n#define\tN_ENTRY\t0xa4\t\t/* alternate entry: name,linenumber,address */\n#define\tN_LBRAC\t0xc0\t\t/* left bracket: 0,,0,nesting level,address */\n#define\tN_EXCL\t0xc2\t\t/* excluded include file */\n#define\tN_RBRAC\t0xe0\t\t/* right bracket: 0,,0,nesting level,address */\n#define\tN_BCOMM\t0xe2\t\t/* begin common: name,, */\n#define\tN_ECOMM\t0xe4\t\t/* end common: name,, */\n#define\tN_ECOML\t0xe8\t\t/* end common (local name): ,,address */\n#define\tN_LENG\t0xfe\t\t/* second stab entry with length information */\n\n/*\n * for the berkeley pascal compiler, pc(1):\n */\n#define\tN_PC\t0x30\t\t/* global pascal symbol: name,,0,subtype,line */\n#define\tN_WITH\t0xea\t\t/* pascal with statement: type,,0,0,offset */\n\n/*\n * for code browser only\n */\n#define N_BROWS\t0x48\t\t/* path to associated .cb file */\n\n/*\n * Optional langauge designations for N_SO\n */\n#define N_SO_AS         1       /* Assembler    */\n#define N_SO_C          2       /* C            */\n#define N_SO_ANSI_C     3       /* ANSI C       */\n#define N_SO_CC         4       /* C++          */\n#define N_SO_FORTRAN    5       /* Fortran 77   */\n#define N_SO_PASCAL     6       /* Pascal       */\n\n/*\n * Floating point type values\n */\n#define NF_NONE\t\t0\t/* Undefined type \t*/\n#define NF_SINGLE\t1\t/* IEEE 32 bit float\t*/\n#define NF_DOUBLE\t2\t/* IEEE 64 bit float\t*/\n#define NF_COMPLEX\t3\t/* Fortran complex \t*/\n#define NF_COMPLEX16\t4\t/* Fortran double complex */\n#define NF_COMPLEX32\t5\t/* Fortran complex*16\t*/\n#define NF_LDOUBLE \t6\t/* Long double\t\t*/\n\n#endif\n"
  },
  {
    "path": "lcc/src/stmt.c",
    "content": "#include \"c.h\"\n\n\n#define SWSIZE 512\n\n#define den(i,j) ((j-buckets[i]+1.0)/(v[j]-v[buckets[i]]+1))\n\nstruct code codehead = { Start };\nCode codelist = &codehead;\nfloat density = 0.5;\nTable stmtlabs;\n\nstatic int foldcond(Tree e1, Tree e2);\nstatic void caselabel(Swtch, long, int);\nstatic void cmp(int, Symbol, long, int);\nstatic Tree conditional(int);\nstatic void dostmt(int, Swtch, int);\nstatic int equal(Symbol, Symbol);\nstatic void forstmt(int, Swtch, int);\nstatic void ifstmt(int, int, Swtch, int);\nstatic Symbol localaddr(Tree);\nstatic void stmtlabel(void);\nstatic void swstmt(int, int, int);\nstatic void whilestmt(int, Swtch, int);\nCode code(int kind) {\n\tCode cp;\n\n\tif (!reachable(kind))\n\t\twarning(\"unreachable code\\n\");\n\n\tNEW(cp, FUNC);\n\tcp->kind = kind;\n\tcp->prev = codelist;\n\tcp->next = NULL;\n\tcodelist->next = cp;\n\tcodelist = cp;\n\treturn cp;\n}\nint reachable(int kind) {\n\tCode cp;\n\n\tif (kind > Start) {\n\t\tCode cp;\n\t\tfor (cp = codelist; cp->kind < Label; )\n\t\t\tcp = cp->prev;\n\t\tif (cp->kind == Jump || cp->kind == Switch)\n\t\t\treturn 0;\n\t}\n\treturn 1;\n}\nvoid addlocal(Symbol p) {\n\tif (!p->defined) {\n\t\tcode(Local)->u.var = p;\n\t\tp->defined = 1;\n\t\tp->scope = level;\n\t}\n}\nvoid definept(Coordinate *p) {\n\tCode cp = code(Defpoint);\n\n\tcp->u.point.src = p ? *p : src;\n\tcp->u.point.point = npoints;\n\tif (ncalled > 0) {\n\t\tint n = findcount(cp->u.point.src.file,\n\t\t\tcp->u.point.src.x, cp->u.point.src.y);\n\t\tif (n > 0)\n\t\t\trefinc = (float)n/ncalled;\n\t}\n\tif (glevel > 2)\tlocus(identifiers, &cp->u.point.src);\n\tif (events.points && reachable(Gen))\n\t\t{\n\t\t\tTree e = NULL;\n\t\t\tapply(events.points, &cp->u.point.src, &e);\n\t\t\tif (e)\n\t\t\t\tlistnodes(e, 0, 0);\n\t\t}\n}\nvoid statement(int loop, Swtch swp, int lev) {\n\tfloat ref = refinc;\n\n\tif (Aflag >= 2 && lev == 15)\n\t\twarning(\"more than 15 levels of nested statements\\n\");\n\tswitch (t) {\n\tcase IF:       ifstmt(genlabel(2), loop, swp, lev + 1);\n break;\n\tcase WHILE:    whilestmt(genlabel(3), swp, lev + 1); break;\n\tcase DO:       dostmt(genlabel(3), swp, lev + 1); expect(';');\n\t\t\t\t\tbreak;\n\n\tcase FOR:      forstmt(genlabel(4), swp, lev + 1);\n break;\n\tcase BREAK:    walk(NULL, 0, 0);\n\t\t       definept(NULL);\n\t\t       if (swp && swp->lab > loop)\n\t\t       \tbranch(swp->lab + 1);\n\t\t       else if (loop)\n\t\t       \tbranch(loop + 2);\n\t\t       else\n\t\t       \terror(\"illegal break statement\\n\");\n\t\t       t = gettok(); expect(';');\n\t\t\t\t\t   break;\n\n\tcase CONTINUE: walk(NULL, 0, 0);\n\t\t       definept(NULL);\n\t\t       if (loop)\n\t\t       \tbranch(loop + 1);\n\t\t       else\n\t\t       \terror(\"illegal continue statement\\n\");\n\t\t       t = gettok(); expect(';');\n\t\t\t\t\t      break;\n\n\tcase SWITCH:   swstmt(loop, genlabel(2), lev + 1);\n break;\n\tcase CASE:     {\n\t\t       \tint lab = genlabel(1);\n\t\t       \tif (swp == NULL)\n\t\t       \t\terror(\"illegal case label\\n\");\n\t\t       \tdefinelab(lab);\n\t\t       \twhile (t == CASE) {\n\t\t       \t\tstatic char stop[] = { IF, ID, 0 };\n\t\t       \t\tTree p;\n\t\t       \t\tt = gettok();\n\t\t       \t\tp = constexpr(0);\n\t\t       \t\tif (generic(p->op) == CNST && isint(p->type)) {\n\t\t       \t\t\tif (swp) {\n\t\t       \t\t\t\tneedconst++;\n\t\t       \t\t\t\tp = cast(p, swp->sym->type);\n\t\t       \t\t\t\tif (p->type->op == UNSIGNED)\n\t\t       \t\t\t\t\tp->u.v.i = extend(p->u.v.u, p->type);\n\t\t       \t\t\t\tneedconst--;\n\t\t       \t\t\t\tcaselabel(swp, p->u.v.i, lab);\n\t\t       \t\t\t}\n\t\t       \t\t} else\n\t\t       \t\t\terror(\"case label must be a constant integer expression\\n\");\n\n\t\t       \t\ttest(':', stop);\n\t\t       \t}\n\t\t       \tstatement(loop, swp, lev);\n\t\t       } break;\n\tcase DEFAULT:  if (swp == NULL)\n\t\t       \terror(\"illegal default label\\n\");\n\t\t       else if (swp->deflab)\n\t\t       \terror(\"extra default label\\n\");\n\t\t       else {\n\t\t       \tswp->deflab = findlabel(swp->lab);\n\t\t       \tdefinelab(swp->deflab->u.l.label);\n\t\t       }\n\t\t       t = gettok();\n\t\t       expect(':');\n\t\t       statement(loop, swp, lev); break;\n\tcase RETURN:   {\n\t\t       \tType rty = freturn(cfunc->type);\n\t\t       \tt = gettok();\n\t\t       \tdefinept(NULL);\n\t\t       \tif (t != ';')\n\t\t       \t\tif (rty == voidtype) {\n\t\t       \t\t\terror(\"extraneous return value\\n\");\n\t\t       \t\t\texpr(0);\n\t\t       \t\t\tretcode(NULL);\n\t\t       \t\t} else\n\t\t       \t\t\tretcode(expr(0));\n\t\t       \telse {\n\t\t       \t\tif (rty != voidtype)\n\t\t       \t\t\twarning(\"missing return value\\n\");\n\t\t       \t\tretcode(NULL);\n\t\t       \t}\n\t\t       \tbranch(cfunc->u.f.label);\n\t\t       } expect(';');\n\t\t\t\t\t    break;\n\n\tcase '{':      compound(loop, swp, lev + 1); break;\n\tcase ';':      definept(NULL); t = gettok(); break;\n\tcase GOTO:     walk(NULL, 0, 0);\n\t\t       definept(NULL);\n\t\t       t = gettok();\n\t\t       if (t == ID) {\n\t\t       \tSymbol p = lookup(token, stmtlabs);\n\t\t       \tif (p == NULL) {\n\t\t\t\tp = install(token, &stmtlabs, 0, FUNC);\n\t\t\t\tp->scope = LABELS;\n\t\t\t\tp->u.l.label = genlabel(1);\n\t\t\t\tp->src = src;\n\t\t\t}\n\t\t       \tuse(p, src);\n\t\t       \tbranch(p->u.l.label);\n\t\t       \tt = gettok();\n\t\t       } else\n\t\t       \terror(\"missing label in goto\\n\"); expect(';');\n\t\t\t\t\t  break;\n\n\tcase ID:       if (getchr() == ':') {\n\t\t       \tstmtlabel();\n\t\t       \tstatement(loop, swp, lev);\n\t\t       \tbreak;\n\t\t       }\n\tdefault:       definept(NULL);\n\t\t       if (kind[t] != ID) {\n\t\t       \terror(\"unrecognized statement\\n\");\n\t\t       \tt = gettok();\n\t\t       } else {\n\t\t       \tTree e = expr0(0);\n\t\t       \tlistnodes(e, 0, 0);\n\t\t       \tif (nodecount == 0 || nodecount > 200)\n\t\t       \t\twalk(NULL, 0, 0);\n\t\t       \telse if (glevel) walk(NULL, 0, 0);\n\t\t       \tdeallocate(STMT);\n\t\t       } expect(';');\n\t\t\t\t\t\tbreak;\n\n\t}\n\tif (kind[t] != IF && kind[t] != ID\n\t&& t != '}' && t != EOI) {\n\t\tstatic char stop[] = { IF, ID, '}', 0 };\n\t\terror(\"illegal statement termination\\n\");\n\t\tskipto(0, stop);\n\t}\n\trefinc = ref;\n}\n\nstatic void ifstmt(int lab, int loop, Swtch swp, int lev) {\n\tt = gettok();\n\texpect('(');\n\tdefinept(NULL);\n\twalk(conditional(')'), 0, lab);\n\trefinc /= 2.0;\n\tstatement(loop, swp, lev);\n\tif (t == ELSE) {\n\t\tbranch(lab + 1);\n\t\tt = gettok();\n\t\tdefinelab(lab);\n\t\tstatement(loop, swp, lev);\n\t\tif (findlabel(lab + 1)->ref)\n\t\t\tdefinelab(lab + 1);\n\t} else\n\t\tdefinelab(lab);\n}\nstatic Tree conditional(int tok) {\n\tTree p = expr(tok);\n\n\tif (Aflag > 1 && isfunc(p->type))\n\t\twarning(\"%s used in a conditional expression\\n\",\n\t\t\tfuncname(p));\n\treturn cond(p);\n}\nstatic void stmtlabel(void) {\n\tSymbol p = lookup(token, stmtlabs);\n\n\tif (p == NULL) {\n\t\tp = install(token, &stmtlabs, 0, FUNC);\n\t\tp->scope = LABELS;\n\t\tp->u.l.label = genlabel(1);\n\t\tp->src = src;\n\t}\n\tif (p->defined)\n\t\terror(\"redefinition of label `%s' previously defined at %w\\n\", p->name, &p->src);\n\n\tp->defined = 1;\n\tdefinelab(p->u.l.label);\n\tt = gettok();\n\texpect(':');\n}\nstatic void forstmt(int lab, Swtch swp, int lev) {\n\tint once = 0;\n\tTree e1 = NULL, e2 = NULL, e3 = NULL;\n\tCoordinate pt2, pt3;\n\t\n\tt = gettok();\n\texpect('(');\n\tdefinept(NULL);\n\tif (kind[t] == ID)\n\t\te1 = texpr(expr0, ';', FUNC);\n\telse\n\t\texpect(';');\n\twalk(e1, 0, 0);\n\tpt2 = src;\n\trefinc *= 10.0;\n\tif (kind[t] == ID)\n\t\te2 = texpr(conditional, ';', FUNC);\n\telse\n\t\texpect(';');\n\tpt3 = src;\n\tif (kind[t] == ID)\n\t\te3 = texpr(expr0, ')', FUNC);\n\telse {\n\t\tstatic char stop[] = { IF, ID, '}', 0 };\n\t\ttest(')', stop);\n\t}\n\tif (e2) {\n\t\tonce = foldcond(e1, e2);\n\t\tif (!once)\n\t\t\tbranch(lab + 3);\n\t}\n\tdefinelab(lab);\n\tstatement(lab, swp, lev);\n\tdefinelab(lab + 1);\n\tdefinept(&pt3);\n\tif (e3)\n\t\twalk(e3, 0, 0);\n\tif (e2) {\n\t\tif (!once)\n\t\t\tdefinelab(lab + 3);\n\t\tdefinept(&pt2);\n\t\twalk(e2, lab, 0);\n\t} else {\n\t\tdefinept(&pt2);\n\t\tbranch(lab);\n\t}\n\tif (findlabel(lab + 2)->ref)\n\t\tdefinelab(lab + 2);\n}\nstatic void swstmt(int loop, int lab, int lev) {\n\tTree e;\n\tstruct swtch sw;\n\tCode head, tail;\n\n\tt = gettok();\n\texpect('(');\n\tdefinept(NULL);\n\te = expr(')');\n\tif (!isint(e->type)) {\n\t\terror(\"illegal type `%t' in switch expression\\n\",\n\t\t\te->type);\n\t\te = retype(e, inttype);\n\t}\n\te = cast(e, promote(e->type));\n\tif (generic(e->op) == INDIR && isaddrop(e->kids[0]->op)\n\t&& e->kids[0]->u.sym->type == e->type\n\t&& !isvolatile(e->kids[0]->u.sym->type)) {\n\t\tsw.sym = e->kids[0]->u.sym;\n\t\twalk(NULL, 0, 0);\n\t} else {\n\t\tsw.sym = genident(REGISTER, e->type, level);\n\t\taddlocal(sw.sym);\n\t\twalk(asgn(sw.sym, e), 0, 0);\n\t}\n\thead = code(Switch);\n\tsw.lab = lab;\n\tsw.deflab = NULL;\n\tsw.ncases = 0;\n\tsw.size = SWSIZE;\n\tsw.values = newarray(SWSIZE, sizeof *sw.values, FUNC);\n\tsw.labels = newarray(SWSIZE, sizeof *sw.labels, FUNC);\n\trefinc /= 10.0;\n\tstatement(loop, &sw, lev);\n\tif (sw.deflab == NULL) {\n\t\tsw.deflab = findlabel(lab);\n\t\tdefinelab(lab);\n\t\tif (sw.ncases == 0)\n\t\t\twarning(\"switch statement with no cases\\n\");\n\t}\n\tif (findlabel(lab + 1)->ref)\n\t\tdefinelab(lab + 1);\n\ttail = codelist;\n\tcodelist = head->prev;\n\tcodelist->next = head->prev = NULL;\n\tif (sw.ncases > 0)\n\t\tswgen(&sw);\n\tbranch(lab);\n\thead->next->prev = codelist;\n\tcodelist->next = head->next;\n\tcodelist = tail;\n}\nstatic void caselabel(Swtch swp, long val, int lab) {\n\tint k;\n\n\tif (swp->ncases >= swp->size)\n\t\t{\n\t\tlong   *vals = swp->values;\n\t\tSymbol *labs = swp->labels;\n\t\tswp->size *= 2;\n\t\tswp->values = newarray(swp->size, sizeof *swp->values, FUNC);\n\t\tswp->labels = newarray(swp->size, sizeof *swp->labels, FUNC);\n\t\tfor (k = 0; k < swp->ncases; k++) {\n\t\t\tswp->values[k] = vals[k];\n\t\t\tswp->labels[k] = labs[k];\n\t\t}\n\t\t}\n\tk = swp->ncases;\n\tfor ( ; k > 0 && swp->values[k-1] >= val; k--) {\n\t\tswp->values[k] = swp->values[k-1];\n\t\tswp->labels[k] = swp->labels[k-1];\n\t}\n\tif (k < swp->ncases && swp->values[k] == val)\n\t\terror(\"duplicate case label `%d'\\n\", val);\n\tswp->values[k] = val;\n\tswp->labels[k] = findlabel(lab);\n\t++swp->ncases;\n\tif (Aflag >= 2 && swp->ncases == 258)\n\t\twarning(\"more than 257 cases in a switch\\n\");\n}\nvoid swgen(Swtch swp) {\n\tint *buckets, k, n;\n\tlong *v = swp->values;\n\n\tbuckets = newarray(swp->ncases + 1,\n\t\tsizeof *buckets, FUNC);\n\tfor (n = k = 0; k < swp->ncases; k++, n++) {\n\t\tbuckets[n] = k;\n\t\twhile (n > 0 && den(n-1, k) >= density)\n\t\t\tn--;\n\t}\n\tbuckets[n] = swp->ncases;\n\tswcode(swp, buckets, 0, n - 1);\n}\nvoid swcode(Swtch swp, int b[], int lb, int ub) {\n\tint hilab, lolab, l, u, k = (lb + ub)/2;\n\tlong *v = swp->values;\n\n\tif (k > lb && k < ub) {\n\t\tlolab = genlabel(1);\n\t\thilab = genlabel(1);\n\t} else if (k > lb) {\n\t\tlolab = genlabel(1);\n\t\thilab = swp->deflab->u.l.label;\n\t} else if (k < ub) {\n\t\tlolab = swp->deflab->u.l.label;\n\t\thilab = genlabel(1);\n\t} else\n\t\tlolab = hilab = swp->deflab->u.l.label;\n\tl = b[k];\n\tu = b[k+1] - 1;\n\tif (u - l + 1 <= 3)\n\t\t{\n\t\t\tint i;\n\t\t\tfor (i = l; i <= u; i++)\n\t\t\t\tcmp(EQ, swp->sym, v[i], swp->labels[i]->u.l.label);\n\t\t\tif (k > lb && k < ub)\n\t\t\t\tcmp(GT, swp->sym, v[u], hilab);\n\t\t\telse if (k > lb)\n\t\t\t\tcmp(GT, swp->sym, v[u], hilab);\n\t\t\telse if (k < ub)\n\t\t\t\tcmp(LT, swp->sym, v[l], lolab);\n\t\t\telse\n\t\t\t\tassert(lolab == hilab),\n\t\t\t\tbranch(lolab);\n\t\t\twalk(NULL, 0, 0);\n\t\t}\n\telse {\n\t\tTree e;\n\t\tType ty = signedint(swp->sym->type);\n\t\tSymbol table = genident(STATIC,\n\t\t\tarray(voidptype, u - l + 1, 0), GLOBAL);\n\t\t(*IR->defsymbol)(table);\n\t\tif (!isunsigned(swp->sym->type) || v[l] != 0)\n\t\t\tcmp(LT, swp->sym, v[l], lolab);\n\t\tcmp(GT, swp->sym, v[u], hilab);\n\t\te = (*optree['-'])(SUB, cast(idtree(swp->sym), ty), cnsttree(ty, v[l]));\n\t\tif (e->type->size < unsignedptr->size)\n\t\t\te = cast(e, unsignedlong);\n\t\twalk(tree(JUMP, voidtype,\n\t\t\trvalue((*optree['+'])(ADD, pointer(idtree(table)), e)), NULL),\n\t\t\t0, 0);\n\t\tcode(Switch);\n\t\tcodelist->u.swtch.table = table;\n\t\tcodelist->u.swtch.sym = swp->sym;\n\t\tcodelist->u.swtch.deflab = swp->deflab;\n\t\tcodelist->u.swtch.size = u - l + 1;\n\t\tcodelist->u.swtch.values = &v[l];\n\t\tcodelist->u.swtch.labels = &swp->labels[l];\n\t\tif (v[u] - v[l] + 1 >= 10000)\n\t\t\twarning(\"switch generates a huge table\\n\");\n\t}\n\tif (k > lb) {\n\t\tassert(lolab != swp->deflab->u.l.label);\n\t\tdefinelab(lolab);\n\t\tswcode(swp, b, lb, k - 1);\n\t}\n\tif (k < ub) {\n\t\tassert(hilab != swp->deflab->u.l.label);\n\t\tdefinelab(hilab);\n\t\tswcode(swp, b, k + 1, ub);\n\t}\n}\nstatic void cmp(int op, Symbol p, long n, int lab) {\n\tType ty = signedint(p->type);\n\n\tlistnodes(eqtree(op,\n\t\t\tcast(idtree(p), ty),\n\t\t\tcnsttree(ty, n)),\n\t\tlab, 0);\n}\nvoid retcode(Tree p) {\n\tType ty;\n\n\tif (p == NULL) {\n\t\tif (events.returns)\n\t\t\tapply(events.returns, cfunc, NULL);\n\t\treturn;\n\t}\n\tp = pointer(p);\n\tty = assign(freturn(cfunc->type), p);\n\tif (ty == NULL) {\n\t\terror(\"illegal return type; found `%t' expected `%t'\\n\",\n\t\t\tp->type, freturn(cfunc->type));\n\t\treturn;\n\t}\n\tp = cast(p, ty);\n\tif (retv)\n\t\t{\n\t\t\tif (iscallb(p))\n\t\t\t\tp = tree(RIGHT, p->type,\n\t\t\t\t\ttree(CALL+B, p->type,\n\t\t\t\t\t\tp->kids[0]->kids[0], idtree(retv)),\n\t\t\t\t\trvalue(idtree(retv)));\n\t\t\telse\n\t\t\t\tp = asgntree(ASGN, rvalue(idtree(retv)), p);\n\t\t\twalk(p, 0, 0);\n\t\t\tif (events.returns)\n\t\t\t\tapply(events.returns, cfunc, rvalue(idtree(retv)));\n\t\t\treturn;\n\t\t}\n\tif (events.returns)\n\t\t{\n\t\t\tSymbol t1 = genident(AUTO, p->type, level);\n\t\t\taddlocal(t1);\n\t\t\twalk(asgn(t1, p), 0, 0);\n\t\t\tapply(events.returns, cfunc, idtree(t1));\n\t\t\tp = idtree(t1);\n\t\t}\n\tif (!isfloat(p->type))\n\t\tp = cast(p, promote(p->type));\n\tif (isptr(p->type))\n\t\t{\n\t\t\tSymbol q = localaddr(p);\n\t\t\tif (q && (q->computed || q->generated))\n\t\t\t\twarning(\"pointer to a %s is an illegal return value\\n\",\n\t\t\t\t\tq->scope == PARAM ? \"parameter\" : \"local\");\n\t\t\telse if (q)\n\t\t\t\twarning(\"pointer to %s `%s' is an illegal return value\\n\",\n\t\t\t\t\tq->scope == PARAM ? \"parameter\" : \"local\", q->name);\n\t\t}\n\twalk(tree(mkop(RET,p->type), p->type, p, NULL), 0, 0);\n}\nvoid definelab(int lab) {\n\tCode cp;\n\tSymbol p = findlabel(lab);\n\n\tassert(lab);\n\twalk(NULL, 0, 0);\n\tcode(Label)->u.forest = newnode(LABEL+V, NULL, NULL, p);\n\tfor (cp = codelist->prev; cp->kind <= Label; )\n\t\tcp = cp->prev;\n\twhile (   cp->kind == Jump\n\t       && cp->u.forest->kids[0]\n\t       && specific(cp->u.forest->kids[0]->op) == ADDRG+P\n\t       && cp->u.forest->kids[0]->syms[0] == p) {\n\t\tassert(cp->u.forest->kids[0]->syms[0]->u.l.label == lab);\n\t\tp->ref--;\n\t\tassert(cp->next);\n\t\tassert(cp->prev);\n\t\tcp->prev->next = cp->next;\n\t\tcp->next->prev = cp->prev;\n\t\tcp = cp->prev;\n\t\twhile (cp->kind <= Label)\n\t\t\tcp = cp->prev;\n\t}\n}\nNode jump(int lab) {\n\tSymbol p = findlabel(lab);\n\n\tp->ref++;\n\treturn newnode(JUMP+V, newnode(ADDRG+ttob(voidptype), NULL, NULL, p),\n\t\tNULL, NULL);\n}\nvoid branch(int lab) {\n\tCode cp;\n\tSymbol p = findlabel(lab);\n\n\tassert(lab);\n\twalk(NULL, 0, 0);\n\tcode(Label)->u.forest = jump(lab);\n\tfor (cp = codelist->prev; cp->kind < Label; )\n\t\tcp = cp->prev;\n\twhile (   cp->kind == Label\n\t       && cp->u.forest->op == LABEL+V\n\t       && !equal(cp->u.forest->syms[0], p)) {\n\t\tequatelab(cp->u.forest->syms[0], p);\n\t\tassert(cp->next);\n\t\tassert(cp->prev);\n\t\tcp->prev->next = cp->next;\n\t\tcp->next->prev = cp->prev;\n\t\tcp = cp->prev;\n\t\twhile (cp->kind < Label)\n\t\t\tcp = cp->prev;\n\t}\n\tif (cp->kind == Jump || cp->kind == Switch) {\n\t\tp->ref--;\n\t\tcodelist->prev->next = NULL;\n\t\tcodelist = codelist->prev;\n\t} else {\n\t\tcodelist->kind = Jump;\n\t\tif (cp->kind == Label\n\t\t&&  cp->u.forest->op == LABEL+V\n\t\t&&  equal(cp->u.forest->syms[0], p))\n\t\t\twarning(\"source code specifies an infinite loop\");\n\t}\n}\nvoid equatelab(Symbol old, Symbol new) {\n\tassert(old->u.l.equatedto == NULL);\n\told->u.l.equatedto = new;\n\tnew->ref++;\n}\nstatic int equal(Symbol lprime, Symbol dst) {\n\tassert(dst && lprime);\n\tfor ( ; dst; dst = dst->u.l.equatedto)\n\t\tif (lprime == dst)\n\t\t\treturn 1;\n\treturn 0;\n}\n/* dostmt - do statement while ( expression ) */\nstatic void dostmt(int lab, Swtch swp, int lev) {\n\trefinc *= 10.0;\n\tt = gettok();\n\tdefinelab(lab);\n\tstatement(lab, swp, lev);\n\tdefinelab(lab + 1);\n\texpect(WHILE);\n\texpect('(');\n\tdefinept(NULL);\n\twalk(conditional(')'), lab, 0);\n\tif (findlabel(lab + 2)->ref)\n\t\tdefinelab(lab + 2);\n}\n\n/* foldcond - check if initial test in for(e1;e2;e3) S is necessary */\nstatic int foldcond(Tree e1, Tree e2) {\n\tint op = generic(e2->op);\n\tSymbol v;\n\n\tif (e1 == 0 || e2 == 0)\n\t\treturn 0;\n\tif (generic(e1->op) == ASGN && isaddrop(e1->kids[0]->op)\n\t&& generic(e1->kids[1]->op) == CNST) {\n\t\tv = e1->kids[0]->u.sym;\n\t\te1 = e1->kids[1];\n\t} else\n\t\treturn 0;\n\tif ((op==LE || op==LT || op==EQ || op==NE || op==GT || op==GE)\n\t&& generic(e2->kids[0]->op) == INDIR\n\t&& e2->kids[0]->kids[0]->u.sym == v\n\t&& e2->kids[1]->op == e1->op) {\n\t\te1 = simplify(op, e2->type, e1, e2->kids[1]);\n\t\tif (e1->op == CNST+I)\n\t\t\treturn e1->u.v.i;\n\t}\n\treturn 0;\n}\n\n/* localaddr - returns q if p yields the address of local/parameter q; otherwise returns 0 */\nstatic Symbol localaddr(Tree p) {\n\tif (p == NULL)\n\t\treturn NULL;\n\tswitch (generic(p->op)) {\n\tcase INDIR: case CALL: case ARG:\n\t\treturn NULL;\n\tcase ADDRL: case ADDRF:\n\t\treturn p->u.sym;\n\tcase RIGHT: case ASGN:\n\t\tif (p->kids[1])\n\t\t\treturn localaddr(p->kids[1]);\n\t\treturn localaddr(p->kids[0]);\n\tcase COND: {\n\t\tSymbol q;\n\t\tassert(p->kids[1] && p->kids[1]->op == RIGHT);\n\t\tif ((q = localaddr(p->kids[1]->kids[0])) != NULL)\n\t\t\treturn q;\n\t\treturn localaddr(p->kids[1]->kids[1]);\n\t\t}\n\tdefault: {\n\t\tSymbol q;\n\t\tif (p->kids[0] && (q = localaddr(p->kids[0])) != NULL)\n\t\t\treturn q;\n\t\treturn localaddr(p->kids[1]);\n\t\t}\n\t}\n}\n\n/* whilestmt - while ( expression ) statement */\nstatic void whilestmt(int lab, Swtch swp, int lev) {\n\tCoordinate pt;\n\tTree e;\n\n\trefinc *= 10.0;\n\tt = gettok();\n\texpect('(');\n\twalk(NULL, 0, 0);\n\tpt = src;\n\te = texpr(conditional, ')', FUNC);\n\tbranch(lab + 1);\n\tdefinelab(lab);\n\tstatement(lab, swp, lev);\n\tdefinelab(lab + 1);\n\tdefinept(&pt);\n\twalk(e, lab, 0);\n\tif (findlabel(lab + 2)->ref)\n\t\tdefinelab(lab + 2);\n}\n"
  },
  {
    "path": "lcc/src/string.c",
    "content": "#include \"c.h\"\n\n\nstatic struct string {\n\tchar *str;\n\tint len;\n\tstruct string *link;\n} *buckets[1024];\nstatic int scatter[] = {\t/* map characters to random values */\n\t2078917053, 143302914, 1027100827, 1953210302, 755253631,\n\t2002600785, 1405390230, 45248011, 1099951567, 433832350,\n\t2018585307, 438263339, 813528929, 1703199216, 618906479,\n\t573714703, 766270699, 275680090, 1510320440, 1583583926,\n\t1723401032, 1965443329, 1098183682, 1636505764, 980071615,\n\t1011597961, 643279273, 1315461275, 157584038, 1069844923,\n\t471560540, 89017443, 1213147837, 1498661368, 2042227746,\n\t1968401469, 1353778505, 1300134328, 2013649480, 306246424,\n\t1733966678, 1884751139, 744509763, 400011959, 1440466707,\n\t1363416242, 973726663, 59253759, 1639096332, 336563455,\n\t1642837685, 1215013716, 154523136, 593537720, 704035832,\n\t1134594751, 1605135681, 1347315106, 302572379, 1762719719,\n\t269676381, 774132919, 1851737163, 1482824219, 125310639,\n\t1746481261, 1303742040, 1479089144, 899131941, 1169907872,\n\t1785335569, 485614972, 907175364, 382361684, 885626931,\n\t200158423, 1745777927, 1859353594, 259412182, 1237390611,\n\t48433401, 1902249868, 304920680, 202956538, 348303940,\n\t1008956512, 1337551289, 1953439621, 208787970, 1640123668,\n\t1568675693, 478464352, 266772940, 1272929208, 1961288571,\n\t392083579, 871926821, 1117546963, 1871172724, 1771058762,\n\t139971187, 1509024645, 109190086, 1047146551, 1891386329,\n\t994817018, 1247304975, 1489680608, 706686964, 1506717157,\n\t579587572, 755120366, 1261483377, 884508252, 958076904,\n\t1609787317, 1893464764, 148144545, 1415743291, 2102252735,\n\t1788268214, 836935336, 433233439, 2055041154, 2109864544,\n\t247038362, 299641085, 834307717, 1364585325, 23330161,\n\t457882831, 1504556512, 1532354806, 567072918, 404219416,\n\t1276257488, 1561889936, 1651524391, 618454448, 121093252,\n\t1010757900, 1198042020, 876213618, 124757630, 2082550272,\n\t1834290522, 1734544947, 1828531389, 1982435068, 1002804590,\n\t1783300476, 1623219634, 1839739926, 69050267, 1530777140,\n\t1802120822, 316088629, 1830418225, 488944891, 1680673954,\n\t1853748387, 946827723, 1037746818, 1238619545, 1513900641,\n\t1441966234, 367393385, 928306929, 946006977, 985847834,\n\t1049400181, 1956764878, 36406206, 1925613800, 2081522508,\n\t2118956479, 1612420674, 1668583807, 1800004220, 1447372094,\n\t523904750, 1435821048, 923108080, 216161028, 1504871315,\n\t306401572, 2018281851, 1820959944, 2136819798, 359743094,\n\t1354150250, 1843084537, 1306570817, 244413420, 934220434,\n\t672987810, 1686379655, 1301613820, 1601294739, 484902984,\n\t139978006, 503211273, 294184214, 176384212, 281341425,\n\t228223074, 147857043, 1893762099, 1896806882, 1947861263,\n\t1193650546, 273227984, 1236198663, 2116758626, 489389012,\n\t593586330, 275676551, 360187215, 267062626, 265012701,\n\t719930310, 1621212876, 2108097238, 2026501127, 1865626297,\n\t894834024, 552005290, 1404522304, 48964196, 5816381,\n\t1889425288, 188942202, 509027654, 36125855, 365326415,\n\t790369079, 264348929, 513183458, 536647531, 13672163,\n\t313561074, 1730298077, 286900147, 1549759737, 1699573055,\n\t776289160, 2143346068, 1975249606, 1136476375, 262925046,\n\t92778659, 1856406685, 1884137923, 53392249, 1735424165,\n\t1602280572\n};\nchar *string(const char *str) {\n\tconst char *s;\n\n\tfor (s = str; *s; s++)\n\t\t;\n\treturn stringn(str, s - str);\n}\nchar *stringd(long n) {\n\tchar str[25], *s = str + sizeof (str);\n\tunsigned long m;\n\n\tif (n == LONG_MIN)\n\t\tm = (unsigned long)LONG_MAX + 1;\n\telse if (n < 0)\n\t\tm = -n;\n\telse\n\t\tm = n;\n\tdo\n\t\t*--s = m%10 + '0';\n\twhile ((m /= 10) != 0);\n\tif (n < 0)\n\t\t*--s = '-';\n\treturn stringn(s, str + sizeof (str) - s);\n}\nchar *stringn(const char *str, int len) {\n\tint i;\n\tunsigned int h;\n\tconst char *end;\n\tstruct string *p;\n\n\tassert(str);\n\tfor (h = 0, i = len, end = str; i > 0; i--)\n\t\th = (h<<1) + scatter[*(unsigned char *)end++];\n\th &= NELEMS(buckets)-1;\n\tfor (p = buckets[h]; p; p = p->link)\n\t\tif (len == p->len) {\n\t\t\tconst char *s1 = str;\n\t\t\tchar *s2 = p->str;\n\t\t\tdo {\n\t\t\t\tif (s1 == end)\n\t\t\t\t\treturn p->str;\n\t\t\t} while (*s1++ == *s2++);\n\t\t}\n\t{\n\t\tstatic char *next, *strlimit;\n\t\tif (len + 1 >= strlimit - next) {\n\t\t\tint n = len + 4*1024;\n\t\t\tnext = allocate(n, PERM);\n\t\t\tstrlimit = next + n;\n\t\t}\n\t\tNEW(p, PERM);\n\t\tp->len = len;\n\t\tfor (p->str = next; str < end; )\n\t\t\t*next++ = *str++;\n\t\t*next++ = 0;\n\t\tp->link = buckets[h];\n\t\tbuckets[h] = p;\n\t\treturn p->str;\n\t}\n}\n"
  },
  {
    "path": "lcc/src/sym.c",
    "content": "#include \"c.h\"\n#include <stdio.h>\n\n\n#define equalp(x) v.x == p->sym.u.c.v.x\n\nstruct table {\n\tint level;\n\tTable previous;\n\tstruct entry {\n\t\tstruct symbol sym;\n\t\tstruct entry *link;\n\t} *buckets[256];\n\tSymbol all;\n};\n#define HASHSIZE NELEMS(((Table)0)->buckets)\nstatic struct table\n\tcns = { CONSTANTS },\n\text = { GLOBAL },\n\tids = { GLOBAL },\n\ttys = { GLOBAL };\nTable constants   = &cns;\nTable externals   = &ext;\nTable identifiers = &ids;\nTable globals     = &ids;\nTable types       = &tys;\nTable labels;\nint level = GLOBAL;\nstatic int tempid;\nList loci, symbols;\n\nTable table(Table tp, int level) {\n\tTable new;\n\n\tNEW0(new, FUNC);\n\tnew->previous = tp;\n\tnew->level = level;\n\tif (tp)\n\t\tnew->all = tp->all;\n\treturn new;\n}\nvoid foreach(Table tp, int lev, void (*apply)(Symbol, void *), void *cl) {\n\tassert(tp);\n\twhile (tp && tp->level > lev)\n\t\ttp = tp->previous;\n\tif (tp && tp->level == lev) {\n\t\tSymbol p;\n\t\tCoordinate sav;\n\t\tsav = src;\n\t\tfor (p = tp->all; p && p->scope == lev; p = p->up) {\n\t\t\tsrc = p->src;\n\t\t\t(*apply)(p, cl);\n\t\t}\n\t\tsrc = sav;\n\t}\n}\nvoid enterscope(void) {\n\tif (++level == LOCAL)\n\t\ttempid = 0;\n}\nvoid exitscope(void) {\n\trmtypes(level);\n\tif (types->level == level)\n\t\ttypes = types->previous;\n\tif (identifiers->level == level) {\n\t\tif (Aflag >= 2) {\n\t\t\tint n = 0;\n\t\t\tSymbol p;\n\t\t\tfor (p = identifiers->all; p && p->scope == level; p = p->up)\n\t\t\t\tif (++n > 127) {\n\t\t\t\t\twarning(\"more than 127 identifiers declared in a block\\n\");\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t}\n\t\tidentifiers = identifiers->previous;\n\t}\n\tassert(level >= GLOBAL);\n\t--level;\n}\nSymbol install(const char *name, Table *tpp, int level, int arena) {\n\tTable tp = *tpp;\n\tstruct entry *p;\n\tunsigned h = (unsigned long)name&(HASHSIZE-1);\n\n\tassert(level == 0 || level >= tp->level);\n\tif (level > 0 && tp->level < level)\n\t\ttp = *tpp = table(tp, level);\n\tNEW0(p, arena);\n\tp->sym.name = (char *)name;\n\tp->sym.scope = level;\n\tp->sym.up = tp->all;\n\ttp->all = &p->sym;\n\tp->link = tp->buckets[h];\n\ttp->buckets[h] = p;\n\treturn &p->sym;\n}\nSymbol relocate(const char *name, Table src, Table dst) {\n\tstruct entry *p, **q;\n\tSymbol *r;\n\tunsigned h = (unsigned long)name&(HASHSIZE-1);\n\n\tfor (q = &src->buckets[h]; *q; q = &(*q)->link)\n\t\tif (name == (*q)->sym.name)\n\t\t\tbreak;\n\tassert(*q);\n\t/*\n\t Remove the entry from src's hash chain\n\t  and from its list of all symbols.\n\t*/\n\tp = *q;\n\t*q = (*q)->link;\n\tfor (r = &src->all; *r && *r != &p->sym; r = &(*r)->up)\n\t\t;\n\tassert(*r == &p->sym);\n\t*r = p->sym.up;\n\t/*\n\t Insert the entry into dst's hash chain\n\t  and into its list of all symbols.\n\t  Return the symbol-table entry.\n\t*/\n\tp->link = dst->buckets[h];\n\tdst->buckets[h] = p;\n\tp->sym.up = dst->all;\n\tdst->all = &p->sym;\n\treturn &p->sym;\n}\nSymbol lookup(const char *name, Table tp) {\n\tstruct entry *p;\n\tunsigned h = (unsigned long)name&(HASHSIZE-1);\n\n\tassert(tp);\n\tdo\n\t\tfor (p = tp->buckets[h]; p; p = p->link)\n\t\t\tif (name == p->sym.name)\n\t\t\t\treturn &p->sym;\n\twhile ((tp = tp->previous) != NULL);\n\treturn NULL;\n}\nint genlabel(int n) {\n\tstatic int label = 1;\n\n\tlabel += n;\n\treturn label - n;\n}\nSymbol findlabel(int lab) {\n\tstruct entry *p;\n\tunsigned h = lab&(HASHSIZE-1);\n\n\tfor (p = labels->buckets[h]; p; p = p->link)\n\t\tif (lab == p->sym.u.l.label)\n\t\t\treturn &p->sym;\n\tNEW0(p, FUNC);\n\tp->sym.name = stringd(lab);\n\tp->sym.scope = LABELS;\n\tp->sym.up = labels->all;\n\tlabels->all = &p->sym;\n\tp->link = labels->buckets[h];\n\tlabels->buckets[h] = p;\n\tp->sym.generated = 1;\n\tp->sym.u.l.label = lab;\n\t(*IR->defsymbol)(&p->sym);\n\treturn &p->sym;\n}\nSymbol constant(Type ty, Value v) {\n\tstruct entry *p;\n\tunsigned h = v.u&(HASHSIZE-1);\n\n\tty = unqual(ty);\n\tfor (p = constants->buckets[h]; p; p = p->link)\n\t\tif (eqtype(ty, p->sym.type, 1))\n\t\t\tswitch (ty->op) {\n\t\t\tcase INT:      if (equalp(i)) return &p->sym; break;\n\t\t\tcase UNSIGNED: if (equalp(u)) return &p->sym; break;\n\t\t\tcase FLOAT:    if (equalp(d)) return &p->sym; break;\n\t\t\tcase FUNCTION: if (equalp(g)) return &p->sym; break;\n\t\t\tcase ARRAY:\n\t\t\tcase POINTER:  if (equalp(p)) return &p->sym; break;\n\t\t\tdefault: assert(0);\n\t\t\t}\n\tNEW0(p, PERM);\n\tp->sym.name = vtoa(ty, v);\n\tp->sym.scope = CONSTANTS;\n\tp->sym.type = ty;\n\tp->sym.sclass = STATIC;\n\tp->sym.u.c.v = v;\n\tp->link = constants->buckets[h];\n\tp->sym.up = constants->all;\n\tconstants->all = &p->sym;\n\tconstants->buckets[h] = p;\n\tif (ty->u.sym && !ty->u.sym->addressed)\n\t\t(*IR->defsymbol)(&p->sym);\n\tp->sym.defined = 1;\n\treturn &p->sym;\n}\nSymbol intconst(int n) {\n\tValue v;\n\n\tv.i = n;\n\treturn constant(inttype, v);\n}\nSymbol genident(int scls, Type ty, int lev) {\n\tSymbol p;\n\n\tNEW0(p, lev >= LOCAL ? FUNC : PERM);\n\tp->name = stringd(genlabel(1));\n\tp->scope = lev;\n\tp->sclass = scls;\n\tp->type = ty;\n\tp->generated = 1;\n\tif (lev == GLOBAL)\n\t\t(*IR->defsymbol)(p);\n\treturn p;\n}\n\nSymbol temporary(int scls, Type ty) {\n\tSymbol p;\n\n\tNEW0(p, FUNC);\n\tp->name = stringd(++tempid);\n\tp->scope = level < LOCAL ? LOCAL : level;\n\tp->sclass = scls;\n\tp->type = ty;\n\tp->temporary = 1;\n\tp->generated = 1;\n\treturn p;\n}\nSymbol newtemp(int sclass, int tc, int size) {\n\tSymbol p = temporary(sclass, btot(tc, size));\n\n\t(*IR->local)(p);\n\tp->defined = 1;\n\treturn p;\n}\n\nSymbol allsymbols(Table tp) {\n\treturn tp->all;\n}\n\nvoid locus(Table tp, Coordinate *cp) {\n\tloci    = append(cp, loci);\n\tsymbols = append(allsymbols(tp), symbols);\n}\n\nvoid use(Symbol p, Coordinate src) {\n\tCoordinate *cp;\n\n\tNEW(cp, PERM);\n\t*cp = src;\n\tp->uses = append(cp, p->uses);\n}\n/* findtype - find type ty in identifiers */\nSymbol findtype(Type ty) {\n\tTable tp = identifiers;\n\tint i;\n\tstruct entry *p;\n\n\tassert(tp);\n\tdo\n\t\tfor (i = 0; i < HASHSIZE; i++)\n\t\t\tfor (p = tp->buckets[i]; p; p = p->link)\n\t\t\t\tif (p->sym.type == ty && p->sym.sclass == TYPEDEF)\n\t\t\t\t\treturn &p->sym;\n\twhile ((tp = tp->previous) != NULL);\n\treturn NULL;\n}\n\n/* mkstr - make a string constant */\nSymbol mkstr(char *str) {\n\tValue v;\n\tSymbol p;\n\n\tv.p = str;\n\tp = constant(array(chartype, strlen(v.p) + 1, 0), v);\n\tif (p->u.c.loc == NULL)\n\t\tp->u.c.loc = genident(STATIC, p->type, GLOBAL);\n\treturn p;\n}\n\n/* mksymbol - make a symbol for name, install in &globals if sclass==EXTERN */\nSymbol mksymbol(int sclass, const char *name, Type ty) {\n\tSymbol p;\n\n\tif (sclass == EXTERN)\n\t\tp = install(string(name), &globals, GLOBAL, PERM);\n\telse {\n\t\tNEW0(p, PERM);\n\t\tp->name = string(name);\n\t\tp->scope = GLOBAL;\n\t}\n\tp->sclass = sclass;\n\tp->type = ty;\n\t(*IR->defsymbol)(p);\n\tp->defined = 1;\n\treturn p;\n}\n\n/* vtoa - return string for the constant v of type ty */\nchar *vtoa(Type ty, Value v) {\n\tchar buf[50];\n\n\tty = unqual(ty);\n\tswitch (ty->op) {\n\tcase INT:      return stringd(v.i);\n\tcase UNSIGNED: return stringf((v.u&~0x7FFF) ? \"0x%X\" : \"%U\", v.u);\n\tcase FLOAT:    return stringf(\"%g\", (double)v.d);\n\tcase ARRAY:\n\t\tif (ty->type == chartype || ty->type == signedchar\n\t\t||  ty->type == unsignedchar)\n\t\t\treturn v.p;\n\t\treturn stringf(\"%p\", v.p);\n\tcase POINTER:  return stringf(\"%p\", v.p);\n\tcase FUNCTION: return stringf(\"%p\", v.g);\n\t}\n\tassert(0); return NULL;\n}\n"
  },
  {
    "path": "lcc/src/symbolic.c",
    "content": "#include <time.h>\n#include <ctype.h>\n#include \"c.h\"\n\n#define I(f) s_##f\n\nstatic Node *tail;\nstatic int off, maxoff, uid = 0, verbose = 0, html = 0;\n\nstatic const char *yyBEGIN(const char *tag) {\n\tif (html)\n\t\tprint(\"<%s>\", tag);\n\treturn tag;\n}\n\nstatic void yyEND(const char *tag) {\n\tif (html)\n\t\tprint(\"</%s>\", tag);\n\tif (isupper(*tag))\n\t\tprint(\"\\n\");\n}\n\n#define BEGIN(tag) do { const char *yytag=yyBEGIN(#tag);\n#define END yyEND(yytag); } while (0)\n#define ITEM BEGIN(li)\n#define START BEGIN(LI)\n#define ANCHOR(attr,code) do { const char *yytag=\"a\"; if (html) { printf(\"<a \" #attr \"=\\\"\"); code; print(\"\\\">\"); }\n#define NEWLINE print(html ? \"<br>\\n\" : \"\\n\")\n\nstatic void emitCoord(Coordinate src) {\n\tif (src.file && *src.file) {\n\t\tANCHOR(href,print(\"%s\", src.file)); print(\"%s\", src.file); END;\n\t\tprint(\":\");\n\t}\n\tprint(\"%d.%d\", src.y, src.x);\n}\n\nstatic void emitString(int len, const char *s) {\n\tfor ( ; len-- > 0; s++)\n\t\tif (*s == '&' && html)\n\t\t\tprint(\"&amp;\");\n\t\telse if (*s == '<' && html)\n\t\t\tprint(\"&lt;\");\n\t\telse if (*s == '>' && html)\n\t\t\tprint(\"&lt;\");\n\t\telse if (*s == '\"' || *s == '\\\\')\n\t\t\tprint(\"\\\\%c\", *s);\n\t\telse if (*s >= ' ' && *s < 0177)\n\t\t\tprint(\"%c\", *s);\n\t\telse\n\t\t\tprint(\"\\\\%d%d%d\", (*s>>6)&3, (*s>>3)&7, *s&7);\n}\n\nstatic void emitSymRef(Symbol p) {\n\t(*IR->defsymbol)(p);\n\tANCHOR(href,print(\"#%s\", p->x.name)); BEGIN(code); print(\"%s\", p->name); END; END;\n}\n\nstatic void emitSymbol(Symbol p) {\n\t(*IR->defsymbol)(p);\n\tANCHOR(name,print(\"%s\", p->x.name)); BEGIN(code); print(\"%s\", p->name); END; END;\n\tBEGIN(ul);\n#define xx(field,code) ITEM; if (!html) print(\" \"); print(#field \"=\"); code; END\n\tif (verbose && (src.y || src.x))\n\t\txx(src,emitCoord(p->src));\n\txx(type,print(\"%t\", p->type));\n\txx(sclass,print(\"%k\", p->sclass));\n\tswitch (p->scope) {\n\tcase CONSTANTS: xx(scope,print(\"CONSTANTS\")); break;\n\tcase LABELS:    xx(scope,print(\"LABELS\"));    break;\n\tcase GLOBAL:    xx(scope,print(\"GLOBAL\"));    break;\n\tcase PARAM:     xx(scope,print(\"PARAM\"));     break;\n\tcase LOCAL:     xx(scope,print(\"LOCAL\"));     break;\n\tdefault:\n\t\tif (p->scope > LOCAL)\n\t\t\txx(scope,print(\"LOCAL+%d\", p->scope-LOCAL));\n\t\telse\n\t\t\txx(scope,print(\"%d\", p->scope));\n\t}\n\tif (p->scope >= PARAM && p->sclass != STATIC)\n\t\txx(offset,print(\"%d\", p->x.offset));\n\txx(ref,print(\"%f\", p->ref));\n\tif (p->temporary && p->u.t.cse)\n\t\txx(u.t.cse,print(\"%p\", p->u.t.cse));\n\tEND;\n#undef xx\n}\n\n/* address - initialize q for addressing expression p+n */\nstatic void I(address)(Symbol q, Symbol p, long n) {\n\tq->name = stringf(\"%s%s%D\", p->name, n > 0 ? \"+\" : \"\", n);\n\t(*IR->defsymbol)(q);\n\tSTART; print(\"address \"); emitSymbol(q); END;\n}\n\n/* blockbeg - start a block */\nstatic void I(blockbeg)(Env *e) {\n\te->offset = off;\n\tSTART; print(\"blockbeg off=%d\", off); END;\n}\n\n/* blockend - start a block */\nstatic void I(blockend)(Env *e) {\n\tif (off > maxoff)\n\t\tmaxoff = off;\n\tSTART; print(\"blockend off=%d\", off); END;\n\toff = e->offset;\n}\n\n/* defaddress - initialize an address */\nstatic void I(defaddress)(Symbol p){\n\tSTART; print(\"defaddress \"); emitSymRef(p); END;\n}\n\n/* defconst - define a constant */\nstatic void I(defconst)(int suffix, int size, Value v) {\n\tSTART;\n\tprint(\"defconst \");\n\tswitch (suffix) {\n\tcase I:\n\t\tprint(\"int.%d \", size);\n\t\tBEGIN(code);\n\t\tif (size > sizeof (int))\n\t\t\tprint(\"%D\", v.i);\n\t\telse\n\t\t\tprint(\"%d\", (int)v.i);\n\t\tEND;\n\t\tbreak;\n\tcase U:\n\t\tprint(\"unsigned.%d \", size);\n\t\tBEGIN(code);\n\t\tif (size > sizeof (unsigned))\n\t\t\tprint(\"%U\", v.u);\n\t\telse\n\t\t\tprint(\"%u\", (unsigned)v.u);\n\t\tEND;\n\t\tbreak;\n\tcase P: print(\"void*.%d \", size); BEGIN(code); print(\"%p\", v.p); END; break;\n\tcase F: print(\"float.%d \", size); BEGIN(code); print(\"%g\", (double)v.d); END; break;\n\tdefault: assert(0);\n\t}\n\tEND;\n}\n\n/* defstring - emit a string constant */\nstatic void I(defstring)(int len, char *s) {\n\tSTART; print(\"defstring \");\n\tBEGIN(code); print(\"\\\"\"); emitString(len, s); print(\"\\\"\"); END;\n\tEND;\n}\n\n/* defsymbol - define a symbol: initialize p->x */\nstatic void I(defsymbol)(Symbol p) {\n\tif (p->x.name == NULL)\n\t\tp->x.name = stringd(++uid);\n}\n\n/* emit - emit the dags on list p */\nstatic void I(emit)(Node p){\n\tITEM;\n\tif (!html)\n\t\tprint(\" \");\n\tfor (; p; p = p->x.next) {\n\t\tif (p->op == LABEL+V) {\n\t\t\tassert(p->syms[0]);\n\t\t\tANCHOR(name,print(\"%s\", p->syms[0]->x.name));\n\t\t\tBEGIN(code); print(\"%s\", p->syms[0]->name); END;\n\t\t\tEND;\n\t\t\tprint(\":\");\n\t\t} else {\n\t\t\tint i;\n\t\t\tif (p->x.listed) {\n\t\t\t\tBEGIN(strong); print(\"%d\", p->x.inst); END; print(\"'\");\n\t\t\t\tprint(\" %s\", opname(p->op));\n\t\t\t} else\n\t\t\t\tprint(\"%d. %s\", p->x.inst, opname(p->op));\n\t\t\tif (p->count > 1)\n\t\t\t\tprint(\" count=%d\", p->count);\n\t\t\tfor (i = 0; i < NELEMS(p->kids) && p->kids[i]; i++)\n\t\t\t\tprint(\" #%d\", p->kids[i]->x.inst);\n\t\t\tif (generic(p->op) == CALL && p->syms[0] && p->syms[0]->type)\n\t\t\t\tprint(\" {%t}\", p->syms[0]->type);\n\t\t\telse\n\t\t\t\tfor (i = 0; i < NELEMS(p->syms) && p->syms[i]; i++) {\n\t\t\t\t\tprint(\" \");\n\t\t\t\t\tif (p->syms[i]->scope == CONSTANTS)\n\t\t\t\t\t\tprint(p->syms[i]->name);\n\t\t\t\t\telse\n\t\t\t\t\t\temitSymRef(p->syms[i]);\n\t\t\t\t}\n\t\t}\n\t\tNEWLINE;\n\t}\n\tEND;\n}\n\n/* export - announce p as exported */\nstatic void I(export)(Symbol p) {\n\tSTART; print(\"export \"); emitSymRef(p); END;\n}\n\n/* function - generate code for a function */\nstatic void I(function)(Symbol f, Symbol caller[], Symbol callee[], int ncalls) {\n\tint i;\n\n\t(*IR->defsymbol)(f);\n\toff = 0;\n\tfor (i = 0; caller[i] && callee[i]; i++) {\n\t\toff = roundup(off, caller[i]->type->align);\n\t\tcaller[i]->x.offset = callee[i]->x.offset = off;\n\t\toff += caller[i]->type->size;\n\t}\n\tif (!html) {\n\t\tprint(\"function \");\n\t\temitSymbol(f);\n\t\tprint(\" ncalls=%d\\n\", ncalls);\n\t\tfor (i = 0; caller[i]; i++)\n\t\t\tSTART; print(\"caller \"); emitSymbol(caller[i]); END;\n\t\tfor (i = 0; callee[i]; i++)\n\t\t\tSTART; print(\"callee \"); emitSymbol(callee[i]); END;\n\t} else {\n\t\tSTART;\n\t\tprint(\"function\");\n\t\tBEGIN(UL);\n#define xx(field,code) ITEM; print(#field \"=\"); code; END\n\t\txx(f,emitSymbol(f));\n\t\txx(ncalls,print(\"%d\", ncalls));\n\t\tif (caller[0]) {\n\t\t\tITEM; print(\"caller\"); BEGIN(OL);\n\t\t\tfor (i = 0; caller[i]; i++)\n\t\t\t\tITEM; emitSymbol(caller[i]); END;\n\t\t\tEND; END;\n\t\t\tITEM; print(\"callee\"); BEGIN(OL);\n\t\t\tfor (i = 0; callee[i]; i++)\n\t\t\t\tITEM; emitSymbol(callee[i]); END;\n\t\t\tEND; END;\n\t\t} else {\n\t\t\txx(caller,BEGIN(em); print(\"empty\"); END);\n\t\t\txx(callee,BEGIN(em); print(\"empty\"); END);\n\t\t}\n\t\tEND;\n\t\tEND;\n\t}\n\tmaxoff = off = 0;\n\tgencode(caller, callee);\n\tif (html)\n\t\tSTART; print(\"emitcode\"); BEGIN(ul); emitcode(); END; END;\n\telse\n\t\temitcode();\n\tSTART; print(\"maxoff=%d\", maxoff); END;\n#undef xx\n}\n\n/* visit - generate code for *p */\nstatic int visit(Node p, int n) {\n\tif (p && p->x.inst == 0) {\n\t\tp->x.inst = ++n;\n\t\tn = visit(p->kids[0], n);\n\t\tn = visit(p->kids[1], n);\n\t\t*tail = p;\n\t\ttail = &p->x.next;\n\t}\n\treturn n;\n}\n\n/* gen0 - generate code for the dags on list p */\nstatic Node I(gen)(Node p) {\n\tint n;\n\tNode nodelist;\n\n\ttail = &nodelist;\n\tfor (n = 0; p; p = p->link) {\n\t\tswitch (generic(p->op)) {\t/* check for valid forest */\n\t\tcase CALL:\n\t\t\tassert(IR->wants_dag || p->count == 0);\n\t\t\tbreak;\n\t\tcase ARG:\n\t\tcase ASGN: case JUMP: case LABEL: case RET:\n\t\tcase EQ: case GE: case GT: case LE: case LT: case NE:\n\t\t\tassert(p->count == 0);\n\t\t\tbreak;\n\t\tcase INDIR:\n\t\t\tassert(IR->wants_dag && p->count > 0);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tassert(0);\n\t\t}\n\t\tcheck(p);\n\t\tp->x.listed = 1;\n\t\tn = visit(p, n);\n\t}\n\t*tail = 0;\n\treturn nodelist;\n}\n\n/* global - announce a global */\nstatic void I(global)(Symbol p) {\n\tSTART; print(\"global \"); emitSymbol(p); END;\n}\n\n/* import - import a symbol */\nstatic void I(import)(Symbol p) {\n\tSTART; print(\"import \"); emitSymRef(p); END;\n}\n\n/* local - local variable */\nstatic void I(local)(Symbol p) {\n\tif (p->temporary)\n\t\tp->name = stringf(\"t%s\", p->name);\n\t(*IR->defsymbol)(p);\n\toff = roundup(off, p->type->align);\n\tp->x.offset = off;\n\toff += p->type->size;\n\tSTART; print(p->temporary ? \"temporary \" : \"local \"); emitSymbol(p); END;\n}\n\n/* progbeg - beginning of program */\nstatic void I(progbeg)(int argc, char *argv[]) {\n\tint i;\n\n\tfor (i = 1; i < argc; i++)\n\t\tif (strcmp(argv[i], \"-v\") == 0)\n\t\t\tverbose++;\n\t\telse if (strcmp(argv[i], \"-html\") == 0)\n\t\t\thtml++;\n\tif (html) {\n\t\tprint(\"<!DOCTYPE HTML PUBLIC \\\"-//W3C//DTD HTML 3.2 Final//EN\\\">\\n\");\n\t\tprint(\"<html>\");\n\t\tBEGIN(head);\n\t\tif (firstfile && *firstfile)\n\t\t\tBEGIN(title); emitString(strlen(firstfile), firstfile);\tEND;\n\t\tprint(\"<link rev=made href=\\\"mailto:drh@microsoft.com\\\">\\n\");\n\t\tEND;\n\t\tprint(\"<body>\\n\");\n\t\tif (firstfile && *firstfile)\n\t\t\tBEGIN(h1); emitString(strlen(firstfile), firstfile); END;\n\t\tBEGIN(P); BEGIN(em);\n\t\tprint(\"Links lead from uses of identifiers and labels to their definitions.\");\n\t\tEND; END;\n\t\tprint(\"<ul>\\n\");\n\t\tSTART;\n\t\tprint(\"progbeg\");\n\t\tBEGIN(ol);\n\t\tfor (i = 1; i < argc; i++) {\n\t\t\tITEM;\n\t\t\tBEGIN(code); print(\"\\\"\"); emitString(strlen(argv[i]), argv[i]); print(\"\\\"\"); END;\n\t\t\tEND;\n\t\t}\n\t\tEND;\n\t\tEND;\n\t}\n}\n\n/* progend - end of program */\nstatic void I(progend)(void) {\n\tSTART; print(\"progend\"); END;\n\tif (html) {\n\t\ttime_t t;\n\t\tprint(\"</ul>\\n\");\n\t\ttime(&t);\n\t\tprint(\"<hr><address>%s</address>\\n\", ctime(&t));\n\t\tprint(\"</body></html>\\n\");\n\t}\n}\n\n/* segment - switch to segment s */\nstatic void I(segment)(int s) {\n\tSTART; print(\"segment %s\", &\"text\\0bss\\0.data\\0lit\\0.sym\\0.\"[5*s-5]); END;\n}\n\n/* space - initialize n bytes of space */\nstatic void I(space)(int n) {\n\tSTART; print(\"space %d\", n); END;\n}\n\nstatic void I(stabblock)(int brace, int lev, Symbol *p) {}\n\n/* stabend - finalize stab output */\nstatic void I(stabend)(Coordinate *cp, Symbol p, Coordinate **cpp, Symbol *sp, Symbol *stab) {\n\tint i;\n\n\tif (p)\n\t\temitSymRef(p);\n\tprint(\"\\n\");\n\tif (cpp && sp)\n\t\tfor (i = 0; cpp[i] && sp[i]; i++) {\n\t\t\tprint(\"%w.%d: \", cpp[i], cpp[i]->x);\n\t\t\temitSymRef(sp[i]);\n\t\t\tprint(\"\\n\");\n\t\t}\n}\n\nstatic void I(stabfend)(Symbol p, int lineno) {}\nstatic void I(stabinit)(char *file, int argc, char *argv[]) {}\n\n/* stabline - emit line number information for source coordinate *cp */\nstatic void I(stabline)(Coordinate *cp) {\n\tif (cp->file)\n\t\tprint(\"%s:\", cp->file);\n\tprint(\"%d.%d:\\n\", cp->y, cp->x);\n}\n\nstatic void I(stabsym)(Symbol p) {}\nstatic void I(stabtype)(Symbol p) {}\n\nInterface symbolicIR = {\n\t1, 1, 0,\t/* char */\n\t2, 2, 0,\t/* short */\n\t4, 4, 0,\t/* int */\n\t4, 4, 0,\t/* long */\n\t4, 4, 0,\t/* long long */\n\t4, 4, 1,\t/* float */\n\t8, 8, 1,\t/* double */\n\t8, 8, 1,\t/* long double */\n\t4, 4, 0,\t/* T* */\n\t0, 4, 0,\t/* struct */\n\t0,\t\t/* little_endian */\n\t0,\t\t/* mulops_calls */\n\t0,\t\t/* wants_callb */\n\t1,\t\t/* wants_argb */\n\t1,\t\t/* left_to_right */\n\t1,\t\t/* wants_dag */\n\t0,\t\t/* unsigned_char */\n\tI(address),\n\tI(blockbeg),\n\tI(blockend),\n\tI(defaddress),\n\tI(defconst),\n\tI(defstring),\n\tI(defsymbol),\n\tI(emit),\n\tI(export),\n\tI(function),\n\tI(gen),\n\tI(global),\n\tI(import),\n\tI(local),\n\tI(progbeg),\n\tI(progend),\n\tI(segment),\n\tI(space),\n\tI(stabblock),\n\tI(stabend),\n\tI(stabfend),\n\tI(stabinit),\n\tI(stabline),\n\tI(stabsym),\n\tI(stabtype)\n};\n\nInterface symbolic64IR = {\n\t1, 1, 0,\t/* char */\n\t2, 2, 0,\t/* short */\n\t4, 4, 0,\t/* int */\n\t8, 8, 0,\t/* long */\n\t8, 8, 0,\t/* long long */\n\t4, 4, 1,\t/* float */\n\t8, 8, 1,\t/* double */\n\t8, 8, 1,\t/* long double */\n\t8, 8, 0,\t/* T* */\n\t0, 1, 0,\t/* struct */\n\t1,\t\t/* little_endian */\n\t0,\t\t/* mulops_calls */\n\t0,\t\t/* wants_callb */\n\t1,\t\t/* wants_argb */\n\t1,\t\t/* left_to_right */\n\t1,\t\t/* wants_dag */\n\t0,\t\t/* unsigned_char */\n\tI(address),\n\tI(blockbeg),\n\tI(blockend),\n\tI(defaddress),\n\tI(defconst),\n\tI(defstring),\n\tI(defsymbol),\n\tI(emit),\n\tI(export),\n\tI(function),\n\tI(gen),\n\tI(global),\n\tI(import),\n\tI(local),\n\tI(progbeg),\n\tI(progend),\n\tI(segment),\n\tI(space),\n\tI(stabblock),\n\tI(stabend),\n\tI(stabfend),\n\tI(stabinit),\n\tI(stabline),\n\tI(stabsym),\n\tI(stabtype)\n};\n"
  },
  {
    "path": "lcc/src/token.h",
    "content": "/*\nxx(symbol,\tvalue,\tprec,\top,\toptree,\tkind,\tstring)\n*/\nyy(0,         0, 0,  0,    0,      0,      0)\nxx(FLOAT,     1, 0,  0,    0,      CHAR,   \"float\")\nxx(DOUBLE,    2, 0,  0,    0,      CHAR,   \"double\")\nxx(CHAR,      3, 0,  0,    0,      CHAR,   \"char\")\nxx(SHORT,     4, 0,  0,    0,      CHAR,   \"short\")\nxx(INT,       5, 0,  0,    0,      CHAR,   \"int\")\nxx(UNSIGNED,  6, 0,  0,    0,      CHAR,   \"unsigned\")\nxx(POINTER,   7, 0,  0,    0,      0,      \"pointer\")\nxx(VOID,      8, 0,  0,    0,      CHAR,   \"void\")\nxx(STRUCT,    9, 0,  0,    0,      CHAR,   \"struct\")\nxx(UNION,    10, 0,  0,    0,      CHAR,   \"union\")\nxx(FUNCTION, 11, 0,  0,    0,      0,      \"function\")\nxx(ARRAY,    12, 0,  0,    0,      0,      \"array\")\nxx(ENUM,     13, 0,  0,    0,      CHAR,   \"enum\")\nxx(LONG,     14, 0,  0,    0,      CHAR,   \"long\")\nxx(CONST,    15, 0,  0,    0,      CHAR,   \"const\")\nxx(VOLATILE, 16, 0,  0,    0,      CHAR,   \"volatile\")\nyy(0,        17,     0,      0,    0,      0,      0)\nyy(0,        18,     0,      0,    0,      0,      0)\nyy(0,        19,     0,      0,    0,      0,      0)\nyy(0,        20,     0,      0,    0,      0,      0)\nyy(0,        21,     0,      0,    0,      0,      0)\nyy(0,        22,     0,      0,    0,      0,      0)\nyy(0,        23,     0,      0,    0,      0,      0)\nyy(0,        24,     0,      0,    0,      0,      0)\nyy(0,        25,     0,      0,    0,      0,      0)\nyy(0,        26,     0,      0,    0,      0,      0)\nyy(0,        27,     0,      0,    0,      0,      0)\nyy(0,        28,     0,      0,    0,      0,      \"long long\")\nyy(0,        29,     0,      0,    0,      0,      0)\nyy(0,        30,     0,      0,    0,      0,      0)\nyy(0,        31,     0,      0,    0,      0,      \"const volatile\")\nxx(ID,       32,     0,      0,    0,      ID,     \"identifier\")\nyy(0,        33,     0,      0,    0,      ID,     \"!\")\nxx(FCON,     34,     0,      0,    0,      ID,     \"floating constant\")\nxx(ICON,     35,     0,      0,    0,      ID,     \"integer constant\")\nxx(SCON,     36,     0,      0,    0,      ID,     \"string constant\")\nyy(0,        37,     13,     MOD,  bittree,'%',    \"%\")\nyy(0,        38,     8,      BAND, bittree,ID,     \"&\")\nxx(INCR,     39,     0,      ADD,  addtree,ID,     \"++\")\nyy(0,        40,     0,      0,    0,      ID,     \"(\")\nyy(0,        41,     0,      0,    0,      ')',    \")\")\nyy(0,        42, 13, MUL,  multree,ID,     \"*\")\nyy(0,        43, 12, ADD,  addtree,ID,     \"+\")\nyy(0,        44, 1,  0,    0,      ',',    \",\")\nyy(0,        45, 12, SUB,  subtree,ID,     \"-\")\nyy(0,        46, 0,  0,    0,      '.',    \".\")\nyy(0,        47, 13, DIV,  multree,'/',    \"/\")\nxx(DECR,     48, 0,  SUB,  subtree,ID,     \"--\")\nxx(DEREF,    49, 0,  0,    0,      DEREF,  \"->\")\nxx(ANDAND,   50, 5,  AND,  andtree,ANDAND, \"&&\")\nxx(OROR,     51, 4,  OR,   andtree,OROR,   \"||\")\nxx(LEQ,      52, 10, LE,   cmptree,LEQ,    \"<=\")\nxx(EQL,         53,     9,      EQ,     eqtree, EQL,    \"==\")\nxx(NEQ,         54,     9,      NE,     eqtree, NEQ,    \"!=\")\nxx(GEQ,         55,     10,     GE,     cmptree,GEQ,    \">=\")\nxx(RSHIFT,      56,     11,     RSH,    shtree, RSHIFT, \">>\")\nxx(LSHIFT,      57,     11,     LSH,    shtree, LSHIFT, \"<<\")\nyy(0,           58,     0,      0,      0,      ':',    \":\")\nyy(0,           59,     0,      0,      0,      IF,     \";\")\nyy(0,           60,     10,     LT,     cmptree,'<',    \"<\")\nyy(0,           61,     2,      ASGN,   asgntree,'=',   \"=\")\nyy(0,           62,     10,     GT,     cmptree,'>',    \">\")\nyy(0,           63,     0,      0,      0,      '?',    \"?\")\nxx(ELLIPSIS,    64,     0,      0,      0,      ELLIPSIS,\"...\")\nxx(SIZEOF,      65,     0,      0,      0,      ID,     \"sizeof\")\nyy(0,           66,     0,      0,      0,      0,      0)\nxx(AUTO,        67,     0,      0,      0,      STATIC, \"auto\")\nxx(BREAK,       68,     0,      0,      0,      IF,     \"break\")\nxx(CASE,        69,     0,      0,      0,      IF,     \"case\")\nxx(CONTINUE,    70,     0,      0,      0,      IF,     \"continue\")\nxx(DEFAULT,     71,     0,      0,      0,      IF,     \"default\")\nxx(DO,          72,     0,      0,      0,      IF,     \"do\")\nxx(ELSE,        73,     0,      0,      0,      IF,     \"else\")\nxx(EXTERN,      74,     0,      0,      0,      STATIC, \"extern\")\nxx(FOR,         75,     0,      0,      0,      IF,     \"for\")\nxx(GOTO,        76,     0,      0,      0,      IF,     \"goto\")\nxx(IF,          77,     0,      0,      0,      IF,     \"if\")\nxx(REGISTER,    78,     0,      0,      0,      STATIC, \"register\")\nxx(RETURN,      79,     0,      0,      0,      IF,     \"return\")\nxx(SIGNED,      80,     0,      0,      0,      CHAR,   \"signed\")\nxx(STATIC,      81,     0,      0,      0,      STATIC, \"static\")\nxx(SWITCH,      82,     0,      0,      0,      IF,     \"switch\")\nxx(TYPEDEF,     83,     0,      0,      0,      STATIC, \"typedef\")\nxx(WHILE,       84,     0,      0,      0,      IF,     \"while\")\nxx(TYPECODE,    85,     0,      0,      0,      ID,     \"__typecode\")\nxx(FIRSTARG,    86,     0,      0,      0,      ID,     \"__firstarg\")\nyy(0,           87,     0,      0,      0,      0,      0)\nyy(0,           88,     0,      0,      0,      0,      0)\nyy(0,           89,     0,      0,      0,      0,      0)\nyy(0,           90,     0,      0,      0,      0,      0)\nyy(0,           91,     0,      0,      0,      '[',    \"[\")\nyy(0,           92,     0,      0,      0,      0,      0)\nyy(0,           93,     0,      0,      0,      ']',    \"]\")\nyy(0,           94,     7,      BXOR,   bittree,'^',    \"^\")\nyy(0,           95,     0,      0,      0,      0,      0)\nyy(0,           96,     0,      0,      0,      0,      0)\nyy(0,           97,     0,      0,      0,      0,      0)\nyy(0,           98,     0,      0,      0,      0,      0)\nyy(0,           99,     0,      0,      0,      0,      0)\nyy(0,           100,    0,      0,      0,      0,      0)\nyy(0,           101,    0,      0,      0,      0,      0)\nyy(0,           102,    0,      0,      0,      0,      0)\nyy(0,           103,    0,      0,      0,      0,      0)\nyy(0,           104,    0,      0,      0,      0,      0)\nyy(0,           105,    0,      0,      0,      0,      0)\nyy(0,           106,    0,      0,      0,      0,      0)\nyy(0,           107,    0,      0,      0,      0,      0)\nyy(0,           108,    0,      0,      0,      0,      0)\nyy(0,           109,    0,      0,      0,      0,      0)\nyy(0,           110,    0,      0,      0,      0,      0)\nyy(0,           111,    0,      0,      0,      0,      0)\nyy(0,           112,    0,      0,      0,      0,      0)\nyy(0,           113,    0,      0,      0,      0,      0)\nyy(0,           114,    0,      0,      0,      0,      0)\nyy(0,           115,    0,      0,      0,      0,      0)\nyy(0,           116,    0,      0,      0,      0,      0)\nyy(0,           117,    0,      0,      0,      0,      0)\nyy(0,           118,    0,      0,      0,      0,      0)\nyy(0,           119,    0,      0,      0,      0,      0)\nyy(0,           120,    0,      0,      0,      0,      0)\nyy(0,           121,    0,      0,      0,      0,      0)\nyy(0,           122,    0,      0,      0,      0,      0)\nyy(0,           123,    0,      0,      0,      IF,     \"{\")\nyy(0,           124,    6,      BOR,    bittree,'|',    \"|\")\nyy(0,           125,    0,      0,      0,      '}',    \"}\")\nyy(0,           126,    0,      BCOM,   0,      ID,     \"~\")\nxx(EOI,         127,    0,      0,      0,      EOI,    \"end of input\")\n#undef xx\n#undef yy\n"
  },
  {
    "path": "lcc/src/trace.c",
    "content": "#include \"c.h\"\n\n\nstatic char *fmt, *fp, *fmtend;\t/* format string, current & limit pointer */\nstatic Tree args;\t\t/* printf arguments */\nstatic Symbol frameno;\t\t/* local holding frame number */\n\n/* appendstr - append str to the evolving format string, expanding it if necessary */\nstatic void appendstr(char *str) {\n\tdo\n\t\tif (fp == fmtend)\n\t\t\tif (fp) {\n\t\t\t\tchar *s = allocate(2*(fmtend - fmt), FUNC);\n\t\t\t\tstrncpy(s, fmt, fmtend - fmt);\n\t\t\t\tfp = s + (fmtend - fmt);\n\t\t\t\tfmtend = s + 2*(fmtend - fmt);\n\t\t\t\tfmt = s;\n\t\t\t} else {\n\t\t\t\tfp = fmt = allocate(80, FUNC);\n\t\t\t\tfmtend = fmt + 80;\n\t\t\t}\n\twhile ((*fp++ = *str++) != 0);\n\tfp--;\n}\n\n/* tracevalue - append format and argument to print the value of e */\nstatic void tracevalue(Tree e, int lev) {\n\tType ty = unqual(e->type);\n\n\tswitch (ty->op) {\n\tcase INT:\n\t\tif (ty == chartype || ty == signedchar)\n\t\t\tappendstr(\"'\\\\x%02x'\");\n\t\telse if (ty == longtype)\n\t\t\tappendstr(\"0x%ld\");\n\t\telse\n\t\t\tappendstr(\"0x%d\");\n\t\tbreak;\n\tcase UNSIGNED:\n\t\tif (ty == chartype || ty == unsignedchar)\n\t\t\tappendstr(\"'\\\\x%02x'\");\n\t\telse if (ty == unsignedlong)\n\t\t\tappendstr(\"0x%lx\");\n\t\telse\n\t\t\tappendstr(\"0x%x\");\n\t\tbreak;\n\tcase FLOAT:\n\t\tif (ty == longdouble)\n\t\t\tappendstr(\"%Lg\");\n\t\telse\n\t\t\tappendstr(\"%g\");\n\t\tbreak;\n\tcase POINTER:\n\t\tif (unqual(ty->type) == chartype\n\t\t||  unqual(ty->type) == signedchar\n\t\t||  unqual(ty->type) == unsignedchar) {\n\t\t\tstatic Symbol null;\n\t\t\tif (null == NULL)\n\t\t\t\tnull = mkstr(\"(null)\");\n\t\t\ttracevalue(cast(e, unsignedtype), lev + 1);\n\t\t\tappendstr(\" \\\"%.30s\\\"\");\n\t\t\te = condtree(e, e, pointer(idtree(null->u.c.loc)));\n\t\t} else {\n\t\t\tappendstr(\"(\"); appendstr(typestring(ty, \"\")); appendstr(\")0x%x\");\n\t\t}\n\t\tbreak;\n\tcase STRUCT: {\n\t\tField q;\n\t\tappendstr(\"(\"); appendstr(typestring(ty, \"\")); appendstr(\"){\");\n\t\tfor (q = ty->u.sym->u.s.flist; q; q = q->link) {\n\t\t\tappendstr(q->name); appendstr(\"=\");\n\t\t\ttracevalue(field(addrof(e), q->name), lev + 1);\n\t\t\tif (q->link)\n\t\t\t\tappendstr(\",\");\n\t\t}\n\t\tappendstr(\"}\");\n\t\treturn;\n\t\t}\n\tcase UNION:\n\t\tappendstr(\"(\"); appendstr(typestring(ty, \"\")); appendstr(\"){...}\");\n\t\treturn;\n\tcase ARRAY:\n\t\tif (lev && ty->type->size > 0) {\n\t\t\tint i;\n\t\t\te = pointer(e);\n\t\t\tappendstr(\"{\");\n\t\t\tfor (i = 0; i < ty->size/ty->type->size; i++) {\n\t\t\t\tTree p = (*optree['+'])(ADD, e, consttree(i, inttype));\n\t\t\t\tif (isptr(p->type) && isarray(p->type->type))\n\t\t\t\t\tp = retype(p, p->type->type);\n\t\t\t\telse\n\t\t\t\t\tp = rvalue(p);\n\t\t\t\tif (i)\n\t\t\t\t\tappendstr(\",\");\n\t\t\t\ttracevalue(p, lev + 1);\n\t\t\t}\n\t\t\tappendstr(\"}\");\n\t\t} else\n\t\t\tappendstr(typestring(ty, \"\"));\n\t\treturn;\n\tdefault:\n\t\tassert(0);\n\t}\n\te = cast(e, promote(ty));\n\targs = tree(mkop(ARG,e->type), e->type, e, args);\n}\n\n/* tracefinis - complete & generate the trace call to print */\nstatic void tracefinis(Symbol printer) {\n\tTree *ap;\n\tSymbol p;\n\n\t*fp = 0;\n\tp = mkstr(string(fmt));\n\tfor (ap = &args; *ap; ap = &(*ap)->kids[1])\n\t\t;\n\t*ap = tree(ARG+P, charptype, pointer(idtree(p->u.c.loc)), 0);\n\twalk(calltree(pointer(idtree(printer)), freturn(printer->type), args, NULL), 0, 0);\n\targs = 0;\n\tfp = fmtend = 0;\n}\n\n/* tracecall - generate code to trace entry to f */\nstatic void tracecall(Symbol printer, Symbol f) {\n\tint i;\n\tSymbol counter = genident(STATIC, inttype, GLOBAL);\n\n\tdefglobal(counter, BSS);\n\t(*IR->space)(counter->type->size);\n\tframeno = genident(AUTO, inttype, level);\n\taddlocal(frameno);\n\tappendstr(f->name); appendstr(\"#\");\n\ttracevalue(asgn(frameno, incr(INCR, idtree(counter), consttree(1, inttype))), 0);\n\tappendstr(\"(\");\n\tfor (i = 0; f->u.f.callee[i]; i++) {\n\t\tif (i)\n\t\t\tappendstr(\",\");\n\t\tappendstr(f->u.f.callee[i]->name); appendstr(\"=\");\n\t\ttracevalue(idtree(f->u.f.callee[i]), 0);\n\t}\n\tif (variadic(f->type))\n\t\tappendstr(\",...\");\n\tappendstr(\") called\\n\");\n\ttracefinis(printer);\n}\n\n/* tracereturn - generate code to trace return e */\nstatic void tracereturn(Symbol printer, Symbol f, Tree e) {\n\tappendstr(f->name); appendstr(\"#\");\n\ttracevalue(idtree(frameno), 0);\n\tappendstr(\" returned\");\n\tif (freturn(f->type) != voidtype && e) {\n\t\tappendstr(\" \");\n\t\ttracevalue(e, 0);\n\t}\n\tappendstr(\"\\n\");\n\ttracefinis(printer);\n}\n\n/* trace_init - initialize for tracing */\nvoid trace_init(int argc, char *argv[]) {\n\tint i;\n\tstatic int inited;\n\n\tif (inited)\n\t\treturn;\n\tinited = 1;\n\ttype_init(argc, argv);\n\tif (IR)\n\t\tfor (i = 1; i < argc; i++)\n\t\t\tif (strncmp(argv[i], \"-t\", 2) == 0 &&  strchr(argv[i], '=') == NULL) {\n\t\t\t\tSymbol printer = mksymbol(EXTERN,\n\t\t\t\t\targv[i][2] ? &argv[i][2] : \"printf\",\n\t\t\t\tftype(inttype, ptr(qual(CONST, chartype))));\n\t\t\t\tprinter->defined = 0;\n\t\t\t\tattach((Apply)tracecall,   printer, &events.entry);\n\t\t\t\tattach((Apply)tracereturn, printer, &events.returns);\n\t\t\t\tbreak;\n\t\t\t}\n}\n"
  },
  {
    "path": "lcc/src/tree.c",
    "content": "#include \"c.h\"\n\n\nint where = STMT;\nstatic int warn;\nstatic int nid = 1;\t\t/* identifies trees & nodes in debugging output */\nstatic struct nodeid {\n\tint printed;\n\tTree node;\n} ids[500];\t\t\t/* if ids[i].node == p, then p's id is i */\n\nstatic void printtree1(Tree, int, int);\n\nTree tree(int op, Type type, Tree left, Tree right) {\n\tTree p;\n\n\tNEW0(p, where);\n\tp->op = op;\n\tp->type = type;\n\tp->kids[0] = left;\n\tp->kids[1] = right;\n\treturn p;\n}\n\nTree texpr(Tree (*f)(int), int tok, int a) {\n\tint save = where;\n\tTree p;\n\n\twhere = a;\n\tp = (*f)(tok);\n\twhere = save;\n\treturn p;\n}\nstatic Tree root1(Tree p) {\n\tif (p == NULL)\n\t\treturn p;\n\tif (p->type == voidtype)\n\t\twarn++;\n\tswitch (generic(p->op)) {\n\tcase COND: {\n\t\tTree q = p->kids[1];\n\t\tassert(q && q->op == RIGHT);\n\t\tif (p->u.sym && q->kids[0] && generic(q->kids[0]->op) == ASGN)\n\t\t\tq->kids[0] = root1(q->kids[0]->kids[1]);\n\t\telse\n\t\t\tq->kids[0] = root1(q->kids[0]);\n\t\tif (p->u.sym && q->kids[1] && generic(q->kids[1]->op) == ASGN)\n\t\t\tq->kids[1] = root1(q->kids[1]->kids[1]);\n\t\telse\n\t\t\tq->kids[1] = root1(q->kids[1]);\n\t\tp->u.sym = 0;\n\t\tif (q->kids[0] == 0 && q->kids[1] == 0)\n\t\t\tp = root1(p->kids[0]);\n\t\t}\n\t\tbreak;\n\tcase AND: case OR:\n\t\tif ((p->kids[1] = root1(p->kids[1])) == 0)\n\t\t\tp = root1(p->kids[0]);\n\t\tbreak;\n\tcase NOT:\n\t\tif (warn++ == 0)\n\t\t\twarning(\"expression with no effect elided\\n\");\n\t\treturn root1(p->kids[0]);\n\tcase RIGHT:\n\t\tif (p->kids[1] == 0)\n\t\t\treturn root1(p->kids[0]);\n\t\tif (p->kids[0] && p->kids[0]->op == CALL+B\n\t\t&&  p->kids[1] && p->kids[1]->op == INDIR+B)\n\t\t\t/* avoid premature release of the CALL+B temporary */\n\t\t\treturn p->kids[0];\n\t\tif (p->kids[0] && p->kids[0]->op == RIGHT\n\t\t&&  p->kids[1] == p->kids[0]->kids[0])\n\t\t\t/* de-construct e++ construction */\n\t\t\treturn p->kids[0]->kids[1];\n\t\tp = tree(RIGHT, p->type, root1(p->kids[0]), root1(p->kids[1]));\n\t\treturn p->kids[0] || p->kids[1] ? p : (Tree)0;\n\tcase EQ:  case NE:  case GT:   case GE:  case LE:  case LT: \n\tcase ADD: case SUB: case MUL:  case DIV: case MOD:\n\tcase LSH: case RSH: case BAND: case BOR: case BXOR:\n\t\tif (warn++ == 0)\n\t\t\twarning(\"expression with no effect elided\\n\");\n\t\tp = tree(RIGHT, p->type, root1(p->kids[0]), root1(p->kids[1]));\n\t\treturn p->kids[0] || p->kids[1] ? p : (Tree)0;\n\tcase INDIR:\n\t\tif (p->type->size == 0 && unqual(p->type) != voidtype)\n\t\t\twarning(\"reference to `%t' elided\\n\", p->type);\n\t\tif (isptr(p->kids[0]->type) && isvolatile(p->kids[0]->type->type))\n\t\t\twarning(\"reference to `volatile %t' elided\\n\", p->type);\n\t\t/* fall thru */\n\tcase CVI: case CVF: case CVU: case CVP:\n\tcase NEG: case BCOM: case FIELD:\n\t\tif (warn++ == 0)\n\t\t\twarning(\"expression with no effect elided\\n\");\n\t\treturn root1(p->kids[0]);\n\tcase ADDRL: case ADDRG: case ADDRF: case CNST:\n\t\tif (needconst)\n\t\t\treturn p;\n\t\tif (warn++ == 0)\n\t\t\twarning(\"expression with no effect elided\\n\");\n\t\treturn NULL;\n\tcase ARG: case ASGN: case CALL: case JUMP: case LABEL:\n\t\tbreak;\n\tdefault: assert(0);\n\t}\n\treturn p;\n}\n\nTree root(Tree p) {\n\twarn = 0;\n\treturn root1(p);\n}\n\nchar *opname(int op) {\n\tstatic char *opnames[] = {\n\t\"\",\n\t\"CNST\",\n\t\"ARG\",\n\t\"ASGN\",\n\t\"INDIR\",\n\t\"CVC\",\n\t\"CVD\",\n\t\"CVF\",\n\t\"CVI\",\n\t\"CVP\",\n\t\"CVS\",\n\t\"CVU\",\n\t\"NEG\",\n\t\"CALL\",\n\t\"*LOAD*\",\n\t\"RET\",\n\t\"ADDRG\",\n\t\"ADDRF\",\n\t\"ADDRL\",\n\t\"ADD\",\n\t\"SUB\",\n\t\"LSH\",\n\t\"MOD\",\n\t\"RSH\",\n\t\"BAND\",\n\t\"BCOM\",\n\t\"BOR\",\n\t\"BXOR\",\n\t\"DIV\",\n\t\"MUL\",\n\t\"EQ\",\n\t\"GE\",\n\t\"GT\",\n\t\"LE\",\n\t\"LT\",\n\t\"NE\",\n\t\"JUMP\",\n\t\"LABEL\",\n\t\"AND\",\n\t\"NOT\",\n\t\"OR\",\n\t\"COND\",\n\t\"RIGHT\",\n\t\"FIELD\"\n\t}, *suffixes[] = {\n\t\t\"0\", \"F\", \"D\", \"C\", \"S\", \"I\", \"U\", \"P\", \"V\", \"B\",\n\t\t\"10\",\"11\",\"12\",\"13\",\"14\",\"15\"\n\t};\n\n\tif (generic(op) >= AND && generic(op) <= FIELD && opsize(op) == 0)\n\t\treturn opnames[opindex(op)];\n\treturn stringf(\"%s%s%s\",\n\t\topindex(op) > 0 && opindex(op) < NELEMS(opnames) ?\n\t\t\topnames[opindex(op)] : stringd(opindex(op)),\n\t\tsuffixes[optype(op)], opsize(op) > 0 ? stringd(opsize(op)) : \"\");\n}\n\nint nodeid(Tree p) {\n\tint i = 1;\n\n\tids[nid].node = p;\n\twhile (ids[i].node != p)\n\t\ti++;\n\tif (i == nid)\n\t\tids[nid++].printed = 0;\n\treturn i;\n}\n\n/* printed - return pointer to ids[id].printed */\nint *printed(int id) {\n\tif (id)\n\t\treturn &ids[id].printed;\n\tnid = 1;\n\treturn 0;\n}\n\n/* printtree - print tree p on fd */\nvoid printtree(Tree p, int fd) {\n\t(void)printed(0);\n\tprinttree1(p, fd, 1);\n}\n\n/* printtree1 - recursively print tree p */\nstatic void printtree1(Tree p, int fd, int lev) {\n\tFILE *f = fd == 1 ? stdout : stderr;\n\tint i;\n\tstatic char blanks[] = \"                                                   \";\n\n\tif (p == 0 || *printed(i = nodeid(p)))\n\t\treturn;\n\tfprint(f, \"#%d%S%S\", i, blanks, i < 10 ? 2 : i < 100 ? 1 : 0, blanks, lev);\n\tfprint(f, \"%s %t\", opname(p->op), p->type);\n\t*printed(i) = 1;\n\tfor (i = 0; i < NELEMS(p->kids); i++)\n\t\tif (p->kids[i])\n\t\t\tfprint(f, \" #%d\", nodeid(p->kids[i]));\n\tif (p->op == FIELD && p->u.field)\n\t\tfprint(f, \" %s %d..%d\", p->u.field->name,\n\t\t\tfieldsize(p->u.field) + fieldright(p->u.field), fieldright(p->u.field));\n\telse if (generic(p->op) == CNST)\n\t\tfprint(f, \" %s\", vtoa(p->type, p->u.v));\n\telse if (p->u.sym)\n\t\tfprint(f, \" %s\", p->u.sym->name);\n\tif (p->node)\n\t\tfprint(f, \" node=%p\", p->node);\n\tfprint(f, \"\\n\");\n\tfor (i = 0; i < NELEMS(p->kids); i++)\n\t\tprinttree1(p->kids[i], fd, lev + 1);\n}\n"
  },
  {
    "path": "lcc/src/types.c",
    "content": "#include \"c.h\"\n#include <float.h>\n\n\nstatic Field isfield(const char *, Field);\nstatic Type type(int, Type, int, int, void *);\n\nstatic struct entry {\n\tstruct type type;\n\tstruct entry *link;\n} *typetable[128];\nstatic int maxlevel;\n\nstatic Symbol pointersym;\n\nType chartype;\t\t\t/* char */\nType doubletype;\t\t/* double */\nType floattype;\t\t\t/* float */\nType inttype;\t\t\t/* signed int */\nType longdouble;\t\t/* long double */\nType longtype;\t\t\t/* long */\nType longlong;\t\t\t/* long long */\nType shorttype;\t\t\t/* signed short int */\nType signedchar;\t\t/* signed char */\nType unsignedchar;\t\t/* unsigned char */\nType unsignedlong;\t\t/* unsigned long int */\nType unsignedlonglong;\t\t/* unsigned long long int */\nType unsignedshort;\t\t/* unsigned short int */\nType unsignedtype;\t\t/* unsigned int */\nType funcptype;\t\t\t/* void (*)() */\nType charptype;\t\t\t/* char* */\nType voidptype;\t\t\t/* void* */\nType voidtype;\t\t\t/* basic types: void */\nType unsignedptr;\t\t/* unsigned type to hold void* */\nType signedptr;\t\t\t/* signed type to hold void* */\nType widechar;\t\t\t/* unsigned type that represents wchar_t */\n\nstatic Type xxinit(int op, char *name, Metrics m) {\n\tSymbol p = install(string(name), &types, GLOBAL, PERM);\n\tType ty = type(op, 0, m.size, m.align, p);\n\n\tassert(ty->align == 0 || ty->size%ty->align == 0);\n\tp->type = ty;\n\tp->addressed = m.outofline;\n\tswitch (ty->op) {\n\tcase INT:\n\t\tp->u.limits.max.i = ones(8*ty->size)>>1;\n\t\tp->u.limits.min.i = -p->u.limits.max.i - 1;\n\t\tbreak;\n\tcase UNSIGNED:\n\t\tp->u.limits.max.u = ones(8*ty->size);\n\t\tp->u.limits.min.u = 0;\n\t\tbreak;\n\tcase FLOAT:\n\t\tif (ty->size == sizeof (float))\n\t\t\tp->u.limits.max.d =  FLT_MAX;\n\t\telse if (ty->size == sizeof (double))\n\t\t\tp->u.limits.max.d =  DBL_MAX;\n\t\telse\n\t\t\tp->u.limits.max.d = LDBL_MAX;\n\t\tp->u.limits.min.d = -p->u.limits.max.d;\n\t\tbreak;\n\tdefault: assert(0);\n\t}\n\treturn ty;\n}\nstatic Type type(int op, Type ty, int size, int align, void *sym) {\n\tunsigned h = (op^((unsigned long)ty>>3))\n&(NELEMS(typetable)-1);\n\tstruct entry *tn;\n\n\tif (op != FUNCTION && (op != ARRAY || size > 0))\n\t\tfor (tn = typetable[h]; tn; tn = tn->link)\n\t\t\tif (tn->type.op    == op   && tn->type.type  == ty\n\t\t\t&&  tn->type.size  == size && tn->type.align == align\n\t\t\t&&  tn->type.u.sym == sym)\n\t\t\t\treturn &tn->type;\n\tNEW0(tn, PERM);\n\ttn->type.op = op;\n\ttn->type.type = ty;\n\ttn->type.size = size;\n\ttn->type.align = align;\n\ttn->type.u.sym = sym;\n\ttn->link = typetable[h];\n\ttypetable[h] = tn;\n\treturn &tn->type;\n}\nvoid type_init(int argc, char *argv[]) {\n\tstatic int inited;\n\tint i;\n\n\tif (inited)\n\t\treturn;\n\tinited = 1;\n\tif (!IR)\n\t\treturn;\n\tfor (i = 1; i < argc; i++) {\n\t\tint size, align, outofline;\n\t\tif (strncmp(argv[i], \"-unsigned_char=\", 15) == 0)\n\t\t\tIR->unsigned_char = argv[i][15] - '0';\n#define xx(name) \\\n\t\telse if (sscanf(argv[i], \"-\" #name \"=%d,%d,%d\", &size, &align, &outofline) == 3) { \\\n\t\t\tIR->name.size = size; IR->name.align = align; \\\n\t\t\tIR->name.outofline = outofline; }\n\txx(charmetric)\n\txx(shortmetric)\n\txx(intmetric)\n\txx(longmetric)\n\txx(longlongmetric)\n\txx(floatmetric)\n\txx(doublemetric)\n\txx(longdoublemetric)\n\txx(ptrmetric)\n\txx(structmetric)\n#undef xx\n\t}\n#define xx(v,name,op,metrics) v=xxinit(op,name,IR->metrics)\n\txx(chartype,        \"char\",              IR->unsigned_char ? UNSIGNED : INT,charmetric);\n\txx(doubletype,      \"double\",            FLOAT,   doublemetric);\n\txx(floattype,       \"float\",             FLOAT,   floatmetric);\n\txx(inttype,         \"int\",               INT,     intmetric);\n\txx(longdouble,      \"long double\",       FLOAT,   longdoublemetric);\n\txx(longtype,        \"long int\",          INT,     longmetric);\n\txx(longlong,        \"long long int\",     INT,     longlongmetric);\n\txx(shorttype,       \"short\",             INT,     shortmetric);\n\txx(signedchar,      \"signed char\",       INT,     charmetric);\n\txx(unsignedchar,    \"unsigned char\",     UNSIGNED,charmetric);\n\txx(unsignedlong,    \"unsigned long\",     UNSIGNED,longmetric);\n\txx(unsignedshort,   \"unsigned short\",    UNSIGNED,shortmetric);\n\txx(unsignedtype,    \"unsigned int\",      UNSIGNED,intmetric);\n\txx(unsignedlonglong,\"unsigned long long\",UNSIGNED,longlongmetric);\n#undef xx\n\t{\n\t\tSymbol p;\n\t\tp = install(string(\"void\"), &types, GLOBAL, PERM);\n\t\tvoidtype = type(VOID, NULL, 0, 0, p);\n\t\tp->type = voidtype;\n\t}\n\tpointersym = install(string(\"T*\"), &types, GLOBAL, PERM);\n\tpointersym->addressed = IR->ptrmetric.outofline;\n\tpointersym->u.limits.max.p = (void*)ones(8*IR->ptrmetric.size);\n\tpointersym->u.limits.min.p = 0;\n\tvoidptype = ptr(voidtype);\n\tfuncptype = ptr(func(voidtype, NULL, 1));\n\tcharptype = ptr(chartype);\n#define xx(v,t) if (v==NULL && t->size==voidptype->size && t->align==voidptype->align) v=t\n\txx(unsignedptr,unsignedshort);\n\txx(unsignedptr,unsignedtype);\n\txx(unsignedptr,unsignedlong);\n\txx(unsignedptr,unsignedlonglong);\n\tif (unsignedptr == NULL)\n\t\tunsignedptr = type(UNSIGNED, NULL, voidptype->size, voidptype->align, voidptype->u.sym);\n\txx(signedptr,shorttype);\n\txx(signedptr,inttype);\n\txx(signedptr,longtype);\n\txx(signedptr,longlong);\n\tif (signedptr == NULL)\n\t\tsignedptr = type(INT, NULL, voidptype->size, voidptype->align, voidptype->u.sym);\n#undef xx\n\twidechar = unsignedshort;\n\tfor (i = 0; i < argc; i++) {\n#define xx(name,type) \\\n\t\tif (strcmp(argv[i], \"-wchar_t=\" #name) == 0) \\\n\t\t\twidechar = type;\n\t\txx(unsigned_char,unsignedchar)\n\t\txx(unsigned_int,unsignedtype)\n\t\txx(unsigned_short,unsignedshort)\n\t}\n#undef xx\n}\nvoid rmtypes(int lev) {\n\tif (maxlevel >= lev) {\n\t\tint i;\n\t\tmaxlevel = 0;\n\t\tfor (i = 0; i < NELEMS(typetable); i++) {\n\t\t\tstruct entry *tn, **tq = &typetable[i];\n\t\t\twhile ((tn = *tq) != NULL)\n\t\t\t\tif (tn->type.op == FUNCTION)\n\t\t\t\t\ttq = &tn->link;\n\t\t\t\telse if (tn->type.u.sym && tn->type.u.sym->scope >= lev)\n\t\t\t\t\t*tq = tn->link;\n\t\t\t\telse {\n\t\t\t\t\tif (tn->type.u.sym && tn->type.u.sym->scope > maxlevel)\n\t\t\t\t\t\tmaxlevel = tn->type.u.sym->scope;\n\t\t\t\t\ttq = &tn->link;\n\t\t\t\t}\n\n\t\t}\n\t}\n}\nType ptr(Type ty) {\n\treturn type(POINTER, ty, IR->ptrmetric.size,\n\t\tIR->ptrmetric.align, pointersym);\n}\nType deref(Type ty) {\n\tif (isptr(ty))\n\t\tty = ty->type;\n\telse\n\t\terror(\"type error: %s\\n\", \"pointer expected\");\n\treturn isenum(ty) ? unqual(ty)->type : ty;\n}\nType array(Type ty, int n, int a) {\n\tassert(ty);\n\tif (isfunc(ty)) {\n\t\terror(\"illegal type `array of %t'\\n\", ty);\n\t\treturn array(inttype, n, 0);\n\t}\n\tif (isarray(ty) && ty->size == 0)\n\t\terror(\"missing array size\\n\");\n\tif (ty->size == 0) {\n\t\tif (unqual(ty) == voidtype)\n\t\t\terror(\"illegal type `array of %t'\\n\", ty);\n\t\telse if (Aflag >= 2)\n\t\t\twarning(\"declaring type array of %t' is undefined\\n\", ty);\n\n\t} else if (n > INT_MAX/ty->size) {\n\t\terror(\"size of `array of %t' exceeds %d bytes\\n\",\n\t\t\tty, INT_MAX);\n\t\tn = 1;\n\t}\n\treturn type(ARRAY, ty, n*ty->size,\n\t\ta ? a : ty->align, NULL);\n}\nType atop(Type ty) {\n\tif (isarray(ty))\n\t\treturn ptr(ty->type);\n\terror(\"type error: %s\\n\", \"array expected\");\n\treturn ptr(ty);\n}\nType qual(int op, Type ty) {\n\tif (isarray(ty))\n\t\tty = type(ARRAY, qual(op, ty->type), ty->size,\n\t\t\tty->align, NULL);\n\telse if (isfunc(ty))\n\t\twarning(\"qualified function type ignored\\n\");\n\telse if (isconst(ty)    && op == CONST\n\t||       isvolatile(ty) && op == VOLATILE)\n\t\terror(\"illegal type `%k %t'\\n\", op, ty);\n\telse {\n\t\tif (isqual(ty)) {\n\t\t\top += ty->op;\n\t\t\tty = ty->type;\n\t\t}\n\t\tty = type(op, ty, ty->size, ty->align, NULL);\n\t}\n\treturn ty;\n}\nType func(Type ty, Type *proto, int style) {\n\tif (ty && (isarray(ty) || isfunc(ty)))\n\t\terror(\"illegal return type `%t'\\n\", ty);\n\tty = type(FUNCTION, ty, 0, 0, NULL);\n\tty->u.f.proto = proto;\n\tty->u.f.oldstyle = style;\n\treturn ty;\n}\nType freturn(Type ty) {\n\tif (isfunc(ty))\n\t\treturn ty->type;\n\terror(\"type error: %s\\n\", \"function expected\");\n\treturn inttype;\n}\nint variadic(Type ty) {\n\tif (isfunc(ty) && ty->u.f.proto) {\n\t\tint i;\n\t\tfor (i = 0; ty->u.f.proto[i]; i++)\n\t\t\t;\n\t\treturn i > 1 && ty->u.f.proto[i-1] == voidtype;\n\t}\n\treturn 0;\n}\nType newstruct(int op, char *tag) {\n\tSymbol p;\n\n\tassert(tag);\n\tif (*tag == 0)\n\t\ttag = stringd(genlabel(1));\n\telse\n\t\tif ((p = lookup(tag, types)) != NULL && (p->scope == level\n\t\t|| p->scope == PARAM && level == PARAM+1)) {\n\t\t\tif (p->type->op == op && !p->defined)\n\t\t\t\treturn p->type;\n\t\t\terror(\"redefinition of `%s' previously defined at %w\\n\",\n\t\t\t\tp->name, &p->src);\n\t\t}\n\tp = install(tag, &types, level, PERM);\n\tp->type = type(op, NULL, 0, 0, p);\n\tif (p->scope > maxlevel)\n\t\tmaxlevel = p->scope;\n\tp->src = src;\n\treturn p->type;\n}\nField newfield(char *name, Type ty, Type fty) {\n\tField p, *q = &ty->u.sym->u.s.flist;\n\n\tif (name == NULL)\n\t\tname = stringd(genlabel(1));\n\tfor (p = *q; p; q = &p->link, p = *q)\n\t\tif (p->name == name)\n\t\t\terror(\"duplicate field name `%s' in `%t'\\n\",\n\t\t\t\tname, ty);\n\tNEW0(p, PERM);\n\t*q = p;\n\tp->name = name;\n\tp->type = fty;\n\tif (xref) {\t\t\t\t\t\t\t/* omit */\n\t\tif (ty->u.sym->u.s.ftab == NULL)\t\t\t/* omit */\n\t\t\tty->u.sym->u.s.ftab = table(NULL, level);\t/* omit */\n\t\tinstall(name, &ty->u.sym->u.s.ftab, 0, PERM)->src = src;/* omit */\n\t}\t\t\t\t\t\t\t\t/* omit */\n\treturn p;\n}\nint eqtype(Type ty1, Type ty2, int ret) {\n\tif (ty1 == ty2)\n\t\treturn 1;\n\tif (ty1->op != ty2->op)\n\t\treturn 0;\n\tswitch (ty1->op) {\n\tcase ENUM: case UNION: case STRUCT:\n\tcase UNSIGNED: case INT: case FLOAT:\n\t\treturn 0;\n\tcase POINTER:  return eqtype(ty1->type, ty2->type, 1);\n\tcase VOLATILE: case CONST+VOLATILE:\n\tcase CONST:    return eqtype(ty1->type, ty2->type, 1);\n\tcase ARRAY:    if (eqtype(ty1->type, ty2->type, 1)) {\n\t\t       \tif (ty1->size == ty2->size)\n\t\t       \t\treturn 1;\n\t\t       \tif (ty1->size == 0 || ty2->size == 0)\n\t\t       \t\treturn ret;\n\t\t       }\n\t\t       return 0;\n\tcase FUNCTION: if (eqtype(ty1->type, ty2->type, 1)) {\n\t\t       \tType *p1 = ty1->u.f.proto, *p2 = ty2->u.f.proto;\n\t\t       \tif (p1 == p2)\n\t\t       \t\treturn 1;\n\t\t       \tif (p1 && p2) {\n\t\t       \t\tfor ( ; *p1 && *p2; p1++, p2++)\n\t\t\t\t\tif (eqtype(unqual(*p1), unqual(*p2), 1) == 0)\n\t\t\t\t\t\treturn 0;\n\t\t\t\tif (*p1 == NULL && *p2 == NULL)\n\t\t\t\t\treturn 1;\n\t\t       \t} else {\n\t\t       \t\tif (variadic(p1 ? ty1 : ty2))\n\t\t\t\t\treturn 0;\n\t\t\t\tif (p1 == NULL)\n\t\t\t\t\tp1 = p2;\n\t\t\t\tfor ( ; *p1; p1++) {\n\t\t\t\t\tType ty = unqual(*p1);\n\t\t\t\t\tif (promote(ty) != (isenum(ty) ? ty->type : ty))\n\t\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\treturn 1;\n\t\t       \t}\n\t\t       }\n\t\t       return 0;\n\t}\n\tassert(0); return 0;\n}\nType promote(Type ty) {\n\tty = unqual(ty);\n\tswitch (ty->op) {\n\tcase ENUM:\n\t\treturn inttype;\n\tcase INT:\n\t\tif (ty->size < inttype->size)\n\t\t\treturn inttype;\n\t\tbreak;\n\tcase UNSIGNED:\n\t\tif (ty->size < inttype->size)\n\t\t\treturn inttype;\n\t\tif (ty->size < unsignedtype->size)\n\t\t\treturn unsignedtype;\n\t\tbreak;\n\tcase FLOAT:\n\t\tif (ty->size < doubletype->size)\n\t\t\treturn doubletype;\n\t}\n\treturn ty;\n}\nType signedint(Type ty) {\n\tif (ty->op == INT)\n\t\treturn ty;\n\tassert(ty->op == UNSIGNED);\n#define xx(t) if (ty->size == t->size) return t\n\txx(inttype);\n\txx(longtype);\n\txx(longlong);\n#undef xx\n\tassert(0); return NULL;\n}\nType compose(Type ty1, Type ty2) {\n\tif (ty1 == ty2)\n\t\treturn ty1;\n\tassert(ty1->op == ty2->op);\n\tswitch (ty1->op) {\n\tcase POINTER:\n\t\treturn ptr(compose(ty1->type, ty2->type));\n\tcase CONST+VOLATILE:\n\t\treturn qual(CONST, qual(VOLATILE,\n\t\t\tcompose(ty1->type, ty2->type)));\n\tcase CONST: case VOLATILE:\n\t\treturn qual(ty1->op, compose(ty1->type, ty2->type));\n\tcase ARRAY:    { Type ty = compose(ty1->type, ty2->type);\n\t\t\t if (ty1->size && (ty1->type->size && ty2->size == 0 || ty1->size == ty2->size))\n\t\t\t \treturn array(ty, ty1->size/ty1->type->size, ty1->align);\n\t\t\t if (ty2->size && ty2->type->size && ty1->size == 0)\n\t\t\t \treturn array(ty, ty2->size/ty2->type->size, ty2->align);\n\t\t\t return array(ty, 0, 0);    }\n\tcase FUNCTION: { Type *p1  = ty1->u.f.proto, *p2 = ty2->u.f.proto;\n\t\t\t Type ty   = compose(ty1->type, ty2->type);\n\t\t\t List tlist = NULL;\n\t\t\t if (p1 == NULL && p2 == NULL)\n\t\t\t \treturn func(ty, NULL, 1);\n\t\t\t if (p1 && p2 == NULL)\n\t\t\t \treturn func(ty, p1, ty1->u.f.oldstyle);\n\t\t\t if (p2 && p1 == NULL)\n\t\t\t \treturn func(ty, p2, ty2->u.f.oldstyle);\n\t\t\t for ( ; *p1 && *p2; p1++, p2++) {\n\t\t\t \tType ty = compose(unqual(*p1), unqual(*p2));\n\t\t\t \tif (isconst(*p1)    || isconst(*p2))\n\t\t\t \t\tty = qual(CONST, ty);\n\t\t\t \tif (isvolatile(*p1) || isvolatile(*p2))\n\t\t\t \t\tty = qual(VOLATILE, ty);\n\t\t\t \ttlist = append(ty, tlist);\n\t\t\t }\n\t\t\t assert(*p1 == NULL && *p2 == NULL);\n\t\t\t return func(ty, ltov(&tlist, PERM), 0); }\n\t}\n\tassert(0); return NULL;\n}\nint ttob(Type ty) {\n\tswitch (ty->op) {\n\tcase CONST: case VOLATILE: case CONST+VOLATILE:\n\t\treturn ttob(ty->type);\n\tcase VOID: case INT: case UNSIGNED: case FLOAT:\n\t\treturn ty->op + sizeop(ty->size);\n\tcase POINTER:\n\t\treturn POINTER + sizeop(voidptype->size);\n\tcase FUNCTION:\n\t\treturn POINTER + sizeop(funcptype->size);\n\tcase ARRAY: case STRUCT: case UNION:\n\t\treturn STRUCT;\n\tcase ENUM:\n\t\treturn INT + sizeop(inttype->size);\n\t}\n\tassert(0); return INT;\n}\nType btot(int op, int size) {\n#define xx(ty) if (size == (ty)->size) return ty;\n\tswitch (optype(op)) {\n\tcase F:\n\t\txx(floattype);\n\t\txx(doubletype);\n\t\txx(longdouble);\n\t\tassert(0); return 0;\n\tcase I:\n\t\tif (chartype->op == INT)\n\t\t\txx(chartype);\n\t\txx(signedchar);\n\t\txx(shorttype);\n\t\txx(inttype);\n\t\txx(longtype);\n\t\txx(longlong);\n\t\tassert(0); return 0;\n\tcase U:\n\t\tif (chartype->op == UNSIGNED)\n\t\t\txx(chartype);\n\t\txx(unsignedchar);\n\t\txx(unsignedshort);\n\t\txx(unsignedtype);\n\t\txx(unsignedlong);\n\t\txx(unsignedlonglong);\n\t\tassert(0); return 0;\n\tcase P:\n\t\txx(voidptype);\n\t\txx(funcptype);\n\t\tassert(0); return 0;\n\t}\n#undef xx\n\tassert(0); return 0;\n}\nint hasproto(Type ty) {\n\tif (ty == 0)\n\t\treturn 1;\n\tswitch (ty->op) {\n\tcase CONST: case VOLATILE: case CONST+VOLATILE: case POINTER:\n\tcase ARRAY:\n\t\treturn hasproto(ty->type);\n\tcase FUNCTION:\n\t\treturn hasproto(ty->type) && ty->u.f.proto;\n\tcase STRUCT: case UNION:\n\tcase VOID:   case FLOAT: case ENUM:  case INT: case UNSIGNED:\n\t\treturn 1;\n\t}\n\tassert(0); return 0;\n}\n/* fieldlist - construct a flat list of fields in type ty */\nField fieldlist(Type ty) {\n\treturn ty->u.sym->u.s.flist;\n}\n\n/* fieldref - find field name of type ty, return entry */\nField fieldref(const char *name, Type ty) {\n\tField p = isfield(name, unqual(ty)->u.sym->u.s.flist);\n\n\tif (p && xref) {\n\t\tSymbol q;\n\t\tassert(unqual(ty)->u.sym->u.s.ftab);\n\t\tq = lookup(name, unqual(ty)->u.sym->u.s.ftab);\n\t\tassert(q);\n\t\tuse(q, src);\n\t}\n\treturn p;\n}\n\n/* ftype - return a function type for rty function (ty,...)' */\nType ftype(Type rty, Type ty) {\n\tList list = append(ty, NULL);\n\n\tlist = append(voidtype, list);\n\treturn func(rty, ltov(&list, PERM), 0);\n}\n\n/* isfield - if name is a field in flist, return pointer to the field structure */\nstatic Field isfield(const char *name, Field flist) {\n\tfor ( ; flist; flist = flist->link)\n\t\tif (flist->name == name)\n\t\t\tbreak;\n\treturn flist;\n}\n\n/* outtype - output type ty */\nvoid outtype(Type ty, FILE *f) {\n\tswitch (ty->op) {\n\tcase CONST+VOLATILE: case CONST: case VOLATILE:\n\t\tfprint(f, \"%k %t\", ty->op, ty->type);\n\t\tbreak;\n\tcase STRUCT: case UNION: case ENUM:\n\t\tassert(ty->u.sym);\n\t\tif (ty->size == 0)\n\t\t\tfprint(f, \"incomplete \");\n\t\tassert(ty->u.sym->name);\n\t\tif (*ty->u.sym->name >= '1' && *ty->u.sym->name <= '9') {\n\t\t\tSymbol p = findtype(ty);\n\t\t\tif (p == 0)\n\t\t\t\tfprint(f, \"%k defined at %w\", ty->op, &ty->u.sym->src);\n\t\t\telse\n\t\t\t\tfprint(f, p->name);\n\t\t} else {\n\t\t\tfprint(f, \"%k %s\", ty->op, ty->u.sym->name);\n\t\t\tif (ty->size == 0)\n\t\t\t\tfprint(f, \" defined at %w\", &ty->u.sym->src);\n\t\t}\n\t\tbreak;\n\tcase VOID: case FLOAT: case INT: case UNSIGNED:\n\t\tfprint(f, ty->u.sym->name);\n\t\tbreak;\n\tcase POINTER:\n\t\tfprint(f, \"pointer to %t\", ty->type);\n\t\tbreak;\n\tcase FUNCTION:\n\t\tfprint(f, \"%t function\", ty->type);\n\t\tif (ty->u.f.proto && ty->u.f.proto[0]) {\n\t\t\tint i;\n\t\t\tfprint(f, \"(%t\", ty->u.f.proto[0]);\n\t\t\tfor (i = 1; ty->u.f.proto[i]; i++)\n\t\t\t\tif (ty->u.f.proto[i] == voidtype)\n\t\t\t\t\tfprint(f, \",...\");\n\t\t\t\telse\n\t\t\t\t\tfprint(f, \",%t\", ty->u.f.proto[i]);\n\t\t\tfprint(f, \")\");\n\t\t} else if (ty->u.f.proto && ty->u.f.proto[0] == 0)\n\t\t\tfprint(f, \"(void)\");\n\n\t\tbreak;\n\tcase ARRAY:\n\t\tif (ty->size > 0 && ty->type && ty->type->size > 0) {\n\t\t\tfprint(f, \"array %d\", ty->size/ty->type->size);\n\t\t\twhile (ty->type && isarray(ty->type) && ty->type->type->size > 0) {\n\t\t\t\tty = ty->type;\n\t\t\t\tfprint(f, \",%d\", ty->size/ty->type->size);\n\t\t\t}\n\t\t} else\n\t\t\tfprint(f, \"incomplete array\");\n\t\tif (ty->type)\n\t\t\tfprint(f, \" of %t\", ty->type);\n\t\tbreak;\n\tdefault: assert(0);\n\t}\n}\n\n/* printdecl - output a C declaration for symbol p of type ty */\nvoid printdecl(Symbol p, Type ty) {\n\tswitch (p->sclass) {\n\tcase AUTO:\n\t\tfprint(stderr, \"%s;\\n\", typestring(ty, p->name));\n\t\tbreak;\n\tcase STATIC: case EXTERN:\n\t\tfprint(stderr, \"%k %s;\\n\", p->sclass, typestring(ty, p->name));\n\t\tbreak;\n\tcase TYPEDEF: case ENUM:\n\t\tbreak;\n\tdefault: assert(0);\n\t}\n}\n\n/* printproto - output a prototype declaration for function p */\nvoid printproto(Symbol p, Symbol callee[]) {\n\tif (p->type->u.f.proto)\n\t\tprintdecl(p, p->type);\n\telse {\n\t\tint i;\n\t\tList list = 0;\n\t\tif (callee[0] == 0)\n\t\t\tlist = append(voidtype, list);\n\t\telse\n\t\t\tfor (i = 0; callee[i]; i++)\n\t\t\t\tlist = append(callee[i]->type, list);\n\t\tprintdecl(p, func(freturn(p->type), ltov(&list, PERM), 0));\n\t}\n}\n\n/* prtype - print details of type ty on f with given indent */\nstatic void prtype(Type ty, FILE *f, int indent, unsigned mark) {\n\tswitch (ty->op) {\n\tdefault:\n\t\tfprint(f, \"(%d %d %d [%p])\", ty->op, ty->size, ty->align, ty->u.sym);\n\t\tbreak;\n\tcase FLOAT: case INT: case UNSIGNED: case VOID:\n\t\tfprint(f, \"(%k %d %d [\\\"%s\\\"])\", ty->op, ty->size, ty->align, ty->u.sym->name);\n\t\tbreak;\n\tcase CONST+VOLATILE: case CONST: case VOLATILE: case POINTER: case ARRAY:\n\t\tfprint(f, \"(%k %d %d \", ty->op, ty->size, ty->align);\n\t\tprtype(ty->type, f, indent+1, mark);\n\t\tfprint(f, \")\");\n\t\tbreak;\n\tcase STRUCT: case UNION:\n\t\tfprint(f, \"(%k %d %d [\\\"%s\\\"]\", ty->op, ty->size, ty->align, ty->u.sym->name);\n\t\tif (ty->x.marked != mark) {\n\t\t\tField p;\n\t\t\tty->x.marked = mark;\n\t\t\tfor (p = ty->u.sym->u.s.flist; p; p = p->link) {\n\t\t\t\tfprint(f, \"\\n%I\", indent+1);\n\t\t\t\tprtype(p->type, f, indent+1, mark);\n\t\t\t\tfprint(f, \" %s@%d\", p->name, p->offset);\n\t\t\t\tif (p->lsb)\n\t\t\t\t\tfprint(f, \":%d..%d\",\n\t\t\t\t\t\tfieldsize(p) + fieldright(p), fieldright(p));\n\t\t\t}\n\t\t\tfprint(f, \"\\n%I\", indent);\n\t\t}\n\t\tfprint(f, \")\");\n\t\tbreak;\n\tcase ENUM:\n\t\tfprint(f, \"(%k %d %d [\\\"%s\\\"]\", ty->op, ty->size, ty->align, ty->u.sym->name);\n\t\tif (ty->x.marked != mark) {\n\t\t\tint i;\n\t\t\tSymbol *p = ty->u.sym->u.idlist;\n\t\t\tty->x.marked = mark;\n\t\t\tfor (i = 0; p[i] != NULL; i++)\n\t\t\t\tfprint(f, \"%I%s=%d\\n\", indent+1, p[i]->name, p[i]->u.value);\n\t\t}\n\t\tfprint(f, \")\");\n\t\tbreak;\n\tcase FUNCTION:\n\t\tfprint(f, \"(%k %d %d \", ty->op, ty->size, ty->align);\n\t\tprtype(ty->type, f, indent+1, mark);\n\t\tif (ty->u.f.proto) {\n\t\t\tint i;\n\t\t\tfprint(f, \"\\n%I{\", indent+1);\n\t\t\tfor (i = 0; ty->u.f.proto[i]; i++) {\n\t\t\t\tif (i > 0)\n\t\t\t\t\tfprint(f, \"%I\", indent+2);\n\t\t\t\tprtype(ty->u.f.proto[i], f, indent+2, mark);\n\t\t\t\tfprint(f, \"\\n\");\n\t\t\t}\n\t\t\tfprint(f, \"%I}\", indent+1);\n\t\t}\n\t\tfprint(f, \")\");\n\t\tbreak;\n\t}\n}\n\n/* printtype - print details of type ty on fd */\nvoid printtype(Type ty, int fd) {\n\tstatic unsigned mark;\n\tprtype(ty, fd == 1 ? stdout : stderr, 0, ++mark);\n\tfprint(fd == 1 ? stdout : stderr, \"\\n\");\n}\n\n/* typestring - return ty as C declaration for str, which may be \"\" */\nchar *typestring(Type ty, char *str) {\n\tfor ( ; ty; ty = ty->type) {\n\t\tSymbol p;\n\t\tswitch (ty->op) {\n\t\tcase CONST+VOLATILE: case CONST: case VOLATILE:\n\t\t\tif (isptr(ty->type))\n\t\t\t\tstr = stringf(\"%k %s\", ty->op, str);\n\t\t\telse\n\t\t\t\treturn stringf(\"%k %s\", ty->op, typestring(ty->type, str));\n\t\t\tbreak;\n\t\tcase STRUCT: case UNION: case ENUM:\n\t\t\tassert(ty->u.sym);\n\t\t\tif ((p = findtype(ty)) != NULL)\n\t\t\t\treturn *str ? stringf(\"%s %s\", p->name, str) : p->name;\n\t\t\tif (*ty->u.sym->name >= '1' && *ty->u.sym->name <= '9')\n\t\t\t\twarning(\"unnamed %k in prototype\\n\", ty->op);\n\t\t\tif (*str)\n\t\t\t\treturn stringf(\"%k %s %s\", ty->op, ty->u.sym->name, str);\n\t\t\telse\n\t\t\t\treturn stringf(\"%k %s\", ty->op, ty->u.sym->name);\n\t\tcase VOID: case FLOAT: case INT: case UNSIGNED:\n\t\t\treturn *str ? stringf(\"%s %s\", ty->u.sym->name, str) : ty->u.sym->name;\n\t\tcase POINTER:\n\t\t\tif (!ischar(ty->type) && (p = findtype(ty)) != NULL)\n\t\t\t\treturn *str ? stringf(\"%s %s\", p->name, str) : p->name;\n\t\t\tstr = stringf(isarray(ty->type) || isfunc(ty->type) ? \"(*%s)\" : \"*%s\", str);\n\t\t\tbreak;\n\t\tcase FUNCTION:\n\t\t\tif ((p = findtype(ty)) != NULL)\n\t\t\t\treturn *str ? stringf(\"%s %s\", p->name, str) : p->name;\n\t\t\tif (ty->u.f.proto == 0)\n\t\t\t\tstr = stringf(\"%s()\", str);\n\t\t\telse if (ty->u.f.proto[0]) {\n\t\t\t\tint i;\n\t\t\t\tstr = stringf(\"%s(%s\", str, typestring(ty->u.f.proto[0], \"\"));\n\t\t\t\tfor (i = 1; ty->u.f.proto[i]; i++)\n\t\t\t\t\tif (ty->u.f.proto[i] == voidtype)\n\t\t\t\t\t\tstr = stringf(\"%s, ...\", str);\n\t\t\t\t\telse\n\t\t\t\t\t\tstr = stringf(\"%s, %s\", str, typestring(ty->u.f.proto[i], \"\"));\n\t\t\t\tstr = stringf(\"%s)\", str);\n\t\t\t} else\n\t\t\t\tstr = stringf(\"%s(void)\", str);\n\t\t\tbreak;\n\t\tcase ARRAY:\n\t\t\tif ((p = findtype(ty)) != NULL)\n\t\t\t\treturn *str ? stringf(\"%s %s\", p->name, str) : p->name;\n\t\t\tif (ty->type && ty->type->size > 0)\n\t\t\t\tstr = stringf(\"%s[%d]\", str, ty->size/ty->type->size);\n\t\t\telse\n\t\t\t\tstr = stringf(\"%s[]\", str);\n\t\t\tbreak;\n\t\tdefault: assert(0);\n\t\t}\n\t}\n\tassert(0); return 0;\n}\n\n"
  },
  {
    "path": "lcc/src/x86.md",
    "content": "%{\nenum { EAX=0, ECX=1, EDX=2, EBX=3, ESI=6, EDI=7 };\n#include \"c.h\"\n#define NODEPTR_TYPE Node\n#define OP_LABEL(p) ((p)->op)\n#define LEFT_CHILD(p) ((p)->kids[0])\n#define RIGHT_CHILD(p) ((p)->kids[1])\n#define STATE_LABEL(p) ((p)->x.state)\nstatic void address(Symbol, Symbol, long);\nstatic void blkfetch(int, int, int, int);\nstatic void blkloop(int, int, int, int, int, int[]);\nstatic void blkstore(int, int, int, int);\nstatic void defaddress(Symbol);\nstatic void defconst(int, int, Value);\nstatic void defstring(int, char *);\nstatic void defsymbol(Symbol);\nstatic void doarg(Node);\nstatic void emit2(Node);\nstatic void export(Symbol);\nstatic void clobber(Node);\nstatic void function(Symbol, Symbol [], Symbol [], int);\nstatic void global(Symbol);\nstatic void import(Symbol);\nstatic void local(Symbol);\nstatic void progbeg(int, char **);\nstatic void progend(void);\nstatic void segment(int);\nstatic void space(int);\nstatic void target(Node);\nextern int ckstack(Node, int);\nextern int memop(Node);\nextern int sametree(Node, Node);\nstatic Symbol charreg[32], shortreg[32], intreg[32];\nstatic Symbol fltreg[32];\n\nstatic Symbol charregw, shortregw, intregw, fltregw;\n\nstatic int cseg;\n\nstatic Symbol quo, rem;\n\n%}\n%start stmt\n%term CNSTF4=4113\n%term CNSTF8=8209\n%term CNSTF16=16401\n%term CNSTI1=1045\n%term CNSTI2=2069\n%term CNSTI4=4117\n%term CNSTI8=8213\n%term CNSTP4=4119\n%term CNSTP8=8215\n%term CNSTU1=1046\n%term CNSTU2=2070\n%term CNSTU4=4118\n%term CNSTU8=8214\n \n%term ARGB=41\n%term ARGF4=4129\n%term ARGF8=8225\n%term ARGF16=16417\n%term ARGI4=4133\n%term ARGI8=8229\n%term ARGP4=4135\n%term ARGP8=8231\n%term ARGU4=4134\n%term ARGU8=8230\n\n%term ASGNB=57\n%term ASGNF4=4145\n%term ASGNF8=8241\n%term ASGNF16=16433\n%term ASGNI1=1077\n%term ASGNI2=2101\n%term ASGNI4=4149\n%term ASGNI8=8245\n%term ASGNP4=4151\n%term ASGNP8=8247\n%term ASGNU1=1078\n%term ASGNU2=2102\n%term ASGNU4=4150\n%term ASGNU8=8246\n\n%term INDIRB=73\n%term INDIRF4=4161\n%term INDIRF8=8257\n%term INDIRF16=16449\n%term INDIRI1=1093\n%term INDIRI2=2117\n%term INDIRI4=4165\n%term INDIRI8=8261\n%term INDIRP4=4167\n%term INDIRP8=8263\n%term INDIRU1=1094\n%term INDIRU2=2118\n%term INDIRU4=4166\n%term INDIRU8=8262\n\n%term CVFF4=4209\n%term CVFF8=8305\n%term CVFF16=16497\n%term CVFI4=4213\n%term CVFI8=8309\n\n%term CVIF4=4225\n%term CVIF8=8321\n%term CVIF16=16513\n%term CVII1=1157\n%term CVII2=2181\n%term CVII4=4229\n%term CVII8=8325\n%term CVIU1=1158\n%term CVIU2=2182\n%term CVIU4=4230\n%term CVIU8=8326\n\n%term CVPP4=4247\n%term CVPP8=8343\n%term CVPP16=16535\n%term CVPU4=4246\n%term CVPU8=8342\n\n%term CVUI1=1205\n%term CVUI2=2229\n%term CVUI4=4277\n%term CVUI8=8373\n%term CVUP4=4279\n%term CVUP8=8375\n%term CVUP16=16567\n%term CVUU1=1206\n%term CVUU2=2230\n%term CVUU4=4278\n%term CVUU8=8374\n\n%term NEGF4=4289\n%term NEGF8=8385\n%term NEGF16=16577\n%term NEGI4=4293\n%term NEGI8=8389\n\n%term CALLB=217\n%term CALLF4=4305\n%term CALLF8=8401\n%term CALLF16=16593\n%term CALLI4=4309\n%term CALLI8=8405\n%term CALLP4=4311\n%term CALLP8=8407\n%term CALLU4=4310\n%term CALLU8=8406\n%term CALLV=216\n\n%term RETF4=4337\n%term RETF8=8433\n%term RETF16=16625\n%term RETI4=4341\n%term RETI8=8437\n%term RETP4=4343\n%term RETP8=8439\n%term RETU4=4342\n%term RETU8=8438\n%term RETV=248\n\n%term ADDRGP4=4359\n%term ADDRGP8=8455\n\n%term ADDRFP4=4375\n%term ADDRFP8=8471\n\n%term ADDRLP4=4391\n%term ADDRLP8=8487\n\n%term ADDF4=4401\n%term ADDF8=8497\n%term ADDF16=16689\n%term ADDI4=4405\n%term ADDI8=8501\n%term ADDP4=4407\n%term ADDP8=8503\n%term ADDU4=4406\n%term ADDU8=8502\n\n%term SUBF4=4417\n%term SUBF8=8513\n%term SUBF16=16705\n%term SUBI4=4421\n%term SUBI8=8517\n%term SUBP4=4423\n%term SUBP8=8519\n%term SUBU4=4422\n%term SUBU8=8518\n\n%term LSHI4=4437\n%term LSHI8=8533\n%term LSHU4=4438\n%term LSHU8=8534\n\n%term MODI4=4453\n%term MODI8=8549\n%term MODU4=4454\n%term MODU8=8550\n\n%term RSHI4=4469\n%term RSHI8=8565\n%term RSHU4=4470\n%term RSHU8=8566\n\n%term BANDI4=4485\n%term BANDI8=8581\n%term BANDU4=4486\n%term BANDU8=8582\n\n%term BCOMI4=4501\n%term BCOMI8=8597\n%term BCOMU4=4502\n%term BCOMU8=8598\n\n%term BORI4=4517\n%term BORI8=8613\n%term BORU4=4518\n%term BORU8=8614\n\n%term BXORI4=4533\n%term BXORI8=8629\n%term BXORU4=4534\n%term BXORU8=8630\n\n%term DIVF4=4545\n%term DIVF8=8641\n%term DIVF16=16833\n%term DIVI4=4549\n%term DIVI8=8645\n%term DIVU4=4550\n%term DIVU8=8646\n\n%term MULF4=4561\n%term MULF8=8657\n%term MULF16=16849\n%term MULI4=4565\n%term MULI8=8661\n%term MULU4=4566\n%term MULU8=8662\n\n%term EQF4=4577\n%term EQF8=8673\n%term EQF16=16865\n%term EQI4=4581\n%term EQI8=8677\n%term EQU4=4582\n%term EQU8=8678\n\n%term GEF4=4593\n%term GEF8=8689\n%term GEI4=4597\n%term GEI8=8693\n%term GEI16=16885\n%term GEU4=4598\n%term GEU8=8694\n\n%term GTF4=4609\n%term GTF8=8705\n%term GTF16=16897\n%term GTI4=4613\n%term GTI8=8709\n%term GTU4=4614\n%term GTU8=8710\n\n%term LEF4=4625\n%term LEF8=8721\n%term LEF16=16913\n%term LEI4=4629\n%term LEI8=8725\n%term LEU4=4630\n%term LEU8=8726\n\n%term LTF4=4641\n%term LTF8=8737\n%term LTF16=16929\n%term LTI4=4645\n%term LTI8=8741\n%term LTU4=4646\n%term LTU8=8742\n\n%term NEF4=4657\n%term NEF8=8753\n%term NEF16=16945\n%term NEI4=4661\n%term NEI8=8757\n%term NEU4=4662\n%term NEU8=8758\n\n%term JUMPV=584\n\n%term LABELV=600\n\n%term LOADB=233\n%term LOADF4=4321\n%term LOADF8=8417\n%term LOADF16=16609\n%term LOADI1=1253\n%term LOADI2=2277\n%term LOADI4=4325\n%term LOADI8=8421\n%term LOADP4=4327\n%term LOADP8=8423\n%term LOADU1=1254\n%term LOADU2=2278\n%term LOADU4=4326\n%term LOADU8=8422\n\n%term VREGP=711\n%%\nreg:  INDIRI1(VREGP)     \"# read register\\n\"\nreg:  INDIRU1(VREGP)     \"# read register\\n\"\n\nreg:  INDIRI2(VREGP)     \"# read register\\n\"\nreg:  INDIRU2(VREGP)     \"# read register\\n\"\n\nreg:  INDIRF4(VREGP)     \"# read register\\n\"\nreg:  INDIRI4(VREGP)     \"# read register\\n\"\nreg:  INDIRP4(VREGP)     \"# read register\\n\"\nreg:  INDIRU4(VREGP)     \"# read register\\n\"\n\nreg:  INDIRF8(VREGP)     \"# read register\\n\"\nreg:  INDIRI8(VREGP)     \"# read register\\n\"\nreg:  INDIRP8(VREGP)     \"# read register\\n\"\nreg:  INDIRU8(VREGP)     \"# read register\\n\"\n\nstmt: ASGNI1(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNU1(VREGP,reg)  \"# write register\\n\"\n\nstmt: ASGNI2(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNU2(VREGP,reg)  \"# write register\\n\"\n\nstmt: ASGNF4(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNI4(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNP4(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNU4(VREGP,reg)  \"# write register\\n\"\n\nstmt: ASGNF8(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNI8(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNP8(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNU8(VREGP,reg)  \"# write register\\n\"\ncon: CNSTI1  \"%a\"\ncon: CNSTU1  \"%a\"\n\ncon: CNSTI2  \"%a\"\ncon: CNSTU2  \"%a\"\n\ncon: CNSTI4  \"%a\"\ncon: CNSTU4  \"%a\"\ncon: CNSTP4  \"%a\"\n\ncon: CNSTI8  \"%a\"\ncon: CNSTU8  \"%a\"\ncon: CNSTP8  \"%a\"\nstmt: reg  \"\"\nacon: ADDRGP4  \"(%a)\"\nacon: con     \"(%0)\"\nbase: ADDRGP4          \"(%a)\"\nbase: reg              \"[%0]\"\nbase: ADDI4(reg,acon)  \"%1[%0]\"\nbase: ADDP4(reg,acon)  \"%1[%0]\"\nbase: ADDU4(reg,acon)  \"%1[%0]\"\nbase: ADDRFP4  \"(%a)[ebp]\"\nbase: ADDRLP4  \"(%a)[ebp]\"\nindex: reg \"%0\"\nindex: LSHI4(reg,con1)  \"%0*2\"\nindex: LSHI4(reg,con2)  \"%0*4\"\nindex: LSHI4(reg,con3)  \"%0*8\"\n\ncon1:  CNSTI4  \"1\"  range(a, 1, 1)\ncon1:  CNSTU4  \"1\"  range(a, 1, 1)\ncon2:  CNSTI4  \"2\"  range(a, 2, 2)\ncon2:  CNSTU4  \"2\"  range(a, 2, 2)\ncon3:  CNSTI4  \"3\"  range(a, 3, 3)\ncon3:  CNSTU4  \"3\"  range(a, 3, 3)\nindex: LSHU4(reg,con1)  \"%0*2\"\nindex: LSHU4(reg,con2)  \"%0*4\"\nindex: LSHU4(reg,con3)  \"%0*8\"\naddr: base              \"%0\"\naddr: ADDI4(index,base)  \"%1[%0]\"\naddr: ADDP4(index,base)  \"%1[%0]\"\naddr: ADDU4(index,base)  \"%1[%0]\"\naddr: index  \"[%0]\"\nmem: INDIRI1(addr)  \"byte ptr %0\"\nmem: INDIRI2(addr)  \"word ptr %0\"\nmem: INDIRI4(addr)  \"dword ptr %0\"\nmem: INDIRU1(addr)  \"byte ptr %0\"\nmem: INDIRU2(addr)  \"word ptr %0\"\nmem: INDIRU4(addr)  \"dword ptr %0\"\nmem: INDIRP4(addr)  \"dword ptr %0\"\nrc:   reg  \"%0\"\nrc:   con  \"%0\"\n\nmr:   reg  \"%0\"\nmr:   mem  \"%0\"\n\nmrc0: mem  \"%0\"\nmrc0: rc   \"%0\"\nmrc1: mem  \"%0\"  1\nmrc1: rc   \"%0\"\n\nmrc3: mem  \"%0\"  3\nmrc3: rc   \"%0\"\nreg: addr         \"lea %c,%0\\n\"  1\nreg: mrc0         \"mov %c,%0\\n\"  1\nreg: LOADI1(reg)  \"# move\\n\"  1\nreg: LOADI2(reg)  \"# move\\n\"  1\nreg: LOADI4(reg)  \"# move\\n\"  move(a)\nreg: LOADU1(reg)  \"# move\\n\"  1\nreg: LOADU2(reg)  \"# move\\n\"  1\nreg: LOADU4(reg)  \"# move\\n\"  move(a)\nreg: LOADP4(reg)  \"# move\\n\"  move(a)\nreg: ADDI4(reg,mrc1)  \"?mov %c,%0\\nadd %c,%1\\n\"  1\nreg: ADDP4(reg,mrc1)  \"?mov %c,%0\\nadd %c,%1\\n\"  1\nreg: ADDU4(reg,mrc1)  \"?mov %c,%0\\nadd %c,%1\\n\"  1\nreg: SUBI4(reg,mrc1)  \"?mov %c,%0\\nsub %c,%1\\n\"  1\nreg: SUBP4(reg,mrc1)  \"?mov %c,%0\\nsub %c,%1\\n\"  1\nreg: SUBU4(reg,mrc1)  \"?mov %c,%0\\nsub %c,%1\\n\"  1\nreg: BANDI4(reg,mrc1)  \"?mov %c,%0\\nand %c,%1\\n\"  1\nreg: BORI4(reg,mrc1)   \"?mov %c,%0\\nor %c,%1\\n\"   1\nreg: BXORI4(reg,mrc1)  \"?mov %c,%0\\nxor %c,%1\\n\"  1\nreg: BANDU4(reg,mrc1)  \"?mov %c,%0\\nand %c,%1\\n\"  1\nreg: BORU4(reg,mrc1)   \"?mov %c,%0\\nor %c,%1\\n\"   1\nreg: BXORU4(reg,mrc1)  \"?mov %c,%0\\nxor %c,%1\\n\"  1\nstmt: ASGNI4(addr,ADDI4(mem,con1))  \"inc %1\\n\"  memop(a)\nstmt: ASGNI4(addr,ADDU4(mem,con1))  \"inc %1\\n\"  memop(a)\nstmt: ASGNP4(addr,ADDP4(mem,con1))  \"inc %1\\n\"  memop(a)\nstmt: ASGNI4(addr,SUBI4(mem,con1))  \"dec %1\\n\"  memop(a)\nstmt: ASGNI4(addr,SUBU4(mem,con1))  \"dec %1\\n\"  memop(a)\nstmt: ASGNP4(addr,SUBP4(mem,con1))  \"dec %1\\n\"  memop(a)\nstmt: ASGNI4(addr,ADDI4(mem,rc))   \"add %1,%2\\n\"  memop(a)\nstmt: ASGNI4(addr,SUBI4(mem,rc))   \"sub %1,%2\\n\"  memop(a)\nstmt: ASGNU4(addr,ADDU4(mem,rc))   \"add %1,%2\\n\"  memop(a)\nstmt: ASGNU4(addr,SUBU4(mem,rc))   \"sub %1,%2\\n\"  memop(a)\n\nstmt: ASGNI4(addr,BANDI4(mem,rc))  \"and %1,%2\\n\"  memop(a)\nstmt: ASGNI4(addr,BORI4(mem,rc))   \"or %1,%2\\n\"   memop(a)\nstmt: ASGNI4(addr,BXORI4(mem,rc))  \"xor %1,%2\\n\"  memop(a)\nstmt: ASGNU4(addr,BANDU4(mem,rc))  \"and %1,%2\\n\"  memop(a)\nstmt: ASGNU4(addr,BORU4(mem,rc))   \"or %1,%2\\n\"   memop(a)\nstmt: ASGNU4(addr,BXORU4(mem,rc))  \"xor %1,%2\\n\"  memop(a)\nreg: BCOMI4(reg)  \"?mov %c,%0\\nnot %c\\n\"  2\nreg: BCOMU4(reg)  \"?mov %c,%0\\nnot %c\\n\"  2\nreg: NEGI4(reg)   \"?mov %c,%0\\nneg %c\\n\"  2\n\nstmt: ASGNI4(addr,BCOMI4(mem))  \"not %1\\n\"  memop(a)\nstmt: ASGNU4(addr,BCOMU4(mem))  \"not %1\\n\"  memop(a)\nstmt: ASGNI4(addr,NEGI4(mem))   \"neg %1\\n\"  memop(a)\nreg: LSHI4(reg,con5)  \"?mov %c,%0\\nsal %c,%1\\n\"  2\nreg: LSHU4(reg,con5)  \"?mov %c,%0\\nshl %c,%1\\n\"  2\nreg: RSHI4(reg,con5)  \"?mov %c,%0\\nsar %c,%1\\n\"  2\nreg: RSHU4(reg,con5)  \"?mov %c,%0\\nshr %c,%1\\n\"  2\n\nstmt: ASGNI4(addr,LSHI4(mem,con5))  \"sal %1,%2\\n\"  memop(a)\nstmt: ASGNI4(addr,LSHU4(mem,con5))  \"shl %1,%2\\n\"  memop(a)\nstmt: ASGNI4(addr,RSHI4(mem,con5))  \"sar %1,%2\\n\"  memop(a)\nstmt: ASGNI4(addr,RSHU4(mem,con5))  \"shr %1,%2\\n\"  memop(a)\n\ncon5: CNSTI4  \"%a\"  range(a, 0, 31)\n\nreg: LSHI4(reg,reg)  \"?mov %c,%0\\nmov ecx,%1\\nsal %c,cl\\n\"  3\nreg: LSHU4(reg,reg)  \"?mov %c,%0\\nmov ecx,%1\\nshl %c,cl\\n\"  2\nreg: RSHI4(reg,reg)  \"?mov %c,%0\\nmov ecx,%1\\nsar %c,cl\\n\"  2\nreg: RSHU4(reg,reg)  \"?mov %c,%0\\nmov ecx,%1\\nshr %c,cl\\n\"  2\nreg: MULI4(reg,mrc3)  \"?mov %c,%0\\nimul %c,%1\\n\"  14\nreg: MULI4(con,mr)    \"imul %c,%1,%0\\n\"  13\nreg: MULU4(reg,mr)  \"mul %1\\n\"  13\nreg: DIVU4(reg,reg)  \"xor edx,edx\\ndiv %1\\n\"\nreg: MODU4(reg,reg)  \"xor edx,edx\\ndiv %1\\n\"\nreg: DIVI4(reg,reg)  \"cdq\\nidiv %1\\n\"\nreg: MODI4(reg,reg)  \"cdq\\nidiv %1\\n\"\nreg: CVPU4(reg)  \"mov %c,%0\\n\"  move(a)\nreg: CVUP4(reg)  \"mov %c,%0\\n\"  move(a)\nreg: CVII4(INDIRI1(addr))  \"movsx %c,byte ptr %0\\n\"  3\nreg: CVII4(INDIRI2(addr))  \"movsx %c,word ptr %0\\n\"  3\nreg: CVUU4(INDIRU1(addr))  \"movzx %c,byte ptr %0\\n\"  3\nreg: CVUU4(INDIRU2(addr))  \"movzx %c,word ptr %0\\n\"  3\nreg: CVII4(reg)  \"# extend\\n\"  3\nreg: CVIU4(reg)  \"# extend\\n\"  3\nreg: CVUI4(reg)  \"# extend\\n\"  3\nreg: CVUU4(reg)  \"# extend\\n\"  3\n\nreg: CVII1(reg)  \"# truncate\\n\"  1\nreg: CVII2(reg)  \"# truncate\\n\"  1\nreg: CVUU1(reg)  \"# truncate\\n\"  1\nreg: CVUU2(reg)  \"# truncate\\n\"  1\nstmt: ASGNI1(addr,rc)  \"mov byte ptr %0,%1\\n\"   1\nstmt: ASGNI2(addr,rc)  \"mov word ptr %0,%1\\n\"   1\nstmt: ASGNI4(addr,rc)  \"mov dword ptr %0,%1\\n\"  1\nstmt: ASGNU1(addr,rc)  \"mov byte ptr %0,%1\\n\"   1\nstmt: ASGNU2(addr,rc)  \"mov word ptr %0,%1\\n\"   1\nstmt: ASGNU4(addr,rc)  \"mov dword ptr %0,%1\\n\"  1\nstmt: ASGNP4(addr,rc)  \"mov dword ptr %0,%1\\n\"  1\nstmt: ARGI4(mrc3)  \"push %0\\n\"  1\nstmt: ARGU4(mrc3)  \"push %0\\n\"  1\nstmt: ARGP4(mrc3)  \"push %0\\n\"  1\nstmt: ASGNB(reg,INDIRB(reg))  \"mov ecx,%a\\nrep movsb\\n\"\nstmt: ARGB(INDIRB(reg))  \"sub esp,%a\\nmov edi,esp\\nmov ecx,%a\\nrep movsb\\n\"\n\nmemf: INDIRF8(addr)         \"qword ptr %0\"\nmemf: INDIRF4(addr)         \"dword ptr %0\"\nmemf: CVFF8(INDIRF4(addr))  \"dword ptr %0\"\nreg: memf  \"fld %0\\n\"  3\nstmt: ASGNF8(addr,reg)         \"fstp qword ptr %0\\n\"  7\nstmt: ASGNF4(addr,reg)         \"fstp dword ptr %0\\n\"  7\nstmt: ASGNF4(addr,CVFF4(reg))  \"fstp dword ptr %0\\n\"  7\nstmt: ARGF8(reg)  \"sub esp,8\\nfstp qword ptr [esp]\\n\"\nstmt: ARGF4(reg)  \"sub esp,4\\nfstp dword ptr [esp]\\n\"\nreg: NEGF8(reg)  \"fchs\\n\"\nreg: NEGF4(reg)  \"fchs\\n\"\nflt: memf  \" %0\"\nflt: reg   \"p st(1),st\"\nreg: ADDF8(reg,flt)  \"fadd%1\\n\"\nreg: ADDF4(reg,flt)  \"fadd%1\\n\"\nreg: DIVF8(reg,flt)  \"fdiv%1\\n\"\nreg: DIVF4(reg,flt)  \"fdiv%1\\n\"\nreg: MULF8(reg,flt)  \"fmul%1\\n\"\nreg: MULF4(reg,flt)  \"fmul%1\\n\"\nreg: SUBF8(reg,flt)  \"fsub%1\\n\"\nreg: SUBF4(reg,flt)  \"fsub%1\\n\"\nreg: CVFF8(reg)  \"# CVFF8\\n\"\nreg: CVFF4(reg)  \"sub esp,4\\nfstp dword ptr 0[esp]\\nfld dword ptr 0[esp]\\nadd esp,4\\n\"  12\n\nreg: CVFI4(reg)  \"call __ftol\\n\" 31\nreg: CVIF8(INDIRI4(addr))  \"fild dword ptr %0\\n\"  10\nreg: CVIF4(reg)  \"push %0\\nfild dword ptr 0[esp]\\nadd esp,4\\n\"  12\n\nreg: CVIF8(reg)  \"push %0\\nfild dword ptr 0[esp]\\nadd esp,4\\n\"  12\n\naddrj: ADDRGP4  \"%a\"\naddrj: reg      \"%0\"  2\naddrj: mem      \"%0\"  2\n\nstmt:  JUMPV(addrj)  \"jmp %0\\n\"  3\nstmt:  LABELV        \"%a:\\n\"\nstmt: EQI4(mem,rc)  \"cmp %0,%1\\nje %a\\n\"   5\nstmt: GEI4(mem,rc)  \"cmp %0,%1\\njge %a\\n\"  5\nstmt: GTI4(mem,rc)  \"cmp %0,%1\\njg %a\\n\"   5\nstmt: LEI4(mem,rc)  \"cmp %0,%1\\njle %a\\n\"  5\nstmt: LTI4(mem,rc)  \"cmp %0,%1\\njl %a\\n\"   5\nstmt: NEI4(mem,rc)  \"cmp %0,%1\\njne %a\\n\"  5\nstmt: GEU4(mem,rc)  \"cmp %0,%1\\njae %a\\n\"  5\nstmt: GTU4(mem,rc)  \"cmp %0,%1\\nja  %a\\n\"  5\nstmt: LEU4(mem,rc)  \"cmp %0,%1\\njbe %a\\n\"  5\nstmt: LTU4(mem,rc)  \"cmp %0,%1\\njb  %a\\n\"  5\nstmt: EQI4(reg,mrc1)  \"cmp %0,%1\\nje %a\\n\"   4\nstmt: GEI4(reg,mrc1)  \"cmp %0,%1\\njge %a\\n\"  4\nstmt: GTI4(reg,mrc1)  \"cmp %0,%1\\njg %a\\n\"   4\nstmt: LEI4(reg,mrc1)  \"cmp %0,%1\\njle %a\\n\"  4\nstmt: LTI4(reg,mrc1)  \"cmp %0,%1\\njl %a\\n\"   4\nstmt: NEI4(reg,mrc1)  \"cmp %0,%1\\njne %a\\n\"  4\n\nstmt: EQU4(reg,mrc1)  \"cmp %0,%1\\nje %a\\n\"   4\nstmt: GEU4(reg,mrc1)  \"cmp %0,%1\\njae %a\\n\"  4\nstmt: GTU4(reg,mrc1)  \"cmp %0,%1\\nja %a\\n\"   4\nstmt: LEU4(reg,mrc1)  \"cmp %0,%1\\njbe %a\\n\"  4\nstmt: LTU4(reg,mrc1)  \"cmp %0,%1\\njb %a\\n\"   4\nstmt: NEU4(reg,mrc1)  \"cmp %0,%1\\njne %a\\n\"  4\ncmpf: memf  \" %0\"\ncmpf: reg   \"p\"\nstmt: EQF8(cmpf,reg)  \"fcomp%0\\nfstsw ax\\nsahf\\nje %a\\n\"\nstmt: GEF8(cmpf,reg)  \"fcomp%0\\nfstsw ax\\nsahf\\njbe %a\\n\"\nstmt: GTF8(cmpf,reg)  \"fcomp%0\\nfstsw ax\\nsahf\\njb %a\\n\"\nstmt: LEF8(cmpf,reg)  \"fcomp%0\\nfstsw ax\\nsahf\\njae %a\\n\"\nstmt: LTF8(cmpf,reg)  \"fcomp%0\\nfstsw ax\\nsahf\\nja %a\\n\"\nstmt: NEF8(cmpf,reg)  \"fcomp%0\\nfstsw ax\\nsahf\\njne %a\\n\"\n\nstmt: EQF4(cmpf,reg)  \"fcomp%0\\nfstsw ax\\nsahf\\nje %a\\n\"\nstmt: GEF4(cmpf,reg)  \"fcomp%0\\nfstsw ax\\nsahf\\njbe %a\\n\"\nstmt: GTF4(cmpf,reg)  \"fcomp%0\\nfstsw ax\\nsahf\\njb %a\\n\"\nstmt: LEF4(cmpf,reg)  \"fcomp%0\\nfstsw ax\\nsahf\\njae %a\\n\"\nstmt: LTF4(cmpf,reg)  \"fcomp%0\\nfstsw ax\\nsahf\\nja %a\\n\"\nstmt: NEF4(cmpf,reg)  \"fcomp%0\\nfstsw ax\\nsahf\\njne %a\\n\"\nreg:  CALLI4(addrj)  \"call %0\\nadd esp,%a\\n\"\nreg:  CALLU4(addrj)  \"call %0\\nadd esp,%a\\n\"\nreg:  CALLP4(addrj)  \"call %0\\nadd esp,%a\\n\"\nstmt: CALLV(addrj)   \"call %0\\nadd esp,%a\\n\"\nreg: CALLF4(addrj)  \"call %0\\nadd esp,%a\\n\"\nreg: CALLF8(addrj)  \"call %0\\nadd esp,%a\\n\"\nstmt: CALLF4(addrj)  \"call %0\\nadd esp,%a\\nfstp\\n\"\nstmt: CALLF8(addrj)  \"call %0\\nadd esp,%a\\nfstp\\n\"\n\nstmt: RETI4(reg)  \"# ret\\n\"\nstmt: RETU4(reg)  \"# ret\\n\"\nstmt: RETP4(reg)  \"# ret\\n\"\nstmt: RETF4(reg)  \"# ret\\n\"\nstmt: RETF8(reg)  \"# ret\\n\"\n%%\nstatic void progbeg(int argc, char *argv[]) {\n        int i;\n\n        {\n                union {\n                        char c;\n                        int i;\n                } u;\n                u.i = 0;\n                u.c = 1;\n                swap = ((int)(u.i == 1)) != IR->little_endian;\n        }\n        parseflags(argc, argv);\n        intreg[EAX] = mkreg(\"eax\", EAX, 1, IREG);\n        intreg[EDX] = mkreg(\"edx\", EDX, 1, IREG);\n        intreg[ECX] = mkreg(\"ecx\", ECX, 1, IREG);\n        intreg[EBX] = mkreg(\"ebx\", EBX, 1, IREG);\n        intreg[ESI] = mkreg(\"esi\", ESI, 1, IREG);\n        intreg[EDI] = mkreg(\"edi\", EDI, 1, IREG);\n\n        shortreg[EAX] = mkreg(\"ax\", EAX, 1, IREG);\n        shortreg[ECX] = mkreg(\"cx\", ECX, 1, IREG);\n        shortreg[EDX] = mkreg(\"dx\", EDX, 1, IREG);\n        shortreg[EBX] = mkreg(\"bx\", EBX, 1, IREG);\n        shortreg[ESI] = mkreg(\"si\", ESI, 1, IREG);\n        shortreg[EDI] = mkreg(\"di\", EDI, 1, IREG);\n\n        charreg[EAX]  = mkreg(\"al\", EAX, 1, IREG);\n        charreg[ECX]  = mkreg(\"cl\", ECX, 1, IREG);\n        charreg[EDX]  = mkreg(\"dl\", EDX, 1, IREG);\n        charreg[EBX]  = mkreg(\"bl\", EBX, 1, IREG);\n        for (i = 0; i < 8; i++)\n                fltreg[i] = mkreg(\"%d\", i, 0, FREG);\n        charregw = mkwildcard(charreg);\n        shortregw = mkwildcard(shortreg);\n        intregw = mkwildcard(intreg);\n        fltregw = mkwildcard(fltreg);\n\n        tmask[IREG] = (1<<EDI) | (1<<ESI) | (1<<EBX)\n                    | (1<<EDX) | (1<<ECX) | (1<<EAX);\n        vmask[IREG] = 0;\n        tmask[FREG] = 0xff;\n        vmask[FREG] = 0;\n        print(\".486\\n\");\n        print(\".model flat\\n\");\n        print(\"extrn __fltused:near\\n\");\n        print(\"extrn __ftol:near\\n\");\n        cseg = 0;\n        quo = mkreg(\"eax\", EAX, 1, IREG);\n        quo->x.regnode->mask |= 1<<EDX;\n        rem = mkreg(\"edx\", EDX, 1, IREG);\n        rem->x.regnode->mask |= 1<<EAX;\n}\nstatic Symbol rmap(int opk) {\n        switch (optype(opk)) {\n        case B: case P:\n                return intregw;\n        case I: case U:\n                if (opsize(opk) == 1)\n                        return charregw;\n                else if (opsize(opk) == 2)\n                        return shortregw;\n                else\n                        return intregw;\n        case F:\n                return fltregw;\n        default:\n                return 0;\n        }\n}\nstatic void segment(int n) {\n        if (n == cseg)\n                return;\n        if (cseg == CODE || cseg == LIT)\n                print(\"_TEXT ends\\n\");\n        else if (cseg == DATA || cseg == BSS)\n                print(\"_DATA ends\\n\");\n        cseg = n;\n        if (cseg == CODE || cseg == LIT)\n                print(\"_TEXT segment\\n\");\n        else if (cseg == DATA || cseg == BSS)\n                print(\"_DATA segment\\n\");\n}\nstatic void progend(void) {\n        segment(0);\n        print(\"end\\n\");\n}\nstatic void target(Node p) {\n        assert(p);\n        switch (specific(p->op)) {\n        case MUL+U:\n                setreg(p, quo);\n                rtarget(p, 0, intreg[EAX]);\n                break;\n        case DIV+I: case DIV+U:\n                setreg(p, quo);\n                rtarget(p, 0, quo);\n                break;\n        case MOD+I: case MOD+U:\n                setreg(p, rem);\n                rtarget(p, 0, quo);\n                break;\n        case ASGN+B:\n                rtarget(p, 0, intreg[EDI]);\n                rtarget(p->kids[1], 0, intreg[ESI]);\n                break;\n        case ARG+B:\n                rtarget(p->kids[0], 0, intreg[ESI]);\n                break;\n        case CVF+I:\n                setreg(p, intreg[EAX]);\n                break;\n        case CALL+I: case CALL+U: case CALL+P: case CALL+V:\n                setreg(p, intreg[EAX]);\n                break;\n        case RET+I: case RET+U: case RET+P:\n                rtarget(p, 0, intreg[EAX]);\n                break;\n        }\n}\n\nstatic void clobber(Node p) {\n        static int nstack = 0;\n\n        assert(p);\n        nstack = ckstack(p, nstack);\n        switch (specific(p->op)) {\n        case RSH+I: case RSH+U: case LSH+I: case LSH+U:\n                if (generic(p->kids[1]->op) != CNST\n                && !(   generic(p->kids[1]->op) == INDIR\n                     && specific(p->kids[1]->kids[0]->op) == VREG+P\n                     && p->kids[1]->syms[RX]->u.t.cse\n                     && generic(p->kids[1]->syms[RX]->u.t.cse->op) == CNST\n)) {\n                        spill(1<<ECX, 1, p);\n                }\n                break;\n        case ASGN+B: case ARG+B:\n                spill(1<<ECX | 1<<ESI | 1<<EDI, IREG, p);\n                break;\n        case EQ+F: case LE+F: case GE+F: case LT+F: case GT+F: case NE+F:\n                spill(1<<EAX, IREG, p);\n                break;\n        case CALL+F:\n                spill(1<<EDX | 1<<EAX | 1<<ECX, IREG, p);\n                break;\n        case CALL+I: case CALL+U: case CALL+P: case CALL+V:\n                spill(1<<EDX | 1<<ECX, IREG, p);\n                break;\n        }\n}\n#define isfp(p) (optype((p)->op)==F)\n\nint ckstack(Node p, int n) {\n        int i;\n\n        for (i = 0; i < NELEMS(p->x.kids) && p->x.kids[i]; i++)\n                if (isfp(p->x.kids[i]))\n                        n--;\n        if (isfp(p) && p->count > 0)\n                n++;\n        if (n > 8)\n                error(\"expression too complicated\\n\");\n        debug(fprint(stderr, \"(ckstack(%x)=%d)\\n\", p, n));\n        assert(n >= 0);\n        return n;\n}\nint memop(Node p) {\n        assert(p);\n        assert(generic(p->op) == ASGN);\n        assert(p->kids[0]);\n        assert(p->kids[1]);\n        if (generic(p->kids[1]->kids[0]->op) == INDIR\n        && sametree(p->kids[0], p->kids[1]->kids[0]->kids[0]))\n                return 3;\n        else\n                return LBURG_MAX;\n}\nint sametree(Node p, Node q) {\n        return p == NULL && q == NULL\n        || p && q && p->op == q->op && p->syms[0] == q->syms[0]\n                && sametree(p->kids[0], q->kids[0])\n                && sametree(p->kids[1], q->kids[1]);\n}\nstatic void emit2(Node p) {\n        int op = specific(p->op);\n#define preg(f) ((f)[getregnum(p->x.kids[0])]->x.name)\n\n        if (op == CVI+I && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 1)\n                print(\"movsx %s,%s\\n\", p->syms[RX]->x.name\n, preg(charreg));\n        else if (op == CVI+U && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 1)\n                print(\"movsx %s,%s\\n\", p->syms[RX]->x.name\n, preg(charreg));\n        else if (op == CVI+I && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 2)\n                print(\"movsx %s,%s\\n\", p->syms[RX]->x.name\n, preg(shortreg));\n        else if (op == CVI+U && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 2)\n                print(\"movsx %s,%s\\n\", p->syms[RX]->x.name\n, preg(shortreg));\n\n        else if (op == CVU+I && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 1)\n                print(\"movzx %s,%s\\n\", p->syms[RX]->x.name\n, preg(charreg));\n        else if (op == CVU+U && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 1)\n                print(\"movzx %s,%s\\n\", p->syms[RX]->x.name\n, preg(charreg));\n        else if (op == CVU+I && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 2)\n                print(\"movzx %s,%s\\n\", p->syms[RX]->x.name\n, preg(shortreg));\n        else if (op == CVU+U && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 2)\n                print(\"movzx %s,%s\\n\", p->syms[RX]->x.name\n, preg(shortreg));\n        else if (generic(op) == CVI || generic(op) == CVU || generic(op) == LOAD) {\n                char *dst = intreg[getregnum(p)]->x.name;\n                char *src = preg(intreg);\n                assert(opsize(p->op) <= opsize(p->x.kids[0]->op));\n                if (dst != src)\n                        print(\"mov %s,%s\\n\", dst, src);\n        }\n}\n\nstatic void doarg(Node p) {\n        assert(p && p->syms[0]);\n        mkactual(4, p->syms[0]->u.c.v.i);\n}\nstatic void blkfetch(int k, int off, int reg, int tmp) {}\nstatic void blkstore(int k, int off, int reg, int tmp) {}\nstatic void blkloop(int dreg, int doff, int sreg, int soff,\n        int size, int tmps[]) {}\nstatic void local(Symbol p) {\n        if (isfloat(p->type))\n                p->sclass = AUTO;\n        if (askregvar(p, (*IR->x.rmap)(ttob(p->type))) == 0)\n                mkauto(p);\n}\nstatic void function(Symbol f, Symbol caller[], Symbol callee[], int n) {\n        int i;\n\n        print(\"%s:\\n\", f->x.name);\n        print(\"push ebx\\n\");\n        print(\"push esi\\n\");\n        print(\"push edi\\n\");\n        print(\"push ebp\\n\");\n        print(\"mov ebp,esp\\n\");\n        usedmask[0] = usedmask[1] = 0;\n        freemask[0] = freemask[1] = ~(unsigned)0;\n        offset = 16 + 4;\n        for (i = 0; callee[i]; i++) {\n                Symbol p = callee[i];\n                Symbol q = caller[i];\n                assert(q);\n                p->x.offset = q->x.offset = offset;\n                p->x.name = q->x.name = stringf(\"%d\", p->x.offset);\n                p->sclass = q->sclass = AUTO;\n                offset += roundup(q->type->size, 4);\n        }\n        assert(caller[i] == 0);\n        offset = maxoffset = 0;\n        gencode(caller, callee);\n        framesize = roundup(maxoffset, 4);\n        if (framesize > 0)\n                print(\"sub esp,%d\\n\", framesize);\n        emitcode();\n        print(\"mov esp,ebp\\n\");\n        print(\"pop ebp\\n\");\n        print(\"pop edi\\n\");\n        print(\"pop esi\\n\");\n        print(\"pop ebx\\n\");\n        print(\"ret\\n\");\n}\nstatic void defsymbol(Symbol p) {\n        if (p->scope >= LOCAL && p->sclass == STATIC)\n                p->x.name = stringf(\"L%d\", genlabel(1));\n        else if (p->generated)\n                p->x.name = stringf(\"L%s\", p->name);\n        else if (p->scope == GLOBAL || p->sclass == EXTERN)\n                p->x.name = stringf(\"_%s\", p->name);\n        else if (p->scope == CONSTANTS\n        && (isint(p->type) || isptr(p->type))\n        && p->name[0] == '0' && p->name[1] == 'x')\n                p->x.name = stringf(\"0%sH\", &p->name[2]);\n        else\n                p->x.name = p->name;\n}\nstatic void address(Symbol q, Symbol p, long n) {\n        if (p->scope == GLOBAL\n        || p->sclass == STATIC || p->sclass == EXTERN)\n                q->x.name = stringf(\"%s%s%D\",\n                        p->x.name, n >= 0 ? \"+\" : \"\", n);\n        else {\n                assert(n <= INT_MAX && n >= INT_MIN);\n                q->x.offset = p->x.offset + n;\n                q->x.name = stringd(q->x.offset);\n        }\n}\nstatic void defconst(int suffix, int size, Value v) {\n        if (suffix == I && size == 1)\n                print(\"db %d\\n\",   v.u);\n        else if (suffix == I && size == 2)\n                print(\"dw %d\\n\",   v.i);\n        else if (suffix == I && size == 4)\n                print(\"dd %d\\n\",   v.i);\n        else if (suffix == U && size == 1)\n                print(\"db 0%xH\\n\", v.u);\n        else if (suffix == U && size == 2)\n                print(\"dw 0%xH\\n\", v.u);\n        else if (suffix == U && size == 4)\n                print(\"dd 0%xH\\n\", v.u);\n        else if (suffix == P && size == 4)\n                print(\"dd 0%xH\\n\", v.p);\n        else if (suffix == F && size == 4) {\n                float f = v.d;\n                print(\"dd 0%xH\\n\", *(unsigned *)&f);\n        }\n        else if (suffix == F && size == 8) {\n                double d = v.d;\n                unsigned *p = (unsigned *)&d;\n                print(\"dd 0%xH\\ndd 0%xH\\n\", p[swap], p[!swap]);\n        }\n        else assert(0);\n}\nstatic void defaddress(Symbol p) {\n        print(\"dd %s\\n\", p->x.name);\n}\nstatic void defstring(int n, char *str) {\n        char *s;\n\n        for (s = str; s < str + n; s++)\n                print(\"db %d\\n\", (*s)&0377);\n}\nstatic void export(Symbol p) {\n        print(\"public %s\\n\", p->x.name);\n}\nstatic void import(Symbol p) {\n        int oldseg = cseg;\n\n        if (p->ref > 0) {\n                segment(0);\n                print(\"extrn %s:near\\n\", p->x.name);\n                segment(oldseg);\n        }\n}\nstatic void global(Symbol p) {\n        print(\"align %d\\n\",\n                p->type->align > 4 ? 4 : p->type->align);\n        print(\"%s label byte\\n\", p->x.name);\n        if (p->u.seg == BSS)\n                print(\"db %d dup (0)\\n\", p->type->size);\n}\nstatic void space(int n) {\n        if (cseg != BSS)\n                print(\"db %d dup (0)\\n\", n);\n}\nInterface x86IR = {\n        1, 1, 0,  /* char */\n        2, 2, 0,  /* short */\n        4, 4, 0,  /* int */\n        4, 4, 0,  /* long */\n        4, 4, 0,  /* long long */\n        4, 4, 1,  /* float */\n        8, 4, 1,  /* double */\n        8, 4, 1,  /* long double */\n        4, 4, 0,  /* T * */\n        0, 4, 0,  /* struct; so that ARGB keeps stack aligned */\n        1,        /* little_endian */\n        0,        /* mulops_calls */\n        0,        /* wants_callb */\n        1,        /* wants_argb */\n        0,        /* left_to_right */\n        0,        /* wants_dag */\n        0,        /* unsigned_char */\n        address,\n        blockbeg,\n        blockend,\n        defaddress,\n        defconst,\n        defstring,\n        defsymbol,\n        emit,\n        export,\n        function,\n        gen,\n        global,\n        import,\n        local,\n        progbeg,\n        progend,\n        segment,\n        space,\n        0, 0, 0, 0, 0, 0, 0,\n        {1, rmap,\n            blkfetch, blkstore, blkloop,\n            _label,\n            _rule,\n            _nts,\n            _kids,\n            _string,\n            _templates,\n            _isinstruction,\n            _ntname,\n            emit2,\n            doarg,\n            target,\n            clobber,\n}\n};\nstatic char rcsid[] = \"$Id: x86.md 145 2001-10-17 21:53:10Z timo $\";\n"
  },
  {
    "path": "lcc/src/x86linux.md",
    "content": "%{\n/* x86/linux lburg spec. Derived from x86.md by\nMarcos Ramirez <marcos@inf.utfsm.cl>\nHorst von Brand <vonbrand@sleipnir.valparaiso.cl>\nJacob Navia <jacob@jacob.remcomp.fr>\n*/\nenum { EAX=0, ECX=1, EDX=2, EBX=3, ESI=6, EDI=7 };\n#include \"c.h\"\n#define NODEPTR_TYPE Node\n#define OP_LABEL(p) ((p)->op)\n#define LEFT_CHILD(p) ((p)->kids[0])\n#define RIGHT_CHILD(p) ((p)->kids[1])\n#define STATE_LABEL(p) ((p)->x.state)\nextern int ckstack(Node, int);\nextern int memop(Node);\nextern int sametree(Node, Node);\nstatic Symbol charreg[32], shortreg[32], intreg[32];\nstatic Symbol fltreg[32];\n\nstatic Symbol charregw, shortregw, intregw, fltregw;\n\nstatic int cseg;\n\nstatic Symbol quo, rem;\n\nextern char *stabprefix;\nextern void stabblock(int, int, Symbol*);\nextern void stabend(Coordinate *, Symbol, Coordinate **, Symbol *, Symbol *);\nextern void stabfend(Symbol, int);\nextern void stabinit(char *, int, char *[]);\nextern void stabline(Coordinate *);\nextern void stabsym(Symbol);\nextern void stabtype(Symbol);\n\nstatic int pflag = 0;\nstatic char rcsid[] = \"$Id: x86linux.md 145 2001-10-17 21:53:10Z timo $\";\n\n#define hasargs(p) (p->syms[0] && p->syms[0]->u.c.v.i > 0 ? 0 : LBURG_MAX)\n%}\n%start stmt\n%term CNSTF4=4113\n%term CNSTF8=8209\n%term CNSTF16=16401\n%term CNSTI1=1045\n%term CNSTI2=2069\n%term CNSTI4=4117\n%term CNSTI8=8213\n%term CNSTP4=4119\n%term CNSTP8=8215\n%term CNSTU1=1046\n%term CNSTU2=2070\n%term CNSTU4=4118\n%term CNSTU8=8214\n \n%term ARGB=41\n%term ARGF4=4129\n%term ARGF8=8225\n%term ARGF16=16417\n%term ARGI4=4133\n%term ARGI8=8229\n%term ARGP4=4135\n%term ARGP8=8231\n%term ARGU4=4134\n%term ARGU8=8230\n\n%term ASGNB=57\n%term ASGNF4=4145\n%term ASGNF8=8241\n%term ASGNF16=16433\n%term ASGNI1=1077\n%term ASGNI2=2101\n%term ASGNI4=4149\n%term ASGNI8=8245\n%term ASGNP4=4151\n%term ASGNP8=8247\n%term ASGNU1=1078\n%term ASGNU2=2102\n%term ASGNU4=4150\n%term ASGNU8=8246\n\n%term INDIRB=73\n%term INDIRF4=4161\n%term INDIRF8=8257\n%term INDIRF16=16449\n%term INDIRI1=1093\n%term INDIRI2=2117\n%term INDIRI4=4165\n%term INDIRI8=8261\n%term INDIRP4=4167\n%term INDIRP8=8263\n%term INDIRU1=1094\n%term INDIRU2=2118\n%term INDIRU4=4166\n%term INDIRU8=8262\n\n%term CVFF4=4209\n%term CVFF8=8305\n%term CVFF16=16497\n%term CVFI4=4213\n%term CVFI8=8309\n\n%term CVIF4=4225\n%term CVIF8=8321\n%term CVIF16=16513\n%term CVII1=1157\n%term CVII2=2181\n%term CVII4=4229\n%term CVII8=8325\n%term CVIU1=1158\n%term CVIU2=2182\n%term CVIU4=4230\n%term CVIU8=8326\n\n%term CVPP4=4247\n%term CVPP8=8343\n%term CVPP16=16535\n%term CVPU4=4246\n%term CVPU8=8342\n\n%term CVUI1=1205\n%term CVUI2=2229\n%term CVUI4=4277\n%term CVUI8=8373\n%term CVUP4=4279\n%term CVUP8=8375\n%term CVUP16=16567\n%term CVUU1=1206\n%term CVUU2=2230\n%term CVUU4=4278\n%term CVUU8=8374\n\n%term NEGF4=4289\n%term NEGF8=8385\n%term NEGF16=16577\n%term NEGI4=4293\n%term NEGI8=8389\n\n%term CALLB=217\n%term CALLF4=4305\n%term CALLF8=8401\n%term CALLF16=16593\n%term CALLI4=4309\n%term CALLI8=8405\n%term CALLP4=4311\n%term CALLP8=8407\n%term CALLU4=4310\n%term CALLU8=8406\n%term CALLV=216\n\n%term RETF4=4337\n%term RETF8=8433\n%term RETF16=16625\n%term RETI4=4341\n%term RETI8=8437\n%term RETP4=4343\n%term RETP8=8439\n%term RETU4=4342\n%term RETU8=8438\n%term RETV=248\n\n%term ADDRGP4=4359\n%term ADDRGP8=8455\n\n%term ADDRFP4=4375\n%term ADDRFP8=8471\n\n%term ADDRLP4=4391\n%term ADDRLP8=8487\n\n%term ADDF4=4401\n%term ADDF8=8497\n%term ADDF16=16689\n%term ADDI4=4405\n%term ADDI8=8501\n%term ADDP4=4407\n%term ADDP8=8503\n%term ADDU4=4406\n%term ADDU8=8502\n\n%term SUBF4=4417\n%term SUBF8=8513\n%term SUBF16=16705\n%term SUBI4=4421\n%term SUBI8=8517\n%term SUBP4=4423\n%term SUBP8=8519\n%term SUBU4=4422\n%term SUBU8=8518\n\n%term LSHI4=4437\n%term LSHI8=8533\n%term LSHU4=4438\n%term LSHU8=8534\n\n%term MODI4=4453\n%term MODI8=8549\n%term MODU4=4454\n%term MODU8=8550\n\n%term RSHI4=4469\n%term RSHI8=8565\n%term RSHU4=4470\n%term RSHU8=8566\n\n%term BANDI4=4485\n%term BANDI8=8581\n%term BANDU4=4486\n%term BANDU8=8582\n\n%term BCOMI4=4501\n%term BCOMI8=8597\n%term BCOMU4=4502\n%term BCOMU8=8598\n\n%term BORI4=4517\n%term BORI8=8613\n%term BORU4=4518\n%term BORU8=8614\n\n%term BXORI4=4533\n%term BXORI8=8629\n%term BXORU4=4534\n%term BXORU8=8630\n\n%term DIVF4=4545\n%term DIVF8=8641\n%term DIVF16=16833\n%term DIVI4=4549\n%term DIVI8=8645\n%term DIVU4=4550\n%term DIVU8=8646\n\n%term MULF4=4561\n%term MULF8=8657\n%term MULF16=16849\n%term MULI4=4565\n%term MULI8=8661\n%term MULU4=4566\n%term MULU8=8662\n\n%term EQF4=4577\n%term EQF8=8673\n%term EQF16=16865\n%term EQI4=4581\n%term EQI8=8677\n%term EQU4=4582\n%term EQU8=8678\n\n%term GEF4=4593\n%term GEF8=8689\n%term GEI4=4597\n%term GEI8=8693\n%term GEI16=16885\n%term GEU4=4598\n%term GEU8=8694\n\n%term GTF4=4609\n%term GTF8=8705\n%term GTF16=16897\n%term GTI4=4613\n%term GTI8=8709\n%term GTU4=4614\n%term GTU8=8710\n\n%term LEF4=4625\n%term LEF8=8721\n%term LEF16=16913\n%term LEI4=4629\n%term LEI8=8725\n%term LEU4=4630\n%term LEU8=8726\n\n%term LTF4=4641\n%term LTF8=8737\n%term LTF16=16929\n%term LTI4=4645\n%term LTI8=8741\n%term LTU4=4646\n%term LTU8=8742\n\n%term NEF4=4657\n%term NEF8=8753\n%term NEF16=16945\n%term NEI4=4661\n%term NEI8=8757\n%term NEU4=4662\n%term NEU8=8758\n\n%term JUMPV=584\n\n%term LABELV=600\n\n%term LOADB=233\n%term LOADF4=4321\n%term LOADF8=8417\n%term LOADF16=16609\n%term LOADI1=1253\n%term LOADI2=2277\n%term LOADI4=4325\n%term LOADI8=8421\n%term LOADP4=4327\n%term LOADP8=8423\n%term LOADU1=1254\n%term LOADU2=2278\n%term LOADU4=4326\n%term LOADU8=8422\n\n%term VREGP=711\n%%\nreg:  INDIRI1(VREGP)     \"# read register\\n\"\nreg:  INDIRU1(VREGP)     \"# read register\\n\"\n\nreg:  INDIRI2(VREGP)     \"# read register\\n\"\nreg:  INDIRU2(VREGP)     \"# read register\\n\"\n\nreg:  INDIRI4(VREGP)     \"# read register\\n\"\nreg:  INDIRP4(VREGP)     \"# read register\\n\"\nreg:  INDIRU4(VREGP)     \"# read register\\n\"\n\nreg:  INDIRI8(VREGP)     \"# read register\\n\"\nreg:  INDIRP8(VREGP)     \"# read register\\n\"\nreg:  INDIRU8(VREGP)     \"# read register\\n\"\n\nfreg:  INDIRF4(VREGP)     \"# read register\\n\"\nfreg:  INDIRF8(VREGP)     \"# read register\\n\"\n\nstmt: ASGNI1(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNU1(VREGP,reg)  \"# write register\\n\"\n\nstmt: ASGNI2(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNU2(VREGP,reg)  \"# write register\\n\"\n\nstmt: ASGNF4(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNI4(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNP4(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNU4(VREGP,reg)  \"# write register\\n\"\n\nstmt: ASGNF8(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNI8(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNP8(VREGP,reg)  \"# write register\\n\"\nstmt: ASGNU8(VREGP,reg)  \"# write register\\n\"\n\ncnst: CNSTI1    \"%a\"\ncnst: CNSTU1    \"%a\"\n\ncnst: CNSTI2    \"%a\"\ncnst: CNSTU2    \"%a\"\n\ncnst: CNSTI4    \"%a\"\ncnst: CNSTU4    \"%a\"\ncnst: CNSTP4    \"%a\"\n\ncnst: CNSTI8    \"%a\"\ncnst: CNSTU8    \"%a\"\ncnst: CNSTP8    \"%a\"\n\ncon: cnst       \"$%0\"\n\nstmt: reg       \"\"\nstmt: freg      \"\"\n\nacon: ADDRGP4  \"%a\"\nacon: ADDRGP8  \"%a\"\nacon: cnst       \"%0\"\n\nbaseaddr: ADDRGP4       \"%a\"\nbase: reg               \"(%0)\"\nbase: ADDI4(reg,acon)   \"%1(%0)\"\nbase: ADDP4(reg,acon)   \"%1(%0)\"\nbase: ADDU4(reg,acon)   \"%1(%0)\"\nbase: ADDRFP4           \"%a(%%ebp)\"\nbase: ADDRLP4           \"%a(%%ebp)\"\n\nindex: reg              \"%0\"\nindex: LSHI4(reg,con1)  \"%0,2\"\nindex: LSHI4(reg,con2)  \"%0,4\"\nindex: LSHI4(reg,con3)  \"%0,8\"\nindex: LSHU4(reg,con1)  \"%0,2\"\nindex: LSHU4(reg,con2)  \"%0,4\"\nindex: LSHU4(reg,con3)  \"%0,8\"\n\ncon0:  CNSTI4  \"1\"  range(a, 0, 0)\ncon0:  CNSTU4  \"1\"  range(a, 0, 0)\ncon1:  CNSTI4  \"1\"  range(a, 1, 1)\ncon1:  CNSTU4  \"1\"  range(a, 1, 1)\ncon2:  CNSTI4  \"2\"  range(a, 2, 2)\ncon2:  CNSTU4  \"2\"  range(a, 2, 2)\ncon3:  CNSTI4  \"3\"  range(a, 3, 3)\ncon3:  CNSTU4  \"3\"  range(a, 3, 3)\n\naddr: base                      \"%0\"\naddr: baseaddr                  \"%0\"\naddr: ADDI4(index,baseaddr)     \"%1(,%0)\"\naddr: ADDP4(index,baseaddr)     \"%1(,%0)\"\naddr: ADDU4(index,baseaddr)     \"%1(,%0)\"\n\naddr: ADDI4(reg,baseaddr)       \"%1(%0)\"\naddr: ADDP4(reg,baseaddr)       \"%1(%0)\"\naddr: ADDU4(reg,baseaddr)       \"%1(%0)\"\n\naddr: ADDI4(index,reg)          \"(%1,%0)\"\naddr: ADDP4(index,reg)          \"(%1,%0)\"\naddr: ADDU4(index,reg)          \"(%1,%0)\"\n\naddr: index  \"(,%0)\"\n\nmem1: INDIRI1(addr)  \"%0\"\nmem1: INDIRU1(addr)  \"%0\"\nmem2: INDIRI2(addr)  \"%0\"\nmem2: INDIRU2(addr)  \"%0\"\nmem4: INDIRI4(addr)  \"%0\"\nmem4: INDIRU4(addr)  \"%0\"\nmem4: INDIRP4(addr)  \"%0\"\n\nrc: reg         \"%0\"\nrc: con         \"%0\"\n\nmr: reg         \"%0\"\nmr: mem4        \"%0\"\n\nmr1: reg        \"%0\"\nmr1: mem1       \"%0\"\n\nmr2: reg        \"%0\"\nmr2: mem2       \"%0\"\n\nmrc: mem4       \"%0\"  1\nmrc: mem1       \"%0\"  1\nmrc: mem2       \"%0\"  1\nmrc: rc         \"%0\"\n\nreg: addr       \"leal %0,%c\\n\"  1\nreg: mr         \"movl %0,%c\\n\"  1\nreg: mr1        \"movb %0,%c\\n\"  1\nreg: mr2        \"movw %0,%c\\n\"  1\nreg: con        \"movl %0,%c\\n\"  1\n\nreg: LOADI1(reg)        \"# move\\n\"  1\nreg: LOADI2(reg)        \"# move\\n\"  1\nreg: LOADI4(reg)        \"# move\\n\"  move(a)\nreg: LOADU1(reg)        \"# move\\n\"  1\nreg: LOADU2(reg)        \"# move\\n\"  1\nreg: LOADU4(reg)        \"# move\\n\"  move(a)\nreg: LOADP4(reg)        \"# move\\n\"  move(a)\nreg: ADDI4(reg,mrc)     \"?movl %0,%c\\naddl %1,%c\\n\"  1\nreg: ADDP4(reg,mrc)     \"?movl %0,%c\\naddl %1,%c\\n\"  1\nreg: ADDU4(reg,mrc)     \"?movl %0,%c\\naddl %1,%c\\n\"  1\nreg: SUBI4(reg,mrc)     \"?movl %0,%c\\nsubl %1,%c\\n\"  1\nreg: SUBP4(reg,mrc)     \"?movl %0,%c\\nsubl %1,%c\\n\"  1\nreg: SUBU4(reg,mrc)     \"?movl %0,%c\\nsubl %1,%c\\n\"  1\nreg: BANDI4(reg,mrc)    \"?movl %0,%c\\nandl %1,%c\\n\"  1\nreg: BORI4(reg,mrc)     \"?movl %0,%c\\norl %1,%c\\n\"   1\nreg: BXORI4(reg,mrc)    \"?movl %0,%c\\nxorl %1,%c\\n\"  1\nreg: BANDU4(reg,mrc)    \"?movl %0,%c\\nandl %1,%c\\n\"  1\nreg: BORU4(reg,mrc)     \"?movl %0,%c\\norl %1,%c\\n\"   1\nreg: BXORU4(reg,mrc)    \"?movl %0,%c\\nxorl %1,%c\\n\"  1\n\nstmt: ASGNI4(addr,ADDI4(mem4,con1))     \"incl %1\\n\"  memop(a)\nstmt: ASGNI4(addr,ADDU4(mem4,con1))     \"incl %1\\n\"  memop(a)\nstmt: ASGNP4(addr,ADDP4(mem4,con1))     \"incl %1\\n\"  memop(a)\nstmt: ASGNI4(addr,SUBI4(mem4,con1))     \"decl %1\\n\"  memop(a)\nstmt: ASGNI4(addr,SUBU4(mem4,con1))     \"decl %1\\n\"  memop(a)\nstmt: ASGNP4(addr,SUBP4(mem4,con1))     \"decl %1\\n\"  memop(a)\nstmt: ASGNI4(addr,ADDI4(mem4,rc))       \"addl %2,%1\\n\"  memop(a)\nstmt: ASGNI4(addr,SUBI4(mem4,rc))       \"sub %2,%1\\n\"  memop(a)\nstmt: ASGNU4(addr,ADDU4(mem4,rc))       \"add %2,%1\\n\"  memop(a)\nstmt: ASGNU4(addr,SUBU4(mem4,rc))       \"sub %2,%1\\n\"  memop(a)\n\nstmt: ASGNI4(addr,BANDI4(mem4,rc))      \"andl %2,%1\\n\"  memop(a)\nstmt: ASGNI4(addr,BORI4(mem4,rc))       \"orl %2,%1\\n\"   memop(a)\nstmt: ASGNI4(addr,BXORI4(mem4,rc))      \"xorl %2,%1\\n\"  memop(a)\nstmt: ASGNU4(addr,BANDU4(mem4,rc))      \"andl %2,%1\\n\"  memop(a)\nstmt: ASGNU4(addr,BORU4(mem4,rc))       \"orl %2,%1\\n\"   memop(a)\nstmt: ASGNU4(addr,BXORU4(mem4,rc))      \"xorl %2,%1\\n\"  memop(a)\nreg: BCOMI4(reg)        \"?movl %0,%c\\nnotl %c\\n\"  2\nreg: BCOMU4(reg)        \"?movl %0,%c\\nnotl %c\\n\"  2\nreg: NEGI4(reg)         \"?movl %0,%c\\nnegl %c\\n\"  2\n\nstmt: ASGNI4(addr,BCOMI4(mem4)) \"notl %1\\n\"  memop(a)\nstmt: ASGNU4(addr,BCOMU4(mem4)) \"notl %1\\n\"  memop(a)\nstmt: ASGNI4(addr,NEGI4(mem4))  \"negl %1\\n\"  memop(a)\nreg: LSHI4(reg,rc5)     \"?movl %0,%c\\nsall %1,%c\\n\"  2\nreg: LSHU4(reg,rc5)     \"?movl %0,%c\\nshll %1,%c\\n\"  2\nreg: RSHI4(reg,rc5)     \"?movl %0,%c\\nsarl %1,%c\\n\"  2\nreg: RSHU4(reg,rc5)     \"?movl %0,%c\\nshrl %1,%c\\n\"  2\n\nstmt: ASGNI4(addr,LSHI4(mem4,rc5))      \"sall %2,%1\\n\"  memop(a)\nstmt: ASGNI4(addr,LSHU4(mem4,rc5))      \"shll %2,%1\\n\"  memop(a)\nstmt: ASGNI4(addr,RSHI4(mem4,rc5))      \"sarl %2,%1\\n\"  memop(a)\nstmt: ASGNI4(addr,RSHU4(mem4,rc5))      \"shrl %2,%1\\n\"  memop(a)\n\nrc5: CNSTI4     \"$%a\"  range(a, 0, 31)\nrc5: reg        \"%%cl\"\nreg: MULI4(reg,mrc)     \"?movl %0,%c\\nimull %1,%c\\n\"  14\nreg: MULI4(con,mr)      \"imul %0,%1,%c\\n\"  13\nreg: MULU4(reg,mr)      \"mull %1\\n\"  13\nreg: DIVU4(reg,reg)     \"xorl %%edx,%%edx\\ndivl %1\\n\"\nreg: MODU4(reg,reg)     \"xorl %%edx,%%edx\\ndivl %1\\n\"\nreg: DIVI4(reg,reg)     \"cdq\\nidivl %1\\n\"\nreg: MODI4(reg,reg)     \"cdq\\nidivl %1\\n\"\nreg: CVPU4(reg)         \"movl %0,%c\\n\"  move(a)\nreg: CVUP4(reg)         \"movl %0,%c\\n\"  move(a)\nreg: CVII4(INDIRI1(addr))       \"movsbl %0,%c\\n\"  3\nreg: CVII4(INDIRI2(addr))       \"movswl %0,%c\\n\"  3\nreg: CVUU4(INDIRU1(addr))       \"movzbl %0,%c\\n\"  3\nreg: CVUU4(INDIRU2(addr))       \"movzwl %0,%c\\n\"  3\nreg: CVII4(reg) \"# extend\\n\"  3\nreg: CVIU4(reg) \"# extend\\n\"  3\nreg: CVUI4(reg) \"# extend\\n\"  3\nreg: CVUU4(reg) \"# extend\\n\"  3\n\nreg: CVII1(reg) \"# truncate\\n\"  1\nreg: CVII2(reg) \"# truncate\\n\"  1\nreg: CVUU1(reg) \"# truncate\\n\"  1\nreg: CVUU2(reg) \"# truncate\\n\"  1\n\nmrca: mem4      \"%0\"\nmrca: rc        \"%0\"\nmrca: ADDRGP4   \"$%a\"\nmrca: ADDRGP8   \"$%a\"\n\nstmt: ASGNI1(addr,rc)           \"movb %1,%0\\n\"   1\nstmt: ASGNI2(addr,rc)           \"movw %1,%0\\n\"   1\nstmt: ASGNI4(addr,rc)           \"movl %1,%0\\n\"   1\nstmt: ASGNU1(addr,rc)           \"movb %1,%0\\n\"   1\nstmt: ASGNU2(addr,rc)           \"movw %1,%0\\n\"   1\nstmt: ASGNU4(addr,rc)           \"movl %1,%0\\n\"   1\nstmt: ASGNP4(addr,rc)           \"movl %1,%0\\n\"   1\nstmt: ARGI4(mrca)               \"pushl %0\\n\"  1\nstmt: ARGU4(mrca)               \"pushl %0\\n\"  1\nstmt: ARGP4(mrca)               \"pushl %0\\n\"  1\nstmt: ASGNB(reg,INDIRB(reg))    \"movl $%a,%%ecx\\nrep\\nmovsb\\n\"\nstmt: ARGB(INDIRB(reg))         \"subl $%a,%%esp\\nmovl %%esp,%%edi\\nmovl $%a,%%ecx\\nrep\\nmovsb\\n\"\n\nmemf: INDIRF8(addr)         \"l %0\"\nmemf: INDIRF4(addr)         \"s %0\"\nmemf: CVFF8(INDIRF4(addr))  \"s %0\"\nmemf: CVFF4(INDIRF8(addr))  \"l %0\"\n\nfreg: memf      \"fld%0\\n\"  3\n\nstmt: ASGNF8(addr,freg)         \"fstpl %0\\n\"  7\nstmt: ASGNF4(addr,freg)         \"fstps %0\\n\"  7\nstmt: ASGNF4(addr,CVFF4(freg))  \"fstps %0\\n\"  7\n\nstmt: ARGF8(freg)       \"subl $8,%%esp\\nfstpl (%%esp)\\n\"\nstmt: ARGF4(freg)       \"subl $4,%%esp\\nfstps (%%esp)\\n\"\nfreg: NEGF8(freg)       \"fchs\\n\"\nfreg: NEGF4(freg)       \"fchs\\n\"\n\nflt: memf       \"%0\"\nflt: freg       \"p %%st(1),%%st\"\n\nfreg: ADDF4(freg,flt)   \"fadd%1\\n\"\nfreg: ADDF8(freg,flt)   \"fadd%1\\n\"\n\nfreg: DIVF4(freg,flt)   \"fdiv%1\\n\"\nfreg: DIVF8(freg,flt)   \"fdiv%1\\n\"\n\nfreg: MULF4(freg,flt)   \"fmul%1\\n\"\nfreg: MULF8(freg,flt)   \"fmul%1\\n\"\n\nfreg: SUBF4(freg,flt)   \"fsub%1\\n\"\nfreg: SUBF8(freg,flt)   \"fsub%1\\n\"\n\nfreg: CVFF8(freg)  \"# CVFF8\\n\"\nfreg: CVFF4(freg)  \"sub $4,%%esp\\nfstps (%%esp)\\nflds (%%esp)\\naddl $4,%%esp\\n\"  12\n\nstmt: ASGNI4(addr,CVFI4(freg))  \"fistpl %0\\n\" 29\nreg: CVFI4(freg)  \"subl $4,%%esp\\nfistpl 0(%%esp)\\npopl %c\\n\" 31\n\nfreg: CVIF8(INDIRI4(addr))      \"fildl %0\\n\"  10\nfreg: CVIF8(reg)  \"pushl %0\\nfildl (%%esp)\\naddl $4,%%esp\\n\"  12\n\nfreg: CVIF4(INDIRI4(addr))      \"fildl %0\\n\"  10\nfreg: CVIF4(reg)  \"pushl %0\\nfildl (%%esp)\\naddl $4,%%esp\\n\"  12\n\naddrj: ADDRGP4  \"%a\"\naddrj: reg      \"*%0\"  2\naddrj: mem4     \"*%0\"  2\n\nstmt: LABELV         \"%a:\\n\"\nstmt: JUMPV(addrj)   \"jmp %0\\n\"  3\nstmt: EQI4(mem4,rc)  \"cmpl %1,%0\\nje %a\\n\"   5\nstmt: GEI4(mem4,rc)  \"cmpl %1,%0\\njge %a\\n\"  5\nstmt: GTI4(mem4,rc)  \"cmpl %1,%0\\njg %a\\n\"   5\nstmt: LEI4(mem4,rc)  \"cmpl %1,%0\\njle %a\\n\"  5\nstmt: LTI4(mem4,rc)  \"cmpl %1,%0\\njl %a\\n\"   5\nstmt: NEI4(mem4,rc)  \"cmpl %1,%0\\njne %a\\n\"  5\nstmt: GEU4(mem4,rc)  \"cmpl %1,%0\\njae %a\\n\"  5\nstmt: GTU4(mem4,rc)  \"cmpl %1,%0\\nja  %a\\n\"  5\nstmt: LEU4(mem4,rc)  \"cmpl %1,%0\\njbe %a\\n\"  5\nstmt: LTU4(mem4,rc)  \"cmpl %1,%0\\njb  %a\\n\"  5\nstmt: EQI4(reg,mrc)  \"cmpl %1,%0\\nje %a\\n\"   4\nstmt: GEI4(reg,mrc)  \"cmpl %1,%0\\njge %a\\n\"  4\nstmt: GTI4(reg,mrc)  \"cmpl %1,%0\\njg %a\\n\"   4\nstmt: LEI4(reg,mrc)  \"cmpl %1,%0\\njle %a\\n\"  4\nstmt: LTI4(reg,mrc)  \"cmpl %1,%0\\njl %a\\n\"   4\nstmt: NEI4(reg,mrc)  \"cmpl %1,%0\\njne %a\\n\"  4\n\nstmt: EQU4(reg,mrc)  \"cmpl %1,%0\\nje %a\\n\"   4\nstmt: GEU4(reg,mrc)  \"cmpl %1,%0\\njae %a\\n\"  4\nstmt: GTU4(reg,mrc)  \"cmpl %1,%0\\nja %a\\n\"   4\nstmt: LEU4(reg,mrc)  \"cmpl %1,%0\\njbe %a\\n\"  4\nstmt: LTU4(reg,mrc)  \"cmpl %1,%0\\njb %a\\n\"   4\nstmt: NEU4(reg,mrc)  \"cmpl %1,%0\\njne %a\\n\"  4\n\nstmt: EQI4(BANDU4(mr,con),con0) \"testl %1,%0\\nje %a\\n\" 3\nstmt: NEI4(BANDU4(mr,con),con0) \"testl %1,%0\\njne %a\\n\"\n\nstmt: EQI4(BANDU4(CVII2(INDIRI2(addr)),con),con0) \"testw %1,%0\\nje %a\\n\"\nstmt: NEI4(BANDU4(CVII2(INDIRI2(addr)),con),con0) \"testw %1,%0\\njne %a\\n\"\nstmt: EQI4(BANDU4(CVIU2(INDIRI2(addr)),con),con0) \"testw %1,%0\\nje %a\\n\"\nstmt: NEI4(BANDU4(CVIU2(INDIRI2(addr)),con),con0) \"testw %1,%0\\njne %a\\n\"\nstmt: EQI4(BANDU4(CVII1(INDIRI1(addr)),con),con0) \"testb %1,%0\\nje %a\\n\"\n\ncmpf: INDIRF8(addr)             \"l %0\"\ncmpf: INDIRF4(addr)             \"s %0\"\ncmpf: CVFF8(INDIRF4(addr))      \"s %0\"\ncmpf: freg                      \"p\"\n\nstmt: EQF8(cmpf,freg)  \"fcomp%0\\nfstsw %%ax\\nsahf\\nje %a\\n\"\nstmt: GEF8(cmpf,freg)  \"fcomp%0\\nfstsw %%ax\\nsahf\\njbe %a\\n\"\nstmt: GTF8(cmpf,freg)  \"fcomp%0\\nfstsw %%ax\\nsahf\\njb %a\\n\"\nstmt: LEF8(cmpf,freg)  \"fcomp%0\\nfstsw %%ax\\nsahf\\njae %a\\n\"\nstmt: LTF8(cmpf,freg)  \"fcomp%0\\nfstsw %%ax\\nsahf\\nja %a\\n\"\nstmt: NEF8(cmpf,freg)  \"fcomp%0\\nfstsw %%ax\\nsahf\\njne %a\\n\"\n\nstmt: EQF4(cmpf,freg)  \"fcomp%0\\nfstsw %%ax\\nsahf\\nje %a\\n\"\nstmt: GEF4(cmpf,freg)  \"fcomp%0\\nfstsw %%ax\\nsahf\\njbe %a\\n\"\nstmt: GTF4(cmpf,freg)  \"fcomp%0\\nfstsw %%ax\\nsahf\\njb %a\\n\"\nstmt: LEF4(cmpf,freg)  \"fcomp%0\\nfstsw %%ax\\nsahf\\njae %a\\n\"\nstmt: LTF4(cmpf,freg)  \"fcomp%0\\nfstsw %%ax\\nsahf\\nja %a\\n\"\nstmt: NEF4(cmpf,freg)  \"fcomp%0\\nfstsw %%ax\\nsahf\\njne %a\\n\"\n\nfreg: DIVF8(freg,CVIF8(INDIRI4(addr)))          \"fidivl %1\\n\"\nfreg: DIVF8(CVIF8(INDIRI4(addr)),freg)          \"fidivrl %0\\n\"\nfreg: DIVF8(freg,CVIF8(CVII2(INDIRI2(addr))))   \"fidivs %1\\n\"\nfreg: DIVF8(CVIF8(CVII2(INDIRI2(addr))),freg)   \"fidivrs %0\\n\"\nfreg: MULF8(freg,CVIF8(INDIRI4(addr)))          \"fimull %1\\n\"\nfreg: MULF8(freg,CVIF8(CVII2(INDIRI2(addr))))   \"fimuls %1\\n\"\nfreg: SUBF8(freg,CVIF8(INDIRI4(addr)))          \"fisubl %1\\n\"\nfreg: SUBF8(CVIF8(INDIRI4(addr)),freg)          \"fisubrl %0\\n\"\nfreg: SUBF8(freg,CVIF8(CVII2(INDIRI2(addr))))   \"fisubs %1\\n\"\nfreg: SUBF8(CVIF8(CVII2(INDIRI2(addr))),freg)   \"fisubrs %0\\n\"\nfreg: ADDF8(freg,CVIF8(INDIRI4(addr)))          \"fiaddl %1\\n\"\nfreg: ADDF8(freg,CVIF8(CVII2(INDIRI2(addr))))   \"fiadds %1\\n\"\nfreg: ADDF8(freg,CVFF8(INDIRF4(addr)))          \"fdivs %1\\n\"\nfreg: SUBF8(freg,CVFF8(INDIRF4(addr)))          \"fsubs %1\\n\"\nfreg: MULF8(freg,CVFF8(INDIRF4(addr)))          \"fmuls %1\\n\"\nfreg: DIVF8(freg,CVFF8(INDIRF4(addr)))          \"fdivs %1\\n\"\nfreg: LOADF8(memf)                              \"fld%0\\n\"\n\nreg:  CALLI4(addrj)  \"call %0\\naddl $%a,%%esp\\n\"        hasargs(a)\nreg:  CALLU4(addrj)  \"call %0\\naddl $%a,%%esp\\n\"        hasargs(a)\nreg:  CALLP4(addrj)  \"call %0\\naddl $%a,%%esp\\n\"        hasargs(a)\n\nreg:  CALLI4(addrj)  \"call %0\\n\"                        1\nreg:  CALLU4(addrj)  \"call %0\\n\"                        1\nreg:  CALLP4(addrj)  \"call %0\\n\"                        1\n\nstmt: CALLV(addrj)   \"call %0\\naddl $%a,%%esp\\n\"        hasargs(a)\nstmt: CALLV(addrj)   \"call %0\\n\"                        1\n\nfreg: CALLF4(addrj)  \"call %0\\naddl $%a,%%esp\\n\"        hasargs(a)\nfreg: CALLF4(addrj)  \"call %0\\n\"                        1\n\nstmt: CALLF4(addrj)  \"call %0\\naddl $%a,%%esp\\nfstp %%st(0)\\n\"  hasargs(a)\nstmt: CALLF4(addrj)  \"call %0\\nfstp %%st(0)\\n\"                  1\n\nfreg: CALLF8(addrj)  \"call %0\\naddl $%a,%%esp\\n\"        hasargs(a)\nfreg: CALLF8(addrj)  \"call %0\\n\"                        1\n\nstmt: CALLF8(addrj)  \"call %0\\naddl $%a,%%esp\\nfstp %%st(0)\\n\"  hasargs(a)\nstmt: CALLF8(addrj)  \"call %0\\nfstp %%st(0)\\n\"                  1\n\nstmt: RETI4(reg)  \"# ret\\n\"\nstmt: RETU4(reg)  \"# ret\\n\"\nstmt: RETP4(reg)  \"# ret\\n\"\nstmt: RETF4(freg) \"# ret\\n\"\nstmt: RETF8(freg) \"# ret\\n\"\n%%\nstatic void progbeg(int argc, char *argv[]) {\n        int i;\n\n        {\n                union {\n                        char c;\n                        int i;\n                } u;\n                u.i = 0;\n                u.c = 1;\n                swap = ((int)(u.i == 1)) != IR->little_endian;\n        }\n        parseflags(argc, argv);\n        for (i = 0; i < argc; i++)\n                if (strcmp(argv[i], \"-p\") == 0 || strcmp(argv[i], \"-pg\") == 0)\n                        pflag = 1;      \n        intreg[EAX]   = mkreg(\"%%eax\", EAX, 1, IREG);\n        intreg[EDX]   = mkreg(\"%%edx\", EDX, 1, IREG);\n        intreg[ECX]   = mkreg(\"%%ecx\", ECX, 1, IREG);\n        intreg[EBX]   = mkreg(\"%%ebx\", EBX, 1, IREG);\n        intreg[ESI]   = mkreg(\"%%esi\", ESI, 1, IREG);\n        intreg[EDI]   = mkreg(\"%%edi\", EDI, 1, IREG);\n        shortreg[EAX] = mkreg(\"%%ax\", EAX, 1, IREG);\n        shortreg[ECX] = mkreg(\"%%cx\", ECX, 1, IREG);\n        shortreg[EDX] = mkreg(\"%%dx\", EDX, 1, IREG);\n        shortreg[EBX] = mkreg(\"%%bx\", EBX, 1, IREG);\n        shortreg[ESI] = mkreg(\"%%si\", ESI, 1, IREG);\n        shortreg[EDI] = mkreg(\"%%di\", EDI, 1, IREG);\n        charreg[EAX]  = mkreg(\"%%al\", EAX, 1, IREG);\n        charreg[ECX]  = mkreg(\"%%cl\", ECX, 1, IREG);\n        charreg[EDX]  = mkreg(\"%%dl\", EDX, 1, IREG);\n        charreg[EBX]  = mkreg(\"%%bl\", EBX, 1, IREG);\n        for (i = 0; i < 8; i++)\n                fltreg[i] = mkreg(\"%d\", i, 0, FREG);\n        charregw = mkwildcard(charreg);\n        shortregw = mkwildcard(shortreg);\n        intregw = mkwildcard(intreg);\n        fltregw = mkwildcard(fltreg);\n\n        tmask[IREG] = (1<<EDI) | (1<<ESI) | (1<<EBX)\n                    | (1<<EDX) | (1<<ECX) | (1<<EAX);\n        vmask[IREG] = 0;\n        tmask[FREG] = 0xff;\n        vmask[FREG] = 0;\n\n        cseg = 0;\n        quo = mkreg(\"%%eax\", EAX, 1, IREG);\n        quo->x.regnode->mask |= 1<<EDX;\n        rem = mkreg(\"%%edx\", EDX, 1, IREG);\n        rem->x.regnode->mask |= 1<<EAX;\n\n        stabprefix = \".LL\";\n}\n\nstatic Symbol rmap(int opk) {\n        switch (optype(opk)) {\n        case B: case P:\n                return intregw;\n        case I: case U:\n                if (opsize(opk) == 1)\n                        return charregw;\n                else if (opsize(opk) == 2)\n                        return shortregw;\n                else\n                        return intregw;\n        case F:\n                return fltregw;\n        default:\n                return 0;\n        }\n}\n\nstatic Symbol prevg;\n\nstatic void globalend(void) {\n        if (prevg && prevg->type->size > 0)\n                print(\".size %s,%d\\n\", prevg->x.name, prevg->type->size);\n        prevg = NULL;\n}\n\nstatic void progend(void) {\n        globalend();\n        (*IR->segment)(CODE);\n        print(\".ident \\\"LCC: 4.1\\\"\\n\");\n}\n\nstatic void target(Node p) {\n        assert(p);\n        switch (specific(p->op)) {\n        case RSH+I: case RSH+U: case LSH+I: case LSH+U:\n                if (generic(p->kids[1]->op) != CNST\n                && !(   generic(p->kids[1]->op) == INDIR\n                     && specific(p->kids[1]->kids[0]->op) == VREG+P\n                     && p->kids[1]->syms[RX]->u.t.cse\n                     && generic(p->kids[1]->syms[RX]->u.t.cse->op) == CNST)) {\n                        rtarget(p, 1, intreg[ECX]);\n                        setreg(p, intreg[EAX]);\n                }\n                break;\n        case MUL+U:\n                setreg(p, quo);\n                rtarget(p, 0, intreg[EAX]);\n                break;\n        case DIV+I: case DIV+U:\n                setreg(p, quo);\n                rtarget(p, 0, intreg[EAX]);\n                rtarget(p, 1, intreg[ECX]);\n                break;\n        case MOD+I: case MOD+U:\n                setreg(p, rem);\n                rtarget(p, 0, intreg[EAX]);\n                rtarget(p, 1, intreg[ECX]);\n                break;\n        case ASGN+B:\n                rtarget(p, 0, intreg[EDI]);\n                rtarget(p->kids[1], 0, intreg[ESI]);\n                break;\n        case ARG+B:\n                rtarget(p->kids[0], 0, intreg[ESI]);\n                break;\n        case CVF+I:\n                setreg(p, intreg[EAX]);\n                break;\n        case CALL+I: case CALL+U: case CALL+P: case CALL+V:\n                setreg(p, intreg[EAX]);\n                break;\n        case RET+I: case RET+U: case RET+P:\n                rtarget(p, 0, intreg[EAX]);\n                break;\n        }\n}\n\nstatic void clobber(Node p) {\n        static int nstack = 0;\n\n        assert(p);\n        nstack = ckstack(p, nstack);\n        switch (specific(p->op)) {\n        case ASGN+B: case ARG+B:\n                spill(1<<ECX | 1<<ESI | 1<<EDI, IREG, p);\n                break;\n        case EQ+F: case LE+F: case GE+F: case LT+F: case GT+F: case NE+F:\n                spill(1<<EAX, IREG, p);\n                break;\n        case CALL+F:\n                spill(1<<EDX | 1<<EAX | 1<<ECX, IREG, p);\n                break;\n        case CALL+I: case CALL+U: case CALL+P: case CALL+V:\n                spill(1<<EDX | 1<<ECX, IREG, p);\n                break;\n        }\n}\n\nstatic void emit2(Node p) {\n        int op = specific(p->op);\n#define preg(f) ((f)[getregnum(p->x.kids[0])]->x.name)\n\n        if (op == CVI+I && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 1)\n                print(\"movsbl %s,%s\\n\", preg(charreg), p->syms[RX]->x.name);\n        else if (op == CVI+U && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 1)\n                print(\"movsbl %s,%s\\n\", preg(charreg), p->syms[RX]->x.name);\n        else if (op == CVI+I && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 2)\n                print(\"movswl %s,%s\\n\", preg(shortreg), p->syms[RX]->x.name);\n        else if (op == CVI+U && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 2)\n                print(\"movswl %s,%s\\n\", preg(shortreg), p->syms[RX]->x.name);\n        else if (op == CVU+I && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 1)\n                print(\"movzbl %s,%s\\n\", preg(charreg), p->syms[RX]->x.name);\n        else if (op == CVU+U && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 1)\n                print(\"movzbl %s,%s\\n\", preg(charreg), p->syms[RX]->x.name);\n        else if (op == CVU+I && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 2)\n                print(\"movzwl %s,%s\\n\", preg(shortreg), p->syms[RX]->x.name);\n        else if (op == CVU+U && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 2)\n                print(\"movzwl %s,%s\\n\", preg(shortreg), p->syms[RX]->x.name);\n        else if (generic(op) == CVI || generic(op) == CVU || generic(op) == LOAD) {\n                char *dst = intreg[getregnum(p)]->x.name;\n                char *src = preg(intreg);\n                assert(opsize(p->op) <= opsize(p->x.kids[0]->op));\n                if (dst != src)\n                        print(\"movl %s,%s\\n\", src, dst);\n        }       \n}\n\nstatic void function(Symbol f, Symbol caller[], Symbol callee[], int n) {\n        int i;\n        \n        globalend();\n        print(\".align 16\\n\");\n        print(\".type %s,@function\\n\", f->x.name);\n        print(\"%s:\\n\", f->x.name);\n        print(\"pushl %%ebp\\n\");\n        if (pflag) {\n                static int plab;\n                print(\"movl %%esp,%%ebp\\n\");\n                (*IR->segment)(DATA);\n                print(\".align 4\\n.LP%d:\\n.long 0\\n\", plab);\n                (*IR->segment)(CODE);\n                print(\"movl $.LP%d,%%edx\\ncall mcount\\n\", plab);\n                plab++;\n        }\n        print(\"pushl %%ebx\\n\");\n        print(\"pushl %%esi\\n\");\n        print(\"pushl %%edi\\n\");\n        print(\"movl %%esp,%%ebp\\n\");\n\n        usedmask[0] = usedmask[1] = 0;\n        freemask[0] = freemask[1] = ~0U;\n        offset = 16 + 4;\n        for (i = 0; callee[i]; i++) {\n                Symbol p = callee[i];\n                Symbol q = caller[i];\n                assert(q);\n                offset = roundup(offset, q->type->align);\n                p->x.offset = q->x.offset = offset;\n                p->x.name = q->x.name = stringf(\"%d\", p->x.offset);\n                p->sclass = q->sclass = AUTO;\n                offset += roundup(q->type->size, 4);\n        }\n        assert(caller[i] == 0);\n        offset = maxoffset = 0;\n        gencode(caller, callee);\n        framesize = roundup(maxoffset, 4);\n        if (framesize > 0)\n                print(\"subl $%d,%%esp\\n\", framesize);\n        emitcode();\n        print(\"movl %%ebp,%%esp\\n\");\n        print(\"popl %%edi\\n\");\n        print(\"popl %%esi\\n\");\n        print(\"popl %%ebx\\n\");\n        print(\"popl %%ebp\\n\");\n        print(\"ret\\n\");\n        { int l = genlabel(1);\n          print(\".Lf%d:\\n\", l);\n          print(\".size %s,.Lf%d-%s\\n\", f->x.name, l, f->x.name);\n        }\n}\n\nstatic void defsymbol(Symbol p) {\n        if (p->scope >= LOCAL && p->sclass == STATIC)\n                p->x.name = stringf(\"%s.%d\", p->name, genlabel(1));\n        else if (p->generated)\n                p->x.name = stringf(\".LC%s\", p->name);\n        else if (p->scope == GLOBAL || p->sclass == EXTERN)\n                p->x.name = stringf(\"%s\", p->name);\n        else\n                p->x.name = p->name;\n}\n\nstatic void segment(int n) {\n        if (n == cseg)\n                return;\n        cseg = n;\n        if (cseg == CODE)\n                print(\".text\\n\");\n        else if (cseg == BSS)\n                print(\".bss\\n\");\n        else if (cseg == DATA || cseg == LIT)\n                print(\".data\\n\");\n}\n\nstatic void defconst(int suffix, int size, Value v) {\n        if (suffix == I && size == 1)\n                print(\".byte %d\\n\",   v.u);\n        else if (suffix == I && size == 2)\n                print(\".word %d\\n\",   v.i);\n        else if (suffix == I && size == 4)\n                print(\".long %d\\n\",   v.i);\n        else if (suffix == U && size == 1)\n                print(\".byte %d\\n\", v.u);\n        else if (suffix == U && size == 2)\n                print(\".word %d\\n\", v.u);\n        else if (suffix == U && size == 4)\n                print(\".long %d\\n\", v.u);\n        else if (suffix == P && size == 4)\n                print(\".long %d\\n\", v.p);\n        else if (suffix == F && size == 4) {\n                float f = v.d;\n                print(\".long %d\\n\", *(unsigned *)&f);\n        } else if (suffix == F && size == 8) {\n                double d = v.d;\n                unsigned *p = (unsigned *)&d;\n                print(\".long %d\\n.long %d\\n\", p[swap], p[!swap]);\n        }\n        else assert(0);\n}\n\nstatic void defaddress(Symbol p) {\n        print(\".long %s\\n\", p->x.name);\n}\n\nstatic void defstring(int n, char *str) {\n        char *s;\n\n        for (s = str; s < str + n; s++)\n                print(\".byte %d\\n\", (*s)&0377);\n}\n\nstatic void export(Symbol p) {\n        globalend();\n        print(\".globl %s\\n\", p->x.name);\n}\n\nstatic void import(Symbol p) {}\n\nstatic void global(Symbol p) {\n        globalend();\n        print(\".align %d\\n\", p->type->align > 4 ? 4 : p->type->align);\n        if (!p->generated) {\n                print(\".type %s,@%s\\n\", p->x.name,\n                        isfunc(p->type) ? \"function\" : \"object\");\n                if (p->type->size > 0)\n                        print(\".size %s,%d\\n\", p->x.name, p->type->size);\n                else\n                        prevg = p;\n        }\n        if (p->u.seg == BSS) {\n                if (p->sclass == STATIC)\n                        print(\".lcomm %s,%d\\n\", p->x.name, p->type->size);\n                else\n                        print(\".comm %s,%d\\n\", p->x.name, p->type->size);\n        } else {\n                print(\"%s:\\n\", p->x.name);\n        }\n}\n\nstatic void space(int n) {\n        if (cseg != BSS)\n                print(\".space %d\\n\", n);\n}\n\nInterface x86linuxIR = {\n        1, 1, 0,  /* char */\n        2, 2, 0,  /* short */\n        4, 4, 0,  /* int */\n        4, 4, 0,  /* long */\n        4, 4, 0,  /* long long */\n        4, 4, 1,  /* float */\n        8, 4, 1,  /* double */\n        8, 4, 1,  /* long double */\n        4, 4, 0,  /* T * */\n        0, 4, 0,  /* struct; so that ARGB keeps stack aligned */\n        1,        /* little_endian */\n        0,        /* mulops_calls */\n        0,        /* wants_callb */\n        1,        /* wants_argb */\n        0,        /* left_to_right */\n        0,        /* wants_dag */\n        0,        /* unsigned_char */\n        0, /* address */\n        blockbeg,\n        blockend,\n        defaddress,\n        defconst,\n        defstring,\n        defsymbol,\n        emit,\n        export,\n        function,\n        gen,\n        global,\n        import,\n        0, /* local */\n        progbeg,\n        progend,\n        segment,\n        space,\n        stabblock, stabend, 0, stabinit, stabline, stabsym, stabtype,\n        {1, rmap,\n            0, 0, 0,    /* blkfetch, blkstore, blkloop */\n            _label,\n            _rule,\n            _nts,\n            _kids,\n            _string,\n            _templates,\n            _isinstruction,\n            _ntname,\n            emit2,\n            0, /* doarg */\n            target,\n            clobber,\n        }\n};\n\nvoid x86linux_init(int argc, char *argv[]) {\n        static int inited;\n        extern Interface x86IR;\n\n        if (inited)\n                return;\n        inited = 1;\n#define xx(f) assert(!x86linuxIR.f); x86linuxIR.f = x86IR.f\n        xx(address);\n        xx(local);\n        xx(x.blkfetch);\n        xx(x.blkstore);\n        xx(x.blkloop);\n        xx(x.doarg);\n#undef xx\n}\n"
  },
  {
    "path": "lcc/tst/8q.0",
    "content": ""
  },
  {
    "path": "lcc/tst/8q.c",
    "content": "int up[15], down[15], rows[8], x[8];\nint queens(), print();\n\nmain()\n{\n\tint i;\n\n\tfor (i = 0; i < 15; i++)\n\t\tup[i] = down[i] = 1;\n\tfor (i = 0; i < 8; i++)\n\t\trows[i] = 1;\n\tqueens(0);\n\treturn 0;\n}\n\nqueens(c)\n{\n\tint r;\n\n\tfor (r = 0; r < 8; r++)\n\t\tif (rows[r] && up[r-c+7] && down[r+c]) {\n\t\t\trows[r] = up[r-c+7] = down[r+c] = 0;\n\t\t\tx[c] = r;\n\t\t\tif (c == 7)\n\t\t\t\tprint();\n\t\t\telse\n\t\t\t\tqueens(c + 1);\n\t\t\trows[r] = up[r-c+7] = down[r+c] = 1;\n\t\t}\n}\n\nprint()\n{\n\tint k;\n\n\tfor (k = 0; k < 8; k++)\n\t\tprintf(\"%c \", x[k]+'1');\n\tprintf(\"\\n\");\n}\n"
  },
  {
    "path": "lcc/tst/array.0",
    "content": ""
  },
  {
    "path": "lcc/tst/array.c",
    "content": "int x[3][4], *y[3];\n\nmain() {\n\tint z[3][4];\n\tint i, j, *p;\n\n\tfor (i = 0; i < 3; i++) {\n\t\tfor (j = 0; j < 4; j++)\n\t\t\tx[i][j] = 1000*i + j;\n\t\ty[i] = x[i];\n\t}\n\tf();\n\tfor (i = 0; i < 3; i++) {\n\t\ty[i] = p = &z[i][0];\n\t\tfor (j = 0; j < 4; j++)\n\t\t\tp[j] = x[i][j];\n\t}\n\tg(z, y);\n\treturn 0;\n}\n\nf() {\n\tint i, j;\n\n\tfor (i = 0; i < 3; i++)\n\t\tfor (j = 0; j < 4; j++)\n\t\t\tprintf(\" %d\", x[i][j]);\n\tprintf(\"\\n\");\n\tfor (i = 0; i < 3; i++)\n\t\tfor (j = 0; j < 4; j++)\n\t\t\tprintf(\" %d\", y[i][j]);\n\tprintf(\"\\n\");\n}\n\ng(x, y)\nint x[][4], *y[];\n{\n\tint i, j;\n\n\tfor (i = 0; i < 3; i++)\n\t\tfor (j = 0; j < 4; j++)\n\t\t\tprintf(\" %d\", x[i][j]);\n\tprintf(\"\\n\");\n\tfor (i = 0; i < 3; i++)\n\t\tfor (j = 0; j < 4; j++)\n\t\t\tprintf(\" %d\", y[i][j]);\n\tprintf(\"\\n\");\n}\n"
  },
  {
    "path": "lcc/tst/cf.0",
    "content": "/* cf - print character frequencies */\nfloat f[128];\n\nmain(argc, argv)\nint argc;\nchar *argv[];\n{\n\tint i, c, nc;\n\tfloat cutoff, atof();\n\n\tif (argc <= 1)\n\t\tcutoff = 0.0;\n\telse\n\t\tcutoff = atof(argv[1])/100;\n\tfor (i = 0; i <= 127; )\n\t\tf[i++] = 0.0;\n\tnc = 0;\n\twhile ((c = getchar()) != -1) {\n\t\tf[c] += 1;\n\t\tnc++;\n\t}\n\tprintf(\"char\\tfreq\\n\");\n\tfor (i = 0; i <= 127; ++i)\n\t\tif (f[i] && f[i]/nc >= cutoff) {\n\t\t\tif (i <= ' ')\n\t\t\t\tprintf(\"%03o\", i);\n\t\t\telse\n\t\t\t\tprintf(\"%c\", i);\n\t\t\tprintf(\"\\t%.1f\\n\", 100*f[i]/nc);\n\t\t}\n\treturn 0;\n}\n"
  },
  {
    "path": "lcc/tst/cf.c",
    "content": "/* cf - print character frequencies */\nfloat f[128];\n\nmain(argc, argv)\nint argc;\nchar *argv[];\n{\n\tint i, c, nc;\n\tfloat cutoff, atof();\n\n\tif (argc <= 1)\n\t\tcutoff = 0.0;\n\telse\n\t\tcutoff = atof(argv[1])/100;\n\tfor (i = 0; i <= 127; )\n\t\tf[i++] = 0.0;\n\tnc = 0;\n\twhile ((c = getchar()) != -1) {\n\t\tf[c] += 1;\n\t\tnc++;\n\t}\n\tprintf(\"char\\tfreq\\n\");\n\tfor (i = 0; i <= 127; ++i)\n\t\tif (f[i] && f[i]/nc >= cutoff) {\n\t\t\tif (i <= ' ')\n\t\t\t\tprintf(\"%03o\", i);\n\t\t\telse\n\t\t\t\tprintf(\"%c\", i);\n\t\t\tprintf(\"\\t%.1f\\n\", 100*f[i]/nc);\n\t\t}\n\treturn 0;\n}\n"
  },
  {
    "path": "lcc/tst/cq.0",
    "content": ""
  },
  {
    "path": "lcc/tst/cq.c",
    "content": "   struct defs {\n     int cbits;          /* No. of bits per char           */\n     int ibits;          /*                 int            */\n     int sbits;          /*                 short          */\n     int lbits;          /*                 long           */\n     int ubits;          /*                 unsigned       */\n     int fbits;          /*                 float          */\n     int dbits;          /*                 double         */\n     float fprec;        /* Smallest number that can be    */\n     float dprec;        /* significantly added to 1.      */\n     int flgs;           /* Print return codes, by section */\n     int flgm;           /* Announce machine dependencies  */\n     int flgd;           /* give explicit diagnostics      */\n     int flgl;           /* Report local return codes.     */\n     int rrc;            /* recent return code             */\n     int crc;            /* Cumulative return code         */\n     char rfs[8];        /* Return from section            */\n   };\nmain(n,args)               /* C REFERENCE MANUAL         */\nint n;\nchar **args;\n{\n\n/*   This program performs a series of tests on a C compiler,\nbased on information in the\n\n             C REFERENCE MANUAL\n\nwhich appears as Appendix A to the book \"The C Programming\nLanguage\" by Brian W. Kernighan and Dennis M. Ritchie\n(Prentice-Hall, 1978, $10.95). This Appendix is hereafter\nreferred to as \"the Manual\".\n\n     The rules followed in writing this program are:\n\n     1. The entire program is written in legal C, according\n     to the Manual. It should compile with no error messages,\n     although some warning messages may be produced by some\n     compilers. Failure to compile should be interpreted as\n     a compiler error.\n\n     2. The program is clean, in that it does not make use\n     of any features of the operating system on which it runs,\n     with the sole exceptions of the printf() function, and an\n     internal \"options\" routine, which is easily excised.\n\n     3. No global variables are used, except for the spec-\n     ific purpose of testing the global variable facility.\n\n     The program is divided into modules having names of the\nform snnn... These modules correspond to those sections of the\nManual, as identified by boldface type headings, in which\nthere is something to test. For example, s241() corresponds\nto section 2.4.1 of the Manual (Integer constants) and tests\nthe facilities described therein. The module numbering\nscheme is ambiguous, especially when it names modules\nreferring to more than one section; module s7813, for ex-\nample, deals with sections 7.8 through 7.13. Nonetheless,\nit is surprisingly easy to find a section in the Manual\ncorresponding to a section of code, and vice versa.\n\n     Note also that there seem to be \"holes\" in the program,\nat least from the point of view that there exist sections in the\nManual for which there is no corresponding code. Such holes\narise from three causes: (a) there is nothing in that partic-\nular section to test, (b) everything in that section is tested\nelsewhere, and (c) it was deemed advisable not to check cer-\ntain features like preprocessor or listing control features.\n\n     Modules are called by a main program main(). The mod-\nules that are called, and the sequence in which they are \ncalled, are determined by two lists in main(), in which the\nmodule names appear. The first list (an extern statement)\ndeclares the module names to be external. The second (a stat-\nic int statement) names the modules and defines the sequence\nin which they are called. There is no need for these lists\nto be in the same order, but it is probably a good idea to keep\nthem that way in the interest of clarity. Since there are no\ncross-linkages between modules, new modules may be added,\nor old ones deleted, simply by editing the lists, with one\nexception: section s26, which pokes around at the hardware\ntrying to figure out the characteristics of the machine that\nit is running on, saves information that is subsequently\nused by sections s626, s72, and s757. If this program is\nto be broken up into smallish pieces, say for running on\na microcomputer, take care to see that s26 is called before\ncalling any of the latter three sections.  The size\nof the lists, i.e., the number of modules to be called, is\nnot explicitly specified as a program parameter, but is\ndetermined dynamically using the sizeof operator.\n\n     Communication between the main program and the modules\ntakes place in two ways. In all cases, a pointer to a structure\nis passed to the called module. The structure contains flags\nthat will determine the type of information to be published\nby the module, and fields that may be written in by the\nmodule. The former include \"flgm\" and \"flgd\", which, if set\nto a nonzero value, specify that machine dependencies are to\nbe announced or that error messages are to be printed, re-\nspectively. The called module's name, and the hardware char-\nacteristics probed in s26() comprise the latter.\n\n\n     Also, in all cases, a return code is returned by the called\nmodule. A return code of zero indicates that all has gone well;\nnonzero indicates otherwise. Since more than one type of error\nmay be detected by a module, the return code is a composite\nof error indicators, which, individually, are given as numbers\nthat are powers of two. Thus, a return code of 10 indicates\nthat two specific errors, 8 and 2, were detected. Whether or\nnot the codes returned by the modules are printed by the main\nprogram is determined by setting \"flgs\" to 1 (resp. 0).\n\n     The entire logic of the main program is contained in the\nhalf-dozen or so lines at the end. The somewhat cryptic \nstatement:\n\n           d0.rrc = (*sec[j])(pd0);\n\nin the for loop calls the modules. The rest of the code is\nreasonably straightforward.\n\n     Finally, in each of the modules, there is the following\nprologue:\n\n           snnn(pd0)\n           struct defs *pd0;\n           {\n              static char snnner[] = \"snnn,er%d\\n\";\n              static char qsnnn[8] = \"snnn   \";\n              char *ps, *pt;\n              int rc;\n\n              rc = 0;\n              ps = qsnnn;\n              pt = pd0->rfs;\n              while(*pt++ = *ps++);\n\nused for housekeeping, handshaking and module initialization.\n\n                                                           */\n   extern\n     s22(),\n     s241(),\n     s243(),\n     s244(),\n     s25(),\n     s26(),\n     s4(),\n     s61(),\n     s626(),\n     s71(),\n     s72(),\n     s757(),\n     s7813(),\n     s714(),\n     s715(),\n     s81(),\n     s84(),\n     s85(),\n     s86(),\n     s88(),\n     s9()\n   ;\n\n   int j;\n   static int (*sec[])() = {\n     s22,\n     s241,\n     s243,\n     s244,\n     s25,\n     s26,\n     s4,\n     s61,\n     s626,\n     s71,\n     s72,\n     s757,\n     s7813,\n     s714,\n     s715,\n     s81,\n     s84,\n     s85,\n     s86,\n     s88,\n     s9\n   };\n\n   static struct defs d0, *pd0;\n    \n     d0.flgs = 1;          /* These flags dictate            */\n     d0.flgm = 1;          /*     the verbosity of           */\n     d0.flgd = 1;          /*         the program.           */\n     d0.flgl = 1;\n\n   pd0 = &d0;\n\n   for (j=0; j<sizeof(sec) / sizeof(sec[0]); j++) {\n     d0.rrc = (*sec[j])(pd0);\n     d0.crc = d0.crc+d0.rrc;\n     if(d0.flgs != 0) printf(\"Section %s returned %d.\\n\",d0.rfs,d0.rrc);\n   }\n  \n   if(d0.crc == 0) printf(\"\\nNo errors detected.\\n\");\n   else printf(\"\\nFailed.\\n\");\n   return 0;\n}\ns22(pd0)                 /* 2.2 Identifiers (Names)      */\nstruct defs *pd0;\n{\n   int a234, a;\n   int _, _234, A, rc;\n\n   static char s22er[] = \"s22,er%d\\n\";\n   static char qs22[8] = \"s22    \";\n\n   char *ps, *pt;\n                         /* Initialize                      */\n\n   rc = 0;\n   ps = qs22;\n   pt = pd0 -> rfs;\n   while (*pt++ = *ps++);\n\n     /* An identifier is a sequence of letters and digits;\n        the first character must be a letter. The under-\n        score _ counts as a letter.                        */\n\n   a=1;\n   _=2;\n   _234=3;\n   a234=4;\n   if(a+_+_234+a234 != 10) {\n     rc = rc+1;\n     if(pd0->flgd != 0) printf(s22er,1);\n   }\n\n   /* Upper and lower case letters are different.     */\n\n   A = 2;\n   if (A == a) {\n     rc = rc+4;\n     if (pd0->flgd != 0) printf(s22er,4);\n   }\n\n   return(rc);\n}\ns241(pd0)                   /* 2.4.1 Integer constants\n                               2.4.2 Explicit long constants  */\nstruct defs *pd0;\n{\n   long pow2();\n   static char s241er[] = \"s241,er%d\\n\";\n   static char qs241[8] = \"s241   \";\n   char *ps, *pt;\n   int rc, j, lrc;\n   static long g[39] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n                        0,6,0,8,0,12,0,16,0,18,0,20,0,24,\n                        0,28,0,30,0,32,0,36};\n   long d[39], o[39], x[39];\n\n   rc = 0;\n   lrc = 0;\n   ps = qs241;\n   pt = pd0 -> rfs;\n   while (*pt++ = *ps++);\n\n     /* An integer constant consisting of a sequence of digits is\n        taken to be octal if it begins with 0 (digit zero), decimal\n        otherwise.                                            */\n\n   if (   8 !=  010\n     ||  16 !=  020\n     ||  24 !=  030\n     ||  32 !=  040\n     ||  40 !=  050\n     ||  48 !=  060\n     ||  56 !=  070\n     ||  64 != 0100\n     ||  72 != 0110\n     ||  80 != 0120\n     ||   9 != 0011\n     ||  17 != 0021\n     ||  25 != 0031\n     ||  33 != 0041\n     ||  41 != 0051\n     ||  49 != 0061\n     ||  57 != 0071\n     ||  65 != 0101\n     ||  73 != 0111\n     ||  81 != 0121 ){\n\n     rc = rc+1;\n     if( pd0->flgd != 0 ) printf(s241er,1);\n   }\n\n     /* A sequence of digits preceded by 0x or 0X (digit zero)\n        is taken to be a hexadecimal integer. The hexadecimal\n        digits include a or A through f or F with values 10\n        through 15.     */\n\n   if ( 0x00abcdef != 0xabcdef\n     || 0xabcdef != 0Xabcdef || 0Xabcdef != 0XAbcdef\n     || 0XAbcdef != 0XABcdef || 0XABcdef != 0XABCdef\n     || 0XABCdef != 0XABCDef || 0XABCDef != 0XABCDEf\n     || 0XABCDEf != 0XABCDEF || 0xABCDEF != 11259375 ){\n\n     rc = rc+2;\n     if( pd0->flgd != 0 ) printf(s241er,2);\n   }\n\n     /* A decimal constant whose value exceeds the largest signed\n        machine integer is taken to be long; an octal or hex con-\n        stant which exceeds the largest unsigned machine integer\n        is likewise taken to be long.     */\n\n   if ( sizeof 010000000000 != sizeof(long)      /* 2**30 */\n     || sizeof 1073741824   != sizeof(long)      /* ditto */\n     || sizeof 0x40000000   != sizeof(long) ){   /*   \"   */\n\n     rc = rc+4;\n     if( pd0->flgd != 0 ) printf(s241er,4);\n   }\n\n     /* A decimal, octal, or hexadecimal constant immediately followed\n        by l (letter ell) or L is a long constant.    */\n\n   if ( sizeof   67l != sizeof(long)\n     || sizeof   67L != sizeof(long)\n     || sizeof  067l != sizeof(long)\n     || sizeof  067L != sizeof(long)\n     || sizeof 0X67l != sizeof(long)\n     || sizeof 0x67L != sizeof(long) ){\n\n     rc = rc+8;\n     if( pd0 -> flgd != 0 ) printf(s241er,8);\n   }\n\n     /* Finally, we test to see that decimal (d), octal (o),\n        and hexadecimal (x) constants representing the same values\n        agree among themselves, and with computed values, at spec-\n        ified points over an appropriate range. The points select-\n        ed here are those with the greatest potential for caus-\n        ing trouble, i.e., zero, 1-16, and values of 2**n and\n        2**n - 1 where n is some multiple of 4 or 6. Unfortunately,\n        just what happens when a value is too big to fit in a\n        long is undefined; however, it would be nice if what\n        happened were at least consistent...      */\n\n   for ( j=0; j<17; j++ ) g[j] = j;\n   for ( j=18; j<39; ) {\n     g[j] = pow2(g[j]);\n     g[j-1] = g[j] - 1;\n     j = j+2;\n   }\n\n   d[0] = 0;                o[0] = 00;               x[0] = 0x0;\n   d[1] = 1;                o[1] = 01;               x[1] = 0x1;\n   d[2] = 2;                o[2] = 02;               x[2] = 0x2;\n   d[3] = 3;                o[3] = 03;               x[3] = 0x3;\n   d[4] = 4;                o[4] = 04;               x[4] = 0x4;\n   d[5] = 5;                o[5] = 05;               x[5] = 0x5;\n   d[6] = 6;                o[6] = 06;               x[6] = 0x6;\n   d[7] = 7;                o[7] = 07;               x[7] = 0x7;\n   d[8] = 8;                o[8] = 010;              x[8] = 0x8;\n   d[9] = 9;                o[9] = 011;              x[9] = 0x9;\n   d[10] = 10;              o[10] = 012;             x[10] = 0xa;\n   d[11] = 11;              o[11] = 013;             x[11] = 0xb;\n   d[12] = 12;              o[12] = 014;             x[12] = 0xc;\n   d[13] = 13;              o[13] = 015;             x[13] = 0xd;\n   d[14] = 14;              o[14] = 016;             x[14] = 0xe;\n   d[15] = 15;              o[15] = 017;             x[15] = 0xf;\n   d[16] = 16;              o[16] = 020;             x[16] = 0x10;\n   d[17] = 63;              o[17] = 077;             x[17] = 0x3f;\n   d[18] = 64;              o[18] = 0100;            x[18] = 0x40;\n   d[19] = 255;             o[19] = 0377;            x[19] = 0xff;\n   d[20] = 256;             o[20] = 0400;            x[20] = 0x100;\n   d[21] = 4095;            o[21] = 07777;           x[21] = 0xfff;\n   d[22] = 4096;            o[22] = 010000;          x[22] = 0x1000;\n   d[23] = 65535;           o[23] = 0177777;         x[23] = 0xffff;\n   d[24] = 65536;           o[24] = 0200000;         x[24] = 0x10000;\n   d[25] = 262143;          o[25] = 0777777;         x[25] = 0x3ffff;\n   d[26] = 262144;          o[26] = 01000000;        x[26] = 0x40000;\n   d[27] = 1048575;         o[27] = 03777777;        x[27] = 0xfffff;\n   d[28] = 1048576;         o[28] = 04000000;        x[28] = 0x100000;\n   d[29] = 16777215;        o[29] = 077777777;       x[29] = 0xffffff;\n   d[30] = 16777216;        o[30] = 0100000000;      x[30] = 0x1000000;\n   d[31] = 268435455;       o[31] = 01777777777;     x[31] = 0xfffffff;\n   d[32] = 268435456;       o[32] = 02000000000;     x[32] = 0x10000000;\n   d[33] = 1073741823;      o[33] = 07777777777;     x[33] = 0x3fffffff;\n   d[34] = 1073741824;      o[34] = 010000000000;    x[34] = 0x40000000;\n   d[35] = 4294967295;      o[35] = 037777777777;    x[35] = 0xffffffff;\n   d[36] = 4294967296;      o[36] = 040000000000;    x[36] = 0x100000000;\n   d[37] = 68719476735;     o[37] = 0777777777777;   x[37] = 0xfffffffff;\n   d[38] = 68719476736;     o[38] = 01000000000000;  x[38] = 0x1000000000;\n\n   /* WHEW! */\n\n   for (j=0; j<39; j++){\n     if ( g[j] != d[j]\n       || d[j] != o[j]\n       || o[j] != x[j]) {\n\n       if( pd0 -> flgm != 0 ) {\n/*       printf(s241er,16);          save in case opinions change...     */\n         printf(\"Decimal and octal/hex constants sometimes give\\n\");\n         printf(\"   different results when assigned to longs.\\n\");\n       }\n/*     lrc = 1;   save...   */\n     }\n   }\n\n   if (lrc != 0) rc =16;\n\n   return rc;\n}\n\nlong pow2(n)        /* Calculate 2**n by multiplying, not shifting  */\nlong n;\n{\n   long s;\n   s = 1;\n   while(n--) s = s*2;\n   return s;\n}\ns243(pd0)                   /*  2.4.3 Character constants  */\nstruct defs *pd0;\n{\n   static char s243er[] = \"s243,er%d\\n\";\n   static char qs243[8] = \"s243   \";\n   char *ps, *pt;\n   int rc;\n   char chars[256];\n\n   rc = 0;\n   ps = qs243;\n   pt = pd0->rfs;\n   while(*pt++ = *ps++);\n\n     /* One of the problems that arises when testing character constants\n        is that of definition: What, exactly, is the character set?\n        In order to guarantee a certain amount of machine independence,\n        the character set we will use here is the set of characters writ-\n        able as escape sequences in C, plus those characters used in writ-\n        ing C programs, i.e.,\n\n        letters:\n                   ABCDEFGHIJKLMNOPQRSTUVWXYZ      26\n                   abcdefghijklmnopqrstuvwxyz      26\n        numbers:\n                   0123456789                      10\n        special characters:\n                   ~!\"#%&()_=-^|{}[]+;*:<>,.?/     27\n        extra special characters:\n                   newline           \\n       \n                   horizontal tab    \\t\n                   backspace         \\b\n                   carriage return   \\r\n                   form feed         \\f\n                   backslash         \\\\\n                   single quote      \\'             7\n        blank & NUL                                 2\n                                                  ---\n                                                   98\n\n        Any specific implementation of C may of course support additional\n        characters.                                       */\n\n        /* Since the value of a character constant is the numerical value\n           of the character in the machine's character set, there should\n           be a one-to-one correspondence between characters and values. */\n\n   zerofill(chars);\n\n   chars['a'] = 1;   chars['A'] = 1;   chars['~'] = 1;   chars['0'] = 1;\n   chars['b'] = 1;   chars['B'] = 1;   chars['!'] = 1;   chars['1'] = 1;\n   chars['c'] = 1;   chars['C'] = 1;   chars['\"'] = 1;   chars['2'] = 1;\n   chars['d'] = 1;   chars['D'] = 1;   chars['#'] = 1;   chars['3'] = 1;\n   chars['e'] = 1;   chars['E'] = 1;   chars['%'] = 1;   chars['4'] = 1;\n   chars['f'] = 1;   chars['F'] = 1;   chars['&'] = 1;   chars['5'] = 1;\n   chars['g'] = 1;   chars['G'] = 1;   chars['('] = 1;   chars['6'] = 1;\n   chars['h'] = 1;   chars['H'] = 1;   chars[')'] = 1;   chars['7'] = 1;\n   chars['i'] = 1;   chars['I'] = 1;   chars['_'] = 1;   chars['8'] = 1;\n   chars['j'] = 1;   chars['J'] = 1;   chars['='] = 1;   chars['9'] = 1;\n   chars['k'] = 1;   chars['K'] = 1;   chars['-'] = 1;\n   chars['l'] = 1;   chars['L'] = 1;   chars['^'] = 1;\n   chars['m'] = 1;   chars['M'] = 1;   chars['|'] = 1;   chars['\\n'] = 1;\n   chars['n'] = 1;   chars['N'] = 1;                     chars['\\t'] = 1;\n   chars['o'] = 1;   chars['O'] = 1;   chars['{'] = 1;   chars['\\b'] = 1;\n   chars['p'] = 1;   chars['P'] = 1;   chars['}'] = 1;   chars['\\r'] = 1;\n   chars['q'] = 1;   chars['Q'] = 1;   chars['['] = 1;   chars['\\f'] = 1;\n   chars['r'] = 1;   chars['R'] = 1;   chars[']'] = 1;\n   chars['s'] = 1;   chars['S'] = 1;   chars['+'] = 1;   chars['\\\\'] = 1;\n   chars['t'] = 1;   chars['T'] = 1;   chars[';'] = 1;   chars['\\''] = 1;\n   chars['u'] = 1;   chars['U'] = 1;   chars['*'] = 1;  \n   chars['v'] = 1;   chars['V'] = 1;   chars[':'] = 1;   chars['\\0'] = 1;\n   chars['w'] = 1;   chars['W'] = 1;   chars['<'] = 1;   chars[' '] = 1;\n   chars['x'] = 1;   chars['X'] = 1;   chars['>'] = 1;\n   chars['y'] = 1;   chars['Y'] = 1;   chars[','] = 1;\n   chars['z'] = 1;   chars['Z'] = 1;   chars['.'] = 1;\n                                       chars['?'] = 1;\n                                       chars['/'] = 1;\n\n   if(sumof(chars) != 98){\n     rc = rc+1;\n     if(pd0->flgd != 0) printf(s243er,1);\n   }\n\n   /* Finally, the escape \\ddd consists of the backslash followed\n      by 1, 2, or 3 octal digits which are taken to specify  the\n      desired character.                           */\n\n   if( '\\0'    !=   0 || '\\01'   !=   1 || '\\02'   !=   2\n    || '\\03'   !=   3 || '\\04'   !=   4 || '\\05'   !=   5\n    || '\\06'   !=   6 || '\\07'   !=   7 || '\\10'   !=   8\n    || '\\17'   !=  15 || '\\20'   !=  16 || '\\77'   !=  63\n    || '\\100'  !=  64 || '\\177'  != 127                 ){\n   \n     rc = rc+8;\n     if(pd0->flgd != 0) printf(s243er,8);\n   }\n\n   return rc;\n}\nzerofill(x)\nchar *x;\n{\n   int j;\n\n   for (j=0; j<256; j++) *x++ = 0;\n}\nsumof(x)\nchar *x;\n{\n   char *p;\n   int total, j;\n\n   p = x;\n   total = 0;\n\n   for(j=0; j<256; j++) total = total+ *p++;\n   return total;\n}\ns244(pd0)\nstruct defs *pd0;\n{\n   double a[8];\n   int rc, lrc, j;\n   static char s244er[] = \"s244,er%d\\n\";\n   static char qs244[8] = \"s244   \";\n   char *ps, *pt;\n\n   ps = qs244;\n   pt = pd0->rfs;\n   while(*pt++ = *ps++);\n   rc = 0;\n   lrc = 0;\n\n   /* Unfortunately, there's not a lot we can do with floating constants.\n      We can check to see that the various representations can be com-\n      piled, that the conversion is such that they yield the same hard-\n      ware representations in all cases, and that all representations\n      thus checked are double precision.              */\n\n   a[0] = .1250E+04;\n   a[1] = 1.250E3;\n   a[2] = 12.50E02;\n   a[3] = 125.0e+1;\n   a[4] = 1250e00;\n   a[5] = 12500.e-01;\n   a[6] = 125000e-2;\n   a[7] = 1250.;\n\n   lrc = 0;\n   for (j=0; j<7; j++) if(a[j] != a[j+1]) lrc = 1;\n\n   if(lrc != 0) {\n     if(pd0->flgd != 0) printf(s244er,1);\n     rc = rc+1;\n   }\n\n   if ( (sizeof .1250E+04 ) != sizeof(double)\n     || (sizeof 1.250E3   ) != sizeof(double)\n     || (sizeof 12.50E02  ) != sizeof(double)\n     || (sizeof 1.250e+1  ) != sizeof(double)\n     || (sizeof 1250e00   ) != sizeof(double)\n     || (sizeof 12500.e-01) != sizeof(double)\n     || (sizeof 125000e-2 ) != sizeof(double)\n     || (sizeof 1250.     ) != sizeof(double)){\n     \n     if(pd0->flgd != 0) printf(s244er,2);\n     rc = rc+2;\n   }\n\n   return rc;\n}\ns25(pd0)\nstruct defs *pd0;\n{\n   char *s, *s2;\n   int rc, lrc, j;\n   static char s25er[] = \"s25,er%d\\n\";\n   static char qs25[8] = \"s25    \";\n   char *ps, *pt;\n\n   ps = qs25;\n   pt = pd0->rfs;\n   while(*pt++ = *ps++);\n   rc = 0;\n\n   /* A string is a sequence of characters surrounded by double\n      quotes, as in \"...\".                         */\n\n   s = \"...\";\n\n   /* A string has type \"array of characters\" and storage class\n      static and is initialized with the given characters.  */\n\n   if ( s[0] != s[1] || s[1] != s[2]\n     || s[2] != '.' ) {\n\n    rc = rc+1;\n     if(pd0->flgd != 0) printf(s25er,1);\n   }\n\n   /* The compiler places a null byte \\0 at the end of each string\n      so the program which scans the string can find its end.   */\n\n   if( s[3] != '\\0' ){\n     rc = rc+4;\n     if(pd0->flgd != 0) printf(s25er,4);\n   }\n\n   /* In a string, the double quote character \" must be preceded\n      by a \\.                                               */\n\n    if( \".\\\".\"[1] != '\"' ){\n    rc = rc+8;\n     if(pd0->flgd != 0) printf(s25er,8);\n   }\n\n   /* In addition, the same escapes described for character constants\n      may be used.                                            */\n\n   s = \"\\n\\t\\b\\r\\f\\\\\\'\";\n\n   if( s[0] != '\\n'\n    || s[1] != '\\t'\n    || s[2] != '\\b'\n    || s[3] != '\\r'\n    || s[4] != '\\f'\n    || s[5] != '\\\\'\n    || s[6] != '\\'' ){\n\n     rc = rc+16;\n     if( pd0->flgd != 0) printf(s25er,16);\n   }\n\n   /* Finally, a \\ and an immediately following newline are ignored */\n\n   s2 = \"queep!\";\n   s = \"queep!\";\n\n   lrc = 0;\n   for (j=0; j<sizeof \"queep!\"; j++) if(s[j] != s2[j]) lrc = 1;\n   if (lrc != 0){\n     rc = rc+32;\n     if(pd0->flgd != 0) printf(s25er,32);\n   }\n   return rc;\n}\ns26(pd0)                  /*  2.6  Hardware Characteristics     */\nstruct defs *pd0;\n{\n   static char qs26[8] = \"s26    \";\n   char *ps, *pt;\n   char c0, c1;\n   float temp, one, delta;\n   double tempd, oned;\n   static char s[] = \"%3d bits in %ss.\\n\";\n   static char s2[] = \"%e is the least number that can be added to 1. (%s).\\n\";\n\n   ps = qs26;\n   pt = pd0->rfs;\n\n   while(*pt++ = *ps++);\n\n          /* Here, we shake the machinery a little to see what falls\n             out.  First, we find out how many bits are in a char.  */\n\n   pd0->cbits = 0;\n   c0 = 0;\n   c1 = 1;\n\n   while(c0 != c1) {\n     c1 = c1<<1;\n     pd0->cbits = pd0->cbits+1;\n   }\n          /* That information lets us determine the size of everything else. */\n\n   pd0->ibits = pd0->cbits * sizeof(int);\n   pd0->sbits = pd0->cbits * sizeof(short);\n   pd0->lbits = pd0->cbits * sizeof(long);\n   pd0->ubits = pd0->cbits * sizeof(unsigned);\n   pd0->fbits = pd0->cbits * sizeof(float);\n   pd0->dbits = pd0->cbits * sizeof(double);\n\n          /* We have now almost reconstructed the table in section 2.6, the\n             exception being the range of the floating point hardware.\n             Now there are just so many ways to conjure up a floating point\n             representation system that it's damned near impossible to guess\n             what's going on by writing a program to interpret bit patterns.\n             Further, the information isn't all that useful, if we consider\n             the fact that machines that won't handle numbers between 10**30\n             and 10**-30 are very hard to find, and that people playing with\n             numbers outside that range have a lot more to worry about than\n             just the capacity of the characteristic.\n\n             A much more useful measure is the precision, which can be ex-\n             pressed in terms of the smallest number that can be added to\n             1. without loss of significance. We calculate that here, for\n             float and double.                       */\n\n   one = 1.;\n   delta = 1.;\n   temp = 0.;\n   while(temp != one) {\n     temp = one+delta;\n     delta = delta/2.;\n   }\n   pd0->fprec = delta * 4.;\n   oned = 1.;\n   delta = 1.;\n   tempd = 0.;\n   while(tempd != oned) {\n     tempd = oned+delta;\n     delta = delta/2.;\n   }\n   pd0->dprec = delta * 4.;\n\n          /* Now, if anyone's interested, we publish the results.       */\n\n   if(pd0->flgm != 0) {\n     printf(s,pd0->cbits,\"char\");\n     printf(s,pd0->ibits,\"int\");\n     printf(s,pd0->sbits,\"short\");\n     printf(s,pd0->lbits,\"long\");\n     printf(s,pd0->ubits,\"unsigned\");\n     printf(s,pd0->fbits,\"float\");\n     printf(s,pd0->dbits,\"double\");\n     printf(s2,pd0->fprec,\"float\");\n     printf(s2,pd0->dprec,\"double\");\n   }\n          /* Since we are only exploring and perhaps reporting, but not \n             testing any features, we cannot return an error code.  */\n\n   return 0;\n}\nint extvar;\ns4(pd0)                    /* 4. What's in a name?             */\nstruct defs *pd0;\n{\n   static char s4er[] = \"s4,er%d\\n\";\n   static char qs4[8] = \"s4     \";\n   char *ps, *pt;\n   int j, rc;\n\n   short sint;             /* short integer, for size test      */\n   int pint;               /* plain                             */\n   long lint;              /* long                              */\n   unsigned target;\n   unsigned int mask;\n\n   rc = 0;\n   ps = qs4;\n   pt = pd0->rfs;\n\n   while(*pt++ = *ps++);\n\n/*   There are four declarable storage classes: automatic,\nstatic, external, and register. Automatic variables have\nbeen dealt with extensively thus far, and will not be specif-\nically treated in this section. Register variables are treated\nin section s81.\n\n     Static variables are local to a block, but retain their\nvalues upon reentry to a block, even after control has left\nthe block.                                                     */\n\n   for (j=0; j<3; j++)\n     if(svtest(j) != zero()){\n       rc = 1;\n       if(pd0->flgd != 0) printf(s4er,1);\n     }\n   ;\n\n/*   External variables exist and retain their values throughout\nthe execution of the entire program, and may be used for comm-\nunication between functions, even separately compiled functions.\n                                                                */\n\n   setev();\n   if(testev() != 0){\n     rc=rc+2;\n     if(pd0->flgd != 0) printf(s4er,2);\n   }\n/*   \n     Characters have been tested elsewhere (in s243).\n\n     Up to three sizes of integer, declared short int, int, and\nlong int, are available. Longer integers provide no less storage\nthan shorter ones, but implementation may make either short\nintegers, or long integers, or both, equivalent to plain\nintegers.\n                                                                */\n\n   if(sizeof lint < sizeof pint || sizeof pint < sizeof sint){\n\n     rc = rc+4;\n     if(pd0->flgd != 0) printf(s4er,4);\n   }\n\n/*   Unsigned integers, declared unsigned, obey the laws of\narithmetic modulo 2**n, where n is the number of bits in the\nimplementation                                                  */\n\n   target = ~0U;\n   mask = 1;\n \n   for(j=0; j<(sizeof target)*pd0->cbits; j++){\n   \n     mask = mask&target;\n     target = target>>1;\n   }\n\n   if(mask != 1 || target != 0){\n\n     rc = rc+8;\n     if(pd0->flgd != 0) printf(s4er,8);\n   }\n\n   return rc;\n}\nsvtest(n)\nint n;\n{\n   static k;\n   int rc;\n   switch (n) {\n\n     case 0: k = 1978;\n             rc = 0;\n             break;\n\n     case 1: if(k != 1978) rc = 1;\n             else{\n              k = 1929;\n              rc = 0;\n             }\n             break;\n\n     case 2: if(k != 1929) rc = 1;\n             else rc = 0;\n             break;\n   }\n   return rc;\n}\nzero(){                 /* Returns a value of zero, possibly */\n   static k;            /* with side effects, as it's called */\n   int rc;              /* alternately with svtest, above,   */\n   k = 2;               /* and has the same internal storage */\n   rc = 0;              /* requirements.                     */\n   return rc;\n}\ntestev(){\n   if(extvar != 1066) return 1;\n   else return 0;\n}\ns61(pd0)          /* Characters and integers */\nstruct defs *pd0;\n{\n   static char s61er[] = \"s61,er%d\\n\";\n   static char qs61[8] = \"s61    \";\n   short from, shortint;\n   long int to, longint;\n   int rc, lrc;\n   int j;\n   char fromc, charint;\n   char *wd, *pc[6];\n   \n   static char upper_alpha[]             = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n   static char lower_alpha[]             = \"abcdefghijklmnopqrstuvwxyz\";\n   static char numbers[]               = \"0123456789\";\n   static char special_characters[]    = \"~!\\\"#%&()_=-^|{}[]+;*:<>,.?/\";\n   static char extra_special_characters[] = \"\\n\\t\\b\\r\\f\\\\\\'\";\n   static char blank_and_NUL[]            = \" \\0\";\n\n   char *ps, *pt;\n   ps = qs61;\n   pt = pd0->rfs;\n   rc = 0;\n   while (*pt++ = *ps++);\n\n/*      A character or a short integer may be used wherever\nan integer may be used. In all cases, the value is converted\nto integer. This principle is extensively used throughout this\nprogram, and will not be explicitly tested here.        */\n\n/*      Conversion of a shorter integer to a longer always\ninvolves sign extension.                                */\n\n   from = -19;\n   to = from;\n\n   if(to != -19){\n     rc = rc+1;\n     if(pd0->flgd != 0) printf(s61er,1);\n   }\n\n/*      It is guaranteed that a member of the standard char-\nacter set is nonnegative.                               */\n\n   pc[0] = upper_alpha;\n   pc[1] = lower_alpha;\n   pc[2] = numbers;\n   pc[3] = special_characters;\n   pc[4] = extra_special_characters;\n   pc[5] = blank_and_NUL;\n\n   lrc = 0;\n   for (j=0; j<6; j++)\n     while(*pc[j]) if(*pc[j]++ < 0) lrc =1;\n\n   if(lrc != 0){\n     rc=rc+2;\n     if(pd0->flgd != 0) printf(s61er,2);\n   }\n\n/*      When a longer integer is converted to a shorter or\nto  a char, it is truncated on the left; excess bits are \nsimply discarded.                                       */\n\n   longint = 1048579;           /* =2**20+3 */\n   shortint = longint;\n   charint = longint;\n\n   if((shortint != longint && shortint != 3) ||\n      (charint  != longint && charint  != 3)) {\n     rc = rc+8;\n     if(pd0->flgd != 0) printf(s61er,8);\n   }\n\n   return rc;\n}\ns626(pd0)          /* 6.2 Float and double                  */\n                   /* 6.3 Floating and integral                 */\n                   /* 6.4 Pointers and integers                 */\n                   /* 6.5 Unsigned                              */\n                   /* 6.6 Arithmetic conversions                */\nstruct defs *pd0;\n{\n   static char s626er[] = \"s626,er%d\\n\";\n   static char qs626[8] = \"s626   \";\n   int rc;\n   char *ps, *pt;\n   float eps, f1, f2, f3, f4, f;\n   long lint1, lint2, l, ls;\n   char c, t[28], t0;\n   short s;\n   int is, i, j;\n   unsigned u, us;\n   double d, ds;\n   ps = qs626;\n   pt = pd0->rfs;\n   rc = 0;\n   while (*pt++ = *ps++);\n\n        /* Conversions of integral values to floating type are\n        well-behaved.                                           */\n\n   f1 = 1.;\n   lint1 = 1.;\n   lint2 = 1.;\n\n   for(j=0;j<pd0->lbits-2;j++){\n     f1 = f1*2;\n     lint2 = (lint2<<1)|lint1;\n   }\n   f2 = lint2;\n   f1 = (f1-f2)/f1;\n   if(f1>2.*pd0->fprec){\n\n     rc = rc+2;\n     if(pd0->flgd != 0) printf(s626er,2);\n   }\n\n        /* Pointer-integer combinations are discussed in s74,\n        \"Additive operators\". The unsigned-int combination\n        appears below.                                          */\n\n   c = 125;\n   s = 125;\n   i = 125;     is = 15625;\n   u = 125;     us = 15625;\n   l = 125;     ls = 15625;\n   f = 125.;\n   d = 125.;    ds = 15625.;\n\n   for(j=0;j<28;j++) t[j] = 0;\n\n   if(c*c != is) t[ 0] = 1;\n   if(s*c != is) t[ 1] = 1;\n   if(s*s != is) t[ 2] = 1;\n   if(i*c != is) t[ 3] = 1;\n   if(i*s != is) t[ 4] = 1;\n   if(i*i != is) t[ 5] = 1;\n   if(u*c != us) t[ 6] = 1;\n   if(u*s != us) t[ 7] = 1;\n   if(u*i != us) t[ 8] = 1;\n   if(u*u != us) t[ 9] = 1;\n   if(l*c != ls) t[10] = 1;\n   if(l*s != ls) t[11] = 1;\n   if(l*i != ls) t[12] = 1;\n   if(l*u != us) t[13] = 1;\n   if(l*l != ls) t[14] = 1;\n   if(f*c != ds) t[15] = 1;\n   if(f*s != ds) t[16] = 1;\n   if(f*i != ds) t[17] = 1;\n   if(f*u != ds) t[18] = 1;\n   if(f*l != ds) t[19] = 1;\n   if(f*f != ds) t[20] = 1;\n   if(d*c != ds) t[21] = 1;\n   if(d*s != ds) t[22] = 1;\n   if(d*i != ds) t[23] = 1;\n   if(d*u != ds) t[24] = 1;\n   if(d*l != ds) t[25] = 1;\n   if(d*f != ds) t[26] = 1;\n   if(d*d != ds) t[27] = 1;\n\n   t0 = 0;\n   for(j=0; j<28; j++) t0 = t0+t[j];\n\n   if(t0 != 0){\n\n     rc = rc+4;\n     if(pd0->flgd != 0){\n\n       printf(s626er,4);\n       printf(\"   key=\");\n       for(j=0;j<28;j++) printf(\"%d\",t[j]);\n       printf(\"\\n\");\n     }\n   }\n\n        /* When an unsigned integer is converted to long,\n           the value of the result is the same numerically\n           as that of the unsigned integer.               */\n\n   l = (unsigned)0100000;\n   if((long)l > (unsigned)0100000){\n\n      rc = rc+8;\n      if(pd0->flgd != 0) printf(s626er,8);\n   }\n\n   return rc;\n}\ns71(pd0)          /*         7.1  Primary expressions   */\nstruct defs *pd0;\n{\n   static char s71er[] = \"s71,er%d\\n\";\n   static char qs71[8] = \"s71    \";\n   int rc;\n   char *ps, *pt;\n   static char q = 'q';\n   int x[10], McCarthy(), clobber(), a, b, *p;\n   ps = qs71;\n   pt = pd0->rfs;\n   rc = 0;\n   while (*pt++ = *ps++);\n\n/*   Testing of expressions and operators is quite complicated,\n     because (a) problems are apt to surface in queer combinations\n     of operators and operands, rather than in isolation,\n     and (b) the number of expressions needed to provoke a case\n     of improper behaviour may be quite large. Hence, we take the\n     following approach: for this section, and for subsequent\n     sections through 7.15, we will check the primitive operations\n     in isolation, thus verifying that the primitives work,\n     after a fashion. The job of testing combinations, we will\n     leave to a separate, machine-generated program, to be included\n     in the C test package at some later date.\n                                                                */\n\n/*   A string is a primary expression. The identifier points to\n     the first character of a string.\n                                                                  */\n\n   if(*\"queep\" != q){\n     rc = rc+1;\n     if(pd0->flgd  != 0) printf(s71er,1);\n   }\n/*   A parenthesized expression is a primary expression whose\n     type and value are the same as those of the unadorned\n     expression.\n                                                                */\n   if((2+3) != 2+3) {\n     rc = rc+2;\n     if(pd0->flgd != 0) printf(s71er,2);\n   }\n\n/*   A primary expression followed by an expression in square \n     brackets is a primary expression. The intuitive meaning is\n     that of a subscript. The expression E1[E2] is identical\n     (by definition) to *((E1)+(E2)).\n                                                                */\n\n   x[5] = 1942;\n   if(x[5] != 1942 || x[5] != *((x)+(5))){\n     rc = rc+4;\n     if(pd0->flgd != 0) printf(s71er,4);\n   }\n\n/*   If the various flavors of function calls didn't work, we\n     would never have gotten this far; however, we do need to \n     show that functions can be recursive...\n                                                               */\n\n   if ( McCarthy(-5) != 91){\n     rc = rc+8;\n     if(pd0->flgd != 0) printf(s71er,8);\n   }\n\n/*   and that argument passing is strictly by value.           */\n\n   a = 2;\n   b = 3;\n   p = &b;\n\n   clobber(a,p);\n\n   if(a != 2 || b != 2){\n     rc = rc+16;\n     if(pd0->flgd != 0) printf(s71er,16);\n   }\n\n/*   Finally, structures and unions are addressed thusly:      */\n\n   if(pd0->dprec != (*pd0).dprec){\n     rc = rc+32;\n     if(pd0->flgd != 0) printf(s71er,32);\n   }\n\n   return rc;\n}\nMcCarthy(x)\nint x;\n{\n   if(x>100) return x-10;\n   else return McCarthy( McCarthy(x+11));\n}\nclobber(x,y)\nint x, *y;\n{\n   x = 3;\n   *y = 2;\n}\ns714(pd0)          /*  7.14  Assignment operators       */\nstruct defs *pd0;\n{\n   static char f[] = \"Local error %d.\\n\";\n   static char s714er[] = \"s714,er%d\\n\";\n   static char qs714[8] = \"s714   \";\n   register int prlc, lrc;\n   int rc;\n   char cl, cr;\n   short sl, sr;\n   int il, ir;\n   long ll, lr;\n   unsigned ul, ur;\n   float fl, fr;\n   double dl, dr;\n   char *ps, *pt;\n   ps = qs714;\n   pt = pd0->rfs;\n   rc = 0;\n   lrc = 0;\n   prlc = pd0->flgl;\n   while (*pt++ = *ps++);\n\n        /* This section tests the assignment operators.\n\n        It is an exhaustive test of all assignment statements\n        of the form:\n\n                vl op vr\n\n        where vl and vr are variables from the set\n        {char,short,int,long,unsigned,float,double} and op is\n        one of the assignment operators. There are 395 such\n        statements.\n\n        The initial values for the variables have been chosen\n        so that both the initial values and the results will\n        \"fit\" in just about any implementation, and that the re-\n        sults will be such that they test for the proper form-\n        ation of composite operators, rather than checking for\n        the valid operation of those operators' components.\n        For example, in checking >>=, we want to verify that\n        a right shift and a move take place, rather than\n        whether or not there may be some peculiarities about\n        the right shift. Such tests have been made previously,\n        and to repeat them here would be to throw out a red\n        herring.\n\n        The table below lists the operators, assignment targets,\n        initial values for left and right operands, and the\n        expected values of the results.\n\n\n          =  +=  -=  *=  /=  %=  >>=  <<=  &=  ^=  |=\t\nchar      2   7   3  10   2   1   1    20   8   6  14\nshort     2   7   3  10   2   1   1    20   8   6  14\nint       2   7   3  10   2   1   1    20   8   6  14\nlong      2   7   3  10   2   1   1    20   8   6  14\nunsigned  2   7   3  10   2   1   1    20   8   6  14\nfloat     2   7   3  10 2.5 |             |\ndouble    2   7   3  10 2.5 |             |\n                            |             |\ninitial         (5,2)       |    (5,2)    |  (12,10)\n\n        The following machine-generated program reflects the\n        tests described in the table.\n                                                                */\n\n   cl = 5; cr = 2;\n   cl = cr;\n   if(cl != 2){\n     lrc = 1;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; sr = 2;\n   cl = sr;\n   if(cl != 2){\n     lrc = 2;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; ir = 2;\n   cl = ir;\n   if(cl != 2){\n     lrc = 3;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; lr = 2;\n   cl = lr;\n   if(cl != 2){\n     lrc = 4;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; ur = 2;\n   cl = ur;\n   if(cl != 2){\n     lrc = 5;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; fr = 2;\n   cl = fr;\n   if(cl != 2){\n     lrc = 6;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; dr = 2;\n   cl = dr;\n   if(cl != 2){\n     lrc = 7;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; cr = 2;\n   sl = cr;\n   if(sl != 2){\n     lrc = 8;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; sr = 2;\n   sl = sr;\n   if(sl != 2){\n     lrc = 9;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; ir = 2;\n   sl = ir;\n   if(sl != 2){\n     lrc = 10;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; lr = 2;\n   sl = lr;\n   if(sl != 2){\n     lrc = 11;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; ur = 2;\n   sl = ur;\n   if(sl != 2){\n     lrc = 12;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; fr = 2;\n   sl = fr;\n   if(sl != 2){\n     lrc = 13;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; dr = 2;\n   sl = dr;\n   if(sl != 2){\n     lrc = 14;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; cr = 2;\n   il = cr;\n   if(il != 2){\n     lrc = 15;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; sr = 2;\n   il = sr;\n   if(il != 2){\n     lrc = 16;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; ir = 2;\n   il = ir;\n   if(il != 2){\n     lrc = 17;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; lr = 2;\n   il = lr;\n   if(il != 2){\n     lrc = 18;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; ur = 2;\n   il = ur;\n   if(il != 2){\n     lrc = 19;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; fr = 2;\n   il = fr;\n   if(il != 2){\n     lrc = 20;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; dr = 2;\n   il = dr;\n   if(il != 2){\n     lrc = 21;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; cr = 2;\n   ll = cr;\n   if(ll != 2){\n     lrc = 22;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; sr = 2;\n   ll = sr;\n   if(ll != 2){\n     lrc = 23;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; ir = 2;\n   ll = ir;\n   if(ll != 2){\n     lrc = 24;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; lr = 2;\n   ll = lr;\n   if(ll != 2){\n     lrc = 25;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; ur = 2;\n   ll = ur;\n   if(ll != 2){\n     lrc = 26;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; fr = 2;\n   ll = fr;\n   if(ll != 2){\n     lrc = 27;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; dr = 2;\n   ll = dr;\n   if(ll != 2){\n     lrc = 28;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; cr = 2;\n   ul = cr;\n   if(ul != 2){\n     lrc = 29;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; sr = 2;\n   ul = sr;\n   if(ul != 2){\n     lrc = 30;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; ir = 2;\n   ul = ir;\n   if(ul != 2){\n     lrc = 31;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; lr = 2;\n   ul = lr;\n   if(ul != 2){\n     lrc = 32;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; ur = 2;\n   ul = ur;\n   if(ul != 2){\n     lrc = 33;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; fr = 2;\n   ul = fr;\n   if(ul != 2){\n     lrc = 34;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; dr = 2;\n   ul = dr;\n   if(ul != 2){\n     lrc = 35;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; cr = 2;\n   fl = cr;\n   if(fl != 2){\n     lrc = 36;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; sr = 2;\n   fl = sr;\n   if(fl != 2){\n     lrc = 37;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; ir = 2;\n   fl = ir;\n   if(fl != 2){\n     lrc = 38;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; lr = 2;\n   fl = lr;\n   if(fl != 2){\n     lrc = 39;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; ur = 2;\n   fl = ur;\n   if(fl != 2){\n     lrc = 40;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; fr = 2;\n   fl = fr;\n   if(fl != 2){\n     lrc = 41;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; dr = 2;\n   fl = dr;\n   if(fl != 2){\n     lrc = 42;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; cr = 2;\n   dl = cr;\n   if(dl != 2){\n     lrc = 43;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; sr = 2;\n   dl = sr;\n   if(dl != 2){\n     lrc = 44;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; ir = 2;\n   dl = ir;\n   if(dl != 2){\n     lrc = 45;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; lr = 2;\n   dl = lr;\n   if(dl != 2){\n     lrc = 46;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; ur = 2;\n   dl = ur;\n   if(dl != 2){\n     lrc = 47;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; fr = 2;\n   dl = fr;\n   if(dl != 2){\n     lrc = 48;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; dr = 2;\n   dl = dr;\n   if(dl != 2){\n     lrc = 49;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; cr = 2;\n   cl += cr;\n   if(cl != 7){\n     lrc = 50;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; sr = 2;\n   cl += sr;\n   if(cl != 7){\n     lrc = 51;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; ir = 2;\n   cl += ir;\n   if(cl != 7){\n     lrc = 52;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; lr = 2;\n   cl += lr;\n   if(cl != 7){\n     lrc = 53;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; ur = 2;\n   cl += ur;\n   if(cl != 7){\n     lrc = 54;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; fr = 2;\n   cl += fr;\n   if(cl != 7){\n     lrc = 55;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; dr = 2;\n   cl += dr;\n   if(cl != 7){\n     lrc = 56;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; cr = 2;\n   sl += cr;\n   if(sl != 7){\n     lrc = 57;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; sr = 2;\n   sl += sr;\n   if(sl != 7){\n     lrc = 58;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; ir = 2;\n   sl += ir;\n   if(sl != 7){\n     lrc = 59;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; lr = 2;\n   sl += lr;\n   if(sl != 7){\n     lrc = 60;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; ur = 2;\n   sl += ur;\n   if(sl != 7){\n     lrc = 61;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; fr = 2;\n   sl += fr;\n   if(sl != 7){\n     lrc = 62;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; dr = 2;\n   sl += dr;\n   if(sl != 7){\n     lrc = 63;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; cr = 2;\n   il += cr;\n   if(il != 7){\n     lrc = 64;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; sr = 2;\n   il += sr;\n   if(il != 7){\n     lrc = 65;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; ir = 2;\n   il += ir;\n   if(il != 7){\n     lrc = 66;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; lr = 2;\n   il += lr;\n   if(il != 7){\n     lrc = 67;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; ur = 2;\n   il += ur;\n   if(il != 7){\n     lrc = 68;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; fr = 2;\n   il += fr;\n   if(il != 7){\n     lrc = 69;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; dr = 2;\n   il += dr;\n   if(il != 7){\n     lrc = 70;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; cr = 2;\n   ll += cr;\n   if(ll != 7){\n     lrc = 71;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; sr = 2;\n   ll += sr;\n   if(ll != 7){\n     lrc = 72;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; ir = 2;\n   ll += ir;\n   if(ll != 7){\n     lrc = 73;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; lr = 2;\n   ll += lr;\n   if(ll != 7){\n     lrc = 74;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; ur = 2;\n   ll += ur;\n   if(ll != 7){\n     lrc = 75;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; fr = 2;\n   ll += fr;\n   if(ll != 7){\n     lrc = 76;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; dr = 2;\n   ll += dr;\n   if(ll != 7){\n     lrc = 77;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; cr = 2;\n   ul += cr;\n   if(ul != 7){\n     lrc = 78;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; sr = 2;\n   ul += sr;\n   if(ul != 7){\n     lrc = 79;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; ir = 2;\n   ul += ir;\n   if(ul != 7){\n     lrc = 80;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; lr = 2;\n   ul += lr;\n   if(ul != 7){\n     lrc = 81;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; ur = 2;\n   ul += ur;\n   if(ul != 7){\n     lrc = 82;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; fr = 2;\n   ul += fr;\n   if(ul != 7){\n     lrc = 83;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; dr = 2;\n   ul += dr;\n   if(ul != 7){\n     lrc = 84;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; cr = 2;\n   fl += cr;\n   if(fl != 7){\n     lrc = 85;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; sr = 2;\n   fl += sr;\n   if(fl != 7){\n     lrc = 86;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; ir = 2;\n   fl += ir;\n   if(fl != 7){\n     lrc = 87;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; lr = 2;\n   fl += lr;\n   if(fl != 7){\n     lrc = 88;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; ur = 2;\n   fl += ur;\n   if(fl != 7){\n     lrc = 89;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; fr = 2;\n   fl += fr;\n   if(fl != 7){\n     lrc = 90;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; dr = 2;\n   fl += dr;\n   if(fl != 7){\n     lrc = 91;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; cr = 2;\n   dl += cr;\n   if(dl != 7){\n     lrc = 92;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; sr = 2;\n   dl += sr;\n   if(dl != 7){\n     lrc = 93;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; ir = 2;\n   dl += ir;\n   if(dl != 7){\n     lrc = 94;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; lr = 2;\n   dl += lr;\n   if(dl != 7){\n     lrc = 95;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; ur = 2;\n   dl += ur;\n   if(dl != 7){\n     lrc = 96;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; fr = 2;\n   dl += fr;\n   if(dl != 7){\n     lrc = 97;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; dr = 2;\n   dl += dr;\n   if(dl != 7){\n     lrc = 98;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; cr = 2;\n   cl -= cr;\n   if(cl != 3){\n     lrc = 99;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; sr = 2;\n   cl -= sr;\n   if(cl != 3){\n     lrc = 100;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; ir = 2;\n   cl -= ir;\n   if(cl != 3){\n     lrc = 101;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; lr = 2;\n   cl -= lr;\n   if(cl != 3){\n     lrc = 102;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; ur = 2;\n   cl -= ur;\n   if(cl != 3){\n     lrc = 103;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; fr = 2;\n   cl -= fr;\n   if(cl != 3){\n     lrc = 104;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; dr = 2;\n   cl -= dr;\n   if(cl != 3){\n     lrc = 105;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; cr = 2;\n   sl -= cr;\n   if(sl != 3){\n     lrc = 106;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; sr = 2;\n   sl -= sr;\n   if(sl != 3){\n     lrc = 107;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; ir = 2;\n   sl -= ir;\n   if(sl != 3){\n     lrc = 108;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; lr = 2;\n   sl -= lr;\n   if(sl != 3){\n     lrc = 109;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; ur = 2;\n   sl -= ur;\n   if(sl != 3){\n     lrc = 110;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; fr = 2;\n   sl -= fr;\n   if(sl != 3){\n     lrc = 111;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; dr = 2;\n   sl -= dr;\n   if(sl != 3){\n     lrc = 112;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; cr = 2;\n   il -= cr;\n   if(il != 3){\n     lrc = 113;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; sr = 2;\n   il -= sr;\n   if(il != 3){\n     lrc = 114;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; ir = 2;\n   il -= ir;\n   if(il != 3){\n     lrc = 115;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; lr = 2;\n   il -= lr;\n   if(il != 3){\n     lrc = 116;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; ur = 2;\n   il -= ur;\n   if(il != 3){\n     lrc = 117;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; fr = 2;\n   il -= fr;\n   if(il != 3){\n     lrc = 118;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; dr = 2;\n   il -= dr;\n   if(il != 3){\n     lrc = 119;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; cr = 2;\n   ll -= cr;\n   if(ll != 3){\n     lrc = 120;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; sr = 2;\n   ll -= sr;\n   if(ll != 3){\n     lrc = 121;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; ir = 2;\n   ll -= ir;\n   if(ll != 3){\n     lrc = 122;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; lr = 2;\n   ll -= lr;\n   if(ll != 3){\n     lrc = 123;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; ur = 2;\n   ll -= ur;\n   if(ll != 3){\n     lrc = 124;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; fr = 2;\n   ll -= fr;\n   if(ll != 3){\n     lrc = 125;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; dr = 2;\n   ll -= dr;\n   if(ll != 3){\n     lrc = 126;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; cr = 2;\n   ul -= cr;\n   if(ul != 3){\n     lrc = 127;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; sr = 2;\n   ul -= sr;\n   if(ul != 3){\n     lrc = 128;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; ir = 2;\n   ul -= ir;\n   if(ul != 3){\n     lrc = 129;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; lr = 2;\n   ul -= lr;\n   if(ul != 3){\n     lrc = 130;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; ur = 2;\n   ul -= ur;\n   if(ul != 3){\n     lrc = 131;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; fr = 2;\n   ul -= fr;\n   if(ul != 3){\n     lrc = 132;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; dr = 2;\n   ul -= dr;\n   if(ul != 3){\n     lrc = 133;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; cr = 2;\n   fl -= cr;\n   if(fl != 3){\n     lrc = 134;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; sr = 2;\n   fl -= sr;\n   if(fl != 3){\n     lrc = 135;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; ir = 2;\n   fl -= ir;\n   if(fl != 3){\n     lrc = 136;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; lr = 2;\n   fl -= lr;\n   if(fl != 3){\n     lrc = 137;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; ur = 2;\n   fl -= ur;\n   if(fl != 3){\n     lrc = 138;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; fr = 2;\n   fl -= fr;\n   if(fl != 3){\n     lrc = 139;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; dr = 2;\n   fl -= dr;\n   if(fl != 3){\n     lrc = 140;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; cr = 2;\n   dl -= cr;\n   if(dl != 3){\n     lrc = 141;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; sr = 2;\n   dl -= sr;\n   if(dl != 3){\n     lrc = 142;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; ir = 2;\n   dl -= ir;\n   if(dl != 3){\n     lrc = 143;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; lr = 2;\n   dl -= lr;\n   if(dl != 3){\n     lrc = 144;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; ur = 2;\n   dl -= ur;\n   if(dl != 3){\n     lrc = 145;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; fr = 2;\n   dl -= fr;\n   if(dl != 3){\n     lrc = 146;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; dr = 2;\n   dl -= dr;\n   if(dl != 3){\n     lrc = 147;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; cr = 2;\n   cl *= cr;\n   if(cl != 10){\n     lrc = 148;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; sr = 2;\n   cl *= sr;\n   if(cl != 10){\n     lrc = 149;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; ir = 2;\n   cl *= ir;\n   if(cl != 10){\n     lrc = 150;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; lr = 2;\n   cl *= lr;\n   if(cl != 10){\n     lrc = 151;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; ur = 2;\n   cl *= ur;\n   if(cl != 10){\n     lrc = 152;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; fr = 2;\n   cl *= fr;\n   if(cl != 10){\n     lrc = 153;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; dr = 2;\n   cl *= dr;\n   if(cl != 10){\n     lrc = 154;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; cr = 2;\n   sl *= cr;\n   if(sl != 10){\n     lrc = 155;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; sr = 2;\n   sl *= sr;\n   if(sl != 10){\n     lrc = 156;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; ir = 2;\n   sl *= ir;\n   if(sl != 10){\n     lrc = 157;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; lr = 2;\n   sl *= lr;\n   if(sl != 10){\n     lrc = 158;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; ur = 2;\n   sl *= ur;\n   if(sl != 10){\n     lrc = 159;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; fr = 2;\n   sl *= fr;\n   if(sl != 10){\n     lrc = 160;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; dr = 2;\n   sl *= dr;\n   if(sl != 10){\n     lrc = 161;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; cr = 2;\n   il *= cr;\n   if(il != 10){\n     lrc = 162;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; sr = 2;\n   il *= sr;\n   if(il != 10){\n     lrc = 163;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; ir = 2;\n   il *= ir;\n   if(il != 10){\n     lrc = 164;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; lr = 2;\n   il *= lr;\n   if(il != 10){\n     lrc = 165;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; ur = 2;\n   il *= ur;\n   if(il != 10){\n     lrc = 166;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; fr = 2;\n   il *= fr;\n   if(il != 10){\n     lrc = 167;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; dr = 2;\n   il *= dr;\n   if(il != 10){\n     lrc = 168;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; cr = 2;\n   ll *= cr;\n   if(ll != 10){\n     lrc = 169;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; sr = 2;\n   ll *= sr;\n   if(ll != 10){\n     lrc = 170;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; ir = 2;\n   ll *= ir;\n   if(ll != 10){\n     lrc = 171;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; lr = 2;\n   ll *= lr;\n   if(ll != 10){\n     lrc = 172;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; ur = 2;\n   ll *= ur;\n   if(ll != 10){\n     lrc = 173;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; fr = 2;\n   ll *= fr;\n   if(ll != 10){\n     lrc = 174;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; dr = 2;\n   ll *= dr;\n   if(ll != 10){\n     lrc = 175;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; cr = 2;\n   ul *= cr;\n   if(ul != 10){\n     lrc = 176;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; sr = 2;\n   ul *= sr;\n   if(ul != 10){\n     lrc = 177;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; ir = 2;\n   ul *= ir;\n   if(ul != 10){\n     lrc = 178;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; lr = 2;\n   ul *= lr;\n   if(ul != 10){\n     lrc = 179;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; ur = 2;\n   ul *= ur;\n   if(ul != 10){\n     lrc = 180;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; fr = 2;\n   ul *= fr;\n   if(ul != 10){\n     lrc = 181;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; dr = 2;\n   ul *= dr;\n   if(ul != 10){\n     lrc = 182;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; cr = 2;\n   fl *= cr;\n   if(fl != 10){\n     lrc = 183;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; sr = 2;\n   fl *= sr;\n   if(fl != 10){\n     lrc = 184;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; ir = 2;\n   fl *= ir;\n   if(fl != 10){\n     lrc = 185;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; lr = 2;\n   fl *= lr;\n   if(fl != 10){\n     lrc = 186;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; ur = 2;\n   fl *= ur;\n   if(fl != 10){\n     lrc = 187;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; fr = 2;\n   fl *= fr;\n   if(fl != 10){\n     lrc = 188;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; dr = 2;\n   fl *= dr;\n   if(fl != 10){\n     lrc = 189;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; cr = 2;\n   dl *= cr;\n   if(dl != 10){\n     lrc = 190;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; sr = 2;\n   dl *= sr;\n   if(dl != 10){\n     lrc = 191;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; ir = 2;\n   dl *= ir;\n   if(dl != 10){\n     lrc = 192;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; lr = 2;\n   dl *= lr;\n   if(dl != 10){\n     lrc = 193;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; ur = 2;\n   dl *= ur;\n   if(dl != 10){\n     lrc = 194;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; fr = 2;\n   dl *= fr;\n   if(dl != 10){\n     lrc = 195;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; dr = 2;\n   dl *= dr;\n   if(dl != 10){\n     lrc = 196;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; cr = 2;\n   cl /= cr;\n   if(cl != 2){\n     lrc = 197;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; sr = 2;\n   cl /= sr;\n   if(cl != 2){\n     lrc = 198;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; ir = 2;\n   cl /= ir;\n   if(cl != 2){\n     lrc = 199;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; lr = 2;\n   cl /= lr;\n   if(cl != 2){\n     lrc = 200;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; ur = 2;\n   cl /= ur;\n   if(cl != 2){\n     lrc = 201;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; fr = 2;\n   cl /= fr;\n   if(cl != 2){\n     lrc = 202;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; dr = 2;\n   cl /= dr;\n   if(cl != 2){\n     lrc = 203;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; cr = 2;\n   sl /= cr;\n   if(sl != 2){\n     lrc = 204;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; sr = 2;\n   sl /= sr;\n   if(sl != 2){\n     lrc = 205;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; ir = 2;\n   sl /= ir;\n   if(sl != 2){\n     lrc = 206;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; lr = 2;\n   sl /= lr;\n   if(sl != 2){\n     lrc = 207;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; ur = 2;\n   sl /= ur;\n   if(sl != 2){\n     lrc = 208;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; fr = 2;\n   sl /= fr;\n   if(sl != 2){\n     lrc = 209;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; dr = 2;\n   sl /= dr;\n   if(sl != 2){\n     lrc = 210;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; cr = 2;\n   il /= cr;\n   if(il != 2){\n     lrc = 211;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; sr = 2;\n   il /= sr;\n   if(il != 2){\n     lrc = 212;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; ir = 2;\n   il /= ir;\n   if(il != 2){\n     lrc = 213;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; lr = 2;\n   il /= lr;\n   if(il != 2){\n     lrc = 214;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; ur = 2;\n   il /= ur;\n   if(il != 2){\n     lrc = 215;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; fr = 2;\n   il /= fr;\n   if(il != 2){\n     lrc = 216;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; dr = 2;\n   il /= dr;\n   if(il != 2){\n     lrc = 217;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; cr = 2;\n   ll /= cr;\n   if(ll != 2){\n     lrc = 218;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; sr = 2;\n   ll /= sr;\n   if(ll != 2){\n     lrc = 219;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; ir = 2;\n   ll /= ir;\n   if(ll != 2){\n     lrc = 220;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; lr = 2;\n   ll /= lr;\n   if(ll != 2){\n     lrc = 221;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; ur = 2;\n   ll /= ur;\n   if(ll != 2){\n     lrc = 222;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; fr = 2;\n   ll /= fr;\n   if(ll != 2){\n     lrc = 223;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; dr = 2;\n   ll /= dr;\n   if(ll != 2){\n     lrc = 224;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; cr = 2;\n   ul /= cr;\n   if(ul != 2){\n     lrc = 225;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; sr = 2;\n   ul /= sr;\n   if(ul != 2){\n     lrc = 226;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; ir = 2;\n   ul /= ir;\n   if(ul != 2){\n     lrc = 227;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; lr = 2;\n   ul /= lr;\n   if(ul != 2){\n     lrc = 228;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; ur = 2;\n   ul /= ur;\n   if(ul != 2){\n     lrc = 229;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; fr = 2;\n   ul /= fr;\n   if(ul != 2){\n     lrc = 230;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; dr = 2;\n   ul /= dr;\n   if(ul != 2){\n     lrc = 231;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; cr = 2;\n   fl /= cr;\n   if(fl != 2.5){\n     lrc = 232;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; sr = 2;\n   fl /= sr;\n   if(fl != 2.5){\n     lrc = 233;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; ir = 2;\n   fl /= ir;\n   if(fl != 2.5){\n     lrc = 234;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; lr = 2;\n   fl /= lr;\n   if(fl != 2.5){\n     lrc = 235;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; ur = 2;\n   fl /= ur;\n   if(fl != 2.5){\n     lrc = 236;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; fr = 2;\n   fl /= fr;\n   if(fl != 2.5){\n     lrc = 237;\n     if(prlc) printf(f,lrc);\n   }\n   fl = 5; dr = 2;\n   fl /= dr;\n   if(fl != 2.5){\n     lrc = 238;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; cr = 2;\n   dl /= cr;\n   if(dl != 2.5){\n     lrc = 239;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; sr = 2;\n   dl /= sr;\n   if(dl != 2.5){\n     lrc = 240;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; ir = 2;\n   dl /= ir;\n   if(dl != 2.5){\n     lrc = 241;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; lr = 2;\n   dl /= lr;\n   if(dl != 2.5){\n     lrc = 242;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; ur = 2;\n   dl /= ur;\n   if(dl != 2.5){\n     lrc = 243;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; fr = 2;\n   dl /= fr;\n   if(dl != 2.5){\n     lrc = 244;\n     if(prlc) printf(f,lrc);\n   }\n   dl = 5; dr = 2;\n   dl /= dr;\n   if(dl != 2.5){\n     lrc = 245;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; cr = 2;\n   cl %= cr;\n   if(cl != 1){\n     lrc = 246;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; sr = 2;\n   cl %= sr;\n   if(cl != 1){\n     lrc = 247;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; ir = 2;\n   cl %= ir;\n   if(cl != 1){\n     lrc = 248;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; lr = 2;\n   cl %= lr;\n   if(cl != 1){\n     lrc = 249;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; ur = 2;\n   cl %= ur;\n   if(cl != 1){\n     lrc = 250;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; cr = 2;\n   sl %= cr;\n   if(sl != 1){\n     lrc = 251;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; sr = 2;\n   sl %= sr;\n   if(sl != 1){\n     lrc = 252;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; ir = 2;\n   sl %= ir;\n   if(sl != 1){\n     lrc = 253;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; lr = 2;\n   sl %= lr;\n   if(sl != 1){\n     lrc = 254;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; ur = 2;\n   sl %= ur;\n   if(sl != 1){\n     lrc = 255;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; cr = 2;\n   il %= cr;\n   if(il != 1){\n     lrc = 256;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; sr = 2;\n   il %= sr;\n   if(il != 1){\n     lrc = 257;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; ir = 2;\n   il %= ir;\n   if(il != 1){\n     lrc = 258;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; lr = 2;\n   il %= lr;\n   if(il != 1){\n     lrc = 259;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; ur = 2;\n   il %= ur;\n   if(il != 1){\n     lrc = 260;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; cr = 2;\n   ll %= cr;\n   if(ll != 1){\n     lrc = 261;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; sr = 2;\n   ll %= sr;\n   if(ll != 1){\n     lrc = 262;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; ir = 2;\n   ll %= ir;\n   if(ll != 1){\n     lrc = 263;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; lr = 2;\n   ll %= lr;\n   if(ll != 1){\n     lrc = 264;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; ur = 2;\n   ll %= ur;\n   if(ll != 1){\n     lrc = 265;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; cr = 2;\n   ul %= cr;\n   if(ul != 1){\n     lrc = 266;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; sr = 2;\n   ul %= sr;\n   if(ul != 1){\n     lrc = 267;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; ir = 2;\n   ul %= ir;\n   if(ul != 1){\n     lrc = 268;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; lr = 2;\n   ul %= lr;\n   if(ul != 1){\n     lrc = 269;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; ur = 2;\n   ul %= ur;\n   if(ul != 1){\n     lrc = 270;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; cr = 2;\n   cl >>= cr;\n   if(cl != 1){\n     lrc = 271;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; sr = 2;\n   cl >>= sr;\n   if(cl != 1){\n     lrc = 272;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; ir = 2;\n   cl >>= ir;\n   if(cl != 1){\n     lrc = 273;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; lr = 2;\n   cl >>= lr;\n   if(cl != 1){\n     lrc = 274;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; ur = 2;\n   cl >>= ur;\n   if(cl != 1){\n     lrc = 275;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; cr = 2;\n   sl >>= cr;\n   if(sl != 1){\n     lrc = 276;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; sr = 2;\n   sl >>= sr;\n   if(sl != 1){\n     lrc = 277;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; ir = 2;\n   sl >>= ir;\n   if(sl != 1){\n     lrc = 278;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; lr = 2;\n   sl >>= lr;\n   if(sl != 1){\n     lrc = 279;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; ur = 2;\n   sl >>= ur;\n   if(sl != 1){\n     lrc = 280;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; cr = 2;\n   il >>= cr;\n   if(il != 1){\n     lrc = 281;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; sr = 2;\n   il >>= sr;\n   if(il != 1){\n     lrc = 282;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; ir = 2;\n   il >>= ir;\n   if(il != 1){\n     lrc = 283;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; lr = 2;\n   il >>= lr;\n   if(il != 1){\n     lrc = 284;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; ur = 2;\n   il >>= ur;\n   if(il != 1){\n     lrc = 285;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; cr = 2;\n   ll >>= cr;\n   if(ll != 1){\n     lrc = 286;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; sr = 2;\n   ll >>= sr;\n   if(ll != 1){\n     lrc = 287;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; ir = 2;\n   ll >>= ir;\n   if(ll != 1){\n     lrc = 288;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; lr = 2;\n   ll >>= lr;\n   if(ll != 1){\n     lrc = 289;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; ur = 2;\n   ll >>= ur;\n   if(ll != 1){\n     lrc = 290;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; cr = 2;\n   ul >>= cr;\n   if(ul != 1){\n     lrc = 291;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; sr = 2;\n   ul >>= sr;\n   if(ul != 1){\n     lrc = 292;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; ir = 2;\n   ul >>= ir;\n   if(ul != 1){\n     lrc = 293;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; lr = 2;\n   ul >>= lr;\n   if(ul != 1){\n     lrc = 294;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; ur = 2;\n   ul >>= ur;\n   if(ul != 1){\n     lrc = 295;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; cr = 2;\n   cl <<= cr;\n   if(cl != 20){\n     lrc = 296;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; sr = 2;\n   cl <<= sr;\n   if(cl != 20){\n     lrc = 297;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; ir = 2;\n   cl <<= ir;\n   if(cl != 20){\n     lrc = 298;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; lr = 2;\n   cl <<= lr;\n   if(cl != 20){\n     lrc = 299;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 5; ur = 2;\n   cl <<= ur;\n   if(cl != 20){\n     lrc = 300;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; cr = 2;\n   sl <<= cr;\n   if(sl != 20){\n     lrc = 301;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; sr = 2;\n   sl <<= sr;\n   if(sl != 20){\n     lrc = 302;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; ir = 2;\n   sl <<= ir;\n   if(sl != 20){\n     lrc = 303;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; lr = 2;\n   sl <<= lr;\n   if(sl != 20){\n     lrc = 304;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 5; ur = 2;\n   sl <<= ur;\n   if(sl != 20){\n     lrc = 305;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; cr = 2;\n   il <<= cr;\n   if(il != 20){\n     lrc = 306;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; sr = 2;\n   il <<= sr;\n   if(il != 20){\n     lrc = 307;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; ir = 2;\n   il <<= ir;\n   if(il != 20){\n     lrc = 308;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; lr = 2;\n   il <<= lr;\n   if(il != 20){\n     lrc = 309;\n     if(prlc) printf(f,lrc);\n   }\n   il = 5; ur = 2;\n   il <<= ur;\n   if(il != 20){\n     lrc = 310;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; cr = 2;\n   ll <<= cr;\n   if(ll != 20){\n     lrc = 311;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; sr = 2;\n   ll <<= sr;\n   if(ll != 20){\n     lrc = 312;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; ir = 2;\n   ll <<= ir;\n   if(ll != 20){\n     lrc = 313;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; lr = 2;\n   ll <<= lr;\n   if(ll != 20){\n     lrc = 314;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 5; ur = 2;\n   ll <<= ur;\n   if(ll != 20){\n     lrc = 315;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; cr = 2;\n   ul <<= cr;\n   if(ul != 20){\n     lrc = 316;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; sr = 2;\n   ul <<= sr;\n   if(ul != 20){\n     lrc = 317;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; ir = 2;\n   ul <<= ir;\n   if(ul != 20){\n     lrc = 318;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; lr = 2;\n   ul <<= lr;\n   if(ul != 20){\n     lrc = 319;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 5; ur = 2;\n   ul <<= ur;\n   if(ul != 20){\n     lrc = 320;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 12; cr = 10;\n   cl &= cr;\n   if(cl != 8){\n     lrc = 321;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 12; sr = 10;\n   cl &= sr;\n   if(cl != 8){\n     lrc = 322;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 12; ir = 10;\n   cl &= ir;\n   if(cl != 8){\n     lrc = 323;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 12; lr = 10;\n   cl &= lr;\n   if(cl != 8){\n     lrc = 324;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 12; ur = 10;\n   cl &= ur;\n   if(cl != 8){\n     lrc = 325;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 12; cr = 10;\n   sl &= cr;\n   if(sl != 8){\n     lrc = 326;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 12; sr = 10;\n   sl &= sr;\n   if(sl != 8){\n     lrc = 327;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 12; ir = 10;\n   sl &= ir;\n   if(sl != 8){\n     lrc = 328;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 12; lr = 10;\n   sl &= lr;\n   if(sl != 8){\n     lrc = 329;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 12; ur = 10;\n   sl &= ur;\n   if(sl != 8){\n     lrc = 330;\n     if(prlc) printf(f,lrc);\n   }\n   il = 12; cr = 10;\n   il &= cr;\n   if(il != 8){\n     lrc = 331;\n     if(prlc) printf(f,lrc);\n   }\n   il = 12; sr = 10;\n   il &= sr;\n   if(il != 8){\n     lrc = 332;\n     if(prlc) printf(f,lrc);\n   }\n   il = 12; ir = 10;\n   il &= ir;\n   if(il != 8){\n     lrc = 333;\n     if(prlc) printf(f,lrc);\n   }\n   il = 12; lr = 10;\n   il &= lr;\n   if(il != 8){\n     lrc = 334;\n     if(prlc) printf(f,lrc);\n   }\n   il = 12; ur = 10;\n   il &= ur;\n   if(il != 8){\n     lrc = 335;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 12; cr = 10;\n   ll &= cr;\n   if(ll != 8){\n     lrc = 336;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 12; sr = 10;\n   ll &= sr;\n   if(ll != 8){\n     lrc = 337;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 12; ir = 10;\n   ll &= ir;\n   if(ll != 8){\n     lrc = 338;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 12; lr = 10;\n   ll &= lr;\n   if(ll != 8){\n     lrc = 339;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 12; ur = 10;\n   ll &= ur;\n   if(ll != 8){\n     lrc = 340;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 12; cr = 10;\n   ul &= cr;\n   if(ul != 8){\n     lrc = 341;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 12; sr = 10;\n   ul &= sr;\n   if(ul != 8){\n     lrc = 342;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 12; ir = 10;\n   ul &= ir;\n   if(ul != 8){\n     lrc = 343;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 12; lr = 10;\n   ul &= lr;\n   if(ul != 8){\n     lrc = 344;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 12; ur = 10;\n   ul &= ur;\n   if(ul != 8){\n     lrc = 345;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 12; cr = 10;\n   cl ^= cr;\n   if(cl != 6){\n     lrc = 346;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 12; sr = 10;\n   cl ^= sr;\n   if(cl != 6){\n     lrc = 347;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 12; ir = 10;\n   cl ^= ir;\n   if(cl != 6){\n     lrc = 348;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 12; lr = 10;\n   cl ^= lr;\n   if(cl != 6){\n     lrc = 349;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 12; ur = 10;\n   cl ^= ur;\n   if(cl != 6){\n     lrc = 350;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 12; cr = 10;\n   sl ^= cr;\n   if(sl != 6){\n     lrc = 351;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 12; sr = 10;\n   sl ^= sr;\n   if(sl != 6){\n     lrc = 352;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 12; ir = 10;\n   sl ^= ir;\n   if(sl != 6){\n     lrc = 353;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 12; lr = 10;\n   sl ^= lr;\n   if(sl != 6){\n     lrc = 354;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 12; ur = 10;\n   sl ^= ur;\n   if(sl != 6){\n     lrc = 355;\n     if(prlc) printf(f,lrc);\n   }\n   il = 12; cr = 10;\n   il ^= cr;\n   if(il != 6){\n     lrc = 356;\n     if(prlc) printf(f,lrc);\n   }\n   il = 12; sr = 10;\n   il ^= sr;\n   if(il != 6){\n     lrc = 357;\n     if(prlc) printf(f,lrc);\n   }\n   il = 12; ir = 10;\n   il ^= ir;\n   if(il != 6){\n     lrc = 358;\n     if(prlc) printf(f,lrc);\n   }\n   il = 12; lr = 10;\n   il ^= lr;\n   if(il != 6){\n     lrc = 359;\n     if(prlc) printf(f,lrc);\n   }\n   il = 12; ur = 10;\n   il ^= ur;\n   if(il != 6){\n     lrc = 360;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 12; cr = 10;\n   ll ^= cr;\n   if(ll != 6){\n     lrc = 361;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 12; sr = 10;\n   ll ^= sr;\n   if(ll != 6){\n     lrc = 362;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 12; ir = 10;\n   ll ^= ir;\n   if(ll != 6){\n     lrc = 363;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 12; lr = 10;\n   ll ^= lr;\n   if(ll != 6){\n     lrc = 364;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 12; ur = 10;\n   ll ^= ur;\n   if(ll != 6){\n     lrc = 365;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 12; cr = 10;\n   ul ^= cr;\n   if(ul != 6){\n     lrc = 366;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 12; sr = 10;\n   ul ^= sr;\n   if(ul != 6){\n     lrc = 367;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 12; ir = 10;\n   ul ^= ir;\n   if(ul != 6){\n     lrc = 368;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 12; lr = 10;\n   ul ^= lr;\n   if(ul != 6){\n     lrc = 369;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 12; ur = 10;\n   ul ^= ur;\n   if(ul != 6){\n     lrc = 370;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 12; cr = 10;\n   cl |= cr;\n   if(cl != 14){\n     lrc = 371;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 12; sr = 10;\n   cl |= sr;\n   if(cl != 14){\n     lrc = 372;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 12; ir = 10;\n   cl |= ir;\n   if(cl != 14){\n     lrc = 373;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 12; lr = 10;\n   cl |= lr;\n   if(cl != 14){\n     lrc = 374;\n     if(prlc) printf(f,lrc);\n   }\n   cl = 12; ur = 10;\n   cl |= ur;\n   if(cl != 14){\n     lrc = 375;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 12; cr = 10;\n   sl |= cr;\n   if(sl != 14){\n     lrc = 376;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 12; sr = 10;\n   sl |= sr;\n   if(sl != 14){\n     lrc = 377;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 12; ir = 10;\n   sl |= ir;\n   if(sl != 14){\n     lrc = 378;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 12; lr = 10;\n   sl |= lr;\n   if(sl != 14){\n     lrc = 379;\n     if(prlc) printf(f,lrc);\n   }\n   sl = 12; ur = 10;\n   sl |= ur;\n   if(sl != 14){\n     lrc = 380;\n     if(prlc) printf(f,lrc);\n   }\n   il = 12; cr = 10;\n   il |= cr;\n   if(il != 14){\n     lrc = 381;\n     if(prlc) printf(f,lrc);\n   }\n   il = 12; sr = 10;\n   il |= sr;\n   if(il != 14){\n     lrc = 382;\n     if(prlc) printf(f,lrc);\n   }\n   il = 12; ir = 10;\n   il |= ir;\n   if(il != 14){\n     lrc = 383;\n     if(prlc) printf(f,lrc);\n   }\n   il = 12; lr = 10;\n   il |= lr;\n   if(il != 14){\n     lrc = 384;\n     if(prlc) printf(f,lrc);\n   }\n   il = 12; ur = 10;\n   il |= ur;\n   if(il != 14){\n     lrc = 385;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 12; cr = 10;\n   ll |= cr;\n   if(ll != 14){\n     lrc = 386;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 12; sr = 10;\n   ll |= sr;\n   if(ll != 14){\n     lrc = 387;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 12; ir = 10;\n   ll |= ir;\n   if(ll != 14){\n     lrc = 388;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 12; lr = 10;\n   ll |= lr;\n   if(ll != 14){\n     lrc = 389;\n     if(prlc) printf(f,lrc);\n   }\n   ll = 12; ur = 10;\n   ll |= ur;\n   if(ll != 14){\n     lrc = 390;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 12; cr = 10;\n   ul |= cr;\n   if(ul != 14){\n     lrc = 391;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 12; sr = 10;\n   ul |= sr;\n   if(ul != 14){\n     lrc = 392;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 12; ir = 10;\n   ul |= ir;\n   if(ul != 14){\n     lrc = 393;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 12; lr = 10;\n   ul |= lr;\n   if(ul != 14){\n     lrc = 394;\n     if(prlc) printf(f,lrc);\n   }\n   ul = 12; ur = 10;\n   ul |= ur;\n   if(ul != 14){\n     lrc = 395;\n     if(prlc) printf(f,lrc);\n   }\n   if(lrc != 0) {\n     rc = 1;\n     if(pd0->flgd != 0) printf(s714er,1);\n   }\n   return rc;\n}\ns715(pd0)          /*  7.15 Comma operator     */\nstruct defs *pd0;\n{\n   static char s715er[] = \"s715,er%d\\n\";\n   static char qs715[8] = \"s715   \";\n   int rc;\n   char *ps, *pt;\n   int a, t, c, i;\n   a = c = 0;\n   ps = qs715;\n   pt = pd0->rfs;\n   rc = 0;\n   while (*pt++ = *ps++);\n\n        /* A pair of expressions separated by a comma is\n        evaluated left to right and the value of the left\n        expression is discarded.\n                                                                */\n   i = 1;\n   if( i++,i++,i++,i++,++i != 6 ){\n     if(pd0->flgd != 0) printf(s715er,1);\n     rc = rc+1;\n   }\n\n        /* In contexts where the comma is given a special mean-\n        ing, for example in a list of actual arguments to \n        functions (sic) and lists of initializers, the comma\n        operator as described in this section can only appear\n        in parentheses; for example\n\n                f( a, (t=3, t+2), c)\n\n        has three arguments, the second of which has the\n        value 5.\n                                                                */\n\n   if(s715f(a, (t=3, t+2), c) != 5){\n     if(pd0->flgd != 0) printf(s715er,2);\n     rc = rc+2;\n   }\n   return rc;\n}\ns715f(x,y,z)\nint x, y, z;\n{\n   return y;\n}\ns72(pd0)          /*  7.2  Unary operators  */\nstruct defs *pd0;\n{\n   static char s72er[] = \"s72,er%d\\n\";\n   static char qs72[8] = \"s72    \";\n   int rc;\n   char *ps, *pt;\n   int k, j, i, lrc;\n   char c;\n   short s;\n   long l;\n   unsigned u;\n   double d;\n   float f;\n   ps = qs72;\n   pt = pd0->rfs;\n   rc = 0;\n   while (*pt++ = *ps++);\n\n        /* The *, denoting indirection, and the &, denoting a\n        pointer, are duals of each other, and ought to behave as \n        such...                                                 */\n\n   k = 2;\n   if(*&*&k != 2){\n     rc = rc+1;\n     printf(s72er,1);\n   }\n\n        /* The unary minus has the conventional meaning.        */\n\n   if(k+(-k) != 0){\n     rc = rc+2;\n     printf(s72er,2);\n   }\n\n        /*  The negation operator (!) has been thoroughly checked out,\n        perhaps more thoroughly than any of the others. The ~ oper-\n        ator gets us a ones complement.                         */\n\n   k = 0;\n   for(j=0;j<pd0->ibits;j++) k = (k<<1)|1;\n   if(~k != 0){\n     rc = rc+4;\n     printf(s72er,4);\n   }\n\n        /*  Now we look at the ++ and -- operators, which can be\n        used in either prefix or suffix form. With side\n        effects they're loaded.                                 */\n\n   k = 5;\n\n   if( ++k != 6 || --k != 5\n    || k++ != 5 || k-- != 6\n    ||   k != 5 ){\n     rc = rc+8;\n     printf(s72er,8);\n   }\n\n        /*  An expression preceded by the parenthesised name of a\n        data type causes conversion of the value of the expression\n        to the named type. This construction is called a cast.\n        Here, we check to see that all of the possible casts and\n        their simple combinations are accepted by the compiler,\n        and that they all produce a correct result for this sample\n        of size one.                                            */\n\n   c = 26;  l = 26;  d = 26.;\n   s = 26;  u = 26; \n   i = 26;  f = 26.;\n\n   lrc = 0;\n\n   if( (char)s != 26 || (char)i != 26\n    || (char)l != 26 || (char)u != 26\n    || (char)f != 26 || (char)d != 26 ) lrc = lrc+1;\n\n   if( (short)c != 26 || (short)i != 26\n    || (short)l != 26 || (short)u != 26\n    || (short)f != 26 || (short)d != 26) lrc = lrc+2;\n\n   if( (int)c != 26 || (int)s != 26\n    || (int)l != 26 || (int)u != 26\n    || (int)f != 26 || (int)d != 26 ) lrc = lrc+4;\n\n   if( (long)c != 26 || (long)s != 26\n    || (long)i != 26 || (long)u != 26\n    || (long)f != 26 || (long)d != 26 ) lrc = lrc+8;\n\n   if( (unsigned)c != 26 || (unsigned)s != 26\n    || (unsigned)i != 26 || (unsigned)l != 26\n    || (unsigned)f != 26 || (unsigned)d != 26 ) lrc = lrc+16;\n\n   if( (float)c != 26. || (float)s != 26.\n    || (float)i != 26. || (float)l != 26.\n    || (float)u != 26. || (float)d != 26. ) lrc = lrc+32;\n\n   if( (double)c != 26. || (double)s != 26.\n    || (double)i != 26. || (double)l != 26.\n    || (double)u != 26. || (double)f != 26. ) lrc = lrc+64;\n\n   if(lrc != 0){\n     rc = rc+16;\n     printf(s72er,16);\n   }\n\n        /*  The sizeof operator has been tested previously.     */\n\n   return rc;\n}\ns757(pd0)          /* 7.5 Shift operators          */\n                   /* 7.6 Relational operators     */\n                   /* 7.7 Equality operator        */\nstruct defs *pd0;\n{\n   static char s757er[] = \"s757,er%d\\n\";\n   static char qs757[8] = \"s757   \";\n   int rc;\n   char *ps, *pt;\n   int t,lrc,k,j,a,b,c,d,x[16],*p;\n   unsigned rs, ls, rt, lt;\n   ps = qs757;\n   pt = pd0->rfs;\n   rc = 0;\n   while (*pt++ = *ps++);\n\n        /* The shift operators << and >> group left-to-right.\n                                                                */\n\n   t = 40;\n   if(t<<3<<2 != 1280 || t>>3>>2 != 1){\n     rc = rc+1;\n     if(pd0->flgd != 0) printf(s757er,1);\n   }\n\n        /* In the following test, an n-bit unsigned consisting\n        of all 1s is shifted right (resp. left) k bits, 0<=k<n.\n        We expect to find k 0s followed by n-k 1s (resp. n-k 1s\n        followed by k 0s). If not, we complain.\n                                                                */\n\n   lrc = 0;\n   for(k=0; k<pd0->ubits; k++){\n     rs = 1;\n     ls = rs<<(pd0->ubits-1);\n\n     rt = 0;\n     lt = ~rt>>k;\n     rt = ~rt<<k;\n\n     for(j=0; j<pd0->ubits;j++){\n       if((j<k) != ((rs&rt) == 0) || (j<k) != ((ls&lt) == 0)) lrc = 1;\n       rs = rs<<1;\n       ls = ls>>1;\n     }\n   }\n\n   if(lrc != 0){\n     rc = rc+2;\n     if(pd0->flgd != 0) printf(s757er,2);\n   }\n\n        /* The relational operators group left-to-right, but this\n        fact is not very useful; a<b<c does not mean what it \n        seems to...\n                                                                */\n\n   a = 3;\n   b = 2;\n   c = 1;\n\n   if((a<b<c) != 1){\n     rc = rc+4;\n     if(pd0->flgd != 0) printf(s757er,4);\n   }\n\n        /* In general, we take note of the fact that if we got this\n        far the relational operators have to be working. We test only\n        that two pointers may be compared; the result depends on\n        the relative locations in the address space of the \n        pointed-to objects.\n                                                                */\n   if( &x[1] == &x[0] ){\n     rc = rc+8;\n     if(pd0->flgd != 0) printf(s757er,8);\n   }\n\n   if( &x[1] < &x[0] ) if(pd0->flgm != 0)\n     printf(\"Increasing array elements assigned to decreasing locations\\n\");\n\n        /* a<b == c<d whenever a<b and c<d have the same \n        truth value.                                            */\n\n   lrc = 0;\n\n   for(j=0;j<16;j++) x[j] = 1;\n   x[1] = 0;\n   x[4] = 0;\n   x[6] = 0;\n   x[7] = 0;\n   x[9] = 0;\n   x[13] = 0;\n\n   for(a=0;a<2;a++)\n     for(b=0;b<2;b++)\n       for(c=0;c<2;c++)\n         for(d=0;d<2;d++)\n           if((a<b==c<d) != x[8*a+4*b+2*c+d] ) lrc = 1;\n\n   if(lrc != 0){\n     rc = rc+16;\n     if(pd0->flgd != 0) printf(s757er,16);\n   }\n\n        /* A pointer to which zero has been assigned will\n        appear to be equal to zero.\n                                                                */\n\n   p = 0;\n\n   if(p != 0){\n     rc = rc+32;\n     if(pd0->flgd != 0) printf(s757er,32);\n   }\n\n   return rc;\n}\ns7813(pd0)          /* 7.8 Bitwise AND operator\n                       7.9 Bitwise OR operator\n                       7.10 Bitwise exclusive OR operator\n                       7.11 Logical AND operator\n                       7.12 Logical OR operator\n                       7.13 Conditional operator            */\nstruct defs *pd0;\n{\n   register int prlc, lrc;\n   int i, j, r, zero, one;\n   static char fl[] = \"Local error %d.\\n\";\n   static char s7813er[] = \"s7813,er%d\\n\";\n   static char qs7813[8] = \"s7813  \";\n   int rc;\n   char *ps, *pt;\n   ps = qs7813;\n   pt = pd0->rfs;\n   lrc = 0;\n   rc = 0;\n   prlc = pd0->flgl;\n   while (*pt++ = *ps++);\n\n        /* If bitwise AND, OR, and exclusive OR are to cause\n        trouble, they will probably do so when they are used in\n        an unusual context. The number of contexts in which\n        they can be used is infinite, so to save time we select\n        a finite subset: the set of all expressions of the form:\n\n                item1 op item2\n\n        where item1 and item2 are chosen from the set\n        {char,short,long,unsigned,int} and op is one of {&,|,^}.\n        We will use 12 and 10 as values for the items, as these\n        values will fit into all data types on just about any\n        imaginable machine, and the results after performing the\n        bitwise operations on them are distinct for each operation,\n        i.e.,\n\n                12 | 10  -> 1100 | 1010  -> 1110 -> 14\n                12 ^ 10  -> 1100 ^ 1010  -> 0110 ->  6\n                12 & 10  -> 1100 & 1010  -> 1000 ->  8\n\n        There are 75 such combinations:\n                                                                */\n\n   if(((char)12 & (char)10) !=  8) {lrc = 1;\n      if(prlc) printf(fl,lrc);}\n   if(((char)12 | (char)10) != 14) {lrc = 2;\n      if(prlc) printf(fl,lrc);}\n   if(((char)12 ^ (char)10) !=  6) {lrc = 3;\n      if(prlc) printf(fl,lrc);}\n   if(((char)12 & (short)10) !=  8) {lrc = 4;\n      if(prlc) printf(fl,lrc);}\n   if(((char)12 | (short)10) != 14) {lrc = 5;\n      if(prlc) printf(fl,lrc);}\n   if(((char)12 ^ (short)10) !=  6) {lrc = 6;\n      if(prlc) printf(fl,lrc);}\n   if(((char)12 & (long)10) !=  8) {lrc = 7;\n      if(prlc) printf(fl,lrc);}\n   if(((char)12 | (long)10) != 14) {lrc = 8;\n      if(prlc) printf(fl,lrc);}\n   if(((char)12 ^ (long)10) !=  6) {lrc = 9;\n      if(prlc) printf(fl,lrc);}\n   if(((char)12 & (unsigned)10) !=  8) {lrc = 10;\n      if(prlc) printf(fl,lrc);}\n   if(((char)12 | (unsigned)10) != 14) {lrc = 11;\n      if(prlc) printf(fl,lrc);}\n   if(((char)12 ^ (unsigned)10) !=  6) {lrc = 12;\n      if(prlc) printf(fl,lrc);}\n   if(((char)12 & (int)10) !=  8) {lrc = 13;\n      if(prlc) printf(fl,lrc);}\n   if(((char)12 | (int)10) != 14) {lrc = 14;\n      if(prlc) printf(fl,lrc);}\n   if(((char)12 ^ (int)10) !=  6) {lrc = 15;\n      if(prlc) printf(fl,lrc);}\n   if(((short)12 & (char)10) !=  8) {lrc = 16;\n      if(prlc) printf(fl,lrc);}\n   if(((short)12 | (char)10) != 14) {lrc = 17;\n      if(prlc) printf(fl,lrc);}\n   if(((short)12 ^ (char)10) !=  6) {lrc = 18;\n      if(prlc) printf(fl,lrc);}\n   if(((short)12 & (short)10) !=  8) {lrc = 16;\n      if(prlc) printf(fl,lrc);}\n   if(((short)12 | (short)10) != 14) {lrc = 20;\n      if(prlc) printf(fl,lrc);}\n   if(((short)12 ^ (short)10) !=  6) {lrc = 21;\n      if(prlc) printf(fl,lrc);}\n   if(((short)12 & (long)10) !=  8) {lrc = 22;\n      if(prlc) printf(fl,lrc);}\n   if(((short)12 | (long)10) != 14) {lrc = 23;\n      if(prlc) printf(fl,lrc);}\n   if(((short)12 ^ (long)10) !=  6) {lrc = 24;\n      if(prlc) printf(fl,lrc);}\n   if(((short)12 & (unsigned)10) !=  8) {lrc = 25;\n      if(prlc) printf(fl,lrc);}\n   if(((short)12 | (unsigned)10) != 14) {lrc = 26;\n      if(prlc) printf(fl,lrc);}\n   if(((short)12 ^ (unsigned)10) !=  6) {lrc = 27;\n      if(prlc) printf(fl,lrc);}\n   if(((short)12 & (int)10) !=  8) {lrc = 28;\n      if(prlc) printf(fl,lrc);}\n   if(((short)12 | (int)10) != 14) {lrc = 26;\n      if(prlc) printf(fl,lrc);}\n   if(((short)12 ^ (int)10) !=  6) {lrc = 30;\n      if(prlc) printf(fl,lrc);}\n   if(((long)12 & (char)10) !=  8) {lrc = 31;\n      if(prlc) printf(fl,lrc);}\n   if(((long)12 | (char)10) != 14) {lrc = 32;\n      if(prlc) printf(fl,lrc);}\n   if(((long)12 ^ (char)10) !=  6) {lrc = 33;\n      if(prlc) printf(fl,lrc);}\n   if(((long)12 & (short)10) !=  8) {lrc = 34;\n      if(prlc) printf(fl,lrc);}\n   if(((long)12 | (short)10) != 14) {lrc = 35;\n      if(prlc) printf(fl,lrc);}\n   if(((long)12 ^ (short)10) !=  6) {lrc = 36;\n      if(prlc) printf(fl,lrc);}\n   if(((long)12 & (long)10) !=  8) {lrc = 37;\n      if(prlc) printf(fl,lrc);}\n   if(((long)12 | (long)10) != 14) {lrc = 38;\n      if(prlc) printf(fl,lrc);}\n   if(((long)12 ^ (long)10) !=  6) {lrc = 39;\n      if(prlc) printf(fl,lrc);}\n   if(((long)12 & (unsigned)10) !=  8) {lrc = 40;\n      if(prlc) printf(fl,lrc);}\n   if(((long)12 | (unsigned)10) != 14) {lrc = 41;\n      if(prlc) printf(fl,lrc);}\n   if(((long)12 ^ (unsigned)10) !=  6) {lrc = 42;\n      if(prlc) printf(fl,lrc);}\n   if(((long)12 & (int)10) !=  8) {lrc = 43;\n      if(prlc) printf(fl,lrc);}\n   if(((long)12 | (int)10) != 14) {lrc = 44;\n      if(prlc) printf(fl,lrc);}\n   if(((long)12 ^ (int)10) !=  6) {lrc = 45;\n      if(prlc) printf(fl,lrc);}\n   if(((unsigned)12 & (char)10) !=  8) {lrc = 46;\n      if(prlc) printf(fl,lrc);}\n   if(((unsigned)12 | (char)10) != 14) {lrc = 47;\n      if(prlc) printf(fl,lrc);}\n   if(((unsigned)12 ^ (char)10) !=  6) {lrc = 48;\n      if(prlc) printf(fl,lrc);}\n   if(((unsigned)12 & (short)10) !=  8) {lrc = 49;\n      if(prlc) printf(fl,lrc);}\n   if(((unsigned)12 | (short)10) != 14) {lrc = 50;\n      if(prlc) printf(fl,lrc);}\n   if(((unsigned)12 ^ (short)10) !=  6) {lrc = 51;\n      if(prlc) printf(fl,lrc);}\n   if(((unsigned)12 & (long)10) !=  8) {lrc = 52;\n      if(prlc) printf(fl,lrc);}\n   if(((unsigned)12 | (long)10) != 14) {lrc = 53;\n      if(prlc) printf(fl,lrc);}\n   if(((unsigned)12 ^ (long)10) !=  6) {lrc = 54;\n      if(prlc) printf(fl,lrc);}\n   if(((unsigned)12 & (unsigned)10) !=  8) {lrc = 55;\n      if(prlc) printf(fl,lrc);}\n   if(((unsigned)12 | (unsigned)10) != 14) {lrc = 56;\n      if(prlc) printf(fl,lrc);}\n   if(((unsigned)12 ^ (unsigned)10) !=  6) {lrc = 57;\n      if(prlc) printf(fl,lrc);}\n   if(((unsigned)12 & (int)10) !=  8) {lrc = 58;\n      if(prlc) printf(fl,lrc);}\n   if(((unsigned)12 | (int)10) != 14) {lrc = 56;\n      if(prlc) printf(fl,lrc);}\n   if(((unsigned)12 ^ (int)10) !=  6) {lrc = 60;\n      if(prlc) printf(fl,lrc);}\n   if(((int)12 & (char)10) !=  8) {lrc = 61;\n      if(prlc) printf(fl,lrc);}\n   if(((int)12 | (char)10) != 14) {lrc = 62;\n      if(prlc) printf(fl,lrc);}\n   if(((int)12 ^ (char)10) !=  6) {lrc = 63;\n      if(prlc) printf(fl,lrc);}\n   if(((int)12 & (short)10) !=  8) {lrc = 64;\n      if(prlc) printf(fl,lrc);}\n   if(((int)12 | (short)10) != 14) {lrc = 65;\n      if(prlc) printf(fl,lrc);}\n   if(((int)12 ^ (short)10) !=  6) {lrc = 66;\n      if(prlc) printf(fl,lrc);}\n   if(((int)12 & (long)10) !=  8) {lrc = 67;\n      if(prlc) printf(fl,lrc);}\n   if(((int)12 | (long)10) != 14) {lrc = 68;\n      if(prlc) printf(fl,lrc);}\n   if(((int)12 ^ (long)10) !=  6) {lrc = 69;\n      if(prlc) printf(fl,lrc);}\n   if(((int)12 & (unsigned)10) !=  8) {lrc = 70;\n      if(prlc) printf(fl,lrc);}\n   if(((int)12 | (unsigned)10) != 14) {lrc = 71;\n      if(prlc) printf(fl,lrc);}\n   if(((int)12 ^ (unsigned)10) !=  6) {lrc = 72;\n      if(prlc) printf(fl,lrc);}\n   if(((int)12 & (int)10) !=  8) {lrc = 73; if(prlc) printf(fl,lrc);}\n   if(((int)12 | (int)10) != 14) {lrc = 74; if(prlc) printf(fl,lrc);}\n   if(((int)12 ^ (int)10) !=  6) {lrc = 75; if(prlc) printf(fl,lrc);}\n\n   if(lrc != 0){\n     if(pd0->flgd != 0) printf(s7813er,1);\n     rc = rc+1;\n   }\n\n        /* The && operator groups left to right. It returns 1\n        if both of the operands are nonzero; 0 otherwise.\n        It guarantees left to right evaluation; moreover, the\n        second operand is not evaluated if the value of the \n        first operand is 0.\n                                                                */\n\n   lrc = 0;\n   i = j = 0;\n\n   r = i++ && j++;\n    if(i!=1) {lrc = 1; if(prlc) printf(fl,lrc);}\n    if(j!=0) {lrc = 2; if(prlc) printf(fl,lrc);}\n    if(r!=0) {lrc = 3; if(prlc) printf(fl,lrc);}\n   r = i && j++;\n    if(i!=1) {lrc = 4; if(prlc) printf(fl,lrc);}\n    if(j!=1) {lrc = 5; if(prlc) printf(fl,lrc);}\n    if(r!=0) {lrc = 6; if(prlc) printf(fl,lrc);}\n   r = i-- && j;\n    if(i!=0) {lrc = 7; if(prlc) printf(fl,lrc);}\n    if(j!=1) {lrc = 8; if(prlc) printf(fl,lrc);}\n    if(r!=1) {lrc = 9; if(prlc) printf(fl,lrc);}\n   r = i && j--;\n    if(i!=0) {lrc = 10; if(prlc) printf(fl,lrc);}\n    if(j!=1) {lrc = 11; if(prlc) printf(fl,lrc);}\n    if(r!=0) {lrc = 12; if(prlc) printf(fl,lrc);}\n\n   if(lrc!=0){\n     if(pd0->flgd != 0) printf(s7813er,2);\n     rc = rc+2;\n   }\n\n        /* The || operator groups left to right. It returns 1\n        if either of its operands is nonzero; 0 otherwise. It\n        guarantees left to right evaluation; moreover, the second\n        operand is not evaluated if the value of the first \n        operand is nonzero.\n                                                                */\n\n   lrc = 0;\n   i = j = 0;\n   r = i++ || j;\n    if(i!=1) {lrc = 1; if(prlc) printf(fl,lrc);}\n    if(j!=0) {lrc = 2; if(prlc) printf(fl,lrc);}\n    if(r!=0) {lrc = 3; if(prlc) printf(fl,lrc);}\n   r = j++ || i;\n    if(i!=1) {lrc = 4; if(prlc) printf(fl,lrc);}\n    if(j!=1) {lrc = 5; if(prlc) printf(fl,lrc);}\n    if(r!=1) {lrc = 6; if(prlc) printf(fl,lrc);}\n   r = i-- || j--;\n    if(i!=0) {lrc = 7; if(prlc) printf(fl,lrc);}\n    if(j!=1) {lrc = 8; if(prlc) printf(fl,lrc);}\n    if(r!=1) {lrc = 9; if(prlc) printf(fl,lrc);}\n   r = i || j--;\n    if(i!=0) {lrc = 10; if(prlc) printf(fl,lrc);}\n    if(j!=0) {lrc = 11; if(prlc) printf(fl,lrc);}\n    if(r!=1) {lrc = 12; if(prlc) printf(fl,lrc);}\n\n   if(lrc!=0){\n     if(pd0->flgd != 0) printf(s7813er,4);\n     rc = rc+4;\n   }\n\n        /* Conditional expressions group right to left.  */\n\n   i = j = 0;\n   zero = 0;\n   one = 1;\n   r = one?zero:one?i++:j++;\n   if(r!=0 || i!=0 || j!=0){\n     if(pd0->flgd != 0) printf(s7813er,8);\n     rc = rc+8;\n   }\n\n        /* The first expression is evaluated and if it is non-\n        zero, the result is the value of the second expression;\n        otherwise, that of the third expression.\n                                                                */\n\n   if((one?zero:1) != 0 || (zero?1:zero) != 0){\n     if(pd0->flgd != 0) printf(s7813er,16);\n     rc = rc+16;\n   }\n   return rc;\n}\ns81(pd0)              /* 8.1 Storage Class Specifiers    */\nstruct defs *pd0;\n{\n   static char s81er[] = \"s81,er%d\\n\";\n   static char qs81[8] = \"s81    \";\n   char *ps, *pt;\n   int k, rc, j, crc, prc, irc;\n   register char rchar;\n            char nrchar;\n   register int *rptr;\n            int *nrptr;\n   register int rint;\n            int nrint;\n   static char badtest[] = \"Register count for %s is unreliable.\\n\";\n   static char goodtest[] = \"%d registers assigned to %s variables.\\n\";\n   \n   rc = 0;\n   crc = 0;\n   prc = 0;\n   irc = 0;\n   ps = qs81;\n   pt = pd0->rfs;\n\n   while(*pt++ = *ps++);\n\n/*    The storage class specifiers are:\n\n        auto\n        static\n        extern\n        register\n        typedef\n\n      The first three of these were treated earlier, in s4. The last\n   will be checked in s88. \"Register\" remains. \n\n      There are three flavors of register, viz., char, int and pointer.\n   We wish first to ascertain that the representations as register\n   are consistent with the corresponding nonregister representations.\n                                                                 */\n\n   k = 1;\n   for (j=0; j<50; j++){\n     rchar = k;\n     nrchar = k;\n     rptr = &k;\n     nrptr = &k;\n     rint = k;\n     nrint = k;\n\n     if ( rchar != nrchar ) crc = 1;\n     if ( rptr != nrptr ) prc = 1;\n     if ( rint != nrint ) irc = 1;\n     k = k<<1;\n   }\n\n   if ( crc != 0 ) {\n     rc = rc+1;\n     if( pd0 -> flgd != 0 ) printf(s81er,1);\n   }\n\n   if ( prc != 0 ) {\n     rc = rc+2;\n     if( pd0 -> flgd != 0 ) printf(s81er,2);\n   }\n\n   if ( irc != 0 ) {\n     rc = rc+4;\n     if( pd0 -> flgd != 0 ) printf(s81er,4);\n   }\n\n/*   Now we check to see if variables are actually being assigned\n     to registers.                       */\n\n   k = regc();\n   if ( pd0->flgm != 0 ) {\n     if ( k < 0 ) printf(badtest,\"char\");\n     else printf(goodtest,k,\"char\");\n   }\n\n   k = regp();\n   if ( pd0->flgm != 0 ) {\n     if ( k<0 ) printf(badtest,\"pointer\");\n     else printf(goodtest,k,\"pointer\");\n   }\n\n   k = regi();\n   if ( pd0->flgm != 0 ) {\n     if ( k<0 ) printf(badtest,\"int\");\n     else printf(goodtest,k,\"int\");\n   }\n\n   return rc;\n}\nregc() {     /*   char to register assignment   */\n/*   Testing a variable whose storage class has been spec-\nified as \"register\" is somewhat tricky, but it can be done in a \nfairly reliable fashion by taking advantage of our knowledge of the\nways in which compilers operate. If we declare a collection of vari-\nables of the same storage class, we would expect that, when storage\nfor these variables is actually allocated, the variables will be \nbunched together and ordered according to one of the following\ncriteria:\n\n     (a) the order in which they were defined.\n     (b) the order in which they are used.\n     (c) alphabetically.\n     (d) the order in which they appear in the compiler's\n         symbol table.\n     (e) some other way.\n\n     Hence, if we define a sequence of variables in close alpha-\nbetical order, and use them in the same order in which we define\nthem, we would expect the differences between the addresses of\nsuccessive variables to be constant, except in case (d) where the\nsymbol table is a hash table, or in case (e). If a subsequence in\nthe middle of this sequence is selected, and for this subsequence,\nevery other variable is specified to be \"register\", and address\ndifferences are taken between adjacent nonregister variables, we would\nstill expect to find constant differences if the \"register\" vari-\nables were actually assigned to registers, and some other diff-\nerences if they were not. Specifically, if we had N variables \nspecified as \"register\" of which the first n were actually ass-\nigned to registers, we would expect the sequence of differences\nto consist of a number of occurrences of some number, followed by\nN-n occurrences of some other number, followed by several occurr-\nences of the first number. If we get a sequence like this, we can\ndetermine, by simple subtraction, how many (if any) variables are\nbeing assigned to registers. If we get some other sequence, we know\nthat the test is invalid.                                     */\n\n            char r00;\n            char r01;\n            char r02;\n            char r03;\n   register char r04;\n            char r05;\n   register char r06;\n            char r07;\n   register char r08;\n            char r09;\n   register char r10;\n            char r11;\n   register char r12;\n            char r13;\n   register char r14;\n            char r15;\n   register char r16;\n            char r17;\n   register char r18;\n            char r19;\n   register char r20;\n            char r21;\n   register char r22;\n            char r23;\n   register char r24;\n            char r25;\n   register char r26;\n            char r27;\n   register char r28;\n            char r29;\n   register char r30;\n            char r31;\n   register char r32;\n            char r33;\n   register char r34;\n            char r35;\n            char r36;\n            char r37;\n            char r38;\n\n   int s, n1, n2, nr, j, d[22];\n   r00 = 0;\n   r01 = 1;\n   r02 = 2;\n   r03 = 3;\n   r04 = 4;\n   r05 = 5;\n   r06 = 6;\n   r07 = 7;\n   r08 = 8;\n   r09 = 9;\n   r10 = 10;\n   r11 = 11;\n   r12 = 12;\n   r13 = 13;\n   r14 = 14;\n   r15 = 15;\n   r16 = 16;\n   r17 = 17;\n   r18 = 18;\n   r19 = 19;\n   r20 = 20;\n   r21 = 21;\n   r22 = 22;\n   r23 = 23;\n   r24 = 24;\n   r25 = 25;\n   r26 = 26;\n   r27 = 27;\n   r28 = 28;\n   r29 = 29;\n   r30 = 30;\n   r31 = 31;\n   r32 = 32;\n   r33 = 33;\n   r34 = 34;\n   r35 = 35;\n   r36 = 36;\n   r37 = 37;\n   r38 = 38;\n\n   d[0] = &r01 - &r00;\n   d[1] = &r02 - &r01;\n   d[2] = &r03 - &r02;\n   d[3] = &r05 - &r03;\n   d[4] = &r07 - &r05;\n   d[5] = &r09 - &r07;\n   d[6] = &r11 - &r09;\n   d[7] = &r13 - &r11;\n   d[8] = &r15 - &r13;\n   d[9] = &r17 - &r15;\n   d[10] = &r19 - &r17;\n   d[11] = &r21 - &r19;\n   d[12] = &r23 - &r21;\n   d[13] = &r25 - &r23;\n   d[14] = &r27 - &r25;\n   d[15] = &r29 - &r27;\n   d[16] = &r31 - &r29;\n   d[17] = &r33 - &r31;\n   d[18] = &r35 - &r33;\n   d[19] = &r36 - &r35;\n   d[20] = &r37 - &r36;\n   d[21] = &r38 - &r37;\n\n\n/*   The following FSM analyzes the string of differences. It accepts\nstrings of the form a+b+a+ and returns 16 minus the number of bs, \nwhich is the number of variables that actually got into registers.\nOtherwise it signals rejection by returning -1., indicating that the\ntest is unreliable.              */\n\n   n1 = d[0];\n   s = 1;\n\n   for (j=0; j<22; j++)\n     switch (s) {\n       case 1: if (d[j] != n1) {\n                n2 = d[j];\n                s = 2;\n                nr = 1;\n               }\n               break;\n       case 2: if (d[j] == n1) {\n                s = 3;\n                break;\n               }\n               if (d[j] == n2) {\n                nr = nr+1;\n                break;\n               }\n               s = 4;\n               break;\n       case 3: if (d[j] != n1) s = 4;\n               break;\n     }\n   ;\n\n   if (s == 3) return 16-nr;\n   else return -1;\n}\nregi() {     /*   int to register assignment    */\n/*   Testing a variable whose storage class has been spec-\nified as \"register\" is somewhat tricky, but it can be done in a \nfairly reliable fashion by taking advantage of our knowledge of the\nways in which compilers operate. If we declare a collection of vari-\nables of the same storage class, we would expect that, when storage\nfor these variables is actually allocated, the variables will be \nbunched together and ordered according to one of the following\ncriteria:\n\n     (a) the order in which they were defined.\n     (b) the order in which they are used.\n     (c) alphabetically.\n     (d) the order in which they appear in the compiler's\n         symbol table.\n     (e) some other way.\n\n     Hence, if we define a sequence of variables in close alpha-\nbetical order, and use them in the same order in which we define\nthem, we would expect the differences between the addresses of\nsuccessive variables to be constant, except in case (d) where the\nsymbol table is a hash table, or in case (e). If a subsequence in\nthe middle of this sequence is selected, and for this subsequence,\nevery other variable is specified to be \"register\", and address\ndifferences are taken between adjacent nonregister variables, we would\nstill expect to find constant differences if the \"register\" vari-\nables were actually assigned to registers, and some other diff-\nerences if they were not. Specifically, if we had N variables \nspecified as \"register\" of which the first n were actually ass-\nigned to registers, we would expect the sequence of differences\nto consist of a number of occurrences of some number, followed by\nN-n occurrences of some other number, followed by several occurr-\nences of the first number. If we get a sequence like this, we can\ndetermine, by simple subtraction, how many (if any) variables are\nbeing assigned to registers. If we get some other sequence, we know\nthat the test is invalid.                                     */\n\n\n            int r00;\n            int r01;\n            int r02;\n            int r03;\n   register int r04;\n            int r05;\n   register int r06;\n            int r07;\n   register int r08;\n            int r09;\n   register int r10;\n            int r11;\n   register int r12;\n            int r13;\n   register int r14;\n            int r15;\n   register int r16;\n            int r17;\n   register int r18;\n            int r19;\n   register int r20;\n            int r21;\n   register int r22;\n            int r23;\n   register int r24;\n            int r25;\n   register int r26;\n            int r27;\n   register int r28;\n            int r29;\n   register int r30;\n            int r31;\n   register int r32;\n            int r33;\n   register int r34;\n            int r35;\n            int r36;\n            int r37;\n            int r38;\n\n   int s, n1, n2, nr, j, d[22];\n\n   r00 = 0;\n   r01 = 1;\n   r02 = 2;\n   r03 = 3;\n   r04 = 4;\n   r05 = 5;\n   r06 = 6;\n   r07 = 7;\n   r08 = 8;\n   r09 = 9;\n   r10 = 10;\n   r11 = 11;\n   r12 = 12;\n   r13 = 13;\n   r14 = 14;\n   r15 = 15;\n   r16 = 16;\n   r17 = 17;\n   r18 = 18;\n   r19 = 19;\n   r20 = 20;\n   r21 = 21;\n   r22 = 22;\n   r23 = 23;\n   r24 = 24;\n   r25 = 25;\n   r26 = 26;\n   r27 = 27;\n   r28 = 28;\n   r29 = 29;\n   r30 = 30;\n   r31 = 31;\n   r32 = 32;\n   r33 = 33;\n   r34 = 34;\n   r35 = 35;\n   r36 = 36;\n   r37 = 37;\n   r38 = 38;\n\n   d[0] = &r01 - &r00;\n   d[1] = &r02 - &r01;\n   d[2] = &r03 - &r02;\n   d[3] = &r05 - &r03;\n   d[4] = &r07 - &r05;\n   d[5] = &r09 - &r07;\n   d[6] = &r11 - &r09;\n   d[7] = &r13 - &r11;\n   d[8] = &r15 - &r13;\n   d[9] = &r17 - &r15;\n   d[10] = &r19 - &r17;\n   d[11] = &r21 - &r19;\n   d[12] = &r23 - &r21;\n   d[13] = &r25 - &r23;\n   d[14] = &r27 - &r25;\n   d[15] = &r29 - &r27;\n   d[16] = &r31 - &r29;\n   d[17] = &r33 - &r31;\n   d[18] = &r35 - &r33;\n   d[19] = &r36 - &r35;\n   d[20] = &r37 - &r36;\n   d[21] = &r38 - &r37;\n\n\n/*   The following FSM analyzes the string of differences. It accepts\nstrings of the form a+b+a+ and returns 16 minus the number of bs, \nwhich is the number of variables that actually got into registers.\nOtherwise it signals rejection by returning -1., indicating that the\ntest is unreliable.              */\n\n   n1 = d[0];\n   s = 1;\n\n   for (j=0; j<22; j++)\n     switch (s) {\n       case 1: if (d[j] != n1) {\n                n2 = d[j];\n                s = 2;\n                nr = 1;\n               }\n               break;\n       case 2: if (d[j] == n1) {\n                s = 3;\n                break;\n               }\n               if (d[j] == n2) {\n                nr = nr+1;\n                break;\n               }\n               s = 4;\n               break;\n       case 3: if (d[j] != n1) s = 4;\n               break;\n     }\n   ;\n\n   if (s == 3) return 16-nr;\n   else return -1;\n}\nregp() {     /*   pointer to register assignment   */\n/*   Testing a variable whose storage class has been spec-\nified as \"register\" is somewhat tricky, but it can be done in a \nfairly reliable fashion by taking advantage of our knowledge of the\nways in which compilers operate. If we declare a collection of vari-\nables of the same storage class, we would expect that, when storage\nfor these variables is actually allocated, the variables will be \nbunched together and ordered according to one of the following\ncriteria:\n\n     (a) the order in which they were defined.\n     (b) the order in which they are used.\n     (c) alphabetically.\n     (d) the order in which they appear in the compiler's\n         symbol table.\n     (e) some other way.\n\n     Hence, if we define a sequence of variables in close alpha-\nbetical order, and use them in the same order in which we define\nthem, we would expect the differences between the addresses of\nsuccessive variables to be constant, except in case (d) where the\nsymbol table is a hash table, or in case (e). If a subsequence in\nthe middle of this sequence is selected, and for this subsequence,\nevery other variable is specified to be \"register\", and address\ndifferences are taken between adjacent nonregister variables, we would\nstill expect to find constant differences if the \"register\" vari-\nables were actually assigned to registers, and some other diff-\nerences if they were not. Specifically, if we had N variables \nspecified as \"register\" of which the first n were actually ass-\nigned to registers, we would expect the sequence of differences\nto consist of a number of occurrences of some number, followed by\nN-n occurrences of some other number, followed by several occurr-\nences of the first number. If we get a sequence like this, we can\ndetermine, by simple subtraction, how many (if any) variables are\nbeing assigned to registers. If we get some other sequence, we know\nthat the test is invalid.                                     */\n\n\n            int *r00;\n            int *r01;\n            int *r02;\n            int *r03;\n   register int *r04;\n            int *r05;\n   register int *r06;\n            int *r07;\n   register int *r08;\n            int *r09;\n   register int *r10;\n            int *r11;\n   register int *r12;\n            int *r13;\n   register int *r14;\n            int *r15;\n   register int *r16;\n            int *r17;\n   register int *r18;\n            int *r19;\n   register int *r20;\n            int *r21;\n   register int *r22;\n            int *r23;\n   register int *r24;\n            int *r25;\n   register int *r26;\n            int *r27;\n   register int *r28;\n            int *r29;\n   register int *r30;\n            int *r31;\n   register int *r32;\n            int *r33;\n   register int *r34;\n            int *r35;\n            int *r36;\n            int *r37;\n            int *r38;\n\n   int s, n1, n2, nr, j, d[22];\n\n   r00 = (int *)&r00;\n   r01 = (int *)&r01;\n   r02 = (int *)&r02;\n   r03 = (int *)&r03;\n   r04 = (int *)&r05;\n   r05 = (int *)&r05;\n   r06 = (int *)&r07;\n   r07 = (int *)&r07;\n   r08 = (int *)&r09;\n   r09 = (int *)&r09;\n   r10 = (int *)&r11;\n   r11 = (int *)&r11;\n   r12 = (int *)&r13;\n   r13 = (int *)&r13;\n   r14 = (int *)&r15;\n   r15 = (int *)&r15;\n   r16 = (int *)&r17;\n   r17 = (int *)&r17;\n   r18 = (int *)&r19;\n   r19 = (int *)&r19;\n   r20 = (int *)&r21;\n   r21 = (int *)&r21;\n   r22 = (int *)&r23;\n   r23 = (int *)&r23;\n   r24 = (int *)&r25;\n   r25 = (int *)&r25;\n   r26 = (int *)&r27;\n   r27 = (int *)&r27;\n   r28 = (int *)&r29;\n   r29 = (int *)&r29;\n   r30 = (int *)&r31;\n   r31 = (int *)&r31;\n   r32 = (int *)&r33;\n   r33 = (int *)&r33;\n   r34 = (int *)&r35;\n   r35 = (int *)&r35;\n   r36 = (int *)&r36;\n   r37 = (int *)&r37;\n   r38 = (int *)&r38;\n\n   d[0] = &r01 - &r00;\n   d[1] = &r02 - &r01;\n   d[2] = &r03 - &r02;\n   d[3] = &r05 - &r03;\n   d[4] = &r07 - &r05;\n   d[5] = &r09 - &r07;\n   d[6] = &r11 - &r09;\n   d[7] = &r13 - &r11;\n   d[8] = &r15 - &r13;\n   d[9] = &r17 - &r15;\n   d[10] = &r19 - &r17;\n   d[11] = &r21 - &r19;\n   d[12] = &r23 - &r21;\n   d[13] = &r25 - &r23;\n   d[14] = &r27 - &r25;\n   d[15] = &r29 - &r27;\n   d[16] = &r31 - &r29;\n   d[17] = &r33 - &r31;\n   d[18] = &r35 - &r33;\n   d[19] = &r36 - &r35;\n   d[20] = &r37 - &r36;\n   d[21] = &r38 - &r37;\n\n\n/*   The following FSM analyzes the string of differences. It accepts\nstrings of the form a+b+a+ and returns 16 minus the number of bs, \nwhich is the number of variables that actually got into registers.\nOtherwise it signals rejection by returning -1., indicating that the\ntest is unreliable.              */\n\n   n1 = d[0];\n   s = 1;\n   for (j=0; j<22; j++)\n     switch (s) {\n       case 1: if (d[j] != n1) {\n                n2 = d[j];\n                s = 2;\n                nr = 1;\n               }\n               break;\n       case 2: if (d[j] == n1) {\n                s = 3;\n                break;\n               }\n               if (d[j] == n2) {\n                nr = nr+1;\n                break;\n               }\n               s = 4;\n               break;\n       case 3: if (d[j] != n1) s = 4;\n               break;\n     }\n   ;\n\n   if (s == 3) return 16-nr;\n   else return -1;\n}\ns84(pd0)          /*  8.4 Meaning of declarators   */\nstruct defs *pd0;\n{\n   int *ip, i, *fip(), (*pfi)(), j, k, array(), glork();\n   static int x3d[3][5][7];\n   float fa[17], *afp[17], sum;\n   static char s84er[] = \"s84,er%d\\n\";\n   static char qs84[8] = \"s84    \";\n   int rc;\n   char *ps, *pt;\n   ps = qs84;\n   pt = pd0->rfs;\n   rc = 0;\n   while (*pt++ = *ps++);\n\n        /* The more common varieties of declarators have al-\n        ready been touched upon, some more than others. It\n        is useful to compare *fip() and (*pfi)().\n                                                                */\n\n   ip = fip(3);\n   if(*ip != 3){\n     if(pd0->flgd != 0) printf(s84er,1);\n     rc = rc+1;\n   }\n\n   pfi = glork;\n   if((*pfi)(4) != 4){\n     if(pd0->flgd != 0) printf(s84er,2);\n     rc = rc+2;\n   }\n\n        /* Float fa[17] declares an array of floating point\n        numbers, and *afp[17] declares an array of pointers\n        to floats.\n                                                                */\n\n   for(j=0; j<17; j++){\n     fa[j] = j;\n     afp[j] = &fa[j];\n   }\n\n   sum = 0.;\n   for(j=0; j<17; j++) sum += *afp[j];\n   if(sum != 136){\n     if(pd0->flgd != 0) printf(s84er,4);\n     rc = rc+4;\n   }\n\n        /*  static int x3d[3][5][7] declares a static three\n        dimensional array of integers, with rank 3x5x7.\n        In complete detail, x3d is an array of three items;\n        each item is an array of five arrays, and each of \n        the latter arrays is an array of seven integers.\n        Any of the expressions x3d, x3d[i], x3d[i][j],\n        and x3d[i][j][k] may reasonably appear in an express-\n        ion. The first three have type \"array\"; the last has\n        type int.\n                                                                */\n\n   for (i=0; i<3; i++)\n     for (j=0; j<5; j++)\n       for (k=0; k<7; k++)\n         x3d[i][j][k] = i*35+j*7+k;\n\n   i = 1; j = 2; k = 3;\n\n   if( array(x3d,105,0)\n      +array(x3d[i],35,35)\n      +array(x3d[i][j],7,49)\n      +      x3d[i][j][k]-52){\n \n      if(pd0->flgd != 0) printf(s84er,8);\n      rc = rc+8;\n   }\n\n   return rc;\n}\narray(a,size,start)\nint a[], size, start;\n{\n   int i;\n   for(i=0; i<size; i++)\n     if(a[i] != i+start) return 1;\n\n   return 0;\n}\nint *fip(x)\nint x;\n{\n   static int y;\n   y = x;\n   return &y;\n}\nglork(x)\nint x;\n{return x;}\ns85(pd0)          /*  8.5 Structure and union declarations   */\nstruct defs *pd0;\n{\n   static char s85er[] = \"s85,er%d\\n\";\n   static char qs85[8] = \"s85    \";\n   int rc;\n   char *ps, *pt;\n   \n   struct tnode {\n     char tword[20];\n     int count;\n     struct tnode *left;\n     struct tnode *right;\n   };\n\n   struct tnode s1, s2, *sp;\n\n   struct{\n     char cdummy;\n     char c;\n   } sc;\n\n   struct{\n     char cdummy;\n     short s;\n   } ss;\n\n   struct{\n     char cdummy;\n     int i;\n   } si;\n\n   struct{\n     char cdummy;\n     long l;\n   } sl;\n\n   struct{\n     char cdummy;\n     unsigned u;\n   } su;\n\n   struct{\n     char cdummy;\n     float f;\n   } sf;\n\n   struct{\n     char cdummy;\n     double d;\n   } sd;\n\n   int diff[7], j;\n\n   static char *type[] = {\n     \"char\",\n     \"short\",\n     \"int\",\n     \"long\",\n     \"unsigned\",\n     \"float\",\n     \"double\"\n   };\n\n   static char aln[] = \" alignment: \";\n\n   struct{\n     int twobit:2;\n     int       :1;\n     int threebit:3;\n     int onebit:1;\n   } s3;\n\n   union{\n     char u1[30];\n     short u2[30];\n     int u3[30];\n     long u4[30];\n     unsigned u5[30];\n     float u6[30];\n     double u7[30];\n   } u0;\n\n   ps = qs85;\n   pt = pd0->rfs;\n   rc = 0;\n   while (*pt++ = *ps++);\n\n        /* Within a structure, the objects declared have\n        addresses which increase as their declarations are\n        read left to right.\n                                                                */\n\n   if( (char *)&s1.count - &s1.tword[0] <= 0\n     ||(char *)&s1.left - (char *)&s1.count <= 0\n     ||(char *)&s1.right - (char *)&s1.left <= 0){\n     if(pd0->flgd != 0) printf(s85er,1);\n     rc = rc+1;\n   }\n\n        /* Each non-field member of a structure begins on an\n        addressing boundary appropriate to its type.\n                                                                */\n\n   diff[0] = &sc.c - &sc.cdummy;\n   diff[1] = (char *)&ss.s - &ss.cdummy;\n   diff[2] = (char *)&si.i - &si.cdummy;\n   diff[3] = (char *)&sl.l - &sl.cdummy;\n   diff[4] = (char *)&su.u - &su.cdummy;\n   diff[5] = (char *)&sf.f - &sf.cdummy;\n   diff[6] = (char *)&sd.d - &sd.cdummy;\n\n   if(pd0->flgm != 0)\n    for(j=0; j<7; j++)\n     printf(\"%s%s%d\\n\",type[j],aln,diff[j]);\n\n        /* Field specifications are highly implementation de-\n        pendent. About the only thing we can do here is to\n        check is that the compiler accepts the field constructs,\n        and that they seem to work, after a fashion, at\n        run time...\n                                                                */\n\n   s3.threebit = 7;\n   s3.twobit = s3.threebit;\n   s3.threebit = s3.twobit;\n\n   if(s3.threebit != 3){\n     if(s3.threebit == -1){\n       if(pd0->flgm != 0) printf(\"Sign extension in fields\\n\");\n     }\n     else{\n       if(pd0->flgd != 0) printf(s85er,2);\n       rc = rc+2;\n     }\n   }\n\n   s3.onebit = 1;\n   if(s3.onebit != 1){\n     if(pd0->flgm != 0)\n      printf(\"Be especially careful with 1-bit fields!\\n\");\n   }\n\n        /* A union may be thought of as a structure all of whose\n        members begin at offset 0 and whose size is sufficient\n        to contain any of its members.\n                                                                */\n\n   if( (char *)u0.u1 - (char *)&u0 != 0\n     ||(char *)u0.u2 - (char *)&u0 != 0\n     ||(char *)u0.u3 - (char *)&u0 != 0\n     ||(char *)u0.u4 - (char *)&u0 != 0\n     ||(char *)u0.u5 - (char *)&u0 != 0\n     ||(char *)u0.u6 - (char *)&u0 != 0\n     ||(char *)u0.u7 - (char *)&u0 != 0){\n\n     if(pd0->flgd != 0) printf(s85er,4);\n     rc = rc+4;\n   }\n\n   if( sizeof u0 < sizeof u0.u1\n     ||sizeof u0 < sizeof u0.u2\n     ||sizeof u0 < sizeof u0.u3\n     ||sizeof u0 < sizeof u0.u4\n     ||sizeof u0 < sizeof u0.u5\n     ||sizeof u0 < sizeof u0.u6\n     ||sizeof u0 < sizeof u0.u7){\n\n     if(pd0->flgd != 0) printf(s85er,8);\n     rc = rc+8;\n   }\n\n        /* Finally, we check that the pointers work.            */\n\n   s1.right = &s2;\n   s2.tword[0] = 2;\n   s1.right->tword[0] += 1;\n   if(s2.tword[0] != 3){\n     if(pd0->flgd != 0) printf(s85er,16);\n     rc = rc+16;\n   }\n   return rc;\n}\ns86(pd0)          /*  8.6 Initialization  */\nstruct defs *pd0;\n{\n   static char s86er[] = \"s86,er%d\\n\";\n   static char qs86[8] = \"s86    \";\n   int lrc, rc;\n   char *ps, *pt;\n   int one(), i, j, k;\n   static int x[] = {1,3,5};\n   static int *pint = x+2;\n   static int zero[10];\n   int *apint = pint-1;\n   register int *rpint = apint+one();\n   static float y0[] = {1,3,5,2,4,6,3,5,7,0,0,0};\n   static float y1[4][3] = {\n     {1,3,5},\n     {2,4,6},\n     {3,5,7},\n   };\n   static float y2[4][3] = {1,3,5,2,4,6,3,5,7};\n   static float y3[4][3] = {\n     {1},{2},{3},{4}\n   };\n   ps = qs86;\n   pt = pd0->rfs;\n   rc = 0;\n   while (*pt++ = *ps++);\n\n        /* The expression in an initializer for a static or\n        external variable must be a constant expression or\n        an expression that reduces to the address of a pre-\n        viously declared variable, possibly offset by a\n        constant expression.\n                                                                */\n\n   if(*pint != 5){\n     if(pd0->flgd != 0) printf(s86er,1);\n     rc = rc+1;\n   }\n\n        /* Automatic and register variables may be initialized\n        by arbitrary expressions involving constants and previously\n        declared variables and functions.\n                                                                */\n\n   if(*apint != 3){\n     if(pd0->flgd != 0) printf(s86er,2);\n     rc = rc+2;\n   }\n\n   if(*rpint != 5){\n     if(pd0->flgd != 0) printf(s86er,4);\n     rc = rc+4;\n   }\n\n        /* Static variables that are not initialized are guar-\n        anteed to start off as zero.\n                                                        */\n\n   lrc = 0;\n   for(j=0; j<10; j++)\n     if(zero[j] != 0) lrc = 1;\n   if(lrc != 0){\n     if(pd0->flgd != 0) printf(s86er,8);\n     rc = rc+8;\n   }\n\n        /* y0, y1, and y2, as declared, should define and \n        initialize identical arrays.\n                                                                */\n   lrc = 0;\n   for(i=0; i<4; i++)\n     for(j=0; j<3; j++){\n       k = 3*i+j;\n       if( y1[i][j] != y2[i][j]\n         ||y1[i][j] != y0[k]) lrc = 1;\n     }\n\n   if(lrc != 0){\n     if(pd0->flgd != 0) printf(s86er,16);\n     rc = rc+16;\n   }\n\n        /* y3 initializes the first column of the array and\n        leaves the rest zero.\n                                                                */\n\n   lrc = 0;\n   for(j=0; j<4; j++) if(y3[j][0] != j+1) lrc = 1;\n\n   if(lrc != 0){\n     if(pd0->flgd != 0) printf(s86er,32);\n     rc = rc+32;\n   }\n   return rc;\n}\none(){\n   return 1;\n}\nint *metricp;\ns88(pd0)          /*  8.8 Typedef  */\nstruct defs *pd0;\n{\n   static char s88er[] = \"s88,er%d\\n\";\n   static char qs88[8] = \"s88    \";\n   int rc;\n   char *ps, *pt;\n\n        /* Declarations whose \"storage class\" is typdef do not\n        define storage, but instead define identifiers which\n        can later be used as if they were type keywords naming\n        fundamental or derived types.\n                                                                */\n\n   typedef int MILES, *KLICKSP;\n   typedef struct {double re, im;} complex;\n\n   MILES distance;\n   extern KLICKSP metricp;\n   complex z, *zp;\n\n   ps = qs88;\n   pt = pd0->rfs;\n   rc = 0;\n   while(*pt++ = *ps++);\n\n        /* Hopefully, all of this stuff will compile. After that,\n        we can only make some superficial tests.\n\n        The type of distance is int,\n                                                                */\n\n   if(sizeof distance != sizeof(int)){\n     if(pd0->flgd != 0) printf(s88er,1);\n     rc = rc+1;\n   }\n\n        /* that of metricp is \"pointer to int\",                 */\n\n   metricp = &distance;\n   distance = 2;\n   *metricp = 3;\n\n   if(distance != 3){\n     if(pd0->flgd != 0) printf(s88er,2);\n     rc = rc+2;\n   }\n\n        /* and that of z is the specified structure. zp is a\n        pointer to such a structure.\n                                                                */\n\n   z.re = 0.;\n   z.im = 0.;\n   zp = &z;\n   zp->re = 1.;\n   zp->im = 1.;\n   if(z.re+z.im != 2.){\n     if(pd0->flgd != 0) printf(s88er,4);\n     rc = rc+4;\n   }\n\n   return rc;\n}\ns9(pd0)          /*  9  Statements  */\nstruct defs *pd0;\n{\n   static char s9er[] = \"s9,er%d\\n\";\n   static char qs9[8] = \"s9     \";\n   int rc;\n   char *ps, *pt;\n   int lrc, i;\n\n   ps = qs9;\n   pt = pd0->rfs;\n   rc = 0;\n   while (*pt++ = *ps++);\n\n        /* One would think that the section on statements would\n        provide the most variety in the entire sequence of tests.\n        As it turns out, most of the material in this section has \n        already been checked in the process of checking out\n        everything else, and the section at this point is somewhat\n        anticlimactic. For this reason, we restrict ourselves\n        to testing two features not already covered.\n\n        Compound statements are delimited by braces. They have the\n        nice property that identifiers of the auto and register\n        variety are pushed and popped. It is currently legal to\n        transfer into a block, but we wont...\n                                                                */\n\n   lrc = 0;\n   for(i=0; i<2; i++){\n     int j;\n     register int k;\n     j = k = 2;\n       {\n       int j;\n       register int k;\n       j = k = 3;\n       if((j != 3) || (k != 3)) lrc = 1;\n       }\n     if((j != 2) || (k != 2)) lrc = 1;\n   }\n\n   if(lrc != 0){\n     if(pd0->flgd != 0) printf(s9er,1);\n     rc = rc+1;\n   }\n\n        /* Goto statements go to labeled statements, we hope.   */\n\n   goto nobarf;\n     if(pd0->flgd != 0) printf(s9er,2);\n     rc = rc+2;\n   nobarf:;\n\n   return rc;\n}\nsetev(){                  /* Sets an external variable. Used  */\n   extern int extvar;     /* by s4, and should be compiled    */\n   extvar = 1066;         /* separately from s4.              */\n}\n     int lbits;          /*                 long           */\n     int ubits;          /*                 unsigned       */\n     int fbits;          /*                 float          */\n     int dbits;          /*                 double         */\n     float fprec;        /* Smallest number that can be    */\n     float dprec;        /* significantly added to 1.      */\n     int flgs;           /* Print return codes, by section */\n     int flgm;           /* Announce machine dependencies  */\n     int flgd;           /* give explicit diagnostics      */\n     int flgl;           /* Report local return codes.     */\n     int rrc;            /* recent return code             */\n     int crc;            /* Cumulative return code         */\n     char rfs[8];        /* Return from section            */\n"
  },
  {
    "path": "lcc/tst/cvt.0",
    "content": ""
  },
  {
    "path": "lcc/tst/cvt.c",
    "content": "signed char c;\nsigned short s;\nsigned int i;\nsigned long int l;\nunsigned char C;\nunsigned short S;\nunsigned int I;\nunsigned long int L;\nfloat f;\ndouble d;\nlong double D;\nvoid *p;\nvoid (*P)(void);\n\nvoid print(void) {\n\tprintf(\"%d %d %d %ld %u %u %u %lu %f %f %lf\\n\",c,s,i,l,C,S,I,L,f,d,D);\n}\n\nmain() {\n\tc= 1;     s=c;i=c;l=c;C=c;S=c;I=c;L=c;f=c;d=c;D=c; print();\n\ts= 2; c=s;    i=s;l=s;C=s;S=s;I=s;L=s;f=s;d=s;D=s; print();\n\ti= 3; c=i;s=i;    l=i;C=i;S=i;I=i;L=i;f=i;d=i;D=i; print();\n\tl= 4; c=l;s=l;i=l;    C=l;S=l;I=l;L=l;f=l;d=l;D=l; print();\n\tC= 5; c=C;s=C;i=C;l=C;    S=C;I=C;L=C;f=C;d=C;D=C; print();\n\tS= 6; c=S;s=S;i=S;l=S;C=S;    I=S;L=S;f=S;d=S;D=S; print();\n\tI= 7; c=I;s=I;i=I;l=I;C=I;S=I;    L=I;f=I;d=I;D=I; print();\n\tL= 8; c=L;s=L;i=L;l=L;C=L;S=L;I=S;    f=L;d=L;D=L; print();\n\tf= 9; c=f;s=f;i=f;l=f;C=f;S=f;I=f;L=f;    d=f;D=f; print();\n\td=10; c=d;s=d;i=d;l=d;C=d;S=d;I=d;L=d;f=d;    D=d; print();\n\tD=11; c=D;s=D;i=D;l=D;C=D;S=D;I=D;L=D;f=D;d=D;     print();\n\n\tp=0; p=0L; p=0U; p=0UL; p=P;\n\tP=0; P=0L; P=0U; P=0UL; P=p;\n\treturn 0;\n}\n"
  },
  {
    "path": "lcc/tst/fields.0",
    "content": ""
  },
  {
    "path": "lcc/tst/fields.c",
    "content": "struct foo {\n\tint a;\n\tchar b;\n\tint x : 12, y : 4, : 0, : 4, z : 3;\n\tchar c;\n} x = { 1, 2, 3, 4, 5, 6 };\nint i = 16;\nstruct baz { unsigned int a:2, b:4, c:32;} y = { 7, 8, 9};\n\nmain()\n{\n\tprintf(\"x = %d %d %d %d %d %d\\n\", x.a, x.b, x.x, x.y, x.z, x.c);\n\tprintf(\"y = %d %d %d\\n\", y.a, y.b, y.c);\n\tx.y = i;\n\tx.z = 070;\n\tprintf(\"x = %d %d %d %d %d %d\\n\", x.a, x.b, x.x, x.y, x.z, x.c);\n\ty.a = 2;\n\ty.c = i;\n\tprintf(\"y = %d %d %d\\n\", y.a, y.b, y.c);\n\tf2(&x);\n\treturn 0;\n}\n\nf1(struct baz *p) {\n\tp->a = p->b = 0;\n\tif (p->b)\n\t\tprintf(\"p->b != 0!\\n\");\n\tp->a = 0x3; p->b = 0xf;\n\tprintf(\"p->a = 0x%x, p->b = 0x%x\\n\", p->a, p->b);\n}\nf2(struct baz *p) {\n\tp->a = (i==0);\n\tp->b = (f1(p),0);\n}\n"
  },
  {
    "path": "lcc/tst/front.0",
    "content": ""
  },
  {
    "path": "lcc/tst/front.c",
    "content": "main() {\n\texit(0);\n}\n\nnested(a,b) {\n\tif ((a<4 && b == 'r')\n\t\t|| (a == 1 && (b == 'h' || b == 'i'))\n\t\t|| (a == 2 && (b == 'o' || b == 'y'))\n\t) a=b;\n}\n\n/* type name scope */\n\nvoid s(struct D *d) {}\t/* this struct D differs from the one below */\ntypedef struct D D;\nstruct D {int x, y;} Dy={0};\nD Dz={1};\nDfunc(){\n\tD a; a.y=1;\n\ts(&Dy);\t\t/* error */\n}\n\n/* qualifiers */\n\nconst a; int b;\nconst int a, *x; int b, *y;\nvolatile unsigned z;\n\nf() {\n\tx = y;\n\tz = z + z;\t/* should be 2 references to z's r-value */\n}\nf1() {\n\tx = &a;\n\tx = &b;\n\ty = &a;\t\t/* error */\n\ty = &b;\n}\nf2(int **a, int **b) {\n\tf(&x, &y);\n\t**a = 0;\n\treturn **b;\n}\ng(const int *p) {\n\tg(&a);\n\tg(&b);\n\treturn *p;\n}\nh(int *p) {\n\tf(&a);\n\tf(&b);\n\treturn *p;\n}\nh1(const int x, int y) {\n\th1(a,b);\n\th1(b,a);\n\treturn x + y;\n}\nh2() {\n\tchar *b; const void *p;\n\tp = b;\n\tb = p;\t\t/* error */\n}\n\n\n/* static naming */\n\nextern int yy; set1() { { static yy=1; yy=2;} yy=4;}\nstatic int yy; set2() { yy=5; {static yy=2; yy=3; }}\nstatic void goo() {}\nsss() { int goo; { static int goo();} goo=1;}\nrrr(p) float *p; { extern int xr;\n { static float xr;\n { extern int *xr; } p=&xr; }}\n\n/* local extern */\n\nstatic int ss1;\nint ss3;\nextern int ss5;\nsetstatic() { extern int ss1,ss2,ss3,ss4; ss1 = ss2; ss3 = ss4; ss5 = 0;}\nstatic int ss2;\nint ss4;\nstatic int ss5;\n\n/* function prototypes */\n\nint fx1(void);\nint fx1();\n\nint gx1(double x);\nint gx1(x) double x; { gx1(&x); }\t/* error */\n\nint hx1();\nint hx1(double x,...);\t/* error */\n\nint ff1(double x, int *y);\nint ff1(x,y) float x; int y[]; {x=y[0];}\n\nint gg1(int a);\nint gg1(a,b){a=b;}\n\nint hh1(const int x);\nhh1(a) {return a;}\n\nextern int strcmp(const char*, const char*);\nextern void qsort(void*, int, int, int (*)(const void*, const void*));\nextern int cmp(char**a, char**b) { return strcmp(*a,*b); }\nsort() {\n\tint n; char *a[100];\n\tqsort(a, n, sizeof(char*), (int (*)(const void*, const void*))cmp);\n\tqsort(a, n, sizeof(char*), cmp);\t/* error */\n}\n\n/* nasty calls */\n\nonearg(){\n\tint a,b,c,d;\n\tf( ( (a? (b = 1): (c = 2)), (d ? 3 : 4) ) );\t/* 1 argument */\n}\n"
  },
  {
    "path": "lcc/tst/incr.0",
    "content": ""
  },
  {
    "path": "lcc/tst/incr.c",
    "content": "main() {}\n\nmemchar() {\n\tchar x, *p;\n\n\t&x, &p;\n\tx = *p++;\n\tx = *++p;\n\tx = *p--;\n\tx = *--p;\n}\n\nmemint() {\n\tint x, *p;\n\n\t&x, &p;\n\tx = *p++;\n\tx = *++p;\n\tx = *p--;\n\tx = *--p;\n}\n\nregchar() {\n\tregister char x, *p;\n\n\tx = *p++;\n\tx = *++p;\n\tx = *p--;\n\tx = *--p;\n}\n\nregint() {\n\tregister int x, *p;\n\n\tx = *p++;\n\tx = *++p;\n\tx = *p--;\n\tx = *--p;\n}\n"
  },
  {
    "path": "lcc/tst/init.0",
    "content": ""
  },
  {
    "path": "lcc/tst/init.c",
    "content": "\ntypedef struct { int codes[3]; char name[6]; } Word;\n\nWord words[] = {\n\t1, 2, 3, \"if\",\n\t{ { 4, 5 }, { 'f', 'o', 'r' } },\n\t6, 7, 8, {\"else\"},\n\t{ { 9, 10, 11,}, 'w', 'h', 'i', 'l', 'e', },\n\t{ 0 },\n}, *wordlist = words;\n\nint x[][5] = { 1, 2, 3, 4, 0, { 5, 6 }, { 7 } };\nint *y[] = { x[0], x[1], x[2], 0 };\n\n\nmain()\n{\n\tint i, j;\n\n\tfor (i = 0; y[i]; i++) {\n\t\tfor (j = 0; y[i][j]; j++)\n\t\t\tprintf(\" %d\", y[i][j]);\n\t\tprintf(\"\\n\");\n\t}\n\tf();\n\tg(wordlist);\n\treturn 0;\n}\n\nf() {\n\tstatic char *keywords[] = {\"if\", \"for\", \"else\", \"while\", 0, };\n\tchar **p;\n\n\tfor (p = keywords; *p; p++)\n\t\tprintf(\"%s\\n\", *p);\n}\n\ng(p)\nWord *p;\n{\n\tint i;\n\n\tfor ( ; p->codes[0]; p++) {\n\t\tfor (i = 0; i < sizeof p->codes/sizeof(p->codes[0]); i++)\n\t\t\tprintf(\"%d \", p->codes[i]);\n\t\tprintf(\"%s\\n\", p->name);\n\t}\n\th();\n}\n\nh()\n{\n\tint i;\n\n\tfor (i = 0; i < sizeof(words)/sizeof(Word); i++)\n\t\tprintf(\"%d %d %d %s\\n\", words[i].codes[0],\n\t\t\twords[i].codes[1], words[i].codes[2],\n\t\t\t&words[i].name[0]);\n}\n"
  },
  {
    "path": "lcc/tst/limits.0",
    "content": ""
  },
  {
    "path": "lcc/tst/limits.c",
    "content": "#include <limits.h>\n\nmain() {\n\tprintf(\"UCHAR_MAX:\t%08x=%d\\n\", UCHAR_MAX, UCHAR_MAX);\n\tprintf(\"USHRT_MAX:\t%08x=%d\\n\", USHRT_MAX, USHRT_MAX);\n\tprintf(\"UINT_MAX:\t%08x=%d\\n\", UINT_MAX, UINT_MAX);\n\tprintf(\"ULONG_MAX:\t%08lx=%ld\\n\", ULONG_MAX, ULONG_MAX);\n\tprintf(\"CHAR_MAX:\t%08x=%d\\n\", CHAR_MAX, CHAR_MAX);\n\tprintf(\"SCHAR_MAX:\t%08x=%d\\n\", SCHAR_MAX, SCHAR_MAX);\n\tprintf(\"SHRT_MAX:\t%08x=%d\\n\", SHRT_MAX, SHRT_MAX);\n\tprintf(\"INT_MAX:\t%08x=%d\\n\", INT_MAX, INT_MAX);\n\tprintf(\"LONG_MAX:\t%08lx=%ld\\n\", LONG_MAX, LONG_MAX);\n\tprintf(\"CHAR_MIN:\t%08x=%d\\n\", CHAR_MIN, CHAR_MIN);\n\tprintf(\"SCHAR_MIN:\t%08x=%d\\n\", SCHAR_MIN, SCHAR_MIN);\n\tprintf(\"SHRT_MIN:\t%08x=%d\\n\", SHRT_MIN, SHRT_MIN);\n\tprintf(\"INT_MIN:\t%08x=%d\\n\", INT_MIN, INT_MIN);\n\tprintf(\"LONG_MIN:\t%08lx=%ld\\n\", LONG_MIN, LONG_MIN);\n\treturn 0;\n}\n"
  },
  {
    "path": "lcc/tst/paranoia.0",
    "content": ""
  },
  {
    "path": "lcc/tst/paranoia.c",
    "content": "#undef V9\n#define NOPAUSE\n/*\tA C version of Kahan's Floating Point Test \"Paranoia\"\n\n\t\t\tThos Sumner, UCSF, Feb. 1985\n\t\t\tDavid Gay, BTL, Jan. 1986\n\n\tThis is a rewrite from the Pascal version by\n\n\t\t\tB. A. Wichmann, 18 Jan. 1985\n\n\t(and does NOT exhibit good C programming style).\n\n(C) Apr 19 1983 in BASIC version by:\n\tProfessor W. M. Kahan,\n\t567 Evans Hall\n\tElectrical Engineering & Computer Science Dept.\n\tUniversity of California\n\tBerkeley, California 94720\n\tUSA\n\nconverted to Pascal by:\n\tB. A. Wichmann\n\tNational Physical Laboratory\n\tTeddington Middx\n\tTW11 OLW\n\tUK\n\nconverted to C by:\n\n\tDavid M. Gay\t\tand\tThos Sumner\n\tAT&T Bell Labs\t\t\tComputer Center, Rm. U-76\n\t600 Mountain Avenue\t\tUniversity of California\n\tMurray Hill, NJ 07974\t\tSan Francisco, CA 94143\n\tUSA\t\t\t\tUSA\n\nwith simultaneous corrections to the Pascal source (reflected\nin the Pascal source available over netlib).\n[A couple of bug fixes from dgh = sun!dhough incorporated 31 July 1986.]\n\nReports of results on various systems from all the versions\nof Paranoia are being collected by Richard Karpinski at the\nsame address as Thos Sumner.  This includes sample outputs,\nbug reports, and criticisms.\n\nYou may copy this program freely if you acknowledge its source.\nComments on the Pascal version to NPL, please.\n\n\nThe C version catches signals from floating-point exceptions.\nIf signal(SIGFPE,...) is unavailable in your environment, you may\n#define NOSIGNAL to comment out the invocations of signal.\n\nThis source file is too big for some C compilers, but may be split\ninto pieces.  Comments containing \"SPLIT\" suggest convenient places\nfor this splitting.  At the end of these comments is an \"ed script\"\n(for the UNIX(tm) editor ed) that will do this splitting.\n\nBy #defining Single when you compile this source, you may obtain\na single-precision C version of Paranoia.\n\n\nThe following is from the introductory commentary from Wichmann's work:\n\nThe BASIC program of Kahan is written in Microsoft BASIC using many\nfacilities which have no exact analogy in Pascal.  The Pascal\nversion below cannot therefore be exactly the same.  Rather than be\na minimal transcription of the BASIC program, the Pascal coding\nfollows the conventional style of block-structured languages.  Hence\nthe Pascal version could be useful in producing versions in other\nstructured languages.\n\nRather than use identifiers of minimal length (which therefore have\nlittle mnemonic significance), the Pascal version uses meaningful\nidentifiers as follows [Note: A few changes have been made for C]:\n\n\nBASIC   C               BASIC   C               BASIC   C               \n\n   A                       J                       S    StickyBit\n   A1   AInverse           J0   NoErrors           T\n   B    Radix                    [Failure]         T0   Underflow\n   B1   BInverse           J1   NoErrors           T2   ThirtyTwo\n   B2   RadixD2                  [SeriousDefect]   T5   OneAndHalf\n   B9   BMinusU2           J2   NoErrors           T7   TwentySeven\n   C                             [Defect]          T8   TwoForty\n   C1   CInverse           J3   NoErrors           U    OneUlp\n   D                             [Flaw]            U0   UnderflowThreshold\n   D4   FourD              K    PageNo             U1\n   E0                      L    Milestone          U2\n   E1                      M                       V\n   E2   Exp2               N                       V0\n   E3                      N1                      V8\n   E5   MinSqEr            O    Zero               V9\n   E6   SqEr               O1   One                W\n   E7   MaxSqEr            O2   Two                X\n   E8                      O3   Three              X1\n   E9                      O4   Four               X8\n   F1   MinusOne           O5   Five               X9   Random1\n   F2   Half               O8   Eight              Y\n   F3   Third              O9   Nine               Y1\n   F6                      P    Precision          Y2\n   F9                      Q                       Y9   Random2\n   G1   GMult              Q8                      Z\n   G2   GDiv               Q9                      Z0   PseudoZero\n   G3   GAddSub            R                       Z1\n   H                       R1   RMult              Z2\n   H1   HInverse           R2   RDiv               Z9\n   I                       R3   RAddSub\n   IO   NoTrials           R4   RSqrt\n   I3   IEEE               R9   Random9\n\n   SqRWrng\n\nAll the variables in BASIC are true variables and in consequence,\nthe program is more difficult to follow since the \"constants\" must\nbe determined (the glossary is very helpful).  The Pascal version\nuses Real constants, but checks are added to ensure that the values\nare correctly converted by the compiler.\n\nThe major textual change to the Pascal version apart from the\nidentifiersis that named procedures are used, inserting parameters\nwherehelpful.  New procedures are also introduced.  The\ncorrespondence is as follows:\n\n\nBASIC       Pascal\nlines \n\n  90- 140   Pause\n 170- 250   Instructions\n 380- 460   Heading\n 480- 670   Characteristics\n 690- 870   History\n2940-2950   Random\n3710-3740   NewD\n4040-4080   DoesYequalX\n4090-4110   PrintIfNPositive\n4640-4850   TestPartialUnderflow\n\n=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=\n\nBelow is an \"ed script\" that splits para.c into 10 files\nof the form part[1-8].c, subs.c, and msgs.c, plus a header\nfile, paranoia.h, that these files require.\n\nr paranoia.c\n$\n?SPLIT\n+,$w msgs.c\n .,$d\n?SPLIT\n .d\n+d\n-,$w subs.c\n-,$d\n?part8\n+d\n?include\n .,$w part8.c\n .,$d\n-d\n?part7\n+d\n?include\n .,$w part7.c\n .,$d\n-d\n?part6\n+d\n?include\n .,$w part6.c\n .,$d\n-d\n?part5\n+d\n?include\n .,$w part5.c\n .,$d\n-d\n?part4\n+d\n?include\n .,$w part4.c\n .,$d\n-d\n?part3\n+d\n?include\n .,$w part3.c\n .,$d\n-d\n?part2\n+d\n?include\n .,$w part2.c\n .,$d\n?SPLIT\n .d\n1,/^#include/-1d\n1,$w part1.c\n/Computed constants/,$d\n1,$s/^int/extern &/\n1,$s/^FLOAT/extern &/\n1,$s/^char/extern &/\n1,$s! = .*!;!\n/^Guard/,/^Round/s/^/extern /\n/^jmp_buf/s/^/extern /\n/^Sig_type/s/^/extern /\ns/$/\\\nextern void sigfpe();/\nw paranoia.h\nq\n\n*/\n\n#include <stdio.h>\n#ifndef NOSIGNAL\n#include <signal.h>\n#endif\n#include <setjmp.h>\n\nextern double fabs(), floor(), log(), pow(), sqrt();\n\n#ifdef Single\n#define FLOAT float\n#define FABS(x) (float)fabs((double)(x))\n#define FLOOR(x) (float)floor((double)(x))\n#define LOG(x) (float)log((double)(x))\n#define POW(x,y) (float)pow((double)(x),(double)(y))\n#define SQRT(x) (float)sqrt((double)(x))\n#else\n#define FLOAT double\n#define FABS(x) fabs(x)\n#define FLOOR(x) floor(x)\n#define LOG(x) log(x)\n#define POW(x,y) pow(x,y)\n#define SQRT(x) sqrt(x)\n#endif\n\njmp_buf ovfl_buf;\ntypedef void (*Sig_type)();\nSig_type sigsave;\n\n#define KEYBOARD 0\n\nFLOAT Radix, BInvrse, RadixD2, BMinusU2;\nFLOAT Sign(), Random();\n\n/*Small floating point constants.*/\nFLOAT Zero = 0.0;\nFLOAT Half = 0.5;\nFLOAT One = 1.0;\nFLOAT Two = 2.0;\nFLOAT Three = 3.0;\nFLOAT Four = 4.0;\nFLOAT Five = 5.0;\nFLOAT Eight = 8.0;\nFLOAT Nine = 9.0;\nFLOAT TwentySeven = 27.0;\nFLOAT ThirtyTwo = 32.0;\nFLOAT TwoForty = 240.0;\nFLOAT MinusOne = -1.0;\nFLOAT OneAndHalf = 1.5;\n/*Integer constants*/\nint NoTrials = 20; /*Number of tests for commutativity. */\n#define False 0\n#define True 1\n\n/* Definitions for declared types \n\tGuard == (Yes, No);\n\tRounding == (Chopped, Rounded, Other);\n\tMessage == packed array [1..40] of char;\n\tClass == (Flaw, Defect, Serious, Failure);\n\t  */\n#define Yes 1\n#define No  0\n#define Chopped 2\n#define Rounded 1\n#define Other   0\n#define Flaw    3\n#define Defect  2\n#define Serious 1\n#define Failure 0\ntypedef int Guard, Rounding, Class;\ntypedef char Message;\n\n/* Declarations of Variables */\nint Indx;\nchar ch[8];\nFLOAT AInvrse, A1;\nFLOAT C, CInvrse;\nFLOAT D, FourD;\nFLOAT E0, E1, Exp2, E3, MinSqEr;\nFLOAT SqEr, MaxSqEr, E9;\nFLOAT Third;\nFLOAT F6, F9;\nFLOAT H, HInvrse;\nint I;\nFLOAT StickyBit, J;\nFLOAT MyZero;\nFLOAT Precision;\nFLOAT Q, Q9;\nFLOAT R, Random9;\nFLOAT T, Underflow, S;\nFLOAT OneUlp, UfThold, U1, U2;\nFLOAT V, V0, V9;\nFLOAT W;\nFLOAT X, X1, X2, X8, Random1;\nFLOAT Y, Y1, Y2, Random2;\nFLOAT Z, PseudoZero, Z1, Z2, Z9;\nint ErrCnt[4];\nint fpecount;\nint Milestone;\nint PageNo;\nint M, N, N1;\nGuard GMult, GDiv, GAddSub;\nRounding RMult, RDiv, RAddSub, RSqrt;\nint Break, Done, NotMonot, Monot, Anomaly, IEEE,\n\t\tSqRWrng, UfNGrad;\n/* Computed constants. */\n/*U1  gap below 1.0, i.e, 1.0-U1 is next number below 1.0 */\n/*U2  gap above 1.0, i.e, 1.0+U2 is next number above 1.0 */\n\n/* floating point exception receiver */\n void\nsigfpe(i)\n{\n\tfpecount++;\n\tprintf(\"\\n* * * FLOATING-POINT ERROR * * *\\n\");\n\tfflush(stdout);\n\tif (sigsave) {\n#ifndef NOSIGNAL\n\t\tsignal(SIGFPE, sigsave);\n#endif\n\t\tsigsave = 0;\n\t\tlongjmp(ovfl_buf, 1);\n\t\t}\n\tabort();\n}\n\nmain()\n{\n#ifdef mc\n\tchar *out;\n\tieee_flags(\"set\", \"precision\", \"double\", &out);\n#endif\n\t/* First two assignments use integer right-hand sides. */\n\tZero = 0;\n\tOne = 1;\n\tTwo = One + One;\n\tThree = Two + One;\n\tFour = Three + One;\n\tFive = Four + One;\n\tEight = Four + Four;\n\tNine = Three * Three;\n\tTwentySeven = Nine * Three;\n\tThirtyTwo = Four * Eight;\n\tTwoForty = Four * Five * Three * Four;\n\tMinusOne = -One;\n\tHalf = One / Two;\n\tOneAndHalf = One + Half;\n\tErrCnt[Failure] = 0;\n\tErrCnt[Serious] = 0;\n\tErrCnt[Defect] = 0;\n\tErrCnt[Flaw] = 0;\n\tPageNo = 1;\n\t/*=============================================*/\n\tMilestone = 0;\n\t/*=============================================*/\n#ifndef NOSIGNAL\n\tsignal(SIGFPE, sigfpe);\n#endif\n\tInstructions();\n\tPause();\n\tHeading();\n\tPause();\n\tCharacteristics();\n\tPause();\n\tHistory();\n\tPause();\n\t/*=============================================*/\n\tMilestone = 7;\n\t/*=============================================*/\n\tprintf(\"Program is now RUNNING tests on small integers:\\n\");\n\t\n\tTstCond (Failure, (Zero + Zero == Zero) && (One - One == Zero)\n\t\t   && (One > Zero) && (One + One == Two),\n\t\t\t\"0+0 != 0, 1-1 != 0, 1 <= 0, or 1+1 != 2\");\n\tZ = - Zero;\n\tif (Z != 0.0) {\n\t\tErrCnt[Failure] = ErrCnt[Failure] + 1;\n\t\tprintf(\"Comparison alleges that -0.0 is Non-zero!\\n\");\n\t\tU1 = 0.001;\n\t\tRadix = 1;\n\t\tTstPtUf();\n\t\t}\n\tTstCond (Failure, (Three == Two + One) && (Four == Three + One)\n\t\t   && (Four + Two * (- Two) == Zero)\n\t\t   && (Four - Three - One == Zero),\n\t\t   \"3 != 2+1, 4 != 3+1, 4+2*(-2) != 0, or 4-3-1 != 0\");\n\tTstCond (Failure, (MinusOne == (0 - One))\n\t\t   && (MinusOne + One == Zero ) && (One + MinusOne == Zero)\n\t\t   && (MinusOne + FABS(One) == Zero)\n\t\t   && (MinusOne + MinusOne * MinusOne == Zero),\n\t\t   \"-1+1 != 0, (-1)+abs(1) != 0, or -1+(-1)*(-1) != 0\");\n\tTstCond (Failure, Half + MinusOne + Half == Zero,\n\t\t  \"1/2 + (-1) + 1/2 != 0\");\n\t/*=============================================*/\n\t/*SPLIT\n\tpart2();\n\tpart3();\n\tpart4();\n\tpart5();\n\tpart6();\n\tpart7();\n\tpart8();\n\t}\n#include \"paranoia.h\"\npart2(){\n*/\n\tMilestone = 10;\n\t/*=============================================*/\n\tTstCond (Failure, (Nine == Three * Three)\n\t\t   && (TwentySeven == Nine * Three) && (Eight == Four + Four)\n\t\t   && (ThirtyTwo == Eight * Four)\n\t\t   && (ThirtyTwo - TwentySeven - Four - One == Zero),\n\t\t   \"9 != 3*3, 27 != 9*3, 32 != 8*4, or 32-27-4-1 != 0\");\n\tTstCond (Failure, (Five == Four + One) &&\n\t\t\t(TwoForty == Four * Five * Three * Four)\n\t\t   && (TwoForty / Three - Four * Four * Five == Zero)\n\t\t   && ( TwoForty / Four - Five * Three * Four == Zero)\n\t\t   && ( TwoForty / Five - Four * Three * Four == Zero),\n\t\t  \"5 != 4+1, 240/3 != 80, 240/4 != 60, or 240/5 != 48\");\n\tif (ErrCnt[Failure] == 0) {\n\t\tprintf(\"-1, 0, 1/2, 1, 2, 3, 4, 5, 9, 27, 32 & 240 are O.K.\\n\");\n\t\tprintf(\"\\n\");\n\t\t}\n\tprintf(\"Searching for Radix and Precision.\\n\");\n\tW = One;\n\tdo  {\n\t\tW = W + W;\n\t\tY = W + One;\n\t\tZ = Y - W;\n\t\tY = Z - One;\n\t\t} while (MinusOne + FABS(Y) < Zero);\n\t/*.. now W is just big enough that |((W+1)-W)-1| >= 1 ...*/\n\tPrecision = Zero;\n\tY = One;\n\tdo  {\n\t\tRadix = W + Y;\n\t\tY = Y + Y;\n\t\tRadix = Radix - W;\n\t\t} while ( Radix == Zero);\n\tif (Radix < Two) Radix = One;\n\tprintf(\"Radix = %f .\\n\", Radix);\n\tif (Radix != 1) {\n\t\tW = One;\n\t\tdo  {\n\t\t\tPrecision = Precision + One;\n\t\t\tW = W * Radix;\n\t\t\tY = W + One;\n\t\t\t} while ((Y - W) == One);\n\t\t}\n\t/*... now W == Radix^Precision is barely too big to satisfy (W+1)-W == 1\n\t\t\t                              ...*/\n\tU1 = One / W;\n\tU2 = Radix * U1;\n\tprintf(\"Closest relative separation found is U1 = %.7e .\\n\\n\", U1);\n\tprintf(\"Recalculating radix and precision\\n \");\n\t\n\t/*save old values*/\n\tE0 = Radix;\n\tE1 = U1;\n\tE9 = U2;\n\tE3 = Precision;\n\t\n\tX = Four / Three;\n\tThird = X - One;\n\tF6 = Half - Third;\n\tX = F6 + F6;\n\tX = FABS(X - Third);\n\tif (X < U2) X = U2;\n\t\n\t/*... now X = (unknown no.) ulps of 1+...*/\n\tdo  {\n\t\tU2 = X;\n\t\tY = Half * U2 + ThirtyTwo * U2 * U2;\n\t\tY = One + Y;\n\t\tX = Y - One;\n\t\t} while ( ! ((U2 <= X) || (X <= Zero)));\n\t\n\t/*... now U2 == 1 ulp of 1 + ... */\n\tX = Two / Three;\n\tF6 = X - Half;\n\tThird = F6 + F6;\n\tX = Third - Half;\n\tX = FABS(X + F6);\n\tif (X < U1) X = U1;\n\t\n\t/*... now  X == (unknown no.) ulps of 1 -... */\n\tdo  {\n\t\tU1 = X;\n\t\tY = Half * U1 + ThirtyTwo * U1 * U1;\n\t\tY = Half - Y;\n\t\tX = Half + Y;\n\t\tY = Half - X;\n\t\tX = Half + Y;\n\t\t} while ( ! ((U1 <= X) || (X <= Zero)));\n\t/*... now U1 == 1 ulp of 1 - ... */\n\tif (U1 == E1) printf(\"confirms closest relative separation U1 .\\n\");\n\telse printf(\"gets better closest relative separation U1 = %.7e .\\n\", U1);\n\tW = One / U1;\n\tF9 = (Half - U1) + Half;\n\tRadix = FLOOR(0.01 + U2 / U1);\n\tif (Radix == E0) printf(\"Radix confirmed.\\n\");\n\telse printf(\"MYSTERY: recalculated Radix = %.7e .\\n\", Radix);\n\tTstCond (Defect, Radix <= Eight + Eight,\n\t\t   \"Radix is too big: roundoff problems\");\n\tTstCond (Flaw, (Radix == Two) || (Radix == 10)\n\t\t   || (Radix == One), \"Radix is not as good as 2 or 10\");\n\t/*=============================================*/\n\tMilestone = 20;\n\t/*=============================================*/\n\tTstCond (Failure, F9 - Half < Half,\n\t\t   \"(1-U1)-1/2 < 1/2 is FALSE, prog. fails?\");\n\tX = F9;\n\tI = 1;\n\tY = X - Half;\n\tZ = Y - Half;\n\tTstCond (Failure, (X != One)\n\t\t   || (Z == Zero), \"Comparison is fuzzy,X=1 but X-1/2-1/2 != 0\");\n\tX = One + U2;\n\tI = 0;\n\t/*=============================================*/\n\tMilestone = 25;\n\t/*=============================================*/\n\t/*... BMinusU2 = nextafter(Radix, 0) */\n\tBMinusU2 = Radix - One;\n\tBMinusU2 = (BMinusU2 - U2) + One;\n\t/* Purify Integers */\n\tif (Radix != One)  {\n\t\tX = - TwoForty * LOG(U1) / LOG(Radix);\n\t\tY = FLOOR(Half + X);\n\t\tif (FABS(X - Y) * Four < One) X = Y;\n\t\tPrecision = X / TwoForty;\n\t\tY = FLOOR(Half + Precision);\n\t\tif (FABS(Precision - Y) * TwoForty < Half) Precision = Y;\n\t\t}\n\tif ((Precision != FLOOR(Precision)) || (Radix == One)) {\n\t\tprintf(\"Precision cannot be characterized by an Integer number\\n\");\n\t\tprintf(\"of significant digits but, by itself, this is a minor flaw.\\n\");\n\t\t}\n\tif (Radix == One) \n\t\tprintf(\"logarithmic encoding has precision characterized solely by U1.\\n\");\n\telse printf(\"The number of significant digits of the Radix is %f .\\n\",\n\t\t\tPrecision);\n\tTstCond (Serious, U2 * Nine * Nine * TwoForty < One,\n\t\t   \"Precision worse than 5 decimal figures  \");\n\t/*=============================================*/\n\tMilestone = 30;\n\t/*=============================================*/\n\t/* Test for extra-precise subepressions */\n\tX = FABS(((Four / Three - One) - One / Four) * Three - One / Four);\n\tdo  {\n\t\tZ2 = X;\n\t\tX = (One + (Half * Z2 + ThirtyTwo * Z2 * Z2)) - One;\n\t\t} while ( ! ((Z2 <= X) || (X <= Zero)));\n\tX = Y = Z = FABS((Three / Four - Two / Three) * Three - One / Four);\n\tdo  {\n\t\tZ1 = Z;\n\t\tZ = (One / Two - ((One / Two - (Half * Z1 + ThirtyTwo * Z1 * Z1))\n\t\t\t+ One / Two)) + One / Two;\n\t\t} while ( ! ((Z1 <= Z) || (Z <= Zero)));\n\tdo  {\n\t\tdo  {\n\t\t\tY1 = Y;\n\t\t\tY = (Half - ((Half - (Half * Y1 + ThirtyTwo * Y1 * Y1)) + Half\n\t\t\t\t)) + Half;\n\t\t\t} while ( ! ((Y1 <= Y) || (Y <= Zero)));\n\t\tX1 = X;\n\t\tX = ((Half * X1 + ThirtyTwo * X1 * X1) - F9) + F9;\n\t\t} while ( ! ((X1 <= X) || (X <= Zero)));\n\tif ((X1 != Y1) || (X1 != Z1)) {\n\t\tBadCond(Serious, \"Disagreements among the values X1, Y1, Z1,\\n\");\n\t\tprintf(\"respectively  %.7e,  %.7e,  %.7e,\\n\", X1, Y1, Z1);\n\t\tprintf(\"are symptoms of inconsistencies introduced\\n\");\n\t\tprintf(\"by extra-precise evaluation of arithmetic subexpressions.\\n\");\n\t\tnotify(\"Possibly some part of this\");\n\t\tif ((X1 == U1) || (Y1 == U1) || (Z1 == U1))  printf(\n\t\t\t\"That feature is not tested further by this program.\\n\") ;\n\t\t}\n\telse  {\n\t\tif ((Z1 != U1) || (Z2 != U2)) {\n\t\t\tif ((Z1 >= U1) || (Z2 >= U2)) {\n\t\t\t\tBadCond(Failure, \"\");\n\t\t\t\tnotify(\"Precision\");\n\t\t\t\tprintf(\"\\tU1 = %.7e, Z1 - U1 = %.7e\\n\",U1,Z1-U1);\n\t\t\t\tprintf(\"\\tU2 = %.7e, Z2 - U2 = %.7e\\n\",U2,Z2-U2);\n\t\t\t\t}\n\t\t\telse {\n\t\t\t\tif ((Z1 <= Zero) || (Z2 <= Zero)) {\n\t\t\t\t\tprintf(\"Because of unusual Radix = %f\", Radix);\n\t\t\t\t\tprintf(\", or exact rational arithmetic a result\\n\");\n\t\t\t\t\tprintf(\"Z1 = %.7e, or Z2 = %.7e \", Z1, Z2);\n\t\t\t\t\tnotify(\"of an\\nextra-precision\");\n\t\t\t\t\t}\n\t\t\t\tif (Z1 != Z2 || Z1 > Zero) {\n\t\t\t\t\tX = Z1 / U1;\n\t\t\t\t\tY = Z2 / U2;\n\t\t\t\t\tif (Y > X) X = Y;\n\t\t\t\t\tQ = - LOG(X);\n\t\t\t\t\tprintf(\"Some subexpressions appear to be calculated extra\\n\");\n\t\t\t\t\tprintf(\"precisely with about %g extra B-digits, i.e.\\n\",\n\t\t\t\t\t\t(Q / LOG(Radix)));\n\t\t\t\t\tprintf(\"roughly %g extra significant decimals.\\n\",\n\t\t\t\t\t\tQ / LOG(10.));\n\t\t\t\t\t}\n\t\t\t\tprintf(\"That feature is not tested further by this program.\\n\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tPause();\n\t/*=============================================*/\n\t/*SPLIT\n\t}\n#include \"paranoia.h\"\npart3(){\n*/\n\tMilestone = 35;\n\t/*=============================================*/\n\tif (Radix >= Two) {\n\t\tX = W / (Radix * Radix);\n\t\tY = X + One;\n\t\tZ = Y - X;\n\t\tT = Z + U2;\n\t\tX = T - Z;\n\t\tTstCond (Failure, X == U2,\n\t\t\t\"Subtraction is not normalized X=Y,X+Z != Y+Z!\");\n\t\tif (X == U2) printf(\n\t\t\t\"Subtraction appears to be normalized, as it should be.\");\n\t\t}\n\tprintf(\"\\nChecking for guard digit in *, /, and -.\\n\");\n\tY = F9 * One;\n\tZ = One * F9;\n\tX = F9 - Half;\n\tY = (Y - Half) - X;\n\tZ = (Z - Half) - X;\n\tX = One + U2;\n\tT = X * Radix;\n\tR = Radix * X;\n\tX = T - Radix;\n\tX = X - Radix * U2;\n\tT = R - Radix;\n\tT = T - Radix * U2;\n\tX = X * (Radix - One);\n\tT = T * (Radix - One);\n\tif ((X == Zero) && (Y == Zero) && (Z == Zero) && (T == Zero)) GMult = Yes;\n\telse {\n\t\tGMult = No;\n\t\tTstCond (Serious, False,\n\t\t\t\"* lacks a Guard Digit, so 1*X != X\");\n\t\t}\n\tZ = Radix * U2;\n\tX = One + Z;\n\tY = FABS((X + Z) - X * X) - U2;\n\tX = One - U2;\n\tZ = FABS((X - U2) - X * X) - U1;\n\tTstCond (Failure, (Y <= Zero)\n\t\t   && (Z <= Zero), \"* gets too many final digits wrong.\\n\");\n\tY = One - U2;\n\tX = One + U2;\n\tZ = One / Y;\n\tY = Z - X;\n\tX = One / Three;\n\tZ = Three / Nine;\n\tX = X - Z;\n\tT = Nine / TwentySeven;\n\tZ = Z - T;\n\tTstCond(Defect, X == Zero && Y == Zero && Z == Zero,\n\t\t\"Division lacks a Guard Digit, so error can exceed 1 ulp\\nor  1/3  and  3/9  and  9/27 may disagree\");\n\tY = F9 / One;\n\tX = F9 - Half;\n\tY = (Y - Half) - X;\n\tX = One + U2;\n\tT = X / One;\n\tX = T - X;\n\tif ((X == Zero) && (Y == Zero) && (Z == Zero)) GDiv = Yes;\n\telse {\n\t\tGDiv = No;\n\t\tTstCond (Serious, False,\n\t\t\t\"Division lacks a Guard Digit, so X/1 != X\");\n\t\t}\n\tX = One / (One + U2);\n\tY = X - Half - Half;\n\tTstCond (Serious, Y < Zero,\n\t\t   \"Computed value of 1/1.000..1 >= 1\");\n\tX = One - U2;\n\tY = One + Radix * U2;\n\tZ = X * Radix;\n\tT = Y * Radix;\n\tR = Z / Radix;\n\tStickyBit = T / Radix;\n\tX = R - X;\n\tY = StickyBit - Y;\n\tTstCond (Failure, X == Zero && Y == Zero,\n\t\t\t\"* and/or / gets too many last digits wrong\");\n\tY = One - U1;\n\tX = One - F9;\n\tY = One - Y;\n\tT = Radix - U2;\n\tZ = Radix - BMinusU2;\n\tT = Radix - T;\n\tif ((X == U1) && (Y == U1) && (Z == U2) && (T == U2)) GAddSub = Yes;\n\telse {\n\t\tGAddSub = No;\n\t\tTstCond (Serious, False,\n\t\t\t\"- lacks Guard Digit, so cancellation is obscured\");\n\t\t}\n\tif (F9 != One && F9 - One >= Zero) {\n\t\tBadCond(Serious, \"comparison alleges  (1-U1) < 1  although\\n\");\n\t\tprintf(\"  subtraction yields  (1-U1) - 1 = 0 , thereby vitiating\\n\");\n\t\tprintf(\"  such precautions against division by zero as\\n\");\n\t\tprintf(\"  ...  if (X == 1.0) {.....} else {.../(X-1.0)...}\\n\");\n\t\t}\n\tif (GMult == Yes && GDiv == Yes && GAddSub == Yes) printf(\n\t\t\"     *, /, and - appear to have guard digits, as they should.\\n\");\n\t/*=============================================*/\n\tMilestone = 40;\n\t/*=============================================*/\n\tPause();\n\tprintf(\"Checking rounding on multiply, divide and add/subtract.\\n\");\n\tRMult = Other;\n\tRDiv = Other;\n\tRAddSub = Other;\n\tRadixD2 = Radix / Two;\n\tA1 = Two;\n\tDone = False;\n\tdo  {\n\t\tAInvrse = Radix;\n\t\tdo  {\n\t\t\tX = AInvrse;\n\t\t\tAInvrse = AInvrse / A1;\n\t\t\t} while ( ! (FLOOR(AInvrse) != AInvrse));\n\t\tDone = (X == One) || (A1 > Three);\n\t\tif (! Done) A1 = Nine + One;\n\t\t} while ( ! (Done));\n\tif (X == One) A1 = Radix;\n\tAInvrse = One / A1;\n\tX = A1;\n\tY = AInvrse;\n\tDone = False;\n\tdo  {\n\t\tZ = X * Y - Half;\n\t\tTstCond (Failure, Z == Half,\n\t\t\t\"X * (1/X) differs from 1\");\n\t\tDone = X == Radix;\n\t\tX = Radix;\n\t\tY = One / X;\n\t\t} while ( ! (Done));\n\tY2 = One + U2;\n\tY1 = One - U2;\n\tX = OneAndHalf - U2;\n\tY = OneAndHalf + U2;\n\tZ = (X - U2) * Y2;\n\tT = Y * Y1;\n\tZ = Z - X;\n\tT = T - X;\n\tX = X * Y2;\n\tY = (Y + U2) * Y1;\n\tX = X - OneAndHalf;\n\tY = Y - OneAndHalf;\n\tif ((X == Zero) && (Y == Zero) && (Z == Zero) && (T <= Zero)) {\n\t\tX = (OneAndHalf + U2) * Y2;\n\t\tY = OneAndHalf - U2 - U2;\n\t\tZ = OneAndHalf + U2 + U2;\n\t\tT = (OneAndHalf - U2) * Y1;\n\t\tX = X - (Z + U2);\n\t\tStickyBit = Y * Y1;\n\t\tS = Z * Y2;\n\t\tT = T - Y;\n\t\tY = (U2 - Y) + StickyBit;\n\t\tZ = S - (Z + U2 + U2);\n\t\tStickyBit = (Y2 + U2) * Y1;\n\t\tY1 = Y2 * Y1;\n\t\tStickyBit = StickyBit - Y2;\n\t\tY1 = Y1 - Half;\n\t\tif ((X == Zero) && (Y == Zero) && (Z == Zero) && (T == Zero)\n\t\t\t&& ( StickyBit == Zero) && (Y1 == Half)) {\n\t\t\tRMult = Rounded;\n\t\t\tprintf(\"Multiplication appears to round correctly.\\n\");\n\t\t\t}\n\t\telse\tif ((X + U2 == Zero) && (Y < Zero) && (Z + U2 == Zero)\n\t\t\t\t&& (T < Zero) && (StickyBit + U2 == Zero)\n\t\t\t\t&& (Y1 < Half)) {\n\t\t\t\tRMult = Chopped;\n\t\t\t\tprintf(\"Multiplication appears to chop.\\n\");\n\t\t\t\t}\n\t\t\telse printf(\"* is neither chopped nor correctly rounded.\\n\");\n\t\tif ((RMult == Rounded) && (GMult == No)) notify(\"Multiplication\");\n\t\t}\n\telse printf(\"* is neither chopped nor correctly rounded.\\n\");\n\t/*=============================================*/\n\tMilestone = 45;\n\t/*=============================================*/\n\tY2 = One + U2;\n\tY1 = One - U2;\n\tZ = OneAndHalf + U2 + U2;\n\tX = Z / Y2;\n\tT = OneAndHalf - U2 - U2;\n\tY = (T - U2) / Y1;\n\tZ = (Z + U2) / Y2;\n\tX = X - OneAndHalf;\n\tY = Y - T;\n\tT = T / Y1;\n\tZ = Z - (OneAndHalf + U2);\n\tT = (U2 - OneAndHalf) + T;\n\tif (! ((X > Zero) || (Y > Zero) || (Z > Zero) || (T > Zero))) {\n\t\tX = OneAndHalf / Y2;\n\t\tY = OneAndHalf - U2;\n\t\tZ = OneAndHalf + U2;\n\t\tX = X - Y;\n\t\tT = OneAndHalf / Y1;\n\t\tY = Y / Y1;\n\t\tT = T - (Z + U2);\n\t\tY = Y - Z;\n\t\tZ = Z / Y2;\n\t\tY1 = (Y2 + U2) / Y2;\n\t\tZ = Z - OneAndHalf;\n\t\tY2 = Y1 - Y2;\n\t\tY1 = (F9 - U1) / F9;\n\t\tif ((X == Zero) && (Y == Zero) && (Z == Zero) && (T == Zero)\n\t\t\t&& (Y2 == Zero) && (Y2 == Zero)\n\t\t\t&& (Y1 - Half == F9 - Half )) {\n\t\t\tRDiv = Rounded;\n\t\t\tprintf(\"Division appears to round correctly.\\n\");\n\t\t\tif (GDiv == No) notify(\"Division\");\n\t\t\t}\n\t\telse if ((X < Zero) && (Y < Zero) && (Z < Zero) && (T < Zero)\n\t\t\t&& (Y2 < Zero) && (Y1 - Half < F9 - Half)) {\n\t\t\tRDiv = Chopped;\n\t\t\tprintf(\"Division appears to chop.\\n\");\n\t\t\t}\n\t\t}\n\tif (RDiv == Other) printf(\"/ is neither chopped nor correctly rounded.\\n\");\n\tBInvrse = One / Radix;\n\tTstCond (Failure, (BInvrse * Radix - Half == Half),\n\t\t   \"Radix * ( 1 / Radix ) differs from 1\");\n\t/*=============================================*/\n\t/*SPLIT\n\t}\n#include \"paranoia.h\"\npart4(){\n*/\n\tMilestone = 50;\n\t/*=============================================*/\n\tTstCond (Failure, ((F9 + U1) - Half == Half)\n\t\t   && ((BMinusU2 + U2 ) - One == Radix - One),\n\t\t   \"Incomplete carry-propagation in Addition\");\n\tX = One - U1 * U1;\n\tY = One + U2 * (One - U2);\n\tZ = F9 - Half;\n\tX = (X - Half) - Z;\n\tY = Y - One;\n\tif ((X == Zero) && (Y == Zero)) {\n\t\tRAddSub = Chopped;\n\t\tprintf(\"Add/Subtract appears to be chopped.\\n\");\n\t\t}\n\tif (GAddSub == Yes) {\n\t\tX = (Half + U2) * U2;\n\t\tY = (Half - U2) * U2;\n\t\tX = One + X;\n\t\tY = One + Y;\n\t\tX = (One + U2) - X;\n\t\tY = One - Y;\n\t\tif ((X == Zero) && (Y == Zero)) {\n\t\t\tX = (Half + U2) * U1;\n\t\t\tY = (Half - U2) * U1;\n\t\t\tX = One - X;\n\t\t\tY = One - Y;\n\t\t\tX = F9 - X;\n\t\t\tY = One - Y;\n\t\t\tif ((X == Zero) && (Y == Zero)) {\n\t\t\t\tRAddSub = Rounded;\n\t\t\t\tprintf(\"Addition/Subtraction appears to round correctly.\\n\");\n\t\t\t\tif (GAddSub == No) notify(\"Add/Subtract\");\n\t\t\t\t}\n\t\t\telse printf(\"Addition/Subtraction neither rounds nor chops.\\n\");\n\t\t\t}\n\t\telse printf(\"Addition/Subtraction neither rounds nor chops.\\n\");\n\t\t}\n\telse printf(\"Addition/Subtraction neither rounds nor chops.\\n\");\n\tS = One;\n\tX = One + Half * (One + Half);\n\tY = (One + U2) * Half;\n\tZ = X - Y;\n\tT = Y - X;\n\tStickyBit = Z + T;\n\tif (StickyBit != Zero) {\n\t\tS = Zero;\n\t\tBadCond(Flaw, \"(X - Y) + (Y - X) is non zero!\\n\");\n\t\t}\n\tStickyBit = Zero;\n\tif ((GMult == Yes) && (GDiv == Yes) && (GAddSub == Yes)\n\t\t&& (RMult == Rounded) && (RDiv == Rounded)\n\t\t&& (RAddSub == Rounded) && (FLOOR(RadixD2) == RadixD2)) {\n\t\tprintf(\"Checking for sticky bit.\\n\");\n\t\tX = (Half + U1) * U2;\n\t\tY = Half * U2;\n\t\tZ = One + Y;\n\t\tT = One + X;\n\t\tif ((Z - One <= Zero) && (T - One >= U2)) {\n\t\t\tZ = T + Y;\n\t\t\tY = Z - X;\n\t\t\tif ((Z - T >= U2) && (Y - T == Zero)) {\n\t\t\t\tX = (Half + U1) * U1;\n\t\t\t\tY = Half * U1;\n\t\t\t\tZ = One - Y;\n\t\t\t\tT = One - X;\n\t\t\t\tif ((Z - One == Zero) && (T - F9 == Zero)) {\n\t\t\t\t\tZ = (Half - U1) * U1;\n\t\t\t\t\tT = F9 - Z;\n\t\t\t\t\tQ = F9 - Y;\n\t\t\t\t\tif ((T - F9 == Zero) && (F9 - U1 - Q == Zero)) {\n\t\t\t\t\t\tZ = (One + U2) * OneAndHalf;\n\t\t\t\t\t\tT = (OneAndHalf + U2) - Z + U2;\n\t\t\t\t\t\tX = One + Half / Radix;\n\t\t\t\t\t\tY = One + Radix * U2;\n\t\t\t\t\t\tZ = X * Y;\n\t\t\t\t\t\tif (T == Zero && X + Radix * U2 - Z == Zero) {\n\t\t\t\t\t\t\tif (Radix != Two) {\n\t\t\t\t\t\t\t\tX = Two + U2;\n\t\t\t\t\t\t\t\tY = X / Two;\n\t\t\t\t\t\t\t\tif ((Y - One == Zero)) StickyBit = S;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse StickyBit = S;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tif (StickyBit == One) printf(\"Sticky bit apparently used correctly.\\n\");\n\telse printf(\"Sticky bit used incorrectly or not at all.\\n\");\n\tTstCond (Flaw, !(GMult == No || GDiv == No || GAddSub == No ||\n\t\t\tRMult == Other || RDiv == Other || RAddSub == Other),\n\t\t\"lack(s) of guard digits or failure(s) to correctly round or chop\\n(noted above) count as one flaw in the final tally below\");\n\t/*=============================================*/\n\tMilestone = 60;\n\t/*=============================================*/\n\tprintf(\"\\n\");\n\tprintf(\"Does Multiplication commute?  \");\n\tprintf(\"Testing on %d random pairs.\\n\", NoTrials);\n\tRandom9 = SQRT(3.0);\n\tRandom1 = Third;\n\tI = 1;\n\tdo  {\n\t\tX = Random();\n\t\tY = Random();\n\t\tZ9 = Y * X;\n\t\tZ = X * Y;\n\t\tZ9 = Z - Z9;\n\t\tI = I + 1;\n\t\t} while ( ! ((I > NoTrials) || (Z9 != Zero)));\n\tif (I == NoTrials) {\n\t\tRandom1 = One + Half / Three;\n\t\tRandom2 = (U2 + U1) + One;\n\t\tZ = Random1 * Random2;\n\t\tY = Random2 * Random1;\n\t\tZ9 = (One + Half / Three) * ((U2 + U1) + One) - (One + Half /\n\t\t\tThree) * ((U2 + U1) + One);\n\t\t}\n\tif (! ((I == NoTrials) || (Z9 == Zero)))\n\t\tBadCond(Defect, \"X * Y == Y * X trial fails.\\n\");\n\telse printf(\"     No failures found in %d integer pairs.\\n\", NoTrials);\n\t/*=============================================*/\n\tMilestone = 70;\n\t/*=============================================*/\n\tprintf(\"\\nRunning test of square root(x).\\n\");\n\tTstCond (Failure, (Zero == SQRT(Zero))\n\t\t   && (- Zero == SQRT(- Zero))\n\t\t   && (One == SQRT(One)), \"Square root of 0.0, -0.0 or 1.0 wrong\");\n\tMinSqEr = Zero;\n\tMaxSqEr = Zero;\n\tJ = Zero;\n\tX = Radix;\n\tOneUlp = U2;\n\tSqXMinX (Serious);\n\tX = BInvrse;\n\tOneUlp = BInvrse * U1;\n\tSqXMinX (Serious);\n\tX = U1;\n\tOneUlp = U1 * U1;\n\tSqXMinX (Serious);\n\tif (J != Zero) Pause();\n\tprintf(\"Testing if sqrt(X * X) == X for %d Integers X.\\n\", NoTrials);\n\tJ = Zero;\n\tX = Two;\n\tY = Radix;\n\tif ((Radix != One)) do  {\n\t\tX = Y;\n\t\tY = Radix * Y;\n\t\t} while ( ! ((Y - X >= NoTrials)));\n\tOneUlp = X * U2;\n\tI = 1;\n\twhile (I <= NoTrials) {\n\t\tX = X + One;\n\t\tSqXMinX (Defect);\n\t\tif (J > Zero) break;\n\t\tI = I + 1;\n\t\t}\n\tprintf(\"Test for sqrt monotonicity.\\n\");\n\tI = - 1;\n\tX = BMinusU2;\n\tY = Radix;\n\tZ = Radix + Radix * U2;\n\tNotMonot = False;\n\tMonot = False;\n\twhile ( ! (NotMonot || Monot)) {\n\t\tI = I + 1;\n\t\tX = SQRT(X);\n\t\tQ = SQRT(Y);\n\t\tZ = SQRT(Z);\n\t\tif ((X > Q) || (Q > Z)) NotMonot = True;\n\t\telse {\n\t\t\tQ = FLOOR(Q + Half);\n\t\t\tif ((I > 0) || (Radix == Q * Q)) Monot = True;\n\t\t\telse if (I > 0) {\n\t\t\tif (I > 1) Monot = True;\n\t\t\telse {\n\t\t\t\tY = Y * BInvrse;\n\t\t\t\tX = Y - U1;\n\t\t\t\tZ = Y + U1;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tY = Q;\n\t\t\t\tX = Y - U2;\n\t\t\t\tZ = Y + U2;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tif (Monot) printf(\"sqrt has passed a test for Monotonicity.\\n\");\n\telse {\n\t\tBadCond(Defect, \"\");\n\t\tprintf(\"sqrt(X) is non-monotonic for X near %.7e .\\n\", Y);\n\t\t}\n\t/*=============================================*/\n\t/*SPLIT\n\t}\n#include \"paranoia.h\"\npart5(){\n*/\n\tMilestone = 80;\n\t/*=============================================*/\n\tMinSqEr = MinSqEr + Half;\n\tMaxSqEr = MaxSqEr - Half;\n\tY = (SQRT(One + U2) - One) / U2;\n\tSqEr = (Y - One) + U2 / Eight;\n\tif (SqEr > MaxSqEr) MaxSqEr = SqEr;\n\tSqEr = Y + U2 / Eight;\n\tif (SqEr < MinSqEr) MinSqEr = SqEr;\n\tY = ((SQRT(F9) - U2) - (One - U2)) / U1;\n\tSqEr = Y + U1 / Eight;\n\tif (SqEr > MaxSqEr) MaxSqEr = SqEr;\n\tSqEr = (Y + One) + U1 / Eight;\n\tif (SqEr < MinSqEr) MinSqEr = SqEr;\n\tOneUlp = U2;\n\tX = OneUlp;\n\tfor( Indx = 1; Indx <= 3; ++Indx) {\n\t\tY = SQRT((X + U1 + X) + F9);\n\t\tY = ((Y - U2) - ((One - U2) + X)) / OneUlp;\n\t\tZ = ((U1 - X) + F9) * Half * X * X / OneUlp;\n\t\tSqEr = (Y + Half) + Z;\n\t\tif (SqEr < MinSqEr) MinSqEr = SqEr;\n\t\tSqEr = (Y - Half) + Z;\n\t\tif (SqEr > MaxSqEr) MaxSqEr = SqEr;\n\t\tif (((Indx == 1) || (Indx == 3))) \n\t\t\tX = OneUlp * Sign (X) * FLOOR(Eight / (Nine * SQRT(OneUlp)));\n\t\telse {\n\t\t\tOneUlp = U1;\n\t\t\tX = - OneUlp;\n\t\t\t}\n\t\t}\n\t/*=============================================*/\n\tMilestone = 85;\n\t/*=============================================*/\n\tSqRWrng = False;\n\tAnomaly = False;\n\tRSqrt = Other; /* ~dgh */\n\tif (Radix != One) {\n\t\tprintf(\"Testing whether sqrt is rounded or chopped.\\n\");\n\t\tD = FLOOR(Half + POW(Radix, One + Precision - FLOOR(Precision)));\n\t/* ... == Radix^(1 + fract) if (Precision == Integer + fract. */\n\t\tX = D / Radix;\n\t\tY = D / A1;\n\t\tif ((X != FLOOR(X)) || (Y != FLOOR(Y))) {\n\t\t\tAnomaly = True;\n\t\t\t}\n\t\telse {\n\t\t\tX = Zero;\n\t\t\tZ2 = X;\n\t\t\tY = One;\n\t\t\tY2 = Y;\n\t\t\tZ1 = Radix - One;\n\t\t\tFourD = Four * D;\n\t\t\tdo  {\n\t\t\t\tif (Y2 > Z2) {\n\t\t\t\t\tQ = Radix;\n\t\t\t\t\tY1 = Y;\n\t\t\t\t\tdo  {\n\t\t\t\t\t\tX1 = FABS(Q + FLOOR(Half - Q / Y1) * Y1);\n\t\t\t\t\t\tQ = Y1;\n\t\t\t\t\t\tY1 = X1;\n\t\t\t\t\t\t} while ( ! (X1 <= Zero));\n\t\t\t\t\tif (Q <= One) {\n\t\t\t\t\t\tZ2 = Y2;\n\t\t\t\t\t\tZ = Y;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tY = Y + Two;\n\t\t\t\tX = X + Eight;\n\t\t\t\tY2 = Y2 + X;\n\t\t\t\tif (Y2 >= FourD) Y2 = Y2 - FourD;\n\t\t\t\t} while ( ! (Y >= D));\n\t\t\tX8 = FourD - Z2;\n\t\t\tQ = (X8 + Z * Z) / FourD;\n\t\t\tX8 = X8 / Eight;\n\t\t\tif (Q != FLOOR(Q)) Anomaly = True;\n\t\t\telse {\n\t\t\t\tBreak = False;\n\t\t\t\tdo  {\n\t\t\t\t\tX = Z1 * Z;\n\t\t\t\t\tX = X - FLOOR(X / Radix) * Radix;\n\t\t\t\t\tif (X == One) \n\t\t\t\t\t\tBreak = True;\n\t\t\t\t\telse\n\t\t\t\t\t\tZ1 = Z1 - One;\n\t\t\t\t\t} while ( ! (Break || (Z1 <= Zero)));\n\t\t\t\tif ((Z1 <= Zero) && (! Break)) Anomaly = True;\n\t\t\t\telse {\n\t\t\t\t\tif (Z1 > RadixD2) Z1 = Z1 - Radix;\n\t\t\t\t\tdo  {\n\t\t\t\t\t\tNewD();\n\t\t\t\t\t\t} while ( ! (U2 * D >= F9));\n\t\t\t\t\tif (D * Radix - D != W - D) Anomaly = True;\n\t\t\t\t\telse {\n\t\t\t\t\t\tZ2 = D;\n\t\t\t\t\t\tI = 0;\n\t\t\t\t\t\tY = D + (One + Z) * Half;\n\t\t\t\t\t\tX = D + Z + Q;\n\t\t\t\t\t\tSR3750();\n\t\t\t\t\t\tY = D + (One - Z) * Half + D;\n\t\t\t\t\t\tX = D - Z + D;\n\t\t\t\t\t\tX = X + Q + X;\n\t\t\t\t\t\tSR3750();\n\t\t\t\t\t\tNewD();\n\t\t\t\t\t\tif (D - Z2 != W - Z2) Anomaly = True;\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tY = (D - Z2) + (Z2 + (One - Z) * Half);\n\t\t\t\t\t\t\tX = (D - Z2) + (Z2 - Z + Q);\n\t\t\t\t\t\t\tSR3750();\n\t\t\t\t\t\t\tY = (One + Z) * Half;\n\t\t\t\t\t\t\tX = Q;\n\t\t\t\t\t\t\tSR3750();\n\t\t\t\t\t\t\tif (I == 0) Anomaly = True;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tif ((I == 0) || Anomaly) {\n\t\t\tBadCond(Failure, \"Anomalous arithmetic with Integer < \");\n\t\t\tprintf(\"Radix^Precision = %.7e\\n\", W);\n\t\t\tprintf(\" fails test whether sqrt rounds or chops.\\n\");\n\t\t\tSqRWrng = True;\n\t\t\t}\n\t\t}\n\tif (! Anomaly) {\n\t\tif (! ((MinSqEr < Zero) || (MaxSqEr > Zero))) {\n\t\t\tRSqrt = Rounded;\n\t\t\tprintf(\"Square root appears to be correctly rounded.\\n\");\n\t\t\t}\n\t\telse  {\n\t\t\tif ((MaxSqEr + U2 > U2 - Half) || (MinSqEr > Half)\n\t\t\t\t|| (MinSqEr + Radix < Half)) SqRWrng = True;\n\t\t\telse {\n\t\t\t\tRSqrt = Chopped;\n\t\t\t\tprintf(\"Square root appears to be chopped.\\n\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tif (SqRWrng) {\n\t\tprintf(\"Square root is neither chopped nor correctly rounded.\\n\");\n\t\tprintf(\"Observed errors run from %.7e \", MinSqEr - Half);\n\t\tprintf(\"to %.7e ulps.\\n\", Half + MaxSqEr);\n\t\tTstCond (Serious, MaxSqEr - MinSqEr < Radix * Radix,\n\t\t\t\"sqrt gets too many last digits wrong\");\n\t\t}\n\t/*=============================================*/\n\tMilestone = 90;\n\t/*=============================================*/\n\tPause();\n\tprintf(\"Testing powers Z^i for small Integers Z and i.\\n\");\n\tN = 0;\n\t/* ... test powers of zero. */\n\tI = 0;\n\tZ = -Zero;\n\tM = 3.0;\n\tBreak = False;\n\tdo  {\n\t\tX = One;\n\t\tSR3980();\n\t\tif (I <= 10) {\n\t\t\tI = 1023;\n\t\t\tSR3980();\n\t\t\t}\n\t\tif (Z == MinusOne) Break = True;\n\t\telse {\n\t\t\tZ = MinusOne;\n\t\t\tPrintIfNPositive();\n\t\t\tN = 0;\n\t\t\t/* .. if(-1)^N is invalid, replace MinusOne by One. */\n\t\t\tI = - 4;\n\t\t\t}\n\t\t} while ( ! Break);\n\tPrintIfNPositive();\n\tN1 = N;\n\tN = 0;\n\tZ = A1;\n\tM = FLOOR(Two * LOG(W) / LOG(A1));\n\tBreak = False;\n\tdo  {\n\t\tX = Z;\n\t\tI = 1;\n\t\tSR3980();\n\t\tif (Z == AInvrse) Break = True;\n\t\telse Z = AInvrse;\n\t\t} while ( ! (Break));\n\t/*=============================================*/\n\t\tMilestone = 100;\n\t/*=============================================*/\n\t/*  Powers of Radix have been tested, */\n\t/*         next try a few primes     */\n\tM = NoTrials;\n\tZ = Three;\n\tdo  {\n\t\tX = Z;\n\t\tI = 1;\n\t\tSR3980();\n\t\tdo  {\n\t\t\tZ = Z + Two;\n\t\t\t} while ( Three * FLOOR(Z / Three) == Z );\n\t\t} while ( Z < Eight * Three );\n\tif (N > 0) {\n\t\tprintf(\"Errors like this may invalidate financial calculations\\n\");\n\t\tprintf(\"\\tinvolving interest rates.\\n\");\n\t\t}\n\tPrintIfNPositive();\n\tN += N1;\n\tif (N == 0) printf(\"... no discrepancis found.\\n\");\n\tif (N > 0) Pause();\n\telse printf(\"\\n\");\n\t/*=============================================*/\n\t/*SPLIT\n\t}\n#include \"paranoia.h\"\npart6(){\n*/\n\tMilestone = 110;\n\t/*=============================================*/\n\tprintf(\"Seeking Underflow thresholds UfThold and E0.\\n\");\n\tD = U1;\n\tif (Precision != FLOOR(Precision)) {\n\t\tD = BInvrse;\n\t\tX = Precision;\n\t\tdo  {\n\t\t\tD = D * BInvrse;\n\t\t\tX = X - One;\n\t\t\t} while ( X > Zero);\n\t\t}\n\tY = One;\n\tZ = D;\n\t/* ... D is power of 1/Radix < 1. */\n\tdo  {\n\t\tC = Y;\n\t\tY = Z;\n\t\tZ = Y * Y;\n\t\t} while ((Y > Z) && (Z + Z > Z));\n\tY = C;\n\tZ = Y * D;\n\tdo  {\n\t\tC = Y;\n\t\tY = Z;\n\t\tZ = Y * D;\n\t\t} while ((Y > Z) && (Z + Z > Z));\n\tif (Radix < Two) HInvrse = Two;\n\telse HInvrse = Radix;\n\tH = One / HInvrse;\n\t/* ... 1/HInvrse == H == Min(1/Radix, 1/2) */\n\tCInvrse = One / C;\n\tE0 = C;\n\tZ = E0 * H;\n\t/* ...1/Radix^(BIG Integer) << 1 << CInvrse == 1/C */\n\tdo  {\n\t\tY = E0;\n\t\tE0 = Z;\n\t\tZ = E0 * H;\n\t\t} while ((E0 > Z) && (Z + Z > Z));\n\tUfThold = E0;\n\tE1 = Zero;\n\tQ = Zero;\n\tE9 = U2;\n\tS = One + E9;\n\tD = C * S;\n\tif (D <= C) {\n\t\tE9 = Radix * U2;\n\t\tS = One + E9;\n\t\tD = C * S;\n\t\tif (D <= C) {\n\t\t\tBadCond(Failure, \"multiplication gets too many last digits wrong.\\n\");\n\t\t\tUnderflow = E0;\n\t\t\tY1 = Zero;\n\t\t\tPseudoZero = Z;\n\t\t\tPause();\n\t\t\t}\n\t\t}\n\telse {\n\t\tUnderflow = D;\n\t\tPseudoZero = Underflow * H;\n\t\tUfThold = Zero;\n\t\tdo  {\n\t\t\tY1 = Underflow;\n\t\t\tUnderflow = PseudoZero;\n\t\t\tif (E1 + E1 <= E1) {\n\t\t\t\tY2 = Underflow * HInvrse;\n\t\t\t\tE1 = FABS(Y1 - Y2);\n\t\t\t\tQ = Y1;\n\t\t\t\tif ((UfThold == Zero) && (Y1 != Y2)) UfThold = Y1;\n\t\t\t\t}\n\t\t\tPseudoZero = PseudoZero * H;\n\t\t\t} while ((Underflow > PseudoZero)\n\t\t\t\t&& (PseudoZero + PseudoZero > PseudoZero));\n\t\t}\n\t/* Comment line 4530 .. 4560 */\n\tif (PseudoZero != Zero) {\n\t\tprintf(\"\\n\");\n\t\tZ = PseudoZero;\n\t/* ... Test PseudoZero for \"phoney- zero\" violates */\n\t/* ... PseudoZero < Underflow or PseudoZero < PseudoZero + PseudoZero\n\t\t   ... */\n\t\tif (PseudoZero <= Zero) {\n\t\t\tBadCond(Failure, \"Positive expressions can underflow to an\\n\");\n\t\t\tprintf(\"allegedly negative value\\n\");\n\t\t\tprintf(\"PseudoZero that prints out as: %g .\\n\", PseudoZero);\n\t\t\tX = - PseudoZero;\n\t\t\tif (X <= Zero) {\n\t\t\t\tprintf(\"But -PseudoZero, which should be\\n\");\n\t\t\t\tprintf(\"positive, isn't; it prints out as  %g .\\n\", X);\n\t\t\t\t}\n\t\t\t}\n\t\telse {\n\t\t\tBadCond(Flaw, \"Underflow can stick at an allegedly positive\\n\");\n\t\t\tprintf(\"value PseudoZero that prints out as %g .\\n\", PseudoZero);\n\t\t\t}\n\t\tTstPtUf();\n\t\t}\n\t/*=============================================*/\n\tMilestone = 120;\n\t/*=============================================*/\n\tif (CInvrse * Y > CInvrse * Y1) {\n\t\tS = H * S;\n\t\tE0 = Underflow;\n\t\t}\n\tif (! ((E1 == Zero) || (E1 == E0))) {\n\t\tBadCond(Defect, \"\");\n\t\tif (E1 < E0) {\n\t\t\tprintf(\"Products underflow at a higher\");\n\t\t\tprintf(\" threshold than differences.\\n\");\n\t\t\tif (PseudoZero == Zero) \n\t\t\tE0 = E1;\n\t\t\t}\n\t\telse {\n\t\t\tprintf(\"Difference underflows at a higher\");\n\t\t\tprintf(\" threshold than products.\\n\");\n\t\t\t}\n\t\t}\n\tprintf(\"Smallest strictly positive number found is E0 = %g .\\n\", E0);\n\tZ = E0;\n\tTstPtUf();\n\tUnderflow = E0;\n\tif (N == 1) Underflow = Y;\n\tI = 4;\n\tif (E1 == Zero) I = 3;\n\tif (UfThold == Zero) I = I - 2;\n\tUfNGrad = True;\n\tswitch (I)  {\n\t\tcase\t1:\n\t\tUfThold = Underflow;\n\t\tif ((CInvrse * Q) != ((CInvrse * Y) * S)) {\n\t\t\tUfThold = Y;\n\t\t\tBadCond(Failure, \"Either accuracy deteriorates as numbers\\n\");\n\t\t\tprintf(\"approach a threshold = %.17e\\n\", UfThold);;\n\t\t\tprintf(\" coming down from %.17e\\n\", C);\n\t\t\tprintf(\" or else multiplication gets too many last digits wrong.\\n\");\n\t\t\t}\n\t\tPause();\n\t\tbreak;\n\t\n\t\tcase\t2:\n\t\tBadCond(Failure, \"Underflow confuses Comparison, which alleges that\\n\");\n\t\tprintf(\"Q == Y while denying that |Q - Y| == 0; these values\\n\");\n\t\tprintf(\"print out as Q = %.17e, Y = %.17e .\\n\", Q, Y2);\n\t\tprintf (\"|Q - Y| = %.17e .\\n\" , FABS(Q - Y2));\n\t\tUfThold = Q;\n\t\tbreak;\n\t\n\t\tcase\t3:\n\t\tX = X;\n\t\tbreak;\n\t\n\t\tcase\t4:\n\t\tif ((Q == UfThold) && (E1 == E0)\n\t\t\t&& (FABS( UfThold - E1 / E9) <= E1)) {\n\t\t\tUfNGrad = False;\n\t\t\tprintf(\"Underflow is gradual; it incurs Absolute Error =\\n\");\n\t\t\tprintf(\"(roundoff in UfThold) < E0.\\n\");\n\t\t\tY = E0 * CInvrse;\n\t\t\tY = Y * (OneAndHalf + U2);\n\t\t\tX = CInvrse * (One + U2);\n\t\t\tY = Y / X;\n\t\t\tIEEE = (Y == E0);\n\t\t\t}\n\t\t}\n\tif (UfNGrad) {\n\t\tprintf(\"\\n\");\n\t\tsigsave = sigfpe;\n\t\tif (setjmp(ovfl_buf)) {\n\t\t\tprintf(\"Underflow / UfThold failed!\\n\");\n\t\t\tR = H + H;\n\t\t\t}\n\t\telse R = SQRT(Underflow / UfThold);\n\t\tsigsave = 0;\n\t\tif (R <= H) {\n\t\t\tZ = R * UfThold;\n\t\t\tX = Z * (One + R * H * (One + H));\n\t\t\t}\n\t\telse {\n\t\t\tZ = UfThold;\n\t\t\tX = Z * (One + H * H * (One + H));\n\t\t\t}\n\t\tif (! ((X == Z) || (X - Z != Zero))) {\n\t\t\tBadCond(Flaw, \"\");\n\t\t\tprintf(\"X = %.17e\\n\\tis not equal to Z = %.17e .\\n\", X, Z);\n\t\t\tZ9 = X - Z;\n\t\t\tprintf(\"yet X - Z yields %.17e .\\n\", Z9);\n\t\t\tprintf(\"    Should this NOT signal Underflow, \");\n\t\t\tprintf(\"this is a SERIOUS DEFECT\\nthat causes \");\n\t\t\tprintf(\"confusion when innocent statements like\\n\");;\n\t\t\tprintf(\"    if (X == Z)  ...  else\");\n\t\t\tprintf(\"  ... (f(X) - f(Z)) / (X - Z) ...\\n\");\n\t\t\tprintf(\"encounter Division by Zero although actually\\n\");\n\t\t\tsigsave = sigfpe;\n\t\t\tif (setjmp(ovfl_buf)) printf(\"X / Z fails!\\n\");\n\t\t\telse printf(\"X / Z = 1 + %g .\\n\", (X / Z - Half) - Half);\n\t\t\tsigsave = 0;\n\t\t\t}\n\t\t}\n\tprintf(\"The Underflow threshold is %.17e, %s\\n\", UfThold,\n\t\t   \" below which\");\n\tprintf(\"calculation may suffer larger Relative error than \");\n\tprintf(\"merely roundoff.\\n\");\n\tY2 = U1 * U1;\n\tY = Y2 * Y2;\n\tY2 = Y * U1;\n\tif (Y2 <= UfThold) {\n\t\tif (Y > E0) {\n\t\t\tBadCond(Defect, \"\");\n\t\t\tI = 5;\n\t\t\t}\n\t\telse {\n\t\t\tBadCond(Serious, \"\");\n\t\t\tI = 4;\n\t\t\t}\n\t\tprintf(\"Range is too narrow; U1^%d Underflows.\\n\", I);\n\t\t}\n\t/*=============================================*/\n\t/*SPLIT\n\t}\n#include \"paranoia.h\"\npart7(){\n*/\n\tMilestone = 130;\n\t/*=============================================*/\n\tY = - FLOOR(Half - TwoForty * LOG(UfThold) / LOG(HInvrse)) / TwoForty;\n\tY2 = Y + Y;\n\tprintf(\"Since underflow occurs below the threshold\\n\");\n\tprintf(\"UfThold = (%.17e) ^ (%.17e)\\nonly underflow \", HInvrse, Y);\n\tprintf(\"should afflict the expression\\n\\t(%.17e) ^ (%.17e);\\n\", HInvrse, Y);\n\tV9 = POW(HInvrse, Y2);\n\tprintf(\"actually calculating yields: %.17e .\\n\", V9);\n\tif (! ((V9 >= Zero) && (V9 <= (Radix + Radix + E9) * UfThold))) {\n\t\tBadCond(Serious, \"this is not between 0 and underflow\\n\");\n\t\tprintf(\"   threshold = %.17e .\\n\", UfThold);\n\t\t}\n\telse if (! (V9 > UfThold * (One + E9)))\n\t\tprintf(\"This computed value is O.K.\\n\");\n\telse {\n\t\tBadCond(Defect, \"this is not between 0 and underflow\\n\");\n\t\tprintf(\"   threshold = %.17e .\\n\", UfThold);\n\t\t}\n\t/*=============================================*/\n\tMilestone = 140;\n\t/*=============================================*/\n\tprintf(\"\\n\");\n\t/* ...calculate Exp2 == exp(2) == 7.389056099... */\n\tX = Zero;\n\tI = 2;\n\tY = Two * Three;\n\tQ = Zero;\n\tN = 0;\n\tdo  {\n\t\tZ = X;\n\t\tI = I + 1;\n\t\tY = Y / (I + I);\n\t\tR = Y + Q;\n\t\tX = Z + R;\n\t\tQ = (Z - X) + R;\n\t\t} while(X > Z);\n\tZ = (OneAndHalf + One / Eight) + X / (OneAndHalf * ThirtyTwo);\n\tX = Z * Z;\n\tExp2 = X * X;\n\tX = F9;\n\tY = X - U1;\n\tprintf(\"Testing X^((X + 1) / (X - 1)) vs. exp(2) = %.17e as X -> 1.\\n\",\n\t\tExp2);\n\tfor(I = 1;;) {\n\t\tZ = X - BInvrse;\n\t\tZ = (X + One) / (Z - (One - BInvrse));\n\t\tQ = POW(X, Z) - Exp2;\n\t\tif (FABS(Q) > TwoForty * U2) {\n\t\t\tN = 1;\n\t \t\tV9 = (X - BInvrse) - (One - BInvrse);\n\t\t\tBadCond(Defect, \"Calculated\");\n\t\t\tprintf(\" %.17e for\\n\", POW(X,Z));\n\t\t\tprintf(\"\\t(1 + (%.17e) ^ (%.17e);\\n\", V9, Z);\n\t\t\tprintf(\"\\tdiffers from correct value by %.17e .\\n\", Q);\n\t\t\tprintf(\"\\tThis much error may spoil financial\\n\");\n\t\t\tprintf(\"\\tcalculations involving tiny interest rates.\\n\");\n\t\t\tbreak;\n\t\t\t}\n\t\telse {\n\t\t\tZ = (Y - X) * Two + Y;\n\t\t\tX = Y;\n\t\t\tY = Z;\n\t\t\tZ = One + (X - F9)*(X - F9);\n\t\t\tif (Z > One && I < NoTrials) I++;\n\t\t\telse  {\n\t\t\t\tif (X > One) {\n\t\t\t\t\tif (N == 0)\n\t\t\t\t\t   printf(\"Accuracy seems adequate.\\n\");\n\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tX = One + U2;\n\t\t\t\t\tY = U2 + U2;\n\t\t\t\t\tY += X;\n\t\t\t\t\tI = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t/*=============================================*/\n\tMilestone = 150;\n\t/*=============================================*/\n\tprintf(\"Testing powers Z^Q at four nearly extreme values.\\n\");\n\tN = 0;\n\tZ = A1;\n\tQ = FLOOR(Half - LOG(C) / LOG(A1));\n\tBreak = False;\n\tdo  {\n\t\tX = CInvrse;\n\t\tY = POW(Z, Q);\n\t\tIsYeqX();\n\t\tQ = - Q;\n\t\tX = C;\n\t\tY = POW(Z, Q);\n\t\tIsYeqX();\n\t\tif (Z < One) Break = True;\n\t\telse Z = AInvrse;\n\t\t} while ( ! (Break));\n\tPrintIfNPositive();\n\tif (N == 0) printf(\" ... no discrepancies found.\\n\");\n\tprintf(\"\\n\");\n\t\n\t/*=============================================*/\n\tMilestone = 160;\n\t/*=============================================*/\n\tPause();\n\tprintf(\"Searching for Overflow threshold:\\n\");\n\tprintf(\"This may generate an error.\\n\");\n\tY = - CInvrse;\n\tV9 = HInvrse * Y;\n\tsigsave = sigfpe;\n\tif (setjmp(ovfl_buf)) { I = 0; V9 = Y; goto overflow; }\n\tdo {\n\t\tV = Y;\n\t\tY = V9;\n\t\tV9 = HInvrse * Y;\n\t\t} while(V9 < Y);\n\tI = 1;\noverflow:\n\tsigsave = 0;\n\tZ = V9;\n\tprintf(\"Can `Z = -Y' overflow?\\n\");\n\tprintf(\"Trying it on Y = %.17e .\\n\", Y);\n\tV9 = - Y;\n\tV0 = V9;\n\tif (V - Y == V + V0) printf(\"Seems O.K.\\n\");\n\telse {\n\t\tprintf(\"finds a \");\n\t\tBadCond(Flaw, \"-(-Y) differs from Y.\\n\");\n\t\t}\n\tif (Z != Y) {\n\t\tBadCond(Serious, \"\");\n\t\tprintf(\"overflow past %.17e\\n\\tshrinks to %.17e .\\n\", Y, Z);\n\t\t}\n\tif (I) {\n\t\tY = V * (HInvrse * U2 - HInvrse);\n\t\tZ = Y + ((One - HInvrse) * U2) * V;\n\t\tif (Z < V0) Y = Z;\n\t\tif (Y < V0) V = Y;\n\t\tif (V0 - V < V0) V = V0;\n\t\t}\n\telse {\n\t\tV = Y * (HInvrse * U2 - HInvrse);\n\t\tV = V + ((One - HInvrse) * U2) * Y;\n\t\t}\n\tprintf(\"Overflow threshold is V  = %.17e .\\n\", V);\n\tif (I) printf(\"Overflow saturates at V0 = %.17e .\\n\", V0);\n\telse printf(\"There is no saturation value because the system traps on overflow.\\n\");\n\tV9 = V * One;\n\tprintf(\"No Overflow should be signaled for V * 1 = %.17e\\n\", V9);\n\tV9 = V / One;\n\tprintf(\"                           nor for V / 1 = %.17e .\\n\", V9);\n\tprintf(\"Any overflow signal separating this * from the one\\n\");\n\tprintf(\"above is a DEFECT.\\n\");\n\t/*=============================================*/\n\tMilestone = 170;\n\t/*=============================================*/\n\tif (!(-V < V && -V0 < V0 && -UfThold < V && UfThold < V)) {\n\t\tBadCond(Failure, \"Comparisons involving \");\n\t\tprintf(\"+-%g, +-%g\\nand +-%g are confused by Overflow.\",\n\t\t\tV, V0, UfThold);\n\t\t}\n\t/*=============================================*/\n\tMilestone = 175;\n\t/*=============================================*/\n\tprintf(\"\\n\");\n\tfor(Indx = 1; Indx <= 3; ++Indx) {\n\t\tswitch (Indx)  {\n\t\t\tcase 1: Z = UfThold; break;\n\t\t\tcase 2: Z = E0; break;\n\t\t\tcase 3: Z = PseudoZero; break;\n\t\t\t}\n\t\tif (Z != Zero) {\n\t\t\tV9 = SQRT(Z);\n\t\t\tY = V9 * V9;\n\t\t\tif (Y / (One - Radix * E9) < Z\n\t\t\t   || Y > (One + Radix * E9) * Z) { /* dgh: + E9 --> * E9 */\n\t\t\t\tif (V9 > U1) BadCond(Serious, \"\");\n\t\t\t\telse BadCond(Defect, \"\");\n\t\t\t\tprintf(\"Comparison alleges that what prints as Z = %.17e\\n\", Z);\n\t\t\t\tprintf(\" is too far from sqrt(Z) ^ 2 = %.17e .\\n\", Y);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t/*=============================================*/\n\tMilestone = 180;\n\t/*=============================================*/\n\tfor(Indx = 1; Indx <= 2; ++Indx) {\n\t\tif (Indx == 1) Z = V;\n\t\telse Z = V0;\n\t\tV9 = SQRT(Z);\n\t\tX = (One - Radix * E9) * V9;\n\t\tV9 = V9 * X;\n\t\tif (((V9 < (One - Two * Radix * E9) * Z) || (V9 > Z))) {\n\t\t\tY = V9;\n\t\t\tif (X < W) BadCond(Serious, \"\");\n\t\t\telse BadCond(Defect, \"\");\n\t\t\tprintf(\"Comparison alleges that Z = %17e\\n\", Z);\n\t\t\tprintf(\" is too far from sqrt(Z) ^ 2 (%.17e) .\\n\", Y);\n\t\t\t}\n\t\t}\n\t/*=============================================*/\n\t/*SPLIT\n\t}\n#include \"paranoia.h\"\npart8(){\n*/\n\tMilestone = 190;\n\t/*=============================================*/\n\tPause();\n\tX = UfThold * V;\n\tY = Radix * Radix;\n\tif (X*Y < One || X > Y) {\n\t\tif (X * Y < U1 || X > Y/U1) BadCond(Defect, \"Badly\");\n\t\telse BadCond(Flaw, \"\");\n\t\t\t\n\t\tprintf(\" unbalanced range; UfThold * V = %.17e\\n\\t%s\\n\",\n\t\t\tX, \"is too far from 1.\\n\");\n\t\t}\n\t/*=============================================*/\n\tMilestone = 200;\n\t/*=============================================*/\n\tfor (Indx = 1; Indx <= 5; ++Indx)  {\n\t\tX = F9;\n\t\tswitch (Indx)  {\n\t\t\tcase 2: X = One + U2; break;\n\t\t\tcase 3: X = V; break;\n\t\t\tcase 4: X = UfThold; break;\n\t\t\tcase 5: X = Radix;\n\t\t\t}\n\t\tY = X;\n\t\tsigsave = sigfpe;\n\t\tif (setjmp(ovfl_buf))\n\t\t\tprintf(\"  X / X  traps when X = %g\\n\", X);\n\t\telse {\n\t\t\tV9 = (Y / X - Half) - Half;\n\t\t\tif (V9 == Zero) continue;\n\t\t\tif (V9 == - U1 && Indx < 5) BadCond(Flaw, \"\");\n\t\t\telse BadCond(Serious, \"\");\n\t\t\tprintf(\"  X / X differs from 1 when X = %.17e\\n\", X);\n\t\t\tprintf(\"  instead, X / X - 1/2 - 1/2 = %.17e .\\n\", V9);\n\t\t\t}\n\t\tsigsave = 0;\n\t\t}\n\t/*=============================================*/\n\tMilestone = 210;\n\t/*=============================================*/\n\tMyZero = Zero;\n\tprintf(\"\\n\");\n\tprintf(\"What message and/or values does Division by Zero produce?\\n\") ;\n#ifndef NOPAUSE\n\tprintf(\"This can interupt your program.  You can \");\n\tprintf(\"skip this part if you wish.\\n\");\n\tprintf(\"Do you wish to compute 1 / 0? \");\n\tfflush(stdout);\n\tread (KEYBOARD, ch, 8);\n\tif ((ch[0] == 'Y') || (ch[0] == 'y')) {\n#endif\n\t\tsigsave = sigfpe;\n\t\tprintf(\"    Trying to compute 1 / 0 produces ...\");\n\t\tif (!setjmp(ovfl_buf)) printf(\"  %.7e .\\n\", One / MyZero);\n\t\tsigsave = 0;\n#ifndef NOPAUSE\n\t\t}\n\telse printf(\"O.K.\\n\");\n\tprintf(\"\\nDo you wish to compute 0 / 0? \");\n\tfflush(stdout);\n\tread (KEYBOARD, ch, 80);\n\tif ((ch[0] == 'Y') || (ch[0] == 'y')) {\n#endif\n\t\tsigsave = sigfpe;\n\t\tprintf(\"\\n    Trying to compute 0 / 0 produces ...\");\n\t\tif (!setjmp(ovfl_buf)) printf(\"  %.7e .\\n\", Zero / MyZero);\n\t\tsigsave = 0;\n#ifndef NOPAUSE\n\t\t}\n\telse printf(\"O.K.\\n\");\n#endif\n\t/*=============================================*/\n\tMilestone = 220;\n\t/*=============================================*/\n\tPause();\n\tprintf(\"\\n\");\n\t{\n\t\tstatic char *msg[] = {\n\t\t\t\"FAILUREs  encountered =\",\n\t\t\t\"SERIOUS DEFECTs  discovered =\",\n\t\t\t\"DEFECTs  discovered =\",\n\t\t\t\"FLAWs  discovered =\" };\n\t\tint i;\n\t\tfor(i = 0; i < 4; i++) if (ErrCnt[i])\n\t\t\tprintf(\"The number of  %-29s %d.\\n\",\n\t\t\t\tmsg[i], ErrCnt[i]);\n\t\t}\n\tprintf(\"\\n\");\n\tif ((ErrCnt[Failure] + ErrCnt[Serious] + ErrCnt[Defect]\n\t\t\t+ ErrCnt[Flaw]) > 0) {\n\t\tif ((ErrCnt[Failure] + ErrCnt[Serious] + ErrCnt[\n\t\t\tDefect] == 0) && (ErrCnt[Flaw] > 0)) {\n\t\t\tprintf(\"The arithmetic diagnosed seems \");\n\t\t\tprintf(\"Satisfactory though flawed.\\n\");\n\t\t\t}\n\t\tif ((ErrCnt[Failure] + ErrCnt[Serious] == 0)\n\t\t\t&& ( ErrCnt[Defect] > 0)) {\n\t\t\tprintf(\"The arithmetic diagnosed may be Acceptable\\n\");\n\t\t\tprintf(\"despite inconvenient Defects.\\n\");\n\t\t\t}\n\t\tif ((ErrCnt[Failure] + ErrCnt[Serious]) > 0) {\n\t\t\tprintf(\"The arithmetic diagnosed has \");\n\t\t\tprintf(\"unacceptable Serious Defects.\\n\");\n\t\t\t}\n\t\tif (ErrCnt[Failure] > 0) {\n\t\t\tprintf(\"Potentially fatal FAILURE may have spoiled this\");\n\t\t\tprintf(\" program's subsequent diagnoses.\\n\");\n\t\t\t}\n\t\t}\n\telse {\n\t\tprintf(\"No failures, defects nor flaws have been discovered.\\n\");\n\t\tif (! ((RMult == Rounded) && (RDiv == Rounded)\n\t\t\t&& (RAddSub == Rounded) && (RSqrt == Rounded))) \n\t\t\tprintf(\"The arithmetic diagnosed seems Satisfactory.\\n\");\n\t\telse {\n\t\t\tif (StickyBit >= One &&\n\t\t\t\t(Radix - Two) * (Radix - Nine - One) == Zero) {\n\t\t\t\tprintf(\"Rounding appears to conform to \");\n\t\t\t\tprintf(\"the proposed IEEE standard P\");\n\t\t\t\tif ((Radix == Two) &&\n\t\t\t\t\t ((Precision - Four * Three * Two) *\n\t\t\t\t\t  ( Precision - TwentySeven -\n\t\t\t\t\t   TwentySeven + One) == Zero)) \n\t\t\t\t\tprintf(\"754\");\n\t\t\t\telse printf(\"854\");\n\t\t\t\tif (IEEE) printf(\".\\n\");\n\t\t\t\telse {\n\t\t\t\t\tprintf(\",\\nexcept for possibly Double Rounding\");\n\t\t\t\t\tprintf(\" during Gradual Underflow.\\n\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tprintf(\"The arithmetic diagnosed appears to be Excellent!\\n\");\n\t\t\t}\n\t\t}\n\tif (fpecount)\n\t\tprintf(\"\\nA total of %d floating point exceptions were registered.\\n\",\n\t\t\tfpecount);\n\tprintf(\"END OF TEST.\\n\");\n\treturn 0;\n\t}\n\n/*SPLIT subs.c\n#include \"paranoia.h\"\n*/\n\n/* Sign */\n\nFLOAT Sign (X)\nFLOAT X;\n{ return X >= 0. ? 1.0 : -1.0; }\n\n/* Pause */\n\nPause()\n{\n#ifndef NOPAUSE\n\tchar ch[8];\n\n\tprintf(\"\\nTo continue, press RETURN\");\n\tfflush(stdout);\n\tread(KEYBOARD, ch, 8);\n#endif\n\tprintf(\"\\nDiagnosis resumes after milestone Number %d\", Milestone);\n\tprintf(\"          Page: %d\\n\\n\", PageNo);\n\t++Milestone;\n\t++PageNo;\n\t}\n\n /* TstCond */\n\nTstCond (K, Valid, T)\nint K, Valid;\nchar *T;\n{ if (! Valid) { BadCond(K,T); printf(\".\\n\"); } }\n\nBadCond(K, T)\nint K;\nchar *T;\n{\n\tstatic char *msg[] = { \"FAILURE\", \"SERIOUS DEFECT\", \"DEFECT\", \"FLAW\" };\n\n\tErrCnt [K] = ErrCnt [K] + 1;\n\tprintf(\"%s:  %s\", msg[K], T);\n\t}\n\n/* Random */\n/*  Random computes\n     X = (Random1 + Random9)^5\n     Random1 = X - FLOOR(X) + 0.000005 * X;\n   and returns the new value of Random1\n*/\n\nFLOAT Random()\n{\n\tFLOAT X, Y;\n\t\n\tX = Random1 + Random9;\n\tY = X * X;\n\tY = Y * Y;\n\tX = X * Y;\n\tY = X - FLOOR(X);\n\tRandom1 = Y + X * 0.000005;\n\treturn(Random1);\n\t}\n\n/* SqXMinX */\n\nSqXMinX (ErrKind)\nint ErrKind;\n{\n\tFLOAT XA, XB;\n\t\n\tXB = X * BInvrse;\n\tXA = X - XB;\n\tSqEr = ((SQRT(X * X) - XB) - XA) / OneUlp;\n\tif (SqEr != Zero) {\n\t\tif (SqEr < MinSqEr) MinSqEr = SqEr;\n\t\tif (SqEr > MaxSqEr) MaxSqEr = SqEr;\n\t\tJ = J + 1.0;\n\t\tBadCond(ErrKind, \"\\n\");\n\t\tprintf(\"sqrt( %.17e) - %.17e  = %.17e\\n\", X * X, X, OneUlp * SqEr);\n\t\tprintf(\"\\tinstead of correct value 0 .\\n\");\n\t\t}\n\t}\n\n/* NewD */\n\nNewD()\n{\n\tX = Z1 * Q;\n\tX = FLOOR(Half - X / Radix) * Radix + X;\n\tQ = (Q - X * Z) / Radix + X * X * (D / Radix);\n\tZ = Z - Two * X * D;\n\tif (Z <= Zero) {\n\t\tZ = - Z;\n\t\tZ1 = - Z1;\n\t\t}\n\tD = Radix * D;\n\t}\n\n/* SR3750 */\n\nSR3750()\n{\n\tif (! ((X - Radix < Z2 - Radix) || (X - Z2 > W - Z2))) {\n\t\tI = I + 1;\n\t\tX2 = SQRT(X * D);\n\t\tY2 = (X2 - Z2) - (Y - Z2);\n\t\tX2 = X8 / (Y - Half);\n\t\tX2 = X2 - Half * X2 * X2;\n\t\tSqEr = (Y2 + Half) + (Half - X2);\n\t\tif (SqEr < MinSqEr) MinSqEr = SqEr;\n\t\tSqEr = Y2 - X2;\n\t\tif (SqEr > MaxSqEr) MaxSqEr = SqEr;\n\t\t}\n\t}\n\n/* IsYeqX */\n\nIsYeqX()\n{\n\tif (Y != X) {\n\t\tif (N <= 0) {\n\t\t\tif (Z == Zero && Q <= Zero)\n\t\t\t\tprintf(\"WARNING:  computing\\n\");\n\t\t\telse BadCond(Defect, \"computing\\n\");\n\t\t\tprintf(\"\\t(%.17e) ^ (%.17e)\\n\", Z, Q);\n\t\t\tprintf(\"\\tyielded %.17e;\\n\", Y);\n\t\t\tprintf(\"\\twhich compared unequal to correct %.17e ;\\n\",\n\t\t\t\tX);\n\t\t\tprintf(\"\\t\\tthey differ by %.17e .\\n\", Y - X);\n\t\t\t}\n\t\tN = N + 1; /* ... count discrepancies. */\n\t\t}\n\t}\n\n/* SR3980 */\n\nSR3980()\n{\n\tdo {\n\t\tQ = (FLOAT) I;\n\t\tY = POW(Z, Q);\n\t\tIsYeqX();\n\t\tif (++I > M) break;\n\t\tX = Z * X;\n\t\t} while ( X < W );\n\t}\n\n/* PrintIfNPositive */\n\nPrintIfNPositive()\n{\n\tif (N > 0) printf(\"Similar discrepancies have occurred %d times.\\n\", N);\n\t}\n\n/* TstPtUf */\n\nTstPtUf()\n{\n\tN = 0;\n\tif (Z != Zero) {\n\t\tprintf(\"Since comparison denies Z = 0, evaluating \");\n\t\tprintf(\"(Z + Z) / Z should be safe.\\n\");\n\t\tsigsave = sigfpe;\n\t\tif (setjmp(ovfl_buf)) goto very_serious;\n\t\tQ9 = (Z + Z) / Z;\n\t\tprintf(\"What the machine gets for (Z + Z) / Z is  %.17e .\\n\",\n\t\t\tQ9);\n\t\tif (FABS(Q9 - Two) < Radix * U2) {\n\t\t\tprintf(\"This is O.K., provided Over/Underflow\");\n\t\t\tprintf(\" has NOT just been signaled.\\n\");\n\t\t\t}\n\t\telse {\n\t\t\tif ((Q9 < One) || (Q9 > Two)) {\nvery_serious:\n\t\t\t\tN = 1;\n\t\t\t\tErrCnt [Serious] = ErrCnt [Serious] + 1;\n\t\t\t\tprintf(\"This is a VERY SERIOUS DEFECT!\\n\");\n\t\t\t\t}\n\t\t\telse {\n\t\t\t\tN = 1;\n\t\t\t\tErrCnt [Defect] = ErrCnt [Defect] + 1;\n\t\t\t\tprintf(\"This is a DEFECT!\\n\");\n\t\t\t\t}\n\t\t\t}\n\t\tsigsave = 0;\n\t\tV9 = Z * One;\n\t\tRandom1 = V9;\n\t\tV9 = One * Z;\n\t\tRandom2 = V9;\n\t\tV9 = Z / One;\n\t\tif ((Z == Random1) && (Z == Random2) && (Z == V9)) {\n\t\t\tif (N > 0) Pause();\n\t\t\t}\n\t\telse {\n\t\t\tN = 1;\n\t\t\tBadCond(Defect, \"What prints as Z = \");\n\t\t\tprintf(\"%.17e\\n\\tcompares different from  \", Z);\n\t\t\tif (Z != Random1) printf(\"Z * 1 = %.17e \", Random1);\n\t\t\tif (! ((Z == Random2)\n\t\t\t\t|| (Random2 == Random1)))\n\t\t\t\tprintf(\"1 * Z == %g\\n\", Random2);\n\t\t\tif (! (Z == V9)) printf(\"Z / 1 = %.17e\\n\", V9);\n\t\t\tif (Random2 != Random1) {\n\t\t\t\tErrCnt [Defect] = ErrCnt [Defect] + 1;\n\t\t\t\tBadCond(Defect, \"Multiplication does not commute!\\n\");\n\t\t\t\tprintf(\"\\tComparison alleges that 1 * Z = %.17e\\n\",\n\t\t\t\t\tRandom2);\n\t\t\t\tprintf(\"\\tdiffers from Z * 1 = %.17e\\n\", Random1);\n\t\t\t\t}\n\t\t\tPause();\n\t\t\t}\n\t\t}\n\t}\n\nnotify(s)\nchar *s;\n{\n\tprintf(\"%s test appears to be inconsistent...\\n\", s);\n\tprintf(\"   PLEASE NOTIFY KARPINKSI!\\n\");\n\t}\n\n/*SPLIT msgs.c */\n\n/* Instructions */\n\nmsglist(s)\nchar **s;\n{ while(*s) printf(\"%s\\n\", *s++); }\n\nInstructions()\n{\n  static char *instr[] = {\n\t\"Lest this program stop prematurely, i.e. before displaying\\n\",\n\t\"    `END OF TEST',\\n\",\n\t\"try to persuade the computer NOT to terminate execution when an\",\n\t\"error like Over/Underflow or Division by Zero occurs, but rather\",\n\t\"to persevere with a surrogate value after, perhaps, displaying some\",\n\t\"warning.  If persuasion avails naught, don't despair but run this\",\n\t\"program anyway to see how many milestones it passes, and then\",\n\t\"amend it to make further progress.\\n\",\n\t\"Answer questions with Y, y, N or n (unless otherwise indicated).\\n\",\n\t0};\n\n\tmsglist(instr);\n\t}\n\n/* Heading */\n\nHeading()\n{\n  static char *head[] = {\n\t\"Users are invited to help debug and augment this program so it will\",\n\t\"cope with unanticipated and newly uncovered arithmetic pathologies.\\n\",\n\t\"Please send suggestions and interesting results to\",\n\t\"\\tRichard Karpinski\",\n\t\"\\tComputer Center U-76\",\n\t\"\\tUniversity of California\",\n\t\"\\tSan Francisco, CA 94143-0704, USA\\n\",\n\t\"In doing so, please include the following information:\",\n#ifdef Single\n\t\"\\tPrecision:\\tsingle;\",\n#else\n\t\"\\tPrecision:\\tdouble;\",\n#endif\n\t\"\\tVersion:\\t10 February 1989;\",\n\t\"\\tComputer:\\n\",\n\t\"\\tCompiler:\\n\",\n\t\"\\tOptimization level:\\n\",\n\t\"\\tOther relevant compiler options:\",\n\t0};\n\n\tmsglist(head);\n\t}\n\n/* Characteristics */\n\nCharacteristics()\n{\n\tstatic char *chars[] = {\n\t \"Running this program should reveal these characteristics:\",\n\t\"     Radix = 1, 2, 4, 8, 10, 16, 100, 256 ...\",\n\t\"     Precision = number of significant digits carried.\",\n\t\"     U2 = Radix/Radix^Precision = One Ulp\",\n\t\"\\t(OneUlpnit in the Last Place) of 1.000xxx .\",\n\t\"     U1 = 1/Radix^Precision = One Ulp of numbers a little less than 1.0 .\",\n\t\"     Adequacy of guard digits for Mult., Div. and Subt.\",\n\t\"     Whether arithmetic is chopped, correctly rounded, or something else\",\n\t\"\\tfor Mult., Div., Add/Subt. and Sqrt.\",\n\t\"     Whether a Sticky Bit used correctly for rounding.\",\n\t\"     UnderflowThreshold = an underflow threshold.\",\n\t\"     E0 and PseudoZero tell whether underflow is abrupt, gradual, or fuzzy.\",\n\t\"     V = an overflow threshold, roughly.\",\n\t\"     V0  tells, roughly, whether  Infinity  is represented.\",\n\t\"     Comparisions are checked for consistency with subtraction\",\n\t\"\\tand for contamination with pseudo-zeros.\",\n\t\"     Sqrt is tested.  Y^X is not tested.\",\n\t\"     Extra-precise subexpressions are revealed but NOT YET tested.\",\n\t\"     Decimal-Binary conversion is NOT YET tested for accuracy.\",\n\t0};\n\n\tmsglist(chars);\n\t}\n\nHistory()\n\n{ /* History */\n /* Converted from Brian Wichmann's Pascal version to C by Thos Sumner,\n\twith further massaging by David M. Gay. */\n\n  static char *hist[] = {\n\t\"The program attempts to discriminate among\",\n\t\"   FLAWs, like lack of a sticky bit,\",\n\t\"   Serious DEFECTs, like lack of a guard digit, and\",\n\t\"   FAILUREs, like 2+2 == 5 .\",\n\t\"Failures may confound subsequent diagnoses.\\n\",\n\t\"The diagnostic capabilities of this program go beyond an earlier\",\n\t\"program called `MACHAR', which can be found at the end of the\",\n\t\"book  `Software Manual for the Elementary Functions' (1980) by\",\n\t\"W. J. Cody and W. Waite. Although both programs try to discover\",\n\t\"the Radix, Precision and range (over/underflow thresholds)\",\n\t\"of the arithmetic, this program tries to cope with a wider variety\",\n\t\"of pathologies, and to say how well the arithmetic is implemented.\",\n\t\"\\nThe program is based upon a conventional radix representation for\",\n\t\"floating-point numbers, but also allows logarithmic encoding\",\n\t\"as used by certain early WANG machines.\\n\",\n\t\"BASIC version of this program (C) 1983 by Prof. W. M. Kahan;\",\n\t\"see source comments for more history.\",\n\t0};\n\n\tmsglist(hist);\n\t}\n\ndouble\npow(x, y) /* return x ^ y (exponentiation) */\ndouble x, y;\n{\n\textern double exp(), frexp(), ldexp(), log(), modf();\n\tdouble xy, ye;\n\tlong i;\n\tint ex, ey = 0, flip = 0;\n\n\tif (!y) return 1.0;\n\n\tif ((y < -1100. || y > 1100.) && x != -1.) return exp(y * log(x));\n\n\tif (y < 0.) { y = -y; flip = 1; }\n\ty = modf(y, &ye);\n\tif (y) xy = exp(y * log(x));\n\telse xy = 1.0;\n\t/* next several lines assume >= 32 bit integers */\n\tx = frexp(x, &ex);\n\tif (i = ye) for(;;) {\n\t\tif (i & 1) { xy *= x; ey += ex; }\n\t\tif (!(i >>= 1)) break;\n\t\tx *= x;\n\t\tex *= 2;\n\t\tif (x < .5) { x *= 2.; ex -= 1; }\n\t\t}\n\tif (flip) { xy = 1. / xy; ey = -ey; }\n\treturn ldexp(xy, ey);\n}\n"
  },
  {
    "path": "lcc/tst/sort.0",
    "content": ""
  },
  {
    "path": "lcc/tst/sort.c",
    "content": "int in[] = {10, 32, -1, 567, 3, 18, 1, -51, 789, 0};\n\nmain() {\n\tint i;\n\n\tsort(in, (sizeof in)/(sizeof in[0]));\n\tfor (i = 0; i < (sizeof in)/(sizeof in[0]); i++) {\n\t\tputd(in[i]);\n\t\tputchar('\\n');\n\t}\n\treturn 0;\n}\n\n/* putd - output decimal number */\nputd(n) {\n\tif (n < 0) {\n\t\tputchar('-');\n\t\tn = -n;\n\t}\n\tif (n/10)\n\t\tputd(n/10);\n\tputchar(n%10 + '0');\n}\n\nint *xx;\n\n/* sort - sort a[0..n-1] into increasing order */\nsort(a, n) int a[]; {\n\tquick(xx = a, 0, --n);\n}\n\n/* quick - quicksort a[lb..ub] */\nquick(a, lb, ub) int a[]; {\n\tint k, partition();\n\n\tif (lb >= ub)\n\t\treturn;\n\tk = partition(a, lb, ub);\n\tquick(a, lb, k - 1);\n\tquick(a, k + 1, ub);\n}\n\n/* partition - partition a[i..j] */\nint partition(a, i, j) int a[]; {\n\tint v, k;\n\n\tj++;\n\tk = i;\n\tv = a[k];\n\twhile (i < j) {\n\t\ti++; while (a[i] < v) i++;\n\t\tj--; while (a[j] > v) j--;\n\t\tif (i < j) exchange(&a[i], &a[j]);\n\t}\n\texchange(&a[k], &a[j]);\n\treturn j;\n}\n\n/* exchange - exchange *x and *y */\nexchange(x, y) int *x, *y; {\n\tint t;\n\n\tprintf(\"exchange(%d,%d)\\n\", x - xx, y - xx);\n\tt = *x; *x = *y; *y = t;\n}\n"
  },
  {
    "path": "lcc/tst/spill.0",
    "content": ""
  },
  {
    "path": "lcc/tst/spill.c",
    "content": "main(){}\n\nf(i){i=f()+f();}\n\nf2(i){i=f()+(i?f():1);}\n\nf3(int i,int *p){register r1=0,r2=0,r3=0,r4=0,r5=0,r6=0,r7=0,r8=0,r9=0,r10=0;*p++=i?f():0;}\n\ndouble a[10],b[10];int i;f4(){register r6=0,r7=0,r8=0,r9=0,r10=0,r11=0;i=a[i]+b[i] && i && a[i]-b[i];}\n/* f4 causes parent to spill child on vax when odd double regs are enabled */\n\nint j, k, m, n;\ndouble *A, *B, x;\nf5(){\n\tx=A[k*m]*A[j*m]+B[k*n]*B[j*n];\n\tx=A[k*m]*B[j*n]-B[k*n]*A[j*m];\n}  \n"
  },
  {
    "path": "lcc/tst/stdarg.0",
    "content": ""
  },
  {
    "path": "lcc/tst/stdarg.c",
    "content": "#include <stdarg.h>\n\nstruct node { int a[4]; } x = {1,2,3,4};\n\nprint(char *fmt, ...);\n\nmain() {\n\tprint(\"test 1\\n\");\n\tprint(\"test %s\\n\", \"2\");\n\tprint(\"test %d%c\", 3, '\\n');\n\tprint(\"%s%s %w%c\", \"te\", \"st\", 4, '\\n');\n\tprint(\"%s%s %f%c\", \"te\", \"st\", 5.0, '\\n');\n\tprint(\"%b %b %b %b %b %b\\n\", x, x, x, x, x, x);\n\treturn 0;\n}\n\nprint(char *fmt, ...) {\n\tva_list ap;\n\n\tva_start(ap, fmt);\n\tfor (; *fmt; fmt++)\n\t\tif (*fmt == '%')\n\t\t\tswitch (*++fmt) {\n\t\t\tcase 'b': {\n\t\t\t\tstruct node x = va_arg(ap, struct node);\n\t\t\t\tprintf(\"{%d %d %d %d}\", x.a[0], x.a[1], x.a[2], x.a[3]);\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\tcase 'c':\n\t\t\t\tprintf(\"%c\", va_arg(ap, char));\n\t\t\t\tbreak;\n\t\t\tcase 'd':\n\t\t\t\tprintf(\"%d\", va_arg(ap, int));\n\t\t\t\tbreak;\n\t\t\tcase 'w':\n\t\t\t\tprintf(\"%x\", va_arg(ap, short));\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\tprintf(\"%s\", va_arg(ap, char *));\n\t\t\t\tbreak;\n\t\t\tcase 'f':\n\t\t\t\tprintf(\"%f\", va_arg(ap, double));\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tprintf(\"%c\", *fmt);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t else\n\t\t\tprintf(\"%c\", *fmt);\n\tva_end(ap);\n}\n"
  },
  {
    "path": "lcc/tst/struct.0",
    "content": ""
  },
  {
    "path": "lcc/tst/struct.c",
    "content": "typedef struct point { int x,y; } point;\ntypedef struct rect { point pt1, pt2; } rect;\n\npoint addpoint(point p1, point p2) {\t/* add two points */\n\tp1.x += p2.x;\n\tp1.y += p2.y;\n\treturn p1;\n}\n\n#define min(a, b) ((a) < (b) ? (a) : (b))\n#define max(a, b) ((a) > (b) ? (a) : (b))\n\nrect canonrect(rect r) {\t\t/* canonicalize rectangle coordinates */\n\trect temp;\n\n\ttemp.pt1.x = min(r.pt1.x, r.pt2.x);\n\ttemp.pt1.y = min(r.pt1.y, r.pt2.y);\n\ttemp.pt2.x = max(r.pt1.x, r.pt2.x);\n\ttemp.pt2.y = max(r.pt1.y, r.pt2.y);\n\treturn temp;\n}\n\npoint makepoint(int x, int y) {\t\t/* make a point from x and y components */\n\tpoint p;\n\n\tp.x = x;\n\tp.y = y;\n\treturn p;\n}\n\nrect makerect(point p1, point p2) {\t/* make a rectangle from two points */\n\trect r;\n\n\tr.pt1 = p1;\n\tr.pt2 = p2;\n\treturn canonrect(r);\n}\n\nint ptinrect(point p, rect r) {\t\t/* is p in r? */\n\treturn p.x >= r.pt1.x && p.x < r.pt2.x\n\t\t&& p.y >= r.pt1.y && p.y < r.pt2.y;\n}\n\nstruct odd {char a[3]; } y = {'a', 'b', 0};\n\nodd(struct odd y) {\n\tstruct odd x = y;\n\tprintf(\"%s\\n\", x.a);\n}\n\nmain() {\n\tint i;\n\tpoint x, origin = { 0, 0 }, maxpt = { 320, 320 };\n\tpoint pts[] = { -1, -1, 1, 1, 20, 300, 500, 400 };\n\trect screen = makerect(addpoint(maxpt, makepoint(-10, -10)),\n\t\taddpoint(origin, makepoint(10, 10)));\n\n\tfor (i = 0; i < sizeof pts/sizeof pts[0]; i++) {\n\t\tprintf(\"(%d,%d) is \", pts[i].x,\n\t\t\t(x = makepoint(pts[i].x, pts[i].y)).y);\n\t\tif (ptinrect(x, screen) == 0)\n\t\t\tprintf(\"not \");\n\t\tprintf(\"within [%d,%d; %d,%d]\\n\", screen.pt1.x, screen.pt1.y,\n\t\t\tscreen.pt2.x, screen.pt2.y);\n\t}\n\todd(y);\n\texit(0);\n}\n\n"
  },
  {
    "path": "lcc/tst/switch.0",
    "content": ""
  },
  {
    "path": "lcc/tst/switch.c",
    "content": "main()\n{\n\tint i; char *s;\n\n\tfor (s = \"bfnrtvx\"; *s; s++)\n\t\tprintf(\"%c = 0x%x\\n\", *s, backslash(*s));\n\tf();\n\tg();\n\th();\n\tfor (i = 0x1000000; i&0x7000000; i += 0x1000000)\n\t\tbig(i);\n\tlimit();\n\treturn 0;\n}\t\n\nbackslash(c)\n{\n\tswitch (c) {\n\tcase 'b':\n\t\treturn '\\b';\n\tcase 'f':\n\t\treturn '\\f';\n\tcase 'n':\n\t\treturn '\\n';\n\tcase 'r':\n\t\treturn '\\r';\n\tcase 't':\n\t\treturn '\\t';\n\tcase 'v':\n\t\treturn '\\v';\n\t}\n\treturn c;\n}\n\nf() {\n\tint i, x = 0, y;\n\n\tprintf(\"f:\\n\");\n\tfor (i = 0; i <= 20; i++) {\n\t\ty = i;\n\t\tswitch (i) {\n\t\tcase 1: x = i; break;\n\t\tcase 2: x = i; break;\n\t\tcase 7: x = i; break;\n\t\tcase 8: x = i; break;\n\t\tcase 9: x = i; break;\n\t\tcase 16: x = i; break;\n\t\tcase 17: x = i; break;\n\t\tcase 18: x = i; break;\n\t\tcase 19: x = i; break;\n\t\tcase 20: x = i; break;\n\t\t}\n\t\tprintf(\"x = %d\\n\", x);\n\t}\n}\n\ng() {\n\tint i;\n\n\tprintf(\"g:\\n\");\n\tfor (i = 1; i <= 10; i++)\n\t\tswitch (i) {\n\t\tcase 1: case 2: printf(\"1 %d\\n\", i); break;\n\t\tcase 3: case 4: case 5: printf(\"2 %d\\n\", i); break;\n\t\tcase 6: case 7: case 8: printf(\"3 %d\\n\", i);\n\t\tdefault:\n\t\t\tprintf(\"d %d\\n\", i); break;\n\t\tcase 1001: case 1002: case 1003: case 1004:\n\t\t\tprintf(\"5 %d\\n\", i); break;\n\t\tcase 3001: case 3002: case 3003: case 3004:\n\t\t\tprintf(\"6 %d\\n\", i); break;\n\t}\n}\n\nh()\n{\n\tint i, n=0;\n\n\tprintf(\"h:\\n\");\n\tfor (i = 1; i <= 500; i++)\n\t\tswitch (i) {\n\t\tdefault: n++; continue;\n\t\tcase 128: printf(\"i = %d\\n\", i); break;\n\t\tcase 16: printf(\"i = %d\\n\", i); break;\n\t\tcase 8: printf(\"i = %d\\n\", i); break;\n\t\tcase 120: printf(\"i = %d\\n\", i); break;\n\t\tcase 280: printf(\"i = %d\\n\", i); break;\n\t\tcase 264: printf(\"i = %d\\n\", i); break;\n\t\tcase 248: printf(\"i = %d\\n\", i); break;\n\t\tcase 272: printf(\"i = %d\\n\", i); break;\n\t\tcase 304: printf(\"i = %d\\n\", i); break;\n\t\tcase 296: printf(\"i = %d\\n\", i); break;\n\t\tcase 288: printf(\"i = %d\\n\", i); break;\n\t\tcase 312: printf(\"i = %d\\n\", i); break;\n\t\t}\n\tprintf(\"%d defaults\\n\", n);\n}\n\nbig(x) unsigned x; {\n\tswitch(x&0x6000000){\n\tcase -1:\n\tcase -2:\n\tcase 0x0000000:\n\t\tprintf(\"x = 0x%x\\n\", x); break;\n\tcase 0x2000000:\n\t\tprintf(\"x = 0x%x\\n\", x); break;\n\tcase 0x4000000:\n\t\tprintf(\"x = 0x%x\\n\", x); break;\n\tdefault:\n\t\tprintf(\"x = 0x%x (default)\\n\", x); break;\n\t}\n}\n\n#include <limits.h>\n\nlimit() {\n\tint i;\n\n\tfor (i = INT_MIN; i <= INT_MIN+5; i++)\n\t\tswitch (i) {\n\t\tcase INT_MIN:\tprintf(\"0\\n\"); break;\n\t\tcase INT_MIN+1:\tprintf(\"1\\n\"); break;\n\t\tcase INT_MIN+2:\tprintf(\"2\\n\"); break;\n\t\tcase INT_MIN+3:\tprintf(\"3\\n\"); break;\n\t\tcase INT_MIN+4:\tprintf(\"4\\n\"); break;\n\t\tdefault:\tprintf(\"5\\n\"); break;\n\t\t}\n\tfor (i = INT_MAX; i >= INT_MAX-5; i--)\n\t\tswitch (i) {\n\t\tcase INT_MAX:\tprintf(\"0\\n\"); break;\n\t\tcase INT_MAX-1:\tprintf(\"1\\n\"); break;\n\t\tcase INT_MAX-2:\tprintf(\"2\\n\"); break;\n\t\tcase INT_MAX-3:\tprintf(\"3\\n\"); break;\n\t\tcase INT_MAX-4:\tprintf(\"4\\n\"); break;\n\t\tdefault:\tprintf(\"5\\n\"); break;\n\t\t}\n}\n"
  },
  {
    "path": "lcc/tst/wf1.0",
    "content": "/* wf1 - print word frequencies; uses structures */\n\nstruct node {\n\tint count;\t\t/* frequency count */\n\tstruct node *left;\t/* left subtree */\n\tstruct node *right;\t/* right subtree */\n\tchar *word;\t\t/* word itself */\n} words[2000];\nint next;\t\t/* index of next free entry in words */\n\nstruct node *lookup();\n\nmain()\n{\n\tstruct node *root;\n\tchar word[20];\n\n\troot = 0;\n\tnext = 0;\n\twhile (getword(word))\n\t\tlookup(word, &root)->count++;\n\ttprint(root);\n\treturn 0;\n}\n\n/* err - print error message s and die\t*/\nerr(s)\nchar *s;\n{\n\tprintf(\"? %s\\n\", s);\n\texit(1);\n}\n\n/* getword - get next input word into buf, return 0 on EOF */\nint getword(buf)\nchar *buf;\n{\n\tchar *s;\n\tint c;\n\n\twhile ((c = getchar()) != -1 && isletter(c) == 0)\n\t\t;\n\tfor (s = buf; c = isletter(c); c = getchar())\n\t\t*s++ = c;\n\t*s = 0;\n\tif (s > buf)\n\t\treturn (1);\n\treturn (0);\n}\n\n/* isletter - return folded version of c if it is a letter, 0 otherwise */\nint isletter(c)\nint c;\n{\n\tif (c >= 'A' && c <= 'Z')\n\t\tc += 'a' - 'A';\n\tif (c >= 'a' && c <= 'z')\n\t\treturn (c);\n\treturn (0);\n}\n\n/* lookup - lookup word in tree; install if necessary */\nstruct node *lookup(word, p)\nchar *word;\nstruct node **p;\n{\n\tint cond;\n\tchar *malloc();\n\n\tif (*p) {\n\t\tcond = strcmp(word, (*p)->word);\n\t\tif (cond < 0)\n\t\t\treturn lookup(word, &(*p)->left);\n\t\telse if (cond > 0)\n\t\t\treturn lookup(word, &(*p)->right);\n\t\telse\n\t\t\treturn *p;\n\t}\n\tif (next >= 2000)\n\t\terr(\"out of node storage\");\n\twords[next].count = 0;\n\twords[next].left = words[next].right = 0;\n\twords[next].word = malloc(strlen(word) + 1);\n\tif (words[next].word == 0)\n\t\terr(\"out of word storage\");\n\tstrcpy(words[next].word, word);\n\treturn *p = &words[next++];\n}\n\n/* tprint - print tree */\ntprint(tree)\nstruct node *tree;\n{\n\tif (tree) {\n\t\ttprint(tree->left);\n\t\tprintf(\"%d\\t%s\\n\", tree->count, tree->word);\n\t\ttprint(tree->right);\n\t}\n}\n\n/* strcmp - compare s1 and s2, return <0, 0, or >0 */\nint strcmp(s1, s2)\nchar *s1, *s2;\n{\n\twhile (*s1 == *s2) {\n\t\tif (*s1++ == 0)\n\t\t\treturn 0;\n\t\t++s2;\n\t}\n\tif (*s1 == 0)\n\t\treturn -1;\n\telse if (*s2 == 0)\n\t\treturn 1;\n\treturn *s1 - *s2;\n}\n"
  },
  {
    "path": "lcc/tst/wf1.c",
    "content": "/* wf1 - print word frequencies; uses structures */\n\nstruct node {\n\tint count;\t\t/* frequency count */\n\tstruct node *left;\t/* left subtree */\n\tstruct node *right;\t/* right subtree */\n\tchar *word;\t\t/* word itself */\n} words[2000];\nint next;\t\t/* index of next free entry in words */\n\nstruct node *lookup();\n\nmain() {\n\tstruct node *root;\n\tchar word[20];\n\n\troot = 0;\n\tnext = 0;\n\twhile (getword(word))\n\t\tlookup(word, &root)->count++;\n\ttprint(root);\n\treturn 0;\n}\n\n/* err - print error message s and die\t*/\nerr(s) char *s; {\n\tprintf(\"? %s\\n\", s);\n\texit(1);\n}\n\n/* getword - get next input word into buf, return 0 on EOF */\nint getword(buf) char *buf; {\n\tchar *s;\n\tint c;\n\n\twhile ((c = getchar()) != -1 && isletter(c) == 0)\n\t\t;\n\tfor (s = buf; c = isletter(c); c = getchar())\n\t\t*s++ = c;\n\t*s = 0;\n\tif (s > buf)\n\t\treturn (1);\n\treturn (0);\n}\n\n/* isletter - return folded version of c if it is a letter, 0 otherwise */\nint isletter(c) {\n\tif (c >= 'A' && c <= 'Z')\n\t\tc += 'a' - 'A';\n\tif (c >= 'a' && c <= 'z')\n\t\treturn (c);\n\treturn (0);\n}\n\n/* lookup - lookup word in tree; install if necessary */\nstruct node *lookup(word, p) char *word; struct node **p; {\n\tint cond;\n\tchar *malloc();\n\n\tif (*p) {\n\t\tcond = strcmp(word, (*p)->word);\n\t\tif (cond < 0)\n\t\t\treturn lookup(word, &(*p)->left);\n\t\telse if (cond > 0)\n\t\t\treturn lookup(word, &(*p)->right);\n\t\telse\n\t\t\treturn *p;\n\t}\n\tif (next >= 2000)\n\t\terr(\"out of node storage\");\n\twords[next].count = 0;\n\twords[next].left = words[next].right = 0;\n\twords[next].word = malloc(strlen(word) + 1);\n\tif (words[next].word == 0)\n\t\terr(\"out of word storage\");\n\tstrcpy(words[next].word, word);\n\treturn *p = &words[next++];\n}\n\n/* tprint - print tree */\ntprint(tree) struct node *tree; {\n\tif (tree) {\n\t\ttprint(tree->left);\n\t\tprintf(\"%d\\t%s\\n\", tree->count, tree->word);\n\t\ttprint(tree->right);\n\t}\n}\n\n/* strcmp - compare s1 and s2, return <0, 0, or >0 */\nint strcmp(s1, s2) char *s1, *s2; {\n\twhile (*s1 == *s2) {\n\t\tif (*s1++ == 0)\n\t\t\treturn 0;\n\t\t++s2;\n\t}\n\tif (*s1 == 0)\n\t\treturn -1;\n\telse if (*s2 == 0)\n\t\treturn 1;\n\treturn *s1 - *s2;\n}\n"
  },
  {
    "path": "lcc/tst/yacc.0",
    "content": "a=-b+5*c\n"
  },
  {
    "path": "lcc/tst/yacc.c",
    "content": "# define ID 257\n# define CON 258\n# define UNARYMINUS 259\n#define yyclearin yychar = -1\n#define yyerrok yyerrflag = 0\nextern int yychar;\nextern short yyerrflag;\n#ifndef YYMAXDEPTH\n#define YYMAXDEPTH 150\n#endif\n#ifndef YYSTYPE\n#define YYSTYPE int\n#endif\nYYSTYPE yylval, yyval;\n# define YYERRCODE 256\n\n\n\n#include <stdio.h>\n\n# define U(x) x\n# define NLSTATE yyprevious=YYNEWLINE\n# define BEGIN yybgin = yysvec + 1 +\n# define INITIAL 0\n# define YYLERR yysvec\n# define YYSTATE (yyestate-yysvec-1)\n# define YYOPTIM 1\n# define YYLMAX 200\n# define output(c) (void)putc(c,yyout)\n# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)\n# define unput(c) {yytchar= (c);if(yytchar=='\\n')yylineno--;*yysptr++=yytchar;}\n# define yymore() (yymorfg=1)\n# define ECHO fprintf(yyout, \"%s\",yytext)\n# define REJECT { nstr = yyreject(); goto yyfussy;}\nint yyleng; extern char yytext[];\nint yymorfg;\nextern char *yysptr, yysbuf[];\nint yytchar;\nFILE *yyin ={stdin}, *yyout ={stdout};\nextern int yylineno;\nstruct yysvf { \n\tstruct yywork *yystoff;\n\tstruct yysvf *yyother;\n\tint *yystops;};\nstruct yysvf *yyestate;\nextern struct yysvf yysvec[], *yybgin;\n# define YYNEWLINE 10\nyylex(){\nint nstr; extern int yyprevious;\nwhile((nstr = yylook()) >= 0)\nyyfussy: switch(nstr){\ncase 0:\nif(yywrap()) return(0); break;\ncase 1:\n return ID;\nbreak;\ncase 2:\n                 return CON;\nbreak;\ncase 3:\n                  ;\nbreak;\ncase 4:\n                   return yytext[0];\nbreak;\ncase -1:\nbreak;\ndefault:\nfprintf(yyout,\"bad switch yylook %d\",nstr);\n} return(0); }\n/* end of yylex */\nint yyvstop[] ={\n0,\n\n4,\n0,\n\n3,\n4,\n0,\n\n2,\n4,\n0,\n\n1,\n4,\n0,\n\n2,\n0,\n\n1,\n0,\n0};\n# define YYTYPE char\nstruct yywork { YYTYPE verify, advance; } yycrank[] ={\n0,0,\t0,0,\t1,3,\t0,0,\t\n0,0,\t0,0,\t0,0,\t0,0,\t\n0,0,\t0,0,\t1,4,\t1,3,\t\n0,0,\t0,0,\t0,0,\t0,0,\t\n0,0,\t0,0,\t0,0,\t0,0,\t\n0,0,\t0,0,\t0,0,\t0,0,\t\n0,0,\t0,0,\t0,0,\t0,0,\t\n0,0,\t0,0,\t0,0,\t0,0,\t\n0,0,\t0,0,\t0,0,\t0,0,\t\n0,0,\t0,0,\t0,0,\t0,0,\t\n0,0,\t0,0,\t0,0,\t0,0,\t\n0,0,\t0,0,\t0,0,\t0,0,\t\n0,0,\t1,5,\t5,7,\t5,7,\t\n5,7,\t5,7,\t5,7,\t5,7,\t\n5,7,\t5,7,\t5,7,\t5,7,\t\n0,0,\t0,0,\t0,0,\t0,0,\t\n0,0,\t0,0,\t1,6,\t6,8,\t\n6,8,\t6,8,\t6,8,\t6,8,\t\n6,8,\t6,8,\t6,8,\t6,8,\t\n6,8,\t0,0,\t0,0,\t0,0,\t\n0,0,\t0,0,\t0,0,\t0,0,\t\n6,8,\t6,8,\t6,8,\t6,8,\t\n6,8,\t6,8,\t6,8,\t6,8,\t\n6,8,\t6,8,\t6,8,\t6,8,\t\n6,8,\t6,8,\t6,8,\t6,8,\t\n6,8,\t6,8,\t6,8,\t6,8,\t\n6,8,\t6,8,\t6,8,\t6,8,\t\n6,8,\t6,8,\t0,0,\t0,0,\t\n0,0,\t0,0,\t6,8,\t0,0,\t\n6,8,\t6,8,\t6,8,\t6,8,\t\n6,8,\t6,8,\t6,8,\t6,8,\t\n6,8,\t6,8,\t6,8,\t6,8,\t\n6,8,\t6,8,\t6,8,\t6,8,\t\n6,8,\t6,8,\t6,8,\t6,8,\t\n6,8,\t6,8,\t6,8,\t6,8,\t\n6,8,\t6,8,\t0,0,\t0,0,\t\n0,0};\nstruct yysvf yysvec[] ={\n0,\t0,\t0,\nyycrank+-1,\t0,\t\t0,\t\nyycrank+0,\tyysvec+1,\t0,\t\nyycrank+0,\t0,\t\tyyvstop+1,\nyycrank+0,\t0,\t\tyyvstop+3,\nyycrank+2,\t0,\t\tyyvstop+6,\nyycrank+19,\t0,\t\tyyvstop+9,\nyycrank+0,\tyysvec+5,\tyyvstop+12,\nyycrank+0,\tyysvec+6,\tyyvstop+14,\n0,\t0,\t0};\nstruct yywork *yytop = yycrank+141;\nstruct yysvf *yybgin = yysvec+1;\nchar yymatch[] ={\n00  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,\n01  ,011 ,012 ,01  ,01  ,01  ,01  ,01  ,\n01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,\n01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,\n011 ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,\n01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,\n'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,\n'0' ,'0' ,01  ,01  ,01  ,01  ,01  ,01  ,\n01  ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,\n'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,\n'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,\n'A' ,'A' ,'A' ,01  ,01  ,01  ,01  ,'A' ,\n01  ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,\n'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,\n'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,\n'A' ,'A' ,'A' ,01  ,01  ,01  ,01  ,01  ,\n0};\nchar yyextra[] ={\n0,0,0,0,0,0,0,0,\n0};\n/*\tncform\t4.1\t83/08/11\t*/\n\nint yylineno =1;\n# define YYU(x) x\n# define NLSTATE yyprevious=YYNEWLINE\nchar yytext[YYLMAX];\nstruct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;\nchar yysbuf[YYLMAX];\nchar *yysptr = yysbuf;\nint *yyfnd;\nextern struct yysvf *yyestate;\nint yyprevious = YYNEWLINE;\nyylook(){\n\tregister struct yysvf *yystate, **lsp;\n\tregister struct yywork *yyt;\n\tstruct yysvf *yyz;\n\tint yych;\n\tstruct yywork *yyr;\n# ifdef LEXDEBUG\n\tint debug;\n# endif\n\tchar *yylastch;\n\t/* start off machines */\n# ifdef LEXDEBUG\n\tdebug = 0;\n# endif\n\tif (!yymorfg)\n\t\tyylastch = yytext;\n\telse {\n\t\tyymorfg=0;\n\t\tyylastch = yytext+yyleng;\n\t\t}\n\tfor(;;){\n\t\tlsp = yylstate;\n\t\tyyestate = yystate = yybgin;\n\t\tif (yyprevious==YYNEWLINE) yystate++;\n\t\tfor (;;){\n# ifdef LEXDEBUG\n\t\t\tif(debug)fprintf(yyout,\"state %d\\n\",yystate-yysvec-1);\n# endif\n\t\t\tyyt = yystate->yystoff;\n\t\t\tif(yyt == yycrank){\t\t/* may not be any transitions */\n\t\t\t\tyyz = yystate->yyother;\n\t\t\t\tif(yyz == 0)break;\n\t\t\t\tif(yyz->yystoff == yycrank)break;\n\t\t\t\t}\n\t\t\t*yylastch++ = yych = input();\n\t\ttryagain:\n# ifdef LEXDEBUG\n\t\t\tif(debug){\n\t\t\t\tfprintf(yyout,\"char \");\n\t\t\t\tallprint(yych);\n\t\t\t\tputchar('\\n');\n\t\t\t\t}\n# endif\n\t\t\tyyr = yyt;\n\t\t\tif ( yyt > yycrank){\n\t\t\t\tyyt = yyr + yych;\n\t\t\t\tif (yyt <= yytop && yyt->verify+yysvec == yystate){\n\t\t\t\t\tif(yyt->advance+yysvec == YYLERR)\t/* error transitions */\n\t\t\t\t\t\t{unput(*--yylastch);break;}\n\t\t\t\t\t*lsp++ = yystate = yyt->advance+yysvec;\n\t\t\t\t\tgoto contin;\n\t\t\t\t\t}\n\t\t\t\t}\n# ifdef YYOPTIM\n\t\t\telse if(yyt < yycrank) {\t\t/* r < yycrank */\n\t\t\t\tyyt = yyr = yycrank+(yycrank-yyt);\n# ifdef LEXDEBUG\n\t\t\t\tif(debug)fprintf(yyout,\"compressed state\\n\");\n# endif\n\t\t\t\tyyt = yyt + yych;\n\t\t\t\tif(yyt <= yytop && yyt->verify+yysvec == yystate){\n\t\t\t\t\tif(yyt->advance+yysvec == YYLERR)\t/* error transitions */\n\t\t\t\t\t\t{unput(*--yylastch);break;}\n\t\t\t\t\t*lsp++ = yystate = yyt->advance+yysvec;\n\t\t\t\t\tgoto contin;\n\t\t\t\t\t}\n\t\t\t\tyyt = yyr + YYU(yymatch[yych]);\n# ifdef LEXDEBUG\n\t\t\t\tif(debug){\n\t\t\t\t\tfprintf(yyout,\"try fall back character \");\n\t\t\t\t\tallprint(YYU(yymatch[yych]));\n\t\t\t\t\tputchar('\\n');\n\t\t\t\t\t}\n# endif\n\t\t\t\tif(yyt <= yytop && yyt->verify+yysvec == yystate){\n\t\t\t\t\tif(yyt->advance+yysvec == YYLERR)\t/* error transition */\n\t\t\t\t\t\t{unput(*--yylastch);break;}\n\t\t\t\t\t*lsp++ = yystate = yyt->advance+yysvec;\n\t\t\t\t\tgoto contin;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tif ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){\n# ifdef LEXDEBUG\n\t\t\t\tif(debug)fprintf(yyout,\"fall back to state %d\\n\",yystate-yysvec-1);\n# endif\n\t\t\t\tgoto tryagain;\n\t\t\t\t}\n# endif\n\t\t\telse\n\t\t\t\t{unput(*--yylastch);break;}\n\t\tcontin:\n# ifdef LEXDEBUG\n\t\t\tif(debug){\n\t\t\t\tfprintf(yyout,\"state %d char \",yystate-yysvec-1);\n\t\t\t\tallprint(yych);\n\t\t\t\tputchar('\\n');\n\t\t\t\t}\n# endif\n\t\t\t;\n\t\t\t}\n# ifdef LEXDEBUG\n\t\tif(debug){\n\t\t\tfprintf(yyout,\"stopped at %d with \",*(lsp-1)-yysvec-1);\n\t\t\tallprint(yych);\n\t\t\tputchar('\\n');\n\t\t\t}\n# endif\n\t\twhile (lsp-- > yylstate){\n\t\t\t*yylastch-- = 0;\n\t\t\tif (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){\n\t\t\t\tyyolsp = lsp;\n\t\t\t\tif(yyextra[*yyfnd]){\t\t/* must backup */\n\t\t\t\t\twhile(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){\n\t\t\t\t\t\tlsp--;\n\t\t\t\t\t\tunput(*yylastch--);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tyyprevious = YYU(*yylastch);\n\t\t\t\tyylsp = lsp;\n\t\t\t\tyyleng = yylastch-yytext+1;\n\t\t\t\tyytext[yyleng] = 0;\n# ifdef LEXDEBUG\n\t\t\t\tif(debug){\n\t\t\t\t\tfprintf(yyout,\"\\nmatch \");\n\t\t\t\t\tsprint(yytext);\n\t\t\t\t\tfprintf(yyout,\" action %d\\n\",*yyfnd);\n\t\t\t\t\t}\n# endif\n\t\t\t\treturn(*yyfnd++);\n\t\t\t\t}\n\t\t\tunput(*yylastch);\n\t\t\t}\n\t\tif (yytext[0] == 0  /* && feof(yyin) */)\n\t\t\t{\n\t\t\tyysptr=yysbuf;\n\t\t\treturn(0);\n\t\t\t}\n\t\tyyprevious = yytext[0] = input();\n\t\tif (yyprevious>0)\n\t\t\toutput(yyprevious);\n\t\tyylastch=yytext;\n# ifdef LEXDEBUG\n\t\tif(debug)putchar('\\n');\n# endif\n\t\t}\n\t}\nyyback(p, m)\n\tint *p;\n{\nif (p==0) return(0);\nwhile (*p)\n\t{\n\tif (*p++ == m)\n\t\treturn(1);\n\t}\nreturn(0);\n}\n\t/* the following are only used in the lex library */\nyyinput(){\n\treturn(input());\n\t}\nyyoutput(c)\n  int c; {\n\toutput(c);\n\t}\nyyunput(c)\n   int c; {\n\tunput(c);\n\t}\n\nmain() {\n        yyparse();\n\treturn 0;\n}\n\n/* yyerror - issue error message */\nyyerror(s) char *s; {\n        printf(\"%s\\n\", s);\n}\nshort yyexca[] ={\n-1, 1,\n\t0, -1,\n\t-2, 0,\n\t};\n# define YYNPROD 15\n# define YYLAST 249\nshort yyact[]={\n\n  12,   2,   9,   8,  17,  11,  25,  17,  15,  18,\n  16,  10,  18,  17,  15,   7,  16,  13,  18,   5,\n   3,   1,   0,  19,  20,   0,   0,  21,  22,  23,\n  24,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   0,   0,   0,   0,   0,   0,   0,   6,  14,   0,\n   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   0,   0,   0,   0,   0,   0,   0,   4,   6 };\nshort yypact[]={\n\n-1000,  -9,-1000,   5,  -7, -59,-1000,-1000,-1000, -40,\n -29, -40, -40,-1000,-1000, -40, -40, -40, -40, -38,\n -35, -38, -38,-1000,-1000,-1000 };\nshort yypgo[]={\n\n   0,  21,  20,  17,  11 };\nshort yyr1[]={\n\n   0,   1,   1,   1,   1,   2,   4,   4,   4,   4,\n   4,   4,   4,   4,   3 };\nshort yyr2[]={\n\n   0,   0,   2,   3,   3,   3,   3,   3,   3,   3,\n   2,   3,   1,   1,   1 };\nshort yychk[]={\n\n-1000,  -1,  10,  -2, 256,  -3, 257,  10,  10,  61,\n  -4,  45,  40,  -3, 258,  43,  45,  42,  47,  -4,\n  -4,  -4,  -4,  -4,  -4,  41 };\nshort yydef[]={\n\n   1,  -2,   2,   0,   0,   0,  14,   3,   4,   0,\n   5,   0,   0,  12,  13,   0,   0,   0,   0,  10,\n   0,   6,   7,   8,   9,  11 };\n#ifndef lint\n#endif\n\n# define YYFLAG -1000\n# define YYERROR goto yyerrlab\n# define YYACCEPT return(0)\n# define YYABORT return(1)\n\n/*\tparser for yacc output\t*/\n\n#ifdef YYDEBUG\nint yydebug = 0; /* 1 for debugging */\n#endif\nYYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */\nint yychar = -1; /* current input token number */\nint yynerrs = 0;  /* number of errors */\nshort yyerrflag = 0;  /* error recovery flag */\n\nyyparse() {\n\n\tshort yys[YYMAXDEPTH];\n\tshort yyj, yym;\n\tregister YYSTYPE *yypvt;\n\tregister short yystate, *yyps, yyn;\n\tregister YYSTYPE *yypv;\n\tregister short *yyxi;\n\n\tyystate = 0;\n\tyychar = -1;\n\tyynerrs = 0;\n\tyyerrflag = 0;\n\tyyps= &yys[-1];\n\tyypv= &yyv[-1];\n\n yystack:    /* put a state and value onto the stack */\n\n#ifdef YYDEBUG\n\tif( yydebug  ) printf( \"state %d, char 0%o\\n\", yystate, yychar );\n#endif\n\t\tif( ++yyps> &yys[YYMAXDEPTH] ) { yyerror( \"yacc stack overflow\" ); return(1); }\n\t\t*yyps = yystate;\n\t\t++yypv;\n\t\t*yypv = yyval;\n\n yynewstate:\n\n\tyyn = yypact[yystate];\n\n\tif( yyn<= YYFLAG ) goto yydefault; /* simple state */\n\n\tif( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;\n\tif( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault;\n\n\tif( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */\n\t\tyychar = -1;\n\t\tyyval = yylval;\n\t\tyystate = yyn;\n\t\tif( yyerrflag > 0 ) --yyerrflag;\n\t\tgoto yystack;\n\t\t}\n\n yydefault:\n\t/* default state action */\n\n\tif( (yyn=yydef[yystate]) == -2 ) {\n\t\tif( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;\n\t\t/* look through exception table */\n\n\t\tfor( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */\n\n\t\twhile( *(yyxi+=2) >= 0 ){\n\t\t\tif( *yyxi == yychar ) break;\n\t\t\t}\n\t\tif( (yyn = yyxi[1]) < 0 ) return(0);   /* accept */\n\t\t}\n\n\tif( yyn == 0 ){ /* error */\n\t\t/* error ... attempt to resume parsing */\n\n\t\tswitch( yyerrflag ){\n\n\t\tcase 0:   /* brand new error */\n\n\t\t\tyyerror( \"syntax error\" );\n\t\tyyerrlab:\n\t\t\t++yynerrs;\n\n\t\tcase 1:\n\t\tcase 2: /* incompletely recovered error ... try again */\n\n\t\t\tyyerrflag = 3;\n\n\t\t\t/* find a state where \"error\" is a legal shift action */\n\n\t\t\twhile ( yyps >= yys ) {\n\t\t\t   yyn = yypact[*yyps] + YYERRCODE;\n\t\t\t   if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){\n\t\t\t      yystate = yyact[yyn];  /* simulate a shift of \"error\" */\n\t\t\t      goto yystack;\n\t\t\t      }\n\t\t\t   yyn = yypact[*yyps];\n\n\t\t\t   /* the current yyps has no shift onn \"error\", pop stack */\n\n#ifdef YYDEBUG\n\t\t\t   if( yydebug ) printf( \"error recovery pops state %d, uncovers %d\\n\", *yyps, yyps[-1] );\n#endif\n\t\t\t   --yyps;\n\t\t\t   --yypv;\n\t\t\t   }\n\n\t\t\t/* there is no state on the stack with an error shift ... abort */\n\n\tyyabort:\n\t\t\treturn(1);\n\n\n\t\tcase 3:  /* no shift yet; clobber input char */\n\n#ifdef YYDEBUG\n\t\t\tif( yydebug ) printf( \"error recovery discards char %d\\n\", yychar );\n#endif\n\n\t\t\tif( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */\n\t\t\tyychar = -1;\n\t\t\tgoto yynewstate;   /* try again in the same state */\n\n\t\t\t}\n\n\t\t}\n\n\t/* reduction by production yyn */\n\n#ifdef YYDEBUG\n\t\tif( yydebug ) printf(\"reduce %d\\n\",yyn);\n#endif\n\t\tyyps -= yyr2[yyn];\n\t\tyypvt = yypv;\n\t\tyypv -= yyr2[yyn];\n\t\tyyval = yypv[1];\n\t\tyym=yyn;\n\t\t\t/* consult goto table to find next state */\n\t\tyyn = yyr1[yyn];\n\t\tyyj = yypgo[yyn] + *yyps + 1;\n\t\tif( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];\n\t\tswitch(yym){\n\t\t\t\ncase 4:\n{ yyerrok; } break;\ncase 5:\n{ printf(\"store\\n\"); } break;\ncase 6:\n{ printf(\"add\\n\"); } break;\ncase 7:\n{ printf(\"negate\\nadd\\n\"); } break;\ncase 8:\n{ printf(\"multiply\\n\"); } break;\ncase 9:\n{ printf(\"divide\\n\"); } break;\ncase 10:\n{ printf(\"negate\\n\"); } break;\ncase 12:\n{ printf(\"load\\n\"); } break;\ncase 13:\n{ printf(\"push %s\\n\", yytext); } break;\ncase 14:\n{ printf(\"%s\\n\", yytext); } break;\n\t\t}\n\t\tgoto yystack;  /* stack new state and value */\n\n\t}\nint yywrap() { return 1; }\n"
  },
  {
    "path": "lcc/x86/linux/tst/8q.1bk",
    "content": "1 5 8 6 3 7 2 4 \n1 6 8 3 7 4 2 5 \n1 7 4 6 8 2 5 3 \n1 7 5 8 2 4 6 3 \n2 4 6 8 3 1 7 5 \n2 5 7 1 3 8 6 4 \n2 5 7 4 1 8 6 3 \n2 6 1 7 4 8 3 5 \n2 6 8 3 1 4 7 5 \n2 7 3 6 8 5 1 4 \n2 7 5 8 1 4 6 3 \n2 8 6 1 3 5 7 4 \n3 1 7 5 8 2 4 6 \n3 5 2 8 1 7 4 6 \n3 5 2 8 6 4 7 1 \n3 5 7 1 4 2 8 6 \n3 5 8 4 1 7 2 6 \n3 6 2 5 8 1 7 4 \n3 6 2 7 1 4 8 5 \n3 6 2 7 5 1 8 4 \n3 6 4 1 8 5 7 2 \n3 6 4 2 8 5 7 1 \n3 6 8 1 4 7 5 2 \n3 6 8 1 5 7 2 4 \n3 6 8 2 4 1 7 5 \n3 7 2 8 5 1 4 6 \n3 7 2 8 6 4 1 5 \n3 8 4 7 1 6 2 5 \n4 1 5 8 2 7 3 6 \n4 1 5 8 6 3 7 2 \n4 2 5 8 6 1 3 7 \n4 2 7 3 6 8 1 5 \n4 2 7 3 6 8 5 1 \n4 2 7 5 1 8 6 3 \n4 2 8 5 7 1 3 6 \n4 2 8 6 1 3 5 7 \n4 6 1 5 2 8 3 7 \n4 6 8 2 7 1 3 5 \n4 6 8 3 1 7 5 2 \n4 7 1 8 5 2 6 3 \n4 7 3 8 2 5 1 6 \n4 7 5 2 6 1 3 8 \n4 7 5 3 1 6 8 2 \n4 8 1 3 6 2 7 5 \n4 8 1 5 7 2 6 3 \n4 8 5 3 1 7 2 6 \n5 1 4 6 8 2 7 3 \n5 1 8 4 2 7 3 6 \n5 1 8 6 3 7 2 4 \n5 2 4 6 8 3 1 7 \n5 2 4 7 3 8 6 1 \n5 2 6 1 7 4 8 3 \n5 2 8 1 4 7 3 6 \n5 3 1 6 8 2 4 7 \n5 3 1 7 2 8 6 4 \n5 3 8 4 7 1 6 2 \n5 7 1 3 8 6 4 2 \n5 7 1 4 2 8 6 3 \n5 7 2 4 8 1 3 6 \n5 7 2 6 3 1 4 8 \n5 7 2 6 3 1 8 4 \n5 7 4 1 3 8 6 2 \n5 8 4 1 3 6 2 7 \n5 8 4 1 7 2 6 3 \n6 1 5 2 8 3 7 4 \n6 2 7 1 3 5 8 4 \n6 2 7 1 4 8 5 3 \n6 3 1 7 5 8 2 4 \n6 3 1 8 4 2 7 5 \n6 3 1 8 5 2 4 7 \n6 3 5 7 1 4 2 8 \n6 3 5 8 1 4 2 7 \n6 3 7 2 4 8 1 5 \n6 3 7 2 8 5 1 4 \n6 3 7 4 1 8 2 5 \n6 4 1 5 8 2 7 3 \n6 4 2 8 5 7 1 3 \n6 4 7 1 3 5 2 8 \n6 4 7 1 8 2 5 3 \n6 8 2 4 1 7 5 3 \n7 1 3 8 6 4 2 5 \n7 2 4 1 8 5 3 6 \n7 2 6 3 1 4 8 5 \n7 3 1 6 8 5 2 4 \n7 3 8 2 5 1 6 4 \n7 4 2 5 8 1 3 6 \n7 4 2 8 6 1 3 5 \n7 5 3 1 6 8 2 4 \n8 2 4 1 7 5 3 6 \n8 2 5 3 1 7 4 6 \n8 3 1 6 2 5 7 4 \n8 4 1 3 6 2 7 5 \n"
  },
  {
    "path": "lcc/x86/linux/tst/8q.2bk",
    "content": "tst/8q.c:30: warning: missing return value\ntst/8q.c:39: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/linux/tst/8q.sbk",
    "content": ".globl main\n.text\n.align 16\n.type main,@function\nmain:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\nmovl $0,-4(%ebp)\n.LC2:\nmovl -4(%ebp),%edi\nleal (,%edi,4),%edi\nmovl $1,down(%edi)\nmovl $1,up(%edi)\n.LC3:\nincl -4(%ebp)\ncmpl $15,-4(%ebp)\njl .LC2\nmovl $0,-4(%ebp)\n.LC6:\nmovl -4(%ebp),%edi\nmovl $1,rows(,%edi,4)\n.LC7:\nincl -4(%ebp)\ncmpl $8,-4(%ebp)\njl .LC6\npushl $0\ncall queens\naddl $4,%esp\nmovl $0,%eax\n.LC1:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf10:\n.size main,.Lf10-main\n.globl queens\n.align 16\n.type queens,@function\nqueens:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\nmovl $0,-4(%ebp)\n.LC12:\nmovl -4(%ebp),%edi\ncmpl $0,rows(,%edi,4)\nje .LC16\nmovl 20(%ebp),%esi\nmovl %edi,%ebx\nsubl %esi,%ebx\ncmpl $0,up+28(,%ebx,4)\nje .LC16\nleal (%esi,%edi),%edi\ncmpl $0,down(,%edi,4)\nje .LC16\nmovl -4(%ebp),%edi\nmovl 20(%ebp),%esi\nleal (%esi,%edi),%ebx\nmovl $0,down(,%ebx,4)\nmovl %edi,%ebx\nsubl %esi,%ebx\nmovl $0,up+28(,%ebx,4)\nmovl $0,rows(,%edi,4)\nmovl 20(%ebp),%edi\nmovl -4(%ebp),%esi\nmovl %esi,x(,%edi,4)\ncmpl $7,20(%ebp)\njne .LC20\ncall print\njmp .LC21\n.LC20:\nmovl 20(%ebp),%edi\nleal 1(%edi),%edi\npushl %edi\ncall queens\naddl $4,%esp\n.LC21:\nmovl -4(%ebp),%edi\nmovl 20(%ebp),%esi\nleal (%esi,%edi),%ebx\nmovl $1,down(,%ebx,4)\nmovl %edi,%ebx\nsubl %esi,%ebx\nmovl $1,up+28(,%ebx,4)\nmovl $1,rows(,%edi,4)\n.LC16:\n.LC13:\nincl -4(%ebp)\ncmpl $8,-4(%ebp)\njl .LC12\nmovl $0,%eax\n.LC11:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf23:\n.size queens,.Lf23-queens\n.globl print\n.align 16\n.type print,@function\nprint:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\nmovl $0,-4(%ebp)\n.LC25:\nmovl -4(%ebp),%edi\nmovl x(,%edi,4),%edi\nleal 49(%edi),%edi\npushl %edi\npushl $.LC29\ncall printf\naddl $8,%esp\n.LC26:\nincl -4(%ebp)\ncmpl $8,-4(%ebp)\njl .LC25\npushl $.LC30\ncall printf\naddl $4,%esp\nmovl $0,%eax\n.LC24:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf31:\n.size print,.Lf31-print\n.bss\n.globl x\n.align 4\n.type x,@object\n.size x,32\n.comm x,32\n.globl rows\n.align 4\n.type rows,@object\n.size rows,32\n.comm rows,32\n.globl down\n.align 4\n.type down,@object\n.size down,60\n.comm down,60\n.globl up\n.align 4\n.type up,@object\n.size up,60\n.comm up,60\n.data\n.align 1\n.LC30:\n.byte 10\n.byte 0\n.align 1\n.LC29:\n.byte 37\n.byte 99\n.byte 32\n.byte 0\n.text\n.ident \"LCC: 4.1\"\n"
  },
  {
    "path": "lcc/x86/linux/tst/array.1bk",
    "content": " 0 1 2 3 1000 1001 1002 1003 2000 2001 2002 2003\n 0 1 2 3 1000 1001 1002 1003 2000 2001 2002 2003\n 0 1 2 3 1000 1001 1002 1003 2000 2001 2002 2003\n 0 1 2 3 1000 1001 1002 1003 2000 2001 2002 2003\n"
  },
  {
    "path": "lcc/x86/linux/tst/array.2bk",
    "content": "tst/array.c:33: warning: missing return value\ntst/array.c:48: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/linux/tst/array.sbk",
    "content": ".globl main\n.text\n.align 16\n.type main,@function\nmain:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $60,%esp\nmovl $0,-8(%ebp)\n.LC2:\nmovl $0,-4(%ebp)\n.LC6:\nmovl -4(%ebp),%edi\nmovl -8(%ebp),%esi\nmovl %esi,%ebx\nsall $4,%ebx\nleal x(%ebx),%ebx\nimul $1000,%esi,%esi\nleal (%edi,%esi),%esi\nmovl %esi,(%ebx,%edi,4)\n.LC7:\nincl -4(%ebp)\ncmpl $4,-4(%ebp)\njl .LC6\nmovl -8(%ebp),%edi\nmovl %edi,%esi\nsall $4,%esi\nleal x(%esi),%esi\nmovl %esi,y(,%edi,4)\n.LC3:\nincl -8(%ebp)\ncmpl $3,-8(%ebp)\njl .LC2\ncall f\nmovl $0,-8(%ebp)\n.LC10:\nmovl -8(%ebp),%edi\nmovl %edi,%esi\nsall $4,%esi\nleal -60(%ebp),%ebx\nleal (%ebx,%esi),%esi\nmovl %esi,-12(%ebp)\nmovl %esi,y(,%edi,4)\nmovl $0,-4(%ebp)\n.LC14:\nmovl -4(%ebp),%edi\nleal (,%edi,4),%edi\nmovl -12(%ebp),%esi\nmovl -8(%ebp),%ebx\nsall $4,%ebx\nleal x(%ebx),%ebx\nmovl (%ebx,%edi),%ebx\nmovl %ebx,(%esi,%edi)\n.LC15:\nincl -4(%ebp)\ncmpl $4,-4(%ebp)\njl .LC14\n.LC11:\nincl -8(%ebp)\ncmpl $3,-8(%ebp)\njl .LC10\npushl $y\nleal -60(%ebp),%edi\npushl %edi\ncall g\naddl $8,%esp\nmovl $0,%eax\n.LC1:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf18:\n.size main,.Lf18-main\n.globl f\n.align 16\n.type f,@function\nf:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $8,%esp\nmovl $0,-8(%ebp)\n.LC20:\nmovl $0,-4(%ebp)\n.LC24:\nmovl -4(%ebp),%edi\nmovl -8(%ebp),%esi\nsall $4,%esi\nleal x(%esi),%esi\npushl (%esi,%edi,4)\npushl $.LC28\ncall printf\naddl $8,%esp\n.LC25:\nincl -4(%ebp)\ncmpl $4,-4(%ebp)\njl .LC24\n.LC21:\nincl -8(%ebp)\ncmpl $3,-8(%ebp)\njl .LC20\npushl $.LC29\ncall printf\naddl $4,%esp\nmovl $0,-8(%ebp)\n.LC30:\nmovl $0,-4(%ebp)\n.LC34:\nmovl -4(%ebp),%edi\nmovl -8(%ebp),%esi\nmovl y(,%esi,4),%esi\npushl (%esi,%edi,4)\npushl $.LC28\ncall printf\naddl $8,%esp\n.LC35:\nincl -4(%ebp)\ncmpl $4,-4(%ebp)\njl .LC34\n.LC31:\nincl -8(%ebp)\ncmpl $3,-8(%ebp)\njl .LC30\npushl $.LC29\ncall printf\naddl $4,%esp\nmovl $0,%eax\n.LC19:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf38:\n.size f,.Lf38-f\n.globl g\n.align 16\n.type g,@function\ng:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $8,%esp\nmovl $0,-8(%ebp)\n.LC40:\nmovl $0,-4(%ebp)\n.LC44:\nmovl -4(%ebp),%edi\nmovl -8(%ebp),%esi\nsall $4,%esi\nmovl 20(%ebp),%ebx\nleal (%ebx,%esi),%esi\npushl (%esi,%edi,4)\npushl $.LC28\ncall printf\naddl $8,%esp\n.LC45:\nincl -4(%ebp)\ncmpl $4,-4(%ebp)\njl .LC44\n.LC41:\nincl -8(%ebp)\ncmpl $3,-8(%ebp)\njl .LC40\npushl $.LC29\ncall printf\naddl $4,%esp\nmovl $0,-8(%ebp)\n.LC48:\nmovl $0,-4(%ebp)\n.LC52:\nmovl -4(%ebp),%edi\nmovl -8(%ebp),%esi\nmovl 24(%ebp),%ebx\nmovl (%ebx,%esi,4),%esi\npushl (%esi,%edi,4)\npushl $.LC28\ncall printf\naddl $8,%esp\n.LC53:\nincl -4(%ebp)\ncmpl $4,-4(%ebp)\njl .LC52\n.LC49:\nincl -8(%ebp)\ncmpl $3,-8(%ebp)\njl .LC48\npushl $.LC29\ncall printf\naddl $4,%esp\nmovl $0,%eax\n.LC39:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf56:\n.size g,.Lf56-g\n.bss\n.globl y\n.align 4\n.type y,@object\n.size y,12\n.comm y,12\n.globl x\n.align 4\n.type x,@object\n.size x,48\n.comm x,48\n.data\n.align 1\n.LC29:\n.byte 10\n.byte 0\n.align 1\n.LC28:\n.byte 32\n.byte 37\n.byte 100\n.byte 0\n.text\n.ident \"LCC: 4.1\"\n"
  },
  {
    "path": "lcc/x86/linux/tst/cf.1bk",
    "content": "char\tfreq\n011\t8.1\n012\t6.1\n040\t11.9\n!\t0.2\n\"\t1.5\n%\t0.6\n&\t0.4\n'\t0.4\n(\t2.9\n)\t2.9\n*\t0.8\n+\t1.3\n,\t1.3\n-\t0.4\n.\t0.6\n/\t1.0\n0\t2.5\n1\t1.9\n2\t0.6\n3\t0.2\n7\t0.4\n8\t0.2\n;\t3.8\n<\t0.8\n=\t2.7\n>\t0.2\n[\t1.5\n\\\t0.8\n]\t1.5\na\t3.1\nc\t4.4\ne\t2.3\nf\t6.0\ng\t1.3\nh\t1.0\ni\t5.0\nl\t1.0\nm\t0.2\nn\t3.3\no\t2.1\np\t1.0\nq\t0.4\nr\t4.2\ns\t0.6\nt\t3.8\nu\t1.2\nv\t0.6\nw\t0.2\n{\t0.6\n}\t0.6\n"
  },
  {
    "path": "lcc/x86/linux/tst/cf.2bk",
    "content": ""
  },
  {
    "path": "lcc/x86/linux/tst/cf.sbk",
    "content": ".globl main\n.text\n.align 16\n.type main,@function\nmain:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $24,%esp\ncmpl $1,20(%ebp)\njg .LC2\nflds .LC4\nfstps -16(%ebp)\njmp .LC3\n.LC2:\nmovl 24(%ebp),%edi\npushl 4(%edi)\ncall atof\naddl $4,%esp\nfstps -20(%ebp)\nflds -20(%ebp)\nfdivs .LC5\nfstps -16(%ebp)\n.LC3:\nmovl $0,-4(%ebp)\n.LC6:\nmovl -4(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-4(%ebp)\nflds .LC4\nfstps f(,%edi,4)\n.LC7:\ncmpl $127,-4(%ebp)\njle .LC6\nmovl $0,-8(%ebp)\njmp .LC11\n.LC10:\nmovl -12(%ebp),%edi\nleal f(,%edi,4),%edi\nflds (,%edi)\nfadds .LC13\nfstps (,%edi)\nincl -8(%ebp)\n.LC11:\ncall getchar\nmovl %eax,-12(%ebp)\ncmpl $-1,%eax\njne .LC10\npushl $.LC14\ncall printf\naddl $4,%esp\nmovl $0,-4(%ebp)\n.LC15:\nmovl -4(%ebp),%edi\nflds f(,%edi,4)\nfstps -24(%ebp)\nflds .LC4\nfcomps -24(%ebp)\nfstsw %ax\nsahf\nje .LC19\nflds -24(%ebp)\nfildl -8(%ebp)\nfdivp %st(1),%st\nflds -16(%ebp)\nfcompp\nfstsw %ax\nsahf\nja .LC19\ncmpl $32,-4(%ebp)\njg .LC21\npushl -4(%ebp)\npushl $.LC23\ncall printf\naddl $8,%esp\njmp .LC22\n.LC21:\npushl -4(%ebp)\npushl $.LC24\ncall printf\naddl $8,%esp\n.LC22:\nflds .LC5\nmovl -4(%ebp),%edi\nfmuls f(,%edi,4)\nfildl -8(%ebp)\nfdivp %st(1),%st\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC25\ncall printf\naddl $12,%esp\n.LC19:\n.LC16:\nincl -4(%ebp)\ncmpl $127,-4(%ebp)\njle .LC15\nmovl $0,%eax\n.LC1:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf26:\n.size main,.Lf26-main\n.bss\n.globl f\n.align 4\n.type f,@object\n.size f,512\n.comm f,512\n.data\n.align 1\n.LC25:\n.byte 9\n.byte 37\n.byte 46\n.byte 49\n.byte 102\n.byte 10\n.byte 0\n.align 1\n.LC24:\n.byte 37\n.byte 99\n.byte 0\n.align 1\n.LC23:\n.byte 37\n.byte 48\n.byte 51\n.byte 111\n.byte 0\n.align 1\n.LC14:\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 9\n.byte 102\n.byte 114\n.byte 101\n.byte 113\n.byte 10\n.byte 0\n.align 4\n.LC13:\n.long 1065353216\n.align 4\n.LC5:\n.long 1120403456\n.align 4\n.LC4:\n.long 0\n.text\n.ident \"LCC: 4.1\"\n"
  },
  {
    "path": "lcc/x86/linux/tst/cq.1bk",
    "content": "Section s22     returned 0.\nDecimal and octal/hex constants sometimes give\n   different results when assigned to longs.\nDecimal and octal/hex constants sometimes give\n   different results when assigned to longs.\nSection s241    returned 0.\nSection s243    returned 0.\nSection s244    returned 0.\nSection s25     returned 0.\n  8 bits in chars.\n 32 bits in ints.\n 16 bits in shorts.\n 32 bits in longs.\n 32 bits in unsigneds.\n 32 bits in floats.\n 64 bits in doubles.\n1.192093e-07 is the least number that can be added to 1. (float).\n2.220446e-16 is the least number that can be added to 1. (double).\nSection s26     returned 0.\nSection s4      returned 0.\nSection s61     returned 0.\nSection s626    returned 0.\nSection s71     returned 0.\nSection s72     returned 0.\nSection s757    returned 0.\nSection s7813   returned 0.\nSection s714    returned 0.\nSection s715    returned 0.\nRegister count for char is unreliable.\nRegister count for pointer is unreliable.\nRegister count for int is unreliable.\nSection s81     returned 0.\nSection s84     returned 0.\nchar alignment: 1\nshort alignment: 2\nint alignment: 4\nlong alignment: 4\nunsigned alignment: 4\nfloat alignment: 4\ndouble alignment: 4\nSign extension in fields\nBe especially careful with 1-bit fields!\nSection s85     returned 0.\nSection s86     returned 0.\nSection s88     returned 0.\nSection s9      returned 0.\n\nNo errors detected.\n"
  },
  {
    "path": "lcc/x86/linux/tst/cq.2bk",
    "content": "tst/cq.c:394: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:394: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:394: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:395: warning: overflow in constant `4294967296'\ntst/cq.c:395: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:395: warning: overflow in constant `040000000000'\ntst/cq.c:395: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:395: warning: overflow in constant `0x100000000'\ntst/cq.c:395: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:396: warning: overflow in constant `68719476735'\ntst/cq.c:396: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:396: warning: overflow in constant `0777777777777'\ntst/cq.c:396: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:396: warning: overflow in constant `0xfffffffff'\ntst/cq.c:396: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:397: warning: overflow in constant `68719476736'\ntst/cq.c:397: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:397: warning: overflow in constant `01000000000000'\ntst/cq.c:397: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:397: warning: overflow in constant `0x1000000000'\ntst/cq.c:397: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:533: warning: missing return value\ntst/cq.c:1169: warning: missing return value\ntst/cq.c:5294: warning: unreachable code\ntst/cq.c:5303: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/linux/tst/cq.sbk",
    "content": ".data\n.align 4\n.type sec.2,@object\nsec.2:\n.long s22\n.long s241\n.long s243\n.long s244\n.long s25\n.long s26\n.long s4\n.long s61\n.long s626\n.long s71\n.long s72\n.long s757\n.long s7813\n.long s714\n.long s715\n.long s81\n.long s84\n.long s85\n.long s86\n.long s88\n.long s9\n.bss\n.size sec.2,84\n.align 4\n.type d0.3,@object\n.size d0.3,68\n.lcomm d0.3,68\n.align 4\n.type pd0.4,@object\n.size pd0.4,4\n.lcomm pd0.4,4\n.globl main\n.text\n.align 16\n.type main,@function\nmain:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\nmovl $1,d0.3+36\nmovl $1,d0.3+40\nmovl $1,d0.3+44\nmovl $1,d0.3+48\nleal d0.3,%edi\nmovl %edi,pd0.4\nmovl $0,-4(%ebp)\njmp .LC12\n.LC9:\npushl pd0.4\nmovl -4(%ebp),%edi\ncall *sec.2(,%edi,4)\naddl $4,%esp\nmovl %eax,d0.3+52\nmovl d0.3+56,%edi\nmovl d0.3+52,%esi\nleal (%esi,%edi),%edi\nmovl %edi,d0.3+56\ncmpl $0,d0.3+36\nje .LC17\npushl d0.3+52\npushl $d0.3+60\npushl $.LC20\ncall printf\naddl $12,%esp\n.LC17:\n.LC10:\nincl -4(%ebp)\n.LC12:\nmovl -4(%ebp),%edi\ncmpl $21,%edi\njb .LC9\ncmpl $0,d0.3+56\njne .LC23\npushl $.LC26\ncall printf\naddl $4,%esp\njmp .LC24\n.LC23:\npushl $.LC27\ncall printf\naddl $4,%esp\n.LC24:\nmovl $0,%eax\n.LC1:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf28:\n.size main,.Lf28-main\n.data\n.align 1\n.type s22er.30,@object\ns22er.30:\n.byte 115\n.byte 50\n.byte 50\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size s22er.30,10\n.align 1\n.type qs22.31,@object\n.size qs22.31,8\nqs22.31:\n.byte 115\n.byte 50\n.byte 50\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s22\n.text\n.align 16\n.type s22,@function\ns22:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $32,%esp\nmovl $0,-12(%ebp)\nleal qs22.31,%edi\nmovl %edi,-4(%ebp)\nmovl 20(%ebp),%edi\nleal 60(%edi),%edi\nmovl %edi,-8(%ebp)\n.LC32:\n.LC33:\nmovl -8(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-8(%ebp)\nmovl -4(%ebp),%esi\nleal 1(%esi),%ebx\nmovl %ebx,-4(%ebp)\nmovb (,%esi),%bl\nmovb %bl,(,%edi)\nmovsbl %bl,%edi\ncmpl $0,%edi\njne .LC32\nmovl $1,-16(%ebp)\nmovl $2,-24(%ebp)\nmovl $3,-28(%ebp)\nmovl $4,-20(%ebp)\nmovl -16(%ebp),%edi\nmovl -24(%ebp),%esi\nleal (%esi,%edi),%edi\nmovl -28(%ebp),%esi\nleal (%esi,%edi),%edi\nmovl -20(%ebp),%esi\nleal (%esi,%edi),%edi\ncmpl $10,%edi\nje .LC35\nincl -12(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC37\npushl $1\npushl $s22er.30\ncall printf\naddl $8,%esp\n.LC37:\n.LC35:\nmovl $2,-32(%ebp)\nmovl -16(%ebp),%edi\ncmpl %edi,-32(%ebp)\njne .LC39\naddl $4,-12(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC41\npushl $4\npushl $s22er.30\ncall printf\naddl $8,%esp\n.LC41:\n.LC39:\nmovl -12(%ebp),%eax\n.LC29:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf43:\n.size s22,.Lf43-s22\n.data\n.align 1\n.type s241er.45,@object\ns241er.45:\n.byte 115\n.byte 50\n.byte 52\n.byte 49\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size s241er.45,11\n.align 1\n.type qs241.46,@object\n.size qs241.46,8\nqs241.46:\n.byte 115\n.byte 50\n.byte 52\n.byte 49\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.align 4\n.type g.47,@object\n.size g.47,156\ng.47:\n.long 0\n.long 0\n.long 0\n.long 0\n.long 0\n.long 0\n.long 0\n.long 0\n.long 0\n.long 0\n.long 0\n.long 0\n.long 0\n.long 0\n.long 0\n.long 0\n.long 0\n.long 0\n.long 6\n.long 0\n.long 8\n.long 0\n.long 12\n.long 0\n.long 16\n.long 0\n.long 18\n.long 0\n.long 20\n.long 0\n.long 24\n.long 0\n.long 28\n.long 0\n.long 30\n.long 0\n.long 32\n.long 0\n.long 36\n.globl s241\n.text\n.align 16\n.type s241,@function\ns241:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $488,%esp\nmovl $0,-484(%ebp)\nmovl $0,-488(%ebp)\nleal qs241.46,%edi\nmovl %edi,-476(%ebp)\nmovl 20(%ebp),%edi\nleal 60(%edi),%edi\nmovl %edi,-480(%ebp)\n.LC48:\n.LC49:\nmovl -480(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-480(%ebp)\nmovl -476(%ebp),%esi\nleal 1(%esi),%ebx\nmovl %ebx,-476(%ebp)\nmovb (,%esi),%bl\nmovb %bl,(,%edi)\nmovsbl %bl,%edi\ncmpl $0,%edi\njne .LC48\njmp .LC51\nincl -484(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC53\npushl $1\npushl $s241er.45\ncall printf\naddl $8,%esp\n.LC53:\n.LC51:\njmp .LC55\naddl $2,-484(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC57\npushl $2\npushl $s241er.45\ncall printf\naddl $8,%esp\n.LC57:\n.LC55:\njmp .LC59\naddl $4,-484(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC61\npushl $4\npushl $s241er.45\ncall printf\naddl $8,%esp\n.LC61:\n.LC59:\njmp .LC63\naddl $8,-484(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC65\npushl $8\npushl $s241er.45\ncall printf\naddl $8,%esp\n.LC65:\n.LC63:\nmovl $0,-4(%ebp)\n.LC67:\nmovl -4(%ebp),%edi\nmovl %edi,g.47(,%edi,4)\n.LC68:\nincl -4(%ebp)\ncmpl $17,-4(%ebp)\njl .LC67\nmovl $18,-4(%ebp)\n.LC71:\nmovl -4(%ebp),%edi\nleal g.47(,%edi,4),%edi\npushl (,%edi)\ncall pow2\naddl $4,%esp\nmovl %eax,(,%edi)\nmovl -4(%ebp),%edi\nleal (,%edi,4),%edi\nmovl g.47(%edi),%esi\nsubl $1,%esi\nmovl %esi,g.47-4(%edi)\naddl $2,-4(%ebp)\n.LC72:\ncmpl $39,-4(%ebp)\njl .LC71\nmovl $0,-160(%ebp)\nmovl $0,-316(%ebp)\nmovl $0,-472(%ebp)\nmovl $1,-156(%ebp)\nmovl $1,-312(%ebp)\nmovl $1,-468(%ebp)\nmovl $2,-152(%ebp)\nmovl $2,-308(%ebp)\nmovl $2,-464(%ebp)\nmovl $3,-148(%ebp)\nmovl $3,-304(%ebp)\nmovl $3,-460(%ebp)\nmovl $4,-144(%ebp)\nmovl $4,-300(%ebp)\nmovl $4,-456(%ebp)\nmovl $5,-140(%ebp)\nmovl $5,-296(%ebp)\nmovl $5,-452(%ebp)\nmovl $6,-136(%ebp)\nmovl $6,-292(%ebp)\nmovl $6,-448(%ebp)\nmovl $7,-132(%ebp)\nmovl $7,-288(%ebp)\nmovl $7,-444(%ebp)\nmovl $8,-128(%ebp)\nmovl $8,-284(%ebp)\nmovl $8,-440(%ebp)\nmovl $9,-124(%ebp)\nmovl $9,-280(%ebp)\nmovl $9,-436(%ebp)\nmovl $10,-120(%ebp)\nmovl $10,-276(%ebp)\nmovl $10,-432(%ebp)\nmovl $11,-116(%ebp)\nmovl $11,-272(%ebp)\nmovl $11,-428(%ebp)\nmovl $12,-112(%ebp)\nmovl $12,-268(%ebp)\nmovl $12,-424(%ebp)\nmovl $13,-108(%ebp)\nmovl $13,-264(%ebp)\nmovl $13,-420(%ebp)\nmovl $14,-104(%ebp)\nmovl $14,-260(%ebp)\nmovl $14,-416(%ebp)\nmovl $15,-100(%ebp)\nmovl $15,-256(%ebp)\nmovl $15,-412(%ebp)\nmovl $16,-96(%ebp)\nmovl $16,-252(%ebp)\nmovl $16,-408(%ebp)\nmovl $63,-92(%ebp)\nmovl $63,-248(%ebp)\nmovl $63,-404(%ebp)\nmovl $64,-88(%ebp)\nmovl $64,-244(%ebp)\nmovl $64,-400(%ebp)\nmovl $255,-84(%ebp)\nmovl $255,-240(%ebp)\nmovl $255,-396(%ebp)\nmovl $256,-80(%ebp)\nmovl $256,-236(%ebp)\nmovl $256,-392(%ebp)\nmovl $4095,-76(%ebp)\nmovl $4095,-232(%ebp)\nmovl $4095,-388(%ebp)\nmovl $4096,-72(%ebp)\nmovl $4096,-228(%ebp)\nmovl $4096,-384(%ebp)\nmovl $65535,-68(%ebp)\nmovl $65535,-224(%ebp)\nmovl $65535,-380(%ebp)\nmovl $65536,-64(%ebp)\nmovl $65536,-220(%ebp)\nmovl $65536,-376(%ebp)\nmovl $262143,-60(%ebp)\nmovl $262143,-216(%ebp)\nmovl $262143,-372(%ebp)\nmovl $262144,-56(%ebp)\nmovl $262144,-212(%ebp)\nmovl $262144,-368(%ebp)\nmovl $1048575,-52(%ebp)\nmovl $1048575,-208(%ebp)\nmovl $1048575,-364(%ebp)\nmovl $1048576,-48(%ebp)\nmovl $1048576,-204(%ebp)\nmovl $1048576,-360(%ebp)\nmovl $16777215,-44(%ebp)\nmovl $16777215,-200(%ebp)\nmovl $16777215,-356(%ebp)\nmovl $16777216,-40(%ebp)\nmovl $16777216,-196(%ebp)\nmovl $16777216,-352(%ebp)\nmovl $268435455,-36(%ebp)\nmovl $268435455,-192(%ebp)\nmovl $268435455,-348(%ebp)\nmovl $268435456,-32(%ebp)\nmovl $268435456,-188(%ebp)\nmovl $268435456,-344(%ebp)\nmovl $1073741823,-28(%ebp)\nmovl $1073741823,-184(%ebp)\nmovl $1073741823,-340(%ebp)\nmovl $1073741824,-24(%ebp)\nmovl $1073741824,-180(%ebp)\nmovl $1073741824,-336(%ebp)\nmovl $0xffffffff,%edi\nmovl %edi,-20(%ebp)\nmovl $0xffffffff,%edi\nmovl %edi,-176(%ebp)\nmovl $0xffffffff,%edi\nmovl %edi,-332(%ebp)\nmovl $0xffffffff,%edi\nmovl %edi,-16(%ebp)\nmovl $0xffffffff,%edi\nmovl %edi,-172(%ebp)\nmovl $0xffffffff,%edi\nmovl %edi,-328(%ebp)\nmovl $0xffffffff,%edi\nmovl %edi,-12(%ebp)\nmovl $0xffffffff,%edi\nmovl %edi,-168(%ebp)\nmovl $0xffffffff,%edi\nmovl %edi,-324(%ebp)\nmovl $0xffffffff,%edi\nmovl %edi,-8(%ebp)\nmovl $0xffffffff,%edi\nmovl %edi,-164(%ebp)\nmovl $0xffffffff,%edi\nmovl %edi,-320(%ebp)\nmovl $0,-4(%ebp)\n.LC190:\nmovl -4(%ebp),%edi\nleal (,%edi,4),%edi\nleal -160(%ebp),%esi\nmovl (%esi,%edi),%esi\ncmpl %esi,g.47(%edi)\njne .LC197\nleal -316(%ebp),%ebx\nmovl (%ebx,%edi),%ebx\ncmpl %ebx,%esi\njne .LC197\nleal -472(%ebp),%esi\ncmpl (%esi,%edi),%ebx\nje .LC194\n.LC197:\nmovl 20(%ebp),%edi\ncmpl $0,40(%edi)\nje .LC198\npushl $.LC200\ncall printf\naddl $4,%esp\npushl $.LC201\ncall printf\naddl $4,%esp\n.LC198:\n.LC194:\n.LC191:\nincl -4(%ebp)\ncmpl $39,-4(%ebp)\njl .LC190\ncmpl $0,-488(%ebp)\nje .LC202\nmovl $16,-484(%ebp)\n.LC202:\nmovl -484(%ebp),%eax\n.LC44:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf204:\n.size s241,.Lf204-s241\n.globl pow2\n.align 16\n.type pow2,@function\npow2:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\nmovl $1,-4(%ebp)\njmp .LC207\n.LC206:\nsall $1,-4(%ebp)\n.LC207:\nmovl 20(%ebp),%edi\nmovl %edi,%esi\nsubl $1,%esi\nmovl %esi,20(%ebp)\ncmpl $0,%edi\njne .LC206\nmovl -4(%ebp),%eax\n.LC205:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf209:\n.size pow2,.Lf209-pow2\n.data\n.align 1\n.type s243er.211,@object\ns243er.211:\n.byte 115\n.byte 50\n.byte 52\n.byte 51\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size s243er.211,11\n.align 1\n.type qs243.212,@object\n.size qs243.212,8\nqs243.212:\n.byte 115\n.byte 50\n.byte 52\n.byte 51\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s243\n.text\n.align 16\n.type s243,@function\ns243:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $268,%esp\nmovl $0,-268(%ebp)\nleal qs243.212,%edi\nmovl %edi,-260(%ebp)\nmovl 20(%ebp),%edi\nleal 60(%edi),%edi\nmovl %edi,-264(%ebp)\n.LC213:\n.LC214:\nmovl -264(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-264(%ebp)\nmovl -260(%ebp),%esi\nleal 1(%esi),%ebx\nmovl %ebx,-260(%ebp)\nmovb (,%esi),%bl\nmovb %bl,(,%edi)\nmovsbl %bl,%edi\ncmpl $0,%edi\njne .LC213\nleal -256(%ebp),%edi\npushl %edi\ncall zerofill\naddl $4,%esp\nmovb $1,-159(%ebp)\nmovb $1,-191(%ebp)\nmovb $1,-130(%ebp)\nmovb $1,-208(%ebp)\nmovb $1,-158(%ebp)\nmovb $1,-190(%ebp)\nmovb $1,-223(%ebp)\nmovb $1,-207(%ebp)\nmovb $1,-157(%ebp)\nmovb $1,-189(%ebp)\nmovb $1,-222(%ebp)\nmovb $1,-206(%ebp)\nmovb $1,-156(%ebp)\nmovb $1,-188(%ebp)\nmovb $1,-221(%ebp)\nmovb $1,-205(%ebp)\nmovb $1,-155(%ebp)\nmovb $1,-187(%ebp)\nmovb $1,-219(%ebp)\nmovb $1,-204(%ebp)\nmovb $1,-154(%ebp)\nmovb $1,-186(%ebp)\nmovb $1,-218(%ebp)\nmovb $1,-203(%ebp)\nmovb $1,-153(%ebp)\nmovb $1,-185(%ebp)\nmovb $1,-216(%ebp)\nmovb $1,-202(%ebp)\nmovb $1,-152(%ebp)\nmovb $1,-184(%ebp)\nmovb $1,-215(%ebp)\nmovb $1,-201(%ebp)\nmovb $1,-151(%ebp)\nmovb $1,-183(%ebp)\nmovb $1,-161(%ebp)\nmovb $1,-200(%ebp)\nmovb $1,-150(%ebp)\nmovb $1,-182(%ebp)\nmovb $1,-195(%ebp)\nmovb $1,-199(%ebp)\nmovb $1,-149(%ebp)\nmovb $1,-181(%ebp)\nmovb $1,-211(%ebp)\nmovb $1,-148(%ebp)\nmovb $1,-180(%ebp)\nmovb $1,-162(%ebp)\nmovb $1,-147(%ebp)\nmovb $1,-179(%ebp)\nmovb $1,-132(%ebp)\nmovb $1,-246(%ebp)\nmovb $1,-146(%ebp)\nmovb $1,-178(%ebp)\nmovb $1,-247(%ebp)\nmovb $1,-145(%ebp)\nmovb $1,-177(%ebp)\nmovb $1,-133(%ebp)\nmovb $1,-248(%ebp)\nmovb $1,-144(%ebp)\nmovb $1,-176(%ebp)\nmovb $1,-131(%ebp)\nmovb $1,-243(%ebp)\nmovb $1,-143(%ebp)\nmovb $1,-175(%ebp)\nmovb $1,-165(%ebp)\nmovb $1,-244(%ebp)\nmovb $1,-142(%ebp)\nmovb $1,-174(%ebp)\nmovb $1,-163(%ebp)\nmovb $1,-141(%ebp)\nmovb $1,-173(%ebp)\nmovb $1,-213(%ebp)\nmovb $1,-164(%ebp)\nmovb $1,-140(%ebp)\nmovb $1,-172(%ebp)\nmovb $1,-197(%ebp)\nmovb $1,-217(%ebp)\nmovb $1,-139(%ebp)\nmovb $1,-171(%ebp)\nmovb $1,-214(%ebp)\nmovb $1,-138(%ebp)\nmovb $1,-170(%ebp)\nmovb $1,-198(%ebp)\nmovb $1,-256(%ebp)\nmovb $1,-137(%ebp)\nmovb $1,-169(%ebp)\nmovb $1,-196(%ebp)\nmovb $1,-224(%ebp)\nmovb $1,-136(%ebp)\nmovb $1,-168(%ebp)\nmovb $1,-194(%ebp)\nmovb $1,-135(%ebp)\nmovb $1,-167(%ebp)\nmovb $1,-212(%ebp)\nmovb $1,-134(%ebp)\nmovb $1,-166(%ebp)\nmovb $1,-210(%ebp)\nmovb $1,-193(%ebp)\nmovb $1,-209(%ebp)\nleal -256(%ebp),%edi\npushl %edi\ncall sumof\naddl $4,%esp\ncmpl $98,%eax\nje .LC313\nincl -268(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC315\npushl $1\npushl $s243er.211\ncall printf\naddl $8,%esp\n.LC315:\n.LC313:\njmp .LC317\naddl $8,-268(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC319\npushl $8\npushl $s243er.211\ncall printf\naddl $8,%esp\n.LC319:\n.LC317:\nmovl -268(%ebp),%eax\n.LC210:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf321:\n.size s243,.Lf321-s243\n.globl zerofill\n.align 16\n.type zerofill,@function\nzerofill:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\nmovl $0,-4(%ebp)\n.LC323:\nmovl 20(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,20(%ebp)\nmovb $0,(,%edi)\n.LC324:\nincl -4(%ebp)\ncmpl $256,-4(%ebp)\njl .LC323\nmovl $0,%eax\n.LC322:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf327:\n.size zerofill,.Lf327-zerofill\n.globl sumof\n.align 16\n.type sumof,@function\nsumof:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $12,%esp\nmovl 20(%ebp),%edi\nmovl %edi,-12(%ebp)\nmovl $0,-4(%ebp)\nmovl $0,-8(%ebp)\n.LC329:\nmovl -12(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-12(%ebp)\nmovsbl (,%edi),%edi\naddl %edi,-4(%ebp)\n.LC330:\nincl -8(%ebp)\ncmpl $256,-8(%ebp)\njl .LC329\nmovl -4(%ebp),%eax\n.LC328:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf333:\n.size sumof,.Lf333-sumof\n.data\n.align 1\n.type s244er.335,@object\ns244er.335:\n.byte 115\n.byte 50\n.byte 52\n.byte 52\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size s244er.335,11\n.align 1\n.type qs244.336,@object\n.size qs244.336,8\nqs244.336:\n.byte 115\n.byte 50\n.byte 52\n.byte 52\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s244\n.text\n.align 16\n.type s244,@function\ns244:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $92,%esp\nleal qs244.336,%edi\nmovl %edi,-72(%ebp)\nmovl 20(%ebp),%edi\nleal 60(%edi),%edi\nmovl %edi,-76(%ebp)\n.LC337:\n.LC338:\nmovl -76(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-76(%ebp)\nmovl -72(%ebp),%esi\nleal 1(%esi),%ebx\nmovl %ebx,-72(%ebp)\nmovb (,%esi),%bl\nmovb %bl,(,%edi)\nmovsbl %bl,%edi\ncmpl $0,%edi\njne .LC337\nmovl $0,-84(%ebp)\nmovl $0,-80(%ebp)\nfldl .LC340\nfstpl -68(%ebp)\nfldl .LC340\nfstpl -60(%ebp)\nfldl .LC340\nfstpl -52(%ebp)\nfldl .LC340\nfstpl -44(%ebp)\nfldl .LC340\nfstpl -36(%ebp)\nfldl .LC340\nfstpl -28(%ebp)\nfldl .LC340\nfstpl -20(%ebp)\nfldl .LC340\nfstpl -12(%ebp)\nmovl $0,-80(%ebp)\nmovl $0,-4(%ebp)\n.LC348:\nmovl -4(%ebp),%edi\nleal (,%edi,8),%edi\nleal -68(%ebp),%esi\nleal -60(%ebp),%ebx\nfldl (%ebx,%edi)\nfcompl (%esi,%edi)\nfstsw %ax\nsahf\nje .LC352\nmovl $1,-80(%ebp)\n.LC352:\n.LC349:\nincl -4(%ebp)\ncmpl $7,-4(%ebp)\njl .LC348\ncmpl $0,-80(%ebp)\nje .LC355\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC357\npushl $1\npushl $s244er.335\ncall printf\naddl $8,%esp\n.LC357:\nincl -84(%ebp)\n.LC355:\njmp .LC359\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC361\npushl $2\npushl $s244er.335\ncall printf\naddl $8,%esp\n.LC361:\naddl $2,-84(%ebp)\n.LC359:\nmovl -84(%ebp),%eax\n.LC334:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf363:\n.size s244,.Lf363-s244\n.data\n.align 1\n.type s25er.365,@object\ns25er.365:\n.byte 115\n.byte 50\n.byte 53\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size s25er.365,10\n.align 1\n.type qs25.366,@object\n.size qs25.366,8\nqs25.366:\n.byte 115\n.byte 50\n.byte 53\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s25\n.text\n.align 16\n.type s25,@function\ns25:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $28,%esp\nleal qs25.366,%edi\nmovl %edi,-16(%ebp)\nmovl 20(%ebp),%edi\nleal 60(%edi),%edi\nmovl %edi,-20(%ebp)\n.LC367:\n.LC368:\nmovl -20(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-20(%ebp)\nmovl -16(%ebp),%esi\nleal 1(%esi),%ebx\nmovl %ebx,-16(%ebp)\nmovb (,%esi),%bl\nmovb %bl,(,%edi)\nmovsbl %bl,%edi\ncmpl $0,%edi\njne .LC367\nmovl $0,-24(%ebp)\nleal .LC370,%edi\nmovl %edi,-8(%ebp)\nmovl -8(%ebp),%edi\nmovsbl 1(%edi),%esi\nmovsbl (,%edi),%ebx\ncmpl %esi,%ebx\njne .LC374\nmovsbl 2(%edi),%edi\ncmpl %edi,%esi\njne .LC374\ncmpl $46,%edi\nje .LC371\n.LC374:\nincl -24(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC375\npushl $1\npushl $s25er.365\ncall printf\naddl $8,%esp\n.LC375:\n.LC371:\nmovl -8(%ebp),%edi\nmovsbl 3(%edi),%edi\ncmpl $0,%edi\nje .LC377\naddl $4,-24(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC379\npushl $4\npushl $s25er.365\ncall printf\naddl $8,%esp\n.LC379:\n.LC377:\nmovsbl .LC383+1,%edi\ncmpl $34,%edi\nje .LC381\naddl $8,-24(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC385\npushl $8\npushl $s25er.365\ncall printf\naddl $8,%esp\n.LC385:\n.LC381:\nleal .LC387,%edi\nmovl %edi,-8(%ebp)\nmovl -8(%ebp),%edi\nmovsbl (,%edi),%esi\ncmpl $10,%esi\njne .LC395\nmovsbl 1(%edi),%esi\ncmpl $9,%esi\njne .LC395\nmovsbl 2(%edi),%esi\ncmpl $8,%esi\njne .LC395\nmovsbl 3(%edi),%esi\ncmpl $13,%esi\njne .LC395\nmovsbl 4(%edi),%esi\ncmpl $12,%esi\njne .LC395\nmovsbl 5(%edi),%esi\ncmpl $92,%esi\njne .LC395\nmovsbl 6(%edi),%edi\ncmpl $39,%edi\nje .LC388\n.LC395:\naddl $16,-24(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC396\npushl $16\npushl $s25er.365\ncall printf\naddl $8,%esp\n.LC396:\n.LC388:\nleal .LC398,%edi\nmovl %edi,-12(%ebp)\nmovl %edi,-8(%ebp)\nmovl $0,-28(%ebp)\nmovl $0,-4(%ebp)\njmp .LC402\n.LC399:\nmovl -4(%ebp),%edi\nmovl -8(%ebp),%esi\nmovsbl (%esi,%edi),%esi\nmovl -12(%ebp),%ebx\nmovsbl (%ebx,%edi),%edi\ncmpl %edi,%esi\nje .LC403\nmovl $1,-28(%ebp)\n.LC403:\n.LC400:\nincl -4(%ebp)\n.LC402:\nmovl -4(%ebp),%edi\ncmpl $7,%edi\njb .LC399\ncmpl $0,-28(%ebp)\nje .LC405\naddl $32,-24(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC407\npushl $32\npushl $s25er.365\ncall printf\naddl $8,%esp\n.LC407:\n.LC405:\nmovl -24(%ebp),%eax\n.LC364:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf409:\n.size s25,.Lf409-s25\n.data\n.align 1\n.type qs26.411,@object\n.size qs26.411,8\nqs26.411:\n.byte 115\n.byte 50\n.byte 54\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.align 1\n.type s.412,@object\ns.412:\n.byte 37\n.byte 51\n.byte 100\n.byte 32\n.byte 98\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 37\n.byte 115\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.size s.412,18\n.align 1\n.type s2.413,@object\ns2.413:\n.byte 37\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 108\n.byte 101\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 97\n.byte 100\n.byte 100\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 49\n.byte 46\n.byte 32\n.byte 40\n.byte 37\n.byte 115\n.byte 41\n.byte 46\n.byte 10\n.byte 0\n.size s2.413,54\n.globl s26\n.text\n.align 16\n.type s26,@function\ns26:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $56,%esp\nleal qs26.411,%edi\nmovl %edi,-36(%ebp)\nmovl 20(%ebp),%edi\nleal 60(%edi),%edi\nmovl %edi,-40(%ebp)\n.LC414:\n.LC415:\nmovl -40(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-40(%ebp)\nmovl -36(%ebp),%esi\nleal 1(%esi),%ebx\nmovl %ebx,-36(%ebp)\nmovb (,%esi),%bl\nmovb %bl,(,%edi)\nmovsbl %bl,%edi\ncmpl $0,%edi\njne .LC414\nmovl 20(%ebp),%edi\nmovl $0,(,%edi)\nmovb $0,-41(%ebp)\nmovb $1,-5(%ebp)\njmp .LC418\n.LC417:\nmovsbl -5(%ebp),%edi\nleal (,%edi,2),%edi\nmovl %edi,%ebx\nmovb %bl,-5(%ebp)\nmovl 20(%ebp),%edi\nincl (,%edi)\n.LC418:\nmovsbl -41(%ebp),%edi\nmovsbl -5(%ebp),%esi\ncmpl %esi,%edi\njne .LC417\nmovl 20(%ebp),%edi\nmovl (,%edi),%esi\nleal (,%esi,4),%esi\nmovl %esi,4(%edi)\nmovl 20(%ebp),%edi\nmovl (,%edi),%esi\nleal (,%esi,2),%esi\nmovl %esi,8(%edi)\nmovl 20(%ebp),%edi\nmovl (,%edi),%esi\nleal (,%esi,4),%esi\nmovl %esi,12(%edi)\nmovl 20(%ebp),%edi\nmovl (,%edi),%esi\nleal (,%esi,4),%esi\nmovl %esi,16(%edi)\nmovl 20(%ebp),%edi\nmovl (,%edi),%esi\nleal (,%esi,4),%esi\nmovl %esi,20(%edi)\nmovl 20(%ebp),%edi\nmovl (,%edi),%esi\nleal (,%esi,8),%esi\nmovl %esi,24(%edi)\nflds .LC420\nfstps -16(%ebp)\nflds .LC420\nfstps -4(%ebp)\nflds .LC421\nfstps -12(%ebp)\njmp .LC423\n.LC422:\nflds -16(%ebp)\nfadds -4(%ebp)\nfstps -12(%ebp)\nflds -4(%ebp)\nfdivl .LC425\nfstps -4(%ebp)\n.LC423:\nflds -16(%ebp)\nfcomps -12(%ebp)\nfstsw %ax\nsahf\njne .LC422\nmovl 20(%ebp),%edi\nfldl .LC426\nfmuls -4(%ebp)\nfstps 28(%edi)\nfldl .LC427\nfstpl -32(%ebp)\nflds .LC420\nfstps -4(%ebp)\nfldl .LC428\nfstpl -24(%ebp)\njmp .LC430\n.LC429:\nflds -4(%ebp)\nfstpl -56(%ebp)\nfldl -32(%ebp)\nfaddl -56(%ebp)\nfstpl -24(%ebp)\nfldl -56(%ebp)\nfdivl .LC425\nfstps -4(%ebp)\n.LC430:\nfldl -32(%ebp)\nfcompl -24(%ebp)\nfstsw %ax\nsahf\njne .LC429\nmovl 20(%ebp),%edi\nfldl .LC426\nfmuls -4(%ebp)\nfstps 32(%edi)\nmovl 20(%ebp),%edi\ncmpl $0,40(%edi)\nje .LC432\npushl $.LC434\nmovl 20(%ebp),%edi\npushl (,%edi)\npushl $s.412\ncall printf\naddl $12,%esp\npushl $.LC435\nmovl 20(%ebp),%edi\npushl 4(%edi)\npushl $s.412\ncall printf\naddl $12,%esp\npushl $.LC436\nmovl 20(%ebp),%edi\npushl 8(%edi)\npushl $s.412\ncall printf\naddl $12,%esp\npushl $.LC437\nmovl 20(%ebp),%edi\npushl 12(%edi)\npushl $s.412\ncall printf\naddl $12,%esp\npushl $.LC438\nmovl 20(%ebp),%edi\npushl 16(%edi)\npushl $s.412\ncall printf\naddl $12,%esp\npushl $.LC439\nmovl 20(%ebp),%edi\npushl 20(%edi)\npushl $s.412\ncall printf\naddl $12,%esp\npushl $.LC440\nmovl 20(%ebp),%edi\npushl 24(%edi)\npushl $s.412\ncall printf\naddl $12,%esp\npushl $.LC439\nmovl 20(%ebp),%edi\nflds 28(%edi)\nsubl $8,%esp\nfstpl (%esp)\npushl $s2.413\ncall printf\naddl $16,%esp\npushl $.LC440\nmovl 20(%ebp),%edi\nflds 32(%edi)\nsubl $8,%esp\nfstpl (%esp)\npushl $s2.413\ncall printf\naddl $16,%esp\n.LC432:\nmovl $0,%eax\n.LC410:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf441:\n.size s26,.Lf441-s26\n.data\n.align 1\n.type s4er.443,@object\ns4er.443:\n.byte 115\n.byte 52\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size s4er.443,9\n.align 1\n.type qs4.444,@object\n.size qs4.444,8\nqs4.444:\n.byte 115\n.byte 52\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s4\n.text\n.align 16\n.type s4,@function\ns4:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $36,%esp\nmovl $0,-24(%ebp)\nleal qs4.444,%edi\nmovl %edi,-16(%ebp)\nmovl 20(%ebp),%edi\nleal 60(%edi),%edi\nmovl %edi,-20(%ebp)\n.LC445:\n.LC446:\nmovl -20(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-20(%ebp)\nmovl -16(%ebp),%esi\nleal 1(%esi),%ebx\nmovl %ebx,-16(%ebp)\nmovb (,%esi),%bl\nmovb %bl,(,%edi)\nmovsbl %bl,%edi\ncmpl $0,%edi\njne .LC445\nmovl $0,-4(%ebp)\n.LC448:\npushl -4(%ebp)\ncall svtest\naddl $4,%esp\nmovl %eax,%edi\ncall zero\ncmpl %eax,%edi\nje .LC452\nmovl $1,-24(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC454\npushl $1\npushl $s4er.443\ncall printf\naddl $8,%esp\n.LC454:\n.LC452:\n.LC449:\nincl -4(%ebp)\ncmpl $3,-4(%ebp)\njl .LC448\ncall setev\ncall testev\ncmpl $0,%eax\nje .LC456\naddl $2,-24(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC458\npushl $2\npushl $s4er.443\ncall printf\naddl $8,%esp\n.LC458:\n.LC456:\njmp .LC460\naddl $4,-24(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC462\npushl $4\npushl $s4er.443\ncall printf\naddl $8,%esp\n.LC462:\n.LC460:\nmovl $0xffffffff,-8(%ebp)\nmovl $1,-12(%ebp)\nmovl $0,-4(%ebp)\njmp .LC467\n.LC464:\nmovl -8(%ebp),%edi\nandl %edi,-12(%ebp)\nshrl $1,%edi\nmovl %edi,-8(%ebp)\n.LC465:\nincl -4(%ebp)\n.LC467:\nmovl -4(%ebp),%edi\nmovl 20(%ebp),%esi\nmovl (,%esi),%esi\nleal (,%esi,4),%esi\ncmpl %esi,%edi\njb .LC464\nmovl -12(%ebp),%edi\ncmpl $1,%edi\njne .LC470\nmovl -8(%ebp),%edi\ncmpl $0,%edi\nje .LC468\n.LC470:\naddl $8,-24(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC471\npushl $8\npushl $s4er.443\ncall printf\naddl $8,%esp\n.LC471:\n.LC468:\nmovl -24(%ebp),%eax\n.LC442:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf473:\n.size s4,.Lf473-s4\n.bss\n.align 4\n.type k.475,@object\n.size k.475,4\n.lcomm k.475,4\n.globl svtest\n.text\n.align 16\n.type svtest,@function\nsvtest:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\nmovl 20(%ebp),%edi\ncmpl $0,%edi\nje .LC478\ncmpl $1,%edi\nje .LC479\ncmpl $2,%edi\nje .LC482\njmp .LC476\n.LC478:\nmovl $1978,k.475\nmovl $0,-4(%ebp)\njmp .LC477\n.LC479:\ncmpl $1978,k.475\nje .LC480\nmovl $1,-4(%ebp)\njmp .LC477\n.LC480:\nmovl $1929,k.475\nmovl $0,-4(%ebp)\njmp .LC477\n.LC482:\ncmpl $1929,k.475\nje .LC483\nmovl $1,-4(%ebp)\njmp .LC477\n.LC483:\nmovl $0,-4(%ebp)\n.LC476:\n.LC477:\nmovl -4(%ebp),%eax\n.LC474:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf485:\n.size svtest,.Lf485-svtest\n.bss\n.align 4\n.type k.487,@object\n.size k.487,4\n.lcomm k.487,4\n.globl zero\n.text\n.align 16\n.type zero,@function\nzero:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\nmovl $2,k.487\nmovl $0,-4(%ebp)\nmovl -4(%ebp),%eax\n.LC486:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf488:\n.size zero,.Lf488-zero\n.globl testev\n.align 16\n.type testev,@function\ntestev:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\ncmpl $1066,extvar\nje .LC490\nmovl $1,%eax\njmp .LC489\n.LC490:\nmovl $0,%eax\n.LC489:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf492:\n.size testev,.Lf492-testev\n.data\n.align 1\n.type s61er.494,@object\ns61er.494:\n.byte 115\n.byte 54\n.byte 49\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size s61er.494,10\n.align 1\n.type qs61.495,@object\n.size qs61.495,8\nqs61.495:\n.byte 115\n.byte 54\n.byte 49\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.align 1\n.type upper_alpha.496,@object\nupper_alpha.496:\n.byte 65\n.byte 66\n.byte 67\n.byte 68\n.byte 69\n.byte 70\n.byte 71\n.byte 72\n.byte 73\n.byte 74\n.byte 75\n.byte 76\n.byte 77\n.byte 78\n.byte 79\n.byte 80\n.byte 81\n.byte 82\n.byte 83\n.byte 84\n.byte 85\n.byte 86\n.byte 87\n.byte 88\n.byte 89\n.byte 90\n.byte 0\n.size upper_alpha.496,27\n.align 1\n.type lower_alpha.497,@object\nlower_alpha.497:\n.byte 97\n.byte 98\n.byte 99\n.byte 100\n.byte 101\n.byte 102\n.byte 103\n.byte 104\n.byte 105\n.byte 106\n.byte 107\n.byte 108\n.byte 109\n.byte 110\n.byte 111\n.byte 112\n.byte 113\n.byte 114\n.byte 115\n.byte 116\n.byte 117\n.byte 118\n.byte 119\n.byte 120\n.byte 121\n.byte 122\n.byte 0\n.size lower_alpha.497,27\n.align 1\n.type numbers.498,@object\nnumbers.498:\n.byte 48\n.byte 49\n.byte 50\n.byte 51\n.byte 52\n.byte 53\n.byte 54\n.byte 55\n.byte 56\n.byte 57\n.byte 0\n.size numbers.498,11\n.align 1\n.type special_characters.499,@object\nspecial_characters.499:\n.byte 126\n.byte 33\n.byte 34\n.byte 35\n.byte 37\n.byte 38\n.byte 40\n.byte 41\n.byte 95\n.byte 61\n.byte 45\n.byte 94\n.byte 124\n.byte 123\n.byte 125\n.byte 91\n.byte 93\n.byte 43\n.byte 59\n.byte 42\n.byte 58\n.byte 60\n.byte 62\n.byte 44\n.byte 46\n.byte 63\n.byte 47\n.byte 0\n.size special_characters.499,28\n.align 1\n.type extra_special_characters.500,@object\nextra_special_characters.500:\n.byte 10\n.byte 9\n.byte 8\n.byte 13\n.byte 12\n.byte 92\n.byte 39\n.byte 0\n.size extra_special_characters.500,8\n.align 1\n.type blank_and_NUL.501,@object\nblank_and_NUL.501:\n.byte 32\n.byte 0\n.byte 0\n.size blank_and_NUL.501,3\n.globl s61\n.text\n.align 16\n.type s61,@function\ns61:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $60,%esp\nleal qs61.495,%edi\nmovl %edi,-36(%ebp)\nmovl 20(%ebp),%edi\nleal 60(%edi),%edi\nmovl %edi,-40(%ebp)\nmovl $0,-48(%ebp)\n.LC502:\n.LC503:\nmovl -40(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-40(%ebp)\nmovl -36(%ebp),%esi\nleal 1(%esi),%ebx\nmovl %ebx,-36(%ebp)\nmovb (,%esi),%bl\nmovb %bl,(,%edi)\nmovsbl %bl,%edi\ncmpl $0,%edi\njne .LC502\nmovw $-19,-54(%ebp)\nmovswl -54(%ebp),%edi\nmovl %edi,-60(%ebp)\ncmpl $-19,-60(%ebp)\nje .LC505\nincl -48(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC507\npushl $1\npushl $s61er.494\ncall printf\naddl $8,%esp\n.LC507:\n.LC505:\nleal upper_alpha.496,%edi\nmovl %edi,-28(%ebp)\nleal lower_alpha.497,%edi\nmovl %edi,-24(%ebp)\nleal numbers.498,%edi\nmovl %edi,-20(%ebp)\nleal special_characters.499,%edi\nmovl %edi,-16(%ebp)\nleal extra_special_characters.500,%edi\nmovl %edi,-12(%ebp)\nleal blank_and_NUL.501,%edi\nmovl %edi,-8(%ebp)\nmovl $0,-32(%ebp)\nmovl $0,-4(%ebp)\njmp .LC519\n.LC518:\nmovl -4(%ebp),%edi\nleal -28(%ebp),%esi\nleal (%esi,%edi,4),%edi\nmovl (,%edi),%esi\nleal 1(%esi),%ebx\nmovl %ebx,(,%edi)\nmovsbl (,%esi),%edi\ncmpl $0,%edi\njge .LC521\nmovl $1,-32(%ebp)\n.LC521:\n.LC519:\nmovl -4(%ebp),%edi\nleal -28(%ebp),%esi\nmovl (%esi,%edi,4),%edi\nmovsbl (,%edi),%edi\ncmpl $0,%edi\njne .LC518\n.LC515:\nincl -4(%ebp)\ncmpl $6,-4(%ebp)\njl .LC519\ncmpl $0,-32(%ebp)\nje .LC523\naddl $2,-48(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC525\npushl $2\npushl $s61er.494\ncall printf\naddl $8,%esp\n.LC525:\n.LC523:\nmovl $1048579,-44(%ebp)\nmovl -44(%ebp),%edi\nmovl %edi,%esi\nmovw %si,-50(%ebp)\nmovl %edi,%ebx\nmovb %bl,-51(%ebp)\nmovswl -50(%ebp),%edi\ncmpl -44(%ebp),%edi\nje .LC530\ncmpl $3,%edi\njne .LC529\n.LC530:\nmovsbl -51(%ebp),%edi\ncmpl -44(%ebp),%edi\nje .LC527\ncmpl $3,%edi\nje .LC527\n.LC529:\naddl $8,-48(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC531\npushl $8\npushl $s61er.494\ncall printf\naddl $8,%esp\n.LC531:\n.LC527:\nmovl -48(%ebp),%eax\n.LC493:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf533:\n.size s61,.Lf533-s61\n.data\n.align 1\n.type s626er.535,@object\ns626er.535:\n.byte 115\n.byte 54\n.byte 50\n.byte 54\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size s626er.535,11\n.align 1\n.type qs626.536,@object\n.size qs626.536,8\nqs626.536:\n.byte 115\n.byte 54\n.byte 50\n.byte 54\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s626\n.text\n.align 16\n.type s626,@function\ns626:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $128,%esp\nleal qs626.536,%edi\nmovl %edi,-56(%ebp)\nmovl 20(%ebp),%edi\nleal 60(%edi),%edi\nmovl %edi,-60(%ebp)\nmovl $0,-104(%ebp)\n.LC537:\n.LC538:\nmovl -60(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-60(%ebp)\nmovl -56(%ebp),%esi\nleal 1(%esi),%ebx\nmovl %ebx,-56(%ebp)\nmovb (,%esi),%bl\nmovb %bl,(,%edi)\nmovsbl %bl,%edi\ncmpl $0,%edi\njne .LC537\nflds .LC420\nfstps -36(%ebp)\nmovl $1,-64(%ebp)\nmovl $1,-40(%ebp)\nmovl $0,-4(%ebp)\njmp .LC543\n.LC540:\nflds .LC544\nfmuls -36(%ebp)\nfstps -36(%ebp)\nmovl -40(%ebp),%edi\nleal (,%edi,2),%edi\norl -64(%ebp),%edi\nmovl %edi,-40(%ebp)\n.LC541:\nincl -4(%ebp)\n.LC543:\nmovl 20(%ebp),%edi\nmovl 12(%edi),%edi\nsubl $2,%edi\ncmpl %edi,-4(%ebp)\njl .LC540\nfildl -40(%ebp)\nfstps -112(%ebp)\nflds -36(%ebp)\nfsubs -112(%ebp)\nfdivs -36(%ebp)\nfstps -36(%ebp)\nfldl .LC425\nmovl 20(%ebp),%edi\nfmuls 28(%edi)\nfcomps -36(%ebp)\nfstsw %ax\nsahf\njae .LC545\naddl $2,-104(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC547\npushl $2\npushl $s626er.535\ncall printf\naddl $8,%esp\n.LC547:\n.LC545:\nmovb $125,-73(%ebp)\nmovw $125,-76(%ebp)\nmovl $125,-80(%ebp)\nmovl $15625,-96(%ebp)\nmovl $125,-84(%ebp)\nmovl $15625,-100(%ebp)\nmovl $125,-68(%ebp)\nmovl $15625,-108(%ebp)\nflds .LC549\nfstps -72(%ebp)\nfldl .LC550\nfstpl -92(%ebp)\nfldl .LC551\nfstpl -52(%ebp)\nmovl $0,-4(%ebp)\n.LC552:\nmovl -4(%ebp),%edi\nleal -32(%ebp),%esi\nmovb $0,(%esi,%edi)\n.LC553:\nincl -4(%ebp)\ncmpl $28,-4(%ebp)\njl .LC552\nmovsbl -73(%ebp),%edi\nmovl %edi,%esi\nimull %edi,%esi\ncmpl -96(%ebp),%esi\nje .LC556\nmovb $1,-32(%ebp)\n.LC556:\nmovswl -76(%ebp),%edi\nmovsbl -73(%ebp),%esi\nimull %esi,%edi\ncmpl -96(%ebp),%edi\nje .LC558\nmovb $1,-31(%ebp)\n.LC558:\nmovswl -76(%ebp),%edi\nmovl %edi,%esi\nimull %edi,%esi\ncmpl -96(%ebp),%esi\nje .LC561\nmovb $1,-30(%ebp)\n.LC561:\nmovl -80(%ebp),%edi\nmovsbl -73(%ebp),%esi\nimull %esi,%edi\ncmpl -96(%ebp),%edi\nje .LC564\nmovb $1,-29(%ebp)\n.LC564:\nmovl -80(%ebp),%edi\nmovswl -76(%ebp),%esi\nimull %esi,%edi\ncmpl -96(%ebp),%edi\nje .LC567\nmovb $1,-28(%ebp)\n.LC567:\nmovl -80(%ebp),%edi\nmovl %edi,%esi\nimull %edi,%esi\ncmpl -96(%ebp),%esi\nje .LC570\nmovb $1,-27(%ebp)\n.LC570:\nmovl -84(%ebp),%eax\nmovsbl -73(%ebp),%edi\nmull %edi\ncmpl -100(%ebp),%eax\nje .LC573\nmovb $1,-26(%ebp)\n.LC573:\nmovl -84(%ebp),%eax\nmovswl -76(%ebp),%edi\nmull %edi\ncmpl -100(%ebp),%eax\nje .LC576\nmovb $1,-25(%ebp)\n.LC576:\nmovl -84(%ebp),%eax\nmovl -80(%ebp),%edi\nmull %edi\ncmpl -100(%ebp),%eax\nje .LC579\nmovb $1,-24(%ebp)\n.LC579:\nmovl -84(%ebp),%edi\nmovl %edi,%eax\nmull %edi\ncmpl -100(%ebp),%eax\nje .LC582\nmovb $1,-23(%ebp)\n.LC582:\nmovl -68(%ebp),%edi\nmovsbl -73(%ebp),%esi\nimull %esi,%edi\ncmpl -108(%ebp),%edi\nje .LC585\nmovb $1,-22(%ebp)\n.LC585:\nmovl -68(%ebp),%edi\nmovswl -76(%ebp),%esi\nimull %esi,%edi\ncmpl -108(%ebp),%edi\nje .LC588\nmovb $1,-21(%ebp)\n.LC588:\nmovl -68(%ebp),%edi\nimull -80(%ebp),%edi\ncmpl -108(%ebp),%edi\nje .LC591\nmovb $1,-20(%ebp)\n.LC591:\nmovl -68(%ebp),%edi\nmovl %edi,%eax\nmull -84(%ebp)\ncmpl -100(%ebp),%eax\nje .LC594\nmovb $1,-19(%ebp)\n.LC594:\nmovl -68(%ebp),%edi\nmovl %edi,%esi\nimull %edi,%esi\ncmpl -108(%ebp),%esi\nje .LC597\nmovb $1,-18(%ebp)\n.LC597:\nflds -72(%ebp)\nmovsbl -73(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nfldl -52(%ebp)\nfcompp\nfstsw %ax\nsahf\nje .LC600\nmovb $1,-17(%ebp)\n.LC600:\nflds -72(%ebp)\nmovswl -76(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nfldl -52(%ebp)\nfcompp\nfstsw %ax\nsahf\nje .LC603\nmovb $1,-16(%ebp)\n.LC603:\nflds -72(%ebp)\nfildl -80(%ebp)\nfmulp %st(1),%st\nfldl -52(%ebp)\nfcompp\nfstsw %ax\nsahf\nje .LC606\nmovb $1,-15(%ebp)\n.LC606:\nmovl -84(%ebp),%edi\nflds -72(%ebp)\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nsub $4,%esp\nfstps (%esp)\nflds (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nfldl -52(%ebp)\nfcompp\nfstsw %ax\nsahf\nje .LC609\nmovb $1,-14(%ebp)\n.LC609:\nflds -72(%ebp)\nfildl -68(%ebp)\nfmulp %st(1),%st\nfldl -52(%ebp)\nfcompp\nfstsw %ax\nsahf\nje .LC613\nmovb $1,-13(%ebp)\n.LC613:\nflds -72(%ebp)\nfmuls -72(%ebp)\nfldl -52(%ebp)\nfcompp\nfstsw %ax\nsahf\nje .LC616\nmovb $1,-12(%ebp)\n.LC616:\nfldl -92(%ebp)\nmovsbl -73(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nfldl -52(%ebp)\nfcompp\nfstsw %ax\nsahf\nje .LC619\nmovb $1,-11(%ebp)\n.LC619:\nfldl -92(%ebp)\nmovswl -76(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nfldl -52(%ebp)\nfcompp\nfstsw %ax\nsahf\nje .LC622\nmovb $1,-10(%ebp)\n.LC622:\nfldl -92(%ebp)\nfimull -80(%ebp)\nfldl -52(%ebp)\nfcompp\nfstsw %ax\nsahf\nje .LC625\nmovb $1,-9(%ebp)\n.LC625:\nmovl -84(%ebp),%edi\nfldl -92(%ebp)\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nfmulp %st(1),%st\nfldl -52(%ebp)\nfcompp\nfstsw %ax\nsahf\nje .LC628\nmovb $1,-8(%ebp)\n.LC628:\nfldl -92(%ebp)\nfimull -68(%ebp)\nfldl -52(%ebp)\nfcompp\nfstsw %ax\nsahf\nje .LC631\nmovb $1,-7(%ebp)\n.LC631:\nfldl -92(%ebp)\nfmuls -72(%ebp)\nfldl -52(%ebp)\nfcompp\nfstsw %ax\nsahf\nje .LC634\nmovb $1,-6(%ebp)\n.LC634:\nfldl -92(%ebp)\nfmull -92(%ebp)\nfldl -52(%ebp)\nfcompp\nfstsw %ax\nsahf\nje .LC637\nmovb $1,-5(%ebp)\n.LC637:\nmovb $0,-41(%ebp)\nmovl $0,-4(%ebp)\n.LC640:\nmovsbl -41(%ebp),%edi\nmovl -4(%ebp),%esi\nleal -32(%ebp),%ebx\nmovsbl (%ebx,%esi),%esi\nleal (%esi,%edi),%edi\nmovl %edi,%ebx\nmovb %bl,-41(%ebp)\n.LC641:\nincl -4(%ebp)\ncmpl $28,-4(%ebp)\njl .LC640\nmovsbl -41(%ebp),%edi\ncmpl $0,%edi\nje .LC644\naddl $4,-104(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC646\npushl $4\npushl $s626er.535\ncall printf\naddl $8,%esp\npushl $.LC648\ncall printf\naddl $4,%esp\nmovl $0,-4(%ebp)\n.LC649:\nmovl -4(%ebp),%edi\nleal -32(%ebp),%esi\nmovsbl (%esi,%edi),%edi\npushl %edi\npushl $.LC653\ncall printf\naddl $8,%esp\n.LC650:\nincl -4(%ebp)\ncmpl $28,-4(%ebp)\njl .LC649\npushl $.LC654\ncall printf\naddl $4,%esp\n.LC646:\n.LC644:\nmovl $32768,-68(%ebp)\nmovl -68(%ebp),%edi\ncmpl $0x8000,%edi\njbe .LC655\naddl $8,-104(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC657\npushl $8\npushl $s626er.535\ncall printf\naddl $8,%esp\n.LC657:\n.LC655:\nmovl -104(%ebp),%eax\n.LC534:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf659:\n.size s626,.Lf659-s626\n.data\n.align 1\n.type s71er.661,@object\ns71er.661:\n.byte 115\n.byte 55\n.byte 49\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size s71er.661,10\n.align 1\n.type qs71.662,@object\n.size qs71.662,8\nqs71.662:\n.byte 115\n.byte 55\n.byte 49\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.align 1\n.type q.663,@object\n.size q.663,1\nq.663:\n.byte 113\n.globl s71\n.text\n.align 16\n.type s71,@function\ns71:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $68,%esp\nleal qs71.662,%edi\nmovl %edi,-4(%ebp)\nmovl 20(%ebp),%edi\nleal 60(%edi),%edi\nmovl %edi,-8(%ebp)\nmovl $0,-12(%ebp)\n.LC664:\n.LC665:\nmovl -8(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-8(%ebp)\nmovl -4(%ebp),%esi\nleal 1(%esi),%ebx\nmovl %ebx,-4(%ebp)\nmovb (,%esi),%bl\nmovb %bl,(,%edi)\nmovsbl %bl,%edi\ncmpl $0,%edi\njne .LC664\nmovsbl .LC669,%edi\nmovsbl q.663,%esi\ncmpl %esi,%edi\nje .LC667\nincl -12(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC670\npushl $1\npushl $s71er.661\ncall printf\naddl $8,%esp\n.LC670:\n.LC667:\njmp .LC672\naddl $2,-12(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC674\npushl $2\npushl $s71er.661\ncall printf\naddl $8,%esp\n.LC674:\n.LC672:\nmovl $1942,-32(%ebp)\ncmpl $1942,-32(%ebp)\njne .LC682\nmovl -32(%ebp),%edi\ncmpl %edi,-32(%ebp)\nje .LC677\n.LC682:\naddl $4,-12(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC683\npushl $4\npushl $s71er.661\ncall printf\naddl $8,%esp\n.LC683:\n.LC677:\npushl $-5\ncall McCarthy\naddl $4,%esp\ncmpl $91,%eax\nje .LC685\naddl $8,-12(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC687\npushl $8\npushl $s71er.661\ncall printf\naddl $8,%esp\n.LC687:\n.LC685:\nmovl $2,-56(%ebp)\nmovl $3,-60(%ebp)\nleal -60(%ebp),%edi\nmovl %edi,-64(%ebp)\npushl -64(%ebp)\npushl -56(%ebp)\ncall clobber\naddl $8,%esp\ncmpl $2,-56(%ebp)\njne .LC691\ncmpl $2,-60(%ebp)\nje .LC689\n.LC691:\naddl $16,-12(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC692\npushl $16\npushl $s71er.661\ncall printf\naddl $8,%esp\n.LC692:\n.LC689:\nmovl 20(%ebp),%edi\nflds 32(%edi)\nfstps -68(%ebp)\nflds -68(%ebp)\nfcomps -68(%ebp)\nfstsw %ax\nsahf\nje .LC694\naddl $32,-12(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC696\npushl $32\npushl $s71er.661\ncall printf\naddl $8,%esp\n.LC696:\n.LC694:\nmovl -12(%ebp),%eax\n.LC660:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf698:\n.size s71,.Lf698-s71\n.globl McCarthy\n.align 16\n.type McCarthy,@function\nMcCarthy:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\ncmpl $100,20(%ebp)\njle .LC700\nmovl 20(%ebp),%edi\nmovl %edi,%eax\nsubl $10,%eax\njmp .LC699\n.LC700:\nmovl 20(%ebp),%edi\nleal 11(%edi),%edi\npushl %edi\ncall McCarthy\naddl $4,%esp\nmovl %eax,%edi\npushl %edi\ncall McCarthy\naddl $4,%esp\nmovl %eax,%edi\n.LC699:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf702:\n.size McCarthy,.Lf702-McCarthy\n.globl clobber\n.align 16\n.type clobber,@function\nclobber:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl $3,20(%ebp)\nmovl 24(%ebp),%edi\nmovl $2,(,%edi)\nmovl $0,%eax\n.LC703:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf704:\n.size clobber,.Lf704-clobber\n.data\n.align 1\n.type f.706,@object\nf.706:\n.byte 76\n.byte 111\n.byte 99\n.byte 97\n.byte 108\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 37\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.size f.706,17\n.align 1\n.type s714er.707,@object\ns714er.707:\n.byte 115\n.byte 55\n.byte 49\n.byte 52\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size s714er.707,11\n.align 1\n.type qs714.708,@object\n.size qs714.708,8\nqs714.708:\n.byte 115\n.byte 55\n.byte 49\n.byte 52\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s714\n.text\n.align 16\n.type s714,@function\ns714:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $248,%esp\nleal qs714.708,%edi\nmovl %edi,-68(%ebp)\nmovl 20(%ebp),%edi\nleal 60(%edi),%esi\nmovl %esi,-72(%ebp)\nmovl $0,-76(%ebp)\nmovl $0,-8(%ebp)\nmovl 48(%edi),%edi\nmovl %edi,-4(%ebp)\n.LC709:\n.LC710:\nmovl -72(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-72(%ebp)\nmovl -68(%ebp),%esi\nleal 1(%esi),%ebx\nmovl %ebx,-68(%ebp)\nmovb (,%esi),%bl\nmovb %bl,(,%edi)\nmovsbl %bl,%edi\ncmpl $0,%edi\njne .LC709\nmovb $5,-9(%ebp)\nmovb $2,-25(%ebp)\nmovb -25(%ebp),%bl\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $2,%edi\nje .LC712\nmovl $1,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC714\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC714:\n.LC712:\nmovb $5,-9(%ebp)\nmovw $2,-28(%ebp)\nmovswl -28(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $2,%edi\nje .LC716\nmovl $2,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC718\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC718:\n.LC716:\nmovb $5,-9(%ebp)\nmovl $2,-32(%ebp)\nmovl -32(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $2,%edi\nje .LC720\nmovl $3,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC722\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC722:\n.LC720:\nmovb $5,-9(%ebp)\nmovl $2,-36(%ebp)\nmovl -36(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $2,%edi\nje .LC724\nmovl $4,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC726\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC726:\n.LC724:\nmovb $5,-9(%ebp)\nmovl $2,-40(%ebp)\nmovl -40(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $2,%edi\nje .LC728\nmovl $5,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC730\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC730:\n.LC728:\nmovb $5,-9(%ebp)\nflds .LC544\nfstps -56(%ebp)\nflds -56(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $2,%edi\nje .LC732\nmovl $6,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC734\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC734:\n.LC732:\nmovb $5,-9(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nfldl -64(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $2,%edi\nje .LC736\nmovl $7,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC738\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC738:\n.LC736:\nmovw $5,-12(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -25(%ebp),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $2,%edi\nje .LC740\nmovl $8,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC742\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC742:\n.LC740:\nmovw $5,-12(%ebp)\nmovw $2,-28(%ebp)\nmovw -28(%ebp),%di\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $2,%edi\nje .LC744\nmovl $9,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC746\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC746:\n.LC744:\nmovw $5,-12(%ebp)\nmovl $2,-32(%ebp)\nmovl -32(%ebp),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $2,%edi\nje .LC748\nmovl $10,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC750\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC750:\n.LC748:\nmovw $5,-12(%ebp)\nmovl $2,-36(%ebp)\nmovl -36(%ebp),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $2,%edi\nje .LC752\nmovl $11,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC754\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC754:\n.LC752:\nmovw $5,-12(%ebp)\nmovl $2,-40(%ebp)\nmovl -40(%ebp),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $2,%edi\nje .LC756\nmovl $12,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC758\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC758:\n.LC756:\nmovw $5,-12(%ebp)\nflds .LC544\nfstps -56(%ebp)\nflds -56(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $2,%edi\nje .LC760\nmovl $13,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC762\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC762:\n.LC760:\nmovw $5,-12(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nfldl -64(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $2,%edi\nje .LC764\nmovl $14,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC766\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC766:\n.LC764:\nmovl $5,-16(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -25(%ebp),%edi\nmovl %edi,-16(%ebp)\ncmpl $2,-16(%ebp)\nje .LC768\nmovl $15,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC770\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC770:\n.LC768:\nmovl $5,-16(%ebp)\nmovw $2,-28(%ebp)\nmovswl -28(%ebp),%edi\nmovl %edi,-16(%ebp)\ncmpl $2,-16(%ebp)\nje .LC772\nmovl $16,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC774\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC774:\n.LC772:\nmovl $5,-16(%ebp)\nmovl $2,-32(%ebp)\nmovl -32(%ebp),%edi\nmovl %edi,-16(%ebp)\ncmpl $2,-16(%ebp)\nje .LC776\nmovl $17,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC778\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC778:\n.LC776:\nmovl $5,-16(%ebp)\nmovl $2,-36(%ebp)\nmovl -36(%ebp),%edi\nmovl %edi,-16(%ebp)\ncmpl $2,-16(%ebp)\nje .LC780\nmovl $18,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC782\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC782:\n.LC780:\nmovl $5,-16(%ebp)\nmovl $2,-40(%ebp)\nmovl -40(%ebp),%edi\nmovl %edi,-16(%ebp)\ncmpl $2,-16(%ebp)\nje .LC784\nmovl $19,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC786\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC786:\n.LC784:\nmovl $5,-16(%ebp)\nflds .LC544\nfstps -56(%ebp)\nflds -56(%ebp)\nfistpl -16(%ebp)\ncmpl $2,-16(%ebp)\nje .LC788\nmovl $20,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC790\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC790:\n.LC788:\nmovl $5,-16(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nfldl -64(%ebp)\nfistpl -16(%ebp)\ncmpl $2,-16(%ebp)\nje .LC792\nmovl $21,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC794\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC794:\n.LC792:\nmovl $5,-20(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -25(%ebp),%edi\nmovl %edi,-20(%ebp)\ncmpl $2,-20(%ebp)\nje .LC796\nmovl $22,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC798\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC798:\n.LC796:\nmovl $5,-20(%ebp)\nmovw $2,-28(%ebp)\nmovswl -28(%ebp),%edi\nmovl %edi,-20(%ebp)\ncmpl $2,-20(%ebp)\nje .LC800\nmovl $23,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC802\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC802:\n.LC800:\nmovl $5,-20(%ebp)\nmovl $2,-32(%ebp)\nmovl -32(%ebp),%edi\nmovl %edi,-20(%ebp)\ncmpl $2,-20(%ebp)\nje .LC804\nmovl $24,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC806\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC806:\n.LC804:\nmovl $5,-20(%ebp)\nmovl $2,-36(%ebp)\nmovl -36(%ebp),%edi\nmovl %edi,-20(%ebp)\ncmpl $2,-20(%ebp)\nje .LC808\nmovl $25,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC810\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC810:\n.LC808:\nmovl $5,-20(%ebp)\nmovl $2,-40(%ebp)\nmovl -40(%ebp),%edi\nmovl %edi,-20(%ebp)\ncmpl $2,-20(%ebp)\nje .LC812\nmovl $26,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC814\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC814:\n.LC812:\nmovl $5,-20(%ebp)\nflds .LC544\nfstps -56(%ebp)\nflds -56(%ebp)\nfistpl -20(%ebp)\ncmpl $2,-20(%ebp)\nje .LC816\nmovl $27,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC818\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC818:\n.LC816:\nmovl $5,-20(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nfldl -64(%ebp)\nfistpl -20(%ebp)\ncmpl $2,-20(%ebp)\nje .LC820\nmovl $28,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC822\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC822:\n.LC820:\nmovl $5,-24(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -25(%ebp),%edi\nmovl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $2,%edi\nje .LC824\nmovl $29,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC826\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC826:\n.LC824:\nmovl $5,-24(%ebp)\nmovw $2,-28(%ebp)\nmovswl -28(%ebp),%edi\nmovl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $2,%edi\nje .LC828\nmovl $30,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC830\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC830:\n.LC828:\nmovl $5,-24(%ebp)\nmovl $2,-32(%ebp)\nmovl -32(%ebp),%edi\nmovl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $2,%edi\nje .LC832\nmovl $31,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC834\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC834:\n.LC832:\nmovl $5,-24(%ebp)\nmovl $2,-36(%ebp)\nmovl -36(%ebp),%edi\nmovl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $2,%edi\nje .LC836\nmovl $32,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC838\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC838:\n.LC836:\nmovl $5,-24(%ebp)\nmovl $2,-40(%ebp)\nmovl -40(%ebp),%edi\nmovl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $2,%edi\nje .LC840\nmovl $33,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC842\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC842:\n.LC840:\nmovl $5,-24(%ebp)\nflds .LC544\nfstps -56(%ebp)\nflds .LC847\nfcomps -56(%ebp)\nfstsw %ax\nsahf\nja .LC845\nflds -56(%ebp)\nfsubs .LC847\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-80(%ebp)\njmp .LC846\n.LC845:\nflds -56(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-80(%ebp)\n.LC846:\nmovl -80(%ebp),%edi\nmovl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $2,%edi\nje .LC848\nmovl $34,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC850\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC850:\n.LC848:\nmovl $5,-24(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nfldl .LC855\nfcompl -64(%ebp)\nfstsw %ax\nsahf\nja .LC853\nfldl -64(%ebp)\nfsubl .LC855\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-92(%ebp)\njmp .LC854\n.LC853:\nfldl -64(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-92(%ebp)\n.LC854:\nmovl -92(%ebp),%edi\nmovl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $2,%edi\nje .LC856\nmovl $35,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC858\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC858:\n.LC856:\nflds .LC860\nfstps -44(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -25(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfstps -44(%ebp)\nflds .LC544\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC861\nmovl $36,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC863\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC863:\n.LC861:\nflds .LC860\nfstps -44(%ebp)\nmovw $2,-28(%ebp)\nmovswl -28(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfstps -44(%ebp)\nflds .LC544\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC865\nmovl $37,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC867\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC867:\n.LC865:\nflds .LC860\nfstps -44(%ebp)\nmovl $2,-32(%ebp)\nfildl -32(%ebp)\nfstps -44(%ebp)\nflds .LC544\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC869\nmovl $38,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC871\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC871:\n.LC869:\nflds .LC860\nfstps -44(%ebp)\nmovl $2,-36(%ebp)\nfildl -36(%ebp)\nfstps -44(%ebp)\nflds .LC544\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC873\nmovl $39,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC875\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC875:\n.LC873:\nflds .LC860\nfstps -44(%ebp)\nmovl $2,-40(%ebp)\nmovl -40(%ebp),%edi\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nfstps -44(%ebp)\nflds .LC544\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC877\nmovl $40,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC879\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC879:\n.LC877:\nflds .LC860\nfstps -44(%ebp)\nflds .LC544\nfstps -56(%ebp)\nflds -56(%ebp)\nfstps -44(%ebp)\nflds .LC544\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC881\nmovl $41,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC883\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC883:\n.LC881:\nflds .LC860\nfstps -44(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nfldl -64(%ebp)\nfstps -44(%ebp)\nflds .LC544\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC885\nmovl $42,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC887\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC887:\n.LC885:\nfldl .LC889\nfstpl -52(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -25(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfstpl -52(%ebp)\nfldl .LC425\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC890\nmovl $43,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC892\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC892:\n.LC890:\nfldl .LC889\nfstpl -52(%ebp)\nmovw $2,-28(%ebp)\nmovswl -28(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfstpl -52(%ebp)\nfldl .LC425\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC894\nmovl $44,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC896\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC896:\n.LC894:\nfldl .LC889\nfstpl -52(%ebp)\nmovl $2,-32(%ebp)\nfildl -32(%ebp)\nfstpl -52(%ebp)\nfldl .LC425\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC898\nmovl $45,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC900\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC900:\n.LC898:\nfldl .LC889\nfstpl -52(%ebp)\nmovl $2,-36(%ebp)\nfildl -36(%ebp)\nfstpl -52(%ebp)\nfldl .LC425\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC902\nmovl $46,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC904\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC904:\n.LC902:\nfldl .LC889\nfstpl -52(%ebp)\nmovl $2,-40(%ebp)\nmovl -40(%ebp),%edi\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nfstpl -52(%ebp)\nfldl .LC425\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC906\nmovl $47,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC908\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC908:\n.LC906:\nfldl .LC889\nfstpl -52(%ebp)\nflds .LC544\nfstps -56(%ebp)\nflds -56(%ebp)\nfstpl -52(%ebp)\nfldl .LC425\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC910\nmovl $48,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC912\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC912:\n.LC910:\nfldl .LC889\nfstpl -52(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nfldl -64(%ebp)\nfstpl -52(%ebp)\nfldl .LC425\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC914\nmovl $49,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC916\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC916:\n.LC914:\nmovb $5,-9(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -9(%ebp),%edi\nmovsbl -25(%ebp),%esi\nleal (%esi,%edi),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $7,%edi\nje .LC918\nmovl $50,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC920\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC920:\n.LC918:\nmovb $5,-9(%ebp)\nmovw $2,-28(%ebp)\nmovsbl -9(%ebp),%edi\nmovswl -28(%ebp),%esi\nleal (%esi,%edi),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $7,%edi\nje .LC922\nmovl $51,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC924\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC924:\n.LC922:\nmovb $5,-9(%ebp)\nmovl $2,-32(%ebp)\nmovsbl -9(%ebp),%edi\nmovl -32(%ebp),%esi\nleal (%esi,%edi),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $7,%edi\nje .LC926\nmovl $52,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC928\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC928:\n.LC926:\nmovb $5,-9(%ebp)\nmovl $2,-36(%ebp)\nmovsbl -9(%ebp),%edi\nmovl -36(%ebp),%esi\nleal (%esi,%edi),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $7,%edi\nje .LC930\nmovl $53,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC932\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC932:\n.LC930:\nmovb $5,-9(%ebp)\nmovl $2,-40(%ebp)\nmovsbl -9(%ebp),%edi\nmovl -40(%ebp),%esi\nleal (%esi,%edi),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $7,%edi\nje .LC934\nmovl $54,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC936\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC936:\n.LC934:\nmovb $5,-9(%ebp)\nflds .LC544\nfstps -56(%ebp)\nmovsbl -9(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfadds -56(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $7,%edi\nje .LC938\nmovl $55,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC940\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC940:\n.LC938:\nmovb $5,-9(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nmovsbl -9(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddl -64(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $7,%edi\nje .LC942\nmovl $56,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC944\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC944:\n.LC942:\nmovw $5,-12(%ebp)\nmovb $2,-25(%ebp)\nmovswl -12(%ebp),%edi\nmovsbl -25(%ebp),%esi\nleal (%esi,%edi),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $7,%edi\nje .LC946\nmovl $57,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC948\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC948:\n.LC946:\nmovw $5,-12(%ebp)\nmovw $2,-28(%ebp)\nmovswl -12(%ebp),%edi\nmovswl -28(%ebp),%esi\nleal (%esi,%edi),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $7,%edi\nje .LC950\nmovl $58,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC952\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC952:\n.LC950:\nmovw $5,-12(%ebp)\nmovl $2,-32(%ebp)\nmovswl -12(%ebp),%edi\nmovl -32(%ebp),%esi\nleal (%esi,%edi),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $7,%edi\nje .LC954\nmovl $59,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC956\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC956:\n.LC954:\nmovw $5,-12(%ebp)\nmovl $2,-36(%ebp)\nmovswl -12(%ebp),%edi\nmovl -36(%ebp),%esi\nleal (%esi,%edi),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $7,%edi\nje .LC958\nmovl $60,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC960\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC960:\n.LC958:\nmovw $5,-12(%ebp)\nmovl $2,-40(%ebp)\nmovswl -12(%ebp),%edi\nmovl -40(%ebp),%esi\nleal (%esi,%edi),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $7,%edi\nje .LC962\nmovl $61,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC964\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC964:\n.LC962:\nmovw $5,-12(%ebp)\nflds .LC544\nfstps -56(%ebp)\nmovswl -12(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfadds -56(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $7,%edi\nje .LC966\nmovl $62,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC968\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC968:\n.LC966:\nmovw $5,-12(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nmovswl -12(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddl -64(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $7,%edi\nje .LC970\nmovl $63,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC972\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC972:\n.LC970:\nmovl $5,-16(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -25(%ebp),%edi\naddl %edi,-16(%ebp)\ncmpl $7,-16(%ebp)\nje .LC974\nmovl $64,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC976\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC976:\n.LC974:\nmovl $5,-16(%ebp)\nmovw $2,-28(%ebp)\nmovswl -28(%ebp),%edi\naddl %edi,-16(%ebp)\ncmpl $7,-16(%ebp)\nje .LC978\nmovl $65,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC980\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC980:\n.LC978:\nmovl $5,-16(%ebp)\nmovl $2,-32(%ebp)\nmovl -32(%ebp),%edi\naddl %edi,-16(%ebp)\ncmpl $7,-16(%ebp)\nje .LC982\nmovl $66,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC984\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC984:\n.LC982:\nmovl $5,-16(%ebp)\nmovl $2,-36(%ebp)\nmovl -36(%ebp),%edi\naddl %edi,-16(%ebp)\ncmpl $7,-16(%ebp)\nje .LC986\nmovl $67,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC988\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC988:\n.LC986:\nmovl $5,-16(%ebp)\nmovl $2,-40(%ebp)\nmovl -16(%ebp),%edi\nmovl -40(%ebp),%esi\nleal (%esi,%edi),%edi\nmovl %edi,-16(%ebp)\ncmpl $7,-16(%ebp)\nje .LC990\nmovl $68,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC992\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC992:\n.LC990:\nmovl $5,-16(%ebp)\nflds .LC544\nfstps -56(%ebp)\nfildl -16(%ebp)\nfadds -56(%ebp)\nfistpl -16(%ebp)\ncmpl $7,-16(%ebp)\nje .LC994\nmovl $69,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC996\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC996:\n.LC994:\nmovl $5,-16(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nfildl -16(%ebp)\nfaddl -64(%ebp)\nfistpl -16(%ebp)\ncmpl $7,-16(%ebp)\nje .LC998\nmovl $70,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1000\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1000:\n.LC998:\nmovl $5,-20(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -25(%ebp),%edi\naddl %edi,-20(%ebp)\ncmpl $7,-20(%ebp)\nje .LC1002\nmovl $71,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1004\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1004:\n.LC1002:\nmovl $5,-20(%ebp)\nmovw $2,-28(%ebp)\nmovswl -28(%ebp),%edi\naddl %edi,-20(%ebp)\ncmpl $7,-20(%ebp)\nje .LC1006\nmovl $72,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1008\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1008:\n.LC1006:\nmovl $5,-20(%ebp)\nmovl $2,-32(%ebp)\nmovl -32(%ebp),%edi\naddl %edi,-20(%ebp)\ncmpl $7,-20(%ebp)\nje .LC1010\nmovl $73,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1012\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1012:\n.LC1010:\nmovl $5,-20(%ebp)\nmovl $2,-36(%ebp)\nmovl -36(%ebp),%edi\naddl %edi,-20(%ebp)\ncmpl $7,-20(%ebp)\nje .LC1014\nmovl $74,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1016\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1016:\n.LC1014:\nmovl $5,-20(%ebp)\nmovl $2,-40(%ebp)\nmovl -20(%ebp),%edi\nmovl -40(%ebp),%esi\nleal (%esi,%edi),%edi\nmovl %edi,-20(%ebp)\ncmpl $7,-20(%ebp)\nje .LC1018\nmovl $75,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1020\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1020:\n.LC1018:\nmovl $5,-20(%ebp)\nflds .LC544\nfstps -56(%ebp)\nfildl -20(%ebp)\nfadds -56(%ebp)\nfistpl -20(%ebp)\ncmpl $7,-20(%ebp)\nje .LC1022\nmovl $76,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1024\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1024:\n.LC1022:\nmovl $5,-20(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nfildl -20(%ebp)\nfaddl -64(%ebp)\nfistpl -20(%ebp)\ncmpl $7,-20(%ebp)\nje .LC1026\nmovl $77,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1028\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1028:\n.LC1026:\nmovl $5,-24(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -25(%ebp),%edi\nadd %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $7,%edi\nje .LC1030\nmovl $78,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1032\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1032:\n.LC1030:\nmovl $5,-24(%ebp)\nmovw $2,-28(%ebp)\nmovswl -28(%ebp),%edi\nadd %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $7,%edi\nje .LC1034\nmovl $79,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1036\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1036:\n.LC1034:\nmovl $5,-24(%ebp)\nmovl $2,-32(%ebp)\nmovl -32(%ebp),%edi\nadd %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $7,%edi\nje .LC1038\nmovl $80,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1040\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1040:\n.LC1038:\nmovl $5,-24(%ebp)\nmovl $2,-36(%ebp)\nmovl -36(%ebp),%edi\nadd %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $7,%edi\nje .LC1042\nmovl $81,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1044\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1044:\n.LC1042:\nmovl $5,-24(%ebp)\nmovl $2,-40(%ebp)\nmovl -40(%ebp),%edi\nadd %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $7,%edi\nje .LC1046\nmovl $82,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1048\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1048:\n.LC1046:\nmovl $5,-24(%ebp)\nflds .LC544\nfstps -56(%ebp)\nmovl -24(%ebp),%edi\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nsub $4,%esp\nfstps (%esp)\nflds (%esp)\naddl $4,%esp\nfadds -56(%ebp)\nfstps -128(%ebp)\nflds .LC847\nfcomps -128(%ebp)\nfstsw %ax\nsahf\nja .LC1051\nflds -128(%ebp)\nfsubs .LC847\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-124(%ebp)\njmp .LC1052\n.LC1051:\nflds -128(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-124(%ebp)\n.LC1052:\nmovl -124(%ebp),%edi\nmovl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $7,%edi\nje .LC1053\nmovl $83,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1055\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1055:\n.LC1053:\nmovl $5,-24(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nmovl -24(%ebp),%edi\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nfaddl -64(%ebp)\nfstpl -144(%ebp)\nfldl .LC855\nfcompl -144(%ebp)\nfstsw %ax\nsahf\nja .LC1058\nfldl -144(%ebp)\nfsubl .LC855\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-136(%ebp)\njmp .LC1059\n.LC1058:\nfldl -144(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-136(%ebp)\n.LC1059:\nmovl -136(%ebp),%edi\nmovl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $7,%edi\nje .LC1060\nmovl $84,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1062\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1062:\n.LC1060:\nflds .LC860\nfstps -44(%ebp)\nmovb $2,-25(%ebp)\nflds -44(%ebp)\nmovsbl -25(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nfstps -44(%ebp)\nflds .LC1066\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1064\nmovl $85,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1067\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1067:\n.LC1064:\nflds .LC860\nfstps -44(%ebp)\nmovw $2,-28(%ebp)\nflds -44(%ebp)\nmovswl -28(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nfstps -44(%ebp)\nflds .LC1066\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1069\nmovl $86,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1071\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1071:\n.LC1069:\nflds .LC860\nfstps -44(%ebp)\nmovl $2,-32(%ebp)\nflds -44(%ebp)\nfildl -32(%ebp)\nfaddp %st(1),%st\nfstps -44(%ebp)\nflds .LC1066\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1073\nmovl $87,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1075\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1075:\n.LC1073:\nflds .LC860\nfstps -44(%ebp)\nmovl $2,-36(%ebp)\nflds -44(%ebp)\nfildl -36(%ebp)\nfaddp %st(1),%st\nfstps -44(%ebp)\nflds .LC1066\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1077\nmovl $88,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1079\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1079:\n.LC1077:\nflds .LC860\nfstps -44(%ebp)\nmovl $2,-40(%ebp)\nmovl -40(%ebp),%edi\nflds -44(%ebp)\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nsub $4,%esp\nfstps (%esp)\nflds (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nfstps -44(%ebp)\nflds .LC1066\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1081\nmovl $89,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1083\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1083:\n.LC1081:\nflds .LC860\nfstps -44(%ebp)\nflds .LC544\nfstps -56(%ebp)\nflds -44(%ebp)\nfadds -56(%ebp)\nfstps -44(%ebp)\nflds .LC1066\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1085\nmovl $90,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1087\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1087:\n.LC1085:\nflds .LC860\nfstps -44(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nflds -44(%ebp)\nfaddl -64(%ebp)\nfstps -44(%ebp)\nflds .LC1066\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1089\nmovl $91,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1091\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1091:\n.LC1089:\nfldl .LC889\nfstpl -52(%ebp)\nmovb $2,-25(%ebp)\nfldl -52(%ebp)\nmovsbl -25(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nfstpl -52(%ebp)\nfldl .LC1095\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1093\nmovl $92,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1096\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1096:\n.LC1093:\nfldl .LC889\nfstpl -52(%ebp)\nmovw $2,-28(%ebp)\nfldl -52(%ebp)\nmovswl -28(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nfstpl -52(%ebp)\nfldl .LC1095\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1098\nmovl $93,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1100\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1100:\n.LC1098:\nfldl .LC889\nfstpl -52(%ebp)\nmovl $2,-32(%ebp)\nfldl -52(%ebp)\nfiaddl -32(%ebp)\nfstpl -52(%ebp)\nfldl .LC1095\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1102\nmovl $94,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1104\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1104:\n.LC1102:\nfldl .LC889\nfstpl -52(%ebp)\nmovl $2,-36(%ebp)\nfldl -52(%ebp)\nfiaddl -36(%ebp)\nfstpl -52(%ebp)\nfldl .LC1095\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1106\nmovl $95,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1108\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1108:\n.LC1106:\nfldl .LC889\nfstpl -52(%ebp)\nmovl $2,-40(%ebp)\nmovl -40(%ebp),%edi\nfldl -52(%ebp)\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nfaddp %st(1),%st\nfstpl -52(%ebp)\nfldl .LC1095\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1110\nmovl $96,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1112\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1112:\n.LC1110:\nfldl .LC889\nfstpl -52(%ebp)\nflds .LC544\nfstps -56(%ebp)\nfldl -52(%ebp)\nfadds -56(%ebp)\nfstpl -52(%ebp)\nfldl .LC1095\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1114\nmovl $97,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1116\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1116:\n.LC1114:\nfldl .LC889\nfstpl -52(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nfldl -52(%ebp)\nfaddl -64(%ebp)\nfstpl -52(%ebp)\nfldl .LC1095\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1118\nmovl $98,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1120\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1120:\n.LC1118:\nmovb $5,-9(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -9(%ebp),%edi\nmovsbl -25(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $3,%edi\nje .LC1122\nmovl $99,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1124\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1124:\n.LC1122:\nmovb $5,-9(%ebp)\nmovw $2,-28(%ebp)\nmovsbl -9(%ebp),%edi\nmovswl -28(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $3,%edi\nje .LC1126\nmovl $100,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1128\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1128:\n.LC1126:\nmovb $5,-9(%ebp)\nmovl $2,-32(%ebp)\nmovsbl -9(%ebp),%edi\nsubl -32(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $3,%edi\nje .LC1130\nmovl $101,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1132\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1132:\n.LC1130:\nmovb $5,-9(%ebp)\nmovl $2,-36(%ebp)\nmovsbl -9(%ebp),%edi\nsubl -36(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $3,%edi\nje .LC1134\nmovl $102,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1136\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1136:\n.LC1134:\nmovb $5,-9(%ebp)\nmovl $2,-40(%ebp)\nmovsbl -9(%ebp),%edi\nsubl -40(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $3,%edi\nje .LC1138\nmovl $103,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1140\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1140:\n.LC1138:\nmovb $5,-9(%ebp)\nflds .LC544\nfstps -56(%ebp)\nmovsbl -9(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfsubs -56(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $3,%edi\nje .LC1142\nmovl $104,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1144\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1144:\n.LC1142:\nmovb $5,-9(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nmovsbl -9(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfsubl -64(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $3,%edi\nje .LC1146\nmovl $105,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1148\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1148:\n.LC1146:\nmovw $5,-12(%ebp)\nmovb $2,-25(%ebp)\nmovswl -12(%ebp),%edi\nmovsbl -25(%ebp),%esi\nsubl %esi,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $3,%edi\nje .LC1150\nmovl $106,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1152\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1152:\n.LC1150:\nmovw $5,-12(%ebp)\nmovw $2,-28(%ebp)\nmovswl -12(%ebp),%edi\nmovswl -28(%ebp),%esi\nsubl %esi,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $3,%edi\nje .LC1154\nmovl $107,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1156\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1156:\n.LC1154:\nmovw $5,-12(%ebp)\nmovl $2,-32(%ebp)\nmovswl -12(%ebp),%edi\nsubl -32(%ebp),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $3,%edi\nje .LC1158\nmovl $108,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1160\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1160:\n.LC1158:\nmovw $5,-12(%ebp)\nmovl $2,-36(%ebp)\nmovswl -12(%ebp),%edi\nsubl -36(%ebp),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $3,%edi\nje .LC1162\nmovl $109,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1164\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1164:\n.LC1162:\nmovw $5,-12(%ebp)\nmovl $2,-40(%ebp)\nmovswl -12(%ebp),%edi\nsubl -40(%ebp),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $3,%edi\nje .LC1166\nmovl $110,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1168\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1168:\n.LC1166:\nmovw $5,-12(%ebp)\nflds .LC544\nfstps -56(%ebp)\nmovswl -12(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfsubs -56(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $3,%edi\nje .LC1170\nmovl $111,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1172\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1172:\n.LC1170:\nmovw $5,-12(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nmovswl -12(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfsubl -64(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $3,%edi\nje .LC1174\nmovl $112,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1176\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1176:\n.LC1174:\nmovl $5,-16(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -25(%ebp),%edi\nsub %edi,-16(%ebp)\ncmpl $3,-16(%ebp)\nje .LC1178\nmovl $113,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1180\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1180:\n.LC1178:\nmovl $5,-16(%ebp)\nmovw $2,-28(%ebp)\nmovswl -28(%ebp),%edi\nsub %edi,-16(%ebp)\ncmpl $3,-16(%ebp)\nje .LC1182\nmovl $114,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1184\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1184:\n.LC1182:\nmovl $5,-16(%ebp)\nmovl $2,-32(%ebp)\nmovl -32(%ebp),%edi\nsub %edi,-16(%ebp)\ncmpl $3,-16(%ebp)\nje .LC1186\nmovl $115,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1188\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1188:\n.LC1186:\nmovl $5,-16(%ebp)\nmovl $2,-36(%ebp)\nmovl -36(%ebp),%edi\nsub %edi,-16(%ebp)\ncmpl $3,-16(%ebp)\nje .LC1190\nmovl $116,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1192\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1192:\n.LC1190:\nmovl $5,-16(%ebp)\nmovl $2,-40(%ebp)\nmovl -16(%ebp),%edi\nsubl -40(%ebp),%edi\nmovl %edi,-16(%ebp)\ncmpl $3,-16(%ebp)\nje .LC1194\nmovl $117,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1196\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1196:\n.LC1194:\nmovl $5,-16(%ebp)\nflds .LC544\nfstps -56(%ebp)\nfildl -16(%ebp)\nfsubs -56(%ebp)\nfistpl -16(%ebp)\ncmpl $3,-16(%ebp)\nje .LC1198\nmovl $118,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1200\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1200:\n.LC1198:\nmovl $5,-16(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nfldl -64(%ebp)\nfisubrl -16(%ebp)\nfistpl -16(%ebp)\ncmpl $3,-16(%ebp)\nje .LC1202\nmovl $119,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1204\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1204:\n.LC1202:\nmovl $5,-20(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -25(%ebp),%edi\nsub %edi,-20(%ebp)\ncmpl $3,-20(%ebp)\nje .LC1206\nmovl $120,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1208\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1208:\n.LC1206:\nmovl $5,-20(%ebp)\nmovw $2,-28(%ebp)\nmovswl -28(%ebp),%edi\nsub %edi,-20(%ebp)\ncmpl $3,-20(%ebp)\nje .LC1210\nmovl $121,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1212\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1212:\n.LC1210:\nmovl $5,-20(%ebp)\nmovl $2,-32(%ebp)\nmovl -32(%ebp),%edi\nsub %edi,-20(%ebp)\ncmpl $3,-20(%ebp)\nje .LC1214\nmovl $122,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1216\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1216:\n.LC1214:\nmovl $5,-20(%ebp)\nmovl $2,-36(%ebp)\nmovl -36(%ebp),%edi\nsub %edi,-20(%ebp)\ncmpl $3,-20(%ebp)\nje .LC1218\nmovl $123,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1220\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1220:\n.LC1218:\nmovl $5,-20(%ebp)\nmovl $2,-40(%ebp)\nmovl -20(%ebp),%edi\nsubl -40(%ebp),%edi\nmovl %edi,-20(%ebp)\ncmpl $3,-20(%ebp)\nje .LC1222\nmovl $124,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1224\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1224:\n.LC1222:\nmovl $5,-20(%ebp)\nflds .LC544\nfstps -56(%ebp)\nfildl -20(%ebp)\nfsubs -56(%ebp)\nfistpl -20(%ebp)\ncmpl $3,-20(%ebp)\nje .LC1226\nmovl $125,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1228\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1228:\n.LC1226:\nmovl $5,-20(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nfldl -64(%ebp)\nfisubrl -20(%ebp)\nfistpl -20(%ebp)\ncmpl $3,-20(%ebp)\nje .LC1230\nmovl $126,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1232\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1232:\n.LC1230:\nmovl $5,-24(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -25(%ebp),%edi\nsub %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $3,%edi\nje .LC1234\nmovl $127,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1236\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1236:\n.LC1234:\nmovl $5,-24(%ebp)\nmovw $2,-28(%ebp)\nmovswl -28(%ebp),%edi\nsub %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $3,%edi\nje .LC1238\nmovl $128,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1240\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1240:\n.LC1238:\nmovl $5,-24(%ebp)\nmovl $2,-32(%ebp)\nmovl -32(%ebp),%edi\nsub %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $3,%edi\nje .LC1242\nmovl $129,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1244\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1244:\n.LC1242:\nmovl $5,-24(%ebp)\nmovl $2,-36(%ebp)\nmovl -36(%ebp),%edi\nsub %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $3,%edi\nje .LC1246\nmovl $130,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1248\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1248:\n.LC1246:\nmovl $5,-24(%ebp)\nmovl $2,-40(%ebp)\nmovl -40(%ebp),%edi\nsub %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $3,%edi\nje .LC1250\nmovl $131,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1252\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1252:\n.LC1250:\nmovl $5,-24(%ebp)\nflds .LC544\nfstps -56(%ebp)\nmovl -24(%ebp),%edi\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nsub $4,%esp\nfstps (%esp)\nflds (%esp)\naddl $4,%esp\nfsubs -56(%ebp)\nfstps -160(%ebp)\nflds .LC847\nfcomps -160(%ebp)\nfstsw %ax\nsahf\nja .LC1255\nflds -160(%ebp)\nfsubs .LC847\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-156(%ebp)\njmp .LC1256\n.LC1255:\nflds -160(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-156(%ebp)\n.LC1256:\nmovl -156(%ebp),%edi\nmovl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $3,%edi\nje .LC1257\nmovl $132,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1259\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1259:\n.LC1257:\nmovl $5,-24(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nmovl -24(%ebp),%edi\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nfsubl -64(%ebp)\nfstpl -176(%ebp)\nfldl .LC855\nfcompl -176(%ebp)\nfstsw %ax\nsahf\nja .LC1262\nfldl -176(%ebp)\nfsubl .LC855\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-168(%ebp)\njmp .LC1263\n.LC1262:\nfldl -176(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-168(%ebp)\n.LC1263:\nmovl -168(%ebp),%edi\nmovl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $3,%edi\nje .LC1264\nmovl $133,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1266\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1266:\n.LC1264:\nflds .LC860\nfstps -44(%ebp)\nmovb $2,-25(%ebp)\nflds -44(%ebp)\nmovsbl -25(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfsubp %st(1),%st\nfstps -44(%ebp)\nflds .LC1270\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1268\nmovl $134,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1271\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1271:\n.LC1268:\nflds .LC860\nfstps -44(%ebp)\nmovw $2,-28(%ebp)\nflds -44(%ebp)\nmovswl -28(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfsubp %st(1),%st\nfstps -44(%ebp)\nflds .LC1270\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1273\nmovl $135,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1275\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1275:\n.LC1273:\nflds .LC860\nfstps -44(%ebp)\nmovl $2,-32(%ebp)\nflds -44(%ebp)\nfildl -32(%ebp)\nfsubp %st(1),%st\nfstps -44(%ebp)\nflds .LC1270\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1277\nmovl $136,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1279\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1279:\n.LC1277:\nflds .LC860\nfstps -44(%ebp)\nmovl $2,-36(%ebp)\nflds -44(%ebp)\nfildl -36(%ebp)\nfsubp %st(1),%st\nfstps -44(%ebp)\nflds .LC1270\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1281\nmovl $137,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1283\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1283:\n.LC1281:\nflds .LC860\nfstps -44(%ebp)\nmovl $2,-40(%ebp)\nmovl -40(%ebp),%edi\nflds -44(%ebp)\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nsub $4,%esp\nfstps (%esp)\nflds (%esp)\naddl $4,%esp\nfsubp %st(1),%st\nfstps -44(%ebp)\nflds .LC1270\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1285\nmovl $138,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1287\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1287:\n.LC1285:\nflds .LC860\nfstps -44(%ebp)\nflds .LC544\nfstps -56(%ebp)\nflds -44(%ebp)\nfsubs -56(%ebp)\nfstps -44(%ebp)\nflds .LC1270\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1289\nmovl $139,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1291\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1291:\n.LC1289:\nflds .LC860\nfstps -44(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nflds -44(%ebp)\nfsubl -64(%ebp)\nfstps -44(%ebp)\nflds .LC1270\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1293\nmovl $140,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1295\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1295:\n.LC1293:\nfldl .LC889\nfstpl -52(%ebp)\nmovb $2,-25(%ebp)\nfldl -52(%ebp)\nmovsbl -25(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfsubp %st(1),%st\nfstpl -52(%ebp)\nfldl .LC1299\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1297\nmovl $141,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1300\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1300:\n.LC1297:\nfldl .LC889\nfstpl -52(%ebp)\nmovw $2,-28(%ebp)\nfldl -52(%ebp)\nmovswl -28(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfsubp %st(1),%st\nfstpl -52(%ebp)\nfldl .LC1299\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1302\nmovl $142,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1304\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1304:\n.LC1302:\nfldl .LC889\nfstpl -52(%ebp)\nmovl $2,-32(%ebp)\nfldl -52(%ebp)\nfisubl -32(%ebp)\nfstpl -52(%ebp)\nfldl .LC1299\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1306\nmovl $143,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1308\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1308:\n.LC1306:\nfldl .LC889\nfstpl -52(%ebp)\nmovl $2,-36(%ebp)\nfldl -52(%ebp)\nfisubl -36(%ebp)\nfstpl -52(%ebp)\nfldl .LC1299\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1310\nmovl $144,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1312\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1312:\n.LC1310:\nfldl .LC889\nfstpl -52(%ebp)\nmovl $2,-40(%ebp)\nmovl -40(%ebp),%edi\nfldl -52(%ebp)\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nfsubp %st(1),%st\nfstpl -52(%ebp)\nfldl .LC1299\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1314\nmovl $145,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1316\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1316:\n.LC1314:\nfldl .LC889\nfstpl -52(%ebp)\nflds .LC544\nfstps -56(%ebp)\nfldl -52(%ebp)\nfsubs -56(%ebp)\nfstpl -52(%ebp)\nfldl .LC1299\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1318\nmovl $146,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1320\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1320:\n.LC1318:\nfldl .LC889\nfstpl -52(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nfldl -52(%ebp)\nfsubl -64(%ebp)\nfstpl -52(%ebp)\nfldl .LC1299\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1322\nmovl $147,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1324\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1324:\n.LC1322:\nmovb $5,-9(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -9(%ebp),%edi\nmovsbl -25(%ebp),%esi\nimull %esi,%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $10,%edi\nje .LC1326\nmovl $148,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1328\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1328:\n.LC1326:\nmovb $5,-9(%ebp)\nmovw $2,-28(%ebp)\nmovsbl -9(%ebp),%edi\nmovswl -28(%ebp),%esi\nimull %esi,%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $10,%edi\nje .LC1330\nmovl $149,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1332\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1332:\n.LC1330:\nmovb $5,-9(%ebp)\nmovl $2,-32(%ebp)\nmovsbl -9(%ebp),%edi\nimull -32(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $10,%edi\nje .LC1334\nmovl $150,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1336\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1336:\n.LC1334:\nmovb $5,-9(%ebp)\nmovl $2,-36(%ebp)\nmovsbl -9(%ebp),%edi\nimull -36(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $10,%edi\nje .LC1338\nmovl $151,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1340\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1340:\n.LC1338:\nmovb $5,-9(%ebp)\nmovl $2,-40(%ebp)\nmovsbl -9(%ebp),%edi\nmovl %edi,%eax\nmull -40(%ebp)\nmovl %eax,%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $10,%edi\nje .LC1342\nmovl $152,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1344\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1344:\n.LC1342:\nmovb $5,-9(%ebp)\nflds .LC544\nfstps -56(%ebp)\nmovsbl -9(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfmuls -56(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $10,%edi\nje .LC1346\nmovl $153,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1348\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1348:\n.LC1346:\nmovb $5,-9(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nmovsbl -9(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfmull -64(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $10,%edi\nje .LC1350\nmovl $154,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1352\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1352:\n.LC1350:\nmovw $5,-12(%ebp)\nmovb $2,-25(%ebp)\nmovswl -12(%ebp),%edi\nmovsbl -25(%ebp),%esi\nimull %esi,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $10,%edi\nje .LC1354\nmovl $155,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1356\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1356:\n.LC1354:\nmovw $5,-12(%ebp)\nmovw $2,-28(%ebp)\nmovswl -12(%ebp),%edi\nmovswl -28(%ebp),%esi\nimull %esi,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $10,%edi\nje .LC1358\nmovl $156,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1360\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1360:\n.LC1358:\nmovw $5,-12(%ebp)\nmovl $2,-32(%ebp)\nmovswl -12(%ebp),%edi\nimull -32(%ebp),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $10,%edi\nje .LC1362\nmovl $157,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1364\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1364:\n.LC1362:\nmovw $5,-12(%ebp)\nmovl $2,-36(%ebp)\nmovswl -12(%ebp),%edi\nimull -36(%ebp),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $10,%edi\nje .LC1366\nmovl $158,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1368\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1368:\n.LC1366:\nmovw $5,-12(%ebp)\nmovl $2,-40(%ebp)\nmovswl -12(%ebp),%edi\nmovl %edi,%eax\nmull -40(%ebp)\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $10,%edi\nje .LC1370\nmovl $159,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1372\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1372:\n.LC1370:\nmovw $5,-12(%ebp)\nflds .LC544\nfstps -56(%ebp)\nmovswl -12(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfmuls -56(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $10,%edi\nje .LC1374\nmovl $160,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1376\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1376:\n.LC1374:\nmovw $5,-12(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nmovswl -12(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfmull -64(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $10,%edi\nje .LC1378\nmovl $161,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1380\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1380:\n.LC1378:\nmovl $5,-16(%ebp)\nmovb $2,-25(%ebp)\nmovl -16(%ebp),%edi\nmovsbl -25(%ebp),%esi\nimull %esi,%edi\nmovl %edi,-16(%ebp)\ncmpl $10,-16(%ebp)\nje .LC1382\nmovl $162,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1384\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1384:\n.LC1382:\nmovl $5,-16(%ebp)\nmovw $2,-28(%ebp)\nmovl -16(%ebp),%edi\nmovswl -28(%ebp),%esi\nimull %esi,%edi\nmovl %edi,-16(%ebp)\ncmpl $10,-16(%ebp)\nje .LC1386\nmovl $163,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1388\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1388:\n.LC1386:\nmovl $5,-16(%ebp)\nmovl $2,-32(%ebp)\nmovl -16(%ebp),%edi\nimull -32(%ebp),%edi\nmovl %edi,-16(%ebp)\ncmpl $10,-16(%ebp)\nje .LC1390\nmovl $164,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1392\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1392:\n.LC1390:\nmovl $5,-16(%ebp)\nmovl $2,-36(%ebp)\nmovl -16(%ebp),%edi\nimull -36(%ebp),%edi\nmovl %edi,-16(%ebp)\ncmpl $10,-16(%ebp)\nje .LC1394\nmovl $165,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1396\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1396:\n.LC1394:\nmovl $5,-16(%ebp)\nmovl $2,-40(%ebp)\nmovl -16(%ebp),%edi\nmovl %edi,%eax\nmull -40(%ebp)\nmovl %eax,%edi\nmovl %edi,-16(%ebp)\ncmpl $10,-16(%ebp)\nje .LC1398\nmovl $166,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1400\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1400:\n.LC1398:\nmovl $5,-16(%ebp)\nflds .LC544\nfstps -56(%ebp)\nfildl -16(%ebp)\nfmuls -56(%ebp)\nfistpl -16(%ebp)\ncmpl $10,-16(%ebp)\nje .LC1402\nmovl $167,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1404\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1404:\n.LC1402:\nmovl $5,-16(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nfildl -16(%ebp)\nfmull -64(%ebp)\nfistpl -16(%ebp)\ncmpl $10,-16(%ebp)\nje .LC1406\nmovl $168,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1408\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1408:\n.LC1406:\nmovl $5,-20(%ebp)\nmovb $2,-25(%ebp)\nmovl -20(%ebp),%edi\nmovsbl -25(%ebp),%esi\nimull %esi,%edi\nmovl %edi,-20(%ebp)\ncmpl $10,-20(%ebp)\nje .LC1410\nmovl $169,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1412\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1412:\n.LC1410:\nmovl $5,-20(%ebp)\nmovw $2,-28(%ebp)\nmovl -20(%ebp),%edi\nmovswl -28(%ebp),%esi\nimull %esi,%edi\nmovl %edi,-20(%ebp)\ncmpl $10,-20(%ebp)\nje .LC1414\nmovl $170,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1416\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1416:\n.LC1414:\nmovl $5,-20(%ebp)\nmovl $2,-32(%ebp)\nmovl -20(%ebp),%edi\nimull -32(%ebp),%edi\nmovl %edi,-20(%ebp)\ncmpl $10,-20(%ebp)\nje .LC1418\nmovl $171,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1420\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1420:\n.LC1418:\nmovl $5,-20(%ebp)\nmovl $2,-36(%ebp)\nmovl -20(%ebp),%edi\nimull -36(%ebp),%edi\nmovl %edi,-20(%ebp)\ncmpl $10,-20(%ebp)\nje .LC1422\nmovl $172,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1424\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1424:\n.LC1422:\nmovl $5,-20(%ebp)\nmovl $2,-40(%ebp)\nmovl -20(%ebp),%edi\nmovl %edi,%eax\nmull -40(%ebp)\nmovl %eax,%edi\nmovl %edi,-20(%ebp)\ncmpl $10,-20(%ebp)\nje .LC1426\nmovl $173,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1428\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1428:\n.LC1426:\nmovl $5,-20(%ebp)\nflds .LC544\nfstps -56(%ebp)\nfildl -20(%ebp)\nfmuls -56(%ebp)\nfistpl -20(%ebp)\ncmpl $10,-20(%ebp)\nje .LC1430\nmovl $174,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1432\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1432:\n.LC1430:\nmovl $5,-20(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nfildl -20(%ebp)\nfmull -64(%ebp)\nfistpl -20(%ebp)\ncmpl $10,-20(%ebp)\nje .LC1434\nmovl $175,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1436\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1436:\n.LC1434:\nmovl $5,-24(%ebp)\nmovb $2,-25(%ebp)\nmovl -24(%ebp),%eax\nmovsbl -25(%ebp),%edi\nmull %edi\nmovl %eax,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $10,%edi\nje .LC1438\nmovl $176,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1440\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1440:\n.LC1438:\nmovl $5,-24(%ebp)\nmovw $2,-28(%ebp)\nmovl -24(%ebp),%eax\nmovswl -28(%ebp),%edi\nmull %edi\nmovl %eax,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $10,%edi\nje .LC1442\nmovl $177,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1444\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1444:\n.LC1442:\nmovl $5,-24(%ebp)\nmovl $2,-32(%ebp)\nmovl -24(%ebp),%eax\nmovl -32(%ebp),%edi\nmull %edi\nmovl %eax,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $10,%edi\nje .LC1446\nmovl $178,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1448\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1448:\n.LC1446:\nmovl $5,-24(%ebp)\nmovl $2,-36(%ebp)\nmovl -24(%ebp),%eax\nmovl -36(%ebp),%edi\nmull %edi\nmovl %eax,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $10,%edi\nje .LC1450\nmovl $179,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1452\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1452:\n.LC1450:\nmovl $5,-24(%ebp)\nmovl $2,-40(%ebp)\nmovl -24(%ebp),%eax\nmull -40(%ebp)\nmovl %eax,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $10,%edi\nje .LC1454\nmovl $180,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1456\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1456:\n.LC1454:\nmovl $5,-24(%ebp)\nflds .LC544\nfstps -56(%ebp)\nmovl -24(%ebp),%edi\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nsub $4,%esp\nfstps (%esp)\nflds (%esp)\naddl $4,%esp\nfmuls -56(%ebp)\nfstps -192(%ebp)\nflds .LC847\nfcomps -192(%ebp)\nfstsw %ax\nsahf\nja .LC1459\nflds -192(%ebp)\nfsubs .LC847\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-188(%ebp)\njmp .LC1460\n.LC1459:\nflds -192(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-188(%ebp)\n.LC1460:\nmovl -188(%ebp),%edi\nmovl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $10,%edi\nje .LC1461\nmovl $181,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1463\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1463:\n.LC1461:\nmovl $5,-24(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nmovl -24(%ebp),%edi\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nfmull -64(%ebp)\nfstpl -208(%ebp)\nfldl .LC855\nfcompl -208(%ebp)\nfstsw %ax\nsahf\nja .LC1466\nfldl -208(%ebp)\nfsubl .LC855\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-200(%ebp)\njmp .LC1467\n.LC1466:\nfldl -208(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-200(%ebp)\n.LC1467:\nmovl -200(%ebp),%edi\nmovl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $10,%edi\nje .LC1468\nmovl $182,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1470\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1470:\n.LC1468:\nflds .LC860\nfstps -44(%ebp)\nmovb $2,-25(%ebp)\nflds -44(%ebp)\nmovsbl -25(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nfstps -44(%ebp)\nflds .LC1474\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1472\nmovl $183,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1475\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1475:\n.LC1472:\nflds .LC860\nfstps -44(%ebp)\nmovw $2,-28(%ebp)\nflds -44(%ebp)\nmovswl -28(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nfstps -44(%ebp)\nflds .LC1474\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1477\nmovl $184,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1479\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1479:\n.LC1477:\nflds .LC860\nfstps -44(%ebp)\nmovl $2,-32(%ebp)\nflds -44(%ebp)\nfildl -32(%ebp)\nfmulp %st(1),%st\nfstps -44(%ebp)\nflds .LC1474\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1481\nmovl $185,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1483\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1483:\n.LC1481:\nflds .LC860\nfstps -44(%ebp)\nmovl $2,-36(%ebp)\nflds -44(%ebp)\nfildl -36(%ebp)\nfmulp %st(1),%st\nfstps -44(%ebp)\nflds .LC1474\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1485\nmovl $186,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1487\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1487:\n.LC1485:\nflds .LC860\nfstps -44(%ebp)\nmovl $2,-40(%ebp)\nmovl -40(%ebp),%edi\nflds -44(%ebp)\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nsub $4,%esp\nfstps (%esp)\nflds (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nfstps -44(%ebp)\nflds .LC1474\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1489\nmovl $187,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1491\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1491:\n.LC1489:\nflds .LC860\nfstps -44(%ebp)\nflds .LC544\nfstps -56(%ebp)\nflds -44(%ebp)\nfmuls -56(%ebp)\nfstps -44(%ebp)\nflds .LC1474\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1493\nmovl $188,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1495\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1495:\n.LC1493:\nflds .LC860\nfstps -44(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nflds -44(%ebp)\nfmull -64(%ebp)\nfstps -44(%ebp)\nflds .LC1474\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1497\nmovl $189,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1499\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1499:\n.LC1497:\nfldl .LC889\nfstpl -52(%ebp)\nmovb $2,-25(%ebp)\nfldl -52(%ebp)\nmovsbl -25(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nfstpl -52(%ebp)\nfldl .LC1503\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1501\nmovl $190,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1504\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1504:\n.LC1501:\nfldl .LC889\nfstpl -52(%ebp)\nmovw $2,-28(%ebp)\nfldl -52(%ebp)\nmovswl -28(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nfstpl -52(%ebp)\nfldl .LC1503\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1506\nmovl $191,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1508\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1508:\n.LC1506:\nfldl .LC889\nfstpl -52(%ebp)\nmovl $2,-32(%ebp)\nfldl -52(%ebp)\nfimull -32(%ebp)\nfstpl -52(%ebp)\nfldl .LC1503\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1510\nmovl $192,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1512\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1512:\n.LC1510:\nfldl .LC889\nfstpl -52(%ebp)\nmovl $2,-36(%ebp)\nfldl -52(%ebp)\nfimull -36(%ebp)\nfstpl -52(%ebp)\nfldl .LC1503\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1514\nmovl $193,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1516\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1516:\n.LC1514:\nfldl .LC889\nfstpl -52(%ebp)\nmovl $2,-40(%ebp)\nmovl -40(%ebp),%edi\nfldl -52(%ebp)\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nfmulp %st(1),%st\nfstpl -52(%ebp)\nfldl .LC1503\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1518\nmovl $194,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1520\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1520:\n.LC1518:\nfldl .LC889\nfstpl -52(%ebp)\nflds .LC544\nfstps -56(%ebp)\nfldl -52(%ebp)\nfmuls -56(%ebp)\nfstpl -52(%ebp)\nfldl .LC1503\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1522\nmovl $195,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1524\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1524:\n.LC1522:\nfldl .LC889\nfstpl -52(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nfldl -52(%ebp)\nfmull -64(%ebp)\nfstpl -52(%ebp)\nfldl .LC1503\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1526\nmovl $196,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1528\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1528:\n.LC1526:\nmovb $5,-9(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -9(%ebp),%eax\nmovsbl -25(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $2,%edi\nje .LC1530\nmovl $197,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1532\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1532:\n.LC1530:\nmovb $5,-9(%ebp)\nmovw $2,-28(%ebp)\nmovsbl -9(%ebp),%eax\nmovswl -28(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $2,%edi\nje .LC1534\nmovl $198,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1536\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1536:\n.LC1534:\nmovb $5,-9(%ebp)\nmovl $2,-32(%ebp)\nmovsbl -9(%ebp),%eax\nmovl -32(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $2,%edi\nje .LC1538\nmovl $199,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1540\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1540:\n.LC1538:\nmovb $5,-9(%ebp)\nmovl $2,-36(%ebp)\nmovsbl -9(%ebp),%eax\nmovl -36(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $2,%edi\nje .LC1542\nmovl $200,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1544\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1544:\n.LC1542:\nmovb $5,-9(%ebp)\nmovl $2,-40(%ebp)\nmovsbl -9(%ebp),%edi\nmovl %edi,%eax\nmovl -40(%ebp),%ecx\nxorl %edx,%edx\ndivl %ecx\nmovl %eax,%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $2,%edi\nje .LC1546\nmovl $201,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1548\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1548:\n.LC1546:\nmovb $5,-9(%ebp)\nflds .LC544\nfstps -56(%ebp)\nmovsbl -9(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfdivs -56(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $2,%edi\nje .LC1550\nmovl $202,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1552\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1552:\n.LC1550:\nmovb $5,-9(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nmovsbl -9(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfdivl -64(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $2,%edi\nje .LC1554\nmovl $203,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1556\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1556:\n.LC1554:\nmovw $5,-12(%ebp)\nmovb $2,-25(%ebp)\nmovswl -12(%ebp),%eax\nmovsbl -25(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $2,%edi\nje .LC1558\nmovl $204,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1560\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1560:\n.LC1558:\nmovw $5,-12(%ebp)\nmovw $2,-28(%ebp)\nmovswl -12(%ebp),%eax\nmovswl -28(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $2,%edi\nje .LC1562\nmovl $205,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1564\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1564:\n.LC1562:\nmovw $5,-12(%ebp)\nmovl $2,-32(%ebp)\nmovswl -12(%ebp),%eax\nmovl -32(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $2,%edi\nje .LC1566\nmovl $206,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1568\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1568:\n.LC1566:\nmovw $5,-12(%ebp)\nmovl $2,-36(%ebp)\nmovswl -12(%ebp),%eax\nmovl -36(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $2,%edi\nje .LC1570\nmovl $207,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1572\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1572:\n.LC1570:\nmovw $5,-12(%ebp)\nmovl $2,-40(%ebp)\nmovswl -12(%ebp),%edi\nmovl %edi,%eax\nmovl -40(%ebp),%ecx\nxorl %edx,%edx\ndivl %ecx\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $2,%edi\nje .LC1574\nmovl $208,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1576\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1576:\n.LC1574:\nmovw $5,-12(%ebp)\nflds .LC544\nfstps -56(%ebp)\nmovswl -12(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfdivs -56(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $2,%edi\nje .LC1578\nmovl $209,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1580\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1580:\n.LC1578:\nmovw $5,-12(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nmovswl -12(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfdivl -64(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $2,%edi\nje .LC1582\nmovl $210,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1584\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1584:\n.LC1582:\nmovl $5,-16(%ebp)\nmovb $2,-25(%ebp)\nmovl -16(%ebp),%eax\nmovsbl -25(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %eax,-16(%ebp)\ncmpl $2,-16(%ebp)\nje .LC1586\nmovl $211,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1588\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1588:\n.LC1586:\nmovl $5,-16(%ebp)\nmovw $2,-28(%ebp)\nmovl -16(%ebp),%eax\nmovswl -28(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %eax,-16(%ebp)\ncmpl $2,-16(%ebp)\nje .LC1590\nmovl $212,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1592\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1592:\n.LC1590:\nmovl $5,-16(%ebp)\nmovl $2,-32(%ebp)\nmovl -16(%ebp),%eax\nmovl -32(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %eax,-16(%ebp)\ncmpl $2,-16(%ebp)\nje .LC1594\nmovl $213,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1596\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1596:\n.LC1594:\nmovl $5,-16(%ebp)\nmovl $2,-36(%ebp)\nmovl -16(%ebp),%eax\nmovl -36(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %eax,-16(%ebp)\ncmpl $2,-16(%ebp)\nje .LC1598\nmovl $214,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1600\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1600:\n.LC1598:\nmovl $5,-16(%ebp)\nmovl $2,-40(%ebp)\nmovl -16(%ebp),%edi\nmovl %edi,%eax\nmovl -40(%ebp),%ecx\nxorl %edx,%edx\ndivl %ecx\nmovl %eax,%edi\nmovl %edi,-16(%ebp)\ncmpl $2,-16(%ebp)\nje .LC1602\nmovl $215,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1604\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1604:\n.LC1602:\nmovl $5,-16(%ebp)\nflds .LC544\nfstps -56(%ebp)\nfildl -16(%ebp)\nfdivs -56(%ebp)\nfistpl -16(%ebp)\ncmpl $2,-16(%ebp)\nje .LC1606\nmovl $216,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1608\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1608:\n.LC1606:\nmovl $5,-16(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nfldl -64(%ebp)\nfidivrl -16(%ebp)\nfistpl -16(%ebp)\ncmpl $2,-16(%ebp)\nje .LC1610\nmovl $217,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1612\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1612:\n.LC1610:\nmovl $5,-20(%ebp)\nmovb $2,-25(%ebp)\nmovl -20(%ebp),%eax\nmovsbl -25(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %eax,-20(%ebp)\ncmpl $2,-20(%ebp)\nje .LC1614\nmovl $218,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1616\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1616:\n.LC1614:\nmovl $5,-20(%ebp)\nmovw $2,-28(%ebp)\nmovl -20(%ebp),%eax\nmovswl -28(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %eax,-20(%ebp)\ncmpl $2,-20(%ebp)\nje .LC1618\nmovl $219,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1620\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1620:\n.LC1618:\nmovl $5,-20(%ebp)\nmovl $2,-32(%ebp)\nmovl -20(%ebp),%eax\nmovl -32(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %eax,-20(%ebp)\ncmpl $2,-20(%ebp)\nje .LC1622\nmovl $220,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1624\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1624:\n.LC1622:\nmovl $5,-20(%ebp)\nmovl $2,-36(%ebp)\nmovl -20(%ebp),%eax\nmovl -36(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %eax,-20(%ebp)\ncmpl $2,-20(%ebp)\nje .LC1626\nmovl $221,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1628\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1628:\n.LC1626:\nmovl $5,-20(%ebp)\nmovl $2,-40(%ebp)\nmovl -20(%ebp),%edi\nmovl %edi,%eax\nmovl -40(%ebp),%ecx\nxorl %edx,%edx\ndivl %ecx\nmovl %eax,%edi\nmovl %edi,-20(%ebp)\ncmpl $2,-20(%ebp)\nje .LC1630\nmovl $222,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1632\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1632:\n.LC1630:\nmovl $5,-20(%ebp)\nflds .LC544\nfstps -56(%ebp)\nfildl -20(%ebp)\nfdivs -56(%ebp)\nfistpl -20(%ebp)\ncmpl $2,-20(%ebp)\nje .LC1634\nmovl $223,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1636\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1636:\n.LC1634:\nmovl $5,-20(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nfldl -64(%ebp)\nfidivrl -20(%ebp)\nfistpl -20(%ebp)\ncmpl $2,-20(%ebp)\nje .LC1638\nmovl $224,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1640\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1640:\n.LC1638:\nmovl $5,-24(%ebp)\nmovb $2,-25(%ebp)\nmovl -24(%ebp),%eax\nmovsbl -25(%ebp),%edi\nmovl %edi,%ecx\nxorl %edx,%edx\ndivl %ecx\nmovl %eax,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $2,%edi\nje .LC1642\nmovl $225,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1644\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1644:\n.LC1642:\nmovl $5,-24(%ebp)\nmovw $2,-28(%ebp)\nmovl -24(%ebp),%eax\nmovswl -28(%ebp),%edi\nmovl %edi,%ecx\nxorl %edx,%edx\ndivl %ecx\nmovl %eax,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $2,%edi\nje .LC1646\nmovl $226,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1648\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1648:\n.LC1646:\nmovl $5,-24(%ebp)\nmovl $2,-32(%ebp)\nmovl -24(%ebp),%eax\nmovl -32(%ebp),%edi\nmovl %edi,%ecx\nxorl %edx,%edx\ndivl %ecx\nmovl %eax,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $2,%edi\nje .LC1650\nmovl $227,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1652\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1652:\n.LC1650:\nmovl $5,-24(%ebp)\nmovl $2,-36(%ebp)\nmovl -24(%ebp),%eax\nmovl -36(%ebp),%edi\nmovl %edi,%ecx\nxorl %edx,%edx\ndivl %ecx\nmovl %eax,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $2,%edi\nje .LC1654\nmovl $228,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1656\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1656:\n.LC1654:\nmovl $5,-24(%ebp)\nmovl $2,-40(%ebp)\nmovl -24(%ebp),%eax\nmovl -40(%ebp),%ecx\nxorl %edx,%edx\ndivl %ecx\nmovl %eax,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $2,%edi\nje .LC1658\nmovl $229,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1660\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1660:\n.LC1658:\nmovl $5,-24(%ebp)\nflds .LC544\nfstps -56(%ebp)\nmovl -24(%ebp),%edi\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nsub $4,%esp\nfstps (%esp)\nflds (%esp)\naddl $4,%esp\nfdivs -56(%ebp)\nfstps -224(%ebp)\nflds .LC847\nfcomps -224(%ebp)\nfstsw %ax\nsahf\nja .LC1663\nflds -224(%ebp)\nfsubs .LC847\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-220(%ebp)\njmp .LC1664\n.LC1663:\nflds -224(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-220(%ebp)\n.LC1664:\nmovl -220(%ebp),%edi\nmovl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $2,%edi\nje .LC1665\nmovl $230,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1667\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1667:\n.LC1665:\nmovl $5,-24(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nmovl -24(%ebp),%edi\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nfdivl -64(%ebp)\nfstpl -240(%ebp)\nfldl .LC855\nfcompl -240(%ebp)\nfstsw %ax\nsahf\nja .LC1670\nfldl -240(%ebp)\nfsubl .LC855\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-232(%ebp)\njmp .LC1671\n.LC1670:\nfldl -240(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-232(%ebp)\n.LC1671:\nmovl -232(%ebp),%edi\nmovl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $2,%edi\nje .LC1672\nmovl $231,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1674\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1674:\n.LC1672:\nflds .LC860\nfstps -44(%ebp)\nmovb $2,-25(%ebp)\nflds -44(%ebp)\nmovsbl -25(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfdivp %st(1),%st\nfstps -44(%ebp)\nfldl .LC1678\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1676\nmovl $232,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1679\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1679:\n.LC1676:\nflds .LC860\nfstps -44(%ebp)\nmovw $2,-28(%ebp)\nflds -44(%ebp)\nmovswl -28(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfdivp %st(1),%st\nfstps -44(%ebp)\nfldl .LC1678\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1681\nmovl $233,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1683\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1683:\n.LC1681:\nflds .LC860\nfstps -44(%ebp)\nmovl $2,-32(%ebp)\nflds -44(%ebp)\nfildl -32(%ebp)\nfdivp %st(1),%st\nfstps -44(%ebp)\nfldl .LC1678\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1685\nmovl $234,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1687\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1687:\n.LC1685:\nflds .LC860\nfstps -44(%ebp)\nmovl $2,-36(%ebp)\nflds -44(%ebp)\nfildl -36(%ebp)\nfdivp %st(1),%st\nfstps -44(%ebp)\nfldl .LC1678\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1689\nmovl $235,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1691\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1691:\n.LC1689:\nflds .LC860\nfstps -44(%ebp)\nmovl $2,-40(%ebp)\nmovl -40(%ebp),%edi\nflds -44(%ebp)\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nsub $4,%esp\nfstps (%esp)\nflds (%esp)\naddl $4,%esp\nfdivp %st(1),%st\nfstps -44(%ebp)\nfldl .LC1678\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1693\nmovl $236,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1695\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1695:\n.LC1693:\nflds .LC860\nfstps -44(%ebp)\nflds .LC544\nfstps -56(%ebp)\nflds -44(%ebp)\nfdivs -56(%ebp)\nfstps -44(%ebp)\nfldl .LC1678\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1697\nmovl $237,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1699\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1699:\n.LC1697:\nflds .LC860\nfstps -44(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nflds -44(%ebp)\nfdivl -64(%ebp)\nfstps -44(%ebp)\nfldl .LC1678\nfcomps -44(%ebp)\nfstsw %ax\nsahf\nje .LC1701\nmovl $238,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1703\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1703:\n.LC1701:\nfldl .LC889\nfstpl -52(%ebp)\nmovb $2,-25(%ebp)\nfldl -52(%ebp)\nmovsbl -25(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfdivp %st(1),%st\nfstpl -52(%ebp)\nfldl .LC1678\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1705\nmovl $239,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1707\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1707:\n.LC1705:\nfldl .LC889\nfstpl -52(%ebp)\nmovw $2,-28(%ebp)\nfldl -52(%ebp)\nmovswl -28(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfdivp %st(1),%st\nfstpl -52(%ebp)\nfldl .LC1678\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1709\nmovl $240,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1711\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1711:\n.LC1709:\nfldl .LC889\nfstpl -52(%ebp)\nmovl $2,-32(%ebp)\nfldl -52(%ebp)\nfidivl -32(%ebp)\nfstpl -52(%ebp)\nfldl .LC1678\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1713\nmovl $241,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1715\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1715:\n.LC1713:\nfldl .LC889\nfstpl -52(%ebp)\nmovl $2,-36(%ebp)\nfldl -52(%ebp)\nfidivl -36(%ebp)\nfstpl -52(%ebp)\nfldl .LC1678\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1717\nmovl $242,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1719\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1719:\n.LC1717:\nfldl .LC889\nfstpl -52(%ebp)\nmovl $2,-40(%ebp)\nmovl -40(%ebp),%edi\nfldl -52(%ebp)\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nfdivp %st(1),%st\nfstpl -52(%ebp)\nfldl .LC1678\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1721\nmovl $243,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1723\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1723:\n.LC1721:\nfldl .LC889\nfstpl -52(%ebp)\nflds .LC544\nfstps -56(%ebp)\nfldl -52(%ebp)\nfdivs -56(%ebp)\nfstpl -52(%ebp)\nfldl .LC1678\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1725\nmovl $244,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1727\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1727:\n.LC1725:\nfldl .LC889\nfstpl -52(%ebp)\nfldl .LC425\nfstpl -64(%ebp)\nfldl -52(%ebp)\nfdivl -64(%ebp)\nfstpl -52(%ebp)\nfldl .LC1678\nfcompl -52(%ebp)\nfstsw %ax\nsahf\nje .LC1729\nmovl $245,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1731\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1731:\n.LC1729:\nmovb $5,-9(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -9(%ebp),%eax\nmovsbl -25(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %edx,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $1,%edi\nje .LC1733\nmovl $246,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1735\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1735:\n.LC1733:\nmovb $5,-9(%ebp)\nmovw $2,-28(%ebp)\nmovsbl -9(%ebp),%eax\nmovswl -28(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %edx,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $1,%edi\nje .LC1737\nmovl $247,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1739\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1739:\n.LC1737:\nmovb $5,-9(%ebp)\nmovl $2,-32(%ebp)\nmovsbl -9(%ebp),%eax\nmovl -32(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %edx,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $1,%edi\nje .LC1741\nmovl $248,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1743\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1743:\n.LC1741:\nmovb $5,-9(%ebp)\nmovl $2,-36(%ebp)\nmovsbl -9(%ebp),%eax\nmovl -36(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %edx,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $1,%edi\nje .LC1745\nmovl $249,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1747\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1747:\n.LC1745:\nmovb $5,-9(%ebp)\nmovl $2,-40(%ebp)\nmovsbl -9(%ebp),%edi\nmovl %edi,%eax\nmovl -40(%ebp),%ecx\nxorl %edx,%edx\ndivl %ecx\nmovl %edx,%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $1,%edi\nje .LC1749\nmovl $250,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1751\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1751:\n.LC1749:\nmovw $5,-12(%ebp)\nmovb $2,-25(%ebp)\nmovswl -12(%ebp),%eax\nmovsbl -25(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %edx,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $1,%edi\nje .LC1753\nmovl $251,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1755\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1755:\n.LC1753:\nmovw $5,-12(%ebp)\nmovw $2,-28(%ebp)\nmovswl -12(%ebp),%eax\nmovswl -28(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %edx,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $1,%edi\nje .LC1757\nmovl $252,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1759\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1759:\n.LC1757:\nmovw $5,-12(%ebp)\nmovl $2,-32(%ebp)\nmovswl -12(%ebp),%eax\nmovl -32(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %edx,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $1,%edi\nje .LC1761\nmovl $253,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1763\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1763:\n.LC1761:\nmovw $5,-12(%ebp)\nmovl $2,-36(%ebp)\nmovswl -12(%ebp),%eax\nmovl -36(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %edx,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $1,%edi\nje .LC1765\nmovl $254,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1767\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1767:\n.LC1765:\nmovw $5,-12(%ebp)\nmovl $2,-40(%ebp)\nmovswl -12(%ebp),%edi\nmovl %edi,%eax\nmovl -40(%ebp),%ecx\nxorl %edx,%edx\ndivl %ecx\nmovl %edx,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $1,%edi\nje .LC1769\nmovl $255,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1771\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1771:\n.LC1769:\nmovl $5,-16(%ebp)\nmovb $2,-25(%ebp)\nmovl -16(%ebp),%eax\nmovsbl -25(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %edx,-16(%ebp)\ncmpl $1,-16(%ebp)\nje .LC1773\nmovl $256,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1775\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1775:\n.LC1773:\nmovl $5,-16(%ebp)\nmovw $2,-28(%ebp)\nmovl -16(%ebp),%eax\nmovswl -28(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %edx,-16(%ebp)\ncmpl $1,-16(%ebp)\nje .LC1777\nmovl $257,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1779\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1779:\n.LC1777:\nmovl $5,-16(%ebp)\nmovl $2,-32(%ebp)\nmovl -16(%ebp),%eax\nmovl -32(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %edx,-16(%ebp)\ncmpl $1,-16(%ebp)\nje .LC1781\nmovl $258,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1783\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1783:\n.LC1781:\nmovl $5,-16(%ebp)\nmovl $2,-36(%ebp)\nmovl -16(%ebp),%eax\nmovl -36(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %edx,-16(%ebp)\ncmpl $1,-16(%ebp)\nje .LC1785\nmovl $259,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1787\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1787:\n.LC1785:\nmovl $5,-16(%ebp)\nmovl $2,-40(%ebp)\nmovl -16(%ebp),%edi\nmovl %edi,%eax\nmovl -40(%ebp),%ecx\nxorl %edx,%edx\ndivl %ecx\nmovl %edx,%edi\nmovl %edi,-16(%ebp)\ncmpl $1,-16(%ebp)\nje .LC1789\nmovl $260,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1791\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1791:\n.LC1789:\nmovl $5,-20(%ebp)\nmovb $2,-25(%ebp)\nmovl -20(%ebp),%eax\nmovsbl -25(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %edx,-20(%ebp)\ncmpl $1,-20(%ebp)\nje .LC1793\nmovl $261,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1795\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1795:\n.LC1793:\nmovl $5,-20(%ebp)\nmovw $2,-28(%ebp)\nmovl -20(%ebp),%eax\nmovswl -28(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %edx,-20(%ebp)\ncmpl $1,-20(%ebp)\nje .LC1797\nmovl $262,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1799\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1799:\n.LC1797:\nmovl $5,-20(%ebp)\nmovl $2,-32(%ebp)\nmovl -20(%ebp),%eax\nmovl -32(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %edx,-20(%ebp)\ncmpl $1,-20(%ebp)\nje .LC1801\nmovl $263,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1803\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1803:\n.LC1801:\nmovl $5,-20(%ebp)\nmovl $2,-36(%ebp)\nmovl -20(%ebp),%eax\nmovl -36(%ebp),%ecx\ncdq\nidivl %ecx\nmovl %edx,-20(%ebp)\ncmpl $1,-20(%ebp)\nje .LC1805\nmovl $264,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1807\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1807:\n.LC1805:\nmovl $5,-20(%ebp)\nmovl $2,-40(%ebp)\nmovl -20(%ebp),%edi\nmovl %edi,%eax\nmovl -40(%ebp),%ecx\nxorl %edx,%edx\ndivl %ecx\nmovl %edx,%edi\nmovl %edi,-20(%ebp)\ncmpl $1,-20(%ebp)\nje .LC1809\nmovl $265,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1811\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1811:\n.LC1809:\nmovl $5,-24(%ebp)\nmovb $2,-25(%ebp)\nmovl -24(%ebp),%eax\nmovsbl -25(%ebp),%edi\nmovl %edi,%ecx\nxorl %edx,%edx\ndivl %ecx\nmovl %edx,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $1,%edi\nje .LC1813\nmovl $266,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1815\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1815:\n.LC1813:\nmovl $5,-24(%ebp)\nmovw $2,-28(%ebp)\nmovl -24(%ebp),%eax\nmovswl -28(%ebp),%edi\nmovl %edi,%ecx\nxorl %edx,%edx\ndivl %ecx\nmovl %edx,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $1,%edi\nje .LC1817\nmovl $267,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1819\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1819:\n.LC1817:\nmovl $5,-24(%ebp)\nmovl $2,-32(%ebp)\nmovl -24(%ebp),%eax\nmovl -32(%ebp),%edi\nmovl %edi,%ecx\nxorl %edx,%edx\ndivl %ecx\nmovl %edx,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $1,%edi\nje .LC1821\nmovl $268,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1823\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1823:\n.LC1821:\nmovl $5,-24(%ebp)\nmovl $2,-36(%ebp)\nmovl -24(%ebp),%eax\nmovl -36(%ebp),%edi\nmovl %edi,%ecx\nxorl %edx,%edx\ndivl %ecx\nmovl %edx,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $1,%edi\nje .LC1825\nmovl $269,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1827\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1827:\n.LC1825:\nmovl $5,-24(%ebp)\nmovl $2,-40(%ebp)\nmovl -24(%ebp),%eax\nmovl -40(%ebp),%ecx\nxorl %edx,%edx\ndivl %ecx\nmovl %edx,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $1,%edi\nje .LC1829\nmovl $270,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1831\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1831:\n.LC1829:\nmovb $5,-9(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -9(%ebp),%edi\nmovsbl -25(%ebp),%ecx\nmovl %edi,%eax\nsarl %cl,%eax\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $1,%edi\nje .LC1833\nmovl $271,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1835\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1835:\n.LC1833:\nmovb $5,-9(%ebp)\nmovw $2,-28(%ebp)\nmovsbl -9(%ebp),%edi\nmovswl -28(%ebp),%ecx\nmovl %edi,%eax\nsarl %cl,%eax\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $1,%edi\nje .LC1837\nmovl $272,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1839\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1839:\n.LC1837:\nmovb $5,-9(%ebp)\nmovl $2,-32(%ebp)\nmovsbl -9(%ebp),%edi\nmovl -32(%ebp),%ecx\nmovl %edi,%eax\nsarl %cl,%eax\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $1,%edi\nje .LC1841\nmovl $273,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1843\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1843:\n.LC1841:\nmovb $5,-9(%ebp)\nmovl $2,-36(%ebp)\nmovsbl -9(%ebp),%edi\nmovl -36(%ebp),%ecx\nmovl %edi,%eax\nsarl %cl,%eax\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $1,%edi\nje .LC1845\nmovl $274,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1847\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1847:\n.LC1845:\nmovb $5,-9(%ebp)\nmovl $2,-40(%ebp)\nmovsbl -9(%ebp),%edi\nmovl -40(%ebp),%esi\nmovl %esi,%ecx\nmovl %edi,%eax\nsarl %cl,%eax\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $1,%edi\nje .LC1849\nmovl $275,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1851\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1851:\n.LC1849:\nmovw $5,-12(%ebp)\nmovb $2,-25(%ebp)\nmovswl -12(%ebp),%edi\nmovsbl -25(%ebp),%ecx\nmovl %edi,%eax\nsarl %cl,%eax\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $1,%edi\nje .LC1853\nmovl $276,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1855\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1855:\n.LC1853:\nmovw $5,-12(%ebp)\nmovw $2,-28(%ebp)\nmovswl -12(%ebp),%edi\nmovswl -28(%ebp),%ecx\nmovl %edi,%eax\nsarl %cl,%eax\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $1,%edi\nje .LC1857\nmovl $277,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1859\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1859:\n.LC1857:\nmovw $5,-12(%ebp)\nmovl $2,-32(%ebp)\nmovswl -12(%ebp),%edi\nmovl -32(%ebp),%ecx\nmovl %edi,%eax\nsarl %cl,%eax\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $1,%edi\nje .LC1861\nmovl $278,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1863\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1863:\n.LC1861:\nmovw $5,-12(%ebp)\nmovl $2,-36(%ebp)\nmovswl -12(%ebp),%edi\nmovl -36(%ebp),%ecx\nmovl %edi,%eax\nsarl %cl,%eax\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $1,%edi\nje .LC1865\nmovl $279,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1867\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1867:\n.LC1865:\nmovw $5,-12(%ebp)\nmovl $2,-40(%ebp)\nmovswl -12(%ebp),%edi\nmovl -40(%ebp),%esi\nmovl %esi,%ecx\nmovl %edi,%eax\nsarl %cl,%eax\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $1,%edi\nje .LC1869\nmovl $280,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1871\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1871:\n.LC1869:\nmovl $5,-16(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -25(%ebp),%ecx\nsarl %cl,-16(%ebp)\ncmpl $1,-16(%ebp)\nje .LC1873\nmovl $281,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1875\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1875:\n.LC1873:\nmovl $5,-16(%ebp)\nmovw $2,-28(%ebp)\nmovswl -28(%ebp),%ecx\nsarl %cl,-16(%ebp)\ncmpl $1,-16(%ebp)\nje .LC1877\nmovl $282,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1879\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1879:\n.LC1877:\nmovl $5,-16(%ebp)\nmovl $2,-32(%ebp)\nmovl -32(%ebp),%ecx\nsarl %cl,-16(%ebp)\ncmpl $1,-16(%ebp)\nje .LC1881\nmovl $283,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1883\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1883:\n.LC1881:\nmovl $5,-16(%ebp)\nmovl $2,-36(%ebp)\nmovl -36(%ebp),%ecx\nsarl %cl,-16(%ebp)\ncmpl $1,-16(%ebp)\nje .LC1885\nmovl $284,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1887\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1887:\n.LC1885:\nmovl $5,-16(%ebp)\nmovl $2,-40(%ebp)\nmovl -40(%ebp),%edi\nmovl %edi,%ecx\nsarl %cl,-16(%ebp)\ncmpl $1,-16(%ebp)\nje .LC1889\nmovl $285,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1891\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1891:\n.LC1889:\nmovl $5,-20(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -25(%ebp),%ecx\nsarl %cl,-20(%ebp)\ncmpl $1,-20(%ebp)\nje .LC1893\nmovl $286,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1895\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1895:\n.LC1893:\nmovl $5,-20(%ebp)\nmovw $2,-28(%ebp)\nmovswl -28(%ebp),%ecx\nsarl %cl,-20(%ebp)\ncmpl $1,-20(%ebp)\nje .LC1897\nmovl $287,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1899\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1899:\n.LC1897:\nmovl $5,-20(%ebp)\nmovl $2,-32(%ebp)\nmovl -32(%ebp),%ecx\nsarl %cl,-20(%ebp)\ncmpl $1,-20(%ebp)\nje .LC1901\nmovl $288,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1903\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1903:\n.LC1901:\nmovl $5,-20(%ebp)\nmovl $2,-36(%ebp)\nmovl -36(%ebp),%ecx\nsarl %cl,-20(%ebp)\ncmpl $1,-20(%ebp)\nje .LC1905\nmovl $289,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1907\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1907:\n.LC1905:\nmovl $5,-20(%ebp)\nmovl $2,-40(%ebp)\nmovl -40(%ebp),%edi\nmovl %edi,%ecx\nsarl %cl,-20(%ebp)\ncmpl $1,-20(%ebp)\nje .LC1909\nmovl $290,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1911\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1911:\n.LC1909:\nmovl $5,-24(%ebp)\nmovb $2,-25(%ebp)\nmovl -24(%ebp),%edi\nmovsbl -25(%ebp),%ecx\nmovl %edi,%eax\nshrl %cl,%eax\nmovl %eax,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $1,%edi\nje .LC1913\nmovl $291,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1915\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1915:\n.LC1913:\nmovl $5,-24(%ebp)\nmovw $2,-28(%ebp)\nmovl -24(%ebp),%edi\nmovswl -28(%ebp),%ecx\nmovl %edi,%eax\nshrl %cl,%eax\nmovl %eax,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $1,%edi\nje .LC1917\nmovl $292,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1919\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1919:\n.LC1917:\nmovl $5,-24(%ebp)\nmovl $2,-32(%ebp)\nmovl -24(%ebp),%edi\nmovl -32(%ebp),%ecx\nmovl %edi,%eax\nshrl %cl,%eax\nmovl %eax,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $1,%edi\nje .LC1921\nmovl $293,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1923\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1923:\n.LC1921:\nmovl $5,-24(%ebp)\nmovl $2,-36(%ebp)\nmovl -24(%ebp),%edi\nmovl -36(%ebp),%ecx\nmovl %edi,%eax\nshrl %cl,%eax\nmovl %eax,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $1,%edi\nje .LC1925\nmovl $294,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1927\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1927:\n.LC1925:\nmovl $5,-24(%ebp)\nmovl $2,-40(%ebp)\nmovl -24(%ebp),%edi\nmovl -40(%ebp),%esi\nmovl %esi,%ecx\nmovl %edi,%eax\nshrl %cl,%eax\nmovl %eax,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $1,%edi\nje .LC1929\nmovl $295,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1931\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1931:\n.LC1929:\nmovb $5,-9(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -9(%ebp),%edi\nmovsbl -25(%ebp),%ecx\nmovl %edi,%eax\nsall %cl,%eax\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $20,%edi\nje .LC1933\nmovl $296,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1935\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1935:\n.LC1933:\nmovb $5,-9(%ebp)\nmovw $2,-28(%ebp)\nmovsbl -9(%ebp),%edi\nmovswl -28(%ebp),%ecx\nmovl %edi,%eax\nsall %cl,%eax\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $20,%edi\nje .LC1937\nmovl $297,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1939\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1939:\n.LC1937:\nmovb $5,-9(%ebp)\nmovl $2,-32(%ebp)\nmovsbl -9(%ebp),%edi\nmovl -32(%ebp),%ecx\nmovl %edi,%eax\nsall %cl,%eax\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $20,%edi\nje .LC1941\nmovl $298,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1943\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1943:\n.LC1941:\nmovb $5,-9(%ebp)\nmovl $2,-36(%ebp)\nmovsbl -9(%ebp),%edi\nmovl -36(%ebp),%ecx\nmovl %edi,%eax\nsall %cl,%eax\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $20,%edi\nje .LC1945\nmovl $299,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1947\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1947:\n.LC1945:\nmovb $5,-9(%ebp)\nmovl $2,-40(%ebp)\nmovsbl -9(%ebp),%edi\nmovl -40(%ebp),%esi\nmovl %esi,%ecx\nmovl %edi,%eax\nsall %cl,%eax\nmovl %eax,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $20,%edi\nje .LC1949\nmovl $300,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1951\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1951:\n.LC1949:\nmovw $5,-12(%ebp)\nmovb $2,-25(%ebp)\nmovswl -12(%ebp),%edi\nmovsbl -25(%ebp),%ecx\nmovl %edi,%eax\nsall %cl,%eax\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $20,%edi\nje .LC1953\nmovl $301,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1955\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1955:\n.LC1953:\nmovw $5,-12(%ebp)\nmovw $2,-28(%ebp)\nmovswl -12(%ebp),%edi\nmovswl -28(%ebp),%ecx\nmovl %edi,%eax\nsall %cl,%eax\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $20,%edi\nje .LC1957\nmovl $302,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1959\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1959:\n.LC1957:\nmovw $5,-12(%ebp)\nmovl $2,-32(%ebp)\nmovswl -12(%ebp),%edi\nmovl -32(%ebp),%ecx\nmovl %edi,%eax\nsall %cl,%eax\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $20,%edi\nje .LC1961\nmovl $303,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1963\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1963:\n.LC1961:\nmovw $5,-12(%ebp)\nmovl $2,-36(%ebp)\nmovswl -12(%ebp),%edi\nmovl -36(%ebp),%ecx\nmovl %edi,%eax\nsall %cl,%eax\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $20,%edi\nje .LC1965\nmovl $304,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1967\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1967:\n.LC1965:\nmovw $5,-12(%ebp)\nmovl $2,-40(%ebp)\nmovswl -12(%ebp),%edi\nmovl -40(%ebp),%esi\nmovl %esi,%ecx\nmovl %edi,%eax\nsall %cl,%eax\nmovl %eax,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $20,%edi\nje .LC1969\nmovl $305,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1971\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1971:\n.LC1969:\nmovl $5,-16(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -25(%ebp),%ecx\nsall %cl,-16(%ebp)\ncmpl $20,-16(%ebp)\nje .LC1973\nmovl $306,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1975\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1975:\n.LC1973:\nmovl $5,-16(%ebp)\nmovw $2,-28(%ebp)\nmovswl -28(%ebp),%ecx\nsall %cl,-16(%ebp)\ncmpl $20,-16(%ebp)\nje .LC1977\nmovl $307,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1979\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1979:\n.LC1977:\nmovl $5,-16(%ebp)\nmovl $2,-32(%ebp)\nmovl -32(%ebp),%ecx\nsall %cl,-16(%ebp)\ncmpl $20,-16(%ebp)\nje .LC1981\nmovl $308,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1983\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1983:\n.LC1981:\nmovl $5,-16(%ebp)\nmovl $2,-36(%ebp)\nmovl -36(%ebp),%ecx\nsall %cl,-16(%ebp)\ncmpl $20,-16(%ebp)\nje .LC1985\nmovl $309,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1987\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1987:\n.LC1985:\nmovl $5,-16(%ebp)\nmovl $2,-40(%ebp)\nmovl -40(%ebp),%edi\nmovl %edi,%ecx\nsall %cl,-16(%ebp)\ncmpl $20,-16(%ebp)\nje .LC1989\nmovl $310,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1991\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1991:\n.LC1989:\nmovl $5,-20(%ebp)\nmovb $2,-25(%ebp)\nmovsbl -25(%ebp),%ecx\nsall %cl,-20(%ebp)\ncmpl $20,-20(%ebp)\nje .LC1993\nmovl $311,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1995\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1995:\n.LC1993:\nmovl $5,-20(%ebp)\nmovw $2,-28(%ebp)\nmovswl -28(%ebp),%ecx\nsall %cl,-20(%ebp)\ncmpl $20,-20(%ebp)\nje .LC1997\nmovl $312,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC1999\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC1999:\n.LC1997:\nmovl $5,-20(%ebp)\nmovl $2,-32(%ebp)\nmovl -32(%ebp),%ecx\nsall %cl,-20(%ebp)\ncmpl $20,-20(%ebp)\nje .LC2001\nmovl $313,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2003\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2003:\n.LC2001:\nmovl $5,-20(%ebp)\nmovl $2,-36(%ebp)\nmovl -36(%ebp),%ecx\nsall %cl,-20(%ebp)\ncmpl $20,-20(%ebp)\nje .LC2005\nmovl $314,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2007\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2007:\n.LC2005:\nmovl $5,-20(%ebp)\nmovl $2,-40(%ebp)\nmovl -40(%ebp),%edi\nmovl %edi,%ecx\nsall %cl,-20(%ebp)\ncmpl $20,-20(%ebp)\nje .LC2009\nmovl $315,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2011\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2011:\n.LC2009:\nmovl $5,-24(%ebp)\nmovb $2,-25(%ebp)\nmovl -24(%ebp),%edi\nmovsbl -25(%ebp),%ecx\nmovl %edi,%eax\nshll %cl,%eax\nmovl %eax,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $20,%edi\nje .LC2013\nmovl $316,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2015\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2015:\n.LC2013:\nmovl $5,-24(%ebp)\nmovw $2,-28(%ebp)\nmovl -24(%ebp),%edi\nmovswl -28(%ebp),%ecx\nmovl %edi,%eax\nshll %cl,%eax\nmovl %eax,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $20,%edi\nje .LC2017\nmovl $317,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2019\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2019:\n.LC2017:\nmovl $5,-24(%ebp)\nmovl $2,-32(%ebp)\nmovl -24(%ebp),%edi\nmovl -32(%ebp),%ecx\nmovl %edi,%eax\nshll %cl,%eax\nmovl %eax,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $20,%edi\nje .LC2021\nmovl $318,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2023\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2023:\n.LC2021:\nmovl $5,-24(%ebp)\nmovl $2,-36(%ebp)\nmovl -24(%ebp),%edi\nmovl -36(%ebp),%ecx\nmovl %edi,%eax\nshll %cl,%eax\nmovl %eax,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $20,%edi\nje .LC2025\nmovl $319,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2027\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2027:\n.LC2025:\nmovl $5,-24(%ebp)\nmovl $2,-40(%ebp)\nmovl -24(%ebp),%edi\nmovl -40(%ebp),%esi\nmovl %esi,%ecx\nmovl %edi,%eax\nshll %cl,%eax\nmovl %eax,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $20,%edi\nje .LC2029\nmovl $320,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2031\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2031:\n.LC2029:\nmovb $12,-9(%ebp)\nmovb $10,-25(%ebp)\nmovsbl -9(%ebp),%edi\nmovsbl -25(%ebp),%esi\nandl %esi,%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $8,%edi\nje .LC2033\nmovl $321,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2035\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2035:\n.LC2033:\nmovb $12,-9(%ebp)\nmovw $10,-28(%ebp)\nmovsbl -9(%ebp),%edi\nmovswl -28(%ebp),%esi\nandl %esi,%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $8,%edi\nje .LC2037\nmovl $322,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2039\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2039:\n.LC2037:\nmovb $12,-9(%ebp)\nmovl $10,-32(%ebp)\nmovsbl -9(%ebp),%edi\nandl -32(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $8,%edi\nje .LC2041\nmovl $323,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2043\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2043:\n.LC2041:\nmovb $12,-9(%ebp)\nmovl $10,-36(%ebp)\nmovsbl -9(%ebp),%edi\nandl -36(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $8,%edi\nje .LC2045\nmovl $324,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2047\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2047:\n.LC2045:\nmovb $12,-9(%ebp)\nmovl $10,-40(%ebp)\nmovsbl -9(%ebp),%edi\nandl -40(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $8,%edi\nje .LC2049\nmovl $325,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2051\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2051:\n.LC2049:\nmovw $12,-12(%ebp)\nmovb $10,-25(%ebp)\nmovswl -12(%ebp),%edi\nmovsbl -25(%ebp),%esi\nandl %esi,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $8,%edi\nje .LC2053\nmovl $326,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2055\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2055:\n.LC2053:\nmovw $12,-12(%ebp)\nmovw $10,-28(%ebp)\nmovswl -12(%ebp),%edi\nmovswl -28(%ebp),%esi\nandl %esi,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $8,%edi\nje .LC2057\nmovl $327,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2059\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2059:\n.LC2057:\nmovw $12,-12(%ebp)\nmovl $10,-32(%ebp)\nmovswl -12(%ebp),%edi\nandl -32(%ebp),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $8,%edi\nje .LC2061\nmovl $328,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2063\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2063:\n.LC2061:\nmovw $12,-12(%ebp)\nmovl $10,-36(%ebp)\nmovswl -12(%ebp),%edi\nandl -36(%ebp),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $8,%edi\nje .LC2065\nmovl $329,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2067\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2067:\n.LC2065:\nmovw $12,-12(%ebp)\nmovl $10,-40(%ebp)\nmovswl -12(%ebp),%edi\nandl -40(%ebp),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $8,%edi\nje .LC2069\nmovl $330,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2071\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2071:\n.LC2069:\nmovl $12,-16(%ebp)\nmovb $10,-25(%ebp)\nmovsbl -25(%ebp),%edi\nandl %edi,-16(%ebp)\ncmpl $8,-16(%ebp)\nje .LC2073\nmovl $331,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2075\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2075:\n.LC2073:\nmovl $12,-16(%ebp)\nmovw $10,-28(%ebp)\nmovswl -28(%ebp),%edi\nandl %edi,-16(%ebp)\ncmpl $8,-16(%ebp)\nje .LC2077\nmovl $332,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2079\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2079:\n.LC2077:\nmovl $12,-16(%ebp)\nmovl $10,-32(%ebp)\nmovl -32(%ebp),%edi\nandl %edi,-16(%ebp)\ncmpl $8,-16(%ebp)\nje .LC2081\nmovl $333,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2083\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2083:\n.LC2081:\nmovl $12,-16(%ebp)\nmovl $10,-36(%ebp)\nmovl -36(%ebp),%edi\nandl %edi,-16(%ebp)\ncmpl $8,-16(%ebp)\nje .LC2085\nmovl $334,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2087\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2087:\n.LC2085:\nmovl $12,-16(%ebp)\nmovl $10,-40(%ebp)\nmovl -16(%ebp),%edi\nandl -40(%ebp),%edi\nmovl %edi,-16(%ebp)\ncmpl $8,-16(%ebp)\nje .LC2089\nmovl $335,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2091\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2091:\n.LC2089:\nmovl $12,-20(%ebp)\nmovb $10,-25(%ebp)\nmovsbl -25(%ebp),%edi\nandl %edi,-20(%ebp)\ncmpl $8,-20(%ebp)\nje .LC2093\nmovl $336,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2095\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2095:\n.LC2093:\nmovl $12,-20(%ebp)\nmovw $10,-28(%ebp)\nmovswl -28(%ebp),%edi\nandl %edi,-20(%ebp)\ncmpl $8,-20(%ebp)\nje .LC2097\nmovl $337,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2099\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2099:\n.LC2097:\nmovl $12,-20(%ebp)\nmovl $10,-32(%ebp)\nmovl -32(%ebp),%edi\nandl %edi,-20(%ebp)\ncmpl $8,-20(%ebp)\nje .LC2101\nmovl $338,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2103\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2103:\n.LC2101:\nmovl $12,-20(%ebp)\nmovl $10,-36(%ebp)\nmovl -36(%ebp),%edi\nandl %edi,-20(%ebp)\ncmpl $8,-20(%ebp)\nje .LC2105\nmovl $339,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2107\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2107:\n.LC2105:\nmovl $12,-20(%ebp)\nmovl $10,-40(%ebp)\nmovl -20(%ebp),%edi\nandl -40(%ebp),%edi\nmovl %edi,-20(%ebp)\ncmpl $8,-20(%ebp)\nje .LC2109\nmovl $340,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2111\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2111:\n.LC2109:\nmovl $12,-24(%ebp)\nmovb $10,-25(%ebp)\nmovsbl -25(%ebp),%edi\nandl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $8,%edi\nje .LC2113\nmovl $341,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2115\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2115:\n.LC2113:\nmovl $12,-24(%ebp)\nmovw $10,-28(%ebp)\nmovswl -28(%ebp),%edi\nandl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $8,%edi\nje .LC2117\nmovl $342,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2119\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2119:\n.LC2117:\nmovl $12,-24(%ebp)\nmovl $10,-32(%ebp)\nmovl -32(%ebp),%edi\nandl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $8,%edi\nje .LC2121\nmovl $343,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2123\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2123:\n.LC2121:\nmovl $12,-24(%ebp)\nmovl $10,-36(%ebp)\nmovl -36(%ebp),%edi\nandl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $8,%edi\nje .LC2125\nmovl $344,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2127\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2127:\n.LC2125:\nmovl $12,-24(%ebp)\nmovl $10,-40(%ebp)\nmovl -40(%ebp),%edi\nandl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $8,%edi\nje .LC2129\nmovl $345,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2131\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2131:\n.LC2129:\nmovb $12,-9(%ebp)\nmovb $10,-25(%ebp)\nmovsbl -9(%ebp),%edi\nmovsbl -25(%ebp),%esi\nxorl %esi,%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $6,%edi\nje .LC2133\nmovl $346,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2135\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2135:\n.LC2133:\nmovb $12,-9(%ebp)\nmovw $10,-28(%ebp)\nmovsbl -9(%ebp),%edi\nmovswl -28(%ebp),%esi\nxorl %esi,%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $6,%edi\nje .LC2137\nmovl $347,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2139\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2139:\n.LC2137:\nmovb $12,-9(%ebp)\nmovl $10,-32(%ebp)\nmovsbl -9(%ebp),%edi\nxorl -32(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $6,%edi\nje .LC2141\nmovl $348,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2143\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2143:\n.LC2141:\nmovb $12,-9(%ebp)\nmovl $10,-36(%ebp)\nmovsbl -9(%ebp),%edi\nxorl -36(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $6,%edi\nje .LC2145\nmovl $349,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2147\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2147:\n.LC2145:\nmovb $12,-9(%ebp)\nmovl $10,-40(%ebp)\nmovsbl -9(%ebp),%edi\nxorl -40(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $6,%edi\nje .LC2149\nmovl $350,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2151\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2151:\n.LC2149:\nmovw $12,-12(%ebp)\nmovb $10,-25(%ebp)\nmovswl -12(%ebp),%edi\nmovsbl -25(%ebp),%esi\nxorl %esi,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $6,%edi\nje .LC2153\nmovl $351,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2155\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2155:\n.LC2153:\nmovw $12,-12(%ebp)\nmovw $10,-28(%ebp)\nmovswl -12(%ebp),%edi\nmovswl -28(%ebp),%esi\nxorl %esi,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $6,%edi\nje .LC2157\nmovl $352,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2159\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2159:\n.LC2157:\nmovw $12,-12(%ebp)\nmovl $10,-32(%ebp)\nmovswl -12(%ebp),%edi\nxorl -32(%ebp),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $6,%edi\nje .LC2161\nmovl $353,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2163\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2163:\n.LC2161:\nmovw $12,-12(%ebp)\nmovl $10,-36(%ebp)\nmovswl -12(%ebp),%edi\nxorl -36(%ebp),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $6,%edi\nje .LC2165\nmovl $354,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2167\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2167:\n.LC2165:\nmovw $12,-12(%ebp)\nmovl $10,-40(%ebp)\nmovswl -12(%ebp),%edi\nxorl -40(%ebp),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $6,%edi\nje .LC2169\nmovl $355,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2171\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2171:\n.LC2169:\nmovl $12,-16(%ebp)\nmovb $10,-25(%ebp)\nmovsbl -25(%ebp),%edi\nxorl %edi,-16(%ebp)\ncmpl $6,-16(%ebp)\nje .LC2173\nmovl $356,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2175\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2175:\n.LC2173:\nmovl $12,-16(%ebp)\nmovw $10,-28(%ebp)\nmovswl -28(%ebp),%edi\nxorl %edi,-16(%ebp)\ncmpl $6,-16(%ebp)\nje .LC2177\nmovl $357,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2179\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2179:\n.LC2177:\nmovl $12,-16(%ebp)\nmovl $10,-32(%ebp)\nmovl -32(%ebp),%edi\nxorl %edi,-16(%ebp)\ncmpl $6,-16(%ebp)\nje .LC2181\nmovl $358,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2183\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2183:\n.LC2181:\nmovl $12,-16(%ebp)\nmovl $10,-36(%ebp)\nmovl -36(%ebp),%edi\nxorl %edi,-16(%ebp)\ncmpl $6,-16(%ebp)\nje .LC2185\nmovl $359,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2187\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2187:\n.LC2185:\nmovl $12,-16(%ebp)\nmovl $10,-40(%ebp)\nmovl -16(%ebp),%edi\nxorl -40(%ebp),%edi\nmovl %edi,-16(%ebp)\ncmpl $6,-16(%ebp)\nje .LC2189\nmovl $360,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2191\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2191:\n.LC2189:\nmovl $12,-20(%ebp)\nmovb $10,-25(%ebp)\nmovsbl -25(%ebp),%edi\nxorl %edi,-20(%ebp)\ncmpl $6,-20(%ebp)\nje .LC2193\nmovl $361,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2195\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2195:\n.LC2193:\nmovl $12,-20(%ebp)\nmovw $10,-28(%ebp)\nmovswl -28(%ebp),%edi\nxorl %edi,-20(%ebp)\ncmpl $6,-20(%ebp)\nje .LC2197\nmovl $362,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2199\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2199:\n.LC2197:\nmovl $12,-20(%ebp)\nmovl $10,-32(%ebp)\nmovl -32(%ebp),%edi\nxorl %edi,-20(%ebp)\ncmpl $6,-20(%ebp)\nje .LC2201\nmovl $363,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2203\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2203:\n.LC2201:\nmovl $12,-20(%ebp)\nmovl $10,-36(%ebp)\nmovl -36(%ebp),%edi\nxorl %edi,-20(%ebp)\ncmpl $6,-20(%ebp)\nje .LC2205\nmovl $364,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2207\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2207:\n.LC2205:\nmovl $12,-20(%ebp)\nmovl $10,-40(%ebp)\nmovl -20(%ebp),%edi\nxorl -40(%ebp),%edi\nmovl %edi,-20(%ebp)\ncmpl $6,-20(%ebp)\nje .LC2209\nmovl $365,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2211\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2211:\n.LC2209:\nmovl $12,-24(%ebp)\nmovb $10,-25(%ebp)\nmovsbl -25(%ebp),%edi\nxorl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $6,%edi\nje .LC2213\nmovl $366,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2215\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2215:\n.LC2213:\nmovl $12,-24(%ebp)\nmovw $10,-28(%ebp)\nmovswl -28(%ebp),%edi\nxorl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $6,%edi\nje .LC2217\nmovl $367,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2219\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2219:\n.LC2217:\nmovl $12,-24(%ebp)\nmovl $10,-32(%ebp)\nmovl -32(%ebp),%edi\nxorl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $6,%edi\nje .LC2221\nmovl $368,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2223\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2223:\n.LC2221:\nmovl $12,-24(%ebp)\nmovl $10,-36(%ebp)\nmovl -36(%ebp),%edi\nxorl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $6,%edi\nje .LC2225\nmovl $369,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2227\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2227:\n.LC2225:\nmovl $12,-24(%ebp)\nmovl $10,-40(%ebp)\nmovl -40(%ebp),%edi\nxorl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $6,%edi\nje .LC2229\nmovl $370,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2231\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2231:\n.LC2229:\nmovb $12,-9(%ebp)\nmovb $10,-25(%ebp)\nmovsbl -9(%ebp),%edi\nmovsbl -25(%ebp),%esi\norl %esi,%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $14,%edi\nje .LC2233\nmovl $371,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2235\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2235:\n.LC2233:\nmovb $12,-9(%ebp)\nmovw $10,-28(%ebp)\nmovsbl -9(%ebp),%edi\nmovswl -28(%ebp),%esi\norl %esi,%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $14,%edi\nje .LC2237\nmovl $372,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2239\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2239:\n.LC2237:\nmovb $12,-9(%ebp)\nmovl $10,-32(%ebp)\nmovsbl -9(%ebp),%edi\norl -32(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $14,%edi\nje .LC2241\nmovl $373,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2243\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2243:\n.LC2241:\nmovb $12,-9(%ebp)\nmovl $10,-36(%ebp)\nmovsbl -9(%ebp),%edi\norl -36(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $14,%edi\nje .LC2245\nmovl $374,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2247\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2247:\n.LC2245:\nmovb $12,-9(%ebp)\nmovl $10,-40(%ebp)\nmovsbl -9(%ebp),%edi\norl -40(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,-9(%ebp)\nmovsbl -9(%ebp),%edi\ncmpl $14,%edi\nje .LC2249\nmovl $375,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2251\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2251:\n.LC2249:\nmovw $12,-12(%ebp)\nmovb $10,-25(%ebp)\nmovswl -12(%ebp),%edi\nmovsbl -25(%ebp),%esi\norl %esi,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $14,%edi\nje .LC2253\nmovl $376,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2255\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2255:\n.LC2253:\nmovw $12,-12(%ebp)\nmovw $10,-28(%ebp)\nmovswl -12(%ebp),%edi\nmovswl -28(%ebp),%esi\norl %esi,%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $14,%edi\nje .LC2257\nmovl $377,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2259\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2259:\n.LC2257:\nmovw $12,-12(%ebp)\nmovl $10,-32(%ebp)\nmovswl -12(%ebp),%edi\norl -32(%ebp),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $14,%edi\nje .LC2261\nmovl $378,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2263\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2263:\n.LC2261:\nmovw $12,-12(%ebp)\nmovl $10,-36(%ebp)\nmovswl -12(%ebp),%edi\norl -36(%ebp),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $14,%edi\nje .LC2265\nmovl $379,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2267\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2267:\n.LC2265:\nmovw $12,-12(%ebp)\nmovl $10,-40(%ebp)\nmovswl -12(%ebp),%edi\norl -40(%ebp),%edi\nmovw %di,-12(%ebp)\nmovswl -12(%ebp),%edi\ncmpl $14,%edi\nje .LC2269\nmovl $380,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2271\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2271:\n.LC2269:\nmovl $12,-16(%ebp)\nmovb $10,-25(%ebp)\nmovsbl -25(%ebp),%edi\norl %edi,-16(%ebp)\ncmpl $14,-16(%ebp)\nje .LC2273\nmovl $381,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2275\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2275:\n.LC2273:\nmovl $12,-16(%ebp)\nmovw $10,-28(%ebp)\nmovswl -28(%ebp),%edi\norl %edi,-16(%ebp)\ncmpl $14,-16(%ebp)\nje .LC2277\nmovl $382,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2279\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2279:\n.LC2277:\nmovl $12,-16(%ebp)\nmovl $10,-32(%ebp)\nmovl -32(%ebp),%edi\norl %edi,-16(%ebp)\ncmpl $14,-16(%ebp)\nje .LC2281\nmovl $383,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2283\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2283:\n.LC2281:\nmovl $12,-16(%ebp)\nmovl $10,-36(%ebp)\nmovl -36(%ebp),%edi\norl %edi,-16(%ebp)\ncmpl $14,-16(%ebp)\nje .LC2285\nmovl $384,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2287\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2287:\n.LC2285:\nmovl $12,-16(%ebp)\nmovl $10,-40(%ebp)\nmovl -16(%ebp),%edi\norl -40(%ebp),%edi\nmovl %edi,-16(%ebp)\ncmpl $14,-16(%ebp)\nje .LC2289\nmovl $385,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2291\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2291:\n.LC2289:\nmovl $12,-20(%ebp)\nmovb $10,-25(%ebp)\nmovsbl -25(%ebp),%edi\norl %edi,-20(%ebp)\ncmpl $14,-20(%ebp)\nje .LC2293\nmovl $386,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2295\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2295:\n.LC2293:\nmovl $12,-20(%ebp)\nmovw $10,-28(%ebp)\nmovswl -28(%ebp),%edi\norl %edi,-20(%ebp)\ncmpl $14,-20(%ebp)\nje .LC2297\nmovl $387,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2299\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2299:\n.LC2297:\nmovl $12,-20(%ebp)\nmovl $10,-32(%ebp)\nmovl -32(%ebp),%edi\norl %edi,-20(%ebp)\ncmpl $14,-20(%ebp)\nje .LC2301\nmovl $388,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2303\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2303:\n.LC2301:\nmovl $12,-20(%ebp)\nmovl $10,-36(%ebp)\nmovl -36(%ebp),%edi\norl %edi,-20(%ebp)\ncmpl $14,-20(%ebp)\nje .LC2305\nmovl $389,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2307\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2307:\n.LC2305:\nmovl $12,-20(%ebp)\nmovl $10,-40(%ebp)\nmovl -20(%ebp),%edi\norl -40(%ebp),%edi\nmovl %edi,-20(%ebp)\ncmpl $14,-20(%ebp)\nje .LC2309\nmovl $390,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2311\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2311:\n.LC2309:\nmovl $12,-24(%ebp)\nmovb $10,-25(%ebp)\nmovsbl -25(%ebp),%edi\norl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $14,%edi\nje .LC2313\nmovl $391,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2315\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2315:\n.LC2313:\nmovl $12,-24(%ebp)\nmovw $10,-28(%ebp)\nmovswl -28(%ebp),%edi\norl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $14,%edi\nje .LC2317\nmovl $392,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2319\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2319:\n.LC2317:\nmovl $12,-24(%ebp)\nmovl $10,-32(%ebp)\nmovl -32(%ebp),%edi\norl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $14,%edi\nje .LC2321\nmovl $393,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2323\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2323:\n.LC2321:\nmovl $12,-24(%ebp)\nmovl $10,-36(%ebp)\nmovl -36(%ebp),%edi\norl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $14,%edi\nje .LC2325\nmovl $394,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2327\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2327:\n.LC2325:\nmovl $12,-24(%ebp)\nmovl $10,-40(%ebp)\nmovl -40(%ebp),%edi\norl %edi,-24(%ebp)\nmovl -24(%ebp),%edi\ncmpl $14,%edi\nje .LC2329\nmovl $395,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2331\npushl -8(%ebp)\npushl $f.706\ncall printf\naddl $8,%esp\n.LC2331:\n.LC2329:\ncmpl $0,-8(%ebp)\nje .LC2333\nmovl $1,-76(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC2335\npushl $1\npushl $s714er.707\ncall printf\naddl $8,%esp\n.LC2335:\n.LC2333:\nmovl -76(%ebp),%eax\n.LC705:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf2337:\n.size s714,.Lf2337-s714\n.data\n.align 1\n.type s715er.2339,@object\ns715er.2339:\n.byte 115\n.byte 55\n.byte 49\n.byte 53\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size s715er.2339,11\n.align 1\n.type qs715.2340,@object\n.size qs715.2340,8\nqs715.2340:\n.byte 115\n.byte 55\n.byte 49\n.byte 53\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s715\n.text\n.align 16\n.type s715,@function\ns715:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $28,%esp\nmovl $0,-28(%ebp)\nmovl $0,-20(%ebp)\nleal qs715.2340,%edi\nmovl %edi,-4(%ebp)\nmovl 20(%ebp),%edi\nleal 60(%edi),%edi\nmovl %edi,-8(%ebp)\nmovl $0,-16(%ebp)\n.LC2341:\n.LC2342:\nmovl -8(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-8(%ebp)\nmovl -4(%ebp),%esi\nleal 1(%esi),%ebx\nmovl %ebx,-4(%ebp)\nmovb (,%esi),%bl\nmovb %bl,(,%edi)\nmovsbl %bl,%edi\ncmpl $0,%edi\njne .LC2341\nmovl $1,-12(%ebp)\nincl -12(%ebp)\nincl -12(%ebp)\nincl -12(%ebp)\nincl -12(%ebp)\nmovl -12(%ebp),%edi\nleal 1(%edi),%edi\nmovl %edi,-12(%ebp)\ncmpl $6,%edi\nje .LC2344\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC2346\npushl $1\npushl $s715er.2339\ncall printf\naddl $8,%esp\n.LC2346:\nincl -16(%ebp)\n.LC2344:\npushl -28(%ebp)\nmovl $3,-24(%ebp)\nmovl -24(%ebp),%edi\nleal 2(%edi),%edi\npushl %edi\npushl -20(%ebp)\ncall s715f\naddl $12,%esp\ncmpl $5,%eax\nje .LC2348\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC2350\npushl $2\npushl $s715er.2339\ncall printf\naddl $8,%esp\n.LC2350:\naddl $2,-16(%ebp)\n.LC2348:\nmovl -16(%ebp),%eax\n.LC2338:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf2352:\n.size s715,.Lf2352-s715\n.globl s715f\n.align 16\n.type s715f,@function\ns715f:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl 24(%ebp),%eax\n.LC2353:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf2354:\n.size s715f,.Lf2354-s715f\n.data\n.align 1\n.type s72er.2356,@object\ns72er.2356:\n.byte 115\n.byte 55\n.byte 50\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size s72er.2356,10\n.align 1\n.type qs72.2357,@object\n.size qs72.2357,8\nqs72.2357:\n.byte 115\n.byte 55\n.byte 50\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s72\n.text\n.align 16\n.type s72,@function\ns72:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $100,%esp\nleal qs72.2357,%edi\nmovl %edi,-12(%ebp)\nmovl 20(%ebp),%edi\nleal 60(%edi),%edi\nmovl %edi,-16(%ebp)\nmovl $0,-24(%ebp)\n.LC2358:\n.LC2359:\nmovl -16(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-16(%ebp)\nmovl -12(%ebp),%esi\nleal 1(%esi),%ebx\nmovl %ebx,-12(%ebp)\nmovb (,%esi),%bl\nmovb %bl,(,%edi)\nmovsbl %bl,%edi\ncmpl $0,%edi\njne .LC2358\nmovl $2,-4(%ebp)\ncmpl $2,-4(%ebp)\nje .LC2361\nincl -24(%ebp)\npushl $1\npushl $s72er.2356\ncall printf\naddl $8,%esp\n.LC2361:\nmovl -4(%ebp),%edi\nmovl %edi,%esi\nnegl %esi\nleal (%esi,%edi),%edi\ncmpl $0,%edi\nje .LC2363\naddl $2,-24(%ebp)\npushl $2\npushl $s72er.2356\ncall printf\naddl $8,%esp\n.LC2363:\nmovl $0,-4(%ebp)\nmovl $0,-8(%ebp)\njmp .LC2368\n.LC2365:\nmovl -4(%ebp),%edi\nleal (,%edi,2),%edi\norl $1,%edi\nmovl %edi,-4(%ebp)\n.LC2366:\nincl -8(%ebp)\n.LC2368:\nmovl 20(%ebp),%edi\nmovl 4(%edi),%edi\ncmpl %edi,-8(%ebp)\njl .LC2365\nmovl -4(%ebp),%edi\nnotl %edi\ncmpl $0,%edi\nje .LC2369\naddl $4,-24(%ebp)\npushl $4\npushl $s72er.2356\ncall printf\naddl $8,%esp\n.LC2369:\nmovl $5,-4(%ebp)\nmovl -4(%ebp),%edi\nleal 1(%edi),%edi\nmovl %edi,-4(%ebp)\ncmpl $6,%edi\njne .LC2376\nmovl -4(%ebp),%edi\nsubl $1,%edi\nmovl %edi,-4(%ebp)\ncmpl $5,%edi\njne .LC2376\nmovl -4(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-4(%ebp)\ncmpl $5,%edi\njne .LC2376\nmovl -4(%ebp),%edi\nmovl %edi,%esi\nsubl $1,%esi\nmovl %esi,-4(%ebp)\ncmpl $6,%edi\njne .LC2376\ncmpl $5,-4(%ebp)\nje .LC2371\n.LC2376:\naddl $8,-24(%ebp)\npushl $8\npushl $s72er.2356\ncall printf\naddl $8,%esp\n.LC2371:\nmovb $26,-29(%ebp)\nmovl $26,-36(%ebp)\nfldl .LC2377\nfstpl -48(%ebp)\nmovw $26,-32(%ebp)\nmovl $26,-40(%ebp)\nmovl $26,-28(%ebp)\nflds .LC2378\nfstps -52(%ebp)\nmovl $0,-20(%ebp)\nmovswl -32(%ebp),%edi\nmovl %edi,%ebx\nmovsbl %bl,%edi\ncmpl $26,%edi\njne .LC2385\nmovl -28(%ebp),%edi\nmovl %edi,%ebx\nmovsbl %bl,%edi\ncmpl $26,%edi\njne .LC2385\nmovl -36(%ebp),%edi\nmovl %edi,%ebx\nmovsbl %bl,%edi\ncmpl $26,%edi\njne .LC2385\nmovl -40(%ebp),%edi\nmovl %edi,%ebx\nmovsbl %bl,%edi\ncmpl $26,%edi\njne .LC2385\nflds -52(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%ebx\nmovsbl %bl,%edi\ncmpl $26,%edi\njne .LC2385\nfldl -48(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%ebx\nmovsbl %bl,%edi\ncmpl $26,%edi\nje .LC2379\n.LC2385:\nincl -20(%ebp)\n.LC2379:\nmovsbl -29(%ebp),%edi\nmovswl %di,%edi\ncmpl $26,%edi\njne .LC2392\nmovl -28(%ebp),%edi\nmovswl %di,%edi\ncmpl $26,%edi\njne .LC2392\nmovl -36(%ebp),%edi\nmovswl %di,%edi\ncmpl $26,%edi\njne .LC2392\nmovl -40(%ebp),%edi\nmovswl %di,%edi\ncmpl $26,%edi\njne .LC2392\nflds -52(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovswl %di,%edi\ncmpl $26,%edi\njne .LC2392\nfldl -48(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovswl %di,%edi\ncmpl $26,%edi\nje .LC2386\n.LC2392:\naddl $2,-20(%ebp)\n.LC2386:\nmovsbl -29(%ebp),%edi\ncmpl $26,%edi\njne .LC2399\nmovswl -32(%ebp),%edi\ncmpl $26,%edi\njne .LC2399\ncmpl $26,-36(%ebp)\njne .LC2399\nmovl -40(%ebp),%edi\ncmpl $26,%edi\njne .LC2399\nflds -52(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\ncmpl $26,%eax\njne .LC2399\nfldl -48(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\ncmpl $26,%eax\nje .LC2393\n.LC2399:\naddl $4,-20(%ebp)\n.LC2393:\nmovsbl -29(%ebp),%edi\ncmpl $26,%edi\njne .LC2406\nmovswl -32(%ebp),%edi\ncmpl $26,%edi\njne .LC2406\ncmpl $26,-28(%ebp)\njne .LC2406\nmovl -40(%ebp),%edi\ncmpl $26,%edi\njne .LC2406\nflds -52(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\ncmpl $26,%eax\njne .LC2406\nfldl -48(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\ncmpl $26,%eax\nje .LC2400\n.LC2406:\naddl $8,-20(%ebp)\n.LC2400:\nmovsbl -29(%ebp),%edi\ncmpl $26,%edi\njne .LC2415\nmovswl -32(%ebp),%edi\ncmpl $26,%edi\njne .LC2415\nmovl -28(%ebp),%edi\ncmpl $26,%edi\njne .LC2415\nmovl -36(%ebp),%edi\ncmpl $26,%edi\njne .LC2415\nflds .LC847\nfcomps -52(%ebp)\nfstsw %ax\nsahf\nja .LC2416\nflds -52(%ebp)\nfsubs .LC847\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-56(%ebp)\njmp .LC2417\n.LC2416:\nflds -52(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-56(%ebp)\n.LC2417:\nmovl -56(%ebp),%edi\ncmpl $26,%edi\njne .LC2415\nfldl .LC855\nfcompl -48(%ebp)\nfstsw %ax\nsahf\nja .LC2418\nfldl -48(%ebp)\nfsubl .LC855\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-60(%ebp)\njmp .LC2419\n.LC2418:\nfldl -48(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-60(%ebp)\n.LC2419:\nmovl -60(%ebp),%edi\ncmpl $26,%edi\nje .LC2407\n.LC2415:\naddl $16,-20(%ebp)\n.LC2407:\nmovsbl -29(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfldl .LC2377\nfcompp\nfstsw %ax\nsahf\njne .LC2426\nmovswl -32(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfldl .LC2377\nfcompp\nfstsw %ax\nsahf\njne .LC2426\nfildl -28(%ebp)\nfldl .LC2377\nfcompp\nfstsw %ax\nsahf\njne .LC2426\nfildl -36(%ebp)\nfldl .LC2377\nfcompp\nfstsw %ax\nsahf\njne .LC2426\nmovl -40(%ebp),%edi\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nsub $4,%esp\nfstps (%esp)\nflds (%esp)\naddl $4,%esp\nfldl .LC2377\nfcompp\nfstsw %ax\nsahf\njne .LC2426\nfldl -48(%ebp)\nfldl .LC2377\nfcompp\nfstsw %ax\nsahf\nje .LC2420\n.LC2426:\naddl $32,-20(%ebp)\n.LC2420:\nmovsbl -29(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfldl .LC2377\nfcompp\nfstsw %ax\nsahf\njne .LC2433\nmovswl -32(%ebp),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfldl .LC2377\nfcompp\nfstsw %ax\nsahf\njne .LC2433\nfildl -28(%ebp)\nfldl .LC2377\nfcompp\nfstsw %ax\nsahf\njne .LC2433\nfildl -36(%ebp)\nfldl .LC2377\nfcompp\nfstsw %ax\nsahf\njne .LC2433\nmovl -40(%ebp),%edi\nfldl .LC611\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nfldl .LC2377\nfcompp\nfstsw %ax\nsahf\njne .LC2433\nfldl .LC2377\nfcomps -52(%ebp)\nfstsw %ax\nsahf\nje .LC2427\n.LC2433:\naddl $64,-20(%ebp)\n.LC2427:\ncmpl $0,-20(%ebp)\nje .LC2434\naddl $16,-24(%ebp)\npushl $16\npushl $s72er.2356\ncall printf\naddl $8,%esp\n.LC2434:\nmovl -24(%ebp),%eax\n.LC2355:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf2436:\n.size s72,.Lf2436-s72\n.data\n.align 1\n.type s757er.2438,@object\ns757er.2438:\n.byte 115\n.byte 55\n.byte 53\n.byte 55\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size s757er.2438,11\n.align 1\n.type qs757.2439,@object\n.size qs757.2439,8\nqs757.2439:\n.byte 115\n.byte 55\n.byte 53\n.byte 55\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s757\n.text\n.align 16\n.type s757,@function\ns757:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $148,%esp\nleal qs757.2439,%edi\nmovl %edi,-112(%ebp)\nmovl 20(%ebp),%edi\nleal 60(%edi),%edi\nmovl %edi,-116(%ebp)\nmovl $0,-120(%ebp)\n.LC2440:\n.LC2441:\nmovl -116(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-116(%ebp)\nmovl -112(%ebp),%esi\nleal 1(%esi),%ebx\nmovl %ebx,-112(%ebp)\nmovb (,%esi),%bl\nmovb %bl,(,%edi)\nmovsbl %bl,%edi\ncmpl $0,%edi\njne .LC2440\nmovl $40,-124(%ebp)\nmovl -124(%ebp),%edi\nleal (,%edi,8),%esi\nleal (,%esi,4),%esi\ncmpl $1280,%esi\njne .LC2445\nsarl $3,%edi\nsarl $2,%edi\ncmpl $1,%edi\nje .LC2443\n.LC2445:\nincl -120(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC2446\npushl $1\npushl $s757er.2438\ncall printf\naddl $8,%esp\n.LC2446:\n.LC2443:\nmovl $0,-84(%ebp)\nmovl $0,-100(%ebp)\njmp .LC2451\n.LC2448:\nmovl $1,-92(%ebp)\nmovl -92(%ebp),%edi\nmovl 20(%ebp),%esi\nmovl 16(%esi),%esi\nmovl %esi,%ecx\nsubl $1,%ecx\nmovl %edi,%eax\nshll %cl,%eax\nmovl %eax,-96(%ebp)\nmovl $0,-104(%ebp)\nmovl -104(%ebp),%edi\nnotl %edi\nmovl -100(%ebp),%esi\nmovl %esi,%ecx\nmovl %edi,%eax\nshrl %cl,%eax\nmovl %eax,-108(%ebp)\nmovl %esi,%ecx\nmovl %edi,%eax\nshll %cl,%eax\nmovl %eax,-104(%ebp)\nmovl $0,-88(%ebp)\njmp .LC2455\n.LC2452:\nmovl -100(%ebp),%edi\ncmpl %edi,-88(%ebp)\njge .LC2463\nmovl $1,-132(%ebp)\njmp .LC2464\n.LC2463:\nmovl $0,-132(%ebp)\n.LC2464:\nmovl -92(%ebp),%edi\nandl -104(%ebp),%edi\ncmpl $0,%edi\njne .LC2465\nmovl $1,-136(%ebp)\njmp .LC2466\n.LC2465:\nmovl $0,-136(%ebp)\n.LC2466:\nmovl -136(%ebp),%edi\ncmpl %edi,-132(%ebp)\njne .LC2462\nmovl -100(%ebp),%edi\ncmpl %edi,-88(%ebp)\njge .LC2467\nmovl $1,-140(%ebp)\njmp .LC2468\n.LC2467:\nmovl $0,-140(%ebp)\n.LC2468:\nmovl -96(%ebp),%edi\nandl -108(%ebp),%edi\ncmpl $0,%edi\njne .LC2469\nmovl $1,-144(%ebp)\njmp .LC2470\n.LC2469:\nmovl $0,-144(%ebp)\n.LC2470:\nmovl -144(%ebp),%edi\ncmpl %edi,-140(%ebp)\nje .LC2456\n.LC2462:\nmovl $1,-84(%ebp)\n.LC2456:\nmovl -92(%ebp),%edi\nleal (,%edi,2),%edi\nmovl %edi,-92(%ebp)\nmovl -96(%ebp),%edi\nshrl $1,%edi\nmovl %edi,-96(%ebp)\n.LC2453:\nincl -88(%ebp)\n.LC2455:\nmovl 20(%ebp),%edi\nmovl 16(%edi),%edi\ncmpl %edi,-88(%ebp)\njl .LC2452\n.LC2449:\nincl -100(%ebp)\n.LC2451:\nmovl 20(%ebp),%edi\nmovl 16(%edi),%edi\ncmpl %edi,-100(%ebp)\njl .LC2448\ncmpl $0,-84(%ebp)\nje .LC2471\naddl $2,-120(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC2473\npushl $2\npushl $s757er.2438\ncall printf\naddl $8,%esp\n.LC2473:\n.LC2471:\nmovl $3,-16(%ebp)\nmovl $2,-12(%ebp)\nmovl $1,-8(%ebp)\nmovl -12(%ebp),%edi\ncmpl %edi,-16(%ebp)\njge .LC2481\nmovl $1,-136(%ebp)\njmp .LC2482\n.LC2481:\nmovl $0,-136(%ebp)\n.LC2482:\nmovl -8(%ebp),%edi\ncmpl %edi,-136(%ebp)\njge .LC2479\nmovl $1,-132(%ebp)\njmp .LC2480\n.LC2479:\nmovl $0,-132(%ebp)\n.LC2480:\ncmpl $1,-132(%ebp)\nje .LC2475\naddl $4,-120(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC2483\npushl $4\npushl $s757er.2438\ncall printf\naddl $8,%esp\n.LC2483:\n.LC2475:\nleal -76(%ebp),%edi\nleal -80(%ebp),%esi\ncmpl %esi,%edi\njne .LC2485\naddl $8,-120(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC2488\npushl $8\npushl $s757er.2438\ncall printf\naddl $8,%esp\n.LC2488:\n.LC2485:\nleal -76(%ebp),%edi\nleal -80(%ebp),%esi\ncmpl %esi,%edi\njae .LC2490\nmovl 20(%ebp),%edi\ncmpl $0,40(%edi)\nje .LC2493\npushl $.LC2495\ncall printf\naddl $4,%esp\n.LC2493:\n.LC2490:\nmovl $0,-84(%ebp)\nmovl $0,-88(%ebp)\n.LC2496:\nmovl -88(%ebp),%edi\nleal -80(%ebp),%esi\nmovl $1,(%esi,%edi,4)\n.LC2497:\nincl -88(%ebp)\ncmpl $16,-88(%ebp)\njl .LC2496\nmovl $0,-76(%ebp)\nmovl $0,-64(%ebp)\nmovl $0,-56(%ebp)\nmovl $0,-52(%ebp)\nmovl $0,-44(%ebp)\nmovl $0,-28(%ebp)\nmovl $0,-16(%ebp)\n.LC2506:\nmovl $0,-12(%ebp)\n.LC2510:\nmovl $0,-8(%ebp)\n.LC2514:\nmovl $0,-4(%ebp)\n.LC2518:\nmovl -12(%ebp),%edi\ncmpl %edi,-16(%ebp)\njge .LC2529\nmovl $1,-144(%ebp)\njmp .LC2530\n.LC2529:\nmovl $0,-144(%ebp)\n.LC2530:\nmovl -4(%ebp),%edi\ncmpl %edi,-8(%ebp)\njge .LC2531\nmovl $1,-148(%ebp)\njmp .LC2532\n.LC2531:\nmovl $0,-148(%ebp)\n.LC2532:\nmovl -148(%ebp),%edi\ncmpl %edi,-144(%ebp)\njne .LC2527\nmovl $1,-140(%ebp)\njmp .LC2528\n.LC2527:\nmovl $0,-140(%ebp)\n.LC2528:\nmovl -16(%ebp),%edi\nmovl -12(%ebp),%esi\nleal (,%esi,4),%esi\nleal (%esi,%edi,8),%edi\nmovl -8(%ebp),%esi\nleal (,%esi,2),%esi\nleal (%esi,%edi),%edi\nmovl -4(%ebp),%esi\nleal (%esi,%edi),%edi\nleal -80(%ebp),%esi\nmovl (%esi,%edi,4),%edi\ncmpl %edi,-140(%ebp)\nje .LC2522\nmovl $1,-84(%ebp)\n.LC2522:\n.LC2519:\nincl -4(%ebp)\ncmpl $2,-4(%ebp)\njl .LC2518\n.LC2515:\nincl -8(%ebp)\ncmpl $2,-8(%ebp)\njl .LC2514\n.LC2511:\nincl -12(%ebp)\ncmpl $2,-12(%ebp)\njl .LC2510\n.LC2507:\nincl -16(%ebp)\ncmpl $2,-16(%ebp)\njl .LC2506\ncmpl $0,-84(%ebp)\nje .LC2533\naddl $16,-120(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC2535\npushl $16\npushl $s757er.2438\ncall printf\naddl $8,%esp\n.LC2535:\n.LC2533:\nmovl $0,-128(%ebp)\nmovl -128(%ebp),%edi\ncmpl $0,%edi\nje .LC2537\naddl $32,-120(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC2539\npushl $32\npushl $s757er.2438\ncall printf\naddl $8,%esp\n.LC2539:\n.LC2537:\nmovl -120(%ebp),%eax\n.LC2437:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf2541:\n.size s757,.Lf2541-s757\n.data\n.align 1\n.type fl.2543,@object\nfl.2543:\n.byte 76\n.byte 111\n.byte 99\n.byte 97\n.byte 108\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 37\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.size fl.2543,17\n.align 1\n.type s7813er.2544,@object\ns7813er.2544:\n.byte 115\n.byte 55\n.byte 56\n.byte 49\n.byte 51\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size s7813er.2544,12\n.align 1\n.type qs7813.2545,@object\n.size qs7813.2545,8\nqs7813.2545:\n.byte 115\n.byte 55\n.byte 56\n.byte 49\n.byte 51\n.byte 32\n.byte 32\n.byte 0\n.globl s7813\n.text\n.align 16\n.type s7813,@function\ns7813:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $88,%esp\nleal qs7813.2545,%edi\nmovl %edi,-24(%ebp)\nmovl 20(%ebp),%edi\nleal 60(%edi),%esi\nmovl %esi,-28(%ebp)\nmovl $0,-8(%ebp)\nmovl $0,-32(%ebp)\nmovl 48(%edi),%edi\nmovl %edi,-4(%ebp)\n.LC2546:\n.LC2547:\nmovl -28(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-28(%ebp)\nmovl -24(%ebp),%esi\nleal 1(%esi),%ebx\nmovl %ebx,-24(%ebp)\nmovb (,%esi),%bl\nmovb %bl,(,%edi)\nmovsbl %bl,%edi\ncmpl $0,%edi\njne .LC2546\njmp .LC2549\nmovl $1,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2551\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2551:\n.LC2549:\njmp .LC2553\nmovl $2,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2555\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2555:\n.LC2553:\njmp .LC2557\nmovl $3,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2559\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2559:\n.LC2557:\njmp .LC2561\nmovl $4,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2563\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2563:\n.LC2561:\njmp .LC2565\nmovl $5,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2567\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2567:\n.LC2565:\njmp .LC2569\nmovl $6,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2571\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2571:\n.LC2569:\njmp .LC2573\nmovl $7,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2575\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2575:\n.LC2573:\njmp .LC2577\nmovl $8,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2579\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2579:\n.LC2577:\njmp .LC2581\nmovl $9,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2583\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2583:\n.LC2581:\njmp .LC2585\nmovl $10,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2587\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2587:\n.LC2585:\njmp .LC2589\nmovl $11,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2591\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2591:\n.LC2589:\njmp .LC2593\nmovl $12,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2595\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2595:\n.LC2593:\njmp .LC2597\nmovl $13,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2599\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2599:\n.LC2597:\njmp .LC2601\nmovl $14,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2603\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2603:\n.LC2601:\njmp .LC2605\nmovl $15,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2607\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2607:\n.LC2605:\njmp .LC2609\nmovl $16,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2611\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2611:\n.LC2609:\njmp .LC2613\nmovl $17,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2615\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2615:\n.LC2613:\njmp .LC2617\nmovl $18,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2619\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2619:\n.LC2617:\njmp .LC2621\nmovl $16,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2623\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2623:\n.LC2621:\njmp .LC2625\nmovl $20,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2627\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2627:\n.LC2625:\njmp .LC2629\nmovl $21,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2631\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2631:\n.LC2629:\njmp .LC2633\nmovl $22,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2635\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2635:\n.LC2633:\njmp .LC2637\nmovl $23,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2639\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2639:\n.LC2637:\njmp .LC2641\nmovl $24,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2643\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2643:\n.LC2641:\njmp .LC2645\nmovl $25,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2647\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2647:\n.LC2645:\njmp .LC2649\nmovl $26,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2651\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2651:\n.LC2649:\njmp .LC2653\nmovl $27,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2655\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2655:\n.LC2653:\njmp .LC2657\nmovl $28,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2659\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2659:\n.LC2657:\njmp .LC2661\nmovl $26,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2663\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2663:\n.LC2661:\njmp .LC2665\nmovl $30,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2667\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2667:\n.LC2665:\njmp .LC2669\nmovl $31,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2671\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2671:\n.LC2669:\njmp .LC2673\nmovl $32,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2675\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2675:\n.LC2673:\njmp .LC2677\nmovl $33,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2679\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2679:\n.LC2677:\njmp .LC2681\nmovl $34,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2683\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2683:\n.LC2681:\njmp .LC2685\nmovl $35,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2687\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2687:\n.LC2685:\njmp .LC2689\nmovl $36,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2691\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2691:\n.LC2689:\njmp .LC2693\nmovl $37,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2695\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2695:\n.LC2693:\njmp .LC2697\nmovl $38,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2699\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2699:\n.LC2697:\njmp .LC2701\nmovl $39,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2703\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2703:\n.LC2701:\njmp .LC2705\nmovl $40,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2707\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2707:\n.LC2705:\njmp .LC2709\nmovl $41,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2711\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2711:\n.LC2709:\njmp .LC2713\nmovl $42,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2715\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2715:\n.LC2713:\njmp .LC2717\nmovl $43,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2719\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2719:\n.LC2717:\njmp .LC2721\nmovl $44,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2723\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2723:\n.LC2721:\njmp .LC2725\nmovl $45,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2727\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2727:\n.LC2725:\njmp .LC2729\nmovl $46,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2731\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2731:\n.LC2729:\njmp .LC2733\nmovl $47,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2735\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2735:\n.LC2733:\njmp .LC2737\nmovl $48,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2739\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2739:\n.LC2737:\njmp .LC2741\nmovl $49,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2743\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2743:\n.LC2741:\njmp .LC2745\nmovl $50,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2747\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2747:\n.LC2745:\njmp .LC2749\nmovl $51,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2751\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2751:\n.LC2749:\njmp .LC2753\nmovl $52,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2755\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2755:\n.LC2753:\njmp .LC2757\nmovl $53,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2759\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2759:\n.LC2757:\njmp .LC2761\nmovl $54,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2763\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2763:\n.LC2761:\njmp .LC2765\nmovl $55,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2767\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2767:\n.LC2765:\njmp .LC2769\nmovl $56,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2771\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2771:\n.LC2769:\njmp .LC2773\nmovl $57,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2775\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2775:\n.LC2773:\njmp .LC2777\nmovl $58,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2779\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2779:\n.LC2777:\njmp .LC2781\nmovl $56,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2783\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2783:\n.LC2781:\njmp .LC2785\nmovl $60,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2787\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2787:\n.LC2785:\njmp .LC2789\nmovl $61,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2791\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2791:\n.LC2789:\njmp .LC2793\nmovl $62,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2795\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2795:\n.LC2793:\njmp .LC2797\nmovl $63,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2799\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2799:\n.LC2797:\njmp .LC2801\nmovl $64,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2803\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2803:\n.LC2801:\njmp .LC2805\nmovl $65,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2807\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2807:\n.LC2805:\njmp .LC2809\nmovl $66,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2811\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2811:\n.LC2809:\njmp .LC2813\nmovl $67,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2815\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2815:\n.LC2813:\njmp .LC2817\nmovl $68,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2819\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2819:\n.LC2817:\njmp .LC2821\nmovl $69,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2823\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2823:\n.LC2821:\njmp .LC2825\nmovl $70,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2827\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2827:\n.LC2825:\njmp .LC2829\nmovl $71,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2831\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2831:\n.LC2829:\njmp .LC2833\nmovl $72,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2835\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2835:\n.LC2833:\njmp .LC2837\nmovl $73,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2839\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2839:\n.LC2837:\njmp .LC2841\nmovl $74,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2843\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2843:\n.LC2841:\njmp .LC2845\nmovl $75,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2847\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2847:\n.LC2845:\ncmpl $0,-8(%ebp)\nje .LC2849\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC2851\npushl $1\npushl $s7813er.2544\ncall printf\naddl $8,%esp\n.LC2851:\nincl -32(%ebp)\n.LC2849:\nmovl $0,-8(%ebp)\nmovl $0,-16(%ebp)\nmovl $0,-12(%ebp)\nmovl -12(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-12(%ebp)\ncmpl $0,%edi\nje .LC2854\nmovl -16(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-16(%ebp)\ncmpl $0,%edi\nje .LC2854\nmovl $1,-44(%ebp)\njmp .LC2855\n.LC2854:\nmovl $0,-44(%ebp)\n.LC2855:\nmovl -44(%ebp),%edi\nmovl %edi,-20(%ebp)\ncmpl $1,-12(%ebp)\nje .LC2856\nmovl $1,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2858\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2858:\n.LC2856:\ncmpl $0,-16(%ebp)\nje .LC2860\nmovl $2,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2862\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2862:\n.LC2860:\ncmpl $0,-20(%ebp)\nje .LC2864\nmovl $3,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2866\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2866:\n.LC2864:\ncmpl $0,-12(%ebp)\nje .LC2869\nmovl -16(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-16(%ebp)\ncmpl $0,%edi\nje .LC2869\nmovl $1,-48(%ebp)\njmp .LC2870\n.LC2869:\nmovl $0,-48(%ebp)\n.LC2870:\nmovl -48(%ebp),%edi\nmovl %edi,-20(%ebp)\ncmpl $1,-12(%ebp)\nje .LC2871\nmovl $4,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2873\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2873:\n.LC2871:\ncmpl $1,-16(%ebp)\nje .LC2875\nmovl $5,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2877\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2877:\n.LC2875:\ncmpl $0,-20(%ebp)\nje .LC2879\nmovl $6,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2881\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2881:\n.LC2879:\nmovl -12(%ebp),%edi\nmovl %edi,%esi\nsubl $1,%esi\nmovl %esi,-12(%ebp)\ncmpl $0,%edi\nje .LC2884\ncmpl $0,-16(%ebp)\nje .LC2884\nmovl $1,-52(%ebp)\njmp .LC2885\n.LC2884:\nmovl $0,-52(%ebp)\n.LC2885:\nmovl -52(%ebp),%edi\nmovl %edi,-20(%ebp)\ncmpl $0,-12(%ebp)\nje .LC2886\nmovl $7,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2888\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2888:\n.LC2886:\ncmpl $1,-16(%ebp)\nje .LC2890\nmovl $8,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2892\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2892:\n.LC2890:\ncmpl $1,-20(%ebp)\nje .LC2894\nmovl $9,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2896\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2896:\n.LC2894:\ncmpl $0,-12(%ebp)\nje .LC2899\nmovl -16(%ebp),%edi\nmovl %edi,%esi\nsubl $1,%esi\nmovl %esi,-16(%ebp)\ncmpl $0,%edi\nje .LC2899\nmovl $1,-56(%ebp)\njmp .LC2900\n.LC2899:\nmovl $0,-56(%ebp)\n.LC2900:\nmovl -56(%ebp),%edi\nmovl %edi,-20(%ebp)\ncmpl $0,-12(%ebp)\nje .LC2901\nmovl $10,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2903\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2903:\n.LC2901:\ncmpl $1,-16(%ebp)\nje .LC2905\nmovl $11,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2907\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2907:\n.LC2905:\ncmpl $0,-20(%ebp)\nje .LC2909\nmovl $12,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2911\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2911:\n.LC2909:\ncmpl $0,-8(%ebp)\nje .LC2913\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC2915\npushl $2\npushl $s7813er.2544\ncall printf\naddl $8,%esp\n.LC2915:\naddl $2,-32(%ebp)\n.LC2913:\nmovl $0,-8(%ebp)\nmovl $0,-16(%ebp)\nmovl $0,-12(%ebp)\nmovl -12(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-12(%ebp)\ncmpl $0,%edi\njne .LC2920\ncmpl $0,-16(%ebp)\nje .LC2918\n.LC2920:\nmovl $1,-60(%ebp)\njmp .LC2919\n.LC2918:\nmovl $0,-60(%ebp)\n.LC2919:\nmovl -60(%ebp),%edi\nmovl %edi,-20(%ebp)\ncmpl $1,-12(%ebp)\nje .LC2921\nmovl $1,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2923\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2923:\n.LC2921:\ncmpl $0,-16(%ebp)\nje .LC2925\nmovl $2,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2927\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2927:\n.LC2925:\ncmpl $0,-20(%ebp)\nje .LC2929\nmovl $3,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2931\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2931:\n.LC2929:\nmovl -16(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-16(%ebp)\ncmpl $0,%edi\njne .LC2936\ncmpl $0,-12(%ebp)\nje .LC2934\n.LC2936:\nmovl $1,-64(%ebp)\njmp .LC2935\n.LC2934:\nmovl $0,-64(%ebp)\n.LC2935:\nmovl -64(%ebp),%edi\nmovl %edi,-20(%ebp)\ncmpl $1,-12(%ebp)\nje .LC2937\nmovl $4,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2939\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2939:\n.LC2937:\ncmpl $1,-16(%ebp)\nje .LC2941\nmovl $5,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2943\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2943:\n.LC2941:\ncmpl $1,-20(%ebp)\nje .LC2945\nmovl $6,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2947\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2947:\n.LC2945:\nmovl -12(%ebp),%edi\nmovl %edi,%esi\nsubl $1,%esi\nmovl %esi,-12(%ebp)\ncmpl $0,%edi\njne .LC2952\nmovl -16(%ebp),%edi\nmovl %edi,%esi\nsubl $1,%esi\nmovl %esi,-16(%ebp)\ncmpl $0,%edi\nje .LC2950\n.LC2952:\nmovl $1,-68(%ebp)\njmp .LC2951\n.LC2950:\nmovl $0,-68(%ebp)\n.LC2951:\nmovl -68(%ebp),%edi\nmovl %edi,-20(%ebp)\ncmpl $0,-12(%ebp)\nje .LC2953\nmovl $7,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2955\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2955:\n.LC2953:\ncmpl $1,-16(%ebp)\nje .LC2957\nmovl $8,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2959\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2959:\n.LC2957:\ncmpl $1,-20(%ebp)\nje .LC2961\nmovl $9,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2963\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2963:\n.LC2961:\ncmpl $0,-12(%ebp)\njne .LC2968\nmovl -16(%ebp),%edi\nmovl %edi,%esi\nsubl $1,%esi\nmovl %esi,-16(%ebp)\ncmpl $0,%edi\nje .LC2966\n.LC2968:\nmovl $1,-72(%ebp)\njmp .LC2967\n.LC2966:\nmovl $0,-72(%ebp)\n.LC2967:\nmovl -72(%ebp),%edi\nmovl %edi,-20(%ebp)\ncmpl $0,-12(%ebp)\nje .LC2969\nmovl $10,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2971\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2971:\n.LC2969:\ncmpl $0,-16(%ebp)\nje .LC2973\nmovl $11,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2975\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2975:\n.LC2973:\ncmpl $1,-20(%ebp)\nje .LC2977\nmovl $12,-8(%ebp)\ncmpl $0,-4(%ebp)\nje .LC2979\npushl -8(%ebp)\npushl $fl.2543\ncall printf\naddl $8,%esp\n.LC2979:\n.LC2977:\ncmpl $0,-8(%ebp)\nje .LC2981\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC2983\npushl $4\npushl $s7813er.2544\ncall printf\naddl $8,%esp\n.LC2983:\naddl $4,-32(%ebp)\n.LC2981:\nmovl $0,-16(%ebp)\nmovl $0,-12(%ebp)\nmovl $0,-36(%ebp)\nmovl $1,-40(%ebp)\ncmpl $0,-40(%ebp)\nje .LC2987\nmovl -36(%ebp),%edi\nmovl %edi,-76(%ebp)\njmp .LC2988\n.LC2987:\ncmpl $0,-40(%ebp)\nje .LC2989\nmovl -12(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-12(%ebp)\nmovl %edi,-80(%ebp)\njmp .LC2990\n.LC2989:\nmovl -16(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-16(%ebp)\nmovl %edi,-80(%ebp)\n.LC2990:\nmovl -80(%ebp),%edi\nmovl %edi,-76(%ebp)\n.LC2988:\nmovl -76(%ebp),%edi\nmovl %edi,-20(%ebp)\ncmpl $0,-20(%ebp)\njne .LC2994\ncmpl $0,-12(%ebp)\njne .LC2994\ncmpl $0,-16(%ebp)\nje .LC2991\n.LC2994:\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC2995\npushl $8\npushl $s7813er.2544\ncall printf\naddl $8,%esp\n.LC2995:\naddl $8,-32(%ebp)\n.LC2991:\ncmpl $0,-40(%ebp)\nje .LC3002\nmovl -36(%ebp),%edi\nmovl %edi,-84(%ebp)\njmp .LC3003\n.LC3002:\nmovl $1,-84(%ebp)\n.LC3003:\ncmpl $0,-84(%ebp)\njne .LC3001\ncmpl $0,-36(%ebp)\nje .LC3004\nmovl $1,-88(%ebp)\njmp .LC3005\n.LC3004:\nmovl -36(%ebp),%edi\nmovl %edi,-88(%ebp)\n.LC3005:\ncmpl $0,-88(%ebp)\nje .LC2997\n.LC3001:\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3006\npushl $16\npushl $s7813er.2544\ncall printf\naddl $8,%esp\n.LC3006:\naddl $16,-32(%ebp)\n.LC2997:\nmovl -32(%ebp),%eax\n.LC2542:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf3008:\n.size s7813,.Lf3008-s7813\n.data\n.align 1\n.type s81er.3010,@object\ns81er.3010:\n.byte 115\n.byte 56\n.byte 49\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size s81er.3010,10\n.align 1\n.type qs81.3011,@object\n.size qs81.3011,8\nqs81.3011:\n.byte 115\n.byte 56\n.byte 49\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.align 1\n.type badtest.3012,@object\nbadtest.3012:\n.byte 82\n.byte 101\n.byte 103\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 117\n.byte 110\n.byte 116\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 37\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 117\n.byte 110\n.byte 114\n.byte 101\n.byte 108\n.byte 105\n.byte 97\n.byte 98\n.byte 108\n.byte 101\n.byte 46\n.byte 10\n.byte 0\n.size badtest.3012,38\n.align 1\n.type goodtest.3013,@object\ngoodtest.3013:\n.byte 37\n.byte 100\n.byte 32\n.byte 114\n.byte 101\n.byte 103\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 97\n.byte 115\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 37\n.byte 115\n.byte 32\n.byte 118\n.byte 97\n.byte 114\n.byte 105\n.byte 97\n.byte 98\n.byte 108\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.size goodtest.3013,40\n.globl s81\n.text\n.align 16\n.type s81,@function\ns81:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $56,%esp\nmovl $0,-56(%ebp)\nmovl $0,-44(%ebp)\nmovl $0,-48(%ebp)\nmovl $0,-52(%ebp)\nleal qs81.3011,%edi\nmovl %edi,-36(%ebp)\nmovl 20(%ebp),%edi\nleal 60(%edi),%edi\nmovl %edi,-40(%ebp)\n.LC3014:\n.LC3015:\nmovl -40(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-40(%ebp)\nmovl -36(%ebp),%esi\nleal 1(%esi),%ebx\nmovl %ebx,-36(%ebp)\nmovb (,%esi),%bl\nmovb %bl,(,%edi)\nmovsbl %bl,%edi\ncmpl $0,%edi\njne .LC3014\nmovl $1,-16(%ebp)\nmovl $0,-20(%ebp)\n.LC3017:\nmovl -16(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,-1(%ebp)\nmovb %bl,-21(%ebp)\nleal -16(%ebp),%esi\nmovl %esi,-8(%ebp)\nleal -16(%ebp),%esi\nmovl %esi,-28(%ebp)\nmovl %edi,-12(%ebp)\nmovl %edi,-32(%ebp)\nmovsbl -1(%ebp),%edi\nmovsbl -21(%ebp),%esi\ncmpl %esi,%edi\nje .LC3021\nmovl $1,-44(%ebp)\n.LC3021:\nmovl -8(%ebp),%edi\nmovl -28(%ebp),%esi\ncmpl %esi,%edi\nje .LC3023\nmovl $1,-48(%ebp)\n.LC3023:\nmovl -32(%ebp),%edi\ncmpl %edi,-12(%ebp)\nje .LC3025\nmovl $1,-52(%ebp)\n.LC3025:\nsall $1,-16(%ebp)\n.LC3018:\nincl -20(%ebp)\ncmpl $50,-20(%ebp)\njl .LC3017\ncmpl $0,-44(%ebp)\nje .LC3027\nincl -56(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3029\npushl $1\npushl $s81er.3010\ncall printf\naddl $8,%esp\n.LC3029:\n.LC3027:\ncmpl $0,-48(%ebp)\nje .LC3031\naddl $2,-56(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3033\npushl $2\npushl $s81er.3010\ncall printf\naddl $8,%esp\n.LC3033:\n.LC3031:\ncmpl $0,-52(%ebp)\nje .LC3035\naddl $4,-56(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3037\npushl $4\npushl $s81er.3010\ncall printf\naddl $8,%esp\n.LC3037:\n.LC3035:\ncall regc\nmovl %eax,-16(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,40(%edi)\nje .LC3039\ncmpl $0,-16(%ebp)\njge .LC3041\npushl $.LC434\npushl $badtest.3012\ncall printf\naddl $8,%esp\njmp .LC3042\n.LC3041:\npushl $.LC434\npushl -16(%ebp)\npushl $goodtest.3013\ncall printf\naddl $12,%esp\n.LC3042:\n.LC3039:\ncall regp\nmovl %eax,-16(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,40(%edi)\nje .LC3043\ncmpl $0,-16(%ebp)\njge .LC3045\npushl $.LC3047\npushl $badtest.3012\ncall printf\naddl $8,%esp\njmp .LC3046\n.LC3045:\npushl $.LC3047\npushl -16(%ebp)\npushl $goodtest.3013\ncall printf\naddl $12,%esp\n.LC3046:\n.LC3043:\ncall regi\nmovl %eax,-16(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,40(%edi)\nje .LC3048\ncmpl $0,-16(%ebp)\njge .LC3050\npushl $.LC435\npushl $badtest.3012\ncall printf\naddl $8,%esp\njmp .LC3051\n.LC3050:\npushl $.LC435\npushl -16(%ebp)\npushl $goodtest.3013\ncall printf\naddl $12,%esp\n.LC3051:\n.LC3048:\nmovl -56(%ebp),%eax\n.LC3009:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf3052:\n.size s81,.Lf3052-s81\n.globl regc\n.align 16\n.type regc,@function\nregc:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $148,%esp\nmovb $0,-138(%ebp)\nmovb $1,-117(%ebp)\nmovb $2,-118(%ebp)\nmovb $3,-119(%ebp)\nmovb $4,-1(%ebp)\nmovb $5,-120(%ebp)\nmovb $6,-2(%ebp)\nmovb $7,-121(%ebp)\nmovb $8,-3(%ebp)\nmovb $9,-122(%ebp)\nmovb $10,-4(%ebp)\nmovb $11,-123(%ebp)\nmovb $12,-5(%ebp)\nmovb $13,-124(%ebp)\nmovb $14,-6(%ebp)\nmovb $15,-125(%ebp)\nmovb $16,-7(%ebp)\nmovb $17,-126(%ebp)\nmovb $18,-8(%ebp)\nmovb $19,-127(%ebp)\nmovb $20,-9(%ebp)\nmovb $21,-128(%ebp)\nmovb $22,-10(%ebp)\nmovb $23,-129(%ebp)\nmovb $24,-11(%ebp)\nmovb $25,-130(%ebp)\nmovb $26,-12(%ebp)\nmovb $27,-131(%ebp)\nmovb $28,-13(%ebp)\nmovb $29,-132(%ebp)\nmovb $30,-14(%ebp)\nmovb $31,-133(%ebp)\nmovb $32,-15(%ebp)\nmovb $33,-134(%ebp)\nmovb $34,-16(%ebp)\nmovb $35,-135(%ebp)\nmovb $36,-136(%ebp)\nmovb $37,-137(%ebp)\nmovb $38,-139(%ebp)\nleal -117(%ebp),%edi\nleal -138(%ebp),%esi\nmovl %edi,%ebx\nsubl %esi,%ebx\nmovl %ebx,%esi\nmovl %esi,-104(%ebp)\nleal -118(%ebp),%esi\nsubl %edi,%esi\nmovl %esi,%edi\nmovl %edi,-100(%ebp)\nleal -119(%ebp),%edi\nleal -118(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-96(%ebp)\nleal -120(%ebp),%edi\nleal -119(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-92(%ebp)\nleal -121(%ebp),%edi\nleal -120(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-88(%ebp)\nleal -122(%ebp),%edi\nleal -121(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-84(%ebp)\nleal -123(%ebp),%edi\nleal -122(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-80(%ebp)\nleal -124(%ebp),%edi\nleal -123(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-76(%ebp)\nleal -125(%ebp),%edi\nleal -124(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-72(%ebp)\nleal -126(%ebp),%edi\nleal -125(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-68(%ebp)\nleal -127(%ebp),%edi\nleal -126(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-64(%ebp)\nleal -128(%ebp),%edi\nleal -127(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-60(%ebp)\nleal -129(%ebp),%edi\nleal -128(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-56(%ebp)\nleal -130(%ebp),%edi\nleal -129(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-52(%ebp)\nleal -131(%ebp),%edi\nleal -130(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-48(%ebp)\nleal -132(%ebp),%edi\nleal -131(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-44(%ebp)\nleal -133(%ebp),%edi\nleal -132(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-40(%ebp)\nleal -134(%ebp),%edi\nleal -133(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-36(%ebp)\nleal -135(%ebp),%edi\nleal -134(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-32(%ebp)\nleal -136(%ebp),%edi\nleal -135(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-28(%ebp)\nleal -137(%ebp),%edi\nleal -136(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-24(%ebp)\nleal -139(%ebp),%edi\nleal -137(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-20(%ebp)\nmovl -104(%ebp),%edi\nmovl %edi,-116(%ebp)\nmovl $1,-112(%ebp)\nmovl $0,-108(%ebp)\n.LC3075:\nmovl -112(%ebp),%edi\ncmpl $1,%edi\nje .LC3081\ncmpl $2,%edi\nje .LC3084\ncmpl $3,%edi\nje .LC3089\njmp .LC3079\n.LC3081:\nmovl -108(%ebp),%edi\nleal -104(%ebp),%esi\nmovl -116(%ebp),%ebx\ncmpl %ebx,(%esi,%edi,4)\nje .LC3080\nmovl -108(%ebp),%edi\nleal -104(%ebp),%esi\nmovl (%esi,%edi,4),%edi\nmovl %edi,-148(%ebp)\nmovl $2,-112(%ebp)\nmovl $1,-144(%ebp)\njmp .LC3080\n.LC3084:\nmovl -108(%ebp),%edi\nleal -104(%ebp),%esi\nmovl -116(%ebp),%ebx\ncmpl %ebx,(%esi,%edi,4)\njne .LC3085\nmovl $3,-112(%ebp)\njmp .LC3080\n.LC3085:\nmovl -108(%ebp),%edi\nleal -104(%ebp),%esi\nmovl -148(%ebp),%ebx\ncmpl %ebx,(%esi,%edi,4)\njne .LC3087\nincl -144(%ebp)\njmp .LC3080\n.LC3087:\nmovl $4,-112(%ebp)\njmp .LC3080\n.LC3089:\nmovl -108(%ebp),%edi\nleal -104(%ebp),%esi\nmovl -116(%ebp),%ebx\ncmpl %ebx,(%esi,%edi,4)\nje .LC3080\nmovl $4,-112(%ebp)\n.LC3079:\n.LC3080:\n.LC3076:\nincl -108(%ebp)\ncmpl $22,-108(%ebp)\njl .LC3075\ncmpl $3,-112(%ebp)\njne .LC3092\nmovl $16,%edi\nmovl %edi,%eax\nsubl -144(%ebp),%eax\njmp .LC3053\n.LC3092:\nmovl $-1,%eax\n.LC3053:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf3094:\n.size regc,.Lf3094-regc\n.globl regi\n.align 16\n.type regi,@function\nregi:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $264,%esp\nmovl $0,-252(%ebp)\nmovl $1,-168(%ebp)\nmovl $2,-172(%ebp)\nmovl $3,-176(%ebp)\nmovl $4,-4(%ebp)\nmovl $5,-180(%ebp)\nmovl $6,-8(%ebp)\nmovl $7,-184(%ebp)\nmovl $8,-12(%ebp)\nmovl $9,-188(%ebp)\nmovl $10,-16(%ebp)\nmovl $11,-192(%ebp)\nmovl $12,-20(%ebp)\nmovl $13,-196(%ebp)\nmovl $14,-24(%ebp)\nmovl $15,-200(%ebp)\nmovl $16,-28(%ebp)\nmovl $17,-204(%ebp)\nmovl $18,-32(%ebp)\nmovl $19,-208(%ebp)\nmovl $20,-36(%ebp)\nmovl $21,-212(%ebp)\nmovl $22,-40(%ebp)\nmovl $23,-216(%ebp)\nmovl $24,-44(%ebp)\nmovl $25,-220(%ebp)\nmovl $26,-48(%ebp)\nmovl $27,-224(%ebp)\nmovl $28,-52(%ebp)\nmovl $29,-228(%ebp)\nmovl $30,-56(%ebp)\nmovl $31,-232(%ebp)\nmovl $32,-60(%ebp)\nmovl $33,-236(%ebp)\nmovl $34,-64(%ebp)\nmovl $35,-240(%ebp)\nmovl $36,-244(%ebp)\nmovl $37,-248(%ebp)\nmovl $38,-256(%ebp)\nleal -168(%ebp),%edi\nmovl $4,%esi\nleal -252(%ebp),%ebx\nmovl %edi,%edx\nsubl %ebx,%edx\nmovl %edx,%eax\nmovl %esi,%ecx\ncdq\nidivl %ecx\nmovl %eax,-152(%ebp)\nleal -172(%ebp),%ebx\nsubl %edi,%ebx\nmovl %ebx,%eax\nmovl %esi,%ecx\ncdq\nidivl %ecx\nmovl %eax,-148(%ebp)\nleal -176(%ebp),%edi\nleal -172(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-144(%ebp)\nleal -180(%ebp),%edi\nleal -176(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-140(%ebp)\nleal -184(%ebp),%edi\nleal -180(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-136(%ebp)\nleal -188(%ebp),%edi\nleal -184(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-132(%ebp)\nleal -192(%ebp),%edi\nleal -188(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-128(%ebp)\nleal -196(%ebp),%edi\nleal -192(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-124(%ebp)\nleal -200(%ebp),%edi\nleal -196(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-120(%ebp)\nleal -204(%ebp),%edi\nleal -200(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-116(%ebp)\nleal -208(%ebp),%edi\nleal -204(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-112(%ebp)\nleal -212(%ebp),%edi\nleal -208(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-108(%ebp)\nleal -216(%ebp),%edi\nleal -212(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-104(%ebp)\nleal -220(%ebp),%edi\nleal -216(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-100(%ebp)\nleal -224(%ebp),%edi\nleal -220(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-96(%ebp)\nleal -228(%ebp),%edi\nleal -224(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-92(%ebp)\nleal -232(%ebp),%edi\nleal -228(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-88(%ebp)\nleal -236(%ebp),%edi\nleal -232(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-84(%ebp)\nleal -240(%ebp),%edi\nleal -236(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-80(%ebp)\nleal -244(%ebp),%edi\nleal -240(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-76(%ebp)\nleal -248(%ebp),%edi\nleal -244(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-72(%ebp)\nleal -256(%ebp),%edi\nleal -248(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-68(%ebp)\nmovl -152(%ebp),%edi\nmovl %edi,-164(%ebp)\nmovl $1,-160(%ebp)\nmovl $0,-156(%ebp)\n.LC3117:\nmovl -160(%ebp),%edi\ncmpl $1,%edi\nje .LC3123\ncmpl $2,%edi\nje .LC3126\ncmpl $3,%edi\nje .LC3131\njmp .LC3121\n.LC3123:\nmovl -156(%ebp),%edi\nleal -152(%ebp),%esi\nmovl -164(%ebp),%ebx\ncmpl %ebx,(%esi,%edi,4)\nje .LC3122\nmovl -156(%ebp),%edi\nleal -152(%ebp),%esi\nmovl (%esi,%edi,4),%edi\nmovl %edi,-264(%ebp)\nmovl $2,-160(%ebp)\nmovl $1,-260(%ebp)\njmp .LC3122\n.LC3126:\nmovl -156(%ebp),%edi\nleal -152(%ebp),%esi\nmovl -164(%ebp),%ebx\ncmpl %ebx,(%esi,%edi,4)\njne .LC3127\nmovl $3,-160(%ebp)\njmp .LC3122\n.LC3127:\nmovl -156(%ebp),%edi\nleal -152(%ebp),%esi\nmovl -264(%ebp),%ebx\ncmpl %ebx,(%esi,%edi,4)\njne .LC3129\nincl -260(%ebp)\njmp .LC3122\n.LC3129:\nmovl $4,-160(%ebp)\njmp .LC3122\n.LC3131:\nmovl -156(%ebp),%edi\nleal -152(%ebp),%esi\nmovl -164(%ebp),%ebx\ncmpl %ebx,(%esi,%edi,4)\nje .LC3122\nmovl $4,-160(%ebp)\n.LC3121:\n.LC3122:\n.LC3118:\nincl -156(%ebp)\ncmpl $22,-156(%ebp)\njl .LC3117\ncmpl $3,-160(%ebp)\njne .LC3134\nmovl $16,%edi\nmovl %edi,%eax\nsubl -260(%ebp),%eax\njmp .LC3095\n.LC3134:\nmovl $-1,%eax\n.LC3095:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf3136:\n.size regi,.Lf3136-regi\n.globl regp\n.align 16\n.type regp,@function\nregp:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $264,%esp\nleal -252(%ebp),%edi\nmovl %edi,-252(%ebp)\nleal -228(%ebp),%edi\nmovl %edi,-228(%ebp)\nleal -232(%ebp),%edi\nmovl %edi,-232(%ebp)\nleal -236(%ebp),%edi\nmovl %edi,-236(%ebp)\nleal -164(%ebp),%edi\nmovl %edi,-4(%ebp)\nleal -164(%ebp),%edi\nmovl %edi,-164(%ebp)\nleal -168(%ebp),%edi\nmovl %edi,-8(%ebp)\nleal -168(%ebp),%edi\nmovl %edi,-168(%ebp)\nleal -172(%ebp),%edi\nmovl %edi,-12(%ebp)\nleal -172(%ebp),%edi\nmovl %edi,-172(%ebp)\nleal -176(%ebp),%edi\nmovl %edi,-16(%ebp)\nleal -176(%ebp),%edi\nmovl %edi,-176(%ebp)\nleal -180(%ebp),%edi\nmovl %edi,-20(%ebp)\nleal -180(%ebp),%edi\nmovl %edi,-180(%ebp)\nleal -184(%ebp),%edi\nmovl %edi,-24(%ebp)\nleal -184(%ebp),%edi\nmovl %edi,-184(%ebp)\nleal -188(%ebp),%edi\nmovl %edi,-28(%ebp)\nleal -188(%ebp),%edi\nmovl %edi,-188(%ebp)\nleal -192(%ebp),%edi\nmovl %edi,-32(%ebp)\nleal -192(%ebp),%edi\nmovl %edi,-192(%ebp)\nleal -196(%ebp),%edi\nmovl %edi,-36(%ebp)\nleal -196(%ebp),%edi\nmovl %edi,-196(%ebp)\nleal -200(%ebp),%edi\nmovl %edi,-40(%ebp)\nleal -200(%ebp),%edi\nmovl %edi,-200(%ebp)\nleal -204(%ebp),%edi\nmovl %edi,-44(%ebp)\nleal -204(%ebp),%edi\nmovl %edi,-204(%ebp)\nleal -208(%ebp),%edi\nmovl %edi,-48(%ebp)\nleal -208(%ebp),%edi\nmovl %edi,-208(%ebp)\nleal -212(%ebp),%edi\nmovl %edi,-52(%ebp)\nleal -212(%ebp),%edi\nmovl %edi,-212(%ebp)\nleal -216(%ebp),%edi\nmovl %edi,-56(%ebp)\nleal -216(%ebp),%edi\nmovl %edi,-216(%ebp)\nleal -220(%ebp),%edi\nmovl %edi,-60(%ebp)\nleal -220(%ebp),%edi\nmovl %edi,-220(%ebp)\nleal -224(%ebp),%edi\nmovl %edi,-64(%ebp)\nleal -224(%ebp),%edi\nmovl %edi,-224(%ebp)\nleal -240(%ebp),%edi\nmovl %edi,-240(%ebp)\nleal -244(%ebp),%edi\nmovl %edi,-244(%ebp)\nleal -256(%ebp),%edi\nmovl %edi,-256(%ebp)\nleal -228(%ebp),%edi\nmovl $4,%esi\nleal -252(%ebp),%ebx\nmovl %edi,%edx\nsubl %ebx,%edx\nmovl %edx,%eax\nmovl %esi,%ecx\ncdq\nidivl %ecx\nmovl %eax,-152(%ebp)\nleal -232(%ebp),%ebx\nsubl %edi,%ebx\nmovl %ebx,%eax\nmovl %esi,%ecx\ncdq\nidivl %ecx\nmovl %eax,-148(%ebp)\nleal -236(%ebp),%edi\nleal -232(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-144(%ebp)\nleal -164(%ebp),%edi\nleal -236(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-140(%ebp)\nleal -168(%ebp),%edi\nleal -164(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-136(%ebp)\nleal -172(%ebp),%edi\nleal -168(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-132(%ebp)\nleal -176(%ebp),%edi\nleal -172(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-128(%ebp)\nleal -180(%ebp),%edi\nleal -176(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-124(%ebp)\nleal -184(%ebp),%edi\nleal -180(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-120(%ebp)\nleal -188(%ebp),%edi\nleal -184(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-116(%ebp)\nleal -192(%ebp),%edi\nleal -188(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-112(%ebp)\nleal -196(%ebp),%edi\nleal -192(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-108(%ebp)\nleal -200(%ebp),%edi\nleal -196(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-104(%ebp)\nleal -204(%ebp),%edi\nleal -200(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-100(%ebp)\nleal -208(%ebp),%edi\nleal -204(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-96(%ebp)\nleal -212(%ebp),%edi\nleal -208(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-92(%ebp)\nleal -216(%ebp),%edi\nleal -212(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-88(%ebp)\nleal -220(%ebp),%edi\nleal -216(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-84(%ebp)\nleal -224(%ebp),%edi\nleal -220(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-80(%ebp)\nleal -240(%ebp),%edi\nleal -224(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-76(%ebp)\nleal -244(%ebp),%edi\nleal -240(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-72(%ebp)\nleal -256(%ebp),%edi\nleal -244(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nmovl %eax,-68(%ebp)\nmovl -152(%ebp),%edi\nmovl %edi,-248(%ebp)\nmovl $1,-160(%ebp)\nmovl $0,-156(%ebp)\n.LC3159:\nmovl -160(%ebp),%edi\ncmpl $1,%edi\nje .LC3165\ncmpl $2,%edi\nje .LC3168\ncmpl $3,%edi\nje .LC3173\njmp .LC3163\n.LC3165:\nmovl -156(%ebp),%edi\nleal -152(%ebp),%esi\nmovl -248(%ebp),%ebx\ncmpl %ebx,(%esi,%edi,4)\nje .LC3164\nmovl -156(%ebp),%edi\nleal -152(%ebp),%esi\nmovl (%esi,%edi,4),%edi\nmovl %edi,-264(%ebp)\nmovl $2,-160(%ebp)\nmovl $1,-260(%ebp)\njmp .LC3164\n.LC3168:\nmovl -156(%ebp),%edi\nleal -152(%ebp),%esi\nmovl -248(%ebp),%ebx\ncmpl %ebx,(%esi,%edi,4)\njne .LC3169\nmovl $3,-160(%ebp)\njmp .LC3164\n.LC3169:\nmovl -156(%ebp),%edi\nleal -152(%ebp),%esi\nmovl -264(%ebp),%ebx\ncmpl %ebx,(%esi,%edi,4)\njne .LC3171\nincl -260(%ebp)\njmp .LC3164\n.LC3171:\nmovl $4,-160(%ebp)\njmp .LC3164\n.LC3173:\nmovl -156(%ebp),%edi\nleal -152(%ebp),%esi\nmovl -248(%ebp),%ebx\ncmpl %ebx,(%esi,%edi,4)\nje .LC3164\nmovl $4,-160(%ebp)\n.LC3163:\n.LC3164:\n.LC3160:\nincl -156(%ebp)\ncmpl $22,-156(%ebp)\njl .LC3159\ncmpl $3,-160(%ebp)\njne .LC3176\nmovl $16,%edi\nmovl %edi,%eax\nsubl -260(%ebp),%eax\njmp .LC3137\n.LC3176:\nmovl $-1,%eax\n.LC3137:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf3178:\n.size regp,.Lf3178-regp\n.bss\n.align 4\n.type x3d.3180,@object\n.size x3d.3180,420\n.lcomm x3d.3180,420\n.data\n.align 1\n.type s84er.3181,@object\ns84er.3181:\n.byte 115\n.byte 56\n.byte 52\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size s84er.3181,10\n.align 1\n.type qs84.3182,@object\n.size qs84.3182,8\nqs84.3182:\n.byte 115\n.byte 56\n.byte 52\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s84\n.text\n.align 16\n.type s84,@function\ns84:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $172,%esp\nleal qs84.3182,%edi\nmovl %edi,-156(%ebp)\nmovl 20(%ebp),%edi\nleal 60(%edi),%edi\nmovl %edi,-160(%ebp)\nmovl $0,-164(%ebp)\n.LC3183:\n.LC3184:\nmovl -160(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-160(%ebp)\nmovl -156(%ebp),%esi\nleal 1(%esi),%ebx\nmovl %ebx,-156(%ebp)\nmovb (,%esi),%bl\nmovb %bl,(,%edi)\nmovsbl %bl,%edi\ncmpl $0,%edi\njne .LC3183\npushl $3\ncall fip\naddl $4,%esp\nmovl %eax,-168(%ebp)\nmovl -168(%ebp),%edi\ncmpl $3,(,%edi)\nje .LC3186\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3188\npushl $1\npushl $s84er.3181\ncall printf\naddl $8,%esp\n.LC3188:\nincl -164(%ebp)\n.LC3186:\nleal glork,%edi\nmovl %edi,-172(%ebp)\npushl $4\ncall *-172(%ebp)\naddl $4,%esp\ncmpl $4,%eax\nje .LC3190\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3192\npushl $2\npushl $s84er.3181\ncall printf\naddl $8,%esp\n.LC3192:\naddl $2,-164(%ebp)\n.LC3190:\nmovl $0,-8(%ebp)\n.LC3194:\nmovl -8(%ebp),%edi\nleal -80(%ebp),%esi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfstps (%esi,%edi,4)\nmovl -8(%ebp),%edi\nleal (,%edi,4),%edi\nleal -148(%ebp),%esi\nleal -80(%ebp),%ebx\nleal (%ebx,%edi),%ebx\nmovl %ebx,(%esi,%edi)\n.LC3195:\nincl -8(%ebp)\ncmpl $17,-8(%ebp)\njl .LC3194\nflds .LC421\nfstps -152(%ebp)\nmovl $0,-8(%ebp)\n.LC3198:\nflds -152(%ebp)\nmovl -8(%ebp),%edi\nleal -148(%ebp),%esi\nmovl (%esi,%edi,4),%edi\nfadds (,%edi)\nfstps -152(%ebp)\n.LC3199:\nincl -8(%ebp)\ncmpl $17,-8(%ebp)\njl .LC3198\nflds .LC3204\nfcomps -152(%ebp)\nfstsw %ax\nsahf\nje .LC3202\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3205\npushl $4\npushl $s84er.3181\ncall printf\naddl $8,%esp\n.LC3205:\naddl $4,-164(%ebp)\n.LC3202:\nmovl $0,-12(%ebp)\n.LC3207:\nmovl $0,-8(%ebp)\n.LC3211:\nmovl $0,-4(%ebp)\n.LC3215:\nmovl -4(%ebp),%edi\nmovl -8(%ebp),%esi\nmovl -12(%ebp),%ebx\nimul $28,%esi,%edx\nimul $140,%ebx,%ecx\nleal x3d.3180(%ecx),%ecx\nleal (%ecx,%edx),%edx\nimul $35,%ebx,%ebx\nimul $7,%esi,%esi\nleal (%esi,%ebx),%esi\nleal (%edi,%esi),%esi\nmovl %esi,(%edx,%edi,4)\n.LC3216:\nincl -4(%ebp)\ncmpl $7,-4(%ebp)\njl .LC3215\n.LC3212:\nincl -8(%ebp)\ncmpl $5,-8(%ebp)\njl .LC3211\n.LC3208:\nincl -12(%ebp)\ncmpl $3,-12(%ebp)\njl .LC3207\nmovl $1,-12(%ebp)\nmovl $2,-8(%ebp)\nmovl $3,-4(%ebp)\npushl $0\npushl $105\npushl $x3d.3180\ncall array\naddl $12,%esp\nmovl %eax,%edi\npushl $35\npushl $35\nimul $140,-12(%ebp),%esi\nleal x3d.3180(%esi),%esi\npushl %esi\ncall array\naddl $12,%esp\nmovl %eax,%esi\npushl $49\npushl $7\nimul $28,-8(%ebp),%ebx\nimul $140,-12(%ebp),%edx\nleal x3d.3180(%edx),%edx\nleal (%edx,%ebx),%ebx\npushl %ebx\ncall array\naddl $12,%esp\nleal (%esi,%edi),%edi\nleal (%eax,%edi),%edi\nmovl -4(%ebp),%esi\nimul $28,-8(%ebp),%ebx\nimul $140,-12(%ebp),%edx\nleal x3d.3180(%edx),%edx\nleal (%edx,%ebx),%ebx\nmovl (%ebx,%esi,4),%esi\nleal (%esi,%edi),%edi\nsubl $52,%edi\ncmpl $0,%edi\nje .LC3219\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3221\npushl $8\npushl $s84er.3181\ncall printf\naddl $8,%esp\n.LC3221:\naddl $8,-164(%ebp)\n.LC3219:\nmovl -164(%ebp),%eax\n.LC3179:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf3223:\n.size s84,.Lf3223-s84\n.globl array\n.align 16\n.type array,@function\narray:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\nmovl $0,-4(%ebp)\njmp .LC3228\n.LC3225:\nmovl -4(%ebp),%edi\nmovl 20(%ebp),%esi\nmovl 28(%ebp),%ebx\nleal (%ebx,%edi),%ebx\ncmpl %ebx,(%esi,%edi,4)\nje .LC3229\nmovl $1,%eax\njmp .LC3224\n.LC3229:\n.LC3226:\nincl -4(%ebp)\n.LC3228:\nmovl 24(%ebp),%edi\ncmpl %edi,-4(%ebp)\njl .LC3225\nmovl $0,%eax\n.LC3224:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf3231:\n.size array,.Lf3231-array\n.bss\n.align 4\n.type y.3233,@object\n.size y.3233,4\n.lcomm y.3233,4\n.globl fip\n.text\n.align 16\n.type fip,@function\nfip:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nleal y.3233,%edi\nmovl 20(%ebp),%esi\nmovl %esi,y.3233\nmovl %edi,%eax\n.LC3232:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf3234:\n.size fip,.Lf3234-fip\n.globl glork\n.align 16\n.type glork,@function\nglork:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl 20(%ebp),%eax\n.LC3235:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf3236:\n.size glork,.Lf3236-glork\n.data\n.align 1\n.type s85er.3238,@object\ns85er.3238:\n.byte 115\n.byte 56\n.byte 53\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size s85er.3238,10\n.align 1\n.type qs85.3239,@object\n.size qs85.3239,8\nqs85.3239:\n.byte 115\n.byte 56\n.byte 53\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.align 4\n.type type.3247,@object\ntype.3247:\n.long .LC434\n.long .LC436\n.long .LC435\n.long .LC437\n.long .LC438\n.long .LC439\n.long .LC440\n.size type.3247,28\n.align 1\n.type aln.3248,@object\naln.3248:\n.byte 32\n.byte 97\n.byte 108\n.byte 105\n.byte 103\n.byte 110\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 58\n.byte 32\n.byte 0\n.size aln.3248,13\n.globl s85\n.text\n.align 16\n.type s85,@function\ns85:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $404,%esp\nleal qs85.3239,%edi\nmovl %edi,-276(%ebp)\nmovl 20(%ebp),%edi\nleal 60(%edi),%edi\nmovl %edi,-280(%ebp)\nmovl $0,-320(%ebp)\n.LC3252:\n.LC3253:\nmovl -280(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-280(%ebp)\nmovl -276(%ebp),%esi\nleal 1(%esi),%ebx\nmovl %ebx,-276(%ebp)\nmovb (,%esi),%bl\nmovb %bl,(,%edi)\nmovsbl %bl,%edi\ncmpl $0,%edi\njne .LC3252\nleal -296(%ebp),%edi\nleal -316(%ebp),%esi\nsubl %esi,%edi\ncmpl $0,%edi\njle .LC3263\nleal -292(%ebp),%edi\nleal -296(%ebp),%esi\nsubl %esi,%edi\ncmpl $0,%edi\njle .LC3263\nleal -288(%ebp),%edi\nleal -292(%ebp),%esi\nsubl %esi,%edi\ncmpl $0,%edi\njg .LC3255\n.LC3263:\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3264\npushl $1\npushl $s85er.3238\ncall printf\naddl $8,%esp\n.LC3264:\nincl -320(%ebp)\n.LC3255:\nleal -355(%ebp),%edi\nleal -356(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-272(%ebp)\nleal -358(%ebp),%edi\nleal -360(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-268(%ebp)\nleal -364(%ebp),%edi\nleal -368(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-264(%ebp)\nleal -372(%ebp),%edi\nleal -376(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-260(%ebp)\nleal -380(%ebp),%edi\nleal -384(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-256(%ebp)\nleal -388(%ebp),%edi\nleal -392(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-252(%ebp)\nleal -400(%ebp),%edi\nleal -404(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,-248(%ebp)\nmovl 20(%ebp),%edi\ncmpl $0,40(%edi)\nje .LC3279\nmovl $0,-244(%ebp)\n.LC3281:\nmovl -244(%ebp),%edi\nleal (,%edi,4),%edi\nleal -272(%ebp),%esi\npushl (%esi,%edi)\npushl $aln.3248\npushl type.3247(%edi)\npushl $.LC3285\ncall printf\naddl $16,%esp\n.LC3282:\nincl -244(%ebp)\ncmpl $7,-244(%ebp)\njl .LC3281\n.LC3279:\nmovl -284(%ebp),%edi\norl $56,%edi\nmovl %edi,-284(%ebp)\nmovl -284(%ebp),%edi\nmovl %edi,%esi\nandl $0xfffffffc,%esi\nsall $26,%edi\nsarl $29,%edi\nsall $30,%edi\nsarl $30,%edi\nandl $3,%edi\norl %edi,%esi\nmovl %esi,-284(%ebp)\nmovl -284(%ebp),%edi\nmovl %edi,%esi\nandl $0xffffffc7,%esi\nsall $30,%edi\nsarl $30,%edi\nsall $29,%edi\nsarl $29,%edi\nleal (,%edi,8),%edi\nandl $56,%edi\norl %edi,%esi\nmovl %esi,-284(%ebp)\nmovl -284(%ebp),%edi\nsall $26,%edi\nsarl $29,%edi\ncmpl $3,%edi\nje .LC3286\nmovl -284(%ebp),%edi\nsall $26,%edi\nsarl $29,%edi\ncmpl $-1,%edi\njne .LC3288\nmovl 20(%ebp),%edi\ncmpl $0,40(%edi)\nje .LC3289\npushl $.LC3292\ncall printf\naddl $4,%esp\njmp .LC3289\n.LC3288:\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3293\npushl $2\npushl $s85er.3238\ncall printf\naddl $8,%esp\n.LC3293:\naddl $2,-320(%ebp)\n.LC3289:\n.LC3286:\nmovl -284(%ebp),%edi\norl $64,%edi\nmovl %edi,-284(%ebp)\nmovl -284(%ebp),%edi\nsall $25,%edi\nsarl $31,%edi\ncmpl $1,%edi\nje .LC3295\nmovl 20(%ebp),%edi\ncmpl $0,40(%edi)\nje .LC3297\npushl $.LC3299\ncall printf\naddl $4,%esp\n.LC3297:\n.LC3295:\nleal -240(%ebp),%edi\nmovl %edi,%esi\nsubl %edi,%esi\ncmpl $0,%esi\njne .LC3307\ncmpl $0,%esi\njne .LC3307\ncmpl $0,%esi\njne .LC3307\ncmpl $0,%esi\njne .LC3307\ncmpl $0,%esi\njne .LC3307\ncmpl $0,%esi\njne .LC3307\ncmpl $0,%esi\nje .LC3300\n.LC3307:\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3308\npushl $4\npushl $s85er.3238\ncall printf\naddl $8,%esp\n.LC3308:\naddl $4,-320(%ebp)\n.LC3300:\njmp .LC3310\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3312\npushl $8\npushl $s85er.3238\ncall printf\naddl $8,%esp\n.LC3312:\naddl $8,-320(%ebp)\n.LC3310:\nleal -352(%ebp),%edi\nmovl %edi,-288(%ebp)\nmovb $2,-352(%ebp)\nmovl -288(%ebp),%edi\nmovsbl (,%edi),%esi\nleal 1(%esi),%esi\nmovl %esi,%ebx\nmovb %bl,(,%edi)\nmovsbl -352(%ebp),%edi\ncmpl $3,%edi\nje .LC3316\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3318\npushl $16\npushl $s85er.3238\ncall printf\naddl $8,%esp\n.LC3318:\naddl $16,-320(%ebp)\n.LC3316:\nmovl -320(%ebp),%eax\n.LC3237:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf3320:\n.size s85,.Lf3320-s85\n.data\n.align 1\n.type s86er.3322,@object\ns86er.3322:\n.byte 115\n.byte 56\n.byte 54\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size s86er.3322,10\n.align 1\n.type qs86.3323,@object\n.size qs86.3323,8\nqs86.3323:\n.byte 115\n.byte 56\n.byte 54\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.align 4\n.type x.3324,@object\nx.3324:\n.long 1\n.long 3\n.long 5\n.size x.3324,12\n.align 4\n.type pint.3325,@object\n.size pint.3325,4\npint.3325:\n.long x.3324+8\n.bss\n.align 4\n.type zero.3327,@object\n.size zero.3327,40\n.lcomm zero.3327,40\n.data\n.align 4\n.type y0.3328,@object\ny0.3328:\n.long 1065353216\n.long 1077936128\n.long 1084227584\n.long 1073741824\n.long 1082130432\n.long 1086324736\n.long 1077936128\n.long 1084227584\n.long 1088421888\n.long 0\n.long 0\n.long 0\n.size y0.3328,48\n.align 4\n.type y1.3329,@object\n.size y1.3329,48\ny1.3329:\n.long 1065353216\n.long 1077936128\n.long 1084227584\n.long 1073741824\n.long 1082130432\n.long 1086324736\n.long 1077936128\n.long 1084227584\n.long 1088421888\n.space 12\n.align 4\n.type y2.3330,@object\n.size y2.3330,48\ny2.3330:\n.long 1065353216\n.long 1077936128\n.long 1084227584\n.long 1073741824\n.long 1082130432\n.long 1086324736\n.long 1077936128\n.long 1084227584\n.long 1088421888\n.space 12\n.align 4\n.type y3.3331,@object\n.size y3.3331,48\ny3.3331:\n.long 1065353216\n.space 8\n.long 1073741824\n.space 8\n.long 1077936128\n.space 8\n.long 1082130432\n.space 8\n.globl s86\n.text\n.align 16\n.type s86,@function\ns86:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $40,%esp\nmovl pint.3325,%edi\nleal -4(%edi),%edi\nmovl %edi,-36(%ebp)\ncall one\nmovl -36(%ebp),%esi\nleal (%esi,%eax,4),%edi\nmovl %edi,-4(%ebp)\nleal qs86.3323,%edi\nmovl %edi,-24(%ebp)\nmovl 20(%ebp),%edi\nleal 60(%edi),%edi\nmovl %edi,-28(%ebp)\nmovl $0,-32(%ebp)\n.LC3332:\n.LC3333:\nmovl -28(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-28(%ebp)\nmovl -24(%ebp),%esi\nleal 1(%esi),%ebx\nmovl %ebx,-24(%ebp)\nmovb (,%esi),%bl\nmovb %bl,(,%edi)\nmovsbl %bl,%edi\ncmpl $0,%edi\njne .LC3332\nmovl pint.3325,%edi\ncmpl $5,(,%edi)\nje .LC3335\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3337\npushl $1\npushl $s86er.3322\ncall printf\naddl $8,%esp\n.LC3337:\nincl -32(%ebp)\n.LC3335:\nmovl -36(%ebp),%edi\ncmpl $3,(,%edi)\nje .LC3339\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3341\npushl $2\npushl $s86er.3322\ncall printf\naddl $8,%esp\n.LC3341:\naddl $2,-32(%ebp)\n.LC3339:\nmovl -4(%ebp),%edi\ncmpl $5,(,%edi)\nje .LC3343\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3345\npushl $4\npushl $s86er.3322\ncall printf\naddl $8,%esp\n.LC3345:\naddl $4,-32(%ebp)\n.LC3343:\nmovl $0,-20(%ebp)\nmovl $0,-8(%ebp)\n.LC3347:\nmovl -8(%ebp),%edi\ncmpl $0,zero.3327(,%edi,4)\nje .LC3351\nmovl $1,-20(%ebp)\n.LC3351:\n.LC3348:\nincl -8(%ebp)\ncmpl $10,-8(%ebp)\njl .LC3347\ncmpl $0,-20(%ebp)\nje .LC3353\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3355\npushl $8\npushl $s86er.3322\ncall printf\naddl $8,%esp\n.LC3355:\naddl $8,-32(%ebp)\n.LC3353:\nmovl $0,-20(%ebp)\nmovl $0,-12(%ebp)\n.LC3357:\nmovl $0,-8(%ebp)\n.LC3361:\nimul $3,-12(%ebp),%edi\nmovl -8(%ebp),%esi\nleal (%esi,%edi),%edi\nmovl %edi,-16(%ebp)\nmovl -8(%ebp),%edi\nleal (,%edi,4),%edi\nimul $12,-12(%ebp),%esi\nleal y1.3329(%esi),%ebx\nflds (%ebx,%edi)\nfstps -40(%ebp)\nleal y2.3330(%esi),%esi\nflds (%esi,%edi)\nfcomps -40(%ebp)\nfstsw %ax\nsahf\njne .LC3367\nmovl -16(%ebp),%edi\nflds y0.3328(,%edi,4)\nfcomps -40(%ebp)\nfstsw %ax\nsahf\nje .LC3365\n.LC3367:\nmovl $1,-20(%ebp)\n.LC3365:\n.LC3362:\nincl -8(%ebp)\ncmpl $3,-8(%ebp)\njl .LC3361\n.LC3358:\nincl -12(%ebp)\ncmpl $4,-12(%ebp)\njl .LC3357\ncmpl $0,-20(%ebp)\nje .LC3368\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3370\npushl $16\npushl $s86er.3322\ncall printf\naddl $8,%esp\n.LC3370:\naddl $16,-32(%ebp)\n.LC3368:\nmovl $0,-20(%ebp)\nmovl $0,-8(%ebp)\n.LC3372:\nmovl -8(%ebp),%edi\nimul $12,%edi,%esi\nleal 1(%edi),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfcomps y3.3331(%esi)\nfstsw %ax\nsahf\nje .LC3376\nmovl $1,-20(%ebp)\n.LC3376:\n.LC3373:\nincl -8(%ebp)\ncmpl $4,-8(%ebp)\njl .LC3372\ncmpl $0,-20(%ebp)\nje .LC3378\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3380\npushl $32\npushl $s86er.3322\ncall printf\naddl $8,%esp\n.LC3380:\naddl $32,-32(%ebp)\n.LC3378:\nmovl -32(%ebp),%eax\n.LC3321:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf3382:\n.size s86,.Lf3382-s86\n.globl one\n.align 16\n.type one,@function\none:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl $1,%eax\n.LC3383:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf3384:\n.size one,.Lf3384-one\n.data\n.align 1\n.type s88er.3386,@object\ns88er.3386:\n.byte 115\n.byte 56\n.byte 56\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size s88er.3386,10\n.align 1\n.type qs88.3387,@object\n.size qs88.3387,8\nqs88.3387:\n.byte 115\n.byte 56\n.byte 56\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s88\n.text\n.align 16\n.type s88,@function\ns88:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $44,%esp\nleal qs88.3387,%edi\nmovl %edi,-4(%ebp)\nmovl 20(%ebp),%edi\nleal 60(%edi),%edi\nmovl %edi,-8(%ebp)\nmovl $0,-12(%ebp)\n.LC3389:\n.LC3390:\nmovl -8(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-8(%ebp)\nmovl -4(%ebp),%esi\nleal 1(%esi),%ebx\nmovl %ebx,-4(%ebp)\nmovb (,%esi),%bl\nmovb %bl,(,%edi)\nmovsbl %bl,%edi\ncmpl $0,%edi\njne .LC3389\njmp .LC3392\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3394\npushl $1\npushl $s88er.3386\ncall printf\naddl $8,%esp\n.LC3394:\nincl -12(%ebp)\n.LC3392:\nleal -32(%ebp),%edi\nmovl %edi,metricp\nmovl $2,-32(%ebp)\nmovl metricp,%edi\nmovl $3,(,%edi)\ncmpl $3,-32(%ebp)\nje .LC3396\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3398\npushl $2\npushl $s88er.3386\ncall printf\naddl $8,%esp\n.LC3398:\naddl $2,-12(%ebp)\n.LC3396:\nfldl .LC428\nfstpl -28(%ebp)\nfldl .LC428\nfstpl -20(%ebp)\nleal -28(%ebp),%edi\nmovl %edi,-36(%ebp)\nmovl -36(%ebp),%edi\nfldl .LC427\nfstpl (,%edi)\nmovl -36(%ebp),%edi\nfldl .LC427\nfstpl 8(%edi)\nfldl -28(%ebp)\nfaddl -20(%ebp)\nfldl .LC425\nfcompp\nfstsw %ax\nsahf\nje .LC3401\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3404\npushl $4\npushl $s88er.3386\ncall printf\naddl $8,%esp\n.LC3404:\naddl $4,-12(%ebp)\n.LC3401:\nmovl -12(%ebp),%eax\n.LC3385:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf3406:\n.size s88,.Lf3406-s88\n.data\n.align 1\n.type s9er.3408,@object\ns9er.3408:\n.byte 115\n.byte 57\n.byte 44\n.byte 101\n.byte 114\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.size s9er.3408,9\n.align 1\n.type qs9.3409,@object\n.size qs9.3409,8\nqs9.3409:\n.byte 115\n.byte 57\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 0\n.globl s9\n.text\n.align 16\n.type s9,@function\ns9:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $36,%esp\nleal qs9.3409,%edi\nmovl %edi,-12(%ebp)\nmovl 20(%ebp),%edi\nleal 60(%edi),%edi\nmovl %edi,-16(%ebp)\nmovl $0,-20(%ebp)\n.LC3410:\n.LC3411:\nmovl -16(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-16(%ebp)\nmovl -12(%ebp),%esi\nleal 1(%esi),%ebx\nmovl %ebx,-12(%ebp)\nmovb (,%esi),%bl\nmovb %bl,(,%edi)\nmovsbl %bl,%edi\ncmpl $0,%edi\njne .LC3410\nmovl $0,-8(%ebp)\nmovl $0,-4(%ebp)\n.LC3413:\nmovl $2,-24(%ebp)\nmovl $2,-28(%ebp)\nmovl $3,-32(%ebp)\nmovl $3,-36(%ebp)\ncmpl $3,-36(%ebp)\njne .LC3419\ncmpl $3,-32(%ebp)\nje .LC3417\n.LC3419:\nmovl $1,-8(%ebp)\n.LC3417:\ncmpl $2,-28(%ebp)\njne .LC3422\ncmpl $2,-24(%ebp)\nje .LC3420\n.LC3422:\nmovl $1,-8(%ebp)\n.LC3420:\n.LC3414:\nincl -4(%ebp)\ncmpl $2,-4(%ebp)\njl .LC3413\ncmpl $0,-8(%ebp)\nje .LC3427\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3425\npushl $1\npushl $s9er.3408\ncall printf\naddl $8,%esp\n.LC3425:\nincl -20(%ebp)\njmp .LC3427\nmovl 20(%ebp),%edi\ncmpl $0,44(%edi)\nje .LC3428\npushl $2\npushl $s9er.3408\ncall printf\naddl $8,%esp\n.LC3428:\naddl $2,-20(%ebp)\n.LC3427:\nmovl -20(%ebp),%eax\n.LC3407:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf3430:\n.size s9,.Lf3430-s9\n.globl setev\n.align 16\n.type setev,@function\nsetev:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl $1066,extvar\nmovl $0,%eax\n.LC3431:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf3432:\n.size setev,.Lf3432-setev\n.bss\n.globl rfs\n.align 1\n.type rfs,@object\n.size rfs,8\n.comm rfs,8\n.globl crc\n.align 4\n.type crc,@object\n.size crc,4\n.comm crc,4\n.globl rrc\n.align 4\n.type rrc,@object\n.size rrc,4\n.comm rrc,4\n.globl flgl\n.align 4\n.type flgl,@object\n.size flgl,4\n.comm flgl,4\n.globl flgd\n.align 4\n.type flgd,@object\n.size flgd,4\n.comm flgd,4\n.globl flgm\n.align 4\n.type flgm,@object\n.size flgm,4\n.comm flgm,4\n.globl flgs\n.align 4\n.type flgs,@object\n.size flgs,4\n.comm flgs,4\n.globl dprec\n.align 4\n.type dprec,@object\n.size dprec,4\n.comm dprec,4\n.globl fprec\n.align 4\n.type fprec,@object\n.size fprec,4\n.comm fprec,4\n.globl dbits\n.align 4\n.type dbits,@object\n.size dbits,4\n.comm dbits,4\n.globl fbits\n.align 4\n.type fbits,@object\n.size fbits,4\n.comm fbits,4\n.globl ubits\n.align 4\n.type ubits,@object\n.size ubits,4\n.comm ubits,4\n.globl lbits\n.align 4\n.type lbits,@object\n.size lbits,4\n.comm lbits,4\n.globl metricp\n.align 4\n.type metricp,@object\n.size metricp,4\n.comm metricp,4\n.globl extvar\n.align 4\n.type extvar,@object\n.size extvar,4\n.comm extvar,4\n.data\n.align 1\n.LC3299:\n.byte 66\n.byte 101\n.byte 32\n.byte 101\n.byte 115\n.byte 112\n.byte 101\n.byte 99\n.byte 105\n.byte 97\n.byte 108\n.byte 108\n.byte 121\n.byte 32\n.byte 99\n.byte 97\n.byte 114\n.byte 101\n.byte 102\n.byte 117\n.byte 108\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 49\n.byte 45\n.byte 98\n.byte 105\n.byte 116\n.byte 32\n.byte 102\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 115\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.LC3292:\n.byte 83\n.byte 105\n.byte 103\n.byte 110\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 101\n.byte 110\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 102\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.LC3285:\n.byte 37\n.byte 115\n.byte 37\n.byte 115\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 4\n.LC3204:\n.long 1124597760\n.align 1\n.LC3047:\n.byte 112\n.byte 111\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 0\n.align 1\n.LC2495:\n.byte 73\n.byte 110\n.byte 99\n.byte 114\n.byte 101\n.byte 97\n.byte 115\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 97\n.byte 114\n.byte 114\n.byte 97\n.byte 121\n.byte 32\n.byte 101\n.byte 108\n.byte 101\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 97\n.byte 115\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 100\n.byte 101\n.byte 99\n.byte 114\n.byte 101\n.byte 97\n.byte 115\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 108\n.byte 111\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 10\n.byte 0\n.align 4\n.LC2378:\n.long 1104150528\n.align 4\n.LC2377:\n.long 0\n.long 1077542912\n.align 4\n.LC1678:\n.long 0\n.long 1074003968\n.align 4\n.LC1503:\n.long 0\n.long 1076101120\n.align 4\n.LC1474:\n.long 1092616192\n.align 4\n.LC1299:\n.long 0\n.long 1074266112\n.align 4\n.LC1270:\n.long 1077936128\n.align 4\n.LC1095:\n.long 0\n.long 1075576832\n.align 4\n.LC1066:\n.long 1088421888\n.align 4\n.LC889:\n.long 0\n.long 1075052544\n.align 4\n.LC860:\n.long 1084227584\n.align 4\n.LC855:\n.long 0\n.long 1105199104\n.align 4\n.LC847:\n.long 1325400064\n.align 1\n.LC669:\n.byte 113\n.byte 117\n.byte 101\n.byte 101\n.byte 112\n.byte 0\n.align 1\n.LC654:\n.byte 10\n.byte 0\n.align 1\n.LC653:\n.byte 37\n.byte 100\n.byte 0\n.align 1\n.LC648:\n.byte 32\n.byte 32\n.byte 32\n.byte 107\n.byte 101\n.byte 121\n.byte 61\n.byte 0\n.align 4\n.LC611:\n.long 0\n.long 1073741824\n.align 4\n.LC551:\n.long 0\n.long 1087276160\n.align 4\n.LC550:\n.long 0\n.long 1079984128\n.align 4\n.LC549:\n.long 1123680256\n.align 4\n.LC544:\n.long 1073741824\n.align 1\n.LC440:\n.byte 100\n.byte 111\n.byte 117\n.byte 98\n.byte 108\n.byte 101\n.byte 0\n.align 1\n.LC439:\n.byte 102\n.byte 108\n.byte 111\n.byte 97\n.byte 116\n.byte 0\n.align 1\n.LC438:\n.byte 117\n.byte 110\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 101\n.byte 100\n.byte 0\n.align 1\n.LC437:\n.byte 108\n.byte 111\n.byte 110\n.byte 103\n.byte 0\n.align 1\n.LC436:\n.byte 115\n.byte 104\n.byte 111\n.byte 114\n.byte 116\n.byte 0\n.align 1\n.LC435:\n.byte 105\n.byte 110\n.byte 116\n.byte 0\n.align 1\n.LC434:\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 0\n.align 4\n.LC428:\n.long 0\n.long 0\n.align 4\n.LC427:\n.long 0\n.long 1072693248\n.align 4\n.LC426:\n.long 0\n.long 1074790400\n.align 4\n.LC425:\n.long 0\n.long 1073741824\n.align 4\n.LC421:\n.long 0\n.align 4\n.LC420:\n.long 1065353216\n.align 1\n.LC398:\n.byte 113\n.byte 117\n.byte 101\n.byte 101\n.byte 112\n.byte 33\n.byte 0\n.align 1\n.LC387:\n.byte 10\n.byte 9\n.byte 8\n.byte 13\n.byte 12\n.byte 92\n.byte 39\n.byte 0\n.align 1\n.LC383:\n.byte 46\n.byte 34\n.byte 46\n.byte 0\n.align 1\n.LC370:\n.byte 46\n.byte 46\n.byte 46\n.byte 0\n.align 4\n.LC340:\n.long 0\n.long 1083410432\n.align 1\n.LC201:\n.byte 32\n.byte 32\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 114\n.byte 101\n.byte 115\n.byte 117\n.byte 108\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 110\n.byte 32\n.byte 97\n.byte 115\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 108\n.byte 111\n.byte 110\n.byte 103\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC200:\n.byte 68\n.byte 101\n.byte 99\n.byte 105\n.byte 109\n.byte 97\n.byte 108\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 111\n.byte 99\n.byte 116\n.byte 97\n.byte 108\n.byte 47\n.byte 104\n.byte 101\n.byte 120\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 115\n.byte 116\n.byte 97\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 115\n.byte 111\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 109\n.byte 101\n.byte 115\n.byte 32\n.byte 103\n.byte 105\n.byte 118\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC27:\n.byte 10\n.byte 70\n.byte 97\n.byte 105\n.byte 108\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC26:\n.byte 10\n.byte 78\n.byte 111\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 115\n.byte 32\n.byte 100\n.byte 101\n.byte 116\n.byte 101\n.byte 99\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC20:\n.byte 83\n.byte 101\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 37\n.byte 115\n.byte 32\n.byte 114\n.byte 101\n.byte 116\n.byte 117\n.byte 114\n.byte 110\n.byte 101\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.text\n.ident \"LCC: 4.1\"\n"
  },
  {
    "path": "lcc/x86/linux/tst/cvt.1bk",
    "content": "1 1 1 1 1 1 1 1 1.000000 1.000000 1.000000\n2 2 2 2 2 2 2 2 2.000000 2.000000 2.000000\n3 3 3 3 3 3 3 3 3.000000 3.000000 3.000000\n4 4 4 4 4 4 4 4 4.000000 4.000000 4.000000\n5 5 5 5 5 5 5 5 5.000000 5.000000 5.000000\n6 6 6 6 6 6 6 6 6.000000 6.000000 6.000000\n7 7 7 7 7 7 7 7 7.000000 7.000000 7.000000\n8 8 8 8 8 8 8 8 8.000000 8.000000 8.000000\n9 9 9 9 9 9 9 9 9.000000 9.000000 9.000000\n10 10 10 10 10 10 10 10 10.000000 10.000000 10.000000\n11 11 11 11 11 11 11 11 11.000000 11.000000 11.000000\n"
  },
  {
    "path": "lcc/x86/linux/tst/cvt.2bk",
    "content": "tst/cvt.c:32: warning: conversion from `pointer to void function(void)' to `pointer to void' is compiler dependent\ntst/cvt.c:33: warning: conversion from `pointer to void' to `pointer to void function(void)' is compiler dependent\n"
  },
  {
    "path": "lcc/x86/linux/tst/cvt.sbk",
    "content": ".globl print\n.text\n.align 16\n.type print,@function\nprint:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nfldl D\nsubl $8,%esp\nfstpl (%esp)\nfldl d\nsubl $8,%esp\nfstpl (%esp)\nflds f\nsubl $8,%esp\nfstpl (%esp)\npushl L\npushl I\nmovw S,%di\nmovzwl %di,%edi\npushl %edi\nmovb C,%bl\nmovzbl %bl,%edi\npushl %edi\npushl l\npushl i\nmovswl s,%edi\npushl %edi\nmovsbl c,%edi\npushl %edi\npushl $.LC2\ncall printf\naddl $60,%esp\n.LC1:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf3:\n.size print,.Lf3-print\n.globl main\n.align 16\n.type main,@function\nmain:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $296,%esp\nmovb $1,c\nmovsbl c,%edi\nmovl %edi,%esi\nmovw %si,s\nmovl %edi,i\nmovl %edi,l\nmovl %edi,%esi\nmovl %esi,%ebx\nmovb %bl,C\nmovl %esi,%ebx\nmovw %bx,S\nmovl %esi,I\nmovl %esi,L\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfstps f\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfstpl -8(%ebp)\nfldl -8(%ebp)\nfstpl d\nfldl -8(%ebp)\nfstpl D\ncall print\nmovw $2,s\nmovswl s,%edi\nmovl %edi,%ebx\nmovb %bl,c\nmovl %edi,i\nmovl %edi,l\nmovl %edi,%esi\nmovl %esi,%ebx\nmovb %bl,C\nmovl %esi,%ebx\nmovw %bx,S\nmovl %esi,I\nmovl %esi,L\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfstps f\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfstpl -16(%ebp)\nfldl -16(%ebp)\nfstpl d\nfldl -16(%ebp)\nfstpl D\ncall print\nmovl $3,i\nmovl i,%edi\nmovl %edi,%ebx\nmovb %bl,c\nmovl %edi,%esi\nmovw %si,s\nmovl %edi,l\nmovl %edi,%esi\nmovl %esi,%ebx\nmovb %bl,C\nmovl %esi,%ebx\nmovw %bx,S\nmovl %esi,I\nmovl %esi,L\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfstps f\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfstpl -24(%ebp)\nfldl -24(%ebp)\nfstpl d\nfldl -24(%ebp)\nfstpl D\ncall print\nmovl $4,l\nmovl l,%edi\nmovl %edi,%ebx\nmovb %bl,c\nmovl %edi,%esi\nmovw %si,s\nmovl %edi,i\nmovl %edi,%esi\nmovl %esi,%ebx\nmovb %bl,C\nmovl %esi,%ebx\nmovw %bx,S\nmovl %esi,I\nmovl %esi,L\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfstps f\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfstpl -32(%ebp)\nfldl -32(%ebp)\nfstpl d\nfldl -32(%ebp)\nfstpl D\ncall print\nmovb $5,C\nmovb C,%bl\nmovzbl %bl,%edi\nmovl %edi,%ebx\nmovb %bl,c\nmovl %edi,%esi\nmovw %si,s\nmovl %edi,i\nmovl %edi,l\nmovl %edi,%esi\nmovl %esi,%ebx\nmovw %bx,S\nmovl %esi,I\nmovl %esi,L\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfstps f\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfstpl -40(%ebp)\nfldl -40(%ebp)\nfstpl d\nfldl -40(%ebp)\nfstpl D\ncall print\nmovw $6,S\nmovw S,%di\nmovzwl %di,%edi\nmovl %edi,%ebx\nmovb %bl,c\nmovl %edi,%esi\nmovw %si,s\nmovl %edi,i\nmovl %edi,l\nmovl %edi,%esi\nmovl %esi,%ebx\nmovb %bl,C\nmovl %esi,I\nmovl %esi,L\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfstps f\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfstpl -48(%ebp)\nfldl -48(%ebp)\nfstpl d\nfldl -48(%ebp)\nfstpl D\ncall print\nmovl $7,I\nmovl I,%edi\nmovl %edi,%ebx\nmovb %bl,c\nmovl %edi,%ebx\nmovw %bx,s\nmovl %edi,i\nmovl %edi,l\nmovl %edi,%ebx\nmovb %bl,C\nmovl %edi,%esi\nmovw %si,S\nmovl %edi,L\nfldl .LC5\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nfstpl -56(%ebp)\nfldl -56(%ebp)\nfstps f\nfldl -56(%ebp)\nfstpl d\nfldl -56(%ebp)\nfstpl D\ncall print\nmovl $8,L\nmovl L,%edi\nmovl %edi,%ebx\nmovb %bl,c\nmovl %edi,%ebx\nmovw %bx,s\nmovl %edi,i\nmovl %edi,l\nmovl %edi,%ebx\nmovb %bl,C\nmovl %edi,%esi\nmovw %si,S\nmovw S,%si\nmovzwl %si,%esi\nmovl %esi,I\nfldl .LC5\nmovl %edi,%esi\nshrl $1,%esi\npushl %esi\nfildl (%esp)\naddl $4,%esp\nfmulp %st(1),%st\nandl $1,%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfaddp %st(1),%st\nfstpl -64(%ebp)\nfldl -64(%ebp)\nfstps f\nfldl -64(%ebp)\nfstpl d\nfldl -64(%ebp)\nfstpl D\ncall print\nflds .LC6\nfstps f\nflds f\nfstps -84(%ebp)\nflds -84(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,%ebx\nmovb %bl,c\nmovl %edi,%esi\nmovw %si,s\nmovl %edi,i\nmovl %edi,l\nflds .LC10\nfcomps -84(%ebp)\nfstsw %ax\nsahf\nja .LC8\nflds -84(%ebp)\nfsubs .LC10\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-68(%ebp)\njmp .LC9\n.LC8:\nflds -84(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-68(%ebp)\n.LC9:\nmovl -68(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,C\nflds .LC10\nfcomps f\nfstsw %ax\nsahf\nja .LC12\nflds f\nfsubs .LC10\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-72(%ebp)\njmp .LC13\n.LC12:\nflds f\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-72(%ebp)\n.LC13:\nmovl -72(%ebp),%edi\nmovw %di,S\nflds .LC10\nfcomps f\nfstsw %ax\nsahf\nja .LC15\nflds f\nfsubs .LC10\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-76(%ebp)\njmp .LC16\n.LC15:\nflds f\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-76(%ebp)\n.LC16:\nmovl -76(%ebp),%edi\nmovl %edi,I\nflds .LC10\nfcomps f\nfstsw %ax\nsahf\nja .LC18\nflds f\nfsubs .LC10\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-80(%ebp)\njmp .LC19\n.LC18:\nflds f\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-80(%ebp)\n.LC19:\nmovl -80(%ebp),%edi\nmovl %edi,L\nflds f\nfstpl -120(%ebp)\nfldl -120(%ebp)\nfstpl d\nfldl -120(%ebp)\nfstpl D\ncall print\nfldl .LC20\nfstpl d\nfldl d\nfstpl -144(%ebp)\nfldl -144(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,%ebx\nmovb %bl,c\nmovl %edi,%esi\nmovw %si,s\nmovl %edi,i\nmovl %edi,l\nfldl .LC24\nfcompl -144(%ebp)\nfstsw %ax\nsahf\nja .LC22\nfldl -144(%ebp)\nfsubl .LC24\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-124(%ebp)\njmp .LC23\n.LC22:\nfldl -144(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-124(%ebp)\n.LC23:\nmovl -124(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,C\nfldl .LC24\nfcompl d\nfstsw %ax\nsahf\nja .LC26\nfldl d\nfsubl .LC24\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-128(%ebp)\njmp .LC27\n.LC26:\nfldl d\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-128(%ebp)\n.LC27:\nmovl -128(%ebp),%edi\nmovw %di,S\nfldl .LC24\nfcompl d\nfstsw %ax\nsahf\nja .LC29\nfldl d\nfsubl .LC24\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-132(%ebp)\njmp .LC30\n.LC29:\nfldl d\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-132(%ebp)\n.LC30:\nmovl -132(%ebp),%edi\nmovl %edi,I\nfldl .LC24\nfcompl d\nfstsw %ax\nsahf\nja .LC32\nfldl d\nfsubl .LC24\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-136(%ebp)\njmp .LC33\n.LC32:\nfldl d\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-136(%ebp)\n.LC33:\nmovl -136(%ebp),%edi\nmovl %edi,L\nfldl d\nfstps f\nfldl d\nfstpl D\ncall print\nfldl .LC34\nfstpl D\nfldl D\nfstpl -232(%ebp)\nfldl -232(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,%ebx\nmovb %bl,c\nmovl %edi,%esi\nmovw %si,s\nmovl %edi,i\nmovl %edi,l\nfldl .LC38\nfcompl -232(%ebp)\nfstsw %ax\nsahf\nja .LC36\nfldl -232(%ebp)\nfsubl .LC38\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-212(%ebp)\njmp .LC37\n.LC36:\nfldl -232(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-212(%ebp)\n.LC37:\nmovl -212(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,C\nfldl .LC38\nfcompl D\nfstsw %ax\nsahf\nja .LC40\nfldl D\nfsubl .LC38\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-216(%ebp)\njmp .LC41\n.LC40:\nfldl D\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-216(%ebp)\n.LC41:\nmovl -216(%ebp),%edi\nmovw %di,S\nfldl .LC38\nfcompl D\nfstsw %ax\nsahf\nja .LC43\nfldl D\nfsubl .LC38\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-220(%ebp)\njmp .LC44\n.LC43:\nfldl D\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-220(%ebp)\n.LC44:\nmovl -220(%ebp),%edi\nmovl %edi,I\nfldl .LC38\nfcompl D\nfstsw %ax\nsahf\nja .LC46\nfldl D\nfsubl .LC38\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nleal 0x80000000(%edi),%edi\nmovl %edi,-224(%ebp)\njmp .LC47\n.LC46:\nfldl D\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,%edi\nmovl %edi,-224(%ebp)\n.LC47:\nmovl -224(%ebp),%edi\nmovl %edi,L\nfldl D\nfstps f\nfldl D\nfstpl d\ncall print\nmovl $0,p\nmovl $0,p\nmovl $0,p\nmovl $0,p\nmovl P,%edi\nmovl %edi,p\nmovl $0,P\nmovl $0,P\nmovl $0,P\nmovl $0,P\nmovl p,%edi\nmovl %edi,P\nmovl $0,%eax\n.LC4:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf48:\n.size main,.Lf48-main\n.bss\n.globl P\n.align 4\n.type P,@object\n.size P,4\n.comm P,4\n.globl p\n.align 4\n.type p,@object\n.size p,4\n.comm p,4\n.globl D\n.align 4\n.type D,@object\n.size D,8\n.comm D,8\n.globl d\n.align 4\n.type d,@object\n.size d,8\n.comm d,8\n.globl f\n.align 4\n.type f,@object\n.size f,4\n.comm f,4\n.globl L\n.align 4\n.type L,@object\n.size L,4\n.comm L,4\n.globl I\n.align 4\n.type I,@object\n.size I,4\n.comm I,4\n.globl S\n.align 2\n.type S,@object\n.size S,2\n.comm S,2\n.globl C\n.align 1\n.type C,@object\n.size C,1\n.comm C,1\n.globl l\n.align 4\n.type l,@object\n.size l,4\n.comm l,4\n.globl i\n.align 4\n.type i,@object\n.size i,4\n.comm i,4\n.globl s\n.align 2\n.type s,@object\n.size s,2\n.comm s,2\n.globl c\n.align 1\n.type c,@object\n.size c,1\n.comm c,1\n.data\n.align 4\n.LC38:\n.long 0\n.long 1105199104\n.align 4\n.LC34:\n.long 0\n.long 1076232192\n.align 4\n.LC24:\n.long 0\n.long 1105199104\n.align 4\n.LC20:\n.long 0\n.long 1076101120\n.align 4\n.LC10:\n.long 1325400064\n.align 4\n.LC6:\n.long 1091567616\n.align 4\n.LC5:\n.long 0\n.long 1073741824\n.align 1\n.LC2:\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 108\n.byte 100\n.byte 32\n.byte 37\n.byte 117\n.byte 32\n.byte 37\n.byte 117\n.byte 32\n.byte 37\n.byte 117\n.byte 32\n.byte 37\n.byte 108\n.byte 117\n.byte 32\n.byte 37\n.byte 102\n.byte 32\n.byte 37\n.byte 102\n.byte 32\n.byte 37\n.byte 108\n.byte 102\n.byte 10\n.byte 0\n.text\n.ident \"LCC: 4.1\"\n"
  },
  {
    "path": "lcc/x86/linux/tst/fields.1bk",
    "content": "x = 1 2 3 4 -3 6\ny = 3 8 9\nx = 1 2 3 0 0 6\ny = 2 8 16\np->a = 0x3, p->b = 0xf\n"
  },
  {
    "path": "lcc/x86/linux/tst/fields.2bk",
    "content": "tst/fields.c:6: warning: initializer exceeds bit-field width\ntst/fields.c:8: warning: initializer exceeds bit-field width\ntst/fields.c:30: warning: missing return value\ntst/fields.c:34: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/linux/tst/fields.sbk",
    "content": ".data\n.globl x\n.align 4\n.type x,@object\n.size x,16\nx:\n.long 1\n.byte 2\n.space 3\n.byte 3\n.byte 64\n.space 2\n.byte 80\n.byte 6\n.space 2\n.globl i\n.align 4\n.type i,@object\n.size i,4\ni:\n.long 16\n.globl y\n.align 4\n.type y,@object\n.size y,8\ny:\n.byte 35\n.space 3\n.byte 9\n.byte 0\n.byte 0\n.byte 0\n.globl main\n.text\n.align 16\n.type main,@function\nmain:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovsbl x+13,%edi\npushl %edi\nmovl x+12,%edi\nsall $25,%edi\nsarl $29,%edi\npushl %edi\nmovl x+8,%edi\nsall $16,%edi\nsarl $28,%edi\npushl %edi\nmovl x+8,%edi\nsall $20,%edi\nsarl $20,%edi\npushl %edi\nmovsbl x+4,%edi\npushl %edi\npushl x\npushl $.LC4\ncall printf\naddl $28,%esp\npushl y+4\nmovl y,%edi\nmovl %edi,%esi\nshrl $2,%esi\nandl $15,%esi\npushl %esi\nandl $3,%edi\npushl %edi\npushl $.LC10\ncall printf\naddl $16,%esp\nmovl x+8,%edi\nandl $0xffff0fff,%edi\nmovl i,%esi\nsall $28,%esi\nsarl $28,%esi\nshll $12,%esi\nandl $0xf000,%esi\norl %esi,%edi\nmovl %edi,x+8\nmovl x+12,%edi\nandl $0xffffff8f,%edi\nmovl %edi,x+12\nmovsbl x+13,%edi\npushl %edi\nmovl x+12,%edi\nsall $25,%edi\nsarl $29,%edi\npushl %edi\nmovl x+8,%edi\nsall $16,%edi\nsarl $28,%edi\npushl %edi\nmovl x+8,%edi\nsall $20,%edi\nsarl $20,%edi\npushl %edi\nmovsbl x+4,%edi\npushl %edi\npushl x\npushl $.LC4\ncall printf\naddl $28,%esp\nmovl y,%edi\nandl $0xfffffffc,%edi\norl $2,%edi\nmovl %edi,y\nmovl i,%edi\nmovl %edi,y+4\npushl y+4\nmovl y,%edi\nmovl %edi,%esi\nshrl $2,%esi\nandl $15,%esi\npushl %esi\nandl $3,%edi\npushl %edi\npushl $.LC10\ncall printf\naddl $16,%esp\npushl $x\ncall f2\naddl $4,%esp\nmovl $0,%eax\n.LC3:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf21:\n.size main,.Lf21-main\n.globl f1\n.align 16\n.type f1,@function\nf1:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl 20(%ebp),%edi\nandl $0xffffffc3,(,%edi)\nmovl 20(%ebp),%edi\nmovl (,%edi),%esi\nandl $0xfffffffc,%esi\nmovl $0,%ebx\nandl $3,%ebx\nandl $3,%ebx\norl %ebx,%esi\nmovl %esi,(,%edi)\nmovl 20(%ebp),%edi\nmovl (,%edi),%edi\nandl $60,%edi\ncmpl $0,%edi\nje .LC23\npushl $.LC25\ncall printf\naddl $4,%esp\n.LC23:\nmovl 20(%ebp),%edi\norl $3,(,%edi)\nmovl 20(%ebp),%edi\norl $60,(,%edi)\nmovl 20(%ebp),%edi\nmovl (,%edi),%edi\nmovl %edi,%esi\nshrl $2,%esi\nandl $15,%esi\npushl %esi\nandl $3,%edi\npushl %edi\npushl $.LC26\ncall printf\naddl $12,%esp\nmovl $0,%eax\n.LC22:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf27:\n.size f1,.Lf27-f1\n.globl f2\n.align 16\n.type f2,@function\nf2:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\ncmpl $0,i\njne .LC30\nmovl $1,-4(%ebp)\njmp .LC31\n.LC30:\nmovl $0,-4(%ebp)\n.LC31:\nmovl 20(%ebp),%edi\nmovl (,%edi),%esi\nandl $0xfffffffc,%esi\nmovl -4(%ebp),%ebx\nandl $3,%ebx\nandl $3,%ebx\norl %ebx,%esi\nmovl %esi,(,%edi)\nmovl 20(%ebp),%edi\npushl %edi\ncall f1\naddl $4,%esp\nmovl (,%edi),%esi\nandl $0xffffffc3,%esi\nmovl $0,%ebx\nandl $15,%ebx\nleal (,%ebx,4),%ebx\nandl $60,%ebx\norl %ebx,%esi\nmovl %esi,(,%edi)\nmovl $0,%eax\n.LC28:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf32:\n.size f2,.Lf32-f2\n.data\n.align 1\n.LC26:\n.byte 112\n.byte 45\n.byte 62\n.byte 97\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 120\n.byte 37\n.byte 120\n.byte 44\n.byte 32\n.byte 112\n.byte 45\n.byte 62\n.byte 98\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 120\n.byte 37\n.byte 120\n.byte 10\n.byte 0\n.align 1\n.LC25:\n.byte 112\n.byte 45\n.byte 62\n.byte 98\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.LC10:\n.byte 121\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC4:\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.text\n.ident \"LCC: 4.1\"\n"
  },
  {
    "path": "lcc/x86/linux/tst/front.2bk",
    "content": "tst/front.c:3: warning: missing return value\ntst/front.c:10: warning: missing return value\ntst/front.c:20: type error in argument 1 to `s'; found `pointer to struct D' expected `pointer to incomplete struct D defined at tst/front.c:14'\ntst/front.c:21: warning: missing return value\ntst/front.c:32: warning: missing return value\ntst/front.c:36: operands of = have illegal types `pointer to int' and `pointer to const int'\ntst/front.c:38: warning: missing return value\ntst/front.c:62: operands of = have illegal types `pointer to char' and `pointer to const void'\ntst/front.c:63: warning: missing return value\ntst/front.c:68: warning: missing return value\ntst/front.c:69: warning: inconsistent linkage for `yy' previously declared at tst/front.c:68\ntst/front.c:69: warning: missing return value\ntst/front.c:71: invalid storage class `static' for `int function goo'\ntst/front.c:71: warning: declaration of `goo' does not match previous declaration at tst/front.c:70\ntst/front.c:71: warning: missing return value\ntst/front.c:74: warning: declaration of `xr' does not match previous declaration at tst/front.c:72\ntst/front.c:74: warning: missing return value\ntst/front.c:81: warning: missing return value\ntst/front.c:82: warning: declaration of `ss2' does not match previous declaration at tst/front.c:81\ntst/front.c:84: warning: inconsistent linkage for `ss5' previously declared at tst/front.c:80\ntst/front.c:92: type error in argument 1 to `gx1'; found `pointer to double' expected `double'\ntst/front.c:92: warning: missing return value\ntst/front.c:95: redeclaration of `hx1' previously declared at tst/front.c:94\ntst/front.c:98: warning: missing return value\ntst/front.c:101: conflicting argument declarations for function `gg1'\ntst/front.c:101: warning: missing return value\ntst/front.c:112: type error in argument 4 to `qsort'; found `pointer to int function(pointer to pointer to char,pointer to pointer to char)' expected `pointer to int function(pointer to const void,pointer to const void)'\ntst/front.c:113: warning: missing return value\ntst/front.c:120: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/linux/tst/front.sbk",
    "content": ".globl main\n.text\n.align 16\n.type main,@function\nmain:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\npushl $0\ncall exit\naddl $4,%esp\nmovl $0,%eax\n.LC1:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf2:\n.size main,.Lf2-main\n.globl nested\n.align 16\n.type nested,@function\nnested:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\ncmpl $4,20(%ebp)\njge .LC7\ncmpl $114,24(%ebp)\nje .LC10\n.LC7:\ncmpl $1,20(%ebp)\njne .LC9\nmovl 24(%ebp),%edi\ncmpl $104,%edi\nje .LC10\ncmpl $105,%edi\nje .LC10\n.LC9:\ncmpl $2,20(%ebp)\njne .LC4\nmovl 24(%ebp),%edi\ncmpl $111,%edi\nje .LC10\ncmpl $121,%edi\njne .LC4\n.LC10:\nmovl 24(%ebp),%edi\nmovl %edi,20(%ebp)\n.LC4:\nmovl $0,%eax\n.LC3:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf11:\n.size nested,.Lf11-nested\n.globl s\n.align 16\n.type s,@function\ns:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\n.LC12:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf13:\n.size s,.Lf13-s\n.data\n.globl Dy\n.align 4\n.type Dy,@object\n.size Dy,8\nDy:\n.long 0\n.space 4\n.globl Dz\n.align 4\n.type Dz,@object\n.size Dz,8\nDz:\n.long 1\n.space 4\n.globl Dfunc\n.text\n.align 16\n.type Dfunc,@function\nDfunc:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf16:\n.size Dfunc,.Lf16-Dfunc\n.globl f\n.align 16\n.type f,@function\nf:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf18:\n.size f,.Lf18-f\n.globl f1\n.align 16\n.type f1,@function\nf1:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf20:\n.size f1,.Lf20-f1\n.globl f2\n.align 16\n.type f2,@function\nf2:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf22:\n.size f2,.Lf22-f2\n.globl g\n.align 16\n.type g,@function\ng:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf24:\n.size g,.Lf24-g\n.globl h\n.align 16\n.type h,@function\nh:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf26:\n.size h,.Lf26-h\n.globl h1\n.align 16\n.type h1,@function\nh1:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf28:\n.size h1,.Lf28-h1\n.globl h2\n.align 16\n.type h2,@function\nh2:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf30:\n.size h2,.Lf30-h2\n.data\n.align 4\n.type yy.32,@object\n.size yy.32,4\nyy.32:\n.long 1\n.globl set1\n.text\n.align 16\n.type set1,@function\nset1:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf33:\n.size set1,.Lf33-set1\n.data\n.align 4\n.type yy.35,@object\n.size yy.35,4\nyy.35:\n.long 2\n.globl set2\n.text\n.align 16\n.type set2,@function\nset2:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf36:\n.size set2,.Lf36-set2\n.align 16\n.type goo,@function\ngoo:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf38:\n.size goo,.Lf38-goo\n.globl sss\n.align 16\n.type sss,@function\nsss:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf40:\n.size sss,.Lf40-sss\n.bss\n.align 4\n.type xr.42,@object\n.size xr.42,4\n.lcomm xr.42,4\n.globl rrr\n.text\n.align 16\n.type rrr,@function\nrrr:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf43:\n.size rrr,.Lf43-rrr\n.globl setstatic\n.align 16\n.type setstatic,@function\nsetstatic:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf45:\n.size setstatic,.Lf45-setstatic\n.globl gx1\n.align 16\n.type gx1,@function\ngx1:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf47:\n.size gx1,.Lf47-gx1\n.globl ff1\n.align 16\n.type ff1,@function\nff1:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf49:\n.size ff1,.Lf49-ff1\n.globl gg1\n.align 16\n.type gg1,@function\ngg1:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf51:\n.size gg1,.Lf51-gg1\n.globl hh1\n.align 16\n.type hh1,@function\nhh1:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf53:\n.size hh1,.Lf53-hh1\n.globl cmp\n.align 16\n.type cmp,@function\ncmp:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf55:\n.size cmp,.Lf55-cmp\n.globl sort\n.align 16\n.type sort,@function\nsort:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf57:\n.size sort,.Lf57-sort\n.globl onearg\n.align 16\n.type onearg,@function\nonearg:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf65:\n.size onearg,.Lf65-onearg\n.bss\n.globl ss4\n.align 4\n.type ss4,@object\n.size ss4,4\n.comm ss4,4\n.align 4\n.type ss2,@object\n.size ss2,4\n.lcomm ss2,4\n.align 4\n.type ss5,@object\n.size ss5,4\n.lcomm ss5,4\n.globl ss3\n.align 4\n.type ss3,@object\n.size ss3,4\n.comm ss3,4\n.align 4\n.type ss1,@object\n.size ss1,4\n.lcomm ss1,4\n.align 4\n.type yy,@object\n.size yy,4\n.lcomm yy,4\n.globl z\n.align 4\n.type z,@object\n.size z,4\n.comm z,4\n.globl y\n.align 4\n.type y,@object\n.size y,4\n.comm y,4\n.globl x\n.align 4\n.type x,@object\n.size x,4\n.comm x,4\n.globl b\n.align 4\n.type b,@object\n.size b,4\n.comm b,4\n.globl a\n.align 4\n.type a,@object\n.size a,4\n.comm a,4\n.text\n.ident \"LCC: 4.1\"\n"
  },
  {
    "path": "lcc/x86/linux/tst/incr.1bk",
    "content": ""
  },
  {
    "path": "lcc/x86/linux/tst/incr.2bk",
    "content": "tst/incr.c:1: warning: missing return value\ntst/incr.c:6: warning: expression with no effect elided\ntst/incr.c:6: warning: expression with no effect elided\ntst/incr.c:11: warning: missing return value\ntst/incr.c:16: warning: expression with no effect elided\ntst/incr.c:16: warning: expression with no effect elided\ntst/incr.c:21: warning: missing return value\ntst/incr.c:30: warning: missing return value\ntst/incr.c:39: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/linux/tst/incr.sbk",
    "content": ".globl main\n.text\n.align 16\n.type main,@function\nmain:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl $0,%eax\n.LC1:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf2:\n.size main,.Lf2-main\n.globl memchar\n.align 16\n.type memchar,@function\nmemchar:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $8,%esp\nmovl -8(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-8(%ebp)\nmovb (,%edi),%bl\nmovb %bl,-1(%ebp)\nmovl -8(%ebp),%edi\nleal 1(%edi),%edi\nmovl %edi,-8(%ebp)\nmovb (,%edi),%bl\nmovb %bl,-1(%ebp)\nmovl -8(%ebp),%edi\nleal -1(%edi),%esi\nmovl %esi,-8(%ebp)\nmovb (,%edi),%bl\nmovb %bl,-1(%ebp)\nmovl -8(%ebp),%edi\nleal -1(%edi),%edi\nmovl %edi,-8(%ebp)\nmovb (,%edi),%bl\nmovb %bl,-1(%ebp)\nmovl $0,%eax\n.LC3:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf4:\n.size memchar,.Lf4-memchar\n.globl memint\n.align 16\n.type memint,@function\nmemint:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $8,%esp\nmovl -8(%ebp),%edi\nleal 4(%edi),%esi\nmovl %esi,-8(%ebp)\nmovl (,%edi),%edi\nmovl %edi,-4(%ebp)\nmovl -8(%ebp),%edi\nleal 4(%edi),%edi\nmovl %edi,-8(%ebp)\nmovl (,%edi),%edi\nmovl %edi,-4(%ebp)\nmovl -8(%ebp),%edi\nleal -4(%edi),%esi\nmovl %esi,-8(%ebp)\nmovl (,%edi),%edi\nmovl %edi,-4(%ebp)\nmovl -8(%ebp),%edi\nleal -4(%edi),%edi\nmovl %edi,-8(%ebp)\nmovl (,%edi),%edi\nmovl %edi,-4(%ebp)\nmovl $0,%eax\n.LC5:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf6:\n.size memint,.Lf6-memint\n.globl regchar\n.align 16\n.type regchar,@function\nregchar:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $8,%esp\nmovl -8(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-8(%ebp)\nmovb (,%edi),%bl\nmovb %bl,-1(%ebp)\nmovl -8(%ebp),%edi\nleal 1(%edi),%edi\nmovl %edi,-8(%ebp)\nmovb (,%edi),%bl\nmovb %bl,-1(%ebp)\nmovl -8(%ebp),%edi\nleal -1(%edi),%esi\nmovl %esi,-8(%ebp)\nmovb (,%edi),%bl\nmovb %bl,-1(%ebp)\nmovl -8(%ebp),%edi\nleal -1(%edi),%edi\nmovl %edi,-8(%ebp)\nmovb (,%edi),%bl\nmovb %bl,-1(%ebp)\nmovl $0,%eax\n.LC7:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf8:\n.size regchar,.Lf8-regchar\n.globl regint\n.align 16\n.type regint,@function\nregint:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $8,%esp\nmovl -8(%ebp),%edi\nleal 4(%edi),%esi\nmovl %esi,-8(%ebp)\nmovl (,%edi),%edi\nmovl %edi,-4(%ebp)\nmovl -8(%ebp),%edi\nleal 4(%edi),%edi\nmovl %edi,-8(%ebp)\nmovl (,%edi),%edi\nmovl %edi,-4(%ebp)\nmovl -8(%ebp),%edi\nleal -4(%edi),%esi\nmovl %esi,-8(%ebp)\nmovl (,%edi),%edi\nmovl %edi,-4(%ebp)\nmovl -8(%ebp),%edi\nleal -4(%edi),%edi\nmovl %edi,-8(%ebp)\nmovl (,%edi),%edi\nmovl %edi,-4(%ebp)\nmovl $0,%eax\n.LC9:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf10:\n.size regint,.Lf10-regint\n.ident \"LCC: 4.1\"\n"
  },
  {
    "path": "lcc/x86/linux/tst/init.1bk",
    "content": " 1 2 3 4\n 5 6\n 7\nif\nfor\nelse\nwhile\n1 2 3 if\n4 5 0 for\n6 7 8 else\n9 10 11 while\n1 2 3 if\n4 5 0 for\n6 7 8 else\n9 10 11 while\n0 0 0 \n"
  },
  {
    "path": "lcc/x86/linux/tst/init.2bk",
    "content": "tst/init.c:36: warning: missing return value\ntst/init.c:49: warning: missing return value\ntst/init.c:59: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/linux/tst/init.sbk",
    "content": ".data\n.globl words\n.align 4\n.type words,@object\nwords:\n.long 1\n.long 2\n.long 3\n.byte 105\n.byte 102\n.byte 0\n.space 3\n.space 2\n.long 4\n.long 5\n.space 4\n.byte 102\n.byte 111\n.byte 114\n.space 3\n.space 2\n.long 6\n.long 7\n.long 8\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 0\n.space 1\n.space 2\n.long 9\n.long 10\n.long 11\n.byte 119\n.byte 104\n.byte 105\n.byte 108\n.byte 101\n.space 1\n.space 2\n.long 0\n.space 8\n.space 8\n.size words,100\n.globl wordlist\n.align 4\n.type wordlist,@object\n.size wordlist,4\nwordlist:\n.long words\n.globl x\n.align 4\n.type x,@object\nx:\n.long 1\n.long 2\n.long 3\n.long 4\n.long 0\n.long 5\n.long 6\n.space 12\n.long 7\n.space 16\n.size x,60\n.globl y\n.align 4\n.type y,@object\ny:\n.long x\n.long x+20\n.long x+40\n.long 0\n.size y,16\n.globl main\n.text\n.align 16\n.type main,@function\nmain:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $8,%esp\nmovl $0,-8(%ebp)\njmp .LC8\n.LC5:\nmovl $0,-4(%ebp)\njmp .LC12\n.LC9:\nmovl -4(%ebp),%edi\nmovl -8(%ebp),%esi\nmovl y(,%esi,4),%esi\npushl (%esi,%edi,4)\npushl $.LC13\ncall printf\naddl $8,%esp\n.LC10:\nincl -4(%ebp)\n.LC12:\nmovl -4(%ebp),%edi\nmovl -8(%ebp),%esi\nmovl y(,%esi,4),%esi\ncmpl $0,(%esi,%edi,4)\njne .LC9\npushl $.LC14\ncall printf\naddl $4,%esp\n.LC6:\nincl -8(%ebp)\n.LC8:\nmovl -8(%ebp),%edi\nmovl y(,%edi,4),%edi\ncmpl $0,%edi\njne .LC5\ncall f\npushl wordlist\ncall g\naddl $4,%esp\nmovl $0,%eax\n.LC4:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf15:\n.size main,.Lf15-main\n.data\n.align 4\n.type keywords.17,@object\nkeywords.17:\n.long .LC18\n.long .LC19\n.long .LC20\n.long .LC21\n.long 0\n.size keywords.17,20\n.globl f\n.text\n.align 16\n.type f,@function\nf:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\nleal keywords.17,%edi\nmovl %edi,-4(%ebp)\njmp .LC25\n.LC22:\nmovl -4(%ebp),%edi\npushl (,%edi)\npushl $.LC26\ncall printf\naddl $8,%esp\n.LC23:\nmovl -4(%ebp),%edi\nleal 4(%edi),%edi\nmovl %edi,-4(%ebp)\n.LC25:\nmovl -4(%ebp),%edi\nmovl (,%edi),%edi\ncmpl $0,%edi\njne .LC22\nmovl $0,%eax\n.LC16:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf27:\n.size f,.Lf27-f\n.globl g\n.align 16\n.type g,@function\ng:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\njmp .LC32\n.LC29:\nmovl $0,-4(%ebp)\njmp .LC36\n.LC33:\nmovl -4(%ebp),%edi\nmovl 20(%ebp),%esi\npushl (%esi,%edi,4)\npushl $.LC37\ncall printf\naddl $8,%esp\n.LC34:\nincl -4(%ebp)\n.LC36:\nmovl -4(%ebp),%edi\ncmpl $3,%edi\njb .LC33\nmovl 20(%ebp),%edi\nleal 12(%edi),%edi\npushl %edi\npushl $.LC26\ncall printf\naddl $8,%esp\n.LC30:\nmovl 20(%ebp),%edi\nleal 20(%edi),%edi\nmovl %edi,20(%ebp)\n.LC32:\nmovl 20(%ebp),%edi\ncmpl $0,(,%edi)\njne .LC29\ncall h\nmovl $0,%eax\n.LC28:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf38:\n.size g,.Lf38-g\n.globl h\n.align 16\n.type h,@function\nh:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\nmovl $0,-4(%ebp)\njmp .LC43\n.LC40:\nimul $20,-4(%ebp),%edi\nleal words+12(%edi),%esi\npushl %esi\npushl words+8(%edi)\npushl words+4(%edi)\npushl words(%edi)\npushl $.LC44\ncall printf\naddl $20,%esp\n.LC41:\nincl -4(%ebp)\n.LC43:\nmovl -4(%ebp),%edi\ncmpl $5,%edi\njb .LC40\nmovl $0,%eax\n.LC39:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf48:\n.size h,.Lf48-h\n.data\n.align 1\n.LC44:\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.LC37:\n.byte 37\n.byte 100\n.byte 32\n.byte 0\n.align 1\n.LC26:\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.LC21:\n.byte 119\n.byte 104\n.byte 105\n.byte 108\n.byte 101\n.byte 0\n.align 1\n.LC20:\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 0\n.align 1\n.LC19:\n.byte 102\n.byte 111\n.byte 114\n.byte 0\n.align 1\n.LC18:\n.byte 105\n.byte 102\n.byte 0\n.align 1\n.LC14:\n.byte 10\n.byte 0\n.align 1\n.LC13:\n.byte 32\n.byte 37\n.byte 100\n.byte 0\n.text\n.ident \"LCC: 4.1\"\n"
  },
  {
    "path": "lcc/x86/linux/tst/limits.1bk",
    "content": "UCHAR_MAX:\t000000ff=255\nUSHRT_MAX:\t0000ffff=65535\nUINT_MAX:\tffffffff=-1\nULONG_MAX:\tffffffff=-1\nCHAR_MAX:\t0000007f=127\nSCHAR_MAX:\t0000007f=127\nSHRT_MAX:\t00007fff=32767\nINT_MAX:\t7fffffff=2147483647\nLONG_MAX:\t7fffffff=2147483647\nCHAR_MIN:\tffffff80=-128\nSCHAR_MIN:\tffffff80=-128\nSHRT_MIN:\tffff8000=-32768\nINT_MIN:\t80000000=-2147483648\nLONG_MIN:\t80000000=-2147483648\n"
  },
  {
    "path": "lcc/x86/linux/tst/limits.2bk",
    "content": ""
  },
  {
    "path": "lcc/x86/linux/tst/limits.sbk",
    "content": ".globl main\n.text\n.align 16\n.type main,@function\nmain:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\npushl $255\npushl $255\npushl $.LC2\ncall printf\naddl $12,%esp\npushl $65535\npushl $65535\npushl $.LC3\ncall printf\naddl $12,%esp\npushl $0xffffffff\npushl $0xffffffff\npushl $.LC4\ncall printf\naddl $12,%esp\npushl $0xffffffff\npushl $0xffffffff\npushl $.LC5\ncall printf\naddl $12,%esp\npushl $127\npushl $127\npushl $.LC6\ncall printf\naddl $12,%esp\npushl $127\npushl $127\npushl $.LC7\ncall printf\naddl $12,%esp\npushl $32767\npushl $32767\npushl $.LC8\ncall printf\naddl $12,%esp\npushl $2147483647\npushl $2147483647\npushl $.LC9\ncall printf\naddl $12,%esp\npushl $2147483647\npushl $2147483647\npushl $.LC10\ncall printf\naddl $12,%esp\npushl $-128\npushl $-128\npushl $.LC11\ncall printf\naddl $12,%esp\npushl $-128\npushl $-128\npushl $.LC12\ncall printf\naddl $12,%esp\npushl $-32768\npushl $-32768\npushl $.LC13\ncall printf\naddl $12,%esp\npushl $-2147483648\npushl $-2147483648\npushl $.LC14\ncall printf\naddl $12,%esp\npushl $-2147483648\npushl $-2147483648\npushl $.LC15\ncall printf\naddl $12,%esp\nmovl $0,%eax\n.LC1:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf16:\n.size main,.Lf16-main\n.data\n.align 1\n.LC15:\n.byte 76\n.byte 79\n.byte 78\n.byte 71\n.byte 95\n.byte 77\n.byte 73\n.byte 78\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 108\n.byte 120\n.byte 61\n.byte 37\n.byte 108\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC14:\n.byte 73\n.byte 78\n.byte 84\n.byte 95\n.byte 77\n.byte 73\n.byte 78\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC13:\n.byte 83\n.byte 72\n.byte 82\n.byte 84\n.byte 95\n.byte 77\n.byte 73\n.byte 78\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC12:\n.byte 83\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 95\n.byte 77\n.byte 73\n.byte 78\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC11:\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 95\n.byte 77\n.byte 73\n.byte 78\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC10:\n.byte 76\n.byte 79\n.byte 78\n.byte 71\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 108\n.byte 120\n.byte 61\n.byte 37\n.byte 108\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC9:\n.byte 73\n.byte 78\n.byte 84\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC8:\n.byte 83\n.byte 72\n.byte 82\n.byte 84\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC7:\n.byte 83\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC6:\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC5:\n.byte 85\n.byte 76\n.byte 79\n.byte 78\n.byte 71\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 108\n.byte 120\n.byte 61\n.byte 37\n.byte 108\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC4:\n.byte 85\n.byte 73\n.byte 78\n.byte 84\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC3:\n.byte 85\n.byte 83\n.byte 72\n.byte 82\n.byte 84\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC2:\n.byte 85\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 95\n.byte 77\n.byte 65\n.byte 88\n.byte 58\n.byte 9\n.byte 37\n.byte 48\n.byte 56\n.byte 120\n.byte 61\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.text\n.ident \"LCC: 4.1\"\n"
  },
  {
    "path": "lcc/x86/linux/tst/paranoia.1bk",
    "content": "Lest this program stop prematurely, i.e. before displaying\n\n    `END OF TEST',\n\ntry to persuade the computer NOT to terminate execution when an\nerror like Over/Underflow or Division by Zero occurs, but rather\nto persevere with a surrogate value after, perhaps, displaying some\nwarning.  If persuasion avails naught, don't despair but run this\nprogram anyway to see how many milestones it passes, and then\namend it to make further progress.\n\nAnswer questions with Y, y, N or n (unless otherwise indicated).\n\n\nDiagnosis resumes after milestone Number 0          Page: 1\n\nUsers are invited to help debug and augment this program so it will\ncope with unanticipated and newly uncovered arithmetic pathologies.\n\nPlease send suggestions and interesting results to\n\tRichard Karpinski\n\tComputer Center U-76\n\tUniversity of California\n\tSan Francisco, CA 94143-0704, USA\n\nIn doing so, please include the following information:\n\tPrecision:\tdouble;\n\tVersion:\t10 February 1989;\n\tComputer:\n\n\tCompiler:\n\n\tOptimization level:\n\n\tOther relevant compiler options:\n\nDiagnosis resumes after milestone Number 1          Page: 2\n\nRunning this program should reveal these characteristics:\n     Radix = 1, 2, 4, 8, 10, 16, 100, 256 ...\n     Precision = number of significant digits carried.\n     U2 = Radix/Radix^Precision = One Ulp\n\t(OneUlpnit in the Last Place) of 1.000xxx .\n     U1 = 1/Radix^Precision = One Ulp of numbers a little less than 1.0 .\n     Adequacy of guard digits for Mult., Div. and Subt.\n     Whether arithmetic is chopped, correctly rounded, or something else\n\tfor Mult., Div., Add/Subt. and Sqrt.\n     Whether a Sticky Bit used correctly for rounding.\n     UnderflowThreshold = an underflow threshold.\n     E0 and PseudoZero tell whether underflow is abrupt, gradual, or fuzzy.\n     V = an overflow threshold, roughly.\n     V0  tells, roughly, whether  Infinity  is represented.\n     Comparisions are checked for consistency with subtraction\n\tand for contamination with pseudo-zeros.\n     Sqrt is tested.  Y^X is not tested.\n     Extra-precise subexpressions are revealed but NOT YET tested.\n     Decimal-Binary conversion is NOT YET tested for accuracy.\n\nDiagnosis resumes after milestone Number 2          Page: 3\n\nThe program attempts to discriminate among\n   FLAWs, like lack of a sticky bit,\n   Serious DEFECTs, like lack of a guard digit, and\n   FAILUREs, like 2+2 == 5 .\nFailures may confound subsequent diagnoses.\n\nThe diagnostic capabilities of this program go beyond an earlier\nprogram called `MACHAR', which can be found at the end of the\nbook  `Software Manual for the Elementary Functions' (1980) by\nW. J. Cody and W. Waite. Although both programs try to discover\nthe Radix, Precision and range (over/underflow thresholds)\nof the arithmetic, this program tries to cope with a wider variety\nof pathologies, and to say how well the arithmetic is implemented.\n\nThe program is based upon a conventional radix representation for\nfloating-point numbers, but also allows logarithmic encoding\nas used by certain early WANG machines.\n\nBASIC version of this program (C) 1983 by Prof. W. M. Kahan;\nsee source comments for more history.\n\nDiagnosis resumes after milestone Number 3          Page: 4\n\nProgram is now RUNNING tests on small integers:\n-1, 0, 1/2, 1, 2, 3, 4, 5, 9, 27, 32 & 240 are O.K.\n\nSearching for Radix and Precision.\nRadix = 2.000000 .\nClosest relative separation found is U1 = 1.1102230e-16 .\n\nRecalculating radix and precision\n confirms closest relative separation U1 .\nRadix confirmed.\nThe number of significant digits of the Radix is 53.000000 .\nSome subexpressions appear to be calculated extra\nprecisely with about 11 extra B-digits, i.e.\nroughly 3.31133 extra significant decimals.\nThat feature is not tested further by this program.\n\nDiagnosis resumes after milestone Number 30          Page: 5\n\nSubtraction appears to be normalized, as it should be.\nChecking for guard digit in *, /, and -.\n     *, /, and - appear to have guard digits, as they should.\n\nDiagnosis resumes after milestone Number 40          Page: 6\n\nChecking rounding on multiply, divide and add/subtract.\n* is neither chopped nor correctly rounded.\n/ is neither chopped nor correctly rounded.\nAddition/Subtraction neither rounds nor chops.\nSticky bit used incorrectly or not at all.\nFLAW:  lack(s) of guard digits or failure(s) to correctly round or chop\n(noted above) count as one flaw in the final tally below.\n\nDoes Multiplication commute?  Testing on 20 random pairs.\n     No failures found in 20 integer pairs.\n\nRunning test of square root(x).\nTesting if sqrt(X * X) == X for 20 Integers X.\nTest for sqrt monotonicity.\nsqrt has passed a test for Monotonicity.\nTesting whether sqrt is rounded or chopped.\nSquare root is neither chopped nor correctly rounded.\nObserved errors run from -5.0000000e-01 to 5.0000000e-01 ulps.\n\nDiagnosis resumes after milestone Number 90          Page: 7\n\nTesting powers Z^i for small Integers Z and i.\n... no discrepancis found.\n\nSeeking Underflow thresholds UfThold and E0.\nSmallest strictly positive number found is E0 = 4.94066e-324 .\nSince comparison denies Z = 0, evaluating (Z + Z) / Z should be safe.\nWhat the machine gets for (Z + Z) / Z is  2.00000000000000000e+00 .\nThis is O.K., provided Over/Underflow has NOT just been signaled.\nUnderflow is gradual; it incurs Absolute Error =\n(roundoff in UfThold) < E0.\nThe Underflow threshold is 2.22507385850720188e-308,  below which\ncalculation may suffer larger Relative error than merely roundoff.\nSince underflow occurs below the threshold\nUfThold = (2.00000000000000000e+00) ^ (-1.02200000000000000e+03)\nonly underflow should afflict the expression\n\t(2.00000000000000000e+00) ^ (-1.02200000000000000e+03);\nactually calculating yields: 0.00000000000000000e+00 .\nThis computed value is O.K.\n\nTesting X^((X + 1) / (X - 1)) vs. exp(2) = 7.38905609893065218e+00 as X -> 1.\nAccuracy seems adequate.\nTesting powers Z^Q at four nearly extreme values.\n ... no discrepancies found.\n\n\nDiagnosis resumes after milestone Number 160          Page: 8\n\nSearching for Overflow threshold:\nThis may generate an error.\nCan `Z = -Y' overflow?\nTrying it on Y =              -Inf .\nSeems O.K.\nOverflow threshold is V  = 1.79769313486231571e+308 .\nOverflow saturates at V0 =               Inf .\nNo Overflow should be signaled for V * 1 = 1.79769313486231571e+308\n                           nor for V / 1 = 1.79769313486231571e+308 .\nAny overflow signal separating this * from the one\nabove is a DEFECT.\n\n\nDiagnosis resumes after milestone Number 190          Page: 9\n\n\nWhat message and/or values does Division by Zero produce?\n    Trying to compute 1 / 0 produces ...      Inf .\n\n    Trying to compute 0 / 0 produces ...      NaN .\n\nDiagnosis resumes after milestone Number 220          Page: 10\n\n\nThe number of  FLAWs  discovered =           1.\n\nThe arithmetic diagnosed seems Satisfactory though flawed.\nEND OF TEST.\n"
  },
  {
    "path": "lcc/x86/linux/tst/paranoia.2bk",
    "content": "tst/paranoia.c:1867: warning: missing return value\ntst/paranoia.c:1874: warning: missing return value\ntst/paranoia.c:1884: warning: missing return value\ntst/paranoia.c:1924: warning: missing return value\ntst/paranoia.c:1939: warning: missing return value\ntst/paranoia.c:1956: warning: missing return value\ntst/paranoia.c:1975: warning: missing return value\ntst/paranoia.c:1988: warning: missing return value\ntst/paranoia.c:1995: warning: missing return value\ntst/paranoia.c:2055: warning: missing return value\ntst/paranoia.c:2062: warning: missing return value\ntst/paranoia.c:2070: warning: missing return value\ntst/paranoia.c:2087: warning: missing return value\ntst/paranoia.c:2115: warning: missing return value\ntst/paranoia.c:2144: warning: missing return value\ntst/paranoia.c:2173: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/linux/tst/paranoia.sbk",
    "content": ".data\n.globl Zero\n.align 4\n.type Zero,@object\n.size Zero,8\nZero:\n.long 0\n.long 0\n.globl Half\n.align 4\n.type Half,@object\n.size Half,8\nHalf:\n.long 0\n.long 1071644672\n.globl One\n.align 4\n.type One,@object\n.size One,8\nOne:\n.long 0\n.long 1072693248\n.globl Two\n.align 4\n.type Two,@object\n.size Two,8\nTwo:\n.long 0\n.long 1073741824\n.globl Three\n.align 4\n.type Three,@object\n.size Three,8\nThree:\n.long 0\n.long 1074266112\n.globl Four\n.align 4\n.type Four,@object\n.size Four,8\nFour:\n.long 0\n.long 1074790400\n.globl Five\n.align 4\n.type Five,@object\n.size Five,8\nFive:\n.long 0\n.long 1075052544\n.globl Eight\n.align 4\n.type Eight,@object\n.size Eight,8\nEight:\n.long 0\n.long 1075838976\n.globl Nine\n.align 4\n.type Nine,@object\n.size Nine,8\nNine:\n.long 0\n.long 1075970048\n.globl TwentySeven\n.align 4\n.type TwentySeven,@object\n.size TwentySeven,8\nTwentySeven:\n.long 0\n.long 1077608448\n.globl ThirtyTwo\n.align 4\n.type ThirtyTwo,@object\n.size ThirtyTwo,8\nThirtyTwo:\n.long 0\n.long 1077936128\n.globl TwoForty\n.align 4\n.type TwoForty,@object\n.size TwoForty,8\nTwoForty:\n.long 0\n.long 1080950784\n.globl MinusOne\n.align 4\n.type MinusOne,@object\n.size MinusOne,8\nMinusOne:\n.long 0\n.long -1074790400\n.globl OneAndHalf\n.align 4\n.type OneAndHalf,@object\n.size OneAndHalf,8\nOneAndHalf:\n.long 0\n.long 1073217536\n.globl NoTrials\n.align 4\n.type NoTrials,@object\n.size NoTrials,4\nNoTrials:\n.long 20\n.globl sigfpe\n.text\n.align 16\n.type sigfpe,@function\nsigfpe:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nincl fpecount\npushl $.LC3\ncall printf\naddl $4,%esp\npushl $_IO_stdout_\ncall fflush\naddl $4,%esp\nmovl sigsave,%edi\ncmpl $0,%edi\nje .LC4\npushl sigsave\npushl $8\ncall signal\naddl $8,%esp\nmovl $0,sigsave\npushl $1\npushl $ovfl_buf\ncall longjmp\naddl $8,%esp\n.LC4:\ncall abort\n.LC2:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf6:\n.size sigfpe,.Lf6-sigfpe\n.data\n.align 4\n.type msg.758,@object\nmsg.758:\n.long .LC759\n.long .LC760\n.long .LC761\n.long .LC762\n.size msg.758,16\n.globl main\n.text\n.align 16\n.type main,@function\nmain:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $1684,%esp\nfldl .LC8\nfstpl Zero\nfldl .LC9\nfstpl One\nfldl One\nfstpl -8(%ebp)\nfldl -8(%ebp)\nfaddl -8(%ebp)\nfstpl Two\nfldl Two\nfstpl -16(%ebp)\nfldl -16(%ebp)\nfaddl -8(%ebp)\nfstpl Three\nfldl Three\nfstpl -24(%ebp)\nfldl -24(%ebp)\nfaddl -8(%ebp)\nfstpl Four\nfldl Four\nfstpl -32(%ebp)\nfldl -32(%ebp)\nfaddl -8(%ebp)\nfstpl Five\nfldl -32(%ebp)\nfaddl -32(%ebp)\nfstpl Eight\nfldl -24(%ebp)\nfmull -24(%ebp)\nfstpl Nine\nfldl Nine\nfmull -24(%ebp)\nfstpl TwentySeven\nfldl -32(%ebp)\nfmull Eight\nfstpl ThirtyTwo\nfldl -32(%ebp)\nfmull Five\nfmull -24(%ebp)\nfmull -32(%ebp)\nfstpl TwoForty\nfldl -8(%ebp)\nfchs\nfstpl MinusOne\nfldl -8(%ebp)\nfdivl -16(%ebp)\nfstpl Half\nfldl -8(%ebp)\nfaddl Half\nfstpl OneAndHalf\nmovl $0,ErrCnt\nmovl $0,ErrCnt+4\nmovl $0,ErrCnt+8\nmovl $0,ErrCnt+12\nmovl $1,PageNo\nmovl $0,Milestone\npushl $sigfpe\npushl $8\ncall signal\naddl $8,%esp\ncall Instructions\ncall Pause\ncall Heading\ncall Pause\ncall Characteristics\ncall Pause\ncall History\ncall Pause\nmovl $7,Milestone\npushl $.LC13\ncall printf\naddl $4,%esp\npushl $.LC15\nfldl Zero\nfaddl Zero\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC16\nfldl One\nfsubl One\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC16\nfldl Zero\nfcompl One\nfstsw %ax\nsahf\njae .LC16\nfldl One\nfaddl One\nfldl Two\nfcompp\nfstsw %ax\nsahf\njne .LC16\nmovl $1,-36(%ebp)\njmp .LC17\n.LC16:\nmovl $0,-36(%ebp)\n.LC17:\npushl -36(%ebp)\npushl $0\ncall TstCond\naddl $12,%esp\nfldl Zero\nfchs\nfstpl Z\nfldl .LC8\nfcompl Z\nfstsw %ax\nsahf\nje .LC18\nincl ErrCnt\npushl $.LC20\ncall printf\naddl $4,%esp\nfldl .LC21\nfstpl U1\nfldl .LC9\nfstpl Radix\ncall TstPtUf\n.LC18:\npushl $.LC23\nfldl Two\nfaddl One\nfcompl Three\nfstsw %ax\nsahf\njne .LC24\nfldl Three\nfaddl One\nfcompl Four\nfstsw %ax\nsahf\njne .LC24\nfldl Four\nfldl Two\nfldl Two\nfchs\nfmulp %st(1),%st\nfaddp %st(1),%st\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC24\nfldl Four\nfsubl Three\nfsubl One\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC24\nmovl $1,-56(%ebp)\njmp .LC25\n.LC24:\nmovl $0,-56(%ebp)\n.LC25:\npushl -56(%ebp)\npushl $0\ncall TstCond\naddl $12,%esp\nfldl .LC8\nfsubl One\nfcompl MinusOne\nfstsw %ax\nsahf\njne .LC28\nfldl MinusOne\nfaddl One\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC28\nfldl One\nfaddl MinusOne\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC28\nfldl One\nsubl $8,%esp\nfstpl (%esp)\ncall fabs\naddl $8,%esp\nfstpl -132(%ebp)\nfldl MinusOne\nfaddl -132(%ebp)\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC28\nfldl MinusOne\nfldl MinusOne\nfmull MinusOne\nfaddp %st(1),%st\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC28\nmovl $1,-100(%ebp)\njmp .LC29\n.LC28:\nmovl $0,-100(%ebp)\n.LC29:\npushl $.LC27\npushl -100(%ebp)\npushl $0\ncall TstCond\naddl $12,%esp\npushl $.LC31\nfldl Half\nfaddl MinusOne\nfaddl Half\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC32\nmovl $1,-152(%ebp)\njmp .LC33\n.LC32:\nmovl $0,-152(%ebp)\n.LC33:\npushl -152(%ebp)\npushl $0\ncall TstCond\naddl $12,%esp\nmovl $10,Milestone\npushl $.LC35\nfldl Three\nfmull Three\nfcompl Nine\nfstsw %ax\nsahf\njne .LC36\nfldl Nine\nfmull Three\nfcompl TwentySeven\nfstsw %ax\nsahf\njne .LC36\nfldl Four\nfaddl Four\nfcompl Eight\nfstsw %ax\nsahf\njne .LC36\nfldl Eight\nfmull Four\nfcompl ThirtyTwo\nfstsw %ax\nsahf\njne .LC36\nfldl ThirtyTwo\nfsubl TwentySeven\nfsubl Four\nfsubl One\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC36\nmovl $1,-164(%ebp)\njmp .LC37\n.LC36:\nmovl $0,-164(%ebp)\n.LC37:\npushl -164(%ebp)\npushl $0\ncall TstCond\naddl $12,%esp\npushl $.LC39\nfldl Four\nfaddl One\nfcompl Five\nfstsw %ax\nsahf\njne .LC40\nfldl Four\nfmull Five\nfmull Three\nfmull Four\nfcompl TwoForty\nfstsw %ax\nsahf\njne .LC40\nfldl TwoForty\nfdivl Three\nfldl Four\nfmull Four\nfmull Five\nfsubp %st(1),%st\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC40\nfldl TwoForty\nfdivl Four\nfldl Five\nfmull Three\nfmull Four\nfsubp %st(1),%st\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC40\nfldl TwoForty\nfdivl Five\nfldl Four\nfmull Three\nfmull Four\nfsubp %st(1),%st\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC40\nmovl $1,-216(%ebp)\njmp .LC41\n.LC40:\nmovl $0,-216(%ebp)\n.LC41:\npushl -216(%ebp)\npushl $0\ncall TstCond\naddl $12,%esp\ncmpl $0,ErrCnt\njne .LC42\npushl $.LC44\ncall printf\naddl $4,%esp\npushl $.LC45\ncall printf\naddl $4,%esp\n.LC42:\npushl $.LC46\ncall printf\naddl $4,%esp\nfldl One\nfstpl W\n.LC47:\nfldl W\nfstpl -264(%ebp)\nfldl -264(%ebp)\nfaddl -264(%ebp)\nfstpl W\nfldl W\nfstpl -272(%ebp)\nfldl -272(%ebp)\nfaddl One\nfstpl Y\nfldl Y\nfsubl -272(%ebp)\nfstpl Z\nfldl Z\nfsubl One\nfstpl Y\n.LC48:\nfldl Y\nsubl $8,%esp\nfstpl (%esp)\ncall fabs\naddl $8,%esp\nfstpl -264(%ebp)\nfldl MinusOne\nfaddl -264(%ebp)\nfldl Zero\nfcompp\nfstsw %ax\nsahf\nja .LC47\nfldl Zero\nfstpl Precision\nfldl One\nfstpl Y\n.LC50:\nfldl Y\nfstpl -280(%ebp)\nfldl W\nfaddl -280(%ebp)\nfstpl Radix\nfldl -280(%ebp)\nfaddl -280(%ebp)\nfstpl Y\nfldl Radix\nfsubl W\nfstpl Radix\n.LC51:\nfldl Zero\nfcompl Radix\nfstsw %ax\nsahf\nje .LC50\nfldl Two\nfcompl Radix\nfstsw %ax\nsahf\njbe .LC53\nfldl One\nfstpl Radix\n.LC53:\nfldl Radix\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC55\ncall printf\naddl $12,%esp\nfldl .LC9\nfcompl Radix\nfstsw %ax\nsahf\nje .LC56\nfldl One\nfstpl W\n.LC58:\nfldl Precision\nfaddl One\nfstpl Precision\nfldl W\nfmull Radix\nfstpl W\nfldl W\nfaddl One\nfstpl Y\n.LC59:\nfldl Y\nfsubl W\nfldl One\nfcompp\nfstsw %ax\nsahf\nje .LC58\n.LC56:\nfldl One\nfdivl W\nfstpl U1\nfldl U1\nfstpl -272(%ebp)\nfldl Radix\nfmull -272(%ebp)\nfstpl U2\nfldl -272(%ebp)\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC61\ncall printf\naddl $12,%esp\npushl $.LC62\ncall printf\naddl $4,%esp\nfldl Radix\nfstpl E0\nfldl U1\nfstpl E1\nfldl U2\nfstpl E9\nfldl Precision\nfstpl E3\nfldl Four\nfdivl Three\nfstpl X\nfldl X\nfsubl One\nfstpl Third\nfldl Third\nfstpl -280(%ebp)\nfldl Half\nfsubl -280(%ebp)\nfstpl F6\nfldl F6\nfstpl -288(%ebp)\nfldl -288(%ebp)\nfaddl -288(%ebp)\nfstpl X\nfldl X\nfsubl -280(%ebp)\nsubl $8,%esp\nfstpl (%esp)\ncall fabs\naddl $8,%esp\nfstpl -296(%ebp)\nfldl -296(%ebp)\nfstpl X\nfldl U2\nfcompl X\nfstsw %ax\nsahf\njbe .LC63\nfldl U2\nfstpl X\n.LC63:\n.LC65:\nfldl X\nfstpl U2\nfldl U2\nfstpl -304(%ebp)\nfldl Half\nfmull -304(%ebp)\nfldl ThirtyTwo\nfmull -304(%ebp)\nfmull -304(%ebp)\nfaddp %st(1),%st\nfstpl Y\nfldl One\nfaddl Y\nfstpl Y\nfldl Y\nfsubl One\nfstpl X\n.LC66:\nfldl X\nfcompl U2\nfstsw %ax\nsahf\njae .LC68\nfldl Zero\nfcompl X\nfstsw %ax\nsahf\njb .LC65\n.LC68:\nfldl Two\nfdivl Three\nfstpl X\nfldl X\nfsubl Half\nfstpl F6\nfldl F6\nfstpl -320(%ebp)\nfldl -320(%ebp)\nfaddl -320(%ebp)\nfstpl Third\nfldl Third\nfsubl Half\nfstpl X\nfldl X\nfaddl -320(%ebp)\nsubl $8,%esp\nfstpl (%esp)\ncall fabs\naddl $8,%esp\nfstpl -328(%ebp)\nfldl -328(%ebp)\nfstpl X\nfldl U1\nfcompl X\nfstsw %ax\nsahf\njbe .LC69\nfldl U1\nfstpl X\n.LC69:\n.LC71:\nfldl X\nfstpl U1\nfldl U1\nfstpl -344(%ebp)\nfldl Half\nfmull -344(%ebp)\nfldl ThirtyTwo\nfmull -344(%ebp)\nfmull -344(%ebp)\nfaddp %st(1),%st\nfstpl Y\nfldl Half\nfsubl Y\nfstpl Y\nfldl Half\nfaddl Y\nfstpl X\nfldl Half\nfsubl X\nfstpl Y\nfldl Half\nfaddl Y\nfstpl X\n.LC72:\nfldl X\nfcompl U1\nfstsw %ax\nsahf\njae .LC74\nfldl Zero\nfcompl X\nfstsw %ax\nsahf\njb .LC71\n.LC74:\nfldl E1\nfcompl U1\nfstsw %ax\nsahf\njne .LC75\npushl $.LC77\ncall printf\naddl $4,%esp\njmp .LC76\n.LC75:\nfldl U1\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC78\ncall printf\naddl $12,%esp\n.LC76:\nfldl One\nfdivl U1\nfstpl W\nfldl Half\nfsubl U1\nfaddl Half\nfstpl F9\nfldl U2\nfdivl U1\nfaddl .LC79\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -360(%ebp)\nfldl -360(%ebp)\nfstpl Radix\nfldl E0\nfcompl Radix\nfstsw %ax\nsahf\njne .LC80\npushl $.LC82\ncall printf\naddl $4,%esp\njmp .LC81\n.LC80:\nfldl Radix\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC83\ncall printf\naddl $12,%esp\n.LC81:\npushl $.LC85\nfldl Eight\nfaddl Eight\nfcompl Radix\nfstsw %ax\nsahf\njb .LC86\nmovl $1,-364(%ebp)\njmp .LC87\n.LC86:\nmovl $0,-364(%ebp)\n.LC87:\npushl -364(%ebp)\npushl $2\ncall TstCond\naddl $12,%esp\npushl $.LC89\nfldl Two\nfcompl Radix\nfstsw %ax\nsahf\nje .LC93\nfldl .LC94\nfcompl Radix\nfstsw %ax\nsahf\nje .LC93\nfldl One\nfcompl Radix\nfstsw %ax\nsahf\njne .LC90\n.LC93:\nmovl $1,-376(%ebp)\njmp .LC91\n.LC90:\nmovl $0,-376(%ebp)\n.LC91:\npushl -376(%ebp)\npushl $3\ncall TstCond\naddl $12,%esp\nmovl $20,Milestone\npushl $.LC96\nfldl F9\nfsubl Half\nfldl Half\nfcompp\nfstsw %ax\nsahf\njbe .LC97\nmovl $1,-388(%ebp)\njmp .LC98\n.LC97:\nmovl $0,-388(%ebp)\n.LC98:\npushl -388(%ebp)\npushl $0\ncall TstCond\naddl $12,%esp\nfldl F9\nfstpl X\nmovl $1,I\nfldl X\nfsubl Half\nfstpl Y\nfldl Y\nfsubl Half\nfstpl Z\npushl $.LC100\nfldl One\nfcompl X\nfstsw %ax\nsahf\njne .LC103\nfldl Zero\nfcompl Z\nfstsw %ax\nsahf\njne .LC101\n.LC103:\nmovl $1,-400(%ebp)\njmp .LC102\n.LC101:\nmovl $0,-400(%ebp)\n.LC102:\npushl -400(%ebp)\npushl $0\ncall TstCond\naddl $12,%esp\nfldl One\nfaddl U2\nfstpl X\nmovl $0,I\nmovl $25,Milestone\nfldl Radix\nfsubl One\nfstpl BMinusU2\nfldl BMinusU2\nfsubl U2\nfaddl One\nfstpl BMinusU2\nfldl One\nfcompl Radix\nfstsw %ax\nsahf\nje .LC104\nfldl U1\nsubl $8,%esp\nfstpl (%esp)\ncall log\naddl $8,%esp\nfstpl -440(%ebp)\nfldl Radix\nsubl $8,%esp\nfstpl (%esp)\ncall log\naddl $8,%esp\nfstpl -448(%ebp)\nfldl TwoForty\nfchs\nfmull -440(%ebp)\nfdivl -448(%ebp)\nfstpl X\nfldl Half\nfaddl X\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -456(%ebp)\nfldl -456(%ebp)\nfstpl Y\nfldl X\nfsubl Y\nsubl $8,%esp\nfstpl (%esp)\ncall fabs\naddl $8,%esp\nfstpl -464(%ebp)\nfldl -464(%ebp)\nfmull Four\nfldl One\nfcompp\nfstsw %ax\nsahf\njbe .LC106\nfldl Y\nfstpl X\n.LC106:\nfldl X\nfdivl TwoForty\nfstpl Precision\nfldl Half\nfaddl Precision\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -472(%ebp)\nfldl -472(%ebp)\nfstpl Y\nfldl Precision\nfsubl Y\nsubl $8,%esp\nfstpl (%esp)\ncall fabs\naddl $8,%esp\nfstpl -480(%ebp)\nfldl -480(%ebp)\nfmull TwoForty\nfldl Half\nfcompp\nfstsw %ax\nsahf\njbe .LC108\nfldl Y\nfstpl Precision\n.LC108:\n.LC104:\nfldl Precision\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -448(%ebp)\nfldl -448(%ebp)\nfcompl Precision\nfstsw %ax\nsahf\njne .LC112\nfldl One\nfcompl Radix\nfstsw %ax\nsahf\njne .LC110\n.LC112:\npushl $.LC113\ncall printf\naddl $4,%esp\npushl $.LC114\ncall printf\naddl $4,%esp\n.LC110:\nfldl One\nfcompl Radix\nfstsw %ax\nsahf\njne .LC115\npushl $.LC117\ncall printf\naddl $4,%esp\njmp .LC116\n.LC115:\nfldl Precision\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC118\ncall printf\naddl $12,%esp\n.LC116:\npushl $.LC120\nfldl U2\nfmull Nine\nfmull Nine\nfmull TwoForty\nfldl One\nfcompp\nfstsw %ax\nsahf\njbe .LC121\nmovl $1,-452(%ebp)\njmp .LC122\n.LC121:\nmovl $0,-452(%ebp)\n.LC122:\npushl -452(%ebp)\npushl $1\ncall TstCond\naddl $12,%esp\nmovl $30,Milestone\nfldl One\nfdivl Four\nfstpl -492(%ebp)\nfldl Four\nfdivl Three\nfsubl One\nfsubl -492(%ebp)\nfmull Three\nfsubl -492(%ebp)\nsubl $8,%esp\nfstpl (%esp)\ncall fabs\naddl $8,%esp\nfstpl -500(%ebp)\nfldl -500(%ebp)\nfstpl X\n.LC123:\nfldl X\nfstpl Z2\nfldl Z2\nfstpl -516(%ebp)\nfldl One\nfldl Half\nfmull -516(%ebp)\nfldl ThirtyTwo\nfmull -516(%ebp)\nfmull -516(%ebp)\nfaddp %st(1),%st\nfaddp %st(1),%st\nfsubl One\nfstpl X\n.LC124:\nfldl X\nfcompl Z2\nfstsw %ax\nsahf\njae .LC126\nfldl Zero\nfcompl X\nfstsw %ax\nsahf\njb .LC123\n.LC126:\nfldl Three\nfdivl Four\nfldl Two\nfdivl Three\nfsubp %st(1),%st\nfmull Three\nfldl One\nfdivl Four\nfsubp %st(1),%st\nsubl $8,%esp\nfstpl (%esp)\ncall fabs\naddl $8,%esp\nfstpl -532(%ebp)\nfldl -532(%ebp)\nfstpl Z\nfldl -532(%ebp)\nfstpl Y\nfldl -532(%ebp)\nfstpl X\n.LC127:\nfldl Z\nfstpl Z1\nfldl One\nfdivl Two\nfstpl -540(%ebp)\nfldl Z1\nfstpl -548(%ebp)\nfldl -540(%ebp)\nfldl -540(%ebp)\nfldl Half\nfmull -548(%ebp)\nfldl ThirtyTwo\nfmull -548(%ebp)\nfmull -548(%ebp)\nfaddp %st(1),%st\nfsubp %st(1),%st\nfaddl -540(%ebp)\nfsubp %st(1),%st\nfaddl -540(%ebp)\nfstpl Z\n.LC128:\nfldl Z\nfcompl Z1\nfstsw %ax\nsahf\njae .LC130\nfldl Zero\nfcompl Z\nfstsw %ax\nsahf\njb .LC127\n.LC130:\n.LC131:\n.LC134:\nfldl Y\nfstpl Y1\nfldl Y1\nfstpl -556(%ebp)\nfldl Half\nfldl Half\nfldl Half\nfmull -556(%ebp)\nfldl ThirtyTwo\nfmull -556(%ebp)\nfmull -556(%ebp)\nfaddp %st(1),%st\nfsubp %st(1),%st\nfaddl Half\nfsubp %st(1),%st\nfaddl Half\nfstpl Y\n.LC135:\nfldl Y\nfcompl Y1\nfstsw %ax\nsahf\njae .LC137\nfldl Zero\nfcompl Y\nfstsw %ax\nsahf\njb .LC134\n.LC137:\nfldl X\nfstpl X1\nfldl X1\nfstpl -556(%ebp)\nfldl Half\nfmull -556(%ebp)\nfldl ThirtyTwo\nfmull -556(%ebp)\nfmull -556(%ebp)\nfaddp %st(1),%st\nfsubl F9\nfaddl F9\nfstpl X\n.LC132:\nfldl X\nfcompl X1\nfstsw %ax\nsahf\njae .LC138\nfldl Zero\nfcompl X\nfstsw %ax\nsahf\njb .LC131\n.LC138:\nfldl Y1\nfcompl X1\nfstsw %ax\nsahf\njne .LC141\nfldl Z1\nfcompl X1\nfstsw %ax\nsahf\nje .LC139\n.LC141:\npushl $.LC142\npushl $1\ncall BadCond\naddl $8,%esp\nfldl Z1\nsubl $8,%esp\nfstpl (%esp)\nfldl Y1\nsubl $8,%esp\nfstpl (%esp)\nfldl X1\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC143\ncall printf\naddl $28,%esp\npushl $.LC144\ncall printf\naddl $4,%esp\npushl $.LC145\ncall printf\naddl $4,%esp\npushl $.LC146\ncall notify\naddl $4,%esp\nfldl U1\nfcompl X1\nfstsw %ax\nsahf\nje .LC150\nfldl U1\nfcompl Y1\nfstsw %ax\nsahf\nje .LC150\nfldl U1\nfcompl Z1\nfstsw %ax\nsahf\njne .LC140\n.LC150:\npushl $.LC151\ncall printf\naddl $4,%esp\njmp .LC140\n.LC139:\nfldl U1\nfcompl Z1\nfstsw %ax\nsahf\njne .LC154\nfldl U2\nfcompl Z2\nfstsw %ax\nsahf\nje .LC152\n.LC154:\nfldl U1\nfcompl Z1\nfstsw %ax\nsahf\njbe .LC157\nfldl U2\nfcompl Z2\nfstsw %ax\nsahf\nja .LC155\n.LC157:\npushl $.LC158\npushl $0\ncall BadCond\naddl $8,%esp\npushl $.LC159\ncall notify\naddl $4,%esp\nfldl Z1\nfsubl U1\nsubl $8,%esp\nfstpl (%esp)\nfldl U1\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC160\ncall printf\naddl $20,%esp\nfldl Z2\nfsubl U2\nsubl $8,%esp\nfstpl (%esp)\nfldl U2\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC161\ncall printf\naddl $20,%esp\njmp .LC156\n.LC155:\nfldl Zero\nfcompl Z1\nfstsw %ax\nsahf\njae .LC164\nfldl Zero\nfcompl Z2\nfstsw %ax\nsahf\njb .LC162\n.LC164:\nfldl Radix\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC165\ncall printf\naddl $12,%esp\npushl $.LC166\ncall printf\naddl $4,%esp\nfldl Z2\nsubl $8,%esp\nfstpl (%esp)\nfldl Z1\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC167\ncall printf\naddl $20,%esp\npushl $.LC168\ncall notify\naddl $4,%esp\n.LC162:\nfldl Z2\nfcompl Z1\nfstsw %ax\nsahf\njne .LC171\nfldl Zero\nfcompl Z1\nfstsw %ax\nsahf\njae .LC169\n.LC171:\nfldl Z1\nfdivl U1\nfstpl X\nfldl Z2\nfdivl U2\nfstpl Y\nfldl X\nfcompl Y\nfstsw %ax\nsahf\njae .LC172\nfldl Y\nfstpl X\n.LC172:\nfldl X\nsubl $8,%esp\nfstpl (%esp)\ncall log\naddl $8,%esp\nfstpl -580(%ebp)\nfldl -580(%ebp)\nfchs\nfstpl Q\npushl $.LC174\ncall printf\naddl $4,%esp\nfldl Radix\nsubl $8,%esp\nfstpl (%esp)\ncall log\naddl $8,%esp\nfstpl -588(%ebp)\nfldl Q\nfdivl -588(%ebp)\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC175\ncall printf\naddl $12,%esp\nfldl .LC94\nsubl $8,%esp\nfstpl (%esp)\ncall log\naddl $8,%esp\nfstpl -596(%ebp)\nfldl Q\nfdivl -596(%ebp)\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC176\ncall printf\naddl $12,%esp\n.LC169:\npushl $.LC151\ncall printf\naddl $4,%esp\n.LC156:\n.LC152:\n.LC140:\ncall Pause\nmovl $35,Milestone\nfldl Two\nfcompl Radix\nfstsw %ax\nsahf\nja .LC177\nfldl W\nfldl Radix\nfmull Radix\nfdivp %st(1),%st\nfstpl X\nfldl X\nfstpl -576(%ebp)\nfldl -576(%ebp)\nfaddl One\nfstpl Y\nfldl Y\nfsubl -576(%ebp)\nfstpl Z\nfldl Z\nfstpl -584(%ebp)\nfldl -584(%ebp)\nfaddl U2\nfstpl T\nfldl T\nfsubl -584(%ebp)\nfstpl X\npushl $.LC180\nfldl U2\nfcompl X\nfstsw %ax\nsahf\njne .LC181\nmovl $1,-560(%ebp)\njmp .LC182\n.LC181:\nmovl $0,-560(%ebp)\n.LC182:\npushl -560(%ebp)\npushl $0\ncall TstCond\naddl $12,%esp\nfldl U2\nfcompl X\nfstsw %ax\nsahf\njne .LC183\npushl $.LC185\ncall printf\naddl $4,%esp\n.LC183:\n.LC177:\npushl $.LC186\ncall printf\naddl $4,%esp\nfldl F9\nfmull One\nfstpl Y\nfldl One\nfmull F9\nfstpl Z\nfldl F9\nfsubl Half\nfstpl X\nfldl X\nfstpl -588(%ebp)\nfldl Y\nfsubl Half\nfsubl -588(%ebp)\nfstpl Y\nfldl Z\nfsubl Half\nfsubl -588(%ebp)\nfstpl Z\nfldl One\nfaddl U2\nfstpl X\nfldl X\nfstpl -604(%ebp)\nfldl -604(%ebp)\nfmull Radix\nfstpl T\nfldl Radix\nfmull -604(%ebp)\nfstpl R\nfldl T\nfsubl Radix\nfstpl X\nfldl Radix\nfmull U2\nfstpl -620(%ebp)\nfldl X\nfsubl -620(%ebp)\nfstpl X\nfldl R\nfsubl Radix\nfstpl T\nfldl T\nfsubl -620(%ebp)\nfstpl T\nfldl Radix\nfsubl One\nfstpl -628(%ebp)\nfldl X\nfmull -628(%ebp)\nfstpl X\nfldl T\nfmull -628(%ebp)\nfstpl T\nfldl Zero\nfcompl X\nfstsw %ax\nsahf\njne .LC187\nfldl Zero\nfcompl Y\nfstsw %ax\nsahf\njne .LC187\nfldl Zero\nfcompl Z\nfstsw %ax\nsahf\njne .LC187\nfldl Zero\nfcompl T\nfstsw %ax\nsahf\njne .LC187\nmovl $1,GMult\njmp .LC188\n.LC187:\nmovl $0,GMult\npushl $.LC189\npushl $0\npushl $1\ncall TstCond\naddl $12,%esp\n.LC188:\nfldl Radix\nfmull U2\nfstpl Z\nfldl Z\nfstpl -648(%ebp)\nfldl One\nfaddl -648(%ebp)\nfstpl X\nfldl X\nfstpl -656(%ebp)\nfldl -656(%ebp)\nfaddl -648(%ebp)\nfldl -656(%ebp)\nfmull -656(%ebp)\nfsubp %st(1),%st\nsubl $8,%esp\nfstpl (%esp)\ncall fabs\naddl $8,%esp\nfstpl -664(%ebp)\nfldl -664(%ebp)\nfsubl U2\nfstpl Y\nfldl One\nfsubl U2\nfstpl X\nfldl X\nfstpl -680(%ebp)\nfldl -680(%ebp)\nfsubl U2\nfldl -680(%ebp)\nfmull -680(%ebp)\nfsubp %st(1),%st\nsubl $8,%esp\nfstpl (%esp)\ncall fabs\naddl $8,%esp\nfstpl -688(%ebp)\nfldl -688(%ebp)\nfsubl U1\nfstpl Z\npushl $.LC191\nfldl Zero\nfcompl Y\nfstsw %ax\nsahf\njb .LC192\nfldl Zero\nfcompl Z\nfstsw %ax\nsahf\njb .LC192\nmovl $1,-640(%ebp)\njmp .LC193\n.LC192:\nmovl $0,-640(%ebp)\n.LC193:\npushl -640(%ebp)\npushl $0\ncall TstCond\naddl $12,%esp\nfldl One\nfsubl U2\nfstpl Y\nfldl One\nfaddl U2\nfstpl X\nfldl One\nfdivl Y\nfstpl Z\nfldl Z\nfsubl X\nfstpl Y\nfldl One\nfdivl Three\nfstpl X\nfldl Three\nfdivl Nine\nfstpl Z\nfldl Z\nfstpl -740(%ebp)\nfldl X\nfsubl -740(%ebp)\nfstpl X\nfldl Nine\nfdivl TwentySeven\nfstpl T\nfldl -740(%ebp)\nfsubl T\nfstpl Z\npushl $.LC195\nfldl Zero\nfcompl X\nfstsw %ax\nsahf\njne .LC196\nfldl Zero\nfcompl Y\nfstsw %ax\nsahf\njne .LC196\nfldl Zero\nfcompl Z\nfstsw %ax\nsahf\njne .LC196\nmovl $1,-700(%ebp)\njmp .LC197\n.LC196:\nmovl $0,-700(%ebp)\n.LC197:\npushl -700(%ebp)\npushl $2\ncall TstCond\naddl $12,%esp\nfldl F9\nfdivl One\nfstpl Y\nfldl F9\nfsubl Half\nfstpl X\nfldl Y\nfsubl Half\nfsubl X\nfstpl Y\nfldl One\nfaddl U2\nfstpl X\nfldl X\nfstpl -780(%ebp)\nfldl -780(%ebp)\nfdivl One\nfstpl T\nfldl T\nfsubl -780(%ebp)\nfstpl X\nfldl Zero\nfcompl X\nfstsw %ax\nsahf\njne .LC198\nfldl Zero\nfcompl Y\nfstsw %ax\nsahf\njne .LC198\nfldl Zero\nfcompl Z\nfstsw %ax\nsahf\njne .LC198\nmovl $1,GDiv\njmp .LC199\n.LC198:\nmovl $0,GDiv\npushl $.LC200\npushl $0\npushl $1\ncall TstCond\naddl $12,%esp\n.LC199:\nfldl One\nfldl One\nfaddl U2\nfdivp %st(1),%st\nfstpl X\nfldl X\nfsubl Half\nfsubl Half\nfstpl Y\npushl $.LC202\nfldl Zero\nfcompl Y\nfstsw %ax\nsahf\njbe .LC203\nmovl $1,-792(%ebp)\njmp .LC204\n.LC203:\nmovl $0,-792(%ebp)\n.LC204:\npushl -792(%ebp)\npushl $1\ncall TstCond\naddl $12,%esp\nfldl One\nfsubl U2\nfstpl X\nfldl One\nfldl Radix\nfmull U2\nfaddp %st(1),%st\nfstpl Y\nfldl X\nfstpl -844(%ebp)\nfldl -844(%ebp)\nfmull Radix\nfstpl Z\nfldl Y\nfstpl -852(%ebp)\nfldl -852(%ebp)\nfmull Radix\nfstpl T\nfldl Z\nfdivl Radix\nfstpl R\nfldl T\nfdivl Radix\nfstpl StickyBit\nfldl R\nfsubl -844(%ebp)\nfstpl X\nfldl StickyBit\nfsubl -852(%ebp)\nfstpl Y\npushl $.LC206\nfldl Zero\nfcompl X\nfstsw %ax\nsahf\njne .LC207\nfldl Zero\nfcompl Y\nfstsw %ax\nsahf\njne .LC207\nmovl $1,-812(%ebp)\njmp .LC208\n.LC207:\nmovl $0,-812(%ebp)\n.LC208:\npushl -812(%ebp)\npushl $0\ncall TstCond\naddl $12,%esp\nfldl One\nfsubl U1\nfstpl Y\nfldl One\nfsubl F9\nfstpl X\nfldl One\nfsubl Y\nfstpl Y\nfldl Radix\nfsubl U2\nfstpl T\nfldl Radix\nfsubl BMinusU2\nfstpl Z\nfldl Radix\nfsubl T\nfstpl T\nfldl U1\nfcompl X\nfstsw %ax\nsahf\njne .LC209\nfldl U1\nfcompl Y\nfstsw %ax\nsahf\njne .LC209\nfldl U2\nfcompl Z\nfstsw %ax\nsahf\njne .LC209\nfldl U2\nfcompl T\nfstsw %ax\nsahf\njne .LC209\nmovl $1,GAddSub\njmp .LC210\n.LC209:\nmovl $0,GAddSub\npushl $.LC211\npushl $0\npushl $1\ncall TstCond\naddl $12,%esp\n.LC210:\nfldl One\nfcompl F9\nfstsw %ax\nsahf\nje .LC212\nfldl F9\nfsubl One\nfldl Zero\nfcompp\nfstsw %ax\nsahf\nja .LC212\npushl $.LC214\npushl $1\ncall BadCond\naddl $8,%esp\npushl $.LC215\ncall printf\naddl $4,%esp\npushl $.LC216\ncall printf\naddl $4,%esp\npushl $.LC217\ncall printf\naddl $4,%esp\n.LC212:\ncmpl $1,GMult\njne .LC218\ncmpl $1,GDiv\njne .LC218\ncmpl $1,GAddSub\njne .LC218\npushl $.LC220\ncall printf\naddl $4,%esp\n.LC218:\nmovl $40,Milestone\ncall Pause\npushl $.LC221\ncall printf\naddl $4,%esp\nmovl $0,RMult\nmovl $0,RDiv\nmovl $0,RAddSub\nfldl Radix\nfdivl Two\nfstpl RadixD2\nfldl Two\nfstpl A1\nmovl $0,Done\n.LC222:\nfldl Radix\nfstpl AInvrse\n.LC225:\nfldl AInvrse\nfstpl -924(%ebp)\nfldl -924(%ebp)\nfstpl X\nfldl -924(%ebp)\nfdivl A1\nfstpl AInvrse\n.LC226:\nfldl AInvrse\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -924(%ebp)\nfldl AInvrse\nfcompl -924(%ebp)\nfstsw %ax\nsahf\nje .LC225\nfldl One\nfcompl X\nfstsw %ax\nsahf\nje .LC231\nfldl Three\nfcompl A1\nfstsw %ax\nsahf\njae .LC229\n.LC231:\nmovl $1,-928(%ebp)\njmp .LC230\n.LC229:\nmovl $0,-928(%ebp)\n.LC230:\nmovl -928(%ebp),%edi\nmovl %edi,Done\ncmpl $0,Done\njne .LC232\nfldl Nine\nfaddl One\nfstpl A1\n.LC232:\n.LC223:\ncmpl $0,Done\nje .LC222\nfldl One\nfcompl X\nfstsw %ax\nsahf\njne .LC234\nfldl Radix\nfstpl A1\n.LC234:\nfldl One\nfdivl A1\nfstpl AInvrse\nfldl A1\nfstpl X\nfldl AInvrse\nfstpl Y\nmovl $0,Done\n.LC236:\nfldl X\nfmull Y\nfsubl Half\nfstpl Z\npushl $.LC240\nfldl Half\nfcompl Z\nfstsw %ax\nsahf\njne .LC241\nmovl $1,-928(%ebp)\njmp .LC242\n.LC241:\nmovl $0,-928(%ebp)\n.LC242:\npushl -928(%ebp)\npushl $0\ncall TstCond\naddl $12,%esp\nfldl Radix\nfcompl X\nfstsw %ax\nsahf\njne .LC244\nmovl $1,-940(%ebp)\njmp .LC245\n.LC244:\nmovl $0,-940(%ebp)\n.LC245:\nmovl -940(%ebp),%edi\nmovl %edi,Done\nfldl Radix\nfstpl X\nfldl One\nfdivl X\nfstpl Y\n.LC237:\ncmpl $0,Done\nje .LC236\nfldl One\nfaddl U2\nfstpl Y2\nfldl One\nfsubl U2\nfstpl Y1\nfldl OneAndHalf\nfsubl U2\nfstpl X\nfldl OneAndHalf\nfaddl U2\nfstpl Y\nfldl X\nfstpl -956(%ebp)\nfldl Y2\nfstpl -964(%ebp)\nfldl -956(%ebp)\nfsubl U2\nfmull -964(%ebp)\nfstpl Z\nfldl Y\nfstpl -972(%ebp)\nfldl Y1\nfstpl -980(%ebp)\nfldl -972(%ebp)\nfmull -980(%ebp)\nfstpl T\nfldl Z\nfsubl -956(%ebp)\nfstpl Z\nfldl T\nfsubl -956(%ebp)\nfstpl T\nfldl -956(%ebp)\nfmull -964(%ebp)\nfstpl X\nfldl -972(%ebp)\nfaddl U2\nfmull -980(%ebp)\nfstpl Y\nfldl X\nfsubl OneAndHalf\nfstpl X\nfldl Y\nfsubl OneAndHalf\nfstpl Y\nfldl Zero\nfcompl X\nfstsw %ax\nsahf\njne .LC246\nfldl Zero\nfcompl Y\nfstsw %ax\nsahf\njne .LC246\nfldl Zero\nfcompl Z\nfstsw %ax\nsahf\njne .LC246\nfldl Zero\nfcompl T\nfstsw %ax\nsahf\njb .LC246\nfldl OneAndHalf\nfaddl U2\nfstpl -1012(%ebp)\nfldl -1012(%ebp)\nfmull Y2\nfstpl X\nfldl OneAndHalf\nfsubl U2\nfstpl -1028(%ebp)\nfldl -1028(%ebp)\nfsubl U2\nfstpl Y\nfldl -1012(%ebp)\nfaddl U2\nfstpl Z\nfldl Y1\nfstpl -1036(%ebp)\nfldl -1028(%ebp)\nfmull -1036(%ebp)\nfstpl T\nfldl Z\nfstpl -1044(%ebp)\nfldl -1044(%ebp)\nfaddl U2\nfstpl -1052(%ebp)\nfldl X\nfsubl -1052(%ebp)\nfstpl X\nfldl Y\nfstpl -1060(%ebp)\nfldl -1060(%ebp)\nfmull -1036(%ebp)\nfstpl StickyBit\nfldl -1044(%ebp)\nfmull Y2\nfstpl S\nfldl T\nfsubl -1060(%ebp)\nfstpl T\nfldl U2\nfsubl -1060(%ebp)\nfaddl StickyBit\nfstpl Y\nfldl S\nfldl -1052(%ebp)\nfaddl U2\nfsubp %st(1),%st\nfstpl Z\nfldl Y2\nfaddl U2\nfmull -1036(%ebp)\nfstpl StickyBit\nfldl Y2\nfmull -1036(%ebp)\nfstpl Y1\nfldl StickyBit\nfsubl Y2\nfstpl StickyBit\nfldl Y1\nfsubl Half\nfstpl Y1\nfldl Zero\nfcompl X\nfstsw %ax\nsahf\njne .LC248\nfldl Zero\nfcompl Y\nfstsw %ax\nsahf\njne .LC248\nfldl Zero\nfcompl Z\nfstsw %ax\nsahf\njne .LC248\nfldl Zero\nfcompl T\nfstsw %ax\nsahf\njne .LC248\nfldl Zero\nfcompl StickyBit\nfstsw %ax\nsahf\njne .LC248\nfldl Half\nfcompl Y1\nfstsw %ax\nsahf\njne .LC248\nmovl $1,RMult\npushl $.LC250\ncall printf\naddl $4,%esp\njmp .LC249\n.LC248:\nfldl X\nfaddl U2\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC251\nfldl Zero\nfcompl Y\nfstsw %ax\nsahf\njbe .LC251\nfldl Z\nfaddl U2\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC251\nfldl Zero\nfcompl T\nfstsw %ax\nsahf\njbe .LC251\nfldl StickyBit\nfaddl U2\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC251\nfldl Half\nfcompl Y1\nfstsw %ax\nsahf\njbe .LC251\nmovl $2,RMult\npushl $.LC253\ncall printf\naddl $4,%esp\njmp .LC252\n.LC251:\npushl $.LC254\ncall printf\naddl $4,%esp\n.LC252:\n.LC249:\ncmpl $1,RMult\njne .LC247\ncmpl $0,GMult\njne .LC247\npushl $.LC257\ncall notify\naddl $4,%esp\njmp .LC247\n.LC246:\npushl $.LC254\ncall printf\naddl $4,%esp\n.LC247:\nmovl $45,Milestone\nfldl One\nfaddl U2\nfstpl Y2\nfldl One\nfsubl U2\nfstpl Y1\nfldl OneAndHalf\nfaddl U2\nfstpl -1020(%ebp)\nfldl -1020(%ebp)\nfaddl U2\nfstpl Z\nfldl Z\nfstpl -1028(%ebp)\nfldl Y2\nfstpl -1036(%ebp)\nfldl -1028(%ebp)\nfdivl -1036(%ebp)\nfstpl X\nfldl OneAndHalf\nfsubl U2\nfsubl U2\nfstpl T\nfldl T\nfstpl -1044(%ebp)\nfldl Y1\nfstpl -1052(%ebp)\nfldl -1044(%ebp)\nfsubl U2\nfdivl -1052(%ebp)\nfstpl Y\nfldl -1028(%ebp)\nfaddl U2\nfdivl -1036(%ebp)\nfstpl Z\nfldl X\nfsubl OneAndHalf\nfstpl X\nfldl Y\nfsubl -1044(%ebp)\nfstpl Y\nfldl -1044(%ebp)\nfdivl -1052(%ebp)\nfstpl T\nfldl Z\nfsubl -1020(%ebp)\nfstpl Z\nfldl U2\nfsubl OneAndHalf\nfaddl T\nfstpl T\nfldl Zero\nfcompl X\nfstsw %ax\nsahf\njb .LC258\nfldl Zero\nfcompl Y\nfstsw %ax\nsahf\njb .LC258\nfldl Zero\nfcompl Z\nfstsw %ax\nsahf\njb .LC258\nfldl Zero\nfcompl T\nfstsw %ax\nsahf\njb .LC258\nfldl Y2\nfstpl -1076(%ebp)\nfldl OneAndHalf\nfdivl -1076(%ebp)\nfstpl X\nfldl OneAndHalf\nfsubl U2\nfstpl Y\nfldl OneAndHalf\nfaddl U2\nfstpl Z\nfldl Y\nfstpl -1092(%ebp)\nfldl X\nfsubl -1092(%ebp)\nfstpl X\nfldl Y1\nfstpl -1100(%ebp)\nfldl OneAndHalf\nfdivl -1100(%ebp)\nfstpl T\nfldl -1092(%ebp)\nfdivl -1100(%ebp)\nfstpl Y\nfldl Z\nfstpl -1108(%ebp)\nfldl T\nfldl -1108(%ebp)\nfaddl U2\nfsubp %st(1),%st\nfstpl T\nfldl Y\nfsubl -1108(%ebp)\nfstpl Y\nfldl -1108(%ebp)\nfdivl -1076(%ebp)\nfstpl Z\nfldl -1076(%ebp)\nfaddl U2\nfdivl -1076(%ebp)\nfstpl Y1\nfldl Z\nfsubl OneAndHalf\nfstpl Z\nfldl Y1\nfsubl -1076(%ebp)\nfstpl Y2\nfldl F9\nfsubl U1\nfdivl F9\nfstpl Y1\nfldl Zero\nfcompl X\nfstsw %ax\nsahf\njne .LC260\nfldl Zero\nfcompl Y\nfstsw %ax\nsahf\njne .LC260\nfldl Zero\nfcompl Z\nfstsw %ax\nsahf\njne .LC260\nfldl Zero\nfcompl T\nfstsw %ax\nsahf\njne .LC260\nfldl Zero\nfcompl Y2\nfstsw %ax\nsahf\njne .LC260\nfldl Zero\nfcompl Y2\nfstsw %ax\nsahf\njne .LC260\nfldl Y1\nfsubl Half\nfldl F9\nfsubl Half\nfcompp\nfstsw %ax\nsahf\njne .LC260\nmovl $1,RDiv\npushl $.LC262\ncall printf\naddl $4,%esp\ncmpl $0,GDiv\njne .LC261\npushl $.LC265\ncall notify\naddl $4,%esp\njmp .LC261\n.LC260:\nfldl Zero\nfcompl X\nfstsw %ax\nsahf\njbe .LC266\nfldl Zero\nfcompl Y\nfstsw %ax\nsahf\njbe .LC266\nfldl Zero\nfcompl Z\nfstsw %ax\nsahf\njbe .LC266\nfldl Zero\nfcompl T\nfstsw %ax\nsahf\njbe .LC266\nfldl Zero\nfcompl Y2\nfstsw %ax\nsahf\njbe .LC266\nfldl Y1\nfsubl Half\nfldl F9\nfsubl Half\nfcompp\nfstsw %ax\nsahf\njbe .LC266\nmovl $2,RDiv\npushl $.LC268\ncall printf\naddl $4,%esp\n.LC266:\n.LC261:\n.LC258:\ncmpl $0,RDiv\njne .LC269\npushl $.LC271\ncall printf\naddl $4,%esp\n.LC269:\nfldl One\nfdivl Radix\nfstpl BInvrse\npushl $.LC273\nfldl BInvrse\nfmull Radix\nfsubl Half\nfldl Half\nfcompp\nfstsw %ax\nsahf\njne .LC274\nmovl $1,-1064(%ebp)\njmp .LC275\n.LC274:\nmovl $0,-1064(%ebp)\n.LC275:\npushl -1064(%ebp)\npushl $0\ncall TstCond\naddl $12,%esp\nmovl $50,Milestone\npushl $.LC277\nfldl F9\nfaddl U1\nfsubl Half\nfldl Half\nfcompp\nfstsw %ax\nsahf\njne .LC278\nfldl BMinusU2\nfaddl U2\nfsubl One\nfldl Radix\nfsubl One\nfcompp\nfstsw %ax\nsahf\njne .LC278\nmovl $1,-1084(%ebp)\njmp .LC279\n.LC278:\nmovl $0,-1084(%ebp)\n.LC279:\npushl -1084(%ebp)\npushl $0\ncall TstCond\naddl $12,%esp\nfldl One\nfldl U1\nfmull U1\nfsubp %st(1),%st\nfstpl X\nfldl One\nfldl U2\nfldl One\nfsubl U2\nfmulp %st(1),%st\nfaddp %st(1),%st\nfstpl Y\nfldl F9\nfsubl Half\nfstpl Z\nfldl X\nfsubl Half\nfsubl Z\nfstpl X\nfldl Y\nfsubl One\nfstpl Y\nfldl Zero\nfcompl X\nfstsw %ax\nsahf\njne .LC280\nfldl Zero\nfcompl Y\nfstsw %ax\nsahf\njne .LC280\nmovl $2,RAddSub\npushl $.LC282\ncall printf\naddl $4,%esp\n.LC280:\ncmpl $1,GAddSub\njne .LC283\nfldl Half\nfaddl U2\nfmull U2\nfstpl X\nfldl Half\nfsubl U2\nfmull U2\nfstpl Y\nfldl One\nfaddl X\nfstpl X\nfldl One\nfaddl Y\nfstpl Y\nfldl One\nfaddl U2\nfsubl X\nfstpl X\nfldl One\nfsubl Y\nfstpl Y\nfldl Zero\nfcompl X\nfstsw %ax\nsahf\njne .LC285\nfldl Zero\nfcompl Y\nfstsw %ax\nsahf\njne .LC285\nfldl Half\nfaddl U2\nfmull U1\nfstpl X\nfldl Half\nfsubl U2\nfmull U1\nfstpl Y\nfldl One\nfsubl X\nfstpl X\nfldl One\nfsubl Y\nfstpl Y\nfldl F9\nfsubl X\nfstpl X\nfldl One\nfsubl Y\nfstpl Y\nfldl Zero\nfcompl X\nfstsw %ax\nsahf\njne .LC287\nfldl Zero\nfcompl Y\nfstsw %ax\nsahf\njne .LC287\nmovl $1,RAddSub\npushl $.LC289\ncall printf\naddl $4,%esp\ncmpl $0,GAddSub\njne .LC284\npushl $.LC292\ncall notify\naddl $4,%esp\njmp .LC284\n.LC287:\npushl $.LC293\ncall printf\naddl $4,%esp\njmp .LC284\n.LC285:\npushl $.LC293\ncall printf\naddl $4,%esp\njmp .LC284\n.LC283:\npushl $.LC293\ncall printf\naddl $4,%esp\n.LC284:\nfldl One\nfstpl S\nfldl One\nfldl Half\nfldl One\nfaddl Half\nfmulp %st(1),%st\nfaddp %st(1),%st\nfstpl X\nfldl One\nfaddl U2\nfmull Half\nfstpl Y\nfldl X\nfstpl -1164(%ebp)\nfldl Y\nfstpl -1172(%ebp)\nfldl -1164(%ebp)\nfsubl -1172(%ebp)\nfstpl Z\nfldl -1172(%ebp)\nfsubl -1164(%ebp)\nfstpl T\nfldl Z\nfaddl T\nfstpl StickyBit\nfldl Zero\nfcompl StickyBit\nfstsw %ax\nsahf\nje .LC294\nfldl Zero\nfstpl S\npushl $.LC296\npushl $3\ncall BadCond\naddl $8,%esp\n.LC294:\nfldl Zero\nfstpl StickyBit\ncmpl $1,GMult\njne .LC297\ncmpl $1,GDiv\njne .LC297\ncmpl $1,GAddSub\njne .LC297\ncmpl $1,RMult\njne .LC297\ncmpl $1,RDiv\njne .LC297\ncmpl $1,RAddSub\njne .LC297\nfldl RadixD2\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -1180(%ebp)\nfldl RadixD2\nfcompl -1180(%ebp)\nfstsw %ax\nsahf\njne .LC297\npushl $.LC299\ncall printf\naddl $4,%esp\nfldl Half\nfaddl U1\nfmull U2\nfstpl X\nfldl Half\nfmull U2\nfstpl Y\nfldl One\nfaddl Y\nfstpl Z\nfldl One\nfaddl X\nfstpl T\nfldl Z\nfsubl One\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njb .LC300\nfldl T\nfsubl One\nfldl U2\nfcompp\nfstsw %ax\nsahf\nja .LC300\nfldl T\nfaddl Y\nfstpl Z\nfldl Z\nfsubl X\nfstpl Y\nfldl Z\nfsubl T\nfldl U2\nfcompp\nfstsw %ax\nsahf\nja .LC302\nfldl Y\nfsubl T\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC302\nfldl Half\nfaddl U1\nfmull U1\nfstpl X\nfldl Half\nfmull U1\nfstpl Y\nfldl One\nfsubl Y\nfstpl Z\nfldl One\nfsubl X\nfstpl T\nfldl Z\nfsubl One\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC304\nfldl T\nfsubl F9\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC304\nfldl Half\nfsubl U1\nfmull U1\nfstpl Z\nfldl F9\nfsubl Z\nfstpl T\nfldl F9\nfsubl Y\nfstpl Q\nfldl T\nfsubl F9\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC306\nfldl F9\nfsubl U1\nfsubl Q\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC306\nfldl One\nfaddl U2\nfmull OneAndHalf\nfstpl Z\nfldl OneAndHalf\nfaddl U2\nfsubl Z\nfaddl U2\nfstpl T\nfldl One\nfldl Half\nfdivl Radix\nfaddp %st(1),%st\nfstpl X\nfldl One\nfldl Radix\nfmull U2\nfaddp %st(1),%st\nfstpl Y\nfldl X\nfmull Y\nfstpl Z\nfldl Zero\nfcompl T\nfstsw %ax\nsahf\njne .LC308\nfldl X\nfldl Radix\nfmull U2\nfaddp %st(1),%st\nfsubl Z\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC308\nfldl Two\nfcompl Radix\nfstsw %ax\nsahf\nje .LC310\nfldl Two\nfaddl U2\nfstpl X\nfldl X\nfdivl Two\nfstpl Y\nfldl Y\nfsubl One\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC311\nfldl S\nfstpl StickyBit\njmp .LC311\n.LC310:\nfldl S\nfstpl StickyBit\n.LC311:\n.LC308:\n.LC306:\n.LC304:\n.LC302:\n.LC300:\n.LC297:\nfldl One\nfcompl StickyBit\nfstsw %ax\nsahf\njne .LC314\npushl $.LC316\ncall printf\naddl $4,%esp\njmp .LC315\n.LC314:\npushl $.LC317\ncall printf\naddl $4,%esp\n.LC315:\npushl $.LC319\ncmpl $0,GMult\nje .LC320\ncmpl $0,GDiv\nje .LC320\ncmpl $0,GAddSub\nje .LC320\ncmpl $0,RMult\nje .LC320\ncmpl $0,RDiv\nje .LC320\ncmpl $0,RAddSub\nje .LC320\nmovl $1,-1184(%ebp)\njmp .LC321\n.LC320:\nmovl $0,-1184(%ebp)\n.LC321:\npushl -1184(%ebp)\npushl $3\ncall TstCond\naddl $12,%esp\nmovl $60,Milestone\npushl $.LC45\ncall printf\naddl $4,%esp\npushl $.LC322\ncall printf\naddl $4,%esp\npushl NoTrials\npushl $.LC323\ncall printf\naddl $8,%esp\nfldl .LC324\nsubl $8,%esp\nfstpl (%esp)\ncall sqrt\naddl $8,%esp\nfstpl -1192(%ebp)\nfldl -1192(%ebp)\nfstpl Random9\nfldl Third\nfstpl Random1\nmovl $1,I\n.LC325:\ncall Random\nfstpl -1200(%ebp)\nfldl -1200(%ebp)\nfstpl X\ncall Random\nfstpl -1208(%ebp)\nfldl -1208(%ebp)\nfstpl Y\nfldl Y\nfmull X\nfstpl Z9\nfldl X\nfmull Y\nfstpl Z\nfldl Z\nfsubl Z9\nfstpl Z9\nincl I\n.LC326:\nmovl NoTrials,%edi\ncmpl %edi,I\njg .LC328\nfldl Zero\nfcompl Z9\nfstsw %ax\nsahf\nje .LC325\n.LC328:\nmovl NoTrials,%edi\ncmpl %edi,I\njne .LC329\nfldl One\nfldl Half\nfdivl Three\nfaddp %st(1),%st\nfstpl -1208(%ebp)\nfldl -1208(%ebp)\nfstpl Random1\nfldl U2\nfaddl U1\nfaddl One\nfstpl -1216(%ebp)\nfldl -1216(%ebp)\nfstpl Random2\nfldl Random1\nfstpl -1224(%ebp)\nfldl Random2\nfstpl -1232(%ebp)\nfldl -1224(%ebp)\nfmull -1232(%ebp)\nfstpl Z\nfldl -1232(%ebp)\nfmull -1224(%ebp)\nfstpl Y\nfldl -1208(%ebp)\nfmull -1216(%ebp)\nfstpl -1240(%ebp)\nfldl -1240(%ebp)\nfsubl -1240(%ebp)\nfstpl Z9\n.LC329:\nmovl NoTrials,%edi\ncmpl %edi,I\nje .LC331\nfldl Zero\nfcompl Z9\nfstsw %ax\nsahf\nje .LC331\npushl $.LC333\npushl $2\ncall BadCond\naddl $8,%esp\njmp .LC332\n.LC331:\npushl NoTrials\npushl $.LC334\ncall printf\naddl $8,%esp\n.LC332:\nmovl $70,Milestone\npushl $.LC335\ncall printf\naddl $4,%esp\nfldl Zero\nsubl $8,%esp\nfstpl (%esp)\ncall sqrt\naddl $8,%esp\nfstpl -1212(%ebp)\nfldl -1212(%ebp)\nfcompl Zero\nfstsw %ax\nsahf\njne .LC338\nfldl Zero\nfchs\nfstpl -1220(%ebp)\nfldl -1220(%ebp)\nsubl $8,%esp\nfstpl (%esp)\ncall sqrt\naddl $8,%esp\nfstpl -1228(%ebp)\nfldl -1228(%ebp)\nfcompl -1220(%ebp)\nfstsw %ax\nsahf\njne .LC338\nfldl One\nsubl $8,%esp\nfstpl (%esp)\ncall sqrt\naddl $8,%esp\nfstpl -1244(%ebp)\nfldl -1244(%ebp)\nfcompl One\nfstsw %ax\nsahf\njne .LC338\nmovl $1,-1196(%ebp)\njmp .LC339\n.LC338:\nmovl $0,-1196(%ebp)\n.LC339:\npushl $.LC337\npushl -1196(%ebp)\npushl $0\ncall TstCond\naddl $12,%esp\nfldl Zero\nfstpl MinSqEr\nfldl Zero\nfstpl MaxSqEr\nfldl Zero\nfstpl J\nfldl Radix\nfstpl X\nfldl U2\nfstpl OneUlp\npushl $1\ncall SqXMinX\naddl $4,%esp\nfldl BInvrse\nfstpl X\nfldl BInvrse\nfmull U1\nfstpl OneUlp\npushl $1\ncall SqXMinX\naddl $4,%esp\nfldl U1\nfstpl X\nfldl U1\nfmull U1\nfstpl OneUlp\npushl $1\ncall SqXMinX\naddl $4,%esp\nfldl Zero\nfcompl J\nfstsw %ax\nsahf\nje .LC340\ncall Pause\n.LC340:\npushl NoTrials\npushl $.LC342\ncall printf\naddl $8,%esp\nfldl Zero\nfstpl J\nfldl Two\nfstpl X\nfldl Radix\nfstpl Y\nfldl One\nfcompl Radix\nfstsw %ax\nsahf\nje .LC343\n.LC345:\nfldl Y\nfstpl -1284(%ebp)\nfldl -1284(%ebp)\nfstpl X\nfldl Radix\nfmull -1284(%ebp)\nfstpl Y\n.LC346:\nfldl Y\nfsubl X\nfildl NoTrials\nfcompp\nfstsw %ax\nsahf\nja .LC345\n.LC343:\nfldl X\nfmull U2\nfstpl OneUlp\nmovl $1,I\njmp .LC349\n.LC348:\nfldl X\nfaddl One\nfstpl X\npushl $2\ncall SqXMinX\naddl $4,%esp\nfldl Zero\nfcompl J\nfstsw %ax\nsahf\njae .LC351\njmp .LC350\n.LC351:\nincl I\n.LC349:\nmovl NoTrials,%edi\ncmpl %edi,I\njle .LC348\n.LC350:\npushl $.LC353\ncall printf\naddl $4,%esp\nmovl $-1,I\nfldl BMinusU2\nfstpl X\nfldl Radix\nfstpl Y\nfldl Radix\nfldl Radix\nfmull U2\nfaddp %st(1),%st\nfstpl Z\nmovl $0,NotMonot\nmovl $0,Monot\njmp .LC355\n.LC354:\nincl I\nfldl X\nsubl $8,%esp\nfstpl (%esp)\ncall sqrt\naddl $8,%esp\nfstpl -1292(%ebp)\nfldl -1292(%ebp)\nfstpl X\nfldl Y\nsubl $8,%esp\nfstpl (%esp)\ncall sqrt\naddl $8,%esp\nfstpl -1300(%ebp)\nfldl -1300(%ebp)\nfstpl Q\nfldl Z\nsubl $8,%esp\nfstpl (%esp)\ncall sqrt\naddl $8,%esp\nfstpl -1308(%ebp)\nfldl -1308(%ebp)\nfstpl Z\nfldl Q\nfcompl X\nfstsw %ax\nsahf\njb .LC359\nfldl Z\nfcompl Q\nfstsw %ax\nsahf\njae .LC357\n.LC359:\nmovl $1,NotMonot\njmp .LC358\n.LC357:\nfldl Q\nfaddl Half\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -1324(%ebp)\nfldl -1324(%ebp)\nfstpl Q\ncmpl $0,I\njg .LC362\nfldl Q\nfmull Q\nfcompl Radix\nfstsw %ax\nsahf\njne .LC360\n.LC362:\nmovl $1,Monot\njmp .LC361\n.LC360:\ncmpl $0,I\njle .LC363\ncmpl $1,I\njle .LC365\nmovl $1,Monot\njmp .LC364\n.LC365:\nfldl Y\nfmull BInvrse\nfstpl Y\nfldl Y\nfstpl -1340(%ebp)\nfldl -1340(%ebp)\nfsubl U1\nfstpl X\nfldl -1340(%ebp)\nfaddl U1\nfstpl Z\njmp .LC364\n.LC363:\nfldl Q\nfstpl Y\nfldl Y\nfstpl -1340(%ebp)\nfldl -1340(%ebp)\nfsubl U2\nfstpl X\nfldl -1340(%ebp)\nfaddl U2\nfstpl Z\n.LC364:\n.LC361:\n.LC358:\n.LC355:\ncmpl $0,NotMonot\njne .LC367\ncmpl $0,Monot\nje .LC354\n.LC367:\ncmpl $0,Monot\nje .LC368\npushl $.LC370\ncall printf\naddl $4,%esp\njmp .LC369\n.LC368:\npushl $.LC158\npushl $2\ncall BadCond\naddl $8,%esp\nfldl Y\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC371\ncall printf\naddl $12,%esp\n.LC369:\nmovl $80,Milestone\nfldl MinSqEr\nfaddl Half\nfstpl MinSqEr\nfldl MaxSqEr\nfsubl Half\nfstpl MaxSqEr\nfldl One\nfaddl U2\nsubl $8,%esp\nfstpl (%esp)\ncall sqrt\naddl $8,%esp\nfstpl -1300(%ebp)\nfldl -1300(%ebp)\nfsubl One\nfdivl U2\nfstpl Y\nfldl Y\nfsubl One\nfldl U2\nfdivl Eight\nfaddp %st(1),%st\nfstpl SqEr\nfldl MaxSqEr\nfcompl SqEr\nfstsw %ax\nsahf\njae .LC372\nfldl SqEr\nfstpl MaxSqEr\n.LC372:\nfldl Y\nfldl U2\nfdivl Eight\nfaddp %st(1),%st\nfstpl SqEr\nfldl MinSqEr\nfcompl SqEr\nfstsw %ax\nsahf\njbe .LC374\nfldl SqEr\nfstpl MinSqEr\n.LC374:\nfldl F9\nsubl $8,%esp\nfstpl (%esp)\ncall sqrt\naddl $8,%esp\nfstpl -1324(%ebp)\nfldl -1324(%ebp)\nfsubl U2\nfldl One\nfsubl U2\nfsubp %st(1),%st\nfdivl U1\nfstpl Y\nfldl Y\nfldl U1\nfdivl Eight\nfaddp %st(1),%st\nfstpl SqEr\nfldl MaxSqEr\nfcompl SqEr\nfstsw %ax\nsahf\njae .LC376\nfldl SqEr\nfstpl MaxSqEr\n.LC376:\nfldl Y\nfaddl One\nfldl U1\nfdivl Eight\nfaddp %st(1),%st\nfstpl SqEr\nfldl MinSqEr\nfcompl SqEr\nfstsw %ax\nsahf\njbe .LC378\nfldl SqEr\nfstpl MinSqEr\n.LC378:\nfldl U2\nfstpl OneUlp\nfldl OneUlp\nfstpl X\nmovl $1,Indx\n.LC380:\nfldl X\nfaddl U1\nfaddl X\nfaddl F9\nsubl $8,%esp\nfstpl (%esp)\ncall sqrt\naddl $8,%esp\nfstpl -1356(%ebp)\nfldl -1356(%ebp)\nfstpl Y\nfldl Y\nfsubl U2\nfldl One\nfsubl U2\nfaddl X\nfsubp %st(1),%st\nfdivl OneUlp\nfstpl Y\nfldl U1\nfsubl X\nfaddl F9\nfmull Half\nfmull X\nfmull X\nfdivl OneUlp\nfstpl Z\nfldl Y\nfaddl Half\nfaddl Z\nfstpl SqEr\nfldl MinSqEr\nfcompl SqEr\nfstsw %ax\nsahf\njbe .LC384\nfldl SqEr\nfstpl MinSqEr\n.LC384:\nfldl Y\nfsubl Half\nfaddl Z\nfstpl SqEr\nfldl MaxSqEr\nfcompl SqEr\nfstsw %ax\nsahf\njae .LC386\nfldl SqEr\nfstpl MaxSqEr\n.LC386:\nmovl Indx,%edi\ncmpl $1,%edi\nje .LC390\ncmpl $3,%edi\njne .LC388\n.LC390:\nfldl X\nsubl $8,%esp\nfstpl (%esp)\ncall Sign\naddl $8,%esp\nfstpl -1396(%ebp)\nfldl OneUlp\nsubl $8,%esp\nfstpl (%esp)\ncall sqrt\naddl $8,%esp\nfstpl -1404(%ebp)\nfldl Eight\nfldl Nine\nfmull -1404(%ebp)\nfdivp %st(1),%st\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -1412(%ebp)\nfldl OneUlp\nfmull -1396(%ebp)\nfmull -1412(%ebp)\nfstpl X\njmp .LC389\n.LC388:\nfldl U1\nfstpl OneUlp\nfldl OneUlp\nfchs\nfstpl X\n.LC389:\n.LC381:\nincl Indx\ncmpl $3,Indx\njle .LC380\nmovl $85,Milestone\nmovl $0,SqRWrng\nmovl $0,Anomaly\nmovl $0,RSqrt\nfldl One\nfcompl Radix\nfstsw %ax\nsahf\nje .LC391\npushl $.LC393\ncall printf\naddl $4,%esp\nfldl Precision\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -1356(%ebp)\nfldl One\nfaddl Precision\nfsubl -1356(%ebp)\nsubl $8,%esp\nfstpl (%esp)\nfldl Radix\nsubl $8,%esp\nfstpl (%esp)\ncall pow\naddl $16,%esp\nfstpl -1364(%ebp)\nfldl Half\nfaddl -1364(%ebp)\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -1372(%ebp)\nfldl -1372(%ebp)\nfstpl D\nfldl D\nfdivl Radix\nfstpl X\nfldl D\nfdivl A1\nfstpl Y\nfldl X\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -1396(%ebp)\nfldl -1396(%ebp)\nfcompl X\nfstsw %ax\nsahf\njne .LC396\nfldl Y\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -1412(%ebp)\nfldl -1412(%ebp)\nfcompl Y\nfstsw %ax\nsahf\nje .LC394\n.LC396:\nmovl $1,Anomaly\njmp .LC395\n.LC394:\nfldl Zero\nfstpl X\nfldl X\nfstpl Z2\nfldl One\nfstpl Y\nfldl Y\nfstpl Y2\nfldl Radix\nfsubl One\nfstpl Z1\nfldl Four\nfmull D\nfstpl FourD\n.LC397:\nfldl Z2\nfcompl Y2\nfstsw %ax\nsahf\njae .LC400\nfldl Radix\nfstpl Q\nfldl Y\nfstpl Y1\n.LC402:\nfldl Half\nfldl Q\nfdivl Y1\nfsubp %st(1),%st\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -1436(%ebp)\nfldl Q\nfldl -1436(%ebp)\nfmull Y1\nfaddp %st(1),%st\nsubl $8,%esp\nfstpl (%esp)\ncall fabs\naddl $8,%esp\nfstpl -1444(%ebp)\nfldl -1444(%ebp)\nfstpl X1\nfldl Y1\nfstpl Q\nfldl X1\nfstpl Y1\n.LC403:\nfldl Zero\nfcompl X1\nfstsw %ax\nsahf\njb .LC402\nfldl One\nfcompl Q\nfstsw %ax\nsahf\njb .LC405\nfldl Y2\nfstpl Z2\nfldl Y\nfstpl Z\n.LC405:\n.LC400:\nfldl Y\nfaddl Two\nfstpl Y\nfldl X\nfaddl Eight\nfstpl X\nfldl Y2\nfaddl X\nfstpl Y2\nfldl FourD\nfcompl Y2\nfstsw %ax\nsahf\nja .LC407\nfldl Y2\nfsubl FourD\nfstpl Y2\n.LC407:\n.LC398:\nfldl D\nfcompl Y\nfstsw %ax\nsahf\nja .LC397\nfldl FourD\nfsubl Z2\nfstpl X8\nfldl X8\nfstpl -1436(%ebp)\nfldl -1436(%ebp)\nfldl Z\nfmull Z\nfaddp %st(1),%st\nfdivl FourD\nfstpl Q\nfldl -1436(%ebp)\nfdivl Eight\nfstpl X8\nfldl Q\nfstpl -1452(%ebp)\nfldl -1452(%ebp)\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -1460(%ebp)\nfldl -1460(%ebp)\nfcompl -1452(%ebp)\nfstsw %ax\nsahf\nje .LC409\nmovl $1,Anomaly\njmp .LC410\n.LC409:\nmovl $0,Break\n.LC411:\nfldl Z1\nfmull Z\nfstpl X\nfldl X\nfstpl -1468(%ebp)\nfldl -1468(%ebp)\nfdivl Radix\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -1476(%ebp)\nfldl -1468(%ebp)\nfldl -1476(%ebp)\nfmull Radix\nfsubp %st(1),%st\nfstpl X\nfldl One\nfcompl X\nfstsw %ax\nsahf\njne .LC414\nmovl $1,Break\njmp .LC415\n.LC414:\nfldl Z1\nfsubl One\nfstpl Z1\n.LC415:\n.LC412:\ncmpl $0,Break\njne .LC416\nfldl Zero\nfcompl Z1\nfstsw %ax\nsahf\njb .LC411\n.LC416:\nfldl Zero\nfcompl Z1\nfstsw %ax\nsahf\njb .LC417\ncmpl $0,Break\njne .LC417\nmovl $1,Anomaly\njmp .LC418\n.LC417:\nfldl RadixD2\nfcompl Z1\nfstsw %ax\nsahf\njae .LC419\nfldl Z1\nfsubl Radix\nfstpl Z1\n.LC419:\n.LC421:\ncall NewD\n.LC422:\nfldl U2\nfmull D\nfldl F9\nfcompp\nfstsw %ax\nsahf\nja .LC421\nfldl D\nfmull Radix\nfsubl D\nfldl W\nfsubl D\nfcompp\nfstsw %ax\nsahf\nje .LC424\nmovl $1,Anomaly\njmp .LC425\n.LC424:\nfldl D\nfstpl Z2\nmovl $0,I\nfldl D\nfldl One\nfaddl Z\nfmull Half\nfaddp %st(1),%st\nfstpl Y\nfldl D\nfaddl Z\nfaddl Q\nfstpl X\ncall SR3750\nfldl D\nfldl One\nfsubl Z\nfmull Half\nfaddp %st(1),%st\nfaddl D\nfstpl Y\nfldl D\nfsubl Z\nfaddl D\nfstpl X\nfldl X\nfstpl -1508(%ebp)\nfldl -1508(%ebp)\nfaddl Q\nfaddl -1508(%ebp)\nfstpl X\ncall SR3750\ncall NewD\nfldl D\nfsubl Z2\nfldl W\nfsubl Z2\nfcompp\nfstsw %ax\nsahf\nje .LC426\nmovl $1,Anomaly\njmp .LC427\n.LC426:\nfldl D\nfsubl Z2\nfstpl -1532(%ebp)\nfldl -1532(%ebp)\nfldl Z2\nfldl One\nfsubl Z\nfmull Half\nfaddp %st(1),%st\nfaddp %st(1),%st\nfstpl Y\nfldl -1532(%ebp)\nfldl Z2\nfsubl Z\nfaddl Q\nfaddp %st(1),%st\nfstpl X\ncall SR3750\nfldl One\nfaddl Z\nfmull Half\nfstpl Y\nfldl Q\nfstpl X\ncall SR3750\ncmpl $0,I\njne .LC428\nmovl $1,Anomaly\n.LC428:\n.LC427:\n.LC425:\n.LC418:\n.LC410:\n.LC395:\ncmpl $0,I\nje .LC432\ncmpl $0,Anomaly\nje .LC430\n.LC432:\npushl $.LC433\npushl $0\ncall BadCond\naddl $8,%esp\nfldl W\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC434\ncall printf\naddl $12,%esp\npushl $.LC435\ncall printf\naddl $4,%esp\nmovl $1,SqRWrng\n.LC430:\n.LC391:\ncmpl $0,Anomaly\njne .LC436\nfldl Zero\nfcompl MinSqEr\nfstsw %ax\nsahf\nja .LC438\nfldl Zero\nfcompl MaxSqEr\nfstsw %ax\nsahf\njb .LC438\nmovl $1,RSqrt\npushl $.LC440\ncall printf\naddl $4,%esp\njmp .LC439\n.LC438:\nfldl MaxSqEr\nfaddl U2\nfldl U2\nfsubl Half\nfcompp\nfstsw %ax\nsahf\njb .LC444\nfldl Half\nfcompl MinSqEr\nfstsw %ax\nsahf\njb .LC444\nfldl MinSqEr\nfaddl Radix\nfldl Half\nfcompp\nfstsw %ax\nsahf\njbe .LC441\n.LC444:\nmovl $1,SqRWrng\njmp .LC442\n.LC441:\nmovl $2,RSqrt\npushl $.LC445\ncall printf\naddl $4,%esp\n.LC442:\n.LC439:\n.LC436:\ncmpl $0,SqRWrng\nje .LC446\npushl $.LC448\ncall printf\naddl $4,%esp\nfldl MinSqEr\nfsubl Half\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC449\ncall printf\naddl $12,%esp\nfldl Half\nfaddl MaxSqEr\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC450\ncall printf\naddl $12,%esp\npushl $.LC452\nfldl MaxSqEr\nfsubl MinSqEr\nfldl Radix\nfmull Radix\nfcompp\nfstsw %ax\nsahf\njbe .LC453\nmovl $1,-1344(%ebp)\njmp .LC454\n.LC453:\nmovl $0,-1344(%ebp)\n.LC454:\npushl -1344(%ebp)\npushl $1\ncall TstCond\naddl $12,%esp\n.LC446:\nmovl $90,Milestone\ncall Pause\npushl $.LC455\ncall printf\naddl $4,%esp\nmovl $0,N\nmovl $0,I\nfldl Zero\nfchs\nfstpl Z\nmovl $3,M\nmovl $0,Break\n.LC456:\nfldl One\nfstpl X\ncall SR3980\ncmpl $10,I\njg .LC459\nmovl $1023,I\ncall SR3980\n.LC459:\nfldl MinusOne\nfcompl Z\nfstsw %ax\nsahf\njne .LC461\nmovl $1,Break\njmp .LC462\n.LC461:\nfldl MinusOne\nfstpl Z\ncall PrintIfNPositive\nmovl $0,N\nmovl $-4,I\n.LC462:\n.LC457:\ncmpl $0,Break\nje .LC456\ncall PrintIfNPositive\nmovl N,%edi\nmovl %edi,N1\nmovl $0,N\nfldl A1\nfstpl Z\nfldl W\nsubl $8,%esp\nfstpl (%esp)\ncall log\naddl $8,%esp\nfstpl -1348(%ebp)\nfldl A1\nsubl $8,%esp\nfstpl (%esp)\ncall log\naddl $8,%esp\nfstpl -1356(%ebp)\nfldl Two\nfmull -1348(%ebp)\nfdivl -1356(%ebp)\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -1364(%ebp)\nfldl -1364(%ebp)\nfistpl M\nmovl $0,Break\n.LC463:\nfldl Z\nfstpl X\nmovl $1,I\ncall SR3980\nfldl AInvrse\nfcompl Z\nfstsw %ax\nsahf\njne .LC466\nmovl $1,Break\njmp .LC467\n.LC466:\nfldl AInvrse\nfstpl Z\n.LC467:\n.LC464:\ncmpl $0,Break\nje .LC463\nmovl $100,Milestone\nmovl NoTrials,%edi\nmovl %edi,M\nfldl Three\nfstpl Z\n.LC468:\nfldl Z\nfstpl X\nmovl $1,I\ncall SR3980\n.LC471:\nfldl Z\nfaddl Two\nfstpl Z\n.LC472:\nfldl Z\nfdivl Three\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -1380(%ebp)\nfldl Three\nfmull -1380(%ebp)\nfldl Z\nfcompp\nfstsw %ax\nsahf\nje .LC471\n.LC469:\nfldl Eight\nfmull Three\nfcompl Z\nfstsw %ax\nsahf\nja .LC468\ncmpl $0,N\njle .LC474\npushl $.LC476\ncall printf\naddl $4,%esp\npushl $.LC477\ncall printf\naddl $4,%esp\n.LC474:\ncall PrintIfNPositive\nmovl N1,%edi\naddl %edi,N\ncmpl $0,N\njne .LC478\npushl $.LC480\ncall printf\naddl $4,%esp\n.LC478:\ncmpl $0,N\njle .LC481\ncall Pause\njmp .LC482\n.LC481:\npushl $.LC45\ncall printf\naddl $4,%esp\n.LC482:\nmovl $110,Milestone\npushl $.LC483\ncall printf\naddl $4,%esp\nfldl U1\nfstpl D\nfldl Precision\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -1380(%ebp)\nfldl -1380(%ebp)\nfcompl Precision\nfstsw %ax\nsahf\nje .LC484\nfldl BInvrse\nfstpl D\nfldl Precision\nfstpl X\n.LC486:\nfldl D\nfmull BInvrse\nfstpl D\nfldl X\nfsubl One\nfstpl X\n.LC487:\nfldl Zero\nfcompl X\nfstsw %ax\nsahf\njb .LC486\n.LC484:\nfldl One\nfstpl Y\nfldl D\nfstpl Z\n.LC489:\nfldl Y\nfstpl C\nfldl Z\nfstpl Y\nfldl Y\nfstpl -1388(%ebp)\nfldl -1388(%ebp)\nfmull -1388(%ebp)\nfstpl Z\n.LC490:\nfldl Z\nfcompl Y\nfstsw %ax\nsahf\njae .LC492\nfldl Z\nfaddl Z\nfldl Z\nfcompp\nfstsw %ax\nsahf\njb .LC489\n.LC492:\nfldl C\nfstpl Y\nfldl Y\nfmull D\nfstpl Z\n.LC493:\nfldl Y\nfstpl C\nfldl Z\nfstpl Y\nfldl Y\nfmull D\nfstpl Z\n.LC494:\nfldl Z\nfcompl Y\nfstsw %ax\nsahf\njae .LC496\nfldl Z\nfaddl Z\nfldl Z\nfcompp\nfstsw %ax\nsahf\njb .LC493\n.LC496:\nfldl Two\nfcompl Radix\nfstsw %ax\nsahf\njbe .LC497\nfldl Two\nfstpl HInvrse\njmp .LC498\n.LC497:\nfldl Radix\nfstpl HInvrse\n.LC498:\nfldl One\nfdivl HInvrse\nfstpl H\nfldl One\nfdivl C\nfstpl CInvrse\nfldl C\nfstpl E0\nfldl E0\nfmull H\nfstpl Z\n.LC499:\nfldl E0\nfstpl Y\nfldl Z\nfstpl E0\nfldl E0\nfmull H\nfstpl Z\n.LC500:\nfldl Z\nfcompl E0\nfstsw %ax\nsahf\njae .LC502\nfldl Z\nfaddl Z\nfldl Z\nfcompp\nfstsw %ax\nsahf\njb .LC499\n.LC502:\nfldl E0\nfstpl UfThold\nfldl Zero\nfstpl E1\nfldl Zero\nfstpl Q\nfldl U2\nfstpl E9\nfldl One\nfaddl E9\nfstpl S\nfldl C\nfmull S\nfstpl D\nfldl C\nfcompl D\nfstsw %ax\nsahf\njb .LC503\nfldl Radix\nfmull U2\nfstpl E9\nfldl One\nfaddl E9\nfstpl S\nfldl C\nfmull S\nfstpl D\nfldl C\nfcompl D\nfstsw %ax\nsahf\njb .LC504\npushl $.LC507\npushl $0\ncall BadCond\naddl $8,%esp\nfldl E0\nfstpl Underflow\nfldl Zero\nfstpl Y1\nfldl Z\nfstpl PseudoZero\ncall Pause\njmp .LC504\n.LC503:\nfldl D\nfstpl Underflow\nfldl Underflow\nfmull H\nfstpl PseudoZero\nfldl Zero\nfstpl UfThold\n.LC508:\nfldl Underflow\nfstpl Y1\nfldl PseudoZero\nfstpl Underflow\nfldl E1\nfaddl E1\nfldl E1\nfcompp\nfstsw %ax\nsahf\njb .LC511\nfldl Underflow\nfmull HInvrse\nfstpl Y2\nfldl Y1\nfsubl Y2\nsubl $8,%esp\nfstpl (%esp)\ncall fabs\naddl $8,%esp\nfstpl -1452(%ebp)\nfldl -1452(%ebp)\nfstpl E1\nfldl Y1\nfstpl Q\nfldl Zero\nfcompl UfThold\nfstsw %ax\nsahf\njne .LC513\nfldl Y2\nfcompl Y1\nfstsw %ax\nsahf\nje .LC513\nfldl Y1\nfstpl UfThold\n.LC513:\n.LC511:\nfldl PseudoZero\nfmull H\nfstpl PseudoZero\n.LC509:\nfldl PseudoZero\nfcompl Underflow\nfstsw %ax\nsahf\njae .LC515\nfldl PseudoZero\nfaddl PseudoZero\nfldl PseudoZero\nfcompp\nfstsw %ax\nsahf\njb .LC508\n.LC515:\n.LC504:\nfldl Zero\nfcompl PseudoZero\nfstsw %ax\nsahf\nje .LC516\npushl $.LC45\ncall printf\naddl $4,%esp\nfldl PseudoZero\nfstpl Z\nfldl Zero\nfcompl PseudoZero\nfstsw %ax\nsahf\njb .LC518\npushl $.LC520\npushl $0\ncall BadCond\naddl $8,%esp\npushl $.LC521\ncall printf\naddl $4,%esp\nfldl PseudoZero\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC522\ncall printf\naddl $12,%esp\nfldl PseudoZero\nfchs\nfstpl X\nfldl Zero\nfcompl X\nfstsw %ax\nsahf\njb .LC519\npushl $.LC525\ncall printf\naddl $4,%esp\nfldl X\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC526\ncall printf\naddl $12,%esp\njmp .LC519\n.LC518:\npushl $.LC527\npushl $3\ncall BadCond\naddl $8,%esp\nfldl PseudoZero\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC528\ncall printf\naddl $12,%esp\n.LC519:\ncall TstPtUf\n.LC516:\nmovl $120,Milestone\nfldl CInvrse\nfmull Y\nfldl CInvrse\nfmull Y1\nfcompp\nfstsw %ax\nsahf\njae .LC529\nfldl H\nfmull S\nfstpl S\nfldl Underflow\nfstpl E0\n.LC529:\nfldl Zero\nfcompl E1\nfstsw %ax\nsahf\nje .LC531\nfldl E0\nfcompl E1\nfstsw %ax\nsahf\nje .LC531\npushl $.LC158\npushl $2\ncall BadCond\naddl $8,%esp\nfldl E0\nfcompl E1\nfstsw %ax\nsahf\njbe .LC533\npushl $.LC535\ncall printf\naddl $4,%esp\npushl $.LC536\ncall printf\naddl $4,%esp\nfldl Zero\nfcompl PseudoZero\nfstsw %ax\nsahf\njne .LC534\nfldl E1\nfstpl E0\njmp .LC534\n.LC533:\npushl $.LC539\ncall printf\naddl $4,%esp\npushl $.LC540\ncall printf\naddl $4,%esp\n.LC534:\n.LC531:\nfldl E0\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC541\ncall printf\naddl $12,%esp\nfldl E0\nfstpl Z\ncall TstPtUf\nfldl E0\nfstpl Underflow\ncmpl $1,N\njne .LC542\nfldl Y\nfstpl Underflow\n.LC542:\nmovl $4,I\nfldl Zero\nfcompl E1\nfstsw %ax\nsahf\njne .LC544\nmovl $3,I\n.LC544:\nfldl Zero\nfcompl UfThold\nfstsw %ax\nsahf\njne .LC546\nsub $2,I\n.LC546:\nmovl $1,UfNGrad\nmovl I,%edi\ncmpl $1,%edi\njl .LC548\ncmpl $4,%edi\njg .LC548\njmp *.LC571-4(,%edi,4)\n.data\n.align 4\n.LC571:\n.long .LC550\n.long .LC557\n.long .LC562\n.long .LC563\n.text\n.LC550:\nfldl Underflow\nfstpl UfThold\nfldl CInvrse\nfmull Q\nfldl CInvrse\nfmull Y\nfmull S\nfcompp\nfstsw %ax\nsahf\nje .LC551\nfldl Y\nfstpl UfThold\npushl $.LC553\npushl $0\ncall BadCond\naddl $8,%esp\nfldl UfThold\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC554\ncall printf\naddl $12,%esp\nfldl C\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC555\ncall printf\naddl $12,%esp\npushl $.LC556\ncall printf\naddl $4,%esp\n.LC551:\ncall Pause\njmp .LC549\n.LC557:\npushl $.LC558\npushl $0\ncall BadCond\naddl $8,%esp\npushl $.LC559\ncall printf\naddl $4,%esp\nfldl Y2\nsubl $8,%esp\nfstpl (%esp)\nfldl Q\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC560\ncall printf\naddl $20,%esp\nfldl Q\nfsubl Y2\nsubl $8,%esp\nfstpl (%esp)\ncall fabs\naddl $8,%esp\nfstpl -1468(%ebp)\nfldl -1468(%ebp)\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC561\ncall printf\naddl $12,%esp\nfldl Q\nfstpl UfThold\njmp .LC549\n.LC562:\nfldl X\nfstpl X\njmp .LC549\n.LC563:\nfldl UfThold\nfcompl Q\nfstsw %ax\nsahf\njne .LC564\nfldl E0\nfcompl E1\nfstsw %ax\nsahf\njne .LC564\nfldl UfThold\nfldl E1\nfdivl E9\nfsubp %st(1),%st\nsubl $8,%esp\nfstpl (%esp)\ncall fabs\naddl $8,%esp\nfstpl -1492(%ebp)\nfldl E1\nfcompl -1492(%ebp)\nfstsw %ax\nsahf\njb .LC564\nmovl $0,UfNGrad\npushl $.LC566\ncall printf\naddl $4,%esp\npushl $.LC567\ncall printf\naddl $4,%esp\nfldl E0\nfmull CInvrse\nfstpl Y\nfldl Y\nfldl OneAndHalf\nfaddl U2\nfmulp %st(1),%st\nfstpl Y\nfldl CInvrse\nfldl One\nfaddl U2\nfmulp %st(1),%st\nfstpl X\nfldl Y\nfdivl X\nfstpl Y\nfldl E0\nfcompl Y\nfstsw %ax\nsahf\njne .LC569\nmovl $1,-1496(%ebp)\njmp .LC570\n.LC569:\nmovl $0,-1496(%ebp)\n.LC570:\nmovl -1496(%ebp),%edi\nmovl %edi,IEEE\n.LC564:\n.LC548:\n.LC549:\ncmpl $0,UfNGrad\nje .LC573\npushl $.LC45\ncall printf\naddl $4,%esp\nleal sigfpe,%edi\nmovl %edi,sigsave\npushl $ovfl_buf\ncall __setjmp\naddl $4,%esp\ncmpl $0,%eax\nje .LC575\npushl $.LC577\ncall printf\naddl $4,%esp\nfldl H\nfaddl H\nfstpl R\njmp .LC576\n.LC575:\nfldl Underflow\nfdivl UfThold\nsubl $8,%esp\nfstpl (%esp)\ncall sqrt\naddl $8,%esp\nfstpl -1460(%ebp)\nfldl -1460(%ebp)\nfstpl R\n.LC576:\nmovl $0,sigsave\nfldl H\nfcompl R\nfstsw %ax\nsahf\njb .LC578\nfldl R\nfmull UfThold\nfstpl Z\nfldl Z\nfldl One\nfldl R\nfmull H\nfldl One\nfaddl H\nfmulp %st(1),%st\nfaddp %st(1),%st\nfmulp %st(1),%st\nfstpl X\njmp .LC579\n.LC578:\nfldl UfThold\nfstpl Z\nfldl Z\nfldl One\nfldl H\nfmull H\nfldl One\nfaddl H\nfmulp %st(1),%st\nfaddp %st(1),%st\nfmulp %st(1),%st\nfstpl X\n.LC579:\nfldl Z\nfcompl X\nfstsw %ax\nsahf\nje .LC580\nfldl X\nfsubl Z\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC580\npushl $.LC158\npushl $3\ncall BadCond\naddl $8,%esp\nfldl Z\nsubl $8,%esp\nfstpl (%esp)\nfldl X\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC582\ncall printf\naddl $20,%esp\nfldl X\nfsubl Z\nfstpl Z9\nfldl Z9\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC583\ncall printf\naddl $12,%esp\npushl $.LC584\ncall printf\naddl $4,%esp\npushl $.LC585\ncall printf\naddl $4,%esp\npushl $.LC586\ncall printf\naddl $4,%esp\npushl $.LC587\ncall printf\naddl $4,%esp\npushl $.LC588\ncall printf\naddl $4,%esp\npushl $.LC589\ncall printf\naddl $4,%esp\nleal sigfpe,%edi\nmovl %edi,sigsave\npushl $ovfl_buf\ncall __setjmp\naddl $4,%esp\ncmpl $0,%eax\nje .LC590\npushl $.LC592\ncall printf\naddl $4,%esp\njmp .LC591\n.LC590:\nfldl X\nfdivl Z\nfsubl Half\nfsubl Half\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC593\ncall printf\naddl $12,%esp\n.LC591:\nmovl $0,sigsave\n.LC580:\n.LC573:\npushl $.LC595\nfldl UfThold\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC594\ncall printf\naddl $16,%esp\npushl $.LC596\ncall printf\naddl $4,%esp\npushl $.LC597\ncall printf\naddl $4,%esp\nfldl U1\nfmull U1\nfstpl Y2\nfldl Y2\nfstpl -1468(%ebp)\nfldl -1468(%ebp)\nfmull -1468(%ebp)\nfstpl Y\nfldl Y\nfmull U1\nfstpl Y2\nfldl UfThold\nfcompl Y2\nfstsw %ax\nsahf\njb .LC598\nfldl E0\nfcompl Y\nfstsw %ax\nsahf\njae .LC600\npushl $.LC158\npushl $2\ncall BadCond\naddl $8,%esp\nmovl $5,I\njmp .LC601\n.LC600:\npushl $.LC158\npushl $1\ncall BadCond\naddl $8,%esp\nmovl $4,I\n.LC601:\npushl I\npushl $.LC602\ncall printf\naddl $8,%esp\n.LC598:\nmovl $130,Milestone\nfldl UfThold\nsubl $8,%esp\nfstpl (%esp)\ncall log\naddl $8,%esp\nfstpl -1476(%ebp)\nfldl HInvrse\nsubl $8,%esp\nfstpl (%esp)\ncall log\naddl $8,%esp\nfstpl -1484(%ebp)\nfldl Half\nfldl TwoForty\nfmull -1476(%ebp)\nfdivl -1484(%ebp)\nfsubp %st(1),%st\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -1492(%ebp)\nfldl -1492(%ebp)\nfchs\nfdivl TwoForty\nfstpl Y\nfldl Y\nfaddl Y\nfstpl Y2\npushl $.LC603\ncall printf\naddl $4,%esp\nfldl Y\nsubl $8,%esp\nfstpl (%esp)\nfldl HInvrse\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC604\ncall printf\naddl $20,%esp\nfldl Y\nsubl $8,%esp\nfstpl (%esp)\nfldl HInvrse\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC605\ncall printf\naddl $20,%esp\nfldl Y2\nsubl $8,%esp\nfstpl (%esp)\nfldl HInvrse\nsubl $8,%esp\nfstpl (%esp)\ncall pow\naddl $16,%esp\nfstpl -1508(%ebp)\nfldl -1508(%ebp)\nfstpl V9\nfldl V9\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC606\ncall printf\naddl $12,%esp\nfldl Zero\nfcompl V9\nfstsw %ax\nsahf\nja .LC609\nfldl Radix\nfaddl Radix\nfaddl E9\nfmull UfThold\nfcompl V9\nfstsw %ax\nsahf\njae .LC607\n.LC609:\npushl $.LC610\npushl $1\ncall BadCond\naddl $8,%esp\nfldl UfThold\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC611\ncall printf\naddl $12,%esp\njmp .LC608\n.LC607:\nfldl UfThold\nfldl One\nfaddl E9\nfmulp %st(1),%st\nfcompl V9\nfstsw %ax\nsahf\njb .LC612\npushl $.LC614\ncall printf\naddl $4,%esp\njmp .LC613\n.LC612:\npushl $.LC610\npushl $2\ncall BadCond\naddl $8,%esp\nfldl UfThold\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC611\ncall printf\naddl $12,%esp\n.LC613:\n.LC608:\nmovl $140,Milestone\npushl $.LC45\ncall printf\naddl $4,%esp\nfldl Zero\nfstpl X\nmovl $2,I\nfldl Two\nfmull Three\nfstpl Y\nfldl Zero\nfstpl Q\nmovl $0,N\n.LC615:\nfldl X\nfstpl Z\nincl I\nmovl I,%edi\nfldl Y\nleal (%edi,%edi),%edi\npushl %edi\nfildl (%esp)\naddl $4,%esp\nfdivp %st(1),%st\nfstpl Y\nfldl Y\nfaddl Q\nfstpl R\nfldl Z\nfstpl -1540(%ebp)\nfldl R\nfstpl -1548(%ebp)\nfldl -1540(%ebp)\nfaddl -1548(%ebp)\nfstpl X\nfldl -1540(%ebp)\nfsubl X\nfaddl -1548(%ebp)\nfstpl Q\n.LC616:\nfldl Z\nfcompl X\nfstsw %ax\nsahf\njb .LC615\nfldl OneAndHalf\nfldl One\nfdivl Eight\nfaddp %st(1),%st\nfldl X\nfldl OneAndHalf\nfmull ThirtyTwo\nfdivp %st(1),%st\nfaddp %st(1),%st\nfstpl Z\nfldl Z\nfstpl -1548(%ebp)\nfldl -1548(%ebp)\nfmull -1548(%ebp)\nfstpl X\nfldl X\nfstpl -1556(%ebp)\nfldl -1556(%ebp)\nfmull -1556(%ebp)\nfstpl Exp2\nfldl F9\nfstpl X\nfldl X\nfsubl U1\nfstpl Y\nfldl Exp2\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC618\ncall printf\naddl $12,%esp\nmovl $1,I\n.LC619:\nfldl X\nfsubl BInvrse\nfstpl Z\nfldl X\nfaddl One\nfldl Z\nfldl One\nfsubl BInvrse\nfsubp %st(1),%st\nfdivp %st(1),%st\nfstpl Z\nfldl Z\nsubl $8,%esp\nfstpl (%esp)\nfldl X\nsubl $8,%esp\nfstpl (%esp)\ncall pow\naddl $16,%esp\nfstpl -1588(%ebp)\nfldl -1588(%ebp)\nfsubl Exp2\nfstpl Q\nfldl Q\nsubl $8,%esp\nfstpl (%esp)\ncall fabs\naddl $8,%esp\nfstpl -1596(%ebp)\nfldl TwoForty\nfmull U2\nfcompl -1596(%ebp)\nfstsw %ax\nsahf\njae .LC623\nmovl $1,N\nfldl X\nfsubl BInvrse\nfldl One\nfsubl BInvrse\nfsubp %st(1),%st\nfstpl V9\npushl $.LC625\npushl $2\ncall BadCond\naddl $8,%esp\nfldl Z\nsubl $8,%esp\nfstpl (%esp)\nfldl X\nsubl $8,%esp\nfstpl (%esp)\ncall pow\naddl $16,%esp\nfstpl -1612(%ebp)\nfldl -1612(%ebp)\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC626\ncall printf\naddl $12,%esp\nfldl Z\nsubl $8,%esp\nfstpl (%esp)\nfldl V9\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC627\ncall printf\naddl $20,%esp\nfldl Q\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC628\ncall printf\naddl $12,%esp\npushl $.LC629\ncall printf\naddl $4,%esp\npushl $.LC630\ncall printf\naddl $4,%esp\njmp .LC621\n.LC623:\nfldl Y\nfstpl -1604(%ebp)\nfldl -1604(%ebp)\nfsubl X\nfmull Two\nfaddl -1604(%ebp)\nfstpl Z\nfldl -1604(%ebp)\nfstpl X\nfldl Z\nfstpl Y\nfldl X\nfsubl F9\nfstpl -1612(%ebp)\nfldl One\nfldl -1612(%ebp)\nfmull -1612(%ebp)\nfaddp %st(1),%st\nfstpl Z\nfldl One\nfcompl Z\nfstsw %ax\nsahf\njae .LC631\nmovl NoTrials,%edi\ncmpl %edi,I\njge .LC631\nincl I\njmp .LC619\n.LC631:\nfldl One\nfcompl X\nfstsw %ax\nsahf\njae .LC633\ncmpl $0,N\njne .LC621\npushl $.LC637\ncall printf\naddl $4,%esp\njmp .LC621\n.LC633:\nfldl One\nfaddl U2\nfstpl X\nfldl U2\nfaddl U2\nfstpl Y\nfldl Y\nfaddl X\nfstpl Y\nmovl $1,I\njmp .LC619\n.LC621:\nmovl $150,Milestone\npushl $.LC638\ncall printf\naddl $4,%esp\nmovl $0,N\nfldl A1\nfstpl Z\nfldl C\nsubl $8,%esp\nfstpl (%esp)\ncall log\naddl $8,%esp\nfstpl -1564(%ebp)\nfldl A1\nsubl $8,%esp\nfstpl (%esp)\ncall log\naddl $8,%esp\nfstpl -1572(%ebp)\nfldl Half\nfldl -1564(%ebp)\nfdivl -1572(%ebp)\nfsubp %st(1),%st\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -1580(%ebp)\nfldl -1580(%ebp)\nfstpl Q\nmovl $0,Break\n.LC639:\nfldl CInvrse\nfstpl X\nfldl Q\nsubl $8,%esp\nfstpl (%esp)\nfldl Z\nsubl $8,%esp\nfstpl (%esp)\ncall pow\naddl $16,%esp\nfstpl -1588(%ebp)\nfldl -1588(%ebp)\nfstpl Y\ncall IsYeqX\nfldl Q\nfchs\nfstpl Q\nfldl C\nfstpl X\nfldl Q\nsubl $8,%esp\nfstpl (%esp)\nfldl Z\nsubl $8,%esp\nfstpl (%esp)\ncall pow\naddl $16,%esp\nfstpl -1596(%ebp)\nfldl -1596(%ebp)\nfstpl Y\ncall IsYeqX\nfldl One\nfcompl Z\nfstsw %ax\nsahf\njbe .LC642\nmovl $1,Break\njmp .LC643\n.LC642:\nfldl AInvrse\nfstpl Z\n.LC643:\n.LC640:\ncmpl $0,Break\nje .LC639\ncall PrintIfNPositive\ncmpl $0,N\njne .LC644\npushl $.LC646\ncall printf\naddl $4,%esp\n.LC644:\npushl $.LC45\ncall printf\naddl $4,%esp\nmovl $160,Milestone\ncall Pause\npushl $.LC647\ncall printf\naddl $4,%esp\npushl $.LC648\ncall printf\naddl $4,%esp\nfldl CInvrse\nfchs\nfstpl Y\nfldl HInvrse\nfmull Y\nfstpl V9\nleal sigfpe,%edi\nmovl %edi,sigsave\npushl $ovfl_buf\ncall __setjmp\naddl $4,%esp\ncmpl $0,%eax\nje .LC649\nmovl $0,I\nfldl Y\nfstpl V9\njmp .LC651\n.LC649:\n.LC652:\nfldl Y\nfstpl V\nfldl V9\nfstpl Y\nfldl HInvrse\nfmull Y\nfstpl V9\n.LC653:\nfldl Y\nfcompl V9\nfstsw %ax\nsahf\nja .LC652\nmovl $1,I\n.LC651:\nmovl $0,sigsave\nfldl V9\nfstpl Z\npushl $.LC655\ncall printf\naddl $4,%esp\nfldl Y\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC656\ncall printf\naddl $12,%esp\nfldl Y\nfchs\nfstpl V9\nfldl V9\nfstpl V0\nfldl V\nfsubl Y\nfldl V\nfaddl V0\nfcompp\nfstsw %ax\nsahf\njne .LC657\npushl $.LC659\ncall printf\naddl $4,%esp\njmp .LC658\n.LC657:\npushl $.LC660\ncall printf\naddl $4,%esp\npushl $.LC661\npushl $3\ncall BadCond\naddl $8,%esp\n.LC658:\nfldl Y\nfcompl Z\nfstsw %ax\nsahf\nje .LC662\npushl $.LC158\npushl $1\ncall BadCond\naddl $8,%esp\nfldl Z\nsubl $8,%esp\nfstpl (%esp)\nfldl Y\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC664\ncall printf\naddl $20,%esp\n.LC662:\ncmpl $0,I\nje .LC665\nfldl V\nfldl HInvrse\nfmull U2\nfsubl HInvrse\nfmulp %st(1),%st\nfstpl Y\nfldl Y\nfldl One\nfsubl HInvrse\nfmull U2\nfmull V\nfaddp %st(1),%st\nfstpl Z\nfldl V0\nfcompl Z\nfstsw %ax\nsahf\njbe .LC667\nfldl Z\nfstpl Y\n.LC667:\nfldl V0\nfcompl Y\nfstsw %ax\nsahf\njbe .LC669\nfldl Y\nfstpl V\n.LC669:\nfldl V0\nfsubl V\nfldl V0\nfcompp\nfstsw %ax\nsahf\njbe .LC666\nfldl V0\nfstpl V\njmp .LC666\n.LC665:\nfldl Y\nfldl HInvrse\nfmull U2\nfsubl HInvrse\nfmulp %st(1),%st\nfstpl V\nfldl V\nfldl One\nfsubl HInvrse\nfmull U2\nfmull Y\nfaddp %st(1),%st\nfstpl V\n.LC666:\nfldl V\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC673\ncall printf\naddl $12,%esp\ncmpl $0,I\nje .LC674\nfldl V0\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC676\ncall printf\naddl $12,%esp\njmp .LC675\n.LC674:\npushl $.LC677\ncall printf\naddl $4,%esp\n.LC675:\nfldl V\nfmull One\nfstpl V9\nfldl V9\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC678\ncall printf\naddl $12,%esp\nfldl V\nfdivl One\nfstpl V9\nfldl V9\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC679\ncall printf\naddl $12,%esp\npushl $.LC680\ncall printf\naddl $4,%esp\npushl $.LC681\ncall printf\naddl $4,%esp\nmovl $170,Milestone\nfldl V\nfchs\nfldl V\nfcompp\nfstsw %ax\nsahf\njbe .LC686\nfldl V0\nfchs\nfldl V0\nfcompp\nfstsw %ax\nsahf\njbe .LC686\nfldl UfThold\nfchs\nfldl V\nfcompp\nfstsw %ax\nsahf\njbe .LC686\nfldl V\nfcompl UfThold\nfstsw %ax\nsahf\nja .LC682\n.LC686:\npushl $.LC687\npushl $0\ncall BadCond\naddl $8,%esp\nfldl UfThold\nsubl $8,%esp\nfstpl (%esp)\nfldl V0\nsubl $8,%esp\nfstpl (%esp)\nfldl V\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC688\ncall printf\naddl $28,%esp\n.LC682:\nmovl $175,Milestone\npushl $.LC45\ncall printf\naddl $4,%esp\nmovl $1,Indx\n.LC689:\nmovl Indx,%edi\ncmpl $1,%edi\nje .LC695\ncmpl $2,%edi\nje .LC696\ncmpl $3,%edi\nje .LC697\njmp .LC693\n.LC695:\nfldl UfThold\nfstpl Z\njmp .LC694\n.LC696:\nfldl E0\nfstpl Z\njmp .LC694\n.LC697:\nfldl PseudoZero\nfstpl Z\n.LC693:\n.LC694:\nfldl Zero\nfcompl Z\nfstsw %ax\nsahf\nje .LC698\nfldl Z\nsubl $8,%esp\nfstpl (%esp)\ncall sqrt\naddl $8,%esp\nfstpl -1628(%ebp)\nfldl -1628(%ebp)\nfstpl V9\nfldl V9\nfmull V9\nfstpl Y\nfldl Radix\nfmull E9\nfstpl -1660(%ebp)\nfldl Y\nfldl One\nfsubl -1660(%ebp)\nfdivp %st(1),%st\nfldl Z\nfcompp\nfstsw %ax\nsahf\nja .LC702\nfldl One\nfaddl -1660(%ebp)\nfmull Z\nfcompl Y\nfstsw %ax\nsahf\njae .LC700\n.LC702:\nfldl U1\nfcompl V9\nfstsw %ax\nsahf\njae .LC703\npushl $.LC158\npushl $1\ncall BadCond\naddl $8,%esp\njmp .LC704\n.LC703:\npushl $.LC158\npushl $2\ncall BadCond\naddl $8,%esp\n.LC704:\nfldl Z\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC705\ncall printf\naddl $12,%esp\nfldl Y\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC706\ncall printf\naddl $12,%esp\n.LC700:\n.LC698:\n.LC690:\nincl Indx\ncmpl $3,Indx\njle .LC689\nmovl $180,Milestone\nmovl $1,Indx\n.LC707:\ncmpl $1,Indx\njne .LC711\nfldl V\nfstpl Z\njmp .LC712\n.LC711:\nfldl V0\nfstpl Z\n.LC712:\nfldl Z\nsubl $8,%esp\nfstpl (%esp)\ncall sqrt\naddl $8,%esp\nfstpl -1628(%ebp)\nfldl -1628(%ebp)\nfstpl V9\nfldl V9\nfstpl -1636(%ebp)\nfldl One\nfldl Radix\nfmull E9\nfsubp %st(1),%st\nfmull -1636(%ebp)\nfstpl X\nfldl -1636(%ebp)\nfmull X\nfstpl V9\nfldl One\nfldl Two\nfmull Radix\nfmull E9\nfsubp %st(1),%st\nfmull Z\nfcompl V9\nfstsw %ax\nsahf\nja .LC715\nfldl Z\nfcompl V9\nfstsw %ax\nsahf\njae .LC713\n.LC715:\nfldl V9\nfstpl Y\nfldl W\nfcompl X\nfstsw %ax\nsahf\njbe .LC716\npushl $.LC158\npushl $1\ncall BadCond\naddl $8,%esp\njmp .LC717\n.LC716:\npushl $.LC158\npushl $2\ncall BadCond\naddl $8,%esp\n.LC717:\nfldl Z\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC718\ncall printf\naddl $12,%esp\nfldl Y\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC719\ncall printf\naddl $12,%esp\n.LC713:\n.LC708:\nincl Indx\ncmpl $2,Indx\njle .LC707\nmovl $190,Milestone\ncall Pause\nfldl UfThold\nfmull V\nfstpl X\nfldl Radix\nfmull Radix\nfstpl Y\nfldl X\nfmull Y\nfldl One\nfcompp\nfstsw %ax\nsahf\nja .LC722\nfldl Y\nfcompl X\nfstsw %ax\nsahf\njae .LC720\n.LC722:\nfldl X\nfmull Y\nfldl U1\nfcompp\nfstsw %ax\nsahf\nja .LC725\nfldl Y\nfdivl U1\nfcompl X\nfstsw %ax\nsahf\njae .LC723\n.LC725:\npushl $.LC726\npushl $2\ncall BadCond\naddl $8,%esp\njmp .LC724\n.LC723:\npushl $.LC158\npushl $3\ncall BadCond\naddl $8,%esp\n.LC724:\npushl $.LC728\nfldl X\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC727\ncall printf\naddl $16,%esp\n.LC720:\nmovl $200,Milestone\nmovl $1,Indx\n.LC729:\nfldl F9\nfstpl X\nmovl Indx,%edi\ncmpl $2,%edi\njl .LC733\ncmpl $5,%edi\njg .LC733\njmp *.LC739-8(,%edi,4)\n.data\n.align 4\n.LC739:\n.long .LC735\n.long .LC736\n.long .LC737\n.long .LC738\n.text\n.LC735:\nfldl One\nfaddl U2\nfstpl X\njmp .LC734\n.LC736:\nfldl V\nfstpl X\njmp .LC734\n.LC737:\nfldl UfThold\nfstpl X\njmp .LC734\n.LC738:\nfldl Radix\nfstpl X\n.LC733:\n.LC734:\nfldl X\nfstpl Y\nleal sigfpe,%edi\nmovl %edi,sigsave\npushl $ovfl_buf\ncall __setjmp\naddl $4,%esp\ncmpl $0,%eax\nje .LC741\nfldl X\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC743\ncall printf\naddl $12,%esp\njmp .LC742\n.LC741:\nfldl Y\nfdivl X\nfsubl Half\nfsubl Half\nfstpl V9\nfldl Zero\nfcompl V9\nfstsw %ax\nsahf\njne .LC744\njmp .LC730\n.LC744:\nfldl U1\nfchs\nfcompl V9\nfstsw %ax\nsahf\njne .LC746\ncmpl $5,Indx\njge .LC746\npushl $.LC158\npushl $3\ncall BadCond\naddl $8,%esp\njmp .LC747\n.LC746:\npushl $.LC158\npushl $1\ncall BadCond\naddl $8,%esp\n.LC747:\nfldl X\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC748\ncall printf\naddl $12,%esp\nfldl V9\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC749\ncall printf\naddl $12,%esp\n.LC742:\nmovl $0,sigsave\n.LC730:\nincl Indx\ncmpl $5,Indx\njle .LC729\nmovl $210,Milestone\nfldl Zero\nfstpl MyZero\npushl $.LC45\ncall printf\naddl $4,%esp\npushl $.LC750\ncall printf\naddl $4,%esp\nleal sigfpe,%edi\nmovl %edi,sigsave\npushl $.LC751\ncall printf\naddl $4,%esp\npushl $ovfl_buf\ncall __setjmp\naddl $4,%esp\ncmpl $0,%eax\njne .LC752\nfldl One\nfdivl MyZero\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC754\ncall printf\naddl $12,%esp\n.LC752:\nmovl $0,sigsave\nleal sigfpe,%edi\nmovl %edi,sigsave\npushl $.LC755\ncall printf\naddl $4,%esp\npushl $ovfl_buf\ncall __setjmp\naddl $4,%esp\ncmpl $0,%eax\njne .LC756\nfldl Zero\nfdivl MyZero\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC754\ncall printf\naddl $12,%esp\n.LC756:\nmovl $0,sigsave\nmovl $220,Milestone\ncall Pause\npushl $.LC45\ncall printf\naddl $4,%esp\nmovl $0,-1648(%ebp)\n.LC763:\nmovl -1648(%ebp),%edi\ncmpl $0,ErrCnt(,%edi,4)\nje .LC767\nmovl -1648(%ebp),%edi\nleal (,%edi,4),%edi\npushl ErrCnt(%edi)\npushl msg.758(%edi)\npushl $.LC769\ncall printf\naddl $12,%esp\n.LC767:\n.LC764:\nincl -1648(%ebp)\ncmpl $4,-1648(%ebp)\njl .LC763\npushl $.LC45\ncall printf\naddl $4,%esp\nmovl ErrCnt,%edi\nmovl ErrCnt+4,%esi\nleal (%esi,%edi),%edi\nmovl ErrCnt+8,%esi\nleal (%esi,%edi),%edi\nmovl ErrCnt+12,%esi\nleal (%esi,%edi),%edi\ncmpl $0,%edi\njle .LC770\nmovl ErrCnt,%edi\nmovl ErrCnt+4,%esi\nleal (%esi,%edi),%edi\nmovl ErrCnt+8,%esi\nleal (%esi,%edi),%edi\ncmpl $0,%edi\njne .LC775\ncmpl $0,ErrCnt+12\njle .LC775\npushl $.LC780\ncall printf\naddl $4,%esp\npushl $.LC781\ncall printf\naddl $4,%esp\n.LC775:\nmovl ErrCnt,%edi\nmovl ErrCnt+4,%esi\nleal (%esi,%edi),%edi\ncmpl $0,%edi\njne .LC782\ncmpl $0,ErrCnt+8\njle .LC782\npushl $.LC786\ncall printf\naddl $4,%esp\npushl $.LC787\ncall printf\naddl $4,%esp\n.LC782:\nmovl ErrCnt,%edi\nmovl ErrCnt+4,%esi\nleal (%esi,%edi),%edi\ncmpl $0,%edi\njle .LC788\npushl $.LC791\ncall printf\naddl $4,%esp\npushl $.LC792\ncall printf\naddl $4,%esp\n.LC788:\ncmpl $0,ErrCnt\njle .LC771\npushl $.LC795\ncall printf\naddl $4,%esp\npushl $.LC796\ncall printf\naddl $4,%esp\njmp .LC771\n.LC770:\npushl $.LC797\ncall printf\naddl $4,%esp\ncmpl $1,RMult\njne .LC802\ncmpl $1,RDiv\njne .LC802\ncmpl $1,RAddSub\njne .LC802\ncmpl $1,RSqrt\nje .LC798\n.LC802:\npushl $.LC803\ncall printf\naddl $4,%esp\njmp .LC799\n.LC798:\nfldl One\nfcompl StickyBit\nfstsw %ax\nsahf\nja .LC804\nfldl Radix\nfsubl Two\nfldl Radix\nfsubl Nine\nfsubl One\nfmulp %st(1),%st\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC804\npushl $.LC806\ncall printf\naddl $4,%esp\npushl $.LC807\ncall printf\naddl $4,%esp\nfldl Two\nfcompl Radix\nfstsw %ax\nsahf\njne .LC808\nfldl Precision\nfldl Four\nfmull Three\nfmull Two\nfsubp %st(1),%st\nfldl Precision\nfsubl TwentySeven\nfsubl TwentySeven\nfaddl One\nfmulp %st(1),%st\nfldl Zero\nfcompp\nfstsw %ax\nsahf\njne .LC808\npushl $.LC810\ncall printf\naddl $4,%esp\njmp .LC809\n.LC808:\npushl $.LC811\ncall printf\naddl $4,%esp\n.LC809:\ncmpl $0,IEEE\nje .LC812\npushl $.LC814\ncall printf\naddl $4,%esp\njmp .LC813\n.LC812:\npushl $.LC815\ncall printf\naddl $4,%esp\npushl $.LC816\ncall printf\naddl $4,%esp\n.LC813:\n.LC804:\npushl $.LC817\ncall printf\naddl $4,%esp\n.LC799:\n.LC771:\ncmpl $0,fpecount\nje .LC818\npushl fpecount\npushl $.LC820\ncall printf\naddl $8,%esp\n.LC818:\npushl $.LC821\ncall printf\naddl $4,%esp\nmovl $0,%eax\n.LC7:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf822:\n.size main,.Lf822-main\n.globl Sign\n.align 16\n.type Sign,@function\nSign:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $8,%esp\nfldl .LC8\nfcompl 20(%ebp)\nfstsw %ax\nsahf\nja .LC825\nfldl .LC9\nfstpl -8(%ebp)\njmp .LC826\n.LC825:\nfldl .LC827\nfstpl -8(%ebp)\n.LC826:\nfldl -8(%ebp)\n.LC823:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf828:\n.size Sign,.Lf828-Sign\n.globl Pause\n.align 16\n.type Pause,@function\nPause:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\npushl Milestone\npushl $.LC830\ncall printf\naddl $8,%esp\npushl PageNo\npushl $.LC831\ncall printf\naddl $8,%esp\nincl Milestone\nincl PageNo\nmovl $0,%eax\n.LC829:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf832:\n.size Pause,.Lf832-Pause\n.globl TstCond\n.align 16\n.type TstCond,@function\nTstCond:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\ncmpl $0,24(%ebp)\njne .LC834\npushl 28(%ebp)\npushl 20(%ebp)\ncall BadCond\naddl $8,%esp\npushl $.LC814\ncall printf\naddl $4,%esp\n.LC834:\nmovl $0,%eax\n.LC833:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf836:\n.size TstCond,.Lf836-TstCond\n.data\n.align 4\n.type msg.838,@object\nmsg.838:\n.long .LC839\n.long .LC840\n.long .LC841\n.long .LC842\n.size msg.838,16\n.globl BadCond\n.text\n.align 16\n.type BadCond,@function\nBadCond:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl 20(%ebp),%edi\nleal ErrCnt(,%edi,4),%edi\nincl (,%edi)\npushl 24(%ebp)\nmovl 20(%ebp),%edi\npushl msg.838(,%edi,4)\npushl $.LC843\ncall printf\naddl $12,%esp\nmovl $0,%eax\n.LC837:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf844:\n.size BadCond,.Lf844-BadCond\n.globl Random\n.align 16\n.type Random,@function\nRandom:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $48,%esp\nfldl Random1\nfaddl Random9\nfstpl -8(%ebp)\nfldl -8(%ebp)\nfmull -8(%ebp)\nfstpl -16(%ebp)\nfldl -16(%ebp)\nfmull -16(%ebp)\nfstpl -16(%ebp)\nfldl -8(%ebp)\nfmull -16(%ebp)\nfstpl -8(%ebp)\nfldl -8(%ebp)\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -48(%ebp)\nfldl -8(%ebp)\nfsubl -48(%ebp)\nfstpl -16(%ebp)\nfldl -16(%ebp)\nfldl .LC846\nfmull -8(%ebp)\nfaddp %st(1),%st\nfstpl Random1\nfldl Random1\n.LC845:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf847:\n.size Random,.Lf847-Random\n.globl SqXMinX\n.align 16\n.type SqXMinX,@function\nSqXMinX:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $40,%esp\nfldl X\nfmull BInvrse\nfstpl -8(%ebp)\nfldl X\nfsubl -8(%ebp)\nfstpl -16(%ebp)\nfldl X\nfmull X\nsubl $8,%esp\nfstpl (%esp)\ncall sqrt\naddl $8,%esp\nfstpl -32(%ebp)\nfldl -32(%ebp)\nfsubl -8(%ebp)\nfsubl -16(%ebp)\nfdivl OneUlp\nfstpl SqEr\nfldl Zero\nfcompl SqEr\nfstsw %ax\nsahf\nje .LC849\nfldl MinSqEr\nfcompl SqEr\nfstsw %ax\nsahf\njbe .LC851\nfldl SqEr\nfstpl MinSqEr\n.LC851:\nfldl MaxSqEr\nfcompl SqEr\nfstsw %ax\nsahf\njae .LC853\nfldl SqEr\nfstpl MaxSqEr\n.LC853:\nfldl J\nfaddl .LC9\nfstpl J\npushl $.LC45\npushl 20(%ebp)\ncall BadCond\naddl $8,%esp\nfldl OneUlp\nfmull SqEr\nsubl $8,%esp\nfstpl (%esp)\nfldl X\nsubl $8,%esp\nfstpl (%esp)\nfldl X\nfmull X\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC855\ncall printf\naddl $28,%esp\npushl $.LC856\ncall printf\naddl $4,%esp\n.LC849:\nmovl $0,%eax\n.LC848:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf857:\n.size SqXMinX,.Lf857-SqXMinX\n.globl NewD\n.align 16\n.type NewD,@function\nNewD:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $40,%esp\nfldl Z1\nfmull Q\nfstpl X\nfldl Half\nfldl X\nfdivl Radix\nfsubp %st(1),%st\nsubl $8,%esp\nfstpl (%esp)\ncall floor\naddl $8,%esp\nfstpl -8(%ebp)\nfldl -8(%ebp)\nfmull Radix\nfaddl X\nfstpl X\nfldl X\nfstpl -24(%ebp)\nfldl Z\nfstpl -32(%ebp)\nfldl Q\nfldl -24(%ebp)\nfmull -32(%ebp)\nfsubp %st(1),%st\nfdivl Radix\nfldl -24(%ebp)\nfmull -24(%ebp)\nfldl D\nfdivl Radix\nfmulp %st(1),%st\nfaddp %st(1),%st\nfstpl Q\nfldl -32(%ebp)\nfldl Two\nfmull -24(%ebp)\nfmull D\nfsubp %st(1),%st\nfstpl Z\nfldl Zero\nfcompl Z\nfstsw %ax\nsahf\njb .LC859\nfldl Z\nfchs\nfstpl Z\nfldl Z1\nfchs\nfstpl Z1\n.LC859:\nfldl Radix\nfmull D\nfstpl D\nmovl $0,%eax\n.LC858:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf861:\n.size NewD,.Lf861-NewD\n.globl SR3750\n.align 16\n.type SR3750,@function\nSR3750:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $64,%esp\nfldl X\nfsubl Radix\nfldl Z2\nfsubl Radix\nfcompp\nfstsw %ax\nsahf\nja .LC863\nfldl X\nfsubl Z2\nfldl W\nfsubl Z2\nfcompp\nfstsw %ax\nsahf\njb .LC863\nincl I\nfldl X\nfmull D\nsubl $8,%esp\nfstpl (%esp)\ncall sqrt\naddl $8,%esp\nfstpl -32(%ebp)\nfldl -32(%ebp)\nfstpl X2\nfldl X2\nfsubl Z2\nfldl Y\nfsubl Z2\nfsubp %st(1),%st\nfstpl Y2\nfldl X8\nfldl Y\nfsubl Half\nfdivp %st(1),%st\nfstpl X2\nfldl X2\nfstpl -64(%ebp)\nfldl -64(%ebp)\nfldl Half\nfmull -64(%ebp)\nfmull -64(%ebp)\nfsubp %st(1),%st\nfstpl X2\nfldl Y2\nfaddl Half\nfldl Half\nfsubl X2\nfaddp %st(1),%st\nfstpl SqEr\nfldl MinSqEr\nfcompl SqEr\nfstsw %ax\nsahf\njbe .LC865\nfldl SqEr\nfstpl MinSqEr\n.LC865:\nfldl Y2\nfsubl X2\nfstpl SqEr\nfldl MaxSqEr\nfcompl SqEr\nfstsw %ax\nsahf\njae .LC867\nfldl SqEr\nfstpl MaxSqEr\n.LC867:\n.LC863:\nmovl $0,%eax\n.LC862:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf869:\n.size SR3750,.Lf869-SR3750\n.globl IsYeqX\n.align 16\n.type IsYeqX,@function\nIsYeqX:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $8,%esp\nfldl X\nfcompl Y\nfstsw %ax\nsahf\nje .LC871\ncmpl $0,N\njg .LC873\nfldl Zero\nfcompl Z\nfstsw %ax\nsahf\njne .LC875\nfldl Zero\nfcompl Q\nfstsw %ax\nsahf\njb .LC875\npushl $.LC877\ncall printf\naddl $4,%esp\njmp .LC876\n.LC875:\npushl $.LC878\npushl $2\ncall BadCond\naddl $8,%esp\n.LC876:\nfldl Q\nsubl $8,%esp\nfstpl (%esp)\nfldl Z\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC879\ncall printf\naddl $20,%esp\nfldl Y\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC880\ncall printf\naddl $12,%esp\nfldl X\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC881\ncall printf\naddl $12,%esp\nfldl Y\nfsubl X\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC882\ncall printf\naddl $12,%esp\n.LC873:\nincl N\n.LC871:\nmovl $0,%eax\n.LC870:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf883:\n.size IsYeqX,.Lf883-IsYeqX\n.globl SR3980\n.align 16\n.type SR3980,@function\nSR3980:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $8,%esp\n.LC885:\nfildl I\nfstpl Q\nfldl Q\nsubl $8,%esp\nfstpl (%esp)\nfldl Z\nsubl $8,%esp\nfstpl (%esp)\ncall pow\naddl $16,%esp\nfstpl -8(%ebp)\nfldl -8(%ebp)\nfstpl Y\ncall IsYeqX\nmovl I,%edi\nleal 1(%edi),%edi\nmovl %edi,I\ncmpl M,%edi\njle .LC888\njmp .LC887\n.LC888:\nfldl Z\nfmull X\nfstpl X\n.LC886:\nfldl W\nfcompl X\nfstsw %ax\nsahf\nja .LC885\n.LC887:\nmovl $0,%eax\n.LC884:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf890:\n.size SR3980,.Lf890-SR3980\n.globl PrintIfNPositive\n.align 16\n.type PrintIfNPositive,@function\nPrintIfNPositive:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\ncmpl $0,N\njle .LC892\npushl N\npushl $.LC894\ncall printf\naddl $8,%esp\n.LC892:\nmovl $0,%eax\n.LC891:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf895:\n.size PrintIfNPositive,.Lf895-PrintIfNPositive\n.globl TstPtUf\n.align 16\n.type TstPtUf,@function\nTstPtUf:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $48,%esp\nmovl $0,N\nfldl Zero\nfcompl Z\nfstsw %ax\nsahf\nje .LC897\npushl $.LC899\ncall printf\naddl $4,%esp\npushl $.LC900\ncall printf\naddl $4,%esp\nleal sigfpe,%edi\nmovl %edi,sigsave\npushl $ovfl_buf\ncall __setjmp\naddl $4,%esp\ncmpl $0,%eax\nje .LC901\njmp .LC903\n.LC901:\nfldl Z\nfaddl Z\nfdivl Z\nfstpl Q9\nfldl Q9\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC904\ncall printf\naddl $12,%esp\nfldl Q9\nfsubl Two\nsubl $8,%esp\nfstpl (%esp)\ncall fabs\naddl $8,%esp\nfstpl -16(%ebp)\nfldl Radix\nfmull U2\nfcompl -16(%ebp)\nfstsw %ax\nsahf\njbe .LC905\npushl $.LC907\ncall printf\naddl $4,%esp\npushl $.LC908\ncall printf\naddl $4,%esp\njmp .LC906\n.LC905:\nfldl One\nfcompl Q9\nfstsw %ax\nsahf\nja .LC911\nfldl Two\nfcompl Q9\nfstsw %ax\nsahf\njae .LC909\n.LC911:\n.LC903:\nmovl $1,N\nmovl ErrCnt+4,%edi\nleal 1(%edi),%edi\nmovl %edi,ErrCnt+4\npushl $.LC914\ncall printf\naddl $4,%esp\njmp .LC910\n.LC909:\nmovl $1,N\nmovl ErrCnt+8,%edi\nleal 1(%edi),%edi\nmovl %edi,ErrCnt+8\npushl $.LC917\ncall printf\naddl $4,%esp\n.LC910:\n.LC906:\nmovl $0,sigsave\nfldl Z\nfmull One\nfstpl V9\nfldl V9\nfstpl Random1\nfldl One\nfmull Z\nfstpl V9\nfldl V9\nfstpl Random2\nfldl Z\nfdivl One\nfstpl V9\nfldl Random1\nfcompl Z\nfstsw %ax\nsahf\njne .LC918\nfldl Random2\nfcompl Z\nfstsw %ax\nsahf\njne .LC918\nfldl V9\nfcompl Z\nfstsw %ax\nsahf\njne .LC918\ncmpl $0,N\njle .LC919\ncall Pause\njmp .LC919\n.LC918:\nmovl $1,N\npushl $.LC922\npushl $2\ncall BadCond\naddl $8,%esp\nfldl Z\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC923\ncall printf\naddl $12,%esp\nfldl Random1\nfcompl Z\nfstsw %ax\nsahf\nje .LC924\nfldl Random1\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC926\ncall printf\naddl $12,%esp\n.LC924:\nfldl Random2\nfcompl Z\nfstsw %ax\nsahf\nje .LC927\nfldl Random1\nfcompl Random2\nfstsw %ax\nsahf\nje .LC927\nfldl Random2\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC929\ncall printf\naddl $12,%esp\n.LC927:\nfldl V9\nfcompl Z\nfstsw %ax\nsahf\nje .LC930\nfldl V9\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC932\ncall printf\naddl $12,%esp\n.LC930:\nfldl Random1\nfcompl Random2\nfstsw %ax\nsahf\nje .LC933\nmovl ErrCnt+8,%edi\nleal 1(%edi),%edi\nmovl %edi,ErrCnt+8\npushl $.LC937\npushl $2\ncall BadCond\naddl $8,%esp\nfldl Random2\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC938\ncall printf\naddl $12,%esp\nfldl Random1\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC939\ncall printf\naddl $12,%esp\n.LC933:\ncall Pause\n.LC919:\n.LC897:\nmovl $0,%eax\n.LC896:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf940:\n.size TstPtUf,.Lf940-TstPtUf\n.globl notify\n.align 16\n.type notify,@function\nnotify:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\npushl 20(%ebp)\npushl $.LC942\ncall printf\naddl $8,%esp\npushl $.LC943\ncall printf\naddl $4,%esp\nmovl $0,%eax\n.LC941:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf944:\n.size notify,.Lf944-notify\n.globl msglist\n.align 16\n.type msglist,@function\nmsglist:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\njmp .LC947\n.LC946:\nmovl 20(%ebp),%edi\nleal 4(%edi),%esi\nmovl %esi,20(%ebp)\npushl (,%edi)\npushl $.LC949\ncall printf\naddl $8,%esp\n.LC947:\nmovl 20(%ebp),%edi\nmovl (,%edi),%edi\ncmpl $0,%edi\njne .LC946\nmovl $0,%eax\n.LC945:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf950:\n.size msglist,.Lf950-msglist\n.data\n.align 4\n.type instr.952,@object\ninstr.952:\n.long .LC953\n.long .LC954\n.long .LC955\n.long .LC956\n.long .LC957\n.long .LC958\n.long .LC959\n.long .LC960\n.long .LC961\n.long 0\n.size instr.952,40\n.globl Instructions\n.text\n.align 16\n.type Instructions,@function\nInstructions:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\npushl $instr.952\ncall msglist\naddl $4,%esp\nmovl $0,%eax\n.LC951:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf962:\n.size Instructions,.Lf962-Instructions\n.data\n.align 4\n.type head.964,@object\nhead.964:\n.long .LC965\n.long .LC966\n.long .LC967\n.long .LC968\n.long .LC969\n.long .LC970\n.long .LC971\n.long .LC972\n.long .LC973\n.long .LC974\n.long .LC975\n.long .LC976\n.long .LC977\n.long .LC978\n.long 0\n.size head.964,60\n.globl Heading\n.text\n.align 16\n.type Heading,@function\nHeading:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\npushl $head.964\ncall msglist\naddl $4,%esp\nmovl $0,%eax\n.LC963:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf979:\n.size Heading,.Lf979-Heading\n.data\n.align 4\n.type chars.981,@object\nchars.981:\n.long .LC982\n.long .LC983\n.long .LC984\n.long .LC985\n.long .LC986\n.long .LC987\n.long .LC988\n.long .LC989\n.long .LC990\n.long .LC991\n.long .LC992\n.long .LC993\n.long .LC994\n.long .LC995\n.long .LC996\n.long .LC997\n.long .LC998\n.long .LC999\n.long .LC1000\n.long 0\n.size chars.981,80\n.globl Characteristics\n.text\n.align 16\n.type Characteristics,@function\nCharacteristics:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\npushl $chars.981\ncall msglist\naddl $4,%esp\nmovl $0,%eax\n.LC980:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf1001:\n.size Characteristics,.Lf1001-Characteristics\n.data\n.align 4\n.type hist.1003,@object\nhist.1003:\n.long .LC1004\n.long .LC1005\n.long .LC1006\n.long .LC1007\n.long .LC1008\n.long .LC1009\n.long .LC1010\n.long .LC1011\n.long .LC1012\n.long .LC1013\n.long .LC1014\n.long .LC1015\n.long .LC1016\n.long .LC1017\n.long .LC1018\n.long .LC1019\n.long .LC1020\n.long 0\n.size hist.1003,72\n.globl History\n.text\n.align 16\n.type History,@function\nHistory:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\npushl $hist.1003\ncall msglist\naddl $4,%esp\nmovl $0,%eax\n.LC1002:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf1021:\n.size History,.Lf1021-History\n.globl pow\n.align 16\n.type pow,@function\npow:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $96,%esp\nmovl $0,-20(%ebp)\nmovl $0,-24(%ebp)\nfldl .LC8\nfcompl 28(%ebp)\nfstsw %ax\nsahf\njne .LC1023\nfldl .LC9\njmp .LC1022\n.LC1023:\nfldl .LC1028\nfcompl 28(%ebp)\nfstsw %ax\nsahf\nja .LC1027\nfldl .LC1029\nfcompl 28(%ebp)\nfstsw %ax\nsahf\njae .LC1025\n.LC1027:\nfldl .LC827\nfcompl 20(%ebp)\nfstsw %ax\nsahf\nje .LC1025\nfldl 20(%ebp)\nsubl $8,%esp\nfstpl (%esp)\ncall log\naddl $8,%esp\nfstpl -48(%ebp)\nfldl 28(%ebp)\nfmull -48(%ebp)\nsubl $8,%esp\nfstpl (%esp)\ncall exp\naddl $8,%esp\nfstpl -56(%ebp)\nfldl -56(%ebp)\njmp .LC1022\n.LC1025:\nfldl .LC8\nfcompl 28(%ebp)\nfstsw %ax\nsahf\njbe .LC1030\nfldl 28(%ebp)\nfchs\nfstpl 28(%ebp)\nmovl $1,-24(%ebp)\n.LC1030:\nleal -32(%ebp),%edi\npushl %edi\nfldl 28(%ebp)\nsubl $8,%esp\nfstpl (%esp)\ncall modf\naddl $12,%esp\nfstpl -64(%ebp)\nfldl -64(%ebp)\nfstpl 28(%ebp)\nfldl .LC8\nfcompl 28(%ebp)\nfstsw %ax\nsahf\nje .LC1032\nfldl 20(%ebp)\nsubl $8,%esp\nfstpl (%esp)\ncall log\naddl $8,%esp\nfstpl -72(%ebp)\nfldl 28(%ebp)\nfmull -72(%ebp)\nsubl $8,%esp\nfstpl (%esp)\ncall exp\naddl $8,%esp\nfstpl -80(%ebp)\nfldl -80(%ebp)\nfstpl -16(%ebp)\njmp .LC1033\n.LC1032:\nfldl .LC9\nfstpl -16(%ebp)\n.LC1033:\nleal -8(%ebp),%edi\npushl %edi\nfldl 20(%ebp)\nsubl $8,%esp\nfstpl (%esp)\ncall frexp\naddl $12,%esp\nfstpl -88(%ebp)\nfldl -88(%ebp)\nfstpl 20(%ebp)\nfldl -32(%ebp)\nsubl $4,%esp\nfistpl 0(%esp)\npopl %eax\nmovl %eax,-4(%ebp)\ncmpl $0,%eax\nje .LC1034\n.LC1036:\nmovl -4(%ebp),%edi\nandl $1,%edi\ncmpl $0,%edi\nje .LC1040\nfldl -16(%ebp)\nfmull 20(%ebp)\nfstpl -16(%ebp)\nmovl -8(%ebp),%edi\naddl %edi,-20(%ebp)\n.LC1040:\nmovl -4(%ebp),%edi\nsarl $1,%edi\nmovl %edi,-4(%ebp)\ncmpl $0,%edi\njne .LC1042\njmp .LC1038\n.LC1042:\nfldl 20(%ebp)\nfmull 20(%ebp)\nfstpl 20(%ebp)\nsall $1,-8(%ebp)\nfldl .LC1046\nfcompl 20(%ebp)\nfstsw %ax\nsahf\njbe .LC1036\nfldl .LC1047\nfmull 20(%ebp)\nfstpl 20(%ebp)\ndecl -8(%ebp)\njmp .LC1036\n.LC1038:\n.LC1034:\ncmpl $0,-24(%ebp)\nje .LC1048\nfldl .LC9\nfdivl -16(%ebp)\nfstpl -16(%ebp)\nnegl -20(%ebp)\n.LC1048:\npushl -20(%ebp)\nfldl -16(%ebp)\nsubl $8,%esp\nfstpl (%esp)\ncall ldexp\naddl $12,%esp\nfstpl -96(%ebp)\nfldl -96(%ebp)\n.LC1022:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf1050:\n.size pow,.Lf1050-pow\n.bss\n.globl UfNGrad\n.align 4\n.type UfNGrad,@object\n.size UfNGrad,4\n.comm UfNGrad,4\n.globl SqRWrng\n.align 4\n.type SqRWrng,@object\n.size SqRWrng,4\n.comm SqRWrng,4\n.globl IEEE\n.align 4\n.type IEEE,@object\n.size IEEE,4\n.comm IEEE,4\n.globl Anomaly\n.align 4\n.type Anomaly,@object\n.size Anomaly,4\n.comm Anomaly,4\n.globl Monot\n.align 4\n.type Monot,@object\n.size Monot,4\n.comm Monot,4\n.globl NotMonot\n.align 4\n.type NotMonot,@object\n.size NotMonot,4\n.comm NotMonot,4\n.globl Done\n.align 4\n.type Done,@object\n.size Done,4\n.comm Done,4\n.globl Break\n.align 4\n.type Break,@object\n.size Break,4\n.comm Break,4\n.globl RSqrt\n.align 4\n.type RSqrt,@object\n.size RSqrt,4\n.comm RSqrt,4\n.globl RAddSub\n.align 4\n.type RAddSub,@object\n.size RAddSub,4\n.comm RAddSub,4\n.globl RDiv\n.align 4\n.type RDiv,@object\n.size RDiv,4\n.comm RDiv,4\n.globl RMult\n.align 4\n.type RMult,@object\n.size RMult,4\n.comm RMult,4\n.globl GAddSub\n.align 4\n.type GAddSub,@object\n.size GAddSub,4\n.comm GAddSub,4\n.globl GDiv\n.align 4\n.type GDiv,@object\n.size GDiv,4\n.comm GDiv,4\n.globl GMult\n.align 4\n.type GMult,@object\n.size GMult,4\n.comm GMult,4\n.globl N1\n.align 4\n.type N1,@object\n.size N1,4\n.comm N1,4\n.globl N\n.align 4\n.type N,@object\n.size N,4\n.comm N,4\n.globl M\n.align 4\n.type M,@object\n.size M,4\n.comm M,4\n.globl PageNo\n.align 4\n.type PageNo,@object\n.size PageNo,4\n.comm PageNo,4\n.globl Milestone\n.align 4\n.type Milestone,@object\n.size Milestone,4\n.comm Milestone,4\n.globl fpecount\n.align 4\n.type fpecount,@object\n.size fpecount,4\n.comm fpecount,4\n.globl ErrCnt\n.align 4\n.type ErrCnt,@object\n.size ErrCnt,16\n.comm ErrCnt,16\n.globl Z9\n.align 4\n.type Z9,@object\n.size Z9,8\n.comm Z9,8\n.globl Z2\n.align 4\n.type Z2,@object\n.size Z2,8\n.comm Z2,8\n.globl Z1\n.align 4\n.type Z1,@object\n.size Z1,8\n.comm Z1,8\n.globl PseudoZero\n.align 4\n.type PseudoZero,@object\n.size PseudoZero,8\n.comm PseudoZero,8\n.globl Z\n.align 4\n.type Z,@object\n.size Z,8\n.comm Z,8\n.globl Random2\n.align 4\n.type Random2,@object\n.size Random2,8\n.comm Random2,8\n.globl Y2\n.align 4\n.type Y2,@object\n.size Y2,8\n.comm Y2,8\n.globl Y1\n.align 4\n.type Y1,@object\n.size Y1,8\n.comm Y1,8\n.globl Y\n.align 4\n.type Y,@object\n.size Y,8\n.comm Y,8\n.globl Random1\n.align 4\n.type Random1,@object\n.size Random1,8\n.comm Random1,8\n.globl X8\n.align 4\n.type X8,@object\n.size X8,8\n.comm X8,8\n.globl X2\n.align 4\n.type X2,@object\n.size X2,8\n.comm X2,8\n.globl X1\n.align 4\n.type X1,@object\n.size X1,8\n.comm X1,8\n.globl X\n.align 4\n.type X,@object\n.size X,8\n.comm X,8\n.globl W\n.align 4\n.type W,@object\n.size W,8\n.comm W,8\n.globl V9\n.align 4\n.type V9,@object\n.size V9,8\n.comm V9,8\n.globl V0\n.align 4\n.type V0,@object\n.size V0,8\n.comm V0,8\n.globl V\n.align 4\n.type V,@object\n.size V,8\n.comm V,8\n.globl U2\n.align 4\n.type U2,@object\n.size U2,8\n.comm U2,8\n.globl U1\n.align 4\n.type U1,@object\n.size U1,8\n.comm U1,8\n.globl UfThold\n.align 4\n.type UfThold,@object\n.size UfThold,8\n.comm UfThold,8\n.globl OneUlp\n.align 4\n.type OneUlp,@object\n.size OneUlp,8\n.comm OneUlp,8\n.globl S\n.align 4\n.type S,@object\n.size S,8\n.comm S,8\n.globl Underflow\n.align 4\n.type Underflow,@object\n.size Underflow,8\n.comm Underflow,8\n.globl T\n.align 4\n.type T,@object\n.size T,8\n.comm T,8\n.globl Random9\n.align 4\n.type Random9,@object\n.size Random9,8\n.comm Random9,8\n.globl R\n.align 4\n.type R,@object\n.size R,8\n.comm R,8\n.globl Q9\n.align 4\n.type Q9,@object\n.size Q9,8\n.comm Q9,8\n.globl Q\n.align 4\n.type Q,@object\n.size Q,8\n.comm Q,8\n.globl Precision\n.align 4\n.type Precision,@object\n.size Precision,8\n.comm Precision,8\n.globl MyZero\n.align 4\n.type MyZero,@object\n.size MyZero,8\n.comm MyZero,8\n.globl J\n.align 4\n.type J,@object\n.size J,8\n.comm J,8\n.globl StickyBit\n.align 4\n.type StickyBit,@object\n.size StickyBit,8\n.comm StickyBit,8\n.globl I\n.align 4\n.type I,@object\n.size I,4\n.comm I,4\n.globl HInvrse\n.align 4\n.type HInvrse,@object\n.size HInvrse,8\n.comm HInvrse,8\n.globl H\n.align 4\n.type H,@object\n.size H,8\n.comm H,8\n.globl F9\n.align 4\n.type F9,@object\n.size F9,8\n.comm F9,8\n.globl F6\n.align 4\n.type F6,@object\n.size F6,8\n.comm F6,8\n.globl Third\n.align 4\n.type Third,@object\n.size Third,8\n.comm Third,8\n.globl E9\n.align 4\n.type E9,@object\n.size E9,8\n.comm E9,8\n.globl MaxSqEr\n.align 4\n.type MaxSqEr,@object\n.size MaxSqEr,8\n.comm MaxSqEr,8\n.globl SqEr\n.align 4\n.type SqEr,@object\n.size SqEr,8\n.comm SqEr,8\n.globl MinSqEr\n.align 4\n.type MinSqEr,@object\n.size MinSqEr,8\n.comm MinSqEr,8\n.globl E3\n.align 4\n.type E3,@object\n.size E3,8\n.comm E3,8\n.globl Exp2\n.align 4\n.type Exp2,@object\n.size Exp2,8\n.comm Exp2,8\n.globl E1\n.align 4\n.type E1,@object\n.size E1,8\n.comm E1,8\n.globl E0\n.align 4\n.type E0,@object\n.size E0,8\n.comm E0,8\n.globl FourD\n.align 4\n.type FourD,@object\n.size FourD,8\n.comm FourD,8\n.globl D\n.align 4\n.type D,@object\n.size D,8\n.comm D,8\n.globl CInvrse\n.align 4\n.type CInvrse,@object\n.size CInvrse,8\n.comm CInvrse,8\n.globl C\n.align 4\n.type C,@object\n.size C,8\n.comm C,8\n.globl A1\n.align 4\n.type A1,@object\n.size A1,8\n.comm A1,8\n.globl AInvrse\n.align 4\n.type AInvrse,@object\n.size AInvrse,8\n.comm AInvrse,8\n.globl ch\n.align 1\n.type ch,@object\n.size ch,8\n.comm ch,8\n.globl Indx\n.align 4\n.type Indx,@object\n.size Indx,4\n.comm Indx,4\n.globl BMinusU2\n.align 4\n.type BMinusU2,@object\n.size BMinusU2,8\n.comm BMinusU2,8\n.globl RadixD2\n.align 4\n.type RadixD2,@object\n.size RadixD2,8\n.comm RadixD2,8\n.globl BInvrse\n.align 4\n.type BInvrse,@object\n.size BInvrse,8\n.comm BInvrse,8\n.globl Radix\n.align 4\n.type Radix,@object\n.size Radix,8\n.comm Radix,8\n.globl sigsave\n.align 4\n.type sigsave,@object\n.size sigsave,4\n.comm sigsave,4\n.globl ovfl_buf\n.align 4\n.type ovfl_buf,@object\n.size ovfl_buf,24\n.comm ovfl_buf,24\n.data\n.align 4\n.LC1047:\n.long 0\n.long 1073741824\n.align 4\n.LC1046:\n.long 0\n.long 1071644672\n.align 4\n.LC1029:\n.long 0\n.long 1083256832\n.align 4\n.LC1028:\n.long 0\n.long -1064226816\n.align 1\n.LC1020:\n.byte 115\n.byte 101\n.byte 101\n.byte 32\n.byte 115\n.byte 111\n.byte 117\n.byte 114\n.byte 99\n.byte 101\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 109\n.byte 111\n.byte 114\n.byte 101\n.byte 32\n.byte 104\n.byte 105\n.byte 115\n.byte 116\n.byte 111\n.byte 114\n.byte 121\n.byte 46\n.byte 0\n.align 1\n.LC1019:\n.byte 66\n.byte 65\n.byte 83\n.byte 73\n.byte 67\n.byte 32\n.byte 118\n.byte 101\n.byte 114\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 40\n.byte 67\n.byte 41\n.byte 32\n.byte 49\n.byte 57\n.byte 56\n.byte 51\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 80\n.byte 114\n.byte 111\n.byte 102\n.byte 46\n.byte 32\n.byte 87\n.byte 46\n.byte 32\n.byte 77\n.byte 46\n.byte 32\n.byte 75\n.byte 97\n.byte 104\n.byte 97\n.byte 110\n.byte 59\n.byte 0\n.align 1\n.LC1018:\n.byte 97\n.byte 115\n.byte 32\n.byte 117\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 99\n.byte 101\n.byte 114\n.byte 116\n.byte 97\n.byte 105\n.byte 110\n.byte 32\n.byte 101\n.byte 97\n.byte 114\n.byte 108\n.byte 121\n.byte 32\n.byte 87\n.byte 65\n.byte 78\n.byte 71\n.byte 32\n.byte 109\n.byte 97\n.byte 99\n.byte 104\n.byte 105\n.byte 110\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC1017:\n.byte 102\n.byte 108\n.byte 111\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 45\n.byte 112\n.byte 111\n.byte 105\n.byte 110\n.byte 116\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 115\n.byte 44\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 32\n.byte 97\n.byte 108\n.byte 115\n.byte 111\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 111\n.byte 119\n.byte 115\n.byte 32\n.byte 108\n.byte 111\n.byte 103\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 105\n.byte 99\n.byte 32\n.byte 101\n.byte 110\n.byte 99\n.byte 111\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 0\n.align 1\n.LC1016:\n.byte 10\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 98\n.byte 97\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 117\n.byte 112\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 118\n.byte 101\n.byte 110\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 114\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 114\n.byte 101\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 101\n.byte 110\n.byte 116\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 0\n.align 1\n.LC1015:\n.byte 111\n.byte 102\n.byte 32\n.byte 112\n.byte 97\n.byte 116\n.byte 104\n.byte 111\n.byte 108\n.byte 111\n.byte 103\n.byte 105\n.byte 101\n.byte 115\n.byte 44\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 115\n.byte 97\n.byte 121\n.byte 32\n.byte 104\n.byte 111\n.byte 119\n.byte 32\n.byte 119\n.byte 101\n.byte 108\n.byte 108\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 109\n.byte 112\n.byte 108\n.byte 101\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 0\n.align 1\n.LC1014:\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 44\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 116\n.byte 114\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 112\n.byte 101\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 97\n.byte 32\n.byte 119\n.byte 105\n.byte 100\n.byte 101\n.byte 114\n.byte 32\n.byte 118\n.byte 97\n.byte 114\n.byte 105\n.byte 101\n.byte 116\n.byte 121\n.byte 0\n.align 1\n.LC1013:\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 44\n.byte 32\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 114\n.byte 97\n.byte 110\n.byte 103\n.byte 101\n.byte 32\n.byte 40\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 47\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 115\n.byte 41\n.byte 0\n.align 1\n.LC1012:\n.byte 87\n.byte 46\n.byte 32\n.byte 74\n.byte 46\n.byte 32\n.byte 67\n.byte 111\n.byte 100\n.byte 121\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 87\n.byte 46\n.byte 32\n.byte 87\n.byte 97\n.byte 105\n.byte 116\n.byte 101\n.byte 46\n.byte 32\n.byte 65\n.byte 108\n.byte 116\n.byte 104\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 32\n.byte 98\n.byte 111\n.byte 116\n.byte 104\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 115\n.byte 32\n.byte 116\n.byte 114\n.byte 121\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 0\n.align 1\n.LC1011:\n.byte 98\n.byte 111\n.byte 111\n.byte 107\n.byte 32\n.byte 32\n.byte 96\n.byte 83\n.byte 111\n.byte 102\n.byte 116\n.byte 119\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 77\n.byte 97\n.byte 110\n.byte 117\n.byte 97\n.byte 108\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 69\n.byte 108\n.byte 101\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 97\n.byte 114\n.byte 121\n.byte 32\n.byte 70\n.byte 117\n.byte 110\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 39\n.byte 32\n.byte 40\n.byte 49\n.byte 57\n.byte 56\n.byte 48\n.byte 41\n.byte 32\n.byte 98\n.byte 121\n.byte 0\n.align 1\n.LC1010:\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 99\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 100\n.byte 32\n.byte 96\n.byte 77\n.byte 65\n.byte 67\n.byte 72\n.byte 65\n.byte 82\n.byte 39\n.byte 44\n.byte 32\n.byte 119\n.byte 104\n.byte 105\n.byte 99\n.byte 104\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 101\n.byte 110\n.byte 100\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 0\n.align 1\n.LC1009:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 99\n.byte 97\n.byte 112\n.byte 97\n.byte 98\n.byte 105\n.byte 108\n.byte 105\n.byte 116\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 103\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 121\n.byte 111\n.byte 110\n.byte 100\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 101\n.byte 97\n.byte 114\n.byte 108\n.byte 105\n.byte 101\n.byte 114\n.byte 0\n.align 1\n.LC1008:\n.byte 70\n.byte 97\n.byte 105\n.byte 108\n.byte 117\n.byte 114\n.byte 101\n.byte 115\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 115\n.byte 101\n.byte 113\n.byte 117\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC1007:\n.byte 32\n.byte 32\n.byte 32\n.byte 70\n.byte 65\n.byte 73\n.byte 76\n.byte 85\n.byte 82\n.byte 69\n.byte 115\n.byte 44\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 32\n.byte 50\n.byte 43\n.byte 50\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 53\n.byte 32\n.byte 46\n.byte 0\n.align 1\n.LC1006:\n.byte 32\n.byte 32\n.byte 32\n.byte 83\n.byte 101\n.byte 114\n.byte 105\n.byte 111\n.byte 117\n.byte 115\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 115\n.byte 44\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 97\n.byte 32\n.byte 103\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 44\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 0\n.align 1\n.LC1005:\n.byte 32\n.byte 32\n.byte 32\n.byte 70\n.byte 76\n.byte 65\n.byte 87\n.byte 115\n.byte 44\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 97\n.byte 32\n.byte 115\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 121\n.byte 32\n.byte 98\n.byte 105\n.byte 116\n.byte 44\n.byte 0\n.align 1\n.LC1004:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 97\n.byte 116\n.byte 116\n.byte 101\n.byte 109\n.byte 112\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 114\n.byte 105\n.byte 109\n.byte 105\n.byte 110\n.byte 97\n.byte 116\n.byte 101\n.byte 32\n.byte 97\n.byte 109\n.byte 111\n.byte 110\n.byte 103\n.byte 0\n.align 1\n.LC1000:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 68\n.byte 101\n.byte 99\n.byte 105\n.byte 109\n.byte 97\n.byte 108\n.byte 45\n.byte 66\n.byte 105\n.byte 110\n.byte 97\n.byte 114\n.byte 121\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 118\n.byte 101\n.byte 114\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 32\n.byte 89\n.byte 69\n.byte 84\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 97\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 97\n.byte 99\n.byte 121\n.byte 46\n.byte 0\n.align 1\n.LC999:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 69\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 45\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 101\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 101\n.byte 120\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 101\n.byte 118\n.byte 101\n.byte 97\n.byte 108\n.byte 101\n.byte 100\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 32\n.byte 89\n.byte 69\n.byte 84\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 0\n.align 1\n.LC998:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 83\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 32\n.byte 32\n.byte 89\n.byte 94\n.byte 88\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 0\n.align 1\n.LC997:\n.byte 9\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 116\n.byte 97\n.byte 109\n.byte 105\n.byte 110\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 112\n.byte 115\n.byte 101\n.byte 117\n.byte 100\n.byte 111\n.byte 45\n.byte 122\n.byte 101\n.byte 114\n.byte 111\n.byte 115\n.byte 46\n.byte 0\n.align 1\n.LC996:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 99\n.byte 104\n.byte 101\n.byte 99\n.byte 107\n.byte 101\n.byte 100\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 115\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 110\n.byte 99\n.byte 121\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 1\n.LC995:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 86\n.byte 48\n.byte 32\n.byte 32\n.byte 116\n.byte 101\n.byte 108\n.byte 108\n.byte 115\n.byte 44\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 108\n.byte 121\n.byte 44\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 32\n.byte 73\n.byte 110\n.byte 102\n.byte 105\n.byte 110\n.byte 105\n.byte 116\n.byte 121\n.byte 32\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 114\n.byte 101\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 101\n.byte 110\n.byte 116\n.byte 101\n.byte 100\n.byte 46\n.byte 0\n.align 1\n.LC994:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 86\n.byte 32\n.byte 61\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 44\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 108\n.byte 121\n.byte 46\n.byte 0\n.align 1\n.LC993:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 69\n.byte 48\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 80\n.byte 115\n.byte 101\n.byte 117\n.byte 100\n.byte 111\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 116\n.byte 101\n.byte 108\n.byte 108\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 98\n.byte 114\n.byte 117\n.byte 112\n.byte 116\n.byte 44\n.byte 32\n.byte 103\n.byte 114\n.byte 97\n.byte 100\n.byte 117\n.byte 97\n.byte 108\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 102\n.byte 117\n.byte 122\n.byte 122\n.byte 121\n.byte 46\n.byte 0\n.align 1\n.LC992:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 84\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 61\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 46\n.byte 0\n.align 1\n.LC991:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 87\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 97\n.byte 32\n.byte 83\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 121\n.byte 32\n.byte 66\n.byte 105\n.byte 116\n.byte 32\n.byte 117\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 46\n.byte 0\n.align 1\n.LC990:\n.byte 9\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 46\n.byte 44\n.byte 32\n.byte 68\n.byte 105\n.byte 118\n.byte 46\n.byte 44\n.byte 32\n.byte 65\n.byte 100\n.byte 100\n.byte 47\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 46\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 83\n.byte 113\n.byte 114\n.byte 116\n.byte 46\n.byte 0\n.align 1\n.LC989:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 87\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 44\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 115\n.byte 111\n.byte 109\n.byte 101\n.byte 116\n.byte 104\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 0\n.align 1\n.LC988:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 65\n.byte 100\n.byte 101\n.byte 113\n.byte 117\n.byte 97\n.byte 99\n.byte 121\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 103\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 46\n.byte 44\n.byte 32\n.byte 68\n.byte 105\n.byte 118\n.byte 46\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 46\n.byte 0\n.align 1\n.LC987:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 85\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 49\n.byte 47\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 94\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 61\n.byte 32\n.byte 79\n.byte 110\n.byte 101\n.byte 32\n.byte 85\n.byte 108\n.byte 112\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 108\n.byte 105\n.byte 116\n.byte 116\n.byte 108\n.byte 101\n.byte 32\n.byte 108\n.byte 101\n.byte 115\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 110\n.byte 32\n.byte 49\n.byte 46\n.byte 48\n.byte 32\n.byte 46\n.byte 0\n.align 1\n.LC986:\n.byte 9\n.byte 40\n.byte 79\n.byte 110\n.byte 101\n.byte 85\n.byte 108\n.byte 112\n.byte 110\n.byte 105\n.byte 116\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 76\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 80\n.byte 108\n.byte 97\n.byte 99\n.byte 101\n.byte 41\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 49\n.byte 46\n.byte 48\n.byte 48\n.byte 48\n.byte 120\n.byte 120\n.byte 120\n.byte 32\n.byte 46\n.byte 0\n.align 1\n.LC985:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 85\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 47\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 94\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 61\n.byte 32\n.byte 79\n.byte 110\n.byte 101\n.byte 32\n.byte 85\n.byte 108\n.byte 112\n.byte 0\n.align 1\n.LC984:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 61\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 105\n.byte 102\n.byte 105\n.byte 99\n.byte 97\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 99\n.byte 97\n.byte 114\n.byte 114\n.byte 105\n.byte 101\n.byte 100\n.byte 46\n.byte 0\n.align 1\n.LC983:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 49\n.byte 44\n.byte 32\n.byte 50\n.byte 44\n.byte 32\n.byte 52\n.byte 44\n.byte 32\n.byte 56\n.byte 44\n.byte 32\n.byte 49\n.byte 48\n.byte 44\n.byte 32\n.byte 49\n.byte 54\n.byte 44\n.byte 32\n.byte 49\n.byte 48\n.byte 48\n.byte 44\n.byte 32\n.byte 50\n.byte 53\n.byte 54\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 0\n.align 1\n.LC982:\n.byte 82\n.byte 117\n.byte 110\n.byte 110\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 114\n.byte 101\n.byte 118\n.byte 101\n.byte 97\n.byte 108\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 115\n.byte 101\n.byte 32\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 101\n.byte 114\n.byte 105\n.byte 115\n.byte 116\n.byte 105\n.byte 99\n.byte 115\n.byte 58\n.byte 0\n.align 1\n.LC978:\n.byte 9\n.byte 79\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 114\n.byte 101\n.byte 108\n.byte 101\n.byte 118\n.byte 97\n.byte 110\n.byte 116\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 105\n.byte 108\n.byte 101\n.byte 114\n.byte 32\n.byte 111\n.byte 112\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 58\n.byte 0\n.align 1\n.LC977:\n.byte 9\n.byte 79\n.byte 112\n.byte 116\n.byte 105\n.byte 109\n.byte 105\n.byte 122\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 108\n.byte 101\n.byte 118\n.byte 101\n.byte 108\n.byte 58\n.byte 10\n.byte 0\n.align 1\n.LC976:\n.byte 9\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 105\n.byte 108\n.byte 101\n.byte 114\n.byte 58\n.byte 10\n.byte 0\n.align 1\n.LC975:\n.byte 9\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 114\n.byte 58\n.byte 10\n.byte 0\n.align 1\n.LC974:\n.byte 9\n.byte 86\n.byte 101\n.byte 114\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 58\n.byte 9\n.byte 49\n.byte 48\n.byte 32\n.byte 70\n.byte 101\n.byte 98\n.byte 114\n.byte 117\n.byte 97\n.byte 114\n.byte 121\n.byte 32\n.byte 49\n.byte 57\n.byte 56\n.byte 57\n.byte 59\n.byte 0\n.align 1\n.LC973:\n.byte 9\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 58\n.byte 9\n.byte 100\n.byte 111\n.byte 117\n.byte 98\n.byte 108\n.byte 101\n.byte 59\n.byte 0\n.align 1\n.LC972:\n.byte 73\n.byte 110\n.byte 32\n.byte 100\n.byte 111\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 115\n.byte 111\n.byte 44\n.byte 32\n.byte 112\n.byte 108\n.byte 101\n.byte 97\n.byte 115\n.byte 101\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 108\n.byte 117\n.byte 100\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 102\n.byte 111\n.byte 108\n.byte 108\n.byte 111\n.byte 119\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 105\n.byte 110\n.byte 102\n.byte 111\n.byte 114\n.byte 109\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 58\n.byte 0\n.align 1\n.LC971:\n.byte 9\n.byte 83\n.byte 97\n.byte 110\n.byte 32\n.byte 70\n.byte 114\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 44\n.byte 32\n.byte 67\n.byte 65\n.byte 32\n.byte 57\n.byte 52\n.byte 49\n.byte 52\n.byte 51\n.byte 45\n.byte 48\n.byte 55\n.byte 48\n.byte 52\n.byte 44\n.byte 32\n.byte 85\n.byte 83\n.byte 65\n.byte 10\n.byte 0\n.align 1\n.LC970:\n.byte 9\n.byte 85\n.byte 110\n.byte 105\n.byte 118\n.byte 101\n.byte 114\n.byte 115\n.byte 105\n.byte 116\n.byte 121\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 67\n.byte 97\n.byte 108\n.byte 105\n.byte 102\n.byte 111\n.byte 114\n.byte 110\n.byte 105\n.byte 97\n.byte 0\n.align 1\n.LC969:\n.byte 9\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 67\n.byte 101\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 85\n.byte 45\n.byte 55\n.byte 54\n.byte 0\n.align 1\n.LC968:\n.byte 9\n.byte 82\n.byte 105\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 75\n.byte 97\n.byte 114\n.byte 112\n.byte 105\n.byte 110\n.byte 115\n.byte 107\n.byte 105\n.byte 0\n.align 1\n.LC967:\n.byte 80\n.byte 108\n.byte 101\n.byte 97\n.byte 115\n.byte 101\n.byte 32\n.byte 115\n.byte 101\n.byte 110\n.byte 100\n.byte 32\n.byte 115\n.byte 117\n.byte 103\n.byte 103\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 114\n.byte 101\n.byte 115\n.byte 117\n.byte 108\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 0\n.align 1\n.LC966:\n.byte 99\n.byte 111\n.byte 112\n.byte 101\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 117\n.byte 110\n.byte 97\n.byte 110\n.byte 116\n.byte 105\n.byte 99\n.byte 105\n.byte 112\n.byte 97\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 110\n.byte 101\n.byte 119\n.byte 108\n.byte 121\n.byte 32\n.byte 117\n.byte 110\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 112\n.byte 97\n.byte 116\n.byte 104\n.byte 111\n.byte 108\n.byte 111\n.byte 103\n.byte 105\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC965:\n.byte 85\n.byte 115\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 105\n.byte 110\n.byte 118\n.byte 105\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 104\n.byte 101\n.byte 108\n.byte 112\n.byte 32\n.byte 100\n.byte 101\n.byte 98\n.byte 117\n.byte 103\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 97\n.byte 117\n.byte 103\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 115\n.byte 111\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 119\n.byte 105\n.byte 108\n.byte 108\n.byte 0\n.align 1\n.LC961:\n.byte 65\n.byte 110\n.byte 115\n.byte 119\n.byte 101\n.byte 114\n.byte 32\n.byte 113\n.byte 117\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 89\n.byte 44\n.byte 32\n.byte 121\n.byte 44\n.byte 32\n.byte 78\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 110\n.byte 32\n.byte 40\n.byte 117\n.byte 110\n.byte 108\n.byte 101\n.byte 115\n.byte 115\n.byte 32\n.byte 111\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 119\n.byte 105\n.byte 115\n.byte 101\n.byte 32\n.byte 105\n.byte 110\n.byte 100\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 101\n.byte 100\n.byte 41\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC960:\n.byte 97\n.byte 109\n.byte 101\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 107\n.byte 101\n.byte 32\n.byte 102\n.byte 117\n.byte 114\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC959:\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 97\n.byte 110\n.byte 121\n.byte 119\n.byte 97\n.byte 121\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 115\n.byte 101\n.byte 101\n.byte 32\n.byte 104\n.byte 111\n.byte 119\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 109\n.byte 105\n.byte 108\n.byte 101\n.byte 115\n.byte 116\n.byte 111\n.byte 110\n.byte 101\n.byte 115\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 112\n.byte 97\n.byte 115\n.byte 115\n.byte 101\n.byte 115\n.byte 44\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 110\n.byte 0\n.align 1\n.LC958:\n.byte 119\n.byte 97\n.byte 114\n.byte 110\n.byte 105\n.byte 110\n.byte 103\n.byte 46\n.byte 32\n.byte 32\n.byte 73\n.byte 102\n.byte 32\n.byte 112\n.byte 101\n.byte 114\n.byte 115\n.byte 117\n.byte 97\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 118\n.byte 97\n.byte 105\n.byte 108\n.byte 115\n.byte 32\n.byte 110\n.byte 97\n.byte 117\n.byte 103\n.byte 104\n.byte 116\n.byte 44\n.byte 32\n.byte 100\n.byte 111\n.byte 110\n.byte 39\n.byte 116\n.byte 32\n.byte 100\n.byte 101\n.byte 115\n.byte 112\n.byte 97\n.byte 105\n.byte 114\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 32\n.byte 114\n.byte 117\n.byte 110\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 0\n.align 1\n.LC957:\n.byte 116\n.byte 111\n.byte 32\n.byte 112\n.byte 101\n.byte 114\n.byte 115\n.byte 101\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 97\n.byte 32\n.byte 115\n.byte 117\n.byte 114\n.byte 114\n.byte 111\n.byte 103\n.byte 97\n.byte 116\n.byte 101\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 97\n.byte 102\n.byte 116\n.byte 101\n.byte 114\n.byte 44\n.byte 32\n.byte 112\n.byte 101\n.byte 114\n.byte 104\n.byte 97\n.byte 112\n.byte 115\n.byte 44\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 112\n.byte 108\n.byte 97\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 115\n.byte 111\n.byte 109\n.byte 101\n.byte 0\n.align 1\n.LC956:\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 32\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 47\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 111\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 115\n.byte 44\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 32\n.byte 114\n.byte 97\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 0\n.align 1\n.LC955:\n.byte 116\n.byte 114\n.byte 121\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 112\n.byte 101\n.byte 114\n.byte 115\n.byte 117\n.byte 97\n.byte 100\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 116\n.byte 101\n.byte 114\n.byte 109\n.byte 105\n.byte 110\n.byte 97\n.byte 116\n.byte 101\n.byte 32\n.byte 101\n.byte 120\n.byte 101\n.byte 99\n.byte 117\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 110\n.byte 32\n.byte 97\n.byte 110\n.byte 0\n.align 1\n.LC954:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 96\n.byte 69\n.byte 78\n.byte 68\n.byte 32\n.byte 79\n.byte 70\n.byte 32\n.byte 84\n.byte 69\n.byte 83\n.byte 84\n.byte 39\n.byte 44\n.byte 10\n.byte 0\n.align 1\n.LC953:\n.byte 76\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 115\n.byte 116\n.byte 111\n.byte 112\n.byte 32\n.byte 112\n.byte 114\n.byte 101\n.byte 109\n.byte 97\n.byte 116\n.byte 117\n.byte 114\n.byte 101\n.byte 108\n.byte 121\n.byte 44\n.byte 32\n.byte 105\n.byte 46\n.byte 101\n.byte 46\n.byte 32\n.byte 98\n.byte 101\n.byte 102\n.byte 111\n.byte 114\n.byte 101\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 112\n.byte 108\n.byte 97\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 10\n.byte 0\n.align 1\n.LC949:\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.LC943:\n.byte 32\n.byte 32\n.byte 32\n.byte 80\n.byte 76\n.byte 69\n.byte 65\n.byte 83\n.byte 69\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 73\n.byte 70\n.byte 89\n.byte 32\n.byte 75\n.byte 65\n.byte 82\n.byte 80\n.byte 73\n.byte 78\n.byte 75\n.byte 83\n.byte 73\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.LC942:\n.byte 37\n.byte 115\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 111\n.byte 110\n.byte 115\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 110\n.byte 116\n.byte 46\n.byte 46\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC939:\n.byte 9\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 90\n.byte 32\n.byte 42\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC938:\n.byte 9\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 49\n.byte 32\n.byte 42\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC937:\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 100\n.byte 111\n.byte 101\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 109\n.byte 117\n.byte 116\n.byte 101\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.LC932:\n.byte 90\n.byte 32\n.byte 47\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC929:\n.byte 49\n.byte 32\n.byte 42\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 37\n.byte 103\n.byte 10\n.byte 0\n.align 1\n.LC926:\n.byte 90\n.byte 32\n.byte 42\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 0\n.align 1\n.LC923:\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 9\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 101\n.byte 115\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 32\n.byte 0\n.align 1\n.LC922:\n.byte 87\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 0\n.align 1\n.LC917:\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.LC914:\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 86\n.byte 69\n.byte 82\n.byte 89\n.byte 32\n.byte 83\n.byte 69\n.byte 82\n.byte 73\n.byte 79\n.byte 85\n.byte 83\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.LC908:\n.byte 32\n.byte 104\n.byte 97\n.byte 115\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 32\n.byte 106\n.byte 117\n.byte 115\n.byte 116\n.byte 32\n.byte 98\n.byte 101\n.byte 101\n.byte 110\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 97\n.byte 108\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC907:\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 79\n.byte 46\n.byte 75\n.byte 46\n.byte 44\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 118\n.byte 105\n.byte 100\n.byte 101\n.byte 100\n.byte 32\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 47\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 0\n.align 1\n.LC904:\n.byte 87\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 109\n.byte 97\n.byte 99\n.byte 104\n.byte 105\n.byte 110\n.byte 101\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 40\n.byte 90\n.byte 32\n.byte 43\n.byte 32\n.byte 90\n.byte 41\n.byte 32\n.byte 47\n.byte 32\n.byte 90\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC900:\n.byte 40\n.byte 90\n.byte 32\n.byte 43\n.byte 32\n.byte 90\n.byte 41\n.byte 32\n.byte 47\n.byte 32\n.byte 90\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 115\n.byte 97\n.byte 102\n.byte 101\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC899:\n.byte 83\n.byte 105\n.byte 110\n.byte 99\n.byte 101\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 100\n.byte 101\n.byte 110\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 101\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 0\n.align 1\n.LC894:\n.byte 83\n.byte 105\n.byte 109\n.byte 105\n.byte 108\n.byte 97\n.byte 114\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 114\n.byte 101\n.byte 112\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 104\n.byte 97\n.byte 118\n.byte 101\n.byte 32\n.byte 111\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 116\n.byte 105\n.byte 109\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC882:\n.byte 9\n.byte 9\n.byte 116\n.byte 104\n.byte 101\n.byte 121\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC881:\n.byte 9\n.byte 119\n.byte 104\n.byte 105\n.byte 99\n.byte 104\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 117\n.byte 110\n.byte 101\n.byte 113\n.byte 117\n.byte 97\n.byte 108\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 59\n.byte 10\n.byte 0\n.align 1\n.LC880:\n.byte 9\n.byte 121\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 101\n.byte 100\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 59\n.byte 10\n.byte 0\n.align 1\n.LC879:\n.byte 9\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 10\n.byte 0\n.align 1\n.LC878:\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 10\n.byte 0\n.align 1\n.LC877:\n.byte 87\n.byte 65\n.byte 82\n.byte 78\n.byte 73\n.byte 78\n.byte 71\n.byte 58\n.byte 32\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 10\n.byte 0\n.align 1\n.LC856:\n.byte 9\n.byte 105\n.byte 110\n.byte 115\n.byte 116\n.byte 101\n.byte 97\n.byte 100\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 48\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC855:\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 40\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 45\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 4\n.LC846:\n.long -1998362383\n.long 1054144693\n.align 1\n.LC843:\n.byte 37\n.byte 115\n.byte 58\n.byte 32\n.byte 32\n.byte 37\n.byte 115\n.byte 0\n.align 1\n.LC842:\n.byte 70\n.byte 76\n.byte 65\n.byte 87\n.byte 0\n.align 1\n.LC841:\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 0\n.align 1\n.LC840:\n.byte 83\n.byte 69\n.byte 82\n.byte 73\n.byte 79\n.byte 85\n.byte 83\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 0\n.align 1\n.LC839:\n.byte 70\n.byte 65\n.byte 73\n.byte 76\n.byte 85\n.byte 82\n.byte 69\n.byte 0\n.align 1\n.LC831:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 80\n.byte 97\n.byte 103\n.byte 101\n.byte 58\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 10\n.byte 0\n.align 1\n.LC830:\n.byte 10\n.byte 68\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 105\n.byte 115\n.byte 32\n.byte 114\n.byte 101\n.byte 115\n.byte 117\n.byte 109\n.byte 101\n.byte 115\n.byte 32\n.byte 97\n.byte 102\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 109\n.byte 105\n.byte 108\n.byte 101\n.byte 115\n.byte 116\n.byte 111\n.byte 110\n.byte 101\n.byte 32\n.byte 78\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 37\n.byte 100\n.byte 0\n.align 4\n.LC827:\n.long 0\n.long -1074790400\n.align 1\n.LC821:\n.byte 69\n.byte 78\n.byte 68\n.byte 32\n.byte 79\n.byte 70\n.byte 32\n.byte 84\n.byte 69\n.byte 83\n.byte 84\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC820:\n.byte 10\n.byte 65\n.byte 32\n.byte 116\n.byte 111\n.byte 116\n.byte 97\n.byte 108\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 102\n.byte 108\n.byte 111\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 112\n.byte 111\n.byte 105\n.byte 110\n.byte 116\n.byte 32\n.byte 101\n.byte 120\n.byte 99\n.byte 101\n.byte 112\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 119\n.byte 101\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 101\n.byte 103\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC817:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 69\n.byte 120\n.byte 99\n.byte 101\n.byte 108\n.byte 108\n.byte 101\n.byte 110\n.byte 116\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.LC816:\n.byte 32\n.byte 100\n.byte 117\n.byte 114\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 71\n.byte 114\n.byte 97\n.byte 100\n.byte 117\n.byte 97\n.byte 108\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC815:\n.byte 44\n.byte 10\n.byte 101\n.byte 120\n.byte 99\n.byte 101\n.byte 112\n.byte 116\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 112\n.byte 111\n.byte 115\n.byte 115\n.byte 105\n.byte 98\n.byte 108\n.byte 121\n.byte 32\n.byte 68\n.byte 111\n.byte 117\n.byte 98\n.byte 108\n.byte 101\n.byte 32\n.byte 82\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 0\n.align 1\n.LC814:\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC811:\n.byte 56\n.byte 53\n.byte 52\n.byte 0\n.align 1\n.LC810:\n.byte 55\n.byte 53\n.byte 52\n.byte 0\n.align 1\n.LC807:\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 112\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 73\n.byte 69\n.byte 69\n.byte 69\n.byte 32\n.byte 115\n.byte 116\n.byte 97\n.byte 110\n.byte 100\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 80\n.byte 0\n.align 1\n.LC806:\n.byte 82\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 111\n.byte 114\n.byte 109\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 0\n.align 1\n.LC803:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 115\n.byte 101\n.byte 101\n.byte 109\n.byte 115\n.byte 32\n.byte 83\n.byte 97\n.byte 116\n.byte 105\n.byte 115\n.byte 102\n.byte 97\n.byte 99\n.byte 116\n.byte 111\n.byte 114\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC797:\n.byte 78\n.byte 111\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 117\n.byte 114\n.byte 101\n.byte 115\n.byte 44\n.byte 32\n.byte 100\n.byte 101\n.byte 102\n.byte 101\n.byte 99\n.byte 116\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 102\n.byte 108\n.byte 97\n.byte 119\n.byte 115\n.byte 32\n.byte 104\n.byte 97\n.byte 118\n.byte 101\n.byte 32\n.byte 98\n.byte 101\n.byte 101\n.byte 110\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC796:\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 39\n.byte 115\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 115\n.byte 101\n.byte 113\n.byte 117\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC795:\n.byte 80\n.byte 111\n.byte 116\n.byte 101\n.byte 110\n.byte 116\n.byte 105\n.byte 97\n.byte 108\n.byte 108\n.byte 121\n.byte 32\n.byte 102\n.byte 97\n.byte 116\n.byte 97\n.byte 108\n.byte 32\n.byte 70\n.byte 65\n.byte 73\n.byte 76\n.byte 85\n.byte 82\n.byte 69\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 104\n.byte 97\n.byte 118\n.byte 101\n.byte 32\n.byte 115\n.byte 112\n.byte 111\n.byte 105\n.byte 108\n.byte 101\n.byte 100\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 0\n.align 1\n.LC792:\n.byte 117\n.byte 110\n.byte 97\n.byte 99\n.byte 99\n.byte 101\n.byte 112\n.byte 116\n.byte 97\n.byte 98\n.byte 108\n.byte 101\n.byte 32\n.byte 83\n.byte 101\n.byte 114\n.byte 105\n.byte 111\n.byte 117\n.byte 115\n.byte 32\n.byte 68\n.byte 101\n.byte 102\n.byte 101\n.byte 99\n.byte 116\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC791:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 104\n.byte 97\n.byte 115\n.byte 32\n.byte 0\n.align 1\n.LC787:\n.byte 100\n.byte 101\n.byte 115\n.byte 112\n.byte 105\n.byte 116\n.byte 101\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 111\n.byte 110\n.byte 118\n.byte 101\n.byte 110\n.byte 105\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 68\n.byte 101\n.byte 102\n.byte 101\n.byte 99\n.byte 116\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC786:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 65\n.byte 99\n.byte 99\n.byte 101\n.byte 112\n.byte 116\n.byte 97\n.byte 98\n.byte 108\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC781:\n.byte 83\n.byte 97\n.byte 116\n.byte 105\n.byte 115\n.byte 102\n.byte 97\n.byte 99\n.byte 116\n.byte 111\n.byte 114\n.byte 121\n.byte 32\n.byte 116\n.byte 104\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 32\n.byte 102\n.byte 108\n.byte 97\n.byte 119\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC780:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 100\n.byte 105\n.byte 97\n.byte 103\n.byte 110\n.byte 111\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 115\n.byte 101\n.byte 101\n.byte 109\n.byte 115\n.byte 32\n.byte 0\n.align 1\n.LC769:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 32\n.byte 37\n.byte 45\n.byte 50\n.byte 57\n.byte 115\n.byte 32\n.byte 37\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC762:\n.byte 70\n.byte 76\n.byte 65\n.byte 87\n.byte 115\n.byte 32\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 61\n.byte 0\n.align 1\n.LC761:\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 115\n.byte 32\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 61\n.byte 0\n.align 1\n.LC760:\n.byte 83\n.byte 69\n.byte 82\n.byte 73\n.byte 79\n.byte 85\n.byte 83\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 115\n.byte 32\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 61\n.byte 0\n.align 1\n.LC759:\n.byte 70\n.byte 65\n.byte 73\n.byte 76\n.byte 85\n.byte 82\n.byte 69\n.byte 115\n.byte 32\n.byte 32\n.byte 101\n.byte 110\n.byte 99\n.byte 111\n.byte 117\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 101\n.byte 100\n.byte 32\n.byte 61\n.byte 0\n.align 1\n.LC755:\n.byte 10\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 84\n.byte 114\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 32\n.byte 48\n.byte 32\n.byte 47\n.byte 32\n.byte 48\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 101\n.byte 115\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 0\n.align 1\n.LC754:\n.byte 32\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC751:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 84\n.byte 114\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 32\n.byte 49\n.byte 32\n.byte 47\n.byte 32\n.byte 48\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 101\n.byte 115\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 0\n.align 1\n.LC750:\n.byte 87\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 109\n.byte 101\n.byte 115\n.byte 115\n.byte 97\n.byte 103\n.byte 101\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 47\n.byte 111\n.byte 114\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 115\n.byte 32\n.byte 100\n.byte 111\n.byte 101\n.byte 115\n.byte 32\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 101\n.byte 63\n.byte 10\n.byte 0\n.align 1\n.LC749:\n.byte 32\n.byte 32\n.byte 105\n.byte 110\n.byte 115\n.byte 116\n.byte 101\n.byte 97\n.byte 100\n.byte 44\n.byte 32\n.byte 88\n.byte 32\n.byte 47\n.byte 32\n.byte 88\n.byte 32\n.byte 45\n.byte 32\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 45\n.byte 32\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC748:\n.byte 32\n.byte 32\n.byte 88\n.byte 32\n.byte 47\n.byte 32\n.byte 88\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 49\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 110\n.byte 32\n.byte 88\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC743:\n.byte 32\n.byte 32\n.byte 88\n.byte 32\n.byte 47\n.byte 32\n.byte 88\n.byte 32\n.byte 32\n.byte 116\n.byte 114\n.byte 97\n.byte 112\n.byte 115\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 110\n.byte 32\n.byte 88\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 103\n.byte 10\n.byte 0\n.align 1\n.LC728:\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 102\n.byte 97\n.byte 114\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 49\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC727:\n.byte 32\n.byte 117\n.byte 110\n.byte 98\n.byte 97\n.byte 108\n.byte 97\n.byte 110\n.byte 99\n.byte 101\n.byte 100\n.byte 32\n.byte 114\n.byte 97\n.byte 110\n.byte 103\n.byte 101\n.byte 59\n.byte 32\n.byte 85\n.byte 102\n.byte 84\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 42\n.byte 32\n.byte 86\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 9\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.LC726:\n.byte 66\n.byte 97\n.byte 100\n.byte 108\n.byte 121\n.byte 0\n.align 1\n.LC719:\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 102\n.byte 97\n.byte 114\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 40\n.byte 90\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 50\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC718:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC706:\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 102\n.byte 97\n.byte 114\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 40\n.byte 90\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC705:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 119\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC688:\n.byte 43\n.byte 45\n.byte 37\n.byte 103\n.byte 44\n.byte 32\n.byte 43\n.byte 45\n.byte 37\n.byte 103\n.byte 10\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 43\n.byte 45\n.byte 37\n.byte 103\n.byte 32\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 117\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 46\n.byte 0\n.align 1\n.LC687:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 105\n.byte 110\n.byte 118\n.byte 111\n.byte 108\n.byte 118\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 0\n.align 1\n.LC681:\n.byte 97\n.byte 98\n.byte 111\n.byte 118\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC680:\n.byte 65\n.byte 110\n.byte 121\n.byte 32\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 115\n.byte 101\n.byte 112\n.byte 97\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 42\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 111\n.byte 110\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC679:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 86\n.byte 32\n.byte 47\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC678:\n.byte 78\n.byte 111\n.byte 32\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 97\n.byte 108\n.byte 101\n.byte 100\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 86\n.byte 32\n.byte 42\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC677:\n.byte 84\n.byte 104\n.byte 101\n.byte 114\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 32\n.byte 115\n.byte 97\n.byte 116\n.byte 117\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 98\n.byte 101\n.byte 99\n.byte 97\n.byte 117\n.byte 115\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 115\n.byte 121\n.byte 115\n.byte 116\n.byte 101\n.byte 109\n.byte 32\n.byte 116\n.byte 114\n.byte 97\n.byte 112\n.byte 115\n.byte 32\n.byte 111\n.byte 110\n.byte 32\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC676:\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 115\n.byte 97\n.byte 116\n.byte 117\n.byte 114\n.byte 97\n.byte 116\n.byte 101\n.byte 115\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 86\n.byte 48\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC673:\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 86\n.byte 32\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC664:\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 112\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 9\n.byte 115\n.byte 104\n.byte 114\n.byte 105\n.byte 110\n.byte 107\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC661:\n.byte 45\n.byte 40\n.byte 45\n.byte 89\n.byte 41\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 89\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC660:\n.byte 102\n.byte 105\n.byte 110\n.byte 100\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 0\n.align 1\n.LC659:\n.byte 83\n.byte 101\n.byte 101\n.byte 109\n.byte 115\n.byte 32\n.byte 79\n.byte 46\n.byte 75\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC656:\n.byte 84\n.byte 114\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 111\n.byte 110\n.byte 32\n.byte 89\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC655:\n.byte 67\n.byte 97\n.byte 110\n.byte 32\n.byte 96\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 45\n.byte 89\n.byte 39\n.byte 32\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 63\n.byte 10\n.byte 0\n.align 1\n.LC648:\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 103\n.byte 101\n.byte 110\n.byte 101\n.byte 114\n.byte 97\n.byte 116\n.byte 101\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC647:\n.byte 83\n.byte 101\n.byte 97\n.byte 114\n.byte 99\n.byte 104\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 79\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 58\n.byte 10\n.byte 0\n.align 1\n.LC646:\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 32\n.byte 110\n.byte 111\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 114\n.byte 101\n.byte 112\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC638:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 112\n.byte 111\n.byte 119\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 90\n.byte 94\n.byte 81\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 114\n.byte 32\n.byte 110\n.byte 101\n.byte 97\n.byte 114\n.byte 108\n.byte 121\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 101\n.byte 109\n.byte 101\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC637:\n.byte 65\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 97\n.byte 99\n.byte 121\n.byte 32\n.byte 115\n.byte 101\n.byte 101\n.byte 109\n.byte 115\n.byte 32\n.byte 97\n.byte 100\n.byte 101\n.byte 113\n.byte 117\n.byte 97\n.byte 116\n.byte 101\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC630:\n.byte 9\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 105\n.byte 110\n.byte 118\n.byte 111\n.byte 108\n.byte 118\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 105\n.byte 110\n.byte 121\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 114\n.byte 97\n.byte 116\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC629:\n.byte 9\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 109\n.byte 117\n.byte 99\n.byte 104\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 115\n.byte 112\n.byte 111\n.byte 105\n.byte 108\n.byte 32\n.byte 102\n.byte 105\n.byte 110\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 97\n.byte 108\n.byte 10\n.byte 0\n.align 1\n.LC628:\n.byte 9\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC627:\n.byte 9\n.byte 40\n.byte 49\n.byte 32\n.byte 43\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 59\n.byte 10\n.byte 0\n.align 1\n.LC626:\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 10\n.byte 0\n.align 1\n.LC625:\n.byte 67\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 101\n.byte 100\n.byte 0\n.align 1\n.LC618:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 88\n.byte 94\n.byte 40\n.byte 40\n.byte 88\n.byte 32\n.byte 43\n.byte 32\n.byte 49\n.byte 41\n.byte 32\n.byte 47\n.byte 32\n.byte 40\n.byte 88\n.byte 32\n.byte 45\n.byte 32\n.byte 49\n.byte 41\n.byte 41\n.byte 32\n.byte 118\n.byte 115\n.byte 46\n.byte 32\n.byte 101\n.byte 120\n.byte 112\n.byte 40\n.byte 50\n.byte 41\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 88\n.byte 32\n.byte 45\n.byte 62\n.byte 32\n.byte 49\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC614:\n.byte 84\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 79\n.byte 46\n.byte 75\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC611:\n.byte 32\n.byte 32\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC610:\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 98\n.byte 101\n.byte 116\n.byte 119\n.byte 101\n.byte 101\n.byte 110\n.byte 32\n.byte 48\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 10\n.byte 0\n.align 1\n.LC606:\n.byte 97\n.byte 99\n.byte 116\n.byte 117\n.byte 97\n.byte 108\n.byte 108\n.byte 121\n.byte 32\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 121\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 115\n.byte 58\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC605:\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 97\n.byte 102\n.byte 102\n.byte 108\n.byte 105\n.byte 99\n.byte 116\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 101\n.byte 120\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 10\n.byte 9\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 59\n.byte 10\n.byte 0\n.align 1\n.LC604:\n.byte 85\n.byte 102\n.byte 84\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 61\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 32\n.byte 94\n.byte 32\n.byte 40\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 41\n.byte 10\n.byte 111\n.byte 110\n.byte 108\n.byte 121\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 0\n.align 1\n.LC603:\n.byte 83\n.byte 105\n.byte 110\n.byte 99\n.byte 101\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 111\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 115\n.byte 32\n.byte 98\n.byte 101\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC602:\n.byte 82\n.byte 97\n.byte 110\n.byte 103\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 110\n.byte 97\n.byte 114\n.byte 114\n.byte 111\n.byte 119\n.byte 59\n.byte 32\n.byte 85\n.byte 49\n.byte 94\n.byte 37\n.byte 100\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC597:\n.byte 109\n.byte 101\n.byte 114\n.byte 101\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 111\n.byte 102\n.byte 102\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC596:\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 115\n.byte 117\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 32\n.byte 108\n.byte 97\n.byte 114\n.byte 103\n.byte 101\n.byte 114\n.byte 32\n.byte 82\n.byte 101\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 110\n.byte 32\n.byte 0\n.align 1\n.LC595:\n.byte 32\n.byte 98\n.byte 101\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 119\n.byte 104\n.byte 105\n.byte 99\n.byte 104\n.byte 0\n.align 1\n.LC594:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.LC593:\n.byte 88\n.byte 32\n.byte 47\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 49\n.byte 32\n.byte 43\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC592:\n.byte 88\n.byte 32\n.byte 47\n.byte 32\n.byte 90\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 115\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.LC589:\n.byte 101\n.byte 110\n.byte 99\n.byte 111\n.byte 117\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 97\n.byte 108\n.byte 116\n.byte 104\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 32\n.byte 97\n.byte 99\n.byte 116\n.byte 117\n.byte 97\n.byte 108\n.byte 108\n.byte 121\n.byte 10\n.byte 0\n.align 1\n.LC588:\n.byte 32\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 32\n.byte 40\n.byte 102\n.byte 40\n.byte 88\n.byte 41\n.byte 32\n.byte 45\n.byte 32\n.byte 102\n.byte 40\n.byte 90\n.byte 41\n.byte 41\n.byte 32\n.byte 47\n.byte 32\n.byte 40\n.byte 88\n.byte 32\n.byte 45\n.byte 32\n.byte 90\n.byte 41\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC587:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 105\n.byte 102\n.byte 32\n.byte 40\n.byte 88\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 90\n.byte 41\n.byte 32\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 32\n.byte 32\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 0\n.align 1\n.LC586:\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 117\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 110\n.byte 32\n.byte 105\n.byte 110\n.byte 110\n.byte 111\n.byte 99\n.byte 101\n.byte 110\n.byte 116\n.byte 32\n.byte 115\n.byte 116\n.byte 97\n.byte 116\n.byte 101\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC585:\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 83\n.byte 69\n.byte 82\n.byte 73\n.byte 79\n.byte 85\n.byte 83\n.byte 32\n.byte 68\n.byte 69\n.byte 70\n.byte 69\n.byte 67\n.byte 84\n.byte 10\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 99\n.byte 97\n.byte 117\n.byte 115\n.byte 101\n.byte 115\n.byte 32\n.byte 0\n.align 1\n.LC584:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 83\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 78\n.byte 79\n.byte 84\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 44\n.byte 32\n.byte 0\n.align 1\n.LC583:\n.byte 121\n.byte 101\n.byte 116\n.byte 32\n.byte 88\n.byte 32\n.byte 45\n.byte 32\n.byte 90\n.byte 32\n.byte 121\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 115\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC582:\n.byte 88\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 9\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 101\n.byte 113\n.byte 117\n.byte 97\n.byte 108\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 90\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC577:\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 47\n.byte 32\n.byte 85\n.byte 102\n.byte 84\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 101\n.byte 100\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.LC567:\n.byte 40\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 111\n.byte 102\n.byte 102\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 85\n.byte 102\n.byte 84\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 41\n.byte 32\n.byte 60\n.byte 32\n.byte 69\n.byte 48\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC566:\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 103\n.byte 114\n.byte 97\n.byte 100\n.byte 117\n.byte 97\n.byte 108\n.byte 59\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 117\n.byte 114\n.byte 115\n.byte 32\n.byte 65\n.byte 98\n.byte 115\n.byte 111\n.byte 108\n.byte 117\n.byte 116\n.byte 101\n.byte 32\n.byte 69\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 61\n.byte 10\n.byte 0\n.align 1\n.LC561:\n.byte 124\n.byte 81\n.byte 32\n.byte 45\n.byte 32\n.byte 89\n.byte 124\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC560:\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 32\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 81\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 89\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC559:\n.byte 81\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 89\n.byte 32\n.byte 119\n.byte 104\n.byte 105\n.byte 108\n.byte 101\n.byte 32\n.byte 100\n.byte 101\n.byte 110\n.byte 121\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 124\n.byte 81\n.byte 32\n.byte 45\n.byte 32\n.byte 89\n.byte 124\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 48\n.byte 59\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 115\n.byte 101\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.LC558:\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 117\n.byte 115\n.byte 101\n.byte 115\n.byte 32\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 44\n.byte 32\n.byte 119\n.byte 104\n.byte 105\n.byte 99\n.byte 104\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 10\n.byte 0\n.align 1\n.LC556:\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 32\n.byte 109\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 108\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC555:\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 100\n.byte 111\n.byte 119\n.byte 110\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC554:\n.byte 97\n.byte 112\n.byte 112\n.byte 114\n.byte 111\n.byte 97\n.byte 99\n.byte 104\n.byte 32\n.byte 97\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 49\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC553:\n.byte 69\n.byte 105\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 97\n.byte 99\n.byte 99\n.byte 117\n.byte 114\n.byte 97\n.byte 99\n.byte 121\n.byte 32\n.byte 100\n.byte 101\n.byte 116\n.byte 101\n.byte 114\n.byte 105\n.byte 111\n.byte 114\n.byte 97\n.byte 116\n.byte 101\n.byte 115\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.LC541:\n.byte 83\n.byte 109\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 115\n.byte 116\n.byte 114\n.byte 105\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 112\n.byte 111\n.byte 115\n.byte 105\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 69\n.byte 48\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC540:\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 110\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 116\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC539:\n.byte 68\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 101\n.byte 110\n.byte 99\n.byte 101\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 115\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 97\n.byte 32\n.byte 104\n.byte 105\n.byte 103\n.byte 104\n.byte 101\n.byte 114\n.byte 0\n.align 1\n.LC536:\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 110\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 101\n.byte 110\n.byte 99\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC535:\n.byte 80\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 116\n.byte 115\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 97\n.byte 32\n.byte 104\n.byte 105\n.byte 103\n.byte 104\n.byte 101\n.byte 114\n.byte 0\n.align 1\n.LC528:\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 80\n.byte 115\n.byte 101\n.byte 117\n.byte 100\n.byte 111\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC527:\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 32\n.byte 115\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 100\n.byte 108\n.byte 121\n.byte 32\n.byte 112\n.byte 111\n.byte 115\n.byte 105\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC526:\n.byte 112\n.byte 111\n.byte 115\n.byte 105\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 44\n.byte 32\n.byte 105\n.byte 115\n.byte 110\n.byte 39\n.byte 116\n.byte 59\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC525:\n.byte 66\n.byte 117\n.byte 116\n.byte 32\n.byte 45\n.byte 80\n.byte 115\n.byte 101\n.byte 117\n.byte 100\n.byte 111\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 44\n.byte 32\n.byte 119\n.byte 104\n.byte 105\n.byte 99\n.byte 104\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 98\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC522:\n.byte 80\n.byte 115\n.byte 101\n.byte 117\n.byte 100\n.byte 111\n.byte 90\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 112\n.byte 114\n.byte 105\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 58\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC521:\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 100\n.byte 108\n.byte 121\n.byte 32\n.byte 110\n.byte 101\n.byte 103\n.byte 97\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC520:\n.byte 80\n.byte 111\n.byte 115\n.byte 105\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 101\n.byte 120\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 32\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 97\n.byte 110\n.byte 10\n.byte 0\n.align 1\n.LC507:\n.byte 109\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 108\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC483:\n.byte 83\n.byte 101\n.byte 101\n.byte 107\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 85\n.byte 110\n.byte 100\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 32\n.byte 116\n.byte 104\n.byte 114\n.byte 101\n.byte 115\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 115\n.byte 32\n.byte 85\n.byte 102\n.byte 84\n.byte 104\n.byte 111\n.byte 108\n.byte 100\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 69\n.byte 48\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC480:\n.byte 46\n.byte 46\n.byte 46\n.byte 32\n.byte 110\n.byte 111\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 99\n.byte 114\n.byte 101\n.byte 112\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC477:\n.byte 9\n.byte 105\n.byte 110\n.byte 118\n.byte 111\n.byte 108\n.byte 118\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 114\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 114\n.byte 97\n.byte 116\n.byte 101\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC476:\n.byte 69\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 115\n.byte 32\n.byte 108\n.byte 105\n.byte 107\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 105\n.byte 110\n.byte 118\n.byte 97\n.byte 108\n.byte 105\n.byte 100\n.byte 97\n.byte 116\n.byte 101\n.byte 32\n.byte 102\n.byte 105\n.byte 110\n.byte 97\n.byte 110\n.byte 99\n.byte 105\n.byte 97\n.byte 108\n.byte 32\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.LC455:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 112\n.byte 111\n.byte 119\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 90\n.byte 94\n.byte 105\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 115\n.byte 109\n.byte 97\n.byte 108\n.byte 108\n.byte 32\n.byte 73\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 90\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC452:\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 108\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 0\n.align 1\n.LC450:\n.byte 116\n.byte 111\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 117\n.byte 108\n.byte 112\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC449:\n.byte 79\n.byte 98\n.byte 115\n.byte 101\n.byte 114\n.byte 118\n.byte 101\n.byte 100\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 115\n.byte 32\n.byte 114\n.byte 117\n.byte 110\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 0\n.align 1\n.LC448:\n.byte 83\n.byte 113\n.byte 117\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 111\n.byte 111\n.byte 116\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 101\n.byte 105\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC445:\n.byte 83\n.byte 113\n.byte 117\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 111\n.byte 111\n.byte 116\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC440:\n.byte 83\n.byte 113\n.byte 117\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 111\n.byte 111\n.byte 116\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC435:\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 115\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 115\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC434:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 94\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC433:\n.byte 65\n.byte 110\n.byte 111\n.byte 109\n.byte 97\n.byte 108\n.byte 111\n.byte 117\n.byte 115\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 73\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 32\n.byte 60\n.byte 32\n.byte 0\n.align 1\n.LC393:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 119\n.byte 104\n.byte 101\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC371:\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 40\n.byte 88\n.byte 41\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 110\n.byte 45\n.byte 109\n.byte 111\n.byte 110\n.byte 111\n.byte 116\n.byte 111\n.byte 110\n.byte 105\n.byte 99\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 88\n.byte 32\n.byte 110\n.byte 101\n.byte 97\n.byte 114\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC370:\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 104\n.byte 97\n.byte 115\n.byte 32\n.byte 112\n.byte 97\n.byte 115\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 97\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 77\n.byte 111\n.byte 110\n.byte 111\n.byte 116\n.byte 111\n.byte 110\n.byte 105\n.byte 99\n.byte 105\n.byte 116\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC353:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 32\n.byte 109\n.byte 111\n.byte 110\n.byte 111\n.byte 116\n.byte 111\n.byte 110\n.byte 105\n.byte 99\n.byte 105\n.byte 116\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC342:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 105\n.byte 102\n.byte 32\n.byte 115\n.byte 113\n.byte 114\n.byte 116\n.byte 40\n.byte 88\n.byte 32\n.byte 42\n.byte 32\n.byte 88\n.byte 41\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 88\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 73\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 88\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC337:\n.byte 83\n.byte 113\n.byte 117\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 111\n.byte 111\n.byte 116\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 48\n.byte 46\n.byte 48\n.byte 44\n.byte 32\n.byte 45\n.byte 48\n.byte 46\n.byte 48\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 49\n.byte 46\n.byte 48\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 0\n.align 1\n.LC335:\n.byte 10\n.byte 82\n.byte 117\n.byte 110\n.byte 110\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 115\n.byte 113\n.byte 117\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 114\n.byte 111\n.byte 111\n.byte 116\n.byte 40\n.byte 120\n.byte 41\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC334:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 78\n.byte 111\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 117\n.byte 114\n.byte 101\n.byte 115\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 32\n.byte 112\n.byte 97\n.byte 105\n.byte 114\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC333:\n.byte 88\n.byte 32\n.byte 42\n.byte 32\n.byte 89\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 89\n.byte 32\n.byte 42\n.byte 32\n.byte 88\n.byte 32\n.byte 116\n.byte 114\n.byte 105\n.byte 97\n.byte 108\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 4\n.LC324:\n.long 0\n.long 1074266112\n.align 1\n.LC323:\n.byte 84\n.byte 101\n.byte 115\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 111\n.byte 110\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 114\n.byte 97\n.byte 110\n.byte 100\n.byte 111\n.byte 109\n.byte 32\n.byte 112\n.byte 97\n.byte 105\n.byte 114\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC322:\n.byte 68\n.byte 111\n.byte 101\n.byte 115\n.byte 32\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 99\n.byte 111\n.byte 109\n.byte 109\n.byte 117\n.byte 116\n.byte 101\n.byte 63\n.byte 32\n.byte 32\n.byte 0\n.align 1\n.LC319:\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 40\n.byte 115\n.byte 41\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 103\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 117\n.byte 114\n.byte 101\n.byte 40\n.byte 115\n.byte 41\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 10\n.byte 40\n.byte 110\n.byte 111\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 97\n.byte 98\n.byte 111\n.byte 118\n.byte 101\n.byte 41\n.byte 32\n.byte 99\n.byte 111\n.byte 117\n.byte 110\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 111\n.byte 110\n.byte 101\n.byte 32\n.byte 102\n.byte 108\n.byte 97\n.byte 119\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 102\n.byte 105\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 116\n.byte 97\n.byte 108\n.byte 108\n.byte 121\n.byte 32\n.byte 98\n.byte 101\n.byte 108\n.byte 111\n.byte 119\n.byte 0\n.align 1\n.LC317:\n.byte 83\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 121\n.byte 32\n.byte 98\n.byte 105\n.byte 116\n.byte 32\n.byte 117\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 97\n.byte 116\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC316:\n.byte 83\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 121\n.byte 32\n.byte 98\n.byte 105\n.byte 116\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 97\n.byte 114\n.byte 101\n.byte 110\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 117\n.byte 115\n.byte 101\n.byte 100\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC299:\n.byte 67\n.byte 104\n.byte 101\n.byte 99\n.byte 107\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 115\n.byte 116\n.byte 105\n.byte 99\n.byte 107\n.byte 121\n.byte 32\n.byte 98\n.byte 105\n.byte 116\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC296:\n.byte 40\n.byte 88\n.byte 32\n.byte 45\n.byte 32\n.byte 89\n.byte 41\n.byte 32\n.byte 43\n.byte 32\n.byte 40\n.byte 89\n.byte 32\n.byte 45\n.byte 32\n.byte 88\n.byte 41\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 110\n.byte 32\n.byte 122\n.byte 101\n.byte 114\n.byte 111\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.LC293:\n.byte 65\n.byte 100\n.byte 100\n.byte 105\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 47\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 110\n.byte 101\n.byte 105\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC292:\n.byte 65\n.byte 100\n.byte 100\n.byte 47\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 0\n.align 1\n.LC289:\n.byte 65\n.byte 100\n.byte 100\n.byte 105\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 47\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC282:\n.byte 65\n.byte 100\n.byte 100\n.byte 47\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC277:\n.byte 73\n.byte 110\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 108\n.byte 101\n.byte 116\n.byte 101\n.byte 32\n.byte 99\n.byte 97\n.byte 114\n.byte 114\n.byte 121\n.byte 45\n.byte 112\n.byte 114\n.byte 111\n.byte 112\n.byte 97\n.byte 103\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 65\n.byte 100\n.byte 100\n.byte 105\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 1\n.LC273:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 42\n.byte 32\n.byte 40\n.byte 32\n.byte 49\n.byte 32\n.byte 47\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 41\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 49\n.byte 0\n.align 1\n.LC271:\n.byte 47\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 101\n.byte 105\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC268:\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC265:\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 1\n.LC262:\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC257:\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 1\n.LC254:\n.byte 42\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 101\n.byte 105\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 112\n.byte 101\n.byte 100\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC253:\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 99\n.byte 104\n.byte 111\n.byte 112\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC250:\n.byte 77\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 105\n.byte 99\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 99\n.byte 111\n.byte 114\n.byte 114\n.byte 101\n.byte 99\n.byte 116\n.byte 108\n.byte 121\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC240:\n.byte 88\n.byte 32\n.byte 42\n.byte 32\n.byte 40\n.byte 49\n.byte 47\n.byte 88\n.byte 41\n.byte 32\n.byte 100\n.byte 105\n.byte 102\n.byte 102\n.byte 101\n.byte 114\n.byte 115\n.byte 32\n.byte 102\n.byte 114\n.byte 111\n.byte 109\n.byte 32\n.byte 49\n.byte 0\n.align 1\n.LC221:\n.byte 67\n.byte 104\n.byte 101\n.byte 99\n.byte 107\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 111\n.byte 110\n.byte 32\n.byte 109\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 121\n.byte 44\n.byte 32\n.byte 100\n.byte 105\n.byte 118\n.byte 105\n.byte 100\n.byte 101\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 97\n.byte 100\n.byte 100\n.byte 47\n.byte 115\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC220:\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 32\n.byte 42\n.byte 44\n.byte 32\n.byte 47\n.byte 44\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 45\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 104\n.byte 97\n.byte 118\n.byte 101\n.byte 32\n.byte 103\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 44\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 121\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC217:\n.byte 32\n.byte 32\n.byte 46\n.byte 46\n.byte 46\n.byte 32\n.byte 32\n.byte 105\n.byte 102\n.byte 32\n.byte 40\n.byte 88\n.byte 32\n.byte 61\n.byte 61\n.byte 32\n.byte 49\n.byte 46\n.byte 48\n.byte 41\n.byte 32\n.byte 123\n.byte 46\n.byte 46\n.byte 46\n.byte 46\n.byte 46\n.byte 125\n.byte 32\n.byte 101\n.byte 108\n.byte 115\n.byte 101\n.byte 32\n.byte 123\n.byte 46\n.byte 46\n.byte 46\n.byte 47\n.byte 40\n.byte 88\n.byte 45\n.byte 49\n.byte 46\n.byte 48\n.byte 41\n.byte 46\n.byte 46\n.byte 46\n.byte 125\n.byte 10\n.byte 0\n.align 1\n.LC216:\n.byte 32\n.byte 32\n.byte 115\n.byte 117\n.byte 99\n.byte 104\n.byte 32\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 97\n.byte 117\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 97\n.byte 103\n.byte 97\n.byte 105\n.byte 110\n.byte 115\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 122\n.byte 101\n.byte 114\n.byte 111\n.byte 32\n.byte 97\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.LC215:\n.byte 32\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 121\n.byte 105\n.byte 101\n.byte 108\n.byte 100\n.byte 115\n.byte 32\n.byte 32\n.byte 40\n.byte 49\n.byte 45\n.byte 85\n.byte 49\n.byte 41\n.byte 32\n.byte 45\n.byte 32\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 32\n.byte 44\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 101\n.byte 98\n.byte 121\n.byte 32\n.byte 118\n.byte 105\n.byte 116\n.byte 105\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 10\n.byte 0\n.align 1\n.LC214:\n.byte 99\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 32\n.byte 40\n.byte 49\n.byte 45\n.byte 85\n.byte 49\n.byte 41\n.byte 32\n.byte 60\n.byte 32\n.byte 49\n.byte 32\n.byte 32\n.byte 97\n.byte 108\n.byte 116\n.byte 104\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 10\n.byte 0\n.align 1\n.LC211:\n.byte 45\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 115\n.byte 32\n.byte 71\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 68\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 44\n.byte 32\n.byte 115\n.byte 111\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 99\n.byte 101\n.byte 108\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 111\n.byte 98\n.byte 115\n.byte 99\n.byte 117\n.byte 114\n.byte 101\n.byte 100\n.byte 0\n.align 1\n.LC206:\n.byte 42\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 47\n.byte 111\n.byte 114\n.byte 32\n.byte 47\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 108\n.byte 97\n.byte 115\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 0\n.align 1\n.LC202:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 117\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 49\n.byte 47\n.byte 49\n.byte 46\n.byte 48\n.byte 48\n.byte 48\n.byte 46\n.byte 46\n.byte 49\n.byte 32\n.byte 62\n.byte 61\n.byte 32\n.byte 49\n.byte 0\n.align 1\n.LC200:\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 71\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 68\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 44\n.byte 32\n.byte 115\n.byte 111\n.byte 32\n.byte 88\n.byte 47\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 88\n.byte 0\n.align 1\n.LC195:\n.byte 68\n.byte 105\n.byte 118\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 71\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 68\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 44\n.byte 32\n.byte 115\n.byte 111\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 32\n.byte 101\n.byte 120\n.byte 99\n.byte 101\n.byte 101\n.byte 100\n.byte 32\n.byte 49\n.byte 32\n.byte 117\n.byte 108\n.byte 112\n.byte 10\n.byte 111\n.byte 114\n.byte 32\n.byte 32\n.byte 49\n.byte 47\n.byte 51\n.byte 32\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 32\n.byte 51\n.byte 47\n.byte 57\n.byte 32\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 32\n.byte 57\n.byte 47\n.byte 50\n.byte 55\n.byte 32\n.byte 109\n.byte 97\n.byte 121\n.byte 32\n.byte 100\n.byte 105\n.byte 115\n.byte 97\n.byte 103\n.byte 114\n.byte 101\n.byte 101\n.byte 0\n.align 1\n.LC191:\n.byte 42\n.byte 32\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 109\n.byte 97\n.byte 110\n.byte 121\n.byte 32\n.byte 102\n.byte 105\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 119\n.byte 114\n.byte 111\n.byte 110\n.byte 103\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC189:\n.byte 42\n.byte 32\n.byte 108\n.byte 97\n.byte 99\n.byte 107\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 71\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 68\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 44\n.byte 32\n.byte 115\n.byte 111\n.byte 32\n.byte 49\n.byte 42\n.byte 88\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 88\n.byte 0\n.align 1\n.LC186:\n.byte 10\n.byte 67\n.byte 104\n.byte 101\n.byte 99\n.byte 107\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 103\n.byte 117\n.byte 97\n.byte 114\n.byte 100\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 32\n.byte 105\n.byte 110\n.byte 32\n.byte 42\n.byte 44\n.byte 32\n.byte 47\n.byte 44\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 45\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC185:\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 109\n.byte 97\n.byte 108\n.byte 105\n.byte 122\n.byte 101\n.byte 100\n.byte 44\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 105\n.byte 116\n.byte 32\n.byte 115\n.byte 104\n.byte 111\n.byte 117\n.byte 108\n.byte 100\n.byte 32\n.byte 98\n.byte 101\n.byte 46\n.byte 0\n.align 1\n.LC180:\n.byte 83\n.byte 117\n.byte 98\n.byte 116\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 110\n.byte 111\n.byte 114\n.byte 109\n.byte 97\n.byte 108\n.byte 105\n.byte 122\n.byte 101\n.byte 100\n.byte 32\n.byte 88\n.byte 61\n.byte 89\n.byte 44\n.byte 88\n.byte 43\n.byte 90\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 89\n.byte 43\n.byte 90\n.byte 33\n.byte 0\n.align 1\n.LC176:\n.byte 114\n.byte 111\n.byte 117\n.byte 103\n.byte 104\n.byte 108\n.byte 121\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 105\n.byte 102\n.byte 105\n.byte 99\n.byte 97\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 101\n.byte 99\n.byte 105\n.byte 109\n.byte 97\n.byte 108\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC175:\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 101\n.byte 108\n.byte 121\n.byte 32\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 32\n.byte 97\n.byte 98\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 37\n.byte 103\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 32\n.byte 66\n.byte 45\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 44\n.byte 32\n.byte 105\n.byte 46\n.byte 101\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC174:\n.byte 83\n.byte 111\n.byte 109\n.byte 101\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 101\n.byte 120\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 32\n.byte 97\n.byte 112\n.byte 112\n.byte 101\n.byte 97\n.byte 114\n.byte 32\n.byte 116\n.byte 111\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 10\n.byte 0\n.align 1\n.LC168:\n.byte 111\n.byte 102\n.byte 32\n.byte 97\n.byte 110\n.byte 10\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 45\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 1\n.LC167:\n.byte 90\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 90\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 0\n.align 1\n.LC166:\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 101\n.byte 120\n.byte 97\n.byte 99\n.byte 116\n.byte 32\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 97\n.byte 108\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 97\n.byte 32\n.byte 114\n.byte 101\n.byte 115\n.byte 117\n.byte 108\n.byte 116\n.byte 10\n.byte 0\n.align 1\n.LC165:\n.byte 66\n.byte 101\n.byte 99\n.byte 97\n.byte 117\n.byte 115\n.byte 101\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 117\n.byte 110\n.byte 117\n.byte 115\n.byte 117\n.byte 97\n.byte 108\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 102\n.byte 0\n.align 1\n.LC161:\n.byte 9\n.byte 85\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 90\n.byte 50\n.byte 32\n.byte 45\n.byte 32\n.byte 85\n.byte 50\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC160:\n.byte 9\n.byte 85\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 90\n.byte 49\n.byte 32\n.byte 45\n.byte 32\n.byte 85\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC159:\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 0\n.align 1\n.LC158:\n.byte 0\n.align 1\n.LC151:\n.byte 84\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 102\n.byte 101\n.byte 97\n.byte 116\n.byte 117\n.byte 114\n.byte 101\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 102\n.byte 117\n.byte 114\n.byte 116\n.byte 104\n.byte 101\n.byte 114\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC146:\n.byte 80\n.byte 111\n.byte 115\n.byte 115\n.byte 105\n.byte 98\n.byte 108\n.byte 121\n.byte 32\n.byte 115\n.byte 111\n.byte 109\n.byte 101\n.byte 32\n.byte 112\n.byte 97\n.byte 114\n.byte 116\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 0\n.align 1\n.LC145:\n.byte 98\n.byte 121\n.byte 32\n.byte 101\n.byte 120\n.byte 116\n.byte 114\n.byte 97\n.byte 45\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 101\n.byte 32\n.byte 101\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 101\n.byte 116\n.byte 105\n.byte 99\n.byte 32\n.byte 115\n.byte 117\n.byte 98\n.byte 101\n.byte 120\n.byte 112\n.byte 114\n.byte 101\n.byte 115\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 115\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC144:\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 115\n.byte 121\n.byte 109\n.byte 112\n.byte 116\n.byte 111\n.byte 109\n.byte 115\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 105\n.byte 110\n.byte 99\n.byte 111\n.byte 110\n.byte 115\n.byte 105\n.byte 115\n.byte 116\n.byte 101\n.byte 110\n.byte 99\n.byte 105\n.byte 101\n.byte 115\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 114\n.byte 111\n.byte 100\n.byte 117\n.byte 99\n.byte 101\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC143:\n.byte 114\n.byte 101\n.byte 115\n.byte 112\n.byte 101\n.byte 99\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 108\n.byte 121\n.byte 32\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 32\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 44\n.byte 10\n.byte 0\n.align 1\n.LC142:\n.byte 68\n.byte 105\n.byte 115\n.byte 97\n.byte 103\n.byte 114\n.byte 101\n.byte 101\n.byte 109\n.byte 101\n.byte 110\n.byte 116\n.byte 115\n.byte 32\n.byte 97\n.byte 109\n.byte 111\n.byte 110\n.byte 103\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 118\n.byte 97\n.byte 108\n.byte 117\n.byte 101\n.byte 115\n.byte 32\n.byte 88\n.byte 49\n.byte 44\n.byte 32\n.byte 89\n.byte 49\n.byte 44\n.byte 32\n.byte 90\n.byte 49\n.byte 44\n.byte 10\n.byte 0\n.align 1\n.LC120:\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 119\n.byte 111\n.byte 114\n.byte 115\n.byte 101\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 110\n.byte 32\n.byte 53\n.byte 32\n.byte 100\n.byte 101\n.byte 99\n.byte 105\n.byte 109\n.byte 97\n.byte 108\n.byte 32\n.byte 102\n.byte 105\n.byte 103\n.byte 117\n.byte 114\n.byte 101\n.byte 115\n.byte 32\n.byte 32\n.byte 0\n.align 1\n.LC118:\n.byte 84\n.byte 104\n.byte 101\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 105\n.byte 102\n.byte 105\n.byte 99\n.byte 97\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 116\n.byte 104\n.byte 101\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 37\n.byte 102\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC117:\n.byte 108\n.byte 111\n.byte 103\n.byte 97\n.byte 114\n.byte 105\n.byte 116\n.byte 104\n.byte 109\n.byte 105\n.byte 99\n.byte 32\n.byte 101\n.byte 110\n.byte 99\n.byte 111\n.byte 100\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 104\n.byte 97\n.byte 115\n.byte 32\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 101\n.byte 114\n.byte 105\n.byte 122\n.byte 101\n.byte 100\n.byte 32\n.byte 115\n.byte 111\n.byte 108\n.byte 101\n.byte 108\n.byte 121\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 85\n.byte 49\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC114:\n.byte 111\n.byte 102\n.byte 32\n.byte 115\n.byte 105\n.byte 103\n.byte 110\n.byte 105\n.byte 102\n.byte 105\n.byte 99\n.byte 97\n.byte 110\n.byte 116\n.byte 32\n.byte 100\n.byte 105\n.byte 103\n.byte 105\n.byte 116\n.byte 115\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 44\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 105\n.byte 116\n.byte 115\n.byte 101\n.byte 108\n.byte 102\n.byte 44\n.byte 32\n.byte 116\n.byte 104\n.byte 105\n.byte 115\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 97\n.byte 32\n.byte 109\n.byte 105\n.byte 110\n.byte 111\n.byte 114\n.byte 32\n.byte 102\n.byte 108\n.byte 97\n.byte 119\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC113:\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 99\n.byte 97\n.byte 110\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 98\n.byte 101\n.byte 32\n.byte 99\n.byte 104\n.byte 97\n.byte 114\n.byte 97\n.byte 99\n.byte 116\n.byte 101\n.byte 114\n.byte 105\n.byte 122\n.byte 101\n.byte 100\n.byte 32\n.byte 98\n.byte 121\n.byte 32\n.byte 97\n.byte 110\n.byte 32\n.byte 73\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 32\n.byte 110\n.byte 117\n.byte 109\n.byte 98\n.byte 101\n.byte 114\n.byte 10\n.byte 0\n.align 1\n.LC100:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 102\n.byte 117\n.byte 122\n.byte 122\n.byte 121\n.byte 44\n.byte 88\n.byte 61\n.byte 49\n.byte 32\n.byte 98\n.byte 117\n.byte 116\n.byte 32\n.byte 88\n.byte 45\n.byte 49\n.byte 47\n.byte 50\n.byte 45\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 0\n.align 1\n.LC96:\n.byte 40\n.byte 49\n.byte 45\n.byte 85\n.byte 49\n.byte 41\n.byte 45\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 60\n.byte 32\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 70\n.byte 65\n.byte 76\n.byte 83\n.byte 69\n.byte 44\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 103\n.byte 46\n.byte 32\n.byte 102\n.byte 97\n.byte 105\n.byte 108\n.byte 115\n.byte 63\n.byte 0\n.align 4\n.LC94:\n.long 0\n.long 1076101120\n.align 1\n.LC89:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 103\n.byte 111\n.byte 111\n.byte 100\n.byte 32\n.byte 97\n.byte 115\n.byte 32\n.byte 50\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 49\n.byte 48\n.byte 0\n.align 1\n.LC85:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 116\n.byte 111\n.byte 111\n.byte 32\n.byte 98\n.byte 105\n.byte 103\n.byte 58\n.byte 32\n.byte 114\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 111\n.byte 102\n.byte 102\n.byte 32\n.byte 112\n.byte 114\n.byte 111\n.byte 98\n.byte 108\n.byte 101\n.byte 109\n.byte 115\n.byte 0\n.align 1\n.LC83:\n.byte 77\n.byte 89\n.byte 83\n.byte 84\n.byte 69\n.byte 82\n.byte 89\n.byte 58\n.byte 32\n.byte 114\n.byte 101\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 101\n.byte 100\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC82:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 105\n.byte 114\n.byte 109\n.byte 101\n.byte 100\n.byte 46\n.byte 10\n.byte 0\n.align 4\n.LC79:\n.long 1202590843\n.long 1065646817\n.align 1\n.LC78:\n.byte 103\n.byte 101\n.byte 116\n.byte 115\n.byte 32\n.byte 98\n.byte 101\n.byte 116\n.byte 116\n.byte 101\n.byte 114\n.byte 32\n.byte 99\n.byte 108\n.byte 111\n.byte 115\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 114\n.byte 101\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 115\n.byte 101\n.byte 112\n.byte 97\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 85\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC77:\n.byte 99\n.byte 111\n.byte 110\n.byte 102\n.byte 105\n.byte 114\n.byte 109\n.byte 115\n.byte 32\n.byte 99\n.byte 108\n.byte 111\n.byte 115\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 114\n.byte 101\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 115\n.byte 101\n.byte 112\n.byte 97\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 85\n.byte 49\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC62:\n.byte 82\n.byte 101\n.byte 99\n.byte 97\n.byte 108\n.byte 99\n.byte 117\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 114\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 112\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 10\n.byte 32\n.byte 0\n.align 1\n.LC61:\n.byte 67\n.byte 108\n.byte 111\n.byte 115\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 114\n.byte 101\n.byte 108\n.byte 97\n.byte 116\n.byte 105\n.byte 118\n.byte 101\n.byte 32\n.byte 115\n.byte 101\n.byte 112\n.byte 97\n.byte 114\n.byte 97\n.byte 116\n.byte 105\n.byte 111\n.byte 110\n.byte 32\n.byte 102\n.byte 111\n.byte 117\n.byte 110\n.byte 100\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 85\n.byte 49\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 46\n.byte 55\n.byte 101\n.byte 32\n.byte 46\n.byte 10\n.byte 10\n.byte 0\n.align 1\n.LC55:\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 102\n.byte 32\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC46:\n.byte 83\n.byte 101\n.byte 97\n.byte 114\n.byte 99\n.byte 104\n.byte 105\n.byte 110\n.byte 103\n.byte 32\n.byte 102\n.byte 111\n.byte 114\n.byte 32\n.byte 82\n.byte 97\n.byte 100\n.byte 105\n.byte 120\n.byte 32\n.byte 97\n.byte 110\n.byte 100\n.byte 32\n.byte 80\n.byte 114\n.byte 101\n.byte 99\n.byte 105\n.byte 115\n.byte 105\n.byte 111\n.byte 110\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC45:\n.byte 10\n.byte 0\n.align 1\n.LC44:\n.byte 45\n.byte 49\n.byte 44\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 49\n.byte 47\n.byte 50\n.byte 44\n.byte 32\n.byte 49\n.byte 44\n.byte 32\n.byte 50\n.byte 44\n.byte 32\n.byte 51\n.byte 44\n.byte 32\n.byte 52\n.byte 44\n.byte 32\n.byte 53\n.byte 44\n.byte 32\n.byte 57\n.byte 44\n.byte 32\n.byte 50\n.byte 55\n.byte 44\n.byte 32\n.byte 51\n.byte 50\n.byte 32\n.byte 38\n.byte 32\n.byte 50\n.byte 52\n.byte 48\n.byte 32\n.byte 97\n.byte 114\n.byte 101\n.byte 32\n.byte 79\n.byte 46\n.byte 75\n.byte 46\n.byte 10\n.byte 0\n.align 1\n.LC39:\n.byte 53\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 52\n.byte 43\n.byte 49\n.byte 44\n.byte 32\n.byte 50\n.byte 52\n.byte 48\n.byte 47\n.byte 51\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 56\n.byte 48\n.byte 44\n.byte 32\n.byte 50\n.byte 52\n.byte 48\n.byte 47\n.byte 52\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 54\n.byte 48\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 50\n.byte 52\n.byte 48\n.byte 47\n.byte 53\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 52\n.byte 56\n.byte 0\n.align 1\n.LC35:\n.byte 57\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 51\n.byte 42\n.byte 51\n.byte 44\n.byte 32\n.byte 50\n.byte 55\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 57\n.byte 42\n.byte 51\n.byte 44\n.byte 32\n.byte 51\n.byte 50\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 56\n.byte 42\n.byte 52\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 51\n.byte 50\n.byte 45\n.byte 50\n.byte 55\n.byte 45\n.byte 52\n.byte 45\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 0\n.align 1\n.LC31:\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 43\n.byte 32\n.byte 40\n.byte 45\n.byte 49\n.byte 41\n.byte 32\n.byte 43\n.byte 32\n.byte 49\n.byte 47\n.byte 50\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 0\n.align 1\n.LC27:\n.byte 45\n.byte 49\n.byte 43\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 40\n.byte 45\n.byte 49\n.byte 41\n.byte 43\n.byte 97\n.byte 98\n.byte 115\n.byte 40\n.byte 49\n.byte 41\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 45\n.byte 49\n.byte 43\n.byte 40\n.byte 45\n.byte 49\n.byte 41\n.byte 42\n.byte 40\n.byte 45\n.byte 49\n.byte 41\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 0\n.align 1\n.LC23:\n.byte 51\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 50\n.byte 43\n.byte 49\n.byte 44\n.byte 32\n.byte 52\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 51\n.byte 43\n.byte 49\n.byte 44\n.byte 32\n.byte 52\n.byte 43\n.byte 50\n.byte 42\n.byte 40\n.byte 45\n.byte 50\n.byte 41\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 52\n.byte 45\n.byte 51\n.byte 45\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 0\n.align 4\n.LC21:\n.long -755914244\n.long 1062232653\n.align 1\n.LC20:\n.byte 67\n.byte 111\n.byte 109\n.byte 112\n.byte 97\n.byte 114\n.byte 105\n.byte 115\n.byte 111\n.byte 110\n.byte 32\n.byte 97\n.byte 108\n.byte 108\n.byte 101\n.byte 103\n.byte 101\n.byte 115\n.byte 32\n.byte 116\n.byte 104\n.byte 97\n.byte 116\n.byte 32\n.byte 45\n.byte 48\n.byte 46\n.byte 48\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 78\n.byte 111\n.byte 110\n.byte 45\n.byte 122\n.byte 101\n.byte 114\n.byte 111\n.byte 33\n.byte 10\n.byte 0\n.align 1\n.LC15:\n.byte 48\n.byte 43\n.byte 48\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 49\n.byte 45\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 49\n.byte 32\n.byte 60\n.byte 61\n.byte 32\n.byte 48\n.byte 44\n.byte 32\n.byte 111\n.byte 114\n.byte 32\n.byte 49\n.byte 43\n.byte 49\n.byte 32\n.byte 33\n.byte 61\n.byte 32\n.byte 50\n.byte 0\n.align 1\n.LC13:\n.byte 80\n.byte 114\n.byte 111\n.byte 103\n.byte 114\n.byte 97\n.byte 109\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 110\n.byte 111\n.byte 119\n.byte 32\n.byte 82\n.byte 85\n.byte 78\n.byte 78\n.byte 73\n.byte 78\n.byte 71\n.byte 32\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 115\n.byte 32\n.byte 111\n.byte 110\n.byte 32\n.byte 115\n.byte 109\n.byte 97\n.byte 108\n.byte 108\n.byte 32\n.byte 105\n.byte 110\n.byte 116\n.byte 101\n.byte 103\n.byte 101\n.byte 114\n.byte 115\n.byte 58\n.byte 10\n.byte 0\n.align 4\n.LC9:\n.long 0\n.long 1072693248\n.align 4\n.LC8:\n.long 0\n.long 0\n.align 1\n.LC3:\n.byte 10\n.byte 42\n.byte 32\n.byte 42\n.byte 32\n.byte 42\n.byte 32\n.byte 70\n.byte 76\n.byte 79\n.byte 65\n.byte 84\n.byte 73\n.byte 78\n.byte 71\n.byte 45\n.byte 80\n.byte 79\n.byte 73\n.byte 78\n.byte 84\n.byte 32\n.byte 69\n.byte 82\n.byte 82\n.byte 79\n.byte 82\n.byte 32\n.byte 42\n.byte 32\n.byte 42\n.byte 32\n.byte 42\n.byte 10\n.byte 0\n.text\n.ident \"LCC: 4.1\"\n"
  },
  {
    "path": "lcc/x86/linux/tst/sort.1bk",
    "content": "exchange(1,9)\nexchange(3,7)\nexchange(5,6)\nexchange(0,5)\nexchange(0,3)\nexchange(0,0)\nexchange(1,2)\nexchange(6,6)\nexchange(8,9)\nexchange(7,8)\n-51\n-1\n0\n1\n3\n10\n18\n32\n567\n789\n"
  },
  {
    "path": "lcc/x86/linux/tst/sort.2bk",
    "content": "tst/sort.c:23: warning: missing return value\ntst/sort.c:30: warning: missing return value\ntst/sort.c:37: warning: missing return value\ntst/sort.c:41: warning: missing return value\ntst/sort.c:65: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/linux/tst/sort.sbk",
    "content": ".data\n.globl in\n.align 4\n.type in,@object\nin:\n.long 10\n.long 32\n.long -1\n.long 567\n.long 3\n.long 18\n.long 1\n.long -51\n.long 789\n.long 0\n.size in,40\n.globl main\n.text\n.align 16\n.type main,@function\nmain:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\npushl $10\npushl $in\ncall sort\naddl $8,%esp\nmovl $0,-4(%ebp)\njmp .LC5\n.LC2:\nmovl -4(%ebp),%edi\npushl in(,%edi,4)\ncall putd\naddl $4,%esp\npushl $10\ncall putchar\naddl $4,%esp\n.LC3:\nincl -4(%ebp)\n.LC5:\nmovl -4(%ebp),%edi\ncmpl $10,%edi\njb .LC2\nmovl $0,%eax\n.LC1:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf6:\n.size main,.Lf6-main\n.globl putd\n.align 16\n.type putd,@function\nputd:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\ncmpl $0,20(%ebp)\njge .LC8\npushl $45\ncall putchar\naddl $4,%esp\nnegl 20(%ebp)\n.LC8:\nmovl 20(%ebp),%eax\nmovl $10,%ecx\ncdq\nidivl %ecx\ncmpl $0,%eax\nje .LC10\nmovl 20(%ebp),%eax\nmovl $10,%ecx\ncdq\nidivl %ecx\npushl %eax\ncall putd\naddl $4,%esp\n.LC10:\nmovl 20(%ebp),%eax\nmovl $10,%ecx\ncdq\nidivl %ecx\nleal 48(%edx),%edi\npushl %edi\ncall putchar\naddl $4,%esp\nmovl $0,%eax\n.LC7:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf12:\n.size putd,.Lf12-putd\n.globl sort\n.align 16\n.type sort,@function\nsort:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl 24(%ebp),%edi\nsubl $1,%edi\nmovl %edi,24(%ebp)\npushl %edi\npushl $0\nmovl 20(%ebp),%edi\nmovl %edi,xx\npushl %edi\ncall quick\naddl $12,%esp\nmovl $0,%eax\n.LC13:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf14:\n.size sort,.Lf14-sort\n.globl quick\n.align 16\n.type quick,@function\nquick:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\nmovl 28(%ebp),%edi\ncmpl %edi,24(%ebp)\njl .LC16\njmp .LC15\n.LC16:\npushl 28(%ebp)\npushl 24(%ebp)\npushl 20(%ebp)\ncall partition\naddl $12,%esp\nmovl %eax,-4(%ebp)\nmovl -4(%ebp),%edi\nsubl $1,%edi\npushl %edi\npushl 24(%ebp)\npushl 20(%ebp)\ncall quick\naddl $12,%esp\npushl 28(%ebp)\nmovl -4(%ebp),%edi\nleal 1(%edi),%edi\npushl %edi\npushl 20(%ebp)\ncall quick\naddl $12,%esp\nmovl $0,%eax\n.LC15:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf18:\n.size quick,.Lf18-quick\n.globl partition\n.align 16\n.type partition,@function\npartition:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $8,%esp\nincl 28(%ebp)\nmovl 24(%ebp),%edi\nmovl %edi,-8(%ebp)\nmovl -8(%ebp),%edi\nmovl 20(%ebp),%esi\nmovl (%esi,%edi,4),%edi\nmovl %edi,-4(%ebp)\njmp .LC21\n.LC20:\nincl 24(%ebp)\njmp .LC24\n.LC23:\nincl 24(%ebp)\n.LC24:\nmovl 24(%ebp),%edi\nmovl 20(%ebp),%esi\nmovl -4(%ebp),%ebx\ncmpl %ebx,(%esi,%edi,4)\njl .LC23\ndecl 28(%ebp)\njmp .LC27\n.LC26:\ndecl 28(%ebp)\n.LC27:\nmovl 28(%ebp),%edi\nmovl 20(%ebp),%esi\nmovl -4(%ebp),%ebx\ncmpl %ebx,(%esi,%edi,4)\njg .LC26\nmovl 28(%ebp),%edi\ncmpl %edi,24(%ebp)\njge .LC29\nmovl 20(%ebp),%edi\nmovl 28(%ebp),%esi\nleal (%edi,%esi,4),%esi\npushl %esi\nmovl 24(%ebp),%esi\nleal (%edi,%esi,4),%edi\npushl %edi\ncall exchange\naddl $8,%esp\n.LC29:\n.LC21:\nmovl 28(%ebp),%edi\ncmpl %edi,24(%ebp)\njl .LC20\nmovl 20(%ebp),%edi\nmovl 28(%ebp),%esi\nleal (%edi,%esi,4),%esi\npushl %esi\nmovl -8(%ebp),%esi\nleal (%edi,%esi,4),%edi\npushl %edi\ncall exchange\naddl $8,%esp\nmovl 28(%ebp),%eax\n.LC19:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf31:\n.size partition,.Lf31-partition\n.globl exchange\n.align 16\n.type exchange,@function\nexchange:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\nmovl xx,%edi\nmovl $4,%esi\nmovl 24(%ebp),%ebx\nsubl %edi,%ebx\nmovl %ebx,%eax\nmovl %esi,%ecx\ncdq\nidivl %ecx\npushl %eax\nmovl 20(%ebp),%ebx\nsubl %edi,%ebx\nmovl %ebx,%eax\nmovl %esi,%ecx\ncdq\nidivl %ecx\npushl %eax\npushl $.LC33\ncall printf\naddl $12,%esp\nmovl 20(%ebp),%edi\nmovl (,%edi),%esi\nmovl %esi,-4(%ebp)\nmovl 24(%ebp),%esi\nmovl (,%esi),%esi\nmovl %esi,(,%edi)\nmovl 24(%ebp),%edi\nmovl -4(%ebp),%esi\nmovl %esi,(,%edi)\nmovl $0,%eax\n.LC32:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf34:\n.size exchange,.Lf34-exchange\n.bss\n.globl xx\n.align 4\n.type xx,@object\n.size xx,4\n.comm xx,4\n.data\n.align 1\n.LC33:\n.byte 101\n.byte 120\n.byte 99\n.byte 104\n.byte 97\n.byte 110\n.byte 103\n.byte 101\n.byte 40\n.byte 37\n.byte 100\n.byte 44\n.byte 37\n.byte 100\n.byte 41\n.byte 10\n.byte 0\n.text\n.ident \"LCC: 4.1\"\n"
  },
  {
    "path": "lcc/x86/linux/tst/spill.1bk",
    "content": ""
  },
  {
    "path": "lcc/x86/linux/tst/spill.2bk",
    "content": "tst/spill.c:1: warning: missing return value\ntst/spill.c:3: warning: missing return value\ntst/spill.c:5: warning: missing return value\ntst/spill.c:7: warning: missing return value\ntst/spill.c:9: warning: missing return value\ntst/spill.c:17: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/linux/tst/spill.sbk",
    "content": ".globl main\n.text\n.align 16\n.type main,@function\nmain:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl $0,%eax\n.LC1:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf2:\n.size main,.Lf2-main\n.globl f\n.align 16\n.type f,@function\nf:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\ncall f\nmovl %eax,%edi\ncall f\nleal (%eax,%edi),%edi\nmovl %edi,20(%ebp)\nmovl $0,%eax\n.LC3:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf4:\n.size f,.Lf4-f\n.globl f2\n.align 16\n.type f2,@function\nf2:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\ncall f\nmovl %eax,%edi\ncmpl $0,20(%ebp)\nje .LC7\ncall f\nmovl %eax,%esi\nmovl %esi,-4(%ebp)\njmp .LC8\n.LC7:\nmovl $1,-4(%ebp)\n.LC8:\nmovl -4(%ebp),%esi\nleal (%esi,%edi),%edi\nmovl %edi,20(%ebp)\nmovl $0,%eax\n.LC5:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf9:\n.size f2,.Lf9-f2\n.globl f3\n.align 16\n.type f3,@function\nf3:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $44,%esp\nmovl $0,-4(%ebp)\nmovl $0,-8(%ebp)\nmovl $0,-12(%ebp)\nmovl $0,-16(%ebp)\nmovl $0,-20(%ebp)\nmovl $0,-24(%ebp)\nmovl $0,-28(%ebp)\nmovl $0,-32(%ebp)\nmovl $0,-36(%ebp)\nmovl $0,-40(%ebp)\nmovl 24(%ebp),%edi\nleal 4(%edi),%esi\nmovl %esi,24(%ebp)\ncmpl $0,20(%ebp)\nje .LC12\ncall f\nmovl %eax,%esi\nmovl %esi,-44(%ebp)\njmp .LC13\n.LC12:\nmovl $0,-44(%ebp)\n.LC13:\nmovl -44(%ebp),%esi\nmovl %esi,(,%edi)\nmovl $0,%eax\n.LC10:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf14:\n.size f3,.Lf14-f3\n.globl f4\n.align 16\n.type f4,@function\nf4:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $52,%esp\nmovl $0,-4(%ebp)\nmovl $0,-8(%ebp)\nmovl $0,-12(%ebp)\nmovl $0,-16(%ebp)\nmovl $0,-20(%ebp)\nmovl $0,-24(%ebp)\nmovl i,%edi\nleal (,%edi,8),%esi\nfldl a(%esi)\nfstpl -36(%ebp)\nfldl b(%esi)\nfstpl -44(%ebp)\nfldl -36(%ebp)\nfaddl -44(%ebp)\nfldl .LC19\nfcompp\nfstsw %ax\nsahf\nje .LC17\ncmpl $0,%edi\nje .LC17\nfldl -36(%ebp)\nfsubl -44(%ebp)\nfldl .LC19\nfcompp\nfstsw %ax\nsahf\nje .LC17\nmovl $1,-28(%ebp)\njmp .LC18\n.LC17:\nmovl $0,-28(%ebp)\n.LC18:\nmovl -28(%ebp),%edi\nmovl %edi,i\nmovl $0,%eax\n.LC15:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf20:\n.size f4,.Lf20-f4\n.globl f5\n.align 16\n.type f5,@function\nf5:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl k,%edi\nmovl m,%esi\nmovl A,%ebx\nmovl %edi,%edx\nimull %esi,%edx\nleal (%ebx,%edx,8),%edx\nmovl j,%ecx\nmovl %ecx,%eax\nimull %esi,%eax\nleal (%ebx,%eax,8),%esi\nmovl n,%ebx\nmovl B,%eax\nimull %ebx,%edi\nleal (%eax,%edi,8),%edi\nimull %ebx,%ecx\nleal (%eax,%ecx,8),%ebx\nfldl (,%edx)\nfmull (,%esi)\nfldl (,%edi)\nfmull (,%ebx)\nfaddp %st(1),%st\nfstpl x\nfldl (,%edx)\nfmull (,%ebx)\nfldl (,%edi)\nfmull (,%esi)\nfsubp %st(1),%st\nfstpl x\nmovl $0,%eax\n.LC21:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf22:\n.size f5,.Lf22-f5\n.bss\n.globl x\n.align 4\n.type x,@object\n.size x,8\n.comm x,8\n.globl B\n.align 4\n.type B,@object\n.size B,4\n.comm B,4\n.globl A\n.align 4\n.type A,@object\n.size A,4\n.comm A,4\n.globl n\n.align 4\n.type n,@object\n.size n,4\n.comm n,4\n.globl m\n.align 4\n.type m,@object\n.size m,4\n.comm m,4\n.globl k\n.align 4\n.type k,@object\n.size k,4\n.comm k,4\n.globl j\n.align 4\n.type j,@object\n.size j,4\n.comm j,4\n.globl i\n.align 4\n.type i,@object\n.size i,4\n.comm i,4\n.globl b\n.align 4\n.type b,@object\n.size b,80\n.comm b,80\n.globl a\n.align 4\n.type a,@object\n.size a,80\n.comm a,80\n.data\n.align 4\n.LC19:\n.long 0\n.long 0\n.text\n.ident \"LCC: 4.1\"\n"
  },
  {
    "path": "lcc/x86/linux/tst/stdarg.1bk",
    "content": "test 1\ntest 2\ntest 3\ntest 4\ntest 5.000000\n{1 2 3 4} {1 2 3 4} {1 2 3 4} {1 2 3 4} {1 2 3 4} {1 2 3 4}\n"
  },
  {
    "path": "lcc/x86/linux/tst/stdarg.2bk",
    "content": "tst/stdarg.c:51: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/linux/tst/stdarg.sbk",
    "content": ".data\n.globl x\n.align 4\n.type x,@object\n.size x,16\nx:\n.long 1\n.long 2\n.long 3\n.long 4\n.globl main\n.text\n.align 16\n.type main,@function\nmain:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $8,%esp\npushl $.LC2\ncall print\naddl $4,%esp\npushl $.LC4\npushl $.LC3\ncall print\naddl $8,%esp\npushl $10\npushl $3\npushl $.LC5\ncall print\naddl $12,%esp\npushl $10\npushl $4\npushl $.LC8\npushl $.LC7\npushl $.LC6\ncall print\naddl $20,%esp\npushl $10\nfldl .LC10\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC8\npushl $.LC7\npushl $.LC9\ncall print\naddl $24,%esp\nleal x,%edi\nmovl %edi,-8(%ebp)\nmovl %edi,%esi\nmovl %esi,-4(%ebp)\nsubl $16,%esp\nmovl %esp,%edi\nmovl $16,%ecx\nrep\nmovsb\nmovl -8(%ebp),%edi\nmovl %edi,%esi\nsubl $16,%esp\nmovl %esp,%edi\nmovl $16,%ecx\nrep\nmovsb\nmovl -8(%ebp),%edi\nmovl %edi,%esi\nsubl $16,%esp\nmovl %esp,%edi\nmovl $16,%ecx\nrep\nmovsb\nmovl -8(%ebp),%edi\nmovl %edi,%esi\nsubl $16,%esp\nmovl %esp,%edi\nmovl $16,%ecx\nrep\nmovsb\nmovl -8(%ebp),%edi\nmovl %edi,%esi\nsubl $16,%esp\nmovl %esp,%edi\nmovl $16,%ecx\nrep\nmovsb\nmovl -8(%ebp),%edi\nmovl %edi,%esi\nsubl $16,%esp\nmovl %esp,%edi\nmovl $16,%ecx\nrep\nmovsb\npushl $.LC11\ncall print\naddl $100,%esp\nmovl $0,%eax\n.LC1:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf12:\n.size main,.Lf12-main\n.globl print\n.align 16\n.type print,@function\nprint:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $28,%esp\nleal 24(%ebp),%edi\nmovl %edi,-4(%ebp)\njmp .LC19\n.LC16:\nmovl 20(%ebp),%edi\nmovsbl (,%edi),%edi\ncmpl $37,%edi\njne .LC20\nmovl 20(%ebp),%edi\nleal 1(%edi),%edi\nmovl %edi,20(%ebp)\nmovsbl (,%edi),%edi\nmovl %edi,-8(%ebp)\nmovl -8(%ebp),%edi\ncmpl $115,%edi\nje .LC36\ncmpl $115,%edi\njg .LC41\n.LC40:\nmovl -8(%ebp),%edi\ncmpl $98,%edi\njl .LC22\ncmpl $102,%edi\njg .LC22\njmp *.LC42-392(,%edi,4)\n.data\n.align 4\n.LC42:\n.long .LC25\n.long .LC30\n.long .LC32\n.long .LC22\n.long .LC38\n.text\n.LC41:\ncmpl $119,-8(%ebp)\nje .LC34\njmp .LC22\n.LC25:\nmovl -4(%ebp),%edi\nleal 16(%edi),%edi\nmovl %edi,-28(%ebp)\nmovl %edi,-4(%ebp)\nleal -24(%ebp),%edi\nmovl -28(%ebp),%esi\nleal -16(%esi),%esi\nmovl $16,%ecx\nrep\nmovsb\npushl -12(%ebp)\npushl -16(%ebp)\npushl -20(%ebp)\npushl -24(%ebp)\npushl $.LC26\ncall printf\naddl $20,%esp\njmp .LC21\n.LC30:\nmovl -4(%ebp),%edi\nleal 4(%edi),%edi\nmovl %edi,-4(%ebp)\nmovsbl -4(%edi),%edi\npushl %edi\npushl $.LC31\ncall printf\naddl $8,%esp\njmp .LC21\n.LC32:\nmovl -4(%ebp),%edi\nleal 4(%edi),%edi\nmovl %edi,-4(%ebp)\npushl -4(%edi)\npushl $.LC33\ncall printf\naddl $8,%esp\njmp .LC21\n.LC34:\nmovl -4(%ebp),%edi\nleal 4(%edi),%edi\nmovl %edi,-4(%ebp)\nmovswl -4(%edi),%edi\npushl %edi\npushl $.LC35\ncall printf\naddl $8,%esp\njmp .LC21\n.LC36:\nmovl -4(%ebp),%edi\nleal 4(%edi),%edi\nmovl %edi,-4(%ebp)\npushl -4(%edi)\npushl $.LC37\ncall printf\naddl $8,%esp\njmp .LC21\n.LC38:\nmovl -4(%ebp),%edi\nleal 8(%edi),%edi\nmovl %edi,-4(%ebp)\nfldl -8(%edi)\nsubl $8,%esp\nfstpl (%esp)\npushl $.LC39\ncall printf\naddl $12,%esp\njmp .LC21\n.LC22:\nmovl 20(%ebp),%edi\nmovsbl (,%edi),%edi\npushl %edi\npushl $.LC31\ncall printf\naddl $8,%esp\njmp .LC21\n.LC20:\nmovl 20(%ebp),%edi\nmovsbl (,%edi),%edi\npushl %edi\npushl $.LC31\ncall printf\naddl $8,%esp\n.LC21:\n.LC17:\nincl 20(%ebp)\n.LC19:\nmovl 20(%ebp),%edi\nmovsbl (,%edi),%edi\ncmpl $0,%edi\njne .LC16\nmovl $0,%eax\n.LC13:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf44:\n.size print,.Lf44-print\n.data\n.align 1\n.LC39:\n.byte 37\n.byte 102\n.byte 0\n.align 1\n.LC37:\n.byte 37\n.byte 115\n.byte 0\n.align 1\n.LC35:\n.byte 37\n.byte 120\n.byte 0\n.align 1\n.LC33:\n.byte 37\n.byte 100\n.byte 0\n.align 1\n.LC31:\n.byte 37\n.byte 99\n.byte 0\n.align 1\n.LC26:\n.byte 123\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 125\n.byte 0\n.align 1\n.LC11:\n.byte 37\n.byte 98\n.byte 32\n.byte 37\n.byte 98\n.byte 32\n.byte 37\n.byte 98\n.byte 32\n.byte 37\n.byte 98\n.byte 32\n.byte 37\n.byte 98\n.byte 32\n.byte 37\n.byte 98\n.byte 10\n.byte 0\n.align 4\n.LC10:\n.long 0\n.long 1075052544\n.align 1\n.LC9:\n.byte 37\n.byte 115\n.byte 37\n.byte 115\n.byte 32\n.byte 37\n.byte 102\n.byte 37\n.byte 99\n.byte 0\n.align 1\n.LC8:\n.byte 115\n.byte 116\n.byte 0\n.align 1\n.LC7:\n.byte 116\n.byte 101\n.byte 0\n.align 1\n.LC6:\n.byte 37\n.byte 115\n.byte 37\n.byte 115\n.byte 32\n.byte 37\n.byte 119\n.byte 37\n.byte 99\n.byte 0\n.align 1\n.LC5:\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 37\n.byte 100\n.byte 37\n.byte 99\n.byte 0\n.align 1\n.LC4:\n.byte 50\n.byte 0\n.align 1\n.LC3:\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.LC2:\n.byte 116\n.byte 101\n.byte 115\n.byte 116\n.byte 32\n.byte 49\n.byte 10\n.byte 0\n.text\n.ident \"LCC: 4.1\"\n"
  },
  {
    "path": "lcc/x86/linux/tst/struct.1bk",
    "content": "(-1,-1) is not within [10,10; 310,310]\n(1,1) is not within [10,10; 310,310]\n(20,300) is within [10,10; 310,310]\n(500,400) is not within [10,10; 310,310]\nab\n"
  },
  {
    "path": "lcc/x86/linux/tst/struct.2bk",
    "content": "tst/struct.c:49: warning: missing return value\ntst/struct.c:68: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/linux/tst/struct.sbk",
    "content": ".globl addpoint\n.text\n.align 16\n.type addpoint,@function\naddpoint:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl 32(%ebp),%edi\naddl %edi,24(%ebp)\nmovl 36(%ebp),%edi\naddl %edi,28(%ebp)\nmovl 20(%ebp),%edi\nleal 24(%ebp),%esi\nmovl $8,%ecx\nrep\nmovsb\n.LC1:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf5:\n.size addpoint,.Lf5-addpoint\n.globl canonrect\n.align 16\n.type canonrect,@function\ncanonrect:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $32,%esp\nmovl 32(%ebp),%edi\ncmpl %edi,24(%ebp)\njge .LC11\nmovl 24(%ebp),%edi\nmovl %edi,-20(%ebp)\njmp .LC12\n.LC11:\nmovl 32(%ebp),%edi\nmovl %edi,-20(%ebp)\n.LC12:\nmovl -20(%ebp),%edi\nmovl %edi,-16(%ebp)\nmovl 36(%ebp),%edi\ncmpl %edi,28(%ebp)\njge .LC21\nmovl 28(%ebp),%edi\nmovl %edi,-24(%ebp)\njmp .LC22\n.LC21:\nmovl 36(%ebp),%edi\nmovl %edi,-24(%ebp)\n.LC22:\nmovl -24(%ebp),%edi\nmovl %edi,-12(%ebp)\nmovl 32(%ebp),%edi\ncmpl %edi,24(%ebp)\njle .LC27\nmovl 24(%ebp),%edi\nmovl %edi,-28(%ebp)\njmp .LC28\n.LC27:\nmovl 32(%ebp),%edi\nmovl %edi,-28(%ebp)\n.LC28:\nmovl -28(%ebp),%edi\nmovl %edi,-8(%ebp)\nmovl 36(%ebp),%edi\ncmpl %edi,28(%ebp)\njle .LC38\nmovl 28(%ebp),%edi\nmovl %edi,-32(%ebp)\njmp .LC39\n.LC38:\nmovl 36(%ebp),%edi\nmovl %edi,-32(%ebp)\n.LC39:\nmovl -32(%ebp),%edi\nmovl %edi,-4(%ebp)\nmovl 20(%ebp),%edi\nleal -16(%ebp),%esi\nmovl $16,%ecx\nrep\nmovsb\n.LC6:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf40:\n.size canonrect,.Lf40-canonrect\n.globl makepoint\n.align 16\n.type makepoint,@function\nmakepoint:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $8,%esp\nmovl 24(%ebp),%edi\nmovl %edi,-8(%ebp)\nmovl 28(%ebp),%edi\nmovl %edi,-4(%ebp)\nmovl 20(%ebp),%edi\nleal -8(%ebp),%esi\nmovl $8,%ecx\nrep\nmovsb\n.LC41:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf44:\n.size makepoint,.Lf44-makepoint\n.globl makerect\n.align 16\n.type makerect,@function\nmakerect:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $16,%esp\nleal -16(%ebp),%edi\nleal 24(%ebp),%esi\nmovl $8,%ecx\nrep\nmovsb\nleal -8(%ebp),%edi\nleal 32(%ebp),%esi\nmovl $8,%ecx\nrep\nmovsb\nleal -16(%ebp),%esi\nsubl $16,%esp\nmovl %esp,%edi\nmovl $16,%ecx\nrep\nmovsb\npushl 20(%ebp)\ncall canonrect\naddl $20,%esp\n.LC45:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf48:\n.size makerect,.Lf48-makerect\n.globl ptinrect\n.align 16\n.type ptinrect,@function\nptinrect:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\nmovl 20(%ebp),%edi\ncmpl 28(%ebp),%edi\njl .LC57\ncmpl 36(%ebp),%edi\njge .LC57\nmovl 32(%ebp),%edi\ncmpl %edi,24(%ebp)\njl .LC57\nmovl 40(%ebp),%edi\ncmpl %edi,24(%ebp)\njge .LC57\nmovl $1,-4(%ebp)\njmp .LC58\n.LC57:\nmovl $0,-4(%ebp)\n.LC58:\nmovl -4(%ebp),%eax\n.LC49:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf59:\n.size ptinrect,.Lf59-ptinrect\n.data\n.globl y\n.align 4\n.type y,@object\n.size y,4\ny:\n.byte 97\n.byte 98\n.byte 0\n.space 1\n.globl odd\n.text\n.align 16\n.type odd,@function\nodd:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\nleal -4(%ebp),%edi\nleal 20(%ebp),%esi\nmovl $4,%ecx\nrep\nmovsb\nleal -4(%ebp),%edi\npushl %edi\npushl $.LC61\ncall printf\naddl $8,%esp\nmovl $0,%eax\n.LC60:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf62:\n.size odd,.Lf62-odd\n.data\n.align 4\n.LC64:\n.long 0\n.long 0\n.align 4\n.LC65:\n.long 320\n.long 320\n.align 4\n.LC66:\n.long -1\n.long -1\n.long 1\n.long 1\n.long 20\n.long 300\n.long 500\n.long 400\n.globl main\n.text\n.align 16\n.type main,@function\nmain:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $108,%esp\nleal -68(%ebp),%edi\nleal .LC64,%esi\nmovl $8,%ecx\nrep\nmovsb\nleal -76(%ebp),%edi\nleal .LC65,%esi\nmovl $8,%ecx\nrep\nmovsb\nleal -36(%ebp),%edi\nleal .LC66,%esi\nmovl $32,%ecx\nrep\nmovsb\npushl $-10\npushl $-10\nleal -84(%ebp),%edi\npushl %edi\ncall makepoint\naddl $12,%esp\nleal -84(%ebp),%esi\nsubl $8,%esp\nmovl %esp,%edi\nmovl $8,%ecx\nrep\nmovsb\nleal -76(%ebp),%esi\nsubl $8,%esp\nmovl %esp,%edi\nmovl $8,%ecx\nrep\nmovsb\nleal -92(%ebp),%edi\npushl %edi\ncall addpoint\naddl $20,%esp\npushl $10\npushl $10\nleal -100(%ebp),%edi\npushl %edi\ncall makepoint\naddl $12,%esp\nleal -100(%ebp),%esi\nsubl $8,%esp\nmovl %esp,%edi\nmovl $8,%ecx\nrep\nmovsb\nleal -68(%ebp),%esi\nsubl $8,%esp\nmovl %esp,%edi\nmovl $8,%ecx\nrep\nmovsb\nleal -108(%ebp),%edi\npushl %edi\ncall addpoint\naddl $20,%esp\nleal -108(%ebp),%esi\nsubl $8,%esp\nmovl %esp,%edi\nmovl $8,%ecx\nrep\nmovsb\nleal -92(%ebp),%esi\nsubl $8,%esp\nmovl %esp,%edi\nmovl $8,%ecx\nrep\nmovsb\nleal -52(%ebp),%edi\npushl %edi\ncall makerect\naddl $20,%esp\nmovl $0,-4(%ebp)\njmp .LC70\n.LC67:\nmovl -4(%ebp),%edi\nleal (,%edi,8),%edi\nleal -32(%ebp),%esi\npushl (%esi,%edi)\nleal -36(%ebp),%esi\npushl (%esi,%edi)\nleal -60(%ebp),%edi\npushl %edi\ncall makepoint\naddl $12,%esp\npushl -56(%ebp)\nmovl -4(%ebp),%edi\nleal -36(%ebp),%esi\npushl (%esi,%edi,8)\npushl $.LC71\ncall printf\naddl $12,%esp\nleal -52(%ebp),%esi\nsubl $16,%esp\nmovl %esp,%edi\nmovl $16,%ecx\nrep\nmovsb\nleal -60(%ebp),%esi\nsubl $8,%esp\nmovl %esp,%edi\nmovl $8,%ecx\nrep\nmovsb\ncall ptinrect\naddl $24,%esp\ncmpl $0,%eax\njne .LC74\npushl $.LC76\ncall printf\naddl $4,%esp\n.LC74:\npushl -40(%ebp)\npushl -44(%ebp)\npushl -48(%ebp)\npushl -52(%ebp)\npushl $.LC77\ncall printf\naddl $20,%esp\n.LC68:\nincl -4(%ebp)\n.LC70:\nmovl -4(%ebp),%edi\ncmpl $4,%edi\njb .LC67\nleal y,%esi\nsubl $4,%esp\nmovl %esp,%edi\nmovl $4,%ecx\nrep\nmovsb\ncall odd\naddl $4,%esp\npushl $0\ncall exit\naddl $4,%esp\nmovl $0,%eax\n.LC63:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf82:\n.size main,.Lf82-main\n.data\n.align 1\n.LC77:\n.byte 119\n.byte 105\n.byte 116\n.byte 104\n.byte 105\n.byte 110\n.byte 32\n.byte 91\n.byte 37\n.byte 100\n.byte 44\n.byte 37\n.byte 100\n.byte 59\n.byte 32\n.byte 37\n.byte 100\n.byte 44\n.byte 37\n.byte 100\n.byte 93\n.byte 10\n.byte 0\n.align 1\n.LC76:\n.byte 110\n.byte 111\n.byte 116\n.byte 32\n.byte 0\n.align 1\n.LC71:\n.byte 40\n.byte 37\n.byte 100\n.byte 44\n.byte 37\n.byte 100\n.byte 41\n.byte 32\n.byte 105\n.byte 115\n.byte 32\n.byte 0\n.align 1\n.LC61:\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.text\n.ident \"LCC: 4.1\"\n"
  },
  {
    "path": "lcc/x86/linux/tst/switch.1bk",
    "content": "b = 0x8\nf = 0xc\nn = 0xa\nr = 0xd\nt = 0x9\nv = 0xb\nx = 0x78\nf:\nx = 0\nx = 1\nx = 2\nx = 2\nx = 2\nx = 2\nx = 2\nx = 7\nx = 8\nx = 9\nx = 9\nx = 9\nx = 9\nx = 9\nx = 9\nx = 9\nx = 16\nx = 17\nx = 18\nx = 19\nx = 20\ng:\n1 1\n1 2\n2 3\n2 4\n2 5\n3 6\nd 6\n3 7\nd 7\n3 8\nd 8\nd 9\nd 10\nh:\ni = 8\ni = 16\ni = 120\ni = 128\ni = 248\ni = 264\ni = 272\ni = 280\ni = 288\ni = 296\ni = 304\ni = 312\n488 defaults\nx = 0x1000000\nx = 0x2000000\nx = 0x3000000\nx = 0x4000000\nx = 0x5000000\nx = 0x6000000 (default)\nx = 0x7000000 (default)\n0\n1\n2\n3\n4\n5\n0\n1\n2\n3\n4\n5\n"
  },
  {
    "path": "lcc/x86/linux/tst/switch.2bk",
    "content": "tst/switch.c:55: warning: missing return value\ntst/switch.c:73: warning: missing return value\ntst/switch.c:97: warning: missing return value\ntst/switch.c:112: warning: missing return value\ntst/switch.c:137: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/linux/tst/switch.sbk",
    "content": ".globl main\n.text\n.align 16\n.type main,@function\nmain:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $8,%esp\nleal .LC6,%edi\nmovl %edi,-4(%ebp)\njmp .LC5\n.LC2:\nmovl -4(%ebp),%edi\nmovsbl (,%edi),%edi\npushl %edi\ncall backslash\naddl $4,%esp\npushl %eax\nmovl -4(%ebp),%edi\nmovsbl (,%edi),%edi\npushl %edi\npushl $.LC7\ncall printf\naddl $12,%esp\n.LC3:\nincl -4(%ebp)\n.LC5:\nmovl -4(%ebp),%edi\nmovsbl (,%edi),%edi\ncmpl $0,%edi\njne .LC2\ncall f\ncall g\ncall h\nmovl $16777216,-8(%ebp)\njmp .LC11\n.LC8:\npushl -8(%ebp)\ncall big\naddl $4,%esp\n.LC9:\naddl $16777216,-8(%ebp)\n.LC11:\nmovl -8(%ebp),%edi\nandl $117440512,%edi\ncmpl $0,%edi\njne .LC8\ncall limit\nmovl $0,%eax\n.LC1:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf12:\n.size main,.Lf12-main\n.globl backslash\n.align 16\n.type backslash,@function\nbackslash:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl 20(%ebp),%edi\ncmpl $102,%edi\nje .LC17\ncmpl $102,%edi\njg .LC23\n.LC22:\ncmpl $98,20(%ebp)\nje .LC16\njmp .LC14\n.LC23:\nmovl 20(%ebp),%edi\ncmpl $110,%edi\nje .LC18\ncmpl $110,%edi\njl .LC14\n.LC24:\nmovl 20(%ebp),%edi\ncmpl $114,%edi\nje .LC19\ncmpl $116,%edi\nje .LC20\ncmpl $118,%edi\nje .LC21\njmp .LC14\n.LC16:\nmovl $8,%eax\njmp .LC13\n.LC17:\nmovl $12,%eax\njmp .LC13\n.LC18:\nmovl $10,%eax\njmp .LC13\n.LC19:\nmovl $13,%eax\njmp .LC13\n.LC20:\nmovl $9,%eax\njmp .LC13\n.LC21:\nmovl $11,%eax\njmp .LC13\n.LC14:\nmovl 20(%ebp),%eax\n.LC13:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf25:\n.size backslash,.Lf25-backslash\n.globl f\n.align 16\n.type f,@function\nf:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $12,%esp\nmovl $0,-8(%ebp)\npushl $.LC27\ncall printf\naddl $4,%esp\nmovl $0,-4(%ebp)\n.LC28:\nmovl -4(%ebp),%edi\nmovl %edi,-12(%ebp)\nmovl -4(%ebp),%edi\ncmpl $1,%edi\njl .LC32\ncmpl $20,%edi\njg .LC32\njmp *.LC44-4(,%edi,4)\n.data\n.align 4\n.LC44:\n.long .LC34\n.long .LC35\n.long .LC32\n.long .LC32\n.long .LC32\n.long .LC32\n.long .LC36\n.long .LC37\n.long .LC38\n.long .LC32\n.long .LC32\n.long .LC32\n.long .LC32\n.long .LC32\n.long .LC32\n.long .LC39\n.long .LC40\n.long .LC41\n.long .LC42\n.long .LC43\n.text\n.LC34:\nmovl -4(%ebp),%edi\nmovl %edi,-8(%ebp)\njmp .LC33\n.LC35:\nmovl -4(%ebp),%edi\nmovl %edi,-8(%ebp)\njmp .LC33\n.LC36:\nmovl -4(%ebp),%edi\nmovl %edi,-8(%ebp)\njmp .LC33\n.LC37:\nmovl -4(%ebp),%edi\nmovl %edi,-8(%ebp)\njmp .LC33\n.LC38:\nmovl -4(%ebp),%edi\nmovl %edi,-8(%ebp)\njmp .LC33\n.LC39:\nmovl -4(%ebp),%edi\nmovl %edi,-8(%ebp)\njmp .LC33\n.LC40:\nmovl -4(%ebp),%edi\nmovl %edi,-8(%ebp)\njmp .LC33\n.LC41:\nmovl -4(%ebp),%edi\nmovl %edi,-8(%ebp)\njmp .LC33\n.LC42:\nmovl -4(%ebp),%edi\nmovl %edi,-8(%ebp)\njmp .LC33\n.LC43:\nmovl -4(%ebp),%edi\nmovl %edi,-8(%ebp)\n.LC32:\n.LC33:\npushl -8(%ebp)\npushl $.LC46\ncall printf\naddl $8,%esp\n.LC29:\nincl -4(%ebp)\ncmpl $20,-4(%ebp)\njle .LC28\nmovl $0,%eax\n.LC26:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf47:\n.size f,.Lf47-f\n.globl g\n.align 16\n.type g,@function\ng:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\npushl $.LC49\ncall printf\naddl $4,%esp\nmovl $1,-4(%ebp)\n.LC50:\nmovl -4(%ebp),%edi\ncmpl $1001,%edi\njl .LC67\ncmpl $1004,%edi\njg .LC68\njmp *.LC69-4004(,%edi,4)\n.data\n.align 4\n.LC69:\n.long .LC63\n.long .LC63\n.long .LC63\n.long .LC63\n.text\n.LC67:\nmovl -4(%ebp),%edi\ncmpl $1,%edi\njl .LC54\ncmpl $8,%edi\njg .LC54\njmp *.LC71-4(,%edi,4)\n.data\n.align 4\n.LC71:\n.long .LC56\n.long .LC56\n.long .LC58\n.long .LC58\n.long .LC58\n.long .LC60\n.long .LC60\n.long .LC60\n.text\n.LC68:\nmovl -4(%ebp),%edi\ncmpl $3001,%edi\njl .LC54\ncmpl $3004,%edi\njg .LC54\njmp *.LC73-12004(,%edi,4)\n.data\n.align 4\n.LC73:\n.long .LC65\n.long .LC65\n.long .LC65\n.long .LC65\n.text\n.LC56:\npushl -4(%ebp)\npushl $.LC57\ncall printf\naddl $8,%esp\njmp .LC55\n.LC58:\npushl -4(%ebp)\npushl $.LC59\ncall printf\naddl $8,%esp\njmp .LC55\n.LC60:\npushl -4(%ebp)\npushl $.LC61\ncall printf\naddl $8,%esp\n.LC54:\npushl -4(%ebp)\npushl $.LC62\ncall printf\naddl $8,%esp\njmp .LC55\n.LC63:\npushl -4(%ebp)\npushl $.LC64\ncall printf\naddl $8,%esp\njmp .LC55\n.LC65:\npushl -4(%ebp)\npushl $.LC66\ncall printf\naddl $8,%esp\n.LC55:\n.LC51:\nincl -4(%ebp)\ncmpl $10,-4(%ebp)\njle .LC50\nmovl $0,%eax\n.LC48:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf75:\n.size g,.Lf75-g\n.globl h\n.align 16\n.type h,@function\nh:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $8,%esp\nmovl $0,-8(%ebp)\npushl $.LC77\ncall printf\naddl $4,%esp\nmovl $1,-4(%ebp)\n.LC78:\nmovl -4(%ebp),%edi\ncmpl $264,%edi\nje .LC90\ncmpl $264,%edi\njg .LC98\n.LC97:\nmovl -4(%ebp),%edi\ncmpl $120,%edi\nje .LC88\ncmpl $120,%edi\njg .LC100\n.LC99:\nmovl -4(%ebp),%edi\ncmpl $8,%edi\nje .LC87\ncmpl $8,%edi\njl .LC82\n.LC101:\ncmpl $16,-4(%ebp)\nje .LC86\njmp .LC82\n.LC100:\nmovl -4(%ebp),%edi\ncmpl $128,%edi\nje .LC84\ncmpl $128,%edi\njl .LC82\n.LC102:\ncmpl $248,-4(%ebp)\nje .LC91\njmp .LC82\n.LC98:\nmovl -4(%ebp),%edi\ncmpl $288,%edi\nje .LC95\ncmpl $288,%edi\njg .LC104\n.LC103:\nmovl -4(%ebp),%edi\ncmpl $272,%edi\nje .LC92\ncmpl $272,%edi\njl .LC82\n.LC105:\ncmpl $280,-4(%ebp)\nje .LC89\njmp .LC82\n.LC104:\nmovl -4(%ebp),%edi\ncmpl $304,%edi\nje .LC93\ncmpl $304,%edi\njg .LC107\n.LC106:\ncmpl $296,-4(%ebp)\nje .LC94\njmp .LC82\n.LC107:\ncmpl $312,-4(%ebp)\nje .LC96\njmp .LC82\n.LC82:\nincl -8(%ebp)\njmp .LC79\n.LC84:\npushl -4(%ebp)\npushl $.LC85\ncall printf\naddl $8,%esp\njmp .LC83\n.LC86:\npushl -4(%ebp)\npushl $.LC85\ncall printf\naddl $8,%esp\njmp .LC83\n.LC87:\npushl -4(%ebp)\npushl $.LC85\ncall printf\naddl $8,%esp\njmp .LC83\n.LC88:\npushl -4(%ebp)\npushl $.LC85\ncall printf\naddl $8,%esp\njmp .LC83\n.LC89:\npushl -4(%ebp)\npushl $.LC85\ncall printf\naddl $8,%esp\njmp .LC83\n.LC90:\npushl -4(%ebp)\npushl $.LC85\ncall printf\naddl $8,%esp\njmp .LC83\n.LC91:\npushl -4(%ebp)\npushl $.LC85\ncall printf\naddl $8,%esp\njmp .LC83\n.LC92:\npushl -4(%ebp)\npushl $.LC85\ncall printf\naddl $8,%esp\njmp .LC83\n.LC93:\npushl -4(%ebp)\npushl $.LC85\ncall printf\naddl $8,%esp\njmp .LC83\n.LC94:\npushl -4(%ebp)\npushl $.LC85\ncall printf\naddl $8,%esp\njmp .LC83\n.LC95:\npushl -4(%ebp)\npushl $.LC85\ncall printf\naddl $8,%esp\njmp .LC83\n.LC96:\npushl -4(%ebp)\npushl $.LC85\ncall printf\naddl $8,%esp\n.LC83:\n.LC79:\nincl -4(%ebp)\ncmpl $500,-4(%ebp)\njle .LC78\npushl -8(%ebp)\npushl $.LC108\ncall printf\naddl $8,%esp\nmovl $0,%eax\n.LC76:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf109:\n.size h,.Lf109-h\n.globl big\n.align 16\n.type big,@function\nbig:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\nmovl 20(%ebp),%edi\nandl $0x6000000,%edi\nmovl %edi,-4(%ebp)\nmovl -4(%ebp),%edi\ncmpl $33554432,%edi\nje .LC116\ncmpl $33554432,%edi\njg .LC120\n.LC119:\nmovl -4(%ebp),%edi\ncmpl $-2,%edi\nje .LC114\ncmpl $-1,%edi\nje .LC114\ncmpl $0,%edi\nje .LC114\njmp .LC111\n.LC120:\nmovl -4(%ebp),%edi\ncmpl $67108864,%edi\nje .LC117\njmp .LC111\n.LC114:\npushl 20(%ebp)\npushl $.LC115\ncall printf\naddl $8,%esp\njmp .LC112\n.LC116:\npushl 20(%ebp)\npushl $.LC115\ncall printf\naddl $8,%esp\njmp .LC112\n.LC117:\npushl 20(%ebp)\npushl $.LC115\ncall printf\naddl $8,%esp\njmp .LC112\n.LC111:\npushl 20(%ebp)\npushl $.LC118\ncall printf\naddl $8,%esp\n.LC112:\nmovl $0,%eax\n.LC110:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf121:\n.size big,.Lf121-big\n.globl limit\n.align 16\n.type limit,@function\nlimit:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\nmovl $-2147483648,-4(%ebp)\n.LC123:\nmovl -4(%ebp),%edi\nmovl $-2147483648,%esi\ncmpl $-2147483648,%edi\njl .LC127\ncmpl $-2147483644,%edi\njg .LC127\nleal (,%edi,4),%edi\nleal (,%esi,4),%esi\nsubl %esi,%edi\njmp *.LC140(%edi)\n.data\n.align 4\n.LC140:\n.long .LC129\n.long .LC131\n.long .LC133\n.long .LC135\n.long .LC137\n.text\n.LC129:\npushl $.LC130\ncall printf\naddl $4,%esp\njmp .LC128\n.LC131:\npushl $.LC132\ncall printf\naddl $4,%esp\njmp .LC128\n.LC133:\npushl $.LC134\ncall printf\naddl $4,%esp\njmp .LC128\n.LC135:\npushl $.LC136\ncall printf\naddl $4,%esp\njmp .LC128\n.LC137:\npushl $.LC138\ncall printf\naddl $4,%esp\njmp .LC128\n.LC127:\npushl $.LC139\ncall printf\naddl $4,%esp\n.LC128:\n.LC124:\nincl -4(%ebp)\ncmpl $-2147483643,-4(%ebp)\njle .LC123\nmovl $2147483647,-4(%ebp)\n.LC141:\nmovl -4(%ebp),%edi\nmovl $2147483643,%esi\ncmpl $2147483643,%edi\njl .LC145\ncmpl $2147483647,%edi\njg .LC145\nleal (,%edi,4),%edi\nleal (,%esi,4),%esi\nsubl %esi,%edi\njmp *.LC152(%edi)\n.data\n.align 4\n.LC152:\n.long .LC151\n.long .LC150\n.long .LC149\n.long .LC148\n.long .LC147\n.text\n.LC147:\npushl $.LC130\ncall printf\naddl $4,%esp\njmp .LC146\n.LC148:\npushl $.LC132\ncall printf\naddl $4,%esp\njmp .LC146\n.LC149:\npushl $.LC134\ncall printf\naddl $4,%esp\njmp .LC146\n.LC150:\npushl $.LC136\ncall printf\naddl $4,%esp\njmp .LC146\n.LC151:\npushl $.LC138\ncall printf\naddl $4,%esp\njmp .LC146\n.LC145:\npushl $.LC139\ncall printf\naddl $4,%esp\n.LC146:\n.LC142:\ndecl -4(%ebp)\ncmpl $2147483642,-4(%ebp)\njge .LC141\nmovl $0,%eax\n.LC122:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf153:\n.size limit,.Lf153-limit\n.data\n.align 1\n.LC139:\n.byte 53\n.byte 10\n.byte 0\n.align 1\n.LC138:\n.byte 52\n.byte 10\n.byte 0\n.align 1\n.LC136:\n.byte 51\n.byte 10\n.byte 0\n.align 1\n.LC134:\n.byte 50\n.byte 10\n.byte 0\n.align 1\n.LC132:\n.byte 49\n.byte 10\n.byte 0\n.align 1\n.LC130:\n.byte 48\n.byte 10\n.byte 0\n.align 1\n.LC118:\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 120\n.byte 37\n.byte 120\n.byte 32\n.byte 40\n.byte 100\n.byte 101\n.byte 102\n.byte 97\n.byte 117\n.byte 108\n.byte 116\n.byte 41\n.byte 10\n.byte 0\n.align 1\n.LC115:\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 120\n.byte 37\n.byte 120\n.byte 10\n.byte 0\n.align 1\n.LC108:\n.byte 37\n.byte 100\n.byte 32\n.byte 100\n.byte 101\n.byte 102\n.byte 97\n.byte 117\n.byte 108\n.byte 116\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.LC85:\n.byte 105\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC77:\n.byte 104\n.byte 58\n.byte 10\n.byte 0\n.align 1\n.LC66:\n.byte 54\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC64:\n.byte 53\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC62:\n.byte 100\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC61:\n.byte 51\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC59:\n.byte 50\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC57:\n.byte 49\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC49:\n.byte 103\n.byte 58\n.byte 10\n.byte 0\n.align 1\n.LC46:\n.byte 120\n.byte 32\n.byte 61\n.byte 32\n.byte 37\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC27:\n.byte 102\n.byte 58\n.byte 10\n.byte 0\n.align 1\n.LC7:\n.byte 37\n.byte 99\n.byte 32\n.byte 61\n.byte 32\n.byte 48\n.byte 120\n.byte 37\n.byte 120\n.byte 10\n.byte 0\n.align 1\n.LC6:\n.byte 98\n.byte 102\n.byte 110\n.byte 114\n.byte 116\n.byte 118\n.byte 120\n.byte 0\n.text\n.ident \"LCC: 4.1\"\n"
  },
  {
    "path": "lcc/x86/linux/tst/wf1.1bk",
    "content": "5\ta\n2\tand\n5\tbuf\n16\tc\n8\tchar\n1\tcompare\n4\tcond\n5\tcount\n1\td\n1\tdie\n3\telse\n1\tentry\n1\teof\n4\terr\n1\terror\n1\texit\n1\tfolded\n1\tfor\n1\tfree\n1\tfrequencies\n1\tfrequency\n1\tget\n2\tgetchar\n3\tgetword\n14\tif\n2\tin\n1\tindex\n1\tinput\n1\tinstall\n8\tint\n1\tinto\n1\tis\n4\tisletter\n1\tit\n1\titself\n5\tleft\n1\tletter\n7\tlookup\n1\tmain\n2\tmalloc\n1\tmessage\n2\tn\n1\tnecessary\n12\tnext\n9\tnode\n4\tof\n1\ton\n1\tor\n1\totherwise\n2\tout\n8\tp\n3\tprint\n2\tprintf\n16\treturn\n5\tright\n4\troot\n25\ts\n2\tstorage\n3\tstrcmp\n1\tstrcpy\n1\tstrlen\n8\tstruct\n1\tstructures\n2\tsubtree\n1\tt\n5\ttprint\n9\ttree\n1\tuses\n1\tversion\n1\twf\n3\twhile\n21\tword\n9\twords\n2\tz\n"
  },
  {
    "path": "lcc/x86/linux/tst/wf1.2bk",
    "content": "tst/wf1.c:29: warning: missing return value\ntst/wf1.c:87: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/linux/tst/wf1.sbk",
    "content": ".globl main\n.text\n.align 16\n.type main,@function\nmain:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $24,%esp\nmovl $0,-24(%ebp)\nmovl $0,next\njmp .LC3\n.LC2:\nleal -24(%ebp),%edi\npushl %edi\nleal -20(%ebp),%edi\npushl %edi\ncall lookup\naddl $8,%esp\nincl (,%eax)\n.LC3:\nleal -20(%ebp),%edi\npushl %edi\ncall getword\naddl $4,%esp\ncmpl $0,%eax\njne .LC2\npushl -24(%ebp)\ncall tprint\naddl $4,%esp\nmovl $0,%eax\n.LC1:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf5:\n.size main,.Lf5-main\n.globl err\n.align 16\n.type err,@function\nerr:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\npushl 20(%ebp)\npushl $.LC7\ncall printf\naddl $8,%esp\npushl $1\ncall exit\naddl $4,%esp\nmovl $0,%eax\n.LC6:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf8:\n.size err,.Lf8-err\n.globl getword\n.align 16\n.type getword,@function\ngetword:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $8,%esp\n.LC10:\n.LC11:\ncall getchar\nmovl %eax,%edi\nmovl %edi,-4(%ebp)\ncmpl $-1,%edi\nje .LC13\npushl -4(%ebp)\ncall isletter\naddl $4,%esp\ncmpl $0,%eax\nje .LC10\n.LC13:\nmovl 20(%ebp),%edi\nmovl %edi,-8(%ebp)\njmp .LC17\n.LC14:\nmovl -8(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-8(%ebp)\nmovl -4(%ebp),%esi\nmovl %esi,%ebx\nmovb %bl,(,%edi)\n.LC15:\ncall getchar\nmovl %eax,-4(%ebp)\n.LC17:\npushl -4(%ebp)\ncall isletter\naddl $4,%esp\nmovl %eax,-4(%ebp)\ncmpl $0,%eax\njne .LC14\nmovl -8(%ebp),%edi\nmovb $0,(,%edi)\nmovl -8(%ebp),%edi\nmovl 20(%ebp),%esi\ncmpl %esi,%edi\njbe .LC18\nmovl $1,%eax\njmp .LC9\n.LC18:\nmovl $0,%eax\n.LC9:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf20:\n.size getword,.Lf20-getword\n.globl isletter\n.align 16\n.type isletter,@function\nisletter:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl 20(%ebp),%edi\ncmpl $65,%edi\njl .LC22\ncmpl $90,%edi\njg .LC22\naddl $32,20(%ebp)\n.LC22:\nmovl 20(%ebp),%edi\ncmpl $97,%edi\njl .LC24\ncmpl $122,%edi\njg .LC24\nmovl 20(%ebp),%eax\njmp .LC21\n.LC24:\nmovl $0,%eax\n.LC21:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf26:\n.size isletter,.Lf26-isletter\n.globl lookup\n.align 16\n.type lookup,@function\nlookup:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\nmovl 24(%ebp),%edi\nmovl (,%edi),%edi\ncmpl $0,%edi\nje .LC28\nmovl 24(%ebp),%edi\nmovl (,%edi),%edi\npushl 12(%edi)\npushl 20(%ebp)\ncall strcmp\naddl $8,%esp\nmovl %eax,-4(%ebp)\ncmpl $0,-4(%ebp)\njge .LC30\nmovl 24(%ebp),%edi\nmovl (,%edi),%edi\nleal 4(%edi),%edi\npushl %edi\npushl 20(%ebp)\ncall lookup\naddl $8,%esp\nmovl %eax,%edi\njmp .LC27\n.LC30:\ncmpl $0,-4(%ebp)\njle .LC32\nmovl 24(%ebp),%edi\nmovl (,%edi),%edi\nleal 8(%edi),%edi\npushl %edi\npushl 20(%ebp)\ncall lookup\naddl $8,%esp\nmovl %eax,%edi\njmp .LC27\n.LC32:\nmovl 24(%ebp),%edi\nmovl (,%edi),%eax\njmp .LC27\n.LC28:\ncmpl $2000,next\njl .LC34\npushl $.LC36\ncall err\naddl $4,%esp\n.LC34:\nmovl next,%edi\nsall $4,%edi\nmovl $0,words(%edi)\nmovl next,%edi\nsall $4,%edi\nmovl $0,words+8(%edi)\nmovl $0,words+4(%edi)\npushl 20(%ebp)\ncall strlen\naddl $4,%esp\nleal 1(%eax),%edi\npushl %edi\ncall malloc\naddl $4,%esp\nmovl next,%esi\nsall $4,%esi\nmovl %eax,words+12(%esi)\nmovl next,%edi\nsall $4,%edi\nmovl words+12(%edi),%edi\ncmpl $0,%edi\njne .LC40\npushl $.LC43\ncall err\naddl $4,%esp\n.LC40:\npushl 20(%ebp)\nmovl next,%edi\nsall $4,%edi\npushl words+12(%edi)\ncall strcpy\naddl $8,%esp\nmovl next,%edi\nleal 1(%edi),%esi\nmovl %esi,next\nsall $4,%edi\nleal words(%edi),%edi\nmovl 24(%ebp),%esi\nmovl %edi,(,%esi)\nmovl %edi,%eax\n.LC27:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf45:\n.size lookup,.Lf45-lookup\n.globl tprint\n.align 16\n.type tprint,@function\ntprint:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl 20(%ebp),%edi\ncmpl $0,%edi\nje .LC47\nmovl 20(%ebp),%edi\npushl 4(%edi)\ncall tprint\naddl $4,%esp\nmovl 20(%ebp),%edi\npushl 12(%edi)\npushl (,%edi)\npushl $.LC49\ncall printf\naddl $12,%esp\nmovl 20(%ebp),%edi\npushl 8(%edi)\ncall tprint\naddl $4,%esp\n.LC47:\nmovl $0,%eax\n.LC46:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf50:\n.size tprint,.Lf50-tprint\n.globl strcmp\n.align 16\n.type strcmp,@function\nstrcmp:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\njmp .LC53\n.LC52:\nmovl 20(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,20(%ebp)\nmovsbl (,%edi),%edi\ncmpl $0,%edi\njne .LC55\nmovl $0,%eax\njmp .LC51\n.LC55:\nincl 24(%ebp)\n.LC53:\nmovl 20(%ebp),%edi\nmovsbl (,%edi),%edi\nmovl 24(%ebp),%esi\nmovsbl (,%esi),%esi\ncmpl %esi,%edi\nje .LC52\nmovl 20(%ebp),%edi\nmovsbl (,%edi),%edi\ncmpl $0,%edi\njne .LC57\nmovl $-1,%eax\njmp .LC51\n.LC57:\nmovl 24(%ebp),%edi\nmovsbl (,%edi),%edi\ncmpl $0,%edi\njne .LC59\nmovl $1,%eax\njmp .LC51\n.LC59:\nmovl 20(%ebp),%edi\nmovsbl (,%edi),%edi\nmovl 24(%ebp),%esi\nmovsbl (,%esi),%esi\nmovl %edi,%eax\nsubl %esi,%eax\n.LC51:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf61:\n.size strcmp,.Lf61-strcmp\n.bss\n.globl next\n.align 4\n.type next,@object\n.size next,4\n.comm next,4\n.globl words\n.align 4\n.type words,@object\n.size words,32000\n.comm words,32000\n.data\n.align 1\n.LC49:\n.byte 37\n.byte 100\n.byte 9\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.LC43:\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 119\n.byte 111\n.byte 114\n.byte 100\n.byte 32\n.byte 115\n.byte 116\n.byte 111\n.byte 114\n.byte 97\n.byte 103\n.byte 101\n.byte 0\n.align 1\n.LC36:\n.byte 111\n.byte 117\n.byte 116\n.byte 32\n.byte 111\n.byte 102\n.byte 32\n.byte 110\n.byte 111\n.byte 100\n.byte 101\n.byte 32\n.byte 115\n.byte 116\n.byte 111\n.byte 114\n.byte 97\n.byte 103\n.byte 101\n.byte 0\n.align 1\n.LC7:\n.byte 63\n.byte 32\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.text\n.ident \"LCC: 4.1\"\n"
  },
  {
    "path": "lcc/x86/linux/tst/yacc.1bk",
    "content": "a\nb\nload\nnegate\npush 5\nc\nload\nmultiply\nadd\nstore\n"
  },
  {
    "path": "lcc/x86/linux/tst/yacc.2bk",
    "content": "tst/yacc.c:345: warning: missing return value\ntst/yacc.c:349: warning: missing return value\ntst/yacc.c:359: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/linux/tst/yacc.sbk",
    "content": ".data\n.globl yyin\n.align 4\n.type yyin,@object\n.size yyin,4\nyyin:\n.long _IO_stdin_\n.globl yyout\n.align 4\n.type yyout,@object\n.size yyout,4\nyyout:\n.long _IO_stdout_\n.globl yylex\n.text\n.align 16\n.type yylex,@function\nyylex:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $4,%esp\njmp .LC3\n.LC2:\n.LC5:\nmovl -4(%ebp),%edi\ncmpl $-1,%edi\njl .LC6\ncmpl $4,%edi\njg .LC6\njmp *.LC17+4(,%edi,4)\n.data\n.align 4\n.LC17:\n.long .LC7\n.long .LC8\n.long .LC11\n.long .LC12\n.long .LC7\n.long .LC14\n.text\n.LC8:\ncall yywrap\ncmpl $0,%eax\nje .LC7\nmovl $0,%eax\njmp .LC1\n.LC11:\nmovl $257,%eax\njmp .LC1\n.LC12:\nmovl $258,%eax\njmp .LC1\n.LC14:\nmovsbl yytext,%eax\njmp .LC1\n.LC6:\npushl -4(%ebp)\npushl $.LC16\npushl yyout\ncall fprintf\naddl $12,%esp\n.LC7:\n.LC3:\ncall yylook\nmovl %eax,-4(%ebp)\ncmpl $0,%eax\njge .LC2\nmovl $0,%eax\n.LC1:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf19:\n.size yylex,.Lf19-yylex\n.data\n.globl yyvstop\n.align 4\n.type yyvstop,@object\nyyvstop:\n.long 0\n.long 4\n.long 0\n.long 3\n.long 4\n.long 0\n.long 2\n.long 4\n.long 0\n.long 1\n.long 4\n.long 0\n.long 2\n.long 0\n.long 1\n.long 0\n.long 0\n.size yyvstop,68\n.globl yycrank\n.align 4\n.type yycrank,@object\nyycrank:\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 1\n.byte 3\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 1\n.byte 4\n.space 2\n.byte 1\n.byte 3\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 1\n.byte 5\n.space 2\n.byte 5\n.byte 7\n.space 2\n.byte 5\n.byte 7\n.space 2\n.byte 5\n.byte 7\n.space 2\n.byte 5\n.byte 7\n.space 2\n.byte 5\n.byte 7\n.space 2\n.byte 5\n.byte 7\n.space 2\n.byte 5\n.byte 7\n.space 2\n.byte 5\n.byte 7\n.space 2\n.byte 5\n.byte 7\n.space 2\n.byte 5\n.byte 7\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 1\n.byte 6\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 6\n.byte 8\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.byte 0\n.byte 0\n.space 2\n.size yycrank,580\n.globl yysvec\n.align 4\n.type yysvec,@object\nyysvec:\n.long 0\n.long 0\n.long 0\n.long yycrank-4\n.long 0\n.long 0\n.long yycrank\n.long yysvec+12\n.long 0\n.long yycrank\n.long 0\n.long yyvstop+4\n.long yycrank\n.long 0\n.long yyvstop+12\n.long yycrank+8\n.long 0\n.long yyvstop+24\n.long yycrank+76\n.long 0\n.long yyvstop+36\n.long yycrank\n.long yysvec+60\n.long yyvstop+48\n.long yycrank\n.long yysvec+72\n.long yyvstop+56\n.long 0\n.long 0\n.long 0\n.size yysvec,120\n.globl yytop\n.align 4\n.type yytop,@object\n.size yytop,4\nyytop:\n.long yycrank+564\n.globl yybgin\n.align 4\n.type yybgin,@object\n.size yybgin,4\nyybgin:\n.long yysvec+12\n.globl yymatch\n.align 1\n.type yymatch,@object\nyymatch:\n.byte 0\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 9\n.byte 10\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 9\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 48\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 65\n.byte 1\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 65\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 1\n.byte 0\n.size yymatch,129\n.globl yyextra\n.align 1\n.type yyextra,@object\nyyextra:\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.byte 0\n.size yyextra,9\n.globl yylineno\n.align 4\n.type yylineno,@object\n.size yylineno,4\nyylineno:\n.long 1\n.globl yysptr\n.align 4\n.type yysptr,@object\n.size yysptr,4\nyysptr:\n.long yysbuf\n.globl yyprevious\n.align 4\n.type yyprevious,@object\n.size yyprevious,4\nyyprevious:\n.long 10\n.globl yylook\n.text\n.align 16\n.type yylook,@function\nyylook:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $44,%esp\ncmpl $0,yymorfg\njne .LC35\nleal yytext,%edi\nmovl %edi,-16(%ebp)\njmp .LC36\n.LC35:\nmovl $0,yymorfg\nmovl yyleng,%edi\nleal yytext(%edi),%edi\nmovl %edi,-16(%ebp)\n.LC36:\n.LC37:\nleal yylstate,%edi\nmovl %edi,-8(%ebp)\nmovl yybgin,%edi\nmovl %edi,-4(%ebp)\nmovl %edi,yyestate\ncmpl $10,yyprevious\njne .LC41\nmovl -4(%ebp),%edi\nleal 12(%edi),%edi\nmovl %edi,-4(%ebp)\n.LC41:\n.LC43:\nmovl -4(%ebp),%edi\nmovl (,%edi),%edi\nmovl %edi,-12(%ebp)\nmovl -12(%ebp),%edi\nleal yycrank,%esi\ncmpl %esi,%edi\njne .LC47\nmovl -4(%ebp),%edi\nmovl 4(%edi),%edi\nmovl %edi,-28(%ebp)\nmovl -28(%ebp),%edi\ncmpl $0,%edi\njne .LC49\njmp .LC94\n.LC49:\nmovl -28(%ebp),%edi\nmovl (,%edi),%edi\nleal yycrank,%esi\ncmpl %esi,%edi\njne .LC51\njmp .LC94\n.LC51:\n.LC47:\nmovl -16(%ebp),%edi\nleal 1(%edi),%esi\nmovl %esi,-16(%ebp)\nmovl yysptr,%esi\nleal yysbuf,%ebx\ncmpl %ebx,%esi\njbe .LC61\nmovl yysptr,%esi\nleal -1(%esi),%esi\nmovl %esi,yysptr\nmovsbl (,%esi),%esi\nmovl %esi,-40(%ebp)\njmp .LC62\n.LC61:\nmovl yyin,%esi\nmovl 4(%esi),%ebx\nmovl 8(%esi),%esi\ncmpl %esi,%ebx\njb .LC63\npushl yyin\ncall __uflow\naddl $4,%esp\nmovl %eax,%esi\nmovl %esi,-44(%ebp)\njmp .LC64\n.LC63:\nmovl yyin,%esi\nleal 4(%esi),%esi\nmovl (,%esi),%ebx\nleal 1(%ebx),%edx\nmovl %edx,(,%esi)\nmovb (,%ebx),%bl\nmovzbl %bl,%esi\nmovl %esi,-44(%ebp)\n.LC64:\nmovl -44(%ebp),%esi\nmovl %esi,-40(%ebp)\n.LC62:\nmovl -40(%ebp),%esi\nmovl %esi,yytchar\ncmpl $10,%esi\njne .LC59\nincl yylineno\nmovl yytchar,%esi\nmovl %esi,-36(%ebp)\njmp .LC60\n.LC59:\nmovl yytchar,%esi\nmovl %esi,-36(%ebp)\n.LC60:\ncmpl $-1,-36(%ebp)\njne .LC57\nmovl $0,-32(%ebp)\njmp .LC58\n.LC57:\nmovl yytchar,%esi\nmovl %esi,-32(%ebp)\n.LC58:\nmovl -32(%ebp),%esi\nmovl %esi,-20(%ebp)\nmovl %esi,%ebx\nmovb %bl,(,%edi)\n.LC65:\nmovl -12(%ebp),%edi\nmovl %edi,-24(%ebp)\nleal yycrank,%esi\ncmpl %esi,%edi\njbe .LC66\nmovl -20(%ebp),%edi\nmovl -24(%ebp),%esi\nleal (%esi,%edi,4),%edi\nmovl %edi,-12(%ebp)\nmovl -12(%ebp),%edi\nmovl %edi,%esi\nmovl yytop,%ebx\ncmpl %ebx,%esi\nja .LC67\nmovsbl (,%edi),%edi\nimul $12,%edi,%edi\nleal yysvec(%edi),%edi\nmovl -4(%ebp),%esi\ncmpl %esi,%edi\njne .LC67\nleal yysvec,%edi\nmovl -12(%ebp),%esi\nmovsbl 1(%esi),%esi\nimul $12,%esi,%esi\nleal yysvec(%esi),%esi\ncmpl %edi,%esi\njne .LC70\nmovl -16(%ebp),%edi\nleal -1(%edi),%edi\nmovl %edi,-16(%ebp)\nmovsbl (,%edi),%edi\nmovl %edi,yytchar\ncmpl $10,yytchar\njne .LC72\ndecl yylineno\n.LC72:\nmovl yysptr,%edi\nleal 1(%edi),%esi\nmovl %esi,yysptr\nmovl yytchar,%esi\nmovl %esi,%ebx\nmovb %bl,(,%edi)\njmp .LC94\n.LC70:\nmovl -8(%ebp),%edi\nleal 4(%edi),%esi\nmovl %esi,-8(%ebp)\nmovl -12(%ebp),%esi\nmovsbl 1(%esi),%esi\nimul $12,%esi,%esi\nleal yysvec(%esi),%esi\nmovl %esi,-4(%ebp)\nmovl %esi,(,%edi)\njmp .LC43\n.LC66:\nmovl -12(%ebp),%edi\nleal yycrank,%esi\ncmpl %esi,%edi\njae .LC75\nleal yycrank,%edi\nmovl -12(%ebp),%esi\nsubl %esi,%edi\nmovl %edi,%eax\nmovl $4,%ecx\ncdq\nidivl %ecx\nleal yycrank(,%eax,4),%edi\nmovl %edi,-24(%ebp)\nmovl %edi,-12(%ebp)\nmovl -20(%ebp),%edi\nmovl -12(%ebp),%esi\nleal (%esi,%edi,4),%edi\nmovl %edi,-12(%ebp)\nmovl -12(%ebp),%edi\nmovl %edi,%esi\nmovl yytop,%ebx\ncmpl %ebx,%esi\nja .LC77\nmovsbl (,%edi),%edi\nimul $12,%edi,%edi\nleal yysvec(%edi),%edi\nmovl -4(%ebp),%esi\ncmpl %esi,%edi\njne .LC77\nleal yysvec,%edi\nmovl -12(%ebp),%esi\nmovsbl 1(%esi),%esi\nimul $12,%esi,%esi\nleal yysvec(%esi),%esi\ncmpl %edi,%esi\njne .LC79\nmovl -16(%ebp),%edi\nleal -1(%edi),%edi\nmovl %edi,-16(%ebp)\nmovsbl (,%edi),%edi\nmovl %edi,yytchar\ncmpl $10,yytchar\njne .LC81\ndecl yylineno\n.LC81:\nmovl yysptr,%edi\nleal 1(%edi),%esi\nmovl %esi,yysptr\nmovl yytchar,%esi\nmovl %esi,%ebx\nmovb %bl,(,%edi)\njmp .LC94\n.LC79:\nmovl -8(%ebp),%edi\nleal 4(%edi),%esi\nmovl %esi,-8(%ebp)\nmovl -12(%ebp),%esi\nmovsbl 1(%esi),%esi\nimul $12,%esi,%esi\nleal yysvec(%esi),%esi\nmovl %esi,-4(%ebp)\nmovl %esi,(,%edi)\njmp .LC43\n.LC77:\nmovl -20(%ebp),%edi\nmovsbl yymatch(%edi),%edi\nmovl -24(%ebp),%esi\nleal (%esi,%edi,4),%edi\nmovl %edi,-12(%ebp)\nmovl -12(%ebp),%edi\nmovl %edi,%esi\nmovl yytop,%ebx\ncmpl %ebx,%esi\nja .LC83\nmovsbl (,%edi),%edi\nimul $12,%edi,%edi\nleal yysvec(%edi),%edi\nmovl -4(%ebp),%esi\ncmpl %esi,%edi\njne .LC83\nleal yysvec,%edi\nmovl -12(%ebp),%esi\nmovsbl 1(%esi),%esi\nimul $12,%esi,%esi\nleal yysvec(%esi),%esi\ncmpl %edi,%esi\njne .LC85\nmovl -16(%ebp),%edi\nleal -1(%edi),%edi\nmovl %edi,-16(%ebp)\nmovsbl (,%edi),%edi\nmovl %edi,yytchar\ncmpl $10,yytchar\njne .LC87\ndecl yylineno\n.LC87:\nmovl yysptr,%edi\nleal 1(%edi),%esi\nmovl %esi,yysptr\nmovl yytchar,%esi\nmovl %esi,%ebx\nmovb %bl,(,%edi)\njmp .LC94\n.LC85:\nmovl -8(%ebp),%edi\nleal 4(%edi),%esi\nmovl %esi,-8(%ebp)\nmovl -12(%ebp),%esi\nmovsbl 1(%esi),%esi\nimul $12,%esi,%esi\nleal yysvec(%esi),%esi\nmovl %esi,-4(%ebp)\nmovl %esi,(,%edi)\njmp .LC43\n.LC83:\n.LC75:\n.LC67:\nmovl -4(%ebp),%edi\nmovl 4(%edi),%edi\nmovl %edi,-4(%ebp)\ncmpl $0,%edi\nje .LC89\nmovl -4(%ebp),%edi\nmovl (,%edi),%edi\nmovl %edi,-12(%ebp)\nleal yycrank,%esi\ncmpl %esi,%edi\nje .LC89\njmp .LC65\n.LC89:\nmovl -16(%ebp),%edi\nleal -1(%edi),%edi\nmovl %edi,-16(%ebp)\nmovsbl (,%edi),%edi\nmovl %edi,yytchar\ncmpl $10,yytchar\njne .LC91\ndecl yylineno\n.LC91:\nmovl yysptr,%edi\nleal 1(%edi),%esi\nmovl %esi,yysptr\nmovl yytchar,%esi\nmovl %esi,%ebx\nmovb %bl,(,%edi)\njmp .LC94\n.LC93:\nmovl -16(%ebp),%edi\nleal -1(%edi),%esi\nmovl %esi,-16(%ebp)\nmovb $0,(,%edi)\nmovl -8(%ebp),%edi\nmovl (,%edi),%edi\nmovl %edi,%esi\ncmpl $0,%esi\nje .LC96\nmovl 8(%edi),%edi\nmovl %edi,yyfnd\ncmpl $0,%edi\nje .LC96\nmovl yyfnd,%edi\ncmpl $0,(,%edi)\njle .LC96\nmovl -8(%ebp),%edi\nmovl %edi,yyolsp\nmovl yyfnd,%edi\nmovl (,%edi),%edi\nmovsbl yyextra(%edi),%edi\ncmpl $0,%edi\nje .LC98\njmp .LC101\n.LC100:\nmovl -8(%ebp),%edi\nleal -4(%edi),%edi\nmovl %edi,-8(%ebp)\nmovl -16(%ebp),%edi\nleal -1(%edi),%esi\nmovl %esi,-16(%ebp)\nmovsbl (,%edi),%edi\nmovl %edi,yytchar\ncmpl $10,yytchar\njne .LC103\ndecl yylineno\n.LC103:\nmovl yysptr,%edi\nleal 1(%edi),%esi\nmovl %esi,yysptr\nmovl yytchar,%esi\nmovl %esi,%ebx\nmovb %bl,(,%edi)\n.LC101:\nmovl yyfnd,%edi\nmovl (,%edi),%edi\nnegl %edi\npushl %edi\nmovl -8(%ebp),%edi\nmovl (,%edi),%edi\npushl 8(%edi)\ncall yyback\naddl $8,%esp\ncmpl $1,%eax\nje .LC105\nmovl -8(%ebp),%edi\nleal yylstate,%esi\ncmpl %esi,%edi\nja .LC100\n.LC105:\n.LC98:\nmovl -16(%ebp),%edi\nmovsbl (,%edi),%esi\nmovl %esi,yyprevious\nmovl -8(%ebp),%esi\nmovl %esi,yylsp\nleal yytext,%esi\nsubl %esi,%edi\nleal 1(%edi),%edi\nmovl %edi,yyleng\nmovl yyleng,%edi\nmovb $0,yytext(%edi)\nmovl yyfnd,%edi\nleal 4(%edi),%esi\nmovl %esi,yyfnd\nmovl (,%edi),%eax\njmp .LC34\n.LC96:\nmovl -16(%ebp),%edi\nmovsbl (,%edi),%edi\nmovl %edi,yytchar\ncmpl $10,yytchar\njne .LC106\ndecl yylineno\n.LC106:\nmovl yysptr,%edi\nleal 1(%edi),%esi\nmovl %esi,yysptr\nmovl yytchar,%esi\nmovl %esi,%ebx\nmovb %bl,(,%edi)\n.LC94:\nmovl -8(%ebp),%edi\nleal -4(%edi),%esi\nmovl %esi,-8(%ebp)\nleal yylstate,%esi\ncmpl %esi,%edi\nja .LC93\nmovsbl yytext,%edi\ncmpl $0,%edi\njne .LC108\nleal yysbuf,%edi\nmovl %edi,yysptr\nmovl $0,%eax\njmp .LC34\n.LC108:\nmovl yysptr,%edi\nleal yysbuf,%esi\ncmpl %esi,%edi\njbe .LC118\nmovl yysptr,%edi\nleal -1(%edi),%edi\nmovl %edi,yysptr\nmovsbl (,%edi),%edi\nmovl %edi,-40(%ebp)\njmp .LC119\n.LC118:\nmovl yyin,%edi\nmovl 4(%edi),%esi\nmovl 8(%edi),%edi\ncmpl %edi,%esi\njb .LC120\npushl yyin\ncall __uflow\naddl $4,%esp\nmovl %eax,%edi\nmovl %edi,-44(%ebp)\njmp .LC121\n.LC120:\nmovl yyin,%edi\nleal 4(%edi),%edi\nmovl (,%edi),%esi\nleal 1(%esi),%ebx\nmovl %ebx,(,%edi)\nmovb (,%esi),%bl\nmovzbl %bl,%edi\nmovl %edi,-44(%ebp)\n.LC121:\nmovl -44(%ebp),%edi\nmovl %edi,-40(%ebp)\n.LC119:\nmovl -40(%ebp),%edi\nmovl %edi,yytchar\ncmpl $10,%edi\njne .LC116\nincl yylineno\nmovl yytchar,%edi\nmovl %edi,-36(%ebp)\njmp .LC117\n.LC116:\nmovl yytchar,%edi\nmovl %edi,-36(%ebp)\n.LC117:\ncmpl $-1,-36(%ebp)\njne .LC114\nmovl $0,-32(%ebp)\njmp .LC115\n.LC114:\nmovl yytchar,%edi\nmovl %edi,-32(%ebp)\n.LC115:\nmovl -32(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,yytext\nmovsbl %bl,%edi\nmovl %edi,yyprevious\ncmpl $0,yyprevious\njle .LC122\nmovl yyout,%edi\nmovl 20(%edi),%esi\nmovl 24(%edi),%edi\ncmpl %edi,%esi\njb .LC125\nmovl yyprevious,%edi\nmovl %edi,%ebx\nmovzbl %bl,%edi\npushl %edi\npushl yyout\ncall __overflow\naddl $8,%esp\njmp .LC126\n.LC125:\nmovl yyout,%edi\nleal 20(%edi),%edi\nmovl (,%edi),%esi\nleal 1(%esi),%ebx\nmovl %ebx,(,%edi)\nmovl yyprevious,%edi\nmovl %edi,%ebx\nmovb %bl,(,%esi)\n.LC126:\n.LC122:\nleal yytext,%edi\nmovl %edi,-16(%ebp)\njmp .LC37\n.LC34:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf127:\n.size yylook,.Lf127-yylook\n.globl yyback\n.align 16\n.type yyback,@function\nyyback:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl 20(%ebp),%edi\ncmpl $0,%edi\njne .LC132\nmovl $0,%eax\njmp .LC128\n.LC131:\nmovl 20(%ebp),%edi\nleal 4(%edi),%esi\nmovl %esi,20(%ebp)\nmovl 24(%ebp),%esi\ncmpl %esi,(,%edi)\njne .LC134\nmovl $1,%eax\njmp .LC128\n.LC134:\n.LC132:\nmovl 20(%ebp),%edi\ncmpl $0,(,%edi)\njne .LC131\nmovl $0,%eax\n.LC128:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf136:\n.size yyback,.Lf136-yyback\n.globl yyinput\n.align 16\n.type yyinput,@function\nyyinput:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $16,%esp\nmovl yysptr,%edi\nleal yysbuf,%esi\ncmpl %esi,%edi\njbe .LC146\nmovl yysptr,%edi\nleal -1(%edi),%edi\nmovl %edi,yysptr\nmovsbl (,%edi),%edi\nmovl %edi,-12(%ebp)\njmp .LC147\n.LC146:\nmovl yyin,%edi\nmovl 4(%edi),%esi\nmovl 8(%edi),%edi\ncmpl %edi,%esi\njb .LC148\npushl yyin\ncall __uflow\naddl $4,%esp\nmovl %eax,%edi\nmovl %edi,-16(%ebp)\njmp .LC149\n.LC148:\nmovl yyin,%edi\nleal 4(%edi),%edi\nmovl (,%edi),%esi\nleal 1(%esi),%ebx\nmovl %ebx,(,%edi)\nmovb (,%esi),%bl\nmovzbl %bl,%edi\nmovl %edi,-16(%ebp)\n.LC149:\nmovl -16(%ebp),%edi\nmovl %edi,-12(%ebp)\n.LC147:\nmovl -12(%ebp),%edi\nmovl %edi,yytchar\ncmpl $10,%edi\njne .LC144\nincl yylineno\nmovl yytchar,%edi\nmovl %edi,-8(%ebp)\njmp .LC145\n.LC144:\nmovl yytchar,%edi\nmovl %edi,-8(%ebp)\n.LC145:\ncmpl $-1,-8(%ebp)\njne .LC142\nmovl $0,-4(%ebp)\njmp .LC143\n.LC142:\nmovl yytchar,%edi\nmovl %edi,-4(%ebp)\n.LC143:\nmovl -4(%ebp),%eax\n.LC137:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf150:\n.size yyinput,.Lf150-yyinput\n.globl yyoutput\n.align 16\n.type yyoutput,@function\nyyoutput:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl yyout,%edi\nmovl 20(%edi),%esi\nmovl 24(%edi),%edi\ncmpl %edi,%esi\njb .LC153\nmovl 20(%ebp),%edi\nmovl %edi,%ebx\nmovzbl %bl,%edi\npushl %edi\npushl yyout\ncall __overflow\naddl $8,%esp\njmp .LC154\n.LC153:\nmovl yyout,%edi\nleal 20(%edi),%edi\nmovl (,%edi),%esi\nleal 1(%esi),%ebx\nmovl %ebx,(,%edi)\nmovl 20(%ebp),%edi\nmovl %edi,%ebx\nmovb %bl,(,%esi)\n.LC154:\nmovl $0,%eax\n.LC151:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf155:\n.size yyoutput,.Lf155-yyoutput\n.globl yyunput\n.align 16\n.type yyunput,@function\nyyunput:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl 20(%ebp),%edi\nmovl %edi,yytchar\ncmpl $10,yytchar\njne .LC157\ndecl yylineno\n.LC157:\nmovl yysptr,%edi\nleal 1(%edi),%esi\nmovl %esi,yysptr\nmovl yytchar,%esi\nmovl %esi,%ebx\nmovb %bl,(,%edi)\nmovl $0,%eax\n.LC156:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf159:\n.size yyunput,.Lf159-yyunput\n.globl main\n.align 16\n.type main,@function\nmain:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\ncall yyparse\nmovl $0,%eax\n.LC160:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf161:\n.size main,.Lf161-main\n.globl yyerror\n.align 16\n.type yyerror,@function\nyyerror:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\npushl 20(%ebp)\npushl $.LC163\ncall printf\naddl $8,%esp\nmovl $0,%eax\n.LC162:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf164:\n.size yyerror,.Lf164-yyerror\n.data\n.globl yyexca\n.align 2\n.type yyexca,@object\nyyexca:\n.word -1\n.word 1\n.word 0\n.word -1\n.word -2\n.word 0\n.size yyexca,12\n.globl yyact\n.align 2\n.type yyact,@object\nyyact:\n.word 12\n.word 2\n.word 9\n.word 8\n.word 17\n.word 11\n.word 25\n.word 17\n.word 15\n.word 18\n.word 16\n.word 10\n.word 18\n.word 17\n.word 15\n.word 7\n.word 16\n.word 13\n.word 18\n.word 5\n.word 3\n.word 1\n.word 0\n.word 19\n.word 20\n.word 0\n.word 0\n.word 21\n.word 22\n.word 23\n.word 24\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 6\n.word 14\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 0\n.word 4\n.word 6\n.size yyact,498\n.globl yypact\n.align 2\n.type yypact,@object\nyypact:\n.word -1000\n.word -9\n.word -1000\n.word 5\n.word -7\n.word -59\n.word -1000\n.word -1000\n.word -1000\n.word -40\n.word -29\n.word -40\n.word -40\n.word -1000\n.word -1000\n.word -40\n.word -40\n.word -40\n.word -40\n.word -38\n.word -35\n.word -38\n.word -38\n.word -1000\n.word -1000\n.word -1000\n.size yypact,52\n.globl yypgo\n.align 2\n.type yypgo,@object\nyypgo:\n.word 0\n.word 21\n.word 20\n.word 17\n.word 11\n.size yypgo,10\n.globl yyr1\n.align 2\n.type yyr1,@object\nyyr1:\n.word 0\n.word 1\n.word 1\n.word 1\n.word 1\n.word 2\n.word 4\n.word 4\n.word 4\n.word 4\n.word 4\n.word 4\n.word 4\n.word 4\n.word 3\n.size yyr1,30\n.globl yyr2\n.align 2\n.type yyr2,@object\nyyr2:\n.word 0\n.word 0\n.word 2\n.word 3\n.word 3\n.word 3\n.word 3\n.word 3\n.word 3\n.word 3\n.word 2\n.word 3\n.word 1\n.word 1\n.word 1\n.size yyr2,30\n.globl yychk\n.align 2\n.type yychk,@object\nyychk:\n.word -1000\n.word -1\n.word 10\n.word -2\n.word 256\n.word -3\n.word 257\n.word 10\n.word 10\n.word 61\n.word -4\n.word 45\n.word 40\n.word -3\n.word 258\n.word 43\n.word 45\n.word 42\n.word 47\n.word -4\n.word -4\n.word -4\n.word -4\n.word -4\n.word -4\n.word 41\n.size yychk,52\n.globl yydef\n.align 2\n.type yydef,@object\nyydef:\n.word 1\n.word -2\n.word 2\n.word 0\n.word 0\n.word 0\n.word 14\n.word 3\n.word 4\n.word 0\n.word 5\n.word 0\n.word 0\n.word 12\n.word 13\n.word 0\n.word 0\n.word 0\n.word 0\n.word 10\n.word 0\n.word 6\n.word 7\n.word 8\n.word 9\n.word 11\n.size yydef,52\n.globl yychar\n.align 4\n.type yychar,@object\n.size yychar,4\nyychar:\n.long -1\n.globl yynerrs\n.align 4\n.type yynerrs,@object\n.size yynerrs,4\nyynerrs:\n.long 0\n.globl yyerrflag\n.align 2\n.type yyerrflag,@object\n.size yyerrflag,2\nyyerrflag:\n.word 0\n.globl yyparse\n.text\n.align 16\n.type yyparse,@function\nyyparse:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nsubl $332,%esp\nmovw $0,-6(%ebp)\nmovl $-1,yychar\nmovl $0,yynerrs\nmovw $0,yyerrflag\nleal -328(%ebp),%edi\nmovl %edi,-12(%ebp)\nleal yyv-4,%edi\nmovl %edi,-20(%ebp)\n.LC168:\nmovl -12(%ebp),%edi\nleal 2(%edi),%edi\nmovl %edi,-12(%ebp)\nleal -26(%ebp),%esi\ncmpl %esi,%edi\njbe .LC169\npushl $.LC172\ncall yyerror\naddl $4,%esp\nmovl $1,%eax\njmp .LC165\n.LC169:\nmovl -12(%ebp),%edi\nmovw -6(%ebp),%si\nmovw %si,(,%edi)\nmovl -20(%ebp),%edi\nleal 4(%edi),%edi\nmovl %edi,-20(%ebp)\nmovl -20(%ebp),%edi\nmovl yyval,%esi\nmovl %esi,(,%edi)\n.LC173:\nmovswl -6(%ebp),%edi\nmovw yypact(,%edi,2),%di\nmovw %di,-14(%ebp)\nmovswl -14(%ebp),%edi\ncmpl $-1000,%edi\njg .LC174\njmp .LC176\n.LC174:\ncmpl $0,yychar\njge .LC177\ncall yylex\nmovl %eax,yychar\ncmpl $0,%eax\njge .LC179\nmovl $0,yychar\n.LC179:\n.LC177:\nmovswl -14(%ebp),%edi\nmovl yychar,%esi\nleal (%esi,%edi),%edi\nmovw %di,-14(%ebp)\nmovswl %di,%edi\ncmpl $0,%edi\njl .LC183\nmovswl -14(%ebp),%edi\ncmpl $249,%edi\njl .LC181\n.LC183:\njmp .LC176\n.LC181:\nmovswl -14(%ebp),%edi\nmovw yyact(,%edi,2),%di\nmovw %di,-14(%ebp)\nmovswl %di,%edi\nmovswl yychk(,%edi,2),%edi\ncmpl yychar,%edi\njne .LC184\nmovl $-1,yychar\nmovl yylval,%edi\nmovl %edi,yyval\nmovw -14(%ebp),%di\nmovw %di,-6(%ebp)\nmovswl yyerrflag,%edi\ncmpl $0,%edi\njle .LC168\nmovswl yyerrflag,%edi\nsubl $1,%edi\nmovw %di,yyerrflag\njmp .LC168\n.LC184:\n.LC176:\nmovswl -6(%ebp),%edi\nmovw yydef(,%edi,2),%di\nmovw %di,-14(%ebp)\nmovswl %di,%edi\ncmpl $-2,%edi\njne .LC188\ncmpl $0,yychar\njge .LC190\ncall yylex\nmovl %eax,yychar\ncmpl $0,%eax\njge .LC192\nmovl $0,yychar\n.LC192:\n.LC190:\nleal yyexca,%edi\nmovl %edi,-24(%ebp)\njmp .LC197\n.LC194:\n.LC195:\nmovl -24(%ebp),%edi\nleal 4(%edi),%edi\nmovl %edi,-24(%ebp)\n.LC197:\nmovl -24(%ebp),%edi\nmovswl (,%edi),%esi\ncmpl $-1,%esi\njne .LC194\nmovswl 2(%edi),%edi\nmovswl -6(%ebp),%esi\ncmpl %esi,%edi\njne .LC194\njmp .LC199\n.LC198:\nmovl -24(%ebp),%edi\nmovswl (,%edi),%edi\ncmpl yychar,%edi\njne .LC201\njmp .LC200\n.LC201:\n.LC199:\nmovl -24(%ebp),%edi\nleal 4(%edi),%edi\nmovl %edi,-24(%ebp)\nmovswl (,%edi),%edi\ncmpl $0,%edi\njge .LC198\n.LC200:\nmovl -24(%ebp),%edi\nmovw 2(%edi),%di\nmovw %di,-14(%ebp)\nmovswl %di,%edi\ncmpl $0,%edi\njge .LC203\nmovl $0,%eax\njmp .LC165\n.LC203:\n.LC188:\nmovswl -14(%ebp),%edi\ncmpl $0,%edi\njne .LC205\nmovswl yyerrflag,%edi\nmovl %edi,-332(%ebp)\nmovl -332(%ebp),%edi\ncmpl $0,%edi\njl .LC207\ncmpl $3,%edi\njg .LC207\njmp *.LC223(,%edi,4)\n.data\n.align 4\n.LC223:\n.long .LC210\n.long .LC213\n.long .LC213\n.long .LC220\n.text\n.LC210:\npushl $.LC211\ncall yyerror\naddl $4,%esp\n.LC212:\nincl yynerrs\n.LC213:\nmovw $3,yyerrflag\njmp .LC215\n.LC214:\nmovl -12(%ebp),%edi\nmovswl (,%edi),%edi\nmovswl yypact(,%edi,2),%edi\nleal 256(%edi),%edi\nmovw %di,-14(%ebp)\nmovswl -14(%ebp),%edi\ncmpl $0,%edi\njl .LC217\ncmpl $249,%edi\njge .LC217\nmovswl yyact(,%edi,2),%edi\nmovswl yychk(,%edi,2),%edi\ncmpl $256,%edi\njne .LC217\nmovswl -14(%ebp),%edi\nmovw yyact(,%edi,2),%di\nmovw %di,-6(%ebp)\njmp .LC168\n.LC217:\nmovl -12(%ebp),%edi\nmovswl (,%edi),%esi\nmovw yypact(,%esi,2),%si\nmovw %si,-14(%ebp)\nleal -2(%edi),%edi\nmovl %edi,-12(%ebp)\nmovl -20(%ebp),%edi\nleal -4(%edi),%edi\nmovl %edi,-20(%ebp)\n.LC215:\nmovl -12(%ebp),%edi\nleal -326(%ebp),%esi\ncmpl %esi,%edi\njae .LC214\n.LC219:\nmovl $1,%eax\njmp .LC165\n.LC220:\ncmpl $0,yychar\njne .LC221\njmp .LC219\n.LC221:\nmovl $-1,yychar\njmp .LC173\n.LC207:\n.LC205:\nmovw -14(%ebp),%di\nmovswl %di,%esi\nleal (,%esi,2),%esi\nleal yyr2(%esi),%ebx\nmovl -12(%ebp),%edx\nmovswl (,%ebx),%ecx\nleal (,%ecx,2),%ecx\nsubl %ecx,%edx\nmovl %edx,-12(%ebp)\nmovl -20(%ebp),%edx\nmovl %edx,-4(%ebp)\nmovswl (,%ebx),%ebx\nleal (,%ebx,4),%ebx\nsubl %ebx,%edx\nmovl %edx,-20(%ebp)\nmovl -20(%ebp),%ebx\nmovl 4(%ebx),%ebx\nmovl %ebx,yyval\nmovw %di,-328(%ebp)\nmovw yyr1(%esi),%di\nmovw %di,-14(%ebp)\nmovswl -14(%ebp),%edi\nmovswl yypgo(,%edi,2),%edi\nmovl -12(%ebp),%esi\nmovswl (,%esi),%esi\nleal (%esi,%edi),%edi\nleal 1(%edi),%edi\nmovw %di,-26(%ebp)\nmovswl -26(%ebp),%edi\ncmpl $249,%edi\njge .LC226\nmovw yyact(,%edi,2),%di\nmovw %di,-6(%ebp)\nmovswl %di,%edi\nmovswl yychk(,%edi,2),%edi\nmovswl -14(%ebp),%esi\nnegl %esi\ncmpl %esi,%edi\nje .LC224\n.LC226:\nmovswl -14(%ebp),%edi\nmovswl yypgo(,%edi,2),%edi\nmovw yyact(,%edi,2),%di\nmovw %di,-6(%ebp)\n.LC224:\nmovswl -328(%ebp),%edi\nmovl %edi,-332(%ebp)\nmovl -332(%ebp),%edi\ncmpl $4,%edi\njl .LC168\ncmpl $14,%edi\njg .LC168\njmp *.LC248-16(,%edi,4)\n.data\n.align 4\n.LC248:\n.long .LC230\n.long .LC231\n.long .LC233\n.long .LC235\n.long .LC237\n.long .LC239\n.long .LC241\n.long .LC168\n.long .LC243\n.long .LC245\n.long .LC247\n.text\n.LC230:\nmovw $0,yyerrflag\njmp .LC168\n.LC231:\npushl $.LC232\ncall printf\naddl $4,%esp\njmp .LC168\n.LC233:\npushl $.LC234\ncall printf\naddl $4,%esp\njmp .LC168\n.LC235:\npushl $.LC236\ncall printf\naddl $4,%esp\njmp .LC168\n.LC237:\npushl $.LC238\ncall printf\naddl $4,%esp\njmp .LC168\n.LC239:\npushl $.LC240\ncall printf\naddl $4,%esp\njmp .LC168\n.LC241:\npushl $.LC242\ncall printf\naddl $4,%esp\njmp .LC168\n.LC243:\npushl $.LC244\ncall printf\naddl $4,%esp\njmp .LC168\n.LC245:\npushl $yytext\npushl $.LC246\ncall printf\naddl $8,%esp\njmp .LC168\n.LC247:\npushl $yytext\npushl $.LC163\ncall printf\naddl $8,%esp\njmp .LC168\n.LC165:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf250:\n.size yyparse,.Lf250-yyparse\n.globl yywrap\n.align 16\n.type yywrap,@function\nyywrap:\npushl %ebp\npushl %ebx\npushl %esi\npushl %edi\nmovl %esp,%ebp\nmovl $1,%eax\n.LC251:\nmovl %ebp,%esp\npopl %edi\npopl %esi\npopl %ebx\npopl %ebp\nret\n.Lf252:\n.size yywrap,.Lf252-yywrap\n.bss\n.globl yyv\n.align 4\n.type yyv,@object\n.size yyv,600\n.comm yyv,600\n.globl yyfnd\n.align 4\n.type yyfnd,@object\n.size yyfnd,4\n.comm yyfnd,4\n.globl yyolsp\n.align 4\n.type yyolsp,@object\n.size yyolsp,4\n.comm yyolsp,4\n.globl yylsp\n.align 4\n.type yylsp,@object\n.size yylsp,4\n.comm yylsp,4\n.globl yylstate\n.align 4\n.type yylstate,@object\n.size yylstate,800\n.comm yylstate,800\n.globl yyestate\n.align 4\n.type yyestate,@object\n.size yyestate,4\n.comm yyestate,4\n.globl yytchar\n.align 4\n.type yytchar,@object\n.size yytchar,4\n.comm yytchar,4\n.globl yysbuf\n.align 1\n.type yysbuf,@object\n.size yysbuf,200\n.comm yysbuf,200\n.globl yymorfg\n.align 4\n.type yymorfg,@object\n.size yymorfg,4\n.comm yymorfg,4\n.globl yytext\n.align 1\n.type yytext,@object\n.size yytext,200\n.comm yytext,200\n.globl yyleng\n.align 4\n.type yyleng,@object\n.size yyleng,4\n.comm yyleng,4\n.globl yyval\n.align 4\n.type yyval,@object\n.size yyval,4\n.comm yyval,4\n.globl yylval\n.align 4\n.type yylval,@object\n.size yylval,4\n.comm yylval,4\n.data\n.align 1\n.LC246:\n.byte 112\n.byte 117\n.byte 115\n.byte 104\n.byte 32\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.LC244:\n.byte 108\n.byte 111\n.byte 97\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC242:\n.byte 110\n.byte 101\n.byte 103\n.byte 97\n.byte 116\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC240:\n.byte 100\n.byte 105\n.byte 118\n.byte 105\n.byte 100\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC238:\n.byte 109\n.byte 117\n.byte 108\n.byte 116\n.byte 105\n.byte 112\n.byte 108\n.byte 121\n.byte 10\n.byte 0\n.align 1\n.LC236:\n.byte 110\n.byte 101\n.byte 103\n.byte 97\n.byte 116\n.byte 101\n.byte 10\n.byte 97\n.byte 100\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC234:\n.byte 97\n.byte 100\n.byte 100\n.byte 10\n.byte 0\n.align 1\n.LC232:\n.byte 115\n.byte 116\n.byte 111\n.byte 114\n.byte 101\n.byte 10\n.byte 0\n.align 1\n.LC211:\n.byte 115\n.byte 121\n.byte 110\n.byte 116\n.byte 97\n.byte 120\n.byte 32\n.byte 101\n.byte 114\n.byte 114\n.byte 111\n.byte 114\n.byte 0\n.align 1\n.LC172:\n.byte 121\n.byte 97\n.byte 99\n.byte 99\n.byte 32\n.byte 115\n.byte 116\n.byte 97\n.byte 99\n.byte 107\n.byte 32\n.byte 111\n.byte 118\n.byte 101\n.byte 114\n.byte 102\n.byte 108\n.byte 111\n.byte 119\n.byte 0\n.align 1\n.LC163:\n.byte 37\n.byte 115\n.byte 10\n.byte 0\n.align 1\n.LC16:\n.byte 98\n.byte 97\n.byte 100\n.byte 32\n.byte 115\n.byte 119\n.byte 105\n.byte 116\n.byte 99\n.byte 104\n.byte 32\n.byte 121\n.byte 121\n.byte 108\n.byte 111\n.byte 111\n.byte 107\n.byte 32\n.byte 37\n.byte 100\n.byte 0\n.text\n.ident \"LCC: 4.1\"\n"
  },
  {
    "path": "lcc/x86/win32/tst/8q.1bk",
    "content": "1 5 8 6 3 7 2 4 \n1 6 8 3 7 4 2 5 \n1 7 4 6 8 2 5 3 \n1 7 5 8 2 4 6 3 \n2 4 6 8 3 1 7 5 \n2 5 7 1 3 8 6 4 \n2 5 7 4 1 8 6 3 \n2 6 1 7 4 8 3 5 \n2 6 8 3 1 4 7 5 \n2 7 3 6 8 5 1 4 \n2 7 5 8 1 4 6 3 \n2 8 6 1 3 5 7 4 \n3 1 7 5 8 2 4 6 \n3 5 2 8 1 7 4 6 \n3 5 2 8 6 4 7 1 \n3 5 7 1 4 2 8 6 \n3 5 8 4 1 7 2 6 \n3 6 2 5 8 1 7 4 \n3 6 2 7 1 4 8 5 \n3 6 2 7 5 1 8 4 \n3 6 4 1 8 5 7 2 \n3 6 4 2 8 5 7 1 \n3 6 8 1 4 7 5 2 \n3 6 8 1 5 7 2 4 \n3 6 8 2 4 1 7 5 \n3 7 2 8 5 1 4 6 \n3 7 2 8 6 4 1 5 \n3 8 4 7 1 6 2 5 \n4 1 5 8 2 7 3 6 \n4 1 5 8 6 3 7 2 \n4 2 5 8 6 1 3 7 \n4 2 7 3 6 8 1 5 \n4 2 7 3 6 8 5 1 \n4 2 7 5 1 8 6 3 \n4 2 8 5 7 1 3 6 \n4 2 8 6 1 3 5 7 \n4 6 1 5 2 8 3 7 \n4 6 8 2 7 1 3 5 \n4 6 8 3 1 7 5 2 \n4 7 1 8 5 2 6 3 \n4 7 3 8 2 5 1 6 \n4 7 5 2 6 1 3 8 \n4 7 5 3 1 6 8 2 \n4 8 1 3 6 2 7 5 \n4 8 1 5 7 2 6 3 \n4 8 5 3 1 7 2 6 \n5 1 4 6 8 2 7 3 \n5 1 8 4 2 7 3 6 \n5 1 8 6 3 7 2 4 \n5 2 4 6 8 3 1 7 \n5 2 4 7 3 8 6 1 \n5 2 6 1 7 4 8 3 \n5 2 8 1 4 7 3 6 \n5 3 1 6 8 2 4 7 \n5 3 1 7 2 8 6 4 \n5 3 8 4 7 1 6 2 \n5 7 1 3 8 6 4 2 \n5 7 1 4 2 8 6 3 \n5 7 2 4 8 1 3 6 \n5 7 2 6 3 1 4 8 \n5 7 2 6 3 1 8 4 \n5 7 4 1 3 8 6 2 \n5 8 4 1 3 6 2 7 \n5 8 4 1 7 2 6 3 \n6 1 5 2 8 3 7 4 \n6 2 7 1 3 5 8 4 \n6 2 7 1 4 8 5 3 \n6 3 1 7 5 8 2 4 \n6 3 1 8 4 2 7 5 \n6 3 1 8 5 2 4 7 \n6 3 5 7 1 4 2 8 \n6 3 5 8 1 4 2 7 \n6 3 7 2 4 8 1 5 \n6 3 7 2 8 5 1 4 \n6 3 7 4 1 8 2 5 \n6 4 1 5 8 2 7 3 \n6 4 2 8 5 7 1 3 \n6 4 7 1 3 5 2 8 \n6 4 7 1 8 2 5 3 \n6 8 2 4 1 7 5 3 \n7 1 3 8 6 4 2 5 \n7 2 4 1 8 5 3 6 \n7 2 6 3 1 4 8 5 \n7 3 1 6 8 5 2 4 \n7 3 8 2 5 1 6 4 \n7 4 2 5 8 1 3 6 \n7 4 2 8 6 1 3 5 \n7 5 3 1 6 8 2 4 \n8 2 4 1 7 5 3 6 \n8 2 5 3 1 7 4 6 \n8 3 1 6 2 5 7 4 \n8 4 1 3 6 2 7 5 \n"
  },
  {
    "path": "lcc/x86/win32/tst/8q.2bk",
    "content": "tst/8q.c:30: warning: missing return value\ntst/8q.c:39: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/win32/tst/8q.sbk",
    "content": ".486\n.model flat\nextrn __fltused:near\nextrn __ftol:near\npublic _main\n_TEXT segment\n_main:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\nmov dword ptr (-4)[ebp],0\nL2:\nmov edi,dword ptr (-4)[ebp]\nlea edi,[edi*4]\nmov dword ptr (_down)[edi],1\nmov dword ptr (_up)[edi],1\nL3:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],15\njl L2\nmov dword ptr (-4)[ebp],0\nL6:\nmov edi,dword ptr (-4)[ebp]\nmov dword ptr (_rows)[edi*4],1\nL7:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],8\njl L6\npush 0\ncall _queens\nadd esp,4\nmov eax,0\nL1:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _queens\n_queens:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\nmov dword ptr (-4)[ebp],0\nL11:\nmov edi,dword ptr (-4)[ebp]\ncmp dword ptr (_rows)[edi*4],0\nje L15\nmov esi,dword ptr (20)[ebp]\nmov ebx,edi\nsub ebx,esi\ncmp dword ptr (_up+28)[ebx*4],0\nje L15\nlea edi,[esi][edi]\ncmp dword ptr (_down)[edi*4],0\nje L15\nmov edi,dword ptr (-4)[ebp]\nmov esi,dword ptr (20)[ebp]\nlea ebx,[esi][edi]\nmov dword ptr (_down)[ebx*4],0\nmov ebx,edi\nsub ebx,esi\nmov dword ptr (_up+28)[ebx*4],0\nmov dword ptr (_rows)[edi*4],0\nmov edi,dword ptr (20)[ebp]\nmov esi,dword ptr (-4)[ebp]\nmov dword ptr (_x)[edi*4],esi\ncmp dword ptr (20)[ebp],7\njne L19\ncall _print\nadd esp,0\njmp L20\nL19:\nmov edi,dword ptr (20)[ebp]\nlea edi,(1)[edi]\npush edi\ncall _queens\nadd esp,4\nL20:\nmov edi,dword ptr (-4)[ebp]\nmov esi,dword ptr (20)[ebp]\nlea ebx,[esi][edi]\nmov dword ptr (_down)[ebx*4],1\nmov ebx,edi\nsub ebx,esi\nmov dword ptr (_up+28)[ebx*4],1\nmov dword ptr (_rows)[edi*4],1\nL15:\nL12:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],8\njl L11\nmov eax,0\nL10:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _print\n_print:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\nmov dword ptr (-4)[ebp],0\nL23:\nmov edi,dword ptr (-4)[ebp]\nmov edi,dword ptr (_x)[edi*4]\nlea edi,(49)[edi]\npush edi\nlea edi,(L27)\npush edi\ncall _printf\nadd esp,8\nL24:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],8\njl L23\nlea edi,(L28)\npush edi\ncall _printf\nadd esp,4\nmov eax,0\nL22:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\nextrn _printf:near\n_TEXT segment\n_TEXT ends\n_DATA segment\npublic _x\nalign 4\n_x label byte\ndb 32 dup (0)\npublic _rows\nalign 4\n_rows label byte\ndb 32 dup (0)\npublic _down\nalign 4\n_down label byte\ndb 60 dup (0)\npublic _up\nalign 4\n_up label byte\ndb 60 dup (0)\n_DATA ends\n_TEXT segment\nalign 1\nL28 label byte\ndb 10\ndb 0\nalign 1\nL27 label byte\ndb 37\ndb 99\ndb 32\ndb 0\n_TEXT ends\nend\n"
  },
  {
    "path": "lcc/x86/win32/tst/array.1bk",
    "content": " 0 1 2 3 1000 1001 1002 1003 2000 2001 2002 2003\n 0 1 2 3 1000 1001 1002 1003 2000 2001 2002 2003\n 0 1 2 3 1000 1001 1002 1003 2000 2001 2002 2003\n 0 1 2 3 1000 1001 1002 1003 2000 2001 2002 2003\n"
  },
  {
    "path": "lcc/x86/win32/tst/array.2bk",
    "content": "tst/array.c:33: warning: missing return value\ntst/array.c:48: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/win32/tst/array.sbk",
    "content": ".486\n.model flat\nextrn __fltused:near\nextrn __ftol:near\npublic _main\n_TEXT segment\n_main:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,60\nmov dword ptr (-8)[ebp],0\nL2:\nmov dword ptr (-4)[ebp],0\nL6:\nmov edi,dword ptr (-4)[ebp]\nmov esi,dword ptr (-8)[ebp]\nmov ebx,esi\nsal ebx,4\nimul esi,esi,1000\nlea esi,[edi][esi]\nmov dword ptr (_x)[ebx][edi*4],esi\nL7:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],4\njl L6\nmov edi,dword ptr (-8)[ebp]\nmov esi,edi\nsal esi,4\nlea esi,(_x)[esi]\nmov dword ptr (_y)[edi*4],esi\nL3:\ninc dword ptr (-8)[ebp]\ncmp dword ptr (-8)[ebp],3\njl L2\ncall _f\nadd esp,0\nmov dword ptr (-8)[ebp],0\nL10:\nmov edi,dword ptr (-8)[ebp]\nmov esi,edi\nsal esi,4\nlea esi,(-60)[ebp][esi]\nmov dword ptr (-12)[ebp],esi\nmov dword ptr (_y)[edi*4],esi\nmov dword ptr (-4)[ebp],0\nL14:\nmov edi,dword ptr (-4)[ebp]\nlea edi,[edi*4]\nmov esi,dword ptr (-12)[ebp]\nmov ebx,dword ptr (-8)[ebp]\nsal ebx,4\nmov ebx,dword ptr (_x)[ebx][edi]\nmov dword ptr [esi][edi],ebx\nL15:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],4\njl L14\nL11:\ninc dword ptr (-8)[ebp]\ncmp dword ptr (-8)[ebp],3\njl L10\nlea edi,(_y)\npush edi\nlea edi,(-60)[ebp]\npush edi\ncall _g\nadd esp,8\nmov eax,0\nL1:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _f\n_f:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,8\nmov dword ptr (-8)[ebp],0\nL19:\nmov dword ptr (-4)[ebp],0\nL23:\nmov edi,dword ptr (-4)[ebp]\nmov esi,dword ptr (-8)[ebp]\nsal esi,4\nmov edi,dword ptr (_x)[esi][edi*4]\npush edi\nlea edi,(L27)\npush edi\ncall _printf\nadd esp,8\nL24:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],4\njl L23\nL20:\ninc dword ptr (-8)[ebp]\ncmp dword ptr (-8)[ebp],3\njl L19\nlea edi,(L28)\npush edi\ncall _printf\nadd esp,4\nmov dword ptr (-8)[ebp],0\nL29:\nmov dword ptr (-4)[ebp],0\nL33:\nmov edi,dword ptr (-4)[ebp]\nmov esi,dword ptr (-8)[ebp]\nmov esi,dword ptr (_y)[esi*4]\nmov edi,dword ptr [esi][edi*4]\npush edi\nlea edi,(L27)\npush edi\ncall _printf\nadd esp,8\nL34:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],4\njl L33\nL30:\ninc dword ptr (-8)[ebp]\ncmp dword ptr (-8)[ebp],3\njl L29\nlea edi,(L28)\npush edi\ncall _printf\nadd esp,4\nmov eax,0\nL18:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _g\n_g:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,8\nmov dword ptr (-8)[ebp],0\nL38:\nmov dword ptr (-4)[ebp],0\nL42:\nmov edi,dword ptr (-4)[ebp]\nmov esi,dword ptr (-8)[ebp]\nsal esi,4\nmov ebx,dword ptr (20)[ebp]\nlea esi,[ebx][esi]\nmov edi,dword ptr [esi][edi*4]\npush edi\nlea edi,(L27)\npush edi\ncall _printf\nadd esp,8\nL43:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],4\njl L42\nL39:\ninc dword ptr (-8)[ebp]\ncmp dword ptr (-8)[ebp],3\njl L38\nlea edi,(L28)\npush edi\ncall _printf\nadd esp,4\nmov dword ptr (-8)[ebp],0\nL46:\nmov dword ptr (-4)[ebp],0\nL50:\nmov edi,dword ptr (-4)[ebp]\nmov esi,dword ptr (-8)[ebp]\nmov ebx,dword ptr (24)[ebp]\nmov esi,dword ptr [ebx][esi*4]\nmov edi,dword ptr [esi][edi*4]\npush edi\nlea edi,(L27)\npush edi\ncall _printf\nadd esp,8\nL51:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],4\njl L50\nL47:\ninc dword ptr (-8)[ebp]\ncmp dword ptr (-8)[ebp],3\njl L46\nlea edi,(L28)\npush edi\ncall _printf\nadd esp,4\nmov eax,0\nL37:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\nextrn _printf:near\n_TEXT segment\n_TEXT ends\n_DATA segment\npublic _y\nalign 4\n_y label byte\ndb 12 dup (0)\npublic _x\nalign 4\n_x label byte\ndb 48 dup (0)\n_DATA ends\n_TEXT segment\nalign 1\nL28 label byte\ndb 10\ndb 0\nalign 1\nL27 label byte\ndb 32\ndb 37\ndb 100\ndb 0\n_TEXT ends\nend\n"
  },
  {
    "path": "lcc/x86/win32/tst/cf.1bk",
    "content": "char\tfreq\n011\t8.1\n012\t6.1\n040\t11.9\n!\t0.2\n\"\t1.5\n%\t0.6\n&\t0.4\n'\t0.4\n(\t2.9\n)\t2.9\n*\t0.8\n+\t1.3\n,\t1.3\n-\t0.4\n.\t0.6\n/\t1.0\n0\t2.5\n1\t1.9\n2\t0.6\n3\t0.2\n7\t0.4\n8\t0.2\n;\t3.8\n<\t0.8\n=\t2.7\n>\t0.2\n[\t1.5\n\\\t0.8\n]\t1.5\na\t3.1\nc\t4.4\ne\t2.3\nf\t6.0\ng\t1.3\nh\t1.0\ni\t5.0\nl\t1.0\nm\t0.2\nn\t3.3\no\t2.1\np\t1.0\nq\t0.4\nr\t4.2\ns\t0.6\nt\t3.8\nu\t1.2\nv\t0.6\nw\t0.2\n{\t0.6\n}\t0.6\n"
  },
  {
    "path": "lcc/x86/win32/tst/cf.2bk",
    "content": ""
  },
  {
    "path": "lcc/x86/win32/tst/cf.sbk",
    "content": ".486\n.model flat\nextrn __fltused:near\nextrn __ftol:near\npublic _main\n_TEXT segment\n_main:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,24\ncmp dword ptr (20)[ebp],1\njg L2\nfld dword ptr (L4)\nfstp dword ptr (-16)[ebp]\njmp L3\nL2:\nmov edi,dword ptr (24)[ebp]\nmov edi,dword ptr (4)[edi]\npush edi\ncall _atof\nadd esp,4\nfstp dword ptr (-20)[ebp]\nfld dword ptr (-20)[ebp]\nfdiv dword ptr (L5)\nfstp dword ptr (-16)[ebp]\nL3:\nmov dword ptr (-4)[ebp],0\nL6:\nmov edi,dword ptr (-4)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-4)[ebp],esi\nfld dword ptr (L4)\nfstp dword ptr (_f)[edi*4]\nL7:\ncmp dword ptr (-4)[ebp],127\njle L6\nmov dword ptr (-8)[ebp],0\njmp L11\nL10:\nmov edi,dword ptr (-12)[ebp]\nlea edi,(_f)[edi*4]\nfld dword ptr [edi]\nfadd dword ptr (L13)\nfstp dword ptr [edi]\ninc dword ptr (-8)[ebp]\nL11:\ncall _getchar\nadd esp,0\nmov dword ptr (-12)[ebp],eax\ncmp eax,-1\njne L10\nlea edi,(L14)\npush edi\ncall _printf\nadd esp,4\nmov dword ptr (-4)[ebp],0\nL15:\nmov edi,dword ptr (-4)[ebp]\nfld dword ptr (_f)[edi*4]\nfstp dword ptr (-24)[ebp]\nfld dword ptr (L4)\nfcomp dword ptr (-24)[ebp]\nfstsw ax\nsahf\nje L19\nfld dword ptr (-24)[ebp]\nmov edi,dword ptr (-8)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfdivp st(1),st\nfld dword ptr (-16)[ebp]\nfcompp\nfstsw ax\nsahf\nja L19\ncmp dword ptr (-4)[ebp],32\njg L21\nmov edi,dword ptr (-4)[ebp]\npush edi\nlea edi,(L23)\npush edi\ncall _printf\nadd esp,8\njmp L22\nL21:\nmov edi,dword ptr (-4)[ebp]\npush edi\nlea edi,(L24)\npush edi\ncall _printf\nadd esp,8\nL22:\nfld dword ptr (L5)\nmov edi,dword ptr (-4)[ebp]\nfmul dword ptr (_f)[edi*4]\nmov edi,dword ptr (-8)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfdivp st(1),st\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L25)\npush edi\ncall _printf\nadd esp,12\nL19:\nL16:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],127\njle L15\nmov eax,0\nL1:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\nextrn _printf:near\n_TEXT segment\n_TEXT ends\nextrn _getchar:near\n_TEXT segment\n_TEXT ends\nextrn _atof:near\n_TEXT segment\n_TEXT ends\n_DATA segment\npublic _f\nalign 4\n_f label byte\ndb 512 dup (0)\n_DATA ends\n_TEXT segment\nalign 1\nL25 label byte\ndb 9\ndb 37\ndb 46\ndb 49\ndb 102\ndb 10\ndb 0\nalign 1\nL24 label byte\ndb 37\ndb 99\ndb 0\nalign 1\nL23 label byte\ndb 37\ndb 48\ndb 51\ndb 111\ndb 0\nalign 1\nL14 label byte\ndb 99\ndb 104\ndb 97\ndb 114\ndb 9\ndb 102\ndb 114\ndb 101\ndb 113\ndb 10\ndb 0\nalign 4\nL13 label byte\ndd 03f800000H\nalign 4\nL5 label byte\ndd 042c80000H\nalign 4\nL4 label byte\ndd 00H\n_TEXT ends\nend\n"
  },
  {
    "path": "lcc/x86/win32/tst/cq.1bk",
    "content": "Section s22     returned 0.\nDecimal and octal/hex constants sometimes give\n   different results when assigned to longs.\nDecimal and octal/hex constants sometimes give\n   different results when assigned to longs.\nSection s241    returned 0.\nSection s243    returned 0.\nSection s244    returned 0.\nSection s25     returned 0.\n  8 bits in chars.\n 32 bits in ints.\n 16 bits in shorts.\n 32 bits in longs.\n 32 bits in unsigneds.\n 32 bits in floats.\n 64 bits in doubles.\n1.192093e-007 is the least number that can be added to 1. (float).\n2.220446e-016 is the least number that can be added to 1. (double).\nSection s26     returned 0.\nSection s4      returned 0.\nSection s61     returned 0.\nSection s626    returned 0.\nSection s71     returned 0.\nSection s72     returned 0.\nSection s757    returned 0.\nSection s7813   returned 0.\nSection s714    returned 0.\nSection s715    returned 0.\nRegister count for char is unreliable.\nRegister count for pointer is unreliable.\nRegister count for int is unreliable.\nSection s81     returned 0.\nSection s84     returned 0.\nchar alignment: 1\nshort alignment: 2\nint alignment: 4\nlong alignment: 4\nunsigned alignment: 4\nfloat alignment: 4\ndouble alignment: 4\nSign extension in fields\nBe especially careful with 1-bit fields!\nSection s85     returned 0.\nSection s86     returned 0.\nSection s88     returned 0.\nSection s9      returned 0.\n\nNo errors detected.\n"
  },
  {
    "path": "lcc/x86/win32/tst/cq.2bk",
    "content": "tst/cq.c:394: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:394: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:394: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:395: warning: overflow in constant `4294967296'\ntst/cq.c:395: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:395: warning: overflow in constant `040000000000'\ntst/cq.c:395: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:395: warning: overflow in constant `0x100000000'\ntst/cq.c:395: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:396: warning: overflow in constant `68719476735'\ntst/cq.c:396: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:396: warning: overflow in constant `0777777777777'\ntst/cq.c:396: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:396: warning: overflow in constant `0xfffffffff'\ntst/cq.c:396: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:397: warning: overflow in constant `68719476736'\ntst/cq.c:397: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:397: warning: overflow in constant `01000000000000'\ntst/cq.c:397: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:397: warning: overflow in constant `0x1000000000'\ntst/cq.c:397: warning: overflow in converting constant expression from `unsigned long' to `long int'\ntst/cq.c:533: warning: missing return value\ntst/cq.c:1169: warning: missing return value\ntst/cq.c:5294: warning: unreachable code\ntst/cq.c:5303: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/win32/tst/cq.sbk",
    "content": ".486\n.model flat\nextrn __fltused:near\nextrn __ftol:near\n_DATA segment\nalign 4\nL2 label byte\ndd _s22\ndd _s241\ndd _s243\ndd _s244\ndd _s25\ndd _s26\ndd _s4\ndd _s61\ndd _s626\ndd _s71\ndd _s72\ndd _s757\ndd _s7813\ndd _s714\ndd _s715\ndd _s81\ndd _s84\ndd _s85\ndd _s86\ndd _s88\ndd _s9\n_DATA ends\n_DATA segment\nalign 4\nL3 label byte\ndb 68 dup (0)\nalign 4\nL4 label byte\ndb 4 dup (0)\npublic _main\n_DATA ends\n_TEXT segment\n_main:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\nmov dword ptr (L3+36),1\nmov dword ptr (L3+40),1\nmov dword ptr (L3+44),1\nmov dword ptr (L3+48),1\nlea edi,(L3)\nmov dword ptr (L4),edi\nmov dword ptr (-4)[ebp],0\njmp L12\nL9:\nmov edi,dword ptr (L4)\npush edi\nmov edi,dword ptr (-4)[ebp]\ncall dword ptr (L2)[edi*4]\nadd esp,4\nmov dword ptr (L3+52),eax\nmov edi,dword ptr (L3+56)\nmov esi,dword ptr (L3+52)\nlea edi,[esi][edi]\nmov dword ptr (L3+56),edi\ncmp dword ptr (L3+36),0\nje L17\nmov edi,dword ptr (L3+52)\npush edi\nlea edi,(L3+60)\npush edi\nlea edi,(L20)\npush edi\ncall _printf\nadd esp,12\nL17:\nL10:\ninc dword ptr (-4)[ebp]\nL12:\nmov edi,dword ptr (-4)[ebp]\ncmp edi,21\njb L9\ncmp dword ptr (L3+56),0\njne L23\nlea edi,(L26)\npush edi\ncall _printf\nadd esp,4\njmp L24\nL23:\nlea edi,(L27)\npush edi\ncall _printf\nadd esp,4\nL24:\nmov eax,0\nL1:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 1\nL29 label byte\ndb 115\ndb 50\ndb 50\ndb 44\ndb 101\ndb 114\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL30 label byte\ndb 115\ndb 50\ndb 50\ndb 32\ndb 32\ndb 32\ndb 32\ndb 0\npublic _s22\n_DATA ends\n_TEXT segment\n_s22:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,32\nmov dword ptr (-12)[ebp],0\nlea edi,(L30)\nmov dword ptr (-4)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea edi,(60)[edi]\nmov dword ptr (-8)[ebp],edi\nL31:\nL32:\nmov edi,dword ptr (-8)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-8)[ebp],esi\nmov esi,dword ptr (-4)[ebp]\nlea ebx,(1)[esi]\nmov dword ptr (-4)[ebp],ebx\nmov bl,byte ptr [esi]\nmov byte ptr [edi],bl\nmovsx edi,bl\ncmp edi,0\njne L31\nmov dword ptr (-16)[ebp],1\nmov dword ptr (-24)[ebp],2\nmov dword ptr (-28)[ebp],3\nmov dword ptr (-20)[ebp],4\nmov edi,dword ptr (-16)[ebp]\nmov esi,dword ptr (-24)[ebp]\nlea edi,[esi][edi]\nmov esi,dword ptr (-28)[ebp]\nlea edi,[esi][edi]\nmov esi,dword ptr (-20)[ebp]\nlea edi,[esi][edi]\ncmp edi,10\nje L34\ninc dword ptr (-12)[ebp]\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L36\npush 1\nlea edi,(L29)\npush edi\ncall _printf\nadd esp,8\nL36:\nL34:\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (-16)[ebp]\ncmp dword ptr (-32)[ebp],edi\njne L38\nadd dword ptr (-12)[ebp],4\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L40\npush 4\nlea edi,(L29)\npush edi\ncall _printf\nadd esp,8\nL40:\nL38:\nmov eax,dword ptr (-12)[ebp]\nL28:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 1\nL43 label byte\ndb 115\ndb 50\ndb 52\ndb 49\ndb 44\ndb 101\ndb 114\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL44 label byte\ndb 115\ndb 50\ndb 52\ndb 49\ndb 32\ndb 32\ndb 32\ndb 0\nalign 4\nL45 label byte\ndd 0\ndd 0\ndd 0\ndd 0\ndd 0\ndd 0\ndd 0\ndd 0\ndd 0\ndd 0\ndd 0\ndd 0\ndd 0\ndd 0\ndd 0\ndd 0\ndd 0\ndd 0\ndd 6\ndd 0\ndd 8\ndd 0\ndd 12\ndd 0\ndd 16\ndd 0\ndd 18\ndd 0\ndd 20\ndd 0\ndd 24\ndd 0\ndd 28\ndd 0\ndd 30\ndd 0\ndd 32\ndd 0\ndd 36\npublic _s241\n_DATA ends\n_TEXT segment\n_s241:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,488\nmov dword ptr (-484)[ebp],0\nmov dword ptr (-488)[ebp],0\nlea edi,(L44)\nmov dword ptr (-476)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea edi,(60)[edi]\nmov dword ptr (-480)[ebp],edi\nL46:\nL47:\nmov edi,dword ptr (-480)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-480)[ebp],esi\nmov esi,dword ptr (-476)[ebp]\nlea ebx,(1)[esi]\nmov dword ptr (-476)[ebp],ebx\nmov bl,byte ptr [esi]\nmov byte ptr [edi],bl\nmovsx edi,bl\ncmp edi,0\njne L46\njmp L49\ninc dword ptr (-484)[ebp]\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L51\npush 1\nlea edi,(L43)\npush edi\ncall _printf\nadd esp,8\nL51:\nL49:\njmp L53\nadd dword ptr (-484)[ebp],2\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L55\npush 2\nlea edi,(L43)\npush edi\ncall _printf\nadd esp,8\nL55:\nL53:\njmp L57\nadd dword ptr (-484)[ebp],4\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L59\npush 4\nlea edi,(L43)\npush edi\ncall _printf\nadd esp,8\nL59:\nL57:\njmp L61\nadd dword ptr (-484)[ebp],8\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L63\npush 8\nlea edi,(L43)\npush edi\ncall _printf\nadd esp,8\nL63:\nL61:\nmov dword ptr (-4)[ebp],0\nL65:\nmov edi,dword ptr (-4)[ebp]\nmov dword ptr (L45)[edi*4],edi\nL66:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],17\njl L65\nmov dword ptr (-4)[ebp],18\nL69:\nmov edi,dword ptr (-4)[ebp]\nlea edi,(L45)[edi*4]\nmov esi,dword ptr [edi]\npush esi\ncall _pow2\nadd esp,4\nmov dword ptr [edi],eax\nmov edi,dword ptr (-4)[ebp]\nlea edi,[edi*4]\nmov esi,dword ptr (L45)[edi]\nsub esi,1\nmov dword ptr (L45-4)[edi],esi\nadd dword ptr (-4)[ebp],2\nL70:\ncmp dword ptr (-4)[ebp],39\njl L69\nmov dword ptr (-160)[ebp],0\nmov dword ptr (-316)[ebp],0\nmov dword ptr (-472)[ebp],0\nmov dword ptr (-156)[ebp],1\nmov dword ptr (-312)[ebp],1\nmov dword ptr (-468)[ebp],1\nmov dword ptr (-152)[ebp],2\nmov dword ptr (-308)[ebp],2\nmov dword ptr (-464)[ebp],2\nmov dword ptr (-148)[ebp],3\nmov dword ptr (-304)[ebp],3\nmov dword ptr (-460)[ebp],3\nmov dword ptr (-144)[ebp],4\nmov dword ptr (-300)[ebp],4\nmov dword ptr (-456)[ebp],4\nmov dword ptr (-140)[ebp],5\nmov dword ptr (-296)[ebp],5\nmov dword ptr (-452)[ebp],5\nmov dword ptr (-136)[ebp],6\nmov dword ptr (-292)[ebp],6\nmov dword ptr (-448)[ebp],6\nmov dword ptr (-132)[ebp],7\nmov dword ptr (-288)[ebp],7\nmov dword ptr (-444)[ebp],7\nmov dword ptr (-128)[ebp],8\nmov dword ptr (-284)[ebp],8\nmov dword ptr (-440)[ebp],8\nmov dword ptr (-124)[ebp],9\nmov dword ptr (-280)[ebp],9\nmov dword ptr (-436)[ebp],9\nmov dword ptr (-120)[ebp],10\nmov dword ptr (-276)[ebp],10\nmov dword ptr (-432)[ebp],10\nmov dword ptr (-116)[ebp],11\nmov dword ptr (-272)[ebp],11\nmov dword ptr (-428)[ebp],11\nmov dword ptr (-112)[ebp],12\nmov dword ptr (-268)[ebp],12\nmov dword ptr (-424)[ebp],12\nmov dword ptr (-108)[ebp],13\nmov dword ptr (-264)[ebp],13\nmov dword ptr (-420)[ebp],13\nmov dword ptr (-104)[ebp],14\nmov dword ptr (-260)[ebp],14\nmov dword ptr (-416)[ebp],14\nmov dword ptr (-100)[ebp],15\nmov dword ptr (-256)[ebp],15\nmov dword ptr (-412)[ebp],15\nmov dword ptr (-96)[ebp],16\nmov dword ptr (-252)[ebp],16\nmov dword ptr (-408)[ebp],16\nmov dword ptr (-92)[ebp],63\nmov dword ptr (-248)[ebp],63\nmov dword ptr (-404)[ebp],63\nmov dword ptr (-88)[ebp],64\nmov dword ptr (-244)[ebp],64\nmov dword ptr (-400)[ebp],64\nmov dword ptr (-84)[ebp],255\nmov dword ptr (-240)[ebp],255\nmov dword ptr (-396)[ebp],255\nmov dword ptr (-80)[ebp],256\nmov dword ptr (-236)[ebp],256\nmov dword ptr (-392)[ebp],256\nmov dword ptr (-76)[ebp],4095\nmov dword ptr (-232)[ebp],4095\nmov dword ptr (-388)[ebp],4095\nmov dword ptr (-72)[ebp],4096\nmov dword ptr (-228)[ebp],4096\nmov dword ptr (-384)[ebp],4096\nmov dword ptr (-68)[ebp],65535\nmov dword ptr (-224)[ebp],65535\nmov dword ptr (-380)[ebp],65535\nmov dword ptr (-64)[ebp],65536\nmov dword ptr (-220)[ebp],65536\nmov dword ptr (-376)[ebp],65536\nmov dword ptr (-60)[ebp],262143\nmov dword ptr (-216)[ebp],262143\nmov dword ptr (-372)[ebp],262143\nmov dword ptr (-56)[ebp],262144\nmov dword ptr (-212)[ebp],262144\nmov dword ptr (-368)[ebp],262144\nmov dword ptr (-52)[ebp],1048575\nmov dword ptr (-208)[ebp],1048575\nmov dword ptr (-364)[ebp],1048575\nmov dword ptr (-48)[ebp],1048576\nmov dword ptr (-204)[ebp],1048576\nmov dword ptr (-360)[ebp],1048576\nmov dword ptr (-44)[ebp],16777215\nmov dword ptr (-200)[ebp],16777215\nmov dword ptr (-356)[ebp],16777215\nmov dword ptr (-40)[ebp],16777216\nmov dword ptr (-196)[ebp],16777216\nmov dword ptr (-352)[ebp],16777216\nmov dword ptr (-36)[ebp],268435455\nmov dword ptr (-192)[ebp],268435455\nmov dword ptr (-348)[ebp],268435455\nmov dword ptr (-32)[ebp],268435456\nmov dword ptr (-188)[ebp],268435456\nmov dword ptr (-344)[ebp],268435456\nmov dword ptr (-28)[ebp],1073741823\nmov dword ptr (-184)[ebp],1073741823\nmov dword ptr (-340)[ebp],1073741823\nmov dword ptr (-24)[ebp],1073741824\nmov dword ptr (-180)[ebp],1073741824\nmov dword ptr (-336)[ebp],1073741824\nmov edi,0ffffffffH\nmov dword ptr (-20)[ebp],edi\nmov edi,0ffffffffH\nmov dword ptr (-176)[ebp],edi\nmov edi,0ffffffffH\nmov dword ptr (-332)[ebp],edi\nmov edi,0ffffffffH\nmov dword ptr (-16)[ebp],edi\nmov edi,0ffffffffH\nmov dword ptr (-172)[ebp],edi\nmov edi,0ffffffffH\nmov dword ptr (-328)[ebp],edi\nmov edi,0ffffffffH\nmov dword ptr (-12)[ebp],edi\nmov edi,0ffffffffH\nmov dword ptr (-168)[ebp],edi\nmov edi,0ffffffffH\nmov dword ptr (-324)[ebp],edi\nmov edi,0ffffffffH\nmov dword ptr (-8)[ebp],edi\nmov edi,0ffffffffH\nmov dword ptr (-164)[ebp],edi\nmov edi,0ffffffffH\nmov dword ptr (-320)[ebp],edi\nmov dword ptr (-4)[ebp],0\nL188:\nmov edi,dword ptr (-4)[ebp]\nlea edi,[edi*4]\nmov esi,dword ptr (-160)[ebp][edi]\ncmp dword ptr (L45)[edi],esi\njne L195\nmov ebx,dword ptr (-316)[ebp][edi]\ncmp esi,ebx\njne L195\ncmp ebx,dword ptr (-472)[ebp][edi]\nje L192\nL195:\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (40)[edi],0\nje L196\nlea edi,(L198)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L199)\npush edi\ncall _printf\nadd esp,4\nL196:\nL192:\nL189:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],39\njl L188\ncmp dword ptr (-488)[ebp],0\nje L200\nmov dword ptr (-484)[ebp],16\nL200:\nmov eax,dword ptr (-484)[ebp]\nL42:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _pow2\n_pow2:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\nmov dword ptr (-4)[ebp],1\njmp L204\nL203:\nsal dword ptr (-4)[ebp],1\nL204:\nmov edi,dword ptr (20)[ebp]\nmov esi,edi\nsub esi,1\nmov dword ptr (20)[ebp],esi\ncmp edi,0\njne L203\nmov eax,dword ptr (-4)[ebp]\nL202:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 1\nL207 label byte\ndb 115\ndb 50\ndb 52\ndb 51\ndb 44\ndb 101\ndb 114\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL208 label byte\ndb 115\ndb 50\ndb 52\ndb 51\ndb 32\ndb 32\ndb 32\ndb 0\npublic _s243\n_DATA ends\n_TEXT segment\n_s243:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,268\nmov dword ptr (-268)[ebp],0\nlea edi,(L208)\nmov dword ptr (-260)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea edi,(60)[edi]\nmov dword ptr (-264)[ebp],edi\nL209:\nL210:\nmov edi,dword ptr (-264)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-264)[ebp],esi\nmov esi,dword ptr (-260)[ebp]\nlea ebx,(1)[esi]\nmov dword ptr (-260)[ebp],ebx\nmov bl,byte ptr [esi]\nmov byte ptr [edi],bl\nmovsx edi,bl\ncmp edi,0\njne L209\nlea edi,(-256)[ebp]\npush edi\ncall _zerofill\nadd esp,4\nmov byte ptr (-159)[ebp],1\nmov byte ptr (-191)[ebp],1\nmov byte ptr (-130)[ebp],1\nmov byte ptr (-208)[ebp],1\nmov byte ptr (-158)[ebp],1\nmov byte ptr (-190)[ebp],1\nmov byte ptr (-223)[ebp],1\nmov byte ptr (-207)[ebp],1\nmov byte ptr (-157)[ebp],1\nmov byte ptr (-189)[ebp],1\nmov byte ptr (-222)[ebp],1\nmov byte ptr (-206)[ebp],1\nmov byte ptr (-156)[ebp],1\nmov byte ptr (-188)[ebp],1\nmov byte ptr (-221)[ebp],1\nmov byte ptr (-205)[ebp],1\nmov byte ptr (-155)[ebp],1\nmov byte ptr (-187)[ebp],1\nmov byte ptr (-219)[ebp],1\nmov byte ptr (-204)[ebp],1\nmov byte ptr (-154)[ebp],1\nmov byte ptr (-186)[ebp],1\nmov byte ptr (-218)[ebp],1\nmov byte ptr (-203)[ebp],1\nmov byte ptr (-153)[ebp],1\nmov byte ptr (-185)[ebp],1\nmov byte ptr (-216)[ebp],1\nmov byte ptr (-202)[ebp],1\nmov byte ptr (-152)[ebp],1\nmov byte ptr (-184)[ebp],1\nmov byte ptr (-215)[ebp],1\nmov byte ptr (-201)[ebp],1\nmov byte ptr (-151)[ebp],1\nmov byte ptr (-183)[ebp],1\nmov byte ptr (-161)[ebp],1\nmov byte ptr (-200)[ebp],1\nmov byte ptr (-150)[ebp],1\nmov byte ptr (-182)[ebp],1\nmov byte ptr (-195)[ebp],1\nmov byte ptr (-199)[ebp],1\nmov byte ptr (-149)[ebp],1\nmov byte ptr (-181)[ebp],1\nmov byte ptr (-211)[ebp],1\nmov byte ptr (-148)[ebp],1\nmov byte ptr (-180)[ebp],1\nmov byte ptr (-162)[ebp],1\nmov byte ptr (-147)[ebp],1\nmov byte ptr (-179)[ebp],1\nmov byte ptr (-132)[ebp],1\nmov byte ptr (-246)[ebp],1\nmov byte ptr (-146)[ebp],1\nmov byte ptr (-178)[ebp],1\nmov byte ptr (-247)[ebp],1\nmov byte ptr (-145)[ebp],1\nmov byte ptr (-177)[ebp],1\nmov byte ptr (-133)[ebp],1\nmov byte ptr (-248)[ebp],1\nmov byte ptr (-144)[ebp],1\nmov byte ptr (-176)[ebp],1\nmov byte ptr (-131)[ebp],1\nmov byte ptr (-243)[ebp],1\nmov byte ptr (-143)[ebp],1\nmov byte ptr (-175)[ebp],1\nmov byte ptr (-165)[ebp],1\nmov byte ptr (-244)[ebp],1\nmov byte ptr (-142)[ebp],1\nmov byte ptr (-174)[ebp],1\nmov byte ptr (-163)[ebp],1\nmov byte ptr (-141)[ebp],1\nmov byte ptr (-173)[ebp],1\nmov byte ptr (-213)[ebp],1\nmov byte ptr (-164)[ebp],1\nmov byte ptr (-140)[ebp],1\nmov byte ptr (-172)[ebp],1\nmov byte ptr (-197)[ebp],1\nmov byte ptr (-217)[ebp],1\nmov byte ptr (-139)[ebp],1\nmov byte ptr (-171)[ebp],1\nmov byte ptr (-214)[ebp],1\nmov byte ptr (-138)[ebp],1\nmov byte ptr (-170)[ebp],1\nmov byte ptr (-198)[ebp],1\nmov byte ptr (-256)[ebp],1\nmov byte ptr (-137)[ebp],1\nmov byte ptr (-169)[ebp],1\nmov byte ptr (-196)[ebp],1\nmov byte ptr (-224)[ebp],1\nmov byte ptr (-136)[ebp],1\nmov byte ptr (-168)[ebp],1\nmov byte ptr (-194)[ebp],1\nmov byte ptr (-135)[ebp],1\nmov byte ptr (-167)[ebp],1\nmov byte ptr (-212)[ebp],1\nmov byte ptr (-134)[ebp],1\nmov byte ptr (-166)[ebp],1\nmov byte ptr (-210)[ebp],1\nmov byte ptr (-193)[ebp],1\nmov byte ptr (-209)[ebp],1\nlea edi,(-256)[ebp]\npush edi\ncall _sumof\nadd esp,4\ncmp eax,98\nje L309\ninc dword ptr (-268)[ebp]\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L311\npush 1\nlea edi,(L207)\npush edi\ncall _printf\nadd esp,8\nL311:\nL309:\njmp L313\nadd dword ptr (-268)[ebp],8\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L315\npush 8\nlea edi,(L207)\npush edi\ncall _printf\nadd esp,8\nL315:\nL313:\nmov eax,dword ptr (-268)[ebp]\nL206:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _zerofill\n_zerofill:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\nmov dword ptr (-4)[ebp],0\nL318:\nmov edi,dword ptr (20)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (20)[ebp],esi\nmov byte ptr [edi],0\nL319:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],256\njl L318\nmov eax,0\nL317:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _sumof\n_sumof:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,12\nmov edi,dword ptr (20)[ebp]\nmov dword ptr (-12)[ebp],edi\nmov dword ptr (-4)[ebp],0\nmov dword ptr (-8)[ebp],0\nL323:\nmov edi,dword ptr (-12)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-12)[ebp],esi\nmovsx edi,byte ptr [edi]\nadd dword ptr (-4)[ebp],edi\nL324:\ninc dword ptr (-8)[ebp]\ncmp dword ptr (-8)[ebp],256\njl L323\nmov eax,dword ptr (-4)[ebp]\nL322:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 1\nL328 label byte\ndb 115\ndb 50\ndb 52\ndb 52\ndb 44\ndb 101\ndb 114\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL329 label byte\ndb 115\ndb 50\ndb 52\ndb 52\ndb 32\ndb 32\ndb 32\ndb 0\npublic _s244\n_DATA ends\n_TEXT segment\n_s244:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,92\nlea edi,(L329)\nmov dword ptr (-72)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea edi,(60)[edi]\nmov dword ptr (-76)[ebp],edi\nL330:\nL331:\nmov edi,dword ptr (-76)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-76)[ebp],esi\nmov esi,dword ptr (-72)[ebp]\nlea ebx,(1)[esi]\nmov dword ptr (-72)[ebp],ebx\nmov bl,byte ptr [esi]\nmov byte ptr [edi],bl\nmovsx edi,bl\ncmp edi,0\njne L330\nmov dword ptr (-84)[ebp],0\nmov dword ptr (-80)[ebp],0\nfld qword ptr (L333)\nfstp qword ptr (-68)[ebp]\nfld qword ptr (L333)\nfstp qword ptr (-60)[ebp]\nfld qword ptr (L333)\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L333)\nfstp qword ptr (-44)[ebp]\nfld qword ptr (L333)\nfstp qword ptr (-36)[ebp]\nfld qword ptr (L333)\nfstp qword ptr (-28)[ebp]\nfld qword ptr (L333)\nfstp qword ptr (-20)[ebp]\nfld qword ptr (L333)\nfstp qword ptr (-12)[ebp]\nmov dword ptr (-80)[ebp],0\nmov dword ptr (-4)[ebp],0\nL341:\nmov edi,dword ptr (-4)[ebp]\nlea edi,[edi*8]\nfld qword ptr (-60)[ebp][edi]\nfcomp qword ptr (-68)[ebp][edi]\nfstsw ax\nsahf\nje L345\nmov dword ptr (-80)[ebp],1\nL345:\nL342:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],7\njl L341\ncmp dword ptr (-80)[ebp],0\nje L348\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L350\npush 1\nlea edi,(L328)\npush edi\ncall _printf\nadd esp,8\nL350:\ninc dword ptr (-84)[ebp]\nL348:\njmp L352\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L354\npush 2\nlea edi,(L328)\npush edi\ncall _printf\nadd esp,8\nL354:\nadd dword ptr (-84)[ebp],2\nL352:\nmov eax,dword ptr (-84)[ebp]\nL327:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 1\nL357 label byte\ndb 115\ndb 50\ndb 53\ndb 44\ndb 101\ndb 114\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL358 label byte\ndb 115\ndb 50\ndb 53\ndb 32\ndb 32\ndb 32\ndb 32\ndb 0\npublic _s25\n_DATA ends\n_TEXT segment\n_s25:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,28\nlea edi,(L358)\nmov dword ptr (-16)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea edi,(60)[edi]\nmov dword ptr (-20)[ebp],edi\nL359:\nL360:\nmov edi,dword ptr (-20)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-20)[ebp],esi\nmov esi,dword ptr (-16)[ebp]\nlea ebx,(1)[esi]\nmov dword ptr (-16)[ebp],ebx\nmov bl,byte ptr [esi]\nmov byte ptr [edi],bl\nmovsx edi,bl\ncmp edi,0\njne L359\nmov dword ptr (-24)[ebp],0\nlea edi,(L362)\nmov dword ptr (-8)[ebp],edi\nmov edi,dword ptr (-8)[ebp]\nmovsx esi,byte ptr (1)[edi]\nmovsx ebx,byte ptr [edi]\ncmp ebx,esi\njne L366\nmovsx edi,byte ptr (2)[edi]\ncmp esi,edi\njne L366\ncmp edi,46\nje L363\nL366:\ninc dword ptr (-24)[ebp]\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L367\npush 1\nlea edi,(L357)\npush edi\ncall _printf\nadd esp,8\nL367:\nL363:\nmov edi,dword ptr (-8)[ebp]\nmovsx edi,byte ptr (3)[edi]\ncmp edi,0\nje L369\nadd dword ptr (-24)[ebp],4\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L371\npush 4\nlea edi,(L357)\npush edi\ncall _printf\nadd esp,8\nL371:\nL369:\nmovsx edi,byte ptr (L375+1)\ncmp edi,34\nje L373\nadd dword ptr (-24)[ebp],8\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L377\npush 8\nlea edi,(L357)\npush edi\ncall _printf\nadd esp,8\nL377:\nL373:\nlea edi,(L379)\nmov dword ptr (-8)[ebp],edi\nmov edi,dword ptr (-8)[ebp]\nmovsx esi,byte ptr [edi]\ncmp esi,10\njne L387\nmovsx esi,byte ptr (1)[edi]\ncmp esi,9\njne L387\nmovsx esi,byte ptr (2)[edi]\ncmp esi,8\njne L387\nmovsx esi,byte ptr (3)[edi]\ncmp esi,13\njne L387\nmovsx esi,byte ptr (4)[edi]\ncmp esi,12\njne L387\nmovsx esi,byte ptr (5)[edi]\ncmp esi,92\njne L387\nmovsx edi,byte ptr (6)[edi]\ncmp edi,39\nje L380\nL387:\nadd dword ptr (-24)[ebp],16\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L388\npush 16\nlea edi,(L357)\npush edi\ncall _printf\nadd esp,8\nL388:\nL380:\nlea edi,(L390)\nmov dword ptr (-12)[ebp],edi\nmov dword ptr (-8)[ebp],edi\nmov dword ptr (-28)[ebp],0\nmov dword ptr (-4)[ebp],0\njmp L394\nL391:\nmov edi,dword ptr (-4)[ebp]\nmov esi,dword ptr (-8)[ebp]\nmovsx esi,byte ptr [esi][edi]\nmov ebx,dword ptr (-12)[ebp]\nmovsx edi,byte ptr [ebx][edi]\ncmp esi,edi\nje L395\nmov dword ptr (-28)[ebp],1\nL395:\nL392:\ninc dword ptr (-4)[ebp]\nL394:\nmov edi,dword ptr (-4)[ebp]\ncmp edi,7\njb L391\ncmp dword ptr (-28)[ebp],0\nje L397\nadd dword ptr (-24)[ebp],32\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L399\npush 32\nlea edi,(L357)\npush edi\ncall _printf\nadd esp,8\nL399:\nL397:\nmov eax,dword ptr (-24)[ebp]\nL356:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 1\nL402 label byte\ndb 115\ndb 50\ndb 54\ndb 32\ndb 32\ndb 32\ndb 32\ndb 0\nalign 1\nL403 label byte\ndb 37\ndb 51\ndb 100\ndb 32\ndb 98\ndb 105\ndb 116\ndb 115\ndb 32\ndb 105\ndb 110\ndb 32\ndb 37\ndb 115\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL404 label byte\ndb 37\ndb 101\ndb 32\ndb 105\ndb 115\ndb 32\ndb 116\ndb 104\ndb 101\ndb 32\ndb 108\ndb 101\ndb 97\ndb 115\ndb 116\ndb 32\ndb 110\ndb 117\ndb 109\ndb 98\ndb 101\ndb 114\ndb 32\ndb 116\ndb 104\ndb 97\ndb 116\ndb 32\ndb 99\ndb 97\ndb 110\ndb 32\ndb 98\ndb 101\ndb 32\ndb 97\ndb 100\ndb 100\ndb 101\ndb 100\ndb 32\ndb 116\ndb 111\ndb 32\ndb 49\ndb 46\ndb 32\ndb 40\ndb 37\ndb 115\ndb 41\ndb 46\ndb 10\ndb 0\npublic _s26\n_DATA ends\n_TEXT segment\n_s26:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,56\nlea edi,(L402)\nmov dword ptr (-36)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea edi,(60)[edi]\nmov dword ptr (-40)[ebp],edi\nL405:\nL406:\nmov edi,dword ptr (-40)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-40)[ebp],esi\nmov esi,dword ptr (-36)[ebp]\nlea ebx,(1)[esi]\nmov dword ptr (-36)[ebp],ebx\nmov bl,byte ptr [esi]\nmov byte ptr [edi],bl\nmovsx edi,bl\ncmp edi,0\njne L405\nmov edi,dword ptr (20)[ebp]\nmov dword ptr [edi],0\nmov byte ptr (-41)[ebp],0\nmov byte ptr (-5)[ebp],1\njmp L409\nL408:\nmovsx edi,byte ptr (-5)[ebp]\nlea edi,[edi*2]\nmov ebx,edi\nmov byte ptr (-5)[ebp],bl\nmov edi,dword ptr (20)[ebp]\ninc dword ptr [edi]\nL409:\nmovsx edi,byte ptr (-41)[ebp]\nmovsx esi,byte ptr (-5)[ebp]\ncmp edi,esi\njne L408\nmov edi,dword ptr (20)[ebp]\nmov esi,dword ptr [edi]\nlea esi,[esi*4]\nmov dword ptr (4)[edi],esi\nmov edi,dword ptr (20)[ebp]\nmov esi,dword ptr [edi]\nlea esi,[esi*2]\nmov dword ptr (8)[edi],esi\nmov edi,dword ptr (20)[ebp]\nmov esi,dword ptr [edi]\nlea esi,[esi*4]\nmov dword ptr (12)[edi],esi\nmov edi,dword ptr (20)[ebp]\nmov esi,dword ptr [edi]\nlea esi,[esi*4]\nmov dword ptr (16)[edi],esi\nmov edi,dword ptr (20)[ebp]\nmov esi,dword ptr [edi]\nlea esi,[esi*4]\nmov dword ptr (20)[edi],esi\nmov edi,dword ptr (20)[ebp]\nmov esi,dword ptr [edi]\nlea esi,[esi*8]\nmov dword ptr (24)[edi],esi\nfld dword ptr (L411)\nfstp dword ptr (-16)[ebp]\nfld dword ptr (L411)\nfstp dword ptr (-4)[ebp]\nfld dword ptr (L412)\nfstp dword ptr (-12)[ebp]\njmp L414\nL413:\nfld dword ptr (-16)[ebp]\nfadd dword ptr (-4)[ebp]\nfstp dword ptr (-12)[ebp]\nfld dword ptr (-4)[ebp]\nfdiv qword ptr (L416)\nfstp dword ptr (-4)[ebp]\nL414:\nfld dword ptr (-16)[ebp]\nfcomp dword ptr (-12)[ebp]\nfstsw ax\nsahf\njne L413\nmov edi,dword ptr (20)[ebp]\nfld qword ptr (L417)\nfmul dword ptr (-4)[ebp]\nfstp dword ptr (28)[edi]\nfld qword ptr (L418)\nfstp qword ptr (-32)[ebp]\nfld dword ptr (L411)\nfstp dword ptr (-4)[ebp]\nfld qword ptr (L419)\nfstp qword ptr (-24)[ebp]\njmp L421\nL420:\nfld dword ptr (-4)[ebp]\nfstp qword ptr (-56)[ebp]\nfld qword ptr (-32)[ebp]\nfadd qword ptr (-56)[ebp]\nfstp qword ptr (-24)[ebp]\nfld qword ptr (-56)[ebp]\nfdiv qword ptr (L416)\nfstp dword ptr (-4)[ebp]\nL421:\nfld qword ptr (-32)[ebp]\nfcomp qword ptr (-24)[ebp]\nfstsw ax\nsahf\njne L420\nmov edi,dword ptr (20)[ebp]\nfld qword ptr (L417)\nfmul dword ptr (-4)[ebp]\nfstp dword ptr (32)[edi]\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (40)[edi],0\nje L423\nlea edi,(L425)\npush edi\nmov edi,dword ptr (20)[ebp]\nmov edi,dword ptr [edi]\npush edi\nlea edi,(L403)\npush edi\ncall _printf\nadd esp,12\nlea edi,(L426)\npush edi\nmov edi,dword ptr (20)[ebp]\nmov edi,dword ptr (4)[edi]\npush edi\nlea edi,(L403)\npush edi\ncall _printf\nadd esp,12\nlea edi,(L427)\npush edi\nmov edi,dword ptr (20)[ebp]\nmov edi,dword ptr (8)[edi]\npush edi\nlea edi,(L403)\npush edi\ncall _printf\nadd esp,12\nlea edi,(L428)\npush edi\nmov edi,dword ptr (20)[ebp]\nmov edi,dword ptr (12)[edi]\npush edi\nlea edi,(L403)\npush edi\ncall _printf\nadd esp,12\nlea edi,(L429)\npush edi\nmov edi,dword ptr (20)[ebp]\nmov edi,dword ptr (16)[edi]\npush edi\nlea edi,(L403)\npush edi\ncall _printf\nadd esp,12\nlea edi,(L430)\npush edi\nmov edi,dword ptr (20)[ebp]\nmov edi,dword ptr (20)[edi]\npush edi\nlea edi,(L403)\npush edi\ncall _printf\nadd esp,12\nlea edi,(L431)\npush edi\nmov edi,dword ptr (20)[ebp]\nmov edi,dword ptr (24)[edi]\npush edi\nlea edi,(L403)\npush edi\ncall _printf\nadd esp,12\nlea edi,(L430)\npush edi\nmov edi,dword ptr (20)[ebp]\nfld dword ptr (28)[edi]\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L404)\npush edi\ncall _printf\nadd esp,16\nlea edi,(L431)\npush edi\nmov edi,dword ptr (20)[ebp]\nfld dword ptr (32)[edi]\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L404)\npush edi\ncall _printf\nadd esp,16\nL423:\nmov eax,0\nL401:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 1\nL433 label byte\ndb 115\ndb 52\ndb 44\ndb 101\ndb 114\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL434 label byte\ndb 115\ndb 52\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 0\npublic _s4\n_DATA ends\n_TEXT segment\n_s4:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,36\nmov dword ptr (-24)[ebp],0\nlea edi,(L434)\nmov dword ptr (-16)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea edi,(60)[edi]\nmov dword ptr (-20)[ebp],edi\nL435:\nL436:\nmov edi,dword ptr (-20)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-20)[ebp],esi\nmov esi,dword ptr (-16)[ebp]\nlea ebx,(1)[esi]\nmov dword ptr (-16)[ebp],ebx\nmov bl,byte ptr [esi]\nmov byte ptr [edi],bl\nmovsx edi,bl\ncmp edi,0\njne L435\nmov dword ptr (-4)[ebp],0\nL438:\nmov edi,dword ptr (-4)[ebp]\npush edi\ncall _svtest\nadd esp,4\nmov edi,eax\ncall _zero\nadd esp,0\ncmp edi,eax\nje L442\nmov dword ptr (-24)[ebp],1\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L444\npush 1\nlea edi,(L433)\npush edi\ncall _printf\nadd esp,8\nL444:\nL442:\nL439:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],3\njl L438\ncall _setev\nadd esp,0\ncall _testev\nadd esp,0\ncmp eax,0\nje L446\nadd dword ptr (-24)[ebp],2\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L448\npush 2\nlea edi,(L433)\npush edi\ncall _printf\nadd esp,8\nL448:\nL446:\njmp L450\nadd dword ptr (-24)[ebp],4\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L452\npush 4\nlea edi,(L433)\npush edi\ncall _printf\nadd esp,8\nL452:\nL450:\nmov dword ptr (-8)[ebp],0ffffffffH\nmov dword ptr (-12)[ebp],1\nmov dword ptr (-4)[ebp],0\njmp L457\nL454:\nmov edi,dword ptr (-8)[ebp]\nand dword ptr (-12)[ebp],edi\nshr edi,1\nmov dword ptr (-8)[ebp],edi\nL455:\ninc dword ptr (-4)[ebp]\nL457:\nmov edi,dword ptr (-4)[ebp]\nmov esi,dword ptr (20)[ebp]\nmov esi,dword ptr [esi]\nlea esi,[esi*4]\ncmp edi,esi\njb L454\nmov edi,dword ptr (-12)[ebp]\ncmp edi,1\njne L460\nmov edi,dword ptr (-8)[ebp]\ncmp edi,0\nje L458\nL460:\nadd dword ptr (-24)[ebp],8\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L461\npush 8\nlea edi,(L433)\npush edi\ncall _printf\nadd esp,8\nL461:\nL458:\nmov eax,dword ptr (-24)[ebp]\nL432:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 4\nL464 label byte\ndb 4 dup (0)\npublic _svtest\n_DATA ends\n_TEXT segment\n_svtest:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\nmov edi,dword ptr (20)[ebp]\ncmp edi,0\nje L467\ncmp edi,1\nje L468\ncmp edi,2\nje L471\njmp L465\nL467:\nmov dword ptr (L464),1978\nmov dword ptr (-4)[ebp],0\njmp L466\nL468:\ncmp dword ptr (L464),1978\nje L469\nmov dword ptr (-4)[ebp],1\njmp L466\nL469:\nmov dword ptr (L464),1929\nmov dword ptr (-4)[ebp],0\njmp L466\nL471:\ncmp dword ptr (L464),1929\nje L472\nmov dword ptr (-4)[ebp],1\njmp L466\nL472:\nmov dword ptr (-4)[ebp],0\nL465:\nL466:\nmov eax,dword ptr (-4)[ebp]\nL463:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 4\nL475 label byte\ndb 4 dup (0)\npublic _zero\n_DATA ends\n_TEXT segment\n_zero:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\nmov dword ptr (L475),2\nmov dword ptr (-4)[ebp],0\nmov eax,dword ptr (-4)[ebp]\nL474:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _testev\n_testev:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\ncmp dword ptr (_extvar),1066\nje L477\nmov eax,1\njmp L476\nL477:\nmov eax,0\nL476:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 1\nL480 label byte\ndb 115\ndb 54\ndb 49\ndb 44\ndb 101\ndb 114\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL481 label byte\ndb 115\ndb 54\ndb 49\ndb 32\ndb 32\ndb 32\ndb 32\ndb 0\nalign 1\nL482 label byte\ndb 65\ndb 66\ndb 67\ndb 68\ndb 69\ndb 70\ndb 71\ndb 72\ndb 73\ndb 74\ndb 75\ndb 76\ndb 77\ndb 78\ndb 79\ndb 80\ndb 81\ndb 82\ndb 83\ndb 84\ndb 85\ndb 86\ndb 87\ndb 88\ndb 89\ndb 90\ndb 0\nalign 1\nL483 label byte\ndb 97\ndb 98\ndb 99\ndb 100\ndb 101\ndb 102\ndb 103\ndb 104\ndb 105\ndb 106\ndb 107\ndb 108\ndb 109\ndb 110\ndb 111\ndb 112\ndb 113\ndb 114\ndb 115\ndb 116\ndb 117\ndb 118\ndb 119\ndb 120\ndb 121\ndb 122\ndb 0\nalign 1\nL484 label byte\ndb 48\ndb 49\ndb 50\ndb 51\ndb 52\ndb 53\ndb 54\ndb 55\ndb 56\ndb 57\ndb 0\nalign 1\nL485 label byte\ndb 126\ndb 33\ndb 34\ndb 35\ndb 37\ndb 38\ndb 40\ndb 41\ndb 95\ndb 61\ndb 45\ndb 94\ndb 124\ndb 123\ndb 125\ndb 91\ndb 93\ndb 43\ndb 59\ndb 42\ndb 58\ndb 60\ndb 62\ndb 44\ndb 46\ndb 63\ndb 47\ndb 0\nalign 1\nL486 label byte\ndb 10\ndb 9\ndb 8\ndb 13\ndb 12\ndb 92\ndb 39\ndb 0\nalign 1\nL487 label byte\ndb 32\ndb 0\ndb 0\npublic _s61\n_DATA ends\n_TEXT segment\n_s61:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,60\nlea edi,(L481)\nmov dword ptr (-36)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea edi,(60)[edi]\nmov dword ptr (-40)[ebp],edi\nmov dword ptr (-48)[ebp],0\nL488:\nL489:\nmov edi,dword ptr (-40)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-40)[ebp],esi\nmov esi,dword ptr (-36)[ebp]\nlea ebx,(1)[esi]\nmov dword ptr (-36)[ebp],ebx\nmov bl,byte ptr [esi]\nmov byte ptr [edi],bl\nmovsx edi,bl\ncmp edi,0\njne L488\nmov word ptr (-54)[ebp],-19\nmovsx edi,word ptr (-54)[ebp]\nmov dword ptr (-60)[ebp],edi\ncmp dword ptr (-60)[ebp],-19\nje L491\ninc dword ptr (-48)[ebp]\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L493\npush 1\nlea edi,(L480)\npush edi\ncall _printf\nadd esp,8\nL493:\nL491:\nlea edi,(L482)\nmov dword ptr (-28)[ebp],edi\nlea edi,(L483)\nmov dword ptr (-24)[ebp],edi\nlea edi,(L484)\nmov dword ptr (-20)[ebp],edi\nlea edi,(L485)\nmov dword ptr (-16)[ebp],edi\nlea edi,(L486)\nmov dword ptr (-12)[ebp],edi\nlea edi,(L487)\nmov dword ptr (-8)[ebp],edi\nmov dword ptr (-32)[ebp],0\nmov dword ptr (-4)[ebp],0\njmp L505\nL504:\nmov edi,dword ptr (-4)[ebp]\nlea edi,(-28)[ebp][edi*4]\nmov esi,dword ptr [edi]\nlea ebx,(1)[esi]\nmov dword ptr [edi],ebx\nmovsx edi,byte ptr [esi]\ncmp edi,0\njge L507\nmov dword ptr (-32)[ebp],1\nL507:\nL505:\nmov edi,dword ptr (-4)[ebp]\nmov edi,dword ptr (-28)[ebp][edi*4]\nmovsx edi,byte ptr [edi]\ncmp edi,0\njne L504\nL501:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],6\njl L505\ncmp dword ptr (-32)[ebp],0\nje L509\nadd dword ptr (-48)[ebp],2\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L511\npush 2\nlea edi,(L480)\npush edi\ncall _printf\nadd esp,8\nL511:\nL509:\nmov dword ptr (-44)[ebp],1048579\nmov edi,dword ptr (-44)[ebp]\nmov esi,edi\nmov word ptr (-50)[ebp],si\nmov ebx,edi\nmov byte ptr (-51)[ebp],bl\nmovsx edi,word ptr (-50)[ebp]\ncmp edi,dword ptr (-44)[ebp]\nje L516\ncmp edi,3\njne L515\nL516:\nmovsx edi,byte ptr (-51)[ebp]\ncmp edi,dword ptr (-44)[ebp]\nje L513\ncmp edi,3\nje L513\nL515:\nadd dword ptr (-48)[ebp],8\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L517\npush 8\nlea edi,(L480)\npush edi\ncall _printf\nadd esp,8\nL517:\nL513:\nmov eax,dword ptr (-48)[ebp]\nL479:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 1\nL520 label byte\ndb 115\ndb 54\ndb 50\ndb 54\ndb 44\ndb 101\ndb 114\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL521 label byte\ndb 115\ndb 54\ndb 50\ndb 54\ndb 32\ndb 32\ndb 32\ndb 0\npublic _s626\n_DATA ends\n_TEXT segment\n_s626:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,128\nlea edi,(L521)\nmov dword ptr (-56)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea edi,(60)[edi]\nmov dword ptr (-60)[ebp],edi\nmov dword ptr (-104)[ebp],0\nL522:\nL523:\nmov edi,dword ptr (-60)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-60)[ebp],esi\nmov esi,dword ptr (-56)[ebp]\nlea ebx,(1)[esi]\nmov dword ptr (-56)[ebp],ebx\nmov bl,byte ptr [esi]\nmov byte ptr [edi],bl\nmovsx edi,bl\ncmp edi,0\njne L522\nfld dword ptr (L411)\nfstp dword ptr (-36)[ebp]\nmov dword ptr (-64)[ebp],1\nmov dword ptr (-40)[ebp],1\nmov dword ptr (-4)[ebp],0\njmp L528\nL525:\nfld dword ptr (L529)\nfmul dword ptr (-36)[ebp]\nfstp dword ptr (-36)[ebp]\nmov edi,dword ptr (-40)[ebp]\nlea edi,[edi*2]\nor edi,dword ptr (-64)[ebp]\nmov dword ptr (-40)[ebp],edi\nL526:\ninc dword ptr (-4)[ebp]\nL528:\nmov edi,dword ptr (20)[ebp]\nmov edi,dword ptr (12)[edi]\nsub edi,2\ncmp dword ptr (-4)[ebp],edi\njl L525\nmov edi,dword ptr (-40)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfstp dword ptr (-112)[ebp]\nfld dword ptr (-36)[ebp]\nfsub dword ptr (-112)[ebp]\nfdiv dword ptr (-36)[ebp]\nfstp dword ptr (-36)[ebp]\nfld qword ptr (L416)\nmov edi,dword ptr (20)[ebp]\nfmul dword ptr (28)[edi]\nfcomp dword ptr (-36)[ebp]\nfstsw ax\nsahf\njae L530\nadd dword ptr (-104)[ebp],2\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L532\npush 2\nlea edi,(L520)\npush edi\ncall _printf\nadd esp,8\nL532:\nL530:\nmov byte ptr (-73)[ebp],125\nmov word ptr (-76)[ebp],125\nmov dword ptr (-80)[ebp],125\nmov dword ptr (-96)[ebp],15625\nmov dword ptr (-84)[ebp],125\nmov dword ptr (-100)[ebp],15625\nmov dword ptr (-68)[ebp],125\nmov dword ptr (-108)[ebp],15625\nfld dword ptr (L534)\nfstp dword ptr (-72)[ebp]\nfld qword ptr (L535)\nfstp qword ptr (-92)[ebp]\nfld qword ptr (L536)\nfstp qword ptr (-52)[ebp]\nmov dword ptr (-4)[ebp],0\nL537:\nmov edi,dword ptr (-4)[ebp]\nmov byte ptr (-32)[ebp][edi],0\nL538:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],28\njl L537\nmovsx edi,byte ptr (-73)[ebp]\nmov esi,edi\nimul esi,edi\ncmp esi,dword ptr (-96)[ebp]\nje L541\nmov byte ptr (-32)[ebp],1\nL541:\nmovsx edi,word ptr (-76)[ebp]\nmovsx esi,byte ptr (-73)[ebp]\nimul edi,esi\ncmp edi,dword ptr (-96)[ebp]\nje L543\nmov byte ptr (-31)[ebp],1\nL543:\nmovsx edi,word ptr (-76)[ebp]\nmov esi,edi\nimul esi,edi\ncmp esi,dword ptr (-96)[ebp]\nje L546\nmov byte ptr (-30)[ebp],1\nL546:\nmov edi,dword ptr (-80)[ebp]\nmovsx esi,byte ptr (-73)[ebp]\nimul edi,esi\ncmp edi,dword ptr (-96)[ebp]\nje L549\nmov byte ptr (-29)[ebp],1\nL549:\nmov edi,dword ptr (-80)[ebp]\nmovsx esi,word ptr (-76)[ebp]\nimul edi,esi\ncmp edi,dword ptr (-96)[ebp]\nje L552\nmov byte ptr (-28)[ebp],1\nL552:\nmov edi,dword ptr (-80)[ebp]\nmov esi,edi\nimul esi,edi\ncmp esi,dword ptr (-96)[ebp]\nje L555\nmov byte ptr (-27)[ebp],1\nL555:\nmov eax,dword ptr (-84)[ebp]\nmovsx edi,byte ptr (-73)[ebp]\nmul edi\ncmp eax,dword ptr (-100)[ebp]\nje L558\nmov byte ptr (-26)[ebp],1\nL558:\nmov eax,dword ptr (-84)[ebp]\nmovsx edi,word ptr (-76)[ebp]\nmul edi\ncmp eax,dword ptr (-100)[ebp]\nje L561\nmov byte ptr (-25)[ebp],1\nL561:\nmov eax,dword ptr (-84)[ebp]\nmov edi,dword ptr (-80)[ebp]\nmul edi\ncmp eax,dword ptr (-100)[ebp]\nje L564\nmov byte ptr (-24)[ebp],1\nL564:\nmov edi,dword ptr (-84)[ebp]\nmov eax,edi\nmul edi\ncmp eax,dword ptr (-100)[ebp]\nje L567\nmov byte ptr (-23)[ebp],1\nL567:\nmov edi,dword ptr (-68)[ebp]\nmovsx esi,byte ptr (-73)[ebp]\nimul edi,esi\ncmp edi,dword ptr (-108)[ebp]\nje L570\nmov byte ptr (-22)[ebp],1\nL570:\nmov edi,dword ptr (-68)[ebp]\nmovsx esi,word ptr (-76)[ebp]\nimul edi,esi\ncmp edi,dword ptr (-108)[ebp]\nje L573\nmov byte ptr (-21)[ebp],1\nL573:\nmov edi,dword ptr (-68)[ebp]\nmov esi,dword ptr (-80)[ebp]\nimul edi,esi\ncmp edi,dword ptr (-108)[ebp]\nje L576\nmov byte ptr (-20)[ebp],1\nL576:\nmov edi,dword ptr (-68)[ebp]\nmov eax,edi\nmul dword ptr (-84)[ebp]\ncmp eax,dword ptr (-100)[ebp]\nje L579\nmov byte ptr (-19)[ebp],1\nL579:\nmov edi,dword ptr (-68)[ebp]\nmov esi,edi\nimul esi,edi\ncmp esi,dword ptr (-108)[ebp]\nje L582\nmov byte ptr (-18)[ebp],1\nL582:\nfld dword ptr (-72)[ebp]\nmovsx edi,byte ptr (-73)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nfld qword ptr (-52)[ebp]\nfcompp\nfstsw ax\nsahf\nje L585\nmov byte ptr (-17)[ebp],1\nL585:\nfld dword ptr (-72)[ebp]\nmovsx edi,word ptr (-76)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nfld qword ptr (-52)[ebp]\nfcompp\nfstsw ax\nsahf\nje L588\nmov byte ptr (-16)[ebp],1\nL588:\nfld dword ptr (-72)[ebp]\nmov edi,dword ptr (-80)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nfld qword ptr (-52)[ebp]\nfcompp\nfstsw ax\nsahf\nje L591\nmov byte ptr (-15)[ebp],1\nL591:\nmov edi,dword ptr (-84)[ebp]\nfld dword ptr (-72)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nsub esp,4\nfstp dword ptr 0[esp]\nfld dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nfld qword ptr (-52)[ebp]\nfcompp\nfstsw ax\nsahf\nje L594\nmov byte ptr (-14)[ebp],1\nL594:\nfld dword ptr (-72)[ebp]\nmov edi,dword ptr (-68)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nfld qword ptr (-52)[ebp]\nfcompp\nfstsw ax\nsahf\nje L598\nmov byte ptr (-13)[ebp],1\nL598:\nfld dword ptr (-72)[ebp]\nfmul dword ptr (-72)[ebp]\nfld qword ptr (-52)[ebp]\nfcompp\nfstsw ax\nsahf\nje L601\nmov byte ptr (-12)[ebp],1\nL601:\nfld qword ptr (-92)[ebp]\nmovsx edi,byte ptr (-73)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nfld qword ptr (-52)[ebp]\nfcompp\nfstsw ax\nsahf\nje L604\nmov byte ptr (-11)[ebp],1\nL604:\nfld qword ptr (-92)[ebp]\nmovsx edi,word ptr (-76)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nfld qword ptr (-52)[ebp]\nfcompp\nfstsw ax\nsahf\nje L607\nmov byte ptr (-10)[ebp],1\nL607:\nfld qword ptr (-92)[ebp]\nfild dword ptr (-80)[ebp]\nfmulp st(1),st\nfld qword ptr (-52)[ebp]\nfcompp\nfstsw ax\nsahf\nje L610\nmov byte ptr (-9)[ebp],1\nL610:\nmov edi,dword ptr (-84)[ebp]\nfld qword ptr (-92)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nfmulp st(1),st\nfld qword ptr (-52)[ebp]\nfcompp\nfstsw ax\nsahf\nje L613\nmov byte ptr (-8)[ebp],1\nL613:\nfld qword ptr (-92)[ebp]\nfild dword ptr (-68)[ebp]\nfmulp st(1),st\nfld qword ptr (-52)[ebp]\nfcompp\nfstsw ax\nsahf\nje L616\nmov byte ptr (-7)[ebp],1\nL616:\nfld qword ptr (-92)[ebp]\nfmul dword ptr (-72)[ebp]\nfld qword ptr (-52)[ebp]\nfcompp\nfstsw ax\nsahf\nje L619\nmov byte ptr (-6)[ebp],1\nL619:\nfld qword ptr (-92)[ebp]\nfmul qword ptr (-92)[ebp]\nfld qword ptr (-52)[ebp]\nfcompp\nfstsw ax\nsahf\nje L622\nmov byte ptr (-5)[ebp],1\nL622:\nmov byte ptr (-41)[ebp],0\nmov dword ptr (-4)[ebp],0\nL625:\nmovsx edi,byte ptr (-41)[ebp]\nmov esi,dword ptr (-4)[ebp]\nmovsx esi,byte ptr (-32)[ebp][esi]\nlea edi,[esi][edi]\nmov ebx,edi\nmov byte ptr (-41)[ebp],bl\nL626:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],28\njl L625\nmovsx edi,byte ptr (-41)[ebp]\ncmp edi,0\nje L629\nadd dword ptr (-104)[ebp],4\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L631\npush 4\nlea edi,(L520)\npush edi\ncall _printf\nadd esp,8\nlea edi,(L633)\npush edi\ncall _printf\nadd esp,4\nmov dword ptr (-4)[ebp],0\nL634:\nmov edi,dword ptr (-4)[ebp]\nmovsx edi,byte ptr (-32)[ebp][edi]\npush edi\nlea edi,(L638)\npush edi\ncall _printf\nadd esp,8\nL635:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],28\njl L634\nlea edi,(L639)\npush edi\ncall _printf\nadd esp,4\nL631:\nL629:\nmov dword ptr (-68)[ebp],32768\nmov edi,dword ptr (-68)[ebp]\ncmp edi,08000H\njbe L640\nadd dword ptr (-104)[ebp],8\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L642\npush 8\nlea edi,(L520)\npush edi\ncall _printf\nadd esp,8\nL642:\nL640:\nmov eax,dword ptr (-104)[ebp]\nL519:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 1\nL645 label byte\ndb 115\ndb 55\ndb 49\ndb 44\ndb 101\ndb 114\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL646 label byte\ndb 115\ndb 55\ndb 49\ndb 32\ndb 32\ndb 32\ndb 32\ndb 0\nalign 1\nL647 label byte\ndb 113\npublic _s71\n_DATA ends\n_TEXT segment\n_s71:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,68\nlea edi,(L646)\nmov dword ptr (-4)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea edi,(60)[edi]\nmov dword ptr (-8)[ebp],edi\nmov dword ptr (-12)[ebp],0\nL648:\nL649:\nmov edi,dword ptr (-8)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-8)[ebp],esi\nmov esi,dword ptr (-4)[ebp]\nlea ebx,(1)[esi]\nmov dword ptr (-4)[ebp],ebx\nmov bl,byte ptr [esi]\nmov byte ptr [edi],bl\nmovsx edi,bl\ncmp edi,0\njne L648\nmovsx edi,byte ptr (L653)\nmovsx esi,byte ptr (L647)\ncmp edi,esi\nje L651\ninc dword ptr (-12)[ebp]\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L654\npush 1\nlea edi,(L645)\npush edi\ncall _printf\nadd esp,8\nL654:\nL651:\njmp L656\nadd dword ptr (-12)[ebp],2\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L658\npush 2\nlea edi,(L645)\npush edi\ncall _printf\nadd esp,8\nL658:\nL656:\nmov dword ptr (-32)[ebp],1942\ncmp dword ptr (-32)[ebp],1942\njne L666\nmov edi,dword ptr (-32)[ebp]\ncmp dword ptr (-32)[ebp],edi\nje L661\nL666:\nadd dword ptr (-12)[ebp],4\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L667\npush 4\nlea edi,(L645)\npush edi\ncall _printf\nadd esp,8\nL667:\nL661:\npush -5\ncall _McCarthy\nadd esp,4\ncmp eax,91\nje L669\nadd dword ptr (-12)[ebp],8\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L671\npush 8\nlea edi,(L645)\npush edi\ncall _printf\nadd esp,8\nL671:\nL669:\nmov dword ptr (-56)[ebp],2\nmov dword ptr (-60)[ebp],3\nlea edi,(-60)[ebp]\nmov dword ptr (-64)[ebp],edi\nmov edi,dword ptr (-64)[ebp]\npush edi\nmov edi,dword ptr (-56)[ebp]\npush edi\ncall _clobber\nadd esp,8\ncmp dword ptr (-56)[ebp],2\njne L675\ncmp dword ptr (-60)[ebp],2\nje L673\nL675:\nadd dword ptr (-12)[ebp],16\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L676\npush 16\nlea edi,(L645)\npush edi\ncall _printf\nadd esp,8\nL676:\nL673:\nmov edi,dword ptr (20)[ebp]\nfld dword ptr (32)[edi]\nfstp dword ptr (-68)[ebp]\nfld dword ptr (-68)[ebp]\nfcomp dword ptr (-68)[ebp]\nfstsw ax\nsahf\nje L678\nadd dword ptr (-12)[ebp],32\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L680\npush 32\nlea edi,(L645)\npush edi\ncall _printf\nadd esp,8\nL680:\nL678:\nmov eax,dword ptr (-12)[ebp]\nL644:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _McCarthy\n_McCarthy:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\ncmp dword ptr (20)[ebp],100\njle L683\nmov edi,dword ptr (20)[ebp]\nmov eax,edi\nsub eax,10\njmp L682\nL683:\nmov edi,dword ptr (20)[ebp]\nlea edi,(11)[edi]\npush edi\ncall _McCarthy\nadd esp,4\nmov edi,eax\npush edi\ncall _McCarthy\nadd esp,4\nmov edi,eax\nL682:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _clobber\n_clobber:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov dword ptr (20)[ebp],3\nmov edi,dword ptr (24)[ebp]\nmov dword ptr [edi],2\nmov eax,0\nL685:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 1\nL687 label byte\ndb 76\ndb 111\ndb 99\ndb 97\ndb 108\ndb 32\ndb 101\ndb 114\ndb 114\ndb 111\ndb 114\ndb 32\ndb 37\ndb 100\ndb 46\ndb 10\ndb 0\nalign 1\nL688 label byte\ndb 115\ndb 55\ndb 49\ndb 52\ndb 44\ndb 101\ndb 114\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL689 label byte\ndb 115\ndb 55\ndb 49\ndb 52\ndb 32\ndb 32\ndb 32\ndb 0\npublic _s714\n_DATA ends\n_TEXT segment\n_s714:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,248\nlea edi,(L689)\nmov dword ptr (-68)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea esi,(60)[edi]\nmov dword ptr (-72)[ebp],esi\nmov dword ptr (-76)[ebp],0\nmov dword ptr (-8)[ebp],0\nmov edi,dword ptr (48)[edi]\nmov dword ptr (-4)[ebp],edi\nL690:\nL691:\nmov edi,dword ptr (-72)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-72)[ebp],esi\nmov esi,dword ptr (-68)[ebp]\nlea ebx,(1)[esi]\nmov dword ptr (-68)[ebp],ebx\nmov bl,byte ptr [esi]\nmov byte ptr [edi],bl\nmovsx edi,bl\ncmp edi,0\njne L690\nmov byte ptr (-9)[ebp],5\nmov byte ptr (-25)[ebp],2\nmov bl,byte ptr (-25)[ebp]\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,2\nje L693\nmov dword ptr (-8)[ebp],1\ncmp dword ptr (-4)[ebp],0\nje L695\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL695:\nL693:\nmov byte ptr (-9)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx edi,word ptr (-28)[ebp]\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,2\nje L697\nmov dword ptr (-8)[ebp],2\ncmp dword ptr (-4)[ebp],0\nje L699\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL699:\nL697:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (-32)[ebp]\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,2\nje L701\nmov dword ptr (-8)[ebp],3\ncmp dword ptr (-4)[ebp],0\nje L703\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL703:\nL701:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov edi,dword ptr (-36)[ebp]\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,2\nje L705\nmov dword ptr (-8)[ebp],4\ncmp dword ptr (-4)[ebp],0\nje L707\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL707:\nL705:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-40)[ebp]\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,2\nje L709\nmov dword ptr (-8)[ebp],5\ncmp dword ptr (-4)[ebp],0\nje L711\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL711:\nL709:\nmov byte ptr (-9)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nfld dword ptr (-56)[ebp]\ncall __ftol\nmov ebx,eax\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,2\nje L713\nmov dword ptr (-8)[ebp],6\ncmp dword ptr (-4)[ebp],0\nje L715\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL715:\nL713:\nmov byte ptr (-9)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfld qword ptr (-64)[ebp]\ncall __ftol\nmov ebx,eax\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,2\nje L717\nmov dword ptr (-8)[ebp],7\ncmp dword ptr (-4)[ebp],0\nje L719\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL719:\nL717:\nmov word ptr (-12)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx edi,byte ptr (-25)[ebp]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,2\nje L721\nmov dword ptr (-8)[ebp],8\ncmp dword ptr (-4)[ebp],0\nje L723\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL723:\nL721:\nmov word ptr (-12)[ebp],5\nmov word ptr (-28)[ebp],2\nmov di,word ptr (-28)[ebp]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,2\nje L725\nmov dword ptr (-8)[ebp],9\ncmp dword ptr (-4)[ebp],0\nje L727\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL727:\nL725:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (-32)[ebp]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,2\nje L729\nmov dword ptr (-8)[ebp],10\ncmp dword ptr (-4)[ebp],0\nje L731\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL731:\nL729:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov edi,dword ptr (-36)[ebp]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,2\nje L733\nmov dword ptr (-8)[ebp],11\ncmp dword ptr (-4)[ebp],0\nje L735\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL735:\nL733:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-40)[ebp]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,2\nje L737\nmov dword ptr (-8)[ebp],12\ncmp dword ptr (-4)[ebp],0\nje L739\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL739:\nL737:\nmov word ptr (-12)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nfld dword ptr (-56)[ebp]\ncall __ftol\nmov edi,eax\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,2\nje L741\nmov dword ptr (-8)[ebp],13\ncmp dword ptr (-4)[ebp],0\nje L743\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL743:\nL741:\nmov word ptr (-12)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfld qword ptr (-64)[ebp]\ncall __ftol\nmov edi,eax\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,2\nje L745\nmov dword ptr (-8)[ebp],14\ncmp dword ptr (-4)[ebp],0\nje L747\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL747:\nL745:\nmov dword ptr (-16)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx edi,byte ptr (-25)[ebp]\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],2\nje L749\nmov dword ptr (-8)[ebp],15\ncmp dword ptr (-4)[ebp],0\nje L751\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL751:\nL749:\nmov dword ptr (-16)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx edi,word ptr (-28)[ebp]\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],2\nje L753\nmov dword ptr (-8)[ebp],16\ncmp dword ptr (-4)[ebp],0\nje L755\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL755:\nL753:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (-32)[ebp]\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],2\nje L757\nmov dword ptr (-8)[ebp],17\ncmp dword ptr (-4)[ebp],0\nje L759\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL759:\nL757:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov edi,dword ptr (-36)[ebp]\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],2\nje L761\nmov dword ptr (-8)[ebp],18\ncmp dword ptr (-4)[ebp],0\nje L763\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL763:\nL761:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-40)[ebp]\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],2\nje L765\nmov dword ptr (-8)[ebp],19\ncmp dword ptr (-4)[ebp],0\nje L767\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL767:\nL765:\nmov dword ptr (-16)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nfld dword ptr (-56)[ebp]\ncall __ftol\nmov dword ptr (-16)[ebp],eax\ncmp dword ptr (-16)[ebp],2\nje L769\nmov dword ptr (-8)[ebp],20\ncmp dword ptr (-4)[ebp],0\nje L771\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL771:\nL769:\nmov dword ptr (-16)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfld qword ptr (-64)[ebp]\ncall __ftol\nmov dword ptr (-16)[ebp],eax\ncmp dword ptr (-16)[ebp],2\nje L773\nmov dword ptr (-8)[ebp],21\ncmp dword ptr (-4)[ebp],0\nje L775\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL775:\nL773:\nmov dword ptr (-20)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx edi,byte ptr (-25)[ebp]\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],2\nje L777\nmov dword ptr (-8)[ebp],22\ncmp dword ptr (-4)[ebp],0\nje L779\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL779:\nL777:\nmov dword ptr (-20)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx edi,word ptr (-28)[ebp]\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],2\nje L781\nmov dword ptr (-8)[ebp],23\ncmp dword ptr (-4)[ebp],0\nje L783\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL783:\nL781:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (-32)[ebp]\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],2\nje L785\nmov dword ptr (-8)[ebp],24\ncmp dword ptr (-4)[ebp],0\nje L787\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL787:\nL785:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov edi,dword ptr (-36)[ebp]\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],2\nje L789\nmov dword ptr (-8)[ebp],25\ncmp dword ptr (-4)[ebp],0\nje L791\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL791:\nL789:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-40)[ebp]\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],2\nje L793\nmov dword ptr (-8)[ebp],26\ncmp dword ptr (-4)[ebp],0\nje L795\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL795:\nL793:\nmov dword ptr (-20)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nfld dword ptr (-56)[ebp]\ncall __ftol\nmov dword ptr (-20)[ebp],eax\ncmp dword ptr (-20)[ebp],2\nje L797\nmov dword ptr (-8)[ebp],27\ncmp dword ptr (-4)[ebp],0\nje L799\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL799:\nL797:\nmov dword ptr (-20)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfld qword ptr (-64)[ebp]\ncall __ftol\nmov dword ptr (-20)[ebp],eax\ncmp dword ptr (-20)[ebp],2\nje L801\nmov dword ptr (-8)[ebp],28\ncmp dword ptr (-4)[ebp],0\nje L803\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL803:\nL801:\nmov dword ptr (-24)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx edi,byte ptr (-25)[ebp]\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,2\nje L805\nmov dword ptr (-8)[ebp],29\ncmp dword ptr (-4)[ebp],0\nje L807\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL807:\nL805:\nmov dword ptr (-24)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx edi,word ptr (-28)[ebp]\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,2\nje L809\nmov dword ptr (-8)[ebp],30\ncmp dword ptr (-4)[ebp],0\nje L811\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL811:\nL809:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (-32)[ebp]\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,2\nje L813\nmov dword ptr (-8)[ebp],31\ncmp dword ptr (-4)[ebp],0\nje L815\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL815:\nL813:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov edi,dword ptr (-36)[ebp]\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,2\nje L817\nmov dword ptr (-8)[ebp],32\ncmp dword ptr (-4)[ebp],0\nje L819\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL819:\nL817:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-40)[ebp]\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,2\nje L821\nmov dword ptr (-8)[ebp],33\ncmp dword ptr (-4)[ebp],0\nje L823\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL823:\nL821:\nmov dword ptr (-24)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nfld dword ptr (L828)\nfcomp dword ptr (-56)[ebp]\nfstsw ax\nsahf\nja L826\nfld dword ptr (-56)[ebp]\nfsub dword ptr (L828)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-80)[ebp],edi\njmp L827\nL826:\nfld dword ptr (-56)[ebp]\ncall __ftol\nmov edi,eax\nmov dword ptr (-80)[ebp],edi\nL827:\nmov edi,dword ptr (-80)[ebp]\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,2\nje L829\nmov dword ptr (-8)[ebp],34\ncmp dword ptr (-4)[ebp],0\nje L831\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL831:\nL829:\nmov dword ptr (-24)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfld qword ptr (L836)\nfcomp qword ptr (-64)[ebp]\nfstsw ax\nsahf\nja L834\nfld qword ptr (-64)[ebp]\nfsub qword ptr (L836)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-92)[ebp],edi\njmp L835\nL834:\nfld qword ptr (-64)[ebp]\ncall __ftol\nmov edi,eax\nmov dword ptr (-92)[ebp],edi\nL835:\nmov edi,dword ptr (-92)[ebp]\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,2\nje L837\nmov dword ptr (-8)[ebp],35\ncmp dword ptr (-4)[ebp],0\nje L839\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL839:\nL837:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov byte ptr (-25)[ebp],2\nmovsx edi,byte ptr (-25)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L529)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L842\nmov dword ptr (-8)[ebp],36\ncmp dword ptr (-4)[ebp],0\nje L844\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL844:\nL842:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov word ptr (-28)[ebp],2\nmovsx edi,word ptr (-28)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L529)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L846\nmov dword ptr (-8)[ebp],37\ncmp dword ptr (-4)[ebp],0\nje L848\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL848:\nL846:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (-32)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L529)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L850\nmov dword ptr (-8)[ebp],38\ncmp dword ptr (-4)[ebp],0\nje L852\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL852:\nL850:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov dword ptr (-36)[ebp],2\nmov edi,dword ptr (-36)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L529)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L854\nmov dword ptr (-8)[ebp],39\ncmp dword ptr (-4)[ebp],0\nje L856\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL856:\nL854:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-40)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L529)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L858\nmov dword ptr (-8)[ebp],40\ncmp dword ptr (-4)[ebp],0\nje L860\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL860:\nL858:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nfld dword ptr (-56)[ebp]\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L529)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L862\nmov dword ptr (-8)[ebp],41\ncmp dword ptr (-4)[ebp],0\nje L864\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL864:\nL862:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfld qword ptr (-64)[ebp]\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L529)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L866\nmov dword ptr (-8)[ebp],42\ncmp dword ptr (-4)[ebp],0\nje L868\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL868:\nL866:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov byte ptr (-25)[ebp],2\nmovsx edi,byte ptr (-25)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L416)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L871\nmov dword ptr (-8)[ebp],43\ncmp dword ptr (-4)[ebp],0\nje L873\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL873:\nL871:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov word ptr (-28)[ebp],2\nmovsx edi,word ptr (-28)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L416)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L875\nmov dword ptr (-8)[ebp],44\ncmp dword ptr (-4)[ebp],0\nje L877\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL877:\nL875:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov dword ptr (-32)[ebp],2\nfild dword ptr (-32)[ebp]\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L416)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L879\nmov dword ptr (-8)[ebp],45\ncmp dword ptr (-4)[ebp],0\nje L881\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL881:\nL879:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov dword ptr (-36)[ebp],2\nfild dword ptr (-36)[ebp]\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L416)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L883\nmov dword ptr (-8)[ebp],46\ncmp dword ptr (-4)[ebp],0\nje L885\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL885:\nL883:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-40)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L416)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L887\nmov dword ptr (-8)[ebp],47\ncmp dword ptr (-4)[ebp],0\nje L889\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL889:\nL887:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nfld dword ptr (-56)[ebp]\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L416)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L891\nmov dword ptr (-8)[ebp],48\ncmp dword ptr (-4)[ebp],0\nje L893\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL893:\nL891:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfld qword ptr (-64)[ebp]\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L416)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L895\nmov dword ptr (-8)[ebp],49\ncmp dword ptr (-4)[ebp],0\nje L897\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL897:\nL895:\nmov byte ptr (-9)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nlea edi,[esi][edi]\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,7\nje L899\nmov dword ptr (-8)[ebp],50\ncmp dword ptr (-4)[ebp],0\nje L901\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL901:\nL899:\nmov byte ptr (-9)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nlea edi,[esi][edi]\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,7\nje L903\nmov dword ptr (-8)[ebp],51\ncmp dword ptr (-4)[ebp],0\nje L905\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL905:\nL903:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-32)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmov esi,dword ptr (-32)[ebp]\nlea edi,[esi][edi]\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,7\nje L907\nmov dword ptr (-8)[ebp],52\ncmp dword ptr (-4)[ebp],0\nje L909\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL909:\nL907:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-36)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmov esi,dword ptr (-36)[ebp]\nlea edi,[esi][edi]\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,7\nje L911\nmov dword ptr (-8)[ebp],53\ncmp dword ptr (-4)[ebp],0\nje L913\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL913:\nL911:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-40)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmov esi,dword ptr (-40)[ebp]\nlea edi,[esi][edi]\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,7\nje L915\nmov dword ptr (-8)[ebp],54\ncmp dword ptr (-4)[ebp],0\nje L917\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL917:\nL915:\nmov byte ptr (-9)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nmovsx edi,byte ptr (-9)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfadd dword ptr (-56)[ebp]\ncall __ftol\nmov ebx,eax\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,7\nje L919\nmov dword ptr (-8)[ebp],55\ncmp dword ptr (-4)[ebp],0\nje L921\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL921:\nL919:\nmov byte ptr (-9)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nmovsx edi,byte ptr (-9)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfadd qword ptr (-64)[ebp]\ncall __ftol\nmov ebx,eax\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,7\nje L923\nmov dword ptr (-8)[ebp],56\ncmp dword ptr (-4)[ebp],0\nje L925\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL925:\nL923:\nmov word ptr (-12)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nlea edi,[esi][edi]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,7\nje L927\nmov dword ptr (-8)[ebp],57\ncmp dword ptr (-4)[ebp],0\nje L929\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL929:\nL927:\nmov word ptr (-12)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nlea edi,[esi][edi]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,7\nje L931\nmov dword ptr (-8)[ebp],58\ncmp dword ptr (-4)[ebp],0\nje L933\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL933:\nL931:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-32)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmov esi,dword ptr (-32)[ebp]\nlea edi,[esi][edi]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,7\nje L935\nmov dword ptr (-8)[ebp],59\ncmp dword ptr (-4)[ebp],0\nje L937\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL937:\nL935:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-36)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmov esi,dword ptr (-36)[ebp]\nlea edi,[esi][edi]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,7\nje L939\nmov dword ptr (-8)[ebp],60\ncmp dword ptr (-4)[ebp],0\nje L941\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL941:\nL939:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-40)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmov esi,dword ptr (-40)[ebp]\nlea edi,[esi][edi]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,7\nje L943\nmov dword ptr (-8)[ebp],61\ncmp dword ptr (-4)[ebp],0\nje L945\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL945:\nL943:\nmov word ptr (-12)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nmovsx edi,word ptr (-12)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfadd dword ptr (-56)[ebp]\ncall __ftol\nmov edi,eax\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,7\nje L947\nmov dword ptr (-8)[ebp],62\ncmp dword ptr (-4)[ebp],0\nje L949\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL949:\nL947:\nmov word ptr (-12)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nmovsx edi,word ptr (-12)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfadd qword ptr (-64)[ebp]\ncall __ftol\nmov edi,eax\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,7\nje L951\nmov dword ptr (-8)[ebp],63\ncmp dword ptr (-4)[ebp],0\nje L953\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL953:\nL951:\nmov dword ptr (-16)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx edi,byte ptr (-25)[ebp]\nadd dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],7\nje L955\nmov dword ptr (-8)[ebp],64\ncmp dword ptr (-4)[ebp],0\nje L957\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL957:\nL955:\nmov dword ptr (-16)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx edi,word ptr (-28)[ebp]\nadd dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],7\nje L959\nmov dword ptr (-8)[ebp],65\ncmp dword ptr (-4)[ebp],0\nje L961\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL961:\nL959:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (-32)[ebp]\nadd dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],7\nje L963\nmov dword ptr (-8)[ebp],66\ncmp dword ptr (-4)[ebp],0\nje L965\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL965:\nL963:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov edi,dword ptr (-36)[ebp]\nadd dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],7\nje L967\nmov dword ptr (-8)[ebp],67\ncmp dword ptr (-4)[ebp],0\nje L969\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL969:\nL967:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-16)[ebp]\nmov esi,dword ptr (-40)[ebp]\nlea edi,[esi][edi]\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],7\nje L971\nmov dword ptr (-8)[ebp],68\ncmp dword ptr (-4)[ebp],0\nje L973\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL973:\nL971:\nmov dword ptr (-16)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nmov edi,dword ptr (-16)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfadd dword ptr (-56)[ebp]\ncall __ftol\nmov dword ptr (-16)[ebp],eax\ncmp dword ptr (-16)[ebp],7\nje L975\nmov dword ptr (-8)[ebp],69\ncmp dword ptr (-4)[ebp],0\nje L977\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL977:\nL975:\nmov dword ptr (-16)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfild dword ptr (-16)[ebp]\nfadd qword ptr (-64)[ebp]\ncall __ftol\nmov dword ptr (-16)[ebp],eax\ncmp dword ptr (-16)[ebp],7\nje L979\nmov dword ptr (-8)[ebp],70\ncmp dword ptr (-4)[ebp],0\nje L981\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL981:\nL979:\nmov dword ptr (-20)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx edi,byte ptr (-25)[ebp]\nadd dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],7\nje L983\nmov dword ptr (-8)[ebp],71\ncmp dword ptr (-4)[ebp],0\nje L985\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL985:\nL983:\nmov dword ptr (-20)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx edi,word ptr (-28)[ebp]\nadd dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],7\nje L987\nmov dword ptr (-8)[ebp],72\ncmp dword ptr (-4)[ebp],0\nje L989\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL989:\nL987:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (-32)[ebp]\nadd dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],7\nje L991\nmov dword ptr (-8)[ebp],73\ncmp dword ptr (-4)[ebp],0\nje L993\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL993:\nL991:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov edi,dword ptr (-36)[ebp]\nadd dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],7\nje L995\nmov dword ptr (-8)[ebp],74\ncmp dword ptr (-4)[ebp],0\nje L997\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL997:\nL995:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-20)[ebp]\nmov esi,dword ptr (-40)[ebp]\nlea edi,[esi][edi]\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],7\nje L999\nmov dword ptr (-8)[ebp],75\ncmp dword ptr (-4)[ebp],0\nje L1001\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1001:\nL999:\nmov dword ptr (-20)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nmov edi,dword ptr (-20)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfadd dword ptr (-56)[ebp]\ncall __ftol\nmov dword ptr (-20)[ebp],eax\ncmp dword ptr (-20)[ebp],7\nje L1003\nmov dword ptr (-8)[ebp],76\ncmp dword ptr (-4)[ebp],0\nje L1005\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1005:\nL1003:\nmov dword ptr (-20)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfild dword ptr (-20)[ebp]\nfadd qword ptr (-64)[ebp]\ncall __ftol\nmov dword ptr (-20)[ebp],eax\ncmp dword ptr (-20)[ebp],7\nje L1007\nmov dword ptr (-8)[ebp],77\ncmp dword ptr (-4)[ebp],0\nje L1009\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1009:\nL1007:\nmov dword ptr (-24)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx edi,byte ptr (-25)[ebp]\nadd dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,7\nje L1011\nmov dword ptr (-8)[ebp],78\ncmp dword ptr (-4)[ebp],0\nje L1013\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1013:\nL1011:\nmov dword ptr (-24)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx edi,word ptr (-28)[ebp]\nadd dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,7\nje L1015\nmov dword ptr (-8)[ebp],79\ncmp dword ptr (-4)[ebp],0\nje L1017\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1017:\nL1015:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (-32)[ebp]\nadd dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,7\nje L1019\nmov dword ptr (-8)[ebp],80\ncmp dword ptr (-4)[ebp],0\nje L1021\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1021:\nL1019:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov edi,dword ptr (-36)[ebp]\nadd dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,7\nje L1023\nmov dword ptr (-8)[ebp],81\ncmp dword ptr (-4)[ebp],0\nje L1025\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1025:\nL1023:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-40)[ebp]\nadd dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,7\nje L1027\nmov dword ptr (-8)[ebp],82\ncmp dword ptr (-4)[ebp],0\nje L1029\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1029:\nL1027:\nmov dword ptr (-24)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nmov edi,dword ptr (-24)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nsub esp,4\nfstp dword ptr 0[esp]\nfld dword ptr 0[esp]\nadd esp,4\nfadd dword ptr (-56)[ebp]\nfstp dword ptr (-128)[ebp]\nfld dword ptr (L828)\nfcomp dword ptr (-128)[ebp]\nfstsw ax\nsahf\nja L1032\nfld dword ptr (-128)[ebp]\nfsub dword ptr (L828)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-124)[ebp],edi\njmp L1033\nL1032:\nfld dword ptr (-128)[ebp]\ncall __ftol\nmov edi,eax\nmov dword ptr (-124)[ebp],edi\nL1033:\nmov edi,dword ptr (-124)[ebp]\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,7\nje L1034\nmov dword ptr (-8)[ebp],83\ncmp dword ptr (-4)[ebp],0\nje L1036\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1036:\nL1034:\nmov dword ptr (-24)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nmov edi,dword ptr (-24)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nfadd qword ptr (-64)[ebp]\nfstp qword ptr (-144)[ebp]\nfld qword ptr (L836)\nfcomp qword ptr (-144)[ebp]\nfstsw ax\nsahf\nja L1039\nfld qword ptr (-144)[ebp]\nfsub qword ptr (L836)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-136)[ebp],edi\njmp L1040\nL1039:\nfld qword ptr (-144)[ebp]\ncall __ftol\nmov edi,eax\nmov dword ptr (-136)[ebp],edi\nL1040:\nmov edi,dword ptr (-136)[ebp]\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,7\nje L1041\nmov dword ptr (-8)[ebp],84\ncmp dword ptr (-4)[ebp],0\nje L1043\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1043:\nL1041:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov byte ptr (-25)[ebp],2\nfld dword ptr (-44)[ebp]\nmovsx edi,byte ptr (-25)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L1047)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1045\nmov dword ptr (-8)[ebp],85\ncmp dword ptr (-4)[ebp],0\nje L1048\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1048:\nL1045:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov word ptr (-28)[ebp],2\nfld dword ptr (-44)[ebp]\nmovsx edi,word ptr (-28)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L1047)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1050\nmov dword ptr (-8)[ebp],86\ncmp dword ptr (-4)[ebp],0\nje L1052\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1052:\nL1050:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov dword ptr (-32)[ebp],2\nfld dword ptr (-44)[ebp]\nmov edi,dword ptr (-32)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L1047)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1054\nmov dword ptr (-8)[ebp],87\ncmp dword ptr (-4)[ebp],0\nje L1056\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1056:\nL1054:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov dword ptr (-36)[ebp],2\nfld dword ptr (-44)[ebp]\nmov edi,dword ptr (-36)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L1047)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1058\nmov dword ptr (-8)[ebp],88\ncmp dword ptr (-4)[ebp],0\nje L1060\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1060:\nL1058:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-40)[ebp]\nfld dword ptr (-44)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nsub esp,4\nfstp dword ptr 0[esp]\nfld dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L1047)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1062\nmov dword ptr (-8)[ebp],89\ncmp dword ptr (-4)[ebp],0\nje L1064\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1064:\nL1062:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nfld dword ptr (-44)[ebp]\nfadd dword ptr (-56)[ebp]\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L1047)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1066\nmov dword ptr (-8)[ebp],90\ncmp dword ptr (-4)[ebp],0\nje L1068\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1068:\nL1066:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfld dword ptr (-44)[ebp]\nfadd qword ptr (-64)[ebp]\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L1047)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1070\nmov dword ptr (-8)[ebp],91\ncmp dword ptr (-4)[ebp],0\nje L1072\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1072:\nL1070:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov byte ptr (-25)[ebp],2\nfld qword ptr (-52)[ebp]\nmovsx edi,byte ptr (-25)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1076)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1074\nmov dword ptr (-8)[ebp],92\ncmp dword ptr (-4)[ebp],0\nje L1077\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1077:\nL1074:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov word ptr (-28)[ebp],2\nfld qword ptr (-52)[ebp]\nmovsx edi,word ptr (-28)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1076)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1079\nmov dword ptr (-8)[ebp],93\ncmp dword ptr (-4)[ebp],0\nje L1081\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1081:\nL1079:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov dword ptr (-32)[ebp],2\nfld qword ptr (-52)[ebp]\nfild dword ptr (-32)[ebp]\nfaddp st(1),st\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1076)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1083\nmov dword ptr (-8)[ebp],94\ncmp dword ptr (-4)[ebp],0\nje L1085\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1085:\nL1083:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov dword ptr (-36)[ebp],2\nfld qword ptr (-52)[ebp]\nfild dword ptr (-36)[ebp]\nfaddp st(1),st\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1076)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1087\nmov dword ptr (-8)[ebp],95\ncmp dword ptr (-4)[ebp],0\nje L1089\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1089:\nL1087:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-40)[ebp]\nfld qword ptr (-52)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nfaddp st(1),st\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1076)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1091\nmov dword ptr (-8)[ebp],96\ncmp dword ptr (-4)[ebp],0\nje L1093\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1093:\nL1091:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nfld qword ptr (-52)[ebp]\nfadd dword ptr (-56)[ebp]\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1076)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1095\nmov dword ptr (-8)[ebp],97\ncmp dword ptr (-4)[ebp],0\nje L1097\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1097:\nL1095:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfld qword ptr (-52)[ebp]\nfadd qword ptr (-64)[ebp]\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1076)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1099\nmov dword ptr (-8)[ebp],98\ncmp dword ptr (-4)[ebp],0\nje L1101\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1101:\nL1099:\nmov byte ptr (-9)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nsub edi,esi\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,3\nje L1103\nmov dword ptr (-8)[ebp],99\ncmp dword ptr (-4)[ebp],0\nje L1105\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1105:\nL1103:\nmov byte ptr (-9)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nsub edi,esi\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,3\nje L1107\nmov dword ptr (-8)[ebp],100\ncmp dword ptr (-4)[ebp],0\nje L1109\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1109:\nL1107:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-32)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nsub edi,dword ptr (-32)[ebp]\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,3\nje L1111\nmov dword ptr (-8)[ebp],101\ncmp dword ptr (-4)[ebp],0\nje L1113\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1113:\nL1111:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-36)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nsub edi,dword ptr (-36)[ebp]\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,3\nje L1115\nmov dword ptr (-8)[ebp],102\ncmp dword ptr (-4)[ebp],0\nje L1117\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1117:\nL1115:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-40)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nsub edi,dword ptr (-40)[ebp]\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,3\nje L1119\nmov dword ptr (-8)[ebp],103\ncmp dword ptr (-4)[ebp],0\nje L1121\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1121:\nL1119:\nmov byte ptr (-9)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nmovsx edi,byte ptr (-9)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfsub dword ptr (-56)[ebp]\ncall __ftol\nmov ebx,eax\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,3\nje L1123\nmov dword ptr (-8)[ebp],104\ncmp dword ptr (-4)[ebp],0\nje L1125\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1125:\nL1123:\nmov byte ptr (-9)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nmovsx edi,byte ptr (-9)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfsub qword ptr (-64)[ebp]\ncall __ftol\nmov ebx,eax\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,3\nje L1127\nmov dword ptr (-8)[ebp],105\ncmp dword ptr (-4)[ebp],0\nje L1129\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1129:\nL1127:\nmov word ptr (-12)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nsub edi,esi\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,3\nje L1131\nmov dword ptr (-8)[ebp],106\ncmp dword ptr (-4)[ebp],0\nje L1133\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1133:\nL1131:\nmov word ptr (-12)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nsub edi,esi\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,3\nje L1135\nmov dword ptr (-8)[ebp],107\ncmp dword ptr (-4)[ebp],0\nje L1137\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1137:\nL1135:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-32)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nsub edi,dword ptr (-32)[ebp]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,3\nje L1139\nmov dword ptr (-8)[ebp],108\ncmp dword ptr (-4)[ebp],0\nje L1141\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1141:\nL1139:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-36)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nsub edi,dword ptr (-36)[ebp]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,3\nje L1143\nmov dword ptr (-8)[ebp],109\ncmp dword ptr (-4)[ebp],0\nje L1145\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1145:\nL1143:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-40)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nsub edi,dword ptr (-40)[ebp]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,3\nje L1147\nmov dword ptr (-8)[ebp],110\ncmp dword ptr (-4)[ebp],0\nje L1149\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1149:\nL1147:\nmov word ptr (-12)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nmovsx edi,word ptr (-12)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfsub dword ptr (-56)[ebp]\ncall __ftol\nmov edi,eax\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,3\nje L1151\nmov dword ptr (-8)[ebp],111\ncmp dword ptr (-4)[ebp],0\nje L1153\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1153:\nL1151:\nmov word ptr (-12)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nmovsx edi,word ptr (-12)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfsub qword ptr (-64)[ebp]\ncall __ftol\nmov edi,eax\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,3\nje L1155\nmov dword ptr (-8)[ebp],112\ncmp dword ptr (-4)[ebp],0\nje L1157\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1157:\nL1155:\nmov dword ptr (-16)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx edi,byte ptr (-25)[ebp]\nsub dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],3\nje L1159\nmov dword ptr (-8)[ebp],113\ncmp dword ptr (-4)[ebp],0\nje L1161\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1161:\nL1159:\nmov dword ptr (-16)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx edi,word ptr (-28)[ebp]\nsub dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],3\nje L1163\nmov dword ptr (-8)[ebp],114\ncmp dword ptr (-4)[ebp],0\nje L1165\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1165:\nL1163:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (-32)[ebp]\nsub dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],3\nje L1167\nmov dword ptr (-8)[ebp],115\ncmp dword ptr (-4)[ebp],0\nje L1169\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1169:\nL1167:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov edi,dword ptr (-36)[ebp]\nsub dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],3\nje L1171\nmov dword ptr (-8)[ebp],116\ncmp dword ptr (-4)[ebp],0\nje L1173\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1173:\nL1171:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-16)[ebp]\nsub edi,dword ptr (-40)[ebp]\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],3\nje L1175\nmov dword ptr (-8)[ebp],117\ncmp dword ptr (-4)[ebp],0\nje L1177\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1177:\nL1175:\nmov dword ptr (-16)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nmov edi,dword ptr (-16)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfsub dword ptr (-56)[ebp]\ncall __ftol\nmov dword ptr (-16)[ebp],eax\ncmp dword ptr (-16)[ebp],3\nje L1179\nmov dword ptr (-8)[ebp],118\ncmp dword ptr (-4)[ebp],0\nje L1181\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1181:\nL1179:\nmov dword ptr (-16)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfild dword ptr (-16)[ebp]\nfsub qword ptr (-64)[ebp]\ncall __ftol\nmov dword ptr (-16)[ebp],eax\ncmp dword ptr (-16)[ebp],3\nje L1183\nmov dword ptr (-8)[ebp],119\ncmp dword ptr (-4)[ebp],0\nje L1185\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1185:\nL1183:\nmov dword ptr (-20)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx edi,byte ptr (-25)[ebp]\nsub dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],3\nje L1187\nmov dword ptr (-8)[ebp],120\ncmp dword ptr (-4)[ebp],0\nje L1189\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1189:\nL1187:\nmov dword ptr (-20)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx edi,word ptr (-28)[ebp]\nsub dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],3\nje L1191\nmov dword ptr (-8)[ebp],121\ncmp dword ptr (-4)[ebp],0\nje L1193\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1193:\nL1191:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (-32)[ebp]\nsub dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],3\nje L1195\nmov dword ptr (-8)[ebp],122\ncmp dword ptr (-4)[ebp],0\nje L1197\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1197:\nL1195:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov edi,dword ptr (-36)[ebp]\nsub dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],3\nje L1199\nmov dword ptr (-8)[ebp],123\ncmp dword ptr (-4)[ebp],0\nje L1201\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1201:\nL1199:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-20)[ebp]\nsub edi,dword ptr (-40)[ebp]\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],3\nje L1203\nmov dword ptr (-8)[ebp],124\ncmp dword ptr (-4)[ebp],0\nje L1205\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1205:\nL1203:\nmov dword ptr (-20)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nmov edi,dword ptr (-20)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfsub dword ptr (-56)[ebp]\ncall __ftol\nmov dword ptr (-20)[ebp],eax\ncmp dword ptr (-20)[ebp],3\nje L1207\nmov dword ptr (-8)[ebp],125\ncmp dword ptr (-4)[ebp],0\nje L1209\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1209:\nL1207:\nmov dword ptr (-20)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfild dword ptr (-20)[ebp]\nfsub qword ptr (-64)[ebp]\ncall __ftol\nmov dword ptr (-20)[ebp],eax\ncmp dword ptr (-20)[ebp],3\nje L1211\nmov dword ptr (-8)[ebp],126\ncmp dword ptr (-4)[ebp],0\nje L1213\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1213:\nL1211:\nmov dword ptr (-24)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx edi,byte ptr (-25)[ebp]\nsub dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,3\nje L1215\nmov dword ptr (-8)[ebp],127\ncmp dword ptr (-4)[ebp],0\nje L1217\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1217:\nL1215:\nmov dword ptr (-24)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx edi,word ptr (-28)[ebp]\nsub dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,3\nje L1219\nmov dword ptr (-8)[ebp],128\ncmp dword ptr (-4)[ebp],0\nje L1221\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1221:\nL1219:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (-32)[ebp]\nsub dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,3\nje L1223\nmov dword ptr (-8)[ebp],129\ncmp dword ptr (-4)[ebp],0\nje L1225\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1225:\nL1223:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov edi,dword ptr (-36)[ebp]\nsub dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,3\nje L1227\nmov dword ptr (-8)[ebp],130\ncmp dword ptr (-4)[ebp],0\nje L1229\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1229:\nL1227:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-40)[ebp]\nsub dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,3\nje L1231\nmov dword ptr (-8)[ebp],131\ncmp dword ptr (-4)[ebp],0\nje L1233\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1233:\nL1231:\nmov dword ptr (-24)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nmov edi,dword ptr (-24)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nsub esp,4\nfstp dword ptr 0[esp]\nfld dword ptr 0[esp]\nadd esp,4\nfsub dword ptr (-56)[ebp]\nfstp dword ptr (-160)[ebp]\nfld dword ptr (L828)\nfcomp dword ptr (-160)[ebp]\nfstsw ax\nsahf\nja L1236\nfld dword ptr (-160)[ebp]\nfsub dword ptr (L828)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-156)[ebp],edi\njmp L1237\nL1236:\nfld dword ptr (-160)[ebp]\ncall __ftol\nmov edi,eax\nmov dword ptr (-156)[ebp],edi\nL1237:\nmov edi,dword ptr (-156)[ebp]\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,3\nje L1238\nmov dword ptr (-8)[ebp],132\ncmp dword ptr (-4)[ebp],0\nje L1240\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1240:\nL1238:\nmov dword ptr (-24)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nmov edi,dword ptr (-24)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nfsub qword ptr (-64)[ebp]\nfstp qword ptr (-176)[ebp]\nfld qword ptr (L836)\nfcomp qword ptr (-176)[ebp]\nfstsw ax\nsahf\nja L1243\nfld qword ptr (-176)[ebp]\nfsub qword ptr (L836)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-168)[ebp],edi\njmp L1244\nL1243:\nfld qword ptr (-176)[ebp]\ncall __ftol\nmov edi,eax\nmov dword ptr (-168)[ebp],edi\nL1244:\nmov edi,dword ptr (-168)[ebp]\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,3\nje L1245\nmov dword ptr (-8)[ebp],133\ncmp dword ptr (-4)[ebp],0\nje L1247\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1247:\nL1245:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov byte ptr (-25)[ebp],2\nfld dword ptr (-44)[ebp]\nmovsx edi,byte ptr (-25)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfsubp st(1),st\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L1251)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1249\nmov dword ptr (-8)[ebp],134\ncmp dword ptr (-4)[ebp],0\nje L1252\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1252:\nL1249:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov word ptr (-28)[ebp],2\nfld dword ptr (-44)[ebp]\nmovsx edi,word ptr (-28)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfsubp st(1),st\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L1251)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1254\nmov dword ptr (-8)[ebp],135\ncmp dword ptr (-4)[ebp],0\nje L1256\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1256:\nL1254:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov dword ptr (-32)[ebp],2\nfld dword ptr (-44)[ebp]\nmov edi,dword ptr (-32)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfsubp st(1),st\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L1251)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1258\nmov dword ptr (-8)[ebp],136\ncmp dword ptr (-4)[ebp],0\nje L1260\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1260:\nL1258:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov dword ptr (-36)[ebp],2\nfld dword ptr (-44)[ebp]\nmov edi,dword ptr (-36)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfsubp st(1),st\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L1251)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1262\nmov dword ptr (-8)[ebp],137\ncmp dword ptr (-4)[ebp],0\nje L1264\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1264:\nL1262:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-40)[ebp]\nfld dword ptr (-44)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nsub esp,4\nfstp dword ptr 0[esp]\nfld dword ptr 0[esp]\nadd esp,4\nfsubp st(1),st\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L1251)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1266\nmov dword ptr (-8)[ebp],138\ncmp dword ptr (-4)[ebp],0\nje L1268\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1268:\nL1266:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nfld dword ptr (-44)[ebp]\nfsub dword ptr (-56)[ebp]\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L1251)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1270\nmov dword ptr (-8)[ebp],139\ncmp dword ptr (-4)[ebp],0\nje L1272\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1272:\nL1270:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfld dword ptr (-44)[ebp]\nfsub qword ptr (-64)[ebp]\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L1251)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1274\nmov dword ptr (-8)[ebp],140\ncmp dword ptr (-4)[ebp],0\nje L1276\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1276:\nL1274:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov byte ptr (-25)[ebp],2\nfld qword ptr (-52)[ebp]\nmovsx edi,byte ptr (-25)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfsubp st(1),st\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1280)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1278\nmov dword ptr (-8)[ebp],141\ncmp dword ptr (-4)[ebp],0\nje L1281\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1281:\nL1278:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov word ptr (-28)[ebp],2\nfld qword ptr (-52)[ebp]\nmovsx edi,word ptr (-28)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfsubp st(1),st\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1280)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1283\nmov dword ptr (-8)[ebp],142\ncmp dword ptr (-4)[ebp],0\nje L1285\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1285:\nL1283:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov dword ptr (-32)[ebp],2\nfld qword ptr (-52)[ebp]\nfild dword ptr (-32)[ebp]\nfsubp st(1),st\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1280)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1287\nmov dword ptr (-8)[ebp],143\ncmp dword ptr (-4)[ebp],0\nje L1289\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1289:\nL1287:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov dword ptr (-36)[ebp],2\nfld qword ptr (-52)[ebp]\nfild dword ptr (-36)[ebp]\nfsubp st(1),st\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1280)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1291\nmov dword ptr (-8)[ebp],144\ncmp dword ptr (-4)[ebp],0\nje L1293\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1293:\nL1291:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-40)[ebp]\nfld qword ptr (-52)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nfsubp st(1),st\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1280)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1295\nmov dword ptr (-8)[ebp],145\ncmp dword ptr (-4)[ebp],0\nje L1297\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1297:\nL1295:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nfld qword ptr (-52)[ebp]\nfsub dword ptr (-56)[ebp]\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1280)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1299\nmov dword ptr (-8)[ebp],146\ncmp dword ptr (-4)[ebp],0\nje L1301\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1301:\nL1299:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfld qword ptr (-52)[ebp]\nfsub qword ptr (-64)[ebp]\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1280)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1303\nmov dword ptr (-8)[ebp],147\ncmp dword ptr (-4)[ebp],0\nje L1305\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1305:\nL1303:\nmov byte ptr (-9)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nimul edi,esi\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,10\nje L1307\nmov dword ptr (-8)[ebp],148\ncmp dword ptr (-4)[ebp],0\nje L1309\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1309:\nL1307:\nmov byte ptr (-9)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nimul edi,esi\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,10\nje L1311\nmov dword ptr (-8)[ebp],149\ncmp dword ptr (-4)[ebp],0\nje L1313\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1313:\nL1311:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-32)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmov esi,dword ptr (-32)[ebp]\nimul edi,esi\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,10\nje L1315\nmov dword ptr (-8)[ebp],150\ncmp dword ptr (-4)[ebp],0\nje L1317\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1317:\nL1315:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-36)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmov esi,dword ptr (-36)[ebp]\nimul edi,esi\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,10\nje L1319\nmov dword ptr (-8)[ebp],151\ncmp dword ptr (-4)[ebp],0\nje L1321\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1321:\nL1319:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-40)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmov eax,edi\nmul dword ptr (-40)[ebp]\nmov edi,eax\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,10\nje L1323\nmov dword ptr (-8)[ebp],152\ncmp dword ptr (-4)[ebp],0\nje L1325\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1325:\nL1323:\nmov byte ptr (-9)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nmovsx edi,byte ptr (-9)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfmul dword ptr (-56)[ebp]\ncall __ftol\nmov ebx,eax\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,10\nje L1327\nmov dword ptr (-8)[ebp],153\ncmp dword ptr (-4)[ebp],0\nje L1329\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1329:\nL1327:\nmov byte ptr (-9)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nmovsx edi,byte ptr (-9)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfmul qword ptr (-64)[ebp]\ncall __ftol\nmov ebx,eax\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,10\nje L1331\nmov dword ptr (-8)[ebp],154\ncmp dword ptr (-4)[ebp],0\nje L1333\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1333:\nL1331:\nmov word ptr (-12)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nimul edi,esi\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,10\nje L1335\nmov dword ptr (-8)[ebp],155\ncmp dword ptr (-4)[ebp],0\nje L1337\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1337:\nL1335:\nmov word ptr (-12)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nimul edi,esi\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,10\nje L1339\nmov dword ptr (-8)[ebp],156\ncmp dword ptr (-4)[ebp],0\nje L1341\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1341:\nL1339:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-32)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmov esi,dword ptr (-32)[ebp]\nimul edi,esi\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,10\nje L1343\nmov dword ptr (-8)[ebp],157\ncmp dword ptr (-4)[ebp],0\nje L1345\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1345:\nL1343:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-36)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmov esi,dword ptr (-36)[ebp]\nimul edi,esi\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,10\nje L1347\nmov dword ptr (-8)[ebp],158\ncmp dword ptr (-4)[ebp],0\nje L1349\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1349:\nL1347:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-40)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmov eax,edi\nmul dword ptr (-40)[ebp]\nmov edi,eax\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,10\nje L1351\nmov dword ptr (-8)[ebp],159\ncmp dword ptr (-4)[ebp],0\nje L1353\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1353:\nL1351:\nmov word ptr (-12)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nmovsx edi,word ptr (-12)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfmul dword ptr (-56)[ebp]\ncall __ftol\nmov edi,eax\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,10\nje L1355\nmov dword ptr (-8)[ebp],160\ncmp dword ptr (-4)[ebp],0\nje L1357\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1357:\nL1355:\nmov word ptr (-12)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nmovsx edi,word ptr (-12)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfmul qword ptr (-64)[ebp]\ncall __ftol\nmov edi,eax\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,10\nje L1359\nmov dword ptr (-8)[ebp],161\ncmp dword ptr (-4)[ebp],0\nje L1361\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1361:\nL1359:\nmov dword ptr (-16)[ebp],5\nmov byte ptr (-25)[ebp],2\nmov edi,dword ptr (-16)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nimul edi,esi\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],10\nje L1363\nmov dword ptr (-8)[ebp],162\ncmp dword ptr (-4)[ebp],0\nje L1365\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1365:\nL1363:\nmov dword ptr (-16)[ebp],5\nmov word ptr (-28)[ebp],2\nmov edi,dword ptr (-16)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nimul edi,esi\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],10\nje L1367\nmov dword ptr (-8)[ebp],163\ncmp dword ptr (-4)[ebp],0\nje L1369\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1369:\nL1367:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (-16)[ebp]\nmov esi,dword ptr (-32)[ebp]\nimul edi,esi\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],10\nje L1371\nmov dword ptr (-8)[ebp],164\ncmp dword ptr (-4)[ebp],0\nje L1373\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1373:\nL1371:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov edi,dword ptr (-16)[ebp]\nmov esi,dword ptr (-36)[ebp]\nimul edi,esi\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],10\nje L1375\nmov dword ptr (-8)[ebp],165\ncmp dword ptr (-4)[ebp],0\nje L1377\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1377:\nL1375:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-16)[ebp]\nmov eax,edi\nmul dword ptr (-40)[ebp]\nmov edi,eax\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],10\nje L1379\nmov dword ptr (-8)[ebp],166\ncmp dword ptr (-4)[ebp],0\nje L1381\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1381:\nL1379:\nmov dword ptr (-16)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nmov edi,dword ptr (-16)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfmul dword ptr (-56)[ebp]\ncall __ftol\nmov dword ptr (-16)[ebp],eax\ncmp dword ptr (-16)[ebp],10\nje L1383\nmov dword ptr (-8)[ebp],167\ncmp dword ptr (-4)[ebp],0\nje L1385\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1385:\nL1383:\nmov dword ptr (-16)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfild dword ptr (-16)[ebp]\nfmul qword ptr (-64)[ebp]\ncall __ftol\nmov dword ptr (-16)[ebp],eax\ncmp dword ptr (-16)[ebp],10\nje L1387\nmov dword ptr (-8)[ebp],168\ncmp dword ptr (-4)[ebp],0\nje L1389\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1389:\nL1387:\nmov dword ptr (-20)[ebp],5\nmov byte ptr (-25)[ebp],2\nmov edi,dword ptr (-20)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nimul edi,esi\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],10\nje L1391\nmov dword ptr (-8)[ebp],169\ncmp dword ptr (-4)[ebp],0\nje L1393\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1393:\nL1391:\nmov dword ptr (-20)[ebp],5\nmov word ptr (-28)[ebp],2\nmov edi,dword ptr (-20)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nimul edi,esi\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],10\nje L1395\nmov dword ptr (-8)[ebp],170\ncmp dword ptr (-4)[ebp],0\nje L1397\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1397:\nL1395:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (-20)[ebp]\nmov esi,dword ptr (-32)[ebp]\nimul edi,esi\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],10\nje L1399\nmov dword ptr (-8)[ebp],171\ncmp dword ptr (-4)[ebp],0\nje L1401\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1401:\nL1399:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov edi,dword ptr (-20)[ebp]\nmov esi,dword ptr (-36)[ebp]\nimul edi,esi\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],10\nje L1403\nmov dword ptr (-8)[ebp],172\ncmp dword ptr (-4)[ebp],0\nje L1405\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1405:\nL1403:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-20)[ebp]\nmov eax,edi\nmul dword ptr (-40)[ebp]\nmov edi,eax\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],10\nje L1407\nmov dword ptr (-8)[ebp],173\ncmp dword ptr (-4)[ebp],0\nje L1409\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1409:\nL1407:\nmov dword ptr (-20)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nmov edi,dword ptr (-20)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfmul dword ptr (-56)[ebp]\ncall __ftol\nmov dword ptr (-20)[ebp],eax\ncmp dword ptr (-20)[ebp],10\nje L1411\nmov dword ptr (-8)[ebp],174\ncmp dword ptr (-4)[ebp],0\nje L1413\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1413:\nL1411:\nmov dword ptr (-20)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfild dword ptr (-20)[ebp]\nfmul qword ptr (-64)[ebp]\ncall __ftol\nmov dword ptr (-20)[ebp],eax\ncmp dword ptr (-20)[ebp],10\nje L1415\nmov dword ptr (-8)[ebp],175\ncmp dword ptr (-4)[ebp],0\nje L1417\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1417:\nL1415:\nmov dword ptr (-24)[ebp],5\nmov byte ptr (-25)[ebp],2\nmov eax,dword ptr (-24)[ebp]\nmovsx edi,byte ptr (-25)[ebp]\nmul edi\nmov dword ptr (-24)[ebp],eax\nmov edi,dword ptr (-24)[ebp]\ncmp edi,10\nje L1419\nmov dword ptr (-8)[ebp],176\ncmp dword ptr (-4)[ebp],0\nje L1421\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1421:\nL1419:\nmov dword ptr (-24)[ebp],5\nmov word ptr (-28)[ebp],2\nmov eax,dword ptr (-24)[ebp]\nmovsx edi,word ptr (-28)[ebp]\nmul edi\nmov dword ptr (-24)[ebp],eax\nmov edi,dword ptr (-24)[ebp]\ncmp edi,10\nje L1423\nmov dword ptr (-8)[ebp],177\ncmp dword ptr (-4)[ebp],0\nje L1425\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1425:\nL1423:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov eax,dword ptr (-24)[ebp]\nmov edi,dword ptr (-32)[ebp]\nmul edi\nmov dword ptr (-24)[ebp],eax\nmov edi,dword ptr (-24)[ebp]\ncmp edi,10\nje L1427\nmov dword ptr (-8)[ebp],178\ncmp dword ptr (-4)[ebp],0\nje L1429\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1429:\nL1427:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov eax,dword ptr (-24)[ebp]\nmov edi,dword ptr (-36)[ebp]\nmul edi\nmov dword ptr (-24)[ebp],eax\nmov edi,dword ptr (-24)[ebp]\ncmp edi,10\nje L1431\nmov dword ptr (-8)[ebp],179\ncmp dword ptr (-4)[ebp],0\nje L1433\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1433:\nL1431:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov eax,dword ptr (-24)[ebp]\nmul dword ptr (-40)[ebp]\nmov dword ptr (-24)[ebp],eax\nmov edi,dword ptr (-24)[ebp]\ncmp edi,10\nje L1435\nmov dword ptr (-8)[ebp],180\ncmp dword ptr (-4)[ebp],0\nje L1437\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1437:\nL1435:\nmov dword ptr (-24)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nmov edi,dword ptr (-24)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nsub esp,4\nfstp dword ptr 0[esp]\nfld dword ptr 0[esp]\nadd esp,4\nfmul dword ptr (-56)[ebp]\nfstp dword ptr (-192)[ebp]\nfld dword ptr (L828)\nfcomp dword ptr (-192)[ebp]\nfstsw ax\nsahf\nja L1440\nfld dword ptr (-192)[ebp]\nfsub dword ptr (L828)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-188)[ebp],edi\njmp L1441\nL1440:\nfld dword ptr (-192)[ebp]\ncall __ftol\nmov edi,eax\nmov dword ptr (-188)[ebp],edi\nL1441:\nmov edi,dword ptr (-188)[ebp]\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,10\nje L1442\nmov dword ptr (-8)[ebp],181\ncmp dword ptr (-4)[ebp],0\nje L1444\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1444:\nL1442:\nmov dword ptr (-24)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nmov edi,dword ptr (-24)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nfmul qword ptr (-64)[ebp]\nfstp qword ptr (-208)[ebp]\nfld qword ptr (L836)\nfcomp qword ptr (-208)[ebp]\nfstsw ax\nsahf\nja L1447\nfld qword ptr (-208)[ebp]\nfsub qword ptr (L836)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-200)[ebp],edi\njmp L1448\nL1447:\nfld qword ptr (-208)[ebp]\ncall __ftol\nmov edi,eax\nmov dword ptr (-200)[ebp],edi\nL1448:\nmov edi,dword ptr (-200)[ebp]\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,10\nje L1449\nmov dword ptr (-8)[ebp],182\ncmp dword ptr (-4)[ebp],0\nje L1451\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1451:\nL1449:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov byte ptr (-25)[ebp],2\nfld dword ptr (-44)[ebp]\nmovsx edi,byte ptr (-25)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L1455)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1453\nmov dword ptr (-8)[ebp],183\ncmp dword ptr (-4)[ebp],0\nje L1456\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1456:\nL1453:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov word ptr (-28)[ebp],2\nfld dword ptr (-44)[ebp]\nmovsx edi,word ptr (-28)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L1455)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1458\nmov dword ptr (-8)[ebp],184\ncmp dword ptr (-4)[ebp],0\nje L1460\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1460:\nL1458:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov dword ptr (-32)[ebp],2\nfld dword ptr (-44)[ebp]\nmov edi,dword ptr (-32)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L1455)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1462\nmov dword ptr (-8)[ebp],185\ncmp dword ptr (-4)[ebp],0\nje L1464\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1464:\nL1462:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov dword ptr (-36)[ebp],2\nfld dword ptr (-44)[ebp]\nmov edi,dword ptr (-36)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L1455)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1466\nmov dword ptr (-8)[ebp],186\ncmp dword ptr (-4)[ebp],0\nje L1468\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1468:\nL1466:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-40)[ebp]\nfld dword ptr (-44)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nsub esp,4\nfstp dword ptr 0[esp]\nfld dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L1455)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1470\nmov dword ptr (-8)[ebp],187\ncmp dword ptr (-4)[ebp],0\nje L1472\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1472:\nL1470:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nfld dword ptr (-44)[ebp]\nfmul dword ptr (-56)[ebp]\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L1455)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1474\nmov dword ptr (-8)[ebp],188\ncmp dword ptr (-4)[ebp],0\nje L1476\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1476:\nL1474:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfld dword ptr (-44)[ebp]\nfmul qword ptr (-64)[ebp]\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L1455)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1478\nmov dword ptr (-8)[ebp],189\ncmp dword ptr (-4)[ebp],0\nje L1480\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1480:\nL1478:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov byte ptr (-25)[ebp],2\nfld qword ptr (-52)[ebp]\nmovsx edi,byte ptr (-25)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1484)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1482\nmov dword ptr (-8)[ebp],190\ncmp dword ptr (-4)[ebp],0\nje L1485\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1485:\nL1482:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov word ptr (-28)[ebp],2\nfld qword ptr (-52)[ebp]\nmovsx edi,word ptr (-28)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1484)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1487\nmov dword ptr (-8)[ebp],191\ncmp dword ptr (-4)[ebp],0\nje L1489\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1489:\nL1487:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov dword ptr (-32)[ebp],2\nfld qword ptr (-52)[ebp]\nfild dword ptr (-32)[ebp]\nfmulp st(1),st\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1484)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1491\nmov dword ptr (-8)[ebp],192\ncmp dword ptr (-4)[ebp],0\nje L1493\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1493:\nL1491:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov dword ptr (-36)[ebp],2\nfld qword ptr (-52)[ebp]\nfild dword ptr (-36)[ebp]\nfmulp st(1),st\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1484)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1495\nmov dword ptr (-8)[ebp],193\ncmp dword ptr (-4)[ebp],0\nje L1497\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1497:\nL1495:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-40)[ebp]\nfld qword ptr (-52)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nfmulp st(1),st\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1484)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1499\nmov dword ptr (-8)[ebp],194\ncmp dword ptr (-4)[ebp],0\nje L1501\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1501:\nL1499:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nfld qword ptr (-52)[ebp]\nfmul dword ptr (-56)[ebp]\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1484)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1503\nmov dword ptr (-8)[ebp],195\ncmp dword ptr (-4)[ebp],0\nje L1505\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1505:\nL1503:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfld qword ptr (-52)[ebp]\nfmul qword ptr (-64)[ebp]\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1484)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1507\nmov dword ptr (-8)[ebp],196\ncmp dword ptr (-4)[ebp],0\nje L1509\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1509:\nL1507:\nmov byte ptr (-9)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx eax,byte ptr (-9)[ebp]\nmovsx edi,byte ptr (-25)[ebp]\ncdq\nidiv edi\nmov ebx,eax\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,2\nje L1511\nmov dword ptr (-8)[ebp],197\ncmp dword ptr (-4)[ebp],0\nje L1513\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1513:\nL1511:\nmov byte ptr (-9)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx eax,byte ptr (-9)[ebp]\nmovsx edi,word ptr (-28)[ebp]\ncdq\nidiv edi\nmov ebx,eax\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,2\nje L1515\nmov dword ptr (-8)[ebp],198\ncmp dword ptr (-4)[ebp],0\nje L1517\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1517:\nL1515:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-32)[ebp],2\nmovsx eax,byte ptr (-9)[ebp]\nmov edi,dword ptr (-32)[ebp]\ncdq\nidiv edi\nmov ebx,eax\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,2\nje L1519\nmov dword ptr (-8)[ebp],199\ncmp dword ptr (-4)[ebp],0\nje L1521\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1521:\nL1519:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-36)[ebp],2\nmovsx eax,byte ptr (-9)[ebp]\nmov edi,dword ptr (-36)[ebp]\ncdq\nidiv edi\nmov ebx,eax\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,2\nje L1523\nmov dword ptr (-8)[ebp],200\ncmp dword ptr (-4)[ebp],0\nje L1525\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1525:\nL1523:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-40)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmov eax,edi\nmov edi,dword ptr (-40)[ebp]\nxor edx,edx\ndiv edi\nmov edi,eax\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,2\nje L1527\nmov dword ptr (-8)[ebp],201\ncmp dword ptr (-4)[ebp],0\nje L1529\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1529:\nL1527:\nmov byte ptr (-9)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nmovsx edi,byte ptr (-9)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfdiv dword ptr (-56)[ebp]\ncall __ftol\nmov ebx,eax\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,2\nje L1531\nmov dword ptr (-8)[ebp],202\ncmp dword ptr (-4)[ebp],0\nje L1533\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1533:\nL1531:\nmov byte ptr (-9)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nmovsx edi,byte ptr (-9)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfdiv qword ptr (-64)[ebp]\ncall __ftol\nmov ebx,eax\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,2\nje L1535\nmov dword ptr (-8)[ebp],203\ncmp dword ptr (-4)[ebp],0\nje L1537\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1537:\nL1535:\nmov word ptr (-12)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx eax,word ptr (-12)[ebp]\nmovsx edi,byte ptr (-25)[ebp]\ncdq\nidiv edi\nmov edi,eax\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,2\nje L1539\nmov dword ptr (-8)[ebp],204\ncmp dword ptr (-4)[ebp],0\nje L1541\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1541:\nL1539:\nmov word ptr (-12)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx eax,word ptr (-12)[ebp]\nmovsx edi,word ptr (-28)[ebp]\ncdq\nidiv edi\nmov edi,eax\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,2\nje L1543\nmov dword ptr (-8)[ebp],205\ncmp dword ptr (-4)[ebp],0\nje L1545\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1545:\nL1543:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-32)[ebp],2\nmovsx eax,word ptr (-12)[ebp]\nmov edi,dword ptr (-32)[ebp]\ncdq\nidiv edi\nmov edi,eax\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,2\nje L1547\nmov dword ptr (-8)[ebp],206\ncmp dword ptr (-4)[ebp],0\nje L1549\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1549:\nL1547:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-36)[ebp],2\nmovsx eax,word ptr (-12)[ebp]\nmov edi,dword ptr (-36)[ebp]\ncdq\nidiv edi\nmov edi,eax\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,2\nje L1551\nmov dword ptr (-8)[ebp],207\ncmp dword ptr (-4)[ebp],0\nje L1553\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1553:\nL1551:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-40)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmov eax,edi\nmov edi,dword ptr (-40)[ebp]\nxor edx,edx\ndiv edi\nmov edi,eax\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,2\nje L1555\nmov dword ptr (-8)[ebp],208\ncmp dword ptr (-4)[ebp],0\nje L1557\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1557:\nL1555:\nmov word ptr (-12)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nmovsx edi,word ptr (-12)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfdiv dword ptr (-56)[ebp]\ncall __ftol\nmov edi,eax\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,2\nje L1559\nmov dword ptr (-8)[ebp],209\ncmp dword ptr (-4)[ebp],0\nje L1561\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1561:\nL1559:\nmov word ptr (-12)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nmovsx edi,word ptr (-12)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfdiv qword ptr (-64)[ebp]\ncall __ftol\nmov edi,eax\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,2\nje L1563\nmov dword ptr (-8)[ebp],210\ncmp dword ptr (-4)[ebp],0\nje L1565\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1565:\nL1563:\nmov dword ptr (-16)[ebp],5\nmov byte ptr (-25)[ebp],2\nmov eax,dword ptr (-16)[ebp]\nmovsx edi,byte ptr (-25)[ebp]\ncdq\nidiv edi\nmov dword ptr (-16)[ebp],eax\ncmp dword ptr (-16)[ebp],2\nje L1567\nmov dword ptr (-8)[ebp],211\ncmp dword ptr (-4)[ebp],0\nje L1569\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1569:\nL1567:\nmov dword ptr (-16)[ebp],5\nmov word ptr (-28)[ebp],2\nmov eax,dword ptr (-16)[ebp]\nmovsx edi,word ptr (-28)[ebp]\ncdq\nidiv edi\nmov dword ptr (-16)[ebp],eax\ncmp dword ptr (-16)[ebp],2\nje L1571\nmov dword ptr (-8)[ebp],212\ncmp dword ptr (-4)[ebp],0\nje L1573\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1573:\nL1571:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov eax,dword ptr (-16)[ebp]\nmov edi,dword ptr (-32)[ebp]\ncdq\nidiv edi\nmov dword ptr (-16)[ebp],eax\ncmp dword ptr (-16)[ebp],2\nje L1575\nmov dword ptr (-8)[ebp],213\ncmp dword ptr (-4)[ebp],0\nje L1577\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1577:\nL1575:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov eax,dword ptr (-16)[ebp]\nmov edi,dword ptr (-36)[ebp]\ncdq\nidiv edi\nmov dword ptr (-16)[ebp],eax\ncmp dword ptr (-16)[ebp],2\nje L1579\nmov dword ptr (-8)[ebp],214\ncmp dword ptr (-4)[ebp],0\nje L1581\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1581:\nL1579:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-16)[ebp]\nmov eax,edi\nmov edi,dword ptr (-40)[ebp]\nxor edx,edx\ndiv edi\nmov edi,eax\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],2\nje L1583\nmov dword ptr (-8)[ebp],215\ncmp dword ptr (-4)[ebp],0\nje L1585\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1585:\nL1583:\nmov dword ptr (-16)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nmov edi,dword ptr (-16)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfdiv dword ptr (-56)[ebp]\ncall __ftol\nmov dword ptr (-16)[ebp],eax\ncmp dword ptr (-16)[ebp],2\nje L1587\nmov dword ptr (-8)[ebp],216\ncmp dword ptr (-4)[ebp],0\nje L1589\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1589:\nL1587:\nmov dword ptr (-16)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfild dword ptr (-16)[ebp]\nfdiv qword ptr (-64)[ebp]\ncall __ftol\nmov dword ptr (-16)[ebp],eax\ncmp dword ptr (-16)[ebp],2\nje L1591\nmov dword ptr (-8)[ebp],217\ncmp dword ptr (-4)[ebp],0\nje L1593\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1593:\nL1591:\nmov dword ptr (-20)[ebp],5\nmov byte ptr (-25)[ebp],2\nmov eax,dword ptr (-20)[ebp]\nmovsx edi,byte ptr (-25)[ebp]\ncdq\nidiv edi\nmov dword ptr (-20)[ebp],eax\ncmp dword ptr (-20)[ebp],2\nje L1595\nmov dword ptr (-8)[ebp],218\ncmp dword ptr (-4)[ebp],0\nje L1597\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1597:\nL1595:\nmov dword ptr (-20)[ebp],5\nmov word ptr (-28)[ebp],2\nmov eax,dword ptr (-20)[ebp]\nmovsx edi,word ptr (-28)[ebp]\ncdq\nidiv edi\nmov dword ptr (-20)[ebp],eax\ncmp dword ptr (-20)[ebp],2\nje L1599\nmov dword ptr (-8)[ebp],219\ncmp dword ptr (-4)[ebp],0\nje L1601\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1601:\nL1599:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov eax,dword ptr (-20)[ebp]\nmov edi,dword ptr (-32)[ebp]\ncdq\nidiv edi\nmov dword ptr (-20)[ebp],eax\ncmp dword ptr (-20)[ebp],2\nje L1603\nmov dword ptr (-8)[ebp],220\ncmp dword ptr (-4)[ebp],0\nje L1605\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1605:\nL1603:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov eax,dword ptr (-20)[ebp]\nmov edi,dword ptr (-36)[ebp]\ncdq\nidiv edi\nmov dword ptr (-20)[ebp],eax\ncmp dword ptr (-20)[ebp],2\nje L1607\nmov dword ptr (-8)[ebp],221\ncmp dword ptr (-4)[ebp],0\nje L1609\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1609:\nL1607:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-20)[ebp]\nmov eax,edi\nmov edi,dword ptr (-40)[ebp]\nxor edx,edx\ndiv edi\nmov edi,eax\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],2\nje L1611\nmov dword ptr (-8)[ebp],222\ncmp dword ptr (-4)[ebp],0\nje L1613\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1613:\nL1611:\nmov dword ptr (-20)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nmov edi,dword ptr (-20)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfdiv dword ptr (-56)[ebp]\ncall __ftol\nmov dword ptr (-20)[ebp],eax\ncmp dword ptr (-20)[ebp],2\nje L1615\nmov dword ptr (-8)[ebp],223\ncmp dword ptr (-4)[ebp],0\nje L1617\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1617:\nL1615:\nmov dword ptr (-20)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfild dword ptr (-20)[ebp]\nfdiv qword ptr (-64)[ebp]\ncall __ftol\nmov dword ptr (-20)[ebp],eax\ncmp dword ptr (-20)[ebp],2\nje L1619\nmov dword ptr (-8)[ebp],224\ncmp dword ptr (-4)[ebp],0\nje L1621\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1621:\nL1619:\nmov dword ptr (-24)[ebp],5\nmov byte ptr (-25)[ebp],2\nmov eax,dword ptr (-24)[ebp]\nmovsx edi,byte ptr (-25)[ebp]\nxor edx,edx\ndiv edi\nmov dword ptr (-24)[ebp],eax\nmov edi,dword ptr (-24)[ebp]\ncmp edi,2\nje L1623\nmov dword ptr (-8)[ebp],225\ncmp dword ptr (-4)[ebp],0\nje L1625\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1625:\nL1623:\nmov dword ptr (-24)[ebp],5\nmov word ptr (-28)[ebp],2\nmov eax,dword ptr (-24)[ebp]\nmovsx edi,word ptr (-28)[ebp]\nxor edx,edx\ndiv edi\nmov dword ptr (-24)[ebp],eax\nmov edi,dword ptr (-24)[ebp]\ncmp edi,2\nje L1627\nmov dword ptr (-8)[ebp],226\ncmp dword ptr (-4)[ebp],0\nje L1629\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1629:\nL1627:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov eax,dword ptr (-24)[ebp]\nmov edi,dword ptr (-32)[ebp]\nxor edx,edx\ndiv edi\nmov dword ptr (-24)[ebp],eax\nmov edi,dword ptr (-24)[ebp]\ncmp edi,2\nje L1631\nmov dword ptr (-8)[ebp],227\ncmp dword ptr (-4)[ebp],0\nje L1633\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1633:\nL1631:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov eax,dword ptr (-24)[ebp]\nmov edi,dword ptr (-36)[ebp]\nxor edx,edx\ndiv edi\nmov dword ptr (-24)[ebp],eax\nmov edi,dword ptr (-24)[ebp]\ncmp edi,2\nje L1635\nmov dword ptr (-8)[ebp],228\ncmp dword ptr (-4)[ebp],0\nje L1637\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1637:\nL1635:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov eax,dword ptr (-24)[ebp]\nmov edi,dword ptr (-40)[ebp]\nxor edx,edx\ndiv edi\nmov dword ptr (-24)[ebp],eax\nmov edi,dword ptr (-24)[ebp]\ncmp edi,2\nje L1639\nmov dword ptr (-8)[ebp],229\ncmp dword ptr (-4)[ebp],0\nje L1641\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1641:\nL1639:\nmov dword ptr (-24)[ebp],5\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nmov edi,dword ptr (-24)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nsub esp,4\nfstp dword ptr 0[esp]\nfld dword ptr 0[esp]\nadd esp,4\nfdiv dword ptr (-56)[ebp]\nfstp dword ptr (-224)[ebp]\nfld dword ptr (L828)\nfcomp dword ptr (-224)[ebp]\nfstsw ax\nsahf\nja L1644\nfld dword ptr (-224)[ebp]\nfsub dword ptr (L828)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-220)[ebp],edi\njmp L1645\nL1644:\nfld dword ptr (-224)[ebp]\ncall __ftol\nmov edi,eax\nmov dword ptr (-220)[ebp],edi\nL1645:\nmov edi,dword ptr (-220)[ebp]\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,2\nje L1646\nmov dword ptr (-8)[ebp],230\ncmp dword ptr (-4)[ebp],0\nje L1648\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1648:\nL1646:\nmov dword ptr (-24)[ebp],5\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nmov edi,dword ptr (-24)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nfdiv qword ptr (-64)[ebp]\nfstp qword ptr (-240)[ebp]\nfld qword ptr (L836)\nfcomp qword ptr (-240)[ebp]\nfstsw ax\nsahf\nja L1651\nfld qword ptr (-240)[ebp]\nfsub qword ptr (L836)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-232)[ebp],edi\njmp L1652\nL1651:\nfld qword ptr (-240)[ebp]\ncall __ftol\nmov edi,eax\nmov dword ptr (-232)[ebp],edi\nL1652:\nmov edi,dword ptr (-232)[ebp]\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,2\nje L1653\nmov dword ptr (-8)[ebp],231\ncmp dword ptr (-4)[ebp],0\nje L1655\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1655:\nL1653:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov byte ptr (-25)[ebp],2\nfld dword ptr (-44)[ebp]\nmovsx edi,byte ptr (-25)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfdivp st(1),st\nfstp dword ptr (-44)[ebp]\nfld qword ptr (L1659)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1657\nmov dword ptr (-8)[ebp],232\ncmp dword ptr (-4)[ebp],0\nje L1660\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1660:\nL1657:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov word ptr (-28)[ebp],2\nfld dword ptr (-44)[ebp]\nmovsx edi,word ptr (-28)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfdivp st(1),st\nfstp dword ptr (-44)[ebp]\nfld qword ptr (L1659)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1662\nmov dword ptr (-8)[ebp],233\ncmp dword ptr (-4)[ebp],0\nje L1664\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1664:\nL1662:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov dword ptr (-32)[ebp],2\nfld dword ptr (-44)[ebp]\nmov edi,dword ptr (-32)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfdivp st(1),st\nfstp dword ptr (-44)[ebp]\nfld qword ptr (L1659)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1666\nmov dword ptr (-8)[ebp],234\ncmp dword ptr (-4)[ebp],0\nje L1668\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1668:\nL1666:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov dword ptr (-36)[ebp],2\nfld dword ptr (-44)[ebp]\nmov edi,dword ptr (-36)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfdivp st(1),st\nfstp dword ptr (-44)[ebp]\nfld qword ptr (L1659)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1670\nmov dword ptr (-8)[ebp],235\ncmp dword ptr (-4)[ebp],0\nje L1672\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1672:\nL1670:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-40)[ebp]\nfld dword ptr (-44)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nsub esp,4\nfstp dword ptr 0[esp]\nfld dword ptr 0[esp]\nadd esp,4\nfdivp st(1),st\nfstp dword ptr (-44)[ebp]\nfld qword ptr (L1659)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1674\nmov dword ptr (-8)[ebp],236\ncmp dword ptr (-4)[ebp],0\nje L1676\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1676:\nL1674:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nfld dword ptr (-44)[ebp]\nfdiv dword ptr (-56)[ebp]\nfstp dword ptr (-44)[ebp]\nfld qword ptr (L1659)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1678\nmov dword ptr (-8)[ebp],237\ncmp dword ptr (-4)[ebp],0\nje L1680\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1680:\nL1678:\nfld dword ptr (L841)\nfstp dword ptr (-44)[ebp]\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfld dword ptr (-44)[ebp]\nfdiv qword ptr (-64)[ebp]\nfstp dword ptr (-44)[ebp]\nfld qword ptr (L1659)\nfcomp dword ptr (-44)[ebp]\nfstsw ax\nsahf\nje L1682\nmov dword ptr (-8)[ebp],238\ncmp dword ptr (-4)[ebp],0\nje L1684\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1684:\nL1682:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov byte ptr (-25)[ebp],2\nfld qword ptr (-52)[ebp]\nmovsx edi,byte ptr (-25)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfdivp st(1),st\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1659)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1686\nmov dword ptr (-8)[ebp],239\ncmp dword ptr (-4)[ebp],0\nje L1688\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1688:\nL1686:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov word ptr (-28)[ebp],2\nfld qword ptr (-52)[ebp]\nmovsx edi,word ptr (-28)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfdivp st(1),st\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1659)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1690\nmov dword ptr (-8)[ebp],240\ncmp dword ptr (-4)[ebp],0\nje L1692\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1692:\nL1690:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov dword ptr (-32)[ebp],2\nfld qword ptr (-52)[ebp]\nfild dword ptr (-32)[ebp]\nfdivp st(1),st\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1659)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1694\nmov dword ptr (-8)[ebp],241\ncmp dword ptr (-4)[ebp],0\nje L1696\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1696:\nL1694:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov dword ptr (-36)[ebp],2\nfld qword ptr (-52)[ebp]\nfild dword ptr (-36)[ebp]\nfdivp st(1),st\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1659)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1698\nmov dword ptr (-8)[ebp],242\ncmp dword ptr (-4)[ebp],0\nje L1700\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1700:\nL1698:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-40)[ebp]\nfld qword ptr (-52)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nfdivp st(1),st\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1659)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1702\nmov dword ptr (-8)[ebp],243\ncmp dword ptr (-4)[ebp],0\nje L1704\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1704:\nL1702:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nfld dword ptr (L529)\nfstp dword ptr (-56)[ebp]\nfld qword ptr (-52)[ebp]\nfdiv dword ptr (-56)[ebp]\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1659)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1706\nmov dword ptr (-8)[ebp],244\ncmp dword ptr (-4)[ebp],0\nje L1708\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1708:\nL1706:\nfld qword ptr (L870)\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L416)\nfstp qword ptr (-64)[ebp]\nfld qword ptr (-52)[ebp]\nfdiv qword ptr (-64)[ebp]\nfstp qword ptr (-52)[ebp]\nfld qword ptr (L1659)\nfcomp qword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L1710\nmov dword ptr (-8)[ebp],245\ncmp dword ptr (-4)[ebp],0\nje L1712\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1712:\nL1710:\nmov byte ptr (-9)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx eax,byte ptr (-9)[ebp]\nmovsx edi,byte ptr (-25)[ebp]\ncdq\nidiv edi\nmov ebx,edx\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,1\nje L1714\nmov dword ptr (-8)[ebp],246\ncmp dword ptr (-4)[ebp],0\nje L1716\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1716:\nL1714:\nmov byte ptr (-9)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx eax,byte ptr (-9)[ebp]\nmovsx edi,word ptr (-28)[ebp]\ncdq\nidiv edi\nmov ebx,edx\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,1\nje L1718\nmov dword ptr (-8)[ebp],247\ncmp dword ptr (-4)[ebp],0\nje L1720\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1720:\nL1718:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-32)[ebp],2\nmovsx eax,byte ptr (-9)[ebp]\nmov edi,dword ptr (-32)[ebp]\ncdq\nidiv edi\nmov ebx,edx\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,1\nje L1722\nmov dword ptr (-8)[ebp],248\ncmp dword ptr (-4)[ebp],0\nje L1724\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1724:\nL1722:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-36)[ebp],2\nmovsx eax,byte ptr (-9)[ebp]\nmov edi,dword ptr (-36)[ebp]\ncdq\nidiv edi\nmov ebx,edx\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,1\nje L1726\nmov dword ptr (-8)[ebp],249\ncmp dword ptr (-4)[ebp],0\nje L1728\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1728:\nL1726:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-40)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmov eax,edi\nmov edi,dword ptr (-40)[ebp]\nxor edx,edx\ndiv edi\nmov edi,edx\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,1\nje L1730\nmov dword ptr (-8)[ebp],250\ncmp dword ptr (-4)[ebp],0\nje L1732\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1732:\nL1730:\nmov word ptr (-12)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx eax,word ptr (-12)[ebp]\nmovsx edi,byte ptr (-25)[ebp]\ncdq\nidiv edi\nmov edi,edx\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,1\nje L1734\nmov dword ptr (-8)[ebp],251\ncmp dword ptr (-4)[ebp],0\nje L1736\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1736:\nL1734:\nmov word ptr (-12)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx eax,word ptr (-12)[ebp]\nmovsx edi,word ptr (-28)[ebp]\ncdq\nidiv edi\nmov edi,edx\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,1\nje L1738\nmov dword ptr (-8)[ebp],252\ncmp dword ptr (-4)[ebp],0\nje L1740\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1740:\nL1738:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-32)[ebp],2\nmovsx eax,word ptr (-12)[ebp]\nmov edi,dword ptr (-32)[ebp]\ncdq\nidiv edi\nmov edi,edx\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,1\nje L1742\nmov dword ptr (-8)[ebp],253\ncmp dword ptr (-4)[ebp],0\nje L1744\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1744:\nL1742:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-36)[ebp],2\nmovsx eax,word ptr (-12)[ebp]\nmov edi,dword ptr (-36)[ebp]\ncdq\nidiv edi\nmov edi,edx\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,1\nje L1746\nmov dword ptr (-8)[ebp],254\ncmp dword ptr (-4)[ebp],0\nje L1748\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1748:\nL1746:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-40)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmov eax,edi\nmov edi,dword ptr (-40)[ebp]\nxor edx,edx\ndiv edi\nmov edi,edx\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,1\nje L1750\nmov dword ptr (-8)[ebp],255\ncmp dword ptr (-4)[ebp],0\nje L1752\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1752:\nL1750:\nmov dword ptr (-16)[ebp],5\nmov byte ptr (-25)[ebp],2\nmov eax,dword ptr (-16)[ebp]\nmovsx edi,byte ptr (-25)[ebp]\ncdq\nidiv edi\nmov dword ptr (-16)[ebp],edx\ncmp dword ptr (-16)[ebp],1\nje L1754\nmov dword ptr (-8)[ebp],256\ncmp dword ptr (-4)[ebp],0\nje L1756\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1756:\nL1754:\nmov dword ptr (-16)[ebp],5\nmov word ptr (-28)[ebp],2\nmov eax,dword ptr (-16)[ebp]\nmovsx edi,word ptr (-28)[ebp]\ncdq\nidiv edi\nmov dword ptr (-16)[ebp],edx\ncmp dword ptr (-16)[ebp],1\nje L1758\nmov dword ptr (-8)[ebp],257\ncmp dword ptr (-4)[ebp],0\nje L1760\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1760:\nL1758:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov eax,dword ptr (-16)[ebp]\nmov edi,dword ptr (-32)[ebp]\ncdq\nidiv edi\nmov dword ptr (-16)[ebp],edx\ncmp dword ptr (-16)[ebp],1\nje L1762\nmov dword ptr (-8)[ebp],258\ncmp dword ptr (-4)[ebp],0\nje L1764\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1764:\nL1762:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov eax,dword ptr (-16)[ebp]\nmov edi,dword ptr (-36)[ebp]\ncdq\nidiv edi\nmov dword ptr (-16)[ebp],edx\ncmp dword ptr (-16)[ebp],1\nje L1766\nmov dword ptr (-8)[ebp],259\ncmp dword ptr (-4)[ebp],0\nje L1768\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1768:\nL1766:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-16)[ebp]\nmov eax,edi\nmov edi,dword ptr (-40)[ebp]\nxor edx,edx\ndiv edi\nmov edi,edx\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],1\nje L1770\nmov dword ptr (-8)[ebp],260\ncmp dword ptr (-4)[ebp],0\nje L1772\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1772:\nL1770:\nmov dword ptr (-20)[ebp],5\nmov byte ptr (-25)[ebp],2\nmov eax,dword ptr (-20)[ebp]\nmovsx edi,byte ptr (-25)[ebp]\ncdq\nidiv edi\nmov dword ptr (-20)[ebp],edx\ncmp dword ptr (-20)[ebp],1\nje L1774\nmov dword ptr (-8)[ebp],261\ncmp dword ptr (-4)[ebp],0\nje L1776\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1776:\nL1774:\nmov dword ptr (-20)[ebp],5\nmov word ptr (-28)[ebp],2\nmov eax,dword ptr (-20)[ebp]\nmovsx edi,word ptr (-28)[ebp]\ncdq\nidiv edi\nmov dword ptr (-20)[ebp],edx\ncmp dword ptr (-20)[ebp],1\nje L1778\nmov dword ptr (-8)[ebp],262\ncmp dword ptr (-4)[ebp],0\nje L1780\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1780:\nL1778:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov eax,dword ptr (-20)[ebp]\nmov edi,dword ptr (-32)[ebp]\ncdq\nidiv edi\nmov dword ptr (-20)[ebp],edx\ncmp dword ptr (-20)[ebp],1\nje L1782\nmov dword ptr (-8)[ebp],263\ncmp dword ptr (-4)[ebp],0\nje L1784\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1784:\nL1782:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov eax,dword ptr (-20)[ebp]\nmov edi,dword ptr (-36)[ebp]\ncdq\nidiv edi\nmov dword ptr (-20)[ebp],edx\ncmp dword ptr (-20)[ebp],1\nje L1786\nmov dword ptr (-8)[ebp],264\ncmp dword ptr (-4)[ebp],0\nje L1788\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1788:\nL1786:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-20)[ebp]\nmov eax,edi\nmov edi,dword ptr (-40)[ebp]\nxor edx,edx\ndiv edi\nmov edi,edx\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],1\nje L1790\nmov dword ptr (-8)[ebp],265\ncmp dword ptr (-4)[ebp],0\nje L1792\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1792:\nL1790:\nmov dword ptr (-24)[ebp],5\nmov byte ptr (-25)[ebp],2\nmov eax,dword ptr (-24)[ebp]\nmovsx edi,byte ptr (-25)[ebp]\nxor edx,edx\ndiv edi\nmov dword ptr (-24)[ebp],edx\nmov edi,dword ptr (-24)[ebp]\ncmp edi,1\nje L1794\nmov dword ptr (-8)[ebp],266\ncmp dword ptr (-4)[ebp],0\nje L1796\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1796:\nL1794:\nmov dword ptr (-24)[ebp],5\nmov word ptr (-28)[ebp],2\nmov eax,dword ptr (-24)[ebp]\nmovsx edi,word ptr (-28)[ebp]\nxor edx,edx\ndiv edi\nmov dword ptr (-24)[ebp],edx\nmov edi,dword ptr (-24)[ebp]\ncmp edi,1\nje L1798\nmov dword ptr (-8)[ebp],267\ncmp dword ptr (-4)[ebp],0\nje L1800\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1800:\nL1798:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov eax,dword ptr (-24)[ebp]\nmov edi,dword ptr (-32)[ebp]\nxor edx,edx\ndiv edi\nmov dword ptr (-24)[ebp],edx\nmov edi,dword ptr (-24)[ebp]\ncmp edi,1\nje L1802\nmov dword ptr (-8)[ebp],268\ncmp dword ptr (-4)[ebp],0\nje L1804\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1804:\nL1802:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov eax,dword ptr (-24)[ebp]\nmov edi,dword ptr (-36)[ebp]\nxor edx,edx\ndiv edi\nmov dword ptr (-24)[ebp],edx\nmov edi,dword ptr (-24)[ebp]\ncmp edi,1\nje L1806\nmov dword ptr (-8)[ebp],269\ncmp dword ptr (-4)[ebp],0\nje L1808\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1808:\nL1806:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov eax,dword ptr (-24)[ebp]\nmov edi,dword ptr (-40)[ebp]\nxor edx,edx\ndiv edi\nmov dword ptr (-24)[ebp],edx\nmov edi,dword ptr (-24)[ebp]\ncmp edi,1\nje L1810\nmov dword ptr (-8)[ebp],270\ncmp dword ptr (-4)[ebp],0\nje L1812\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1812:\nL1810:\nmov byte ptr (-9)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nmov ecx,esi\nsar edi,cl\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,1\nje L1814\nmov dword ptr (-8)[ebp],271\ncmp dword ptr (-4)[ebp],0\nje L1816\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1816:\nL1814:\nmov byte ptr (-9)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nmov ecx,esi\nsar edi,cl\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,1\nje L1818\nmov dword ptr (-8)[ebp],272\ncmp dword ptr (-4)[ebp],0\nje L1820\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1820:\nL1818:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-32)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmov esi,dword ptr (-32)[ebp]\nmov ecx,esi\nsar edi,cl\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,1\nje L1822\nmov dword ptr (-8)[ebp],273\ncmp dword ptr (-4)[ebp],0\nje L1824\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1824:\nL1822:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-36)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmov esi,dword ptr (-36)[ebp]\nmov ecx,esi\nsar edi,cl\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,1\nje L1826\nmov dword ptr (-8)[ebp],274\ncmp dword ptr (-4)[ebp],0\nje L1828\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1828:\nL1826:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-40)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmov esi,dword ptr (-40)[ebp]\nmov ecx,esi\nsar edi,cl\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,1\nje L1830\nmov dword ptr (-8)[ebp],275\ncmp dword ptr (-4)[ebp],0\nje L1832\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1832:\nL1830:\nmov word ptr (-12)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nmov ecx,esi\nsar edi,cl\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,1\nje L1834\nmov dword ptr (-8)[ebp],276\ncmp dword ptr (-4)[ebp],0\nje L1836\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1836:\nL1834:\nmov word ptr (-12)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nmov ecx,esi\nsar edi,cl\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,1\nje L1838\nmov dword ptr (-8)[ebp],277\ncmp dword ptr (-4)[ebp],0\nje L1840\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1840:\nL1838:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-32)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmov esi,dword ptr (-32)[ebp]\nmov ecx,esi\nsar edi,cl\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,1\nje L1842\nmov dword ptr (-8)[ebp],278\ncmp dword ptr (-4)[ebp],0\nje L1844\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1844:\nL1842:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-36)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmov esi,dword ptr (-36)[ebp]\nmov ecx,esi\nsar edi,cl\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,1\nje L1846\nmov dword ptr (-8)[ebp],279\ncmp dword ptr (-4)[ebp],0\nje L1848\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1848:\nL1846:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-40)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmov esi,dword ptr (-40)[ebp]\nmov ecx,esi\nsar edi,cl\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,1\nje L1850\nmov dword ptr (-8)[ebp],280\ncmp dword ptr (-4)[ebp],0\nje L1852\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1852:\nL1850:\nmov dword ptr (-16)[ebp],5\nmov byte ptr (-25)[ebp],2\nmov edi,dword ptr (-16)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nmov ecx,esi\nsar edi,cl\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],1\nje L1854\nmov dword ptr (-8)[ebp],281\ncmp dword ptr (-4)[ebp],0\nje L1856\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1856:\nL1854:\nmov dword ptr (-16)[ebp],5\nmov word ptr (-28)[ebp],2\nmov edi,dword ptr (-16)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nmov ecx,esi\nsar edi,cl\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],1\nje L1858\nmov dword ptr (-8)[ebp],282\ncmp dword ptr (-4)[ebp],0\nje L1860\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1860:\nL1858:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (-16)[ebp]\nmov esi,dword ptr (-32)[ebp]\nmov ecx,esi\nsar edi,cl\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],1\nje L1862\nmov dword ptr (-8)[ebp],283\ncmp dword ptr (-4)[ebp],0\nje L1864\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1864:\nL1862:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov edi,dword ptr (-16)[ebp]\nmov esi,dword ptr (-36)[ebp]\nmov ecx,esi\nsar edi,cl\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],1\nje L1866\nmov dword ptr (-8)[ebp],284\ncmp dword ptr (-4)[ebp],0\nje L1868\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1868:\nL1866:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-16)[ebp]\nmov esi,dword ptr (-40)[ebp]\nmov ecx,esi\nsar edi,cl\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],1\nje L1870\nmov dword ptr (-8)[ebp],285\ncmp dword ptr (-4)[ebp],0\nje L1872\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1872:\nL1870:\nmov dword ptr (-20)[ebp],5\nmov byte ptr (-25)[ebp],2\nmov edi,dword ptr (-20)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nmov ecx,esi\nsar edi,cl\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],1\nje L1874\nmov dword ptr (-8)[ebp],286\ncmp dword ptr (-4)[ebp],0\nje L1876\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1876:\nL1874:\nmov dword ptr (-20)[ebp],5\nmov word ptr (-28)[ebp],2\nmov edi,dword ptr (-20)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nmov ecx,esi\nsar edi,cl\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],1\nje L1878\nmov dword ptr (-8)[ebp],287\ncmp dword ptr (-4)[ebp],0\nje L1880\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1880:\nL1878:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (-20)[ebp]\nmov esi,dword ptr (-32)[ebp]\nmov ecx,esi\nsar edi,cl\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],1\nje L1882\nmov dword ptr (-8)[ebp],288\ncmp dword ptr (-4)[ebp],0\nje L1884\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1884:\nL1882:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov edi,dword ptr (-20)[ebp]\nmov esi,dword ptr (-36)[ebp]\nmov ecx,esi\nsar edi,cl\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],1\nje L1886\nmov dword ptr (-8)[ebp],289\ncmp dword ptr (-4)[ebp],0\nje L1888\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1888:\nL1886:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-20)[ebp]\nmov esi,dword ptr (-40)[ebp]\nmov ecx,esi\nsar edi,cl\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],1\nje L1890\nmov dword ptr (-8)[ebp],290\ncmp dword ptr (-4)[ebp],0\nje L1892\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1892:\nL1890:\nmov dword ptr (-24)[ebp],5\nmov byte ptr (-25)[ebp],2\nmov edi,dword ptr (-24)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nmov ecx,esi\nshr edi,cl\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,1\nje L1894\nmov dword ptr (-8)[ebp],291\ncmp dword ptr (-4)[ebp],0\nje L1896\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1896:\nL1894:\nmov dword ptr (-24)[ebp],5\nmov word ptr (-28)[ebp],2\nmov edi,dword ptr (-24)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nmov ecx,esi\nshr edi,cl\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,1\nje L1898\nmov dword ptr (-8)[ebp],292\ncmp dword ptr (-4)[ebp],0\nje L1900\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1900:\nL1898:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (-24)[ebp]\nmov esi,dword ptr (-32)[ebp]\nmov ecx,esi\nshr edi,cl\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,1\nje L1902\nmov dword ptr (-8)[ebp],293\ncmp dword ptr (-4)[ebp],0\nje L1904\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1904:\nL1902:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov edi,dword ptr (-24)[ebp]\nmov esi,dword ptr (-36)[ebp]\nmov ecx,esi\nshr edi,cl\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,1\nje L1906\nmov dword ptr (-8)[ebp],294\ncmp dword ptr (-4)[ebp],0\nje L1908\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1908:\nL1906:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-24)[ebp]\nmov esi,dword ptr (-40)[ebp]\nmov ecx,esi\nshr edi,cl\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,1\nje L1910\nmov dword ptr (-8)[ebp],295\ncmp dword ptr (-4)[ebp],0\nje L1912\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1912:\nL1910:\nmov byte ptr (-9)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nmov ecx,esi\nsal edi,cl\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,20\nje L1914\nmov dword ptr (-8)[ebp],296\ncmp dword ptr (-4)[ebp],0\nje L1916\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1916:\nL1914:\nmov byte ptr (-9)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nmov ecx,esi\nsal edi,cl\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,20\nje L1918\nmov dword ptr (-8)[ebp],297\ncmp dword ptr (-4)[ebp],0\nje L1920\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1920:\nL1918:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-32)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmov esi,dword ptr (-32)[ebp]\nmov ecx,esi\nsal edi,cl\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,20\nje L1922\nmov dword ptr (-8)[ebp],298\ncmp dword ptr (-4)[ebp],0\nje L1924\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1924:\nL1922:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-36)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmov esi,dword ptr (-36)[ebp]\nmov ecx,esi\nsal edi,cl\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,20\nje L1926\nmov dword ptr (-8)[ebp],299\ncmp dword ptr (-4)[ebp],0\nje L1928\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1928:\nL1926:\nmov byte ptr (-9)[ebp],5\nmov dword ptr (-40)[ebp],2\nmovsx edi,byte ptr (-9)[ebp]\nmov esi,dword ptr (-40)[ebp]\nmov ecx,esi\nsal edi,cl\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,20\nje L1930\nmov dword ptr (-8)[ebp],300\ncmp dword ptr (-4)[ebp],0\nje L1932\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1932:\nL1930:\nmov word ptr (-12)[ebp],5\nmov byte ptr (-25)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nmov ecx,esi\nsal edi,cl\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,20\nje L1934\nmov dword ptr (-8)[ebp],301\ncmp dword ptr (-4)[ebp],0\nje L1936\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1936:\nL1934:\nmov word ptr (-12)[ebp],5\nmov word ptr (-28)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nmov ecx,esi\nsal edi,cl\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,20\nje L1938\nmov dword ptr (-8)[ebp],302\ncmp dword ptr (-4)[ebp],0\nje L1940\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1940:\nL1938:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-32)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmov esi,dword ptr (-32)[ebp]\nmov ecx,esi\nsal edi,cl\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,20\nje L1942\nmov dword ptr (-8)[ebp],303\ncmp dword ptr (-4)[ebp],0\nje L1944\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1944:\nL1942:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-36)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmov esi,dword ptr (-36)[ebp]\nmov ecx,esi\nsal edi,cl\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,20\nje L1946\nmov dword ptr (-8)[ebp],304\ncmp dword ptr (-4)[ebp],0\nje L1948\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1948:\nL1946:\nmov word ptr (-12)[ebp],5\nmov dword ptr (-40)[ebp],2\nmovsx edi,word ptr (-12)[ebp]\nmov esi,dword ptr (-40)[ebp]\nmov ecx,esi\nsal edi,cl\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,20\nje L1950\nmov dword ptr (-8)[ebp],305\ncmp dword ptr (-4)[ebp],0\nje L1952\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1952:\nL1950:\nmov dword ptr (-16)[ebp],5\nmov byte ptr (-25)[ebp],2\nmov edi,dword ptr (-16)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nmov ecx,esi\nsal edi,cl\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],20\nje L1954\nmov dword ptr (-8)[ebp],306\ncmp dword ptr (-4)[ebp],0\nje L1956\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1956:\nL1954:\nmov dword ptr (-16)[ebp],5\nmov word ptr (-28)[ebp],2\nmov edi,dword ptr (-16)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nmov ecx,esi\nsal edi,cl\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],20\nje L1958\nmov dword ptr (-8)[ebp],307\ncmp dword ptr (-4)[ebp],0\nje L1960\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1960:\nL1958:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (-16)[ebp]\nmov esi,dword ptr (-32)[ebp]\nmov ecx,esi\nsal edi,cl\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],20\nje L1962\nmov dword ptr (-8)[ebp],308\ncmp dword ptr (-4)[ebp],0\nje L1964\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1964:\nL1962:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov edi,dword ptr (-16)[ebp]\nmov esi,dword ptr (-36)[ebp]\nmov ecx,esi\nsal edi,cl\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],20\nje L1966\nmov dword ptr (-8)[ebp],309\ncmp dword ptr (-4)[ebp],0\nje L1968\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1968:\nL1966:\nmov dword ptr (-16)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-16)[ebp]\nmov esi,dword ptr (-40)[ebp]\nmov ecx,esi\nsal edi,cl\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],20\nje L1970\nmov dword ptr (-8)[ebp],310\ncmp dword ptr (-4)[ebp],0\nje L1972\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1972:\nL1970:\nmov dword ptr (-20)[ebp],5\nmov byte ptr (-25)[ebp],2\nmov edi,dword ptr (-20)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nmov ecx,esi\nsal edi,cl\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],20\nje L1974\nmov dword ptr (-8)[ebp],311\ncmp dword ptr (-4)[ebp],0\nje L1976\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1976:\nL1974:\nmov dword ptr (-20)[ebp],5\nmov word ptr (-28)[ebp],2\nmov edi,dword ptr (-20)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nmov ecx,esi\nsal edi,cl\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],20\nje L1978\nmov dword ptr (-8)[ebp],312\ncmp dword ptr (-4)[ebp],0\nje L1980\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1980:\nL1978:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (-20)[ebp]\nmov esi,dword ptr (-32)[ebp]\nmov ecx,esi\nsal edi,cl\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],20\nje L1982\nmov dword ptr (-8)[ebp],313\ncmp dword ptr (-4)[ebp],0\nje L1984\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1984:\nL1982:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov edi,dword ptr (-20)[ebp]\nmov esi,dword ptr (-36)[ebp]\nmov ecx,esi\nsal edi,cl\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],20\nje L1986\nmov dword ptr (-8)[ebp],314\ncmp dword ptr (-4)[ebp],0\nje L1988\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1988:\nL1986:\nmov dword ptr (-20)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-20)[ebp]\nmov esi,dword ptr (-40)[ebp]\nmov ecx,esi\nsal edi,cl\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],20\nje L1990\nmov dword ptr (-8)[ebp],315\ncmp dword ptr (-4)[ebp],0\nje L1992\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1992:\nL1990:\nmov dword ptr (-24)[ebp],5\nmov byte ptr (-25)[ebp],2\nmov edi,dword ptr (-24)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nmov ecx,esi\nshl edi,cl\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,20\nje L1994\nmov dword ptr (-8)[ebp],316\ncmp dword ptr (-4)[ebp],0\nje L1996\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL1996:\nL1994:\nmov dword ptr (-24)[ebp],5\nmov word ptr (-28)[ebp],2\nmov edi,dword ptr (-24)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nmov ecx,esi\nshl edi,cl\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,20\nje L1998\nmov dword ptr (-8)[ebp],317\ncmp dword ptr (-4)[ebp],0\nje L2000\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2000:\nL1998:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (-24)[ebp]\nmov esi,dword ptr (-32)[ebp]\nmov ecx,esi\nshl edi,cl\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,20\nje L2002\nmov dword ptr (-8)[ebp],318\ncmp dword ptr (-4)[ebp],0\nje L2004\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2004:\nL2002:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-36)[ebp],2\nmov edi,dword ptr (-24)[ebp]\nmov esi,dword ptr (-36)[ebp]\nmov ecx,esi\nshl edi,cl\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,20\nje L2006\nmov dword ptr (-8)[ebp],319\ncmp dword ptr (-4)[ebp],0\nje L2008\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2008:\nL2006:\nmov dword ptr (-24)[ebp],5\nmov dword ptr (-40)[ebp],2\nmov edi,dword ptr (-24)[ebp]\nmov esi,dword ptr (-40)[ebp]\nmov ecx,esi\nshl edi,cl\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,20\nje L2010\nmov dword ptr (-8)[ebp],320\ncmp dword ptr (-4)[ebp],0\nje L2012\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2012:\nL2010:\nmov byte ptr (-9)[ebp],12\nmov byte ptr (-25)[ebp],10\nmovsx edi,byte ptr (-9)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nand edi,esi\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,8\nje L2014\nmov dword ptr (-8)[ebp],321\ncmp dword ptr (-4)[ebp],0\nje L2016\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2016:\nL2014:\nmov byte ptr (-9)[ebp],12\nmov word ptr (-28)[ebp],10\nmovsx edi,byte ptr (-9)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nand edi,esi\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,8\nje L2018\nmov dword ptr (-8)[ebp],322\ncmp dword ptr (-4)[ebp],0\nje L2020\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2020:\nL2018:\nmov byte ptr (-9)[ebp],12\nmov dword ptr (-32)[ebp],10\nmovsx edi,byte ptr (-9)[ebp]\nand edi,dword ptr (-32)[ebp]\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,8\nje L2022\nmov dword ptr (-8)[ebp],323\ncmp dword ptr (-4)[ebp],0\nje L2024\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2024:\nL2022:\nmov byte ptr (-9)[ebp],12\nmov dword ptr (-36)[ebp],10\nmovsx edi,byte ptr (-9)[ebp]\nand edi,dword ptr (-36)[ebp]\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,8\nje L2026\nmov dword ptr (-8)[ebp],324\ncmp dword ptr (-4)[ebp],0\nje L2028\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2028:\nL2026:\nmov byte ptr (-9)[ebp],12\nmov dword ptr (-40)[ebp],10\nmovsx edi,byte ptr (-9)[ebp]\nand edi,dword ptr (-40)[ebp]\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,8\nje L2030\nmov dword ptr (-8)[ebp],325\ncmp dword ptr (-4)[ebp],0\nje L2032\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2032:\nL2030:\nmov word ptr (-12)[ebp],12\nmov byte ptr (-25)[ebp],10\nmovsx edi,word ptr (-12)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nand edi,esi\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,8\nje L2034\nmov dword ptr (-8)[ebp],326\ncmp dword ptr (-4)[ebp],0\nje L2036\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2036:\nL2034:\nmov word ptr (-12)[ebp],12\nmov word ptr (-28)[ebp],10\nmovsx edi,word ptr (-12)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nand edi,esi\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,8\nje L2038\nmov dword ptr (-8)[ebp],327\ncmp dword ptr (-4)[ebp],0\nje L2040\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2040:\nL2038:\nmov word ptr (-12)[ebp],12\nmov dword ptr (-32)[ebp],10\nmovsx edi,word ptr (-12)[ebp]\nand edi,dword ptr (-32)[ebp]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,8\nje L2042\nmov dword ptr (-8)[ebp],328\ncmp dword ptr (-4)[ebp],0\nje L2044\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2044:\nL2042:\nmov word ptr (-12)[ebp],12\nmov dword ptr (-36)[ebp],10\nmovsx edi,word ptr (-12)[ebp]\nand edi,dword ptr (-36)[ebp]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,8\nje L2046\nmov dword ptr (-8)[ebp],329\ncmp dword ptr (-4)[ebp],0\nje L2048\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2048:\nL2046:\nmov word ptr (-12)[ebp],12\nmov dword ptr (-40)[ebp],10\nmovsx edi,word ptr (-12)[ebp]\nand edi,dword ptr (-40)[ebp]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,8\nje L2050\nmov dword ptr (-8)[ebp],330\ncmp dword ptr (-4)[ebp],0\nje L2052\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2052:\nL2050:\nmov dword ptr (-16)[ebp],12\nmov byte ptr (-25)[ebp],10\nmovsx edi,byte ptr (-25)[ebp]\nand dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],8\nje L2054\nmov dword ptr (-8)[ebp],331\ncmp dword ptr (-4)[ebp],0\nje L2056\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2056:\nL2054:\nmov dword ptr (-16)[ebp],12\nmov word ptr (-28)[ebp],10\nmovsx edi,word ptr (-28)[ebp]\nand dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],8\nje L2058\nmov dword ptr (-8)[ebp],332\ncmp dword ptr (-4)[ebp],0\nje L2060\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2060:\nL2058:\nmov dword ptr (-16)[ebp],12\nmov dword ptr (-32)[ebp],10\nmov edi,dword ptr (-32)[ebp]\nand dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],8\nje L2062\nmov dword ptr (-8)[ebp],333\ncmp dword ptr (-4)[ebp],0\nje L2064\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2064:\nL2062:\nmov dword ptr (-16)[ebp],12\nmov dword ptr (-36)[ebp],10\nmov edi,dword ptr (-36)[ebp]\nand dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],8\nje L2066\nmov dword ptr (-8)[ebp],334\ncmp dword ptr (-4)[ebp],0\nje L2068\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2068:\nL2066:\nmov dword ptr (-16)[ebp],12\nmov dword ptr (-40)[ebp],10\nmov edi,dword ptr (-16)[ebp]\nand edi,dword ptr (-40)[ebp]\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],8\nje L2070\nmov dword ptr (-8)[ebp],335\ncmp dword ptr (-4)[ebp],0\nje L2072\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2072:\nL2070:\nmov dword ptr (-20)[ebp],12\nmov byte ptr (-25)[ebp],10\nmovsx edi,byte ptr (-25)[ebp]\nand dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],8\nje L2074\nmov dword ptr (-8)[ebp],336\ncmp dword ptr (-4)[ebp],0\nje L2076\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2076:\nL2074:\nmov dword ptr (-20)[ebp],12\nmov word ptr (-28)[ebp],10\nmovsx edi,word ptr (-28)[ebp]\nand dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],8\nje L2078\nmov dword ptr (-8)[ebp],337\ncmp dword ptr (-4)[ebp],0\nje L2080\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2080:\nL2078:\nmov dword ptr (-20)[ebp],12\nmov dword ptr (-32)[ebp],10\nmov edi,dword ptr (-32)[ebp]\nand dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],8\nje L2082\nmov dword ptr (-8)[ebp],338\ncmp dword ptr (-4)[ebp],0\nje L2084\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2084:\nL2082:\nmov dword ptr (-20)[ebp],12\nmov dword ptr (-36)[ebp],10\nmov edi,dword ptr (-36)[ebp]\nand dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],8\nje L2086\nmov dword ptr (-8)[ebp],339\ncmp dword ptr (-4)[ebp],0\nje L2088\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2088:\nL2086:\nmov dword ptr (-20)[ebp],12\nmov dword ptr (-40)[ebp],10\nmov edi,dword ptr (-20)[ebp]\nand edi,dword ptr (-40)[ebp]\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],8\nje L2090\nmov dword ptr (-8)[ebp],340\ncmp dword ptr (-4)[ebp],0\nje L2092\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2092:\nL2090:\nmov dword ptr (-24)[ebp],12\nmov byte ptr (-25)[ebp],10\nmovsx edi,byte ptr (-25)[ebp]\nand dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,8\nje L2094\nmov dword ptr (-8)[ebp],341\ncmp dword ptr (-4)[ebp],0\nje L2096\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2096:\nL2094:\nmov dword ptr (-24)[ebp],12\nmov word ptr (-28)[ebp],10\nmovsx edi,word ptr (-28)[ebp]\nand dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,8\nje L2098\nmov dword ptr (-8)[ebp],342\ncmp dword ptr (-4)[ebp],0\nje L2100\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2100:\nL2098:\nmov dword ptr (-24)[ebp],12\nmov dword ptr (-32)[ebp],10\nmov edi,dword ptr (-32)[ebp]\nand dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,8\nje L2102\nmov dword ptr (-8)[ebp],343\ncmp dword ptr (-4)[ebp],0\nje L2104\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2104:\nL2102:\nmov dword ptr (-24)[ebp],12\nmov dword ptr (-36)[ebp],10\nmov edi,dword ptr (-36)[ebp]\nand dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,8\nje L2106\nmov dword ptr (-8)[ebp],344\ncmp dword ptr (-4)[ebp],0\nje L2108\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2108:\nL2106:\nmov dword ptr (-24)[ebp],12\nmov dword ptr (-40)[ebp],10\nmov edi,dword ptr (-40)[ebp]\nand dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,8\nje L2110\nmov dword ptr (-8)[ebp],345\ncmp dword ptr (-4)[ebp],0\nje L2112\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2112:\nL2110:\nmov byte ptr (-9)[ebp],12\nmov byte ptr (-25)[ebp],10\nmovsx edi,byte ptr (-9)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nxor edi,esi\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,6\nje L2114\nmov dword ptr (-8)[ebp],346\ncmp dword ptr (-4)[ebp],0\nje L2116\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2116:\nL2114:\nmov byte ptr (-9)[ebp],12\nmov word ptr (-28)[ebp],10\nmovsx edi,byte ptr (-9)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nxor edi,esi\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,6\nje L2118\nmov dword ptr (-8)[ebp],347\ncmp dword ptr (-4)[ebp],0\nje L2120\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2120:\nL2118:\nmov byte ptr (-9)[ebp],12\nmov dword ptr (-32)[ebp],10\nmovsx edi,byte ptr (-9)[ebp]\nxor edi,dword ptr (-32)[ebp]\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,6\nje L2122\nmov dword ptr (-8)[ebp],348\ncmp dword ptr (-4)[ebp],0\nje L2124\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2124:\nL2122:\nmov byte ptr (-9)[ebp],12\nmov dword ptr (-36)[ebp],10\nmovsx edi,byte ptr (-9)[ebp]\nxor edi,dword ptr (-36)[ebp]\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,6\nje L2126\nmov dword ptr (-8)[ebp],349\ncmp dword ptr (-4)[ebp],0\nje L2128\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2128:\nL2126:\nmov byte ptr (-9)[ebp],12\nmov dword ptr (-40)[ebp],10\nmovsx edi,byte ptr (-9)[ebp]\nxor edi,dword ptr (-40)[ebp]\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,6\nje L2130\nmov dword ptr (-8)[ebp],350\ncmp dword ptr (-4)[ebp],0\nje L2132\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2132:\nL2130:\nmov word ptr (-12)[ebp],12\nmov byte ptr (-25)[ebp],10\nmovsx edi,word ptr (-12)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nxor edi,esi\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,6\nje L2134\nmov dword ptr (-8)[ebp],351\ncmp dword ptr (-4)[ebp],0\nje L2136\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2136:\nL2134:\nmov word ptr (-12)[ebp],12\nmov word ptr (-28)[ebp],10\nmovsx edi,word ptr (-12)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nxor edi,esi\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,6\nje L2138\nmov dword ptr (-8)[ebp],352\ncmp dword ptr (-4)[ebp],0\nje L2140\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2140:\nL2138:\nmov word ptr (-12)[ebp],12\nmov dword ptr (-32)[ebp],10\nmovsx edi,word ptr (-12)[ebp]\nxor edi,dword ptr (-32)[ebp]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,6\nje L2142\nmov dword ptr (-8)[ebp],353\ncmp dword ptr (-4)[ebp],0\nje L2144\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2144:\nL2142:\nmov word ptr (-12)[ebp],12\nmov dword ptr (-36)[ebp],10\nmovsx edi,word ptr (-12)[ebp]\nxor edi,dword ptr (-36)[ebp]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,6\nje L2146\nmov dword ptr (-8)[ebp],354\ncmp dword ptr (-4)[ebp],0\nje L2148\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2148:\nL2146:\nmov word ptr (-12)[ebp],12\nmov dword ptr (-40)[ebp],10\nmovsx edi,word ptr (-12)[ebp]\nxor edi,dword ptr (-40)[ebp]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,6\nje L2150\nmov dword ptr (-8)[ebp],355\ncmp dword ptr (-4)[ebp],0\nje L2152\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2152:\nL2150:\nmov dword ptr (-16)[ebp],12\nmov byte ptr (-25)[ebp],10\nmovsx edi,byte ptr (-25)[ebp]\nxor dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],6\nje L2154\nmov dword ptr (-8)[ebp],356\ncmp dword ptr (-4)[ebp],0\nje L2156\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2156:\nL2154:\nmov dword ptr (-16)[ebp],12\nmov word ptr (-28)[ebp],10\nmovsx edi,word ptr (-28)[ebp]\nxor dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],6\nje L2158\nmov dword ptr (-8)[ebp],357\ncmp dword ptr (-4)[ebp],0\nje L2160\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2160:\nL2158:\nmov dword ptr (-16)[ebp],12\nmov dword ptr (-32)[ebp],10\nmov edi,dword ptr (-32)[ebp]\nxor dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],6\nje L2162\nmov dword ptr (-8)[ebp],358\ncmp dword ptr (-4)[ebp],0\nje L2164\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2164:\nL2162:\nmov dword ptr (-16)[ebp],12\nmov dword ptr (-36)[ebp],10\nmov edi,dword ptr (-36)[ebp]\nxor dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],6\nje L2166\nmov dword ptr (-8)[ebp],359\ncmp dword ptr (-4)[ebp],0\nje L2168\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2168:\nL2166:\nmov dword ptr (-16)[ebp],12\nmov dword ptr (-40)[ebp],10\nmov edi,dword ptr (-16)[ebp]\nxor edi,dword ptr (-40)[ebp]\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],6\nje L2170\nmov dword ptr (-8)[ebp],360\ncmp dword ptr (-4)[ebp],0\nje L2172\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2172:\nL2170:\nmov dword ptr (-20)[ebp],12\nmov byte ptr (-25)[ebp],10\nmovsx edi,byte ptr (-25)[ebp]\nxor dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],6\nje L2174\nmov dword ptr (-8)[ebp],361\ncmp dword ptr (-4)[ebp],0\nje L2176\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2176:\nL2174:\nmov dword ptr (-20)[ebp],12\nmov word ptr (-28)[ebp],10\nmovsx edi,word ptr (-28)[ebp]\nxor dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],6\nje L2178\nmov dword ptr (-8)[ebp],362\ncmp dword ptr (-4)[ebp],0\nje L2180\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2180:\nL2178:\nmov dword ptr (-20)[ebp],12\nmov dword ptr (-32)[ebp],10\nmov edi,dword ptr (-32)[ebp]\nxor dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],6\nje L2182\nmov dword ptr (-8)[ebp],363\ncmp dword ptr (-4)[ebp],0\nje L2184\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2184:\nL2182:\nmov dword ptr (-20)[ebp],12\nmov dword ptr (-36)[ebp],10\nmov edi,dword ptr (-36)[ebp]\nxor dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],6\nje L2186\nmov dword ptr (-8)[ebp],364\ncmp dword ptr (-4)[ebp],0\nje L2188\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2188:\nL2186:\nmov dword ptr (-20)[ebp],12\nmov dword ptr (-40)[ebp],10\nmov edi,dword ptr (-20)[ebp]\nxor edi,dword ptr (-40)[ebp]\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],6\nje L2190\nmov dword ptr (-8)[ebp],365\ncmp dword ptr (-4)[ebp],0\nje L2192\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2192:\nL2190:\nmov dword ptr (-24)[ebp],12\nmov byte ptr (-25)[ebp],10\nmovsx edi,byte ptr (-25)[ebp]\nxor dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,6\nje L2194\nmov dword ptr (-8)[ebp],366\ncmp dword ptr (-4)[ebp],0\nje L2196\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2196:\nL2194:\nmov dword ptr (-24)[ebp],12\nmov word ptr (-28)[ebp],10\nmovsx edi,word ptr (-28)[ebp]\nxor dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,6\nje L2198\nmov dword ptr (-8)[ebp],367\ncmp dword ptr (-4)[ebp],0\nje L2200\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2200:\nL2198:\nmov dword ptr (-24)[ebp],12\nmov dword ptr (-32)[ebp],10\nmov edi,dword ptr (-32)[ebp]\nxor dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,6\nje L2202\nmov dword ptr (-8)[ebp],368\ncmp dword ptr (-4)[ebp],0\nje L2204\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2204:\nL2202:\nmov dword ptr (-24)[ebp],12\nmov dword ptr (-36)[ebp],10\nmov edi,dword ptr (-36)[ebp]\nxor dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,6\nje L2206\nmov dword ptr (-8)[ebp],369\ncmp dword ptr (-4)[ebp],0\nje L2208\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2208:\nL2206:\nmov dword ptr (-24)[ebp],12\nmov dword ptr (-40)[ebp],10\nmov edi,dword ptr (-40)[ebp]\nxor dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,6\nje L2210\nmov dword ptr (-8)[ebp],370\ncmp dword ptr (-4)[ebp],0\nje L2212\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2212:\nL2210:\nmov byte ptr (-9)[ebp],12\nmov byte ptr (-25)[ebp],10\nmovsx edi,byte ptr (-9)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nor edi,esi\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,14\nje L2214\nmov dword ptr (-8)[ebp],371\ncmp dword ptr (-4)[ebp],0\nje L2216\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2216:\nL2214:\nmov byte ptr (-9)[ebp],12\nmov word ptr (-28)[ebp],10\nmovsx edi,byte ptr (-9)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nor edi,esi\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,14\nje L2218\nmov dword ptr (-8)[ebp],372\ncmp dword ptr (-4)[ebp],0\nje L2220\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2220:\nL2218:\nmov byte ptr (-9)[ebp],12\nmov dword ptr (-32)[ebp],10\nmovsx edi,byte ptr (-9)[ebp]\nor edi,dword ptr (-32)[ebp]\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,14\nje L2222\nmov dword ptr (-8)[ebp],373\ncmp dword ptr (-4)[ebp],0\nje L2224\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2224:\nL2222:\nmov byte ptr (-9)[ebp],12\nmov dword ptr (-36)[ebp],10\nmovsx edi,byte ptr (-9)[ebp]\nor edi,dword ptr (-36)[ebp]\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,14\nje L2226\nmov dword ptr (-8)[ebp],374\ncmp dword ptr (-4)[ebp],0\nje L2228\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2228:\nL2226:\nmov byte ptr (-9)[ebp],12\nmov dword ptr (-40)[ebp],10\nmovsx edi,byte ptr (-9)[ebp]\nor edi,dword ptr (-40)[ebp]\nmov ebx,edi\nmov byte ptr (-9)[ebp],bl\nmovsx edi,byte ptr (-9)[ebp]\ncmp edi,14\nje L2230\nmov dword ptr (-8)[ebp],375\ncmp dword ptr (-4)[ebp],0\nje L2232\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2232:\nL2230:\nmov word ptr (-12)[ebp],12\nmov byte ptr (-25)[ebp],10\nmovsx edi,word ptr (-12)[ebp]\nmovsx esi,byte ptr (-25)[ebp]\nor edi,esi\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,14\nje L2234\nmov dword ptr (-8)[ebp],376\ncmp dword ptr (-4)[ebp],0\nje L2236\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2236:\nL2234:\nmov word ptr (-12)[ebp],12\nmov word ptr (-28)[ebp],10\nmovsx edi,word ptr (-12)[ebp]\nmovsx esi,word ptr (-28)[ebp]\nor edi,esi\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,14\nje L2238\nmov dword ptr (-8)[ebp],377\ncmp dword ptr (-4)[ebp],0\nje L2240\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2240:\nL2238:\nmov word ptr (-12)[ebp],12\nmov dword ptr (-32)[ebp],10\nmovsx edi,word ptr (-12)[ebp]\nor edi,dword ptr (-32)[ebp]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,14\nje L2242\nmov dword ptr (-8)[ebp],378\ncmp dword ptr (-4)[ebp],0\nje L2244\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2244:\nL2242:\nmov word ptr (-12)[ebp],12\nmov dword ptr (-36)[ebp],10\nmovsx edi,word ptr (-12)[ebp]\nor edi,dword ptr (-36)[ebp]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,14\nje L2246\nmov dword ptr (-8)[ebp],379\ncmp dword ptr (-4)[ebp],0\nje L2248\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2248:\nL2246:\nmov word ptr (-12)[ebp],12\nmov dword ptr (-40)[ebp],10\nmovsx edi,word ptr (-12)[ebp]\nor edi,dword ptr (-40)[ebp]\nmov word ptr (-12)[ebp],di\nmovsx edi,word ptr (-12)[ebp]\ncmp edi,14\nje L2250\nmov dword ptr (-8)[ebp],380\ncmp dword ptr (-4)[ebp],0\nje L2252\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2252:\nL2250:\nmov dword ptr (-16)[ebp],12\nmov byte ptr (-25)[ebp],10\nmovsx edi,byte ptr (-25)[ebp]\nor dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],14\nje L2254\nmov dword ptr (-8)[ebp],381\ncmp dword ptr (-4)[ebp],0\nje L2256\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2256:\nL2254:\nmov dword ptr (-16)[ebp],12\nmov word ptr (-28)[ebp],10\nmovsx edi,word ptr (-28)[ebp]\nor dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],14\nje L2258\nmov dword ptr (-8)[ebp],382\ncmp dword ptr (-4)[ebp],0\nje L2260\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2260:\nL2258:\nmov dword ptr (-16)[ebp],12\nmov dword ptr (-32)[ebp],10\nmov edi,dword ptr (-32)[ebp]\nor dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],14\nje L2262\nmov dword ptr (-8)[ebp],383\ncmp dword ptr (-4)[ebp],0\nje L2264\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2264:\nL2262:\nmov dword ptr (-16)[ebp],12\nmov dword ptr (-36)[ebp],10\nmov edi,dword ptr (-36)[ebp]\nor dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],14\nje L2266\nmov dword ptr (-8)[ebp],384\ncmp dword ptr (-4)[ebp],0\nje L2268\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2268:\nL2266:\nmov dword ptr (-16)[ebp],12\nmov dword ptr (-40)[ebp],10\nmov edi,dword ptr (-16)[ebp]\nor edi,dword ptr (-40)[ebp]\nmov dword ptr (-16)[ebp],edi\ncmp dword ptr (-16)[ebp],14\nje L2270\nmov dword ptr (-8)[ebp],385\ncmp dword ptr (-4)[ebp],0\nje L2272\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2272:\nL2270:\nmov dword ptr (-20)[ebp],12\nmov byte ptr (-25)[ebp],10\nmovsx edi,byte ptr (-25)[ebp]\nor dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],14\nje L2274\nmov dword ptr (-8)[ebp],386\ncmp dword ptr (-4)[ebp],0\nje L2276\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2276:\nL2274:\nmov dword ptr (-20)[ebp],12\nmov word ptr (-28)[ebp],10\nmovsx edi,word ptr (-28)[ebp]\nor dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],14\nje L2278\nmov dword ptr (-8)[ebp],387\ncmp dword ptr (-4)[ebp],0\nje L2280\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2280:\nL2278:\nmov dword ptr (-20)[ebp],12\nmov dword ptr (-32)[ebp],10\nmov edi,dword ptr (-32)[ebp]\nor dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],14\nje L2282\nmov dword ptr (-8)[ebp],388\ncmp dword ptr (-4)[ebp],0\nje L2284\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2284:\nL2282:\nmov dword ptr (-20)[ebp],12\nmov dword ptr (-36)[ebp],10\nmov edi,dword ptr (-36)[ebp]\nor dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],14\nje L2286\nmov dword ptr (-8)[ebp],389\ncmp dword ptr (-4)[ebp],0\nje L2288\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2288:\nL2286:\nmov dword ptr (-20)[ebp],12\nmov dword ptr (-40)[ebp],10\nmov edi,dword ptr (-20)[ebp]\nor edi,dword ptr (-40)[ebp]\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],14\nje L2290\nmov dword ptr (-8)[ebp],390\ncmp dword ptr (-4)[ebp],0\nje L2292\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2292:\nL2290:\nmov dword ptr (-24)[ebp],12\nmov byte ptr (-25)[ebp],10\nmovsx edi,byte ptr (-25)[ebp]\nor dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,14\nje L2294\nmov dword ptr (-8)[ebp],391\ncmp dword ptr (-4)[ebp],0\nje L2296\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2296:\nL2294:\nmov dword ptr (-24)[ebp],12\nmov word ptr (-28)[ebp],10\nmovsx edi,word ptr (-28)[ebp]\nor dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,14\nje L2298\nmov dword ptr (-8)[ebp],392\ncmp dword ptr (-4)[ebp],0\nje L2300\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2300:\nL2298:\nmov dword ptr (-24)[ebp],12\nmov dword ptr (-32)[ebp],10\nmov edi,dword ptr (-32)[ebp]\nor dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,14\nje L2302\nmov dword ptr (-8)[ebp],393\ncmp dword ptr (-4)[ebp],0\nje L2304\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2304:\nL2302:\nmov dword ptr (-24)[ebp],12\nmov dword ptr (-36)[ebp],10\nmov edi,dword ptr (-36)[ebp]\nor dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,14\nje L2306\nmov dword ptr (-8)[ebp],394\ncmp dword ptr (-4)[ebp],0\nje L2308\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2308:\nL2306:\nmov dword ptr (-24)[ebp],12\nmov dword ptr (-40)[ebp],10\nmov edi,dword ptr (-40)[ebp]\nor dword ptr (-24)[ebp],edi\nmov edi,dword ptr (-24)[ebp]\ncmp edi,14\nje L2310\nmov dword ptr (-8)[ebp],395\ncmp dword ptr (-4)[ebp],0\nje L2312\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,8\nL2312:\nL2310:\ncmp dword ptr (-8)[ebp],0\nje L2314\nmov dword ptr (-76)[ebp],1\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L2316\npush 1\nlea edi,(L688)\npush edi\ncall _printf\nadd esp,8\nL2316:\nL2314:\nmov eax,dword ptr (-76)[ebp]\nL686:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 1\nL2319 label byte\ndb 115\ndb 55\ndb 49\ndb 53\ndb 44\ndb 101\ndb 114\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL2320 label byte\ndb 115\ndb 55\ndb 49\ndb 53\ndb 32\ndb 32\ndb 32\ndb 0\npublic _s715\n_DATA ends\n_TEXT segment\n_s715:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,28\nmov dword ptr (-28)[ebp],0\nmov dword ptr (-20)[ebp],0\nlea edi,(L2320)\nmov dword ptr (-4)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea edi,(60)[edi]\nmov dword ptr (-8)[ebp],edi\nmov dword ptr (-16)[ebp],0\nL2321:\nL2322:\nmov edi,dword ptr (-8)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-8)[ebp],esi\nmov esi,dword ptr (-4)[ebp]\nlea ebx,(1)[esi]\nmov dword ptr (-4)[ebp],ebx\nmov bl,byte ptr [esi]\nmov byte ptr [edi],bl\nmovsx edi,bl\ncmp edi,0\njne L2321\nmov dword ptr (-12)[ebp],1\ninc dword ptr (-12)[ebp]\ninc dword ptr (-12)[ebp]\ninc dword ptr (-12)[ebp]\ninc dword ptr (-12)[ebp]\nmov edi,dword ptr (-12)[ebp]\nlea edi,(1)[edi]\nmov dword ptr (-12)[ebp],edi\ncmp edi,6\nje L2324\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L2326\npush 1\nlea edi,(L2319)\npush edi\ncall _printf\nadd esp,8\nL2326:\ninc dword ptr (-16)[ebp]\nL2324:\nmov edi,dword ptr (-28)[ebp]\npush edi\nmov dword ptr (-24)[ebp],3\nmov edi,dword ptr (-24)[ebp]\nlea edi,(2)[edi]\npush edi\nmov edi,dword ptr (-20)[ebp]\npush edi\ncall _s715f\nadd esp,12\ncmp eax,5\nje L2328\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L2330\npush 2\nlea edi,(L2319)\npush edi\ncall _printf\nadd esp,8\nL2330:\nadd dword ptr (-16)[ebp],2\nL2328:\nmov eax,dword ptr (-16)[ebp]\nL2318:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _s715f\n_s715f:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov eax,dword ptr (24)[ebp]\nL2332:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 1\nL2334 label byte\ndb 115\ndb 55\ndb 50\ndb 44\ndb 101\ndb 114\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL2335 label byte\ndb 115\ndb 55\ndb 50\ndb 32\ndb 32\ndb 32\ndb 32\ndb 0\npublic _s72\n_DATA ends\n_TEXT segment\n_s72:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,100\nlea edi,(L2335)\nmov dword ptr (-12)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea edi,(60)[edi]\nmov dword ptr (-16)[ebp],edi\nmov dword ptr (-24)[ebp],0\nL2336:\nL2337:\nmov edi,dword ptr (-16)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-16)[ebp],esi\nmov esi,dword ptr (-12)[ebp]\nlea ebx,(1)[esi]\nmov dword ptr (-12)[ebp],ebx\nmov bl,byte ptr [esi]\nmov byte ptr [edi],bl\nmovsx edi,bl\ncmp edi,0\njne L2336\nmov dword ptr (-4)[ebp],2\ncmp dword ptr (-4)[ebp],2\nje L2339\ninc dword ptr (-24)[ebp]\npush 1\nlea edi,(L2334)\npush edi\ncall _printf\nadd esp,8\nL2339:\nmov edi,dword ptr (-4)[ebp]\nmov esi,edi\nneg esi\nlea edi,[esi][edi]\ncmp edi,0\nje L2341\nadd dword ptr (-24)[ebp],2\npush 2\nlea edi,(L2334)\npush edi\ncall _printf\nadd esp,8\nL2341:\nmov dword ptr (-4)[ebp],0\nmov dword ptr (-8)[ebp],0\njmp L2346\nL2343:\nmov edi,dword ptr (-4)[ebp]\nlea edi,[edi*2]\nor edi,1\nmov dword ptr (-4)[ebp],edi\nL2344:\ninc dword ptr (-8)[ebp]\nL2346:\nmov edi,dword ptr (20)[ebp]\nmov edi,dword ptr (4)[edi]\ncmp dword ptr (-8)[ebp],edi\njl L2343\nmov edi,dword ptr (-4)[ebp]\nnot edi\ncmp edi,0\nje L2347\nadd dword ptr (-24)[ebp],4\npush 4\nlea edi,(L2334)\npush edi\ncall _printf\nadd esp,8\nL2347:\nmov dword ptr (-4)[ebp],5\nmov edi,dword ptr (-4)[ebp]\nlea edi,(1)[edi]\nmov dword ptr (-4)[ebp],edi\ncmp edi,6\njne L2354\nmov edi,dword ptr (-4)[ebp]\nsub edi,1\nmov dword ptr (-4)[ebp],edi\ncmp edi,5\njne L2354\nmov edi,dword ptr (-4)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-4)[ebp],esi\ncmp edi,5\njne L2354\nmov edi,dword ptr (-4)[ebp]\nmov esi,edi\nsub esi,1\nmov dword ptr (-4)[ebp],esi\ncmp edi,6\njne L2354\ncmp dword ptr (-4)[ebp],5\nje L2349\nL2354:\nadd dword ptr (-24)[ebp],8\npush 8\nlea edi,(L2334)\npush edi\ncall _printf\nadd esp,8\nL2349:\nmov byte ptr (-29)[ebp],26\nmov dword ptr (-36)[ebp],26\nfld qword ptr (L2355)\nfstp qword ptr (-48)[ebp]\nmov word ptr (-32)[ebp],26\nmov dword ptr (-40)[ebp],26\nmov dword ptr (-28)[ebp],26\nfld dword ptr (L2356)\nfstp dword ptr (-52)[ebp]\nmov dword ptr (-20)[ebp],0\nmovsx edi,word ptr (-32)[ebp]\nmov ebx,edi\nmovsx edi,bl\ncmp edi,26\njne L2363\nmov edi,dword ptr (-28)[ebp]\nmov ebx,edi\nmovsx edi,bl\ncmp edi,26\njne L2363\nmov edi,dword ptr (-36)[ebp]\nmov ebx,edi\nmovsx edi,bl\ncmp edi,26\njne L2363\nmov edi,dword ptr (-40)[ebp]\nmov ebx,edi\nmovsx edi,bl\ncmp edi,26\njne L2363\nfld dword ptr (-52)[ebp]\ncall __ftol\nmov ebx,eax\nmovsx edi,bl\ncmp edi,26\njne L2363\nfld qword ptr (-48)[ebp]\ncall __ftol\nmov ebx,eax\nmovsx edi,bl\ncmp edi,26\nje L2357\nL2363:\ninc dword ptr (-20)[ebp]\nL2357:\nmovsx edi,byte ptr (-29)[ebp]\nmovsx edi,di\ncmp edi,26\njne L2370\nmov edi,dword ptr (-28)[ebp]\nmovsx edi,di\ncmp edi,26\njne L2370\nmov edi,dword ptr (-36)[ebp]\nmovsx edi,di\ncmp edi,26\njne L2370\nmov edi,dword ptr (-40)[ebp]\nmovsx edi,di\ncmp edi,26\njne L2370\nfld dword ptr (-52)[ebp]\ncall __ftol\nmov edi,eax\nmovsx edi,di\ncmp edi,26\njne L2370\nfld qword ptr (-48)[ebp]\ncall __ftol\nmov edi,eax\nmovsx edi,di\ncmp edi,26\nje L2364\nL2370:\nadd dword ptr (-20)[ebp],2\nL2364:\nmovsx edi,byte ptr (-29)[ebp]\ncmp edi,26\njne L2377\nmovsx edi,word ptr (-32)[ebp]\ncmp edi,26\njne L2377\ncmp dword ptr (-36)[ebp],26\njne L2377\nmov edi,dword ptr (-40)[ebp]\ncmp edi,26\njne L2377\nfld dword ptr (-52)[ebp]\ncall __ftol\ncmp eax,26\njne L2377\nfld qword ptr (-48)[ebp]\ncall __ftol\ncmp eax,26\nje L2371\nL2377:\nadd dword ptr (-20)[ebp],4\nL2371:\nmovsx edi,byte ptr (-29)[ebp]\ncmp edi,26\njne L2384\nmovsx edi,word ptr (-32)[ebp]\ncmp edi,26\njne L2384\ncmp dword ptr (-28)[ebp],26\njne L2384\nmov edi,dword ptr (-40)[ebp]\ncmp edi,26\njne L2384\nfld dword ptr (-52)[ebp]\ncall __ftol\ncmp eax,26\njne L2384\nfld qword ptr (-48)[ebp]\ncall __ftol\ncmp eax,26\nje L2378\nL2384:\nadd dword ptr (-20)[ebp],8\nL2378:\nmovsx edi,byte ptr (-29)[ebp]\ncmp edi,26\njne L2393\nmovsx edi,word ptr (-32)[ebp]\ncmp edi,26\njne L2393\nmov edi,dword ptr (-28)[ebp]\ncmp edi,26\njne L2393\nmov edi,dword ptr (-36)[ebp]\ncmp edi,26\njne L2393\nfld dword ptr (L828)\nfcomp dword ptr (-52)[ebp]\nfstsw ax\nsahf\nja L2394\nfld dword ptr (-52)[ebp]\nfsub dword ptr (L828)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-56)[ebp],edi\njmp L2395\nL2394:\nfld dword ptr (-52)[ebp]\ncall __ftol\nmov edi,eax\nmov dword ptr (-56)[ebp],edi\nL2395:\nmov edi,dword ptr (-56)[ebp]\ncmp edi,26\njne L2393\nfld qword ptr (L836)\nfcomp qword ptr (-48)[ebp]\nfstsw ax\nsahf\nja L2396\nfld qword ptr (-48)[ebp]\nfsub qword ptr (L836)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-60)[ebp],edi\njmp L2397\nL2396:\nfld qword ptr (-48)[ebp]\ncall __ftol\nmov edi,eax\nmov dword ptr (-60)[ebp],edi\nL2397:\nmov edi,dword ptr (-60)[ebp]\ncmp edi,26\nje L2385\nL2393:\nadd dword ptr (-20)[ebp],16\nL2385:\nmovsx edi,byte ptr (-29)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfld qword ptr (L2355)\nfcompp\nfstsw ax\nsahf\njne L2404\nmovsx edi,word ptr (-32)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfld qword ptr (L2355)\nfcompp\nfstsw ax\nsahf\njne L2404\nmov edi,dword ptr (-28)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfld qword ptr (L2355)\nfcompp\nfstsw ax\nsahf\njne L2404\nmov edi,dword ptr (-36)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfld qword ptr (L2355)\nfcompp\nfstsw ax\nsahf\njne L2404\nmov edi,dword ptr (-40)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nsub esp,4\nfstp dword ptr 0[esp]\nfld dword ptr 0[esp]\nadd esp,4\nfld qword ptr (L2355)\nfcompp\nfstsw ax\nsahf\njne L2404\nfld qword ptr (-48)[ebp]\nsub esp,4\nfstp dword ptr 0[esp]\nfld dword ptr 0[esp]\nadd esp,4\nfld qword ptr (L2355)\nfcompp\nfstsw ax\nsahf\nje L2398\nL2404:\nadd dword ptr (-20)[ebp],32\nL2398:\nmovsx edi,byte ptr (-29)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfld qword ptr (L2355)\nfcompp\nfstsw ax\nsahf\njne L2411\nmovsx edi,word ptr (-32)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfld qword ptr (L2355)\nfcompp\nfstsw ax\nsahf\njne L2411\nfild dword ptr (-28)[ebp]\nfld qword ptr (L2355)\nfcompp\nfstsw ax\nsahf\njne L2411\nfild dword ptr (-36)[ebp]\nfld qword ptr (L2355)\nfcompp\nfstsw ax\nsahf\njne L2411\nmov edi,dword ptr (-40)[ebp]\nfld qword ptr (L596)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nfld qword ptr (L2355)\nfcompp\nfstsw ax\nsahf\njne L2411\nfld qword ptr (L2355)\nfcomp dword ptr (-52)[ebp]\nfstsw ax\nsahf\nje L2405\nL2411:\nadd dword ptr (-20)[ebp],64\nL2405:\ncmp dword ptr (-20)[ebp],0\nje L2412\nadd dword ptr (-24)[ebp],16\npush 16\nlea edi,(L2334)\npush edi\ncall _printf\nadd esp,8\nL2412:\nmov eax,dword ptr (-24)[ebp]\nL2333:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 1\nL2415 label byte\ndb 115\ndb 55\ndb 53\ndb 55\ndb 44\ndb 101\ndb 114\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL2416 label byte\ndb 115\ndb 55\ndb 53\ndb 55\ndb 32\ndb 32\ndb 32\ndb 0\npublic _s757\n_DATA ends\n_TEXT segment\n_s757:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,148\nlea edi,(L2416)\nmov dword ptr (-112)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea edi,(60)[edi]\nmov dword ptr (-116)[ebp],edi\nmov dword ptr (-120)[ebp],0\nL2417:\nL2418:\nmov edi,dword ptr (-116)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-116)[ebp],esi\nmov esi,dword ptr (-112)[ebp]\nlea ebx,(1)[esi]\nmov dword ptr (-112)[ebp],ebx\nmov bl,byte ptr [esi]\nmov byte ptr [edi],bl\nmovsx edi,bl\ncmp edi,0\njne L2417\nmov dword ptr (-124)[ebp],40\nmov edi,dword ptr (-124)[ebp]\nlea esi,[edi*8]\nlea esi,[esi*4]\ncmp esi,1280\njne L2422\nsar edi,3\nsar edi,2\ncmp edi,1\nje L2420\nL2422:\ninc dword ptr (-120)[ebp]\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L2423\npush 1\nlea edi,(L2415)\npush edi\ncall _printf\nadd esp,8\nL2423:\nL2420:\nmov dword ptr (-84)[ebp],0\nmov dword ptr (-100)[ebp],0\njmp L2428\nL2425:\nmov dword ptr (-92)[ebp],1\nmov edi,dword ptr (-92)[ebp]\nmov esi,dword ptr (20)[ebp]\nmov esi,dword ptr (16)[esi]\nsub esi,1\nmov ecx,esi\nshl edi,cl\nmov dword ptr (-96)[ebp],edi\nmov dword ptr (-104)[ebp],0\nmov edi,dword ptr (-104)[ebp]\nnot edi\nmov esi,dword ptr (-100)[ebp]\nmov ebx,edi\nmov ecx,esi\nshr ebx,cl\nmov dword ptr (-108)[ebp],ebx\nmov ecx,esi\nshl edi,cl\nmov dword ptr (-104)[ebp],edi\nmov dword ptr (-88)[ebp],0\njmp L2432\nL2429:\nmov edi,dword ptr (-100)[ebp]\ncmp dword ptr (-88)[ebp],edi\njge L2440\nmov dword ptr (-132)[ebp],1\njmp L2441\nL2440:\nmov dword ptr (-132)[ebp],0\nL2441:\nmov edi,dword ptr (-92)[ebp]\nand edi,dword ptr (-104)[ebp]\ncmp edi,0\njne L2442\nmov dword ptr (-136)[ebp],1\njmp L2443\nL2442:\nmov dword ptr (-136)[ebp],0\nL2443:\nmov edi,dword ptr (-136)[ebp]\ncmp dword ptr (-132)[ebp],edi\njne L2439\nmov edi,dword ptr (-100)[ebp]\ncmp dword ptr (-88)[ebp],edi\njge L2444\nmov dword ptr (-140)[ebp],1\njmp L2445\nL2444:\nmov dword ptr (-140)[ebp],0\nL2445:\nmov edi,dword ptr (-96)[ebp]\nand edi,dword ptr (-108)[ebp]\ncmp edi,0\njne L2446\nmov dword ptr (-144)[ebp],1\njmp L2447\nL2446:\nmov dword ptr (-144)[ebp],0\nL2447:\nmov edi,dword ptr (-144)[ebp]\ncmp dword ptr (-140)[ebp],edi\nje L2433\nL2439:\nmov dword ptr (-84)[ebp],1\nL2433:\nmov edi,dword ptr (-92)[ebp]\nlea edi,[edi*2]\nmov dword ptr (-92)[ebp],edi\nmov edi,dword ptr (-96)[ebp]\nshr edi,1\nmov dword ptr (-96)[ebp],edi\nL2430:\ninc dword ptr (-88)[ebp]\nL2432:\nmov edi,dword ptr (20)[ebp]\nmov edi,dword ptr (16)[edi]\ncmp dword ptr (-88)[ebp],edi\njl L2429\nL2426:\ninc dword ptr (-100)[ebp]\nL2428:\nmov edi,dword ptr (20)[ebp]\nmov edi,dword ptr (16)[edi]\ncmp dword ptr (-100)[ebp],edi\njl L2425\ncmp dword ptr (-84)[ebp],0\nje L2448\nadd dword ptr (-120)[ebp],2\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L2450\npush 2\nlea edi,(L2415)\npush edi\ncall _printf\nadd esp,8\nL2450:\nL2448:\nmov dword ptr (-16)[ebp],3\nmov dword ptr (-12)[ebp],2\nmov dword ptr (-8)[ebp],1\nmov edi,dword ptr (-12)[ebp]\ncmp dword ptr (-16)[ebp],edi\njge L2458\nmov dword ptr (-136)[ebp],1\njmp L2459\nL2458:\nmov dword ptr (-136)[ebp],0\nL2459:\nmov edi,dword ptr (-8)[ebp]\ncmp dword ptr (-136)[ebp],edi\njge L2456\nmov dword ptr (-132)[ebp],1\njmp L2457\nL2456:\nmov dword ptr (-132)[ebp],0\nL2457:\ncmp dword ptr (-132)[ebp],1\nje L2452\nadd dword ptr (-120)[ebp],4\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L2460\npush 4\nlea edi,(L2415)\npush edi\ncall _printf\nadd esp,8\nL2460:\nL2452:\nlea edi,(-76)[ebp]\nlea esi,(-80)[ebp]\ncmp edi,esi\njne L2462\nadd dword ptr (-120)[ebp],8\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L2465\npush 8\nlea edi,(L2415)\npush edi\ncall _printf\nadd esp,8\nL2465:\nL2462:\nlea edi,(-76)[ebp]\nlea esi,(-80)[ebp]\ncmp edi,esi\njae L2467\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (40)[edi],0\nje L2470\nlea edi,(L2472)\npush edi\ncall _printf\nadd esp,4\nL2470:\nL2467:\nmov dword ptr (-84)[ebp],0\nmov dword ptr (-88)[ebp],0\nL2473:\nmov edi,dword ptr (-88)[ebp]\nmov dword ptr (-80)[ebp][edi*4],1\nL2474:\ninc dword ptr (-88)[ebp]\ncmp dword ptr (-88)[ebp],16\njl L2473\nmov dword ptr (-76)[ebp],0\nmov dword ptr (-64)[ebp],0\nmov dword ptr (-56)[ebp],0\nmov dword ptr (-52)[ebp],0\nmov dword ptr (-44)[ebp],0\nmov dword ptr (-28)[ebp],0\nmov dword ptr (-16)[ebp],0\nL2483:\nmov dword ptr (-12)[ebp],0\nL2487:\nmov dword ptr (-8)[ebp],0\nL2491:\nmov dword ptr (-4)[ebp],0\nL2495:\nmov edi,dword ptr (-12)[ebp]\ncmp dword ptr (-16)[ebp],edi\njge L2506\nmov dword ptr (-144)[ebp],1\njmp L2507\nL2506:\nmov dword ptr (-144)[ebp],0\nL2507:\nmov edi,dword ptr (-4)[ebp]\ncmp dword ptr (-8)[ebp],edi\njge L2508\nmov dword ptr (-148)[ebp],1\njmp L2509\nL2508:\nmov dword ptr (-148)[ebp],0\nL2509:\nmov edi,dword ptr (-148)[ebp]\ncmp dword ptr (-144)[ebp],edi\njne L2504\nmov dword ptr (-140)[ebp],1\njmp L2505\nL2504:\nmov dword ptr (-140)[ebp],0\nL2505:\nmov edi,dword ptr (-16)[ebp]\nmov esi,dword ptr (-12)[ebp]\nlea esi,[esi*4]\nlea edi,[esi][edi*8]\nmov esi,dword ptr (-8)[ebp]\nlea esi,[esi*2]\nlea edi,[esi][edi]\nmov esi,dword ptr (-4)[ebp]\nlea edi,[esi][edi]\nmov edi,dword ptr (-80)[ebp][edi*4]\ncmp dword ptr (-140)[ebp],edi\nje L2499\nmov dword ptr (-84)[ebp],1\nL2499:\nL2496:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],2\njl L2495\nL2492:\ninc dword ptr (-8)[ebp]\ncmp dword ptr (-8)[ebp],2\njl L2491\nL2488:\ninc dword ptr (-12)[ebp]\ncmp dword ptr (-12)[ebp],2\njl L2487\nL2484:\ninc dword ptr (-16)[ebp]\ncmp dword ptr (-16)[ebp],2\njl L2483\ncmp dword ptr (-84)[ebp],0\nje L2510\nadd dword ptr (-120)[ebp],16\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L2512\npush 16\nlea edi,(L2415)\npush edi\ncall _printf\nadd esp,8\nL2512:\nL2510:\nmov dword ptr (-128)[ebp],0\nmov edi,dword ptr (-128)[ebp]\ncmp edi,0\nje L2514\nadd dword ptr (-120)[ebp],32\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L2516\npush 32\nlea edi,(L2415)\npush edi\ncall _printf\nadd esp,8\nL2516:\nL2514:\nmov eax,dword ptr (-120)[ebp]\nL2414:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 1\nL2519 label byte\ndb 76\ndb 111\ndb 99\ndb 97\ndb 108\ndb 32\ndb 101\ndb 114\ndb 114\ndb 111\ndb 114\ndb 32\ndb 37\ndb 100\ndb 46\ndb 10\ndb 0\nalign 1\nL2520 label byte\ndb 115\ndb 55\ndb 56\ndb 49\ndb 51\ndb 44\ndb 101\ndb 114\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL2521 label byte\ndb 115\ndb 55\ndb 56\ndb 49\ndb 51\ndb 32\ndb 32\ndb 0\npublic _s7813\n_DATA ends\n_TEXT segment\n_s7813:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,88\nlea edi,(L2521)\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea esi,(60)[edi]\nmov dword ptr (-28)[ebp],esi\nmov dword ptr (-8)[ebp],0\nmov dword ptr (-32)[ebp],0\nmov edi,dword ptr (48)[edi]\nmov dword ptr (-4)[ebp],edi\nL2522:\nL2523:\nmov edi,dword ptr (-28)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-28)[ebp],esi\nmov esi,dword ptr (-24)[ebp]\nlea ebx,(1)[esi]\nmov dword ptr (-24)[ebp],ebx\nmov bl,byte ptr [esi]\nmov byte ptr [edi],bl\nmovsx edi,bl\ncmp edi,0\njne L2522\njmp L2525\nmov dword ptr (-8)[ebp],1\ncmp dword ptr (-4)[ebp],0\nje L2527\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2527:\nL2525:\njmp L2529\nmov dword ptr (-8)[ebp],2\ncmp dword ptr (-4)[ebp],0\nje L2531\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2531:\nL2529:\njmp L2533\nmov dword ptr (-8)[ebp],3\ncmp dword ptr (-4)[ebp],0\nje L2535\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2535:\nL2533:\njmp L2537\nmov dword ptr (-8)[ebp],4\ncmp dword ptr (-4)[ebp],0\nje L2539\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2539:\nL2537:\njmp L2541\nmov dword ptr (-8)[ebp],5\ncmp dword ptr (-4)[ebp],0\nje L2543\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2543:\nL2541:\njmp L2545\nmov dword ptr (-8)[ebp],6\ncmp dword ptr (-4)[ebp],0\nje L2547\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2547:\nL2545:\njmp L2549\nmov dword ptr (-8)[ebp],7\ncmp dword ptr (-4)[ebp],0\nje L2551\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2551:\nL2549:\njmp L2553\nmov dword ptr (-8)[ebp],8\ncmp dword ptr (-4)[ebp],0\nje L2555\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2555:\nL2553:\njmp L2557\nmov dword ptr (-8)[ebp],9\ncmp dword ptr (-4)[ebp],0\nje L2559\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2559:\nL2557:\njmp L2561\nmov dword ptr (-8)[ebp],10\ncmp dword ptr (-4)[ebp],0\nje L2563\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2563:\nL2561:\njmp L2565\nmov dword ptr (-8)[ebp],11\ncmp dword ptr (-4)[ebp],0\nje L2567\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2567:\nL2565:\njmp L2569\nmov dword ptr (-8)[ebp],12\ncmp dword ptr (-4)[ebp],0\nje L2571\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2571:\nL2569:\njmp L2573\nmov dword ptr (-8)[ebp],13\ncmp dword ptr (-4)[ebp],0\nje L2575\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2575:\nL2573:\njmp L2577\nmov dword ptr (-8)[ebp],14\ncmp dword ptr (-4)[ebp],0\nje L2579\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2579:\nL2577:\njmp L2581\nmov dword ptr (-8)[ebp],15\ncmp dword ptr (-4)[ebp],0\nje L2583\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2583:\nL2581:\njmp L2585\nmov dword ptr (-8)[ebp],16\ncmp dword ptr (-4)[ebp],0\nje L2587\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2587:\nL2585:\njmp L2589\nmov dword ptr (-8)[ebp],17\ncmp dword ptr (-4)[ebp],0\nje L2591\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2591:\nL2589:\njmp L2593\nmov dword ptr (-8)[ebp],18\ncmp dword ptr (-4)[ebp],0\nje L2595\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2595:\nL2593:\njmp L2597\nmov dword ptr (-8)[ebp],16\ncmp dword ptr (-4)[ebp],0\nje L2599\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2599:\nL2597:\njmp L2601\nmov dword ptr (-8)[ebp],20\ncmp dword ptr (-4)[ebp],0\nje L2603\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2603:\nL2601:\njmp L2605\nmov dword ptr (-8)[ebp],21\ncmp dword ptr (-4)[ebp],0\nje L2607\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2607:\nL2605:\njmp L2609\nmov dword ptr (-8)[ebp],22\ncmp dword ptr (-4)[ebp],0\nje L2611\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2611:\nL2609:\njmp L2613\nmov dword ptr (-8)[ebp],23\ncmp dword ptr (-4)[ebp],0\nje L2615\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2615:\nL2613:\njmp L2617\nmov dword ptr (-8)[ebp],24\ncmp dword ptr (-4)[ebp],0\nje L2619\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2619:\nL2617:\njmp L2621\nmov dword ptr (-8)[ebp],25\ncmp dword ptr (-4)[ebp],0\nje L2623\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2623:\nL2621:\njmp L2625\nmov dword ptr (-8)[ebp],26\ncmp dword ptr (-4)[ebp],0\nje L2627\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2627:\nL2625:\njmp L2629\nmov dword ptr (-8)[ebp],27\ncmp dword ptr (-4)[ebp],0\nje L2631\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2631:\nL2629:\njmp L2633\nmov dword ptr (-8)[ebp],28\ncmp dword ptr (-4)[ebp],0\nje L2635\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2635:\nL2633:\njmp L2637\nmov dword ptr (-8)[ebp],26\ncmp dword ptr (-4)[ebp],0\nje L2639\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2639:\nL2637:\njmp L2641\nmov dword ptr (-8)[ebp],30\ncmp dword ptr (-4)[ebp],0\nje L2643\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2643:\nL2641:\njmp L2645\nmov dword ptr (-8)[ebp],31\ncmp dword ptr (-4)[ebp],0\nje L2647\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2647:\nL2645:\njmp L2649\nmov dword ptr (-8)[ebp],32\ncmp dword ptr (-4)[ebp],0\nje L2651\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2651:\nL2649:\njmp L2653\nmov dword ptr (-8)[ebp],33\ncmp dword ptr (-4)[ebp],0\nje L2655\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2655:\nL2653:\njmp L2657\nmov dword ptr (-8)[ebp],34\ncmp dword ptr (-4)[ebp],0\nje L2659\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2659:\nL2657:\njmp L2661\nmov dword ptr (-8)[ebp],35\ncmp dword ptr (-4)[ebp],0\nje L2663\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2663:\nL2661:\njmp L2665\nmov dword ptr (-8)[ebp],36\ncmp dword ptr (-4)[ebp],0\nje L2667\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2667:\nL2665:\njmp L2669\nmov dword ptr (-8)[ebp],37\ncmp dword ptr (-4)[ebp],0\nje L2671\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2671:\nL2669:\njmp L2673\nmov dword ptr (-8)[ebp],38\ncmp dword ptr (-4)[ebp],0\nje L2675\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2675:\nL2673:\njmp L2677\nmov dword ptr (-8)[ebp],39\ncmp dword ptr (-4)[ebp],0\nje L2679\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2679:\nL2677:\njmp L2681\nmov dword ptr (-8)[ebp],40\ncmp dword ptr (-4)[ebp],0\nje L2683\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2683:\nL2681:\njmp L2685\nmov dword ptr (-8)[ebp],41\ncmp dword ptr (-4)[ebp],0\nje L2687\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2687:\nL2685:\njmp L2689\nmov dword ptr (-8)[ebp],42\ncmp dword ptr (-4)[ebp],0\nje L2691\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2691:\nL2689:\njmp L2693\nmov dword ptr (-8)[ebp],43\ncmp dword ptr (-4)[ebp],0\nje L2695\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2695:\nL2693:\njmp L2697\nmov dword ptr (-8)[ebp],44\ncmp dword ptr (-4)[ebp],0\nje L2699\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2699:\nL2697:\njmp L2701\nmov dword ptr (-8)[ebp],45\ncmp dword ptr (-4)[ebp],0\nje L2703\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2703:\nL2701:\njmp L2705\nmov dword ptr (-8)[ebp],46\ncmp dword ptr (-4)[ebp],0\nje L2707\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2707:\nL2705:\njmp L2709\nmov dword ptr (-8)[ebp],47\ncmp dword ptr (-4)[ebp],0\nje L2711\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2711:\nL2709:\njmp L2713\nmov dword ptr (-8)[ebp],48\ncmp dword ptr (-4)[ebp],0\nje L2715\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2715:\nL2713:\njmp L2717\nmov dword ptr (-8)[ebp],49\ncmp dword ptr (-4)[ebp],0\nje L2719\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2719:\nL2717:\njmp L2721\nmov dword ptr (-8)[ebp],50\ncmp dword ptr (-4)[ebp],0\nje L2723\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2723:\nL2721:\njmp L2725\nmov dword ptr (-8)[ebp],51\ncmp dword ptr (-4)[ebp],0\nje L2727\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2727:\nL2725:\njmp L2729\nmov dword ptr (-8)[ebp],52\ncmp dword ptr (-4)[ebp],0\nje L2731\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2731:\nL2729:\njmp L2733\nmov dword ptr (-8)[ebp],53\ncmp dword ptr (-4)[ebp],0\nje L2735\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2735:\nL2733:\njmp L2737\nmov dword ptr (-8)[ebp],54\ncmp dword ptr (-4)[ebp],0\nje L2739\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2739:\nL2737:\njmp L2741\nmov dword ptr (-8)[ebp],55\ncmp dword ptr (-4)[ebp],0\nje L2743\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2743:\nL2741:\njmp L2745\nmov dword ptr (-8)[ebp],56\ncmp dword ptr (-4)[ebp],0\nje L2747\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2747:\nL2745:\njmp L2749\nmov dword ptr (-8)[ebp],57\ncmp dword ptr (-4)[ebp],0\nje L2751\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2751:\nL2749:\njmp L2753\nmov dword ptr (-8)[ebp],58\ncmp dword ptr (-4)[ebp],0\nje L2755\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2755:\nL2753:\njmp L2757\nmov dword ptr (-8)[ebp],56\ncmp dword ptr (-4)[ebp],0\nje L2759\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2759:\nL2757:\njmp L2761\nmov dword ptr (-8)[ebp],60\ncmp dword ptr (-4)[ebp],0\nje L2763\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2763:\nL2761:\njmp L2765\nmov dword ptr (-8)[ebp],61\ncmp dword ptr (-4)[ebp],0\nje L2767\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2767:\nL2765:\njmp L2769\nmov dword ptr (-8)[ebp],62\ncmp dword ptr (-4)[ebp],0\nje L2771\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2771:\nL2769:\njmp L2773\nmov dword ptr (-8)[ebp],63\ncmp dword ptr (-4)[ebp],0\nje L2775\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2775:\nL2773:\njmp L2777\nmov dword ptr (-8)[ebp],64\ncmp dword ptr (-4)[ebp],0\nje L2779\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2779:\nL2777:\njmp L2781\nmov dword ptr (-8)[ebp],65\ncmp dword ptr (-4)[ebp],0\nje L2783\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2783:\nL2781:\njmp L2785\nmov dword ptr (-8)[ebp],66\ncmp dword ptr (-4)[ebp],0\nje L2787\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2787:\nL2785:\njmp L2789\nmov dword ptr (-8)[ebp],67\ncmp dword ptr (-4)[ebp],0\nje L2791\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2791:\nL2789:\njmp L2793\nmov dword ptr (-8)[ebp],68\ncmp dword ptr (-4)[ebp],0\nje L2795\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2795:\nL2793:\njmp L2797\nmov dword ptr (-8)[ebp],69\ncmp dword ptr (-4)[ebp],0\nje L2799\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2799:\nL2797:\njmp L2801\nmov dword ptr (-8)[ebp],70\ncmp dword ptr (-4)[ebp],0\nje L2803\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2803:\nL2801:\njmp L2805\nmov dword ptr (-8)[ebp],71\ncmp dword ptr (-4)[ebp],0\nje L2807\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2807:\nL2805:\njmp L2809\nmov dword ptr (-8)[ebp],72\ncmp dword ptr (-4)[ebp],0\nje L2811\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2811:\nL2809:\njmp L2813\nmov dword ptr (-8)[ebp],73\ncmp dword ptr (-4)[ebp],0\nje L2815\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2815:\nL2813:\njmp L2817\nmov dword ptr (-8)[ebp],74\ncmp dword ptr (-4)[ebp],0\nje L2819\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2819:\nL2817:\njmp L2821\nmov dword ptr (-8)[ebp],75\ncmp dword ptr (-4)[ebp],0\nje L2823\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2823:\nL2821:\ncmp dword ptr (-8)[ebp],0\nje L2825\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L2827\npush 1\nlea edi,(L2520)\npush edi\ncall _printf\nadd esp,8\nL2827:\ninc dword ptr (-32)[ebp]\nL2825:\nmov dword ptr (-8)[ebp],0\nmov dword ptr (-16)[ebp],0\nmov dword ptr (-12)[ebp],0\nmov edi,dword ptr (-12)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-12)[ebp],esi\ncmp edi,0\nje L2830\nmov edi,dword ptr (-16)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-16)[ebp],esi\ncmp edi,0\nje L2830\nmov dword ptr (-44)[ebp],1\njmp L2831\nL2830:\nmov dword ptr (-44)[ebp],0\nL2831:\nmov edi,dword ptr (-44)[ebp]\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-12)[ebp],1\nje L2832\nmov dword ptr (-8)[ebp],1\ncmp dword ptr (-4)[ebp],0\nje L2834\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2834:\nL2832:\ncmp dword ptr (-16)[ebp],0\nje L2836\nmov dword ptr (-8)[ebp],2\ncmp dword ptr (-4)[ebp],0\nje L2838\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2838:\nL2836:\ncmp dword ptr (-20)[ebp],0\nje L2840\nmov dword ptr (-8)[ebp],3\ncmp dword ptr (-4)[ebp],0\nje L2842\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2842:\nL2840:\ncmp dword ptr (-12)[ebp],0\nje L2845\nmov edi,dword ptr (-16)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-16)[ebp],esi\ncmp edi,0\nje L2845\nmov dword ptr (-48)[ebp],1\njmp L2846\nL2845:\nmov dword ptr (-48)[ebp],0\nL2846:\nmov edi,dword ptr (-48)[ebp]\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-12)[ebp],1\nje L2847\nmov dword ptr (-8)[ebp],4\ncmp dword ptr (-4)[ebp],0\nje L2849\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2849:\nL2847:\ncmp dword ptr (-16)[ebp],1\nje L2851\nmov dword ptr (-8)[ebp],5\ncmp dword ptr (-4)[ebp],0\nje L2853\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2853:\nL2851:\ncmp dword ptr (-20)[ebp],0\nje L2855\nmov dword ptr (-8)[ebp],6\ncmp dword ptr (-4)[ebp],0\nje L2857\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2857:\nL2855:\nmov edi,dword ptr (-12)[ebp]\nmov esi,edi\nsub esi,1\nmov dword ptr (-12)[ebp],esi\ncmp edi,0\nje L2860\ncmp dword ptr (-16)[ebp],0\nje L2860\nmov dword ptr (-52)[ebp],1\njmp L2861\nL2860:\nmov dword ptr (-52)[ebp],0\nL2861:\nmov edi,dword ptr (-52)[ebp]\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-12)[ebp],0\nje L2862\nmov dword ptr (-8)[ebp],7\ncmp dword ptr (-4)[ebp],0\nje L2864\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2864:\nL2862:\ncmp dword ptr (-16)[ebp],1\nje L2866\nmov dword ptr (-8)[ebp],8\ncmp dword ptr (-4)[ebp],0\nje L2868\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2868:\nL2866:\ncmp dword ptr (-20)[ebp],1\nje L2870\nmov dword ptr (-8)[ebp],9\ncmp dword ptr (-4)[ebp],0\nje L2872\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2872:\nL2870:\ncmp dword ptr (-12)[ebp],0\nje L2875\nmov edi,dword ptr (-16)[ebp]\nmov esi,edi\nsub esi,1\nmov dword ptr (-16)[ebp],esi\ncmp edi,0\nje L2875\nmov dword ptr (-56)[ebp],1\njmp L2876\nL2875:\nmov dword ptr (-56)[ebp],0\nL2876:\nmov edi,dword ptr (-56)[ebp]\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-12)[ebp],0\nje L2877\nmov dword ptr (-8)[ebp],10\ncmp dword ptr (-4)[ebp],0\nje L2879\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2879:\nL2877:\ncmp dword ptr (-16)[ebp],1\nje L2881\nmov dword ptr (-8)[ebp],11\ncmp dword ptr (-4)[ebp],0\nje L2883\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2883:\nL2881:\ncmp dword ptr (-20)[ebp],0\nje L2885\nmov dword ptr (-8)[ebp],12\ncmp dword ptr (-4)[ebp],0\nje L2887\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2887:\nL2885:\ncmp dword ptr (-8)[ebp],0\nje L2889\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L2891\npush 2\nlea edi,(L2520)\npush edi\ncall _printf\nadd esp,8\nL2891:\nadd dword ptr (-32)[ebp],2\nL2889:\nmov dword ptr (-8)[ebp],0\nmov dword ptr (-16)[ebp],0\nmov dword ptr (-12)[ebp],0\nmov edi,dword ptr (-12)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-12)[ebp],esi\ncmp edi,0\njne L2896\ncmp dword ptr (-16)[ebp],0\nje L2894\nL2896:\nmov dword ptr (-60)[ebp],1\njmp L2895\nL2894:\nmov dword ptr (-60)[ebp],0\nL2895:\nmov edi,dword ptr (-60)[ebp]\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-12)[ebp],1\nje L2897\nmov dword ptr (-8)[ebp],1\ncmp dword ptr (-4)[ebp],0\nje L2899\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2899:\nL2897:\ncmp dword ptr (-16)[ebp],0\nje L2901\nmov dword ptr (-8)[ebp],2\ncmp dword ptr (-4)[ebp],0\nje L2903\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2903:\nL2901:\ncmp dword ptr (-20)[ebp],0\nje L2905\nmov dword ptr (-8)[ebp],3\ncmp dword ptr (-4)[ebp],0\nje L2907\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2907:\nL2905:\nmov edi,dword ptr (-16)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-16)[ebp],esi\ncmp edi,0\njne L2912\ncmp dword ptr (-12)[ebp],0\nje L2910\nL2912:\nmov dword ptr (-64)[ebp],1\njmp L2911\nL2910:\nmov dword ptr (-64)[ebp],0\nL2911:\nmov edi,dword ptr (-64)[ebp]\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-12)[ebp],1\nje L2913\nmov dword ptr (-8)[ebp],4\ncmp dword ptr (-4)[ebp],0\nje L2915\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2915:\nL2913:\ncmp dword ptr (-16)[ebp],1\nje L2917\nmov dword ptr (-8)[ebp],5\ncmp dword ptr (-4)[ebp],0\nje L2919\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2919:\nL2917:\ncmp dword ptr (-20)[ebp],1\nje L2921\nmov dword ptr (-8)[ebp],6\ncmp dword ptr (-4)[ebp],0\nje L2923\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2923:\nL2921:\nmov edi,dword ptr (-12)[ebp]\nmov esi,edi\nsub esi,1\nmov dword ptr (-12)[ebp],esi\ncmp edi,0\njne L2928\nmov edi,dword ptr (-16)[ebp]\nmov esi,edi\nsub esi,1\nmov dword ptr (-16)[ebp],esi\ncmp edi,0\nje L2926\nL2928:\nmov dword ptr (-68)[ebp],1\njmp L2927\nL2926:\nmov dword ptr (-68)[ebp],0\nL2927:\nmov edi,dword ptr (-68)[ebp]\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-12)[ebp],0\nje L2929\nmov dword ptr (-8)[ebp],7\ncmp dword ptr (-4)[ebp],0\nje L2931\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2931:\nL2929:\ncmp dword ptr (-16)[ebp],1\nje L2933\nmov dword ptr (-8)[ebp],8\ncmp dword ptr (-4)[ebp],0\nje L2935\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2935:\nL2933:\ncmp dword ptr (-20)[ebp],1\nje L2937\nmov dword ptr (-8)[ebp],9\ncmp dword ptr (-4)[ebp],0\nje L2939\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2939:\nL2937:\ncmp dword ptr (-12)[ebp],0\njne L2944\nmov edi,dword ptr (-16)[ebp]\nmov esi,edi\nsub esi,1\nmov dword ptr (-16)[ebp],esi\ncmp edi,0\nje L2942\nL2944:\nmov dword ptr (-72)[ebp],1\njmp L2943\nL2942:\nmov dword ptr (-72)[ebp],0\nL2943:\nmov edi,dword ptr (-72)[ebp]\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-12)[ebp],0\nje L2945\nmov dword ptr (-8)[ebp],10\ncmp dword ptr (-4)[ebp],0\nje L2947\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2947:\nL2945:\ncmp dword ptr (-16)[ebp],0\nje L2949\nmov dword ptr (-8)[ebp],11\ncmp dword ptr (-4)[ebp],0\nje L2951\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2951:\nL2949:\ncmp dword ptr (-20)[ebp],1\nje L2953\nmov dword ptr (-8)[ebp],12\ncmp dword ptr (-4)[ebp],0\nje L2955\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L2519)\npush edi\ncall _printf\nadd esp,8\nL2955:\nL2953:\ncmp dword ptr (-8)[ebp],0\nje L2957\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L2959\npush 4\nlea edi,(L2520)\npush edi\ncall _printf\nadd esp,8\nL2959:\nadd dword ptr (-32)[ebp],4\nL2957:\nmov dword ptr (-16)[ebp],0\nmov dword ptr (-12)[ebp],0\nmov dword ptr (-36)[ebp],0\nmov dword ptr (-40)[ebp],1\ncmp dword ptr (-40)[ebp],0\nje L2963\nmov edi,dword ptr (-36)[ebp]\nmov dword ptr (-76)[ebp],edi\njmp L2964\nL2963:\ncmp dword ptr (-40)[ebp],0\nje L2965\nmov edi,dword ptr (-12)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-12)[ebp],esi\nmov dword ptr (-80)[ebp],edi\njmp L2966\nL2965:\nmov edi,dword ptr (-16)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-16)[ebp],esi\nmov dword ptr (-80)[ebp],edi\nL2966:\nmov edi,dword ptr (-80)[ebp]\nmov dword ptr (-76)[ebp],edi\nL2964:\nmov edi,dword ptr (-76)[ebp]\nmov dword ptr (-20)[ebp],edi\ncmp dword ptr (-20)[ebp],0\njne L2970\ncmp dword ptr (-12)[ebp],0\njne L2970\ncmp dword ptr (-16)[ebp],0\nje L2967\nL2970:\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L2971\npush 8\nlea edi,(L2520)\npush edi\ncall _printf\nadd esp,8\nL2971:\nadd dword ptr (-32)[ebp],8\nL2967:\ncmp dword ptr (-40)[ebp],0\nje L2978\nmov edi,dword ptr (-36)[ebp]\nmov dword ptr (-84)[ebp],edi\njmp L2979\nL2978:\nmov dword ptr (-84)[ebp],1\nL2979:\ncmp dword ptr (-84)[ebp],0\njne L2977\ncmp dword ptr (-36)[ebp],0\nje L2980\nmov dword ptr (-88)[ebp],1\njmp L2981\nL2980:\nmov edi,dword ptr (-36)[ebp]\nmov dword ptr (-88)[ebp],edi\nL2981:\ncmp dword ptr (-88)[ebp],0\nje L2973\nL2977:\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L2982\npush 16\nlea edi,(L2520)\npush edi\ncall _printf\nadd esp,8\nL2982:\nadd dword ptr (-32)[ebp],16\nL2973:\nmov eax,dword ptr (-32)[ebp]\nL2518:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 1\nL2985 label byte\ndb 115\ndb 56\ndb 49\ndb 44\ndb 101\ndb 114\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL2986 label byte\ndb 115\ndb 56\ndb 49\ndb 32\ndb 32\ndb 32\ndb 32\ndb 0\nalign 1\nL2987 label byte\ndb 82\ndb 101\ndb 103\ndb 105\ndb 115\ndb 116\ndb 101\ndb 114\ndb 32\ndb 99\ndb 111\ndb 117\ndb 110\ndb 116\ndb 32\ndb 102\ndb 111\ndb 114\ndb 32\ndb 37\ndb 115\ndb 32\ndb 105\ndb 115\ndb 32\ndb 117\ndb 110\ndb 114\ndb 101\ndb 108\ndb 105\ndb 97\ndb 98\ndb 108\ndb 101\ndb 46\ndb 10\ndb 0\nalign 1\nL2988 label byte\ndb 37\ndb 100\ndb 32\ndb 114\ndb 101\ndb 103\ndb 105\ndb 115\ndb 116\ndb 101\ndb 114\ndb 115\ndb 32\ndb 97\ndb 115\ndb 115\ndb 105\ndb 103\ndb 110\ndb 101\ndb 100\ndb 32\ndb 116\ndb 111\ndb 32\ndb 37\ndb 115\ndb 32\ndb 118\ndb 97\ndb 114\ndb 105\ndb 97\ndb 98\ndb 108\ndb 101\ndb 115\ndb 46\ndb 10\ndb 0\npublic _s81\n_DATA ends\n_TEXT segment\n_s81:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,56\nmov dword ptr (-56)[ebp],0\nmov dword ptr (-44)[ebp],0\nmov dword ptr (-48)[ebp],0\nmov dword ptr (-52)[ebp],0\nlea edi,(L2986)\nmov dword ptr (-36)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea edi,(60)[edi]\nmov dword ptr (-40)[ebp],edi\nL2989:\nL2990:\nmov edi,dword ptr (-40)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-40)[ebp],esi\nmov esi,dword ptr (-36)[ebp]\nlea ebx,(1)[esi]\nmov dword ptr (-36)[ebp],ebx\nmov bl,byte ptr [esi]\nmov byte ptr [edi],bl\nmovsx edi,bl\ncmp edi,0\njne L2989\nmov dword ptr (-16)[ebp],1\nmov dword ptr (-20)[ebp],0\nL2992:\nmov edi,dword ptr (-16)[ebp]\nmov ebx,edi\nmov byte ptr (-1)[ebp],bl\nmov byte ptr (-21)[ebp],bl\nlea esi,(-16)[ebp]\nmov dword ptr (-8)[ebp],esi\nlea esi,(-16)[ebp]\nmov dword ptr (-28)[ebp],esi\nmov dword ptr (-12)[ebp],edi\nmov dword ptr (-32)[ebp],edi\nmovsx edi,byte ptr (-1)[ebp]\nmovsx esi,byte ptr (-21)[ebp]\ncmp edi,esi\nje L2996\nmov dword ptr (-44)[ebp],1\nL2996:\nmov edi,dword ptr (-8)[ebp]\nmov esi,dword ptr (-28)[ebp]\ncmp edi,esi\nje L2998\nmov dword ptr (-48)[ebp],1\nL2998:\nmov edi,dword ptr (-32)[ebp]\ncmp dword ptr (-12)[ebp],edi\nje L3000\nmov dword ptr (-52)[ebp],1\nL3000:\nsal dword ptr (-16)[ebp],1\nL2993:\ninc dword ptr (-20)[ebp]\ncmp dword ptr (-20)[ebp],50\njl L2992\ncmp dword ptr (-44)[ebp],0\nje L3002\ninc dword ptr (-56)[ebp]\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3004\npush 1\nlea edi,(L2985)\npush edi\ncall _printf\nadd esp,8\nL3004:\nL3002:\ncmp dword ptr (-48)[ebp],0\nje L3006\nadd dword ptr (-56)[ebp],2\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3008\npush 2\nlea edi,(L2985)\npush edi\ncall _printf\nadd esp,8\nL3008:\nL3006:\ncmp dword ptr (-52)[ebp],0\nje L3010\nadd dword ptr (-56)[ebp],4\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3012\npush 4\nlea edi,(L2985)\npush edi\ncall _printf\nadd esp,8\nL3012:\nL3010:\ncall _regc\nadd esp,0\nmov dword ptr (-16)[ebp],eax\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (40)[edi],0\nje L3014\ncmp dword ptr (-16)[ebp],0\njge L3016\nlea edi,(L425)\npush edi\nlea edi,(L2987)\npush edi\ncall _printf\nadd esp,8\njmp L3017\nL3016:\nlea edi,(L425)\npush edi\nmov edi,dword ptr (-16)[ebp]\npush edi\nlea edi,(L2988)\npush edi\ncall _printf\nadd esp,12\nL3017:\nL3014:\ncall _regp\nadd esp,0\nmov dword ptr (-16)[ebp],eax\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (40)[edi],0\nje L3018\ncmp dword ptr (-16)[ebp],0\njge L3020\nlea edi,(L3022)\npush edi\nlea edi,(L2987)\npush edi\ncall _printf\nadd esp,8\njmp L3021\nL3020:\nlea edi,(L3022)\npush edi\nmov edi,dword ptr (-16)[ebp]\npush edi\nlea edi,(L2988)\npush edi\ncall _printf\nadd esp,12\nL3021:\nL3018:\ncall _regi\nadd esp,0\nmov dword ptr (-16)[ebp],eax\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (40)[edi],0\nje L3023\ncmp dword ptr (-16)[ebp],0\njge L3025\nlea edi,(L426)\npush edi\nlea edi,(L2987)\npush edi\ncall _printf\nadd esp,8\njmp L3026\nL3025:\nlea edi,(L426)\npush edi\nmov edi,dword ptr (-16)[ebp]\npush edi\nlea edi,(L2988)\npush edi\ncall _printf\nadd esp,12\nL3026:\nL3023:\nmov eax,dword ptr (-56)[ebp]\nL2984:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _regc\n_regc:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,148\nmov byte ptr (-138)[ebp],0\nmov byte ptr (-117)[ebp],1\nmov byte ptr (-118)[ebp],2\nmov byte ptr (-119)[ebp],3\nmov byte ptr (-1)[ebp],4\nmov byte ptr (-120)[ebp],5\nmov byte ptr (-2)[ebp],6\nmov byte ptr (-121)[ebp],7\nmov byte ptr (-3)[ebp],8\nmov byte ptr (-122)[ebp],9\nmov byte ptr (-4)[ebp],10\nmov byte ptr (-123)[ebp],11\nmov byte ptr (-5)[ebp],12\nmov byte ptr (-124)[ebp],13\nmov byte ptr (-6)[ebp],14\nmov byte ptr (-125)[ebp],15\nmov byte ptr (-7)[ebp],16\nmov byte ptr (-126)[ebp],17\nmov byte ptr (-8)[ebp],18\nmov byte ptr (-127)[ebp],19\nmov byte ptr (-9)[ebp],20\nmov byte ptr (-128)[ebp],21\nmov byte ptr (-10)[ebp],22\nmov byte ptr (-129)[ebp],23\nmov byte ptr (-11)[ebp],24\nmov byte ptr (-130)[ebp],25\nmov byte ptr (-12)[ebp],26\nmov byte ptr (-131)[ebp],27\nmov byte ptr (-13)[ebp],28\nmov byte ptr (-132)[ebp],29\nmov byte ptr (-14)[ebp],30\nmov byte ptr (-133)[ebp],31\nmov byte ptr (-15)[ebp],32\nmov byte ptr (-134)[ebp],33\nmov byte ptr (-16)[ebp],34\nmov byte ptr (-135)[ebp],35\nmov byte ptr (-136)[ebp],36\nmov byte ptr (-137)[ebp],37\nmov byte ptr (-139)[ebp],38\nlea edi,(-117)[ebp]\nlea esi,(-138)[ebp]\nmov ebx,edi\nsub ebx,esi\nmov esi,ebx\nmov dword ptr (-104)[ebp],esi\nlea esi,(-118)[ebp]\nsub esi,edi\nmov edi,esi\nmov dword ptr (-100)[ebp],edi\nlea edi,(-119)[ebp]\nlea esi,(-118)[ebp]\nsub edi,esi\nmov dword ptr (-96)[ebp],edi\nlea edi,(-120)[ebp]\nlea esi,(-119)[ebp]\nsub edi,esi\nmov dword ptr (-92)[ebp],edi\nlea edi,(-121)[ebp]\nlea esi,(-120)[ebp]\nsub edi,esi\nmov dword ptr (-88)[ebp],edi\nlea edi,(-122)[ebp]\nlea esi,(-121)[ebp]\nsub edi,esi\nmov dword ptr (-84)[ebp],edi\nlea edi,(-123)[ebp]\nlea esi,(-122)[ebp]\nsub edi,esi\nmov dword ptr (-80)[ebp],edi\nlea edi,(-124)[ebp]\nlea esi,(-123)[ebp]\nsub edi,esi\nmov dword ptr (-76)[ebp],edi\nlea edi,(-125)[ebp]\nlea esi,(-124)[ebp]\nsub edi,esi\nmov dword ptr (-72)[ebp],edi\nlea edi,(-126)[ebp]\nlea esi,(-125)[ebp]\nsub edi,esi\nmov dword ptr (-68)[ebp],edi\nlea edi,(-127)[ebp]\nlea esi,(-126)[ebp]\nsub edi,esi\nmov dword ptr (-64)[ebp],edi\nlea edi,(-128)[ebp]\nlea esi,(-127)[ebp]\nsub edi,esi\nmov dword ptr (-60)[ebp],edi\nlea edi,(-129)[ebp]\nlea esi,(-128)[ebp]\nsub edi,esi\nmov dword ptr (-56)[ebp],edi\nlea edi,(-130)[ebp]\nlea esi,(-129)[ebp]\nsub edi,esi\nmov dword ptr (-52)[ebp],edi\nlea edi,(-131)[ebp]\nlea esi,(-130)[ebp]\nsub edi,esi\nmov dword ptr (-48)[ebp],edi\nlea edi,(-132)[ebp]\nlea esi,(-131)[ebp]\nsub edi,esi\nmov dword ptr (-44)[ebp],edi\nlea edi,(-133)[ebp]\nlea esi,(-132)[ebp]\nsub edi,esi\nmov dword ptr (-40)[ebp],edi\nlea edi,(-134)[ebp]\nlea esi,(-133)[ebp]\nsub edi,esi\nmov dword ptr (-36)[ebp],edi\nlea edi,(-135)[ebp]\nlea esi,(-134)[ebp]\nsub edi,esi\nmov dword ptr (-32)[ebp],edi\nlea edi,(-136)[ebp]\nlea esi,(-135)[ebp]\nsub edi,esi\nmov dword ptr (-28)[ebp],edi\nlea edi,(-137)[ebp]\nlea esi,(-136)[ebp]\nsub edi,esi\nmov dword ptr (-24)[ebp],edi\nlea edi,(-139)[ebp]\nlea esi,(-137)[ebp]\nsub edi,esi\nmov dword ptr (-20)[ebp],edi\nmov edi,dword ptr (-104)[ebp]\nmov dword ptr (-116)[ebp],edi\nmov dword ptr (-112)[ebp],1\nmov dword ptr (-108)[ebp],0\nL3049:\nmov edi,dword ptr (-112)[ebp]\ncmp edi,1\nje L3055\ncmp edi,2\nje L3058\ncmp edi,3\nje L3063\njmp L3053\nL3055:\nmov edi,dword ptr (-108)[ebp]\nmov esi,dword ptr (-116)[ebp]\ncmp dword ptr (-104)[ebp][edi*4],esi\nje L3054\nmov edi,dword ptr (-108)[ebp]\nmov edi,dword ptr (-104)[ebp][edi*4]\nmov dword ptr (-148)[ebp],edi\nmov dword ptr (-112)[ebp],2\nmov dword ptr (-144)[ebp],1\njmp L3054\nL3058:\nmov edi,dword ptr (-108)[ebp]\nmov esi,dword ptr (-116)[ebp]\ncmp dword ptr (-104)[ebp][edi*4],esi\njne L3059\nmov dword ptr (-112)[ebp],3\njmp L3054\nL3059:\nmov edi,dword ptr (-108)[ebp]\nmov esi,dword ptr (-148)[ebp]\ncmp dword ptr (-104)[ebp][edi*4],esi\njne L3061\ninc dword ptr (-144)[ebp]\njmp L3054\nL3061:\nmov dword ptr (-112)[ebp],4\njmp L3054\nL3063:\nmov edi,dword ptr (-108)[ebp]\nmov esi,dword ptr (-116)[ebp]\ncmp dword ptr (-104)[ebp][edi*4],esi\nje L3054\nmov dword ptr (-112)[ebp],4\nL3053:\nL3054:\nL3050:\ninc dword ptr (-108)[ebp]\ncmp dword ptr (-108)[ebp],22\njl L3049\ncmp dword ptr (-112)[ebp],3\njne L3066\nmov edi,16\nmov eax,edi\nsub eax,dword ptr (-144)[ebp]\njmp L3027\nL3066:\nmov eax,-1\nL3027:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _regi\n_regi:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,264\nmov dword ptr (-252)[ebp],0\nmov dword ptr (-168)[ebp],1\nmov dword ptr (-172)[ebp],2\nmov dword ptr (-176)[ebp],3\nmov dword ptr (-4)[ebp],4\nmov dword ptr (-180)[ebp],5\nmov dword ptr (-8)[ebp],6\nmov dword ptr (-184)[ebp],7\nmov dword ptr (-12)[ebp],8\nmov dword ptr (-188)[ebp],9\nmov dword ptr (-16)[ebp],10\nmov dword ptr (-192)[ebp],11\nmov dword ptr (-20)[ebp],12\nmov dword ptr (-196)[ebp],13\nmov dword ptr (-24)[ebp],14\nmov dword ptr (-200)[ebp],15\nmov dword ptr (-28)[ebp],16\nmov dword ptr (-204)[ebp],17\nmov dword ptr (-32)[ebp],18\nmov dword ptr (-208)[ebp],19\nmov dword ptr (-36)[ebp],20\nmov dword ptr (-212)[ebp],21\nmov dword ptr (-40)[ebp],22\nmov dword ptr (-216)[ebp],23\nmov dword ptr (-44)[ebp],24\nmov dword ptr (-220)[ebp],25\nmov dword ptr (-48)[ebp],26\nmov dword ptr (-224)[ebp],27\nmov dword ptr (-52)[ebp],28\nmov dword ptr (-228)[ebp],29\nmov dword ptr (-56)[ebp],30\nmov dword ptr (-232)[ebp],31\nmov dword ptr (-60)[ebp],32\nmov dword ptr (-236)[ebp],33\nmov dword ptr (-64)[ebp],34\nmov dword ptr (-240)[ebp],35\nmov dword ptr (-244)[ebp],36\nmov dword ptr (-248)[ebp],37\nmov dword ptr (-256)[ebp],38\nlea edi,(-168)[ebp]\nmov esi,4\nlea ebx,(-252)[ebp]\nmov edx,edi\nsub edx,ebx\nmov eax,edx\ncdq\nidiv esi\nmov dword ptr (-152)[ebp],eax\nlea ebx,(-172)[ebp]\nsub ebx,edi\nmov eax,ebx\ncdq\nidiv esi\nmov dword ptr (-148)[ebp],eax\nlea edi,(-176)[ebp]\nlea esi,(-172)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-144)[ebp],eax\nlea edi,(-180)[ebp]\nlea esi,(-176)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-140)[ebp],eax\nlea edi,(-184)[ebp]\nlea esi,(-180)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-136)[ebp],eax\nlea edi,(-188)[ebp]\nlea esi,(-184)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-132)[ebp],eax\nlea edi,(-192)[ebp]\nlea esi,(-188)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-128)[ebp],eax\nlea edi,(-196)[ebp]\nlea esi,(-192)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-124)[ebp],eax\nlea edi,(-200)[ebp]\nlea esi,(-196)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-120)[ebp],eax\nlea edi,(-204)[ebp]\nlea esi,(-200)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-116)[ebp],eax\nlea edi,(-208)[ebp]\nlea esi,(-204)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-112)[ebp],eax\nlea edi,(-212)[ebp]\nlea esi,(-208)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-108)[ebp],eax\nlea edi,(-216)[ebp]\nlea esi,(-212)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-104)[ebp],eax\nlea edi,(-220)[ebp]\nlea esi,(-216)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-100)[ebp],eax\nlea edi,(-224)[ebp]\nlea esi,(-220)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-96)[ebp],eax\nlea edi,(-228)[ebp]\nlea esi,(-224)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-92)[ebp],eax\nlea edi,(-232)[ebp]\nlea esi,(-228)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-88)[ebp],eax\nlea edi,(-236)[ebp]\nlea esi,(-232)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-84)[ebp],eax\nlea edi,(-240)[ebp]\nlea esi,(-236)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-80)[ebp],eax\nlea edi,(-244)[ebp]\nlea esi,(-240)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-76)[ebp],eax\nlea edi,(-248)[ebp]\nlea esi,(-244)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-72)[ebp],eax\nlea edi,(-256)[ebp]\nlea esi,(-248)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-68)[ebp],eax\nmov edi,dword ptr (-152)[ebp]\nmov dword ptr (-164)[ebp],edi\nmov dword ptr (-160)[ebp],1\nmov dword ptr (-156)[ebp],0\nL3090:\nmov edi,dword ptr (-160)[ebp]\ncmp edi,1\nje L3096\ncmp edi,2\nje L3099\ncmp edi,3\nje L3104\njmp L3094\nL3096:\nmov edi,dword ptr (-156)[ebp]\nmov esi,dword ptr (-164)[ebp]\ncmp dword ptr (-152)[ebp][edi*4],esi\nje L3095\nmov edi,dword ptr (-156)[ebp]\nmov edi,dword ptr (-152)[ebp][edi*4]\nmov dword ptr (-264)[ebp],edi\nmov dword ptr (-160)[ebp],2\nmov dword ptr (-260)[ebp],1\njmp L3095\nL3099:\nmov edi,dword ptr (-156)[ebp]\nmov esi,dword ptr (-164)[ebp]\ncmp dword ptr (-152)[ebp][edi*4],esi\njne L3100\nmov dword ptr (-160)[ebp],3\njmp L3095\nL3100:\nmov edi,dword ptr (-156)[ebp]\nmov esi,dword ptr (-264)[ebp]\ncmp dword ptr (-152)[ebp][edi*4],esi\njne L3102\ninc dword ptr (-260)[ebp]\njmp L3095\nL3102:\nmov dword ptr (-160)[ebp],4\njmp L3095\nL3104:\nmov edi,dword ptr (-156)[ebp]\nmov esi,dword ptr (-164)[ebp]\ncmp dword ptr (-152)[ebp][edi*4],esi\nje L3095\nmov dword ptr (-160)[ebp],4\nL3094:\nL3095:\nL3091:\ninc dword ptr (-156)[ebp]\ncmp dword ptr (-156)[ebp],22\njl L3090\ncmp dword ptr (-160)[ebp],3\njne L3107\nmov edi,16\nmov eax,edi\nsub eax,dword ptr (-260)[ebp]\njmp L3068\nL3107:\nmov eax,-1\nL3068:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _regp\n_regp:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,264\nlea edi,(-252)[ebp]\nmov dword ptr (-252)[ebp],edi\nlea edi,(-228)[ebp]\nmov dword ptr (-228)[ebp],edi\nlea edi,(-232)[ebp]\nmov dword ptr (-232)[ebp],edi\nlea edi,(-236)[ebp]\nmov dword ptr (-236)[ebp],edi\nlea edi,(-164)[ebp]\nmov dword ptr (-4)[ebp],edi\nlea edi,(-164)[ebp]\nmov dword ptr (-164)[ebp],edi\nlea edi,(-168)[ebp]\nmov dword ptr (-8)[ebp],edi\nlea edi,(-168)[ebp]\nmov dword ptr (-168)[ebp],edi\nlea edi,(-172)[ebp]\nmov dword ptr (-12)[ebp],edi\nlea edi,(-172)[ebp]\nmov dword ptr (-172)[ebp],edi\nlea edi,(-176)[ebp]\nmov dword ptr (-16)[ebp],edi\nlea edi,(-176)[ebp]\nmov dword ptr (-176)[ebp],edi\nlea edi,(-180)[ebp]\nmov dword ptr (-20)[ebp],edi\nlea edi,(-180)[ebp]\nmov dword ptr (-180)[ebp],edi\nlea edi,(-184)[ebp]\nmov dword ptr (-24)[ebp],edi\nlea edi,(-184)[ebp]\nmov dword ptr (-184)[ebp],edi\nlea edi,(-188)[ebp]\nmov dword ptr (-28)[ebp],edi\nlea edi,(-188)[ebp]\nmov dword ptr (-188)[ebp],edi\nlea edi,(-192)[ebp]\nmov dword ptr (-32)[ebp],edi\nlea edi,(-192)[ebp]\nmov dword ptr (-192)[ebp],edi\nlea edi,(-196)[ebp]\nmov dword ptr (-36)[ebp],edi\nlea edi,(-196)[ebp]\nmov dword ptr (-196)[ebp],edi\nlea edi,(-200)[ebp]\nmov dword ptr (-40)[ebp],edi\nlea edi,(-200)[ebp]\nmov dword ptr (-200)[ebp],edi\nlea edi,(-204)[ebp]\nmov dword ptr (-44)[ebp],edi\nlea edi,(-204)[ebp]\nmov dword ptr (-204)[ebp],edi\nlea edi,(-208)[ebp]\nmov dword ptr (-48)[ebp],edi\nlea edi,(-208)[ebp]\nmov dword ptr (-208)[ebp],edi\nlea edi,(-212)[ebp]\nmov dword ptr (-52)[ebp],edi\nlea edi,(-212)[ebp]\nmov dword ptr (-212)[ebp],edi\nlea edi,(-216)[ebp]\nmov dword ptr (-56)[ebp],edi\nlea edi,(-216)[ebp]\nmov dword ptr (-216)[ebp],edi\nlea edi,(-220)[ebp]\nmov dword ptr (-60)[ebp],edi\nlea edi,(-220)[ebp]\nmov dword ptr (-220)[ebp],edi\nlea edi,(-224)[ebp]\nmov dword ptr (-64)[ebp],edi\nlea edi,(-224)[ebp]\nmov dword ptr (-224)[ebp],edi\nlea edi,(-240)[ebp]\nmov dword ptr (-240)[ebp],edi\nlea edi,(-244)[ebp]\nmov dword ptr (-244)[ebp],edi\nlea edi,(-256)[ebp]\nmov dword ptr (-256)[ebp],edi\nlea edi,(-228)[ebp]\nmov esi,4\nlea ebx,(-252)[ebp]\nmov edx,edi\nsub edx,ebx\nmov eax,edx\ncdq\nidiv esi\nmov dword ptr (-152)[ebp],eax\nlea ebx,(-232)[ebp]\nsub ebx,edi\nmov eax,ebx\ncdq\nidiv esi\nmov dword ptr (-148)[ebp],eax\nlea edi,(-236)[ebp]\nlea esi,(-232)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-144)[ebp],eax\nlea edi,(-164)[ebp]\nlea esi,(-236)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-140)[ebp],eax\nlea edi,(-168)[ebp]\nlea esi,(-164)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-136)[ebp],eax\nlea edi,(-172)[ebp]\nlea esi,(-168)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-132)[ebp],eax\nlea edi,(-176)[ebp]\nlea esi,(-172)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-128)[ebp],eax\nlea edi,(-180)[ebp]\nlea esi,(-176)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-124)[ebp],eax\nlea edi,(-184)[ebp]\nlea esi,(-180)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-120)[ebp],eax\nlea edi,(-188)[ebp]\nlea esi,(-184)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-116)[ebp],eax\nlea edi,(-192)[ebp]\nlea esi,(-188)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-112)[ebp],eax\nlea edi,(-196)[ebp]\nlea esi,(-192)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-108)[ebp],eax\nlea edi,(-200)[ebp]\nlea esi,(-196)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-104)[ebp],eax\nlea edi,(-204)[ebp]\nlea esi,(-200)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-100)[ebp],eax\nlea edi,(-208)[ebp]\nlea esi,(-204)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-96)[ebp],eax\nlea edi,(-212)[ebp]\nlea esi,(-208)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-92)[ebp],eax\nlea edi,(-216)[ebp]\nlea esi,(-212)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-88)[ebp],eax\nlea edi,(-220)[ebp]\nlea esi,(-216)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-84)[ebp],eax\nlea edi,(-224)[ebp]\nlea esi,(-220)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-80)[ebp],eax\nlea edi,(-240)[ebp]\nlea esi,(-224)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-76)[ebp],eax\nlea edi,(-244)[ebp]\nlea esi,(-240)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-72)[ebp],eax\nlea edi,(-256)[ebp]\nlea esi,(-244)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nmov dword ptr (-68)[ebp],eax\nmov edi,dword ptr (-152)[ebp]\nmov dword ptr (-248)[ebp],edi\nmov dword ptr (-160)[ebp],1\nmov dword ptr (-156)[ebp],0\nL3131:\nmov edi,dword ptr (-160)[ebp]\ncmp edi,1\nje L3137\ncmp edi,2\nje L3140\ncmp edi,3\nje L3145\njmp L3135\nL3137:\nmov edi,dword ptr (-156)[ebp]\nmov esi,dword ptr (-248)[ebp]\ncmp dword ptr (-152)[ebp][edi*4],esi\nje L3136\nmov edi,dword ptr (-156)[ebp]\nmov edi,dword ptr (-152)[ebp][edi*4]\nmov dword ptr (-264)[ebp],edi\nmov dword ptr (-160)[ebp],2\nmov dword ptr (-260)[ebp],1\njmp L3136\nL3140:\nmov edi,dword ptr (-156)[ebp]\nmov esi,dword ptr (-248)[ebp]\ncmp dword ptr (-152)[ebp][edi*4],esi\njne L3141\nmov dword ptr (-160)[ebp],3\njmp L3136\nL3141:\nmov edi,dword ptr (-156)[ebp]\nmov esi,dword ptr (-264)[ebp]\ncmp dword ptr (-152)[ebp][edi*4],esi\njne L3143\ninc dword ptr (-260)[ebp]\njmp L3136\nL3143:\nmov dword ptr (-160)[ebp],4\njmp L3136\nL3145:\nmov edi,dword ptr (-156)[ebp]\nmov esi,dword ptr (-248)[ebp]\ncmp dword ptr (-152)[ebp][edi*4],esi\nje L3136\nmov dword ptr (-160)[ebp],4\nL3135:\nL3136:\nL3132:\ninc dword ptr (-156)[ebp]\ncmp dword ptr (-156)[ebp],22\njl L3131\ncmp dword ptr (-160)[ebp],3\njne L3148\nmov edi,16\nmov eax,edi\nsub eax,dword ptr (-260)[ebp]\njmp L3109\nL3148:\nmov eax,-1\nL3109:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 4\nL3151 label byte\ndb 420 dup (0)\n_DATA ends\n_DATA segment\nalign 1\nL3152 label byte\ndb 115\ndb 56\ndb 52\ndb 44\ndb 101\ndb 114\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL3153 label byte\ndb 115\ndb 56\ndb 52\ndb 32\ndb 32\ndb 32\ndb 32\ndb 0\npublic _s84\n_DATA ends\n_TEXT segment\n_s84:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,172\nlea edi,(L3153)\nmov dword ptr (-156)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea edi,(60)[edi]\nmov dword ptr (-160)[ebp],edi\nmov dword ptr (-164)[ebp],0\nL3154:\nL3155:\nmov edi,dword ptr (-160)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-160)[ebp],esi\nmov esi,dword ptr (-156)[ebp]\nlea ebx,(1)[esi]\nmov dword ptr (-156)[ebp],ebx\nmov bl,byte ptr [esi]\nmov byte ptr [edi],bl\nmovsx edi,bl\ncmp edi,0\njne L3154\npush 3\ncall _fip\nadd esp,4\nmov dword ptr (-168)[ebp],eax\nmov edi,dword ptr (-168)[ebp]\ncmp dword ptr [edi],3\nje L3157\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3159\npush 1\nlea edi,(L3152)\npush edi\ncall _printf\nadd esp,8\nL3159:\ninc dword ptr (-164)[ebp]\nL3157:\nlea edi,(_glork)\nmov dword ptr (-172)[ebp],edi\npush 4\ncall dword ptr (-172)[ebp]\nadd esp,4\ncmp eax,4\nje L3161\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3163\npush 2\nlea edi,(L3152)\npush edi\ncall _printf\nadd esp,8\nL3163:\nadd dword ptr (-164)[ebp],2\nL3161:\nmov dword ptr (-8)[ebp],0\nL3165:\nmov edi,dword ptr (-8)[ebp]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfstp dword ptr (-80)[ebp][edi*4]\nmov edi,dword ptr (-8)[ebp]\nlea edi,[edi*4]\nlea esi,(-80)[ebp][edi]\nmov dword ptr (-148)[ebp][edi],esi\nL3166:\ninc dword ptr (-8)[ebp]\ncmp dword ptr (-8)[ebp],17\njl L3165\nfld dword ptr (L412)\nfstp dword ptr (-152)[ebp]\nmov dword ptr (-8)[ebp],0\nL3169:\nfld dword ptr (-152)[ebp]\nmov edi,dword ptr (-8)[ebp]\nmov edi,dword ptr (-148)[ebp][edi*4]\nfadd dword ptr [edi]\nfstp dword ptr (-152)[ebp]\nL3170:\ninc dword ptr (-8)[ebp]\ncmp dword ptr (-8)[ebp],17\njl L3169\nfld dword ptr (L3175)\nfcomp dword ptr (-152)[ebp]\nfstsw ax\nsahf\nje L3173\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3176\npush 4\nlea edi,(L3152)\npush edi\ncall _printf\nadd esp,8\nL3176:\nadd dword ptr (-164)[ebp],4\nL3173:\nmov dword ptr (-12)[ebp],0\nL3178:\nmov dword ptr (-8)[ebp],0\nL3182:\nmov dword ptr (-4)[ebp],0\nL3186:\nmov edi,dword ptr (-4)[ebp]\nmov esi,dword ptr (-8)[ebp]\nmov ebx,dword ptr (-12)[ebp]\nimul edx,esi,28\nimul ecx,ebx,140\nlea edx,(L3151)[ecx][edx]\nimul ebx,ebx,35\nimul esi,esi,7\nlea esi,[esi][ebx]\nlea esi,[edi][esi]\nmov dword ptr [edx][edi*4],esi\nL3187:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],7\njl L3186\nL3183:\ninc dword ptr (-8)[ebp]\ncmp dword ptr (-8)[ebp],5\njl L3182\nL3179:\ninc dword ptr (-12)[ebp]\ncmp dword ptr (-12)[ebp],3\njl L3178\nmov dword ptr (-12)[ebp],1\nmov dword ptr (-8)[ebp],2\nmov dword ptr (-4)[ebp],3\npush 0\npush 105\nlea edi,(L3151)\npush edi\ncall _array\nadd esp,12\nmov edi,eax\npush 35\npush 35\nimul esi,dword ptr (-12)[ebp],140\nlea esi,(L3151)[esi]\npush esi\ncall _array\nadd esp,12\nmov esi,eax\npush 49\npush 7\nimul ebx,dword ptr (-8)[ebp],28\nimul edx,dword ptr (-12)[ebp],140\nlea ebx,(L3151)[edx][ebx]\npush ebx\ncall _array\nadd esp,12\nlea edi,[esi][edi]\nlea edi,[eax][edi]\nmov esi,dword ptr (-4)[ebp]\nimul ebx,dword ptr (-8)[ebp],28\nimul edx,dword ptr (-12)[ebp],140\nlea ebx,(L3151)[edx][ebx]\nmov esi,dword ptr [ebx][esi*4]\nlea edi,[esi][edi]\nsub edi,52\ncmp edi,0\nje L3190\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3192\npush 8\nlea edi,(L3152)\npush edi\ncall _printf\nadd esp,8\nL3192:\nadd dword ptr (-164)[ebp],8\nL3190:\nmov eax,dword ptr (-164)[ebp]\nL3150:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _array\n_array:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\nmov dword ptr (-4)[ebp],0\njmp L3198\nL3195:\nmov edi,dword ptr (-4)[ebp]\nmov esi,dword ptr (20)[ebp]\nmov ebx,dword ptr (28)[ebp]\nlea ebx,[ebx][edi]\ncmp dword ptr [esi][edi*4],ebx\nje L3199\nmov eax,1\njmp L3194\nL3199:\nL3196:\ninc dword ptr (-4)[ebp]\nL3198:\nmov edi,dword ptr (24)[ebp]\ncmp dword ptr (-4)[ebp],edi\njl L3195\nmov eax,0\nL3194:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 4\nL3202 label byte\ndb 4 dup (0)\npublic _fip\n_DATA ends\n_TEXT segment\n_fip:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nlea edi,(L3202)\nmov esi,dword ptr (20)[ebp]\nmov dword ptr (L3202),esi\nmov eax,edi\nL3201:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _glork\n_glork:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov eax,dword ptr (20)[ebp]\nL3203:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 1\nL3205 label byte\ndb 115\ndb 56\ndb 53\ndb 44\ndb 101\ndb 114\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL3206 label byte\ndb 115\ndb 56\ndb 53\ndb 32\ndb 32\ndb 32\ndb 32\ndb 0\nalign 4\nL3214 label byte\ndd L425\ndd L427\ndd L426\ndd L428\ndd L429\ndd L430\ndd L431\nalign 1\nL3215 label byte\ndb 32\ndb 97\ndb 108\ndb 105\ndb 103\ndb 110\ndb 109\ndb 101\ndb 110\ndb 116\ndb 58\ndb 32\ndb 0\npublic _s85\n_DATA ends\n_TEXT segment\n_s85:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,404\nlea edi,(L3206)\nmov dword ptr (-276)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea edi,(60)[edi]\nmov dword ptr (-280)[ebp],edi\nmov dword ptr (-320)[ebp],0\nL3219:\nL3220:\nmov edi,dword ptr (-280)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-280)[ebp],esi\nmov esi,dword ptr (-276)[ebp]\nlea ebx,(1)[esi]\nmov dword ptr (-276)[ebp],ebx\nmov bl,byte ptr [esi]\nmov byte ptr [edi],bl\nmovsx edi,bl\ncmp edi,0\njne L3219\nlea edi,(-296)[ebp]\nlea esi,(-316)[ebp]\nsub edi,esi\ncmp edi,0\njle L3230\nlea edi,(-292)[ebp]\nlea esi,(-296)[ebp]\nsub edi,esi\ncmp edi,0\njle L3230\nlea edi,(-288)[ebp]\nlea esi,(-292)[ebp]\nsub edi,esi\ncmp edi,0\njg L3222\nL3230:\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3231\npush 1\nlea edi,(L3205)\npush edi\ncall _printf\nadd esp,8\nL3231:\ninc dword ptr (-320)[ebp]\nL3222:\nlea edi,(-355)[ebp]\nlea esi,(-356)[ebp]\nsub edi,esi\nmov dword ptr (-272)[ebp],edi\nlea edi,(-358)[ebp]\nlea esi,(-360)[ebp]\nsub edi,esi\nmov dword ptr (-268)[ebp],edi\nlea edi,(-364)[ebp]\nlea esi,(-368)[ebp]\nsub edi,esi\nmov dword ptr (-264)[ebp],edi\nlea edi,(-372)[ebp]\nlea esi,(-376)[ebp]\nsub edi,esi\nmov dword ptr (-260)[ebp],edi\nlea edi,(-380)[ebp]\nlea esi,(-384)[ebp]\nsub edi,esi\nmov dword ptr (-256)[ebp],edi\nlea edi,(-388)[ebp]\nlea esi,(-392)[ebp]\nsub edi,esi\nmov dword ptr (-252)[ebp],edi\nlea edi,(-400)[ebp]\nlea esi,(-404)[ebp]\nsub edi,esi\nmov dword ptr (-248)[ebp],edi\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (40)[edi],0\nje L3246\nmov dword ptr (-244)[ebp],0\nL3248:\nmov edi,dword ptr (-244)[ebp]\nlea edi,[edi*4]\nmov esi,dword ptr (-272)[ebp][edi]\npush esi\nlea esi,(L3215)\npush esi\nmov edi,dword ptr (L3214)[edi]\npush edi\nlea edi,(L3252)\npush edi\ncall _printf\nadd esp,16\nL3249:\ninc dword ptr (-244)[ebp]\ncmp dword ptr (-244)[ebp],7\njl L3248\nL3246:\nmov edi,dword ptr (-284)[ebp]\nor edi,56\nmov dword ptr (-284)[ebp],edi\nmov edi,dword ptr (-284)[ebp]\nmov esi,edi\nand esi,0fffffffcH\nsal edi,26\nsar edi,29\nsal edi,30\nsar edi,30\nand edi,3\nor esi,edi\nmov dword ptr (-284)[ebp],esi\nmov edi,dword ptr (-284)[ebp]\nmov esi,edi\nand esi,0ffffffc7H\nsal edi,30\nsar edi,30\nsal edi,29\nsar edi,29\nlea edi,[edi*8]\nand edi,56\nor esi,edi\nmov dword ptr (-284)[ebp],esi\nmov edi,dword ptr (-284)[ebp]\nsal edi,26\nsar edi,29\ncmp edi,3\nje L3253\nmov edi,dword ptr (-284)[ebp]\nsal edi,26\nsar edi,29\ncmp edi,-1\njne L3255\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (40)[edi],0\nje L3256\nlea edi,(L3259)\npush edi\ncall _printf\nadd esp,4\njmp L3256\nL3255:\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3260\npush 2\nlea edi,(L3205)\npush edi\ncall _printf\nadd esp,8\nL3260:\nadd dword ptr (-320)[ebp],2\nL3256:\nL3253:\nmov edi,dword ptr (-284)[ebp]\nor edi,64\nmov dword ptr (-284)[ebp],edi\nmov edi,dword ptr (-284)[ebp]\nsal edi,25\nsar edi,31\ncmp edi,1\nje L3262\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (40)[edi],0\nje L3264\nlea edi,(L3266)\npush edi\ncall _printf\nadd esp,4\nL3264:\nL3262:\nlea edi,(-240)[ebp]\nmov esi,edi\nsub esi,edi\ncmp esi,0\njne L3274\ncmp esi,0\njne L3274\ncmp esi,0\njne L3274\ncmp esi,0\njne L3274\ncmp esi,0\njne L3274\ncmp esi,0\njne L3274\ncmp esi,0\nje L3267\nL3274:\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3275\npush 4\nlea edi,(L3205)\npush edi\ncall _printf\nadd esp,8\nL3275:\nadd dword ptr (-320)[ebp],4\nL3267:\njmp L3277\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3279\npush 8\nlea edi,(L3205)\npush edi\ncall _printf\nadd esp,8\nL3279:\nadd dword ptr (-320)[ebp],8\nL3277:\nlea edi,(-352)[ebp]\nmov dword ptr (-288)[ebp],edi\nmov byte ptr (-352)[ebp],2\nmov edi,dword ptr (-288)[ebp]\nmovsx esi,byte ptr [edi]\nlea esi,(1)[esi]\nmov ebx,esi\nmov byte ptr [edi],bl\nmovsx edi,byte ptr (-352)[ebp]\ncmp edi,3\nje L3283\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3285\npush 16\nlea edi,(L3205)\npush edi\ncall _printf\nadd esp,8\nL3285:\nadd dword ptr (-320)[ebp],16\nL3283:\nmov eax,dword ptr (-320)[ebp]\nL3204:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 1\nL3288 label byte\ndb 115\ndb 56\ndb 54\ndb 44\ndb 101\ndb 114\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL3289 label byte\ndb 115\ndb 56\ndb 54\ndb 32\ndb 32\ndb 32\ndb 32\ndb 0\nalign 4\nL3290 label byte\ndd 1\ndd 3\ndd 5\nalign 4\nL3291 label byte\ndd L3290+8\n_DATA ends\n_DATA segment\nalign 4\nL3293 label byte\ndb 40 dup (0)\n_DATA ends\n_DATA segment\nalign 4\nL3294 label byte\ndd 03f800000H\ndd 040400000H\ndd 040a00000H\ndd 040000000H\ndd 040800000H\ndd 040c00000H\ndd 040400000H\ndd 040a00000H\ndd 040e00000H\ndd 00H\ndd 00H\ndd 00H\nalign 4\nL3295 label byte\ndd 03f800000H\ndd 040400000H\ndd 040a00000H\ndd 040000000H\ndd 040800000H\ndd 040c00000H\ndd 040400000H\ndd 040a00000H\ndd 040e00000H\ndb 12 dup (0)\nalign 4\nL3296 label byte\ndd 03f800000H\ndd 040400000H\ndd 040a00000H\ndd 040000000H\ndd 040800000H\ndd 040c00000H\ndd 040400000H\ndd 040a00000H\ndd 040e00000H\ndb 12 dup (0)\nalign 4\nL3297 label byte\ndd 03f800000H\ndb 8 dup (0)\ndd 040000000H\ndb 8 dup (0)\ndd 040400000H\ndb 8 dup (0)\ndd 040800000H\ndb 8 dup (0)\npublic _s86\n_DATA ends\n_TEXT segment\n_s86:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,40\nmov edi,dword ptr (L3291)\nlea edi,(-4)[edi]\nmov dword ptr (-36)[ebp],edi\ncall _one\nadd esp,0\nmov esi,dword ptr (-36)[ebp]\nlea edi,[esi][eax*4]\nmov dword ptr (-4)[ebp],edi\nlea edi,(L3289)\nmov dword ptr (-24)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea edi,(60)[edi]\nmov dword ptr (-28)[ebp],edi\nmov dword ptr (-32)[ebp],0\nL3298:\nL3299:\nmov edi,dword ptr (-28)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-28)[ebp],esi\nmov esi,dword ptr (-24)[ebp]\nlea ebx,(1)[esi]\nmov dword ptr (-24)[ebp],ebx\nmov bl,byte ptr [esi]\nmov byte ptr [edi],bl\nmovsx edi,bl\ncmp edi,0\njne L3298\nmov edi,dword ptr (L3291)\ncmp dword ptr [edi],5\nje L3301\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3303\npush 1\nlea edi,(L3288)\npush edi\ncall _printf\nadd esp,8\nL3303:\ninc dword ptr (-32)[ebp]\nL3301:\nmov edi,dword ptr (-36)[ebp]\ncmp dword ptr [edi],3\nje L3305\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3307\npush 2\nlea edi,(L3288)\npush edi\ncall _printf\nadd esp,8\nL3307:\nadd dword ptr (-32)[ebp],2\nL3305:\nmov edi,dword ptr (-4)[ebp]\ncmp dword ptr [edi],5\nje L3309\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3311\npush 4\nlea edi,(L3288)\npush edi\ncall _printf\nadd esp,8\nL3311:\nadd dword ptr (-32)[ebp],4\nL3309:\nmov dword ptr (-20)[ebp],0\nmov dword ptr (-8)[ebp],0\nL3313:\nmov edi,dword ptr (-8)[ebp]\ncmp dword ptr (L3293)[edi*4],0\nje L3317\nmov dword ptr (-20)[ebp],1\nL3317:\nL3314:\ninc dword ptr (-8)[ebp]\ncmp dword ptr (-8)[ebp],10\njl L3313\ncmp dword ptr (-20)[ebp],0\nje L3319\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3321\npush 8\nlea edi,(L3288)\npush edi\ncall _printf\nadd esp,8\nL3321:\nadd dword ptr (-32)[ebp],8\nL3319:\nmov dword ptr (-20)[ebp],0\nmov dword ptr (-12)[ebp],0\nL3323:\nmov dword ptr (-8)[ebp],0\nL3327:\nimul edi,dword ptr (-12)[ebp],3\nmov esi,dword ptr (-8)[ebp]\nlea edi,[esi][edi]\nmov dword ptr (-16)[ebp],edi\nmov edi,dword ptr (-8)[ebp]\nlea edi,[edi*4]\nimul esi,dword ptr (-12)[ebp],12\nfld dword ptr (L3295)[esi][edi]\nfstp dword ptr (-40)[ebp]\nfld dword ptr (L3296)[esi][edi]\nfcomp dword ptr (-40)[ebp]\nfstsw ax\nsahf\njne L3333\nmov edi,dword ptr (-16)[ebp]\nfld dword ptr (L3294)[edi*4]\nfcomp dword ptr (-40)[ebp]\nfstsw ax\nsahf\nje L3331\nL3333:\nmov dword ptr (-20)[ebp],1\nL3331:\nL3328:\ninc dword ptr (-8)[ebp]\ncmp dword ptr (-8)[ebp],3\njl L3327\nL3324:\ninc dword ptr (-12)[ebp]\ncmp dword ptr (-12)[ebp],4\njl L3323\ncmp dword ptr (-20)[ebp],0\nje L3334\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3336\npush 16\nlea edi,(L3288)\npush edi\ncall _printf\nadd esp,8\nL3336:\nadd dword ptr (-32)[ebp],16\nL3334:\nmov dword ptr (-20)[ebp],0\nmov dword ptr (-8)[ebp],0\nL3338:\nmov edi,dword ptr (-8)[ebp]\nimul esi,edi,12\nlea edi,(1)[edi]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfcomp dword ptr (L3297)[esi]\nfstsw ax\nsahf\nje L3342\nmov dword ptr (-20)[ebp],1\nL3342:\nL3339:\ninc dword ptr (-8)[ebp]\ncmp dword ptr (-8)[ebp],4\njl L3338\ncmp dword ptr (-20)[ebp],0\nje L3344\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3346\npush 32\nlea edi,(L3288)\npush edi\ncall _printf\nadd esp,8\nL3346:\nadd dword ptr (-32)[ebp],32\nL3344:\nmov eax,dword ptr (-32)[ebp]\nL3287:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _one\n_one:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov eax,1\nL3348:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 1\nL3350 label byte\ndb 115\ndb 56\ndb 56\ndb 44\ndb 101\ndb 114\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL3351 label byte\ndb 115\ndb 56\ndb 56\ndb 32\ndb 32\ndb 32\ndb 32\ndb 0\npublic _s88\n_DATA ends\n_TEXT segment\n_s88:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,44\nlea edi,(L3351)\nmov dword ptr (-4)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea edi,(60)[edi]\nmov dword ptr (-8)[ebp],edi\nmov dword ptr (-12)[ebp],0\nL3353:\nL3354:\nmov edi,dword ptr (-8)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-8)[ebp],esi\nmov esi,dword ptr (-4)[ebp]\nlea ebx,(1)[esi]\nmov dword ptr (-4)[ebp],ebx\nmov bl,byte ptr [esi]\nmov byte ptr [edi],bl\nmovsx edi,bl\ncmp edi,0\njne L3353\njmp L3356\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3358\npush 1\nlea edi,(L3350)\npush edi\ncall _printf\nadd esp,8\nL3358:\ninc dword ptr (-12)[ebp]\nL3356:\nlea edi,(-32)[ebp]\nmov dword ptr (_metricp),edi\nmov dword ptr (-32)[ebp],2\nmov edi,dword ptr (_metricp)\nmov dword ptr [edi],3\ncmp dword ptr (-32)[ebp],3\nje L3360\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3362\npush 2\nlea edi,(L3350)\npush edi\ncall _printf\nadd esp,8\nL3362:\nadd dword ptr (-12)[ebp],2\nL3360:\nfld qword ptr (L419)\nfstp qword ptr (-28)[ebp]\nfld qword ptr (L419)\nfstp qword ptr (-20)[ebp]\nlea edi,(-28)[ebp]\nmov dword ptr (-36)[ebp],edi\nmov edi,dword ptr (-36)[ebp]\nfld qword ptr (L418)\nfstp qword ptr [edi]\nmov edi,dword ptr (-36)[ebp]\nfld qword ptr (L418)\nfstp qword ptr (8)[edi]\nfld qword ptr (-28)[ebp]\nfadd qword ptr (-20)[ebp]\nfld qword ptr (L416)\nfcompp\nfstsw ax\nsahf\nje L3365\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3368\npush 4\nlea edi,(L3350)\npush edi\ncall _printf\nadd esp,8\nL3368:\nadd dword ptr (-12)[ebp],4\nL3365:\nmov eax,dword ptr (-12)[ebp]\nL3349:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 1\nL3371 label byte\ndb 115\ndb 57\ndb 44\ndb 101\ndb 114\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL3372 label byte\ndb 115\ndb 57\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 0\npublic _s9\n_DATA ends\n_TEXT segment\n_s9:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,36\nlea edi,(L3372)\nmov dword ptr (-12)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea edi,(60)[edi]\nmov dword ptr (-16)[ebp],edi\nmov dword ptr (-20)[ebp],0\nL3373:\nL3374:\nmov edi,dword ptr (-16)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-16)[ebp],esi\nmov esi,dword ptr (-12)[ebp]\nlea ebx,(1)[esi]\nmov dword ptr (-12)[ebp],ebx\nmov bl,byte ptr [esi]\nmov byte ptr [edi],bl\nmovsx edi,bl\ncmp edi,0\njne L3373\nmov dword ptr (-8)[ebp],0\nmov dword ptr (-4)[ebp],0\nL3376:\nmov dword ptr (-24)[ebp],2\nmov dword ptr (-28)[ebp],2\nmov dword ptr (-32)[ebp],3\nmov dword ptr (-36)[ebp],3\ncmp dword ptr (-36)[ebp],3\njne L3382\ncmp dword ptr (-32)[ebp],3\nje L3380\nL3382:\nmov dword ptr (-8)[ebp],1\nL3380:\ncmp dword ptr (-28)[ebp],2\njne L3385\ncmp dword ptr (-24)[ebp],2\nje L3383\nL3385:\nmov dword ptr (-8)[ebp],1\nL3383:\nL3377:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],2\njl L3376\ncmp dword ptr (-8)[ebp],0\nje L3390\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3388\npush 1\nlea edi,(L3371)\npush edi\ncall _printf\nadd esp,8\nL3388:\ninc dword ptr (-20)[ebp]\njmp L3390\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr (44)[edi],0\nje L3391\npush 2\nlea edi,(L3371)\npush edi\ncall _printf\nadd esp,8\nL3391:\nadd dword ptr (-20)[ebp],2\nL3390:\nmov eax,dword ptr (-20)[ebp]\nL3370:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _setev\n_setev:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov dword ptr (_extvar),1066\nmov eax,0\nL3393:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\nextrn _printf:near\n_TEXT segment\n_TEXT ends\n_DATA segment\npublic _rfs\nalign 1\n_rfs label byte\ndb 8 dup (0)\npublic _crc\nalign 4\n_crc label byte\ndb 4 dup (0)\npublic _rrc\nalign 4\n_rrc label byte\ndb 4 dup (0)\npublic _flgl\nalign 4\n_flgl label byte\ndb 4 dup (0)\npublic _flgd\nalign 4\n_flgd label byte\ndb 4 dup (0)\npublic _flgm\nalign 4\n_flgm label byte\ndb 4 dup (0)\npublic _flgs\nalign 4\n_flgs label byte\ndb 4 dup (0)\npublic _dprec\nalign 4\n_dprec label byte\ndb 4 dup (0)\npublic _fprec\nalign 4\n_fprec label byte\ndb 4 dup (0)\npublic _dbits\nalign 4\n_dbits label byte\ndb 4 dup (0)\npublic _fbits\nalign 4\n_fbits label byte\ndb 4 dup (0)\npublic _ubits\nalign 4\n_ubits label byte\ndb 4 dup (0)\npublic _lbits\nalign 4\n_lbits label byte\ndb 4 dup (0)\npublic _metricp\nalign 4\n_metricp label byte\ndb 4 dup (0)\npublic _extvar\nalign 4\n_extvar label byte\ndb 4 dup (0)\n_DATA ends\n_TEXT segment\nalign 1\nL3266 label byte\ndb 66\ndb 101\ndb 32\ndb 101\ndb 115\ndb 112\ndb 101\ndb 99\ndb 105\ndb 97\ndb 108\ndb 108\ndb 121\ndb 32\ndb 99\ndb 97\ndb 114\ndb 101\ndb 102\ndb 117\ndb 108\ndb 32\ndb 119\ndb 105\ndb 116\ndb 104\ndb 32\ndb 49\ndb 45\ndb 98\ndb 105\ndb 116\ndb 32\ndb 102\ndb 105\ndb 101\ndb 108\ndb 100\ndb 115\ndb 33\ndb 10\ndb 0\nalign 1\nL3259 label byte\ndb 83\ndb 105\ndb 103\ndb 110\ndb 32\ndb 101\ndb 120\ndb 116\ndb 101\ndb 110\ndb 115\ndb 105\ndb 111\ndb 110\ndb 32\ndb 105\ndb 110\ndb 32\ndb 102\ndb 105\ndb 101\ndb 108\ndb 100\ndb 115\ndb 10\ndb 0\nalign 1\nL3252 label byte\ndb 37\ndb 115\ndb 37\ndb 115\ndb 37\ndb 100\ndb 10\ndb 0\nalign 4\nL3175 label byte\ndd 043080000H\nalign 1\nL3022 label byte\ndb 112\ndb 111\ndb 105\ndb 110\ndb 116\ndb 101\ndb 114\ndb 0\nalign 1\nL2472 label byte\ndb 73\ndb 110\ndb 99\ndb 114\ndb 101\ndb 97\ndb 115\ndb 105\ndb 110\ndb 103\ndb 32\ndb 97\ndb 114\ndb 114\ndb 97\ndb 121\ndb 32\ndb 101\ndb 108\ndb 101\ndb 109\ndb 101\ndb 110\ndb 116\ndb 115\ndb 32\ndb 97\ndb 115\ndb 115\ndb 105\ndb 103\ndb 110\ndb 101\ndb 100\ndb 32\ndb 116\ndb 111\ndb 32\ndb 100\ndb 101\ndb 99\ndb 114\ndb 101\ndb 97\ndb 115\ndb 105\ndb 110\ndb 103\ndb 32\ndb 108\ndb 111\ndb 99\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 115\ndb 10\ndb 0\nalign 4\nL2356 label byte\ndd 041d00000H\nalign 4\nL2355 label byte\ndd 00H\ndd 0403a0000H\nalign 4\nL1659 label byte\ndd 00H\ndd 040040000H\nalign 4\nL1484 label byte\ndd 00H\ndd 040240000H\nalign 4\nL1455 label byte\ndd 041200000H\nalign 4\nL1280 label byte\ndd 00H\ndd 040080000H\nalign 4\nL1251 label byte\ndd 040400000H\nalign 4\nL1076 label byte\ndd 00H\ndd 0401c0000H\nalign 4\nL1047 label byte\ndd 040e00000H\nalign 4\nL870 label byte\ndd 00H\ndd 040140000H\nalign 4\nL841 label byte\ndd 040a00000H\nalign 4\nL836 label byte\ndd 00H\ndd 041e00000H\nalign 4\nL828 label byte\ndd 04f000000H\nalign 1\nL653 label byte\ndb 113\ndb 117\ndb 101\ndb 101\ndb 112\ndb 0\nalign 1\nL639 label byte\ndb 10\ndb 0\nalign 1\nL638 label byte\ndb 37\ndb 100\ndb 0\nalign 1\nL633 label byte\ndb 32\ndb 32\ndb 32\ndb 107\ndb 101\ndb 121\ndb 61\ndb 0\nalign 4\nL596 label byte\ndd 00H\ndd 040000000H\nalign 4\nL536 label byte\ndd 00H\ndd 040ce8480H\nalign 4\nL535 label byte\ndd 00H\ndd 0405f4000H\nalign 4\nL534 label byte\ndd 042fa0000H\nalign 4\nL529 label byte\ndd 040000000H\nalign 1\nL431 label byte\ndb 100\ndb 111\ndb 117\ndb 98\ndb 108\ndb 101\ndb 0\nalign 1\nL430 label byte\ndb 102\ndb 108\ndb 111\ndb 97\ndb 116\ndb 0\nalign 1\nL429 label byte\ndb 117\ndb 110\ndb 115\ndb 105\ndb 103\ndb 110\ndb 101\ndb 100\ndb 0\nalign 1\nL428 label byte\ndb 108\ndb 111\ndb 110\ndb 103\ndb 0\nalign 1\nL427 label byte\ndb 115\ndb 104\ndb 111\ndb 114\ndb 116\ndb 0\nalign 1\nL426 label byte\ndb 105\ndb 110\ndb 116\ndb 0\nalign 1\nL425 label byte\ndb 99\ndb 104\ndb 97\ndb 114\ndb 0\nalign 4\nL419 label byte\ndd 00H\ndd 00H\nalign 4\nL418 label byte\ndd 00H\ndd 03ff00000H\nalign 4\nL417 label byte\ndd 00H\ndd 040100000H\nalign 4\nL416 label byte\ndd 00H\ndd 040000000H\nalign 4\nL412 label byte\ndd 00H\nalign 4\nL411 label byte\ndd 03f800000H\nalign 1\nL390 label byte\ndb 113\ndb 117\ndb 101\ndb 101\ndb 112\ndb 33\ndb 0\nalign 1\nL379 label byte\ndb 10\ndb 9\ndb 8\ndb 13\ndb 12\ndb 92\ndb 39\ndb 0\nalign 1\nL375 label byte\ndb 46\ndb 34\ndb 46\ndb 0\nalign 1\nL362 label byte\ndb 46\ndb 46\ndb 46\ndb 0\nalign 4\nL333 label byte\ndd 00H\ndd 040938800H\nalign 1\nL199 label byte\ndb 32\ndb 32\ndb 32\ndb 100\ndb 105\ndb 102\ndb 102\ndb 101\ndb 114\ndb 101\ndb 110\ndb 116\ndb 32\ndb 114\ndb 101\ndb 115\ndb 117\ndb 108\ndb 116\ndb 115\ndb 32\ndb 119\ndb 104\ndb 101\ndb 110\ndb 32\ndb 97\ndb 115\ndb 115\ndb 105\ndb 103\ndb 110\ndb 101\ndb 100\ndb 32\ndb 116\ndb 111\ndb 32\ndb 108\ndb 111\ndb 110\ndb 103\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL198 label byte\ndb 68\ndb 101\ndb 99\ndb 105\ndb 109\ndb 97\ndb 108\ndb 32\ndb 97\ndb 110\ndb 100\ndb 32\ndb 111\ndb 99\ndb 116\ndb 97\ndb 108\ndb 47\ndb 104\ndb 101\ndb 120\ndb 32\ndb 99\ndb 111\ndb 110\ndb 115\ndb 116\ndb 97\ndb 110\ndb 116\ndb 115\ndb 32\ndb 115\ndb 111\ndb 109\ndb 101\ndb 116\ndb 105\ndb 109\ndb 101\ndb 115\ndb 32\ndb 103\ndb 105\ndb 118\ndb 101\ndb 10\ndb 0\nalign 1\nL27 label byte\ndb 10\ndb 70\ndb 97\ndb 105\ndb 108\ndb 101\ndb 100\ndb 46\ndb 10\ndb 0\nalign 1\nL26 label byte\ndb 10\ndb 78\ndb 111\ndb 32\ndb 101\ndb 114\ndb 114\ndb 111\ndb 114\ndb 115\ndb 32\ndb 100\ndb 101\ndb 116\ndb 101\ndb 99\ndb 116\ndb 101\ndb 100\ndb 46\ndb 10\ndb 0\nalign 1\nL20 label byte\ndb 83\ndb 101\ndb 99\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 37\ndb 115\ndb 32\ndb 114\ndb 101\ndb 116\ndb 117\ndb 114\ndb 110\ndb 101\ndb 100\ndb 32\ndb 37\ndb 100\ndb 46\ndb 10\ndb 0\n_TEXT ends\nend\n"
  },
  {
    "path": "lcc/x86/win32/tst/cvt.1bk",
    "content": "1 1 1 1 1 1 1 1 1.000000 1.000000 1.000000\n2 2 2 2 2 2 2 2 2.000000 2.000000 2.000000\n3 3 3 3 3 3 3 3 3.000000 3.000000 3.000000\n4 4 4 4 4 4 4 4 4.000000 4.000000 4.000000\n5 5 5 5 5 5 5 5 5.000000 5.000000 5.000000\n6 6 6 6 6 6 6 6 6.000000 6.000000 6.000000\n7 7 7 7 7 7 7 7 7.000000 7.000000 7.000000\n8 8 8 8 8 8 8 8 8.000000 8.000000 8.000000\n9 9 9 9 9 9 9 9 9.000000 9.000000 9.000000\n10 10 10 10 10 10 10 10 10.000000 10.000000 10.000000\n11 11 11 11 11 11 11 11 11.000000 11.000000 11.000000\n"
  },
  {
    "path": "lcc/x86/win32/tst/cvt.2bk",
    "content": "tst/cvt.c:32: warning: conversion from `pointer to void function(void)' to `pointer to void' is compiler dependent\ntst/cvt.c:33: warning: conversion from `pointer to void' to `pointer to void function(void)' is compiler dependent\n"
  },
  {
    "path": "lcc/x86/win32/tst/cvt.sbk",
    "content": ".486\n.model flat\nextrn __fltused:near\nextrn __ftol:near\npublic _print\n_TEXT segment\n_print:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nfld qword ptr (_D)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_d)\nsub esp,8\nfstp qword ptr [esp]\nfld dword ptr (_f)\nsub esp,8\nfstp qword ptr [esp]\nmov edi,dword ptr (_L)\npush edi\nmov edi,dword ptr (_I)\npush edi\nmov di,word ptr (_S)\nmovzx edi,di\npush edi\nmov bl,byte ptr (_C)\nmovzx edi,bl\npush edi\nmov edi,dword ptr (_l)\npush edi\nmov edi,dword ptr (_i)\npush edi\nmovsx edi,word ptr (_s)\npush edi\nmovsx edi,byte ptr (_c)\npush edi\nlea edi,(L2)\npush edi\ncall _printf\nadd esp,60\nL1:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _main\n_main:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,296\nmov byte ptr (_c),1\nmovsx edi,byte ptr (_c)\nmov esi,edi\nmov word ptr (_s),si\nmov dword ptr (_i),edi\nmov dword ptr (_l),edi\nmov esi,edi\nmov ebx,esi\nmov byte ptr (_C),bl\nmov ebx,esi\nmov word ptr (_S),bx\nmov dword ptr (_I),esi\nmov dword ptr (_L),esi\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfstp dword ptr (_f)\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfstp qword ptr (-8)[ebp]\nfld qword ptr (-8)[ebp]\nfstp qword ptr (_d)\nfld qword ptr (-8)[ebp]\nfstp qword ptr (_D)\ncall _print\nadd esp,0\nmov word ptr (_s),2\nmovsx edi,word ptr (_s)\nmov ebx,edi\nmov byte ptr (_c),bl\nmov dword ptr (_i),edi\nmov dword ptr (_l),edi\nmov esi,edi\nmov ebx,esi\nmov byte ptr (_C),bl\nmov ebx,esi\nmov word ptr (_S),bx\nmov dword ptr (_I),esi\nmov dword ptr (_L),esi\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfstp dword ptr (_f)\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfstp qword ptr (-16)[ebp]\nfld qword ptr (-16)[ebp]\nfstp qword ptr (_d)\nfld qword ptr (-16)[ebp]\nfstp qword ptr (_D)\ncall _print\nadd esp,0\nmov dword ptr (_i),3\nmov edi,dword ptr (_i)\nmov ebx,edi\nmov byte ptr (_c),bl\nmov esi,edi\nmov word ptr (_s),si\nmov dword ptr (_l),edi\nmov esi,edi\nmov ebx,esi\nmov byte ptr (_C),bl\nmov ebx,esi\nmov word ptr (_S),bx\nmov dword ptr (_I),esi\nmov dword ptr (_L),esi\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfstp dword ptr (_f)\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfstp qword ptr (-24)[ebp]\nfld qword ptr (-24)[ebp]\nfstp qword ptr (_d)\nfld qword ptr (-24)[ebp]\nfstp qword ptr (_D)\ncall _print\nadd esp,0\nmov dword ptr (_l),4\nmov edi,dword ptr (_l)\nmov ebx,edi\nmov byte ptr (_c),bl\nmov esi,edi\nmov word ptr (_s),si\nmov dword ptr (_i),edi\nmov esi,edi\nmov ebx,esi\nmov byte ptr (_C),bl\nmov ebx,esi\nmov word ptr (_S),bx\nmov dword ptr (_I),esi\nmov dword ptr (_L),esi\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfstp dword ptr (_f)\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfstp qword ptr (-32)[ebp]\nfld qword ptr (-32)[ebp]\nfstp qword ptr (_d)\nfld qword ptr (-32)[ebp]\nfstp qword ptr (_D)\ncall _print\nadd esp,0\nmov byte ptr (_C),5\nmov bl,byte ptr (_C)\nmovzx edi,bl\nmov ebx,edi\nmov byte ptr (_c),bl\nmov esi,edi\nmov word ptr (_s),si\nmov dword ptr (_i),edi\nmov dword ptr (_l),edi\nmov esi,edi\nmov ebx,esi\nmov word ptr (_S),bx\nmov dword ptr (_I),esi\nmov dword ptr (_L),esi\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfstp dword ptr (_f)\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfstp qword ptr (-40)[ebp]\nfld qword ptr (-40)[ebp]\nfstp qword ptr (_d)\nfld qword ptr (-40)[ebp]\nfstp qword ptr (_D)\ncall _print\nadd esp,0\nmov word ptr (_S),6\nmov di,word ptr (_S)\nmovzx edi,di\nmov ebx,edi\nmov byte ptr (_c),bl\nmov esi,edi\nmov word ptr (_s),si\nmov dword ptr (_i),edi\nmov dword ptr (_l),edi\nmov esi,edi\nmov ebx,esi\nmov byte ptr (_C),bl\nmov dword ptr (_I),esi\nmov dword ptr (_L),esi\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfstp dword ptr (_f)\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfstp qword ptr (-48)[ebp]\nfld qword ptr (-48)[ebp]\nfstp qword ptr (_d)\nfld qword ptr (-48)[ebp]\nfstp qword ptr (_D)\ncall _print\nadd esp,0\nmov dword ptr (_I),7\nmov edi,dword ptr (_I)\nmov ebx,edi\nmov byte ptr (_c),bl\nmov ebx,edi\nmov word ptr (_s),bx\nmov dword ptr (_i),edi\nmov dword ptr (_l),edi\nmov ebx,edi\nmov byte ptr (_C),bl\nmov esi,edi\nmov word ptr (_S),si\nmov dword ptr (_L),edi\nfld qword ptr (L4)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nfstp qword ptr (-56)[ebp]\nfld qword ptr (-56)[ebp]\nfstp dword ptr (_f)\nfld qword ptr (-56)[ebp]\nfstp qword ptr (_d)\nfld qword ptr (-56)[ebp]\nfstp qword ptr (_D)\ncall _print\nadd esp,0\nmov dword ptr (_L),8\nmov edi,dword ptr (_L)\nmov ebx,edi\nmov byte ptr (_c),bl\nmov ebx,edi\nmov word ptr (_s),bx\nmov dword ptr (_i),edi\nmov dword ptr (_l),edi\nmov ebx,edi\nmov byte ptr (_C),bl\nmov esi,edi\nmov word ptr (_S),si\nmov si,word ptr (_S)\nmovzx esi,si\nmov dword ptr (_I),esi\nfld qword ptr (L4)\nmov esi,edi\nshr esi,1\npush esi\nfild dword ptr 0[esp]\nadd esp,4\nfmulp st(1),st\nand edi,1\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfaddp st(1),st\nfstp qword ptr (-64)[ebp]\nfld qword ptr (-64)[ebp]\nfstp dword ptr (_f)\nfld qword ptr (-64)[ebp]\nfstp qword ptr (_d)\nfld qword ptr (-64)[ebp]\nfstp qword ptr (_D)\ncall _print\nadd esp,0\nfld dword ptr (L5)\nfstp dword ptr (_f)\nfld dword ptr (_f)\nfstp dword ptr (-84)[ebp]\nfld dword ptr (-84)[ebp]\ncall __ftol\nmov edi,eax\nmov ebx,edi\nmov byte ptr (_c),bl\nmov esi,edi\nmov word ptr (_s),si\nmov dword ptr (_i),edi\nmov dword ptr (_l),edi\nfld dword ptr (L9)\nfcomp dword ptr (-84)[ebp]\nfstsw ax\nsahf\nja L7\nfld dword ptr (-84)[ebp]\nfsub dword ptr (L9)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-68)[ebp],edi\njmp L8\nL7:\nfld dword ptr (-84)[ebp]\ncall __ftol\nmov edi,eax\nmov dword ptr (-68)[ebp],edi\nL8:\nmov edi,dword ptr (-68)[ebp]\nmov ebx,edi\nmov byte ptr (_C),bl\nfld dword ptr (L9)\nfcomp dword ptr (_f)\nfstsw ax\nsahf\nja L11\nfld dword ptr (_f)\nfsub dword ptr (L9)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-72)[ebp],edi\njmp L12\nL11:\nfld dword ptr (_f)\ncall __ftol\nmov edi,eax\nmov dword ptr (-72)[ebp],edi\nL12:\nmov edi,dword ptr (-72)[ebp]\nmov word ptr (_S),di\nfld dword ptr (L9)\nfcomp dword ptr (_f)\nfstsw ax\nsahf\nja L14\nfld dword ptr (_f)\nfsub dword ptr (L9)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-76)[ebp],edi\njmp L15\nL14:\nfld dword ptr (_f)\ncall __ftol\nmov edi,eax\nmov dword ptr (-76)[ebp],edi\nL15:\nmov edi,dword ptr (-76)[ebp]\nmov dword ptr (_I),edi\nfld dword ptr (L9)\nfcomp dword ptr (_f)\nfstsw ax\nsahf\nja L17\nfld dword ptr (_f)\nfsub dword ptr (L9)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-80)[ebp],edi\njmp L18\nL17:\nfld dword ptr (_f)\ncall __ftol\nmov edi,eax\nmov dword ptr (-80)[ebp],edi\nL18:\nmov edi,dword ptr (-80)[ebp]\nmov dword ptr (_L),edi\nfld dword ptr (_f)\nfstp qword ptr (-120)[ebp]\nfld qword ptr (-120)[ebp]\nfstp qword ptr (_d)\nfld qword ptr (-120)[ebp]\nfstp qword ptr (_D)\ncall _print\nadd esp,0\nfld qword ptr (L19)\nfstp qword ptr (_d)\nfld qword ptr (_d)\nfstp qword ptr (-144)[ebp]\nfld qword ptr (-144)[ebp]\ncall __ftol\nmov edi,eax\nmov ebx,edi\nmov byte ptr (_c),bl\nmov esi,edi\nmov word ptr (_s),si\nmov dword ptr (_i),edi\nmov dword ptr (_l),edi\nfld qword ptr (L23)\nfcomp qword ptr (-144)[ebp]\nfstsw ax\nsahf\nja L21\nfld qword ptr (-144)[ebp]\nfsub qword ptr (L23)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-124)[ebp],edi\njmp L22\nL21:\nfld qword ptr (-144)[ebp]\ncall __ftol\nmov edi,eax\nmov dword ptr (-124)[ebp],edi\nL22:\nmov edi,dword ptr (-124)[ebp]\nmov ebx,edi\nmov byte ptr (_C),bl\nfld qword ptr (L23)\nfcomp qword ptr (_d)\nfstsw ax\nsahf\nja L25\nfld qword ptr (_d)\nfsub qword ptr (L23)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-128)[ebp],edi\njmp L26\nL25:\nfld qword ptr (_d)\ncall __ftol\nmov edi,eax\nmov dword ptr (-128)[ebp],edi\nL26:\nmov edi,dword ptr (-128)[ebp]\nmov word ptr (_S),di\nfld qword ptr (L23)\nfcomp qword ptr (_d)\nfstsw ax\nsahf\nja L28\nfld qword ptr (_d)\nfsub qword ptr (L23)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-132)[ebp],edi\njmp L29\nL28:\nfld qword ptr (_d)\ncall __ftol\nmov edi,eax\nmov dword ptr (-132)[ebp],edi\nL29:\nmov edi,dword ptr (-132)[ebp]\nmov dword ptr (_I),edi\nfld qword ptr (L23)\nfcomp qword ptr (_d)\nfstsw ax\nsahf\nja L31\nfld qword ptr (_d)\nfsub qword ptr (L23)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-136)[ebp],edi\njmp L32\nL31:\nfld qword ptr (_d)\ncall __ftol\nmov edi,eax\nmov dword ptr (-136)[ebp],edi\nL32:\nmov edi,dword ptr (-136)[ebp]\nmov dword ptr (_L),edi\nfld qword ptr (_d)\nfstp dword ptr (_f)\nfld qword ptr (_d)\nfstp qword ptr (_D)\ncall _print\nadd esp,0\nfld qword ptr (L33)\nfstp qword ptr (_D)\nfld qword ptr (_D)\nfstp qword ptr (-232)[ebp]\nfld qword ptr (-232)[ebp]\ncall __ftol\nmov edi,eax\nmov ebx,edi\nmov byte ptr (_c),bl\nmov esi,edi\nmov word ptr (_s),si\nmov dword ptr (_i),edi\nmov dword ptr (_l),edi\nfld qword ptr (L37)\nfcomp qword ptr (-232)[ebp]\nfstsw ax\nsahf\nja L35\nfld qword ptr (-232)[ebp]\nfsub qword ptr (L37)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-212)[ebp],edi\njmp L36\nL35:\nfld qword ptr (-232)[ebp]\ncall __ftol\nmov edi,eax\nmov dword ptr (-212)[ebp],edi\nL36:\nmov edi,dword ptr (-212)[ebp]\nmov ebx,edi\nmov byte ptr (_C),bl\nfld qword ptr (L37)\nfcomp qword ptr (_D)\nfstsw ax\nsahf\nja L39\nfld qword ptr (_D)\nfsub qword ptr (L37)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-216)[ebp],edi\njmp L40\nL39:\nfld qword ptr (_D)\ncall __ftol\nmov edi,eax\nmov dword ptr (-216)[ebp],edi\nL40:\nmov edi,dword ptr (-216)[ebp]\nmov word ptr (_S),di\nfld qword ptr (L37)\nfcomp qword ptr (_D)\nfstsw ax\nsahf\nja L42\nfld qword ptr (_D)\nfsub qword ptr (L37)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-220)[ebp],edi\njmp L43\nL42:\nfld qword ptr (_D)\ncall __ftol\nmov edi,eax\nmov dword ptr (-220)[ebp],edi\nL43:\nmov edi,dword ptr (-220)[ebp]\nmov dword ptr (_I),edi\nfld qword ptr (L37)\nfcomp qword ptr (_D)\nfstsw ax\nsahf\nja L45\nfld qword ptr (_D)\nfsub qword ptr (L37)\ncall __ftol\nmov edi,eax\nlea edi,(080000000H)[edi]\nmov dword ptr (-224)[ebp],edi\njmp L46\nL45:\nfld qword ptr (_D)\ncall __ftol\nmov edi,eax\nmov dword ptr (-224)[ebp],edi\nL46:\nmov edi,dword ptr (-224)[ebp]\nmov dword ptr (_L),edi\nfld qword ptr (_D)\nfstp dword ptr (_f)\nfld qword ptr (_D)\nfstp qword ptr (_d)\ncall _print\nadd esp,0\nmov dword ptr (_p),0\nmov dword ptr (_p),0\nmov dword ptr (_p),0\nmov dword ptr (_p),0\nmov edi,dword ptr (_P)\nmov dword ptr (_p),edi\nmov dword ptr (_P),0\nmov dword ptr (_P),0\nmov dword ptr (_P),0\nmov dword ptr (_P),0\nmov edi,dword ptr (_p)\nmov dword ptr (_P),edi\nmov eax,0\nL3:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\nextrn _printf:near\n_TEXT segment\n_TEXT ends\n_DATA segment\npublic _P\nalign 4\n_P label byte\ndb 4 dup (0)\npublic _p\nalign 4\n_p label byte\ndb 4 dup (0)\npublic _D\nalign 4\n_D label byte\ndb 8 dup (0)\npublic _d\nalign 4\n_d label byte\ndb 8 dup (0)\npublic _f\nalign 4\n_f label byte\ndb 4 dup (0)\npublic _L\nalign 4\n_L label byte\ndb 4 dup (0)\npublic _I\nalign 4\n_I label byte\ndb 4 dup (0)\npublic _S\nalign 2\n_S label byte\ndb 2 dup (0)\npublic _C\nalign 1\n_C label byte\ndb 1 dup (0)\npublic _l\nalign 4\n_l label byte\ndb 4 dup (0)\npublic _i\nalign 4\n_i label byte\ndb 4 dup (0)\npublic _s\nalign 2\n_s label byte\ndb 2 dup (0)\npublic _c\nalign 1\n_c label byte\ndb 1 dup (0)\n_DATA ends\n_TEXT segment\nalign 4\nL37 label byte\ndd 00H\ndd 041e00000H\nalign 4\nL33 label byte\ndd 00H\ndd 040260000H\nalign 4\nL23 label byte\ndd 00H\ndd 041e00000H\nalign 4\nL19 label byte\ndd 00H\ndd 040240000H\nalign 4\nL9 label byte\ndd 04f000000H\nalign 4\nL5 label byte\ndd 041100000H\nalign 4\nL4 label byte\ndd 00H\ndd 040000000H\nalign 1\nL2 label byte\ndb 37\ndb 100\ndb 32\ndb 37\ndb 100\ndb 32\ndb 37\ndb 100\ndb 32\ndb 37\ndb 108\ndb 100\ndb 32\ndb 37\ndb 117\ndb 32\ndb 37\ndb 117\ndb 32\ndb 37\ndb 117\ndb 32\ndb 37\ndb 108\ndb 117\ndb 32\ndb 37\ndb 102\ndb 32\ndb 37\ndb 102\ndb 32\ndb 37\ndb 108\ndb 102\ndb 10\ndb 0\n_TEXT ends\nend\n"
  },
  {
    "path": "lcc/x86/win32/tst/fields.1bk",
    "content": "x = 1 2 3 4 -3 6\ny = 3 8 9\nx = 1 2 3 0 0 6\ny = 2 8 16\np->a = 0x3, p->b = 0xf\n"
  },
  {
    "path": "lcc/x86/win32/tst/fields.2bk",
    "content": "tst/fields.c:6: warning: initializer exceeds bit-field width\ntst/fields.c:8: warning: initializer exceeds bit-field width\ntst/fields.c:30: warning: missing return value\ntst/fields.c:34: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/win32/tst/fields.sbk",
    "content": ".486\n.model flat\nextrn __fltused:near\nextrn __ftol:near\n_DATA segment\npublic _x\nalign 4\n_x label byte\ndd 1\ndb 2\ndb 3 dup (0)\ndb 03H\ndb 040H\ndb 2 dup (0)\ndb 050H\ndb 6\ndb 2 dup (0)\npublic _i\nalign 4\n_i label byte\ndd 16\npublic _y\nalign 4\n_y label byte\ndb 023H\ndb 3 dup (0)\ndb 09H\ndb 00H\ndb 00H\ndb 00H\npublic _main\n_DATA ends\n_TEXT segment\n_main:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmovsx edi,byte ptr (_x+13)\npush edi\nmov edi,dword ptr (_x+12)\nsal edi,25\nsar edi,29\npush edi\nmov edi,dword ptr (_x+8)\nsal edi,16\nsar edi,28\npush edi\nmov edi,dword ptr (_x+8)\nsal edi,20\nsar edi,20\npush edi\nmovsx edi,byte ptr (_x+4)\npush edi\nmov edi,dword ptr (_x)\npush edi\nlea edi,(L4)\npush edi\ncall _printf\nadd esp,28\nmov edi,dword ptr (_y+4)\npush edi\nmov edi,dword ptr (_y)\nmov esi,edi\nshr esi,2\nand esi,15\npush esi\nand edi,3\npush edi\nlea edi,(L10)\npush edi\ncall _printf\nadd esp,16\nmov edi,dword ptr (_x+8)\nand edi,0ffff0fffH\nmov esi,dword ptr (_i)\nsal esi,28\nsar esi,28\nshl esi,12\nand esi,0f000H\nor edi,esi\nmov dword ptr (_x+8),edi\nmov edi,dword ptr (_x+12)\nand edi,0ffffff8fH\nmov dword ptr (_x+12),edi\nmovsx edi,byte ptr (_x+13)\npush edi\nmov edi,dword ptr (_x+12)\nsal edi,25\nsar edi,29\npush edi\nmov edi,dword ptr (_x+8)\nsal edi,16\nsar edi,28\npush edi\nmov edi,dword ptr (_x+8)\nsal edi,20\nsar edi,20\npush edi\nmovsx edi,byte ptr (_x+4)\npush edi\nmov edi,dword ptr (_x)\npush edi\nlea edi,(L4)\npush edi\ncall _printf\nadd esp,28\nmov edi,dword ptr (_y)\nand edi,0fffffffcH\nor edi,2\nmov dword ptr (_y),edi\nmov edi,dword ptr (_i)\nmov dword ptr (_y+4),edi\nmov edi,dword ptr (_y+4)\npush edi\nmov edi,dword ptr (_y)\nmov esi,edi\nshr esi,2\nand esi,15\npush esi\nand edi,3\npush edi\nlea edi,(L10)\npush edi\ncall _printf\nadd esp,16\nlea edi,(_x)\npush edi\ncall _f2\nadd esp,4\nmov eax,0\nL3:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _f1\n_f1:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov edi,dword ptr (20)[ebp]\nand dword ptr [edi],0ffffffc3H\nmov edi,dword ptr (20)[ebp]\nmov esi,dword ptr [edi]\nand esi,0fffffffcH\nmov ebx,0\nand ebx,3\nand ebx,3\nor esi,ebx\nmov dword ptr [edi],esi\nmov edi,dword ptr (20)[ebp]\nmov edi,dword ptr [edi]\nand edi,60\ncmp edi,0\nje L22\nlea edi,(L24)\npush edi\ncall _printf\nadd esp,4\nL22:\nmov edi,dword ptr (20)[ebp]\nor dword ptr [edi],3\nmov edi,dword ptr (20)[ebp]\nor dword ptr [edi],60\nmov edi,dword ptr (20)[ebp]\nmov edi,dword ptr [edi]\nmov esi,edi\nshr esi,2\nand esi,15\npush esi\nand edi,3\npush edi\nlea edi,(L25)\npush edi\ncall _printf\nadd esp,12\nmov eax,0\nL21:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _f2\n_f2:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\ncmp dword ptr (_i),0\njne L28\nmov dword ptr (-4)[ebp],1\njmp L29\nL28:\nmov dword ptr (-4)[ebp],0\nL29:\nmov edi,dword ptr (20)[ebp]\nmov esi,dword ptr [edi]\nand esi,0fffffffcH\nmov ebx,dword ptr (-4)[ebp]\nand ebx,3\nand ebx,3\nor esi,ebx\nmov dword ptr [edi],esi\nmov edi,dword ptr (20)[ebp]\npush edi\ncall _f1\nadd esp,4\nmov esi,dword ptr [edi]\nand esi,0ffffffc3H\nmov ebx,0\nand ebx,15\nlea ebx,[ebx*4]\nand ebx,60\nor esi,ebx\nmov dword ptr [edi],esi\nmov eax,0\nL26:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\nextrn _printf:near\n_TEXT segment\n_TEXT ends\n_TEXT segment\nalign 1\nL25 label byte\ndb 112\ndb 45\ndb 62\ndb 97\ndb 32\ndb 61\ndb 32\ndb 48\ndb 120\ndb 37\ndb 120\ndb 44\ndb 32\ndb 112\ndb 45\ndb 62\ndb 98\ndb 32\ndb 61\ndb 32\ndb 48\ndb 120\ndb 37\ndb 120\ndb 10\ndb 0\nalign 1\nL24 label byte\ndb 112\ndb 45\ndb 62\ndb 98\ndb 32\ndb 33\ndb 61\ndb 32\ndb 48\ndb 33\ndb 10\ndb 0\nalign 1\nL10 label byte\ndb 121\ndb 32\ndb 61\ndb 32\ndb 37\ndb 100\ndb 32\ndb 37\ndb 100\ndb 32\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL4 label byte\ndb 120\ndb 32\ndb 61\ndb 32\ndb 37\ndb 100\ndb 32\ndb 37\ndb 100\ndb 32\ndb 37\ndb 100\ndb 32\ndb 37\ndb 100\ndb 32\ndb 37\ndb 100\ndb 32\ndb 37\ndb 100\ndb 10\ndb 0\n_TEXT ends\nend\n"
  },
  {
    "path": "lcc/x86/win32/tst/front.2bk",
    "content": "tst/front.c:3: warning: missing return value\ntst/front.c:10: warning: missing return value\ntst/front.c:20: type error in argument 1 to `s'; found `pointer to struct D' expected `pointer to incomplete struct D defined at tst/front.c:14'\ntst/front.c:21: warning: missing return value\ntst/front.c:32: warning: missing return value\ntst/front.c:36: operands of = have illegal types `pointer to int' and `pointer to const int'\ntst/front.c:38: warning: missing return value\ntst/front.c:62: operands of = have illegal types `pointer to char' and `pointer to const void'\ntst/front.c:63: warning: missing return value\ntst/front.c:68: warning: missing return value\ntst/front.c:69: warning: inconsistent linkage for `yy' previously declared at tst/front.c:68\ntst/front.c:69: warning: missing return value\ntst/front.c:71: invalid storage class `static' for `int function goo'\ntst/front.c:71: warning: declaration of `goo' does not match previous declaration at tst/front.c:70\ntst/front.c:71: warning: missing return value\ntst/front.c:74: warning: declaration of `xr' does not match previous declaration at tst/front.c:72\ntst/front.c:74: warning: missing return value\ntst/front.c:81: warning: missing return value\ntst/front.c:82: warning: declaration of `ss2' does not match previous declaration at tst/front.c:81\ntst/front.c:84: warning: inconsistent linkage for `ss5' previously declared at tst/front.c:80\ntst/front.c:92: type error in argument 1 to `gx1'; found `pointer to double' expected `double'\ntst/front.c:92: warning: missing return value\ntst/front.c:95: redeclaration of `hx1' previously declared at tst/front.c:94\ntst/front.c:98: warning: missing return value\ntst/front.c:101: conflicting argument declarations for function `gg1'\ntst/front.c:101: warning: missing return value\ntst/front.c:112: type error in argument 4 to `qsort'; found `pointer to int function(pointer to pointer to char,pointer to pointer to char)' expected `pointer to int function(pointer to const void,pointer to const void)'\ntst/front.c:113: warning: missing return value\ntst/front.c:120: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/win32/tst/front.sbk",
    "content": ".486\n.model flat\nextrn __fltused:near\nextrn __ftol:near\npublic _main\n_TEXT segment\n_main:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\npush 0\ncall _exit\nadd esp,4\nmov eax,0\nL1:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _nested\n_nested:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\ncmp dword ptr (20)[ebp],4\njge L6\ncmp dword ptr (24)[ebp],114\nje L9\nL6:\ncmp dword ptr (20)[ebp],1\njne L8\nmov edi,dword ptr (24)[ebp]\ncmp edi,104\nje L9\ncmp edi,105\nje L9\nL8:\ncmp dword ptr (20)[ebp],2\njne L3\nmov edi,dword ptr (24)[ebp]\ncmp edi,111\nje L9\ncmp edi,121\njne L3\nL9:\nmov edi,dword ptr (24)[ebp]\nmov dword ptr (20)[ebp],edi\nL3:\nmov eax,0\nL2:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _s\n_s:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nL10:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\npublic _Dy\nalign 4\n_Dy label byte\ndd 0\ndb 4 dup (0)\npublic _Dz\nalign 4\n_Dz label byte\ndd 1\ndb 4 dup (0)\npublic _Dfunc\n_DATA ends\n_TEXT segment\n_Dfunc:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _f\n_f:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _f1\n_f1:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _f2\n_f2:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _g\n_g:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _h\n_h:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _h1\n_h1:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _h2\n_h2:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 4\nL21 label byte\ndd 1\npublic _set1\n_DATA ends\n_TEXT segment\n_set1:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 4\nL23 label byte\ndd 2\npublic _set2\n_DATA ends\n_TEXT segment\n_set2:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_goo:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _sss\n_sss:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 4\nL27 label byte\ndb 4 dup (0)\npublic _rrr\n_DATA ends\n_TEXT segment\n_rrr:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _setstatic\n_setstatic:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _gx1\n_gx1:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _ff1\n_ff1:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _gg1\n_gg1:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _hh1\n_hh1:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _cmp\n_cmp:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _sort\n_sort:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _onearg\n_onearg:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\nextrn _exit:near\n_TEXT segment\n_TEXT ends\nextrn _qsort:near\n_TEXT segment\n_TEXT ends\nextrn _strcmp:near\n_TEXT segment\n_TEXT ends\n_DATA segment\npublic _ss4\nalign 4\n_ss4 label byte\ndb 4 dup (0)\nalign 4\n_ss2 label byte\ndb 4 dup (0)\nalign 4\n_ss5 label byte\ndb 4 dup (0)\npublic _ss3\nalign 4\n_ss3 label byte\ndb 4 dup (0)\nalign 4\n_ss1 label byte\ndb 4 dup (0)\nalign 4\n_yy label byte\ndb 4 dup (0)\npublic _z\nalign 4\n_z label byte\ndb 4 dup (0)\npublic _y\nalign 4\n_y label byte\ndb 4 dup (0)\npublic _x\nalign 4\n_x label byte\ndb 4 dup (0)\npublic _b\nalign 4\n_b label byte\ndb 4 dup (0)\npublic _a\nalign 4\n_a label byte\ndb 4 dup (0)\n_DATA ends\nend\n"
  },
  {
    "path": "lcc/x86/win32/tst/incr.1bk",
    "content": ""
  },
  {
    "path": "lcc/x86/win32/tst/incr.2bk",
    "content": "tst/incr.c:1: warning: missing return value\ntst/incr.c:6: warning: expression with no effect elided\ntst/incr.c:6: warning: expression with no effect elided\ntst/incr.c:11: warning: missing return value\ntst/incr.c:16: warning: expression with no effect elided\ntst/incr.c:16: warning: expression with no effect elided\ntst/incr.c:21: warning: missing return value\ntst/incr.c:30: warning: missing return value\ntst/incr.c:39: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/win32/tst/incr.sbk",
    "content": ".486\n.model flat\nextrn __fltused:near\nextrn __ftol:near\npublic _main\n_TEXT segment\n_main:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov eax,0\nL1:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _memchar\n_memchar:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,8\nmov edi,dword ptr (-8)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-8)[ebp],esi\nmov bl,byte ptr [edi]\nmov byte ptr (-1)[ebp],bl\nmov edi,dword ptr (-8)[ebp]\nlea edi,(1)[edi]\nmov dword ptr (-8)[ebp],edi\nmov bl,byte ptr [edi]\nmov byte ptr (-1)[ebp],bl\nmov edi,dword ptr (-8)[ebp]\nlea esi,(-1)[edi]\nmov dword ptr (-8)[ebp],esi\nmov bl,byte ptr [edi]\nmov byte ptr (-1)[ebp],bl\nmov edi,dword ptr (-8)[ebp]\nlea edi,(-1)[edi]\nmov dword ptr (-8)[ebp],edi\nmov bl,byte ptr [edi]\nmov byte ptr (-1)[ebp],bl\nmov eax,0\nL2:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _memint\n_memint:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,8\nmov edi,dword ptr (-8)[ebp]\nlea esi,(4)[edi]\nmov dword ptr (-8)[ebp],esi\nmov edi,dword ptr [edi]\nmov dword ptr (-4)[ebp],edi\nmov edi,dword ptr (-8)[ebp]\nlea edi,(4)[edi]\nmov dword ptr (-8)[ebp],edi\nmov edi,dword ptr [edi]\nmov dword ptr (-4)[ebp],edi\nmov edi,dword ptr (-8)[ebp]\nlea esi,(-4)[edi]\nmov dword ptr (-8)[ebp],esi\nmov edi,dword ptr [edi]\nmov dword ptr (-4)[ebp],edi\nmov edi,dword ptr (-8)[ebp]\nlea edi,(-4)[edi]\nmov dword ptr (-8)[ebp],edi\nmov edi,dword ptr [edi]\nmov dword ptr (-4)[ebp],edi\nmov eax,0\nL3:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _regchar\n_regchar:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,8\nmov edi,dword ptr (-8)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-8)[ebp],esi\nmov bl,byte ptr [edi]\nmov byte ptr (-1)[ebp],bl\nmov edi,dword ptr (-8)[ebp]\nlea edi,(1)[edi]\nmov dword ptr (-8)[ebp],edi\nmov bl,byte ptr [edi]\nmov byte ptr (-1)[ebp],bl\nmov edi,dword ptr (-8)[ebp]\nlea esi,(-1)[edi]\nmov dword ptr (-8)[ebp],esi\nmov bl,byte ptr [edi]\nmov byte ptr (-1)[ebp],bl\nmov edi,dword ptr (-8)[ebp]\nlea edi,(-1)[edi]\nmov dword ptr (-8)[ebp],edi\nmov bl,byte ptr [edi]\nmov byte ptr (-1)[ebp],bl\nmov eax,0\nL4:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _regint\n_regint:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,8\nmov edi,dword ptr (-8)[ebp]\nlea esi,(4)[edi]\nmov dword ptr (-8)[ebp],esi\nmov edi,dword ptr [edi]\nmov dword ptr (-4)[ebp],edi\nmov edi,dword ptr (-8)[ebp]\nlea edi,(4)[edi]\nmov dword ptr (-8)[ebp],edi\nmov edi,dword ptr [edi]\nmov dword ptr (-4)[ebp],edi\nmov edi,dword ptr (-8)[ebp]\nlea esi,(-4)[edi]\nmov dword ptr (-8)[ebp],esi\nmov edi,dword ptr [edi]\nmov dword ptr (-4)[ebp],edi\nmov edi,dword ptr (-8)[ebp]\nlea edi,(-4)[edi]\nmov dword ptr (-8)[ebp],edi\nmov edi,dword ptr [edi]\nmov dword ptr (-4)[ebp],edi\nmov eax,0\nL5:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\nend\n"
  },
  {
    "path": "lcc/x86/win32/tst/init.1bk",
    "content": " 1 2 3 4\n 5 6\n 7\nif\nfor\nelse\nwhile\n1 2 3 if\n4 5 0 for\n6 7 8 else\n9 10 11 while\n1 2 3 if\n4 5 0 for\n6 7 8 else\n9 10 11 while\n0 0 0 \n"
  },
  {
    "path": "lcc/x86/win32/tst/init.2bk",
    "content": "tst/init.c:36: warning: missing return value\ntst/init.c:49: warning: missing return value\ntst/init.c:59: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/win32/tst/init.sbk",
    "content": ".486\n.model flat\nextrn __fltused:near\nextrn __ftol:near\n_DATA segment\npublic _words\nalign 4\n_words label byte\ndd 1\ndd 2\ndd 3\ndb 105\ndb 102\ndb 0\ndb 3 dup (0)\ndb 2 dup (0)\ndd 4\ndd 5\ndb 4 dup (0)\ndb 102\ndb 111\ndb 114\ndb 3 dup (0)\ndb 2 dup (0)\ndd 6\ndd 7\ndd 8\ndb 101\ndb 108\ndb 115\ndb 101\ndb 0\ndb 1 dup (0)\ndb 2 dup (0)\ndd 9\ndd 10\ndd 11\ndb 119\ndb 104\ndb 105\ndb 108\ndb 101\ndb 1 dup (0)\ndb 2 dup (0)\ndd 0\ndb 8 dup (0)\ndb 8 dup (0)\npublic _wordlist\nalign 4\n_wordlist label byte\ndd _words\npublic _x\nalign 4\n_x label byte\ndd 1\ndd 2\ndd 3\ndd 4\ndd 0\ndd 5\ndd 6\ndb 12 dup (0)\ndd 7\ndb 16 dup (0)\npublic _y\nalign 4\n_y label byte\ndd _x\ndd _x+20\ndd _x+40\ndd 00H\npublic _main\n_DATA ends\n_TEXT segment\n_main:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,8\nmov dword ptr (-8)[ebp],0\njmp L8\nL5:\nmov dword ptr (-4)[ebp],0\njmp L12\nL9:\nmov edi,dword ptr (-4)[ebp]\nmov esi,dword ptr (-8)[ebp]\nmov esi,dword ptr (_y)[esi*4]\nmov edi,dword ptr [esi][edi*4]\npush edi\nlea edi,(L13)\npush edi\ncall _printf\nadd esp,8\nL10:\ninc dword ptr (-4)[ebp]\nL12:\nmov edi,dword ptr (-4)[ebp]\nmov esi,dword ptr (-8)[ebp]\nmov esi,dword ptr (_y)[esi*4]\ncmp dword ptr [esi][edi*4],0\njne L9\nlea edi,(L14)\npush edi\ncall _printf\nadd esp,4\nL6:\ninc dword ptr (-8)[ebp]\nL8:\nmov edi,dword ptr (-8)[ebp]\nmov edi,dword ptr (_y)[edi*4]\ncmp edi,0\njne L5\ncall _f\nadd esp,0\nmov edi,dword ptr (_wordlist)\npush edi\ncall _g\nadd esp,4\nmov eax,0\nL4:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 4\nL16 label byte\ndd L17\ndd L18\ndd L19\ndd L20\ndd 00H\npublic _f\n_DATA ends\n_TEXT segment\n_f:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\nlea edi,(L16)\nmov dword ptr (-4)[ebp],edi\njmp L24\nL21:\nmov edi,dword ptr (-4)[ebp]\nmov edi,dword ptr [edi]\npush edi\nlea edi,(L25)\npush edi\ncall _printf\nadd esp,8\nL22:\nmov edi,dword ptr (-4)[ebp]\nlea edi,(4)[edi]\nmov dword ptr (-4)[ebp],edi\nL24:\nmov edi,dword ptr (-4)[ebp]\nmov edi,dword ptr [edi]\ncmp edi,0\njne L21\nmov eax,0\nL15:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _g\n_g:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\njmp L30\nL27:\nmov dword ptr (-4)[ebp],0\njmp L34\nL31:\nmov edi,dword ptr (-4)[ebp]\nmov esi,dword ptr (20)[ebp]\nmov edi,dword ptr [esi][edi*4]\npush edi\nlea edi,(L35)\npush edi\ncall _printf\nadd esp,8\nL32:\ninc dword ptr (-4)[ebp]\nL34:\nmov edi,dword ptr (-4)[ebp]\ncmp edi,3\njb L31\nmov edi,dword ptr (20)[ebp]\nlea edi,(12)[edi]\npush edi\nlea edi,(L25)\npush edi\ncall _printf\nadd esp,8\nL28:\nmov edi,dword ptr (20)[ebp]\nlea edi,(20)[edi]\nmov dword ptr (20)[ebp],edi\nL30:\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr [edi],0\njne L27\ncall _h\nadd esp,0\nmov eax,0\nL26:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _h\n_h:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\nmov dword ptr (-4)[ebp],0\njmp L40\nL37:\nimul edi,dword ptr (-4)[ebp],20\nlea esi,(_words+12)[edi]\npush esi\nmov esi,dword ptr (_words+8)[edi]\npush esi\nmov esi,dword ptr (_words+4)[edi]\npush esi\nmov edi,dword ptr (_words)[edi]\npush edi\nlea edi,(L41)\npush edi\ncall _printf\nadd esp,20\nL38:\ninc dword ptr (-4)[ebp]\nL40:\nmov edi,dword ptr (-4)[ebp]\ncmp edi,5\njb L37\nmov eax,0\nL36:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\nextrn _printf:near\n_TEXT segment\n_TEXT ends\n_TEXT segment\nalign 1\nL41 label byte\ndb 37\ndb 100\ndb 32\ndb 37\ndb 100\ndb 32\ndb 37\ndb 100\ndb 32\ndb 37\ndb 115\ndb 10\ndb 0\nalign 1\nL35 label byte\ndb 37\ndb 100\ndb 32\ndb 0\nalign 1\nL25 label byte\ndb 37\ndb 115\ndb 10\ndb 0\nalign 1\nL20 label byte\ndb 119\ndb 104\ndb 105\ndb 108\ndb 101\ndb 0\nalign 1\nL19 label byte\ndb 101\ndb 108\ndb 115\ndb 101\ndb 0\nalign 1\nL18 label byte\ndb 102\ndb 111\ndb 114\ndb 0\nalign 1\nL17 label byte\ndb 105\ndb 102\ndb 0\nalign 1\nL14 label byte\ndb 10\ndb 0\nalign 1\nL13 label byte\ndb 32\ndb 37\ndb 100\ndb 0\n_TEXT ends\nend\n"
  },
  {
    "path": "lcc/x86/win32/tst/limits.1bk",
    "content": "UCHAR_MAX:\t000000ff=255\nUSHRT_MAX:\t0000ffff=65535\nUINT_MAX:\tffffffff=-1\nULONG_MAX:\tffffffff=-1\nCHAR_MAX:\t0000007f=127\nSCHAR_MAX:\t0000007f=127\nSHRT_MAX:\t00007fff=32767\nINT_MAX:\t7fffffff=2147483647\nLONG_MAX:\t7fffffff=2147483647\nCHAR_MIN:\tffffff80=-128\nSCHAR_MIN:\tffffff80=-128\nSHRT_MIN:\tffff8000=-32768\nINT_MIN:\t80000000=-2147483648\nLONG_MIN:\t80000000=-2147483648\n"
  },
  {
    "path": "lcc/x86/win32/tst/limits.2bk",
    "content": ""
  },
  {
    "path": "lcc/x86/win32/tst/limits.sbk",
    "content": ".486\n.model flat\nextrn __fltused:near\nextrn __ftol:near\npublic _main\n_TEXT segment\n_main:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\npush 255\npush 255\nlea edi,(L2)\npush edi\ncall _printf\nadd esp,12\npush 65535\npush 65535\nlea edi,(L3)\npush edi\ncall _printf\nadd esp,12\npush 0ffffffffH\npush 0ffffffffH\nlea edi,(L4)\npush edi\ncall _printf\nadd esp,12\npush 0ffffffffH\npush 0ffffffffH\nlea edi,(L5)\npush edi\ncall _printf\nadd esp,12\npush 127\npush 127\nlea edi,(L6)\npush edi\ncall _printf\nadd esp,12\npush 127\npush 127\nlea edi,(L7)\npush edi\ncall _printf\nadd esp,12\npush 32767\npush 32767\nlea edi,(L8)\npush edi\ncall _printf\nadd esp,12\npush 2147483647\npush 2147483647\nlea edi,(L9)\npush edi\ncall _printf\nadd esp,12\npush 2147483647\npush 2147483647\nlea edi,(L10)\npush edi\ncall _printf\nadd esp,12\npush -128\npush -128\nlea edi,(L11)\npush edi\ncall _printf\nadd esp,12\npush -128\npush -128\nlea edi,(L12)\npush edi\ncall _printf\nadd esp,12\npush -32768\npush -32768\nlea edi,(L13)\npush edi\ncall _printf\nadd esp,12\npush -2147483648\npush -2147483648\nlea edi,(L14)\npush edi\ncall _printf\nadd esp,12\npush -2147483648\npush -2147483648\nlea edi,(L15)\npush edi\ncall _printf\nadd esp,12\nmov eax,0\nL1:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\nextrn _printf:near\n_TEXT segment\n_TEXT ends\n_TEXT segment\nalign 1\nL15 label byte\ndb 76\ndb 79\ndb 78\ndb 71\ndb 95\ndb 77\ndb 73\ndb 78\ndb 58\ndb 9\ndb 37\ndb 48\ndb 56\ndb 108\ndb 120\ndb 61\ndb 37\ndb 108\ndb 100\ndb 10\ndb 0\nalign 1\nL14 label byte\ndb 73\ndb 78\ndb 84\ndb 95\ndb 77\ndb 73\ndb 78\ndb 58\ndb 9\ndb 37\ndb 48\ndb 56\ndb 120\ndb 61\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL13 label byte\ndb 83\ndb 72\ndb 82\ndb 84\ndb 95\ndb 77\ndb 73\ndb 78\ndb 58\ndb 9\ndb 37\ndb 48\ndb 56\ndb 120\ndb 61\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL12 label byte\ndb 83\ndb 67\ndb 72\ndb 65\ndb 82\ndb 95\ndb 77\ndb 73\ndb 78\ndb 58\ndb 9\ndb 37\ndb 48\ndb 56\ndb 120\ndb 61\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL11 label byte\ndb 67\ndb 72\ndb 65\ndb 82\ndb 95\ndb 77\ndb 73\ndb 78\ndb 58\ndb 9\ndb 37\ndb 48\ndb 56\ndb 120\ndb 61\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL10 label byte\ndb 76\ndb 79\ndb 78\ndb 71\ndb 95\ndb 77\ndb 65\ndb 88\ndb 58\ndb 9\ndb 37\ndb 48\ndb 56\ndb 108\ndb 120\ndb 61\ndb 37\ndb 108\ndb 100\ndb 10\ndb 0\nalign 1\nL9 label byte\ndb 73\ndb 78\ndb 84\ndb 95\ndb 77\ndb 65\ndb 88\ndb 58\ndb 9\ndb 37\ndb 48\ndb 56\ndb 120\ndb 61\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL8 label byte\ndb 83\ndb 72\ndb 82\ndb 84\ndb 95\ndb 77\ndb 65\ndb 88\ndb 58\ndb 9\ndb 37\ndb 48\ndb 56\ndb 120\ndb 61\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL7 label byte\ndb 83\ndb 67\ndb 72\ndb 65\ndb 82\ndb 95\ndb 77\ndb 65\ndb 88\ndb 58\ndb 9\ndb 37\ndb 48\ndb 56\ndb 120\ndb 61\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL6 label byte\ndb 67\ndb 72\ndb 65\ndb 82\ndb 95\ndb 77\ndb 65\ndb 88\ndb 58\ndb 9\ndb 37\ndb 48\ndb 56\ndb 120\ndb 61\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL5 label byte\ndb 85\ndb 76\ndb 79\ndb 78\ndb 71\ndb 95\ndb 77\ndb 65\ndb 88\ndb 58\ndb 9\ndb 37\ndb 48\ndb 56\ndb 108\ndb 120\ndb 61\ndb 37\ndb 108\ndb 100\ndb 10\ndb 0\nalign 1\nL4 label byte\ndb 85\ndb 73\ndb 78\ndb 84\ndb 95\ndb 77\ndb 65\ndb 88\ndb 58\ndb 9\ndb 37\ndb 48\ndb 56\ndb 120\ndb 61\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL3 label byte\ndb 85\ndb 83\ndb 72\ndb 82\ndb 84\ndb 95\ndb 77\ndb 65\ndb 88\ndb 58\ndb 9\ndb 37\ndb 48\ndb 56\ndb 120\ndb 61\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL2 label byte\ndb 85\ndb 67\ndb 72\ndb 65\ndb 82\ndb 95\ndb 77\ndb 65\ndb 88\ndb 58\ndb 9\ndb 37\ndb 48\ndb 56\ndb 120\ndb 61\ndb 37\ndb 100\ndb 10\ndb 0\n_TEXT ends\nend\n"
  },
  {
    "path": "lcc/x86/win32/tst/paranoia.1bk",
    "content": "Lest this program stop prematurely, i.e. before displaying\n\n    `END OF TEST',\n\ntry to persuade the computer NOT to terminate execution when an\nerror like Over/Underflow or Division by Zero occurs, but rather\nto persevere with a surrogate value after, perhaps, displaying some\nwarning.  If persuasion avails naught, don't despair but run this\nprogram anyway to see how many milestones it passes, and then\namend it to make further progress.\n\nAnswer questions with Y, y, N or n (unless otherwise indicated).\n\n\nDiagnosis resumes after milestone Number 0          Page: 1\n\nUsers are invited to help debug and augment this program so it will\ncope with unanticipated and newly uncovered arithmetic pathologies.\n\nPlease send suggestions and interesting results to\n\tRichard Karpinski\n\tComputer Center U-76\n\tUniversity of California\n\tSan Francisco, CA 94143-0704, USA\n\nIn doing so, please include the following information:\n\tPrecision:\tdouble;\n\tVersion:\t10 February 1989;\n\tComputer:\n\n\tCompiler:\n\n\tOptimization level:\n\n\tOther relevant compiler options:\n\nDiagnosis resumes after milestone Number 1          Page: 2\n\nRunning this program should reveal these characteristics:\n     Radix = 1, 2, 4, 8, 10, 16, 100, 256 ...\n     Precision = number of significant digits carried.\n     U2 = Radix/Radix^Precision = One Ulp\n\t(OneUlpnit in the Last Place) of 1.000xxx .\n     U1 = 1/Radix^Precision = One Ulp of numbers a little less than 1.0 .\n     Adequacy of guard digits for Mult., Div. and Subt.\n     Whether arithmetic is chopped, correctly rounded, or something else\n\tfor Mult., Div., Add/Subt. and Sqrt.\n     Whether a Sticky Bit used correctly for rounding.\n     UnderflowThreshold = an underflow threshold.\n     E0 and PseudoZero tell whether underflow is abrupt, gradual, or fuzzy.\n     V = an overflow threshold, roughly.\n     V0  tells, roughly, whether  Infinity  is represented.\n     Comparisions are checked for consistency with subtraction\n\tand for contamination with pseudo-zeros.\n     Sqrt is tested.  Y^X is not tested.\n     Extra-precise subexpressions are revealed but NOT YET tested.\n     Decimal-Binary conversion is NOT YET tested for accuracy.\n\nDiagnosis resumes after milestone Number 2          Page: 3\n\nThe program attempts to discriminate among\n   FLAWs, like lack of a sticky bit,\n   Serious DEFECTs, like lack of a guard digit, and\n   FAILUREs, like 2+2 == 5 .\nFailures may confound subsequent diagnoses.\n\nThe diagnostic capabilities of this program go beyond an earlier\nprogram called `MACHAR', which can be found at the end of the\nbook  `Software Manual for the Elementary Functions' (1980) by\nW. J. Cody and W. Waite. Although both programs try to discover\nthe Radix, Precision and range (over/underflow thresholds)\nof the arithmetic, this program tries to cope with a wider variety\nof pathologies, and to say how well the arithmetic is implemented.\n\nThe program is based upon a conventional radix representation for\nfloating-point numbers, but also allows logarithmic encoding\nas used by certain early WANG machines.\n\nBASIC version of this program (C) 1983 by Prof. W. M. Kahan;\nsee source comments for more history.\n\nDiagnosis resumes after milestone Number 3          Page: 4\n\nProgram is now RUNNING tests on small integers:\n-1, 0, 1/2, 1, 2, 3, 4, 5, 9, 27, 32 & 240 are O.K.\n\nSearching for Radix and Precision.\nRadix = 2.000000 .\nClosest relative separation found is U1 = 1.1102230e-016 .\n\nRecalculating radix and precision\n confirms closest relative separation U1 .\nRadix confirmed.\nThe number of significant digits of the Radix is 53.000000 .\n\nDiagnosis resumes after milestone Number 30          Page: 5\n\nSubtraction appears to be normalized, as it should be.\nChecking for guard digit in *, /, and -.\n     *, /, and - appear to have guard digits, as they should.\n\nDiagnosis resumes after milestone Number 40          Page: 6\n\nChecking rounding on multiply, divide and add/subtract.\nMultiplication appears to round correctly.\nDivision appears to round correctly.\nAddition/Subtraction appears to round correctly.\nChecking for sticky bit.\nSticky bit apparently used correctly.\n\nDoes Multiplication commute?  Testing on 20 random pairs.\n     No failures found in 20 integer pairs.\n\nRunning test of square root(x).\nTesting if sqrt(X * X) == X for 20 Integers X.\nTest for sqrt monotonicity.\nsqrt has passed a test for Monotonicity.\nTesting whether sqrt is rounded or chopped.\nSquare root appears to be correctly rounded.\n\nDiagnosis resumes after milestone Number 90          Page: 7\n\nTesting powers Z^i for small Integers Z and i.\n... no discrepancis found.\n\nSeeking Underflow thresholds UfThold and E0.\nSmallest strictly positive number found is E0 = 4.94066e-324 .\nSince comparison denies Z = 0, evaluating (Z + Z) / Z should be safe.\nWhat the machine gets for (Z + Z) / Z is  2.00000000000000000e+000 .\nThis is O.K., provided Over/Underflow has NOT just been signaled.\nUnderflow is gradual; it incurs Absolute Error =\n(roundoff in UfThold) < E0.\nThe Underflow threshold is 2.22507385850720190e-308,  below which\ncalculation may suffer larger Relative error than merely roundoff.\nSince underflow occurs below the threshold\nUfThold = (2.00000000000000000e+000) ^ (-1.02200000000000000e+003)\nonly underflow should afflict the expression\n\t(2.00000000000000000e+000) ^ (-1.02200000000000000e+003);\nactually calculating yields: 0.00000000000000000e+000 .\nThis computed value is O.K.\n\nTesting X^((X + 1) / (X - 1)) vs. exp(2) = 7.38905609893065220e+000 as X -> 1.\nAccuracy seems adequate.\nTesting powers Z^Q at four nearly extreme values.\n ... no discrepancies found.\n\n\nDiagnosis resumes after milestone Number 160          Page: 8\n\nSearching for Overflow threshold:\nThis may generate an error.\nCan `Z = -Y' overflow?\nTrying it on Y = -1.#INF0000000000000e+000 .\nSeems O.K.\nOverflow threshold is V  = 1.79769313486231570e+308 .\nOverflow saturates at V0 = 1.#INF0000000000000e+000 .\nNo Overflow should be signaled for V * 1 = 1.79769313486231570e+308\n                           nor for V / 1 = 1.79769313486231570e+308 .\nAny overflow signal separating this * from the one\nabove is a DEFECT.\n\n\nDiagnosis resumes after milestone Number 190          Page: 9\n\n\nWhat message and/or values does Division by Zero produce?\n    Trying to compute 1 / 0 produces ...  1.#INF000e+000 .\n\n    Trying to compute 0 / 0 produces ...  -1.#IND000e+000 .\n\nDiagnosis resumes after milestone Number 220          Page: 10\n\n\n\nNo failures, defects nor flaws have been discovered.\nRounding appears to conform to the proposed IEEE standard P754,\nexcept for possibly Double Rounding during Gradual Underflow.\nThe arithmetic diagnosed appears to be Excellent!\nEND OF TEST.\n"
  },
  {
    "path": "lcc/x86/win32/tst/paranoia.2bk",
    "content": "tst/paranoia.c:1867: warning: missing return value\ntst/paranoia.c:1874: warning: missing return value\ntst/paranoia.c:1884: warning: missing return value\ntst/paranoia.c:1924: warning: missing return value\ntst/paranoia.c:1939: warning: missing return value\ntst/paranoia.c:1956: warning: missing return value\ntst/paranoia.c:1975: warning: missing return value\ntst/paranoia.c:1988: warning: missing return value\ntst/paranoia.c:1995: warning: missing return value\ntst/paranoia.c:2055: warning: missing return value\ntst/paranoia.c:2062: warning: missing return value\ntst/paranoia.c:2070: warning: missing return value\ntst/paranoia.c:2087: warning: missing return value\ntst/paranoia.c:2115: warning: missing return value\ntst/paranoia.c:2144: warning: missing return value\ntst/paranoia.c:2173: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/win32/tst/paranoia.sbk",
    "content": ".486\n.model flat\nextrn __fltused:near\nextrn __ftol:near\n_DATA segment\npublic _Zero\nalign 4\n_Zero label byte\ndd 00H\ndd 00H\npublic _Half\nalign 4\n_Half label byte\ndd 00H\ndd 03fe00000H\npublic _One\nalign 4\n_One label byte\ndd 00H\ndd 03ff00000H\npublic _Two\nalign 4\n_Two label byte\ndd 00H\ndd 040000000H\npublic _Three\nalign 4\n_Three label byte\ndd 00H\ndd 040080000H\npublic _Four\nalign 4\n_Four label byte\ndd 00H\ndd 040100000H\npublic _Five\nalign 4\n_Five label byte\ndd 00H\ndd 040140000H\npublic _Eight\nalign 4\n_Eight label byte\ndd 00H\ndd 040200000H\npublic _Nine\nalign 4\n_Nine label byte\ndd 00H\ndd 040220000H\npublic _TwentySeven\nalign 4\n_TwentySeven label byte\ndd 00H\ndd 0403b0000H\npublic _ThirtyTwo\nalign 4\n_ThirtyTwo label byte\ndd 00H\ndd 040400000H\npublic _TwoForty\nalign 4\n_TwoForty label byte\ndd 00H\ndd 0406e0000H\npublic _MinusOne\nalign 4\n_MinusOne label byte\ndd 00H\ndd 0bff00000H\npublic _OneAndHalf\nalign 4\n_OneAndHalf label byte\ndd 00H\ndd 03ff80000H\npublic _NoTrials\nalign 4\n_NoTrials label byte\ndd 20\npublic _sigfpe\n_DATA ends\n_TEXT segment\n_sigfpe:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\ninc dword ptr (_fpecount)\nlea edi,(L2)\npush edi\ncall _printf\nadd esp,4\nlea edi,(__iob+32)\npush edi\ncall _fflush\nadd esp,4\nmov edi,dword ptr (_sigsave)\ncmp edi,0\nje L4\nmov edi,dword ptr (_sigsave)\npush edi\npush 8\ncall _signal\nadd esp,8\nmov dword ptr (_sigsave),0\npush 1\nlea edi,(_ovfl_buf)\npush edi\ncall _longjmp\nadd esp,8\nL4:\ncall _abort\nadd esp,0\nL1:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 4\nL757 label byte\ndd L758\ndd L759\ndd L760\ndd L761\npublic _main\n_DATA ends\n_TEXT segment\n_main:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,1684\nfld qword ptr (L7)\nfstp qword ptr (_Zero)\nfld qword ptr (L8)\nfstp qword ptr (_One)\nfld qword ptr (_One)\nfstp qword ptr (-8)[ebp]\nfld qword ptr (-8)[ebp]\nfadd qword ptr (-8)[ebp]\nfstp qword ptr (_Two)\nfld qword ptr (_Two)\nfstp qword ptr (-16)[ebp]\nfld qword ptr (-16)[ebp]\nfadd qword ptr (-8)[ebp]\nfstp qword ptr (_Three)\nfld qword ptr (_Three)\nfstp qword ptr (-24)[ebp]\nfld qword ptr (-24)[ebp]\nfadd qword ptr (-8)[ebp]\nfstp qword ptr (_Four)\nfld qword ptr (_Four)\nfstp qword ptr (-32)[ebp]\nfld qword ptr (-32)[ebp]\nfadd qword ptr (-8)[ebp]\nfstp qword ptr (_Five)\nfld qword ptr (-32)[ebp]\nfadd qword ptr (-32)[ebp]\nfstp qword ptr (_Eight)\nfld qword ptr (-24)[ebp]\nfmul qword ptr (-24)[ebp]\nfstp qword ptr (_Nine)\nfld qword ptr (_Nine)\nfmul qword ptr (-24)[ebp]\nfstp qword ptr (_TwentySeven)\nfld qword ptr (-32)[ebp]\nfmul qword ptr (_Eight)\nfstp qword ptr (_ThirtyTwo)\nfld qword ptr (-32)[ebp]\nfmul qword ptr (_Five)\nfmul qword ptr (-24)[ebp]\nfmul qword ptr (-32)[ebp]\nfstp qword ptr (_TwoForty)\nfld qword ptr (-8)[ebp]\nfchs\nfstp qword ptr (_MinusOne)\nfld qword ptr (-8)[ebp]\nfdiv qword ptr (-16)[ebp]\nfstp qword ptr (_Half)\nfld qword ptr (-8)[ebp]\nfadd qword ptr (_Half)\nfstp qword ptr (_OneAndHalf)\nmov dword ptr (_ErrCnt),0\nmov dword ptr (_ErrCnt+4),0\nmov dword ptr (_ErrCnt+8),0\nmov dword ptr (_ErrCnt+12),0\nmov dword ptr (_PageNo),1\nmov dword ptr (_Milestone),0\nlea edi,(_sigfpe)\npush edi\npush 8\ncall _signal\nadd esp,8\ncall _Instructions\nadd esp,0\ncall _Pause\nadd esp,0\ncall _Heading\nadd esp,0\ncall _Pause\nadd esp,0\ncall _Characteristics\nadd esp,0\ncall _Pause\nadd esp,0\ncall _History\nadd esp,0\ncall _Pause\nadd esp,0\nmov dword ptr (_Milestone),7\nlea edi,(L12)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L14)\npush edi\nfld qword ptr (_Zero)\nfadd qword ptr (_Zero)\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L15\nfld qword ptr (_One)\nfsub qword ptr (_One)\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L15\nfld qword ptr (_Zero)\nfcomp qword ptr (_One)\nfstsw ax\nsahf\njae L15\nfld qword ptr (_One)\nfadd qword ptr (_One)\nfld qword ptr (_Two)\nfcompp\nfstsw ax\nsahf\njne L15\nmov dword ptr (-36)[ebp],1\njmp L16\nL15:\nmov dword ptr (-36)[ebp],0\nL16:\nmov edi,dword ptr (-36)[ebp]\npush edi\npush 0\ncall _TstCond\nadd esp,12\nfld qword ptr (_Zero)\nfchs\nfstp qword ptr (_Z)\nfld qword ptr (L7)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\nje L17\ninc dword ptr (_ErrCnt)\nlea edi,(L19)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (L20)\nfstp qword ptr (_U1)\nfld qword ptr (L8)\nfstp qword ptr (_Radix)\ncall _TstPtUf\nadd esp,0\nL17:\nlea edi,(L22)\npush edi\nfld qword ptr (_Two)\nfadd qword ptr (_One)\nfcomp qword ptr (_Three)\nfstsw ax\nsahf\njne L23\nfld qword ptr (_Three)\nfadd qword ptr (_One)\nfcomp qword ptr (_Four)\nfstsw ax\nsahf\njne L23\nfld qword ptr (_Four)\nfld qword ptr (_Two)\nfld qword ptr (_Two)\nfchs\nfmulp st(1),st\nfaddp st(1),st\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L23\nfld qword ptr (_Four)\nfsub qword ptr (_Three)\nfsub qword ptr (_One)\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L23\nmov dword ptr (-56)[ebp],1\njmp L24\nL23:\nmov dword ptr (-56)[ebp],0\nL24:\nmov edi,dword ptr (-56)[ebp]\npush edi\npush 0\ncall _TstCond\nadd esp,12\nfld qword ptr (L7)\nfsub qword ptr (_One)\nfcomp qword ptr (_MinusOne)\nfstsw ax\nsahf\njne L27\nfld qword ptr (_MinusOne)\nfadd qword ptr (_One)\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L27\nfld qword ptr (_One)\nfadd qword ptr (_MinusOne)\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L27\nfld qword ptr (_One)\nsub esp,8\nfstp qword ptr [esp]\ncall _fabs\nadd esp,8\nfstp qword ptr (-132)[ebp]\nfld qword ptr (_MinusOne)\nfadd qword ptr (-132)[ebp]\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L27\nfld qword ptr (_MinusOne)\nfld qword ptr (_MinusOne)\nfmul qword ptr (_MinusOne)\nfaddp st(1),st\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L27\nmov dword ptr (-100)[ebp],1\njmp L28\nL27:\nmov dword ptr (-100)[ebp],0\nL28:\nlea edi,(L26)\npush edi\nmov edi,dword ptr (-100)[ebp]\npush edi\npush 0\ncall _TstCond\nadd esp,12\nlea edi,(L30)\npush edi\nfld qword ptr (_Half)\nfadd qword ptr (_MinusOne)\nfadd qword ptr (_Half)\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L31\nmov dword ptr (-152)[ebp],1\njmp L32\nL31:\nmov dword ptr (-152)[ebp],0\nL32:\nmov edi,dword ptr (-152)[ebp]\npush edi\npush 0\ncall _TstCond\nadd esp,12\nmov dword ptr (_Milestone),10\nlea edi,(L34)\npush edi\nfld qword ptr (_Three)\nfmul qword ptr (_Three)\nfcomp qword ptr (_Nine)\nfstsw ax\nsahf\njne L35\nfld qword ptr (_Nine)\nfmul qword ptr (_Three)\nfcomp qword ptr (_TwentySeven)\nfstsw ax\nsahf\njne L35\nfld qword ptr (_Four)\nfadd qword ptr (_Four)\nfcomp qword ptr (_Eight)\nfstsw ax\nsahf\njne L35\nfld qword ptr (_Eight)\nfmul qword ptr (_Four)\nfcomp qword ptr (_ThirtyTwo)\nfstsw ax\nsahf\njne L35\nfld qword ptr (_ThirtyTwo)\nfsub qword ptr (_TwentySeven)\nfsub qword ptr (_Four)\nfsub qword ptr (_One)\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L35\nmov dword ptr (-164)[ebp],1\njmp L36\nL35:\nmov dword ptr (-164)[ebp],0\nL36:\nmov edi,dword ptr (-164)[ebp]\npush edi\npush 0\ncall _TstCond\nadd esp,12\nlea edi,(L38)\npush edi\nfld qword ptr (_Four)\nfadd qword ptr (_One)\nfcomp qword ptr (_Five)\nfstsw ax\nsahf\njne L39\nfld qword ptr (_Four)\nfmul qword ptr (_Five)\nfmul qword ptr (_Three)\nfmul qword ptr (_Four)\nfcomp qword ptr (_TwoForty)\nfstsw ax\nsahf\njne L39\nfld qword ptr (_TwoForty)\nfdiv qword ptr (_Three)\nfld qword ptr (_Four)\nfmul qword ptr (_Four)\nfmul qword ptr (_Five)\nfsubp st(1),st\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L39\nfld qword ptr (_TwoForty)\nfdiv qword ptr (_Four)\nfld qword ptr (_Five)\nfmul qword ptr (_Three)\nfmul qword ptr (_Four)\nfsubp st(1),st\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L39\nfld qword ptr (_TwoForty)\nfdiv qword ptr (_Five)\nfld qword ptr (_Four)\nfmul qword ptr (_Three)\nfmul qword ptr (_Four)\nfsubp st(1),st\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L39\nmov dword ptr (-216)[ebp],1\njmp L40\nL39:\nmov dword ptr (-216)[ebp],0\nL40:\nmov edi,dword ptr (-216)[ebp]\npush edi\npush 0\ncall _TstCond\nadd esp,12\ncmp dword ptr (_ErrCnt),0\njne L41\nlea edi,(L43)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L44)\npush edi\ncall _printf\nadd esp,4\nL41:\nlea edi,(L45)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_One)\nfstp qword ptr (_W)\nL46:\nfld qword ptr (_W)\nfstp qword ptr (-264)[ebp]\nfld qword ptr (-264)[ebp]\nfadd qword ptr (-264)[ebp]\nfstp qword ptr (_W)\nfld qword ptr (_W)\nfstp qword ptr (-272)[ebp]\nfld qword ptr (-272)[ebp]\nfadd qword ptr (_One)\nfstp qword ptr (_Y)\nfld qword ptr (_Y)\nfsub qword ptr (-272)[ebp]\nfstp qword ptr (_Z)\nfld qword ptr (_Z)\nfsub qword ptr (_One)\nfstp qword ptr (_Y)\nL47:\nfld qword ptr (_Y)\nsub esp,8\nfstp qword ptr [esp]\ncall _fabs\nadd esp,8\nfstp qword ptr (-264)[ebp]\nfld qword ptr (_MinusOne)\nfadd qword ptr (-264)[ebp]\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\nja L46\nfld qword ptr (_Zero)\nfstp qword ptr (_Precision)\nfld qword ptr (_One)\nfstp qword ptr (_Y)\nL49:\nfld qword ptr (_Y)\nfstp qword ptr (-280)[ebp]\nfld qword ptr (_W)\nfadd qword ptr (-280)[ebp]\nfstp qword ptr (_Radix)\nfld qword ptr (-280)[ebp]\nfadd qword ptr (-280)[ebp]\nfstp qword ptr (_Y)\nfld qword ptr (_Radix)\nfsub qword ptr (_W)\nfstp qword ptr (_Radix)\nL50:\nfld qword ptr (_Zero)\nfcomp qword ptr (_Radix)\nfstsw ax\nsahf\nje L49\nfld qword ptr (_Two)\nfcomp qword ptr (_Radix)\nfstsw ax\nsahf\njbe L52\nfld qword ptr (_One)\nfstp qword ptr (_Radix)\nL52:\nfld qword ptr (_Radix)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L54)\npush edi\ncall _printf\nadd esp,12\nfld qword ptr (L8)\nfcomp qword ptr (_Radix)\nfstsw ax\nsahf\nje L55\nfld qword ptr (_One)\nfstp qword ptr (_W)\nL57:\nfld qword ptr (_Precision)\nfadd qword ptr (_One)\nfstp qword ptr (_Precision)\nfld qword ptr (_W)\nfmul qword ptr (_Radix)\nfstp qword ptr (_W)\nfld qword ptr (_W)\nfadd qword ptr (_One)\nfstp qword ptr (_Y)\nL58:\nfld qword ptr (_Y)\nfsub qword ptr (_W)\nfld qword ptr (_One)\nfcompp\nfstsw ax\nsahf\nje L57\nL55:\nfld qword ptr (_One)\nfdiv qword ptr (_W)\nfstp qword ptr (_U1)\nfld qword ptr (_U1)\nfstp qword ptr (-272)[ebp]\nfld qword ptr (_Radix)\nfmul qword ptr (-272)[ebp]\nfstp qword ptr (_U2)\nfld qword ptr (-272)[ebp]\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L60)\npush edi\ncall _printf\nadd esp,12\nlea edi,(L61)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_Radix)\nfstp qword ptr (_E0)\nfld qword ptr (_U1)\nfstp qword ptr (_E1)\nfld qword ptr (_U2)\nfstp qword ptr (_E9)\nfld qword ptr (_Precision)\nfstp qword ptr (_E3)\nfld qword ptr (_Four)\nfdiv qword ptr (_Three)\nfstp qword ptr (_X)\nfld qword ptr (_X)\nfsub qword ptr (_One)\nfstp qword ptr (_Third)\nfld qword ptr (_Third)\nfstp qword ptr (-280)[ebp]\nfld qword ptr (_Half)\nfsub qword ptr (-280)[ebp]\nfstp qword ptr (_F6)\nfld qword ptr (_F6)\nfstp qword ptr (-288)[ebp]\nfld qword ptr (-288)[ebp]\nfadd qword ptr (-288)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (_X)\nfsub qword ptr (-280)[ebp]\nsub esp,8\nfstp qword ptr [esp]\ncall _fabs\nadd esp,8\nfstp qword ptr (-296)[ebp]\nfld qword ptr (-296)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (_U2)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njbe L62\nfld qword ptr (_U2)\nfstp qword ptr (_X)\nL62:\nL64:\nfld qword ptr (_X)\nfstp qword ptr (_U2)\nfld qword ptr (_U2)\nfstp qword ptr (-304)[ebp]\nfld qword ptr (_Half)\nfmul qword ptr (-304)[ebp]\nfld qword ptr (_ThirtyTwo)\nfmul qword ptr (-304)[ebp]\nfmul qword ptr (-304)[ebp]\nfaddp st(1),st\nfstp qword ptr (_Y)\nfld qword ptr (_One)\nfadd qword ptr (_Y)\nfstp qword ptr (_Y)\nfld qword ptr (_Y)\nfsub qword ptr (_One)\nfstp qword ptr (_X)\nL65:\nfld qword ptr (_X)\nfcomp qword ptr (_U2)\nfstsw ax\nsahf\njae L67\nfld qword ptr (_Zero)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njb L64\nL67:\nfld qword ptr (_Two)\nfdiv qword ptr (_Three)\nfstp qword ptr (_X)\nfld qword ptr (_X)\nfsub qword ptr (_Half)\nfstp qword ptr (_F6)\nfld qword ptr (_F6)\nfstp qword ptr (-320)[ebp]\nfld qword ptr (-320)[ebp]\nfadd qword ptr (-320)[ebp]\nfstp qword ptr (_Third)\nfld qword ptr (_Third)\nfsub qword ptr (_Half)\nfstp qword ptr (_X)\nfld qword ptr (_X)\nfadd qword ptr (-320)[ebp]\nsub esp,8\nfstp qword ptr [esp]\ncall _fabs\nadd esp,8\nfstp qword ptr (-328)[ebp]\nfld qword ptr (-328)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (_U1)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njbe L68\nfld qword ptr (_U1)\nfstp qword ptr (_X)\nL68:\nL70:\nfld qword ptr (_X)\nfstp qword ptr (_U1)\nfld qword ptr (_U1)\nfstp qword ptr (-344)[ebp]\nfld qword ptr (_Half)\nfmul qword ptr (-344)[ebp]\nfld qword ptr (_ThirtyTwo)\nfmul qword ptr (-344)[ebp]\nfmul qword ptr (-344)[ebp]\nfaddp st(1),st\nfstp qword ptr (_Y)\nfld qword ptr (_Half)\nfsub qword ptr (_Y)\nfstp qword ptr (_Y)\nfld qword ptr (_Half)\nfadd qword ptr (_Y)\nfstp qword ptr (_X)\nfld qword ptr (_Half)\nfsub qword ptr (_X)\nfstp qword ptr (_Y)\nfld qword ptr (_Half)\nfadd qword ptr (_Y)\nfstp qword ptr (_X)\nL71:\nfld qword ptr (_X)\nfcomp qword ptr (_U1)\nfstsw ax\nsahf\njae L73\nfld qword ptr (_Zero)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njb L70\nL73:\nfld qword ptr (_E1)\nfcomp qword ptr (_U1)\nfstsw ax\nsahf\njne L74\nlea edi,(L76)\npush edi\ncall _printf\nadd esp,4\njmp L75\nL74:\nfld qword ptr (_U1)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L77)\npush edi\ncall _printf\nadd esp,12\nL75:\nfld qword ptr (_One)\nfdiv qword ptr (_U1)\nfstp qword ptr (_W)\nfld qword ptr (_Half)\nfsub qword ptr (_U1)\nfadd qword ptr (_Half)\nfstp qword ptr (_F9)\nfld qword ptr (_U2)\nfdiv qword ptr (_U1)\nfadd qword ptr (L78)\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-360)[ebp]\nfld qword ptr (-360)[ebp]\nfstp qword ptr (_Radix)\nfld qword ptr (_E0)\nfcomp qword ptr (_Radix)\nfstsw ax\nsahf\njne L79\nlea edi,(L81)\npush edi\ncall _printf\nadd esp,4\njmp L80\nL79:\nfld qword ptr (_Radix)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L82)\npush edi\ncall _printf\nadd esp,12\nL80:\nlea edi,(L84)\npush edi\nfld qword ptr (_Eight)\nfadd qword ptr (_Eight)\nfcomp qword ptr (_Radix)\nfstsw ax\nsahf\njb L85\nmov dword ptr (-364)[ebp],1\njmp L86\nL85:\nmov dword ptr (-364)[ebp],0\nL86:\nmov edi,dword ptr (-364)[ebp]\npush edi\npush 2\ncall _TstCond\nadd esp,12\nlea edi,(L88)\npush edi\nfld qword ptr (_Two)\nfcomp qword ptr (_Radix)\nfstsw ax\nsahf\nje L92\nfld qword ptr (L93)\nfcomp qword ptr (_Radix)\nfstsw ax\nsahf\nje L92\nfld qword ptr (_One)\nfcomp qword ptr (_Radix)\nfstsw ax\nsahf\njne L89\nL92:\nmov dword ptr (-376)[ebp],1\njmp L90\nL89:\nmov dword ptr (-376)[ebp],0\nL90:\nmov edi,dword ptr (-376)[ebp]\npush edi\npush 3\ncall _TstCond\nadd esp,12\nmov dword ptr (_Milestone),20\nlea edi,(L95)\npush edi\nfld qword ptr (_F9)\nfsub qword ptr (_Half)\nfld qword ptr (_Half)\nfcompp\nfstsw ax\nsahf\njbe L96\nmov dword ptr (-388)[ebp],1\njmp L97\nL96:\nmov dword ptr (-388)[ebp],0\nL97:\nmov edi,dword ptr (-388)[ebp]\npush edi\npush 0\ncall _TstCond\nadd esp,12\nfld qword ptr (_F9)\nfstp qword ptr (_X)\nmov dword ptr (_I),1\nfld qword ptr (_X)\nfsub qword ptr (_Half)\nfstp qword ptr (_Y)\nfld qword ptr (_Y)\nfsub qword ptr (_Half)\nfstp qword ptr (_Z)\nlea edi,(L99)\npush edi\nfld qword ptr (_One)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njne L102\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njne L100\nL102:\nmov dword ptr (-400)[ebp],1\njmp L101\nL100:\nmov dword ptr (-400)[ebp],0\nL101:\nmov edi,dword ptr (-400)[ebp]\npush edi\npush 0\ncall _TstCond\nadd esp,12\nfld qword ptr (_One)\nfadd qword ptr (_U2)\nfstp qword ptr (_X)\nmov dword ptr (_I),0\nmov dword ptr (_Milestone),25\nfld qword ptr (_Radix)\nfsub qword ptr (_One)\nfstp qword ptr (_BMinusU2)\nfld qword ptr (_BMinusU2)\nfsub qword ptr (_U2)\nfadd qword ptr (_One)\nfstp qword ptr (_BMinusU2)\nfld qword ptr (_One)\nfcomp qword ptr (_Radix)\nfstsw ax\nsahf\nje L103\nfld qword ptr (_U1)\nsub esp,8\nfstp qword ptr [esp]\ncall _log\nadd esp,8\nfstp qword ptr (-440)[ebp]\nfld qword ptr (_Radix)\nsub esp,8\nfstp qword ptr [esp]\ncall _log\nadd esp,8\nfstp qword ptr (-448)[ebp]\nfld qword ptr (_TwoForty)\nfchs\nfmul qword ptr (-440)[ebp]\nfdiv qword ptr (-448)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (_Half)\nfadd qword ptr (_X)\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-456)[ebp]\nfld qword ptr (-456)[ebp]\nfstp qword ptr (_Y)\nfld qword ptr (_X)\nfsub qword ptr (_Y)\nsub esp,8\nfstp qword ptr [esp]\ncall _fabs\nadd esp,8\nfstp qword ptr (-464)[ebp]\nfld qword ptr (-464)[ebp]\nfmul qword ptr (_Four)\nfld qword ptr (_One)\nfcompp\nfstsw ax\nsahf\njbe L105\nfld qword ptr (_Y)\nfstp qword ptr (_X)\nL105:\nfld qword ptr (_X)\nfdiv qword ptr (_TwoForty)\nfstp qword ptr (_Precision)\nfld qword ptr (_Half)\nfadd qword ptr (_Precision)\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-472)[ebp]\nfld qword ptr (-472)[ebp]\nfstp qword ptr (_Y)\nfld qword ptr (_Precision)\nfsub qword ptr (_Y)\nsub esp,8\nfstp qword ptr [esp]\ncall _fabs\nadd esp,8\nfstp qword ptr (-480)[ebp]\nfld qword ptr (-480)[ebp]\nfmul qword ptr (_TwoForty)\nfld qword ptr (_Half)\nfcompp\nfstsw ax\nsahf\njbe L107\nfld qword ptr (_Y)\nfstp qword ptr (_Precision)\nL107:\nL103:\nfld qword ptr (_Precision)\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-448)[ebp]\nfld qword ptr (-448)[ebp]\nfcomp qword ptr (_Precision)\nfstsw ax\nsahf\njne L111\nfld qword ptr (_One)\nfcomp qword ptr (_Radix)\nfstsw ax\nsahf\njne L109\nL111:\nlea edi,(L112)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L113)\npush edi\ncall _printf\nadd esp,4\nL109:\nfld qword ptr (_One)\nfcomp qword ptr (_Radix)\nfstsw ax\nsahf\njne L114\nlea edi,(L116)\npush edi\ncall _printf\nadd esp,4\njmp L115\nL114:\nfld qword ptr (_Precision)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L117)\npush edi\ncall _printf\nadd esp,12\nL115:\nlea edi,(L119)\npush edi\nfld qword ptr (_U2)\nfmul qword ptr (_Nine)\nfmul qword ptr (_Nine)\nfmul qword ptr (_TwoForty)\nfld qword ptr (_One)\nfcompp\nfstsw ax\nsahf\njbe L120\nmov dword ptr (-452)[ebp],1\njmp L121\nL120:\nmov dword ptr (-452)[ebp],0\nL121:\nmov edi,dword ptr (-452)[ebp]\npush edi\npush 1\ncall _TstCond\nadd esp,12\nmov dword ptr (_Milestone),30\nfld qword ptr (_One)\nfdiv qword ptr (_Four)\nfstp qword ptr (-492)[ebp]\nfld qword ptr (_Four)\nfdiv qword ptr (_Three)\nfsub qword ptr (_One)\nfsub qword ptr (-492)[ebp]\nfmul qword ptr (_Three)\nfsub qword ptr (-492)[ebp]\nsub esp,8\nfstp qword ptr [esp]\ncall _fabs\nadd esp,8\nfstp qword ptr (-500)[ebp]\nfld qword ptr (-500)[ebp]\nfstp qword ptr (_X)\nL122:\nfld qword ptr (_X)\nfstp qword ptr (_Z2)\nfld qword ptr (_Z2)\nfstp qword ptr (-516)[ebp]\nfld qword ptr (_One)\nfld qword ptr (_Half)\nfmul qword ptr (-516)[ebp]\nfld qword ptr (_ThirtyTwo)\nfmul qword ptr (-516)[ebp]\nfmul qword ptr (-516)[ebp]\nfaddp st(1),st\nfaddp st(1),st\nfsub qword ptr (_One)\nfstp qword ptr (_X)\nL123:\nfld qword ptr (_X)\nfcomp qword ptr (_Z2)\nfstsw ax\nsahf\njae L125\nfld qword ptr (_Zero)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njb L122\nL125:\nfld qword ptr (_Three)\nfdiv qword ptr (_Four)\nfld qword ptr (_Two)\nfdiv qword ptr (_Three)\nfsubp st(1),st\nfmul qword ptr (_Three)\nfld qword ptr (_One)\nfdiv qword ptr (_Four)\nfsubp st(1),st\nsub esp,8\nfstp qword ptr [esp]\ncall _fabs\nadd esp,8\nfstp qword ptr (-532)[ebp]\nfld qword ptr (-532)[ebp]\nfstp qword ptr (_Z)\nfld qword ptr (-532)[ebp]\nfstp qword ptr (_Y)\nfld qword ptr (-532)[ebp]\nfstp qword ptr (_X)\nL126:\nfld qword ptr (_Z)\nfstp qword ptr (_Z1)\nfld qword ptr (_One)\nfdiv qword ptr (_Two)\nfstp qword ptr (-540)[ebp]\nfld qword ptr (_Z1)\nfstp qword ptr (-548)[ebp]\nfld qword ptr (-540)[ebp]\nfld qword ptr (-540)[ebp]\nfld qword ptr (_Half)\nfmul qword ptr (-548)[ebp]\nfld qword ptr (_ThirtyTwo)\nfmul qword ptr (-548)[ebp]\nfmul qword ptr (-548)[ebp]\nfaddp st(1),st\nfsubp st(1),st\nfadd qword ptr (-540)[ebp]\nfsubp st(1),st\nfadd qword ptr (-540)[ebp]\nfstp qword ptr (_Z)\nL127:\nfld qword ptr (_Z)\nfcomp qword ptr (_Z1)\nfstsw ax\nsahf\njae L129\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njb L126\nL129:\nL130:\nL133:\nfld qword ptr (_Y)\nfstp qword ptr (_Y1)\nfld qword ptr (_Y1)\nfstp qword ptr (-556)[ebp]\nfld qword ptr (_Half)\nfld qword ptr (_Half)\nfld qword ptr (_Half)\nfmul qword ptr (-556)[ebp]\nfld qword ptr (_ThirtyTwo)\nfmul qword ptr (-556)[ebp]\nfmul qword ptr (-556)[ebp]\nfaddp st(1),st\nfsubp st(1),st\nfadd qword ptr (_Half)\nfsubp st(1),st\nfadd qword ptr (_Half)\nfstp qword ptr (_Y)\nL134:\nfld qword ptr (_Y)\nfcomp qword ptr (_Y1)\nfstsw ax\nsahf\njae L136\nfld qword ptr (_Zero)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njb L133\nL136:\nfld qword ptr (_X)\nfstp qword ptr (_X1)\nfld qword ptr (_X1)\nfstp qword ptr (-556)[ebp]\nfld qword ptr (_Half)\nfmul qword ptr (-556)[ebp]\nfld qword ptr (_ThirtyTwo)\nfmul qword ptr (-556)[ebp]\nfmul qword ptr (-556)[ebp]\nfaddp st(1),st\nfsub qword ptr (_F9)\nfadd qword ptr (_F9)\nfstp qword ptr (_X)\nL131:\nfld qword ptr (_X)\nfcomp qword ptr (_X1)\nfstsw ax\nsahf\njae L137\nfld qword ptr (_Zero)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njb L130\nL137:\nfld qword ptr (_Y1)\nfcomp qword ptr (_X1)\nfstsw ax\nsahf\njne L140\nfld qword ptr (_Z1)\nfcomp qword ptr (_X1)\nfstsw ax\nsahf\nje L138\nL140:\nlea edi,(L141)\npush edi\npush 1\ncall _BadCond\nadd esp,8\nfld qword ptr (_Z1)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_Y1)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_X1)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L142)\npush edi\ncall _printf\nadd esp,28\nlea edi,(L143)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L144)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L145)\npush edi\ncall _notify\nadd esp,4\nfld qword ptr (_U1)\nfcomp qword ptr (_X1)\nfstsw ax\nsahf\nje L149\nfld qword ptr (_U1)\nfcomp qword ptr (_Y1)\nfstsw ax\nsahf\nje L149\nfld qword ptr (_U1)\nfcomp qword ptr (_Z1)\nfstsw ax\nsahf\njne L139\nL149:\nlea edi,(L150)\npush edi\ncall _printf\nadd esp,4\njmp L139\nL138:\nfld qword ptr (_U1)\nfcomp qword ptr (_Z1)\nfstsw ax\nsahf\njne L153\nfld qword ptr (_U2)\nfcomp qword ptr (_Z2)\nfstsw ax\nsahf\nje L151\nL153:\nfld qword ptr (_U1)\nfcomp qword ptr (_Z1)\nfstsw ax\nsahf\njbe L156\nfld qword ptr (_U2)\nfcomp qword ptr (_Z2)\nfstsw ax\nsahf\nja L154\nL156:\nlea edi,(L157)\npush edi\npush 0\ncall _BadCond\nadd esp,8\nlea edi,(L158)\npush edi\ncall _notify\nadd esp,4\nfld qword ptr (_Z1)\nfsub qword ptr (_U1)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_U1)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L159)\npush edi\ncall _printf\nadd esp,20\nfld qword ptr (_Z2)\nfsub qword ptr (_U2)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_U2)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L160)\npush edi\ncall _printf\nadd esp,20\njmp L155\nL154:\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z1)\nfstsw ax\nsahf\njae L163\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z2)\nfstsw ax\nsahf\njb L161\nL163:\nfld qword ptr (_Radix)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L164)\npush edi\ncall _printf\nadd esp,12\nlea edi,(L165)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_Z2)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_Z1)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L166)\npush edi\ncall _printf\nadd esp,20\nlea edi,(L167)\npush edi\ncall _notify\nadd esp,4\nL161:\nfld qword ptr (_Z2)\nfcomp qword ptr (_Z1)\nfstsw ax\nsahf\njne L170\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z1)\nfstsw ax\nsahf\njae L168\nL170:\nfld qword ptr (_Z1)\nfdiv qword ptr (_U1)\nfstp qword ptr (_X)\nfld qword ptr (_Z2)\nfdiv qword ptr (_U2)\nfstp qword ptr (_Y)\nfld qword ptr (_X)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njae L171\nfld qword ptr (_Y)\nfstp qword ptr (_X)\nL171:\nfld qword ptr (_X)\nsub esp,8\nfstp qword ptr [esp]\ncall _log\nadd esp,8\nfstp qword ptr (-580)[ebp]\nfld qword ptr (-580)[ebp]\nfchs\nfstp qword ptr (_Q)\nlea edi,(L173)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_Radix)\nsub esp,8\nfstp qword ptr [esp]\ncall _log\nadd esp,8\nfstp qword ptr (-588)[ebp]\nfld qword ptr (_Q)\nfdiv qword ptr (-588)[ebp]\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L174)\npush edi\ncall _printf\nadd esp,12\nfld qword ptr (L93)\nsub esp,8\nfstp qword ptr [esp]\ncall _log\nadd esp,8\nfstp qword ptr (-596)[ebp]\nfld qword ptr (_Q)\nfdiv qword ptr (-596)[ebp]\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L175)\npush edi\ncall _printf\nadd esp,12\nL168:\nlea edi,(L150)\npush edi\ncall _printf\nadd esp,4\nL155:\nL151:\nL139:\ncall _Pause\nadd esp,0\nmov dword ptr (_Milestone),35\nfld qword ptr (_Two)\nfcomp qword ptr (_Radix)\nfstsw ax\nsahf\nja L176\nfld qword ptr (_W)\nfld qword ptr (_Radix)\nfmul qword ptr (_Radix)\nfdivp st(1),st\nfstp qword ptr (_X)\nfld qword ptr (_X)\nfstp qword ptr (-576)[ebp]\nfld qword ptr (-576)[ebp]\nfadd qword ptr (_One)\nfstp qword ptr (_Y)\nfld qword ptr (_Y)\nfsub qword ptr (-576)[ebp]\nfstp qword ptr (_Z)\nfld qword ptr (_Z)\nfstp qword ptr (-584)[ebp]\nfld qword ptr (-584)[ebp]\nfadd qword ptr (_U2)\nfstp qword ptr (_T)\nfld qword ptr (_T)\nfsub qword ptr (-584)[ebp]\nfstp qword ptr (_X)\nlea edi,(L179)\npush edi\nfld qword ptr (_U2)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njne L180\nmov dword ptr (-560)[ebp],1\njmp L181\nL180:\nmov dword ptr (-560)[ebp],0\nL181:\nmov edi,dword ptr (-560)[ebp]\npush edi\npush 0\ncall _TstCond\nadd esp,12\nfld qword ptr (_U2)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njne L182\nlea edi,(L184)\npush edi\ncall _printf\nadd esp,4\nL182:\nL176:\nlea edi,(L185)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_F9)\nfmul qword ptr (_One)\nfstp qword ptr (_Y)\nfld qword ptr (_One)\nfmul qword ptr (_F9)\nfstp qword ptr (_Z)\nfld qword ptr (_F9)\nfsub qword ptr (_Half)\nfstp qword ptr (_X)\nfld qword ptr (_X)\nfstp qword ptr (-588)[ebp]\nfld qword ptr (_Y)\nfsub qword ptr (_Half)\nfsub qword ptr (-588)[ebp]\nfstp qword ptr (_Y)\nfld qword ptr (_Z)\nfsub qword ptr (_Half)\nfsub qword ptr (-588)[ebp]\nfstp qword ptr (_Z)\nfld qword ptr (_One)\nfadd qword ptr (_U2)\nfstp qword ptr (_X)\nfld qword ptr (_X)\nfstp qword ptr (-604)[ebp]\nfld qword ptr (-604)[ebp]\nfmul qword ptr (_Radix)\nfstp qword ptr (_T)\nfld qword ptr (_Radix)\nfmul qword ptr (-604)[ebp]\nfstp qword ptr (_R)\nfld qword ptr (_T)\nfsub qword ptr (_Radix)\nfstp qword ptr (_X)\nfld qword ptr (_Radix)\nfmul qword ptr (_U2)\nfstp qword ptr (-620)[ebp]\nfld qword ptr (_X)\nfsub qword ptr (-620)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (_R)\nfsub qword ptr (_Radix)\nfstp qword ptr (_T)\nfld qword ptr (_T)\nfsub qword ptr (-620)[ebp]\nfstp qword ptr (_T)\nfld qword ptr (_Radix)\nfsub qword ptr (_One)\nfstp qword ptr (-628)[ebp]\nfld qword ptr (_X)\nfmul qword ptr (-628)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (_T)\nfmul qword ptr (-628)[ebp]\nfstp qword ptr (_T)\nfld qword ptr (_Zero)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njne L186\nfld qword ptr (_Zero)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njne L186\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njne L186\nfld qword ptr (_Zero)\nfcomp qword ptr (_T)\nfstsw ax\nsahf\njne L186\nmov dword ptr (_GMult),1\njmp L187\nL186:\nmov dword ptr (_GMult),0\nlea edi,(L188)\npush edi\npush 0\npush 1\ncall _TstCond\nadd esp,12\nL187:\nfld qword ptr (_Radix)\nfmul qword ptr (_U2)\nfstp qword ptr (_Z)\nfld qword ptr (_Z)\nfstp qword ptr (-648)[ebp]\nfld qword ptr (_One)\nfadd qword ptr (-648)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (_X)\nfstp qword ptr (-656)[ebp]\nfld qword ptr (-656)[ebp]\nfadd qword ptr (-648)[ebp]\nfld qword ptr (-656)[ebp]\nfmul qword ptr (-656)[ebp]\nfsubp st(1),st\nsub esp,8\nfstp qword ptr [esp]\ncall _fabs\nadd esp,8\nfstp qword ptr (-664)[ebp]\nfld qword ptr (-664)[ebp]\nfsub qword ptr (_U2)\nfstp qword ptr (_Y)\nfld qword ptr (_One)\nfsub qword ptr (_U2)\nfstp qword ptr (_X)\nfld qword ptr (_X)\nfstp qword ptr (-680)[ebp]\nfld qword ptr (-680)[ebp]\nfsub qword ptr (_U2)\nfld qword ptr (-680)[ebp]\nfmul qword ptr (-680)[ebp]\nfsubp st(1),st\nsub esp,8\nfstp qword ptr [esp]\ncall _fabs\nadd esp,8\nfstp qword ptr (-688)[ebp]\nfld qword ptr (-688)[ebp]\nfsub qword ptr (_U1)\nfstp qword ptr (_Z)\nlea edi,(L190)\npush edi\nfld qword ptr (_Zero)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njb L191\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njb L191\nmov dword ptr (-640)[ebp],1\njmp L192\nL191:\nmov dword ptr (-640)[ebp],0\nL192:\nmov edi,dword ptr (-640)[ebp]\npush edi\npush 0\ncall _TstCond\nadd esp,12\nfld qword ptr (_One)\nfsub qword ptr (_U2)\nfstp qword ptr (_Y)\nfld qword ptr (_One)\nfadd qword ptr (_U2)\nfstp qword ptr (_X)\nfld qword ptr (_One)\nfdiv qword ptr (_Y)\nfstp qword ptr (_Z)\nfld qword ptr (_Z)\nfsub qword ptr (_X)\nfstp qword ptr (_Y)\nfld qword ptr (_One)\nfdiv qword ptr (_Three)\nfstp qword ptr (_X)\nfld qword ptr (_Three)\nfdiv qword ptr (_Nine)\nfstp qword ptr (_Z)\nfld qword ptr (_Z)\nfstp qword ptr (-740)[ebp]\nfld qword ptr (_X)\nfsub qword ptr (-740)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (_Nine)\nfdiv qword ptr (_TwentySeven)\nfstp qword ptr (_T)\nfld qword ptr (-740)[ebp]\nfsub qword ptr (_T)\nfstp qword ptr (_Z)\nlea edi,(L194)\npush edi\nfld qword ptr (_Zero)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njne L195\nfld qword ptr (_Zero)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njne L195\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njne L195\nmov dword ptr (-700)[ebp],1\njmp L196\nL195:\nmov dword ptr (-700)[ebp],0\nL196:\nmov edi,dword ptr (-700)[ebp]\npush edi\npush 2\ncall _TstCond\nadd esp,12\nfld qword ptr (_F9)\nfdiv qword ptr (_One)\nfstp qword ptr (_Y)\nfld qword ptr (_F9)\nfsub qword ptr (_Half)\nfstp qword ptr (_X)\nfld qword ptr (_Y)\nfsub qword ptr (_Half)\nfsub qword ptr (_X)\nfstp qword ptr (_Y)\nfld qword ptr (_One)\nfadd qword ptr (_U2)\nfstp qword ptr (_X)\nfld qword ptr (_X)\nfstp qword ptr (-780)[ebp]\nfld qword ptr (-780)[ebp]\nfdiv qword ptr (_One)\nfstp qword ptr (_T)\nfld qword ptr (_T)\nfsub qword ptr (-780)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (_Zero)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njne L197\nfld qword ptr (_Zero)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njne L197\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njne L197\nmov dword ptr (_GDiv),1\njmp L198\nL197:\nmov dword ptr (_GDiv),0\nlea edi,(L199)\npush edi\npush 0\npush 1\ncall _TstCond\nadd esp,12\nL198:\nfld qword ptr (_One)\nfld qword ptr (_One)\nfadd qword ptr (_U2)\nfdivp st(1),st\nfstp qword ptr (_X)\nfld qword ptr (_X)\nfsub qword ptr (_Half)\nfsub qword ptr (_Half)\nfstp qword ptr (_Y)\nlea edi,(L201)\npush edi\nfld qword ptr (_Zero)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njbe L202\nmov dword ptr (-792)[ebp],1\njmp L203\nL202:\nmov dword ptr (-792)[ebp],0\nL203:\nmov edi,dword ptr (-792)[ebp]\npush edi\npush 1\ncall _TstCond\nadd esp,12\nfld qword ptr (_One)\nfsub qword ptr (_U2)\nfstp qword ptr (_X)\nfld qword ptr (_One)\nfld qword ptr (_Radix)\nfmul qword ptr (_U2)\nfaddp st(1),st\nfstp qword ptr (_Y)\nfld qword ptr (_X)\nfstp qword ptr (-844)[ebp]\nfld qword ptr (-844)[ebp]\nfmul qword ptr (_Radix)\nfstp qword ptr (_Z)\nfld qword ptr (_Y)\nfstp qword ptr (-852)[ebp]\nfld qword ptr (-852)[ebp]\nfmul qword ptr (_Radix)\nfstp qword ptr (_T)\nfld qword ptr (_Z)\nfdiv qword ptr (_Radix)\nfstp qword ptr (_R)\nfld qword ptr (_T)\nfdiv qword ptr (_Radix)\nfstp qword ptr (_StickyBit)\nfld qword ptr (_R)\nfsub qword ptr (-844)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (_StickyBit)\nfsub qword ptr (-852)[ebp]\nfstp qword ptr (_Y)\nlea edi,(L205)\npush edi\nfld qword ptr (_Zero)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njne L206\nfld qword ptr (_Zero)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njne L206\nmov dword ptr (-812)[ebp],1\njmp L207\nL206:\nmov dword ptr (-812)[ebp],0\nL207:\nmov edi,dword ptr (-812)[ebp]\npush edi\npush 0\ncall _TstCond\nadd esp,12\nfld qword ptr (_One)\nfsub qword ptr (_U1)\nfstp qword ptr (_Y)\nfld qword ptr (_One)\nfsub qword ptr (_F9)\nfstp qword ptr (_X)\nfld qword ptr (_One)\nfsub qword ptr (_Y)\nfstp qword ptr (_Y)\nfld qword ptr (_Radix)\nfsub qword ptr (_U2)\nfstp qword ptr (_T)\nfld qword ptr (_Radix)\nfsub qword ptr (_BMinusU2)\nfstp qword ptr (_Z)\nfld qword ptr (_Radix)\nfsub qword ptr (_T)\nfstp qword ptr (_T)\nfld qword ptr (_U1)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njne L208\nfld qword ptr (_U1)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njne L208\nfld qword ptr (_U2)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njne L208\nfld qword ptr (_U2)\nfcomp qword ptr (_T)\nfstsw ax\nsahf\njne L208\nmov dword ptr (_GAddSub),1\njmp L209\nL208:\nmov dword ptr (_GAddSub),0\nlea edi,(L210)\npush edi\npush 0\npush 1\ncall _TstCond\nadd esp,12\nL209:\nfld qword ptr (_One)\nfcomp qword ptr (_F9)\nfstsw ax\nsahf\nje L211\nfld qword ptr (_F9)\nfsub qword ptr (_One)\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\nja L211\nlea edi,(L213)\npush edi\npush 1\ncall _BadCond\nadd esp,8\nlea edi,(L214)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L215)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L216)\npush edi\ncall _printf\nadd esp,4\nL211:\ncmp dword ptr (_GMult),1\njne L217\ncmp dword ptr (_GDiv),1\njne L217\ncmp dword ptr (_GAddSub),1\njne L217\nlea edi,(L219)\npush edi\ncall _printf\nadd esp,4\nL217:\nmov dword ptr (_Milestone),40\ncall _Pause\nadd esp,0\nlea edi,(L220)\npush edi\ncall _printf\nadd esp,4\nmov dword ptr (_RMult),0\nmov dword ptr (_RDiv),0\nmov dword ptr (_RAddSub),0\nfld qword ptr (_Radix)\nfdiv qword ptr (_Two)\nfstp qword ptr (_RadixD2)\nfld qword ptr (_Two)\nfstp qword ptr (_A1)\nmov dword ptr (_Done),0\nL221:\nfld qword ptr (_Radix)\nfstp qword ptr (_AInvrse)\nL224:\nfld qword ptr (_AInvrse)\nfstp qword ptr (-924)[ebp]\nfld qword ptr (-924)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (-924)[ebp]\nfdiv qword ptr (_A1)\nfstp qword ptr (_AInvrse)\nL225:\nfld qword ptr (_AInvrse)\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-924)[ebp]\nfld qword ptr (_AInvrse)\nfcomp qword ptr (-924)[ebp]\nfstsw ax\nsahf\nje L224\nfld qword ptr (_One)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\nje L230\nfld qword ptr (_Three)\nfcomp qword ptr (_A1)\nfstsw ax\nsahf\njae L228\nL230:\nmov dword ptr (-928)[ebp],1\njmp L229\nL228:\nmov dword ptr (-928)[ebp],0\nL229:\nmov edi,dword ptr (-928)[ebp]\nmov dword ptr (_Done),edi\ncmp dword ptr (_Done),0\njne L231\nfld qword ptr (_Nine)\nfadd qword ptr (_One)\nfstp qword ptr (_A1)\nL231:\nL222:\ncmp dword ptr (_Done),0\nje L221\nfld qword ptr (_One)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njne L233\nfld qword ptr (_Radix)\nfstp qword ptr (_A1)\nL233:\nfld qword ptr (_One)\nfdiv qword ptr (_A1)\nfstp qword ptr (_AInvrse)\nfld qword ptr (_A1)\nfstp qword ptr (_X)\nfld qword ptr (_AInvrse)\nfstp qword ptr (_Y)\nmov dword ptr (_Done),0\nL235:\nfld qword ptr (_X)\nfmul qword ptr (_Y)\nfsub qword ptr (_Half)\nfstp qword ptr (_Z)\nlea edi,(L239)\npush edi\nfld qword ptr (_Half)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njne L240\nmov dword ptr (-928)[ebp],1\njmp L241\nL240:\nmov dword ptr (-928)[ebp],0\nL241:\nmov edi,dword ptr (-928)[ebp]\npush edi\npush 0\ncall _TstCond\nadd esp,12\nfld qword ptr (_Radix)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njne L243\nmov dword ptr (-940)[ebp],1\njmp L244\nL243:\nmov dword ptr (-940)[ebp],0\nL244:\nmov edi,dword ptr (-940)[ebp]\nmov dword ptr (_Done),edi\nfld qword ptr (_Radix)\nfstp qword ptr (_X)\nfld qword ptr (_One)\nfdiv qword ptr (_X)\nfstp qword ptr (_Y)\nL236:\ncmp dword ptr (_Done),0\nje L235\nfld qword ptr (_One)\nfadd qword ptr (_U2)\nfstp qword ptr (_Y2)\nfld qword ptr (_One)\nfsub qword ptr (_U2)\nfstp qword ptr (_Y1)\nfld qword ptr (_OneAndHalf)\nfsub qword ptr (_U2)\nfstp qword ptr (_X)\nfld qword ptr (_OneAndHalf)\nfadd qword ptr (_U2)\nfstp qword ptr (_Y)\nfld qword ptr (_X)\nfstp qword ptr (-956)[ebp]\nfld qword ptr (_Y2)\nfstp qword ptr (-964)[ebp]\nfld qword ptr (-956)[ebp]\nfsub qword ptr (_U2)\nfmul qword ptr (-964)[ebp]\nfstp qword ptr (_Z)\nfld qword ptr (_Y)\nfstp qword ptr (-972)[ebp]\nfld qword ptr (_Y1)\nfstp qword ptr (-980)[ebp]\nfld qword ptr (-972)[ebp]\nfmul qword ptr (-980)[ebp]\nfstp qword ptr (_T)\nfld qword ptr (_Z)\nfsub qword ptr (-956)[ebp]\nfstp qword ptr (_Z)\nfld qword ptr (_T)\nfsub qword ptr (-956)[ebp]\nfstp qword ptr (_T)\nfld qword ptr (-956)[ebp]\nfmul qword ptr (-964)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (-972)[ebp]\nfadd qword ptr (_U2)\nfmul qword ptr (-980)[ebp]\nfstp qword ptr (_Y)\nfld qword ptr (_X)\nfsub qword ptr (_OneAndHalf)\nfstp qword ptr (_X)\nfld qword ptr (_Y)\nfsub qword ptr (_OneAndHalf)\nfstp qword ptr (_Y)\nfld qword ptr (_Zero)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njne L245\nfld qword ptr (_Zero)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njne L245\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njne L245\nfld qword ptr (_Zero)\nfcomp qword ptr (_T)\nfstsw ax\nsahf\njb L245\nfld qword ptr (_OneAndHalf)\nfadd qword ptr (_U2)\nfstp qword ptr (-1012)[ebp]\nfld qword ptr (-1012)[ebp]\nfmul qword ptr (_Y2)\nfstp qword ptr (_X)\nfld qword ptr (_OneAndHalf)\nfsub qword ptr (_U2)\nfstp qword ptr (-1028)[ebp]\nfld qword ptr (-1028)[ebp]\nfsub qword ptr (_U2)\nfstp qword ptr (_Y)\nfld qword ptr (-1012)[ebp]\nfadd qword ptr (_U2)\nfstp qword ptr (_Z)\nfld qword ptr (_Y1)\nfstp qword ptr (-1036)[ebp]\nfld qword ptr (-1028)[ebp]\nfmul qword ptr (-1036)[ebp]\nfstp qword ptr (_T)\nfld qword ptr (_Z)\nfstp qword ptr (-1044)[ebp]\nfld qword ptr (-1044)[ebp]\nfadd qword ptr (_U2)\nfstp qword ptr (-1052)[ebp]\nfld qword ptr (_X)\nfsub qword ptr (-1052)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (_Y)\nfstp qword ptr (-1060)[ebp]\nfld qword ptr (-1060)[ebp]\nfmul qword ptr (-1036)[ebp]\nfstp qword ptr (_StickyBit)\nfld qword ptr (-1044)[ebp]\nfmul qword ptr (_Y2)\nfstp qword ptr (_S)\nfld qword ptr (_T)\nfsub qword ptr (-1060)[ebp]\nfstp qword ptr (_T)\nfld qword ptr (_U2)\nfsub qword ptr (-1060)[ebp]\nfadd qword ptr (_StickyBit)\nfstp qword ptr (_Y)\nfld qword ptr (_S)\nfld qword ptr (-1052)[ebp]\nfadd qword ptr (_U2)\nfsubp st(1),st\nfstp qword ptr (_Z)\nfld qword ptr (_Y2)\nfadd qword ptr (_U2)\nfmul qword ptr (-1036)[ebp]\nfstp qword ptr (_StickyBit)\nfld qword ptr (_Y2)\nfmul qword ptr (-1036)[ebp]\nfstp qword ptr (_Y1)\nfld qword ptr (_StickyBit)\nfsub qword ptr (_Y2)\nfstp qword ptr (_StickyBit)\nfld qword ptr (_Y1)\nfsub qword ptr (_Half)\nfstp qword ptr (_Y1)\nfld qword ptr (_Zero)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njne L247\nfld qword ptr (_Zero)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njne L247\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njne L247\nfld qword ptr (_Zero)\nfcomp qword ptr (_T)\nfstsw ax\nsahf\njne L247\nfld qword ptr (_Zero)\nfcomp qword ptr (_StickyBit)\nfstsw ax\nsahf\njne L247\nfld qword ptr (_Half)\nfcomp qword ptr (_Y1)\nfstsw ax\nsahf\njne L247\nmov dword ptr (_RMult),1\nlea edi,(L249)\npush edi\ncall _printf\nadd esp,4\njmp L248\nL247:\nfld qword ptr (_X)\nfadd qword ptr (_U2)\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L250\nfld qword ptr (_Zero)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njbe L250\nfld qword ptr (_Z)\nfadd qword ptr (_U2)\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L250\nfld qword ptr (_Zero)\nfcomp qword ptr (_T)\nfstsw ax\nsahf\njbe L250\nfld qword ptr (_StickyBit)\nfadd qword ptr (_U2)\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L250\nfld qword ptr (_Half)\nfcomp qword ptr (_Y1)\nfstsw ax\nsahf\njbe L250\nmov dword ptr (_RMult),2\nlea edi,(L252)\npush edi\ncall _printf\nadd esp,4\njmp L251\nL250:\nlea edi,(L253)\npush edi\ncall _printf\nadd esp,4\nL251:\nL248:\ncmp dword ptr (_RMult),1\njne L246\ncmp dword ptr (_GMult),0\njne L246\nlea edi,(L256)\npush edi\ncall _notify\nadd esp,4\njmp L246\nL245:\nlea edi,(L253)\npush edi\ncall _printf\nadd esp,4\nL246:\nmov dword ptr (_Milestone),45\nfld qword ptr (_One)\nfadd qword ptr (_U2)\nfstp qword ptr (_Y2)\nfld qword ptr (_One)\nfsub qword ptr (_U2)\nfstp qword ptr (_Y1)\nfld qword ptr (_OneAndHalf)\nfadd qword ptr (_U2)\nfstp qword ptr (-1020)[ebp]\nfld qword ptr (-1020)[ebp]\nfadd qword ptr (_U2)\nfstp qword ptr (_Z)\nfld qword ptr (_Z)\nfstp qword ptr (-1028)[ebp]\nfld qword ptr (_Y2)\nfstp qword ptr (-1036)[ebp]\nfld qword ptr (-1028)[ebp]\nfdiv qword ptr (-1036)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (_OneAndHalf)\nfsub qword ptr (_U2)\nfsub qword ptr (_U2)\nfstp qword ptr (_T)\nfld qword ptr (_T)\nfstp qword ptr (-1044)[ebp]\nfld qword ptr (_Y1)\nfstp qword ptr (-1052)[ebp]\nfld qword ptr (-1044)[ebp]\nfsub qword ptr (_U2)\nfdiv qword ptr (-1052)[ebp]\nfstp qword ptr (_Y)\nfld qword ptr (-1028)[ebp]\nfadd qword ptr (_U2)\nfdiv qword ptr (-1036)[ebp]\nfstp qword ptr (_Z)\nfld qword ptr (_X)\nfsub qword ptr (_OneAndHalf)\nfstp qword ptr (_X)\nfld qword ptr (_Y)\nfsub qword ptr (-1044)[ebp]\nfstp qword ptr (_Y)\nfld qword ptr (-1044)[ebp]\nfdiv qword ptr (-1052)[ebp]\nfstp qword ptr (_T)\nfld qword ptr (_Z)\nfsub qword ptr (-1020)[ebp]\nfstp qword ptr (_Z)\nfld qword ptr (_U2)\nfsub qword ptr (_OneAndHalf)\nfadd qword ptr (_T)\nfstp qword ptr (_T)\nfld qword ptr (_Zero)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njb L257\nfld qword ptr (_Zero)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njb L257\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njb L257\nfld qword ptr (_Zero)\nfcomp qword ptr (_T)\nfstsw ax\nsahf\njb L257\nfld qword ptr (_Y2)\nfstp qword ptr (-1076)[ebp]\nfld qword ptr (_OneAndHalf)\nfdiv qword ptr (-1076)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (_OneAndHalf)\nfsub qword ptr (_U2)\nfstp qword ptr (_Y)\nfld qword ptr (_OneAndHalf)\nfadd qword ptr (_U2)\nfstp qword ptr (_Z)\nfld qword ptr (_Y)\nfstp qword ptr (-1092)[ebp]\nfld qword ptr (_X)\nfsub qword ptr (-1092)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (_Y1)\nfstp qword ptr (-1100)[ebp]\nfld qword ptr (_OneAndHalf)\nfdiv qword ptr (-1100)[ebp]\nfstp qword ptr (_T)\nfld qword ptr (-1092)[ebp]\nfdiv qword ptr (-1100)[ebp]\nfstp qword ptr (_Y)\nfld qword ptr (_Z)\nfstp qword ptr (-1108)[ebp]\nfld qword ptr (_T)\nfld qword ptr (-1108)[ebp]\nfadd qword ptr (_U2)\nfsubp st(1),st\nfstp qword ptr (_T)\nfld qword ptr (_Y)\nfsub qword ptr (-1108)[ebp]\nfstp qword ptr (_Y)\nfld qword ptr (-1108)[ebp]\nfdiv qword ptr (-1076)[ebp]\nfstp qword ptr (_Z)\nfld qword ptr (-1076)[ebp]\nfadd qword ptr (_U2)\nfdiv qword ptr (-1076)[ebp]\nfstp qword ptr (_Y1)\nfld qword ptr (_Z)\nfsub qword ptr (_OneAndHalf)\nfstp qword ptr (_Z)\nfld qword ptr (_Y1)\nfsub qword ptr (-1076)[ebp]\nfstp qword ptr (_Y2)\nfld qword ptr (_F9)\nfsub qword ptr (_U1)\nfdiv qword ptr (_F9)\nfstp qword ptr (_Y1)\nfld qword ptr (_Zero)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njne L259\nfld qword ptr (_Zero)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njne L259\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njne L259\nfld qword ptr (_Zero)\nfcomp qword ptr (_T)\nfstsw ax\nsahf\njne L259\nfld qword ptr (_Zero)\nfcomp qword ptr (_Y2)\nfstsw ax\nsahf\njne L259\nfld qword ptr (_Zero)\nfcomp qword ptr (_Y2)\nfstsw ax\nsahf\njne L259\nfld qword ptr (_Y1)\nfsub qword ptr (_Half)\nfld qword ptr (_F9)\nfsub qword ptr (_Half)\nfcompp\nfstsw ax\nsahf\njne L259\nmov dword ptr (_RDiv),1\nlea edi,(L261)\npush edi\ncall _printf\nadd esp,4\ncmp dword ptr (_GDiv),0\njne L260\nlea edi,(L264)\npush edi\ncall _notify\nadd esp,4\njmp L260\nL259:\nfld qword ptr (_Zero)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njbe L265\nfld qword ptr (_Zero)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njbe L265\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njbe L265\nfld qword ptr (_Zero)\nfcomp qword ptr (_T)\nfstsw ax\nsahf\njbe L265\nfld qword ptr (_Zero)\nfcomp qword ptr (_Y2)\nfstsw ax\nsahf\njbe L265\nfld qword ptr (_Y1)\nfsub qword ptr (_Half)\nfld qword ptr (_F9)\nfsub qword ptr (_Half)\nfcompp\nfstsw ax\nsahf\njbe L265\nmov dword ptr (_RDiv),2\nlea edi,(L267)\npush edi\ncall _printf\nadd esp,4\nL265:\nL260:\nL257:\ncmp dword ptr (_RDiv),0\njne L268\nlea edi,(L270)\npush edi\ncall _printf\nadd esp,4\nL268:\nfld qword ptr (_One)\nfdiv qword ptr (_Radix)\nfstp qword ptr (_BInvrse)\nlea edi,(L272)\npush edi\nfld qword ptr (_BInvrse)\nfmul qword ptr (_Radix)\nfsub qword ptr (_Half)\nfld qword ptr (_Half)\nfcompp\nfstsw ax\nsahf\njne L273\nmov dword ptr (-1064)[ebp],1\njmp L274\nL273:\nmov dword ptr (-1064)[ebp],0\nL274:\nmov edi,dword ptr (-1064)[ebp]\npush edi\npush 0\ncall _TstCond\nadd esp,12\nmov dword ptr (_Milestone),50\nlea edi,(L276)\npush edi\nfld qword ptr (_F9)\nfadd qword ptr (_U1)\nfsub qword ptr (_Half)\nfld qword ptr (_Half)\nfcompp\nfstsw ax\nsahf\njne L277\nfld qword ptr (_BMinusU2)\nfadd qword ptr (_U2)\nfsub qword ptr (_One)\nfld qword ptr (_Radix)\nfsub qword ptr (_One)\nfcompp\nfstsw ax\nsahf\njne L277\nmov dword ptr (-1084)[ebp],1\njmp L278\nL277:\nmov dword ptr (-1084)[ebp],0\nL278:\nmov edi,dword ptr (-1084)[ebp]\npush edi\npush 0\ncall _TstCond\nadd esp,12\nfld qword ptr (_One)\nfld qword ptr (_U1)\nfmul qword ptr (_U1)\nfsubp st(1),st\nfstp qword ptr (_X)\nfld qword ptr (_One)\nfld qword ptr (_U2)\nfld qword ptr (_One)\nfsub qword ptr (_U2)\nfmulp st(1),st\nfaddp st(1),st\nfstp qword ptr (_Y)\nfld qword ptr (_F9)\nfsub qword ptr (_Half)\nfstp qword ptr (_Z)\nfld qword ptr (_X)\nfsub qword ptr (_Half)\nfsub qword ptr (_Z)\nfstp qword ptr (_X)\nfld qword ptr (_Y)\nfsub qword ptr (_One)\nfstp qword ptr (_Y)\nfld qword ptr (_Zero)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njne L279\nfld qword ptr (_Zero)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njne L279\nmov dword ptr (_RAddSub),2\nlea edi,(L281)\npush edi\ncall _printf\nadd esp,4\nL279:\ncmp dword ptr (_GAddSub),1\njne L282\nfld qword ptr (_Half)\nfadd qword ptr (_U2)\nfmul qword ptr (_U2)\nfstp qword ptr (_X)\nfld qword ptr (_Half)\nfsub qword ptr (_U2)\nfmul qword ptr (_U2)\nfstp qword ptr (_Y)\nfld qword ptr (_One)\nfadd qword ptr (_X)\nfstp qword ptr (_X)\nfld qword ptr (_One)\nfadd qword ptr (_Y)\nfstp qword ptr (_Y)\nfld qword ptr (_One)\nfadd qword ptr (_U2)\nfsub qword ptr (_X)\nfstp qword ptr (_X)\nfld qword ptr (_One)\nfsub qword ptr (_Y)\nfstp qword ptr (_Y)\nfld qword ptr (_Zero)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njne L284\nfld qword ptr (_Zero)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njne L284\nfld qword ptr (_Half)\nfadd qword ptr (_U2)\nfmul qword ptr (_U1)\nfstp qword ptr (_X)\nfld qword ptr (_Half)\nfsub qword ptr (_U2)\nfmul qword ptr (_U1)\nfstp qword ptr (_Y)\nfld qword ptr (_One)\nfsub qword ptr (_X)\nfstp qword ptr (_X)\nfld qword ptr (_One)\nfsub qword ptr (_Y)\nfstp qword ptr (_Y)\nfld qword ptr (_F9)\nfsub qword ptr (_X)\nfstp qword ptr (_X)\nfld qword ptr (_One)\nfsub qword ptr (_Y)\nfstp qword ptr (_Y)\nfld qword ptr (_Zero)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njne L286\nfld qword ptr (_Zero)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njne L286\nmov dword ptr (_RAddSub),1\nlea edi,(L288)\npush edi\ncall _printf\nadd esp,4\ncmp dword ptr (_GAddSub),0\njne L283\nlea edi,(L291)\npush edi\ncall _notify\nadd esp,4\njmp L283\nL286:\nlea edi,(L292)\npush edi\ncall _printf\nadd esp,4\njmp L283\nL284:\nlea edi,(L292)\npush edi\ncall _printf\nadd esp,4\njmp L283\nL282:\nlea edi,(L292)\npush edi\ncall _printf\nadd esp,4\nL283:\nfld qword ptr (_One)\nfstp qword ptr (_S)\nfld qword ptr (_One)\nfld qword ptr (_Half)\nfld qword ptr (_One)\nfadd qword ptr (_Half)\nfmulp st(1),st\nfaddp st(1),st\nfstp qword ptr (_X)\nfld qword ptr (_One)\nfadd qword ptr (_U2)\nfmul qword ptr (_Half)\nfstp qword ptr (_Y)\nfld qword ptr (_X)\nfstp qword ptr (-1164)[ebp]\nfld qword ptr (_Y)\nfstp qword ptr (-1172)[ebp]\nfld qword ptr (-1164)[ebp]\nfsub qword ptr (-1172)[ebp]\nfstp qword ptr (_Z)\nfld qword ptr (-1172)[ebp]\nfsub qword ptr (-1164)[ebp]\nfstp qword ptr (_T)\nfld qword ptr (_Z)\nfadd qword ptr (_T)\nfstp qword ptr (_StickyBit)\nfld qword ptr (_Zero)\nfcomp qword ptr (_StickyBit)\nfstsw ax\nsahf\nje L293\nfld qword ptr (_Zero)\nfstp qword ptr (_S)\nlea edi,(L295)\npush edi\npush 3\ncall _BadCond\nadd esp,8\nL293:\nfld qword ptr (_Zero)\nfstp qword ptr (_StickyBit)\ncmp dword ptr (_GMult),1\njne L296\ncmp dword ptr (_GDiv),1\njne L296\ncmp dword ptr (_GAddSub),1\njne L296\ncmp dword ptr (_RMult),1\njne L296\ncmp dword ptr (_RDiv),1\njne L296\ncmp dword ptr (_RAddSub),1\njne L296\nfld qword ptr (_RadixD2)\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-1180)[ebp]\nfld qword ptr (_RadixD2)\nfcomp qword ptr (-1180)[ebp]\nfstsw ax\nsahf\njne L296\nlea edi,(L298)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_Half)\nfadd qword ptr (_U1)\nfmul qword ptr (_U2)\nfstp qword ptr (_X)\nfld qword ptr (_Half)\nfmul qword ptr (_U2)\nfstp qword ptr (_Y)\nfld qword ptr (_One)\nfadd qword ptr (_Y)\nfstp qword ptr (_Z)\nfld qword ptr (_One)\nfadd qword ptr (_X)\nfstp qword ptr (_T)\nfld qword ptr (_Z)\nfsub qword ptr (_One)\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njb L299\nfld qword ptr (_T)\nfsub qword ptr (_One)\nfld qword ptr (_U2)\nfcompp\nfstsw ax\nsahf\nja L299\nfld qword ptr (_T)\nfadd qword ptr (_Y)\nfstp qword ptr (_Z)\nfld qword ptr (_Z)\nfsub qword ptr (_X)\nfstp qword ptr (_Y)\nfld qword ptr (_Z)\nfsub qword ptr (_T)\nfld qword ptr (_U2)\nfcompp\nfstsw ax\nsahf\nja L301\nfld qword ptr (_Y)\nfsub qword ptr (_T)\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L301\nfld qword ptr (_Half)\nfadd qword ptr (_U1)\nfmul qword ptr (_U1)\nfstp qword ptr (_X)\nfld qword ptr (_Half)\nfmul qword ptr (_U1)\nfstp qword ptr (_Y)\nfld qword ptr (_One)\nfsub qword ptr (_Y)\nfstp qword ptr (_Z)\nfld qword ptr (_One)\nfsub qword ptr (_X)\nfstp qword ptr (_T)\nfld qword ptr (_Z)\nfsub qword ptr (_One)\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L303\nfld qword ptr (_T)\nfsub qword ptr (_F9)\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L303\nfld qword ptr (_Half)\nfsub qword ptr (_U1)\nfmul qword ptr (_U1)\nfstp qword ptr (_Z)\nfld qword ptr (_F9)\nfsub qword ptr (_Z)\nfstp qword ptr (_T)\nfld qword ptr (_F9)\nfsub qword ptr (_Y)\nfstp qword ptr (_Q)\nfld qword ptr (_T)\nfsub qword ptr (_F9)\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L305\nfld qword ptr (_F9)\nfsub qword ptr (_U1)\nfsub qword ptr (_Q)\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L305\nfld qword ptr (_One)\nfadd qword ptr (_U2)\nfmul qword ptr (_OneAndHalf)\nfstp qword ptr (_Z)\nfld qword ptr (_OneAndHalf)\nfadd qword ptr (_U2)\nfsub qword ptr (_Z)\nfadd qword ptr (_U2)\nfstp qword ptr (_T)\nfld qword ptr (_One)\nfld qword ptr (_Half)\nfdiv qword ptr (_Radix)\nfaddp st(1),st\nfstp qword ptr (_X)\nfld qword ptr (_One)\nfld qword ptr (_Radix)\nfmul qword ptr (_U2)\nfaddp st(1),st\nfstp qword ptr (_Y)\nfld qword ptr (_X)\nfmul qword ptr (_Y)\nfstp qword ptr (_Z)\nfld qword ptr (_Zero)\nfcomp qword ptr (_T)\nfstsw ax\nsahf\njne L307\nfld qword ptr (_X)\nfld qword ptr (_Radix)\nfmul qword ptr (_U2)\nfaddp st(1),st\nfsub qword ptr (_Z)\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L307\nfld qword ptr (_Two)\nfcomp qword ptr (_Radix)\nfstsw ax\nsahf\nje L309\nfld qword ptr (_Two)\nfadd qword ptr (_U2)\nfstp qword ptr (_X)\nfld qword ptr (_X)\nfdiv qword ptr (_Two)\nfstp qword ptr (_Y)\nfld qword ptr (_Y)\nfsub qword ptr (_One)\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L310\nfld qword ptr (_S)\nfstp qword ptr (_StickyBit)\njmp L310\nL309:\nfld qword ptr (_S)\nfstp qword ptr (_StickyBit)\nL310:\nL307:\nL305:\nL303:\nL301:\nL299:\nL296:\nfld qword ptr (_One)\nfcomp qword ptr (_StickyBit)\nfstsw ax\nsahf\njne L313\nlea edi,(L315)\npush edi\ncall _printf\nadd esp,4\njmp L314\nL313:\nlea edi,(L316)\npush edi\ncall _printf\nadd esp,4\nL314:\nlea edi,(L318)\npush edi\ncmp dword ptr (_GMult),0\nje L319\ncmp dword ptr (_GDiv),0\nje L319\ncmp dword ptr (_GAddSub),0\nje L319\ncmp dword ptr (_RMult),0\nje L319\ncmp dword ptr (_RDiv),0\nje L319\ncmp dword ptr (_RAddSub),0\nje L319\nmov dword ptr (-1184)[ebp],1\njmp L320\nL319:\nmov dword ptr (-1184)[ebp],0\nL320:\nmov edi,dword ptr (-1184)[ebp]\npush edi\npush 3\ncall _TstCond\nadd esp,12\nmov dword ptr (_Milestone),60\nlea edi,(L44)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L321)\npush edi\ncall _printf\nadd esp,4\nmov edi,dword ptr (_NoTrials)\npush edi\nlea edi,(L322)\npush edi\ncall _printf\nadd esp,8\nfld qword ptr (L323)\nsub esp,8\nfstp qword ptr [esp]\ncall _sqrt\nadd esp,8\nfstp qword ptr (-1192)[ebp]\nfld qword ptr (-1192)[ebp]\nfstp qword ptr (_Random9)\nfld qword ptr (_Third)\nfstp qword ptr (_Random1)\nmov dword ptr (_I),1\nL324:\ncall _Random\nadd esp,0\nfstp qword ptr (-1200)[ebp]\nfld qword ptr (-1200)[ebp]\nfstp qword ptr (_X)\ncall _Random\nadd esp,0\nfstp qword ptr (-1208)[ebp]\nfld qword ptr (-1208)[ebp]\nfstp qword ptr (_Y)\nfld qword ptr (_Y)\nfmul qword ptr (_X)\nfstp qword ptr (_Z9)\nfld qword ptr (_X)\nfmul qword ptr (_Y)\nfstp qword ptr (_Z)\nfld qword ptr (_Z)\nfsub qword ptr (_Z9)\nfstp qword ptr (_Z9)\ninc dword ptr (_I)\nL325:\nmov edi,dword ptr (_NoTrials)\ncmp dword ptr (_I),edi\njg L327\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z9)\nfstsw ax\nsahf\nje L324\nL327:\nmov edi,dword ptr (_NoTrials)\ncmp dword ptr (_I),edi\njne L328\nfld qword ptr (_One)\nfld qword ptr (_Half)\nfdiv qword ptr (_Three)\nfaddp st(1),st\nfstp qword ptr (-1208)[ebp]\nfld qword ptr (-1208)[ebp]\nfstp qword ptr (_Random1)\nfld qword ptr (_U2)\nfadd qword ptr (_U1)\nfadd qword ptr (_One)\nfstp qword ptr (-1216)[ebp]\nfld qword ptr (-1216)[ebp]\nfstp qword ptr (_Random2)\nfld qword ptr (_Random1)\nfstp qword ptr (-1224)[ebp]\nfld qword ptr (_Random2)\nfstp qword ptr (-1232)[ebp]\nfld qword ptr (-1224)[ebp]\nfmul qword ptr (-1232)[ebp]\nfstp qword ptr (_Z)\nfld qword ptr (-1232)[ebp]\nfmul qword ptr (-1224)[ebp]\nfstp qword ptr (_Y)\nfld qword ptr (-1208)[ebp]\nfmul qword ptr (-1216)[ebp]\nfstp qword ptr (-1240)[ebp]\nfld qword ptr (-1240)[ebp]\nfsub qword ptr (-1240)[ebp]\nfstp qword ptr (_Z9)\nL328:\nmov edi,dword ptr (_NoTrials)\ncmp dword ptr (_I),edi\nje L330\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z9)\nfstsw ax\nsahf\nje L330\nlea edi,(L332)\npush edi\npush 2\ncall _BadCond\nadd esp,8\njmp L331\nL330:\nmov edi,dword ptr (_NoTrials)\npush edi\nlea edi,(L333)\npush edi\ncall _printf\nadd esp,8\nL331:\nmov dword ptr (_Milestone),70\nlea edi,(L334)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_Zero)\nsub esp,8\nfstp qword ptr [esp]\ncall _sqrt\nadd esp,8\nfstp qword ptr (-1212)[ebp]\nfld qword ptr (-1212)[ebp]\nfcomp qword ptr (_Zero)\nfstsw ax\nsahf\njne L337\nfld qword ptr (_Zero)\nfchs\nfstp qword ptr (-1220)[ebp]\nfld qword ptr (-1220)[ebp]\nsub esp,8\nfstp qword ptr [esp]\ncall _sqrt\nadd esp,8\nfstp qword ptr (-1228)[ebp]\nfld qword ptr (-1228)[ebp]\nfcomp qword ptr (-1220)[ebp]\nfstsw ax\nsahf\njne L337\nfld qword ptr (_One)\nsub esp,8\nfstp qword ptr [esp]\ncall _sqrt\nadd esp,8\nfstp qword ptr (-1244)[ebp]\nfld qword ptr (-1244)[ebp]\nfcomp qword ptr (_One)\nfstsw ax\nsahf\njne L337\nmov dword ptr (-1196)[ebp],1\njmp L338\nL337:\nmov dword ptr (-1196)[ebp],0\nL338:\nlea edi,(L336)\npush edi\nmov edi,dword ptr (-1196)[ebp]\npush edi\npush 0\ncall _TstCond\nadd esp,12\nfld qword ptr (_Zero)\nfstp qword ptr (_MinSqEr)\nfld qword ptr (_Zero)\nfstp qword ptr (_MaxSqEr)\nfld qword ptr (_Zero)\nfstp qword ptr (_J)\nfld qword ptr (_Radix)\nfstp qword ptr (_X)\nfld qword ptr (_U2)\nfstp qword ptr (_OneUlp)\npush 1\ncall _SqXMinX\nadd esp,4\nfld qword ptr (_BInvrse)\nfstp qword ptr (_X)\nfld qword ptr (_BInvrse)\nfmul qword ptr (_U1)\nfstp qword ptr (_OneUlp)\npush 1\ncall _SqXMinX\nadd esp,4\nfld qword ptr (_U1)\nfstp qword ptr (_X)\nfld qword ptr (_U1)\nfmul qword ptr (_U1)\nfstp qword ptr (_OneUlp)\npush 1\ncall _SqXMinX\nadd esp,4\nfld qword ptr (_Zero)\nfcomp qword ptr (_J)\nfstsw ax\nsahf\nje L339\ncall _Pause\nadd esp,0\nL339:\nmov edi,dword ptr (_NoTrials)\npush edi\nlea edi,(L341)\npush edi\ncall _printf\nadd esp,8\nfld qword ptr (_Zero)\nfstp qword ptr (_J)\nfld qword ptr (_Two)\nfstp qword ptr (_X)\nfld qword ptr (_Radix)\nfstp qword ptr (_Y)\nfld qword ptr (_One)\nfcomp qword ptr (_Radix)\nfstsw ax\nsahf\nje L342\nL344:\nfld qword ptr (_Y)\nfstp qword ptr (-1284)[ebp]\nfld qword ptr (-1284)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (_Radix)\nfmul qword ptr (-1284)[ebp]\nfstp qword ptr (_Y)\nL345:\nfld qword ptr (_Y)\nfsub qword ptr (_X)\nfild dword ptr (_NoTrials)\nfcompp\nfstsw ax\nsahf\nja L344\nL342:\nfld qword ptr (_X)\nfmul qword ptr (_U2)\nfstp qword ptr (_OneUlp)\nmov dword ptr (_I),1\njmp L348\nL347:\nfld qword ptr (_X)\nfadd qword ptr (_One)\nfstp qword ptr (_X)\npush 2\ncall _SqXMinX\nadd esp,4\nfld qword ptr (_Zero)\nfcomp qword ptr (_J)\nfstsw ax\nsahf\njae L350\njmp L349\nL350:\ninc dword ptr (_I)\nL348:\nmov edi,dword ptr (_NoTrials)\ncmp dword ptr (_I),edi\njle L347\nL349:\nlea edi,(L352)\npush edi\ncall _printf\nadd esp,4\nmov dword ptr (_I),-1\nfld qword ptr (_BMinusU2)\nfstp qword ptr (_X)\nfld qword ptr (_Radix)\nfstp qword ptr (_Y)\nfld qword ptr (_Radix)\nfld qword ptr (_Radix)\nfmul qword ptr (_U2)\nfaddp st(1),st\nfstp qword ptr (_Z)\nmov dword ptr (_NotMonot),0\nmov dword ptr (_Monot),0\njmp L354\nL353:\ninc dword ptr (_I)\nfld qword ptr (_X)\nsub esp,8\nfstp qword ptr [esp]\ncall _sqrt\nadd esp,8\nfstp qword ptr (-1292)[ebp]\nfld qword ptr (-1292)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (_Y)\nsub esp,8\nfstp qword ptr [esp]\ncall _sqrt\nadd esp,8\nfstp qword ptr (-1300)[ebp]\nfld qword ptr (-1300)[ebp]\nfstp qword ptr (_Q)\nfld qword ptr (_Z)\nsub esp,8\nfstp qword ptr [esp]\ncall _sqrt\nadd esp,8\nfstp qword ptr (-1308)[ebp]\nfld qword ptr (-1308)[ebp]\nfstp qword ptr (_Z)\nfld qword ptr (_Q)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njb L358\nfld qword ptr (_Z)\nfcomp qword ptr (_Q)\nfstsw ax\nsahf\njae L356\nL358:\nmov dword ptr (_NotMonot),1\njmp L357\nL356:\nfld qword ptr (_Q)\nfadd qword ptr (_Half)\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-1324)[ebp]\nfld qword ptr (-1324)[ebp]\nfstp qword ptr (_Q)\ncmp dword ptr (_I),0\njg L361\nfld qword ptr (_Q)\nfmul qword ptr (_Q)\nfcomp qword ptr (_Radix)\nfstsw ax\nsahf\njne L359\nL361:\nmov dword ptr (_Monot),1\njmp L360\nL359:\ncmp dword ptr (_I),0\njle L362\ncmp dword ptr (_I),1\njle L364\nmov dword ptr (_Monot),1\njmp L363\nL364:\nfld qword ptr (_Y)\nfmul qword ptr (_BInvrse)\nfstp qword ptr (_Y)\nfld qword ptr (_Y)\nfstp qword ptr (-1340)[ebp]\nfld qword ptr (-1340)[ebp]\nfsub qword ptr (_U1)\nfstp qword ptr (_X)\nfld qword ptr (-1340)[ebp]\nfadd qword ptr (_U1)\nfstp qword ptr (_Z)\njmp L363\nL362:\nfld qword ptr (_Q)\nfstp qword ptr (_Y)\nfld qword ptr (_Y)\nfstp qword ptr (-1340)[ebp]\nfld qword ptr (-1340)[ebp]\nfsub qword ptr (_U2)\nfstp qword ptr (_X)\nfld qword ptr (-1340)[ebp]\nfadd qword ptr (_U2)\nfstp qword ptr (_Z)\nL363:\nL360:\nL357:\nL354:\ncmp dword ptr (_NotMonot),0\njne L366\ncmp dword ptr (_Monot),0\nje L353\nL366:\ncmp dword ptr (_Monot),0\nje L367\nlea edi,(L369)\npush edi\ncall _printf\nadd esp,4\njmp L368\nL367:\nlea edi,(L157)\npush edi\npush 2\ncall _BadCond\nadd esp,8\nfld qword ptr (_Y)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L370)\npush edi\ncall _printf\nadd esp,12\nL368:\nmov dword ptr (_Milestone),80\nfld qword ptr (_MinSqEr)\nfadd qword ptr (_Half)\nfstp qword ptr (_MinSqEr)\nfld qword ptr (_MaxSqEr)\nfsub qword ptr (_Half)\nfstp qword ptr (_MaxSqEr)\nfld qword ptr (_One)\nfadd qword ptr (_U2)\nsub esp,8\nfstp qword ptr [esp]\ncall _sqrt\nadd esp,8\nfstp qword ptr (-1300)[ebp]\nfld qword ptr (-1300)[ebp]\nfsub qword ptr (_One)\nfdiv qword ptr (_U2)\nfstp qword ptr (_Y)\nfld qword ptr (_Y)\nfsub qword ptr (_One)\nfld qword ptr (_U2)\nfdiv qword ptr (_Eight)\nfaddp st(1),st\nfstp qword ptr (_SqEr)\nfld qword ptr (_MaxSqEr)\nfcomp qword ptr (_SqEr)\nfstsw ax\nsahf\njae L371\nfld qword ptr (_SqEr)\nfstp qword ptr (_MaxSqEr)\nL371:\nfld qword ptr (_Y)\nfld qword ptr (_U2)\nfdiv qword ptr (_Eight)\nfaddp st(1),st\nfstp qword ptr (_SqEr)\nfld qword ptr (_MinSqEr)\nfcomp qword ptr (_SqEr)\nfstsw ax\nsahf\njbe L373\nfld qword ptr (_SqEr)\nfstp qword ptr (_MinSqEr)\nL373:\nfld qword ptr (_F9)\nsub esp,8\nfstp qword ptr [esp]\ncall _sqrt\nadd esp,8\nfstp qword ptr (-1324)[ebp]\nfld qword ptr (-1324)[ebp]\nfsub qword ptr (_U2)\nfld qword ptr (_One)\nfsub qword ptr (_U2)\nfsubp st(1),st\nfdiv qword ptr (_U1)\nfstp qword ptr (_Y)\nfld qword ptr (_Y)\nfld qword ptr (_U1)\nfdiv qword ptr (_Eight)\nfaddp st(1),st\nfstp qword ptr (_SqEr)\nfld qword ptr (_MaxSqEr)\nfcomp qword ptr (_SqEr)\nfstsw ax\nsahf\njae L375\nfld qword ptr (_SqEr)\nfstp qword ptr (_MaxSqEr)\nL375:\nfld qword ptr (_Y)\nfadd qword ptr (_One)\nfld qword ptr (_U1)\nfdiv qword ptr (_Eight)\nfaddp st(1),st\nfstp qword ptr (_SqEr)\nfld qword ptr (_MinSqEr)\nfcomp qword ptr (_SqEr)\nfstsw ax\nsahf\njbe L377\nfld qword ptr (_SqEr)\nfstp qword ptr (_MinSqEr)\nL377:\nfld qword ptr (_U2)\nfstp qword ptr (_OneUlp)\nfld qword ptr (_OneUlp)\nfstp qword ptr (_X)\nmov dword ptr (_Indx),1\nL379:\nfld qword ptr (_X)\nfadd qword ptr (_U1)\nfadd qword ptr (_X)\nfadd qword ptr (_F9)\nsub esp,8\nfstp qword ptr [esp]\ncall _sqrt\nadd esp,8\nfstp qword ptr (-1356)[ebp]\nfld qword ptr (-1356)[ebp]\nfstp qword ptr (_Y)\nfld qword ptr (_Y)\nfsub qword ptr (_U2)\nfld qword ptr (_One)\nfsub qword ptr (_U2)\nfadd qword ptr (_X)\nfsubp st(1),st\nfdiv qword ptr (_OneUlp)\nfstp qword ptr (_Y)\nfld qword ptr (_U1)\nfsub qword ptr (_X)\nfadd qword ptr (_F9)\nfmul qword ptr (_Half)\nfmul qword ptr (_X)\nfmul qword ptr (_X)\nfdiv qword ptr (_OneUlp)\nfstp qword ptr (_Z)\nfld qword ptr (_Y)\nfadd qword ptr (_Half)\nfadd qword ptr (_Z)\nfstp qword ptr (_SqEr)\nfld qword ptr (_MinSqEr)\nfcomp qword ptr (_SqEr)\nfstsw ax\nsahf\njbe L383\nfld qword ptr (_SqEr)\nfstp qword ptr (_MinSqEr)\nL383:\nfld qword ptr (_Y)\nfsub qword ptr (_Half)\nfadd qword ptr (_Z)\nfstp qword ptr (_SqEr)\nfld qword ptr (_MaxSqEr)\nfcomp qword ptr (_SqEr)\nfstsw ax\nsahf\njae L385\nfld qword ptr (_SqEr)\nfstp qword ptr (_MaxSqEr)\nL385:\nmov edi,dword ptr (_Indx)\ncmp edi,1\nje L389\ncmp edi,3\njne L387\nL389:\nfld qword ptr (_X)\nsub esp,8\nfstp qword ptr [esp]\ncall _Sign\nadd esp,8\nfstp qword ptr (-1396)[ebp]\nfld qword ptr (_OneUlp)\nsub esp,8\nfstp qword ptr [esp]\ncall _sqrt\nadd esp,8\nfstp qword ptr (-1404)[ebp]\nfld qword ptr (_Eight)\nfld qword ptr (_Nine)\nfmul qword ptr (-1404)[ebp]\nfdivp st(1),st\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-1412)[ebp]\nfld qword ptr (_OneUlp)\nfmul qword ptr (-1396)[ebp]\nfmul qword ptr (-1412)[ebp]\nfstp qword ptr (_X)\njmp L388\nL387:\nfld qword ptr (_U1)\nfstp qword ptr (_OneUlp)\nfld qword ptr (_OneUlp)\nfchs\nfstp qword ptr (_X)\nL388:\nL380:\ninc dword ptr (_Indx)\ncmp dword ptr (_Indx),3\njle L379\nmov dword ptr (_Milestone),85\nmov dword ptr (_SqRWrng),0\nmov dword ptr (_Anomaly),0\nmov dword ptr (_RSqrt),0\nfld qword ptr (_One)\nfcomp qword ptr (_Radix)\nfstsw ax\nsahf\nje L390\nlea edi,(L392)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_Precision)\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-1356)[ebp]\nfld qword ptr (_One)\nfadd qword ptr (_Precision)\nfsub qword ptr (-1356)[ebp]\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_Radix)\nsub esp,8\nfstp qword ptr [esp]\ncall _pow\nadd esp,16\nfstp qword ptr (-1364)[ebp]\nfld qword ptr (_Half)\nfadd qword ptr (-1364)[ebp]\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-1372)[ebp]\nfld qword ptr (-1372)[ebp]\nfstp qword ptr (_D)\nfld qword ptr (_D)\nfdiv qword ptr (_Radix)\nfstp qword ptr (_X)\nfld qword ptr (_D)\nfdiv qword ptr (_A1)\nfstp qword ptr (_Y)\nfld qword ptr (_X)\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-1396)[ebp]\nfld qword ptr (-1396)[ebp]\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njne L395\nfld qword ptr (_Y)\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-1412)[ebp]\nfld qword ptr (-1412)[ebp]\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\nje L393\nL395:\nmov dword ptr (_Anomaly),1\njmp L394\nL393:\nfld qword ptr (_Zero)\nfstp qword ptr (_X)\nfld qword ptr (_X)\nfstp qword ptr (_Z2)\nfld qword ptr (_One)\nfstp qword ptr (_Y)\nfld qword ptr (_Y)\nfstp qword ptr (_Y2)\nfld qword ptr (_Radix)\nfsub qword ptr (_One)\nfstp qword ptr (_Z1)\nfld qword ptr (_Four)\nfmul qword ptr (_D)\nfstp qword ptr (_FourD)\nL396:\nfld qword ptr (_Z2)\nfcomp qword ptr (_Y2)\nfstsw ax\nsahf\njae L399\nfld qword ptr (_Radix)\nfstp qword ptr (_Q)\nfld qword ptr (_Y)\nfstp qword ptr (_Y1)\nL401:\nfld qword ptr (_Half)\nfld qword ptr (_Q)\nfdiv qword ptr (_Y1)\nfsubp st(1),st\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-1436)[ebp]\nfld qword ptr (_Q)\nfld qword ptr (-1436)[ebp]\nfmul qword ptr (_Y1)\nfaddp st(1),st\nsub esp,8\nfstp qword ptr [esp]\ncall _fabs\nadd esp,8\nfstp qword ptr (-1444)[ebp]\nfld qword ptr (-1444)[ebp]\nfstp qword ptr (_X1)\nfld qword ptr (_Y1)\nfstp qword ptr (_Q)\nfld qword ptr (_X1)\nfstp qword ptr (_Y1)\nL402:\nfld qword ptr (_Zero)\nfcomp qword ptr (_X1)\nfstsw ax\nsahf\njb L401\nfld qword ptr (_One)\nfcomp qword ptr (_Q)\nfstsw ax\nsahf\njb L404\nfld qword ptr (_Y2)\nfstp qword ptr (_Z2)\nfld qword ptr (_Y)\nfstp qword ptr (_Z)\nL404:\nL399:\nfld qword ptr (_Y)\nfadd qword ptr (_Two)\nfstp qword ptr (_Y)\nfld qword ptr (_X)\nfadd qword ptr (_Eight)\nfstp qword ptr (_X)\nfld qword ptr (_Y2)\nfadd qword ptr (_X)\nfstp qword ptr (_Y2)\nfld qword ptr (_FourD)\nfcomp qword ptr (_Y2)\nfstsw ax\nsahf\nja L406\nfld qword ptr (_Y2)\nfsub qword ptr (_FourD)\nfstp qword ptr (_Y2)\nL406:\nL397:\nfld qword ptr (_D)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\nja L396\nfld qword ptr (_FourD)\nfsub qword ptr (_Z2)\nfstp qword ptr (_X8)\nfld qword ptr (_X8)\nfstp qword ptr (-1436)[ebp]\nfld qword ptr (-1436)[ebp]\nfld qword ptr (_Z)\nfmul qword ptr (_Z)\nfaddp st(1),st\nfdiv qword ptr (_FourD)\nfstp qword ptr (_Q)\nfld qword ptr (-1436)[ebp]\nfdiv qword ptr (_Eight)\nfstp qword ptr (_X8)\nfld qword ptr (_Q)\nfstp qword ptr (-1452)[ebp]\nfld qword ptr (-1452)[ebp]\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-1460)[ebp]\nfld qword ptr (-1460)[ebp]\nfcomp qword ptr (-1452)[ebp]\nfstsw ax\nsahf\nje L408\nmov dword ptr (_Anomaly),1\njmp L409\nL408:\nmov dword ptr (_Break),0\nL410:\nfld qword ptr (_Z1)\nfmul qword ptr (_Z)\nfstp qword ptr (_X)\nfld qword ptr (_X)\nfstp qword ptr (-1468)[ebp]\nfld qword ptr (-1468)[ebp]\nfdiv qword ptr (_Radix)\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-1476)[ebp]\nfld qword ptr (-1468)[ebp]\nfld qword ptr (-1476)[ebp]\nfmul qword ptr (_Radix)\nfsubp st(1),st\nfstp qword ptr (_X)\nfld qword ptr (_One)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njne L413\nmov dword ptr (_Break),1\njmp L414\nL413:\nfld qword ptr (_Z1)\nfsub qword ptr (_One)\nfstp qword ptr (_Z1)\nL414:\nL411:\ncmp dword ptr (_Break),0\njne L415\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z1)\nfstsw ax\nsahf\njb L410\nL415:\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z1)\nfstsw ax\nsahf\njb L416\ncmp dword ptr (_Break),0\njne L416\nmov dword ptr (_Anomaly),1\njmp L417\nL416:\nfld qword ptr (_RadixD2)\nfcomp qword ptr (_Z1)\nfstsw ax\nsahf\njae L418\nfld qword ptr (_Z1)\nfsub qword ptr (_Radix)\nfstp qword ptr (_Z1)\nL418:\nL420:\ncall _NewD\nadd esp,0\nL421:\nfld qword ptr (_U2)\nfmul qword ptr (_D)\nfld qword ptr (_F9)\nfcompp\nfstsw ax\nsahf\nja L420\nfld qword ptr (_D)\nfmul qword ptr (_Radix)\nfsub qword ptr (_D)\nfld qword ptr (_W)\nfsub qword ptr (_D)\nfcompp\nfstsw ax\nsahf\nje L423\nmov dword ptr (_Anomaly),1\njmp L424\nL423:\nfld qword ptr (_D)\nfstp qword ptr (_Z2)\nmov dword ptr (_I),0\nfld qword ptr (_D)\nfld qword ptr (_One)\nfadd qword ptr (_Z)\nfmul qword ptr (_Half)\nfaddp st(1),st\nfstp qword ptr (_Y)\nfld qword ptr (_D)\nfadd qword ptr (_Z)\nfadd qword ptr (_Q)\nfstp qword ptr (_X)\ncall _SR3750\nadd esp,0\nfld qword ptr (_D)\nfld qword ptr (_One)\nfsub qword ptr (_Z)\nfmul qword ptr (_Half)\nfaddp st(1),st\nfadd qword ptr (_D)\nfstp qword ptr (_Y)\nfld qword ptr (_D)\nfsub qword ptr (_Z)\nfadd qword ptr (_D)\nfstp qword ptr (_X)\nfld qword ptr (_X)\nfstp qword ptr (-1508)[ebp]\nfld qword ptr (-1508)[ebp]\nfadd qword ptr (_Q)\nfadd qword ptr (-1508)[ebp]\nfstp qword ptr (_X)\ncall _SR3750\nadd esp,0\ncall _NewD\nadd esp,0\nfld qword ptr (_D)\nfsub qword ptr (_Z2)\nfld qword ptr (_W)\nfsub qword ptr (_Z2)\nfcompp\nfstsw ax\nsahf\nje L425\nmov dword ptr (_Anomaly),1\njmp L426\nL425:\nfld qword ptr (_D)\nfsub qword ptr (_Z2)\nfstp qword ptr (-1532)[ebp]\nfld qword ptr (-1532)[ebp]\nfld qword ptr (_Z2)\nfld qword ptr (_One)\nfsub qword ptr (_Z)\nfmul qword ptr (_Half)\nfaddp st(1),st\nfaddp st(1),st\nfstp qword ptr (_Y)\nfld qword ptr (-1532)[ebp]\nfld qword ptr (_Z2)\nfsub qword ptr (_Z)\nfadd qword ptr (_Q)\nfaddp st(1),st\nfstp qword ptr (_X)\ncall _SR3750\nadd esp,0\nfld qword ptr (_One)\nfadd qword ptr (_Z)\nfmul qword ptr (_Half)\nfstp qword ptr (_Y)\nfld qword ptr (_Q)\nfstp qword ptr (_X)\ncall _SR3750\nadd esp,0\ncmp dword ptr (_I),0\njne L427\nmov dword ptr (_Anomaly),1\nL427:\nL426:\nL424:\nL417:\nL409:\nL394:\ncmp dword ptr (_I),0\nje L431\ncmp dword ptr (_Anomaly),0\nje L429\nL431:\nlea edi,(L432)\npush edi\npush 0\ncall _BadCond\nadd esp,8\nfld qword ptr (_W)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L433)\npush edi\ncall _printf\nadd esp,12\nlea edi,(L434)\npush edi\ncall _printf\nadd esp,4\nmov dword ptr (_SqRWrng),1\nL429:\nL390:\ncmp dword ptr (_Anomaly),0\njne L435\nfld qword ptr (_Zero)\nfcomp qword ptr (_MinSqEr)\nfstsw ax\nsahf\nja L437\nfld qword ptr (_Zero)\nfcomp qword ptr (_MaxSqEr)\nfstsw ax\nsahf\njb L437\nmov dword ptr (_RSqrt),1\nlea edi,(L439)\npush edi\ncall _printf\nadd esp,4\njmp L438\nL437:\nfld qword ptr (_MaxSqEr)\nfadd qword ptr (_U2)\nfld qword ptr (_U2)\nfsub qword ptr (_Half)\nfcompp\nfstsw ax\nsahf\njb L443\nfld qword ptr (_Half)\nfcomp qword ptr (_MinSqEr)\nfstsw ax\nsahf\njb L443\nfld qword ptr (_MinSqEr)\nfadd qword ptr (_Radix)\nfld qword ptr (_Half)\nfcompp\nfstsw ax\nsahf\njbe L440\nL443:\nmov dword ptr (_SqRWrng),1\njmp L441\nL440:\nmov dword ptr (_RSqrt),2\nlea edi,(L444)\npush edi\ncall _printf\nadd esp,4\nL441:\nL438:\nL435:\ncmp dword ptr (_SqRWrng),0\nje L445\nlea edi,(L447)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_MinSqEr)\nfsub qword ptr (_Half)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L448)\npush edi\ncall _printf\nadd esp,12\nfld qword ptr (_Half)\nfadd qword ptr (_MaxSqEr)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L449)\npush edi\ncall _printf\nadd esp,12\nlea edi,(L451)\npush edi\nfld qword ptr (_MaxSqEr)\nfsub qword ptr (_MinSqEr)\nfld qword ptr (_Radix)\nfmul qword ptr (_Radix)\nfcompp\nfstsw ax\nsahf\njbe L452\nmov dword ptr (-1344)[ebp],1\njmp L453\nL452:\nmov dword ptr (-1344)[ebp],0\nL453:\nmov edi,dword ptr (-1344)[ebp]\npush edi\npush 1\ncall _TstCond\nadd esp,12\nL445:\nmov dword ptr (_Milestone),90\ncall _Pause\nadd esp,0\nlea edi,(L454)\npush edi\ncall _printf\nadd esp,4\nmov dword ptr (_N),0\nmov dword ptr (_I),0\nfld qword ptr (_Zero)\nfchs\nfstp qword ptr (_Z)\nmov dword ptr (_M),3\nmov dword ptr (_Break),0\nL455:\nfld qword ptr (_One)\nfstp qword ptr (_X)\ncall _SR3980\nadd esp,0\ncmp dword ptr (_I),10\njg L458\nmov dword ptr (_I),1023\ncall _SR3980\nadd esp,0\nL458:\nfld qword ptr (_MinusOne)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njne L460\nmov dword ptr (_Break),1\njmp L461\nL460:\nfld qword ptr (_MinusOne)\nfstp qword ptr (_Z)\ncall _PrintIfNPositive\nadd esp,0\nmov dword ptr (_N),0\nmov dword ptr (_I),-4\nL461:\nL456:\ncmp dword ptr (_Break),0\nje L455\ncall _PrintIfNPositive\nadd esp,0\nmov edi,dword ptr (_N)\nmov dword ptr (_N1),edi\nmov dword ptr (_N),0\nfld qword ptr (_A1)\nfstp qword ptr (_Z)\nfld qword ptr (_W)\nsub esp,8\nfstp qword ptr [esp]\ncall _log\nadd esp,8\nfstp qword ptr (-1348)[ebp]\nfld qword ptr (_A1)\nsub esp,8\nfstp qword ptr [esp]\ncall _log\nadd esp,8\nfstp qword ptr (-1356)[ebp]\nfld qword ptr (_Two)\nfmul qword ptr (-1348)[ebp]\nfdiv qword ptr (-1356)[ebp]\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-1364)[ebp]\nfld qword ptr (-1364)[ebp]\ncall __ftol\nmov dword ptr (_M),eax\nmov dword ptr (_Break),0\nL462:\nfld qword ptr (_Z)\nfstp qword ptr (_X)\nmov dword ptr (_I),1\ncall _SR3980\nadd esp,0\nfld qword ptr (_AInvrse)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njne L465\nmov dword ptr (_Break),1\njmp L466\nL465:\nfld qword ptr (_AInvrse)\nfstp qword ptr (_Z)\nL466:\nL463:\ncmp dword ptr (_Break),0\nje L462\nmov dword ptr (_Milestone),100\nmov edi,dword ptr (_NoTrials)\nmov dword ptr (_M),edi\nfld qword ptr (_Three)\nfstp qword ptr (_Z)\nL467:\nfld qword ptr (_Z)\nfstp qword ptr (_X)\nmov dword ptr (_I),1\ncall _SR3980\nadd esp,0\nL470:\nfld qword ptr (_Z)\nfadd qword ptr (_Two)\nfstp qword ptr (_Z)\nL471:\nfld qword ptr (_Z)\nfdiv qword ptr (_Three)\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-1380)[ebp]\nfld qword ptr (_Three)\nfmul qword ptr (-1380)[ebp]\nfld qword ptr (_Z)\nfcompp\nfstsw ax\nsahf\nje L470\nL468:\nfld qword ptr (_Eight)\nfmul qword ptr (_Three)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\nja L467\ncmp dword ptr (_N),0\njle L473\nlea edi,(L475)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L476)\npush edi\ncall _printf\nadd esp,4\nL473:\ncall _PrintIfNPositive\nadd esp,0\nmov edi,dword ptr (_N1)\nadd dword ptr (_N),edi\ncmp dword ptr (_N),0\njne L477\nlea edi,(L479)\npush edi\ncall _printf\nadd esp,4\nL477:\ncmp dword ptr (_N),0\njle L480\ncall _Pause\nadd esp,0\njmp L481\nL480:\nlea edi,(L44)\npush edi\ncall _printf\nadd esp,4\nL481:\nmov dword ptr (_Milestone),110\nlea edi,(L482)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_U1)\nfstp qword ptr (_D)\nfld qword ptr (_Precision)\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-1380)[ebp]\nfld qword ptr (-1380)[ebp]\nfcomp qword ptr (_Precision)\nfstsw ax\nsahf\nje L483\nfld qword ptr (_BInvrse)\nfstp qword ptr (_D)\nfld qword ptr (_Precision)\nfstp qword ptr (_X)\nL485:\nfld qword ptr (_D)\nfmul qword ptr (_BInvrse)\nfstp qword ptr (_D)\nfld qword ptr (_X)\nfsub qword ptr (_One)\nfstp qword ptr (_X)\nL486:\nfld qword ptr (_Zero)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njb L485\nL483:\nfld qword ptr (_One)\nfstp qword ptr (_Y)\nfld qword ptr (_D)\nfstp qword ptr (_Z)\nL488:\nfld qword ptr (_Y)\nfstp qword ptr (_C)\nfld qword ptr (_Z)\nfstp qword ptr (_Y)\nfld qword ptr (_Y)\nfstp qword ptr (-1388)[ebp]\nfld qword ptr (-1388)[ebp]\nfmul qword ptr (-1388)[ebp]\nfstp qword ptr (_Z)\nL489:\nfld qword ptr (_Z)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njae L491\nfld qword ptr (_Z)\nfadd qword ptr (_Z)\nfld qword ptr (_Z)\nfcompp\nfstsw ax\nsahf\njb L488\nL491:\nfld qword ptr (_C)\nfstp qword ptr (_Y)\nfld qword ptr (_Y)\nfmul qword ptr (_D)\nfstp qword ptr (_Z)\nL492:\nfld qword ptr (_Y)\nfstp qword ptr (_C)\nfld qword ptr (_Z)\nfstp qword ptr (_Y)\nfld qword ptr (_Y)\nfmul qword ptr (_D)\nfstp qword ptr (_Z)\nL493:\nfld qword ptr (_Z)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njae L495\nfld qword ptr (_Z)\nfadd qword ptr (_Z)\nfld qword ptr (_Z)\nfcompp\nfstsw ax\nsahf\njb L492\nL495:\nfld qword ptr (_Two)\nfcomp qword ptr (_Radix)\nfstsw ax\nsahf\njbe L496\nfld qword ptr (_Two)\nfstp qword ptr (_HInvrse)\njmp L497\nL496:\nfld qword ptr (_Radix)\nfstp qword ptr (_HInvrse)\nL497:\nfld qword ptr (_One)\nfdiv qword ptr (_HInvrse)\nfstp qword ptr (_H)\nfld qword ptr (_One)\nfdiv qword ptr (_C)\nfstp qword ptr (_CInvrse)\nfld qword ptr (_C)\nfstp qword ptr (_E0)\nfld qword ptr (_E0)\nfmul qword ptr (_H)\nfstp qword ptr (_Z)\nL498:\nfld qword ptr (_E0)\nfstp qword ptr (_Y)\nfld qword ptr (_Z)\nfstp qword ptr (_E0)\nfld qword ptr (_E0)\nfmul qword ptr (_H)\nfstp qword ptr (_Z)\nL499:\nfld qword ptr (_Z)\nfcomp qword ptr (_E0)\nfstsw ax\nsahf\njae L501\nfld qword ptr (_Z)\nfadd qword ptr (_Z)\nfld qword ptr (_Z)\nfcompp\nfstsw ax\nsahf\njb L498\nL501:\nfld qword ptr (_E0)\nfstp qword ptr (_UfThold)\nfld qword ptr (_Zero)\nfstp qword ptr (_E1)\nfld qword ptr (_Zero)\nfstp qword ptr (_Q)\nfld qword ptr (_U2)\nfstp qword ptr (_E9)\nfld qword ptr (_One)\nfadd qword ptr (_E9)\nfstp qword ptr (_S)\nfld qword ptr (_C)\nfmul qword ptr (_S)\nfstp qword ptr (_D)\nfld qword ptr (_C)\nfcomp qword ptr (_D)\nfstsw ax\nsahf\njb L502\nfld qword ptr (_Radix)\nfmul qword ptr (_U2)\nfstp qword ptr (_E9)\nfld qword ptr (_One)\nfadd qword ptr (_E9)\nfstp qword ptr (_S)\nfld qword ptr (_C)\nfmul qword ptr (_S)\nfstp qword ptr (_D)\nfld qword ptr (_C)\nfcomp qword ptr (_D)\nfstsw ax\nsahf\njb L503\nlea edi,(L506)\npush edi\npush 0\ncall _BadCond\nadd esp,8\nfld qword ptr (_E0)\nfstp qword ptr (_Underflow)\nfld qword ptr (_Zero)\nfstp qword ptr (_Y1)\nfld qword ptr (_Z)\nfstp qword ptr (_PseudoZero)\ncall _Pause\nadd esp,0\njmp L503\nL502:\nfld qword ptr (_D)\nfstp qword ptr (_Underflow)\nfld qword ptr (_Underflow)\nfmul qword ptr (_H)\nfstp qword ptr (_PseudoZero)\nfld qword ptr (_Zero)\nfstp qword ptr (_UfThold)\nL507:\nfld qword ptr (_Underflow)\nfstp qword ptr (_Y1)\nfld qword ptr (_PseudoZero)\nfstp qword ptr (_Underflow)\nfld qword ptr (_E1)\nfadd qword ptr (_E1)\nfld qword ptr (_E1)\nfcompp\nfstsw ax\nsahf\njb L510\nfld qword ptr (_Underflow)\nfmul qword ptr (_HInvrse)\nfstp qword ptr (_Y2)\nfld qword ptr (_Y1)\nfsub qword ptr (_Y2)\nsub esp,8\nfstp qword ptr [esp]\ncall _fabs\nadd esp,8\nfstp qword ptr (-1452)[ebp]\nfld qword ptr (-1452)[ebp]\nfstp qword ptr (_E1)\nfld qword ptr (_Y1)\nfstp qword ptr (_Q)\nfld qword ptr (_Zero)\nfcomp qword ptr (_UfThold)\nfstsw ax\nsahf\njne L512\nfld qword ptr (_Y2)\nfcomp qword ptr (_Y1)\nfstsw ax\nsahf\nje L512\nfld qword ptr (_Y1)\nfstp qword ptr (_UfThold)\nL512:\nL510:\nfld qword ptr (_PseudoZero)\nfmul qword ptr (_H)\nfstp qword ptr (_PseudoZero)\nL508:\nfld qword ptr (_PseudoZero)\nfcomp qword ptr (_Underflow)\nfstsw ax\nsahf\njae L514\nfld qword ptr (_PseudoZero)\nfadd qword ptr (_PseudoZero)\nfld qword ptr (_PseudoZero)\nfcompp\nfstsw ax\nsahf\njb L507\nL514:\nL503:\nfld qword ptr (_Zero)\nfcomp qword ptr (_PseudoZero)\nfstsw ax\nsahf\nje L515\nlea edi,(L44)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_PseudoZero)\nfstp qword ptr (_Z)\nfld qword ptr (_Zero)\nfcomp qword ptr (_PseudoZero)\nfstsw ax\nsahf\njb L517\nlea edi,(L519)\npush edi\npush 0\ncall _BadCond\nadd esp,8\nlea edi,(L520)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_PseudoZero)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L521)\npush edi\ncall _printf\nadd esp,12\nfld qword ptr (_PseudoZero)\nfchs\nfstp qword ptr (_X)\nfld qword ptr (_Zero)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njb L518\nlea edi,(L524)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_X)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L525)\npush edi\ncall _printf\nadd esp,12\njmp L518\nL517:\nlea edi,(L526)\npush edi\npush 3\ncall _BadCond\nadd esp,8\nfld qword ptr (_PseudoZero)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L527)\npush edi\ncall _printf\nadd esp,12\nL518:\ncall _TstPtUf\nadd esp,0\nL515:\nmov dword ptr (_Milestone),120\nfld qword ptr (_CInvrse)\nfmul qword ptr (_Y)\nfld qword ptr (_CInvrse)\nfmul qword ptr (_Y1)\nfcompp\nfstsw ax\nsahf\njae L528\nfld qword ptr (_H)\nfmul qword ptr (_S)\nfstp qword ptr (_S)\nfld qword ptr (_Underflow)\nfstp qword ptr (_E0)\nL528:\nfld qword ptr (_Zero)\nfcomp qword ptr (_E1)\nfstsw ax\nsahf\nje L530\nfld qword ptr (_E0)\nfcomp qword ptr (_E1)\nfstsw ax\nsahf\nje L530\nlea edi,(L157)\npush edi\npush 2\ncall _BadCond\nadd esp,8\nfld qword ptr (_E0)\nfcomp qword ptr (_E1)\nfstsw ax\nsahf\njbe L532\nlea edi,(L534)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L535)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_Zero)\nfcomp qword ptr (_PseudoZero)\nfstsw ax\nsahf\njne L533\nfld qword ptr (_E1)\nfstp qword ptr (_E0)\njmp L533\nL532:\nlea edi,(L538)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L539)\npush edi\ncall _printf\nadd esp,4\nL533:\nL530:\nfld qword ptr (_E0)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L540)\npush edi\ncall _printf\nadd esp,12\nfld qword ptr (_E0)\nfstp qword ptr (_Z)\ncall _TstPtUf\nadd esp,0\nfld qword ptr (_E0)\nfstp qword ptr (_Underflow)\ncmp dword ptr (_N),1\njne L541\nfld qword ptr (_Y)\nfstp qword ptr (_Underflow)\nL541:\nmov dword ptr (_I),4\nfld qword ptr (_Zero)\nfcomp qword ptr (_E1)\nfstsw ax\nsahf\njne L543\nmov dword ptr (_I),3\nL543:\nfld qword ptr (_Zero)\nfcomp qword ptr (_UfThold)\nfstsw ax\nsahf\njne L545\nsub dword ptr (_I),2\nL545:\nmov dword ptr (_UfNGrad),1\nmov edi,dword ptr (_I)\ncmp edi,1\njl L547\ncmp edi,4\njg L547\njmp dword ptr (L570-4)[edi*4]\n_TEXT ends\n_TEXT segment\nalign 4\nL570 label byte\ndd L549\ndd L556\ndd L561\ndd L562\n_TEXT ends\n_TEXT segment\nL549:\nfld qword ptr (_Underflow)\nfstp qword ptr (_UfThold)\nfld qword ptr (_CInvrse)\nfmul qword ptr (_Q)\nfld qword ptr (_CInvrse)\nfmul qword ptr (_Y)\nfmul qword ptr (_S)\nfcompp\nfstsw ax\nsahf\nje L550\nfld qword ptr (_Y)\nfstp qword ptr (_UfThold)\nlea edi,(L552)\npush edi\npush 0\ncall _BadCond\nadd esp,8\nfld qword ptr (_UfThold)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L553)\npush edi\ncall _printf\nadd esp,12\nfld qword ptr (_C)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L554)\npush edi\ncall _printf\nadd esp,12\nlea edi,(L555)\npush edi\ncall _printf\nadd esp,4\nL550:\ncall _Pause\nadd esp,0\njmp L548\nL556:\nlea edi,(L557)\npush edi\npush 0\ncall _BadCond\nadd esp,8\nlea edi,(L558)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_Y2)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_Q)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L559)\npush edi\ncall _printf\nadd esp,20\nfld qword ptr (_Q)\nfsub qword ptr (_Y2)\nsub esp,8\nfstp qword ptr [esp]\ncall _fabs\nadd esp,8\nfstp qword ptr (-1468)[ebp]\nfld qword ptr (-1468)[ebp]\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L560)\npush edi\ncall _printf\nadd esp,12\nfld qword ptr (_Q)\nfstp qword ptr (_UfThold)\njmp L548\nL561:\nfld qword ptr (_X)\nfstp qword ptr (_X)\njmp L548\nL562:\nfld qword ptr (_UfThold)\nfcomp qword ptr (_Q)\nfstsw ax\nsahf\njne L563\nfld qword ptr (_E0)\nfcomp qword ptr (_E1)\nfstsw ax\nsahf\njne L563\nfld qword ptr (_UfThold)\nfld qword ptr (_E1)\nfdiv qword ptr (_E9)\nfsubp st(1),st\nsub esp,8\nfstp qword ptr [esp]\ncall _fabs\nadd esp,8\nfstp qword ptr (-1492)[ebp]\nfld qword ptr (_E1)\nfcomp qword ptr (-1492)[ebp]\nfstsw ax\nsahf\njb L563\nmov dword ptr (_UfNGrad),0\nlea edi,(L565)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L566)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_E0)\nfmul qword ptr (_CInvrse)\nfstp qword ptr (_Y)\nfld qword ptr (_Y)\nfld qword ptr (_OneAndHalf)\nfadd qword ptr (_U2)\nfmulp st(1),st\nfstp qword ptr (_Y)\nfld qword ptr (_CInvrse)\nfld qword ptr (_One)\nfadd qword ptr (_U2)\nfmulp st(1),st\nfstp qword ptr (_X)\nfld qword ptr (_Y)\nfdiv qword ptr (_X)\nfstp qword ptr (_Y)\nfld qword ptr (_E0)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njne L568\nmov dword ptr (-1496)[ebp],1\njmp L569\nL568:\nmov dword ptr (-1496)[ebp],0\nL569:\nmov edi,dword ptr (-1496)[ebp]\nmov dword ptr (_IEEE),edi\nL563:\nL547:\nL548:\ncmp dword ptr (_UfNGrad),0\nje L572\nlea edi,(L44)\npush edi\ncall _printf\nadd esp,4\nlea edi,(_sigfpe)\nmov dword ptr (_sigsave),edi\nlea edi,(_ovfl_buf)\npush edi\ncall __setjmp\nadd esp,4\ncmp eax,0\nje L574\nlea edi,(L576)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_H)\nfadd qword ptr (_H)\nfstp qword ptr (_R)\njmp L575\nL574:\nfld qword ptr (_Underflow)\nfdiv qword ptr (_UfThold)\nsub esp,8\nfstp qword ptr [esp]\ncall _sqrt\nadd esp,8\nfstp qword ptr (-1460)[ebp]\nfld qword ptr (-1460)[ebp]\nfstp qword ptr (_R)\nL575:\nmov dword ptr (_sigsave),0\nfld qword ptr (_H)\nfcomp qword ptr (_R)\nfstsw ax\nsahf\njb L577\nfld qword ptr (_R)\nfmul qword ptr (_UfThold)\nfstp qword ptr (_Z)\nfld qword ptr (_Z)\nfld qword ptr (_One)\nfld qword ptr (_R)\nfmul qword ptr (_H)\nfld qword ptr (_One)\nfadd qword ptr (_H)\nfmulp st(1),st\nfaddp st(1),st\nfmulp st(1),st\nfstp qword ptr (_X)\njmp L578\nL577:\nfld qword ptr (_UfThold)\nfstp qword ptr (_Z)\nfld qword ptr (_Z)\nfld qword ptr (_One)\nfld qword ptr (_H)\nfmul qword ptr (_H)\nfld qword ptr (_One)\nfadd qword ptr (_H)\nfmulp st(1),st\nfaddp st(1),st\nfmulp st(1),st\nfstp qword ptr (_X)\nL578:\nfld qword ptr (_Z)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\nje L579\nfld qword ptr (_X)\nfsub qword ptr (_Z)\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L579\nlea edi,(L157)\npush edi\npush 3\ncall _BadCond\nadd esp,8\nfld qword ptr (_Z)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_X)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L581)\npush edi\ncall _printf\nadd esp,20\nfld qword ptr (_X)\nfsub qword ptr (_Z)\nfstp qword ptr (_Z9)\nfld qword ptr (_Z9)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L582)\npush edi\ncall _printf\nadd esp,12\nlea edi,(L583)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L584)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L585)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L586)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L587)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L588)\npush edi\ncall _printf\nadd esp,4\nlea edi,(_sigfpe)\nmov dword ptr (_sigsave),edi\nlea edi,(_ovfl_buf)\npush edi\ncall __setjmp\nadd esp,4\ncmp eax,0\nje L589\nlea edi,(L591)\npush edi\ncall _printf\nadd esp,4\njmp L590\nL589:\nfld qword ptr (_X)\nfdiv qword ptr (_Z)\nfsub qword ptr (_Half)\nfsub qword ptr (_Half)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L592)\npush edi\ncall _printf\nadd esp,12\nL590:\nmov dword ptr (_sigsave),0\nL579:\nL572:\nlea edi,(L594)\npush edi\nfld qword ptr (_UfThold)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L593)\npush edi\ncall _printf\nadd esp,16\nlea edi,(L595)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L596)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_U1)\nfmul qword ptr (_U1)\nfstp qword ptr (_Y2)\nfld qword ptr (_Y2)\nfstp qword ptr (-1468)[ebp]\nfld qword ptr (-1468)[ebp]\nfmul qword ptr (-1468)[ebp]\nfstp qword ptr (_Y)\nfld qword ptr (_Y)\nfmul qword ptr (_U1)\nfstp qword ptr (_Y2)\nfld qword ptr (_UfThold)\nfcomp qword ptr (_Y2)\nfstsw ax\nsahf\njb L597\nfld qword ptr (_E0)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njae L599\nlea edi,(L157)\npush edi\npush 2\ncall _BadCond\nadd esp,8\nmov dword ptr (_I),5\njmp L600\nL599:\nlea edi,(L157)\npush edi\npush 1\ncall _BadCond\nadd esp,8\nmov dword ptr (_I),4\nL600:\nmov edi,dword ptr (_I)\npush edi\nlea edi,(L601)\npush edi\ncall _printf\nadd esp,8\nL597:\nmov dword ptr (_Milestone),130\nfld qword ptr (_UfThold)\nsub esp,8\nfstp qword ptr [esp]\ncall _log\nadd esp,8\nfstp qword ptr (-1476)[ebp]\nfld qword ptr (_HInvrse)\nsub esp,8\nfstp qword ptr [esp]\ncall _log\nadd esp,8\nfstp qword ptr (-1484)[ebp]\nfld qword ptr (_Half)\nfld qword ptr (_TwoForty)\nfmul qword ptr (-1476)[ebp]\nfdiv qword ptr (-1484)[ebp]\nfsubp st(1),st\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-1492)[ebp]\nfld qword ptr (-1492)[ebp]\nfchs\nfdiv qword ptr (_TwoForty)\nfstp qword ptr (_Y)\nfld qword ptr (_Y)\nfadd qword ptr (_Y)\nfstp qword ptr (_Y2)\nlea edi,(L602)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_Y)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_HInvrse)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L603)\npush edi\ncall _printf\nadd esp,20\nfld qword ptr (_Y)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_HInvrse)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L604)\npush edi\ncall _printf\nadd esp,20\nfld qword ptr (_Y2)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_HInvrse)\nsub esp,8\nfstp qword ptr [esp]\ncall _pow\nadd esp,16\nfstp qword ptr (-1508)[ebp]\nfld qword ptr (-1508)[ebp]\nfstp qword ptr (_V9)\nfld qword ptr (_V9)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L605)\npush edi\ncall _printf\nadd esp,12\nfld qword ptr (_Zero)\nfcomp qword ptr (_V9)\nfstsw ax\nsahf\nja L608\nfld qword ptr (_Radix)\nfadd qword ptr (_Radix)\nfadd qword ptr (_E9)\nfmul qword ptr (_UfThold)\nfcomp qword ptr (_V9)\nfstsw ax\nsahf\njae L606\nL608:\nlea edi,(L609)\npush edi\npush 1\ncall _BadCond\nadd esp,8\nfld qword ptr (_UfThold)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L610)\npush edi\ncall _printf\nadd esp,12\njmp L607\nL606:\nfld qword ptr (_UfThold)\nfld qword ptr (_One)\nfadd qword ptr (_E9)\nfmulp st(1),st\nfcomp qword ptr (_V9)\nfstsw ax\nsahf\njb L611\nlea edi,(L613)\npush edi\ncall _printf\nadd esp,4\njmp L612\nL611:\nlea edi,(L609)\npush edi\npush 2\ncall _BadCond\nadd esp,8\nfld qword ptr (_UfThold)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L610)\npush edi\ncall _printf\nadd esp,12\nL612:\nL607:\nmov dword ptr (_Milestone),140\nlea edi,(L44)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_Zero)\nfstp qword ptr (_X)\nmov dword ptr (_I),2\nfld qword ptr (_Two)\nfmul qword ptr (_Three)\nfstp qword ptr (_Y)\nfld qword ptr (_Zero)\nfstp qword ptr (_Q)\nmov dword ptr (_N),0\nL614:\nfld qword ptr (_X)\nfstp qword ptr (_Z)\ninc dword ptr (_I)\nmov edi,dword ptr (_I)\nfld qword ptr (_Y)\nlea edi,[edi][edi]\npush edi\nfild dword ptr 0[esp]\nadd esp,4\nfdivp st(1),st\nfstp qword ptr (_Y)\nfld qword ptr (_Y)\nfadd qword ptr (_Q)\nfstp qword ptr (_R)\nfld qword ptr (_Z)\nfstp qword ptr (-1540)[ebp]\nfld qword ptr (_R)\nfstp qword ptr (-1548)[ebp]\nfld qword ptr (-1540)[ebp]\nfadd qword ptr (-1548)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (-1540)[ebp]\nfsub qword ptr (_X)\nfadd qword ptr (-1548)[ebp]\nfstp qword ptr (_Q)\nL615:\nfld qword ptr (_Z)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njb L614\nfld qword ptr (_OneAndHalf)\nfld qword ptr (_One)\nfdiv qword ptr (_Eight)\nfaddp st(1),st\nfld qword ptr (_X)\nfld qword ptr (_OneAndHalf)\nfmul qword ptr (_ThirtyTwo)\nfdivp st(1),st\nfaddp st(1),st\nfstp qword ptr (_Z)\nfld qword ptr (_Z)\nfstp qword ptr (-1548)[ebp]\nfld qword ptr (-1548)[ebp]\nfmul qword ptr (-1548)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (_X)\nfstp qword ptr (-1556)[ebp]\nfld qword ptr (-1556)[ebp]\nfmul qword ptr (-1556)[ebp]\nfstp qword ptr (_Exp2)\nfld qword ptr (_F9)\nfstp qword ptr (_X)\nfld qword ptr (_X)\nfsub qword ptr (_U1)\nfstp qword ptr (_Y)\nfld qword ptr (_Exp2)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L617)\npush edi\ncall _printf\nadd esp,12\nmov dword ptr (_I),1\nL618:\nfld qword ptr (_X)\nfsub qword ptr (_BInvrse)\nfstp qword ptr (_Z)\nfld qword ptr (_X)\nfadd qword ptr (_One)\nfld qword ptr (_Z)\nfld qword ptr (_One)\nfsub qword ptr (_BInvrse)\nfsubp st(1),st\nfdivp st(1),st\nfstp qword ptr (_Z)\nfld qword ptr (_Z)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_X)\nsub esp,8\nfstp qword ptr [esp]\ncall _pow\nadd esp,16\nfstp qword ptr (-1588)[ebp]\nfld qword ptr (-1588)[ebp]\nfsub qword ptr (_Exp2)\nfstp qword ptr (_Q)\nfld qword ptr (_Q)\nsub esp,8\nfstp qword ptr [esp]\ncall _fabs\nadd esp,8\nfstp qword ptr (-1596)[ebp]\nfld qword ptr (_TwoForty)\nfmul qword ptr (_U2)\nfcomp qword ptr (-1596)[ebp]\nfstsw ax\nsahf\njae L622\nmov dword ptr (_N),1\nfld qword ptr (_X)\nfsub qword ptr (_BInvrse)\nfld qword ptr (_One)\nfsub qword ptr (_BInvrse)\nfsubp st(1),st\nfstp qword ptr (_V9)\nlea edi,(L624)\npush edi\npush 2\ncall _BadCond\nadd esp,8\nfld qword ptr (_Z)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_X)\nsub esp,8\nfstp qword ptr [esp]\ncall _pow\nadd esp,16\nfstp qword ptr (-1612)[ebp]\nfld qword ptr (-1612)[ebp]\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L625)\npush edi\ncall _printf\nadd esp,12\nfld qword ptr (_Z)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_V9)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L626)\npush edi\ncall _printf\nadd esp,20\nfld qword ptr (_Q)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L627)\npush edi\ncall _printf\nadd esp,12\nlea edi,(L628)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L629)\npush edi\ncall _printf\nadd esp,4\njmp L620\nL622:\nfld qword ptr (_Y)\nfstp qword ptr (-1604)[ebp]\nfld qword ptr (-1604)[ebp]\nfsub qword ptr (_X)\nfmul qword ptr (_Two)\nfadd qword ptr (-1604)[ebp]\nfstp qword ptr (_Z)\nfld qword ptr (-1604)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (_Z)\nfstp qword ptr (_Y)\nfld qword ptr (_X)\nfsub qword ptr (_F9)\nfstp qword ptr (-1612)[ebp]\nfld qword ptr (_One)\nfld qword ptr (-1612)[ebp]\nfmul qword ptr (-1612)[ebp]\nfaddp st(1),st\nfstp qword ptr (_Z)\nfld qword ptr (_One)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njae L630\nmov edi,dword ptr (_NoTrials)\ncmp dword ptr (_I),edi\njge L630\ninc dword ptr (_I)\njmp L618\nL630:\nfld qword ptr (_One)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njae L632\ncmp dword ptr (_N),0\njne L620\nlea edi,(L636)\npush edi\ncall _printf\nadd esp,4\njmp L620\nL632:\nfld qword ptr (_One)\nfadd qword ptr (_U2)\nfstp qword ptr (_X)\nfld qword ptr (_U2)\nfadd qword ptr (_U2)\nfstp qword ptr (_Y)\nfld qword ptr (_Y)\nfadd qword ptr (_X)\nfstp qword ptr (_Y)\nmov dword ptr (_I),1\njmp L618\nL620:\nmov dword ptr (_Milestone),150\nlea edi,(L637)\npush edi\ncall _printf\nadd esp,4\nmov dword ptr (_N),0\nfld qword ptr (_A1)\nfstp qword ptr (_Z)\nfld qword ptr (_C)\nsub esp,8\nfstp qword ptr [esp]\ncall _log\nadd esp,8\nfstp qword ptr (-1564)[ebp]\nfld qword ptr (_A1)\nsub esp,8\nfstp qword ptr [esp]\ncall _log\nadd esp,8\nfstp qword ptr (-1572)[ebp]\nfld qword ptr (_Half)\nfld qword ptr (-1564)[ebp]\nfdiv qword ptr (-1572)[ebp]\nfsubp st(1),st\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-1580)[ebp]\nfld qword ptr (-1580)[ebp]\nfstp qword ptr (_Q)\nmov dword ptr (_Break),0\nL638:\nfld qword ptr (_CInvrse)\nfstp qword ptr (_X)\nfld qword ptr (_Q)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_Z)\nsub esp,8\nfstp qword ptr [esp]\ncall _pow\nadd esp,16\nfstp qword ptr (-1588)[ebp]\nfld qword ptr (-1588)[ebp]\nfstp qword ptr (_Y)\ncall _IsYeqX\nadd esp,0\nfld qword ptr (_Q)\nfchs\nfstp qword ptr (_Q)\nfld qword ptr (_C)\nfstp qword ptr (_X)\nfld qword ptr (_Q)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_Z)\nsub esp,8\nfstp qword ptr [esp]\ncall _pow\nadd esp,16\nfstp qword ptr (-1596)[ebp]\nfld qword ptr (-1596)[ebp]\nfstp qword ptr (_Y)\ncall _IsYeqX\nadd esp,0\nfld qword ptr (_One)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njbe L641\nmov dword ptr (_Break),1\njmp L642\nL641:\nfld qword ptr (_AInvrse)\nfstp qword ptr (_Z)\nL642:\nL639:\ncmp dword ptr (_Break),0\nje L638\ncall _PrintIfNPositive\nadd esp,0\ncmp dword ptr (_N),0\njne L643\nlea edi,(L645)\npush edi\ncall _printf\nadd esp,4\nL643:\nlea edi,(L44)\npush edi\ncall _printf\nadd esp,4\nmov dword ptr (_Milestone),160\ncall _Pause\nadd esp,0\nlea edi,(L646)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L647)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_CInvrse)\nfchs\nfstp qword ptr (_Y)\nfld qword ptr (_HInvrse)\nfmul qword ptr (_Y)\nfstp qword ptr (_V9)\nlea edi,(_sigfpe)\nmov dword ptr (_sigsave),edi\nlea edi,(_ovfl_buf)\npush edi\ncall __setjmp\nadd esp,4\ncmp eax,0\nje L648\nmov dword ptr (_I),0\nfld qword ptr (_Y)\nfstp qword ptr (_V9)\njmp L650\nL648:\nL651:\nfld qword ptr (_Y)\nfstp qword ptr (_V)\nfld qword ptr (_V9)\nfstp qword ptr (_Y)\nfld qword ptr (_HInvrse)\nfmul qword ptr (_Y)\nfstp qword ptr (_V9)\nL652:\nfld qword ptr (_Y)\nfcomp qword ptr (_V9)\nfstsw ax\nsahf\nja L651\nmov dword ptr (_I),1\nL650:\nmov dword ptr (_sigsave),0\nfld qword ptr (_V9)\nfstp qword ptr (_Z)\nlea edi,(L654)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_Y)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L655)\npush edi\ncall _printf\nadd esp,12\nfld qword ptr (_Y)\nfchs\nfstp qword ptr (_V9)\nfld qword ptr (_V9)\nfstp qword ptr (_V0)\nfld qword ptr (_V)\nfsub qword ptr (_Y)\nfld qword ptr (_V)\nfadd qword ptr (_V0)\nfcompp\nfstsw ax\nsahf\njne L656\nlea edi,(L658)\npush edi\ncall _printf\nadd esp,4\njmp L657\nL656:\nlea edi,(L659)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L660)\npush edi\npush 3\ncall _BadCond\nadd esp,8\nL657:\nfld qword ptr (_Y)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\nje L661\nlea edi,(L157)\npush edi\npush 1\ncall _BadCond\nadd esp,8\nfld qword ptr (_Z)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_Y)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L663)\npush edi\ncall _printf\nadd esp,20\nL661:\ncmp dword ptr (_I),0\nje L664\nfld qword ptr (_V)\nfld qword ptr (_HInvrse)\nfmul qword ptr (_U2)\nfsub qword ptr (_HInvrse)\nfmulp st(1),st\nfstp qword ptr (_Y)\nfld qword ptr (_Y)\nfld qword ptr (_One)\nfsub qword ptr (_HInvrse)\nfmul qword ptr (_U2)\nfmul qword ptr (_V)\nfaddp st(1),st\nfstp qword ptr (_Z)\nfld qword ptr (_V0)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njbe L666\nfld qword ptr (_Z)\nfstp qword ptr (_Y)\nL666:\nfld qword ptr (_V0)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njbe L668\nfld qword ptr (_Y)\nfstp qword ptr (_V)\nL668:\nfld qword ptr (_V0)\nfsub qword ptr (_V)\nfld qword ptr (_V0)\nfcompp\nfstsw ax\nsahf\njbe L665\nfld qword ptr (_V0)\nfstp qword ptr (_V)\njmp L665\nL664:\nfld qword ptr (_Y)\nfld qword ptr (_HInvrse)\nfmul qword ptr (_U2)\nfsub qword ptr (_HInvrse)\nfmulp st(1),st\nfstp qword ptr (_V)\nfld qword ptr (_V)\nfld qword ptr (_One)\nfsub qword ptr (_HInvrse)\nfmul qword ptr (_U2)\nfmul qword ptr (_Y)\nfaddp st(1),st\nfstp qword ptr (_V)\nL665:\nfld qword ptr (_V)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L672)\npush edi\ncall _printf\nadd esp,12\ncmp dword ptr (_I),0\nje L673\nfld qword ptr (_V0)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L675)\npush edi\ncall _printf\nadd esp,12\njmp L674\nL673:\nlea edi,(L676)\npush edi\ncall _printf\nadd esp,4\nL674:\nfld qword ptr (_V)\nfmul qword ptr (_One)\nfstp qword ptr (_V9)\nfld qword ptr (_V9)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L677)\npush edi\ncall _printf\nadd esp,12\nfld qword ptr (_V)\nfdiv qword ptr (_One)\nfstp qword ptr (_V9)\nfld qword ptr (_V9)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L678)\npush edi\ncall _printf\nadd esp,12\nlea edi,(L679)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L680)\npush edi\ncall _printf\nadd esp,4\nmov dword ptr (_Milestone),170\nfld qword ptr (_V)\nfchs\nfld qword ptr (_V)\nfcompp\nfstsw ax\nsahf\njbe L685\nfld qword ptr (_V0)\nfchs\nfld qword ptr (_V0)\nfcompp\nfstsw ax\nsahf\njbe L685\nfld qword ptr (_UfThold)\nfchs\nfld qword ptr (_V)\nfcompp\nfstsw ax\nsahf\njbe L685\nfld qword ptr (_V)\nfcomp qword ptr (_UfThold)\nfstsw ax\nsahf\nja L681\nL685:\nlea edi,(L686)\npush edi\npush 0\ncall _BadCond\nadd esp,8\nfld qword ptr (_UfThold)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_V0)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_V)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L687)\npush edi\ncall _printf\nadd esp,28\nL681:\nmov dword ptr (_Milestone),175\nlea edi,(L44)\npush edi\ncall _printf\nadd esp,4\nmov dword ptr (_Indx),1\nL688:\nmov edi,dword ptr (_Indx)\ncmp edi,1\nje L694\ncmp edi,2\nje L695\ncmp edi,3\nje L696\njmp L692\nL694:\nfld qword ptr (_UfThold)\nfstp qword ptr (_Z)\njmp L693\nL695:\nfld qword ptr (_E0)\nfstp qword ptr (_Z)\njmp L693\nL696:\nfld qword ptr (_PseudoZero)\nfstp qword ptr (_Z)\nL692:\nL693:\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\nje L697\nfld qword ptr (_Z)\nsub esp,8\nfstp qword ptr [esp]\ncall _sqrt\nadd esp,8\nfstp qword ptr (-1628)[ebp]\nfld qword ptr (-1628)[ebp]\nfstp qword ptr (_V9)\nfld qword ptr (_V9)\nfmul qword ptr (_V9)\nfstp qword ptr (_Y)\nfld qword ptr (_Radix)\nfmul qword ptr (_E9)\nfstp qword ptr (-1660)[ebp]\nfld qword ptr (_Y)\nfld qword ptr (_One)\nfsub qword ptr (-1660)[ebp]\nfdivp st(1),st\nfld qword ptr (_Z)\nfcompp\nfstsw ax\nsahf\nja L701\nfld qword ptr (_One)\nfadd qword ptr (-1660)[ebp]\nfmul qword ptr (_Z)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\njae L699\nL701:\nfld qword ptr (_U1)\nfcomp qword ptr (_V9)\nfstsw ax\nsahf\njae L702\nlea edi,(L157)\npush edi\npush 1\ncall _BadCond\nadd esp,8\njmp L703\nL702:\nlea edi,(L157)\npush edi\npush 2\ncall _BadCond\nadd esp,8\nL703:\nfld qword ptr (_Z)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L704)\npush edi\ncall _printf\nadd esp,12\nfld qword ptr (_Y)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L705)\npush edi\ncall _printf\nadd esp,12\nL699:\nL697:\nL689:\ninc dword ptr (_Indx)\ncmp dword ptr (_Indx),3\njle L688\nmov dword ptr (_Milestone),180\nmov dword ptr (_Indx),1\nL706:\ncmp dword ptr (_Indx),1\njne L710\nfld qword ptr (_V)\nfstp qword ptr (_Z)\njmp L711\nL710:\nfld qword ptr (_V0)\nfstp qword ptr (_Z)\nL711:\nfld qword ptr (_Z)\nsub esp,8\nfstp qword ptr [esp]\ncall _sqrt\nadd esp,8\nfstp qword ptr (-1628)[ebp]\nfld qword ptr (-1628)[ebp]\nfstp qword ptr (_V9)\nfld qword ptr (_V9)\nfstp qword ptr (-1636)[ebp]\nfld qword ptr (_One)\nfld qword ptr (_Radix)\nfmul qword ptr (_E9)\nfsubp st(1),st\nfmul qword ptr (-1636)[ebp]\nfstp qword ptr (_X)\nfld qword ptr (-1636)[ebp]\nfmul qword ptr (_X)\nfstp qword ptr (_V9)\nfld qword ptr (_One)\nfld qword ptr (_Two)\nfmul qword ptr (_Radix)\nfmul qword ptr (_E9)\nfsubp st(1),st\nfmul qword ptr (_Z)\nfcomp qword ptr (_V9)\nfstsw ax\nsahf\nja L714\nfld qword ptr (_Z)\nfcomp qword ptr (_V9)\nfstsw ax\nsahf\njae L712\nL714:\nfld qword ptr (_V9)\nfstp qword ptr (_Y)\nfld qword ptr (_W)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njbe L715\nlea edi,(L157)\npush edi\npush 1\ncall _BadCond\nadd esp,8\njmp L716\nL715:\nlea edi,(L157)\npush edi\npush 2\ncall _BadCond\nadd esp,8\nL716:\nfld qword ptr (_Z)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L717)\npush edi\ncall _printf\nadd esp,12\nfld qword ptr (_Y)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L718)\npush edi\ncall _printf\nadd esp,12\nL712:\nL707:\ninc dword ptr (_Indx)\ncmp dword ptr (_Indx),2\njle L706\nmov dword ptr (_Milestone),190\ncall _Pause\nadd esp,0\nfld qword ptr (_UfThold)\nfmul qword ptr (_V)\nfstp qword ptr (_X)\nfld qword ptr (_Radix)\nfmul qword ptr (_Radix)\nfstp qword ptr (_Y)\nfld qword ptr (_X)\nfmul qword ptr (_Y)\nfld qword ptr (_One)\nfcompp\nfstsw ax\nsahf\nja L721\nfld qword ptr (_Y)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njae L719\nL721:\nfld qword ptr (_X)\nfmul qword ptr (_Y)\nfld qword ptr (_U1)\nfcompp\nfstsw ax\nsahf\nja L724\nfld qword ptr (_Y)\nfdiv qword ptr (_U1)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\njae L722\nL724:\nlea edi,(L725)\npush edi\npush 2\ncall _BadCond\nadd esp,8\njmp L723\nL722:\nlea edi,(L157)\npush edi\npush 3\ncall _BadCond\nadd esp,8\nL723:\nlea edi,(L727)\npush edi\nfld qword ptr (_X)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L726)\npush edi\ncall _printf\nadd esp,16\nL719:\nmov dword ptr (_Milestone),200\nmov dword ptr (_Indx),1\nL728:\nfld qword ptr (_F9)\nfstp qword ptr (_X)\nmov edi,dword ptr (_Indx)\ncmp edi,2\njl L732\ncmp edi,5\njg L732\njmp dword ptr (L738-8)[edi*4]\n_TEXT ends\n_TEXT segment\nalign 4\nL738 label byte\ndd L734\ndd L735\ndd L736\ndd L737\n_TEXT ends\n_TEXT segment\nL734:\nfld qword ptr (_One)\nfadd qword ptr (_U2)\nfstp qword ptr (_X)\njmp L733\nL735:\nfld qword ptr (_V)\nfstp qword ptr (_X)\njmp L733\nL736:\nfld qword ptr (_UfThold)\nfstp qword ptr (_X)\njmp L733\nL737:\nfld qword ptr (_Radix)\nfstp qword ptr (_X)\nL732:\nL733:\nfld qword ptr (_X)\nfstp qword ptr (_Y)\nlea edi,(_sigfpe)\nmov dword ptr (_sigsave),edi\nlea edi,(_ovfl_buf)\npush edi\ncall __setjmp\nadd esp,4\ncmp eax,0\nje L740\nfld qword ptr (_X)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L742)\npush edi\ncall _printf\nadd esp,12\njmp L741\nL740:\nfld qword ptr (_Y)\nfdiv qword ptr (_X)\nfsub qword ptr (_Half)\nfsub qword ptr (_Half)\nfstp qword ptr (_V9)\nfld qword ptr (_Zero)\nfcomp qword ptr (_V9)\nfstsw ax\nsahf\njne L743\njmp L729\nL743:\nfld qword ptr (_U1)\nfchs\nfcomp qword ptr (_V9)\nfstsw ax\nsahf\njne L745\ncmp dword ptr (_Indx),5\njge L745\nlea edi,(L157)\npush edi\npush 3\ncall _BadCond\nadd esp,8\njmp L746\nL745:\nlea edi,(L157)\npush edi\npush 1\ncall _BadCond\nadd esp,8\nL746:\nfld qword ptr (_X)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L747)\npush edi\ncall _printf\nadd esp,12\nfld qword ptr (_V9)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L748)\npush edi\ncall _printf\nadd esp,12\nL741:\nmov dword ptr (_sigsave),0\nL729:\ninc dword ptr (_Indx)\ncmp dword ptr (_Indx),5\njle L728\nmov dword ptr (_Milestone),210\nfld qword ptr (_Zero)\nfstp qword ptr (_MyZero)\nlea edi,(L44)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L749)\npush edi\ncall _printf\nadd esp,4\nlea edi,(_sigfpe)\nmov dword ptr (_sigsave),edi\nlea edi,(L750)\npush edi\ncall _printf\nadd esp,4\nlea edi,(_ovfl_buf)\npush edi\ncall __setjmp\nadd esp,4\ncmp eax,0\njne L751\nfld qword ptr (_One)\nfdiv qword ptr (_MyZero)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L753)\npush edi\ncall _printf\nadd esp,12\nL751:\nmov dword ptr (_sigsave),0\nlea edi,(_sigfpe)\nmov dword ptr (_sigsave),edi\nlea edi,(L754)\npush edi\ncall _printf\nadd esp,4\nlea edi,(_ovfl_buf)\npush edi\ncall __setjmp\nadd esp,4\ncmp eax,0\njne L755\nfld qword ptr (_Zero)\nfdiv qword ptr (_MyZero)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L753)\npush edi\ncall _printf\nadd esp,12\nL755:\nmov dword ptr (_sigsave),0\nmov dword ptr (_Milestone),220\ncall _Pause\nadd esp,0\nlea edi,(L44)\npush edi\ncall _printf\nadd esp,4\nmov dword ptr (-1648)[ebp],0\nL762:\nmov edi,dword ptr (-1648)[ebp]\ncmp dword ptr (_ErrCnt)[edi*4],0\nje L766\nmov edi,dword ptr (-1648)[ebp]\nlea edi,[edi*4]\nmov esi,dword ptr (_ErrCnt)[edi]\npush esi\nmov edi,dword ptr (L757)[edi]\npush edi\nlea edi,(L768)\npush edi\ncall _printf\nadd esp,12\nL766:\nL763:\ninc dword ptr (-1648)[ebp]\ncmp dword ptr (-1648)[ebp],4\njl L762\nlea edi,(L44)\npush edi\ncall _printf\nadd esp,4\nmov edi,dword ptr (_ErrCnt)\nmov esi,dword ptr (_ErrCnt+4)\nlea edi,[esi][edi]\nmov esi,dword ptr (_ErrCnt+8)\nlea edi,[esi][edi]\nmov esi,dword ptr (_ErrCnt+12)\nlea edi,[esi][edi]\ncmp edi,0\njle L769\nmov edi,dword ptr (_ErrCnt)\nmov esi,dword ptr (_ErrCnt+4)\nlea edi,[esi][edi]\nmov esi,dword ptr (_ErrCnt+8)\nlea edi,[esi][edi]\ncmp edi,0\njne L774\ncmp dword ptr (_ErrCnt+12),0\njle L774\nlea edi,(L779)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L780)\npush edi\ncall _printf\nadd esp,4\nL774:\nmov edi,dword ptr (_ErrCnt)\nmov esi,dword ptr (_ErrCnt+4)\nlea edi,[esi][edi]\ncmp edi,0\njne L781\ncmp dword ptr (_ErrCnt+8),0\njle L781\nlea edi,(L785)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L786)\npush edi\ncall _printf\nadd esp,4\nL781:\nmov edi,dword ptr (_ErrCnt)\nmov esi,dword ptr (_ErrCnt+4)\nlea edi,[esi][edi]\ncmp edi,0\njle L787\nlea edi,(L790)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L791)\npush edi\ncall _printf\nadd esp,4\nL787:\ncmp dword ptr (_ErrCnt),0\njle L770\nlea edi,(L794)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L795)\npush edi\ncall _printf\nadd esp,4\njmp L770\nL769:\nlea edi,(L796)\npush edi\ncall _printf\nadd esp,4\ncmp dword ptr (_RMult),1\njne L801\ncmp dword ptr (_RDiv),1\njne L801\ncmp dword ptr (_RAddSub),1\njne L801\ncmp dword ptr (_RSqrt),1\nje L797\nL801:\nlea edi,(L802)\npush edi\ncall _printf\nadd esp,4\njmp L798\nL797:\nfld qword ptr (_One)\nfcomp qword ptr (_StickyBit)\nfstsw ax\nsahf\nja L803\nfld qword ptr (_Radix)\nfsub qword ptr (_Two)\nfld qword ptr (_Radix)\nfsub qword ptr (_Nine)\nfsub qword ptr (_One)\nfmulp st(1),st\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L803\nlea edi,(L805)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L806)\npush edi\ncall _printf\nadd esp,4\nfld qword ptr (_Two)\nfcomp qword ptr (_Radix)\nfstsw ax\nsahf\njne L807\nfld qword ptr (_Precision)\nfld qword ptr (_Four)\nfmul qword ptr (_Three)\nfmul qword ptr (_Two)\nfsubp st(1),st\nfld qword ptr (_Precision)\nfsub qword ptr (_TwentySeven)\nfsub qword ptr (_TwentySeven)\nfadd qword ptr (_One)\nfmulp st(1),st\nfld qword ptr (_Zero)\nfcompp\nfstsw ax\nsahf\njne L807\nlea edi,(L809)\npush edi\ncall _printf\nadd esp,4\njmp L808\nL807:\nlea edi,(L810)\npush edi\ncall _printf\nadd esp,4\nL808:\ncmp dword ptr (_IEEE),0\nje L811\nlea edi,(L813)\npush edi\ncall _printf\nadd esp,4\njmp L812\nL811:\nlea edi,(L814)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L815)\npush edi\ncall _printf\nadd esp,4\nL812:\nL803:\nlea edi,(L816)\npush edi\ncall _printf\nadd esp,4\nL798:\nL770:\ncmp dword ptr (_fpecount),0\nje L817\nmov edi,dword ptr (_fpecount)\npush edi\nlea edi,(L819)\npush edi\ncall _printf\nadd esp,8\nL817:\nlea edi,(L820)\npush edi\ncall _printf\nadd esp,4\nmov eax,0\nL6:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _Sign\n_Sign:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,8\nfld qword ptr (L7)\nfcomp qword ptr (20)[ebp]\nfstsw ax\nsahf\nja L823\nfld qword ptr (L8)\nfstp qword ptr (-8)[ebp]\njmp L824\nL823:\nfld qword ptr (L825)\nfstp qword ptr (-8)[ebp]\nL824:\nfld qword ptr (-8)[ebp]\nL821:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _Pause\n_Pause:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov edi,dword ptr (_Milestone)\npush edi\nlea edi,(L827)\npush edi\ncall _printf\nadd esp,8\nmov edi,dword ptr (_PageNo)\npush edi\nlea edi,(L828)\npush edi\ncall _printf\nadd esp,8\ninc dword ptr (_Milestone)\ninc dword ptr (_PageNo)\nmov eax,0\nL826:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _TstCond\n_TstCond:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\ncmp dword ptr (24)[ebp],0\njne L830\nmov edi,dword ptr (28)[ebp]\npush edi\nmov edi,dword ptr (20)[ebp]\npush edi\ncall _BadCond\nadd esp,8\nlea edi,(L813)\npush edi\ncall _printf\nadd esp,4\nL830:\nmov eax,0\nL829:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 4\nL833 label byte\ndd L834\ndd L835\ndd L836\ndd L837\npublic _BadCond\n_DATA ends\n_TEXT segment\n_BadCond:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov edi,dword ptr (20)[ebp]\nlea edi,(_ErrCnt)[edi*4]\ninc dword ptr [edi]\nmov edi,dword ptr (24)[ebp]\npush edi\nmov edi,dword ptr (20)[ebp]\nmov edi,dword ptr (L833)[edi*4]\npush edi\nlea edi,(L838)\npush edi\ncall _printf\nadd esp,12\nmov eax,0\nL832:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _Random\n_Random:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,48\nfld qword ptr (_Random1)\nfadd qword ptr (_Random9)\nfstp qword ptr (-8)[ebp]\nfld qword ptr (-8)[ebp]\nfmul qword ptr (-8)[ebp]\nfstp qword ptr (-16)[ebp]\nfld qword ptr (-16)[ebp]\nfmul qword ptr (-16)[ebp]\nfstp qword ptr (-16)[ebp]\nfld qword ptr (-8)[ebp]\nfmul qword ptr (-16)[ebp]\nfstp qword ptr (-8)[ebp]\nfld qword ptr (-8)[ebp]\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-48)[ebp]\nfld qword ptr (-8)[ebp]\nfsub qword ptr (-48)[ebp]\nfstp qword ptr (-16)[ebp]\nfld qword ptr (-16)[ebp]\nfld qword ptr (L840)\nfmul qword ptr (-8)[ebp]\nfaddp st(1),st\nfstp qword ptr (_Random1)\nfld qword ptr (_Random1)\nL839:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _SqXMinX\n_SqXMinX:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,40\nfld qword ptr (_X)\nfmul qword ptr (_BInvrse)\nfstp qword ptr (-8)[ebp]\nfld qword ptr (_X)\nfsub qword ptr (-8)[ebp]\nfstp qword ptr (-16)[ebp]\nfld qword ptr (_X)\nfmul qword ptr (_X)\nsub esp,8\nfstp qword ptr [esp]\ncall _sqrt\nadd esp,8\nfstp qword ptr (-32)[ebp]\nfld qword ptr (-32)[ebp]\nfsub qword ptr (-8)[ebp]\nfsub qword ptr (-16)[ebp]\nfdiv qword ptr (_OneUlp)\nfstp qword ptr (_SqEr)\nfld qword ptr (_Zero)\nfcomp qword ptr (_SqEr)\nfstsw ax\nsahf\nje L842\nfld qword ptr (_MinSqEr)\nfcomp qword ptr (_SqEr)\nfstsw ax\nsahf\njbe L844\nfld qword ptr (_SqEr)\nfstp qword ptr (_MinSqEr)\nL844:\nfld qword ptr (_MaxSqEr)\nfcomp qword ptr (_SqEr)\nfstsw ax\nsahf\njae L846\nfld qword ptr (_SqEr)\nfstp qword ptr (_MaxSqEr)\nL846:\nfld qword ptr (_J)\nfadd qword ptr (L8)\nfstp qword ptr (_J)\nlea edi,(L44)\npush edi\nmov edi,dword ptr (20)[ebp]\npush edi\ncall _BadCond\nadd esp,8\nfld qword ptr (_OneUlp)\nfmul qword ptr (_SqEr)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_X)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_X)\nfmul qword ptr (_X)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L848)\npush edi\ncall _printf\nadd esp,28\nlea edi,(L849)\npush edi\ncall _printf\nadd esp,4\nL842:\nmov eax,0\nL841:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _NewD\n_NewD:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,40\nfld qword ptr (_Z1)\nfmul qword ptr (_Q)\nfstp qword ptr (_X)\nfld qword ptr (_Half)\nfld qword ptr (_X)\nfdiv qword ptr (_Radix)\nfsubp st(1),st\nsub esp,8\nfstp qword ptr [esp]\ncall _floor\nadd esp,8\nfstp qword ptr (-8)[ebp]\nfld qword ptr (-8)[ebp]\nfmul qword ptr (_Radix)\nfadd qword ptr (_X)\nfstp qword ptr (_X)\nfld qword ptr (_X)\nfstp qword ptr (-24)[ebp]\nfld qword ptr (_Z)\nfstp qword ptr (-32)[ebp]\nfld qword ptr (_Q)\nfld qword ptr (-24)[ebp]\nfmul qword ptr (-32)[ebp]\nfsubp st(1),st\nfdiv qword ptr (_Radix)\nfld qword ptr (-24)[ebp]\nfmul qword ptr (-24)[ebp]\nfld qword ptr (_D)\nfdiv qword ptr (_Radix)\nfmulp st(1),st\nfaddp st(1),st\nfstp qword ptr (_Q)\nfld qword ptr (-32)[ebp]\nfld qword ptr (_Two)\nfmul qword ptr (-24)[ebp]\nfmul qword ptr (_D)\nfsubp st(1),st\nfstp qword ptr (_Z)\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njb L851\nfld qword ptr (_Z)\nfchs\nfstp qword ptr (_Z)\nfld qword ptr (_Z1)\nfchs\nfstp qword ptr (_Z1)\nL851:\nfld qword ptr (_Radix)\nfmul qword ptr (_D)\nfstp qword ptr (_D)\nmov eax,0\nL850:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _SR3750\n_SR3750:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,64\nfld qword ptr (_X)\nfsub qword ptr (_Radix)\nfld qword ptr (_Z2)\nfsub qword ptr (_Radix)\nfcompp\nfstsw ax\nsahf\nja L854\nfld qword ptr (_X)\nfsub qword ptr (_Z2)\nfld qword ptr (_W)\nfsub qword ptr (_Z2)\nfcompp\nfstsw ax\nsahf\njb L854\ninc dword ptr (_I)\nfld qword ptr (_X)\nfmul qword ptr (_D)\nsub esp,8\nfstp qword ptr [esp]\ncall _sqrt\nadd esp,8\nfstp qword ptr (-32)[ebp]\nfld qword ptr (-32)[ebp]\nfstp qword ptr (_X2)\nfld qword ptr (_X2)\nfsub qword ptr (_Z2)\nfld qword ptr (_Y)\nfsub qword ptr (_Z2)\nfsubp st(1),st\nfstp qword ptr (_Y2)\nfld qword ptr (_X8)\nfld qword ptr (_Y)\nfsub qword ptr (_Half)\nfdivp st(1),st\nfstp qword ptr (_X2)\nfld qword ptr (_X2)\nfstp qword ptr (-64)[ebp]\nfld qword ptr (-64)[ebp]\nfld qword ptr (_Half)\nfmul qword ptr (-64)[ebp]\nfmul qword ptr (-64)[ebp]\nfsubp st(1),st\nfstp qword ptr (_X2)\nfld qword ptr (_Y2)\nfadd qword ptr (_Half)\nfld qword ptr (_Half)\nfsub qword ptr (_X2)\nfaddp st(1),st\nfstp qword ptr (_SqEr)\nfld qword ptr (_MinSqEr)\nfcomp qword ptr (_SqEr)\nfstsw ax\nsahf\njbe L856\nfld qword ptr (_SqEr)\nfstp qword ptr (_MinSqEr)\nL856:\nfld qword ptr (_Y2)\nfsub qword ptr (_X2)\nfstp qword ptr (_SqEr)\nfld qword ptr (_MaxSqEr)\nfcomp qword ptr (_SqEr)\nfstsw ax\nsahf\njae L858\nfld qword ptr (_SqEr)\nfstp qword ptr (_MaxSqEr)\nL858:\nL854:\nmov eax,0\nL853:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _IsYeqX\n_IsYeqX:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,8\nfld qword ptr (_X)\nfcomp qword ptr (_Y)\nfstsw ax\nsahf\nje L861\ncmp dword ptr (_N),0\njg L863\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njne L865\nfld qword ptr (_Zero)\nfcomp qword ptr (_Q)\nfstsw ax\nsahf\njb L865\nlea edi,(L867)\npush edi\ncall _printf\nadd esp,4\njmp L866\nL865:\nlea edi,(L868)\npush edi\npush 2\ncall _BadCond\nadd esp,8\nL866:\nfld qword ptr (_Q)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_Z)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L869)\npush edi\ncall _printf\nadd esp,20\nfld qword ptr (_Y)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L870)\npush edi\ncall _printf\nadd esp,12\nfld qword ptr (_X)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L871)\npush edi\ncall _printf\nadd esp,12\nfld qword ptr (_Y)\nfsub qword ptr (_X)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L872)\npush edi\ncall _printf\nadd esp,12\nL863:\ninc dword ptr (_N)\nL861:\nmov eax,0\nL860:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _SR3980\n_SR3980:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,8\nL874:\nfild dword ptr (_I)\nfstp qword ptr (_Q)\nfld qword ptr (_Q)\nsub esp,8\nfstp qword ptr [esp]\nfld qword ptr (_Z)\nsub esp,8\nfstp qword ptr [esp]\ncall _pow\nadd esp,16\nfstp qword ptr (-8)[ebp]\nfld qword ptr (-8)[ebp]\nfstp qword ptr (_Y)\ncall _IsYeqX\nadd esp,0\nmov edi,dword ptr (_I)\nlea edi,(1)[edi]\nmov dword ptr (_I),edi\ncmp edi,dword ptr (_M)\njle L877\njmp L876\nL877:\nfld qword ptr (_Z)\nfmul qword ptr (_X)\nfstp qword ptr (_X)\nL875:\nfld qword ptr (_W)\nfcomp qword ptr (_X)\nfstsw ax\nsahf\nja L874\nL876:\nmov eax,0\nL873:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _PrintIfNPositive\n_PrintIfNPositive:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\ncmp dword ptr (_N),0\njle L880\nmov edi,dword ptr (_N)\npush edi\nlea edi,(L882)\npush edi\ncall _printf\nadd esp,8\nL880:\nmov eax,0\nL879:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _TstPtUf\n_TstPtUf:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,48\nmov dword ptr (_N),0\nfld qword ptr (_Zero)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\nje L884\nlea edi,(L886)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L887)\npush edi\ncall _printf\nadd esp,4\nlea edi,(_sigfpe)\nmov dword ptr (_sigsave),edi\nlea edi,(_ovfl_buf)\npush edi\ncall __setjmp\nadd esp,4\ncmp eax,0\nje L888\njmp L890\nL888:\nfld qword ptr (_Z)\nfadd qword ptr (_Z)\nfdiv qword ptr (_Z)\nfstp qword ptr (_Q9)\nfld qword ptr (_Q9)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L891)\npush edi\ncall _printf\nadd esp,12\nfld qword ptr (_Q9)\nfsub qword ptr (_Two)\nsub esp,8\nfstp qword ptr [esp]\ncall _fabs\nadd esp,8\nfstp qword ptr (-16)[ebp]\nfld qword ptr (_Radix)\nfmul qword ptr (_U2)\nfcomp qword ptr (-16)[ebp]\nfstsw ax\nsahf\njbe L892\nlea edi,(L894)\npush edi\ncall _printf\nadd esp,4\nlea edi,(L895)\npush edi\ncall _printf\nadd esp,4\njmp L893\nL892:\nfld qword ptr (_One)\nfcomp qword ptr (_Q9)\nfstsw ax\nsahf\nja L898\nfld qword ptr (_Two)\nfcomp qword ptr (_Q9)\nfstsw ax\nsahf\njae L896\nL898:\nL890:\nmov dword ptr (_N),1\nmov edi,dword ptr (_ErrCnt+4)\nlea edi,(1)[edi]\nmov dword ptr (_ErrCnt+4),edi\nlea edi,(L901)\npush edi\ncall _printf\nadd esp,4\njmp L897\nL896:\nmov dword ptr (_N),1\nmov edi,dword ptr (_ErrCnt+8)\nlea edi,(1)[edi]\nmov dword ptr (_ErrCnt+8),edi\nlea edi,(L904)\npush edi\ncall _printf\nadd esp,4\nL897:\nL893:\nmov dword ptr (_sigsave),0\nfld qword ptr (_Z)\nfmul qword ptr (_One)\nfstp qword ptr (_V9)\nfld qword ptr (_V9)\nfstp qword ptr (_Random1)\nfld qword ptr (_One)\nfmul qword ptr (_Z)\nfstp qword ptr (_V9)\nfld qword ptr (_V9)\nfstp qword ptr (_Random2)\nfld qword ptr (_Z)\nfdiv qword ptr (_One)\nfstp qword ptr (_V9)\nfld qword ptr (_Random1)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njne L905\nfld qword ptr (_Random2)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njne L905\nfld qword ptr (_V9)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\njne L905\ncmp dword ptr (_N),0\njle L906\ncall _Pause\nadd esp,0\njmp L906\nL905:\nmov dword ptr (_N),1\nlea edi,(L909)\npush edi\npush 2\ncall _BadCond\nadd esp,8\nfld qword ptr (_Z)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L910)\npush edi\ncall _printf\nadd esp,12\nfld qword ptr (_Random1)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\nje L911\nfld qword ptr (_Random1)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L913)\npush edi\ncall _printf\nadd esp,12\nL911:\nfld qword ptr (_Random2)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\nje L914\nfld qword ptr (_Random1)\nfcomp qword ptr (_Random2)\nfstsw ax\nsahf\nje L914\nfld qword ptr (_Random2)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L916)\npush edi\ncall _printf\nadd esp,12\nL914:\nfld qword ptr (_V9)\nfcomp qword ptr (_Z)\nfstsw ax\nsahf\nje L917\nfld qword ptr (_V9)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L919)\npush edi\ncall _printf\nadd esp,12\nL917:\nfld qword ptr (_Random1)\nfcomp qword ptr (_Random2)\nfstsw ax\nsahf\nje L920\nmov edi,dword ptr (_ErrCnt+8)\nlea edi,(1)[edi]\nmov dword ptr (_ErrCnt+8),edi\nlea edi,(L924)\npush edi\npush 2\ncall _BadCond\nadd esp,8\nfld qword ptr (_Random2)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L925)\npush edi\ncall _printf\nadd esp,12\nfld qword ptr (_Random1)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L926)\npush edi\ncall _printf\nadd esp,12\nL920:\ncall _Pause\nadd esp,0\nL906:\nL884:\nmov eax,0\nL883:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _notify\n_notify:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov edi,dword ptr (20)[ebp]\npush edi\nlea edi,(L928)\npush edi\ncall _printf\nadd esp,8\nlea edi,(L929)\npush edi\ncall _printf\nadd esp,4\nmov eax,0\nL927:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _msglist\n_msglist:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\njmp L932\nL931:\nmov edi,dword ptr (20)[ebp]\nlea esi,(4)[edi]\nmov dword ptr (20)[ebp],esi\nmov edi,dword ptr [edi]\npush edi\nlea edi,(L934)\npush edi\ncall _printf\nadd esp,8\nL932:\nmov edi,dword ptr (20)[ebp]\nmov edi,dword ptr [edi]\ncmp edi,0\njne L931\nmov eax,0\nL930:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 4\nL936 label byte\ndd L937\ndd L938\ndd L939\ndd L940\ndd L941\ndd L942\ndd L943\ndd L944\ndd L945\ndd 00H\npublic _Instructions\n_DATA ends\n_TEXT segment\n_Instructions:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nlea edi,(L936)\npush edi\ncall _msglist\nadd esp,4\nmov eax,0\nL935:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 4\nL947 label byte\ndd L948\ndd L949\ndd L950\ndd L951\ndd L952\ndd L953\ndd L954\ndd L955\ndd L956\ndd L957\ndd L958\ndd L959\ndd L960\ndd L961\ndd 00H\npublic _Heading\n_DATA ends\n_TEXT segment\n_Heading:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nlea edi,(L947)\npush edi\ncall _msglist\nadd esp,4\nmov eax,0\nL946:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 4\nL963 label byte\ndd L964\ndd L965\ndd L966\ndd L967\ndd L968\ndd L969\ndd L970\ndd L971\ndd L972\ndd L973\ndd L974\ndd L975\ndd L976\ndd L977\ndd L978\ndd L979\ndd L980\ndd L981\ndd L982\ndd 00H\npublic _Characteristics\n_DATA ends\n_TEXT segment\n_Characteristics:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nlea edi,(L963)\npush edi\ncall _msglist\nadd esp,4\nmov eax,0\nL962:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\nalign 4\nL984 label byte\ndd L985\ndd L986\ndd L987\ndd L988\ndd L989\ndd L990\ndd L991\ndd L992\ndd L993\ndd L994\ndd L995\ndd L996\ndd L997\ndd L998\ndd L999\ndd L1000\ndd L1001\ndd 00H\npublic _History\n_DATA ends\n_TEXT segment\n_History:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nlea edi,(L984)\npush edi\ncall _msglist\nadd esp,4\nmov eax,0\nL983:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _pow\n_pow:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,96\nmov dword ptr (-20)[ebp],0\nmov dword ptr (-24)[ebp],0\nfld qword ptr (L7)\nfcomp qword ptr (28)[ebp]\nfstsw ax\nsahf\njne L1003\nfld qword ptr (L8)\njmp L1002\nL1003:\nfld qword ptr (L1008)\nfcomp qword ptr (28)[ebp]\nfstsw ax\nsahf\nja L1007\nfld qword ptr (L1009)\nfcomp qword ptr (28)[ebp]\nfstsw ax\nsahf\njae L1005\nL1007:\nfld qword ptr (L825)\nfcomp qword ptr (20)[ebp]\nfstsw ax\nsahf\nje L1005\nfld qword ptr (20)[ebp]\nsub esp,8\nfstp qword ptr [esp]\ncall _log\nadd esp,8\nfstp qword ptr (-48)[ebp]\nfld qword ptr (28)[ebp]\nfmul qword ptr (-48)[ebp]\nsub esp,8\nfstp qword ptr [esp]\ncall _exp\nadd esp,8\nfstp qword ptr (-56)[ebp]\nfld qword ptr (-56)[ebp]\njmp L1002\nL1005:\nfld qword ptr (L7)\nfcomp qword ptr (28)[ebp]\nfstsw ax\nsahf\njbe L1010\nfld qword ptr (28)[ebp]\nfchs\nfstp qword ptr (28)[ebp]\nmov dword ptr (-24)[ebp],1\nL1010:\nlea edi,(-32)[ebp]\npush edi\nfld qword ptr (28)[ebp]\nsub esp,8\nfstp qword ptr [esp]\ncall _modf\nadd esp,12\nfstp qword ptr (-64)[ebp]\nfld qword ptr (-64)[ebp]\nfstp qword ptr (28)[ebp]\nfld qword ptr (L7)\nfcomp qword ptr (28)[ebp]\nfstsw ax\nsahf\nje L1012\nfld qword ptr (20)[ebp]\nsub esp,8\nfstp qword ptr [esp]\ncall _log\nadd esp,8\nfstp qword ptr (-72)[ebp]\nfld qword ptr (28)[ebp]\nfmul qword ptr (-72)[ebp]\nsub esp,8\nfstp qword ptr [esp]\ncall _exp\nadd esp,8\nfstp qword ptr (-80)[ebp]\nfld qword ptr (-80)[ebp]\nfstp qword ptr (-16)[ebp]\njmp L1013\nL1012:\nfld qword ptr (L8)\nfstp qword ptr (-16)[ebp]\nL1013:\nlea edi,(-8)[ebp]\npush edi\nfld qword ptr (20)[ebp]\nsub esp,8\nfstp qword ptr [esp]\ncall _frexp\nadd esp,12\nfstp qword ptr (-88)[ebp]\nfld qword ptr (-88)[ebp]\nfstp qword ptr (20)[ebp]\nfld qword ptr (-32)[ebp]\ncall __ftol\nmov dword ptr (-4)[ebp],eax\ncmp eax,0\nje L1014\nL1016:\nmov edi,dword ptr (-4)[ebp]\nand edi,1\ncmp edi,0\nje L1020\nfld qword ptr (-16)[ebp]\nfmul qword ptr (20)[ebp]\nfstp qword ptr (-16)[ebp]\nmov edi,dword ptr (-8)[ebp]\nadd dword ptr (-20)[ebp],edi\nL1020:\nmov edi,dword ptr (-4)[ebp]\nsar edi,1\nmov dword ptr (-4)[ebp],edi\ncmp edi,0\njne L1022\njmp L1018\nL1022:\nfld qword ptr (20)[ebp]\nfmul qword ptr (20)[ebp]\nfstp qword ptr (20)[ebp]\nsal dword ptr (-8)[ebp],1\nfld qword ptr (L1026)\nfcomp qword ptr (20)[ebp]\nfstsw ax\nsahf\njbe L1016\nfld qword ptr (L1027)\nfmul qword ptr (20)[ebp]\nfstp qword ptr (20)[ebp]\ndec dword ptr (-8)[ebp]\njmp L1016\nL1018:\nL1014:\ncmp dword ptr (-24)[ebp],0\nje L1028\nfld qword ptr (L8)\nfdiv qword ptr (-16)[ebp]\nfstp qword ptr (-16)[ebp]\nneg dword ptr (-20)[ebp]\nL1028:\nmov edi,dword ptr (-20)[ebp]\npush edi\nfld qword ptr (-16)[ebp]\nsub esp,8\nfstp qword ptr [esp]\ncall _ldexp\nadd esp,12\nfstp qword ptr (-96)[ebp]\nfld qword ptr (-96)[ebp]\nL1002:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\nextrn _modf:near\n_TEXT segment\n_TEXT ends\nextrn _ldexp:near\n_TEXT segment\n_TEXT ends\nextrn _frexp:near\n_TEXT segment\n_TEXT ends\nextrn _exp:near\n_TEXT segment\n_TEXT ends\nextrn _abort:near\n_TEXT segment\n_TEXT ends\n_DATA segment\npublic _UfNGrad\nalign 4\n_UfNGrad label byte\ndb 4 dup (0)\npublic _SqRWrng\nalign 4\n_SqRWrng label byte\ndb 4 dup (0)\npublic _IEEE\nalign 4\n_IEEE label byte\ndb 4 dup (0)\npublic _Anomaly\nalign 4\n_Anomaly label byte\ndb 4 dup (0)\npublic _Monot\nalign 4\n_Monot label byte\ndb 4 dup (0)\npublic _NotMonot\nalign 4\n_NotMonot label byte\ndb 4 dup (0)\npublic _Done\nalign 4\n_Done label byte\ndb 4 dup (0)\npublic _Break\nalign 4\n_Break label byte\ndb 4 dup (0)\npublic _RSqrt\nalign 4\n_RSqrt label byte\ndb 4 dup (0)\npublic _RAddSub\nalign 4\n_RAddSub label byte\ndb 4 dup (0)\npublic _RDiv\nalign 4\n_RDiv label byte\ndb 4 dup (0)\npublic _RMult\nalign 4\n_RMult label byte\ndb 4 dup (0)\npublic _GAddSub\nalign 4\n_GAddSub label byte\ndb 4 dup (0)\npublic _GDiv\nalign 4\n_GDiv label byte\ndb 4 dup (0)\npublic _GMult\nalign 4\n_GMult label byte\ndb 4 dup (0)\npublic _N1\nalign 4\n_N1 label byte\ndb 4 dup (0)\npublic _N\nalign 4\n_N label byte\ndb 4 dup (0)\npublic _M\nalign 4\n_M label byte\ndb 4 dup (0)\npublic _PageNo\nalign 4\n_PageNo label byte\ndb 4 dup (0)\npublic _Milestone\nalign 4\n_Milestone label byte\ndb 4 dup (0)\npublic _fpecount\nalign 4\n_fpecount label byte\ndb 4 dup (0)\npublic _ErrCnt\nalign 4\n_ErrCnt label byte\ndb 16 dup (0)\npublic _Z9\nalign 4\n_Z9 label byte\ndb 8 dup (0)\npublic _Z2\nalign 4\n_Z2 label byte\ndb 8 dup (0)\npublic _Z1\nalign 4\n_Z1 label byte\ndb 8 dup (0)\npublic _PseudoZero\nalign 4\n_PseudoZero label byte\ndb 8 dup (0)\npublic _Z\nalign 4\n_Z label byte\ndb 8 dup (0)\npublic _Random2\nalign 4\n_Random2 label byte\ndb 8 dup (0)\npublic _Y2\nalign 4\n_Y2 label byte\ndb 8 dup (0)\npublic _Y1\nalign 4\n_Y1 label byte\ndb 8 dup (0)\npublic _Y\nalign 4\n_Y label byte\ndb 8 dup (0)\npublic _Random1\nalign 4\n_Random1 label byte\ndb 8 dup (0)\npublic _X8\nalign 4\n_X8 label byte\ndb 8 dup (0)\npublic _X2\nalign 4\n_X2 label byte\ndb 8 dup (0)\npublic _X1\nalign 4\n_X1 label byte\ndb 8 dup (0)\npublic _X\nalign 4\n_X label byte\ndb 8 dup (0)\npublic _W\nalign 4\n_W label byte\ndb 8 dup (0)\npublic _V9\nalign 4\n_V9 label byte\ndb 8 dup (0)\npublic _V0\nalign 4\n_V0 label byte\ndb 8 dup (0)\npublic _V\nalign 4\n_V label byte\ndb 8 dup (0)\npublic _U2\nalign 4\n_U2 label byte\ndb 8 dup (0)\npublic _U1\nalign 4\n_U1 label byte\ndb 8 dup (0)\npublic _UfThold\nalign 4\n_UfThold label byte\ndb 8 dup (0)\npublic _OneUlp\nalign 4\n_OneUlp label byte\ndb 8 dup (0)\npublic _S\nalign 4\n_S label byte\ndb 8 dup (0)\npublic _Underflow\nalign 4\n_Underflow label byte\ndb 8 dup (0)\npublic _T\nalign 4\n_T label byte\ndb 8 dup (0)\npublic _Random9\nalign 4\n_Random9 label byte\ndb 8 dup (0)\npublic _R\nalign 4\n_R label byte\ndb 8 dup (0)\npublic _Q9\nalign 4\n_Q9 label byte\ndb 8 dup (0)\npublic _Q\nalign 4\n_Q label byte\ndb 8 dup (0)\npublic _Precision\nalign 4\n_Precision label byte\ndb 8 dup (0)\npublic _MyZero\nalign 4\n_MyZero label byte\ndb 8 dup (0)\npublic _J\nalign 4\n_J label byte\ndb 8 dup (0)\npublic _StickyBit\nalign 4\n_StickyBit label byte\ndb 8 dup (0)\npublic _I\nalign 4\n_I label byte\ndb 4 dup (0)\npublic _HInvrse\nalign 4\n_HInvrse label byte\ndb 8 dup (0)\npublic _H\nalign 4\n_H label byte\ndb 8 dup (0)\npublic _F9\nalign 4\n_F9 label byte\ndb 8 dup (0)\npublic _F6\nalign 4\n_F6 label byte\ndb 8 dup (0)\npublic _Third\nalign 4\n_Third label byte\ndb 8 dup (0)\npublic _E9\nalign 4\n_E9 label byte\ndb 8 dup (0)\npublic _MaxSqEr\nalign 4\n_MaxSqEr label byte\ndb 8 dup (0)\npublic _SqEr\nalign 4\n_SqEr label byte\ndb 8 dup (0)\npublic _MinSqEr\nalign 4\n_MinSqEr label byte\ndb 8 dup (0)\npublic _E3\nalign 4\n_E3 label byte\ndb 8 dup (0)\npublic _Exp2\nalign 4\n_Exp2 label byte\ndb 8 dup (0)\npublic _E1\nalign 4\n_E1 label byte\ndb 8 dup (0)\npublic _E0\nalign 4\n_E0 label byte\ndb 8 dup (0)\npublic _FourD\nalign 4\n_FourD label byte\ndb 8 dup (0)\npublic _D\nalign 4\n_D label byte\ndb 8 dup (0)\npublic _CInvrse\nalign 4\n_CInvrse label byte\ndb 8 dup (0)\npublic _C\nalign 4\n_C label byte\ndb 8 dup (0)\npublic _A1\nalign 4\n_A1 label byte\ndb 8 dup (0)\npublic _AInvrse\nalign 4\n_AInvrse label byte\ndb 8 dup (0)\npublic _ch\nalign 1\n_ch label byte\ndb 8 dup (0)\npublic _Indx\nalign 4\n_Indx label byte\ndb 4 dup (0)\npublic _BMinusU2\nalign 4\n_BMinusU2 label byte\ndb 8 dup (0)\npublic _RadixD2\nalign 4\n_RadixD2 label byte\ndb 8 dup (0)\npublic _BInvrse\nalign 4\n_BInvrse label byte\ndb 8 dup (0)\npublic _Radix\nalign 4\n_Radix label byte\ndb 8 dup (0)\npublic _sigsave\nalign 4\n_sigsave label byte\ndb 4 dup (0)\npublic _ovfl_buf\nalign 4\n_ovfl_buf label byte\ndb 64 dup (0)\n_DATA ends\nextrn _sqrt:near\n_DATA segment\n_DATA ends\nextrn _log:near\n_DATA segment\n_DATA ends\nextrn _floor:near\n_DATA segment\n_DATA ends\nextrn _fabs:near\n_DATA segment\n_DATA ends\nextrn _longjmp:near\n_DATA segment\n_DATA ends\nextrn __setjmp:near\n_DATA segment\n_DATA ends\nextrn _signal:near\n_DATA segment\n_DATA ends\nextrn _printf:near\n_DATA segment\n_DATA ends\nextrn _fflush:near\n_DATA segment\n_DATA ends\nextrn __iob:near\n_DATA segment\n_DATA ends\n_TEXT segment\nalign 4\nL1027 label byte\ndd 00H\ndd 040000000H\nalign 4\nL1026 label byte\ndd 00H\ndd 03fe00000H\nalign 4\nL1009 label byte\ndd 00H\ndd 040913000H\nalign 4\nL1008 label byte\ndd 00H\ndd 0c0913000H\nalign 1\nL1001 label byte\ndb 115\ndb 101\ndb 101\ndb 32\ndb 115\ndb 111\ndb 117\ndb 114\ndb 99\ndb 101\ndb 32\ndb 99\ndb 111\ndb 109\ndb 109\ndb 101\ndb 110\ndb 116\ndb 115\ndb 32\ndb 102\ndb 111\ndb 114\ndb 32\ndb 109\ndb 111\ndb 114\ndb 101\ndb 32\ndb 104\ndb 105\ndb 115\ndb 116\ndb 111\ndb 114\ndb 121\ndb 46\ndb 0\nalign 1\nL1000 label byte\ndb 66\ndb 65\ndb 83\ndb 73\ndb 67\ndb 32\ndb 118\ndb 101\ndb 114\ndb 115\ndb 105\ndb 111\ndb 110\ndb 32\ndb 111\ndb 102\ndb 32\ndb 116\ndb 104\ndb 105\ndb 115\ndb 32\ndb 112\ndb 114\ndb 111\ndb 103\ndb 114\ndb 97\ndb 109\ndb 32\ndb 40\ndb 67\ndb 41\ndb 32\ndb 49\ndb 57\ndb 56\ndb 51\ndb 32\ndb 98\ndb 121\ndb 32\ndb 80\ndb 114\ndb 111\ndb 102\ndb 46\ndb 32\ndb 87\ndb 46\ndb 32\ndb 77\ndb 46\ndb 32\ndb 75\ndb 97\ndb 104\ndb 97\ndb 110\ndb 59\ndb 0\nalign 1\nL999 label byte\ndb 97\ndb 115\ndb 32\ndb 117\ndb 115\ndb 101\ndb 100\ndb 32\ndb 98\ndb 121\ndb 32\ndb 99\ndb 101\ndb 114\ndb 116\ndb 97\ndb 105\ndb 110\ndb 32\ndb 101\ndb 97\ndb 114\ndb 108\ndb 121\ndb 32\ndb 87\ndb 65\ndb 78\ndb 71\ndb 32\ndb 109\ndb 97\ndb 99\ndb 104\ndb 105\ndb 110\ndb 101\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL998 label byte\ndb 102\ndb 108\ndb 111\ndb 97\ndb 116\ndb 105\ndb 110\ndb 103\ndb 45\ndb 112\ndb 111\ndb 105\ndb 110\ndb 116\ndb 32\ndb 110\ndb 117\ndb 109\ndb 98\ndb 101\ndb 114\ndb 115\ndb 44\ndb 32\ndb 98\ndb 117\ndb 116\ndb 32\ndb 97\ndb 108\ndb 115\ndb 111\ndb 32\ndb 97\ndb 108\ndb 108\ndb 111\ndb 119\ndb 115\ndb 32\ndb 108\ndb 111\ndb 103\ndb 97\ndb 114\ndb 105\ndb 116\ndb 104\ndb 109\ndb 105\ndb 99\ndb 32\ndb 101\ndb 110\ndb 99\ndb 111\ndb 100\ndb 105\ndb 110\ndb 103\ndb 0\nalign 1\nL997 label byte\ndb 10\ndb 84\ndb 104\ndb 101\ndb 32\ndb 112\ndb 114\ndb 111\ndb 103\ndb 114\ndb 97\ndb 109\ndb 32\ndb 105\ndb 115\ndb 32\ndb 98\ndb 97\ndb 115\ndb 101\ndb 100\ndb 32\ndb 117\ndb 112\ndb 111\ndb 110\ndb 32\ndb 97\ndb 32\ndb 99\ndb 111\ndb 110\ndb 118\ndb 101\ndb 110\ndb 116\ndb 105\ndb 111\ndb 110\ndb 97\ndb 108\ndb 32\ndb 114\ndb 97\ndb 100\ndb 105\ndb 120\ndb 32\ndb 114\ndb 101\ndb 112\ndb 114\ndb 101\ndb 115\ndb 101\ndb 110\ndb 116\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 102\ndb 111\ndb 114\ndb 0\nalign 1\nL996 label byte\ndb 111\ndb 102\ndb 32\ndb 112\ndb 97\ndb 116\ndb 104\ndb 111\ndb 108\ndb 111\ndb 103\ndb 105\ndb 101\ndb 115\ndb 44\ndb 32\ndb 97\ndb 110\ndb 100\ndb 32\ndb 116\ndb 111\ndb 32\ndb 115\ndb 97\ndb 121\ndb 32\ndb 104\ndb 111\ndb 119\ndb 32\ndb 119\ndb 101\ndb 108\ndb 108\ndb 32\ndb 116\ndb 104\ndb 101\ndb 32\ndb 97\ndb 114\ndb 105\ndb 116\ndb 104\ndb 109\ndb 101\ndb 116\ndb 105\ndb 99\ndb 32\ndb 105\ndb 115\ndb 32\ndb 105\ndb 109\ndb 112\ndb 108\ndb 101\ndb 109\ndb 101\ndb 110\ndb 116\ndb 101\ndb 100\ndb 46\ndb 0\nalign 1\nL995 label byte\ndb 111\ndb 102\ndb 32\ndb 116\ndb 104\ndb 101\ndb 32\ndb 97\ndb 114\ndb 105\ndb 116\ndb 104\ndb 109\ndb 101\ndb 116\ndb 105\ndb 99\ndb 44\ndb 32\ndb 116\ndb 104\ndb 105\ndb 115\ndb 32\ndb 112\ndb 114\ndb 111\ndb 103\ndb 114\ndb 97\ndb 109\ndb 32\ndb 116\ndb 114\ndb 105\ndb 101\ndb 115\ndb 32\ndb 116\ndb 111\ndb 32\ndb 99\ndb 111\ndb 112\ndb 101\ndb 32\ndb 119\ndb 105\ndb 116\ndb 104\ndb 32\ndb 97\ndb 32\ndb 119\ndb 105\ndb 100\ndb 101\ndb 114\ndb 32\ndb 118\ndb 97\ndb 114\ndb 105\ndb 101\ndb 116\ndb 121\ndb 0\nalign 1\nL994 label byte\ndb 116\ndb 104\ndb 101\ndb 32\ndb 82\ndb 97\ndb 100\ndb 105\ndb 120\ndb 44\ndb 32\ndb 80\ndb 114\ndb 101\ndb 99\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 32\ndb 97\ndb 110\ndb 100\ndb 32\ndb 114\ndb 97\ndb 110\ndb 103\ndb 101\ndb 32\ndb 40\ndb 111\ndb 118\ndb 101\ndb 114\ndb 47\ndb 117\ndb 110\ndb 100\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 32\ndb 116\ndb 104\ndb 114\ndb 101\ndb 115\ndb 104\ndb 111\ndb 108\ndb 100\ndb 115\ndb 41\ndb 0\nalign 1\nL993 label byte\ndb 87\ndb 46\ndb 32\ndb 74\ndb 46\ndb 32\ndb 67\ndb 111\ndb 100\ndb 121\ndb 32\ndb 97\ndb 110\ndb 100\ndb 32\ndb 87\ndb 46\ndb 32\ndb 87\ndb 97\ndb 105\ndb 116\ndb 101\ndb 46\ndb 32\ndb 65\ndb 108\ndb 116\ndb 104\ndb 111\ndb 117\ndb 103\ndb 104\ndb 32\ndb 98\ndb 111\ndb 116\ndb 104\ndb 32\ndb 112\ndb 114\ndb 111\ndb 103\ndb 114\ndb 97\ndb 109\ndb 115\ndb 32\ndb 116\ndb 114\ndb 121\ndb 32\ndb 116\ndb 111\ndb 32\ndb 100\ndb 105\ndb 115\ndb 99\ndb 111\ndb 118\ndb 101\ndb 114\ndb 0\nalign 1\nL992 label byte\ndb 98\ndb 111\ndb 111\ndb 107\ndb 32\ndb 32\ndb 96\ndb 83\ndb 111\ndb 102\ndb 116\ndb 119\ndb 97\ndb 114\ndb 101\ndb 32\ndb 77\ndb 97\ndb 110\ndb 117\ndb 97\ndb 108\ndb 32\ndb 102\ndb 111\ndb 114\ndb 32\ndb 116\ndb 104\ndb 101\ndb 32\ndb 69\ndb 108\ndb 101\ndb 109\ndb 101\ndb 110\ndb 116\ndb 97\ndb 114\ndb 121\ndb 32\ndb 70\ndb 117\ndb 110\ndb 99\ndb 116\ndb 105\ndb 111\ndb 110\ndb 115\ndb 39\ndb 32\ndb 40\ndb 49\ndb 57\ndb 56\ndb 48\ndb 41\ndb 32\ndb 98\ndb 121\ndb 0\nalign 1\nL991 label byte\ndb 112\ndb 114\ndb 111\ndb 103\ndb 114\ndb 97\ndb 109\ndb 32\ndb 99\ndb 97\ndb 108\ndb 108\ndb 101\ndb 100\ndb 32\ndb 96\ndb 77\ndb 65\ndb 67\ndb 72\ndb 65\ndb 82\ndb 39\ndb 44\ndb 32\ndb 119\ndb 104\ndb 105\ndb 99\ndb 104\ndb 32\ndb 99\ndb 97\ndb 110\ndb 32\ndb 98\ndb 101\ndb 32\ndb 102\ndb 111\ndb 117\ndb 110\ndb 100\ndb 32\ndb 97\ndb 116\ndb 32\ndb 116\ndb 104\ndb 101\ndb 32\ndb 101\ndb 110\ndb 100\ndb 32\ndb 111\ndb 102\ndb 32\ndb 116\ndb 104\ndb 101\ndb 0\nalign 1\nL990 label byte\ndb 84\ndb 104\ndb 101\ndb 32\ndb 100\ndb 105\ndb 97\ndb 103\ndb 110\ndb 111\ndb 115\ndb 116\ndb 105\ndb 99\ndb 32\ndb 99\ndb 97\ndb 112\ndb 97\ndb 98\ndb 105\ndb 108\ndb 105\ndb 116\ndb 105\ndb 101\ndb 115\ndb 32\ndb 111\ndb 102\ndb 32\ndb 116\ndb 104\ndb 105\ndb 115\ndb 32\ndb 112\ndb 114\ndb 111\ndb 103\ndb 114\ndb 97\ndb 109\ndb 32\ndb 103\ndb 111\ndb 32\ndb 98\ndb 101\ndb 121\ndb 111\ndb 110\ndb 100\ndb 32\ndb 97\ndb 110\ndb 32\ndb 101\ndb 97\ndb 114\ndb 108\ndb 105\ndb 101\ndb 114\ndb 0\nalign 1\nL989 label byte\ndb 70\ndb 97\ndb 105\ndb 108\ndb 117\ndb 114\ndb 101\ndb 115\ndb 32\ndb 109\ndb 97\ndb 121\ndb 32\ndb 99\ndb 111\ndb 110\ndb 102\ndb 111\ndb 117\ndb 110\ndb 100\ndb 32\ndb 115\ndb 117\ndb 98\ndb 115\ndb 101\ndb 113\ndb 117\ndb 101\ndb 110\ndb 116\ndb 32\ndb 100\ndb 105\ndb 97\ndb 103\ndb 110\ndb 111\ndb 115\ndb 101\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL988 label byte\ndb 32\ndb 32\ndb 32\ndb 70\ndb 65\ndb 73\ndb 76\ndb 85\ndb 82\ndb 69\ndb 115\ndb 44\ndb 32\ndb 108\ndb 105\ndb 107\ndb 101\ndb 32\ndb 50\ndb 43\ndb 50\ndb 32\ndb 61\ndb 61\ndb 32\ndb 53\ndb 32\ndb 46\ndb 0\nalign 1\nL987 label byte\ndb 32\ndb 32\ndb 32\ndb 83\ndb 101\ndb 114\ndb 105\ndb 111\ndb 117\ndb 115\ndb 32\ndb 68\ndb 69\ndb 70\ndb 69\ndb 67\ndb 84\ndb 115\ndb 44\ndb 32\ndb 108\ndb 105\ndb 107\ndb 101\ndb 32\ndb 108\ndb 97\ndb 99\ndb 107\ndb 32\ndb 111\ndb 102\ndb 32\ndb 97\ndb 32\ndb 103\ndb 117\ndb 97\ndb 114\ndb 100\ndb 32\ndb 100\ndb 105\ndb 103\ndb 105\ndb 116\ndb 44\ndb 32\ndb 97\ndb 110\ndb 100\ndb 0\nalign 1\nL986 label byte\ndb 32\ndb 32\ndb 32\ndb 70\ndb 76\ndb 65\ndb 87\ndb 115\ndb 44\ndb 32\ndb 108\ndb 105\ndb 107\ndb 101\ndb 32\ndb 108\ndb 97\ndb 99\ndb 107\ndb 32\ndb 111\ndb 102\ndb 32\ndb 97\ndb 32\ndb 115\ndb 116\ndb 105\ndb 99\ndb 107\ndb 121\ndb 32\ndb 98\ndb 105\ndb 116\ndb 44\ndb 0\nalign 1\nL985 label byte\ndb 84\ndb 104\ndb 101\ndb 32\ndb 112\ndb 114\ndb 111\ndb 103\ndb 114\ndb 97\ndb 109\ndb 32\ndb 97\ndb 116\ndb 116\ndb 101\ndb 109\ndb 112\ndb 116\ndb 115\ndb 32\ndb 116\ndb 111\ndb 32\ndb 100\ndb 105\ndb 115\ndb 99\ndb 114\ndb 105\ndb 109\ndb 105\ndb 110\ndb 97\ndb 116\ndb 101\ndb 32\ndb 97\ndb 109\ndb 111\ndb 110\ndb 103\ndb 0\nalign 1\nL982 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 68\ndb 101\ndb 99\ndb 105\ndb 109\ndb 97\ndb 108\ndb 45\ndb 66\ndb 105\ndb 110\ndb 97\ndb 114\ndb 121\ndb 32\ndb 99\ndb 111\ndb 110\ndb 118\ndb 101\ndb 114\ndb 115\ndb 105\ndb 111\ndb 110\ndb 32\ndb 105\ndb 115\ndb 32\ndb 78\ndb 79\ndb 84\ndb 32\ndb 89\ndb 69\ndb 84\ndb 32\ndb 116\ndb 101\ndb 115\ndb 116\ndb 101\ndb 100\ndb 32\ndb 102\ndb 111\ndb 114\ndb 32\ndb 97\ndb 99\ndb 99\ndb 117\ndb 114\ndb 97\ndb 99\ndb 121\ndb 46\ndb 0\nalign 1\nL981 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 69\ndb 120\ndb 116\ndb 114\ndb 97\ndb 45\ndb 112\ndb 114\ndb 101\ndb 99\ndb 105\ndb 115\ndb 101\ndb 32\ndb 115\ndb 117\ndb 98\ndb 101\ndb 120\ndb 112\ndb 114\ndb 101\ndb 115\ndb 115\ndb 105\ndb 111\ndb 110\ndb 115\ndb 32\ndb 97\ndb 114\ndb 101\ndb 32\ndb 114\ndb 101\ndb 118\ndb 101\ndb 97\ndb 108\ndb 101\ndb 100\ndb 32\ndb 98\ndb 117\ndb 116\ndb 32\ndb 78\ndb 79\ndb 84\ndb 32\ndb 89\ndb 69\ndb 84\ndb 32\ndb 116\ndb 101\ndb 115\ndb 116\ndb 101\ndb 100\ndb 46\ndb 0\nalign 1\nL980 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 83\ndb 113\ndb 114\ndb 116\ndb 32\ndb 105\ndb 115\ndb 32\ndb 116\ndb 101\ndb 115\ndb 116\ndb 101\ndb 100\ndb 46\ndb 32\ndb 32\ndb 89\ndb 94\ndb 88\ndb 32\ndb 105\ndb 115\ndb 32\ndb 110\ndb 111\ndb 116\ndb 32\ndb 116\ndb 101\ndb 115\ndb 116\ndb 101\ndb 100\ndb 46\ndb 0\nalign 1\nL979 label byte\ndb 9\ndb 97\ndb 110\ndb 100\ndb 32\ndb 102\ndb 111\ndb 114\ndb 32\ndb 99\ndb 111\ndb 110\ndb 116\ndb 97\ndb 109\ndb 105\ndb 110\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 119\ndb 105\ndb 116\ndb 104\ndb 32\ndb 112\ndb 115\ndb 101\ndb 117\ndb 100\ndb 111\ndb 45\ndb 122\ndb 101\ndb 114\ndb 111\ndb 115\ndb 46\ndb 0\nalign 1\nL978 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 67\ndb 111\ndb 109\ndb 112\ndb 97\ndb 114\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 115\ndb 32\ndb 97\ndb 114\ndb 101\ndb 32\ndb 99\ndb 104\ndb 101\ndb 99\ndb 107\ndb 101\ndb 100\ndb 32\ndb 102\ndb 111\ndb 114\ndb 32\ndb 99\ndb 111\ndb 110\ndb 115\ndb 105\ndb 115\ndb 116\ndb 101\ndb 110\ndb 99\ndb 121\ndb 32\ndb 119\ndb 105\ndb 116\ndb 104\ndb 32\ndb 115\ndb 117\ndb 98\ndb 116\ndb 114\ndb 97\ndb 99\ndb 116\ndb 105\ndb 111\ndb 110\ndb 0\nalign 1\nL977 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 86\ndb 48\ndb 32\ndb 32\ndb 116\ndb 101\ndb 108\ndb 108\ndb 115\ndb 44\ndb 32\ndb 114\ndb 111\ndb 117\ndb 103\ndb 104\ndb 108\ndb 121\ndb 44\ndb 32\ndb 119\ndb 104\ndb 101\ndb 116\ndb 104\ndb 101\ndb 114\ndb 32\ndb 32\ndb 73\ndb 110\ndb 102\ndb 105\ndb 110\ndb 105\ndb 116\ndb 121\ndb 32\ndb 32\ndb 105\ndb 115\ndb 32\ndb 114\ndb 101\ndb 112\ndb 114\ndb 101\ndb 115\ndb 101\ndb 110\ndb 116\ndb 101\ndb 100\ndb 46\ndb 0\nalign 1\nL976 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 86\ndb 32\ndb 61\ndb 32\ndb 97\ndb 110\ndb 32\ndb 111\ndb 118\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 32\ndb 116\ndb 104\ndb 114\ndb 101\ndb 115\ndb 104\ndb 111\ndb 108\ndb 100\ndb 44\ndb 32\ndb 114\ndb 111\ndb 117\ndb 103\ndb 104\ndb 108\ndb 121\ndb 46\ndb 0\nalign 1\nL975 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 69\ndb 48\ndb 32\ndb 97\ndb 110\ndb 100\ndb 32\ndb 80\ndb 115\ndb 101\ndb 117\ndb 100\ndb 111\ndb 90\ndb 101\ndb 114\ndb 111\ndb 32\ndb 116\ndb 101\ndb 108\ndb 108\ndb 32\ndb 119\ndb 104\ndb 101\ndb 116\ndb 104\ndb 101\ndb 114\ndb 32\ndb 117\ndb 110\ndb 100\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 32\ndb 105\ndb 115\ndb 32\ndb 97\ndb 98\ndb 114\ndb 117\ndb 112\ndb 116\ndb 44\ndb 32\ndb 103\ndb 114\ndb 97\ndb 100\ndb 117\ndb 97\ndb 108\ndb 44\ndb 32\ndb 111\ndb 114\ndb 32\ndb 102\ndb 117\ndb 122\ndb 122\ndb 121\ndb 46\ndb 0\nalign 1\nL974 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 85\ndb 110\ndb 100\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 84\ndb 104\ndb 114\ndb 101\ndb 115\ndb 104\ndb 111\ndb 108\ndb 100\ndb 32\ndb 61\ndb 32\ndb 97\ndb 110\ndb 32\ndb 117\ndb 110\ndb 100\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 32\ndb 116\ndb 104\ndb 114\ndb 101\ndb 115\ndb 104\ndb 111\ndb 108\ndb 100\ndb 46\ndb 0\nalign 1\nL973 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 87\ndb 104\ndb 101\ndb 116\ndb 104\ndb 101\ndb 114\ndb 32\ndb 97\ndb 32\ndb 83\ndb 116\ndb 105\ndb 99\ndb 107\ndb 121\ndb 32\ndb 66\ndb 105\ndb 116\ndb 32\ndb 117\ndb 115\ndb 101\ndb 100\ndb 32\ndb 99\ndb 111\ndb 114\ndb 114\ndb 101\ndb 99\ndb 116\ndb 108\ndb 121\ndb 32\ndb 102\ndb 111\ndb 114\ndb 32\ndb 114\ndb 111\ndb 117\ndb 110\ndb 100\ndb 105\ndb 110\ndb 103\ndb 46\ndb 0\nalign 1\nL972 label byte\ndb 9\ndb 102\ndb 111\ndb 114\ndb 32\ndb 77\ndb 117\ndb 108\ndb 116\ndb 46\ndb 44\ndb 32\ndb 68\ndb 105\ndb 118\ndb 46\ndb 44\ndb 32\ndb 65\ndb 100\ndb 100\ndb 47\ndb 83\ndb 117\ndb 98\ndb 116\ndb 46\ndb 32\ndb 97\ndb 110\ndb 100\ndb 32\ndb 83\ndb 113\ndb 114\ndb 116\ndb 46\ndb 0\nalign 1\nL971 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 87\ndb 104\ndb 101\ndb 116\ndb 104\ndb 101\ndb 114\ndb 32\ndb 97\ndb 114\ndb 105\ndb 116\ndb 104\ndb 109\ndb 101\ndb 116\ndb 105\ndb 99\ndb 32\ndb 105\ndb 115\ndb 32\ndb 99\ndb 104\ndb 111\ndb 112\ndb 112\ndb 101\ndb 100\ndb 44\ndb 32\ndb 99\ndb 111\ndb 114\ndb 114\ndb 101\ndb 99\ndb 116\ndb 108\ndb 121\ndb 32\ndb 114\ndb 111\ndb 117\ndb 110\ndb 100\ndb 101\ndb 100\ndb 44\ndb 32\ndb 111\ndb 114\ndb 32\ndb 115\ndb 111\ndb 109\ndb 101\ndb 116\ndb 104\ndb 105\ndb 110\ndb 103\ndb 32\ndb 101\ndb 108\ndb 115\ndb 101\ndb 0\nalign 1\nL970 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 65\ndb 100\ndb 101\ndb 113\ndb 117\ndb 97\ndb 99\ndb 121\ndb 32\ndb 111\ndb 102\ndb 32\ndb 103\ndb 117\ndb 97\ndb 114\ndb 100\ndb 32\ndb 100\ndb 105\ndb 103\ndb 105\ndb 116\ndb 115\ndb 32\ndb 102\ndb 111\ndb 114\ndb 32\ndb 77\ndb 117\ndb 108\ndb 116\ndb 46\ndb 44\ndb 32\ndb 68\ndb 105\ndb 118\ndb 46\ndb 32\ndb 97\ndb 110\ndb 100\ndb 32\ndb 83\ndb 117\ndb 98\ndb 116\ndb 46\ndb 0\nalign 1\nL969 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 85\ndb 49\ndb 32\ndb 61\ndb 32\ndb 49\ndb 47\ndb 82\ndb 97\ndb 100\ndb 105\ndb 120\ndb 94\ndb 80\ndb 114\ndb 101\ndb 99\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 32\ndb 61\ndb 32\ndb 79\ndb 110\ndb 101\ndb 32\ndb 85\ndb 108\ndb 112\ndb 32\ndb 111\ndb 102\ndb 32\ndb 110\ndb 117\ndb 109\ndb 98\ndb 101\ndb 114\ndb 115\ndb 32\ndb 97\ndb 32\ndb 108\ndb 105\ndb 116\ndb 116\ndb 108\ndb 101\ndb 32\ndb 108\ndb 101\ndb 115\ndb 115\ndb 32\ndb 116\ndb 104\ndb 97\ndb 110\ndb 32\ndb 49\ndb 46\ndb 48\ndb 32\ndb 46\ndb 0\nalign 1\nL968 label byte\ndb 9\ndb 40\ndb 79\ndb 110\ndb 101\ndb 85\ndb 108\ndb 112\ndb 110\ndb 105\ndb 116\ndb 32\ndb 105\ndb 110\ndb 32\ndb 116\ndb 104\ndb 101\ndb 32\ndb 76\ndb 97\ndb 115\ndb 116\ndb 32\ndb 80\ndb 108\ndb 97\ndb 99\ndb 101\ndb 41\ndb 32\ndb 111\ndb 102\ndb 32\ndb 49\ndb 46\ndb 48\ndb 48\ndb 48\ndb 120\ndb 120\ndb 120\ndb 32\ndb 46\ndb 0\nalign 1\nL967 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 85\ndb 50\ndb 32\ndb 61\ndb 32\ndb 82\ndb 97\ndb 100\ndb 105\ndb 120\ndb 47\ndb 82\ndb 97\ndb 100\ndb 105\ndb 120\ndb 94\ndb 80\ndb 114\ndb 101\ndb 99\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 32\ndb 61\ndb 32\ndb 79\ndb 110\ndb 101\ndb 32\ndb 85\ndb 108\ndb 112\ndb 0\nalign 1\nL966 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 80\ndb 114\ndb 101\ndb 99\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 32\ndb 61\ndb 32\ndb 110\ndb 117\ndb 109\ndb 98\ndb 101\ndb 114\ndb 32\ndb 111\ndb 102\ndb 32\ndb 115\ndb 105\ndb 103\ndb 110\ndb 105\ndb 102\ndb 105\ndb 99\ndb 97\ndb 110\ndb 116\ndb 32\ndb 100\ndb 105\ndb 103\ndb 105\ndb 116\ndb 115\ndb 32\ndb 99\ndb 97\ndb 114\ndb 114\ndb 105\ndb 101\ndb 100\ndb 46\ndb 0\nalign 1\nL965 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 82\ndb 97\ndb 100\ndb 105\ndb 120\ndb 32\ndb 61\ndb 32\ndb 49\ndb 44\ndb 32\ndb 50\ndb 44\ndb 32\ndb 52\ndb 44\ndb 32\ndb 56\ndb 44\ndb 32\ndb 49\ndb 48\ndb 44\ndb 32\ndb 49\ndb 54\ndb 44\ndb 32\ndb 49\ndb 48\ndb 48\ndb 44\ndb 32\ndb 50\ndb 53\ndb 54\ndb 32\ndb 46\ndb 46\ndb 46\ndb 0\nalign 1\nL964 label byte\ndb 82\ndb 117\ndb 110\ndb 110\ndb 105\ndb 110\ndb 103\ndb 32\ndb 116\ndb 104\ndb 105\ndb 115\ndb 32\ndb 112\ndb 114\ndb 111\ndb 103\ndb 114\ndb 97\ndb 109\ndb 32\ndb 115\ndb 104\ndb 111\ndb 117\ndb 108\ndb 100\ndb 32\ndb 114\ndb 101\ndb 118\ndb 101\ndb 97\ndb 108\ndb 32\ndb 116\ndb 104\ndb 101\ndb 115\ndb 101\ndb 32\ndb 99\ndb 104\ndb 97\ndb 114\ndb 97\ndb 99\ndb 116\ndb 101\ndb 114\ndb 105\ndb 115\ndb 116\ndb 105\ndb 99\ndb 115\ndb 58\ndb 0\nalign 1\nL961 label byte\ndb 9\ndb 79\ndb 116\ndb 104\ndb 101\ndb 114\ndb 32\ndb 114\ndb 101\ndb 108\ndb 101\ndb 118\ndb 97\ndb 110\ndb 116\ndb 32\ndb 99\ndb 111\ndb 109\ndb 112\ndb 105\ndb 108\ndb 101\ndb 114\ndb 32\ndb 111\ndb 112\ndb 116\ndb 105\ndb 111\ndb 110\ndb 115\ndb 58\ndb 0\nalign 1\nL960 label byte\ndb 9\ndb 79\ndb 112\ndb 116\ndb 105\ndb 109\ndb 105\ndb 122\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 108\ndb 101\ndb 118\ndb 101\ndb 108\ndb 58\ndb 10\ndb 0\nalign 1\nL959 label byte\ndb 9\ndb 67\ndb 111\ndb 109\ndb 112\ndb 105\ndb 108\ndb 101\ndb 114\ndb 58\ndb 10\ndb 0\nalign 1\nL958 label byte\ndb 9\ndb 67\ndb 111\ndb 109\ndb 112\ndb 117\ndb 116\ndb 101\ndb 114\ndb 58\ndb 10\ndb 0\nalign 1\nL957 label byte\ndb 9\ndb 86\ndb 101\ndb 114\ndb 115\ndb 105\ndb 111\ndb 110\ndb 58\ndb 9\ndb 49\ndb 48\ndb 32\ndb 70\ndb 101\ndb 98\ndb 114\ndb 117\ndb 97\ndb 114\ndb 121\ndb 32\ndb 49\ndb 57\ndb 56\ndb 57\ndb 59\ndb 0\nalign 1\nL956 label byte\ndb 9\ndb 80\ndb 114\ndb 101\ndb 99\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 58\ndb 9\ndb 100\ndb 111\ndb 117\ndb 98\ndb 108\ndb 101\ndb 59\ndb 0\nalign 1\nL955 label byte\ndb 73\ndb 110\ndb 32\ndb 100\ndb 111\ndb 105\ndb 110\ndb 103\ndb 32\ndb 115\ndb 111\ndb 44\ndb 32\ndb 112\ndb 108\ndb 101\ndb 97\ndb 115\ndb 101\ndb 32\ndb 105\ndb 110\ndb 99\ndb 108\ndb 117\ndb 100\ndb 101\ndb 32\ndb 116\ndb 104\ndb 101\ndb 32\ndb 102\ndb 111\ndb 108\ndb 108\ndb 111\ndb 119\ndb 105\ndb 110\ndb 103\ndb 32\ndb 105\ndb 110\ndb 102\ndb 111\ndb 114\ndb 109\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 58\ndb 0\nalign 1\nL954 label byte\ndb 9\ndb 83\ndb 97\ndb 110\ndb 32\ndb 70\ndb 114\ndb 97\ndb 110\ndb 99\ndb 105\ndb 115\ndb 99\ndb 111\ndb 44\ndb 32\ndb 67\ndb 65\ndb 32\ndb 57\ndb 52\ndb 49\ndb 52\ndb 51\ndb 45\ndb 48\ndb 55\ndb 48\ndb 52\ndb 44\ndb 32\ndb 85\ndb 83\ndb 65\ndb 10\ndb 0\nalign 1\nL953 label byte\ndb 9\ndb 85\ndb 110\ndb 105\ndb 118\ndb 101\ndb 114\ndb 115\ndb 105\ndb 116\ndb 121\ndb 32\ndb 111\ndb 102\ndb 32\ndb 67\ndb 97\ndb 108\ndb 105\ndb 102\ndb 111\ndb 114\ndb 110\ndb 105\ndb 97\ndb 0\nalign 1\nL952 label byte\ndb 9\ndb 67\ndb 111\ndb 109\ndb 112\ndb 117\ndb 116\ndb 101\ndb 114\ndb 32\ndb 67\ndb 101\ndb 110\ndb 116\ndb 101\ndb 114\ndb 32\ndb 85\ndb 45\ndb 55\ndb 54\ndb 0\nalign 1\nL951 label byte\ndb 9\ndb 82\ndb 105\ndb 99\ndb 104\ndb 97\ndb 114\ndb 100\ndb 32\ndb 75\ndb 97\ndb 114\ndb 112\ndb 105\ndb 110\ndb 115\ndb 107\ndb 105\ndb 0\nalign 1\nL950 label byte\ndb 80\ndb 108\ndb 101\ndb 97\ndb 115\ndb 101\ndb 32\ndb 115\ndb 101\ndb 110\ndb 100\ndb 32\ndb 115\ndb 117\ndb 103\ndb 103\ndb 101\ndb 115\ndb 116\ndb 105\ndb 111\ndb 110\ndb 115\ndb 32\ndb 97\ndb 110\ndb 100\ndb 32\ndb 105\ndb 110\ndb 116\ndb 101\ndb 114\ndb 101\ndb 115\ndb 116\ndb 105\ndb 110\ndb 103\ndb 32\ndb 114\ndb 101\ndb 115\ndb 117\ndb 108\ndb 116\ndb 115\ndb 32\ndb 116\ndb 111\ndb 0\nalign 1\nL949 label byte\ndb 99\ndb 111\ndb 112\ndb 101\ndb 32\ndb 119\ndb 105\ndb 116\ndb 104\ndb 32\ndb 117\ndb 110\ndb 97\ndb 110\ndb 116\ndb 105\ndb 99\ndb 105\ndb 112\ndb 97\ndb 116\ndb 101\ndb 100\ndb 32\ndb 97\ndb 110\ndb 100\ndb 32\ndb 110\ndb 101\ndb 119\ndb 108\ndb 121\ndb 32\ndb 117\ndb 110\ndb 99\ndb 111\ndb 118\ndb 101\ndb 114\ndb 101\ndb 100\ndb 32\ndb 97\ndb 114\ndb 105\ndb 116\ndb 104\ndb 109\ndb 101\ndb 116\ndb 105\ndb 99\ndb 32\ndb 112\ndb 97\ndb 116\ndb 104\ndb 111\ndb 108\ndb 111\ndb 103\ndb 105\ndb 101\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL948 label byte\ndb 85\ndb 115\ndb 101\ndb 114\ndb 115\ndb 32\ndb 97\ndb 114\ndb 101\ndb 32\ndb 105\ndb 110\ndb 118\ndb 105\ndb 116\ndb 101\ndb 100\ndb 32\ndb 116\ndb 111\ndb 32\ndb 104\ndb 101\ndb 108\ndb 112\ndb 32\ndb 100\ndb 101\ndb 98\ndb 117\ndb 103\ndb 32\ndb 97\ndb 110\ndb 100\ndb 32\ndb 97\ndb 117\ndb 103\ndb 109\ndb 101\ndb 110\ndb 116\ndb 32\ndb 116\ndb 104\ndb 105\ndb 115\ndb 32\ndb 112\ndb 114\ndb 111\ndb 103\ndb 114\ndb 97\ndb 109\ndb 32\ndb 115\ndb 111\ndb 32\ndb 105\ndb 116\ndb 32\ndb 119\ndb 105\ndb 108\ndb 108\ndb 0\nalign 1\nL945 label byte\ndb 65\ndb 110\ndb 115\ndb 119\ndb 101\ndb 114\ndb 32\ndb 113\ndb 117\ndb 101\ndb 115\ndb 116\ndb 105\ndb 111\ndb 110\ndb 115\ndb 32\ndb 119\ndb 105\ndb 116\ndb 104\ndb 32\ndb 89\ndb 44\ndb 32\ndb 121\ndb 44\ndb 32\ndb 78\ndb 32\ndb 111\ndb 114\ndb 32\ndb 110\ndb 32\ndb 40\ndb 117\ndb 110\ndb 108\ndb 101\ndb 115\ndb 115\ndb 32\ndb 111\ndb 116\ndb 104\ndb 101\ndb 114\ndb 119\ndb 105\ndb 115\ndb 101\ndb 32\ndb 105\ndb 110\ndb 100\ndb 105\ndb 99\ndb 97\ndb 116\ndb 101\ndb 100\ndb 41\ndb 46\ndb 10\ndb 0\nalign 1\nL944 label byte\ndb 97\ndb 109\ndb 101\ndb 110\ndb 100\ndb 32\ndb 105\ndb 116\ndb 32\ndb 116\ndb 111\ndb 32\ndb 109\ndb 97\ndb 107\ndb 101\ndb 32\ndb 102\ndb 117\ndb 114\ndb 116\ndb 104\ndb 101\ndb 114\ndb 32\ndb 112\ndb 114\ndb 111\ndb 103\ndb 114\ndb 101\ndb 115\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL943 label byte\ndb 112\ndb 114\ndb 111\ndb 103\ndb 114\ndb 97\ndb 109\ndb 32\ndb 97\ndb 110\ndb 121\ndb 119\ndb 97\ndb 121\ndb 32\ndb 116\ndb 111\ndb 32\ndb 115\ndb 101\ndb 101\ndb 32\ndb 104\ndb 111\ndb 119\ndb 32\ndb 109\ndb 97\ndb 110\ndb 121\ndb 32\ndb 109\ndb 105\ndb 108\ndb 101\ndb 115\ndb 116\ndb 111\ndb 110\ndb 101\ndb 115\ndb 32\ndb 105\ndb 116\ndb 32\ndb 112\ndb 97\ndb 115\ndb 115\ndb 101\ndb 115\ndb 44\ndb 32\ndb 97\ndb 110\ndb 100\ndb 32\ndb 116\ndb 104\ndb 101\ndb 110\ndb 0\nalign 1\nL942 label byte\ndb 119\ndb 97\ndb 114\ndb 110\ndb 105\ndb 110\ndb 103\ndb 46\ndb 32\ndb 32\ndb 73\ndb 102\ndb 32\ndb 112\ndb 101\ndb 114\ndb 115\ndb 117\ndb 97\ndb 115\ndb 105\ndb 111\ndb 110\ndb 32\ndb 97\ndb 118\ndb 97\ndb 105\ndb 108\ndb 115\ndb 32\ndb 110\ndb 97\ndb 117\ndb 103\ndb 104\ndb 116\ndb 44\ndb 32\ndb 100\ndb 111\ndb 110\ndb 39\ndb 116\ndb 32\ndb 100\ndb 101\ndb 115\ndb 112\ndb 97\ndb 105\ndb 114\ndb 32\ndb 98\ndb 117\ndb 116\ndb 32\ndb 114\ndb 117\ndb 110\ndb 32\ndb 116\ndb 104\ndb 105\ndb 115\ndb 0\nalign 1\nL941 label byte\ndb 116\ndb 111\ndb 32\ndb 112\ndb 101\ndb 114\ndb 115\ndb 101\ndb 118\ndb 101\ndb 114\ndb 101\ndb 32\ndb 119\ndb 105\ndb 116\ndb 104\ndb 32\ndb 97\ndb 32\ndb 115\ndb 117\ndb 114\ndb 114\ndb 111\ndb 103\ndb 97\ndb 116\ndb 101\ndb 32\ndb 118\ndb 97\ndb 108\ndb 117\ndb 101\ndb 32\ndb 97\ndb 102\ndb 116\ndb 101\ndb 114\ndb 44\ndb 32\ndb 112\ndb 101\ndb 114\ndb 104\ndb 97\ndb 112\ndb 115\ndb 44\ndb 32\ndb 100\ndb 105\ndb 115\ndb 112\ndb 108\ndb 97\ndb 121\ndb 105\ndb 110\ndb 103\ndb 32\ndb 115\ndb 111\ndb 109\ndb 101\ndb 0\nalign 1\nL940 label byte\ndb 101\ndb 114\ndb 114\ndb 111\ndb 114\ndb 32\ndb 108\ndb 105\ndb 107\ndb 101\ndb 32\ndb 79\ndb 118\ndb 101\ndb 114\ndb 47\ndb 85\ndb 110\ndb 100\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 32\ndb 111\ndb 114\ndb 32\ndb 68\ndb 105\ndb 118\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 32\ndb 98\ndb 121\ndb 32\ndb 90\ndb 101\ndb 114\ndb 111\ndb 32\ndb 111\ndb 99\ndb 99\ndb 117\ndb 114\ndb 115\ndb 44\ndb 32\ndb 98\ndb 117\ndb 116\ndb 32\ndb 114\ndb 97\ndb 116\ndb 104\ndb 101\ndb 114\ndb 0\nalign 1\nL939 label byte\ndb 116\ndb 114\ndb 121\ndb 32\ndb 116\ndb 111\ndb 32\ndb 112\ndb 101\ndb 114\ndb 115\ndb 117\ndb 97\ndb 100\ndb 101\ndb 32\ndb 116\ndb 104\ndb 101\ndb 32\ndb 99\ndb 111\ndb 109\ndb 112\ndb 117\ndb 116\ndb 101\ndb 114\ndb 32\ndb 78\ndb 79\ndb 84\ndb 32\ndb 116\ndb 111\ndb 32\ndb 116\ndb 101\ndb 114\ndb 109\ndb 105\ndb 110\ndb 97\ndb 116\ndb 101\ndb 32\ndb 101\ndb 120\ndb 101\ndb 99\ndb 117\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 119\ndb 104\ndb 101\ndb 110\ndb 32\ndb 97\ndb 110\ndb 0\nalign 1\nL938 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 96\ndb 69\ndb 78\ndb 68\ndb 32\ndb 79\ndb 70\ndb 32\ndb 84\ndb 69\ndb 83\ndb 84\ndb 39\ndb 44\ndb 10\ndb 0\nalign 1\nL937 label byte\ndb 76\ndb 101\ndb 115\ndb 116\ndb 32\ndb 116\ndb 104\ndb 105\ndb 115\ndb 32\ndb 112\ndb 114\ndb 111\ndb 103\ndb 114\ndb 97\ndb 109\ndb 32\ndb 115\ndb 116\ndb 111\ndb 112\ndb 32\ndb 112\ndb 114\ndb 101\ndb 109\ndb 97\ndb 116\ndb 117\ndb 114\ndb 101\ndb 108\ndb 121\ndb 44\ndb 32\ndb 105\ndb 46\ndb 101\ndb 46\ndb 32\ndb 98\ndb 101\ndb 102\ndb 111\ndb 114\ndb 101\ndb 32\ndb 100\ndb 105\ndb 115\ndb 112\ndb 108\ndb 97\ndb 121\ndb 105\ndb 110\ndb 103\ndb 10\ndb 0\nalign 1\nL934 label byte\ndb 37\ndb 115\ndb 10\ndb 0\nalign 1\nL929 label byte\ndb 32\ndb 32\ndb 32\ndb 80\ndb 76\ndb 69\ndb 65\ndb 83\ndb 69\ndb 32\ndb 78\ndb 79\ndb 84\ndb 73\ndb 70\ndb 89\ndb 32\ndb 75\ndb 65\ndb 82\ndb 80\ndb 73\ndb 78\ndb 75\ndb 83\ndb 73\ndb 33\ndb 10\ndb 0\nalign 1\nL928 label byte\ndb 37\ndb 115\ndb 32\ndb 116\ndb 101\ndb 115\ndb 116\ndb 32\ndb 97\ndb 112\ndb 112\ndb 101\ndb 97\ndb 114\ndb 115\ndb 32\ndb 116\ndb 111\ndb 32\ndb 98\ndb 101\ndb 32\ndb 105\ndb 110\ndb 99\ndb 111\ndb 110\ndb 115\ndb 105\ndb 115\ndb 116\ndb 101\ndb 110\ndb 116\ndb 46\ndb 46\ndb 46\ndb 10\ndb 0\nalign 1\nL926 label byte\ndb 9\ndb 100\ndb 105\ndb 102\ndb 102\ndb 101\ndb 114\ndb 115\ndb 32\ndb 102\ndb 114\ndb 111\ndb 109\ndb 32\ndb 90\ndb 32\ndb 42\ndb 32\ndb 49\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 10\ndb 0\nalign 1\nL925 label byte\ndb 9\ndb 67\ndb 111\ndb 109\ndb 112\ndb 97\ndb 114\ndb 105\ndb 115\ndb 111\ndb 110\ndb 32\ndb 97\ndb 108\ndb 108\ndb 101\ndb 103\ndb 101\ndb 115\ndb 32\ndb 116\ndb 104\ndb 97\ndb 116\ndb 32\ndb 49\ndb 32\ndb 42\ndb 32\ndb 90\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 10\ndb 0\nalign 1\nL924 label byte\ndb 77\ndb 117\ndb 108\ndb 116\ndb 105\ndb 112\ndb 108\ndb 105\ndb 99\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 100\ndb 111\ndb 101\ndb 115\ndb 32\ndb 110\ndb 111\ndb 116\ndb 32\ndb 99\ndb 111\ndb 109\ndb 109\ndb 117\ndb 116\ndb 101\ndb 33\ndb 10\ndb 0\nalign 1\nL919 label byte\ndb 90\ndb 32\ndb 47\ndb 32\ndb 49\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 10\ndb 0\nalign 1\nL916 label byte\ndb 49\ndb 32\ndb 42\ndb 32\ndb 90\ndb 32\ndb 61\ndb 61\ndb 32\ndb 37\ndb 103\ndb 10\ndb 0\nalign 1\nL913 label byte\ndb 90\ndb 32\ndb 42\ndb 32\ndb 49\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 32\ndb 0\nalign 1\nL910 label byte\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 10\ndb 9\ndb 99\ndb 111\ndb 109\ndb 112\ndb 97\ndb 114\ndb 101\ndb 115\ndb 32\ndb 100\ndb 105\ndb 102\ndb 102\ndb 101\ndb 114\ndb 101\ndb 110\ndb 116\ndb 32\ndb 102\ndb 114\ndb 111\ndb 109\ndb 32\ndb 32\ndb 0\nalign 1\nL909 label byte\ndb 87\ndb 104\ndb 97\ndb 116\ndb 32\ndb 112\ndb 114\ndb 105\ndb 110\ndb 116\ndb 115\ndb 32\ndb 97\ndb 115\ndb 32\ndb 90\ndb 32\ndb 61\ndb 32\ndb 0\nalign 1\nL904 label byte\ndb 84\ndb 104\ndb 105\ndb 115\ndb 32\ndb 105\ndb 115\ndb 32\ndb 97\ndb 32\ndb 68\ndb 69\ndb 70\ndb 69\ndb 67\ndb 84\ndb 33\ndb 10\ndb 0\nalign 1\nL901 label byte\ndb 84\ndb 104\ndb 105\ndb 115\ndb 32\ndb 105\ndb 115\ndb 32\ndb 97\ndb 32\ndb 86\ndb 69\ndb 82\ndb 89\ndb 32\ndb 83\ndb 69\ndb 82\ndb 73\ndb 79\ndb 85\ndb 83\ndb 32\ndb 68\ndb 69\ndb 70\ndb 69\ndb 67\ndb 84\ndb 33\ndb 10\ndb 0\nalign 1\nL895 label byte\ndb 32\ndb 104\ndb 97\ndb 115\ndb 32\ndb 78\ndb 79\ndb 84\ndb 32\ndb 106\ndb 117\ndb 115\ndb 116\ndb 32\ndb 98\ndb 101\ndb 101\ndb 110\ndb 32\ndb 115\ndb 105\ndb 103\ndb 110\ndb 97\ndb 108\ndb 101\ndb 100\ndb 46\ndb 10\ndb 0\nalign 1\nL894 label byte\ndb 84\ndb 104\ndb 105\ndb 115\ndb 32\ndb 105\ndb 115\ndb 32\ndb 79\ndb 46\ndb 75\ndb 46\ndb 44\ndb 32\ndb 112\ndb 114\ndb 111\ndb 118\ndb 105\ndb 100\ndb 101\ndb 100\ndb 32\ndb 79\ndb 118\ndb 101\ndb 114\ndb 47\ndb 85\ndb 110\ndb 100\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 0\nalign 1\nL891 label byte\ndb 87\ndb 104\ndb 97\ndb 116\ndb 32\ndb 116\ndb 104\ndb 101\ndb 32\ndb 109\ndb 97\ndb 99\ndb 104\ndb 105\ndb 110\ndb 101\ndb 32\ndb 103\ndb 101\ndb 116\ndb 115\ndb 32\ndb 102\ndb 111\ndb 114\ndb 32\ndb 40\ndb 90\ndb 32\ndb 43\ndb 32\ndb 90\ndb 41\ndb 32\ndb 47\ndb 32\ndb 90\ndb 32\ndb 105\ndb 115\ndb 32\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL887 label byte\ndb 40\ndb 90\ndb 32\ndb 43\ndb 32\ndb 90\ndb 41\ndb 32\ndb 47\ndb 32\ndb 90\ndb 32\ndb 115\ndb 104\ndb 111\ndb 117\ndb 108\ndb 100\ndb 32\ndb 98\ndb 101\ndb 32\ndb 115\ndb 97\ndb 102\ndb 101\ndb 46\ndb 10\ndb 0\nalign 1\nL886 label byte\ndb 83\ndb 105\ndb 110\ndb 99\ndb 101\ndb 32\ndb 99\ndb 111\ndb 109\ndb 112\ndb 97\ndb 114\ndb 105\ndb 115\ndb 111\ndb 110\ndb 32\ndb 100\ndb 101\ndb 110\ndb 105\ndb 101\ndb 115\ndb 32\ndb 90\ndb 32\ndb 61\ndb 32\ndb 48\ndb 44\ndb 32\ndb 101\ndb 118\ndb 97\ndb 108\ndb 117\ndb 97\ndb 116\ndb 105\ndb 110\ndb 103\ndb 32\ndb 0\nalign 1\nL882 label byte\ndb 83\ndb 105\ndb 109\ndb 105\ndb 108\ndb 97\ndb 114\ndb 32\ndb 100\ndb 105\ndb 115\ndb 99\ndb 114\ndb 101\ndb 112\ndb 97\ndb 110\ndb 99\ndb 105\ndb 101\ndb 115\ndb 32\ndb 104\ndb 97\ndb 118\ndb 101\ndb 32\ndb 111\ndb 99\ndb 99\ndb 117\ndb 114\ndb 114\ndb 101\ndb 100\ndb 32\ndb 37\ndb 100\ndb 32\ndb 116\ndb 105\ndb 109\ndb 101\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL872 label byte\ndb 9\ndb 9\ndb 116\ndb 104\ndb 101\ndb 121\ndb 32\ndb 100\ndb 105\ndb 102\ndb 102\ndb 101\ndb 114\ndb 32\ndb 98\ndb 121\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL871 label byte\ndb 9\ndb 119\ndb 104\ndb 105\ndb 99\ndb 104\ndb 32\ndb 99\ndb 111\ndb 109\ndb 112\ndb 97\ndb 114\ndb 101\ndb 100\ndb 32\ndb 117\ndb 110\ndb 101\ndb 113\ndb 117\ndb 97\ndb 108\ndb 32\ndb 116\ndb 111\ndb 32\ndb 99\ndb 111\ndb 114\ndb 114\ndb 101\ndb 99\ndb 116\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 32\ndb 59\ndb 10\ndb 0\nalign 1\nL870 label byte\ndb 9\ndb 121\ndb 105\ndb 101\ndb 108\ndb 100\ndb 101\ndb 100\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 59\ndb 10\ndb 0\nalign 1\nL869 label byte\ndb 9\ndb 40\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 41\ndb 32\ndb 94\ndb 32\ndb 40\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 41\ndb 10\ndb 0\nalign 1\nL868 label byte\ndb 99\ndb 111\ndb 109\ndb 112\ndb 117\ndb 116\ndb 105\ndb 110\ndb 103\ndb 10\ndb 0\nalign 1\nL867 label byte\ndb 87\ndb 65\ndb 82\ndb 78\ndb 73\ndb 78\ndb 71\ndb 58\ndb 32\ndb 32\ndb 99\ndb 111\ndb 109\ndb 112\ndb 117\ndb 116\ndb 105\ndb 110\ndb 103\ndb 10\ndb 0\nalign 1\nL849 label byte\ndb 9\ndb 105\ndb 110\ndb 115\ndb 116\ndb 101\ndb 97\ndb 100\ndb 32\ndb 111\ndb 102\ndb 32\ndb 99\ndb 111\ndb 114\ndb 114\ndb 101\ndb 99\ndb 116\ndb 32\ndb 118\ndb 97\ndb 108\ndb 117\ndb 101\ndb 32\ndb 48\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL848 label byte\ndb 115\ndb 113\ndb 114\ndb 116\ndb 40\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 41\ndb 32\ndb 45\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 32\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 10\ndb 0\nalign 4\nL840 label byte\ndd 088e368f1H\ndd 03ed4f8b5H\nalign 1\nL838 label byte\ndb 37\ndb 115\ndb 58\ndb 32\ndb 32\ndb 37\ndb 115\ndb 0\nalign 1\nL837 label byte\ndb 70\ndb 76\ndb 65\ndb 87\ndb 0\nalign 1\nL836 label byte\ndb 68\ndb 69\ndb 70\ndb 69\ndb 67\ndb 84\ndb 0\nalign 1\nL835 label byte\ndb 83\ndb 69\ndb 82\ndb 73\ndb 79\ndb 85\ndb 83\ndb 32\ndb 68\ndb 69\ndb 70\ndb 69\ndb 67\ndb 84\ndb 0\nalign 1\nL834 label byte\ndb 70\ndb 65\ndb 73\ndb 76\ndb 85\ndb 82\ndb 69\ndb 0\nalign 1\nL828 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 80\ndb 97\ndb 103\ndb 101\ndb 58\ndb 32\ndb 37\ndb 100\ndb 10\ndb 10\ndb 0\nalign 1\nL827 label byte\ndb 10\ndb 68\ndb 105\ndb 97\ndb 103\ndb 110\ndb 111\ndb 115\ndb 105\ndb 115\ndb 32\ndb 114\ndb 101\ndb 115\ndb 117\ndb 109\ndb 101\ndb 115\ndb 32\ndb 97\ndb 102\ndb 116\ndb 101\ndb 114\ndb 32\ndb 109\ndb 105\ndb 108\ndb 101\ndb 115\ndb 116\ndb 111\ndb 110\ndb 101\ndb 32\ndb 78\ndb 117\ndb 109\ndb 98\ndb 101\ndb 114\ndb 32\ndb 37\ndb 100\ndb 0\nalign 4\nL825 label byte\ndd 00H\ndd 0bff00000H\nalign 1\nL820 label byte\ndb 69\ndb 78\ndb 68\ndb 32\ndb 79\ndb 70\ndb 32\ndb 84\ndb 69\ndb 83\ndb 84\ndb 46\ndb 10\ndb 0\nalign 1\nL819 label byte\ndb 10\ndb 65\ndb 32\ndb 116\ndb 111\ndb 116\ndb 97\ndb 108\ndb 32\ndb 111\ndb 102\ndb 32\ndb 37\ndb 100\ndb 32\ndb 102\ndb 108\ndb 111\ndb 97\ndb 116\ndb 105\ndb 110\ndb 103\ndb 32\ndb 112\ndb 111\ndb 105\ndb 110\ndb 116\ndb 32\ndb 101\ndb 120\ndb 99\ndb 101\ndb 112\ndb 116\ndb 105\ndb 111\ndb 110\ndb 115\ndb 32\ndb 119\ndb 101\ndb 114\ndb 101\ndb 32\ndb 114\ndb 101\ndb 103\ndb 105\ndb 115\ndb 116\ndb 101\ndb 114\ndb 101\ndb 100\ndb 46\ndb 10\ndb 0\nalign 1\nL816 label byte\ndb 84\ndb 104\ndb 101\ndb 32\ndb 97\ndb 114\ndb 105\ndb 116\ndb 104\ndb 109\ndb 101\ndb 116\ndb 105\ndb 99\ndb 32\ndb 100\ndb 105\ndb 97\ndb 103\ndb 110\ndb 111\ndb 115\ndb 101\ndb 100\ndb 32\ndb 97\ndb 112\ndb 112\ndb 101\ndb 97\ndb 114\ndb 115\ndb 32\ndb 116\ndb 111\ndb 32\ndb 98\ndb 101\ndb 32\ndb 69\ndb 120\ndb 99\ndb 101\ndb 108\ndb 108\ndb 101\ndb 110\ndb 116\ndb 33\ndb 10\ndb 0\nalign 1\nL815 label byte\ndb 32\ndb 100\ndb 117\ndb 114\ndb 105\ndb 110\ndb 103\ndb 32\ndb 71\ndb 114\ndb 97\ndb 100\ndb 117\ndb 97\ndb 108\ndb 32\ndb 85\ndb 110\ndb 100\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 46\ndb 10\ndb 0\nalign 1\nL814 label byte\ndb 44\ndb 10\ndb 101\ndb 120\ndb 99\ndb 101\ndb 112\ndb 116\ndb 32\ndb 102\ndb 111\ndb 114\ndb 32\ndb 112\ndb 111\ndb 115\ndb 115\ndb 105\ndb 98\ndb 108\ndb 121\ndb 32\ndb 68\ndb 111\ndb 117\ndb 98\ndb 108\ndb 101\ndb 32\ndb 82\ndb 111\ndb 117\ndb 110\ndb 100\ndb 105\ndb 110\ndb 103\ndb 0\nalign 1\nL813 label byte\ndb 46\ndb 10\ndb 0\nalign 1\nL810 label byte\ndb 56\ndb 53\ndb 52\ndb 0\nalign 1\nL809 label byte\ndb 55\ndb 53\ndb 52\ndb 0\nalign 1\nL806 label byte\ndb 116\ndb 104\ndb 101\ndb 32\ndb 112\ndb 114\ndb 111\ndb 112\ndb 111\ndb 115\ndb 101\ndb 100\ndb 32\ndb 73\ndb 69\ndb 69\ndb 69\ndb 32\ndb 115\ndb 116\ndb 97\ndb 110\ndb 100\ndb 97\ndb 114\ndb 100\ndb 32\ndb 80\ndb 0\nalign 1\nL805 label byte\ndb 82\ndb 111\ndb 117\ndb 110\ndb 100\ndb 105\ndb 110\ndb 103\ndb 32\ndb 97\ndb 112\ndb 112\ndb 101\ndb 97\ndb 114\ndb 115\ndb 32\ndb 116\ndb 111\ndb 32\ndb 99\ndb 111\ndb 110\ndb 102\ndb 111\ndb 114\ndb 109\ndb 32\ndb 116\ndb 111\ndb 32\ndb 0\nalign 1\nL802 label byte\ndb 84\ndb 104\ndb 101\ndb 32\ndb 97\ndb 114\ndb 105\ndb 116\ndb 104\ndb 109\ndb 101\ndb 116\ndb 105\ndb 99\ndb 32\ndb 100\ndb 105\ndb 97\ndb 103\ndb 110\ndb 111\ndb 115\ndb 101\ndb 100\ndb 32\ndb 115\ndb 101\ndb 101\ndb 109\ndb 115\ndb 32\ndb 83\ndb 97\ndb 116\ndb 105\ndb 115\ndb 102\ndb 97\ndb 99\ndb 116\ndb 111\ndb 114\ndb 121\ndb 46\ndb 10\ndb 0\nalign 1\nL796 label byte\ndb 78\ndb 111\ndb 32\ndb 102\ndb 97\ndb 105\ndb 108\ndb 117\ndb 114\ndb 101\ndb 115\ndb 44\ndb 32\ndb 100\ndb 101\ndb 102\ndb 101\ndb 99\ndb 116\ndb 115\ndb 32\ndb 110\ndb 111\ndb 114\ndb 32\ndb 102\ndb 108\ndb 97\ndb 119\ndb 115\ndb 32\ndb 104\ndb 97\ndb 118\ndb 101\ndb 32\ndb 98\ndb 101\ndb 101\ndb 110\ndb 32\ndb 100\ndb 105\ndb 115\ndb 99\ndb 111\ndb 118\ndb 101\ndb 114\ndb 101\ndb 100\ndb 46\ndb 10\ndb 0\nalign 1\nL795 label byte\ndb 32\ndb 112\ndb 114\ndb 111\ndb 103\ndb 114\ndb 97\ndb 109\ndb 39\ndb 115\ndb 32\ndb 115\ndb 117\ndb 98\ndb 115\ndb 101\ndb 113\ndb 117\ndb 101\ndb 110\ndb 116\ndb 32\ndb 100\ndb 105\ndb 97\ndb 103\ndb 110\ndb 111\ndb 115\ndb 101\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL794 label byte\ndb 80\ndb 111\ndb 116\ndb 101\ndb 110\ndb 116\ndb 105\ndb 97\ndb 108\ndb 108\ndb 121\ndb 32\ndb 102\ndb 97\ndb 116\ndb 97\ndb 108\ndb 32\ndb 70\ndb 65\ndb 73\ndb 76\ndb 85\ndb 82\ndb 69\ndb 32\ndb 109\ndb 97\ndb 121\ndb 32\ndb 104\ndb 97\ndb 118\ndb 101\ndb 32\ndb 115\ndb 112\ndb 111\ndb 105\ndb 108\ndb 101\ndb 100\ndb 32\ndb 116\ndb 104\ndb 105\ndb 115\ndb 0\nalign 1\nL791 label byte\ndb 117\ndb 110\ndb 97\ndb 99\ndb 99\ndb 101\ndb 112\ndb 116\ndb 97\ndb 98\ndb 108\ndb 101\ndb 32\ndb 83\ndb 101\ndb 114\ndb 105\ndb 111\ndb 117\ndb 115\ndb 32\ndb 68\ndb 101\ndb 102\ndb 101\ndb 99\ndb 116\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL790 label byte\ndb 84\ndb 104\ndb 101\ndb 32\ndb 97\ndb 114\ndb 105\ndb 116\ndb 104\ndb 109\ndb 101\ndb 116\ndb 105\ndb 99\ndb 32\ndb 100\ndb 105\ndb 97\ndb 103\ndb 110\ndb 111\ndb 115\ndb 101\ndb 100\ndb 32\ndb 104\ndb 97\ndb 115\ndb 32\ndb 0\nalign 1\nL786 label byte\ndb 100\ndb 101\ndb 115\ndb 112\ndb 105\ndb 116\ndb 101\ndb 32\ndb 105\ndb 110\ndb 99\ndb 111\ndb 110\ndb 118\ndb 101\ndb 110\ndb 105\ndb 101\ndb 110\ndb 116\ndb 32\ndb 68\ndb 101\ndb 102\ndb 101\ndb 99\ndb 116\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL785 label byte\ndb 84\ndb 104\ndb 101\ndb 32\ndb 97\ndb 114\ndb 105\ndb 116\ndb 104\ndb 109\ndb 101\ndb 116\ndb 105\ndb 99\ndb 32\ndb 100\ndb 105\ndb 97\ndb 103\ndb 110\ndb 111\ndb 115\ndb 101\ndb 100\ndb 32\ndb 109\ndb 97\ndb 121\ndb 32\ndb 98\ndb 101\ndb 32\ndb 65\ndb 99\ndb 99\ndb 101\ndb 112\ndb 116\ndb 97\ndb 98\ndb 108\ndb 101\ndb 10\ndb 0\nalign 1\nL780 label byte\ndb 83\ndb 97\ndb 116\ndb 105\ndb 115\ndb 102\ndb 97\ndb 99\ndb 116\ndb 111\ndb 114\ndb 121\ndb 32\ndb 116\ndb 104\ndb 111\ndb 117\ndb 103\ndb 104\ndb 32\ndb 102\ndb 108\ndb 97\ndb 119\ndb 101\ndb 100\ndb 46\ndb 10\ndb 0\nalign 1\nL779 label byte\ndb 84\ndb 104\ndb 101\ndb 32\ndb 97\ndb 114\ndb 105\ndb 116\ndb 104\ndb 109\ndb 101\ndb 116\ndb 105\ndb 99\ndb 32\ndb 100\ndb 105\ndb 97\ndb 103\ndb 110\ndb 111\ndb 115\ndb 101\ndb 100\ndb 32\ndb 115\ndb 101\ndb 101\ndb 109\ndb 115\ndb 32\ndb 0\nalign 1\nL768 label byte\ndb 84\ndb 104\ndb 101\ndb 32\ndb 110\ndb 117\ndb 109\ndb 98\ndb 101\ndb 114\ndb 32\ndb 111\ndb 102\ndb 32\ndb 32\ndb 37\ndb 45\ndb 50\ndb 57\ndb 115\ndb 32\ndb 37\ndb 100\ndb 46\ndb 10\ndb 0\nalign 1\nL761 label byte\ndb 70\ndb 76\ndb 65\ndb 87\ndb 115\ndb 32\ndb 32\ndb 100\ndb 105\ndb 115\ndb 99\ndb 111\ndb 118\ndb 101\ndb 114\ndb 101\ndb 100\ndb 32\ndb 61\ndb 0\nalign 1\nL760 label byte\ndb 68\ndb 69\ndb 70\ndb 69\ndb 67\ndb 84\ndb 115\ndb 32\ndb 32\ndb 100\ndb 105\ndb 115\ndb 99\ndb 111\ndb 118\ndb 101\ndb 114\ndb 101\ndb 100\ndb 32\ndb 61\ndb 0\nalign 1\nL759 label byte\ndb 83\ndb 69\ndb 82\ndb 73\ndb 79\ndb 85\ndb 83\ndb 32\ndb 68\ndb 69\ndb 70\ndb 69\ndb 67\ndb 84\ndb 115\ndb 32\ndb 32\ndb 100\ndb 105\ndb 115\ndb 99\ndb 111\ndb 118\ndb 101\ndb 114\ndb 101\ndb 100\ndb 32\ndb 61\ndb 0\nalign 1\nL758 label byte\ndb 70\ndb 65\ndb 73\ndb 76\ndb 85\ndb 82\ndb 69\ndb 115\ndb 32\ndb 32\ndb 101\ndb 110\ndb 99\ndb 111\ndb 117\ndb 110\ndb 116\ndb 101\ndb 114\ndb 101\ndb 100\ndb 32\ndb 61\ndb 0\nalign 1\nL754 label byte\ndb 10\ndb 32\ndb 32\ndb 32\ndb 32\ndb 84\ndb 114\ndb 121\ndb 105\ndb 110\ndb 103\ndb 32\ndb 116\ndb 111\ndb 32\ndb 99\ndb 111\ndb 109\ndb 112\ndb 117\ndb 116\ndb 101\ndb 32\ndb 48\ndb 32\ndb 47\ndb 32\ndb 48\ndb 32\ndb 112\ndb 114\ndb 111\ndb 100\ndb 117\ndb 99\ndb 101\ndb 115\ndb 32\ndb 46\ndb 46\ndb 46\ndb 0\nalign 1\nL753 label byte\ndb 32\ndb 32\ndb 37\ndb 46\ndb 55\ndb 101\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL750 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 84\ndb 114\ndb 121\ndb 105\ndb 110\ndb 103\ndb 32\ndb 116\ndb 111\ndb 32\ndb 99\ndb 111\ndb 109\ndb 112\ndb 117\ndb 116\ndb 101\ndb 32\ndb 49\ndb 32\ndb 47\ndb 32\ndb 48\ndb 32\ndb 112\ndb 114\ndb 111\ndb 100\ndb 117\ndb 99\ndb 101\ndb 115\ndb 32\ndb 46\ndb 46\ndb 46\ndb 0\nalign 1\nL749 label byte\ndb 87\ndb 104\ndb 97\ndb 116\ndb 32\ndb 109\ndb 101\ndb 115\ndb 115\ndb 97\ndb 103\ndb 101\ndb 32\ndb 97\ndb 110\ndb 100\ndb 47\ndb 111\ndb 114\ndb 32\ndb 118\ndb 97\ndb 108\ndb 117\ndb 101\ndb 115\ndb 32\ndb 100\ndb 111\ndb 101\ndb 115\ndb 32\ndb 68\ndb 105\ndb 118\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 32\ndb 98\ndb 121\ndb 32\ndb 90\ndb 101\ndb 114\ndb 111\ndb 32\ndb 112\ndb 114\ndb 111\ndb 100\ndb 117\ndb 99\ndb 101\ndb 63\ndb 10\ndb 0\nalign 1\nL748 label byte\ndb 32\ndb 32\ndb 105\ndb 110\ndb 115\ndb 116\ndb 101\ndb 97\ndb 100\ndb 44\ndb 32\ndb 88\ndb 32\ndb 47\ndb 32\ndb 88\ndb 32\ndb 45\ndb 32\ndb 49\ndb 47\ndb 50\ndb 32\ndb 45\ndb 32\ndb 49\ndb 47\ndb 50\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL747 label byte\ndb 32\ndb 32\ndb 88\ndb 32\ndb 47\ndb 32\ndb 88\ndb 32\ndb 100\ndb 105\ndb 102\ndb 102\ndb 101\ndb 114\ndb 115\ndb 32\ndb 102\ndb 114\ndb 111\ndb 109\ndb 32\ndb 49\ndb 32\ndb 119\ndb 104\ndb 101\ndb 110\ndb 32\ndb 88\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 10\ndb 0\nalign 1\nL742 label byte\ndb 32\ndb 32\ndb 88\ndb 32\ndb 47\ndb 32\ndb 88\ndb 32\ndb 32\ndb 116\ndb 114\ndb 97\ndb 112\ndb 115\ndb 32\ndb 119\ndb 104\ndb 101\ndb 110\ndb 32\ndb 88\ndb 32\ndb 61\ndb 32\ndb 37\ndb 103\ndb 10\ndb 0\nalign 1\nL727 label byte\ndb 105\ndb 115\ndb 32\ndb 116\ndb 111\ndb 111\ndb 32\ndb 102\ndb 97\ndb 114\ndb 32\ndb 102\ndb 114\ndb 111\ndb 109\ndb 32\ndb 49\ndb 46\ndb 10\ndb 0\nalign 1\nL726 label byte\ndb 32\ndb 117\ndb 110\ndb 98\ndb 97\ndb 108\ndb 97\ndb 110\ndb 99\ndb 101\ndb 100\ndb 32\ndb 114\ndb 97\ndb 110\ndb 103\ndb 101\ndb 59\ndb 32\ndb 85\ndb 102\ndb 84\ndb 104\ndb 111\ndb 108\ndb 100\ndb 32\ndb 42\ndb 32\ndb 86\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 10\ndb 9\ndb 37\ndb 115\ndb 10\ndb 0\nalign 1\nL725 label byte\ndb 66\ndb 97\ndb 100\ndb 108\ndb 121\ndb 0\nalign 1\nL718 label byte\ndb 32\ndb 105\ndb 115\ndb 32\ndb 116\ndb 111\ndb 111\ndb 32\ndb 102\ndb 97\ndb 114\ndb 32\ndb 102\ndb 114\ndb 111\ndb 109\ndb 32\ndb 115\ndb 113\ndb 114\ndb 116\ndb 40\ndb 90\ndb 41\ndb 32\ndb 94\ndb 32\ndb 50\ndb 32\ndb 40\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 41\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL717 label byte\ndb 67\ndb 111\ndb 109\ndb 112\ndb 97\ndb 114\ndb 105\ndb 115\ndb 111\ndb 110\ndb 32\ndb 97\ndb 108\ndb 108\ndb 101\ndb 103\ndb 101\ndb 115\ndb 32\ndb 116\ndb 104\ndb 97\ndb 116\ndb 32\ndb 90\ndb 32\ndb 61\ndb 32\ndb 37\ndb 49\ndb 55\ndb 101\ndb 10\ndb 0\nalign 1\nL705 label byte\ndb 32\ndb 105\ndb 115\ndb 32\ndb 116\ndb 111\ndb 111\ndb 32\ndb 102\ndb 97\ndb 114\ndb 32\ndb 102\ndb 114\ndb 111\ndb 109\ndb 32\ndb 115\ndb 113\ndb 114\ndb 116\ndb 40\ndb 90\ndb 41\ndb 32\ndb 94\ndb 32\ndb 50\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL704 label byte\ndb 67\ndb 111\ndb 109\ndb 112\ndb 97\ndb 114\ndb 105\ndb 115\ndb 111\ndb 110\ndb 32\ndb 97\ndb 108\ndb 108\ndb 101\ndb 103\ndb 101\ndb 115\ndb 32\ndb 116\ndb 104\ndb 97\ndb 116\ndb 32\ndb 119\ndb 104\ndb 97\ndb 116\ndb 32\ndb 112\ndb 114\ndb 105\ndb 110\ndb 116\ndb 115\ndb 32\ndb 97\ndb 115\ndb 32\ndb 90\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 10\ndb 0\nalign 1\nL687 label byte\ndb 43\ndb 45\ndb 37\ndb 103\ndb 44\ndb 32\ndb 43\ndb 45\ndb 37\ndb 103\ndb 10\ndb 97\ndb 110\ndb 100\ndb 32\ndb 43\ndb 45\ndb 37\ndb 103\ndb 32\ndb 97\ndb 114\ndb 101\ndb 32\ndb 99\ndb 111\ndb 110\ndb 102\ndb 117\ndb 115\ndb 101\ndb 100\ndb 32\ndb 98\ndb 121\ndb 32\ndb 79\ndb 118\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 46\ndb 0\nalign 1\nL686 label byte\ndb 67\ndb 111\ndb 109\ndb 112\ndb 97\ndb 114\ndb 105\ndb 115\ndb 111\ndb 110\ndb 115\ndb 32\ndb 105\ndb 110\ndb 118\ndb 111\ndb 108\ndb 118\ndb 105\ndb 110\ndb 103\ndb 32\ndb 0\nalign 1\nL680 label byte\ndb 97\ndb 98\ndb 111\ndb 118\ndb 101\ndb 32\ndb 105\ndb 115\ndb 32\ndb 97\ndb 32\ndb 68\ndb 69\ndb 70\ndb 69\ndb 67\ndb 84\ndb 46\ndb 10\ndb 0\nalign 1\nL679 label byte\ndb 65\ndb 110\ndb 121\ndb 32\ndb 111\ndb 118\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 32\ndb 115\ndb 105\ndb 103\ndb 110\ndb 97\ndb 108\ndb 32\ndb 115\ndb 101\ndb 112\ndb 97\ndb 114\ndb 97\ndb 116\ndb 105\ndb 110\ndb 103\ndb 32\ndb 116\ndb 104\ndb 105\ndb 115\ndb 32\ndb 42\ndb 32\ndb 102\ndb 114\ndb 111\ndb 109\ndb 32\ndb 116\ndb 104\ndb 101\ndb 32\ndb 111\ndb 110\ndb 101\ndb 10\ndb 0\nalign 1\nL678 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 110\ndb 111\ndb 114\ndb 32\ndb 102\ndb 111\ndb 114\ndb 32\ndb 86\ndb 32\ndb 47\ndb 32\ndb 49\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL677 label byte\ndb 78\ndb 111\ndb 32\ndb 79\ndb 118\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 32\ndb 115\ndb 104\ndb 111\ndb 117\ndb 108\ndb 100\ndb 32\ndb 98\ndb 101\ndb 32\ndb 115\ndb 105\ndb 103\ndb 110\ndb 97\ndb 108\ndb 101\ndb 100\ndb 32\ndb 102\ndb 111\ndb 114\ndb 32\ndb 86\ndb 32\ndb 42\ndb 32\ndb 49\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 10\ndb 0\nalign 1\nL676 label byte\ndb 84\ndb 104\ndb 101\ndb 114\ndb 101\ndb 32\ndb 105\ndb 115\ndb 32\ndb 110\ndb 111\ndb 32\ndb 115\ndb 97\ndb 116\ndb 117\ndb 114\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 118\ndb 97\ndb 108\ndb 117\ndb 101\ndb 32\ndb 98\ndb 101\ndb 99\ndb 97\ndb 117\ndb 115\ndb 101\ndb 32\ndb 116\ndb 104\ndb 101\ndb 32\ndb 115\ndb 121\ndb 115\ndb 116\ndb 101\ndb 109\ndb 32\ndb 116\ndb 114\ndb 97\ndb 112\ndb 115\ndb 32\ndb 111\ndb 110\ndb 32\ndb 111\ndb 118\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 46\ndb 10\ndb 0\nalign 1\nL675 label byte\ndb 79\ndb 118\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 32\ndb 115\ndb 97\ndb 116\ndb 117\ndb 114\ndb 97\ndb 116\ndb 101\ndb 115\ndb 32\ndb 97\ndb 116\ndb 32\ndb 86\ndb 48\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL672 label byte\ndb 79\ndb 118\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 32\ndb 116\ndb 104\ndb 114\ndb 101\ndb 115\ndb 104\ndb 111\ndb 108\ndb 100\ndb 32\ndb 105\ndb 115\ndb 32\ndb 86\ndb 32\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL663 label byte\ndb 111\ndb 118\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 32\ndb 112\ndb 97\ndb 115\ndb 116\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 10\ndb 9\ndb 115\ndb 104\ndb 114\ndb 105\ndb 110\ndb 107\ndb 115\ndb 32\ndb 116\ndb 111\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL660 label byte\ndb 45\ndb 40\ndb 45\ndb 89\ndb 41\ndb 32\ndb 100\ndb 105\ndb 102\ndb 102\ndb 101\ndb 114\ndb 115\ndb 32\ndb 102\ndb 114\ndb 111\ndb 109\ndb 32\ndb 89\ndb 46\ndb 10\ndb 0\nalign 1\nL659 label byte\ndb 102\ndb 105\ndb 110\ndb 100\ndb 115\ndb 32\ndb 97\ndb 32\ndb 0\nalign 1\nL658 label byte\ndb 83\ndb 101\ndb 101\ndb 109\ndb 115\ndb 32\ndb 79\ndb 46\ndb 75\ndb 46\ndb 10\ndb 0\nalign 1\nL655 label byte\ndb 84\ndb 114\ndb 121\ndb 105\ndb 110\ndb 103\ndb 32\ndb 105\ndb 116\ndb 32\ndb 111\ndb 110\ndb 32\ndb 89\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL654 label byte\ndb 67\ndb 97\ndb 110\ndb 32\ndb 96\ndb 90\ndb 32\ndb 61\ndb 32\ndb 45\ndb 89\ndb 39\ndb 32\ndb 111\ndb 118\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 63\ndb 10\ndb 0\nalign 1\nL647 label byte\ndb 84\ndb 104\ndb 105\ndb 115\ndb 32\ndb 109\ndb 97\ndb 121\ndb 32\ndb 103\ndb 101\ndb 110\ndb 101\ndb 114\ndb 97\ndb 116\ndb 101\ndb 32\ndb 97\ndb 110\ndb 32\ndb 101\ndb 114\ndb 114\ndb 111\ndb 114\ndb 46\ndb 10\ndb 0\nalign 1\nL646 label byte\ndb 83\ndb 101\ndb 97\ndb 114\ndb 99\ndb 104\ndb 105\ndb 110\ndb 103\ndb 32\ndb 102\ndb 111\ndb 114\ndb 32\ndb 79\ndb 118\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 32\ndb 116\ndb 104\ndb 114\ndb 101\ndb 115\ndb 104\ndb 111\ndb 108\ndb 100\ndb 58\ndb 10\ndb 0\nalign 1\nL645 label byte\ndb 32\ndb 46\ndb 46\ndb 46\ndb 32\ndb 110\ndb 111\ndb 32\ndb 100\ndb 105\ndb 115\ndb 99\ndb 114\ndb 101\ndb 112\ndb 97\ndb 110\ndb 99\ndb 105\ndb 101\ndb 115\ndb 32\ndb 102\ndb 111\ndb 117\ndb 110\ndb 100\ndb 46\ndb 10\ndb 0\nalign 1\nL637 label byte\ndb 84\ndb 101\ndb 115\ndb 116\ndb 105\ndb 110\ndb 103\ndb 32\ndb 112\ndb 111\ndb 119\ndb 101\ndb 114\ndb 115\ndb 32\ndb 90\ndb 94\ndb 81\ndb 32\ndb 97\ndb 116\ndb 32\ndb 102\ndb 111\ndb 117\ndb 114\ndb 32\ndb 110\ndb 101\ndb 97\ndb 114\ndb 108\ndb 121\ndb 32\ndb 101\ndb 120\ndb 116\ndb 114\ndb 101\ndb 109\ndb 101\ndb 32\ndb 118\ndb 97\ndb 108\ndb 117\ndb 101\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL636 label byte\ndb 65\ndb 99\ndb 99\ndb 117\ndb 114\ndb 97\ndb 99\ndb 121\ndb 32\ndb 115\ndb 101\ndb 101\ndb 109\ndb 115\ndb 32\ndb 97\ndb 100\ndb 101\ndb 113\ndb 117\ndb 97\ndb 116\ndb 101\ndb 46\ndb 10\ndb 0\nalign 1\nL629 label byte\ndb 9\ndb 99\ndb 97\ndb 108\ndb 99\ndb 117\ndb 108\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 115\ndb 32\ndb 105\ndb 110\ndb 118\ndb 111\ndb 108\ndb 118\ndb 105\ndb 110\ndb 103\ndb 32\ndb 116\ndb 105\ndb 110\ndb 121\ndb 32\ndb 105\ndb 110\ndb 116\ndb 101\ndb 114\ndb 101\ndb 115\ndb 116\ndb 32\ndb 114\ndb 97\ndb 116\ndb 101\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL628 label byte\ndb 9\ndb 84\ndb 104\ndb 105\ndb 115\ndb 32\ndb 109\ndb 117\ndb 99\ndb 104\ndb 32\ndb 101\ndb 114\ndb 114\ndb 111\ndb 114\ndb 32\ndb 109\ndb 97\ndb 121\ndb 32\ndb 115\ndb 112\ndb 111\ndb 105\ndb 108\ndb 32\ndb 102\ndb 105\ndb 110\ndb 97\ndb 110\ndb 99\ndb 105\ndb 97\ndb 108\ndb 10\ndb 0\nalign 1\nL627 label byte\ndb 9\ndb 100\ndb 105\ndb 102\ndb 102\ndb 101\ndb 114\ndb 115\ndb 32\ndb 102\ndb 114\ndb 111\ndb 109\ndb 32\ndb 99\ndb 111\ndb 114\ndb 114\ndb 101\ndb 99\ndb 116\ndb 32\ndb 118\ndb 97\ndb 108\ndb 117\ndb 101\ndb 32\ndb 98\ndb 121\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL626 label byte\ndb 9\ndb 40\ndb 49\ndb 32\ndb 43\ndb 32\ndb 40\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 41\ndb 32\ndb 94\ndb 32\ndb 40\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 41\ndb 59\ndb 10\ndb 0\nalign 1\nL625 label byte\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 32\ndb 102\ndb 111\ndb 114\ndb 10\ndb 0\nalign 1\nL624 label byte\ndb 67\ndb 97\ndb 108\ndb 99\ndb 117\ndb 108\ndb 97\ndb 116\ndb 101\ndb 100\ndb 0\nalign 1\nL617 label byte\ndb 84\ndb 101\ndb 115\ndb 116\ndb 105\ndb 110\ndb 103\ndb 32\ndb 88\ndb 94\ndb 40\ndb 40\ndb 88\ndb 32\ndb 43\ndb 32\ndb 49\ndb 41\ndb 32\ndb 47\ndb 32\ndb 40\ndb 88\ndb 32\ndb 45\ndb 32\ndb 49\ndb 41\ndb 41\ndb 32\ndb 118\ndb 115\ndb 46\ndb 32\ndb 101\ndb 120\ndb 112\ndb 40\ndb 50\ndb 41\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 32\ndb 97\ndb 115\ndb 32\ndb 88\ndb 32\ndb 45\ndb 62\ndb 32\ndb 49\ndb 46\ndb 10\ndb 0\nalign 1\nL613 label byte\ndb 84\ndb 104\ndb 105\ndb 115\ndb 32\ndb 99\ndb 111\ndb 109\ndb 112\ndb 117\ndb 116\ndb 101\ndb 100\ndb 32\ndb 118\ndb 97\ndb 108\ndb 117\ndb 101\ndb 32\ndb 105\ndb 115\ndb 32\ndb 79\ndb 46\ndb 75\ndb 46\ndb 10\ndb 0\nalign 1\nL610 label byte\ndb 32\ndb 32\ndb 32\ndb 116\ndb 104\ndb 114\ndb 101\ndb 115\ndb 104\ndb 111\ndb 108\ndb 100\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL609 label byte\ndb 116\ndb 104\ndb 105\ndb 115\ndb 32\ndb 105\ndb 115\ndb 32\ndb 110\ndb 111\ndb 116\ndb 32\ndb 98\ndb 101\ndb 116\ndb 119\ndb 101\ndb 101\ndb 110\ndb 32\ndb 48\ndb 32\ndb 97\ndb 110\ndb 100\ndb 32\ndb 117\ndb 110\ndb 100\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 10\ndb 0\nalign 1\nL605 label byte\ndb 97\ndb 99\ndb 116\ndb 117\ndb 97\ndb 108\ndb 108\ndb 121\ndb 32\ndb 99\ndb 97\ndb 108\ndb 99\ndb 117\ndb 108\ndb 97\ndb 116\ndb 105\ndb 110\ndb 103\ndb 32\ndb 121\ndb 105\ndb 101\ndb 108\ndb 100\ndb 115\ndb 58\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL604 label byte\ndb 115\ndb 104\ndb 111\ndb 117\ndb 108\ndb 100\ndb 32\ndb 97\ndb 102\ndb 102\ndb 108\ndb 105\ndb 99\ndb 116\ndb 32\ndb 116\ndb 104\ndb 101\ndb 32\ndb 101\ndb 120\ndb 112\ndb 114\ndb 101\ndb 115\ndb 115\ndb 105\ndb 111\ndb 110\ndb 10\ndb 9\ndb 40\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 41\ndb 32\ndb 94\ndb 32\ndb 40\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 41\ndb 59\ndb 10\ndb 0\nalign 1\nL603 label byte\ndb 85\ndb 102\ndb 84\ndb 104\ndb 111\ndb 108\ndb 100\ndb 32\ndb 61\ndb 32\ndb 40\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 41\ndb 32\ndb 94\ndb 32\ndb 40\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 41\ndb 10\ndb 111\ndb 110\ndb 108\ndb 121\ndb 32\ndb 117\ndb 110\ndb 100\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 32\ndb 0\nalign 1\nL602 label byte\ndb 83\ndb 105\ndb 110\ndb 99\ndb 101\ndb 32\ndb 117\ndb 110\ndb 100\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 32\ndb 111\ndb 99\ndb 99\ndb 117\ndb 114\ndb 115\ndb 32\ndb 98\ndb 101\ndb 108\ndb 111\ndb 119\ndb 32\ndb 116\ndb 104\ndb 101\ndb 32\ndb 116\ndb 104\ndb 114\ndb 101\ndb 115\ndb 104\ndb 111\ndb 108\ndb 100\ndb 10\ndb 0\nalign 1\nL601 label byte\ndb 82\ndb 97\ndb 110\ndb 103\ndb 101\ndb 32\ndb 105\ndb 115\ndb 32\ndb 116\ndb 111\ndb 111\ndb 32\ndb 110\ndb 97\ndb 114\ndb 114\ndb 111\ndb 119\ndb 59\ndb 32\ndb 85\ndb 49\ndb 94\ndb 37\ndb 100\ndb 32\ndb 85\ndb 110\ndb 100\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL596 label byte\ndb 109\ndb 101\ndb 114\ndb 101\ndb 108\ndb 121\ndb 32\ndb 114\ndb 111\ndb 117\ndb 110\ndb 100\ndb 111\ndb 102\ndb 102\ndb 46\ndb 10\ndb 0\nalign 1\nL595 label byte\ndb 99\ndb 97\ndb 108\ndb 99\ndb 117\ndb 108\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 109\ndb 97\ndb 121\ndb 32\ndb 115\ndb 117\ndb 102\ndb 102\ndb 101\ndb 114\ndb 32\ndb 108\ndb 97\ndb 114\ndb 103\ndb 101\ndb 114\ndb 32\ndb 82\ndb 101\ndb 108\ndb 97\ndb 116\ndb 105\ndb 118\ndb 101\ndb 32\ndb 101\ndb 114\ndb 114\ndb 111\ndb 114\ndb 32\ndb 116\ndb 104\ndb 97\ndb 110\ndb 32\ndb 0\nalign 1\nL594 label byte\ndb 32\ndb 98\ndb 101\ndb 108\ndb 111\ndb 119\ndb 32\ndb 119\ndb 104\ndb 105\ndb 99\ndb 104\ndb 0\nalign 1\nL593 label byte\ndb 84\ndb 104\ndb 101\ndb 32\ndb 85\ndb 110\ndb 100\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 32\ndb 116\ndb 104\ndb 114\ndb 101\ndb 115\ndb 104\ndb 111\ndb 108\ndb 100\ndb 32\ndb 105\ndb 115\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 44\ndb 32\ndb 37\ndb 115\ndb 10\ndb 0\nalign 1\nL592 label byte\ndb 88\ndb 32\ndb 47\ndb 32\ndb 90\ndb 32\ndb 61\ndb 32\ndb 49\ndb 32\ndb 43\ndb 32\ndb 37\ndb 103\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL591 label byte\ndb 88\ndb 32\ndb 47\ndb 32\ndb 90\ndb 32\ndb 102\ndb 97\ndb 105\ndb 108\ndb 115\ndb 33\ndb 10\ndb 0\nalign 1\nL588 label byte\ndb 101\ndb 110\ndb 99\ndb 111\ndb 117\ndb 110\ndb 116\ndb 101\ndb 114\ndb 32\ndb 68\ndb 105\ndb 118\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 32\ndb 98\ndb 121\ndb 32\ndb 90\ndb 101\ndb 114\ndb 111\ndb 32\ndb 97\ndb 108\ndb 116\ndb 104\ndb 111\ndb 117\ndb 103\ndb 104\ndb 32\ndb 97\ndb 99\ndb 116\ndb 117\ndb 97\ndb 108\ndb 108\ndb 121\ndb 10\ndb 0\nalign 1\nL587 label byte\ndb 32\ndb 32\ndb 46\ndb 46\ndb 46\ndb 32\ndb 40\ndb 102\ndb 40\ndb 88\ndb 41\ndb 32\ndb 45\ndb 32\ndb 102\ndb 40\ndb 90\ndb 41\ndb 41\ndb 32\ndb 47\ndb 32\ndb 40\ndb 88\ndb 32\ndb 45\ndb 32\ndb 90\ndb 41\ndb 32\ndb 46\ndb 46\ndb 46\ndb 10\ndb 0\nalign 1\nL586 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 105\ndb 102\ndb 32\ndb 40\ndb 88\ndb 32\ndb 61\ndb 61\ndb 32\ndb 90\ndb 41\ndb 32\ndb 32\ndb 46\ndb 46\ndb 46\ndb 32\ndb 32\ndb 101\ndb 108\ndb 115\ndb 101\ndb 0\nalign 1\nL585 label byte\ndb 99\ndb 111\ndb 110\ndb 102\ndb 117\ndb 115\ndb 105\ndb 111\ndb 110\ndb 32\ndb 119\ndb 104\ndb 101\ndb 110\ndb 32\ndb 105\ndb 110\ndb 110\ndb 111\ndb 99\ndb 101\ndb 110\ndb 116\ndb 32\ndb 115\ndb 116\ndb 97\ndb 116\ndb 101\ndb 109\ndb 101\ndb 110\ndb 116\ndb 115\ndb 32\ndb 108\ndb 105\ndb 107\ndb 101\ndb 10\ndb 0\nalign 1\nL584 label byte\ndb 116\ndb 104\ndb 105\ndb 115\ndb 32\ndb 105\ndb 115\ndb 32\ndb 97\ndb 32\ndb 83\ndb 69\ndb 82\ndb 73\ndb 79\ndb 85\ndb 83\ndb 32\ndb 68\ndb 69\ndb 70\ndb 69\ndb 67\ndb 84\ndb 10\ndb 116\ndb 104\ndb 97\ndb 116\ndb 32\ndb 99\ndb 97\ndb 117\ndb 115\ndb 101\ndb 115\ndb 32\ndb 0\nalign 1\nL583 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 83\ndb 104\ndb 111\ndb 117\ndb 108\ndb 100\ndb 32\ndb 116\ndb 104\ndb 105\ndb 115\ndb 32\ndb 78\ndb 79\ndb 84\ndb 32\ndb 115\ndb 105\ndb 103\ndb 110\ndb 97\ndb 108\ndb 32\ndb 85\ndb 110\ndb 100\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 44\ndb 32\ndb 0\nalign 1\nL582 label byte\ndb 121\ndb 101\ndb 116\ndb 32\ndb 88\ndb 32\ndb 45\ndb 32\ndb 90\ndb 32\ndb 121\ndb 105\ndb 101\ndb 108\ndb 100\ndb 115\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL581 label byte\ndb 88\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 10\ndb 9\ndb 105\ndb 115\ndb 32\ndb 110\ndb 111\ndb 116\ndb 32\ndb 101\ndb 113\ndb 117\ndb 97\ndb 108\ndb 32\ndb 116\ndb 111\ndb 32\ndb 90\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL576 label byte\ndb 85\ndb 110\ndb 100\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 32\ndb 47\ndb 32\ndb 85\ndb 102\ndb 84\ndb 104\ndb 111\ndb 108\ndb 100\ndb 32\ndb 102\ndb 97\ndb 105\ndb 108\ndb 101\ndb 100\ndb 33\ndb 10\ndb 0\nalign 1\nL566 label byte\ndb 40\ndb 114\ndb 111\ndb 117\ndb 110\ndb 100\ndb 111\ndb 102\ndb 102\ndb 32\ndb 105\ndb 110\ndb 32\ndb 85\ndb 102\ndb 84\ndb 104\ndb 111\ndb 108\ndb 100\ndb 41\ndb 32\ndb 60\ndb 32\ndb 69\ndb 48\ndb 46\ndb 10\ndb 0\nalign 1\nL565 label byte\ndb 85\ndb 110\ndb 100\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 32\ndb 105\ndb 115\ndb 32\ndb 103\ndb 114\ndb 97\ndb 100\ndb 117\ndb 97\ndb 108\ndb 59\ndb 32\ndb 105\ndb 116\ndb 32\ndb 105\ndb 110\ndb 99\ndb 117\ndb 114\ndb 115\ndb 32\ndb 65\ndb 98\ndb 115\ndb 111\ndb 108\ndb 117\ndb 116\ndb 101\ndb 32\ndb 69\ndb 114\ndb 114\ndb 111\ndb 114\ndb 32\ndb 61\ndb 10\ndb 0\nalign 1\nL560 label byte\ndb 124\ndb 81\ndb 32\ndb 45\ndb 32\ndb 89\ndb 124\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL559 label byte\ndb 112\ndb 114\ndb 105\ndb 110\ndb 116\ndb 32\ndb 111\ndb 117\ndb 116\ndb 32\ndb 97\ndb 115\ndb 32\ndb 81\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 44\ndb 32\ndb 89\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL558 label byte\ndb 81\ndb 32\ndb 61\ndb 61\ndb 32\ndb 89\ndb 32\ndb 119\ndb 104\ndb 105\ndb 108\ndb 101\ndb 32\ndb 100\ndb 101\ndb 110\ndb 121\ndb 105\ndb 110\ndb 103\ndb 32\ndb 116\ndb 104\ndb 97\ndb 116\ndb 32\ndb 124\ndb 81\ndb 32\ndb 45\ndb 32\ndb 89\ndb 124\ndb 32\ndb 61\ndb 61\ndb 32\ndb 48\ndb 59\ndb 32\ndb 116\ndb 104\ndb 101\ndb 115\ndb 101\ndb 32\ndb 118\ndb 97\ndb 108\ndb 117\ndb 101\ndb 115\ndb 10\ndb 0\nalign 1\nL557 label byte\ndb 85\ndb 110\ndb 100\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 32\ndb 99\ndb 111\ndb 110\ndb 102\ndb 117\ndb 115\ndb 101\ndb 115\ndb 32\ndb 67\ndb 111\ndb 109\ndb 112\ndb 97\ndb 114\ndb 105\ndb 115\ndb 111\ndb 110\ndb 44\ndb 32\ndb 119\ndb 104\ndb 105\ndb 99\ndb 104\ndb 32\ndb 97\ndb 108\ndb 108\ndb 101\ndb 103\ndb 101\ndb 115\ndb 32\ndb 116\ndb 104\ndb 97\ndb 116\ndb 10\ndb 0\nalign 1\nL555 label byte\ndb 32\ndb 111\ndb 114\ndb 32\ndb 101\ndb 108\ndb 115\ndb 101\ndb 32\ndb 109\ndb 117\ndb 108\ndb 116\ndb 105\ndb 112\ndb 108\ndb 105\ndb 99\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 103\ndb 101\ndb 116\ndb 115\ndb 32\ndb 116\ndb 111\ndb 111\ndb 32\ndb 109\ndb 97\ndb 110\ndb 121\ndb 32\ndb 108\ndb 97\ndb 115\ndb 116\ndb 32\ndb 100\ndb 105\ndb 103\ndb 105\ndb 116\ndb 115\ndb 32\ndb 119\ndb 114\ndb 111\ndb 110\ndb 103\ndb 46\ndb 10\ndb 0\nalign 1\nL554 label byte\ndb 32\ndb 99\ndb 111\ndb 109\ndb 105\ndb 110\ndb 103\ndb 32\ndb 100\ndb 111\ndb 119\ndb 110\ndb 32\ndb 102\ndb 114\ndb 111\ndb 109\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 10\ndb 0\nalign 1\nL553 label byte\ndb 97\ndb 112\ndb 112\ndb 114\ndb 111\ndb 97\ndb 99\ndb 104\ndb 32\ndb 97\ndb 32\ndb 116\ndb 104\ndb 114\ndb 101\ndb 115\ndb 104\ndb 111\ndb 108\ndb 100\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 49\ndb 55\ndb 101\ndb 10\ndb 0\nalign 1\nL552 label byte\ndb 69\ndb 105\ndb 116\ndb 104\ndb 101\ndb 114\ndb 32\ndb 97\ndb 99\ndb 99\ndb 117\ndb 114\ndb 97\ndb 99\ndb 121\ndb 32\ndb 100\ndb 101\ndb 116\ndb 101\ndb 114\ndb 105\ndb 111\ndb 114\ndb 97\ndb 116\ndb 101\ndb 115\ndb 32\ndb 97\ndb 115\ndb 32\ndb 110\ndb 117\ndb 109\ndb 98\ndb 101\ndb 114\ndb 115\ndb 10\ndb 0\nalign 1\nL540 label byte\ndb 83\ndb 109\ndb 97\ndb 108\ndb 108\ndb 101\ndb 115\ndb 116\ndb 32\ndb 115\ndb 116\ndb 114\ndb 105\ndb 99\ndb 116\ndb 108\ndb 121\ndb 32\ndb 112\ndb 111\ndb 115\ndb 105\ndb 116\ndb 105\ndb 118\ndb 101\ndb 32\ndb 110\ndb 117\ndb 109\ndb 98\ndb 101\ndb 114\ndb 32\ndb 102\ndb 111\ndb 117\ndb 110\ndb 100\ndb 32\ndb 105\ndb 115\ndb 32\ndb 69\ndb 48\ndb 32\ndb 61\ndb 32\ndb 37\ndb 103\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL539 label byte\ndb 32\ndb 116\ndb 104\ndb 114\ndb 101\ndb 115\ndb 104\ndb 111\ndb 108\ndb 100\ndb 32\ndb 116\ndb 104\ndb 97\ndb 110\ndb 32\ndb 112\ndb 114\ndb 111\ndb 100\ndb 117\ndb 99\ndb 116\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL538 label byte\ndb 68\ndb 105\ndb 102\ndb 102\ndb 101\ndb 114\ndb 101\ndb 110\ndb 99\ndb 101\ndb 32\ndb 117\ndb 110\ndb 100\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 115\ndb 32\ndb 97\ndb 116\ndb 32\ndb 97\ndb 32\ndb 104\ndb 105\ndb 103\ndb 104\ndb 101\ndb 114\ndb 0\nalign 1\nL535 label byte\ndb 32\ndb 116\ndb 104\ndb 114\ndb 101\ndb 115\ndb 104\ndb 111\ndb 108\ndb 100\ndb 32\ndb 116\ndb 104\ndb 97\ndb 110\ndb 32\ndb 100\ndb 105\ndb 102\ndb 102\ndb 101\ndb 114\ndb 101\ndb 110\ndb 99\ndb 101\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL534 label byte\ndb 80\ndb 114\ndb 111\ndb 100\ndb 117\ndb 99\ndb 116\ndb 115\ndb 32\ndb 117\ndb 110\ndb 100\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 32\ndb 97\ndb 116\ndb 32\ndb 97\ndb 32\ndb 104\ndb 105\ndb 103\ndb 104\ndb 101\ndb 114\ndb 0\nalign 1\nL527 label byte\ndb 118\ndb 97\ndb 108\ndb 117\ndb 101\ndb 32\ndb 80\ndb 115\ndb 101\ndb 117\ndb 100\ndb 111\ndb 90\ndb 101\ndb 114\ndb 111\ndb 32\ndb 116\ndb 104\ndb 97\ndb 116\ndb 32\ndb 112\ndb 114\ndb 105\ndb 110\ndb 116\ndb 115\ndb 32\ndb 111\ndb 117\ndb 116\ndb 32\ndb 97\ndb 115\ndb 32\ndb 37\ndb 103\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL526 label byte\ndb 85\ndb 110\ndb 100\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 32\ndb 99\ndb 97\ndb 110\ndb 32\ndb 115\ndb 116\ndb 105\ndb 99\ndb 107\ndb 32\ndb 97\ndb 116\ndb 32\ndb 97\ndb 110\ndb 32\ndb 97\ndb 108\ndb 108\ndb 101\ndb 103\ndb 101\ndb 100\ndb 108\ndb 121\ndb 32\ndb 112\ndb 111\ndb 115\ndb 105\ndb 116\ndb 105\ndb 118\ndb 101\ndb 10\ndb 0\nalign 1\nL525 label byte\ndb 112\ndb 111\ndb 115\ndb 105\ndb 116\ndb 105\ndb 118\ndb 101\ndb 44\ndb 32\ndb 105\ndb 115\ndb 110\ndb 39\ndb 116\ndb 59\ndb 32\ndb 105\ndb 116\ndb 32\ndb 112\ndb 114\ndb 105\ndb 110\ndb 116\ndb 115\ndb 32\ndb 111\ndb 117\ndb 116\ndb 32\ndb 97\ndb 115\ndb 32\ndb 32\ndb 37\ndb 103\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL524 label byte\ndb 66\ndb 117\ndb 116\ndb 32\ndb 45\ndb 80\ndb 115\ndb 101\ndb 117\ndb 100\ndb 111\ndb 90\ndb 101\ndb 114\ndb 111\ndb 44\ndb 32\ndb 119\ndb 104\ndb 105\ndb 99\ndb 104\ndb 32\ndb 115\ndb 104\ndb 111\ndb 117\ndb 108\ndb 100\ndb 32\ndb 98\ndb 101\ndb 10\ndb 0\nalign 1\nL521 label byte\ndb 80\ndb 115\ndb 101\ndb 117\ndb 100\ndb 111\ndb 90\ndb 101\ndb 114\ndb 111\ndb 32\ndb 116\ndb 104\ndb 97\ndb 116\ndb 32\ndb 112\ndb 114\ndb 105\ndb 110\ndb 116\ndb 115\ndb 32\ndb 111\ndb 117\ndb 116\ndb 32\ndb 97\ndb 115\ndb 58\ndb 32\ndb 37\ndb 103\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL520 label byte\ndb 97\ndb 108\ndb 108\ndb 101\ndb 103\ndb 101\ndb 100\ndb 108\ndb 121\ndb 32\ndb 110\ndb 101\ndb 103\ndb 97\ndb 116\ndb 105\ndb 118\ndb 101\ndb 32\ndb 118\ndb 97\ndb 108\ndb 117\ndb 101\ndb 10\ndb 0\nalign 1\nL519 label byte\ndb 80\ndb 111\ndb 115\ndb 105\ndb 116\ndb 105\ndb 118\ndb 101\ndb 32\ndb 101\ndb 120\ndb 112\ndb 114\ndb 101\ndb 115\ndb 115\ndb 105\ndb 111\ndb 110\ndb 115\ndb 32\ndb 99\ndb 97\ndb 110\ndb 32\ndb 117\ndb 110\ndb 100\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 32\ndb 116\ndb 111\ndb 32\ndb 97\ndb 110\ndb 10\ndb 0\nalign 1\nL506 label byte\ndb 109\ndb 117\ndb 108\ndb 116\ndb 105\ndb 112\ndb 108\ndb 105\ndb 99\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 103\ndb 101\ndb 116\ndb 115\ndb 32\ndb 116\ndb 111\ndb 111\ndb 32\ndb 109\ndb 97\ndb 110\ndb 121\ndb 32\ndb 108\ndb 97\ndb 115\ndb 116\ndb 32\ndb 100\ndb 105\ndb 103\ndb 105\ndb 116\ndb 115\ndb 32\ndb 119\ndb 114\ndb 111\ndb 110\ndb 103\ndb 46\ndb 10\ndb 0\nalign 1\nL482 label byte\ndb 83\ndb 101\ndb 101\ndb 107\ndb 105\ndb 110\ndb 103\ndb 32\ndb 85\ndb 110\ndb 100\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 32\ndb 116\ndb 104\ndb 114\ndb 101\ndb 115\ndb 104\ndb 111\ndb 108\ndb 100\ndb 115\ndb 32\ndb 85\ndb 102\ndb 84\ndb 104\ndb 111\ndb 108\ndb 100\ndb 32\ndb 97\ndb 110\ndb 100\ndb 32\ndb 69\ndb 48\ndb 46\ndb 10\ndb 0\nalign 1\nL479 label byte\ndb 46\ndb 46\ndb 46\ndb 32\ndb 110\ndb 111\ndb 32\ndb 100\ndb 105\ndb 115\ndb 99\ndb 114\ndb 101\ndb 112\ndb 97\ndb 110\ndb 99\ndb 105\ndb 115\ndb 32\ndb 102\ndb 111\ndb 117\ndb 110\ndb 100\ndb 46\ndb 10\ndb 0\nalign 1\nL476 label byte\ndb 9\ndb 105\ndb 110\ndb 118\ndb 111\ndb 108\ndb 118\ndb 105\ndb 110\ndb 103\ndb 32\ndb 105\ndb 110\ndb 116\ndb 101\ndb 114\ndb 101\ndb 115\ndb 116\ndb 32\ndb 114\ndb 97\ndb 116\ndb 101\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL475 label byte\ndb 69\ndb 114\ndb 114\ndb 111\ndb 114\ndb 115\ndb 32\ndb 108\ndb 105\ndb 107\ndb 101\ndb 32\ndb 116\ndb 104\ndb 105\ndb 115\ndb 32\ndb 109\ndb 97\ndb 121\ndb 32\ndb 105\ndb 110\ndb 118\ndb 97\ndb 108\ndb 105\ndb 100\ndb 97\ndb 116\ndb 101\ndb 32\ndb 102\ndb 105\ndb 110\ndb 97\ndb 110\ndb 99\ndb 105\ndb 97\ndb 108\ndb 32\ndb 99\ndb 97\ndb 108\ndb 99\ndb 117\ndb 108\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 115\ndb 10\ndb 0\nalign 1\nL454 label byte\ndb 84\ndb 101\ndb 115\ndb 116\ndb 105\ndb 110\ndb 103\ndb 32\ndb 112\ndb 111\ndb 119\ndb 101\ndb 114\ndb 115\ndb 32\ndb 90\ndb 94\ndb 105\ndb 32\ndb 102\ndb 111\ndb 114\ndb 32\ndb 115\ndb 109\ndb 97\ndb 108\ndb 108\ndb 32\ndb 73\ndb 110\ndb 116\ndb 101\ndb 103\ndb 101\ndb 114\ndb 115\ndb 32\ndb 90\ndb 32\ndb 97\ndb 110\ndb 100\ndb 32\ndb 105\ndb 46\ndb 10\ndb 0\nalign 1\nL451 label byte\ndb 115\ndb 113\ndb 114\ndb 116\ndb 32\ndb 103\ndb 101\ndb 116\ndb 115\ndb 32\ndb 116\ndb 111\ndb 111\ndb 32\ndb 109\ndb 97\ndb 110\ndb 121\ndb 32\ndb 108\ndb 97\ndb 115\ndb 116\ndb 32\ndb 100\ndb 105\ndb 103\ndb 105\ndb 116\ndb 115\ndb 32\ndb 119\ndb 114\ndb 111\ndb 110\ndb 103\ndb 0\nalign 1\nL449 label byte\ndb 116\ndb 111\ndb 32\ndb 37\ndb 46\ndb 55\ndb 101\ndb 32\ndb 117\ndb 108\ndb 112\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL448 label byte\ndb 79\ndb 98\ndb 115\ndb 101\ndb 114\ndb 118\ndb 101\ndb 100\ndb 32\ndb 101\ndb 114\ndb 114\ndb 111\ndb 114\ndb 115\ndb 32\ndb 114\ndb 117\ndb 110\ndb 32\ndb 102\ndb 114\ndb 111\ndb 109\ndb 32\ndb 37\ndb 46\ndb 55\ndb 101\ndb 32\ndb 0\nalign 1\nL447 label byte\ndb 83\ndb 113\ndb 117\ndb 97\ndb 114\ndb 101\ndb 32\ndb 114\ndb 111\ndb 111\ndb 116\ndb 32\ndb 105\ndb 115\ndb 32\ndb 110\ndb 101\ndb 105\ndb 116\ndb 104\ndb 101\ndb 114\ndb 32\ndb 99\ndb 104\ndb 111\ndb 112\ndb 112\ndb 101\ndb 100\ndb 32\ndb 110\ndb 111\ndb 114\ndb 32\ndb 99\ndb 111\ndb 114\ndb 114\ndb 101\ndb 99\ndb 116\ndb 108\ndb 121\ndb 32\ndb 114\ndb 111\ndb 117\ndb 110\ndb 100\ndb 101\ndb 100\ndb 46\ndb 10\ndb 0\nalign 1\nL444 label byte\ndb 83\ndb 113\ndb 117\ndb 97\ndb 114\ndb 101\ndb 32\ndb 114\ndb 111\ndb 111\ndb 116\ndb 32\ndb 97\ndb 112\ndb 112\ndb 101\ndb 97\ndb 114\ndb 115\ndb 32\ndb 116\ndb 111\ndb 32\ndb 98\ndb 101\ndb 32\ndb 99\ndb 104\ndb 111\ndb 112\ndb 112\ndb 101\ndb 100\ndb 46\ndb 10\ndb 0\nalign 1\nL439 label byte\ndb 83\ndb 113\ndb 117\ndb 97\ndb 114\ndb 101\ndb 32\ndb 114\ndb 111\ndb 111\ndb 116\ndb 32\ndb 97\ndb 112\ndb 112\ndb 101\ndb 97\ndb 114\ndb 115\ndb 32\ndb 116\ndb 111\ndb 32\ndb 98\ndb 101\ndb 32\ndb 99\ndb 111\ndb 114\ndb 114\ndb 101\ndb 99\ndb 116\ndb 108\ndb 121\ndb 32\ndb 114\ndb 111\ndb 117\ndb 110\ndb 100\ndb 101\ndb 100\ndb 46\ndb 10\ndb 0\nalign 1\nL434 label byte\ndb 32\ndb 102\ndb 97\ndb 105\ndb 108\ndb 115\ndb 32\ndb 116\ndb 101\ndb 115\ndb 116\ndb 32\ndb 119\ndb 104\ndb 101\ndb 116\ndb 104\ndb 101\ndb 114\ndb 32\ndb 115\ndb 113\ndb 114\ndb 116\ndb 32\ndb 114\ndb 111\ndb 117\ndb 110\ndb 100\ndb 115\ndb 32\ndb 111\ndb 114\ndb 32\ndb 99\ndb 104\ndb 111\ndb 112\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL433 label byte\ndb 82\ndb 97\ndb 100\ndb 105\ndb 120\ndb 94\ndb 80\ndb 114\ndb 101\ndb 99\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 55\ndb 101\ndb 10\ndb 0\nalign 1\nL432 label byte\ndb 65\ndb 110\ndb 111\ndb 109\ndb 97\ndb 108\ndb 111\ndb 117\ndb 115\ndb 32\ndb 97\ndb 114\ndb 105\ndb 116\ndb 104\ndb 109\ndb 101\ndb 116\ndb 105\ndb 99\ndb 32\ndb 119\ndb 105\ndb 116\ndb 104\ndb 32\ndb 73\ndb 110\ndb 116\ndb 101\ndb 103\ndb 101\ndb 114\ndb 32\ndb 60\ndb 32\ndb 0\nalign 1\nL392 label byte\ndb 84\ndb 101\ndb 115\ndb 116\ndb 105\ndb 110\ndb 103\ndb 32\ndb 119\ndb 104\ndb 101\ndb 116\ndb 104\ndb 101\ndb 114\ndb 32\ndb 115\ndb 113\ndb 114\ndb 116\ndb 32\ndb 105\ndb 115\ndb 32\ndb 114\ndb 111\ndb 117\ndb 110\ndb 100\ndb 101\ndb 100\ndb 32\ndb 111\ndb 114\ndb 32\ndb 99\ndb 104\ndb 111\ndb 112\ndb 112\ndb 101\ndb 100\ndb 46\ndb 10\ndb 0\nalign 1\nL370 label byte\ndb 115\ndb 113\ndb 114\ndb 116\ndb 40\ndb 88\ndb 41\ndb 32\ndb 105\ndb 115\ndb 32\ndb 110\ndb 111\ndb 110\ndb 45\ndb 109\ndb 111\ndb 110\ndb 111\ndb 116\ndb 111\ndb 110\ndb 105\ndb 99\ndb 32\ndb 102\ndb 111\ndb 114\ndb 32\ndb 88\ndb 32\ndb 110\ndb 101\ndb 97\ndb 114\ndb 32\ndb 37\ndb 46\ndb 55\ndb 101\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL369 label byte\ndb 115\ndb 113\ndb 114\ndb 116\ndb 32\ndb 104\ndb 97\ndb 115\ndb 32\ndb 112\ndb 97\ndb 115\ndb 115\ndb 101\ndb 100\ndb 32\ndb 97\ndb 32\ndb 116\ndb 101\ndb 115\ndb 116\ndb 32\ndb 102\ndb 111\ndb 114\ndb 32\ndb 77\ndb 111\ndb 110\ndb 111\ndb 116\ndb 111\ndb 110\ndb 105\ndb 99\ndb 105\ndb 116\ndb 121\ndb 46\ndb 10\ndb 0\nalign 1\nL352 label byte\ndb 84\ndb 101\ndb 115\ndb 116\ndb 32\ndb 102\ndb 111\ndb 114\ndb 32\ndb 115\ndb 113\ndb 114\ndb 116\ndb 32\ndb 109\ndb 111\ndb 110\ndb 111\ndb 116\ndb 111\ndb 110\ndb 105\ndb 99\ndb 105\ndb 116\ndb 121\ndb 46\ndb 10\ndb 0\nalign 1\nL341 label byte\ndb 84\ndb 101\ndb 115\ndb 116\ndb 105\ndb 110\ndb 103\ndb 32\ndb 105\ndb 102\ndb 32\ndb 115\ndb 113\ndb 114\ndb 116\ndb 40\ndb 88\ndb 32\ndb 42\ndb 32\ndb 88\ndb 41\ndb 32\ndb 61\ndb 61\ndb 32\ndb 88\ndb 32\ndb 102\ndb 111\ndb 114\ndb 32\ndb 37\ndb 100\ndb 32\ndb 73\ndb 110\ndb 116\ndb 101\ndb 103\ndb 101\ndb 114\ndb 115\ndb 32\ndb 88\ndb 46\ndb 10\ndb 0\nalign 1\nL336 label byte\ndb 83\ndb 113\ndb 117\ndb 97\ndb 114\ndb 101\ndb 32\ndb 114\ndb 111\ndb 111\ndb 116\ndb 32\ndb 111\ndb 102\ndb 32\ndb 48\ndb 46\ndb 48\ndb 44\ndb 32\ndb 45\ndb 48\ndb 46\ndb 48\ndb 32\ndb 111\ndb 114\ndb 32\ndb 49\ndb 46\ndb 48\ndb 32\ndb 119\ndb 114\ndb 111\ndb 110\ndb 103\ndb 0\nalign 1\nL334 label byte\ndb 10\ndb 82\ndb 117\ndb 110\ndb 110\ndb 105\ndb 110\ndb 103\ndb 32\ndb 116\ndb 101\ndb 115\ndb 116\ndb 32\ndb 111\ndb 102\ndb 32\ndb 115\ndb 113\ndb 117\ndb 97\ndb 114\ndb 101\ndb 32\ndb 114\ndb 111\ndb 111\ndb 116\ndb 40\ndb 120\ndb 41\ndb 46\ndb 10\ndb 0\nalign 1\nL333 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 78\ndb 111\ndb 32\ndb 102\ndb 97\ndb 105\ndb 108\ndb 117\ndb 114\ndb 101\ndb 115\ndb 32\ndb 102\ndb 111\ndb 117\ndb 110\ndb 100\ndb 32\ndb 105\ndb 110\ndb 32\ndb 37\ndb 100\ndb 32\ndb 105\ndb 110\ndb 116\ndb 101\ndb 103\ndb 101\ndb 114\ndb 32\ndb 112\ndb 97\ndb 105\ndb 114\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL332 label byte\ndb 88\ndb 32\ndb 42\ndb 32\ndb 89\ndb 32\ndb 61\ndb 61\ndb 32\ndb 89\ndb 32\ndb 42\ndb 32\ndb 88\ndb 32\ndb 116\ndb 114\ndb 105\ndb 97\ndb 108\ndb 32\ndb 102\ndb 97\ndb 105\ndb 108\ndb 115\ndb 46\ndb 10\ndb 0\nalign 4\nL323 label byte\ndd 00H\ndd 040080000H\nalign 1\nL322 label byte\ndb 84\ndb 101\ndb 115\ndb 116\ndb 105\ndb 110\ndb 103\ndb 32\ndb 111\ndb 110\ndb 32\ndb 37\ndb 100\ndb 32\ndb 114\ndb 97\ndb 110\ndb 100\ndb 111\ndb 109\ndb 32\ndb 112\ndb 97\ndb 105\ndb 114\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL321 label byte\ndb 68\ndb 111\ndb 101\ndb 115\ndb 32\ndb 77\ndb 117\ndb 108\ndb 116\ndb 105\ndb 112\ndb 108\ndb 105\ndb 99\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 99\ndb 111\ndb 109\ndb 109\ndb 117\ndb 116\ndb 101\ndb 63\ndb 32\ndb 32\ndb 0\nalign 1\nL318 label byte\ndb 108\ndb 97\ndb 99\ndb 107\ndb 40\ndb 115\ndb 41\ndb 32\ndb 111\ndb 102\ndb 32\ndb 103\ndb 117\ndb 97\ndb 114\ndb 100\ndb 32\ndb 100\ndb 105\ndb 103\ndb 105\ndb 116\ndb 115\ndb 32\ndb 111\ndb 114\ndb 32\ndb 102\ndb 97\ndb 105\ndb 108\ndb 117\ndb 114\ndb 101\ndb 40\ndb 115\ndb 41\ndb 32\ndb 116\ndb 111\ndb 32\ndb 99\ndb 111\ndb 114\ndb 114\ndb 101\ndb 99\ndb 116\ndb 108\ndb 121\ndb 32\ndb 114\ndb 111\ndb 117\ndb 110\ndb 100\ndb 32\ndb 111\ndb 114\ndb 32\ndb 99\ndb 104\ndb 111\ndb 112\ndb 10\ndb 40\ndb 110\ndb 111\ndb 116\ndb 101\ndb 100\ndb 32\ndb 97\ndb 98\ndb 111\ndb 118\ndb 101\ndb 41\ndb 32\ndb 99\ndb 111\ndb 117\ndb 110\ndb 116\ndb 32\ndb 97\ndb 115\ndb 32\ndb 111\ndb 110\ndb 101\ndb 32\ndb 102\ndb 108\ndb 97\ndb 119\ndb 32\ndb 105\ndb 110\ndb 32\ndb 116\ndb 104\ndb 101\ndb 32\ndb 102\ndb 105\ndb 110\ndb 97\ndb 108\ndb 32\ndb 116\ndb 97\ndb 108\ndb 108\ndb 121\ndb 32\ndb 98\ndb 101\ndb 108\ndb 111\ndb 119\ndb 0\nalign 1\nL316 label byte\ndb 83\ndb 116\ndb 105\ndb 99\ndb 107\ndb 121\ndb 32\ndb 98\ndb 105\ndb 116\ndb 32\ndb 117\ndb 115\ndb 101\ndb 100\ndb 32\ndb 105\ndb 110\ndb 99\ndb 111\ndb 114\ndb 114\ndb 101\ndb 99\ndb 116\ndb 108\ndb 121\ndb 32\ndb 111\ndb 114\ndb 32\ndb 110\ndb 111\ndb 116\ndb 32\ndb 97\ndb 116\ndb 32\ndb 97\ndb 108\ndb 108\ndb 46\ndb 10\ndb 0\nalign 1\nL315 label byte\ndb 83\ndb 116\ndb 105\ndb 99\ndb 107\ndb 121\ndb 32\ndb 98\ndb 105\ndb 116\ndb 32\ndb 97\ndb 112\ndb 112\ndb 97\ndb 114\ndb 101\ndb 110\ndb 116\ndb 108\ndb 121\ndb 32\ndb 117\ndb 115\ndb 101\ndb 100\ndb 32\ndb 99\ndb 111\ndb 114\ndb 114\ndb 101\ndb 99\ndb 116\ndb 108\ndb 121\ndb 46\ndb 10\ndb 0\nalign 1\nL298 label byte\ndb 67\ndb 104\ndb 101\ndb 99\ndb 107\ndb 105\ndb 110\ndb 103\ndb 32\ndb 102\ndb 111\ndb 114\ndb 32\ndb 115\ndb 116\ndb 105\ndb 99\ndb 107\ndb 121\ndb 32\ndb 98\ndb 105\ndb 116\ndb 46\ndb 10\ndb 0\nalign 1\nL295 label byte\ndb 40\ndb 88\ndb 32\ndb 45\ndb 32\ndb 89\ndb 41\ndb 32\ndb 43\ndb 32\ndb 40\ndb 89\ndb 32\ndb 45\ndb 32\ndb 88\ndb 41\ndb 32\ndb 105\ndb 115\ndb 32\ndb 110\ndb 111\ndb 110\ndb 32\ndb 122\ndb 101\ndb 114\ndb 111\ndb 33\ndb 10\ndb 0\nalign 1\nL292 label byte\ndb 65\ndb 100\ndb 100\ndb 105\ndb 116\ndb 105\ndb 111\ndb 110\ndb 47\ndb 83\ndb 117\ndb 98\ndb 116\ndb 114\ndb 97\ndb 99\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 110\ndb 101\ndb 105\ndb 116\ndb 104\ndb 101\ndb 114\ndb 32\ndb 114\ndb 111\ndb 117\ndb 110\ndb 100\ndb 115\ndb 32\ndb 110\ndb 111\ndb 114\ndb 32\ndb 99\ndb 104\ndb 111\ndb 112\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL291 label byte\ndb 65\ndb 100\ndb 100\ndb 47\ndb 83\ndb 117\ndb 98\ndb 116\ndb 114\ndb 97\ndb 99\ndb 116\ndb 0\nalign 1\nL288 label byte\ndb 65\ndb 100\ndb 100\ndb 105\ndb 116\ndb 105\ndb 111\ndb 110\ndb 47\ndb 83\ndb 117\ndb 98\ndb 116\ndb 114\ndb 97\ndb 99\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 97\ndb 112\ndb 112\ndb 101\ndb 97\ndb 114\ndb 115\ndb 32\ndb 116\ndb 111\ndb 32\ndb 114\ndb 111\ndb 117\ndb 110\ndb 100\ndb 32\ndb 99\ndb 111\ndb 114\ndb 114\ndb 101\ndb 99\ndb 116\ndb 108\ndb 121\ndb 46\ndb 10\ndb 0\nalign 1\nL281 label byte\ndb 65\ndb 100\ndb 100\ndb 47\ndb 83\ndb 117\ndb 98\ndb 116\ndb 114\ndb 97\ndb 99\ndb 116\ndb 32\ndb 97\ndb 112\ndb 112\ndb 101\ndb 97\ndb 114\ndb 115\ndb 32\ndb 116\ndb 111\ndb 32\ndb 98\ndb 101\ndb 32\ndb 99\ndb 104\ndb 111\ndb 112\ndb 112\ndb 101\ndb 100\ndb 46\ndb 10\ndb 0\nalign 1\nL276 label byte\ndb 73\ndb 110\ndb 99\ndb 111\ndb 109\ndb 112\ndb 108\ndb 101\ndb 116\ndb 101\ndb 32\ndb 99\ndb 97\ndb 114\ndb 114\ndb 121\ndb 45\ndb 112\ndb 114\ndb 111\ndb 112\ndb 97\ndb 103\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 105\ndb 110\ndb 32\ndb 65\ndb 100\ndb 100\ndb 105\ndb 116\ndb 105\ndb 111\ndb 110\ndb 0\nalign 1\nL272 label byte\ndb 82\ndb 97\ndb 100\ndb 105\ndb 120\ndb 32\ndb 42\ndb 32\ndb 40\ndb 32\ndb 49\ndb 32\ndb 47\ndb 32\ndb 82\ndb 97\ndb 100\ndb 105\ndb 120\ndb 32\ndb 41\ndb 32\ndb 100\ndb 105\ndb 102\ndb 102\ndb 101\ndb 114\ndb 115\ndb 32\ndb 102\ndb 114\ndb 111\ndb 109\ndb 32\ndb 49\ndb 0\nalign 1\nL270 label byte\ndb 47\ndb 32\ndb 105\ndb 115\ndb 32\ndb 110\ndb 101\ndb 105\ndb 116\ndb 104\ndb 101\ndb 114\ndb 32\ndb 99\ndb 104\ndb 111\ndb 112\ndb 112\ndb 101\ndb 100\ndb 32\ndb 110\ndb 111\ndb 114\ndb 32\ndb 99\ndb 111\ndb 114\ndb 114\ndb 101\ndb 99\ndb 116\ndb 108\ndb 121\ndb 32\ndb 114\ndb 111\ndb 117\ndb 110\ndb 100\ndb 101\ndb 100\ndb 46\ndb 10\ndb 0\nalign 1\nL267 label byte\ndb 68\ndb 105\ndb 118\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 32\ndb 97\ndb 112\ndb 112\ndb 101\ndb 97\ndb 114\ndb 115\ndb 32\ndb 116\ndb 111\ndb 32\ndb 99\ndb 104\ndb 111\ndb 112\ndb 46\ndb 10\ndb 0\nalign 1\nL264 label byte\ndb 68\ndb 105\ndb 118\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 0\nalign 1\nL261 label byte\ndb 68\ndb 105\ndb 118\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 32\ndb 97\ndb 112\ndb 112\ndb 101\ndb 97\ndb 114\ndb 115\ndb 32\ndb 116\ndb 111\ndb 32\ndb 114\ndb 111\ndb 117\ndb 110\ndb 100\ndb 32\ndb 99\ndb 111\ndb 114\ndb 114\ndb 101\ndb 99\ndb 116\ndb 108\ndb 121\ndb 46\ndb 10\ndb 0\nalign 1\nL256 label byte\ndb 77\ndb 117\ndb 108\ndb 116\ndb 105\ndb 112\ndb 108\ndb 105\ndb 99\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 0\nalign 1\nL253 label byte\ndb 42\ndb 32\ndb 105\ndb 115\ndb 32\ndb 110\ndb 101\ndb 105\ndb 116\ndb 104\ndb 101\ndb 114\ndb 32\ndb 99\ndb 104\ndb 111\ndb 112\ndb 112\ndb 101\ndb 100\ndb 32\ndb 110\ndb 111\ndb 114\ndb 32\ndb 99\ndb 111\ndb 114\ndb 114\ndb 101\ndb 99\ndb 116\ndb 108\ndb 121\ndb 32\ndb 114\ndb 111\ndb 117\ndb 110\ndb 100\ndb 101\ndb 100\ndb 46\ndb 10\ndb 0\nalign 1\nL252 label byte\ndb 77\ndb 117\ndb 108\ndb 116\ndb 105\ndb 112\ndb 108\ndb 105\ndb 99\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 97\ndb 112\ndb 112\ndb 101\ndb 97\ndb 114\ndb 115\ndb 32\ndb 116\ndb 111\ndb 32\ndb 99\ndb 104\ndb 111\ndb 112\ndb 46\ndb 10\ndb 0\nalign 1\nL249 label byte\ndb 77\ndb 117\ndb 108\ndb 116\ndb 105\ndb 112\ndb 108\ndb 105\ndb 99\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 97\ndb 112\ndb 112\ndb 101\ndb 97\ndb 114\ndb 115\ndb 32\ndb 116\ndb 111\ndb 32\ndb 114\ndb 111\ndb 117\ndb 110\ndb 100\ndb 32\ndb 99\ndb 111\ndb 114\ndb 114\ndb 101\ndb 99\ndb 116\ndb 108\ndb 121\ndb 46\ndb 10\ndb 0\nalign 1\nL239 label byte\ndb 88\ndb 32\ndb 42\ndb 32\ndb 40\ndb 49\ndb 47\ndb 88\ndb 41\ndb 32\ndb 100\ndb 105\ndb 102\ndb 102\ndb 101\ndb 114\ndb 115\ndb 32\ndb 102\ndb 114\ndb 111\ndb 109\ndb 32\ndb 49\ndb 0\nalign 1\nL220 label byte\ndb 67\ndb 104\ndb 101\ndb 99\ndb 107\ndb 105\ndb 110\ndb 103\ndb 32\ndb 114\ndb 111\ndb 117\ndb 110\ndb 100\ndb 105\ndb 110\ndb 103\ndb 32\ndb 111\ndb 110\ndb 32\ndb 109\ndb 117\ndb 108\ndb 116\ndb 105\ndb 112\ndb 108\ndb 121\ndb 44\ndb 32\ndb 100\ndb 105\ndb 118\ndb 105\ndb 100\ndb 101\ndb 32\ndb 97\ndb 110\ndb 100\ndb 32\ndb 97\ndb 100\ndb 100\ndb 47\ndb 115\ndb 117\ndb 98\ndb 116\ndb 114\ndb 97\ndb 99\ndb 116\ndb 46\ndb 10\ndb 0\nalign 1\nL219 label byte\ndb 32\ndb 32\ndb 32\ndb 32\ndb 32\ndb 42\ndb 44\ndb 32\ndb 47\ndb 44\ndb 32\ndb 97\ndb 110\ndb 100\ndb 32\ndb 45\ndb 32\ndb 97\ndb 112\ndb 112\ndb 101\ndb 97\ndb 114\ndb 32\ndb 116\ndb 111\ndb 32\ndb 104\ndb 97\ndb 118\ndb 101\ndb 32\ndb 103\ndb 117\ndb 97\ndb 114\ndb 100\ndb 32\ndb 100\ndb 105\ndb 103\ndb 105\ndb 116\ndb 115\ndb 44\ndb 32\ndb 97\ndb 115\ndb 32\ndb 116\ndb 104\ndb 101\ndb 121\ndb 32\ndb 115\ndb 104\ndb 111\ndb 117\ndb 108\ndb 100\ndb 46\ndb 10\ndb 0\nalign 1\nL216 label byte\ndb 32\ndb 32\ndb 46\ndb 46\ndb 46\ndb 32\ndb 32\ndb 105\ndb 102\ndb 32\ndb 40\ndb 88\ndb 32\ndb 61\ndb 61\ndb 32\ndb 49\ndb 46\ndb 48\ndb 41\ndb 32\ndb 123\ndb 46\ndb 46\ndb 46\ndb 46\ndb 46\ndb 125\ndb 32\ndb 101\ndb 108\ndb 115\ndb 101\ndb 32\ndb 123\ndb 46\ndb 46\ndb 46\ndb 47\ndb 40\ndb 88\ndb 45\ndb 49\ndb 46\ndb 48\ndb 41\ndb 46\ndb 46\ndb 46\ndb 125\ndb 10\ndb 0\nalign 1\nL215 label byte\ndb 32\ndb 32\ndb 115\ndb 117\ndb 99\ndb 104\ndb 32\ndb 112\ndb 114\ndb 101\ndb 99\ndb 97\ndb 117\ndb 116\ndb 105\ndb 111\ndb 110\ndb 115\ndb 32\ndb 97\ndb 103\ndb 97\ndb 105\ndb 110\ndb 115\ndb 116\ndb 32\ndb 100\ndb 105\ndb 118\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 32\ndb 98\ndb 121\ndb 32\ndb 122\ndb 101\ndb 114\ndb 111\ndb 32\ndb 97\ndb 115\ndb 10\ndb 0\nalign 1\nL214 label byte\ndb 32\ndb 32\ndb 115\ndb 117\ndb 98\ndb 116\ndb 114\ndb 97\ndb 99\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 121\ndb 105\ndb 101\ndb 108\ndb 100\ndb 115\ndb 32\ndb 32\ndb 40\ndb 49\ndb 45\ndb 85\ndb 49\ndb 41\ndb 32\ndb 45\ndb 32\ndb 49\ndb 32\ndb 61\ndb 32\ndb 48\ndb 32\ndb 44\ndb 32\ndb 116\ndb 104\ndb 101\ndb 114\ndb 101\ndb 98\ndb 121\ndb 32\ndb 118\ndb 105\ndb 116\ndb 105\ndb 97\ndb 116\ndb 105\ndb 110\ndb 103\ndb 10\ndb 0\nalign 1\nL213 label byte\ndb 99\ndb 111\ndb 109\ndb 112\ndb 97\ndb 114\ndb 105\ndb 115\ndb 111\ndb 110\ndb 32\ndb 97\ndb 108\ndb 108\ndb 101\ndb 103\ndb 101\ndb 115\ndb 32\ndb 32\ndb 40\ndb 49\ndb 45\ndb 85\ndb 49\ndb 41\ndb 32\ndb 60\ndb 32\ndb 49\ndb 32\ndb 32\ndb 97\ndb 108\ndb 116\ndb 104\ndb 111\ndb 117\ndb 103\ndb 104\ndb 10\ndb 0\nalign 1\nL210 label byte\ndb 45\ndb 32\ndb 108\ndb 97\ndb 99\ndb 107\ndb 115\ndb 32\ndb 71\ndb 117\ndb 97\ndb 114\ndb 100\ndb 32\ndb 68\ndb 105\ndb 103\ndb 105\ndb 116\ndb 44\ndb 32\ndb 115\ndb 111\ndb 32\ndb 99\ndb 97\ndb 110\ndb 99\ndb 101\ndb 108\ndb 108\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 105\ndb 115\ndb 32\ndb 111\ndb 98\ndb 115\ndb 99\ndb 117\ndb 114\ndb 101\ndb 100\ndb 0\nalign 1\nL205 label byte\ndb 42\ndb 32\ndb 97\ndb 110\ndb 100\ndb 47\ndb 111\ndb 114\ndb 32\ndb 47\ndb 32\ndb 103\ndb 101\ndb 116\ndb 115\ndb 32\ndb 116\ndb 111\ndb 111\ndb 32\ndb 109\ndb 97\ndb 110\ndb 121\ndb 32\ndb 108\ndb 97\ndb 115\ndb 116\ndb 32\ndb 100\ndb 105\ndb 103\ndb 105\ndb 116\ndb 115\ndb 32\ndb 119\ndb 114\ndb 111\ndb 110\ndb 103\ndb 0\nalign 1\nL201 label byte\ndb 67\ndb 111\ndb 109\ndb 112\ndb 117\ndb 116\ndb 101\ndb 100\ndb 32\ndb 118\ndb 97\ndb 108\ndb 117\ndb 101\ndb 32\ndb 111\ndb 102\ndb 32\ndb 49\ndb 47\ndb 49\ndb 46\ndb 48\ndb 48\ndb 48\ndb 46\ndb 46\ndb 49\ndb 32\ndb 62\ndb 61\ndb 32\ndb 49\ndb 0\nalign 1\nL199 label byte\ndb 68\ndb 105\ndb 118\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 32\ndb 108\ndb 97\ndb 99\ndb 107\ndb 115\ndb 32\ndb 97\ndb 32\ndb 71\ndb 117\ndb 97\ndb 114\ndb 100\ndb 32\ndb 68\ndb 105\ndb 103\ndb 105\ndb 116\ndb 44\ndb 32\ndb 115\ndb 111\ndb 32\ndb 88\ndb 47\ndb 49\ndb 32\ndb 33\ndb 61\ndb 32\ndb 88\ndb 0\nalign 1\nL194 label byte\ndb 68\ndb 105\ndb 118\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 32\ndb 108\ndb 97\ndb 99\ndb 107\ndb 115\ndb 32\ndb 97\ndb 32\ndb 71\ndb 117\ndb 97\ndb 114\ndb 100\ndb 32\ndb 68\ndb 105\ndb 103\ndb 105\ndb 116\ndb 44\ndb 32\ndb 115\ndb 111\ndb 32\ndb 101\ndb 114\ndb 114\ndb 111\ndb 114\ndb 32\ndb 99\ndb 97\ndb 110\ndb 32\ndb 101\ndb 120\ndb 99\ndb 101\ndb 101\ndb 100\ndb 32\ndb 49\ndb 32\ndb 117\ndb 108\ndb 112\ndb 10\ndb 111\ndb 114\ndb 32\ndb 32\ndb 49\ndb 47\ndb 51\ndb 32\ndb 32\ndb 97\ndb 110\ndb 100\ndb 32\ndb 32\ndb 51\ndb 47\ndb 57\ndb 32\ndb 32\ndb 97\ndb 110\ndb 100\ndb 32\ndb 32\ndb 57\ndb 47\ndb 50\ndb 55\ndb 32\ndb 109\ndb 97\ndb 121\ndb 32\ndb 100\ndb 105\ndb 115\ndb 97\ndb 103\ndb 114\ndb 101\ndb 101\ndb 0\nalign 1\nL190 label byte\ndb 42\ndb 32\ndb 103\ndb 101\ndb 116\ndb 115\ndb 32\ndb 116\ndb 111\ndb 111\ndb 32\ndb 109\ndb 97\ndb 110\ndb 121\ndb 32\ndb 102\ndb 105\ndb 110\ndb 97\ndb 108\ndb 32\ndb 100\ndb 105\ndb 103\ndb 105\ndb 116\ndb 115\ndb 32\ndb 119\ndb 114\ndb 111\ndb 110\ndb 103\ndb 46\ndb 10\ndb 0\nalign 1\nL188 label byte\ndb 42\ndb 32\ndb 108\ndb 97\ndb 99\ndb 107\ndb 115\ndb 32\ndb 97\ndb 32\ndb 71\ndb 117\ndb 97\ndb 114\ndb 100\ndb 32\ndb 68\ndb 105\ndb 103\ndb 105\ndb 116\ndb 44\ndb 32\ndb 115\ndb 111\ndb 32\ndb 49\ndb 42\ndb 88\ndb 32\ndb 33\ndb 61\ndb 32\ndb 88\ndb 0\nalign 1\nL185 label byte\ndb 10\ndb 67\ndb 104\ndb 101\ndb 99\ndb 107\ndb 105\ndb 110\ndb 103\ndb 32\ndb 102\ndb 111\ndb 114\ndb 32\ndb 103\ndb 117\ndb 97\ndb 114\ndb 100\ndb 32\ndb 100\ndb 105\ndb 103\ndb 105\ndb 116\ndb 32\ndb 105\ndb 110\ndb 32\ndb 42\ndb 44\ndb 32\ndb 47\ndb 44\ndb 32\ndb 97\ndb 110\ndb 100\ndb 32\ndb 45\ndb 46\ndb 10\ndb 0\nalign 1\nL184 label byte\ndb 83\ndb 117\ndb 98\ndb 116\ndb 114\ndb 97\ndb 99\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 97\ndb 112\ndb 112\ndb 101\ndb 97\ndb 114\ndb 115\ndb 32\ndb 116\ndb 111\ndb 32\ndb 98\ndb 101\ndb 32\ndb 110\ndb 111\ndb 114\ndb 109\ndb 97\ndb 108\ndb 105\ndb 122\ndb 101\ndb 100\ndb 44\ndb 32\ndb 97\ndb 115\ndb 32\ndb 105\ndb 116\ndb 32\ndb 115\ndb 104\ndb 111\ndb 117\ndb 108\ndb 100\ndb 32\ndb 98\ndb 101\ndb 46\ndb 0\nalign 1\nL179 label byte\ndb 83\ndb 117\ndb 98\ndb 116\ndb 114\ndb 97\ndb 99\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 105\ndb 115\ndb 32\ndb 110\ndb 111\ndb 116\ndb 32\ndb 110\ndb 111\ndb 114\ndb 109\ndb 97\ndb 108\ndb 105\ndb 122\ndb 101\ndb 100\ndb 32\ndb 88\ndb 61\ndb 89\ndb 44\ndb 88\ndb 43\ndb 90\ndb 32\ndb 33\ndb 61\ndb 32\ndb 89\ndb 43\ndb 90\ndb 33\ndb 0\nalign 1\nL175 label byte\ndb 114\ndb 111\ndb 117\ndb 103\ndb 104\ndb 108\ndb 121\ndb 32\ndb 37\ndb 103\ndb 32\ndb 101\ndb 120\ndb 116\ndb 114\ndb 97\ndb 32\ndb 115\ndb 105\ndb 103\ndb 110\ndb 105\ndb 102\ndb 105\ndb 99\ndb 97\ndb 110\ndb 116\ndb 32\ndb 100\ndb 101\ndb 99\ndb 105\ndb 109\ndb 97\ndb 108\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL174 label byte\ndb 112\ndb 114\ndb 101\ndb 99\ndb 105\ndb 115\ndb 101\ndb 108\ndb 121\ndb 32\ndb 119\ndb 105\ndb 116\ndb 104\ndb 32\ndb 97\ndb 98\ndb 111\ndb 117\ndb 116\ndb 32\ndb 37\ndb 103\ndb 32\ndb 101\ndb 120\ndb 116\ndb 114\ndb 97\ndb 32\ndb 66\ndb 45\ndb 100\ndb 105\ndb 103\ndb 105\ndb 116\ndb 115\ndb 44\ndb 32\ndb 105\ndb 46\ndb 101\ndb 46\ndb 10\ndb 0\nalign 1\nL173 label byte\ndb 83\ndb 111\ndb 109\ndb 101\ndb 32\ndb 115\ndb 117\ndb 98\ndb 101\ndb 120\ndb 112\ndb 114\ndb 101\ndb 115\ndb 115\ndb 105\ndb 111\ndb 110\ndb 115\ndb 32\ndb 97\ndb 112\ndb 112\ndb 101\ndb 97\ndb 114\ndb 32\ndb 116\ndb 111\ndb 32\ndb 98\ndb 101\ndb 32\ndb 99\ndb 97\ndb 108\ndb 99\ndb 117\ndb 108\ndb 97\ndb 116\ndb 101\ndb 100\ndb 32\ndb 101\ndb 120\ndb 116\ndb 114\ndb 97\ndb 10\ndb 0\nalign 1\nL167 label byte\ndb 111\ndb 102\ndb 32\ndb 97\ndb 110\ndb 10\ndb 101\ndb 120\ndb 116\ndb 114\ndb 97\ndb 45\ndb 112\ndb 114\ndb 101\ndb 99\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 0\nalign 1\nL166 label byte\ndb 90\ndb 49\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 55\ndb 101\ndb 44\ndb 32\ndb 111\ndb 114\ndb 32\ndb 90\ndb 50\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 55\ndb 101\ndb 32\ndb 0\nalign 1\nL165 label byte\ndb 44\ndb 32\ndb 111\ndb 114\ndb 32\ndb 101\ndb 120\ndb 97\ndb 99\ndb 116\ndb 32\ndb 114\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 97\ndb 108\ndb 32\ndb 97\ndb 114\ndb 105\ndb 116\ndb 104\ndb 109\ndb 101\ndb 116\ndb 105\ndb 99\ndb 32\ndb 97\ndb 32\ndb 114\ndb 101\ndb 115\ndb 117\ndb 108\ndb 116\ndb 10\ndb 0\nalign 1\nL164 label byte\ndb 66\ndb 101\ndb 99\ndb 97\ndb 117\ndb 115\ndb 101\ndb 32\ndb 111\ndb 102\ndb 32\ndb 117\ndb 110\ndb 117\ndb 115\ndb 117\ndb 97\ndb 108\ndb 32\ndb 82\ndb 97\ndb 100\ndb 105\ndb 120\ndb 32\ndb 61\ndb 32\ndb 37\ndb 102\ndb 0\nalign 1\nL160 label byte\ndb 9\ndb 85\ndb 50\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 55\ndb 101\ndb 44\ndb 32\ndb 90\ndb 50\ndb 32\ndb 45\ndb 32\ndb 85\ndb 50\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 55\ndb 101\ndb 10\ndb 0\nalign 1\nL159 label byte\ndb 9\ndb 85\ndb 49\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 55\ndb 101\ndb 44\ndb 32\ndb 90\ndb 49\ndb 32\ndb 45\ndb 32\ndb 85\ndb 49\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 55\ndb 101\ndb 10\ndb 0\nalign 1\nL158 label byte\ndb 80\ndb 114\ndb 101\ndb 99\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 0\nalign 1\nL157 label byte\ndb 0\nalign 1\nL150 label byte\ndb 84\ndb 104\ndb 97\ndb 116\ndb 32\ndb 102\ndb 101\ndb 97\ndb 116\ndb 117\ndb 114\ndb 101\ndb 32\ndb 105\ndb 115\ndb 32\ndb 110\ndb 111\ndb 116\ndb 32\ndb 116\ndb 101\ndb 115\ndb 116\ndb 101\ndb 100\ndb 32\ndb 102\ndb 117\ndb 114\ndb 116\ndb 104\ndb 101\ndb 114\ndb 32\ndb 98\ndb 121\ndb 32\ndb 116\ndb 104\ndb 105\ndb 115\ndb 32\ndb 112\ndb 114\ndb 111\ndb 103\ndb 114\ndb 97\ndb 109\ndb 46\ndb 10\ndb 0\nalign 1\nL145 label byte\ndb 80\ndb 111\ndb 115\ndb 115\ndb 105\ndb 98\ndb 108\ndb 121\ndb 32\ndb 115\ndb 111\ndb 109\ndb 101\ndb 32\ndb 112\ndb 97\ndb 114\ndb 116\ndb 32\ndb 111\ndb 102\ndb 32\ndb 116\ndb 104\ndb 105\ndb 115\ndb 0\nalign 1\nL144 label byte\ndb 98\ndb 121\ndb 32\ndb 101\ndb 120\ndb 116\ndb 114\ndb 97\ndb 45\ndb 112\ndb 114\ndb 101\ndb 99\ndb 105\ndb 115\ndb 101\ndb 32\ndb 101\ndb 118\ndb 97\ndb 108\ndb 117\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 111\ndb 102\ndb 32\ndb 97\ndb 114\ndb 105\ndb 116\ndb 104\ndb 109\ndb 101\ndb 116\ndb 105\ndb 99\ndb 32\ndb 115\ndb 117\ndb 98\ndb 101\ndb 120\ndb 112\ndb 114\ndb 101\ndb 115\ndb 115\ndb 105\ndb 111\ndb 110\ndb 115\ndb 46\ndb 10\ndb 0\nalign 1\nL143 label byte\ndb 97\ndb 114\ndb 101\ndb 32\ndb 115\ndb 121\ndb 109\ndb 112\ndb 116\ndb 111\ndb 109\ndb 115\ndb 32\ndb 111\ndb 102\ndb 32\ndb 105\ndb 110\ndb 99\ndb 111\ndb 110\ndb 115\ndb 105\ndb 115\ndb 116\ndb 101\ndb 110\ndb 99\ndb 105\ndb 101\ndb 115\ndb 32\ndb 105\ndb 110\ndb 116\ndb 114\ndb 111\ndb 100\ndb 117\ndb 99\ndb 101\ndb 100\ndb 10\ndb 0\nalign 1\nL142 label byte\ndb 114\ndb 101\ndb 115\ndb 112\ndb 101\ndb 99\ndb 116\ndb 105\ndb 118\ndb 101\ndb 108\ndb 121\ndb 32\ndb 32\ndb 37\ndb 46\ndb 55\ndb 101\ndb 44\ndb 32\ndb 32\ndb 37\ndb 46\ndb 55\ndb 101\ndb 44\ndb 32\ndb 32\ndb 37\ndb 46\ndb 55\ndb 101\ndb 44\ndb 10\ndb 0\nalign 1\nL141 label byte\ndb 68\ndb 105\ndb 115\ndb 97\ndb 103\ndb 114\ndb 101\ndb 101\ndb 109\ndb 101\ndb 110\ndb 116\ndb 115\ndb 32\ndb 97\ndb 109\ndb 111\ndb 110\ndb 103\ndb 32\ndb 116\ndb 104\ndb 101\ndb 32\ndb 118\ndb 97\ndb 108\ndb 117\ndb 101\ndb 115\ndb 32\ndb 88\ndb 49\ndb 44\ndb 32\ndb 89\ndb 49\ndb 44\ndb 32\ndb 90\ndb 49\ndb 44\ndb 10\ndb 0\nalign 1\nL119 label byte\ndb 80\ndb 114\ndb 101\ndb 99\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 32\ndb 119\ndb 111\ndb 114\ndb 115\ndb 101\ndb 32\ndb 116\ndb 104\ndb 97\ndb 110\ndb 32\ndb 53\ndb 32\ndb 100\ndb 101\ndb 99\ndb 105\ndb 109\ndb 97\ndb 108\ndb 32\ndb 102\ndb 105\ndb 103\ndb 117\ndb 114\ndb 101\ndb 115\ndb 32\ndb 32\ndb 0\nalign 1\nL117 label byte\ndb 84\ndb 104\ndb 101\ndb 32\ndb 110\ndb 117\ndb 109\ndb 98\ndb 101\ndb 114\ndb 32\ndb 111\ndb 102\ndb 32\ndb 115\ndb 105\ndb 103\ndb 110\ndb 105\ndb 102\ndb 105\ndb 99\ndb 97\ndb 110\ndb 116\ndb 32\ndb 100\ndb 105\ndb 103\ndb 105\ndb 116\ndb 115\ndb 32\ndb 111\ndb 102\ndb 32\ndb 116\ndb 104\ndb 101\ndb 32\ndb 82\ndb 97\ndb 100\ndb 105\ndb 120\ndb 32\ndb 105\ndb 115\ndb 32\ndb 37\ndb 102\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL116 label byte\ndb 108\ndb 111\ndb 103\ndb 97\ndb 114\ndb 105\ndb 116\ndb 104\ndb 109\ndb 105\ndb 99\ndb 32\ndb 101\ndb 110\ndb 99\ndb 111\ndb 100\ndb 105\ndb 110\ndb 103\ndb 32\ndb 104\ndb 97\ndb 115\ndb 32\ndb 112\ndb 114\ndb 101\ndb 99\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 32\ndb 99\ndb 104\ndb 97\ndb 114\ndb 97\ndb 99\ndb 116\ndb 101\ndb 114\ndb 105\ndb 122\ndb 101\ndb 100\ndb 32\ndb 115\ndb 111\ndb 108\ndb 101\ndb 108\ndb 121\ndb 32\ndb 98\ndb 121\ndb 32\ndb 85\ndb 49\ndb 46\ndb 10\ndb 0\nalign 1\nL113 label byte\ndb 111\ndb 102\ndb 32\ndb 115\ndb 105\ndb 103\ndb 110\ndb 105\ndb 102\ndb 105\ndb 99\ndb 97\ndb 110\ndb 116\ndb 32\ndb 100\ndb 105\ndb 103\ndb 105\ndb 116\ndb 115\ndb 32\ndb 98\ndb 117\ndb 116\ndb 44\ndb 32\ndb 98\ndb 121\ndb 32\ndb 105\ndb 116\ndb 115\ndb 101\ndb 108\ndb 102\ndb 44\ndb 32\ndb 116\ndb 104\ndb 105\ndb 115\ndb 32\ndb 105\ndb 115\ndb 32\ndb 97\ndb 32\ndb 109\ndb 105\ndb 110\ndb 111\ndb 114\ndb 32\ndb 102\ndb 108\ndb 97\ndb 119\ndb 46\ndb 10\ndb 0\nalign 1\nL112 label byte\ndb 80\ndb 114\ndb 101\ndb 99\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 32\ndb 99\ndb 97\ndb 110\ndb 110\ndb 111\ndb 116\ndb 32\ndb 98\ndb 101\ndb 32\ndb 99\ndb 104\ndb 97\ndb 114\ndb 97\ndb 99\ndb 116\ndb 101\ndb 114\ndb 105\ndb 122\ndb 101\ndb 100\ndb 32\ndb 98\ndb 121\ndb 32\ndb 97\ndb 110\ndb 32\ndb 73\ndb 110\ndb 116\ndb 101\ndb 103\ndb 101\ndb 114\ndb 32\ndb 110\ndb 117\ndb 109\ndb 98\ndb 101\ndb 114\ndb 10\ndb 0\nalign 1\nL99 label byte\ndb 67\ndb 111\ndb 109\ndb 112\ndb 97\ndb 114\ndb 105\ndb 115\ndb 111\ndb 110\ndb 32\ndb 105\ndb 115\ndb 32\ndb 102\ndb 117\ndb 122\ndb 122\ndb 121\ndb 44\ndb 88\ndb 61\ndb 49\ndb 32\ndb 98\ndb 117\ndb 116\ndb 32\ndb 88\ndb 45\ndb 49\ndb 47\ndb 50\ndb 45\ndb 49\ndb 47\ndb 50\ndb 32\ndb 33\ndb 61\ndb 32\ndb 48\ndb 0\nalign 1\nL95 label byte\ndb 40\ndb 49\ndb 45\ndb 85\ndb 49\ndb 41\ndb 45\ndb 49\ndb 47\ndb 50\ndb 32\ndb 60\ndb 32\ndb 49\ndb 47\ndb 50\ndb 32\ndb 105\ndb 115\ndb 32\ndb 70\ndb 65\ndb 76\ndb 83\ndb 69\ndb 44\ndb 32\ndb 112\ndb 114\ndb 111\ndb 103\ndb 46\ndb 32\ndb 102\ndb 97\ndb 105\ndb 108\ndb 115\ndb 63\ndb 0\nalign 4\nL93 label byte\ndd 00H\ndd 040240000H\nalign 1\nL88 label byte\ndb 82\ndb 97\ndb 100\ndb 105\ndb 120\ndb 32\ndb 105\ndb 115\ndb 32\ndb 110\ndb 111\ndb 116\ndb 32\ndb 97\ndb 115\ndb 32\ndb 103\ndb 111\ndb 111\ndb 100\ndb 32\ndb 97\ndb 115\ndb 32\ndb 50\ndb 32\ndb 111\ndb 114\ndb 32\ndb 49\ndb 48\ndb 0\nalign 1\nL84 label byte\ndb 82\ndb 97\ndb 100\ndb 105\ndb 120\ndb 32\ndb 105\ndb 115\ndb 32\ndb 116\ndb 111\ndb 111\ndb 32\ndb 98\ndb 105\ndb 103\ndb 58\ndb 32\ndb 114\ndb 111\ndb 117\ndb 110\ndb 100\ndb 111\ndb 102\ndb 102\ndb 32\ndb 112\ndb 114\ndb 111\ndb 98\ndb 108\ndb 101\ndb 109\ndb 115\ndb 0\nalign 1\nL82 label byte\ndb 77\ndb 89\ndb 83\ndb 84\ndb 69\ndb 82\ndb 89\ndb 58\ndb 32\ndb 114\ndb 101\ndb 99\ndb 97\ndb 108\ndb 99\ndb 117\ndb 108\ndb 97\ndb 116\ndb 101\ndb 100\ndb 32\ndb 82\ndb 97\ndb 100\ndb 105\ndb 120\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 55\ndb 101\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL81 label byte\ndb 82\ndb 97\ndb 100\ndb 105\ndb 120\ndb 32\ndb 99\ndb 111\ndb 110\ndb 102\ndb 105\ndb 114\ndb 109\ndb 101\ndb 100\ndb 46\ndb 10\ndb 0\nalign 4\nL78 label byte\ndd 047ae147bH\ndd 03f847ae1H\nalign 1\nL77 label byte\ndb 103\ndb 101\ndb 116\ndb 115\ndb 32\ndb 98\ndb 101\ndb 116\ndb 116\ndb 101\ndb 114\ndb 32\ndb 99\ndb 108\ndb 111\ndb 115\ndb 101\ndb 115\ndb 116\ndb 32\ndb 114\ndb 101\ndb 108\ndb 97\ndb 116\ndb 105\ndb 118\ndb 101\ndb 32\ndb 115\ndb 101\ndb 112\ndb 97\ndb 114\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 85\ndb 49\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 55\ndb 101\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL76 label byte\ndb 99\ndb 111\ndb 110\ndb 102\ndb 105\ndb 114\ndb 109\ndb 115\ndb 32\ndb 99\ndb 108\ndb 111\ndb 115\ndb 101\ndb 115\ndb 116\ndb 32\ndb 114\ndb 101\ndb 108\ndb 97\ndb 116\ndb 105\ndb 118\ndb 101\ndb 32\ndb 115\ndb 101\ndb 112\ndb 97\ndb 114\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 85\ndb 49\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL61 label byte\ndb 82\ndb 101\ndb 99\ndb 97\ndb 108\ndb 99\ndb 117\ndb 108\ndb 97\ndb 116\ndb 105\ndb 110\ndb 103\ndb 32\ndb 114\ndb 97\ndb 100\ndb 105\ndb 120\ndb 32\ndb 97\ndb 110\ndb 100\ndb 32\ndb 112\ndb 114\ndb 101\ndb 99\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 10\ndb 32\ndb 0\nalign 1\nL60 label byte\ndb 67\ndb 108\ndb 111\ndb 115\ndb 101\ndb 115\ndb 116\ndb 32\ndb 114\ndb 101\ndb 108\ndb 97\ndb 116\ndb 105\ndb 118\ndb 101\ndb 32\ndb 115\ndb 101\ndb 112\ndb 97\ndb 114\ndb 97\ndb 116\ndb 105\ndb 111\ndb 110\ndb 32\ndb 102\ndb 111\ndb 117\ndb 110\ndb 100\ndb 32\ndb 105\ndb 115\ndb 32\ndb 85\ndb 49\ndb 32\ndb 61\ndb 32\ndb 37\ndb 46\ndb 55\ndb 101\ndb 32\ndb 46\ndb 10\ndb 10\ndb 0\nalign 1\nL54 label byte\ndb 82\ndb 97\ndb 100\ndb 105\ndb 120\ndb 32\ndb 61\ndb 32\ndb 37\ndb 102\ndb 32\ndb 46\ndb 10\ndb 0\nalign 1\nL45 label byte\ndb 83\ndb 101\ndb 97\ndb 114\ndb 99\ndb 104\ndb 105\ndb 110\ndb 103\ndb 32\ndb 102\ndb 111\ndb 114\ndb 32\ndb 82\ndb 97\ndb 100\ndb 105\ndb 120\ndb 32\ndb 97\ndb 110\ndb 100\ndb 32\ndb 80\ndb 114\ndb 101\ndb 99\ndb 105\ndb 115\ndb 105\ndb 111\ndb 110\ndb 46\ndb 10\ndb 0\nalign 1\nL44 label byte\ndb 10\ndb 0\nalign 1\nL43 label byte\ndb 45\ndb 49\ndb 44\ndb 32\ndb 48\ndb 44\ndb 32\ndb 49\ndb 47\ndb 50\ndb 44\ndb 32\ndb 49\ndb 44\ndb 32\ndb 50\ndb 44\ndb 32\ndb 51\ndb 44\ndb 32\ndb 52\ndb 44\ndb 32\ndb 53\ndb 44\ndb 32\ndb 57\ndb 44\ndb 32\ndb 50\ndb 55\ndb 44\ndb 32\ndb 51\ndb 50\ndb 32\ndb 38\ndb 32\ndb 50\ndb 52\ndb 48\ndb 32\ndb 97\ndb 114\ndb 101\ndb 32\ndb 79\ndb 46\ndb 75\ndb 46\ndb 10\ndb 0\nalign 1\nL38 label byte\ndb 53\ndb 32\ndb 33\ndb 61\ndb 32\ndb 52\ndb 43\ndb 49\ndb 44\ndb 32\ndb 50\ndb 52\ndb 48\ndb 47\ndb 51\ndb 32\ndb 33\ndb 61\ndb 32\ndb 56\ndb 48\ndb 44\ndb 32\ndb 50\ndb 52\ndb 48\ndb 47\ndb 52\ndb 32\ndb 33\ndb 61\ndb 32\ndb 54\ndb 48\ndb 44\ndb 32\ndb 111\ndb 114\ndb 32\ndb 50\ndb 52\ndb 48\ndb 47\ndb 53\ndb 32\ndb 33\ndb 61\ndb 32\ndb 52\ndb 56\ndb 0\nalign 1\nL34 label byte\ndb 57\ndb 32\ndb 33\ndb 61\ndb 32\ndb 51\ndb 42\ndb 51\ndb 44\ndb 32\ndb 50\ndb 55\ndb 32\ndb 33\ndb 61\ndb 32\ndb 57\ndb 42\ndb 51\ndb 44\ndb 32\ndb 51\ndb 50\ndb 32\ndb 33\ndb 61\ndb 32\ndb 56\ndb 42\ndb 52\ndb 44\ndb 32\ndb 111\ndb 114\ndb 32\ndb 51\ndb 50\ndb 45\ndb 50\ndb 55\ndb 45\ndb 52\ndb 45\ndb 49\ndb 32\ndb 33\ndb 61\ndb 32\ndb 48\ndb 0\nalign 1\nL30 label byte\ndb 49\ndb 47\ndb 50\ndb 32\ndb 43\ndb 32\ndb 40\ndb 45\ndb 49\ndb 41\ndb 32\ndb 43\ndb 32\ndb 49\ndb 47\ndb 50\ndb 32\ndb 33\ndb 61\ndb 32\ndb 48\ndb 0\nalign 1\nL26 label byte\ndb 45\ndb 49\ndb 43\ndb 49\ndb 32\ndb 33\ndb 61\ndb 32\ndb 48\ndb 44\ndb 32\ndb 40\ndb 45\ndb 49\ndb 41\ndb 43\ndb 97\ndb 98\ndb 115\ndb 40\ndb 49\ndb 41\ndb 32\ndb 33\ndb 61\ndb 32\ndb 48\ndb 44\ndb 32\ndb 111\ndb 114\ndb 32\ndb 45\ndb 49\ndb 43\ndb 40\ndb 45\ndb 49\ndb 41\ndb 42\ndb 40\ndb 45\ndb 49\ndb 41\ndb 32\ndb 33\ndb 61\ndb 32\ndb 48\ndb 0\nalign 1\nL22 label byte\ndb 51\ndb 32\ndb 33\ndb 61\ndb 32\ndb 50\ndb 43\ndb 49\ndb 44\ndb 32\ndb 52\ndb 32\ndb 33\ndb 61\ndb 32\ndb 51\ndb 43\ndb 49\ndb 44\ndb 32\ndb 52\ndb 43\ndb 50\ndb 42\ndb 40\ndb 45\ndb 50\ndb 41\ndb 32\ndb 33\ndb 61\ndb 32\ndb 48\ndb 44\ndb 32\ndb 111\ndb 114\ndb 32\ndb 52\ndb 45\ndb 51\ndb 45\ndb 49\ndb 32\ndb 33\ndb 61\ndb 32\ndb 48\ndb 0\nalign 4\nL20 label byte\ndd 0d2f1a9fcH\ndd 03f50624dH\nalign 1\nL19 label byte\ndb 67\ndb 111\ndb 109\ndb 112\ndb 97\ndb 114\ndb 105\ndb 115\ndb 111\ndb 110\ndb 32\ndb 97\ndb 108\ndb 108\ndb 101\ndb 103\ndb 101\ndb 115\ndb 32\ndb 116\ndb 104\ndb 97\ndb 116\ndb 32\ndb 45\ndb 48\ndb 46\ndb 48\ndb 32\ndb 105\ndb 115\ndb 32\ndb 78\ndb 111\ndb 110\ndb 45\ndb 122\ndb 101\ndb 114\ndb 111\ndb 33\ndb 10\ndb 0\nalign 1\nL14 label byte\ndb 48\ndb 43\ndb 48\ndb 32\ndb 33\ndb 61\ndb 32\ndb 48\ndb 44\ndb 32\ndb 49\ndb 45\ndb 49\ndb 32\ndb 33\ndb 61\ndb 32\ndb 48\ndb 44\ndb 32\ndb 49\ndb 32\ndb 60\ndb 61\ndb 32\ndb 48\ndb 44\ndb 32\ndb 111\ndb 114\ndb 32\ndb 49\ndb 43\ndb 49\ndb 32\ndb 33\ndb 61\ndb 32\ndb 50\ndb 0\nalign 1\nL12 label byte\ndb 80\ndb 114\ndb 111\ndb 103\ndb 114\ndb 97\ndb 109\ndb 32\ndb 105\ndb 115\ndb 32\ndb 110\ndb 111\ndb 119\ndb 32\ndb 82\ndb 85\ndb 78\ndb 78\ndb 73\ndb 78\ndb 71\ndb 32\ndb 116\ndb 101\ndb 115\ndb 116\ndb 115\ndb 32\ndb 111\ndb 110\ndb 32\ndb 115\ndb 109\ndb 97\ndb 108\ndb 108\ndb 32\ndb 105\ndb 110\ndb 116\ndb 101\ndb 103\ndb 101\ndb 114\ndb 115\ndb 58\ndb 10\ndb 0\nalign 4\nL8 label byte\ndd 00H\ndd 03ff00000H\nalign 4\nL7 label byte\ndd 00H\ndd 00H\nalign 1\nL2 label byte\ndb 10\ndb 42\ndb 32\ndb 42\ndb 32\ndb 42\ndb 32\ndb 70\ndb 76\ndb 79\ndb 65\ndb 84\ndb 73\ndb 78\ndb 71\ndb 45\ndb 80\ndb 79\ndb 73\ndb 78\ndb 84\ndb 32\ndb 69\ndb 82\ndb 82\ndb 79\ndb 82\ndb 32\ndb 42\ndb 32\ndb 42\ndb 32\ndb 42\ndb 10\ndb 0\n_TEXT ends\nend\n"
  },
  {
    "path": "lcc/x86/win32/tst/sort.1bk",
    "content": "exchange(1,9)\nexchange(3,7)\nexchange(5,6)\nexchange(0,5)\nexchange(0,3)\nexchange(0,0)\nexchange(1,2)\nexchange(6,6)\nexchange(8,9)\nexchange(7,8)\n-51\n-1\n0\n1\n3\n10\n18\n32\n567\n789\n"
  },
  {
    "path": "lcc/x86/win32/tst/sort.2bk",
    "content": "tst/sort.c:23: warning: missing return value\ntst/sort.c:30: warning: missing return value\ntst/sort.c:37: warning: missing return value\ntst/sort.c:41: warning: missing return value\ntst/sort.c:65: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/win32/tst/sort.sbk",
    "content": ".486\n.model flat\nextrn __fltused:near\nextrn __ftol:near\n_DATA segment\npublic _in\nalign 4\n_in label byte\ndd 10\ndd 32\ndd -1\ndd 567\ndd 3\ndd 18\ndd 1\ndd -51\ndd 789\ndd 0\npublic _main\n_DATA ends\n_TEXT segment\n_main:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\npush 10\nlea edi,(_in)\npush edi\ncall _sort\nadd esp,8\nmov dword ptr (-4)[ebp],0\njmp L5\nL2:\nmov edi,dword ptr (-4)[ebp]\nmov edi,dword ptr (_in)[edi*4]\npush edi\ncall _putd\nadd esp,4\npush 10\ncall _putchar\nadd esp,4\nL3:\ninc dword ptr (-4)[ebp]\nL5:\nmov edi,dword ptr (-4)[ebp]\ncmp edi,10\njb L2\nmov eax,0\nL1:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _putd\n_putd:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\ncmp dword ptr (20)[ebp],0\njge L7\npush 45\ncall _putchar\nadd esp,4\nneg dword ptr (20)[ebp]\nL7:\nmov eax,dword ptr (20)[ebp]\nmov edi,10\ncdq\nidiv edi\ncmp eax,0\nje L9\nmov eax,dword ptr (20)[ebp]\nmov edi,10\ncdq\nidiv edi\npush eax\ncall _putd\nadd esp,4\nL9:\nmov eax,dword ptr (20)[ebp]\nmov edi,10\ncdq\nidiv edi\nlea edi,(48)[edx]\npush edi\ncall _putchar\nadd esp,4\nmov eax,0\nL6:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _sort\n_sort:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov edi,dword ptr (24)[ebp]\nsub edi,1\nmov dword ptr (24)[ebp],edi\npush edi\npush 0\nmov edi,dword ptr (20)[ebp]\nmov dword ptr (_xx),edi\npush edi\ncall _quick\nadd esp,12\nmov eax,0\nL11:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _quick\n_quick:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\nmov edi,dword ptr (28)[ebp]\ncmp dword ptr (24)[ebp],edi\njl L13\njmp L12\nL13:\nmov edi,dword ptr (28)[ebp]\npush edi\nmov edi,dword ptr (24)[ebp]\npush edi\nmov edi,dword ptr (20)[ebp]\npush edi\ncall _partition\nadd esp,12\nmov dword ptr (-4)[ebp],eax\nmov edi,dword ptr (-4)[ebp]\nsub edi,1\npush edi\nmov edi,dword ptr (24)[ebp]\npush edi\nmov edi,dword ptr (20)[ebp]\npush edi\ncall _quick\nadd esp,12\nmov edi,dword ptr (28)[ebp]\npush edi\nmov edi,dword ptr (-4)[ebp]\nlea edi,(1)[edi]\npush edi\nmov edi,dword ptr (20)[ebp]\npush edi\ncall _quick\nadd esp,12\nmov eax,0\nL12:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _partition\n_partition:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,8\ninc dword ptr (28)[ebp]\nmov edi,dword ptr (24)[ebp]\nmov dword ptr (-8)[ebp],edi\nmov edi,dword ptr (-8)[ebp]\nmov esi,dword ptr (20)[ebp]\nmov edi,dword ptr [esi][edi*4]\nmov dword ptr (-4)[ebp],edi\njmp L17\nL16:\ninc dword ptr (24)[ebp]\njmp L20\nL19:\ninc dword ptr (24)[ebp]\nL20:\nmov edi,dword ptr (24)[ebp]\nmov esi,dword ptr (20)[ebp]\nmov ebx,dword ptr (-4)[ebp]\ncmp dword ptr [esi][edi*4],ebx\njl L19\ndec dword ptr (28)[ebp]\njmp L23\nL22:\ndec dword ptr (28)[ebp]\nL23:\nmov edi,dword ptr (28)[ebp]\nmov esi,dword ptr (20)[ebp]\nmov ebx,dword ptr (-4)[ebp]\ncmp dword ptr [esi][edi*4],ebx\njg L22\nmov edi,dword ptr (28)[ebp]\ncmp dword ptr (24)[ebp],edi\njge L25\nmov edi,dword ptr (20)[ebp]\nmov esi,dword ptr (28)[ebp]\nlea esi,[edi][esi*4]\npush esi\nmov esi,dword ptr (24)[ebp]\nlea edi,[edi][esi*4]\npush edi\ncall _exchange\nadd esp,8\nL25:\nL17:\nmov edi,dword ptr (28)[ebp]\ncmp dword ptr (24)[ebp],edi\njl L16\nmov edi,dword ptr (20)[ebp]\nmov esi,dword ptr (28)[ebp]\nlea esi,[edi][esi*4]\npush esi\nmov esi,dword ptr (-8)[ebp]\nlea edi,[edi][esi*4]\npush edi\ncall _exchange\nadd esp,8\nmov eax,dword ptr (28)[ebp]\nL15:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _exchange\n_exchange:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\nmov edi,dword ptr (_xx)\nmov esi,4\nmov ebx,dword ptr (24)[ebp]\nsub ebx,edi\nmov eax,ebx\ncdq\nidiv esi\npush eax\nmov ebx,dword ptr (20)[ebp]\nsub ebx,edi\nmov eax,ebx\ncdq\nidiv esi\npush eax\nlea edi,(L28)\npush edi\ncall _printf\nadd esp,12\nmov edi,dword ptr (20)[ebp]\nmov esi,dword ptr [edi]\nmov dword ptr (-4)[ebp],esi\nmov esi,dword ptr (24)[ebp]\nmov esi,dword ptr [esi]\nmov dword ptr [edi],esi\nmov edi,dword ptr (24)[ebp]\nmov esi,dword ptr (-4)[ebp]\nmov dword ptr [edi],esi\nmov eax,0\nL27:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\nextrn _printf:near\n_TEXT segment\n_TEXT ends\nextrn _putchar:near\n_TEXT segment\n_TEXT ends\n_DATA segment\npublic _xx\nalign 4\n_xx label byte\ndb 4 dup (0)\n_DATA ends\n_TEXT segment\nalign 1\nL28 label byte\ndb 101\ndb 120\ndb 99\ndb 104\ndb 97\ndb 110\ndb 103\ndb 101\ndb 40\ndb 37\ndb 100\ndb 44\ndb 37\ndb 100\ndb 41\ndb 10\ndb 0\n_TEXT ends\nend\n"
  },
  {
    "path": "lcc/x86/win32/tst/spill.1bk",
    "content": ""
  },
  {
    "path": "lcc/x86/win32/tst/spill.2bk",
    "content": "tst/spill.c:1: warning: missing return value\ntst/spill.c:3: warning: missing return value\ntst/spill.c:5: warning: missing return value\ntst/spill.c:7: warning: missing return value\ntst/spill.c:9: warning: missing return value\ntst/spill.c:17: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/win32/tst/spill.sbk",
    "content": ".486\n.model flat\nextrn __fltused:near\nextrn __ftol:near\npublic _main\n_TEXT segment\n_main:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov eax,0\nL1:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _f\n_f:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\ncall _f\nadd esp,0\nmov edi,eax\ncall _f\nadd esp,0\nlea edi,[eax][edi]\nmov dword ptr (20)[ebp],edi\nmov eax,0\nL2:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _f2\n_f2:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\ncall _f\nadd esp,0\nmov edi,eax\ncmp dword ptr (20)[ebp],0\nje L5\ncall _f\nadd esp,0\nmov esi,eax\nmov dword ptr (-4)[ebp],esi\njmp L6\nL5:\nmov dword ptr (-4)[ebp],1\nL6:\nmov esi,dword ptr (-4)[ebp]\nlea edi,[esi][edi]\nmov dword ptr (20)[ebp],edi\nmov eax,0\nL3:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _f3\n_f3:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,44\nmov dword ptr (-4)[ebp],0\nmov dword ptr (-8)[ebp],0\nmov dword ptr (-12)[ebp],0\nmov dword ptr (-16)[ebp],0\nmov dword ptr (-20)[ebp],0\nmov dword ptr (-24)[ebp],0\nmov dword ptr (-28)[ebp],0\nmov dword ptr (-32)[ebp],0\nmov dword ptr (-36)[ebp],0\nmov dword ptr (-40)[ebp],0\nmov edi,dword ptr (24)[ebp]\nlea esi,(4)[edi]\nmov dword ptr (24)[ebp],esi\ncmp dword ptr (20)[ebp],0\nje L9\ncall _f\nadd esp,0\nmov esi,eax\nmov dword ptr (-44)[ebp],esi\njmp L10\nL9:\nmov dword ptr (-44)[ebp],0\nL10:\nmov esi,dword ptr (-44)[ebp]\nmov dword ptr [edi],esi\nmov eax,0\nL7:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _f4\n_f4:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,52\nmov dword ptr (-4)[ebp],0\nmov dword ptr (-8)[ebp],0\nmov dword ptr (-12)[ebp],0\nmov dword ptr (-16)[ebp],0\nmov dword ptr (-20)[ebp],0\nmov dword ptr (-24)[ebp],0\nmov edi,dword ptr (_i)\nlea esi,[edi*8]\nfld qword ptr (_a)[esi]\nfstp qword ptr (-36)[ebp]\nfld qword ptr (_b)[esi]\nfstp qword ptr (-44)[ebp]\nfld qword ptr (-36)[ebp]\nfadd qword ptr (-44)[ebp]\nfld qword ptr (L15)\nfcompp\nfstsw ax\nsahf\nje L13\ncmp edi,0\nje L13\nfld qword ptr (-36)[ebp]\nfsub qword ptr (-44)[ebp]\nfld qword ptr (L15)\nfcompp\nfstsw ax\nsahf\nje L13\nmov dword ptr (-28)[ebp],1\njmp L14\nL13:\nmov dword ptr (-28)[ebp],0\nL14:\nmov edi,dword ptr (-28)[ebp]\nmov dword ptr (_i),edi\nmov eax,0\nL11:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _f5\n_f5:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov edi,dword ptr (_k)\nmov esi,dword ptr (_m)\nmov ebx,dword ptr (_A)\nmov edx,edi\nimul edx,esi\nlea edx,[ebx][edx*8]\nmov ecx,dword ptr (_j)\nmov eax,ecx\nimul eax,esi\nlea esi,[ebx][eax*8]\nmov ebx,dword ptr (_n)\nmov eax,dword ptr (_B)\nimul edi,ebx\nlea edi,[eax][edi*8]\nimul ecx,ebx\nlea ebx,[eax][ecx*8]\nfld qword ptr [edx]\nfmul qword ptr [esi]\nfld qword ptr [edi]\nfmul qword ptr [ebx]\nfaddp st(1),st\nfstp qword ptr (_x)\nfld qword ptr [edx]\nfmul qword ptr [ebx]\nfld qword ptr [edi]\nfmul qword ptr [esi]\nfsubp st(1),st\nfstp qword ptr (_x)\nmov eax,0\nL16:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\npublic _x\nalign 4\n_x label byte\ndb 8 dup (0)\npublic _B\nalign 4\n_B label byte\ndb 4 dup (0)\npublic _A\nalign 4\n_A label byte\ndb 4 dup (0)\npublic _n\nalign 4\n_n label byte\ndb 4 dup (0)\npublic _m\nalign 4\n_m label byte\ndb 4 dup (0)\npublic _k\nalign 4\n_k label byte\ndb 4 dup (0)\npublic _j\nalign 4\n_j label byte\ndb 4 dup (0)\npublic _i\nalign 4\n_i label byte\ndb 4 dup (0)\npublic _b\nalign 4\n_b label byte\ndb 80 dup (0)\npublic _a\nalign 4\n_a label byte\ndb 80 dup (0)\n_DATA ends\n_TEXT segment\nalign 4\nL15 label byte\ndd 00H\ndd 00H\n_TEXT ends\nend\n"
  },
  {
    "path": "lcc/x86/win32/tst/stdarg.1bk",
    "content": "test 1\ntest 2\ntest 3\ntest 4\ntest 5.000000\n{1 2 3 4} {1 2 3 4} {1 2 3 4} {1 2 3 4} {1 2 3 4} {1 2 3 4}\n"
  },
  {
    "path": "lcc/x86/win32/tst/stdarg.2bk",
    "content": "tst/stdarg.c:51: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/win32/tst/stdarg.sbk",
    "content": ".486\n.model flat\nextrn __fltused:near\nextrn __ftol:near\n_DATA segment\npublic _x\nalign 4\n_x label byte\ndd 1\ndd 2\ndd 3\ndd 4\npublic _main\n_DATA ends\n_TEXT segment\n_main:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,8\nlea edi,(L2)\npush edi\ncall _print\nadd esp,4\nlea edi,(L4)\npush edi\nlea edi,(L3)\npush edi\ncall _print\nadd esp,8\npush 10\npush 3\nlea edi,(L5)\npush edi\ncall _print\nadd esp,12\npush 10\npush 4\nlea edi,(L8)\npush edi\nlea edi,(L7)\npush edi\nlea edi,(L6)\npush edi\ncall _print\nadd esp,20\npush 10\nfld qword ptr (L10)\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L8)\npush edi\nlea edi,(L7)\npush edi\nlea edi,(L9)\npush edi\ncall _print\nadd esp,24\nlea edi,(_x)\nmov dword ptr (-8)[ebp],edi\nmov esi,edi\nmov dword ptr (-4)[ebp],esi\nsub esp,16\nmov edi,esp\nmov ecx,16\nrep movsb\nmov edi,dword ptr (-8)[ebp]\nmov esi,edi\nsub esp,16\nmov edi,esp\nmov ecx,16\nrep movsb\nmov edi,dword ptr (-8)[ebp]\nmov esi,edi\nsub esp,16\nmov edi,esp\nmov ecx,16\nrep movsb\nmov edi,dword ptr (-8)[ebp]\nmov esi,edi\nsub esp,16\nmov edi,esp\nmov ecx,16\nrep movsb\nmov edi,dword ptr (-8)[ebp]\nmov esi,edi\nsub esp,16\nmov edi,esp\nmov ecx,16\nrep movsb\nmov edi,dword ptr (-8)[ebp]\nmov esi,edi\nsub esp,16\nmov edi,esp\nmov ecx,16\nrep movsb\nlea edi,(L11)\npush edi\ncall _print\nadd esp,100\nmov eax,0\nL1:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _print\n_print:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,28\nlea edi,(24)[ebp]\nmov dword ptr (-4)[ebp],edi\njmp L17\nL14:\nmov edi,dword ptr (20)[ebp]\nmovsx edi,byte ptr [edi]\ncmp edi,37\njne L18\nmov edi,dword ptr (20)[ebp]\nlea edi,(1)[edi]\nmov dword ptr (20)[ebp],edi\nmovsx edi,byte ptr [edi]\nmov dword ptr (-8)[ebp],edi\nmov edi,dword ptr (-8)[ebp]\ncmp edi,115\nje L34\ncmp edi,115\njg L39\nL38:\nmov edi,dword ptr (-8)[ebp]\ncmp edi,98\njl L20\ncmp edi,102\njg L20\njmp dword ptr (L40-392)[edi*4]\n_TEXT ends\n_TEXT segment\nalign 4\nL40 label byte\ndd L23\ndd L28\ndd L30\ndd L20\ndd L36\n_TEXT ends\n_TEXT segment\nL39:\ncmp dword ptr (-8)[ebp],119\nje L32\njmp L20\nL23:\nmov edi,dword ptr (-4)[ebp]\nlea edi,(16)[edi]\nmov dword ptr (-28)[ebp],edi\nmov dword ptr (-4)[ebp],edi\nlea edi,(-24)[ebp]\nmov esi,dword ptr (-28)[ebp]\nlea esi,(-16)[esi]\nmov ecx,16\nrep movsb\nmov edi,dword ptr (-12)[ebp]\npush edi\nmov edi,dword ptr (-16)[ebp]\npush edi\nmov edi,dword ptr (-20)[ebp]\npush edi\nmov edi,dword ptr (-24)[ebp]\npush edi\nlea edi,(L24)\npush edi\ncall _printf\nadd esp,20\njmp L19\nL28:\nmov edi,dword ptr (-4)[ebp]\nlea edi,(4)[edi]\nmov dword ptr (-4)[ebp],edi\nmovsx edi,byte ptr (-4)[edi]\npush edi\nlea edi,(L29)\npush edi\ncall _printf\nadd esp,8\njmp L19\nL30:\nmov edi,dword ptr (-4)[ebp]\nlea edi,(4)[edi]\nmov dword ptr (-4)[ebp],edi\nmov edi,dword ptr (-4)[edi]\npush edi\nlea edi,(L31)\npush edi\ncall _printf\nadd esp,8\njmp L19\nL32:\nmov edi,dword ptr (-4)[ebp]\nlea edi,(4)[edi]\nmov dword ptr (-4)[ebp],edi\nmovsx edi,word ptr (-4)[edi]\npush edi\nlea edi,(L33)\npush edi\ncall _printf\nadd esp,8\njmp L19\nL34:\nmov edi,dword ptr (-4)[ebp]\nlea edi,(4)[edi]\nmov dword ptr (-4)[ebp],edi\nmov edi,dword ptr (-4)[edi]\npush edi\nlea edi,(L35)\npush edi\ncall _printf\nadd esp,8\njmp L19\nL36:\nmov edi,dword ptr (-4)[ebp]\nlea edi,(8)[edi]\nmov dword ptr (-4)[ebp],edi\nfld qword ptr (-8)[edi]\nsub esp,8\nfstp qword ptr [esp]\nlea edi,(L37)\npush edi\ncall _printf\nadd esp,12\njmp L19\nL20:\nmov edi,dword ptr (20)[ebp]\nmovsx edi,byte ptr [edi]\npush edi\nlea edi,(L29)\npush edi\ncall _printf\nadd esp,8\njmp L19\nL18:\nmov edi,dword ptr (20)[ebp]\nmovsx edi,byte ptr [edi]\npush edi\nlea edi,(L29)\npush edi\ncall _printf\nadd esp,8\nL19:\nL15:\ninc dword ptr (20)[ebp]\nL17:\nmov edi,dword ptr (20)[ebp]\nmovsx edi,byte ptr [edi]\ncmp edi,0\njne L14\nmov dword ptr (-4)[ebp],0\nmov eax,0\nL12:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\nextrn _printf:near\n_TEXT segment\n_TEXT ends\n_TEXT segment\nalign 1\nL37 label byte\ndb 37\ndb 102\ndb 0\nalign 1\nL35 label byte\ndb 37\ndb 115\ndb 0\nalign 1\nL33 label byte\ndb 37\ndb 120\ndb 0\nalign 1\nL31 label byte\ndb 37\ndb 100\ndb 0\nalign 1\nL29 label byte\ndb 37\ndb 99\ndb 0\nalign 1\nL24 label byte\ndb 123\ndb 37\ndb 100\ndb 32\ndb 37\ndb 100\ndb 32\ndb 37\ndb 100\ndb 32\ndb 37\ndb 100\ndb 125\ndb 0\nalign 1\nL11 label byte\ndb 37\ndb 98\ndb 32\ndb 37\ndb 98\ndb 32\ndb 37\ndb 98\ndb 32\ndb 37\ndb 98\ndb 32\ndb 37\ndb 98\ndb 32\ndb 37\ndb 98\ndb 10\ndb 0\nalign 4\nL10 label byte\ndd 00H\ndd 040140000H\nalign 1\nL9 label byte\ndb 37\ndb 115\ndb 37\ndb 115\ndb 32\ndb 37\ndb 102\ndb 37\ndb 99\ndb 0\nalign 1\nL8 label byte\ndb 115\ndb 116\ndb 0\nalign 1\nL7 label byte\ndb 116\ndb 101\ndb 0\nalign 1\nL6 label byte\ndb 37\ndb 115\ndb 37\ndb 115\ndb 32\ndb 37\ndb 119\ndb 37\ndb 99\ndb 0\nalign 1\nL5 label byte\ndb 116\ndb 101\ndb 115\ndb 116\ndb 32\ndb 37\ndb 100\ndb 37\ndb 99\ndb 0\nalign 1\nL4 label byte\ndb 50\ndb 0\nalign 1\nL3 label byte\ndb 116\ndb 101\ndb 115\ndb 116\ndb 32\ndb 37\ndb 115\ndb 10\ndb 0\nalign 1\nL2 label byte\ndb 116\ndb 101\ndb 115\ndb 116\ndb 32\ndb 49\ndb 10\ndb 0\n_TEXT ends\nend\n"
  },
  {
    "path": "lcc/x86/win32/tst/struct.1bk",
    "content": "(-1,-1) is not within [10,10; 310,310]\n(1,1) is not within [10,10; 310,310]\n(20,300) is within [10,10; 310,310]\n(500,400) is not within [10,10; 310,310]\nab\n"
  },
  {
    "path": "lcc/x86/win32/tst/struct.2bk",
    "content": "tst/struct.c:49: warning: missing return value\ntst/struct.c:68: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/win32/tst/struct.sbk",
    "content": ".486\n.model flat\nextrn __fltused:near\nextrn __ftol:near\npublic _addpoint\n_TEXT segment\n_addpoint:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov edi,dword ptr (32)[ebp]\nadd dword ptr (24)[ebp],edi\nmov edi,dword ptr (36)[ebp]\nadd dword ptr (28)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea esi,(24)[ebp]\nmov ecx,8\nrep movsb\nL1:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _canonrect\n_canonrect:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,32\nmov edi,dword ptr (32)[ebp]\ncmp dword ptr (24)[ebp],edi\njge L10\nmov edi,dword ptr (24)[ebp]\nmov dword ptr (-20)[ebp],edi\njmp L11\nL10:\nmov edi,dword ptr (32)[ebp]\nmov dword ptr (-20)[ebp],edi\nL11:\nmov edi,dword ptr (-20)[ebp]\nmov dword ptr (-16)[ebp],edi\nmov edi,dword ptr (36)[ebp]\ncmp dword ptr (28)[ebp],edi\njge L20\nmov edi,dword ptr (28)[ebp]\nmov dword ptr (-24)[ebp],edi\njmp L21\nL20:\nmov edi,dword ptr (36)[ebp]\nmov dword ptr (-24)[ebp],edi\nL21:\nmov edi,dword ptr (-24)[ebp]\nmov dword ptr (-12)[ebp],edi\nmov edi,dword ptr (32)[ebp]\ncmp dword ptr (24)[ebp],edi\njle L26\nmov edi,dword ptr (24)[ebp]\nmov dword ptr (-28)[ebp],edi\njmp L27\nL26:\nmov edi,dword ptr (32)[ebp]\nmov dword ptr (-28)[ebp],edi\nL27:\nmov edi,dword ptr (-28)[ebp]\nmov dword ptr (-8)[ebp],edi\nmov edi,dword ptr (36)[ebp]\ncmp dword ptr (28)[ebp],edi\njle L37\nmov edi,dword ptr (28)[ebp]\nmov dword ptr (-32)[ebp],edi\njmp L38\nL37:\nmov edi,dword ptr (36)[ebp]\nmov dword ptr (-32)[ebp],edi\nL38:\nmov edi,dword ptr (-32)[ebp]\nmov dword ptr (-4)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea esi,(-16)[ebp]\nmov ecx,16\nrep movsb\nL5:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _makepoint\n_makepoint:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,8\nmov edi,dword ptr (24)[ebp]\nmov dword ptr (-8)[ebp],edi\nmov edi,dword ptr (28)[ebp]\nmov dword ptr (-4)[ebp],edi\nmov edi,dword ptr (20)[ebp]\nlea esi,(-8)[ebp]\nmov ecx,8\nrep movsb\nL39:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _makerect\n_makerect:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,16\nlea edi,(-16)[ebp]\nlea esi,(24)[ebp]\nmov ecx,8\nrep movsb\nlea edi,(-8)[ebp]\nlea esi,(32)[ebp]\nmov ecx,8\nrep movsb\nlea esi,(-16)[ebp]\nsub esp,16\nmov edi,esp\nmov ecx,16\nrep movsb\nmov edi,dword ptr (20)[ebp]\npush edi\ncall _canonrect\nadd esp,20\nL42:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _ptinrect\n_ptinrect:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\nmov edi,dword ptr (20)[ebp]\ncmp edi,dword ptr (28)[ebp]\njl L53\ncmp edi,dword ptr (36)[ebp]\njge L53\nmov edi,dword ptr (32)[ebp]\ncmp dword ptr (24)[ebp],edi\njl L53\nmov edi,dword ptr (40)[ebp]\ncmp dword ptr (24)[ebp],edi\njge L53\nmov dword ptr (-4)[ebp],1\njmp L54\nL53:\nmov dword ptr (-4)[ebp],0\nL54:\nmov eax,dword ptr (-4)[ebp]\nL45:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\npublic _y\nalign 4\n_y label byte\ndb 97\ndb 98\ndb 0\ndb 1 dup (0)\npublic _odd\n_DATA ends\n_TEXT segment\n_odd:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\nlea edi,(-4)[ebp]\nlea esi,(20)[ebp]\nmov ecx,4\nrep movsb\nlea edi,(-4)[ebp]\npush edi\nlea edi,(L56)\npush edi\ncall _printf\nadd esp,8\nmov eax,0\nL55:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_TEXT segment\nalign 4\nL58 label byte\ndd 0\ndd 0\nalign 4\nL59 label byte\ndd 320\ndd 320\nalign 4\nL60 label byte\ndd -1\ndd -1\ndd 1\ndd 1\ndd 20\ndd 300\ndd 500\ndd 400\npublic _main\n_TEXT ends\n_TEXT segment\n_main:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,108\nlea edi,(-68)[ebp]\nlea esi,(L58)\nmov ecx,8\nrep movsb\nlea edi,(-76)[ebp]\nlea esi,(L59)\nmov ecx,8\nrep movsb\nlea edi,(-36)[ebp]\nlea esi,(L60)\nmov ecx,32\nrep movsb\npush -10\npush -10\nlea edi,(-84)[ebp]\npush edi\ncall _makepoint\nadd esp,12\nlea esi,(-84)[ebp]\nsub esp,8\nmov edi,esp\nmov ecx,8\nrep movsb\nlea esi,(-76)[ebp]\nsub esp,8\nmov edi,esp\nmov ecx,8\nrep movsb\nlea edi,(-92)[ebp]\npush edi\ncall _addpoint\nadd esp,20\npush 10\npush 10\nlea edi,(-100)[ebp]\npush edi\ncall _makepoint\nadd esp,12\nlea esi,(-100)[ebp]\nsub esp,8\nmov edi,esp\nmov ecx,8\nrep movsb\nlea esi,(-68)[ebp]\nsub esp,8\nmov edi,esp\nmov ecx,8\nrep movsb\nlea edi,(-108)[ebp]\npush edi\ncall _addpoint\nadd esp,20\nlea esi,(-108)[ebp]\nsub esp,8\nmov edi,esp\nmov ecx,8\nrep movsb\nlea esi,(-92)[ebp]\nsub esp,8\nmov edi,esp\nmov ecx,8\nrep movsb\nlea edi,(-52)[ebp]\npush edi\ncall _makerect\nadd esp,20\nmov dword ptr (-4)[ebp],0\njmp L64\nL61:\nmov edi,dword ptr (-4)[ebp]\nlea edi,[edi*8]\nmov esi,dword ptr (-32)[ebp][edi]\npush esi\nmov edi,dword ptr (-36)[ebp][edi]\npush edi\nlea edi,(-60)[ebp]\npush edi\ncall _makepoint\nadd esp,12\nmov edi,dword ptr (-56)[ebp]\npush edi\nmov edi,dword ptr (-4)[ebp]\nmov edi,dword ptr (-36)[ebp][edi*8]\npush edi\nlea edi,(L65)\npush edi\ncall _printf\nadd esp,12\nlea esi,(-52)[ebp]\nsub esp,16\nmov edi,esp\nmov ecx,16\nrep movsb\nlea esi,(-60)[ebp]\nsub esp,8\nmov edi,esp\nmov ecx,8\nrep movsb\ncall _ptinrect\nadd esp,24\ncmp eax,0\njne L68\nlea edi,(L70)\npush edi\ncall _printf\nadd esp,4\nL68:\nmov edi,dword ptr (-40)[ebp]\npush edi\nmov edi,dword ptr (-44)[ebp]\npush edi\nmov edi,dword ptr (-48)[ebp]\npush edi\nmov edi,dword ptr (-52)[ebp]\npush edi\nlea edi,(L71)\npush edi\ncall _printf\nadd esp,20\nL62:\ninc dword ptr (-4)[ebp]\nL64:\nmov edi,dword ptr (-4)[ebp]\ncmp edi,4\njb L61\nlea esi,(_y)\nsub esp,4\nmov edi,esp\nmov ecx,4\nrep movsb\ncall _odd\nadd esp,4\npush 0\ncall _exit\nadd esp,4\nmov eax,0\nL57:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\nextrn _exit:near\n_TEXT segment\n_TEXT ends\nextrn _printf:near\n_TEXT segment\n_TEXT ends\n_TEXT segment\nalign 1\nL71 label byte\ndb 119\ndb 105\ndb 116\ndb 104\ndb 105\ndb 110\ndb 32\ndb 91\ndb 37\ndb 100\ndb 44\ndb 37\ndb 100\ndb 59\ndb 32\ndb 37\ndb 100\ndb 44\ndb 37\ndb 100\ndb 93\ndb 10\ndb 0\nalign 1\nL70 label byte\ndb 110\ndb 111\ndb 116\ndb 32\ndb 0\nalign 1\nL65 label byte\ndb 40\ndb 37\ndb 100\ndb 44\ndb 37\ndb 100\ndb 41\ndb 32\ndb 105\ndb 115\ndb 32\ndb 0\nalign 1\nL56 label byte\ndb 37\ndb 115\ndb 10\ndb 0\n_TEXT ends\nend\n"
  },
  {
    "path": "lcc/x86/win32/tst/switch.1bk",
    "content": "b = 0x8\nf = 0xc\nn = 0xa\nr = 0xd\nt = 0x9\nv = 0xb\nx = 0x78\nf:\nx = 0\nx = 1\nx = 2\nx = 2\nx = 2\nx = 2\nx = 2\nx = 7\nx = 8\nx = 9\nx = 9\nx = 9\nx = 9\nx = 9\nx = 9\nx = 9\nx = 16\nx = 17\nx = 18\nx = 19\nx = 20\ng:\n1 1\n1 2\n2 3\n2 4\n2 5\n3 6\nd 6\n3 7\nd 7\n3 8\nd 8\nd 9\nd 10\nh:\ni = 8\ni = 16\ni = 120\ni = 128\ni = 248\ni = 264\ni = 272\ni = 280\ni = 288\ni = 296\ni = 304\ni = 312\n488 defaults\nx = 0x1000000\nx = 0x2000000\nx = 0x3000000\nx = 0x4000000\nx = 0x5000000\nx = 0x6000000 (default)\nx = 0x7000000 (default)\n0\n1\n2\n3\n4\n5\n0\n1\n2\n3\n4\n5\n"
  },
  {
    "path": "lcc/x86/win32/tst/switch.2bk",
    "content": "tst/switch.c:55: warning: missing return value\ntst/switch.c:73: warning: missing return value\ntst/switch.c:97: warning: missing return value\ntst/switch.c:112: warning: missing return value\ntst/switch.c:137: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/win32/tst/switch.sbk",
    "content": ".486\n.model flat\nextrn __fltused:near\nextrn __ftol:near\npublic _main\n_TEXT segment\n_main:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,8\nlea edi,(L6)\nmov dword ptr (-4)[ebp],edi\njmp L5\nL2:\nmov edi,dword ptr (-4)[ebp]\nmovsx edi,byte ptr [edi]\npush edi\ncall _backslash\nadd esp,4\npush eax\nmov edi,dword ptr (-4)[ebp]\nmovsx edi,byte ptr [edi]\npush edi\nlea edi,(L7)\npush edi\ncall _printf\nadd esp,12\nL3:\ninc dword ptr (-4)[ebp]\nL5:\nmov edi,dword ptr (-4)[ebp]\nmovsx edi,byte ptr [edi]\ncmp edi,0\njne L2\ncall _f\nadd esp,0\ncall _g\nadd esp,0\ncall _h\nadd esp,0\nmov dword ptr (-8)[ebp],16777216\njmp L11\nL8:\nmov edi,dword ptr (-8)[ebp]\npush edi\ncall _big\nadd esp,4\nL9:\nadd dword ptr (-8)[ebp],16777216\nL11:\nmov edi,dword ptr (-8)[ebp]\nand edi,117440512\ncmp edi,0\njne L8\ncall _limit\nadd esp,0\nmov eax,0\nL1:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _backslash\n_backslash:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov edi,dword ptr (20)[ebp]\ncmp edi,102\nje L16\ncmp edi,102\njg L22\nL21:\ncmp dword ptr (20)[ebp],98\nje L15\njmp L13\nL22:\nmov edi,dword ptr (20)[ebp]\ncmp edi,110\nje L17\ncmp edi,110\njl L13\nL23:\nmov edi,dword ptr (20)[ebp]\ncmp edi,114\nje L18\ncmp edi,116\nje L19\ncmp edi,118\nje L20\njmp L13\nL15:\nmov eax,8\njmp L12\nL16:\nmov eax,12\njmp L12\nL17:\nmov eax,10\njmp L12\nL18:\nmov eax,13\njmp L12\nL19:\nmov eax,9\njmp L12\nL20:\nmov eax,11\njmp L12\nL13:\nmov eax,dword ptr (20)[ebp]\nL12:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _f\n_f:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,12\nmov dword ptr (-8)[ebp],0\nlea edi,(L25)\npush edi\ncall _printf\nadd esp,4\nmov dword ptr (-4)[ebp],0\nL26:\nmov edi,dword ptr (-4)[ebp]\nmov dword ptr (-12)[ebp],edi\nmov edi,dword ptr (-4)[ebp]\ncmp edi,1\njl L30\ncmp edi,20\njg L30\njmp dword ptr (L42-4)[edi*4]\n_TEXT ends\n_TEXT segment\nalign 4\nL42 label byte\ndd L32\ndd L33\ndd L30\ndd L30\ndd L30\ndd L30\ndd L34\ndd L35\ndd L36\ndd L30\ndd L30\ndd L30\ndd L30\ndd L30\ndd L30\ndd L37\ndd L38\ndd L39\ndd L40\ndd L41\n_TEXT ends\n_TEXT segment\nL32:\nmov edi,dword ptr (-4)[ebp]\nmov dword ptr (-8)[ebp],edi\njmp L31\nL33:\nmov edi,dword ptr (-4)[ebp]\nmov dword ptr (-8)[ebp],edi\njmp L31\nL34:\nmov edi,dword ptr (-4)[ebp]\nmov dword ptr (-8)[ebp],edi\njmp L31\nL35:\nmov edi,dword ptr (-4)[ebp]\nmov dword ptr (-8)[ebp],edi\njmp L31\nL36:\nmov edi,dword ptr (-4)[ebp]\nmov dword ptr (-8)[ebp],edi\njmp L31\nL37:\nmov edi,dword ptr (-4)[ebp]\nmov dword ptr (-8)[ebp],edi\njmp L31\nL38:\nmov edi,dword ptr (-4)[ebp]\nmov dword ptr (-8)[ebp],edi\njmp L31\nL39:\nmov edi,dword ptr (-4)[ebp]\nmov dword ptr (-8)[ebp],edi\njmp L31\nL40:\nmov edi,dword ptr (-4)[ebp]\nmov dword ptr (-8)[ebp],edi\njmp L31\nL41:\nmov edi,dword ptr (-4)[ebp]\nmov dword ptr (-8)[ebp],edi\nL30:\nL31:\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L44)\npush edi\ncall _printf\nadd esp,8\nL27:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],20\njle L26\nmov eax,0\nL24:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _g\n_g:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\nlea edi,(L46)\npush edi\ncall _printf\nadd esp,4\nmov dword ptr (-4)[ebp],1\nL47:\nmov edi,dword ptr (-4)[ebp]\ncmp edi,1001\njl L64\ncmp edi,1004\njg L65\njmp dword ptr (L66-4004)[edi*4]\n_TEXT ends\n_TEXT segment\nalign 4\nL66 label byte\ndd L60\ndd L60\ndd L60\ndd L60\n_TEXT ends\n_TEXT segment\nL64:\nmov edi,dword ptr (-4)[ebp]\ncmp edi,1\njl L51\ncmp edi,8\njg L51\njmp dword ptr (L68-4)[edi*4]\n_TEXT ends\n_TEXT segment\nalign 4\nL68 label byte\ndd L53\ndd L53\ndd L55\ndd L55\ndd L55\ndd L57\ndd L57\ndd L57\n_TEXT ends\n_TEXT segment\nL65:\nmov edi,dword ptr (-4)[ebp]\ncmp edi,3001\njl L51\ncmp edi,3004\njg L51\njmp dword ptr (L70-12004)[edi*4]\n_TEXT ends\n_TEXT segment\nalign 4\nL70 label byte\ndd L62\ndd L62\ndd L62\ndd L62\n_TEXT ends\n_TEXT segment\nL53:\nmov edi,dword ptr (-4)[ebp]\npush edi\nlea edi,(L54)\npush edi\ncall _printf\nadd esp,8\njmp L52\nL55:\nmov edi,dword ptr (-4)[ebp]\npush edi\nlea edi,(L56)\npush edi\ncall _printf\nadd esp,8\njmp L52\nL57:\nmov edi,dword ptr (-4)[ebp]\npush edi\nlea edi,(L58)\npush edi\ncall _printf\nadd esp,8\nL51:\nmov edi,dword ptr (-4)[ebp]\npush edi\nlea edi,(L59)\npush edi\ncall _printf\nadd esp,8\njmp L52\nL60:\nmov edi,dword ptr (-4)[ebp]\npush edi\nlea edi,(L61)\npush edi\ncall _printf\nadd esp,8\njmp L52\nL62:\nmov edi,dword ptr (-4)[ebp]\npush edi\nlea edi,(L63)\npush edi\ncall _printf\nadd esp,8\nL52:\nL48:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],10\njle L47\nmov eax,0\nL45:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _h\n_h:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,8\nmov dword ptr (-8)[ebp],0\nlea edi,(L73)\npush edi\ncall _printf\nadd esp,4\nmov dword ptr (-4)[ebp],1\nL74:\nmov edi,dword ptr (-4)[ebp]\ncmp edi,264\nje L86\ncmp edi,264\njg L94\nL93:\nmov edi,dword ptr (-4)[ebp]\ncmp edi,120\nje L84\ncmp edi,120\njg L96\nL95:\nmov edi,dword ptr (-4)[ebp]\ncmp edi,8\nje L83\ncmp edi,8\njl L78\nL97:\ncmp dword ptr (-4)[ebp],16\nje L82\njmp L78\nL96:\nmov edi,dword ptr (-4)[ebp]\ncmp edi,128\nje L80\ncmp edi,128\njl L78\nL98:\ncmp dword ptr (-4)[ebp],248\nje L87\njmp L78\nL94:\nmov edi,dword ptr (-4)[ebp]\ncmp edi,288\nje L91\ncmp edi,288\njg L100\nL99:\nmov edi,dword ptr (-4)[ebp]\ncmp edi,272\nje L88\ncmp edi,272\njl L78\nL101:\ncmp dword ptr (-4)[ebp],280\nje L85\njmp L78\nL100:\nmov edi,dword ptr (-4)[ebp]\ncmp edi,304\nje L89\ncmp edi,304\njg L103\nL102:\ncmp dword ptr (-4)[ebp],296\nje L90\njmp L78\nL103:\ncmp dword ptr (-4)[ebp],312\nje L92\njmp L78\nL78:\ninc dword ptr (-8)[ebp]\njmp L75\nL80:\nmov edi,dword ptr (-4)[ebp]\npush edi\nlea edi,(L81)\npush edi\ncall _printf\nadd esp,8\njmp L79\nL82:\nmov edi,dword ptr (-4)[ebp]\npush edi\nlea edi,(L81)\npush edi\ncall _printf\nadd esp,8\njmp L79\nL83:\nmov edi,dword ptr (-4)[ebp]\npush edi\nlea edi,(L81)\npush edi\ncall _printf\nadd esp,8\njmp L79\nL84:\nmov edi,dword ptr (-4)[ebp]\npush edi\nlea edi,(L81)\npush edi\ncall _printf\nadd esp,8\njmp L79\nL85:\nmov edi,dword ptr (-4)[ebp]\npush edi\nlea edi,(L81)\npush edi\ncall _printf\nadd esp,8\njmp L79\nL86:\nmov edi,dword ptr (-4)[ebp]\npush edi\nlea edi,(L81)\npush edi\ncall _printf\nadd esp,8\njmp L79\nL87:\nmov edi,dword ptr (-4)[ebp]\npush edi\nlea edi,(L81)\npush edi\ncall _printf\nadd esp,8\njmp L79\nL88:\nmov edi,dword ptr (-4)[ebp]\npush edi\nlea edi,(L81)\npush edi\ncall _printf\nadd esp,8\njmp L79\nL89:\nmov edi,dword ptr (-4)[ebp]\npush edi\nlea edi,(L81)\npush edi\ncall _printf\nadd esp,8\njmp L79\nL90:\nmov edi,dword ptr (-4)[ebp]\npush edi\nlea edi,(L81)\npush edi\ncall _printf\nadd esp,8\njmp L79\nL91:\nmov edi,dword ptr (-4)[ebp]\npush edi\nlea edi,(L81)\npush edi\ncall _printf\nadd esp,8\njmp L79\nL92:\nmov edi,dword ptr (-4)[ebp]\npush edi\nlea edi,(L81)\npush edi\ncall _printf\nadd esp,8\nL79:\nL75:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],500\njle L74\nmov edi,dword ptr (-8)[ebp]\npush edi\nlea edi,(L104)\npush edi\ncall _printf\nadd esp,8\nmov eax,0\nL72:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _big\n_big:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\nmov edi,dword ptr (20)[ebp]\nand edi,06000000H\nmov dword ptr (-4)[ebp],edi\nmov edi,dword ptr (-4)[ebp]\ncmp edi,33554432\nje L111\ncmp edi,33554432\njg L115\nL114:\nmov edi,dword ptr (-4)[ebp]\ncmp edi,-2\nje L109\ncmp edi,-1\nje L109\ncmp edi,0\nje L109\njmp L106\nL115:\nmov edi,dword ptr (-4)[ebp]\ncmp edi,67108864\nje L112\njmp L106\nL109:\nmov edi,dword ptr (20)[ebp]\npush edi\nlea edi,(L110)\npush edi\ncall _printf\nadd esp,8\njmp L107\nL111:\nmov edi,dword ptr (20)[ebp]\npush edi\nlea edi,(L110)\npush edi\ncall _printf\nadd esp,8\njmp L107\nL112:\nmov edi,dword ptr (20)[ebp]\npush edi\nlea edi,(L110)\npush edi\ncall _printf\nadd esp,8\njmp L107\nL106:\nmov edi,dword ptr (20)[ebp]\npush edi\nlea edi,(L113)\npush edi\ncall _printf\nadd esp,8\nL107:\nmov eax,0\nL105:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _limit\n_limit:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\nmov dword ptr (-4)[ebp],-2147483648\nL117:\nmov edi,dword ptr (-4)[ebp]\nmov esi,-2147483648\ncmp edi,-2147483648\njl L121\ncmp edi,-2147483644\njg L121\nlea edi,[edi*4]\nlea esi,[esi*4]\nsub edi,esi\njmp dword ptr (L134)[edi]\n_TEXT ends\n_TEXT segment\nalign 4\nL134 label byte\ndd L123\ndd L125\ndd L127\ndd L129\ndd L131\n_TEXT ends\n_TEXT segment\nL123:\nlea edi,(L124)\npush edi\ncall _printf\nadd esp,4\njmp L122\nL125:\nlea edi,(L126)\npush edi\ncall _printf\nadd esp,4\njmp L122\nL127:\nlea edi,(L128)\npush edi\ncall _printf\nadd esp,4\njmp L122\nL129:\nlea edi,(L130)\npush edi\ncall _printf\nadd esp,4\njmp L122\nL131:\nlea edi,(L132)\npush edi\ncall _printf\nadd esp,4\njmp L122\nL121:\nlea edi,(L133)\npush edi\ncall _printf\nadd esp,4\nL122:\nL118:\ninc dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],-2147483643\njle L117\nmov dword ptr (-4)[ebp],2147483647\nL135:\nmov edi,dword ptr (-4)[ebp]\nmov esi,2147483643\ncmp edi,2147483643\njl L139\ncmp edi,2147483647\njg L139\nlea edi,[edi*4]\nlea esi,[esi*4]\nsub edi,esi\njmp dword ptr (L146)[edi]\n_TEXT ends\n_TEXT segment\nalign 4\nL146 label byte\ndd L145\ndd L144\ndd L143\ndd L142\ndd L141\n_TEXT ends\n_TEXT segment\nL141:\nlea edi,(L124)\npush edi\ncall _printf\nadd esp,4\njmp L140\nL142:\nlea edi,(L126)\npush edi\ncall _printf\nadd esp,4\njmp L140\nL143:\nlea edi,(L128)\npush edi\ncall _printf\nadd esp,4\njmp L140\nL144:\nlea edi,(L130)\npush edi\ncall _printf\nadd esp,4\njmp L140\nL145:\nlea edi,(L132)\npush edi\ncall _printf\nadd esp,4\njmp L140\nL139:\nlea edi,(L133)\npush edi\ncall _printf\nadd esp,4\nL140:\nL136:\ndec dword ptr (-4)[ebp]\ncmp dword ptr (-4)[ebp],2147483642\njge L135\nmov eax,0\nL116:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\nextrn _printf:near\n_TEXT segment\n_TEXT ends\n_TEXT segment\nalign 1\nL133 label byte\ndb 53\ndb 10\ndb 0\nalign 1\nL132 label byte\ndb 52\ndb 10\ndb 0\nalign 1\nL130 label byte\ndb 51\ndb 10\ndb 0\nalign 1\nL128 label byte\ndb 50\ndb 10\ndb 0\nalign 1\nL126 label byte\ndb 49\ndb 10\ndb 0\nalign 1\nL124 label byte\ndb 48\ndb 10\ndb 0\nalign 1\nL113 label byte\ndb 120\ndb 32\ndb 61\ndb 32\ndb 48\ndb 120\ndb 37\ndb 120\ndb 32\ndb 40\ndb 100\ndb 101\ndb 102\ndb 97\ndb 117\ndb 108\ndb 116\ndb 41\ndb 10\ndb 0\nalign 1\nL110 label byte\ndb 120\ndb 32\ndb 61\ndb 32\ndb 48\ndb 120\ndb 37\ndb 120\ndb 10\ndb 0\nalign 1\nL104 label byte\ndb 37\ndb 100\ndb 32\ndb 100\ndb 101\ndb 102\ndb 97\ndb 117\ndb 108\ndb 116\ndb 115\ndb 10\ndb 0\nalign 1\nL81 label byte\ndb 105\ndb 32\ndb 61\ndb 32\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL73 label byte\ndb 104\ndb 58\ndb 10\ndb 0\nalign 1\nL63 label byte\ndb 54\ndb 32\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL61 label byte\ndb 53\ndb 32\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL59 label byte\ndb 100\ndb 32\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL58 label byte\ndb 51\ndb 32\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL56 label byte\ndb 50\ndb 32\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL54 label byte\ndb 49\ndb 32\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL46 label byte\ndb 103\ndb 58\ndb 10\ndb 0\nalign 1\nL44 label byte\ndb 120\ndb 32\ndb 61\ndb 32\ndb 37\ndb 100\ndb 10\ndb 0\nalign 1\nL25 label byte\ndb 102\ndb 58\ndb 10\ndb 0\nalign 1\nL7 label byte\ndb 37\ndb 99\ndb 32\ndb 61\ndb 32\ndb 48\ndb 120\ndb 37\ndb 120\ndb 10\ndb 0\nalign 1\nL6 label byte\ndb 98\ndb 102\ndb 110\ndb 114\ndb 116\ndb 118\ndb 120\ndb 0\n_TEXT ends\nend\n"
  },
  {
    "path": "lcc/x86/win32/tst/wf1.1bk",
    "content": "5\ta\n2\tand\n5\tbuf\n16\tc\n8\tchar\n1\tcompare\n4\tcond\n5\tcount\n1\td\n1\tdie\n3\telse\n1\tentry\n1\teof\n4\terr\n1\terror\n1\texit\n1\tfolded\n1\tfor\n1\tfree\n1\tfrequencies\n1\tfrequency\n1\tget\n2\tgetchar\n3\tgetword\n14\tif\n2\tin\n1\tindex\n1\tinput\n1\tinstall\n8\tint\n1\tinto\n1\tis\n4\tisletter\n1\tit\n1\titself\n5\tleft\n1\tletter\n7\tlookup\n1\tmain\n2\tmalloc\n1\tmessage\n2\tn\n1\tnecessary\n12\tnext\n9\tnode\n4\tof\n1\ton\n1\tor\n1\totherwise\n2\tout\n8\tp\n3\tprint\n2\tprintf\n16\treturn\n5\tright\n4\troot\n25\ts\n2\tstorage\n3\tstrcmp\n1\tstrcpy\n1\tstrlen\n8\tstruct\n1\tstructures\n2\tsubtree\n1\tt\n5\ttprint\n9\ttree\n1\tuses\n1\tversion\n1\twf\n3\twhile\n21\tword\n9\twords\n2\tz\n"
  },
  {
    "path": "lcc/x86/win32/tst/wf1.2bk",
    "content": "tst/wf1.c:29: warning: missing return value\ntst/wf1.c:87: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/win32/tst/wf1.sbk",
    "content": ".486\n.model flat\nextrn __fltused:near\nextrn __ftol:near\npublic _main\n_TEXT segment\n_main:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,24\nmov dword ptr (-24)[ebp],0\nmov dword ptr (_next),0\njmp L3\nL2:\nlea edi,(-24)[ebp]\npush edi\nlea edi,(-20)[ebp]\npush edi\ncall _lookup\nadd esp,8\ninc dword ptr [eax]\nL3:\nlea edi,(-20)[ebp]\npush edi\ncall _getword\nadd esp,4\ncmp eax,0\njne L2\nmov edi,dword ptr (-24)[ebp]\npush edi\ncall _tprint\nadd esp,4\nmov eax,0\nL1:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _err\n_err:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov edi,dword ptr (20)[ebp]\npush edi\nlea edi,(L6)\npush edi\ncall _printf\nadd esp,8\npush 1\ncall _exit\nadd esp,4\nmov eax,0\nL5:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _getword\n_getword:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,8\nL8:\nL9:\ncall _getchar\nadd esp,0\nmov dword ptr (-4)[ebp],eax\ncmp eax,-1\nje L11\nmov edi,dword ptr (-4)[ebp]\npush edi\ncall _isletter\nadd esp,4\ncmp eax,0\nje L8\nL11:\nmov edi,dword ptr (20)[ebp]\nmov dword ptr (-8)[ebp],edi\njmp L15\nL12:\nmov edi,dword ptr (-8)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-8)[ebp],esi\nmov esi,dword ptr (-4)[ebp]\nmov ebx,esi\nmov byte ptr [edi],bl\nL13:\ncall _getchar\nadd esp,0\nmov dword ptr (-4)[ebp],eax\nL15:\nmov edi,dword ptr (-4)[ebp]\npush edi\ncall _isletter\nadd esp,4\nmov dword ptr (-4)[ebp],eax\ncmp eax,0\njne L12\nmov edi,dword ptr (-8)[ebp]\nmov byte ptr [edi],0\nmov edi,dword ptr (-8)[ebp]\nmov esi,dword ptr (20)[ebp]\ncmp edi,esi\njbe L16\nmov eax,1\njmp L7\nL16:\nmov eax,0\nL7:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _isletter\n_isletter:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov edi,dword ptr (20)[ebp]\ncmp edi,65\njl L19\ncmp edi,90\njg L19\nadd dword ptr (20)[ebp],32\nL19:\nmov edi,dword ptr (20)[ebp]\ncmp edi,97\njl L21\ncmp edi,122\njg L21\nmov eax,dword ptr (20)[ebp]\njmp L18\nL21:\nmov eax,0\nL18:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _lookup\n_lookup:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\nmov edi,dword ptr (24)[ebp]\nmov edi,dword ptr [edi]\ncmp edi,0\nje L24\nmov edi,dword ptr (24)[ebp]\nmov edi,dword ptr [edi]\nmov edi,dword ptr (12)[edi]\npush edi\nmov edi,dword ptr (20)[ebp]\npush edi\ncall _strcmp\nadd esp,8\nmov dword ptr (-4)[ebp],eax\ncmp dword ptr (-4)[ebp],0\njge L26\nmov edi,dword ptr (24)[ebp]\nmov edi,dword ptr [edi]\nlea edi,(4)[edi]\npush edi\nmov edi,dword ptr (20)[ebp]\npush edi\ncall _lookup\nadd esp,8\nmov edi,eax\njmp L23\nL26:\ncmp dword ptr (-4)[ebp],0\njle L28\nmov edi,dword ptr (24)[ebp]\nmov edi,dword ptr [edi]\nlea edi,(8)[edi]\npush edi\nmov edi,dword ptr (20)[ebp]\npush edi\ncall _lookup\nadd esp,8\nmov edi,eax\njmp L23\nL28:\nmov edi,dword ptr (24)[ebp]\nmov eax,dword ptr [edi]\njmp L23\nL24:\ncmp dword ptr (_next),2000\njl L30\nlea edi,(L32)\npush edi\ncall _err\nadd esp,4\nL30:\nmov edi,dword ptr (_next)\nsal edi,4\nmov dword ptr (_words)[edi],0\nmov edi,dword ptr (_next)\nsal edi,4\nmov dword ptr (_words+8)[edi],0\nmov dword ptr (_words+4)[edi],0\nmov edi,dword ptr (20)[ebp]\npush edi\ncall _strlen\nadd esp,4\nlea edi,(1)[eax]\npush edi\ncall _malloc\nadd esp,4\nmov esi,dword ptr (_next)\nsal esi,4\nmov dword ptr (_words+12)[esi],eax\nmov edi,dword ptr (_next)\nsal edi,4\nmov edi,dword ptr (_words+12)[edi]\ncmp edi,0\njne L36\nlea edi,(L39)\npush edi\ncall _err\nadd esp,4\nL36:\nmov edi,dword ptr (20)[ebp]\npush edi\nmov edi,dword ptr (_next)\nsal edi,4\nmov edi,dword ptr (_words+12)[edi]\npush edi\ncall _strcpy\nadd esp,8\nmov edi,dword ptr (_next)\nlea esi,(1)[edi]\nmov dword ptr (_next),esi\nsal edi,4\nlea edi,(_words)[edi]\nmov esi,dword ptr (24)[ebp]\nmov dword ptr [esi],edi\nmov eax,edi\nL23:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _tprint\n_tprint:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov edi,dword ptr (20)[ebp]\ncmp edi,0\nje L42\nmov edi,dword ptr (20)[ebp]\nmov edi,dword ptr (4)[edi]\npush edi\ncall _tprint\nadd esp,4\nmov edi,dword ptr (20)[ebp]\nmov esi,dword ptr (12)[edi]\npush esi\nmov edi,dword ptr [edi]\npush edi\nlea edi,(L44)\npush edi\ncall _printf\nadd esp,12\nmov edi,dword ptr (20)[ebp]\nmov edi,dword ptr (8)[edi]\npush edi\ncall _tprint\nadd esp,4\nL42:\nmov eax,0\nL41:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _strcmp\n_strcmp:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\njmp L47\nL46:\nmov edi,dword ptr (20)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (20)[ebp],esi\nmovsx edi,byte ptr [edi]\ncmp edi,0\njne L49\nmov eax,0\njmp L45\nL49:\ninc dword ptr (24)[ebp]\nL47:\nmov edi,dword ptr (20)[ebp]\nmovsx edi,byte ptr [edi]\nmov esi,dword ptr (24)[ebp]\nmovsx esi,byte ptr [esi]\ncmp edi,esi\nje L46\nmov edi,dword ptr (20)[ebp]\nmovsx edi,byte ptr [edi]\ncmp edi,0\njne L51\nmov eax,-1\njmp L45\nL51:\nmov edi,dword ptr (24)[ebp]\nmovsx edi,byte ptr [edi]\ncmp edi,0\njne L53\nmov eax,1\njmp L45\nL53:\nmov edi,dword ptr (20)[ebp]\nmovsx edi,byte ptr [edi]\nmov esi,dword ptr (24)[ebp]\nmovsx esi,byte ptr [esi]\nmov eax,edi\nsub eax,esi\nL45:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\nextrn _strcpy:near\n_TEXT segment\n_TEXT ends\nextrn _strlen:near\n_TEXT segment\n_TEXT ends\nextrn _malloc:near\n_TEXT segment\n_TEXT ends\nextrn _getchar:near\n_TEXT segment\n_TEXT ends\nextrn _exit:near\n_TEXT segment\n_TEXT ends\nextrn _printf:near\n_TEXT segment\n_TEXT ends\n_DATA segment\npublic _next\nalign 4\n_next label byte\ndb 4 dup (0)\npublic _words\nalign 4\n_words label byte\ndb 32000 dup (0)\n_DATA ends\n_TEXT segment\nalign 1\nL44 label byte\ndb 37\ndb 100\ndb 9\ndb 37\ndb 115\ndb 10\ndb 0\nalign 1\nL39 label byte\ndb 111\ndb 117\ndb 116\ndb 32\ndb 111\ndb 102\ndb 32\ndb 119\ndb 111\ndb 114\ndb 100\ndb 32\ndb 115\ndb 116\ndb 111\ndb 114\ndb 97\ndb 103\ndb 101\ndb 0\nalign 1\nL32 label byte\ndb 111\ndb 117\ndb 116\ndb 32\ndb 111\ndb 102\ndb 32\ndb 110\ndb 111\ndb 100\ndb 101\ndb 32\ndb 115\ndb 116\ndb 111\ndb 114\ndb 97\ndb 103\ndb 101\ndb 0\nalign 1\nL6 label byte\ndb 63\ndb 32\ndb 37\ndb 115\ndb 10\ndb 0\n_TEXT ends\nend\n"
  },
  {
    "path": "lcc/x86/win32/tst/yacc.1bk",
    "content": "a\nb\nload\nnegate\npush 5\nc\nload\nmultiply\nadd\nstore\n"
  },
  {
    "path": "lcc/x86/win32/tst/yacc.2bk",
    "content": "tst/yacc.c:345: warning: missing return value\ntst/yacc.c:349: warning: missing return value\ntst/yacc.c:359: warning: missing return value\n"
  },
  {
    "path": "lcc/x86/win32/tst/yacc.sbk",
    "content": ".486\n.model flat\nextrn __fltused:near\nextrn __ftol:near\n_DATA segment\npublic _yyin\nalign 4\n_yyin label byte\ndd __iob\npublic _yyout\nalign 4\n_yyout label byte\ndd __iob+32\npublic _yylex\n_DATA ends\n_TEXT segment\n_yylex:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,4\njmp L4\nL3:\nL6:\nmov edi,dword ptr (-4)[ebp]\ncmp edi,-1\njl L7\ncmp edi,4\njg L7\njmp dword ptr (L18+4)[edi*4]\n_TEXT ends\n_TEXT segment\nalign 4\nL18 label byte\ndd L8\ndd L9\ndd L12\ndd L13\ndd L8\ndd L15\n_TEXT ends\n_TEXT segment\nL9:\ncall _yywrap\nadd esp,0\ncmp eax,0\nje L8\nmov eax,0\njmp L2\nL12:\nmov eax,257\njmp L2\nL13:\nmov eax,258\njmp L2\nL15:\nmovsx eax,byte ptr (_yytext)\njmp L2\nL7:\nmov edi,dword ptr (-4)[ebp]\npush edi\nlea edi,(L17)\npush edi\nmov edi,dword ptr (_yyout)\npush edi\ncall _fprintf\nadd esp,12\nL8:\nL4:\ncall _yylook\nadd esp,0\nmov dword ptr (-4)[ebp],eax\ncmp eax,0\njge L3\nmov eax,0\nL2:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\npublic _yyvstop\nalign 4\n_yyvstop label byte\ndd 0\ndd 4\ndd 0\ndd 3\ndd 4\ndd 0\ndd 2\ndd 4\ndd 0\ndd 1\ndd 4\ndd 0\ndd 2\ndd 0\ndd 1\ndd 0\ndd 0\npublic _yycrank\nalign 4\n_yycrank label byte\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 1\ndb 3\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 1\ndb 4\ndb 2 dup (0)\ndb 1\ndb 3\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 1\ndb 5\ndb 2 dup (0)\ndb 5\ndb 7\ndb 2 dup (0)\ndb 5\ndb 7\ndb 2 dup (0)\ndb 5\ndb 7\ndb 2 dup (0)\ndb 5\ndb 7\ndb 2 dup (0)\ndb 5\ndb 7\ndb 2 dup (0)\ndb 5\ndb 7\ndb 2 dup (0)\ndb 5\ndb 7\ndb 2 dup (0)\ndb 5\ndb 7\ndb 2 dup (0)\ndb 5\ndb 7\ndb 2 dup (0)\ndb 5\ndb 7\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 1\ndb 6\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 6\ndb 8\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\ndb 0\ndb 0\ndb 2 dup (0)\npublic _yysvec\nalign 4\n_yysvec label byte\ndd 00H\ndd 00H\ndd 00H\ndd _yycrank-4\ndd 00H\ndd 00H\ndd _yycrank\ndd _yysvec+12\ndd 00H\ndd _yycrank\ndd 00H\ndd _yyvstop+4\ndd _yycrank\ndd 00H\ndd _yyvstop+12\ndd _yycrank+8\ndd 00H\ndd _yyvstop+24\ndd _yycrank+76\ndd 00H\ndd _yyvstop+36\ndd _yycrank\ndd _yysvec+60\ndd _yyvstop+48\ndd _yycrank\ndd _yysvec+72\ndd _yyvstop+56\ndd 00H\ndd 00H\ndd 00H\npublic _yytop\nalign 4\n_yytop label byte\ndd _yycrank+564\npublic _yybgin\nalign 4\n_yybgin label byte\ndd _yysvec+12\npublic _yymatch\nalign 1\n_yymatch label byte\ndb 0\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 9\ndb 10\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 9\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 48\ndb 48\ndb 48\ndb 48\ndb 48\ndb 48\ndb 48\ndb 48\ndb 48\ndb 48\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 1\ndb 1\ndb 1\ndb 1\ndb 65\ndb 1\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 65\ndb 1\ndb 1\ndb 1\ndb 1\ndb 1\ndb 0\npublic _yyextra\nalign 1\n_yyextra label byte\ndb 0\ndb 0\ndb 0\ndb 0\ndb 0\ndb 0\ndb 0\ndb 0\ndb 0\npublic _yylineno\nalign 4\n_yylineno label byte\ndd 1\npublic _yysptr\nalign 4\n_yysptr label byte\ndd _yysbuf\npublic _yyprevious\nalign 4\n_yyprevious label byte\ndd 10\npublic _yylook\n_DATA ends\n_TEXT segment\n_yylook:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,44\ncmp dword ptr (_yymorfg),0\njne L35\nlea edi,(_yytext)\nmov dword ptr (-16)[ebp],edi\njmp L36\nL35:\nmov dword ptr (_yymorfg),0\nmov edi,dword ptr (_yyleng)\nlea edi,(_yytext)[edi]\nmov dword ptr (-16)[ebp],edi\nL36:\nL37:\nlea edi,(_yylstate)\nmov dword ptr (-8)[ebp],edi\nmov edi,dword ptr (_yybgin)\nmov dword ptr (-4)[ebp],edi\nmov dword ptr (_yyestate),edi\ncmp dword ptr (_yyprevious),10\njne L41\nmov edi,dword ptr (-4)[ebp]\nlea edi,(12)[edi]\nmov dword ptr (-4)[ebp],edi\nL41:\nL43:\nmov edi,dword ptr (-4)[ebp]\nmov edi,dword ptr [edi]\nmov dword ptr (-12)[ebp],edi\nmov edi,dword ptr (-12)[ebp]\nlea esi,(_yycrank)\ncmp edi,esi\njne L47\nmov edi,dword ptr (-4)[ebp]\nmov edi,dword ptr (4)[edi]\nmov dword ptr (-28)[ebp],edi\nmov edi,dword ptr (-28)[ebp]\ncmp edi,0\njne L49\njmp L94\nL49:\nmov edi,dword ptr (-28)[ebp]\nmov edi,dword ptr [edi]\nlea esi,(_yycrank)\ncmp edi,esi\njne L51\njmp L94\nL51:\nL47:\nmov edi,dword ptr (-16)[ebp]\nlea esi,(1)[edi]\nmov dword ptr (-16)[ebp],esi\nmov esi,dword ptr (_yysptr)\nlea ebx,(_yysbuf)\ncmp esi,ebx\njbe L61\nmov esi,dword ptr (_yysptr)\nlea esi,(-1)[esi]\nmov dword ptr (_yysptr),esi\nmovsx esi,byte ptr [esi]\nmov dword ptr (-40)[ebp],esi\njmp L62\nL61:\nmov esi,dword ptr (_yyin)\nlea esi,(4)[esi]\nmov ebx,dword ptr [esi]\nsub ebx,1\nmov dword ptr [esi],ebx\ncmp ebx,0\njl L63\nmov esi,dword ptr (_yyin)\nmov ebx,dword ptr [esi]\nlea edx,(1)[ebx]\nmov dword ptr [esi],edx\nmovsx esi,byte ptr [ebx]\nand esi,255\nmov dword ptr (-44)[ebp],esi\njmp L64\nL63:\nmov esi,dword ptr (_yyin)\npush esi\ncall __filbuf\nadd esp,4\nmov esi,eax\nmov dword ptr (-44)[ebp],esi\nL64:\nmov esi,dword ptr (-44)[ebp]\nmov dword ptr (-40)[ebp],esi\nL62:\nmov esi,dword ptr (-40)[ebp]\nmov dword ptr (_yytchar),esi\ncmp esi,10\njne L59\ninc dword ptr (_yylineno)\nmov esi,dword ptr (_yytchar)\nmov dword ptr (-36)[ebp],esi\njmp L60\nL59:\nmov esi,dword ptr (_yytchar)\nmov dword ptr (-36)[ebp],esi\nL60:\ncmp dword ptr (-36)[ebp],-1\njne L57\nmov dword ptr (-32)[ebp],0\njmp L58\nL57:\nmov esi,dword ptr (_yytchar)\nmov dword ptr (-32)[ebp],esi\nL58:\nmov esi,dword ptr (-32)[ebp]\nmov dword ptr (-20)[ebp],esi\nmov ebx,esi\nmov byte ptr [edi],bl\nL65:\nmov edi,dword ptr (-12)[ebp]\nmov dword ptr (-24)[ebp],edi\nlea esi,(_yycrank)\ncmp edi,esi\njbe L66\nmov edi,dword ptr (-20)[ebp]\nmov esi,dword ptr (-24)[ebp]\nlea edi,[esi][edi*4]\nmov dword ptr (-12)[ebp],edi\nmov edi,dword ptr (-12)[ebp]\nmov esi,edi\nmov ebx,dword ptr (_yytop)\ncmp esi,ebx\nja L67\nmovsx edi,byte ptr [edi]\nimul edi,edi,12\nlea edi,(_yysvec)[edi]\nmov esi,dword ptr (-4)[ebp]\ncmp edi,esi\njne L67\nlea edi,(_yysvec)\nmov esi,dword ptr (-12)[ebp]\nmovsx esi,byte ptr (1)[esi]\nimul esi,esi,12\nlea esi,(_yysvec)[esi]\ncmp esi,edi\njne L70\nmov edi,dword ptr (-16)[ebp]\nlea edi,(-1)[edi]\nmov dword ptr (-16)[ebp],edi\nmovsx edi,byte ptr [edi]\nmov dword ptr (_yytchar),edi\ncmp dword ptr (_yytchar),10\njne L72\ndec dword ptr (_yylineno)\nL72:\nmov edi,dword ptr (_yysptr)\nlea esi,(1)[edi]\nmov dword ptr (_yysptr),esi\nmov esi,dword ptr (_yytchar)\nmov ebx,esi\nmov byte ptr [edi],bl\njmp L94\nL70:\nmov edi,dword ptr (-8)[ebp]\nlea esi,(4)[edi]\nmov dword ptr (-8)[ebp],esi\nmov esi,dword ptr (-12)[ebp]\nmovsx esi,byte ptr (1)[esi]\nimul esi,esi,12\nlea esi,(_yysvec)[esi]\nmov dword ptr (-4)[ebp],esi\nmov dword ptr [edi],esi\njmp L43\nL66:\nmov edi,dword ptr (-12)[ebp]\nlea esi,(_yycrank)\ncmp edi,esi\njae L75\nlea edi,(_yycrank)\nmov esi,dword ptr (-12)[ebp]\nsub edi,esi\nmov eax,edi\nmov edi,4\ncdq\nidiv edi\nlea edi,(_yycrank)[eax*4]\nmov dword ptr (-24)[ebp],edi\nmov dword ptr (-12)[ebp],edi\nmov edi,dword ptr (-20)[ebp]\nmov esi,dword ptr (-12)[ebp]\nlea edi,[esi][edi*4]\nmov dword ptr (-12)[ebp],edi\nmov edi,dword ptr (-12)[ebp]\nmov esi,edi\nmov ebx,dword ptr (_yytop)\ncmp esi,ebx\nja L77\nmovsx edi,byte ptr [edi]\nimul edi,edi,12\nlea edi,(_yysvec)[edi]\nmov esi,dword ptr (-4)[ebp]\ncmp edi,esi\njne L77\nlea edi,(_yysvec)\nmov esi,dword ptr (-12)[ebp]\nmovsx esi,byte ptr (1)[esi]\nimul esi,esi,12\nlea esi,(_yysvec)[esi]\ncmp esi,edi\njne L79\nmov edi,dword ptr (-16)[ebp]\nlea edi,(-1)[edi]\nmov dword ptr (-16)[ebp],edi\nmovsx edi,byte ptr [edi]\nmov dword ptr (_yytchar),edi\ncmp dword ptr (_yytchar),10\njne L81\ndec dword ptr (_yylineno)\nL81:\nmov edi,dword ptr (_yysptr)\nlea esi,(1)[edi]\nmov dword ptr (_yysptr),esi\nmov esi,dword ptr (_yytchar)\nmov ebx,esi\nmov byte ptr [edi],bl\njmp L94\nL79:\nmov edi,dword ptr (-8)[ebp]\nlea esi,(4)[edi]\nmov dword ptr (-8)[ebp],esi\nmov esi,dword ptr (-12)[ebp]\nmovsx esi,byte ptr (1)[esi]\nimul esi,esi,12\nlea esi,(_yysvec)[esi]\nmov dword ptr (-4)[ebp],esi\nmov dword ptr [edi],esi\njmp L43\nL77:\nmov edi,dword ptr (-20)[ebp]\nmovsx edi,byte ptr (_yymatch)[edi]\nmov esi,dword ptr (-24)[ebp]\nlea edi,[esi][edi*4]\nmov dword ptr (-12)[ebp],edi\nmov edi,dword ptr (-12)[ebp]\nmov esi,edi\nmov ebx,dword ptr (_yytop)\ncmp esi,ebx\nja L83\nmovsx edi,byte ptr [edi]\nimul edi,edi,12\nlea edi,(_yysvec)[edi]\nmov esi,dword ptr (-4)[ebp]\ncmp edi,esi\njne L83\nlea edi,(_yysvec)\nmov esi,dword ptr (-12)[ebp]\nmovsx esi,byte ptr (1)[esi]\nimul esi,esi,12\nlea esi,(_yysvec)[esi]\ncmp esi,edi\njne L85\nmov edi,dword ptr (-16)[ebp]\nlea edi,(-1)[edi]\nmov dword ptr (-16)[ebp],edi\nmovsx edi,byte ptr [edi]\nmov dword ptr (_yytchar),edi\ncmp dword ptr (_yytchar),10\njne L87\ndec dword ptr (_yylineno)\nL87:\nmov edi,dword ptr (_yysptr)\nlea esi,(1)[edi]\nmov dword ptr (_yysptr),esi\nmov esi,dword ptr (_yytchar)\nmov ebx,esi\nmov byte ptr [edi],bl\njmp L94\nL85:\nmov edi,dword ptr (-8)[ebp]\nlea esi,(4)[edi]\nmov dword ptr (-8)[ebp],esi\nmov esi,dword ptr (-12)[ebp]\nmovsx esi,byte ptr (1)[esi]\nimul esi,esi,12\nlea esi,(_yysvec)[esi]\nmov dword ptr (-4)[ebp],esi\nmov dword ptr [edi],esi\njmp L43\nL83:\nL75:\nL67:\nmov edi,dword ptr (-4)[ebp]\nmov edi,dword ptr (4)[edi]\nmov dword ptr (-4)[ebp],edi\ncmp edi,0\nje L89\nmov edi,dword ptr (-4)[ebp]\nmov edi,dword ptr [edi]\nmov dword ptr (-12)[ebp],edi\nlea esi,(_yycrank)\ncmp edi,esi\nje L89\njmp L65\nL89:\nmov edi,dword ptr (-16)[ebp]\nlea edi,(-1)[edi]\nmov dword ptr (-16)[ebp],edi\nmovsx edi,byte ptr [edi]\nmov dword ptr (_yytchar),edi\ncmp dword ptr (_yytchar),10\njne L91\ndec dword ptr (_yylineno)\nL91:\nmov edi,dword ptr (_yysptr)\nlea esi,(1)[edi]\nmov dword ptr (_yysptr),esi\nmov esi,dword ptr (_yytchar)\nmov ebx,esi\nmov byte ptr [edi],bl\njmp L94\nL93:\nmov edi,dword ptr (-16)[ebp]\nlea esi,(-1)[edi]\nmov dword ptr (-16)[ebp],esi\nmov byte ptr [edi],0\nmov edi,dword ptr (-8)[ebp]\nmov edi,dword ptr [edi]\nmov esi,edi\ncmp esi,0\nje L96\nmov edi,dword ptr (8)[edi]\nmov dword ptr (_yyfnd),edi\ncmp edi,0\nje L96\nmov edi,dword ptr (_yyfnd)\ncmp dword ptr [edi],0\njle L96\nmov edi,dword ptr (-8)[ebp]\nmov dword ptr (_yyolsp),edi\nmov edi,dword ptr (_yyfnd)\nmov edi,dword ptr [edi]\nmovsx edi,byte ptr (_yyextra)[edi]\ncmp edi,0\nje L98\njmp L101\nL100:\nmov edi,dword ptr (-8)[ebp]\nlea edi,(-4)[edi]\nmov dword ptr (-8)[ebp],edi\nmov edi,dword ptr (-16)[ebp]\nlea esi,(-1)[edi]\nmov dword ptr (-16)[ebp],esi\nmovsx edi,byte ptr [edi]\nmov dword ptr (_yytchar),edi\ncmp dword ptr (_yytchar),10\njne L103\ndec dword ptr (_yylineno)\nL103:\nmov edi,dword ptr (_yysptr)\nlea esi,(1)[edi]\nmov dword ptr (_yysptr),esi\nmov esi,dword ptr (_yytchar)\nmov ebx,esi\nmov byte ptr [edi],bl\nL101:\nmov edi,dword ptr (_yyfnd)\nmov edi,dword ptr [edi]\nneg edi\npush edi\nmov edi,dword ptr (-8)[ebp]\nmov edi,dword ptr [edi]\nmov edi,dword ptr (8)[edi]\npush edi\ncall _yyback\nadd esp,8\ncmp eax,1\nje L105\nmov edi,dword ptr (-8)[ebp]\nlea esi,(_yylstate)\ncmp edi,esi\nja L100\nL105:\nL98:\nmov edi,dword ptr (-16)[ebp]\nmovsx esi,byte ptr [edi]\nmov dword ptr (_yyprevious),esi\nmov esi,dword ptr (-8)[ebp]\nmov dword ptr (_yylsp),esi\nlea esi,(_yytext)\nsub edi,esi\nlea edi,(1)[edi]\nmov dword ptr (_yyleng),edi\nmov edi,dword ptr (_yyleng)\nmov byte ptr (_yytext)[edi],0\nmov edi,dword ptr (_yyfnd)\nlea esi,(4)[edi]\nmov dword ptr (_yyfnd),esi\nmov eax,dword ptr [edi]\njmp L34\nL96:\nmov edi,dword ptr (-16)[ebp]\nmovsx edi,byte ptr [edi]\nmov dword ptr (_yytchar),edi\ncmp dword ptr (_yytchar),10\njne L106\ndec dword ptr (_yylineno)\nL106:\nmov edi,dword ptr (_yysptr)\nlea esi,(1)[edi]\nmov dword ptr (_yysptr),esi\nmov esi,dword ptr (_yytchar)\nmov ebx,esi\nmov byte ptr [edi],bl\nL94:\nmov edi,dword ptr (-8)[ebp]\nlea esi,(-4)[edi]\nmov dword ptr (-8)[ebp],esi\nlea esi,(_yylstate)\ncmp edi,esi\nja L93\nmovsx edi,byte ptr (_yytext)\ncmp edi,0\njne L108\nlea edi,(_yysbuf)\nmov dword ptr (_yysptr),edi\nmov eax,0\njmp L34\nL108:\nmov edi,dword ptr (_yysptr)\nlea esi,(_yysbuf)\ncmp edi,esi\njbe L118\nmov edi,dword ptr (_yysptr)\nlea edi,(-1)[edi]\nmov dword ptr (_yysptr),edi\nmovsx edi,byte ptr [edi]\nmov dword ptr (-40)[ebp],edi\njmp L119\nL118:\nmov edi,dword ptr (_yyin)\nlea edi,(4)[edi]\nmov esi,dword ptr [edi]\nsub esi,1\nmov dword ptr [edi],esi\ncmp esi,0\njl L120\nmov edi,dword ptr (_yyin)\nmov esi,dword ptr [edi]\nlea ebx,(1)[esi]\nmov dword ptr [edi],ebx\nmovsx edi,byte ptr [esi]\nand edi,255\nmov dword ptr (-44)[ebp],edi\njmp L121\nL120:\nmov edi,dword ptr (_yyin)\npush edi\ncall __filbuf\nadd esp,4\nmov edi,eax\nmov dword ptr (-44)[ebp],edi\nL121:\nmov edi,dword ptr (-44)[ebp]\nmov dword ptr (-40)[ebp],edi\nL119:\nmov edi,dword ptr (-40)[ebp]\nmov dword ptr (_yytchar),edi\ncmp edi,10\njne L116\ninc dword ptr (_yylineno)\nmov edi,dword ptr (_yytchar)\nmov dword ptr (-36)[ebp],edi\njmp L117\nL116:\nmov edi,dword ptr (_yytchar)\nmov dword ptr (-36)[ebp],edi\nL117:\ncmp dword ptr (-36)[ebp],-1\njne L114\nmov dword ptr (-32)[ebp],0\njmp L115\nL114:\nmov edi,dword ptr (_yytchar)\nmov dword ptr (-32)[ebp],edi\nL115:\nmov edi,dword ptr (-32)[ebp]\nmov ebx,edi\nmov byte ptr (_yytext),bl\nmovsx edi,bl\nmov dword ptr (_yyprevious),edi\ncmp dword ptr (_yyprevious),0\njle L122\nmov edi,dword ptr (_yyout)\nlea edi,(4)[edi]\nmov esi,dword ptr [edi]\nsub esi,1\nmov dword ptr [edi],esi\ncmp esi,0\njl L125\nmov edi,dword ptr (_yyout)\nmov esi,dword ptr [edi]\nlea ebx,(1)[esi]\nmov dword ptr [edi],ebx\nmov edi,dword ptr (_yyprevious)\nmov ebx,edi\nmov byte ptr [esi],bl\njmp L126\nL125:\nmov edi,dword ptr (_yyout)\npush edi\nmov edi,dword ptr (_yyprevious)\npush edi\ncall __flsbuf\nadd esp,8\nL126:\nL122:\nlea edi,(_yytext)\nmov dword ptr (-16)[ebp],edi\njmp L37\nL34:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _yyback\n_yyback:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov edi,dword ptr (20)[ebp]\ncmp edi,0\njne L131\nmov eax,0\njmp L127\nL130:\nmov edi,dword ptr (20)[ebp]\nlea esi,(4)[edi]\nmov dword ptr (20)[ebp],esi\nmov esi,dword ptr (24)[ebp]\ncmp dword ptr [edi],esi\njne L133\nmov eax,1\njmp L127\nL133:\nL131:\nmov edi,dword ptr (20)[ebp]\ncmp dword ptr [edi],0\njne L130\nmov eax,0\nL127:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _yyinput\n_yyinput:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,16\nmov edi,dword ptr (_yysptr)\nlea esi,(_yysbuf)\ncmp edi,esi\njbe L144\nmov edi,dword ptr (_yysptr)\nlea edi,(-1)[edi]\nmov dword ptr (_yysptr),edi\nmovsx edi,byte ptr [edi]\nmov dword ptr (-12)[ebp],edi\njmp L145\nL144:\nmov edi,dword ptr (_yyin)\nlea edi,(4)[edi]\nmov esi,dword ptr [edi]\nsub esi,1\nmov dword ptr [edi],esi\ncmp esi,0\njl L146\nmov edi,dword ptr (_yyin)\nmov esi,dword ptr [edi]\nlea ebx,(1)[esi]\nmov dword ptr [edi],ebx\nmovsx edi,byte ptr [esi]\nand edi,255\nmov dword ptr (-16)[ebp],edi\njmp L147\nL146:\nmov edi,dword ptr (_yyin)\npush edi\ncall __filbuf\nadd esp,4\nmov edi,eax\nmov dword ptr (-16)[ebp],edi\nL147:\nmov edi,dword ptr (-16)[ebp]\nmov dword ptr (-12)[ebp],edi\nL145:\nmov edi,dword ptr (-12)[ebp]\nmov dword ptr (_yytchar),edi\ncmp edi,10\njne L142\ninc dword ptr (_yylineno)\nmov edi,dword ptr (_yytchar)\nmov dword ptr (-8)[ebp],edi\njmp L143\nL142:\nmov edi,dword ptr (_yytchar)\nmov dword ptr (-8)[ebp],edi\nL143:\ncmp dword ptr (-8)[ebp],-1\njne L140\nmov dword ptr (-4)[ebp],0\njmp L141\nL140:\nmov edi,dword ptr (_yytchar)\nmov dword ptr (-4)[ebp],edi\nL141:\nmov eax,dword ptr (-4)[ebp]\nL135:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _yyoutput\n_yyoutput:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov edi,dword ptr (_yyout)\nlea edi,(4)[edi]\nmov esi,dword ptr [edi]\nsub esi,1\nmov dword ptr [edi],esi\ncmp esi,0\njl L150\nmov edi,dword ptr (_yyout)\nmov esi,dword ptr [edi]\nlea ebx,(1)[esi]\nmov dword ptr [edi],ebx\nmov edi,dword ptr (20)[ebp]\nmov ebx,edi\nmov byte ptr [esi],bl\njmp L151\nL150:\nmov edi,dword ptr (_yyout)\npush edi\nmov edi,dword ptr (20)[ebp]\npush edi\ncall __flsbuf\nadd esp,8\nL151:\nmov eax,0\nL148:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _yyunput\n_yyunput:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov edi,dword ptr (20)[ebp]\nmov dword ptr (_yytchar),edi\ncmp dword ptr (_yytchar),10\njne L153\ndec dword ptr (_yylineno)\nL153:\nmov edi,dword ptr (_yysptr)\nlea esi,(1)[edi]\nmov dword ptr (_yysptr),esi\nmov esi,dword ptr (_yytchar)\nmov ebx,esi\nmov byte ptr [edi],bl\nmov eax,0\nL152:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _main\n_main:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\ncall _yyparse\nadd esp,0\nmov eax,0\nL155:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _yyerror\n_yyerror:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov edi,dword ptr (20)[ebp]\npush edi\nlea edi,(L157)\npush edi\ncall _printf\nadd esp,8\nmov eax,0\nL156:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\npublic _yyexca\nalign 2\n_yyexca label byte\ndw -1\ndw 1\ndw 0\ndw -1\ndw -2\ndw 0\npublic _yyact\nalign 2\n_yyact label byte\ndw 12\ndw 2\ndw 9\ndw 8\ndw 17\ndw 11\ndw 25\ndw 17\ndw 15\ndw 18\ndw 16\ndw 10\ndw 18\ndw 17\ndw 15\ndw 7\ndw 16\ndw 13\ndw 18\ndw 5\ndw 3\ndw 1\ndw 0\ndw 19\ndw 20\ndw 0\ndw 0\ndw 21\ndw 22\ndw 23\ndw 24\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 6\ndw 14\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 0\ndw 4\ndw 6\npublic _yypact\nalign 2\n_yypact label byte\ndw -1000\ndw -9\ndw -1000\ndw 5\ndw -7\ndw -59\ndw -1000\ndw -1000\ndw -1000\ndw -40\ndw -29\ndw -40\ndw -40\ndw -1000\ndw -1000\ndw -40\ndw -40\ndw -40\ndw -40\ndw -38\ndw -35\ndw -38\ndw -38\ndw -1000\ndw -1000\ndw -1000\npublic _yypgo\nalign 2\n_yypgo label byte\ndw 0\ndw 21\ndw 20\ndw 17\ndw 11\npublic _yyr1\nalign 2\n_yyr1 label byte\ndw 0\ndw 1\ndw 1\ndw 1\ndw 1\ndw 2\ndw 4\ndw 4\ndw 4\ndw 4\ndw 4\ndw 4\ndw 4\ndw 4\ndw 3\npublic _yyr2\nalign 2\n_yyr2 label byte\ndw 0\ndw 0\ndw 2\ndw 3\ndw 3\ndw 3\ndw 3\ndw 3\ndw 3\ndw 3\ndw 2\ndw 3\ndw 1\ndw 1\ndw 1\npublic _yychk\nalign 2\n_yychk label byte\ndw -1000\ndw -1\ndw 10\ndw -2\ndw 256\ndw -3\ndw 257\ndw 10\ndw 10\ndw 61\ndw -4\ndw 45\ndw 40\ndw -3\ndw 258\ndw 43\ndw 45\ndw 42\ndw 47\ndw -4\ndw -4\ndw -4\ndw -4\ndw -4\ndw -4\ndw 41\npublic _yydef\nalign 2\n_yydef label byte\ndw 1\ndw -2\ndw 2\ndw 0\ndw 0\ndw 0\ndw 14\ndw 3\ndw 4\ndw 0\ndw 5\ndw 0\ndw 0\ndw 12\ndw 13\ndw 0\ndw 0\ndw 0\ndw 0\ndw 10\ndw 0\ndw 6\ndw 7\ndw 8\ndw 9\ndw 11\npublic _yychar\nalign 4\n_yychar label byte\ndd -1\npublic _yynerrs\nalign 4\n_yynerrs label byte\ndd 0\npublic _yyerrflag\nalign 2\n_yyerrflag label byte\ndw 0\npublic _yyparse\n_DATA ends\n_TEXT segment\n_yyparse:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nsub esp,332\nmov word ptr (-6)[ebp],0\nmov dword ptr (_yychar),-1\nmov dword ptr (_yynerrs),0\nmov word ptr (_yyerrflag),0\nlea edi,(-328)[ebp]\nmov dword ptr (-12)[ebp],edi\nlea edi,(_yyv-4)\nmov dword ptr (-20)[ebp],edi\nL161:\nmov edi,dword ptr (-12)[ebp]\nlea edi,(2)[edi]\nmov dword ptr (-12)[ebp],edi\nlea esi,(-26)[ebp]\ncmp edi,esi\njbe L162\nlea edi,(L165)\npush edi\ncall _yyerror\nadd esp,4\nmov eax,1\njmp L158\nL162:\nmov edi,dword ptr (-12)[ebp]\nmov si,word ptr (-6)[ebp]\nmov word ptr [edi],si\nmov edi,dword ptr (-20)[ebp]\nlea edi,(4)[edi]\nmov dword ptr (-20)[ebp],edi\nmov edi,dword ptr (-20)[ebp]\nmov esi,dword ptr (_yyval)\nmov dword ptr [edi],esi\nL166:\nmovsx edi,word ptr (-6)[ebp]\nmov di,word ptr (_yypact)[edi*2]\nmov word ptr (-14)[ebp],di\nmovsx edi,word ptr (-14)[ebp]\ncmp edi,-1000\njg L167\njmp L169\nL167:\ncmp dword ptr (_yychar),0\njge L170\ncall _yylex\nadd esp,0\nmov dword ptr (_yychar),eax\ncmp eax,0\njge L172\nmov dword ptr (_yychar),0\nL172:\nL170:\nmovsx edi,word ptr (-14)[ebp]\nmov esi,dword ptr (_yychar)\nlea edi,[esi][edi]\nmov word ptr (-14)[ebp],di\nmovsx edi,di\ncmp edi,0\njl L176\nmovsx edi,word ptr (-14)[ebp]\ncmp edi,249\njl L174\nL176:\njmp L169\nL174:\nmovsx edi,word ptr (-14)[ebp]\nmov di,word ptr (_yyact)[edi*2]\nmov word ptr (-14)[ebp],di\nmovsx edi,di\nmovsx edi,word ptr (_yychk)[edi*2]\ncmp edi,dword ptr (_yychar)\njne L177\nmov dword ptr (_yychar),-1\nmov edi,dword ptr (_yylval)\nmov dword ptr (_yyval),edi\nmov di,word ptr (-14)[ebp]\nmov word ptr (-6)[ebp],di\nmovsx edi,word ptr (_yyerrflag)\ncmp edi,0\njle L161\nmovsx edi,word ptr (_yyerrflag)\nsub edi,1\nmov word ptr (_yyerrflag),di\njmp L161\nL177:\nL169:\nmovsx edi,word ptr (-6)[ebp]\nmov di,word ptr (_yydef)[edi*2]\nmov word ptr (-14)[ebp],di\nmovsx edi,di\ncmp edi,-2\njne L181\ncmp dword ptr (_yychar),0\njge L183\ncall _yylex\nadd esp,0\nmov dword ptr (_yychar),eax\ncmp eax,0\njge L185\nmov dword ptr (_yychar),0\nL185:\nL183:\nlea edi,(_yyexca)\nmov dword ptr (-24)[ebp],edi\njmp L190\nL187:\nL188:\nmov edi,dword ptr (-24)[ebp]\nlea edi,(4)[edi]\nmov dword ptr (-24)[ebp],edi\nL190:\nmov edi,dword ptr (-24)[ebp]\nmovsx esi,word ptr [edi]\ncmp esi,-1\njne L187\nmovsx edi,word ptr (2)[edi]\nmovsx esi,word ptr (-6)[ebp]\ncmp edi,esi\njne L187\njmp L192\nL191:\nmov edi,dword ptr (-24)[ebp]\nmovsx edi,word ptr [edi]\ncmp edi,dword ptr (_yychar)\njne L194\njmp L193\nL194:\nL192:\nmov edi,dword ptr (-24)[ebp]\nlea edi,(4)[edi]\nmov dword ptr (-24)[ebp],edi\nmovsx edi,word ptr [edi]\ncmp edi,0\njge L191\nL193:\nmov edi,dword ptr (-24)[ebp]\nmov di,word ptr (2)[edi]\nmov word ptr (-14)[ebp],di\nmovsx edi,di\ncmp edi,0\njge L196\nmov eax,0\njmp L158\nL196:\nL181:\nmovsx edi,word ptr (-14)[ebp]\ncmp edi,0\njne L198\nmovsx edi,word ptr (_yyerrflag)\nmov dword ptr (-332)[ebp],edi\nmov edi,dword ptr (-332)[ebp]\ncmp edi,0\njl L200\ncmp edi,3\njg L200\njmp dword ptr (L216)[edi*4]\n_TEXT ends\n_TEXT segment\nalign 4\nL216 label byte\ndd L203\ndd L206\ndd L206\ndd L213\n_TEXT ends\n_TEXT segment\nL203:\nlea edi,(L204)\npush edi\ncall _yyerror\nadd esp,4\nL205:\ninc dword ptr (_yynerrs)\nL206:\nmov word ptr (_yyerrflag),3\njmp L208\nL207:\nmov edi,dword ptr (-12)[ebp]\nmovsx edi,word ptr [edi]\nmovsx edi,word ptr (_yypact)[edi*2]\nlea edi,(256)[edi]\nmov word ptr (-14)[ebp],di\nmovsx edi,word ptr (-14)[ebp]\ncmp edi,0\njl L210\ncmp edi,249\njge L210\nmovsx edi,word ptr (_yyact)[edi*2]\nmovsx edi,word ptr (_yychk)[edi*2]\ncmp edi,256\njne L210\nmovsx edi,word ptr (-14)[ebp]\nmov di,word ptr (_yyact)[edi*2]\nmov word ptr (-6)[ebp],di\njmp L161\nL210:\nmov edi,dword ptr (-12)[ebp]\nmovsx esi,word ptr [edi]\nmov si,word ptr (_yypact)[esi*2]\nmov word ptr (-14)[ebp],si\nlea edi,(-2)[edi]\nmov dword ptr (-12)[ebp],edi\nmov edi,dword ptr (-20)[ebp]\nlea edi,(-4)[edi]\nmov dword ptr (-20)[ebp],edi\nL208:\nmov edi,dword ptr (-12)[ebp]\nlea esi,(-326)[ebp]\ncmp edi,esi\njae L207\nL212:\nmov eax,1\njmp L158\nL213:\ncmp dword ptr (_yychar),0\njne L214\njmp L212\nL214:\nmov dword ptr (_yychar),-1\njmp L166\nL200:\nL198:\nmov di,word ptr (-14)[ebp]\nmovsx esi,di\nlea esi,[esi*2]\nlea ebx,(_yyr2)[esi]\nmov edx,dword ptr (-12)[ebp]\nmovsx ecx,word ptr [ebx]\nlea ecx,[ecx*2]\nsub edx,ecx\nmov dword ptr (-12)[ebp],edx\nmov edx,dword ptr (-20)[ebp]\nmov dword ptr (-4)[ebp],edx\nmovsx ebx,word ptr [ebx]\nlea ebx,[ebx*4]\nsub edx,ebx\nmov dword ptr (-20)[ebp],edx\nmov ebx,dword ptr (-20)[ebp]\nmov ebx,dword ptr (4)[ebx]\nmov dword ptr (_yyval),ebx\nmov word ptr (-328)[ebp],di\nmov di,word ptr (_yyr1)[esi]\nmov word ptr (-14)[ebp],di\nmovsx edi,word ptr (-14)[ebp]\nmovsx edi,word ptr (_yypgo)[edi*2]\nmov esi,dword ptr (-12)[ebp]\nmovsx esi,word ptr [esi]\nlea edi,[esi][edi]\nlea edi,(1)[edi]\nmov word ptr (-26)[ebp],di\nmovsx edi,word ptr (-26)[ebp]\ncmp edi,249\njge L219\nmov di,word ptr (_yyact)[edi*2]\nmov word ptr (-6)[ebp],di\nmovsx edi,di\nmovsx edi,word ptr (_yychk)[edi*2]\nmovsx esi,word ptr (-14)[ebp]\nneg esi\ncmp edi,esi\nje L217\nL219:\nmovsx edi,word ptr (-14)[ebp]\nmovsx edi,word ptr (_yypgo)[edi*2]\nmov di,word ptr (_yyact)[edi*2]\nmov word ptr (-6)[ebp],di\nL217:\nmovsx edi,word ptr (-328)[ebp]\nmov dword ptr (-332)[ebp],edi\nmov edi,dword ptr (-332)[ebp]\ncmp edi,4\njl L161\ncmp edi,14\njg L161\njmp dword ptr (L241-16)[edi*4]\n_TEXT ends\n_TEXT segment\nalign 4\nL241 label byte\ndd L223\ndd L224\ndd L226\ndd L228\ndd L230\ndd L232\ndd L234\ndd L161\ndd L236\ndd L238\ndd L240\n_TEXT ends\n_TEXT segment\nL223:\nmov word ptr (_yyerrflag),0\njmp L161\nL224:\nlea edi,(L225)\npush edi\ncall _printf\nadd esp,4\njmp L161\nL226:\nlea edi,(L227)\npush edi\ncall _printf\nadd esp,4\njmp L161\nL228:\nlea edi,(L229)\npush edi\ncall _printf\nadd esp,4\njmp L161\nL230:\nlea edi,(L231)\npush edi\ncall _printf\nadd esp,4\njmp L161\nL232:\nlea edi,(L233)\npush edi\ncall _printf\nadd esp,4\njmp L161\nL234:\nlea edi,(L235)\npush edi\ncall _printf\nadd esp,4\njmp L161\nL236:\nlea edi,(L237)\npush edi\ncall _printf\nadd esp,4\njmp L161\nL238:\nlea edi,(_yytext)\npush edi\nlea edi,(L239)\npush edi\ncall _printf\nadd esp,8\njmp L161\nL240:\nlea edi,(_yytext)\npush edi\nlea edi,(L157)\npush edi\ncall _printf\nadd esp,8\njmp L161\nL158:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\npublic _yywrap\n_yywrap:\npush ebx\npush esi\npush edi\npush ebp\nmov ebp,esp\nmov eax,1\nL243:\nmov esp,ebp\npop ebp\npop edi\npop esi\npop ebx\nret\n_TEXT ends\n_DATA segment\npublic _yyv\nalign 4\n_yyv label byte\ndb 600 dup (0)\npublic _yyfnd\nalign 4\n_yyfnd label byte\ndb 4 dup (0)\npublic _yyolsp\nalign 4\n_yyolsp label byte\ndb 4 dup (0)\npublic _yylsp\nalign 4\n_yylsp label byte\ndb 4 dup (0)\npublic _yylstate\nalign 4\n_yylstate label byte\ndb 800 dup (0)\npublic _yyestate\nalign 4\n_yyestate label byte\ndb 4 dup (0)\npublic _yytchar\nalign 4\n_yytchar label byte\ndb 4 dup (0)\npublic _yysbuf\nalign 1\n_yysbuf label byte\ndb 200 dup (0)\npublic _yymorfg\nalign 4\n_yymorfg label byte\ndb 4 dup (0)\npublic _yytext\nalign 1\n_yytext label byte\ndb 200 dup (0)\npublic _yyleng\nalign 4\n_yyleng label byte\ndb 4 dup (0)\n_DATA ends\nextrn _printf:near\n_DATA segment\n_DATA ends\nextrn _fprintf:near\n_DATA segment\n_DATA ends\nextrn __flsbuf:near\n_DATA segment\n_DATA ends\nextrn __filbuf:near\n_DATA segment\n_DATA ends\nextrn __iob:near\n_DATA segment\npublic _yyval\nalign 4\n_yyval label byte\ndb 4 dup (0)\npublic _yylval\nalign 4\n_yylval label byte\ndb 4 dup (0)\n_DATA ends\n_TEXT segment\nalign 1\nL239 label byte\ndb 112\ndb 117\ndb 115\ndb 104\ndb 32\ndb 37\ndb 115\ndb 10\ndb 0\nalign 1\nL237 label byte\ndb 108\ndb 111\ndb 97\ndb 100\ndb 10\ndb 0\nalign 1\nL235 label byte\ndb 110\ndb 101\ndb 103\ndb 97\ndb 116\ndb 101\ndb 10\ndb 0\nalign 1\nL233 label byte\ndb 100\ndb 105\ndb 118\ndb 105\ndb 100\ndb 101\ndb 10\ndb 0\nalign 1\nL231 label byte\ndb 109\ndb 117\ndb 108\ndb 116\ndb 105\ndb 112\ndb 108\ndb 121\ndb 10\ndb 0\nalign 1\nL229 label byte\ndb 110\ndb 101\ndb 103\ndb 97\ndb 116\ndb 101\ndb 10\ndb 97\ndb 100\ndb 100\ndb 10\ndb 0\nalign 1\nL227 label byte\ndb 97\ndb 100\ndb 100\ndb 10\ndb 0\nalign 1\nL225 label byte\ndb 115\ndb 116\ndb 111\ndb 114\ndb 101\ndb 10\ndb 0\nalign 1\nL204 label byte\ndb 115\ndb 121\ndb 110\ndb 116\ndb 97\ndb 120\ndb 32\ndb 101\ndb 114\ndb 114\ndb 111\ndb 114\ndb 0\nalign 1\nL165 label byte\ndb 121\ndb 97\ndb 99\ndb 99\ndb 32\ndb 115\ndb 116\ndb 97\ndb 99\ndb 107\ndb 32\ndb 111\ndb 118\ndb 101\ndb 114\ndb 102\ndb 108\ndb 111\ndb 119\ndb 0\nalign 1\nL157 label byte\ndb 37\ndb 115\ndb 10\ndb 0\nalign 1\nL17 label byte\ndb 98\ndb 97\ndb 100\ndb 32\ndb 115\ndb 119\ndb 105\ndb 116\ndb 99\ndb 104\ndb 32\ndb 121\ndb 121\ndb 108\ndb 111\ndb 111\ndb 107\ndb 32\ndb 37\ndb 100\ndb 0\n_TEXT ends\nend\n"
  },
  {
    "path": "libs/cmdlib/cmdlib.cpp",
    "content": "//\n// start of shared cmdlib stuff\n// \n\n\n#include \"cmdlib.h\"\n#include \"windows.h\"\n\n#define PATHSEPERATOR   '/'\n\n// rad additions\n// 11.29.99\nPFN_ERR *g_pfnError = NULL;\nPFN_PRINTF *g_pfnPrintf = NULL;\nPFN_ERR_NUM *g_pfnErrorNum = NULL;\nPFN_PRINTF_NUM *g_pfnPrintfNum = NULL;\n\n\nvoid Error(const char *pFormat, ...)\n{\n  if (g_pfnError)\n  {\n    va_list arg_ptr;\n    va_start(arg_ptr, pFormat);\n    g_pfnError(pFormat, arg_ptr);\n    va_end(arg_ptr);\n  }\n}\n\nvoid Printf(const char *pFormat, ...)\n{\n  if (g_pfnPrintf)\n  {\n    va_list arg_ptr;\n    va_start(arg_ptr, pFormat);\n    g_pfnPrintf(pFormat, arg_ptr);\n    va_end(arg_ptr);\n  }\n}\n\nvoid ErrorNum(int nErr, const char *pFormat, ...)\n{\n  if (g_pfnErrorNum)\n  {\n    va_list arg_ptr;\n    va_start(arg_ptr, pFormat);\n    g_pfnErrorNum(nErr, pFormat, arg_ptr);\n    va_end(arg_ptr);\n  }\n}\n\nvoid PrintfNum(int nErr, const char *pFormat, ...)\n{\n  if (g_pfnPrintfNum)\n  {\n    va_list arg_ptr;\n    va_start(arg_ptr, pFormat);\n    g_pfnPrintfNum(nErr, pFormat, arg_ptr);\n    va_end(arg_ptr);\n  }\n}\n\n\n\nvoid SetErrorHandler(PFN_ERR pe)\n{\n  g_pfnError = pe;\n}\n\nvoid SetPrintfHandler(PFN_PRINTF pe)\n{\n  g_pfnPrintf = pe;\n}\n\nvoid SetErrorHandlerNum(PFN_ERR_NUM pe)\n{\n  g_pfnErrorNum = pe;\n}\n\nvoid SetPrintfHandler(PFN_PRINTF_NUM pe)\n{\n  g_pfnPrintfNum = pe;\n}\n\n\n\n// rad end\n\n#define MEM_BLOCKSIZE 4096\nvoid* qblockmalloc(size_t nSize)\n{\n\tvoid *b;\n  // round up to threshold\n  int nAllocSize = nSize % MEM_BLOCKSIZE;\n  if ( nAllocSize > 0)\n  {\n    nSize += MEM_BLOCKSIZE - nAllocSize;\n  }\n\tb = malloc(nSize + 1);\n\tmemset (b, 0, nSize);\n\treturn b;\n}\n\nvoid* qmalloc (size_t nSize)\n{\n\tvoid *b;\n\tb = malloc(nSize + 1);\n\tmemset (b, 0, nSize);\n\treturn b;\n}\n\n/*\n================\nQ_filelength\n================\n*/\nint Q_filelength (FILE *f)\n{\n\tint\t\tpos;\n\tint\t\tend;\n\n\tpos = ftell (f);\n\tfseek (f, 0, SEEK_END);\n\tend = ftell (f);\n\tfseek (f, pos, SEEK_SET);\n\n\treturn end;\n}\n\n\n// FIXME: need error handler\nFILE *SafeOpenWrite (const char *filename)\n{\n\tFILE\t*f;\n\n\tf = fopen(filename, \"wb\");\n\n\tif (!f)\n  {\n\t\tError (\"Error opening %s: %s\",filename,strerror(errno));\n  }\n\n\treturn f;\n}\n\nFILE *SafeOpenRead (const char *filename)\n{\n\tFILE\t*f;\n\n\tf = fopen(filename, \"rb\");\n\n\tif (!f)\n  {\n\t\tError (\"Error opening %s: %s\",filename,strerror(errno));\n  }\n\n\treturn f;\n}\n\n\nvoid SafeRead (FILE *f, void *buffer, int count)\n{\n\tif ( (int)fread (buffer, 1, count, f) != count)\n\t\tError (\"File read failure\");\n}\n\n\nvoid SafeWrite (FILE *f, const void *buffer, int count)\n{\n\tif ( (int)fwrite (buffer, 1, count, f) != count)\n\t\tError (\"File read failure\");\n}\n\n\n\n/*\n==============\nLoadFile\n==============\n*/\nint LoadFile (const char *filename, void **bufferptr)\n{\n\tFILE\t*f;\n\tint    length;\n\tvoid    *buffer;\n\n  *bufferptr = NULL;\n  \n  if (filename == NULL || strlen(filename) == 0)\n  {\n    return -1;\n  }\n\n\tf = fopen (filename, \"rb\");\n\tif (!f)\n\t{\n\t\treturn -1;\n\t}\n\tlength = Q_filelength (f);\n\tbuffer = qblockmalloc (length+1);\n\t((char *)buffer)[length] = 0;\n\tSafeRead (f, buffer, length);\n\tfclose (f);\n\n\t*bufferptr = buffer;\n\treturn length;\n}\n\n\n/*\n==============\nLoadFileNoCrash\n\nreturns -1 length if not present\n==============\n*/\nint    LoadFileNoCrash (const char *filename, void **bufferptr)\n{\n\tFILE\t*f;\n\tint    length;\n\tvoid    *buffer;\n\n\tf = fopen (filename, \"rb\");\n\tif (!f)\n\t\treturn -1;\n\tlength = Q_filelength (f);\n\tbuffer = qmalloc (length+1);\n\t((char *)buffer)[length] = 0;\n\tSafeRead (f, buffer, length);\n\tfclose (f);\n\n\t*bufferptr = buffer;\n\treturn length;\n}\n\n\n/*\n==============\nSaveFile\n==============\n*/\nvoid    SaveFile (const char *filename, void *buffer, int count)\n{\n\tFILE\t*f;\n\n\tf = SafeOpenWrite (filename);\n\tSafeWrite (f, buffer, count);\n\tfclose (f);\n}\n\n\n\nvoid DefaultExtension (char *path, char *extension)\n{\n\tchar    *src;\n//\n// if path doesn't have a .EXT, append extension\n// (extension should include the .)\n//\n\tsrc = path + strlen(path) - 1;\n\n\twhile (*src != PATHSEPERATOR && src != path)\n\t{\n\t\tif (*src == '.')\n\t\t\treturn;                 // it has an extension\n\t\tsrc--;\n\t}\n\n\tstrcat (path, extension);\n}\n\n\nvoid DefaultPath (char *path, char *basepath)\n{\n\tchar    temp[128];\n\n\tif (path[0] == PATHSEPERATOR)\n\t\treturn;                   // absolute path location\n\tstrcpy (temp,path);\n\tstrcpy (path,basepath);\n\tstrcat (path,temp);\n}\n\n\nvoid    StripFilename (char *path)\n{\n\tint             length;\n\n\tlength = strlen(path)-1;\n\twhile (length > 0 && path[length] != PATHSEPERATOR)\n\t\tlength--;\n\tpath[length] = 0;\n}\n\nvoid    StripExtension (char *path)\n{\n\tint             length;\n\n\tlength = strlen(path)-1;\n\twhile (length > 0 && path[length] != '.')\n\t{\n\t\tlength--;\n\t\tif (path[length] == '/')\n\t\t\treturn;\t\t// no extension\n\t}\n\tif (length)\n\t\tpath[length] = 0;\n}\n\n\n/*\n====================\nExtract file parts\n====================\n*/\nvoid ExtractFilePath (const char *path, char *dest)\n{\n\tconst char *src;\n\n\tsrc = path + strlen(path) - 1;\n\n//\n// back up until a \\ or the start\n//\n\twhile (src != path && *(src-1) != PATHSEPERATOR)\n\t\tsrc--;\n\n\tmemcpy (dest, path, src-path);\n\tdest[src-path] = 0;\n}\n\nvoid ExtractFileName (const char *path, char *dest)\n{\n\tconst char *src;\n\n\tsrc = path + strlen(path) - 1;\n\n//\n// back up until a \\ or the start\n//\n\twhile (src != path && *(src-1) != '/' \n\t\t && *(src-1) != '\\\\' )\n\t\tsrc--;\n\n\twhile (*src)\n\t{\n\t\t*dest++ = *src++;\n\t}\n\t*dest = 0;\n}\n\nvoid ExtractFileBase (const char *path, char *dest)\n{\n\tconst char *src;\n\n\tsrc = path + strlen(path) - 1;\n\n//\n// back up until a \\ or the start\n//\n\twhile (src != path && *(src-1) != '/' \n\t\t && *(src-1) != '\\\\' )\n\t\tsrc--;\n\n\twhile (*src && *src != '.')\n\t{\n\t\t*dest++ = *src++;\n\t}\n\t*dest = 0;\n}\n\nvoid ExtractFileExtension (const char *path, char *dest)\n{\n\tconst char *src;\n\n\tsrc = path + strlen(path) - 1;\n\n//\n// back up until a . or the start\n//\n\twhile (src != path && *(src-1) != '.')\n\t\tsrc--;\n\tif (src == path)\n\t{\n\t\t*dest = 0;\t// no extension\n\t\treturn;\n\t}\n\n\tstrcpy (dest,src);\n}\n\n\nvoid ConvertDOSToUnixName( char *dst, const char *src )\n{\n\twhile ( *src )\n\t{\n\t\tif ( *src == '\\\\' )\n\t\t\t*dst = '/';\n\t\telse\n\t\t\t*dst = *src;\n\t\tdst++; src++;\n\t}\n\t*dst = 0;\n}\n\n\nchar* StrDup(char* pStr)\n{ \n  if (pStr)\n  {\n    return strcpy(new char[strlen(pStr)+1], pStr); \n  }\n  return NULL;\n}\n\nchar* StrDup(const char* pStr)\n{ \n  if (pStr)\n  {\n    return strcpy(new char[strlen(pStr)+1], pStr); \n  }\n  return NULL;\n}\n\n\n/*\n============================================================================\n\n\t\t\t\t\tBYTE ORDER FUNCTIONS\n\n============================================================================\n*/\n\n#ifdef _SGI_SOURCE\n#define\t__BIG_ENDIAN__\n#endif\n\n#ifdef __BIG_ENDIAN__\n\nshort   LittleShort (short l)\n{\n\tbyte    b1,b2;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\n\treturn (b1<<8) + b2;\n}\n\nshort   BigShort (short l)\n{\n\treturn l;\n}\n\n\nint    LittleLong (int l)\n{\n\tbyte    b1,b2,b3,b4;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\tb3 = (l>>16)&255;\n\tb4 = (l>>24)&255;\n\n\treturn ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;\n}\n\nint    BigLong (int l)\n{\n\treturn l;\n}\n\n\nfloat\tLittleFloat (float l)\n{\n\tunion {byte b[4]; float f;} in, out;\n\t\n\tin.f = l;\n\tout.b[0] = in.b[3];\n\tout.b[1] = in.b[2];\n\tout.b[2] = in.b[1];\n\tout.b[3] = in.b[0];\n\t\n\treturn out.f;\n}\n\nfloat\tBigFloat (float l)\n{\n\treturn l;\n}\n\n\n#else\n\n\nshort   BigShort (short l)\n{\n\tbyte    b1,b2;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\n\treturn (b1<<8) + b2;\n}\n\nshort   LittleShort (short l)\n{\n\treturn l;\n}\n\n\nint    BigLong (int l)\n{\n\tbyte    b1,b2,b3,b4;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\tb3 = (l>>16)&255;\n\tb4 = (l>>24)&255;\n\n\treturn ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;\n}\n\nint    LittleLong (int l)\n{\n\treturn l;\n}\n\nfloat\tBigFloat (float l)\n{\n\tunion {byte b[4]; float f;} in, out;\n\t\n\tin.f = l;\n\tout.b[0] = in.b[3];\n\tout.b[1] = in.b[2];\n\tout.b[2] = in.b[1];\n\tout.b[3] = in.b[0];\n\t\n\treturn out.f;\n}\n\nfloat\tLittleFloat (float l)\n{\n\treturn l;\n}\n\n\n\n#endif\n\n"
  },
  {
    "path": "libs/cmdlib/cmdlib.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<VisualStudioProject\n\tProjectType=\"Visual C++\"\n\tVersion=\"7.10\"\n\tName=\"cmdlib\"\n\tSccProjectName=\"&quot;$/source/q3radiant&quot;, FEFAAAAA\"\n\tSccLocalPath=\"..\\..\\q3radiant\">\n\t<Platforms>\n\t\t<Platform\n\t\t\tName=\"Win32\"/>\n\t</Platforms>\n\t<Configurations>\n\t\t<Configuration\n\t\t\tName=\"Release|Win32\"\n\t\t\tOutputDirectory=\".\\Release\"\n\t\t\tIntermediateDirectory=\".\\Release\"\n\t\t\tConfigurationType=\"4\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tAdditionalIncludeDirectories=\"..\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_LIB\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"0\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tRuntimeTypeInfo=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release/cmdlib.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release/\"\n\t\t\t\tObjectFile=\".\\Release/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tCompileAs=\"0\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLibrarianTool\"\n\t\t\t\tOutputFile=\"..\\cmdlib.lib\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Debug|Win32\"\n\t\t\tOutputDirectory=\".\\Debug\"\n\t\t\tIntermediateDirectory=\".\\Debug\"\n\t\t\tConfigurationType=\"4\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tAdditionalIncludeDirectories=\"..\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_LIB\"\n\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tRuntimeTypeInfo=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Debug/cmdlib.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug/\"\n\t\t\t\tObjectFile=\".\\Debug/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Debug/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"\n\t\t\t\tCompileAs=\"0\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLibrarianTool\"\n\t\t\t\tOutputFile=\"..\\cmdlibd.lib\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t</Configurations>\n\t<References>\n\t</References>\n\t<Files>\n\t\t<Filter\n\t\t\tName=\"Source Files\"\n\t\t\tFilter=\"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"cmdlib.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Header Files\"\n\t\t\tFilter=\"h;hpp;hxx;hm;inl\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\cmdlib.h\">\n\t\t\t</File>\n\t\t</Filter>\n\t</Files>\n\t<Globals>\n\t</Globals>\n</VisualStudioProject>\n"
  },
  {
    "path": "libs/cmdlib.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n// start of shared cmdlib stuff\n// \n\n#ifndef __CMDLIB__\n#define __CMDLIB__\n\n#include <stdio.h>\n#include <string.h>\n#include <stdlib.h>\n#include <errno.h>\n#include <ctype.h>\n#include <time.h>\n#include <stdarg.h>\n\n#ifndef __BYTEBOOL__\n#define __BYTEBOOL__\n\n#ifndef __cplusplus\n  typedef enum {false, true} boolean;\n#else\n  typedef unsigned char boolean;\n#endif\n\n\ntypedef unsigned char byte;\n//typedef unsigned char byte;\n#endif\n\nFILE\t*SafeOpenWrite (const char *filename);\nFILE\t*SafeOpenRead (const char *filename);\nvoid\tSafeRead (FILE *f, void *buffer, int count);\nvoid\tSafeWrite (FILE *f, const void *buffer, int count);\nint\t\tLoadFile (const char *filename, void **bufferptr);\nint\t\tLoadFileNoCrash (const char *filename, void **bufferptr);\nvoid\tSaveFile (const char *filename, void *buffer, int count);\nvoid \tDefaultExtension (char *path, char *extension);\nvoid \tDefaultPath (char *path, char *basepath);\nvoid \tStripFilename (char *path);\nvoid \tStripExtension (char *path);\nvoid \tExtractFilePath (const char *path, char *dest);\nvoid\tExtractFileName (const char *path, char *dest);\nvoid \tExtractFileBase (const char *path, char *dest);\nvoid\tExtractFileExtension (const char *path, char *dest);\nshort\tBigShort (short l);\nshort\tLittleShort (short l);\nint\t\tBigLong (int l);\nint\t\tLittleLong (int l);\nfloat\tBigFloat (float l);\nfloat\tLittleFloat (float l);\nvoid *qmalloc (size_t size);\nvoid* qblockmalloc(size_t nSize);\n\n\n\n// error and printf functions\ntypedef void (PFN_ERR)(const char *pFormat, ...);\ntypedef void (PFN_PRINTF)(const char *pFormat, ...);\ntypedef void (PFN_ERR_NUM)(int nNum, const char *pFormat, ...);\ntypedef void (PFN_PRINTF_NUM)(int nNum, const char *pFormat, ...);\n\nvoid Error(const char *pFormat, ...);\nvoid Printf(const char *pFormat, ...);\nvoid ErrorNum(int n, const char *pFormat, ...);\nvoid PrintfNum(int n, const char *pFormat, ...);\n\nvoid SetErrorHandler(PFN_ERR pe);\nvoid SetPrintfHandler(PFN_PRINTF pe);\nvoid SetErrorHandlerNum(PFN_ERR_NUM pe);\nvoid SetPrintfHandlerNum(PFN_PRINTF_NUM pe);\nvoid ConvertDOSToUnixName( char *dst, const char *src );\nchar* StrDup(char* pStr);\nchar* StrDup(const char* pStr);\n\n\n#endif"
  },
  {
    "path": "libs/jpeg6/README",
    "content": "The Independent JPEG Group's JPEG software\n==========================================\n\nREADME for release 6b of 27-Mar-1998\n====================================\n\nThis distribution contains the sixth public release of the Independent JPEG\nGroup's free JPEG software.  You are welcome to redistribute this software and\nto use it for any purpose, subject to the conditions under LEGAL ISSUES, below.\n\nSerious users of this software (particularly those incorporating it into\nlarger programs) should contact IJG at jpeg-info@uunet.uu.net to be added to\nour electronic mailing list.  Mailing list members are notified of updates\nand have a chance to participate in technical discussions, etc.\n\nThis software is the work of Tom Lane, Philip Gladstone, Jim Boucher,\nLee Crocker, Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi,\nGuido Vollbeding, Ge' Weijers, and other members of the Independent JPEG\nGroup.\n\nIJG is not affiliated with the official ISO JPEG standards committee.\n\n\nDOCUMENTATION ROADMAP\n=====================\n\nThis file contains the following sections:\n\nOVERVIEW            General description of JPEG and the IJG software.\nLEGAL ISSUES        Copyright, lack of warranty, terms of distribution.\nREFERENCES          Where to learn more about JPEG.\nARCHIVE LOCATIONS   Where to find newer versions of this software.\nRELATED SOFTWARE    Other stuff you should get.\nFILE FORMAT WARS    Software *not* to get.\nTO DO               Plans for future IJG releases.\n\nOther documentation files in the distribution are:\n\nUser documentation:\n  install.doc       How to configure and install the IJG software.\n  usage.doc         Usage instructions for cjpeg, djpeg, jpegtran,\n                    rdjpgcom, and wrjpgcom.\n  *.1               Unix-style man pages for programs (same info as usage.doc).\n  wizard.doc        Advanced usage instructions for JPEG wizards only.\n  change.log        Version-to-version change highlights.\nProgrammer and internal documentation:\n  libjpeg.doc       How to use the JPEG library in your own programs.\n  example.c         Sample code for calling the JPEG library.\n  structure.doc     Overview of the JPEG library's internal structure.\n  filelist.doc      Road map of IJG files.\n  coderules.doc     Coding style rules --- please read if you contribute code.\n\nPlease read at least the files install.doc and usage.doc.  Useful information\ncan also be found in the JPEG FAQ (Frequently Asked Questions) article.  See\nARCHIVE LOCATIONS below to find out where to obtain the FAQ article.\n\nIf you want to understand how the JPEG code works, we suggest reading one or\nmore of the REFERENCES, then looking at the documentation files (in roughly\nthe order listed) before diving into the code.\n\n\nOVERVIEW\n========\n\nThis package contains C software to implement JPEG image compression and\ndecompression.  JPEG (pronounced \"jay-peg\") is a standardized compression\nmethod for full-color and gray-scale images.  JPEG is intended for compressing\n\"real-world\" scenes; line drawings, cartoons and other non-realistic images\nare not its strong suit.  JPEG is lossy, meaning that the output image is not\nexactly identical to the input image.  Hence you must not use JPEG if you\nhave to have identical output bits.  However, on typical photographic images,\nvery good compression levels can be obtained with no visible change, and\nremarkably high compression levels are possible if you can tolerate a\nlow-quality image.  For more details, see the references, or just experiment\nwith various compression settings.\n\nThis software implements JPEG baseline, extended-sequential, and progressive\ncompression processes.  Provision is made for supporting all variants of these\nprocesses, although some uncommon parameter settings aren't implemented yet.\nFor legal reasons, we are not distributing code for the arithmetic-coding\nvariants of JPEG; see LEGAL ISSUES.  We have made no provision for supporting\nthe hierarchical or lossless processes defined in the standard.\n\nWe provide a set of library routines for reading and writing JPEG image files,\nplus two sample applications \"cjpeg\" and \"djpeg\", which use the library to\nperform conversion between JPEG and some other popular image file formats.\nThe library is intended to be reused in other applications.\n\nIn order to support file conversion and viewing software, we have included\nconsiderable functionality beyond the bare JPEG coding/decoding capability;\nfor example, the color quantization modules are not strictly part of JPEG\ndecoding, but they are essential for output to colormapped file formats or\ncolormapped displays.  These extra functions can be compiled out of the\nlibrary if not required for a particular application.  We have also included\n\"jpegtran\", a utility for lossless transcoding between different JPEG\nprocesses, and \"rdjpgcom\" and \"wrjpgcom\", two simple applications for\ninserting and extracting textual comments in JFIF files.\n\nThe emphasis in designing this software has been on achieving portability and\nflexibility, while also making it fast enough to be useful.  In particular,\nthe software is not intended to be read as a tutorial on JPEG.  (See the\nREFERENCES section for introductory material.)  Rather, it is intended to\nbe reliable, portable, industrial-strength code.  We do not claim to have\nachieved that goal in every aspect of the software, but we strive for it.\n\nWe welcome the use of this software as a component of commercial products.\nNo royalty is required, but we do ask for an acknowledgement in product\ndocumentation, as described under LEGAL ISSUES.\n\n\nLEGAL ISSUES\n============\n\nIn plain English:\n\n1. We don't promise that this software works.  (But if you find any bugs,\n   please let us know!)\n2. You can use this software for whatever you want.  You don't have to pay us.\n3. You may not pretend that you wrote this software.  If you use it in a\n   program, you must acknowledge somewhere in your documentation that\n   you've used the IJG code.\n\nIn legalese:\n\nThe authors make NO WARRANTY or representation, either express or implied,\nwith respect to this software, its quality, accuracy, merchantability, or\nfitness for a particular purpose.  This software is provided \"AS IS\", and you,\nits user, assume the entire risk as to its quality and accuracy.\n\nThis software is copyright (C) 1991-1998, Thomas G. Lane.\nAll Rights Reserved except as specified below.\n\nPermission is hereby granted to use, copy, modify, and distribute this\nsoftware (or portions thereof) for any purpose, without fee, subject to these\nconditions:\n(1) If any part of the source code for this software is distributed, then this\nREADME file must be included, with this copyright and no-warranty notice\nunaltered; and any additions, deletions, or changes to the original files\nmust be clearly indicated in accompanying documentation.\n(2) If only executable code is distributed, then the accompanying\ndocumentation must state that \"this software is based in part on the work of\nthe Independent JPEG Group\".\n(3) Permission for use of this software is granted only if the user accepts\nfull responsibility for any undesirable consequences; the authors accept\nNO LIABILITY for damages of any kind.\n\nThese conditions apply to any software derived from or based on the IJG code,\nnot just to the unmodified library.  If you use our work, you ought to\nacknowledge us.\n\nPermission is NOT granted for the use of any IJG author's name or company name\nin advertising or publicity relating to this software or products derived from\nit.  This software may be referred to only as \"the Independent JPEG Group's\nsoftware\".\n\nWe specifically permit and encourage the use of this software as the basis of\ncommercial products, provided that all warranty or liability claims are\nassumed by the product vendor.\n\n\nansi2knr.c is included in this distribution by permission of L. Peter Deutsch,\nsole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA.\nansi2knr.c is NOT covered by the above copyright and conditions, but instead\nby the usual distribution terms of the Free Software Foundation; principally,\nthat you must include source code if you redistribute it.  (See the file\nansi2knr.c for full details.)  However, since ansi2knr.c is not needed as part\nof any program generated from the IJG code, this does not limit you more than\nthe foregoing paragraphs do.\n\nThe Unix configuration script \"configure\" was produced with GNU Autoconf.\nIt is copyright by the Free Software Foundation but is freely distributable.\nThe same holds for its supporting scripts (config.guess, config.sub,\nltconfig, ltmain.sh).  Another support script, install-sh, is copyright\nby M.I.T. but is also freely distributable.\n\nIt appears that the arithmetic coding option of the JPEG spec is covered by\npatents owned by IBM, AT&T, and Mitsubishi.  Hence arithmetic coding cannot\nlegally be used without obtaining one or more licenses.  For this reason,\nsupport for arithmetic coding has been removed from the free JPEG software.\n(Since arithmetic coding provides only a marginal gain over the unpatented\nHuffman mode, it is unlikely that very many implementations will support it.)\nSo far as we are aware, there are no patent restrictions on the remaining\ncode.\n\nThe IJG distribution formerly included code to read and write GIF files.\nTo avoid entanglement with the Unisys LZW patent, GIF reading support has\nbeen removed altogether, and the GIF writer has been simplified to produce\n\"uncompressed GIFs\".  This technique does not use the LZW algorithm; the\nresulting GIF files are larger than usual, but are readable by all standard\nGIF decoders.\n\nWe are required to state that\n    \"The Graphics Interchange Format(c) is the Copyright property of\n    CompuServe Incorporated.  GIF(sm) is a Service Mark property of\n    CompuServe Incorporated.\"\n\n\nREFERENCES\n==========\n\nWe highly recommend reading one or more of these references before trying to\nunderstand the innards of the JPEG software.\n\nThe best short technical introduction to the JPEG compression algorithm is\n\tWallace, Gregory K.  \"The JPEG Still Picture Compression Standard\",\n\tCommunications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44.\n(Adjacent articles in that issue discuss MPEG motion picture compression,\napplications of JPEG, and related topics.)  If you don't have the CACM issue\nhandy, a PostScript file containing a revised version of Wallace's article is\navailable at ftp://ftp.uu.net/graphics/jpeg/wallace.ps.gz.  The file (actually\na preprint for an article that appeared in IEEE Trans. Consumer Electronics)\nomits the sample images that appeared in CACM, but it includes corrections\nand some added material.  Note: the Wallace article is copyright ACM and IEEE,\nand it may not be used for commercial purposes.\n\nA somewhat less technical, more leisurely introduction to JPEG can be found in\n\"The Data Compression Book\" by Mark Nelson and Jean-loup Gailly, published by\nM&T Books (New York), 2nd ed. 1996, ISBN 1-55851-434-1.  This book provides\ngood explanations and example C code for a multitude of compression methods\nincluding JPEG.  It is an excellent source if you are comfortable reading C\ncode but don't know much about data compression in general.  The book's JPEG\nsample code is far from industrial-strength, but when you are ready to look\nat a full implementation, you've got one here...\n\nThe best full description of JPEG is the textbook \"JPEG Still Image Data\nCompression Standard\" by William B. Pennebaker and Joan L. Mitchell, published\nby Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1.  Price US$59.95, 638 pp.\nThe book includes the complete text of the ISO JPEG standards (DIS 10918-1\nand draft DIS 10918-2).  This is by far the most complete exposition of JPEG\nin existence, and we highly recommend it.\n\nThe JPEG standard itself is not available electronically; you must order a\npaper copy through ISO or ITU.  (Unless you feel a need to own a certified\nofficial copy, we recommend buying the Pennebaker and Mitchell book instead;\nit's much cheaper and includes a great deal of useful explanatory material.)\nIn the USA, copies of the standard may be ordered from ANSI Sales at (212)\n642-4900, or from Global Engineering Documents at (800) 854-7179.  (ANSI\ndoesn't take credit card orders, but Global does.)  It's not cheap: as of\n1992, ANSI was charging $95 for Part 1 and $47 for Part 2, plus 7%\nshipping/handling.  The standard is divided into two parts, Part 1 being the\nactual specification, while Part 2 covers compliance testing methods.  Part 1\nis titled \"Digital Compression and Coding of Continuous-tone Still Images,\nPart 1: Requirements and guidelines\" and has document numbers ISO/IEC IS\n10918-1, ITU-T T.81.  Part 2 is titled \"Digital Compression and Coding of\nContinuous-tone Still Images, Part 2: Compliance testing\" and has document\nnumbers ISO/IEC IS 10918-2, ITU-T T.83.\n\nSome extensions to the original JPEG standard are defined in JPEG Part 3,\na newer ISO standard numbered ISO/IEC IS 10918-3 and ITU-T T.84.  IJG\ncurrently does not support any Part 3 extensions.\n\nThe JPEG standard does not specify all details of an interchangeable file\nformat.  For the omitted details we follow the \"JFIF\" conventions, revision\n1.02.  A copy of the JFIF spec is available from:\n\tLiterature Department\n\tC-Cube Microsystems, Inc.\n\t1778 McCarthy Blvd.\n\tMilpitas, CA 95035\n\tphone (408) 944-6300,  fax (408) 944-6314\nA PostScript version of this document is available by FTP at\nftp://ftp.uu.net/graphics/jpeg/jfif.ps.gz.  There is also a plain text\nversion at ftp://ftp.uu.net/graphics/jpeg/jfif.txt.gz, but it is missing\nthe figures.\n\nThe TIFF 6.0 file format specification can be obtained by FTP from\nftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz.  The JPEG incorporation scheme\nfound in the TIFF 6.0 spec of 3-June-92 has a number of serious problems.\nIJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6).\nInstead, we recommend the JPEG design proposed by TIFF Technical Note #2\n(Compression tag 7).  Copies of this Note can be obtained from ftp.sgi.com or\nfrom ftp://ftp.uu.net/graphics/jpeg/.  It is expected that the next revision\nof the TIFF spec will replace the 6.0 JPEG design with the Note's design.\nAlthough IJG's own code does not support TIFF/JPEG, the free libtiff library\nuses our library to implement TIFF/JPEG per the Note.  libtiff is available\nfrom ftp://ftp.sgi.com/graphics/tiff/.\n\n\nARCHIVE LOCATIONS\n=================\n\nThe \"official\" archive site for this software is ftp.uu.net (Internet\naddress 192.48.96.9).  The most recent released version can always be found\nthere in directory graphics/jpeg.  This particular version will be archived\nas ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz.  If you don't have\ndirect Internet access, UUNET's archives are also available via UUCP; contact\nhelp@uunet.uu.net for information on retrieving files that way.\n\nNumerous Internet sites maintain copies of the UUNET files.  However, only\nftp.uu.net is guaranteed to have the latest official version.\n\nYou can also obtain this software in DOS-compatible \"zip\" archive format from\nthe SimTel archives (ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/), or\non CompuServe in the Graphics Support forum (GO CIS:GRAPHSUP), library 12\n\"JPEG Tools\".  Again, these versions may sometimes lag behind the ftp.uu.net\nrelease.\n\nThe JPEG FAQ (Frequently Asked Questions) article is a useful source of\ngeneral information about JPEG.  It is updated constantly and therefore is\nnot included in this distribution.  The FAQ is posted every two weeks to\nUsenet newsgroups comp.graphics.misc, news.answers, and other groups.\nIt is available on the World Wide Web at http://www.faqs.org/faqs/jpeg-faq/\nand other news.answers archive sites, including the official news.answers\narchive at rtfm.mit.edu: ftp://rtfm.mit.edu/pub/usenet/news.answers/jpeg-faq/.\nIf you don't have Web or FTP access, send e-mail to mail-server@rtfm.mit.edu\nwith body\n\tsend usenet/news.answers/jpeg-faq/part1\n\tsend usenet/news.answers/jpeg-faq/part2\n\n\nRELATED SOFTWARE\n================\n\nNumerous viewing and image manipulation programs now support JPEG.  (Quite a\nfew of them use this library to do so.)  The JPEG FAQ described above lists\nsome of the more popular free and shareware viewers, and tells where to\nobtain them on Internet.\n\nIf you are on a Unix machine, we highly recommend Jef Poskanzer's free\nPBMPLUS software, which provides many useful operations on PPM-format image\nfiles.  In particular, it can convert PPM images to and from a wide range of\nother formats, thus making cjpeg/djpeg considerably more useful.  The latest\nversion is distributed by the NetPBM group, and is available from numerous\nsites, notably ftp://wuarchive.wustl.edu/graphics/graphics/packages/NetPBM/.\nUnfortunately PBMPLUS/NETPBM is not nearly as portable as the IJG software is;\nyou are likely to have difficulty making it work on any non-Unix machine.\n\nA different free JPEG implementation, written by the PVRG group at Stanford,\nis available from ftp://havefun.stanford.edu/pub/jpeg/.  This program\nis designed for research and experimentation rather than production use;\nit is slower, harder to use, and less portable than the IJG code, but it\nis easier to read and modify.  Also, the PVRG code supports lossless JPEG,\nwhich we do not.  (On the other hand, it doesn't do progressive JPEG.)\n\n\nFILE FORMAT WARS\n================\n\nSome JPEG programs produce files that are not compatible with our library.\nThe root of the problem is that the ISO JPEG committee failed to specify a\nconcrete file format.  Some vendors \"filled in the blanks\" on their own,\ncreating proprietary formats that no one else could read.  (For example, none\nof the early commercial JPEG implementations for the Macintosh were able to\nexchange compressed files.)\n\nThe file format we have adopted is called JFIF (see REFERENCES).  This format\nhas been agreed to by a number of major commercial JPEG vendors, and it has\nbecome the de facto standard.  JFIF is a minimal or \"low end\" representation.\nWe recommend the use of TIFF/JPEG (TIFF revision 6.0 as modified by TIFF\nTechnical Note #2) for \"high end\" applications that need to record a lot of\nadditional data about an image.  TIFF/JPEG is fairly new and not yet widely\nsupported, unfortunately.\n\nThe upcoming JPEG Part 3 standard defines a file format called SPIFF.\nSPIFF is interoperable with JFIF, in the sense that most JFIF decoders should\nbe able to read the most common variant of SPIFF.  SPIFF has some technical\nadvantages over JFIF, but its major claim to fame is simply that it is an\nofficial standard rather than an informal one.  At this point it is unclear\nwhether SPIFF will supersede JFIF or whether JFIF will remain the de-facto\nstandard.  IJG intends to support SPIFF once the standard is frozen, but we\nhave not decided whether it should become our default output format or not.\n(In any case, our decoder will remain capable of reading JFIF indefinitely.)\n\nVarious proprietary file formats incorporating JPEG compression also exist.\nWe have little or no sympathy for the existence of these formats.  Indeed,\none of the original reasons for developing this free software was to help\nforce convergence on common, open format standards for JPEG files.  Don't\nuse a proprietary file format!\n\n\nTO DO\n=====\n\nThe major thrust for v7 will probably be improvement of visual quality.\nThe current method for scaling the quantization tables is known not to be\nvery good at low Q values.  We also intend to investigate block boundary\nsmoothing, \"poor man's variable quantization\", and other means of improving\nquality-vs-file-size performance without sacrificing compatibility.\n\nIn future versions, we are considering supporting some of the upcoming JPEG\nPart 3 extensions --- principally, variable quantization and the SPIFF file\nformat.\n\nAs always, speeding things up is of great interest.\n\nPlease send bug reports, offers of help, etc. to jpeg-info@uunet.uu.net.\n"
  },
  {
    "path": "libs/jpeg6/jchuff.h",
    "content": "/*\n * jchuff.h\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains declarations for Huffman entropy encoding routines\n * that are shared between the sequential encoder (jchuff.c) and the\n * progressive encoder (jcphuff.c).  No other modules need to see these.\n */\n\n/* Derived data constructed for each Huffman table */\n\ntypedef struct {\n  unsigned int ehufco[256];\t/* code for each symbol */\n  char ehufsi[256];\t\t/* length of code for each symbol */\n  /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */\n} c_derived_tbl;\n\n/* Short forms of external names for systems with brain-damaged linkers. */\n\n#ifdef NEED_SHORT_EXTERNAL_NAMES\n#define jpeg_make_c_derived_tbl\tjMkCDerived\n#define jpeg_gen_optimal_table\tjGenOptTbl\n#endif /* NEED_SHORT_EXTERNAL_NAMES */\n\n/* Expand a Huffman table definition into the derived format */\nEXTERN void jpeg_make_c_derived_tbl JPP((j_compress_ptr cinfo,\n\t\t\t\tJHUFF_TBL * htbl, c_derived_tbl ** pdtbl));\n\n/* Generate an optimal table definition given the specified counts */\nEXTERN void jpeg_gen_optimal_table JPP((j_compress_ptr cinfo,\n\t\t\t\t\tJHUFF_TBL * htbl, long freq[]));\n"
  },
  {
    "path": "libs/jpeg6/jcomapi.cpp",
    "content": "/*\n * jcomapi.c\n *\n * Copyright (C) 1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains application interface routines that are used for both\n * compression and decompression.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/*\n * Abort processing of a JPEG compression or decompression operation,\n * but don't destroy the object itself.\n *\n * For this, we merely clean up all the nonpermanent memory pools.\n * Note that temp files (virtual arrays) are not allowed to belong to\n * the permanent pool, so we will be able to close all temp files here.\n * Closing a data source or destination, if necessary, is the application's\n * responsibility.\n */\n\nGLOBAL void\njpeg_abort (j_common_ptr cinfo)\n{\n  int pool;\n\n  /* Releasing pools in reverse order might help avoid fragmentation\n   * with some (brain-damaged) malloc libraries.\n   */\n  for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) {\n    (*cinfo->mem->free_pool) (cinfo, pool);\n  }\n\n  /* Reset overall state for possible reuse of object */\n  cinfo->global_state = (cinfo->is_decompressor ? DSTATE_START : CSTATE_START);\n}\n\n\n/*\n * Destruction of a JPEG object.\n *\n * Everything gets deallocated except the master jpeg_compress_struct itself\n * and the error manager struct.  Both of these are supplied by the application\n * and must be freed, if necessary, by the application.  (Often they are on\n * the stack and so don't need to be freed anyway.)\n * Closing a data source or destination, if necessary, is the application's\n * responsibility.\n */\n\nGLOBAL void\njpeg_destroy (j_common_ptr cinfo)\n{\n  /* We need only tell the memory manager to release everything. */\n  /* NB: mem pointer is NULL if memory mgr failed to initialize. */\n  if (cinfo->mem != NULL)\n    (*cinfo->mem->self_destruct) (cinfo);\n  cinfo->mem = NULL;\t\t/* be safe if jpeg_destroy is called twice */\n  cinfo->global_state = 0;\t/* mark it destroyed */\n}\n\n\n/*\n * Convenience routines for allocating quantization and Huffman tables.\n * (Would jutils.c be a more reasonable place to put these?)\n */\n\nGLOBAL JQUANT_TBL *\njpeg_alloc_quant_table (j_common_ptr cinfo)\n{\n  JQUANT_TBL *tbl;\n\n  tbl = (JQUANT_TBL *)\n    (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL));\n  tbl->sent_table = FALSE;\t/* make sure this is false in any new table */\n  return tbl;\n}\n\n\nGLOBAL JHUFF_TBL *\njpeg_alloc_huff_table (j_common_ptr cinfo)\n{\n  JHUFF_TBL *tbl;\n\n  tbl = (JHUFF_TBL *)\n    (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL));\n  tbl->sent_table = FALSE;\t/* make sure this is false in any new table */\n  return tbl;\n}\n"
  },
  {
    "path": "libs/jpeg6/jconfig.h",
    "content": "/* jconfig.wat --- jconfig.h for Watcom C/C++ on MS-DOS or OS/2. */\n/* see jconfig.doc for explanations */\n\n#define HAVE_PROTOTYPES\n#define HAVE_UNSIGNED_CHAR\n#define HAVE_UNSIGNED_SHORT\n/* #define void char */\n/* #define const */\n#define CHAR_IS_UNSIGNED\n#define HAVE_STDDEF_H\n#define HAVE_STDLIB_H\n#undef NEED_BSD_STRINGS\n#undef NEED_SYS_TYPES_H\n#undef NEED_FAR_POINTERS\t/* Watcom uses flat 32-bit addressing */\n#undef NEED_SHORT_EXTERNAL_NAMES\n#undef INCOMPLETE_TYPES_BROKEN\n\n#define JDCT_DEFAULT  JDCT_FLOAT\n#define JDCT_FASTEST  JDCT_FLOAT\n\n#ifdef JPEG_INTERNALS\n\n#undef RIGHT_SHIFT_IS_UNSIGNED\n\n#endif /* JPEG_INTERNALS */\n\n#ifdef JPEG_CJPEG_DJPEG\n\n#define BMP_SUPPORTED\t\t/* BMP image file format */\n#define GIF_SUPPORTED\t\t/* GIF image file format */\n#define PPM_SUPPORTED\t\t/* PBMPLUS PPM/PGM image file format */\n#undef RLE_SUPPORTED\t\t/* Utah RLE image file format */\n#define TARGA_SUPPORTED\t\t/* Targa image file format */\n\n#undef TWO_FILE_COMMANDLINE\t/* optional */\n#define USE_SETMODE\t\t/* Needed to make one-file style work in Watcom */\n#undef NEED_SIGNAL_CATCHER\t/* Define this if you use jmemname.c */\n#undef DONT_USE_B_MODE\n#undef PROGRESS_REPORT\t\t/* optional */\n\n#endif /* JPEG_CJPEG_DJPEG */\n"
  },
  {
    "path": "libs/jpeg6/jdapimin.cpp",
    "content": "/*\n * jdapimin.c\n *\n * Copyright (C) 1994-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains application interface code for the decompression half\n * of the JPEG library.  These are the \"minimum\" API routines that may be\n * needed in either the normal full-decompression case or the\n * transcoding-only case.\n *\n * Most of the routines intended to be called directly by an application\n * are in this file or in jdapistd.c.  But also see jcomapi.c for routines\n * shared by compression and decompression, and jdtrans.c for the transcoding\n * case.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/*\n * Initialization of a JPEG decompression object.\n * The error manager must already be set up (in case memory manager fails).\n */\n\nGLOBAL void\njpeg_create_decompress (j_decompress_ptr cinfo)\n{\n  int i;\n\n  /* For debugging purposes, zero the whole master structure.\n   * But error manager pointer is already there, so save and restore it.\n   */\n  {\n    struct jpeg_error_mgr * err = cinfo->err;\n    i = sizeof(struct jpeg_decompress_struct);\n    i = SIZEOF(struct jpeg_decompress_struct);\n    MEMZERO(cinfo, SIZEOF(struct jpeg_decompress_struct));\n    cinfo->err = err;\n  }\n  cinfo->is_decompressor = TRUE;\n\n  /* Initialize a memory manager instance for this object */\n  jinit_memory_mgr((j_common_ptr) cinfo);\n\n  /* Zero out pointers to permanent structures. */\n  cinfo->progress = NULL;\n  cinfo->src = NULL;\n\n  for (i = 0; i < NUM_QUANT_TBLS; i++)\n    cinfo->quant_tbl_ptrs[i] = NULL;\n\n  for (i = 0; i < NUM_HUFF_TBLS; i++) {\n    cinfo->dc_huff_tbl_ptrs[i] = NULL;\n    cinfo->ac_huff_tbl_ptrs[i] = NULL;\n  }\n\n  /* Initialize marker processor so application can override methods\n   * for COM, APPn markers before calling jpeg_read_header.\n   */\n  jinit_marker_reader(cinfo);\n\n  /* And initialize the overall input controller. */\n  jinit_input_controller(cinfo);\n\n  /* OK, I'm ready */\n  cinfo->global_state = DSTATE_START;\n}\n\n\n/*\n * Destruction of a JPEG decompression object\n */\n\nGLOBAL void\njpeg_destroy_decompress (j_decompress_ptr cinfo)\n{\n  jpeg_destroy((j_common_ptr) cinfo); /* use common routine */\n}\n\n\n/*\n * Abort processing of a JPEG decompression operation,\n * but don't destroy the object itself.\n */\n\nGLOBAL void\njpeg_abort_decompress (j_decompress_ptr cinfo)\n{\n  jpeg_abort((j_common_ptr) cinfo); /* use common routine */\n}\n\n\n/*\n * Install a special processing method for COM or APPn markers.\n */\n\nGLOBAL void\njpeg_set_marker_processor (j_decompress_ptr cinfo, int marker_code,\n\t\t\t   jpeg_marker_parser_method routine)\n{\n  if (marker_code == JPEG_COM)\n    cinfo->marker->process_COM = routine;\n  else if (marker_code >= JPEG_APP0 && marker_code <= JPEG_APP0+15)\n    cinfo->marker->process_APPn[marker_code-JPEG_APP0] = routine;\n  else\n    ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code);\n}\n\n\n/*\n * Set default decompression parameters.\n */\n\nLOCAL void\ndefault_decompress_parms (j_decompress_ptr cinfo)\n{\n  /* Guess the input colorspace, and set output colorspace accordingly. */\n  /* (Wish JPEG committee had provided a real way to specify this...) */\n  /* Note application may override our guesses. */\n  switch (cinfo->num_components) {\n  case 1:\n    cinfo->jpeg_color_space = JCS_GRAYSCALE;\n    cinfo->out_color_space = JCS_GRAYSCALE;\n    break;\n    \n  case 3:\n    if (cinfo->saw_JFIF_marker) {\n      cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */\n    } else if (cinfo->saw_Adobe_marker) {\n      switch (cinfo->Adobe_transform) {\n      case 0:\n\tcinfo->jpeg_color_space = JCS_RGB;\n\tbreak;\n      case 1:\n\tcinfo->jpeg_color_space = JCS_YCbCr;\n\tbreak;\n      default:\n\tWARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);\n\tcinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */\n\tbreak;\n      }\n    } else {\n      /* Saw no special markers, try to guess from the component IDs */\n      int cid0 = cinfo->comp_info[0].component_id;\n      int cid1 = cinfo->comp_info[1].component_id;\n      int cid2 = cinfo->comp_info[2].component_id;\n\n      if (cid0 == 1 && cid1 == 2 && cid2 == 3)\n\tcinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */\n      else if (cid0 == 82 && cid1 == 71 && cid2 == 66)\n\tcinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */\n      else {\n\tTRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);\n\tcinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */\n      }\n    }\n    /* Always guess RGB is proper output colorspace. */\n    cinfo->out_color_space = JCS_RGB;\n    break;\n    \n  case 4:\n    if (cinfo->saw_Adobe_marker) {\n      switch (cinfo->Adobe_transform) {\n      case 0:\n\tcinfo->jpeg_color_space = JCS_CMYK;\n\tbreak;\n      case 2:\n\tcinfo->jpeg_color_space = JCS_YCCK;\n\tbreak;\n      default:\n\tWARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);\n\tcinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */\n\tbreak;\n      }\n    } else {\n      /* No special markers, assume straight CMYK. */\n      cinfo->jpeg_color_space = JCS_CMYK;\n    }\n    cinfo->out_color_space = JCS_CMYK;\n    break;\n    \n  default:\n    cinfo->jpeg_color_space = JCS_UNKNOWN;\n    cinfo->out_color_space = JCS_UNKNOWN;\n    break;\n  }\n\n  /* Set defaults for other decompression parameters. */\n  cinfo->scale_num = 1;\t\t/* 1:1 scaling */\n  cinfo->scale_denom = 1;\n  cinfo->output_gamma = 1.0;\n  cinfo->buffered_image = FALSE;\n  cinfo->raw_data_out = FALSE;\n  cinfo->dct_method = JDCT_DEFAULT;\n  cinfo->do_fancy_upsampling = TRUE;\n  cinfo->do_block_smoothing = TRUE;\n  cinfo->quantize_colors = FALSE;\n  /* We set these in case application only sets quantize_colors. */\n  cinfo->dither_mode = JDITHER_FS;\n#ifdef QUANT_2PASS_SUPPORTED\n  cinfo->two_pass_quantize = TRUE;\n#else\n  cinfo->two_pass_quantize = FALSE;\n#endif\n  cinfo->desired_number_of_colors = 256;\n  cinfo->colormap = NULL;\n  /* Initialize for no mode change in buffered-image mode. */\n  cinfo->enable_1pass_quant = FALSE;\n  cinfo->enable_external_quant = FALSE;\n  cinfo->enable_2pass_quant = FALSE;\n}\n\n\n/*\n * Decompression startup: read start of JPEG datastream to see what's there.\n * Need only initialize JPEG object and supply a data source before calling.\n *\n * This routine will read as far as the first SOS marker (ie, actual start of\n * compressed data), and will save all tables and parameters in the JPEG\n * object.  It will also initialize the decompression parameters to default\n * values, and finally return JPEG_HEADER_OK.  On return, the application may\n * adjust the decompression parameters and then call jpeg_start_decompress.\n * (Or, if the application only wanted to determine the image parameters,\n * the data need not be decompressed.  In that case, call jpeg_abort or\n * jpeg_destroy to release any temporary space.)\n * If an abbreviated (tables only) datastream is presented, the routine will\n * return JPEG_HEADER_TABLES_ONLY upon reaching EOI.  The application may then\n * re-use the JPEG object to read the abbreviated image datastream(s).\n * It is unnecessary (but OK) to call jpeg_abort in this case.\n * The JPEG_SUSPENDED return code only occurs if the data source module\n * requests suspension of the decompressor.  In this case the application\n * should load more source data and then re-call jpeg_read_header to resume\n * processing.\n * If a non-suspending data source is used and require_image is TRUE, then the\n * return code need not be inspected since only JPEG_HEADER_OK is possible.\n *\n * This routine is now just a front end to jpeg_consume_input, with some\n * extra error checking.\n */\n\nGLOBAL int\njpeg_read_header (j_decompress_ptr cinfo, boolean require_image)\n{\n  int retcode;\n\n  if (cinfo->global_state != DSTATE_START &&\n      cinfo->global_state != DSTATE_INHEADER)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n\n  retcode = jpeg_consume_input(cinfo);\n\n  switch (retcode) {\n  case JPEG_REACHED_SOS:\n    retcode = JPEG_HEADER_OK;\n    break;\n  case JPEG_REACHED_EOI:\n    if (require_image)\t\t/* Complain if application wanted an image */\n      ERREXIT(cinfo, JERR_NO_IMAGE);\n    /* Reset to start state; it would be safer to require the application to\n     * call jpeg_abort, but we can't change it now for compatibility reasons.\n     * A side effect is to free any temporary memory (there shouldn't be any).\n     */\n    jpeg_abort((j_common_ptr) cinfo); /* sets state = DSTATE_START */\n    retcode = JPEG_HEADER_TABLES_ONLY;\n    break;\n  case JPEG_SUSPENDED:\n    /* no work */\n    break;\n  }\n\n  return retcode;\n}\n\n\n/*\n * Consume data in advance of what the decompressor requires.\n * This can be called at any time once the decompressor object has\n * been created and a data source has been set up.\n *\n * This routine is essentially a state machine that handles a couple\n * of critical state-transition actions, namely initial setup and\n * transition from header scanning to ready-for-start_decompress.\n * All the actual input is done via the input controller's consume_input\n * method.\n */\n\nGLOBAL int\njpeg_consume_input (j_decompress_ptr cinfo)\n{\n  int retcode = JPEG_SUSPENDED;\n\n  /* NB: every possible DSTATE value should be listed in this switch */\n  switch (cinfo->global_state) {\n  case DSTATE_START:\n    /* Start-of-datastream actions: reset appropriate modules */\n    (*cinfo->inputctl->reset_input_controller) (cinfo);\n    /* Initialize application's data source module */\n    (*cinfo->src->init_source) (cinfo);\n    cinfo->global_state = DSTATE_INHEADER;\n    /*FALLTHROUGH*/\n  case DSTATE_INHEADER:\n    retcode = (*cinfo->inputctl->consume_input) (cinfo);\n    if (retcode == JPEG_REACHED_SOS) { /* Found SOS, prepare to decompress */\n      /* Set up default parameters based on header data */\n      default_decompress_parms(cinfo);\n      /* Set global state: ready for start_decompress */\n      cinfo->global_state = DSTATE_READY;\n    }\n    break;\n  case DSTATE_READY:\n    /* Can't advance past first SOS until start_decompress is called */\n    retcode = JPEG_REACHED_SOS;\n    break;\n  case DSTATE_PRELOAD:\n  case DSTATE_PRESCAN:\n  case DSTATE_SCANNING:\n  case DSTATE_RAW_OK:\n  case DSTATE_BUFIMAGE:\n  case DSTATE_BUFPOST:\n  case DSTATE_STOPPING:\n    retcode = (*cinfo->inputctl->consume_input) (cinfo);\n    break;\n  default:\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  }\n  return retcode;\n}\n\n\n/*\n * Have we finished reading the input file?\n */\n\nGLOBAL boolean\njpeg_input_complete (j_decompress_ptr cinfo)\n{\n  /* Check for valid jpeg object */\n  if (cinfo->global_state < DSTATE_START ||\n      cinfo->global_state > DSTATE_STOPPING)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  return cinfo->inputctl->eoi_reached;\n}\n\n\n/*\n * Is there more than one scan?\n */\n\nGLOBAL boolean\njpeg_has_multiple_scans (j_decompress_ptr cinfo)\n{\n  /* Only valid after jpeg_read_header completes */\n  if (cinfo->global_state < DSTATE_READY ||\n      cinfo->global_state > DSTATE_STOPPING)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  return cinfo->inputctl->has_multiple_scans;\n}\n\n\n/*\n * Finish JPEG decompression.\n *\n * This will normally just verify the file trailer and release temp storage.\n *\n * Returns FALSE if suspended.  The return value need be inspected only if\n * a suspending data source is used.\n */\n\nGLOBAL boolean\njpeg_finish_decompress (j_decompress_ptr cinfo)\n{\n  if ((cinfo->global_state == DSTATE_SCANNING ||\n       cinfo->global_state == DSTATE_RAW_OK) && ! cinfo->buffered_image) {\n    /* Terminate final pass of non-buffered mode */\n    if (cinfo->output_scanline < cinfo->output_height)\n      ERREXIT(cinfo, JERR_TOO_LITTLE_DATA);\n    (*cinfo->master->finish_output_pass) (cinfo);\n    cinfo->global_state = DSTATE_STOPPING;\n  } else if (cinfo->global_state == DSTATE_BUFIMAGE) {\n    /* Finishing after a buffered-image operation */\n    cinfo->global_state = DSTATE_STOPPING;\n  } else if (cinfo->global_state != DSTATE_STOPPING) {\n    /* STOPPING = repeat call after a suspension, anything else is error */\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  }\n  /* Read until EOI */\n  while (! cinfo->inputctl->eoi_reached) {\n    if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)\n      return FALSE;\t\t/* Suspend, come back later */\n  }\n  /* Do final cleanup */\n  (*cinfo->src->term_source) (cinfo);\n  /* We can use jpeg_abort to release memory and reset global_state */\n  jpeg_abort((j_common_ptr) cinfo);\n  return TRUE;\n}\n"
  },
  {
    "path": "libs/jpeg6/jdapistd.cpp",
    "content": "/*\n * jdapistd.c\n *\n * Copyright (C) 1994-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains application interface code for the decompression half\n * of the JPEG library.  These are the \"standard\" API routines that are\n * used in the normal full-decompression case.  They are not used by a\n * transcoding-only application.  Note that if an application links in\n * jpeg_start_decompress, it will end up linking in the entire decompressor.\n * We thus must separate this file from jdapimin.c to avoid linking the\n * whole decompression library into a transcoder.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/* Forward declarations */\nLOCAL boolean output_pass_setup JPP((j_decompress_ptr cinfo));\n\n\n/*\n * Decompression initialization.\n * jpeg_read_header must be completed before calling this.\n *\n * If a multipass operating mode was selected, this will do all but the\n * last pass, and thus may take a great deal of time.\n *\n * Returns FALSE if suspended.  The return value need be inspected only if\n * a suspending data source is used.\n */\n\nGLOBAL boolean\njpeg_start_decompress (j_decompress_ptr cinfo)\n{\n  if (cinfo->global_state == DSTATE_READY) {\n    /* First call: initialize master control, select active modules */\n    jinit_master_decompress(cinfo);\n    if (cinfo->buffered_image) {\n      /* No more work here; expecting jpeg_start_output next */\n      cinfo->global_state = DSTATE_BUFIMAGE;\n      return TRUE;\n    }\n    cinfo->global_state = DSTATE_PRELOAD;\n  }\n  if (cinfo->global_state == DSTATE_PRELOAD) {\n    /* If file has multiple scans, absorb them all into the coef buffer */\n    if (cinfo->inputctl->has_multiple_scans) {\n#ifdef D_MULTISCAN_FILES_SUPPORTED\n      for (;;) {\n\tint retcode;\n\t/* Call progress monitor hook if present */\n\tif (cinfo->progress != NULL)\n\t  (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);\n\t/* Absorb some more input */\n\tretcode = (*cinfo->inputctl->consume_input) (cinfo);\n\tif (retcode == JPEG_SUSPENDED)\n\t  return FALSE;\n\tif (retcode == JPEG_REACHED_EOI)\n\t  break;\n\t/* Advance progress counter if appropriate */\n\tif (cinfo->progress != NULL &&\n\t    (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {\n\t  if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {\n\t    /* jdmaster underestimated number of scans; ratchet up one scan */\n\t    cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;\n\t  }\n\t}\n      }\n#else\n      ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif /* D_MULTISCAN_FILES_SUPPORTED */\n    }\n    cinfo->output_scan_number = cinfo->input_scan_number;\n  } else if (cinfo->global_state != DSTATE_PRESCAN)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  /* Perform any dummy output passes, and set up for the final pass */\n  return output_pass_setup(cinfo);\n}\n\n\n/*\n * Set up for an output pass, and perform any dummy pass(es) needed.\n * Common subroutine for jpeg_start_decompress and jpeg_start_output.\n * Entry: global_state = DSTATE_PRESCAN only if previously suspended.\n * Exit: If done, returns TRUE and sets global_state for proper output mode.\n *       If suspended, returns FALSE and sets global_state = DSTATE_PRESCAN.\n */\n\nLOCAL boolean\noutput_pass_setup (j_decompress_ptr cinfo)\n{\n  if (cinfo->global_state != DSTATE_PRESCAN) {\n    /* First call: do pass setup */\n    (*cinfo->master->prepare_for_output_pass) (cinfo);\n    cinfo->output_scanline = 0;\n    cinfo->global_state = DSTATE_PRESCAN;\n  }\n  /* Loop over any required dummy passes */\n  while (cinfo->master->is_dummy_pass) {\n#ifdef QUANT_2PASS_SUPPORTED\n    /* Crank through the dummy pass */\n    while (cinfo->output_scanline < cinfo->output_height) {\n      JDIMENSION last_scanline;\n      /* Call progress monitor hook if present */\n      if (cinfo->progress != NULL) {\n\tcinfo->progress->pass_counter = (long) cinfo->output_scanline;\n\tcinfo->progress->pass_limit = (long) cinfo->output_height;\n\t(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);\n      }\n      /* Process some data */\n      last_scanline = cinfo->output_scanline;\n      (*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL,\n\t\t\t\t    &cinfo->output_scanline, (JDIMENSION) 0);\n      if (cinfo->output_scanline == last_scanline)\n\treturn FALSE;\t\t/* No progress made, must suspend */\n    }\n    /* Finish up dummy pass, and set up for another one */\n    (*cinfo->master->finish_output_pass) (cinfo);\n    (*cinfo->master->prepare_for_output_pass) (cinfo);\n    cinfo->output_scanline = 0;\n#else\n    ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif /* QUANT_2PASS_SUPPORTED */\n  }\n  /* Ready for application to drive output pass through\n   * jpeg_read_scanlines or jpeg_read_raw_data.\n   */\n  cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING;\n  return TRUE;\n}\n\n\n/*\n * Read some scanlines of data from the JPEG decompressor.\n *\n * The return value will be the number of lines actually read.\n * This may be less than the number requested in several cases,\n * including bottom of image, data source suspension, and operating\n * modes that emit multiple scanlines at a time.\n *\n * Note: we warn about excess calls to jpeg_read_scanlines() since\n * this likely signals an application programmer error.  However,\n * an oversize buffer (max_lines > scanlines remaining) is not an error.\n */\n\nGLOBAL JDIMENSION\njpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines,\n\t\t     JDIMENSION max_lines)\n{\n  JDIMENSION row_ctr;\n\n  if (cinfo->global_state != DSTATE_SCANNING)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  if (cinfo->output_scanline >= cinfo->output_height) {\n    WARNMS(cinfo, JWRN_TOO_MUCH_DATA);\n    return 0;\n  }\n\n  /* Call progress monitor hook if present */\n  if (cinfo->progress != NULL) {\n    cinfo->progress->pass_counter = (long) cinfo->output_scanline;\n    cinfo->progress->pass_limit = (long) cinfo->output_height;\n    (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);\n  }\n\n  /* Process some data */\n  row_ctr = 0;\n  (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines);\n  cinfo->output_scanline += row_ctr;\n  return row_ctr;\n}\n\n\n/*\n * Alternate entry point to read raw data.\n * Processes exactly one iMCU row per call, unless suspended.\n */\n\nGLOBAL JDIMENSION\njpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,\n\t\t    JDIMENSION max_lines)\n{\n  JDIMENSION lines_per_iMCU_row;\n\n  if (cinfo->global_state != DSTATE_RAW_OK)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  if (cinfo->output_scanline >= cinfo->output_height) {\n    WARNMS(cinfo, JWRN_TOO_MUCH_DATA);\n    return 0;\n  }\n\n  /* Call progress monitor hook if present */\n  if (cinfo->progress != NULL) {\n    cinfo->progress->pass_counter = (long) cinfo->output_scanline;\n    cinfo->progress->pass_limit = (long) cinfo->output_height;\n    (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);\n  }\n\n  /* Verify that at least one iMCU row can be returned. */\n  lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size;\n  if (max_lines < lines_per_iMCU_row)\n    ERREXIT(cinfo, JERR_BUFFER_SIZE);\n\n  /* Decompress directly into user's buffer. */\n  if (! (*cinfo->coef->decompress_data) (cinfo, data))\n    return 0;\t\t\t/* suspension forced, can do nothing more */\n\n  /* OK, we processed one iMCU row. */\n  cinfo->output_scanline += lines_per_iMCU_row;\n  return lines_per_iMCU_row;\n}\n\n\n/* Additional entry points for buffered-image mode. */\n\n#ifdef D_MULTISCAN_FILES_SUPPORTED\n\n/*\n * Initialize for an output pass in buffered-image mode.\n */\n\nGLOBAL boolean\njpeg_start_output (j_decompress_ptr cinfo, int scan_number)\n{\n  if (cinfo->global_state != DSTATE_BUFIMAGE &&\n      cinfo->global_state != DSTATE_PRESCAN)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  /* Limit scan number to valid range */\n  if (scan_number <= 0)\n    scan_number = 1;\n  if (cinfo->inputctl->eoi_reached &&\n      scan_number > cinfo->input_scan_number)\n    scan_number = cinfo->input_scan_number;\n  cinfo->output_scan_number = scan_number;\n  /* Perform any dummy output passes, and set up for the real pass */\n  return output_pass_setup(cinfo);\n}\n\n\n/*\n * Finish up after an output pass in buffered-image mode.\n *\n * Returns FALSE if suspended.  The return value need be inspected only if\n * a suspending data source is used.\n */\n\nGLOBAL boolean\njpeg_finish_output (j_decompress_ptr cinfo)\n{\n  if ((cinfo->global_state == DSTATE_SCANNING ||\n       cinfo->global_state == DSTATE_RAW_OK) && cinfo->buffered_image) {\n    /* Terminate this pass. */\n    /* We do not require the whole pass to have been completed. */\n    (*cinfo->master->finish_output_pass) (cinfo);\n    cinfo->global_state = DSTATE_BUFPOST;\n  } else if (cinfo->global_state != DSTATE_BUFPOST) {\n    /* BUFPOST = repeat call after a suspension, anything else is error */\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  }\n  /* Read markers looking for SOS or EOI */\n  while (cinfo->input_scan_number <= cinfo->output_scan_number &&\n\t ! cinfo->inputctl->eoi_reached) {\n    if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)\n      return FALSE;\t\t/* Suspend, come back later */\n  }\n  cinfo->global_state = DSTATE_BUFIMAGE;\n  return TRUE;\n}\n\n#endif /* D_MULTISCAN_FILES_SUPPORTED */\n"
  },
  {
    "path": "libs/jpeg6/jdatasrc.cpp",
    "content": "/*\n * jdatasrc.c\n *\n * Copyright (C) 1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains decompression data source routines for the case of\n * reading JPEG data from a file (or any stdio stream).  While these routines\n * are sufficient for most applications, some will want to use a different\n * source manager.\n * IMPORTANT: we assume that fread() will correctly transcribe an array of\n * JOCTETs from 8-bit-wide elements on external storage.  If char is wider\n * than 8 bits on your machine, you may need to do some tweaking.\n */\n\n\n/* this is not a core library module, so it doesn't define JPEG_INTERNALS */\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jerror.h\"\n\n\n/* Expanded data source object for stdio input */\n\ntypedef struct {\n  struct jpeg_source_mgr pub;\t/* public fields */\n\n  unsigned char *infile;\t\t/* source stream */\n  JOCTET * buffer;\t\t/* start of buffer */\n  boolean start_of_file;\t/* have we gotten any data yet? */\n} my_source_mgr;\n\ntypedef my_source_mgr * my_src_ptr;\n\n#define INPUT_BUF_SIZE  4096\t/* choose an efficiently fread'able size */\n\n\n/*\n * Initialize source --- called by jpeg_read_header\n * before any data is actually read.\n */\n\nMETHODDEF void\ninit_source (j_decompress_ptr cinfo)\n{\n  my_src_ptr src = (my_src_ptr) cinfo->src;\n\n  /* We reset the empty-input-file flag for each image,\n   * but we don't clear the input buffer.\n   * This is correct behavior for reading a series of images from one source.\n   */\n  src->start_of_file = TRUE;\n}\n\n\n/*\n * Fill the input buffer --- called whenever buffer is emptied.\n *\n * In typical applications, this should read fresh data into the buffer\n * (ignoring the current state of next_input_byte & bytes_in_buffer),\n * reset the pointer & count to the start of the buffer, and return TRUE\n * indicating that the buffer has been reloaded.  It is not necessary to\n * fill the buffer entirely, only to obtain at least one more byte.\n *\n * There is no such thing as an EOF return.  If the end of the file has been\n * reached, the routine has a choice of ERREXIT() or inserting fake data into\n * the buffer.  In most cases, generating a warning message and inserting a\n * fake EOI marker is the best course of action --- this will allow the\n * decompressor to output however much of the image is there.  However,\n * the resulting error message is misleading if the real problem is an empty\n * input file, so we handle that case specially.\n *\n * In applications that need to be able to suspend compression due to input\n * not being available yet, a FALSE return indicates that no more data can be\n * obtained right now, but more may be forthcoming later.  In this situation,\n * the decompressor will return to its caller (with an indication of the\n * number of scanlines it has read, if any).  The application should resume\n * decompression after it has loaded more data into the input buffer.  Note\n * that there are substantial restrictions on the use of suspension --- see\n * the documentation.\n *\n * When suspending, the decompressor will back up to a convenient restart point\n * (typically the start of the current MCU). next_input_byte & bytes_in_buffer\n * indicate where the restart point will be if the current call returns FALSE.\n * Data beyond this point must be rescanned after resumption, so move it to\n * the front of the buffer rather than discarding it.\n */\n\nMETHODDEF boolean\nfill_input_buffer (j_decompress_ptr cinfo)\n{\n  my_src_ptr src = (my_src_ptr) cinfo->src;\n\n  memcpy( src->buffer, src->infile, INPUT_BUF_SIZE );\n\n  src->infile += INPUT_BUF_SIZE;\n\n  src->pub.next_input_byte = src->buffer;\n  src->pub.bytes_in_buffer = INPUT_BUF_SIZE;\n  src->start_of_file = FALSE;\n\n  return TRUE;\n}\n\n\n/*\n * Skip data --- used to skip over a potentially large amount of\n * uninteresting data (such as an APPn marker).\n *\n * Writers of suspendable-input applications must note that skip_input_data\n * is not granted the right to give a suspension return.  If the skip extends\n * beyond the data currently in the buffer, the buffer can be marked empty so\n * that the next read will cause a fill_input_buffer call that can suspend.\n * Arranging for additional bytes to be discarded before reloading the input\n * buffer is the application writer's problem.\n */\n\nMETHODDEF void\nskip_input_data (j_decompress_ptr cinfo, long num_bytes)\n{\n  my_src_ptr src = (my_src_ptr) cinfo->src;\n\n  /* Just a dumb implementation for now.  Could use fseek() except\n   * it doesn't work on pipes.  Not clear that being smart is worth\n   * any trouble anyway --- large skips are infrequent.\n   */\n  if (num_bytes > 0) {\n    while (num_bytes > (long) src->pub.bytes_in_buffer) {\n      num_bytes -= (long) src->pub.bytes_in_buffer;\n      (void) fill_input_buffer(cinfo);\n      /* note we assume that fill_input_buffer will never return FALSE,\n       * so suspension need not be handled.\n       */\n    }\n    src->pub.next_input_byte += (size_t) num_bytes;\n    src->pub.bytes_in_buffer -= (size_t) num_bytes;\n  }\n}\n\n\n/*\n * An additional method that can be provided by data source modules is the\n * resync_to_restart method for error recovery in the presence of RST markers.\n * For the moment, this source module just uses the default resync method\n * provided by the JPEG library.  That method assumes that no backtracking\n * is possible.\n */\n\n\n/*\n * Terminate source --- called by jpeg_finish_decompress\n * after all data has been read.  Often a no-op.\n *\n * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding\n * application must deal with any cleanup that should happen even\n * for error exit.\n */\n\nMETHODDEF void\nterm_source (j_decompress_ptr cinfo)\n{\n  /* no work necessary here */\n}\n\n\n/*\n * Prepare for input from a stdio stream.\n * The caller must have already opened the stream, and is responsible\n * for closing it after finishing decompression.\n */\n\nGLOBAL void\njpeg_stdio_src (j_decompress_ptr cinfo, unsigned char *infile)\n{\n  my_src_ptr src;\n\n  /* The source object and input buffer are made permanent so that a series\n   * of JPEG images can be read from the same file by calling jpeg_stdio_src\n   * only before the first one.  (If we discarded the buffer at the end of\n   * one image, we'd likely lose the start of the next one.)\n   * This makes it unsafe to use this manager and a different source\n   * manager serially with the same JPEG object.  Caveat programmer.\n   */\n  if (cinfo->src == NULL) {\t/* first time for this JPEG object? */\n    cinfo->src = (struct jpeg_source_mgr *)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,\n\t\t\t\t  SIZEOF(my_source_mgr));\n    src = (my_src_ptr) cinfo->src;\n    src->buffer = (JOCTET *)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,\n\t\t\t\t  INPUT_BUF_SIZE * SIZEOF(JOCTET));\n  }\n\n  src = (my_src_ptr) cinfo->src;\n  src->pub.init_source = init_source;\n  src->pub.fill_input_buffer = fill_input_buffer;\n  src->pub.skip_input_data = skip_input_data;\n  src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */\n  src->pub.term_source = term_source;\n  src->infile = infile;\n  src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */\n  src->pub.next_input_byte = NULL; /* until buffer loaded */\n}\n"
  },
  {
    "path": "libs/jpeg6/jdcoefct.cpp",
    "content": "/*\n * jdcoefct.c\n *\n * Copyright (C) 1994-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains the coefficient buffer controller for decompression.\n * This controller is the top level of the JPEG decompressor proper.\n * The coefficient buffer lies between entropy decoding and inverse-DCT steps.\n *\n * In buffered-image mode, this controller is the interface between\n * input-oriented processing and output-oriented processing.\n * Also, the input side (only) is used when reading a file for transcoding.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n/* Block smoothing is only applicable for progressive JPEG, so: */\n#ifndef D_PROGRESSIVE_SUPPORTED\n#undef BLOCK_SMOOTHING_SUPPORTED\n#endif\n\n/* Private buffer controller object */\n\ntypedef struct {\n  struct jpeg_d_coef_controller pub; /* public fields */\n\n  /* These variables keep track of the current location of the input side. */\n  /* cinfo->input_iMCU_row is also used for this. */\n  JDIMENSION MCU_ctr;\t\t/* counts MCUs processed in current row */\n  int MCU_vert_offset;\t\t/* counts MCU rows within iMCU row */\n  int MCU_rows_per_iMCU_row;\t/* number of such rows needed */\n\n  /* The output side's location is represented by cinfo->output_iMCU_row. */\n\n  /* In single-pass modes, it's sufficient to buffer just one MCU.\n   * We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks,\n   * and let the entropy decoder write into that workspace each time.\n   * (On 80x86, the workspace is FAR even though it's not really very big;\n   * this is to keep the module interfaces unchanged when a large coefficient\n   * buffer is necessary.)\n   * In multi-pass modes, this array points to the current MCU's blocks\n   * within the virtual arrays; it is used only by the input side.\n   */\n  JBLOCKROW MCU_buffer[D_MAX_BLOCKS_IN_MCU];\n\n#ifdef D_MULTISCAN_FILES_SUPPORTED\n  /* In multi-pass modes, we need a virtual block array for each component. */\n  jvirt_barray_ptr whole_image[MAX_COMPONENTS];\n#endif\n\n#ifdef BLOCK_SMOOTHING_SUPPORTED\n  /* When doing block smoothing, we latch coefficient Al values here */\n  int * coef_bits_latch;\n#define SAVED_COEFS  6\t\t/* we save coef_bits[0..5] */\n#endif\n} my_coef_controller;\n\ntypedef my_coef_controller * my_coef_ptr;\n\n/* Forward declarations */\nMETHODDEF int decompress_onepass\n\tJPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));\n#ifdef D_MULTISCAN_FILES_SUPPORTED\nMETHODDEF int decompress_data\n\tJPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));\n#endif\n#ifdef BLOCK_SMOOTHING_SUPPORTED\nLOCAL boolean smoothing_ok JPP((j_decompress_ptr cinfo));\nMETHODDEF int decompress_smooth_data\n\tJPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));\n#endif\n\n\nLOCAL void\nstart_iMCU_row (j_decompress_ptr cinfo)\n/* Reset within-iMCU-row counters for a new row (input side) */\n{\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n\n  /* In an interleaved scan, an MCU row is the same as an iMCU row.\n   * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.\n   * But at the bottom of the image, process only what's left.\n   */\n  if (cinfo->comps_in_scan > 1) {\n    coef->MCU_rows_per_iMCU_row = 1;\n  } else {\n    if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1))\n      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;\n    else\n      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;\n  }\n\n  coef->MCU_ctr = 0;\n  coef->MCU_vert_offset = 0;\n}\n\n\n/*\n * Initialize for an input processing pass.\n */\n\nMETHODDEF void\nstart_input_pass (j_decompress_ptr cinfo)\n{\n  cinfo->input_iMCU_row = 0;\n  start_iMCU_row(cinfo);\n}\n\n\n/*\n * Initialize for an output processing pass.\n */\n\nMETHODDEF void\nstart_output_pass (j_decompress_ptr cinfo)\n{\n#ifdef BLOCK_SMOOTHING_SUPPORTED\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n\n  /* If multipass, check to see whether to use block smoothing on this pass */\n  if (coef->pub.coef_arrays != NULL) {\n    if (cinfo->do_block_smoothing && smoothing_ok(cinfo))\n      coef->pub.decompress_data = decompress_smooth_data;\n    else\n      coef->pub.decompress_data = decompress_data;\n  }\n#endif\n  cinfo->output_iMCU_row = 0;\n}\n\n\n/*\n * Decompress and return some data in the single-pass case.\n * Always attempts to emit one fully interleaved MCU row (\"iMCU\" row).\n * Input and output must run in lockstep since we have only a one-MCU buffer.\n * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.\n *\n * NB: output_buf contains a plane for each component in image.\n * For single pass, this is the same as the components in the scan.\n */\n\nMETHODDEF int\ndecompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)\n{\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n  JDIMENSION MCU_col_num;\t/* index of current MCU within row */\n  JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;\n  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;\n  int blkn, ci, xindex, yindex, yoffset, useful_width;\n  JSAMPARRAY output_ptr;\n  JDIMENSION start_col, output_col;\n  jpeg_component_info *compptr;\n  inverse_DCT_method_ptr inverse_DCT;\n\n  /* Loop to process as much as one whole iMCU row */\n  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;\n       yoffset++) {\n    for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;\n\t MCU_col_num++) {\n      /* Try to fetch an MCU.  Entropy decoder expects buffer to be zeroed. */\n      jzero_far((void FAR *) coef->MCU_buffer[0],\n\t\t(size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK)));\n      if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {\n\t/* Suspension forced; update state counters and exit */\n\tcoef->MCU_vert_offset = yoffset;\n\tcoef->MCU_ctr = MCU_col_num;\n\treturn JPEG_SUSPENDED;\n      }\n      /* Determine where data should go in output_buf and do the IDCT thing.\n       * We skip dummy blocks at the right and bottom edges (but blkn gets\n       * incremented past them!).  Note the inner loop relies on having\n       * allocated the MCU_buffer[] blocks sequentially.\n       */\n      blkn = 0;\t\t\t/* index of current DCT block within MCU */\n      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n\tcompptr = cinfo->cur_comp_info[ci];\n\t/* Don't bother to IDCT an uninteresting component. */\n\tif (! compptr->component_needed) {\n\t  blkn += compptr->MCU_blocks;\n\t  continue;\n\t}\n\tinverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index];\n\tuseful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width\n\t\t\t\t\t\t    : compptr->last_col_width;\n\toutput_ptr = output_buf[ci] + yoffset * compptr->DCT_scaled_size;\n\tstart_col = MCU_col_num * compptr->MCU_sample_width;\n\tfor (yindex = 0; yindex < compptr->MCU_height; yindex++) {\n\t  if (cinfo->input_iMCU_row < last_iMCU_row ||\n\t      yoffset+yindex < compptr->last_row_height) {\n\t    output_col = start_col;\n\t    for (xindex = 0; xindex < useful_width; xindex++) {\n\t      (*inverse_DCT) (cinfo, compptr,\n\t\t\t      (JCOEFPTR) coef->MCU_buffer[blkn+xindex],\n\t\t\t      output_ptr, output_col);\n\t      output_col += compptr->DCT_scaled_size;\n\t    }\n\t  }\n\t  blkn += compptr->MCU_width;\n\t  output_ptr += compptr->DCT_scaled_size;\n\t}\n      }\n    }\n    /* Completed an MCU row, but perhaps not an iMCU row */\n    coef->MCU_ctr = 0;\n  }\n  /* Completed the iMCU row, advance counters for next one */\n  cinfo->output_iMCU_row++;\n  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {\n    start_iMCU_row(cinfo);\n    return JPEG_ROW_COMPLETED;\n  }\n  /* Completed the scan */\n  (*cinfo->inputctl->finish_input_pass) (cinfo);\n  return JPEG_SCAN_COMPLETED;\n}\n\n\n/*\n * Dummy consume-input routine for single-pass operation.\n */\n\nMETHODDEF int\ndummy_consume_data (j_decompress_ptr cinfo)\n{\n  return JPEG_SUSPENDED;\t/* Always indicate nothing was done */\n}\n\n\n#ifdef D_MULTISCAN_FILES_SUPPORTED\n\n/*\n * Consume input data and store it in the full-image coefficient buffer.\n * We read as much as one fully interleaved MCU row (\"iMCU\" row) per call,\n * ie, v_samp_factor block rows for each component in the scan.\n * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.\n */\n\nMETHODDEF int\nconsume_data (j_decompress_ptr cinfo)\n{\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n  JDIMENSION MCU_col_num;\t/* index of current MCU within row */\n  int blkn, ci, xindex, yindex, yoffset;\n  JDIMENSION start_col;\n  JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];\n  JBLOCKROW buffer_ptr;\n  jpeg_component_info *compptr;\n\n  /* Align the virtual buffers for the components used in this scan. */\n  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n    compptr = cinfo->cur_comp_info[ci];\n    buffer[ci] = (*cinfo->mem->access_virt_barray)\n      ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],\n       cinfo->input_iMCU_row * compptr->v_samp_factor,\n       (JDIMENSION) compptr->v_samp_factor, TRUE);\n    /* Note: entropy decoder expects buffer to be zeroed,\n     * but this is handled automatically by the memory manager\n     * because we requested a pre-zeroed array.\n     */\n  }\n\n  /* Loop to process one whole iMCU row */\n  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;\n       yoffset++) {\n    for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;\n\t MCU_col_num++) {\n      /* Construct list of pointers to DCT blocks belonging to this MCU */\n      blkn = 0;\t\t\t/* index of current DCT block within MCU */\n      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n\tcompptr = cinfo->cur_comp_info[ci];\n\tstart_col = MCU_col_num * compptr->MCU_width;\n\tfor (yindex = 0; yindex < compptr->MCU_height; yindex++) {\n\t  buffer_ptr = buffer[ci][yindex+yoffset] + start_col;\n\t  for (xindex = 0; xindex < compptr->MCU_width; xindex++) {\n\t    coef->MCU_buffer[blkn++] = buffer_ptr++;\n\t  }\n\t}\n      }\n      /* Try to fetch the MCU. */\n      if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {\n\t/* Suspension forced; update state counters and exit */\n\tcoef->MCU_vert_offset = yoffset;\n\tcoef->MCU_ctr = MCU_col_num;\n\treturn JPEG_SUSPENDED;\n      }\n    }\n    /* Completed an MCU row, but perhaps not an iMCU row */\n    coef->MCU_ctr = 0;\n  }\n  /* Completed the iMCU row, advance counters for next one */\n  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {\n    start_iMCU_row(cinfo);\n    return JPEG_ROW_COMPLETED;\n  }\n  /* Completed the scan */\n  (*cinfo->inputctl->finish_input_pass) (cinfo);\n  return JPEG_SCAN_COMPLETED;\n}\n\n\n/*\n * Decompress and return some data in the multi-pass case.\n * Always attempts to emit one fully interleaved MCU row (\"iMCU\" row).\n * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.\n *\n * NB: output_buf contains a plane for each component in image.\n */\n\nMETHODDEF int\ndecompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)\n{\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;\n  JDIMENSION block_num;\n  int ci, block_row, block_rows;\n  JBLOCKARRAY buffer;\n  JBLOCKROW buffer_ptr;\n  JSAMPARRAY output_ptr;\n  JDIMENSION output_col;\n  jpeg_component_info *compptr;\n  inverse_DCT_method_ptr inverse_DCT;\n\n  /* Force some input to be done if we are getting ahead of the input. */\n  while (cinfo->input_scan_number < cinfo->output_scan_number ||\n\t (cinfo->input_scan_number == cinfo->output_scan_number &&\n\t  cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) {\n    if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED)\n      return JPEG_SUSPENDED;\n  }\n\n  /* OK, output from the virtual arrays. */\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    /* Don't bother to IDCT an uninteresting component. */\n    if (! compptr->component_needed)\n      continue;\n    /* Align the virtual buffer for this component. */\n    buffer = (*cinfo->mem->access_virt_barray)\n      ((j_common_ptr) cinfo, coef->whole_image[ci],\n       cinfo->output_iMCU_row * compptr->v_samp_factor,\n       (JDIMENSION) compptr->v_samp_factor, FALSE);\n    /* Count non-dummy DCT block rows in this iMCU row. */\n    if (cinfo->output_iMCU_row < last_iMCU_row)\n      block_rows = compptr->v_samp_factor;\n    else {\n      /* NB: can't use last_row_height here; it is input-side-dependent! */\n      block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);\n      if (block_rows == 0) block_rows = compptr->v_samp_factor;\n    }\n    inverse_DCT = cinfo->idct->inverse_DCT[ci];\n    output_ptr = output_buf[ci];\n    /* Loop over all DCT blocks to be processed. */\n    for (block_row = 0; block_row < block_rows; block_row++) {\n      buffer_ptr = buffer[block_row];\n      output_col = 0;\n      for (block_num = 0; block_num < compptr->width_in_blocks; block_num++) {\n\t(*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr,\n\t\t\toutput_ptr, output_col);\n\tbuffer_ptr++;\n\toutput_col += compptr->DCT_scaled_size;\n      }\n      output_ptr += compptr->DCT_scaled_size;\n    }\n  }\n\n  if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)\n    return JPEG_ROW_COMPLETED;\n  return JPEG_SCAN_COMPLETED;\n}\n\n#endif /* D_MULTISCAN_FILES_SUPPORTED */\n\n\n#ifdef BLOCK_SMOOTHING_SUPPORTED\n\n/*\n * This code applies interblock smoothing as described by section K.8\n * of the JPEG standard: the first 5 AC coefficients are estimated from\n * the DC values of a DCT block and its 8 neighboring blocks.\n * We apply smoothing only for progressive JPEG decoding, and only if\n * the coefficients it can estimate are not yet known to full precision.\n */\n\n/*\n * Determine whether block smoothing is applicable and safe.\n * We also latch the current states of the coef_bits[] entries for the\n * AC coefficients; otherwise, if the input side of the decompressor\n * advances into a new scan, we might think the coefficients are known\n * more accurately than they really are.\n */\n\nLOCAL boolean\nsmoothing_ok (j_decompress_ptr cinfo)\n{\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n  boolean smoothing_useful = FALSE;\n  int ci, coefi;\n  jpeg_component_info *compptr;\n  JQUANT_TBL * qtable;\n  int * coef_bits;\n  int * coef_bits_latch;\n\n  if (! cinfo->progressive_mode || cinfo->coef_bits == NULL)\n    return FALSE;\n\n  /* Allocate latch area if not already done */\n  if (coef->coef_bits_latch == NULL)\n    coef->coef_bits_latch = (int *)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t  cinfo->num_components *\n\t\t\t\t  (SAVED_COEFS * SIZEOF(int)));\n  coef_bits_latch = coef->coef_bits_latch;\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    /* All components' quantization values must already be latched. */\n    if ((qtable = compptr->quant_table) == NULL)\n      return FALSE;\n    /* Verify DC & first 5 AC quantizers are nonzero to avoid zero-divide. */\n    for (coefi = 0; coefi <= 5; coefi++) {\n      if (qtable->quantval[coefi] == 0)\n\treturn FALSE;\n    }\n    /* DC values must be at least partly known for all components. */\n    coef_bits = cinfo->coef_bits[ci];\n    if (coef_bits[0] < 0)\n      return FALSE;\n    /* Block smoothing is helpful if some AC coefficients remain inaccurate. */\n    for (coefi = 1; coefi <= 5; coefi++) {\n      coef_bits_latch[coefi] = coef_bits[coefi];\n      if (coef_bits[coefi] != 0)\n\tsmoothing_useful = TRUE;\n    }\n    coef_bits_latch += SAVED_COEFS;\n  }\n\n  return smoothing_useful;\n}\n\n\n/*\n * Variant of decompress_data for use when doing block smoothing.\n */\n\nMETHODDEF int\ndecompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)\n{\n  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\n  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;\n  JDIMENSION block_num, last_block_column;\n  int ci, block_row, block_rows, access_rows;\n  JBLOCKARRAY buffer;\n  JBLOCKROW buffer_ptr, prev_block_row, next_block_row;\n  JSAMPARRAY output_ptr;\n  JDIMENSION output_col;\n  jpeg_component_info *compptr;\n  inverse_DCT_method_ptr inverse_DCT;\n  boolean first_row, last_row;\n  JBLOCK workspace;\n  int *coef_bits;\n  JQUANT_TBL *quanttbl;\n  INT32 Q00,Q01,Q02,Q10,Q11,Q20, num;\n  int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9;\n  int Al, pred;\n\n  /* Force some input to be done if we are getting ahead of the input. */\n  while (cinfo->input_scan_number <= cinfo->output_scan_number &&\n\t ! cinfo->inputctl->eoi_reached) {\n    if (cinfo->input_scan_number == cinfo->output_scan_number) {\n      /* If input is working on current scan, we ordinarily want it to\n       * have completed the current row.  But if input scan is DC,\n       * we want it to keep one row ahead so that next block row's DC\n       * values are up to date.\n       */\n      JDIMENSION delta = (cinfo->Ss == 0) ? 1 : 0;\n      if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta)\n\tbreak;\n    }\n    if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED)\n      return JPEG_SUSPENDED;\n  }\n\n  /* OK, output from the virtual arrays. */\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    /* Don't bother to IDCT an uninteresting component. */\n    if (! compptr->component_needed)\n      continue;\n    /* Count non-dummy DCT block rows in this iMCU row. */\n    if (cinfo->output_iMCU_row < last_iMCU_row) {\n      block_rows = compptr->v_samp_factor;\n      access_rows = block_rows * 2; /* this and next iMCU row */\n      last_row = FALSE;\n    } else {\n      /* NB: can't use last_row_height here; it is input-side-dependent! */\n      block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);\n      if (block_rows == 0) block_rows = compptr->v_samp_factor;\n      access_rows = block_rows; /* this iMCU row only */\n      last_row = TRUE;\n    }\n    /* Align the virtual buffer for this component. */\n    if (cinfo->output_iMCU_row > 0) {\n      access_rows += compptr->v_samp_factor; /* prior iMCU row too */\n      buffer = (*cinfo->mem->access_virt_barray)\n\t((j_common_ptr) cinfo, coef->whole_image[ci],\n\t (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor,\n\t (JDIMENSION) access_rows, FALSE);\n      buffer += compptr->v_samp_factor;\t/* point to current iMCU row */\n      first_row = FALSE;\n    } else {\n      buffer = (*cinfo->mem->access_virt_barray)\n\t((j_common_ptr) cinfo, coef->whole_image[ci],\n\t (JDIMENSION) 0, (JDIMENSION) access_rows, FALSE);\n      first_row = TRUE;\n    }\n    /* Fetch component-dependent info */\n    coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS);\n    quanttbl = compptr->quant_table;\n    Q00 = quanttbl->quantval[0];\n    Q01 = quanttbl->quantval[1];\n    Q10 = quanttbl->quantval[2];\n    Q20 = quanttbl->quantval[3];\n    Q11 = quanttbl->quantval[4];\n    Q02 = quanttbl->quantval[5];\n    inverse_DCT = cinfo->idct->inverse_DCT[ci];\n    output_ptr = output_buf[ci];\n    /* Loop over all DCT blocks to be processed. */\n    for (block_row = 0; block_row < block_rows; block_row++) {\n      buffer_ptr = buffer[block_row];\n      if (first_row && block_row == 0)\n\tprev_block_row = buffer_ptr;\n      else\n\tprev_block_row = buffer[block_row-1];\n      if (last_row && block_row == block_rows-1)\n\tnext_block_row = buffer_ptr;\n      else\n\tnext_block_row = buffer[block_row+1];\n      /* We fetch the surrounding DC values using a sliding-register approach.\n       * Initialize all nine here so as to do the right thing on narrow pics.\n       */\n      DC1 = DC2 = DC3 = (int) prev_block_row[0][0];\n      DC4 = DC5 = DC6 = (int) buffer_ptr[0][0];\n      DC7 = DC8 = DC9 = (int) next_block_row[0][0];\n      output_col = 0;\n      last_block_column = compptr->width_in_blocks - 1;\n      for (block_num = 0; block_num <= last_block_column; block_num++) {\n\t/* Fetch current DCT block into workspace so we can modify it. */\n\tjcopy_block_row(buffer_ptr, (JBLOCKROW) workspace, (JDIMENSION) 1);\n\t/* Update DC values */\n\tif (block_num < last_block_column) {\n\t  DC3 = (int) prev_block_row[1][0];\n\t  DC6 = (int) buffer_ptr[1][0];\n\t  DC9 = (int) next_block_row[1][0];\n\t}\n\t/* Compute coefficient estimates per K.8.\n\t * An estimate is applied only if coefficient is still zero,\n\t * and is not known to be fully accurate.\n\t */\n\t/* AC01 */\n\tif ((Al=coef_bits[1]) != 0 && workspace[1] == 0) {\n\t  num = 36 * Q00 * (DC4 - DC6);\n\t  if (num >= 0) {\n\t    pred = (int) (((Q01<<7) + num) / (Q01<<8));\n\t    if (Al > 0 && pred >= (1<<Al))\n\t      pred = (1<<Al)-1;\n\t  } else {\n\t    pred = (int) (((Q01<<7) - num) / (Q01<<8));\n\t    if (Al > 0 && pred >= (1<<Al))\n\t      pred = (1<<Al)-1;\n\t    pred = -pred;\n\t  }\n\t  workspace[1] = (JCOEF) pred;\n\t}\n\t/* AC10 */\n\tif ((Al=coef_bits[2]) != 0 && workspace[8] == 0) {\n\t  num = 36 * Q00 * (DC2 - DC8);\n\t  if (num >= 0) {\n\t    pred = (int) (((Q10<<7) + num) / (Q10<<8));\n\t    if (Al > 0 && pred >= (1<<Al))\n\t      pred = (1<<Al)-1;\n\t  } else {\n\t    pred = (int) (((Q10<<7) - num) / (Q10<<8));\n\t    if (Al > 0 && pred >= (1<<Al))\n\t      pred = (1<<Al)-1;\n\t    pred = -pred;\n\t  }\n\t  workspace[8] = (JCOEF) pred;\n\t}\n\t/* AC20 */\n\tif ((Al=coef_bits[3]) != 0 && workspace[16] == 0) {\n\t  num = 9 * Q00 * (DC2 + DC8 - 2*DC5);\n\t  if (num >= 0) {\n\t    pred = (int) (((Q20<<7) + num) / (Q20<<8));\n\t    if (Al > 0 && pred >= (1<<Al))\n\t      pred = (1<<Al)-1;\n\t  } else {\n\t    pred = (int) (((Q20<<7) - num) / (Q20<<8));\n\t    if (Al > 0 && pred >= (1<<Al))\n\t      pred = (1<<Al)-1;\n\t    pred = -pred;\n\t  }\n\t  workspace[16] = (JCOEF) pred;\n\t}\n\t/* AC11 */\n\tif ((Al=coef_bits[4]) != 0 && workspace[9] == 0) {\n\t  num = 5 * Q00 * (DC1 - DC3 - DC7 + DC9);\n\t  if (num >= 0) {\n\t    pred = (int) (((Q11<<7) + num) / (Q11<<8));\n\t    if (Al > 0 && pred >= (1<<Al))\n\t      pred = (1<<Al)-1;\n\t  } else {\n\t    pred = (int) (((Q11<<7) - num) / (Q11<<8));\n\t    if (Al > 0 && pred >= (1<<Al))\n\t      pred = (1<<Al)-1;\n\t    pred = -pred;\n\t  }\n\t  workspace[9] = (JCOEF) pred;\n\t}\n\t/* AC02 */\n\tif ((Al=coef_bits[5]) != 0 && workspace[2] == 0) {\n\t  num = 9 * Q00 * (DC4 + DC6 - 2*DC5);\n\t  if (num >= 0) {\n\t    pred = (int) (((Q02<<7) + num) / (Q02<<8));\n\t    if (Al > 0 && pred >= (1<<Al))\n\t      pred = (1<<Al)-1;\n\t  } else {\n\t    pred = (int) (((Q02<<7) - num) / (Q02<<8));\n\t    if (Al > 0 && pred >= (1<<Al))\n\t      pred = (1<<Al)-1;\n\t    pred = -pred;\n\t  }\n\t  workspace[2] = (JCOEF) pred;\n\t}\n\t/* OK, do the IDCT */\n\t(*inverse_DCT) (cinfo, compptr, (JCOEFPTR) workspace,\n\t\t\toutput_ptr, output_col);\n\t/* Advance for next column */\n\tDC1 = DC2; DC2 = DC3;\n\tDC4 = DC5; DC5 = DC6;\n\tDC7 = DC8; DC8 = DC9;\n\tbuffer_ptr++, prev_block_row++, next_block_row++;\n\toutput_col += compptr->DCT_scaled_size;\n      }\n      output_ptr += compptr->DCT_scaled_size;\n    }\n  }\n\n  if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)\n    return JPEG_ROW_COMPLETED;\n  return JPEG_SCAN_COMPLETED;\n}\n\n#endif /* BLOCK_SMOOTHING_SUPPORTED */\n\n\n/*\n * Initialize coefficient buffer controller.\n */\n\nGLOBAL void\njinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)\n{\n  my_coef_ptr coef;\n\n  coef = (my_coef_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_coef_controller));\n  cinfo->coef = (struct jpeg_d_coef_controller *) coef;\n  coef->pub.start_input_pass = start_input_pass;\n  coef->pub.start_output_pass = start_output_pass;\n#ifdef BLOCK_SMOOTHING_SUPPORTED\n  coef->coef_bits_latch = NULL;\n#endif\n\n  /* Create the coefficient buffer. */\n  if (need_full_buffer) {\n#ifdef D_MULTISCAN_FILES_SUPPORTED\n    /* Allocate a full-image virtual array for each component, */\n    /* padded to a multiple of samp_factor DCT blocks in each direction. */\n    /* Note we ask for a pre-zeroed array. */\n    int ci, access_rows;\n    jpeg_component_info *compptr;\n\n    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n\t ci++, compptr++) {\n      access_rows = compptr->v_samp_factor;\n#ifdef BLOCK_SMOOTHING_SUPPORTED\n      /* If block smoothing could be used, need a bigger window */\n      if (cinfo->progressive_mode)\n\taccess_rows *= 3;\n#endif\n      coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)\n\t((j_common_ptr) cinfo, JPOOL_IMAGE, TRUE,\n\t (JDIMENSION) jround_up((long) compptr->width_in_blocks,\n\t\t\t\t(long) compptr->h_samp_factor),\n\t (JDIMENSION) jround_up((long) compptr->height_in_blocks,\n\t\t\t\t(long) compptr->v_samp_factor),\n\t (JDIMENSION) access_rows);\n    }\n    coef->pub.consume_data = consume_data;\n    coef->pub.decompress_data = decompress_data;\n    coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */\n#else\n    ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif\n  } else {\n    /* We only need a single-MCU buffer. */\n    JBLOCKROW buffer;\n    int i;\n\n    buffer = (JBLOCKROW)\n      (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t  D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));\n    for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {\n      coef->MCU_buffer[i] = buffer + i;\n    }\n    coef->pub.consume_data = dummy_consume_data;\n    coef->pub.decompress_data = decompress_onepass;\n    coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */\n  }\n}\n"
  },
  {
    "path": "libs/jpeg6/jdcolor.cpp",
    "content": "/*\n * jdcolor.c\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains output colorspace conversion routines.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/* Private subobject */\n\ntypedef struct {\n  struct jpeg_color_deconverter pub; /* public fields */\n\n  /* Private state for YCC->RGB conversion */\n  int * Cr_r_tab;\t\t/* => table for Cr to R conversion */\n  int * Cb_b_tab;\t\t/* => table for Cb to B conversion */\n  INT32 * Cr_g_tab;\t\t/* => table for Cr to G conversion */\n  INT32 * Cb_g_tab;\t\t/* => table for Cb to G conversion */\n} my_color_deconverter;\n\ntypedef my_color_deconverter * my_cconvert_ptr;\n\n\n/**************** YCbCr -> RGB conversion: most common case **************/\n\n/*\n * YCbCr is defined per CCIR 601-1, except that Cb and Cr are\n * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.\n * The conversion equations to be implemented are therefore\n *\tR = Y                + 1.40200 * Cr\n *\tG = Y - 0.34414 * Cb - 0.71414 * Cr\n *\tB = Y + 1.77200 * Cb\n * where Cb and Cr represent the incoming values less CENTERJSAMPLE.\n * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)\n *\n * To avoid floating-point arithmetic, we represent the fractional constants\n * as integers scaled up by 2^16 (about 4 digits precision); we have to divide\n * the products by 2^16, with appropriate rounding, to get the correct answer.\n * Notice that Y, being an integral input, does not contribute any fraction\n * so it need not participate in the rounding.\n *\n * For even more speed, we avoid doing any multiplications in the inner loop\n * by precalculating the constants times Cb and Cr for all possible values.\n * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);\n * for 12-bit samples it is still acceptable.  It's not very reasonable for\n * 16-bit samples, but if you want lossless storage you shouldn't be changing\n * colorspace anyway.\n * The Cr=>R and Cb=>B values can be rounded to integers in advance; the\n * values for the G calculation are left scaled up, since we must add them\n * together before rounding.\n */\n\n#define SCALEBITS\t16\t/* speediest right-shift on some machines */\n#define ONE_HALF\t((INT32) 1 << (SCALEBITS-1))\n#define FIX(x)\t\t((INT32) ((x) * (1L<<SCALEBITS) + 0.5))\n\n\n/*\n * Initialize tables for YCC->RGB colorspace conversion.\n */\n\nLOCAL void\nbuild_ycc_rgb_table (j_decompress_ptr cinfo)\n{\n  my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;\n  int i;\n  INT32 x;\n  SHIFT_TEMPS\n\n  cconvert->Cr_r_tab = (int *)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t(MAXJSAMPLE+1) * SIZEOF(int));\n  cconvert->Cb_b_tab = (int *)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t(MAXJSAMPLE+1) * SIZEOF(int));\n  cconvert->Cr_g_tab = (INT32 *)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t(MAXJSAMPLE+1) * SIZEOF(INT32));\n  cconvert->Cb_g_tab = (INT32 *)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t(MAXJSAMPLE+1) * SIZEOF(INT32));\n\n  for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {\n    /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */\n    /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */\n    /* Cr=>R value is nearest int to 1.40200 * x */\n    cconvert->Cr_r_tab[i] = (int)\n\t\t    RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS);\n    /* Cb=>B value is nearest int to 1.77200 * x */\n    cconvert->Cb_b_tab[i] = (int)\n\t\t    RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS);\n    /* Cr=>G value is scaled-up -0.71414 * x */\n    cconvert->Cr_g_tab[i] = (- FIX(0.71414)) * x;\n    /* Cb=>G value is scaled-up -0.34414 * x */\n    /* We also add in ONE_HALF so that need not do it in inner loop */\n    cconvert->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF;\n  }\n}\n\n\n/*\n * Convert some rows of samples to the output colorspace.\n *\n * Note that we change from noninterleaved, one-plane-per-component format\n * to interleaved-pixel format.  The output buffer is therefore three times\n * as wide as the input buffer.\n * A starting row offset is provided only for the input buffer.  The caller\n * can easily adjust the passed output_buf value to accommodate any row\n * offset required on that side.\n */\n\nMETHODDEF void\nycc_rgb_convert (j_decompress_ptr cinfo,\n\t\t JSAMPIMAGE input_buf, JDIMENSION input_row,\n\t\t JSAMPARRAY output_buf, int num_rows)\n{\n  my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;\n  register int y, cb, cr;\n  register JSAMPROW outptr;\n  register JSAMPROW inptr0, inptr1, inptr2;\n  register JDIMENSION col;\n  JDIMENSION num_cols = cinfo->output_width;\n  /* copy these pointers into registers if possible */\n  register JSAMPLE * range_limit = cinfo->sample_range_limit;\n  register int * Crrtab = cconvert->Cr_r_tab;\n  register int * Cbbtab = cconvert->Cb_b_tab;\n  register INT32 * Crgtab = cconvert->Cr_g_tab;\n  register INT32 * Cbgtab = cconvert->Cb_g_tab;\n  SHIFT_TEMPS\n\n  while (--num_rows >= 0) {\n    inptr0 = input_buf[0][input_row];\n    inptr1 = input_buf[1][input_row];\n    inptr2 = input_buf[2][input_row];\n    input_row++;\n    outptr = *output_buf++;\n    for (col = 0; col < num_cols; col++) {\n      y  = GETJSAMPLE(inptr0[col]);\n      cb = GETJSAMPLE(inptr1[col]);\n      cr = GETJSAMPLE(inptr2[col]);\n      /* Range-limiting is essential due to noise introduced by DCT losses. */\n      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];\n      outptr[RGB_GREEN] = range_limit[y +\n\t\t\t      ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],\n\t\t\t\t\t\t SCALEBITS))];\n      outptr[RGB_BLUE] =  range_limit[y + Cbbtab[cb]];\n      outptr += RGB_PIXELSIZE;\n    }\n  }\n}\n\n\n/**************** Cases other than YCbCr -> RGB **************/\n\n\n/*\n * Color conversion for no colorspace change: just copy the data,\n * converting from separate-planes to interleaved representation.\n */\n\nMETHODDEF void\nnull_convert (j_decompress_ptr cinfo,\n\t      JSAMPIMAGE input_buf, JDIMENSION input_row,\n\t      JSAMPARRAY output_buf, int num_rows)\n{\n  register JSAMPROW inptr, outptr;\n  register JDIMENSION count;\n  register int num_components = cinfo->num_components;\n  JDIMENSION num_cols = cinfo->output_width;\n  int ci;\n\n  while (--num_rows >= 0) {\n    for (ci = 0; ci < num_components; ci++) {\n      inptr = input_buf[ci][input_row];\n      outptr = output_buf[0] + ci;\n      for (count = num_cols; count > 0; count--) {\n\t*outptr = *inptr++;\t/* needn't bother with GETJSAMPLE() here */\n\toutptr += num_components;\n      }\n    }\n    input_row++;\n    output_buf++;\n  }\n}\n\n\n/*\n * Color conversion for grayscale: just copy the data.\n * This also works for YCbCr -> grayscale conversion, in which\n * we just copy the Y (luminance) component and ignore chrominance.\n */\n\nMETHODDEF void\ngrayscale_convert (j_decompress_ptr cinfo,\n\t\t   JSAMPIMAGE input_buf, JDIMENSION input_row,\n\t\t   JSAMPARRAY output_buf, int num_rows)\n{\n  jcopy_sample_rows(input_buf[0], (int) input_row, output_buf, 0,\n\t\t    num_rows, cinfo->output_width);\n}\n\n\n/*\n * Adobe-style YCCK->CMYK conversion.\n * We convert YCbCr to R=1-C, G=1-M, and B=1-Y using the same\n * conversion as above, while passing K (black) unchanged.\n * We assume build_ycc_rgb_table has been called.\n */\n\nMETHODDEF void\nycck_cmyk_convert (j_decompress_ptr cinfo,\n\t\t   JSAMPIMAGE input_buf, JDIMENSION input_row,\n\t\t   JSAMPARRAY output_buf, int num_rows)\n{\n  my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;\n  register int y, cb, cr;\n  register JSAMPROW outptr;\n  register JSAMPROW inptr0, inptr1, inptr2, inptr3;\n  register JDIMENSION col;\n  JDIMENSION num_cols = cinfo->output_width;\n  /* copy these pointers into registers if possible */\n  register JSAMPLE * range_limit = cinfo->sample_range_limit;\n  register int * Crrtab = cconvert->Cr_r_tab;\n  register int * Cbbtab = cconvert->Cb_b_tab;\n  register INT32 * Crgtab = cconvert->Cr_g_tab;\n  register INT32 * Cbgtab = cconvert->Cb_g_tab;\n  SHIFT_TEMPS\n\n  while (--num_rows >= 0) {\n    inptr0 = input_buf[0][input_row];\n    inptr1 = input_buf[1][input_row];\n    inptr2 = input_buf[2][input_row];\n    inptr3 = input_buf[3][input_row];\n    input_row++;\n    outptr = *output_buf++;\n    for (col = 0; col < num_cols; col++) {\n      y  = GETJSAMPLE(inptr0[col]);\n      cb = GETJSAMPLE(inptr1[col]);\n      cr = GETJSAMPLE(inptr2[col]);\n      /* Range-limiting is essential due to noise introduced by DCT losses. */\n      outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])];\t/* red */\n      outptr[1] = range_limit[MAXJSAMPLE - (y +\t\t\t/* green */\n\t\t\t      ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],\n\t\t\t\t\t\t SCALEBITS)))];\n      outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])];\t/* blue */\n      /* K passes through unchanged */\n      outptr[3] = inptr3[col];\t/* don't need GETJSAMPLE here */\n      outptr += 4;\n    }\n  }\n}\n\n\n/*\n * Empty method for start_pass.\n */\n\nMETHODDEF void\nstart_pass_dcolor (j_decompress_ptr cinfo)\n{\n  /* no work needed */\n}\n\n\n/*\n * Module initialization routine for output colorspace conversion.\n */\n\nGLOBAL void\njinit_color_deconverter (j_decompress_ptr cinfo)\n{\n  my_cconvert_ptr cconvert;\n  int ci;\n\n  cconvert = (my_cconvert_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_color_deconverter));\n  cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert;\n  cconvert->pub.start_pass = start_pass_dcolor;\n\n  /* Make sure num_components agrees with jpeg_color_space */\n  switch (cinfo->jpeg_color_space) {\n  case JCS_GRAYSCALE:\n    if (cinfo->num_components != 1)\n      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);\n    break;\n\n  case JCS_RGB:\n  case JCS_YCbCr:\n    if (cinfo->num_components != 3)\n      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);\n    break;\n\n  case JCS_CMYK:\n  case JCS_YCCK:\n    if (cinfo->num_components != 4)\n      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);\n    break;\n\n  default:\t\t\t/* JCS_UNKNOWN can be anything */\n    if (cinfo->num_components < 1)\n      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);\n    break;\n  }\n\n  /* Set out_color_components and conversion method based on requested space.\n   * Also clear the component_needed flags for any unused components,\n   * so that earlier pipeline stages can avoid useless computation.\n   */\n\n  switch (cinfo->out_color_space) {\n  case JCS_GRAYSCALE:\n    cinfo->out_color_components = 1;\n    if (cinfo->jpeg_color_space == JCS_GRAYSCALE ||\n\tcinfo->jpeg_color_space == JCS_YCbCr) {\n      cconvert->pub.color_convert = grayscale_convert;\n      /* For color->grayscale conversion, only the Y (0) component is needed */\n      for (ci = 1; ci < cinfo->num_components; ci++)\n\tcinfo->comp_info[ci].component_needed = FALSE;\n    } else\n      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);\n    break;\n\n  case JCS_RGB:\n    cinfo->out_color_components = RGB_PIXELSIZE;\n    if (cinfo->jpeg_color_space == JCS_YCbCr) {\n      cconvert->pub.color_convert = ycc_rgb_convert;\n      build_ycc_rgb_table(cinfo);\n    } else if (cinfo->jpeg_color_space == JCS_RGB && RGB_PIXELSIZE == 3) {\n      cconvert->pub.color_convert = null_convert;\n    } else\n      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);\n    break;\n\n  case JCS_CMYK:\n    cinfo->out_color_components = 4;\n    if (cinfo->jpeg_color_space == JCS_YCCK) {\n      cconvert->pub.color_convert = ycck_cmyk_convert;\n      build_ycc_rgb_table(cinfo);\n    } else if (cinfo->jpeg_color_space == JCS_CMYK) {\n      cconvert->pub.color_convert = null_convert;\n    } else\n      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);\n    break;\n\n  default:\n    /* Permit null conversion to same output space */\n    if (cinfo->out_color_space == cinfo->jpeg_color_space) {\n      cinfo->out_color_components = cinfo->num_components;\n      cconvert->pub.color_convert = null_convert;\n    } else\t\t\t/* unsupported non-null conversion */\n      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);\n    break;\n  }\n\n  if (cinfo->quantize_colors)\n    cinfo->output_components = 1; /* single colormapped output component */\n  else\n    cinfo->output_components = cinfo->out_color_components;\n}\n"
  },
  {
    "path": "libs/jpeg6/jdct.h",
    "content": "/*\n * jdct.h\n *\n * Copyright (C) 1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This include file contains common declarations for the forward and\n * inverse DCT modules.  These declarations are private to the DCT managers\n * (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms.\n * The individual DCT algorithms are kept in separate files to ease \n * machine-dependent tuning (e.g., assembly coding).\n */\n\n\n/*\n * A forward DCT routine is given a pointer to a work area of type DCTELEM[];\n * the DCT is to be performed in-place in that buffer.  Type DCTELEM is int\n * for 8-bit samples, INT32 for 12-bit samples.  (NOTE: Floating-point DCT\n * implementations use an array of type FAST_FLOAT, instead.)\n * The DCT inputs are expected to be signed (range +-CENTERJSAMPLE).\n * The DCT outputs are returned scaled up by a factor of 8; they therefore\n * have a range of +-8K for 8-bit data, +-128K for 12-bit data.  This\n * convention improves accuracy in integer implementations and saves some\n * work in floating-point ones.\n * Quantization of the output coefficients is done by jcdctmgr.c.\n */\n\n#if BITS_IN_JSAMPLE == 8\ntypedef int DCTELEM;\t\t/* 16 or 32 bits is fine */\n#else\ntypedef INT32 DCTELEM;\t\t/* must have 32 bits */\n#endif\n\ntypedef JMETHOD(void, forward_DCT_method_ptr, (DCTELEM * data));\ntypedef JMETHOD(void, float_DCT_method_ptr, (FAST_FLOAT * data));\n\n\n/*\n * An inverse DCT routine is given a pointer to the input JBLOCK and a pointer\n * to an output sample array.  The routine must dequantize the input data as\n * well as perform the IDCT; for dequantization, it uses the multiplier table\n * pointed to by compptr->dct_table.  The output data is to be placed into the\n * sample array starting at a specified column.  (Any row offset needed will\n * be applied to the array pointer before it is passed to the IDCT code.)\n * Note that the number of samples emitted by the IDCT routine is\n * DCT_scaled_size * DCT_scaled_size.\n */\n\n/* typedef inverse_DCT_method_ptr is declared in jpegint.h */\n\n/*\n * Each IDCT routine has its own ideas about the best dct_table element type.\n */\n\ntypedef MULTIPLIER ISLOW_MULT_TYPE; /* short or int, whichever is faster */\n#if BITS_IN_JSAMPLE == 8\ntypedef MULTIPLIER IFAST_MULT_TYPE; /* 16 bits is OK, use short if faster */\n#define IFAST_SCALE_BITS  2\t/* fractional bits in scale factors */\n#else\ntypedef INT32 IFAST_MULT_TYPE;\t/* need 32 bits for scaled quantizers */\n#define IFAST_SCALE_BITS  13\t/* fractional bits in scale factors */\n#endif\ntypedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */\n\n\n/*\n * Each IDCT routine is responsible for range-limiting its results and\n * converting them to unsigned form (0..MAXJSAMPLE).  The raw outputs could\n * be quite far out of range if the input data is corrupt, so a bulletproof\n * range-limiting step is required.  We use a mask-and-table-lookup method\n * to do the combined operations quickly.  See the comments with\n * prepare_range_limit_table (in jdmaster.c) for more info.\n */\n\n#define IDCT_range_limit(cinfo)  ((cinfo)->sample_range_limit + CENTERJSAMPLE)\n\n#define RANGE_MASK  (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */\n\n\n/* Short forms of external names for systems with brain-damaged linkers. */\n\n#ifdef NEED_SHORT_EXTERNAL_NAMES\n#define jpeg_fdct_islow\t\tjFDislow\n#define jpeg_fdct_ifast\t\tjFDifast\n#define jpeg_fdct_float\t\tjFDfloat\n#define jpeg_idct_islow\t\tjRDislow\n#define jpeg_idct_ifast\t\tjRDifast\n#define jpeg_idct_float\t\tjRDfloat\n#define jpeg_idct_4x4\t\tjRD4x4\n#define jpeg_idct_2x2\t\tjRD2x2\n#define jpeg_idct_1x1\t\tjRD1x1\n#endif /* NEED_SHORT_EXTERNAL_NAMES */\n\n/* Extern declarations for the forward and inverse DCT routines. */\n\nEXTERN void jpeg_fdct_islow JPP((DCTELEM * data));\nEXTERN void jpeg_fdct_ifast JPP((DCTELEM * data));\nEXTERN void jpeg_fdct_float JPP((FAST_FLOAT * data));\n\nEXTERN void jpeg_idct_islow\n    JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));\nEXTERN void jpeg_idct_ifast\n    JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));\nEXTERN void jpeg_idct_float\n    JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));\nEXTERN void jpeg_idct_4x4\n    JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));\nEXTERN void jpeg_idct_2x2\n    JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));\nEXTERN void jpeg_idct_1x1\n    JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));\n\n\n/*\n * Macros for handling fixed-point arithmetic; these are used by many\n * but not all of the DCT/IDCT modules.\n *\n * All values are expected to be of type INT32.\n * Fractional constants are scaled left by CONST_BITS bits.\n * CONST_BITS is defined within each module using these macros,\n * and may differ from one module to the next.\n */\n\n#define ONE\t((INT32) 1)\n#define CONST_SCALE (ONE << CONST_BITS)\n\n/* Convert a positive real constant to an integer scaled by CONST_SCALE.\n * Caution: some C compilers fail to reduce \"FIX(constant)\" at compile time,\n * thus causing a lot of useless floating-point operations at run time.\n */\n\n#define FIX(x)\t((INT32) ((x) * CONST_SCALE + 0.5))\n\n/* Descale and correctly round an INT32 value that's scaled by N bits.\n * We assume RIGHT_SHIFT rounds towards minus infinity, so adding\n * the fudge factor is correct for either sign of X.\n */\n\n#define DESCALE(x,n)  RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)\n\n/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.\n * This macro is used only when the two inputs will actually be no more than\n * 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a\n * full 32x32 multiply.  This provides a useful speedup on many machines.\n * Unfortunately there is no way to specify a 16x16->32 multiply portably\n * in C, but some C compilers will do the right thing if you provide the\n * correct combination of casts.\n */\n\n#ifdef SHORTxSHORT_32\t\t/* may work if 'int' is 32 bits */\n#define MULTIPLY16C16(var,const)  (((INT16) (var)) * ((INT16) (const)))\n#endif\n#ifdef SHORTxLCONST_32\t\t/* known to work with Microsoft C 6.0 */\n#define MULTIPLY16C16(var,const)  (((INT16) (var)) * ((INT32) (const)))\n#endif\n\n#ifndef MULTIPLY16C16\t\t/* default definition */\n#define MULTIPLY16C16(var,const)  ((var) * (const))\n#endif\n\n/* Same except both inputs are variables. */\n\n#ifdef SHORTxSHORT_32\t\t/* may work if 'int' is 32 bits */\n#define MULTIPLY16V16(var1,var2)  (((INT16) (var1)) * ((INT16) (var2)))\n#endif\n\n#ifndef MULTIPLY16V16\t\t/* default definition */\n#define MULTIPLY16V16(var1,var2)  ((var1) * (var2))\n#endif\n"
  },
  {
    "path": "libs/jpeg6/jddctmgr.cpp",
    "content": "/*\n * jddctmgr.c\n *\n * Copyright (C) 1994-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains the inverse-DCT management logic.\n * This code selects a particular IDCT implementation to be used,\n * and it performs related housekeeping chores.  No code in this file\n * is executed per IDCT step, only during output pass setup.\n *\n * Note that the IDCT routines are responsible for performing coefficient\n * dequantization as well as the IDCT proper.  This module sets up the\n * dequantization multiplier table needed by the IDCT routine.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jdct.h\"\t\t/* Private declarations for DCT subsystem */\n\n\n/*\n * The decompressor input side (jdinput.c) saves away the appropriate\n * quantization table for each component at the start of the first scan\n * involving that component.  (This is necessary in order to correctly\n * decode files that reuse Q-table slots.)\n * When we are ready to make an output pass, the saved Q-table is converted\n * to a multiplier table that will actually be used by the IDCT routine.\n * The multiplier table contents are IDCT-method-dependent.  To support\n * application changes in IDCT method between scans, we can remake the\n * multiplier tables if necessary.\n * In buffered-image mode, the first output pass may occur before any data\n * has been seen for some components, and thus before their Q-tables have\n * been saved away.  To handle this case, multiplier tables are preset\n * to zeroes; the result of the IDCT will be a neutral gray level.\n */\n\n\n/* Private subobject for this module */\n\ntypedef struct {\n  struct jpeg_inverse_dct pub;\t/* public fields */\n\n  /* This array contains the IDCT method code that each multiplier table\n   * is currently set up for, or -1 if it's not yet set up.\n   * The actual multiplier tables are pointed to by dct_table in the\n   * per-component comp_info structures.\n   */\n  int cur_method[MAX_COMPONENTS];\n} my_idct_controller;\n\ntypedef my_idct_controller * my_idct_ptr;\n\n\n/* Allocated multiplier tables: big enough for any supported variant */\n\ntypedef union {\n  ISLOW_MULT_TYPE islow_array[DCTSIZE2];\n#ifdef DCT_IFAST_SUPPORTED\n  IFAST_MULT_TYPE ifast_array[DCTSIZE2];\n#endif\n#ifdef DCT_FLOAT_SUPPORTED\n  FLOAT_MULT_TYPE float_array[DCTSIZE2];\n#endif\n} multiplier_table;\n\n\n/* The current scaled-IDCT routines require ISLOW-style multiplier tables,\n * so be sure to compile that code if either ISLOW or SCALING is requested.\n */\n#ifdef DCT_ISLOW_SUPPORTED\n#define PROVIDE_ISLOW_TABLES\n#else\n#ifdef IDCT_SCALING_SUPPORTED\n#define PROVIDE_ISLOW_TABLES\n#endif\n#endif\n\n\n/*\n * Prepare for an output pass.\n * Here we select the proper IDCT routine for each component and build\n * a matching multiplier table.\n */\n\nMETHODDEF void\nstart_pass (j_decompress_ptr cinfo)\n{\n  my_idct_ptr idct = (my_idct_ptr) cinfo->idct;\n  int ci, i;\n  jpeg_component_info *compptr;\n  int method = 0;\n  inverse_DCT_method_ptr method_ptr = NULL;\n  JQUANT_TBL * qtbl;\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    /* Select the proper IDCT routine for this component's scaling */\n    switch (compptr->DCT_scaled_size) {\n#ifdef IDCT_SCALING_SUPPORTED\n    case 1:\n      method_ptr = jpeg_idct_1x1;\n      method = JDCT_ISLOW;\t/* jidctred uses islow-style table */\n      break;\n    case 2:\n      method_ptr = jpeg_idct_2x2;\n      method = JDCT_ISLOW;\t/* jidctred uses islow-style table */\n      break;\n    case 4:\n      method_ptr = jpeg_idct_4x4;\n      method = JDCT_ISLOW;\t/* jidctred uses islow-style table */\n      break;\n#endif\n    case DCTSIZE:\n      switch (cinfo->dct_method) {\n#ifdef DCT_ISLOW_SUPPORTED\n      case JDCT_ISLOW:\n\tmethod_ptr = jpeg_idct_islow;\n\tmethod = JDCT_ISLOW;\n\tbreak;\n#endif\n#ifdef DCT_IFAST_SUPPORTED\n      case JDCT_IFAST:\n\tmethod_ptr = jpeg_idct_ifast;\n\tmethod = JDCT_IFAST;\n\tbreak;\n#endif\n#ifdef DCT_FLOAT_SUPPORTED\n      case JDCT_FLOAT:\n\tmethod_ptr = jpeg_idct_float;\n\tmethod = JDCT_FLOAT;\n\tbreak;\n#endif\n      default:\n\tERREXIT(cinfo, JERR_NOT_COMPILED);\n\tbreak;\n      }\n      break;\n    default:\n      ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->DCT_scaled_size);\n      break;\n    }\n    idct->pub.inverse_DCT[ci] = method_ptr;\n    /* Create multiplier table from quant table.\n     * However, we can skip this if the component is uninteresting\n     * or if we already built the table.  Also, if no quant table\n     * has yet been saved for the component, we leave the\n     * multiplier table all-zero; we'll be reading zeroes from the\n     * coefficient controller's buffer anyway.\n     */\n    if (! compptr->component_needed || idct->cur_method[ci] == method)\n      continue;\n    qtbl = compptr->quant_table;\n    if (qtbl == NULL)\t\t/* happens if no data yet for component */\n      continue;\n    idct->cur_method[ci] = method;\n    switch (method) {\n#ifdef PROVIDE_ISLOW_TABLES\n    case JDCT_ISLOW:\n      {\n\t/* For LL&M IDCT method, multipliers are equal to raw quantization\n\t * coefficients, but are stored in natural order as ints.\n\t */\n\tISLOW_MULT_TYPE * ismtbl = (ISLOW_MULT_TYPE *) compptr->dct_table;\n\tfor (i = 0; i < DCTSIZE2; i++) {\n\t  ismtbl[i] = (ISLOW_MULT_TYPE) qtbl->quantval[jpeg_zigzag_order[i]];\n\t}\n      }\n      break;\n#endif\n#ifdef DCT_IFAST_SUPPORTED\n    case JDCT_IFAST:\n      {\n\t/* For AA&N IDCT method, multipliers are equal to quantization\n\t * coefficients scaled by scalefactor[row]*scalefactor[col], where\n\t *   scalefactor[0] = 1\n\t *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7\n\t * For integer operation, the multiplier table is to be scaled by\n\t * IFAST_SCALE_BITS.  The multipliers are stored in natural order.\n\t */\n\tIFAST_MULT_TYPE * ifmtbl = (IFAST_MULT_TYPE *) compptr->dct_table;\n#define CONST_BITS 14\n\tstatic const INT16 aanscales[DCTSIZE2] = {\n\t  /* precomputed values scaled up by 14 bits */\n\t  16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,\n\t  22725, 31521, 29692, 26722, 22725, 17855, 12299,  6270,\n\t  21407, 29692, 27969, 25172, 21407, 16819, 11585,  5906,\n\t  19266, 26722, 25172, 22654, 19266, 15137, 10426,  5315,\n\t  16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,\n\t  12873, 17855, 16819, 15137, 12873, 10114,  6967,  3552,\n\t   8867, 12299, 11585, 10426,  8867,  6967,  4799,  2446,\n\t   4520,  6270,  5906,  5315,  4520,  3552,  2446,  1247\n\t};\n\tSHIFT_TEMPS\n\n\tfor (i = 0; i < DCTSIZE2; i++) {\n\t  ifmtbl[i] = (IFAST_MULT_TYPE)\n\t    DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[jpeg_zigzag_order[i]],\n\t\t\t\t  (INT32) aanscales[i]),\n\t\t    CONST_BITS-IFAST_SCALE_BITS);\n\t}\n      }\n      break;\n#endif\n#ifdef DCT_FLOAT_SUPPORTED\n    case JDCT_FLOAT:\n      {\n\t/* For float AA&N IDCT method, multipliers are equal to quantization\n\t * coefficients scaled by scalefactor[row]*scalefactor[col], where\n\t *   scalefactor[0] = 1\n\t *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7\n\t * The multipliers are stored in natural order.\n\t */\n\tFLOAT_MULT_TYPE * fmtbl = (FLOAT_MULT_TYPE *) compptr->dct_table;\n\tint row, col;\n\tstatic const double aanscalefactor[DCTSIZE] = {\n\t  1.0, 1.387039845, 1.306562965, 1.175875602,\n\t  1.0, 0.785694958, 0.541196100, 0.275899379\n\t};\n\n\ti = 0;\n\tfor (row = 0; row < DCTSIZE; row++) {\n\t  for (col = 0; col < DCTSIZE; col++) {\n\t    fmtbl[i] = (FLOAT_MULT_TYPE)\n\t      ((double) qtbl->quantval[jpeg_zigzag_order[i]] *\n\t       aanscalefactor[row] * aanscalefactor[col]);\n\t    i++;\n\t  }\n\t}\n      }\n      break;\n#endif\n    default:\n      ERREXIT(cinfo, JERR_NOT_COMPILED);\n      break;\n    }\n  }\n}\n\n\n/*\n * Initialize IDCT manager.\n */\n\nGLOBAL void\njinit_inverse_dct (j_decompress_ptr cinfo)\n{\n  my_idct_ptr idct;\n  int ci;\n  jpeg_component_info *compptr;\n\n  idct = (my_idct_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_idct_controller));\n  cinfo->idct = (struct jpeg_inverse_dct *) idct;\n  idct->pub.start_pass = start_pass;\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    /* Allocate and pre-zero a multiplier table for each component */\n    compptr->dct_table =\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t  SIZEOF(multiplier_table));\n    MEMZERO(compptr->dct_table, SIZEOF(multiplier_table));\n    /* Mark multiplier table not yet set up for any method */\n    idct->cur_method[ci] = -1;\n  }\n}\n"
  },
  {
    "path": "libs/jpeg6/jdhuff.cpp",
    "content": "/*\n * jdhuff.c\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains Huffman entropy decoding routines.\n *\n * Much of the complexity here has to do with supporting input suspension.\n * If the data source module demands suspension, we want to be able to back\n * up to the start of the current MCU.  To do this, we copy state variables\n * into local working storage, and update them back to the permanent\n * storage only upon successful completion of an MCU.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jdhuff.h\"\t\t/* Declarations shared with jdphuff.c */\n\n\n/*\n * Expanded entropy decoder object for Huffman decoding.\n *\n * The savable_state subrecord contains fields that change within an MCU,\n * but must not be updated permanently until we complete the MCU.\n */\n\ntypedef struct {\n  int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */\n} savable_state;\n\n/* This macro is to work around compilers with missing or broken\n * structure assignment.  You'll need to fix this code if you have\n * such a compiler and you change MAX_COMPS_IN_SCAN.\n */\n\n#ifndef NO_STRUCT_ASSIGN\n#define ASSIGN_STATE(dest,src)  ((dest) = (src))\n#else\n#if MAX_COMPS_IN_SCAN == 4\n#define ASSIGN_STATE(dest,src)  \\\n\t((dest).last_dc_val[0] = (src).last_dc_val[0], \\\n\t (dest).last_dc_val[1] = (src).last_dc_val[1], \\\n\t (dest).last_dc_val[2] = (src).last_dc_val[2], \\\n\t (dest).last_dc_val[3] = (src).last_dc_val[3])\n#endif\n#endif\n\n\ntypedef struct {\n  struct jpeg_entropy_decoder pub; /* public fields */\n\n  /* These fields are loaded into local variables at start of each MCU.\n   * In case of suspension, we exit WITHOUT updating them.\n   */\n  bitread_perm_state bitstate;\t/* Bit buffer at start of MCU */\n  savable_state saved;\t\t/* Other state at start of MCU */\n\n  /* These fields are NOT loaded into local working state. */\n  unsigned int restarts_to_go;\t/* MCUs left in this restart interval */\n\n  /* Pointers to derived tables (these workspaces have image lifespan) */\n  d_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS];\n  d_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS];\n} huff_entropy_decoder;\n\ntypedef huff_entropy_decoder * huff_entropy_ptr;\n\n\n/*\n * Initialize for a Huffman-compressed scan.\n */\n\nMETHODDEF void\nstart_pass_huff_decoder (j_decompress_ptr cinfo)\n{\n  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;\n  int ci, dctbl, actbl;\n  jpeg_component_info * compptr;\n\n  /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG.\n   * This ought to be an error condition, but we make it a warning because\n   * there are some baseline files out there with all zeroes in these bytes.\n   */\n  if (cinfo->Ss != 0 || cinfo->Se != DCTSIZE2-1 ||\n      cinfo->Ah != 0 || cinfo->Al != 0)\n    WARNMS(cinfo, JWRN_NOT_SEQUENTIAL);\n\n  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n    compptr = cinfo->cur_comp_info[ci];\n    dctbl = compptr->dc_tbl_no;\n    actbl = compptr->ac_tbl_no;\n    /* Make sure requested tables are present */\n    if (dctbl < 0 || dctbl >= NUM_HUFF_TBLS ||\n\tcinfo->dc_huff_tbl_ptrs[dctbl] == NULL)\n      ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, dctbl);\n    if (actbl < 0 || actbl >= NUM_HUFF_TBLS ||\n\tcinfo->ac_huff_tbl_ptrs[actbl] == NULL)\n      ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, actbl);\n    /* Compute derived values for Huffman tables */\n    /* We may do this more than once for a table, but it's not expensive */\n    jpeg_make_d_derived_tbl(cinfo, cinfo->dc_huff_tbl_ptrs[dctbl],\n\t\t\t    & entropy->dc_derived_tbls[dctbl]);\n    jpeg_make_d_derived_tbl(cinfo, cinfo->ac_huff_tbl_ptrs[actbl],\n\t\t\t    & entropy->ac_derived_tbls[actbl]);\n    /* Initialize DC predictions to 0 */\n    entropy->saved.last_dc_val[ci] = 0;\n  }\n\n  /* Initialize bitread state variables */\n  entropy->bitstate.bits_left = 0;\n  entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */\n  entropy->bitstate.printed_eod = FALSE;\n\n  /* Initialize restart counter */\n  entropy->restarts_to_go = cinfo->restart_interval;\n}\n\n\n/*\n * Compute the derived values for a Huffman table.\n * Note this is also used by jdphuff.c.\n */\n\nGLOBAL void\njpeg_make_d_derived_tbl (j_decompress_ptr cinfo, JHUFF_TBL * htbl,\n\t\t\t d_derived_tbl ** pdtbl)\n{\n  d_derived_tbl *dtbl;\n  int p, i, l, si;\n  int lookbits, ctr;\n  char huffsize[257];\n  unsigned int huffcode[257];\n  unsigned int code;\n\n  /* Allocate a workspace if we haven't already done so. */\n  if (*pdtbl == NULL)\n    *pdtbl = (d_derived_tbl *)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t  SIZEOF(d_derived_tbl));\n  dtbl = *pdtbl;\n  dtbl->pub = htbl;\t\t/* fill in back link */\n  \n  /* Figure C.1: make table of Huffman code length for each symbol */\n  /* Note that this is in code-length order. */\n\n  p = 0;\n  for (l = 1; l <= 16; l++) {\n    for (i = 1; i <= (int) htbl->bits[l]; i++)\n      huffsize[p++] = (char) l;\n  }\n  huffsize[p] = 0;\n  \n  /* Figure C.2: generate the codes themselves */\n  /* Note that this is in code-length order. */\n  \n  code = 0;\n  si = huffsize[0];\n  p = 0;\n  while (huffsize[p]) {\n    while (((int) huffsize[p]) == si) {\n      huffcode[p++] = code;\n      code++;\n    }\n    code <<= 1;\n    si++;\n  }\n\n  /* Figure F.15: generate decoding tables for bit-sequential decoding */\n\n  p = 0;\n  for (l = 1; l <= 16; l++) {\n    if (htbl->bits[l]) {\n      dtbl->valptr[l] = p; /* huffval[] index of 1st symbol of code length l */\n      dtbl->mincode[l] = huffcode[p]; /* minimum code of length l */\n      p += htbl->bits[l];\n      dtbl->maxcode[l] = huffcode[p-1]; /* maximum code of length l */\n    } else {\n      dtbl->maxcode[l] = -1;\t/* -1 if no codes of this length */\n    }\n  }\n  dtbl->maxcode[17] = 0xFFFFFL; /* ensures jpeg_huff_decode terminates */\n\n  /* Compute lookahead tables to speed up decoding.\n   * First we set all the table entries to 0, indicating \"too long\";\n   * then we iterate through the Huffman codes that are short enough and\n   * fill in all the entries that correspond to bit sequences starting\n   * with that code.\n   */\n\n  MEMZERO(dtbl->look_nbits, SIZEOF(dtbl->look_nbits));\n\n  p = 0;\n  for (l = 1; l <= HUFF_LOOKAHEAD; l++) {\n    for (i = 1; i <= (int) htbl->bits[l]; i++, p++) {\n      /* l = current code's length, p = its index in huffcode[] & huffval[]. */\n      /* Generate left-justified code followed by all possible bit sequences */\n      lookbits = huffcode[p] << (HUFF_LOOKAHEAD-l);\n      for (ctr = 1 << (HUFF_LOOKAHEAD-l); ctr > 0; ctr--) {\n\tdtbl->look_nbits[lookbits] = l;\n\tdtbl->look_sym[lookbits] = htbl->huffval[p];\n\tlookbits++;\n      }\n    }\n  }\n}\n\n\n/*\n * Out-of-line code for bit fetching (shared with jdphuff.c).\n * See jdhuff.h for info about usage.\n * Note: current values of get_buffer and bits_left are passed as parameters,\n * but are returned in the corresponding fields of the state struct.\n *\n * On most machines MIN_GET_BITS should be 25 to allow the full 32-bit width\n * of get_buffer to be used.  (On machines with wider words, an even larger\n * buffer could be used.)  However, on some machines 32-bit shifts are\n * quite slow and take time proportional to the number of places shifted.\n * (This is true with most PC compilers, for instance.)  In this case it may\n * be a win to set MIN_GET_BITS to the minimum value of 15.  This reduces the\n * average shift distance at the cost of more calls to jpeg_fill_bit_buffer.\n */\n\n#ifdef SLOW_SHIFT_32\n#define MIN_GET_BITS  15\t/* minimum allowable value */\n#else\n#define MIN_GET_BITS  (BIT_BUF_SIZE-7)\n#endif\n\n\nGLOBAL boolean\njpeg_fill_bit_buffer (bitread_working_state * state,\n\t\t      register bit_buf_type get_buffer, register int bits_left,\n\t\t      int nbits)\n/* Load up the bit buffer to a depth of at least nbits */\n{\n  /* Copy heavily used state fields into locals (hopefully registers) */\n  register const JOCTET * next_input_byte = state->next_input_byte;\n  register size_t bytes_in_buffer = state->bytes_in_buffer;\n  register int c;\n\n  /* Attempt to load at least MIN_GET_BITS bits into get_buffer. */\n  /* (It is assumed that no request will be for more than that many bits.) */\n\n  while (bits_left < MIN_GET_BITS) {\n    /* Attempt to read a byte */\n    if (state->unread_marker != 0)\n      goto no_more_data;\t/* can't advance past a marker */\n\n    if (bytes_in_buffer == 0) {\n      if (! (*state->cinfo->src->fill_input_buffer) (state->cinfo))\n\treturn FALSE;\n      next_input_byte = state->cinfo->src->next_input_byte;\n      bytes_in_buffer = state->cinfo->src->bytes_in_buffer;\n    }\n    bytes_in_buffer--;\n    c = GETJOCTET(*next_input_byte++);\n\n    /* If it's 0xFF, check and discard stuffed zero byte */\n    if (c == 0xFF) {\n      do {\n\tif (bytes_in_buffer == 0) {\n\t  if (! (*state->cinfo->src->fill_input_buffer) (state->cinfo))\n\t    return FALSE;\n\t  next_input_byte = state->cinfo->src->next_input_byte;\n\t  bytes_in_buffer = state->cinfo->src->bytes_in_buffer;\n\t}\n\tbytes_in_buffer--;\n\tc = GETJOCTET(*next_input_byte++);\n      } while (c == 0xFF);\n\n      if (c == 0) {\n\t/* Found FF/00, which represents an FF data byte */\n\tc = 0xFF;\n      } else {\n\t/* Oops, it's actually a marker indicating end of compressed data. */\n\t/* Better put it back for use later */\n\tstate->unread_marker = c;\n\n      no_more_data:\n\t/* There should be enough bits still left in the data segment; */\n\t/* if so, just break out of the outer while loop. */\n\tif (bits_left >= nbits)\n\t  break;\n\t/* Uh-oh.  Report corrupted data to user and stuff zeroes into\n\t * the data stream, so that we can produce some kind of image.\n\t * Note that this code will be repeated for each byte demanded\n\t * for the rest of the segment.  We use a nonvolatile flag to ensure\n\t * that only one warning message appears.\n\t */\n\tif (! *(state->printed_eod_ptr)) {\n\t  WARNMS(state->cinfo, JWRN_HIT_MARKER);\n\t  *(state->printed_eod_ptr) = TRUE;\n\t}\n\tc = 0;\t\t\t/* insert a zero byte into bit buffer */\n      }\n    }\n\n    /* OK, load c into get_buffer */\n    get_buffer = (get_buffer << 8) | c;\n    bits_left += 8;\n  }\n\n  /* Unload the local registers */\n  state->next_input_byte = next_input_byte;\n  state->bytes_in_buffer = bytes_in_buffer;\n  state->get_buffer = get_buffer;\n  state->bits_left = bits_left;\n\n  return TRUE;\n}\n\n\n/*\n * Out-of-line code for Huffman code decoding.\n * See jdhuff.h for info about usage.\n */\n\nGLOBAL int\njpeg_huff_decode (bitread_working_state * state,\n\t\t  register bit_buf_type get_buffer, register int bits_left,\n\t\t  d_derived_tbl * htbl, int min_bits)\n{\n  register int l = min_bits;\n  register INT32 code;\n\n  /* HUFF_DECODE has determined that the code is at least min_bits */\n  /* bits long, so fetch that many bits in one swoop. */\n\n  CHECK_BIT_BUFFER(*state, l, return -1);\n  code = GET_BITS(l);\n\n  /* Collect the rest of the Huffman code one bit at a time. */\n  /* This is per Figure F.16 in the JPEG spec. */\n\n  while (code > htbl->maxcode[l]) {\n    code <<= 1;\n    CHECK_BIT_BUFFER(*state, 1, return -1);\n    code |= GET_BITS(1);\n    l++;\n  }\n\n  /* Unload the local registers */\n  state->get_buffer = get_buffer;\n  state->bits_left = bits_left;\n\n  /* With garbage input we may reach the sentinel value l = 17. */\n\n  if (l > 16) {\n    WARNMS(state->cinfo, JWRN_HUFF_BAD_CODE);\n    return 0;\t\t\t/* fake a zero as the safest result */\n  }\n\n  return htbl->pub->huffval[ htbl->valptr[l] +\n\t\t\t    ((int) (code - htbl->mincode[l])) ];\n}\n\n\n/*\n * Figure F.12: extend sign bit.\n * On some machines, a shift and add will be faster than a table lookup.\n */\n\n#ifdef AVOID_TABLES\n\n#define HUFF_EXTEND(x,s)  ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x))\n\n#else\n\n#define HUFF_EXTEND(x,s)  ((x) < extend_test[s] ? (x) + extend_offset[s] : (x))\n\nstatic const int extend_test[16] =   /* entry n is 2**(n-1) */\n  { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,\n    0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 };\n\nstatic const int extend_offset[16] = /* entry n is (-1 << n) + 1 */\n  { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1,\n    ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1,\n    ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1,\n    ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 };\n\n#endif /* AVOID_TABLES */\n\n\n/*\n * Check for a restart marker & resynchronize decoder.\n * Returns FALSE if must suspend.\n */\n\nLOCAL boolean\nprocess_restart (j_decompress_ptr cinfo)\n{\n  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;\n  int ci;\n\n  /* Throw away any unused bits remaining in bit buffer; */\n  /* include any full bytes in next_marker's count of discarded bytes */\n  cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8;\n  entropy->bitstate.bits_left = 0;\n\n  /* Advance past the RSTn marker */\n  if (! (*cinfo->marker->read_restart_marker) (cinfo))\n    return FALSE;\n\n  /* Re-initialize DC predictions to 0 */\n  for (ci = 0; ci < cinfo->comps_in_scan; ci++)\n    entropy->saved.last_dc_val[ci] = 0;\n\n  /* Reset restart counter */\n  entropy->restarts_to_go = cinfo->restart_interval;\n\n  /* Next segment can get another out-of-data warning */\n  entropy->bitstate.printed_eod = FALSE;\n\n  return TRUE;\n}\n\n\n/*\n * Decode and return one MCU's worth of Huffman-compressed coefficients.\n * The coefficients are reordered from zigzag order into natural array order,\n * but are not dequantized.\n *\n * The i'th block of the MCU is stored into the block pointed to by\n * MCU_data[i].  WE ASSUME THIS AREA HAS BEEN ZEROED BY THE CALLER.\n * (Wholesale zeroing is usually a little faster than retail...)\n *\n * Returns FALSE if data source requested suspension.  In that case no\n * changes have been made to permanent state.  (Exception: some output\n * coefficients may already have been assigned.  This is harmless for\n * this module, since we'll just re-assign them on the next call.)\n */\n\nMETHODDEF boolean\ndecode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)\n{\n  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;\n  register int s, k, r;\n  int blkn, ci;\n  JBLOCKROW block;\n  BITREAD_STATE_VARS;\n  savable_state state;\n  d_derived_tbl * dctbl;\n  d_derived_tbl * actbl;\n  jpeg_component_info * compptr;\n\n  /* Process restart marker if needed; may have to suspend */\n  if (cinfo->restart_interval) {\n    if (entropy->restarts_to_go == 0)\n      if (! process_restart(cinfo))\n\treturn FALSE;\n  }\n\n  /* Load up working state */\n  BITREAD_LOAD_STATE(cinfo,entropy->bitstate);\n  ASSIGN_STATE(state, entropy->saved);\n\n  /* Outer loop handles each block in the MCU */\n\n  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {\n    block = MCU_data[blkn];\n    ci = cinfo->MCU_membership[blkn];\n    compptr = cinfo->cur_comp_info[ci];\n    dctbl = entropy->dc_derived_tbls[compptr->dc_tbl_no];\n    actbl = entropy->ac_derived_tbls[compptr->ac_tbl_no];\n\n    /* Decode a single block's worth of coefficients */\n\n    /* Section F.2.2.1: decode the DC coefficient difference */\n    HUFF_DECODE(s, br_state, dctbl, return FALSE, label1);\n    if (s) {\n      CHECK_BIT_BUFFER(br_state, s, return FALSE);\n      r = GET_BITS(s);\n      s = HUFF_EXTEND(r, s);\n    }\n\n    /* Shortcut if component's values are not interesting */\n    if (! compptr->component_needed)\n      goto skip_ACs;\n\n    /* Convert DC difference to actual value, update last_dc_val */\n    s += state.last_dc_val[ci];\n    state.last_dc_val[ci] = s;\n    /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */\n    (*block)[0] = (JCOEF) s;\n\n    /* Do we need to decode the AC coefficients for this component? */\n    if (compptr->DCT_scaled_size > 1) {\n\n      /* Section F.2.2.2: decode the AC coefficients */\n      /* Since zeroes are skipped, output area must be cleared beforehand */\n      for (k = 1; k < DCTSIZE2; k++) {\n\tHUFF_DECODE(s, br_state, actbl, return FALSE, label2);\n      \n\tr = s >> 4;\n\ts &= 15;\n      \n\tif (s) {\n\t  k += r;\n\t  CHECK_BIT_BUFFER(br_state, s, return FALSE);\n\t  r = GET_BITS(s);\n\t  s = HUFF_EXTEND(r, s);\n\t  /* Output coefficient in natural (dezigzagged) order.\n\t   * Note: the extra entries in jpeg_natural_order[] will save us\n\t   * if k >= DCTSIZE2, which could happen if the data is corrupted.\n\t   */\n\t  (*block)[jpeg_natural_order[k]] = (JCOEF) s;\n\t} else {\n\t  if (r != 15)\n\t    break;\n\t  k += 15;\n\t}\n      }\n\n    } else {\nskip_ACs:\n\n      /* Section F.2.2.2: decode the AC coefficients */\n      /* In this path we just discard the values */\n      for (k = 1; k < DCTSIZE2; k++) {\n\tHUFF_DECODE(s, br_state, actbl, return FALSE, label3);\n      \n\tr = s >> 4;\n\ts &= 15;\n      \n\tif (s) {\n\t  k += r;\n\t  CHECK_BIT_BUFFER(br_state, s, return FALSE);\n\t  DROP_BITS(s);\n\t} else {\n\t  if (r != 15)\n\t    break;\n\t  k += 15;\n\t}\n      }\n\n    }\n  }\n\n  /* Completed MCU, so update state */\n  BITREAD_SAVE_STATE(cinfo,entropy->bitstate);\n  ASSIGN_STATE(entropy->saved, state);\n\n  /* Account for restart interval (no-op if not using restarts) */\n  entropy->restarts_to_go--;\n\n  return TRUE;\n}\n\n\n/*\n * Module initialization routine for Huffman entropy decoding.\n */\n\nGLOBAL void\njinit_huff_decoder (j_decompress_ptr cinfo)\n{\n  huff_entropy_ptr entropy;\n  int i;\n\n  entropy = (huff_entropy_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(huff_entropy_decoder));\n  cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;\n  entropy->pub.start_pass = start_pass_huff_decoder;\n  entropy->pub.decode_mcu = decode_mcu;\n\n  /* Mark tables unallocated */\n  for (i = 0; i < NUM_HUFF_TBLS; i++) {\n    entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL;\n  }\n}\n"
  },
  {
    "path": "libs/jpeg6/jdhuff.h",
    "content": "/*\n * jdhuff.h\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains declarations for Huffman entropy decoding routines\n * that are shared between the sequential decoder (jdhuff.c) and the\n * progressive decoder (jdphuff.c).  No other modules need to see these.\n */\n\n/* Short forms of external names for systems with brain-damaged linkers. */\n\n#ifdef NEED_SHORT_EXTERNAL_NAMES\n#define jpeg_make_d_derived_tbl\tjMkDDerived\n#define jpeg_fill_bit_buffer\tjFilBitBuf\n#define jpeg_huff_decode\tjHufDecode\n#endif /* NEED_SHORT_EXTERNAL_NAMES */\n\n\n/* Derived data constructed for each Huffman table */\n\n#define HUFF_LOOKAHEAD\t8\t/* # of bits of lookahead */\n\ntypedef struct {\n  /* Basic tables: (element [0] of each array is unused) */\n  INT32 mincode[17];\t\t/* smallest code of length k */\n  INT32 maxcode[18];\t\t/* largest code of length k (-1 if none) */\n  /* (maxcode[17] is a sentinel to ensure jpeg_huff_decode terminates) */\n  int valptr[17];\t\t/* huffval[] index of 1st symbol of length k */\n\n  /* Link to public Huffman table (needed only in jpeg_huff_decode) */\n  JHUFF_TBL *pub;\n\n  /* Lookahead tables: indexed by the next HUFF_LOOKAHEAD bits of\n   * the input data stream.  If the next Huffman code is no more\n   * than HUFF_LOOKAHEAD bits long, we can obtain its length and\n   * the corresponding symbol directly from these tables.\n   */\n  int look_nbits[1<<HUFF_LOOKAHEAD]; /* # bits, or 0 if too long */\n  UINT8 look_sym[1<<HUFF_LOOKAHEAD]; /* symbol, or unused */\n} d_derived_tbl;\n\n/* Expand a Huffman table definition into the derived format */\nEXTERN void jpeg_make_d_derived_tbl JPP((j_decompress_ptr cinfo,\n\t\t\t\tJHUFF_TBL * htbl, d_derived_tbl ** pdtbl));\n\n\n/*\n * Fetching the next N bits from the input stream is a time-critical operation\n * for the Huffman decoders.  We implement it with a combination of inline\n * macros and out-of-line subroutines.  Note that N (the number of bits\n * demanded at one time) never exceeds 15 for JPEG use.\n *\n * We read source bytes into get_buffer and dole out bits as needed.\n * If get_buffer already contains enough bits, they are fetched in-line\n * by the macros CHECK_BIT_BUFFER and GET_BITS.  When there aren't enough\n * bits, jpeg_fill_bit_buffer is called; it will attempt to fill get_buffer\n * as full as possible (not just to the number of bits needed; this\n * prefetching reduces the overhead cost of calling jpeg_fill_bit_buffer).\n * Note that jpeg_fill_bit_buffer may return FALSE to indicate suspension.\n * On TRUE return, jpeg_fill_bit_buffer guarantees that get_buffer contains\n * at least the requested number of bits --- dummy zeroes are inserted if\n * necessary.\n */\n\ntypedef INT32 bit_buf_type;\t/* type of bit-extraction buffer */\n#define BIT_BUF_SIZE  32\t/* size of buffer in bits */\n\n/* If long is > 32 bits on your machine, and shifting/masking longs is\n * reasonably fast, making bit_buf_type be long and setting BIT_BUF_SIZE\n * appropriately should be a win.  Unfortunately we can't do this with\n * something like  #define BIT_BUF_SIZE (sizeof(bit_buf_type)*8)\n * because not all machines measure sizeof in 8-bit bytes.\n */\n\ntypedef struct {\t\t/* Bitreading state saved across MCUs */\n  bit_buf_type get_buffer;\t/* current bit-extraction buffer */\n  int bits_left;\t\t/* # of unused bits in it */\n  boolean printed_eod;\t\t/* flag to suppress multiple warning msgs */\n} bitread_perm_state;\n\ntypedef struct {\t\t/* Bitreading working state within an MCU */\n  /* current data source state */\n  const JOCTET * next_input_byte; /* => next byte to read from source */\n  size_t bytes_in_buffer;\t/* # of bytes remaining in source buffer */\n  int unread_marker;\t\t/* nonzero if we have hit a marker */\n  /* bit input buffer --- note these values are kept in register variables,\n   * not in this struct, inside the inner loops.\n   */\n  bit_buf_type get_buffer;\t/* current bit-extraction buffer */\n  int bits_left;\t\t/* # of unused bits in it */\n  /* pointers needed by jpeg_fill_bit_buffer */\n  j_decompress_ptr cinfo;\t/* back link to decompress master record */\n  boolean * printed_eod_ptr;\t/* => flag in permanent state */\n} bitread_working_state;\n\n/* Macros to declare and load/save bitread local variables. */\n#define BITREAD_STATE_VARS  \\\n\tregister bit_buf_type get_buffer;  \\\n\tregister int bits_left;  \\\n\tbitread_working_state br_state\n\n#define BITREAD_LOAD_STATE(cinfop,permstate)  \\\n\tbr_state.cinfo = cinfop; \\\n\tbr_state.next_input_byte = cinfop->src->next_input_byte; \\\n\tbr_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \\\n\tbr_state.unread_marker = cinfop->unread_marker; \\\n\tget_buffer = permstate.get_buffer; \\\n\tbits_left = permstate.bits_left; \\\n\tbr_state.printed_eod_ptr = & permstate.printed_eod\n\n#define BITREAD_SAVE_STATE(cinfop,permstate)  \\\n\tcinfop->src->next_input_byte = br_state.next_input_byte; \\\n\tcinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \\\n\tcinfop->unread_marker = br_state.unread_marker; \\\n\tpermstate.get_buffer = get_buffer; \\\n\tpermstate.bits_left = bits_left\n\n/*\n * These macros provide the in-line portion of bit fetching.\n * Use CHECK_BIT_BUFFER to ensure there are N bits in get_buffer\n * before using GET_BITS, PEEK_BITS, or DROP_BITS.\n * The variables get_buffer and bits_left are assumed to be locals,\n * but the state struct might not be (jpeg_huff_decode needs this).\n *\tCHECK_BIT_BUFFER(state,n,action);\n *\t\tEnsure there are N bits in get_buffer; if suspend, take action.\n *      val = GET_BITS(n);\n *\t\tFetch next N bits.\n *      val = PEEK_BITS(n);\n *\t\tFetch next N bits without removing them from the buffer.\n *\tDROP_BITS(n);\n *\t\tDiscard next N bits.\n * The value N should be a simple variable, not an expression, because it\n * is evaluated multiple times.\n */\n\n#define CHECK_BIT_BUFFER(state,nbits,action) \\\n\t{ if (bits_left < (nbits)) {  \\\n\t    if (! jpeg_fill_bit_buffer(&(state),get_buffer,bits_left,nbits))  \\\n\t      { action; }  \\\n\t    get_buffer = (state).get_buffer; bits_left = (state).bits_left; } }\n\n#define GET_BITS(nbits) \\\n\t(((int) (get_buffer >> (bits_left -= (nbits)))) & ((1<<(nbits))-1))\n\n#define PEEK_BITS(nbits) \\\n\t(((int) (get_buffer >> (bits_left -  (nbits)))) & ((1<<(nbits))-1))\n\n#define DROP_BITS(nbits) \\\n\t(bits_left -= (nbits))\n\n/* Load up the bit buffer to a depth of at least nbits */\nEXTERN boolean jpeg_fill_bit_buffer JPP((bitread_working_state * state,\n\t\tregister bit_buf_type get_buffer, register int bits_left,\n\t\tint nbits));\n\n\n/*\n * Code for extracting next Huffman-coded symbol from input bit stream.\n * Again, this is time-critical and we make the main paths be macros.\n *\n * We use a lookahead table to process codes of up to HUFF_LOOKAHEAD bits\n * without looping.  Usually, more than 95% of the Huffman codes will be 8\n * or fewer bits long.  The few overlength codes are handled with a loop,\n * which need not be inline code.\n *\n * Notes about the HUFF_DECODE macro:\n * 1. Near the end of the data segment, we may fail to get enough bits\n *    for a lookahead.  In that case, we do it the hard way.\n * 2. If the lookahead table contains no entry, the next code must be\n *    more than HUFF_LOOKAHEAD bits long.\n * 3. jpeg_huff_decode returns -1 if forced to suspend.\n */\n\n#define HUFF_DECODE(result,state,htbl,failaction,slowlabel) \\\n{ register int nb, look; \\\n  if (bits_left < HUFF_LOOKAHEAD) { \\\n    if (! jpeg_fill_bit_buffer(&state,get_buffer,bits_left, 0)) {failaction;} \\\n    get_buffer = state.get_buffer; bits_left = state.bits_left; \\\n    if (bits_left < HUFF_LOOKAHEAD) { \\\n      nb = 1; goto slowlabel; \\\n    } \\\n  } \\\n  look = PEEK_BITS(HUFF_LOOKAHEAD); \\\n  if ((nb = htbl->look_nbits[look]) != 0) { \\\n    DROP_BITS(nb); \\\n    result = htbl->look_sym[look]; \\\n  } else { \\\n    nb = HUFF_LOOKAHEAD+1; \\\nslowlabel: \\\n    if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \\\n\t{ failaction; } \\\n    get_buffer = state.get_buffer; bits_left = state.bits_left; \\\n  } \\\n}\n\n/* Out-of-line case for Huffman code fetching */\nEXTERN int jpeg_huff_decode JPP((bitread_working_state * state,\n\t\tregister bit_buf_type get_buffer, register int bits_left,\n\t\td_derived_tbl * htbl, int min_bits));\n"
  },
  {
    "path": "libs/jpeg6/jdinput.cpp",
    "content": "/*\n * jdinput.c\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains input control logic for the JPEG decompressor.\n * These routines are concerned with controlling the decompressor's input\n * processing (marker reading and coefficient decoding).  The actual input\n * reading is done in jdmarker.c, jdhuff.c, and jdphuff.c.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/* Private state */\n\ntypedef struct {\n  struct jpeg_input_controller pub; /* public fields */\n\n  boolean inheaders;\t\t/* TRUE until first SOS is reached */\n} my_input_controller;\n\ntypedef my_input_controller * my_inputctl_ptr;\n\n\n/* Forward declarations */\nMETHODDEF int consume_markers JPP((j_decompress_ptr cinfo));\n\n\n/*\n * Routines to calculate various quantities related to the size of the image.\n */\n\nLOCAL void\ninitial_setup (j_decompress_ptr cinfo)\n/* Called once, when first SOS marker is reached */\n{\n  int ci;\n  jpeg_component_info *compptr;\n\n  /* Make sure image isn't bigger than I can handle */\n  if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION ||\n      (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION)\n    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);\n\n  /* For now, precision must match compiled-in value... */\n  if (cinfo->data_precision != BITS_IN_JSAMPLE)\n    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);\n\n  /* Check that number of components won't exceed internal array sizes */\n  if (cinfo->num_components > MAX_COMPONENTS)\n    ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,\n\t     MAX_COMPONENTS);\n\n  /* Compute maximum sampling factors; check factor validity */\n  cinfo->max_h_samp_factor = 1;\n  cinfo->max_v_samp_factor = 1;\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR ||\n\tcompptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR)\n      ERREXIT(cinfo, JERR_BAD_SAMPLING);\n    cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,\n\t\t\t\t   compptr->h_samp_factor);\n    cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor,\n\t\t\t\t   compptr->v_samp_factor);\n  }\n\n  /* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE.\n   * In the full decompressor, this will be overridden by jdmaster.c;\n   * but in the transcoder, jdmaster.c is not used, so we must do it here.\n   */\n  cinfo->min_DCT_scaled_size = DCTSIZE;\n\n  /* Compute dimensions of components */\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    compptr->DCT_scaled_size = DCTSIZE;\n    /* Size in DCT blocks */\n    compptr->width_in_blocks = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,\n\t\t    (long) (cinfo->max_h_samp_factor * DCTSIZE));\n    compptr->height_in_blocks = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,\n\t\t    (long) (cinfo->max_v_samp_factor * DCTSIZE));\n    /* downsampled_width and downsampled_height will also be overridden by\n     * jdmaster.c if we are doing full decompression.  The transcoder library\n     * doesn't use these values, but the calling application might.\n     */\n    /* Size in samples */\n    compptr->downsampled_width = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,\n\t\t    (long) cinfo->max_h_samp_factor);\n    compptr->downsampled_height = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,\n\t\t    (long) cinfo->max_v_samp_factor);\n    /* Mark component needed, until color conversion says otherwise */\n    compptr->component_needed = TRUE;\n    /* Mark no quantization table yet saved for component */\n    compptr->quant_table = NULL;\n  }\n\n  /* Compute number of fully interleaved MCU rows. */\n  cinfo->total_iMCU_rows = (JDIMENSION)\n    jdiv_round_up((long) cinfo->image_height,\n\t\t  (long) (cinfo->max_v_samp_factor*DCTSIZE));\n\n  /* Decide whether file contains multiple scans */\n  if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode)\n    cinfo->inputctl->has_multiple_scans = TRUE;\n  else\n    cinfo->inputctl->has_multiple_scans = FALSE;\n}\n\n\nLOCAL void\nper_scan_setup (j_decompress_ptr cinfo)\n/* Do computations that are needed before processing a JPEG scan */\n/* cinfo->comps_in_scan and cinfo->cur_comp_info[] were set from SOS marker */\n{\n  int ci, mcublks, tmp;\n  jpeg_component_info *compptr;\n  \n  if (cinfo->comps_in_scan == 1) {\n    \n    /* Noninterleaved (single-component) scan */\n    compptr = cinfo->cur_comp_info[0];\n    \n    /* Overall image size in MCUs */\n    cinfo->MCUs_per_row = compptr->width_in_blocks;\n    cinfo->MCU_rows_in_scan = compptr->height_in_blocks;\n    \n    /* For noninterleaved scan, always one block per MCU */\n    compptr->MCU_width = 1;\n    compptr->MCU_height = 1;\n    compptr->MCU_blocks = 1;\n    compptr->MCU_sample_width = compptr->DCT_scaled_size;\n    compptr->last_col_width = 1;\n    /* For noninterleaved scans, it is convenient to define last_row_height\n     * as the number of block rows present in the last iMCU row.\n     */\n    tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor);\n    if (tmp == 0) tmp = compptr->v_samp_factor;\n    compptr->last_row_height = tmp;\n    \n    /* Prepare array describing MCU composition */\n    cinfo->blocks_in_MCU = 1;\n    cinfo->MCU_membership[0] = 0;\n    \n  } else {\n    \n    /* Interleaved (multi-component) scan */\n    if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)\n      ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,\n\t       MAX_COMPS_IN_SCAN);\n    \n    /* Overall image size in MCUs */\n    cinfo->MCUs_per_row = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_width,\n\t\t    (long) (cinfo->max_h_samp_factor*DCTSIZE));\n    cinfo->MCU_rows_in_scan = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_height,\n\t\t    (long) (cinfo->max_v_samp_factor*DCTSIZE));\n    \n    cinfo->blocks_in_MCU = 0;\n    \n    for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n      compptr = cinfo->cur_comp_info[ci];\n      /* Sampling factors give # of blocks of component in each MCU */\n      compptr->MCU_width = compptr->h_samp_factor;\n      compptr->MCU_height = compptr->v_samp_factor;\n      compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;\n      compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_scaled_size;\n      /* Figure number of non-dummy blocks in last MCU column & row */\n      tmp = (int) (compptr->width_in_blocks % compptr->MCU_width);\n      if (tmp == 0) tmp = compptr->MCU_width;\n      compptr->last_col_width = tmp;\n      tmp = (int) (compptr->height_in_blocks % compptr->MCU_height);\n      if (tmp == 0) tmp = compptr->MCU_height;\n      compptr->last_row_height = tmp;\n      /* Prepare array describing MCU composition */\n      mcublks = compptr->MCU_blocks;\n      if (cinfo->blocks_in_MCU + mcublks > D_MAX_BLOCKS_IN_MCU)\n\tERREXIT(cinfo, JERR_BAD_MCU_SIZE);\n      while (mcublks-- > 0) {\n\tcinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;\n      }\n    }\n    \n  }\n}\n\n\n/*\n * Save away a copy of the Q-table referenced by each component present\n * in the current scan, unless already saved during a prior scan.\n *\n * In a multiple-scan JPEG file, the encoder could assign different components\n * the same Q-table slot number, but change table definitions between scans\n * so that each component uses a different Q-table.  (The IJG encoder is not\n * currently capable of doing this, but other encoders might.)  Since we want\n * to be able to dequantize all the components at the end of the file, this\n * means that we have to save away the table actually used for each component.\n * We do this by copying the table at the start of the first scan containing\n * the component.\n * The JPEG spec prohibits the encoder from changing the contents of a Q-table\n * slot between scans of a component using that slot.  If the encoder does so\n * anyway, this decoder will simply use the Q-table values that were current\n * at the start of the first scan for the component.\n *\n * The decompressor output side looks only at the saved quant tables,\n * not at the current Q-table slots.\n */\n\nLOCAL void\nlatch_quant_tables (j_decompress_ptr cinfo)\n{\n  int ci, qtblno;\n  jpeg_component_info *compptr;\n  JQUANT_TBL * qtbl;\n\n  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\n    compptr = cinfo->cur_comp_info[ci];\n    /* No work if we already saved Q-table for this component */\n    if (compptr->quant_table != NULL)\n      continue;\n    /* Make sure specified quantization table is present */\n    qtblno = compptr->quant_tbl_no;\n    if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS ||\n\tcinfo->quant_tbl_ptrs[qtblno] == NULL)\n      ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);\n    /* OK, save away the quantization table */\n    qtbl = (JQUANT_TBL *)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t  SIZEOF(JQUANT_TBL));\n    MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], SIZEOF(JQUANT_TBL));\n    compptr->quant_table = qtbl;\n  }\n}\n\n\n/*\n * Initialize the input modules to read a scan of compressed data.\n * The first call to this is done by jdmaster.c after initializing\n * the entire decompressor (during jpeg_start_decompress).\n * Subsequent calls come from consume_markers, below.\n */\n\nMETHODDEF void\nstart_input_pass (j_decompress_ptr cinfo)\n{\n  per_scan_setup(cinfo);\n  latch_quant_tables(cinfo);\n  (*cinfo->entropy->start_pass) (cinfo);\n  (*cinfo->coef->start_input_pass) (cinfo);\n  cinfo->inputctl->consume_input = cinfo->coef->consume_data;\n}\n\n\n/*\n * Finish up after inputting a compressed-data scan.\n * This is called by the coefficient controller after it's read all\n * the expected data of the scan.\n */\n\nMETHODDEF void\nfinish_input_pass (j_decompress_ptr cinfo)\n{\n  cinfo->inputctl->consume_input = consume_markers;\n}\n\n\n/*\n * Read JPEG markers before, between, or after compressed-data scans.\n * Change state as necessary when a new scan is reached.\n * Return value is JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.\n *\n * The consume_input method pointer points either here or to the\n * coefficient controller's consume_data routine, depending on whether\n * we are reading a compressed data segment or inter-segment markers.\n */\n\nMETHODDEF int\nconsume_markers (j_decompress_ptr cinfo)\n{\n  my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl;\n  int val;\n\n  if (inputctl->pub.eoi_reached) /* After hitting EOI, read no further */\n    return JPEG_REACHED_EOI;\n\n  val = (*cinfo->marker->read_markers) (cinfo);\n\n  switch (val) {\n  case JPEG_REACHED_SOS:\t/* Found SOS */\n    if (inputctl->inheaders) {\t/* 1st SOS */\n      initial_setup(cinfo);\n      inputctl->inheaders = FALSE;\n      /* Note: start_input_pass must be called by jdmaster.c\n       * before any more input can be consumed.  jdapi.c is\n       * responsible for enforcing this sequencing.\n       */\n    } else {\t\t\t/* 2nd or later SOS marker */\n      if (! inputctl->pub.has_multiple_scans)\n\tERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */\n      start_input_pass(cinfo);\n    }\n    break;\n  case JPEG_REACHED_EOI:\t/* Found EOI */\n    inputctl->pub.eoi_reached = TRUE;\n    if (inputctl->inheaders) {\t/* Tables-only datastream, apparently */\n      if (cinfo->marker->saw_SOF)\n\tERREXIT(cinfo, JERR_SOF_NO_SOS);\n    } else {\n      /* Prevent infinite loop in coef ctlr's decompress_data routine\n       * if user set output_scan_number larger than number of scans.\n       */\n      if (cinfo->output_scan_number > cinfo->input_scan_number)\n\tcinfo->output_scan_number = cinfo->input_scan_number;\n    }\n    break;\n  case JPEG_SUSPENDED:\n    break;\n  }\n\n  return val;\n}\n\n\n/*\n * Reset state to begin a fresh datastream.\n */\n\nMETHODDEF void\nreset_input_controller (j_decompress_ptr cinfo)\n{\n  my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl;\n\n  inputctl->pub.consume_input = consume_markers;\n  inputctl->pub.has_multiple_scans = FALSE; /* \"unknown\" would be better */\n  inputctl->pub.eoi_reached = FALSE;\n  inputctl->inheaders = TRUE;\n  /* Reset other modules */\n  (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);\n  (*cinfo->marker->reset_marker_reader) (cinfo);\n  /* Reset progression state -- would be cleaner if entropy decoder did this */\n  cinfo->coef_bits = NULL;\n}\n\n\n/*\n * Initialize the input controller module.\n * This is called only once, when the decompression object is created.\n */\n\nGLOBAL void\njinit_input_controller (j_decompress_ptr cinfo)\n{\n  my_inputctl_ptr inputctl;\n\n  /* Create subobject in permanent pool */\n  inputctl = (my_inputctl_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,\n\t\t\t\tSIZEOF(my_input_controller));\n  cinfo->inputctl = (struct jpeg_input_controller *) inputctl;\n  /* Initialize method pointers */\n  inputctl->pub.consume_input = consume_markers;\n  inputctl->pub.reset_input_controller = reset_input_controller;\n  inputctl->pub.start_input_pass = start_input_pass;\n  inputctl->pub.finish_input_pass = finish_input_pass;\n  /* Initialize state: can't use reset_input_controller since we don't\n   * want to try to reset other modules yet.\n   */\n  inputctl->pub.has_multiple_scans = FALSE; /* \"unknown\" would be better */\n  inputctl->pub.eoi_reached = FALSE;\n  inputctl->inheaders = TRUE;\n}\n"
  },
  {
    "path": "libs/jpeg6/jdmainct.cpp",
    "content": "/*\n * jdmainct.c\n *\n * Copyright (C) 1994-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains the main buffer controller for decompression.\n * The main buffer lies between the JPEG decompressor proper and the\n * post-processor; it holds downsampled data in the JPEG colorspace.\n *\n * Note that this code is bypassed in raw-data mode, since the application\n * supplies the equivalent of the main buffer in that case.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/*\n * In the current system design, the main buffer need never be a full-image\n * buffer; any full-height buffers will be found inside the coefficient or\n * postprocessing controllers.  Nonetheless, the main controller is not\n * trivial.  Its responsibility is to provide context rows for upsampling/\n * rescaling, and doing this in an efficient fashion is a bit tricky.\n *\n * Postprocessor input data is counted in \"row groups\".  A row group\n * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size)\n * sample rows of each component.  (We require DCT_scaled_size values to be\n * chosen such that these numbers are integers.  In practice DCT_scaled_size\n * values will likely be powers of two, so we actually have the stronger\n * condition that DCT_scaled_size / min_DCT_scaled_size is an integer.)\n * Upsampling will typically produce max_v_samp_factor pixel rows from each\n * row group (times any additional scale factor that the upsampler is\n * applying).\n *\n * The coefficient controller will deliver data to us one iMCU row at a time;\n * each iMCU row contains v_samp_factor * DCT_scaled_size sample rows, or\n * exactly min_DCT_scaled_size row groups.  (This amount of data corresponds\n * to one row of MCUs when the image is fully interleaved.)  Note that the\n * number of sample rows varies across components, but the number of row\n * groups does not.  Some garbage sample rows may be included in the last iMCU\n * row at the bottom of the image.\n *\n * Depending on the vertical scaling algorithm used, the upsampler may need\n * access to the sample row(s) above and below its current input row group.\n * The upsampler is required to set need_context_rows TRUE at global selection\n * time if so.  When need_context_rows is FALSE, this controller can simply\n * obtain one iMCU row at a time from the coefficient controller and dole it\n * out as row groups to the postprocessor.\n *\n * When need_context_rows is TRUE, this controller guarantees that the buffer\n * passed to postprocessing contains at least one row group's worth of samples\n * above and below the row group(s) being processed.  Note that the context\n * rows \"above\" the first passed row group appear at negative row offsets in\n * the passed buffer.  At the top and bottom of the image, the required\n * context rows are manufactured by duplicating the first or last real sample\n * row; this avoids having special cases in the upsampling inner loops.\n *\n * The amount of context is fixed at one row group just because that's a\n * convenient number for this controller to work with.  The existing\n * upsamplers really only need one sample row of context.  An upsampler\n * supporting arbitrary output rescaling might wish for more than one row\n * group of context when shrinking the image; tough, we don't handle that.\n * (This is justified by the assumption that downsizing will be handled mostly\n * by adjusting the DCT_scaled_size values, so that the actual scale factor at\n * the upsample step needn't be much less than one.)\n *\n * To provide the desired context, we have to retain the last two row groups\n * of one iMCU row while reading in the next iMCU row.  (The last row group\n * can't be processed until we have another row group for its below-context,\n * and so we have to save the next-to-last group too for its above-context.)\n * We could do this most simply by copying data around in our buffer, but\n * that'd be very slow.  We can avoid copying any data by creating a rather\n * strange pointer structure.  Here's how it works.  We allocate a workspace\n * consisting of M+2 row groups (where M = min_DCT_scaled_size is the number\n * of row groups per iMCU row).  We create two sets of redundant pointers to\n * the workspace.  Labeling the physical row groups 0 to M+1, the synthesized\n * pointer lists look like this:\n *                   M+1                          M-1\n * master pointer --> 0         master pointer --> 0\n *                    1                            1\n *                   ...                          ...\n *                   M-3                          M-3\n *                   M-2                           M\n *                   M-1                          M+1\n *                    M                           M-2\n *                   M+1                          M-1\n *                    0                            0\n * We read alternate iMCU rows using each master pointer; thus the last two\n * row groups of the previous iMCU row remain un-overwritten in the workspace.\n * The pointer lists are set up so that the required context rows appear to\n * be adjacent to the proper places when we pass the pointer lists to the\n * upsampler.\n *\n * The above pictures describe the normal state of the pointer lists.\n * At top and bottom of the image, we diddle the pointer lists to duplicate\n * the first or last sample row as necessary (this is cheaper than copying\n * sample rows around).\n *\n * This scheme breaks down if M < 2, ie, min_DCT_scaled_size is 1.  In that\n * situation each iMCU row provides only one row group so the buffering logic\n * must be different (eg, we must read two iMCU rows before we can emit the\n * first row group).  For now, we simply do not support providing context\n * rows when min_DCT_scaled_size is 1.  That combination seems unlikely to\n * be worth providing --- if someone wants a 1/8th-size preview, they probably\n * want it quick and dirty, so a context-free upsampler is sufficient.\n */\n\n\n/* Private buffer controller object */\n\ntypedef struct {\n  struct jpeg_d_main_controller pub; /* public fields */\n\n  /* Pointer to allocated workspace (M or M+2 row groups). */\n  JSAMPARRAY buffer[MAX_COMPONENTS];\n\n  boolean buffer_full;\t\t/* Have we gotten an iMCU row from decoder? */\n  JDIMENSION rowgroup_ctr;\t/* counts row groups output to postprocessor */\n\n  /* Remaining fields are only used in the context case. */\n\n  /* These are the master pointers to the funny-order pointer lists. */\n  JSAMPIMAGE xbuffer[2];\t/* pointers to weird pointer lists */\n\n  int whichptr;\t\t\t/* indicates which pointer set is now in use */\n  int context_state;\t\t/* process_data state machine status */\n  JDIMENSION rowgroups_avail;\t/* row groups available to postprocessor */\n  JDIMENSION iMCU_row_ctr;\t/* counts iMCU rows to detect image top/bot */\n} my_main_controller;\n\ntypedef my_main_controller * my_main_ptr;\n\n/* context_state values: */\n#define CTX_PREPARE_FOR_IMCU\t0\t/* need to prepare for MCU row */\n#define CTX_PROCESS_IMCU\t1\t/* feeding iMCU to postprocessor */\n#define CTX_POSTPONED_ROW\t2\t/* feeding postponed row group */\n\n\n/* Forward declarations */\nMETHODDEF void process_data_simple_main\n\tJPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf,\n\t     JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail));\nMETHODDEF void process_data_context_main\n\tJPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf,\n\t     JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail));\n#ifdef QUANT_2PASS_SUPPORTED\nMETHODDEF void process_data_crank_post\n\tJPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf,\n\t     JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail));\n#endif\n\n\nLOCAL void\nalloc_funny_pointers (j_decompress_ptr cinfo)\n/* Allocate space for the funny pointer lists.\n * This is done only once, not once per pass.\n */\n{\n  my_main_ptr main = (my_main_ptr) cinfo->main;\n  int ci, rgroup;\n  int M = cinfo->min_DCT_scaled_size;\n  jpeg_component_info *compptr;\n  JSAMPARRAY xbuf;\n\n  /* Get top-level space for component array pointers.\n   * We alloc both arrays with one call to save a few cycles.\n   */\n  main->xbuffer[0] = (JSAMPIMAGE)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tcinfo->num_components * 2 * SIZEOF(JSAMPARRAY));\n  main->xbuffer[1] = main->xbuffer[0] + cinfo->num_components;\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /\n      cinfo->min_DCT_scaled_size; /* height of a row group of component */\n    /* Get space for pointer lists --- M+4 row groups in each list.\n     * We alloc both pointer lists with one call to save a few cycles.\n     */\n    xbuf = (JSAMPARRAY)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t  2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW));\n    xbuf += rgroup;\t\t/* want one row group at negative offsets */\n    main->xbuffer[0][ci] = xbuf;\n    xbuf += rgroup * (M + 4);\n    main->xbuffer[1][ci] = xbuf;\n  }\n}\n\n\nLOCAL void\nmake_funny_pointers (j_decompress_ptr cinfo)\n/* Create the funny pointer lists discussed in the comments above.\n * The actual workspace is already allocated (in main->buffer),\n * and the space for the pointer lists is allocated too.\n * This routine just fills in the curiously ordered lists.\n * This will be repeated at the beginning of each pass.\n */\n{\n  my_main_ptr main = (my_main_ptr) cinfo->main;\n  int ci, i, rgroup;\n  int M = cinfo->min_DCT_scaled_size;\n  jpeg_component_info *compptr;\n  JSAMPARRAY buf, xbuf0, xbuf1;\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /\n      cinfo->min_DCT_scaled_size; /* height of a row group of component */\n    xbuf0 = main->xbuffer[0][ci];\n    xbuf1 = main->xbuffer[1][ci];\n    /* First copy the workspace pointers as-is */\n    buf = main->buffer[ci];\n    for (i = 0; i < rgroup * (M + 2); i++) {\n      xbuf0[i] = xbuf1[i] = buf[i];\n    }\n    /* In the second list, put the last four row groups in swapped order */\n    for (i = 0; i < rgroup * 2; i++) {\n      xbuf1[rgroup*(M-2) + i] = buf[rgroup*M + i];\n      xbuf1[rgroup*M + i] = buf[rgroup*(M-2) + i];\n    }\n    /* The wraparound pointers at top and bottom will be filled later\n     * (see set_wraparound_pointers, below).  Initially we want the \"above\"\n     * pointers to duplicate the first actual data line.  This only needs\n     * to happen in xbuffer[0].\n     */\n    for (i = 0; i < rgroup; i++) {\n      xbuf0[i - rgroup] = xbuf0[0];\n    }\n  }\n}\n\n\nLOCAL void\nset_wraparound_pointers (j_decompress_ptr cinfo)\n/* Set up the \"wraparound\" pointers at top and bottom of the pointer lists.\n * This changes the pointer list state from top-of-image to the normal state.\n */\n{\n  my_main_ptr main = (my_main_ptr) cinfo->main;\n  int ci, i, rgroup;\n  int M = cinfo->min_DCT_scaled_size;\n  jpeg_component_info *compptr;\n  JSAMPARRAY xbuf0, xbuf1;\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /\n      cinfo->min_DCT_scaled_size; /* height of a row group of component */\n    xbuf0 = main->xbuffer[0][ci];\n    xbuf1 = main->xbuffer[1][ci];\n    for (i = 0; i < rgroup; i++) {\n      xbuf0[i - rgroup] = xbuf0[rgroup*(M+1) + i];\n      xbuf1[i - rgroup] = xbuf1[rgroup*(M+1) + i];\n      xbuf0[rgroup*(M+2) + i] = xbuf0[i];\n      xbuf1[rgroup*(M+2) + i] = xbuf1[i];\n    }\n  }\n}\n\n\nLOCAL void\nset_bottom_pointers (j_decompress_ptr cinfo)\n/* Change the pointer lists to duplicate the last sample row at the bottom\n * of the image.  whichptr indicates which xbuffer holds the final iMCU row.\n * Also sets rowgroups_avail to indicate number of nondummy row groups in row.\n */\n{\n  my_main_ptr main = (my_main_ptr) cinfo->main;\n  int ci, i, rgroup, iMCUheight, rows_left;\n  jpeg_component_info *compptr;\n  JSAMPARRAY xbuf;\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    /* Count sample rows in one iMCU row and in one row group */\n    iMCUheight = compptr->v_samp_factor * compptr->DCT_scaled_size;\n    rgroup = iMCUheight / cinfo->min_DCT_scaled_size;\n    /* Count nondummy sample rows remaining for this component */\n    rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight);\n    if (rows_left == 0) rows_left = iMCUheight;\n    /* Count nondummy row groups.  Should get same answer for each component,\n     * so we need only do it once.\n     */\n    if (ci == 0) {\n      main->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1);\n    }\n    /* Duplicate the last real sample row rgroup*2 times; this pads out the\n     * last partial rowgroup and ensures at least one full rowgroup of context.\n     */\n    xbuf = main->xbuffer[main->whichptr][ci];\n    for (i = 0; i < rgroup * 2; i++) {\n      xbuf[rows_left + i] = xbuf[rows_left-1];\n    }\n  }\n}\n\n\n/*\n * Initialize for a processing pass.\n */\n\nMETHODDEF void\nstart_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)\n{\n  my_main_ptr main = (my_main_ptr) cinfo->main;\n\n  switch (pass_mode) {\n  case JBUF_PASS_THRU:\n    if (cinfo->upsample->need_context_rows) {\n      main->pub.process_data = process_data_context_main;\n      make_funny_pointers(cinfo); /* Create the xbuffer[] lists */\n      main->whichptr = 0;\t/* Read first iMCU row into xbuffer[0] */\n      main->context_state = CTX_PREPARE_FOR_IMCU;\n      main->iMCU_row_ctr = 0;\n    } else {\n      /* Simple case with no context needed */\n      main->pub.process_data = process_data_simple_main;\n    }\n    main->buffer_full = FALSE;\t/* Mark buffer empty */\n    main->rowgroup_ctr = 0;\n    break;\n#ifdef QUANT_2PASS_SUPPORTED\n  case JBUF_CRANK_DEST:\n    /* For last pass of 2-pass quantization, just crank the postprocessor */\n    main->pub.process_data = process_data_crank_post;\n    break;\n#endif\n  default:\n    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n    break;\n  }\n}\n\n\n/*\n * Process some data.\n * This handles the simple case where no context is required.\n */\n\nMETHODDEF void\nprocess_data_simple_main (j_decompress_ptr cinfo,\n\t\t\t  JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t\t\t  JDIMENSION out_rows_avail)\n{\n  my_main_ptr main = (my_main_ptr) cinfo->main;\n  JDIMENSION rowgroups_avail;\n\n  /* Read input data if we haven't filled the main buffer yet */\n  if (! main->buffer_full) {\n    if (! (*cinfo->coef->decompress_data) (cinfo, main->buffer))\n      return;\t\t\t/* suspension forced, can do nothing more */\n    main->buffer_full = TRUE;\t/* OK, we have an iMCU row to work with */\n  }\n\n  /* There are always min_DCT_scaled_size row groups in an iMCU row. */\n  rowgroups_avail = (JDIMENSION) cinfo->min_DCT_scaled_size;\n  /* Note: at the bottom of the image, we may pass extra garbage row groups\n   * to the postprocessor.  The postprocessor has to check for bottom\n   * of image anyway (at row resolution), so no point in us doing it too.\n   */\n\n  /* Feed the postprocessor */\n  (*cinfo->post->post_process_data) (cinfo, main->buffer,\n\t\t\t\t     &main->rowgroup_ctr, rowgroups_avail,\n\t\t\t\t     output_buf, out_row_ctr, out_rows_avail);\n\n  /* Has postprocessor consumed all the data yet? If so, mark buffer empty */\n  if (main->rowgroup_ctr >= rowgroups_avail) {\n    main->buffer_full = FALSE;\n    main->rowgroup_ctr = 0;\n  }\n}\n\n\n/*\n * Process some data.\n * This handles the case where context rows must be provided.\n */\n\nMETHODDEF void\nprocess_data_context_main (j_decompress_ptr cinfo,\n\t\t\t   JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t\t\t   JDIMENSION out_rows_avail)\n{\n  my_main_ptr main = (my_main_ptr) cinfo->main;\n\n  /* Read input data if we haven't filled the main buffer yet */\n  if (! main->buffer_full) {\n    if (! (*cinfo->coef->decompress_data) (cinfo,\n\t\t\t\t\t   main->xbuffer[main->whichptr]))\n      return;\t\t\t/* suspension forced, can do nothing more */\n    main->buffer_full = TRUE;\t/* OK, we have an iMCU row to work with */\n    main->iMCU_row_ctr++;\t/* count rows received */\n  }\n\n  /* Postprocessor typically will not swallow all the input data it is handed\n   * in one call (due to filling the output buffer first).  Must be prepared\n   * to exit and restart.  This switch lets us keep track of how far we got.\n   * Note that each case falls through to the next on successful completion.\n   */\n  switch (main->context_state) {\n  case CTX_POSTPONED_ROW:\n    /* Call postprocessor using previously set pointers for postponed row */\n    (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr],\n\t\t\t&main->rowgroup_ctr, main->rowgroups_avail,\n\t\t\toutput_buf, out_row_ctr, out_rows_avail);\n    if (main->rowgroup_ctr < main->rowgroups_avail)\n      return;\t\t\t/* Need to suspend */\n    main->context_state = CTX_PREPARE_FOR_IMCU;\n    if (*out_row_ctr >= out_rows_avail)\n      return;\t\t\t/* Postprocessor exactly filled output buf */\n    /*FALLTHROUGH*/\n  case CTX_PREPARE_FOR_IMCU:\n    /* Prepare to process first M-1 row groups of this iMCU row */\n    main->rowgroup_ctr = 0;\n    main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size - 1);\n    /* Check for bottom of image: if so, tweak pointers to \"duplicate\"\n     * the last sample row, and adjust rowgroups_avail to ignore padding rows.\n     */\n    if (main->iMCU_row_ctr == cinfo->total_iMCU_rows)\n      set_bottom_pointers(cinfo);\n    main->context_state = CTX_PROCESS_IMCU;\n    /*FALLTHROUGH*/\n  case CTX_PROCESS_IMCU:\n    /* Call postprocessor using previously set pointers */\n    (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr],\n\t\t\t&main->rowgroup_ctr, main->rowgroups_avail,\n\t\t\toutput_buf, out_row_ctr, out_rows_avail);\n    if (main->rowgroup_ctr < main->rowgroups_avail)\n      return;\t\t\t/* Need to suspend */\n    /* After the first iMCU, change wraparound pointers to normal state */\n    if (main->iMCU_row_ctr == 1)\n      set_wraparound_pointers(cinfo);\n    /* Prepare to load new iMCU row using other xbuffer list */\n    main->whichptr ^= 1;\t/* 0=>1 or 1=>0 */\n    main->buffer_full = FALSE;\n    /* Still need to process last row group of this iMCU row, */\n    /* which is saved at index M+1 of the other xbuffer */\n    main->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_scaled_size + 1);\n    main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size + 2);\n    main->context_state = CTX_POSTPONED_ROW;\n  }\n}\n\n\n/*\n * Process some data.\n * Final pass of two-pass quantization: just call the postprocessor.\n * Source data will be the postprocessor controller's internal buffer.\n */\n\n#ifdef QUANT_2PASS_SUPPORTED\n\nMETHODDEF void\nprocess_data_crank_post (j_decompress_ptr cinfo,\n\t\t\t JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t\t\t JDIMENSION out_rows_avail)\n{\n  (*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL,\n\t\t\t\t     (JDIMENSION *) NULL, (JDIMENSION) 0,\n\t\t\t\t     output_buf, out_row_ctr, out_rows_avail);\n}\n\n#endif /* QUANT_2PASS_SUPPORTED */\n\n\n/*\n * Initialize main buffer controller.\n */\n\nGLOBAL void\njinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer)\n{\n  my_main_ptr main;\n  int ci, rgroup, ngroups;\n  jpeg_component_info *compptr;\n\n  main = (my_main_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_main_controller));\n  cinfo->main = (struct jpeg_d_main_controller *) main;\n  main->pub.start_pass = start_pass_main;\n\n  if (need_full_buffer)\t\t/* shouldn't happen */\n    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n\n  /* Allocate the workspace.\n   * ngroups is the number of row groups we need.\n   */\n  if (cinfo->upsample->need_context_rows) {\n    if (cinfo->min_DCT_scaled_size < 2) /* unsupported, see comments above */\n      ERREXIT(cinfo, JERR_NOTIMPL);\n    alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */\n    ngroups = cinfo->min_DCT_scaled_size + 2;\n  } else {\n    ngroups = cinfo->min_DCT_scaled_size;\n  }\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /\n      cinfo->min_DCT_scaled_size; /* height of a row group of component */\n    main->buffer[ci] = (*cinfo->mem->alloc_sarray)\n\t\t\t((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t compptr->width_in_blocks * compptr->DCT_scaled_size,\n\t\t\t (JDIMENSION) (rgroup * ngroups));\n  }\n}\n"
  },
  {
    "path": "libs/jpeg6/jdmarker.cpp",
    "content": "/*\n * jdmarker.c\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains routines to decode JPEG datastream markers.\n * Most of the complexity arises from our desire to support input\n * suspension: if not all of the data for a marker is available,\n * we must exit back to the application.  On resumption, we reprocess\n * the marker.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\ntypedef enum {\t\t\t/* JPEG marker codes */\n  M_SOF0  = 0xc0,\n  M_SOF1  = 0xc1,\n  M_SOF2  = 0xc2,\n  M_SOF3  = 0xc3,\n  \n  M_SOF5  = 0xc5,\n  M_SOF6  = 0xc6,\n  M_SOF7  = 0xc7,\n  \n  M_JPG   = 0xc8,\n  M_SOF9  = 0xc9,\n  M_SOF10 = 0xca,\n  M_SOF11 = 0xcb,\n  \n  M_SOF13 = 0xcd,\n  M_SOF14 = 0xce,\n  M_SOF15 = 0xcf,\n  \n  M_DHT   = 0xc4,\n  \n  M_DAC   = 0xcc,\n  \n  M_RST0  = 0xd0,\n  M_RST1  = 0xd1,\n  M_RST2  = 0xd2,\n  M_RST3  = 0xd3,\n  M_RST4  = 0xd4,\n  M_RST5  = 0xd5,\n  M_RST6  = 0xd6,\n  M_RST7  = 0xd7,\n  \n  M_SOI   = 0xd8,\n  M_EOI   = 0xd9,\n  M_SOS   = 0xda,\n  M_DQT   = 0xdb,\n  M_DNL   = 0xdc,\n  M_DRI   = 0xdd,\n  M_DHP   = 0xde,\n  M_EXP   = 0xdf,\n  \n  M_APP0  = 0xe0,\n  M_APP1  = 0xe1,\n  M_APP2  = 0xe2,\n  M_APP3  = 0xe3,\n  M_APP4  = 0xe4,\n  M_APP5  = 0xe5,\n  M_APP6  = 0xe6,\n  M_APP7  = 0xe7,\n  M_APP8  = 0xe8,\n  M_APP9  = 0xe9,\n  M_APP10 = 0xea,\n  M_APP11 = 0xeb,\n  M_APP12 = 0xec,\n  M_APP13 = 0xed,\n  M_APP14 = 0xee,\n  M_APP15 = 0xef,\n  \n  M_JPG0  = 0xf0,\n  M_JPG13 = 0xfd,\n  M_COM   = 0xfe,\n  \n  M_TEM   = 0x01,\n  \n  M_ERROR = 0x100\n} JPEG_MARKER;\n\n\n/*\n * Macros for fetching data from the data source module.\n *\n * At all times, cinfo->src->next_input_byte and ->bytes_in_buffer reflect\n * the current restart point; we update them only when we have reached a\n * suitable place to restart if a suspension occurs.\n */\n\n/* Declare and initialize local copies of input pointer/count */\n#define INPUT_VARS(cinfo)  \\\n\tstruct jpeg_source_mgr * datasrc = (cinfo)->src;  \\\n\tconst JOCTET * next_input_byte = datasrc->next_input_byte;  \\\n\tsize_t bytes_in_buffer = datasrc->bytes_in_buffer\n\n/* Unload the local copies --- do this only at a restart boundary */\n#define INPUT_SYNC(cinfo)  \\\n\t( datasrc->next_input_byte = next_input_byte,  \\\n\t  datasrc->bytes_in_buffer = bytes_in_buffer )\n\n/* Reload the local copies --- seldom used except in MAKE_BYTE_AVAIL */\n#define INPUT_RELOAD(cinfo)  \\\n\t( next_input_byte = datasrc->next_input_byte,  \\\n\t  bytes_in_buffer = datasrc->bytes_in_buffer )\n\n/* Internal macro for INPUT_BYTE and INPUT_2BYTES: make a byte available.\n * Note we do *not* do INPUT_SYNC before calling fill_input_buffer,\n * but we must reload the local copies after a successful fill.\n */\n#define MAKE_BYTE_AVAIL(cinfo,action)  \\\n\tif (bytes_in_buffer == 0) {  \\\n\t  if (! (*datasrc->fill_input_buffer) (cinfo))  \\\n\t    { action; }  \\\n\t  INPUT_RELOAD(cinfo);  \\\n\t}  \\\n\tbytes_in_buffer--\n\n/* Read a byte into variable V.\n * If must suspend, take the specified action (typically \"return FALSE\").\n */\n#define INPUT_BYTE(cinfo,V,action)  \\\n\tMAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \\\n\t\t  V = GETJOCTET(*next_input_byte++); )\n\n/* As above, but read two bytes interpreted as an unsigned 16-bit integer.\n * V should be declared unsigned int or perhaps INT32.\n */\n#define INPUT_2BYTES(cinfo,V,action)  \\\n\tMAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \\\n\t\t  V = ((unsigned int) GETJOCTET(*next_input_byte++)) << 8; \\\n\t\t  MAKE_BYTE_AVAIL(cinfo,action); \\\n\t\t  V += GETJOCTET(*next_input_byte++); )\n\n\n/*\n * Routines to process JPEG markers.\n *\n * Entry condition: JPEG marker itself has been read and its code saved\n *   in cinfo->unread_marker; input restart point is just after the marker.\n *\n * Exit: if return TRUE, have read and processed any parameters, and have\n *   updated the restart point to point after the parameters.\n *   If return FALSE, was forced to suspend before reaching end of\n *   marker parameters; restart point has not been moved.  Same routine\n *   will be called again after application supplies more input data.\n *\n * This approach to suspension assumes that all of a marker's parameters can\n * fit into a single input bufferload.  This should hold for \"normal\"\n * markers.  Some COM/APPn markers might have large parameter segments,\n * but we use skip_input_data to get past those, and thereby put the problem\n * on the source manager's shoulders.\n *\n * Note that we don't bother to avoid duplicate trace messages if a\n * suspension occurs within marker parameters.  Other side effects\n * require more care.\n */\n\n\nLOCAL boolean\nget_soi (j_decompress_ptr cinfo)\n/* Process an SOI marker */\n{\n  int i;\n  \n  TRACEMS(cinfo, 1, JTRC_SOI);\n\n  if (cinfo->marker->saw_SOI)\n    ERREXIT(cinfo, JERR_SOI_DUPLICATE);\n\n  /* Reset all parameters that are defined to be reset by SOI */\n\n  for (i = 0; i < NUM_ARITH_TBLS; i++) {\n    cinfo->arith_dc_L[i] = 0;\n    cinfo->arith_dc_U[i] = 1;\n    cinfo->arith_ac_K[i] = 5;\n  }\n  cinfo->restart_interval = 0;\n\n  /* Set initial assumptions for colorspace etc */\n\n  cinfo->jpeg_color_space = JCS_UNKNOWN;\n  cinfo->CCIR601_sampling = FALSE; /* Assume non-CCIR sampling??? */\n\n  cinfo->saw_JFIF_marker = FALSE;\n  cinfo->density_unit = 0;\t/* set default JFIF APP0 values */\n  cinfo->X_density = 1;\n  cinfo->Y_density = 1;\n  cinfo->saw_Adobe_marker = FALSE;\n  cinfo->Adobe_transform = 0;\n\n  cinfo->marker->saw_SOI = TRUE;\n\n  return TRUE;\n}\n\n\nLOCAL boolean\nget_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)\n/* Process a SOFn marker */\n{\n  INT32 length;\n  int c, ci;\n  jpeg_component_info * compptr;\n  INPUT_VARS(cinfo);\n\n  cinfo->progressive_mode = is_prog;\n  cinfo->arith_code = is_arith;\n\n  INPUT_2BYTES(cinfo, length, return FALSE);\n\n  INPUT_BYTE(cinfo, cinfo->data_precision, return FALSE);\n  INPUT_2BYTES(cinfo, cinfo->image_height, return FALSE);\n  INPUT_2BYTES(cinfo, cinfo->image_width, return FALSE);\n  INPUT_BYTE(cinfo, cinfo->num_components, return FALSE);\n\n  length -= 8;\n\n  TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker,\n\t   (int) cinfo->image_width, (int) cinfo->image_height,\n\t   cinfo->num_components);\n\n  if (cinfo->marker->saw_SOF)\n    ERREXIT(cinfo, JERR_SOF_DUPLICATE);\n\n  /* We don't support files in which the image height is initially specified */\n  /* as 0 and is later redefined by DNL.  As long as we have to check that,  */\n  /* might as well have a general sanity check. */\n  if (cinfo->image_height <= 0 || cinfo->image_width <= 0\n      || cinfo->num_components <= 0)\n    ERREXIT(cinfo, JERR_EMPTY_IMAGE);\n\n  if (length != (cinfo->num_components * 3))\n    ERREXIT(cinfo, JERR_BAD_LENGTH);\n\n  if (cinfo->comp_info == NULL)\t/* do only once, even if suspend */\n    cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small)\n\t\t\t((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t cinfo->num_components * SIZEOF(jpeg_component_info));\n  \n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    compptr->component_index = ci;\n    INPUT_BYTE(cinfo, compptr->component_id, return FALSE);\n    INPUT_BYTE(cinfo, c, return FALSE);\n    compptr->h_samp_factor = (c >> 4) & 15;\n    compptr->v_samp_factor = (c     ) & 15;\n    INPUT_BYTE(cinfo, compptr->quant_tbl_no, return FALSE);\n\n    TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT,\n\t     compptr->component_id, compptr->h_samp_factor,\n\t     compptr->v_samp_factor, compptr->quant_tbl_no);\n  }\n\n  cinfo->marker->saw_SOF = TRUE;\n\n  INPUT_SYNC(cinfo);\n  return TRUE;\n}\n\n\nLOCAL boolean\nget_sos (j_decompress_ptr cinfo)\n/* Process a SOS marker */\n{\n  INT32 length;\n  int i, ci, n, c, cc;\n  jpeg_component_info * compptr;\n  INPUT_VARS(cinfo);\n\n  if (! cinfo->marker->saw_SOF)\n    ERREXIT(cinfo, JERR_SOS_NO_SOF);\n\n  INPUT_2BYTES(cinfo, length, return FALSE);\n\n  INPUT_BYTE(cinfo, n, return FALSE); /* Number of components */\n\n  if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN)\n    ERREXIT(cinfo, JERR_BAD_LENGTH);\n\n  TRACEMS1(cinfo, 1, JTRC_SOS, n);\n\n  cinfo->comps_in_scan = n;\n\n  /* Collect the component-spec parameters */\n\n  for (i = 0; i < n; i++) {\n    INPUT_BYTE(cinfo, cc, return FALSE);\n    INPUT_BYTE(cinfo, c, return FALSE);\n    \n    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n\t ci++, compptr++) {\n      if (cc == compptr->component_id)\n\tgoto id_found;\n    }\n\n    ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);\n\n  id_found:\n\n    cinfo->cur_comp_info[i] = compptr;\n    compptr->dc_tbl_no = (c >> 4) & 15;\n    compptr->ac_tbl_no = (c     ) & 15;\n    \n    TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc,\n\t     compptr->dc_tbl_no, compptr->ac_tbl_no);\n  }\n\n  /* Collect the additional scan parameters Ss, Se, Ah/Al. */\n  INPUT_BYTE(cinfo, c, return FALSE);\n  cinfo->Ss = c;\n  INPUT_BYTE(cinfo, c, return FALSE);\n  cinfo->Se = c;\n  INPUT_BYTE(cinfo, c, return FALSE);\n  cinfo->Ah = (c >> 4) & 15;\n  cinfo->Al = (c     ) & 15;\n\n  TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo->Ss, cinfo->Se,\n\t   cinfo->Ah, cinfo->Al);\n\n  /* Prepare to scan data & restart markers */\n  cinfo->marker->next_restart_num = 0;\n\n  /* Count another SOS marker */\n  cinfo->input_scan_number++;\n\n  INPUT_SYNC(cinfo);\n  return TRUE;\n}\n\n\nMETHODDEF boolean\nget_app0 (j_decompress_ptr cinfo)\n/* Process an APP0 marker */\n{\n#define JFIF_LEN 14\n  INT32 length;\n  UINT8 b[JFIF_LEN];\n  int buffp;\n  INPUT_VARS(cinfo);\n\n  INPUT_2BYTES(cinfo, length, return FALSE);\n  length -= 2;\n\n  /* See if a JFIF APP0 marker is present */\n\n  if (length >= JFIF_LEN) {\n    for (buffp = 0; buffp < JFIF_LEN; buffp++)\n      INPUT_BYTE(cinfo, b[buffp], return FALSE);\n    length -= JFIF_LEN;\n\n    if (b[0]==0x4A && b[1]==0x46 && b[2]==0x49 && b[3]==0x46 && b[4]==0) {\n      /* Found JFIF APP0 marker: check version */\n      /* Major version must be 1, anything else signals an incompatible change.\n       * We used to treat this as an error, but now it's a nonfatal warning,\n       * because some bozo at Hijaak couldn't read the spec.\n       * Minor version should be 0..2, but process anyway if newer.\n       */\n      if (b[5] != 1)\n\tWARNMS2(cinfo, JWRN_JFIF_MAJOR, b[5], b[6]);\n      else if (b[6] > 2)\n\tTRACEMS2(cinfo, 1, JTRC_JFIF_MINOR, b[5], b[6]);\n      /* Save info */\n      cinfo->saw_JFIF_marker = TRUE;\n      cinfo->density_unit = b[7];\n      cinfo->X_density = (b[8] << 8) + b[9];\n      cinfo->Y_density = (b[10] << 8) + b[11];\n      TRACEMS3(cinfo, 1, JTRC_JFIF,\n\t       cinfo->X_density, cinfo->Y_density, cinfo->density_unit);\n      if (b[12] | b[13])\n\tTRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL, b[12], b[13]);\n      if (length != ((INT32) b[12] * (INT32) b[13] * (INT32) 3))\n\tTRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int) length);\n    } else {\n      /* Start of APP0 does not match \"JFIF\" */\n      TRACEMS1(cinfo, 1, JTRC_APP0, (int) length + JFIF_LEN);\n    }\n  } else {\n    /* Too short to be JFIF marker */\n    TRACEMS1(cinfo, 1, JTRC_APP0, (int) length);\n  }\n\n  INPUT_SYNC(cinfo);\n  if (length > 0)\t\t/* skip any remaining data -- could be lots */\n    (*cinfo->src->skip_input_data) (cinfo, (long) length);\n\n  return TRUE;\n}\n\n\nMETHODDEF boolean\nget_app14 (j_decompress_ptr cinfo)\n/* Process an APP14 marker */\n{\n#define ADOBE_LEN 12\n  INT32 length;\n  UINT8 b[ADOBE_LEN];\n  int buffp;\n  unsigned int version, flags0, flags1, transform;\n  INPUT_VARS(cinfo);\n\n  INPUT_2BYTES(cinfo, length, return FALSE);\n  length -= 2;\n\n  /* See if an Adobe APP14 marker is present */\n\n  if (length >= ADOBE_LEN) {\n    for (buffp = 0; buffp < ADOBE_LEN; buffp++)\n      INPUT_BYTE(cinfo, b[buffp], return FALSE);\n    length -= ADOBE_LEN;\n\n    if (b[0]==0x41 && b[1]==0x64 && b[2]==0x6F && b[3]==0x62 && b[4]==0x65) {\n      /* Found Adobe APP14 marker */\n      version = (b[5] << 8) + b[6];\n      flags0 = (b[7] << 8) + b[8];\n      flags1 = (b[9] << 8) + b[10];\n      transform = b[11];\n      TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform);\n      cinfo->saw_Adobe_marker = TRUE;\n      cinfo->Adobe_transform = (UINT8) transform;\n    } else {\n      /* Start of APP14 does not match \"Adobe\" */\n      TRACEMS1(cinfo, 1, JTRC_APP14, (int) length + ADOBE_LEN);\n    }\n  } else {\n    /* Too short to be Adobe marker */\n    TRACEMS1(cinfo, 1, JTRC_APP14, (int) length);\n  }\n\n  INPUT_SYNC(cinfo);\n  if (length > 0)\t\t/* skip any remaining data -- could be lots */\n    (*cinfo->src->skip_input_data) (cinfo, (long) length);\n\n  return TRUE;\n}\n\n\nLOCAL boolean\nget_dac (j_decompress_ptr cinfo)\n/* Process a DAC marker */\n{\n  INT32 length;\n  int index, val;\n  INPUT_VARS(cinfo);\n\n  INPUT_2BYTES(cinfo, length, return FALSE);\n  length -= 2;\n  \n  while (length > 0) {\n    INPUT_BYTE(cinfo, index, return FALSE);\n    INPUT_BYTE(cinfo, val, return FALSE);\n\n    length -= 2;\n\n    TRACEMS2(cinfo, 1, JTRC_DAC, index, val);\n\n    if (index < 0 || index >= (2*NUM_ARITH_TBLS))\n      ERREXIT1(cinfo, JERR_DAC_INDEX, index);\n\n    if (index >= NUM_ARITH_TBLS) { /* define AC table */\n      cinfo->arith_ac_K[index-NUM_ARITH_TBLS] = (UINT8) val;\n    } else {\t\t\t/* define DC table */\n      cinfo->arith_dc_L[index] = (UINT8) (val & 0x0F);\n      cinfo->arith_dc_U[index] = (UINT8) (val >> 4);\n      if (cinfo->arith_dc_L[index] > cinfo->arith_dc_U[index])\n\tERREXIT1(cinfo, JERR_DAC_VALUE, val);\n    }\n  }\n\n  INPUT_SYNC(cinfo);\n  return TRUE;\n}\n\n\nLOCAL boolean\nget_dht (j_decompress_ptr cinfo)\n/* Process a DHT marker */\n{\n  INT32 length;\n  UINT8 bits[17];\n  UINT8 huffval[256];\n  int i, index, count;\n  JHUFF_TBL **htblptr;\n  INPUT_VARS(cinfo);\n\n  INPUT_2BYTES(cinfo, length, return FALSE);\n  length -= 2;\n  \n  while (length > 0) {\n    INPUT_BYTE(cinfo, index, return FALSE);\n\n    TRACEMS1(cinfo, 1, JTRC_DHT, index);\n      \n    bits[0] = 0;\n    count = 0;\n    for (i = 1; i <= 16; i++) {\n      INPUT_BYTE(cinfo, bits[i], return FALSE);\n      count += bits[i];\n    }\n\n    length -= 1 + 16;\n\n    TRACEMS8(cinfo, 2, JTRC_HUFFBITS,\n\t     bits[1], bits[2], bits[3], bits[4],\n\t     bits[5], bits[6], bits[7], bits[8]);\n    TRACEMS8(cinfo, 2, JTRC_HUFFBITS,\n\t     bits[9], bits[10], bits[11], bits[12],\n\t     bits[13], bits[14], bits[15], bits[16]);\n\n    if (count > 256 || ((INT32) count) > length)\n      ERREXIT(cinfo, JERR_DHT_COUNTS);\n\n    for (i = 0; i < count; i++)\n      INPUT_BYTE(cinfo, huffval[i], return FALSE);\n\n    length -= count;\n\n    if (index & 0x10) {\t\t/* AC table definition */\n      index -= 0x10;\n      htblptr = &cinfo->ac_huff_tbl_ptrs[index];\n    } else {\t\t\t/* DC table definition */\n      htblptr = &cinfo->dc_huff_tbl_ptrs[index];\n    }\n\n    if (index < 0 || index >= NUM_HUFF_TBLS)\n      ERREXIT1(cinfo, JERR_DHT_INDEX, index);\n\n    if (*htblptr == NULL)\n      *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);\n  \n    MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits));\n    MEMCOPY((*htblptr)->huffval, huffval, SIZEOF((*htblptr)->huffval));\n  }\n\n  INPUT_SYNC(cinfo);\n  return TRUE;\n}\n\n\nLOCAL boolean\nget_dqt (j_decompress_ptr cinfo)\n/* Process a DQT marker */\n{\n  INT32 length;\n  int n, i, prec;\n  unsigned int tmp;\n  JQUANT_TBL *quant_ptr;\n  INPUT_VARS(cinfo);\n\n  INPUT_2BYTES(cinfo, length, return FALSE);\n  length -= 2;\n\n  while (length > 0) {\n    INPUT_BYTE(cinfo, n, return FALSE);\n    prec = n >> 4;\n    n &= 0x0F;\n\n    TRACEMS2(cinfo, 1, JTRC_DQT, n, prec);\n\n    if (n >= NUM_QUANT_TBLS)\n      ERREXIT1(cinfo, JERR_DQT_INDEX, n);\n      \n    if (cinfo->quant_tbl_ptrs[n] == NULL)\n      cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo);\n    quant_ptr = cinfo->quant_tbl_ptrs[n];\n\n    for (i = 0; i < DCTSIZE2; i++) {\n      if (prec)\n\tINPUT_2BYTES(cinfo, tmp, return FALSE);\n      else\n\tINPUT_BYTE(cinfo, tmp, return FALSE);\n      quant_ptr->quantval[i] = (UINT16) tmp;\n    }\n\n    for (i = 0; i < DCTSIZE2; i += 8) {\n      TRACEMS8(cinfo, 2, JTRC_QUANTVALS,\n\t       quant_ptr->quantval[i  ], quant_ptr->quantval[i+1],\n\t       quant_ptr->quantval[i+2], quant_ptr->quantval[i+3],\n\t       quant_ptr->quantval[i+4], quant_ptr->quantval[i+5],\n\t       quant_ptr->quantval[i+6], quant_ptr->quantval[i+7]);\n    }\n\n    length -= DCTSIZE2+1;\n    if (prec) length -= DCTSIZE2;\n  }\n\n  INPUT_SYNC(cinfo);\n  return TRUE;\n}\n\n\nLOCAL boolean\nget_dri (j_decompress_ptr cinfo)\n/* Process a DRI marker */\n{\n  INT32 length;\n  unsigned int tmp;\n  INPUT_VARS(cinfo);\n\n  INPUT_2BYTES(cinfo, length, return FALSE);\n  \n  if (length != 4)\n    ERREXIT(cinfo, JERR_BAD_LENGTH);\n\n  INPUT_2BYTES(cinfo, tmp, return FALSE);\n\n  TRACEMS1(cinfo, 1, JTRC_DRI, tmp);\n\n  cinfo->restart_interval = tmp;\n\n  INPUT_SYNC(cinfo);\n  return TRUE;\n}\n\n\nMETHODDEF boolean\nskip_variable (j_decompress_ptr cinfo)\n/* Skip over an unknown or uninteresting variable-length marker */\n{\n  INT32 length;\n  INPUT_VARS(cinfo);\n\n  INPUT_2BYTES(cinfo, length, return FALSE);\n  \n  TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int) length);\n\n  INPUT_SYNC(cinfo);\t\t/* do before skip_input_data */\n  (*cinfo->src->skip_input_data) (cinfo, (long) length - 2L);\n\n  return TRUE;\n}\n\n\n/*\n * Find the next JPEG marker, save it in cinfo->unread_marker.\n * Returns FALSE if had to suspend before reaching a marker;\n * in that case cinfo->unread_marker is unchanged.\n *\n * Note that the result might not be a valid marker code,\n * but it will never be 0 or FF.\n */\n\nLOCAL boolean\nnext_marker (j_decompress_ptr cinfo)\n{\n  int c;\n  INPUT_VARS(cinfo);\n\n  for (;;) {\n    INPUT_BYTE(cinfo, c, return FALSE);\n    /* Skip any non-FF bytes.\n     * This may look a bit inefficient, but it will not occur in a valid file.\n     * We sync after each discarded byte so that a suspending data source\n     * can discard the byte from its buffer.\n     */\n    while (c != 0xFF) {\n      cinfo->marker->discarded_bytes++;\n      INPUT_SYNC(cinfo);\n      INPUT_BYTE(cinfo, c, return FALSE);\n    }\n    /* This loop swallows any duplicate FF bytes.  Extra FFs are legal as\n     * pad bytes, so don't count them in discarded_bytes.  We assume there\n     * will not be so many consecutive FF bytes as to overflow a suspending\n     * data source's input buffer.\n     */\n    do {\n      INPUT_BYTE(cinfo, c, return FALSE);\n    } while (c == 0xFF);\n    if (c != 0)\n      break;\t\t\t/* found a valid marker, exit loop */\n    /* Reach here if we found a stuffed-zero data sequence (FF/00).\n     * Discard it and loop back to try again.\n     */\n    cinfo->marker->discarded_bytes += 2;\n    INPUT_SYNC(cinfo);\n  }\n\n  if (cinfo->marker->discarded_bytes != 0) {\n    WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes, c);\n    cinfo->marker->discarded_bytes = 0;\n  }\n\n  cinfo->unread_marker = c;\n\n  INPUT_SYNC(cinfo);\n  return TRUE;\n}\n\n\nLOCAL boolean\nfirst_marker (j_decompress_ptr cinfo)\n/* Like next_marker, but used to obtain the initial SOI marker. */\n/* For this marker, we do not allow preceding garbage or fill; otherwise,\n * we might well scan an entire input file before realizing it ain't JPEG.\n * If an application wants to process non-JFIF files, it must seek to the\n * SOI before calling the JPEG library.\n */\n{\n  int c, c2;\n  INPUT_VARS(cinfo);\n\n  INPUT_BYTE(cinfo, c, return FALSE);\n  INPUT_BYTE(cinfo, c2, return FALSE);\n  if (c != 0xFF || c2 != (int) M_SOI)\n    ERREXIT2(cinfo, JERR_NO_SOI, c, c2);\n\n  cinfo->unread_marker = c2;\n\n  INPUT_SYNC(cinfo);\n  return TRUE;\n}\n\n\n/*\n * Read markers until SOS or EOI.\n *\n * Returns same codes as are defined for jpeg_consume_input:\n * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.\n */\n\nMETHODDEF int\nread_markers (j_decompress_ptr cinfo)\n{\n  /* Outer loop repeats once for each marker. */\n  for (;;) {\n    /* Collect the marker proper, unless we already did. */\n    /* NB: first_marker() enforces the requirement that SOI appear first. */\n    if (cinfo->unread_marker == 0) {\n      if (! cinfo->marker->saw_SOI) {\n\tif (! first_marker(cinfo))\n\t  return JPEG_SUSPENDED;\n      } else {\n\tif (! next_marker(cinfo))\n\t  return JPEG_SUSPENDED;\n      }\n    }\n    /* At this point cinfo->unread_marker contains the marker code and the\n     * input point is just past the marker proper, but before any parameters.\n     * A suspension will cause us to return with this state still true.\n     */\n    switch (cinfo->unread_marker) {\n    case M_SOI:\n      if (! get_soi(cinfo))\n\treturn JPEG_SUSPENDED;\n      break;\n\n    case M_SOF0:\t\t/* Baseline */\n    case M_SOF1:\t\t/* Extended sequential, Huffman */\n      if (! get_sof(cinfo, FALSE, FALSE))\n\treturn JPEG_SUSPENDED;\n      break;\n\n    case M_SOF2:\t\t/* Progressive, Huffman */\n      if (! get_sof(cinfo, TRUE, FALSE))\n\treturn JPEG_SUSPENDED;\n      break;\n\n    case M_SOF9:\t\t/* Extended sequential, arithmetic */\n      if (! get_sof(cinfo, FALSE, TRUE))\n\treturn JPEG_SUSPENDED;\n      break;\n\n    case M_SOF10:\t\t/* Progressive, arithmetic */\n      if (! get_sof(cinfo, TRUE, TRUE))\n\treturn JPEG_SUSPENDED;\n      break;\n\n    /* Currently unsupported SOFn types */\n    case M_SOF3:\t\t/* Lossless, Huffman */\n    case M_SOF5:\t\t/* Differential sequential, Huffman */\n    case M_SOF6:\t\t/* Differential progressive, Huffman */\n    case M_SOF7:\t\t/* Differential lossless, Huffman */\n    case M_JPG:\t\t\t/* Reserved for JPEG extensions */\n    case M_SOF11:\t\t/* Lossless, arithmetic */\n    case M_SOF13:\t\t/* Differential sequential, arithmetic */\n    case M_SOF14:\t\t/* Differential progressive, arithmetic */\n    case M_SOF15:\t\t/* Differential lossless, arithmetic */\n      ERREXIT1(cinfo, JERR_SOF_UNSUPPORTED, cinfo->unread_marker);\n      break;\n\n    case M_SOS:\n      if (! get_sos(cinfo))\n\treturn JPEG_SUSPENDED;\n      cinfo->unread_marker = 0;\t/* processed the marker */\n      return JPEG_REACHED_SOS;\n    \n    case M_EOI:\n      TRACEMS(cinfo, 1, JTRC_EOI);\n      cinfo->unread_marker = 0;\t/* processed the marker */\n      return JPEG_REACHED_EOI;\n      \n    case M_DAC:\n      if (! get_dac(cinfo))\n\treturn JPEG_SUSPENDED;\n      break;\n      \n    case M_DHT:\n      if (! get_dht(cinfo))\n\treturn JPEG_SUSPENDED;\n      break;\n      \n    case M_DQT:\n      if (! get_dqt(cinfo))\n\treturn JPEG_SUSPENDED;\n      break;\n      \n    case M_DRI:\n      if (! get_dri(cinfo))\n\treturn JPEG_SUSPENDED;\n      break;\n      \n    case M_APP0:\n    case M_APP1:\n    case M_APP2:\n    case M_APP3:\n    case M_APP4:\n    case M_APP5:\n    case M_APP6:\n    case M_APP7:\n    case M_APP8:\n    case M_APP9:\n    case M_APP10:\n    case M_APP11:\n    case M_APP12:\n    case M_APP13:\n    case M_APP14:\n    case M_APP15:\n      if (! (*cinfo->marker->process_APPn[cinfo->unread_marker - (int) M_APP0]) (cinfo))\n\treturn JPEG_SUSPENDED;\n      break;\n      \n    case M_COM:\n      if (! (*cinfo->marker->process_COM) (cinfo))\n\treturn JPEG_SUSPENDED;\n      break;\n\n    case M_RST0:\t\t/* these are all parameterless */\n    case M_RST1:\n    case M_RST2:\n    case M_RST3:\n    case M_RST4:\n    case M_RST5:\n    case M_RST6:\n    case M_RST7:\n    case M_TEM:\n      TRACEMS1(cinfo, 1, JTRC_PARMLESS_MARKER, cinfo->unread_marker);\n      break;\n\n    case M_DNL:\t\t\t/* Ignore DNL ... perhaps the wrong thing */\n      if (! skip_variable(cinfo))\n\treturn JPEG_SUSPENDED;\n      break;\n\n    default:\t\t\t/* must be DHP, EXP, JPGn, or RESn */\n      /* For now, we treat the reserved markers as fatal errors since they are\n       * likely to be used to signal incompatible JPEG Part 3 extensions.\n       * Once the JPEG 3 version-number marker is well defined, this code\n       * ought to change!\n       */\n      ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);\n      break;\n    }\n    /* Successfully processed marker, so reset state variable */\n    cinfo->unread_marker = 0;\n  } /* end loop */\n}\n\n\n/*\n * Read a restart marker, which is expected to appear next in the datastream;\n * if the marker is not there, take appropriate recovery action.\n * Returns FALSE if suspension is required.\n *\n * This is called by the entropy decoder after it has read an appropriate\n * number of MCUs.  cinfo->unread_marker may be nonzero if the entropy decoder\n * has already read a marker from the data source.  Under normal conditions\n * cinfo->unread_marker will be reset to 0 before returning; if not reset,\n * it holds a marker which the decoder will be unable to read past.\n */\n\nMETHODDEF boolean\nread_restart_marker (j_decompress_ptr cinfo)\n{\n  /* Obtain a marker unless we already did. */\n  /* Note that next_marker will complain if it skips any data. */\n  if (cinfo->unread_marker == 0) {\n    if (! next_marker(cinfo))\n      return FALSE;\n  }\n\n  if (cinfo->unread_marker ==\n      ((int) M_RST0 + cinfo->marker->next_restart_num)) {\n    /* Normal case --- swallow the marker and let entropy decoder continue */\n    TRACEMS1(cinfo, 2, JTRC_RST, cinfo->marker->next_restart_num);\n    cinfo->unread_marker = 0;\n  } else {\n    /* Uh-oh, the restart markers have been messed up. */\n    /* Let the data source manager determine how to resync. */\n    if (! (*cinfo->src->resync_to_restart) (cinfo,\n\t\t\t\t\t    cinfo->marker->next_restart_num))\n      return FALSE;\n  }\n\n  /* Update next-restart state */\n  cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7;\n\n  return TRUE;\n}\n\n\n/*\n * This is the default resync_to_restart method for data source managers\n * to use if they don't have any better approach.  Some data source managers\n * may be able to back up, or may have additional knowledge about the data\n * which permits a more intelligent recovery strategy; such managers would\n * presumably supply their own resync method.\n *\n * read_restart_marker calls resync_to_restart if it finds a marker other than\n * the restart marker it was expecting.  (This code is *not* used unless\n * a nonzero restart interval has been declared.)  cinfo->unread_marker is\n * the marker code actually found (might be anything, except 0 or FF).\n * The desired restart marker number (0..7) is passed as a parameter.\n * This routine is supposed to apply whatever error recovery strategy seems\n * appropriate in order to position the input stream to the next data segment.\n * Note that cinfo->unread_marker is treated as a marker appearing before\n * the current data-source input point; usually it should be reset to zero\n * before returning.\n * Returns FALSE if suspension is required.\n *\n * This implementation is substantially constrained by wanting to treat the\n * input as a data stream; this means we can't back up.  Therefore, we have\n * only the following actions to work with:\n *   1. Simply discard the marker and let the entropy decoder resume at next\n *      byte of file.\n *   2. Read forward until we find another marker, discarding intervening\n *      data.  (In theory we could look ahead within the current bufferload,\n *      without having to discard data if we don't find the desired marker.\n *      This idea is not implemented here, in part because it makes behavior\n *      dependent on buffer size and chance buffer-boundary positions.)\n *   3. Leave the marker unread (by failing to zero cinfo->unread_marker).\n *      This will cause the entropy decoder to process an empty data segment,\n *      inserting dummy zeroes, and then we will reprocess the marker.\n *\n * #2 is appropriate if we think the desired marker lies ahead, while #3 is\n * appropriate if the found marker is a future restart marker (indicating\n * that we have missed the desired restart marker, probably because it got\n * corrupted).\n * We apply #2 or #3 if the found marker is a restart marker no more than\n * two counts behind or ahead of the expected one.  We also apply #2 if the\n * found marker is not a legal JPEG marker code (it's certainly bogus data).\n * If the found marker is a restart marker more than 2 counts away, we do #1\n * (too much risk that the marker is erroneous; with luck we will be able to\n * resync at some future point).\n * For any valid non-restart JPEG marker, we apply #3.  This keeps us from\n * overrunning the end of a scan.  An implementation limited to single-scan\n * files might find it better to apply #2 for markers other than EOI, since\n * any other marker would have to be bogus data in that case.\n */\n\nGLOBAL boolean\njpeg_resync_to_restart (j_decompress_ptr cinfo, int desired)\n{\n  int marker = cinfo->unread_marker;\n  int action = 1;\n  \n  /* Always put up a warning. */\n  WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired);\n  \n  /* Outer loop handles repeated decision after scanning forward. */\n  for (;;) {\n    if (marker < (int) M_SOF0)\n      action = 2;\t\t/* invalid marker */\n    else if (marker < (int) M_RST0 || marker > (int) M_RST7)\n      action = 3;\t\t/* valid non-restart marker */\n    else {\n      if (marker == ((int) M_RST0 + ((desired+1) & 7)) ||\n\t  marker == ((int) M_RST0 + ((desired+2) & 7)))\n\taction = 3;\t\t/* one of the next two expected restarts */\n      else if (marker == ((int) M_RST0 + ((desired-1) & 7)) ||\n\t       marker == ((int) M_RST0 + ((desired-2) & 7)))\n\taction = 2;\t\t/* a prior restart, so advance */\n      else\n\taction = 1;\t\t/* desired restart or too far away */\n    }\n    TRACEMS2(cinfo, 4, JTRC_RECOVERY_ACTION, marker, action);\n    switch (action) {\n    case 1:\n      /* Discard marker and let entropy decoder resume processing. */\n      cinfo->unread_marker = 0;\n      return TRUE;\n    case 2:\n      /* Scan to the next marker, and repeat the decision loop. */\n      if (! next_marker(cinfo))\n\treturn FALSE;\n      marker = cinfo->unread_marker;\n      break;\n    case 3:\n      /* Return without advancing past this marker. */\n      /* Entropy decoder will be forced to process an empty segment. */\n      return TRUE;\n    }\n  } /* end loop */\n}\n\n\n/*\n * Reset marker processing state to begin a fresh datastream.\n */\n\nMETHODDEF void\nreset_marker_reader (j_decompress_ptr cinfo)\n{\n  cinfo->comp_info = NULL;\t\t/* until allocated by get_sof */\n  cinfo->input_scan_number = 0;\t\t/* no SOS seen yet */\n  cinfo->unread_marker = 0;\t\t/* no pending marker */\n  cinfo->marker->saw_SOI = FALSE;\t/* set internal state too */\n  cinfo->marker->saw_SOF = FALSE;\n  cinfo->marker->discarded_bytes = 0;\n}\n\n\n/*\n * Initialize the marker reader module.\n * This is called only once, when the decompression object is created.\n */\n\nGLOBAL void\njinit_marker_reader (j_decompress_ptr cinfo)\n{\n  int i;\n\n  /* Create subobject in permanent pool */\n  cinfo->marker = (struct jpeg_marker_reader *)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,\n\t\t\t\tSIZEOF(struct jpeg_marker_reader));\n  /* Initialize method pointers */\n  cinfo->marker->reset_marker_reader = reset_marker_reader;\n  cinfo->marker->read_markers = read_markers;\n  cinfo->marker->read_restart_marker = read_restart_marker;\n  cinfo->marker->process_COM = skip_variable;\n  for (i = 0; i < 16; i++)\n    cinfo->marker->process_APPn[i] = skip_variable;\n  cinfo->marker->process_APPn[0] = get_app0;\n  cinfo->marker->process_APPn[14] = get_app14;\n  /* Reset marker processing state */\n  reset_marker_reader(cinfo);\n}\n"
  },
  {
    "path": "libs/jpeg6/jdmaster.cpp",
    "content": "/*\n * jdmaster.c\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains master control logic for the JPEG decompressor.\n * These routines are concerned with selecting the modules to be executed\n * and with determining the number of passes and the work to be done in each\n * pass.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/* Private state */\n\ntypedef struct {\n  struct jpeg_decomp_master pub; /* public fields */\n\n  int pass_number;\t\t/* # of passes completed */\n\n  boolean using_merged_upsample; /* TRUE if using merged upsample/cconvert */\n\n  /* Saved references to initialized quantizer modules,\n   * in case we need to switch modes.\n   */\n  struct jpeg_color_quantizer * quantizer_1pass;\n  struct jpeg_color_quantizer * quantizer_2pass;\n} my_decomp_master;\n\ntypedef my_decomp_master * my_master_ptr;\n\n\n/*\n * Determine whether merged upsample/color conversion should be used.\n * CRUCIAL: this must match the actual capabilities of jdmerge.c!\n */\n\nLOCAL boolean\nuse_merged_upsample (j_decompress_ptr cinfo)\n{\n#ifdef UPSAMPLE_MERGING_SUPPORTED\n  /* Merging is the equivalent of plain box-filter upsampling */\n  if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling)\n    return FALSE;\n  /* jdmerge.c only supports YCC=>RGB color conversion */\n  if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 ||\n      cinfo->out_color_space != JCS_RGB ||\n      cinfo->out_color_components != RGB_PIXELSIZE)\n    return FALSE;\n  /* and it only handles 2h1v or 2h2v sampling ratios */\n  if (cinfo->comp_info[0].h_samp_factor != 2 ||\n      cinfo->comp_info[1].h_samp_factor != 1 ||\n      cinfo->comp_info[2].h_samp_factor != 1 ||\n      cinfo->comp_info[0].v_samp_factor >  2 ||\n      cinfo->comp_info[1].v_samp_factor != 1 ||\n      cinfo->comp_info[2].v_samp_factor != 1)\n    return FALSE;\n  /* furthermore, it doesn't work if we've scaled the IDCTs differently */\n  if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size ||\n      cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size ||\n      cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size)\n    return FALSE;\n  /* ??? also need to test for upsample-time rescaling, when & if supported */\n  return TRUE;\t\t\t/* by golly, it'll work... */\n#else\n  return FALSE;\n#endif\n}\n\n\n/*\n * Compute output image dimensions and related values.\n * NOTE: this is exported for possible use by application.\n * Hence it mustn't do anything that can't be done twice.\n * Also note that it may be called before the master module is initialized!\n */\n\nGLOBAL void\njpeg_calc_output_dimensions (j_decompress_ptr cinfo)\n/* Do computations that are needed before master selection phase */\n{\n#if 0\t// JDC: commented out to remove warning\n  int ci;\n  jpeg_component_info *compptr;\n#endif\n\n  /* Prevent application from calling me at wrong times */\n  if (cinfo->global_state != DSTATE_READY)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n\n#ifdef IDCT_SCALING_SUPPORTED\n\n  /* Compute actual output image dimensions and DCT scaling choices. */\n  if (cinfo->scale_num * 8 <= cinfo->scale_denom) {\n    /* Provide 1/8 scaling */\n    cinfo->output_width = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_width, 8L);\n    cinfo->output_height = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_height, 8L);\n    cinfo->min_DCT_scaled_size = 1;\n  } else if (cinfo->scale_num * 4 <= cinfo->scale_denom) {\n    /* Provide 1/4 scaling */\n    cinfo->output_width = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_width, 4L);\n    cinfo->output_height = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_height, 4L);\n    cinfo->min_DCT_scaled_size = 2;\n  } else if (cinfo->scale_num * 2 <= cinfo->scale_denom) {\n    /* Provide 1/2 scaling */\n    cinfo->output_width = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_width, 2L);\n    cinfo->output_height = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_height, 2L);\n    cinfo->min_DCT_scaled_size = 4;\n  } else {\n    /* Provide 1/1 scaling */\n    cinfo->output_width = cinfo->image_width;\n    cinfo->output_height = cinfo->image_height;\n    cinfo->min_DCT_scaled_size = DCTSIZE;\n  }\n  /* In selecting the actual DCT scaling for each component, we try to\n   * scale up the chroma components via IDCT scaling rather than upsampling.\n   * This saves time if the upsampler gets to use 1:1 scaling.\n   * Note this code assumes that the supported DCT scalings are powers of 2.\n   */\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    int ssize = cinfo->min_DCT_scaled_size;\n    while (ssize < DCTSIZE &&\n\t   (compptr->h_samp_factor * ssize * 2 <=\n\t    cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) &&\n\t   (compptr->v_samp_factor * ssize * 2 <=\n\t    cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) {\n      ssize = ssize * 2;\n    }\n    compptr->DCT_scaled_size = ssize;\n  }\n\n  /* Recompute downsampled dimensions of components;\n   * application needs to know these if using raw downsampled data.\n   */\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    /* Size in samples, after IDCT scaling */\n    compptr->downsampled_width = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_width *\n\t\t    (long) (compptr->h_samp_factor * compptr->DCT_scaled_size),\n\t\t    (long) (cinfo->max_h_samp_factor * DCTSIZE));\n    compptr->downsampled_height = (JDIMENSION)\n      jdiv_round_up((long) cinfo->image_height *\n\t\t    (long) (compptr->v_samp_factor * compptr->DCT_scaled_size),\n\t\t    (long) (cinfo->max_v_samp_factor * DCTSIZE));\n  }\n\n#else /* !IDCT_SCALING_SUPPORTED */\n\n  /* Hardwire it to \"no scaling\" */\n  cinfo->output_width = cinfo->image_width;\n  cinfo->output_height = cinfo->image_height;\n  /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE,\n   * and has computed unscaled downsampled_width and downsampled_height.\n   */\n\n#endif /* IDCT_SCALING_SUPPORTED */\n\n  /* Report number of components in selected colorspace. */\n  /* Probably this should be in the color conversion module... */\n  switch (cinfo->out_color_space) {\n  case JCS_GRAYSCALE:\n    cinfo->out_color_components = 1;\n    break;\n  case JCS_RGB:\n#if RGB_PIXELSIZE != 3\n    cinfo->out_color_components = RGB_PIXELSIZE;\n    break;\n#endif /* else share code with YCbCr */\n  case JCS_YCbCr:\n    cinfo->out_color_components = 3;\n    break;\n  case JCS_CMYK:\n  case JCS_YCCK:\n    cinfo->out_color_components = 4;\n    break;\n  default:\t\t\t/* else must be same colorspace as in file */\n    cinfo->out_color_components = cinfo->num_components;\n    break;\n  }\n  cinfo->output_components = (cinfo->quantize_colors ? 1 :\n\t\t\t      cinfo->out_color_components);\n\n  /* See if upsampler will want to emit more than one row at a time */\n  if (use_merged_upsample(cinfo))\n    cinfo->rec_outbuf_height = cinfo->max_v_samp_factor;\n  else\n    cinfo->rec_outbuf_height = 1;\n}\n\n\n/*\n * Several decompression processes need to range-limit values to the range\n * 0..MAXJSAMPLE; the input value may fall somewhat outside this range\n * due to noise introduced by quantization, roundoff error, etc.  These\n * processes are inner loops and need to be as fast as possible.  On most\n * machines, particularly CPUs with pipelines or instruction prefetch,\n * a (subscript-check-less) C table lookup\n *\t\tx = sample_range_limit[x];\n * is faster than explicit tests\n *\t\tif (x < 0)  x = 0;\n *\t\telse if (x > MAXJSAMPLE)  x = MAXJSAMPLE;\n * These processes all use a common table prepared by the routine below.\n *\n * For most steps we can mathematically guarantee that the initial value\n * of x is within MAXJSAMPLE+1 of the legal range, so a table running from\n * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient.  But for the initial\n * limiting step (just after the IDCT), a wildly out-of-range value is \n * possible if the input data is corrupt.  To avoid any chance of indexing\n * off the end of memory and getting a bad-pointer trap, we perform the\n * post-IDCT limiting thus:\n *\t\tx = range_limit[x & MASK];\n * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit\n * samples.  Under normal circumstances this is more than enough range and\n * a correct output will be generated; with bogus input data the mask will\n * cause wraparound, and we will safely generate a bogus-but-in-range output.\n * For the post-IDCT step, we want to convert the data from signed to unsigned\n * representation by adding CENTERJSAMPLE at the same time that we limit it.\n * So the post-IDCT limiting table ends up looking like this:\n *   CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE,\n *   MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),\n *   0          (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),\n *   0,1,...,CENTERJSAMPLE-1\n * Negative inputs select values from the upper half of the table after\n * masking.\n *\n * We can save some space by overlapping the start of the post-IDCT table\n * with the simpler range limiting table.  The post-IDCT table begins at\n * sample_range_limit + CENTERJSAMPLE.\n *\n * Note that the table is allocated in near data space on PCs; it's small\n * enough and used often enough to justify this.\n */\n\nLOCAL void\nprepare_range_limit_table (j_decompress_ptr cinfo)\n/* Allocate and fill in the sample_range_limit table */\n{\n  JSAMPLE * table;\n  int i;\n\n  table = (JSAMPLE *)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t(5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE));\n  table += (MAXJSAMPLE+1);\t/* allow negative subscripts of simple table */\n  cinfo->sample_range_limit = table;\n  /* First segment of \"simple\" table: limit[x] = 0 for x < 0 */\n  MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));\n  /* Main part of \"simple\" table: limit[x] = x */\n  for (i = 0; i <= MAXJSAMPLE; i++)\n    table[i] = (JSAMPLE) i;\n  table += CENTERJSAMPLE;\t/* Point to where post-IDCT table starts */\n  /* End of simple table, rest of first half of post-IDCT table */\n  for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++)\n    table[i] = MAXJSAMPLE;\n  /* Second half of post-IDCT table */\n  MEMZERO(table + (2 * (MAXJSAMPLE+1)),\n\t  (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE));\n  MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE),\n\t  cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE));\n}\n\n\n/*\n * Master selection of decompression modules.\n * This is done once at jpeg_start_decompress time.  We determine\n * which modules will be used and give them appropriate initialization calls.\n * We also initialize the decompressor input side to begin consuming data.\n *\n * Since jpeg_read_header has finished, we know what is in the SOF\n * and (first) SOS markers.  We also have all the application parameter\n * settings.\n */\n\nLOCAL void\nmaster_selection (j_decompress_ptr cinfo)\n{\n  my_master_ptr master = (my_master_ptr) cinfo->master;\n  boolean use_c_buffer;\n  long samplesperrow;\n  JDIMENSION jd_samplesperrow;\n\n  /* Initialize dimensions and other stuff */\n  jpeg_calc_output_dimensions(cinfo);\n  prepare_range_limit_table(cinfo);\n\n  /* Width of an output scanline must be representable as JDIMENSION. */\n  samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components;\n  jd_samplesperrow = (JDIMENSION) samplesperrow;\n  if ((long) jd_samplesperrow != samplesperrow)\n    ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);\n\n  /* Initialize my private state */\n  master->pass_number = 0;\n  master->using_merged_upsample = use_merged_upsample(cinfo);\n\n  /* Color quantizer selection */\n  master->quantizer_1pass = NULL;\n  master->quantizer_2pass = NULL;\n  /* No mode changes if not using buffered-image mode. */\n  if (! cinfo->quantize_colors || ! cinfo->buffered_image) {\n    cinfo->enable_1pass_quant = FALSE;\n    cinfo->enable_external_quant = FALSE;\n    cinfo->enable_2pass_quant = FALSE;\n  }\n  if (cinfo->quantize_colors) {\n    if (cinfo->raw_data_out)\n      ERREXIT(cinfo, JERR_NOTIMPL);\n    /* 2-pass quantizer only works in 3-component color space. */\n    if (cinfo->out_color_components != 3) {\n      cinfo->enable_1pass_quant = TRUE;\n      cinfo->enable_external_quant = FALSE;\n      cinfo->enable_2pass_quant = FALSE;\n      cinfo->colormap = NULL;\n    } else if (cinfo->colormap != NULL) {\n      cinfo->enable_external_quant = TRUE;\n    } else if (cinfo->two_pass_quantize) {\n      cinfo->enable_2pass_quant = TRUE;\n    } else {\n      cinfo->enable_1pass_quant = TRUE;\n    }\n\n    if (cinfo->enable_1pass_quant) {\n#ifdef QUANT_1PASS_SUPPORTED\n      jinit_1pass_quantizer(cinfo);\n      master->quantizer_1pass = cinfo->cquantize;\n#else\n      ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif\n    }\n\n    /* We use the 2-pass code to map to external colormaps. */\n    if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) {\n#ifdef QUANT_2PASS_SUPPORTED\n      jinit_2pass_quantizer(cinfo);\n      master->quantizer_2pass = cinfo->cquantize;\n#else\n      ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif\n    }\n    /* If both quantizers are initialized, the 2-pass one is left active;\n     * this is necessary for starting with quantization to an external map.\n     */\n  }\n\n  /* Post-processing: in particular, color conversion first */\n  if (! cinfo->raw_data_out) {\n    if (master->using_merged_upsample) {\n#ifdef UPSAMPLE_MERGING_SUPPORTED\n      jinit_merged_upsampler(cinfo); /* does color conversion too */\n#else\n      ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif\n    } else {\n      jinit_color_deconverter(cinfo);\n      jinit_upsampler(cinfo);\n    }\n    jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant);\n  }\n  /* Inverse DCT */\n  jinit_inverse_dct(cinfo);\n  /* Entropy decoding: either Huffman or arithmetic coding. */\n  if (cinfo->arith_code) {\n    ERREXIT(cinfo, JERR_ARITH_NOTIMPL);\n  } else {\n    if (cinfo->progressive_mode) {\n#ifdef D_PROGRESSIVE_SUPPORTED\n      jinit_phuff_decoder(cinfo);\n#else\n      ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif\n    } else\n      jinit_huff_decoder(cinfo);\n  }\n\n  /* Initialize principal buffer controllers. */\n  use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image;\n  jinit_d_coef_controller(cinfo, use_c_buffer);\n\n  if (! cinfo->raw_data_out)\n    jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */);\n\n  /* We can now tell the memory manager to allocate virtual arrays. */\n  (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);\n\n  /* Initialize input side of decompressor to consume first scan. */\n  (*cinfo->inputctl->start_input_pass) (cinfo);\n\n#ifdef D_MULTISCAN_FILES_SUPPORTED\n  /* If jpeg_start_decompress will read the whole file, initialize\n   * progress monitoring appropriately.  The input step is counted\n   * as one pass.\n   */\n  if (cinfo->progress != NULL && ! cinfo->buffered_image &&\n      cinfo->inputctl->has_multiple_scans) {\n    int nscans;\n    /* Estimate number of scans to set pass_limit. */\n    if (cinfo->progressive_mode) {\n      /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */\n      nscans = 2 + 3 * cinfo->num_components;\n    } else {\n      /* For a nonprogressive multiscan file, estimate 1 scan per component. */\n      nscans = cinfo->num_components;\n    }\n    cinfo->progress->pass_counter = 0L;\n    cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans;\n    cinfo->progress->completed_passes = 0;\n    cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2);\n    /* Count the input pass as done */\n    master->pass_number++;\n  }\n#endif /* D_MULTISCAN_FILES_SUPPORTED */\n}\n\n\n/*\n * Per-pass setup.\n * This is called at the beginning of each output pass.  We determine which\n * modules will be active during this pass and give them appropriate\n * start_pass calls.  We also set is_dummy_pass to indicate whether this\n * is a \"real\" output pass or a dummy pass for color quantization.\n * (In the latter case, jdapi.c will crank the pass to completion.)\n */\n\nMETHODDEF void\nprepare_for_output_pass (j_decompress_ptr cinfo)\n{\n  my_master_ptr master = (my_master_ptr) cinfo->master;\n\n  if (master->pub.is_dummy_pass) {\n#ifdef QUANT_2PASS_SUPPORTED\n    /* Final pass of 2-pass quantization */\n    master->pub.is_dummy_pass = FALSE;\n    (*cinfo->cquantize->start_pass) (cinfo, FALSE);\n    (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST);\n    (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST);\n#else\n    ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif /* QUANT_2PASS_SUPPORTED */\n  } else {\n    if (cinfo->quantize_colors && cinfo->colormap == NULL) {\n      /* Select new quantization method */\n      if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) {\n\tcinfo->cquantize = master->quantizer_2pass;\n\tmaster->pub.is_dummy_pass = TRUE;\n      } else if (cinfo->enable_1pass_quant) {\n\tcinfo->cquantize = master->quantizer_1pass;\n      } else {\n\tERREXIT(cinfo, JERR_MODE_CHANGE);\n      }\n    }\n    (*cinfo->idct->start_pass) (cinfo);\n    (*cinfo->coef->start_output_pass) (cinfo);\n    if (! cinfo->raw_data_out) {\n      if (! master->using_merged_upsample)\n\t(*cinfo->cconvert->start_pass) (cinfo);\n      (*cinfo->upsample->start_pass) (cinfo);\n      if (cinfo->quantize_colors)\n\t(*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass);\n      (*cinfo->post->start_pass) (cinfo,\n\t    (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));\n      (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);\n    }\n  }\n\n  /* Set up progress monitor's pass info if present */\n  if (cinfo->progress != NULL) {\n    cinfo->progress->completed_passes = master->pass_number;\n    cinfo->progress->total_passes = master->pass_number +\n\t\t\t\t    (master->pub.is_dummy_pass ? 2 : 1);\n    /* In buffered-image mode, we assume one more output pass if EOI not\n     * yet reached, but no more passes if EOI has been reached.\n     */\n    if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) {\n      cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1);\n    }\n  }\n}\n\n\n/*\n * Finish up at end of an output pass.\n */\n\nMETHODDEF void\nfinish_output_pass (j_decompress_ptr cinfo)\n{\n  my_master_ptr master = (my_master_ptr) cinfo->master;\n\n  if (cinfo->quantize_colors)\n    (*cinfo->cquantize->finish_pass) (cinfo);\n  master->pass_number++;\n}\n\n\n#ifdef D_MULTISCAN_FILES_SUPPORTED\n\n/*\n * Switch to a new external colormap between output passes.\n */\n\nGLOBAL void\njpeg_new_colormap (j_decompress_ptr cinfo)\n{\n  my_master_ptr master = (my_master_ptr) cinfo->master;\n\n  /* Prevent application from calling me at wrong times */\n  if (cinfo->global_state != DSTATE_BUFIMAGE)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n\n  if (cinfo->quantize_colors && cinfo->enable_external_quant &&\n      cinfo->colormap != NULL) {\n    /* Select 2-pass quantizer for external colormap use */\n    cinfo->cquantize = master->quantizer_2pass;\n    /* Notify quantizer of colormap change */\n    (*cinfo->cquantize->new_color_map) (cinfo);\n    master->pub.is_dummy_pass = FALSE; /* just in case */\n  } else\n    ERREXIT(cinfo, JERR_MODE_CHANGE);\n}\n\n#endif /* D_MULTISCAN_FILES_SUPPORTED */\n\n\n/*\n * Initialize master decompression control and select active modules.\n * This is performed at the start of jpeg_start_decompress.\n */\n\nGLOBAL void\njinit_master_decompress (j_decompress_ptr cinfo)\n{\n  my_master_ptr master;\n\n  master = (my_master_ptr)\n      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\t  SIZEOF(my_decomp_master));\n  cinfo->master = (struct jpeg_decomp_master *) master;\n  master->pub.prepare_for_output_pass = prepare_for_output_pass;\n  master->pub.finish_output_pass = finish_output_pass;\n\n  master->pub.is_dummy_pass = FALSE;\n\n  master_selection(cinfo);\n}\n"
  },
  {
    "path": "libs/jpeg6/jdpostct.cpp",
    "content": "/*\n * jdpostct.c\n *\n * Copyright (C) 1994-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains the decompression postprocessing controller.\n * This controller manages the upsampling, color conversion, and color\n * quantization/reduction steps; specifically, it controls the buffering\n * between upsample/color conversion and color quantization/reduction.\n *\n * If no color quantization/reduction is required, then this module has no\n * work to do, and it just hands off to the upsample/color conversion code.\n * An integrated upsample/convert/quantize process would replace this module\n * entirely.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/* Private buffer controller object */\n\ntypedef struct {\n  struct jpeg_d_post_controller pub; /* public fields */\n\n  /* Color quantization source buffer: this holds output data from\n   * the upsample/color conversion step to be passed to the quantizer.\n   * For two-pass color quantization, we need a full-image buffer;\n   * for one-pass operation, a strip buffer is sufficient.\n   */\n  jvirt_sarray_ptr whole_image;\t/* virtual array, or NULL if one-pass */\n  JSAMPARRAY buffer;\t\t/* strip buffer, or current strip of virtual */\n  JDIMENSION strip_height;\t/* buffer size in rows */\n  /* for two-pass mode only: */\n  JDIMENSION starting_row;\t/* row # of first row in current strip */\n  JDIMENSION next_row;\t\t/* index of next row to fill/empty in strip */\n} my_post_controller;\n\ntypedef my_post_controller * my_post_ptr;\n\n\n/* Forward declarations */\nMETHODDEF void post_process_1pass\n\tJPP((j_decompress_ptr cinfo,\n\t     JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,\n\t     JDIMENSION in_row_groups_avail,\n\t     JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t     JDIMENSION out_rows_avail));\n#ifdef QUANT_2PASS_SUPPORTED\nMETHODDEF void post_process_prepass\n\tJPP((j_decompress_ptr cinfo,\n\t     JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,\n\t     JDIMENSION in_row_groups_avail,\n\t     JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t     JDIMENSION out_rows_avail));\nMETHODDEF void post_process_2pass\n\tJPP((j_decompress_ptr cinfo,\n\t     JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,\n\t     JDIMENSION in_row_groups_avail,\n\t     JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t     JDIMENSION out_rows_avail));\n#endif\n\n\n/*\n * Initialize for a processing pass.\n */\n\nMETHODDEF void\nstart_pass_dpost (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)\n{\n  my_post_ptr post = (my_post_ptr) cinfo->post;\n\n  switch (pass_mode) {\n  case JBUF_PASS_THRU:\n    if (cinfo->quantize_colors) {\n      /* Single-pass processing with color quantization. */\n      post->pub.post_process_data = post_process_1pass;\n      /* We could be doing buffered-image output before starting a 2-pass\n       * color quantization; in that case, jinit_d_post_controller did not\n       * allocate a strip buffer.  Use the virtual-array buffer as workspace.\n       */\n      if (post->buffer == NULL) {\n\tpost->buffer = (*cinfo->mem->access_virt_sarray)\n\t  ((j_common_ptr) cinfo, post->whole_image,\n\t   (JDIMENSION) 0, post->strip_height, TRUE);\n      }\n    } else {\n      /* For single-pass processing without color quantization,\n       * I have no work to do; just call the upsampler directly.\n       */\n      post->pub.post_process_data = cinfo->upsample->upsample;\n    }\n    break;\n#ifdef QUANT_2PASS_SUPPORTED\n  case JBUF_SAVE_AND_PASS:\n    /* First pass of 2-pass quantization */\n    if (post->whole_image == NULL)\n      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n    post->pub.post_process_data = post_process_prepass;\n    break;\n  case JBUF_CRANK_DEST:\n    /* Second pass of 2-pass quantization */\n    if (post->whole_image == NULL)\n      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n    post->pub.post_process_data = post_process_2pass;\n    break;\n#endif /* QUANT_2PASS_SUPPORTED */\n  default:\n    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n    break;\n  }\n  post->starting_row = post->next_row = 0;\n}\n\n\n/*\n * Process some data in the one-pass (strip buffer) case.\n * This is used for color precision reduction as well as one-pass quantization.\n */\n\nMETHODDEF void\npost_process_1pass (j_decompress_ptr cinfo,\n\t\t    JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,\n\t\t    JDIMENSION in_row_groups_avail,\n\t\t    JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t\t    JDIMENSION out_rows_avail)\n{\n  my_post_ptr post = (my_post_ptr) cinfo->post;\n  JDIMENSION num_rows, max_rows;\n\n  /* Fill the buffer, but not more than what we can dump out in one go. */\n  /* Note we rely on the upsampler to detect bottom of image. */\n  max_rows = out_rows_avail - *out_row_ctr;\n  if (max_rows > post->strip_height)\n    max_rows = post->strip_height;\n  num_rows = 0;\n  (*cinfo->upsample->upsample) (cinfo,\n\t\tinput_buf, in_row_group_ctr, in_row_groups_avail,\n\t\tpost->buffer, &num_rows, max_rows);\n  /* Quantize and emit data. */\n  (*cinfo->cquantize->color_quantize) (cinfo,\n\t\tpost->buffer, output_buf + *out_row_ctr, (int) num_rows);\n  *out_row_ctr += num_rows;\n}\n\n\n#ifdef QUANT_2PASS_SUPPORTED\n\n/*\n * Process some data in the first pass of 2-pass quantization.\n */\n\nMETHODDEF void\npost_process_prepass (j_decompress_ptr cinfo,\n\t\t      JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,\n\t\t      JDIMENSION in_row_groups_avail,\n\t\t      JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t\t      JDIMENSION out_rows_avail)\n{\n  my_post_ptr post = (my_post_ptr) cinfo->post;\n  JDIMENSION old_next_row, num_rows;\n\n  /* Reposition virtual buffer if at start of strip. */\n  if (post->next_row == 0) {\n    post->buffer = (*cinfo->mem->access_virt_sarray)\n\t((j_common_ptr) cinfo, post->whole_image,\n\t post->starting_row, post->strip_height, TRUE);\n  }\n\n  /* Upsample some data (up to a strip height's worth). */\n  old_next_row = post->next_row;\n  (*cinfo->upsample->upsample) (cinfo,\n\t\tinput_buf, in_row_group_ctr, in_row_groups_avail,\n\t\tpost->buffer, &post->next_row, post->strip_height);\n\n  /* Allow quantizer to scan new data.  No data is emitted, */\n  /* but we advance out_row_ctr so outer loop can tell when we're done. */\n  if (post->next_row > old_next_row) {\n    num_rows = post->next_row - old_next_row;\n    (*cinfo->cquantize->color_quantize) (cinfo, post->buffer + old_next_row,\n\t\t\t\t\t (JSAMPARRAY) NULL, (int) num_rows);\n    *out_row_ctr += num_rows;\n  }\n\n  /* Advance if we filled the strip. */\n  if (post->next_row >= post->strip_height) {\n    post->starting_row += post->strip_height;\n    post->next_row = 0;\n  }\n}\n\n\n/*\n * Process some data in the second pass of 2-pass quantization.\n */\n\nMETHODDEF void\npost_process_2pass (j_decompress_ptr cinfo,\n\t\t    JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,\n\t\t    JDIMENSION in_row_groups_avail,\n\t\t    JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t\t    JDIMENSION out_rows_avail)\n{\n  my_post_ptr post = (my_post_ptr) cinfo->post;\n  JDIMENSION num_rows, max_rows;\n\n  /* Reposition virtual buffer if at start of strip. */\n  if (post->next_row == 0) {\n    post->buffer = (*cinfo->mem->access_virt_sarray)\n\t((j_common_ptr) cinfo, post->whole_image,\n\t post->starting_row, post->strip_height, FALSE);\n  }\n\n  /* Determine number of rows to emit. */\n  num_rows = post->strip_height - post->next_row; /* available in strip */\n  max_rows = out_rows_avail - *out_row_ctr; /* available in output area */\n  if (num_rows > max_rows)\n    num_rows = max_rows;\n  /* We have to check bottom of image here, can't depend on upsampler. */\n  max_rows = cinfo->output_height - post->starting_row;\n  if (num_rows > max_rows)\n    num_rows = max_rows;\n\n  /* Quantize and emit data. */\n  (*cinfo->cquantize->color_quantize) (cinfo,\n\t\tpost->buffer + post->next_row, output_buf + *out_row_ctr,\n\t\t(int) num_rows);\n  *out_row_ctr += num_rows;\n\n  /* Advance if we filled the strip. */\n  post->next_row += num_rows;\n  if (post->next_row >= post->strip_height) {\n    post->starting_row += post->strip_height;\n    post->next_row = 0;\n  }\n}\n\n#endif /* QUANT_2PASS_SUPPORTED */\n\n\n/*\n * Initialize postprocessing controller.\n */\n\nGLOBAL void\njinit_d_post_controller (j_decompress_ptr cinfo, boolean need_full_buffer)\n{\n  my_post_ptr post;\n\n  post = (my_post_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_post_controller));\n  cinfo->post = (struct jpeg_d_post_controller *) post;\n  post->pub.start_pass = start_pass_dpost;\n  post->whole_image = NULL;\t/* flag for no virtual arrays */\n  post->buffer = NULL;\t\t/* flag for no strip buffer */\n\n  /* Create the quantization buffer, if needed */\n  if (cinfo->quantize_colors) {\n    /* The buffer strip height is max_v_samp_factor, which is typically\n     * an efficient number of rows for upsampling to return.\n     * (In the presence of output rescaling, we might want to be smarter?)\n     */\n    post->strip_height = (JDIMENSION) cinfo->max_v_samp_factor;\n    if (need_full_buffer) {\n      /* Two-pass color quantization: need full-image storage. */\n      /* We round up the number of rows to a multiple of the strip height. */\n#ifdef QUANT_2PASS_SUPPORTED\n      post->whole_image = (*cinfo->mem->request_virt_sarray)\n\t((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,\n\t cinfo->output_width * cinfo->out_color_components,\n\t (JDIMENSION) jround_up((long) cinfo->output_height,\n\t\t\t\t(long) post->strip_height),\n\t post->strip_height);\n#else\n      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\n#endif /* QUANT_2PASS_SUPPORTED */\n    } else {\n      /* One-pass color quantization: just make a strip buffer. */\n      post->buffer = (*cinfo->mem->alloc_sarray)\n\t((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t cinfo->output_width * cinfo->out_color_components,\n\t post->strip_height);\n    }\n  }\n}\n"
  },
  {
    "path": "libs/jpeg6/jdsample.cpp",
    "content": "/*\n * jdsample.c\n *\n * Copyright (C) 1991-1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains upsampling routines.\n *\n * Upsampling input data is counted in \"row groups\".  A row group\n * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size)\n * sample rows of each component.  Upsampling will normally produce\n * max_v_samp_factor pixel rows from each row group (but this could vary\n * if the upsampler is applying a scale factor of its own).\n *\n * An excellent reference for image resampling is\n *   Digital Image Warping, George Wolberg, 1990.\n *   Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/* Pointer to routine to upsample a single component */\ntypedef JMETHOD(void, upsample1_ptr,\n\t\t(j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t\t JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr));\n\n/* Private subobject */\n\ntypedef struct {\n  struct jpeg_upsampler pub;\t/* public fields */\n\n  /* Color conversion buffer.  When using separate upsampling and color\n   * conversion steps, this buffer holds one upsampled row group until it\n   * has been color converted and output.\n   * Note: we do not allocate any storage for component(s) which are full-size,\n   * ie do not need rescaling.  The corresponding entry of color_buf[] is\n   * simply set to point to the input data array, thereby avoiding copying.\n   */\n  JSAMPARRAY color_buf[MAX_COMPONENTS];\n\n  /* Per-component upsampling method pointers */\n  upsample1_ptr methods[MAX_COMPONENTS];\n\n  int next_row_out;\t\t/* counts rows emitted from color_buf */\n  JDIMENSION rows_to_go;\t/* counts rows remaining in image */\n\n  /* Height of an input row group for each component. */\n  int rowgroup_height[MAX_COMPONENTS];\n\n  /* These arrays save pixel expansion factors so that int_expand need not\n   * recompute them each time.  They are unused for other upsampling methods.\n   */\n  UINT8 h_expand[MAX_COMPONENTS];\n  UINT8 v_expand[MAX_COMPONENTS];\n} my_upsampler;\n\ntypedef my_upsampler * my_upsample_ptr;\n\n\n/*\n * Initialize for an upsampling pass.\n */\n\nMETHODDEF void\nstart_pass_upsample (j_decompress_ptr cinfo)\n{\n  my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;\n\n  /* Mark the conversion buffer empty */\n  upsample->next_row_out = cinfo->max_v_samp_factor;\n  /* Initialize total-height counter for detecting bottom of image */\n  upsample->rows_to_go = cinfo->output_height;\n}\n\n\n/*\n * Control routine to do upsampling (and color conversion).\n *\n * In this version we upsample each component independently.\n * We upsample one row group into the conversion buffer, then apply\n * color conversion a row at a time.\n */\n\nMETHODDEF void\nsep_upsample (j_decompress_ptr cinfo,\n\t      JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,\n\t      JDIMENSION in_row_groups_avail,\n\t      JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t      JDIMENSION out_rows_avail)\n{\n  my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;\n  int ci;\n  jpeg_component_info * compptr;\n  JDIMENSION num_rows;\n\n  /* Fill the conversion buffer, if it's empty */\n  if (upsample->next_row_out >= cinfo->max_v_samp_factor) {\n    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n\t ci++, compptr++) {\n      /* Invoke per-component upsample method.  Notice we pass a POINTER\n       * to color_buf[ci], so that fullsize_upsample can change it.\n       */\n      (*upsample->methods[ci]) (cinfo, compptr,\n\tinput_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]),\n\tupsample->color_buf + ci);\n    }\n    upsample->next_row_out = 0;\n  }\n\n  /* Color-convert and emit rows */\n\n  /* How many we have in the buffer: */\n  num_rows = (JDIMENSION) (cinfo->max_v_samp_factor - upsample->next_row_out);\n  /* Not more than the distance to the end of the image.  Need this test\n   * in case the image height is not a multiple of max_v_samp_factor:\n   */\n  if (num_rows > upsample->rows_to_go) \n    num_rows = upsample->rows_to_go;\n  /* And not more than what the client can accept: */\n  out_rows_avail -= *out_row_ctr;\n  if (num_rows > out_rows_avail)\n    num_rows = out_rows_avail;\n\n  (*cinfo->cconvert->color_convert) (cinfo, upsample->color_buf,\n\t\t\t\t     (JDIMENSION) upsample->next_row_out,\n\t\t\t\t     output_buf + *out_row_ctr,\n\t\t\t\t     (int) num_rows);\n\n  /* Adjust counts */\n  *out_row_ctr += num_rows;\n  upsample->rows_to_go -= num_rows;\n  upsample->next_row_out += num_rows;\n  /* When the buffer is emptied, declare this input row group consumed */\n  if (upsample->next_row_out >= cinfo->max_v_samp_factor)\n    (*in_row_group_ctr)++;\n}\n\n\n/*\n * These are the routines invoked by sep_upsample to upsample pixel values\n * of a single component.  One row group is processed per call.\n */\n\n\n/*\n * For full-size components, we just make color_buf[ci] point at the\n * input buffer, and thus avoid copying any data.  Note that this is\n * safe only because sep_upsample doesn't declare the input row group\n * \"consumed\" until we are done color converting and emitting it.\n */\n\nMETHODDEF void\nfullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t\t   JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)\n{\n  *output_data_ptr = input_data;\n}\n\n\n/*\n * This is a no-op version used for \"uninteresting\" components.\n * These components will not be referenced by color conversion.\n */\n\nMETHODDEF void\nnoop_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t       JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)\n{\n  *output_data_ptr = NULL;\t/* safety check */\n}\n\n\n/*\n * This version handles any integral sampling ratios.\n * This is not used for typical JPEG files, so it need not be fast.\n * Nor, for that matter, is it particularly accurate: the algorithm is\n * simple replication of the input pixel onto the corresponding output\n * pixels.  The hi-falutin sampling literature refers to this as a\n * \"box filter\".  A box filter tends to introduce visible artifacts,\n * so if you are actually going to use 3:1 or 4:1 sampling ratios\n * you would be well advised to improve this code.\n */\n\nMETHODDEF void\nint_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t      JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)\n{\n  my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;\n  JSAMPARRAY output_data = *output_data_ptr;\n  register JSAMPROW inptr, outptr;\n  register JSAMPLE invalue;\n  register int h;\n  JSAMPROW outend;\n  int h_expand, v_expand;\n  int inrow, outrow;\n\n  h_expand = upsample->h_expand[compptr->component_index];\n  v_expand = upsample->v_expand[compptr->component_index];\n\n  inrow = outrow = 0;\n  while (outrow < cinfo->max_v_samp_factor) {\n    /* Generate one output row with proper horizontal expansion */\n    inptr = input_data[inrow];\n    outptr = output_data[outrow];\n    outend = outptr + cinfo->output_width;\n    while (outptr < outend) {\n      invalue = *inptr++;\t/* don't need GETJSAMPLE() here */\n      for (h = h_expand; h > 0; h--) {\n\t*outptr++ = invalue;\n      }\n    }\n    /* Generate any additional output rows by duplicating the first one */\n    if (v_expand > 1) {\n      jcopy_sample_rows(output_data, outrow, output_data, outrow+1,\n\t\t\tv_expand-1, cinfo->output_width);\n    }\n    inrow++;\n    outrow += v_expand;\n  }\n}\n\n\n/*\n * Fast processing for the common case of 2:1 horizontal and 1:1 vertical.\n * It's still a box filter.\n */\n\nMETHODDEF void\nh2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t       JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)\n{\n  JSAMPARRAY output_data = *output_data_ptr;\n  register JSAMPROW inptr, outptr;\n  register JSAMPLE invalue;\n  JSAMPROW outend;\n  int inrow;\n\n  for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) {\n    inptr = input_data[inrow];\n    outptr = output_data[inrow];\n    outend = outptr + cinfo->output_width;\n    while (outptr < outend) {\n      invalue = *inptr++;\t/* don't need GETJSAMPLE() here */\n      *outptr++ = invalue;\n      *outptr++ = invalue;\n    }\n  }\n}\n\n\n/*\n * Fast processing for the common case of 2:1 horizontal and 2:1 vertical.\n * It's still a box filter.\n */\n\nMETHODDEF void\nh2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t       JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)\n{\n  JSAMPARRAY output_data = *output_data_ptr;\n  register JSAMPROW inptr, outptr;\n  register JSAMPLE invalue;\n  JSAMPROW outend;\n  int inrow, outrow;\n\n  inrow = outrow = 0;\n  while (outrow < cinfo->max_v_samp_factor) {\n    inptr = input_data[inrow];\n    outptr = output_data[outrow];\n    outend = outptr + cinfo->output_width;\n    while (outptr < outend) {\n      invalue = *inptr++;\t/* don't need GETJSAMPLE() here */\n      *outptr++ = invalue;\n      *outptr++ = invalue;\n    }\n    jcopy_sample_rows(output_data, outrow, output_data, outrow+1,\n\t\t      1, cinfo->output_width);\n    inrow++;\n    outrow += 2;\n  }\n}\n\n\n/*\n * Fancy processing for the common case of 2:1 horizontal and 1:1 vertical.\n *\n * The upsampling algorithm is linear interpolation between pixel centers,\n * also known as a \"triangle filter\".  This is a good compromise between\n * speed and visual quality.  The centers of the output pixels are 1/4 and 3/4\n * of the way between input pixel centers.\n *\n * A note about the \"bias\" calculations: when rounding fractional values to\n * integer, we do not want to always round 0.5 up to the next integer.\n * If we did that, we'd introduce a noticeable bias towards larger values.\n * Instead, this code is arranged so that 0.5 will be rounded up or down at\n * alternate pixel locations (a simple ordered dither pattern).\n */\n\nMETHODDEF void\nh2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t\t     JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)\n{\n  JSAMPARRAY output_data = *output_data_ptr;\n  register JSAMPROW inptr, outptr;\n  register int invalue;\n  register JDIMENSION colctr;\n  int inrow;\n\n  for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) {\n    inptr = input_data[inrow];\n    outptr = output_data[inrow];\n    /* Special case for first column */\n    invalue = GETJSAMPLE(*inptr++);\n    *outptr++ = (JSAMPLE) invalue;\n    *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(*inptr) + 2) >> 2);\n\n    for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) {\n      /* General case: 3/4 * nearer pixel + 1/4 * further pixel */\n      invalue = GETJSAMPLE(*inptr++) * 3;\n      *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(inptr[-2]) + 1) >> 2);\n      *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(*inptr) + 2) >> 2);\n    }\n\n    /* Special case for last column */\n    invalue = GETJSAMPLE(*inptr);\n    *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(inptr[-1]) + 1) >> 2);\n    *outptr++ = (JSAMPLE) invalue;\n  }\n}\n\n\n/*\n * Fancy processing for the common case of 2:1 horizontal and 2:1 vertical.\n * Again a triangle filter; see comments for h2v1 case, above.\n *\n * It is OK for us to reference the adjacent input rows because we demanded\n * context from the main buffer controller (see initialization code).\n */\n\nMETHODDEF void\nh2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t\t     JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)\n{\n  JSAMPARRAY output_data = *output_data_ptr;\n  register JSAMPROW inptr0, inptr1, outptr;\n#if BITS_IN_JSAMPLE == 8\n  register int thiscolsum, lastcolsum, nextcolsum;\n#else\n  register INT32 thiscolsum, lastcolsum, nextcolsum;\n#endif\n  register JDIMENSION colctr;\n  int inrow, outrow, v;\n\n  inrow = outrow = 0;\n  while (outrow < cinfo->max_v_samp_factor) {\n    for (v = 0; v < 2; v++) {\n      /* inptr0 points to nearest input row, inptr1 points to next nearest */\n      inptr0 = input_data[inrow];\n      if (v == 0)\t\t/* next nearest is row above */\n\tinptr1 = input_data[inrow-1];\n      else\t\t\t/* next nearest is row below */\n\tinptr1 = input_data[inrow+1];\n      outptr = output_data[outrow++];\n\n      /* Special case for first column */\n      thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);\n      nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);\n      *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 8) >> 4);\n      *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4);\n      lastcolsum = thiscolsum; thiscolsum = nextcolsum;\n\n      for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) {\n\t/* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */\n\t/* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */\n\tnextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);\n\t*outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4);\n\t*outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4);\n\tlastcolsum = thiscolsum; thiscolsum = nextcolsum;\n      }\n\n      /* Special case for last column */\n      *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4);\n      *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 7) >> 4);\n    }\n    inrow++;\n  }\n}\n\n\n/*\n * Module initialization routine for upsampling.\n */\n\nGLOBAL void\njinit_upsampler (j_decompress_ptr cinfo)\n{\n  my_upsample_ptr upsample;\n  int ci;\n  jpeg_component_info * compptr;\n  boolean need_buffer, do_fancy;\n  int h_in_group, v_in_group, h_out_group, v_out_group;\n\n  upsample = (my_upsample_ptr)\n    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_upsampler));\n  cinfo->upsample = (struct jpeg_upsampler *) upsample;\n  upsample->pub.start_pass = start_pass_upsample;\n  upsample->pub.upsample = sep_upsample;\n  upsample->pub.need_context_rows = FALSE; /* until we find out differently */\n\n  if (cinfo->CCIR601_sampling)\t/* this isn't supported */\n    ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);\n\n  /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1,\n   * so don't ask for it.\n   */\n  do_fancy = cinfo->do_fancy_upsampling && cinfo->min_DCT_scaled_size > 1;\n\n  /* Verify we can handle the sampling factors, select per-component methods,\n   * and create storage as needed.\n   */\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    /* Compute size of an \"input group\" after IDCT scaling.  This many samples\n     * are to be converted to max_h_samp_factor * max_v_samp_factor pixels.\n     */\n    h_in_group = (compptr->h_samp_factor * compptr->DCT_scaled_size) /\n\t\t cinfo->min_DCT_scaled_size;\n    v_in_group = (compptr->v_samp_factor * compptr->DCT_scaled_size) /\n\t\t cinfo->min_DCT_scaled_size;\n    h_out_group = cinfo->max_h_samp_factor;\n    v_out_group = cinfo->max_v_samp_factor;\n    upsample->rowgroup_height[ci] = v_in_group; /* save for use later */\n    need_buffer = TRUE;\n    if (! compptr->component_needed) {\n      /* Don't bother to upsample an uninteresting component. */\n      upsample->methods[ci] = noop_upsample;\n      need_buffer = FALSE;\n    } else if (h_in_group == h_out_group && v_in_group == v_out_group) {\n      /* Fullsize components can be processed without any work. */\n      upsample->methods[ci] = fullsize_upsample;\n      need_buffer = FALSE;\n    } else if (h_in_group * 2 == h_out_group &&\n\t       v_in_group == v_out_group) {\n      /* Special cases for 2h1v upsampling */\n      if (do_fancy && compptr->downsampled_width > 2)\n\tupsample->methods[ci] = h2v1_fancy_upsample;\n      else\n\tupsample->methods[ci] = h2v1_upsample;\n    } else if (h_in_group * 2 == h_out_group &&\n\t       v_in_group * 2 == v_out_group) {\n      /* Special cases for 2h2v upsampling */\n      if (do_fancy && compptr->downsampled_width > 2) {\n\tupsample->methods[ci] = h2v2_fancy_upsample;\n\tupsample->pub.need_context_rows = TRUE;\n      } else\n\tupsample->methods[ci] = h2v2_upsample;\n    } else if ((h_out_group % h_in_group) == 0 &&\n\t       (v_out_group % v_in_group) == 0) {\n      /* Generic integral-factors upsampling method */\n      upsample->methods[ci] = int_upsample;\n      upsample->h_expand[ci] = (UINT8) (h_out_group / h_in_group);\n      upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group);\n    } else\n      ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);\n    if (need_buffer) {\n      upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray)\n\t((j_common_ptr) cinfo, JPOOL_IMAGE,\n\t (JDIMENSION) jround_up((long) cinfo->output_width,\n\t\t\t\t(long) cinfo->max_h_samp_factor),\n\t (JDIMENSION) cinfo->max_v_samp_factor);\n    }\n  }\n}\n"
  },
  {
    "path": "libs/jpeg6/jdtrans.cpp",
    "content": "/*\n * jdtrans.c\n *\n * Copyright (C) 1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains library routines for transcoding decompression,\n * that is, reading raw DCT coefficient arrays from an input JPEG file.\n * The routines in jdapimin.c will also be needed by a transcoder.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/* Forward declarations */\nLOCAL void transdecode_master_selection JPP((j_decompress_ptr cinfo));\n\n\n/*\n * Read the coefficient arrays from a JPEG file.\n * jpeg_read_header must be completed before calling this.\n *\n * The entire image is read into a set of virtual coefficient-block arrays,\n * one per component.  The return value is a pointer to the array of\n * virtual-array descriptors.  These can be manipulated directly via the\n * JPEG memory manager, or handed off to jpeg_write_coefficients().\n * To release the memory occupied by the virtual arrays, call\n * jpeg_finish_decompress() when done with the data.\n *\n * Returns NULL if suspended.  This case need be checked only if\n * a suspending data source is used.\n */\n\nGLOBAL jvirt_barray_ptr *\njpeg_read_coefficients (j_decompress_ptr cinfo)\n{\n  if (cinfo->global_state == DSTATE_READY) {\n    /* First call: initialize active modules */\n    transdecode_master_selection(cinfo);\n    cinfo->global_state = DSTATE_RDCOEFS;\n  } else if (cinfo->global_state != DSTATE_RDCOEFS)\n    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\n  /* Absorb whole file into the coef buffer */\n  for (;;) {\n    int retcode;\n    /* Call progress monitor hook if present */\n    if (cinfo->progress != NULL)\n      (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);\n    /* Absorb some more input */\n    retcode = (*cinfo->inputctl->consume_input) (cinfo);\n    if (retcode == JPEG_SUSPENDED)\n      return NULL;\n    if (retcode == JPEG_REACHED_EOI)\n      break;\n    /* Advance progress counter if appropriate */\n    if (cinfo->progress != NULL &&\n\t(retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {\n      if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {\n\t/* startup underestimated number of scans; ratchet up one scan */\n\tcinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;\n      }\n    }\n  }\n  /* Set state so that jpeg_finish_decompress does the right thing */\n  cinfo->global_state = DSTATE_STOPPING;\n  return cinfo->coef->coef_arrays;\n}\n\n\n/*\n * Master selection of decompression modules for transcoding.\n * This substitutes for jdmaster.c's initialization of the full decompressor.\n */\n\nLOCAL void\ntransdecode_master_selection (j_decompress_ptr cinfo)\n{\n  /* Entropy decoding: either Huffman or arithmetic coding. */\n  if (cinfo->arith_code) {\n    ERREXIT(cinfo, JERR_ARITH_NOTIMPL);\n  } else {\n    if (cinfo->progressive_mode) {\n#ifdef D_PROGRESSIVE_SUPPORTED\n      jinit_phuff_decoder(cinfo);\n#else\n      ERREXIT(cinfo, JERR_NOT_COMPILED);\n#endif\n    } else\n      jinit_huff_decoder(cinfo);\n  }\n\n  /* Always get a full-image coefficient buffer. */\n  jinit_d_coef_controller(cinfo, TRUE);\n\n  /* We can now tell the memory manager to allocate virtual arrays. */\n  (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);\n\n  /* Initialize input side of decompressor to consume first scan. */\n  (*cinfo->inputctl->start_input_pass) (cinfo);\n\n  /* Initialize progress monitoring. */\n  if (cinfo->progress != NULL) {\n    int nscans;\n    /* Estimate number of scans to set pass_limit. */\n    if (cinfo->progressive_mode) {\n      /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */\n      nscans = 2 + 3 * cinfo->num_components;\n    } else if (cinfo->inputctl->has_multiple_scans) {\n      /* For a nonprogressive multiscan file, estimate 1 scan per component. */\n      nscans = cinfo->num_components;\n    } else {\n      nscans = 1;\n    }\n    cinfo->progress->pass_counter = 0L;\n    cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans;\n    cinfo->progress->completed_passes = 0;\n    cinfo->progress->total_passes = 1;\n  }\n}\n"
  },
  {
    "path": "libs/jpeg6/jerror.cpp",
    "content": "/*\n * jerror.c\n *\n * Copyright (C) 1991-1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains simple error-reporting and trace-message routines.\n * These are suitable for Unix-like systems and others where writing to\n * stderr is the right thing to do.  Many applications will want to replace\n * some or all of these routines.\n *\n * These routines are used by both the compression and decompression code.\n */\n\n/* this is not a core library module, so it doesn't define JPEG_INTERNALS */\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jversion.h\"\n#include \"jerror.h\"\n\n#ifndef EXIT_FAILURE\t\t/* define exit() codes if not provided */\n#define EXIT_FAILURE  1\n#endif\n\n\n/*\n * Create the message string table.\n * We do this from the master message list in jerror.h by re-reading\n * jerror.h with a suitable definition for macro JMESSAGE.\n * The message table is made an external symbol just in case any applications\n * want to refer to it directly.\n */\n\n#ifdef NEED_SHORT_EXTERNAL_NAMES\n#define jpeg_std_message_table\tjMsgTable\n#endif\n\n#define JMESSAGE(code,string)\tstring ,\n\nconst char * const jpeg_std_message_table[] = {\n#include \"jerror.h\"\n  NULL\n};\n\n\n/*\n * Error exit handler: must not return to caller.\n *\n * Applications may override this if they want to get control back after\n * an error.  Typically one would longjmp somewhere instead of exiting.\n * The setjmp buffer can be made a private field within an expanded error\n * handler object.  Note that the info needed to generate an error message\n * is stored in the error object, so you can generate the message now or\n * later, at your convenience.\n * You should make sure that the JPEG object is cleaned up (with jpeg_abort\n * or jpeg_destroy) at some point.\n */\n\nMETHODDEF void\nerror_exit (j_common_ptr cinfo)\n{\n  char buffer[JMSG_LENGTH_MAX];\n\n  /* Create the message */\n  (*cinfo->err->format_message) (cinfo, buffer);\n\n  /* Let the memory manager delete any temp files before we die */\n  jpeg_destroy(cinfo);\n\n  // FIXME: need to get this setup with an error handler\n  //Error(\"%s\\n\", buffer );\n}\n\n\n/*\n * Actual output of an error or trace message.\n * Applications may override this method to send JPEG messages somewhere\n * other than stderr.\n */\n\nMETHODDEF void\noutput_message (j_common_ptr cinfo)\n{\n  char buffer[JMSG_LENGTH_MAX];\n\n  /* Create the message */\n  (*cinfo->err->format_message) (cinfo, buffer);\n\n  /* Send it to stderr, adding a newline */\n  printf(\"%s\\n\", buffer);\n}\n\n\n/*\n * Decide whether to emit a trace or warning message.\n * msg_level is one of:\n *   -1: recoverable corrupt-data warning, may want to abort.\n *    0: important advisory messages (always display to user).\n *    1: first level of tracing detail.\n *    2,3,...: successively more detailed tracing messages.\n * An application might override this method if it wanted to abort on warnings\n * or change the policy about which messages to display.\n */\n\nMETHODDEF void\nemit_message (j_common_ptr cinfo, int msg_level)\n{\n  struct jpeg_error_mgr * err = cinfo->err;\n\n  if (msg_level < 0) {\n    /* It's a warning message.  Since corrupt files may generate many warnings,\n     * the policy implemented here is to show only the first warning,\n     * unless trace_level >= 3.\n     */\n    if (err->num_warnings == 0 || err->trace_level >= 3)\n      (*err->output_message) (cinfo);\n    /* Always count warnings in num_warnings. */\n    err->num_warnings++;\n  } else {\n    /* It's a trace message.  Show it if trace_level >= msg_level. */\n    if (err->trace_level >= msg_level)\n      (*err->output_message) (cinfo);\n  }\n}\n\n\n/*\n * Format a message string for the most recent JPEG error or message.\n * The message is stored into buffer, which should be at least JMSG_LENGTH_MAX\n * characters.  Note that no '\\n' character is added to the string.\n * Few applications should need to override this method.\n */\n\nMETHODDEF void\nformat_message (j_common_ptr cinfo, char * buffer)\n{\n  struct jpeg_error_mgr * err = cinfo->err;\n  int msg_code = err->msg_code;\n  const char * msgtext = NULL;\n  const char * msgptr;\n  char ch;\n  boolean isstring;\n\n  /* Look up message string in proper table */\n  if (msg_code > 0 && msg_code <= err->last_jpeg_message) {\n    msgtext = err->jpeg_message_table[msg_code];\n  } else if (err->addon_message_table != NULL &&\n\t     msg_code >= err->first_addon_message &&\n\t     msg_code <= err->last_addon_message) {\n    msgtext = err->addon_message_table[msg_code - err->first_addon_message];\n  }\n\n  /* Defend against bogus message number */\n  if (msgtext == NULL) {\n    err->msg_parm.i[0] = msg_code;\n    msgtext = err->jpeg_message_table[0];\n  }\n\n  /* Check for string parameter, as indicated by %s in the message text */\n  isstring = FALSE;\n  msgptr = msgtext;\n  while ((ch = *msgptr++) != '\\0') {\n    if (ch == '%') {\n      if (*msgptr == 's') isstring = TRUE;\n      break;\n    }\n  }\n\n  /* Format the message into the passed buffer */\n  if (isstring)\n    sprintf(buffer, msgtext, err->msg_parm.s);\n  else\n    sprintf(buffer, msgtext,\n\t    err->msg_parm.i[0], err->msg_parm.i[1],\n\t    err->msg_parm.i[2], err->msg_parm.i[3],\n\t    err->msg_parm.i[4], err->msg_parm.i[5],\n\t    err->msg_parm.i[6], err->msg_parm.i[7]);\n}\n\n\n/*\n * Reset error state variables at start of a new image.\n * This is called during compression startup to reset trace/error\n * processing to default state, without losing any application-specific\n * method pointers.  An application might possibly want to override\n * this method if it has additional error processing state.\n */\n\nMETHODDEF void\nreset_error_mgr (j_common_ptr cinfo)\n{\n  cinfo->err->num_warnings = 0;\n  /* trace_level is not reset since it is an application-supplied parameter */\n  cinfo->err->msg_code = 0;\t/* may be useful as a flag for \"no error\" */\n}\n\n\n/*\n * Fill in the standard error-handling methods in a jpeg_error_mgr object.\n * Typical call is:\n *\tstruct jpeg_compress_struct cinfo;\n *\tstruct jpeg_error_mgr err;\n *\n *\tcinfo.err = jpeg_std_error(&err);\n * after which the application may override some of the methods.\n */\n\nGLOBAL struct jpeg_error_mgr *\njpeg_std_error (struct jpeg_error_mgr * err)\n{\n  err->error_exit = error_exit;\n  err->emit_message = emit_message;\n  err->output_message = output_message;\n  err->format_message = format_message;\n  err->reset_error_mgr = reset_error_mgr;\n\n  err->trace_level = 0;\t\t/* default = no tracing */\n  err->num_warnings = 0;\t/* no warnings emitted yet */\n  err->msg_code = 0;\t\t/* may be useful as a flag for \"no error\" */\n\n  /* Initialize message table pointers */\n  err->jpeg_message_table = jpeg_std_message_table;\n  err->last_jpeg_message = (int) JMSG_LASTMSGCODE - 1;\n\n  err->addon_message_table = NULL;\n  err->first_addon_message = 0;\t/* for safety */\n  err->last_addon_message = 0;\n\n  return err;\n}\n"
  },
  {
    "path": "libs/jpeg6/jerror.h",
    "content": "/*\n * jerror.h\n *\n * Copyright (C) 1994-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file defines the error and message codes for the JPEG library.\n * Edit this file to add new codes, or to translate the message strings to\n * some other language.\n * A set of error-reporting macros are defined too.  Some applications using\n * the JPEG library may wish to include this file to get the error codes\n * and/or the macros.\n */\n\n/*\n * To define the enum list of message codes, include this file without\n * defining macro JMESSAGE.  To create a message string table, include it\n * again with a suitable JMESSAGE definition (see jerror.c for an example).\n */\n#ifndef JMESSAGE\n#ifndef JERROR_H\n/* First time through, define the enum list */\n#define JMAKE_ENUM_LIST\n#else\n/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */\n#define JMESSAGE(code,string)\n#endif /* JERROR_H */\n#endif /* JMESSAGE */\n\n#ifdef JMAKE_ENUM_LIST\n\ntypedef enum {\n\n#define JMESSAGE(code,string)\tcode ,\n\n#endif /* JMAKE_ENUM_LIST */\n\nJMESSAGE(JMSG_NOMESSAGE, \"Bogus message code %d\") /* Must be first entry! */\n\n/* For maintenance convenience, list is alphabetical by message code name */\nJMESSAGE(JERR_ARITH_NOTIMPL,\n\t \"Sorry, there are legal restrictions on arithmetic coding\")\nJMESSAGE(JERR_BAD_ALIGN_TYPE, \"ALIGN_TYPE is wrong, please fix\")\nJMESSAGE(JERR_BAD_ALLOC_CHUNK, \"MAX_ALLOC_CHUNK is wrong, please fix\")\nJMESSAGE(JERR_BAD_BUFFER_MODE, \"Bogus buffer control mode\")\nJMESSAGE(JERR_BAD_COMPONENT_ID, \"Invalid component ID %d in SOS\")\nJMESSAGE(JERR_BAD_DCTSIZE, \"IDCT output block size %d not supported\")\nJMESSAGE(JERR_BAD_IN_COLORSPACE, \"Bogus input colorspace\")\nJMESSAGE(JERR_BAD_J_COLORSPACE, \"Bogus JPEG colorspace\")\nJMESSAGE(JERR_BAD_LENGTH, \"Bogus marker length\")\nJMESSAGE(JERR_BAD_MCU_SIZE, \"Sampling factors too large for interleaved scan\")\nJMESSAGE(JERR_BAD_POOL_ID, \"Invalid memory pool code %d\")\nJMESSAGE(JERR_BAD_PRECISION, \"Unsupported JPEG data precision %d\")\nJMESSAGE(JERR_BAD_PROGRESSION,\n\t \"Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d\")\nJMESSAGE(JERR_BAD_PROG_SCRIPT,\n\t \"Invalid progressive parameters at scan script entry %d\")\nJMESSAGE(JERR_BAD_SAMPLING, \"Bogus sampling factors\")\nJMESSAGE(JERR_BAD_SCAN_SCRIPT, \"Invalid scan script at entry %d\")\nJMESSAGE(JERR_BAD_STATE, \"Improper call to JPEG library in state %d\")\nJMESSAGE(JERR_BAD_VIRTUAL_ACCESS, \"Bogus virtual array access\")\nJMESSAGE(JERR_BUFFER_SIZE, \"Buffer passed to JPEG library is too small\")\nJMESSAGE(JERR_CANT_SUSPEND, \"Suspension not allowed here\")\nJMESSAGE(JERR_CCIR601_NOTIMPL, \"CCIR601 sampling not implemented yet\")\nJMESSAGE(JERR_COMPONENT_COUNT, \"Too many color components: %d, max %d\")\nJMESSAGE(JERR_CONVERSION_NOTIMPL, \"Unsupported color conversion request\")\nJMESSAGE(JERR_DAC_INDEX, \"Bogus DAC index %d\")\nJMESSAGE(JERR_DAC_VALUE, \"Bogus DAC value 0x%x\")\nJMESSAGE(JERR_DHT_COUNTS, \"Bogus DHT counts\")\nJMESSAGE(JERR_DHT_INDEX, \"Bogus DHT index %d\")\nJMESSAGE(JERR_DQT_INDEX, \"Bogus DQT index %d\")\nJMESSAGE(JERR_EMPTY_IMAGE, \"Empty JPEG image (DNL not supported)\")\nJMESSAGE(JERR_EMS_READ, \"Read from EMS failed\")\nJMESSAGE(JERR_EMS_WRITE, \"Write to EMS failed\")\nJMESSAGE(JERR_EOI_EXPECTED, \"Didn't expect more than one scan\")\nJMESSAGE(JERR_FILE_READ, \"Input file read error\")\nJMESSAGE(JERR_FILE_WRITE, \"Output file write error --- out of disk space?\")\nJMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, \"Fractional sampling not implemented yet\")\nJMESSAGE(JERR_HUFF_CLEN_OVERFLOW, \"Huffman code size table overflow\")\nJMESSAGE(JERR_HUFF_MISSING_CODE, \"Missing Huffman code table entry\")\nJMESSAGE(JERR_IMAGE_TOO_BIG, \"Maximum supported image dimension is %u pixels\")\nJMESSAGE(JERR_INPUT_EMPTY, \"Empty input file\")\nJMESSAGE(JERR_INPUT_EOF, \"Premature end of input file\")\nJMESSAGE(JERR_MISMATCHED_QUANT_TABLE,\n\t \"Cannot transcode due to multiple use of quantization table %d\")\nJMESSAGE(JERR_MISSING_DATA, \"Scan script does not transmit all data\")\nJMESSAGE(JERR_MODE_CHANGE, \"Invalid color quantization mode change\")\nJMESSAGE(JERR_NOTIMPL, \"Not implemented yet\")\nJMESSAGE(JERR_NOT_COMPILED, \"Requested feature was omitted at compile time\")\nJMESSAGE(JERR_NO_BACKING_STORE, \"Backing store not supported\")\nJMESSAGE(JERR_NO_HUFF_TABLE, \"Huffman table 0x%02x was not defined\")\nJMESSAGE(JERR_NO_IMAGE, \"JPEG datastream contains no image\")\nJMESSAGE(JERR_NO_QUANT_TABLE, \"Quantization table 0x%02x was not defined\")\nJMESSAGE(JERR_NO_SOI, \"Not a JPEG file: starts with 0x%02x 0x%02x\")\nJMESSAGE(JERR_OUT_OF_MEMORY, \"Insufficient memory (case %d)\")\nJMESSAGE(JERR_QUANT_COMPONENTS,\n\t \"Cannot quantize more than %d color components\")\nJMESSAGE(JERR_QUANT_FEW_COLORS, \"Cannot quantize to fewer than %d colors\")\nJMESSAGE(JERR_QUANT_MANY_COLORS, \"Cannot quantize to more than %d colors\")\nJMESSAGE(JERR_SOF_DUPLICATE, \"Invalid JPEG file structure: two SOF markers\")\nJMESSAGE(JERR_SOF_NO_SOS, \"Invalid JPEG file structure: missing SOS marker\")\nJMESSAGE(JERR_SOF_UNSUPPORTED, \"Unsupported JPEG process: SOF type 0x%02x\")\nJMESSAGE(JERR_SOI_DUPLICATE, \"Invalid JPEG file structure: two SOI markers\")\nJMESSAGE(JERR_SOS_NO_SOF, \"Invalid JPEG file structure: SOS before SOF\")\nJMESSAGE(JERR_TFILE_CREATE, \"Failed to create temporary file %s\")\nJMESSAGE(JERR_TFILE_READ, \"Read failed on temporary file\")\nJMESSAGE(JERR_TFILE_SEEK, \"Seek failed on temporary file\")\nJMESSAGE(JERR_TFILE_WRITE,\n\t \"Write failed on temporary file --- out of disk space?\")\nJMESSAGE(JERR_TOO_LITTLE_DATA, \"Application transferred too few scanlines\")\nJMESSAGE(JERR_UNKNOWN_MARKER, \"Unsupported marker type 0x%02x\")\nJMESSAGE(JERR_VIRTUAL_BUG, \"Virtual array controller messed up\")\nJMESSAGE(JERR_WIDTH_OVERFLOW, \"Image too wide for this implementation\")\nJMESSAGE(JERR_XMS_READ, \"Read from XMS failed\")\nJMESSAGE(JERR_XMS_WRITE, \"Write to XMS failed\")\nJMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT)\nJMESSAGE(JMSG_VERSION, JVERSION)\nJMESSAGE(JTRC_16BIT_TABLES,\n\t \"Caution: quantization tables are too coarse for baseline JPEG\")\nJMESSAGE(JTRC_ADOBE,\n\t \"Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d\")\nJMESSAGE(JTRC_APP0, \"Unknown APP0 marker (not JFIF), length %u\")\nJMESSAGE(JTRC_APP14, \"Unknown APP14 marker (not Adobe), length %u\")\nJMESSAGE(JTRC_DAC, \"Define Arithmetic Table 0x%02x: 0x%02x\")\nJMESSAGE(JTRC_DHT, \"Define Huffman Table 0x%02x\")\nJMESSAGE(JTRC_DQT, \"Define Quantization Table %d  precision %d\")\nJMESSAGE(JTRC_DRI, \"Define Restart Interval %u\")\nJMESSAGE(JTRC_EMS_CLOSE, \"Freed EMS handle %u\")\nJMESSAGE(JTRC_EMS_OPEN, \"Obtained EMS handle %u\")\nJMESSAGE(JTRC_EOI, \"End Of Image\")\nJMESSAGE(JTRC_HUFFBITS, \"        %3d %3d %3d %3d %3d %3d %3d %3d\")\nJMESSAGE(JTRC_JFIF, \"JFIF APP0 marker, density %dx%d  %d\")\nJMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE,\n\t \"Warning: thumbnail image size does not match data length %u\")\nJMESSAGE(JTRC_JFIF_MINOR, \"Unknown JFIF minor revision number %d.%02d\")\nJMESSAGE(JTRC_JFIF_THUMBNAIL, \"    with %d x %d thumbnail image\")\nJMESSAGE(JTRC_MISC_MARKER, \"Skipping marker 0x%02x, length %u\")\nJMESSAGE(JTRC_PARMLESS_MARKER, \"Unexpected marker 0x%02x\")\nJMESSAGE(JTRC_QUANTVALS, \"        %4u %4u %4u %4u %4u %4u %4u %4u\")\nJMESSAGE(JTRC_QUANT_3_NCOLORS, \"Quantizing to %d = %d*%d*%d colors\")\nJMESSAGE(JTRC_QUANT_NCOLORS, \"Quantizing to %d colors\")\nJMESSAGE(JTRC_QUANT_SELECTED, \"Selected %d colors for quantization\")\nJMESSAGE(JTRC_RECOVERY_ACTION, \"At marker 0x%02x, recovery action %d\")\nJMESSAGE(JTRC_RST, \"RST%d\")\nJMESSAGE(JTRC_SMOOTH_NOTIMPL,\n\t \"Smoothing not supported with nonstandard sampling ratios\")\nJMESSAGE(JTRC_SOF, \"Start Of Frame 0x%02x: width=%u, height=%u, components=%d\")\nJMESSAGE(JTRC_SOF_COMPONENT, \"    Component %d: %dhx%dv q=%d\")\nJMESSAGE(JTRC_SOI, \"Start of Image\")\nJMESSAGE(JTRC_SOS, \"Start Of Scan: %d components\")\nJMESSAGE(JTRC_SOS_COMPONENT, \"    Component %d: dc=%d ac=%d\")\nJMESSAGE(JTRC_SOS_PARAMS, \"  Ss=%d, Se=%d, Ah=%d, Al=%d\")\nJMESSAGE(JTRC_TFILE_CLOSE, \"Closed temporary file %s\")\nJMESSAGE(JTRC_TFILE_OPEN, \"Opened temporary file %s\")\nJMESSAGE(JTRC_UNKNOWN_IDS,\n\t \"Unrecognized component IDs %d %d %d, assuming YCbCr\")\nJMESSAGE(JTRC_XMS_CLOSE, \"Freed XMS handle %u\")\nJMESSAGE(JTRC_XMS_OPEN, \"Obtained XMS handle %u\")\nJMESSAGE(JWRN_ADOBE_XFORM, \"Unknown Adobe color transform code %d\")\nJMESSAGE(JWRN_BOGUS_PROGRESSION,\n\t \"Inconsistent progression sequence for component %d coefficient %d\")\nJMESSAGE(JWRN_EXTRANEOUS_DATA,\n\t \"Corrupt JPEG data: %u extraneous bytes before marker 0x%02x\")\nJMESSAGE(JWRN_HIT_MARKER, \"Corrupt JPEG data: premature end of data segment\")\nJMESSAGE(JWRN_HUFF_BAD_CODE, \"Corrupt JPEG data: bad Huffman code\")\nJMESSAGE(JWRN_JFIF_MAJOR, \"Warning: unknown JFIF revision number %d.%02d\")\nJMESSAGE(JWRN_JPEG_EOF, \"Premature end of JPEG file\")\nJMESSAGE(JWRN_MUST_RESYNC,\n\t \"Corrupt JPEG data: found marker 0x%02x instead of RST%d\")\nJMESSAGE(JWRN_NOT_SEQUENTIAL, \"Invalid SOS parameters for sequential JPEG\")\nJMESSAGE(JWRN_TOO_MUCH_DATA, \"Application transferred too many scanlines\")\n\n#ifdef JMAKE_ENUM_LIST\n\n  JMSG_LASTMSGCODE\n} J_MESSAGE_CODE;\n\n#undef JMAKE_ENUM_LIST\n#endif /* JMAKE_ENUM_LIST */\n\n/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */\n#undef JMESSAGE\n\n\n#ifndef JERROR_H\n#define JERROR_H\n\n/* Macros to simplify using the error and trace message stuff */\n/* The first parameter is either type of cinfo pointer */\n\n/* Fatal errors (print message and exit) */\n#define ERREXIT(cinfo,code)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))\n#define ERREXIT1(cinfo,code,p1)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (cinfo)->err->msg_parm.i[0] = (p1), \\\n   (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))\n#define ERREXIT2(cinfo,code,p1,p2)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (cinfo)->err->msg_parm.i[0] = (p1), \\\n   (cinfo)->err->msg_parm.i[1] = (p2), \\\n   (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))\n#define ERREXIT3(cinfo,code,p1,p2,p3)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (cinfo)->err->msg_parm.i[0] = (p1), \\\n   (cinfo)->err->msg_parm.i[1] = (p2), \\\n   (cinfo)->err->msg_parm.i[2] = (p3), \\\n   (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))\n#define ERREXIT4(cinfo,code,p1,p2,p3,p4)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (cinfo)->err->msg_parm.i[0] = (p1), \\\n   (cinfo)->err->msg_parm.i[1] = (p2), \\\n   (cinfo)->err->msg_parm.i[2] = (p3), \\\n   (cinfo)->err->msg_parm.i[3] = (p4), \\\n   (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))\n#define ERREXITS(cinfo,code,str)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \\\n   (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))\n\n#define MAKESTMT(stuff)\t\tdo { stuff } while (0)\n\n/* Nonfatal errors (we can keep going, but the data is probably corrupt) */\n#define WARNMS(cinfo,code)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))\n#define WARNMS1(cinfo,code,p1)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (cinfo)->err->msg_parm.i[0] = (p1), \\\n   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))\n#define WARNMS2(cinfo,code,p1,p2)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (cinfo)->err->msg_parm.i[0] = (p1), \\\n   (cinfo)->err->msg_parm.i[1] = (p2), \\\n   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))\n\n/* Informational/debugging messages */\n#define TRACEMS(cinfo,lvl,code)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))\n#define TRACEMS1(cinfo,lvl,code,p1)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (cinfo)->err->msg_parm.i[0] = (p1), \\\n   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))\n#define TRACEMS2(cinfo,lvl,code,p1,p2)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   (cinfo)->err->msg_parm.i[0] = (p1), \\\n   (cinfo)->err->msg_parm.i[1] = (p2), \\\n   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))\n#define TRACEMS3(cinfo,lvl,code,p1,p2,p3)  \\\n  MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \\\n\t   _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \\\n\t   (cinfo)->err->msg_code = (code); \\\n\t   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )\n#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4)  \\\n  MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \\\n\t   _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \\\n\t   (cinfo)->err->msg_code = (code); \\\n\t   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )\n#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8)  \\\n  MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \\\n\t   _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \\\n\t   _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \\\n\t   (cinfo)->err->msg_code = (code); \\\n\t   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )\n#define TRACEMSS(cinfo,lvl,code,str)  \\\n  ((cinfo)->err->msg_code = (code), \\\n   strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \\\n   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))\n\n#endif /* JERROR_H */\n"
  },
  {
    "path": "libs/jpeg6/jfdctflt.cpp",
    "content": "/*\n * jfdctflt.c\n *\n * Copyright (C) 1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains a floating-point implementation of the\n * forward DCT (Discrete Cosine Transform).\n *\n * This implementation should be more accurate than either of the integer\n * DCT implementations.  However, it may not give the same results on all\n * machines because of differences in roundoff behavior.  Speed will depend\n * on the hardware's floating point capacity.\n *\n * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT\n * on each column.  Direct algorithms are also available, but they are\n * much more complex and seem not to be any faster when reduced to code.\n *\n * This implementation is based on Arai, Agui, and Nakajima's algorithm for\n * scaled DCT.  Their original paper (Trans. IEICE E-71(11):1095) is in\n * Japanese, but the algorithm is described in the Pennebaker & Mitchell\n * JPEG textbook (see REFERENCES section in file README).  The following code\n * is based directly on figure 4-8 in P&M.\n * While an 8-point DCT cannot be done in less than 11 multiplies, it is\n * possible to arrange the computation so that many of the multiplies are\n * simple scalings of the final outputs.  These multiplies can then be\n * folded into the multiplications or divisions by the JPEG quantization\n * table entries.  The AA&N method leaves only 5 multiplies and 29 adds\n * to be done in the DCT itself.\n * The primary disadvantage of this method is that with a fixed-point\n * implementation, accuracy is lost due to imprecise representation of the\n * scaled quantization values.  However, that problem does not arise if\n * we use floating point arithmetic.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jdct.h\"\t\t/* Private declarations for DCT subsystem */\n\n#ifdef DCT_FLOAT_SUPPORTED\n\n\n/*\n * This module is specialized to the case DCTSIZE = 8.\n */\n\n#if DCTSIZE != 8\n  Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */\n#endif\n\n\n/*\n * Perform the forward DCT on one block of samples.\n */\n\nGLOBAL void\njpeg_fdct_float (FAST_FLOAT * data)\n{\n  FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;\n  FAST_FLOAT tmp10, tmp11, tmp12, tmp13;\n  FAST_FLOAT z1, z2, z3, z4, z5, z11, z13;\n  FAST_FLOAT *dataptr;\n  int ctr;\n\n  /* Pass 1: process rows. */\n\n  dataptr = data;\n  for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {\n    tmp0 = dataptr[0] + dataptr[7];\n    tmp7 = dataptr[0] - dataptr[7];\n    tmp1 = dataptr[1] + dataptr[6];\n    tmp6 = dataptr[1] - dataptr[6];\n    tmp2 = dataptr[2] + dataptr[5];\n    tmp5 = dataptr[2] - dataptr[5];\n    tmp3 = dataptr[3] + dataptr[4];\n    tmp4 = dataptr[3] - dataptr[4];\n    \n    /* Even part */\n    \n    tmp10 = tmp0 + tmp3;\t/* phase 2 */\n    tmp13 = tmp0 - tmp3;\n    tmp11 = tmp1 + tmp2;\n    tmp12 = tmp1 - tmp2;\n    \n    dataptr[0] = tmp10 + tmp11; /* phase 3 */\n    dataptr[4] = tmp10 - tmp11;\n    \n    z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */\n    dataptr[2] = tmp13 + z1;\t/* phase 5 */\n    dataptr[6] = tmp13 - z1;\n    \n    /* Odd part */\n\n    tmp10 = tmp4 + tmp5;\t/* phase 2 */\n    tmp11 = tmp5 + tmp6;\n    tmp12 = tmp6 + tmp7;\n\n    /* The rotator is modified from fig 4-8 to avoid extra negations. */\n    z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */\n    z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */\n    z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */\n    z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */\n\n    z11 = tmp7 + z3;\t\t/* phase 5 */\n    z13 = tmp7 - z3;\n\n    dataptr[5] = z13 + z2;\t/* phase 6 */\n    dataptr[3] = z13 - z2;\n    dataptr[1] = z11 + z4;\n    dataptr[7] = z11 - z4;\n\n    dataptr += DCTSIZE;\t\t/* advance pointer to next row */\n  }\n\n  /* Pass 2: process columns. */\n\n  dataptr = data;\n  for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {\n    tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7];\n    tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7];\n    tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6];\n    tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6];\n    tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5];\n    tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5];\n    tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4];\n    tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4];\n    \n    /* Even part */\n    \n    tmp10 = tmp0 + tmp3;\t/* phase 2 */\n    tmp13 = tmp0 - tmp3;\n    tmp11 = tmp1 + tmp2;\n    tmp12 = tmp1 - tmp2;\n    \n    dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */\n    dataptr[DCTSIZE*4] = tmp10 - tmp11;\n    \n    z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */\n    dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */\n    dataptr[DCTSIZE*6] = tmp13 - z1;\n    \n    /* Odd part */\n\n    tmp10 = tmp4 + tmp5;\t/* phase 2 */\n    tmp11 = tmp5 + tmp6;\n    tmp12 = tmp6 + tmp7;\n\n    /* The rotator is modified from fig 4-8 to avoid extra negations. */\n    z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */\n    z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */\n    z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */\n    z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */\n\n    z11 = tmp7 + z3;\t\t/* phase 5 */\n    z13 = tmp7 - z3;\n\n    dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */\n    dataptr[DCTSIZE*3] = z13 - z2;\n    dataptr[DCTSIZE*1] = z11 + z4;\n    dataptr[DCTSIZE*7] = z11 - z4;\n\n    dataptr++;\t\t\t/* advance pointer to next column */\n  }\n}\n\n#endif /* DCT_FLOAT_SUPPORTED */\n"
  },
  {
    "path": "libs/jpeg6/jidctflt.cpp",
    "content": "/*\n * jidctflt.c\n *\n * Copyright (C) 1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains a floating-point implementation of the\n * inverse DCT (Discrete Cosine Transform).  In the IJG code, this routine\n * must also perform dequantization of the input coefficients.\n *\n * This implementation should be more accurate than either of the integer\n * IDCT implementations.  However, it may not give the same results on all\n * machines because of differences in roundoff behavior.  Speed will depend\n * on the hardware's floating point capacity.\n *\n * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT\n * on each row (or vice versa, but it's more convenient to emit a row at\n * a time).  Direct algorithms are also available, but they are much more\n * complex and seem not to be any faster when reduced to code.\n *\n * This implementation is based on Arai, Agui, and Nakajima's algorithm for\n * scaled DCT.  Their original paper (Trans. IEICE E-71(11):1095) is in\n * Japanese, but the algorithm is described in the Pennebaker & Mitchell\n * JPEG textbook (see REFERENCES section in file README).  The following code\n * is based directly on figure 4-8 in P&M.\n * While an 8-point DCT cannot be done in less than 11 multiplies, it is\n * possible to arrange the computation so that many of the multiplies are\n * simple scalings of the final outputs.  These multiplies can then be\n * folded into the multiplications or divisions by the JPEG quantization\n * table entries.  The AA&N method leaves only 5 multiplies and 29 adds\n * to be done in the DCT itself.\n * The primary disadvantage of this method is that with a fixed-point\n * implementation, accuracy is lost due to imprecise representation of the\n * scaled quantization values.  However, that problem does not arise if\n * we use floating point arithmetic.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jdct.h\"\t\t/* Private declarations for DCT subsystem */\n\n#ifdef DCT_FLOAT_SUPPORTED\n\n\n/*\n * This module is specialized to the case DCTSIZE = 8.\n */\n\n#if DCTSIZE != 8\n  Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */\n#endif\n\n\n/* Dequantize a coefficient by multiplying it by the multiplier-table\n * entry; produce a float result.\n */\n\n#define DEQUANTIZE(coef,quantval)  (((FAST_FLOAT) (coef)) * (quantval))\n\n\n/*\n * Perform dequantization and inverse DCT on one block of coefficients.\n */\n\nGLOBAL void\njpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t\t JCOEFPTR coef_block,\n\t\t JSAMPARRAY output_buf, JDIMENSION output_col)\n{\n  FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;\n  FAST_FLOAT tmp10, tmp11, tmp12, tmp13;\n  FAST_FLOAT z5, z10, z11, z12, z13;\n  JCOEFPTR inptr;\n  FLOAT_MULT_TYPE * quantptr;\n  FAST_FLOAT * wsptr;\n  JSAMPROW outptr;\n  JSAMPLE *range_limit = IDCT_range_limit(cinfo);\n  int ctr;\n  FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */\n  SHIFT_TEMPS\n\n  /* Pass 1: process columns from input, store into work array. */\n\n  inptr = coef_block;\n  quantptr = (FLOAT_MULT_TYPE *) compptr->dct_table;\n  wsptr = workspace;\n  for (ctr = DCTSIZE; ctr > 0; ctr--) {\n    /* Due to quantization, we will usually find that many of the input\n     * coefficients are zero, especially the AC terms.  We can exploit this\n     * by short-circuiting the IDCT calculation for any column in which all\n     * the AC terms are zero.  In that case each output is equal to the\n     * DC coefficient (with scale factor as needed).\n     * With typical images and quantization tables, half or more of the\n     * column DCT calculations can be simplified this way.\n     */\n    \n    if ((inptr[DCTSIZE*1] | inptr[DCTSIZE*2] | inptr[DCTSIZE*3] |\n\t inptr[DCTSIZE*4] | inptr[DCTSIZE*5] | inptr[DCTSIZE*6] |\n\t inptr[DCTSIZE*7]) == 0) {\n      /* AC terms all zero */\n      FAST_FLOAT dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);\n      \n      wsptr[DCTSIZE*0] = dcval;\n      wsptr[DCTSIZE*1] = dcval;\n      wsptr[DCTSIZE*2] = dcval;\n      wsptr[DCTSIZE*3] = dcval;\n      wsptr[DCTSIZE*4] = dcval;\n      wsptr[DCTSIZE*5] = dcval;\n      wsptr[DCTSIZE*6] = dcval;\n      wsptr[DCTSIZE*7] = dcval;\n      \n      inptr++;\t\t\t/* advance pointers to next column */\n      quantptr++;\n      wsptr++;\n      continue;\n    }\n    \n    /* Even part */\n\n    tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);\n    tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);\n    tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);\n    tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);\n\n    tmp10 = tmp0 + tmp2;\t/* phase 3 */\n    tmp11 = tmp0 - tmp2;\n\n    tmp13 = tmp1 + tmp3;\t/* phases 5-3 */\n    tmp12 = (tmp1 - tmp3) * ((FAST_FLOAT) 1.414213562) - tmp13; /* 2*c4 */\n\n    tmp0 = tmp10 + tmp13;\t/* phase 2 */\n    tmp3 = tmp10 - tmp13;\n    tmp1 = tmp11 + tmp12;\n    tmp2 = tmp11 - tmp12;\n    \n    /* Odd part */\n\n    tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);\n    tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);\n    tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);\n    tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);\n\n    z13 = tmp6 + tmp5;\t\t/* phase 6 */\n    z10 = tmp6 - tmp5;\n    z11 = tmp4 + tmp7;\n    z12 = tmp4 - tmp7;\n\n    tmp7 = z11 + z13;\t\t/* phase 5 */\n    tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */\n\n    z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */\n    tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */\n    tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */\n\n    tmp6 = tmp12 - tmp7;\t/* phase 2 */\n    tmp5 = tmp11 - tmp6;\n    tmp4 = tmp10 + tmp5;\n\n    wsptr[DCTSIZE*0] = tmp0 + tmp7;\n    wsptr[DCTSIZE*7] = tmp0 - tmp7;\n    wsptr[DCTSIZE*1] = tmp1 + tmp6;\n    wsptr[DCTSIZE*6] = tmp1 - tmp6;\n    wsptr[DCTSIZE*2] = tmp2 + tmp5;\n    wsptr[DCTSIZE*5] = tmp2 - tmp5;\n    wsptr[DCTSIZE*4] = tmp3 + tmp4;\n    wsptr[DCTSIZE*3] = tmp3 - tmp4;\n\n    inptr++;\t\t\t/* advance pointers to next column */\n    quantptr++;\n    wsptr++;\n  }\n  \n  /* Pass 2: process rows from work array, store into output array. */\n  /* Note that we must descale the results by a factor of 8 == 2**3. */\n\n  wsptr = workspace;\n  for (ctr = 0; ctr < DCTSIZE; ctr++) {\n    outptr = output_buf[ctr] + output_col;\n    /* Rows of zeroes can be exploited in the same way as we did with columns.\n     * However, the column calculation has created many nonzero AC terms, so\n     * the simplification applies less often (typically 5% to 10% of the time).\n     * And testing floats for zero is relatively expensive, so we don't bother.\n     */\n    \n    /* Even part */\n\n    tmp10 = wsptr[0] + wsptr[4];\n    tmp11 = wsptr[0] - wsptr[4];\n\n    tmp13 = wsptr[2] + wsptr[6];\n    tmp12 = (wsptr[2] - wsptr[6]) * ((FAST_FLOAT) 1.414213562) - tmp13;\n\n    tmp0 = tmp10 + tmp13;\n    tmp3 = tmp10 - tmp13;\n    tmp1 = tmp11 + tmp12;\n    tmp2 = tmp11 - tmp12;\n\n    /* Odd part */\n\n    z13 = wsptr[5] + wsptr[3];\n    z10 = wsptr[5] - wsptr[3];\n    z11 = wsptr[1] + wsptr[7];\n    z12 = wsptr[1] - wsptr[7];\n\n    tmp7 = z11 + z13;\n    tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562);\n\n    z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */\n    tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */\n    tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */\n\n    tmp6 = tmp12 - tmp7;\n    tmp5 = tmp11 - tmp6;\n    tmp4 = tmp10 + tmp5;\n\n    /* Final output stage: scale down by a factor of 8 and range-limit */\n\n    outptr[0] = range_limit[(int) DESCALE((INT32) (tmp0 + tmp7), 3)\n\t\t\t    & RANGE_MASK];\n    outptr[7] = range_limit[(int) DESCALE((INT32) (tmp0 - tmp7), 3)\n\t\t\t    & RANGE_MASK];\n    outptr[1] = range_limit[(int) DESCALE((INT32) (tmp1 + tmp6), 3)\n\t\t\t    & RANGE_MASK];\n    outptr[6] = range_limit[(int) DESCALE((INT32) (tmp1 - tmp6), 3)\n\t\t\t    & RANGE_MASK];\n    outptr[2] = range_limit[(int) DESCALE((INT32) (tmp2 + tmp5), 3)\n\t\t\t    & RANGE_MASK];\n    outptr[5] = range_limit[(int) DESCALE((INT32) (tmp2 - tmp5), 3)\n\t\t\t    & RANGE_MASK];\n    outptr[4] = range_limit[(int) DESCALE((INT32) (tmp3 + tmp4), 3)\n\t\t\t    & RANGE_MASK];\n    outptr[3] = range_limit[(int) DESCALE((INT32) (tmp3 - tmp4), 3)\n\t\t\t    & RANGE_MASK];\n    \n    wsptr += DCTSIZE;\t\t/* advance pointer to next row */\n  }\n}\n\n#endif /* DCT_FLOAT_SUPPORTED */\n"
  },
  {
    "path": "libs/jpeg6/jinclude.h",
    "content": "/*\n * jinclude.h\n *\n * Copyright (C) 1991-1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file exists to provide a single place to fix any problems with\n * including the wrong system include files.  (Common problems are taken\n * care of by the standard jconfig symbols, but on really weird systems\n * you may have to edit this file.)\n *\n * NOTE: this file is NOT intended to be included by applications using the\n * JPEG library.  Most applications need only include jpeglib.h.\n */\n\n\n/* Include auto-config file to find out which system include files we need. */\n\n#include \"jconfig.h\"\t\t/* auto configuration options */\n#define JCONFIG_INCLUDED\t/* so that jpeglib.h doesn't do it again */\n\n/*\n * We need the NULL macro and size_t typedef.\n * On an ANSI-conforming system it is sufficient to include <stddef.h>.\n * Otherwise, we get them from <stdlib.h> or <stdio.h>; we may have to\n * pull in <sys/types.h> as well.\n * Note that the core JPEG library does not require <stdio.h>;\n * only the default error handler and data source/destination modules do.\n * But we must pull it in because of the references to FILE in jpeglib.h.\n * You can remove those references if you want to compile without <stdio.h>.\n */\n\n#ifdef HAVE_STDDEF_H\n#include <stddef.h>\n#endif\n\n#ifdef HAVE_STDLIB_H\n#include <stdlib.h>\n#endif\n\n#ifdef NEED_SYS_TYPES_H\n#include <sys/types.h>\n#endif\n\n#include <stdio.h>\n\n/*\n * We need memory copying and zeroing functions, plus strncpy().\n * ANSI and System V implementations declare these in <string.h>.\n * BSD doesn't have the mem() functions, but it does have bcopy()/bzero().\n * Some systems may declare memset and memcpy in <memory.h>.\n *\n * NOTE: we assume the size parameters to these functions are of type size_t.\n * Change the casts in these macros if not!\n */\n\n#ifdef NEED_BSD_STRINGS\n\n#include <strings.h>\n#define MEMZERO(target,size)\tbzero((void *)(target), (size_t)(size))\n#define MEMCOPY(dest,src,size)\tbcopy((const void *)(src), (void *)(dest), (size_t)(size))\n\n#else /* not BSD, assume ANSI/SysV string lib */\n\n#include <string.h>\n#define MEMZERO(target,size)\tmemset((void *)(target), 0, (size_t)(size))\n#define MEMCOPY(dest,src,size)\tmemcpy((void *)(dest), (const void *)(src), (size_t)(size))\n\n#endif\n\n/*\n * In ANSI C, and indeed any rational implementation, size_t is also the\n * type returned by sizeof().  However, it seems there are some irrational\n * implementations out there, in which sizeof() returns an int even though\n * size_t is defined as long or unsigned long.  To ensure consistent results\n * we always use this SIZEOF() macro in place of using sizeof() directly.\n */\n\n#define SIZEOF(object)\t((size_t) sizeof(object))\n\n/*\n * The modules that use fread() and fwrite() always invoke them through\n * these macros.  On some systems you may need to twiddle the argument casts.\n * CAUTION: argument order is different from underlying functions!\n */\n\n#define JFREAD(file,buf,sizeofbuf)  \\\n  ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))\n#define JFWRITE(file,buf,sizeofbuf)  \\\n  ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))\n"
  },
  {
    "path": "libs/jpeg6/jmemmgr.cpp",
    "content": "/*\n * jmemmgr.c\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains the JPEG system-independent memory management\n * routines.  This code is usable across a wide variety of machines; most\n * of the system dependencies have been isolated in a separate file.\n * The major functions provided here are:\n *   * pool-based allocation and freeing of memory;\n *   * policy decisions about how to divide available memory among the\n *     virtual arrays;\n *   * control logic for swapping virtual arrays between main memory and\n *     backing storage.\n * The separate system-dependent file provides the actual backing-storage\n * access code, and it contains the policy decision about how much total\n * main memory to use.\n * This file is system-dependent in the sense that some of its functions\n * are unnecessary in some systems.  For example, if there is enough virtual\n * memory so that backing storage will never be used, much of the virtual\n * array control logic could be removed.  (Of course, if you have that much\n * memory then you shouldn't care about a little bit of unused code...)\n */\n\n#define JPEG_INTERNALS\n#define AM_MEMORY_MANAGER\t/* we define jvirt_Xarray_control structs */\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jmemsys.h\"\t\t/* import the system-dependent declarations */\n\n#ifndef NO_GETENV\n#ifndef HAVE_STDLIB_H\t\t/* <stdlib.h> should declare getenv() */\nextern char * getenv JPP((const char * name));\n#endif\n#endif\n\n\n/*\n * Some important notes:\n *   The allocation routines provided here must never return NULL.\n *   They should exit to error_exit if unsuccessful.\n *\n *   It's not a good idea to try to merge the sarray and barray routines,\n *   even though they are textually almost the same, because samples are\n *   usually stored as bytes while coefficients are shorts or ints.  Thus,\n *   in machines where byte pointers have a different representation from\n *   word pointers, the resulting machine code could not be the same.\n */\n\n\n/*\n * Many machines require storage alignment: longs must start on 4-byte\n * boundaries, doubles on 8-byte boundaries, etc.  On such machines, malloc()\n * always returns pointers that are multiples of the worst-case alignment\n * requirement, and we had better do so too.\n * There isn't any really portable way to determine the worst-case alignment\n * requirement.  This module assumes that the alignment requirement is\n * multiples of sizeof(ALIGN_TYPE).\n * By default, we define ALIGN_TYPE as double.  This is necessary on some\n * workstations (where doubles really do need 8-byte alignment) and will work\n * fine on nearly everything.  If your machine has lesser alignment needs,\n * you can save a few bytes by making ALIGN_TYPE smaller.\n * The only place I know of where this will NOT work is certain Macintosh\n * 680x0 compilers that define double as a 10-byte IEEE extended float.\n * Doing 10-byte alignment is counterproductive because longwords won't be\n * aligned well.  Put \"#define ALIGN_TYPE long\" in jconfig.h if you have\n * such a compiler.\n */\n\n#ifndef ALIGN_TYPE\t\t/* so can override from jconfig.h */\n#define ALIGN_TYPE  double\n#endif\n\n\n/*\n * We allocate objects from \"pools\", where each pool is gotten with a single\n * request to jpeg_get_small() or jpeg_get_large().  There is no per-object\n * overhead within a pool, except for alignment padding.  Each pool has a\n * header with a link to the next pool of the same class.\n * Small and large pool headers are identical except that the latter's\n * link pointer must be FAR on 80x86 machines.\n * Notice that the \"real\" header fields are union'ed with a dummy ALIGN_TYPE\n * field.  This forces the compiler to make SIZEOF(small_pool_hdr) a multiple\n * of the alignment requirement of ALIGN_TYPE.\n */\n\ntypedef union small_pool_struct * small_pool_ptr;\n\ntypedef union small_pool_struct {\n  struct {\n    small_pool_ptr next;\t/* next in list of pools */\n    size_t bytes_used;\t\t/* how many bytes already used within pool */\n    size_t bytes_left;\t\t/* bytes still available in this pool */\n  } hdr;\n  ALIGN_TYPE dummy;\t\t/* included in union to ensure alignment */\n} small_pool_hdr;\n\ntypedef union large_pool_struct FAR * large_pool_ptr;\n\ntypedef union large_pool_struct {\n  struct {\n    large_pool_ptr next;\t/* next in list of pools */\n    size_t bytes_used;\t\t/* how many bytes already used within pool */\n    size_t bytes_left;\t\t/* bytes still available in this pool */\n  } hdr;\n  ALIGN_TYPE dummy;\t\t/* included in union to ensure alignment */\n} large_pool_hdr;\n\n\n/*\n * Here is the full definition of a memory manager object.\n */\n\ntypedef struct {\n  struct jpeg_memory_mgr pub;\t/* public fields */\n\n  /* Each pool identifier (lifetime class) names a linked list of pools. */\n  small_pool_ptr small_list[JPOOL_NUMPOOLS];\n  large_pool_ptr large_list[JPOOL_NUMPOOLS];\n\n  /* Since we only have one lifetime class of virtual arrays, only one\n   * linked list is necessary (for each datatype).  Note that the virtual\n   * array control blocks being linked together are actually stored somewhere\n   * in the small-pool list.\n   */\n  jvirt_sarray_ptr virt_sarray_list;\n  jvirt_barray_ptr virt_barray_list;\n\n  /* This counts total space obtained from jpeg_get_small/large */\n  long total_space_allocated;\n\n  /* alloc_sarray and alloc_barray set this value for use by virtual\n   * array routines.\n   */\n  JDIMENSION last_rowsperchunk;\t/* from most recent alloc_sarray/barray */\n} my_memory_mgr;\n\ntypedef my_memory_mgr * my_mem_ptr;\n\n\n/*\n * The control blocks for virtual arrays.\n * Note that these blocks are allocated in the \"small\" pool area.\n * System-dependent info for the associated backing store (if any) is hidden\n * inside the backing_store_info struct.\n */\n\nstruct jvirt_sarray_control {\n  JSAMPARRAY mem_buffer;\t/* => the in-memory buffer */\n  JDIMENSION rows_in_array;\t/* total virtual array height */\n  JDIMENSION samplesperrow;\t/* width of array (and of memory buffer) */\n  JDIMENSION maxaccess;\t\t/* max rows accessed by access_virt_sarray */\n  JDIMENSION rows_in_mem;\t/* height of memory buffer */\n  JDIMENSION rowsperchunk;\t/* allocation chunk size in mem_buffer */\n  JDIMENSION cur_start_row;\t/* first logical row # in the buffer */\n  JDIMENSION first_undef_row;\t/* row # of first uninitialized row */\n  boolean pre_zero;\t\t/* pre-zero mode requested? */\n  boolean dirty;\t\t/* do current buffer contents need written? */\n  boolean b_s_open;\t\t/* is backing-store data valid? */\n  jvirt_sarray_ptr next;\t/* link to next virtual sarray control block */\n  backing_store_info b_s_info;\t/* System-dependent control info */\n};\n\nstruct jvirt_barray_control {\n  JBLOCKARRAY mem_buffer;\t/* => the in-memory buffer */\n  JDIMENSION rows_in_array;\t/* total virtual array height */\n  JDIMENSION blocksperrow;\t/* width of array (and of memory buffer) */\n  JDIMENSION maxaccess;\t\t/* max rows accessed by access_virt_barray */\n  JDIMENSION rows_in_mem;\t/* height of memory buffer */\n  JDIMENSION rowsperchunk;\t/* allocation chunk size in mem_buffer */\n  JDIMENSION cur_start_row;\t/* first logical row # in the buffer */\n  JDIMENSION first_undef_row;\t/* row # of first uninitialized row */\n  boolean pre_zero;\t\t/* pre-zero mode requested? */\n  boolean dirty;\t\t/* do current buffer contents need written? */\n  boolean b_s_open;\t\t/* is backing-store data valid? */\n  jvirt_barray_ptr next;\t/* link to next virtual barray control block */\n  backing_store_info b_s_info;\t/* System-dependent control info */\n};\n\n\n#ifdef MEM_STATS\t\t/* optional extra stuff for statistics */\n\nLOCAL void\nprint_mem_stats (j_common_ptr cinfo, int pool_id)\n{\n  my_mem_ptr mem = (my_mem_ptr) cinfo->mem;\n  small_pool_ptr shdr_ptr;\n  large_pool_ptr lhdr_ptr;\n\n  /* Since this is only a debugging stub, we can cheat a little by using\n   * fprintf directly rather than going through the trace message code.\n   * This is helpful because message parm array can't handle longs.\n   */\n  fprintf(stderr, \"Freeing pool %d, total space = %ld\\n\",\n\t  pool_id, mem->total_space_allocated);\n\n  for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL;\n       lhdr_ptr = lhdr_ptr->hdr.next) {\n    fprintf(stderr, \"  Large chunk used %ld\\n\",\n\t    (long) lhdr_ptr->hdr.bytes_used);\n  }\n\n  for (shdr_ptr = mem->small_list[pool_id]; shdr_ptr != NULL;\n       shdr_ptr = shdr_ptr->hdr.next) {\n    fprintf(stderr, \"  Small chunk used %ld free %ld\\n\",\n\t    (long) shdr_ptr->hdr.bytes_used,\n\t    (long) shdr_ptr->hdr.bytes_left);\n  }\n}\n\n#endif /* MEM_STATS */\n\n\nLOCAL void\nout_of_memory (j_common_ptr cinfo, int which)\n/* Report an out-of-memory error and stop execution */\n/* If we compiled MEM_STATS support, report alloc requests before dying */\n{\n#ifdef MEM_STATS\n  cinfo->err->trace_level = 2;\t/* force self_destruct to report stats */\n#endif\n  ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, which);\n}\n\n\n/*\n * Allocation of \"small\" objects.\n *\n * For these, we use pooled storage.  When a new pool must be created,\n * we try to get enough space for the current request plus a \"slop\" factor,\n * where the slop will be the amount of leftover space in the new pool.\n * The speed vs. space tradeoff is largely determined by the slop values.\n * A different slop value is provided for each pool class (lifetime),\n * and we also distinguish the first pool of a class from later ones.\n * NOTE: the values given work fairly well on both 16- and 32-bit-int\n * machines, but may be too small if longs are 64 bits or more.\n */\n\nstatic const size_t first_pool_slop[JPOOL_NUMPOOLS] = \n{\n\t1600,\t\t\t/* first PERMANENT pool */\n\t16000\t\t\t/* first IMAGE pool */\n};\n\nstatic const size_t extra_pool_slop[JPOOL_NUMPOOLS] = \n{\n\t0,\t\t\t/* additional PERMANENT pools */\n\t5000\t\t\t/* additional IMAGE pools */\n};\n\n#define MIN_SLOP  50\t\t/* greater than 0 to avoid futile looping */\n\n\nMETHODDEF void *\nalloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)\n/* Allocate a \"small\" object */\n{\n  my_mem_ptr mem = (my_mem_ptr) cinfo->mem;\n  small_pool_ptr hdr_ptr, prev_hdr_ptr;\n  char * data_ptr;\n  size_t odd_bytes, min_request, slop;\n\n  /* Check for unsatisfiable request (do now to ensure no overflow below) */\n  if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(small_pool_hdr)))\n    out_of_memory(cinfo, 1);\t/* request exceeds malloc's ability */\n\n  /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */\n  odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE);\n  if (odd_bytes > 0)\n    sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes;\n\n  /* See if space is available in any existing pool */\n  if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS)\n    ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id);\t/* safety check */\n  prev_hdr_ptr = NULL;\n  hdr_ptr = mem->small_list[pool_id];\n  while (hdr_ptr != NULL) {\n    if (hdr_ptr->hdr.bytes_left >= sizeofobject)\n      break;\t\t\t/* found pool with enough space */\n    prev_hdr_ptr = hdr_ptr;\n    hdr_ptr = hdr_ptr->hdr.next;\n  }\n\n  /* Time to make a new pool? */\n  if (hdr_ptr == NULL) {\n    /* min_request is what we need now, slop is what will be leftover */\n    min_request = sizeofobject + SIZEOF(small_pool_hdr);\n    if (prev_hdr_ptr == NULL)\t/* first pool in class? */\n      slop = first_pool_slop[pool_id];\n    else\n      slop = extra_pool_slop[pool_id];\n    /* Don't ask for more than MAX_ALLOC_CHUNK */\n    if (slop > (size_t) (MAX_ALLOC_CHUNK-min_request))\n      slop = (size_t) (MAX_ALLOC_CHUNK-min_request);\n    /* Try to get space, if fail reduce slop and try again */\n    for (;;) {\n      hdr_ptr = (small_pool_ptr) jpeg_get_small(cinfo, min_request + slop);\n      if (hdr_ptr != NULL)\n\tbreak;\n      slop /= 2;\n      if (slop < MIN_SLOP)\t/* give up when it gets real small */\n\tout_of_memory(cinfo, 2); /* jpeg_get_small failed */\n    }\n    mem->total_space_allocated += min_request + slop;\n    /* Success, initialize the new pool header and add to end of list */\n    hdr_ptr->hdr.next = NULL;\n    hdr_ptr->hdr.bytes_used = 0;\n    hdr_ptr->hdr.bytes_left = sizeofobject + slop;\n    if (prev_hdr_ptr == NULL)\t/* first pool in class? */\n      mem->small_list[pool_id] = hdr_ptr;\n    else\n      prev_hdr_ptr->hdr.next = hdr_ptr;\n  }\n\n  /* OK, allocate the object from the current pool */\n  data_ptr = (char *) (hdr_ptr + 1); /* point to first data byte in pool */\n  data_ptr += hdr_ptr->hdr.bytes_used; /* point to place for object */\n  hdr_ptr->hdr.bytes_used += sizeofobject;\n  hdr_ptr->hdr.bytes_left -= sizeofobject;\n\n  return (void *) data_ptr;\n}\n\n\n/*\n * Allocation of \"large\" objects.\n *\n * The external semantics of these are the same as \"small\" objects,\n * except that FAR pointers are used on 80x86.  However the pool\n * management heuristics are quite different.  We assume that each\n * request is large enough that it may as well be passed directly to\n * jpeg_get_large; the pool management just links everything together\n * so that we can free it all on demand.\n * Note: the major use of \"large\" objects is in JSAMPARRAY and JBLOCKARRAY\n * structures.  The routines that create these structures (see below)\n * deliberately bunch rows together to ensure a large request size.\n */\n\nMETHODDEF void FAR *\nalloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)\n/* Allocate a \"large\" object */\n{\n  my_mem_ptr mem = (my_mem_ptr) cinfo->mem;\n  large_pool_ptr hdr_ptr;\n  size_t odd_bytes;\n\n  /* Check for unsatisfiable request (do now to ensure no overflow below) */\n  if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)))\n    out_of_memory(cinfo, 3);\t/* request exceeds malloc's ability */\n\n  /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */\n  odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE);\n  if (odd_bytes > 0)\n    sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes;\n\n  /* Always make a new pool */\n  if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS)\n    ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id);\t/* safety check */\n\n  hdr_ptr = (large_pool_ptr) jpeg_get_large(cinfo, sizeofobject +\n\t\t\t\t\t    SIZEOF(large_pool_hdr));\n  if (hdr_ptr == NULL)\n    out_of_memory(cinfo, 4);\t/* jpeg_get_large failed */\n  mem->total_space_allocated += sizeofobject + SIZEOF(large_pool_hdr);\n\n  /* Success, initialize the new pool header and add to list */\n  hdr_ptr->hdr.next = mem->large_list[pool_id];\n  /* We maintain space counts in each pool header for statistical purposes,\n   * even though they are not needed for allocation.\n   */\n  hdr_ptr->hdr.bytes_used = sizeofobject;\n  hdr_ptr->hdr.bytes_left = 0;\n  mem->large_list[pool_id] = hdr_ptr;\n\n  return (void FAR *) (hdr_ptr + 1); /* point to first data byte in pool */\n}\n\n\n/*\n * Creation of 2-D sample arrays.\n * The pointers are in near heap, the samples themselves in FAR heap.\n *\n * To minimize allocation overhead and to allow I/O of large contiguous\n * blocks, we allocate the sample rows in groups of as many rows as possible\n * without exceeding MAX_ALLOC_CHUNK total bytes per allocation request.\n * NB: the virtual array control routines, later in this file, know about\n * this chunking of rows.  The rowsperchunk value is left in the mem manager\n * object so that it can be saved away if this sarray is the workspace for\n * a virtual array.\n */\n\nMETHODDEF JSAMPARRAY\nalloc_sarray (j_common_ptr cinfo, int pool_id,\n\t      JDIMENSION samplesperrow, JDIMENSION numrows)\n/* Allocate a 2-D sample array */\n{\n  my_mem_ptr mem = (my_mem_ptr) cinfo->mem;\n  JSAMPARRAY result;\n  JSAMPROW workspace;\n  JDIMENSION rowsperchunk, currow, i;\n  long ltemp;\n\n  /* Calculate max # of rows allowed in one allocation chunk */\n  ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) /\n\t  ((long) samplesperrow * SIZEOF(JSAMPLE));\n  if (ltemp <= 0)\n    ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);\n  if (ltemp < (long) numrows)\n    rowsperchunk = (JDIMENSION) ltemp;\n  else\n    rowsperchunk = numrows;\n  mem->last_rowsperchunk = rowsperchunk;\n\n  /* Get space for row pointers (small object) */\n  result = (JSAMPARRAY) alloc_small(cinfo, pool_id,\n\t\t\t\t    (size_t) (numrows * SIZEOF(JSAMPROW)));\n\n  /* Get the rows themselves (large objects) */\n  currow = 0;\n  while (currow < numrows) {\n    rowsperchunk = MIN(rowsperchunk, numrows - currow);\n    workspace = (JSAMPROW) alloc_large(cinfo, pool_id,\n\t(size_t) ((size_t) rowsperchunk * (size_t) samplesperrow\n\t\t  * SIZEOF(JSAMPLE)));\n    for (i = rowsperchunk; i > 0; i--) {\n      result[currow++] = workspace;\n      workspace += samplesperrow;\n    }\n  }\n\n  return result;\n}\n\n\n/*\n * Creation of 2-D coefficient-block arrays.\n * This is essentially the same as the code for sample arrays, above.\n */\n\nMETHODDEF JBLOCKARRAY\nalloc_barray (j_common_ptr cinfo, int pool_id,\n\t      JDIMENSION blocksperrow, JDIMENSION numrows)\n/* Allocate a 2-D coefficient-block array */\n{\n  my_mem_ptr mem = (my_mem_ptr) cinfo->mem;\n  JBLOCKARRAY result;\n  JBLOCKROW workspace;\n  JDIMENSION rowsperchunk, currow, i;\n  long ltemp;\n\n  /* Calculate max # of rows allowed in one allocation chunk */\n  ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) /\n\t  ((long) blocksperrow * SIZEOF(JBLOCK));\n  if (ltemp <= 0)\n    ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);\n  if (ltemp < (long) numrows)\n    rowsperchunk = (JDIMENSION) ltemp;\n  else\n    rowsperchunk = numrows;\n  mem->last_rowsperchunk = rowsperchunk;\n\n  /* Get space for row pointers (small object) */\n  result = (JBLOCKARRAY) alloc_small(cinfo, pool_id,\n\t\t\t\t     (size_t) (numrows * SIZEOF(JBLOCKROW)));\n\n  /* Get the rows themselves (large objects) */\n  currow = 0;\n  while (currow < numrows) {\n    rowsperchunk = MIN(rowsperchunk, numrows - currow);\n    workspace = (JBLOCKROW) alloc_large(cinfo, pool_id,\n\t(size_t) ((size_t) rowsperchunk * (size_t) blocksperrow\n\t\t  * SIZEOF(JBLOCK)));\n    for (i = rowsperchunk; i > 0; i--) {\n      result[currow++] = workspace;\n      workspace += blocksperrow;\n    }\n  }\n\n  return result;\n}\n\n\n/*\n * About virtual array management:\n *\n * The above \"normal\" array routines are only used to allocate strip buffers\n * (as wide as the image, but just a few rows high).  Full-image-sized buffers\n * are handled as \"virtual\" arrays.  The array is still accessed a strip at a\n * time, but the memory manager must save the whole array for repeated\n * accesses.  The intended implementation is that there is a strip buffer in\n * memory (as high as is possible given the desired memory limit), plus a\n * backing file that holds the rest of the array.\n *\n * The request_virt_array routines are told the total size of the image and\n * the maximum number of rows that will be accessed at once.  The in-memory\n * buffer must be at least as large as the maxaccess value.\n *\n * The request routines create control blocks but not the in-memory buffers.\n * That is postponed until realize_virt_arrays is called.  At that time the\n * total amount of space needed is known (approximately, anyway), so free\n * memory can be divided up fairly.\n *\n * The access_virt_array routines are responsible for making a specific strip\n * area accessible (after reading or writing the backing file, if necessary).\n * Note that the access routines are told whether the caller intends to modify\n * the accessed strip; during a read-only pass this saves having to rewrite\n * data to disk.  The access routines are also responsible for pre-zeroing\n * any newly accessed rows, if pre-zeroing was requested.\n *\n * In current usage, the access requests are usually for nonoverlapping\n * strips; that is, successive access start_row numbers differ by exactly\n * num_rows = maxaccess.  This means we can get good performance with simple\n * buffer dump/reload logic, by making the in-memory buffer be a multiple\n * of the access height; then there will never be accesses across bufferload\n * boundaries.  The code will still work with overlapping access requests,\n * but it doesn't handle bufferload overlaps very efficiently.\n */\n\n\nMETHODDEF jvirt_sarray_ptr\nrequest_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero,\n\t\t     JDIMENSION samplesperrow, JDIMENSION numrows,\n\t\t     JDIMENSION maxaccess)\n/* Request a virtual 2-D sample array */\n{\n  my_mem_ptr mem = (my_mem_ptr) cinfo->mem;\n  jvirt_sarray_ptr result;\n\n  /* Only IMAGE-lifetime virtual arrays are currently supported */\n  if (pool_id != JPOOL_IMAGE)\n    ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id);\t/* safety check */\n\n  /* get control block */\n  result = (jvirt_sarray_ptr) alloc_small(cinfo, pool_id,\n\t\t\t\t\t  SIZEOF(struct jvirt_sarray_control));\n\n  result->mem_buffer = NULL;\t/* marks array not yet realized */\n  result->rows_in_array = numrows;\n  result->samplesperrow = samplesperrow;\n  result->maxaccess = maxaccess;\n  result->pre_zero = pre_zero;\n  result->b_s_open = FALSE;\t/* no associated backing-store object */\n  result->next = mem->virt_sarray_list; /* add to list of virtual arrays */\n  mem->virt_sarray_list = result;\n\n  return result;\n}\n\n\nMETHODDEF jvirt_barray_ptr\nrequest_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero,\n\t\t     JDIMENSION blocksperrow, JDIMENSION numrows,\n\t\t     JDIMENSION maxaccess)\n/* Request a virtual 2-D coefficient-block array */\n{\n  my_mem_ptr mem = (my_mem_ptr) cinfo->mem;\n  jvirt_barray_ptr result;\n\n  /* Only IMAGE-lifetime virtual arrays are currently supported */\n  if (pool_id != JPOOL_IMAGE)\n    ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id);\t/* safety check */\n\n  /* get control block */\n  result = (jvirt_barray_ptr) alloc_small(cinfo, pool_id,\n\t\t\t\t\t  SIZEOF(struct jvirt_barray_control));\n\n  result->mem_buffer = NULL;\t/* marks array not yet realized */\n  result->rows_in_array = numrows;\n  result->blocksperrow = blocksperrow;\n  result->maxaccess = maxaccess;\n  result->pre_zero = pre_zero;\n  result->b_s_open = FALSE;\t/* no associated backing-store object */\n  result->next = mem->virt_barray_list; /* add to list of virtual arrays */\n  mem->virt_barray_list = result;\n\n  return result;\n}\n\n\nMETHODDEF void\nrealize_virt_arrays (j_common_ptr cinfo)\n/* Allocate the in-memory buffers for any unrealized virtual arrays */\n{\n  my_mem_ptr mem = (my_mem_ptr) cinfo->mem;\n  long space_per_minheight, maximum_space, avail_mem;\n  long minheights, max_minheights;\n  jvirt_sarray_ptr sptr;\n  jvirt_barray_ptr bptr;\n\n  /* Compute the minimum space needed (maxaccess rows in each buffer)\n   * and the maximum space needed (full image height in each buffer).\n   * These may be of use to the system-dependent jpeg_mem_available routine.\n   */\n  space_per_minheight = 0;\n  maximum_space = 0;\n  for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {\n    if (sptr->mem_buffer == NULL) { /* if not realized yet */\n      space_per_minheight += (long) sptr->maxaccess *\n\t\t\t     (long) sptr->samplesperrow * SIZEOF(JSAMPLE);\n      maximum_space += (long) sptr->rows_in_array *\n\t\t       (long) sptr->samplesperrow * SIZEOF(JSAMPLE);\n    }\n  }\n  for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {\n    if (bptr->mem_buffer == NULL) { /* if not realized yet */\n      space_per_minheight += (long) bptr->maxaccess *\n\t\t\t     (long) bptr->blocksperrow * SIZEOF(JBLOCK);\n      maximum_space += (long) bptr->rows_in_array *\n\t\t       (long) bptr->blocksperrow * SIZEOF(JBLOCK);\n    }\n  }\n\n  if (space_per_minheight <= 0)\n    return;\t\t\t/* no unrealized arrays, no work */\n\n  /* Determine amount of memory to actually use; this is system-dependent. */\n  avail_mem = jpeg_mem_available(cinfo, space_per_minheight, maximum_space,\n\t\t\t\t mem->total_space_allocated);\n\n  /* If the maximum space needed is available, make all the buffers full\n   * height; otherwise parcel it out with the same number of minheights\n   * in each buffer.\n   */\n  if (avail_mem >= maximum_space)\n    max_minheights = 1000000000L;\n  else {\n    max_minheights = avail_mem / space_per_minheight;\n    /* If there doesn't seem to be enough space, try to get the minimum\n     * anyway.  This allows a \"stub\" implementation of jpeg_mem_available().\n     */\n    if (max_minheights <= 0)\n      max_minheights = 1;\n  }\n\n  /* Allocate the in-memory buffers and initialize backing store as needed. */\n\n  for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {\n    if (sptr->mem_buffer == NULL) { /* if not realized yet */\n      minheights = ((long) sptr->rows_in_array - 1L) / sptr->maxaccess + 1L;\n      if (minheights <= max_minheights) {\n\t/* This buffer fits in memory */\n\tsptr->rows_in_mem = sptr->rows_in_array;\n      } else {\n\t/* It doesn't fit in memory, create backing store. */\n\tsptr->rows_in_mem = (JDIMENSION) (max_minheights * sptr->maxaccess);\n\tjpeg_open_backing_store(cinfo, & sptr->b_s_info,\n\t\t\t\t(long) sptr->rows_in_array *\n\t\t\t\t(long) sptr->samplesperrow *\n\t\t\t\t(long) SIZEOF(JSAMPLE));\n\tsptr->b_s_open = TRUE;\n      }\n      sptr->mem_buffer = alloc_sarray(cinfo, JPOOL_IMAGE,\n\t\t\t\t      sptr->samplesperrow, sptr->rows_in_mem);\n      sptr->rowsperchunk = mem->last_rowsperchunk;\n      sptr->cur_start_row = 0;\n      sptr->first_undef_row = 0;\n      sptr->dirty = FALSE;\n    }\n  }\n\n  for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {\n    if (bptr->mem_buffer == NULL) { /* if not realized yet */\n      minheights = ((long) bptr->rows_in_array - 1L) / bptr->maxaccess + 1L;\n      if (minheights <= max_minheights) {\n\t/* This buffer fits in memory */\n\tbptr->rows_in_mem = bptr->rows_in_array;\n      } else {\n\t/* It doesn't fit in memory, create backing store. */\n\tbptr->rows_in_mem = (JDIMENSION) (max_minheights * bptr->maxaccess);\n\tjpeg_open_backing_store(cinfo, & bptr->b_s_info,\n\t\t\t\t(long) bptr->rows_in_array *\n\t\t\t\t(long) bptr->blocksperrow *\n\t\t\t\t(long) SIZEOF(JBLOCK));\n\tbptr->b_s_open = TRUE;\n      }\n      bptr->mem_buffer = alloc_barray(cinfo, JPOOL_IMAGE,\n\t\t\t\t      bptr->blocksperrow, bptr->rows_in_mem);\n      bptr->rowsperchunk = mem->last_rowsperchunk;\n      bptr->cur_start_row = 0;\n      bptr->first_undef_row = 0;\n      bptr->dirty = FALSE;\n    }\n  }\n}\n\n\nLOCAL void\ndo_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)\n/* Do backing store read or write of a virtual sample array */\n{\n  long bytesperrow, file_offset, byte_count, rows, thisrow, i;\n\n  bytesperrow = (long) ptr->samplesperrow * SIZEOF(JSAMPLE);\n  file_offset = ptr->cur_start_row * bytesperrow;\n  /* Loop to read or write each allocation chunk in mem_buffer */\n  for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {\n    /* One chunk, but check for short chunk at end of buffer */\n    rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i);\n    /* Transfer no more than is currently defined */\n    thisrow = (long) ptr->cur_start_row + i;\n    rows = MIN(rows, (long) ptr->first_undef_row - thisrow);\n    /* Transfer no more than fits in file */\n    rows = MIN(rows, (long) ptr->rows_in_array - thisrow);\n    if (rows <= 0)\t\t/* this chunk might be past end of file! */\n      break;\n    byte_count = rows * bytesperrow;\n    if (writing)\n      (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info,\n\t\t\t\t\t    (void FAR *) ptr->mem_buffer[i],\n\t\t\t\t\t    file_offset, byte_count);\n    else\n      (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info,\n\t\t\t\t\t   (void FAR *) ptr->mem_buffer[i],\n\t\t\t\t\t   file_offset, byte_count);\n    file_offset += byte_count;\n  }\n}\n\n\nLOCAL void\ndo_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing)\n/* Do backing store read or write of a virtual coefficient-block array */\n{\n  long bytesperrow, file_offset, byte_count, rows, thisrow, i;\n\n  bytesperrow = (long) ptr->blocksperrow * SIZEOF(JBLOCK);\n  file_offset = ptr->cur_start_row * bytesperrow;\n  /* Loop to read or write each allocation chunk in mem_buffer */\n  for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {\n    /* One chunk, but check for short chunk at end of buffer */\n    rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i);\n    /* Transfer no more than is currently defined */\n    thisrow = (long) ptr->cur_start_row + i;\n    rows = MIN(rows, (long) ptr->first_undef_row - thisrow);\n    /* Transfer no more than fits in file */\n    rows = MIN(rows, (long) ptr->rows_in_array - thisrow);\n    if (rows <= 0)\t\t/* this chunk might be past end of file! */\n      break;\n    byte_count = rows * bytesperrow;\n    if (writing)\n      (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info,\n\t\t\t\t\t    (void FAR *) ptr->mem_buffer[i],\n\t\t\t\t\t    file_offset, byte_count);\n    else\n      (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info,\n\t\t\t\t\t   (void FAR *) ptr->mem_buffer[i],\n\t\t\t\t\t   file_offset, byte_count);\n    file_offset += byte_count;\n  }\n}\n\n\nMETHODDEF JSAMPARRAY\naccess_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,\n\t\t    JDIMENSION start_row, JDIMENSION num_rows,\n\t\t    boolean writable)\n/* Access the part of a virtual sample array starting at start_row */\n/* and extending for num_rows rows.  writable is true if  */\n/* caller intends to modify the accessed area. */\n{\n  JDIMENSION end_row = start_row + num_rows;\n  JDIMENSION undef_row;\n\n  /* debugging check */\n  if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess ||\n      ptr->mem_buffer == NULL)\n    ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);\n\n  /* Make the desired part of the virtual array accessible */\n  if (start_row < ptr->cur_start_row ||\n      end_row > ptr->cur_start_row+ptr->rows_in_mem) {\n    if (! ptr->b_s_open)\n      ERREXIT(cinfo, JERR_VIRTUAL_BUG);\n    /* Flush old buffer contents if necessary */\n    if (ptr->dirty) {\n      do_sarray_io(cinfo, ptr, TRUE);\n      ptr->dirty = FALSE;\n    }\n    /* Decide what part of virtual array to access.\n     * Algorithm: if target address > current window, assume forward scan,\n     * load starting at target address.  If target address < current window,\n     * assume backward scan, load so that target area is top of window.\n     * Note that when switching from forward write to forward read, will have\n     * start_row = 0, so the limiting case applies and we load from 0 anyway.\n     */\n    if (start_row > ptr->cur_start_row) {\n      ptr->cur_start_row = start_row;\n    } else {\n      /* use long arithmetic here to avoid overflow & unsigned problems */\n      long ltemp;\n\n      ltemp = (long) end_row - (long) ptr->rows_in_mem;\n      if (ltemp < 0)\n\tltemp = 0;\t\t/* don't fall off front end of file */\n      ptr->cur_start_row = (JDIMENSION) ltemp;\n    }\n    /* Read in the selected part of the array.\n     * During the initial write pass, we will do no actual read\n     * because the selected part is all undefined.\n     */\n    do_sarray_io(cinfo, ptr, FALSE);\n  }\n  /* Ensure the accessed part of the array is defined; prezero if needed.\n   * To improve locality of access, we only prezero the part of the array\n   * that the caller is about to access, not the entire in-memory array.\n   */\n  if (ptr->first_undef_row < end_row) {\n    if (ptr->first_undef_row < start_row) {\n      if (writable)\t\t/* writer skipped over a section of array */\n\tERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);\n      undef_row = start_row;\t/* but reader is allowed to read ahead */\n    } else {\n      undef_row = ptr->first_undef_row;\n    }\n    if (writable)\n      ptr->first_undef_row = end_row;\n    if (ptr->pre_zero) {\n      size_t bytesperrow = (size_t) ptr->samplesperrow * SIZEOF(JSAMPLE);\n      undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */\n      end_row -= ptr->cur_start_row;\n      while (undef_row < end_row) {\n\tjzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow);\n\tundef_row++;\n      }\n    } else {\n      if (! writable)\t\t/* reader looking at undefined data */\n\tERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);\n    }\n  }\n  /* Flag the buffer dirty if caller will write in it */\n  if (writable)\n    ptr->dirty = TRUE;\n  /* Return address of proper part of the buffer */\n  return ptr->mem_buffer + (start_row - ptr->cur_start_row);\n}\n\n\nMETHODDEF JBLOCKARRAY\naccess_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,\n\t\t    JDIMENSION start_row, JDIMENSION num_rows,\n\t\t    boolean writable)\n/* Access the part of a virtual block array starting at start_row */\n/* and extending for num_rows rows.  writable is true if  */\n/* caller intends to modify the accessed area. */\n{\n  JDIMENSION end_row = start_row + num_rows;\n  JDIMENSION undef_row;\n\n  /* debugging check */\n  if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess ||\n      ptr->mem_buffer == NULL)\n    ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);\n\n  /* Make the desired part of the virtual array accessible */\n  if (start_row < ptr->cur_start_row ||\n      end_row > ptr->cur_start_row+ptr->rows_in_mem) {\n    if (! ptr->b_s_open)\n      ERREXIT(cinfo, JERR_VIRTUAL_BUG);\n    /* Flush old buffer contents if necessary */\n    if (ptr->dirty) {\n      do_barray_io(cinfo, ptr, TRUE);\n      ptr->dirty = FALSE;\n    }\n    /* Decide what part of virtual array to access.\n     * Algorithm: if target address > current window, assume forward scan,\n     * load starting at target address.  If target address < current window,\n     * assume backward scan, load so that target area is top of window.\n     * Note that when switching from forward write to forward read, will have\n     * start_row = 0, so the limiting case applies and we load from 0 anyway.\n     */\n    if (start_row > ptr->cur_start_row) {\n      ptr->cur_start_row = start_row;\n    } else {\n      /* use long arithmetic here to avoid overflow & unsigned problems */\n      long ltemp;\n\n      ltemp = (long) end_row - (long) ptr->rows_in_mem;\n      if (ltemp < 0)\n\tltemp = 0;\t\t/* don't fall off front end of file */\n      ptr->cur_start_row = (JDIMENSION) ltemp;\n    }\n    /* Read in the selected part of the array.\n     * During the initial write pass, we will do no actual read\n     * because the selected part is all undefined.\n     */\n    do_barray_io(cinfo, ptr, FALSE);\n  }\n  /* Ensure the accessed part of the array is defined; prezero if needed.\n   * To improve locality of access, we only prezero the part of the array\n   * that the caller is about to access, not the entire in-memory array.\n   */\n  if (ptr->first_undef_row < end_row) {\n    if (ptr->first_undef_row < start_row) {\n      if (writable)\t\t/* writer skipped over a section of array */\n\tERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);\n      undef_row = start_row;\t/* but reader is allowed to read ahead */\n    } else {\n      undef_row = ptr->first_undef_row;\n    }\n    if (writable)\n      ptr->first_undef_row = end_row;\n    if (ptr->pre_zero) {\n      size_t bytesperrow = (size_t) ptr->blocksperrow * SIZEOF(JBLOCK);\n      undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */\n      end_row -= ptr->cur_start_row;\n      while (undef_row < end_row) {\n\tjzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow);\n\tundef_row++;\n      }\n    } else {\n      if (! writable)\t\t/* reader looking at undefined data */\n\tERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS);\n    }\n  }\n  /* Flag the buffer dirty if caller will write in it */\n  if (writable)\n    ptr->dirty = TRUE;\n  /* Return address of proper part of the buffer */\n  return ptr->mem_buffer + (start_row - ptr->cur_start_row);\n}\n\n\n/*\n * Release all objects belonging to a specified pool.\n */\n\nMETHODDEF void\nfree_pool (j_common_ptr cinfo, int pool_id)\n{\n  my_mem_ptr mem = (my_mem_ptr) cinfo->mem;\n  small_pool_ptr shdr_ptr;\n  large_pool_ptr lhdr_ptr;\n  size_t space_freed;\n\n  if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS)\n    ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id);\t/* safety check */\n\n#ifdef MEM_STATS\n  if (cinfo->err->trace_level > 1)\n    print_mem_stats(cinfo, pool_id); /* print pool's memory usage statistics */\n#endif\n\n  /* If freeing IMAGE pool, close any virtual arrays first */\n  if (pool_id == JPOOL_IMAGE) {\n    jvirt_sarray_ptr sptr;\n    jvirt_barray_ptr bptr;\n\n    for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {\n      if (sptr->b_s_open) {\t/* there may be no backing store */\n\tsptr->b_s_open = FALSE;\t/* prevent recursive close if error */\n\t(*sptr->b_s_info.close_backing_store) (cinfo, & sptr->b_s_info);\n      }\n    }\n    mem->virt_sarray_list = NULL;\n    for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {\n      if (bptr->b_s_open) {\t/* there may be no backing store */\n\tbptr->b_s_open = FALSE;\t/* prevent recursive close if error */\n\t(*bptr->b_s_info.close_backing_store) (cinfo, & bptr->b_s_info);\n      }\n    }\n    mem->virt_barray_list = NULL;\n  }\n\n  /* Release large objects */\n  lhdr_ptr = mem->large_list[pool_id];\n  mem->large_list[pool_id] = NULL;\n\n  while (lhdr_ptr != NULL) {\n    large_pool_ptr next_lhdr_ptr = lhdr_ptr->hdr.next;\n    space_freed = lhdr_ptr->hdr.bytes_used +\n\t\t  lhdr_ptr->hdr.bytes_left +\n\t\t  SIZEOF(large_pool_hdr);\n    jpeg_free_large(cinfo, (void FAR *) lhdr_ptr, space_freed);\n    mem->total_space_allocated -= space_freed;\n    lhdr_ptr = next_lhdr_ptr;\n  }\n\n  /* Release small objects */\n  shdr_ptr = mem->small_list[pool_id];\n  mem->small_list[pool_id] = NULL;\n\n  while (shdr_ptr != NULL) {\n    small_pool_ptr next_shdr_ptr = shdr_ptr->hdr.next;\n    space_freed = shdr_ptr->hdr.bytes_used +\n\t\t  shdr_ptr->hdr.bytes_left +\n\t\t  SIZEOF(small_pool_hdr);\n    jpeg_free_small(cinfo, (void *) shdr_ptr, space_freed);\n    mem->total_space_allocated -= space_freed;\n    shdr_ptr = next_shdr_ptr;\n  }\n}\n\n\n/*\n * Close up shop entirely.\n * Note that this cannot be called unless cinfo->mem is non-NULL.\n */\n\nMETHODDEF void\nself_destruct (j_common_ptr cinfo)\n{\n  int pool;\n\n  /* Close all backing store, release all memory.\n   * Releasing pools in reverse order might help avoid fragmentation\n   * with some (brain-damaged) malloc libraries.\n   */\n  for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) {\n    free_pool(cinfo, pool);\n  }\n\n  /* Release the memory manager control block too. */\n  jpeg_free_small(cinfo, (void *) cinfo->mem, SIZEOF(my_memory_mgr));\n  cinfo->mem = NULL;\t\t/* ensures I will be called only once */\n\n  jpeg_mem_term(cinfo);\t\t/* system-dependent cleanup */\n}\n\n\n/*\n * Memory manager initialization.\n * When this is called, only the error manager pointer is valid in cinfo!\n */\n\nGLOBAL void\njinit_memory_mgr (j_common_ptr cinfo)\n{\n  my_mem_ptr mem;\n  long max_to_use;\n  int pool;\n  size_t test_mac;\n\n  cinfo->mem = NULL;\t\t/* for safety if init fails */\n\n  /* Check for configuration errors.\n   * SIZEOF(ALIGN_TYPE) should be a power of 2; otherwise, it probably\n   * doesn't reflect any real hardware alignment requirement.\n   * The test is a little tricky: for X>0, X and X-1 have no one-bits\n   * in common if and only if X is a power of 2, ie has only one one-bit.\n   * Some compilers may give an \"unreachable code\" warning here; ignore it.\n   */\n  if ((SIZEOF(ALIGN_TYPE) & (SIZEOF(ALIGN_TYPE)-1)) != 0)\n    ERREXIT(cinfo, JERR_BAD_ALIGN_TYPE);\n  /* MAX_ALLOC_CHUNK must be representable as type size_t, and must be\n   * a multiple of SIZEOF(ALIGN_TYPE).\n   * Again, an \"unreachable code\" warning may be ignored here.\n   * But a \"constant too large\" warning means you need to fix MAX_ALLOC_CHUNK.\n   */\n  test_mac = (size_t) MAX_ALLOC_CHUNK;\n  if ((long) test_mac != MAX_ALLOC_CHUNK ||\n      (MAX_ALLOC_CHUNK % SIZEOF(ALIGN_TYPE)) != 0)\n    ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK);\n\n  max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */\n\n  /* Attempt to allocate memory manager's control block */\n  mem = (my_mem_ptr) jpeg_get_small(cinfo, SIZEOF(my_memory_mgr));\n\n  if (mem == NULL) {\n    jpeg_mem_term(cinfo);\t/* system-dependent cleanup */\n    ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 0);\n  }\n\n  /* OK, fill in the method pointers */\n  mem->pub.alloc_small = alloc_small;\n  mem->pub.alloc_large = alloc_large;\n  mem->pub.alloc_sarray = alloc_sarray;\n  mem->pub.alloc_barray = alloc_barray;\n  mem->pub.request_virt_sarray = request_virt_sarray;\n  mem->pub.request_virt_barray = request_virt_barray;\n  mem->pub.realize_virt_arrays = realize_virt_arrays;\n  mem->pub.access_virt_sarray = access_virt_sarray;\n  mem->pub.access_virt_barray = access_virt_barray;\n  mem->pub.free_pool = free_pool;\n  mem->pub.self_destruct = self_destruct;\n\n  /* Initialize working state */\n  mem->pub.max_memory_to_use = max_to_use;\n\n  for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) {\n    mem->small_list[pool] = NULL;\n    mem->large_list[pool] = NULL;\n  }\n  mem->virt_sarray_list = NULL;\n  mem->virt_barray_list = NULL;\n\n  mem->total_space_allocated = SIZEOF(my_memory_mgr);\n\n  /* Declare ourselves open for business */\n  cinfo->mem = & mem->pub;\n\n  /* Check for an environment variable JPEGMEM; if found, override the\n   * default max_memory setting from jpeg_mem_init.  Note that the\n   * surrounding application may again override this value.\n   * If your system doesn't support getenv(), define NO_GETENV to disable\n   * this feature.\n   */\n#ifndef NO_GETENV\n  { char * memenv;\n\n    if ((memenv = getenv(\"JPEGMEM\")) != NULL) {\n      char ch = 'x';\n\n      if (sscanf(memenv, \"%ld%c\", &max_to_use, &ch) > 0) {\n\tif (ch == 'm' || ch == 'M')\n\t  max_to_use *= 1000L;\n\tmem->pub.max_memory_to_use = max_to_use * 1000L;\n      }\n    }\n  }\n#endif\n\n}\n"
  },
  {
    "path": "libs/jpeg6/jmemnobs.cpp",
    "content": "/*\n * jmemnobs.c\n *\n * Copyright (C) 1992-1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file provides a really simple implementation of the system-\n * dependent portion of the JPEG memory manager.  This implementation\n * assumes that no backing-store files are needed: all required space\n * can be obtained from ri.Malloc().\n * This is very portable in the sense that it'll compile on almost anything,\n * but you'd better have lots of main memory (or virtual memory) if you want\n * to process big images.\n * Note that the max_memory_to_use option is ignored by this implementation.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n#include \"jmemsys.h\"\t\t/* import the system-dependent declarations */\n\n/*\n * Memory allocation and ri.Freeing are controlled by the regular library\n * routines ri.Malloc() and ri.Free().\n */\n\nGLOBAL void *\njpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)\n{\n  return (void *) malloc(sizeofobject);\n}\n\nGLOBAL void\njpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)\n{\n  free(object);\n}\n\n\n/*\n * \"Large\" objects are treated the same as \"small\" ones.\n * NB: although we include FAR keywords in the routine declarations,\n * this file won't actually work in 80x86 small/medium model; at least,\n * you probably won't be able to process useful-size images in only 64KB.\n */\n\nGLOBAL void FAR *\njpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)\n{\n  return (void FAR *) malloc(sizeofobject);\n}\n\nGLOBAL void\njpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)\n{\n  free(object);\n}\n\n\n/*\n * This routine computes the total memory space available for allocation.\n * Here we always say, \"we got all you want bud!\"\n */\n\nGLOBAL long\njpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,\n\t\t    long max_bytes_needed, long already_allocated)\n{\n  return max_bytes_needed;\n}\n\n\n/*\n * Backing store (temporary file) management.\n * Since jpeg_mem_available always promised the moon,\n * this should never be called and we can just error out.\n */\n\nGLOBAL void\njpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,\n\t\t\t long total_bytes_needed)\n{\n  ERREXIT(cinfo, JERR_NO_BACKING_STORE);\n}\n\n\n/*\n * These routines take care of any system-dependent initialization and\n * cleanup required.  Here, there isn't any.\n */\n\nGLOBAL long\njpeg_mem_init (j_common_ptr cinfo)\n{\n  return 0;\t\t\t/* just set max_memory_to_use to 0 */\n}\n\nGLOBAL void\njpeg_mem_term (j_common_ptr cinfo)\n{\n  /* no work */\n}\n"
  },
  {
    "path": "libs/jpeg6/jmemsys.h",
    "content": "/*\n * jmemsys.h\n *\n * Copyright (C) 1992-1994, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This include file defines the interface between the system-independent\n * and system-dependent portions of the JPEG memory manager.  No other\n * modules need include it.  (The system-independent portion is jmemmgr.c;\n * there are several different versions of the system-dependent portion.)\n *\n * This file works as-is for the system-dependent memory managers supplied\n * in the IJG distribution.  You may need to modify it if you write a\n * custom memory manager.  If system-dependent changes are needed in\n * this file, the best method is to #ifdef them based on a configuration\n * symbol supplied in jconfig.h, as we have done with USE_MSDOS_MEMMGR.\n */\n\n\n/* Short forms of external names for systems with brain-damaged linkers. */\n\n#ifdef NEED_SHORT_EXTERNAL_NAMES\n#define jpeg_get_small\t\tjGetSmall\n#define jpeg_free_small\t\tjFreeSmall\n#define jpeg_get_large\t\tjGetLarge\n#define jpeg_free_large\t\tjFreeLarge\n#define jpeg_mem_available\tjMemAvail\n#define jpeg_open_backing_store\tjOpenBackStore\n#define jpeg_mem_init\t\tjMemInit\n#define jpeg_mem_term\t\tjMemTerm\n#endif /* NEED_SHORT_EXTERNAL_NAMES */\n\n\n/*\n * These two functions are used to allocate and release small chunks of\n * memory.  (Typically the total amount requested through jpeg_get_small is\n * no more than 20K or so; this will be requested in chunks of a few K each.)\n * Behavior should be the same as for the standard library functions malloc\n * and free; in particular, jpeg_get_small must return NULL on failure.\n * On most systems, these ARE malloc and free.  jpeg_free_small is passed the\n * size of the object being freed, just in case it's needed.\n * On an 80x86 machine using small-data memory model, these manage near heap.\n */\n\nEXTERN void * jpeg_get_small JPP((j_common_ptr cinfo, size_t sizeofobject));\nEXTERN void jpeg_free_small JPP((j_common_ptr cinfo, void * object,\n\t\t\t\t size_t sizeofobject));\n\n/*\n * These two functions are used to allocate and release large chunks of\n * memory (up to the total free space designated by jpeg_mem_available).\n * The interface is the same as above, except that on an 80x86 machine,\n * far pointers are used.  On most other machines these are identical to\n * the jpeg_get/free_small routines; but we keep them separate anyway,\n * in case a different allocation strategy is desirable for large chunks.\n */\n\nEXTERN void FAR * jpeg_get_large JPP((j_common_ptr cinfo,size_t sizeofobject));\nEXTERN void jpeg_free_large JPP((j_common_ptr cinfo, void FAR * object,\n\t\t\t\t size_t sizeofobject));\n\n/*\n * The macro MAX_ALLOC_CHUNK designates the maximum number of bytes that may\n * be requested in a single call to jpeg_get_large (and jpeg_get_small for that\n * matter, but that case should never come into play).  This macro is needed\n * to model the 64Kb-segment-size limit of far addressing on 80x86 machines.\n * On those machines, we expect that jconfig.h will provide a proper value.\n * On machines with 32-bit flat address spaces, any large constant may be used.\n *\n * NB: jmemmgr.c expects that MAX_ALLOC_CHUNK will be representable as type\n * size_t and will be a multiple of sizeof(align_type).\n */\n\n#ifndef MAX_ALLOC_CHUNK\t\t/* may be overridden in jconfig.h */\n#define MAX_ALLOC_CHUNK  1000000000L\n#endif\n\n/*\n * This routine computes the total space still available for allocation by\n * jpeg_get_large.  If more space than this is needed, backing store will be\n * used.  NOTE: any memory already allocated must not be counted.\n *\n * There is a minimum space requirement, corresponding to the minimum\n * feasible buffer sizes; jmemmgr.c will request that much space even if\n * jpeg_mem_available returns zero.  The maximum space needed, enough to hold\n * all working storage in memory, is also passed in case it is useful.\n * Finally, the total space already allocated is passed.  If no better\n * method is available, cinfo->mem->max_memory_to_use - already_allocated\n * is often a suitable calculation.\n *\n * It is OK for jpeg_mem_available to underestimate the space available\n * (that'll just lead to more backing-store access than is really necessary).\n * However, an overestimate will lead to failure.  Hence it's wise to subtract\n * a slop factor from the true available space.  5% should be enough.\n *\n * On machines with lots of virtual memory, any large constant may be returned.\n * Conversely, zero may be returned to always use the minimum amount of memory.\n */\n\nEXTERN long jpeg_mem_available JPP((j_common_ptr cinfo,\n\t\t\t\t    long min_bytes_needed,\n\t\t\t\t    long max_bytes_needed,\n\t\t\t\t    long already_allocated));\n\n\n/*\n * This structure holds whatever state is needed to access a single\n * backing-store object.  The read/write/close method pointers are called\n * by jmemmgr.c to manipulate the backing-store object; all other fields\n * are private to the system-dependent backing store routines.\n */\n\n#define TEMP_NAME_LENGTH   64\t/* max length of a temporary file's name */\n\n#ifdef USE_MSDOS_MEMMGR\t\t/* DOS-specific junk */\n\ntypedef unsigned short XMSH;\t/* type of extended-memory handles */\ntypedef unsigned short EMSH;\t/* type of expanded-memory handles */\n\ntypedef union {\n  short file_handle;\t\t/* DOS file handle if it's a temp file */\n  XMSH xms_handle;\t\t/* handle if it's a chunk of XMS */\n  EMSH ems_handle;\t\t/* handle if it's a chunk of EMS */\n} handle_union;\n\n#endif /* USE_MSDOS_MEMMGR */\n\ntypedef struct backing_store_struct * backing_store_ptr;\n\ntypedef struct backing_store_struct {\n  /* Methods for reading/writing/closing this backing-store object */\n  JMETHOD(void, read_backing_store, (j_common_ptr cinfo,\n\t\t\t\t     backing_store_ptr info,\n\t\t\t\t     void FAR * buffer_address,\n\t\t\t\t     long file_offset, long byte_count));\n  JMETHOD(void, write_backing_store, (j_common_ptr cinfo,\n\t\t\t\t      backing_store_ptr info,\n\t\t\t\t      void FAR * buffer_address,\n\t\t\t\t      long file_offset, long byte_count));\n  JMETHOD(void, close_backing_store, (j_common_ptr cinfo,\n\t\t\t\t      backing_store_ptr info));\n\n  /* Private fields for system-dependent backing-store management */\n#ifdef USE_MSDOS_MEMMGR\n  /* For the MS-DOS manager (jmemdos.c), we need: */\n  handle_union handle;\t\t/* reference to backing-store storage object */\n  char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */\n#else\n  /* For a typical implementation with temp files, we need: */\n  FILE * temp_file;\t\t/* stdio reference to temp file */\n  char temp_name[TEMP_NAME_LENGTH]; /* name of temp file */\n#endif\n} backing_store_info;\n\n/*\n * Initial opening of a backing-store object.  This must fill in the\n * read/write/close pointers in the object.  The read/write routines\n * may take an error exit if the specified maximum file size is exceeded.\n * (If jpeg_mem_available always returns a large value, this routine can\n * just take an error exit.)\n */\n\nEXTERN void jpeg_open_backing_store JPP((j_common_ptr cinfo,\n\t\t\t\t\t backing_store_ptr info,\n\t\t\t\t\t long total_bytes_needed));\n\n\n/*\n * These routines take care of any system-dependent initialization and\n * cleanup required.  jpeg_mem_init will be called before anything is\n * allocated (and, therefore, nothing in cinfo is of use except the error\n * manager pointer).  It should return a suitable default value for\n * max_memory_to_use; this may subsequently be overridden by the surrounding\n * application.  (Note that max_memory_to_use is only important if\n * jpeg_mem_available chooses to consult it ... no one else will.)\n * jpeg_mem_term may assume that all requested memory has been freed and that\n * all opened backing-store objects have been closed.\n */\n\nEXTERN long jpeg_mem_init JPP((j_common_ptr cinfo));\nEXTERN void jpeg_mem_term JPP((j_common_ptr cinfo));\n"
  },
  {
    "path": "libs/jpeg6/jmorecfg.h",
    "content": "/*\n * jmorecfg.h\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains additional configuration options that customize the\n * JPEG software for special applications or support machine-dependent\n * optimizations.  Most users will not need to touch this file.\n */\n\n\n/*\n * Define BITS_IN_JSAMPLE as either\n *   8   for 8-bit sample values (the usual setting)\n *   12  for 12-bit sample values\n * Only 8 and 12 are legal data precisions for lossy JPEG according to the\n * JPEG standard, and the IJG code does not support anything else!\n * We do not support run-time selection of data precision, sorry.\n */\n\n#define BITS_IN_JSAMPLE  8\t/* use 8 or 12 */\n\n\n/*\n * Maximum number of components (color channels) allowed in JPEG image.\n * To meet the letter of the JPEG spec, set this to 255.  However, darn\n * few applications need more than 4 channels (maybe 5 for CMYK + alpha\n * mask).  We recommend 10 as a reasonable compromise; use 4 if you are\n * really short on memory.  (Each allowed component costs a hundred or so\n * bytes of storage, whether actually used in an image or not.)\n */\n\n#define MAX_COMPONENTS  10\t/* maximum number of image components */\n\n\n/*\n * Basic data types.\n * You may need to change these if you have a machine with unusual data\n * type sizes; for example, \"char\" not 8 bits, \"short\" not 16 bits,\n * or \"long\" not 32 bits.  We don't care whether \"int\" is 16 or 32 bits,\n * but it had better be at least 16.\n */\n\n/* Representation of a single sample (pixel element value).\n * We frequently allocate large arrays of these, so it's important to keep\n * them small.  But if you have memory to burn and access to char or short\n * arrays is very slow on your hardware, you might want to change these.\n */\n\n#if BITS_IN_JSAMPLE == 8\n/* JSAMPLE should be the smallest type that will hold the values 0..255.\n * You can use a signed char by having GETJSAMPLE mask it with 0xFF.\n */\n\n#ifdef HAVE_UNSIGNED_CHAR\n\ntypedef unsigned char JSAMPLE;\n#define GETJSAMPLE(value)  ((int) (value))\n\n#else /* not HAVE_UNSIGNED_CHAR */\n\ntypedef char JSAMPLE;\n#ifdef CHAR_IS_UNSIGNED\n#define GETJSAMPLE(value)  ((int) (value))\n#else\n#define GETJSAMPLE(value)  ((int) (value) & 0xFF)\n#endif /* CHAR_IS_UNSIGNED */\n\n#endif /* HAVE_UNSIGNED_CHAR */\n\n#define MAXJSAMPLE\t255\n#define CENTERJSAMPLE\t128\n\n#endif /* BITS_IN_JSAMPLE == 8 */\n\n\n#if BITS_IN_JSAMPLE == 12\n/* JSAMPLE should be the smallest type that will hold the values 0..4095.\n * On nearly all machines \"short\" will do nicely.\n */\n\ntypedef short JSAMPLE;\n#define GETJSAMPLE(value)  ((int) (value))\n\n#define MAXJSAMPLE\t4095\n#define CENTERJSAMPLE\t2048\n\n#endif /* BITS_IN_JSAMPLE == 12 */\n\n\n/* Representation of a DCT frequency coefficient.\n * This should be a signed value of at least 16 bits; \"short\" is usually OK.\n * Again, we allocate large arrays of these, but you can change to int\n * if you have memory to burn and \"short\" is really slow.\n */\n\ntypedef short JCOEF;\n\n\n/* Compressed datastreams are represented as arrays of JOCTET.\n * These must be EXACTLY 8 bits wide, at least once they are written to\n * external storage.  Note that when using the stdio data source/destination\n * managers, this is also the data type passed to fread/fwrite.\n */\n\n#ifdef HAVE_UNSIGNED_CHAR\n\ntypedef unsigned char JOCTET;\n#define GETJOCTET(value)  (value)\n\n#else /* not HAVE_UNSIGNED_CHAR */\n\ntypedef char JOCTET;\n#ifdef CHAR_IS_UNSIGNED\n#define GETJOCTET(value)  (value)\n#else\n#define GETJOCTET(value)  ((value) & 0xFF)\n#endif /* CHAR_IS_UNSIGNED */\n\n#endif /* HAVE_UNSIGNED_CHAR */\n\n\n/* These typedefs are used for various table entries and so forth.\n * They must be at least as wide as specified; but making them too big\n * won't cost a huge amount of memory, so we don't provide special\n * extraction code like we did for JSAMPLE.  (In other words, these\n * typedefs live at a different point on the speed/space tradeoff curve.)\n */\n\n/* UINT8 must hold at least the values 0..255. */\n\n#ifdef HAVE_UNSIGNED_CHAR\ntypedef unsigned char UINT8;\n#else /* not HAVE_UNSIGNED_CHAR */\n#ifdef CHAR_IS_UNSIGNED\ntypedef char UINT8;\n#else /* not CHAR_IS_UNSIGNED */\ntypedef short UINT8;\n#endif /* CHAR_IS_UNSIGNED */\n#endif /* HAVE_UNSIGNED_CHAR */\n\n/* UINT16 must hold at least the values 0..65535. */\n\n#ifdef HAVE_UNSIGNED_SHORT\ntypedef unsigned short UINT16;\n#else /* not HAVE_UNSIGNED_SHORT */\ntypedef unsigned int UINT16;\n#endif /* HAVE_UNSIGNED_SHORT */\n\n/* INT16 must hold at least the values -32768..32767. */\n\n#ifndef XMD_H\t\t\t/* X11/xmd.h correctly defines INT16 */\ntypedef short INT16;\n#endif\n\n/* INT32 must hold at least signed 32-bit values. */\n\n//#ifndef XMD_H\t\t\t/* X11/xmd.h correctly defines INT32 */\n//typedef long INT32;\n//#endif\n\n/* Datatype used for image dimensions.  The JPEG standard only supports\n * images up to 64K*64K due to 16-bit fields in SOF markers.  Therefore\n * \"unsigned int\" is sufficient on all machines.  However, if you need to\n * handle larger images and you don't mind deviating from the spec, you\n * can change this datatype.\n */\n\ntypedef unsigned int JDIMENSION;\n\n#define JPEG_MAX_DIMENSION  65500L  /* a tad under 64K to prevent overflows */\n\n\n/* These defines are used in all function definitions and extern declarations.\n * You could modify them if you need to change function linkage conventions.\n * Another application is to make all functions global for use with debuggers\n * or code profilers that require it.\n */\n\n#define METHODDEF static\t/* a function called through method pointers */\n#define LOCAL\t  static\t/* a function used only in its module */\n#define GLOBAL\t\t\t/* a function referenced thru EXTERNs */\n#define EXTERN\t  extern\t/* a reference to a GLOBAL function */\n\n\n/* Here is the pseudo-keyword for declaring pointers that must be \"far\"\n * on 80x86 machines.  Most of the specialized coding for 80x86 is handled\n * by just saying \"FAR *\" where such a pointer is needed.  In a few places\n * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol.\n */\n\n#ifdef NEED_FAR_POINTERS\n#undef FAR\n#define FAR  far\n#else\n#undef FAR\n#define FAR\n#endif\n\n\n/*\n * On a few systems, type boolean and/or its values FALSE, TRUE may appear\n * in standard header files.  Or you may have conflicts with application-\n * specific header files that you want to include together with these files.\n * Defining HAVE_BOOLEAN before including jpeglib.h should make it work.\n */\n\n//#ifndef HAVE_BOOLEAN\n//typedef int boolean;\n//#endif\n#ifndef FALSE\t\t\t/* in case these macros already exist */\n#define FALSE\t0\t\t/* values of boolean */\n#endif\n#ifndef TRUE\n#define TRUE\t1\n#endif\n\n\n/*\n * The remaining options affect code selection within the JPEG library,\n * but they don't need to be visible to most applications using the library.\n * To minimize application namespace pollution, the symbols won't be\n * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.\n */\n\n#ifdef JPEG_INTERNALS\n#define JPEG_INTERNAL_OPTIONS\n#endif\n\n#ifdef JPEG_INTERNAL_OPTIONS\n\n\n/*\n * These defines indicate whether to include various optional functions.\n * Undefining some of these symbols will produce a smaller but less capable\n * library.  Note that you can leave certain source files out of the\n * compilation/linking process if you've #undef'd the corresponding symbols.\n * (You may HAVE to do that if your compiler doesn't like null source files.)\n */\n\n/* Arithmetic coding is unsupported for legal reasons.  Complaints to IBM. */\n\n/* Capability options common to encoder and decoder: */\n\n#undef DCT_ISLOW_SUPPORTED\t/* slow but accurate integer algorithm */\n#undef DCT_IFAST_SUPPORTED\t/* faster, less accurate integer method */\n#define DCT_FLOAT_SUPPORTED\t/* floating-point: accurate, fast on fast HW */\n\n/* Encoder capability options: */\n\n#undef  C_ARITH_CODING_SUPPORTED    /* Arithmetic coding back end? */\n#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */\n#define C_PROGRESSIVE_SUPPORTED\t    /* Progressive JPEG? (Requires MULTISCAN)*/\n#define ENTROPY_OPT_SUPPORTED\t    /* Optimization of entropy coding parms? */\n/* Note: if you selected 12-bit data precision, it is dangerous to turn off\n * ENTROPY_OPT_SUPPORTED.  The standard Huffman tables are only good for 8-bit\n * precision, so jchuff.c normally uses entropy optimization to compute\n * usable tables for higher precision.  If you don't want to do optimization,\n * you'll have to supply different default Huffman tables.\n * The exact same statements apply for progressive JPEG: the default tables\n * don't work for progressive mode.  (This may get fixed, however.)\n */\n#define INPUT_SMOOTHING_SUPPORTED   /* Input image smoothing option? */\n\n/* Decoder capability options: */\n\n#undef  D_ARITH_CODING_SUPPORTED    /* Arithmetic coding back end? */\n#undef D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */\n#undef D_PROGRESSIVE_SUPPORTED\t    /* Progressive JPEG? (Requires MULTISCAN)*/\n#undef BLOCK_SMOOTHING_SUPPORTED   /* Block smoothing? (Progressive only) */\n#undef IDCT_SCALING_SUPPORTED\t    /* Output rescaling via IDCT? */\n#undef  UPSAMPLE_SCALING_SUPPORTED  /* Output rescaling at upsample stage? */\n#undef UPSAMPLE_MERGING_SUPPORTED  /* Fast path for sloppy upsampling? */\n#undef QUANT_1PASS_SUPPORTED\t    /* 1-pass color quantization? */\n#undef QUANT_2PASS_SUPPORTED\t    /* 2-pass color quantization? */\n\n/* more capability options later, no doubt */\n\n\n/*\n * Ordering of RGB data in scanlines passed to or from the application.\n * If your application wants to deal with data in the order B,G,R, just\n * change these macros.  You can also deal with formats such as R,G,B,X\n * (one extra byte per pixel) by changing RGB_PIXELSIZE.  Note that changing\n * the offsets will also change the order in which colormap data is organized.\n * RESTRICTIONS:\n * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.\n * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not\n *    useful if you are using JPEG color spaces other than YCbCr or grayscale.\n * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE\n *    is not 3 (they don't understand about dummy color components!).  So you\n *    can't use color quantization if you change that value.\n */\n\n#define RGB_RED\t\t0\t/* Offset of Red in an RGB scanline element */\n#define RGB_GREEN\t1\t/* Offset of Green */\n#define RGB_BLUE\t2\t/* Offset of Blue */\n#define RGB_PIXELSIZE\t4\t/* JSAMPLEs per RGB scanline element */\n\n\n/* Definitions for speed-related optimizations. */\n\n\n/* If your compiler supports inline functions, define INLINE\n * as the inline keyword; otherwise define it as empty.\n */\n\n#ifndef INLINE\n#ifdef __GNUC__\t\t\t/* for instance, GNU C knows about inline */\n#define INLINE __inline__\n#endif\n#ifndef INLINE\n#define INLINE\t\t\t/* default is to define it as empty */\n#endif\n#endif\n\n\n/* On some machines (notably 68000 series) \"int\" is 32 bits, but multiplying\n * two 16-bit shorts is faster than multiplying two ints.  Define MULTIPLIER\n * as short on such a machine.  MULTIPLIER must be at least 16 bits wide.\n */\n\n#ifndef MULTIPLIER\n#define MULTIPLIER  int\t\t/* type for fastest integer multiply */\n#endif\n\n\n/* FAST_FLOAT should be either float or double, whichever is done faster\n * by your compiler.  (Note that this type is only used in the floating point\n * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)\n * Typically, float is faster in ANSI C compilers, while double is faster in\n * pre-ANSI compilers (because they insist on converting to double anyway).\n * The code below therefore chooses float if we have ANSI-style prototypes.\n */\n\n#ifndef FAST_FLOAT\n#ifdef HAVE_PROTOTYPES\n#define FAST_FLOAT  float\n#else\n#define FAST_FLOAT  double\n#endif\n#endif\n\n#endif /* JPEG_INTERNAL_OPTIONS */\n"
  },
  {
    "path": "libs/jpeg6/jpeg6.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<VisualStudioProject\n\tProjectType=\"Visual C++\"\n\tVersion=\"7.10\"\n\tName=\"jpeg6\"\n\tSccProjectName=\"&quot;$/source/q3radiant&quot;, FEFAAAAA\"\n\tSccLocalPath=\"..\\..\\q3radiant\">\n\t<Platforms>\n\t\t<Platform\n\t\t\tName=\"Win32\"/>\n\t</Platforms>\n\t<Configurations>\n\t\t<Configuration\n\t\t\tName=\"Release|Win32\"\n\t\t\tOutputDirectory=\".\\Release\"\n\t\t\tIntermediateDirectory=\".\\Release\"\n\t\t\tConfigurationType=\"4\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tAdditionalIncludeDirectories=\"..\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_LIB\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"0\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tRuntimeTypeInfo=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release/jpeg6.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release/\"\n\t\t\t\tObjectFile=\".\\Release/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tCompileAs=\"0\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLibrarianTool\"\n\t\t\t\tOutputFile=\"..\\jpeg6.lib\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Debug|Win32\"\n\t\t\tOutputDirectory=\".\\Debug\"\n\t\t\tIntermediateDirectory=\".\\Debug\"\n\t\t\tConfigurationType=\"4\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tAdditionalIncludeDirectories=\"..\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_LIB\"\n\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tRuntimeTypeInfo=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Debug/jpeg6.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug/\"\n\t\t\t\tObjectFile=\".\\Debug/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Debug/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"\n\t\t\t\tCompileAs=\"0\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLibrarianTool\"\n\t\t\t\tOutputFile=\"..\\jpeg6d.lib\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t</Configurations>\n\t<References>\n\t</References>\n\t<Files>\n\t\t<Filter\n\t\t\tName=\"Source Files\"\n\t\t\tFilter=\"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"jcomapi.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jdapimin.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jdapistd.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jdatasrc.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jdcoefct.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jdcolor.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jddctmgr.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jdhuff.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jdinput.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jdmainct.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jdmarker.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jdmaster.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jdpostct.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jdsample.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jdtrans.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jerror.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jfdctflt.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jidctflt.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jmemmgr.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jmemnobs.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jpgload.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jutils.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Header Files\"\n\t\t\tFilter=\"h;hpp;hxx;hm;inl\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"jchuff.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jconfig.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jdct.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jdhuff.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jerror.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jinclude.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jmemsys.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jmorecfg.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jpegint.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"jversion.h\">\n\t\t\t</File>\n\t\t</Filter>\n\t</Files>\n\t<Globals>\n\t</Globals>\n</VisualStudioProject>\n"
  },
  {
    "path": "libs/jpeg6/jpegint.h",
    "content": "/*\n * jpegint.h\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file provides common declarations for the various JPEG modules.\n * These declarations are considered internal to the JPEG library; most\n * applications using the library shouldn't need to include this file.\n */\n\n\n/* Declarations for both compression & decompression */\n\ntypedef enum {\t\t\t/* Operating modes for buffer controllers */\n\tJBUF_PASS_THRU,\t\t/* Plain stripwise operation */\n\t/* Remaining modes require a full-image buffer to have been created */\n\tJBUF_SAVE_SOURCE,\t/* Run source subobject only, save output */\n\tJBUF_CRANK_DEST,\t/* Run dest subobject only, using saved data */\n\tJBUF_SAVE_AND_PASS\t/* Run both subobjects, save output */\n} J_BUF_MODE;\n\n/* Values of global_state field (jdapi.c has some dependencies on ordering!) */\n#define CSTATE_START\t100\t/* after create_compress */\n#define CSTATE_SCANNING\t101\t/* start_compress done, write_scanlines OK */\n#define CSTATE_RAW_OK\t102\t/* start_compress done, write_raw_data OK */\n#define CSTATE_WRCOEFS\t103\t/* jpeg_write_coefficients done */\n#define DSTATE_START\t200\t/* after create_decompress */\n#define DSTATE_INHEADER\t201\t/* reading header markers, no SOS yet */\n#define DSTATE_READY\t202\t/* found SOS, ready for start_decompress */\n#define DSTATE_PRELOAD\t203\t/* reading multiscan file in start_decompress*/\n#define DSTATE_PRESCAN\t204\t/* performing dummy pass for 2-pass quant */\n#define DSTATE_SCANNING\t205\t/* start_decompress done, read_scanlines OK */\n#define DSTATE_RAW_OK\t206\t/* start_decompress done, read_raw_data OK */\n#define DSTATE_BUFIMAGE\t207\t/* expecting jpeg_start_output */\n#define DSTATE_BUFPOST\t208\t/* looking for SOS/EOI in jpeg_finish_output */\n#define DSTATE_RDCOEFS\t209\t/* reading file in jpeg_read_coefficients */\n#define DSTATE_STOPPING\t210\t/* looking for EOI in jpeg_finish_decompress */\n\n\n/* Declarations for compression modules */\n\n/* Master control module */\nstruct jpeg_comp_master {\n  JMETHOD(void, prepare_for_pass, (j_compress_ptr cinfo));\n  JMETHOD(void, pass_startup, (j_compress_ptr cinfo));\n  JMETHOD(void, finish_pass, (j_compress_ptr cinfo));\n\n  /* State variables made visible to other modules */\n  boolean call_pass_startup;\t/* True if pass_startup must be called */\n  boolean is_last_pass;\t\t/* True during last pass */\n};\n\n/* Main buffer control (downsampled-data buffer) */\nstruct jpeg_c_main_controller {\n  JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));\n  JMETHOD(void, process_data, (j_compress_ptr cinfo,\n\t\t\t       JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,\n\t\t\t       JDIMENSION in_rows_avail));\n};\n\n/* Compression preprocessing (downsampling input buffer control) */\nstruct jpeg_c_prep_controller {\n  JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));\n  JMETHOD(void, pre_process_data, (j_compress_ptr cinfo,\n\t\t\t\t   JSAMPARRAY input_buf,\n\t\t\t\t   JDIMENSION *in_row_ctr,\n\t\t\t\t   JDIMENSION in_rows_avail,\n\t\t\t\t   JSAMPIMAGE output_buf,\n\t\t\t\t   JDIMENSION *out_row_group_ctr,\n\t\t\t\t   JDIMENSION out_row_groups_avail));\n};\n\n/* Coefficient buffer control */\nstruct jpeg_c_coef_controller {\n  JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));\n  JMETHOD(boolean, compress_data, (j_compress_ptr cinfo,\n\t\t\t\t   JSAMPIMAGE input_buf));\n};\n\n/* Colorspace conversion */\nstruct jpeg_color_converter {\n  JMETHOD(void, start_pass, (j_compress_ptr cinfo));\n  JMETHOD(void, color_convert, (j_compress_ptr cinfo,\n\t\t\t\tJSAMPARRAY input_buf, JSAMPIMAGE output_buf,\n\t\t\t\tJDIMENSION output_row, int num_rows));\n};\n\n/* Downsampling */\nstruct jpeg_downsampler {\n  JMETHOD(void, start_pass, (j_compress_ptr cinfo));\n  JMETHOD(void, downsample, (j_compress_ptr cinfo,\n\t\t\t     JSAMPIMAGE input_buf, JDIMENSION in_row_index,\n\t\t\t     JSAMPIMAGE output_buf,\n\t\t\t     JDIMENSION out_row_group_index));\n\n  boolean need_context_rows;\t/* TRUE if need rows above & below */\n};\n\n/* Forward DCT (also controls coefficient quantization) */\nstruct jpeg_forward_dct {\n  JMETHOD(void, start_pass, (j_compress_ptr cinfo));\n  /* perhaps this should be an array??? */\n  JMETHOD(void, forward_DCT, (j_compress_ptr cinfo,\n\t\t\t      jpeg_component_info * compptr,\n\t\t\t      JSAMPARRAY sample_data, JBLOCKROW coef_blocks,\n\t\t\t      JDIMENSION start_row, JDIMENSION start_col,\n\t\t\t      JDIMENSION num_blocks));\n};\n\n/* Entropy encoding */\nstruct jpeg_entropy_encoder {\n  JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics));\n  JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKROW *MCU_data));\n  JMETHOD(void, finish_pass, (j_compress_ptr cinfo));\n};\n\n/* Marker writing */\nstruct jpeg_marker_writer {\n  /* write_any_marker is exported for use by applications */\n  /* Probably only COM and APPn markers should be written */\n  JMETHOD(void, write_any_marker, (j_compress_ptr cinfo, int marker,\n\t\t\t\t   const JOCTET *dataptr, unsigned int datalen));\n  JMETHOD(void, write_file_header, (j_compress_ptr cinfo));\n  JMETHOD(void, write_frame_header, (j_compress_ptr cinfo));\n  JMETHOD(void, write_scan_header, (j_compress_ptr cinfo));\n  JMETHOD(void, write_file_trailer, (j_compress_ptr cinfo));\n  JMETHOD(void, write_tables_only, (j_compress_ptr cinfo));\n};\n\n\n/* Declarations for decompression modules */\n\n/* Master control module */\nstruct jpeg_decomp_master {\n  JMETHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo));\n  JMETHOD(void, finish_output_pass, (j_decompress_ptr cinfo));\n\n  /* State variables made visible to other modules */\n  boolean is_dummy_pass;\t/* True during 1st pass for 2-pass quant */\n};\n\n/* Input control module */\nstruct jpeg_input_controller {\n  JMETHOD(int, consume_input, (j_decompress_ptr cinfo));\n  JMETHOD(void, reset_input_controller, (j_decompress_ptr cinfo));\n  JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo));\n  JMETHOD(void, finish_input_pass, (j_decompress_ptr cinfo));\n\n  /* State variables made visible to other modules */\n  boolean has_multiple_scans;\t/* True if file has multiple scans */\n  boolean eoi_reached;\t\t/* True when EOI has been consumed */\n};\n\n/* Main buffer control (downsampled-data buffer) */\nstruct jpeg_d_main_controller {\n  JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));\n  JMETHOD(void, process_data, (j_decompress_ptr cinfo,\n\t\t\t       JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\n\t\t\t       JDIMENSION out_rows_avail));\n};\n\n/* Coefficient buffer control */\nstruct jpeg_d_coef_controller {\n  JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo));\n  JMETHOD(int, consume_data, (j_decompress_ptr cinfo));\n  JMETHOD(void, start_output_pass, (j_decompress_ptr cinfo));\n  JMETHOD(int, decompress_data, (j_decompress_ptr cinfo,\n\t\t\t\t JSAMPIMAGE output_buf));\n  /* Pointer to array of coefficient virtual arrays, or NULL if none */\n  jvirt_barray_ptr *coef_arrays;\n};\n\n/* Decompression postprocessing (color quantization buffer control) */\nstruct jpeg_d_post_controller {\n  JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));\n  JMETHOD(void, post_process_data, (j_decompress_ptr cinfo,\n\t\t\t\t    JSAMPIMAGE input_buf,\n\t\t\t\t    JDIMENSION *in_row_group_ctr,\n\t\t\t\t    JDIMENSION in_row_groups_avail,\n\t\t\t\t    JSAMPARRAY output_buf,\n\t\t\t\t    JDIMENSION *out_row_ctr,\n\t\t\t\t    JDIMENSION out_rows_avail));\n};\n\n/* Marker reading & parsing */\nstruct jpeg_marker_reader {\n  JMETHOD(void, reset_marker_reader, (j_decompress_ptr cinfo));\n  /* Read markers until SOS or EOI.\n   * Returns same codes as are defined for jpeg_consume_input:\n   * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.\n   */\n  JMETHOD(int, read_markers, (j_decompress_ptr cinfo));\n  /* Read a restart marker --- exported for use by entropy decoder only */\n  jpeg_marker_parser_method read_restart_marker;\n  /* Application-overridable marker processing methods */\n  jpeg_marker_parser_method process_COM;\n  jpeg_marker_parser_method process_APPn[16];\n\n  /* State of marker reader --- nominally internal, but applications\n   * supplying COM or APPn handlers might like to know the state.\n   */\n  boolean saw_SOI;\t\t/* found SOI? */\n  boolean saw_SOF;\t\t/* found SOF? */\n  int next_restart_num;\t\t/* next restart number expected (0-7) */\n  unsigned int discarded_bytes;\t/* # of bytes skipped looking for a marker */\n};\n\n/* Entropy decoding */\nstruct jpeg_entropy_decoder {\n  JMETHOD(void, start_pass, (j_decompress_ptr cinfo));\n  JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo,\n\t\t\t\tJBLOCKROW *MCU_data));\n};\n\n/* Inverse DCT (also performs dequantization) */\ntypedef JMETHOD(void, inverse_DCT_method_ptr,\n\t\t(j_decompress_ptr cinfo, jpeg_component_info * compptr,\n\t\t JCOEFPTR coef_block,\n\t\t JSAMPARRAY output_buf, JDIMENSION output_col));\n\nstruct jpeg_inverse_dct {\n  JMETHOD(void, start_pass, (j_decompress_ptr cinfo));\n  /* It is useful to allow each component to have a separate IDCT method. */\n  inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS];\n};\n\n/* Upsampling (note that upsampler must also call color converter) */\nstruct jpeg_upsampler {\n  JMETHOD(void, start_pass, (j_decompress_ptr cinfo));\n  JMETHOD(void, upsample, (j_decompress_ptr cinfo,\n\t\t\t   JSAMPIMAGE input_buf,\n\t\t\t   JDIMENSION *in_row_group_ctr,\n\t\t\t   JDIMENSION in_row_groups_avail,\n\t\t\t   JSAMPARRAY output_buf,\n\t\t\t   JDIMENSION *out_row_ctr,\n\t\t\t   JDIMENSION out_rows_avail));\n\n  boolean need_context_rows;\t/* TRUE if need rows above & below */\n};\n\n/* Colorspace conversion */\nstruct jpeg_color_deconverter {\n  JMETHOD(void, start_pass, (j_decompress_ptr cinfo));\n  JMETHOD(void, color_convert, (j_decompress_ptr cinfo,\n\t\t\t\tJSAMPIMAGE input_buf, JDIMENSION input_row,\n\t\t\t\tJSAMPARRAY output_buf, int num_rows));\n};\n\n/* Color quantization or color precision reduction */\nstruct jpeg_color_quantizer {\n  JMETHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan));\n  JMETHOD(void, color_quantize, (j_decompress_ptr cinfo,\n\t\t\t\t JSAMPARRAY input_buf, JSAMPARRAY output_buf,\n\t\t\t\t int num_rows));\n  JMETHOD(void, finish_pass, (j_decompress_ptr cinfo));\n  JMETHOD(void, new_color_map, (j_decompress_ptr cinfo));\n};\n\n\n/* Miscellaneous useful macros */\n\n#undef MAX\n#define MAX(a,b)\t((a) > (b) ? (a) : (b))\n#undef MIN\n#define MIN(a,b)\t((a) < (b) ? (a) : (b))\n\n\n/* We assume that right shift corresponds to signed division by 2 with\n * rounding towards minus infinity.  This is correct for typical \"arithmetic\n * shift\" instructions that shift in copies of the sign bit.  But some\n * C compilers implement >> with an unsigned shift.  For these machines you\n * must define RIGHT_SHIFT_IS_UNSIGNED.\n * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity.\n * It is only applied with constant shift counts.  SHIFT_TEMPS must be\n * included in the variables of any routine using RIGHT_SHIFT.\n */\n\n#ifdef RIGHT_SHIFT_IS_UNSIGNED\n#define SHIFT_TEMPS\tINT32 shift_temp;\n#define RIGHT_SHIFT(x,shft)  \\\n\t((shift_temp = (x)) < 0 ? \\\n\t (shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \\\n\t (shift_temp >> (shft)))\n#else\n#define SHIFT_TEMPS\n#define RIGHT_SHIFT(x,shft)\t((x) >> (shft))\n#endif\n\n\n/* Short forms of external names for systems with brain-damaged linkers. */\n\n#ifdef NEED_SHORT_EXTERNAL_NAMES\n#define jinit_compress_master\tjICompress\n#define jinit_c_master_control\tjICMaster\n#define jinit_c_main_controller\tjICMainC\n#define jinit_c_prep_controller\tjICPrepC\n#define jinit_c_coef_controller\tjICCoefC\n#define jinit_color_converter\tjICColor\n#define jinit_downsampler\tjIDownsampler\n#define jinit_forward_dct\tjIFDCT\n#define jinit_huff_encoder\tjIHEncoder\n#define jinit_phuff_encoder\tjIPHEncoder\n#define jinit_marker_writer\tjIMWriter\n#define jinit_master_decompress\tjIDMaster\n#define jinit_d_main_controller\tjIDMainC\n#define jinit_d_coef_controller\tjIDCoefC\n#define jinit_d_post_controller\tjIDPostC\n#define jinit_input_controller\tjIInCtlr\n#define jinit_marker_reader\tjIMReader\n#define jinit_huff_decoder\tjIHDecoder\n#define jinit_phuff_decoder\tjIPHDecoder\n#define jinit_inverse_dct\tjIIDCT\n#define jinit_upsampler\t\tjIUpsampler\n#define jinit_color_deconverter\tjIDColor\n#define jinit_1pass_quantizer\tjI1Quant\n#define jinit_2pass_quantizer\tjI2Quant\n#define jinit_merged_upsampler\tjIMUpsampler\n#define jinit_memory_mgr\tjIMemMgr\n#define jdiv_round_up\t\tjDivRound\n#define jround_up\t\tjRound\n#define jcopy_sample_rows\tjCopySamples\n#define jcopy_block_row\t\tjCopyBlocks\n#define jzero_far\t\tjZeroFar\n#define jpeg_zigzag_order\tjZIGTable\n#define jpeg_natural_order\tjZAGTable\n#endif /* NEED_SHORT_EXTERNAL_NAMES */\n\n\n/* Compression module initialization routines */\nEXTERN void jinit_compress_master JPP((j_compress_ptr cinfo));\nEXTERN void jinit_c_master_control JPP((j_compress_ptr cinfo,\n\t\t\t\t\tboolean transcode_only));\nEXTERN void jinit_c_main_controller JPP((j_compress_ptr cinfo,\n\t\t\t\t\t boolean need_full_buffer));\nEXTERN void jinit_c_prep_controller JPP((j_compress_ptr cinfo,\n\t\t\t\t\t boolean need_full_buffer));\nEXTERN void jinit_c_coef_controller JPP((j_compress_ptr cinfo,\n\t\t\t\t\t boolean need_full_buffer));\nEXTERN void jinit_color_converter JPP((j_compress_ptr cinfo));\nEXTERN void jinit_downsampler JPP((j_compress_ptr cinfo));\nEXTERN void jinit_forward_dct JPP((j_compress_ptr cinfo));\nEXTERN void jinit_huff_encoder JPP((j_compress_ptr cinfo));\nEXTERN void jinit_phuff_encoder JPP((j_compress_ptr cinfo));\nEXTERN void jinit_marker_writer JPP((j_compress_ptr cinfo));\n/* Decompression module initialization routines */\nEXTERN void jinit_master_decompress JPP((j_decompress_ptr cinfo));\nEXTERN void jinit_d_main_controller JPP((j_decompress_ptr cinfo,\n\t\t\t\t\t boolean need_full_buffer));\nEXTERN void jinit_d_coef_controller JPP((j_decompress_ptr cinfo,\n\t\t\t\t\t boolean need_full_buffer));\nEXTERN void jinit_d_post_controller JPP((j_decompress_ptr cinfo,\n\t\t\t\t\t boolean need_full_buffer));\nEXTERN void jinit_input_controller JPP((j_decompress_ptr cinfo));\nEXTERN void jinit_marker_reader JPP((j_decompress_ptr cinfo));\nEXTERN void jinit_huff_decoder JPP((j_decompress_ptr cinfo));\nEXTERN void jinit_phuff_decoder JPP((j_decompress_ptr cinfo));\nEXTERN void jinit_inverse_dct JPP((j_decompress_ptr cinfo));\nEXTERN void jinit_upsampler JPP((j_decompress_ptr cinfo));\nEXTERN void jinit_color_deconverter JPP((j_decompress_ptr cinfo));\nEXTERN void jinit_1pass_quantizer JPP((j_decompress_ptr cinfo));\nEXTERN void jinit_2pass_quantizer JPP((j_decompress_ptr cinfo));\nEXTERN void jinit_merged_upsampler JPP((j_decompress_ptr cinfo));\n/* Memory manager initialization */\nEXTERN void jinit_memory_mgr JPP((j_common_ptr cinfo));\n\n/* Utility routines in jutils.c */\nEXTERN long jdiv_round_up JPP((long a, long b));\nEXTERN long jround_up JPP((long a, long b));\nEXTERN void jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row,\n\t\t\t\t   JSAMPARRAY output_array, int dest_row,\n\t\t\t\t   int num_rows, JDIMENSION num_cols));\nEXTERN void jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row,\n\t\t\t\t JDIMENSION num_blocks));\nEXTERN void jzero_far JPP((void FAR * target, size_t bytestozero));\n/* Constant tables in jutils.c */\nextern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */\nextern const int jpeg_natural_order[]; /* zigzag coef order to natural order */\n\n/* Suppress undefined-structure complaints if necessary. */\n\n#ifdef INCOMPLETE_TYPES_BROKEN\n#ifndef AM_MEMORY_MANAGER\t/* only jmemmgr.c defines these */\nstruct jvirt_sarray_control { long dummy; };\nstruct jvirt_barray_control { long dummy; };\n#endif\n#endif /* INCOMPLETE_TYPES_BROKEN */\n"
  },
  {
    "path": "libs/jpeg6/jpgload.cpp",
    "content": "\n    \n#include \"jpeglib.h\"\n#include <memory.h>\n\nGLOBAL void LoadJPGBuff(unsigned char *fbuffer, unsigned char **pic, int *width, int *height ) \n{\n  /* This struct contains the JPEG decompression parameters and pointers to\n   * working space (which is allocated as needed by the JPEG library).\n   */\n  struct jpeg_decompress_struct cinfo;\n  /* We use our private extension JPEG error handler.\n   * Note that this struct must live as long as the main JPEG parameter\n   * struct, to avoid dangling-pointer problems.\n   */\n  /* This struct represents a JPEG error handler.  It is declared separately\n   * because applications often want to supply a specialized error handler\n   * (see the second half of this file for an example).  But here we just\n   * take the easy way out and use the standard error handler, which will\n   * print a message on stderr and call exit() if compression fails.\n   * Note that this struct must live as long as the main JPEG parameter\n   * struct, to avoid dangling-pointer problems.\n   */\n\n  struct jpeg_error_mgr jerr;\n  /* More stuff */\n  JSAMPARRAY buffer;\t\t/* Output row buffer */\n  int row_stride;\t\t/* physical row width in output buffer */\n  unsigned char *out;\n  byte  *bbuf;\n  int nSize;\n\n  /* Step 1: allocate and initialize JPEG decompression object */\n\n  /* We have to set up the error handler first, in case the initialization\n   * step fails.  (Unlikely, but it could happen if you are out of memory.)\n   * This routine fills in the contents of struct jerr, and returns jerr's\n   * address which we place into the link field in cinfo.\n   */\n  cinfo.err = jpeg_std_error(&jerr);\n\n  /* Now we can initialize the JPEG decompression object. */\n  jpeg_create_decompress(&cinfo);\n\n  /* Step 2: specify data source (eg, a file) */\n\n  jpeg_stdio_src(&cinfo, fbuffer);\n\n  /* Step 3: read file parameters with jpeg_read_header() */\n\n  (void) jpeg_read_header(&cinfo, TRUE);\n  /* We can ignore the return value from jpeg_read_header since\n   *   (a) suspension is not possible with the stdio data source, and\n   *   (b) we passed TRUE to reject a tables-only JPEG file as an error.\n   * See libjpeg.doc for more info.\n   */\n\n  /* Step 4: set parameters for decompression */\n\n  /* In this example, we don't need to change any of the defaults set by\n   * jpeg_read_header(), so we do nothing here.\n   */\n\n  /* Step 5: Start decompressor */\n\n  (void) jpeg_start_decompress(&cinfo);\n  /* We can ignore the return value since suspension is not possible\n   * with the stdio data source.\n   */\n\n  /* We may need to do some setup of our own at this point before reading\n   * the data.  After jpeg_start_decompress() we have the correct scaled\n   * output image dimensions available, as well as the output colormap\n   * if we asked for color quantization.\n   * In this example, we need to make an output work buffer of the right size.\n   */ \n  /* JSAMPLEs per row in output buffer */\n  row_stride = cinfo.output_width * cinfo.output_components;\n\n  nSize = cinfo.output_width*cinfo.output_height*cinfo.output_components;\n  out = reinterpret_cast<unsigned char*>(malloc(nSize+1));\n  memset(out, 0, nSize+1);\n\n  *pic = out;\n  *width = cinfo.output_width;\n  *height = cinfo.output_height;\n\n  /* Step 6: while (scan lines remain to be read) */\n  /*           jpeg_read_scanlines(...); */\n\n  /* Here we use the library's state variable cinfo.output_scanline as the\n   * loop counter, so that we don't have to keep track ourselves.\n   */\n  while (cinfo.output_scanline < cinfo.output_height) {\n    /* jpeg_read_scanlines expects an array of pointers to scanlines.\n     * Here the array is only one element long, but you could ask for\n     * more than one scanline at a time if that's more convenient.\n     */\n\t  bbuf = ((out+(row_stride*cinfo.output_scanline)));\n  \tbuffer = &bbuf;\n    (void) jpeg_read_scanlines(&cinfo, buffer, 1);\n  }\n\n  // clear all the alphas to 255\n  {\n\t  int\ti, j;\n\t\tbyte\t*buf;\n\n\t\tbuf = *pic;\n\n\t  j = cinfo.output_width * cinfo.output_height * 4;\n\t  for ( i = 3 ; i < j ; i+=4 ) {\n\t\t  buf[i] = 255;\n\t  }\n  }\n\n  /* Step 7: Finish decompression */\n\n  (void) jpeg_finish_decompress(&cinfo);\n  /* We can ignore the return value since suspension is not possible\n   * with the stdio data source.\n   */\n\n  /* Step 8: Release JPEG decompression object */\n\n  /* This is an important step since it will release a good deal of memory. */\n  jpeg_destroy_decompress(&cinfo);\n\n  /* After finish_decompress, we can close the input file.\n   * Here we postpone it until after no more JPEG errors are possible,\n   * so as to simplify the setjmp error logic above.  (Actually, I don't\n   * think that jpeg_destroy can do an error exit, but why assume anything...)\n   */\n  //free (fbuffer);\n\n  /* At this point you may want to check to see whether any corrupt-data\n   * warnings occurred (test whether jerr.pub.num_warnings is nonzero).\n   */\n\n  /* And we're done! */\n}\n\n"
  },
  {
    "path": "libs/jpeg6/jutils.cpp",
    "content": "/*\n * jutils.c\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains tables and miscellaneous utility routines needed\n * for both compression and decompression.\n * Note we prefix all global names with \"j\" to minimize conflicts with\n * a surrounding application.\n */\n\n#define JPEG_INTERNALS\n#include \"jinclude.h\"\n#include \"jpeglib.h\"\n\n\n/*\n * jpeg_zigzag_order[i] is the zigzag-order position of the i'th element\n * of a DCT block read in natural order (left to right, top to bottom).\n */\n\nconst int jpeg_zigzag_order[DCTSIZE2] = {\n   0,  1,  5,  6, 14, 15, 27, 28,\n   2,  4,  7, 13, 16, 26, 29, 42,\n   3,  8, 12, 17, 25, 30, 41, 43,\n   9, 11, 18, 24, 31, 40, 44, 53,\n  10, 19, 23, 32, 39, 45, 52, 54,\n  20, 22, 33, 38, 46, 51, 55, 60,\n  21, 34, 37, 47, 50, 56, 59, 61,\n  35, 36, 48, 49, 57, 58, 62, 63\n};\n\n/*\n * jpeg_natural_order[i] is the natural-order position of the i'th element\n * of zigzag order.\n *\n * When reading corrupted data, the Huffman decoders could attempt\n * to reference an entry beyond the end of this array (if the decoded\n * zero run length reaches past the end of the block).  To prevent\n * wild stores without adding an inner-loop test, we put some extra\n * \"63\"s after the real entries.  This will cause the extra coefficient\n * to be stored in location 63 of the block, not somewhere random.\n * The worst case would be a run-length of 15, which means we need 16\n * fake entries.\n */\n\nconst int jpeg_natural_order[DCTSIZE2+16] = {\n  0,  1,  8, 16,  9,  2,  3, 10,\n 17, 24, 32, 25, 18, 11,  4,  5,\n 12, 19, 26, 33, 40, 48, 41, 34,\n 27, 20, 13,  6,  7, 14, 21, 28,\n 35, 42, 49, 56, 57, 50, 43, 36,\n 29, 22, 15, 23, 30, 37, 44, 51,\n 58, 59, 52, 45, 38, 31, 39, 46,\n 53, 60, 61, 54, 47, 55, 62, 63,\n 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */\n 63, 63, 63, 63, 63, 63, 63, 63\n};\n\n\n/*\n * Arithmetic utilities\n */\n\nGLOBAL long\njdiv_round_up (long a, long b)\n/* Compute a/b rounded up to next integer, ie, ceil(a/b) */\n/* Assumes a >= 0, b > 0 */\n{\n  return (a + b - 1L) / b;\n}\n\n\nGLOBAL long\njround_up (long a, long b)\n/* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */\n/* Assumes a >= 0, b > 0 */\n{\n  a += b - 1L;\n  return a - (a % b);\n}\n\n\n/* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays\n * and coefficient-block arrays.  This won't work on 80x86 because the arrays\n * are FAR and we're assuming a small-pointer memory model.  However, some\n * DOS compilers provide far-pointer versions of memcpy() and memset() even\n * in the small-model libraries.  These will be used if USE_FMEM is defined.\n * Otherwise, the routines below do it the hard way.  (The performance cost\n * is not all that great, because these routines aren't very heavily used.)\n */\n\n#ifndef NEED_FAR_POINTERS\t/* normal case, same as regular macros */\n#define FMEMCOPY(dest,src,size)\tMEMCOPY(dest,src,size)\n#define FMEMZERO(target,size)\tMEMZERO(target,size)\n#else\t\t\t\t/* 80x86 case, define if we can */\n#ifdef USE_FMEM\n#define FMEMCOPY(dest,src,size)\t_fmemcpy((void FAR *)(dest), (const void FAR *)(src), (size_t)(size))\n#define FMEMZERO(target,size)\t_fmemset((void FAR *)(target), 0, (size_t)(size))\n#endif\n#endif\n\n\nGLOBAL void\njcopy_sample_rows (JSAMPARRAY input_array, int source_row,\n\t\t   JSAMPARRAY output_array, int dest_row,\n\t\t   int num_rows, JDIMENSION num_cols)\n/* Copy some rows of samples from one place to another.\n * num_rows rows are copied from input_array[source_row++]\n * to output_array[dest_row++]; these areas may overlap for duplication.\n * The source and destination arrays must be at least as wide as num_cols.\n */\n{\n  register JSAMPROW inptr, outptr;\n#ifdef FMEMCOPY\n  register size_t count = (size_t) (num_cols * SIZEOF(JSAMPLE));\n#else\n  register JDIMENSION count;\n#endif\n  register int row;\n\n  input_array += source_row;\n  output_array += dest_row;\n\n  for (row = num_rows; row > 0; row--) {\n    inptr = *input_array++;\n    outptr = *output_array++;\n#ifdef FMEMCOPY\n    FMEMCOPY(outptr, inptr, count);\n#else\n    for (count = num_cols; count > 0; count--)\n      *outptr++ = *inptr++;\t/* needn't bother with GETJSAMPLE() here */\n#endif\n  }\n}\n\n\nGLOBAL void\njcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row,\n\t\t JDIMENSION num_blocks)\n/* Copy a row of coefficient blocks from one place to another. */\n{\n#ifdef FMEMCOPY\n  FMEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF)));\n#else\n  register JCOEFPTR inptr, outptr;\n  register long count;\n\n  inptr = (JCOEFPTR) input_row;\n  outptr = (JCOEFPTR) output_row;\n  for (count = (long) num_blocks * DCTSIZE2; count > 0; count--) {\n    *outptr++ = *inptr++;\n  }\n#endif\n}\n\n\nGLOBAL void\njzero_far (void FAR * target, size_t bytestozero)\n/* Zero out a chunk of FAR memory. */\n/* This might be sample-array data, block-array data, or alloc_large data. */\n{\n#ifdef FMEMZERO\n  FMEMZERO(target, bytestozero);\n#else\n  register char FAR * ptr = (char FAR *) target;\n  register size_t count;\n\n  for (count = bytestozero; count > 0; count--) {\n    *ptr++ = 0;\n  }\n#endif\n}\n"
  },
  {
    "path": "libs/jpeg6/jversion.h",
    "content": "/*\n * jversion.h\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file contains software version identification.\n */\n\n\n#define JVERSION\t\"6  2-Aug-95\"\n\n#define JCOPYRIGHT\t\"Copyright (C) 1995, Thomas G. Lane\"\n"
  },
  {
    "path": "libs/jpeglib.h",
    "content": "/*\n * jpeglib.h\n *\n * Copyright (C) 1991-1995, Thomas G. Lane.\n * This file is part of the Independent JPEG Group's software.\n * For conditions of distribution and use, see the accompanying README file.\n *\n * This file defines the application interface for the JPEG library.\n * Most applications using the library need only include this file,\n * and perhaps jerror.h if they want to know the exact error codes.\n */\n\n#ifndef JPEGLIB_H\n#define JPEGLIB_H\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n\n\n#ifdef __MACOS__\n\n// JDC: stuff to make mac version compile\n#define\tboolean\tqboolean\n#define\tregister\n#define\tINT32\tint\n\n#endif\n\n// rad additions\n// 11.29.99\n\n//#include \"cmdlib.h\"\n#ifdef _WIN32\n#include \"windows.h\"\n#include \"stdio.h\"\n#endif\n\n#ifndef INT32\n#define\tINT32\tint\n#endif\n\nextern void LoadJPGBuff(unsigned char *fbuffer, unsigned char **pic, int *width, int *height );\n// rad end\n\n\n/*\n * First we include the configuration files that record how this\n * installation of the JPEG library is set up.  jconfig.h can be\n * generated automatically for many systems.  jmorecfg.h contains\n * manual configuration options that most people need not worry about.\n */\n\n#ifndef JCONFIG_INCLUDED\t/* in case jinclude.h already did */\n#include \"jpeg6/jconfig.h\"\t\t/* widely used configuration options */\n#endif\n#include \"jpeg6/jmorecfg.h\"\t\t/* seldom changed options */\n\n\n/* Version ID for the JPEG library.\n * Might be useful for tests like \"#if JPEG_LIB_VERSION >= 60\".\n */\n\n#define JPEG_LIB_VERSION  60\t/* Version 6 */\n\n\n/* Various constants determining the sizes of things.\n * All of these are specified by the JPEG standard, so don't change them\n * if you want to be compatible.\n */\n\n#define DCTSIZE\t\t    8\t/* The basic DCT block is 8x8 samples */\n#define DCTSIZE2\t    64\t/* DCTSIZE squared; # of elements in a block */\n#define NUM_QUANT_TBLS      4\t/* Quantization tables are numbered 0..3 */\n#define NUM_HUFF_TBLS       4\t/* Huffman tables are numbered 0..3 */\n#define NUM_ARITH_TBLS      16\t/* Arith-coding tables are numbered 0..15 */\n#define MAX_COMPS_IN_SCAN   4\t/* JPEG limit on # of components in one scan */\n#define MAX_SAMP_FACTOR     4\t/* JPEG limit on sampling factors */\n/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard;\n * the PostScript DCT filter can emit files with many more than 10 blocks/MCU.\n * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU\n * to handle it.  We even let you do this from the jconfig.h file.  However,\n * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe\n * sometimes emits noncompliant files doesn't mean you should too.\n */\n#define C_MAX_BLOCKS_IN_MCU   10 /* compressor's limit on blocks per MCU */\n#ifndef D_MAX_BLOCKS_IN_MCU\n#define D_MAX_BLOCKS_IN_MCU   10 /* decompressor's limit on blocks per MCU */\n#endif\n\n\n/* This macro is used to declare a \"method\", that is, a function pointer.\n * We want to supply prototype parameters if the compiler can cope.\n * Note that the arglist parameter must be parenthesized!\n */\n\n#ifdef HAVE_PROTOTYPES\n#define JMETHOD(type,methodname,arglist)  type (*methodname) arglist\n#else\n#define JMETHOD(type,methodname,arglist)  type (*methodname) ()\n#endif\n\n\n/* Data structures for images (arrays of samples and of DCT coefficients).\n * On 80x86 machines, the image arrays are too big for near pointers,\n * but the pointer arrays can fit in near memory.\n */\n\ntypedef JSAMPLE FAR *JSAMPROW;\t/* ptr to one image row of pixel samples. */\ntypedef JSAMPROW *JSAMPARRAY;\t/* ptr to some rows (a 2-D sample array) */\ntypedef JSAMPARRAY *JSAMPIMAGE;\t/* a 3-D sample array: top index is color */\n\ntypedef JCOEF JBLOCK[DCTSIZE2];\t/* one block of coefficients */\ntypedef JBLOCK FAR *JBLOCKROW;\t/* pointer to one row of coefficient blocks */\ntypedef JBLOCKROW *JBLOCKARRAY;\t\t/* a 2-D array of coefficient blocks */\ntypedef JBLOCKARRAY *JBLOCKIMAGE;\t/* a 3-D array of coefficient blocks */\n\ntypedef JCOEF FAR *JCOEFPTR;\t/* useful in a couple of places */\n\n\n/* Types for JPEG compression parameters and working tables. */\n\n\n/* DCT coefficient quantization tables. */\n\ntypedef struct {\n  /* This field directly represents the contents of a JPEG DQT marker.\n   * Note: the values are always given in zigzag order.\n   */\n  UINT16 quantval[DCTSIZE2];\t/* quantization step for each coefficient */\n  /* This field is used only during compression.  It's initialized FALSE when\n   * the table is created, and set TRUE when it's been output to the file.\n   * You could suppress output of a table by setting this to TRUE.\n   * (See jpeg_suppress_tables for an example.)\n   */\n  boolean sent_table;\t\t/* TRUE when table has been output */\n} JQUANT_TBL;\n\n\n/* Huffman coding tables. */\n\ntypedef struct {\n  /* These two fields directly represent the contents of a JPEG DHT marker */\n  UINT8 bits[17];\t\t/* bits[k] = # of symbols with codes of */\n\t\t\t\t/* length k bits; bits[0] is unused */\n  UINT8 huffval[256];\t\t/* The symbols, in order of incr code length */\n  /* This field is used only during compression.  It's initialized FALSE when\n   * the table is created, and set TRUE when it's been output to the file.\n   * You could suppress output of a table by setting this to TRUE.\n   * (See jpeg_suppress_tables for an example.)\n   */\n  boolean sent_table;\t\t/* TRUE when table has been output */\n} JHUFF_TBL;\n\n\n/* Basic info about one component (color channel). */\n\ntypedef struct {\n  /* These values are fixed over the whole image. */\n  /* For compression, they must be supplied by parameter setup; */\n  /* for decompression, they are read from the SOF marker. */\n  int component_id;\t\t/* identifier for this component (0..255) */\n  int component_index;\t\t/* its index in SOF or cinfo->comp_info[] */\n  int h_samp_factor;\t\t/* horizontal sampling factor (1..4) */\n  int v_samp_factor;\t\t/* vertical sampling factor (1..4) */\n  int quant_tbl_no;\t\t/* quantization table selector (0..3) */\n  /* These values may vary between scans. */\n  /* For compression, they must be supplied by parameter setup; */\n  /* for decompression, they are read from the SOS marker. */\n  /* The decompressor output side may not use these variables. */\n  int dc_tbl_no;\t\t/* DC entropy table selector (0..3) */\n  int ac_tbl_no;\t\t/* AC entropy table selector (0..3) */\n  \n  /* Remaining fields should be treated as private by applications. */\n  \n  /* These values are computed during compression or decompression startup: */\n  /* Component's size in DCT blocks.\n   * Any dummy blocks added to complete an MCU are not counted; therefore\n   * these values do not depend on whether a scan is interleaved or not.\n   */\n  JDIMENSION width_in_blocks;\n  JDIMENSION height_in_blocks;\n  /* Size of a DCT block in samples.  Always DCTSIZE for compression.\n   * For decompression this is the size of the output from one DCT block,\n   * reflecting any scaling we choose to apply during the IDCT step.\n   * Values of 1,2,4,8 are likely to be supported.  Note that different\n   * components may receive different IDCT scalings.\n   */\n  int DCT_scaled_size;\n  /* The downsampled dimensions are the component's actual, unpadded number\n   * of samples at the main buffer (preprocessing/compression interface), thus\n   * downsampled_width = ceil(image_width * Hi/Hmax)\n   * and similarly for height.  For decompression, IDCT scaling is included, so\n   * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE)\n   */\n  JDIMENSION downsampled_width;\t /* actual width in samples */\n  JDIMENSION downsampled_height; /* actual height in samples */\n  /* This flag is used only for decompression.  In cases where some of the\n   * components will be ignored (eg grayscale output from YCbCr image),\n   * we can skip most computations for the unused components.\n   */\n  boolean component_needed;\t/* do we need the value of this component? */\n\n  /* These values are computed before starting a scan of the component. */\n  /* The decompressor output side may not use these variables. */\n  int MCU_width;\t\t/* number of blocks per MCU, horizontally */\n  int MCU_height;\t\t/* number of blocks per MCU, vertically */\n  int MCU_blocks;\t\t/* MCU_width * MCU_height */\n  int MCU_sample_width;\t\t/* MCU width in samples, MCU_width*DCT_scaled_size */\n  int last_col_width;\t\t/* # of non-dummy blocks across in last MCU */\n  int last_row_height;\t\t/* # of non-dummy blocks down in last MCU */\n\n  /* Saved quantization table for component; NULL if none yet saved.\n   * See jdinput.c comments about the need for this information.\n   * This field is not currently used by the compressor.\n   */\n  JQUANT_TBL * quant_table;\n\n  /* Private per-component storage for DCT or IDCT subsystem. */\n  void * dct_table;\n} jpeg_component_info;\n\n\n/* The script for encoding a multiple-scan file is an array of these: */\n\ntypedef struct {\n  int comps_in_scan;\t\t/* number of components encoded in this scan */\n  int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */\n  int Ss, Se;\t\t\t/* progressive JPEG spectral selection parms */\n  int Ah, Al;\t\t\t/* progressive JPEG successive approx. parms */\n} jpeg_scan_info;\n\n\n/* Known color spaces. */\n\ntypedef enum {\n\tJCS_UNKNOWN,\t\t/* error/unspecified */\n\tJCS_GRAYSCALE,\t\t/* monochrome */\n\tJCS_RGB,\t\t/* red/green/blue */\n\tJCS_YCbCr,\t\t/* Y/Cb/Cr (also known as YUV) */\n\tJCS_CMYK,\t\t/* C/M/Y/K */\n\tJCS_YCCK\t\t/* Y/Cb/Cr/K */\n} J_COLOR_SPACE;\n\n/* DCT/IDCT algorithm options. */\n\ntypedef enum {\n\tJDCT_ISLOW,\t\t/* slow but accurate integer algorithm */\n\tJDCT_IFAST,\t\t/* faster, less accurate integer method */\n\tJDCT_FLOAT\t\t/* floating-point: accurate, fast on fast HW */\n} J_DCT_METHOD;\n\n#ifndef JDCT_DEFAULT\t\t/* may be overridden in jconfig.h */\n#define JDCT_DEFAULT  JDCT_ISLOW\n#endif\n#ifndef JDCT_FASTEST\t\t/* may be overridden in jconfig.h */\n#define JDCT_FASTEST  JDCT_IFAST\n#endif\n\n/* Dithering options for decompression. */\n\ntypedef enum {\n\tJDITHER_NONE,\t\t/* no dithering */\n\tJDITHER_ORDERED,\t/* simple ordered dither */\n\tJDITHER_FS\t\t/* Floyd-Steinberg error diffusion dither */\n} J_DITHER_MODE;\n\n\n/* Common fields between JPEG compression and decompression master structs. */\n\n#define jpeg_common_fields \\\n  struct jpeg_error_mgr * err;\t/* Error handler module */\\\n  struct jpeg_memory_mgr * mem;\t/* Memory manager module */\\\n  struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\\\n  boolean is_decompressor;\t/* so common code can tell which is which */\\\n  int global_state\t\t/* for checking call sequence validity */\n\n/* Routines that are to be used by both halves of the library are declared\n * to receive a pointer to this structure.  There are no actual instances of\n * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct.\n */\nstruct jpeg_common_struct {\n  jpeg_common_fields;\t\t/* Fields common to both master struct types */\n  /* Additional fields follow in an actual jpeg_compress_struct or\n   * jpeg_decompress_struct.  All three structs must agree on these\n   * initial fields!  (This would be a lot cleaner in C++.)\n   */\n};\n\ntypedef struct jpeg_common_struct * j_common_ptr;\ntypedef struct jpeg_compress_struct * j_compress_ptr;\ntypedef struct jpeg_decompress_struct * j_decompress_ptr;\n\n\n/* Master record for a compression instance */\n\nstruct jpeg_compress_struct {\n  jpeg_common_fields;\t\t/* Fields shared with jpeg_decompress_struct */\n\n  /* Destination for compressed data */\n  struct jpeg_destination_mgr * dest;\n\n  /* Description of source image --- these fields must be filled in by\n   * outer application before starting compression.  in_color_space must\n   * be correct before you can even call jpeg_set_defaults().\n   */\n\n  JDIMENSION image_width;\t/* input image width */\n  JDIMENSION image_height;\t/* input image height */\n  int input_components;\t\t/* # of color components in input image */\n  J_COLOR_SPACE in_color_space;\t/* colorspace of input image */\n\n  double input_gamma;\t\t/* image gamma of input image */\n\n  /* Compression parameters --- these fields must be set before calling\n   * jpeg_start_compress().  We recommend calling jpeg_set_defaults() to\n   * initialize everything to reasonable defaults, then changing anything\n   * the application specifically wants to change.  That way you won't get\n   * burnt when new parameters are added.  Also note that there are several\n   * helper routines to simplify changing parameters.\n   */\n\n  int data_precision;\t\t/* bits of precision in image data */\n\n  int num_components;\t\t/* # of color components in JPEG image */\n  J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */\n\n  jpeg_component_info * comp_info;\n  /* comp_info[i] describes component that appears i'th in SOF */\n  \n  JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS];\n  /* ptrs to coefficient quantization tables, or NULL if not defined */\n  \n  JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS];\n  JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS];\n  /* ptrs to Huffman coding tables, or NULL if not defined */\n  \n  UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */\n  UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */\n  UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */\n\n  int num_scans;\t\t/* # of entries in scan_info array */\n  const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */\n  /* The default value of scan_info is NULL, which causes a single-scan\n   * sequential JPEG file to be emitted.  To create a multi-scan file,\n   * set num_scans and scan_info to point to an array of scan definitions.\n   */\n\n  boolean raw_data_in;\t\t/* TRUE=caller supplies downsampled data */\n  boolean arith_code;\t\t/* TRUE=arithmetic coding, FALSE=Huffman */\n  boolean optimize_coding;\t/* TRUE=optimize entropy encoding parms */\n  boolean CCIR601_sampling;\t/* TRUE=first samples are cosited */\n  int smoothing_factor;\t\t/* 1..100, or 0 for no input smoothing */\n  J_DCT_METHOD dct_method;\t/* DCT algorithm selector */\n\n  /* The restart interval can be specified in absolute MCUs by setting\n   * restart_interval, or in MCU rows by setting restart_in_rows\n   * (in which case the correct restart_interval will be figured\n   * for each scan).\n   */\n  unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */\n  int restart_in_rows;\t\t/* if > 0, MCU rows per restart interval */\n\n  /* Parameters controlling emission of special markers. */\n\n  boolean write_JFIF_header;\t/* should a JFIF marker be written? */\n  /* These three values are not used by the JPEG code, merely copied */\n  /* into the JFIF APP0 marker.  density_unit can be 0 for unknown, */\n  /* 1 for dots/inch, or 2 for dots/cm.  Note that the pixel aspect */\n  /* ratio is defined by X_density/Y_density even when density_unit=0. */\n  UINT8 density_unit;\t\t/* JFIF code for pixel size units */\n  UINT16 X_density;\t\t/* Horizontal pixel density */\n  UINT16 Y_density;\t\t/* Vertical pixel density */\n  boolean write_Adobe_marker;\t/* should an Adobe marker be written? */\n  \n  /* State variable: index of next scanline to be written to\n   * jpeg_write_scanlines().  Application may use this to control its\n   * processing loop, e.g., \"while (next_scanline < image_height)\".\n   */\n\n  JDIMENSION next_scanline;\t/* 0 .. image_height-1  */\n\n  /* Remaining fields are known throughout compressor, but generally\n   * should not be touched by a surrounding application.\n   */\n\n  /*\n   * These fields are computed during compression startup\n   */\n  boolean progressive_mode;\t/* TRUE if scan script uses progressive mode */\n  int max_h_samp_factor;\t/* largest h_samp_factor */\n  int max_v_samp_factor;\t/* largest v_samp_factor */\n\n  JDIMENSION total_iMCU_rows;\t/* # of iMCU rows to be input to coef ctlr */\n  /* The coefficient controller receives data in units of MCU rows as defined\n   * for fully interleaved scans (whether the JPEG file is interleaved or not).\n   * There are v_samp_factor * DCTSIZE sample rows of each component in an\n   * \"iMCU\" (interleaved MCU) row.\n   */\n  \n  /*\n   * These fields are valid during any one scan.\n   * They describe the components and MCUs actually appearing in the scan.\n   */\n  int comps_in_scan;\t\t/* # of JPEG components in this scan */\n  jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];\n  /* *cur_comp_info[i] describes component that appears i'th in SOS */\n  \n  JDIMENSION MCUs_per_row;\t/* # of MCUs across the image */\n  JDIMENSION MCU_rows_in_scan;\t/* # of MCU rows in the image */\n  \n  int blocks_in_MCU;\t\t/* # of DCT blocks per MCU */\n  int MCU_membership[C_MAX_BLOCKS_IN_MCU];\n  /* MCU_membership[i] is index in cur_comp_info of component owning */\n  /* i'th block in an MCU */\n\n  int Ss, Se, Ah, Al;\t\t/* progressive JPEG parameters for scan */\n\n  /*\n   * Links to compression subobjects (methods and private variables of modules)\n   */\n  struct jpeg_comp_master * master;\n  struct jpeg_c_main_controller * main;\n  struct jpeg_c_prep_controller * prep;\n  struct jpeg_c_coef_controller * coef;\n  struct jpeg_marker_writer * marker;\n  struct jpeg_color_converter * cconvert;\n  struct jpeg_downsampler * downsample;\n  struct jpeg_forward_dct * fdct;\n  struct jpeg_entropy_encoder * entropy;\n};\n\n\n/* Master record for a decompression instance */\n\nstruct jpeg_decompress_struct {\n  jpeg_common_fields;\t\t/* Fields shared with jpeg_compress_struct */\n\n  /* Source of compressed data */\n  struct jpeg_source_mgr * src;\n\n  /* Basic description of image --- filled in by jpeg_read_header(). */\n  /* Application may inspect these values to decide how to process image. */\n\n  JDIMENSION image_width;\t/* nominal image width (from SOF marker) */\n  JDIMENSION image_height;\t/* nominal image height */\n  int num_components;\t\t/* # of color components in JPEG image */\n  J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */\n\n  /* Decompression processing parameters --- these fields must be set before\n   * calling jpeg_start_decompress().  Note that jpeg_read_header() initializes\n   * them to default values.\n   */\n\n  J_COLOR_SPACE out_color_space; /* colorspace for output */\n\n  unsigned int scale_num, scale_denom; /* fraction by which to scale image */\n\n  double output_gamma;\t\t/* image gamma wanted in output */\n\n  boolean buffered_image;\t/* TRUE=multiple output passes */\n  boolean raw_data_out;\t\t/* TRUE=downsampled data wanted */\n\n  J_DCT_METHOD dct_method;\t/* IDCT algorithm selector */\n  boolean do_fancy_upsampling;\t/* TRUE=apply fancy upsampling */\n  boolean do_block_smoothing;\t/* TRUE=apply interblock smoothing */\n\n  boolean quantize_colors;\t/* TRUE=colormapped output wanted */\n  /* the following are ignored if not quantize_colors: */\n  J_DITHER_MODE dither_mode;\t/* type of color dithering to use */\n  boolean two_pass_quantize;\t/* TRUE=use two-pass color quantization */\n  int desired_number_of_colors;\t/* max # colors to use in created colormap */\n  /* these are significant only in buffered-image mode: */\n  boolean enable_1pass_quant;\t/* enable future use of 1-pass quantizer */\n  boolean enable_external_quant;/* enable future use of external colormap */\n  boolean enable_2pass_quant;\t/* enable future use of 2-pass quantizer */\n\n  /* Description of actual output image that will be returned to application.\n   * These fields are computed by jpeg_start_decompress().\n   * You can also use jpeg_calc_output_dimensions() to determine these values\n   * in advance of calling jpeg_start_decompress().\n   */\n\n  JDIMENSION output_width;\t/* scaled image width */\n  JDIMENSION output_height;\t/* scaled image height */\n  int out_color_components;\t/* # of color components in out_color_space */\n  int output_components;\t/* # of color components returned */\n  /* output_components is 1 (a colormap index) when quantizing colors;\n   * otherwise it equals out_color_components.\n   */\n  int rec_outbuf_height;\t/* min recommended height of scanline buffer */\n  /* If the buffer passed to jpeg_read_scanlines() is less than this many rows\n   * high, space and time will be wasted due to unnecessary data copying.\n   * Usually rec_outbuf_height will be 1 or 2, at most 4.\n   */\n\n  /* When quantizing colors, the output colormap is described by these fields.\n   * The application can supply a colormap by setting colormap non-NULL before\n   * calling jpeg_start_decompress; otherwise a colormap is created during\n   * jpeg_start_decompress or jpeg_start_output.\n   * The map has out_color_components rows and actual_number_of_colors columns.\n   */\n  int actual_number_of_colors;\t/* number of entries in use */\n  JSAMPARRAY colormap;\t\t/* The color map as a 2-D pixel array */\n\n  /* State variables: these variables indicate the progress of decompression.\n   * The application may examine these but must not modify them.\n   */\n\n  /* Row index of next scanline to be read from jpeg_read_scanlines().\n   * Application may use this to control its processing loop, e.g.,\n   * \"while (output_scanline < output_height)\".\n   */\n  JDIMENSION output_scanline;\t/* 0 .. output_height-1  */\n\n  /* Current input scan number and number of iMCU rows completed in scan.\n   * These indicate the progress of the decompressor input side.\n   */\n  int input_scan_number;\t/* Number of SOS markers seen so far */\n  JDIMENSION input_iMCU_row;\t/* Number of iMCU rows completed */\n\n  /* The \"output scan number\" is the notional scan being displayed by the\n   * output side.  The decompressor will not allow output scan/row number\n   * to get ahead of input scan/row, but it can fall arbitrarily far behind.\n   */\n  int output_scan_number;\t/* Nominal scan number being displayed */\n  JDIMENSION output_iMCU_row;\t/* Number of iMCU rows read */\n\n  /* Current progression status.  coef_bits[c][i] indicates the precision\n   * with which component c's DCT coefficient i (in zigzag order) is known.\n   * It is -1 when no data has yet been received, otherwise it is the point\n   * transform (shift) value for the most recent scan of the coefficient\n   * (thus, 0 at completion of the progression).\n   * This pointer is NULL when reading a non-progressive file.\n   */\n  int (*coef_bits)[DCTSIZE2];\t/* -1 or current Al value for each coef */\n\n  /* Internal JPEG parameters --- the application usually need not look at\n   * these fields.  Note that the decompressor output side may not use\n   * any parameters that can change between scans.\n   */\n\n  /* Quantization and Huffman tables are carried forward across input\n   * datastreams when processing abbreviated JPEG datastreams.\n   */\n\n  JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS];\n  /* ptrs to coefficient quantization tables, or NULL if not defined */\n\n  JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS];\n  JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS];\n  /* ptrs to Huffman coding tables, or NULL if not defined */\n\n  /* These parameters are never carried across datastreams, since they\n   * are given in SOF/SOS markers or defined to be reset by SOI.\n   */\n\n  int data_precision;\t\t/* bits of precision in image data */\n\n  jpeg_component_info * comp_info;\n  /* comp_info[i] describes component that appears i'th in SOF */\n\n  boolean progressive_mode;\t/* TRUE if SOFn specifies progressive mode */\n  boolean arith_code;\t\t/* TRUE=arithmetic coding, FALSE=Huffman */\n\n  UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */\n  UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */\n  UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */\n\n  unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */\n\n  /* These fields record data obtained from optional markers recognized by\n   * the JPEG library.\n   */\n  boolean saw_JFIF_marker;\t/* TRUE iff a JFIF APP0 marker was found */\n  /* Data copied from JFIF marker: */\n  UINT8 density_unit;\t\t/* JFIF code for pixel size units */\n  UINT16 X_density;\t\t/* Horizontal pixel density */\n  UINT16 Y_density;\t\t/* Vertical pixel density */\n  boolean saw_Adobe_marker;\t/* TRUE iff an Adobe APP14 marker was found */\n  UINT8 Adobe_transform;\t/* Color transform code from Adobe marker */\n\n  boolean CCIR601_sampling;\t/* TRUE=first samples are cosited */\n\n  /* Remaining fields are known throughout decompressor, but generally\n   * should not be touched by a surrounding application.\n   */\n\n  /*\n   * These fields are computed during decompression startup\n   */\n  int max_h_samp_factor;\t/* largest h_samp_factor */\n  int max_v_samp_factor;\t/* largest v_samp_factor */\n\n  int min_DCT_scaled_size;\t/* smallest DCT_scaled_size of any component */\n\n  JDIMENSION total_iMCU_rows;\t/* # of iMCU rows in image */\n  /* The coefficient controller's input and output progress is measured in\n   * units of \"iMCU\" (interleaved MCU) rows.  These are the same as MCU rows\n   * in fully interleaved JPEG scans, but are used whether the scan is\n   * interleaved or not.  We define an iMCU row as v_samp_factor DCT block\n   * rows of each component.  Therefore, the IDCT output contains\n   * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row.\n   */\n\n  JSAMPLE * sample_range_limit; /* table for fast range-limiting */\n\n  /*\n   * These fields are valid during any one scan.\n   * They describe the components and MCUs actually appearing in the scan.\n   * Note that the decompressor output side must not use these fields.\n   */\n  int comps_in_scan;\t\t/* # of JPEG components in this scan */\n  jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];\n  /* *cur_comp_info[i] describes component that appears i'th in SOS */\n\n  JDIMENSION MCUs_per_row;\t/* # of MCUs across the image */\n  JDIMENSION MCU_rows_in_scan;\t/* # of MCU rows in the image */\n\n  int blocks_in_MCU;\t\t/* # of DCT blocks per MCU */\n  int MCU_membership[D_MAX_BLOCKS_IN_MCU];\n  /* MCU_membership[i] is index in cur_comp_info of component owning */\n  /* i'th block in an MCU */\n\n  int Ss, Se, Ah, Al;\t\t/* progressive JPEG parameters for scan */\n\n  /* This field is shared between entropy decoder and marker parser.\n   * It is either zero or the code of a JPEG marker that has been\n   * read from the data source, but has not yet been processed.\n   */\n  int unread_marker;\n\n  /*\n   * Links to decompression subobjects (methods, private variables of modules)\n   */\n  struct jpeg_decomp_master * master;\n  struct jpeg_d_main_controller * main;\n  struct jpeg_d_coef_controller * coef;\n  struct jpeg_d_post_controller * post;\n  struct jpeg_input_controller * inputctl;\n  struct jpeg_marker_reader * marker;\n  struct jpeg_entropy_decoder * entropy;\n  struct jpeg_inverse_dct * idct;\n  struct jpeg_upsampler * upsample;\n  struct jpeg_color_deconverter * cconvert;\n  struct jpeg_color_quantizer * cquantize;\n};\n\n\n/* \"Object\" declarations for JPEG modules that may be supplied or called\n * directly by the surrounding application.\n * As with all objects in the JPEG library, these structs only define the\n * publicly visible methods and state variables of a module.  Additional\n * private fields may exist after the public ones.\n */\n\n\n/* Error handler object */\n\nstruct jpeg_error_mgr {\n  /* Error exit handler: does not return to caller */\n  JMETHOD(void, error_exit, (j_common_ptr cinfo));\n  /* Conditionally emit a trace or warning message */\n  JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level));\n  /* Routine that actually outputs a trace or error message */\n  JMETHOD(void, output_message, (j_common_ptr cinfo));\n  /* Format a message string for the most recent JPEG error or message */\n  JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer));\n#define JMSG_LENGTH_MAX  200\t/* recommended size of format_message buffer */\n  /* Reset error state variables at start of a new image */\n  JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo));\n  \n  /* The message ID code and any parameters are saved here.\n   * A message can have one string parameter or up to 8 int parameters.\n   */\n  int msg_code;\n#define JMSG_STR_PARM_MAX  80\n  union {\n    int i[8];\n    char s[JMSG_STR_PARM_MAX];\n  } msg_parm;\n  \n  /* Standard state variables for error facility */\n  \n  int trace_level;\t\t/* max msg_level that will be displayed */\n  \n  /* For recoverable corrupt-data errors, we emit a warning message,\n   * but keep going unless emit_message chooses to abort.  emit_message\n   * should count warnings in num_warnings.  The surrounding application\n   * can check for bad data by seeing if num_warnings is nonzero at the\n   * end of processing.\n   */\n  long num_warnings;\t\t/* number of corrupt-data warnings */\n\n  /* These fields point to the table(s) of error message strings.\n   * An application can change the table pointer to switch to a different\n   * message list (typically, to change the language in which errors are\n   * reported).  Some applications may wish to add additional error codes\n   * that will be handled by the JPEG library error mechanism; the second\n   * table pointer is used for this purpose.\n   *\n   * First table includes all errors generated by JPEG library itself.\n   * Error code 0 is reserved for a \"no such error string\" message.\n   */\n  const char * const * jpeg_message_table; /* Library errors */\n  int last_jpeg_message;    /* Table contains strings 0..last_jpeg_message */\n  /* Second table can be added by application (see cjpeg/djpeg for example).\n   * It contains strings numbered first_addon_message..last_addon_message.\n   */\n  const char * const * addon_message_table; /* Non-library errors */\n  int first_addon_message;\t/* code for first string in addon table */\n  int last_addon_message;\t/* code for last string in addon table */\n};\n\n\n/* Progress monitor object */\n\nstruct jpeg_progress_mgr {\n  JMETHOD(void, progress_monitor, (j_common_ptr cinfo));\n\n  long pass_counter;\t\t/* work units completed in this pass */\n  long pass_limit;\t\t/* total number of work units in this pass */\n  int completed_passes;\t\t/* passes completed so far */\n  int total_passes;\t\t/* total number of passes expected */\n};\n\n\n/* Data destination object for compression */\n\nstruct jpeg_destination_mgr {\n  JOCTET * next_output_byte;\t/* => next byte to write in buffer */\n  size_t free_in_buffer;\t/* # of byte spaces remaining in buffer */\n\n  JMETHOD(void, init_destination, (j_compress_ptr cinfo));\n  JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo));\n  JMETHOD(void, term_destination, (j_compress_ptr cinfo));\n};\n\n\n/* Data source object for decompression */\n\nstruct jpeg_source_mgr {\n  const JOCTET * next_input_byte; /* => next byte to read from buffer */\n  size_t bytes_in_buffer;\t/* # of bytes remaining in buffer */\n\n  JMETHOD(void, init_source, (j_decompress_ptr cinfo));\n  JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo));\n  JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes));\n  JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired));\n  JMETHOD(void, term_source, (j_decompress_ptr cinfo));\n};\n\n\n/* Memory manager object.\n * Allocates \"small\" objects (a few K total), \"large\" objects (tens of K),\n * and \"really big\" objects (virtual arrays with backing store if needed).\n * The memory manager does not allow individual objects to be freed; rather,\n * each created object is assigned to a pool, and whole pools can be freed\n * at once.  This is faster and more convenient than remembering exactly what\n * to free, especially where malloc()/free() are not too speedy.\n * NB: alloc routines never return NULL.  They exit to error_exit if not\n * successful.\n */\n\n#define JPOOL_PERMANENT\t0\t/* lasts until master record is destroyed */\n#define JPOOL_IMAGE\t1\t/* lasts until done with image/datastream */\n#define JPOOL_NUMPOOLS\t2\n\ntypedef struct jvirt_sarray_control * jvirt_sarray_ptr;\ntypedef struct jvirt_barray_control * jvirt_barray_ptr;\n\n\nstruct jpeg_memory_mgr {\n  /* Method pointers */\n  JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id,\n\t\t\t\tsize_t sizeofobject));\n  JMETHOD(void FAR *, alloc_large, (j_common_ptr cinfo, int pool_id,\n\t\t\t\t     size_t sizeofobject));\n  JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id,\n\t\t\t\t     JDIMENSION samplesperrow,\n\t\t\t\t     JDIMENSION numrows));\n  JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id,\n\t\t\t\t      JDIMENSION blocksperrow,\n\t\t\t\t      JDIMENSION numrows));\n  JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo,\n\t\t\t\t\t\t  int pool_id,\n\t\t\t\t\t\t  boolean pre_zero,\n\t\t\t\t\t\t  JDIMENSION samplesperrow,\n\t\t\t\t\t\t  JDIMENSION numrows,\n\t\t\t\t\t\t  JDIMENSION maxaccess));\n  JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo,\n\t\t\t\t\t\t  int pool_id,\n\t\t\t\t\t\t  boolean pre_zero,\n\t\t\t\t\t\t  JDIMENSION blocksperrow,\n\t\t\t\t\t\t  JDIMENSION numrows,\n\t\t\t\t\t\t  JDIMENSION maxaccess));\n  JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo));\n  JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo,\n\t\t\t\t\t   jvirt_sarray_ptr ptr,\n\t\t\t\t\t   JDIMENSION start_row,\n\t\t\t\t\t   JDIMENSION num_rows,\n\t\t\t\t\t   boolean writable));\n  JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo,\n\t\t\t\t\t    jvirt_barray_ptr ptr,\n\t\t\t\t\t    JDIMENSION start_row,\n\t\t\t\t\t    JDIMENSION num_rows,\n\t\t\t\t\t    boolean writable));\n  JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id));\n  JMETHOD(void, self_destruct, (j_common_ptr cinfo));\n\n  /* Limit on memory allocation for this JPEG object.  (Note that this is\n   * merely advisory, not a guaranteed maximum; it only affects the space\n   * used for virtual-array buffers.)  May be changed by outer application\n   * after creating the JPEG object.\n   */\n  long max_memory_to_use;\n};\n\n\n/* Routine signature for application-supplied marker processing methods.\n * Need not pass marker code since it is stored in cinfo->unread_marker.\n */\ntypedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo));\n\n\n/* Declarations for routines called by application.\n * The JPP macro hides prototype parameters from compilers that can't cope.\n * Note JPP requires double parentheses.\n */\n\n#ifdef HAVE_PROTOTYPES\n#define JPP(arglist)\targlist\n#else\n#define JPP(arglist)\t()\n#endif\n\n\n/* Short forms of external names for systems with brain-damaged linkers.\n * We shorten external names to be unique in the first six letters, which\n * is good enough for all known systems.\n * (If your compiler itself needs names to be unique in less than 15 \n * characters, you are out of luck.  Get a better compiler.)\n */\n\n#ifdef NEED_SHORT_EXTERNAL_NAMES\n#define jpeg_std_error\t\tjStdError\n#define jpeg_create_compress\tjCreaCompress\n#define jpeg_create_decompress\tjCreaDecompress\n#define jpeg_destroy_compress\tjDestCompress\n#define jpeg_destroy_decompress\tjDestDecompress\n#define jpeg_stdio_dest\t\tjStdDest\n#define jpeg_stdio_src\t\tjStdSrc\n#define jpeg_set_defaults\tjSetDefaults\n#define jpeg_set_colorspace\tjSetColorspace\n#define jpeg_default_colorspace\tjDefColorspace\n#define jpeg_set_quality\tjSetQuality\n#define jpeg_set_linear_quality\tjSetLQuality\n#define jpeg_add_quant_table\tjAddQuantTable\n#define jpeg_quality_scaling\tjQualityScaling\n#define jpeg_simple_progression\tjSimProgress\n#define jpeg_suppress_tables\tjSuppressTables\n#define jpeg_alloc_quant_table\tjAlcQTable\n#define jpeg_alloc_huff_table\tjAlcHTable\n#define jpeg_start_compress\tjStrtCompress\n#define jpeg_write_scanlines\tjWrtScanlines\n#define jpeg_finish_compress\tjFinCompress\n#define jpeg_write_raw_data\tjWrtRawData\n#define jpeg_write_marker\tjWrtMarker\n#define jpeg_write_tables\tjWrtTables\n#define jpeg_read_header\tjReadHeader\n#define jpeg_start_decompress\tjStrtDecompress\n#define jpeg_read_scanlines\tjReadScanlines\n#define jpeg_finish_decompress\tjFinDecompress\n#define jpeg_read_raw_data\tjReadRawData\n#define jpeg_has_multiple_scans\tjHasMultScn\n#define jpeg_start_output\tjStrtOutput\n#define jpeg_finish_output\tjFinOutput\n#define jpeg_input_complete\tjInComplete\n#define jpeg_new_colormap\tjNewCMap\n#define jpeg_consume_input\tjConsumeInput\n#define jpeg_calc_output_dimensions\tjCalcDimensions\n#define jpeg_set_marker_processor\tjSetMarker\n#define jpeg_read_coefficients\tjReadCoefs\n#define jpeg_write_coefficients\tjWrtCoefs\n#define jpeg_copy_critical_parameters\tjCopyCrit\n#define jpeg_abort_compress\tjAbrtCompress\n#define jpeg_abort_decompress\tjAbrtDecompress\n#define jpeg_abort\t\tjAbort\n#define jpeg_destroy\t\tjDestroy\n#define jpeg_resync_to_restart\tjResyncRestart\n#endif /* NEED_SHORT_EXTERNAL_NAMES */\n\n\n/* Default error-management setup */\nEXTERN struct jpeg_error_mgr *jpeg_std_error JPP((struct jpeg_error_mgr *err));\n\n/* Initialization and destruction of JPEG compression objects */\n/* NB: you must set up the error-manager BEFORE calling jpeg_create_xxx */\nEXTERN void jpeg_create_compress JPP((j_compress_ptr cinfo));\nEXTERN void jpeg_create_decompress JPP((j_decompress_ptr cinfo));\nEXTERN void jpeg_destroy_compress JPP((j_compress_ptr cinfo));\nEXTERN void jpeg_destroy_decompress JPP((j_decompress_ptr cinfo));\n\n/* Standard data source and destination managers: stdio streams. */\n/* Caller is responsible for opening the file before and closing after. */\nEXTERN void jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile));\nEXTERN void jpeg_stdio_src JPP((j_decompress_ptr cinfo, unsigned char *infile));\n\n/* Default parameter setup for compression */\nEXTERN void jpeg_set_defaults JPP((j_compress_ptr cinfo));\n/* Compression parameter setup aids */\nEXTERN void jpeg_set_colorspace JPP((j_compress_ptr cinfo,\n\t\t\t\t     J_COLOR_SPACE colorspace));\nEXTERN void jpeg_default_colorspace JPP((j_compress_ptr cinfo));\nEXTERN void jpeg_set_quality JPP((j_compress_ptr cinfo, int quality,\n\t\t\t\t  boolean force_baseline));\nEXTERN void jpeg_set_linear_quality JPP((j_compress_ptr cinfo,\n\t\t\t\t\t int scale_factor,\n\t\t\t\t\t boolean force_baseline));\nEXTERN void jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl,\n\t\t\t\t      const unsigned int *basic_table,\n\t\t\t\t      int scale_factor,\n\t\t\t\t      boolean force_baseline));\nEXTERN int jpeg_quality_scaling JPP((int quality));\nEXTERN void jpeg_simple_progression JPP((j_compress_ptr cinfo));\nEXTERN void jpeg_suppress_tables JPP((j_compress_ptr cinfo,\n\t\t\t\t      boolean suppress));\nEXTERN JQUANT_TBL * jpeg_alloc_quant_table JPP((j_common_ptr cinfo));\nEXTERN JHUFF_TBL * jpeg_alloc_huff_table JPP((j_common_ptr cinfo));\n\n/* Main entry points for compression */\nEXTERN void jpeg_start_compress JPP((j_compress_ptr cinfo,\n\t\t\t\t     boolean write_all_tables));\nEXTERN JDIMENSION jpeg_write_scanlines JPP((j_compress_ptr cinfo,\n\t\t\t\t\t    JSAMPARRAY scanlines,\n\t\t\t\t\t    JDIMENSION num_lines));\nEXTERN void jpeg_finish_compress JPP((j_compress_ptr cinfo));\n\n/* Replaces jpeg_write_scanlines when writing raw downsampled data. */\nEXTERN JDIMENSION jpeg_write_raw_data JPP((j_compress_ptr cinfo,\n\t\t\t\t\t   JSAMPIMAGE data,\n\t\t\t\t\t   JDIMENSION num_lines));\n\n/* Write a special marker.  See libjpeg.doc concerning safe usage. */\nEXTERN void jpeg_write_marker JPP((j_compress_ptr cinfo, int marker,\n\t\t\t\t   const JOCTET *dataptr, unsigned int datalen));\n\n/* Alternate compression function: just write an abbreviated table file */\nEXTERN void jpeg_write_tables JPP((j_compress_ptr cinfo));\n\n/* Decompression startup: read start of JPEG datastream to see what's there */\nEXTERN int jpeg_read_header JPP((j_decompress_ptr cinfo,\n\t\t\t\t boolean require_image));\n/* Return value is one of: */\n#define JPEG_SUSPENDED\t\t0 /* Suspended due to lack of input data */\n#define JPEG_HEADER_OK\t\t1 /* Found valid image datastream */\n#define JPEG_HEADER_TABLES_ONLY\t2 /* Found valid table-specs-only datastream */\n/* If you pass require_image = TRUE (normal case), you need not check for\n * a TABLES_ONLY return code; an abbreviated file will cause an error exit.\n * JPEG_SUSPENDED is only possible if you use a data source module that can\n * give a suspension return (the stdio source module doesn't).\n */\n\n/* Main entry points for decompression */\nEXTERN boolean jpeg_start_decompress JPP((j_decompress_ptr cinfo));\nEXTERN JDIMENSION jpeg_read_scanlines JPP((j_decompress_ptr cinfo,\n\t\t\t\t\t   JSAMPARRAY scanlines,\n\t\t\t\t\t   JDIMENSION max_lines));\nEXTERN boolean jpeg_finish_decompress JPP((j_decompress_ptr cinfo));\n\n/* Replaces jpeg_read_scanlines when reading raw downsampled data. */\nEXTERN JDIMENSION jpeg_read_raw_data JPP((j_decompress_ptr cinfo,\n\t\t\t\t\t  JSAMPIMAGE data,\n\t\t\t\t\t  JDIMENSION max_lines));\n\n/* Additional entry points for buffered-image mode. */\nEXTERN boolean jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo));\nEXTERN boolean jpeg_start_output JPP((j_decompress_ptr cinfo,\n\t\t\t\t      int scan_number));\nEXTERN boolean jpeg_finish_output JPP((j_decompress_ptr cinfo));\nEXTERN boolean jpeg_input_complete JPP((j_decompress_ptr cinfo));\nEXTERN void jpeg_new_colormap JPP((j_decompress_ptr cinfo));\nEXTERN int jpeg_consume_input JPP((j_decompress_ptr cinfo));\n/* Return value is one of: */\n/* #define JPEG_SUSPENDED\t0    Suspended due to lack of input data */\n#define JPEG_REACHED_SOS\t1 /* Reached start of new scan */\n#define JPEG_REACHED_EOI\t2 /* Reached end of image */\n#define JPEG_ROW_COMPLETED\t3 /* Completed one iMCU row */\n#define JPEG_SCAN_COMPLETED\t4 /* Completed last iMCU row of a scan */\n\n/* Precalculate output dimensions for current decompression parameters. */\nEXTERN void jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo));\n\n/* Install a special processing method for COM or APPn markers. */\nEXTERN void jpeg_set_marker_processor JPP((j_decompress_ptr cinfo,\n\t\t\t\t\t   int marker_code,\n\t\t\t\t\t   jpeg_marker_parser_method routine));\n\n/* Read or write raw DCT coefficients --- useful for lossless transcoding. */\nEXTERN jvirt_barray_ptr * jpeg_read_coefficients JPP((j_decompress_ptr cinfo));\nEXTERN void jpeg_write_coefficients JPP((j_compress_ptr cinfo,\n\t\t\t\t\t jvirt_barray_ptr * coef_arrays));\nEXTERN void jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo,\n\t\t\t\t\t       j_compress_ptr dstinfo));\n\n/* If you choose to abort compression or decompression before completing\n * jpeg_finish_(de)compress, then you need to clean up to release memory,\n * temporary files, etc.  You can just call jpeg_destroy_(de)compress\n * if you're done with the JPEG object, but if you want to clean it up and\n * reuse it, call this:\n */\nEXTERN void jpeg_abort_compress JPP((j_compress_ptr cinfo));\nEXTERN void jpeg_abort_decompress JPP((j_decompress_ptr cinfo));\n\n/* Generic versions of jpeg_abort and jpeg_destroy that work on either\n * flavor of JPEG object.  These may be more convenient in some places.\n */\nEXTERN void jpeg_abort JPP((j_common_ptr cinfo));\nEXTERN void jpeg_destroy JPP((j_common_ptr cinfo));\n\n/* Default restart-marker-resync procedure for use by data source modules */\nEXTERN boolean jpeg_resync_to_restart JPP((j_decompress_ptr cinfo,\n\t\t\t\t\t   int desired));\n\n\n/* These marker codes are exported since applications and data source modules\n * are likely to want to use them.\n */\n\n#define JPEG_RST0\t0xD0\t/* RST0 marker code */\n#define JPEG_EOI\t0xD9\t/* EOI marker code */\n#define JPEG_APP0\t0xE0\t/* APP0 marker code */\n#define JPEG_COM\t0xFE\t/* COM marker code */\n\n\n/* If we have a brain-damaged compiler that emits warnings (or worse, errors)\n * for structure definitions that are never filled in, keep it quiet by\n * supplying dummy definitions for the various substructures.\n */\n\n#ifdef INCOMPLETE_TYPES_BROKEN\n#ifndef JPEG_INTERNALS\t\t/* will be defined in jpegint.h */\nstruct jvirt_sarray_control { long dummy; };\nstruct jvirt_barray_control { long dummy; };\nstruct jpeg_comp_master { long dummy; };\nstruct jpeg_c_main_controller { long dummy; };\nstruct jpeg_c_prep_controller { long dummy; };\nstruct jpeg_c_coef_controller { long dummy; };\nstruct jpeg_marker_writer { long dummy; };\nstruct jpeg_color_converter { long dummy; };\nstruct jpeg_downsampler { long dummy; };\nstruct jpeg_forward_dct { long dummy; };\nstruct jpeg_entropy_encoder { long dummy; };\nstruct jpeg_decomp_master { long dummy; };\nstruct jpeg_d_main_controller { long dummy; };\nstruct jpeg_d_coef_controller { long dummy; };\nstruct jpeg_d_post_controller { long dummy; };\nstruct jpeg_input_controller { long dummy; };\nstruct jpeg_marker_reader { long dummy; };\nstruct jpeg_entropy_decoder { long dummy; };\nstruct jpeg_inverse_dct { long dummy; };\nstruct jpeg_upsampler { long dummy; };\nstruct jpeg_color_deconverter { long dummy; };\nstruct jpeg_color_quantizer { long dummy; };\n#endif /* JPEG_INTERNALS */\n#endif /* INCOMPLETE_TYPES_BROKEN */\n\n\n/*\n * The JPEG library modules define JPEG_INTERNALS before including this file.\n * The internal structure declarations are read only when that is true.\n * Applications using the library should not include jpegint.h, but may wish\n * to include jerror.h.\n */\n\n#ifdef JPEG_INTERNALS\n#include \"jpegint.h\"\t\t/* fetch private declarations */\n#include \"jerror.h\"\t\t/* fetch error codes too */\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* JPEGLIB_H */\n"
  },
  {
    "path": "libs/pak/pak.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<VisualStudioProject\n\tProjectType=\"Visual C++\"\n\tVersion=\"7.10\"\n\tName=\"pak\"\n\tSccProjectName=\"&quot;$/source/q3radiant&quot;, FEFAAAAA\"\n\tSccLocalPath=\"..\\..\\q3radiant\">\n\t<Platforms>\n\t\t<Platform\n\t\t\tName=\"Win32\"/>\n\t</Platforms>\n\t<Configurations>\n\t\t<Configuration\n\t\t\tName=\"Debug|Win32\"\n\t\t\tOutputDirectory=\".\\Debug\"\n\t\t\tIntermediateDirectory=\".\\Debug\"\n\t\t\tConfigurationType=\"4\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tAdditionalIncludeDirectories=\"..\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_LIB\"\n\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tRuntimeTypeInfo=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Debug/pak.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug/\"\n\t\t\t\tObjectFile=\".\\Debug/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Debug/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"\n\t\t\t\tCompileAs=\"0\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLibrarianTool\"\n\t\t\t\tOutputFile=\"..\\pakd.lib\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Release|Win32\"\n\t\t\tOutputDirectory=\".\\Release\"\n\t\t\tIntermediateDirectory=\".\\Release\"\n\t\t\tConfigurationType=\"4\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tAdditionalIncludeDirectories=\"..\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_LIB\"\n\t\t\t\tRuntimeLibrary=\"0\"\n\t\t\t\tRuntimeTypeInfo=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release/pak.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release/\"\n\t\t\t\tObjectFile=\".\\Release/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tCompileAs=\"0\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLibrarianTool\"\n\t\t\t\tOutputFile=\"..\\pak.lib\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t</Configurations>\n\t<References>\n\t</References>\n\t<Files>\n\t\t<Filter\n\t\t\tName=\"Source Files\"\n\t\t\tFilter=\"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"pakstuff.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"unzip.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Header Files\"\n\t\t\tFilter=\"h;hpp;hxx;hm;inl\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\pakstuff.h\">\n\t\t\t</File>\n\t\t</Filter>\n\t</Files>\n\t<Globals>\n\t</Globals>\n</VisualStudioProject>\n"
  },
  {
    "path": "libs/pak/pakstuff.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include <stdio.h>\n#include <stdarg.h>\n#include <stdlib.h>\n#include <string.h>\n#include <windows.h>\n#include \"io.h\"\n#include \"pakstuff.h\"\n#include \"unzip.h\"\n//#include \"cmdlib.h\"\n#include \"str.h\"\n\nint m_nPAKIndex;\nFILE* pakfile[16];\nstruct PACKDirectory\tpakdir;\nPACKDirPtr\t\t\t\tpakdirptr = &pakdir;\nUInt16\t\t\t\t\tdirsize;\nboolean\t\t\t\t\tpakopen = false;\nint\t\t\t\t\t\tf_type;\nDIRECTORY\t\t\t\t*paktextures = NULL;\nboolean\t\t\t\t\tHavePakColormap;\nUInt32\t\t\t\t\tPakColormapOffset;\nUInt32\t\t\t\t\tPakColormapSize;\nDIRECTORY\t\t\t\t*dirhead = NULL;\nboolean g_bPK3 = false;\nchar g_strBasePath[1024];\n\nstruct PK3FileInfo\n{\n  unzFile m_zFile;\n  char *m_pName;\n  unz_s m_zInfo;\n  long m_lSize;\n  ~PK3FileInfo()\n  {\n    delete []m_pName;\n  }\n  bool operator ==(const PK3FileInfo& rhs) const { return strcmp(m_pName, rhs.m_pName) == 0; }\n};\n\n#define __PATHSEPERATOR   '/'\n\n#define LOG_PAKFAIL\n\n#ifdef LOG_PAKFAIL\n\nclass LogFile\n{\npublic:\n  FILE *m_pFile;\n  LogFile(const char* pName)\n  {\n    m_pFile = fopen(pName, \"w\");\n  }\n  ~LogFile()\n  {\n    if (m_pFile)\n    {\n      fclose(m_pFile);\n    }\n  }\n  void Log(const char *pFormat, ...)\n  {\n    va_list arg_ptr;\n    va_start(arg_ptr, pFormat);\n    fprintf(m_pFile, pFormat, arg_ptr);\n    va_end(arg_ptr);\n  }\n};\n\nLogFile g_LogFile(\"c:\\\\paklog.txt\");\n#endif\n\ntemplate <class T> class StrPtr : public Str\n{\nprotected:\n  T* m_pPtr;\n  StrPtr()\n  {\n    m_pPtr = NULL;\n  }\n\n  StrPtr(const char *pStr, T *p) : Str(pStr)\n  {\n    m_pPtr = p;\n  }\n\n  T* Ptr()\n  {\n    return m_pPtr;\n  }\n\n  T& Ref()\n  {\n    return *m_pPtr;\n  }\n    \n\n};\n// PtrList\n// a list of ptrs\n// \ntemplate <class T> class PtrList\n{\nprotected:\n  T *m_pPtr;\n  PtrList *m_pNext;\n\npublic:\n\n  PtrList()\n  {\n    m_pNext = NULL;\n    m_pPtr = NULL;\n  }\n\n  PtrList(T *ip)\n  {\n    m_pNext = NULL;\n    m_pPtr = ip;\n  }\n\n  ~PtrList()\n  {\n    delete m_pPtr;\n  }\n\n  PtrList* Next()\n  {\n    return m_pNext;\n  }\n\n  void Add(T *ip)\n  {\n    PtrList *pl = this;\n    while (pl && pl->m_pNext)\n    {\n      pl = pl->Next();\n    }\n    pl->m_pNext = new PtrList(ip);\n  }\n\n  void Remove()\n  {\n    PtrList *p = m_pNext;\n    if (p)\n    {\n      while (p->m_pNext != this && p->m_pNext != NULL)\n      {\n        p = p->m_pNext;\n      }\n      if (p->m_pNext == this)\n      {\n        p->m_pNext = m_pNext;\n      }\n    }\n  }\n\n  virtual PtrList* Find(T *ip)\n  {\n    PtrList *p = m_pNext;\n    while (p)\n    {\n      if (*p->m_pPtr == *ip)\n      {\n        return p;\n      }\n      p = p->m_pNext;\n    }\n    return NULL;\n  }\n\n  // remove vp from the list\n  void Remove(T *ip)\n  {\n    PtrList *p = Find(ip);\n    if (p)\n    {\n      p->Remove();\n    }\n  }\n\n  T* Ptr()\n  {\n    return m_pPtr;\n  }\n\n  T& Ref()\n  {\n    return *m_pPtr;\n  }\n\n  void RemoveAll()\n  {\n    PtrList *p = m_pNext;\n    while (p)\n    {\n      PtrList *p2 = p;\n      p = p->m_pNext;\n      delete p2;\n    }\n  }\n};\n\n\ntypedef PtrList<unzFile> ZFileList;\ntypedef PtrList<Str> StrList;\ntypedef PtrList<PK3FileInfo> PK3List;\n\n\nStrList g_PK3TexturePaths;\nPK3List g_PK3Files;\nZFileList g_zFiles;\n#define WORK_LEN 1024\n#define TEXTURE_PATH \"textures\"\n#define PATH_SEPERATORS \"/\\\\:\\0\"\n\n\nchar* __StrDup(char* pStr)\n{ \n  if (pStr)\n  {\n    return strcpy(new char[strlen(pStr)+1], pStr); \n  }\n  return NULL;\n}\n\nchar* __StrDup(const char* pStr)\n{ \n  if (pStr)\n  {\n    return strcpy(new char[strlen(pStr)+1], pStr); \n  }\n  return NULL;\n}\n\n#define MEM_BLOCKSIZE 4096\nvoid* __qblockmalloc(size_t nSize)\n{\n\tvoid *b;\n  // round up to threshold\n  int nAllocSize = nSize % MEM_BLOCKSIZE;\n  if ( nAllocSize > 0)\n  {\n    nSize += MEM_BLOCKSIZE - nAllocSize;\n  }\n\tb = malloc(nSize + 1);\n\tmemset (b, 0, nSize);\n\treturn b;\n}\n\nvoid* __qmalloc (size_t nSize)\n{\n\tvoid *b;\n\tb = malloc(nSize + 1);\n\tmemset (b, 0, nSize);\n\treturn b;\n}\n\n\n/*\n====================\nExtract file parts\n====================\n*/\nvoid __ExtractFilePath (const char *path, char *dest)\n{\n\tconst char *src;\n\n\tsrc = path + strlen(path) - 1;\n\n//\n// back up until a \\ or the start\n//\n\twhile (src != path && *(src-1) != __PATHSEPERATOR)\n\t\tsrc--;\n\n\tmemcpy (dest, path, src-path);\n\tdest[src-path] = 0;\n}\n\nvoid __ExtractFileName (const char *path, char *dest)\n{\n\tconst char *src;\n\n\tsrc = path + strlen(path) - 1;\n\n//\n// back up until a \\ or the start\n//\n\twhile (src != path && *(src-1) != '/' \n\t\t && *(src-1) != '\\\\' )\n\t\tsrc--;\n\n\twhile (*src)\n\t{\n\t\t*dest++ = *src++;\n\t}\n\t*dest = 0;\n}\n\nvoid __ExtractFileBase (const char *path, char *dest)\n{\n\tconst char *src;\n\n\tsrc = path + strlen(path) - 1;\n\n//\n// back up until a \\ or the start\n//\n\twhile (src != path && *(src-1) != '/' \n\t\t && *(src-1) != '\\\\' )\n\t\tsrc--;\n\n\twhile (*src && *src != '.')\n\t{\n\t\t*dest++ = *src++;\n\t}\n\t*dest = 0;\n}\n\nvoid __ExtractFileExtension (const char *path, char *dest)\n{\n\tconst char *src;\n\n\tsrc = path + strlen(path) - 1;\n\n//\n// back up until a . or the start\n//\n\twhile (src != path && *(src-1) != '.')\n\t\tsrc--;\n\tif (src == path)\n\t{\n\t\t*dest = 0;\t// no extension\n\t\treturn;\n\t}\n\n\tstrcpy (dest,src);\n}\n\n\nvoid __ConvertDOSToUnixName( char *dst, const char *src )\n{\n\twhile ( *src )\n\t{\n\t\tif ( *src == '\\\\' )\n\t\t\t*dst = '/';\n\t\telse\n\t\t\t*dst = *src;\n\t\tdst++; src++;\n\t}\n\t*dst = 0;\n}\n\n\n\n\n\nvoid AddSlash(Str& str)\n{\n  int nLen = str.GetLength();\n  if (nLen > 0)\n  {\n    if (str[nLen-1] != '\\\\' && str[nLen-1] != '/')\n      str += '\\\\';\n  }\n}\n\nvoid FindReplace(Str& strContents, const char* pTag, const char* pValue)\n{\n  if (strcmp(pTag, pValue) == 0)\n    return;\n  for (int nPos = strContents.Find(pTag); nPos >= 0; nPos = strContents.Find(pTag))\n  {\n    int nRightLen = strContents.GetLength() - strlen(pTag) - nPos;\n    Str strLeft(strContents.Left(nPos));\n    Str strRight(strContents.Right(nRightLen));\n    strLeft += pValue;\n    strLeft += strRight;\n    strContents = strLeft;\n  }\n}\n\n\n\n\n\nvoid ProgError(char *errstr, ...)\n{\n  va_list args;\n\n  va_start(args, errstr);\n  printf(\"\\nProgram Error: *** \");\n  vprintf(errstr, args);\n  printf(\" ***\\n\");\n  va_end(args);\n  exit(5);\n}\n\nboolean ReadBytes(FILE *file, void *addr, UInt32 size)\n{\n  while (size > 0x8000)\n    {\n      if (fread(addr, 1, 0x8000, file) != 0x8000)\n\treturn false;\n      addr = (char *)addr + 0x8000;\n      size -= 0x8000;\n    }\n  if (fread(addr, 1, size, file) != size)\n    return false;\n  return true;\n}\nint ReadMagic(FILE *file)\n{\n  UInt8 buf[4];\n\n  if (ReadBytes(file, buf, 4) == FALSE)\n    return FTYPE_ERROR;\n  if (!strncmp(reinterpret_cast<const char*>(&buf[0]), \"IWAD\", 4))\n    return FTYPE_IWAD;\n  if (!strncmp(reinterpret_cast<const char*>(&buf[0]), \"PWAD\", 4))\n    return FTYPE_PWAD;\n  if (!strncmp(reinterpret_cast<const char*>(&buf[0]), \"PACK\", 4))\n    return FTYPE_PACK;\n  if (!strncmp(reinterpret_cast<const char*>(&buf[0]), \"WAD2\", 4))\n    return FTYPE_WAD2;\n  if (buf[0] == 0x17 && buf[1] == 0 && buf[2] == 0 && buf[3] == 0)\n    return FTYPE_BSP;\n  if (!strncmp(reinterpret_cast<const char*>(&buf[0]), \"IDPO\", 4))\n    return FTYPE_MODEL;\n  if (!strncmp(reinterpret_cast<const char*>(&buf[0]), \"IDSP\", 4))\n    return FTYPE_SPRITE;\n  if (!strncmp(reinterpret_cast<const char*>(&buf[0]), \"RIFF\", 4))\n    return FTYPE_WAV;\n  if (!strncmp(reinterpret_cast<const char*>(&buf[0]), \".snd\", 4))\n    return FTYPE_AU;\n  if (buf[0] == 'P')\n    {\n      if (buf[1] == '1')\n\treturn FTYPE_PBM_ASC;\n      if (buf[1] == '2')\n\treturn FTYPE_PGM_ASC;\n      if (buf[1] == '3')\n\treturn FTYPE_PPM_ASC;\n      if (buf[1] == '4')\n\treturn FTYPE_PBM_RAW;\n      if (buf[1] == '5')\n\treturn FTYPE_PGM_RAW;\n      if (buf[1] == '6')\n\treturn FTYPE_PPM_RAW;\n    }\n  if (buf[0] == 'B' && buf[1] == 'M')\n    return FTYPE_BMP;\n  if (!strncmp(reinterpret_cast<const char*>(&buf[0]), \"GIF8\", 4))\n    return FTYPE_GIF;\n  if (buf[0] == 0x0a && buf[1] == 0x05 && buf[2] == 0x01 && buf[3] == 0x08)\n    return FTYPE_PCX;\n  return FTYPE_UNKNOWN;\n}\nFILE *OpenFileReadMagic(const char *filename, int *ftype_r)\n{\n  FILE *f;\n\n  *ftype_r = FTYPE_ERROR;\n  if ((f = fopen(filename, \"rb\")) == NULL)\n    return NULL;\n  *ftype_r = ReadMagic(f);\n  if (*ftype_r == FTYPE_ERROR)\n    {\n      fclose(f);\n      return NULL;\n    }\n  return f;\n}\nboolean WriteBytes(FILE *file, void *addr, UInt32 size)\n{\n  while (size > 0x8000)\n    {\n      if (fwrite(addr, 1, 0x8000, file) != 0x8000)\n\treturn FALSE;\n      addr = (char *)addr + 0x8000;\n      size -= 0x8000;\n    }\n  if (fwrite(addr, 1, size, file) != size)\n    return FALSE;\n  return TRUE;\n}\nchar *ConvertFilePath(char *filename)\n{\n  char *cp;\n  \n  if (filename == NULL)\n    ProgError(\"BUG: cannot convert a NULL pathname\");\n  for (cp = filename; *cp; cp++)\n    if (*cp == '/' || *cp == '\\\\')\n      {\n#ifdef QEU_DOS\n\t*cp = '\\\\';\n#else\n\t*cp = '/';\n#endif\n      }\n  return filename;\n}\n\n/*\n * Read the PACK directory into memory.  The optional offset to the\n * start of the PACK file is given in \"offset\".  The number of files in\n * the directory is returned in *dirsize_r.\n */\nPACKDirPtr ReadPACKDirectory(FILE *packfile, UInt32 offset, UInt16 *dirsize_r)\n{\n  PACKDirPtr dir;\n  UInt32     pos, size;\n  UInt16     max, i;\n\n  *dirsize_r = 0;\n  if (packfile == NULL)\n    return NULL;\n  if ((fseek(packfile, offset, SEEK_SET) < 0)\n      || (ReadMagic(packfile) != FTYPE_PACK)\n      || (ReadInt32(packfile, &pos) == FALSE)\n      || (ReadInt32(packfile, &size) == FALSE)\n      || (size == 0L)\n      || (size / sizeof(struct PACKDirectory) > 65535L)\n      || (fseek(packfile, offset + pos, SEEK_SET) < 0))\n    return NULL;\n  dir = (PACKDirPtr)__qmalloc(size);\n  max = (UInt16)(size / sizeof(struct PACKDirectory));\n  for (i = 0; i < max; i++)\n    {\n      if (ReadBytes(packfile, &dir[i], sizeof(struct PACKDirectory)) == FALSE)\n\t{\n\t  free(dir);\n\t  return NULL;\n\t}\n      ConvertFilePath(dir[i].name);\n      dir[i].offset = SwapInt32(dir[i].offset);\n      dir[i].size = SwapInt32(dir[i].size);\n    }\n  *dirsize_r = max;\n  return dir;\n}\n\n/*\n * Print the contents of the PACK directory in \"outf\".\n */\nvoid DumpPACKDirectory(FILE *outf, PACKDirPtr dir, UInt16 dirsize)\n{\n\tUInt16 i;\n\tUInt32 sum;\n\tchar   buf[57];\n\n\tif (outf == NULL || dir == NULL || dirsize == 0)\n\t\treturn;\n\tfprintf(outf, \"num    offset     size    file name\\n\");\n\tfprintf(outf, \"       (hex)      (dec)\\n\");\n\tsum = 0L;\n\tfor (i = 0; i < dirsize; i++)\n\t{\n\t\tif(!strnicmp(dir[i].name, \"textures\", 8))\n\t\t{\n   \t   strncpy(buf, dir[i].name, 56);\n\t      buf[56] = '\\0';\n      \tfprintf(outf, \"%3u  0x%08lx  %6ld   %s\\n\",\n\t\t      i, dir[i].offset, dir[i].size, buf);\n\t      sum += dir[i].size;\n\t\t}\n    }\n\tfprintf(outf, \"\\nTotal size for %3u entries:  %7lu bytes.\\n\", dirsize, sum);\n\tfprintf(outf, \"Size of the PACK directory:  %7lu bytes.\\n\",\n\t\t(UInt32)dirsize * (UInt32)sizeof(struct PACKDirectory));\n\tfprintf(outf, \"Total (header + data + dir): %7lu bytes.\\n\",\n\t\t12L + sum + (UInt32)dirsize * (UInt32)sizeof(struct PACKDirectory));\n}\n\nvoid ClearFileList(FILELIST **list)\n{\n\tFILELIST\t*temp;\n\n\twhile(*list)\n\t{\n\t\ttemp = *list;\n\t\t*list = (*list)->next;\n\t\tfree(temp);\n\t}\n}\n\nvoid ClearDirList(DIRLIST **list)\n{\n\tDIRLIST\t*temp;\n\n\twhile(*list)\n\t{\n\t\ttemp = *list;\n\t\t*list = (*list)->next;\n\t\tfree(temp);\n\t}\n}\n\nDIRECTORY *FindPakDir(DIRECTORY *dir, char *name)\n{\n\tDIRECTORY\t*currentPtr;\n\n\tfor(currentPtr = dir; currentPtr; currentPtr = currentPtr->next)\n\t{\n\t\tif(!stricmp(name, currentPtr->name))\n\t\t{\n\t\t\treturn currentPtr;\n\t\t}\n\t}\n\treturn NULL;\n}\n\n\n// LoadPK3FileList\n// ---------------\n//\n// This gets passed a file mask which we want to remove as \n// we are only interested in the directory name and any given\n// extension. Only handles explicit filenames or *.something\n//\nboolean LoadPK3FileList(FILELIST **filelist, const char *pattern)\n{\n  char cSearch[WORK_LEN];\n\t__ConvertDOSToUnixName( cSearch, pattern );\n  char cPath[WORK_LEN];\n  char cExt[WORK_LEN];\n  char cFile[WORK_LEN];\n  char cWork[WORK_LEN];\n  __ExtractFilePath(pattern, cPath);\n  __ExtractFileName(pattern, cFile);\n  __ExtractFileExtension(pattern, cExt);\n  const char *pCompare = (strnicmp(cFile, \"*.\", 2) == 0) ? cExt : cFile;\n  strcpy(cWork, cPath);\n  sprintf(cPath, \"textures/%s\", cWork);\n\n  PK3List *p = g_PK3Files.Next();\n  while (p != NULL)\n  {\n    // qualify the path\n    PK3FileInfo *pKey = p->Ptr();\n    if (strstr(pKey->m_pName, cPath) && strstr(pKey->m_pName, pCompare))\n    {\n      __ExtractFileName(pKey->m_pName, cWork); \n      AddToFileListAlphabetized(filelist, cWork, 0, 0, false);\n    }\n    p = p->Next();\n  }\n  return (*filelist) != NULL;\n}\n\nboolean GetPackFileList(FILELIST **filelist, char *pattern)\n{\n\tchar\t\t\t\t\t*str1, *str2;\n\tint\t\t\t\t\t\ti;\n\tDIRECTORY\t\t\t\t*dummy = paktextures;\n\tFILELIST\t\t\t\t*temp;\n\n\tif (!pakopen)\n\t\treturn false;\n\n  if (g_bPK3)\n  {\n    return LoadPK3FileList(filelist, pattern);\n  }\n\n\tstr1 = pattern;\n\n\tfor(i = 0; pattern[i] != '\\0'; i++)\n\t{\n\t\tif(pattern[i] == '\\\\')\n\t\t\tpattern[i] = '/';\n\t}\n\n\twhile(strchr(str1, '/'))\n\t{\n\t\tstr2 = strchr(str1, '/');\n\t\t*str2++ = '\\0';\n\t\tdummy = FindPakDir(dummy, str1);\n\t\tif(!dummy)\n\t\t\treturn false;\n\t\tstr1 = str2;\n\t}\n\tfor(temp = dummy->files; temp; temp=temp->next)\n\t{\n\t  AddToFileListAlphabetized(filelist, temp->filename, temp->offset, 0, false);\n\t}\n\treturn true;\n}\n\nboolean GetPackTextureDirs(DIRLIST **dirlist)\n{\n\tUInt16\t\t\t\t\ti;\n\tchar\t\t\t\t\tbuf[57];\n\n\tif (!pakopen)\n\t\treturn 1;\n\n  if (g_bPK3)\n  {\n    StrList *pl = g_PK3TexturePaths.Next();\n    while (pl != NULL)\n    {\n      AddToDirListAlphabetized(dirlist, pl->Ref(), 0);\n      pl = pl->Next();\n    }\n    return true;\n  }\n\n\tfor (i = 0; i < dirsize; i++)\n\t{\n\t\tif(!strnicmp(pakdirptr[i].name, \"textures\", 8))\n\t\t{\n\t\t\tstrncpy(buf, &(pakdirptr[i].name[9]), 46);\n\t\t\tif(strchr(buf, '\\\\'))\n\t      \t*strchr(buf, '\\\\') = '\\0';\n\t\t\telse if(strchr(buf, '/'))\n\t      \t*strchr(buf, '/') = '\\0';\n\t\t\telse\n\t      \tbuf[56] = '\\0';\n\n\t\t\tif(strchr(buf, '.'))\n\t\t\t\tcontinue;\n\n\t\t\tAddToDirListAlphabetized(dirlist, buf, 0);\n\t\t}\n\t}\n\treturn true;\n}\n\nboolean AddToDirListAlphabetized(DIRLIST **list, char *dirname, int from)\n{\n\tDIRLIST\t*currentPtr, *previousPtr, *newPtr;\n\n\tstrlwr(dirname);\n\tfor(currentPtr = *list; currentPtr; currentPtr = currentPtr->next)\n\t{\n\t\tif(!stricmp(dirname, currentPtr->dirname))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t}\n\tpreviousPtr = NULL;\n\tcurrentPtr = *list;\n\n\tif((newPtr = (DIRLIST *)__qmalloc(sizeof(DIRLIST))) == NULL)\n\t\treturn false;\n\n\tstrcpy(newPtr->dirname, dirname);\n\tnewPtr->from = from;\n\n\twhile(currentPtr != NULL && stricmp(dirname, currentPtr->dirname) > 0)\n\t{\n\t\tpreviousPtr = currentPtr;\n\t\tcurrentPtr = currentPtr->next;\n\t} //End while\n\tif(previousPtr == NULL)\n\t{\n\t\tnewPtr->next = *list;\n\t\t*list = newPtr;\n\t} //End if\n\telse\n\t{\n\t\tpreviousPtr->next = newPtr;\n\t\tnewPtr->next = currentPtr;\n\t} //End else\n\treturn true;\n}\n\nboolean AddToFileListAlphabetized(FILELIST **list, char *filename, UInt32 offset, UInt32 size, boolean dirs)\n{\n\tFILELIST\t*currentPtr, *previousPtr, *newPtr;\n\n\tfor(currentPtr = *list; currentPtr; currentPtr = currentPtr->next)\n\t{\n\t\tif(!stricmp(filename, currentPtr->filename))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t}\n\tpreviousPtr = NULL;\n\tcurrentPtr = *list;\n\n\tif((newPtr = (FILELIST *)__qmalloc(sizeof(FILELIST))) == NULL)\n\t\treturn false;\n\n\tstrcpy(newPtr->filename, filename);\n\tnewPtr->offset = offset;\n\tnewPtr->size = size;\n\n\twhile(currentPtr != NULL && stricmp(filename, currentPtr->filename) > 0)\n\t{\n\t\tpreviousPtr = currentPtr;\n\t\tcurrentPtr = currentPtr->next;\n\t} //End while\n\tif(previousPtr == NULL)\n\t{\n\t\tnewPtr->next = *list;\n\t\t*list = newPtr;\n\t} //End if\n\telse\n\t{\n\t\tpreviousPtr->next = newPtr;\n\t\tnewPtr->next = currentPtr;\n\t} //End else\n\treturn true;\n}\n\nboolean PakLoadFile(const char *filename, void **bufferptr)\n{\n\tFILELIST\t*p = NULL;\n\tDIRECTORY\t*dummy;\n\tvoid\t\t*buffer;\n\tchar\t\t*str1, *str2;\n\n\tif(!pakopen)\n\t\treturn false;\n\n  Str str(filename);\n  __ConvertDOSToUnixName(str, str);\n\n\tdummy = paktextures;\n\tstr1 = str;\n\n\twhile(strchr(str1, '/'))\n\t{\n\t\tstr2 = strchr(str1, '/');\n\t\t*str2++ = '\\0';\n\t\tdummy = FindPakDir(dummy, str1);\n\t\tif(!dummy)\n\t\t\treturn false;\n\t\tstr1 = str2;\n\t}\n\n  // FIXME: add error handling routines\n\tfor(p = dummy->files; p; p = p->next)\n\t{\n\t\tif(!stricmp(str1, p->filename))\n\t\t{\n\t\t\tif (fseek(pakfile[m_nPAKIndex], p->offset, SEEK_SET) < 0)\n\t\t\t{\n\t\t\t\t//Sys_Printf(\"Unexpected EOF in pakfile\\n\");\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif((buffer = __qmalloc(p->size+5)) == NULL)\n\t\t\t\t//Error(\"Could not allocate memory\");\n\t\n\t\t\tif(fread(buffer, 1, p->size, pakfile[m_nPAKIndex]) != p->size)\n\t\t\t{\n\t\t\t\t//Sys_Printf(\"Error reading %s from pak\\n\", str1);\n\t\t\t\tfree(buffer);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t*bufferptr = buffer;\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\nint PakLoadAnyFile(const char *filename, void **bufferptr)\n{\n  char cWork[WORK_LEN];\n  if (g_bPK3)\n  {\n    PK3FileInfo *pInfo;\n    Str strKey;\n    // need to lookup the file without the base/texture path on it\n    Str strBase(g_strBasePath);\n    AddSlash(strBase);\n    __ConvertDOSToUnixName(cWork, strBase);\n    Str strFile(filename);\n    __ConvertDOSToUnixName(strFile, strFile);\n    strFile.MakeLower();\n    strlwr(cWork);\n    FindReplace(strFile, cWork, \"\");\n\n    PK3FileInfo infoFind;\n    infoFind.m_pName = __StrDup(strFile.GetBuffer());\n    PK3List *pList = g_PK3Files.Find(&infoFind);\n    if (pList)\n    {\n      pInfo = pList->Ptr();\n      memcpy(pInfo->m_zFile, &pInfo->m_zInfo, sizeof(unz_s));\n      if (unzOpenCurrentFile(pInfo->m_zFile) == UNZ_OK)\n      {\n        void *buffer = __qblockmalloc(pInfo->m_lSize+1);\n        int n = unzReadCurrentFile(pInfo->m_zFile , buffer, pInfo->m_lSize);\n        *bufferptr = buffer;\n        unzCloseCurrentFile(pInfo->m_zFile);\n        return n;\n      }\n    }\n#ifdef LOG_PAKFAIL\n    sprintf(cWork, \"PAK failed on %s\\n\", filename);\n    g_LogFile.Log(cWork);\n#endif\n    return -1;\n  }\n\n\tfor (int i = 0; i < dirsize; i++)\n\t{\n\t\tif(!stricmp(filename, pakdirptr[i].name))\n\t\t{\n\t\t\tif (fseek(pakfile[m_nPAKIndex], pakdirptr[i].offset, SEEK_SET) >= 0)\n      {\n\t      void *buffer = __qmalloc (pakdirptr[i].size+1);\n\t      ((char *)buffer)[pakdirptr[i].size] = 0;\n\t\t\t  if (fread(buffer, 1, pakdirptr[i].size, pakfile[m_nPAKIndex]) == pakdirptr[i].size)\n        {\n          *bufferptr = buffer;\n          return pakdirptr[i].size;\n        }\n      }\n\t\t}\n\t}\n#ifdef LOG_PAKFAIL\n    sprintf(cWork, \"PAK failed on %s\\n\", filename);\n    g_LogFile.Log(cWork);\n#endif\n  return -1;\n}\n\n\n\nDIRECTORY *AddPakDir(DIRECTORY **dir, char *name)\n{\n\tDIRECTORY\t*currentPtr, *previousPtr, *newPtr;\n\n\tfor(currentPtr = *dir; currentPtr; currentPtr = currentPtr->next)\n\t{\n\t\tif(!stricmp(name, currentPtr->name))\n\t\t{\n\t\t\treturn currentPtr;\n\t\t}\n\t}\n\tpreviousPtr = NULL;\n\tcurrentPtr = *dir;\n\n\tif((newPtr = (DIRECTORY *)__qmalloc(sizeof(DIRECTORY))) == NULL)\n\t\treturn NULL;\n\n\tstrcpy(newPtr->name, name);\n\tnewPtr->files = NULL;\n\n\twhile(currentPtr != NULL && stricmp(name, currentPtr->name) > 0)\n\t{\n\t\tpreviousPtr = currentPtr;\n\t\tcurrentPtr = currentPtr->next;\n\t}\n\tif(previousPtr == NULL)\n\t{\n\t\tnewPtr->next = *dir;\n\t\t*dir = newPtr;\n\t}\n\telse\n\t{\n\t\tpreviousPtr->next = newPtr;\n\t\tnewPtr->next = currentPtr;\n\t}\n\treturn newPtr;\n}\n\n\n// OpenPK3\n// -------\n// Opens a PK3 ( or zip ) file and creates a list of filenames\n// and zip info structures\n// \nboolean OpenPK3(const char *filename)\n{\n  char cFilename[WORK_LEN];\n  char cName[WORK_LEN];\n  char cWork[WORK_LEN];\n  unz_file_info zInfo;\n  unzFile *zFile = new unzFile(unzOpen(filename));\n  g_zFiles.Add(zFile);\n  if (zFile != NULL)\n  {\n    int nStatus = unzGoToFirstFile(*zFile);\n    while (nStatus == UNZ_OK)\n    {\n      cFilename[0] = '\\0';\n      unzGetCurrentFileInfo(*zFile, &zInfo, cFilename, WORK_LEN, NULL, 0, NULL, 0);\n      strlwr(cFilename);\n    \t__ConvertDOSToUnixName( cWork, cFilename);\n      if (strstr(cWork, \".\") != NULL)\n      {\n        PK3FileInfo *pInfo = new PK3FileInfo();\n        pInfo->m_pName = __StrDup(cWork);\n        memcpy(&pInfo->m_zInfo, (unz_s*)*zFile, sizeof(unz_s));\n        pInfo->m_lSize = zInfo.uncompressed_size;\n        pInfo->m_zFile = *zFile;\n        g_PK3Files.Add(pInfo);\n      }\n      char *p = strstr(cFilename, TEXTURE_PATH);\n      if (p != NULL)\n      {\n        // FIXME: path differences per os ?\n        // catch solo directory entry\n        if (strlen(p) > strlen(TEXTURE_PATH) + 1)\n        {\n          // skip textures + path seperator\n          p += strlen(TEXTURE_PATH) + 1;\n          int nEnd = strcspn(p, PATH_SEPERATORS);\n          strncpy(cName, p, nEnd);\n          cName[nEnd] = '\\0';\n\n          boolean bFound = false;\n          StrList *pl = g_PK3TexturePaths.Next();\n          while (pl != NULL)\n          {\n            if (strcmpi(pl->Ref(), cName) == 0)\n            {\n              // already have this, continue\n              bFound = true;\n              break;\n            }\n            pl = pl->Next();\n          }\n          if (!bFound)\n          {\n            g_PK3TexturePaths.Add(new Str(cName));\n          }\n        }\n      }\n      nStatus = unzGoToNextFile(*zFile);\n    }\n  }\n  return (zFile != NULL);\n}\n\nvoid closePK3(unzFile zf)\n{\n  unzClose(zf);\n}\n\nvoid OpenPakFile(const char *filename)\n{\n\tint\t\t\ti;\n\tchar\t\t*str1, *str2;\n\tDIRECTORY\t*dummy;\n\n\tif(!pakopen)\n\t\tpaktextures = NULL;\n\n\tHavePakColormap = false;\n\n  Str strTest(filename);\n  strTest.MakeLower();\n  if (strTest.Find(\"pk3\") >= 0 || strTest.Find(\"zip\") >= 0)\n  {\n    pakopen = g_bPK3 = OpenPK3(filename);\n    return;\n  }\n\n\n\tif((pakfile[m_nPAKIndex] = OpenFileReadMagic(filename, &f_type)) == NULL)\n\t{\n    //FIXME: error routine\n\t\t//Sys_Printf(\"ERROR: Could not open %s\", filename);\n\t\treturn;\n\t}\n\tif(f_type != FTYPE_PACK)\n\t{\n\t\t//Sys_Printf(\"ERROR: %s is not a valid pack file\", filename);\n\t\tif(f_type != FTYPE_ERROR)\n\t\t\tfclose(pakfile[m_nPAKIndex]);\n\t\treturn;\n\t}\n\tpakdirptr = ReadPACKDirectory(pakfile[m_nPAKIndex], 0, &dirsize);\n\tif (pakdirptr == NULL)\n\t{\n\t\t//Sys_Printf(\"ERROR: Could not read pack directory\", filename);\n\t\tfclose(pakfile[m_nPAKIndex]);\n\t\treturn;\n\t}\n\tif (dirsize == 0)\n\t{\n\t\tfclose(pakfile[m_nPAKIndex]);\n\t\treturn;\n\t}\n\tfor (i = 0; i < dirsize; i++)\n\t{\n\t\tif(!strnicmp(\"textures/\", pakdirptr[i].name, 9))\n\t\t{\n\t\t\tdummy = paktextures;\n\t\t\tstr1 = pakdirptr[i].name+9;\n\t\t\twhile(strchr(str1, '/'))\n\t\t\t{\n\t\t\t\tstr2 = strchr(str1, '/');\n\t\t\t\t*str2++ = '\\0';\n\t\t\t\t\tdummy = AddPakDir(dummy==paktextures?&paktextures:&dummy, str1);\n\t\t\t\tstr1 = str2;\n\t\t\t}\n\n\t\t\tAddToFileListAlphabetized(&(dummy->files), str1, pakdirptr[i].offset, pakdirptr[i].size, true);\n\t\t}\n\t\telse if(!strnicmp(\"pics/colormap.pcx\", pakdirptr[i].name, 17))\n\t\t{\n\t\t\tHavePakColormap = true;\n\t\t\tPakColormapOffset = pakdirptr[i].offset;\n\t\t\tPakColormapSize = pakdirptr[i].size;\n\t\t}\n\t}\n\tpakopen = true;\n\n}\n\nvoid ClearPaKDir(DIRECTORY **dir)\n{\n\tDIRECTORY\t*d1 = *dir, *d2;\n\n\twhile(d1)\n\t{\n\t\tClearFileList(&(d1->files));\n\t\td2 = d1;\n\t\td1 = d1->next;\n\t\tfree(d2);\n\t}\n}\n\nvoid CleanUpPakDirs()\n{\n  ClearPaKDir(&paktextures);\n  paktextures = NULL;\n  dirhead = NULL;\n  g_PK3TexturePaths.RemoveAll();\n  g_PK3Files.RemoveAll();\n}\n\nvoid ClosePakFile(void)\n{\n\tif(pakopen)\n  {\n    if (g_bPK3)\n    {\n      ZFileList *p = g_zFiles.Next();\n      while (p != NULL)\n      {\n        unzFile uz = p->Ref();\n        closePK3(uz);\n        p = p->Next();\n      }\n    }\n    else\n    {\n      fclose(pakfile[m_nPAKIndex]);\n    }\n  }\n\tpakopen = false;\n  CleanUpPakDirs();\n}\n\n\nvoid WINAPI InitPakFile(const char * pBasePath, const char *pName)\n{\n  m_nPAKIndex = 0;\n  pakopen = false;\n\tpaktextures = NULL;\n  strcpy(g_strBasePath, pBasePath);\n  if (pName == NULL)\n  {\n    char cWork[WORK_LEN];\n\t  Str strPath(pBasePath);\n    AddSlash(strPath);\n  \tstrPath += \"*.pk3\";\n  \tbool bGo = true;\n\t  struct _finddata_t fileinfo;\n  \tint handle = _findfirst (strPath, &fileinfo);\n\t  if (handle != -1)\n  \t{\n\t  \tdo\n\t\t  {\n        sprintf(cWork, \"%s\\\\%s\", pBasePath, fileinfo.name);\n        OpenPakFile(cWork);\n\t\t  } while (_findnext( handle, &fileinfo ) != -1);\n\t    _findclose (handle);\n    }\n\t}\n  else\n  {\n\t  OpenPakFile(pName);\n  }\n}\n\n"
  },
  {
    "path": "libs/pak/unzip.cpp",
    "content": "/*****************************************************************************\n * name:\t\tunzip.c\n *\n * desc:\t\tIO on .zip files using portions of zlib \n *\n * $Archive: /source/code/qcommon/unzip.c $\n * $Author: ttimo $ \n * $Revision: 1.1.1.3 $\n * $Modtime: 10/19/99 3:59p $\n * $Date: 2000/01/11 16:37:27 $\n *\n *****************************************************************************/\n\n#include <stdio.h>\n#include <string.h>\n#include <windows.h>\n#include \"unzip.h\"\n//#include \"cmdlib.h\"\n\n/* unzip.h -- IO for uncompress .zip files using zlib \n   Version 0.15 beta, Mar 19th, 1998,\n\n   Copyright (C) 1998 Gilles Vollant\n\n   This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g\n     WinZip, InfoZip tools and compatible.\n   Encryption and multi volume ZipFile (span) are not supported.\n   Old compressions used by old PKZip 1.x are not supported\n\n   THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE\n   CAN CHANGE IN FUTURE VERSION !!\n   I WAIT FEEDBACK at mail info@winimage.com\n   Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution\n\n   Condition of use and distribution are the same than zlib :\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n\n*/\n/* for more info about .ZIP format, see \n      ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip\n   PkWare has also a specification at :\n      ftp://ftp.pkware.com/probdesc.zip */\n\n/* zlib.h -- interface of the 'zlib' general purpose compression library\n  version 1.1.3, July 9th, 1998\n\n  Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n  Jean-loup Gailly        Mark Adler\n  jloup@gzip.org          madler@alumni.caltech.edu\n\n\n  The data format used by the zlib library is described by RFCs (Request for\n  Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt\n  (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).\n*/\n\n/* zconf.h -- configuration of the zlib compression library\n * Copyright (C) 1995-1998 Jean-loup Gailly.\n * For conditions of distribution and use, see copyright notice in zlib.h \n */\n\n/* @(#) $Id: unzip.cpp,v 1.1.1.3 2000/01/11 16:37:27 ttimo Exp $ */\n\n#ifndef _ZCONF_H\n#define _ZCONF_H\n\n/* Maximum value for memLevel in deflateInit2 */\n#ifndef MAX_MEM_LEVEL\n#  ifdef MAXSEG_64K\n#    define MAX_MEM_LEVEL 8\n#  else\n#    define MAX_MEM_LEVEL 9\n#  endif\n#endif\n\n/* Maximum value for windowBits in deflateInit2 and inflateInit2.\n * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files\n * created by gzip. (Files created by minigzip can still be extracted by\n * gzip.)\n */\n#ifndef MAX_WBITS\n#  define MAX_WBITS   15 /* 32K LZ77 window */\n#endif\n\n/* The memory requirements for deflate are (in bytes):\n            (1 << (windowBits+2)) +  (1 << (memLevel+9))\n that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)\n plus a few kilobytes for small objects. For example, if you want to reduce\n the default memory requirements from 256K to 128K, compile with\n     make CFLAGS=\"-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7\"\n Of course this will generally degrade compression (there's no free lunch).\n\n   The memory requirements for inflate are (in bytes) 1 << windowBits\n that is, 32K for windowBits=15 (default value) plus a few kilobytes\n for small objects.\n*/\n\n                        /* Type declarations */\n\n#ifndef OF /* function prototypes */\n#define OF(args)  args\n#endif\n\ntypedef unsigned char  Byte;  /* 8 bits */\ntypedef unsigned int   uInt;  /* 16 bits or more */\ntypedef unsigned long  uLong; /* 32 bits or more */\ntypedef Byte    *voidp;\n\n#ifndef SEEK_SET\n#  define SEEK_SET        0       /* Seek from beginning of file.  */\n#  define SEEK_CUR        1       /* Seek from current position.  */\n#  define SEEK_END        2       /* Set file pointer to EOF plus \"offset\" */\n#endif\n\n#endif /* _ZCONF_H */\n\n#define ZLIB_VERSION \"1.1.3\"\n\n/* \n     The 'zlib' compression library provides in-memory compression and\n  decompression functions, including integrity checks of the uncompressed\n  data.  This version of the library supports only one compression method\n  (deflation) but other algorithms will be added later and will have the same\n  stream interface.\n\n     Compression can be done in a single step if the buffers are large\n  enough (for example if an input file is mmap'ed), or can be done by\n  repeated calls of the compression function.  In the latter case, the\n  application must provide more input and/or consume the output\n  (providing more output space) before each call.\n\n     The library also supports reading and writing files in gzip (.gz) format\n  with an interface similar to that of stdio.\n\n     The library does not install any signal handler. The decoder checks\n  the consistency of the compressed data, so the library should never\n  crash even in case of corrupted input.\n*/\n\n/*\n   The application must update next_in and avail_in when avail_in has\n   dropped to zero. It must update next_out and avail_out when avail_out\n   has dropped to zero. The application must initialize zalloc, zfree and\n   opaque before calling the init function. All other fields are set by the\n   compression library and must not be updated by the application.\n\n   The opaque value provided by the application will be passed as the first\n   parameter for calls of zalloc and zfree. This can be useful for custom\n   memory management. The compression library attaches no meaning to the\n   opaque value.\n\n   zalloc must return Z_NULL if there is not enough memory for the object.\n   If zlib is used in a multi-threaded application, zalloc and zfree must be\n   thread safe.\n\n   On 16-bit systems, the functions zalloc and zfree must be able to allocate\n   exactly 65536 bytes, but will not be required to allocate more than this\n   if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,\n   pointers returned by zalloc for objects of exactly 65536 bytes *must*\n   have their offset normalized to zero. The default allocation function\n   provided by this library ensures this (see zutil.c). To reduce memory\n   requirements and avoid any allocation of 64K objects, at the expense of\n   compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).\n\n   The fields total_in and total_out can be used for statistics or\n   progress reports. After compression, total_in holds the total size of\n   the uncompressed data and may be saved for use in the decompressor\n   (particularly if the decompressor wants to decompress everything in\n   a single step).\n*/\n\n                        /* constants */\n\n#define Z_NO_FLUSH      0\n#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */\n#define Z_SYNC_FLUSH    2\n#define Z_FULL_FLUSH    3\n#define Z_FINISH        4\n/* Allowed flush values; see deflate() below for details */\n\n#define Z_OK            0\n#define Z_STREAM_END    1\n#define Z_NEED_DICT     2\n#define Z_ERRNO        (-1)\n#define Z_STREAM_ERROR (-2)\n#define Z_DATA_ERROR   (-3)\n#define Z_MEM_ERROR    (-4)\n#define Z_BUF_ERROR    (-5)\n#define Z_VERSION_ERROR (-6)\n/* Return codes for the compression/decompression functions. Negative\n * values are errors, positive values are used for special but normal events.\n */\n\n#define Z_NO_COMPRESSION         0\n#define Z_BEST_SPEED             1\n#define Z_BEST_COMPRESSION       9\n#define Z_DEFAULT_COMPRESSION  (-1)\n/* compression levels */\n\n#define Z_FILTERED            1\n#define Z_HUFFMAN_ONLY        2\n#define Z_DEFAULT_STRATEGY    0\n/* compression strategy; see deflateInit2() below for details */\n\n#define Z_BINARY   0\n#define Z_ASCII    1\n#define Z_UNKNOWN  2\n/* Possible values of the data_type field */\n\n#define Z_DEFLATED   8\n/* The deflate compression method (the only one supported in this version) */\n\n#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */\n\n#define zlib_version zlibVersion()\n/* for compatibility with versions < 1.0.2 */\n\n                        /* basic functions */\n\nconst char * zlibVersion OF((void));\n/* The application can compare zlibVersion and ZLIB_VERSION for consistency.\n   If the first character differs, the library code actually used is\n   not compatible with the zlib.h header file used by the application.\n   This check is automatically made by deflateInit and inflateInit.\n */\n\n/* \nint deflateInit OF((z_streamp strm, int level));\n\n     Initializes the internal stream state for compression. The fields\n   zalloc, zfree and opaque must be initialized before by the caller.\n   If zalloc and zfree are set to Z_NULL, deflateInit updates them to\n   use default allocation functions.\n\n     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:\n   1 gives best speed, 9 gives best compression, 0 gives no compression at\n   all (the input data is simply copied a block at a time).\n   Z_DEFAULT_COMPRESSION requests a default compromise between speed and\n   compression (currently equivalent to level 6).\n\n     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if level is not a valid compression level,\n   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible\n   with the version assumed by the caller (ZLIB_VERSION).\n   msg is set to null if there is no error message.  deflateInit does not\n   perform any compression: this will be done by deflate().\n*/\n\n\nint deflate OF((z_streamp strm, int flush));\n/*\n    deflate compresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full. It may introduce some\n  output latency (reading input without producing any output) except when\n  forced to flush.\n\n    The detailed semantics are as follows. deflate performs one or both of the\n  following actions:\n\n  - Compress more input starting at next_in and update next_in and avail_in\n    accordingly. If not all input can be processed (because there is not\n    enough room in the output buffer), next_in and avail_in are updated and\n    processing will resume at this point for the next call of deflate().\n\n  - Provide more output starting at next_out and update next_out and avail_out\n    accordingly. This action is forced if the parameter flush is non zero.\n    Forcing flush frequently degrades the compression ratio, so this parameter\n    should be set only when necessary (in interactive applications).\n    Some output may be provided even if flush is not set.\n\n  Before the call of deflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming\n  more output, and updating avail_in or avail_out accordingly; avail_out\n  should never be zero before the call. The application can consume the\n  compressed output when it wants, for example when the output buffer is full\n  (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK\n  and with zero avail_out, it must be called again after making room in the\n  output buffer because there might be more output pending.\n\n    If the parameter flush is set to Z_SYNC_FLUSH, all pending output is\n  flushed to the output buffer and the output is aligned on a byte boundary, so\n  that the decompressor can get all input data available so far. (In particular\n  avail_in is zero after the call if enough output space has been provided\n  before the call.)  Flushing may degrade compression for some compression\n  algorithms and so it should be used only when necessary.\n\n    If flush is set to Z_FULL_FLUSH, all output is flushed as with\n  Z_SYNC_FLUSH, and the compression state is reset so that decompression can\n  restart from this point if previous compressed data has been damaged or if\n  random access is desired. Using Z_FULL_FLUSH too often can seriously degrade\n  the compression.\n\n    If deflate returns with avail_out == 0, this function must be called again\n  with the same value of the flush parameter and more output space (updated\n  avail_out), until the flush is complete (deflate returns with non-zero\n  avail_out).\n\n    If the parameter flush is set to Z_FINISH, pending input is processed,\n  pending output is flushed and deflate returns with Z_STREAM_END if there\n  was enough output space; if deflate returns with Z_OK, this function must be\n  called again with Z_FINISH and more output space (updated avail_out) but no\n  more input data, until it returns with Z_STREAM_END or an error. After\n  deflate has returned Z_STREAM_END, the only possible operations on the\n  stream are deflateReset or deflateEnd.\n  \n    Z_FINISH can be used immediately after deflateInit if all the compression\n  is to be done in a single step. In this case, avail_out must be at least\n  0.1% larger than avail_in plus 12 bytes.  If deflate does not return\n  Z_STREAM_END, then it must be called again as described above.\n\n    deflate() sets strm->adler to the adler32 checksum of all input read\n  so (that is, total_in bytes).\n\n    deflate() may update data_type if it can make a good guess about\n  the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered\n  binary. This field is only for information purposes and does not affect\n  the compression algorithm in any manner.\n\n    deflate() returns Z_OK if some progress has been made (more input\n  processed or more output produced), Z_STREAM_END if all input has been\n  consumed and all output has been produced (only when flush is set to\n  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example\n  if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible\n  (for example avail_in or avail_out was zero).\n*/\n\n\nint deflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any\n   pending output.\n\n     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the\n   stream state was inconsistent, Z_DATA_ERROR if the stream was freed\n   prematurely (some input or output was discarded). In the error case,\n   msg may be set but then points to a static string (which must not be\n   deallocated).\n*/\n\n\n/* \nint inflateInit OF((z_streamp strm));\n\n     Initializes the internal stream state for decompression. The fields\n   next_in, avail_in, zalloc, zfree and opaque must be initialized before by\n   the caller. If next_in is not Z_NULL and avail_in is large enough (the exact\n   value depends on the compression method), inflateInit determines the\n   compression method from the zlib header and allocates all data structures\n   accordingly; otherwise the allocation will be deferred to the first call of\n   inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to\n   use default allocation functions.\n\n     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller.  msg is set to null if there is no error\n   message. inflateInit does not perform any decompression apart from reading\n   the zlib header if present: this will be done by inflate().  (So next_in and\n   avail_in may be modified, but next_out and avail_out are unchanged.)\n*/\n\n\nint inflate OF((z_streamp strm, int flush));\n/*\n    inflate decompresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full. It may some\n  introduce some output latency (reading input without producing any output)\n  except when forced to flush.\n\n  The detailed semantics are as follows. inflate performs one or both of the\n  following actions:\n\n  - Decompress more input starting at next_in and update next_in and avail_in\n    accordingly. If not all input can be processed (because there is not\n    enough room in the output buffer), next_in is updated and processing\n    will resume at this point for the next call of inflate().\n\n  - Provide more output starting at next_out and update next_out and avail_out\n    accordingly.  inflate() provides as much output as possible, until there\n    is no more input data or no more space in the output buffer (see below\n    about the flush parameter).\n\n  Before the call of inflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming\n  more output, and updating the next_* and avail_* values accordingly.\n  The application can consume the uncompressed output when it wants, for\n  example when the output buffer is full (avail_out == 0), or after each\n  call of inflate(). If inflate returns Z_OK and with zero avail_out, it\n  must be called again after making room in the output buffer because there\n  might be more output pending.\n\n    If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much\n  output as possible to the output buffer. The flushing behavior of inflate is\n  not specified for values of the flush parameter other than Z_SYNC_FLUSH\n  and Z_FINISH, but the current implementation actually flushes as much output\n  as possible anyway.\n\n    inflate() should normally be called until it returns Z_STREAM_END or an\n  error. However if all decompression is to be performed in a single step\n  (a single call of inflate), the parameter flush should be set to\n  Z_FINISH. In this case all pending input is processed and all pending\n  output is flushed; avail_out must be large enough to hold all the\n  uncompressed data. (The size of the uncompressed data may have been saved\n  by the compressor for this purpose.) The next operation on this stream must\n  be inflateEnd to deallocate the decompression state. The use of Z_FINISH\n  is never required, but can be used to inform inflate that a faster routine\n  may be used for the single inflate() call.\n\n     If a preset dictionary is needed at this point (see inflateSetDictionary\n  below), inflate sets strm-adler to the adler32 checksum of the\n  dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise \n  it sets strm->adler to the adler32 checksum of all output produced\n  so (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or\n  an error code as described below. At the end of the stream, inflate()\n  checks that its computed adler32 checksum is equal to that saved by the\n  compressor and returns Z_STREAM_END only if the checksum is correct.\n\n    inflate() returns Z_OK if some progress has been made (more input processed\n  or more output produced), Z_STREAM_END if the end of the compressed data has\n  been reached and all uncompressed output has been produced, Z_NEED_DICT if a\n  preset dictionary is needed at this point, Z_DATA_ERROR if the input data was\n  corrupted (input stream not conforming to the zlib format or incorrect\n  adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent\n  (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not\n  enough memory, Z_BUF_ERROR if no progress is possible or if there was not\n  enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR\n  case, the application may then call inflateSync to look for a good\n  compression block.\n*/\n\n\nint inflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any\n   pending output.\n\n     inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state\n   was inconsistent. In the error case, msg may be set but then points to a\n   static string (which must not be deallocated).\n*/\n\n                        /* Advanced functions */\n\n/*\n    The following functions are needed only in some special applications.\n*/\n\n/*   \nint deflateInit2 OF((z_streamp strm,\n                                     int  level,\n                                     int  method,\n                                     int  windowBits,\n                                     int  memLevel,\n                                     int  strategy));\n\n     This is another version of deflateInit with more compression options. The\n   fields next_in, zalloc, zfree and opaque must be initialized before by\n   the caller.\n\n     The method parameter is the compression method. It must be Z_DEFLATED in\n   this version of the library.\n\n     The windowBits parameter is the base two logarithm of the window size\n   (the size of the history buffer).  It should be in the range 8..15 for this\n   version of the library. Larger values of this parameter result in better\n   compression at the expense of memory usage. The default value is 15 if\n   deflateInit is used instead.\n\n     The memLevel parameter specifies how much memory should be allocated\n   for the internal compression state. memLevel=1 uses minimum memory but\n   is slow and reduces compression ratio; memLevel=9 uses maximum memory\n   for optimal speed. The default value is 8. See zconf.h for total memory\n   usage as a function of windowBits and memLevel.\n\n     The strategy parameter is used to tune the compression algorithm. Use the\n   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a\n   filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no\n   string match).  Filtered data consists mostly of small values with a\n   somewhat random distribution. In this case, the compression algorithm is\n   tuned to compress them better. The effect of Z_FILTERED is to force more\n   Huffman coding and less string matching; it is somewhat intermediate\n   between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects\n   the compression ratio but not the correctness of the compressed output even\n   if it is not set appropriately.\n\n      deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid\n   method). msg is set to null if there is no error message.  deflateInit2 does\n   not perform any compression: this will be done by deflate().\n*/\n                            \nint deflateSetDictionary OF((z_streamp strm,\n                                             const Byte *dictionary,\n                                             uInt  dictLength));\n/*\n     Initializes the compression dictionary from the given byte sequence\n   without producing any compressed output. This function must be called\n   immediately after deflateInit, deflateInit2 or deflateReset, before any\n   call of deflate. The compressor and decompressor must use exactly the same\n   dictionary (see inflateSetDictionary).\n\n     The dictionary should consist of strings (byte sequences) that are likely\n   to be encountered later in the data to be compressed, with the most commonly\n   used strings preferably put towards the end of the dictionary. Using a\n   dictionary is most useful when the data to be compressed is short and can be\n   predicted with good accuracy; the data can then be compressed better than\n   with the default empty dictionary.\n\n     Depending on the size of the compression data structures selected by\n   deflateInit or deflateInit2, a part of the dictionary may in effect be\n   discarded, for example if the dictionary is larger than the window size in\n   deflate or deflate2. Thus the strings most likely to be useful should be\n   put at the end of the dictionary, not at the front.\n\n     Upon return of this function, strm->adler is set to the Adler32 value\n   of the dictionary; the decompressor may later use this value to determine\n   which dictionary has been used by the compressor. (The Adler32 value\n   applies to the whole dictionary even if only a subset of the dictionary is\n   actually used by the compressor.)\n\n     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a\n   parameter is invalid (such as NULL dictionary) or the stream state is\n   inconsistent (for example if deflate has already been called for this stream\n   or if the compression method is bsort). deflateSetDictionary does not\n   perform any compression: this will be done by deflate().\n*/\n\nint deflateCopy OF((z_streamp dest,\n                                    z_streamp source));\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when several compression strategies will be\n   tried, for example when there are several ways of pre-processing the input\n   data with a filter. The streams that will be discarded should then be freed\n   by calling deflateEnd.  Note that deflateCopy duplicates the internal\n   compression state which can be quite large, so this strategy is slow and\n   can consume lots of memory.\n\n     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being NULL). msg is left unchanged in both source and\n   destination.\n*/\n\nint deflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to deflateEnd followed by deflateInit,\n   but does not free and reallocate all the internal compression state.\n   The stream will keep the same compression level and any other attributes\n   that may have been set by deflateInit2.\n\n      deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being NULL).\n*/\n\nint deflateParams OF((z_streamp strm,\n\t\t\t\t      int level,\n\t\t\t\t      int strategy));\n/*\n     Dynamically update the compression level and compression strategy.  The\n   interpretation of level and strategy is as in deflateInit2.  This can be\n   used to switch between compression and straight copy of the input data, or\n   to switch to a different kind of input data requiring a different\n   strategy. If the compression level is changed, the input available so far\n   is compressed with the old level (and may be flushed); the new level will\n   take effect only at the next call of deflate().\n\n     Before the call of deflateParams, the stream state must be set as for\n   a call of deflate(), since the currently available input may have to\n   be compressed and flushed. In particular, strm->avail_out must be non-zero.\n\n     deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source\n   stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR\n   if strm->avail_out was zero.\n*/\n\n/*   \nint inflateInit2 OF((z_streamp strm,\n                                     int  windowBits));\n\n     This is another version of inflateInit with an extra parameter. The\n   fields next_in, avail_in, zalloc, zfree and opaque must be initialized\n   before by the caller.\n\n     The windowBits parameter is the base two logarithm of the maximum window\n   size (the size of the history buffer).  It should be in the range 8..15 for\n   this version of the library. The default value is 15 if inflateInit is used\n   instead. If a compressed stream with a larger window size is given as\n   input, inflate() will return with the error code Z_DATA_ERROR instead of\n   trying to allocate a larger window.\n\n      inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative\n   memLevel). msg is set to null if there is no error message.  inflateInit2\n   does not perform any decompression apart from reading the zlib header if\n   present: this will be done by inflate(). (So next_in and avail_in may be\n   modified, but next_out and avail_out are unchanged.)\n*/\n\nint inflateSetDictionary OF((z_streamp strm,\n                                             const Byte *dictionary,\n                                             uInt  dictLength));\n/*\n     Initializes the decompression dictionary from the given uncompressed byte\n   sequence. This function must be called immediately after a call of inflate\n   if this call returned Z_NEED_DICT. The dictionary chosen by the compressor\n   can be determined from the Adler32 value returned by this call of\n   inflate. The compressor and decompressor must use exactly the same\n   dictionary (see deflateSetDictionary).\n\n     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a\n   parameter is invalid (such as NULL dictionary) or the stream state is\n   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the\n   expected one (incorrect Adler32 value). inflateSetDictionary does not\n   perform any decompression: this will be done by subsequent calls of\n   inflate().\n*/\n\nint inflateSync OF((z_streamp strm));\n/* \n    Skips invalid compressed data until a full flush point (see above the\n  description of deflate with Z_FULL_FLUSH) can be found, or until all\n  available input is skipped. No output is provided.\n\n    inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR\n  if no more input was provided, Z_DATA_ERROR if no flush point has been found,\n  or Z_STREAM_ERROR if the stream structure was inconsistent. In the success\n  case, the application may save the current current value of total_in which\n  indicates where valid compressed data was found. In the error case, the\n  application may repeatedly call inflateSync, providing more input each time,\n  until success or end of the input data.\n*/\n\nint inflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to inflateEnd followed by inflateInit,\n   but does not free and reallocate all the internal decompression state.\n   The stream will keep attributes that may have been set by inflateInit2.\n\n      inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being NULL).\n*/\n\n\n                        /* utility functions */\n\n/*\n     The following utility functions are implemented on top of the\n   basic stream-oriented functions. To simplify the interface, some\n   default options are assumed (compression level and memory usage,\n   standard memory allocation functions). The source code of these\n   utility functions can easily be modified if you need special options.\n*/\n\nint compress OF((Byte *dest,   uLong *destLen,\n                                 const Byte *source, uLong sourceLen));\n/*\n     Compresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer. Upon entry, destLen is the total\n   size of the destination buffer, which must be at least 0.1% larger than\n   sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the\n   compressed buffer.\n     This function can be used to compress a whole file at once if the\n   input file is mmap'ed.\n     compress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer.\n*/\n\nint compress2 OF((Byte *dest,   uLong *destLen,\n                                  const Byte *source, uLong sourceLen,\n                                  int level));\n/*\n     Compresses the source buffer into the destination buffer. The level\n   parameter has the same meaning as in deflateInit.  sourceLen is the byte\n   length of the source buffer. Upon entry, destLen is the total size of the\n   destination buffer, which must be at least 0.1% larger than sourceLen plus\n   12 bytes. Upon exit, destLen is the actual size of the compressed buffer.\n\n     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_BUF_ERROR if there was not enough room in the output buffer,\n   Z_STREAM_ERROR if the level parameter is invalid.\n*/\n\nint uncompress OF((Byte *dest,   uLong *destLen,\n                                   const Byte *source, uLong sourceLen));\n/*\n     Decompresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer. Upon entry, destLen is the total\n   size of the destination buffer, which must be large enough to hold the\n   entire uncompressed data. (The size of the uncompressed data must have\n   been saved previously by the compressor and transmitted to the decompressor\n   by some mechanism outside the scope of this compression library.)\n   Upon exit, destLen is the actual size of the compressed buffer.\n     This function can be used to decompress a whole file at once if the\n   input file is mmap'ed.\n\n     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer, or Z_DATA_ERROR if the input data was corrupted.\n*/\n\n\ntypedef voidp gzFile;\n\ngzFile gzopen  OF((const char *path, const char *mode));\n/*\n     Opens a gzip (.gz) file for reading or writing. The mode parameter\n   is as in fopen (\"rb\" or \"wb\") but can also include a compression level\n   (\"wb9\") or a strategy: 'f' for filtered data as in \"wb6f\", 'h' for\n   Huffman only compression as in \"wb1h\". (See the description\n   of deflateInit2 for more information about the strategy parameter.)\n\n     gzopen can be used to read a file which is not in gzip format; in this\n   case gzread will directly read from the file without decompression.\n\n     gzopen returns NULL if the file could not be opened or if there was\n   insufficient memory to allocate the (de)compression state; errno\n   can be checked to distinguish the two cases (if errno is zero, the\n   zlib error is Z_MEM_ERROR).  */\n\ngzFile gzdopen  OF((int fd, const char *mode));\n/*\n     gzdopen() associates a gzFile with the file descriptor fd.  File\n   descriptors are obtained from calls like open, dup, creat, pipe or\n   fileno (in the file has been previously opened with fopen).\n   The mode parameter is as in gzopen.\n     The next call of gzclose on the returned gzFile will also close the\n   file descriptor fd, just like fclose(fdopen(fd), mode) closes the file\n   descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).\n     gzdopen returns NULL if there was insufficient memory to allocate\n   the (de)compression state.\n*/\n\nint gzsetparams OF((gzFile file, int level, int strategy));\n/*\n     Dynamically update the compression level or strategy. See the description\n   of deflateInit2 for the meaning of these parameters.\n     gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not\n   opened for writing.\n*/\n\nint    gzread  OF((gzFile file, voidp buf, unsigned len));\n/*\n     Reads the given number of uncompressed bytes from the compressed file.\n   If the input file was not in gzip format, gzread copies the given number\n   of bytes into the buffer.\n     gzread returns the number of uncompressed bytes actually read (0 for\n   end of file, -1 for error). */\n\nint    gzwrite OF((gzFile file, \n\t\t\t\t   const voidp buf, unsigned len));\n/*\n     Writes the given number of uncompressed bytes into the compressed file.\n   gzwrite returns the number of uncompressed bytes actually written\n   (0 in case of error).\n*/\n\nint    gzprintf OF((gzFile file, const char *format, ...));\n/*\n     Converts, formats, and writes the args to the compressed file under\n   control of the format string, as in fprintf. gzprintf returns the number of\n   uncompressed bytes actually written (0 in case of error).\n*/\n\nint gzputs OF((gzFile file, const char *s));\n/*\n      Writes the given null-terminated string to the compressed file, excluding\n   the terminating null character.\n      gzputs returns the number of characters written, or -1 in case of error.\n*/\n\nchar * gzgets OF((gzFile file, char *buf, int len));\n/*\n      Reads bytes from the compressed file until len-1 characters are read, or\n   a newline character is read and transferred to buf, or an end-of-file\n   condition is encountered.  The string is then terminated with a null\n   character.\n      gzgets returns buf, or Z_NULL in case of error.\n*/\n\nint    gzputc OF((gzFile file, int c));\n/*\n      Writes c, converted to an unsigned char, into the compressed file.\n   gzputc returns the value that was written, or -1 in case of error.\n*/\n\nint    gzgetc OF((gzFile file));\n/*\n      Reads one byte from the compressed file. gzgetc returns this byte\n   or -1 in case of end of file or error.\n*/\n\nint    gzflush OF((gzFile file, int flush));\n/*\n     Flushes all pending output into the compressed file. The parameter\n   flush is as in the deflate() function. The return value is the zlib\n   error number (see function gzerror below). gzflush returns Z_OK if\n   the flush parameter is Z_FINISH and all output could be flushed.\n     gzflush should be called only when strictly necessary because it can\n   degrade compression.\n*/\n\nlong gzseek OF((gzFile file,\n\t\t\t\t      long offset, int whence));\n/* \n      Sets the starting position for the next gzread or gzwrite on the\n   given compressed file. The offset represents a number of bytes in the\n   uncompressed data stream. The whence parameter is defined as in lseek(2);\n   the value SEEK_END is not supported.\n     If the file is opened for reading, this function is emulated but can be\n   extremely slow. If the file is opened for writing, only forward seeks are\n   supported; gzseek then compresses a sequence of zeroes up to the new\n   starting position.\n\n      gzseek returns the resulting offset location as measured in bytes from\n   the beginning of the uncompressed stream, or -1 in case of error, in\n   particular if the file is opened for writing and the new starting position\n   would be before the current position.\n*/\n\nint    gzrewind OF((gzFile file));\n/*\n     Rewinds the given file. This function is supported only for reading.\n\n   gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)\n*/\n\nlong    gztell OF((gzFile file));\n/*\n     Returns the starting position for the next gzread or gzwrite on the\n   given compressed file. This position represents a number of bytes in the\n   uncompressed data stream.\n\n   gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)\n*/\n\nint gzeof OF((gzFile file));\n/*\n     Returns 1 when EOF has previously been detected reading the given\n   input stream, otherwise zero.\n*/\n\nint    gzclose OF((gzFile file));\n/*\n     Flushes all pending output if necessary, closes the compressed file\n   and deallocates all the (de)compression state. The return value is the zlib\n   error number (see function gzerror below).\n*/\n\nconst char * gzerror OF((gzFile file, int *errnum));\n/*\n     Returns the error message for the last error which occurred on the\n   given compressed file. errnum is set to zlib error number. If an\n   error occurred in the file system and not in the compression library,\n   errnum is set to Z_ERRNO and the application may consult errno\n   to get the exact error code.\n*/\n\n                        /* checksum functions */\n\n/*\n     These functions are not related to compression but are exported\n   anyway because they might be useful in applications using the\n   compression library.\n*/\n\nuLong adler32 OF((uLong adler, const Byte *buf, uInt len));\n\n/*\n     Update a running Adler-32 checksum with the bytes buf[0..len-1] and\n   return the updated checksum. If buf is NULL, this function returns\n   the required initial value for the checksum.\n   An Adler-32 checksum is almost as reliable as a CRC32 but can be computed\n   much faster. Usage example:\n\n     uLong adler = adler32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       adler = adler32(adler, buffer, length);\n     }\n     if (adler != original_adler) error();\n*/\n\nuLong crc32   OF((uLong crc, const Byte *buf, uInt len));\n/*\n     Update a running crc with the bytes buf[0..len-1] and return the updated\n   crc. If buf is NULL, this function returns the required initial value\n   for the crc. Pre- and post-conditioning (one's complement) is performed\n   within this function so it shouldn't be done by the application.\n   Usage example:\n\n     uLong crc = crc32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       crc = crc32(crc, buffer, length);\n     }\n     if (crc != original_crc) error();\n*/\n\n// private stuff to not include cmdlib.h\n/*\n============================================================================\n\n\t\t\t\t\tBYTE ORDER FUNCTIONS\n\n============================================================================\n*/\n\n#ifdef _SGI_SOURCE\n#define\t__BIG_ENDIAN__\n#endif\n\n#ifdef __BIG_ENDIAN__\n\nshort   __LittleShort (short l)\n{\n\tbyte    b1,b2;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\n\treturn (b1<<8) + b2;\n}\n\nshort   __BigShort (short l)\n{\n\treturn l;\n}\n\n\nint    __LittleLong (int l)\n{\n\tbyte    b1,b2,b3,b4;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\tb3 = (l>>16)&255;\n\tb4 = (l>>24)&255;\n\n\treturn ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;\n}\n\nint    __BigLong (int l)\n{\n\treturn l;\n}\n\n\nfloat\t__LittleFloat (float l)\n{\n\tunion {byte b[4]; float f;} in, out;\n\t\n\tin.f = l;\n\tout.b[0] = in.b[3];\n\tout.b[1] = in.b[2];\n\tout.b[2] = in.b[1];\n\tout.b[3] = in.b[0];\n\t\n\treturn out.f;\n}\n\nfloat\t__BigFloat (float l)\n{\n\treturn l;\n}\n\n\n#else\n\n\nshort   __BigShort (short l)\n{\n\tbyte    b1,b2;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\n\treturn (b1<<8) + b2;\n}\n\nshort   __LittleShort (short l)\n{\n\treturn l;\n}\n\n\nint    __BigLong (int l)\n{\n\tbyte    b1,b2,b3,b4;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\tb3 = (l>>16)&255;\n\tb4 = (l>>24)&255;\n\n\treturn ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;\n}\n\nint    __LittleLong (int l)\n{\n\treturn l;\n}\n\nfloat\t__BigFloat (float l)\n{\n\tunion {byte b[4]; float f;} in, out;\n\t\n\tin.f = l;\n\tout.b[0] = in.b[3];\n\tout.b[1] = in.b[2];\n\tout.b[2] = in.b[1];\n\tout.b[3] = in.b[0];\n\t\n\treturn out.f;\n}\n\nfloat\t__LittleFloat (float l)\n{\n\treturn l;\n}\n\n\n\n#endif\n\n\n\n\n                        /* various hacks, don't look :) */\n\n/* deflateInit and inflateInit are macros to allow checking the zlib version\n * and the compiler's view of z_stream:\n */\nint deflateInit_ OF((z_streamp strm, int level,\n                                     const char *version, int stream_size));\nint inflateInit_ OF((z_streamp strm,\n                                     const char *version, int stream_size));\nint deflateInit2_ OF((z_streamp strm, int  level, int  method,\n                                      int windowBits, int memLevel,\n                                      int strategy, const char *version,\n                                      int stream_size));\nint inflateInit2_ OF((z_streamp strm, int  windowBits,\n                                      const char *version, int stream_size));\n#define deflateInit(strm, level) \\\n        deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream))\n#define inflateInit(strm) \\\n        inflateInit_((strm),                ZLIB_VERSION, sizeof(z_stream))\n#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \\\n        deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\\\n                      (strategy),           ZLIB_VERSION, sizeof(z_stream))\n#define inflateInit2(strm, windowBits) \\\n        inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))\n\n\nconst char   * zError           OF((int err));\nint            inflateSyncPoint OF((z_streamp z));\nconst uLong * get_crc_table    OF((void));\n\ntypedef unsigned char  uch;\ntypedef unsigned short ush;\ntypedef unsigned long  ulg;\n\nextern const char *z_errmsg[10]; /* indexed by 2-zlib_error */\n/* (size given to avoid silly warnings with Visual C++) */\n\n#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]\n\n#define ERR_RETURN(strm,err) \\\n  return (strm->msg = (char*)ERR_MSG(err), (err))\n/* To be used only when the state is known to be valid */\n\n        /* common constants */\n\n#ifndef DEF_WBITS\n#  define DEF_WBITS MAX_WBITS\n#endif\n/* default windowBits for decompression. MAX_WBITS is for compression only */\n\n#if MAX_MEM_LEVEL >= 8\n#  define DEF_MEM_LEVEL 8\n#else\n#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL\n#endif\n/* default memLevel */\n\n#define STORED_BLOCK 0\n#define STATIC_TREES 1\n#define DYN_TREES    2\n/* The three kinds of block type */\n\n#define MIN_MATCH  3\n#define MAX_MATCH  258\n/* The minimum and maximum match lengths */\n\n#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */\n\n        /* target dependencies */\n\n        /* Common defaults */\n\n#ifndef OS_CODE\n#  define OS_CODE  0x03  /* assume Unix */\n#endif\n\n#ifndef F_OPEN\n#  define F_OPEN(name, mode) fopen((name), (mode))\n#endif\n\n         /* functions */\n\n#ifdef HAVE_STRERROR\n   extern char *strerror OF((int));\n#  define zstrerror(errnum) strerror(errnum)\n#else\n#  define zstrerror(errnum) \"\"\n#endif\n\n#define zmemcpy memcpy\n#define zmemcmp memcmp\n#define zmemzero(dest, len) memset(dest, 0, len)\n\n/* Diagnostic functions */\n#ifdef _ZIP_DEBUG_\n   int z_verbose = 0;\n#  define Assert(cond,msg) assert(cond);\n   //{if(!(cond)) Sys_Error(msg);}\n#  define Trace(x) {if (z_verbose>=0) Sys_Error x ;}\n#  define Tracev(x) {if (z_verbose>0) Sys_Error x ;}\n#  define Tracevv(x) {if (z_verbose>1) Sys_Error x ;}\n#  define Tracec(c,x) {if (z_verbose>0 && (c)) Sys_Error x ;}\n#  define Tracecv(c,x) {if (z_verbose>1 && (c)) Sys_Error x ;}\n#else\n#  define Assert(cond,msg)\n#  define Trace(x)\n#  define Tracev(x)\n#  define Tracevv(x)\n#  define Tracec(c,x)\n#  define Tracecv(c,x)\n#endif\n\n\ntypedef uLong (*check_func) OF((uLong check, const Byte *buf, uInt len));\nvoidp zcalloc OF((voidp opaque, unsigned items, unsigned size));\nvoid   zcfree  OF((voidp opaque, voidp ptr));\n\n#define ZALLOC(strm, items, size) \\\n           (*((strm)->zalloc))((strm)->opaque, (items), (size))\n#define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidp)(addr))\n#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}\n\n\n#if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \\\n                      !defined(CASESENSITIVITYDEFAULT_NO)\n#define CASESENSITIVITYDEFAULT_NO\n#endif\n\n\n#ifndef UNZ_BUFSIZE\n#define UNZ_BUFSIZE (65536)\n#endif\n\n#ifndef UNZ_MAXFILENAMEINZIP\n#define UNZ_MAXFILENAMEINZIP (256)\n#endif\n\n#ifndef ALLOC\n# define ALLOC(size) (malloc(size))\n#endif\n#ifndef TRYFREE\n# define TRYFREE(p) {if (p) free(p);}\n#endif\n\n#define SIZECENTRALDIRITEM (0x2e)\n#define SIZEZIPLOCALHEADER (0x1e)\n\n\n\n/* ===========================================================================\n     Read a byte from a gz_stream; update next_in and avail_in. Return EOF\n   for end of file.\n   IN assertion: the stream s has been sucessfully opened for reading.\n*/\n\n/*\nstatic int unzlocal_getByte(FILE *fin,int *pi)\n{\n    unsigned char c;\n\tint err = fread(&c, 1, 1, fin);\n    if (err==1)\n    {\n        *pi = (int)c;\n        return UNZ_OK;\n    }\n    else\n    {\n        if (ferror(fin)) \n            return UNZ_ERRNO;\n        else\n            return UNZ_EOF;\n    }\n}\n*/\n\n/* ===========================================================================\n   Reads a long in LSB order from the given gz_stream. Sets \n*/\nstatic int unzlocal_getShort (FILE* fin, uLong *pX)\n{\n\tshort\tv;\n\n\tfread( &v, sizeof(v), 1, fin );\n\n\t*pX = __LittleShort( v);\n\treturn UNZ_OK;\n\n/*\n    uLong x ;\n    int i;\n    int err;\n\n    err = unzlocal_getByte(fin,&i);\n    x = (uLong)i;\n    \n    if (err==UNZ_OK)\n        err = unzlocal_getByte(fin,&i);\n    x += ((uLong)i)<<8;\n   \n    if (err==UNZ_OK)\n        *pX = x;\n    else\n        *pX = 0;\n    return err;\n*/\n}\n\nstatic int unzlocal_getLong (FILE *fin, uLong *pX)\n{\n\tint\t\tv;\n\n\tfread( &v, sizeof(v), 1, fin );\n\n\t*pX = __LittleLong( v);\n\treturn UNZ_OK;\n\n/*\n    uLong x ;\n    int i;\n    int err;\n\n    err = unzlocal_getByte(fin,&i);\n    x = (uLong)i;\n    \n    if (err==UNZ_OK)\n        err = unzlocal_getByte(fin,&i);\n    x += ((uLong)i)<<8;\n\n    if (err==UNZ_OK)\n        err = unzlocal_getByte(fin,&i);\n    x += ((uLong)i)<<16;\n\n    if (err==UNZ_OK)\n        err = unzlocal_getByte(fin,&i);\n    x += ((uLong)i)<<24;\n   \n    if (err==UNZ_OK)\n        *pX = x;\n    else\n        *pX = 0;\n    return err;\n*/\n}\n\n\n/* My own strcmpi / strcasecmp */\nstatic int strcmpcasenosensitive_internal (const char* fileName1,const char* fileName2)\n{\n\tfor (;;)\n\t{\n\t\tchar c1=*(fileName1++);\n\t\tchar c2=*(fileName2++);\n\t\tif ((c1>='a') && (c1<='z'))\n\t\t\tc1 -= 0x20;\n\t\tif ((c2>='a') && (c2<='z'))\n\t\t\tc2 -= 0x20;\n\t\tif (c1=='\\0')\n\t\t\treturn ((c2=='\\0') ? 0 : -1);\n\t\tif (c2=='\\0')\n\t\t\treturn 1;\n\t\tif (c1<c2)\n\t\t\treturn -1;\n\t\tif (c1>c2)\n\t\t\treturn 1;\n\t}\n}\n\n\n#ifdef  CASESENSITIVITYDEFAULT_NO\n#define CASESENSITIVITYDEFAULTVALUE 2\n#else\n#define CASESENSITIVITYDEFAULTVALUE 1\n#endif\n\n#ifndef STRCMPCASENOSENTIVEFUNCTION\n#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal\n#endif\n\n/* \n   Compare two filename (fileName1,fileName2).\n   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)\n   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi\n                                                                or strcasecmp)\n   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system\n        (like 1 on Unix, 2 on Windows)\n\n*/\nextern int unzStringFileNameCompare (const char* fileName1,const char* fileName2,int iCaseSensitivity)\n{\n\tif (iCaseSensitivity==0)\n\t\tiCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;\n\n\tif (iCaseSensitivity==1)\n\t\treturn strcmp(fileName1,fileName2);\n\n\treturn STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);\n} \n\n#define BUFREADCOMMENT (0x400)\n\n/*\n  Locate the Central directory of a zipfile (at the end, just before\n    the global comment)\n*/\nstatic uLong unzlocal_SearchCentralDir(FILE *fin)\n{\n\tunsigned char* buf;\n\tuLong uSizeFile;\n\tuLong uBackRead;\n\tuLong uMaxBack=0xffff; /* maximum size of global comment */\n\tuLong uPosFound=0;\n\t\n\tif (fseek(fin,0,SEEK_END) != 0)\n\t\treturn 0;\n\n\n\tuSizeFile = ftell( fin );\n\t\n\tif (uMaxBack>uSizeFile)\n\t\tuMaxBack = uSizeFile;\n\n\tbuf = (unsigned char*)malloc(BUFREADCOMMENT+4);\n\tif (buf==NULL)\n\t\treturn 0;\n\n\tuBackRead = 4;\n\twhile (uBackRead<uMaxBack)\n\t{\n\t\tuLong uReadSize,uReadPos ;\n\t\tint i;\n\t\tif (uBackRead+BUFREADCOMMENT>uMaxBack) \n\t\t\tuBackRead = uMaxBack;\n\t\telse\n\t\t\tuBackRead+=BUFREADCOMMENT;\n\t\tuReadPos = uSizeFile-uBackRead ;\n\t\t\n\t\tuReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? \n                     (BUFREADCOMMENT+4) : (uSizeFile-uReadPos);\n\t\tif (fseek(fin,uReadPos,SEEK_SET)!=0)\n\t\t\tbreak;\n\n\t\tif (fread(buf,(uInt)uReadSize,1,fin)!=1)\n\t\t\tbreak;\n\n                for (i=(int)uReadSize-3; (i--)>0;)\n\t\t\tif (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && \n\t\t\t\t((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))\n\t\t\t{\n\t\t\t\tuPosFound = uReadPos+i;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\tif (uPosFound!=0)\n\t\t\tbreak;\n\t}\n\tfree(buf);\n\treturn uPosFound;\n}\n\nextern unzFile unzReOpen (const char* path, unzFile file)\n{\n\tunz_s *s;\n\tFILE * fin;\n\n    fin=fopen(path,\"rb\");\n\tif (fin==NULL)\n\t\treturn NULL;\n\n\ts=(unz_s*)malloc(sizeof(unz_s));\n\tmemcpy(s, (unz_s*)file, sizeof(unz_s));\n\n\ts->file = fin;\n\treturn (unzFile)s;\t\n}\n\n/*\n  Open a Zip file. path contain the full pathname (by example,\n     on a Windows NT computer \"c:\\\\test\\\\zlib109.zip\" or on an Unix computer\n\t \"zlib/zlib109.zip\".\n\t If the zipfile cannot be opened (file don't exist or in not valid), the\n\t   return value is NULL.\n     Else, the return value is a unzFile Handle, usable with other function\n\t   of this unzip package.\n*/\nextern unzFile unzOpen (const char* path)\n{\n\tunz_s us;\n\tunz_s *s;\n\tuLong central_pos,uL;\n\tFILE * fin ;\n\n\tuLong number_disk;          /* number of the current dist, used for \n\t\t\t\t\t\t\t\t   spaning ZIP, unsupported, always 0*/\n\tuLong number_disk_with_CD;  /* number the the disk with central dir, used\n\t\t\t\t\t\t\t\t   for spaning ZIP, unsupported, always 0*/\n\tuLong number_entry_CD;      /* total number of entries in\n\t                               the central dir \n\t                               (same than number_entry on nospan) */\n\n\tint err=UNZ_OK;\n\n    fin=fopen(path,\"rb\");\n\tif (fin==NULL)\n\t\treturn NULL;\n\n\tcentral_pos = unzlocal_SearchCentralDir(fin);\n\tif (central_pos==0)\n\t\terr=UNZ_ERRNO;\n\n\tif (fseek(fin,central_pos,SEEK_SET)!=0)\n\t\terr=UNZ_ERRNO;\n\n\t/* the signature, already checked */\n\tif (unzlocal_getLong(fin,&uL)!=UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\t/* number of this disk */\n\tif (unzlocal_getShort(fin,&number_disk)!=UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\t/* number of the disk with the start of the central directory */\n\tif (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\t/* total number of entries in the central dir on this disk */\n\tif (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\t/* total number of entries in the central dir */\n\tif (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif ((number_entry_CD!=us.gi.number_entry) ||\n\t\t(number_disk_with_CD!=0) ||\n\t\t(number_disk!=0))\n\t\terr=UNZ_BADZIPFILE;\n\n\t/* size of the central directory */\n\tif (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\t/* offset of start of central directory with respect to the \n\t      starting disk number */\n\tif (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\t/* zipfile comment length */\n\tif (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif ((central_pos<us.offset_central_dir+us.size_central_dir) && \n\t\t(err==UNZ_OK))\n\t\terr=UNZ_BADZIPFILE;\n\n\tif (err!=UNZ_OK)\n\t{\n\t\tfclose(fin);\n\t\treturn NULL;\n\t}\n\n\tus.file=fin;\n\tus.byte_before_the_zipfile = central_pos -\n\t\t                    (us.offset_central_dir+us.size_central_dir);\n\tus.central_pos = central_pos;\n    us.pfile_in_zip_read = NULL;\n\t\n\n\ts=(unz_s*)malloc(sizeof(unz_s));\n\t*s=us;\n//\tunzGoToFirstFile((unzFile)s);\t\n\treturn (unzFile)s;\t\n}\n\n\n/*\n  Close a ZipFile opened with unzipOpen.\n  If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),\n    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.\n  return UNZ_OK if there is no problem. */\nextern int unzClose (unzFile file)\n{\n\tunz_s* s;\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n\n    if (s->pfile_in_zip_read!=NULL)\n        unzCloseCurrentFile(file);\n\n\tfclose(s->file);\n\tfree(s);\n\treturn UNZ_OK;\n}\n\n\n/*\n  Write info about the ZipFile in the *pglobal_info structure.\n  No preparation of the structure is needed\n  return UNZ_OK if there is no problem. */\nextern int unzGetGlobalInfo (unzFile file,unz_global_info *pglobal_info)\n{\n\tunz_s* s;\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n\t*pglobal_info=s->gi;\n\treturn UNZ_OK;\n}\n\n\n/*\n   Translate date/time from Dos format to tm_unz (readable more easilty)\n*/\nstatic void unzlocal_DosDateToTmuDate (uLong ulDosDate, tm_unz* ptm)\n{\n    uLong uDate;\n    uDate = (uLong)(ulDosDate>>16);\n    ptm->tm_mday = (uInt)(uDate&0x1f) ;\n    ptm->tm_mon =  (uInt)((((uDate)&0x1E0)/0x20)-1) ;\n    ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;\n\n    ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);\n    ptm->tm_min =  (uInt) ((ulDosDate&0x7E0)/0x20) ;\n    ptm->tm_sec =  (uInt) (2*(ulDosDate&0x1f)) ;\n}\n\n/*\n  Get Info about the current file in the zipfile, with internal only info\n*/\nstatic int unzlocal_GetCurrentFileInfoInternal (unzFile file,\n                                                  unz_file_info *pfile_info,\n                                                  unz_file_info_internal \n                                                  *pfile_info_internal,\n                                                  char *szFileName,\n\t\t\t\t\t\t\t\t\t\t\t\t  uLong fileNameBufferSize,\n                                                  void *extraField,\n\t\t\t\t\t\t\t\t\t\t\t\t  uLong extraFieldBufferSize,\n                                                  char *szComment,\n\t\t\t\t\t\t\t\t\t\t\t\t  uLong commentBufferSize)\n{\n\tunz_s* s;\n\tunz_file_info file_info;\n\tunz_file_info_internal file_info_internal;\n\tint err=UNZ_OK;\n\tuLong uMagic;\n\tlong lSeek=0;\n\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n\tif (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0)\n\t\terr=UNZ_ERRNO;\n\n\n\t/* we check the magic */\n\tif (err==UNZ_OK)\n\t\tif (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)\n\t\t\terr=UNZ_ERRNO;\n\t\telse if (uMagic!=0x02014b50)\n\t\t\terr=UNZ_BADZIPFILE;\n\n\tif (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n    unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);\n\n\tif (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tlSeek+=file_info.size_filename;\n\tif ((err==UNZ_OK) && (szFileName!=NULL))\n\t{\n\t\tuLong uSizeRead ;\n\t\tif (file_info.size_filename<fileNameBufferSize)\n\t\t{\n\t\t\t*(szFileName+file_info.size_filename)='\\0';\n\t\t\tuSizeRead = file_info.size_filename;\n\t\t}\n\t\telse\n\t\t\tuSizeRead = fileNameBufferSize;\n\n\t\tif ((file_info.size_filename>0) && (fileNameBufferSize>0))\n\t\t\tif (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1)\n\t\t\t\terr=UNZ_ERRNO;\n\t\tlSeek -= uSizeRead;\n\t}\n\n\t\n\tif ((err==UNZ_OK) && (extraField!=NULL))\n\t{\n\t\tuLong uSizeRead ;\n\t\tif (file_info.size_file_extra<extraFieldBufferSize)\n\t\t\tuSizeRead = file_info.size_file_extra;\n\t\telse\n\t\t\tuSizeRead = extraFieldBufferSize;\n\n\t\tif (lSeek!=0)\n\t\t\tif (fseek(s->file,lSeek,SEEK_CUR)==0)\n\t\t\t\tlSeek=0;\n\t\t\telse\n\t\t\t\terr=UNZ_ERRNO;\n\t\tif ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))\n\t\t\tif (fread(extraField,(uInt)uSizeRead,1,s->file)!=1)\n\t\t\t\terr=UNZ_ERRNO;\n\t\tlSeek += file_info.size_file_extra - uSizeRead;\n\t}\n\telse\n\t\tlSeek+=file_info.size_file_extra; \n\n\t\n\tif ((err==UNZ_OK) && (szComment!=NULL))\n\t{\n\t\tuLong uSizeRead ;\n\t\tif (file_info.size_file_comment<commentBufferSize)\n\t\t{\n\t\t\t*(szComment+file_info.size_file_comment)='\\0';\n\t\t\tuSizeRead = file_info.size_file_comment;\n\t\t}\n\t\telse\n\t\t\tuSizeRead = commentBufferSize;\n\n\t\tif (lSeek!=0)\n\t\t\tif (fseek(s->file,lSeek,SEEK_CUR)==0)\n\t\t\t\tlSeek=0;\n\t\t\telse\n\t\t\t\terr=UNZ_ERRNO;\n\t\tif ((file_info.size_file_comment>0) && (commentBufferSize>0))\n\t\t\tif (fread(szComment,(uInt)uSizeRead,1,s->file)!=1)\n\t\t\t\terr=UNZ_ERRNO;\n\t\tlSeek+=file_info.size_file_comment - uSizeRead;\n\t}\n\telse\n\t\tlSeek+=file_info.size_file_comment;\n\n\tif ((err==UNZ_OK) && (pfile_info!=NULL))\n\t\t*pfile_info=file_info;\n\n\tif ((err==UNZ_OK) && (pfile_info_internal!=NULL))\n\t\t*pfile_info_internal=file_info_internal;\n\n\treturn err;\n}\n\n\n\n/*\n  Write info about the ZipFile in the *pglobal_info structure.\n  No preparation of the structure is needed\n  return UNZ_OK if there is no problem.\n*/\nextern int unzGetCurrentFileInfo (\tunzFile file, unz_file_info *pfile_info,\n\t\t\t\t\t\t\t\t\tchar *szFileName, uLong fileNameBufferSize,\n\t\t\t\t\t\t\t\t\tvoid *extraField, uLong extraFieldBufferSize,\n\t\t\t\t\t\t\t\t\tchar *szComment, uLong commentBufferSize)\n{\n\treturn unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,\n\t\t\t\t\t\t\t\t\t\t\t\tszFileName,fileNameBufferSize,\n\t\t\t\t\t\t\t\t\t\t\t\textraField,extraFieldBufferSize,\n\t\t\t\t\t\t\t\t\t\t\t\tszComment,commentBufferSize);\n}\n\n/*\n  Set the current file of the zipfile to the first file.\n  return UNZ_OK if there is no problem\n*/\nextern int unzGoToFirstFile (unzFile file)\n{\n\tint err=UNZ_OK;\n\tunz_s* s;\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n\ts->pos_in_central_dir=s->offset_central_dir;\n\ts->num_file=0;\n\terr=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,\n\t\t\t\t\t\t\t\t\t\t\t &s->cur_file_info_internal,\n\t\t\t\t\t\t\t\t\t\t\t NULL,0,NULL,0,NULL,0);\n\ts->current_file_ok = (err == UNZ_OK);\n\treturn err;\n}\n\n\n/*\n  Set the current file of the zipfile to the next file.\n  return UNZ_OK if there is no problem\n  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.\n*/\nextern int unzGoToNextFile (unzFile file)\n{\n\tunz_s* s;\t\n\tint err;\n\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n\tif (!s->current_file_ok)\n\t\treturn UNZ_END_OF_LIST_OF_FILE;\n\tif (s->num_file+1==s->gi.number_entry)\n\t\treturn UNZ_END_OF_LIST_OF_FILE;\n\n\ts->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +\n\t\t\ts->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;\n\ts->num_file++;\n\terr = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,\n\t\t\t\t\t\t\t\t\t\t\t   &s->cur_file_info_internal,\n\t\t\t\t\t\t\t\t\t\t\t   NULL,0,NULL,0,NULL,0);\n\ts->current_file_ok = (err == UNZ_OK);\n\treturn err;\n}\n\n\n/*\n  Try locate the file szFileName in the zipfile.\n  For the iCaseSensitivity signification, see unzipStringFileNameCompare\n\n  return value :\n  UNZ_OK if the file is found. It becomes the current file.\n  UNZ_END_OF_LIST_OF_FILE if the file is not found\n*/\nextern int unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity)\n{\n\tunz_s* s;\t\n\tint err;\n\n\t\n\tuLong num_fileSaved;\n\tuLong pos_in_central_dirSaved;\n\n\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\n    if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)\n        return UNZ_PARAMERROR;\n\n\ts=(unz_s*)file;\n\tif (!s->current_file_ok)\n\t\treturn UNZ_END_OF_LIST_OF_FILE;\n\n\tnum_fileSaved = s->num_file;\n\tpos_in_central_dirSaved = s->pos_in_central_dir;\n\n\terr = unzGoToFirstFile(file);\n\n\twhile (err == UNZ_OK)\n\t{\n\t\tchar szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];\n\t\tunzGetCurrentFileInfo(file,NULL,\n\t\t\t\t\t\t\t\tszCurrentFileName,sizeof(szCurrentFileName)-1,\n\t\t\t\t\t\t\t\tNULL,0,NULL,0);\n\t\tif (unzStringFileNameCompare(szCurrentFileName,\n\t\t\t\t\t\t\t\t\t\tszFileName,iCaseSensitivity)==0)\n\t\t\treturn UNZ_OK;\n\t\terr = unzGoToNextFile(file);\n\t}\n\n\ts->num_file = num_fileSaved ;\n\ts->pos_in_central_dir = pos_in_central_dirSaved ;\n\treturn err;\n}\n\n\n/*\n  Read the static header of the current zipfile\n  Check the coherency of the static header and info in the end of central\n        directory about this file\n  store in *piSizeVar the size of extra info in static header\n        (filename and size of extra field data)\n*/\nstatic int unzlocal_CheckCurrentFileCoherencyHeader (unz_s* s, uInt* piSizeVar,\n\t\t\t\t\t\t\t\t\t\t\t\t\tuLong *poffset_local_extrafield,\n\t\t\t\t\t\t\t\t\t\t\t\t\tuInt *psize_local_extrafield)\n{\n\tuLong uMagic,uData,uFlags;\n\tuLong size_filename;\n\tuLong size_extra_field;\n\tint err=UNZ_OK;\n\n\t*piSizeVar = 0;\n\t*poffset_local_extrafield = 0;\n\t*psize_local_extrafield = 0;\n\n\tif (fseek(s->file,s->cur_file_info_internal.offset_curfile +\n\t\t\t\t\t\t\t\ts->byte_before_the_zipfile,SEEK_SET)!=0)\n\t\treturn UNZ_ERRNO;\n\n\n\tif (err==UNZ_OK)\n\t\tif (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)\n\t\t\terr=UNZ_ERRNO;\n\t\telse if (uMagic!=0x04034b50)\n\t\t\terr=UNZ_BADZIPFILE;\n\n\tif (unzlocal_getShort(s->file,&uData) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n/*\n\telse if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))\n\t\terr=UNZ_BADZIPFILE;\n*/\n\tif (unzlocal_getShort(s->file,&uFlags) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getShort(s->file,&uData) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\telse if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))\n\t\terr=UNZ_BADZIPFILE;\n\n    if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&\n                         (s->cur_file_info.compression_method!=Z_DEFLATED))\n        err=UNZ_BADZIPFILE;\n\n\tif (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */\n\t\terr=UNZ_ERRNO;\n\n\tif (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */\n\t\terr=UNZ_ERRNO;\n\telse if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) &&\n\t\t                      ((uFlags & 8)==0))\n\t\terr=UNZ_BADZIPFILE;\n\n\tif (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */\n\t\terr=UNZ_ERRNO;\n\telse if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) &&\n\t\t\t\t\t\t\t  ((uFlags & 8)==0))\n\t\terr=UNZ_BADZIPFILE;\n\n\tif (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */\n\t\terr=UNZ_ERRNO;\n\telse if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && \n\t\t\t\t\t\t\t  ((uFlags & 8)==0))\n\t\terr=UNZ_BADZIPFILE;\n\n\n\tif (unzlocal_getShort(s->file,&size_filename) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\telse if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))\n\t\terr=UNZ_BADZIPFILE;\n\n\t*piSizeVar += (uInt)size_filename;\n\n\tif (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK)\n\t\terr=UNZ_ERRNO;\n\t*poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +\n\t\t\t\t\t\t\t\t\tSIZEZIPLOCALHEADER + size_filename;\n\t*psize_local_extrafield = (uInt)size_extra_field;\n\n\t*piSizeVar += (uInt)size_extra_field;\n\n\treturn err;\n}\n\t\t\t\t\t\t\t\t\t\t\t\t\n/*\n  Open for reading data the current file in the zipfile.\n  If there is no error and the file is opened, the return value is UNZ_OK.\n*/\nextern int unzOpenCurrentFile (unzFile file)\n{\n\tint err=UNZ_OK;\n\tint Store;\n\tuInt iSizeVar;\n\tunz_s* s;\n\tfile_in_zip_read_info_s* pfile_in_zip_read_info;\n\tuLong offset_local_extrafield;  /* offset of the static extra field */\n\tuInt  size_local_extrafield;    /* size of the static extra field */\n\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n\tif (!s->current_file_ok)\n\t\treturn UNZ_PARAMERROR;\n\n    if (s->pfile_in_zip_read != NULL)\n        unzCloseCurrentFile(file);\n\n\tif (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar,\n\t\t\t\t&offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)\n\t\treturn UNZ_BADZIPFILE;\n\n\tpfile_in_zip_read_info = (file_in_zip_read_info_s*)\n\t\t\t\t\t\t\t\t\t    malloc(sizeof(file_in_zip_read_info_s));\n\tif (pfile_in_zip_read_info==NULL)\n\t\treturn UNZ_INTERNALERROR;\n\n\tpfile_in_zip_read_info->read_buffer=(char*)malloc(UNZ_BUFSIZE);\n\tpfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;\n\tpfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;\n\tpfile_in_zip_read_info->pos_local_extrafield=0;\n\n\tif (pfile_in_zip_read_info->read_buffer==NULL)\n\t{\n\t\tfree(pfile_in_zip_read_info);\n\t\treturn UNZ_INTERNALERROR;\n\t}\n\n\tpfile_in_zip_read_info->stream_initialised=0;\n\t\n\tif ((s->cur_file_info.compression_method!=0) &&\n        (s->cur_file_info.compression_method!=Z_DEFLATED))\n\t\terr=UNZ_BADZIPFILE;\n\tStore = s->cur_file_info.compression_method==0;\n\n\tpfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;\n\tpfile_in_zip_read_info->crc32=0;\n\tpfile_in_zip_read_info->compression_method =\n            s->cur_file_info.compression_method;\n\tpfile_in_zip_read_info->file=s->file;\n\tpfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;\n\n    pfile_in_zip_read_info->stream.total_out = 0;\n\n\tif (!Store)\n\t{\n\t  pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;\n\t  pfile_in_zip_read_info->stream.zfree = (free_func)0;\n\t  pfile_in_zip_read_info->stream.opaque = (voidp)0; \n      \n\t  err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);\n\t  if (err == Z_OK)\n\t    pfile_in_zip_read_info->stream_initialised=1;\n        /* windowBits is passed < 0 to tell that there is no zlib header.\n         * Note that in this case inflate *requires* an extra \"dummy\" byte\n         * after the compressed stream in order to complete decompression and\n         * return Z_STREAM_END. \n         * In unzip, i don't wait absolutely Z_STREAM_END because I known the \n         * size of both compressed and uncompressed data\n         */\n\t}\n\tpfile_in_zip_read_info->rest_read_compressed = \n            s->cur_file_info.compressed_size ;\n\tpfile_in_zip_read_info->rest_read_uncompressed = \n            s->cur_file_info.uncompressed_size ;\n\n\t\n\tpfile_in_zip_read_info->pos_in_zipfile = \n            s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + \n\t\t\t  iSizeVar;\n\t\n\tpfile_in_zip_read_info->stream.avail_in = (uInt)0;\n\n\n\ts->pfile_in_zip_read = pfile_in_zip_read_info;\n    return UNZ_OK;\n}\n\n\n/*\n  Read bytes from the current file.\n  buf contain buffer where data must be copied\n  len the size of buf.\n\n  return the number of byte copied if somes bytes are copied\n  return 0 if the end of file was reached\n  return <0 with error code if there is an error\n    (UNZ_ERRNO for IO error, or zLib error for uncompress error)\n*/\nextern int unzReadCurrentFile  (unzFile file, void *buf, unsigned len)\n{\n\tint err=UNZ_OK;\n\tuInt iRead = 0;\n\tunz_s* s;\n\tfile_in_zip_read_info_s* pfile_in_zip_read_info;\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n    pfile_in_zip_read_info=s->pfile_in_zip_read;\n\n\tif (pfile_in_zip_read_info==NULL)\n\t\treturn UNZ_PARAMERROR;\n\n\n\tif ((pfile_in_zip_read_info->read_buffer == NULL))\n\t\treturn UNZ_END_OF_LIST_OF_FILE;\n\tif (len==0)\n\t\treturn 0;\n\n\tpfile_in_zip_read_info->stream.next_out = (Byte*)buf;\n\n\tpfile_in_zip_read_info->stream.avail_out = (uInt)len;\n\t\n\tif (len>pfile_in_zip_read_info->rest_read_uncompressed)\n\t\tpfile_in_zip_read_info->stream.avail_out = \n\t\t  (uInt)pfile_in_zip_read_info->rest_read_uncompressed;\n\n\twhile (pfile_in_zip_read_info->stream.avail_out>0)\n\t{\n\t\tif ((pfile_in_zip_read_info->stream.avail_in==0) &&\n            (pfile_in_zip_read_info->rest_read_compressed>0))\n\t\t{\n\t\t\tuInt uReadThis = UNZ_BUFSIZE;\n\t\t\tif (pfile_in_zip_read_info->rest_read_compressed<uReadThis)\n\t\t\t\tuReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;\n\t\t\tif (uReadThis == 0)\n\t\t\t\treturn UNZ_EOF;\n\t\t\tif (s->cur_file_info.compressed_size == pfile_in_zip_read_info->rest_read_compressed)\n\t\t\t\tif (fseek(pfile_in_zip_read_info->file,\n\t\t\t\t\t\t  pfile_in_zip_read_info->pos_in_zipfile + \n\t\t\t\t\t\t\t pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0)\n\t\t\t\t\treturn UNZ_ERRNO;\n\t\t\tif (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1,\n                         pfile_in_zip_read_info->file)!=1)\n\t\t\t\treturn UNZ_ERRNO;\n\t\t\tpfile_in_zip_read_info->pos_in_zipfile += uReadThis;\n\n\t\t\tpfile_in_zip_read_info->rest_read_compressed-=uReadThis;\n\t\t\t\n\t\t\tpfile_in_zip_read_info->stream.next_in = \n                (Byte*)pfile_in_zip_read_info->read_buffer;\n\t\t\tpfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;\n\t\t}\n\n\t\tif (pfile_in_zip_read_info->compression_method==0)\n\t\t{\n\t\t\tuInt uDoCopy,i ;\n\t\t\tif (pfile_in_zip_read_info->stream.avail_out < \n                            pfile_in_zip_read_info->stream.avail_in)\n\t\t\t\tuDoCopy = pfile_in_zip_read_info->stream.avail_out ;\n\t\t\telse\n\t\t\t\tuDoCopy = pfile_in_zip_read_info->stream.avail_in ;\n\t\t\t\t\n\t\t\tfor (i=0;i<uDoCopy;i++)\n\t\t\t\t*(pfile_in_zip_read_info->stream.next_out+i) =\n                        *(pfile_in_zip_read_info->stream.next_in+i);\n\t\t\t\t\t\n\t\t\tpfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,\n\t\t\t\t\t\t\t\tpfile_in_zip_read_info->stream.next_out,\n\t\t\t\t\t\t\t\tuDoCopy);\n\t\t\tpfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;\n\t\t\tpfile_in_zip_read_info->stream.avail_in -= uDoCopy;\n\t\t\tpfile_in_zip_read_info->stream.avail_out -= uDoCopy;\n\t\t\tpfile_in_zip_read_info->stream.next_out += uDoCopy;\n\t\t\tpfile_in_zip_read_info->stream.next_in += uDoCopy;\n            pfile_in_zip_read_info->stream.total_out += uDoCopy;\n\t\t\tiRead += uDoCopy;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tuLong uTotalOutBefore,uTotalOutAfter;\n\t\t\tconst Byte *bufBefore;\n\t\t\tuLong uOutThis;\n\t\t\tint flush=Z_SYNC_FLUSH;\n\n\t\t\tuTotalOutBefore = pfile_in_zip_read_info->stream.total_out;\n\t\t\tbufBefore = pfile_in_zip_read_info->stream.next_out;\n\n\t\t\t/*\n\t\t\tif ((pfile_in_zip_read_info->rest_read_uncompressed ==\n\t\t\t         pfile_in_zip_read_info->stream.avail_out) &&\n\t\t\t\t(pfile_in_zip_read_info->rest_read_compressed == 0))\n\t\t\t\tflush = Z_FINISH;\n\t\t\t*/\n\t\t\terr=inflate(&pfile_in_zip_read_info->stream,flush);\n\n\t\t\tuTotalOutAfter = pfile_in_zip_read_info->stream.total_out;\n\t\t\tuOutThis = uTotalOutAfter-uTotalOutBefore;\n\t\t\t\n\t\t\tpfile_in_zip_read_info->crc32 = \n                crc32(pfile_in_zip_read_info->crc32,bufBefore,\n                        (uInt)(uOutThis));\n\n\t\t\tpfile_in_zip_read_info->rest_read_uncompressed -=\n                uOutThis;\n\n\t\t\tiRead += (uInt)(uTotalOutAfter - uTotalOutBefore);\n            \n\t\t\tif (err==Z_STREAM_END)\n\t\t\t\treturn (iRead==0) ? UNZ_EOF : iRead;\n\t\t\tif (err!=Z_OK) \n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (err==Z_OK)\n\t\treturn iRead;\n\treturn err;\n}\n\n\n/*\n  Give the current position in uncompressed data\n*/\nextern long unztell (unzFile file)\n{\n\tunz_s* s;\n\tfile_in_zip_read_info_s* pfile_in_zip_read_info;\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n    pfile_in_zip_read_info=s->pfile_in_zip_read;\n\n\tif (pfile_in_zip_read_info==NULL)\n\t\treturn UNZ_PARAMERROR;\n\n\treturn (long)pfile_in_zip_read_info->stream.total_out;\n}\n\n\n/*\n  return 1 if the end of file was reached, 0 elsewhere \n*/\nextern int unzeof (unzFile file)\n{\n\tunz_s* s;\n\tfile_in_zip_read_info_s* pfile_in_zip_read_info;\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n    pfile_in_zip_read_info=s->pfile_in_zip_read;\n\n\tif (pfile_in_zip_read_info==NULL)\n\t\treturn UNZ_PARAMERROR;\n\t\n\tif (pfile_in_zip_read_info->rest_read_uncompressed == 0)\n\t\treturn 1;\n\telse\n\t\treturn 0;\n}\n\n\n\n/*\n  Read extra field from the current file (opened by unzOpenCurrentFile)\n  This is the static-header version of the extra field (sometimes, there is\n    more info in the static-header version than in the central-header)\n\n  if buf==NULL, it return the size of the static extra field that can be read\n\n  if buf!=NULL, len is the size of the buffer, the extra header is copied in\n\tbuf.\n  the return value is the number of bytes copied in buf, or (if <0) \n\tthe error code\n*/\nextern int unzGetLocalExtrafield (unzFile file,void *buf,unsigned len)\n{\n\tunz_s* s;\n\tfile_in_zip_read_info_s* pfile_in_zip_read_info;\n\tuInt read_now;\n\tuLong size_to_read;\n\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n    pfile_in_zip_read_info=s->pfile_in_zip_read;\n\n\tif (pfile_in_zip_read_info==NULL)\n\t\treturn UNZ_PARAMERROR;\n\n\tsize_to_read = (pfile_in_zip_read_info->size_local_extrafield - \n\t\t\t\tpfile_in_zip_read_info->pos_local_extrafield);\n\n\tif (buf==NULL)\n\t\treturn (int)size_to_read;\n\t\n\tif (len>size_to_read)\n\t\tread_now = (uInt)size_to_read;\n\telse\n\t\tread_now = (uInt)len ;\n\n\tif (read_now==0)\n\t\treturn 0;\n\t\n\tif (fseek(pfile_in_zip_read_info->file,\n              pfile_in_zip_read_info->offset_local_extrafield + \n\t\t\t  pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0)\n\t\treturn UNZ_ERRNO;\n\n\tif (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1)\n\t\treturn UNZ_ERRNO;\n\n\treturn (int)read_now;\n}\n\n/*\n  Close the file in zip opened with unzipOpenCurrentFile\n  Return UNZ_CRCERROR if all the file was read but the CRC is not good\n*/\nextern int unzCloseCurrentFile (unzFile file)\n{\n\tint err=UNZ_OK;\n\n\tunz_s* s;\n\tfile_in_zip_read_info_s* pfile_in_zip_read_info;\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n    pfile_in_zip_read_info=s->pfile_in_zip_read;\n\n\tif (pfile_in_zip_read_info==NULL)\n\t\treturn UNZ_PARAMERROR;\n\n\n\tif (pfile_in_zip_read_info->rest_read_uncompressed == 0)\n\t{\n\t\tif (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)\n\t\t\terr=UNZ_CRCERROR;\n\t}\n\n\n\tfree(pfile_in_zip_read_info->read_buffer);\n\tpfile_in_zip_read_info->read_buffer = NULL;\n\tif (pfile_in_zip_read_info->stream_initialised)\n\t\tinflateEnd(&pfile_in_zip_read_info->stream);\n\n\tpfile_in_zip_read_info->stream_initialised = 0;\n\tfree(pfile_in_zip_read_info);\n\n    s->pfile_in_zip_read=NULL;\n\n\treturn err;\n}\n\n\n/*\n  Get the global comment string of the ZipFile, in the szComment buffer.\n  uSizeBuf is the size of the szComment buffer.\n  return the number of byte copied or an error code <0\n*/\nextern int unzGetGlobalComment (unzFile file, char *szComment, uLong uSizeBuf)\n{\n\tunz_s* s;\n\tuLong uReadThis ;\n\tif (file==NULL)\n\t\treturn UNZ_PARAMERROR;\n\ts=(unz_s*)file;\n\n\tuReadThis = uSizeBuf;\n\tif (uReadThis>s->gi.size_comment)\n\t\tuReadThis = s->gi.size_comment;\n\n\tif (fseek(s->file,s->central_pos+22,SEEK_SET)!=0)\n\t\treturn UNZ_ERRNO;\n\n\tif (uReadThis>0)\n    {\n      *szComment='\\0';\n\t  if (fread(szComment,(uInt)uReadThis,1,s->file)!=1)\n\t\treturn UNZ_ERRNO;\n    }\n\n\tif ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))\n\t\t*(szComment+s->gi.size_comment)='\\0';\n\treturn (int)uReadThis;\n}\n\n/* crc32.c -- compute the CRC-32 of a data stream\n * Copyright (C) 1995-1998 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h \n */\n\n/* @(#) $Id: unzip.cpp,v 1.1.1.3 2000/01/11 16:37:27 ttimo Exp $ */\n\n#ifdef DYNAMIC_CRC_TABLE\n\nstatic int crc_table_empty = 1;\nstatic uLong crc_table[256];\nstatic void make_crc_table OF((void));\n\n/*\n  Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:\n  x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.\n\n  Polynomials over GF(2) are represented in binary, one bit per coefficient,\n  with the lowest powers in the most significant bit.  Then adding polynomials\n  is just exclusive-or, and multiplying a polynomial by x is a right shift by\n  one.  If we call the above polynomial p, and represent a byte as the\n  polynomial q, also with the lowest power in the most significant bit (so the\n  byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,\n  where a mod b means the remainder after dividing a by b.\n\n  This calculation is done using the shift-register method of multiplying and\n  taking the remainder.  The register is initialized to zero, and for each\n  incoming bit, x^32 is added mod p to the register if the bit is a one (where\n  x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by\n  x (which is shifting right by one and adding x^32 mod p if the bit shifted\n  out is a one).  We start with the highest power (least significant bit) of\n  q and repeat for all eight bits of q.\n\n  The table is simply the CRC of all possible eight bit values.  This is all\n  the information needed to generate CRC's on data a byte at a time for all\n  combinations of CRC register values and incoming bytes.\n*/\nstatic void make_crc_table()\n{\n  uLong c;\n  int n, k;\n  uLong poly;            /* polynomial exclusive-or pattern */\n  /* terms of polynomial defining this crc (except x^32): */\n  static const Byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};\n\n  /* make exclusive-or pattern from polynomial (0xedb88320L) */\n  poly = 0L;\n  for (n = 0; n < sizeof(p)/sizeof(Byte); n++)\n    poly |= 1L << (31 - p[n]);\n \n  for (n = 0; n < 256; n++)\n  {\n    c = (uLong)n;\n    for (k = 0; k < 8; k++)\n      c = c & 1 ? poly ^ (c >> 1) : c >> 1;\n    crc_table[n] = c;\n  }\n  crc_table_empty = 0;\n}\n#else\n/* ========================================================================\n * Table of CRC-32's of all single-byte values (made by make_crc_table)\n */\nstatic const uLong crc_table[256] = {\n  0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,\n  0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,\n  0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,\n  0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,\n  0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,\n  0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,\n  0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,\n  0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,\n  0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,\n  0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,\n  0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,\n  0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,\n  0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,\n  0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,\n  0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,\n  0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,\n  0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,\n  0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,\n  0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,\n  0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,\n  0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,\n  0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,\n  0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,\n  0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,\n  0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,\n  0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,\n  0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,\n  0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,\n  0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,\n  0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,\n  0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,\n  0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,\n  0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,\n  0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,\n  0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,\n  0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,\n  0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,\n  0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,\n  0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,\n  0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,\n  0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,\n  0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,\n  0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,\n  0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,\n  0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,\n  0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,\n  0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,\n  0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,\n  0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,\n  0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,\n  0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,\n  0x2d02ef8dL\n};\n#endif\n\n/* =========================================================================\n * This function can be used by asm versions of crc32()\n */\nconst uLong * get_crc_table()\n{\n#ifdef DYNAMIC_CRC_TABLE\n  if (crc_table_empty) make_crc_table();\n#endif\n  return (const uLong *)crc_table;\n}\n\n/* ========================================================================= */\n#define DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);\n#define DO2(buf)  DO1(buf); DO1(buf);\n#define DO4(buf)  DO2(buf); DO2(buf);\n#define DO8(buf)  DO4(buf); DO4(buf);\n\n/* ========================================================================= */\nuLong crc32(uLong crc, const Byte *buf, uInt len)\n{\n    if (buf == Z_NULL) return 0L;\n#ifdef DYNAMIC_CRC_TABLE\n    if (crc_table_empty)\n      make_crc_table();\n#endif\n    crc = crc ^ 0xffffffffL;\n    while (len >= 8)\n    {\n      DO8(buf);\n      len -= 8;\n    }\n    if (len) do {\n      DO1(buf);\n    } while (--len);\n    return crc ^ 0xffffffffL;\n}\n\n/* infblock.h -- header to use infblock.c\n * Copyright (C) 1995-1998 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h \n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\nstruct inflate_blocks_state;\ntypedef struct inflate_blocks_state inflate_blocks_statef;\n\nextern inflate_blocks_statef * inflate_blocks_new OF((\n    z_streamp z,\n    check_func c,               /* check function */\n    uInt w));                   /* window size */\n\nextern int inflate_blocks OF((\n    inflate_blocks_statef *,\n    z_streamp ,\n    int));                      /* initial return code */\n\nextern void inflate_blocks_reset OF((\n    inflate_blocks_statef *,\n    z_streamp ,\n    uLong *));                  /* check value on output */\n\nextern int inflate_blocks_free OF((\n    inflate_blocks_statef *,\n    z_streamp));\n\nextern void inflate_set_dictionary OF((\n    inflate_blocks_statef *s,\n    const Byte *d,  /* dictionary */\n    uInt  n));       /* dictionary length */\n\nextern int inflate_blocks_sync_point OF((\n    inflate_blocks_statef *s));\n\n/* simplify the use of the inflate_huft type with some defines */\n#define exop word.what.Exop\n#define bits word.what.Bits\n\n/* Table for deflate from PKZIP's appnote.txt. */\nstatic const uInt border[] = { /* Order of the bit length code lengths */\n        16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};\n\n/* inftrees.h -- header to use inftrees.c\n * Copyright (C) 1995-1998 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h \n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\n/* Huffman code lookup table entry--this entry is four bytes for machines\n   that have 16-bit pointers (e.g. PC's in the small or medium model). */\n\ntypedef struct inflate_huft_s inflate_huft;\n\nstruct inflate_huft_s {\n  union {\n    struct {\n      Byte Exop;        /* number of extra bits or operation */\n      Byte Bits;        /* number of bits in this code or subcode */\n    } what;\n    uInt pad;           /* pad structure to a power of 2 (4 bytes for */\n  } word;               /*  16-bit, 8 bytes for 32-bit int's) */\n  uInt base;            /* literal, length base, distance base,\n                           or table offset */\n};\n\n/* Maximum size of dynamic tree.  The maximum found in a long but non-\n   exhaustive search was 1004 huft structures (850 for length/literals\n   and 154 for distances, the latter actually the result of an\n   exhaustive search).  The actual maximum is not known, but the\n   value below is more than safe. */\n#define MANY 1440\n\nextern int inflate_trees_bits OF((\n    uInt *,                    /* 19 code lengths */\n    uInt *,                    /* bits tree desired/actual depth */\n    inflate_huft * *,       /* bits tree result */\n    inflate_huft *,             /* space for trees */\n    z_streamp));                /* for messages */\n\nextern int inflate_trees_dynamic OF((\n    uInt,                       /* number of literal/length codes */\n    uInt,                       /* number of distance codes */\n    uInt *,                    /* that many (total) code lengths */\n    uInt *,                    /* literal desired/actual bit depth */\n    uInt *,                    /* distance desired/actual bit depth */\n    inflate_huft * *,       /* literal/length tree result */\n    inflate_huft * *,       /* distance tree result */\n    inflate_huft *,             /* space for trees */\n    z_streamp));                /* for messages */\n\nextern int inflate_trees_fixed OF((\n    uInt *,                    /* literal desired/actual bit depth */\n    uInt *,                    /* distance desired/actual bit depth */\n    inflate_huft * *,       /* literal/length tree result */\n    inflate_huft * *,       /* distance tree result */\n    z_streamp));                /* for memory allocation */\n\n\n/* infcodes.h -- header to use infcodes.c\n * Copyright (C) 1995-1998 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h \n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\nstruct inflate_codes_state;\ntypedef struct inflate_codes_state inflate_codes_statef;\n\nextern inflate_codes_statef *inflate_codes_new OF((\n    uInt, uInt,\n    inflate_huft *, inflate_huft *,\n    z_streamp ));\n\nextern int inflate_codes OF((\n    inflate_blocks_statef *,\n    z_streamp ,\n    int));\n\nextern void inflate_codes_free OF((\n    inflate_codes_statef *,\n    z_streamp ));\n\n/* infutil.h -- types and macros common to blocks and codes\n * Copyright (C) 1995-1998 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h \n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\n#ifndef _INFUTIL_H\n#define _INFUTIL_H\n\ntypedef enum {\n      TYPE,     /* get type bits (3, including end bit) */\n      LENS,     /* get lengths for stored */\n      STORED,   /* processing stored block */\n      TABLE,    /* get table lengths */\n      BTREE,    /* get bit lengths tree for a dynamic block */\n      DTREE,    /* get length, distance trees for a dynamic block */\n      CODES,    /* processing fixed or dynamic block */\n      DRY,      /* output remaining window bytes */\n      DONE,     /* finished last block, done */\n      BAD}      /* got a data error--stuck here */\ninflate_block_mode;\n\n/* inflate blocks semi-private state */\nstruct inflate_blocks_state {\n\n  /* mode */\n  inflate_block_mode  mode;     /* current inflate_block mode */\n\n  /* mode dependent information */\n  union {\n    uInt left;          /* if STORED, bytes left to copy */\n    struct {\n      uInt table;               /* table lengths (14 bits) */\n      uInt index;               /* index into blens (or border) */\n      uInt *blens;             /* bit lengths of codes */\n      uInt bb;                  /* bit length tree depth */\n      inflate_huft *tb;         /* bit length decoding tree */\n    } trees;            /* if DTREE, decoding info for trees */\n    struct {\n      inflate_codes_statef \n         *codes;\n    } decode;           /* if CODES, current state */\n  } sub;                /* submode */\n  uInt last;            /* true if this block is the last block */\n\n  /* mode independent information */\n  uInt bitk;            /* bits in bit buffer */\n  uLong bitb;           /* bit buffer */\n  inflate_huft *hufts;  /* single malloc for tree space */\n  Byte *window;        /* sliding window */\n  Byte *end;           /* one byte after sliding window */\n  Byte *read;          /* window read pointer */\n  Byte *write;         /* window write pointer */\n  check_func checkfn;   /* check function */\n  uLong check;          /* check on output */\n\n};\n\n\n/* defines for inflate input/output */\n/*   update pointers and return */\n#define UPDBITS {s->bitb=b;s->bitk=k;}\n#define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;}\n#define UPDOUT {s->write=q;}\n#define UPDATE {UPDBITS UPDIN UPDOUT}\n#define LEAVE {UPDATE return inflate_flush(s,z,r);}\n/*   get bytes and bits */\n#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}\n#define NEEDBYTE {if(n)r=Z_OK;else LEAVE}\n#define NEXTBYTE (n--,*p++)\n#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}}\n#define DUMPBITS(j) {b>>=(j);k-=(j);}\n/*   output bytes */\n#define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q)\n#define LOADOUT {q=s->write;m=(uInt)WAVAIL;}\n#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}}\n#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT}\n#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;}\n#define OUTBYTE(a) {*q++=(Byte)(a);m--;}\n/*   load static pointers */\n#define LOAD {LOADIN LOADOUT}\n\n/* masks for lower bits (size given to avoid silly warnings with Visual C++) */\nextern uInt inflate_mask[17];\n\n/* copy as much as possible from the sliding window to the output area */\nextern int inflate_flush OF((\n    inflate_blocks_statef *,\n    z_streamp ,\n    int));\n\n#endif\n\n\t\t\t\t\t\t\t\t\n/*\n   Notes beyond the 1.93a appnote.txt:\n\n   1. Distance pointers never point before the beginning of the output\n      stream.\n   2. Distance pointers can point back across blocks, up to 32k away.\n   3. There is an implied maximum of 7 bits for the bit length table and\n      15 bits for the actual data.\n   4. If only one code exists, then it is encoded using one bit.  (Zero\n      would be more efficient, but perhaps a little confusing.)  If two\n      codes exist, they are coded using one bit each (0 and 1).\n   5. There is no way of sending zero distance codes--a dummy must be\n      sent if there are none.  (History: a pre 2.0 version of PKZIP would\n      store blocks with no distance codes, but this was discovered to be\n      too harsh a criterion.)  Valid only for 1.93a.  2.04c does allow\n      zero distance codes, which is sent as one code of zero bits in\n      length.\n   6. There are up to 286 literal/length codes.  Code 256 represents the\n      end-of-block.  Note however that the static length tree defines\n      288 codes just to fill out the Huffman codes.  Codes 286 and 287\n      cannot be used though, since there is no length base or extra bits\n      defined for them.  Similarily, there are up to 30 distance codes.\n      However, static trees define 32 codes (all 5 bits) to fill out the\n      Huffman codes, but the last two had better not show up in the data.\n   7. Unzip can check dynamic Huffman blocks for complete code sets.\n      The exception is that a single code would not be complete (see #4).\n   8. The five bits following the block type is really the number of\n      literal codes sent minus 257.\n   9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits\n      (1+6+6).  Therefore, to output three times the length, you output\n      three codes (1+1+1), whereas to output four times the same length,\n      you only need two codes (1+3).  Hmm.\n  10. In the tree reconstruction algorithm, Code = Code + Increment\n      only if BitLength(i) is not zero.  (Pretty obvious.)\n  11. Correction: 4 Bits: # of Bit Length codes - 4     (4 - 19)\n  12. Note: length code 284 can represent 227-258, but length code 285\n      really is 258.  The last length deserves its own, short code\n      since it gets used a lot in very redundant files.  The length\n      258 is special since 258 - 3 (the min match length) is 255.\n  13. The literal/length and distance code bit lengths are read as a\n      single stream of lengths.  It is possible (and advantageous) for\n      a repeat code (16, 17, or 18) to go across the boundary between\n      the two sets of lengths.\n */\n\n\nvoid inflate_blocks_reset(inflate_blocks_statef *s, z_streamp z, uLong *c)\n{\n  if (c != Z_NULL)\n    *c = s->check;\n  if (s->mode == BTREE || s->mode == DTREE)\n    ZFREE(z, s->sub.trees.blens);\n  if (s->mode == CODES)\n    inflate_codes_free(s->sub.decode.codes, z);\n  s->mode = TYPE;\n  s->bitk = 0;\n  s->bitb = 0;\n  s->read = s->write = s->window;\n  if (s->checkfn != Z_NULL)\n    z->adler = s->check = (*s->checkfn)(0L, (const Byte *)Z_NULL, 0);\n  Tracev((\"inflate:   blocks reset\\n\"));\n}\n\n\ninflate_blocks_statef *inflate_blocks_new(z_streamp z, check_func c, uInt w)\n{\n  inflate_blocks_statef *s;\n\n  if ((s = (inflate_blocks_statef *)ZALLOC\n       (z,1,sizeof(struct inflate_blocks_state))) == Z_NULL)\n    return s;\n  if ((s->hufts =\n       (inflate_huft *)ZALLOC(z, sizeof(inflate_huft), MANY)) == Z_NULL)\n  {\n    ZFREE(z, s);\n    return Z_NULL;\n  }\n  if ((s->window = (Byte *)ZALLOC(z, 1, w)) == Z_NULL)\n  {\n    ZFREE(z, s->hufts);\n    ZFREE(z, s);\n    return Z_NULL;\n  }\n  s->end = s->window + w;\n  s->checkfn = c;\n  s->mode = TYPE;\n  Tracev((\"inflate:   blocks allocated\\n\"));\n  inflate_blocks_reset(s, z, Z_NULL);\n  return s;\n}\n\n\nint inflate_blocks(inflate_blocks_statef *s, z_streamp z, int r)\n{\n  uInt t;               /* temporary storage */\n  uLong b;              /* bit buffer */\n  uInt k;               /* bits in bit buffer */\n  Byte *p;             /* input data pointer */\n  uInt n;               /* bytes available there */\n  Byte *q;             /* output window write pointer */\n  uInt m;               /* bytes to end of window or read pointer */\n\n  /* copy input/output information to locals (UPDATE macro restores) */\n  LOAD\n\n  /* process input based on current state */\n  while (1) switch (s->mode)\n  {\n    case TYPE:\n      NEEDBITS(3)\n      t = (uInt)b & 7;\n      s->last = t & 1;\n      switch (t >> 1)\n      {\n        case 0:                         /* stored */\n          Tracev((\"inflate:     stored block%s\\n\",\n                 s->last ? \" (last)\" : \"\"));\n          DUMPBITS(3)\n          t = k & 7;                    /* go to byte boundary */\n          DUMPBITS(t)\n          s->mode = LENS;               /* get length of stored block */\n          break;\n        case 1:                         /* fixed */\n          Tracev((\"inflate:     fixed codes block%s\\n\",\n                 s->last ? \" (last)\" : \"\"));\n          {\n            uInt bl, bd;\n            inflate_huft *tl, *td;\n\n            inflate_trees_fixed(&bl, &bd, &tl, &td, z);\n            s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z);\n            if (s->sub.decode.codes == Z_NULL)\n            {\n              r = Z_MEM_ERROR;\n              LEAVE\n            }\n          }\n          DUMPBITS(3)\n          s->mode = CODES;\n          break;\n        case 2:                         /* dynamic */\n          Tracev((\"inflate:     dynamic codes block%s\\n\",\n                 s->last ? \" (last)\" : \"\"));\n          DUMPBITS(3)\n          s->mode = TABLE;\n          break;\n        case 3:                         /* illegal */\n          DUMPBITS(3)\n          s->mode = BAD;\n          z->msg = (char*)\"invalid block type\";\n          r = Z_DATA_ERROR;\n          LEAVE\n      }\n      break;\n    case LENS:\n      NEEDBITS(32)\n      if ((((~b) >> 16) & 0xffff) != (b & 0xffff))\n      {\n        s->mode = BAD;\n        z->msg = (char*)\"invalid stored block lengths\";\n        r = Z_DATA_ERROR;\n        LEAVE\n      }\n      s->sub.left = (uInt)b & 0xffff;\n      b = k = 0;                      /* dump bits */\n      Tracev((\"inflate:       stored length %u\\n\", s->sub.left));\n      s->mode = s->sub.left ? STORED : (s->last ? DRY : TYPE);\n      break;\n    case STORED:\n      if (n == 0)\n        LEAVE\n      NEEDOUT\n      t = s->sub.left;\n      if (t > n) t = n;\n      if (t > m) t = m;\n      zmemcpy(q, p, t);\n      p += t;  n -= t;\n      q += t;  m -= t;\n      if ((s->sub.left -= t) != 0)\n        break;\n      Tracev((\"inflate:       stored end, %lu total out\\n\",\n              z->total_out + (q >= s->read ? q - s->read :\n              (s->end - s->read) + (q - s->window))));\n      s->mode = s->last ? DRY : TYPE;\n      break;\n    case TABLE:\n      NEEDBITS(14)\n      s->sub.trees.table = t = (uInt)b & 0x3fff;\n#ifndef PKZIP_BUG_WORKAROUND\n      if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)\n      {\n        s->mode = BAD;\n        z->msg = (char*)\"too many length or distance symbols\";\n        r = Z_DATA_ERROR;\n        LEAVE\n      }\n#endif\n      t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f);\n      if ((s->sub.trees.blens = (uInt*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL)\n      {\n        r = Z_MEM_ERROR;\n        LEAVE\n      }\n      DUMPBITS(14)\n      s->sub.trees.index = 0;\n      Tracev((\"inflate:       table sizes ok\\n\"));\n      s->mode = BTREE;\n    case BTREE:\n      while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10))\n      {\n        NEEDBITS(3)\n        s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7;\n        DUMPBITS(3)\n      }\n      while (s->sub.trees.index < 19)\n        s->sub.trees.blens[border[s->sub.trees.index++]] = 0;\n      s->sub.trees.bb = 7;\n      t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb,\n                             &s->sub.trees.tb, s->hufts, z);\n      if (t != Z_OK)\n      {\n        ZFREE(z, s->sub.trees.blens);\n        r = t;\n        if (r == Z_DATA_ERROR)\n          s->mode = BAD;\n        LEAVE\n      }\n      s->sub.trees.index = 0;\n      Tracev((\"inflate:       bits tree ok\\n\"));\n      s->mode = DTREE;\n    case DTREE:\n      while (t = s->sub.trees.table,\n             s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))\n      {\n        inflate_huft *h;\n        uInt i, j, c;\n\n        t = s->sub.trees.bb;\n        NEEDBITS(t)\n        h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]);\n        t = h->bits;\n        c = h->base;\n        if (c < 16)\n        {\n          DUMPBITS(t)\n          s->sub.trees.blens[s->sub.trees.index++] = c;\n        }\n        else /* c == 16..18 */\n        {\n          i = c == 18 ? 7 : c - 14;\n          j = c == 18 ? 11 : 3;\n          NEEDBITS(t + i)\n          DUMPBITS(t)\n          j += (uInt)b & inflate_mask[i];\n          DUMPBITS(i)\n          i = s->sub.trees.index;\n          t = s->sub.trees.table;\n          if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||\n              (c == 16 && i < 1))\n          {\n            ZFREE(z, s->sub.trees.blens);\n            s->mode = BAD;\n            z->msg = (char*)\"invalid bit length repeat\";\n            r = Z_DATA_ERROR;\n            LEAVE\n          }\n          c = c == 16 ? s->sub.trees.blens[i - 1] : 0;\n          do {\n            s->sub.trees.blens[i++] = c;\n          } while (--j);\n          s->sub.trees.index = i;\n        }\n      }\n      s->sub.trees.tb = Z_NULL;\n      {\n        uInt bl, bd;\n        inflate_huft *tl, *td;\n        inflate_codes_statef *c;\n\n        bl = 9;         /* must be <= 9 for lookahead assumptions */\n        bd = 6;         /* must be <= 9 for lookahead assumptions */\n        t = s->sub.trees.table;\n        t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f),\n                                  s->sub.trees.blens, &bl, &bd, &tl, &td,\n                                  s->hufts, z);\n        ZFREE(z, s->sub.trees.blens);\n        if (t != Z_OK)\n        {\n          if (t == (uInt)Z_DATA_ERROR)\n            s->mode = BAD;\n          r = t;\n          LEAVE\n        }\n        Tracev((\"inflate:       trees ok\\n\"));\n        if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL)\n        {\n          r = Z_MEM_ERROR;\n          LEAVE\n        }\n        s->sub.decode.codes = c;\n      }\n      s->mode = CODES;\n    case CODES:\n      UPDATE\n      if ((r = inflate_codes(s, z, r)) != Z_STREAM_END)\n        return inflate_flush(s, z, r);\n      r = Z_OK;\n      inflate_codes_free(s->sub.decode.codes, z);\n      LOAD\n      Tracev((\"inflate:       codes end, %lu total out\\n\",\n              z->total_out + (q >= s->read ? q - s->read :\n              (s->end - s->read) + (q - s->window))));\n      if (!s->last)\n      {\n        s->mode = TYPE;\n        break;\n      }\n      s->mode = DRY;\n    case DRY:\n      FLUSH\n      if (s->read != s->write)\n        LEAVE\n      s->mode = DONE;\n    case DONE:\n      r = Z_STREAM_END;\n      LEAVE\n    case BAD:\n      r = Z_DATA_ERROR;\n      LEAVE\n    default:\n      r = Z_STREAM_ERROR;\n      LEAVE\n  }\n}\n\n\nint inflate_blocks_free(inflate_blocks_statef *s, z_streamp z)\n{\n  inflate_blocks_reset(s, z, Z_NULL);\n  ZFREE(z, s->window);\n  ZFREE(z, s->hufts);\n  ZFREE(z, s);\n  Tracev((\"inflate:   blocks freed\\n\"));\n  return Z_OK;\n}\n\n\nvoid inflate_set_dictionary(inflate_blocks_statef *s, const Byte *d, uInt n)\n{\n  zmemcpy(s->window, d, n);\n  s->read = s->write = s->window + n;\n}\n\n\n/* Returns true if inflate is currently at the end of a block generated\n * by Z_SYNC_FLUSH or Z_FULL_FLUSH. \n * IN assertion: s != Z_NULL\n */\nint inflate_blocks_sync_point(inflate_blocks_statef *s)\n{\n  return s->mode == LENS;\n}\n\n\n/* And'ing with mask[n] masks the lower n bits */\nuInt inflate_mask[17] = {\n    0x0000,\n    0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,\n    0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff\n};\n\n\n/* copy as much as possible from the sliding window to the output area */\nint inflate_flush(inflate_blocks_statef *s, z_streamp z, int r)\n{\n  uInt n;\n  Byte *p;\n  Byte *q;\n\n  /* static copies of source and destination pointers */\n  p = z->next_out;\n  q = s->read;\n\n  /* compute number of bytes to copy as as end of window */\n  n = (uInt)((q <= s->write ? s->write : s->end) - q);\n  if (n > z->avail_out) n = z->avail_out;\n  if (n && r == Z_BUF_ERROR) r = Z_OK;\n\n  /* update counters */\n  z->avail_out -= n;\n  z->total_out += n;\n\n  /* update check information */\n  if (s->checkfn != Z_NULL)\n    z->adler = s->check = (*s->checkfn)(s->check, q, n);\n\n  /* copy as as end of window */\n  zmemcpy(p, q, n);\n  p += n;\n  q += n;\n\n  /* see if more to copy at beginning of window */\n  if (q == s->end)\n  {\n    /* wrap pointers */\n    q = s->window;\n    if (s->write == s->end)\n      s->write = s->window;\n\n    /* compute bytes to copy */\n    n = (uInt)(s->write - q);\n    if (n > z->avail_out) n = z->avail_out;\n    if (n && r == Z_BUF_ERROR) r = Z_OK;\n\n    /* update counters */\n    z->avail_out -= n;\n    z->total_out += n;\n\n    /* update check information */\n    if (s->checkfn != Z_NULL)\n      z->adler = s->check = (*s->checkfn)(s->check, q, n);\n\n    /* copy */\n    zmemcpy(p, q, n);\n    p += n;\n    q += n;\n  }\n\n  /* update pointers */\n  z->next_out = p;\n  s->read = q;\n\n  /* done */\n  return r;\n}\n\n/* inftrees.c -- generate Huffman trees for efficient decoding\n * Copyright (C) 1995-1998 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h \n */\n\nconst char inflate_copyright[] =\n   \" inflate 1.1.3 Copyright 1995-1998 Mark Adler \";\n/*\n  If you use the zlib library in a product, an acknowledgment is welcome\n  in the documentation of your product. If for some reason you cannot\n  include such an acknowledgment, I would appreciate that you keep this\n  copyright string in the executable of your product.\n */\n\n/* simplify the use of the inflate_huft type with some defines */\n#define exop word.what.Exop\n#define bits word.what.Bits\n\n\nstatic int huft_build OF((\n    uInt *,\t\t\t\t/* code lengths in bits */\n    uInt,               /* number of codes */\n    uInt,               /* number of \"simple\" codes */\n    const uInt *,\t\t/* list of base values for non-simple codes */\n    const uInt *,\t\t/* list of extra bits for non-simple codes */\n    inflate_huft **,\t/* result: starting table */\n    uInt *,\t\t\t\t/* maximum lookup bits (returns actual) */\n    inflate_huft *,     /* space for trees */\n    uInt *,             /* hufts used in space */\n    uInt * ));\t\t\t/* space for values */\n\n/* Tables for deflate from PKZIP's appnote.txt. */\nstatic const uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */\n        3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n        35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};\n        /* see note #13 above about 258 */\nstatic const uInt cplext[31] = { /* Extra bits for literal codes 257..285 */\n        0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,\n        3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112}; /* 112==invalid */\nstatic const uInt cpdist[30] = { /* Copy offsets for distance codes 0..29 */\n        1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n        257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n        8193, 12289, 16385, 24577};\nstatic const uInt cpdext[30] = { /* Extra bits for distance codes */\n        0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,\n        7, 7, 8, 8, 9, 9, 10, 10, 11, 11,\n        12, 12, 13, 13};\n\n/*\n   Huffman code decoding is performed using a multi-level table lookup.\n   The fastest way to decode is to simply build a lookup table whose\n   size is determined by the longest code.  However, the time it takes\n   to build this table can also be a factor if the data being decoded\n   is not very long.  The most common codes are necessarily the\n   shortest codes, so those codes dominate the decoding time, and hence\n   the speed.  The idea is you can have a shorter table that decodes the\n   shorter, more probable codes, and then point to subsidiary tables for\n   the longer codes.  The time it costs to decode the longer codes is\n   then traded against the time it takes to make longer tables.\n\n   This results of this trade are in the variables lbits and dbits\n   below.  lbits is the number of bits the first level table for literal/\n   length codes can decode in one step, and dbits is the same thing for\n   the distance codes.  Subsequent tables are also less than or equal to\n   those sizes.  These values may be adjusted either when all of the\n   codes are shorter than that, in which case the longest code length in\n   bits is used, or when the shortest code is *longer* than the requested\n   table size, in which case the length of the shortest code in bits is\n   used.\n\n   There are two different values for the two tables, since they code a\n   different number of possibilities each.  The literal/length table\n   codes 286 possible values, or in a flat code, a little over eight\n   bits.  The distance table codes 30 possible values, or a little less\n   than five bits, flat.  The optimum values for speed end up being\n   about one bit more than those, so lbits is 8+1 and dbits is 5+1.\n   The optimum values may differ though from machine to machine, and\n   possibly even between compilers.  Your mileage may vary.\n */\n\n\n/* If BMAX needs to be larger than 16, then h and x[] should be uLong. */\n#define BMAX 15         /* maximum bit length of any code */\n\nstatic int huft_build(uInt *b, uInt n, uInt s, const uInt *d, const uInt *e, inflate_huft ** t, uInt *m, inflate_huft *hp, uInt *hn, uInt *v)\n//uInt *b;               /* code lengths in bits (all assumed <= BMAX) */\n//uInt n;                 /* number of codes (assumed <= 288) */\n//uInt s;                 /* number of simple-valued codes (0..s-1) */\n//const uInt *d;         /* list of base values for non-simple codes */\n//const uInt *e;         /* list of extra bits for non-simple codes */\n//inflate_huft ** t;\t\t/* result: starting table */\n//uInt *m;               /* maximum lookup bits, returns actual */\n//inflate_huft *hp;       /* space for trees */\n//uInt *hn;               /* hufts used in space */\n//uInt *v;               /* working area: values in order of bit length */\n/* Given a list of code lengths and a maximum table size, make a set of\n   tables to decode that set of codes.  Return Z_OK on success, Z_BUF_ERROR\n   if the given code set is incomplete (the tables are still built in this\n   case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of\n   lengths), or Z_MEM_ERROR if not enough memory. */\n{\n\n  uInt a;                       /* counter for codes of length k */\n  uInt c[BMAX+1];               /* bit length count table */\n  uInt f;                       /* i repeats in table every f entries */\n  int g;                        /* maximum code length */\n  int h;                        /* table level */\n  register uInt i;              /* counter, current code */\n  register uInt j;              /* counter */\n  register int k;               /* number of bits in current code */\n  int l;                        /* bits per table (returned in m) */\n  uInt mask;                    /* (1 << w) - 1, to avoid cc -O bug on HP */\n  register uInt *p;            /* pointer into c[], b[], or v[] */\n  inflate_huft *q;              /* points to current table */\n  struct inflate_huft_s r;      /* table entry for structure assignment */\n  inflate_huft *u[BMAX];        /* table stack */\n  register int w;               /* bits before this table == (l * h) */\n  uInt x[BMAX+1];               /* bit offsets, then code stack */\n  uInt *xp;                    /* pointer into x */\n  int y;                        /* number of dummy codes added */\n  uInt z;                       /* number of entries in current table */\n\n\n  /* Generate counts for each bit length */\n  p = c;\n#define C0 *p++ = 0;\n#define C2 C0 C0 C0 C0\n#define C4 C2 C2 C2 C2\n  C4                            /* clear c[]--assume BMAX+1 is 16 */\n  p = b;  i = n;\n  do {\n    c[*p++]++;                  /* assume all entries <= BMAX */\n  } while (--i);\n  if (c[0] == n)                /* null input--all zero length codes */\n  {\n    *t = (inflate_huft *)Z_NULL;\n    *m = 0;\n    return Z_OK;\n  }\n\n\n  /* Find minimum and maximum length, bound *m by those */\n  l = *m;\n  for (j = 1; j <= BMAX; j++)\n    if (c[j])\n      break;\n  k = j;                        /* minimum code length */\n  if ((uInt)l < j)\n    l = j;\n  for (i = BMAX; i; i--)\n    if (c[i])\n      break;\n  g = i;                        /* maximum code length */\n  if ((uInt)l > i)\n    l = i;\n  *m = l;\n\n\n  /* Adjust last length count to fill out codes, if needed */\n  for (y = 1 << j; j < i; j++, y <<= 1)\n    if ((y -= c[j]) < 0)\n      return Z_DATA_ERROR;\n  if ((y -= c[i]) < 0)\n    return Z_DATA_ERROR;\n  c[i] += y;\n\n\n  /* Generate starting offsets into the value table for each length */\n  x[1] = j = 0;\n  p = c + 1;  xp = x + 2;\n  while (--i) {                 /* note that i == g from above */\n    *xp++ = (j += *p++);\n  }\n\n\n  /* Make a table of values in order of bit lengths */\n  p = b;  i = 0;\n  do {\n    if ((j = *p++) != 0)\n      v[x[j]++] = i;\n  } while (++i < n);\n  n = x[g];                     /* set n to length of v */\n\n\n  /* Generate the Huffman codes and for each, make the table entries */\n  x[0] = i = 0;                 /* first Huffman code is zero */\n  p = v;                        /* grab values in bit order */\n  h = -1;                       /* no tables yet--level -1 */\n  w = -l;                       /* bits decoded == (l * h) */\n  u[0] = (inflate_huft *)Z_NULL;        /* just to keep compilers happy */\n  q = (inflate_huft *)Z_NULL;   /* ditto */\n  z = 0;                        /* ditto */\n\n  /* go through the bit lengths (k already is bits in shortest code) */\n  for (; k <= g; k++)\n  {\n    a = c[k];\n    while (a--)\n    {\n      /* here i is the Huffman code of length k bits for value *p */\n      /* make tables up to required level */\n      while (k > w + l)\n      {\n        h++;\n        w += l;                 /* previous table always l bits */\n\n        /* compute minimum size table less than or equal to l bits */\n        z = g - w;\n        z = z > (uInt)l ? l : z;        /* table size upper limit */\n        if ((f = 1 << (j = k - w)) > a + 1)     /* try a k-w bit table */\n        {                       /* too few codes for k-w bit table */\n          f -= a + 1;           /* deduct codes from patterns left */\n          xp = c + k;\n          if (j < z)\n            while (++j < z)     /* try smaller tables up to z bits */\n            {\n              if ((f <<= 1) <= *++xp)\n                break;          /* enough codes to use up j bits */\n              f -= *xp;         /* else deduct codes from patterns */\n            }\n        }\n        z = 1 << j;             /* table entries for j-bit table */\n\n        /* allocate new table */\n        if (*hn + z > MANY)     /* (note: doesn't matter for fixed) */\n          return Z_MEM_ERROR;   /* not enough memory */\n        u[h] = q = hp + *hn;\n        *hn += z;\n\n        /* connect to last table, if there is one */\n        if (h)\n        {\n          x[h] = i;             /* save pattern for backing up */\n          r.bits = (Byte)l;     /* bits to dump before this table */\n          r.exop = (Byte)j;     /* bits in this table */\n          j = i >> (w - l);\n          r.base = (uInt)(q - u[h-1] - j);   /* offset to this table */\n          u[h-1][j] = r;        /* connect to last table */\n        }\n        else\n          *t = q;               /* first table is returned result */\n      }\n\n      /* set up table entry in r */\n      r.bits = (Byte)(k - w);\n      if (p >= v + n)\n        r.exop = 128 + 64;      /* out of values--invalid code */\n      else if (*p < s)\n      {\n        r.exop = (Byte)(*p < 256 ? 0 : 32 + 64);     /* 256 is end-of-block */\n        r.base = *p++;          /* simple code is just the value */\n      }\n      else\n      {\n        r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */\n        r.base = d[*p++ - s];\n      }\n\n      /* fill code-like entries with r */\n      f = 1 << (k - w);\n      for (j = i >> w; j < z; j += f)\n        q[j] = r;\n\n      /* backwards increment the k-bit code i */\n      for (j = 1 << (k - 1); i & j; j >>= 1)\n        i ^= j;\n      i ^= j;\n\n      /* backup over finished tables */\n      mask = (1 << w) - 1;      /* needed on HP, cc -O bug */\n      while ((i & mask) != x[h])\n      {\n        h--;                    /* don't need to update q */\n        w -= l;\n        mask = (1 << w) - 1;\n      }\n    }\n  }\n\n\n  /* Return Z_BUF_ERROR if we were given an incomplete table */\n  return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK;\n}\n\n\nint inflate_trees_bits(uInt *c, uInt *bb, inflate_huft * *tb, inflate_huft *hp, z_streamp z)\n//uInt *c;               /* 19 code lengths */\n//uInt *bb;              /* bits tree desired/actual depth */\n//inflate_huft * *tb; /* bits tree result */\n//inflate_huft *hp;       /* space for trees */\n//z_streamp z;            /* for messages */\n{\n  int r;\n  uInt hn = 0;          /* hufts used in space */\n  uInt *v;             /* work area for huft_build */\n\n  if ((v = (uInt*)ZALLOC(z, 19, sizeof(uInt))) == Z_NULL)\n    return Z_MEM_ERROR;\n  r = huft_build(c, 19, 19, (uInt*)Z_NULL, (uInt*)Z_NULL,\n                 tb, bb, hp, &hn, v);\n  if (r == Z_DATA_ERROR)\n    z->msg = (char*)\"oversubscribed dynamic bit lengths tree\";\n  else if (r == Z_BUF_ERROR || *bb == 0)\n  {\n    z->msg = (char*)\"incomplete dynamic bit lengths tree\";\n    r = Z_DATA_ERROR;\n  }\n  ZFREE(z, v);\n  return r;\n}\n\n\nint inflate_trees_dynamic(uInt nl, uInt nd, uInt *c, uInt *bl, uInt *bd, inflate_huft * *tl, inflate_huft * *td, inflate_huft *hp, z_streamp z)\n//uInt nl;                /* number of literal/length codes */\n//uInt nd;                /* number of distance codes */\n//uInt *c;               /* that many (total) code lengths */\n//uInt *bl;              /* literal desired/actual bit depth */\n//uInt *bd;              /* distance desired/actual bit depth */\n//inflate_huft * *tl; /* literal/length tree result */\n//inflate_huft * *td; /* distance tree result */\n//inflate_huft *hp;       /* space for trees */\n//z_streamp z;            /* for messages */\n{\n  int r;\n  uInt hn = 0;          /* hufts used in space */\n  uInt *v;             /* work area for huft_build */\n\n  /* allocate work area */\n  if ((v = (uInt*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)\n    return Z_MEM_ERROR;\n\n  /* build literal/length tree */\n  r = huft_build(c, nl, 257, cplens, cplext, tl, bl, hp, &hn, v);\n  if (r != Z_OK || *bl == 0)\n  {\n    if (r == Z_DATA_ERROR)\n      z->msg = (char*)\"oversubscribed literal/length tree\";\n    else if (r != Z_MEM_ERROR)\n    {\n      z->msg = (char*)\"incomplete literal/length tree\";\n      r = Z_DATA_ERROR;\n    }\n    ZFREE(z, v);\n    return r;\n  }\n\n  /* build distance tree */\n  r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, hp, &hn, v);\n  if (r != Z_OK || (*bd == 0 && nl > 257))\n  {\n    if (r == Z_DATA_ERROR)\n      z->msg = (char*)\"oversubscribed distance tree\";\n    else if (r == Z_BUF_ERROR) {\n#ifdef PKZIP_BUG_WORKAROUND\n      r = Z_OK;\n    }\n#else\n      z->msg = (char*)\"incomplete distance tree\";\n      r = Z_DATA_ERROR;\n    }\n    else if (r != Z_MEM_ERROR)\n    {\n      z->msg = (char*)\"empty distance tree with lengths\";\n      r = Z_DATA_ERROR;\n    }\n    ZFREE(z, v);\n    return r;\n#endif\n  }\n\n  /* done */\n  ZFREE(z, v);\n  return Z_OK;\n}\n\n/* inffixed.h -- table for decoding fixed codes\n * Generated automatically by the maketree.c program\n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\nstatic uInt fixed_bl = 9;\nstatic uInt fixed_bd = 5;\nstatic inflate_huft fixed_tl[] = {\n    {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},\n    {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192},\n    {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160},\n    {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},224},\n    {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},144},\n    {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},208},\n    {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},176},\n    {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},240},\n    {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},\n    {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},200},\n    {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},168},\n    {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},232},\n    {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},152},\n    {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},216},\n    {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},184},\n    {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},248},\n    {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},\n    {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},196},\n    {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},164},\n    {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},228},\n    {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},148},\n    {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},212},\n    {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},180},\n    {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},244},\n    {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},\n    {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},204},\n    {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},172},\n    {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},236},\n    {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},156},\n    {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},220},\n    {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},188},\n    {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},252},\n    {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},\n    {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},194},\n    {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},162},\n    {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},226},\n    {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},146},\n    {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},210},\n    {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},178},\n    {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},242},\n    {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},\n    {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},202},\n    {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},170},\n    {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},234},\n    {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},154},\n    {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},218},\n    {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},186},\n    {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},250},\n    {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},\n    {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},198},\n    {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},166},\n    {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},230},\n    {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},150},\n    {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},214},\n    {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},182},\n    {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},246},\n    {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},\n    {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},206},\n    {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},174},\n    {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},238},\n    {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},158},\n    {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},222},\n    {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},190},\n    {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},254},\n    {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},\n    {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},193},\n    {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},161},\n    {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},225},\n    {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},145},\n    {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},209},\n    {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},177},\n    {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},241},\n    {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},\n    {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},201},\n    {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},169},\n    {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},233},\n    {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},153},\n    {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},217},\n    {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},185},\n    {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},249},\n    {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},\n    {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},197},\n    {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},165},\n    {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},229},\n    {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},149},\n    {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},213},\n    {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},181},\n    {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},245},\n    {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},\n    {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},205},\n    {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},173},\n    {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},237},\n    {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},157},\n    {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},221},\n    {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},189},\n    {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},253},\n    {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},\n    {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},195},\n    {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},163},\n    {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},227},\n    {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},147},\n    {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},211},\n    {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},179},\n    {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},243},\n    {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},\n    {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},203},\n    {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},171},\n    {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},235},\n    {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},155},\n    {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},219},\n    {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},187},\n    {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},251},\n    {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},\n    {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},199},\n    {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},167},\n    {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},231},\n    {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},151},\n    {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},215},\n    {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},183},\n    {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},247},\n    {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},\n    {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},207},\n    {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},175},\n    {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},239},\n    {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},159},\n    {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},223},\n    {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191},\n    {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255}\n  };\nstatic inflate_huft fixed_td[] = {\n    {{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097},\n    {{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385},\n    {{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193},\n    {{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577},\n    {{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145},\n    {{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577},\n    {{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289},\n    {{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577}\n  };\n\nint inflate_trees_fixed(uInt *bl, uInt *bd, inflate_huft * *tl, inflate_huft * *td, z_streamp z)\n//uInt *bl;               /* literal desired/actual bit depth */\n//uInt *bd;               /* distance desired/actual bit depth */\n//inflate_huft * *tl;  /* literal/length tree result */\n//inflate_huft * *td;  /* distance tree result */\n//z_streamp z;             /* for memory allocation */\n{\n  *bl = fixed_bl;\n  *bd = fixed_bd;\n  *tl = fixed_tl;\n  *td = fixed_td;\n  return Z_OK;\n}\n\n/* simplify the use of the inflate_huft type with some defines */\n#define exop word.what.Exop\n#define bits word.what.Bits\n\n/* macros for bit input with no checking and for returning unused bytes */\n#define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}}\n#define UNGRAB {c=z->avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;}\n\n/* Called with number of bytes left to write in window at least 258\n   (the maximum string length) and number of input bytes available\n   at least ten.  The ten bytes are six bytes for the longest length/\n   distance pair plus four bytes for overloading the bit buffer. */\n\nint inflate_fast(uInt bl, uInt bd, inflate_huft *tl, inflate_huft *td, inflate_blocks_statef *s, z_streamp z)\n{\n  inflate_huft *t;      /* temporary pointer */\n  uInt e;               /* extra bits or operation */\n  uLong b;              /* bit buffer */\n  uInt k;               /* bits in bit buffer */\n  Byte *p;             /* input data pointer */\n  uInt n;               /* bytes available there */\n  Byte *q;             /* output window write pointer */\n  uInt m;               /* bytes to end of window or read pointer */\n  uInt ml;              /* mask for literal/length tree */\n  uInt md;              /* mask for distance tree */\n  uInt c;               /* bytes to copy */\n  uInt d;               /* distance back to copy from */\n  Byte *r;             /* copy source pointer */\n\n  /* load input, output, bit values */\n  LOAD\n\n  /* initialize masks */\n  ml = inflate_mask[bl];\n  md = inflate_mask[bd];\n\n  /* do until not enough input or output space for fast loop */\n  do {                          /* assume called with m >= 258 && n >= 10 */\n    /* get literal/length code */\n    GRABBITS(20)                /* max bits for literal/length code */\n    if ((e = (t = tl + ((uInt)b & ml))->exop) == 0)\n    {\n      DUMPBITS(t->bits)\n      Tracevv((t->base >= 0x20 && t->base < 0x7f ?\n                \"inflate:         * literal '%c'\\n\" :\n                \"inflate:         * literal 0x%02x\\n\", t->base));\n      *q++ = (Byte)t->base;\n      m--;\n      continue;\n    }\n    do {\n      DUMPBITS(t->bits)\n      if (e & 16)\n      {\n        /* get extra bits for length */\n        e &= 15;\n        c = t->base + ((uInt)b & inflate_mask[e]);\n        DUMPBITS(e)\n        Tracevv((\"inflate:         * length %u\\n\", c));\n\n        /* decode distance base of block to copy */\n        GRABBITS(15);           /* max bits for distance code */\n        e = (t = td + ((uInt)b & md))->exop;\n        do {\n          DUMPBITS(t->bits)\n          if (e & 16)\n          {\n            /* get extra bits to add to distance base */\n            e &= 15;\n            GRABBITS(e)         /* get extra bits (up to 13) */\n            d = t->base + ((uInt)b & inflate_mask[e]);\n            DUMPBITS(e)\n            Tracevv((\"inflate:         * distance %u\\n\", d));\n\n            /* do the copy */\n            m -= c;\n            if ((uInt)(q - s->window) >= d)     /* offset before dest */\n            {                                   /*  just copy */\n              r = q - d;\n              *q++ = *r++;  c--;        /* minimum count is three, */\n              *q++ = *r++;  c--;        /*  so unroll loop a little */\n            }\n            else                        /* else offset after destination */\n            {\n              e = d - (uInt)(q - s->window); /* bytes from offset to end */\n              r = s->end - e;           /* pointer to offset */\n              if (c > e)                /* if source crosses, */\n              {\n                c -= e;                 /* copy to end of window */\n                do {\n                  *q++ = *r++;\n                } while (--e);\n                r = s->window;          /* copy rest from start of window */\n              }\n            }\n            do {                        /* copy all or what's left */\n              *q++ = *r++;\n            } while (--c);\n            break;\n          }\n          else if ((e & 64) == 0)\n          {\n            t += t->base;\n            e = (t += ((uInt)b & inflate_mask[e]))->exop;\n          }\n          else\n          {\n            z->msg = (char*)\"invalid distance code\";\n            UNGRAB\n            UPDATE\n            return Z_DATA_ERROR;\n          }\n        } while (1);\n        break;\n      }\n      if ((e & 64) == 0)\n      {\n        t += t->base;\n        if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0)\n        {\n          DUMPBITS(t->bits)\n          Tracevv((t->base >= 0x20 && t->base < 0x7f ?\n                    \"inflate:         * literal '%c'\\n\" :\n                    \"inflate:         * literal 0x%02x\\n\", t->base));\n          *q++ = (Byte)t->base;\n          m--;\n          break;\n        }\n      }\n      else if (e & 32)\n      {\n        Tracevv((\"inflate:         * end of block\\n\"));\n        UNGRAB\n        UPDATE\n        return Z_STREAM_END;\n      }\n      else\n      {\n        z->msg = (char*)\"invalid literal/length code\";\n        UNGRAB\n        UPDATE\n        return Z_DATA_ERROR;\n      }\n    } while (1);\n  } while (m >= 258 && n >= 10);\n\n  /* not enough input or output--restore pointers and return */\n  UNGRAB\n  UPDATE\n  return Z_OK;\n}\n\n/* infcodes.c -- process literals and length/distance pairs\n * Copyright (C) 1995-1998 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h \n */\n\n/* simplify the use of the inflate_huft type with some defines */\n#define exop word.what.Exop\n#define bits word.what.Bits\n\ntypedef enum {        /* waiting for \"i:\"=input, \"o:\"=output, \"x:\"=nothing */\n      START,    /* x: set up for LEN */\n      LEN,      /* i: get length/literal/eob next */\n      LENEXT,   /* i: getting length extra (have base) */\n      DIST,     /* i: get distance next */\n      DISTEXT,  /* i: getting distance extra */\n      COPY,     /* o: copying bytes in window, waiting for space */\n      LIT,      /* o: got literal, waiting for output space */\n      WASH,     /* o: got eob, possibly still output waiting */\n      END,      /* x: got eob and all data flushed */\n      BADCODE}  /* x: got error */\ninflate_codes_mode;\n\n/* inflate codes private state */\nstruct inflate_codes_state {\n\n  /* mode */\n  inflate_codes_mode mode;      /* current inflate_codes mode */\n\n  /* mode dependent information */\n  uInt len;\n  union {\n    struct {\n      inflate_huft *tree;       /* pointer into tree */\n      uInt need;                /* bits needed */\n    } code;             /* if LEN or DIST, where in tree */\n    uInt lit;           /* if LIT, literal */\n    struct {\n      uInt get;                 /* bits to get for extra */\n      uInt dist;                /* distance back to copy from */\n    } copy;             /* if EXT or COPY, where and how much */\n  } sub;                /* submode */\n\n  /* mode independent information */\n  Byte lbits;           /* ltree bits decoded per branch */\n  Byte dbits;           /* dtree bits decoder per branch */\n  inflate_huft *ltree;          /* literal/length/eob tree */\n  inflate_huft *dtree;          /* distance tree */\n\n};\n\n\ninflate_codes_statef *inflate_codes_new(uInt bl, uInt bd, inflate_huft *tl, inflate_huft *td, z_streamp z)\n{\n  inflate_codes_statef *c;\n\n  if ((c = (inflate_codes_statef *)\n       ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL)\n  {\n    c->mode = START;\n    c->lbits = (Byte)bl;\n    c->dbits = (Byte)bd;\n    c->ltree = tl;\n    c->dtree = td;\n    Tracev((\"inflate:       codes new\\n\"));\n  }\n  return c;\n}\n\n\nint inflate_codes(inflate_blocks_statef *s, z_streamp z, int r)\n{\n  uInt j;               /* temporary storage */\n  inflate_huft *t;      /* temporary pointer */\n  uInt e;               /* extra bits or operation */\n  uLong b;              /* bit buffer */\n  uInt k;               /* bits in bit buffer */\n  Byte *p;             /* input data pointer */\n  uInt n;               /* bytes available there */\n  Byte *q;             /* output window write pointer */\n  uInt m;               /* bytes to end of window or read pointer */\n  Byte *f;             /* pointer to copy strings from */\n  inflate_codes_statef *c = s->sub.decode.codes;  /* codes state */\n\n  /* copy input/output information to locals (UPDATE macro restores) */\n  LOAD\n\n  /* process input and output based on current state */\n  while (1) switch (c->mode)\n  {             /* waiting for \"i:\"=input, \"o:\"=output, \"x:\"=nothing */\n    case START:         /* x: set up for LEN */\n#ifndef SLOW\n      if (m >= 258 && n >= 10)\n      {\n        UPDATE\n        r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z);\n        LOAD\n        if (r != Z_OK)\n        {\n          c->mode = r == Z_STREAM_END ? WASH : BADCODE;\n          break;\n        }\n      }\n#endif /* !SLOW */\n      c->sub.code.need = c->lbits;\n      c->sub.code.tree = c->ltree;\n      c->mode = LEN;\n    case LEN:           /* i: get length/literal/eob next */\n      j = c->sub.code.need;\n      NEEDBITS(j)\n      t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);\n      DUMPBITS(t->bits)\n      e = (uInt)(t->exop);\n      if (e == 0)               /* literal */\n      {\n        c->sub.lit = t->base;\n        Tracevv((t->base >= 0x20 && t->base < 0x7f ?\n                 \"inflate:         literal '%c'\\n\" :\n                 \"inflate:         literal 0x%02x\\n\", t->base));\n        c->mode = LIT;\n        break;\n      }\n      if (e & 16)               /* length */\n      {\n        c->sub.copy.get = e & 15;\n        c->len = t->base;\n        c->mode = LENEXT;\n        break;\n      }\n      if ((e & 64) == 0)        /* next table */\n      {\n        c->sub.code.need = e;\n        c->sub.code.tree = t + t->base;\n        break;\n      }\n      if (e & 32)               /* end of block */\n      {\n        Tracevv((\"inflate:         end of block\\n\"));\n        c->mode = WASH;\n        break;\n      }\n      c->mode = BADCODE;        /* invalid code */\n      z->msg = (char*)\"invalid literal/length code\";\n      r = Z_DATA_ERROR;\n      LEAVE\n    case LENEXT:        /* i: getting length extra (have base) */\n      j = c->sub.copy.get;\n      NEEDBITS(j)\n      c->len += (uInt)b & inflate_mask[j];\n      DUMPBITS(j)\n      c->sub.code.need = c->dbits;\n      c->sub.code.tree = c->dtree;\n      Tracevv((\"inflate:         length %u\\n\", c->len));\n      c->mode = DIST;\n    case DIST:          /* i: get distance next */\n      j = c->sub.code.need;\n      NEEDBITS(j)\n      t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);\n      DUMPBITS(t->bits)\n      e = (uInt)(t->exop);\n      if (e & 16)               /* distance */\n      {\n        c->sub.copy.get = e & 15;\n        c->sub.copy.dist = t->base;\n        c->mode = DISTEXT;\n        break;\n      }\n      if ((e & 64) == 0)        /* next table */\n      {\n        c->sub.code.need = e;\n        c->sub.code.tree = t + t->base;\n        break;\n      }\n      c->mode = BADCODE;        /* invalid code */\n      z->msg = (char*)\"invalid distance code\";\n      r = Z_DATA_ERROR;\n      LEAVE\n    case DISTEXT:       /* i: getting distance extra */\n      j = c->sub.copy.get;\n      NEEDBITS(j)\n      c->sub.copy.dist += (uInt)b & inflate_mask[j];\n      DUMPBITS(j)\n      Tracevv((\"inflate:         distance %u\\n\", c->sub.copy.dist));\n      c->mode = COPY;\n    case COPY:          /* o: copying bytes in window, waiting for space */\n#ifndef __TURBOC__ /* Turbo C bug for following expression */\n      f = (uInt)(q - s->window) < c->sub.copy.dist ?\n          s->end - (c->sub.copy.dist - (q - s->window)) :\n          q - c->sub.copy.dist;\n#else\n      f = q - c->sub.copy.dist;\n      if ((uInt)(q - s->window) < c->sub.copy.dist)\n        f = s->end - (c->sub.copy.dist - (uInt)(q - s->window));\n#endif\n      while (c->len)\n      {\n        NEEDOUT\n        OUTBYTE(*f++)\n        if (f == s->end)\n          f = s->window;\n        c->len--;\n      }\n      c->mode = START;\n      break;\n    case LIT:           /* o: got literal, waiting for output space */\n      NEEDOUT\n      OUTBYTE(c->sub.lit)\n      c->mode = START;\n      break;\n    case WASH:          /* o: got eob, possibly more output */\n      if (k > 7)        /* return unused byte, if any */\n      {\n        Assert(k < 16, \"inflate_codes grabbed too many bytes\")\n        k -= 8;\n        n++;\n        p--;            /* can always return one */\n      }\n      FLUSH\n      if (s->read != s->write)\n        LEAVE\n      c->mode = END;\n    case END:\n      r = Z_STREAM_END;\n      LEAVE\n    case BADCODE:       /* x: got error */\n      r = Z_DATA_ERROR;\n      LEAVE\n    default:\n      r = Z_STREAM_ERROR;\n      LEAVE\n  }\n#ifdef NEED_DUMMY_RETURN\n  return Z_STREAM_ERROR;  /* Some dumb compilers complain without this */\n#endif\n}\n\n\nvoid inflate_codes_free(inflate_codes_statef *c, z_streamp z)\n{\n  ZFREE(z, c);\n  Tracev((\"inflate:       codes free\\n\"));\n}\n\n/* adler32.c -- compute the Adler-32 checksum of a data stream\n * Copyright (C) 1995-1998 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h \n */\n\n#define BASE 65521L /* largest prime smaller than 65536 */\n#define NMAX 5552\n/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */\n\n#undef DO1\n#undef DO2\n#undef DO4\n#undef DO8\n\n#define DO1(buf,i)  {s1 += buf[i]; s2 += s1;}\n#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);\n#define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);\n#define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);\n#define DO16(buf)   DO8(buf,0); DO8(buf,8);\n\n/* ========================================================================= */\nuLong adler32(uLong adler, const Byte *buf, uInt len)\n{\n    unsigned long s1 = adler & 0xffff;\n    unsigned long s2 = (adler >> 16) & 0xffff;\n    int k;\n\n    if (buf == Z_NULL) return 1L;\n\n    while (len > 0) {\n        k = len < NMAX ? len : NMAX;\n        len -= k;\n        while (k >= 16) {\n            DO16(buf);\n\t    buf += 16;\n            k -= 16;\n        }\n        if (k != 0) do {\n            s1 += *buf++;\n\t    s2 += s1;\n        } while (--k);\n        s1 %= BASE;\n        s2 %= BASE;\n    }\n    return (s2 << 16) | s1;\n}\n\n/* @(#) $Id: unzip.cpp,v 1.1.1.3 2000/01/11 16:37:27 ttimo Exp $ */\n\n/* infblock.h -- header to use infblock.c\n * Copyright (C) 1995-1998 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h \n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\nextern inflate_blocks_statef * inflate_blocks_new OF((\n    z_streamp z,\n    check_func c,               /* check function */\n    uInt w));                   /* window size */\n\nextern int inflate_blocks OF((\n    inflate_blocks_statef *,\n    z_streamp ,\n    int));                      /* initial return code */\n\nextern void inflate_blocks_reset OF((\n    inflate_blocks_statef *,\n    z_streamp ,\n    uLong *));                  /* check value on output */\n\nextern int inflate_blocks_free OF((\n    inflate_blocks_statef *,\n    z_streamp));\n\nextern void inflate_set_dictionary OF((\n    inflate_blocks_statef *s,\n    const Byte *d,  /* dictionary */\n    uInt  n));       /* dictionary length */\n\nextern int inflate_blocks_sync_point OF((\n    inflate_blocks_statef *s));\n\ntypedef enum {\n      imMETHOD,   /* waiting for method byte */\n      imFLAG,     /* waiting for flag byte */\n      imDICT4,    /* four dictionary check bytes to go */\n      imDICT3,    /* three dictionary check bytes to go */\n      imDICT2,    /* two dictionary check bytes to go */\n      imDICT1,    /* one dictionary check byte to go */\n      imDICT0,    /* waiting for inflateSetDictionary */\n      imBLOCKS,   /* decompressing blocks */\n      imCHECK4,   /* four check bytes to go */\n      imCHECK3,   /* three check bytes to go */\n      imCHECK2,   /* two check bytes to go */\n      imCHECK1,   /* one check byte to go */\n      imDONE,     /* finished check, done */\n      imBAD}      /* got an error--stay here */\ninflate_mode;\n\n/* inflate private state */\nstruct internal_state {\n\n  /* mode */\n  inflate_mode  mode;   /* current inflate mode */\n\n  /* mode dependent information */\n  union {\n    uInt method;        /* if FLAGS, method byte */\n    struct {\n      uLong was;                /* computed check value */\n      uLong need;               /* stream check value */\n    } check;            /* if CHECK, check values to compare */\n    uInt marker;        /* if BAD, inflateSync's marker bytes count */\n  } sub;        /* submode */\n\n  /* mode independent information */\n  int  nowrap;          /* flag for no wrapper */\n  uInt wbits;           /* log2(window size)  (8..15, defaults to 15) */\n  inflate_blocks_statef \n    *blocks;            /* current inflate_blocks state */\n\n};\n\n\nint inflateReset(z_streamp z)\n{\n  if (z == Z_NULL || z->state == Z_NULL)\n    return Z_STREAM_ERROR;\n  z->total_in = z->total_out = 0;\n  z->msg = Z_NULL;\n  z->state->mode = z->state->nowrap ? imBLOCKS : imMETHOD;\n  inflate_blocks_reset(z->state->blocks, z, Z_NULL);\n  Tracev((\"inflate: reset\\n\"));\n  return Z_OK;\n}\n\n\nint inflateEnd(z_streamp z)\n{\n  if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL)\n    return Z_STREAM_ERROR;\n  if (z->state->blocks != Z_NULL)\n    inflate_blocks_free(z->state->blocks, z);\n  ZFREE(z, z->state);\n  z->state = Z_NULL;\n  Tracev((\"inflate: end\\n\"));\n  return Z_OK;\n}\n\n\n\nint inflateInit2_(z_streamp z, int w, const char *version, int stream_size)\n{\n  if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||\n      stream_size != sizeof(z_stream))\n      return Z_VERSION_ERROR;\n\n  /* initialize state */\n  if (z == Z_NULL)\n    return Z_STREAM_ERROR;\n  z->msg = Z_NULL;\n  if (z->zalloc == Z_NULL)\n  {\n    z->zalloc = (void *(*)(void *, unsigned, unsigned))zcalloc;\n    z->opaque = (voidp)0;\n  }\n  if (z->zfree == Z_NULL) z->zfree = (void (*)(void *, void *))zcfree;\n  if ((z->state = (struct internal_state *)\n       ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL)\n    return Z_MEM_ERROR;\n  z->state->blocks = Z_NULL;\n\n  /* handle undocumented nowrap option (no zlib header or check) */\n  z->state->nowrap = 0;\n  if (w < 0)\n  {\n    w = - w;\n    z->state->nowrap = 1;\n  }\n\n  /* set window size */\n  if (w < 8 || w > 15)\n  {\n    inflateEnd(z);\n    return Z_STREAM_ERROR;\n  }\n  z->state->wbits = (uInt)w;\n\n  /* create inflate_blocks state */\n  if ((z->state->blocks =\n      inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w))\n      == Z_NULL)\n  {\n    inflateEnd(z);\n    return Z_MEM_ERROR;\n  }\n  Tracev((\"inflate: allocated\\n\"));\n\n  /* reset state */\n  inflateReset(z);\n  return Z_OK;\n}\n\n\nint inflateInit_(z_streamp z, const char *version, int stream_size)\n{\n  return inflateInit2_(z, DEF_WBITS, version, stream_size);\n}\n\n\n#define iNEEDBYTE {if(z->avail_in==0)return r;r=f;}\n#define iNEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++)\n\nint inflate(z_streamp z, int f)\n{\n  int r;\n  uInt b;\n\n  if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL)\n    return Z_STREAM_ERROR;\n  f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK;\n  r = Z_BUF_ERROR;\n  while (1) switch (z->state->mode)\n  {\n    case imMETHOD:\n      iNEEDBYTE\n      if (((z->state->sub.method = iNEXTBYTE) & 0xf) != Z_DEFLATED)\n      {\n        z->state->mode = imBAD;\n        z->msg = (char*)\"unknown compression method\";\n        z->state->sub.marker = 5;       /* can't try inflateSync */\n        break;\n      }\n      if ((z->state->sub.method >> 4) + 8 > z->state->wbits)\n      {\n        z->state->mode = imBAD;\n        z->msg = (char*)\"invalid window size\";\n        z->state->sub.marker = 5;       /* can't try inflateSync */\n        break;\n      }\n      z->state->mode = imFLAG;\n    case imFLAG:\n      iNEEDBYTE\n      b = iNEXTBYTE;\n      if (((z->state->sub.method << 8) + b) % 31)\n      {\n        z->state->mode = imBAD;\n        z->msg = (char*)\"incorrect header check\";\n        z->state->sub.marker = 5;       /* can't try inflateSync */\n        break;\n      }\n      Tracev((\"inflate: zlib header ok\\n\"));\n      if (!(b & PRESET_DICT))\n      {\n        z->state->mode = imBLOCKS;\n        break;\n      }\n      z->state->mode = imDICT4;\n    case imDICT4:\n      iNEEDBYTE\n      z->state->sub.check.need = (uLong)iNEXTBYTE << 24;\n      z->state->mode = imDICT3;\n    case imDICT3:\n      iNEEDBYTE\n      z->state->sub.check.need += (uLong)iNEXTBYTE << 16;\n      z->state->mode = imDICT2;\n    case imDICT2:\n      iNEEDBYTE\n      z->state->sub.check.need += (uLong)iNEXTBYTE << 8;\n      z->state->mode = imDICT1;\n    case imDICT1:\n      iNEEDBYTE\n      z->state->sub.check.need += (uLong)iNEXTBYTE;\n      z->adler = z->state->sub.check.need;\n      z->state->mode = imDICT0;\n      return Z_NEED_DICT;\n    case imDICT0:\n      z->state->mode = imBAD;\n      z->msg = (char*)\"need dictionary\";\n      z->state->sub.marker = 0;       /* can try inflateSync */\n      return Z_STREAM_ERROR;\n    case imBLOCKS:\n      r = inflate_blocks(z->state->blocks, z, r);\n      if (r == Z_DATA_ERROR)\n      {\n        z->state->mode = imBAD;\n        z->state->sub.marker = 0;       /* can try inflateSync */\n        break;\n      }\n      if (r == Z_OK)\n        r = f;\n      if (r != Z_STREAM_END)\n        return r;\n      r = f;\n      inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was);\n      if (z->state->nowrap)\n      {\n        z->state->mode = imDONE;\n        break;\n      }\n      z->state->mode = imCHECK4;\n    case imCHECK4:\n      iNEEDBYTE\n      z->state->sub.check.need = (uLong)iNEXTBYTE << 24;\n      z->state->mode = imCHECK3;\n    case imCHECK3:\n      iNEEDBYTE\n      z->state->sub.check.need += (uLong)iNEXTBYTE << 16;\n      z->state->mode = imCHECK2;\n    case imCHECK2:\n      iNEEDBYTE\n      z->state->sub.check.need += (uLong)iNEXTBYTE << 8;\n      z->state->mode = imCHECK1;\n    case imCHECK1:\n      iNEEDBYTE\n      z->state->sub.check.need += (uLong)iNEXTBYTE;\n\n      if (z->state->sub.check.was != z->state->sub.check.need)\n      {\n        z->state->mode = imBAD;\n        z->msg = (char*)\"incorrect data check\";\n        z->state->sub.marker = 5;       /* can't try inflateSync */\n        break;\n      }\n      Tracev((\"inflate: zlib check ok\\n\"));\n      z->state->mode = imDONE;\n    case imDONE:\n      return Z_STREAM_END;\n    case imBAD:\n      return Z_DATA_ERROR;\n    default:\n      return Z_STREAM_ERROR;\n  }\n#ifdef NEED_DUMMY_RETURN\n  return Z_STREAM_ERROR;  /* Some dumb compilers complain without this */\n#endif\n}\n\n\nint inflateSetDictionary(z_streamp z, const Byte *dictionary, uInt dictLength)\n{\n  uInt length = dictLength;\n\n  if (z == Z_NULL || z->state == Z_NULL || z->state->mode != imDICT0)\n    return Z_STREAM_ERROR;\n\n  if (adler32(1L, dictionary, dictLength) != z->adler) return Z_DATA_ERROR;\n  z->adler = 1L;\n\n  if (length >= ((uInt)1<<z->state->wbits))\n  {\n    length = (1<<z->state->wbits)-1;\n    dictionary += dictLength - length;\n  }\n  inflate_set_dictionary(z->state->blocks, dictionary, length);\n  z->state->mode = imBLOCKS;\n  return Z_OK;\n}\n\n\nint inflateSync(z_streamp z)\n{\n  uInt n;       /* number of bytes to look at */\n  Byte *p;     /* pointer to bytes */\n  uInt m;       /* number of marker bytes found in a row */\n  uLong r, w;   /* temporaries to save total_in and total_out */\n\n  /* set up */\n  if (z == Z_NULL || z->state == Z_NULL)\n    return Z_STREAM_ERROR;\n  if (z->state->mode != imBAD)\n  {\n    z->state->mode = imBAD;\n    z->state->sub.marker = 0;\n  }\n  if ((n = z->avail_in) == 0)\n    return Z_BUF_ERROR;\n  p = z->next_in;\n  m = z->state->sub.marker;\n\n  /* search */\n  while (n && m < 4)\n  {\n    static const Byte mark[4] = {0, 0, 0xff, 0xff};\n    if (*p == mark[m])\n      m++;\n    else if (*p)\n      m = 0;\n    else\n      m = 4 - m;\n    p++, n--;\n  }\n\n  /* restore */\n  z->total_in += p - z->next_in;\n  z->next_in = p;\n  z->avail_in = n;\n  z->state->sub.marker = m;\n\n  /* return no joy or set up to restart on a new block */\n  if (m != 4)\n    return Z_DATA_ERROR;\n  r = z->total_in;  w = z->total_out;\n  inflateReset(z);\n  z->total_in = r;  z->total_out = w;\n  z->state->mode = imBLOCKS;\n  return Z_OK;\n}\n\n\n/* Returns true if inflate is currently at the end of a block generated\n * by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP\n * implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH\n * but removes the length bytes of the resulting empty stored block. When\n * decompressing, PPP checks that at the end of input packet, inflate is\n * waiting for these length bytes.\n */\nint inflateSyncPoint(z_streamp z)\n{\n  if (z == Z_NULL || z->state == Z_NULL || z->state->blocks == Z_NULL)\n    return Z_STREAM_ERROR;\n  return inflate_blocks_sync_point(z->state->blocks);\n}\n\nvoidp zcalloc (voidp opaque, unsigned items, unsigned size)\n{\n    if (opaque) items += size - size; /* make compiler happy */\n    return (voidp)malloc(items*size);\n}\n\nvoid  zcfree (voidp opaque, voidp ptr)\n{\n    free(ptr);\n    if (opaque) return; /* make compiler happy */\n}\n\n"
  },
  {
    "path": "libs/pak/unzip.h",
    "content": "\n#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)\n/* like the STRICT of WIN32, we define a pointer that cannot be converted\n    from (void*) without cast */\ntypedef struct TagunzFile__ { int unused; } unzFile__; \ntypedef unzFile__ *unzFile;\n#else\ntypedef void* unzFile;\n#endif\n\n\n/* tm_unz contain date/time info */\ntypedef struct tm_unz_s \n{\n\tunsigned int tm_sec;            /* seconds after the minute - [0,59] */\n\tunsigned int tm_min;            /* minutes after the hour - [0,59] */\n\tunsigned int tm_hour;           /* hours since midnight - [0,23] */\n\tunsigned int tm_mday;           /* day of the month - [1,31] */\n\tunsigned int tm_mon;            /* months since January - [0,11] */\n\tunsigned int tm_year;           /* years - [1980..2044] */\n} tm_unz;\n\n/* unz_global_info structure contain global data about the ZIPfile\n   These data comes from the end of central dir */\ntypedef struct unz_global_info_s\n{\n\tunsigned long number_entry;         /* total number of entries in the central dir on this disk */\n\tunsigned long size_comment;         /* size of the global comment of the zipfile */\n} unz_global_info;\n\n\n/* unz_file_info contain information about a file in the zipfile */\ntypedef struct unz_file_info_s\n{\n    unsigned long version;              /* version made by                 2 unsigned chars */\n    unsigned long version_needed;       /* version needed to extract       2 unsigned chars */\n    unsigned long flag;                 /* general purpose bit flag        2 unsigned chars */\n    unsigned long compression_method;   /* compression method              2 unsigned chars */\n    unsigned long dosDate;              /* last mod file date in Dos fmt   4 unsigned chars */\n    unsigned long crc;                  /* crc-32                          4 unsigned chars */\n    unsigned long compressed_size;      /* compressed size                 4 unsigned chars */ \n    unsigned long uncompressed_size;    /* uncompressed size               4 unsigned chars */ \n    unsigned long size_filename;        /* filename length                 2 unsigned chars */\n    unsigned long size_file_extra;      /* extra field length              2 unsigned chars */\n    unsigned long size_file_comment;    /* file comment length             2 unsigned chars */\n\n    unsigned long disk_num_start;       /* disk number start               2 unsigned chars */\n    unsigned long internal_fa;          /* internal file attributes        2 unsigned chars */\n    unsigned long external_fa;          /* external file attributes        4 unsigned chars */\n\n    tm_unz tmu_date;\n} unz_file_info;\n\n/* unz_file_info_interntal contain internal info about a file in zipfile*/\ntypedef struct unz_file_info_internal_s\n{\n    unsigned long offset_curfile;/* relative offset of static header 4 unsigned chars */\n} unz_file_info_internal;\n\ntypedef void* (*alloc_func) (void* opaque, unsigned int items, unsigned int size);\ntypedef void   (*free_func) (void* opaque, void* address);\n\nstruct internal_state;\n\ntypedef struct z_stream_s {\n    unsigned char    *next_in;  /* next input unsigned char */\n    unsigned int     avail_in;  /* number of unsigned chars available at next_in */\n    unsigned long    total_in;  /* total nb of input unsigned chars read so */\n\n    unsigned char    *next_out; /* next output unsigned char should be put there */\n    unsigned int     avail_out; /* remaining free space at next_out */\n    unsigned long    total_out; /* total nb of unsigned chars output so */\n\n    char     *msg;      /* last error message, NULL if no error */\n    struct internal_state *state; /* not visible by applications */\n\n    alloc_func zalloc;  /* used to allocate the internal state */\n    free_func  zfree;   /* used to free the internal state */\n    unsigned char*     opaque;  /* private data object passed to zalloc and zfree */\n\n    int     data_type;  /* best guess about the data type: ascii or binary */\n    unsigned long   adler;      /* adler32 value of the uncompressed data */\n    unsigned long   reserved;   /* reserved for future use */\n} z_stream;\n\ntypedef z_stream *z_streamp;\n\n\n/* file_in_zip_read_info_s contain internal information about a file in zipfile,\n    when reading and decompress it */\ntypedef struct\n{\n\tchar  *read_buffer;         /* internal buffer for compressed data */\n\tz_stream stream;            /* zLib stream structure for inflate */\n\n\tunsigned long pos_in_zipfile;       /* position in unsigned char on the zipfile, for fseek*/\n\tunsigned long stream_initialised;   /* flag set if stream structure is initialised*/\n\n\tunsigned long offset_local_extrafield;/* offset of the static extra field */\n\tunsigned int  size_local_extrafield;/* size of the static extra field */\n\tunsigned long pos_local_extrafield;   /* position in the static extra field in read*/\n\n\tunsigned long crc32;                /* crc32 of all data uncompressed */\n\tunsigned long crc32_wait;           /* crc32 we must obtain after decompress all */\n\tunsigned long rest_read_compressed; /* number of unsigned char to be decompressed */\n\tunsigned long rest_read_uncompressed;/*number of unsigned char to be obtained after decomp*/\n\tFILE* file;                 /* io structore of the zipfile */\n\tunsigned long compression_method;   /* compression method (0==store) */\n\tunsigned long byte_before_the_zipfile;/* unsigned char before the zipfile, (>0 for sfx)*/\n} file_in_zip_read_info_s;\n\n\n/* unz_s contain internal information about the zipfile\n*/\ntypedef struct\n{\n\tFILE* file;                 /* io structore of the zipfile */\n\tunz_global_info gi;       /* public global information */\n\tunsigned long byte_before_the_zipfile;/* unsigned char before the zipfile, (>0 for sfx)*/\n\tunsigned long num_file;             /* number of the current file in the zipfile*/\n\tunsigned long pos_in_central_dir;   /* pos of the current file in the central dir*/\n\tunsigned long current_file_ok;      /* flag about the usability of the current file*/\n\tunsigned long central_pos;          /* position of the beginning of the central dir*/\n\n\tunsigned long size_central_dir;     /* size of the central directory  */\n\tunsigned long offset_central_dir;   /* offset of start of central directory with\n\t\t\t\t\t\t\t\t   respect to the starting disk number */\n\n\tunz_file_info cur_file_info; /* public info about the current file in zip*/\n\tunz_file_info_internal cur_file_info_internal; /* private info about it*/\n    file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current\n\t                                    file if we are decompressing it */\n} unz_s;\n\n#define UNZ_OK                                  (0)\n#define UNZ_END_OF_LIST_OF_FILE (-100)\n#define UNZ_ERRNO               (Z_ERRNO)\n#define UNZ_EOF                 (0)\n#define UNZ_PARAMERROR                  (-102)\n#define UNZ_BADZIPFILE                  (-103)\n#define UNZ_INTERNALERROR               (-104)\n#define UNZ_CRCERROR                    (-105)\n\n#define UNZ_CASESENSITIVE\t\t1\n#define UNZ_NOTCASESENSITIVE\t2\n#define UNZ_OSDEFAULTCASE\t\t0\n\nextern int unzStringFileNameCompare (const char* fileName1, const char* fileName2, int iCaseSensitivity);\n\n/*\n   Compare two filename (fileName1,fileName2).\n   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)\n   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi\n\t\t\t\t\t\t\t\tor strcasecmp)\n   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system\n\t(like 1 on Unix, 2 on Windows)\n*/\n\nextern unzFile unzOpen (const char *path);\nextern unzFile unzReOpen (const char* path, unzFile file);\n\n/*\n  Open a Zip file. path contain the full pathname (by example,\n     on a Windows NT computer \"c:\\\\zlib\\\\zlib111.zip\" or on an Unix computer\n\t \"zlib/zlib111.zip\".\n\t If the zipfile cannot be opened (file don't exist or in not valid), the\n\t   return value is NULL.\n     Else, the return value is a unzFile Handle, usable with other function\n\t   of this unzip package.\n*/\n\nextern int unzClose (unzFile file);\n\n/*\n  Close a ZipFile opened with unzipOpen.\n  If there is files inside the .Zip opened with unzOpenCurrentFile (see later),\n    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.\n  return UNZ_OK if there is no problem. */\n\nextern int unzGetGlobalInfo (unzFile file, unz_global_info *pglobal_info);\n\n/*\n  Write info about the ZipFile in the *pglobal_info structure.\n  No preparation of the structure is needed\n  return UNZ_OK if there is no problem. */\n\n\nextern int unzGetGlobalComment (unzFile file, char *szComment, unsigned long uSizeBuf);\n\n/*\n  Get the global comment string of the ZipFile, in the szComment buffer.\n  uSizeBuf is the size of the szComment buffer.\n  return the number of unsigned char copied or an error code <0\n*/\n\n\n/***************************************************************************/\n/* Unzip package allow you browse the directory of the zipfile */\n\nextern int unzGoToFirstFile (unzFile file);\n\n/*\n  Set the current file of the zipfile to the first file.\n  return UNZ_OK if there is no problem\n*/\n\nextern int unzGoToNextFile (unzFile file);\n\n/*\n  Set the current file of the zipfile to the next file.\n  return UNZ_OK if there is no problem\n  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.\n*/\n\nextern int unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity);\n\n/*\n  Try locate the file szFileName in the zipfile.\n  For the iCaseSensitivity signification, see unzStringFileNameCompare\n\n  return value :\n  UNZ_OK if the file is found. It becomes the current file.\n  UNZ_END_OF_LIST_OF_FILE if the file is not found\n*/\n\n\nextern int unzGetCurrentFileInfo (unzFile file, unz_file_info *pfile_info, char *szFileName, unsigned long fileNameBufferSize, void *extraField, unsigned long extraFieldBufferSize, char *szComment, unsigned long commentBufferSize);\n\n/*\n  Get Info about the current file\n  if pfile_info!=NULL, the *pfile_info structure will contain somes info about\n\t    the current file\n  if szFileName!=NULL, the filemane string will be copied in szFileName\n\t\t\t(fileNameBufferSize is the size of the buffer)\n  if extraField!=NULL, the extra field information will be copied in extraField\n\t\t\t(extraFieldBufferSize is the size of the buffer).\n\t\t\tThis is the Central-header version of the extra field\n  if szComment!=NULL, the comment string of the file will be copied in szComment\n\t\t\t(commentBufferSize is the size of the buffer)\n*/\n\n/***************************************************************************/\n/* for reading the content of the current zipfile, you can open it, read data\n   from it, and close it (you can close it before reading all the file)\n   */\n\nextern int unzOpenCurrentFile (unzFile file);\n\n/*\n  Open for reading data the current file in the zipfile.\n  If there is no error, the return value is UNZ_OK.\n*/\n\nextern int unzCloseCurrentFile (unzFile file);\n\n/*\n  Close the file in zip opened with unzOpenCurrentFile\n  Return UNZ_CRCERROR if all the file was read but the CRC is not good\n*/\n\n\t\t\t\t\t\t\t\t\t\t\t\t\nextern int unzReadCurrentFile (unzFile file, void* buf, unsigned len);\n\n/*\n  Read unsigned chars from the current file (opened by unzOpenCurrentFile)\n  buf contain buffer where data must be copied\n  len the size of buf.\n\n  return the number of unsigned char copied if somes unsigned chars are copied\n  return 0 if the end of file was reached\n  return <0 with error code if there is an error\n    (UNZ_ERRNO for IO error, or zLib error for uncompress error)\n*/\n\nextern long unztell(unzFile file);\n\n/*\n  Give the current position in uncompressed data\n*/\n\nextern int unzeof (unzFile file);\n\n/*\n  return 1 if the end of file was reached, 0 elsewhere \n*/\n\nextern int unzGetLocalExtrafield (unzFile file, void* buf, unsigned len);\n\n/*\n  Read extra field from the current file (opened by unzOpenCurrentFile)\n  This is the local-header version of the extra field (sometimes, there is\n    more info in the local-header version than in the central-header)\n\n  if buf==NULL, it return the size of the local extra field\n\n  if buf!=NULL, len is the size of the buffer, the extra header is copied in\n\tbuf.\n  the return value is the number of unsigned chars copied in buf, or (if <0) \n\tthe error code\n*/\n"
  },
  {
    "path": "libs/pakstuff.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef _PAKSTUFF_H_\n#define _PAKSTUFF_H_\n\n#include <windows.h>\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\ntypedef char           Int8;\ntypedef short          Int16;\ntypedef long           Int32;\ntypedef unsigned char  UInt8;\ntypedef unsigned short UInt16;\ntypedef unsigned long  UInt32;\ntypedef float          Float32;\ntypedef double         Float64;\n#define MAX(a, b)              (((a) > (b)) ? (a) : (b))\n#define MIN(a, b)              (((a) < (b)) ? (a) : (b))\n#define RANDOM(x)              (random() % (x))\n#define RANDOMIZE()             srand((int) time(NULL))\n\n#define FTYPE_UNKNOWN 0\n#define FTYPE_IWAD    1    /* .wad  \"IWAD\" */\n#define FTYPE_PWAD    2    /* .wad  \"PWAD\" */\n#define FTYPE_PACK    3    /* .pak  \"PACK\" */\n#define FTYPE_WAD2    4    /* .wad  \"WAD2\" */\n#define FTYPE_BSP     10   /* .bsp  (0x17 0x00 0x00 0x00) */\n#define FTYPE_MODEL   11   /* .mdl  \"IDPO\" */\n#define FTYPE_SPRITE  12   /* .spr  \"IDSP\" */\n#define FTYPE_WAV     20   /* .wav  \"RIFF\" */\n#define FTYPE_AU      21   /* .au   \".snd\" */\n#define FTYPE_VOC     22   /* .voc  ?      */\n#define FTYPE_PBM_ASC 30   /* .pbm  \"P1\"   */\n#define FTYPE_PGM_ASC 31   /* .pgm  \"P2\"   */\n#define FTYPE_PPM_ASC 32   /* .ppm  \"P3\"   */\n#define FTYPE_PBM_RAW 33   /* .pbm  \"P4\"   */\n#define FTYPE_PGM_RAW 34   /* .pgm  \"P5\"   */\n#define FTYPE_PPM_RAW 35   /* .ppm  \"P6\"   */\n#define FTYPE_BMP     36   /* .bmp  \"BM\"   */\n#define FTYPE_GIF     37   /* .gif  \"GIF8\" */\n#define FTYPE_PCX     38   /* .pcx  (0x0a 0x05 0x01 0x08) */\n#define FTYPE_ERROR   -1\n\n#ifdef FAT_ENDIAN\nBool\tReadInt16\t\t(FILE *file, UInt16 huge *x);\nBool\tReadInt32\t\t(FILE *file, UInt32 huge *x);\nBool\tReadFloat32\t\t(FILE *file, Float32 huge *x);\nBool\tWriteInt16\t\t(FILE *file, UInt16 huge *x);\nBool\tWriteInt32\t\t(FILE *file, UInt32 huge *x);\nBool\tWriteFloat32\t(FILE *file, Float32 huge *x);\nUInt16\tSwapInt16\t\t(UInt16 x);\nUInt32\tSwapInt32\t\t(UInt32 x);\nFloat32\tSwapFloat32\t\t(Float32 x);\n#else\n#define ReadInt16(f, p)\t\tReadBytes((f), (p), 2L)\n#define ReadInt32(f, p)\t\tReadBytes((f), (p), 4L)\n#define ReadFloat32(f, p)\tReadBytes((f), (p), 4L)\n#define WriteInt16(f, p)\tWriteBytes((f), (p), 2L)\n#define WriteInt32(f, p)\tWriteBytes((f), (p), 4L)\n#define WriteFloat32(f, p)\tWriteBytes((f), (p), 4L)\n#define SwapInt16(x)\t\t(x)\n#define SwapInt32(x)\t\t(x)\n#define SwapFloat32(x)\t\t(x)\n#endif /* FAT_ENDIAN */\n\n#define FROMDISK\t-1\nstruct PACKDirectory\n{\n   char   name[56];             /* name of file */\n   UInt32 offset;               /* offset to start of data */\n   UInt32 size;                 /* byte size of data */\n};\ntypedef struct PACKDirectory *PACKDirPtr;\n\ntypedef struct DirListStruct\n{\n\tchar\t\t\t\t\tdirname[1024];\n\tint\t\t\t\t\t\tfrom;\n\tstruct\tDirListStruct\t*next;\n} DIRLIST;\n\ntypedef struct FileListStruct\n{\n\tchar\t\t\t\t\tfilename[1024];\n\tUInt32\t\t\t\t\toffset;\n\tUInt32\t\t\t\t\tsize;\n\tstruct\tFileListStruct\t*next;\n} FILELIST;\n\ntypedef struct DirStruct\n{\n\tchar\t\t\t\tname[1024];\n\tFILELIST\t\t\t*files;\n\tstruct DirStruct\t*next;\n} DIRECTORY;\n\n\nextern int m_nPAKIndex;\nextern FILE* pakfile[16];\nextern boolean pakopen;\nextern DIRECTORY\t*paktextures;\n\nvoid\tClearFileList\t\t\t\t(FILELIST **);\nvoid\tClearDirList\t\t\t\t(DIRLIST **);\nboolean\t\tGetPackFileList\t\t\t\t(FILELIST **, char *);\nboolean\t\tGetPackTextureDirs\t\t\t(DIRLIST **);\nboolean\tAddToDirListAlphabetized\t(DIRLIST **, char *, int);\nboolean\tAddToFileListAlphabetized\t(FILELIST **t, char *, UInt32, UInt32, boolean);\nboolean\tPakLoadFile\t\t\t\t\t(const char *, void **);\nvoid\tOpenPakFile\t\t\t\t\t(const char *);\nvoid\tClosePakFile\t\t\t\t(void);\nint PakLoadAnyFile(const char *filename, void **bufferptr);\nvoid WINAPI InitPakFile(const char * pBasePath, const char *pName);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "libs/str.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __STR__\n#define __STR__\n//\n// class Str\n// loose replacement for CString from MFC\n//\n//#include \"cmdlib.h\"\n#include <string.h>\n\nchar* __StrDup(char* pStr);\nchar* __StrDup(const char* pStr);\n\n\n\nstatic char *g_pStrWork = NULL;\n\nclass Str\n{\nprotected:\n  bool m_bIgnoreCase;\n  char *m_pStr;\n\npublic:\n  Str()\n  {\n    m_bIgnoreCase = true;\n    m_pStr = NULL;\n  }\n\n  Str(char *p)\n  {\n    m_bIgnoreCase = true;\n    m_pStr = __StrDup(p);\n  }\n\n  Str(const char *p)\n  {\n    m_bIgnoreCase = true;\n    m_pStr = __StrDup(p);\n  }\n\n  void Deallocate()\n  {\n    delete []m_pStr;\n    m_pStr = NULL;\n  }\n\n  void Allocate(int n)\n  {\n    Deallocate();\n    m_pStr = new char[n];\n  }\n\n  const char* GetBuffer()\n  {\n    return m_pStr;\n  }\n\n  void MakeEmpty()\n  {\n    Deallocate();\n    m_pStr = __StrDup(\"\");\n  }\n\n  ~Str()\n  {\n    Deallocate();\n    delete []g_pStrWork;\n    g_pStrWork = NULL;\n  }\n\n  void MakeLower()\n  {\n    if (m_pStr)\n    {\n      strlwr(m_pStr);\n    }\n  }\n\n  int Find(const char *p)\n  {\n    char *pf = strstr(m_pStr, p);\n    return (pf) ? (pf - m_pStr) : -1;\n  }\n\n  int GetLength()\n  {\n    return (m_pStr) ? strlen(m_pStr) : 0;\n  }\n\n  const char* Left(int n)\n  {\n    delete []g_pStrWork;\n    if (n > 0)\n    {\n      g_pStrWork = new char[n+1];\n      strncpy(g_pStrWork, m_pStr, n);\n    }\n    else\n    {\n      g_pStrWork = \"\";\n      g_pStrWork = new char[1];\n      g_pStrWork[0] = '\\0';\n    }\n    return g_pStrWork;\n  }\n\n  const char* Right(int n)\n  {\n    delete []g_pStrWork;\n    if (n > 0)\n    {\n      g_pStrWork = new char[n+1];\n      int nStart = GetLength() - n;\n      strncpy(g_pStrWork, &m_pStr[nStart], n);\n      g_pStrWork[n] = '\\0';\n    }\n    else\n    {\n      g_pStrWork = new char[1];\n      g_pStrWork[0] = '\\0';\n    }\n    return g_pStrWork;\n  }\n\n\n  char& operator *() { return *m_pStr; }\n  char& operator *() const { return *const_cast<Str*>(this)->m_pStr; }\n  operator void*() { return m_pStr; }\n  operator char*() { return m_pStr; }\n  operator const char*(){ return reinterpret_cast<const char*>(m_pStr); }\n  operator unsigned char*() { return reinterpret_cast<unsigned char*>(m_pStr); }\n  operator const unsigned char*() { return reinterpret_cast<const unsigned char*>(m_pStr); }\n  Str& operator =(const Str& rhs)\n  {\n    if (&rhs != this)\n    {\n      delete[] m_pStr;\n      m_pStr = __StrDup(rhs.m_pStr);\n    }\n    return *this;\n  }\n  \n  Str& operator =(const char* pStr)\n  {\n    if (m_pStr != pStr)\n    {\n      delete[] m_pStr;\n      m_pStr = __StrDup(pStr);\n    }\n    return *this;\n  }\n\n  Str& operator +=(const char *pStr)\n  {\n    if (pStr)\n    {\n      if (m_pStr)\n      {\n        char *p = new char[strlen(m_pStr) + strlen(pStr) + 1];\n        strcpy(p, m_pStr);\n        strcat(p, pStr);\n        delete m_pStr;\n        m_pStr = p;\n      }\n      else\n      {\n        m_pStr = __StrDup(pStr);\n      }\n    }\n    return *this;\n  }\n  \n  Str& operator +=(const char c)\n  {\n    return operator+=(&c);\n  }\n\n\n  bool operator ==(const Str& rhs) const { return (m_bIgnoreCase) ? stricmp(m_pStr, rhs.m_pStr) == 0 : strcmp(m_pStr, rhs.m_pStr) == 0; }\n  bool operator ==(char* pStr) const { return (m_bIgnoreCase) ? stricmp(m_pStr, pStr) == 0 : strcmp(m_pStr, pStr) == 0; }\n  bool operator ==(const char* pStr) const { return (m_bIgnoreCase) ? stricmp(m_pStr, pStr) == 0 : strcmp(m_pStr, pStr) == 0; }\n  bool operator !=(Str& rhs) const { return (m_bIgnoreCase) ? stricmp(m_pStr, rhs.m_pStr) != 0 : strcmp(m_pStr, rhs.m_pStr) != 0; }\n  bool operator !=(char* pStr) const { return (m_bIgnoreCase) ? stricmp(m_pStr, pStr) != 0 : strcmp(m_pStr, pStr) != 0; }\n  bool operator !=(const char* pStr) const { return (m_bIgnoreCase) ? stricmp(m_pStr, pStr) != 0 : strcmp(m_pStr, pStr) != 0; }\n  char& operator [](int nIndex) { return m_pStr[nIndex]; }\n  char& operator [](int nIndex) const { return m_pStr[nIndex]; }\n     \n};\n\n\n\n#endif"
  },
  {
    "path": "q3asm/Makefile",
    "content": "# yeah, couldn't do more simple really\n\nCC=gcc\nCFLAGS=-g -Wall\n\ndefault:\tq3asm\n\nq3asm:\tq3asm.c cmdlib.c\n\t$(CC) $(CFLAGS) -o $@ $^\n\nclean:\n\trm -f q3asm *~ *.o\n\n"
  },
  {
    "path": "q3asm/README.Id",
    "content": "2002-10-25  Timothee Besset <ttimo@idsoftware.com>\nIf you are looking for a faster version of the q3asm tool, try:\nhttp://www.icculus.org/~phaethon/q3/q3asm-turbo/q3asm-turbo.html\n\n2001-10-31  Timothee Besset <ttimo@idsoftware.com>\nupdated from the $/source/q3asm code\nmodified for portability and use with >= 1.31 mod source release\n\nthe cmdlib.c cmdlib.h mathlib.h qfiles.h have been copied from\n$/source/common\n"
  },
  {
    "path": "q3asm/cmdlib.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// cmdlib.c\n\n#include \"cmdlib.h\"\n#include <sys/types.h>\n#include <sys/stat.h>\n\n#ifdef WIN32\n#include <direct.h>\n#include <windows.h>\n#endif\n\n#ifdef __linux\n#include <unistd.h>\n#endif\n\n#ifdef NeXT\n#include <libc.h>\n#endif\n\n#define\tBASEDIRNAME\t\"quake\"\t\t// assumed to have a 2 or 3 following\n#define PATHSEPERATOR   '/'\n\n// set these before calling CheckParm\nint myargc;\nchar **myargv;\n\nchar\t\tcom_token[1024];\nqboolean\tcom_eof;\n\nqboolean\t\tarchive;\nchar\t\t\tarchivedir[1024];\n\n\n/*\n===================\nExpandWildcards\n\nMimic unix command line expansion\n===================\n*/\n#define\tMAX_EX_ARGC\t1024\nint\t\tex_argc;\nchar\t*ex_argv[MAX_EX_ARGC];\n#ifdef _WIN32\n#include \"io.h\"\nvoid ExpandWildcards( int *argc, char ***argv )\n{\n\tstruct _finddata_t fileinfo;\n\tint\t\thandle;\n\tint\t\ti;\n\tchar\tfilename[1024];\n\tchar\tfilebase[1024];\n\tchar\t*path;\n\n\tex_argc = 0;\n\tfor (i=0 ; i<*argc ; i++)\n\t{\n\t\tpath = (*argv)[i];\n\t\tif ( path[0] == '-'\n\t\t\t|| ( !strstr(path, \"*\") && !strstr(path, \"?\") ) )\n\t\t{\n\t\t\tex_argv[ex_argc++] = path;\n\t\t\tcontinue;\n\t\t}\n\n\t\thandle = _findfirst (path, &fileinfo);\n\t\tif (handle == -1)\n\t\t\treturn;\n\n\t\tExtractFilePath (path, filebase);\n\n\t\tdo\n\t\t{\n\t\t\tsprintf (filename, \"%s%s\", filebase, fileinfo.name);\n\t\t\tex_argv[ex_argc++] = copystring (filename);\n\t\t} while (_findnext( handle, &fileinfo ) != -1);\n\n\t\t_findclose (handle);\n\t}\n\n\t*argc = ex_argc;\n\t*argv = ex_argv;\n}\n#else\nvoid ExpandWildcards (int *argc, char ***argv)\n{\n}\n#endif\n\n#ifdef WIN_ERROR\n#include <windows.h>\n/*\n=================\nError\n\nFor abnormal program terminations in windowed apps\n=================\n*/\nvoid Error( const char *error, ... )\n{\n\tva_list argptr;\n\tchar\ttext[1024];\n\tchar\ttext2[1024];\n\tint\t\terr;\n\n\terr = GetLastError ();\n\n\tva_start (argptr,error);\n\tvsprintf (text, error,argptr);\n\tva_end (argptr);\n\n\tsprintf (text2, \"%s\\nGetLastError() = %i\", text, err);\n    MessageBox(NULL, text2, \"Error\", 0 /* MB_OK */ );\n\n\texit (1);\n}\n\n#else\n/*\n=================\nError\n\nFor abnormal program terminations in console apps\n=================\n*/\nvoid Error( const char *error, ...)\n{\n\tva_list argptr;\n\n\t_printf (\"\\n************ ERROR ************\\n\");\n\n\tva_start (argptr,error);\n\tvprintf (error,argptr);\n\tva_end (argptr);\n\t_printf (\"\\r\\n\");\n\n\texit (1);\n}\n#endif\n\n// only printf if in verbose mode\nqboolean verbose = qfalse;\nvoid qprintf( const char *format, ... ) {\n\tva_list argptr;\n\n\tif (!verbose)\n\t\treturn;\n\n\tva_start (argptr,format);\n\tvprintf (format,argptr);\n\tva_end (argptr);\n\n}\n\n#ifdef WIN32\nHWND hwndOut = NULL;\nqboolean lookedForServer = qfalse;\nUINT wm_BroadcastCommand = -1;\n#endif\n\nvoid _printf( const char *format, ... ) {\n\tva_list argptr;\n  char text[4096];\n#ifdef WIN32\n  ATOM a;\n#endif\n\tva_start (argptr,format);\n\tvsprintf (text, format, argptr);\n\tva_end (argptr);\n\n  printf(text);\n\n#ifdef WIN32\n  if (!lookedForServer) {\n    lookedForServer = qtrue;\n    hwndOut = FindWindow(NULL, \"Q3Map Process Server\");\n    if (hwndOut) {\n      wm_BroadcastCommand = RegisterWindowMessage( \"Q3MPS_BroadcastCommand\" );\n    }\n  }\n  if (hwndOut) {\n    a = GlobalAddAtom(text);\n    PostMessage(hwndOut, wm_BroadcastCommand, 0, (LPARAM)a);\n  }\n#endif\n}\n\n\n/*\n\nqdir will hold the path up to the quake directory, including the slash\n\n  f:\\quake\\\n  /raid/quake/\n\ngamedir will hold qdir + the game directory (id1, id2, etc)\n\n  */\n\nchar\t\tqdir[1024];\nchar\t\tgamedir[1024];\nchar\t\twritedir[1024];\n\nvoid SetQdirFromPath( const char *path )\n{\n\tchar\ttemp[1024];\n\tconst char\t*c;\n  const char *sep;\n\tint\t\tlen, count;\n\n\tif (!(path[0] == '/' || path[0] == '\\\\' || path[1] == ':'))\n\t{\t// path is partial\n\t\tQ_getwd (temp);\n\t\tstrcat (temp, path);\n\t\tpath = temp;\n\t}\n\n\t// search for \"quake2\" in path\n\n\tlen = strlen(BASEDIRNAME);\n\tfor (c=path+strlen(path)-1 ; c != path ; c--)\n\t{\n\t\tint i;\n\n\t\tif (!Q_strncasecmp (c, BASEDIRNAME, len))\n\t\t{\n      //\n\t\t\t//strncpy (qdir, path, c+len+2-path);\n      // the +2 assumes a 2 or 3 following quake which is not the\n      // case with a retail install\n      // so we need to add up how much to the next separator\n      sep = c + len;\n      count = 1;\n      while (*sep && *sep != '/' && *sep != '\\\\')\n      {\n        sep++;\n        count++;\n      }\n\t\t\tstrncpy (qdir, path, c+len+count-path);\n\t\t\tqprintf (\"qdir: %s\\n\", qdir);\n\t\t\tfor ( i = 0; i < strlen( qdir ); i++ )\n\t\t\t{\n\t\t\t\tif ( qdir[i] == '\\\\' ) \n\t\t\t\t\tqdir[i] = '/';\n\t\t\t}\n\n\t\t\tc += len+count;\n\t\t\twhile (*c)\n\t\t\t{\n\t\t\t\tif (*c == '/' || *c == '\\\\')\n\t\t\t\t{\n\t\t\t\t\tstrncpy (gamedir, path, c+1-path);\n\n\t\t\t\t\tfor ( i = 0; i < strlen( gamedir ); i++ )\n\t\t\t\t\t{\n\t\t\t\t\t\tif ( gamedir[i] == '\\\\' ) \n\t\t\t\t\t\t\tgamedir[i] = '/';\n\t\t\t\t\t}\n\n\t\t\t\t\tqprintf (\"gamedir: %s\\n\", gamedir);\n\n\t\t\t\t\tif ( !writedir[0] )\n\t\t\t\t\t\tstrcpy( writedir, gamedir );\n\t\t\t\t\telse if ( writedir[strlen( writedir )-1] != '/' )\n\t\t\t\t\t{\n\t\t\t\t\t\twritedir[strlen( writedir )] = '/';\n\t\t\t\t\t\twritedir[strlen( writedir )+1] = 0;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tc++;\n\t\t\t}\n\t\t\tError (\"No gamedir in %s\", path);\n\t\t\treturn;\n\t\t}\n\t}\n\tError (\"SetQdirFromPath: no '%s' in %s\", BASEDIRNAME, path);\n}\n\nchar *ExpandArg (const char *path)\n{\n\tstatic char full[1024];\n\n\tif (path[0] != '/' && path[0] != '\\\\' && path[1] != ':')\n\t{\n\t\tQ_getwd (full);\n\t\tstrcat (full, path);\n\t}\n\telse\n\t\tstrcpy (full, path);\n\treturn full;\n}\n\nchar *ExpandPath (const char *path)\n{\n\tstatic char full[1024];\n\tif (!qdir)\n\t\tError (\"ExpandPath called without qdir set\");\n\tif (path[0] == '/' || path[0] == '\\\\' || path[1] == ':') {\n\t\tstrcpy( full, path );\n\t\treturn full;\n\t}\n\tsprintf (full, \"%s%s\", qdir, path);\n\treturn full;\n}\n\nchar *ExpandGamePath (const char *path)\n{\n\tstatic char full[1024];\n\tif (!qdir)\n\t\tError (\"ExpandGamePath called without qdir set\");\n\tif (path[0] == '/' || path[0] == '\\\\' || path[1] == ':') {\n\t\tstrcpy( full, path );\n\t\treturn full;\n\t}\n\tsprintf (full, \"%s%s\", gamedir, path);\n\treturn full;\n}\n\nchar *ExpandPathAndArchive (const char *path)\n{\n\tchar\t*expanded;\n\tchar\tarchivename[1024];\n\n\texpanded = ExpandPath (path);\n\n\tif (archive)\n\t{\n\t\tsprintf (archivename, \"%s/%s\", archivedir, path);\n\t\tQCopyFile (expanded, archivename);\n\t}\n\treturn expanded;\n}\n\n\nchar *copystring(const char *s)\n{\n\tchar\t*b;\n\tb = malloc(strlen(s)+1);\n\tstrcpy (b, s);\n\treturn b;\n}\n\n\n\n/*\n================\nI_FloatTime\n================\n*/\ndouble I_FloatTime (void)\n{\n\ttime_t\tt;\n\t\n\ttime (&t);\n\t\n\treturn t;\n#if 0\n// more precise, less portable\n\tstruct timeval tp;\n\tstruct timezone tzp;\n\tstatic int\t\tsecbase;\n\n\tgettimeofday(&tp, &tzp);\n\t\n\tif (!secbase)\n\t{\n\t\tsecbase = tp.tv_sec;\n\t\treturn tp.tv_usec/1000000.0;\n\t}\n\t\n\treturn (tp.tv_sec - secbase) + tp.tv_usec/1000000.0;\n#endif\n}\n\nvoid Q_getwd (char *out)\n{\n\tint i = 0;\n\n#ifdef WIN32\n   _getcwd (out, 256);\n   strcat (out, \"\\\\\");\n#else\n   getcwd (out, 256);\n   strcat (out, \"/\");\n#endif\n\n   while ( out[i] != 0 )\n   {\n\t   if ( out[i] == '\\\\' )\n\t\t   out[i] = '/';\n\t   i++;\n   }\n}\n\n\nvoid Q_mkdir (const char *path)\n{\n#ifdef WIN32\n\tif (_mkdir (path) != -1)\n\t\treturn;\n#else\n\tif (mkdir (path, 0777) != -1)\n\t\treturn;\n#endif\n\tif (errno != EEXIST)\n\t\tError (\"mkdir %s: %s\",path, strerror(errno));\n}\n\n/*\n============\nFileTime\n\nreturns -1 if not present\n============\n*/\nint\tFileTime (const char *path)\n{\n\tstruct\tstat\tbuf;\n\t\n\tif (stat (path,&buf) == -1)\n\t\treturn -1;\n\t\n\treturn buf.st_mtime;\n}\n\n\n\n/*\n==============\nCOM_Parse\n\nParse a token out of a string\n==============\n*/\nchar *COM_Parse (char *data)\n{\n\tint\t\tc;\n\tint\t\tlen;\n\t\n\tlen = 0;\n\tcom_token[0] = 0;\n\t\n\tif (!data)\n\t\treturn NULL;\n\t\t\n// skip whitespace\nskipwhite:\n\twhile ( (c = *data) <= ' ')\n\t{\n\t\tif (c == 0)\n\t\t{\n\t\t\tcom_eof = qtrue;\n\t\t\treturn NULL;\t\t\t// end of file;\n\t\t}\n\t\tdata++;\n\t}\n\t\n// skip // comments\n\tif (c=='/' && data[1] == '/')\n\t{\n\t\twhile (*data && *data != '\\n')\n\t\t\tdata++;\n\t\tgoto skipwhite;\n\t}\n\t\n\n// handle quoted strings specially\n\tif (c == '\\\"')\n\t{\n\t\tdata++;\n\t\tdo\n\t\t{\n\t\t\tc = *data++;\n\t\t\tif (c=='\\\"')\n\t\t\t{\n\t\t\t\tcom_token[len] = 0;\n\t\t\t\treturn data;\n\t\t\t}\n\t\t\tcom_token[len] = c;\n\t\t\tlen++;\n\t\t} while (1);\n\t}\n\n// parse single characters\n\tif (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\\'' || c==':')\n\t{\n\t\tcom_token[len] = c;\n\t\tlen++;\n\t\tcom_token[len] = 0;\n\t\treturn data+1;\n\t}\n\n// parse a regular word\n\tdo\n\t{\n\t\tcom_token[len] = c;\n\t\tdata++;\n\t\tlen++;\n\t\tc = *data;\n\tif (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\\'' || c==':')\n\t\t\tbreak;\n\t} while (c>32);\n\t\n\tcom_token[len] = 0;\n\treturn data;\n}\n\n\nint Q_strncasecmp (const char *s1, const char *s2, int n)\n{\n\tint\t\tc1, c2;\n\t\n\tdo\n\t{\n\t\tc1 = *s1++;\n\t\tc2 = *s2++;\n\n\t\tif (!n--)\n\t\t\treturn 0;\t\t// strings are equal until end point\n\t\t\n\t\tif (c1 != c2)\n\t\t{\n\t\t\tif (c1 >= 'a' && c1 <= 'z')\n\t\t\t\tc1 -= ('a' - 'A');\n\t\t\tif (c2 >= 'a' && c2 <= 'z')\n\t\t\t\tc2 -= ('a' - 'A');\n\t\t\tif (c1 != c2)\n\t\t\t\treturn -1;\t\t// strings not equal\n\t\t}\n\t} while (c1);\n\t\n\treturn 0;\t\t// strings are equal\n}\n\nint Q_stricmp (const char *s1, const char *s2)\n{\n\treturn Q_strncasecmp (s1, s2, 99999);\n}\n\n\nchar *strupr (char *start)\n{\n\tchar\t*in;\n\tin = start;\n\twhile (*in)\n\t{\n\t\t*in = toupper(*in);\n\t\tin++;\n\t}\n\treturn start;\n}\n\nchar *strlower (char *start)\n{\n\tchar\t*in;\n\tin = start;\n\twhile (*in)\n\t{\n\t\t*in = tolower(*in); \n\t\tin++;\n\t}\n\treturn start;\n}\n\n\n/*\n=============================================================================\n\n\t\t\t\t\t\tMISC FUNCTIONS\n\n=============================================================================\n*/\n\n\n/*\n=================\nCheckParm\n\nChecks for the given parameter in the program's command line arguments\nReturns the argument number (1 to argc-1) or 0 if not present\n=================\n*/\nint CheckParm (const char *check)\n{\n\tint             i;\n\n\tfor (i = 1;i<myargc;i++)\n\t{\n\t\tif ( !Q_stricmp(check, myargv[i]) )\n\t\t\treturn i;\n\t}\n\n\treturn 0;\n}\n\n\n\n/*\n================\nQ_filelength\n================\n*/\nint Q_filelength (FILE *f)\n{\n\tint\t\tpos;\n\tint\t\tend;\n\n\tpos = ftell (f);\n\tfseek (f, 0, SEEK_END);\n\tend = ftell (f);\n\tfseek (f, pos, SEEK_SET);\n\n\treturn end;\n}\n\n\nFILE *SafeOpenWrite (const char *filename)\n{\n\tFILE\t*f;\n\n\tf = fopen(filename, \"wb\");\n\n\tif (!f)\n\t\tError (\"Error opening %s: %s\",filename,strerror(errno));\n\n\treturn f;\n}\n\nFILE *SafeOpenRead (const char *filename)\n{\n\tFILE\t*f;\n\n\tf = fopen(filename, \"rb\");\n\n\tif (!f)\n\t\tError (\"Error opening %s: %s\",filename,strerror(errno));\n\n\treturn f;\n}\n\n\nvoid SafeRead (FILE *f, void *buffer, int count)\n{\n\tif ( fread (buffer, 1, count, f) != (size_t)count)\n\t\tError (\"File read failure\");\n}\n\n\nvoid SafeWrite (FILE *f, const void *buffer, int count)\n{\n\tif (fwrite (buffer, 1, count, f) != (size_t)count)\n\t\tError (\"File write failure\");\n}\n\n\n/*\n==============\nFileExists\n==============\n*/\nqboolean\tFileExists (const char *filename)\n{\n\tFILE\t*f;\n\n\tf = fopen (filename, \"r\");\n\tif (!f)\n\t\treturn qfalse;\n\tfclose (f);\n\treturn qtrue;\n}\n\n/*\n==============\nLoadFile\n==============\n*/\nint    LoadFile( const char *filename, void **bufferptr )\n{\n\tFILE\t*f;\n\tint    length;\n\tvoid    *buffer;\n\n\tf = SafeOpenRead (filename);\n\tlength = Q_filelength (f);\n\tbuffer = malloc (length+1);\n\t((char *)buffer)[length] = 0;\n\tSafeRead (f, buffer, length);\n\tfclose (f);\n\n\t*bufferptr = buffer;\n\treturn length;\n}\n\n\n/*\n==============\nLoadFileBlock\n-\nrounds up memory allocation to 4K boundry\n-\n==============\n*/\nint    LoadFileBlock( const char *filename, void **bufferptr )\n{\n\tFILE\t*f;\n\tint    length, nBlock, nAllocSize;\n\tvoid    *buffer;\n\n\tf = SafeOpenRead (filename);\n\tlength = Q_filelength (f);\n  nAllocSize = length;\n  nBlock = nAllocSize % MEM_BLOCKSIZE;\n  if ( nBlock > 0) {\n    nAllocSize += MEM_BLOCKSIZE - nBlock;\n  }\n\tbuffer = malloc (nAllocSize+1);\n  memset(buffer, 0, nAllocSize+1);\n\tSafeRead (f, buffer, length);\n\tfclose (f);\n\n\t*bufferptr = buffer;\n\treturn length;\n}\n\n\n/*\n==============\nTryLoadFile\n\nAllows failure\n==============\n*/\nint    TryLoadFile (const char *filename, void **bufferptr)\n{\n\tFILE\t*f;\n\tint    length;\n\tvoid    *buffer;\n\n\t*bufferptr = NULL;\n\n\tf = fopen (filename, \"rb\");\n\tif (!f)\n\t\treturn -1;\n\tlength = Q_filelength (f);\n\tbuffer = malloc (length+1);\n\t((char *)buffer)[length] = 0;\n\tSafeRead (f, buffer, length);\n\tfclose (f);\n\n\t*bufferptr = buffer;\n\treturn length;\n}\n\n\n/*\n==============\nSaveFile\n==============\n*/\nvoid    SaveFile (const char *filename, const void *buffer, int count)\n{\n\tFILE\t*f;\n\n\tf = SafeOpenWrite (filename);\n\tSafeWrite (f, buffer, count);\n\tfclose (f);\n}\n\n\n\nvoid DefaultExtension (char *path, const char *extension)\n{\n\tchar    *src;\n//\n// if path doesnt have a .EXT, append extension\n// (extension should include the .)\n//\n\tsrc = path + strlen(path) - 1;\n\n\twhile (*src != '/' && *src != '\\\\' && src != path)\n\t{\n\t\tif (*src == '.')\n\t\t\treturn;                 // it has an extension\n\t\tsrc--;\n\t}\n\n\tstrcat (path, extension);\n}\n\n\nvoid DefaultPath (char *path, const char *basepath)\n{\n\tchar    temp[128];\n\n\tif (path[0] == PATHSEPERATOR)\n\t\treturn;                   // absolute path location\n\tstrcpy (temp,path);\n\tstrcpy (path,basepath);\n\tstrcat (path,temp);\n}\n\n\nvoid    StripFilename (char *path)\n{\n\tint             length;\n\n\tlength = strlen(path)-1;\n\twhile (length > 0 && path[length] != PATHSEPERATOR)\n\t\tlength--;\n\tpath[length] = 0;\n}\n\nvoid    StripExtension (char *path)\n{\n\tint             length;\n\n\tlength = strlen(path)-1;\n\twhile (length > 0 && path[length] != '.')\n\t{\n\t\tlength--;\n\t\tif (path[length] == '/')\n\t\t\treturn;\t\t// no extension\n\t}\n\tif (length)\n\t\tpath[length] = 0;\n}\n\n\n/*\n====================\nExtract file parts\n====================\n*/\n// FIXME: should include the slash, otherwise\n// backing to an empty path will be wrong when appending a slash\nvoid ExtractFilePath (const char *path, char *dest)\n{\n\tconst char    *src;\n\n\tsrc = path + strlen(path) - 1;\n\n//\n// back up until a \\ or the start\n//\n\twhile (src != path && *(src-1) != '\\\\' && *(src-1) != '/')\n\t\tsrc--;\n\n\tmemcpy (dest, path, src-path);\n\tdest[src-path] = 0;\n}\n\nvoid ExtractFileBase (const char *path, char *dest)\n{\n\tconst char    *src;\n\n\tsrc = path + strlen(path) - 1;\n\n//\n// back up until a \\ or the start\n//\n\twhile (src != path && *(src-1) != PATHSEPERATOR)\n\t\tsrc--;\n\n\twhile (*src && *src != '.')\n\t{\n\t\t*dest++ = *src++;\n\t}\n\t*dest = 0;\n}\n\nvoid ExtractFileExtension (const char *path, char *dest)\n{\n\tconst char    *src;\n\n\tsrc = path + strlen(path) - 1;\n\n//\n// back up until a . or the start\n//\n\twhile (src != path && *(src-1) != '.')\n\t\tsrc--;\n\tif (src == path)\n\t{\n\t\t*dest = 0;\t// no extension\n\t\treturn;\n\t}\n\n\tstrcpy (dest,src);\n}\n\n\n/*\n==============\nParseNum / ParseHex\n==============\n*/\nint ParseHex (const char *hex)\n{\n\tconst char    *str;\n\tint    num;\n\n\tnum = 0;\n\tstr = hex;\n\n\twhile (*str)\n\t{\n\t\tnum <<= 4;\n\t\tif (*str >= '0' && *str <= '9')\n\t\t\tnum += *str-'0';\n\t\telse if (*str >= 'a' && *str <= 'f')\n\t\t\tnum += 10 + *str-'a';\n\t\telse if (*str >= 'A' && *str <= 'F')\n\t\t\tnum += 10 + *str-'A';\n\t\telse\n\t\t\tError (\"Bad hex number: %s\",hex);\n\t\tstr++;\n\t}\n\n\treturn num;\n}\n\n\nint ParseNum (const char *str)\n{\n\tif (str[0] == '$')\n\t\treturn ParseHex (str+1);\n\tif (str[0] == '0' && str[1] == 'x')\n\t\treturn ParseHex (str+2);\n\treturn atol (str);\n}\n\n\n\n/*\n============================================================================\n\n\t\t\t\t\tBYTE ORDER FUNCTIONS\n\n============================================================================\n*/\n\n#ifdef _SGI_SOURCE\n#define\t__BIG_ENDIAN__\n#endif\n\n#ifdef __BIG_ENDIAN__\n\nshort   LittleShort (short l)\n{\n\tbyte    b1,b2;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\n\treturn (b1<<8) + b2;\n}\n\nshort   BigShort (short l)\n{\n\treturn l;\n}\n\n\nint    LittleLong (int l)\n{\n\tbyte    b1,b2,b3,b4;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\tb3 = (l>>16)&255;\n\tb4 = (l>>24)&255;\n\n\treturn ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;\n}\n\nint    BigLong (int l)\n{\n\treturn l;\n}\n\n\nfloat\tLittleFloat (float l)\n{\n\tunion {byte b[4]; float f;} in, out;\n\t\n\tin.f = l;\n\tout.b[0] = in.b[3];\n\tout.b[1] = in.b[2];\n\tout.b[2] = in.b[1];\n\tout.b[3] = in.b[0];\n\t\n\treturn out.f;\n}\n\nfloat\tBigFloat (float l)\n{\n\treturn l;\n}\n\n\n#else\n\n\nshort   BigShort (short l)\n{\n\tbyte    b1,b2;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\n\treturn (b1<<8) + b2;\n}\n\nshort   LittleShort (short l)\n{\n\treturn l;\n}\n\n\nint    BigLong (int l)\n{\n\tbyte    b1,b2,b3,b4;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\tb3 = (l>>16)&255;\n\tb4 = (l>>24)&255;\n\n\treturn ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;\n}\n\nint    LittleLong (int l)\n{\n\treturn l;\n}\n\nfloat\tBigFloat (float l)\n{\n\tunion {byte b[4]; float f;} in, out;\n\t\n\tin.f = l;\n\tout.b[0] = in.b[3];\n\tout.b[1] = in.b[2];\n\tout.b[2] = in.b[1];\n\tout.b[3] = in.b[0];\n\t\n\treturn out.f;\n}\n\nfloat\tLittleFloat (float l)\n{\n\treturn l;\n}\n\n\n#endif\n\n\n//=======================================================\n\n\n// FIXME: byte swap?\n\n// this is a 16 bit, non-reflected CRC using the polynomial 0x1021\n// and the initial and final xor values shown below...  in other words, the\n// CCITT standard CRC used by XMODEM\n\n#define CRC_INIT_VALUE\t0xffff\n#define CRC_XOR_VALUE\t0x0000\n\nstatic unsigned short crctable[256] =\n{\n\t0x0000,\t0x1021,\t0x2042,\t0x3063,\t0x4084,\t0x50a5,\t0x60c6,\t0x70e7,\n\t0x8108,\t0x9129,\t0xa14a,\t0xb16b,\t0xc18c,\t0xd1ad,\t0xe1ce,\t0xf1ef,\n\t0x1231,\t0x0210,\t0x3273,\t0x2252,\t0x52b5,\t0x4294,\t0x72f7,\t0x62d6,\n\t0x9339,\t0x8318,\t0xb37b,\t0xa35a,\t0xd3bd,\t0xc39c,\t0xf3ff,\t0xe3de,\n\t0x2462,\t0x3443,\t0x0420,\t0x1401,\t0x64e6,\t0x74c7,\t0x44a4,\t0x5485,\n\t0xa56a,\t0xb54b,\t0x8528,\t0x9509,\t0xe5ee,\t0xf5cf,\t0xc5ac,\t0xd58d,\n\t0x3653,\t0x2672,\t0x1611,\t0x0630,\t0x76d7,\t0x66f6,\t0x5695,\t0x46b4,\n\t0xb75b,\t0xa77a,\t0x9719,\t0x8738,\t0xf7df,\t0xe7fe,\t0xd79d,\t0xc7bc,\n\t0x48c4,\t0x58e5,\t0x6886,\t0x78a7,\t0x0840,\t0x1861,\t0x2802,\t0x3823,\n\t0xc9cc,\t0xd9ed,\t0xe98e,\t0xf9af,\t0x8948,\t0x9969,\t0xa90a,\t0xb92b,\n\t0x5af5,\t0x4ad4,\t0x7ab7,\t0x6a96,\t0x1a71,\t0x0a50,\t0x3a33,\t0x2a12,\n\t0xdbfd,\t0xcbdc,\t0xfbbf,\t0xeb9e,\t0x9b79,\t0x8b58,\t0xbb3b,\t0xab1a,\n\t0x6ca6,\t0x7c87,\t0x4ce4,\t0x5cc5,\t0x2c22,\t0x3c03,\t0x0c60,\t0x1c41,\n\t0xedae,\t0xfd8f,\t0xcdec,\t0xddcd,\t0xad2a,\t0xbd0b,\t0x8d68,\t0x9d49,\n\t0x7e97,\t0x6eb6,\t0x5ed5,\t0x4ef4,\t0x3e13,\t0x2e32,\t0x1e51,\t0x0e70,\n\t0xff9f,\t0xefbe,\t0xdfdd,\t0xcffc,\t0xbf1b,\t0xaf3a,\t0x9f59,\t0x8f78,\n\t0x9188,\t0x81a9,\t0xb1ca,\t0xa1eb,\t0xd10c,\t0xc12d,\t0xf14e,\t0xe16f,\n\t0x1080,\t0x00a1,\t0x30c2,\t0x20e3,\t0x5004,\t0x4025,\t0x7046,\t0x6067,\n\t0x83b9,\t0x9398,\t0xa3fb,\t0xb3da,\t0xc33d,\t0xd31c,\t0xe37f,\t0xf35e,\n\t0x02b1,\t0x1290,\t0x22f3,\t0x32d2,\t0x4235,\t0x5214,\t0x6277,\t0x7256,\n\t0xb5ea,\t0xa5cb,\t0x95a8,\t0x8589,\t0xf56e,\t0xe54f,\t0xd52c,\t0xc50d,\n\t0x34e2,\t0x24c3,\t0x14a0,\t0x0481,\t0x7466,\t0x6447,\t0x5424,\t0x4405,\n\t0xa7db,\t0xb7fa,\t0x8799,\t0x97b8,\t0xe75f,\t0xf77e,\t0xc71d,\t0xd73c,\n\t0x26d3,\t0x36f2,\t0x0691,\t0x16b0,\t0x6657,\t0x7676,\t0x4615,\t0x5634,\n\t0xd94c,\t0xc96d,\t0xf90e,\t0xe92f,\t0x99c8,\t0x89e9,\t0xb98a,\t0xa9ab,\n\t0x5844,\t0x4865,\t0x7806,\t0x6827,\t0x18c0,\t0x08e1,\t0x3882,\t0x28a3,\n\t0xcb7d,\t0xdb5c,\t0xeb3f,\t0xfb1e,\t0x8bf9,\t0x9bd8,\t0xabbb,\t0xbb9a,\n\t0x4a75,\t0x5a54,\t0x6a37,\t0x7a16,\t0x0af1,\t0x1ad0,\t0x2ab3,\t0x3a92,\n\t0xfd2e,\t0xed0f,\t0xdd6c,\t0xcd4d,\t0xbdaa,\t0xad8b,\t0x9de8,\t0x8dc9,\n\t0x7c26,\t0x6c07,\t0x5c64,\t0x4c45,\t0x3ca2,\t0x2c83,\t0x1ce0,\t0x0cc1,\n\t0xef1f,\t0xff3e,\t0xcf5d,\t0xdf7c,\t0xaf9b,\t0xbfba,\t0x8fd9,\t0x9ff8,\n\t0x6e17,\t0x7e36,\t0x4e55,\t0x5e74,\t0x2e93,\t0x3eb2,\t0x0ed1,\t0x1ef0\n};\n\nvoid CRC_Init(unsigned short *crcvalue)\n{\n\t*crcvalue = CRC_INIT_VALUE;\n}\n\nvoid CRC_ProcessByte(unsigned short *crcvalue, byte data)\n{\n\t*crcvalue = (*crcvalue << 8) ^ crctable[(*crcvalue >> 8) ^ data];\n}\n\nunsigned short CRC_Value(unsigned short crcvalue)\n{\n\treturn crcvalue ^ CRC_XOR_VALUE;\n}\n//=============================================================================\n\n/*\n============\nCreatePath\n============\n*/\nvoid\tCreatePath (const char *path)\n{\n\tconst char\t*ofs;\n\tchar\t\tc;\n\tchar\t\tdir[1024];\n\n#ifdef _WIN32\n\tint\t\tolddrive = -1;\n\n\tif ( path[1] == ':' )\n\t{\n\t\tolddrive = _getdrive();\n\t\t_chdrive( toupper( path[0] ) - 'A' + 1 );\n\t}\n#endif\n\n\tif (path[1] == ':')\n\t\tpath += 2;\n\n\tfor (ofs = path+1 ; *ofs ; ofs++)\n\t{\n\t\tc = *ofs;\n\t\tif (c == '/' || c == '\\\\')\n\t\t{\t// create the directory\n\t\t\tmemcpy( dir, path, ofs - path );\n\t\t\tdir[ ofs - path ] = 0;\n\t\t\tQ_mkdir( dir );\n\t\t}\n\t}\n\n#ifdef _WIN32\n\tif ( olddrive != -1 )\n\t{\n\t\t_chdrive( olddrive );\n\t}\n#endif\n}\n\n\n/*\n============\nQCopyFile\n\n  Used to archive source files\n============\n*/\nvoid QCopyFile (const char *from, const char *to)\n{\n\tvoid\t*buffer;\n\tint\t\tlength;\n\n\tlength = LoadFile (from, &buffer);\n\tCreatePath (to);\n\tSaveFile (to, buffer, length);\n\tfree (buffer);\n}\n"
  },
  {
    "path": "q3asm/cmdlib.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// cmdlib.h\n\n#ifndef __CMDLIB__\n#define __CMDLIB__\n\n#ifdef _WIN32\n#pragma warning(disable : 4244)     // MIPS\n#pragma warning(disable : 4136)     // X86\n#pragma warning(disable : 4051)     // ALPHA\n\n#pragma warning(disable : 4018)     // signed/unsigned mismatch\n#pragma warning(disable : 4305)     // truncate from double to float\n\n#pragma check_stack(off)\n\n#endif\n\n#include <stdio.h>\n#include <string.h>\n#include <stdlib.h>\n#include <errno.h>\n#include <ctype.h>\n#include <time.h>\n#include <stdarg.h>\n\n#ifdef _WIN32\n\n#pragma intrinsic( memset, memcpy )\n\n#endif\n\n#ifndef __BYTEBOOL__\n#define __BYTEBOOL__\ntypedef enum { qfalse, qtrue } qboolean;\ntypedef unsigned char byte;\n#endif\n\n#define\tMAX_OS_PATH\t\t1024\n#define MEM_BLOCKSIZE 4096\n\n// the dec offsetof macro doesnt work very well...\n#define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier)\n\n\n// set these before calling CheckParm\nextern int myargc;\nextern char **myargv;\n\nchar *strupr (char *in);\nchar *strlower (char *in);\nint Q_strncasecmp( const char *s1, const char *s2, int n );\nint Q_stricmp( const char *s1, const char *s2 );\nvoid Q_getwd( char *out );\n\nint Q_filelength (FILE *f);\nint\tFileTime( const char *path );\n\nvoid\tQ_mkdir( const char *path );\n\nextern\tchar\t\tqdir[1024];\nextern\tchar\t\tgamedir[1024];\nextern  char\t\twritedir[1024];\nvoid SetQdirFromPath( const char *path );\nchar *ExpandArg( const char *path );\t// from cmd line\nchar *ExpandPath( const char *path );\t// from scripts\nchar *ExpandGamePath (const char *path);\nchar *ExpandPathAndArchive( const char *path );\n\n\ndouble I_FloatTime( void );\n\nvoid\tError( const char *error, ... );\nint\t\tCheckParm( const char *check );\n\nFILE\t*SafeOpenWrite( const char *filename );\nFILE\t*SafeOpenRead( const char *filename );\nvoid\tSafeRead (FILE *f, void *buffer, int count);\nvoid\tSafeWrite (FILE *f, const void *buffer, int count);\n\nint\t\tLoadFile( const char *filename, void **bufferptr );\nint   LoadFileBlock( const char *filename, void **bufferptr );\nint\t\tTryLoadFile( const char *filename, void **bufferptr );\nvoid\tSaveFile( const char *filename, const void *buffer, int count );\nqboolean\tFileExists( const char *filename );\n\nvoid \tDefaultExtension( char *path, const char *extension );\nvoid \tDefaultPath( char *path, const char *basepath );\nvoid \tStripFilename( char *path );\nvoid \tStripExtension( char *path );\n\nvoid \tExtractFilePath( const char *path, char *dest );\nvoid \tExtractFileBase( const char *path, char *dest );\nvoid\tExtractFileExtension( const char *path, char *dest );\n\nint \tParseNum (const char *str);\n\nshort\tBigShort (short l);\nshort\tLittleShort (short l);\nint\t\tBigLong (int l);\nint\t\tLittleLong (int l);\nfloat\tBigFloat (float l);\nfloat\tLittleFloat (float l);\n\n\nchar *COM_Parse (char *data);\n\nextern\tchar\t\tcom_token[1024];\nextern\tqboolean\tcom_eof;\n\nchar *copystring(const char *s);\n\n\nvoid CRC_Init(unsigned short *crcvalue);\nvoid CRC_ProcessByte(unsigned short *crcvalue, byte data);\nunsigned short CRC_Value(unsigned short crcvalue);\n\nvoid\tCreatePath( const char *path );\nvoid\tQCopyFile( const char *from, const char *to );\n\nextern\tqboolean\t\tarchive;\nextern\tchar\t\t\tarchivedir[1024];\n\n\nextern\tqboolean verbose;\nvoid qprintf( const char *format, ... );\nvoid _printf( const char *format, ... );\n\nvoid ExpandWildcards( int *argc, char ***argv );\n\n\n// for compression routines\ntypedef struct\n{\n\tvoid\t*data;\n\tint\t\tcount, width, height;\n} cblock_t;\n\n\n#endif\n"
  },
  {
    "path": "q3asm/lib.txt",
    "content": "\nstrlen\nstrcasecmp\ntolower\nstrcat\nstrncpy\nstrcmp\nstrcpy\nstrchr\n\nvsprintf\n\nmemcpy\nmemset\nrand\n\natoi\natof\n\nabs\n\nfloor\nfabs\ntan\natan\nsqrt\nlog\ncos\nsin\natan2\n\n"
  },
  {
    "path": "q3asm/mathlib.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __MATHLIB__\n#define __MATHLIB__\n\n// mathlib.h\n\n#include <math.h>\n\n#ifdef DOUBLEVEC_T\ntypedef double vec_t;\n#else\ntypedef float vec_t;\n#endif\ntypedef vec_t vec2_t[3];\ntypedef vec_t vec3_t[3];\ntypedef vec_t vec4_t[4];\n\n#define\tSIDE_FRONT\t\t0\n#define\tSIDE_ON\t\t\t2\n#define\tSIDE_BACK\t\t1\n#define\tSIDE_CROSS\t\t-2\n\n#define\tQ_PI\t3.14159265358979323846\n#define DEG2RAD( a ) ( ( (a) * Q_PI ) / 180.0F )\n#define RAD2DEG( a ) ( ( (a) * 180.0f ) / Q_PI )\n\nextern vec3_t vec3_origin;\n\n#define\tEQUAL_EPSILON\t0.001\n\n// plane types are used to speed some tests\n// 0-2 are axial planes\n#define\tPLANE_X\t\t\t0\n#define\tPLANE_Y\t\t\t1\n#define\tPLANE_Z\t\t\t2\n#define\tPLANE_NON_AXIAL\t3\n\nqboolean VectorCompare( const vec3_t v1, const vec3_t v2 );\n\n#define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])\n#define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];}\n#define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];}\n#define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];}\n#define VectorScale(a,b,c) {c[0]=b*a[0];c[1]=b*a[1];c[2]=b*a[2];}\n#define VectorClear(x) {x[0] = x[1] = x[2] = 0;}\n#define\tVectorNegate(x) {x[0]=-x[0];x[1]=-x[1];x[2]=-x[2];}\nvoid Vec10Copy( vec_t *in, vec_t *out );\n\nvec_t Q_rint (vec_t in);\nvec_t _DotProduct (vec3_t v1, vec3_t v2);\nvoid _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out);\nvoid _VectorAdd (vec3_t va, vec3_t vb, vec3_t out);\nvoid _VectorCopy (vec3_t in, vec3_t out);\nvoid _VectorScale (vec3_t v, vec_t scale, vec3_t out);\n\ndouble VectorLength( const vec3_t v );\n\nvoid VectorMA( const vec3_t va, double scale, const vec3_t vb, vec3_t vc );\n\nvoid CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross );\nvec_t VectorNormalize( const vec3_t in, vec3_t out );\nvec_t ColorNormalize( const vec3_t in, vec3_t out );\nvoid VectorInverse (vec3_t v);\n\nvoid ClearBounds (vec3_t mins, vec3_t maxs);\nvoid AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs );\n\nqboolean PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const vec3_t c );\n\nvoid NormalToLatLong( const vec3_t normal, byte bytes[2] );\n\nint\tPlaneTypeForNormal (vec3_t normal);\n\n#endif\n"
  },
  {
    "path": "q3asm/notes.txt",
    "content": "\ndon't do any paramter conversion (double to float, etc)\n\n\n\nWhy?\n\nSecurity.\nPortability.\n\nIt may be more aproachable.\n\ncan still use regular dlls for development purposes\n\nlcc\nq3asm\n"
  },
  {
    "path": "q3asm/ops.txt",
    "content": "CNSTF,\nCNSTI,\nCNSTP,\nCNSTU,\n\nARGB,\nARGF,\nARGI,\nARGP,\nARGU,\n\nASGNB,\nASGNF,\nASGNI,\nASGNP,\nASGNU,\n\nINDIRB,\nINDIRF,\nINDIRI,\nINDIRP,\nINDIRU,\n\nCVFF,\nCVFI,\n\nCVIF,\nCVII,\nCVIU,\n\nCVPU,\n\nCVUI,\nCVUP,\nCVUU,\n\nNEGF,\nNEGI,\n\nCALLB,\nCALLF,\nCALLI,\nCALLP,\nCALLU,\nCALLV,\n\nRETF,\nRETI,\nRETP,\nRETU,\nRETV,\n\nADDRGP,\n\nADDRFP,\n\nADDRLP,\n\nADDF,\nADDI,\nADDP,\nADDU,\n\nSUBF,\nSUBI,\nSUBP,\nSUBU,\n\nLSHI,\nLSHU,\n\nMODI,\nMODU,\n\nRSHI,\nRSHU,\n\nBANDI,\nBANDU,\n\nBCOMI,\nBCOMU,\n\nBORI,\nBORU,\n\nBXORI,\nBXORU,\n\nDIVF,\nDIVI,\nDIVU,\n\nMULF,\nMULI,\nMULU,\n\nEQF,\nEQI,\nEQU,\n\nGEF,\nGEI,\nGEU,\n\nGTF,\nGTI,\nGTU,\n\nLEF,\nLEI,\nLEU,\n\nLTF,\nLTI,\nLTU,\n\nNEF,\nNEI,\nNEU,\n\nJUMPV,\n\nLABELV,\n\nLOADB,\nLOADF,\nLOADI,\nLOADP,\nLOADU,\n\n\n"
  },
  {
    "path": "q3asm/opstrings.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n{ \"BREAK\", OP_BREAK },\n\n{ \"CNSTF4\", OP_CONST },\n{ \"CNSTI4\", OP_CONST },\n{ \"CNSTP4\", OP_CONST },\n{ \"CNSTU4\", OP_CONST },\n\n{ \"CNSTI2\", OP_CONST },\n{ \"CNSTU2\", OP_CONST },\n\n{ \"CNSTI1\", OP_CONST },\n{ \"CNSTU1\", OP_CONST },\n\n//{ \"ARGB\", OP_ARG },\n//{ \"ARGF\", OP_ARG },\n//{ \"ARGI\", OP_ARG },\n//{ \"ARGP\", OP_ARG },\n//{ \"ARGU\", OP_ARG },\n\n{ \"ASGNB\", \tOP_BLOCK_COPY },\n{ \"ASGNF4\", OP_STORE4 },\n{ \"ASGNI4\", OP_STORE4 },\n{ \"ASGNP4\", OP_STORE4 },\n{ \"ASGNU4\", OP_STORE4 },\n\n{ \"ASGNI2\", OP_STORE2 },\n{ \"ASGNU2\", OP_STORE2 },\n\n{ \"ASGNI1\", OP_STORE1 },\n{ \"ASGNU1\", OP_STORE1 },\n\n{ \"INDIRB\", OP_IGNORE },\t// block copy deals with this\n{ \"INDIRF4\", OP_LOAD4 },\n{ \"INDIRI4\", OP_LOAD4 },\n{ \"INDIRP4\", OP_LOAD4 },\n{ \"INDIRU4\", OP_LOAD4 },\n\n{ \"INDIRI2\", OP_LOAD2 },\n{ \"INDIRU2\", OP_LOAD2 },\n\n{ \"INDIRI1\", OP_LOAD1 },\n{ \"INDIRU1\", OP_LOAD1 },\n\n{ \"CVFF4\", OP_UNDEF },\n{ \"CVFI4\", OP_CVFI },\n\n{ \"CVIF4\", OP_CVIF },\n{ \"CVII4\", OP_SEX8 },\t// will be either SEX8 or SEX16\n{ \"CVII1\", OP_IGNORE },\n{ \"CVII2\", OP_IGNORE },\n{ \"CVIU4\", OP_IGNORE },\n\n{ \"CVPU4\", OP_IGNORE },\n\n{ \"CVUI4\", OP_IGNORE },\n{ \"CVUP4\", OP_IGNORE },\n{ \"CVUU4\", OP_IGNORE },\n\n{ \"CVUU1\", OP_IGNORE },\n\n{ \"NEGF4\", OP_NEGF },\n{ \"NEGI4\", OP_NEGI },\n\n//{ \"CALLB\", OP_UNDEF },\n//{ \"CALLF\", OP_UNDEF },\n//{ \"CALLI\", OP_UNDEF },\n//{ \"CALLP\", OP_UNDEF },\n//{ \"CALLU\", OP_UNDEF },\n//{ \"CALLV\", OP_CALL },\n\n//{ \"RETF\", OP_UNDEF },\n//{ \"RETI\", OP_UNDEF },\n//{ \"RETP\", OP_UNDEF },\n//{ \"RETU\", OP_UNDEF },\n//{ \"RETV\", OP_UNDEF },\n\n{ \"ADDRGP4\", OP_CONST },\n\n//{ \"ADDRFP\", OP_PARM },\n//{ \"ADDRLP\", OP_LOCAL },\n\n{ \"ADDF4\", OP_ADDF },\n{ \"ADDI4\", OP_ADD },\n{ \"ADDP4\", OP_ADD },\n{ \"ADDP\", OP_ADD },\n{ \"ADDU4\", OP_ADD },\n\n{ \"SUBF4\", OP_SUBF },\n{ \"SUBI4\", OP_SUB },\n{ \"SUBP4\", OP_SUB },\n{ \"SUBU4\", OP_SUB },\n\n{ \"LSHI4\", OP_LSH },\n{ \"LSHU4\", OP_LSH },\n\n{ \"MODI4\", OP_MODI },\n{ \"MODU4\", OP_MODU },\n\n{ \"RSHI4\", OP_RSHI },\n{ \"RSHU4\", OP_RSHU },\n\n{ \"BANDI4\", OP_BAND },\n{ \"BANDU4\", OP_BAND },\n\n{ \"BCOMI4\", OP_BCOM },\n{ \"BCOMU4\", OP_BCOM },\n\n{ \"BORI4\", OP_BOR },\n{ \"BORU4\", OP_BOR },\n\n{ \"BXORI4\", OP_BXOR },\n{ \"BXORU4\", OP_BXOR },\n\n{ \"DIVF4\", OP_DIVF },\n{ \"DIVI4\", OP_DIVI },\n{ \"DIVU4\", OP_DIVU },\n\n{ \"MULF4\", OP_MULF },\n{ \"MULI4\", OP_MULI },\n{ \"MULU4\", OP_MULU },\n\n{ \"EQF4\", OP_EQF },\n{ \"EQI4\", OP_EQ },\n{ \"EQU4\", OP_EQ },\n\n{ \"GEF4\", OP_GEF },\n{ \"GEI4\", OP_GEI },\n{ \"GEU4\", OP_GEU },\n\n{ \"GTF4\", OP_GTF },\n{ \"GTI4\", OP_GTI },\n{ \"GTU4\", OP_GTU },\n\n{ \"LEF4\", OP_LEF },\n{ \"LEI4\", OP_LEI },\n{ \"LEU4\", OP_LEU },\n\n{ \"LTF4\", OP_LTF },\n{ \"LTI4\", OP_LTI },\n{ \"LTU4\", OP_LTU },\n\n{ \"NEF4\", OP_NEF },\n{ \"NEI4\", OP_NE },\n{ \"NEU4\", OP_NE },\n\n{ \"JUMPV\", OP_JUMP },\n\n{ \"LOADB4\", OP_UNDEF },\n{ \"LOADF4\", OP_UNDEF },\n{ \"LOADI4\", OP_UNDEF },\n{ \"LOADP4\", OP_UNDEF },\n{ \"LOADU4\", OP_UNDEF },\n\n\n"
  },
  {
    "path": "q3asm/q3asm.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"cmdlib.h\"\n#include \"mathlib.h\"\n#include \"qfiles.h\"\n\n/* MSVC-ism fix. */\n#define atoi(s) strtoul(s,NULL,10)\n\nchar\toutputFilename[MAX_OS_PATH];\n\n// the zero page size is just used for detecting run time faults\n#define\tZERO_PAGE_SIZE\t0\t\t// 256\n\ntypedef enum {\n\tOP_UNDEF, \n\n\tOP_IGNORE, \n\n\tOP_BREAK, \n\n\tOP_ENTER,\n\tOP_LEAVE,\n\tOP_CALL,\n\tOP_PUSH,\n\tOP_POP,\n\n\tOP_CONST,\n\tOP_LOCAL,\n\n\tOP_JUMP,\n\n\t//-------------------\n\n\tOP_EQ,\n\tOP_NE,\n\n\tOP_LTI,\n\tOP_LEI,\n\tOP_GTI,\n\tOP_GEI,\n\n\tOP_LTU,\n\tOP_LEU,\n\tOP_GTU,\n\tOP_GEU,\n\n\tOP_EQF,\n\tOP_NEF,\n\n\tOP_LTF,\n\tOP_LEF,\n\tOP_GTF,\n\tOP_GEF,\n\n\t//-------------------\n\n\tOP_LOAD1,\n\tOP_LOAD2,\n\tOP_LOAD4,\n\tOP_STORE1,\n\tOP_STORE2,\n\tOP_STORE4,\t\t\t\t// *(stack[top-1]) = stack[yop\n\tOP_ARG,\n\tOP_BLOCK_COPY,\n\n\t//-------------------\n\n\tOP_SEX8,\n\tOP_SEX16,\n\n\tOP_NEGI,\n\tOP_ADD,\n\tOP_SUB,\n\tOP_DIVI,\n\tOP_DIVU,\n\tOP_MODI,\n\tOP_MODU,\n\tOP_MULI,\n\tOP_MULU,\n\n\tOP_BAND,\n\tOP_BOR,\n\tOP_BXOR,\n\tOP_BCOM,\n\n\tOP_LSH,\n\tOP_RSHI,\n\tOP_RSHU,\n\n\tOP_NEGF,\n\tOP_ADDF,\n\tOP_SUBF,\n\tOP_DIVF,\n\tOP_MULF,\n\n\tOP_CVIF,\n\tOP_CVFI\n} opcode_t;\n\ntypedef struct {\n\tint\t\timageBytes;\t\t// after decompression\n\tint\t\tentryPoint;\n\tint\t\tstackBase;\n\tint\t\tstackSize;\n} executableHeader_t;\n\ntypedef enum {\n\tCODESEG,\n\tDATASEG,\t// initialized 32 bit data, will be byte swapped\n\tLITSEG,\t\t// strings\n\tBSSSEG,\t\t// 0 filled\n\tNUM_SEGMENTS\n} segmentName_t;\n\n#define\tMAX_IMAGE\t0x400000\n\ntypedef struct {\n\tbyte\timage[MAX_IMAGE];\n\tint\t\timageUsed;\n\tint\t\tsegmentBase;\t\t// only valid on second pass\n} segment_t;\n\ntypedef struct symbol_s {\n\tstruct\tsymbol_s\t*next;\n\tint\t\thash;\n\tsegment_t\t*segment;\n\tchar\t*name;\n\tint\t\tvalue;\n} symbol_t;\n\n\nsegment_t\tsegment[NUM_SEGMENTS];\nsegment_t\t*currentSegment;\n\nint\t\tpassNumber;\n\nint\t\tnumSymbols;\nint\t\terrorCount;\n\nsymbol_t\t*symbols;\nsymbol_t\t*lastSymbol;\n\n\n#define\tMAX_ASM_FILES\t256\nint\t\tnumAsmFiles;\nchar\t*asmFiles[MAX_ASM_FILES];\nchar\t*asmFileNames[MAX_ASM_FILES];\n\nint\t\tcurrentFileIndex;\nchar\t*currentFileName;\nint\t\tcurrentFileLine;\n\n//int\t\tstackSize = 16384;\nint\t\tstackSize = 0x10000;\n\n// we need to convert arg and ret instructions to\n// stores to the local stack frame, so we need to track the\n// characteristics of the current functions stack frame\nint\t\tcurrentLocals;\t\t\t// bytes of locals needed by this function\nint\t\tcurrentArgs;\t\t\t// bytes of largest argument list called from this function\nint\t\tcurrentArgOffset;\t\t// byte offset in currentArgs to store next arg, reset each call\n\n#define\tMAX_LINE_LENGTH\t1024\nchar\tlineBuffer[MAX_LINE_LENGTH];\nint\t\tlineParseOffset;\nchar\ttoken[MAX_LINE_LENGTH];\n\nint\t\tinstructionCount;\n\ntypedef struct {\n\tchar\t*name;\n\tint\t\topcode;\n} sourceOps_t;\n\nsourceOps_t\t\tsourceOps[] = {\n#include \"opstrings.h\"\n};\n\n#define\tNUM_SOURCE_OPS ( sizeof( sourceOps ) / sizeof( sourceOps[0] ) )\n\nint\t\topcodesHash[ NUM_SOURCE_OPS ];\n\n\n/*\n=============\nHashString\n=============\n*/\nint\tHashString( char *s ) {\n\tint\t\tv = 0;\n\n\twhile ( *s ) {\n\t\tv += *s;\n\t\ts++;\n\t}\n\treturn v;\n}\n\n\n/*\n============\nCodeError\n============\n*/\nvoid CodeError( char *fmt, ... ) {\n\tva_list\t\targptr;\n\n\terrorCount++;\n\n\tprintf( \"%s:%i \", currentFileName, currentFileLine );\n\n\tva_start( argptr,fmt );\n\tvprintf( fmt,argptr );\n\tva_end( argptr );\n}\n\n/*\n============\nEmitByte\n============\n*/\nvoid EmitByte( segment_t *seg, int v ) {\n\tif ( seg->imageUsed >= MAX_IMAGE ) {\n\t\tError( \"MAX_IMAGE\" );\n\t}\n\tseg->image[ seg->imageUsed ] = v;\n\tseg->imageUsed++;\n}\n\n/*\n============\nEmitInt\n============\n*/\nvoid EmitInt( segment_t *seg, int v ) {\n\tif ( seg->imageUsed >= MAX_IMAGE - 4) {\n\t\tError( \"MAX_IMAGE\" );\n\t}\n\tseg->image[ seg->imageUsed ] = v & 255;\n\tseg->image[ seg->imageUsed + 1 ] = ( v >> 8 ) & 255;\n\tseg->image[ seg->imageUsed + 2 ] = ( v >> 16 ) & 255;\n\tseg->image[ seg->imageUsed + 3 ] = ( v >> 24 ) & 255;\n\tseg->imageUsed += 4;\n}\n\n/*\n============\nDefineSymbol\n\nSymbols can only be defined on pass 0\n============\n*/\nvoid DefineSymbol( char *sym, int value ) {\n\tsymbol_t\t*s, *after;\n\tchar\t\texpanded[MAX_LINE_LENGTH];\n\tint\t\t\thash;\n\n\tif ( passNumber == 1 ) {\n\t\treturn;\n\t}\n  \n  // TTimo\n  // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=381\n  // as a security, bail out if vmMain entry point is not first\n  if (!Q_stricmp(sym, \"vmMain\"))\n    if (value)\n      Error( \"vmMain must be the first symbol in the qvm (got offset %d)\\n\", value );\n\n\t// add the file prefix to local symbols to guarantee unique\n\tif ( sym[0] == '$' ) {\n\t\tsprintf( expanded, \"%s_%i\", sym, currentFileIndex );\n\t\tsym = expanded;\n\t}\n\n\thash = HashString( sym );\n\n\tfor ( s = symbols ; s ; s = s->next ) {\n\t\tif ( hash == s->hash && !strcmp( sym, s->name ) ) {\n\t\t\tCodeError( \"Multiple definitions for %s\\n\", sym );\n\t\t\treturn;\n\t\t}\n\t}\n\n\ts = malloc( sizeof( *s ) );\n\ts->name = copystring( sym );\n\ts->hash = hash;\n\ts->value = value;\n\ts->segment = currentSegment;\n\n\tlastSymbol = s;\t/* for the move-to-lit-segment byteswap hack */\n\n\t// insert it in order\n\tif ( !symbols || s->value < symbols->value ) {\n\t\ts->next = symbols;\n\t\tsymbols = s;\n\t\treturn;\n\t}\n\n\tfor ( after = symbols ; after->next && after->next->value < value ; after = after->next ) {\n\t}\n\ts->next = after->next;\n\tafter->next = s;\n}\n\n\n/*\n============\nLookupSymbol\n\nSymbols can only be evaluated on pass 1\n============\n*/\nint LookupSymbol( char *sym ) {\n\tsymbol_t\t*s;\n\tchar\t\texpanded[MAX_LINE_LENGTH];\n\tint\t\t\thash;\n\n\tif ( passNumber == 0 ) {\n\t\treturn 0;\n\t}\n\n\t// add the file prefix to local symbols to guarantee unique\n\tif ( sym[0] == '$' ) {\n\t\tsprintf( expanded, \"%s_%i\", sym, currentFileIndex );\n\t\tsym = expanded;\n\t}\n\n\thash = HashString( sym );\n\tfor ( s = symbols ; s ; s = s->next ) {\n\t\tif ( hash == s->hash && !strcmp( sym, s->name ) ) {\n\t\t\treturn s->segment->segmentBase + s->value;\n\t\t}\n\t}\n\n\tCodeError( \"ERROR: symbol %s undefined\\n\", sym );\n\tpassNumber = 0;\n\tDefineSymbol( sym, 0 );\t// so more errors aren't printed\n\tpassNumber = 1;\n\treturn 0;\n}\n\n\n/*\n==============\nExtractLine\n\nExtracts the next line from the given text block.\nIf a full line isn't parsed, returns NULL\nOtherwise returns the updated parse pointer\n===============\n*/\nchar *ExtractLine( char *data ) {\n\tint\t\t\ti;\n\n\tcurrentFileLine++;\n\tlineParseOffset = 0;\n\ttoken[0] = 0;\n\n\tif ( data[0] == 0 ) {\n\t\tlineBuffer[0] = 0;\n\t\treturn NULL;\n\t}\n\n\tfor ( i = 0 ; i < MAX_LINE_LENGTH ; i++ ) {\n\t\tif ( data[i] == 0 || data[i] == '\\n' ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif ( i == MAX_LINE_LENGTH ) {\n\t\tCodeError( \"MAX_LINE_LENGTH\" );\n\t\treturn data;\n\t}\n\tmemcpy( lineBuffer, data, i );\n\tlineBuffer[i] = 0;\n\tdata += i;\n\tif ( data[0] == '\\n' ) {\n\t\tdata++;\n\t}\n\treturn data;\n}\n\n\n/*\n==============\nParse\n\nParse a token out of linebuffer\n==============\n*/\nqboolean Parse( void ) {\n\tint\t\tc;\n\tint\t\tlen;\n\t\n\tlen = 0;\n\ttoken[0] = 0;\n\t\n\t// skip whitespace\n\twhile ( lineBuffer[ lineParseOffset ] <= ' ' ) {\n\t\tif ( lineBuffer[ lineParseOffset ] == 0 ) {\n\t\t\treturn qfalse;\n\t\t}\n\t\tlineParseOffset++;\n\t}\n\n\t// skip ; comments\n\tc = lineBuffer[ lineParseOffset ];\n\tif ( c == ';' ) {\n\t\treturn qfalse;\n\t}\n\t\n\n\t// parse a regular word\n\tdo {\n\t\ttoken[len] = c;\n\t\tlen++;\n\t\tlineParseOffset++;\n\t\tc = lineBuffer[ lineParseOffset ];\n\t} while (c>32);\n\t\n\ttoken[len] = 0;\n\treturn qtrue;\n}\n\n\n/*\n==============\nParseValue\n==============\n*/\nint\tParseValue( void ) {\n\tParse();\n\treturn atoi( token );\n}\n\n\n/*\n==============\nParseExpression\n==============\n*/\nint\tParseExpression(void) {\n\tint\t\ti, j;\n\tchar\tsym[MAX_LINE_LENGTH];\n\tint\t\tv;\n\n\tif ( token[0] == '-' ) {\n\t\ti = 1;\n\t} else {\n\t\ti = 0;\n\t}\n\n\tfor ( ; i < MAX_LINE_LENGTH ; i++ ) {\n\t\tif ( token[i] == '+' || token[i] == '-' || token[i] == 0 ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tmemcpy( sym, token, i );\n\tsym[i] = 0;\n\n\tif ( ( sym[0] >= '0' && sym[0] <= '9' ) || sym[0] == '-' ) {\n\t\tv = atoi( sym );\n\t} else {\n\t\tv = LookupSymbol( sym );\n\t}\n\n\t// parse add / subtract offsets\n\twhile ( token[i] != 0 ) {\n\t\tfor ( j = i + 1 ; j < MAX_LINE_LENGTH ; j++ ) {\n\t\t\tif ( token[j] == '+' || token[j] == '-' || token[j] == 0 ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tmemcpy( sym, token+i+1, j-i-1 );\n\t\tsym[j-i-1] = 0;\n\n\t\tif ( token[i] == '+' ) {\n\t\t\tv += atoi( sym );\n\t\t}\n\t\tif ( token[i] == '-' ) {\n\t\t\tv -= atoi( sym );\n\t\t}\n\t\ti = j;\n\t}\n\n\treturn v;\n}\n\n\n/*\n==============\nHackToSegment\n\nBIG HACK: I want to put all 32 bit values in the data\nsegment so they can be byte swapped, and all char data in the lit\nsegment, but switch jump tables are emited in the lit segment and\ninitialized strng variables are put in the data segment.\n\nI can change segments here, but I also need to fixup the\nlabel that was just defined\n\nNote that the lit segment is read-write in the VM, so strings\naren't read only as in some architectures.\n==============\n*/\nvoid HackToSegment( segmentName_t seg ) {\n\tif ( currentSegment == &segment[seg] ) {\n\t\treturn;\n\t}\n\n\tcurrentSegment = &segment[seg];\n\tif ( passNumber == 0 ) {\n\t\tlastSymbol->segment = currentSegment;\n\t\tlastSymbol->value = currentSegment->imageUsed;\n\t}\n}\n\n/*\n==============\nAssembleLine\n\n==============\n*/\nvoid AssembleLine( void ) {\n\tint\t\tv, v2;\n\tint\t\ti;\n\tint\t\thash;\n\n\tParse();\n\tif ( !token[0] ) {\n\t\treturn;\n\t}\n\n\thash = HashString( token );\n\n\tfor ( i = 0 ; i < NUM_SOURCE_OPS ; i++ ) {\n\t\tif ( hash == opcodesHash[i] && !strcmp( token, sourceOps[i].name ) ) {\n\t\t\tint\t\topcode;\n\t\t\tint\t\texpression;\n\n\t\t\tif ( sourceOps[i].opcode == OP_UNDEF ) {\n\t\t\t\tCodeError( \"Undefined opcode: %s\\n\", token );\n\t\t\t}\n\t\t\tif ( sourceOps[i].opcode == OP_IGNORE ) {\n\t\t\t\treturn;\t\t// we ignore most conversions\n\t\t\t}\n\n\t\t\t// sign extensions need to check next parm\n\t\t\topcode = sourceOps[i].opcode;\n\t\t\tif ( opcode == OP_SEX8 ) {\n\t\t\t\tParse();\n\t\t\t\tif ( token[0] == '1' ) {\n\t\t\t\t\topcode = OP_SEX8;\n\t\t\t\t} else if ( token[0] == '2' ) {\n\t\t\t\t\topcode = OP_SEX16;\n\t\t\t\t} else {\n\t\t\t\t\tCodeError( \"Bad sign extension: %s\\n\", token );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// check for expression\n\t\t\tParse();\n\t\t\tif ( token[0] && sourceOps[i].opcode != OP_CVIF\n\t\t\t\t\t&& sourceOps[i].opcode != OP_CVFI ) {\n\t\t\t\texpression = ParseExpression();\n\n\t\t\t\t// code like this can generate non-dword block copies:\n\t\t\t\t// auto char buf[2] = \" \";\n\t\t\t\t// we are just going to round up.  This might conceivably\n\t\t\t\t// be incorrect if other initialized chars follow.\n\t\t\t\tif ( opcode == OP_BLOCK_COPY ) {\n\t\t\t\t\texpression = ( expression + 3 ) & ~3;\n\t\t\t\t}\n\n\t\t\t\tEmitByte( &segment[CODESEG], opcode );\n\t\t\t\tEmitInt( &segment[CODESEG], expression );\n\t\t\t} else {\n\t\t\t\tEmitByte( &segment[CODESEG], opcode );\n\t\t\t}\n\n\t\t\tinstructionCount++;\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// call instructions reset currentArgOffset\n\tif ( !strncmp( token, \"CALL\", 4 ) ) {\n\t\tEmitByte( &segment[CODESEG], OP_CALL );\n\t\tinstructionCount++;\n\t\tcurrentArgOffset = 0;\n\t\treturn;\n\t}\n\n\t// arg is converted to a reversed store\n\tif ( !strncmp( token, \"ARG\", 3 ) ) {\n\t\tEmitByte( &segment[CODESEG], OP_ARG );\n\t\tinstructionCount++;\n\t\tif ( 8 + currentArgOffset >= 256 ) {\n\t\t\tCodeError( \"currentArgOffset >= 256\" );\n\t\t\treturn;\n\t\t}\n\t\tEmitByte( &segment[CODESEG], 8 + currentArgOffset );\n\t\tcurrentArgOffset += 4;\n\t\treturn;\n\t}\n\n\t// ret just leaves something on the op stack\n\tif ( !strncmp( token, \"RET\", 3 ) ) {\n\t\tEmitByte( &segment[CODESEG], OP_LEAVE );\n\t\tinstructionCount++;\n\t\tEmitInt( &segment[CODESEG], 8 + currentLocals + currentArgs );\n\t\treturn;\n\t}\n\n\t// pop is needed to discard the return value of \n\t// a function\n\tif ( !strncmp( token, \"pop\", 3 ) ) {\n\t\tEmitByte( &segment[CODESEG], OP_POP );\n\t\tinstructionCount++;\n\t\treturn;\n\t}\n\n\t// address of a parameter is converted to OP_LOCAL\n\tif ( !strncmp( token, \"ADDRF\", 5 ) ) {\n\t\tinstructionCount++;\n\t\tParse();\n\t\tv = ParseExpression();\n\t\tv = 16 + currentArgs + currentLocals + v;\n\t\tEmitByte( &segment[CODESEG], OP_LOCAL );\n\t\tEmitInt( &segment[CODESEG], v );\n\t\treturn;\n\t}\n\n\t// address of a local is converted to OP_LOCAL\n\tif ( !strncmp( token, \"ADDRL\", 5 ) ) {\n\t\tinstructionCount++;\n\t\tParse();\n\t\tv = ParseExpression();\n\t\tv = 8 + currentArgs + v;\n\t\tEmitByte( &segment[CODESEG], OP_LOCAL );\n\t\tEmitInt( &segment[CODESEG], v );\n\t\treturn;\n\t}\n\n\tif ( !strcmp( token, \"proc\" ) ) {\n\t\tchar\tname[1024];\n\n\t\tParse();\t\t\t\t\t// function name\n\t\tstrcpy( name, token );\n\n\t\tDefineSymbol( token, instructionCount ); // segment[CODESEG].imageUsed );\n\n\t\tcurrentLocals = ParseValue();\t// locals\n\t\tcurrentLocals = ( currentLocals + 3 ) & ~3;\n\t\tcurrentArgs = ParseValue();\t\t// arg marshalling\n\t\tcurrentArgs = ( currentArgs + 3 ) & ~3;\n\n\t\tif ( 8 + currentLocals + currentArgs >= 32767 ) {\n\t\t\tCodeError( \"Locals > 32k in %s\\n\", name );\n\t\t}\n\n\t\tinstructionCount++;\n\t\tEmitByte( &segment[CODESEG], OP_ENTER );\n\t\tEmitInt( &segment[CODESEG], 8 + currentLocals + currentArgs );\n\t\treturn;\n\t}\n\tif ( !strcmp( token, \"endproc\" ) ) {\n\t\tParse();\t\t\t\t// skip the function name\n\t\tv = ParseValue();\t\t// locals\n\t\tv2 = ParseValue();\t\t// arg marshalling\n\n\t\t// all functions must leave something on the opstack\n\t\tinstructionCount++;\n\t\tEmitByte( &segment[CODESEG], OP_PUSH );\n\n\t\tinstructionCount++;\n\t\tEmitByte( &segment[CODESEG], OP_LEAVE );\n\t\tEmitInt( &segment[CODESEG], 8 + currentLocals + currentArgs );\n\n\t\treturn;\n\t}\n\n\n\tif ( !strcmp( token, \"address\" ) ) {\n\t\tParse();\n\t\tv = ParseExpression();\n\n\t\tHackToSegment( DATASEG );\n\t\tEmitInt( currentSegment, v );\n\t\treturn;\n\t}\n\tif ( !strcmp( token, \"export\" ) ) {\n\t\treturn;\n\t}\n\tif ( !strcmp( token, \"import\" ) ) {\n\t\treturn;\n\t}\n\tif ( !strcmp( token, \"code\" ) ) {\n\t\tcurrentSegment = &segment[CODESEG];\n\t\treturn;\n\t}\n\tif ( !strcmp( token, \"bss\" ) ) {\n\t\tcurrentSegment = &segment[BSSSEG];\n\t\treturn;\n\t}\n\tif ( !strcmp( token, \"data\" ) ) {\n\t\tcurrentSegment = &segment[DATASEG];\n\t\treturn;\n\t}\n\tif ( !strcmp( token, \"lit\" ) ) {\n\t\tcurrentSegment = &segment[LITSEG];\n\t\treturn;\n\t}\n\tif ( !strcmp( token, \"line\" ) ) {\n\t\treturn;\n\t}\n\tif ( !strcmp( token, \"file\" ) ) {\n\t\treturn;\n\t}\n\n\tif ( !strcmp( token, \"equ\" ) ) {\n\t\tchar\tname[1024];\n\n\t\tParse();\n\t\tstrcpy( name, token );\n\t\tParse();\n\t\tDefineSymbol( name, atoi(token) );\n\t\treturn;\n\t}\n\n\tif ( !strcmp( token, \"align\" ) ) {\n\t\tv = ParseValue();\n\t\tcurrentSegment->imageUsed = (currentSegment->imageUsed + v - 1 ) & ~( v - 1 );\n\t\treturn;\n\t}\n\n\tif ( !strcmp( token, \"skip\" ) ) {\n\t\tv = ParseValue();\n\t\tcurrentSegment->imageUsed += v;\n\t\treturn;\n\t}\n\n\tif ( !strcmp( token, \"byte\" ) ) {\n\t\tv = ParseValue();\n\t\tv2 = ParseValue();\n\n\t\tif ( v == 1 ) {\n\t\t\tHackToSegment( LITSEG );\n\t\t} else if ( v == 4 ) {\n\t\t\tHackToSegment( DATASEG );\n\t\t} else if ( v == 2 ) {\n\t\t\tCodeError( \"16 bit initialized data not supported\" );\n\t\t}\n\n\t\t// emit little endien\n\t\tfor ( i = 0 ; i < v ; i++ ) {\n\t\t\tEmitByte( currentSegment, v2 );\n\t\t\tv2 >>= 8;\n\t\t}\n\t\treturn;\n\t}\n\n\t// code labels are emited as instruction counts, not byte offsets,\n\t// because the physical size of the code will change with\n\t// different run time compilers and we want to minimize the\n\t// size of the required translation table\n\tif ( !strncmp( token, \"LABEL\", 5 ) ) {\n\t\tParse();\n\t\tif ( currentSegment == &segment[CODESEG] ) {\n\t\t\tDefineSymbol( token, instructionCount );\n\t\t} else {\n\t\t\tDefineSymbol( token, currentSegment->imageUsed );\n\t\t}\n\t\treturn;\n\t}\n\n\tCodeError( \"Unknown token: %s\\n\", token );\n}\n\n/*\n==============\nInitTables\n==============\n*/\nvoid InitTables( void ) {\n\tint\t\ti;\n\n\tfor ( i = 0 ; i < NUM_SOURCE_OPS ; i++ ) {\n\t\topcodesHash[i] = HashString( sourceOps[i].name );\n\t}\n}\n\n\n/*\n==============\nWriteMapFile\n==============\n*/\nvoid WriteMapFile( void ) {\n\tFILE\t\t*f;\n\tsymbol_t\t*s;\n\tchar\t\timageName[MAX_OS_PATH];\n\tint\t\t\tseg;\n\n\tstrcpy( imageName, outputFilename );\n\tStripExtension( imageName );\n\tstrcat( imageName, \".map\" );\n\n\tprintf( \"Writing %s...\\n\", imageName );\n\tf = SafeOpenWrite( imageName );\n\tfor ( seg = CODESEG ; seg <= BSSSEG ; seg++ ) {\n\t\tfor ( s = symbols ; s ; s = s->next ) {\n\t\t\tif ( s->name[0] == '$' ) {\n\t\t\t\tcontinue;\t// skip locals\n\t\t\t}\n\t\t\tif ( &segment[seg] != s->segment ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfprintf( f, \"%i %8x %s\\n\", seg, s->value, s->name );\n\t\t}\n\t}\n\tfclose( f );\n}\n\n/*\n===============\nWriteVmFile\n===============\n*/\nvoid WriteVmFile( void ) {\n\tchar\timageName[MAX_OS_PATH];\n\tvmHeader_t\theader;\n\tFILE\t*f;\n\n\tprintf( \"%i total errors\\n\", errorCount );\n\tstrcpy( imageName, outputFilename );\n\tStripExtension( imageName );\n\tstrcat( imageName, \".qvm\" );\n\n\tremove( imageName );\n\n\tprintf( \"code segment: %7i\\n\", segment[CODESEG].imageUsed );\n\tprintf( \"data segment: %7i\\n\", segment[DATASEG].imageUsed );\n\tprintf( \"lit  segment: %7i\\n\", segment[LITSEG].imageUsed );\n\tprintf( \"bss  segment: %7i\\n\", segment[BSSSEG].imageUsed );\n\tprintf( \"instruction count: %i\\n\", instructionCount );\n\tif ( errorCount != 0 ) {\n\t\tprintf( \"Not writing a file due to errors\\n\" );\n\t\treturn;\n\t}\n\n\theader.vmMagic = VM_MAGIC;\n\theader.instructionCount = instructionCount;\n\theader.codeOffset = sizeof( header );\n\theader.codeLength = segment[CODESEG].imageUsed;\n\theader.dataOffset = header.codeOffset + segment[CODESEG].imageUsed;\n\theader.dataLength = segment[DATASEG].imageUsed;\n\theader.litLength = segment[LITSEG].imageUsed;\n\theader.bssLength = segment[BSSSEG].imageUsed;\n\n\tprintf( \"Writing to %s\\n\", imageName );\n\n\tCreatePath( imageName );\n\tf = SafeOpenWrite( imageName );\n\tSafeWrite( f, &header, sizeof( header ) );\n\tSafeWrite( f, &segment[CODESEG].image, segment[CODESEG].imageUsed );\n\tSafeWrite( f, &segment[DATASEG].image, segment[DATASEG].imageUsed );\n\tSafeWrite( f, &segment[LITSEG].image, segment[LITSEG].imageUsed );\n\tfclose( f );\n}\n\n/*\n===============\nAssemble\n===============\n*/\nvoid Assemble( void ) {\n\tint\t\ti;\n\tchar\tfilename[MAX_OS_PATH];\n\tchar\t\t*ptr;\n\n\tprintf( \"outputFilename: %s\\n\", outputFilename );\n\n\tfor ( i = 0 ; i < numAsmFiles ; i++ ) {\n\t\tstrcpy( filename, asmFileNames[ i ] );\n\t\tDefaultExtension( filename, \".asm\" );\n\t\tLoadFile( filename, (void **)&asmFiles[i] );\n\t}\n\n\t// assemble\n\tfor ( passNumber = 0 ; passNumber < 2 ; passNumber++ ) {\n\t\tsegment[LITSEG].segmentBase = segment[DATASEG].imageUsed;\n\t\tsegment[BSSSEG].segmentBase = segment[LITSEG].segmentBase + segment[LITSEG].imageUsed;\n\t\tfor ( i = 0 ; i < NUM_SEGMENTS ; i++ ) {\n\t\t\tsegment[i].imageUsed = 0;\n\t\t}\n\t\tsegment[DATASEG].imageUsed = 4;\t\t// skip the 0 byte, so NULL pointers are fixed up properly\n\t\tinstructionCount = 0;\n\n\t\tfor ( i = 0 ; i < numAsmFiles ; i++ ) {\n\t\t\tcurrentFileIndex = i;\n\t\t\tcurrentFileName = asmFileNames[ i ];\n\t\t\tcurrentFileLine = 0;\n\t\t\tprintf(\"pass %i: %s\\n\", passNumber, currentFileName );\n\t\t\tptr = asmFiles[i];\n\t\t\twhile ( ptr ) {\n\t\t\t\tptr = ExtractLine( ptr );\n\t\t\t\tAssembleLine();\n\t\t\t}\n\t\t}\n\n\t\t// align all segment\n\t\tfor ( i = 0 ; i < NUM_SEGMENTS ; i++ ) {\n\t\t\tsegment[i].imageUsed = (segment[i].imageUsed + 3) & ~3;\n\t\t}\n\t}\n\n\t// reserve the stack in bss\n\tDefineSymbol( \"_stackStart\", segment[BSSSEG].imageUsed );\n\tsegment[BSSSEG].imageUsed += stackSize;\n\tDefineSymbol( \"_stackEnd\", segment[BSSSEG].imageUsed );\n\n\t// write the image\n\tWriteVmFile();\n\n\t// write the map file even if there were errors\n\tWriteMapFile();\n}\n\n\n/*\n=============\nParseOptionFile\n\n=============\n*/\nvoid ParseOptionFile( const char *filename ) {\n\tchar\t\texpanded[MAX_OS_PATH];\n\tchar\t\t*text, *text_p;\n\n\tstrcpy( expanded, filename );\n\tDefaultExtension( expanded, \".q3asm\" );\n\tLoadFile( expanded, (void **)&text );\n\tif ( !text ) {\n\t\treturn;\n\t}\n\n\ttext_p = text;\n\n\twhile( ( text_p = COM_Parse( text_p ) ) != 0 ) {\n\t\tif ( !strcmp( com_token, \"-o\" ) ) {\n\t\t\t// allow output override in option file\n\t\t\ttext_p = COM_Parse( text_p );\n\t\t\tif ( text_p ) {\n\t\t\t\tstrcpy( outputFilename, com_token );\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tasmFileNames[ numAsmFiles ] = copystring( com_token );\n\t\tnumAsmFiles++;\n\t}\n}\n\n/*\n==============\nmain\n==============\n*/\nint main( int argc, char **argv ) {\n\tint\t\t\ti;\n\tdouble\t\tstart, end;\n\n//\t_chdir( \"/quake3/jccode/cgame/lccout\" );\t// hack for vc profiler\n\n\tif ( argc < 2 ) {\n\t\tError( \"usage: q3asm [-o output] <files> or q3asm -f <listfile>\\n\" );\n\t}\n\n\tstart = I_FloatTime ();\n\tInitTables();\n\n\t// default filename is \"q3asm\"\n\tstrcpy( outputFilename, \"q3asm\" );\n\tnumAsmFiles = 0;\t\n\n\tfor ( i = 1 ; i < argc ; i++ ) {\n\t\tif ( argv[i][0] != '-' ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( !strcmp( argv[i], \"-o\" ) ) {\n\t\t\tif ( i == argc - 1 ) {\n\t\t\t\tError( \"-o must preceed a filename\" );\n\t\t\t}\n\t\t\tstrcpy( outputFilename, argv[ i+1 ] );\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( !strcmp( argv[i], \"-f\" ) ) {\n\t\t\tif ( i == argc - 1 ) {\n\t\t\t\tError( \"-f must preceed a filename\" );\n\t\t\t}\n\t\t\tParseOptionFile( argv[ i+1 ] );\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tError( \"Unknown option: %s\", argv[i] );\n\t}\n\n\t// the rest of the command line args are asm files\n\tfor ( ; i < argc ; i++ ) {\n\t\tasmFileNames[ numAsmFiles ] = copystring( argv[ i ] );\n\t\tnumAsmFiles++;\n\t}\n\n\tAssemble();\n\n\tend = I_FloatTime ();\n\tprintf (\"%5.0f seconds elapsed\\n\", end-start);\n\n\treturn 0;\n}\n\n"
  },
  {
    "path": "q3asm/q3asm.sln",
    "content": "Microsoft Visual Studio Solution File, Format Version 8.00\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"q3asm\", \"q3asm.vcproj\", \"{E0D6B319-6F95-4ABA-9BE0-5454CAA5C8CD}\"\n\tProjectSection(ProjectDependencies) = postProject\n\tEndProjectSection\nEndProject\nGlobal\n\tGlobalSection(SourceCodeControl) = preSolution\n\t\tSccNumberOfProjects = 1\n\t\tSccProjectUniqueName0 = q3asm.vcproj\n\t\tSccProjectName0 = \\u0022$/source/q3asm\\u0022,\\u0020YUCAAAAA\n\t\tSccLocalPath0 = .\n\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM\n\tEndGlobalSection\n\tGlobalSection(SolutionConfiguration) = preSolution\n\t\tDebug = Debug\n\t\tRelease = Release\n\tEndGlobalSection\n\tGlobalSection(ProjectConfiguration) = postSolution\n\t\t{E0D6B319-6F95-4ABA-9BE0-5454CAA5C8CD}.Debug.ActiveCfg = Debug|Win32\n\t\t{E0D6B319-6F95-4ABA-9BE0-5454CAA5C8CD}.Debug.Build.0 = Debug|Win32\n\t\t{E0D6B319-6F95-4ABA-9BE0-5454CAA5C8CD}.Release.ActiveCfg = Release|Win32\n\t\t{E0D6B319-6F95-4ABA-9BE0-5454CAA5C8CD}.Release.Build.0 = Release|Win32\n\tEndGlobalSection\n\tGlobalSection(ExtensibilityGlobals) = postSolution\n\tEndGlobalSection\n\tGlobalSection(ExtensibilityAddIns) = postSolution\n\tEndGlobalSection\nEndGlobal\n"
  },
  {
    "path": "q3asm/q3asm.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<VisualStudioProject\n\tProjectType=\"Visual C++\"\n\tVersion=\"7.10\"\n\tName=\"q3asm\"\n\tSccProjectName=\"&quot;$/source/q3asm&quot;, YUCAAAAA\"\n\tSccLocalPath=\".\">\n\t<Platforms>\n\t\t<Platform\n\t\t\tName=\"Win32\"/>\n\t</Platforms>\n\t<Configurations>\n\t\t<Configuration\n\t\t\tName=\"Release|Win32\"\n\t\t\tOutputDirectory=\".\\Release\"\n\t\t\tIntermediateDirectory=\".\\Release\"\n\t\t\tConfigurationType=\"1\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tAdditionalIncludeDirectories=\"../common\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_CONSOLE\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"4\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release/q3asm.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release/\"\n\t\t\t\tObjectFile=\".\\Release/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tCompileAs=\"0\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tOutputFile=\".\\Release/q3asm.exe\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\Release/q3asm.pdb\"\n\t\t\t\tSubSystem=\"1\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tTypeLibraryName=\".\\Release/q3asm.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Debug|Win32\"\n\t\t\tOutputDirectory=\".\\Debug\"\n\t\t\tIntermediateDirectory=\".\\Debug\"\n\t\t\tConfigurationType=\"1\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tAdditionalIncludeDirectories=\"../common\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_CONSOLE\"\n\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\tRuntimeLibrary=\"5\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Debug/q3asm.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug/\"\n\t\t\t\tObjectFile=\".\\Debug/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Debug/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"\n\t\t\t\tCompileAs=\"0\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tOutputFile=\".\\Debug/q3asm.exe\"\n\t\t\t\tLinkIncremental=\"2\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\Debug/q3asm.pdb\"\n\t\t\t\tSubSystem=\"1\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tTypeLibraryName=\".\\Debug/q3asm.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t</Configurations>\n\t<References>\n\t</References>\n\t<Files>\n\t\t<Filter\n\t\t\tName=\"Source Files\"\n\t\t\tFilter=\"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"cmdlib.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"q3asm.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Header Files\"\n\t\t\tFilter=\"h;hpp;hxx;hm;inl\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"..\\common\\cmdlib.h\">\n\t\t\t</File>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Resource Files\"\n\t\t\tFilter=\"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\">\n\t\t</Filter>\n\t</Files>\n\t<Globals>\n\t</Globals>\n</VisualStudioProject>\n"
  },
  {
    "path": "q3asm/qfiles.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __QFILES_H__\n#define __QFILES_H__\n\n//\n// qfiles.h: quake file formats\n// This file must be identical in the quake and utils directories\n//\n\n// surface geometry should not exceed these limits\n#define\tSHADER_MAX_VERTEXES\t1000\n#define\tSHADER_MAX_INDEXES\t(6*SHADER_MAX_VERTEXES)\n\n\n// the maximum size of game reletive pathnames\n#define\tMAX_QPATH\t\t64\n\n/*\n========================================================================\n\nQVM files\n\n========================================================================\n*/\n\n#define\tVM_MAGIC\t0x12721444\ntypedef struct {\n\tint\t\tvmMagic;\n\n\tint\t\tinstructionCount;\n\n\tint\t\tcodeOffset;\n\tint\t\tcodeLength;\n\n\tint\t\tdataOffset;\n\tint\t\tdataLength;\n\tint\t\tlitLength;\t\t\t// ( dataLength - litLength ) should be byteswapped on load\n\tint\t\tbssLength;\t\t\t// zero filled memory appended to datalength\n} vmHeader_t;\n\n\n/*\n========================================================================\n\nPCX files are used for 8 bit images\n\n========================================================================\n*/\n\ntypedef struct {\n    char\tmanufacturer;\n    char\tversion;\n    char\tencoding;\n    char\tbits_per_pixel;\n    unsigned short\txmin,ymin,xmax,ymax;\n    unsigned short\thres,vres;\n    unsigned char\tpalette[48];\n    char\treserved;\n    char\tcolor_planes;\n    unsigned short\tbytes_per_line;\n    unsigned short\tpalette_type;\n    char\tfiller[58];\n    unsigned char\tdata;\t\t\t// unbounded\n} pcx_t;\n\n\n/*\n========================================================================\n\nTGA files are used for 24/32 bit images\n\n========================================================================\n*/\n\ntypedef struct _TargaHeader {\n\tunsigned char \tid_length, colormap_type, image_type;\n\tunsigned short\tcolormap_index, colormap_length;\n\tunsigned char\tcolormap_size;\n\tunsigned short\tx_origin, y_origin, width, height;\n\tunsigned char\tpixel_size, attributes;\n} TargaHeader;\n\n\n\n/*\n========================================================================\n\n.MD3 triangle model file format\n\n========================================================================\n*/\n\n#define MD3_IDENT\t\t\t(('3'<<24)+('P'<<16)+('D'<<8)+'I')\n#define MD3_VERSION\t\t\t15\n\n// limits\n#define MD3_MAX_LODS\t\t3\n#define\tMD3_MAX_TRIANGLES\t8192\t// per surface\n#define MD3_MAX_VERTS\t\t4096\t// per surface\n#define MD3_MAX_SHADERS\t\t256\t\t// per surface\n#define MD3_MAX_FRAMES\t\t1024\t// per model\n#define\tMD3_MAX_SURFACES\t32\t\t// per model\n#define MD3_MAX_TAGS\t\t16\t\t// per frame\n\n// vertex scales\n#define\tMD3_XYZ_SCALE\t\t(1.0/64)\n\ntypedef struct md3Frame_s {\n\tvec3_t\t\tbounds[2];\n\tvec3_t\t\tlocalOrigin;\n\tfloat\t\tradius;\n\tchar\t\tname[16];\n} md3Frame_t;\n\ntypedef struct md3Tag_s {\n\tchar\t\tname[MAX_QPATH];\t// tag name\n\tvec3_t\t\torigin;\n\tvec3_t\t\taxis[3];\n} md3Tag_t;\n\n/*\n** md3Surface_t\n**\n** CHUNK\t\t\tSIZE\n** header\t\t\tsizeof( md3Surface_t )\n** shaders\t\t\tsizeof( md3Shader_t ) * numShaders\n** triangles[0]\t\tsizeof( md3Triangle_t ) * numTriangles\n** st\t\t\t\tsizeof( md3St_t ) * numVerts\n** XyzNormals\t\tsizeof( md3XyzNormal_t ) * numVerts * numFrames\n*/\ntypedef struct {\n\tint\t\tident;\t\t\t\t// \n\n\tchar\tname[MAX_QPATH];\t// polyset name\n\n\tint\t\tflags;\n\tint\t\tnumFrames;\t\t\t// all surfaces in a model should have the same\n\n\tint\t\tnumShaders;\t\t\t// all surfaces in a model should have the same\n\tint\t\tnumVerts;\n\n\tint\t\tnumTriangles;\n\tint\t\tofsTriangles;\n\n\tint\t\tofsShaders;\t\t\t// offset from start of md3Surface_t\n\tint\t\tofsSt;\t\t\t\t// texture coords are common for all frames\n\tint\t\tofsXyzNormals;\t\t// numVerts * numFrames\n\n\tint\t\tofsEnd;\t\t\t\t// next surface follows\n} md3Surface_t;\n\ntypedef struct {\n\tchar\t\t\tname[MAX_QPATH];\n\tint\t\t\t\tshaderIndex;\t// for in-game use\n} md3Shader_t;\n\ntypedef struct {\n\tint\t\t\tindexes[3];\n} md3Triangle_t;\n\ntypedef struct {\n\tfloat\t\tst[2];\n} md3St_t;\n\ntypedef struct {\n\tshort\t\txyz[3];\n\tshort\t\tnormal;\n} md3XyzNormal_t;\n\ntypedef struct {\n\tint\t\t\tident;\n\tint\t\t\tversion;\n\n\tchar\t\tname[MAX_QPATH];\t// model name\n\n\tint\t\t\tflags;\n\n\tint\t\t\tnumFrames;\n\tint\t\t\tnumTags;\t\t\t\n\tint\t\t\tnumSurfaces;\n\n\tint\t\t\tnumSkins;\n\n\tint\t\t\tofsFrames;\t\t\t// offset for first frame\n\tint\t\t\tofsTags;\t\t\t// numFrames * numTags\n\tint\t\t\tofsSurfaces;\t\t// first surface, others follow\n\n\tint\t\t\tofsEnd;\t\t\t\t// end of file\n} md3Header_t;\n\n/*\n==============================================================================\n\nMD4 file format\n\n==============================================================================\n*/\n\n#define MD4_IDENT\t\t\t(('4'<<24)+('P'<<16)+('D'<<8)+'I')\n#define MD4_VERSION\t\t\t1\n#define\tMD4_MAX_BONES\t\t128\n\ntypedef struct {\n\tint\t\t\tboneIndex;\t\t// these are indexes into the boneReferences,\n\tfloat\t\t   boneWeight;\t\t// not the global per-frame bone list\n\tvec3_t\t\toffset;\n} md4Weight_t;\n\ntypedef struct {\n\tvec3_t\t\tnormal;\n\tvec2_t\t\ttexCoords;\n\tint\t\t\tnumWeights;\n\tmd4Weight_t\tweights[1];\t\t// variable sized\n} md4Vertex_t;\n\ntypedef struct {\n\tint\t\t\tindexes[3];\n} md4Triangle_t;\n\ntypedef struct {\n\tint\t\t\tident;\n\n\tchar\t\tname[MAX_QPATH];\t// polyset name\n\tchar\t\tshader[MAX_QPATH];\n\tint\t\t\tshaderIndex;\t\t// for in-game use\n\n\tint\t\t\tofsHeader;\t\t\t// this will be a negative number\n\n\tint\t\t\tnumVerts;\n\tint\t\t\tofsVerts;\n\n\tint\t\t\tnumTriangles;\n\tint\t\t\tofsTriangles;\n\n\t// Bone references are a set of ints representing all the bones\n\t// present in any vertex weights for this surface.  This is\n\t// needed because a model may have surfaces that need to be\n\t// drawn at different sort times, and we don't want to have\n\t// to re-interpolate all the bones for each surface.\n\tint\t\t\tnumBoneReferences;\n\tint\t\t\tofsBoneReferences;\n\n\tint\t\t\tofsEnd;\t\t\t\t// next surface follows\n} md4Surface_t;\n\ntypedef struct {\n\tfloat\t\tmatrix[3][4];\n} md4Bone_t;\n\ntypedef struct {\n\tvec3_t\t\tbounds[2];\t\t\t// bounds of all surfaces of all LOD's for this frame\n\tvec3_t\t\tlocalOrigin;\t\t// midpoint of bounds, used for sphere cull\n\tfloat\t\tradius;\t\t\t\t// dist from localOrigin to corner\n\tchar\t\tname[16];\n\tmd4Bone_t\tbones[1];\t\t\t// [numBones]\n} md4Frame_t;\n\ntypedef struct {\n\tint\t\t\tnumSurfaces;\n\tint\t\t\tofsSurfaces;\t\t// first surface, others follow\n\tint\t\t\tofsEnd;\t\t\t\t// next lod follows\n} md4LOD_t;\n\ntypedef struct {\n\tint\t\t\tident;\n\tint\t\t\tversion;\n\n\tchar\t\tname[MAX_QPATH];\t// model name\n\n\t// frames and bones are shared by all levels of detail\n\tint\t\t\tnumFrames;\n\tint\t\t\tnumBones;\n\tint\t\t\tofsFrames;\t\t\t// md4Frame_t[numFrames]\n\n\t// each level of detail has completely separate sets of surfaces\n\tint\t\t\tnumLODs;\n\tint\t\t\tofsLODs;\n\n\tint\t\t\tofsEnd;\t\t\t\t// end of file\n} md4Header_t;\n\n\n/*\n==============================================================================\n\n  .BSP file format\n\n==============================================================================\n*/\n\n\n#define BSP_IDENT\t(('P'<<24)+('S'<<16)+('B'<<8)+'I')\n\t\t// little-endian \"IBSP\"\n\n#define BSP_VERSION\t\t\t46\n\n\n// there shouldn't be any problem with increasing these values at the\n// expense of more memory allocation in the utilities\n#define\tMAX_MAP_MODELS\t\t0x400\n#define\tMAX_MAP_BRUSHES\t\t0x8000\n#define\tMAX_MAP_ENTITIES\t0x800\n#define\tMAX_MAP_ENTSTRING\t0x40000\n#define\tMAX_MAP_SHADERS\t\t0x400\n\n#define\tMAX_MAP_AREAS\t\t0x100\t// MAX_MAP_AREA_BYTES in q_shared must match!\n#define\tMAX_MAP_FOGS\t\t0x100\n#define\tMAX_MAP_PLANES\t\t0x20000\n#define\tMAX_MAP_NODES\t\t0x20000\n#define\tMAX_MAP_BRUSHSIDES\t0x20000\n#define\tMAX_MAP_LEAFS\t\t0x20000\n#define\tMAX_MAP_LEAFFACES\t0x20000\n#define\tMAX_MAP_LEAFBRUSHES 0x40000\n#define\tMAX_MAP_PORTALS\t\t0x20000\n#define\tMAX_MAP_LIGHTING\t0x800000\n#define\tMAX_MAP_LIGHTGRID\t0x800000\n#define\tMAX_MAP_VISIBILITY\t0x200000\n\n#define\tMAX_MAP_DRAW_SURFS\t0x20000\n#define\tMAX_MAP_DRAW_VERTS\t0x80000\n#define\tMAX_MAP_DRAW_INDEXES\t0x80000\n\n\n// key / value pair sizes in the entities lump\n#define\tMAX_KEY\t\t\t\t32\n#define\tMAX_VALUE\t\t\t1024\n\n// the editor uses these predefined yaw angles to orient entities up or down\n#define\tANGLE_UP\t\t\t-1\n#define\tANGLE_DOWN\t\t\t-2\n\n#define\tLIGHTMAP_WIDTH\t\t128\n#define\tLIGHTMAP_HEIGHT\t\t128\n\n\n//=============================================================================\n\n\ntypedef struct {\n\tint\t\tfileofs, filelen;\n} lump_t;\n\n#define\tLUMP_ENTITIES\t\t0\n#define\tLUMP_SHADERS\t\t1\n#define\tLUMP_PLANES\t\t\t2\n#define\tLUMP_NODES\t\t\t3\n#define\tLUMP_LEAFS\t\t\t4\n#define\tLUMP_LEAFSURFACES\t5\n#define\tLUMP_LEAFBRUSHES\t6\n#define\tLUMP_MODELS\t\t\t7\n#define\tLUMP_BRUSHES\t\t8\n#define\tLUMP_BRUSHSIDES\t\t9\n#define\tLUMP_DRAWVERTS\t\t10\n#define\tLUMP_DRAWINDEXES\t11\n#define\tLUMP_FOGS\t\t\t12\n#define\tLUMP_SURFACES\t\t13\n#define\tLUMP_LIGHTMAPS\t\t14\n#define\tLUMP_LIGHTGRID\t\t15\n#define\tLUMP_VISIBILITY\t\t16\n#define\tHEADER_LUMPS\t\t17\n\ntypedef struct {\n\tint\t\t\tident;\n\tint\t\t\tversion;\n\n\tlump_t\t\tlumps[HEADER_LUMPS];\n} dheader_t;\n\ntypedef struct {\n\tfloat\t\tmins[3], maxs[3];\n\tint\t\t\tfirstSurface, numSurfaces;\n\tint\t\t\tfirstBrush, numBrushes;\n} dmodel_t;\n\ntypedef struct {\n\tchar\t\tshader[MAX_QPATH];\n\tint\t\t\tsurfaceFlags;\n\tint\t\t\tcontentFlags;\n} dshader_t;\n\n// planes x^1 is allways the opposite of plane x\n\ntypedef struct {\n\tfloat\t\tnormal[3];\n\tfloat\t\tdist;\n} dplane_t;\n\ntypedef struct {\n\tint\t\t\tplaneNum;\n\tint\t\t\tchildren[2];\t// negative numbers are -(leafs+1), not nodes\n\tint\t\t\tmins[3];\t\t// for frustom culling\n\tint\t\t\tmaxs[3];\n} dnode_t;\n\ntypedef struct {\n\tint\t\t\tcluster;\t\t\t// -1 = opaque cluster (do I still store these?)\n\tint\t\t\tarea;\n\n\tint\t\t\tmins[3];\t\t\t// for frustum culling\n\tint\t\t\tmaxs[3];\n\n\tint\t\t\tfirstLeafSurface;\n\tint\t\t\tnumLeafSurfaces;\n\n\tint\t\t\tfirstLeafBrush;\n\tint\t\t\tnumLeafBrushes;\n} dleaf_t;\n\ntypedef struct {\n\tint\t\t\tplaneNum;\t\t\t// positive plane side faces out of the leaf\n\tint\t\t\tshaderNum;\n} dbrushside_t;\n\ntypedef struct {\n\tint\t\t\tfirstSide;\n\tint\t\t\tnumSides;\n\tint\t\t\tshaderNum;\t\t// the shader that determines the contents flags\n} dbrush_t;\n\ntypedef struct {\n\tchar\t\tshader[MAX_QPATH];\n\tint\t\t\tbrushNum;\n\tint\t\t\tvisibleSide;\t// the brush side that ray tests need to clip against (-1 == none)\n} dfog_t;\n\ntypedef struct {\n\tvec3_t\t\txyz;\n\tfloat\t\tst[2];\n\tfloat\t\tlightmap[2];\n\tvec3_t\t\tnormal;\n\tbyte\t\tcolor[4];\n} drawVert_t;\n\ntypedef enum {\n\tMST_BAD,\n\tMST_PLANAR,\n\tMST_PATCH,\n\tMST_TRIANGLE_SOUP,\n\tMST_FLARE\n} mapSurfaceType_t;\n\ntypedef struct {\n\tint\t\t\tshaderNum;\n\tint\t\t\tfogNum;\n\tint\t\t\tsurfaceType;\n\n\tint\t\t\tfirstVert;\n\tint\t\t\tnumVerts;\n\n\tint\t\t\tfirstIndex;\n\tint\t\t\tnumIndexes;\n\n\tint\t\t\tlightmapNum;\n\tint\t\t\tlightmapX, lightmapY;\n\tint\t\t\tlightmapWidth, lightmapHeight;\n\n\tvec3_t\t\tlightmapOrigin;\n\tvec3_t\t\tlightmapVecs[3];\t// for patches, [0] and [1] are lodbounds\n\n\tint\t\t\tpatchWidth;\n\tint\t\t\tpatchHeight;\n} dsurface_t;\n\n\n#endif\n"
  },
  {
    "path": "q3map/brush.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"qbsp.h\"\n\n\nint\t\tc_active_brushes;\n\nint\t\tc_nodes;\n\n// if a brush just barely pokes onto the other side,\n// let it slide by without chopping\n#define\tPLANESIDE_EPSILON\t0.001\n//0.1\n\n\n\n\n/*\n================\nCountBrushList\n================\n*/\nint\tCountBrushList (bspbrush_t *brushes)\n{\n\tint\tc;\n\n\tc = 0;\n\tfor ( ; brushes ; brushes = brushes->next)\n\t\tc++;\n\treturn c;\n}\n\n\n/*\n================\nAllocBrush\n================\n*/\nbspbrush_t *AllocBrush (int numsides)\n{\n\tbspbrush_t\t*bb;\n\tint\t\t\tc;\n\n\tc = (int)&(((bspbrush_t *)0)->sides[numsides]);\n\tbb = malloc(c);\n\tmemset (bb, 0, c);\n\tif (numthreads == 1)\n\t\tc_active_brushes++;\n\treturn bb;\n}\n\n/*\n================\nFreeBrush\n================\n*/\nvoid FreeBrush (bspbrush_t *brushes)\n{\n\tint\t\t\ti;\n\n\tfor (i=0 ; i<brushes->numsides ; i++)\n\t\tif (brushes->sides[i].winding)\n\t\t\tFreeWinding(brushes->sides[i].winding);\n\tfree (brushes);\n\tif (numthreads == 1)\n\t\tc_active_brushes--;\n}\n\n\n/*\n================\nFreeBrushList\n================\n*/\nvoid FreeBrushList (bspbrush_t *brushes)\n{\n\tbspbrush_t\t*next;\n\n\tfor ( ; brushes ; brushes = next)\n\t{\n\t\tnext = brushes->next;\n\n\t\tFreeBrush (brushes);\n\t}\t\t\n}\n\n/*\n==================\nCopyBrush\n\nDuplicates the brush, the sides, and the windings\n==================\n*/\nbspbrush_t *CopyBrush (bspbrush_t *brush)\n{\n\tbspbrush_t *newbrush;\n\tint\t\t\tsize;\n\tint\t\t\ti;\n\t\n\tsize = (int)&(((bspbrush_t *)0)->sides[brush->numsides]);\n\n\tnewbrush = AllocBrush (brush->numsides);\n\tmemcpy (newbrush, brush, size);\n\n\tfor (i=0 ; i<brush->numsides ; i++)\n\t{\n\t\tif (brush->sides[i].winding)\n\t\t\tnewbrush->sides[i].winding = CopyWinding (brush->sides[i].winding);\n\t}\n\n\treturn newbrush;\n}\n\n\n/*\n================\nDrawBrushList\n================\n*/\nvoid DrawBrushList (bspbrush_t *brush)\n{\n\tint\t\ti;\n\tside_t\t*s;\n\n\tGLS_BeginScene ();\n\tfor ( ; brush ; brush=brush->next)\n\t{\n\t\tfor (i=0 ; i<brush->numsides ; i++)\n\t\t{\n\t\t\ts = &brush->sides[i];\n\t\t\tif (!s->winding)\n\t\t\t\tcontinue;\n\t\t\tGLS_Winding (s->winding, 0);\n\t\t}\n\t}\n\tGLS_EndScene ();\n}\n\n\n\n/*\n================\nWriteBrushList\n================\n*/\nvoid WriteBrushList (char *name, bspbrush_t *brush, qboolean onlyvis)\n{\n\tint\t\ti;\n\tside_t\t*s;\n\tFILE\t*f;\n\n\tqprintf (\"writing %s\\n\", name);\n\tf = SafeOpenWrite (name);\n\n\tfor ( ; brush ; brush=brush->next)\n\t{\n\t\tfor (i=0 ; i<brush->numsides ; i++)\n\t\t{\n\t\t\ts = &brush->sides[i];\n\t\t\tif (!s->winding)\n\t\t\t\tcontinue;\n\t\t\tif (onlyvis && !s->visible)\n\t\t\t\tcontinue;\n\t\t\tOutputWinding (brush->sides[i].winding, f);\n\t\t}\n\t}\n\n\tfclose (f);\n}\n\n\n/*\n=============\nPrintBrush\n=============\n*/\nvoid PrintBrush (bspbrush_t *brush)\n{\n\tint\t\ti;\n\n\t_printf (\"brush: %p\\n\", brush);\n\tfor (i=0;i<brush->numsides ; i++)\n\t{\n\t\tpw(brush->sides[i].winding);\n\t\t_printf (\"\\n\");\n\t}\n}\n\n/*\n==================\nBoundBrush\n\nSets the mins/maxs based on the windings\nreturns false if the brush doesn't enclose a valid volume\n==================\n*/\nqboolean BoundBrush (bspbrush_t *brush)\n{\n\tint\t\t\ti, j;\n\twinding_t\t*w;\n\n\tClearBounds (brush->mins, brush->maxs);\n\tfor (i=0 ; i<brush->numsides ; i++)\n\t{\n\t\tw = brush->sides[i].winding;\n\t\tif (!w)\n\t\t\tcontinue;\n\t\tfor (j=0 ; j<w->numpoints ; j++)\n\t\t\tAddPointToBounds (w->p[j], brush->mins, brush->maxs);\n\t}\n\n\tfor (i=0 ; i<3 ; i++) {\n\t\tif (brush->mins[i] < MIN_WORLD_COORD || brush->maxs[i] > MAX_WORLD_COORD\n\t\t\t|| brush->mins[i] >= brush->maxs[i] ) {\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\treturn qtrue;\n}\n\n/*\n==================\nCreateBrushWindings\n\nmakes basewindigs for sides and mins / maxs for the brush\nreturns false if the brush doesn't enclose a valid volume\n==================\n*/\nqboolean CreateBrushWindings (bspbrush_t *brush)\n{\n\tint\t\t\ti, j;\n\twinding_t\t*w;\n\tside_t\t\t*side;\n\tplane_t\t\t*plane;\n\n\tfor ( i = 0; i < brush->numsides; i++ )\n\t{\n\t\tside = &brush->sides[i];\n\t\t// don't create a winding for a bevel\n\t\tif ( side->bevel ) {\n\t\t\tcontinue;\n\t\t}\n\t\tplane = &mapplanes[side->planenum];\n\t\tw = BaseWindingForPlane (plane->normal, plane->dist);\n\t\tfor ( j = 0; j < brush->numsides && w; j++ )\n\t\t{\n\t\t\tif (i == j)\n\t\t\t\tcontinue;\n\t\t\tif ( brush->sides[j].planenum == ( brush->sides[i].planenum ^ 1 ) )\n\t\t\t\tcontinue;\t\t// back side clipaway\n\t\t\tif (brush->sides[j].bevel)\n\t\t\t\tcontinue;\n\t\t\tif (brush->sides[j].backSide)\n\t\t\t\tcontinue;\n\t\t\tplane = &mapplanes[brush->sides[j].planenum^1];\n\t\t\tChopWindingInPlace (&w, plane->normal, plane->dist, 0); //CLIP_EPSILON);\n\t\t}\n\t\t// free any existing winding\n\t\tif ( side->winding ) {\n\t\t\tFreeWinding( side->winding );\n\t\t}\n\t\tside->winding = w;\n\t}\n\n\treturn BoundBrush (brush);\n}\n\n/*\n==================\nBrushFromBounds\n\nCreates a new axial brush\n==================\n*/\nbspbrush_t\t*BrushFromBounds (vec3_t mins, vec3_t maxs)\n{\n\tbspbrush_t\t*b;\n\tint\t\t\ti;\n\tvec3_t\t\tnormal;\n\tvec_t\t\tdist;\n\n\tb = AllocBrush (6);\n\tb->numsides = 6;\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tVectorClear (normal);\n\t\tnormal[i] = 1;\n\t\tdist = maxs[i];\n\t\tb->sides[i].planenum = FindFloatPlane (normal, dist);\n\n\t\tnormal[i] = -1;\n\t\tdist = -mins[i];\n\t\tb->sides[3+i].planenum = FindFloatPlane (normal, dist);\n\t}\n\n\tCreateBrushWindings (b);\n\n\treturn b;\n}\n\n/*\n==================\nBrushVolume\n\n==================\n*/\nvec_t BrushVolume (bspbrush_t *brush)\n{\n\tint\t\t\ti;\n\twinding_t\t*w;\n\tvec3_t\t\tcorner;\n\tvec_t\t\td, area, volume;\n\tplane_t\t\t*plane;\n\n\tif (!brush)\n\t\treturn 0;\n\n\t// grab the first valid point as the corner\n\n\tw = NULL;\n\tfor (i=0 ; i<brush->numsides ; i++)\n\t{\n\t\tw = brush->sides[i].winding;\n\t\tif (w)\n\t\t\tbreak;\n\t}\n\tif (!w)\n\t\treturn 0;\n\tVectorCopy (w->p[0], corner);\n\n\t// make tetrahedrons to all other faces\n\n\tvolume = 0;\n\tfor ( ; i<brush->numsides ; i++)\n\t{\n\t\tw = brush->sides[i].winding;\n\t\tif (!w)\n\t\t\tcontinue;\n\t\tplane = &mapplanes[brush->sides[i].planenum];\n\t\td = -(DotProduct (corner, plane->normal) - plane->dist);\n\t\tarea = WindingArea (w);\n\t\tvolume += d*area;\n\t}\n\n\tvolume /= 3;\n\treturn volume;\n}\n\n\n/*\n==================\nWriteBspBrushMap\n==================\n*/\nvoid WriteBspBrushMap (char *name, bspbrush_t *list)\n{\n\tFILE\t*f;\n\tside_t\t*s;\n\tint\t\ti;\n\twinding_t\t*w;\n\n\t_printf (\"writing %s\\n\", name);\n\tf = fopen (name, \"wb\");\n\tif (!f)\n\t\tError (\"Can't write %s\\b\", name);\n\n\tfprintf (f, \"{\\n\\\"classname\\\" \\\"worldspawn\\\"\\n\");\n\n\tfor ( ; list ; list=list->next )\n\t{\n\t\tfprintf (f, \"{\\n\");\n\t\tfor (i=0,s=list->sides ; i<list->numsides ; i++,s++)\n\t\t{\n\t\t\tw = BaseWindingForPlane (mapplanes[s->planenum].normal, mapplanes[s->planenum].dist);\n\n\t\t\tfprintf (f,\"( %i %i %i ) \", (int)w->p[0][0], (int)w->p[0][1], (int)w->p[0][2]);\n\t\t\tfprintf (f,\"( %i %i %i ) \", (int)w->p[1][0], (int)w->p[1][1], (int)w->p[1][2]);\n\t\t\tfprintf (f,\"( %i %i %i ) \", (int)w->p[2][0], (int)w->p[2][1], (int)w->p[2][2]);\n\n\t\t\tfprintf (f, \"notexture 0 0 0 1 1\\n\" );\n\t\t\tFreeWinding (w);\n\t\t}\n\t\tfprintf (f, \"}\\n\");\n\t}\n\tfprintf (f, \"}\\n\");\n\n\tfclose (f);\n\n}\n\n\n//=====================================================================================\n\n/*\n====================\nFilterBrushIntoTree_r\n\n====================\n*/\nint FilterBrushIntoTree_r( bspbrush_t *b, node_t *node ) {\n\tbspbrush_t\t\t*front, *back;\n\tint\t\t\t\tc;\n\n\tif ( !b ) {\n\t\treturn 0;\n\t}\n\n\t// add it to the leaf list\n\tif ( node->planenum == PLANENUM_LEAF ) {\n\t\tb->next = node->brushlist;\n\t\tnode->brushlist = b;\n\n\t\t// classify the leaf by the structural brush\n\t\tif ( !b->detail ) {\n\t\t\tif ( b->opaque ) {\n\t\t\t\tnode->opaque = qtrue;\n\t\t\t\tnode->areaportal = qfalse;\n\t\t\t} else if ( b->contents & CONTENTS_AREAPORTAL ) {\n\t\t\t\tif ( !node->opaque ) {\n\t\t\t\t\tnode->areaportal = qtrue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn 1;\n\t}\n\n\t// split it by the node plane\n\tSplitBrush ( b, node->planenum, &front, &back );\n\tFreeBrush( b );\n\n\tc = 0;\n\tc += FilterBrushIntoTree_r( front, node->children[0] );\n\tc += FilterBrushIntoTree_r( back, node->children[1] );\n\n\treturn c;\n}\n\n/*\n=====================\nFilterDetailBrushesIntoTree\n\nFragment all the detail brushes into the structural leafs\n=====================\n*/\nvoid FilterDetailBrushesIntoTree( entity_t *e, tree_t *tree ) {\n\tbspbrush_t\t\t\t*b, *newb;\n\tint\t\t\t\t\tr;\n\tint\t\t\t\t\tc_unique, c_clusters;\n\tint\t\t\t\t\ti;\n\n\tqprintf( \"----- FilterDetailBrushesIntoTree -----\\n\");\n\n\tc_unique = 0;\n\tc_clusters = 0;\n\tfor ( b = e->brushes ; b ; b = b->next ) {\n\t\tif ( !b->detail ) {\n\t\t\tcontinue;\n\t\t}\n\t\tc_unique++;\n\t\tnewb = CopyBrush( b );\n\t\tr = FilterBrushIntoTree_r( newb, tree->headnode );\n\t\tc_clusters += r;\n\n\t\t// mark all sides as visible so drawsurfs are created\n\t\tif ( r ) {\n\t\t\tfor ( i = 0 ; i < b->numsides ; i++ ) {\n\t\t\t\tif ( b->sides[i].winding ) {\n\t\t\t\t\tb->sides[i].visible = qtrue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tqprintf( \"%5i detail brushes\\n\", c_unique );\n\tqprintf( \"%5i cluster references\\n\", c_clusters );\n}\n\n/*\n=====================\nFilterStructuralBrushesIntoTree\n\nMark the leafs as opaque and areaportals\n=====================\n*/\nvoid FilterStructuralBrushesIntoTree( entity_t *e, tree_t *tree ) {\n\tbspbrush_t\t\t\t*b, *newb;\n\tint\t\t\t\t\tr;\n\tint\t\t\t\t\tc_unique, c_clusters;\n\tint\t\t\t\t\ti;\n\n\tqprintf( \"----- FilterStructuralBrushesIntoTree -----\\n\");\n\n\tc_unique = 0;\n\tc_clusters = 0;\n\tfor ( b = e->brushes ; b ; b = b->next ) {\n\t\tif ( b->detail ) {\n\t\t\tcontinue;\n\t\t}\n\t\tc_unique++;\n\t\tnewb = CopyBrush( b );\n\t\tr = FilterBrushIntoTree_r( newb, tree->headnode );\n\t\tc_clusters += r;\n\n\t\t// mark all sides as visible so drawsurfs are created\n\t\tif ( r ) {\n\t\t\tfor ( i = 0 ; i < b->numsides ; i++ ) {\n\t\t\t\tif ( b->sides[i].winding ) {\n\t\t\t\t\tb->sides[i].visible = qtrue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tqprintf( \"%5i structural brushes\\n\", c_unique );\n\tqprintf( \"%5i cluster references\\n\", c_clusters );\n}\n\n\n\n/*\n================\nAllocTree\n================\n*/\ntree_t *AllocTree (void)\n{\n\ttree_t\t*tree;\n\n\ttree = malloc(sizeof(*tree));\n\tmemset (tree, 0, sizeof(*tree));\n\tClearBounds (tree->mins, tree->maxs);\n\n\treturn tree;\n}\n\n/*\n================\nAllocNode\n================\n*/\nnode_t *AllocNode (void)\n{\n\tnode_t\t*node;\n\n\tnode = malloc(sizeof(*node));\n\tmemset (node, 0, sizeof(*node));\n\n\treturn node;\n}\n\n\n/*\n================\nWindingIsTiny\n\nReturns true if the winding would be crunched out of\nexistance by the vertex snapping.\n================\n*/\n#define\tEDGE_LENGTH\t0.2\nqboolean WindingIsTiny (winding_t *w)\n{\n/*\n\tif (WindingArea (w) < 1)\n\t\treturn qtrue;\n\treturn qfalse;\n*/\n\tint\t\ti, j;\n\tvec_t\tlen;\n\tvec3_t\tdelta;\n\tint\t\tedges;\n\n\tedges = 0;\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tj = i == w->numpoints - 1 ? 0 : i+1;\n\t\tVectorSubtract (w->p[j], w->p[i], delta);\n\t\tlen = VectorLength (delta);\n\t\tif (len > EDGE_LENGTH)\n\t\t{\n\t\t\tif (++edges == 3)\n\t\t\t\treturn qfalse;\n\t\t}\n\t}\n\treturn qtrue;\n}\n\n/*\n================\nWindingIsHuge\n\nReturns true if the winding still has one of the points\nfrom basewinding for plane\n================\n*/\nqboolean WindingIsHuge (winding_t *w)\n{\n\tint\t\ti, j;\n\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t\tif (w->p[i][j] <= MIN_WORLD_COORD || w->p[i][j] >= MAX_WORLD_COORD)\n\t\t\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n//============================================================\n\n/*\n==================\nBrushMostlyOnSide\n\n==================\n*/\nint BrushMostlyOnSide (bspbrush_t *brush, plane_t *plane)\n{\n\tint\t\t\ti, j;\n\twinding_t\t*w;\n\tvec_t\t\td, max;\n\tint\t\t\tside;\n\n\tmax = 0;\n\tside = PSIDE_FRONT;\n\tfor (i=0 ; i<brush->numsides ; i++)\n\t{\n\t\tw = brush->sides[i].winding;\n\t\tif (!w)\n\t\t\tcontinue;\n\t\tfor (j=0 ; j<w->numpoints ; j++)\n\t\t{\n\t\t\td = DotProduct (w->p[j], plane->normal) - plane->dist;\n\t\t\tif (d > max)\n\t\t\t{\n\t\t\t\tmax = d;\n\t\t\t\tside = PSIDE_FRONT;\n\t\t\t}\n\t\t\tif (-d > max)\n\t\t\t{\n\t\t\t\tmax = -d;\n\t\t\t\tside = PSIDE_BACK;\n\t\t\t}\n\t\t}\n\t}\n\treturn side;\n}\n\n/*\n================\nSplitBrush\n\nGenerates two new brushes, leaving the original\nunchanged\n================\n*/\nvoid SplitBrush (bspbrush_t *brush, int planenum,\n\tbspbrush_t **front, bspbrush_t **back)\n{\n\tbspbrush_t\t*b[2];\n\tint\t\t\ti, j;\n\twinding_t\t*w, *cw[2], *midwinding;\n\tplane_t\t\t*plane, *plane2;\n\tside_t\t\t*s, *cs;\n\tfloat\t\td, d_front, d_back;\n\n\t*front = *back = NULL;\n\tplane = &mapplanes[planenum];\n\n\t// check all points\n\td_front = d_back = 0;\n\tfor (i=0 ; i<brush->numsides ; i++)\n\t{\n\t\tw = brush->sides[i].winding;\n\t\tif (!w)\n\t\t\tcontinue;\n\t\tfor (j=0 ; j<w->numpoints ; j++)\n\t\t{\n\t\t\td = DotProduct (w->p[j], plane->normal) - plane->dist;\n\t\t\tif (d > 0 && d > d_front)\n\t\t\t\td_front = d;\n\t\t\tif (d < 0 && d < d_back)\n\t\t\t\td_back = d;\n\t\t}\n\t}\n\tif (d_front < 0.1) // PLANESIDE_EPSILON)\n\t{\t// only on back\n\t\t*back = CopyBrush (brush);\n\t\treturn;\n\t}\n\tif (d_back > -0.1) // PLANESIDE_EPSILON)\n\t{\t// only on front\n\t\t*front = CopyBrush (brush);\n\t\treturn;\n\t}\n\n\t// create a new winding from the split plane\n\n\tw = BaseWindingForPlane (plane->normal, plane->dist);\n\tfor (i=0 ; i<brush->numsides && w ; i++)\n\t{\n\t\tif ( brush->sides[i].backSide ) {\n\t\t\tcontinue;\t// fake back-sided polygons never split\n\t\t}\n\t\tplane2 = &mapplanes[brush->sides[i].planenum ^ 1];\n\t\tChopWindingInPlace (&w, plane2->normal, plane2->dist, 0); // PLANESIDE_EPSILON);\n\t}\n\n\tif (!w || WindingIsTiny (w) )\n\t{\t// the brush isn't really split\n\t\tint\t\tside;\n\n\t\tside = BrushMostlyOnSide (brush, plane);\n\t\tif (side == PSIDE_FRONT)\n\t\t\t*front = CopyBrush (brush);\n\t\tif (side == PSIDE_BACK)\n\t\t\t*back = CopyBrush (brush);\n\t\treturn;\n\t}\n\n\tif (WindingIsHuge (w))\n\t{\n\t\tqprintf (\"WARNING: huge winding\\n\");\n\t}\n\n\tmidwinding = w;\n\n\t// split it for real\n\n\tfor (i=0 ; i<2 ; i++)\n\t{\n\t\tb[i] = AllocBrush (brush->numsides+1);\n\t\tmemcpy( b[i], brush, sizeof( bspbrush_t ) - sizeof( brush->sides ) );\n\t\tb[i]->numsides = 0;\n\t\tb[i]->next = NULL;\n\t\tb[i]->original = brush->original;\n\t}\n\n\t// split all the current windings\n\n\tfor (i=0 ; i<brush->numsides ; i++)\n\t{\n\t\ts = &brush->sides[i];\n\t\tw = s->winding;\n\t\tif (!w)\n\t\t\tcontinue;\n\t\tClipWindingEpsilon (w, plane->normal, plane->dist,\n\t\t\t0 /*PLANESIDE_EPSILON*/, &cw[0], &cw[1]);\n\t\tfor (j=0 ; j<2 ; j++)\n\t\t{\n\t\t\tif (!cw[j])\n\t\t\t\tcontinue;\n/*\n\t\t\tif (WindingIsTiny (cw[j]))\n\t\t\t{\n\t\t\t\tFreeWinding (cw[j]);\n\t\t\t\tcontinue;\n\t\t\t}\n*/\n\t\t\tcs = &b[j]->sides[b[j]->numsides];\n\t\t\tb[j]->numsides++;\n\t\t\t*cs = *s;\n\t\t\tcs->winding = cw[j];\n\t\t}\n\t}\n\n\n\t// see if we have valid polygons on both sides\n\n\tfor (i=0 ; i<2 ; i++)\n\t{\n\t\tBoundBrush (b[i]);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\tif (b[i]->mins[j] < MIN_WORLD_COORD || b[i]->maxs[j] > MAX_WORLD_COORD)\n\t\t\t{\n\t\t\t\tqprintf (\"bogus brush after clip\\n\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (b[i]->numsides < 3 || j < 3)\n\t\t{\n\t\t\tFreeBrush (b[i]);\n\t\t\tb[i] = NULL;\n\t\t}\n\t}\n\n\tif ( !(b[0] && b[1]) )\n\t{\n\t\tif (!b[0] && !b[1])\n\t\t\tqprintf (\"split removed brush\\n\");\n\t\telse\n\t\t\tqprintf (\"split not on both sides\\n\");\n\t\tif (b[0])\n\t\t{\n\t\t\tFreeBrush (b[0]);\n\t\t\t*front = CopyBrush (brush);\n\t\t}\n\t\tif (b[1])\n\t\t{\n\t\t\tFreeBrush (b[1]);\n\t\t\t*back = CopyBrush (brush);\n\t\t}\n\t\treturn;\n\t}\n\n\t// add the midwinding to both sides\n\tfor (i=0 ; i<2 ; i++)\n\t{\n\t\tcs = &b[i]->sides[b[i]->numsides];\n\t\tb[i]->numsides++;\n\n\t\tcs->planenum = planenum^i^1;\n\t\tcs->shaderInfo = NULL;\n\t\tif (i==0)\n\t\t\tcs->winding = CopyWinding (midwinding);\n\t\telse\n\t\t\tcs->winding = midwinding;\n\t}\n\n{\n\tvec_t\tv1;\n\tint\t\ti;\n\n\tfor (i=0 ; i<2 ; i++)\n\t{\n\t\tv1 = BrushVolume (b[i]);\n\t\tif (v1 < 1.0)\n\t\t{\n\t\t\tFreeBrush (b[i]);\n\t\t\tb[i] = NULL;\n//\t\t\tqprintf (\"tiny volume after clip\\n\");\n\t\t}\n\t}\n}\n\n\t*front = b[0];\n\t*back = b[1];\n}\n"
  },
  {
    "path": "q3map/brush_primit.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"qbsp.h\"\n\n\n// global flag\nint\tg_bBrushPrimit;\n\n// NOTE : ComputeAxisBase here and in editor code must always BE THE SAME !\n// WARNING : special case behaviour of atan2(y,x) <-> atan(y/x) might not be the same everywhere when x == 0\n// rotation by (0,RotY,RotZ) assigns X to normal\nvoid ComputeAxisBase(vec3_t normal,vec3_t texX,vec3_t texY)\n{\n\tvec_t RotY,RotZ;\n\t// do some cleaning\n\tif (fabs(normal[0])<1e-6)\n\t\tnormal[0]=0.0f;\n\tif (fabs(normal[1])<1e-6)\n\t\tnormal[1]=0.0f;\n\tif (fabs(normal[2])<1e-6)\n\t\tnormal[2]=0.0f;\n\t// compute the two rotations around Y and Z to rotate X to normal\n\tRotY=-atan2(normal[2],sqrt(normal[1]*normal[1]+normal[0]*normal[0]));\n\tRotZ=atan2(normal[1],normal[0]);\n\t// rotate (0,1,0) and (0,0,1) to compute texX and texY\n\ttexX[0]=-sin(RotZ);\n\ttexX[1]=cos(RotZ);\n\ttexX[2]=0;\n\t// the texY vector is along -Z ( T texture coorinates axis )\n\ttexY[0]=-sin(RotY)*cos(RotZ);\n\ttexY[1]=-sin(RotY)*sin(RotZ);\n\ttexY[2]=-cos(RotY);\n}\n"
  },
  {
    "path": "q3map/bsp.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"qbsp.h\"\n\n#ifdef _WIN32\n#ifdef _TTIMOBUILD\n#include \"pakstuff.h\"\n#else\n#include \"../libs/pakstuff.h\"\n#endif\nextern HWND hwndOut;\n#endif\n\nchar\t\tsource[1024];\nchar    tempsource[1024];\nchar\t\tname[1024];\n\nvec_t\t\tmicrovolume = 1.0;\nqboolean\tglview;\nqboolean\tnodetail;\nqboolean\tfulldetail;\nqboolean\tonlyents;\nqboolean\tonlytextures;\nqboolean\tnowater;\nqboolean\tnofill;\nqboolean\tnoopt;\nqboolean\tleaktest;\nqboolean\tverboseentities;\nqboolean\tnoCurveBrushes;\nqboolean\tfakemap;\nqboolean\tnotjunc;\nqboolean\tnomerge;\nqboolean\tnofog;\nqboolean\tnosubdivide;\nqboolean\ttestExpand;\nqboolean\tshowseams;\n\nchar\t\toutbase[32];\n\nint\t\t\tentity_num;\n\n/*\n============\nProcessWorldModel\n\n============\n*/\nvoid ProcessWorldModel( void ) {\n\tentity_t\t*e;\n\ttree_t\t\t*tree;\n\tbspface_t\t*faces;\n\tqboolean\tleaked;\n\n\tBeginModel();\n\n\te = &entities[0];\n\te->firstDrawSurf = 0;//numMapDrawSurfs;\n\n\t// check for patches with adjacent edges that need to LOD together\n\tPatchMapDrawSurfs( e );\n\n\t// build an initial bsp tree using all of the sides\n\t// of all of the structural brushes\n\tfaces = MakeStructuralBspFaceList ( entities[0].brushes );\n\ttree = FaceBSP( faces );\n\tMakeTreePortals (tree);\n\tFilterStructuralBrushesIntoTree( e, tree );\n\n\t// see if the bsp is completely enclosed\n\tif ( FloodEntities (tree) ) {\n\t\t// rebuild a better bsp tree using only the\n\t\t// sides that are visible from the inside\n\t\tFillOutside (tree->headnode);\n\n\t\t// chop the sides to the convex hull of\n\t\t// their visible fragments, giving us the smallest\n\t\t// polygons \n\t\tClipSidesIntoTree( e, tree );\n\n\t\tfaces = MakeVisibleBspFaceList( entities[0].brushes );\n\t\tFreeTree (tree);\n\t\ttree = FaceBSP( faces );\n\t\tMakeTreePortals( tree );\n\t\tFilterStructuralBrushesIntoTree( e, tree );\n\t\tleaked = qfalse;\n\t} else {\n\t\t_printf (\"**********************\\n\");\n\t\t_printf (\"******* leaked *******\\n\");\n\t\t_printf (\"**********************\\n\");\n\t\tLeakFile (tree);\n\t\tif ( leaktest ) {\n\t\t\t_printf (\"--- MAP LEAKED, ABORTING LEAKTEST ---\\n\");\n\t\t\texit (0);\n\t\t}\n\t\tleaked = qtrue;\n\n\t\t// chop the sides to the convex hull of\n\t\t// their visible fragments, giving us the smallest\n\t\t// polygons \n\t\tClipSidesIntoTree( e, tree );\n\t}\n\n\t// save out information for visibility processing\n\tNumberClusters( tree );\n\tif ( !leaked ) {\n\t\tWritePortalFile( tree );\n\t}\n\tif ( glview ) {\n\t\t// dump the portals for debugging\n\t\tWriteGLView( tree, source );\n\t}\n\tFloodAreas (tree);\n\n\t// add references to the detail brushes\n\tFilterDetailBrushesIntoTree( e, tree );\n\n\t// create drawsurfs for triangle models\n\tAddTriangleModels( tree );\n\n\t// drawsurfs that cross fog boundaries will need to\n\t// be split along the bound\n\tif ( !nofog ) {\n\t\tFogDrawSurfs();\t\t// may fragment drawsurfs\n\t}\n\n\t// subdivide each drawsurf as required by shader tesselation\n\tif ( !nosubdivide ) {\n\t\tSubdivideDrawSurfs( e, tree );\n\t}\n\n\t// merge together all common shaders on the same plane and remove \n\t// all colinear points, so extra tjunctions won't be generated\n\tif ( !nomerge ) {\n\t\tMergeSides( e, tree );\t\t// !@# testing\n\t}\n\n\t// add in any vertexes required to fix tjunctions\n\tif ( !notjunc ) {\n\t\tFixTJunctions( e );\n\t}\n\n\t// allocate lightmaps for faces and patches\n\tAllocateLightmaps( e );\n\n\t// add references to the final drawsurfs in the apropriate clusters\n\tFilterDrawsurfsIntoTree( e, tree );\n\n\tEndModel( tree->headnode );\n\n\tFreeTree (tree);\n}\n\n/*\n============\nProcessSubModel\n\n============\n*/\nvoid ProcessSubModel( void ) {\n\tentity_t\t*e;\n\ttree_t\t\t*tree;\n\tbspbrush_t\t*b, *bc;\n\tnode_t\t\t*node;\n\n\tBeginModel ();\n\n\te = &entities[entity_num];\n\te->firstDrawSurf = numMapDrawSurfs;\n\n\tPatchMapDrawSurfs( e );\n\n\t// just put all the brushes in an empty leaf\n\t// FIXME: patches?\n\tnode = AllocNode();\n\tnode->planenum = PLANENUM_LEAF;\n\tfor ( b = e->brushes ; b ; b = b->next ) {\n\t\tbc = CopyBrush( b );\n\t\tbc->next = node->brushlist;\n\t\tnode->brushlist = bc;\n\t}\n\n\ttree = AllocTree();\n\ttree->headnode = node;\n\n\tClipSidesIntoTree( e, tree );\n\n\t// subdivide each drawsurf as required by shader tesselation or fog\n\tif ( !nosubdivide ) {\n\t\tSubdivideDrawSurfs( e, tree );\n\t}\n\n\t// merge together all common shaders on the same plane and remove \n\t// all colinear points, so extra tjunctions won't be generated\n\tif ( !nomerge ) {\n\t\tMergeSides( e, tree );\t\t// !@# testing\n\t}\n\n\t// add in any vertexes required to fix tjunctions\n\tif ( !notjunc ) {\n\t\tFixTJunctions( e );\n\t}\n\n\t// allocate lightmaps for faces and patches\n\tAllocateLightmaps( e );\n\n\t// add references to the final drawsurfs in the apropriate clusters\n\tFilterDrawsurfsIntoTree( e, tree );\n\n\tEndModel ( node );\n\n\tFreeTree( tree );\n}\n\n\n/*\n============\nProcessModels\n============\n*/\nvoid ProcessModels (void)\n{\n\tqboolean\toldVerbose;\n\tentity_t\t*entity;\n\n\toldVerbose = verbose;\n\n\tBeginBSPFile ();\n\n\tfor ( entity_num=0 ; entity_num< num_entities ; entity_num++ ) {\n\t\tentity = &entities[entity_num];\n\t\n\t\tif ( !entity->brushes && !entity->patches ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tqprintf (\"############### model %i ###############\\n\", nummodels);\n\t\tif (entity_num == 0)\n\t\t\tProcessWorldModel ();\n\t\telse\n\t\t\tProcessSubModel ();\n\n\t\tif (!verboseentities)\n\t\t\tverbose = qfalse;\t// don't bother printing submodels\n\t}\n\n\tverbose = oldVerbose;\n}\n\n/*\n============\nBspinfo\n============\n*/\nvoid Bspinfo( int count, char **fileNames ) {\n\tint\t\ti;\n\tchar\tsource[1024];\n\tint\t\t\tsize;\n\tFILE\t\t*f;\n\n\tif ( count < 1 ) {\n\t\t_printf( \"No files to dump info for.\\n\");\n\t\treturn;\n\t}\n\n\tfor ( i = 0 ; i < count ; i++ ) {\n\t\t_printf (\"---------------------\\n\");\n\t\tstrcpy (source, fileNames[ i ] );\n\t\tDefaultExtension (source, \".bsp\");\n\t\tf = fopen (source, \"rb\");\n\t\tif (f)\n\t\t{\n\t\t\tsize = Q_filelength (f);\n\t\t\tfclose (f);\n\t\t}\n\t\telse\n\t\t\tsize = 0;\n\t\t_printf (\"%s: %i\\n\", source, size);\n\t\t\n\t\tLoadBSPFile (source);\t\t\n\t\tPrintBSPFileSizes ();\n\t\t_printf (\"---------------------\\n\");\n\t}\n}\n\n\n/*\n============\nOnlyEnts\n============\n*/\nvoid OnlyEnts( void ) {\n\tchar out[1024];\n\n\tsprintf (out, \"%s.bsp\", source);\n\tLoadBSPFile (out);\n\tnum_entities = 0;\n\n\tLoadMapFile (name);\n\tSetModelNumbers ();\n\tSetLightStyles ();\n\n\tUnparseEntities ();\n\n\tWriteBSPFile (out);\n}\n\n\n/*\n============\nOnlyTextures\n============\n*/\nvoid OnlyTextures( void ) {\t\t// FIXME!!!\n\tchar\tout[1024];\n\tint\t\ti;\n\n\tError( \"-onlytextures isn't working now...\" );\n\n\tsprintf (out, \"%s.bsp\", source);\n\n\tLoadMapFile (name);\n\n\tLoadBSPFile (out);\n\n\t// replace all the drawsurface shader names\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ ) {\n\t}\n\n\tWriteBSPFile (out);\n}\n\n\n/*\n============\nmain\n============\n*/\nint LightMain( int argc, char **argv );\nint VLightMain (int argc, char **argv);\nint VSoundMain (int argc, char **argv);\nint VisMain( int argc, char **argv );\n\nint main (int argc, char **argv) {\n\tint\t\ti;\n\tdouble\t\tstart, end;\n\tchar\t\tpath[1024];\n\n\t_printf (\"Q3Map v1.0s (c) 1999 Id Software Inc.\\n\");\n  \n\tif ( argc < 2 ) {\n\t\tError (\"usage: q3map [options] mapfile\");\n\t}\n\n\t// check for general program options\n\tif (!strcmp(argv[1], \"-info\")) {\n\t\tBspinfo( argc - 2, argv + 2 );\n\t\treturn 0;\n\t}\n\tif (!strcmp(argv[1], \"-light\")) {\n\t\tLightMain( argc - 1, argv + 1 );\n\t\treturn 0;\n\t}\n\tif (!strcmp(argv[1], \"-vlight\")) {\n\t\tVLightMain( argc - 1, argv + 1 );\n\t\treturn 0;\n\t}\n\tif (!strcmp(argv[1], \"-vsound\")) {\n\t\tVSoundMain( argc - 1, argv + 1 );\n\t\treturn 0;\n\t}\n\tif (!strcmp(argv[1], \"-vis\")) {\n\t\tVisMain( argc - 1, argv + 1 );\n\t\treturn 0;\n\t}\n\n\t// do a bsp if nothing else was specified\n\n\t_printf (\"---- q3map ----\\n\");\n\n  tempsource[0] = '\\0';\n\n\tfor (i=1 ; i<argc ; i++)\n\t{\n\t\tif (!strcmp(argv[i],\"-tempname\"))\n    {\n      strcpy(tempsource, argv[++i]);\n    }\n\t\telse if (!strcmp(argv[i],\"-threads\"))\n\t\t{\n\t\t\tnumthreads = atoi (argv[i+1]);\n\t\t\ti++;\n\t\t}\n\t\telse if (!strcmp(argv[i],\"-glview\"))\n\t\t{\n\t\t\tglview = qtrue;\n\t\t}\n\t\telse if (!strcmp(argv[i], \"-v\"))\n\t\t{\n\t\t\t_printf (\"verbose = true\\n\");\n\t\t\tverbose = qtrue;\n\t\t}\n\t\telse if (!strcmp(argv[i], \"-draw\"))\n\t\t{\n\t\t\t_printf (\"drawflag = true\\n\");\n\t\t\tdrawflag = qtrue;\n\t\t}\n\t\telse if (!strcmp(argv[i], \"-nowater\"))\n\t\t{\n\t\t\t_printf (\"nowater = true\\n\");\n\t\t\tnowater = qtrue;\n\t\t}\n\t\telse if (!strcmp(argv[i], \"-noopt\"))\n\t\t{\n\t\t\t_printf (\"noopt = true\\n\");\n\t\t\tnoopt = qtrue;\n\t\t}\n\t\telse if (!strcmp(argv[i], \"-nofill\"))\n\t\t{\n\t\t\t_printf (\"nofill = true\\n\");\n\t\t\tnofill = qtrue;\n\t\t}\n\t\telse if (!strcmp(argv[i], \"-nodetail\"))\n\t\t{\n\t\t\t_printf (\"nodetail = true\\n\");\n\t\t\tnodetail = qtrue;\n\t\t}\n\t\telse if (!strcmp(argv[i], \"-fulldetail\"))\n\t\t{\n\t\t\t_printf (\"fulldetail = true\\n\");\n\t\t\tfulldetail = qtrue;\n\t\t}\n\t\telse if (!strcmp(argv[i], \"-onlyents\"))\n\t\t{\n\t\t\t_printf (\"onlyents = true\\n\");\n\t\t\tonlyents = qtrue;\n\t\t}\n\t\telse if (!strcmp(argv[i], \"-onlytextures\"))\n\t\t{\n\t\t\t_printf (\"onlytextures = true\\n\");\t// FIXME: make work again!\n\t\t\tonlytextures = qtrue;\n\t\t}\n\t\telse if (!strcmp(argv[i], \"-micro\"))\n\t\t{\n\t\t\tmicrovolume = atof(argv[i+1]);\n\t\t\t_printf (\"microvolume = %f\\n\", microvolume);\n\t\t\ti++;\n\t\t}\n\t\telse if (!strcmp(argv[i], \"-nofog\"))\n\t\t{\n\t\t\t_printf (\"nofog = true\\n\");\n\t\t\tnofog = qtrue;\n\t\t}\n\t\telse if (!strcmp(argv[i], \"-nosubdivide\"))\n\t\t{\n\t\t\t_printf (\"nosubdivide = true\\n\");\n\t\t\tnosubdivide = qtrue;\n\t\t}\n\t\telse if (!strcmp(argv[i], \"-leaktest\"))\n\t\t{\n\t\t\t_printf (\"leaktest = true\\n\");\n\t\t\tleaktest = qtrue;\n\t\t}\n\t\telse if (!strcmp(argv[i], \"-verboseentities\"))\n\t\t{\n\t\t\t_printf (\"verboseentities = true\\n\");\n\t\t\tverboseentities = qtrue;\n\t\t}\n\t\telse if (!strcmp(argv[i], \"-nocurves\"))\n\t\t{\n\t\t\tnoCurveBrushes = qtrue;\n\t\t\t_printf (\"no curve brushes\\n\");\n\t\t}\n\t\telse if (!strcmp(argv[i], \"-notjunc\"))\n\t\t{\n\t\t\tnotjunc = qtrue;\n\t\t\t_printf (\"no tjunction fixing\\n\");\n\t\t}\n\t\telse if (!strcmp(argv[i], \"-expand\"))\n\t\t{\n\t\t\ttestExpand = qtrue;\n\t\t\t_printf (\"Writing expanded.map.\\n\");\n\t\t}\n\t\telse if (!strcmp(argv[i], \"-showseams\"))\n\t\t{\n\t\t\tshowseams = qtrue;\n\t\t\t_printf (\"Showing seams on terrain.\\n\");\n\t\t}\n\t\telse if (!strcmp (argv[i],\"-tmpout\"))\n\t\t{\n\t\t\tstrcpy (outbase, \"/tmp\");\n\t\t}\n\t\telse if (!strcmp (argv[i],\"-fakemap\"))\n\t\t{\n\t\t\tfakemap = qtrue;\n\t\t\t_printf( \"will generate fakemap.map\\n\");\n\t\t}\n\t\telse if (!strcmp(argv[i], \"-samplesize\"))\n\t\t{\n\t\t\tsamplesize = atoi(argv[i+1]);\n\t\t\tif (samplesize < 1) samplesize = 1;\n\t\t\ti++;\n\t\t\t_printf(\"lightmap sample size is %dx%d units\\n\", samplesize, samplesize);\n\t\t}\n\t\telse if (argv[i][0] == '-')\n\t\t\tError (\"Unknown option \\\"%s\\\"\", argv[i]);\n\t\telse\n\t\t\tbreak;\n\t}\n\n\tif (i != argc - 1)\n\t\tError (\"usage: q3map [options] mapfile\");\n\n\tstart = I_FloatTime ();\n\n\tThreadSetDefault ();\n\t//numthreads = 1;\t\t// multiple threads aren't helping because of heavy malloc use\n\tSetQdirFromPath (argv[i]);\n\n#ifdef _WIN32\n  InitPakFile(gamedir, NULL);\n#endif\n\n\tstrcpy (source, ExpandArg (argv[i]));\n\tStripExtension (source);\n\n\t// delete portal and line files\n\tsprintf (path, \"%s.prt\", source);\n\tremove (path);\n\tsprintf (path, \"%s.lin\", source);\n\tremove (path);\n\n\tstrcpy (name, ExpandArg (argv[i]));\t\n\tif ( strcmp(name + strlen(name) - 4, \".reg\" ) ) {\n\t\t// if we are doing a full map, delete the last saved region map\n\t\tsprintf (path, \"%s.reg\", source);\n\t\tremove (path);\n\n\t\tDefaultExtension (name, \".map\");\t// might be .reg\n\t}\n\n\t//\n\t// if onlyents, just grab the entites and resave\n\t//\n\tif ( onlyents ) {\n\t\tOnlyEnts();\n\t\treturn 0;\n\t}\n\n\t//\n\t// if onlytextures, just grab the textures and resave\n\t//\n\tif ( onlytextures ) {\n\t\tOnlyTextures();\n\t\treturn 0;\n\t}\n\n\t//\n\t// start from scratch\n\t//\n\tLoadShaderInfo();\n\n  // load original file from temp spot in case it was renamed by the editor on the way in\n  if (strlen(tempsource) > 0) {\n\t  LoadMapFile (tempsource);\n  } else {\n\t  LoadMapFile (name);\n  }\n\n\tSetModelNumbers ();\n\tSetLightStyles ();\n\n\tProcessModels ();\n\n\tEndBSPFile();\n\n\tend = I_FloatTime ();\n\t_printf (\"%5.0f seconds elapsed\\n\", end-start);\n\n  // remove temp name if appropriate\n  if (strlen(tempsource) > 0) {\n    remove(tempsource);\n  }\n\n\treturn 0;\n}\n\n"
  },
  {
    "path": "q3map/facebsp.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n\n\nint\t\t\tc_faceLeafs;\n\n\n/*\n================\nAllocBspFace\n================\n*/\nbspface_t\t*AllocBspFace( void ) {\n\tbspface_t\t*f;\n\n\tf = malloc(sizeof(*f));\n\tmemset( f, 0, sizeof(*f) );\n\n\treturn f;\n}\n\n/*\n================\nFreeBspFace\n================\n*/\nvoid\tFreeBspFace( bspface_t *f ) {\n\tif ( f->w ) {\n\t\tFreeWinding( f->w );\n\t}\n\tfree( f );\n}\n\n\n/*\n================\nSelectSplitPlaneNum\n================\n*/\nint hintsplit;\n\n#define\tBLOCK_SIZE\t1024\nint SelectSplitPlaneNum( node_t *node, bspface_t *list ) {\n\tbspface_t\t*split;\n\tbspface_t\t*check;\n\tbspface_t\t*bestSplit;\n\tint\t\t\tsplits, facing, front, back;\n\tint\t\t\tside;\n\tplane_t\t\t*plane;\n\tint\t\t\tvalue, bestValue;\n\tint\t\t\ti;\n\tvec3_t\t\tnormal;\n\tfloat\t\tdist;\n\tint\t\t\tplanenum;\n\n\thintsplit = qfalse;\n\t// if it is crossing a 1k block boundary, force a split\n\tfor ( i = 0 ; i < 2 ; i++ ) {\n\t\tdist = BLOCK_SIZE * ( floor( node->mins[i] / BLOCK_SIZE ) + 1 );\t\n\t\tif ( node->maxs[i] > dist ) {\n\t\t\tVectorClear( normal );\n\t\t\tnormal[i] = 1;\n\t\t\tplanenum = FindFloatPlane( normal, dist );\n\t\t\treturn planenum;\n\t\t}\n\t}\n\n\t// pick one of the face planes\n\tbestValue = -99999;\n\tbestSplit = list;\n\n\tfor ( split = list ; split ; split = split->next ) {\n\t\tsplit->checked = qfalse;\n\t}\n\n\tfor ( split = list ; split ; split = split->next ) {\n\t\tif ( split->checked ) {\n\t\t\tcontinue;\n\t\t}\n\t\tplane = &mapplanes[ split->planenum ];\n\t\tsplits = 0;\n\t\tfacing = 0;\n\t\tfront = 0;\n\t\tback = 0;\n\t\tfor ( check = list ; check ; check = check->next ) {\n\t\t\tif ( check->planenum == split->planenum ) {\n\t\t\t\tfacing++;\n\t\t\t\tcheck->checked = qtrue;\t// won't need to test this plane again\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tside = WindingOnPlaneSide( check->w, plane->normal, plane->dist );\n\t\t\tif ( side == SIDE_CROSS ) {\n\t\t\t\tsplits++;\n\t\t\t} else if ( side == SIDE_FRONT ) {\n\t\t\t\tfront++;\n\t\t\t} else if ( side == SIDE_BACK ) {\n\t\t\t\tback++;\n\t\t\t}\n\t\t}\n\t\tvalue =  5*facing - 5*splits; // - abs(front-back);\n\t\tif ( plane->type < 3 ) {\n\t\t\tvalue+=5;\t\t// axial is better\n\t\t}\n\t\tvalue += split->priority;\t\t// prioritize hints higher\n\n\t\tif ( value > bestValue ) {\n\t\t\tbestValue = value;\n\t\t\tbestSplit = split;\n\t\t}\n\t}\n\n\tif ( bestValue == -99999 ) {\n\t\treturn -1;\n\t}\n\n\tif (bestSplit->hint)\n\t\thintsplit = qtrue;\n\n\treturn bestSplit->planenum;\n}\n\nint\tCountFaceList( bspface_t *list ) {\n\tint\t\tc;\n\tc = 0;\n\tfor ( ; list ; list = list->next ) {\n\t\tc++;\n\t}\n\treturn c;\n}\n\n/*\n================\nBuildFaceTree_r\n================\n*/\nvoid\tBuildFaceTree_r( node_t *node, bspface_t *list ) {\n\tbspface_t\t*split;\n\tbspface_t\t*next;\n\tint\t\t\tside;\n\tplane_t\t\t*plane;\n\tbspface_t\t*newFace;\n\tbspface_t\t*childLists[2];\n\twinding_t\t*frontWinding, *backWinding;\n\tint\t\t\ti;\n\tint\t\t\tsplitPlaneNum;\n\n\ti = CountFaceList( list );\n\n\tsplitPlaneNum = SelectSplitPlaneNum( node, list );\n\t// if we don't have any more faces, this is a node\n\tif ( splitPlaneNum == -1 ) {\n\t\tnode->planenum = PLANENUM_LEAF;\n\t\tc_faceLeafs++;\n\t\treturn;\n\t}\n\n\t// partition the list\n\tnode->planenum = splitPlaneNum;\n\tnode->hint = hintsplit;\n\tplane = &mapplanes[ splitPlaneNum ];\n\tchildLists[0] = NULL;\n\tchildLists[1] = NULL;\n\tfor ( split = list ; split ; split = next ) {\n\t\tnext = split->next;\n\n\t\tif ( split->planenum == node->planenum ) {\n\t\t\tFreeBspFace( split );\n\t\t\tcontinue;\n\t\t}\n\n\t\tside = WindingOnPlaneSide( split->w, plane->normal, plane->dist );\n\n\t\tif ( side == SIDE_CROSS ) {\n\t\t\tClipWindingEpsilon( split->w, plane->normal, plane->dist, CLIP_EPSILON * 2,\n\t\t\t\t&frontWinding, &backWinding );\n\t\t\tif ( frontWinding ) {\n\t\t\t\tnewFace = AllocBspFace();\n\t\t\t\tnewFace->w = frontWinding;\n\t\t\t\tnewFace->next = childLists[0];\n\t\t\t\tnewFace->planenum = split->planenum;\n\t\t\t\tnewFace->priority = split->priority;\n\t\t\t\tnewFace->hint = split->hint;\n\t\t\t\tchildLists[0] = newFace;\n\t\t\t}\n\t\t\tif ( backWinding ) {\n\t\t\t\tnewFace = AllocBspFace();\n\t\t\t\tnewFace->w = backWinding;\n\t\t\t\tnewFace->next = childLists[1];\n\t\t\t\tnewFace->planenum = split->planenum;\n\t\t\t\tnewFace->priority = split->priority;\n\t\t\t\tnewFace->hint = split->hint;\n\t\t\t\tchildLists[1] = newFace;\n\t\t\t}\n\t\t\tFreeBspFace( split );\n\t\t} else if ( side == SIDE_FRONT ) {\n\t\t\tsplit->next = childLists[0];\n\t\t\tchildLists[0] = split;\n\t\t} else if ( side == SIDE_BACK ) {\n\t\t\tsplit->next = childLists[1];\n\t\t\tchildLists[1] = split;\n\t\t}\n\t}\n\n\n\t// recursively process children\n\tfor ( i = 0 ; i < 2 ; i++ ) {\n\t\tnode->children[i] = AllocNode();\n\t\tnode->children[i]->parent = node;\n\t\tVectorCopy( node->mins, node->children[i]->mins );\n\t\tVectorCopy( node->maxs, node->children[i]->maxs );\n\t}\n\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tif ( plane->normal[i] == 1 ) {\n\t\t\tnode->children[0]->mins[i] = plane->dist;\n\t\t\tnode->children[1]->maxs[i] = plane->dist;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tfor ( i = 0 ; i < 2 ; i++ ) {\n\t\tBuildFaceTree_r ( node->children[i], childLists[i]);\n\t}\n}\n\n\n/*\n================\nFaceBSP\n\nList will be freed before returning\n================\n*/\ntree_t *FaceBSP( bspface_t *list ) {\n\ttree_t\t\t*tree;\n\tbspface_t\t*face;\n\tint\t\t\ti;\n\tint\t\t\tcount;\n\n\tqprintf( \"--- FaceBSP ---\\n\" );\n\n\ttree = AllocTree ();\n\n\tcount = 0;\n\tfor ( face = list ; face ; face = face->next ) {\n\t\tcount++;\n\t\tfor ( i = 0 ; i < face->w->numpoints ; i++ ) {\n\t\t\tAddPointToBounds( face->w->p[i], tree->mins, tree->maxs);\n\t\t}\n\t}\n\tqprintf( \"%5i faces\\n\", count );\n\n\ttree->headnode = AllocNode();\n\tVectorCopy( tree->mins, tree->headnode->mins );\n\tVectorCopy( tree->maxs, tree->headnode->maxs );\n\tc_faceLeafs = 0;\n\n\tBuildFaceTree_r ( tree->headnode, list );\n\n\tqprintf( \"%5i leafs\\n\", c_faceLeafs );\n\n\treturn tree;\n}\n\n\n/*\n=================\nBspFaceForPortal\n=================\n*/\nbspface_t *BspFaceForPortal( portal_t *p ) {\n\tbspface_t\t*f;\n\n\tf = AllocBspFace();\n\tf->w = CopyWinding( p->winding );\n\tf->planenum = p->onnode->planenum & ~1;\n\n\treturn f;\n}\n\n\n\n/*\n=================\nMakeStructuralBspFaceList\n=================\n*/\nbspface_t\t*MakeStructuralBspFaceList( bspbrush_t *list ) {\n\tbspbrush_t\t*b;\n\tint\t\t\ti;\n\tside_t\t\t*s;\n\twinding_t\t*w;\n\tbspface_t\t*f, *flist;\n\n\tflist = NULL;\n\tfor ( b = list ; b ; b = b->next ) {\n\t\tif ( b->detail ) {\n\t\t\tcontinue;\n\t\t}\n\t\tfor ( i = 0 ; i < b->numsides ; i++ ) {\n\t\t\ts = &b->sides[i];\n\t\t\tw = s->winding;\n\t\t\tif ( !w ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tf = AllocBspFace();\n\t\t\tf->w = CopyWinding( w );\n\t\t\tf->planenum = s->planenum & ~1;\n\t\t\tf->next = flist;\n\t\t\tif (s->surfaceFlags & SURF_HINT) {\n\t\t\t\t//f->priority = HINT_PRIORITY;\n\t\t\t\tf->hint = qtrue;\n\t\t\t}\n\t\t\tflist = f;\n\t\t}\n\t}\n\n\treturn flist;\n}\n\n/*\n=================\nMakeVisibleBspFaceList\n=================\n*/\nbspface_t\t*MakeVisibleBspFaceList( bspbrush_t *list ) {\n\tbspbrush_t\t*b;\n\tint\t\t\ti;\n\tside_t\t\t*s;\n\twinding_t\t*w;\n\tbspface_t\t*f, *flist;\n\n\tflist = NULL;\n\tfor ( b = list ; b ; b = b->next ) {\n\t\tif ( b->detail ) {\n\t\t\tcontinue;\n\t\t}\n\t\tfor ( i = 0 ; i < b->numsides ; i++ ) {\n\t\t\ts = &b->sides[i];\n\t\t\tw = s->visibleHull;\n\t\t\tif ( !w ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tf = AllocBspFace();\n\t\t\tf->w = CopyWinding( w );\n\t\t\tf->planenum = s->planenum & ~1;\n\t\t\tf->next = flist;\n\t\t\tif (s->surfaceFlags & SURF_HINT) {\n\t\t\t\t//f->priority = HINT_PRIORITY;\n\t\t\t\tf->hint = qtrue;\n\t\t\t}\n\t\t\tflist = f;\n\t\t}\n\t}\n\n\treturn flist;\n}\n\n"
  },
  {
    "path": "q3map/fog.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"qbsp.h\"\n\n\nint\t\t\tc_fogFragment;\nint\t\t\tc_fogPatchFragments;\n\n/*\n====================\nDrawSurfToMesh\n====================\n*/\nmesh_t\t*DrawSurfToMesh( mapDrawSurface_t *ds ) {\n\tmesh_t\t\t*m;\n\n\tm = malloc( sizeof( *m ) );\n\tm->width = ds->patchWidth;\n\tm->height = ds->patchHeight;\n\tm->verts = malloc( sizeof(m->verts[0]) * m->width * m->height );\n\tmemcpy( m->verts, ds->verts, sizeof(m->verts[0]) * m->width * m->height );\n\n\treturn m;\n}\n\n\n/*\n====================\nSplitMeshByPlane\n====================\n*/\nvoid SplitMeshByPlane( mesh_t *in, vec3_t normal, float dist, mesh_t **front, mesh_t **back ) {\n\tint\t\tw, h, split;\n\tfloat\td[MAX_PATCH_SIZE][MAX_PATCH_SIZE];\n\tdrawVert_t\t*dv, *v1, *v2;\n\tint\t\tc_front, c_back, c_on;\n\tmesh_t\t*f, *b;\n\tint\t\ti;\n\tfloat\tfrac;\n\tint\t\tfrontAprox, backAprox;\n\n\tfor ( i = 0 ; i < 2 ; i++ ) {\n\t\tdv = in->verts;\n\t\tc_front = 0;\n\t\tc_back = 0;\n\t\tc_on = 0;\n\t\tfor ( h = 0 ; h < in->height ; h++ ) {\n\t\t\tfor ( w = 0 ; w < in->width ; w++, dv++ ) {\n\t\t\t\td[h][w] = DotProduct( dv->xyz, normal ) - dist;\n\t\t\t\tif ( d[h][w] > ON_EPSILON ) {\n\t\t\t\t\tc_front++;\n\t\t\t\t} else if ( d[h][w] < -ON_EPSILON ) {\n\t\t\t\t\tc_back++;\n\t\t\t\t} else {\n\t\t\t\t\tc_on++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t*front = NULL;\n\t\t*back = NULL;\n\n\t\tif ( !c_front ) {\n\t\t\t*back = in;\n\t\t\treturn;\n\t\t}\n\t\tif ( !c_back ) {\n\t\t\t*front = in;\n\t\t\treturn;\n\t\t}\n\n\t\t// find a split point\n\t\tsplit = -1;\n\t\tfor ( w = 0 ; w < in->width -1 ; w++ ) {\n\t\t\tif ( ( d[0][w] < 0 ) != ( d[0][w+1] < 0 ) ) {\n\t\t\t\tif ( split == -1 ) {\n\t\t\t\t\tsplit = w;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( split == -1 ) {\n\t\t\tif ( i == 1 ) {\n\t\t\t\tqprintf( \"No crossing points in patch\\n\");\n\t\t\t\t*front = in;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tin = TransposeMesh( in );\n\t\t\tInvertMesh( in );\n\t\t\tcontinue;\n\t\t}\n\n\t\t// make sure the split point stays the same for all other rows\n\t\tfor ( h = 1 ; h < in->height ; h++ ) {\n\t\t\tfor ( w = 0 ; w < in->width -1 ; w++ ) {\n\t\t\t\tif ( ( d[h][w] < 0 ) != ( d[h][w+1] < 0 ) ) {\n\t\t\t\t\tif ( w != split ) {\n\t\t\t\t\t\t_printf( \"multiple crossing points for patch -- can't clip\\n\");\n\t\t\t\t\t\t*front = in;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( ( d[h][split] < 0 ) == ( d[h][split+1] < 0 ) ) {\n\t\t\t\t_printf( \"differing crossing points for patch -- can't clip\\n\");\n\t\t\t\t*front = in;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tbreak;\n\t}\n\n\n\t// create two new meshes\n\tf = malloc( sizeof( *f ) );\n\tf->width = split + 2;\n\tif ( ! (f->width & 1) ) {\n\t\tf->width++;\n\t\tfrontAprox = 1;\n\t} else {\n\t\tfrontAprox = 0;\n\t}\n\tif ( f->width > MAX_PATCH_SIZE ) {\n\t\tError( \"MAX_PATCH_SIZE after split\");\n\t}\n\tf->height = in->height;\n\tf->verts = malloc( sizeof(f->verts[0]) * f->width * f->height );\n\n\tb = malloc( sizeof( *b ) );\n\tb->width = in->width - split;\n\tif ( ! (b->width & 1) ) {\n\t\tb->width++;\n\t\tbackAprox = 1;\n\t} else {\n\t\tbackAprox = 0;\n\t}\n\tif ( b->width > MAX_PATCH_SIZE ) {\n\t\tError( \"MAX_PATCH_SIZE after split\");\n\t}\n\tb->height = in->height;\n\tb->verts = malloc( sizeof(b->verts[0]) * b->width * b->height );\n\n\tif ( d[0][0] > 0 ) {\n\t\t*front = f;\n\t\t*back = b;\n\t} else {\n\t\t*front = b;\n\t\t*back = f;\n\t}\n\n\t// distribute the points\n\tfor ( w = 0 ; w < in->width ; w++ ) {\n\t\tfor ( h = 0 ; h < in->height ; h++ ) {\n\t\t\tif ( w <= split ) {\n\t\t\t\tf->verts[ h * f->width + w ] = in->verts[ h * in->width + w ];\n\t\t\t} else {\n\t\t\t\tb->verts[ h * b->width + w - split + backAprox ] = in->verts[ h * in->width + w ];\n\t\t\t}\n\t\t}\n\t}\n\n\t// clip the crossing line\n\tfor ( h = 0 ; h < in->height ; h++ ) {\n\t\tdv = &f->verts[ h * f->width + split + 1 ];\n\t\tv1 = &in->verts[ h * in->width + split ];\n\t\tv2 = &in->verts[ h * in->width + split + 1 ];\n\t\tfrac = d[h][split] / ( d[h][split] - d[h][split+1] );\n\t\tfor ( i = 0 ; i < 10 ; i++ ) {\n\t\t\tdv->xyz[i] = v1->xyz[i] + frac * ( v2->xyz[i] - v1->xyz[i] );\n\t\t}\n\t\tdv->xyz[10] = 0;//set all 4 colors to 0 \n\t\tif ( frontAprox ) {\n\t\t\tf->verts[ h * f->width + split + 2 ] = *dv;\n\t\t}\n\t\tb->verts[ h * b->width ] = *dv;\n\t\tif ( backAprox ) {\n\t\t\tb->verts[ h * b->width + 1 ] = *dv;\n\t\t}\n\t}\n\n\t/*\nPrintMesh( in );\n_printf(\"\\n\");\nPrintMesh( f );\n_printf(\"\\n\");\nPrintMesh( b );\n_printf(\"\\n\");\n\t*/\n\n\tFreeMesh( in );\n}\n\n\n/*\n====================\nChopPatchByBrush\n====================\n*/\nqboolean ChopPatchByBrush( mapDrawSurface_t *ds, bspbrush_t *b ) {\n\tint\t\t\ti, j;\n\tside_t\t\t*s;\n\tplane_t\t\t*plane;\n\tmesh_t\t\t*outside[MAX_BRUSH_SIDES];\n\tint\t\t\tnumOutside;\n\tmesh_t\t\t*m, *front, *back;\n\tmapDrawSurface_t\t*newds;\n\n\tm = DrawSurfToMesh( ds );\n\tnumOutside = 0;\n\n\t// only split by the top and bottom planes to avoid\n\t// some messy patch clipping issues\n\n\tfor ( i = 4 ; i <= 5 ; i++ ) {\n\t\ts = &b->sides[ i ];\n\t\tplane = &mapplanes[ s->planenum ];\n\n\t\tSplitMeshByPlane( m, plane->normal, plane->dist, &front, &back );\n\n\t\tif ( !back ) {\n\t\t\t// nothing actually contained inside\n\t\t\tfor ( j = 0 ; j < numOutside ; j++ ) {\n\t\t\t\tFreeMesh( outside[j] );\n\t\t\t}\n\t\t\treturn qfalse;\n\t\t}\n\t\tm = back;\n\n\t\tif ( front ) {\n\t\t\tif ( numOutside == MAX_BRUSH_SIDES ) {\n\t\t\t\tError( \"MAX_BRUSH_SIDES\" );\n\t\t\t}\n\t\t\toutside[ numOutside ] = front;\n\t\t\tnumOutside++;\n\t\t}\n\t}\n\n\t// all of outside fragments become seperate drawsurfs\n\tc_fogPatchFragments += numOutside;\n\tfor ( i = 0 ; i < numOutside ; i++ ) {\n\t\tnewds = DrawSurfaceForMesh( outside[ i ] );\n\t\tnewds->shaderInfo = ds->shaderInfo;\n\t\tFreeMesh( outside[ i ] );\n\t}\n\n\t// replace ds with m\n\tds->patchWidth = m->width;\n\tds->patchHeight = m->height;\n\tds->numVerts = m->width * m->height;\n\tfree( ds->verts );\n\tds->verts = malloc( ds->numVerts * sizeof( *ds->verts ) );\n\tmemcpy( ds->verts, m->verts, ds->numVerts * sizeof( *ds->verts ) );\n\n\tFreeMesh( m );\n\n\treturn qtrue;\n}\n\n//===============================================================================\n\n/*\n====================\nWindingFromDrawSurf\n====================\n*/\nwinding_t\t*WindingFromDrawSurf( mapDrawSurface_t *ds ) {\n\twinding_t\t*w;\n\tint\t\t\ti;\n\n\tw = AllocWinding( ds->numVerts );\n\tw->numpoints = ds->numVerts;\n\tfor ( i = 0 ; i < ds->numVerts ; i++ ) {\n\t\tVectorCopy( ds->verts[i].xyz, w->p[i] );\n\t}\n\treturn w;\n}\n\n/*\n====================\nChopFaceByBrush\n\nThere may be a fragment contained in the brush\n====================\n*/\nqboolean ChopFaceByBrush( mapDrawSurface_t *ds, bspbrush_t *b ) {\n\tint\t\t\ti, j;\n\tside_t\t\t*s;\n\tplane_t\t\t*plane;\n\twinding_t\t*w;\n\twinding_t\t*front, *back;\n\twinding_t\t*outside[MAX_BRUSH_SIDES];\n\tint\t\t\tnumOutside;\n\tmapDrawSurface_t\t*newds;\n\tdrawVert_t\t\t*dv;\n\tshaderInfo_t\t*si;\n\tfloat\t\tmins[2];\n\n\t// brush primitive :\n\t// axis base\n\tvec3_t\t\ttexX,texY;\n\tvec_t\t\tx,y;\n\n\tw = WindingFromDrawSurf( ds );\n\tnumOutside = 0;\n\n\tfor ( i = 0 ; i < b->numsides ; i++ ) {\n\t\ts = &b->sides[ i ];\n\t\tif ( s->backSide ) {\n\t\t\tcontinue;\n\t\t}\n\t\tplane = &mapplanes[ s->planenum ];\n\n\t\t// handle coplanar outfacing (don't fog)\n\t\tif ( ds->side->planenum == s->planenum ) {\n\t\t\treturn qfalse;\n\t\t}\n\n\t\t// handle coplanar infacing (keep inside)\n\t\tif ( ( ds->side->planenum ^ 1 ) == s->planenum ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// general case\n\t\tClipWindingEpsilon( w, plane->normal, plane->dist, ON_EPSILON,\n\t\t\t&front, &back );\n\t\tFreeWinding( w );\n\t\tif ( !back ) {\n\t\t\t// nothing actually contained inside\n\t\t\tfor ( j = 0 ; j < numOutside ; j++ ) {\n\t\t\t\tFreeWinding( outside[j] );\n\t\t\t}\n\t\t\treturn qfalse;\n\t\t}\n\t\tif ( front ) {\n\t\t\tif ( numOutside == MAX_BRUSH_SIDES ) {\n\t\t\t\tError( \"MAX_BRUSH_SIDES\" );\n\t\t\t}\n\t\t\toutside[ numOutside ] = front;\n\t\t\tnumOutside++;\n\t\t}\n\t\tw = back;\n\t}\n\n\t// all of outside fragments become seperate drawsurfs\n\t// linked to the same side\n\tc_fogFragment += numOutside;\n\ts = ds->side;\n\n\tfor ( i = 0 ; i < numOutside ; i++ ) {\n\t\tnewds = DrawSurfaceForSide( ds->mapBrush, s, outside[i] );\n\t\tFreeWinding( outside[i] );\n\t}\n\n\n\t// replace ds->verts with the verts for w\n\tds->numVerts = w->numpoints;\n\tfree( ds->verts );\n\n\tds->verts = malloc( ds->numVerts * sizeof( *ds->verts ) );\n\tmemset( ds->verts, 0, ds->numVerts * sizeof( *ds->verts ) );\n\n\tsi = s->shaderInfo;\n\n\tmins[0] = 9999;\n\tmins[1] = 9999;\n\n\t// compute s/t coordinates from brush primitive texture matrix\n\t// compute axis base\n\tComputeAxisBase( mapplanes[s->planenum].normal, texX, texY );\n\n\tfor ( j = 0 ; j < w->numpoints ; j++ ) {\n\t\tdv = ds->verts + j;\n\t\tVectorCopy( w->p[j], dv->xyz );\n\t\n\t\tif (g_bBrushPrimit==BPRIMIT_OLDBRUSHES)\n\t\t{\n\t\t\t// calculate texture s/t\n\t\t\tdv->st[0] = s->vecs[0][3] + DotProduct( s->vecs[0],\tdv->xyz );\n\t\t\tdv->st[1] = s->vecs[1][3] + DotProduct( s->vecs[1],\tdv->xyz );\t\n\t\t\tdv->st[0] /= si->width;\n\t\t\tdv->st[1] /= si->height;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// calculate texture s/t from brush primitive texture matrix\n\t\t\tx = DotProduct( dv->xyz, texX );\n\t\t\ty = DotProduct( dv->xyz, texY );\n\t\t\tdv->st[0]=s->texMat[0][0]*x+s->texMat[0][1]*y+s->texMat[0][2];\n\t\t\tdv->st[1]=s->texMat[1][0]*x+s->texMat[1][1]*y+s->texMat[1][2];\n\t\t}\n\n\t\tif ( dv->st[0] < mins[0] ) {\n\t\t\tmins[0] = dv->st[0];\n\t\t}\n\t\tif ( dv->st[1] < mins[1] ) {\n\t\t\tmins[1] = dv->st[1];\n\t\t}\n\n\t\t// copy normal\n\t\tVectorCopy ( mapplanes[s->planenum].normal, dv->normal );\n\t}\n\n\t// adjust the texture coordinates to be as close to 0 as possible\n\tif ( !si->globalTexture ) {\n\t\tmins[0] = floor( mins[0] );\n\t\tmins[1] = floor( mins[1] );\n\t\tfor ( i = 0 ; i < w->numpoints ; i++ ) {\n\t\t\tdv = ds->verts + i;\n\t\t\tdv->st[0] -= mins[0];\n\t\t\tdv->st[1] -= mins[1];\n\t\t}\n\t}\n\n\treturn qtrue;\n}\n\n//===============================================================================\n\n\n/*\n=====================\nFogDrawSurfs\n\nCall after the surface list has been pruned, \nbefore tjunction fixing\nbefore lightmap allocation\n=====================\n*/\nvoid FogDrawSurfs( void ) {\n\tint\t\t\t\t\ti, j, k;\n\tmapDrawSurface_t\t*ds;\n\tbspbrush_t\t\t\t*b;\n\tvec3_t\t\t\t\tmins, maxs;\n\tint\t\t\t\t\tc_fogged;\n\tint\t\t\t\t\tnumBaseDrawSurfs;\n\tdfog_t\t\t\t\t*fog;\n\n\tqprintf(\"----- FogDrawsurfs -----\\n\");\n\n\tc_fogged = 0;\n\tc_fogFragment = 0;\n\n\t// find all fog brushes\n\tfor ( b = entities[0].brushes ; b ; b = b->next ) {\n\t\tif ( !(b->contents & CONTENTS_FOG) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( numFogs == MAX_MAP_FOGS ) {\n\t\t\tError( \"MAX_MAP_FOGS\" );\n\t\t}\n\t\tfog = &dfogs[numFogs];\n\t\tnumFogs++;\n\t\tfog->brushNum = b->outputNumber;\n\n\t\t// find a side with a valid shaderInfo\n\t\t// non-axial fog columns may have bevel planes that need to be skipped\n\t\tfor ( i = 0 ; i < b->numsides ; i++ ) {\n\t\t\tif ( b->sides[i].shaderInfo && (b->sides[i].shaderInfo->contents & CONTENTS_FOG) ) {\n\t\t\t\tstrcpy( fog->shader, b->sides[i].shaderInfo->shader );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif ( i == b->numsides ) {\n\t\t\tcontinue;\t\t// shouldn't happen\n\t\t}\n\n\t\tfog->visibleSide = -1;\n\n\t\t// clip each surface into this, but don't clip any of\n\t\t// the resulting fragments to the same brush\n\t\tnumBaseDrawSurfs = numMapDrawSurfs;\n\t\tfor ( i = 0 ; i < numBaseDrawSurfs ; i++ ) {\n\t\t\tds = &mapDrawSurfs[i];\n\n\t\t\t// bound the drawsurf\n\t\t\tClearBounds( mins, maxs );\n\t\t\tfor ( j = 0 ; j < ds->numVerts ; j++ ) {\n\t\t\t\tAddPointToBounds( ds->verts[j].xyz, mins, maxs );\n\t\t\t}\n\n\t\t\t// check against the fog brush\n\t\t\tfor ( k = 0 ; k < 3 ; k++ ) {\n\t\t\t\tif ( mins[k] > b->maxs[k] ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif ( maxs[k] < b->mins[k] ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( k < 3 ) {\n\t\t\t\tcontinue;\t\t// bboxes don't intersect\n\t\t\t}\n\n\t\t\tif ( ds->mapBrush == b ) {\n\t\t\t\tint\t\ts;\n\n\t\t\t\ts = ds->side - b->sides;\n\t\t\t\tif ( s <= 6 ) {\t// not one of the reversed inside faces\n\t\t\t\t\t// this is a visible fog plane\n\t\t\t\t\tif ( fog->visibleSide != -1 ) {\n\t\t\t\t\t\t_printf( \"WARNING: fog brush %i has multiple visible sides\\n\", b->brushnum );\n\t\t\t\t\t}\n\t\t\t\t\tfog->visibleSide = s;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ds->miscModel ) {\n\t\t\t\t// we could write splitting code for trimodels if we wanted to...\n\t\t\t\tc_fogged++;\n\t\t\t\tds->fogNum = numFogs - 1;\n\t\t\t} else if ( ds->patch ) {\n\t\t\t\tif ( ChopPatchByBrush( ds, b ) ) {\n\t\t\t\t\tc_fogged++;\n\t\t\t\t\tds->fogNum = numFogs - 1;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( ChopFaceByBrush( ds, b ) ) {\n\t\t\t\t\tc_fogged++;\n\t\t\t\t\tds->fogNum = numFogs - 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// split the drawsurfs by the fog brushes\n\n\tqprintf( \"%5i fogs\\n\", numFogs );\n\tqprintf( \"%5i fog polygon fragments\\n\", c_fogFragment );\n\tqprintf( \"%5i fog patch fragments\\n\", c_fogPatchFragments );\n\tqprintf( \"%5i fogged drawsurfs\\n\", c_fogged );\n}\n"
  },
  {
    "path": "q3map/gldraw.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include <windows.h>\n#include <GL/gl.h>\n#include <GL/glu.h>\n#include <GL/glaux.h>\n\n#include \"qbsp.h\"\n\n// can't use the glvertex3fv functions, because the vec3_t fields\n// could be either floats or doubles, depending on DOUBLEVEC_T\n\nqboolean\tdrawflag;\nvec3_t\tdraw_mins, draw_maxs;\n\n\n#define\tWIN_SIZE\t512\n\nvoid InitWindow (void)\n{\n    auxInitDisplayMode (AUX_SINGLE | AUX_RGB);\n    auxInitPosition (0, 0, WIN_SIZE, WIN_SIZE);\n    auxInitWindow (\"qcsg\");\n}\n\nvoid Draw_ClearWindow (void)\n{\n\tstatic int\tinit;\n\tint\t\tw, h, g;\n\tvec_t\tmx, my;\n\n\tif (!drawflag)\n\t\treturn;\n\n\tif (!init)\n\t{\n\t\tinit = qtrue;\n\t\tInitWindow ();\n\t}\n\n\tglClearColor (1,0.8,0.8,0);\n\tglClear (GL_COLOR_BUFFER_BIT);\n\n\tw = (draw_maxs[0] - draw_mins[0]);\n\th = (draw_maxs[1] - draw_mins[1]);\n\n\tmx = draw_mins[0] + w/2;\n\tmy = draw_mins[1] + h/2;\n\n\tg = w > h ? w : h;\n\n\tglLoadIdentity ();\n    gluPerspective (90,  1,  2,  16384);\n\tgluLookAt (mx, my, draw_maxs[2] + g/2, mx , my, draw_maxs[2], 0, 1, 0);\n\n\tglColor3f (0,0,0);\n//\tglPolygonMode (GL_FRONT_AND_BACK, GL_LINE);\n\tglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);\n\tglDisable (GL_DEPTH_TEST);\n\tglEnable (GL_BLEND);\n\tglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\n\n#if 0\n\tglColor4f (1,0,0,0.5);\n\tglBegin (GL_POLYGON);\n\n\tglVertex3f (0, 500, 0);\n\tglVertex3f (0, 900, 0);\n\tglVertex3f (0, 900, 100);\n\tglVertex3f (0, 500, 100);\n\n\tglEnd ();\n#endif\n\n\tglFlush ();\n\n}\n\nvoid Draw_SetRed (void)\n{\n\tif (!drawflag)\n\t\treturn;\n\n\tglColor3f (1,0,0);\n}\n\nvoid Draw_SetGrey (void)\n{\n\tif (!drawflag)\n\t\treturn;\n\n\tglColor3f (0.5,0.5,0.5);\n}\n\nvoid Draw_SetBlack (void)\n{\n\tif (!drawflag)\n\t\treturn;\n\n\tglColor3f (0,0,0);\n}\n\nvoid DrawWinding (winding_t *w)\n{\n\tint\t\ti;\n\n\tif (!drawflag)\n\t\treturn;\n\n\tglColor4f (0,0,0,0.5);\n\tglBegin (GL_LINE_LOOP);\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\tglVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );\n\tglEnd ();\n\n\tglColor4f (0,1,0,0.3);\n\tglBegin (GL_POLYGON);\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\tglVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );\n\tglEnd ();\n\n\tglFlush ();\n}\n\nvoid DrawAuxWinding (winding_t *w)\n{\n\tint\t\ti;\n\n\tif (!drawflag)\n\t\treturn;\n\n\tglColor4f (0,0,0,0.5);\n\tglBegin (GL_LINE_LOOP);\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\tglVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );\n\tglEnd ();\n\n\tglColor4f (1,0,0,0.3);\n\tglBegin (GL_POLYGON);\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\tglVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );\n\tglEnd ();\n\n\tglFlush ();\n}\n\n//============================================================\n\n#define\tGLSERV_PORT\t25001\n\nqboolean\twins_init;\nint\t\t\tdraw_socket;\n\nvoid GLS_BeginScene (void)\n{\n\tWSADATA\twinsockdata;\n\tWORD\twVersionRequested; \n\tstruct sockaddr_in\taddress;\n\tint\t\tr;\n\n\tif (!wins_init)\n\t{\n\t\twins_init = qtrue;\n\n\t\twVersionRequested = MAKEWORD(1, 1); \n\n\t\tr = WSAStartup (MAKEWORD(1, 1), &winsockdata);\n\n\t\tif (r)\n\t\t\tError (\"Winsock initialization failed.\");\n\n\t}\n\n\t// connect a socket to the server\n\n\tdraw_socket = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);\n\tif (draw_socket == -1)\n\t\tError (\"draw_socket failed\");\n\n\taddress.sin_family = AF_INET;\n\taddress.sin_addr.s_addr = htonl(INADDR_LOOPBACK);\n\taddress.sin_port = GLSERV_PORT;\n\tr = connect (draw_socket, (struct sockaddr *)&address, sizeof(address));\n\tif (r == -1)\n\t{\n\t\tclosesocket (draw_socket);\n\t\tdraw_socket = 0;\n\t}\n}\n\nvoid GLS_Winding (winding_t *w, int code)\n{\n\tbyte\tbuf[1024];\n\tint\t\ti, j;\n\n\tif (!draw_socket)\n\t\treturn;\n\n\t((int *)buf)[0] = w->numpoints;\n\t((int *)buf)[1] = code;\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t\t((float *)buf)[2+i*3+j] = w->p[i][j];\n\n\tsend (draw_socket, buf, w->numpoints*12+8, 0);\n}\n\nvoid GLS_EndScene (void)\n{\n\tclosesocket (draw_socket);\n\tdraw_socket = 0;\n}\n"
  },
  {
    "path": "q3map/glfile.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n\nint\t\tc_glfaces;\n\nint PortalVisibleSides (portal_t *p)\n{\n\tint\t\tfcon, bcon;\n\n\tif (!p->onnode)\n\t\treturn 0;\t\t// outside\n\n\tfcon = p->nodes[0]->opaque;\n\tbcon = p->nodes[1]->opaque;\n\n\t// same contents never create a face\n\tif (fcon == bcon)\n\t\treturn 0;\n\n\tif (!fcon)\n\t\treturn 1;\n\tif (!bcon)\n\t\treturn 2;\n\treturn 0;\n}\n\nvoid OutputWinding (winding_t *w, FILE *glview)\n{\n\tstatic\tint\tlevel = 128;\n\tvec_t\t\tlight;\n\tint\t\t\ti;\n\n\tfprintf (glview, \"%i\\n\", w->numpoints);\n\tlevel+=28;\n\tlight = (level&255)/255.0;\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tfprintf (glview, \"%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f\\n\",\n\t\t\tw->p[i][0],\n\t\t\tw->p[i][1],\n\t\t\tw->p[i][2],\n\t\t\tlight,\n\t\t\tlight,\n\t\t\tlight);\n\t}\n\tfprintf (glview, \"\\n\");\n}\n\n/*\n=============\nOutputPortal\n=============\n*/\nvoid OutputPortal (portal_t *p, FILE *glview)\n{\n\twinding_t\t*w;\n\tint\t\tsides;\n\n\tsides = PortalVisibleSides (p);\n\tif (!sides)\n\t\treturn;\n\n\tc_glfaces++;\n\n\tw = p->winding;\n\n\tif (sides == 2)\t\t// back side\n\t\tw = ReverseWinding (w);\n\n\tOutputWinding (w, glview);\n\n\tif (sides == 2)\n\t\tFreeWinding(w);\n}\n\n/*\n=============\nWriteGLView_r\n=============\n*/\nvoid WriteGLView_r (node_t *node, FILE *glview)\n{\n\tportal_t\t*p, *nextp;\n\n\tif (node->planenum != PLANENUM_LEAF)\n\t{\n\t\tWriteGLView_r (node->children[0], glview);\n\t\tWriteGLView_r (node->children[1], glview);\n\t\treturn;\n\t}\n\n\t// write all the portals\n\tfor (p=node->portals ; p ; p=nextp)\n\t{\n\t\tif (p->nodes[0] == node)\n\t\t{\n\t\t\tOutputPortal (p, glview);\n\t\t\tnextp = p->next[0];\n\t\t}\n\t\telse\n\t\t\tnextp = p->next[1];\n\t}\n}\n\n/*\n=============\nWriteGLView\n=============\n*/\nvoid WriteGLView (tree_t *tree, char *source)\n{\n\tchar\tname[1024];\n\tFILE\t*glview;\n\n\tc_glfaces = 0;\n\tsprintf (name, \"%s%s.gl\",outbase, source);\n\t_printf (\"Writing %s\\n\", name);\n\n\tglview = fopen (name, \"w\");\n\tif (!glview)\n\t\tError (\"Couldn't open %s\", name);\n\tWriteGLView_r (tree->headnode, glview);\n\tfclose (glview);\n\n\t_printf (\"%5i c_glfaces\\n\", c_glfaces);\n}\n\n"
  },
  {
    "path": "q3map/leakfile.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n\n/*\n==============================================================================\n\nLEAF FILE GENERATION\n\nSave out name.line for qe3 to read\n==============================================================================\n*/\n\n\n/*\n=============\nLeakFile\n\nFinds the shortest possible chain of portals\nthat leads from the outside leaf to a specifically\noccupied leaf\n=============\n*/\nvoid LeakFile (tree_t *tree)\n{\n\tvec3_t\tmid;\n\tFILE\t*linefile;\n\tchar\tfilename[1024];\n\tnode_t\t*node;\n\tint\t\tcount;\n\n\tif (!tree->outside_node.occupied)\n\t\treturn;\n\n\tqprintf (\"--- LeakFile ---\\n\");\n\n\t//\n\t// write the points to the file\n\t//\n\tsprintf (filename, \"%s.lin\", source);\n\tlinefile = fopen (filename, \"w\");\n\tif (!linefile)\n\t\tError (\"Couldn't open %s\\n\", filename);\n\n\tcount = 0;\n\tnode = &tree->outside_node;\n\twhile (node->occupied > 1)\n\t{\n\t\tint\t\t\tnext;\n\t\tportal_t\t*p, *nextportal;\n\t\tnode_t\t\t*nextnode;\n\t\tint\t\t\ts;\n\n\t\t// find the best portal exit\n\t\tnext = node->occupied;\n\t\tfor (p=node->portals ; p ; p = p->next[!s])\n\t\t{\n\t\t\ts = (p->nodes[0] == node);\n\t\t\tif (p->nodes[s]->occupied\n\t\t\t\t&& p->nodes[s]->occupied < next)\n\t\t\t{\n\t\t\t\tnextportal = p;\n\t\t\t\tnextnode = p->nodes[s];\n\t\t\t\tnext = nextnode->occupied;\n\t\t\t}\n\t\t}\n\t\tnode = nextnode;\n\t\tWindingCenter (nextportal->winding, mid);\n\t\tfprintf (linefile, \"%f %f %f\\n\", mid[0], mid[1], mid[2]);\n\t\tcount++;\n\t}\n\t// add the occupant center\n\tGetVectorForKey (node->occupant, \"origin\", mid);\n\n\tfprintf (linefile, \"%f %f %f\\n\", mid[0], mid[1], mid[2]);\n\tqprintf (\"%5i point linefile\\n\", count+1);\n\n\tfclose (linefile);\n}\n\n"
  },
  {
    "path": "q3map/light.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// light.c\n\n#include \"light.h\"\n#ifdef _WIN32\n#ifdef _TTIMOBUILD\n#include \"pakstuff.h\"\n#else\n#include \"../libs/pakstuff.h\"\n#endif\n#endif\n\n\n#define\tEXTRASCALE\t2\n\ntypedef struct {\n\tfloat\t\tplane[4];\n\tvec3_t\t\torigin;\n\tvec3_t\t\tvectors[2];\n\tshaderInfo_t\t*si;\n} filter_t;\n\n#define\tMAX_FILTERS\t1024\nfilter_t\tfilters[MAX_FILTERS];\nint\t\t\tnumFilters;\n\nextern char\tsource[1024];\n\nqboolean\tnotrace;\nqboolean\tpatchshadows;\nqboolean\tdump;\nqboolean\textra;\nqboolean\textraWide;\nqboolean\tlightmapBorder;\n\nqboolean\tnoSurfaces;\n\nint\t\t\tsamplesize = 16;\t\t//sample size in units\nint\t\t\tnovertexlighting = 0;\nint\t\t\tnogridlighting = 0;\n\n// for run time tweaking of all area sources in the level\nfloat\t\tareaScale =\t0.25;\n\n// for run time tweaking of all point sources in the level\nfloat\t\tpointScale = 7500;\n\nqboolean\texactPointToPolygon = qtrue;\n\nfloat\t\tformFactorValueScale = 3;\n\nfloat\t\tlinearScale = 1.0 / 8000;\n\nlight_t\t\t*lights;\nint\t\t\tnumPointLights;\nint\t\t\tnumAreaLights;\n\nFILE\t\t*dumpFile;\n\nint\t\t\tc_visible, c_occluded;\n\n//int\t\t\tdefaultLightSubdivide = 128;\t\t// vary by surface size?\nint\t\t\tdefaultLightSubdivide = 999;\t\t// vary by surface size?\n\nvec3_t\t\tambientColor;\n\nvec3_t\t\tsurfaceOrigin[ MAX_MAP_DRAW_SURFS ];\nint\t\t\tentitySurface[ MAX_MAP_DRAW_SURFS ];\n\n// 7,9,11 normalized to avoid being nearly coplanar with common faces\n//vec3_t\t\tsunDirection = { 0.441835, 0.56807, 0.694313 };\n//vec3_t\t\tsunDirection = { 0.45, 0, 0.9 };\n//vec3_t\t\tsunDirection = { 0, 0, 1 };\n\n// these are usually overrided by shader values\nvec3_t\t\tsunDirection = { 0.45, 0.3, 0.9 };\nvec3_t\t\tsunLight = { 100, 100, 50 };\n\n\n\ntypedef struct {\n\tdbrush_t\t*b;\n\tvec3_t\t\tbounds[2];\n} skyBrush_t;\n\nint\t\t\tnumSkyBrushes;\nskyBrush_t\tskyBrushes[MAX_MAP_BRUSHES];\n\n\n/*\n\nthe corners of a patch mesh will always be exactly at lightmap samples.\nThe dimensions of the lightmap will be equal to the average length of the control\nmesh in each dimension divided by 2.\nThe lightmap sample points should correspond to the chosen subdivision points.\n\n*/\n\n/*\n===============================================================\n\nSURFACE LOADING\n\n===============================================================\n*/\n\n#define\tMAX_FACE_POINTS\t\t128\n\n/*\n===============\nSubdivideAreaLight\n\nSubdivide area lights that are very large\nA light that is subdivided will never backsplash, avoiding weird pools of light near edges\n===============\n*/\nvoid SubdivideAreaLight( shaderInfo_t *ls, winding_t *w, vec3_t normal, \n\t\t\t\t\t\tfloat areaSubdivide, qboolean backsplash ) {\n\tfloat\t\t\tarea, value, intensity;\n\tlight_t\t\t\t*dl, *dl2;\n\tvec3_t\t\t\tmins, maxs;\n\tint\t\t\t\taxis;\n\twinding_t\t\t*front, *back;\n\tvec3_t\t\t\tplaneNormal;\n\tfloat\t\t\tplaneDist;\n\n\tif ( !w ) {\n\t\treturn;\n\t}\n\n\tWindingBounds( w, mins, maxs );\n\n\t// check for subdivision\n\tfor ( axis = 0 ; axis < 3 ; axis++ ) {\n\t\tif ( maxs[axis] - mins[axis] > areaSubdivide ) {\n\t\t\tVectorClear( planeNormal );\n\t\t\tplaneNormal[axis] = 1;\n\t\t\tplaneDist = ( maxs[axis] + mins[axis] ) * 0.5;\n\t\t\tClipWindingEpsilon ( w, planeNormal, planeDist, ON_EPSILON, &front, &back );\n\t\t\tSubdivideAreaLight( ls, front, normal, areaSubdivide, qfalse );\n\t\t\tSubdivideAreaLight( ls, back, normal, areaSubdivide, qfalse );\n\t\t\tFreeWinding( w );\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// create a light from this\n\tarea = WindingArea (w);\n\tif ( area <= 0 || area > 20000000 ) {\n\t\treturn;\n\t}\n\n\tnumAreaLights++;\n\tdl = malloc(sizeof(*dl));\n\tmemset (dl, 0, sizeof(*dl));\n\tdl->next = lights;\n\tlights = dl;\n\tdl->type = emit_area;\n\n\tWindingCenter( w, dl->origin );\n\tdl->w = w;\n\tVectorCopy ( normal, dl->normal);\n\tdl->dist = DotProduct( dl->origin, normal );\n\n\tvalue = ls->value;\n\tintensity = value * area * areaScale;\n\tVectorAdd( dl->origin, dl->normal, dl->origin );\n\n\tVectorCopy( ls->color, dl->color );\n\n\tdl->photons = intensity;\n\n\t// emitColor is irrespective of the area\n\tVectorScale( ls->color, value*formFactorValueScale*areaScale, dl->emitColor );\n\n\tdl->si = ls;\n\n\tif ( ls->contents & CONTENTS_FOG ) {\n\t\tdl->twosided = qtrue;\n\t}\n\n\t// optionally create a point backsplash light\n\tif ( backsplash && ls->backsplashFraction > 0 ) {\n\t\tdl2 = malloc(sizeof(*dl));\n\t\tmemset (dl2, 0, sizeof(*dl2));\n\t\tdl2->next = lights;\n\t\tlights = dl2;\n\t\tdl2->type = emit_point;\n\n\t\tVectorMA( dl->origin, ls->backsplashDistance, normal, dl2->origin );\n\n\t\tVectorCopy( ls->color, dl2->color );\n\n\t\tdl2->photons = dl->photons * ls->backsplashFraction;\n\t\tdl2->si = ls;\n\t}\n}\n\n\n/*\n===============\nCountLightmaps\n===============\n*/\nvoid CountLightmaps( void ) {\n\tint\t\t\tcount;\n\tint\t\t\ti;\n\tdsurface_t\t*ds;\n\n\tqprintf (\"--- CountLightmaps ---\\n\");\n\tcount = 0;\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ ) {\n\t\t// see if this surface is light emiting\n\t\tds = &drawSurfaces[i];\n\t\tif ( ds->lightmapNum > count ) {\n\t\t\tcount = ds->lightmapNum;\n\t\t}\n\t}\n\n\tcount++;\n\tnumLightBytes = count * LIGHTMAP_WIDTH * LIGHTMAP_HEIGHT * 3;\n\tif ( numLightBytes > MAX_MAP_LIGHTING ) {\n\t\tError(\"MAX_MAP_LIGHTING exceeded\");\n\t}\n\n\tqprintf( \"%5i drawSurfaces\\n\", numDrawSurfaces );\n\tqprintf( \"%5i lightmaps\\n\", count );\n}\n\n/*\n===============\nCreateSurfaceLights\n\nThis creates area lights\n===============\n*/\nvoid CreateSurfaceLights( void ) {\n\tint\t\t\t\ti, j, side;\n\tdsurface_t\t\t*ds;\n\tshaderInfo_t\t*ls;\n\twinding_t\t\t*w;\n\tcFacet_t\t\t*f;\n\tlight_t\t\t\t*dl;\n\tvec3_t\t\t\torigin;\n\tdrawVert_t\t\t*dv;\n\tint\t\t\t\tc_lightSurfaces;\n\tfloat\t\t\tlightSubdivide;\n\tvec3_t\t\t\tnormal;\n\n\tqprintf (\"--- CreateSurfaceLights ---\\n\");\n\tc_lightSurfaces = 0;\n\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ ) {\n\t\t// see if this surface is light emiting\n\t\tds = &drawSurfaces[i];\n\n\t\tls = ShaderInfoForShader( dshaders[ ds->shaderNum].shader );\n\t\tif ( ls->value == 0 ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// determine how much we need to chop up the surface\n\t\tif ( ls->lightSubdivide ) {\n\t\t\tlightSubdivide = ls->lightSubdivide;\n\t\t} else {\n\t\t\tlightSubdivide = defaultLightSubdivide;\n\t\t}\n\n\t\tc_lightSurfaces++;\n\n\t\t// an autosprite shader will become\n\t\t// a point light instead of an area light\n\t\tif ( ls->autosprite ) {\n\t\t\t// autosprite geometry should only have four vertexes\n\t\t\tif ( surfaceTest[i] ) {\n\t\t\t\t// curve or misc_model\n\t\t\t\tf = surfaceTest[i]->facets;\n\t\t\t\tif ( surfaceTest[i]->numFacets != 1 || f->numBoundaries != 4 ) {\n\t\t\t\t\t_printf( \"WARNING: surface at (%i %i %i) has autosprite shader but isn't a quad\\n\",\n\t\t\t\t\t\t(int)f->points[0], (int)f->points[1], (int)f->points[2] );\n\t\t\t\t}\n\t\t\t\tVectorAdd( f->points[0], f->points[1], origin );\n\t\t\t\tVectorAdd( f->points[2], origin, origin );\n\t\t\t\tVectorAdd( f->points[3], origin, origin );\n\t\t\t\tVectorScale( origin, 0.25, origin );\n\t\t\t} else {\n\t\t\t\t// normal polygon\n\t\t\t\tdv = &drawVerts[ ds->firstVert ];\n\t\t\t\tif ( ds->numVerts != 4 ) {\n\t\t\t\t\t_printf( \"WARNING: surface at (%i %i %i) has autosprite shader but %i verts\\n\",\n\t\t\t\t\t\t(int)dv->xyz[0], (int)dv->xyz[1], (int)dv->xyz[2] );\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tVectorAdd( dv[0].xyz, dv[1].xyz, origin );\n\t\t\t\tVectorAdd( dv[2].xyz, origin, origin );\n\t\t\t\tVectorAdd( dv[3].xyz, origin, origin );\n\t\t\t\tVectorScale( origin, 0.25, origin );\n\t\t\t}\n\n\n\t\t\tnumPointLights++;\n\t\t\tdl = malloc(sizeof(*dl));\n\t\t\tmemset (dl, 0, sizeof(*dl));\n\t\t\tdl->next = lights;\n\t\t\tlights = dl;\n\n\t\t\tVectorCopy( origin, dl->origin );\n\t\t\tVectorCopy( ls->color, dl->color );\n\t\t\tdl->photons = ls->value * pointScale;\n\t\t\tdl->type = emit_point;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// possibly create for both sides of the polygon\n\t\tfor ( side = 0 ; side <= ls->twoSided ; side++ ) {\n\t\t\t// create area lights\n\t\t\tif ( surfaceTest[i] ) {\n\t\t\t\t// curve or misc_model\n\t\t\t\tfor ( j = 0 ; j < surfaceTest[i]->numFacets ; j++ ) {\n\t\t\t\t\tf = surfaceTest[i]->facets + j;\n\t\t\t\t\tw = AllocWinding( f->numBoundaries );\n\t\t\t\t\tw->numpoints = f->numBoundaries;\n\t\t\t\t\tmemcpy( w->p, f->points, f->numBoundaries * 12 );\n\n\t\t\t\t\tVectorCopy( f->surface, normal );\n\t\t\t\t\tif ( side ) {\n\t\t\t\t\t\twinding_t\t*t;\n\n\t\t\t\t\t\tt = w;\n\t\t\t\t\t\tw = ReverseWinding( t );\n\t\t\t\t\t\tFreeWinding( t );\n\t\t\t\t\t\tVectorSubtract( vec3_origin, normal, normal );\n\t\t\t\t\t}\n\t\t\t\t\tSubdivideAreaLight( ls, w, normal, lightSubdivide, qtrue );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// normal polygon\n\n\t\t\t\tw = AllocWinding( ds->numVerts );\n\t\t\t\tw->numpoints = ds->numVerts;\n\t\t\t\tfor ( j = 0 ; j < ds->numVerts ; j++ ) {\n\t\t\t\t\tVectorCopy( drawVerts[ds->firstVert+j].xyz, w->p[j] );\n\t\t\t\t}\n\t\t\t\tVectorCopy( ds->lightmapVecs[2], normal );\n\t\t\t\tif ( side ) {\n\t\t\t\t\twinding_t\t*t;\n\n\t\t\t\t\tt = w;\n\t\t\t\t\tw = ReverseWinding( t );\n\t\t\t\t\tFreeWinding( t );\n\t\t\t\t\tVectorSubtract( vec3_origin, normal, normal );\n\t\t\t\t}\n\t\t\t\tSubdivideAreaLight( ls, w, normal, lightSubdivide, qtrue );\n\t\t\t}\n\t\t}\n\t}\n\n\t_printf( \"%5i light emitting surfaces\\n\", c_lightSurfaces );\n}\n\n\n\n/*\n================\nFindSkyBrushes\n================\n*/\nvoid FindSkyBrushes( void ) {\n\tint\t\t\t\ti, j;\n\tdbrush_t\t\t*b;\n\tskyBrush_t\t\t*sb;\n\tshaderInfo_t\t*si;\n\tdbrushside_t\t*s;\n\n\t// find the brushes\n\tfor ( i = 0 ; i < numbrushes ; i++ ) {\n\t\tb = &dbrushes[i];\n\t\tfor ( j = 0 ; j < b->numSides ; j++ ) {\n\t\t\ts = &dbrushsides[ b->firstSide + j ];\n\t\t\tif ( dshaders[ s->shaderNum ].surfaceFlags & SURF_SKY ) {\n\t\t\t\tsb = &skyBrushes[ numSkyBrushes ];\n\t\t\t\tsb->b = b;\n\t\t\t\tsb->bounds[0][0] = -dplanes[ dbrushsides[ b->firstSide + 0 ].planeNum ].dist - 1;\n\t\t\t\tsb->bounds[1][0] = dplanes[ dbrushsides[ b->firstSide + 1 ].planeNum ].dist + 1;\n\t\t\t\tsb->bounds[0][1] = -dplanes[ dbrushsides[ b->firstSide + 2 ].planeNum ].dist - 1;\n\t\t\t\tsb->bounds[1][1] = dplanes[ dbrushsides[ b->firstSide + 3 ].planeNum ].dist + 1;\n\t\t\t\tsb->bounds[0][2] = -dplanes[ dbrushsides[ b->firstSide + 4 ].planeNum ].dist - 1;\n\t\t\t\tsb->bounds[1][2] = dplanes[ dbrushsides[ b->firstSide + 5 ].planeNum ].dist + 1;\n\t\t\t\tnumSkyBrushes++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t// default\n\tVectorNormalize( sunDirection, sunDirection );\n\n\t// find the sky shader\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ ) {\n\t\tsi = ShaderInfoForShader( dshaders[ drawSurfaces[i].shaderNum ].shader );\n\t\tif ( si->surfaceFlags & SURF_SKY ) {\n\t\t\tVectorCopy( si->sunLight, sunLight );\n\t\t\tVectorCopy( si->sunDirection, sunDirection );\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/*\n=================================================================\n\n  LIGHT SETUP\n\n=================================================================\n*/\n\n/*\n==================\nFindTargetEntity\n==================\n*/\nentity_t *FindTargetEntity( const char *target ) {\n\tint\t\t\ti;\n\tconst char\t*n;\n\n\tfor ( i = 0 ; i < num_entities ; i++ ) {\n\t\tn = ValueForKey (&entities[i], \"targetname\");\n\t\tif ( !strcmp (n, target) ) {\n\t\t\treturn &entities[i];\n\t\t}\n\t}\n\n\treturn NULL;\n}\n\n\n\n/*\n=============\nCreateEntityLights\n=============\n*/\nvoid CreateEntityLights (void)\n{\n\tint\t\ti;\n\tlight_t\t*dl;\n\tentity_t\t*e, *e2;\n\tconst char\t*name;\n\tconst char\t*target;\n\tvec3_t\tdest;\n\tconst char\t*_color;\n\tfloat\tintensity;\n\tint\t\tspawnflags;\n\n\t//\n\t// entities\n\t//\n\tfor ( i = 0 ; i < num_entities ; i++ ) {\n\t\te = &entities[i];\n\t\tname = ValueForKey (e, \"classname\");\n\t\tif (strncmp (name, \"light\", 5))\n\t\t\tcontinue;\n\n\t\tnumPointLights++;\n\t\tdl = malloc(sizeof(*dl));\n\t\tmemset (dl, 0, sizeof(*dl));\n\t\tdl->next = lights;\n\t\tlights = dl;\n\n\t\tspawnflags = FloatForKey (e, \"spawnflags\");\n\t\tif ( spawnflags & 1 ) {\n\t\t\tdl->linearLight = qtrue;\n\t\t}\n\n\t\tGetVectorForKey (e, \"origin\", dl->origin);\n\t\tdl->style = FloatForKey (e, \"_style\");\n\t\tif (!dl->style)\n\t\t\tdl->style = FloatForKey (e, \"style\");\n\t\tif (dl->style < 0)\n\t\t\tdl->style = 0;\n\n\t\tintensity = FloatForKey (e, \"light\");\n\t\tif (!intensity)\n\t\t\tintensity = FloatForKey (e, \"_light\");\n\t\tif (!intensity)\n\t\t\tintensity = 300;\n\t\t_color = ValueForKey (e, \"_color\");\n\t\tif (_color && _color[0])\n\t\t{\n\t\t\tsscanf (_color, \"%f %f %f\", &dl->color[0],&dl->color[1],&dl->color[2]);\n\t\t\tColorNormalize (dl->color, dl->color);\n\t\t}\n\t\telse\n\t\t\tdl->color[0] = dl->color[1] = dl->color[2] = 1.0;\n\n\t\tintensity = intensity * pointScale;\n\t\tdl->photons = intensity;\n\n\t\tdl->type = emit_point;\n\n\t\t// lights with a target will be spotlights\n\t\ttarget = ValueForKey (e, \"target\");\n\n\t\tif ( target[0] ) {\n\t\t\tfloat\tradius;\n\t\t\tfloat\tdist;\n\n\t\t\te2 = FindTargetEntity (target);\n\t\t\tif (!e2) {\n\t\t\t\t_printf (\"WARNING: light at (%i %i %i) has missing target\\n\",\n\t\t\t\t(int)dl->origin[0], (int)dl->origin[1], (int)dl->origin[2]);\n\t\t\t} else {\n\t\t\t\tGetVectorForKey (e2, \"origin\", dest);\n\t\t\t\tVectorSubtract (dest, dl->origin, dl->normal);\n\t\t\t\tdist = VectorNormalize (dl->normal, dl->normal);\n\t\t\t\tradius = FloatForKey (e, \"radius\");\n\t\t\t\tif ( !radius ) {\n\t\t\t\t\tradius = 64;\n\t\t\t\t}\n\t\t\t\tif ( !dist ) {\n\t\t\t\t\tdist = 64;\n\t\t\t\t}\n\t\t\t\tdl->radiusByDist = (radius + 16) / dist;\n\t\t\t\tdl->type = emit_spotlight;\n\t\t\t}\n\t\t}\n\t}\n}\n\n//=================================================================\n\n/*\n================\nSetEntityOrigins\n\nFind the offset values for inline models\n================\n*/\nvoid SetEntityOrigins( void ) {\n\tint\t\t\ti, j;\n\tentity_t\t*e;\n\tvec3_t\t\torigin;\n\tconst char\t*key;\n\tint\t\t\tmodelnum;\n\tdmodel_t\t*dm;\n\n\tfor ( i=0 ; i < num_entities ; i++ ) {\n\t\te = &entities[i];\n\t\tkey = ValueForKey (e, \"model\");\n\t\tif ( key[0] != '*' ) {\n\t\t\tcontinue;\n\t\t}\n\t\tmodelnum = atoi( key + 1 );\n\t\tdm = &dmodels[ modelnum ];\n\n\t\t// set entity surface to true for all surfaces for this model\n\t\tfor ( j = 0 ; j < dm->numSurfaces ; j++ ) {\n\t\t\tentitySurface[ dm->firstSurface + j ] = qtrue;\n\t\t}\n\n\t\tkey = ValueForKey (e, \"origin\");\n\t\tif ( !key[0] ) {\n\t\t\tcontinue;\n\t\t}\n\t\tGetVectorForKey ( e, \"origin\", origin );\n\n\t\t// set origin for all surfaces for this model\n\t\tfor ( j = 0 ; j < dm->numSurfaces ; j++ ) {\n\t\t\tVectorCopy( origin, surfaceOrigin[ dm->firstSurface + j ] );\n\t\t}\n\t}\n}\n\n\n/*\n=================================================================\n\n\n=================================================================\n*/\n\n#define\tMAX_POINTS_ON_WINDINGS\t64\n\n/*\n================\nPointToPolygonFormFactor\n================\n*/\nfloat\tPointToPolygonFormFactor( const vec3_t point, const vec3_t normal, const winding_t *w ) {\n\tvec3_t\t\ttriVector, triNormal;\n\tint\t\t\ti, j;\n\tvec3_t\t\tdirs[MAX_POINTS_ON_WINDING];\n\tfloat\t\ttotal;\n\tfloat\t\tdot, angle, facing;\n\n\tfor ( i = 0 ; i < w->numpoints ; i++ ) {\n\t\tVectorSubtract( w->p[i], point, dirs[i] );\n\t\tVectorNormalize( dirs[i], dirs[i] );\n\t}\n\n\t// duplicate first vertex to avoid mod operation\n\tVectorCopy( dirs[0], dirs[i] );\n\n\ttotal = 0;\n\tfor ( i = 0 ; i < w->numpoints ; i++ ) {\n\t\tj = i+1;\n\t\tdot = DotProduct( dirs[i], dirs[j] );\n\n\t\t// roundoff can cause slight creep, which gives an IND from acos\n\t\tif ( dot > 1.0 ) {\n\t\t\tdot = 1.0;\n\t\t} else if ( dot < -1.0 ) {\n\t\t\tdot = -1.0;\n\t\t}\n\t\t\n\t\tangle = acos( dot );\n\t\tCrossProduct( dirs[i], dirs[j], triVector );\n\t\tif ( VectorNormalize( triVector, triNormal ) < 0.0001 ) {\n\t\t\tcontinue;\n\t\t}\n\t\tfacing = DotProduct( normal, triNormal );\n\t\ttotal += facing * angle;\n\n\t\tif ( total > 6.3 || total < -6.3 ) {\n\t\t\tstatic qboolean printed;\n\n\t\t\tif ( !printed ) {\n\t\t\t\tprinted = qtrue;\n\t\t\t\t_printf( \"WARNING: bad PointToPolygonFormFactor: %f at %1.1f %1.1f %1.1f from %1.1f %1.1f %1.1f\\n\", total,\n\t\t\t\t\tw->p[i][0], w->p[i][1], w->p[i][2], point[0], point[1], point[2]);\n\t\t\t}\n\t\t\treturn 0;\n\t\t}\n\n\t}\n\n\ttotal /= 2*3.141592657;\t\t// now in the range of 0 to 1 over the entire incoming hemisphere\n\n\treturn total;\n}\n\n\n/*\n================\nFilterTrace\n\nReturns 0 to 1.0 filter fractions for the given trace\n================\n*/\nvoid\tFilterTrace( const vec3_t start, const vec3_t end, vec3_t filter ) {\n\tfloat\t\td1, d2;\n\tfilter_t\t*f;\n\tint\t\t\tfilterNum;\n\tvec3_t\t\tpoint;\n\tfloat\t\tfrac;\n\tint\t\t\ti;\n\tfloat\t\ts, t;\n\tint\t\t\tu, v;\n\tint\t\t\tx, y;\n\tbyte\t\t*pixel;\n\tfloat\t\tradius;\n\tfloat\t\tlen;\n\tvec3_t\t\ttotal;\n\n\tfilter[0] = 1.0;\n\tfilter[1] = 1.0;\n\tfilter[2] = 1.0;\n\n\tfor ( filterNum = 0 ; filterNum < numFilters ; filterNum++ ) {\n\t\tf = &filters[ filterNum ];\n\n\t\t// see if the plane is crossed\n\t\td1 = DotProduct( start, f->plane ) - f->plane[3];\n\t\td2 = DotProduct( end, f->plane ) - f->plane[3];\n\n\t\tif ( ( d1 < 0 ) == ( d2 < 0 ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// calculate the crossing point\n\t\tfrac = d1 / ( d1 - d2 );\n\n\t\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\t\tpoint[i] = start[i] + frac * ( end[i] - start[i] );\n\t\t}\n\n\t\tVectorSubtract( point, f->origin, point );\n\n\t\ts = DotProduct( point, f->vectors[0] );\n\t\tt = 1.0 - DotProduct( point, f->vectors[1] );\n\t\tif ( s < 0 || s >= 1.0 || t < 0 || t >= 1.0 ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// decide the filter size\n\t\tradius = 10 * frac;\n\t\tlen = VectorLength( f->vectors[0] );\n\t\tif ( !len ) {\n\t\t\tcontinue;\n\t\t}\n\t\tradius = radius * len * f->si->width;\n\n\t\t// look up the filter, taking multiple samples\n\t\tVectorClear( total );\n\t\tfor ( u = -1 ; u <= 1 ; u++ ) {\n\t\t\tfor ( v = -1 ; v <=1 ; v++ ) {\n\t\t\t\tx = s * f->si->width + u * radius;\n\t\t\t\tif ( x < 0 ) {\n\t\t\t\t\tx = 0;\n\t\t\t\t}\n\t\t\t\tif ( x >= f->si->width ) {\n\t\t\t\t\tx = f->si->width - 1;\n\t\t\t\t}\n\t\t\t\ty = t * f->si->height + v * radius;\n\t\t\t\tif ( y < 0 ) {\n\t\t\t\t\ty = 0;\n\t\t\t\t}\n\t\t\t\tif ( y >= f->si->height ) {\n\t\t\t\t\ty = f->si->height - 1;\n\t\t\t\t}\n\n\t\t\t\tpixel = f->si->pixels + ( y * f->si->width + x ) * 4;\n\t\t\t\ttotal[0] += pixel[0];\n\t\t\t\ttotal[1] += pixel[1];\n\t\t\t\ttotal[2] += pixel[2];\n\t\t\t}\n\t\t}\n\n\t\tfilter[0] *= total[0]/(255.0*9);\n\t\tfilter[1] *= total[1]/(255.0*9);\n\t\tfilter[2] *= total[2]/(255.0*9);\n\t}\n\n}\n\n/*\n================\nSunToPoint\n\nReturns an amount of light to add at the point\n================\n*/\nint\t\tc_sunHit, c_sunMiss;\nvoid SunToPoint( const vec3_t origin, traceWork_t *tw, vec3_t addLight ) {\n\tint\t\t\ti;\n\ttrace_t\t\ttrace;\n\tskyBrush_t\t*b;\n\tvec3_t\t\tend;\n\n\tif ( !numSkyBrushes ) {\n\t\tVectorClear( addLight );\n\t\treturn;\n\t}\n\n\tVectorMA( origin, MAX_WORLD_COORD * 2, sunDirection, end );\n\n\tTraceLine( origin, end, &trace, qtrue, tw );\n\n\t// see if trace.hit is inside a sky brush\n\tfor ( i = 0 ; i < numSkyBrushes ; i++) {\n\t\tb = &skyBrushes[ i ];\n\n\t\t// this assumes that sky brushes are axial...\n\t\tif (   trace.hit[0] < b->bounds[0][0] \n\t\t\t|| trace.hit[0] > b->bounds[1][0]\n\t\t\t|| trace.hit[1] < b->bounds[0][1]\n\t\t\t|| trace.hit[1] > b->bounds[1][1]\n\t\t\t|| trace.hit[2] < b->bounds[0][2]\n\t\t\t|| trace.hit[2] > b->bounds[1][2] ) {\n\t\t\tcontinue;\n\t\t}\n\n\n\t\t// trace again to get intermediate filters\n\t\tTraceLine( origin, trace.hit, &trace, qtrue, tw );\n\n\t\t// we hit the sky, so add sunlight\n\t\tif ( numthreads == 1 ) {\n\t\t\tc_sunHit++;\n\t\t}\n\t\taddLight[0] = trace.filter[0] * sunLight[0];\n\t\taddLight[1] = trace.filter[1] * sunLight[1];\n\t\taddLight[2] = trace.filter[2] * sunLight[2];\n\n\t\treturn;\n\t}\n\n\tif ( numthreads == 1 ) {\n\t\tc_sunMiss++;\n\t}\n\n\tVectorClear( addLight );\n}\n\n/*\n================\nSunToPlane\n================\n*/\nvoid SunToPlane( const vec3_t origin, const vec3_t normal, vec3_t color, traceWork_t *tw ) {\n\tfloat\t\tangle;\n\tvec3_t\t\tsunColor;\n\n\tif ( !numSkyBrushes ) {\n\t\treturn;\n\t}\n\n\tangle = DotProduct( normal, sunDirection );\n\tif ( angle <= 0 ) {\n\t\treturn;\t\t// facing away\n\t}\n\n\tSunToPoint( origin, tw, sunColor );\n\tVectorMA( color, angle, sunColor, color );\n}\n\n/*\n================\nLightingAtSample\n================\n*/\nvoid LightingAtSample( vec3_t origin, vec3_t normal, vec3_t color, \n\t\t\t\t\t  qboolean testOcclusion, qboolean forceSunLight, traceWork_t *tw ) {\n\tlight_t\t\t*light;\n\ttrace_t\t\ttrace;\n\tfloat\t\tangle;\n\tfloat\t\tadd;\n\tfloat\t\tdist;\n\tvec3_t\t\tdir;\n\n\tVectorCopy( ambientColor, color );\n\n\t// trace to all the lights\n\tfor ( light = lights ; light ; light = light->next ) {\n\n\t\t//MrE: if the light is behind the surface\n\t\tif ( DotProduct(light->origin, normal) - DotProduct(normal, origin) < 0 )\n\t\t\tcontinue;\n\t\t// testing exact PTPFF\n\t\tif ( exactPointToPolygon && light->type == emit_area ) {\n\t\t\tfloat\t\tfactor;\n\t\t\tfloat\t\td;\n\t\t\tvec3_t\t\tpushedOrigin;\n\n\t\t\t// see if the point is behind the light\n\t\t\td = DotProduct( origin, light->normal ) - light->dist;\n\t\t\tif ( !light->twosided ) {\n\t\t\t\tif ( d < -1 ) {\n\t\t\t\t\tcontinue;\t\t// point is behind light\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// test occlusion and find light filters\n\t\t\t// clip the line, tracing from the surface towards the light\n\t\t\tif ( !notrace && testOcclusion ) {\n\t\t\t\tTraceLine( origin, light->origin, &trace, qfalse, tw );\n\n\t\t\t\t// other light rays must not hit anything\n\t\t\t\tif ( trace.passSolid ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttrace.filter[0] = 1.0;\n\t\t\t\ttrace.filter[1] = 1.0;\n\t\t\t\ttrace.filter[2] = 1.0;\n\t\t\t}\n\n\t\t\t// nudge the point so that it is clearly forward of the light\n\t\t\t// so that surfaces meeting a light emiter don't get black edges\n\t\t\tif ( d > -8 && d < 8 ) {\n\t\t\t\tVectorMA( origin, (8-d), light->normal, pushedOrigin );\t\n\t\t\t} else {\n\t\t\t\tVectorCopy( origin, pushedOrigin );\n\t\t\t}\n\n\t\t\t// calculate the contribution\n\t\t\tfactor = PointToPolygonFormFactor( pushedOrigin, normal, light->w );\n\t\t\tif ( factor <= 0 ) {\n\t\t\t\tif ( light->twosided ) {\n\t\t\t\t\tfactor = -factor;\n\t\t\t\t} else {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tcolor[0] += factor * light->emitColor[0] * trace.filter[0];\n\t\t\tcolor[1] += factor * light->emitColor[1] * trace.filter[1];\n\t\t\tcolor[2] += factor * light->emitColor[2] * trace.filter[2];\n\n\t\t\tcontinue;\n\t\t}\n\n\t\t// calculate the amount of light at this sample\n\t\tif ( light->type == emit_point ) {\n\t\t\tVectorSubtract( light->origin, origin, dir );\n\t\t\tdist = VectorNormalize( dir, dir );\n\t\t\t// clamp the distance to prevent super hot spots\n\t\t\tif ( dist < 16 ) {\n\t\t\t\tdist = 16;\n\t\t\t}\n\t\t\tangle = DotProduct( normal, dir );\n\t\t\tif ( light->linearLight ) {\n\t\t\t\tadd = angle * light->photons * linearScale - dist;\n\t\t\t\tif ( add < 0 ) {\n\t\t\t\t\tadd = 0;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tadd = light->photons / ( dist * dist ) * angle;\n\t\t\t}\n\t\t} else if ( light->type == emit_spotlight ) {\n\t\t\tfloat\tdistByNormal;\n\t\t\tvec3_t\tpointAtDist;\n\t\t\tfloat\tradiusAtDist;\n\t\t\tfloat\tsampleRadius;\n\t\t\tvec3_t\tdistToSample;\n\t\t\tfloat\tconeScale;\n\n\t\t\tVectorSubtract( light->origin, origin, dir );\n\n\t\t\tdistByNormal = -DotProduct( dir, light->normal );\n\t\t\tif ( distByNormal < 0 ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tVectorMA( light->origin, distByNormal, light->normal, pointAtDist );\n\t\t\tradiusAtDist = light->radiusByDist * distByNormal;\n\n\t\t\tVectorSubtract( origin, pointAtDist, distToSample );\n\t\t\tsampleRadius = VectorLength( distToSample );\n\n\t\t\tif ( sampleRadius >= radiusAtDist ) {\n\t\t\t\tcontinue;\t\t// outside the cone\n\t\t\t}\n\t\t\tif ( sampleRadius <= radiusAtDist - 32 ) {\n\t\t\t\tconeScale = 1.0;\t// fully inside\n\t\t\t} else {\n\t\t\t\tconeScale = ( radiusAtDist - sampleRadius ) / 32.0;\n\t\t\t}\n\t\t\t\n\t\t\tdist = VectorNormalize( dir, dir );\n\t\t\t// clamp the distance to prevent super hot spots\n\t\t\tif ( dist < 16 ) {\n\t\t\t\tdist = 16;\n\t\t\t}\n\t\t\tangle = DotProduct( normal, dir );\n\t\t\tadd = light->photons / ( dist * dist ) * angle * coneScale;\n\n\t\t} else if ( light->type == emit_area ) {\n\t\t\tVectorSubtract( light->origin, origin, dir );\n\t\t\tdist = VectorNormalize( dir, dir );\n\t\t\t// clamp the distance to prevent super hot spots\n\t\t\tif ( dist < 16 ) {\n\t\t\t\tdist = 16;\n\t\t\t}\n\t\t\tangle = DotProduct( normal, dir );\n\t\t\tif ( angle <= 0 ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tangle *= -DotProduct( light->normal, dir );\n\t\t\tif ( angle <= 0 ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif ( light->linearLight ) {\n\t\t\t\tadd = angle * light->photons * linearScale - dist;\n\t\t\t\tif ( add < 0 ) {\n\t\t\t\t\tadd = 0;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tadd = light->photons / ( dist * dist ) * angle;\n\t\t\t}\n\t\t}\n\n\t\tif ( add <= 1.0 ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// clip the line, tracing from the surface towards the light\n\t\tif ( !notrace && testOcclusion ) {\n\t\t\tTraceLine( origin, light->origin, &trace, qfalse, tw );\n\n\t\t\t// other light rays must not hit anything\n\t\t\tif ( trace.passSolid ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else {\n\t\t\ttrace.filter[0] = 1;\n\t\t\ttrace.filter[1] = 1;\n\t\t\ttrace.filter[2] = 1;\n\t\t}\n\t\t\n\t\t// add the result\n\t\tcolor[0] += add * light->color[0] * trace.filter[0];\n\t\tcolor[1] += add * light->color[1] * trace.filter[1];\n\t\tcolor[2] += add * light->color[2] * trace.filter[2];\n\t}\n\n\t//\n\t// trace directly to the sun\n\t//\n\tif ( testOcclusion || forceSunLight ) {\n\t\tSunToPlane( origin, normal, color, tw );\n\t}\n}\n\n/*\n=============\nPrintOccluded\n\nFor debugging\n=============\n*/\nvoid PrintOccluded( byte occluded[LIGHTMAP_WIDTH*EXTRASCALE][LIGHTMAP_HEIGHT*EXTRASCALE], \n\t\t\t\t   int width, int height ) {\n\tint\ti, j;\n\n\t_printf( \"\\n\" );\n\n\tfor ( i = 0 ; i < height ; i++ ) {\n\t\tfor ( j = 0 ; j < width ; j++ ) {\n\t\t\t_printf(\"%i\", (int)occluded[j][i] );\n\t\t}\n\t\t_printf( \"\\n\" );\n\t}\n}\n\n\n/*\n=============\nVertexLighting\n\nVertex lighting will completely ignore occlusion, because\nshadows would not be resolvable anyway.\n=============\n*/\nvoid VertexLighting( dsurface_t *ds, qboolean testOcclusion, qboolean forceSunLight, float scale, traceWork_t *tw ) {\n\tint\t\t\ti, j;\n\tdrawVert_t\t*dv;\n\tvec3_t\t\tsample, normal;\n\tfloat\t\tmax;\n\n\tVectorCopy( ds->lightmapVecs[2], normal );\n\n\t// generate vertex lighting\n\tfor ( i = 0 ; i < ds->numVerts ; i++ ) {\n\t\tdv = &drawVerts[ ds->firstVert + i ];\n\n\t\tif ( ds->patchWidth ) {\n\t\t\tLightingAtSample( dv->xyz, dv->normal, sample, testOcclusion, forceSunLight, tw );\n\t\t}\n\t\telse if (ds->surfaceType == MST_TRIANGLE_SOUP) {\n\t\t\tLightingAtSample( dv->xyz, dv->normal, sample, testOcclusion, forceSunLight, tw );\n\t\t}\n\t\telse {\n\t\t\tLightingAtSample( dv->xyz, normal, sample, testOcclusion, forceSunLight, tw );\n\t\t}\n\n\t\tif (scale >= 0)\n\t\t\tVectorScale(sample, scale, sample);\n\t\t// clamp with color normalization\n\t\tmax = sample[0];\n\t\tif ( sample[1] > max ) {\n\t\t\tmax = sample[1];\n\t\t}\n\t\tif ( sample[2] > max ) {\n\t\t\tmax = sample[2];\n\t\t}\n\t\tif ( max > 255 ) {\n\t\t\tVectorScale( sample, 255/max, sample );\n\t\t}\n\n\t\t// save the sample\n\t\tfor ( j = 0 ; j < 3 ; j++ ) {\n\t\t\tif ( sample[j] > 255 ) {\n\t\t\t\tsample[j] = 255;\n\t\t\t}\n\t\t\tdv->color[j] = sample[j];\n\t\t}\n\n\t\t// Don't bother writing alpha since it will already be set to 255,\n\t\t// plus we don't want to write over alpha generated by SetTerrainTextures\n\t\t//dv->color[3] = 255;\n\t}\n}\n\n\n/*\n=================\nLinearSubdivideMesh\n\nFor extra lighting, just midpoint one of the axis.\nThe edges are clamped at the original edges.\n=================\n*/\nmesh_t *LinearSubdivideMesh( mesh_t *in ) {\n\tint\t\t\ti, j;\n\tmesh_t\t\t*out;\n\tdrawVert_t\t*v1, *v2, *vout;\n\n\tout = malloc( sizeof( *out ) );\n\n\tout->width = in->width * 2;\n\tout->height = in->height;\n\tout->verts = malloc( out->width * out->height * sizeof(*out->verts) );\n\tfor ( j = 0 ; j < in->height ; j++ ) {\n\t\tout->verts[ j * out->width + 0 ] = in->verts[ j * in->width + 0 ];\n\t\tout->verts[ j * out->width + out->width - 1 ] = in->verts[ j * in->width + in->width - 1 ];\n\t\tfor ( i = 1 ; i < out->width - 1 ; i+= 2 ) {\n\t\t\tv1 = in->verts + j * in->width + (i >> 1);\n\t\t\tv2 = v1 + 1;\n\t\t\tvout = out->verts + j * out->width + i;\n\n\t\t\tvout->xyz[0] = 0.75 * v1->xyz[0] + 0.25 * v2->xyz[0];\n\t\t\tvout->xyz[1] = 0.75 * v1->xyz[1] + 0.25 * v2->xyz[1];\n\t\t\tvout->xyz[2] = 0.75 * v1->xyz[2] + 0.25 * v2->xyz[2];\n\n\t\t\tvout->normal[0] = 0.75 * v1->normal[0] + 0.25 * v2->normal[0];\n\t\t\tvout->normal[1] = 0.75 * v1->normal[1] + 0.25 * v2->normal[1];\n\t\t\tvout->normal[2] = 0.75 * v1->normal[2] + 0.25 * v2->normal[2];\n\n\t\t\tVectorNormalize( vout->normal, vout->normal );\n\n\t\t\tvout++;\n\n\t\t\tvout->xyz[0] = 0.25 * v1->xyz[0] + 0.75 * v2->xyz[0];\n\t\t\tvout->xyz[1] = 0.25 * v1->xyz[1] + 0.75 * v2->xyz[1];\n\t\t\tvout->xyz[2] = 0.25 * v1->xyz[2] + 0.75 * v2->xyz[2];\n\n\t\t\tvout->normal[0] = 0.25 * v1->normal[0] + 0.75 * v2->normal[0];\n\t\t\tvout->normal[1] = 0.25 * v1->normal[1] + 0.75 * v2->normal[1];\n\t\t\tvout->normal[2] = 0.25 * v1->normal[2] + 0.75 * v2->normal[2];\n\n\t\t\tVectorNormalize( vout->normal, vout->normal );\n\n\t\t}\n\t}\n\n\tFreeMesh( in );\n\n\treturn out;\n}\n\n/*\n==============\nColorToBytes\n==============\n*/\nvoid ColorToBytes( const float *color, byte *colorBytes ) {\n\tfloat\tmax;\n\tvec3_t\tsample;\n\n\tVectorCopy( color, sample );\n\n\t// clamp with color normalization\n\tmax = sample[0];\n\tif ( sample[1] > max ) {\n\t\tmax = sample[1];\n\t}\n\tif ( sample[2] > max ) {\n\t\tmax = sample[2];\n\t}\n\tif ( max > 255 ) {\n\t\tVectorScale( sample, 255/max, sample );\n\t}\n\tcolorBytes[ 0 ] = sample[0];\n\tcolorBytes[ 1 ] = sample[1];\n\tcolorBytes[ 2 ] = sample[2];\n}\n\n\n\n/*\n=============\nTraceLtm\n=============\n*/\nvoid TraceLtm( int num ) {\n\tdsurface_t\t*ds;\n\tint\t\t\ti, j, k;\n\tint\t\t\tx, y;\n\tint\t\t\tposition, numPositions;\n\tvec3_t\t\tbase, origin, normal;\n\tbyte\t\toccluded[LIGHTMAP_WIDTH*EXTRASCALE][LIGHTMAP_HEIGHT*EXTRASCALE];\n\tvec3_t\t\tcolor[LIGHTMAP_WIDTH*EXTRASCALE][LIGHTMAP_HEIGHT*EXTRASCALE];\n\ttraceWork_t\ttw;\n\tvec3_t\t\taverage;\n\tint\t\t\tcount;\n\tmesh_t\t\tsrcMesh, *mesh, *subdivided;\n\tshaderInfo_t\t*si;\n\tstatic float\tnudge[2][9] = {\n\t\t{ 0, -1, 0, 1, -1, 1, -1, 0, 1 },\n\t\t{ 0, -1, -1, -1, 0, 0, 1, 1, 1 }\n\t};\n\tint\t\t\tsampleWidth, sampleHeight, ssize;\n\tvec3_t\t\tlightmapOrigin, lightmapVecs[2];\n\tint widthtable[LIGHTMAP_WIDTH], heighttable[LIGHTMAP_WIDTH];\n\n\tds = &drawSurfaces[num];\n\tsi = ShaderInfoForShader( dshaders[ ds->shaderNum].shader );\n\n\t// vertex-lit triangle model\n\tif ( ds->surfaceType == MST_TRIANGLE_SOUP ) {\n\t\tVertexLighting( ds, !si->noVertexShadows, si->forceSunLight, 1.0, &tw );\n\t\treturn;\n\t}\n\t\n\tif ( ds->lightmapNum == -1 ) {\n\t\treturn;\t\t// doesn't need lighting at all\n\t}\n\n\tif (!novertexlighting) {\n\t\t// calculate the vertex lighting for gouraud shade mode\n\t\tVertexLighting( ds, si->vertexShadows, si->forceSunLight, si->vertexScale, &tw );\n\t}\n\n\tif ( ds->lightmapNum < 0 ) {\n\t\treturn;\t\t// doesn't need lightmap lighting\n\t}\n\n\tsi = ShaderInfoForShader( dshaders[ ds->shaderNum].shader );\n\tssize = samplesize;\n\tif (si->lightmapSampleSize)\n\t\tssize = si->lightmapSampleSize;\n\n\tif (si->patchShadows)\n\t\ttw.patchshadows = qtrue;\n\telse\n\t\ttw.patchshadows = patchshadows;\n\n\tif ( ds->surfaceType == MST_PATCH ) {\n\t\tsrcMesh.width = ds->patchWidth;\n\t\tsrcMesh.height = ds->patchHeight;\n\t\tsrcMesh.verts = drawVerts + ds->firstVert;\n\t\tmesh = SubdivideMesh( srcMesh, 8, 999 );\n\t\tPutMeshOnCurve( *mesh );\n\t\tMakeMeshNormals( *mesh );\n\n\t\tsubdivided = RemoveLinearMeshColumnsRows( mesh );\n\t\tFreeMesh(mesh);\n\n\t\tmesh = SubdivideMeshQuads( subdivided, ssize, LIGHTMAP_WIDTH, widthtable, heighttable);\n\t\tif ( mesh->width != ds->lightmapWidth || mesh->height != ds->lightmapHeight ) {\n\t\t\tError( \"Mesh lightmap miscount\");\n\t\t}\n\n\t\tif ( extra ) {\n\t\t\tmesh_t\t*mp;\n\n\t\t\t// chop it up for more light samples (leaking memory...)\n\t\t\tmp = mesh;//CopyMesh( mesh );\n\t\t\tmp = LinearSubdivideMesh( mp );\n\t\t\tmp = TransposeMesh( mp );\n\t\t\tmp = LinearSubdivideMesh( mp );\n\t\t\tmp = TransposeMesh( mp );\n\n\t\t\tmesh = mp;\n\t\t}\n\t} else {\n\t\tVectorCopy( ds->lightmapVecs[2], normal );\n\n\t\tif ( !extra ) {\n\t\t\tVectorCopy( ds->lightmapOrigin, lightmapOrigin );\n\t\t\tVectorCopy( ds->lightmapVecs[0], lightmapVecs[0] );\n\t\t\tVectorCopy( ds->lightmapVecs[1], lightmapVecs[1] );\n\t\t} else {\n\t\t\t// sample at a closer spacing for antialiasing\n\t\t\tVectorCopy( ds->lightmapOrigin, lightmapOrigin );\n\t\t\tVectorScale( ds->lightmapVecs[0], 0.5, lightmapVecs[0] );\n\t\t\tVectorScale( ds->lightmapVecs[1], 0.5, lightmapVecs[1] );\n\t\t\tVectorMA( lightmapOrigin, -0.5, lightmapVecs[0], lightmapOrigin );\n\t\t\tVectorMA( lightmapOrigin, -0.5, lightmapVecs[1], lightmapOrigin );\n\t\t}\n\t}\n\n\tif ( extra ) {\n\t\tsampleWidth = ds->lightmapWidth * 2;\n\t\tsampleHeight = ds->lightmapHeight * 2;\n\t} else {\n\t\tsampleWidth = ds->lightmapWidth;\n\t\tsampleHeight = ds->lightmapHeight;\n\t}\n\n\tmemset ( color, 0, sizeof( color ) );\n\n\t// determine which samples are occluded\n\tmemset ( occluded, 0, sizeof( occluded ) );\n\tfor ( i = 0 ; i < sampleWidth ; i++ ) {\n\t\tfor ( j = 0 ; j < sampleHeight ; j++ ) {\n\n\t\t\tif ( ds->patchWidth ) {\n\t\t\t\tnumPositions = 9;\n\t\t\t\tVectorCopy( mesh->verts[j*mesh->width+i].normal, normal );\n\t\t\t\t// VectorNormalize( normal, normal );\n\t\t\t\t// push off of the curve a bit\n\t\t\t\tVectorMA( mesh->verts[j*mesh->width+i].xyz, 1, normal, base );\n\n\t\t\t\tMakeNormalVectors( normal, lightmapVecs[0], lightmapVecs[1] );\n\t\t\t} else {\n\t\t\t\tnumPositions = 9;\n\t\t\t\tfor ( k = 0 ; k < 3 ; k++ ) {\n\t\t\t\t\tbase[k] = lightmapOrigin[k] + normal[k]\n\t\t\t\t\t\t+ i * lightmapVecs[0][k] \n\t\t\t\t\t\t+ j * lightmapVecs[1][k];\n\t\t\t\t}\n\t\t\t}\n\t\t\tVectorAdd( base, surfaceOrigin[ num ], base );\n\n\t\t\t// we may need to slightly nudge the sample point\n\t\t\t// if directly on a wall\n\t\t\tfor ( position = 0 ; position < numPositions ; position++ ) {\n\t\t\t\t// calculate lightmap sample position\n\t\t\t\tfor ( k = 0 ; k < 3 ; k++ ) {\n\t\t\t\t\torigin[k] = base[k] + \n\t\t\t\t\t\t+ ( nudge[0][position]/16 ) * lightmapVecs[0][k] \n\t\t\t\t\t\t+ ( nudge[1][position]/16 ) * lightmapVecs[1][k];\n\t\t\t\t}\n\n\t\t\t\tif ( notrace ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif ( !PointInSolid( origin ) ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// if none of the nudges worked, this sample is occluded\n\t\t\tif ( position == numPositions ) {\n\t\t\t\toccluded[i][j] = qtrue;\n\t\t\t\tif ( numthreads == 1 ) {\n\t\t\t\t\tc_occluded++;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\n\t\t\tif ( numthreads == 1 ) {\n\t\t\t\tc_visible++;\n\t\t\t}\n\t\t\toccluded[i][j] = qfalse;\n\t\t\tLightingAtSample( origin, normal, color[i][j], qtrue, qfalse, &tw );\n\t\t}\n\t}\n\n\tif ( dump ) {\n\t\tPrintOccluded( occluded, sampleWidth, sampleHeight );\n\t}\n\n\t// calculate average values for occluded samples\n\tfor ( i = 0 ; i < sampleWidth ; i++ ) {\n\t\tfor ( j = 0 ; j < sampleHeight ; j++ ) {\n\t\t\tif ( !occluded[i][j] ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// scan all surrounding samples\n\t\t\tcount = 0;\n\t\t\tVectorClear( average );\n\t\t\tfor ( x = -1 ; x <= 1; x++ ) {\n\t\t\t\tfor ( y = -1 ; y <= 1 ; y++ ) {\n\t\t\t\t\tif ( i + x < 0 || i + x >= sampleWidth ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif ( j + y < 0 || j + y >= sampleHeight ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif ( occluded[i+x][j+y] ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcount++;\n\t\t\t\t\tVectorAdd( color[i+x][j+y], average, average );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( count ) {\n\t\t\t\tVectorScale( average, 1.0/count, color[i][j] );\n\t\t\t}\n\t\t}\n\t}\n\n\t// average together the values if we are extra sampling\n\tif ( ds->lightmapWidth != sampleWidth ) {\n\t\tfor ( i = 0 ; i < ds->lightmapWidth ; i++ ) {\n\t\t\tfor ( j = 0 ; j < ds->lightmapHeight ; j++ ) {\n\t\t\t\tfor ( k = 0 ; k < 3 ; k++ ) {\n\t\t\t\t\tfloat\t\tvalue, coverage;\n\n\t\t\t\t\tvalue = color[i*2][j*2][k] + color[i*2][j*2+1][k] +\n\t\t\t\t\t\tcolor[i*2+1][j*2][k] + color[i*2+1][j*2+1][k];\n\t\t\t\t\tcoverage = 4;\n\t\t\t\t\tif ( extraWide ) {\n\t\t\t\t\t\t// wider than box filter\n\t\t\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\t\t\tvalue += color[i*2-1][j*2][k] + color[i*2-1][j*2+1][k];\n\t\t\t\t\t\t\tvalue += color[i*2-2][j*2][k] + color[i*2-2][j*2+1][k];\n\t\t\t\t\t\t\tcoverage += 4;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( i < ds->lightmapWidth - 1 ) {\n\t\t\t\t\t\t\tvalue += color[i*2+2][j*2][k] + color[i*2+2][j*2+1][k];\n\t\t\t\t\t\t\tvalue += color[i*2+3][j*2][k] + color[i*2+3][j*2+1][k];\n\t\t\t\t\t\t\tcoverage += 4;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( j > 0 ) {\n\t\t\t\t\t\t\tvalue += color[i*2][j*2-1][k] + color[i*2+1][j*2-1][k];\n\t\t\t\t\t\t\tvalue += color[i*2][j*2-2][k] + color[i*2+1][j*2-2][k];\n\t\t\t\t\t\t\tcoverage += 4;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( j < ds->lightmapHeight - 1 ) {\n\t\t\t\t\t\t\tvalue += color[i*2][j*2+2][k] + color[i*2+1][j*2+2][k];\n\t\t\t\t\t\t\tvalue += color[i*2][j*2+3][k] + color[i*2+1][j*2+3][k];\n\t\t\t\t\t\t\tcoverage += 2;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tcolor[i][j][k] = value / coverage;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// optionally create a debugging border around the lightmap\n\tif ( lightmapBorder ) {\n\t\tfor ( i = 0 ; i < ds->lightmapWidth ; i++ ) {\n\t\t\tcolor[i][0][0] = 255;\n\t\t\tcolor[i][0][1] = 0;\n\t\t\tcolor[i][0][2] = 0;\n\n\t\t\tcolor[i][ds->lightmapHeight-1][0] = 255;\n\t\t\tcolor[i][ds->lightmapHeight-1][1] = 0;\n\t\t\tcolor[i][ds->lightmapHeight-1][2] = 0;\n\t\t}\n\t\tfor ( i = 0 ; i < ds->lightmapHeight ; i++ ) {\n\t\t\tcolor[0][i][0] = 255;\n\t\t\tcolor[0][i][1] = 0;\n\t\t\tcolor[0][i][2] = 0;\n\n\t\t\tcolor[ds->lightmapWidth-1][i][0] = 255;\n\t\t\tcolor[ds->lightmapWidth-1][i][1] = 0;\n\t\t\tcolor[ds->lightmapWidth-1][i][2] = 0;\n\t\t}\n\t}\n\n\t// clamp the colors to bytes and store off\n\tfor ( i = 0 ; i < ds->lightmapWidth ; i++ ) {\n\t\tfor ( j = 0 ; j < ds->lightmapHeight ; j++ ) {\n\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + j) \n\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + i;\n\n\t\t\tColorToBytes( color[i][j], lightBytes + k*3 );\n\t\t}\n\t}\n\n\tif (ds->surfaceType == MST_PATCH)\n\t{\n\t\tFreeMesh(mesh);\n\t}\n}\n\n\n//=============================================================================\n\nvec3_t\tgridMins;\nvec3_t\tgridSize = { 64, 64, 128 };\nint\t\tgridBounds[3];\n\n\n/*\n========================\nLightContributionToPoint\n========================\n*/\nqboolean LightContributionToPoint( const light_t *light, const vec3_t origin,\n\t\t\t\t\t\t\t\t  vec3_t color, traceWork_t *tw ) {\n\ttrace_t\t\ttrace;\n\tfloat\t\tadd;\n\n\tadd = 0;\n\n\tVectorClear( color );\n\n\t// testing exact PTPFF\n\tif ( exactPointToPolygon && light->type == emit_area ) {\n\t\tfloat\t\tfactor;\n\t\tfloat\t\td;\n\t\tvec3_t\t\tnormal;\n\n\t\t// see if the point is behind the light\n\t\td = DotProduct( origin, light->normal ) - light->dist;\n\t\tif ( !light->twosided ) {\n\t\t\tif ( d < 1 ) {\n\t\t\t\treturn qfalse;\t\t// point is behind light\n\t\t\t}\n\t\t}\n\n\t\t// test occlusion\n\t\t// clip the line, tracing from the surface towards the light\n\t\tTraceLine( origin, light->origin, &trace, qfalse, tw );\n\t\tif ( trace.passSolid ) {\n\t\t\treturn qfalse;\n\t\t}\n\n\t\t// calculate the contribution\n\t\tVectorSubtract( light->origin, origin, normal );\n\t\tif ( VectorNormalize( normal, normal ) == 0 ) {\n\t\t\treturn qfalse;\n\t\t}\n\t\tfactor = PointToPolygonFormFactor( origin, normal, light->w );\n\t\tif ( factor <= 0 ) {\n\t\t\tif ( light->twosided ) {\n\t\t\t\tfactor = -factor;\n\t\t\t} else {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t}\n\t\tVectorScale( light->emitColor, factor, color );\n\t\treturn qtrue;\n\t}\n\n\t// calculate the amount of light at this sample\n\tif ( light->type == emit_point || light->type == emit_spotlight ) {\n\t\tvec3_t\t\tdir;\n\t\tfloat\t\tdist;\n\n\t\tVectorSubtract( light->origin, origin, dir );\n\t\tdist = VectorLength( dir );\n\t\t// clamp the distance to prevent super hot spots\n\t\tif ( dist < 16 ) {\n\t\t\tdist = 16;\n\t\t}\n\t\tif ( light->linearLight ) {\n\t\t\tadd = light->photons * linearScale - dist;\n\t\t\tif ( add < 0 ) {\n\t\t\t\tadd = 0;\n\t\t\t}\n\t\t} else {\n\t\t\tadd = light->photons / ( dist * dist );\n\t\t}\n\t} else {\n\t\treturn qfalse;\n\t}\n\n\tif ( add <= 1.0 ) {\n\t\treturn qfalse;\n\t}\n\n\t// clip the line, tracing from the surface towards the light\n\tTraceLine( origin, light->origin, &trace, qfalse, tw );\n\n\t// other light rays must not hit anything\n\tif ( trace.passSolid ) {\n\t\treturn qfalse;\n\t}\n\n\t// add the result\n\tcolor[0] = add * light->color[0];\n\tcolor[1] = add * light->color[1];\n\tcolor[2] = add * light->color[2];\n\n\treturn qtrue;\n}\n\ntypedef struct {\n\tvec3_t\t\tdir;\n\tvec3_t\t\tcolor;\n} contribution_t;\n\n/*\n=============\nTraceGrid\n\nGrid samples are foe quickly determining the lighting\nof dynamically placed entities in the world\n=============\n*/\n#define\tMAX_CONTRIBUTIONS\t1024\nvoid TraceGrid( int num ) {\n\tint\t\t\tx, y, z;\n\tvec3_t\t\torigin;\n\tlight_t\t\t*light;\n\tvec3_t\t\tcolor;\n\tint\t\t\tmod;\n\tvec3_t\t\tdirectedColor;\n\tvec3_t\t\tsummedDir;\n\tcontribution_t\tcontributions[MAX_CONTRIBUTIONS];\n\tint\t\t\tnumCon;\n\tint\t\t\ti;\n\ttraceWork_t\ttw;\n\tfloat\t\taddSize;\n\n\tmod = num;\n\tz = mod / ( gridBounds[0] * gridBounds[1] );\n\tmod -= z * ( gridBounds[0] * gridBounds[1] );\n\n\ty = mod / gridBounds[0];\n\tmod -= y * gridBounds[0];\n\n\tx = mod;\n\n\torigin[0] = gridMins[0] + x * gridSize[0];\n\torigin[1] = gridMins[1] + y * gridSize[1];\n\torigin[2] = gridMins[2] + z * gridSize[2];\n\n\tif ( PointInSolid( origin ) ) {\n\t\tvec3_t\tbaseOrigin;\n\t\tint\t\tstep;\n\n\t\tVectorCopy( origin, baseOrigin );\n\n\t\t// try to nudge the origin around to find a valid point\n\t\tfor ( step = 9 ; step <= 18 ; step += 9 ) {\n\t\t\tfor ( i = 0 ; i < 8 ; i++ ) {\n\t\t\t\tVectorCopy( baseOrigin, origin );\n\t\t\t\tif ( i & 1 ) {\n\t\t\t\t\torigin[0] += step;\n\t\t\t\t} else {\n\t\t\t\t\torigin[0] -= step;\n\t\t\t\t}\n\t\t\t\tif ( i & 2 ) {\n\t\t\t\t\torigin[1] += step;\n\t\t\t\t} else {\n\t\t\t\t\torigin[1] -= step;\n\t\t\t\t}\n\t\t\t\tif ( i & 4 ) {\n\t\t\t\t\torigin[2] += step;\n\t\t\t\t} else {\n\t\t\t\t\torigin[2] -= step;\n\t\t\t\t}\n\n\t\t\t\tif ( !PointInSolid( origin ) ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( i != 8 ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif ( step > 18 ) {\n\t\t\t// can't find a valid point at all\n\t\t\tfor ( i = 0 ; i < 8 ; i++ ) {\n\t\t\t\tgridData[ num*8 + i ] = 0;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t}\n\n\tVectorClear( summedDir );\n\n\t// trace to all the lights\n\n\t// find the major light direction, and divide the\n\t// total light between that along the direction and\n\t// the remaining in the ambient \n\tnumCon = 0;\n\tfor ( light = lights ; light ; light = light->next ) {\n\t\tvec3_t\t\tadd;\n\t\tvec3_t\t\tdir;\n\t\tfloat\t\taddSize;\n\n\t\tif ( !LightContributionToPoint( light, origin, add, &tw ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tVectorSubtract( light->origin, origin, dir );\n\t\tVectorNormalize( dir, dir );\n\n\t\tVectorCopy( add, contributions[numCon].color );\n\t\tVectorCopy( dir, contributions[numCon].dir );\n\t\tnumCon++;\n\n\t\taddSize = VectorLength( add );\n\t\tVectorMA( summedDir, addSize, dir, summedDir );\n\n\t\tif ( numCon == MAX_CONTRIBUTIONS-1 ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t//\n\t// trace directly to the sun\n\t//\n\tSunToPoint( origin, &tw, color );\n\taddSize = VectorLength( color );\n\tif ( addSize > 0 ) {\n\t\tVectorCopy( color, contributions[numCon].color );\n\t\tVectorCopy( sunDirection, contributions[numCon].dir );\n\t\tVectorMA( summedDir, addSize, sunDirection, summedDir );\n\t\tnumCon++;\n\t}\n\n\n\t// now that we have identified the primary light direction,\n\t// go back and seperate all the light into directed and ambient\n\tVectorNormalize( summedDir, summedDir );\n\tVectorCopy( ambientColor, color );\n\tVectorClear( directedColor );\n\n\tfor ( i = 0 ; i < numCon ; i++ ) {\n\t\tfloat\td;\n\n\t\td = DotProduct( contributions[i].dir, summedDir );\n\t\tif ( d < 0 ) {\n\t\t\td = 0;\n\t\t}\n\n\t\tVectorMA( directedColor, d, contributions[i].color, directedColor );\n\n\t\t// the ambient light will be at 1/4 the value of directed light\n\t\td = 0.25 * ( 1.0 - d );\n\t\tVectorMA( color, d, contributions[i].color, color );\n\t}\n\n\t// now do some fudging to keep the ambient from being too low\n\tVectorMA( color, 0.25, directedColor, color );\n\n\t//\n\t// save the resulting value out\n\t//\n\tColorToBytes( color, gridData + num*8 );\n\tColorToBytes( directedColor, gridData + num*8 + 3 );\n\n\tVectorNormalize( summedDir, summedDir );\n\tNormalToLatLong( summedDir, gridData + num*8 + 6);\n}\n\n\n/*\n=============\nSetupGrid\n=============\n*/\nvoid SetupGrid( void ) {\n\tint\t\ti;\n\tvec3_t\tmaxs;\n\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tgridMins[i] = gridSize[i] * ceil( dmodels[0].mins[i] / gridSize[i] );\n\t\tmaxs[i] = gridSize[i] * floor( dmodels[0].maxs[i] / gridSize[i] );\n\t\tgridBounds[i] = (maxs[i] - gridMins[i])/gridSize[i] + 1;\n\t}\n\n\tnumGridPoints = gridBounds[0] * gridBounds[1] * gridBounds[2];\n\tif (numGridPoints * 8 >= MAX_MAP_LIGHTGRID)\n\t\tError(\"MAX_MAP_LIGHTGRID\");\n\tqprintf( \"%5i gridPoints\\n\", numGridPoints );\n}\n\n//=============================================================================\n\n/*\n=============\nRemoveLightsInSolid\n=============\n*/\nvoid RemoveLightsInSolid(void)\n{\n\tlight_t *light, *prev;\n\tint numsolid = 0;\n\n\tprev = NULL;\n\tfor ( light = lights ; light ;  ) {\n\t\tif (PointInSolid(light->origin))\n\t\t{\n\t\t\tif (prev) prev->next = light->next;\n\t\t\telse lights = light->next;\n\t\t\tif (light->w)\n\t\t\t\tFreeWinding(light->w);\n\t\t\tfree(light);\n\t\t\tnumsolid++;\n\t\t\tif (prev)\n\t\t\t\tlight = prev->next;\n\t\t\telse\n\t\t\t\tlight = lights;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprev = light;\n\t\t\tlight = light->next;\n\t\t}\n\t}\n\t_printf (\" %7i lights in solid\\n\", numsolid);\n}\n\n/*\n=============\nLightWorld\n=============\n*/\nvoid LightWorld (void) {\n\tfloat\t\tf;\n\n\t// determine the number of grid points\n\tSetupGrid();\n\n\t// find the optional world ambient\n\tGetVectorForKey( &entities[0], \"_color\", ambientColor );\n\tf = FloatForKey( &entities[0], \"ambient\" );\n\tVectorScale( ambientColor, f, ambientColor );\n\n\t// create lights out of patches and lights\n\tqprintf (\"--- CreateLights ---\\n\");\n\tCreateEntityLights ();\n\tqprintf (\"%i point lights\\n\", numPointLights);\n\tqprintf (\"%i area lights\\n\", numAreaLights);\n\n\tif (!nogridlighting) {\n\t\tqprintf (\"--- TraceGrid ---\\n\");\n\t\tRunThreadsOnIndividual( numGridPoints, qtrue, TraceGrid );\n\t\tqprintf( \"%i x %i x %i = %i grid\\n\", gridBounds[0], gridBounds[1],\n\t\t\tgridBounds[2], numGridPoints);\n\t}\n\n\tqprintf (\"--- TraceLtm ---\\n\");\n\tRunThreadsOnIndividual( numDrawSurfaces, qtrue, TraceLtm );\n\tqprintf( \"%5i visible samples\\n\", c_visible );\n\tqprintf( \"%5i occluded samples\\n\", c_occluded );\n}\n\n/*\n========\nCreateFilters\n\nEXPERIMENTAL, UNUSED\n\nLook for transparent light filter surfaces.\n\nThis will only work for flat 3*3 patches that exactly hold one copy of the texture.\n========\n*/\n#define\tPLANAR_PATCH_EPSILON\t0.1\nvoid CreateFilters( void ) {\n\tint\t\t\t\ti;\n\tfilter_t\t\t*f;\n\tdsurface_t\t\t*ds;\n\tshaderInfo_t\t*si;\n\tdrawVert_t\t\t*v1, *v2, *v3;\n\tvec3_t\t\t\td1, d2;\n\tint\t\t\t\tvertNum;\n\n\tnumFilters = 0;\n\n\treturn;\n\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ ) {\n\t\tds = &drawSurfaces[i];\n\t\tif ( !ds->patchWidth ) {\n\t\t\tcontinue;\n\t\t}\n\t\tsi = ShaderInfoForShader( dshaders[ ds->shaderNum ].shader );\n/*\n\t\tif ( !(si->surfaceFlags & SURF_LIGHTFILTER) ) {\n\t\t\tcontinue;\n\t\t}\n*/\n\n\t\t// we have a filter patch\n\t\tv1 = &drawVerts[ ds->firstVert ];\n\n\t\tif ( ds->patchWidth != 3 || ds->patchHeight != 3 ) {\n\t\t\t_printf(\"WARNING: patch at %i %i %i has SURF_LIGHTFILTER but isn't a 3 by 3\\n\",\n\t\t\t\tv1->xyz[0], v1->xyz[1], v1->xyz[2] );\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( numFilters == MAX_FILTERS ) {\n\t\t\tError( \"MAX_FILTERS\" );\n\t\t}\n\t\tf = &filters[ numFilters ];\n\t\tnumFilters++;\n\n\t\tv2 = &drawVerts[ ds->firstVert + 2 ];\n\t\tv3 = &drawVerts[ ds->firstVert + 6 ];\n\n\t\tVectorSubtract( v2->xyz, v1->xyz, d1 );\n\t\tVectorSubtract( v3->xyz, v1->xyz, d2 );\n\t\tVectorNormalize( d1, d1 );\n\t\tVectorNormalize( d2, d2 );\n\t\tCrossProduct( d1, d2, f->plane );\n\t\tf->plane[3] = DotProduct( v1->xyz, f->plane );\n\n\t\t// make sure all the control points are on the plane\n\t\tfor ( vertNum = 0 ; vertNum < ds->numVerts ; vertNum++ ) {\n\t\t\tfloat\td;\n\n\t\t\td = DotProduct( drawVerts[ ds->firstVert + vertNum ].xyz, f->plane ) - f->plane[3];\n\t\t\tif ( fabs( d ) > PLANAR_PATCH_EPSILON ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif ( vertNum != ds->numVerts ) {\n\t\t\tnumFilters--;\n\t\t\t_printf(\"WARNING: patch at %i %i %i has SURF_LIGHTFILTER but isn't flat\\n\",\n\t\t\t\tv1->xyz[0], v1->xyz[1], v1->xyz[2] );\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\tf = &filters[0];\n\tnumFilters = 1;\n\n\tf->plane[0] = 1;\n\tf->plane[1] = 0;\n\tf->plane[2] = 0;\n\tf->plane[3] = 448;\n\n\tf->origin[0] = 448;\n\tf->origin[1] = 192;\n\tf->origin[2] = 0;\n\n\tf->vectors[0][0] = 0;\n\tf->vectors[0][1] = -1.0 / 128;\n\tf->vectors[0][2] = 0;\n\n\tf->vectors[1][0] = 0;\n\tf->vectors[1][1] = 0;\n\tf->vectors[1][2] = 1.0 / 128;\n\n\tf->si = ShaderInfoForShader( \"textures/hell/blocks11ct\" );\n}\n\n/*\n=============\nVertexLightingThread\n=============\n*/\nvoid VertexLightingThread(int num) {\n\tdsurface_t\t*ds;\n\ttraceWork_t\ttw;\n\tshaderInfo_t *si;\n\n\tds = &drawSurfaces[num];\n\n\t// vertex-lit triangle model\n\tif ( ds->surfaceType == MST_TRIANGLE_SOUP ) {\n\t\treturn;\n\t}\n\n\tif (novertexlighting)\n\t\treturn;\n\n\tif ( ds->lightmapNum == -1 ) {\n\t\treturn;\t// doesn't need lighting at all\n\t}\n\n\tsi = ShaderInfoForShader( dshaders[ ds->shaderNum].shader );\n\n\t// calculate the vertex lighting for gouraud shade mode\n\tVertexLighting( ds, si->vertexShadows, si->forceSunLight, si->vertexScale, &tw );\n}\n\n/*\n=============\nTriSoupLightingThread\n=============\n*/\nvoid TriSoupLightingThread(int num) {\n\tdsurface_t\t*ds;\n\ttraceWork_t\ttw;\n\tshaderInfo_t *si;\n\n\tds = &drawSurfaces[num];\n\tsi = ShaderInfoForShader( dshaders[ ds->shaderNum].shader );\n\n\t// vertex-lit triangle model\n\tif ( ds->surfaceType == MST_TRIANGLE_SOUP ) {\n\t\tVertexLighting( ds, !si->noVertexShadows, si->forceSunLight, 1.0, &tw );\n\t}\n}\n\n/*\n=============\nGridAndVertexLighting\n=============\n*/\nvoid GridAndVertexLighting(void) {\n\tSetupGrid();\n\n\tFindSkyBrushes();\n\tCreateFilters();\n\tInitTrace();\n\tCreateEntityLights ();\n\tCreateSurfaceLights();\n\n\tif (!nogridlighting) {\n\t\t_printf (\"--- TraceGrid ---\\n\");\n\t\tRunThreadsOnIndividual( numGridPoints, qtrue, TraceGrid );\n\t}\n\n\tif (!novertexlighting) {\n\t\t_printf (\"--- Vertex Lighting ---\\n\");\n\t\tRunThreadsOnIndividual( numDrawSurfaces, qtrue, VertexLightingThread );\n\t}\n\n\t_printf(\"--- Model Lighting ---\\n\");\n\tRunThreadsOnIndividual( numDrawSurfaces, qtrue, TriSoupLightingThread );\n}\n\n/*\n========\nLightMain\n\n========\n*/\nint LightMain (int argc, char **argv) {\n\tint\t\t\ti;\n\tdouble\t\tstart, end;\n\tconst char\t*value;\n\n\t_printf (\"----- Lighting ----\\n\");\n\n\tverbose = qfalse;\n\n\tfor (i=1 ; i<argc ; i++) {\n\t\tif (!strcmp(argv[i],\"-tempname\"))\n    {\n      i++;\n    } else if (!strcmp(argv[i],\"-v\")) {\n\t\t\tverbose = qtrue;\n\t\t} else if (!strcmp(argv[i],\"-threads\")) {\n\t\t\tnumthreads = atoi (argv[i+1]);\n\t\t\ti++;\n\t\t} else if (!strcmp(argv[i],\"-area\")) {\n\t\t\tareaScale *= atof(argv[i+1]);\n\t\t\t_printf (\"area light scaling at %f\\n\", areaScale);\n\t\t\ti++;\n\t\t} else if (!strcmp(argv[i],\"-point\")) {\n\t\t\tpointScale *= atof(argv[i+1]);\n\t\t\t_printf (\"point light scaling at %f\\n\", pointScale);\n\t\t\ti++;\n\t\t} else if (!strcmp(argv[i],\"-notrace\")) {\n\t\t\tnotrace = qtrue;\n\t\t\t_printf (\"No occlusion tracing\\n\");\n\t\t} else if (!strcmp(argv[i],\"-patchshadows\")) {\n\t\t\tpatchshadows = qtrue;\n\t\t\t_printf (\"Patch shadow casting enabled\\n\");\n\t\t} else if (!strcmp(argv[i],\"-extra\")) {\n\t\t\textra = qtrue;\n\t\t\t_printf (\"Extra detail tracing\\n\");\n\t\t} else if (!strcmp(argv[i],\"-extrawide\")) {\n\t\t\textra = qtrue;\n\t\t\textraWide = qtrue;\n\t\t\t_printf (\"Extra wide detail tracing\\n\");\n\t\t} else if (!strcmp(argv[i], \"-samplesize\")) {\n\t\t\tsamplesize = atoi(argv[i+1]);\n\t\t\tif (samplesize < 1) samplesize = 1;\n\t\t\ti++;\n\t\t\t_printf(\"lightmap sample size is %dx%d units\\n\", samplesize, samplesize);\n\t\t} else if (!strcmp(argv[i], \"-novertex\")) {\n\t\t\tnovertexlighting = qtrue;\n\t\t\t_printf(\"no vertex lighting = true\\n\");\n\t\t} else if (!strcmp(argv[i], \"-nogrid\")) {\n\t\t\tnogridlighting = qtrue;\n\t\t\t_printf(\"no grid lighting = true\\n\");\n\t\t} else if (!strcmp(argv[i],\"-border\")) {\n\t\t\tlightmapBorder = qtrue;\n\t\t\t_printf (\"Adding debug border to lightmaps\\n\");\n\t\t} else if (!strcmp(argv[i],\"-nosurf\")) {\n\t\t\tnoSurfaces = qtrue;\n\t\t\t_printf (\"Not tracing against surfaces\\n\" );\n\t\t} else if (!strcmp(argv[i],\"-dump\")) {\n\t\t\tdump = qtrue;\n\t\t\t_printf (\"Dumping occlusion maps\\n\");\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tThreadSetDefault ();\n\n\tif (i != argc - 1) {\n\t\t_printf(\"usage: q3map -light [-<switch> [-<switch> ...]] <mapname>\\n\"\n\t\t\t\t\"\\n\"\n\t\t\t\t\"Switches:\\n\"\n\t\t\t\t\"   v              = verbose output\\n\"\n\t\t\t\t\"   threads <X>    = set number of threads to X\\n\"\n\t\t\t\t\"   area <V>       = set the area light scale to V\\n\"\n\t\t\t\t\"   point <W>      = set the point light scale to W\\n\"\n\t\t\t\t\"   notrace        = don't cast any shadows\\n\"\n\t\t\t\t\"   extra          = enable super sampling for anti-aliasing\\n\"\n\t\t\t\t\"   extrawide      = same as extra but smoothen more\\n\"\n\t\t\t\t\"   nogrid         = don't calculate light grid for dynamic model lighting\\n\"\n\t\t\t\t\"   novertex       = don't calculate vertex lighting\\n\"\n\t\t\t\t\"   samplesize <N> = set the lightmap pixel size to NxN units\\n\");\n\t\texit(0);\n\t}\n\n\tstart = I_FloatTime ();\n\n\tSetQdirFromPath (argv[i]);\t\n\n#ifdef _WIN32\n\tInitPakFile(gamedir, NULL);\n#endif\n\n\tstrcpy (source, ExpandArg(argv[i]));\n\tStripExtension (source);\n\tDefaultExtension (source, \".bsp\");\n\n\tLoadShaderInfo();\n\n\t_printf (\"reading %s\\n\", source);\n\n\tLoadBSPFile (source);\n\n\tFindSkyBrushes();\n\n\tParseEntities();\n\n\tvalue = ValueForKey( &entities[0], \"gridsize\" );\n\tif (strlen(value)) {\n\t\tsscanf( value, \"%f %f %f\", &gridSize[0], &gridSize[1], &gridSize[2] );\n\t\t_printf(\"grid size = {%1.1f, %1.1f, %1.1f}\\n\", gridSize[0], gridSize[1], gridSize[2]);\n\t}\n\n\tCreateFilters();\n\n\tInitTrace();\n\n\tSetEntityOrigins();\n\n\tCountLightmaps();\n\n\tCreateSurfaceLights();\n\n\tLightWorld();\n\n\t_printf (\"writing %s\\n\", source);\n\tWriteBSPFile (source);\n\n\tend = I_FloatTime ();\n\t_printf (\"%5.0f seconds elapsed\\n\", end-start);\n\t\n\treturn 0;\n}\n\n"
  },
  {
    "path": "q3map/light.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"cmdlib.h\"\n#include \"mathlib.h\"\n#include \"bspfile.h\"\n#include \"polylib.h\"\n#include \"imagelib.h\"\n#include \"threads.h\"\n#include \"scriplib.h\"\n\n#include \"shaders.h\"\n#include \"mesh.h\"\n\n\n\ntypedef enum\n{\n\temit_point,\n\temit_area,\n\temit_spotlight,\n\temit_sun\n} emittype_t;\n\n#define\tMAX_LIGHT_EDGES\t\t8\ntypedef struct light_s\n{\n\tstruct light_s *next;\n\temittype_t\ttype;\n\tstruct shaderInfo_s\t*si;\n\n\tvec3_t\t\torigin;\n\tvec3_t\t\tnormal;\t\t// for surfaces, spotlights, and suns\n\tfloat\t\tdist;\t\t// plane location along normal\n\n\tqboolean\tlinearLight;\n\tint\t\t\tphotons;\n\tint\t\t\tstyle;\n\tvec3_t\t\tcolor;\n\tfloat\t\tradiusByDist;\t// for spotlights\n\n\tqboolean\ttwosided;\t\t// fog lights both sides\n\n\twinding_t\t*w;\n\tvec3_t\t\temitColor;\t\t// full out-of-gamut value\n} light_t;\n\n\nextern\tfloat\tlightscale;\nextern\tfloat\tambient;\nextern\tfloat\tmaxlight;\nextern\tfloat\tdirect_scale;\nextern\tfloat\tentity_scale;\n\nextern\tqboolean\tnoSurfaces;\n\n//===============================================================\n\n// light_trace.c\n\n// a facet is a subdivided element of a patch aproximation or model\ntypedef struct cFacet_s {\n\tfloat\tsurface[4];\n\tint\t\tnumBoundaries;\t\t// either 3 or 4, anything less is degenerate\n\tfloat\tboundaries[4][4];\t// positive is outside the bounds\n\n\tvec3_t\tpoints[4];\t\t\t// needed for area light subdivision\n\n\tfloat\ttextureMatrix[2][4];\t// compute texture coordinates at point of impact for translucency\n} cFacet_t;\n\ntypedef struct {\n\tvec3_t\t\tmins, maxs;\n\tvec3_t\t\torigin;\n\tfloat\t\tradius;\n\n\tqboolean\tpatch;\n\n\tint\t\t\tnumFacets;\n\tcFacet_t\t*facets;\n\n\tshaderInfo_t\t*shader;\t\t// for translucency\n} surfaceTest_t;\n\n\ntypedef struct {\n\tvec3_t\t\tfilter;\t\t\t\t// starts out 1.0, 1.0, 1.0, may be reduced if\n\t\t\t\t\t\t\t\t\t// transparent surfaces are crossed\n\n\tvec3_t\t\thit;\t\t\t\t// the impact point of a completely opaque surface\n\tfloat\t\thitFraction;\t\t// 0 = at start, 1.0 = at end\n\tqboolean\tpassSolid;\n} trace_t;\n\nextern\tsurfaceTest_t\t*surfaceTest[MAX_MAP_DRAW_SURFS];\n\nvoid\tInitTrace( void );\n\n// traceWork_t is only a parameter to crutch up poor large local allocations on\n// winNT and macOS.  It should be allocated in the worker function, but never\n// looked at.\ntypedef struct {\n\tvec3_t\t\tstart, end;\n\tint\t\t\tnumOpenLeafs;\n\tint\t\t\topenLeafNumbers[MAX_MAP_LEAFS];\n\ttrace_t\t\t*trace;\n\tint\t\t\tpatchshadows;\n} traceWork_t;\n\nvoid TraceLine( const vec3_t start, const vec3_t stop, trace_t *trace,\n\t\t\t   qboolean testAll, traceWork_t *tw );\nqboolean PointInSolid( vec3_t start );\n\n//===============================================================\n\n//===============================================================\n\n\ntypedef struct {\n\tint\t\ttextureNum;\n\tint\t\tx, y, width, height;\n\n\t// for patches\n\tqboolean\tpatch;\n\tmesh_t\t\tmesh;\n\n\t// for faces\n\tvec3_t\torigin;\n\tvec3_t\tvecs[3];\n} lightmap_t;\n\n\n"
  },
  {
    "path": "q3map/light_trace.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"light.h\"\n\n\n\n#define\tCURVE_FACET_ERROR\t8\n\nint\t\t\t\tc_totalTrace;\nint\t\t\t\tc_cullTrace, c_testTrace;\nint\t\t\t\tc_testFacets;\n\nsurfaceTest_t\t*surfaceTest[MAX_MAP_DRAW_SURFS];\n\n/*\n=====================\nCM_GenerateBoundaryForPoints\n=====================\n*/\nvoid CM_GenerateBoundaryForPoints( float boundary[4], float plane[4], vec3_t a, vec3_t b ) {\n\tvec3_t\td1;\n\n\t// amke a perpendicular vector to the edge and the surface\n\tVectorSubtract( b, a, d1 );\n\tCrossProduct( plane, d1, boundary );\n\tVectorNormalize( boundary, boundary );\n\tboundary[3] = DotProduct( a, boundary );\n}\n\n/*\n=====================\nTextureMatrixFromPoints\n=====================\n*/\nvoid TextureMatrixFromPoints( cFacet_t *f, drawVert_t *a, drawVert_t *b, drawVert_t *c ) {\n\tint\t\t\ti, j;\n\tfloat\t\tt;\n\tfloat\t\tm[3][4];\n\tfloat\t\ts;\n\n\t// This is an incredibly stupid way of solving a three variable equation\n\tfor ( i = 0 ; i < 2 ; i++ ) {\n\n\t\tm[0][0] = a->xyz[0];\n\t\tm[0][1] = a->xyz[1];\n\t\tm[0][2] = a->xyz[2];\n\t\tm[0][3] = a->st[i];\n\n\t\tm[1][0] = b->xyz[0];\n\t\tm[1][1] = b->xyz[1];\n\t\tm[1][2] = b->xyz[2];\n\t\tm[1][3] = b->st[i];\n\n\t\tm[2][0] = c->xyz[0];\n\t\tm[2][1] = c->xyz[1];\n\t\tm[2][2] = c->xyz[2];\n\t\tm[2][3] = c->st[i];\n\n\t\tif ( fabs(m[1][0]) > fabs(m[0][0]) && fabs(m[1][0]) > fabs(m[2][0]) ) {\n\t\t\tfor ( j = 0 ; j < 4 ; j ++ ) {\n\t\t\t\tt = m[0][j];\n\t\t\t\tm[0][j] = m[1][j];\n\t\t\t\tm[1][j] = t;\n\t\t\t}\n\t\t} else if ( fabs(m[2][0]) > fabs(m[0][0]) && fabs(m[2][0]) > fabs(m[1][0]) ) {\n\t\t\tfor ( j = 0 ; j < 4 ; j ++ ) {\n\t\t\t\tt = m[0][j];\n\t\t\t\tm[0][j] = m[2][j];\n\t\t\t\tm[2][j] = t;\n\t\t\t}\n\t\t}\n\n\t\ts = 1.0 / m[0][0];\n\t\tm[0][0] *= s;\n\t\tm[0][1] *= s;\n\t\tm[0][2] *= s;\n\t\tm[0][3] *= s;\n\n\t\ts = m[1][0];\n\t\tm[1][0] -= m[0][0] * s;\n\t\tm[1][1] -= m[0][1] * s;\n\t\tm[1][2] -= m[0][2] * s;\n\t\tm[1][3] -= m[0][3] * s;\n\n\t\ts = m[2][0];\n\t\tm[2][0] -= m[0][0] * s;\n\t\tm[2][1] -= m[0][1] * s;\n\t\tm[2][2] -= m[0][2] * s;\n\t\tm[2][3] -= m[0][3] * s;\n\n\t\tif ( fabs(m[2][1]) > fabs(m[1][1]) ) {\n\t\t\tfor ( j = 0 ; j < 4 ; j ++ ) {\n\t\t\t\tt = m[1][j];\n\t\t\t\tm[1][j] = m[2][j];\n\t\t\t\tm[2][j] = t;\n\t\t\t}\n\t\t}\n\n\t\ts = 1.0 / m[1][1];\n\t\tm[1][0] *= s;\n\t\tm[1][1] *= s;\n\t\tm[1][2] *= s;\n\t\tm[1][3] *= s;\n\n\t\ts = m[2][1];\n\t\tm[2][0] -= m[1][0] * s;\n\t\tm[2][1] -= m[1][1] * s;\n\t\tm[2][2] -= m[1][2] * s;\n\t\tm[2][3] -= m[1][3] * s;\n\n\t\ts = 1.0 / m[2][2];\n\t\tm[2][0] *= s;\n\t\tm[2][1] *= s;\n\t\tm[2][2] *= s;\n\t\tm[2][3] *= s;\n\n\t\tf->textureMatrix[i][2] = m[2][3];\n\t\tf->textureMatrix[i][1] = m[1][3] - f->textureMatrix[i][2] * m[1][2];\n\t\tf->textureMatrix[i][0] = m[0][3] - f->textureMatrix[i][2] * m[0][2] - f->textureMatrix[i][1] * m[0][1];\n\n\t\tf->textureMatrix[i][3] = 0;\n/*\n\t\ts = fabs( DotProduct( a->xyz, f->textureMatrix[i] ) - a->st[i] );\n\t\tif ( s > 0.01 ) {\n\t\t\tError( \"Bad textureMatrix\" );\n\t\t}\n\t\ts = fabs( DotProduct( b->xyz, f->textureMatrix[i] ) - b->st[i] );\n\t\tif ( s > 0.01 ) {\n\t\t\tError( \"Bad textureMatrix\" );\n\t\t}\n\t\ts = fabs( DotProduct( c->xyz, f->textureMatrix[i] ) - c->st[i] );\n\t\tif ( s > 0.01 ) {\n\t\t\tError( \"Bad textureMatrix\" );\n\t\t}\n*/\n\t}\n}\n\n/*\n=====================\nCM_GenerateFacetFor3Points\n=====================\n*/\nqboolean CM_GenerateFacetFor3Points( cFacet_t *f, drawVert_t *a, drawVert_t *b, drawVert_t *c ) {\n\t// if we can't generate a valid plane for the points, ignore the facet\n\tif ( !PlaneFromPoints( f->surface, a->xyz, b->xyz, c->xyz ) ) {\n\t\tf->numBoundaries = 0;\n\t\treturn qfalse;\n\t}\n\n\t// make boundaries\n\tf->numBoundaries = 3;\n\n\tCM_GenerateBoundaryForPoints( f->boundaries[0], f->surface, a->xyz, b->xyz );\n\tCM_GenerateBoundaryForPoints( f->boundaries[1], f->surface, b->xyz, c->xyz );\n\tCM_GenerateBoundaryForPoints( f->boundaries[2], f->surface, c->xyz, a->xyz );\n\n\tVectorCopy( a->xyz, f->points[0] );\n\tVectorCopy( b->xyz, f->points[1] );\n\tVectorCopy( c->xyz, f->points[2] );\n\n\tTextureMatrixFromPoints( f, a, b, c );\n\n\treturn qtrue;\n}\n\n/*\n=====================\nCM_GenerateFacetFor4Points\n\nAttempts to use four points as a planar quad\n=====================\n*/\n#define\tPLANAR_EPSILON\t0.1\nqboolean CM_GenerateFacetFor4Points( cFacet_t *f, drawVert_t *a, drawVert_t *b, drawVert_t *c, drawVert_t *d ) {\n\tfloat\tdist;\n\tint\t\ti;\n\tvec4_t\tplane;\n\n\t// if we can't generate a valid plane for the points, ignore the facet\n\tif ( !PlaneFromPoints( f->surface, a->xyz, b->xyz, c->xyz ) ) {\n\t\tf->numBoundaries = 0;\n\t\treturn qfalse;\n\t}\n\n\t// if the fourth point is also on the plane, we can make a quad facet\n\tdist = DotProduct( d->xyz, f->surface ) - f->surface[3];\n\tif ( fabs( dist ) > PLANAR_EPSILON ) {\n\t\tf->numBoundaries = 0;\n\t\treturn qfalse;\n\t}\n\n\t// make boundaries\n\tf->numBoundaries = 4;\n\n\tCM_GenerateBoundaryForPoints( f->boundaries[0], f->surface, a->xyz, b->xyz );\n\tCM_GenerateBoundaryForPoints( f->boundaries[1], f->surface, b->xyz, c->xyz );\n\tCM_GenerateBoundaryForPoints( f->boundaries[2], f->surface, c->xyz, d->xyz );\n\tCM_GenerateBoundaryForPoints( f->boundaries[3], f->surface, d->xyz, a->xyz );\n\n\tVectorCopy( a->xyz, f->points[0] );\n\tVectorCopy( b->xyz, f->points[1] );\n\tVectorCopy( c->xyz, f->points[2] );\n\tVectorCopy( d->xyz, f->points[3] );\n\n\tfor (i = 1; i < 4; i++)\n\t{\n\t\tif ( !PlaneFromPoints( plane, f->points[i], f->points[(i+1) % 4], f->points[(i+2) % 4]) ) {\n\t\t\tf->numBoundaries = 0;\n\t\t\treturn qfalse;\n\t\t}\n\n\t\tif (DotProduct(f->surface, plane) < 0.9) {\n\t\t\tf->numBoundaries = 0;\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\tTextureMatrixFromPoints( f, a, b, c );\n\n\treturn qtrue;\n}\n\n\n\n\n/*\n===============\nSphereFromBounds\n===============\n*/\nvoid SphereFromBounds( vec3_t mins, vec3_t maxs, vec3_t origin, float *radius ) {\n\tvec3_t\t\ttemp;\n\n\tVectorAdd( mins, maxs, origin );\n\tVectorScale( origin, 0.5, origin );\n\tVectorSubtract( maxs, origin, temp );\n\t*radius = VectorLength( temp );\n}\n\n\n/*\n====================\nFacetsForTriangleSurface\n====================\n*/\nvoid FacetsForTriangleSurface( dsurface_t *dsurf, shaderInfo_t *si, surfaceTest_t *test ) {\n\tint\t\t\ti;\n\tdrawVert_t\t*v1, *v2, *v3, *v4;\n\tint\t\t\tcount;\n\tint\t\t\ti1, i2, i3, i4, i5, i6;\n\n\ttest->patch = qfalse;\n\ttest->numFacets = dsurf->numIndexes / 3;\n\ttest->facets = malloc( sizeof( test->facets[0] ) * test->numFacets );\n\ttest->shader = si;\n\n\tcount = 0;\n\tfor ( i = 0 ; i < test->numFacets ; i++ ) {\n\t\ti1 = drawIndexes[ dsurf->firstIndex + i*3 ];\n\t\ti2 = drawIndexes[ dsurf->firstIndex + i*3 + 1 ];\n\t\ti3 = drawIndexes[ dsurf->firstIndex + i*3 + 2 ];\n\n\t\tv1 = &drawVerts[ dsurf->firstVert + i1 ];\n\t\tv2 = &drawVerts[ dsurf->firstVert + i2 ];\n\t\tv3 = &drawVerts[ dsurf->firstVert + i3 ];\n\n\t\t// try and make a quad out of two triangles\n\t\tif ( i != test->numFacets - 1 ) {\n\t\t\ti4 = drawIndexes[ dsurf->firstIndex + i*3 + 3 ];\n\t\t\ti5 = drawIndexes[ dsurf->firstIndex + i*3 + 4 ];\n\t\t\ti6 = drawIndexes[ dsurf->firstIndex + i*3 + 5 ];\n\t\t\tif ( i4 == i3 && i5 == i2 ) {\n\t\t\t\tv4 = &drawVerts[ dsurf->firstVert + i6 ];\n\t\t\t\tif ( CM_GenerateFacetFor4Points( &test->facets[count], v1, v2, v4, v3 ) ) {\n\t\t\t\t\tcount++;\n\t\t\t\t\ti++;\t\t// skip next tri\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (CM_GenerateFacetFor3Points( &test->facets[count], v1, v2, v3 ))\n\t\t\tcount++;\n\t}\t\t\n\n\t// we may have turned some pairs into quads\n\ttest->numFacets = count;\n}\n\n/*\n====================\nFacetsForPatch\n====================\n*/\nvoid FacetsForPatch( dsurface_t *dsurf, shaderInfo_t *si, surfaceTest_t *test ) {\n\tint\t\t\ti, j;\n\tdrawVert_t\t*v1, *v2, *v3, *v4;\n\tint\t\t\tcount;\n\tmesh_t\t\tsrcMesh, *subdivided, *mesh;\n\n\tsrcMesh.width = dsurf->patchWidth;\n\tsrcMesh.height = dsurf->patchHeight;\n\tsrcMesh.verts = &drawVerts[ dsurf->firstVert ];\n\n\t//subdivided = SubdivideMesh( mesh, CURVE_FACET_ERROR, 9999 );\n\tmesh = SubdivideMesh( srcMesh, 8, 999 );\n\tPutMeshOnCurve( *mesh );\n\tMakeMeshNormals( *mesh );\n\n\tsubdivided = RemoveLinearMeshColumnsRows( mesh );\n\tFreeMesh(mesh);\n\n\ttest->patch = qtrue;\n\ttest->numFacets = ( subdivided->width - 1 ) * ( subdivided->height - 1 ) * 2;\n\ttest->facets = malloc( sizeof( test->facets[0] ) * test->numFacets );\n\ttest->shader = si;\n\n\tcount = 0;\n\tfor ( i = 0 ; i < subdivided->width - 1 ; i++ ) {\n\t\tfor ( j = 0 ; j < subdivided->height - 1 ; j++ ) {\n\n\t\t\tv1 = subdivided->verts + j * subdivided->width + i;\n\t\t\tv2 = v1 + 1;\n\t\t\tv3 = v1 + subdivided->width + 1;\n\t\t\tv4 = v1 + subdivided->width;\n\n\t\t\tif ( CM_GenerateFacetFor4Points( &test->facets[count], v1, v4, v3, v2 ) ) {\n\t\t\t\tcount++;\n\t\t\t} else {\n\t\t\t\tif (CM_GenerateFacetFor3Points( &test->facets[count], v1, v4, v3 ))\n\t\t\t\t\tcount++;\n\t\t\t\tif (CM_GenerateFacetFor3Points( &test->facets[count], v1, v3, v2 ))\n\t\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}\n\ttest->numFacets = count;\n\tFreeMesh(subdivided);\n}\n\n\n/*\n=====================\nInitSurfacesForTesting\n\nBuilds structures to speed the ray tracing against surfaces\n=====================\n*/\nvoid InitSurfacesForTesting( void ) {\n\n\tint\t\t\t\ti, j;\n\tdsurface_t\t\t*dsurf;\n\tsurfaceTest_t\t*test;\n\tdrawVert_t\t\t*dvert;\n\tshaderInfo_t\t*si;\n\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ ) {\n\t\tdsurf = &drawSurfaces[ i ];\n\t\tif ( !dsurf->numIndexes && !dsurf->patchWidth ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// don't make surfaces for transparent objects\n\t\t// because we want light to pass through them\n\t\tsi = ShaderInfoForShader( dshaders[ dsurf->shaderNum].shader );\n\t\tif ( (si->contents & CONTENTS_TRANSLUCENT) && !(si->surfaceFlags & SURF_ALPHASHADOW) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\ttest = malloc( sizeof( *test ) );\n\t\tsurfaceTest[i] = test;\n\t\tClearBounds( test->mins, test->maxs );\n\n\t\tdvert = &drawVerts[ dsurf->firstVert ];\n\t\tfor ( j = 0 ; j < dsurf->numVerts ; j++, dvert++ ) {\n\t\t\tAddPointToBounds( dvert->xyz, test->mins, test->maxs );\n\t\t}\n\n\t\tSphereFromBounds( test->mins, test->maxs, test->origin, &test->radius );\n\n\t\tif ( dsurf->surfaceType == MST_TRIANGLE_SOUP || dsurf->surfaceType == MST_PLANAR ) {\n\t\t\tFacetsForTriangleSurface( dsurf, si, test );\n\t\t} else if ( dsurf->surfaceType == MST_PATCH ) {\n\t\t\tFacetsForPatch( dsurf, si, test );\n\t\t}\n\t}\n}\n\n\n/*\n=====================\nGenerateBoundaryForPoints\n=====================\n*/\nvoid GenerateBoundaryForPoints( float boundary[4], float plane[4], vec3_t a, vec3_t b ) {\n\tvec3_t\td1;\n\n\t// amke a perpendicular vector to the edge and the surface\n\tVectorSubtract( b, a, d1 );\n\tCrossProduct( plane, d1, boundary );\n\tVectorNormalize( boundary, boundary );\n\tboundary[3] = DotProduct( a, boundary );\n}\n\n\n/*\n=================\nSetFacetFilter\n\nGiven a point on a facet, determine the color filter\nfor light passing through\n=================\n*/\nvoid SetFacetFilter( traceWork_t *tr, shaderInfo_t *shader, cFacet_t *facet, vec3_t point ) {\n\tfloat\ts, t;\n\tint\t\tis, it;\n\tbyte\t*image;\n\tint\t\tb;\n\n\t// most surfaces are completely opaque\n\tif ( !(shader->surfaceFlags & SURF_ALPHASHADOW) ) {\n\t\tVectorClear( tr->trace->filter );\n\t\treturn;\n\t}\n\n\ts = DotProduct( point, facet->textureMatrix[0] ) + facet->textureMatrix[0][3];\n\tt = DotProduct( point, facet->textureMatrix[1] ) + facet->textureMatrix[1][3];\n\n\tif ( !shader->pixels ) {\n\t\t// assume completely solid\n\t\tVectorClear( point );\n\t\treturn;\n\t}\n\n\ts = s - floor( s );\n\tt = t - floor( t );\n\n\tis = s * shader->width;\n\tit = t * shader->height;\n\n\timage = shader->pixels + 4 * ( it * shader->width + is );\n\n\t// alpha filter\n\tb = image[3];\n\n\t// alpha test makes this a binary option\n\tb = b < 128 ? 0 : 255;\n\n\ttr->trace->filter[0] = tr->trace->filter[0] * (255-b) / 255;\n\ttr->trace->filter[1] = tr->trace->filter[1] * (255-b) / 255;\n\ttr->trace->filter[2] = tr->trace->filter[2] * (255-b) / 255;\n}\n\n\n/*\n====================\nTraceAgainstFacet\n\nShader is needed for translucent surfaces\n====================\n*/\nvoid TraceAgainstFacet( traceWork_t *tr, shaderInfo_t *shader, cFacet_t *facet ) {\n\tint\t\t\tj;\n\tfloat\t\td1, d2, d, f;\n\tvec3_t\t\tpoint;\n\tfloat\t\tdist;\n\n\t// ignore degenerate facets\n\tif ( facet->numBoundaries < 3 ) {\n\t\treturn;\n\t}\n\n\tdist = facet->surface[3];\n\n\t// compare the trace endpoints against the facet plane\n\td1 = DotProduct( tr->start, facet->surface ) - dist;\n\tif ( d1 > -1 && d1 < 1 ) {\n\t\treturn;\t\t// don't self intersect\n\t}\n\td2 = DotProduct( tr->end, facet->surface ) - dist;\n\tif ( d2 > -1 && d2 < 1 ) {\n\t\treturn;\t\t// don't self intersect\n\t}\n\n\t// calculate the intersection fraction\n\tf = ( d1 - ON_EPSILON ) / ( d1 - d2 );\n\tif ( f <= 0 ) {\n\t\treturn;\n\t}\n\tif ( f >= tr->trace->hitFraction ) {\n\t\treturn;\t\t\t// we have hit something earlier\n\t}\n\n\t// calculate the intersection point\n\tfor ( j = 0 ; j < 3 ; j++ ) {\n\t\tpoint[j] = tr->start[j] + f * ( tr->end[j] - tr->start[j] );\n\t}\n\n\t// check the point against the facet boundaries\n\tfor ( j = 0 ; j < facet->numBoundaries ; j++ ) {\n\t\t// adjust the plane distance apropriately for mins/maxs\n\t\tdist = facet->boundaries[j][3];\n\n\t\td = DotProduct( point, facet->boundaries[j] );\n\t\tif ( d > dist + ON_EPSILON ) {\n\t\t\tbreak;\t\t// outside the bounds\n\t\t}\n\t}\n\n\tif ( j != facet->numBoundaries ) {\n\t\treturn;\t\t\t// we are outside the bounds of the facet\n\t}\n\n\t// we hit this facet\n\n\t// if this is a transparent surface, calculate filter value\n\tif ( shader->surfaceFlags & SURF_ALPHASHADOW ) {\n\t\tSetFacetFilter( tr, shader, facet, point );\n\t} else {\n\t\t// completely opaque\n\t\tVectorClear( tr->trace->filter );\n\t\ttr->trace->hitFraction = f;\n\t}\n\n//\tVectorCopy( facet->surface, tr->trace->plane.normal );\n//\ttr->trace->plane.dist = facet->surface[3];\n}\n\n\n/*\n===============================================================\n\n  LINE TRACING\n\n===============================================================\n*/\n\n\n#define\tTRACE_ON_EPSILON\t0.1\n\ntypedef struct tnode_s\n{\n\tint\t\ttype;\n\tvec3_t\tnormal;\n\tfloat\tdist;\n\tint\t\tchildren[2];\n\tint\t\tplaneNum;\n} tnode_t;\n\n#define\tMAX_TNODES\t(MAX_MAP_NODES*4)\ntnode_t\t\t*tnodes, *tnode_p;\n\n/*\n==============\nMakeTnode\n\nConverts the disk node structure into the efficient tracing structure\n==============\n*/\nvoid MakeTnode (int nodenum)\n{\n\ttnode_t\t\t\t*t;\n\tdplane_t\t\t*plane;\n\tint\t\t\t\ti;\n\tdnode_t \t\t*node;\n\tint\t\t\t\tleafNum;\n\n\tt = tnode_p++;\n\n\tnode = dnodes + nodenum;\n\tplane = dplanes + node->planeNum;\n\n\tt->planeNum = node->planeNum;\n\tt->type = PlaneTypeForNormal( plane->normal );\n\tVectorCopy (plane->normal, t->normal);\n\tt->dist = plane->dist;\n\t\n\tfor (i=0 ; i<2 ; i++)\n\t{\n\t\tif (node->children[i] < 0) {\n\t\t\tleafNum = -node->children[i] - 1;\n\t\t\tif ( dleafs[leafNum].cluster == -1  ) {\n\t\t\t\t// solid\n\t\t\t\tt->children[i] = leafNum | ( 1 << 31 ) | ( 1 << 30 );\n\t\t\t} else {\n\t\t\t\tt->children[i] = leafNum | ( 1 << 31 );\n\t\t\t}\n\t\t} else {\n\t\t\tt->children[i] = tnode_p - tnodes;\n\t\t\tMakeTnode (node->children[i]);\n\t\t}\n\t}\n\t\t\t\n}\n\n/*\n=============\nInitTrace\n\nLoads the node structure out of a .bsp file to be used for light occlusion\n=============\n*/\nvoid InitTrace( void ) {\n\t// 32 byte align the structs\n\ttnodes = malloc( (MAX_TNODES+1) * sizeof(tnode_t));\n\ttnodes = (tnode_t *)(((int)tnodes + 31)&~31);\n\ttnode_p = tnodes;\n\n\tMakeTnode (0);\n\n\tInitSurfacesForTesting();\n}\n\n\n/*\n===================\nPointInSolid\n===================\n*/\nqboolean PointInSolid_r( vec3_t start, int node ) {\n\ttnode_t\t*tnode;\n\tfloat\tfront;\n\n\twhile ( !(node & (1<<31) ) ) {\n\t\ttnode = &tnodes[node];\n\t\tswitch (tnode->type) {\n\t\tcase PLANE_X:\n\t\t\tfront = start[0] - tnode->dist;\n\t\t\tbreak;\n\t\tcase PLANE_Y:\n\t\t\tfront = start[1] - tnode->dist;\n\t\t\tbreak;\n\t\tcase PLANE_Z:\n\t\t\tfront = start[2] - tnode->dist;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tfront = (start[0]*tnode->normal[0] + start[1]*tnode->normal[1] + start[2]*tnode->normal[2]) - tnode->dist;\n\t\t\tbreak;\n\t\t}\n\n\t\tif ( front == 0 ) {\n\t\t\t// exactly on node, must check both sides\n\t\t\treturn (qboolean) ( PointInSolid_r( start, tnode->children[0] ) \n\t\t\t\t| PointInSolid_r( start, tnode->children[1] ) );\n\t\t}\n\n\t\tif ( front > 0 ) {\n\t\t\tnode = tnode->children[0];\n\t\t} else {\n\t\t\tnode = tnode->children[1];\n\t\t}\n\t}\n\n\tif ( node & ( 1 << 30 ) ) {\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\n/*\n=============\nPointInSolid\n\n=============\n*/\nqboolean PointInSolid( vec3_t start ) {\n\treturn PointInSolid_r( start, 0 );\n}\n\n\n/*\n=============\nTraceLine_r\n\nReturns qtrue if something is hit and tracing can stop\n=============\n*/\nint TraceLine_r( int node, const vec3_t start, const vec3_t stop, traceWork_t *tw ) {\n\ttnode_t\t*tnode;\n\tfloat\tfront, back;\n\tvec3_t\tmid;\n\tfloat\tfrac;\n\tint\t\tside;\n\tint\t\tr;\n\n\tif (node & (1<<31)) {\n\t\tif (node & ( 1 << 30 ) ) {\n\t\t\tVectorCopy (start, tw->trace->hit);\n\t\t\ttw->trace->passSolid = qtrue;\n\t\t\treturn qtrue;\n\t\t} else {\n\t\t\t// save the node off for more exact testing\n\t\t\tif ( tw->numOpenLeafs == MAX_MAP_LEAFS ) {\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t\ttw->openLeafNumbers[ tw->numOpenLeafs ] = node & ~(3 << 30);\n\t\t\ttw->numOpenLeafs++;\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\ttnode = &tnodes[node];\n\tswitch (tnode->type) {\n\tcase PLANE_X:\n\t\tfront = start[0] - tnode->dist;\n\t\tback = stop[0] - tnode->dist;\n\t\tbreak;\n\tcase PLANE_Y:\n\t\tfront = start[1] - tnode->dist;\n\t\tback = stop[1] - tnode->dist;\n\t\tbreak;\n\tcase PLANE_Z:\n\t\tfront = start[2] - tnode->dist;\n\t\tback = stop[2] - tnode->dist;\n\t\tbreak;\n\tdefault:\n\t\tfront = (start[0]*tnode->normal[0] + start[1]*tnode->normal[1] + start[2]*tnode->normal[2]) - tnode->dist;\n\t\tback = (stop[0]*tnode->normal[0] + stop[1]*tnode->normal[1] + stop[2]*tnode->normal[2]) - tnode->dist;\n\t\tbreak;\n\t}\n\n\tif (front >= -TRACE_ON_EPSILON && back >= -TRACE_ON_EPSILON) {\n\t\treturn TraceLine_r (tnode->children[0], start, stop, tw);\n\t}\n\t\n\tif (front < TRACE_ON_EPSILON && back < TRACE_ON_EPSILON) {\n\t\treturn TraceLine_r (tnode->children[1], start, stop, tw);\n\t}\n\n\tside = front < 0;\n\t\n\tfrac = front / (front-back);\n\n\tmid[0] = start[0] + (stop[0] - start[0])*frac;\n\tmid[1] = start[1] + (stop[1] - start[1])*frac;\n\tmid[2] = start[2] + (stop[2] - start[2])*frac;\n\n\tr = TraceLine_r (tnode->children[side], start, mid, tw);\n\n\tif (r) {\n\t\treturn r;\n\t}\n\n//\ttrace->planeNum = tnode->planeNum;\n\treturn TraceLine_r (tnode->children[!side], mid, stop, tw);\n}\n\n//==========================================================================================\n\n\n/*\n================\nSphereCull\n================\n*/\nqboolean\tSphereCull( vec3_t start, vec3_t stop, vec3_t origin, float radius ) {\n\tvec3_t\t\tv;\n\tfloat\t\td;\n\tvec3_t\t\tdir;\n\tfloat\t\tlen;\n\tvec3_t\t\ton;\n\n\tVectorSubtract( stop, start, dir );\n\tlen = VectorNormalize( dir, dir );\n\n\tVectorSubtract( origin, start, v );\n\td = DotProduct( v, dir );\n\tif ( d > len + radius ) {\n\t\treturn qtrue;\t\t// too far ahead\n\t}\n\tif ( d < -radius ) {\n\t\treturn qtrue;\t\t// too far behind\n\t}\n\tVectorMA( start, d, dir, on );\n\t\n\tVectorSubtract( on, origin, v );\n\n\tlen = VectorLength( v );\n\n\tif ( len > radius ) {\n\t\treturn qtrue;\t\t// too far to the side\n\t}\n\n\treturn qfalse;\t\t// must be traced against\n}\n\n/*\n================\nTraceAgainstSurface\n================\n*/\nvoid\tTraceAgainstSurface( traceWork_t *tw, surfaceTest_t *surf ) {\n\tint\t\ti;\n\n\t// if surfaces are trans\n\tif ( SphereCull( tw->start, tw->end, surf->origin, surf->radius ) ) {\n\t\tif ( numthreads == 1 ) {\n\t\t\tc_cullTrace++;\n\t\t}\n\t\treturn;\n\t}\n\n\tif ( numthreads == 1 ) {\n\t\tc_testTrace++;\n\t\tc_testFacets += surf->numFacets;\n\t}\n\n\t/*\n\t// MrE: backface culling\n\tif (!surf->patch && surf->numFacets) {\n\t\t// if the surface does not cast an alpha shadow\n\t\tif ( !(surf->shader->surfaceFlags & SURF_ALPHASHADOW) ) {\n\t\t\tvec3_t vec;\n\t\t\tVectorSubtract(tw->end, tw->start, vec);\n\t\t\tif (DotProduct(vec, surf->facets->surface) > 0)\n\t\t\t\treturn;\n\t\t}\n\t}\n\t*/\n\n\t// test against each facet\n\tfor ( i = 0 ; i < surf->numFacets ; i++ ) {\n\t\tTraceAgainstFacet( tw, surf->shader, surf->facets + i );\n\t}\n}\n\n/*\n=============\nTraceLine\n\nFollow the trace just through the solid leafs first, and only\nif it passes that, trace against the objects inside the empty leafs\nReturns qtrue if the trace hit any\n\ntraceWork_t is only a parameter to crutch up poor large local allocations on\nwinNT and macOS.  It should be allocated in the worker function, but never\nlooked at.\n\nleave testAll false if all you care about is if it hit anything at all.\nif you need to know the exact first point of impact (for a sun trace), set\ntestAll to true\n=============\n*/\nextern qboolean\tpatchshadows;\n\nvoid TraceLine( const vec3_t start, const vec3_t stop, trace_t *trace, qboolean testAll, traceWork_t *tw ) {\n\tint\t\t\t\tr;\n\tint\t\t\t\ti, j;\n\tdleaf_t\t\t\t*leaf;\n\tfloat\t\t\toldHitFrac;\n\tsurfaceTest_t\t*test;\n\tint\t\t\t\tsurfaceNum;\n\tbyte\t\t\tsurfaceTested[MAX_MAP_DRAW_SURFS/8];\n\t;\n\n\tif ( numthreads == 1 ) {\n\t\tc_totalTrace++;\n\t}\n\n\t// assume all light gets through, unless the ray crosses\n\t// a translucent surface\n\ttrace->filter[0] = 1.0;\n\ttrace->filter[1] = 1.0;\n\ttrace->filter[2] = 1.0;\n\n\tVectorCopy( start, tw->start );\n\tVectorCopy( stop, tw->end );\n\ttw->trace = trace;\n\n\ttw->numOpenLeafs = 0;\n\n\ttrace->passSolid = qfalse;\n\ttrace->hitFraction = 1.0;\n\n\tr = TraceLine_r( 0, start, stop, tw );\n\n\t// if we hit a solid leaf, stop without testing the leaf\n\t// surfaces.  Note that the plane and endpoint might not\n\t// be the first solid intersection along the ray.\n\tif ( r && !testAll ) {\n\t\treturn;\n\t}\n\n\tif ( noSurfaces ) {\n\t\treturn;\n\t}\n\n\tmemset( surfaceTested, 0, (numDrawSurfaces+7)/8 );\n\toldHitFrac = trace->hitFraction;\n\n\tfor ( i = 0 ; i < tw->numOpenLeafs ; i++ ) {\n\t\tleaf = &dleafs[ tw->openLeafNumbers[ i ] ];\n\t\tfor ( j = 0 ; j < leaf->numLeafSurfaces ; j++ ) {\n\t\t\tsurfaceNum = dleafsurfaces[ leaf->firstLeafSurface + j ];\n\n\t\t\t// make sure we don't test the same ray against a surface more than once\n\t\t\tif ( surfaceTested[ surfaceNum>>3 ] & ( 1 << ( surfaceNum & 7) ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tsurfaceTested[ surfaceNum>>3 ] |= ( 1 << ( surfaceNum & 7 ) );\n\n\t\t\ttest = surfaceTest[ surfaceNum ];\n\t\t\tif ( !test ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t//\n\t\t\tif ( !tw->patchshadows && test->patch ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tTraceAgainstSurface( tw, test );\n\t\t}\n\n\t\t// if the trace is now solid, we can't possibly hit anything closer\n\t\tif ( trace->hitFraction < oldHitFrac ) {\n\t\t\ttrace->passSolid = qtrue;\n\t\t\tbreak;\n\t\t}\n\t}\n\t\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\ttrace->hit[i] = start[i] + ( stop[i] - start[i] ) * trace->hitFraction;\n\t}\n}\n\n"
  },
  {
    "path": "q3map/lightmaps.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"qbsp.h\"\n\n\n/*\n\n  Lightmap allocation has to be done after all flood filling and\n  visible surface determination.\n\n*/\n\nint\t\t\t\t\tnumSortShaders;\nmapDrawSurface_t\t*surfsOnShader[MAX_MAP_SHADERS];\n\n\nint\t\tallocated[LIGHTMAP_WIDTH];\n\nint\t\tnumLightmaps = 1;\nint\t\tc_exactLightmap;\n\n\nvoid PrepareNewLightmap( void ) {\n\tmemset( allocated, 0, sizeof( allocated ) );\n\tnumLightmaps++;\n}\n\n/*\n===============\nAllocLMBlock\n\nreturns a texture number and the position inside it\n===============\n*/\nqboolean AllocLMBlock (int w, int h, int *x, int *y)\n{\n\tint\t\ti, j;\n\tint\t\tbest, best2;\n\n\tbest = LIGHTMAP_HEIGHT;\n\n\tfor ( i=0 ; i <= LIGHTMAP_WIDTH-w ; i++ ) {\n\t\tbest2 = 0;\n\n\t\tfor (j=0 ; j<w ; j++) {\n\t\t\tif (allocated[i+j] >= best) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (allocated[i+j] > best2) {\n\t\t\t\tbest2 = allocated[i+j];\n\t\t\t}\n\t\t}\n\t\tif (j == w)\t{\t// this is a valid spot\n\t\t\t*x = i;\n\t\t\t*y = best = best2;\n\t\t}\n\t}\n\n\tif (best + h > LIGHTMAP_HEIGHT) {\n\t\treturn qfalse;\n\t}\n\n\tfor (i=0 ; i<w ; i++) {\n\t\tallocated[*x + i] = best + h;\n\t}\n\n\treturn qtrue;\n}\n\n\n/*\n===================\nAllocateLightmapForPatch\n===================\n*/\n//#define LIGHTMAP_PATCHSHIFT\n\nvoid AllocateLightmapForPatch( mapDrawSurface_t *ds ) {\n\tint\t\t\ti, j, k;\n\tdrawVert_t\t*verts;\n\tint\t\t\tw, h;\n\tint\t\t\tx, y;\n\tfloat\t\ts, t;\n\tmesh_t\t\tmesh, *subdividedMesh, *tempMesh, *newmesh;\n\tint\t\t\twidthtable[LIGHTMAP_WIDTH], heighttable[LIGHTMAP_HEIGHT], ssize;\n\n\tverts = ds->verts;\n\n\tmesh.width = ds->patchWidth;\n\tmesh.height = ds->patchHeight;\n\tmesh.verts = verts;\n\tnewmesh = SubdivideMesh( mesh, 8, 999 );\n\n\tPutMeshOnCurve( *newmesh );\n\ttempMesh = RemoveLinearMeshColumnsRows( newmesh );\n\tFreeMesh(newmesh);\n\n\tssize = samplesize;\n\tif (ds->shaderInfo->lightmapSampleSize)\n\t\tssize = ds->shaderInfo->lightmapSampleSize;\n\n#ifdef LIGHTMAP_PATCHSHIFT\n\tsubdividedMesh = SubdivideMeshQuads( tempMesh, ssize, LIGHTMAP_WIDTH-1, widthtable, heighttable);\n#else\n\tsubdividedMesh = SubdivideMeshQuads( tempMesh, ssize, LIGHTMAP_WIDTH, widthtable, heighttable);\n#endif\n\n\tw = subdividedMesh->width;\n\th = subdividedMesh->height;\n\n#ifdef LIGHTMAP_PATCHSHIFT\n\tw++;\n\th++;\n#endif\n\n\tFreeMesh(subdividedMesh);\n\n\t// allocate the lightmap\n\tc_exactLightmap += w * h;\n\n\tif ( !AllocLMBlock( w, h, &x, &y ) ) {\n\t\tPrepareNewLightmap();\n\t\tif ( !AllocLMBlock( w, h, &x, &y ) ) {\n\t\t\tError(\"Entity %i, brush %i: Lightmap allocation failed\", \n\t\t\t\tds->mapBrush->entitynum, ds->mapBrush->brushnum );\n\t\t}\n\t}\n\n#ifdef LIGHTMAP_PATCHSHIFT\n\tw--;\n\th--;\n#endif\n\n\t// set the lightmap texture coordinates in the drawVerts\n\tds->lightmapNum = numLightmaps - 1;\n\tds->lightmapWidth = w;\n\tds->lightmapHeight = h;\n\tds->lightmapX = x;\n\tds->lightmapY = y;\n\n\tfor ( i = 0 ; i < ds->patchWidth ; i++ ) {\n\t\tfor ( k = 0 ; k < w ; k++ ) {\n\t\t\tif ( originalWidths[k] >= i ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (k >= w)\n\t\t\tk = w-1;\n\t\ts = x + k;\n\t\tfor ( j = 0 ; j < ds->patchHeight ; j++ ) {\n\t\t\tfor ( k = 0 ; k < h ; k++ ) {\n\t\t\t\tif ( originalHeights[k] >= j ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (k >= h)\n\t\t\t\tk = h-1;\n\t\t\tt = y + k;\n\t\t\tverts[i + j * ds->patchWidth].lightmap[0] = ( s + 0.5 ) / LIGHTMAP_WIDTH;\n\t\t\tverts[i + j * ds->patchWidth].lightmap[1] = ( t + 0.5 ) / LIGHTMAP_HEIGHT;\n\t\t}\n\t}\n}\n\n\n/*\n===================\nAllocateLightmapForSurface\n===================\n*/\n//#define\tLIGHTMAP_BLOCK\t16\nvoid AllocateLightmapForSurface( mapDrawSurface_t *ds ) {\n\tvec3_t\t\tmins, maxs, size, exactSize, delta;\n\tint\t\t\ti;\n\tdrawVert_t\t*verts;\n\tint\t\t\tw, h;\n\tint\t\t\tx, y, ssize;\n\tint\t\t\taxis;\n\tvec3_t\t\tvecs[2];\n\tfloat\t\ts, t;\n\tvec3_t\t\torigin;\n\tplane_t\t\t*plane;\n\tfloat\t\td;\n\tvec3_t\t\tplaneNormal;\n\n\tif ( ds->patch ) {\n\t\tAllocateLightmapForPatch( ds );\n\t\treturn;\n\t}\n\n\tssize = samplesize;\n\tif (ds->shaderInfo->lightmapSampleSize)\n\t\tssize = ds->shaderInfo->lightmapSampleSize;\n\n\tplane = &mapplanes[ ds->side->planenum ];\n\n\t// bound the surface\n\tClearBounds( mins, maxs );\n\tverts = ds->verts;\n\tfor ( i = 0 ; i < ds->numVerts ; i++ ) {\n\t\tAddPointToBounds( verts[i].xyz, mins, maxs );\n\t}\n\n\t// round to the lightmap resolution\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\texactSize[i] = maxs[i] - mins[i];\n\t\tmins[i] = ssize * floor( mins[i] / ssize );\n\t\tmaxs[i] = ssize * ceil( maxs[i] / ssize );\n\t\tsize[i] = (maxs[i] - mins[i]) / ssize + 1;\n\t}\n\n\t// the two largest axis will be the lightmap size\n\tmemset( vecs, 0, sizeof( vecs ) );\n\n\tplaneNormal[0] = fabs( plane->normal[0] );\n\tplaneNormal[1] = fabs( plane->normal[1] );\n\tplaneNormal[2] = fabs( plane->normal[2] );\n\n\tif ( planeNormal[0] >= planeNormal[1] && planeNormal[0] >= planeNormal[2] ) {\n\t\tw = size[1];\n\t\th = size[2];\n\t\taxis = 0;\n\t\tvecs[0][1] = 1.0 / ssize;\n\t\tvecs[1][2] = 1.0 / ssize;\n\t} else if ( planeNormal[1] >= planeNormal[0] && planeNormal[1] >= planeNormal[2] ) {\n\t\tw = size[0];\n\t\th = size[2];\n\t\taxis = 1;\n\t\tvecs[0][0] = 1.0 / ssize;\n\t\tvecs[1][2] = 1.0 / ssize;\n\t} else {\n\t\tw = size[0];\n\t\th = size[1];\n\t\taxis = 2;\n\t\tvecs[0][0] = 1.0 / ssize;\n\t\tvecs[1][1] = 1.0 / ssize;\n\t}\n\n\tif ( !plane->normal[axis] ) {\n\t\tError( \"Chose a 0 valued axis\" );\n\t}\n\n\tif ( w > LIGHTMAP_WIDTH ) {\n\t\tVectorScale ( vecs[0], (float)LIGHTMAP_WIDTH/w, vecs[0] );\n\t\tw = LIGHTMAP_WIDTH;\n\t}\n\t\n\tif ( h > LIGHTMAP_HEIGHT ) {\n\t\tVectorScale ( vecs[1], (float)LIGHTMAP_HEIGHT/h, vecs[1] );\n\t\th = LIGHTMAP_HEIGHT;\n\t}\n\t\n\tc_exactLightmap += w * h;\n\n\tif ( !AllocLMBlock( w, h, &x, &y ) ) {\n\t\tPrepareNewLightmap();\n\t\tif ( !AllocLMBlock( w, h, &x, &y ) ) {\n\t\t\tError(\"Entity %i, brush %i: Lightmap allocation failed\", \n\t\t\t\tds->mapBrush->entitynum, ds->mapBrush->brushnum );\n\t\t}\n\t}\n\n\t// set the lightmap texture coordinates in the drawVerts\n\tds->lightmapNum = numLightmaps - 1;\n\tds->lightmapWidth = w;\n\tds->lightmapHeight = h;\n\tds->lightmapX = x;\n\tds->lightmapY = y;\n\n\tfor ( i = 0 ; i < ds->numVerts ; i++ ) {\n\t\tVectorSubtract( verts[i].xyz, mins, delta );\n\t\ts = DotProduct( delta, vecs[0] ) + x + 0.5;\n\t\tt = DotProduct( delta, vecs[1] ) + y + 0.5;\n\t\tverts[i].lightmap[0] = s / LIGHTMAP_WIDTH;\n\t\tverts[i].lightmap[1] = t / LIGHTMAP_HEIGHT;\n\t}\n\n\t// calculate the world coordinates of the lightmap samples\n\n\t// project mins onto plane to get origin\n\td = DotProduct( mins, plane->normal ) - plane->dist;\n\td /= plane->normal[ axis ];\n\tVectorCopy( mins, origin );\n\torigin[axis] -= d;\n\n\t// project stepped lightmap blocks and subtract to get planevecs\n\tfor ( i = 0 ; i < 2 ; i++ ) {\n\t\tvec3_t\tnormalized;\n\t\tfloat\tlen;\n\n\t\tlen = VectorNormalize( vecs[i], normalized );\n\t\tVectorScale( normalized, (1.0/len), vecs[i] );\n\t\td = DotProduct( vecs[i], plane->normal );\n\t\td /= plane->normal[ axis ];\n\t\tvecs[i][axis] -= d;\n\t}\n\n\tVectorCopy( origin, ds->lightmapOrigin );\n\tVectorCopy( vecs[0], ds->lightmapVecs[0] );\n\tVectorCopy( vecs[1], ds->lightmapVecs[1] );\n\tVectorCopy( plane->normal, ds->lightmapVecs[2] );\n}\n\n/*\n===================\nAllocateLightmaps\n===================\n*/\nvoid AllocateLightmaps( entity_t *e ) {\n\tint\t\t\t\ti, j;\n\tmapDrawSurface_t\t*ds;\n\tshaderInfo_t\t*si;\n\n\tqprintf (\"--- AllocateLightmaps ---\\n\");\n\n\n\t// sort all surfaces by shader so common shaders will usually\n\t// be in the same lightmap\n\tnumSortShaders = 0;\n\n\tfor ( i = e->firstDrawSurf ; i < numMapDrawSurfs ; i++ ) {\n\t\tds = &mapDrawSurfs[i];\n\t\tif ( !ds->numVerts ) {\n\t\t\tcontinue;\t\t// leftover from a surface subdivision\n\t\t}\n\t\tif ( ds->miscModel ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( !ds->patch ) {\n\t\t\tVectorCopy( mapplanes[ds->side->planenum].normal, ds->lightmapVecs[2] );\n\t\t}\n\n\t\t// search for this shader\n\t\tfor ( j = 0 ; j < numSortShaders ; j++ ) {\n\t\t\tif ( ds->shaderInfo == surfsOnShader[j]->shaderInfo ) {\n\t\t\t\tds->nextOnShader = surfsOnShader[j];\n\t\t\t\tsurfsOnShader[j] = ds;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif ( j == numSortShaders ) {\n\t\t\tif ( numSortShaders >= MAX_MAP_SHADERS ) {\n\t\t\t\tError( \"MAX_MAP_SHADERS\" );\n\t\t\t}\n\t\t\tsurfsOnShader[j] = ds;\n\t\t\tnumSortShaders++;\n\t\t}\n\t}\n\tqprintf( \"%5i unique shaders\\n\", numSortShaders );\n\n\t// for each shader, allocate lightmaps for each surface\n\n//\tnumLightmaps = 0;\n//\tPrepareNewLightmap();\n\n\tfor ( i = 0 ; i < numSortShaders ; i++ ) {\n\t\tsi = surfsOnShader[i]->shaderInfo;\n\n\t\tfor ( ds = surfsOnShader[i] ; ds ; ds = ds->nextOnShader ) {\n\t\t\t// some surfaces don't need lightmaps allocated for them\n\t\t\tif ( si->surfaceFlags & SURF_NOLIGHTMAP ) {\n\t\t\t\tds->lightmapNum = -1;\n\t\t\t} else if ( si->surfaceFlags & SURF_POINTLIGHT ) {\n\t\t\t\tds->lightmapNum = -3;\n\t\t\t} else {\n\t\t\t\tAllocateLightmapForSurface( ds );\n\t\t\t}\n\t\t}\n\t}\n\n\tqprintf( \"%7i exact lightmap texels\\n\", c_exactLightmap );\n\tqprintf( \"%7i block lightmap texels\\n\", numLightmaps * LIGHTMAP_WIDTH*LIGHTMAP_HEIGHT );\n}\n\n\n\n"
  },
  {
    "path": "q3map/lightv.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n\n#include \"cmdlib.h\"\n#include \"mathlib.h\"\n#include \"bspfile.h\"\n#include \"imagelib.h\"\n#include \"threads.h\"\n#include \"mutex.h\"\n#include \"scriplib.h\"\n\n#include \"shaders.h\"\n#include \"mesh.h\"\n\n#ifdef _WIN32\n//Improve floating-point consistency.\n#pragma optimize( \"p\", on )\n#endif\n\n#ifdef _WIN32\n#include \"../libs/pakstuff.h\"\n#endif\n\n#define MAX_CLUSTERS\t\t16384\n#define\tMAX_PORTALS\t\t\t32768\n#define MAX_FACETS\t\t\t65536\n#define MAX_LIGHTS\t\t\t16384\n\n#define LIGHTMAP_SIZE\t\t128\n\n#define LIGHTMAP_PIXELSHIFT\t\t0.5\n\n//#define LIGHTMAP_PATCHSHIFT\n\n#define\tPORTALFILE\t\"PRT1\"\n\n#define\tON_EPSILON\t0.1\n\n#define VectorSet(v, x, y, z)\t\tv[0] = x;v[1] = y;v[2] = z;\n\ntypedef struct\n{\n\tvec3_t\t\tnormal;\n\tfloat\t\tdist;\n} plane_t;\n\n#define MAX_POINTS_ON_WINDING\t64\n//NOTE: whenever this is overflowed parts of lightmaps might end up not being lit\n#define\tMAX_POINTS_ON_FIXED_WINDING\t48\n\ntypedef struct\n{\n\tint\t\tnumpoints;\n\tvec3_t\tpoints[MAX_POINTS_ON_FIXED_WINDING];\t\t\t// variable sized\n} winding_t;\n\ntypedef struct\n{\n\tplane_t\t\tplane;\t// normal pointing into neighbor\n\tint\t\t\tleaf;\t// neighbor\n\twinding_t\t*winding;\n\tvec3_t\t\torigin;\t// for fast clip testing\n\tfloat\t\tradius;\n} lportal_t;\n\n#define\tMAX_PORTALS_ON_LEAF\t\t128\ntypedef struct lleaf_s\n{\n\tint\t\t\tnumportals;\n\tlportal_t\t*portals[MAX_PORTALS_ON_LEAF];\n\t//\n\tint\t\t\tnumSurfaces;\n\tint\t\t\tfirstSurface;\n} lleaf_t;\n\ntypedef struct lFacet_s\n{\n\tint\t\tnum;\n\tplane_t\tplane;\n\tvec3_t\tpoints[4];\t\t\t\t//\n\tint\t\tnumpoints;\n\tfloat\tlightmapCoords[4][2];\n\tplane_t boundaries[4];\t\t\t// negative is outside the bounds\n\tfloat\ttextureMatrix[2][4];\t// texture coordinates for translucency\n\tfloat\tlightmapMatrix[2][4];\t// lightmap texture coordinates\n\tvec3_t\tmins;\n\tint\t\tx, y, width, height;\n} lFacet_t;\n\ntypedef struct lsurfaceTest_s\n{\n\tvec3_t\t\t\tmins, maxs;\n\tvec3_t\t\t\torigin;\n\tfloat\t\t\tradius;\n\tqboolean\t\tpatch;\t\t\t// true if this is a patch\n\tqboolean\t\ttrisoup;\t\t// true if this is a triangle soup\n\tint\t\t\t\tnumFacets;\n\tlFacet_t\t\t*facets;\n\tmesh_t\t\t\t*detailMesh;\t// detailed mesh with points for each lmp\n\tshaderInfo_t\t*shader;\t\t// for translucency\n\tmutex_t\t\t\t*mutex;\n\tint\t\t\t\tnumvolumes;\t\t// number of volumes casted at this surface\n\t//\n\tint\t\t\t\talways_tracelight;\n\tint\t\t\t\talways_vlight;\n} lsurfaceTest_t;\n\n//volume types\n#define VOLUME_NORMAL\t\t\t0\n#define VOLUME_DIRECTED\t\t\t1\n\n#define MAX_TRANSLUCENTFACETS\t32\n\ntypedef struct lightvolume_s\n{\n\tint num;\n\tint cluster;\t\t\t\t\t\t\t//cluster this light volume started in\n\tplane_t endplane;\t\t\t\t\t\t//end plane\n\tplane_t farplane;\t\t\t\t\t\t//original end plane\n\tvec3_t points[MAX_POINTS_ON_WINDING];\t//end winding points\n\tplane_t planes[MAX_POINTS_ON_WINDING];\t//volume bounding planes\n\tint numplanes;\t\t\t\t\t\t\t//number of volume bounding planes\n\tint type;\t\t\t\t\t\t\t\t//light volume type\n\t//list with translucent surfaces the volume went through\n\tint transFacets[MAX_TRANSLUCENTFACETS];\n\tint transSurfaces[MAX_TRANSLUCENTFACETS];\n\tint numtransFacets;\n\t//clusters already tested\n\tbyte clusterTested[MAX_CLUSTERS/8];\n\t//facets already tested\n\tbyte facetTested[MAX_FACETS/8];\n\tint facetNum;\t\t\t//number of the facet blocking the light in this volume\n\tint surfaceNum;\t\t\t//number of the surface blocking the light in this volume\n} lightvolume_t;\n\n//light types\n#define LIGHT_POINTRADIAL\t\t\t1\n#define LIGHT_POINTSPOT\t\t\t\t2\n#define LIGHT_POINTFAKESURFACE\t\t3\n#define LIGHT_SURFACEDIRECTED\t\t4\n#define LIGHT_SURFACERADIAL\t\t\t5\n#define LIGHT_SURFACESPOT\t\t\t6\n\n//light distance attenuation types\n#define LDAT_QUADRATIC\t\t\t\t0\n#define LDAT_LINEAR\t\t\t\t\t1\n#define LDAT_NOSCALE\t\t\t\t2\n\n//light angle attenuation types\n#define LAAT_NORMAL\t\t\t\t\t0\n#define LAAT_QUADRATIC\t\t\t\t1\n#define LAAT_DOUBLEQUADRATIC\t\t2\n\ntypedef struct vlight_s\n{\n\tvec3_t origin;\t\t\t\t//light origin, for point lights\n\twinding_t w;\t\t\t\t//light winding, for area lights\n\tvec4_t plane;\t\t\t\t//light winding plane\n\tvec3_t normal;\t\t\t\t//direction of the light\n\tint type;\t\t\t\t\t//light type\n\tvec3_t color;\t\t\t\t//light color\n\tqboolean twosided;\t\t\t//radiates light at both sides of the winding\n\tint style;\t\t\t\t\t//light style (not used)\n\tint atten_disttype;\t\t\t//light distance attenuation type\n\tint atten_angletype;\t\t//light angle attenuation type\n\tfloat atten_distscale;\t\t//distance attenuation scale\n\tfloat atten_anglescale;\t\t//angle attenuation scale\n\tfloat radiusByDist;\t\t\t//radius by distance for spot lights\n\tfloat photons;\t\t\t\t//emitted photons\n\tfloat intensity;\t\t\t//intensity\n\tvec3_t emitColor;\t\t\t//full out-of-gamut value (not used)\n\tstruct shaderInfo_s\t*si;\t//shader info\n\tint insolid;\t\t\t\t//set when light is in solid\n} vlight_t;\n\nfloat\tlightLinearScale\t\t\t= 1.0 / 8000;\nfloat\tlightPointScale\t\t\t\t= 7500;\nfloat\tlightAreaScale\t\t\t\t= 0.25;\nfloat\tlightFormFactorValueScale\t= 3;\nint\t\tlightDefaultSubdivide\t\t= 999;\t\t// vary by surface size?\nvec3_t\tlightAmbientColor;\n\nint\t\t\tportalclusters, numportals, numfaces;\nlleaf_t\t\t*leafs;\nlportal_t\t*portals;\nint\t\t\tnumvlights = 0;\nvlight_t\t*vlights[MAX_LIGHTS];\nint\t\t\tnostitching = 0;\nint\t\t\tnoalphashading = 0;\nint\t\t\tnocolorshading = 0;\nint\t\t\tnobackfaceculling = 0;\nint\t\t\tdefaulttracelight = 0;\nint\t\t\tradiosity = 0;\nint\t\t\tradiosity_scale;\n\nint\t\t\t\tclustersurfaces[MAX_MAP_LEAFFACES];\nint\t\t\t\tnumclustersurfaces = 0;\nlsurfaceTest_t\t*lsurfaceTest[MAX_MAP_DRAW_SURFS];\nint\t\t\t\tnumfacets;\nfloat\t\t\tlightmappixelarea[MAX_MAP_LIGHTING/3];\nfloat\t\t\t*lightFloats;//[MAX_MAP_LIGHTING];\n\n// from polylib.c\nwinding_t\t*AllocWinding (int points);\nvoid\t\tFreeWinding (winding_t *w);\nvoid\t\tWindingCenter (winding_t *w, vec3_t center);\nvoid\t\tWindingBounds (winding_t *w, vec3_t mins, vec3_t maxs);\nvec_t\t\tWindingArea (winding_t *w);\nwinding_t\t*BaseWindingForPlane (vec3_t normal, vec_t dist);\nvoid\t\tClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist, \n\t\t\t\tvec_t epsilon, winding_t **front, winding_t **back);\nwinding_t\t*ReverseWinding (winding_t *w);\n\n// from light.c\nextern char\t\tsource[1024];\nextern vec3_t\tsurfaceOrigin[ MAX_MAP_DRAW_SURFS ];\nextern int\t\tentitySurface[ MAX_MAP_DRAW_SURFS ];\nextern int\t\tsamplesize;\nextern int\t\tnovertexlighting;\nextern int\t\tnogridlighting;\nextern qboolean\tpatchshadows;\nextern vec3_t\tgridSize;\n\nfloat PointToPolygonFormFactor( const vec3_t point, const vec3_t normal, const winding_t *w );\nvoid ColorToBytes( const float *color, byte *colorBytes );\nvoid CountLightmaps( void );\nvoid GridAndVertexLighting( void );\nvoid SetEntityOrigins( void );\n\n\n//#define DEBUGNET\n\n#ifdef DEBUGNET\n\n#include \"l_net.h\"\n\nsocket_t *debug_socket;\n\n/*\n=====================\nDebugNet_Setup\n=====================\n*/\nvoid DebugNet_Setup(void)\n{\n\taddress_t address;\n\tint i;\n\n\tNet_Setup();\n\tNet_StringToAddress(\"127.0.0.1:28000\", &address);\n\tfor (i = 0; i < 10; i++)\n\t{\n\t\tdebug_socket = Net_Connect(&address, 28005 + i);\n\t\tif (debug_socket)\n\t\t\tbreak;\n\t}\n}\n\n/*\n=====================\nDebugNet_Shutdown\n=====================\n*/\nvoid DebugNet_Shutdown(void)\n{\n\tnetmessage_t msg;\n\n\tif (debug_socket)\n\t{\n\t\tNMSG_Clear(&msg);\n\t\tNMSG_WriteByte(&msg, 1);\n\t\tNet_Send(debug_socket, &msg);\n\t\tNet_Disconnect(debug_socket);\n\t}\n\tdebug_socket = NULL;\n\tNet_Shutdown();\n}\n\n/*\n=====================\nDebugNet_RemoveAllPolys\n=====================\n*/\nvoid DebugNet_RemoveAllPolys(void)\n{\n\tnetmessage_t msg;\n\n\tif (!debug_socket)\n\t\treturn;\n\tNMSG_Clear(&msg);\n\tNMSG_WriteByte(&msg, 2);\t\t//remove all debug polys\n\tNet_Send(debug_socket, &msg);\n}\n\n/*\n====================\nDebugNet_DrawWinding\n=====================\n*/\nvoid DebugNet_DrawWinding(winding_t *w, int color)\n{\n\tnetmessage_t msg;\n\tint i;\n\n\tif (!debug_socket)\n\t\treturn;\n\tNMSG_Clear(&msg);\n\tNMSG_WriteByte(&msg, 0);\t\t\t\t//draw a winding\n\tNMSG_WriteByte(&msg, w->numpoints);\t\t//number of points\n\tNMSG_WriteLong(&msg, color);\t\t\t//color\n\tfor (i = 0; i < w->numpoints; i++)\n\t{\n\t\tNMSG_WriteFloat(&msg, w->points[i][0]);\n\t\tNMSG_WriteFloat(&msg, w->points[i][1]);\n\t\tNMSG_WriteFloat(&msg, w->points[i][2]);\n\t}\n\tNet_Send(debug_socket, &msg);\n}\n\n/*\n=====================\nDebugNet_DrawLine\n=====================\n*/\nvoid DebugNet_DrawLine(vec3_t p1, vec3_t p2, int color)\n{\n\tnetmessage_t msg;\n\n\tif (!debug_socket)\n\t\treturn;\n\tNMSG_Clear(&msg);\n\tNMSG_WriteByte(&msg, 1);\t\t\t\t//draw a line\n\tNMSG_WriteLong(&msg, color);\t\t\t//color\n\tNMSG_WriteFloat(&msg, p1[0]);\n\tNMSG_WriteFloat(&msg, p1[1]);\n\tNMSG_WriteFloat(&msg, p1[2]);\n\tNMSG_WriteFloat(&msg, p2[0]);\n\tNMSG_WriteFloat(&msg, p2[1]);\n\tNMSG_WriteFloat(&msg, p2[2]);\n\tNet_Send(debug_socket, &msg);\n}\n\n/*\n=====================\nDebugNet_DrawMesh\n=====================\n*/\nvoid DebugNet_DrawMesh(mesh_t *mesh)\n{\n\tint i, j;\n\tfloat dot;\n\tdrawVert_t\t*v1, *v2, *v3, *v4;\n\twinding_t winding;\n\tplane_t plane;\n\tvec3_t d1, d2;\n\n\tfor ( i = 0 ; i < mesh->width - 1 ; i++ ) {\n\t\tfor ( j = 0 ; j < mesh->height - 1 ; j++ ) {\n\n\t\t\tv1 = mesh->verts + j * mesh->width + i;\n\t\t\tv2 = v1 + 1;\n\t\t\tv3 = v1 + mesh->width + 1;\n\t\t\tv4 = v1 + mesh->width;\n\n\t\t\tVectorSubtract( v4->xyz, v1->xyz, d1 );\n\t\t\tVectorSubtract( v3->xyz, v1->xyz, d2 );\n\t\t\tCrossProduct( d2, d1, plane.normal );\n\t\t\tif ( VectorNormalize( plane.normal, plane.normal ) != 0 )\n\t\t\t{\n\t\t\t\tplane.dist = DotProduct( v1->xyz, plane.normal );\n\t\t\t\tdot = DotProduct(plane.normal, v2->xyz) - plane.dist;\n\t\t\t\tif (fabs(dot) < 0.1)\n\t\t\t\t{\n\t\t\t\t\tVectorCopy(v1->xyz, winding.points[0]);\n\t\t\t\t\tVectorCopy(v4->xyz, winding.points[1]);\n\t\t\t\t\tVectorCopy(v3->xyz, winding.points[2]);\n\t\t\t\t\tVectorCopy(v2->xyz, winding.points[3]);\n\t\t\t\t\twinding.numpoints = 4;\n\t\t\t\t\tDebugNet_DrawWinding(&winding, 2);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\twinding.numpoints = 3;\n\t\t\tVectorCopy(v1->xyz, winding.points[0]);\n\t\t\tVectorCopy(v4->xyz, winding.points[1]);\n\t\t\tVectorCopy(v3->xyz, winding.points[2]);\n\t\t\tDebugNet_DrawWinding(&winding, 2);\n\n\t\t\tVectorCopy(v1->xyz, winding.points[0]);\n\t\t\tVectorCopy(v3->xyz, winding.points[1]);\n\t\t\tVectorCopy(v2->xyz, winding.points[2]);\n\t\t\tDebugNet_DrawWinding(&winding, 2);\n\t\t}\n\t}\n}\n\n/*\n=====================\nVL_DrawLightVolume\n=====================\n*/\nint VL_ChopWinding (winding_t *in, plane_t *split, float epsilon);\n\nvoid VL_DrawLightVolume(vlight_t *light, lightvolume_t *volume)\n{\n\twinding_t w;\n\tint i;\n\tvec3_t p2, invlight;\n\n\tmemcpy(w.points, volume->points, volume->numplanes * sizeof(vec3_t));\n\tw.numpoints = volume->numplanes;\n\tDebugNet_DrawWinding(&w, 2);\n\n\tif (volume->type == VOLUME_DIRECTED)\n\t{\n\t\tVectorCopy(light->normal, invlight);\n\t\tVectorInverse(invlight);\n\t\tfor (i = 0; i < volume->numplanes; i++)\n\t\t{\n\t\t\tVectorCopy(volume->points[i], w.points[0]);\n\t\t\tVectorCopy(volume->points[(i+1) % volume->numplanes], w.points[1]);\n\t\t\tVectorMA(w.points[1], MAX_WORLD_COORD, invlight, w.points[2]);\n\t\t\tVectorMA(w.points[0], MAX_WORLD_COORD, invlight, w.points[3]);\n\t\t\tw.numpoints = 4;\n\t\t\tDebugNet_DrawWinding(&w, 2);\n\t\t\tVectorMA(volume->points[i], 8, volume->planes[i].normal, p2);\n\t\t\tDebugNet_DrawLine(volume->points[i], p2, 3);\n\t\t}\n\t}\n\telse\n\t{\n\t\t//\n\t\tVectorCopy(light->origin, w.points[0]);\n\t\tw.numpoints = 3;\n\t\tfor (i = 0; i < volume->numplanes; i++)\n\t\t{\n\t\t\tVectorCopy(volume->points[i], w.points[1]);\n\t\t\tVectorCopy(volume->points[(i+1) % volume->numplanes], w.points[2]);\n\t\t\tVL_ChopWinding(&w, &volume->endplane, 0);\n\t\t\tDebugNet_DrawWinding(&w, 2);\n\t\t\tVectorMA(volume->points[i], 8, volume->planes[i].normal, p2);\n\t\t\tDebugNet_DrawLine(volume->points[i], p2, 3);\n\t\t}\n\t}\n}\n\n/*\n=============\nVL_DrawLightmapPixel\n=============\n*/\nvoid VL_DrawLightmapPixel(int surfaceNum, int x, int y, int color)\n{\n\twinding_t w;\n\tdsurface_t *ds;\n\tmesh_t *mesh;\n\n\tds = &drawSurfaces[surfaceNum];\n\n\tif (ds->surfaceType == MST_PATCH)\n\t{\n\t\tmesh = lsurfaceTest[surfaceNum]->detailMesh;\n\t\tVectorCopy( mesh->verts[(y-ds->lightmapY)*mesh->width+x-ds->lightmapX].xyz, w.points[0]);\n\t\tVectorCopy( mesh->verts[(y+1-ds->lightmapY)*mesh->width+x-ds->lightmapX].xyz, w.points[1]);\n\t\tVectorCopy( mesh->verts[(y+1-ds->lightmapY)*mesh->width+x+1-ds->lightmapX].xyz, w.points[2]);\n\t\tVectorCopy( mesh->verts[(y-ds->lightmapY)*mesh->width+x+1-ds->lightmapX].xyz, w.points[3]);\n\t\tw.numpoints = 4;\n\t}\n\telse\n\t{\n\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT - ds->lightmapX, ds->lightmapVecs[0], w.points[0]);\n\t\tVectorMA(w.points[0], (float) y - LIGHTMAP_PIXELSHIFT - ds->lightmapY, ds->lightmapVecs[1], w.points[0]);\n\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT - ds->lightmapX, ds->lightmapVecs[0], w.points[1]);\n\t\tVectorMA(w.points[1], (float) y - LIGHTMAP_PIXELSHIFT + 1 - ds->lightmapY, ds->lightmapVecs[1], w.points[1]);\n\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT + 1 - ds->lightmapX, ds->lightmapVecs[0], w.points[2]);\n\t\tVectorMA(w.points[2], (float) y - LIGHTMAP_PIXELSHIFT + 1 - ds->lightmapY, ds->lightmapVecs[1], w.points[2]);\n\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT + 1 - ds->lightmapX, ds->lightmapVecs[0], w.points[3]);\n\t\tVectorMA(w.points[3], (float) y - LIGHTMAP_PIXELSHIFT - ds->lightmapY, ds->lightmapVecs[1], w.points[3]);\n\t\tw.numpoints = 4;\n\t}\n\tDebugNet_DrawWinding(&w, color);\n}\n\n/*\n============\nVL_DrawPortals\n============\n*/\nvoid VL_DrawPortals(void)\n{\n\tint j;\n\tlportal_t *p;\n\n\tfor (j = 0; j < numportals * 2; j++)\n\t{\n\t\tp = portals + j;\n\t\tDebugNet_DrawWinding(p->winding, 1);\n\t}\n}\n\n/*\n============\nVL_DrawLeaf\n============\n*/\nvoid VL_DrawLeaf(int cluster)\n{\n\tint i;\n\tlleaf_t *leaf;\n\tlportal_t *p;\n\n\tleaf = &leafs[cluster];\n\tfor (i = 0; i < leaf->numportals; i++)\n\t{\n\t\tp = leaf->portals[i];\n\t\tDebugNet_DrawWinding(p->winding, 1);\n\t}\n}\n\n#endif //DEBUGNET\n\n/*\n=============\nVL_SplitWinding\n=============\n*/\nint VL_SplitWinding (winding_t *in, winding_t *back, plane_t *split, float epsilon)\n{\n\tvec_t\tdists[128];\n\tint\t\tsides[128];\n\tint\t\tcounts[3];\n\tvec_t\tdot;\n\tint\t\ti, j;\n\tvec_t\t*p1, *p2;\n\tvec3_t\tmid;\n\twinding_t out;\n\twinding_t\t*neww;\n\n\tcounts[0] = counts[1] = counts[2] = 0;\n\n\t// determine sides for each point\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tdot = DotProduct (in->points[i], split->normal);\n\t\tdot -= split->dist;\n\t\tdists[i] = dot;\n\t\tif (dot > epsilon)\n\t\t\tsides[i] = SIDE_FRONT;\n\t\telse if (dot < -epsilon)\n\t\t\tsides[i] = SIDE_BACK;\n\t\telse\n\t\t{\n\t\t\tsides[i] = SIDE_ON;\n\t\t}\n\t\tcounts[sides[i]]++;\n\t}\n\n\tif (!counts[SIDE_BACK])\n\t{\n\t\tif (!counts[SIDE_FRONT])\n\t\t\treturn SIDE_ON;\n\t\telse\n\t\t\treturn SIDE_FRONT;\n\t}\n\t\n\tif (!counts[SIDE_FRONT])\n\t{\n\t\treturn SIDE_BACK;\n\t}\n\n\tsides[i] = sides[0];\n\tdists[i] = dists[0];\n\t\n\tneww = &out;\n\n\tneww->numpoints = 0;\n\tback->numpoints = 0;\n\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tp1 = in->points[i];\n\n\t\tif (neww->numpoints >= MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\t_printf(\"WARNING: VL_SplitWinding -> MAX_POINTS_ON_FIXED_WINDING overflowed\\n\");\n\t\t\treturn SIDE_FRONT;\t\t// can't chop -- fall back to original\n\t\t}\n\t\tif (back->numpoints >= MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\t_printf(\"WARNING: VL_SplitWinding -> MAX_POINTS_ON_FIXED_WINDING overflowed\\n\");\n\t\t\treturn SIDE_FRONT;\n\t\t}\n\n\t\tif (sides[i] == SIDE_ON)\n\t\t{\n\t\t\tVectorCopy (p1, neww->points[neww->numpoints]);\n\t\t\tneww->numpoints++;\n\t\t\tVectorCopy (p1, back->points[back->numpoints]);\n\t\t\tback->numpoints++;\n\t\t\tcontinue;\n\t\t}\n\t\n\t\tif (sides[i] == SIDE_FRONT)\n\t\t{\n\t\t\tVectorCopy (p1, neww->points[neww->numpoints]);\n\t\t\tneww->numpoints++;\n\t\t}\n\t\tif (sides[i] == SIDE_BACK)\n\t\t{\n\t\t\tVectorCopy (p1, back->points[back->numpoints]);\n\t\t\tback->numpoints++;\n\t\t}\n\t\t\n\t\tif (sides[i+1] == SIDE_ON || sides[i+1] == sides[i])\n\t\t\tcontinue;\n\t\t\t\n\t\tif (neww->numpoints >= MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\t_printf(\"WARNING: VL_SplitWinding -> MAX_POINTS_ON_FIXED_WINDING overflowed\\n\");\n\t\t\treturn SIDE_FRONT;\t\t// can't chop -- fall back to original\n\t\t}\n\n\t\tif (back->numpoints >= MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\t_printf(\"WARNING: VL_SplitWinding -> MAX_POINTS_ON_FIXED_WINDING overflowed\\n\");\n\t\t\treturn SIDE_FRONT;\t\t// can't chop -- fall back to original\n\t\t}\n\n\t\t// generate a split point\n\t\tp2 = in->points[(i+1)%in->numpoints];\n\t\t\n\t\tdot = dists[i] / (dists[i]-dists[i+1]);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\t// avoid round off error when possible\n\t\t\tif (split->normal[j] == 1)\n\t\t\t\tmid[j] = split->dist;\n\t\t\telse if (split->normal[j] == -1)\n\t\t\t\tmid[j] = -split->dist;\n\t\t\telse\n\t\t\t\tmid[j] = p1[j] + dot*(p2[j]-p1[j]);\n\t\t}\n\t\t\t\n\t\tVectorCopy (mid, neww->points[neww->numpoints]);\n\t\tneww->numpoints++;\n\t\tVectorCopy (mid, back->points[back->numpoints]);\n\t\tback->numpoints++;\n\t}\n\tmemcpy(in, &out, sizeof(winding_t));\n\t\n\treturn SIDE_CROSS;\n}\n\n/*\n=====================\nVL_LinkSurfaceIntoCluster\n=====================\n*/\nvoid VL_LinkSurfaceIntoCluster(int cluster, int surfaceNum)\n{\n\tlleaf_t *leaf;\n\tint i;\n\n\tleaf = &leafs[cluster];\n\n\tfor (i = 0; i < leaf->numSurfaces; i++)\n\t{\n\t\tif (clustersurfaces[leaf->firstSurface + i] == surfaceNum)\n\t\t\treturn;\n\t}\n\tfor (i = numclustersurfaces; i > leaf->firstSurface + leaf->numSurfaces; i--)\n\t\tclustersurfaces[i] = clustersurfaces[i-1];\n\tfor (i = 0; i < portalclusters; i++)\n\t{\n\t\tif (i == cluster)\n\t\t\tcontinue;\n\t\tif (leafs[i].firstSurface >= leaf->firstSurface + leaf->numSurfaces)\n\t\t\tleafs[i].firstSurface++;\n\t}\n\tclustersurfaces[leaf->firstSurface + leaf->numSurfaces] = surfaceNum;\n\tleaf->numSurfaces++;\n\tnumclustersurfaces++;\n\tif (numclustersurfaces >= MAX_MAP_LEAFFACES)\n\t\tError(\"MAX_MAP_LEAFFACES\");\n}\n\n/*\n=====================\nVL_R_LinkSurface\n=====================\n*/\nvoid VL_R_LinkSurface(int nodenum, int surfaceNum, winding_t *w)\n{\n\tint leafnum, cluster, res;\n\tdnode_t *node;\n\tdplane_t *plane;\n\twinding_t back;\n\tplane_t split;\n\n\twhile(nodenum >= 0)\n\t{\n\t\tnode = &dnodes[nodenum];\n\t\tplane = &dplanes[node->planeNum];\n\n\t\tVectorCopy(plane->normal, split.normal);\n\t\tsplit.dist = plane->dist;\n\t\tres = VL_SplitWinding (w, &back, &split, 0.1);\n\n\t\tif (res == SIDE_FRONT)\n\t\t{\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t\telse if (res == SIDE_BACK)\n\t\t{\n\t\t\tnodenum = node->children[1];\n\t\t}\n\t\telse if (res == SIDE_ON)\n\t\t{\n\t\t\tmemcpy(&back, w, sizeof(winding_t));\n\t\t\tVL_R_LinkSurface(node->children[1], surfaceNum, &back);\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVL_R_LinkSurface(node->children[1], surfaceNum, &back);\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t}\n\tleafnum = -nodenum - 1;\n\tcluster = dleafs[leafnum].cluster;\n\tif (cluster != -1)\n\t{\n\t\tVL_LinkSurfaceIntoCluster(cluster, surfaceNum);\n\t}\n}\n\n/*\n=====================\nVL_LinkSurfaces\n\nmaybe link each facet seperately instead of the test surfaces?\n=====================\n*/\nvoid VL_LinkSurfaces(void)\n{\n\tint i, j;\n\tlsurfaceTest_t *test;\n\tlFacet_t *facet;\n\twinding_t winding;\n\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ )\n\t{\n\t\ttest = lsurfaceTest[ i ];\n\t\tif (!test)\n\t\t\tcontinue;\n\t\tfor (j = 0; j < test->numFacets; j++)\n\t\t{\n\t\t\tfacet = &test->facets[j];\n\t\t\tmemcpy(winding.points, facet->points, facet->numpoints * sizeof(vec3_t));\n\t\t\twinding.numpoints = facet->numpoints;\n\t\t\tVL_R_LinkSurface(0, i, &winding);\n\t\t}\n\t}\n}\n\n/*\n=====================\nVL_TextureMatrixFromPoints\n=====================\n*/\nvoid VL_TextureMatrixFromPoints( lFacet_t *f, drawVert_t *a, drawVert_t *b, drawVert_t *c ) {\n\tint\t\t\ti, j;\n\tfloat\t\tt;\n\tfloat\t\tm[3][4];\n\tfloat\t\ts;\n\n\t// This is an incredibly stupid way of solving a three variable equation\n\tfor ( i = 0 ; i < 2 ; i++ ) {\n\n\t\tm[0][0] = a->xyz[0];\n\t\tm[0][1] = a->xyz[1];\n\t\tm[0][2] = a->xyz[2];\n\t\tm[0][3] = a->st[i];\n\n\t\tm[1][0] = b->xyz[0];\n\t\tm[1][1] = b->xyz[1];\n\t\tm[1][2] = b->xyz[2];\n\t\tm[1][3] = b->st[i];\n\n\t\tm[2][0] = c->xyz[0];\n\t\tm[2][1] = c->xyz[1];\n\t\tm[2][2] = c->xyz[2];\n\t\tm[2][3] = c->st[i];\n\n\t\tif ( fabs(m[1][0]) > fabs(m[0][0]) && fabs(m[1][0]) > fabs(m[2][0]) ) {\n\t\t\tfor ( j = 0 ; j < 4 ; j ++ ) {\n\t\t\t\tt = m[0][j];\n\t\t\t\tm[0][j] = m[1][j];\n\t\t\t\tm[1][j] = t;\n\t\t\t}\n\t\t} else if ( fabs(m[2][0]) > fabs(m[0][0]) && fabs(m[2][0]) > fabs(m[1][0]) ) {\n\t\t\tfor ( j = 0 ; j < 4 ; j ++ ) {\n\t\t\t\tt = m[0][j];\n\t\t\t\tm[0][j] = m[2][j];\n\t\t\t\tm[2][j] = t;\n\t\t\t}\n\t\t}\n\n\t\ts = 1.0 / m[0][0];\n\t\tm[0][0] *= s;\n\t\tm[0][1] *= s;\n\t\tm[0][2] *= s;\n\t\tm[0][3] *= s;\n\n\t\ts = m[1][0];\n\t\tm[1][0] -= m[0][0] * s;\n\t\tm[1][1] -= m[0][1] * s;\n\t\tm[1][2] -= m[0][2] * s;\n\t\tm[1][3] -= m[0][3] * s;\n\n\t\ts = m[2][0];\n\t\tm[2][0] -= m[0][0] * s;\n\t\tm[2][1] -= m[0][1] * s;\n\t\tm[2][2] -= m[0][2] * s;\n\t\tm[2][3] -= m[0][3] * s;\n\n\t\tif ( fabs(m[2][1]) > fabs(m[1][1]) ) {\n\t\t\tfor ( j = 0 ; j < 4 ; j ++ ) {\n\t\t\t\tt = m[1][j];\n\t\t\t\tm[1][j] = m[2][j];\n\t\t\t\tm[2][j] = t;\n\t\t\t}\n\t\t}\n\n\t\ts = 1.0 / m[1][1];\n\t\tm[1][0] *= s;\n\t\tm[1][1] *= s;\n\t\tm[1][2] *= s;\n\t\tm[1][3] *= s;\n\n\t\ts = m[2][1];// / m[1][1];\n\t\tm[2][0] -= m[1][0] * s;\n\t\tm[2][1] -= m[1][1] * s;\n\t\tm[2][2] -= m[1][2] * s;\n\t\tm[2][3] -= m[1][3] * s;\n\n\t\ts = 1.0 / m[2][2];\n\t\tm[2][0] *= s;\n\t\tm[2][1] *= s;\n\t\tm[2][2] *= s;\n\t\tm[2][3] *= s;\n\n\t\tf->textureMatrix[i][2] = m[2][3];\n\t\tf->textureMatrix[i][1] = m[1][3] - f->textureMatrix[i][2] * m[1][2];\n\t\tf->textureMatrix[i][0] = m[0][3] - f->textureMatrix[i][2] * m[0][2] - f->textureMatrix[i][1] * m[0][1];\n\n\t\tf->textureMatrix[i][3] = 0;\n/*\n\t\ts = fabs( DotProduct( a->xyz, f->textureMatrix[i] ) - a->st[i] );\n\t\tif ( s > 0.01 ) {\n\t\t\tError( \"Bad textureMatrix\" );\n\t\t}\n\t\ts = fabs( DotProduct( b->xyz, f->textureMatrix[i] ) - b->st[i] );\n\t\tif ( s > 0.01 ) {\n\t\t\tError( \"Bad textureMatrix\" );\n\t\t}\n\t\ts = fabs( DotProduct( c->xyz, f->textureMatrix[i] ) - c->st[i] );\n\t\tif ( s > 0.01 ) {\n\t\t\tError( \"Bad textureMatrix\" );\n\t\t}\n*/\n\t}\n}\n\n/*\n=====================\nVL_LightmapMatrixFromPoints\n=====================\n*/\nvoid VL_LightmapMatrixFromPoints( dsurface_t *dsurf, shaderInfo_t *si, lFacet_t *f, drawVert_t *a, drawVert_t *b, drawVert_t *c ) {\n\tint\t\t\ti, j;\n\tfloat\t\tt;\n\tfloat\t\tm[3][4], al, bl, cl;\n\tfloat\t\ts;\n\tint\t\t\th, w, ssize;\n\tvec3_t\t\tmins, maxs, delta, size, planeNormal;\n\tdrawVert_t\t*verts;\n\tstatic int\tmessage;\n\n\t// vertex-lit triangle model\n\tif ( dsurf->surfaceType == MST_TRIANGLE_SOUP ) {\n\t\treturn;\n\t}\n\t\n\tif ( dsurf->lightmapNum < 0 ) {\n\t\treturn;\t\t// doesn't need lighting\n\t}\n\n\tVectorClear(f->mins);\n\tif (dsurf->surfaceType != MST_PATCH)\n\t{\n\t\tssize = samplesize;\n\t\tif (si->lightmapSampleSize)\n\t\t\tssize = si->lightmapSampleSize;\n\t\tClearBounds( mins, maxs );\n\t\tverts = &drawVerts[dsurf->firstVert];\n\t\tfor ( i = 0 ; i < dsurf->numVerts ; i++ ) {\n\t\t\tAddPointToBounds( verts[i].xyz, mins, maxs );\n\t\t}\n\t\t// round to the lightmap resolution\n\t\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\t\tmins[i] = ssize * floor( mins[i] / ssize );\n\t\t\tmaxs[i] = ssize * ceil( maxs[i] / ssize );\n\t\t\tf->mins[i] = mins[i];\n\t\t\tsize[i] = (maxs[i] - mins[i]) / ssize + 1;\n\t\t}\n\t\t// the two largest axis will be the lightmap size\n\t\tVectorClear(f->lightmapMatrix[0]);\n\t\tf->lightmapMatrix[0][3] = 0;\n\t\tVectorClear(f->lightmapMatrix[1]);\n\t\tf->lightmapMatrix[1][3] = 0;\n\n\t\tplaneNormal[0] = fabs( dsurf->lightmapVecs[2][0] );\n\t\tplaneNormal[1] = fabs( dsurf->lightmapVecs[2][1] );\n\t\tplaneNormal[2] = fabs( dsurf->lightmapVecs[2][2] );\n\n\t\tif ( planeNormal[0] >= planeNormal[1] && planeNormal[0] >= planeNormal[2] ) {\n\t\t\tw = size[1];\n\t\t\th = size[2];\n\t\t\tf->lightmapMatrix[0][1] = 1.0 / ssize;\n\t\t\tf->lightmapMatrix[1][2] = 1.0 / ssize;\n\t\t} else if ( planeNormal[1] >= planeNormal[0] && planeNormal[1] >= planeNormal[2] ) {\n\t\t\tw = size[0];\n\t\t\th = size[2];\n\t\t\tf->lightmapMatrix[0][0] = 1.0 / ssize;\n\t\t\tf->lightmapMatrix[1][2] = 1.0 / ssize;\n\t\t} else {\n\t\t\tw = size[0];\n\t\t\th = size[1];\n\t\t\tf->lightmapMatrix[0][0] = 1.0 / ssize;\n\t\t\tf->lightmapMatrix[1][1] = 1.0 / ssize;\n\t\t}\n\t\tif ( w > LIGHTMAP_WIDTH ) {\n\t\t\tVectorScale ( f->lightmapMatrix[0], (float)LIGHTMAP_SIZE/w, f->lightmapMatrix[0] );\n\t\t}\n\t\t\n\t\tif ( h > LIGHTMAP_HEIGHT ) {\n\t\t\tVectorScale ( f->lightmapMatrix[1], (float)LIGHTMAP_SIZE/h, f->lightmapMatrix[1] );\n\t\t}\n\t\tVectorSubtract(a->xyz, f->mins, delta);\n\t\ts = (DotProduct( delta, f->lightmapMatrix[0] ) + dsurf->lightmapX + 0.5) / LIGHTMAP_SIZE;\n\t\tif ( fabs(s - a->lightmap[0]) > 0.01 ) {\n\t\t\t_printf( \"Bad lightmapMatrix\" );\n\t\t}\n\t\tt = (DotProduct( delta, f->lightmapMatrix[1] ) + dsurf->lightmapY + 0.5) / LIGHTMAP_SIZE;\n\t\tif ( fabs(t - a->lightmap[1]) > 0.01 ) {\n\t\t\t_printf( \"Bad lightmapMatrix\" );\n\t\t}\n\t\tVectorSubtract(b->xyz, f->mins, delta);\n\t\ts = (DotProduct( delta, f->lightmapMatrix[0] ) + dsurf->lightmapX + 0.5) / LIGHTMAP_SIZE;\n\t\tif ( fabs(s - b->lightmap[0]) > 0.01 ) {\n\t\t\t_printf( \"Bad lightmapMatrix\" );\n\t\t}\n\t\tt = (DotProduct( delta, f->lightmapMatrix[1] ) + dsurf->lightmapY + 0.5) / LIGHTMAP_SIZE;\n\t\tif ( fabs(t - b->lightmap[1]) > 0.01 ) {\n\t\t\t_printf( \"Bad lightmapMatrix\" );\n\t\t}\n\t\tVectorSubtract(c->xyz, f->mins, delta);\n\t\ts = (DotProduct( delta, f->lightmapMatrix[0] ) + dsurf->lightmapX + 0.5) / LIGHTMAP_SIZE;\n\t\tif ( fabs(s - c->lightmap[0]) > 0.01 ) {\n\t\t\t_printf( \"Bad lightmapMatrix\" );\n\t\t}\n\t\tt = (DotProduct( delta, f->lightmapMatrix[1] ) + dsurf->lightmapY + 0.5) / LIGHTMAP_SIZE;\n\t\tif ( fabs(t - c->lightmap[1]) > 0.01 ) {\n\t\t\t_printf( \"Bad lightmapMatrix\" );\n\t\t}\n\t\tVectorAdd(f->mins, surfaceOrigin[dsurf - drawSurfaces], f->mins);\n\t\treturn;\n\t}\n\t// This is an incredibly stupid way of solving a three variable equation\n\tfor ( i = 0 ; i < 2 ; i++ ) {\n\n\t\tif (i)\n\t\t\tal = a->lightmap[i] - ((float) dsurf->lightmapY + 0.5) / LIGHTMAP_SIZE;\n\t\telse\n\t\t\tal = a->lightmap[i] - ((float) dsurf->lightmapX + 0.5) / LIGHTMAP_SIZE;\n\n\t\tm[0][0] = a->xyz[0] - f->mins[0];\n\t\tm[0][1] = a->xyz[1] - f->mins[1];\n\t\tm[0][2] = a->xyz[2] - f->mins[2];\n\t\tm[0][3] = al;\n\n\t\tif (i)\n\t\t\tbl = b->lightmap[i] - ((float) dsurf->lightmapY + 0.5) / LIGHTMAP_SIZE;\n\t\telse\n\t\t\tbl = b->lightmap[i] - ((float) dsurf->lightmapX + 0.5) / LIGHTMAP_SIZE;\n\n\t\tm[1][0] = b->xyz[0] - f->mins[0];\n\t\tm[1][1] = b->xyz[1] - f->mins[1];\n\t\tm[1][2] = b->xyz[2] - f->mins[2];\n\t\tm[1][3] = bl;\n\n\t\tif (i)\n\t\t\tcl = c->lightmap[i] - ((float) dsurf->lightmapY + 0.5) / LIGHTMAP_SIZE;\n\t\telse\n\t\t\tcl = c->lightmap[i] - ((float) dsurf->lightmapX + 0.5) / LIGHTMAP_SIZE;\n\n\t\tm[2][0] = c->xyz[0] - f->mins[0];\n\t\tm[2][1] = c->xyz[1] - f->mins[1];\n\t\tm[2][2] = c->xyz[2] - f->mins[2];\n\t\tm[2][3] = cl;\n\n\t\tif ( fabs(m[1][0]) > fabs(m[0][0]) && fabs(m[1][0]) >= fabs(m[2][0]) ) {\n\t\t\tfor ( j = 0 ; j < 4 ; j ++ ) {\n\t\t\t\tt = m[0][j];\n\t\t\t\tm[0][j] = m[1][j];\n\t\t\t\tm[1][j] = t;\n\t\t\t}\n\t\t} else if ( fabs(m[2][0]) > fabs(m[0][0]) && fabs(m[2][0]) >= fabs(m[1][0]) ) {\n\t\t\tfor ( j = 0 ; j < 4 ; j ++ ) {\n\t\t\t\tt = m[0][j];\n\t\t\t\tm[0][j] = m[2][j];\n\t\t\t\tm[2][j] = t;\n\t\t\t}\n\t\t}\n\n\t\tif (m[0][0])\n\t\t{\n\t\t\ts = 1.0 / m[0][0];\n\t\t\tm[0][0] *= s;\n\t\t\tm[0][1] *= s;\n\t\t\tm[0][2] *= s;\n\t\t\tm[0][3] *= s;\n\n\t\t\ts = m[1][0];\n\t\t\tm[1][0] -= m[0][0] * s;\n\t\t\tm[1][1] -= m[0][1] * s;\n\t\t\tm[1][2] -= m[0][2] * s;\n\t\t\tm[1][3] -= m[0][3] * s;\n\n\t\t\ts = m[2][0];\n\t\t\tm[2][0] -= m[0][0] * s;\n\t\t\tm[2][1] -= m[0][1] * s;\n\t\t\tm[2][2] -= m[0][2] * s;\n\t\t\tm[2][3] -= m[0][3] * s;\n\t\t}\n\n\t\tif ( fabs(m[2][1]) > fabs(m[1][1]) ) {\n\t\t\tfor ( j = 0 ; j < 4 ; j ++ ) {\n\t\t\t\tt = m[1][j];\n\t\t\t\tm[1][j] = m[2][j];\n\t\t\t\tm[2][j] = t;\n\t\t\t}\n\t\t}\n\n\t\tif (m[1][1])\n\t\t{\n\t\t\ts = 1.0 / m[1][1];\n\t\t\tm[1][0] *= s;\n\t\t\tm[1][1] *= s;\n\t\t\tm[1][2] *= s;\n\t\t\tm[1][3] *= s;\n\n\t\t\ts = m[2][1];\n\t\t\tm[2][0] -= m[1][0] * s;\n\t\t\tm[2][1] -= m[1][1] * s;\n\t\t\tm[2][2] -= m[1][2] * s;\n\t\t\tm[2][3] -= m[1][3] * s;\n\t\t}\n\n\t\tif (m[2][2])\n\t\t{\n\t\t\ts = 1.0 / m[2][2];\n\t\t\tm[2][0] *= s;\n\t\t\tm[2][1] *= s;\n\t\t\tm[2][2] *= s;\n\t\t\tm[2][3] *= s;\n\t\t}\n\n\t\tf->lightmapMatrix[i][2] = m[2][3];\n\t\tf->lightmapMatrix[i][1] = m[1][3] - f->lightmapMatrix[i][2] * m[1][2];\n\t\tf->lightmapMatrix[i][0] = m[0][3] - f->lightmapMatrix[i][2] * m[0][2] - f->lightmapMatrix[i][1] * m[0][1];\n\n\t\tf->lightmapMatrix[i][3] = 0;\n\n\t\tVectorSubtract(a->xyz, f->mins, delta);\n\t\ts = fabs( DotProduct( delta, f->lightmapMatrix[i] ) - al );\n\t\tif ( s > 0.01 ) {\n\t\t\tif (!message)\n\t\t\t\t_printf( \"Bad lightmapMatrix\\n\" );\n\t\t\tmessage = qtrue;\n\t\t}\n\t\tVectorSubtract(b->xyz, f->mins, delta);\n\t\ts = fabs( DotProduct( delta, f->lightmapMatrix[i] ) - bl );\n\t\tif ( s > 0.01 ) {\n\t\t\tif (!message)\n\t\t\t\t_printf( \"Bad lightmapMatrix\\n\" );\n\t\t\tmessage = qtrue;\n\t\t}\n\t\tVectorSubtract(c->xyz, f->mins, delta);\n\t\ts = fabs( DotProduct( delta, f->lightmapMatrix[i] ) - cl );\n\t\tif ( s > 0.01 ) {\n\t\t\tif (!message)\n\t\t\t\t_printf( \"Bad lightmapMatrix\\n\" );\n\t\t\tmessage = qtrue;\n\t\t}\n\t\tVectorAdd(f->mins, surfaceOrigin[dsurf - drawSurfaces], f->mins);\n\t}\n}\n\n/*\n=============\nPlane_Equal\n=============\n*/\n#define\tNORMAL_EPSILON\t0.0001\n#define\tDIST_EPSILON\t0.02\n\nint Plane_Equal(plane_t *a, plane_t *b, int flip)\n{\n\tvec3_t normal;\n\tfloat dist;\n\n\tif (flip) {\n\t\tnormal[0] = - b->normal[0];\n\t\tnormal[1] = - b->normal[1];\n\t\tnormal[2] = - b->normal[2];\n\t\tdist = - b->dist;\n\t}\n\telse {\n\t\tnormal[0] = b->normal[0];\n\t\tnormal[1] = b->normal[1];\n\t\tnormal[2] = b->normal[2];\n\t\tdist = b->dist;\n\t}\n\tif (\n\t   fabs(a->normal[0] - normal[0]) < NORMAL_EPSILON\n\t&& fabs(a->normal[1] - normal[1]) < NORMAL_EPSILON\n\t&& fabs(a->normal[2] - normal[2]) < NORMAL_EPSILON\n\t&& fabs(a->dist - dist) < DIST_EPSILON )\n\t\treturn qtrue;\n\treturn qfalse;\n}\n\n/*\n=============\nVL_PlaneFromPoints\n=============\n*/\nqboolean VL_PlaneFromPoints( plane_t *plane, const vec3_t a, const vec3_t b, const vec3_t c ) {\n\tvec3_t\td1, d2;\n\n\tVectorSubtract( b, a, d1 );\n\tVectorSubtract( c, a, d2 );\n\tCrossProduct( d2, d1, plane->normal );\n\tif ( VectorNormalize( plane->normal, plane->normal ) == 0 ) {\n\t\treturn qfalse;\n\t}\n\n\tplane->dist = DotProduct( a, plane->normal );\n\treturn qtrue;\n}\n\n/*\n=====================\nVL_GenerateBoundaryForPoints\n=====================\n*/\nvoid VL_GenerateBoundaryForPoints( plane_t *boundary, plane_t *plane, vec3_t a, vec3_t b ) {\n\tvec3_t\td1;\n\n\t// make a perpendicular vector to the edge and the surface\n\tVectorSubtract( a, b, d1 );\n\tCrossProduct( plane->normal, d1, boundary->normal );\n\tVectorNormalize( boundary->normal, boundary->normal );\n\tboundary->dist = DotProduct( a, boundary->normal );\n}\n\n/*\n=====================\nVL_GenerateFacetFor3Points\n=====================\n*/\nqboolean VL_GenerateFacetFor3Points( dsurface_t *dsurf, shaderInfo_t *si, lFacet_t *f, drawVert_t *a, drawVert_t *b, drawVert_t *c ) {\n\t//\n\tvec3_t dir;\n\tint i;\n\n\t// if we can't generate a valid plane for the points, ignore the facet\n\tif ( !VL_PlaneFromPoints( &f->plane, a->xyz, b->xyz, c->xyz ) ) {\n\t\tf->numpoints = 0;\n\t\treturn qfalse;\n\t}\n\n\tf->num = numfacets++;\n\n\tVectorAdd( a->xyz, surfaceOrigin[dsurf - drawSurfaces], f->points[0] );\n\tVectorAdd( b->xyz, surfaceOrigin[dsurf - drawSurfaces], f->points[1] );\n\tVectorAdd( c->xyz, surfaceOrigin[dsurf - drawSurfaces], f->points[2] );\n\n\tf->lightmapCoords[0][0] = a->lightmap[0];\n\tf->lightmapCoords[0][1] = a->lightmap[1];\n\tf->lightmapCoords[1][0] = b->lightmap[0];\n\tf->lightmapCoords[1][1] = b->lightmap[1];\n\tf->lightmapCoords[2][0] = c->lightmap[0];\n\tf->lightmapCoords[2][1] = c->lightmap[1];\n\n\tVL_GenerateBoundaryForPoints( &f->boundaries[0], &f->plane, f->points[0], f->points[1] );\n\tVL_GenerateBoundaryForPoints( &f->boundaries[1], &f->plane, f->points[1], f->points[2] );\n\tVL_GenerateBoundaryForPoints( &f->boundaries[2], &f->plane, f->points[2], f->points[0] );\n\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tVectorSubtract(f->points[(i+1)%3], f->points[i], dir);\n\t\tif (VectorLength(dir) < 0.1)\n\t\t\treturn qfalse;\n\t}\n\n\tVL_TextureMatrixFromPoints( f, a, b, c );\n\tVL_LightmapMatrixFromPoints( dsurf, si, f, a, b, c );\n\n\tf->numpoints = 3;\n\n\treturn qtrue;\n}\n\n/*\n=====================\nVL_GenerateFacetFor4Points\n\nAttempts to use four points as a planar quad\n=====================\n*/\n#define\tPLANAR_EPSILON\t0.1\nqboolean VL_GenerateFacetFor4Points( dsurface_t *dsurf, shaderInfo_t *si, lFacet_t *f, drawVert_t *a, drawVert_t *b, drawVert_t *c, drawVert_t *d ) {\n\tfloat\tdist;\n\tvec3_t dir;\n\tint i;\n\tplane_t plane;\n\n\t// if we can't generate a valid plane for the points, ignore the facet\n\tif ( !VL_PlaneFromPoints( &f->plane, a->xyz, b->xyz, c->xyz ) ) {\n\t\tf->numpoints = 0;\n\t\treturn qfalse;\n\t}\n\n\t// if the fourth point is also on the plane, we can make a quad facet\n\tdist = DotProduct( d->xyz, f->plane.normal ) - f->plane.dist;\n\tif ( fabs( dist ) > PLANAR_EPSILON ) {\n\t\tf->numpoints = 0;\n\t\treturn qfalse;\n\t}\n\n\tVectorAdd( a->xyz, surfaceOrigin[dsurf - drawSurfaces], f->points[0] );\n\tVectorAdd( b->xyz, surfaceOrigin[dsurf - drawSurfaces], f->points[1] );\n\tVectorAdd( c->xyz, surfaceOrigin[dsurf - drawSurfaces], f->points[2] );\n\tVectorAdd( d->xyz, surfaceOrigin[dsurf - drawSurfaces], f->points[3] );\n\n\tfor (i = 1; i < 4; i++)\n\t{\n\t\tif ( !VL_PlaneFromPoints( &plane, f->points[i], f->points[(i+1) % 4], f->points[(i+2) % 4]) ) {\n\t\t\tf->numpoints = 0;\n\t\t\treturn qfalse;\n\t\t}\n\n\t\tif (!Plane_Equal(&f->plane, &plane, qfalse)) {\n\t\t\tf->numpoints = 0;\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\tf->lightmapCoords[0][0] = a->lightmap[0];\n\tf->lightmapCoords[0][1] = a->lightmap[1];\n\tf->lightmapCoords[1][0] = b->lightmap[0];\n\tf->lightmapCoords[1][1] = b->lightmap[1];\n\tf->lightmapCoords[2][0] = c->lightmap[0];\n\tf->lightmapCoords[2][1] = c->lightmap[1];\n\tf->lightmapCoords[3][0] = d->lightmap[0];\n\tf->lightmapCoords[3][1] = d->lightmap[1];\n\n\tVL_GenerateBoundaryForPoints( &f->boundaries[0], &f->plane, f->points[0], f->points[1] );\n\tVL_GenerateBoundaryForPoints( &f->boundaries[1], &f->plane, f->points[1], f->points[2] );\n\tVL_GenerateBoundaryForPoints( &f->boundaries[2], &f->plane, f->points[2], f->points[3] );\n\tVL_GenerateBoundaryForPoints( &f->boundaries[3], &f->plane, f->points[3], f->points[0] );\n\n\tfor (i = 0; i < 4; i++)\n\t{\n\t\tVectorSubtract(f->points[(i+1)%4], f->points[i], dir);\n\t\tif (VectorLength(dir) < 0.1)\n\t\t\treturn qfalse;\n\t}\n\n\tVL_TextureMatrixFromPoints( f, a, b, c );\n\tVL_LightmapMatrixFromPoints( dsurf, si, f, a, b, c );\n\n\tf->num = numfacets++;\n\tf->numpoints = 4;\n\n\treturn qtrue;\n}\n\n/*\n===============\nVL_SphereFromBounds\n===============\n*/\nvoid VL_SphereFromBounds( vec3_t mins, vec3_t maxs, vec3_t origin, float *radius ) {\n\tvec3_t\t\ttemp;\n\n\tVectorAdd( mins, maxs, origin );\n\tVectorScale( origin, 0.5, origin );\n\tVectorSubtract( maxs, origin, temp );\n\t*radius = VectorLength( temp );\n}\n\n/*\n====================\nVL_FacetsForTriangleSurface\n====================\n*/\nvoid VL_FacetsForTriangleSurface( dsurface_t *dsurf, shaderInfo_t *si, lsurfaceTest_t *test ) {\n\tint\t\t\ti;\n\tdrawVert_t\t*v1, *v2, *v3, *v4;\n\tint\t\t\tcount;\n\tint\t\t\ti1, i2, i3, i4, i5, i6;\n\n\ttest->patch = qfalse;\n\tif (dsurf->surfaceType == MST_TRIANGLE_SOUP)\n\t\ttest->trisoup = qtrue;\n\telse\n\t\ttest->trisoup = qfalse;\n\ttest->numFacets = dsurf->numIndexes / 3;\n\ttest->facets = malloc( sizeof( test->facets[0] ) * test->numFacets );\n\ttest->shader = si;\n\n\tcount = 0;\n\tfor ( i = 0 ; i < test->numFacets ; i++ ) {\n\t\ti1 = drawIndexes[ dsurf->firstIndex + i*3 ];\n\t\ti2 = drawIndexes[ dsurf->firstIndex + i*3 + 1 ];\n\t\ti3 = drawIndexes[ dsurf->firstIndex + i*3 + 2 ];\n\n\t\tv1 = &drawVerts[ dsurf->firstVert + i1 ];\n\t\tv2 = &drawVerts[ dsurf->firstVert + i2 ];\n\t\tv3 = &drawVerts[ dsurf->firstVert + i3 ];\n\n\t\t// try and make a quad out of two triangles\n\t\tif ( i != test->numFacets - 1 ) {\n\t\t\ti4 = drawIndexes[ dsurf->firstIndex + i*3 + 3 ];\n\t\t\ti5 = drawIndexes[ dsurf->firstIndex + i*3 + 4 ];\n\t\t\ti6 = drawIndexes[ dsurf->firstIndex + i*3 + 5 ];\n\t\t\tif ( i4 == i3 && i5 == i2 ) {\n\t\t\t\tv4 = &drawVerts[ dsurf->firstVert + i6 ];\n\t\t\t\tif ( VL_GenerateFacetFor4Points( dsurf, si, &test->facets[count], v1, v2, v4, v3 ) ) {\n\t\t\t\t\tcount++;\n\t\t\t\t\ti++;\t\t// skip next tri\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (VL_GenerateFacetFor3Points( dsurf, si, &test->facets[count], v1, v2, v3 )) {\n\t\t\tcount++;\n\t\t}\n\t}\t\t\n\n\t// we may have turned some pairs into quads\n\ttest->numFacets = count;\n}\n\n/*\n====================\nVL_FacetsForPatch\n====================\n*/\nvoid VL_FacetsForPatch( dsurface_t *dsurf, int surfaceNum, shaderInfo_t *si, lsurfaceTest_t *test ) {\n\tint\t\t\ti, j, x, y;\n\tdrawVert_t\t*v1, *v2, *v3, *v4;\n\tint\t\t\tcount, ssize;\n\tmesh_t\t\tmesh;\n\tmesh_t\t\t*subdivided, *detailmesh, *newmesh;\n\tint widthtable[LIGHTMAP_SIZE], heighttable[LIGHTMAP_SIZE];\n\n\tmesh.width = dsurf->patchWidth;\n\tmesh.height = dsurf->patchHeight;\n\tmesh.verts = &drawVerts[ dsurf->firstVert ];\n\n\tnewmesh = SubdivideMesh( mesh, 8, 999 );\n\tPutMeshOnCurve( *newmesh );\n\tMakeMeshNormals( *newmesh );\n\n\tsubdivided = RemoveLinearMeshColumnsRows( newmesh );\n\tFreeMesh(newmesh);\n\n\t//\tDebugNet_RemoveAllPolys();\n\t//\tDebugNet_DrawMesh(subdivided);\n\n\tssize = samplesize;\n\tif (si->lightmapSampleSize)\n\t\tssize = si->lightmapSampleSize;\n\n\tif ( dsurf->lightmapNum >= 0 ) {\n\n\t\tdetailmesh = SubdivideMeshQuads( subdivided, ssize, LIGHTMAP_SIZE, widthtable, heighttable);\n\t\ttest->detailMesh = detailmesh;\n\n\t\t// DebugNet_RemoveAllPolys();\n\t\t// DebugNet_DrawMesh(detailmesh);\n\n\t\tif ( detailmesh->width != dsurf->lightmapWidth || detailmesh->height != dsurf->lightmapHeight ) {\n\t\t\tError( \"Mesh lightmap miscount\");\n\t\t}\n\t}\n\telse {\n\t\ttest->detailMesh = NULL;\n\t\tmemset(widthtable, 0, sizeof(widthtable));\n\t\tmemset(heighttable, 0, sizeof(heighttable));\n\t}\n\n\ttest->patch = qtrue;\n\ttest->trisoup = qfalse;\n\ttest->numFacets = ( subdivided->width - 1 ) * ( subdivided->height - 1 ) * 2;\n\ttest->facets = malloc( sizeof( test->facets[0] ) * test->numFacets );\n\ttest->shader = si;\n\n\tcount = 0;\n\tx = 0;\n\tfor ( i = 0 ; i < subdivided->width - 1 ; i++ ) {\n\t\ty = 0;\n\t\tfor ( j = 0 ; j < subdivided->height - 1 ; j++ ) {\n\n\t\t\tv1 = subdivided->verts + j * subdivided->width + i;\n\t\t\tv2 = v1 + 1;\n\t\t\tv3 = v1 + subdivided->width + 1;\n\t\t\tv4 = v1 + subdivided->width;\n\n\t\t\tif ( VL_GenerateFacetFor4Points( dsurf, si, &test->facets[count], v1, v4, v3, v2 ) ) {\n\t\t\t\ttest->facets[count].x = x;\n\t\t\t\ttest->facets[count].y = y;\n\t\t\t\ttest->facets[count].width = widthtable[i];\n\t\t\t\ttest->facets[count].height = heighttable[j];\n\t\t\t\tcount++;\n\t\t\t} else {\n\t\t\t\tif (VL_GenerateFacetFor3Points( dsurf, si, &test->facets[count], v1, v4, v3 )) {\n\t\t\t\t\ttest->facets[count].x = x;\n\t\t\t\t\ttest->facets[count].y = y;\n\t\t\t\t\ttest->facets[count].width = widthtable[i];\n\t\t\t\t\ttest->facets[count].height = heighttable[j];\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t\tif (VL_GenerateFacetFor3Points( dsurf, si, &test->facets[count], v1, v3, v2 )) {\n\t\t\t\t\ttest->facets[count].x = x;\n\t\t\t\t\ttest->facets[count].y = y;\n\t\t\t\t\ttest->facets[count].width = widthtable[i];\n\t\t\t\t\ttest->facets[count].height = heighttable[j];\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\ty += heighttable[j];\n\t\t}\n\t\tx += widthtable[i];\n\t}\n\ttest->numFacets = count;\n\n\tFreeMesh(subdivided);\n}\n\n/*\n=====================\nVL_InitSurfacesForTesting\n=====================\n*/\nvoid VL_InitSurfacesForTesting( void ) {\n\n\tint\t\t\t\ti, j, k;\n\tdsurface_t\t\t*dsurf;\n\tlsurfaceTest_t\t*test;\n\tshaderInfo_t\t*si;\n\tlFacet_t\t\t*facet;\n\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ ) {\n\t\t// don't light the entity surfaces with vlight\n\t\tif ( entitySurface[i] )\n\t\t\tcontinue;\n\t\t//\n\t\tdsurf = &drawSurfaces[ i ];\n\t\tif ( !dsurf->numIndexes && !dsurf->patchWidth ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tsi = ShaderInfoForShader( dshaders[ dsurf->shaderNum].shader );\n\t\t// if the surface is translucent and does not cast an alpha shadow\n\t\tif ( (si->contents & CONTENTS_TRANSLUCENT) && !(si->surfaceFlags & SURF_ALPHASHADOW) ) {\n\t\t\t// if the surface has no lightmap\n\t\t\tif ( dsurf->lightmapNum < 0 )\n\t\t\t\tcontinue;\n\t\t}\n\n\t\ttest = malloc( sizeof( *test ) );\n\t\tmemset(test, 0, sizeof( *test ));\n\t\ttest->mutex = MutexAlloc();\n\t\ttest->numvolumes = 0;\n\t\tif (si->forceTraceLight)\n\t\t\ttest->always_tracelight = qtrue;\n\t\telse if (si->forceVLight)\n\t\t\ttest->always_vlight = qtrue;\n\t\tlsurfaceTest[i] = test;\n\n\t\tif ( dsurf->surfaceType == MST_TRIANGLE_SOUP || dsurf->surfaceType == MST_PLANAR ) {\n\t\t\tVL_FacetsForTriangleSurface( dsurf, si, test );\n\t\t} else if ( dsurf->surfaceType == MST_PATCH ) {\n\t\t\tVL_FacetsForPatch( dsurf, i, si, test );\n\t\t}\n\t\tif (numfacets >= MAX_FACETS)\n\t\t\tError(\"numfacets >= MAX_FACETS (%d)\", MAX_FACETS);\n\n\t\tClearBounds( test->mins, test->maxs );\n\t\tfor (j = 0; j < test->numFacets; j++)\n\t\t{\n\t\t\tfacet = &test->facets[j];\n\t\t\tfor ( k = 0 ; k < facet->numpoints; k++) {\n\t\t\t\tAddPointToBounds( facet->points[k], test->mins, test->maxs );\n\t\t\t}\n\t\t}\n\t\tVL_SphereFromBounds( test->mins, test->maxs, test->origin, &test->radius );\n\t}\n\t_printf(\"%6d facets\\n\", numfacets);\n\t_printf(\"linking surfaces...\\n\");\n\tVL_LinkSurfaces();\n}\n\n/*\n=============\nVL_ChopWinding\n=============\n*/\nint VL_ChopWinding (winding_t *in, plane_t *split, float epsilon)\n{\n\tvec_t\tdists[128];\n\tint\t\tsides[128];\n\tint\t\tcounts[3];\n\tvec_t\tdot;\n\tint\t\ti, j;\n\tvec_t\t*p1, *p2;\n\tvec3_t\tmid;\n\twinding_t out;\n\twinding_t\t*neww;\n\n\tcounts[0] = counts[1] = counts[2] = 0;\n\n\t// determine sides for each point\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tdot = DotProduct (in->points[i], split->normal);\n\t\tdot -= split->dist;\n\t\tdists[i] = dot;\n\t\tif (dot > epsilon)\n\t\t\tsides[i] = SIDE_FRONT;\n\t\telse if (dot < -epsilon)\n\t\t\tsides[i] = SIDE_BACK;\n\t\telse\n\t\t{\n\t\t\tsides[i] = SIDE_ON;\n\t\t}\n\t\tcounts[sides[i]]++;\n\t}\n\n\tif (!counts[SIDE_BACK])\n\t{\n\t\tif (!counts[SIDE_FRONT])\n\t\t\treturn SIDE_ON;\n\t\telse\n\t\t\treturn SIDE_FRONT;\n\t}\n\t\n\tif (!counts[SIDE_FRONT])\n\t{\n\t\treturn SIDE_BACK;\n\t}\n\n\tsides[i] = sides[0];\n\tdists[i] = dists[0];\n\t\n\tneww = &out;\n\n\tneww->numpoints = 0;\n\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tp1 = in->points[i];\n\n\t\tif (neww->numpoints >= MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\t_printf(\"WARNING: VL_ChopWinding -> MAX_POINTS_ON_FIXED_WINDING overflowed\\n\");\n\t\t\treturn SIDE_FRONT;\t\t// can't chop -- fall back to original\n\t\t}\n\n\t\tif (sides[i] == SIDE_ON)\n\t\t{\n\t\t\tVectorCopy (p1, neww->points[neww->numpoints]);\n\t\t\tneww->numpoints++;\n\t\t\tcontinue;\n\t\t}\n\t\n\t\tif (sides[i] == SIDE_FRONT)\n\t\t{\n\t\t\tVectorCopy (p1, neww->points[neww->numpoints]);\n\t\t\tneww->numpoints++;\n\t\t}\n\t\t\n\t\tif (sides[i+1] == SIDE_ON || sides[i+1] == sides[i])\n\t\t\tcontinue;\n\t\t\t\n\t\tif (neww->numpoints >= MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\t_printf(\"WARNING: VL_ChopWinding -> MAX_POINTS_ON_FIXED_WINDING overflowed\\n\");\n\t\t\treturn SIDE_FRONT;\t\t// can't chop -- fall back to original\n\t\t}\n\n\t\t// generate a split point\n\t\tp2 = in->points[(i+1)%in->numpoints];\n\t\t\n\t\tdot = dists[i] / (dists[i]-dists[i+1]);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\t// avoid round off error when possible\n\t\t\tif (split->normal[j] == 1)\n\t\t\t\tmid[j] = split->dist;\n\t\t\telse if (split->normal[j] == -1)\n\t\t\t\tmid[j] = -split->dist;\n\t\t\telse\n\t\t\t\tmid[j] = p1[j] + dot*(p2[j]-p1[j]);\n\t\t}\n\t\t\t\n\t\tVectorCopy (mid, neww->points[neww->numpoints]);\n\t\tneww->numpoints++;\n\t}\n\tmemcpy(in, &out, sizeof(winding_t));\n\t\n\treturn SIDE_CROSS;\n}\n\n/*\n=============\nVL_ChopWindingWithBrush\n\n  returns all winding fragments outside the brush\n=============\n*/\nint VL_ChopWindingWithBrush(winding_t *w, dbrush_t *brush, winding_t *outwindings, int maxout)\n{\n\tint i, res, numout;\n\twinding_t front, back;\n\tplane_t plane;\n\n\tnumout = 0;\n\tmemcpy(front.points, w->points, w->numpoints * sizeof(vec3_t));\n\tfront.numpoints = w->numpoints;\n\tfor (i = 0; i < brush->numSides; i++)\n\t{\n\t\tVectorCopy(dplanes[ dbrushsides[ brush->firstSide + i ].planeNum ].normal, plane.normal);\n\t\tVectorInverse(plane.normal);\n\t\tplane.dist = -dplanes[ dbrushsides[ brush->firstSide + i ].planeNum ].dist;\n\t\tres = VL_SplitWinding(&front, &back, &plane, 0.1);\n\t\tif (res == SIDE_BACK || res == SIDE_ON)\n\t\t{\n\t\t\tmemcpy(outwindings[0].points, w->points, w->numpoints * sizeof(vec3_t));\n\t\t\toutwindings[0].numpoints = w->numpoints;\n\t\t\treturn 1;\t//did not intersect\n\t\t}\n\t\tif (res != SIDE_FRONT)\n\t\t{\n\t\t\tif (numout >= maxout)\n\t\t\t{\n\t\t\t\t_printf(\"WARNING: VL_ChopWindingWithBrush: more than %d windings\\n\", maxout);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tmemcpy(outwindings[numout].points, back.points, back.numpoints * sizeof(vec3_t));\n\t\t\toutwindings[numout].numpoints = back.numpoints;\n\t\t\tnumout++;\n\t\t}\n\t}\n\treturn numout;\n}\n\n/*\n=============\nVL_WindingAreaOutsideBrushes\n=============\n*/\nfloat VL_WindingAreaOutsideBrushes(winding_t *w, int *brushnums, int numbrushes)\n{\n\tint i, j, numwindings[2], n;\n\twinding_t windingsbuf[2][64];\n\tdbrush_t *brush;\n\tfloat area;\n\n\tmemcpy(windingsbuf[0][0].points, w->points, w->numpoints * sizeof(vec3_t));\n\twindingsbuf[0][0].numpoints = w->numpoints;\n\tnumwindings[0] = 1;\n\tfor (i = 0; i < numbrushes; i++)\n\t{\n\t\tbrush = &dbrushes[brushnums[i]];\n\t\tif (!(dshaders[brush->shaderNum].contentFlags & (\n\t\t\t\t\tCONTENTS_LAVA\n\t\t\t\t\t| CONTENTS_SLIME\n\t\t\t\t\t| CONTENTS_WATER\n\t\t\t\t\t| CONTENTS_FOG\n\t\t\t\t\t| CONTENTS_AREAPORTAL\n\t\t\t\t\t| CONTENTS_PLAYERCLIP\n\t\t\t\t\t| CONTENTS_MONSTERCLIP\n\t\t\t\t\t| CONTENTS_CLUSTERPORTAL\n\t\t\t\t\t| CONTENTS_DONOTENTER\n\t\t\t\t\t| CONTENTS_BODY\n\t\t\t\t\t| CONTENTS_CORPSE\n\t\t\t\t\t| CONTENTS_TRANSLUCENT\n\t\t\t\t\t| CONTENTS_TRIGGER\n\t\t\t\t\t| CONTENTS_NODROP) ) &&\n\t\t\t(dshaders[brush->shaderNum].contentFlags & CONTENTS_SOLID) )\n\t\t{\n\t\t\tnumwindings[!(i & 1)] = 0;\n\t\t\tfor (j = 0; j < numwindings[i&1]; j++)\n\t\t\t{\n\t\t\t\tn = VL_ChopWindingWithBrush(&windingsbuf[i&1][j], brush,\n\t\t\t\t\t\t\t\t\t\t\t&windingsbuf[!(i&1)][numwindings[!(i&1)]],\n\t\t\t\t\t\t\t\t\t\t\t64 - numwindings[!(i&1)]);\n\t\t\t\tnumwindings[!(i&1)] += n;\n\t\t\t}\n\t\t\tif (!numwindings[!(i&1)])\n\t\t\t\treturn 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfor (j = 0; j < numwindings[i&1]; j++)\n\t\t\t{\n\t\t\t\twindingsbuf[!(i&1)][j] = windingsbuf[i&1][j];\n\t\t\t}\n\t\t\tnumwindings[!(i&1)] = numwindings[i&1];\n\t\t}\n\t}\n\tarea = 0;\n\tfor (j = 0; j < numwindings[i&1]; j++)\n\t{\n\t\tarea += WindingArea(&windingsbuf[i&1][j]);\n\t}\n\treturn area;\n}\n\n/*\n=============\nVL_R_WindingAreaOutsideSolid\n=============\n*/\nfloat VL_R_WindingAreaOutsideSolid(winding_t *w, vec3_t normal, int nodenum)\n{\n\tint leafnum, res;\n\tfloat area;\n\tdnode_t *node;\n\tdleaf_t *leaf;\n\tdplane_t *plane;\n\twinding_t back;\n\tplane_t split;\n\n\tarea = 0;\n\twhile(nodenum >= 0)\n\t{\n\t\tnode = &dnodes[nodenum];\n\t\tplane = &dplanes[node->planeNum];\n\n\t\tVectorCopy(plane->normal, split.normal);\n\t\tsplit.dist = plane->dist;\n\t\tres = VL_SplitWinding (w, &back, &split, 0.1);\n\n\t\tif (res == SIDE_FRONT)\n\t\t{\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t\telse if (res == SIDE_BACK)\n\t\t{\n\t\t\tnodenum = node->children[1];\n\t\t}\n\t\telse if (res == SIDE_ON)\n\t\t{\n\t\t\tif (DotProduct(normal, plane->normal) > 0)\n\t\t\t\tnodenum = node->children[0];\n\t\t\telse\n\t\t\t\tnodenum = node->children[1];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tarea += VL_R_WindingAreaOutsideSolid(&back, normal, node->children[1]);\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t}\n\tleafnum = -nodenum - 1;\n\tleaf = &dleafs[leafnum];\n\tif (leaf->cluster != -1)\n\t{\n\t\tarea += VL_WindingAreaOutsideBrushes(w, &dleafbrushes[leaf->firstLeafBrush], leaf->numLeafBrushes);\n\t}\n\treturn area;\n}\n\n/*\n=============\nVL_WindingAreaOutsideSolid\n=============\n*/\nfloat VL_WindingAreaOutsideSolid(winding_t *w, vec3_t normal)\n{\n\treturn VL_R_WindingAreaOutsideSolid(w, normal, 0);\n}\n\n/*\n=============\nVL_ChopWindingWithFacet\n=============\n*/\nfloat VL_ChopWindingWithFacet(winding_t *w, lFacet_t *facet)\n{\n\tint i;\n\n\tfor (i = 0; i < facet->numpoints; i++)\n\t{\n\t\tif (VL_ChopWinding(w, &facet->boundaries[i], 0) == SIDE_BACK)\n\t\t\treturn 0;\n\t}\n\tif (nostitching)\n\t\treturn WindingArea(w);\n\telse\n\t\treturn VL_WindingAreaOutsideSolid(w, facet->plane.normal);\n}\n\n/*\n=============\nVL_CalcVisibleLightmapPixelArea\n\nnice brute force ;)\n=============\n*/\nvoid VL_CalcVisibleLightmapPixelArea(void)\n{\n\tint\t\t\t\ti, j, x, y, k;\n\tdsurface_t\t\t*ds;\n\tlsurfaceTest_t\t*test;\n\tmesh_t\t\t\t*mesh;\n\twinding_t w, tmpw;\n\tfloat area;\n\n\t_printf(\"calculating visible lightmap pixel area...\\n\");\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ )\n\t{\n\t\ttest = lsurfaceTest[ i ];\n\t\tif (!test)\n\t\t\tcontinue;\n\t\tds = &drawSurfaces[ i ];\n\n\t\tif ( ds->lightmapNum < 0 )\n\t\t\tcontinue;\n\n\t\tfor (y = 0; y < ds->lightmapHeight; y++)\n\t\t{\n\t\t\tfor (x = 0; x < ds->lightmapWidth; x++)\n\t\t\t{\n\t\t\t\tif (ds->surfaceType == MST_PATCH)\n\t\t\t\t{\n\t\t\t\t\tif (y == ds->lightmapHeight-1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif (x == ds->lightmapWidth-1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tmesh = lsurfaceTest[i]->detailMesh;\n\t\t\t\t\tVectorCopy( mesh->verts[y*mesh->width+x].xyz, w.points[0]);\n\t\t\t\t\tVectorCopy( mesh->verts[(y+1)*mesh->width+x].xyz, w.points[1]);\n\t\t\t\t\tVectorCopy( mesh->verts[(y+1)*mesh->width+x+1].xyz, w.points[2]);\n\t\t\t\t\tVectorCopy( mesh->verts[y*mesh->width+x+1].xyz, w.points[3]);\n\t\t\t\t\tw.numpoints = 4;\n\t\t\t\t\tif (nostitching)\n\t\t\t\t\t\tarea = WindingArea(&w);\n\t\t\t\t\telse\n\t\t\t\t\t\tarea = VL_WindingAreaOutsideSolid(&w, mesh->verts[y*mesh->width+x].normal);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT, ds->lightmapVecs[0], w.points[0]);\n\t\t\t\t\tVectorMA(w.points[0], (float) y - LIGHTMAP_PIXELSHIFT, ds->lightmapVecs[1], w.points[0]);\n\t\t\t\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT, ds->lightmapVecs[0], w.points[3]);\n\t\t\t\t\tVectorMA(w.points[3], (float) y - LIGHTMAP_PIXELSHIFT + 1, ds->lightmapVecs[1], w.points[3]);\n\t\t\t\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT + 1, ds->lightmapVecs[0], w.points[2]);\n\t\t\t\t\tVectorMA(w.points[2], (float) y - LIGHTMAP_PIXELSHIFT + 1, ds->lightmapVecs[1], w.points[2]);\n\t\t\t\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT + 1, ds->lightmapVecs[0], w.points[1]);\n\t\t\t\t\tVectorMA(w.points[1], (float) y - LIGHTMAP_PIXELSHIFT, ds->lightmapVecs[1], w.points[1]);\n\t\t\t\t\tw.numpoints = 4;\n\t\t\t\t\tarea = 0;\n\t\t\t\t\tfor (j = 0; j < test->numFacets; j++)\n\t\t\t\t\t{\n\t\t\t\t\t\tmemcpy(&tmpw, &w, sizeof(winding_t));\n\t\t\t\t\t\tarea += VL_ChopWindingWithFacet(&tmpw, &test->facets[j]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tlightmappixelarea[k] = area;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n=============\nVL_FindAdjacentSurface\n=============\n*/\nint VL_FindAdjacentSurface(int surfaceNum, int facetNum, vec3_t p1, vec3_t p2, int *sNum, int *fNum, int *point)\n{\n\tint i, j, k;\n\tlsurfaceTest_t *test;\n\tlFacet_t *facet;\n\tdsurface_t *ds;\n\tfloat *fp1, *fp2;\n\tvec3_t dir;\n\tplane_t *facetplane;\n\t//\twinding_t w;\n\n\tfacetplane = &lsurfaceTest[surfaceNum]->facets[facetNum].plane;\n\t//\tDebugNet_RemoveAllPolys();\n\t//\tmemcpy(w.points, lsurfaceTest[surfaceNum]->facets[facetNum].points,\n\t//\t\t\tlsurfaceTest[surfaceNum]->facets[facetNum].numpoints * sizeof(vec3_t));\n\t//\tw.numpoints = lsurfaceTest[surfaceNum]->facets[facetNum].numpoints;\n\t//\tDebugNet_DrawWinding(&w, 2);\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ )\n\t{\n\t\tif (i == surfaceNum)\n\t\t\tcontinue;\n\t\ttest = lsurfaceTest[ i ];\n\t\tif (!test)\n\t\t\tcontinue;\n\t\tif (test->trisoup)// || test->patch)\n\t\t\tcontinue;\n\t\tds = &drawSurfaces[i];\n\t\tif ( ds->lightmapNum < 0 )\n\t\t\tcontinue;\n\t\t//if this surface is not even near the edge\n\t\tVectorSubtract(p1, test->origin, dir);\n\t\tif (fabs(dir[0]) > test->radius ||\n\t\t\tfabs(dir[1]) > test->radius ||\n\t\t\tfabs(dir[1]) > test->radius)\n\t\t{\n\t\t\tVectorSubtract(p2, test->origin, dir);\n\t\t\tif (fabs(dir[0]) > test->radius ||\n\t\t\t\tfabs(dir[1]) > test->radius ||\n\t\t\t\tfabs(dir[1]) > test->radius)\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\t//\n\t\tfor (j = 0; j < test->numFacets; j++)\n\t\t{\n\t\t\tfacet = &test->facets[j];\n\t\t\t//\n\t\t\t//if (!Plane_Equal(&facet->plane, facetplane, qfalse))\n\t\t\tif (DotProduct(facet->plane.normal, facetplane->normal) < 0.9)\n\t\t\t{\n\t\t\t\tif (!test->trisoup && !test->patch)\n\t\t\t\t\tbreak;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t//\n\t\t\tfor (k = 0; k < facet->numpoints; k++)\n\t\t\t{\n\t\t\t\tfp1 = facet->points[k];\n\t\t\t\tif (fabs(p2[0] - fp1[0]) < 0.1 &&\n\t\t\t\t\tfabs(p2[1] - fp1[1]) < 0.1 &&\n\t\t\t\t\tfabs(p2[2] - fp1[2]) < 0.1)\n\t\t\t\t{\n\t\t\t\t\tfp2 = facet->points[(k+1) % facet->numpoints];\n\t\t\t\t\tif (fabs(p1[0] - fp2[0]) < 0.1 &&\n\t\t\t\t\t\tfabs(p1[1] - fp2[1]) < 0.1 &&\n\t\t\t\t\t\tfabs(p1[2] - fp2[2]) < 0.1)\n\t\t\t\t\t{\n\t\t\t\t\t\t//\tmemcpy(w.points, facet->points, facet->numpoints * sizeof(vec3_t));\n\t\t\t\t\t\t//\tw.numpoints = facet->numpoints;\n\t\t\t\t\t\t//\tDebugNet_DrawWinding(&w, 1);\n\t\t\t\t\t\t*sNum = i;\n\t\t\t\t\t\t*fNum = j;\n\t\t\t\t\t\t*point = k;\n\t\t\t\t\t\treturn qtrue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t/*\n\t\t\t\telse if (fabs(p1[0] - fp1[0]) < 0.1 &&\n\t\t\t\t\tfabs(p1[1] - fp1[1]) < 0.1 &&\n\t\t\t\t\tfabs(p1[2] - fp1[2]) < 0.1)\n\t\t\t\t{\n\t\t\t\t\tfp2 = facet->points[(k+1) % facet->numpoints];\n\t\t\t\t\tif (fabs(p2[0] - fp2[0]) < 0.1 &&\n\t\t\t\t\t\tfabs(p2[1] - fp2[1]) < 0.1 &&\n\t\t\t\t\t\tfabs(p2[2] - fp2[2]) < 0.1)\n\t\t\t\t\t{\n\t\t\t\t\t\t//\tmemcpy(w.points, facet->points, facet->numpoints * sizeof(vec3_t));\n\t\t\t\t\t\t//\tw.numpoints = facet->numpoints;\n\t\t\t\t\t\t//\tDebugNet_DrawWinding(&w, 1);\n\t\t\t\t\t\t*sNum = i;\n\t\t\t\t\t\t*fNum = j;\n\t\t\t\t\t\t*point = k;\n\t\t\t\t\t\treturn qtrue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t//*/\n\t\t\t}\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n/*\n=============\nVL_SmoothenLightmapEdges\n\nthis code is used to smoothen lightmaps across surface edges\n=============\n*/\nvoid VL_SmoothenLightmapEdges(void)\n{\n\tint i, j, k, coords1[2][2];\n\tfloat coords2[2][2];\n\tint x1, y1, xinc1, yinc1, k1, k2;\n\tfloat x2, y2, xinc2, yinc2, length;\n\tint surfaceNum, facetNum, point;\n\tlsurfaceTest_t *test;\n\tlFacet_t *facet1, *facet2;\n\tdsurface_t *ds1, *ds2;\n\tfloat *p[2], s, t, *color1, *color2;\n\tvec3_t dir, cross;\n\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ )\n\t{\n\t\ttest = lsurfaceTest[ i ];\n\t\tif (!test)\n\t\t\tcontinue;\n\t\tif (test->trisoup)// || test->patch)\n\t\t\tcontinue;\n\t\tds1 = &drawSurfaces[i];\n\t\tif ( ds1->lightmapNum < 0 )\n\t\t\tcontinue;\n\t\tfor (j = 0; j < test->numFacets; j++)\n\t\t{\n\t\t\tfacet1 = &test->facets[j];\n\t\t\t//\n\t\t\tfor (k = 0; k < facet1->numpoints; k++)\n\t\t\t{\n\t\t\t\tp[0] = facet1->points[k];\n\t\t\t\tp[1] = facet1->points[(k+1)%facet1->numpoints];\n\t\t\t\t//\n\t\t\t\tcoords1[0][0] = facet1->lightmapCoords[k][0] * LIGHTMAP_SIZE;\n\t\t\t\tcoords1[0][1] = facet1->lightmapCoords[k][1] * LIGHTMAP_SIZE;\n\t\t\t\tcoords1[1][0] = facet1->lightmapCoords[(k+1)%facet1->numpoints][0] * LIGHTMAP_SIZE;\n\t\t\t\tcoords1[1][1] = facet1->lightmapCoords[(k+1)%facet1->numpoints][1] * LIGHTMAP_SIZE;\n\t\t\t\tif (coords1[0][0] >= LIGHTMAP_SIZE)\n\t\t\t\t\tcoords1[0][0] = LIGHTMAP_SIZE-1;\n\t\t\t\tif (coords1[0][1] >= LIGHTMAP_SIZE)\n\t\t\t\t\tcoords1[0][1] = LIGHTMAP_SIZE-1;\n\t\t\t\tif (coords1[1][0] >= LIGHTMAP_SIZE)\n\t\t\t\t\tcoords1[1][0] = LIGHTMAP_SIZE-1;\n\t\t\t\tif (coords1[1][1] >= LIGHTMAP_SIZE)\n\t\t\t\t\tcoords1[1][1] = LIGHTMAP_SIZE-1;\n\t\t\t\t// try one row or column further because on flat faces the lightmap can\n\t\t\t\t// extend beyond the edge\n\t\t\t\tVectorSubtract(p[1], p[0], dir);\n\t\t\t\tVectorNormalize(dir, dir);\n\t\t\t\tCrossProduct(dir, facet1->plane.normal, cross);\n\t\t\t\t//\n\t\t\t\tif (coords1[0][0] - coords1[1][0] == 0)\n\t\t\t\t{\n\t\t\t\t\ts = DotProduct( cross, facet1->lightmapMatrix[0] );\n\t\t\t\t\tcoords1[0][0] += s < 0 ? 1 : -1;\n\t\t\t\t\tcoords1[1][0] += s < 0 ? 1 : -1;\n\t\t\t\t\tif (coords1[0][0] < ds1->lightmapX || coords1[0][0] >= ds1->lightmapX + ds1->lightmapWidth)\n\t\t\t\t\t{\n\t\t\t\t\t\tcoords1[0][0] += s < 0 ? -1 : 1;\n\t\t\t\t\t\tcoords1[1][0] += s < 0 ? -1 : 1;\n\t\t\t\t\t}\n\t\t\t\t\tlength = fabs(coords1[1][1] - coords1[0][1]);\n\t\t\t\t}\n\t\t\t\telse if (coords1[0][1] - coords1[1][1] == 0)\n\t\t\t\t{\n\t\t\t\t\tt = DotProduct( cross, facet1->lightmapMatrix[1] );\n\t\t\t\t\tcoords1[0][1] += t < 0 ? 1 : -1;\n\t\t\t\t\tcoords1[1][1] += t < 0 ? 1 : -1;\n\t\t\t\t\tif (coords1[0][1] < ds1->lightmapY || coords1[0][1] >= ds1->lightmapY + ds1->lightmapHeight)\n\t\t\t\t\t{\n\t\t\t\t\t\tcoords1[0][1] += t < 0 ? -1 : 1;\n\t\t\t\t\t\tcoords1[1][1] += t < 0 ? -1 : 1;\n\t\t\t\t\t}\n\t\t\t\t\tlength = fabs(coords1[1][0] - coords1[0][0]);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t//the edge is not parallell to one of the lightmap axis\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tx1 = coords1[0][0];\n\t\t\t\ty1 = coords1[0][1];\n\t\t\t\txinc1 = coords1[1][0] - coords1[0][0];\n\t\t\t\tif (xinc1 < 0) xinc1 = -1;\n\t\t\t\tif (xinc1 > 0) xinc1 = 1;\n\t\t\t\tyinc1 = coords1[1][1] - coords1[0][1];\n\t\t\t\tif (yinc1 < 0) yinc1 = -1;\n\t\t\t\tif (yinc1 > 0) yinc1 = 1;\n\t\t\t\t// the edge should be parallell to one of the lightmap axis\n\t\t\t\tif (xinc1 != 0 && yinc1 != 0)\n\t\t\t\t\tcontinue;\n\t\t\t\t//\n\t\t\t\tif (!VL_FindAdjacentSurface(i, j, p[0], p[1], &surfaceNum, &facetNum, &point))\n\t\t\t\t\tcontinue;\n\t\t\t\t//\n\t\t\t\tds2 = &drawSurfaces[surfaceNum];\n\t\t\t\tfacet2 = &lsurfaceTest[surfaceNum]->facets[facetNum];\n\t\t\t\tcoords2[0][0] = facet2->lightmapCoords[(point+1)%facet2->numpoints][0] * LIGHTMAP_SIZE;\n\t\t\t\tcoords2[0][1] = facet2->lightmapCoords[(point+1)%facet2->numpoints][1] * LIGHTMAP_SIZE;\n\t\t\t\tcoords2[1][0] = facet2->lightmapCoords[point][0] * LIGHTMAP_SIZE;\n\t\t\t\tcoords2[1][1] = facet2->lightmapCoords[point][1] * LIGHTMAP_SIZE;\n\t\t\t\tif (coords2[0][0] >= LIGHTMAP_SIZE)\n\t\t\t\t\tcoords2[0][0] = LIGHTMAP_SIZE-1;\n\t\t\t\tif (coords2[0][1] >= LIGHTMAP_SIZE)\n\t\t\t\t\tcoords2[0][1] = LIGHTMAP_SIZE-1;\n\t\t\t\tif (coords2[1][0] >= LIGHTMAP_SIZE)\n\t\t\t\t\tcoords2[1][0] = LIGHTMAP_SIZE-1;\n\t\t\t\tif (coords2[1][1] >= LIGHTMAP_SIZE)\n\t\t\t\t\tcoords2[1][1] = LIGHTMAP_SIZE-1;\n\t\t\t\t//\n\t\t\t\tx2 = coords2[0][0];\n\t\t\t\ty2 = coords2[0][1];\n\t\t\t\txinc2 = coords2[1][0] - coords2[0][0];\n\t\t\t\tif (length)\n\t\t\t\t\txinc2 = xinc2 / length;\n\t\t\t\tyinc2 = coords2[1][1] - coords2[0][1];\n\t\t\t\tif (length)\n\t\t\t\t\tyinc2 = yinc2 / length;\n\t\t\t\t// the edge should be parallell to one of the lightmap axis\n\t\t\t\tif ((int) xinc2 != 0 && (int) yinc2 != 0)\n\t\t\t\t\tcontinue;\n\t\t\t\t//\n\t\t\t\twhile(1)\n\t\t\t\t{\n\t\t\t\t\tk1 = ( ds1->lightmapNum * LIGHTMAP_HEIGHT + y1) * LIGHTMAP_WIDTH + x1;\n\t\t\t\t\tk2 = ( ds2->lightmapNum * LIGHTMAP_HEIGHT + ((int) y2)) * LIGHTMAP_WIDTH + ((int) x2);\n\t\t\t\t\tcolor1 = lightFloats + k1*3;\n\t\t\t\t\tcolor2 = lightFloats + k2*3;\n\t\t\t\t\tif (lightmappixelarea[k1] < 0.01)\n\t\t\t\t\t{\n\t\t\t\t\t\tcolor1[0] = color2[0];\n\t\t\t\t\t\tcolor1[1] = color2[1];\n\t\t\t\t\t\tcolor1[2] = color2[2];\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tcolor1[0] = (float) color2[0] * 0.7 + (float) color1[0] * 0.3;\n\t\t\t\t\t\tcolor1[1] = (float) color2[1] * 0.7 + (float) color1[1] * 0.3;\n\t\t\t\t\t\tcolor1[2] = (float) color2[2] * 0.7 + (float) color1[2] * 0.3;\n\t\t\t\t\t}\n\t\t\t\t\t//\n\t\t\t\t\tif (x1 == coords1[1][0] &&\n\t\t\t\t\t\ty1 == coords1[1][1])\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tx1 += xinc1;\n\t\t\t\t\ty1 += yinc1;\n\t\t\t\t\tx2 += xinc2;\n\t\t\t\t\ty2 += yinc2;\n\t\t\t\t\tif (x2 < ds2->lightmapX)\n\t\t\t\t\t\tx2 = ds2->lightmapX;\n\t\t\t\t\tif (x2 >= ds2->lightmapX + ds2->lightmapWidth)\n\t\t\t\t\t\tx2 = ds2->lightmapX + ds2->lightmapWidth-1;\n\t\t\t\t\tif (y2 < ds2->lightmapY)\n\t\t\t\t\t\ty2 = ds2->lightmapY;\n\t\t\t\t\tif (y2 >= ds2->lightmapY + ds2->lightmapHeight)\n\t\t\t\t\t\ty2 = ds2->lightmapY + ds2->lightmapHeight-1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n=============\nVL_FixLightmapEdges\n=============\n*/\nvoid VL_FixLightmapEdges(void)\n{\n\tint\t\t\t\ti, j, x, y, k, foundvalue, height, width, index;\n\tint\t\t\t\tpos, top, bottom;\n\tdsurface_t\t\t*ds;\n\tlsurfaceTest_t\t*test;\n\tfloat\t\t\tcolor[3];\n\tfloat\t\t\t*ptr;\n\tbyte filled[(LIGHTMAP_SIZE+1) * (LIGHTMAP_SIZE+1) / 8];\n\tfloat lightmap_edge_epsilon;\n\n\tlightmap_edge_epsilon = 0.1 * samplesize;\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ )\n\t{\n\t\ttest = lsurfaceTest[ i ];\n\t\tif (!test)\n\t\t\tcontinue;\n\t\tds = &drawSurfaces[ i ];\n\n\t\tif ( ds->lightmapNum < 0 )\n\t\t\tcontinue;\n\t\tif (ds->surfaceType == MST_PATCH)\n\t\t{\n\t\t\theight = ds->lightmapHeight - 1;\n\t\t\twidth = ds->lightmapWidth - 1;\n\t\t}\n\t\telse\n\t\t{\n\t\t\theight = ds->lightmapHeight;\n\t\t\twidth = ds->lightmapWidth;\n\t\t}\n\t\tmemset(filled, 0, sizeof(filled));\n//\t\tprintf(\"\\n\");\n\t\tfor (x = 0; x < width; x++)\n\t\t{\n\t\t\tfor (y = 0; y < height; y++)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tif (lightmappixelarea[k] > lightmap_edge_epsilon)\n\t\t\t\t{\n\t\t\t\t\tindex = (ds->lightmapY + y) * LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\t\tfilled[index >> 3] |= 1 << (index & 7);\n//\t\t\t\t\tprintf(\"*\");\n\t\t\t\t}\n//\t\t\t\telse\n//\t\t\t\t\tprintf(\"_\");\n\t\t\t}\n//\t\t\tprintf(\"\\n\");\n\t\t}\n\t\tfor (y = 0; y < height; y++)\n\t\t{\n\t\t\tpos = -2;\n\t\t\tfor (x = 0; x < width; x++)\n\t\t\t{\n\t\t\t\tindex = (ds->lightmapY + y) * LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tif (pos == -2)\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t\tpos = -1;\n\t\t\t\t}\n\t\t\t\telse if (pos == -1)\n\t\t\t\t{\n\t\t\t\t\tif (!(filled[index >> 3] & (1 << (index & 7))))\n\t\t\t\t\t\tpos = x - 1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t{\n\t\t\t\t\t\tbottom = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + pos;\n\t\t\t\t\t\ttop = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\t\t\tfor (j = 0; j < (x - pos + 1) / 2; j++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + pos + j + 1;\n\t\t\t\t\t\t\tindex = (ds->lightmapY + y) * LIGHTMAP_WIDTH + ds->lightmapX + pos + j + 1;\n\t\t\t\t\t\t\tfilled[index >> 3] |= 1 << (index & 7);\n\t\t\t\t\t\t\t(lightFloats + k*3)[0] = (lightFloats + top*3)[0];\n\t\t\t\t\t\t\t(lightFloats + k*3)[1] = (lightFloats + top*3)[1];\n\t\t\t\t\t\t\t(lightFloats + k*3)[2] = (lightFloats + top*3)[2];\n\t\t\t\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x - j - 1;\n\t\t\t\t\t\t\tindex = (ds->lightmapY + y) * LIGHTMAP_WIDTH + ds->lightmapX + x - j - 1;\n\t\t\t\t\t\t\tfilled[index >> 3] |= 1 << (index & 7);\n\t\t\t\t\t\t\t(lightFloats + k*3)[0] = (lightFloats + bottom*3)[0];\n\t\t\t\t\t\t\t(lightFloats + k*3)[1] = (lightFloats + bottom*3)[1];\n\t\t\t\t\t\t\t(lightFloats + k*3)[2] = (lightFloats + bottom*3)[2];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpos = -1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (x = 0; x < width; x++)\n\t\t{\n\t\t\tpos = -2;\n\t\t\tfor (y = 0; y < height; y++)\n\t\t\t{\n\t\t\t\tindex = (ds->lightmapY + y) * LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tif (pos == -2)\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t\tpos = -1;\n\t\t\t\t}\n\t\t\t\telse if (pos == -1)\n\t\t\t\t{\n\t\t\t\t\tif (!(filled[index >> 3] & (1 << (index & 7))))\n\t\t\t\t\t\tpos = y - 1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t{\n\t\t\t\t\t\tbottom = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + pos)\n\t\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\t\t\ttop = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\t\t\tfor (j = 0; j < (y - pos + 1) / 2; j++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + pos + j + 1)\n\t\t\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\t\t\t\tindex = (ds->lightmapY + pos + j + 1) * LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\t\t\t\tfilled[index >> 3] |= 1 << (index & 7);\n\t\t\t\t\t\t\t(lightFloats + k*3)[0] = (lightFloats + top*3)[0];\n\t\t\t\t\t\t\t(lightFloats + k*3)[1] = (lightFloats + top*3)[1];\n\t\t\t\t\t\t\t(lightFloats + k*3)[2] = (lightFloats + top*3)[2];\n\t\t\t\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y - j - 1)\n\t\t\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\t\t\t\tindex = (ds->lightmapY + y - j - 1) * LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\t\t\t\tfilled[index >> 3] |= 1 << (index & 7);\n\t\t\t\t\t\t\t(lightFloats + k*3)[0] = (lightFloats + bottom*3)[0];\n\t\t\t\t\t\t\t(lightFloats + k*3)[1] = (lightFloats + bottom*3)[1];\n\t\t\t\t\t\t\t(lightFloats + k*3)[2] = (lightFloats + bottom*3)[2];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpos = -1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (y = 0; y < height; y++)\n\t\t{\n\t\t\tfoundvalue = qfalse;\n\t\t\tfor (x = 0; x < width; x++)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tindex = (ds->lightmapY + y) * LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tif (foundvalue)\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tcolor[0] = ptr[0];\n\t\t\t\t\t\tcolor[1] = ptr[1];\n\t\t\t\t\t\tcolor[2] = ptr[2];\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tptr[0] = color[0];\n\t\t\t\t\t\tptr[1] = color[1];\n\t\t\t\t\t\tptr[2] = color[2];\n\t\t\t\t\t\tfilled[index >> 3] |= 1 << (index & 7);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tcolor[0] = ptr[0];\n\t\t\t\t\t\tcolor[1] = ptr[1];\n\t\t\t\t\t\tcolor[2] = ptr[2];\n\t\t\t\t\t\tfoundvalue = qtrue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfoundvalue = qfalse;\n\t\t\tfor (x = width-1; x >= 0; x--)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tindex = (ds->lightmapY + y) * LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tif (foundvalue)\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tcolor[0] = ptr[0];\n\t\t\t\t\t\tcolor[1] = ptr[1];\n\t\t\t\t\t\tcolor[2] = ptr[2];\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tptr[0] = color[0];\n\t\t\t\t\t\tptr[1] = color[1];\n\t\t\t\t\t\tptr[2] = color[2];\n\t\t\t\t\t\tfilled[index >> 3] |= 1 << (index & 7);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tcolor[0] = ptr[0];\n\t\t\t\t\t\tcolor[1] = ptr[1];\n\t\t\t\t\t\tcolor[2] = ptr[2];\n\t\t\t\t\t\tfoundvalue = qtrue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (x = 0; x < width; x++)\n\t\t{\n\t\t\tfoundvalue = qfalse;\n\t\t\tfor (y = 0; y < height; y++)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tindex = (ds->lightmapY + y) * LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tif (foundvalue)\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tcolor[0] = ptr[0];\n\t\t\t\t\t\tcolor[1] = ptr[1];\n\t\t\t\t\t\tcolor[2] = ptr[2];\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tptr[0] = color[0];\n\t\t\t\t\t\tptr[1] = color[1];\n\t\t\t\t\t\tptr[2] = color[2];\n\t\t\t\t\t\tfilled[index >> 3] |= 1 << (index & 7);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tcolor[0] = ptr[0];\n\t\t\t\t\t\tcolor[1] = ptr[1];\n\t\t\t\t\t\tcolor[2] = ptr[2];\n\t\t\t\t\t\tfoundvalue = qtrue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfoundvalue = qfalse;\n\t\t\tfor (y = height-1; y >= 0; y--)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tindex = (ds->lightmapY + y) * LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tif (foundvalue)\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tcolor[0] = ptr[0];\n\t\t\t\t\t\tcolor[1] = ptr[1];\n\t\t\t\t\t\tcolor[2] = ptr[2];\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tptr[0] = color[0];\n\t\t\t\t\t\tptr[1] = color[1];\n\t\t\t\t\t\tptr[2] = color[2];\n\t\t\t\t\t\tfilled[index >> 3] |= 1 << (index & 7);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tcolor[0] = ptr[0];\n\t\t\t\t\t\tcolor[1] = ptr[1];\n\t\t\t\t\t\tcolor[2] = ptr[2];\n\t\t\t\t\t\tfoundvalue = qtrue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (ds->surfaceType == MST_PATCH)\n\t\t{\n\t\t\tx = ds->lightmapWidth-1;\n\t\t\tfor (y = 0; y < ds->lightmapHeight; y++)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\tptr[0] = (lightFloats + (k-1)*3)[0];\n\t\t\t\tptr[1] = (lightFloats + (k-1)*3)[1];\n\t\t\t\tptr[2] = (lightFloats + (k-1)*3)[2];\n\t\t\t}\n\t\t\ty = ds->lightmapHeight-1;\n\t\t\tfor (x = 0; x < ds->lightmapWidth; x++)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\tptr[0] = (lightFloats + (k-LIGHTMAP_WIDTH)*3)[0];\n\t\t\t\tptr[1] = (lightFloats + (k-LIGHTMAP_WIDTH)*3)[1];\n\t\t\t\tptr[2] = (lightFloats + (k-LIGHTMAP_WIDTH)*3)[2];\n\t\t\t}\n\t\t}\n\t\t/*\n\t\t//colored debug edges\n\t\tif (ds->surfaceType == MST_PATCH)\n\t\t{\n\t\t\tx = ds->lightmapWidth-1;\n\t\t\tfor (y = 0; y < ds->lightmapHeight; y++)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\tptr[0] = 255;\n\t\t\t\tptr[1] = 0;\n\t\t\t\tptr[2] = 0;\n\t\t\t}\n\t\t\ty = ds->lightmapHeight-1;\n\t\t\tfor (x = 0; x < ds->lightmapWidth; x++)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\tptr[0] = 0;\n\t\t\t\tptr[1] = 255;\n\t\t\t\tptr[2] = 0;\n\t\t\t}\n\t\t}\n\t\t//*/\n\t}\n\t//\n\tVL_SmoothenLightmapEdges();\n}\n\n/*\n=============\nVL_ShiftPatchLightmaps\n=============\n*/\nvoid VL_ShiftPatchLightmaps(void)\n{\n\tint\t\t\t\ti, j, x, y, k;\n\tdrawVert_t\t\t*verts;\n\tdsurface_t\t\t*ds;\n\tlsurfaceTest_t\t*test;\n\tfloat\t\t\t*ptr;\n\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ )\n\t{\n\t\ttest = lsurfaceTest[ i ];\n\t\tif (!test)\n\t\t\tcontinue;\n\t\tds = &drawSurfaces[ i ];\n\n\t\tif ( ds->lightmapNum < 0 )\n\t\t\tcontinue;\n\t\tif (ds->surfaceType != MST_PATCH)\n\t\t\tcontinue;\n\t\tfor (x = ds->lightmapWidth; x > 0; x--)\n\t\t{\n\t\t\tfor (y = 0; y <= ds->lightmapHeight; y++)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\tptr[0] = (lightFloats + (k-1)*3)[0];\n\t\t\t\tptr[1] = (lightFloats + (k-1)*3)[1];\n\t\t\t\tptr[2] = (lightFloats + (k-1)*3)[2];\n\t\t\t}\n\t\t}\n\t\tfor (y = ds->lightmapHeight; y > 0; y--)\n\t\t{\n\t\t\tfor (x = 0; x <= ds->lightmapWidth; x++)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\tptr[0] = (lightFloats + (k-LIGHTMAP_WIDTH)*3)[0];\n\t\t\t\tptr[1] = (lightFloats + (k-LIGHTMAP_WIDTH)*3)[1];\n\t\t\t\tptr[2] = (lightFloats + (k-LIGHTMAP_WIDTH)*3)[2];\n\t\t\t}\n\t\t}\n\t\tverts = &drawVerts[ ds->firstVert ];\n\t\tfor ( j = 0 ; j < ds->patchHeight * ds->patchWidth; j++ )\n\t\t{\n\t\t\tverts[j].lightmap[0] += 0.5 / LIGHTMAP_WIDTH;\n\t\t\tverts[j].lightmap[1] += 0.5 / LIGHTMAP_HEIGHT;\n\t\t}\n\t\tds->lightmapHeight++;\n\t\tds->lightmapWidth++;\n\t}\n}\n\n/*\n=============\nVL_StoreLightmap\n=============\n*/\nvoid VL_StoreLightmap(void)\n{\n\tint\t\t\t\ti, x, y, k;\n\tdsurface_t\t\t*ds;\n\tlsurfaceTest_t\t*test;\n\tfloat\t\t\t*src;\n\tbyte\t\t\t*dst;\n\n\t_printf(\"storing lightmaps...\\n\");\n\t//fix lightmap edges before storing them\n\tVL_FixLightmapEdges();\n\t//\n#ifdef LIGHTMAP_PATCHSHIFT\n\tVL_ShiftPatchLightmaps();\n#endif\n\t//\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ )\n\t{\n\t\ttest = lsurfaceTest[ i ];\n\t\tif (!test)\n\t\t\tcontinue;\n\t\tds = &drawSurfaces[ i ];\n\n\t\tif ( ds->lightmapNum < 0 )\n\t\t\tcontinue;\n\n\t\tfor (y = 0; y < ds->lightmapHeight; y++)\n\t\t{\n\t\t\tfor (x = 0; x < ds->lightmapWidth; x++)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tVectorAdd((lightFloats + k*3), lightAmbientColor, (lightFloats + k*3));\n\t\t\t\tsrc = &lightFloats[k*3];\n\t\t\t\tdst = lightBytes + k*3;\n\t\t\t\tColorToBytes(src, dst);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n=============\nPointInLeafnum\n=============\n*/\nint\tPointInLeafnum(vec3_t point)\n{\n\tint\t\tnodenum;\n\tvec_t\tdist;\n\tdnode_t\t*node;\n\tdplane_t\t*plane;\n\n\tnodenum = 0;\n\twhile (nodenum >= 0)\n\t{\n\t\tnode = &dnodes[nodenum];\n\t\tplane = &dplanes[node->planeNum];\n\t\tdist = DotProduct (point, plane->normal) - plane->dist;\n\t\tif (dist > 0)\n\t\t\tnodenum = node->children[0];\n\t\telse\n\t\t\tnodenum = node->children[1];\n\t}\n\n\treturn -nodenum - 1;\n}\n\n/*\n=============\nVL_PointInLeafnum_r\n=============\n*/\nint\tVL_PointInLeafnum_r(vec3_t point, int nodenum)\n{\n\tint leafnum;\n\tvec_t\tdist;\n\tdnode_t\t*node;\n\tdplane_t\t*plane;\n\n\twhile (nodenum >= 0)\n\t{\n\t\tnode = &dnodes[nodenum];\n\t\tplane = &dplanes[node->planeNum];\n\t\tdist = DotProduct (point, plane->normal) - plane->dist;\n\t\tif (dist > 0.1)\n\t\t{\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t\telse if (dist < -0.1)\n\t\t{\n\t\t\tnodenum = node->children[1];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tleafnum = VL_PointInLeafnum_r(point, node->children[0]);\n\t\t\tif (dleafs[leafnum].cluster != -1)\n\t\t\t\treturn leafnum;\n\t\t\tnodenum = node->children[1];\n\t\t}\n\t}\n\n\tleafnum = -nodenum - 1;\n\treturn leafnum;\n}\n\n/*\n=============\nVL_PointInLeafnum\n=============\n*/\nint\tVL_PointInLeafnum(vec3_t point)\n{\n\treturn VL_PointInLeafnum_r(point, 0);\n}\n\n/*\n=============\nVL_LightLeafnum\n=============\n*/\nint VL_LightLeafnum(vec3_t point)\n{\n\t/*\n\tint leafnum;\n\tdleaf_t *leaf;\n\tfloat x, y, z;\n\tvec3_t test;\n\n\tleafnum = VL_PointInLeafnum(point);\n\tleaf = &dleafs[leafnum];\n\tif (leaf->cluster != -1)\n\t\treturn leafnum;\n\tfor (z = 1; z >= -1; z -= 1)\n\t{\n\t\tfor (x = 1; x >= -1; x -= 1)\n\t\t{\n\t\t\tfor (y = 1; y >= -1; y -= 1)\n\t\t\t{\n\t\t\t\tVectorCopy(point, test);\n\t\t\t\ttest[0] += x;\n\t\t\t\ttest[1] += y;\n\t\t\t\ttest[2] += z;\n\t\t\t\tleafnum = VL_PointInLeafnum(test);\n\t\t\t\tleaf = &dleafs[leafnum];\n\t\t\t\tif (leaf->cluster != -1)\n\t\t\t\t{\n\t\t\t\t\tVectorCopy(test, point);\n\t\t\t\t\treturn leafnum;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn leafnum;\n\t*/\n\treturn VL_PointInLeafnum(point);\n}\n\n//#define LIGHTPOLYS\n\n#ifdef LIGHTPOLYS\n\nwinding_t *lightwindings[MAX_MAP_DRAW_SURFS];\nint numlightwindings;\n\n/*\n=============\nVL_DrawLightWindings\n=============\n*/\nvoid VL_DrawLightWindings(void)\n{\n\tint i;\n\tfor (i = 0; i < numlightwindings; i++)\n\t{\n#ifdef DEBUGNET\n\t\tDebugNet_DrawWinding(lightwindings[i], 1);\n#endif\n\t}\n}\n\n/*\n=============\nVL_LightSurfaceWithVolume\n=============\n*/\nvoid VL_LightSurfaceWithVolume(int surfaceNum, int facetNum, vlight_t *light, lightvolume_t *volume)\n{\n\twinding_t *w;\n\tlsurfaceTest_t *test;\n\tlFacet_t *facet;\n\tint i;\n\n\ttest = lsurfaceTest[ surfaceNum ];\n\tfacet = &test->facets[ facetNum ];\n\n\t//\n\tw = (winding_t *) malloc(sizeof(winding_t));\n\tmemcpy(w->points, facet->points, sizeof(vec3_t) * facet->numpoints);\n\tw->numpoints = facet->numpoints;\n\n\tfor (i = 0; i < volume->numplanes; i++)\n\t{\n\t\t//if totally on the back\n\t\tif (VL_ChopWinding(w, &volume->planes[i], 0.01) == SIDE_BACK)\n\t\t\treturn;\n\t}\n\tlightwindings[numlightwindings] = w;\n\tnumlightwindings++;\n\tif (numlightwindings >= MAX_MAP_DRAW_SURFS)\n\t\tError(\"MAX_LIGHTWINDINGS\");\n}\n\n#else\n\n/*\n=============\nVL_LightSurfaceWithVolume\n=============\n*/\n/*\nint VL_PointInsideLightVolume(vec3_t point, lightvolume_t *volume)\n{\n\tint i;\n\tfloat d;\n\n\tfor (i = 0; i < volume->numplanes; i++)\n\t{\n\t\td = DotProduct(volume->planes[i].normal, point) - volume->planes[i].dist;\n\t\tif (d < 0) return qfalse;\n\t}\n\treturn qtrue;\n}\n\nvoid VL_LightSurfaceWithVolume( int surfaceNum, int facetNum, vlight_t *light, lightvolume_t *volume )\n{\n\tdsurface_t\t*ds;\n\tint\t\t\ti, j, k;\n\tint\t\t\tnumPositions;\n\tvec3_t\t\tbase, normal, color;\n\tint\t\t\tsampleWidth, sampleHeight;\n\tvec3_t\t\tlightmapOrigin, lightmapVecs[2], dir;\n\tunsigned char *ptr;\n\tfloat add, dist, angle;\n\tmesh_t * mesh;\n\n\tds = &drawSurfaces[surfaceNum];\n\n\t// vertex-lit triangle model\n\tif ( ds->surfaceType == MST_TRIANGLE_SOUP ) {\n\t\treturn;\n\t}\n\t\n\tif ( ds->lightmapNum < 0 ) {\n\t\treturn;\t\t// doesn't need lighting\n\t}\n\n\tif ( ds->surfaceType == MST_PATCH ) {\n\t\tmesh = lsurfaceTest[surfaceNum]->detailMesh;\n\t} else {\n\t\tVectorCopy( ds->lightmapVecs[2], normal );\n\n\t\tVectorCopy( ds->lightmapOrigin, lightmapOrigin );\n\t\tVectorCopy( ds->lightmapVecs[0], lightmapVecs[0] );\n\t\tVectorCopy( ds->lightmapVecs[1], lightmapVecs[1] );\n\t}\n\n\tsampleWidth = ds->lightmapWidth;\n\tsampleHeight = ds->lightmapHeight;\n\n\t//calculate lightmap\n\tfor ( i = 0 ; i < sampleWidth; i++ ) {\n\t\tfor ( j = 0 ; j < sampleHeight; j++ ) {\n\n\t\t\tif ( ds->patchWidth ) {\n\t\t\t\tnumPositions = 9;\n\t\t\t\tVectorCopy( mesh->verts[j*mesh->width+i].normal, normal );\n\t\t\t\t// VectorNormalize( normal, normal );\n\t\t\t\t// push off of the curve a bit\n\t\t\t\tVectorMA( mesh->verts[j*mesh->width+i].xyz, 1, normal, base );\n\n//\t\t\t\tMakeNormalVectors( normal, lightmapVecs[0], lightmapVecs[1] );\n\t\t\t} else {\n\t\t\t\tnumPositions = 9;\n\t\t\t\tfor ( k = 0 ; k < 3 ; k++ ) {\n\t\t\t\t\tbase[k] = lightmapOrigin[k] + normal[k]\n\t\t\t\t\t\t\t\t+ ((float) i) * lightmapVecs[0][k]\n\t\t\t\t\t\t\t\t+ ((float) j) * lightmapVecs[1][k];\n\t\t\t\t}\n\t\t\t}\n\t\t\tVectorAdd( base, surfaceOrigin[ surfaceNum ], base );\n\n\t\t\tVectorSubtract(base, light->origin, dir);\n\t\t\tdist = VectorNormalize(dir, dir);\n\t\t\tif ( dist < 16 ) {\n\t\t\t\tdist = 16;\n\t\t\t}\n\t\t\tangle = 1;//DotProduct( normal, dir ); //1;\n\t\t\tif (angle > 1)\n\t\t\t\tangle = 1;\n\t\t\tif ( light->atten_disttype == LDAT_LINEAR ) {\n\t\t\t\tadd = angle * light->photons * lightLinearScale - dist;\n\t\t\t\tif ( add < 0 ) {\n\t\t\t\t\tadd = 0;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tadd = light->photons / ( dist * dist ) * angle;\n\t\t\t}\n\t\t\tif (add <= 1.0)\n\t\t\t\tcontinue;\n\n\t\t\tif (VL_PointInsideLightVolume(base, volume))\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + j) \n\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + i;\n\t\t\t\tptr = lightBytes + k*3;\n\t\t\t\tcolor[0] = (float) ptr[0] + add * light->color[0];\n\t\t\t\tcolor[1] = (float) ptr[1] + add * light->color[1];\n\t\t\t\tcolor[2] = (float) ptr[2] + add * light->color[2];\n\t\t\t\tColorToBytes(color, ptr);\n\t\t\t}\n\t\t}\n\t}\n}\n*/\n\n/*\n=============\nVL_GetFilter\n\nFIXME:  don't use a lightmap pixel origin but use the four corner points\n\t\tto map part of a translucent surface onto the lightmap pixel\n=============\n*/\nvoid VL_GetFilter(vlight_t *light, lightvolume_t *volume, vec3_t lmp, vec3_t filter)\n{\n\tlFacet_t *facet;\n\tlsurfaceTest_t *test;\n\tfloat d, d1, d2, frac, s, t, ns;\n\tint i, j, is, it, b;\n\tint x, y, u, v, numsamples, radius, color[4], largest;\n\tbyte *image;\n\tvec3_t point, origin, total;\n\n\tVectorSet(filter, 1, 1, 1);\n\n\tif (noalphashading)\n\t\treturn;\n\n\tif (volume->numtransFacets <= 0)\n\t\treturn;\n\n\tif (light->type == LIGHT_SURFACEDIRECTED)\n\t{\n\t\t// project the light map pixel origin onto the area light source plane\n\t\td = DotProduct(lmp, light->normal) - DotProduct(light->normal, light->w.points[0]);\n\t\tVectorMA(lmp, -d, light->normal, origin);\n\t}\n\telse\n\t{\n\t\tVectorCopy(light->origin, origin);\n\t}\n\tfor (i = 0; i < volume->numtransFacets; i++)\n\t{\n\t\ttest = lsurfaceTest[ volume->transSurfaces[i] ];\n\t\tfacet = &test->facets[ volume->transFacets[i] ];\n\t\t// if this surface does not cast an alpha shadow\n\t\tif ( !(test->shader->surfaceFlags & SURF_ALPHASHADOW) )\n\t\t\tcontinue;\n\t\t// if there are no texture pixel available\n\t\tif ( !test->shader->pixels ) {\n\t\t\tcontinue;\n\t\t}\n\t\t//\n\t\td1 = DotProduct( origin, facet->plane.normal) - facet->plane.dist;\n\t\td2 = DotProduct( lmp, facet->plane.normal ) - facet->plane.dist;\n\t\t// this should never happen because the light volume went through the facet\n\t\tif ( ( d1 < 0 ) == ( d2 < 0 ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// calculate the crossing point\n\t\tfrac = d1 / ( d1 - d2 );\n\n\t\tfor ( j = 0 ; j < 3 ; j++ ) {\n\t\t\tpoint[j] = origin[j] + frac * ( lmp[j] - origin[j] );\n\t\t}\n\n\t\ts = DotProduct( point, facet->textureMatrix[0] ) + facet->textureMatrix[0][3];\n\t\tt = DotProduct( point, facet->textureMatrix[1] ) + facet->textureMatrix[1][3];\n\t\tif (s < 0)\n\t\t\ts = 0;\n\t\tif (t < 0)\n\t\t\tt = 0;\n\n\t\ts = s - floor( s );\n\t\tt = t - floor( t );\n\n\t\tis = s * test->shader->width;\n\t\tit = t * test->shader->height;\n\n\t\t//if old style alpha shading\n\t\tif (nocolorshading) {\n\t\t\timage = test->shader->pixels + 4 * ( it * test->shader->width + is );\n\n\t\t\t// alpha filter\n\t\t\tb = image[3];\n\n\t\t\t// alpha test makes this a binary option\n\t\t\tb = b < 128 ? 0 : 255;\n\n\t\t\tfilter[0] = filter[0] * (255-b) / 255;\n\t\t\tfilter[1] = filter[1] * (255-b) / 255;\n\t\t\tfilter[2] = filter[2] * (255-b) / 255;\n\t\t}\n\t\telse {\n\t\t\tVectorClear(total);\n\t\t\tnumsamples = 0;\n\t\t\tradius = 2;\n\t\t\tfor ( u = -radius; u <= radius; u++ )\n\t\t\t{\n\t\t\t\tx = is + u;\n\t\t\t\tif ( x < 0 || x >= test->shader->width)\n\t\t\t\t\tcontinue;\n\t\t\t\tfor ( v = -radius; v <= radius; v++ )\n\t\t\t\t{\n\t\t\t\t\ty = it + v;\n\t\t\t\t\tif ( y < 0 || y >= test->shader->height)\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\timage = test->shader->pixels + 4 * ( y * test->shader->width + x );\n\t\t\t\t\tcolor[0] = image[0];\n\t\t\t\t\tcolor[1] = image[1];\n\t\t\t\t\tcolor[2] = image[2];\n\t\t\t\t\tlargest = 0;\n\t\t\t\t\tfor (j = 0; j < 3; j++)\n\t\t\t\t\t\tif (image[j] > largest)\n\t\t\t\t\t\t\tlargest = image[j];\n\t\t\t\t\tif (largest <= 0 || image[3] == 0) {\n\t\t\t\t\t\tcolor[0] = 255;\n\t\t\t\t\t\tcolor[1] = 255;\n\t\t\t\t\t\tcolor[2] = 255;\n\t\t\t\t\t\tlargest = 255;\n\t\t\t\t\t}\n\t\t\t\t\ttotal[0] += ((float) color[0]/largest) * (255-image[3]) / 255.0;\n\t\t\t\t\ttotal[1] += ((float) color[1]/largest) * (255-image[3]) / 255.0;\n\t\t\t\t\ttotal[2] += ((float) color[2]/largest) * (255-image[3]) / 255.0;\n\t\t\t\t\tnumsamples++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tns = numsamples;\n\t\t\t//\n\t\t\tfilter[0] *= total[0] / ns;\n\t\t\tfilter[1] *= total[1] / ns;\n\t\t\tfilter[2] *= total[2] / ns;\n\t\t}\n\t}\n}\n\n/*\n=============\nVL_LightSurfaceWithVolume\n=============\n*/\nvoid VL_LightSurfaceWithVolume( int surfaceNum, int facetNum, vlight_t *light, lightvolume_t *volume )\n{\n\tint i;\n\tdsurface_t\t*ds;\n\tlFacet_t *facet;\n\tlsurfaceTest_t *test;\n\twinding_t w;\n\tvec3_t base, dir, delta, normal, filter, origin;\n\tint min_x[LIGHTMAP_SIZE+2], max_x[LIGHTMAP_SIZE+2];\n\tint min_y, max_y, k, x, y, n;\n\tfloat *color, distscale;\n\tfloat d, add, angle, dist, area, insidearea, coords[MAX_POINTS_ON_WINDING+1][2];\n\tmesh_t *mesh;\n\tbyte polygonedges[(LIGHTMAP_SIZE+1) * (LIGHTMAP_SIZE+1) / 8];\n\n\n\tds = &drawSurfaces[surfaceNum];\n\n\t// vertex-lit triangle model\n\tif ( ds->surfaceType == MST_TRIANGLE_SOUP ) {\n\t\treturn;\n\t}\n\t\n\tif ( ds->lightmapNum < 0 ) {\n\t\treturn;\t\t// doesn't need lighting\n\t}\n\n\ttest = lsurfaceTest[ surfaceNum ];\n\tfacet = &test->facets[ facetNum ];\n\n\tif (defaulttracelight && !test->always_vlight)\n\t\treturn;\n\tif (test->always_tracelight)\n\t\treturn;\n\n\tmemcpy(w.points, facet->points, sizeof(vec3_t) * facet->numpoints);\n\tw.numpoints = facet->numpoints;\n\n\tfor (i = 0; i < volume->numplanes; i++)\n\t{\n\t\t//if totally on the back\n\t\tif (VL_ChopWinding(&w, &volume->planes[i], 0.01) == SIDE_BACK)\n\t\t\treturn;\n\t}\n\n\t// only one thread at a time may write to the lightmap of this surface\n\tMutexLock(test->mutex);\n\n\ttest->numvolumes++;\n\n\tif (ds->surfaceType == MST_PATCH)\n\t{\n\t\t// FIXME: reduce size and don't mark all as edge\n\t\tmin_y = ds->lightmapY + facet->y;\n\t\tmax_y = ds->lightmapY + facet->y + facet->height - 1;\n\t\tfor (y = min_y; y <= max_y; y++)\n\t\t{\n\t\t\tmin_x[y] = ds->lightmapX + facet->x;\n\t\t\tmax_x[y] = ds->lightmapX + facet->x + facet->width - 1;\n\t\t\tfor (x = min_x[y]; x <= max_x[y]; x++)\n\t\t\t{\n\t\t\t\tn = y * LIGHTMAP_SIZE + x;\n\t\t\t\tpolygonedges[n >> 3] |= 1 << (n & 7);\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tfor (i = 0; i < w.numpoints; i++)\n\t\t{\n\t\t\tfloat\ts, t;\n\n\t\t\tif (i >= MAX_POINTS_ON_WINDING)\n\t\t\t\t_printf(\"coords overflow\\n\");\n\t\t\tif (ds->surfaceType != MST_PATCH)\n\t\t\t{\n\t\t\t\tVectorSubtract(w.points[i], facet->mins, delta);\n\t\t\t\ts = DotProduct( delta, facet->lightmapMatrix[0] ) + ds->lightmapX + 0.5;\n\t\t\t\tt = DotProduct( delta, facet->lightmapMatrix[1] ) + ds->lightmapY + 0.5;\n\t\t\t\tif (s >= LIGHTMAP_SIZE)\n\t\t\t\t\ts = LIGHTMAP_SIZE - 0.5;\n\t\t\t\tif (s < 0)\n\t\t\t\t\ts = 0;\n\t\t\t\tif (t >= LIGHTMAP_SIZE)\n\t\t\t\t\tt = LIGHTMAP_SIZE - 0.5;\n\t\t\t\tif (t < 0)\n\t\t\t\t\tt = 0;\n\t\t\t\tcoords[i][0] = s;\n\t\t\t\tcoords[i][1] = t;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ts = DotProduct( w.points[i], facet->lightmapMatrix[0] ) + facet->lightmapMatrix[0][3];\n\t\t\t\tt = DotProduct( w.points[i], facet->lightmapMatrix[1] ) + facet->lightmapMatrix[1][3];\n\n\t\t\t\ts = s - floor( s );\n\t\t\t\tt = t - floor( t );\n\n\t\t\t\tcoords[i][0] = ds->lightmapX + s * LIGHTMAP_SIZE;// + 0.5;\n\t\t\t\tcoords[i][1] = ds->lightmapY + t * LIGHTMAP_SIZE;// + 0.5;\n\n\t\t\t\tif (coords[i][0] >= LIGHTMAP_SIZE)\n\t\t\t\t\tcoords[i][0] -= LIGHTMAP_SIZE;\n\t\t\t\tif (coords[i][1] >= LIGHTMAP_SIZE)\n\t\t\t\t\tcoords[i][1] -= LIGHTMAP_SIZE;\n\t\t\t\tif (coords[i][0] < ds->lightmapX)\n\t\t\t\t\tcoords[i][0] = ds->lightmapX;\n\t\t\t\tif (coords[i][1] < ds->lightmapY)\n\t\t\t\t\tcoords[i][1] = ds->lightmapY;\n\t\t\t}\n\t\t\tx = coords[i][0];\n\t\t\ty = coords[i][1];\n\t\t\tif (x < ds->lightmapX || x >= LIGHTMAP_SIZE)\n\t\t\t\t_printf(\"VL_LightSurfaceWithVolume: x outside lightmap\\n\");\n\t\t\tif (y < ds->lightmapY || y >= LIGHTMAP_SIZE)\n\t\t\t\t_printf(\"VL_LightSurfaceWithVolume: y outside lightmap\\n\");\n\t\t}\n\t\tcoords[i][0] = coords[0][0];\n\t\tcoords[i][1] = coords[0][1];\n\n\t\t//\n\t\tmin_y = LIGHTMAP_SIZE;\n\t\tmax_y = 0;\n\t\tfor (i = 0; i < LIGHTMAP_SIZE; i++)\n\t\t{\n\t\t\tmin_x[i] = LIGHTMAP_SIZE;\n\t\t\tmax_x[i] = 0;\n\t\t}\n\t\tmemset(polygonedges, 0, sizeof(polygonedges));\n\t\t// scan convert the polygon onto the lightmap\n\t\t// for each edge it marks *every* lightmap pixel the edge goes through\n\t\t// so no brasenham and no scan conversion used for texture mapping but\n\t\t// more something like ray casting\n\t\t// this is necesary because we need all lightmap pixels totally or partly\n\t\t// inside the light volume. these lightmap pixels are only lit for the part\n\t\t// that they are inside the light volume.\n\t\tfor (i = 0; i < w.numpoints; i++)\n\t\t{\n\t\t\tfloat xf, yf, dx, dy, xstep, ystep, xfrac, yfrac;\n\t\t\tint xinc, yinc;\n\n\t\t\txf = coords[i][0];\n\t\t\tyf = coords[i][1];\n\t\t\tdx = coords[i+1][0] - xf;\n\t\t\tdy = coords[i+1][1] - yf;\n\t\t\t//\n\t\t\tx = (int) xf;\n\t\t\ty = (int) yf;\n\t\t\t//\n\t\t\tif (y < min_y)\n\t\t\t\tmin_y = y;\n\t\t\tif (y > max_y)\n\t\t\t\tmax_y = y;\n\t\t\t//\n\t\t\tif (fabs(dx) > fabs(dy))\n\t\t\t{\n\t\t\t\tif (dx > 0)\n\t\t\t\t{\n\t\t\t\t\t// y fraction at integer x below fractional x\n\t\t\t\t\tyfrac = yf + (floor(xf) - xf) * dy / dx;\n\t\t\t\t\txinc = 1;\n\t\t\t\t}\n\t\t\t\telse if (dx < 0)\n\t\t\t\t{\n\t\t\t\t\t// y fraction at integer x above fractional x\n\t\t\t\t\tyfrac = yf + (floor(xf) + 1 - xf) * dy / dx;\n\t\t\t\t\txinc = -1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tyfrac = yf;\n\t\t\t\t\txinc = 0;\n\t\t\t\t}\n\t\t\t\t// step in y direction per 1 unit in x direction\n\t\t\t\tif (dx)\n\t\t\t\t\tystep = dy / fabs(dx);\n\t\t\t\telse\n\t\t\t\t\tystep = 0;\n\t\t\t\twhile(1)\n\t\t\t\t{\n\t\t\t\t\tif (x < ds->lightmapX || x >= LIGHTMAP_SIZE)\n\t\t\t\t\t\t_printf(\"VL_LightSurfaceWithVolume: x outside lightmap\\n\");\n\t\t\t\t\tif (y < ds->lightmapY || y >= LIGHTMAP_SIZE)\n\t\t\t\t\t\t_printf(\"VL_LightSurfaceWithVolume: y outside lightmap\\n\");\n\t\t\t\t\t//\n\t\t\t\t\tn = y * LIGHTMAP_SIZE + x;\n\t\t\t\t\tpolygonedges[n >> 3] |= 1 << (n & 7);\n\t\t\t\t\tif (x < min_x[y])\n\t\t\t\t\t\tmin_x[y] = x;\n\t\t\t\t\tif (x > max_x[y])\n\t\t\t\t\t\tmax_x[y] = x;\n\t\t\t\t\tif (x == (int) coords[i+1][0])\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tyfrac += ystep;\n\t\t\t\t\tif (dy > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (yfrac > (float) y + 1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ty += 1;\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\tn = y * LIGHTMAP_SIZE + x;\n\t\t\t\t\t\t\tpolygonedges[n >> 3] |= 1 << (n & 7);\n\t\t\t\t\t\t\tif (x < min_x[y])\n\t\t\t\t\t\t\t\tmin_x[y] = x;\n\t\t\t\t\t\t\tif (x > max_x[y])\n\t\t\t\t\t\t\t\tmax_x[y] = x;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tif (yfrac < (float) y)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ty -= 1;\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\tn = y * LIGHTMAP_SIZE + x;\n\t\t\t\t\t\t\tpolygonedges[n >> 3] |= 1 << (n & 7);\n\t\t\t\t\t\t\tif (x < min_x[y])\n\t\t\t\t\t\t\t\tmin_x[y] = x;\n\t\t\t\t\t\t\tif (x > max_x[y])\n\t\t\t\t\t\t\t\tmax_x[y] = x;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tx += xinc;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (dy > 0)\n\t\t\t\t{\n\t\t\t\t\t//x fraction at integer y below fractional y\n\t\t\t\t\txfrac = xf + (floor(yf) - yf) * dx / dy;\n\t\t\t\t\tyinc = 1;\n\t\t\t\t}\n\t\t\t\telse if (dy < 0)\n\t\t\t\t{\n\t\t\t\t\t//x fraction at integer y above fractional y\n\t\t\t\t\txfrac = xf + (floor(yf) + 1 - yf) * dx / dy;\n\t\t\t\t\tyinc = -1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\txfrac = xf;\n\t\t\t\t\tyinc = 0;\n\t\t\t\t}\n\t\t\t\t// step in x direction per 1 unit in y direction\n\t\t\t\tif (dy)\n\t\t\t\t\txstep = dx / fabs(dy);\n\t\t\t\telse\n\t\t\t\t\txstep = 0;\n\t\t\t\twhile(1)\n\t\t\t\t{\n\t\t\t\t\tif (x < ds->lightmapX || x >= LIGHTMAP_SIZE)\n\t\t\t\t\t\t_printf(\"VL_LightSurfaceWithVolume: x outside lightmap\\n\");\n\t\t\t\t\tif (y < ds->lightmapY || y >= LIGHTMAP_SIZE)\n\t\t\t\t\t\t_printf(\"VL_LightSurfaceWithVolume: y outside lightmap\\n\");\n\t\t\t\t\t//\n\t\t\t\t\tn = y * LIGHTMAP_SIZE + x;\n\t\t\t\t\tpolygonedges[n >> 3] |= 1 << (n & 7);\n\t\t\t\t\tif (x < min_x[y])\n\t\t\t\t\t\tmin_x[y] = x;\n\t\t\t\t\tif (x > max_x[y])\n\t\t\t\t\t\tmax_x[y] = x;\n\t\t\t\t\tif (y == (int) coords[i+1][1])\n\t\t\t\t\t\tbreak;\n\t\t\t\t\txfrac += xstep;\n\t\t\t\t\tif (dx > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (xfrac > (float) x + 1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tx += 1;\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\tn = y * LIGHTMAP_SIZE + x;\n\t\t\t\t\t\t\tpolygonedges[n >> 3] |= 1 << (n & 7);\n\t\t\t\t\t\t\tif (x < min_x[y])\n\t\t\t\t\t\t\t\tmin_x[y] = x;\n\t\t\t\t\t\t\tif (x > max_x[y])\n\t\t\t\t\t\t\t\tmax_x[y] = x;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tif (xfrac < (float) x)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tx -= 1;\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\tn = y * LIGHTMAP_SIZE + x;\n\t\t\t\t\t\t\tpolygonedges[n >> 3] |= 1 << (n & 7);\n\t\t\t\t\t\t\tif (x < min_x[y])\n\t\t\t\t\t\t\t\tmin_x[y] = x;\n\t\t\t\t\t\t\tif (x > max_x[y])\n\t\t\t\t\t\t\t\tmax_x[y] = x;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\ty += yinc;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t// map light onto the lightmap\n\tfor (y = min_y; y <= max_y; y++)\n\t{\n\t\tfor (x = min_x[y]; x <= max_x[y]; x++)\n\t\t{\n\t\t\tif (ds->surfaceType == MST_PATCH)\n\t\t\t{\n\t\t\t\tmesh = test->detailMesh;\n\t\t\t\tVectorCopy( mesh->verts[(y-ds->lightmapY)*mesh->width+x-ds->lightmapX].xyz, base);\n\t\t\t\tVectorCopy( mesh->verts[(y-ds->lightmapY)*mesh->width+x-ds->lightmapX].normal, normal);\n\t\t\t\t//VectorCopy(facet->plane.normal, normal);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tVectorMA(ds->lightmapOrigin, (float) x - ds->lightmapX, ds->lightmapVecs[0], base);\n\t\t\t\tVectorMA(base, (float) y - ds->lightmapY, ds->lightmapVecs[1], base);\n\t\t\t\tVectorCopy(facet->plane.normal, normal);\n\t\t\t}\n\t\t\tif (light->type == LIGHT_POINTSPOT)\n\t\t\t{\n\t\t\t\tfloat\tdistByNormal;\n\t\t\t\tvec3_t\tpointAtDist;\n\t\t\t\tfloat\tradiusAtDist;\n\t\t\t\tfloat\tsampleRadius;\n\t\t\t\tvec3_t\tdistToSample;\n\t\t\t\tfloat\tconeScale;\n\n\t\t\t\tVectorSubtract( light->origin, base, dir );\n\n\t\t\t\tdistByNormal = -DotProduct( dir, light->normal );\n\t\t\t\tif ( distByNormal < 0 ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tVectorMA( light->origin, distByNormal, light->normal, pointAtDist );\n\t\t\t\tradiusAtDist = light->radiusByDist * distByNormal;\n\n\t\t\t\tVectorSubtract( base, pointAtDist, distToSample );\n\t\t\t\tsampleRadius = VectorLength( distToSample );\n\n\t\t\t\tif ( sampleRadius >= radiusAtDist ) {\n\t\t\t\t\tcontinue;\t\t// outside the cone\n\t\t\t\t}\n\t\t\t\tif ( sampleRadius <= radiusAtDist - 32 ) {\n\t\t\t\t\tconeScale = 1.0;\t// fully inside\n\t\t\t\t} else {\n\t\t\t\t\tconeScale = ( radiusAtDist - sampleRadius ) / 32.0;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tdist = VectorNormalize( dir, dir );\n\t\t\t\t// clamp the distance to prevent super hot spots\n\t\t\t\tif ( dist < 16 ) {\n\t\t\t\t\tdist = 16;\n\t\t\t\t}\n\t\t\t\tangle = DotProduct( normal, dir );\n\t\t\t\tif (angle > 1)\n\t\t\t\t\tangle = 1;\n\t\t\t\tif (angle > 0) {\n\t\t\t\t\tif ( light->atten_angletype == LAAT_QUADRATIC ) {\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t\tangle *= angle;\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t}\n\t\t\t\t\telse if ( light->atten_angletype == LAAT_DOUBLEQUADRATIC ) {\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t\tangle *= angle * angle;\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (light->atten_anglescale > 0) {\n\t\t\t\t\tangle /= light->atten_anglescale;\n\t\t\t\t\tif (angle > 1)\n\t\t\t\t\t\tangle = 1;\n\t\t\t\t}\n\t\t\t\tif (light->atten_distscale > 0) {\n\t\t\t\t\tdistscale = light->atten_distscale;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdistscale = 1;\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tif ( light->atten_disttype == LDAT_NOSCALE ) {\n\t\t\t\t\tadd = angle * coneScale;\n\t\t\t\t}\n\t\t\t\telse if ( light->atten_disttype == LDAT_LINEAR ) {\n\t\t\t\t\tadd = angle * light->photons * lightLinearScale * coneScale - dist * distscale;\n\t\t\t\t\tif ( add < 0 ) {\n\t\t\t\t\t\tadd = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tadd = light->photons / ( dist * dist * distscale) * angle * coneScale;\n\t\t\t\t}\n\t\t\t\tif (add <= 1.0)\n\t\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse if (light->type == LIGHT_POINTFAKESURFACE)\n\t\t\t{\n\t\t\t\t// calculate the contribution\n\t\t\t\tadd = PointToPolygonFormFactor( base, normal, &light->w );\n\t\t\t\tif ( add <= 0 ) {\n\t\t\t\t\tif ( light->twosided ) {\n\t\t\t\t\t\tadd = -add;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (light->type == LIGHT_SURFACEDIRECTED)\n\t\t\t{\n\t\t\t\t//VectorCopy(light->normal, dir);\n\t\t\t\t//VectorInverse(dir);\n\t\t\t\t// project the light map pixel origin onto the area light source plane\n\t\t\t\td = DotProduct(base, light->normal) - DotProduct(light->normal, light->w.points[0]);\n\t\t\t\tVectorMA(base, -d, light->normal, origin);\n\t\t\t\tVectorSubtract(origin, base, dir);\n\t\t\t\tdist = VectorNormalize(dir, dir);\n\t\t\t\tif ( dist < 16 ) {\n\t\t\t\t\tdist = 16;\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tangle = DotProduct( normal, dir );\n\t\t\t\tif (angle > 1)\n\t\t\t\t\tangle = 1;\n\t\t\t\tif (angle > 0) {\n\t\t\t\t\tif ( light->atten_angletype == LAAT_QUADRATIC ) {\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t\tangle *= angle;\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t}\n\t\t\t\t\telse if ( light->atten_angletype == LAAT_DOUBLEQUADRATIC ) {\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t\tangle *= angle * angle;\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (light->atten_anglescale > 0) {\n\t\t\t\t\tangle /= light->atten_anglescale;\n\t\t\t\t\tif (angle > 1)\n\t\t\t\t\t\tangle = 1;\n\t\t\t\t}\n\t\t\t\tif (light->atten_distscale > 0) {\n\t\t\t\t\tdistscale = light->atten_distscale;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdistscale = 1;\n\t\t\t\t}\n\t\t\t\tif ( light->atten_disttype == LDAT_NOSCALE ) {\n\t\t\t\t\tadd = angle;\n\t\t\t\t}\n\t\t\t\telse if ( light->atten_disttype == LDAT_LINEAR ) {\n\t\t\t\t\tadd = angle * light->photons * lightLinearScale - dist * distscale;\n\t\t\t\t\tif ( add < 0 ) {\n\t\t\t\t\t\tadd = 0;\n\t\t\t\t\t}\n\t\t\t\t} else { //default quadratic\n\t\t\t\t\tadd = light->photons / ( dist * dist * distscale) * angle;\n\t\t\t\t}\n\t\t\t\tif (add <= 0)\n\t\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse //normal radial point light\n\t\t\t{\n\t\t\t\tVectorSubtract(light->origin, base, dir);\n\t\t\t\tdist = VectorNormalize(dir, dir);\n\t\t\t\tif ( dist < 16 ) {\n\t\t\t\t\tdist = 16;\n\t\t\t\t}\n\t\t\t\tangle = DotProduct( normal, dir );\n\t\t\t\tif (angle > 1)\n\t\t\t\t\tangle = 1;\n\t\t\t\tif (angle > 0) {\n\t\t\t\t\tif ( light->atten_angletype == LAAT_QUADRATIC ) {\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t\tangle *= angle;\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t}\n\t\t\t\t\telse if ( light->atten_angletype == LAAT_DOUBLEQUADRATIC ) {\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t\tangle *= angle * angle;\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (light->atten_anglescale > 0) {\n\t\t\t\t\tangle /= light->atten_anglescale;\n\t\t\t\t\tif (angle > 1)\n\t\t\t\t\t\tangle = 1;\n\t\t\t\t}\n\t\t\t\tif (light->atten_distscale > 0) {\n\t\t\t\t\tdistscale = light->atten_distscale;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdistscale = 1;\n\t\t\t\t}\n\t\t\t\tif ( light->atten_disttype == LDAT_NOSCALE ) {\n\t\t\t\t\tadd = angle;\n\t\t\t\t}\n\t\t\t\telse if ( light->atten_disttype == LDAT_LINEAR ) {\n\t\t\t\t\tadd = angle * light->photons * lightLinearScale - dist * distscale;\n\t\t\t\t\tif ( add < 0 ) {\n\t\t\t\t\t\tadd = 0;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tadd = light->photons / ( dist * dist * distscale) * angle;\n\t\t\t\t}\n\t\t\t\tif (add <= 1.0)\n\t\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t//\n\t\t\tk = (ds->lightmapNum * LIGHTMAP_HEIGHT + y) * LIGHTMAP_WIDTH + x;\n\t\t\t//if on one of the edges\n\t\t\tn = y * LIGHTMAP_SIZE + x;\n\t\t\tif ((polygonedges[n >> 3] & (1 << (n & 7)) ))\n\t\t\t{\n\t\t\t\t// multiply 'add' by the relative area being lit of the total visible lightmap pixel area\n\t\t\t\t//\n\t\t\t\t// first create a winding for the lightmap pixel\n\t\t\t\tif (ds->surfaceType == MST_PATCH)\n\t\t\t\t{\n\t\t\t\t\tmesh = test->detailMesh;\n\t\t\t\t\tif (y-ds->lightmapY >= mesh->height-1)\n\t\t\t\t\t\t_printf(\"y outside mesh\\n\");\n\t\t\t\t\tif (x-ds->lightmapX >= mesh->width-1)\n\t\t\t\t\t\t_printf(\"x outside mesh\\n\");\n\t\t\t\t\tVectorCopy( mesh->verts[(y-ds->lightmapY)*mesh->width+x-ds->lightmapX].xyz, w.points[0]);\n\t\t\t\t\tVectorCopy( mesh->verts[(y+1-ds->lightmapY)*mesh->width+x-ds->lightmapX].xyz, w.points[1]);\n\t\t\t\t\tVectorCopy( mesh->verts[(y+1-ds->lightmapY)*mesh->width+x+1-ds->lightmapX].xyz, w.points[2]);\n\t\t\t\t\tVectorCopy( mesh->verts[(y-ds->lightmapY)*mesh->width+x+1-ds->lightmapX].xyz, w.points[3]);\n\t\t\t\t\tw.numpoints = 4;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT - ds->lightmapX, ds->lightmapVecs[0], w.points[0]);\n\t\t\t\t\tVectorMA(w.points[0], (float) y - LIGHTMAP_PIXELSHIFT - ds->lightmapY, ds->lightmapVecs[1], w.points[0]);\n\t\t\t\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT - ds->lightmapX, ds->lightmapVecs[0], w.points[1]);\n\t\t\t\t\tVectorMA(w.points[1], (float) y - LIGHTMAP_PIXELSHIFT + 1 - ds->lightmapY, ds->lightmapVecs[1], w.points[1]);\n\t\t\t\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT + 1 - ds->lightmapX, ds->lightmapVecs[0], w.points[2]);\n\t\t\t\t\tVectorMA(w.points[2], (float) y - LIGHTMAP_PIXELSHIFT + 1 - ds->lightmapY, ds->lightmapVecs[1], w.points[2]);\n\t\t\t\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT + 1 - ds->lightmapX, ds->lightmapVecs[0], w.points[3]);\n\t\t\t\t\tVectorMA(w.points[3], (float) y - LIGHTMAP_PIXELSHIFT - ds->lightmapY, ds->lightmapVecs[1], w.points[3]);\n\t\t\t\t\tw.numpoints = 4;\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\t// take the visible area of the lightmap pixel into account\n\t\t\t\t//\n\t\t\t\t//area = WindingArea(&w);\n\t\t\t\tarea = lightmappixelarea[k];\n\t\t\t\tif (area <= 0)\n\t\t\t\t\tcontinue;\n\t\t\t\t// chop the lightmap pixel winding with the light volume\n\t\t\t\tfor (i = 0; i < volume->numplanes; i++)\n\t\t\t\t{\n\t\t\t\t\t//if totally on the back\n\t\t\t\t\tif (VL_ChopWinding(&w, &volume->planes[i], 0) == SIDE_BACK)\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t// if the lightmap pixel is partly inside the light volume\n\t\t\t\tif (i >= volume->numplanes)\n\t\t\t\t{\n\t\t\t\t\tinsidearea = WindingArea(&w);\n\t\t\t\t\tif (insidearea <= 0)\n\t\t\t\t\t\ti = 0;\n\t\t\t\t\tadd = add * insidearea / area;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t//DebugNet_DrawWinding(&w, 2);\n\t\t\t\t\tcontinue;\t// this shouldn't happen\n\t\t\t\t}\n\t\t\t}\n\t\t\t// get the light filter from all the translucent surfaces the light volume went through\n\t\t\tVL_GetFilter(light, volume, base, filter);\n\t\t\t//\n\t\t\tcolor = &lightFloats[k*3];\n\t\t\tcolor[0] += add * light->color[0] * filter[0];\n\t\t\tcolor[1] += add * light->color[1] * filter[1];\n\t\t\tcolor[2] += add * light->color[2] * filter[2];\n\t\t}\n\t}\n\n\tMutexUnlock(test->mutex);\n}\n\n#endif\n\n/*\n=============\nVL_SplitLightVolume\n=============\n*/\nint VL_SplitLightVolume(lightvolume_t *volume, lightvolume_t *back, plane_t *split, float epsilon)\n{\n\tlightvolume_t f, b;\n\tvec_t\tdists[128];\n\tint\t\tsides[128];\n\tint\t\tcounts[3];\n\tvec_t\tdot;\n\tint\t\ti, j;\n\tvec_t\t*p1, *p2;\n\tvec3_t\tmid;\n\n\tcounts[0] = counts[1] = counts[2] = 0;\n\n\t// determine sides for each point\n\tfor (i = 0; i < volume->numplanes; i++)\n\t{\n\t\tdot = DotProduct (volume->points[i], split->normal);\n\t\tdot -= split->dist;\n\t\tdists[i] = dot;\n\t\tif (dot > epsilon)\n\t\t\tsides[i] = SIDE_FRONT;\n\t\telse if (dot < -epsilon)\n\t\t\tsides[i] = SIDE_BACK;\n\t\telse\n\t\t{\n\t\t\tsides[i] = SIDE_ON;\n\t\t}\n\t\tcounts[sides[i]]++;\n\t}\n\n\tif (!counts[1])\n\t\treturn 0;\t\t// completely on front side\n\t\n\tif (!counts[0])\n\t\treturn 1;\t\t// completely on back side\n\n\tsides[i] = sides[0];\n\tdists[i] = dists[0];\n\t\n\tf.numplanes = 0;\n\tb.numplanes = 0;\n\n\tfor (i = 0; i < volume->numplanes; i++)\n\t{\n\t\tp1 = volume->points[i];\n\n\t\tif (f.numplanes >= MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\t_printf(\"WARNING: VL_SplitLightVolume -> MAX_POINTS_ON_FIXED_WINDING overflowed\\n\");\n\t\t\treturn 0;\t\t// can't chop -- fall back to original\n\t\t}\n\t\tif (b.numplanes >= MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\t_printf(\"WARNING: VL_SplitLightVolume -> MAX_POINTS_ON_FIXED_WINDING overflowed\\n\");\n\t\t\treturn 0;\t\t// can't chop -- fall back to original\n\t\t}\n\n\t\tif (sides[i] == SIDE_ON)\n\t\t{\n\t\t\tVectorCopy(p1, f.points[f.numplanes]);\n\t\t\tVectorCopy(p1, b.points[b.numplanes]);\n\t\t\tif (sides[i+1] == SIDE_BACK)\n\t\t\t{\n\t\t\t\tf.planes[f.numplanes] = *split;\n\t\t\t\tb.planes[b.numplanes] = volume->planes[i];\n\t\t\t}\n\t\t\telse if (sides[i+1] == SIDE_FRONT)\n\t\t\t{\n\t\t\t\tf.planes[f.numplanes] = volume->planes[i];\n\t\t\t\tb.planes[b.numplanes] = *split;\n\t\t\t\tVectorInverse(b.planes[b.numplanes].normal);\n\t\t\t\tb.planes[b.numplanes].dist = -b.planes[b.numplanes].dist;\n\t\t\t}\n\t\t\telse //this shouldn't happen\n\t\t\t{\n\t\t\t\tf.planes[f.numplanes] = *split;\n\t\t\t\tb.planes[b.numplanes] = *split;\n\t\t\t\tVectorInverse(b.planes[b.numplanes].normal);\n\t\t\t\tb.planes[b.numplanes].dist = -b.planes[b.numplanes].dist;\n\t\t\t}\n\t\t\tf.numplanes++;\n\t\t\tb.numplanes++;\n\t\t\tcontinue;\n\t\t}\n\t\n\t\tif (sides[i] == SIDE_FRONT)\n\t\t{\n\t\t\tVectorCopy (p1, f.points[f.numplanes]);\n\t\t\tf.planes[f.numplanes] = volume->planes[i];\n\t\t\tf.numplanes++;\n\t\t}\n\t\tif (sides[i] == SIDE_BACK)\n\t\t{\n\t\t\tVectorCopy (p1, b.points[b.numplanes]);\n\t\t\tb.planes[b.numplanes] = volume->planes[i];\n\t\t\tb.numplanes++;\n\t\t}\n\t\t\n\t\tif (sides[i+1] == SIDE_ON || sides[i+1] == sides[i])\n\t\t\tcontinue;\n\t\t\t\n\t\tif (f.numplanes >= MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\t_printf(\"WARNING: VL_SplitLightVolume -> MAX_POINTS_ON_FIXED_WINDING overflowed\\n\");\n\t\t\treturn 0;\t\t// can't chop -- fall back to original\n\t\t}\n\t\tif (b.numplanes >= MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\t_printf(\"WARNING: VL_SplitLightVolume -> MAX_POINTS_ON_FIXED_WINDING overflowed\\n\");\n\t\t\treturn 0;\t\t// can't chop -- fall back to original\n\t\t}\n\n\t\t// generate a split point\n\t\tp2 = volume->points[(i+1)%volume->numplanes];\n\t\t\n\t\tdot = dists[i] / (dists[i]-dists[i+1]);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\t// avoid round off error when possible\n\t\t\tif (split->normal[j] == 1)\n\t\t\t\tmid[j] = split->dist;\n\t\t\telse if (split->normal[j] == -1)\n\t\t\t\tmid[j] = -split->dist;\n\t\t\telse\n\t\t\t\tmid[j] = p1[j] + dot*(p2[j]-p1[j]);\n\t\t}\n\n\t\tVectorCopy (mid, f.points[f.numplanes]);\n\t\tVectorCopy(mid, b.points[b.numplanes]);\n\t\tif (sides[i+1] == SIDE_BACK)\n\t\t{\n\t\t\tf.planes[f.numplanes] = *split;\n\t\t\tb.planes[b.numplanes] = volume->planes[i];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tf.planes[f.numplanes] = volume->planes[i];\n\t\t\tb.planes[b.numplanes] = *split;\n\t\t\tVectorInverse(b.planes[b.numplanes].normal);\n\t\t\tb.planes[b.numplanes].dist = -b.planes[b.numplanes].dist;\n\t\t}\n\t\tf.numplanes++;\n\t\tb.numplanes++;\n\t}\n\tmemcpy(volume->points, f.points, sizeof(vec3_t) * f.numplanes);\n\tmemcpy(volume->planes, f.planes, sizeof(plane_t) * f.numplanes);\n\tvolume->numplanes = f.numplanes;\n\tmemcpy(back->points, b.points, sizeof(vec3_t) * b.numplanes);\n\tmemcpy(back->planes, b.planes, sizeof(plane_t) * b.numplanes);\n\tback->numplanes = b.numplanes;\n\n\treturn 2;\n}\n\n/*\n=============\nVL_PlaneForEdgeToWinding\n=============\n*/\nvoid VL_PlaneForEdgeToWinding(vec3_t p1, vec3_t p2, winding_t *w, int windingonfront, plane_t *plane)\n{\n\tint i, j;\n\tfloat length, d;\n\tvec3_t v1, v2;\n\n\tVectorSubtract(p2, p1, v1);\n\tfor (i = 0; i < w->numpoints; i++)\n\t{\n\t\tVectorSubtract (w->points[i], p1, v2);\n\n\t\tplane->normal[0] = v1[1]*v2[2] - v1[2]*v2[1];\n\t\tplane->normal[1] = v1[2]*v2[0] - v1[0]*v2[2];\n\t\tplane->normal[2] = v1[0]*v2[1] - v1[1]*v2[0];\n\t\t\t\n\t\t// if points don't make a valid plane, skip it\n\t\tlength = plane->normal[0] * plane->normal[0]\n\t\t\t\t\t+ plane->normal[1] * plane->normal[1]\n\t\t\t\t\t+ plane->normal[2] * plane->normal[2];\n\t\t\t\n\t\tif (length < ON_EPSILON)\n\t\t\tcontinue;\n\n\t\tlength = 1/sqrt(length);\n\t\t\t\n\t\tplane->normal[0] *= length;\n\t\tplane->normal[1] *= length;\n\t\tplane->normal[2] *= length;\n\n\t\tplane->dist = DotProduct (w->points[i], plane->normal);\n\t\t//\n\t\tfor (j = 0; j < w->numpoints; j++)\n\t\t{\n\t\t\tif (j == i)\n\t\t\t\tcontinue;\n\t\t\td = DotProduct(w->points[j], plane->normal) - plane->dist;\n\t\t\tif (windingonfront)\n\t\t\t{\n\t\t\t\tif (d < -ON_EPSILON)\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (d > ON_EPSILON)\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (j >= w->numpoints)\n\t\t\treturn;\n\t}\n}\n\n/*\n=============\nVL_R_CastLightAtSurface\n=============\n*/\nvoid VL_R_FloodLight(vlight_t *light, lightvolume_t *volume, int cluster, int firstportal);\n\nvoid VL_R_CastLightAtSurface(vlight_t *light, lightvolume_t *volume)\n{\n\tlsurfaceTest_t *test;\n\tint i, n;\n\n\t// light the surface with this volume\n\tVL_LightSurfaceWithVolume(volume->surfaceNum, volume->facetNum, light, volume);\n\t//\n\ttest = lsurfaceTest[ volume->surfaceNum ];\n\t// if this is not a translucent surface\n\tif ( !(test->shader->surfaceFlags & SURF_ALPHASHADOW) && !(test->shader->contents & CONTENTS_TRANSLUCENT))\n\t\treturn;\n\t//\n\tif (volume->numtransFacets >= MAX_TRANSLUCENTFACETS)\n\t\tError(\"a light valume went through more than %d translucent facets\", MAX_TRANSLUCENTFACETS);\n\t//add this translucent surface to the list\n\tvolume->transSurfaces[volume->numtransFacets] = volume->surfaceNum;\n\tvolume->transFacets[volume->numtransFacets] = volume->facetNum;\n\tvolume->numtransFacets++;\n\t//clear the tested facets except the translucent ones\n\tmemset(volume->facetTested, 0, sizeof(volume->facetTested));\n\tfor (i = 0; i < volume->numtransFacets; i++)\n\t{\n\t\ttest = lsurfaceTest[ volume->transSurfaces[i] ];\n\t\tn = test->facets[volume->transFacets[i]].num;\n\t\tvolume->facetTested[n >> 3] |= 1 << (n & 7);\n\t}\n\tmemset(volume->clusterTested, 0, sizeof(volume->clusterTested));\n\tvolume->endplane = volume->farplane;\n\tvolume->surfaceNum = -1;\n\tvolume->facetNum = 0;\n\tVL_R_FloodLight(light, volume, volume->cluster, 0);\n\tif (volume->surfaceNum >= 0)\n\t{\n\t\tVL_R_CastLightAtSurface(light, volume);\n\t}\n}\n\n/*\n=============\nVL_R_SplitLightVolume\n=============\n*/\nint numvolumes = 0;\n\nint VL_R_SplitLightVolume(vlight_t *light, lightvolume_t *volume, plane_t *split, int cluster, int firstportal)\n{\n\tlightvolume_t back;\n\tint res;\n\n\t//\n\tres = VL_SplitLightVolume(volume, &back, split, 0.1);\n\t// if the volume was split\n\tif (res == 2)\n\t{\n\t\tmemcpy(back.clusterTested, volume->clusterTested, sizeof(back.clusterTested));\n\t\tmemcpy(back.facetTested, volume->facetTested, sizeof(back.facetTested));\n\t\tback.num = numvolumes++;\n\t\tback.endplane = volume->endplane;\n\t\tback.surfaceNum = volume->surfaceNum;\n\t\tback.facetNum = volume->facetNum;\n\t\tback.type = volume->type;\n\t\tback.cluster = volume->cluster;\n\t\tback.farplane = volume->farplane;\n\t\tif (volume->numtransFacets > 0)\n\t\t{\n\t\t\tmemcpy(back.transFacets, volume->transFacets, sizeof(back.transFacets));\n\t\t\tmemcpy(back.transSurfaces, volume->transSurfaces, sizeof(back.transSurfaces));\n\t\t}\n\t\tback.numtransFacets = volume->numtransFacets;\n\t\t//\n\t\t// flood the volume at the back of the split plane\n\t\tVL_R_FloodLight(light, &back, cluster, firstportal);\n\t\t// if the back volume hit a surface\n\t\tif (back.surfaceNum >= 0)\n\t\t{\n\t\t\tVL_R_CastLightAtSurface(light, &back);\n\t\t}\n\t}\n\treturn res;\n}\n\n/*\n=============\nVL_R_FloodLight\n=============\n*/\nvoid VL_R_FloodLight(vlight_t *light, lightvolume_t *volume, int cluster, int firstportal)\n{\n\tint i, j, k, res, surfaceNum, backfaceculled, testculled;\n\tfloat d;\n\twinding_t winding, tmpwinding;\n\tlleaf_t *leaf;\n\tlportal_t *p;\n\tlsurfaceTest_t *test;\n\tlFacet_t *facet;\n\tvec3_t dir1, dir2;\n\tplane_t plane;\n\n\t//\tDebugNet_RemoveAllPolys();\n\t//\tVL_DrawLightVolume(light, volume);\n\n\t// if the first portal is not zero then we've checked all occluders in this leaf already\n\tif (firstportal == 0)\n\t{\n\t\t// check all potential occluders in this leaf\n\t\tfor (i = 0; i < leafs[cluster].numSurfaces; i++)\n\t\t{\n\t\t\tsurfaceNum = clustersurfaces[leafs[cluster].firstSurface + i];\n\t\t\t//\n\t\t\ttest = lsurfaceTest[ surfaceNum ];\n\t\t\tif ( !test )\n\t\t\t\tcontinue;\n\t\t\t//\n\t\t\ttestculled = qfalse;\n\t\t\t// use surface as an occluder\n\t\t\tfor (j = 0; j < test->numFacets; j++)\n\t\t\t{\n\t\t\t\t// use each facet as an occluder\n\t\t\t\tfacet = &test->facets[j];\n\t\t\t\t//\n\t\t\t\t//\tmemcpy(winding.points, facet->points, sizeof(vec3_t) * facet->numpoints);\n\t\t\t\t//\twinding.numpoints = facet->numpoints;\n\t\t\t\t//\tDebugNet_DrawWinding(&winding, 5);\n\t\t\t\t//\n\t\t\t\t// if the facet was tested already\n\t\t\t\tif ( volume->facetTested[facet->num >> 3] & (1 << (facet->num & 7)) )\n\t\t\t\t\tcontinue;\n\t\t\t\tvolume->facetTested[facet->num >> 3] |= 1 << (facet->num & 7);\n\t\t\t\t// backface culling for planar surfaces\n\t\t\t\tbackfaceculled = qfalse;\n\t\t\t\tif (!test->patch && !test->trisoup)\n\t\t\t\t{\n\t\t\t\t\tif (volume->type == VOLUME_NORMAL)\n\t\t\t\t\t{\n\t\t\t\t\t\t// facet backface culling\n\t\t\t\t\t\td = DotProduct(light->origin, facet->plane.normal) - facet->plane.dist;\n\t\t\t\t\t\tif (d < 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// NOTE: this doesn't work too great because of sometimes very bad tesselation\n\t\t\t\t\t\t\t//\t\tof surfaces that are supposed to be flat\n\t\t\t\t\t\t\t// FIXME: to work around this problem we should make sure that all facets\n\t\t\t\t\t\t\t//\t\tcreated from planar surfaces use the lightmapVecs normal vector\n\t\t\t\t\t\t\t/*\n\t\t\t\t\t\t\tif ( !test->shader->twoSided )\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t// skip all other facets of this surface as well because they are in the same plane\n\t\t\t\t\t\t\t\tfor (k = 0; k < test->numFacets; k++)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tfacet = &test->facets[k];\n\t\t\t\t\t\t\t\t\tvolume->facetTested[facet->num >> 3] |= 1 << (facet->num & 7);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}*/\n\t\t\t\t\t\t\tbackfaceculled = qtrue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t// FIXME: if all light source winding points are at the back of the facet\n\t\t\t\t\t\t//\t\t\tplane then backfaceculled = qtrue\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse // backface culling per facet for patches and triangle soups\n\t\t\t\t{\n\t\t\t\t\tif (volume->type == VOLUME_NORMAL)\n\t\t\t\t\t{\n\t\t\t\t\t\t// facet backface culling\n\t\t\t\t\t\td = DotProduct(light->origin, facet->plane.normal) - facet->plane.dist;\n\t\t\t\t\t\tif (d < 0)\n\t\t\t\t\t\t\tbackfaceculled = qtrue;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t// FIXME: if all light source winding points are at the back of the facet\n\t\t\t\t\t\t//\t\t\tplane then backfaceculled = qtrue\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t/* chopping does this already\n\t\t\t\t// check if this facet is totally or partly in front of the volume end plane\n\t\t\t\tfor (k = 0; k < facet->numpoints; k++)\n\t\t\t\t{\n\t\t\t\t\td = DotProduct(volume->endplane.normal, facet->points[k]) - volume->endplane.dist;\n\t\t\t\t\tif (d > ON_EPSILON)\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t// if this facet is outside the light volume\n\t\t\t\tif (k >= facet->numpoints)\n\t\t\t\t\tcontinue;\n\t\t\t\t*/\n\t\t\t\t//\n\t\t\t\tif (backfaceculled)\n\t\t\t\t{\n\t\t\t\t\t// if the facet is not two sided\n\t\t\t\t\tif ( !nobackfaceculling && !test->shader->twoSided )\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t// flip the winding\n\t\t\t\t\tfor (k = 0; k < facet->numpoints; k++)\n\t\t\t\t\t\tVectorCopy(facet->points[k], winding.points[facet->numpoints - k - 1]);\n\t\t\t\t\twinding.numpoints = facet->numpoints;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tmemcpy(winding.points, facet->points, sizeof(vec3_t) * facet->numpoints);\n\t\t\t\t\twinding.numpoints = facet->numpoints;\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tif (!testculled)\n\t\t\t\t{\n\t\t\t\t\ttestculled = qtrue;\n\t\t\t\t\t// fast check if the surface sphere is totally behind the volume end plane\n\t\t\t\t\td = DotProduct(volume->endplane.normal, test->origin) - volume->endplane.dist;\n\t\t\t\t\tif (d < -test->radius)\n\t\t\t\t\t{\n\t\t\t\t\t\tfor (k = 0; k < test->numFacets; k++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfacet = &test->facets[k];\n\t\t\t\t\t\t\tvolume->facetTested[facet->num >> 3] |= 1 << (facet->num & 7);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tfor (k = 0; k < volume->numplanes; k++)\n\t\t\t\t\t{\n\t\t\t\t\t\td = DotProduct(volume->planes[k].normal, test->origin) - volume->planes[k].dist;\n\t\t\t\t\t\tif (d < - test->radius)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfor (k = 0; k < test->numFacets; k++)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfacet = &test->facets[k];\n\t\t\t\t\t\t\t\tvolume->facetTested[facet->num >> 3] |= 1 << (facet->num & 7);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (k < volume->numplanes)\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t//NOTE: we have to chop the facet winding with the volume end plane because\n\t\t\t\t//\t\tthe faces in Q3 are not stitched together nicely\n\t\t\t\tres = VL_ChopWinding(&winding, &volume->endplane, 0.01);\n\t\t\t\t// if the facet is on or at the back of the volume end plane\n\t\t\t\tif (res == SIDE_BACK || res == SIDE_ON)\n\t\t\t\t\tcontinue;\n\t\t\t\t// check if the facet winding is totally or partly inside the light volume\n\t\t\t\tmemcpy(&tmpwinding, &winding, sizeof(winding_t));\n\t\t\t\tfor (k = 0; k < volume->numplanes; k++)\n\t\t\t\t{\n\t\t\t\t\tres = VL_ChopWinding(&tmpwinding, &volume->planes[k], 0.01);\n\t\t\t\t\tif (res == SIDE_BACK || res == SIDE_ON)\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t// if no part of the light volume is occluded by this facet\n\t\t\t\tif (k < volume->numplanes)\n\t\t\t\t\tcontinue;\n\t\t\t\t//\n\t\t\t\tfor (k = 0; k < winding.numpoints; k++)\n\t\t\t\t{\n\t\t\t\t\tif (volume->type == VOLUME_DIRECTED)\n\t\t\t\t\t{\n\t\t\t\t\t\tVectorSubtract(winding.points[(k+1) % winding.numpoints], winding.points[k], dir1);\n\t\t\t\t\t\tCrossProduct(light->normal, dir1, plane.normal);\n\t\t\t\t\t\tVectorNormalize(plane.normal, plane.normal);\n\t\t\t\t\t\tplane.dist = DotProduct(plane.normal, winding.points[k]);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tVectorSubtract(winding.points[(k+1) % winding.numpoints], winding.points[k], dir1);\n\t\t\t\t\t\tVectorSubtract(light->origin, winding.points[k], dir2);\n\t\t\t\t\t\tCrossProduct(dir1, dir2, plane.normal);\n\t\t\t\t\t\tVectorNormalize(plane.normal, plane.normal);\n\t\t\t\t\t\tplane.dist = DotProduct(plane.normal, winding.points[k]);\n\t\t\t\t\t}\n\t\t\t\t\tres = VL_R_SplitLightVolume(light, volume, &plane, cluster, 0);\n\t\t\t\t\tif (res == 1)\n\t\t\t\t\t\tbreak; //the facet wasn't really inside the volume\n\t\t\t\t}\n\t\t\t\tif (k >= winding.numpoints)\n\t\t\t\t{\n\t\t\t\t\tvolume->endplane = facet->plane;\n\t\t\t\t\tif (backfaceculled)\n\t\t\t\t\t{\n\t\t\t\t\t\tVectorInverse(volume->endplane.normal);\n\t\t\t\t\t\tvolume->endplane.dist = -volume->endplane.dist;\n\t\t\t\t\t}\n\t\t\t\t\tvolume->surfaceNum = surfaceNum;\n\t\t\t\t\tvolume->facetNum = j;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t// we've tested all occluders in this cluster\n\tvolume->clusterTested[cluster >> 3] |= 1 << (cluster & 7);\n\t// flood light through the portals of the current leaf\n\tleaf = &leafs[cluster];\n\tfor (i = firstportal; i < leaf->numportals; i++)\n\t{\n\t\tp = leaf->portals[i];\n\t\t//\n\t\t//\tmemcpy(&winding, p->winding, sizeof(winding_t));\n\t\t//\tDebugNet_DrawWinding(&winding, 5);\n\t\t// if already flooded into the cluster this portal leads to\n\t\tif ( volume->clusterTested[p->leaf >> 3] & (1 << (p->leaf & 7)) )\n\t\t\tcontinue;\n\t\t//\n\t\tif (volume->type == VOLUME_NORMAL)\n\t\t{\n\t\t\t// portal backface culling\n\t\t\td = DotProduct(light->origin, p->plane.normal) - p->plane.dist;\n\t\t\tif (d > 0) // portal plane normal points into neighbour cluster\n\t\t\t\tcontinue;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// FIXME: if all light source winding points are at the back of this portal\n\t\t\t//\t\t\tplane then there's no need to flood through\n\t\t}\n\t\t// check if this portal is totally or partly in front of the volume end plane\n\t\t// fast check with portal sphere\n\t\td = DotProduct(volume->endplane.normal, p->origin) - volume->endplane.dist;\n\t\tif (d < -p->radius)\n\t\t\tcontinue;\n\t\tfor (j = 0; j < p->winding->numpoints; j++)\n\t\t{\n\t\t\td = DotProduct(volume->endplane.normal, p->winding->points[j]) - volume->endplane.dist;\n\t\t\tif (d > -0.01)\n\t\t\t\tbreak;\n\t\t}\n\t\t// if this portal is totally behind the light volume end plane\n\t\tif (j >= p->winding->numpoints)\n\t\t\tcontinue;\n\t\t//distance from point light to portal\n\t\td = DotProduct(p->plane.normal, light->origin) - p->plane.dist;\n\t\t// only check if a point light is Not *on* the portal\n\t\tif (volume->type != VOLUME_NORMAL || fabs(d) > 0.1)\n\t\t{\n\t\t\t// check if the portal is partly or totally inside the light volume\n\t\t\tmemcpy(&winding, p->winding, sizeof(winding_t));\n\t\t\tfor (j = 0; j < volume->numplanes; j++)\n\t\t\t{\n\t\t\t\tres = VL_ChopWinding(&winding, &volume->planes[j], 0.01);\n\t\t\t\tif (res == SIDE_BACK || res == SIDE_ON)\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// if the light volume does not go through this portal at all\n\t\t\tif (j < volume->numplanes)\n\t\t\t\tcontinue;\n\t\t}\n\t\t// chop the light volume with the portal\n\t\tfor (k = 0; k < p->winding->numpoints; k++)\n\t\t{\n\t\t\tif (volume->type == VOLUME_DIRECTED)\n\t\t\t{\n\t\t\t\tVectorSubtract(p->winding->points[(k+1) % p->winding->numpoints], p->winding->points[k], dir1);\n\t\t\t\tCrossProduct(light->normal, dir1, plane.normal);\n\t\t\t\tVectorNormalize(plane.normal, plane.normal);\n\t\t\t\tplane.dist = DotProduct(plane.normal, p->winding->points[k]);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tVectorSubtract(p->winding->points[(k+1) % p->winding->numpoints], p->winding->points[k], dir1);\n\t\t\t\tVectorSubtract(light->origin, p->winding->points[k], dir2);\n\t\t\t\tCrossProduct(dir1, dir2, plane.normal);\n\t\t\t\tVectorNormalize(plane.normal, plane.normal);\n\t\t\t\tplane.dist = DotProduct(plane.normal, p->winding->points[k]);\n\t\t\t}\n\t\t\tres = VL_R_SplitLightVolume(light, volume, &plane, cluster, i+1);\n\t\t\tif (res == 1)\n\t\t\t\tbreak; //volume didn't really go through the portal\n\t\t}\n\t\t// if the light volume went through the portal\n\t\tif (k >= p->winding->numpoints)\n\t\t{\n\t\t\t// flood through the portal\n\t\t\tVL_R_FloodLight(light, volume, p->leaf, 0);\n\t\t}\n\t}\n}\n\n/*\n=============\nVL_R_FloodAreaSpotLight\n=============\n*/\nvoid VL_FloodAreaSpotLight(vlight_t *light, winding_t *w, int leafnum)\n{\n}\n\n/*\n=============\nVL_R_SubdivideAreaSpotLight\n=============\n*/\nvoid VL_R_SubdivideAreaSpotLight(vlight_t *light, int nodenum, winding_t *w)\n{\n\tint leafnum, res;\n\tdnode_t *node;\n\tdplane_t *plane;\n\twinding_t back;\n\tplane_t split;\n\n\twhile(nodenum >= 0)\n\t{\n\t\tnode = &dnodes[nodenum];\n\t\tplane = &dplanes[node->planeNum];\n\n\t\tVectorCopy(plane->normal, split.normal);\n\t\tsplit.dist = plane->dist;\n\t\tres = VL_SplitWinding (w, &back, &split, 0.1);\n\n\t\tif (res == SIDE_FRONT)\n\t\t{\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t\telse if (res == SIDE_BACK)\n\t\t{\n\t\t\tnodenum = node->children[1];\n\t\t}\n\t\telse if (res == SIDE_ON)\n\t\t{\n\t\t\tmemcpy(&back, w, sizeof(winding_t));\n\t\t\tVL_R_SubdivideAreaSpotLight(light, node->children[1], &back);\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVL_R_SubdivideAreaSpotLight(light, node->children[1], &back);\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t}\n\tleafnum = -nodenum - 1;\n\tif (dleafs[leafnum].cluster != -1)\n\t{\n\t\tVL_FloodAreaSpotLight(light, w, leafnum);\n\t}\n}\n\n/*\n=============\nVL_R_FloodRadialAreaLight\n=============\n*/\nvoid VL_FloodRadialAreaLight(vlight_t *light, winding_t *w, int leafnum)\n{\n}\n\n/*\n=============\nVL_R_SubdivideRadialAreaLight\n=============\n*/\nvoid VL_R_SubdivideRadialAreaLight(vlight_t *light, int nodenum, winding_t *w)\n{\n\tint leafnum, res;\n\tdnode_t *node;\n\tdplane_t *plane;\n\twinding_t back;\n\tplane_t split;\n\n\twhile(nodenum >= 0)\n\t{\n\t\tnode = &dnodes[nodenum];\n\t\tplane = &dplanes[node->planeNum];\n\n\t\tVectorCopy(plane->normal, split.normal);\n\t\tsplit.dist = plane->dist;\n\t\tres = VL_SplitWinding (w, &back, &split, 0.1);\n\n\t\tif (res == SIDE_FRONT)\n\t\t{\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t\telse if (res == SIDE_BACK)\n\t\t{\n\t\t\tnodenum = node->children[1];\n\t\t}\n\t\telse if (res == SIDE_ON)\n\t\t{\n\t\t\tmemcpy(&back, w, sizeof(winding_t));\n\t\t\tVL_R_SubdivideRadialAreaLight(light, node->children[1], &back);\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVL_R_SubdivideRadialAreaLight(light, node->children[1], &back);\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t}\n\tleafnum = -nodenum - 1;\n\tif (dleafs[leafnum].cluster != -1)\n\t{\n\t\tVL_FloodRadialAreaLight(light, w, leafnum);\n\t}\n}\n\n/*\n=============\nVL_R_FloodDirectedLight\n=============\n*/\nvoid VL_FloodDirectedLight(vlight_t *light, winding_t *w, int leafnum)\n{\n\tint i;\n\tfloat dist;\n\tlightvolume_t volume;\n\tvec3_t dir;\n\n\tif (light->atten_disttype == LDAT_NOSCALE)\n\t{\n\t\t// light travels without decrease in intensity over distance\n\t\tdist = MAX_WORLD_COORD;\n\t}\n\telse\n\t{\n\t\tif ( light->atten_disttype == LDAT_LINEAR )\n\t\t\tdist = light->photons * lightLinearScale;\n\t\telse\n\t\t\tdist = sqrt(light->photons);\n\t}\n\n\tmemset(&volume, 0, sizeof(lightvolume_t));\n\tfor (i = 0; i < w->numpoints; i++)\n\t{\n\t\tVectorMA(w->points[i], dist, light->normal, volume.points[i]);\n\t\tVectorSubtract(w->points[(i+1)%w->numpoints], w->points[i], dir);\n\t\tCrossProduct(light->normal, dir, volume.planes[i].normal);\n\t\tVectorNormalize(volume.planes[i].normal, volume.planes[i].normal);\n\t\tvolume.planes[i].dist = DotProduct(volume.planes[i].normal, w->points[i]);\n\t}\n\tvolume.numplanes = w->numpoints;\n\tVectorCopy(light->normal, volume.endplane.normal);\n\tVectorInverse(volume.endplane.normal);\n\tvolume.endplane.dist = DotProduct(volume.endplane.normal, volume.points[0]);\n\tvolume.farplane = volume.endplane;\n\tvolume.surfaceNum = -1;\n\tvolume.type = VOLUME_DIRECTED;\n\tvolume.cluster = dleafs[leafnum].cluster;\n\tVL_R_FloodLight(light, &volume, volume.cluster, 0);\n\tif (volume.surfaceNum >= 0)\n\t{\n\t\tVL_R_CastLightAtSurface(light, &volume);\n\t}\n}\n\n/*\n=============\nVL_R_SubdivideDirectedAreaLight\n=============\n*/\nvoid VL_R_SubdivideDirectedAreaLight(vlight_t *light, int nodenum, winding_t *w)\n{\n\tint leafnum, res;\n\tdnode_t *node;\n\tdplane_t *plane;\n\twinding_t back;\n\tplane_t split;\n\n\twhile(nodenum >= 0)\n\t{\n\t\tnode = &dnodes[nodenum];\n\t\tplane = &dplanes[node->planeNum];\n\n\t\tVectorCopy(plane->normal, split.normal);\n\t\tsplit.dist = plane->dist;\n\t\tres = VL_SplitWinding (w, &back, &split, 0.1);\n\n\t\tif (res == SIDE_FRONT)\n\t\t{\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t\telse if (res == SIDE_BACK)\n\t\t{\n\t\t\tnodenum = node->children[1];\n\t\t}\n\t\telse if (res == SIDE_ON)\n\t\t{\n\t\t\tmemcpy(&back, w, sizeof(winding_t));\n\t\t\tVL_R_SubdivideDirectedAreaLight(light, node->children[1], &back);\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVL_R_SubdivideDirectedAreaLight(light, node->children[1], &back);\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t}\n\tleafnum = -nodenum - 1;\n\tif (dleafs[leafnum].cluster != -1)\n\t{\n\t\tVL_FloodDirectedLight(light, w, leafnum);\n\t}\n}\n\n/*\n=============\nVL_FloodLight\n=============\n*/\nvoid VL_FloodLight(vlight_t *light)\n{\n\tlightvolume_t volume;\n\tdleaf_t *leaf;\n\tint leafnum, i, j, k, dir[2][4] = {{1, 1, -1, -1}, {1, -1, -1, 1}};\n\tfloat a, step, dist, radius, windingdist;\n\tvec3_t vec, r, p, temp;\n\twinding_t winding;\n\n\tswitch(light->type)\n\t{\n\t\tcase LIGHT_POINTRADIAL:\n\t\t{\n\t\t\t// source is a point\n\t\t\t// light radiates in all directions\n\t\t\t// creates sharp shadows\n\t\t\t//\n\t\t\t// create 6 volumes shining in the axis directions\n\t\t\t// what about: 4 tetrahedrons instead?\n\t\t\t//\n\t\t\tif ( light->atten_disttype == LDAT_LINEAR )\n\t\t\t\tdist = light->photons * lightLinearScale;\n\t\t\telse\n\t\t\t\tdist = sqrt(light->photons);\n\t\t\t//always put the winding at a large distance to avoid epsilon issues\n\t\t\twindingdist = MAX_WORLD_COORD;\n\t\t\tif (dist > windingdist)\n\t\t\t\twindingdist = dist;\n\t\t\t//\n\t\t\tleafnum = VL_LightLeafnum(light->origin);\n\t\t\tleaf = &dleafs[leafnum];\n\t\t\tif (leaf->cluster == -1)\n\t\t\t{\n\t\t\t\tlight->insolid = qtrue;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// for each axis\n\t\t\tfor (i = 0; i < 3; i++)\n\t\t\t{\n\t\t\t\t// for both directions on the axis\n\t\t\t\tfor (j = -1; j <= 1; j += 2)\n\t\t\t\t{\n\t\t\t\t\tmemset(&volume, 0, sizeof(lightvolume_t));\n\t\t\t\t\tvolume.numplanes = 0;\n\t\t\t\t\tfor (k = 0; k < 4; k ++)\n\t\t\t\t\t{\n\t\t\t\t\t\tvolume.points[volume.numplanes][i] = light->origin[i] + j * windingdist;\n\t\t\t\t\t\tvolume.points[volume.numplanes][(i+1)%3] = light->origin[(i+1)%3] + dir[0][k] * windingdist;\n\t\t\t\t\t\tvolume.points[volume.numplanes][(i+2)%3] = light->origin[(i+2)%3] + dir[1][k] * windingdist;\n\t\t\t\t\t\tvolume.numplanes++;\n\t\t\t\t\t}\n\t\t\t\t\tif (j >= 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tVectorCopy(volume.points[0], temp);\n\t\t\t\t\t\tVectorCopy(volume.points[2], volume.points[0]);\n\t\t\t\t\t\tVectorCopy(temp, volume.points[2]);\n\t\t\t\t\t}\n\t\t\t\t\tfor (k = 0; k < volume.numplanes; k++)\n\t\t\t\t\t{\n\t\t\t\t\t\tVL_PlaneFromPoints(&volume.planes[k], light->origin, volume.points[(k+1)%volume.numplanes], volume.points[k]);\n\t\t\t\t\t}\n\t\t\t\t\tVectorCopy(light->origin, temp);\n\t\t\t\t\ttemp[i] += (float) j * dist;\n\t\t\t\t\tVectorClear(volume.endplane.normal);\n\t\t\t\t\tvolume.endplane.normal[i] = -j;\n\t\t\t\t\tvolume.endplane.dist = DotProduct(volume.endplane.normal, temp); //DotProduct(volume.endplane.normal, volume.points[0]);\n\t\t\t\t\tvolume.farplane = volume.endplane;\n\t\t\t\t\tvolume.cluster = leaf->cluster;\n\t\t\t\t\tvolume.surfaceNum = -1;\n\t\t\t\t\tvolume.type = VOLUME_NORMAL;\n\t\t\t\t\t//\n\t\t\t\t\tmemset(volume.facetTested, 0, sizeof(volume.facetTested));\n\t\t\t\t\tmemset(volume.clusterTested, 0, sizeof(volume.clusterTested));\n\t\t\t\t\tVL_R_FloodLight(light, &volume, leaf->cluster, 0);\n\t\t\t\t\tif (volume.surfaceNum >= 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tVL_R_CastLightAtSurface(light, &volume);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase LIGHT_POINTSPOT:\n\t\t{\n\t\t\t// source is a point\n\t\t\t// light is targetted\n\t\t\t// creates sharp shadows\n\t\t\t//\n\t\t\t// what about using brushes to shape spot lights? that'd be pretty cool\n\t\t\t//\n\t\t\tif ( light->atten_disttype == LDAT_LINEAR )\n\t\t\t\tdist = light->photons * lightLinearScale;\n\t\t\telse\n\t\t\t\tdist = sqrt(light->photons);\n\t\t\tdist *= 2;\n\t\t\t//\n\t\t\twindingdist = 4096;\n\t\t\tif (dist > windingdist)\n\t\t\t\twindingdist = dist;\n\t\t\t//take 8 times the cone radius because the spotlight also lights outside the cone\n\t\t\tradius = 8 * windingdist * light->radiusByDist;\n\t\t\t//\n\t\t\tmemset(&volume, 0, sizeof(lightvolume_t));\n\t\t\tleafnum = VL_LightLeafnum(light->origin);\n\t\t\tleaf = &dleafs[leafnum];\n\t\t\tif (leaf->cluster == -1)\n\t\t\t{\n\t\t\t\tlight->insolid = qtrue;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t//\n\t\t\tVectorClear(vec);\n\t\t\tfor (i = 0; i < 3; i++)\n\t\t\t{\n\t\t\t\tif (light->normal[i] > -0.9 && light->normal[i] < 0.9)\n\t\t\t\t{\n\t\t\t\t\tvec[i] = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tCrossProduct(light->normal, vec, r);\n\t\t\tVectorScale(r, radius, p);\n\t\t\tvolume.numplanes = 0;\n\t\t\tstep = 45;\n\t\t\tfor (a = step / 2; a < 360 + step / 2; a += step)\n\t\t\t{\n\t\t\t\tRotatePointAroundVector(volume.points[volume.numplanes], light->normal, p, a);\n\t\t\t\tVectorAdd(light->origin, volume.points[volume.numplanes], volume.points[volume.numplanes]);\n\t\t\t\tVectorMA(volume.points[volume.numplanes], windingdist, light->normal, volume.points[volume.numplanes]);\n\t\t\t\tvolume.numplanes++;\n\t\t\t}\n\t\t\tfor (i = 0; i < volume.numplanes; i++)\n\t\t\t{\n\t\t\t\tVL_PlaneFromPoints(&volume.planes[i], light->origin, volume.points[(i+1)%volume.numplanes], volume.points[i]);\n\t\t\t}\n\t\t\tVectorMA(light->origin, dist, light->normal, temp);\n\t\t\tVectorCopy(light->normal, volume.endplane.normal);\n\t\t\tVectorInverse(volume.endplane.normal);\n\t\t\tvolume.endplane.dist = DotProduct(volume.endplane.normal, temp);//DotProduct(volume.endplane.normal, volume.points[0]);\n\t\t\tvolume.farplane = volume.endplane;\n\t\t\tvolume.cluster = leaf->cluster;\n\t\t\tvolume.surfaceNum = -1;\n\t\t\tvolume.type = VOLUME_NORMAL;\n\t\t\t//\n\t\t\tmemset(volume.facetTested, 0, sizeof(volume.facetTested));\n\t\t\tmemset(volume.clusterTested, 0, sizeof(volume.clusterTested));\n\t\t\tVL_R_FloodLight(light, &volume, leaf->cluster, 0);\n\t\t\tif (volume.surfaceNum >= 0)\n\t\t\t{\n\t\t\t\tVL_R_CastLightAtSurface(light, &volume);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase LIGHT_POINTFAKESURFACE:\n\t\t{\n\t\t\tfloat value;\n\t\t\tint n, axis;\n\t\t\tvec3_t v, vecs[2];\n\n\t\t\tif ( light->atten_disttype == LDAT_LINEAR )\n\t\t\t\tdist = light->photons * lightLinearScale;\n\t\t\telse\n\t\t\t\tdist = sqrt(light->photons);\n\t\t\t//always put the winding at a large distance to avoid epsilon issues\n\t\t\twindingdist = 4096;\n\t\t\tif (dist > windingdist)\n\t\t\t\twindingdist = dist;\n\t\t\t//\n\t\t\tVectorMA(light->origin, 0.1, light->normal, light->origin);\n\t\t\t//\n\t\t\tleafnum = VL_LightLeafnum(light->origin);\n\t\t\tleaf = &dleafs[leafnum];\n\t\t\tif (leaf->cluster == -1)\n\t\t\t{\n\t\t\t\tlight->insolid = qtrue;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tvalue = 0;\n\t\t\tfor (i = 0; i < 3; i++)\n\t\t\t{\n\t\t\t\tif (fabs(light->normal[i]) > value)\n\t\t\t\t{\n\t\t\t\t\tvalue = fabs(light->normal[i]);\n\t\t\t\t\taxis = i;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (i = 0; i < 2; i++)\n\t\t\t{\n\t\t\t\tVectorClear(v);\n\t\t\t\tv[(axis + 1 + i) % 3] = 1;\n\t\t\t\tCrossProduct(light->normal, v, vecs[i]);\n\t\t\t}\n\t\t\t//cast 4 volumes at the front of the surface\n\t\t\tfor (i = -1; i <= 1; i += 2)\n\t\t\t{\n\t\t\t\tfor (j = -1; j <= 1; j += 2)\n\t\t\t\t{\n\t\t\t\t\tfor (n = 0; n < 2; n++)\n\t\t\t\t\t{\n\t\t\t\t\t\tmemset(&volume, 0, sizeof(lightvolume_t));\n\t\t\t\t\t\tvolume.numplanes = 3;\n\t\t\t\t\t\tVectorMA(light->origin, i * windingdist, vecs[0], volume.points[(i == j) == n]);\n\t\t\t\t\t\tVectorMA(light->origin, j * windingdist, vecs[1], volume.points[(i != j) == n]);\n\t\t\t\t\t\tVectorMA(light->origin, windingdist, light->normal, volume.points[2]);\n\t\t\t\t\t\tfor (k = 0; k < volume.numplanes; k++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tVL_PlaneFromPoints(&volume.planes[k], light->origin, volume.points[(k+1)%volume.numplanes], volume.points[k]);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tVL_PlaneFromPoints(&volume.endplane, volume.points[0], volume.points[1], volume.points[2]);\n\t\t\t\t\t\tVectorMA(light->origin, dist, light->normal, temp);\n\t\t\t\t\t\tvolume.endplane.dist = DotProduct(volume.endplane.normal, temp);\n\t\t\t\t\t\tif (DotProduct(light->origin, volume.endplane.normal) - volume.endplane.dist > 0)\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tvolume.farplane = volume.endplane;\n\t\t\t\t\tvolume.cluster = leaf->cluster;\n\t\t\t\t\tvolume.surfaceNum = -1;\n\t\t\t\t\tvolume.type = VOLUME_NORMAL;\n\t\t\t\t\t//\n\t\t\t\t\tmemset(volume.facetTested, 0, sizeof(volume.facetTested));\n\t\t\t\t\tmemset(volume.clusterTested, 0, sizeof(volume.clusterTested));\n\n\t\t\t\t\tVL_R_FloodLight(light, &volume, leaf->cluster, 0);\n\t\t\t\t\tif (volume.surfaceNum >= 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tVL_R_CastLightAtSurface(light, &volume);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase LIGHT_SURFACEDIRECTED:\n\t\t{\n\t\t\t// source is an area defined by a winding\n\t\t\t// the light is unidirectional\n\t\t\t// creates sharp shadows\n\t\t\t// for instance sun light or laser light\n\t\t\t//\n\t\t\tmemcpy(&winding, &light->w, sizeof(winding_t));\n\t\t\tVL_R_SubdivideDirectedAreaLight(light, 0, &winding);\n\t\t\tbreak;\n\t\t}\n\t\tcase LIGHT_SURFACERADIAL:\n\t\t{\n\t\t\t// source is an area defined by a winding\n\t\t\t// the light radiates in all directions at the front of the winding plane\n\t\t\t//\n\t\t\tmemcpy(&winding, &light->w, sizeof(winding_t));\n\t\t\tVL_R_SubdivideRadialAreaLight(light, 0, &winding);\n\t\t\tbreak;\n\t\t}\n\t\tcase LIGHT_SURFACESPOT:\n\t\t{\n\t\t\t// source is an area defined by a winding\n\t\t\t// light is targetted but not unidirectional\n\t\t\t//\n\t\t\tmemcpy(&winding, &light->w, sizeof(winding_t));\n\t\t\tVL_R_SubdivideAreaSpotLight(light, 0, &winding);\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/*\n=============\nVL_FloodLightThread\n=============\n*/\nvoid VL_FloodLightThread(int num)\n{\n\tVL_FloodLight(vlights[num]);\n}\n\n/*\n=============\nVL_TestLightLeafs\n=============\n*/\nvoid VL_TestLightLeafs(void)\n{\n\tint leafnum, i;\n\tvlight_t *light;\n\tdleaf_t *leaf;\n\n\tfor (i = 0; i < numvlights; i++)\n\t{\n\t\tlight = vlights[i];\n\t\tif (light->type != LIGHT_POINTRADIAL &&\n\t\t\tlight->type != LIGHT_POINTSPOT)\n\t\t\tcontinue;\n\t\tleafnum = VL_LightLeafnum(light->origin);\n\t\tleaf = &dleafs[leafnum];\n\t\tif (leaf->cluster == -1)\n\t\t\tif (light->type == LIGHT_POINTRADIAL)\n\t\t\t\tqprintf(\"light in solid at %1.1f %1.1f %1.1f\\n\", light->origin[0], light->origin[1], light->origin[2]);\n\t\t\telse if (light->type == LIGHT_POINTSPOT)\n\t\t\t\tqprintf(\"spot light in solid at %1.1f %1.1f %1.1f\\n\", light->origin[0], light->origin[1], light->origin[2]);\n\t}\n}\n\n\n/*\n=============\nVL_DoForcedTraceLight\n=============\n*/\n// from light.c\nvoid TraceLtm( int num );\n\nvoid VL_DoForcedTraceLight(int num)\n{\n\tdsurface_t\t\t*ds;\n\tshaderInfo_t\t*si;\n\n\tds = &drawSurfaces[num];\n\n\tif ( ds->surfaceType == MST_TRIANGLE_SOUP )\n\t\treturn;\n\n\tif ( ds->lightmapNum < 0 )\n\t\treturn;\n\n\t// always light entity surfaces with the old light algorithm\n\tif ( !entitySurface[num] )\n\t{\n\t\tsi = ShaderInfoForShader( dshaders[ ds->shaderNum].shader );\n\n\t\tif (defaulttracelight)\n\t\t{\n\t\t\tif (si->forceVLight)\n\t\t\t\treturn;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (!si->forceTraceLight)\n\t\t\t\treturn;\n\t\t}\n\t}\n\n\tTraceLtm(num);\n}\n\n/*\n=============\nVL_DoForcedTraceLightSurfaces\n=============\n*/\nvoid VL_DoForcedTraceLightSurfaces(void)\n{\n\t_printf( \"forced trace light\\n\" );\n\tRunThreadsOnIndividual( numDrawSurfaces, qtrue, VL_DoForcedTraceLight );\n}\n\nfloat *oldLightFloats;\n\n/*\n=============\nVL_SurfaceRadiosity\n=============\n*/\nvoid VL_SurfaceRadiosity( int num ) {\n\tdsurface_t\t\t*ds;\n\tmesh_t\t\t\t*mesh;\n\tshaderInfo_t\t*si;\n\tlsurfaceTest_t *test;\n\tint x, y, k;\n\tvec3_t base, normal;\n\tfloat *color, area;\n\tvlight_t vlight;\n\n\tds = &drawSurfaces[num];\n\n\tif ( ds->lightmapNum < 0 ) {\n\t\treturn;\t\t// doesn't have a lightmap\n\t}\n\n\t// vertex-lit triangle model\n\tif ( ds->surfaceType == MST_TRIANGLE_SOUP ) {\n\t\treturn;\n\t}\n\n\tsi = ShaderInfoForShader( dshaders[ ds->shaderNum].shader );\n\ttest = lsurfaceTest[ num ];\n\n\tif (!test) {\n\t\treturn;\n\t}\n\n\tfor (x = 0; x < ds->lightmapWidth; x++) {\n\t\tfor (y = 0; y < ds->lightmapHeight; y++) {\n\t\t\t//\n\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y) \n\t\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\tarea = lightmappixelarea[k];\n\t\t\tif (area <= 0)\n\t\t\t\tcontinue;\n\t\t\t//\n\t\t\tif (ds->surfaceType == MST_PATCH)\n\t\t\t{\n\t\t\t\tmesh = test->detailMesh;\n\t\t\t\tVectorCopy( mesh->verts[y*mesh->width+x].xyz, base);\n\t\t\t\tVectorCopy( mesh->verts[y*mesh->width+x].normal, normal);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tVectorMA(ds->lightmapOrigin, (float) x, ds->lightmapVecs[0], base);\n\t\t\t\tVectorMA(base, (float) y, ds->lightmapVecs[1], base);\n\t\t\t\tVectorCopy(test->facets[0].plane.normal, normal);\n\t\t\t}\n\t\t\t// create ligth from base\n\t\t\tmemset(&vlight, 0, sizeof(vlight_t));\n\t\t\tcolor = &oldLightFloats[k*3];\n\t\t\t// a few units away from the surface\n\t\t\tVectorMA(base, 5, normal, vlight.origin);\n\t\t\tColorNormalize(color, vlight.color);\n\t\t\t// ok this is crap\n\t\t\tvlight.photons = VectorLength(color) * 0.05 * lightPointScale / (area * radiosity_scale);\n\t\t\t// what about using a front facing light only ?\n\t\t\tvlight.type = LIGHT_POINTRADIAL;\n\t\t\t// flood the light from this lightmap pixel\n\t\t\tVL_FloodLight(&vlight);\n\t\t\t// only one thread at a time may write to the lightmap of this surface\n\t\t\tMutexLock(test->mutex);\n\t\t\t// don't light the lightmap pixel itself\n\t\t\tlightFloats[k*3] = oldLightFloats[k*3];\n\t\t\tlightFloats[k*3+1] = oldLightFloats[k*3+1];\n\t\t\tlightFloats[k*3+2] = oldLightFloats[k*3+2];\n\t\t\t//\n\t\t\tMutexUnlock(test->mutex);\n\t\t}\n\t}\n}\n\n/*\n=============\nVL_Radiosity\n\nthis aint working real well but it's fun to play with.\n=============\n*/\nvoid VL_Radiosity(void) {\n\n\toldLightFloats = lightFloats;\n\tlightFloats = (float *) malloc(numLightBytes * sizeof(float));\n\tmemcpy(lightFloats, oldLightFloats, numLightBytes * sizeof(float));\n\t_printf(\"%7i surfaces\\n\", numDrawSurfaces);\n\tRunThreadsOnIndividual( numDrawSurfaces, qtrue, VL_SurfaceRadiosity );\n\tfree(oldLightFloats);\n}\n\n/*\n=============\nVL_LightWorld\n=============\n*/\nvoid VL_LightWorld(void)\n{\n\tint i, numcastedvolumes, numvlightsinsolid;\n\tfloat f;\n\n\t// find the optional world ambient\n\tGetVectorForKey( &entities[0], \"_color\", lightAmbientColor );\n\tf = FloatForKey( &entities[0], \"ambient\" );\n\tVectorScale( lightAmbientColor, f, lightAmbientColor );\n\t/*\n\t_printf(\"\\r%6d lights out of %d\", 0, numvlights);\n\tfor (i = 0; i < numvlights; i++)\n\t{\n\t\t_printf(\"\\r%6d\", i);\n\t\tVL_FloodLight(vlights[i]);\n\t}\n\t_printf(\"\\r%6d lights out of %d\\n\", i, numvlights);\n\t*/\n\t_printf(\"%7i lights\\n\", numvlights);\n\tRunThreadsOnIndividual( numvlights, qtrue, VL_FloodLightThread );\n\n\tnumcastedvolumes = 0;\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ ) {\n\t\tif (lsurfaceTest[i])\n\t\t\tnumcastedvolumes += lsurfaceTest[i]->numvolumes;\n\t}\n\t_printf(\"%7i light volumes casted\\n\", numcastedvolumes);\n\tnumvlightsinsolid = 0;\n\tfor (i = 0; i < numvlights; i++)\n\t{\n\t\tif (vlights[i]->insolid)\n\t\t\tnumvlightsinsolid++;\n\t}\n\t_printf(\"%7i lights in solid\\n\", numvlightsinsolid);\n\t//\n\tradiosity_scale = 1;\n\tfor (i = 0; i < radiosity; i++) {\n\t\tVL_Radiosity();\n\t\tradiosity_scale <<= 1;\n\t}\n\t//\n\tVL_StoreLightmap();\n\t// redo surfaces with the old light algorithm when needed\n\tVL_DoForcedTraceLightSurfaces();\n}\n\n/*\n=============\nVL_CreateEntityLights\n=============\n*/\nentity_t *FindTargetEntity( const char *target );\n\nvoid VL_CreateEntityLights (void)\n{\n\tint\t\ti, c_entityLights;\n\tvlight_t\t*dl;\n\tentity_t\t*e, *e2;\n\tconst char\t*name;\n\tconst char\t*target;\n\tvec3_t\tdest;\n\tconst char\t*_color;\n\tfloat\tintensity;\n\tint\t\tspawnflags;\n\n\t//\n\tc_entityLights = 0;\n\t_printf(\"Creating entity lights...\\n\");\n\t//\n\tfor ( i = 0 ; i < num_entities ; i++ ) {\n\t\te = &entities[i];\n\t\tname = ValueForKey (e, \"classname\");\n\t\tif (strncmp (name, \"light\", 5))\n\t\t\tcontinue;\n\n\t\tdl = malloc(sizeof(*dl));\n\t\tmemset (dl, 0, sizeof(*dl));\n\n\t\tspawnflags = FloatForKey (e, \"spawnflags\");\n\t\tif ( spawnflags & 1 ) {\n\t\t\tdl->atten_disttype = LDAT_LINEAR;\n\t\t}\n\t\tif ( spawnflags & 2 ) {\n\t\t\tdl->atten_disttype = LDAT_NOSCALE;\n\t\t}\n\t\tif ( spawnflags & 4 ) {\n\t\t\tdl->atten_angletype = LAAT_QUADRATIC;\n\t\t}\n\t\tif ( spawnflags & 8 ) {\n\t\t\tdl->atten_angletype = LAAT_DOUBLEQUADRATIC;\n\t\t}\n\n\t\tdl->atten_distscale = FloatForKey(e, \"atten_distscale\");\n\t\tdl->atten_anglescale = FloatForKey(e, \"atten_anglescale\");\n\n\t\tGetVectorForKey (e, \"origin\", dl->origin);\n\t\tdl->style = FloatForKey (e, \"_style\");\n\t\tif (!dl->style)\n\t\t\tdl->style = FloatForKey (e, \"style\");\n\t\tif (dl->style < 0)\n\t\t\tdl->style = 0;\n\n\t\tintensity = FloatForKey (e, \"light\");\n\t\tif (!intensity)\n\t\t\tintensity = FloatForKey (e, \"_light\");\n\t\tif (!intensity)\n\t\t\tintensity = 300;\n\t\t_color = ValueForKey (e, \"_color\");\n\t\tif (_color && _color[0])\n\t\t{\n\t\t\tsscanf (_color, \"%f %f %f\", &dl->color[0],&dl->color[1],&dl->color[2]);\n\t\t\tColorNormalize (dl->color, dl->color);\n\t\t}\n\t\telse\n\t\t\tdl->color[0] = dl->color[1] = dl->color[2] = 1.0;\n\n\t\tintensity = intensity * lightPointScale;\n\t\tdl->photons = intensity;\n\n\t\tdl->type = LIGHT_POINTRADIAL;\n\n\t\t// lights with a target will be spotlights\n\t\ttarget = ValueForKey (e, \"target\");\n\n\t\tif ( target[0] ) {\n\t\t\tfloat\tradius;\n\t\t\tfloat\tdist;\n\n\t\t\te2 = FindTargetEntity (target);\n\t\t\tif (!e2) {\n\t\t\t\t_printf (\"WARNING: light at (%i %i %i) has missing target\\n\",\n\t\t\t\t(int)dl->origin[0], (int)dl->origin[1], (int)dl->origin[2]);\n\t\t\t} else {\n\t\t\t\tGetVectorForKey (e2, \"origin\", dest);\n\t\t\t\tVectorSubtract (dest, dl->origin, dl->normal);\n\t\t\t\tdist = VectorNormalize (dl->normal, dl->normal);\n\t\t\t\tradius = FloatForKey (e, \"radius\");\n\t\t\t\tif ( !radius ) {\n\t\t\t\t\tradius = 64;\n\t\t\t\t}\n\t\t\t\tif ( !dist ) {\n\t\t\t\t\tdist = 64;\n\t\t\t\t}\n\t\t\t\tdl->radiusByDist = (radius + 16) / dist;\n\t\t\t\tdl->type = LIGHT_POINTSPOT;\n\t\t\t}\n\t\t}\n\t\tvlights[numvlights++] = dl;\n\t\tc_entityLights++;\n\t}\n\t_printf(\"%7i entity lights\\n\", c_entityLights);\n}\n\n/*\n==================\nVL_SubdivideAreaLight\n==================\n*/\nvoid VL_SubdivideAreaLight( shaderInfo_t *ls, winding_t *w, vec3_t normal, \n\t\t\t\t\t\tfloat areaSubdivide, qboolean backsplash ) {\n\tfloat\t\t\tarea, value, intensity;\n\tvlight_t\t\t\t*dl, *dl2;\n\tvec3_t\t\t\tmins, maxs;\n\tint\t\t\t\taxis;\n\twinding_t\t\t*front, *back;\n\tvec3_t\t\t\tplaneNormal;\n\tfloat\t\t\tplaneDist;\n\n\tif ( !w ) {\n\t\treturn;\n\t}\n\n\tWindingBounds( w, mins, maxs );\n\n\t// check for subdivision\n\tfor ( axis = 0 ; axis < 3 ; axis++ ) {\n\t\tif ( maxs[axis] - mins[axis] > areaSubdivide ) {\n\t\t\tVectorClear( planeNormal );\n\t\t\tplaneNormal[axis] = 1;\n\t\t\tplaneDist = ( maxs[axis] + mins[axis] ) * 0.5;\n\t\t\tClipWindingEpsilon ( w, planeNormal, planeDist, ON_EPSILON, &front, &back );\n\t\t\tVL_SubdivideAreaLight( ls, front, normal, areaSubdivide, qfalse );\n\t\t\tVL_SubdivideAreaLight( ls, back, normal, areaSubdivide, qfalse );\n\t\t\tFreeWinding( w );\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// create a light from this\n\tarea = WindingArea (w);\n\tif ( area <= 0 || area > 20000000 ) {\n\t\treturn;\n\t}\n\n\tdl = malloc(sizeof(*dl));\n\tmemset (dl, 0, sizeof(*dl));\n\tdl->type = LIGHT_POINTFAKESURFACE;\n\n\tWindingCenter( w, dl->origin );\n\tmemcpy(dl->w.points, w->points, sizeof(vec3_t) * w->numpoints);\n\tdl->w.numpoints = w->numpoints;\n\tVectorCopy ( normal, dl->normal);\n\tVectorCopy ( normal, dl->plane);\n\tdl->plane[3] = DotProduct( dl->origin, normal );\n\n\tvalue = ls->value;\n\tintensity = value * area * lightAreaScale;\n\tVectorAdd( dl->origin, dl->normal, dl->origin );\n\n\tVectorCopy( ls->color, dl->color );\n\n\tdl->photons = intensity;\n\n\t// emitColor is irrespective of the area\n\tVectorScale( ls->color, value*lightFormFactorValueScale*lightAreaScale, dl->emitColor );\n\t//\n\tVectorCopy(dl->emitColor, dl->color);\n\n\tdl->si = ls;\n\n\tif ( ls->contents & CONTENTS_FOG ) {\n\t\tdl->twosided = qtrue;\n\t}\n\n\tvlights[numvlights++] = dl;\n\n\t// optionally create a point backsplash light\n\tif ( backsplash && ls->backsplashFraction > 0 ) {\n\n\t\tdl2 = malloc(sizeof(*dl));\n\t\tmemset (dl2, 0, sizeof(*dl2));\n\t\tdl2->type = LIGHT_POINTRADIAL;\n\n\t\tVectorMA( dl->origin, ls->backsplashDistance, normal, dl2->origin );\n\n\t\tVectorCopy( ls->color, dl2->color );\n\n\t\tdl2->photons = dl->photons * ls->backsplashFraction;\n\t\tdl2->si = ls;\n\n\t\tvlights[numvlights++] = dl2;\n\t}\n}\n\n/*\n==================\nVL_CreateFakeSurfaceLights\n==================\n*/\nvoid VL_CreateFakeSurfaceLights( void ) {\n\tint\t\t\t\ti, j, side;\n\tdsurface_t\t\t*ds;\n\tshaderInfo_t\t*ls;\n\twinding_t\t\t*w;\n\tlFacet_t\t\t*f;\n\tvlight_t\t\t\t*dl;\n\tvec3_t\t\t\torigin;\n\tdrawVert_t\t\t*dv;\n\tint\t\t\t\tc_surfaceLights;\n\tfloat\t\t\tlightSubdivide;\n\tvec3_t\t\t\tnormal;\n\n\n\tc_surfaceLights = 0;\n\t_printf (\"Creating surface lights...\\n\");\n\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ ) {\n\t\t// see if this surface is light emiting\n\t\tds = &drawSurfaces[i];\n\n\t\tls = ShaderInfoForShader( dshaders[ ds->shaderNum].shader );\n\t\tif ( ls->value == 0 ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// determine how much we need to chop up the surface\n\t\tif ( ls->lightSubdivide ) {\n\t\t\tlightSubdivide = ls->lightSubdivide;\n\t\t} else {\n\t\t\tlightSubdivide = lightDefaultSubdivide;\n\t\t}\n\n\t\tc_surfaceLights++;\n\n\t\t// an autosprite shader will become\n\t\t// a point light instead of an area light\n\t\tif ( ls->autosprite ) {\n\t\t\t// autosprite geometry should only have four vertexes\n\t\t\tif ( lsurfaceTest[i] ) {\n\t\t\t\t// curve or misc_model\n\t\t\t\tf = lsurfaceTest[i]->facets;\n\t\t\t\tif ( lsurfaceTest[i]->numFacets != 1 || f->numpoints != 4 ) {\n\t\t\t\t\t_printf( \"WARNING: surface at (%i %i %i) has autosprite shader but isn't a quad\\n\",\n\t\t\t\t\t\t(int)f->points[0], (int)f->points[1], (int)f->points[2] );\n\t\t\t\t}\n\t\t\t\tVectorAdd( f->points[0], f->points[1], origin );\n\t\t\t\tVectorAdd( f->points[2], origin, origin );\n\t\t\t\tVectorAdd( f->points[3], origin, origin );\n\t\t\t\tVectorScale( origin, 0.25, origin );\n\t\t\t} else {\n\t\t\t\t// normal polygon\n\t\t\t\tdv = &drawVerts[ ds->firstVert ];\n\t\t\t\tif ( ds->numVerts != 4 ) {\n\t\t\t\t\t_printf( \"WARNING: surface at (%i %i %i) has autosprite shader but %i verts\\n\",\n\t\t\t\t\t\t(int)dv->xyz[0], (int)dv->xyz[1], (int)dv->xyz[2] );\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tVectorAdd( dv[0].xyz, dv[1].xyz, origin );\n\t\t\t\tVectorAdd( dv[2].xyz, origin, origin );\n\t\t\t\tVectorAdd( dv[3].xyz, origin, origin );\n\t\t\t\tVectorScale( origin, 0.25, origin );\n\t\t\t}\n\n\t\t\tdl = malloc(sizeof(*dl));\n\t\t\tmemset (dl, 0, sizeof(*dl));\n\t\t\tVectorCopy( origin, dl->origin );\n\t\t\tVectorCopy( ls->color, dl->color );\n\t\t\tdl->photons = ls->value * lightPointScale;\n\t\t\tdl->type = LIGHT_POINTRADIAL;\n\t\t\tvlights[numvlights++] = dl;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// possibly create for both sides of the polygon\n\t\tfor ( side = 0 ; side <= ls->twoSided ; side++ ) {\n\t\t\t// create area lights\n\t\t\tif ( lsurfaceTest[i] ) {\n\t\t\t\t// curve or misc_model\n\t\t\t\tfor ( j = 0 ; j < lsurfaceTest[i]->numFacets ; j++ ) {\n\t\t\t\t\tf = lsurfaceTest[i]->facets + j;\n\t\t\t\t\tw = AllocWinding( f->numpoints );\n\t\t\t\t\tw->numpoints = f->numpoints;\n\t\t\t\t\tmemcpy( w->points, f->points, f->numpoints * 12 );\n\n\t\t\t\t\tVectorCopy( f->plane.normal, normal );\n\t\t\t\t\tif ( side ) {\n\t\t\t\t\t\twinding_t\t*t;\n\n\t\t\t\t\t\tt = w;\n\t\t\t\t\t\tw = ReverseWinding( t );\n\t\t\t\t\t\tFreeWinding( t );\n\t\t\t\t\t\tVectorSubtract( vec3_origin, normal, normal );\n\t\t\t\t\t}\n\t\t\t\t\tVL_SubdivideAreaLight( ls, w, normal, lightSubdivide, qtrue );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// normal polygon\n\n\t\t\t\tw = AllocWinding( ds->numVerts );\n\t\t\t\tw->numpoints = ds->numVerts;\n\t\t\t\tfor ( j = 0 ; j < ds->numVerts ; j++ ) {\n\t\t\t\t\tVectorCopy( drawVerts[ds->firstVert+j].xyz, w->points[j] );\n\t\t\t\t}\n\t\t\t\tVectorCopy( ds->lightmapVecs[2], normal );\n\t\t\t\tif ( side ) {\n\t\t\t\t\twinding_t\t*t;\n\n\t\t\t\t\tt = w;\n\t\t\t\t\tw = ReverseWinding( t );\n\t\t\t\t\tFreeWinding( t );\n\t\t\t\t\tVectorSubtract( vec3_origin, normal, normal );\n\t\t\t\t}\n\t\t\t\tVL_SubdivideAreaLight( ls, w, normal, lightSubdivide, qtrue );\n\t\t\t}\n\t\t}\n\t}\n\n\t_printf( \"%7i light emitting surfaces\\n\", c_surfaceLights );\n}\n\n\n/*\n==================\nVL_WindingForBrushSide\n==================\n*/\nwinding_t *VL_WindingForBrushSide(dbrush_t *brush, int side, winding_t *w)\n{\n\tint i, res;\n\twinding_t *tmpw;\n\tplane_t plane;\n\n\tVectorCopy(dplanes[ dbrushsides[ brush->firstSide + side ].planeNum ].normal, plane.normal);\n\tVectorInverse(plane.normal);\n\tplane.dist = -dplanes[ dbrushsides[ brush->firstSide + side ].planeNum ].dist;\n\ttmpw = BaseWindingForPlane( plane.normal, plane.dist );\n\tmemcpy(w->points, tmpw->points, sizeof(vec3_t) * tmpw->numpoints);\n\tw->numpoints = tmpw->numpoints;\n\n\tfor (i = 0; i < brush->numSides; i++)\n\t{\n\t\tif (i == side)\n\t\t\tcontinue;\n\t\tVectorCopy(dplanes[ dbrushsides[ brush->firstSide + i ].planeNum ].normal, plane.normal);\n\t\tVectorInverse(plane.normal);\n\t\tplane.dist = -dplanes[ dbrushsides[ brush->firstSide + i ].planeNum ].dist;\n\t\tres = VL_ChopWinding(w, &plane, 0.1);\n\t\tif (res == SIDE_BACK)\n\t\t\treturn NULL;\n\t}\n\treturn w;\n}\n\n/*\n==================\nVL_CreateSkyLights\n==================\n*/\nvoid VL_CreateSkyLights(void)\n{\n\tint\t\t\t\ti, j, c_skyLights;\n\tdbrush_t\t\t*b;\n\tshaderInfo_t\t*si;\n\tdbrushside_t\t*s;\n\tvlight_t\t\t*dl;\n\tvec3_t sunColor, sunDir = { 0.45, 0.3, 0.9 };\n\tfloat d;\n\n\tVectorNormalize(sunDir, sunDir);\n\tVectorInverse(sunDir);\n\n\tc_skyLights = 0;\n\t_printf(\"Creating sky lights...\\n\");\n\t// find the sky shader\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ ) {\n\t\tsi = ShaderInfoForShader( dshaders[ drawSurfaces[i].shaderNum ].shader );\n\t\tif ( si->surfaceFlags & SURF_SKY ) {\n\t\t\tVectorCopy( si->sunLight, sunColor );\n\t\t\tVectorCopy( si->sunDirection, sunDir );\n\t\t\tVectorInverse(sunDir);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// find the brushes\n\tfor ( i = 0 ; i < numbrushes ; i++ ) {\n\t\tb = &dbrushes[i];\n\t\tfor ( j = 0 ; j < b->numSides ; j++ ) {\n\t\t\ts = &dbrushsides[ b->firstSide + j ];\n\t\t\tif ( dshaders[ s->shaderNum ].surfaceFlags & SURF_SKY ) {\n\t\t\t\t//if this surface doesn't face in the same direction as the sun\n\t\t\t\td = DotProduct(dplanes[ s->planeNum ].normal, sunDir);\n\t\t\t\tif (d <= 0)\n\t\t\t\t\tcontinue;\n\t\t\t\t//\n\t\t\t\tdl = malloc(sizeof(*dl));\n\t\t\t\tmemset (dl, 0, sizeof(*dl));\n\t\t\t\tVectorCopy(sunColor, dl->color);\n\t\t\t\tVectorCopy(sunDir, dl->normal);\n\t\t\t\tVectorCopy(dplanes[ s->planeNum ].normal, dl->plane);\n\t\t\t\tdl->plane[3] = dplanes[ s->planeNum ].dist;\n\t\t\t\tdl->type = LIGHT_SURFACEDIRECTED;\n\t\t\t\tdl->atten_disttype = LDAT_NOSCALE;\n\t\t\t\tVL_WindingForBrushSide(b, j, &dl->w);\n//\t\t\t\tDebugNet_DrawWinding(&dl->w, 2);\n\t\t\t\t//\n\t\t\t\tvlights[numvlights++] = dl;\n\t\t\t\tc_skyLights++;\n\t\t\t}\n\t\t}\n\t}\n\t_printf(\"%7i light emitting sky surfaces\\n\", c_skyLights);\n}\n\n/*\n==================\nVL_SetPortalSphere\n==================\n*/\nvoid VL_SetPortalSphere (lportal_t *p)\n{\n\tint\t\ti;\n\tvec3_t\ttotal, dist;\n\twinding_t\t*w;\n\tfloat\tr, bestr;\n\n\tw = p->winding;\n\tVectorCopy (vec3_origin, total);\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tVectorAdd (total, w->points[i], total);\n\t}\n\t\n\tfor (i=0 ; i<3 ; i++)\n\t\ttotal[i] /= w->numpoints;\n\n\tbestr = 0;\t\t\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tVectorSubtract (w->points[i], total, dist);\n\t\tr = VectorLength (dist);\n\t\tif (r > bestr)\n\t\t\tbestr = r;\n\t}\n\tVectorCopy (total, p->origin);\n\tp->radius = bestr;\n}\n\n/*\n==================\nVL_PlaneFromWinding\n==================\n*/\nvoid VL_PlaneFromWinding (winding_t *w, plane_t *plane)\n{\n\tvec3_t\t\tv1, v2;\n\n\t//calc plane\n\tVectorSubtract (w->points[2], w->points[1], v1);\n\tVectorSubtract (w->points[0], w->points[1], v2);\n\tCrossProduct (v2, v1, plane->normal);\n\tVectorNormalize (plane->normal, plane->normal);\n\tplane->dist = DotProduct (w->points[0], plane->normal);\n}\n\n/*\n==================\nVL_AllocWinding\n==================\n*/\nwinding_t *VL_AllocWinding (int points)\n{\n\twinding_t\t*w;\n\tint\t\t\tsize;\n\t\n\tif (points > MAX_POINTS_ON_WINDING)\n\t\tError (\"NewWinding: %i points\", points);\n\t\n\tsize = (int)((winding_t *)0)->points[points];\n\tw = malloc (size);\n\tmemset (w, 0, size);\n\t\n\treturn w;\n}\n\n/*\n============\nVL_LoadPortals\n============\n*/\nvoid VL_LoadPortals (char *name)\n{\n\tint\t\t\ti, j, hint;\n\tlportal_t\t*p;\n\tlleaf_t\t\t*l;\n\tchar\t\tmagic[80];\n\tFILE\t\t*f;\n\tint\t\t\tnumpoints;\n\twinding_t\t*w;\n\tint\t\t\tleafnums[2];\n\tplane_t\t\tplane;\n\t//\n\t\n\tif (!strcmp(name,\"-\"))\n\t\tf = stdin;\n\telse\n\t{\n\t\tf = fopen(name, \"r\");\n\t\tif (!f)\n\t\t\tError (\"LoadPortals: couldn't read %s\\n\",name);\n\t}\n\n\tif (fscanf (f,\"%79s\\n%i\\n%i\\n%i\\n\",magic, &portalclusters, &numportals, &numfaces) != 4)\n\t\tError (\"LoadPortals: failed to read header\");\n\tif (strcmp(magic, PORTALFILE))\n\t\tError (\"LoadPortals: not a portal file\");\n\n\t_printf (\"%6i portalclusters\\n\", portalclusters);\n\t_printf (\"%6i numportals\\n\", numportals);\n\t_printf (\"%6i numfaces\\n\", numfaces);\n\n\tif (portalclusters >= MAX_CLUSTERS)\n\t\tError (\"more than %d clusters in portal file\\n\", MAX_CLUSTERS);\n\n\t// each file portal is split into two memory portals\n\tportals = malloc(2*numportals*sizeof(lportal_t));\n\tmemset (portals, 0, 2*numportals*sizeof(lportal_t));\n\t\n\tleafs = malloc(portalclusters*sizeof(lleaf_t));\n\tmemset (leafs, 0, portalclusters*sizeof(lleaf_t));\n\n\tfor (i=0, p=portals ; i<numportals ; i++)\n\t{\n\t\tif (fscanf (f, \"%i %i %i \", &numpoints, &leafnums[0], &leafnums[1]) != 3)\n\t\t\tError (\"LoadPortals: reading portal %i\", i);\n\t\tif (numpoints > MAX_POINTS_ON_WINDING)\n\t\t\tError (\"LoadPortals: portal %i has too many points\", i);\n\t\tif ( (unsigned)leafnums[0] > portalclusters\n\t\t|| (unsigned)leafnums[1] > portalclusters)\n\t\t\tError (\"LoadPortals: reading portal %i\", i);\n\t\tif (fscanf (f, \"%i \", &hint) != 1)\n\t\t\tError (\"LoadPortals: reading hint state\");\n\t\t\n\t\tw = p->winding = VL_AllocWinding (numpoints);\n\t\tw->numpoints = numpoints;\n\t\t\n\t\tfor (j=0 ; j<numpoints ; j++)\n\t\t{\n\t\t\tdouble\tv[3];\n\t\t\tint\t\tk;\n\n\t\t\t// scanf into double, then assign to vec_t\n\t\t\t// so we don't care what size vec_t is\n\t\t\tif (fscanf (f, \"(%lf %lf %lf ) \"\n\t\t\t, &v[0], &v[1], &v[2]) != 3)\n\t\t\t\tError (\"LoadPortals: reading portal %i\", i);\n\t\t\tfor (k=0 ; k<3 ; k++)\n\t\t\t\tw->points[j][k] = v[k];\n\t\t}\n\t\tfscanf (f, \"\\n\");\n\t\t\n\t\t// calc plane\n\t\tVL_PlaneFromWinding (w, &plane);\n\n\t\t// create forward portal\n\t\tl = &leafs[leafnums[0]];\n\t\tif (l->numportals == MAX_PORTALS_ON_LEAF)\n\t\t\tError (\"Leaf with too many portals\");\n\t\tl->portals[l->numportals] = p;\n\t\tl->numportals++;\n\t\t\n\t\tp->winding = w;\n\t\tVectorSubtract (vec3_origin, plane.normal, p->plane.normal);\n\t\tp->plane.dist = -plane.dist;\n\t\tp->leaf = leafnums[1];\n\t\tVL_SetPortalSphere (p);\n\t\tp++;\n\t\t\n\t\t// create backwards portal\n\t\tl = &leafs[leafnums[1]];\n\t\tif (l->numportals == MAX_PORTALS_ON_LEAF)\n\t\t\tError (\"Leaf with too many portals\");\n\t\tl->portals[l->numportals] = p;\n\t\tl->numportals++;\n\t\t\n\t\tp->winding = VL_AllocWinding(w->numpoints);\n\t\tp->winding->numpoints = w->numpoints;\n\t\tfor (j=0 ; j<w->numpoints ; j++)\n\t\t{\n\t\t\tVectorCopy (w->points[w->numpoints-1-j], p->winding->points[j]);\n\t\t}\n\n\t\tp->plane = plane;\n\t\tp->leaf = leafnums[0];\n\t\tVL_SetPortalSphere (p);\n\t\tp++;\n\n\t}\n\t\n\tfclose (f);\n}\n\n/*\n============\nVLightMain\n============\n*/\nint VLightMain (int argc, char **argv) {\n\tint\t\t\ti;\n\tdouble\t\tstart, end;\n\tconst char\t*value;\n\n\t_printf (\"----- VLighting ----\\n\");\n\n\tfor (i=1 ; i<argc ; i++) {\n\t\tif (!strcmp(argv[i],\"-v\")) {\n\t\t\tverbose = qtrue;\n\t\t} else if (!strcmp(argv[i],\"-threads\")) {\n\t\t\tnumthreads = atoi (argv[i+1]);\n\t\t\t_printf(\"num threads = %d\\n\", numthreads);\n\t\t\ti++;\n\t\t} else if (!strcmp(argv[i],\"-area\")) {\n\t\t\tlightAreaScale *= atof(argv[i+1]);\n\t\t\t_printf (\"area light scaling at %f\\n\", lightAreaScale);\n\t\t\ti++;\n\t\t} else if (!strcmp(argv[i],\"-point\")) {\n\t\t\tlightPointScale *= atof(argv[i+1]);\n\t\t\t_printf (\"point light scaling at %f\\n\", lightPointScale);\n\t\t\ti++;\n\t\t} else if (!strcmp(argv[i], \"-samplesize\")) {\n\t\t\tsamplesize = atoi(argv[i+1]);\n\t\t\tif (samplesize < 1) samplesize = 1;\n\t\t\ti++;\n\t\t\t_printf(\"lightmap sample size is %dx%d units\\n\", samplesize, samplesize);\n\t\t} else if (!strcmp(argv[i], \"-novertex\")) {\n\t\t\tnovertexlighting = qtrue;\n\t\t\t_printf(\"no vertex lighting = true\\n\");\n\t\t} else if (!strcmp(argv[i], \"-nogrid\")) {\n\t\t\tnogridlighting = qtrue;\n\t\t\t_printf(\"no grid lighting = true\\n\");\n\t\t} else if (!strcmp(argv[i], \"-nostitching\")) {\n\t\t\tnostitching = qtrue;\n\t\t\t_printf(\"no stitching = true\\n\");\n\t\t} else if (!strcmp(argv[i], \"-noalphashading\")) {\n\t\t\tnoalphashading = qtrue;\n\t\t\t_printf(\"no alpha shading = true\\n\");\n\t\t} else if (!strcmp(argv[i], \"-nocolorshading\")) {\n\t\t\tnocolorshading = qtrue;\n\t\t\t_printf(\"old style alpha shading = true\\n\");\n\t\t} else if (!strcmp(argv[i], \"-nobackfaceculling\")) {\n\t\t\tnobackfaceculling = qtrue;\n\t\t\t_printf(\"no backface culling = true\\n\");\n\t\t} else if (!strcmp(argv[i], \"-tracelight\")) {\n\t\t\tdefaulttracelight = qtrue;\n\t\t\t_printf(\"default trace light = true\\n\");\n\t\t} else if (!strcmp(argv[i], \"-radiosity\")) {\n\t\t\tradiosity = atoi(argv[i+1]);\n\t\t\t_printf(\"radiosity = %d\\n\", radiosity);\n\t\t\ti++;\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tThreadSetDefault ();\n\n\tif (i != argc - 1) {\n\t\t_printf(\"usage: q3map -vlight [-<switch> [-<switch> ...]] <mapname>\\n\"\n\t\t\t\t\"\\n\"\n\t\t\t\t\"Switches:\\n\"\n\t\t\t\t\"   v              = verbose output\\n\"\n\t\t\t\t\"   threads <X>    = set number of threads to X\\n\"\n\t\t\t\t\"   area <V>       = set the area light scale to V\\n\"\n\t\t\t\t\"   point <W>      = set the point light scale to W\\n\"\n\t\t\t\t\"   novertex       = don't calculate vertex lighting\\n\"\n\t\t\t\t\"   nogrid         = don't calculate light grid for dynamic model lighting\\n\"\n\t\t\t\t\"   nostitching    = no polygon stitching before lighting\\n\"\n\t\t\t\t\"   noalphashading = don't use alpha shading\\n\"\n\t\t\t\t\"   nocolorshading = don't use color alpha shading\\n\"\n\t\t\t\t\"   tracelight     = use old light algorithm by default\\n\"\n\t\t\t\t\"   samplesize <N> = set the lightmap pixel size to NxN units\\n\");\n\t\texit(0);\n\t}\n\n\tSetQdirFromPath (argv[i]);\t\n\n#ifdef _WIN32\n\tInitPakFile(gamedir, NULL);\n#endif\n\n\tstrcpy (source, ExpandArg(argv[i]));\n\tStripExtension (source);\n\tDefaultExtension (source, \".bsp\");\n\n\tLoadShaderInfo();\n\n\t_printf (\"reading %s\\n\", source);\n\n\tLoadBSPFile (source);\n\tParseEntities();\n\n\tvalue = ValueForKey( &entities[0], \"gridsize\" );\n\tif (strlen(value)) {\n\t\tsscanf( value, \"%f %f %f\", &gridSize[0], &gridSize[1], &gridSize[2] );\n\t\t_printf(\"grid size = {%1.1f, %1.1f, %1.1f}\\n\", gridSize[0], gridSize[1], gridSize[2]);\n\t}\n\n\tCountLightmaps();\n\n\tStripExtension (source);\n\tDefaultExtension (source, \".prt\");\n\n\tVL_LoadPortals(source);\n\n\t// set surfaceOrigin\n\tSetEntityOrigins();\n\n\t// grid and vertex lighting\n\tGridAndVertexLighting();\n\n#ifdef DEBUGNET\n\tDebugNet_Setup();\n#endif\n\n\tstart = clock();\n\n\tlightFloats = (float *) malloc(numLightBytes * sizeof(float));\n\tmemset(lightFloats, 0, numLightBytes * sizeof(float));\n\n\tVL_InitSurfacesForTesting();\n\n\tVL_CalcVisibleLightmapPixelArea();\n\n\tnumvlights = 0;\n\tVL_CreateEntityLights();\n\tVL_CreateFakeSurfaceLights();\n\tVL_CreateSkyLights();\n\n\tVL_TestLightLeafs();\n\n\tVL_LightWorld();\n\n#ifndef LIGHTPOLYS\n\tStripExtension (source);\n\tDefaultExtension (source, \".bsp\");\n\t_printf (\"writing %s\\n\", source);\n\tWriteBSPFile (source);\n#endif\n\n\tend = clock();\n\n\t_printf (\"%5.2f seconds elapsed\\n\", (end-start) / CLK_TCK);\n\n#ifdef LIGHTPOLYS\n\tVL_DrawLightWindings();\n#endif\n\n#ifdef DEBUGNET\n\tDebugNet_Shutdown();\n#endif\n\treturn 0;\n}\n"
  },
  {
    "path": "q3map/makefile",
    "content": "\nCFLAGS = -c\nLDFLAGS =\nODIR = /q3/q3map\n\nEXEBASE = q3map\nEXE = $(ODIR)/$(EXEBASE)\nall: $(EXE)\n\n_irix:\n\tmake \"CFLAGS = -c -Ofast=ip27 -OPT:IEEE_arithmetic=3 -I../common -Xcpluscomm \" \"LDFLAGS = -Ofast=ip27 -OPT:IEEE_arithmetic=3 -g\"\n\t\n_irixdebug:\n\tmake \"CFLAGS = -c -O2 -g -I../common -Xcpluscomm\" \"LDFLAGS = -g\"\n\t\n_irixinst:\n\tmake \"_irix\"\n\tmake \"install\"\n\nclean:\n\trm -f $(ODIR)/*.o $(EXE)\n\ninstall:\n\tcp $(EXE) /quake3_bin\n\tchmod 0777 /quake3_bin/$(EXEBASE)\n\ninstalltest:\n\tcp $(EXE) /quake3_bin/$(EXEBASE)_test\n\tchmod 0777 /quake3_bin/$(EXEBASE)_test\n\n\nFILES = $(ODIR)/fog.o $(ODIR)/brush.o $(ODIR)/tjunction.o $(ODIR)/vis.o $(ODIR)/visflow.o \\\n$(ODIR)/light.o $(ODIR)/lightmaps.o $(ODIR)/bspfile.o \\\n$(ODIR)/cmdlib.o $(ODIR)/patch.o $(ODIR)/mesh.o $(ODIR)/nodraw.o $(ODIR)/glfile.o \\\n$(ODIR)/leakfile.o $(ODIR)/map.o $(ODIR)/mathlib.o $(ODIR)/polylib.o $(ODIR)/aselib.o \\\n$(ODIR)/imagelib.o $(ODIR)/portals.o $(ODIR)/prtfile.o $(ODIR)/bsp.o $(ODIR)/surface.o \\\n$(ODIR)/scriplib.o $(ODIR)/shaders.o $(ODIR)/threads.o $(ODIR)/tree.o \\\n$(ODIR)/writebsp.o $(ODIR)/facebsp.o $(ODIR)/misc_model.o $(ODIR)/light_trace.o\n\n$(EXE) : $(FILES)\n\tcc -o $(EXE) $(LDFLAGS) $(FILES) -lm\n\t\n$(ODIR)/surface.o : surface.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/fog.o : fog.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/brush.o : brush.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/tjunction.o : tjunction.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/lightmaps.o : lightmaps.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/brushbsp.o : brushbsp.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/facebsp.o : facebsp.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/patch.o : patch.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/mesh.o : mesh.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/misc_model.o : misc_model.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/nodraw.o : nodraw.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/glfile.o : glfile.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/leakfile.o : leakfile.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/map.o : map.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/portals.o : portals.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/prtfile.o : prtfile.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/bsp.o : bsp.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/tree.o : tree.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/shaders.o : shaders.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/writebsp.o : writebsp.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/csg.o : csg.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n\n\n$(ODIR)/vis.o : vis.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/visflow.o : visflow.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n\n\n$(ODIR)/light.o : light.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/light_trace.o : light_trace.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n\n$(ODIR)/cmdlib.o : ../common/cmdlib.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/mathlib.o : ../common/mathlib.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/polylib.o : ../common/polylib.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/aselib.o : ../common/aselib.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/imagelib.o : ../common/imagelib.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/scriplib.o : ../common/scriplib.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/threads.o : ../common/threads.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n$(ODIR)/bspfile.o : ../common/bspfile.c\n\tcc $(CFLAGS) -E $? | tr -d '\\015' > /tmp/temp.i\n\tcc $(CFLAGS) -o $@ /tmp/temp.i\n\n\n"
  },
  {
    "path": "q3map/map.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// map.c\n\n#include \"qbsp.h\"\n\n\nint\t\t\tentitySourceBrushes;\t\t// to track editor brush numbers\n\nint\t\t\tnumMapPatches;\n\n// undefine to make plane finding use linear sort\n#define\tUSE_HASHING\n#define\tPLANE_HASHES\t1024\nplane_t\t\t*planehash[PLANE_HASHES];\n\nplane_t\t\tmapplanes[MAX_MAP_PLANES];\nint\t\t\tnummapplanes;\n\n// as brushes and patches are read in, the shaders are stored out in order\n// here, so -onlytextures can just copy them out over the existing shaders\n// in the drawSurfaces\nchar\t\tmapIndexedShaders[MAX_MAP_BRUSHSIDES][MAX_QPATH];\nint\t\t\tnumMapIndexedShaders;\n\nvec3_t\t\tmap_mins, map_maxs;\n\nentity_t\t*mapent;\n\n\n\nint\t\tc_boxbevels;\nint\t\tc_edgebevels;\n\nint\t\tc_areaportals;\nint\t\tc_detail;\nint\t\tc_structural;\n\n// brushes are parsed into a temporary array of sides,\n// which will have the bevels added and duplicates\n// removed before the final brush is allocated\nbspbrush_t\t*buildBrush;\n\n\nvoid TestExpandBrushes (void);\nvoid SetTerrainTextures( void );\nvoid ParseTerrain( void );\n\n\n/*\n=============================================================================\n\nPLANE FINDING\n\n=============================================================================\n*/\n\n\n/*\n================\nPlaneEqual\n================\n*/\n#define\tNORMAL_EPSILON\t0.00001\n#define\tDIST_EPSILON\t0.01\nqboolean\tPlaneEqual (plane_t *p, vec3_t normal, vec_t dist)\n{\n#if 1\n\tif (\n\t   fabs(p->normal[0] - normal[0]) < NORMAL_EPSILON\n\t&& fabs(p->normal[1] - normal[1]) < NORMAL_EPSILON\n\t&& fabs(p->normal[2] - normal[2]) < NORMAL_EPSILON\n\t&& fabs(p->dist - dist) < DIST_EPSILON )\n\t\treturn qtrue;\n#else\n\tif (p->normal[0] == normal[0]\n\t\t&& p->normal[1] == normal[1]\n\t\t&& p->normal[2] == normal[2]\n\t\t&& p->dist == dist)\n\t\treturn qtrue;\n#endif\n\treturn qfalse;\n}\n\n/*\n================\nAddPlaneToHash\n================\n*/\nvoid\tAddPlaneToHash (plane_t *p)\n{\n\tint\t\thash;\n\n\thash = (int)fabs(p->dist) / 8;\n\thash &= (PLANE_HASHES-1);\n\n\tp->hash_chain = planehash[hash];\n\tplanehash[hash] = p;\n}\n\n/*\n================\nCreateNewFloatPlane\n================\n*/\nint CreateNewFloatPlane (vec3_t normal, vec_t dist)\n{\n\tplane_t\t*p, temp;\n\n\tif (VectorLength(normal) < 0.5)\n\t{\n\t\t_printf( \"FloatPlane: bad normal\\n\");\n\t\treturn -1;\n\t}\n\n\t// create a new plane\n\tif (nummapplanes+2 > MAX_MAP_PLANES)\n\t\tError (\"MAX_MAP_PLANES\");\n\n\tp = &mapplanes[nummapplanes];\n\tVectorCopy (normal, p->normal);\n\tp->dist = dist;\n\tp->type = (p+1)->type = PlaneTypeForNormal (p->normal);\n\n\tVectorSubtract (vec3_origin, normal, (p+1)->normal);\n\t(p+1)->dist = -dist;\n\n\tnummapplanes += 2;\n\n\t// allways put axial planes facing positive first\n\tif (p->type < 3)\n\t{\n\t\tif (p->normal[0] < 0 || p->normal[1] < 0 || p->normal[2] < 0)\n\t\t{\n\t\t\t// flip order\n\t\t\ttemp = *p;\n\t\t\t*p = *(p+1);\n\t\t\t*(p+1) = temp;\n\n\t\t\tAddPlaneToHash (p);\n\t\t\tAddPlaneToHash (p+1);\n\t\t\treturn nummapplanes - 1;\n\t\t}\n\t}\n\n\tAddPlaneToHash (p);\n\tAddPlaneToHash (p+1);\n\treturn nummapplanes - 2;\n}\n\n/*\n==============\nSnapVector\n==============\n*/\nvoid\tSnapVector (vec3_t normal)\n{\n\tint\t\ti;\n\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tif ( fabs(normal[i] - 1) < NORMAL_EPSILON )\n\t\t{\n\t\t\tVectorClear (normal);\n\t\t\tnormal[i] = 1;\n\t\t\tbreak;\n\t\t}\n\t\tif ( fabs(normal[i] - -1) < NORMAL_EPSILON )\n\t\t{\n\t\t\tVectorClear (normal);\n\t\t\tnormal[i] = -1;\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/*\n==============\nSnapPlane\n==============\n*/\nvoid\tSnapPlane (vec3_t normal, vec_t *dist)\n{\n\tSnapVector (normal);\n\n\tif (fabs(*dist-Q_rint(*dist)) < DIST_EPSILON)\n\t\t*dist = Q_rint(*dist);\n}\n\n/*\n=============\nFindFloatPlane\n\n=============\n*/\n#ifndef USE_HASHING\nint\t\tFindFloatPlane (vec3_t normal, vec_t dist)\n{\n\tint\t\ti;\n\tplane_t\t*p;\n\n\tSnapPlane (normal, &dist);\n\tfor (i=0, p=mapplanes ; i<nummapplanes ; i++, p++)\n\t{\n\t\tif (PlaneEqual (p, normal, dist))\n\t\t\treturn i;\n\t}\n\n\treturn CreateNewFloatPlane (normal, dist);\n}\n#else\nint\t\tFindFloatPlane (vec3_t normal, vec_t dist)\n{\n\tint\t\ti;\n\tplane_t\t*p;\n\tint\t\thash, h;\n\n\tSnapPlane (normal, &dist);\n\thash = (int)fabs(dist) / 8;\n\thash &= (PLANE_HASHES-1);\n\n\t// search the border bins as well\n\tfor (i=-1 ; i<=1 ; i++)\n\t{\n\t\th = (hash+i)&(PLANE_HASHES-1);\n\t\tfor (p = planehash[h] ; p ; p=p->hash_chain)\n\t\t{\n\t\t\tif (PlaneEqual (p, normal, dist))\n\t\t\t\treturn p-mapplanes;\n\t\t}\n\t}\n\n\treturn CreateNewFloatPlane (normal, dist);\n}\n#endif\n\n/*\n================\nMapPlaneFromPoints\n================\n*/\nint MapPlaneFromPoints (vec3_t p0, vec3_t p1, vec3_t p2) {\n\tvec3_t\tt1, t2, normal;\n\tvec_t\tdist;\n\n\tVectorSubtract (p0, p1, t1);\n\tVectorSubtract (p2, p1, t2);\n\tCrossProduct (t1, t2, normal);\n\tVectorNormalize (normal, normal);\n\n\tdist = DotProduct (p0, normal);\n\n\treturn FindFloatPlane (normal, dist);\n}\n\n\n//====================================================================\n\n/*\n===========\nSetBrushContents\n\nThe contents on all sides of a brush should be the same\nSets contentsShader, contents, opaque, and detail\n===========\n*/\nvoid SetBrushContents( bspbrush_t *b ) {\n\tint\t\t\tcontents, c2;\n\tside_t\t\t*s;\n\tint\t\t\ti;\n\tqboolean\tmixed;\n\tint\t\t\tallFlags;\n\n\ts = &b->sides[0];\n\tcontents = s->contents;\n\tb->contentShader = s->shaderInfo;\n\tmixed = qfalse;\n\n\tallFlags = 0;\n\n\tfor ( i=1 ; i<b->numsides ; i++, s++ ) {\n\t\ts = &b->sides[i];\n\n\t\tif ( !s->shaderInfo ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tc2 = s->contents;\n\t\tif (c2 != contents) {\n\t\t\tmixed = qtrue;\n\t\t}\n\n\t\tallFlags |= s->surfaceFlags;\n\t}\n\n\tif ( mixed ) {\n\t\tqprintf (\"Entity %i, Brush %i: mixed face contents\\n\"\n\t\t\t, b->entitynum, b->brushnum);\n\t}\n\n\tif ( ( contents & CONTENTS_DETAIL ) && ( contents & CONTENTS_STRUCTURAL ) ) {\n\t\t_printf (\"Entity %i, Brush %i: mixed CONTENTS_DETAIL and CONTENTS_STRUCTURAL\\n\"\n\t\t\t, num_entities-1, entitySourceBrushes );\n\t\tcontents &= ~CONTENTS_DETAIL;\n\t}\n\n\t// the fulldetail flag will cause detail brushes to be\n\t// treated like normal brushes\n\tif ( fulldetail ) {\n\t\tcontents &= ~CONTENTS_DETAIL;\n\t}\n\n\t// all translucent brushes that aren't specirically made structural will\n\t// be detail\n\tif ( ( contents & CONTENTS_TRANSLUCENT ) && !( contents & CONTENTS_STRUCTURAL ) ) {\n\t\tcontents |= CONTENTS_DETAIL;\n\t}\n\n\tif ( contents & CONTENTS_DETAIL ) {\n\t\tc_detail++;\n\t\tb->detail = qtrue;\n\t} else {\n\t\tc_structural++;\n\t\tb->detail = qfalse;\n\t}\n\n\tif ( contents & CONTENTS_TRANSLUCENT ) {\n\t\tb->opaque = qfalse;\n\t} else {\n\t\tb->opaque = qtrue;\n\t}\n\n\tif ( contents & CONTENTS_AREAPORTAL ) {\n\t\tc_areaportals++;\n\t}\n\n\tb->contents = contents;\n}\n\n\n//============================================================================\n\n/*\n=================\nAddBrushBevels\n\nAdds any additional planes necessary to allow the brush being\nbuilt to be expanded against axial bounding boxes\n=================\n*/\nvoid AddBrushBevels( void ) {\n\tint\t\taxis, dir;\n\tint\t\ti, order;\n\tside_t\tsidetemp;\n\tside_t\t*s;\n\tvec3_t\tnormal;\n\tfloat\tdist;\n\n\t//\n\t// add the axial planes\n\t//\n\torder = 0;\n\tfor (axis=0 ; axis <3 ; axis++)\n\t{\n\t\tfor (dir=-1 ; dir <= 1 ; dir+=2, order++)\n\t\t{\n\t\t\t// see if the plane is allready present\n\t\t\tfor ( i=0, s=buildBrush->sides ; i < buildBrush->numsides ; i++,s++ ) {\n\t\t\t\tif (mapplanes[s->planenum].normal[axis] == dir)\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (i == buildBrush->numsides )\n\t\t\t{\t// add a new side\n\t\t\t\tif ( buildBrush->numsides == MAX_BUILD_SIDES ) {\n\t\t\t\t\tError( \"MAX_BUILD_SIDES\" );\n\t\t\t\t}\n\t\t\t\tmemset( s, 0, sizeof( *s ) );\n\t\t\t\tbuildBrush->numsides++;\n\t\t\t\tVectorClear (normal);\n\t\t\t\tnormal[axis] = dir;\n\t\t\t\tif (dir == 1)\n\t\t\t\t\tdist = buildBrush->maxs[axis];\n\t\t\t\telse\n\t\t\t\t\tdist = -buildBrush->mins[axis];\n\t\t\t\ts->planenum = FindFloatPlane (normal, dist);\n\t\t\t\ts->contents = buildBrush->sides[0].contents;\n\t\t\t\ts->bevel = qtrue;\n\t\t\t\tc_boxbevels++;\n\t\t\t}\n\n\t\t\t// if the plane is not in it canonical order, swap it\n\t\t\tif (i != order)\n\t\t\t{\n\t\t\t\tsidetemp = buildBrush->sides[order];\n\t\t\t\tbuildBrush->sides[order] = buildBrush->sides[i];\n\t\t\t\tbuildBrush->sides[i] = sidetemp;\n\t\t\t}\n\t\t}\n\t}\n\n\t//\n\t// add the edge bevels\n\t//\n\tif ( buildBrush->numsides == 6 ) {\n\t\treturn;\t\t// pure axial\n  } else {\n\t  int\t\t\tj, k, l;\n\t  float\t\td;\n\t  winding_t\t*w, *w2;\n\t  side_t\t\t*s2;\n\t  vec3_t\t\tvec, vec2;\n\n\t  // test the non-axial plane edges\n\t  // this code tends to cause some problems...\n\t  for (i=6 ; i<buildBrush->numsides ; i++)\n\t  {\n\t\t  s = buildBrush->sides + i;\n\t\t  w = s->winding;\n\t\t  if (!w)\n\t\t\t  continue;\n\t\t  for (j=0 ; j<w->numpoints ; j++)\n\t\t  {\n\t\t\t  k = (j+1)%w->numpoints;\n\t\t\t  VectorSubtract (w->p[j], w->p[k], vec);\n\t\t\t  if (VectorNormalize (vec, vec) < 0.5)\n\t\t\t\t  continue;\n\t\t\t  SnapVector (vec);\n\t\t\t  for (k=0 ; k<3 ; k++)\n\t\t\t\t  if ( vec[k] == -1 || vec[k] == 1)\n\t\t\t\t\t  break;\t// axial\n\t\t\t  if (k != 3)\n\t\t\t\t  continue;\t// only test non-axial edges\n\n\t\t\t  // try the six possible slanted axials from this edge\n\t\t\t  for (axis=0 ; axis <3 ; axis++)\n\t\t\t  {\n\t\t\t\t  for (dir=-1 ; dir <= 1 ; dir+=2)\n\t\t\t\t  {\n\t\t\t\t\t  // construct a plane\n\t\t\t\t\t  VectorClear (vec2);\n\t\t\t\t\t  vec2[axis] = dir;\n\t\t\t\t\t  CrossProduct (vec, vec2, normal);\n\t\t\t\t\t  if (VectorNormalize (normal, normal) < 0.5)\n\t\t\t\t\t\t  continue;\n\t\t\t\t\t  dist = DotProduct (w->p[j], normal);\n\n\t\t\t\t\t  // if all the points on all the sides are\n\t\t\t\t\t  // behind this plane, it is a proper edge bevel\n\t\t\t\t\t  for (k=0 ; k < buildBrush->numsides ; k++)\n\t\t\t\t\t  {\n\t\t\t\t\t\t  // if this plane has allready been used, skip it\n\t\t\t\t\t\t  if (PlaneEqual (&mapplanes[buildBrush->sides[k].planenum]\n\t\t\t\t\t\t\t  , normal, dist) )\n\t\t\t\t\t\t\t  break;\n\n\t\t\t\t\t\t  w2 = buildBrush->sides[k].winding;\n\t\t\t\t\t\t  if (!w2)\n\t\t\t\t\t\t\t  continue;\n\t\t\t\t\t\t  for (l=0 ; l<w2->numpoints ; l++)\n\t\t\t\t\t\t  {\n\t\t\t\t\t\t\t  d = DotProduct (w2->p[l], normal) - dist;\n\t\t\t\t\t\t\t  if (d > 0.1)\n\t\t\t\t\t\t\t\t  break;\t// point in front\n\t\t\t\t\t\t  }\n\t\t\t\t\t\t  if (l != w2->numpoints)\n\t\t\t\t\t\t\t  break;\n\t\t\t\t\t  }\n\n\t\t\t\t\t  if (k != buildBrush->numsides)\n\t\t\t\t\t\t  continue;\t// wasn't part of the outer hull\n\t\t\t\t\t  // add this plane\n\t\t\t\t\t  if ( buildBrush->numsides == MAX_BUILD_SIDES ) {\n\t\t\t\t\t\t  Error( \"MAX_BUILD_SIDES\" );\n\t\t\t\t\t  }\n\n\t\t\t\t\t  s2 = &buildBrush->sides[buildBrush->numsides];\n\t\t\t\t\t  buildBrush->numsides++;\n\t\t\t\t\t  memset( s2, 0, sizeof( *s2 ) );\n\n\t\t\t\t\t  s2->planenum = FindFloatPlane (normal, dist);\n\t\t\t\t\t  s2->contents = buildBrush->sides[0].contents;\n\t\t\t\t\t  s2->bevel = qtrue;\n\t\t\t\t\t  c_edgebevels++;\n\t\t\t\t  }\n\t\t\t  }\n\t\t  }\n\t  }\n  }\n}\n\n/*\n===============\nAddBackSides\n\nfog volumes need to have inside faces created\n===============\n*/\nvoid AddBackSides( void ) {\n/*\n\tbspbrush_t\t*b;\n\tint\t\t\ti, originalSides;\n\tside_t\t\t*s;\n\tside_t\t\t*newSide;\n\n\tb = buildBrush;\n\toriginalSides = b->numsides;\n\tfor ( i = 0 ; i < originalSides ; i++ ) {\n\t\ts = &b->sides[i];\n\t\tif ( !s->shaderInfo ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( !(s->shaderInfo->contents & CONTENTS_FOG) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// duplicate the up-facing side\n\t\tif ( mapplanes[ s->planenum ].normal[2] == 1 ) {\n\t\t\tnewSide = &b->sides[ b->numsides ];\n\t\t\tb->numsides++;\n\n\t\t\t*newSide = *s;\n\t\t\tnewSide->backSide = qtrue;\n\t\t\tnewSide->planenum = s->planenum ^ 1;\t// opposite side\n\t\t}\n\t}\n*/\n}\n\n/*\n===============\nFinishBrush\n\nProduces a final brush based on the buildBrush->sides array\nand links it to the current entity\n===============\n*/\nbspbrush_t *FinishBrush( void ) {\n\tbspbrush_t\t*b;\n\n\t// liquids may need to have extra sides created for back sides\n\tAddBackSides();\n\n\t// create windings for sides and bounds for brush\n\tif ( !CreateBrushWindings( buildBrush ) ) {\n\t\t// don't keep this brush\n\t\treturn NULL;\n\t}\n\n\t// brushes that will not be visible at all are forced to be detail\n\tif ( buildBrush->contents & (CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP) )\n\t{\n\t\tbuildBrush->detail = qtrue;\n\t\tc_detail++;\n\t}\n\n\t//\n\t// origin brushes are removed, but they set\n\t// the rotation origin for the rest of the brushes\n\t// in the entity.  After the entire entity is parsed,\n\t// the planenums and texinfos will be adjusted for\n\t// the origin brush\n\t//\n\tif ( buildBrush->contents & CONTENTS_ORIGIN )\n\t{\n\t\tchar\tstring[32];\n\t\tvec3_t\torigin;\n\n\t\tif (num_entities == 1) {\n\t\t\t_printf (\"Entity %i, Brush %i: origin brushes not allowed in world\\n\"\n\t\t\t\t,  num_entities - 1, entitySourceBrushes);\n\t\t\treturn NULL;\n\t\t}\n\n\t\tVectorAdd (buildBrush->mins, buildBrush->maxs, origin);\n\t\tVectorScale (origin, 0.5, origin);\n\n\t\tsprintf (string, \"%i %i %i\", (int)origin[0], (int)origin[1], (int)origin[2]);\n\t\tSetKeyValue (&entities[num_entities - 1], \"origin\", string);\n\n\t\tVectorCopy (origin, entities[num_entities - 1].origin);\n\n\t\t// don't keep this brush\n\t\treturn NULL;\n\t}\n\n\tif ( buildBrush->contents & CONTENTS_AREAPORTAL ) {\n\t\tif (num_entities != 1) {\n\t\t\t_printf (\"Entity %i, Brush %i: areaportals only allowed in world\\n\"\n\t\t\t\t,  num_entities - 1, entitySourceBrushes);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\tAddBrushBevels ();\n\n\t// keep it\n\tb = CopyBrush( buildBrush );\n\n\tb->entitynum = num_entities-1;\n\tb->brushnum = entitySourceBrushes;\n\n\tb->original = b;\n\n\tb->next = mapent->brushes;\n\tmapent->brushes = b;\n\n\treturn b;\n}\n\n//======================================================================\n\n\n/*\n==================\ntextureAxisFromPlane\n==================\n*/\nvec3_t\tbaseaxis[18] =\n{\n{0,0,1}, {1,0,0}, {0,-1,0},\t\t\t// floor\n{0,0,-1}, {1,0,0}, {0,-1,0},\t\t// ceiling\n{1,0,0}, {0,1,0}, {0,0,-1},\t\t\t// west wall\n{-1,0,0}, {0,1,0}, {0,0,-1},\t\t// east wall\n{0,1,0}, {1,0,0}, {0,0,-1},\t\t\t// south wall\n{0,-1,0}, {1,0,0}, {0,0,-1}\t\t\t// north wall\n};\n\nvoid TextureAxisFromPlane(plane_t *pln, vec3_t xv, vec3_t yv)\n{\n\tint\t\tbestaxis;\n\tvec_t\tdot,best;\n\tint\t\ti;\n\t\n\tbest = 0;\n\tbestaxis = 0;\n\t\n\tfor (i=0 ; i<6 ; i++)\n\t{\n\t\tdot = DotProduct (pln->normal, baseaxis[i*3]);\n\t\tif (dot > best)\n\t\t{\n\t\t\tbest = dot;\n\t\t\tbestaxis = i;\n\t\t}\n\t}\n\t\n\tVectorCopy (baseaxis[bestaxis*3+1], xv);\n\tVectorCopy (baseaxis[bestaxis*3+2], yv);\n}\n\n\n\n/*\n=================\nQuakeTextureVecs\n\nCreates world-to-texture mapping vecs for crappy quake plane arrangements\n=================\n*/\nvoid QuakeTextureVecs( \tplane_t *plane, vec_t shift[2], vec_t rotate, vec_t scale[2],\n\t\t\t\t\t  vec_t mappingVecs[2][4] ) {\n \n\tvec3_t\tvecs[2];\n\tint\t\tsv, tv;\n\tvec_t\tang, sinv, cosv;\n\tvec_t\tns, nt;\n\tint\t\ti, j;\n\n\tTextureAxisFromPlane(plane, vecs[0], vecs[1]);\n\n\tif (!scale[0])\n\t\tscale[0] = 1;\n\tif (!scale[1])\n\t\tscale[1] = 1;\n\n\t// rotate axis\n\tif (rotate == 0)\n\t\t{ sinv = 0 ; cosv = 1; }\n\telse if (rotate == 90)\n\t\t{ sinv = 1 ; cosv = 0; }\n\telse if (rotate == 180)\n\t\t{ sinv = 0 ; cosv = -1; }\n\telse if (rotate == 270)\n\t\t{ sinv = -1 ; cosv = 0; }\n\telse\n\t{\t\n\t\tang = rotate / 180 * Q_PI;\n\t\tsinv = sin(ang);\n\t\tcosv = cos(ang);\n\t}\n\n\tif (vecs[0][0])\n\t\tsv = 0;\n\telse if (vecs[0][1])\n\t\tsv = 1;\n\telse\n\t\tsv = 2;\n\t\t\t\t\n\tif (vecs[1][0])\n\t\ttv = 0;\n\telse if (vecs[1][1])\n\t\ttv = 1;\n\telse\n\t\ttv = 2;\n\t\t\t\t\t\n\tfor (i=0 ; i<2 ; i++) {\n\t\tns = cosv * vecs[i][sv] - sinv * vecs[i][tv];\n\t\tnt = sinv * vecs[i][sv] +  cosv * vecs[i][tv];\n\t\tvecs[i][sv] = ns;\n\t\tvecs[i][tv] = nt;\n\t}\n\n\tfor (i=0 ; i<2 ; i++)\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t\tmappingVecs[i][j] = vecs[i][j] / scale[i];\n\n\tmappingVecs[0][3] = shift[0];\n\tmappingVecs[1][3] = shift[1];\n}\n\n//======================================================================\n\n/*\n=================\nParseRawBrush\n\nJust parses the sides into buildBrush->sides[], nothing else.\nno validation, back plane removal, etc.\n\nTimo - 08/26/99\nadded brush epairs parsing ( ignoring actually )\nTimo - 08/04/99\nadded exclusive brush primitive parsing\nTimo - 08/08/99\nsupport for old brush format back in\nNOTE : it would be \"cleaner\" to have seperate functions to parse between old and new brushes\n=================\n*/\nvoid\tParseRawBrush( ) {\n\tside_t\t\t*side;\n\tvec3_t\t\tplanepts[3];\n\tint\t\t\tplanenum;\n\tshaderInfo_t\t*si;\n\t// old brushes\n\tvec_t\t\tshift[2];\n\tvec_t\t\trotate;\n\tvec_t\t\tscale[2];\n\tchar\t\tname[MAX_QPATH];\n\tchar\t\tshader[MAX_QPATH];\n\tint\t\t\tflags;\n\n\tbuildBrush->numsides = 0;\n\tbuildBrush->detail = qfalse;\n\n\tif (g_bBrushPrimit==BPRIMIT_NEWBRUSHES)\n\t\tMatchToken( \"{\" );\n\n\tdo\n\t{\n\t\tif (!GetToken (qtrue))\n\t\t\tbreak;\n\t\tif (!strcmp (token, \"}\") )\n\t\t\tbreak;\n\t\t//Timo : brush primitive : here we may have to jump over brush epairs ( only used in editor )\n\t\tif (g_bBrushPrimit==BPRIMIT_NEWBRUSHES)\n\t\t{\n\t\t\tdo\n\t\t\t{\n\t\t\t\tif (strcmp (token, \"(\") )\n\t\t\t\t\tGetToken( qfalse );\n\t\t\t\telse\n\t\t\t\t\tbreak;\n\t\t\t\tGetToken( qtrue );\n\t\t\t} while (1);\n\t\t}\n\t\tUnGetToken();\n\n\t\tif ( buildBrush->numsides == MAX_BUILD_SIDES ) {\n\t\t\tError( \"MAX_BUILD_SIDES\" );\n\t\t}\n\n\t\tside = &buildBrush->sides[ buildBrush->numsides ];\n\t\tmemset( side, 0, sizeof( *side ) );\n\t\tbuildBrush->numsides++;\n\n\t\t// read the three point plane definition\n\t\tParse1DMatrix( 3, planepts[0] );\n\t\tParse1DMatrix( 3, planepts[1] );\n\t\tParse1DMatrix( 3, planepts[2] );\n\n\t\tif (g_bBrushPrimit==BPRIMIT_NEWBRUSHES)\n\t\t\t// read the texture matrix\n\t\t\tParse2DMatrix( 2, 3, (float *)side->texMat );\n\n\t\t// read the texturedef\n\t\tGetToken (qfalse);\n\t\tstrcpy (name, token);\n\n\t\t// save the shader name for retexturing\n\t\tif ( numMapIndexedShaders == MAX_MAP_BRUSHSIDES ) {\n\t\t\tError( \"MAX_MAP_BRUSHSIDES\" );\n\t\t}\n\t\tstrcpy( mapIndexedShaders[numMapIndexedShaders], name );\n\t\tnumMapIndexedShaders++;\n\n\t\tif (g_bBrushPrimit==BPRIMIT_OLDBRUSHES)\n\t\t{\n\t\t\tGetToken (qfalse);\n\t\t\tshift[0] = atoi(token);\n\t\t\tGetToken (qfalse);\n\t\t\tshift[1] = atoi(token);\n\t\t\tGetToken (qfalse);\n\t\t\trotate = atoi(token);\t\n\t\t\tGetToken (qfalse);\n\t\t\tscale[0] = atof(token);\n\t\t\tGetToken (qfalse);\n\t\t\tscale[1] = atof(token);\n\t\t}\n\n\t\t// find default flags and values\n\t\tsprintf( shader, \"textures/%s\", name );\n\t\tsi = ShaderInfoForShader( shader );\n\t\tside->shaderInfo = si;\n\t\tside->surfaceFlags = si->surfaceFlags;\n\t\tside->value = si->value;\n\t\tside->contents = si->contents;\n\n\t\t// allow override of default flags and values\n\t\t// in Q3, the only thing you can override is DETAIL\n\t\tif (TokenAvailable())\n\t\t{\n\t\t\tGetToken (qfalse);\n//\t\t\tside->contents = atoi(token);\n\t\t\tflags = atoi(token);\n\t\t\tif ( flags & CONTENTS_DETAIL ) {\n\t\t\t\tside->contents |= CONTENTS_DETAIL;\n\t\t\t}\n\n\t\t\tGetToken (qfalse);\n//\t\t\ttd.flags = atoi(token);\n\n\t\t\tGetToken (qfalse);\n//\t\t\ttd.value = atoi(token);\n\t\t}\n\n\n\t\t// find the plane number\n\t\tplanenum = MapPlaneFromPoints (planepts[0], planepts[1], planepts[2]);\n\t\tside->planenum = planenum;\n\n\t\tif (g_bBrushPrimit==BPRIMIT_OLDBRUSHES)\n\t\t\t// get the texture mapping for this texturedef / plane combination\n\t\t\tQuakeTextureVecs( &mapplanes[planenum], shift, rotate, scale, side->vecs );\n\n\t} while (1);\n\n\tif (g_bBrushPrimit==BPRIMIT_NEWBRUSHES)\n\t{\n\t\tUnGetToken();\n\t\tMatchToken( \"}\" );\n\t\tMatchToken( \"}\" );\n\t}\n}\n\n/*\n=================\nRemoveDuplicateBrushPlanes\n\nReturns false if the brush has a mirrored set of planes,\nmeaning it encloses no volume.\nAlso removes planes without any normal\n=================\n*/\nqboolean RemoveDuplicateBrushPlanes( bspbrush_t * b ) {\n\tint\t\t\ti, j, k;\n\tside_t\t\t*sides;\n\n\tsides = b->sides;\n\n\tfor ( i = 1 ; i < b->numsides ; i++ ) {\n\n\t\t// check for a degenerate plane\n\t\tif ( sides[i].planenum == -1) {\n\t\t\t_printf (\"Entity %i, Brush %i: degenerate plane\\n\"\n\t\t\t\t, b->entitynum, b->brushnum);\n\t\t\t// remove it\n\t\t\tfor ( k = i + 1 ; k < b->numsides ; k++ ) {\n\t\t\t\tsides[k-1] = sides[k];\n\t\t\t}\n\t\t\tb->numsides--;\n\t\t\ti--;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// check for duplication and mirroring\n\t\tfor ( j = 0 ; j < i ; j++ ) {\n\t\t\tif ( sides[i].planenum == sides[j].planenum ) {\n\t\t\t\t_printf (\"Entity %i, Brush %i: duplicate plane\\n\"\n\t\t\t\t\t, b->entitynum, b->brushnum);\n\t\t\t\t// remove the second duplicate\n\t\t\t\tfor ( k = i + 1 ; k < b->numsides ; k++ ) {\n\t\t\t\t\tsides[k-1] = sides[k];\n\t\t\t\t}\n\t\t\t\tb->numsides--;\n\t\t\t\ti--;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif ( sides[i].planenum == (sides[j].planenum ^ 1) ) {\n\t\t\t\t// mirror plane, brush is invalid\n\t\t\t\t_printf (\"Entity %i, Brush %i: mirrored plane\\n\"\n\t\t\t\t\t, b->entitynum, b->brushnum);\n\t\t\t\treturn qfalse;\n\t\t\t}\n\t\t}\n\t}\n\treturn qtrue;\n}\n\n\n/*\n=================\nParseBrush\n\n  qboolean parameter to true -> parse new brush primitive format ( else use old format )\n=================\n*/\nvoid ParseBrush (void) {\n\tbspbrush_t\t*b;\n\n\tParseRawBrush();\n\n\tbuildBrush->portalareas[0] = -1;\n\tbuildBrush->portalareas[1] = -1;\n\tbuildBrush->entitynum = num_entities-1;\n\tbuildBrush->brushnum = entitySourceBrushes;\n\n\t// if there are mirrored planes, the entire brush is invalid\n\tif ( !RemoveDuplicateBrushPlanes( buildBrush ) ) {\n\t\treturn;\n\t}\n\n\t// get the content for the entire brush\n\tSetBrushContents( buildBrush );\n\n\t// allow detail brushes to be removed \n\tif (nodetail && (buildBrush->contents & CONTENTS_DETAIL) ) {\n\t\tFreeBrush( buildBrush );\n\t\treturn;\n\t}\n\n\t// allow water brushes to be removed\n\tif (nowater && (buildBrush->contents & (CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_WATER)) ) {\n\t\tFreeBrush( buildBrush );\n\t\treturn;\n\t}\n\n\tb = FinishBrush( );\n\tif ( !b ) {\n\t\treturn;\n\t}\n}\n\n\n/*\n================\nMoveBrushesToWorld\n\nTakes all of the brushes from the current entity and\nadds them to the world's brush list.\n\nUsed by func_group\n================\n*/\nvoid MoveBrushesToWorld (entity_t *mapent) {\n\tbspbrush_t\t*b, *next;\n\tparseMesh_t\t*pm;\n\n\t// move brushes\n\tfor ( b = mapent->brushes ; b ; b = next ) {\n\t\tnext = b->next;\n\n\t\tb->next = entities[0].brushes;\n\t\tentities[0].brushes = b;\n\t}\n\tmapent->brushes = NULL;\n\n\t// move patches\n\tif ( mapent->patches ) {\n\n\t\tfor ( pm = mapent->patches ; pm->next ; pm = pm->next ) {\n\t\t}\n\n\t\tpm->next = entities[0].patches;\n\t\tentities[0].patches = mapent->patches;\n\n\t\tmapent->patches = NULL;\n\t}\n}\n\n\n/*\n================\nAdjustBrushesForOrigin\n================\n*/\nvoid AdjustBrushesForOrigin( entity_t *ent ) {\n\tbspbrush_t\t*b;\n\tint\t\t\ti;\n\tside_t\t\t*s;\n\tvec_t\t\tnewdist;\n\tparseMesh_t\t*p;\n\n\tfor ( b = ent->brushes ; b ; b = b->next ) {\n\t\tfor (i=0 ; i<b->numsides ; i++) {\n\t\t\ts = &b->sides[i];\n\t\t\tnewdist = mapplanes[s->planenum].dist -\n\t\t\t\tDotProduct (mapplanes[s->planenum].normal, ent->origin);\n\t\t\ts->planenum = FindFloatPlane (mapplanes[s->planenum].normal, newdist);\n\t\t}\n\t\tCreateBrushWindings(b);\n\t}\n\n\tfor ( p = ent->patches ; p ; p = p->next ) {\n\t\tfor ( i = 0 ; i < p->mesh.width*p->mesh.height ; i++ ) {\n\t\t\tVectorSubtract( p->mesh.verts[i].xyz, ent->origin, p->mesh.verts[i].xyz );\n\t\t}\n\t}\n\n}\n\n/*\n================\nParseMapEntity\n================\n*/\nqboolean\tParseMapEntity (void) {\n\tepair_t\t\t*e;\n\n\tif (!GetToken (qtrue))\n\t\treturn qfalse;\n\n\tif (strcmp (token, \"{\") )\n\t{\n\t\tError (\"ParseEntity: { not found, found %s on line %d - last entity was at: <%4.2f, %4.2f, %4.2f>...\", token, scriptline, entities[num_entities].origin[0], entities[num_entities].origin[1], entities[num_entities].origin[2]);\n\t}\n\t\n\tif (num_entities == MAX_MAP_ENTITIES)\n\t\tError (\"num_entities == MAX_MAP_ENTITIES\");\n\n\tentitySourceBrushes = 0;\n\n\tmapent = &entities[num_entities];\n\tnum_entities++;\n\tmemset (mapent, 0, sizeof(*mapent));\n\n\tdo\n\t{\n\t\tif (!GetToken (qtrue))\n\t\t\tError (\"ParseEntity: EOF without closing brace\");\n\t\tif (!strcmp (token, \"}\") )\n\t\t\tbreak;\n\n\t\tif (!strcmp (token, \"{\") ) {\n\t\t\t// parse a brush or patch\n\t\t\tif (!GetToken (qtrue))\n\t\t\t\tbreak;\n\t\t\tif ( !strcmp( token, \"patchDef2\" ) ) {\n\t\t\t\tnumMapPatches++;\n\t\t\t\tParsePatch();\n\t\t\t} else if ( !strcmp( token, \"terrainDef\" ) ) {\n\t\t\t\tParseTerrain();\n\t\t\t} else if ( !strcmp( token, \"brushDef\" ) ) {\n\t\t\t\tif (g_bBrushPrimit==BPRIMIT_OLDBRUSHES)\n\t\t\t\t\tError(\"old brush format not allowed in new brush format map\");\n\t\t\t\tg_bBrushPrimit=BPRIMIT_NEWBRUSHES;\n\t\t\t\t// parse brush primitive\n\t\t\t\tParseBrush();\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (g_bBrushPrimit==BPRIMIT_NEWBRUSHES)\n\t\t\t\t\tError(\"new brush format not allowed in old brush format map\");\n\t\t\t\tg_bBrushPrimit=BPRIMIT_OLDBRUSHES;\n\t\t\t\t// parse old brush format\n\t\t\t\tUnGetToken();\n\t\t\t\tParseBrush();\n\t\t\t}\n\t\t\tentitySourceBrushes++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// parse a key / value pair\n\t\t\te = ParseEpair ();\n\t\t\te->next = mapent->epairs;\n\t\t\tmapent->epairs = e;\n\t\t}\n\t} while (1);\n\n\tGetVectorForKey (mapent, \"origin\", mapent->origin);\n\n\t//\n\t// if there was an origin brush, offset all of the planes and texinfo\n\t// for all the brushes in the entity\n\tif (mapent->origin[0] || mapent->origin[1] || mapent->origin[2]) {\n\t\tAdjustBrushesForOrigin( mapent );\n\t}\n\n  // group_info entities are just for editor grouping\n  // ignored\n  // FIXME: leak!\n  if (!strcmp(\"group_info\", ValueForKey (mapent, \"classname\")))\n  {\n    num_entities--;\n    return qtrue;\n  }\n\n\t// group entities are just for editor convenience\n\t// toss all brushes into the world entity\n\tif (!strcmp (\"func_group\", ValueForKey (mapent, \"classname\")))\n\t{\n\t\tif ( !strcmp (\"1\", ValueForKey (mapent, \"terrain\"))) {\n\t\t\tSetTerrainTextures();\n\t\t}\n\t\tMoveBrushesToWorld (mapent);\n\t\tnum_entities--;\n\t\treturn qtrue;\n\t}\n\n\treturn qtrue;\n}\n\n//===================================================================\n\n\n/*\n================\nLoadMapFile\n================\n*/\nvoid LoadMapFile (char *filename) {\t\t\n\tbspbrush_t\t*b;\n\n\tqprintf (\"--- LoadMapFile ---\\n\");\n\t_printf (\"Loading map file %s\\n\", filename);\n\n\tLoadScriptFile (filename);\n\n\tnum_entities = 0;\n\tnumMapDrawSurfs = 0;\n\tc_detail = 0;\n\n\tg_bBrushPrimit = BPRIMIT_UNDEFINED;\n\n\t// allocate a very large temporary brush for building\n\t// the brushes as they are loaded\n\tbuildBrush = AllocBrush( MAX_BUILD_SIDES );\n\n\twhile (ParseMapEntity ())\n\t{\n\t}\n\n\tClearBounds (map_mins, map_maxs);\n\tfor ( b = entities[0].brushes ; b ; b=b->next ) {\n\t\tAddPointToBounds( b->mins, map_mins, map_maxs );\n\t\tAddPointToBounds( b->maxs, map_mins, map_maxs );\n\t}\n\n\tqprintf (\"%5i total world brushes\\n\", CountBrushList( entities[0].brushes ) );\n\tqprintf (\"%5i detail brushes\\n\", c_detail );\n\tqprintf (\"%5i patches\\n\", numMapPatches);\n\tqprintf (\"%5i boxbevels\\n\", c_boxbevels);\n\tqprintf (\"%5i edgebevels\\n\", c_edgebevels);\n\tqprintf (\"%5i entities\\n\", num_entities);\n\tqprintf (\"%5i planes\\n\", nummapplanes);\n\tqprintf (\"%5i areaportals\\n\", c_areaportals);\n\tqprintf (\"size: %5.0f,%5.0f,%5.0f to %5.0f,%5.0f,%5.0f\\n\", map_mins[0],map_mins[1],map_mins[2],\n\t\tmap_maxs[0],map_maxs[1],map_maxs[2]);\n\n\tif ( fakemap ) {\n\t\tWriteBspBrushMap (\"fakemap.map\", entities[0].brushes );\n\t}\n\n\tif ( testExpand ) {\n\t\tTestExpandBrushes ();\n\t}\n}\n\n\n//====================================================================\n\n\n/*\n================\nTestExpandBrushes\n\nExpands all the brush planes and saves a new map out to\nallow visual inspection of the clipping bevels\n================\n*/\nvoid TestExpandBrushes( void ) {\n\tside_t\t*s;\n\tint\t\ti, j;\n\tbspbrush_t\t*brush, *list, *copy;\n\tvec_t\tdist;\n\tplane_t\t\t*plane;\n\n\tlist = NULL;\n\n\tfor ( brush = entities[0].brushes ; brush ; brush = brush->next ) {\n\t\tcopy = CopyBrush( brush );\n\t\tcopy->next = list;\n\t\tlist = copy;\n\n\t\t// expand all the planes\n\t\tfor ( i=0 ; i<brush->numsides ; i++ ) {\n\t\t\ts = brush->sides + i;\n\t\t\tplane = &mapplanes[s->planenum];\n\t\t\tdist = plane->dist;\n\t\t\tfor (j=0 ; j<3 ; j++) {\n\t\t\t\tdist += fabs( 16 * plane->normal[j] );\n\t\t\t}\n\t\t\ts->planenum = FindFloatPlane( plane->normal, dist );\n\t\t}\n\n\t}\n\n\tWriteBspBrushMap ( \"expanded.map\", entities[0].brushes );\n\n\tError (\"can't proceed after expanding brushes\");\n}\n"
  },
  {
    "path": "q3map/mesh.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n\n\n/*\n===============================================================\n\nMESH SUBDIVISION\n\n===============================================================\n*/\n\n\nint\toriginalWidths[MAX_EXPANDED_AXIS];\nint\toriginalHeights[MAX_EXPANDED_AXIS];\n\nint\tneighbors[8][2] = {\n\t{0,1}, {1,1}, {1,0}, {1,-1}, {0,-1}, {-1,-1}, {-1,0}, {-1,1}\n};\n\n/*\n============\nLerpDrawVert\n============\n*/\nvoid LerpDrawVert( drawVert_t *a, drawVert_t *b, drawVert_t *out ) {\n\tout->xyz[0] = 0.5 * (a->xyz[0] + b->xyz[0]);\n\tout->xyz[1] = 0.5 * (a->xyz[1] + b->xyz[1]);\n\tout->xyz[2] = 0.5 * (a->xyz[2] + b->xyz[2]);\n\n\tout->st[0] = 0.5 * (a->st[0] + b->st[0]);\n\tout->st[1] = 0.5 * (a->st[1] + b->st[1]);\n\n\tout->lightmap[0] = 0.5 * (a->lightmap[0] + b->lightmap[0]);\n\tout->lightmap[1] = 0.5 * (a->lightmap[1] + b->lightmap[1]);\n\n\tout->color[0] = (a->color[0] + b->color[0]) >> 1;\n\tout->color[1] = (a->color[1] + b->color[1]) >> 1;\n\tout->color[2] = (a->color[2] + b->color[2]) >> 1;\n\tout->color[3] = (a->color[3] + b->color[3]) >> 1;\n}\n\n\nvoid FreeMesh( mesh_t *m ) {\n\tfree( m->verts );\n\tfree( m );\n}\n\nvoid PrintMesh( mesh_t *m ) {\n\tint\t\ti, j;\n\n\tfor ( i = 0 ; i < m->height ; i++ ) {\n\t\tfor ( j = 0 ; j < m->width ; j++ ) {\n\t\t\t_printf(\"(%5.2f %5.2f %5.2f) \"\n\t\t\t\t, m->verts[i*m->width+j].xyz[0]\n\t\t\t\t, m->verts[i*m->width+j].xyz[1]\n\t\t\t\t, m->verts[i*m->width+j].xyz[2] );\n\t\t}\n\t\t_printf(\"\\n\");\n\t}\n}\n\n\nmesh_t *CopyMesh( mesh_t *mesh ) {\n\tmesh_t\t*out;\n\tint\t\tsize;\n\n\tout = malloc( sizeof( *out ) );\n\tout->width = mesh->width;\n\tout->height = mesh->height;\n\n\tsize = out->width * out->height * sizeof( *out->verts );\n\tout->verts = malloc( size );\n\tmemcpy( out->verts, mesh->verts, size );\n\n\treturn out;\n}\n\n\n/*\n=================\nTransposeMesh\n\nReturns a transposed copy of the mesh, freeing the original\n=================\n*/\nmesh_t *TransposeMesh( mesh_t *in ) {\n\tint\t\t\tw, h;\n\tmesh_t\t\t*out;\n\n\tout = malloc( sizeof( *out ) );\n\tout->width = in->height;\n\tout->height = in->width;\n\tout->verts = malloc( out->width * out->height * sizeof( drawVert_t ) );\n\n\tfor ( h = 0 ; h < in->height ; h++ ) {\n\t\tfor ( w = 0 ; w < in->width ; w++ ) {\n\t\t\tout->verts[ w * in->height + h ] = in->verts[ h * in->width + w ];\n\t\t}\n\t}\n\n\tFreeMesh( in );\n\n\treturn out;\n}\n\nvoid InvertMesh( mesh_t *in ) {\n\tint\t\t\tw, h;\n\tdrawVert_t\ttemp;\n\n\tfor ( h = 0 ; h < in->height ; h++ ) {\n\t\tfor ( w = 0 ; w < in->width / 2 ; w++ ) {\n\t\t\ttemp = in->verts[ h * in->width + w ];\n\t\t\tin->verts[ h * in->width + w ] = in->verts[ h * in->width + in->width - 1 - w ];\n\t\t\tin->verts[ h * in->width + in->width - 1 - w ] = temp;\n\t\t}\n\t}\n}\n\n/*\n=================\nMakeMeshNormals\n\n=================\n*/\nvoid MakeMeshNormals( mesh_t in ) {\n\tint\t\ti, j, k, dist;\n\tvec3_t\tnormal;\n\tvec3_t\tsum;\n\tint\t\tcount;\n\tvec3_t\tbase;\n\tvec3_t\tdelta;\n\tint\t\tx, y;\n\tdrawVert_t\t*dv;\n\tvec3_t\t\taround[8], temp;\n\tqboolean\tgood[8];\n\tqboolean\twrapWidth, wrapHeight;\n\tfloat\t\tlen;\n\n\twrapWidth = qfalse;\n\tfor ( i = 0 ; i < in.height ; i++ ) {\n\t\tVectorSubtract( in.verts[i*in.width].xyz, \n\t\t\tin.verts[i*in.width+in.width-1].xyz, delta );\n\t\tlen = VectorLength( delta );\n\t\tif ( len > 1.0 ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif ( i == in.height ) {\n\t\twrapWidth = qtrue;\n\t}\n\n\twrapHeight = qfalse;\n\tfor ( i = 0 ; i < in.width ; i++ ) {\n\t\tVectorSubtract( in.verts[i].xyz, \n\t\t\tin.verts[i + (in.height-1)*in.width].xyz, delta );\n\t\tlen = VectorLength( delta );\n\t\tif ( len > 1.0 ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif ( i == in.width) {\n\t\twrapHeight = qtrue;\n\t}\n\n\n\tfor ( i = 0 ; i < in.width ; i++ ) {\n\t\tfor ( j = 0 ; j < in.height ; j++ ) {\n\t\t\tcount = 0;\n\t\t\tdv = &in.verts[j*in.width+i];\n\t\t\tVectorCopy( dv->xyz, base );\n\t\t\tfor ( k = 0 ; k < 8 ; k++ ) {\n\t\t\t\tVectorClear( around[k] );\n\t\t\t\tgood[k] = qfalse;\n\n\t\t\t\tfor ( dist = 1 ; dist <= 3 ; dist++ ) {\n\t\t\t\t\tx = i + neighbors[k][0] * dist;\n\t\t\t\t\ty = j + neighbors[k][1] * dist;\n\t\t\t\t\tif ( wrapWidth ) {\n\t\t\t\t\t\tif ( x < 0 ) {\n\t\t\t\t\t\t\tx = in.width - 1 + x;\n\t\t\t\t\t\t} else if ( x >= in.width ) {\n\t\t\t\t\t\t\tx = 1 + x - in.width;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif ( wrapHeight ) {\n\t\t\t\t\t\tif ( y < 0 ) {\n\t\t\t\t\t\t\ty = in.height - 1 + y;\n\t\t\t\t\t\t} else if ( y >= in.height ) {\n\t\t\t\t\t\t\ty = 1 + y - in.height;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( x < 0 || x >= in.width || y < 0 || y >= in.height ) {\n\t\t\t\t\t\tbreak;\t\t\t\t\t// edge of patch\n\t\t\t\t\t}\n\t\t\t\t\tVectorSubtract( in.verts[y*in.width+x].xyz, base, temp );\n\t\t\t\t\tif ( VectorNormalize( temp, temp ) == 0 ) {\n\t\t\t\t\t\tcontinue;\t\t\t\t// degenerate edge, get more dist\n\t\t\t\t\t} else {\n\t\t\t\t\t\tgood[k] = qtrue;\n\t\t\t\t\t\tVectorCopy( temp, around[k] );\n\t\t\t\t\t\tbreak;\t\t\t\t\t// good edge\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tVectorClear( sum );\n\t\t\tfor ( k = 0 ; k < 8 ; k++ ) {\n\t\t\t\tif ( !good[k] || !good[(k+1)&7] ) {\n\t\t\t\t\tcontinue;\t// didn't get two points\n\t\t\t\t}\n\t\t\t\tCrossProduct( around[(k+1)&7], around[k], normal );\n\t\t\t\tif ( VectorNormalize( normal, normal ) == 0 ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tVectorAdd( normal, sum, sum );\n\t\t\t\tcount++;\n\t\t\t}\n\t\t\tif ( count == 0 ) {\n//_printf(\"bad normal\\n\");\n\t\t\t\tcount = 1;\n\t\t\t}\n\t\t\tVectorNormalize( sum, dv->normal );\n\t\t}\n\t}\n}\n\n/*\n=================\nPutMeshOnCurve\n\nDrops the aproximating points onto the curve\n=================\n*/\nvoid PutMeshOnCurve( mesh_t in ) {\n\tint\t\ti, j, l;\n\tfloat\tprev, next;\n\n\t// put all the aproximating points on the curve\n\tfor ( i = 0 ; i < in.width ; i++ ) {\n\t\tfor ( j = 1 ; j < in.height ; j += 2 ) {\n\t\t\tfor ( l = 0 ; l < 3 ; l++ ) {\n\t\t\t\tprev = ( in.verts[j*in.width+i].xyz[l] + in.verts[(j+1)*in.width+i].xyz[l] ) * 0.5;\n\t\t\t\tnext = ( in.verts[j*in.width+i].xyz[l] + in.verts[(j-1)*in.width+i].xyz[l] ) * 0.5;\n\t\t\t\tin.verts[j*in.width+i].xyz[l] = ( prev + next ) * 0.5;\n\t\t\t}\n\t\t}\n\t}\n\n\tfor ( j = 0 ; j < in.height ; j++ ) {\n\t\tfor ( i = 1 ; i < in.width ; i += 2 ) {\n\t\t\tfor ( l = 0 ; l < 3 ; l++ ) {\n\t\t\t\tprev = ( in.verts[j*in.width+i].xyz[l] + in.verts[j*in.width+i+1].xyz[l] ) * 0.5;\n\t\t\t\tnext = ( in.verts[j*in.width+i].xyz[l] + in.verts[j*in.width+i-1].xyz[l] ) * 0.5;\n\t\t\t\tin.verts[j*in.width+i].xyz[l] = ( prev + next ) * 0.5;\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n/*\n=================\nSubdivideMesh\n\n=================\n*/\nmesh_t *SubdivideMesh( mesh_t in, float maxError, float minLength ) {\n\tint\t\t\ti, j, k, l;\n\tdrawVert_t\tprev, next, mid;\n\tvec3_t\t\tprevxyz, nextxyz, midxyz;\n\tvec3_t\t\tdelta;\n\tfloat\t\tlen;\n\tmesh_t\t\tout;\n\tdrawVert_t\texpand[MAX_EXPANDED_AXIS][MAX_EXPANDED_AXIS];\n\n\tout.width = in.width;\n\tout.height = in.height;\n\n\tfor ( i = 0 ; i < in.width ; i++ ) {\n\t\tfor ( j = 0 ; j < in.height ; j++ ) {\n\t\t\texpand[j][i] = in.verts[j*in.width+i];\n\t\t}\n\t}\n\n\tfor ( i = 0 ; i < in.height ; i++ ) {\n\t\toriginalHeights[i] = i;\n\t}\n\tfor ( i = 0 ; i < in.width ; i++ ) {\n\t\toriginalWidths[i] = i;\n\t}\n\n\t// horizontal subdivisions\n\tfor ( j = 0 ; j + 2 < out.width ; j += 2 ) {\n\t\t// check subdivided midpoints against control points\n\t\tfor ( i = 0 ; i < out.height ; i++ ) {\n\t\t\tfor ( l = 0 ; l < 3 ; l++ ) {\n\t\t\t\tprevxyz[l] = expand[i][j+1].xyz[l] - expand[i][j].xyz[l]; \n\t\t\t\tnextxyz[l] = expand[i][j+2].xyz[l] - expand[i][j+1].xyz[l]; \n\t\t\t\tmidxyz[l] = (expand[i][j].xyz[l] + expand[i][j+1].xyz[l] * 2\n\t\t\t\t\t\t+ expand[i][j+2].xyz[l] ) * 0.25;\n\t\t\t}\n\n\t\t\t// if the span length is too long, force a subdivision\n\t\t\tif ( VectorLength( prevxyz ) > minLength \n\t\t\t\t|| VectorLength( nextxyz ) > minLength ) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// see if this midpoint is off far enough to subdivide\n\t\t\tVectorSubtract( expand[i][j+1].xyz, midxyz, delta );\n\t\t\tlen = VectorLength( delta );\n\t\t\tif ( len > maxError ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif ( out.width + 2 >= MAX_EXPANDED_AXIS ) {\n\t\t\tbreak;\t// can't subdivide any more\n\t\t}\n\n\t\tif ( i == out.height ) {\n\t\t\tcontinue;\t// didn't need subdivision\n\t\t}\n\n\t\t// insert two columns and replace the peak\n\t\tout.width += 2;\n\n\t\tfor ( k = out.width - 1 ; k > j + 3 ; k-- ) {\n\t\t\toriginalWidths[k] = originalWidths[k-2];\n\t\t}\n\t\toriginalWidths[j+3] = originalWidths[j+1];\n\t\toriginalWidths[j+2] = originalWidths[j+1];\n\t\toriginalWidths[j+1] = originalWidths[j];\n\n\t\tfor ( i = 0 ; i < out.height ; i++ ) {\n\t\t\tLerpDrawVert( &expand[i][j], &expand[i][j+1], &prev );\n\t\t\tLerpDrawVert( &expand[i][j+1], &expand[i][j+2], &next );\n\t\t\tLerpDrawVert( &prev, &next, &mid );\n\n\t\t\tfor ( k = out.width - 1 ; k > j + 3 ; k-- ) {\n\t\t\t\texpand[i][k] = expand[i][k-2];\n\t\t\t}\n\t\t\texpand[i][j + 1] = prev;\n\t\t\texpand[i][j + 2] = mid;\n\t\t\texpand[i][j + 3] = next;\n\t\t}\n\n\t\t// back up and recheck this set again, it may need more subdivision\n\t\tj -= 2;\n\n\t}\n\n\t// vertical subdivisions\n\tfor ( j = 0 ; j + 2 < out.height ; j += 2 ) {\n\t\t// check subdivided midpoints against control points\n\t\tfor ( i = 0 ; i < out.width ; i++ ) {\n\t\t\tfor ( l = 0 ; l < 3 ; l++ ) {\n\t\t\t\tprevxyz[l] = expand[j+1][i].xyz[l] - expand[j][i].xyz[l]; \n\t\t\t\tnextxyz[l] = expand[j+2][i].xyz[l] - expand[j+1][i].xyz[l]; \n\t\t\t\tmidxyz[l] = (expand[j][i].xyz[l] + expand[j+1][i].xyz[l] * 2\n\t\t\t\t\t\t+ expand[j+2][i].xyz[l] ) * 0.25;\n\t\t\t}\n\n\t\t\t// if the span length is too long, force a subdivision\n\t\t\tif ( VectorLength( prevxyz ) > minLength \n\t\t\t\t|| VectorLength( nextxyz ) > minLength ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// see if this midpoint is off far enough to subdivide\n\t\t\tVectorSubtract( expand[j+1][i].xyz, midxyz, delta );\n\t\t\tlen = VectorLength( delta );\n\t\t\tif ( len > maxError ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif ( out.height + 2 >= MAX_EXPANDED_AXIS ) {\n\t\t\tbreak;\t// can't subdivide any more\n\t\t}\n\n\t\tif ( i == out.width ) {\n\t\t\tcontinue;\t// didn't need subdivision\n\t\t}\n\n\t\t// insert two columns and replace the peak\n\t\tout.height += 2;\n\n\t\tfor ( k = out.height - 1 ; k > j + 3 ; k-- ) {\n\t\t\toriginalHeights[k] = originalHeights[k-2];\n\t\t}\n\t\toriginalHeights[j+3] = originalHeights[j+1];\n\t\toriginalHeights[j+2] = originalHeights[j+1];\n\t\toriginalHeights[j+1] = originalHeights[j];\n\n\t\tfor ( i = 0 ; i < out.width ; i++ ) {\n\t\t\tLerpDrawVert( &expand[j][i], &expand[j+1][i], &prev );\n\t\t\tLerpDrawVert( &expand[j+1][i], &expand[j+2][i], &next );\n\t\t\tLerpDrawVert( &prev, &next, &mid );\n\n\t\t\tfor ( k = out.height - 1 ; k > j + 3 ; k-- ) {\n\t\t\t\texpand[k][i] = expand[k-2][i];\n\t\t\t}\n\t\t\texpand[j+1][i] = prev;\n\t\t\texpand[j+2][i] = mid;\n\t\t\texpand[j+3][i] = next;\n\t\t}\n\n\t\t// back up and recheck this set again, it may need more subdivision\n\t\tj -= 2;\n\n\t}\n\n\t// collapse the verts\n\n\tout.verts = &expand[0][0];\n\tfor ( i = 1 ; i < out.height ; i++ ) {\n\t\tmemmove( &out.verts[i*out.width], expand[i], out.width * sizeof(drawVert_t) );\n\t}\n\n\treturn CopyMesh(&out);\n}\n\n/*\n================\nProjectPointOntoVector\n================\n*/\nvoid ProjectPointOntoVector( vec3_t point, vec3_t vStart, vec3_t vEnd, vec3_t vProj )\n{\n\tvec3_t pVec, vec;\n\n\tVectorSubtract( point, vStart, pVec );\n\tVectorSubtract( vEnd, vStart, vec );\n\tVectorNormalize( vec, vec );\n\t// project onto the directional vector for this segment\n\tVectorMA( vStart, DotProduct( pVec, vec ), vec, vProj );\n}\n\n/*\n================\nRemoveLinearMeshColumsRows\n================\n*/\nmesh_t *RemoveLinearMeshColumnsRows( mesh_t *in ) {\n\tint i, j, k;\n\tfloat len, maxLength;\n\tvec3_t proj, dir;\n\tmesh_t out;\n\tdrawVert_t\texpand[MAX_EXPANDED_AXIS][MAX_EXPANDED_AXIS];\n\n\tout.width = in->width;\n\tout.height = in->height;\n\n\tfor ( i = 0 ; i < in->width ; i++ ) {\n\t\tfor ( j = 0 ; j < in->height ; j++ ) {\n\t\t\texpand[j][i] = in->verts[j*in->width+i];\n\t\t}\n\t}\n\n\tfor ( j = 1 ; j < out.width - 1; j++ ) {\n\t\tmaxLength = 0;\n\t\tfor ( i = 0 ; i < out.height ; i++ ) {\n\t\t\tProjectPointOntoVector(expand[i][j].xyz, expand[i][j-1].xyz, expand[i][j+1].xyz, proj);\n\t\t\tVectorSubtract(expand[i][j].xyz, proj, dir);\n\t\t\tlen = VectorLength(dir);\n\t\t\tif (len > maxLength) {\n\t\t\t\tmaxLength = len;\n\t\t\t}\n\t\t}\n\t\tif (maxLength < 0.1)\n\t\t{\n\t\t\tout.width--;\n\t\t\tfor ( i = 0 ; i < out.height ; i++ ) {\n\t\t\t\tfor (k = j; k < out.width; k++) {\n\t\t\t\t\texpand[i][k] = expand[i][k+1];\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (k = j; k < out.width; k++) {\n\t\t\t\toriginalWidths[k] = originalWidths[k+1];\n\t\t\t}\n\t\t\tj--;\n\t\t}\n\t}\n\tfor ( j = 1 ; j < out.height - 1; j++ ) {\n\t\tmaxLength = 0;\n\t\tfor ( i = 0 ; i < out.width ; i++ ) {\n\t\t\tProjectPointOntoVector(expand[j][i].xyz, expand[j-1][i].xyz, expand[j+1][i].xyz, proj);\n\t\t\tVectorSubtract(expand[j][i].xyz, proj, dir);\n\t\t\tlen = VectorLength(dir);\n\t\t\tif (len > maxLength) {\n\t\t\t\tmaxLength = len;\n\t\t\t}\n\t\t}\n\t\tif (maxLength < 0.1)\n\t\t{\n\t\t\tout.height--;\n\t\t\tfor ( i = 0 ; i < out.width ; i++ ) {\n\t\t\t\tfor (k = j; k < out.height; k++) {\n\t\t\t\t\texpand[k][i] = expand[k+1][i];\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (k = j; k < out.height; k++) {\n\t\t\t\toriginalHeights[k] = originalHeights[k+1];\n\t\t\t}\n\t\t\tj--;\n\t\t}\n\t}\n\t// collapse the verts\n\tout.verts = &expand[0][0];\n\tfor ( i = 1 ; i < out.height ; i++ ) {\n\t\tmemmove( &out.verts[i*out.width], expand[i], out.width * sizeof(drawVert_t) );\n\t}\n\n\treturn CopyMesh(&out);\n}\n\n/*\n============\nLerpDrawVertAmount\n============\n*/\nvoid LerpDrawVertAmount( drawVert_t *a, drawVert_t *b, float amount, drawVert_t *out ) {\n\tout->xyz[0] = a->xyz[0] + amount * (b->xyz[0] - a->xyz[0]);\n\tout->xyz[1] = a->xyz[1] + amount * (b->xyz[1] - a->xyz[1]);\n\tout->xyz[2] = a->xyz[2] + amount * (b->xyz[2] - a->xyz[2]);\n\n\tout->st[0] = a->st[0] + amount * (b->st[0] - a->st[0]);\n\tout->st[1] = a->st[1] + amount * (b->st[1] - a->st[1]);\n\n\tout->lightmap[0] = a->lightmap[0] + amount * (b->lightmap[0] - a->lightmap[0]);\n\tout->lightmap[1] = a->lightmap[1] + amount * (b->lightmap[1] - a->lightmap[1]);\n\n\tout->color[0] = a->color[0] + amount * (b->color[0] - a->color[0]);\n\tout->color[1] = a->color[1] + amount * (b->color[1] - a->color[1]);\n\tout->color[2] = a->color[2] + amount * (b->color[2] - a->color[2]);\n\tout->color[3] = a->color[3] + amount * (b->color[3] - a->color[3]);\n\n\tout->normal[0] = a->normal[0] + amount * (b->normal[0] - a->normal[0]);\n\tout->normal[1] = a->normal[1] + amount * (b->normal[1] - a->normal[1]);\n\tout->normal[2] = a->normal[2] + amount * (b->normal[2] - a->normal[2]);\n\tVectorNormalize(out->normal, out->normal);\n}\n\n/*\n=================\nSubdivideMeshQuads\n=================\n*/\nmesh_t *SubdivideMeshQuads( mesh_t *in, float minLength, int maxsize, int widthtable[], int heighttable[]) {\n\tint\t\t\ti, j, k, w, h, maxsubdivisions, subdivisions;\n\tvec3_t\t\tdir;\n\tfloat\t\tlength, maxLength, amount;\n\tmesh_t\t\tout;\n\tdrawVert_t\texpand[MAX_EXPANDED_AXIS][MAX_EXPANDED_AXIS];\n\n\tout.width = in->width;\n\tout.height = in->height;\n\n\tfor ( i = 0 ; i < in->width ; i++ ) {\n\t\tfor ( j = 0 ; j < in->height ; j++ ) {\n\t\t\texpand[j][i] = in->verts[j*in->width+i];\n\t\t}\n\t}\n\n\tif (maxsize > MAX_EXPANDED_AXIS)\n\t\tError(\"SubdivideMeshQuads: maxsize > MAX_EXPANDED_AXIS\");\n\n\t// horizontal subdivisions\n\n\tmaxsubdivisions = (maxsize - in->width) / (in->width - 1);\n\n\tfor ( w = 0, j = 0 ; w < in->width - 1; w++, j += subdivisions + 1) {\n\t\tmaxLength = 0;\n\t\tfor ( i = 0 ; i < out.height ; i++ ) {\n\t\t\tVectorSubtract(expand[i][j+1].xyz, expand[i][j].xyz, dir);\n\t\t\tlength = VectorLength( dir );\n\t\t\tif (length > maxLength) {\n\t\t\t\tmaxLength = length;\n\t\t\t}\n\t\t}\n\t\t\n\t\tsubdivisions = (int) (maxLength / minLength);\n\t\tif (subdivisions > maxsubdivisions)\n\t\t\tsubdivisions = maxsubdivisions;\n\n\t\twidthtable[w] = subdivisions + 1;\n\t\tif (subdivisions <= 0)\n\t\t\tcontinue;\n\n\t\tout.width += subdivisions;\n\n\t\tfor ( k = out.width - 1; k >= j + subdivisions; k-- ) {\n\t\t\toriginalWidths[k] = originalWidths[k-subdivisions];\n\t\t}\n\t\tfor (k = 1; k <= subdivisions; k++) {\n\t\t\toriginalWidths[j+k] = originalWidths[j];\n\t\t}\n\n\t\tfor ( i = 0 ; i < out.height ; i++ ) {\n\t\t\tfor ( k = out.width - 1 ; k > j + subdivisions; k-- ) {\n\t\t\t\texpand[i][k] = expand[i][k-subdivisions];\n\t\t\t}\n\t\t\tfor (k = 1; k <= subdivisions; k++)\n\t\t\t{\n\t\t\t\tamount = (float) k / (subdivisions + 1);\n\t\t\t\tLerpDrawVertAmount(&expand[i][j], &expand[i][j+subdivisions+1], amount, &expand[i][j+k]);\n\t\t\t}\n\t\t}\n\t}\n\n\tmaxsubdivisions = (maxsize - in->height) / (in->height - 1);\n\n\tfor ( h = 0, j = 0 ; h < in->height - 1; h++, j += subdivisions + 1) {\n\t\tmaxLength = 0;\n\t\tfor ( i = 0 ; i < out.width ; i++ ) {\n\t\t\tVectorSubtract(expand[j+1][i].xyz, expand[j][i].xyz, dir);\n\t\t\tlength = VectorLength( dir );\n\t\t\tif (length  > maxLength) {\n\t\t\t\tmaxLength = length;\n\t\t\t}\n\t\t}\n\t\t\n\t\tsubdivisions = (int) (maxLength / minLength);\n\t\tif (subdivisions > maxsubdivisions)\n\t\t\tsubdivisions = maxsubdivisions;\n\n\t\theighttable[h] = subdivisions + 1;\n\t\tif (subdivisions <= 0)\n\t\t\tcontinue;\n\n\t\tout.height += subdivisions;\n\n\t\tfor ( k = out.height - 1; k >= j + subdivisions; k-- ) {\n\t\t\toriginalHeights[k] = originalHeights[k-subdivisions];\n\t\t}\n\t\tfor (k = 1; k <= subdivisions; k++) {\n\t\t\toriginalHeights[j+k] = originalHeights[j];\n\t\t}\n\n\t\tfor ( i = 0 ; i < out.width ; i++ ) {\n\t\t\tfor ( k = out.height - 1 ; k > j + subdivisions; k-- ) {\n\t\t\t\texpand[k][i] = expand[k-subdivisions][i];\n\t\t\t}\n\t\t\tfor (k = 1; k <= subdivisions; k++)\n\t\t\t{\n\t\t\t\tamount = (float) k / (subdivisions + 1);\n\t\t\t\tLerpDrawVertAmount(&expand[j][i], &expand[j+subdivisions+1][i], amount, &expand[j+k][i]);\n\t\t\t}\n\t\t}\n\t}\n\n\t// collapse the verts\n\tout.verts = &expand[0][0];\n\tfor ( i = 1 ; i < out.height ; i++ ) {\n\t\tmemmove( &out.verts[i*out.width], expand[i], out.width * sizeof(drawVert_t) );\n\t}\n\n\treturn CopyMesh(&out);\n}\n"
  },
  {
    "path": "q3map/mesh.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n// mesh.h\n\n\ntypedef struct {\n\tint\t\t\twidth, height;\n\tdrawVert_t\t*verts;\n} mesh_t;\n\n#define\tMAX_EXPANDED_AXIS\t\t128\n\nextern\tint\toriginalWidths[MAX_EXPANDED_AXIS];\nextern\tint\toriginalHeights[MAX_EXPANDED_AXIS];\n\nvoid FreeMesh( mesh_t *m );\nmesh_t *CopyMesh( mesh_t *mesh );\nvoid PrintMesh( mesh_t *m );\nmesh_t *TransposeMesh( mesh_t *in );\nvoid InvertMesh( mesh_t *m );\nmesh_t *SubdivideMesh( mesh_t in, float maxError, float minLength );\nmesh_t *SubdivideMeshQuads( mesh_t *in, float minLength, int maxsize, int widthtable[], int heighttable[]);\nmesh_t *RemoveLinearMeshColumnsRows( mesh_t *in );\nvoid MakeMeshNormals( mesh_t in );\nvoid PutMeshOnCurve( mesh_t in );\n\n\nvoid MakeNormalVectors (vec3_t forward, vec3_t right, vec3_t up);\n"
  },
  {
    "path": "q3map/misc_model.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n#include \"aselib.h\"\n#ifdef _WIN32\n#ifdef _TTIMOBUILD\n#include \"pakstuff.h\"\n#else\n#include \"../libs/pakstuff.h\"\n#endif\n#endif\n\n\ntypedef struct {\n\tchar\t\tmodelName[1024];\n\tmd3Header_t\t*header;\n} loadedModel_t;\n\nint\t\tc_triangleModels;\nint\t\tc_triangleSurfaces;\nint\t\tc_triangleVertexes;\nint\t\tc_triangleIndexes;\n\n\n#define\tMAX_LOADED_MODELS\t1024\nloadedModel_t\t\tloadedModels[MAX_LOADED_MODELS];\nint\t\t\t\t\tnumLoadedModels;\n\n/*\n=================\nR_LoadMD3\n=================\n*/\n#define\tLL(x) x=LittleLong(x)\nmd3Header_t *R_LoadMD3( const char *mod_name ) {\n\tint\t\t\t\t\ti, j;\n\tmd3Header_t\t\t\t*md3;\n    md3Frame_t\t\t\t*frame;\n\tmd3Surface_t\t\t*surf;\n\tmd3Triangle_t\t\t*tri;\n\tmd3St_t\t\t\t\t*st;\n\tmd3XyzNormal_t\t\t*xyz;\n\tint\t\t\t\t\tversion;\n\tchar\t\t\t\tfilename[1024];\n\tint\t\t\t\t\tlen;\n\n\tsprintf( filename, \"%s%s\", gamedir, mod_name );\n\tlen = TryLoadFile( filename, (void **)&md3 );\n#ifdef _WIN32\n  if ( len <= 0 ) {\n    len = PakLoadAnyFile(filename, (void **)&md3);\n  }\n#endif\n\tif ( len <= 0 ) {\n\t  return NULL;\n\t}\n\n  version = LittleLong (md3->version);\n\tif (version != MD3_VERSION) {\n\t\t_printf( \"R_LoadMD3: %s has wrong version (%i should be %i)\\n\",\n\t\t\t\t mod_name, version, MD3_VERSION);\n\t\treturn NULL;\n\t}\n\n    LL(md3->ident);\n    LL(md3->version);\n    LL(md3->numFrames);\n    LL(md3->numTags);\n    LL(md3->numSurfaces);\n    LL(md3->numSkins);\n    LL(md3->ofsFrames);\n    LL(md3->ofsTags);\n    LL(md3->ofsSurfaces);\n    LL(md3->ofsEnd);\n\n\tif ( md3->numFrames < 1 ) {\n\t\t_printf( \"R_LoadMD3: %s has no frames\\n\", mod_name );\n\t\treturn NULL;\n\t}\n\n    // we don't need to swap tags in the renderer, they aren't used\n    \n\t// swap all the frames\n    frame = (md3Frame_t *) ( (byte *)md3 + md3->ofsFrames );\n    for ( i = 0 ; i < md3->numFrames ; i++, frame++) {\n    \tframe->radius = LittleFloat( frame->radius );\n        for ( j = 0 ; j < 3 ; j++ ) {\n            frame->bounds[0][j] = LittleFloat( frame->bounds[0][j] );\n            frame->bounds[1][j] = LittleFloat( frame->bounds[1][j] );\n\t    \tframe->localOrigin[j] = LittleFloat( frame->localOrigin[j] );\n        }\n\t}\n\n\t// swap all the surfaces\n\tsurf = (md3Surface_t *) ( (byte *)md3 + md3->ofsSurfaces );\n\tfor ( i = 0 ; i < md3->numSurfaces ; i++) {\n\n        LL(surf->ident);\n        LL(surf->flags);\n        LL(surf->numFrames);\n        LL(surf->numShaders);\n        LL(surf->numTriangles);\n        LL(surf->ofsTriangles);\n        LL(surf->numVerts);\n        LL(surf->ofsShaders);\n        LL(surf->ofsSt);\n        LL(surf->ofsXyzNormals);\n        LL(surf->ofsEnd);\n\t\t\n\t\tif ( surf->numVerts > SHADER_MAX_VERTEXES ) {\n\t\t\tError (\"R_LoadMD3: %s has more than %i verts on a surface (%i)\",\n\t\t\t\tmod_name, SHADER_MAX_VERTEXES, surf->numVerts );\n\t\t}\n\t\tif ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) {\n\t\t\tError (\"R_LoadMD3: %s has more than %i triangles on a surface (%i)\",\n\t\t\t\tmod_name, SHADER_MAX_INDEXES / 3, surf->numTriangles );\n\t\t}\n\n\t\t// swap all the triangles\n\t\ttri = (md3Triangle_t *) ( (byte *)surf + surf->ofsTriangles );\n\t\tfor ( j = 0 ; j < surf->numTriangles ; j++, tri++ ) {\n\t\t\tLL(tri->indexes[0]);\n\t\t\tLL(tri->indexes[1]);\n\t\t\tLL(tri->indexes[2]);\n\t\t}\n\n\t\t// swap all the ST\n        st = (md3St_t *) ( (byte *)surf + surf->ofsSt );\n        for ( j = 0 ; j < surf->numVerts ; j++, st++ ) {\n            st->st[0] = LittleFloat( st->st[0] );\n            st->st[1] = LittleFloat( st->st[1] );\n        }\n\n\t\t// swap all the XyzNormals\n        xyz = (md3XyzNormal_t *) ( (byte *)surf + surf->ofsXyzNormals );\n        for ( j = 0 ; j < surf->numVerts * surf->numFrames ; j++, xyz++ ) \n\t\t{\n            xyz->xyz[0] = LittleShort( xyz->xyz[0] );\n            xyz->xyz[1] = LittleShort( xyz->xyz[1] );\n            xyz->xyz[2] = LittleShort( xyz->xyz[2] );\n\n            xyz->normal = LittleShort( xyz->normal );\n        }\n\n\n\t\t// find the next surface\n\t\tsurf = (md3Surface_t *)( (byte *)surf + surf->ofsEnd );\n\t}\n\n\treturn md3;\n}\n\n\n/*\n================\nLoadModel\n================\n*/\nmd3Header_t *LoadModel( const char *modelName ) {\n\tint\t\t\t\ti;\n\tloadedModel_t\t*lm;\n\n\t// see if we already have it loaded\n\tfor ( i = 0, lm = loadedModels ; i < numLoadedModels ; i++, lm++ ) {\n\t\tif ( !strcmp( modelName, lm->modelName ) ) {\n\t\t\treturn lm->header;\n\t\t}\n\t}\n\n\t// load it\n\tif ( numLoadedModels == MAX_LOADED_MODELS ) {\n\t\tError( \"MAX_LOADED_MODELS\" );\n\t}\n\tnumLoadedModels++;\n\n\tstrcpy( lm->modelName, modelName );\n\n\tlm->header = R_LoadMD3( modelName );\n\n\treturn lm->header;\n}\n\n/*\n============\nInsertMD3Model\n\nConvert a model entity to raw geometry surfaces and insert it in the tree\n============\n*/\nvoid InsertMD3Model( const char *modelName, vec3_t origin, float angle, tree_t *tree ) {\n\tint\t\t\t\t\ti, j;\n\tmd3Header_t\t\t\t*md3;\n\tmd3Surface_t\t\t*surf;\n\tmd3Shader_t\t\t\t*shader;\n\tmd3Triangle_t\t\t*tri;\n\tmd3St_t\t\t\t\t*st;\n\tmd3XyzNormal_t\t\t*xyz;\n\tdrawVert_t\t\t\t*outv;\n\tfloat\t\t\t\tlat, lng;\n\tfloat\t\t\t\tangleCos, angleSin;\n\tmapDrawSurface_t\t*out;\n\tvec3_t\t\t\t\ttemp;\n\n\tangle = angle / 180 * Q_PI;\n\tangleCos = cos( angle );\n\tangleSin = sin( angle );\n\n\t// load the model\n\tmd3 = LoadModel( modelName );\n\tif ( !md3 ) {\n\t\treturn;\n\t}\n\n\t// each md3 surface will become a new bsp surface\n\n\tc_triangleModels++;\n\tc_triangleSurfaces += md3->numSurfaces;\n\n\t// expand, translate, and rotate the vertexes\n\t// swap all the surfaces\n\tsurf = (md3Surface_t *) ( (byte *)md3 + md3->ofsSurfaces );\n\tfor ( i = 0 ; i < md3->numSurfaces ; i++) {\n\t\t// allocate a surface\n\t\tout = AllocDrawSurf();\n\t\tout->miscModel = qtrue;\n\n        shader = (md3Shader_t *) ( (byte *)surf + surf->ofsShaders );\n\n\t\tout->shaderInfo = ShaderInfoForShader( shader->name );\n\n\t\tout->numVerts = surf->numVerts;\n\t\tout->verts = malloc( out->numVerts * sizeof( out->verts[0] ) );\n\n\t\tout->numIndexes = surf->numTriangles * 3;\n\t\tout->indexes = malloc( out->numIndexes * sizeof( out->indexes[0] ) );\n\n\t\tout->lightmapNum = -1;\n\t\tout->fogNum = -1;\n\n\t\t// emit the indexes\n\t\tc_triangleIndexes += surf->numTriangles * 3;\n\t\ttri = (md3Triangle_t *) ( (byte *)surf + surf->ofsTriangles );\n\t\tfor ( j = 0 ; j < surf->numTriangles ; j++, tri++ ) {\n\t\t\tout->indexes[j*3+0] = tri->indexes[0];\n\t\t\tout->indexes[j*3+1] = tri->indexes[1];\n\t\t\tout->indexes[j*3+2] = tri->indexes[2];\n\t\t}\n\n\t\t// emit the vertexes\n        st = (md3St_t *) ( (byte *)surf + surf->ofsSt );\n        xyz = (md3XyzNormal_t *) ( (byte *)surf + surf->ofsXyzNormals );\n\n\t\tc_triangleVertexes += surf->numVerts;\n\t\tfor ( j = 0 ; j < surf->numVerts ; j++, st++, xyz++ ) {\n\t\t\toutv = &out->verts[ j ];\n\n\t\t\toutv->st[0] = st->st[0];\n\t\t\toutv->st[1] = st->st[1];\n\n\t\t\toutv->lightmap[0] = 0;\n\t\t\toutv->lightmap[1] = 0;\n\n\t\t\t// the colors will be set by the lighting pass\n\t\t\toutv->color[0] = 255;\n\t\t\toutv->color[1] = 255;\n\t\t\toutv->color[2] = 255;\n\t\t\toutv->color[3] = 255;\n\n\t\t\toutv->xyz[0] = origin[0] + MD3_XYZ_SCALE * ( xyz->xyz[0] * angleCos - xyz->xyz[1] * angleSin );\n\t\t\toutv->xyz[1] = origin[1] + MD3_XYZ_SCALE * ( xyz->xyz[0] * angleSin +  xyz->xyz[1] * angleCos );\n\t\t\toutv->xyz[2] = origin[2] + MD3_XYZ_SCALE * ( xyz->xyz[2] );\n\n\t\t\t// decode the lat/lng normal to a 3 float normal\n\t\t\tlat = ( xyz->normal >> 8 ) & 0xff;\n\t\t\tlng = ( xyz->normal & 0xff );\n\t\t\tlat *= Q_PI/128;\n\t\t\tlng *= Q_PI/128;\n\n\t\t\ttemp[0] = cos(lat) * sin(lng);\n\t\t\ttemp[1] = sin(lat) * sin(lng);\n\t\t\ttemp[2] = cos(lng);\n\n\t\t\t// rotate the normal\n\t\t\toutv->normal[0] = temp[0] * angleCos - temp[1] * angleSin;\n\t\t\toutv->normal[1] = temp[0] * angleSin +  temp[1] * angleCos;\n\t\t\toutv->normal[2] = temp[2];\n\t\t}\n\n\t\t// find the next surface\n\t\tsurf = (md3Surface_t *)( (byte *)surf + surf->ofsEnd );\n\t}\n\n}\n\n//==============================================================================\n\n\n/*\n============\nInsertASEModel\n\nConvert a model entity to raw geometry surfaces and insert it in the tree\n============\n*/\nvoid InsertASEModel( const char *modelName, vec3_t origin, float angle, tree_t *tree ) {\n\tint\t\t\t\t\ti, j;\n\tdrawVert_t\t\t\t*outv;\n\tfloat\t\t\t\tangleCos, angleSin;\n\tmapDrawSurface_t\t*out;\n\tint\t\t\t\t\tnumSurfaces;\n\tconst char\t\t\t*name;\n\tpolyset_t\t\t\t*pset;\n\tint\t\t\t\t\tnumFrames;\n\tchar\t\t\t\tfilename[1024];\n\n\tsprintf( filename, \"%s%s\", gamedir, modelName );\n\n\tangle = angle / 180 * Q_PI;\n\tangleCos = cos( angle );\n\tangleSin = sin( angle );\n\n\t// load the model\n\tASE_Load( filename, qfalse, qfalse );\n\n\t// each ase surface will become a new bsp surface\n\tnumSurfaces = ASE_GetNumSurfaces();\n\n\tc_triangleModels++;\n\tc_triangleSurfaces += numSurfaces;\n\n\t// expand, translate, and rotate the vertexes\n\t// swap all the surfaces\n\tfor ( i = 0 ; i < numSurfaces ; i++) {\n\t\tname = ASE_GetSurfaceName( i );\n\n\t\tpset = ASE_GetSurfaceAnimation( i, &numFrames, -1, -1, -1 );\n\t\tif ( !name || !pset ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// allocate a surface\n\t\tout = AllocDrawSurf();\n\t\tout->miscModel = qtrue;\n\n\t\tout->shaderInfo = ShaderInfoForShader( pset->materialname );\n\n\t\tout->numVerts = 3 * pset->numtriangles;\n\t\tout->verts = malloc( out->numVerts * sizeof( out->verts[0] ) );\n\n\t\tout->numIndexes = 3 * pset->numtriangles;\n\t\tout->indexes = malloc( out->numIndexes * sizeof( out->indexes[0] ) );\n\n\t\tout->lightmapNum = -1;\n\t\tout->fogNum = -1;\n\n\t\t// emit the indexes\n\t\tc_triangleIndexes += out->numIndexes;\n\t\tfor ( j = 0 ; j < out->numIndexes ; j++ ) {\n\t\t\tout->indexes[j] = j;\n\t\t}\n\n\t\t// emit the vertexes\n\t\tc_triangleVertexes += out->numVerts;\n\t\tfor ( j = 0 ; j < out->numVerts ; j++ ) {\n\t\t\tint\t\tindex;\n\t\t\ttriangle_t\t*tri;\n\n\t\t\tindex = j % 3;\n\t\t\ttri = &pset->triangles[ j / 3 ];\n\n\t\t\toutv = &out->verts[ j ];\n\n\t\t\toutv->st[0] = tri->texcoords[index][0];\n\t\t\toutv->st[1] = tri->texcoords[index][1];\n\n\t\t\toutv->lightmap[0] = 0;\n\t\t\toutv->lightmap[1] = 0;\n\n\t\t\t// the colors will be set by the lighting pass\n\t\t\toutv->color[0] = 255;\n\t\t\toutv->color[1] = 255;\n\t\t\toutv->color[2] = 255;\n\t\t\toutv->color[3] = 255;\n\n\t\t\toutv->xyz[0] = origin[0] + tri->verts[index][0];\n\t\t\toutv->xyz[1] = origin[1] + tri->verts[index][1];\n\t\t\toutv->xyz[2] = origin[2] + tri->verts[index][2];\n\n\t\t\t// rotate the normal\n\t\t\toutv->normal[0] = tri->normals[index][0];\n\t\t\toutv->normal[1] = tri->normals[index][1];\n\t\t\toutv->normal[2] = tri->normals[index][2];\n\t\t}\n\t}\n\n}\n\n\n//==============================================================================\n\n\n\n/*\n=====================\nAddTriangleModels\n=====================\n*/\nvoid AddTriangleModels( tree_t *tree ) {\n\tint\t\t\tentity_num;\n\tentity_t\t*entity;\n\n\tqprintf(\"----- AddTriangleModels -----\\n\");\n\n\tfor ( entity_num=1 ; entity_num< num_entities ; entity_num++ ) {\n\t\tentity = &entities[entity_num];\n\t\n\t\t// convert misc_models into raw geometry\n\t\tif ( !Q_stricmp( \"misc_model\", ValueForKey( entity, \"classname\" ) ) ) {\n\t\t\tconst char\t*model;\n\t\t\tvec3_t\torigin;\n\t\t\tfloat\tangle;\n\n\t\t\t// get the angle for rotation  FIXME: support full matrix positioning\n\t\t\tangle = FloatForKey( entity, \"angle\" );\n\n\t\t\tGetVectorForKey( entity, \"origin\", origin );\n\n\t\t\tmodel = ValueForKey( entity, \"model\" );\n\t\t\tif ( !model[0] ) {\n\t\t\t\t_printf(\"WARNING: misc_model at %i %i %i without a model key\\n\", (int)origin[0],\n\t\t\t\t\t(int)origin[1], (int)origin[2] );\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( strstr( model, \".md3\" ) || strstr( model, \".MD3\" ) ) {\n\t\t\t\tInsertMD3Model( model, origin, angle, tree );\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( strstr( model, \".ase\" ) || strstr( model, \".ASE\" ) ) {\n\t\t\t\tInsertASEModel( model, origin, angle, tree );\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t_printf( \"Unknown misc_model type: %s\\n\", model );\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\tqprintf( \"%5i triangle models\\n\", c_triangleModels );\n\tqprintf( \"%5i triangle surfaces\\n\", c_triangleSurfaces );\n\tqprintf( \"%5i triangle vertexes\\n\", c_triangleVertexes );\n\tqprintf( \"%5i triangle indexes\\n\", c_triangleIndexes );\n}\n\n"
  },
  {
    "path": "q3map/nodraw.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n\nvec3_t draw_mins, draw_maxs;\nqboolean\tdrawflag;\n\nvoid Draw_ClearWindow (void)\n{\n}\n\n//============================================================\n\n#define\tGLSERV_PORT\t25001\n\n\nvoid GLS_BeginScene (void)\n{\n}\n\nvoid GLS_Winding (winding_t *w, int code)\n{\n}\n\nvoid GLS_EndScene (void)\n{\n}\n"
  },
  {
    "path": "q3map/patch.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"qbsp.h\"\n\n\nvoid PrintCtrl( vec3_t ctrl[9] ) {\n\tint\t\ti, j;\n\n\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\tfor ( j = 0 ; j < 3 ; j++ ) {\n\t\t\t_printf(\"(%5.2f %5.2f %5.2f) \", ctrl[i*3+j][0], ctrl[i*3+j][1], ctrl[i*3+j][2] );\n\t\t}\n\t\t_printf(\"\\n\");\n\t}\n}\n\n/*\n================\nDrawSurfaceForMesh\n================\n*/\nmapDrawSurface_t\t*DrawSurfaceForMesh( mesh_t *m ) {\n\tmapDrawSurface_t\t*ds;\n\tint\t\t\t\ti, j;\n\tmesh_t\t\t\t*copy;\n\n\t// to make valid normals for patches with degenerate edges,\n\t// we need to make a copy of the mesh and put the aproximating\n\t// points onto the curve\n\tcopy = CopyMesh( m );\n\tPutMeshOnCurve( *copy );\n\tMakeMeshNormals( *copy );\n\tfor ( j = 0 ; j < m->width ; j++ ) {\n\t\tfor ( i = 0 ; i < m->height ; i++ ) {\n\t\t\tVectorCopy( copy->verts[i*m->width+j].normal, m->verts[i*m->width+j].normal );\n\t\t}\n\t}\n\tFreeMesh( copy );\n\n\tds = AllocDrawSurf();\n\tds->mapBrush = NULL;\n\tds->side = NULL;\n\n\tds->patch = qtrue;\n\tds->patchWidth = m->width;\n\tds->patchHeight = m->height;\n\tds->numVerts = ds->patchWidth * ds->patchHeight;\n\tds->verts = malloc( ds->numVerts * sizeof( *ds->verts ) );\n\tmemcpy( ds->verts, m->verts, ds->numVerts * sizeof( *ds->verts ) );\n\n\tds->lightmapNum = -1;\n\tds->fogNum = -1;\n\n\treturn ds;\n}\n\n/*\n=================\nParsePatch\n\nCreates a mapDrawSurface_t from the patch text\n=================\n*/\nvoid ParsePatch( void ) {\n\tvec_t\t\tinfo[5];\n\tint\t\t\ti, j;\n\tparseMesh_t\t*pm;\n\tchar\t\ttexture[MAX_QPATH];\n\tchar\t\tshader[MAX_QPATH];\n\tmesh_t\t\tm;\n\tdrawVert_t\t*verts;\n  epair_t *ep;\n\n\tMatchToken( \"{\" );\n\n\t// get texture\n\tGetToken (qtrue);\n\tstrcpy( texture, token );\n\n\t// save the shader name for retexturing\n\tif ( numMapIndexedShaders == MAX_MAP_BRUSHSIDES ) {\n\t\tError( \"MAX_MAP_BRUSHSIDES\" );\n\t}\n\tstrcpy( mapIndexedShaders[numMapIndexedShaders], texture );\n\tnumMapIndexedShaders++;\n\n\n\tParse1DMatrix( 5, info );\n\tm.width = info[0];\n\tm.height = info[1];\n\tm.verts = verts = malloc( m.width * m.height * sizeof( m.verts[0] ) );\n\n\tif ( m.width < 0 || m.width > MAX_PATCH_SIZE\n\t\t|| m.height < 0 || m.height > MAX_PATCH_SIZE ) {\n\t\tError(\"ParsePatch: bad size\");\n\t}\n\n\tMatchToken( \"(\" );\n\tfor ( j = 0 ; j < m.width ; j++ ) {\n\t\tMatchToken( \"(\" );\n\t\tfor ( i = 0 ; i < m.height ; i++ ) {\n\t\t\tParse1DMatrix( 5, verts[i*m.width+j].xyz );\n\t\t}\n\t\tMatchToken( \")\" );\n\t}\n\tMatchToken( \")\" );\n\n  // if brush primitives format, we may have some epairs to ignore here\n  GetToken(qtrue);\n  if (g_bBrushPrimit!=BPRIMIT_OLDBRUSHES && strcmp(token,\"}\"))\n  {\n    // NOTE: we leak that!\n    ep = ParseEpair();\n  }\n  else\n    UnGetToken();\n\n\tMatchToken( \"}\" );\n\tMatchToken( \"}\" );\n\n\tif ( noCurveBrushes ) {\n\t\treturn;\n\t}\n\n\t// find default flags and values\n\tpm = malloc( sizeof( *pm ) );\n\tmemset( pm, 0, sizeof( *pm ) );\n\n\tsprintf( shader, \"textures/%s\", texture );\n\tpm->shaderInfo = ShaderInfoForShader( shader ); \n\tpm->mesh = m;\n\n\t// link to the entity\n\tpm->next = mapent->patches;\n\tmapent->patches = pm;\n}\n\n\nvoid GrowGroup_r( int patchNum, int patchCount, const byte *bordering, byte *group ) {\n\tint\t\ti;\n\tconst byte *row;\n\n\tif ( group[patchNum] ) {\n\t\treturn;\n\t}\n\tgroup[patchNum] = 1;\n\trow = bordering + patchNum * patchCount;\n\tfor ( i = 0 ; i < patchCount ; i++ ) {\n\t\tif ( row[i] ) {\n\t\t\tGrowGroup_r( i, patchCount, bordering, group );\n\t\t}\n\t}\n}\n\n\n/*\n=====================\nPatchMapDrawSurfs\n\nAny patches that share an edge need to choose their\nlevel of detail as a unit, otherwise the edges would\npull apart.\n=====================\n*/\nvoid PatchMapDrawSurfs( entity_t *e ) {\n\tparseMesh_t\t\t\t*pm;\n\tparseMesh_t\t\t\t*check, *scan;\n\tmapDrawSurface_t\t*ds;\n\tint\t\t\t\t\tpatchCount, groupCount;\n\tint\t\t\t\t\ti, j, k, l, c1, c2;\n\tdrawVert_t\t\t\t*v1, *v2;\n\tvec3_t\t\t\t\tbounds[2];\n\tbyte\t\t\t\t*bordering;\n\tparseMesh_t\t\t\t*meshes[MAX_MAP_DRAW_SURFS];\n\tqboolean\t\t\tgrouped[MAX_MAP_DRAW_SURFS];\n\tbyte\t\t\t\tgroup[MAX_MAP_DRAW_SURFS];\n\n\tqprintf( \"----- PatchMapDrawSurfs -----\\n\" );\n\n\tpatchCount = 0;\n\tfor ( pm = e->patches ; pm ; pm = pm->next  ) {\n\t\tmeshes[patchCount] = pm;\n\t\tpatchCount++;\n\t}\n\n\tif ( !patchCount ) {\n\t\treturn;\n\t}\n\tbordering = malloc( patchCount * patchCount );\n\tmemset( bordering, 0, patchCount * patchCount );\n\n\t// build the bordering matrix\n\tfor ( k = 0 ; k < patchCount ; k++ ) {\n\t\tbordering[k*patchCount+k] = 1;\n\n\t\tfor ( l = k+1 ; l < patchCount ; l++ ) {\n\t\t\tcheck = meshes[k];\n\t\t\tscan = meshes[l];\n\t\t\tc1 = scan->mesh.width * scan->mesh.height;\n\t\t\tv1 = scan->mesh.verts;\n\n\t\t\tfor ( i = 0 ; i < c1 ; i++, v1++ ) {\n\t\t\t\tc2 = check->mesh.width * check->mesh.height;\n\t\t\t\tv2 = check->mesh.verts;\n\t\t\t\tfor ( j = 0 ; j < c2 ; j++, v2++ ) {\n\t\t\t\t\tif ( fabs( v1->xyz[0] - v2->xyz[0] ) < 1.0\n\t\t\t\t\t\t&& fabs( v1->xyz[1] - v2->xyz[1] ) < 1.0\n\t\t\t\t\t\t&& fabs( v1->xyz[2] - v2->xyz[2] ) < 1.0 ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( j != c2 ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( i != c1 ) {\n\t\t\t\t// we have a connection\n\t\t\t\tbordering[k*patchCount+l] =\n\t\t\t\tbordering[l*patchCount+k] = 1;\n\t\t\t} else {\n\t\t\t\t// no connection\n\t\t\t\tbordering[k*patchCount+l] =\n\t\t\t\tbordering[l*patchCount+k] = 0;\n\t\t\t}\n\n\t\t}\n\t}\n\n\t// build groups\n\tmemset( grouped, 0, sizeof(grouped) );\n\tgroupCount = 0;\n\tfor ( i = 0 ; i < patchCount ; i++ ) {\n\t\tif ( !grouped[i] ) {\n\t\t\tgroupCount++;\n\t\t}\n\n\t\t// recursively find all patches that belong in the same group\n\t\tmemset( group, 0, patchCount );\n\t\tGrowGroup_r( i, patchCount, bordering, group );\n\n\t\t// bound them\n\t\tClearBounds( bounds[0], bounds[1] );\n\t\tfor ( j = 0 ; j < patchCount ; j++ ) {\n\t\t\tif ( group[j] ) {\n\t\t\t\tgrouped[j] = qtrue;\n\t\t\t\tscan = meshes[j];\n\t\t\t\tc1 = scan->mesh.width * scan->mesh.height;\n\t\t\t\tv1 = scan->mesh.verts;\n\t\t\t\tfor ( k = 0 ; k < c1 ; k++, v1++ ) {\n\t\t\t\t\tAddPointToBounds( v1->xyz, bounds[0], bounds[1] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// create drawsurf\n\t\tscan = meshes[i];\n\t\tscan->grouped = qtrue;\n\t\tds = DrawSurfaceForMesh( &scan->mesh );\n\t\tds->shaderInfo = scan->shaderInfo;\n\t\tVectorCopy( bounds[0], ds->lightmapVecs[0] );\n\t\tVectorCopy( bounds[1], ds->lightmapVecs[1] );\n\t}\n\n\tqprintf( \"%5i patches\\n\", patchCount );\n\tqprintf( \"%5i patch LOD groups\\n\", groupCount );\n}\n\n"
  },
  {
    "path": "q3map/portals.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n\n\nint\t\tc_active_portals;\nint\t\tc_peak_portals;\nint\t\tc_boundary;\nint\t\tc_boundary_sides;\n\n/*\n===========\nAllocPortal\n===========\n*/\nportal_t *AllocPortal (void)\n{\n\tportal_t\t*p;\n\t\n\tif (numthreads == 1)\n\t\tc_active_portals++;\n\tif (c_active_portals > c_peak_portals)\n\t\tc_peak_portals = c_active_portals;\n\t\n\tp = malloc (sizeof(portal_t));\n\tmemset (p, 0, sizeof(portal_t));\n\t\n\treturn p;\n}\n\nvoid FreePortal (portal_t *p)\n{\n\tif (p->winding)\n\t\tFreeWinding (p->winding);\n\tif (numthreads == 1)\n\t\tc_active_portals--;\n\tfree (p);\n}\n\n//==============================================================\n\n/*\n=============\nPortal_Passable\n\nReturns true if the portal has non-opaque leafs on both sides\n=============\n*/\nqboolean Portal_Passable(portal_t *p) {\n\tif (!p->onnode) {\n\t\treturn qfalse;\t// to global outsideleaf\n\t}\n\n\tif (p->nodes[0]->planenum != PLANENUM_LEAF\n\t\t|| p->nodes[1]->planenum != PLANENUM_LEAF) {\n\t\tError (\"Portal_EntityFlood: not a leaf\");\n\t}\n\n\tif ( !p->nodes[0]->opaque && !p->nodes[1]->opaque ) {\n\t\treturn qtrue;\n\t}\n\n\treturn qfalse;\n}\n\n\n//=============================================================================\n\nint\t\tc_tinyportals;\n\n/*\n=============\nAddPortalToNodes\n=============\n*/\nvoid AddPortalToNodes (portal_t *p, node_t *front, node_t *back)\n{\n\tif (p->nodes[0] || p->nodes[1])\n\t\tError (\"AddPortalToNode: allready included\");\n\n\tp->nodes[0] = front;\n\tp->next[0] = front->portals;\n\tfront->portals = p;\n\t\n\tp->nodes[1] = back;\n\tp->next[1] = back->portals;\n\tback->portals = p;\n}\n\n\n/*\n=============\nRemovePortalFromNode\n=============\n*/\nvoid RemovePortalFromNode (portal_t *portal, node_t *l)\n{\n\tportal_t\t**pp, *t;\n\t\n// remove reference to the current portal\n\tpp = &l->portals;\n\twhile (1)\n\t{\n\t\tt = *pp;\n\t\tif (!t)\n\t\t\tError (\"RemovePortalFromNode: portal not in leaf\");\t\n\n\t\tif ( t == portal )\n\t\t\tbreak;\n\n\t\tif (t->nodes[0] == l)\n\t\t\tpp = &t->next[0];\n\t\telse if (t->nodes[1] == l)\n\t\t\tpp = &t->next[1];\n\t\telse\n\t\t\tError (\"RemovePortalFromNode: portal not bounding leaf\");\n\t}\n\t\n\tif (portal->nodes[0] == l)\n\t{\n\t\t*pp = portal->next[0];\n\t\tportal->nodes[0] = NULL;\n\t}\n\telse if (portal->nodes[1] == l)\n\t{\n\t\t*pp = portal->next[1];\t\n\t\tportal->nodes[1] = NULL;\n\t}\n}\n\n//============================================================================\n\nvoid PrintPortal (portal_t *p)\n{\n\tint\t\t\ti;\n\twinding_t\t*w;\n\t\n\tw = p->winding;\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\t_printf (\"(%5.0f,%5.0f,%5.0f)\\n\",w->p[i][0]\n\t\t, w->p[i][1], w->p[i][2]);\n}\n\n/*\n================\nMakeHeadnodePortals\n\nThe created portals will face the global outside_node\n================\n*/\n#define\tSIDESPACE\t8\nvoid MakeHeadnodePortals (tree_t *tree)\n{\n\tvec3_t\t\tbounds[2];\n\tint\t\t\ti, j, n;\n\tportal_t\t*p, *portals[6];\n\tplane_t\t\tbplanes[6], *pl;\n\tnode_t *node;\n\n\tnode = tree->headnode;\n\n// pad with some space so there will never be null volume leafs\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tbounds[0][i] = tree->mins[i] - SIDESPACE;\n\t\tbounds[1][i] = tree->maxs[i] + SIDESPACE;\n\t\tif ( bounds[0][i] >= bounds[1][i] ) {\n\t\t\tError( \"Backwards tree volume\" );\n\t\t}\n\t}\n\t\n\ttree->outside_node.planenum = PLANENUM_LEAF;\n\ttree->outside_node.brushlist = NULL;\n\ttree->outside_node.portals = NULL;\n\ttree->outside_node.opaque = qfalse;\n\n\tfor (i=0 ; i<3 ; i++)\n\t\tfor (j=0 ; j<2 ; j++)\n\t\t{\n\t\t\tn = j*3 + i;\n\n\t\t\tp = AllocPortal ();\n\t\t\tportals[n] = p;\n\t\t\t\n\t\t\tpl = &bplanes[n];\n\t\t\tmemset (pl, 0, sizeof(*pl));\n\t\t\tif (j)\n\t\t\t{\n\t\t\t\tpl->normal[i] = -1;\n\t\t\t\tpl->dist = -bounds[j][i];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tpl->normal[i] = 1;\n\t\t\t\tpl->dist = bounds[j][i];\n\t\t\t}\n\t\t\tp->plane = *pl;\n\t\t\tp->winding = BaseWindingForPlane (pl->normal, pl->dist);\n\t\t\tAddPortalToNodes (p, node, &tree->outside_node);\n\t\t}\n\t\t\n// clip the basewindings by all the other planes\n\tfor (i=0 ; i<6 ; i++)\n\t{\n\t\tfor (j=0 ; j<6 ; j++)\n\t\t{\n\t\t\tif (j == i)\n\t\t\t\tcontinue;\n\t\t\tChopWindingInPlace (&portals[i]->winding, bplanes[j].normal, bplanes[j].dist, ON_EPSILON);\n\t\t}\n\t}\n}\n\n//===================================================\n\n\n/*\n================\nBaseWindingForNode\n================\n*/\n#define\tBASE_WINDING_EPSILON\t0.001\n#define\tSPLIT_WINDING_EPSILON\t0.001\n\nwinding_t\t*BaseWindingForNode (node_t *node)\n{\n\twinding_t\t*w;\n\tnode_t\t\t*n;\n\tplane_t\t\t*plane;\n\tvec3_t\t\tnormal;\n\tvec_t\t\tdist;\n\n\tw = BaseWindingForPlane (mapplanes[node->planenum].normal\n\t\t, mapplanes[node->planenum].dist);\n\n\t// clip by all the parents\n\tfor (n=node->parent ; n && w ; )\n\t{\n\t\tplane = &mapplanes[n->planenum];\n\n\t\tif (n->children[0] == node)\n\t\t{\t// take front\n\t\t\tChopWindingInPlace (&w, plane->normal, plane->dist, BASE_WINDING_EPSILON);\n\t\t}\n\t\telse\n\t\t{\t// take back\n\t\t\tVectorSubtract (vec3_origin, plane->normal, normal);\n\t\t\tdist = -plane->dist;\n\t\t\tChopWindingInPlace (&w, normal, dist, BASE_WINDING_EPSILON);\n\t\t}\n\t\tnode = n;\n\t\tn = n->parent;\n\t}\n\n\treturn w;\n}\n\n//============================================================\n\n/*\n==================\nMakeNodePortal\n\ncreate the new portal by taking the full plane winding for the cutting plane\nand clipping it by all of parents of this node\n==================\n*/\nvoid MakeNodePortal (node_t *node)\n{\n\tportal_t\t*new_portal, *p;\n\twinding_t\t*w;\n\tvec3_t\t\tnormal;\n\tfloat\t\tdist;\n\tint\t\t\tside;\n\n\tw = BaseWindingForNode (node);\n\n\t// clip the portal by all the other portals in the node\n\tfor (p = node->portals ; p && w; p = p->next[side])\t\n\t{\n\t\tif (p->nodes[0] == node)\n\t\t{\n\t\t\tside = 0;\n\t\t\tVectorCopy (p->plane.normal, normal);\n\t\t\tdist = p->plane.dist;\n\t\t}\n\t\telse if (p->nodes[1] == node)\n\t\t{\n\t\t\tside = 1;\n\t\t\tVectorSubtract (vec3_origin, p->plane.normal, normal);\n\t\t\tdist = -p->plane.dist;\n\t\t}\n\t\telse\n\t\t\tError (\"CutNodePortals_r: mislinked portal\");\n\n\t\tChopWindingInPlace (&w, normal, dist, CLIP_EPSILON);\n\t}\n\n\tif (!w)\n\t{\n\t\treturn;\n\t}\n\n\tif (WindingIsTiny (w))\n\t{\n\t\tc_tinyportals++;\n\t\tFreeWinding (w);\n\t\treturn;\n\t}\n\n\tnew_portal = AllocPortal ();\n\tnew_portal->plane = mapplanes[node->planenum];\n\tnew_portal->onnode = node;\n\tnew_portal->winding = w;\n\tnew_portal->hint = node->hint;\n\tAddPortalToNodes (new_portal, node->children[0], node->children[1]);\n}\n\n\n/*\n==============\nSplitNodePortals\n\nMove or split the portals that bound node so that the node's\nchildren have portals instead of node.\n==============\n*/\nvoid SplitNodePortals (node_t *node)\n{\n\tportal_t\t*p, *next_portal, *new_portal;\n\tnode_t\t\t*f, *b, *other_node;\n\tint\t\t\tside;\n\tplane_t\t\t*plane;\n\twinding_t\t*frontwinding, *backwinding;\n\n\tplane = &mapplanes[node->planenum];\n\tf = node->children[0];\n\tb = node->children[1];\n\n\tfor (p = node->portals ; p ; p = next_portal)\t\n\t{\n\t\tif (p->nodes[0] == node)\n\t\t\tside = 0;\n\t\telse if (p->nodes[1] == node)\n\t\t\tside = 1;\n\t\telse\n\t\t\tError (\"SplitNodePortals: mislinked portal\");\n\t\tnext_portal = p->next[side];\n\n\t\tother_node = p->nodes[!side];\n\t\tRemovePortalFromNode (p, p->nodes[0]);\n\t\tRemovePortalFromNode (p, p->nodes[1]);\n\n//\n// cut the portal into two portals, one on each side of the cut plane\n//\n\t\tClipWindingEpsilon (p->winding, plane->normal, plane->dist,\n\t\t\tSPLIT_WINDING_EPSILON, &frontwinding, &backwinding);\n\n\t\tif (frontwinding && WindingIsTiny(frontwinding))\n\t\t{\n\t\t\tif (!f->tinyportals)\n\t\t\t\tVectorCopy(frontwinding->p[0], f->referencepoint);\n\t\t\tf->tinyportals++;\n\t\t\tif (!other_node->tinyportals)\n\t\t\t\tVectorCopy(frontwinding->p[0], other_node->referencepoint);\n\t\t\tother_node->tinyportals++;\n\n\t\t\tFreeWinding (frontwinding);\n\t\t\tfrontwinding = NULL;\n\t\t\tc_tinyportals++;\n\t\t}\n\n\t\tif (backwinding && WindingIsTiny(backwinding))\n\t\t{\n\t\t\tif (!b->tinyportals)\n\t\t\t\tVectorCopy(backwinding->p[0], b->referencepoint);\n\t\t\tb->tinyportals++;\n\t\t\tif (!other_node->tinyportals)\n\t\t\t\tVectorCopy(backwinding->p[0], other_node->referencepoint);\n\t\t\tother_node->tinyportals++;\n\n\t\t\tFreeWinding (backwinding);\n\t\t\tbackwinding = NULL;\n\t\t\tc_tinyportals++;\n\t\t}\n\n\t\tif (!frontwinding && !backwinding)\n\t\t{\t// tiny windings on both sides\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!frontwinding)\n\t\t{\n\t\t\tFreeWinding (backwinding);\n\t\t\tif (side == 0)\n\t\t\t\tAddPortalToNodes (p, b, other_node);\n\t\t\telse\n\t\t\t\tAddPortalToNodes (p, other_node, b);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!backwinding)\n\t\t{\n\t\t\tFreeWinding (frontwinding);\n\t\t\tif (side == 0)\n\t\t\t\tAddPortalToNodes (p, f, other_node);\n\t\t\telse\n\t\t\t\tAddPortalToNodes (p, other_node, f);\n\t\t\tcontinue;\n\t\t}\n\t\t\n\t// the winding is split\n\t\tnew_portal = AllocPortal ();\n\t\t*new_portal = *p;\n\t\tnew_portal->winding = backwinding;\n\t\tFreeWinding (p->winding);\n\t\tp->winding = frontwinding;\n\n\t\tif (side == 0)\n\t\t{\n\t\t\tAddPortalToNodes (p, f, other_node);\n\t\t\tAddPortalToNodes (new_portal, b, other_node);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tAddPortalToNodes (p, other_node, f);\n\t\t\tAddPortalToNodes (new_portal, other_node, b);\n\t\t}\n\t}\n\n\tnode->portals = NULL;\n}\n\n\n/*\n================\nCalcNodeBounds\n================\n*/\nvoid CalcNodeBounds (node_t *node)\n{\n\tportal_t\t*p;\n\tint\t\t\ts;\n\tint\t\t\ti;\n\n\t// calc mins/maxs for both leafs and nodes\n\tClearBounds (node->mins, node->maxs);\n\tfor (p = node->portals ; p ; p = p->next[s])\n\t{\n\t\ts = (p->nodes[1] == node);\n\t\tfor (i=0 ; i<p->winding->numpoints ; i++)\n\t\t\tAddPointToBounds (p->winding->p[i], node->mins, node->maxs);\n\t}\n}\n\n/*\n==================\nMakeTreePortals_r\n==================\n*/\nvoid MakeTreePortals_r (node_t *node)\n{\n\tint\t\ti;\n\n\tCalcNodeBounds (node);\n\tif (node->mins[0] >= node->maxs[0])\n\t{\n\t\t_printf (\"WARNING: node without a volume\\n\");\n\t\t_printf(\"node has %d tiny portals\\n\", node->tinyportals);\n\t\t_printf(\"node reference point %1.2f %1.2f %1.2f\\n\", node->referencepoint[0],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnode->referencepoint[1],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnode->referencepoint[2]);\n\t}\n\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tif (node->mins[i] < MIN_WORLD_COORD || node->maxs[i] > MAX_WORLD_COORD)\n\t\t{\n\t\t\t_printf (\"WARNING: node with unbounded volume\\n\");\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (node->planenum == PLANENUM_LEAF)\n\t\treturn;\n\n\tMakeNodePortal (node);\n\tSplitNodePortals (node);\n\n\tMakeTreePortals_r (node->children[0]);\n\tMakeTreePortals_r (node->children[1]);\n}\n\n/*\n==================\nMakeTreePortals\n==================\n*/\nvoid MakeTreePortals (tree_t *tree)\n{\n\tqprintf( \"----- MakeTreePortals -----\\n\");\n\tMakeHeadnodePortals (tree);\n\tMakeTreePortals_r (tree->headnode);\n\tqprintf(\"%6d tiny portals\\n\", c_tinyportals);\n}\n\n/*\n=========================================================\n\nFLOOD ENTITIES\n\n=========================================================\n*/\n\nint\t\tc_floodedleafs;\n\n/*\n=============\nFloodPortals_r\n=============\n*/\nvoid FloodPortals_r (node_t *node, int dist) {\n\tportal_t\t*p;\n\tint\t\t\ts;\n\n\tif ( node->occupied ) {\n\t\treturn;\n\t}\n\n\tif ( node->opaque ) {\n\t\treturn;\n\t}\n\n\tc_floodedleafs++;\n\tnode->occupied = dist;\n\n\tfor (p=node->portals ; p ; p = p->next[s]) {\n\t\ts = (p->nodes[1] == node);\n\t\tFloodPortals_r (p->nodes[!s], dist+1);\n\t}\n}\n\n/*\n=============\nPlaceOccupant\n=============\n*/\nqboolean PlaceOccupant (node_t *headnode, vec3_t origin, entity_t *occupant)\n{\n\tnode_t\t*node;\n\tvec_t\td;\n\tplane_t\t*plane;\n\n\t// find the leaf to start in\n\tnode = headnode;\n\twhile (node->planenum != PLANENUM_LEAF)\n\t{\n\t\tplane = &mapplanes[node->planenum];\n\t\td = DotProduct (origin, plane->normal) - plane->dist;\n\t\tif (d >= 0)\n\t\t\tnode = node->children[0];\n\t\telse\n\t\t\tnode = node->children[1];\n\t}\n\n\tif ( node->opaque )\n\t\treturn qfalse;\n\tnode->occupant = occupant;\n\n\tFloodPortals_r (node, 1);\n\n\treturn qtrue;\n}\n\n/*\n=============\nFloodEntities\n\nMarks all nodes that can be reached by entites\n=============\n*/\nqboolean FloodEntities( tree_t *tree ) {\n\tint\t\ti;\n\tvec3_t\torigin;\n\tconst char\t*cl;\n\tqboolean\tinside;\n\tnode_t *headnode;\n\n\theadnode = tree->headnode;\n\tqprintf (\"--- FloodEntities ---\\n\");\n\tinside = qfalse;\n\ttree->outside_node.occupied = 0;\n\n\tc_floodedleafs = 0;\n\tfor (i=1 ; i<num_entities ; i++)\n\t{\n\t\tGetVectorForKey (&entities[i], \"origin\", origin);\n\t\tif (VectorCompare(origin, vec3_origin))\n\t\t\tcontinue;\n\n\t\tcl = ValueForKey (&entities[i], \"classname\");\n\n\t\torigin[2] += 1;\t// so objects on floor are ok\n\n\t\tif (PlaceOccupant (headnode, origin, &entities[i]))\n\t\t\tinside = qtrue;\n\t}\n\n\tqprintf(\"%5i flooded leafs\\n\", c_floodedleafs );\n\n\tif (!inside)\n\t{\n\t\tqprintf (\"no entities in open -- no filling\\n\");\n\t}\n\telse if (tree->outside_node.occupied)\n\t{\n\t\tqprintf (\"entity reached from outside -- no filling\\n\");\n\t}\n\n\treturn (qboolean)(inside && !tree->outside_node.occupied);\n}\n\n/*\n=========================================================\n\nFLOOD AREAS\n\n=========================================================\n*/\n\nint\t\tc_areas;\n\n/*\n=============\nFloodAreas_r\n=============\n*/\nvoid FloodAreas_r (node_t *node)\n{\n\tportal_t\t*p;\n\tint\t\t\ts;\n\tbspbrush_t\t*b;\n\n\tif ( node->areaportal ) {\n\t\t//\n\t\tif ( node->area == -1 ) {\n\t\t\tnode->area = c_areas;\n\t\t}\n\t\t// this node is part of an area portal brush\n\t\tb = node->brushlist->original;\n\n\t\t// if the current area has allready touched this\n\t\t// portal, we are done\n\t\tif (b->portalareas[0] == c_areas || b->portalareas[1] == c_areas)\n\t\t\treturn;\n\n\t\t// note the current area as bounding the portal\n\t\tif (b->portalareas[1] != -1)\n\t\t{\n\t\t\t_printf (\"WARNING: areaportal brush %i touches > 2 areas\\n\", b->brushnum );\n\t\t\treturn;\n\t\t}\n\t\tif (b->portalareas[0] != -1) {\n\t\t\tb->portalareas[1] = c_areas;\n\t\t} else {\n\t\t\tb->portalareas[0] = c_areas;\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (node->area != -1) {\n\t\treturn;\t\t// allready got it\n\t}\n\tif ( node->cluster == -1 ) {\n\t\treturn;\n\t}\n\n\tnode->area = c_areas;\n\n\tfor (p=node->portals ; p ; p = p->next[s])\n\t{\n\t\ts = (p->nodes[1] == node);\n\n\t\tif ( !Portal_Passable(p) )\n\t\t\tcontinue;\n\n\t\tFloodAreas_r (p->nodes[!s]);\n\t}\n}\n\n\n/*\n=============\nFindAreas_r\n\nJust decend the tree, and for each node that hasn't had an\narea set, flood fill out from there\n=============\n*/\nvoid FindAreas_r (node_t *node)\n{\n\tif (node->planenum != PLANENUM_LEAF)\n\t{\n\t\tFindAreas_r (node->children[0]);\n\t\tFindAreas_r (node->children[1]);\n\t\treturn;\n\t}\n\n\tif (node->opaque)\n\t\treturn;\n\n\tif (node->areaportal)\n\t\treturn;\n\n\tif (node->area != -1)\n\t\treturn;\t\t// allready got it\n\n\tFloodAreas_r (node);\n\tc_areas++;\n}\n\n/*\n=============\nCheckAreas_r\n=============\n*/\nvoid CheckAreas_r (node_t *node)\n{\n\tbspbrush_t\t*b;\n\n\tif (node->planenum != PLANENUM_LEAF)\n\t{\n\t\tCheckAreas_r (node->children[0]);\n\t\tCheckAreas_r (node->children[1]);\n\t\treturn;\n\t}\n\n\tif (node->opaque)\n\t\treturn;\n\n\tif (node->cluster != -1)\n\t\tif (node->area == -1)\n\t\t\t_printf(\"WARNING: cluster %d has area set to -1\\n\", node->cluster);\n\tif (node->areaportal)\n\t{\n\t\tb = node->brushlist->original;\n\n\t\t// check if the areaportal touches two areas\n\t\tif (b->portalareas[0] == -1 || b->portalareas[1] == -1)\n\t\t\t_printf (\"WARNING: areaportal brush %i doesn't touch two areas\\n\", b->brushnum);\n\t}\n}\n\n/*\n=============\nFloodAreas\n\nMark each leaf with an area, bounded by CONTENTS_AREAPORTAL\n=============\n*/\nvoid FloodAreas (tree_t *tree)\n{\n\tqprintf (\"--- FloodAreas ---\\n\");\n\tFindAreas_r( tree->headnode );\n\n\t// check for areaportal brushes that don't touch two areas\n\tCheckAreas_r( tree->headnode );\n\n\tqprintf (\"%5i areas\\n\", c_areas);\n}\n\n//======================================================\n\nint\t\tc_outside;\nint\t\tc_inside;\nint\t\tc_solid;\n\nvoid FillOutside_r (node_t *node)\n{\n\tif (node->planenum != PLANENUM_LEAF)\n\t{\n\t\tFillOutside_r (node->children[0]);\n\t\tFillOutside_r (node->children[1]);\n\t\treturn;\n\t}\n\n\t// anything not reachable by an entity\n\t// can be filled away\n\tif (!node->occupied) {\n\t\tif ( !node->opaque ) {\n\t\t\tc_outside++;\n\t\t\tnode->opaque = qtrue;\n\t\t} else {\n\t\t\tc_solid++;\n\t\t}\n\t} else {\n\t\tc_inside++;\n\t}\n\n}\n\n/*\n=============\nFillOutside\n\nFill all nodes that can't be reached by entities\n=============\n*/\nvoid FillOutside (node_t *headnode)\n{\n\tc_outside = 0;\n\tc_inside = 0;\n\tc_solid = 0;\n\tqprintf (\"--- FillOutside ---\\n\");\n\tFillOutside_r (headnode);\n\tqprintf (\"%5i solid leafs\\n\", c_solid);\n\tqprintf (\"%5i leafs filled\\n\", c_outside);\n\tqprintf (\"%5i inside leafs\\n\", c_inside);\n}\n\n\n//==============================================================\n\n"
  },
  {
    "path": "q3map/prtfile.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n\n/*\n==============================================================================\n\nPORTAL FILE GENERATION\n\nSave out name.prt for qvis to read\n==============================================================================\n*/\n\n\n#define\tPORTALFILE\t\"PRT1\"\n\nFILE\t*pf;\nint\t\tnum_visclusters;\t\t\t\t// clusters the player can be in\nint\t\tnum_visportals;\nint\t\tnum_solidfaces;\n\nvoid WriteFloat (FILE *f, vec_t v)\n{\n\tif ( fabs(v - Q_rint(v)) < 0.001 )\n\t\tfprintf (f,\"%i \",(int)Q_rint(v));\n\telse\n\t\tfprintf (f,\"%f \",v);\n}\n\n/*\n=================\nWritePortalFile_r\n=================\n*/\nvoid WritePortalFile_r (node_t *node)\n{\n\tint\t\t\ti, s;\t\n\tportal_t\t*p;\n\twinding_t\t*w;\n\tvec3_t\t\tnormal;\n\tvec_t\t\tdist;\n\n\t// decision node\n\tif (node->planenum != PLANENUM_LEAF) {\n\t\tWritePortalFile_r (node->children[0]);\n\t\tWritePortalFile_r (node->children[1]);\n\t\treturn;\n\t}\n\t\n\tif (node->opaque) {\n\t\treturn;\n\t}\n\n\tfor (p = node->portals ; p ; p=p->next[s])\n\t{\n\t\tw = p->winding;\n\t\ts = (p->nodes[1] == node);\n\t\tif (w && p->nodes[0] == node)\n\t\t{\n\t\t\tif (!Portal_Passable(p))\n\t\t\t\tcontinue;\n\t\t\t// write out to the file\n\t\t\t\n\t\t\t// sometimes planes get turned around when they are very near\n\t\t\t// the changeover point between different axis.  interpret the\n\t\t\t// plane the same way vis will, and flip the side orders if needed\n\t\t\t// FIXME: is this still relevent?\n\t\t\tWindingPlane (w, normal, &dist);\n\t\t\tif ( DotProduct (p->plane.normal, normal) < 0.99 )\n\t\t\t{\t// backwards...\n\t\t\t\tfprintf (pf,\"%i %i %i \",w->numpoints, p->nodes[1]->cluster, p->nodes[0]->cluster);\n\t\t\t}\n\t\t\telse\n\t\t\t\tfprintf (pf,\"%i %i %i \",w->numpoints, p->nodes[0]->cluster, p->nodes[1]->cluster);\n\t\t\tif (p->hint)\n\t\t\t\tfprintf (pf, \"1 \");\n\t\t\telse\n\t\t\t\tfprintf (pf, \"0 \");\n\t\t\tfor (i=0 ; i<w->numpoints ; i++)\n\t\t\t{\n\t\t\t\tfprintf (pf,\"(\");\n\t\t\t\tWriteFloat (pf, w->p[i][0]);\n\t\t\t\tWriteFloat (pf, w->p[i][1]);\n\t\t\t\tWriteFloat (pf, w->p[i][2]);\n\t\t\t\tfprintf (pf,\") \");\n\t\t\t}\n\t\t\tfprintf (pf,\"\\n\");\n\t\t}\n\t}\n\n}\n\n/*\n=================\nWriteFaceFile_r\n=================\n*/\nvoid WriteFaceFile_r (node_t *node)\n{\n\tint\t\t\ti, s;\t\n\tportal_t\t*p;\n\twinding_t\t*w;\n\n\t// decision node\n\tif (node->planenum != PLANENUM_LEAF) {\n\t\tWriteFaceFile_r (node->children[0]);\n\t\tWriteFaceFile_r (node->children[1]);\n\t\treturn;\n\t}\n\t\n\tif (node->opaque) {\n\t\treturn;\n\t}\n\n\tfor (p = node->portals ; p ; p=p->next[s])\n\t{\n\t\tw = p->winding;\n\t\ts = (p->nodes[1] == node);\n\t\tif (w)\n\t\t{\n\t\t\tif (Portal_Passable(p))\n\t\t\t\tcontinue;\n\t\t\t// write out to the file\n\n\t\t\tif (p->nodes[0] == node)\n\t\t\t{\n\t\t\t\tfprintf (pf,\"%i %i \",w->numpoints, p->nodes[0]->cluster);\n\t\t\t\tfor (i=0 ; i<w->numpoints ; i++)\n\t\t\t\t{\n\t\t\t\t\tfprintf (pf,\"(\");\n\t\t\t\t\tWriteFloat (pf, w->p[i][0]);\n\t\t\t\t\tWriteFloat (pf, w->p[i][1]);\n\t\t\t\t\tWriteFloat (pf, w->p[i][2]);\n\t\t\t\t\tfprintf (pf,\") \");\n\t\t\t\t}\n\t\t\t\tfprintf (pf,\"\\n\");\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfprintf (pf,\"%i %i \",w->numpoints, p->nodes[1]->cluster);\n\t\t\t\tfor (i = w->numpoints-1; i >= 0; i--)\n\t\t\t\t{\n\t\t\t\t\tfprintf (pf,\"(\");\n\t\t\t\t\tWriteFloat (pf, w->p[i][0]);\n\t\t\t\t\tWriteFloat (pf, w->p[i][1]);\n\t\t\t\t\tWriteFloat (pf, w->p[i][2]);\n\t\t\t\t\tfprintf (pf,\") \");\n\t\t\t\t}\n\t\t\t\tfprintf (pf,\"\\n\");\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n================\nNumberLeafs_r\n================\n*/\nvoid NumberLeafs_r (node_t *node)\n{\n\tportal_t\t*p;\n\n\tif ( node->planenum != PLANENUM_LEAF ) {\n\t\t// decision node\n\t\tnode->cluster = -99;\n\t\tNumberLeafs_r (node->children[0]);\n\t\tNumberLeafs_r (node->children[1]);\n\t\treturn;\n\t}\n\t\n\tnode->area = -1;\n\n\tif ( node->opaque ) {\n\t\t// solid block, viewpoint never inside\n\t\tnode->cluster = -1;\n\t\treturn;\n\t}\n\n\tnode->cluster = num_visclusters;\n\tnum_visclusters++;\n\n\t// count the portals\n\tfor (p = node->portals ; p ; )\n\t{\n\t\tif (p->nodes[0] == node)\t\t// only write out from first leaf\n\t\t{\n\t\t\tif (Portal_Passable(p))\n\t\t\t\tnum_visportals++;\n\t\t\telse\n\t\t\t\tnum_solidfaces++;\n\t\t\tp = p->next[0];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (!Portal_Passable(p))\n\t\t\t\tnum_solidfaces++;\n\t\t\tp = p->next[1];\t\t\n\t\t}\n\t}\n}\n\n\n/*\n================\nNumberClusters\n================\n*/\nvoid NumberClusters(tree_t *tree) {\n\tnum_visclusters = 0;\n\tnum_visportals = 0;\n\tnum_solidfaces = 0;\n\n\tqprintf (\"--- NumberClusters ---\\n\");\n\t\n\t// set the cluster field in every leaf and count the total number of portals\n\tNumberLeafs_r (tree->headnode);\n\n\tqprintf (\"%5i visclusters\\n\", num_visclusters);\n\tqprintf (\"%5i visportals\\n\", num_visportals);\n\tqprintf (\"%5i solidfaces\\n\", num_solidfaces);\n}\n\n/*\n================\nWritePortalFile\n================\n*/\nvoid WritePortalFile (tree_t *tree)\n{\n\tchar\tfilename[1024];\n\n\tqprintf (\"--- WritePortalFile ---\\n\");\n\t\n\t// write the file\n\tsprintf (filename, \"%s.prt\", source);\n\t_printf (\"writing %s\\n\", filename);\n\tpf = fopen (filename, \"w\");\n\tif (!pf)\n\t\tError (\"Error opening %s\", filename);\n\t\t\n\tfprintf (pf, \"%s\\n\", PORTALFILE);\n\tfprintf (pf, \"%i\\n\", num_visclusters);\n\tfprintf (pf, \"%i\\n\", num_visportals);\n\tfprintf (pf, \"%i\\n\", num_solidfaces);\n\n\tWritePortalFile_r(tree->headnode);\n\tWriteFaceFile_r(tree->headnode);\n\n\tfclose (pf);\n}\n\n"
  },
  {
    "path": "q3map/q3map.sln",
    "content": "Microsoft Visual Studio Solution File, Format Version 8.00\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"jpeg6\", \"..\\libs\\jpeg6\\jpeg6.vcproj\", \"{A862AD26-94DD-4618-A814-F6AACA0B2FE3}\"\n\tProjectSection(ProjectDependencies) = postProject\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"pak\", \"..\\libs\\pak\\pak.vcproj\", \"{F2ACC9D7-D628-4624-864F-87FE58787625}\"\n\tProjectSection(ProjectDependencies) = postProject\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"q3map\", \"q3map.vcproj\", \"{F1162C55-66E7-4486-B1F3-071CFAA78332}\"\n\tProjectSection(ProjectDependencies) = postProject\n\t\t{F2ACC9D7-D628-4624-864F-87FE58787625} = {F2ACC9D7-D628-4624-864F-87FE58787625}\n\t\t{A862AD26-94DD-4618-A814-F6AACA0B2FE3} = {A862AD26-94DD-4618-A814-F6AACA0B2FE3}\n\tEndProjectSection\nEndProject\nGlobal\n\tGlobalSection(SourceCodeControl) = preSolution\n\t\tSccNumberOfProjects = 3\n\t\tSccProjectUniqueName0 = ..\\\\libs\\\\jpeg6\\\\jpeg6.vcproj\n\t\tSccProjectName0 = \\u0022$/source/q3radiant\\u0022,\\u0020FEFAAAAA\n\t\tSccLocalPath0 = ..\\\\q3radiant\n\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM\n\t\tSccProjectFilePathRelativizedFromConnection0 = ..\\\\libs\\\\jpeg6\\\\\n\t\tSccProjectUniqueName1 = ..\\\\libs\\\\pak\\\\pak.vcproj\n\t\tSccProjectName1 = \\u0022$/source/q3radiant\\u0022,\\u0020FEFAAAAA\n\t\tSccLocalPath1 = ..\\\\q3radiant\n\t\tSccProvider1 = MSSCCI:Perforce\\u0020SCM\n\t\tSccProjectFilePathRelativizedFromConnection1 = ..\\\\libs\\\\pak\\\\\n\t\tSccProjectUniqueName2 = q3map.vcproj\n\t\tSccProjectName2 = \\u0022$/source/q3map\\u0022,\\u0020PADAAAAA\n\t\tSccLocalPath2 = .\n\t\tSccProvider2 = MSSCCI:Perforce\\u0020SCM\n\tEndGlobalSection\n\tGlobalSection(SolutionConfiguration) = preSolution\n\t\tDebug = Debug\n\t\tRelease = Release\n\tEndGlobalSection\n\tGlobalSection(ProjectConfiguration) = postSolution\n\t\t{A862AD26-94DD-4618-A814-F6AACA0B2FE3}.Debug.ActiveCfg = Debug|Win32\n\t\t{A862AD26-94DD-4618-A814-F6AACA0B2FE3}.Debug.Build.0 = Debug|Win32\n\t\t{A862AD26-94DD-4618-A814-F6AACA0B2FE3}.Release.ActiveCfg = Release|Win32\n\t\t{A862AD26-94DD-4618-A814-F6AACA0B2FE3}.Release.Build.0 = Release|Win32\n\t\t{F2ACC9D7-D628-4624-864F-87FE58787625}.Debug.ActiveCfg = Debug|Win32\n\t\t{F2ACC9D7-D628-4624-864F-87FE58787625}.Debug.Build.0 = Debug|Win32\n\t\t{F2ACC9D7-D628-4624-864F-87FE58787625}.Release.ActiveCfg = Release|Win32\n\t\t{F2ACC9D7-D628-4624-864F-87FE58787625}.Release.Build.0 = Release|Win32\n\t\t{F1162C55-66E7-4486-B1F3-071CFAA78332}.Debug.ActiveCfg = Debug|Win32\n\t\t{F1162C55-66E7-4486-B1F3-071CFAA78332}.Debug.Build.0 = Debug|Win32\n\t\t{F1162C55-66E7-4486-B1F3-071CFAA78332}.Release.ActiveCfg = Release|Win32\n\t\t{F1162C55-66E7-4486-B1F3-071CFAA78332}.Release.Build.0 = Release|Win32\n\tEndGlobalSection\n\tGlobalSection(ExtensibilityGlobals) = postSolution\n\tEndGlobalSection\n\tGlobalSection(ExtensibilityAddIns) = postSolution\n\tEndGlobalSection\nEndGlobal\n"
  },
  {
    "path": "q3map/q3map.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<VisualStudioProject\n\tProjectType=\"Visual C++\"\n\tVersion=\"7.10\"\n\tName=\"q3map\"\n\tSccProjectName=\"&quot;$/source/q3map&quot;, PADAAAAA\"\n\tSccLocalPath=\".\">\n\t<Platforms>\n\t\t<Platform\n\t\t\tName=\"Win32\"/>\n\t</Platforms>\n\t<Configurations>\n\t\t<Configuration\n\t\t\tName=\"Debug|Win32\"\n\t\t\tOutputDirectory=\".\\Debug\"\n\t\t\tIntermediateDirectory=\".\\Debug\"\n\t\t\tConfigurationType=\"1\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tAdditionalIncludeDirectories=\"../common,c:\\quake3\\common,c:\\quake3\\libs\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_CONSOLE\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Debug/q3map.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug/\"\n\t\t\t\tObjectFile=\".\\Debug/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Debug/\"\n\t\t\t\tBrowseInformation=\"1\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"\n\t\t\t\tCompileAs=\"0\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"glaux.lib glu32.lib wsock32.lib opengl32.lib odbc32.lib odbccp32.lib ..\\libs\\pakd.lib ..\\libs\\jpeg6d.lib\"\n\t\t\t\tOutputFile=\".\\Debug/q3map.exe\"\n\t\t\t\tLinkIncremental=\"2\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\Debug/q3map.pdb\"\n\t\t\t\tSubSystem=\"1\"\n\t\t\t\tStackReserveSize=\"4194304\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tTypeLibraryName=\".\\Debug/q3map.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Release|Win32\"\n\t\t\tOutputDirectory=\".\\Release\"\n\t\t\tIntermediateDirectory=\".\\Release\"\n\t\t\tConfigurationType=\"1\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tAdditionalIncludeDirectories=\"../common,c:\\quake3\\common,c:\\quake3\\libs\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_CONSOLE\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"0\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release/q3map.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release/\"\n\t\t\t\tObjectFile=\".\\Release/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"3\"\n\t\t\t\tCompileAs=\"0\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"glaux.lib glu32.lib wsock32.lib opengl32.lib odbc32.lib odbccp32.lib ..\\libs\\pak.lib ..\\libs\\jpeg6.lib\"\n\t\t\t\tOutputFile=\".\\Release/q3map.exe\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\Release/q3map.pdb\"\n\t\t\t\tSubSystem=\"1\"\n\t\t\t\tStackReserveSize=\"4194304\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tTypeLibraryName=\".\\Release/q3map.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"DebugTTimo|Win32\"\n\t\t\tOutputDirectory=\".\\q3map___Win32_DebugTTimo\"\n\t\t\tIntermediateDirectory=\".\\q3map___Win32_DebugTTimo\"\n\t\t\tConfigurationType=\"1\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tAdditionalIncludeDirectories=\"../common,../../Libs,c:\\quake3\\common,c:\\quake3\\libs\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_CONSOLE;_TTIMOBUILD\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\q3map___Win32_DebugTTimo/q3map.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\q3map___Win32_DebugTTimo/\"\n\t\t\t\tObjectFile=\".\\q3map___Win32_DebugTTimo/\"\n\t\t\t\tProgramDataBaseFileName=\".\\q3map___Win32_DebugTTimo/\"\n\t\t\t\tBrowseInformation=\"1\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"\n\t\t\t\tCompileAs=\"0\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"glaux.lib glu32.lib wsock32.lib opengl32.lib odbc32.lib odbccp32.lib pakd.lib jpeg6d.lib\"\n\t\t\t\tOutputFile=\".\\q3map___Win32_DebugTTimo/q3map.exe\"\n\t\t\t\tLinkIncremental=\"2\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tAdditionalLibraryDirectories=\"../../Libs\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\q3map___Win32_DebugTTimo/q3map.pdb\"\n\t\t\t\tSubSystem=\"1\"\n\t\t\t\tStackReserveSize=\"4194304\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tTypeLibraryName=\".\\q3map___Win32_DebugTTimo/q3map.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"ReleaseTTimo|Win32\"\n\t\t\tOutputDirectory=\".\\q3map___Win32_ReleaseTTimo\"\n\t\t\tIntermediateDirectory=\".\\q3map___Win32_ReleaseTTimo\"\n\t\t\tConfigurationType=\"1\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tAdditionalIncludeDirectories=\"../common,../../Libs,c:\\quake3\\common,c:\\quake3\\libs\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_CONSOLE;_TTIMOBUILD\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"0\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\q3map___Win32_ReleaseTTimo/q3map.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\q3map___Win32_ReleaseTTimo/\"\n\t\t\t\tObjectFile=\".\\q3map___Win32_ReleaseTTimo/\"\n\t\t\t\tProgramDataBaseFileName=\".\\q3map___Win32_ReleaseTTimo/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"3\"\n\t\t\t\tCompileAs=\"0\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"glaux.lib glu32.lib wsock32.lib opengl32.lib odbc32.lib odbccp32.lib pak.lib jpeg6.lib\"\n\t\t\t\tOutputFile=\".\\q3map___Win32_ReleaseTTimo/q3map.exe\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tAdditionalLibraryDirectories=\"../../Libs\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\q3map___Win32_ReleaseTTimo/q3map.pdb\"\n\t\t\t\tSubSystem=\"1\"\n\t\t\t\tStackReserveSize=\"4194304\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tTypeLibraryName=\".\\q3map___Win32_ReleaseTTimo/q3map.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t</Configurations>\n\t<References>\n\t</References>\n\t<Files>\n\t\t<File\n\t\t\tRelativePath=\"..\\common\\aselib.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"brush.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"brush_primit.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"bsp.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"..\\common\\bspfile.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"..\\common\\cmdlib.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"facebsp.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"fog.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"gldraw.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"glfile.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"..\\common\\imagelib.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"leakfile.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"light.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"light_trace.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"lightmaps.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"lightv.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"map.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"..\\common\\mathlib.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"mesh.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"misc_model.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"..\\common\\mutex.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"patch.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"..\\common\\polylib.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"portals.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"prtfile.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"..\\common\\scriplib.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"shaders.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"soundv.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"surface.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"terrain.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"..\\common\\threads.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"tjunction.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"tree.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"vis.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"visflow.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t\t<File\n\t\t\tRelativePath=\"writebsp.c\">\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t</FileConfiguration>\n\t\t\t<FileConfiguration\n\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t<Tool\n\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t</FileConfiguration>\n\t\t</File>\n\t</Files>\n\t<Globals>\n\t</Globals>\n</VisualStudioProject>\n"
  },
  {
    "path": "q3map/qbsp.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"cmdlib.h\"\n#include \"mathlib.h\"\n#include \"scriplib.h\"\n#include \"polylib.h\"\n#include \"imagelib.h\"\n#include \"threads.h\"\n#include \"bspfile.h\"\n#include \"shaders.h\"\n#include \"mesh.h\"\n\n\n#define\tMAX_PATCH_SIZE\t32\n\n#define\tCLIP_EPSILON\t\t0.1\n#define\tPLANENUM_LEAF\t\t-1\n\n#define\tHINT_PRIORITY\t\t1000\n\ntypedef struct parseMesh_s {\n\tstruct parseMesh_s\t*next;\n\tmesh_t\t\t\tmesh;\n\tshaderInfo_t\t*shaderInfo;\n\n\tqboolean\tgrouped;\t\t\t// used during shared edge grouping\n\tstruct parseMesh_s *groupChain;\n} parseMesh_t;\n\ntypedef struct bspface_s {\n\tstruct bspface_s\t*next;\n\tint\t\t\t\t\tplanenum;\n\tint\t\t\t\t\tpriority;\t// added to value calculation\n\tqboolean\t\t\tchecked;\n\tqboolean\t\t\thint;\n\twinding_t\t\t\t*w;\n} bspface_t;\n\ntypedef struct plane_s {\n\tvec3_t\tnormal;\n\tvec_t\tdist;\n\tint\t\ttype;\n\tstruct plane_s\t*hash_chain;\n} plane_t;\n\ntypedef struct side_s {\n\tint\t\t\tplanenum;\n\n\tfloat\t\ttexMat[2][3];\t// brush primitive texture matrix\n\t// for old brush coordinates mode\n\tfloat\t\tvecs[2][4];\t\t// texture coordinate mapping\n\n\twinding_t\t*winding;\n\twinding_t\t*visibleHull;\t// convex hull of all visible fragments\n\n\tstruct shaderInfo_s\t*shaderInfo;\n\n\tint\t\t\tcontents;\t\t// from shaderInfo\n\tint\t\t\tsurfaceFlags;\t// from shaderInfo\n\tint\t\t\tvalue;\t\t\t// from shaderInfo\n\n\tqboolean\tvisible;\t\t// choose visble planes first\n\tqboolean\tbevel;\t\t\t// don't ever use for bsp splitting, and don't bother\n\t\t\t\t\t\t\t\t// making windings for it\n\tqboolean\tbackSide;\t\t// generated side for a q3map_backShader\n} side_t;\n\n\n#define\tMAX_BRUSH_SIDES\t\t1024\n\ntypedef struct bspbrush_s {\n\tstruct bspbrush_s\t*next;\n\n\tint\t\t\tentitynum;\t\t\t// editor numbering\n\tint\t\t\tbrushnum;\t\t\t// editor numbering\n\n\tstruct shaderInfo_s\t*contentShader;\n\n\tint\t\t\tcontents;\n\tqboolean\tdetail;\n\tqboolean\topaque;\n\tint\t\t\toutputNumber;\t\t// set when the brush is written to the file list\n\n\tint\t\t\tportalareas[2];\n\n\tstruct bspbrush_s\t*original;\t// chopped up brushes will reference the originals\n\n\tvec3_t\t\tmins, maxs;\n\tint\t\t\tnumsides;\n\tside_t\t\tsides[6];\t\t\t// variably sized\n} bspbrush_t;\n\n\n\ntypedef struct drawsurf_s {\n\tshaderInfo_t\t*shaderInfo;\n\n\tbspbrush_t\t*mapBrush;\t\t\t// not valid for patches\n\tside_t\t\t*side;\t\t\t\t// not valid for patches\n\n\tstruct drawsurf_s\t*nextOnShader;\t// when sorting by shader for lightmaps\n\n\tint\t\t\tfogNum;\t\t\t\t// set by FogDrawSurfs\n\n\tint\t\t\tlightmapNum;\t\t// -1 = no lightmap\n\tint\t\t\tlightmapX, lightmapY;\n\tint\t\t\tlightmapWidth, lightmapHeight;\n\n\tint\t\t\tnumVerts;\n\tdrawVert_t\t*verts;\n\n\tint\t\t\tnumIndexes;\n\tint\t\t\t*indexes;\n\n\t// for faces only\n\tint\t\t\tplaneNum;\n\n\tvec3_t\t\tlightmapOrigin;\t\t// also used for flares\n\tvec3_t\t\tlightmapVecs[3];\t// also used for flares\n\n\t// for patches only\n\tqboolean\tpatch;\n\tint\t\t\tpatchWidth;\n\tint\t\t\tpatchHeight;\n\n\t// for misc_models only\n\tqboolean\tmiscModel;\n\n\tqboolean\tflareSurface;\n} mapDrawSurface_t;\n\ntypedef struct drawSurfRef_s {\n\tstruct drawSurfRef_s\t*nextRef;\n\tint\t\t\t\t\t\toutputNumber;\n} drawSurfRef_t;\n\ntypedef struct node_s {\n\t// both leafs and nodes\n\tint\t\t\t\tplanenum;\t// -1 = leaf node\n\tstruct node_s\t*parent;\n\tvec3_t\t\t\tmins, maxs;\t// valid after portalization\n\tbspbrush_t\t\t*volume;\t// one for each leaf/node\n\n\t// nodes only\n\tside_t\t\t\t*side;\t\t// the side that created the node\n\tstruct node_s\t*children[2];\n\tqboolean\t\thint;\n\tint\t\t\t\ttinyportals;\n\tvec3_t\t\t\treferencepoint;\n\n\t// leafs only\n\tqboolean\t\topaque;\t\t// view can never be inside\n\tqboolean\t\tareaportal;\n\tint\t\t\t\tcluster;\t// for portalfile writing\n\tint\t\t\t\tarea;\t\t// for areaportals\n\tbspbrush_t\t\t*brushlist;\t// fragments of all brushes in this leaf\n\tdrawSurfRef_t\t*drawSurfReferences;\t// references to patches pushed down\n\n\tint\t\t\t\toccupied;\t// 1 or greater can reach entity\n\tentity_t\t\t*occupant;\t// for leak file testing\n\n\tstruct portal_s\t*portals;\t// also on nodes during construction\n} node_t;\n\ntypedef struct portal_s {\n\tplane_t\t\tplane;\n\tnode_t\t\t*onnode;\t\t// NULL = outside box\n\tnode_t\t\t*nodes[2];\t\t// [0] = front side of plane\n\tstruct portal_s\t*next[2];\n\twinding_t\t*winding;\n\n\tqboolean\tsidefound;\t\t// false if ->side hasn't been checked\n\tqboolean\thint;\n\tside_t\t\t*side;\t\t\t// NULL = non-visible\n} portal_t;\n\ntypedef struct {\n\tnode_t\t\t*headnode;\n\tnode_t\t\toutside_node;\n\tvec3_t\t\tmins, maxs;\n} tree_t;\n\nextern\tint\t\t\tentity_num;\n\n\nextern\tqboolean\tnoprune;\nextern\tqboolean\tnodetail;\nextern\tqboolean\tfulldetail;\nextern\tqboolean\tnowater;\nextern\tqboolean\tnoCurveBrushes;\nextern\tqboolean\tfakemap;\nextern\tqboolean\tcoplanar;\nextern\tqboolean\tnofog;\nextern\tqboolean\ttestExpand;\nextern\tqboolean\tshowseams;\n\nextern\tvec_t\t\tmicrovolume;\n\nextern\tchar\t\toutbase[32];\nextern\tchar\t\tsource[1024];\n\nextern int\t\tsamplesize;\t\t\t//sample size in units\nextern int\t\tnovertexlighting;\nextern int\t\tnogridlighting;\n\n//=============================================================================\n\n// brush.c\n\nint\tCountBrushList (bspbrush_t *brushes);\nbspbrush_t *AllocBrush (int numsides);\nvoid FreeBrush (bspbrush_t *brushes);\nvoid FreeBrushList (bspbrush_t *brushes);\nbspbrush_t *CopyBrush (bspbrush_t *brush);\nvoid DrawBrushList (bspbrush_t *brush);\nvoid WriteBrushList (char *name, bspbrush_t *brush, qboolean onlyvis);\nvoid PrintBrush (bspbrush_t *brush);\nqboolean BoundBrush (bspbrush_t *brush);\nqboolean CreateBrushWindings (bspbrush_t *brush);\nbspbrush_t\t*BrushFromBounds (vec3_t mins, vec3_t maxs);\nvec_t BrushVolume (bspbrush_t *brush);\nvoid WriteBspBrushMap (char *name, bspbrush_t *list);\n\nvoid FilterDetailBrushesIntoTree( entity_t *e, tree_t *tree );\nvoid FilterStructuralBrushesIntoTree( entity_t *e, tree_t *tree );\n\n//=============================================================================\n\n// map.c\n\nextern\tint\t\t\tentitySourceBrushes;\n\n// mapplanes[ num^1 ] will always be the mirror or mapplanes[ num ]\n// nummapplanes will always be even\nextern\tplane_t\t\tmapplanes[MAX_MAP_PLANES];\nextern\tint\t\t\tnummapplanes;\n\nextern\tvec3_t\t\tmap_mins, map_maxs;\n\nextern\tchar\t\tmapIndexedShaders[MAX_MAP_BRUSHSIDES][MAX_QPATH];\nextern\tint\t\t\tnumMapIndexedShaders;\n\nextern\tentity_t\t*mapent;\n\n#define\t\tMAX_BUILD_SIDES\t\t300\nextern\tbspbrush_t\t*buildBrush;\n\n\nvoid \t\tLoadMapFile (char *filename);\nint\t\t\tFindFloatPlane (vec3_t normal, vec_t dist);\nint\t\t\tPlaneTypeForNormal (vec3_t normal);\nbspbrush_t\t*FinishBrush( void );\nmapDrawSurface_t\t*AllocDrawSurf( void );\nmapDrawSurface_t\t*DrawSurfaceForSide( bspbrush_t *b, side_t *s, winding_t *w );\n\n//=============================================================================\n\n//=============================================================================\n\n// draw.c\n\nextern\tvec3_t\t\tdraw_mins, draw_maxs;\nextern\tqboolean\tdrawflag;\n\nvoid Draw_ClearWindow (void);\nvoid DrawWinding (winding_t *w);\n\nvoid GLS_BeginScene (void);\nvoid GLS_Winding (winding_t *w, int code);\nvoid GLS_EndScene (void);\n\n//=============================================================================\n\n// csg\n\nbspbrush_t *MakeBspBrushList ( bspbrush_t *brushes,\tvec3_t clipmins, vec3_t clipmaxs);\n\n//=============================================================================\n\n// brushbsp\n\n#define\tPSIDE_FRONT\t\t\t1\n#define\tPSIDE_BACK\t\t\t2\n#define\tPSIDE_BOTH\t\t\t(PSIDE_FRONT|PSIDE_BACK)\n#define\tPSIDE_FACING\t\t4\n\nint BoxOnPlaneSide (vec3_t mins, vec3_t maxs, plane_t *plane);\nqboolean WindingIsTiny (winding_t *w);\n\nvoid SplitBrush (bspbrush_t *brush, int planenum,\n\tbspbrush_t **front, bspbrush_t **back);\n\ntree_t *AllocTree (void);\nnode_t *AllocNode (void);\n\ntree_t *BrushBSP (bspbrush_t *brushlist, vec3_t mins, vec3_t maxs);\n\n//=============================================================================\n\n// portals.c\n\nvoid MakeHeadnodePortals (tree_t *tree);\nvoid MakeNodePortal (node_t *node);\nvoid SplitNodePortals (node_t *node);\n\nqboolean\tPortal_Passable(portal_t *p);\n\nqboolean FloodEntities (tree_t *tree);\nvoid FillOutside (node_t *headnode);\nvoid FloodAreas (tree_t *tree);\nbspface_t *VisibleFaces(entity_t *e, tree_t *tree);\nvoid FreePortal (portal_t *p);\n\nvoid MakeTreePortals (tree_t *tree);\n\n//=============================================================================\n\n// glfile.c\n\nvoid OutputWinding( winding_t *w, FILE *glview );\nvoid WriteGLView( tree_t *tree, char *source );\n\n//=============================================================================\n\n// leakfile.c\n\nvoid LeakFile( tree_t *tree );\n\n//=============================================================================\n\n// prtfile.c\n\nvoid NumberClusters( tree_t *tree );\nvoid WritePortalFile( tree_t *tree );\n\n//=============================================================================\n\n// writebsp.c\n\nvoid SetModelNumbers (void);\nvoid SetLightStyles (void);\n\nint\tEmitShader( const char *shader );\n\nvoid BeginBSPFile (void);\nvoid EndBSPFile (void);\n\nvoid BeginModel (void);\nvoid EndModel( node_t *headnode );\n\n\n//=============================================================================\n\n// tree.c\n\nvoid FreeTree (tree_t *tree);\nvoid FreeTree_r (node_t *node);\nvoid PrintTree_r (node_t *node, int depth);\nvoid FreeTreePortals_r (node_t *node);\n\n//=============================================================================\n\n// patch.c\n\nextern\tint\t\t\tnumMapPatches;\n\nmapDrawSurface_t\t*DrawSurfaceForMesh( mesh_t *m );\nvoid ParsePatch( void );\nmesh_t *SubdivideMesh( mesh_t in, float maxError, float minLength );\nvoid PatchMapDrawSurfs( entity_t *e );\n\n//=============================================================================\n\n// lightmap.c\n\nvoid AllocateLightmaps( entity_t *e );\n\n//=============================================================================\n\n// tjunction.c\n\nvoid FixTJunctions( entity_t *e );\n\n\n//=============================================================================\n\n// fog.c\n\nvoid FogDrawSurfs( void );\nwinding_t\t*WindingFromDrawSurf( mapDrawSurface_t *ds );\n\n//=============================================================================\n\n// facebsp.c\n\nbspface_t\t*BspFaceForPortal( portal_t *p );\nbspface_t\t*MakeStructuralBspFaceList( bspbrush_t *list );\nbspface_t\t*MakeVisibleBspFaceList( bspbrush_t *list );\ntree_t *FaceBSP( bspface_t *list );\n\n//=============================================================================\n\n// misc_model.c\n\nextern\tint\t\tc_triangleModels;\nextern\tint\t\tc_triangleSurfaces;\nextern\tint\t\tc_triangleVertexes;\nextern\tint\t\tc_triangleIndexes;\n\nvoid AddTriangleModels( tree_t *tree );\n\n//=============================================================================\n\n// surface.c\n\nextern\tmapDrawSurface_t\tmapDrawSurfs[MAX_MAP_DRAW_SURFS];\nextern\tint\t\t\tnumMapDrawSurfs;\n\nmapDrawSurface_t\t*AllocDrawSurf( void );\nvoid\tMergeSides( entity_t *e, tree_t *tree );\nvoid\tSubdivideDrawSurfs( entity_t *e, tree_t *tree );\nvoid\tMakeDrawSurfaces( bspbrush_t *b );\nvoid\tClipSidesIntoTree( entity_t *e, tree_t *tree );\nvoid FilterDrawsurfsIntoTree( entity_t *e, tree_t *tree );\n\n//==============================================================================\n\n// brush_primit.c\n\n#define BPRIMIT_UNDEFINED 0\n#define BPRIMIT_OLDBRUSHES 1\n#define BPRIMIT_NEWBRUSHES 2\nextern\tint\tg_bBrushPrimit;\n\nvoid ComputeAxisBase( vec3_t normal, vec3_t texX, vec3_t texY);\n"
  },
  {
    "path": "q3map/shaders.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include <string.h>\n#include <math.h>\n#include \"cmdlib.h\"\n#include \"mathlib.h\"\n#include \"imagelib.h\"\n#include \"scriplib.h\"\n\n#ifdef _TTIMOBUILD\n#include \"../common/qfiles.h\"\n#include \"../common/surfaceflags.h\"\n#else\n#include \"../code/qcommon/qfiles.h\"\n#include \"../code/game/surfaceflags.h\"\n#endif\n\n#include \"shaders.h\"\n#ifdef _WIN32\n\n#ifdef _TTIMOBUILD\n#include \"pakstuff.h\"\n#include \"jpeglib.h\"\n#else\n#include \"../libs/pakstuff.h\"\n#include \"../libs/jpeglib.h\"\n#endif\n\n#endif\n\n\n// 5% backsplash by default\n#define\tDEFAULT_BACKSPLASH_FRACTION\t\t0.05\n#define\tDEFAULT_BACKSPLASH_DISTANCE\t\t24\n\n\n#define\tMAX_SURFACE_INFO\t4096\n\nshaderInfo_t\tdefaultInfo;\nshaderInfo_t\tshaderInfo[MAX_SURFACE_INFO];\nint\t\t\t\tnumShaderInfo;\n\n\ntypedef struct {\n\tchar\t*name;\n\tint\t\tclearSolid, surfaceFlags, contents;\n} infoParm_t;\n\ninfoParm_t\tinfoParms[] = {\n\t// server relevant contents\n\t{\"water\",\t\t1,\t0,\tCONTENTS_WATER },\n\t{\"slime\",\t\t1,\t0,\tCONTENTS_SLIME },\t\t// mildly damaging\n\t{\"lava\",\t\t1,\t0,\tCONTENTS_LAVA },\t\t// very damaging\n\t{\"playerclip\",\t1,\t0,\tCONTENTS_PLAYERCLIP },\n\t{\"monsterclip\",\t1,\t0,\tCONTENTS_MONSTERCLIP },\n\t{\"nodrop\",\t\t1,\t0,\tCONTENTS_NODROP },\t\t// don't drop items or leave bodies (death fog, lava, etc)\n\t{\"nonsolid\",\t1,\tSURF_NONSOLID,\t0},\t\t\t\t\t\t// clears the solid flag\n\n\t// utility relevant attributes\n\t{\"origin\",\t\t1,\t0,\tCONTENTS_ORIGIN },\t\t// center of rotating brushes\n\t{\"trans\",\t\t0,\t0,\tCONTENTS_TRANSLUCENT },\t// don't eat contained surfaces\n\t{\"detail\",\t\t0,\t0,\tCONTENTS_DETAIL },\t\t// don't include in structural bsp\n\t{\"structural\",\t0,\t0,\tCONTENTS_STRUCTURAL },\t// force into structural bsp even if trnas\n\t{\"areaportal\",\t1,\t0,\tCONTENTS_AREAPORTAL },\t// divides areas\n\t{\"clusterportal\",1, 0,  CONTENTS_CLUSTERPORTAL },// for bots\n\t{\"donotenter\",  1,  0,  CONTENTS_DONOTENTER },\t// for bots\n\t{\"botclip\",     1,  0,  CONTENTS_BOTCLIP },\t\t// for bots\n\t{\"nobotclip\",\t0,\t0,\tCONTENTS_NOBOTCLIP },\t// don't use for bot clipping\n\n\t{\"fog\",\t\t\t1,\t0,\tCONTENTS_FOG},\t\t\t// carves surfaces entering\n\t{\"sky\",\t\t\t0,\tSURF_SKY,\t\t0 },\t\t// emit light from an environment map\n\t{\"lightfilter\",\t0,\tSURF_LIGHTFILTER, 0 },\t\t// filter light going through it\n\t{\"alphashadow\",\t0,\tSURF_ALPHASHADOW, 0 },\t\t// test light on a per-pixel basis\n\t{\"hint\",\t\t0,\tSURF_HINT,\t\t0 },\t\t// use as a primary splitter\n\n\t// server attributes\n\t{\"slick\",\t\t0,\tSURF_SLICK,\t\t0 },\n\t{\"noimpact\",\t0,\tSURF_NOIMPACT,\t0 },\t\t// don't make impact explosions or marks\n\t{\"nomarks\",\t\t0,\tSURF_NOMARKS,\t0 },\t\t// don't make impact marks, but still explode\n\t{\"ladder\",\t\t0,\tSURF_LADDER,\t0 },\n\t{\"nodamage\",\t0,\tSURF_NODAMAGE,\t0 },\n\t{\"metalsteps\",\t0,\tSURF_METALSTEPS,0 },\n\t{\"flesh\",\t\t0,\tSURF_FLESH,\t\t0 },\n\t{\"nosteps\",\t\t0,\tSURF_NOSTEPS,\t0 },\n\n\t// drawsurf attributes\n\t{\"nodraw\",\t\t0,\tSURF_NODRAW,\t0 },\t\t// don't generate a drawsurface (or a lightmap)\n\t{\"pointlight\",\t0,\tSURF_POINTLIGHT, 0 },\t\t// sample lighting at vertexes\n\t{\"nolightmap\",\t0,\tSURF_NOLIGHTMAP,0 },\t\t// don't generate a lightmap\n\t{\"nodlight\",\t0,\tSURF_NODLIGHT, 0 },\t\t\t// don't ever add dynamic lights\n\t{\"dust\",\t\t0,\tSURF_DUST, 0}\t\t\t\t// leave dust trail when walking on this surface\n};\n\n\n/*\n===============\nLoadShaderImage\n===============\n*/\n\nbyte* LoadImageFile(char *filename, qboolean *bTGA)\n{\n  byte *buffer = NULL;\n  int nLen = 0;\n  *bTGA = qtrue;\n  if (FileExists(filename))\n  {\n    LoadFileBlock(filename, &buffer);\n  }\n#ifdef _WIN32\n  else\n  {\n    PakLoadAnyFile(filename, &buffer);\n  }\n#endif\n  if ( buffer == NULL)\n  {\n    nLen = strlen(filename);\n    filename[nLen-3] = 'j';\n    filename[nLen-2] = 'p';\n    filename[nLen-1] = 'g';\n    if (FileExists(filename))\n    {\n      LoadFileBlock(filename, &buffer);\n    }\n#ifdef _WIN32\n    else\n    {\n      PakLoadAnyFile(filename, &buffer);\n    }\n#endif\n    if ( buffer )\n    {\n      *bTGA = qfalse;\n    }\n  }\n  return buffer;\n}\n\n/*\n===============\nLoadShaderImage\n===============\n*/\nstatic void LoadShaderImage( shaderInfo_t *si ) {\n\tchar\t\t\tfilename[1024];\n\tint\t\t\t\ti, count;\n\tfloat\t\t\tcolor[4];\n  byte      *buffer;\n  qboolean  bTGA = qtrue;\n\n\t// look for the lightimage if it is specified\n\tif ( si->lightimage[0] ) {\n\t\tsprintf( filename, \"%s%s\", gamedir, si->lightimage );\n\t\tDefaultExtension( filename, \".tga\" );\n    buffer = LoadImageFile(filename, &bTGA);\n    if ( buffer != NULL) {\n      goto loadTga;\n    }\n  }\n\n\t// look for the editorimage if it is specified\n\tif ( si->editorimage[0] ) {\n\t\tsprintf( filename, \"%s%s\", gamedir, si->editorimage );\n\t\tDefaultExtension( filename, \".tga\" );\n    buffer = LoadImageFile(filename, &bTGA);\n    if ( buffer != NULL) {\n      goto loadTga;\n    }\n  }\n\n  // just try the shader name with a .tga\n\t// on unix, we have case sensitivity problems...\n  sprintf( filename, \"%s%s.tga\", gamedir, si->shader );\n  buffer = LoadImageFile(filename, &bTGA);\n  if ( buffer != NULL) {\n\t\tgoto loadTga;\n\t}\n\n  sprintf( filename, \"%s%s.TGA\", gamedir, si->shader );\n  buffer = LoadImageFile(filename, &bTGA);\n  if ( buffer != NULL) {\n\t\tgoto loadTga;\n\t}\n\n\t// couldn't load anything\n\t_printf(\"WARNING: Couldn't find image for shader %s\\n\", si->shader );\n\n\tsi->color[0] = 1;\n\tsi->color[1] = 1;\n\tsi->color[2] = 1;\n\tsi->width = 64;\n\tsi->height = 64;\n\tsi->pixels = malloc( si->width * si->height * 4 );\n\tmemset ( si->pixels, 255, si->width * si->height * 4 );\n\treturn;\n\n\t// load the image to get dimensions and color\nloadTga:\n  if ( bTGA) {\n\t  LoadTGABuffer( buffer, &si->pixels, &si->width, &si->height );\n  }\n  else {\n#ifdef _WIN32\n    LoadJPGBuff(buffer, &si->pixels, &si->width, &si->height );\n#endif\n  }\n\n  free(buffer);\n\n\tcount = si->width * si->height;\n\n\tVectorClear( color );\n\tcolor[ 3 ] = 0;\n\tfor ( i = 0 ; i < count ; i++ ) {\n\t\tcolor[0] += si->pixels[ i * 4 + 0 ];\n\t\tcolor[1] += si->pixels[ i * 4 + 1 ];\n\t\tcolor[2] += si->pixels[ i * 4 + 2 ];\n\t\tcolor[3] += si->pixels[ i * 4 + 3 ];\n\t}\n\tColorNormalize( color, si->color );\n\tVectorScale( color, 1.0/count, si->averageColor );\n}\n\n/*\n===============\nAllocShaderInfo\n===============\n*/\nstatic shaderInfo_t\t*AllocShaderInfo( void ) {\n\tshaderInfo_t\t*si;\n\n\tif ( numShaderInfo == MAX_SURFACE_INFO ) {\n\t\tError( \"MAX_SURFACE_INFO\" );\n\t}\n\tsi = &shaderInfo[ numShaderInfo ];\n\tnumShaderInfo++;\n\n\t// set defaults\n\n\tsi->contents = CONTENTS_SOLID;\n\n\tsi->backsplashFraction = DEFAULT_BACKSPLASH_FRACTION;\n\tsi->backsplashDistance = DEFAULT_BACKSPLASH_DISTANCE;\n\n\tsi->lightmapSampleSize = 0;\n\tsi->forceTraceLight = qfalse;\n\tsi->forceVLight = qfalse;\n\tsi->patchShadows = qfalse;\n\tsi->vertexShadows = qfalse;\n\tsi->noVertexShadows = qfalse;\n\tsi->forceSunLight = qfalse;\n\tsi->vertexScale = 1.0;\n\tsi->notjunc = qfalse;\n\n\treturn si;\n}\n\n/*\n===============\nShaderInfoForShader\n===============\n*/\nshaderInfo_t\t*ShaderInfoForShader( const char *shaderName ) {\n\tint\t\t\t\ti;\n\tshaderInfo_t\t*si;\n\tchar\t\t\tshader[MAX_QPATH];\n\n\t// strip off extension\n\tstrcpy( shader, shaderName );\n\tStripExtension( shader );\n\n\t// search for it\n\tfor ( i = 0 ; i < numShaderInfo ; i++ ) {\n\t\tsi = &shaderInfo[ i ];\n\t\tif ( !Q_stricmp( shader, si->shader ) ) {\n\t\t\tif ( !si->width ) {\n\t\t\t\tLoadShaderImage( si );\n\t\t\t}\n\t\t\treturn si;\n\t\t}\n\t}\n\n\tsi = AllocShaderInfo();\n\tstrcpy( si->shader, shader );\n\n\tLoadShaderImage( si );\n\n\treturn si;\n}\n\n/*\n===============\nParseShaderFile\n===============\n*/\nstatic void ParseShaderFile( const char *filename ) {\n\tint\t\ti;\n\tint\t\tnumInfoParms = sizeof(infoParms) / sizeof(infoParms[0]);\n\tshaderInfo_t\t*si;\n\n//\tqprintf( \"shaderFile: %s\\n\", filename );\n\tLoadScriptFile( filename );\n\twhile ( 1 ) {\n\t\tif ( !GetToken( qtrue ) ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tsi = AllocShaderInfo();\n\t\tstrcpy( si->shader, token );\n\t\tMatchToken( \"{\" );\n\t\twhile ( 1 ) {\n\t\t\tif ( !GetToken( qtrue ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( !strcmp( token, \"}\" ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// skip internal braced sections\n\t\t\tif ( !strcmp( token, \"{\" ) ) {\n\t\t\t\tsi->hasPasses = qtrue;\n\t\t\t\twhile ( 1 ) {\n\t\t\t\t\tif ( !GetToken( qtrue ) ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif ( !strcmp( token, \"}\" ) ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif ( !Q_stricmp( token, \"surfaceparm\" ) ) {\n\t\t\t\tGetToken( qfalse );\n\t\t\t\tfor ( i = 0 ; i < numInfoParms ; i++ ) {\n\t\t\t\t\tif ( !Q_stricmp( token, infoParms[i].name ) ) {\n\t\t\t\t\t\tsi->surfaceFlags |= infoParms[i].surfaceFlags;\n\t\t\t\t\t\tsi->contents |= infoParms[i].contents;\n\t\t\t\t\t\tif ( infoParms[i].clearSolid ) {\n\t\t\t\t\t\t\tsi->contents &= ~CONTENTS_SOLID;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( i == numInfoParms ) {\n\t\t\t\t\t// we will silently ignore all tokens beginning with qer,\n\t\t\t\t\t// which are QuakeEdRadient parameters\n\t\t\t\t\tif ( Q_strncasecmp( token, \"qer\", 3 ) ) {\n\t\t\t\t\t\t_printf( \"Unknown surfaceparm: \\\"%s\\\"\\n\", token );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\n\t\t\t// qer_editorimage <image>\n\t\t\tif ( !Q_stricmp( token, \"qer_editorimage\" ) ) {\n\t\t\t\tGetToken( qfalse );\n\t\t\t\tstrcpy( si->editorimage, token );\n\t\t\t\tDefaultExtension( si->editorimage, \".tga\" );\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// q3map_lightimage <image>\n\t\t\tif ( !Q_stricmp( token, \"q3map_lightimage\" ) ) {\n\t\t\t\tGetToken( qfalse );\n\t\t\t\tstrcpy( si->lightimage, token );\n\t\t\t\tDefaultExtension( si->lightimage, \".tga\" );\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// q3map_surfacelight <value>\n\t\t\tif ( !Q_stricmp( token, \"q3map_surfacelight\" )  ) {\n\t\t\t\tGetToken( qfalse );\n\t\t\t\tsi->value = atoi( token );\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// q3map_lightsubdivide <value>\n\t\t\tif ( !Q_stricmp( token, \"q3map_lightsubdivide\" )  ) {\n\t\t\t\tGetToken( qfalse );\n\t\t\t\tsi->lightSubdivide = atoi( token );\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// q3map_lightmapsamplesize <value>\n\t\t\tif ( !Q_stricmp( token, \"q3map_lightmapsamplesize\" ) ) {\n\t\t\t\tGetToken( qfalse );\n\t\t\t\tsi->lightmapSampleSize = atoi( token );\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// q3map_tracelight\n\t\t\tif ( !Q_stricmp( token, \"q3map_tracelight\" ) ) {\n\t\t\t\tsi->forceTraceLight = qtrue;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// q3map_vlight\n\t\t\tif ( !Q_stricmp( token, \"q3map_vlight\" ) ) {\n\t\t\t\tsi->forceVLight = qtrue;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// q3map_patchshadows\n\t\t\tif ( !Q_stricmp( token, \"q3map_patchshadows\" ) ) {\n\t\t\t\tsi->patchShadows = qtrue;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// q3map_vertexshadows\n\t\t\tif ( !Q_stricmp( token, \"q3map_vertexshadows\" ) ) {\n\t\t\t\tsi->vertexShadows = qtrue;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// q3map_novertexshadows\n\t\t\tif ( !Q_stricmp( token, \"q3map_novertexshadows\" ) ) {\n\t\t\t\tsi->noVertexShadows = qtrue;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// q3map_forcesunlight\n\t\t\tif ( !Q_stricmp( token, \"q3map_forcesunlight\" ) ) {\n\t\t\t\tsi->forceSunLight = qtrue;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// q3map_vertexscale\n\t\t\tif ( !Q_stricmp( token, \"q3map_vertexscale\" ) ) {\n\t\t\t\tGetToken( qfalse );\n\t\t\t\tsi->vertexScale = atof(token);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// q3map_notjunc\n\t\t\tif ( !Q_stricmp( token, \"q3map_notjunc\" ) ) {\n\t\t\t\tsi->notjunc = qtrue;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// q3map_globaltexture\n\t\t\tif ( !Q_stricmp( token, \"q3map_globaltexture\" )  ) {\n\t\t\t\tsi->globalTexture = qtrue;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// q3map_backsplash <percent> <distance>\n\t\t\tif ( !Q_stricmp( token, \"q3map_backsplash\" ) ) {\n\t\t\t\tGetToken( qfalse );\n\t\t\t\tsi->backsplashFraction = atof( token ) * 0.01;\n\t\t\t\tGetToken( qfalse );\n\t\t\t\tsi->backsplashDistance = atof( token );\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// q3map_backshader <shader>\n\t\t\tif ( !Q_stricmp( token, \"q3map_backshader\" ) ) {\n\t\t\t\tGetToken( qfalse );\n\t\t\t\tstrcpy( si->backShader, token );\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// q3map_flare <shader>\n\t\t\tif ( !Q_stricmp( token, \"q3map_flare\" ) ) {\n\t\t\t\tGetToken( qfalse );\n\t\t\t\tstrcpy( si->flareShader, token );\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// light <value> \n\t\t\t// old style flare specification\n\t\t\tif ( !Q_stricmp( token, \"light\" ) ) {\n\t\t\t\tGetToken( qfalse );\n\t\t\t\tstrcpy( si->flareShader, \"flareshader\" );\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// q3map_sun <red> <green> <blue> <intensity> <degrees> <elivation>\n\t\t\t// color will be normalized, so it doesn't matter what range you use\n\t\t\t// intensity falls off with angle but not distance 100 is a fairly bright sun\n\t\t\t// degree of 0 = from the east, 90 = north, etc.  altitude of 0 = sunrise/set, 90 = noon\n\t\t\tif ( !Q_stricmp( token, \"q3map_sun\" ) ) {\n\t\t\t\tfloat\ta, b;\n\n\t\t\t\tGetToken( qfalse );\n\t\t\t\tsi->sunLight[0] = atof( token );\n\t\t\t\tGetToken( qfalse );\n\t\t\t\tsi->sunLight[1] = atof( token );\n\t\t\t\tGetToken( qfalse );\n\t\t\t\tsi->sunLight[2] = atof( token );\n\t\t\t\t\n\t\t\t\tVectorNormalize( si->sunLight, si->sunLight);\n\n\t\t\t\tGetToken( qfalse );\n\t\t\t\ta = atof( token );\n\t\t\t\tVectorScale( si->sunLight, a, si->sunLight);\n\n\t\t\t\tGetToken( qfalse );\n\t\t\t\ta = atof( token );\n\t\t\t\ta = a / 180 * Q_PI;\n\n\t\t\t\tGetToken( qfalse );\n\t\t\t\tb = atof( token );\n\t\t\t\tb = b / 180 * Q_PI;\n\n\t\t\t\tsi->sunDirection[0] = cos( a ) * cos( b );\n\t\t\t\tsi->sunDirection[1] = sin( a ) * cos( b );\n\t\t\t\tsi->sunDirection[2] = sin( b );\n\n\t\t\t\tsi->surfaceFlags |= SURF_SKY;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// tesssize is used to force liquid surfaces to subdivide\n\t\t\tif ( !Q_stricmp( token, \"tesssize\" ) ) {\n\t\t\t\tGetToken( qfalse );\n\t\t\t\tsi->subdivisions = atof( token );\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// cull none will set twoSided\n\t\t\tif ( !Q_stricmp( token, \"cull\" ) ) {\n\t\t\t\tGetToken( qfalse );\n\t\t\t\tif ( !Q_stricmp( token, \"none\" ) ) {\n\t\t\t\t\tsi->twoSided = qtrue;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\n\t\t\t// deformVertexes autosprite[2]\n\t\t\t// we catch this so autosprited surfaces become point\n\t\t\t// lights instead of area lights\n\t\t\tif ( !Q_stricmp( token, \"deformVertexes\" ) ) {\n\t\t\t\tGetToken( qfalse );\n\t\t\t\tif ( !Q_strncasecmp( token, \"autosprite\", 10 ) ) {\n\t\t\t\t\tsi->autosprite = qtrue;\n          si->contents = CONTENTS_DETAIL;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\n\t\t\t// ignore all other tokens on the line\n\n\t\t\twhile ( TokenAvailable() ) {\n\t\t\t\tGetToken( qfalse );\n\t\t\t}\n\t\t}\t\t\t\n\t}\n}\n\n/*\n===============\nLoadShaderInfo\n===============\n*/\n#define\tMAX_SHADER_FILES\t64\nvoid LoadShaderInfo( void ) {\n\tchar\t\t\tfilename[1024];\n\tint\t\t\t\ti;\n\tchar\t\t\t*shaderFiles[MAX_SHADER_FILES];\n\tint\t\t\t\tnumShaderFiles;\n\n\tsprintf( filename, \"%sscripts/shaderlist.txt\", gamedir );\n\tLoadScriptFile( filename );\n\n\tnumShaderFiles = 0;\n\twhile ( 1 ) {\n\t\tif ( !GetToken( qtrue ) ) {\n\t\t\tbreak;\n\t\t}\n    shaderFiles[numShaderFiles] = malloc(MAX_OS_PATH);\n\t\tstrcpy( shaderFiles[ numShaderFiles ], token );\n\t\tnumShaderFiles++;\n\t}\n\n\tfor ( i = 0 ; i < numShaderFiles ; i++ ) {\n\t\tsprintf( filename, \"%sscripts/%s.shader\", gamedir, shaderFiles[i] );\n\t\tParseShaderFile( filename );\n    free(shaderFiles[i]);\n\t}\n\n\tqprintf( \"%5i shaderInfo\\n\", numShaderInfo);\n}\n\n"
  },
  {
    "path": "q3map/shaders.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n\ntypedef struct shaderInfo_s {\n\tchar\t\tshader[MAX_QPATH];\n\tint\t\t\tsurfaceFlags;\n\tint\t\t\tcontents;\n\tint\t\t\tvalue;\n\n\tchar\t\tbackShader[MAX_QPATH];\t// for surfaces that generate different front and back passes\n\tchar\t\tflareShader[MAX_QPATH];\t// for light flares\n\n\tfloat\t\tsubdivisions;\t\t\t// from a \"tesssize xxx\"\n\tfloat\t\tbacksplashFraction;\t\t// floating point value, usually 0.05\n\tfloat\t\tbacksplashDistance;\t\t// default 16\n\tfloat\t\tlightSubdivide;\t\t\t// default 120\n\tint\t\t\tlightmapSampleSize;\t\t// lightmap sample size\n\n\tqboolean\thasPasses;\t\t\t\t// false if the shader doesn't define any rendering passes\n\n\tqboolean\tglobalTexture;\t\t\t// don't normalize texture repeats\n\n\tqboolean\ttwoSided;\t\t\t\t// cull none\n\tqboolean\tautosprite;\t\t\t\t// autosprite shaders will become point lights\n\t\t\t\t\t\t\t\t\t\t// instead of area lights\n\tqboolean\tlightFilter;\t\t\t// light rays that cross surfaces of this type\n\t\t\t\t\t\t\t\t\t\t// should test against the filter image\n\tqboolean\tforceTraceLight;\t\t// always use -light for this surface\n\tqboolean\tforceVLight;\t\t\t// always use -vlight for this surface\n\tqboolean\tpatchShadows;\t\t\t// have patches casting shadows when using -light for this surface\n\tqboolean\tvertexShadows;\t\t\t// shadows will be casted at this surface even when vertex lit\n\tqboolean\tnoVertexShadows;\t\t// no shadows will be casted at this surface in vertex lighting\n\tqboolean\tforceSunLight;\t\t\t// force sun light at this surface even tho we might not calculate shadows in vertex lighting\n\tqboolean\tnotjunc;\t\t\t\t// don't use this surface for tjunction fixing\n\tfloat\t\tvertexScale;\t\t\t// vertex light scale\n\n\tchar\t\teditorimage[MAX_QPATH];\t// use this image to generate texture coordinates\n\tchar\t\tlightimage[MAX_QPATH];\t// use this image to generate color / averageColor\n\tvec3_t\t\tcolor;\t\t\t\t\t// colorNormalized\n\tvec3_t\t\taverageColor;\n\n\tint\t\t\twidth, height;\n\tbyte\t\t*pixels;\n\n\tvec3_t\t\tsunLight;\n\tvec3_t\t\tsunDirection;\n} shaderInfo_t;\n\nvoid LoadShaderInfo( void );\nshaderInfo_t\t*ShaderInfoForShader( const char *shader );\n\n"
  },
  {
    "path": "q3map/soundv.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n/*****************************************************************************\n * name:\t\tsoundv.c\n *****************************************************************************/\n\n#include \"cmdlib.h\"\n#include \"mathlib.h\"\n#include \"bspfile.h\"\n#include \"imagelib.h\"\n#include \"threads.h\"\n#include \"mutex.h\"\n#include \"scriplib.h\"\n\n#include \"shaders.h\"\n#include \"mesh.h\"\n\n#ifdef _WIN32\n//Improve floating-point consistency.\n#pragma optimize( \"p\", on )\n#endif\n\n#ifdef _WIN32\n#include \"../libs/pakstuff.h\"\n#endif\n\n#define MAX_CLUSTERS\t\t16384\n#define\tMAX_PORTALS\t\t\t32768\n#define MAX_FACETS\t\t\t65536\n#define MAX_LIGHTS\t\t\t16384\n\n#define LIGHTMAP_SIZE\t\t128\n\n#define LIGHTMAP_PIXELSHIFT\t\t0.5\n\n//#define LIGHTMAP_PATCHSHIFT\n\n#define\tPORTALFILE\t\"PRT1\"\n\n#define\tON_EPSILON\t0.1\n\n#define VectorSet(v, x, y, z)\t\tv[0] = x;v[1] = y;v[2] = z;\n\ntypedef struct\n{\n\tvec3_t\t\tnormal;\n\tfloat\t\tdist;\n} plane_t;\n\n#define MAX_POINTS_ON_WINDING\t64\n//NOTE: whenever this is overflowed parts of lightmaps might end up not being lit\n#define\tMAX_POINTS_ON_FIXED_WINDING\t48\n\ntypedef struct\n{\n\tint\t\tnumpoints;\n\tvec3_t\tpoints[MAX_POINTS_ON_FIXED_WINDING];\t\t\t// variable sized\n} winding_t;\n\ntypedef struct\n{\n\tplane_t\t\tplane;\t// normal pointing into neighbor\n\tint\t\t\tleaf;\t// neighbor\n\twinding_t\t*winding;\n\tvec3_t\t\torigin;\t// for fast clip testing\n\tfloat\t\tradius;\n} lportal_t;\n\n#define\tMAX_PORTALS_ON_LEAF\t\t128\ntypedef struct lleaf_s\n{\n\tint\t\t\tnumportals;\n\tlportal_t\t*portals[MAX_PORTALS_ON_LEAF];\n\t//\n\tint\t\t\tnumSurfaces;\n\tint\t\t\tfirstSurface;\n} lleaf_t;\n\ntypedef struct lFacet_s\n{\n\tint\t\tnum;\n\tplane_t\tplane;\n\tvec3_t\tpoints[4];\t\t\t\t//\n\tint\t\tnumpoints;\n\tfloat\tlightmapCoords[4][2];\n\tplane_t boundaries[4];\t\t\t// negative is outside the bounds\n\tfloat\ttextureMatrix[2][4];\t// texture coordinates for translucency\n\tfloat\tlightmapMatrix[2][4];\t// lightmap texture coordinates\n\tvec3_t\tmins;\n\tint\t\tx, y, width, height;\n} lFacet_t;\n\ntypedef struct lsurfaceTest_s\n{\n\tvec3_t\t\t\tmins, maxs;\n\tvec3_t\t\t\torigin;\n\tfloat\t\t\tradius;\n\tqboolean\t\tpatch;\t\t\t// true if this is a patch\n\tqboolean\t\ttrisoup;\t\t// true if this is a triangle soup\n\tint\t\t\t\tnumFacets;\n\tlFacet_t\t\t*facets;\n\tmesh_t\t\t\t*detailMesh;\t// detailed mesh with points for each lmp\n\tshaderInfo_t\t*shader;\t\t// for translucency\n\tmutex_t\t\t\t*mutex;\n\tint\t\t\t\tnumvolumes;\t\t// number of volumes casted at this surface\n\t//\n\tint\t\t\t\talways_tracelight;\n\tint\t\t\t\talways_vsound;\n} lsurfaceTest_t;\n\n//volume types\n#define VOLUME_NORMAL\t\t\t0\n#define VOLUME_DIRECTED\t\t\t1\n\n#define MAX_TRANSLUCENTFACETS\t32\n\ntypedef struct lightvolume_s\n{\n\tint num;\n\tint cluster;\t\t\t\t\t\t\t//cluster this light volume started in\n\tplane_t endplane;\t\t\t\t\t\t//end plane\n\tplane_t farplane;\t\t\t\t\t\t//original end plane\n\tvec3_t points[MAX_POINTS_ON_WINDING];\t//end winding points\n\tplane_t planes[MAX_POINTS_ON_WINDING];\t//volume bounding planes\n\tint numplanes;\t\t\t\t\t\t\t//number of volume bounding planes\n\tint type;\t\t\t\t\t\t\t\t//light volume type\n\t//list with translucent surfaces the volume went through\n\tint transFacets[MAX_TRANSLUCENTFACETS];\n\tint transSurfaces[MAX_TRANSLUCENTFACETS];\n\tint numtransFacets;\n\t//clusters already tested\n\tbyte clusterTested[MAX_CLUSTERS/8];\n\t//facets already tested\n\tbyte facetTested[MAX_FACETS/8];\n\tint facetNum;\t\t\t//number of the facet blocking the light in this volume\n\tint surfaceNum;\t\t\t//number of the surface blocking the light in this volume\n} lightvolume_t;\n\n//light types\n#define LIGHT_POINTRADIAL\t\t\t1\n#define LIGHT_POINTSPOT\t\t\t\t2\n#define LIGHT_POINTFAKESURFACE\t\t3\n#define LIGHT_SURFACEDIRECTED\t\t4\n#define LIGHT_SURFACERADIAL\t\t\t5\n#define LIGHT_SURFACESPOT\t\t\t6\n\n//light distance attenuation types\n#define LDAT_QUADRATIC\t\t\t\t0\n#define LDAT_LINEAR\t\t\t\t\t1\n#define LDAT_NOSCALE\t\t\t\t2\n\n//light angle attenuation types\n#define LAAT_NORMAL\t\t\t\t\t0\n#define LAAT_QUADRATIC\t\t\t\t1\n#define LAAT_DOUBLEQUADRATIC\t\t2\n\ntypedef struct vsound_s\n{\n\tvec3_t origin;\t\t\t\t//light origin, for point lights\n\twinding_t w;\t\t\t\t//light winding, for area lights\n\tvec4_t plane;\t\t\t\t//light winding plane\n\tvec3_t normal;\t\t\t\t//direction of the light\n\tint type;\t\t\t\t\t//light type\n\tvec3_t color;\t\t\t\t//light color\n\tqboolean twosided;\t\t\t//radiates light at both sides of the winding\n\tint style;\t\t\t\t\t//light style (not used)\n\tint atten_disttype;\t\t\t//light distance attenuation type\n\tint atten_angletype;\t\t//light angle attenuation type\n\tfloat atten_distscale;\t\t//distance attenuation scale\n\tfloat atten_anglescale;\t\t//angle attenuation scale\n\tfloat radiusByDist;\t\t\t//radius by distance for spot lights\n\tfloat photons;\t\t\t\t//emitted photons\n\tfloat intensity;\t\t\t//intensity\n\tvec3_t emitColor;\t\t\t//full out-of-gamut value (not used)\n\tstruct shaderInfo_s\t*si;\t//shader info\n\tint insolid;\t\t\t\t//set when light is in solid\n} vsound_t;\n\nstatic float\tlightLinearScale\t\t\t= 1.0 / 8000;\nstatic float\tlightPointScale\t\t\t\t= 7500;\nstatic float\tlightAreaScale\t\t\t\t= 0.25;\nstatic float\tlightFormFactorValueScale\t= 3;\nstatic int\t\tlightDefaultSubdivide\t\t= 999;\t\t// vary by surface size?\nstatic vec3_t\tlightAmbientColor;\n\nstatic int\t\t\tportalclusters, numportals, numfaces;\nstatic lleaf_t\t\t*leafs;\nstatic lportal_t\t*portals;\nstatic int\t\t\tnumvsounds = 0;\nstatic vsound_t\t*vsounds[MAX_LIGHTS];\nstatic int\t\t\tnostitching = 0;\nstatic int\t\t\tnoalphashading = 0;\nstatic int\t\t\tnocolorshading = 0;\nstatic int\t\t\tnobackfaceculling = 0;\nstatic int\t\t\tdefaulttracelight = 0;\nstatic int\t\t\tradiosity = 0;\nstatic int\t\t\tradiosity_scale;\n\nstatic int\t\t\t\tclustersurfaces[MAX_MAP_LEAFFACES];\nstatic int\t\t\t\tnumclustersurfaces = 0;\nstatic lsurfaceTest_t\t*lsurfaceTest[MAX_MAP_DRAW_SURFS];\nstatic int\t\t\t\tnumfacets;\nstatic float\t\t\tlightmappixelarea[MAX_MAP_LIGHTING/3];\nstatic float\t\t\t*lightFloats;//[MAX_MAP_LIGHTING];\n\n// from polylib.c\nwinding_t\t*AllocWinding (int points);\nvoid\t\tFreeWinding (winding_t *w);\nvoid\t\tWindingCenter (winding_t *w, vec3_t center);\nvoid\t\tWindingBounds (winding_t *w, vec3_t mins, vec3_t maxs);\nvec_t\t\tWindingArea (winding_t *w);\nwinding_t\t*BaseWindingForPlane (vec3_t normal, vec_t dist);\nvoid\t\tClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist, \n\t\t\t\tvec_t epsilon, winding_t **front, winding_t **back);\nwinding_t\t*ReverseWinding (winding_t *w);\n\n// from light.c\nextern char\t\tsource[1024];\nextern vec3_t\tsurfaceOrigin[ MAX_MAP_DRAW_SURFS ];\nextern int\t\tentitySurface[ MAX_MAP_DRAW_SURFS ];\nextern int\t\tsamplesize;\nextern qboolean\tpatchshadows;\nextern vec3_t\tgridSize;\n\nfloat PointToPolygonFormFactor( const vec3_t point, const vec3_t normal, const winding_t *w );\nvoid ColorToBytes( const float *color, byte *colorBytes );\nvoid CountLightmaps( void );\nvoid GridAndVertexLighting( void );\nvoid SetEntityOrigins( void );\n\n\n//#define DEBUGNET\n\n#ifdef DEBUGNET\n\n#include \"l_net.h\"\n\nsocket_t *debug_socket;\n\n/*\n=====================\nDebugNet_Setup\n=====================\n*/\nvoid DebugNet_Setup(void)\n{\n\taddress_t address;\n\tint i;\n\n\tNet_Setup();\n\tNet_StringToAddress(\"127.0.0.1:28000\", &address);\n\tfor (i = 0; i < 10; i++)\n\t{\n\t\tdebug_socket = Net_Connect(&address, 28005 + i);\n\t\tif (debug_socket)\n\t\t\tbreak;\n\t}\n}\n\n/*\n=====================\nDebugNet_Shutdown\n=====================\n*/\nvoid DebugNet_Shutdown(void)\n{\n\tnetmessage_t msg;\n\n\tif (debug_socket)\n\t{\n\t\tNMSG_Clear(&msg);\n\t\tNMSG_WriteByte(&msg, 1);\n\t\tNet_Send(debug_socket, &msg);\n\t\tNet_Disconnect(debug_socket);\n\t}\n\tdebug_socket = NULL;\n\tNet_Shutdown();\n}\n\n/*\n=====================\nDebugNet_RemoveAllPolys\n=====================\n*/\nvoid DebugNet_RemoveAllPolys(void)\n{\n\tnetmessage_t msg;\n\n\tif (!debug_socket)\n\t\treturn;\n\tNMSG_Clear(&msg);\n\tNMSG_WriteByte(&msg, 2);\t\t//remove all debug polys\n\tNet_Send(debug_socket, &msg);\n}\n\n/*\n====================\nDebugNet_DrawWinding\n=====================\n*/\nvoid DebugNet_DrawWinding(winding_t *w, int color)\n{\n\tnetmessage_t msg;\n\tint i;\n\n\tif (!debug_socket)\n\t\treturn;\n\tNMSG_Clear(&msg);\n\tNMSG_WriteByte(&msg, 0);\t\t\t\t//draw a winding\n\tNMSG_WriteByte(&msg, w->numpoints);\t\t//number of points\n\tNMSG_WriteLong(&msg, color);\t\t\t//color\n\tfor (i = 0; i < w->numpoints; i++)\n\t{\n\t\tNMSG_WriteFloat(&msg, w->points[i][0]);\n\t\tNMSG_WriteFloat(&msg, w->points[i][1]);\n\t\tNMSG_WriteFloat(&msg, w->points[i][2]);\n\t}\n\tNet_Send(debug_socket, &msg);\n}\n\n/*\n=====================\nDebugNet_DrawLine\n=====================\n*/\nvoid DebugNet_DrawLine(vec3_t p1, vec3_t p2, int color)\n{\n\tnetmessage_t msg;\n\n\tif (!debug_socket)\n\t\treturn;\n\tNMSG_Clear(&msg);\n\tNMSG_WriteByte(&msg, 1);\t\t\t\t//draw a line\n\tNMSG_WriteLong(&msg, color);\t\t\t//color\n\tNMSG_WriteFloat(&msg, p1[0]);\n\tNMSG_WriteFloat(&msg, p1[1]);\n\tNMSG_WriteFloat(&msg, p1[2]);\n\tNMSG_WriteFloat(&msg, p2[0]);\n\tNMSG_WriteFloat(&msg, p2[1]);\n\tNMSG_WriteFloat(&msg, p2[2]);\n\tNet_Send(debug_socket, &msg);\n}\n\n/*\n=====================\nDebugNet_DrawMesh\n=====================\n*/\nvoid DebugNet_DrawMesh(mesh_t *mesh)\n{\n\tint i, j;\n\tfloat dot;\n\tdrawVert_t\t*v1, *v2, *v3, *v4;\n\twinding_t winding;\n\tplane_t plane;\n\tvec3_t d1, d2;\n\n\tfor ( i = 0 ; i < mesh->width - 1 ; i++ ) {\n\t\tfor ( j = 0 ; j < mesh->height - 1 ; j++ ) {\n\n\t\t\tv1 = mesh->verts + j * mesh->width + i;\n\t\t\tv2 = v1 + 1;\n\t\t\tv3 = v1 + mesh->width + 1;\n\t\t\tv4 = v1 + mesh->width;\n\n\t\t\tVectorSubtract( v4->xyz, v1->xyz, d1 );\n\t\t\tVectorSubtract( v3->xyz, v1->xyz, d2 );\n\t\t\tCrossProduct( d2, d1, plane.normal );\n\t\t\tif ( VectorNormalize( plane.normal, plane.normal ) != 0 )\n\t\t\t{\n\t\t\t\tplane.dist = DotProduct( v1->xyz, plane.normal );\n\t\t\t\tdot = DotProduct(plane.normal, v2->xyz) - plane.dist;\n\t\t\t\tif (fabs(dot) < 0.1)\n\t\t\t\t{\n\t\t\t\t\tVectorCopy(v1->xyz, winding.points[0]);\n\t\t\t\t\tVectorCopy(v4->xyz, winding.points[1]);\n\t\t\t\t\tVectorCopy(v3->xyz, winding.points[2]);\n\t\t\t\t\tVectorCopy(v2->xyz, winding.points[3]);\n\t\t\t\t\twinding.numpoints = 4;\n\t\t\t\t\tDebugNet_DrawWinding(&winding, 2);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\twinding.numpoints = 3;\n\t\t\tVectorCopy(v1->xyz, winding.points[0]);\n\t\t\tVectorCopy(v4->xyz, winding.points[1]);\n\t\t\tVectorCopy(v3->xyz, winding.points[2]);\n\t\t\tDebugNet_DrawWinding(&winding, 2);\n\n\t\t\tVectorCopy(v1->xyz, winding.points[0]);\n\t\t\tVectorCopy(v3->xyz, winding.points[1]);\n\t\t\tVectorCopy(v2->xyz, winding.points[2]);\n\t\t\tDebugNet_DrawWinding(&winding, 2);\n\t\t}\n\t}\n}\n\n/*\n=====================\nVS_DrawLightVolume\n=====================\n*/\nint VS_ChopWinding (winding_t *in, plane_t *split, float epsilon);\n\nvoid VS_DrawLightVolume(vsound_t *light, lightvolume_t *volume)\n{\n\twinding_t w;\n\tint i;\n\tvec3_t p2, invsound;\n\n\tmemcpy(w.points, volume->points, volume->numplanes * sizeof(vec3_t));\n\tw.numpoints = volume->numplanes;\n\tDebugNet_DrawWinding(&w, 2);\n\n\tif (volume->type == VOLUME_DIRECTED)\n\t{\n\t\tVectorCopy(light->normal, invsound);\n\t\tVectorInverse(invsound);\n\t\tfor (i = 0; i < volume->numplanes; i++)\n\t\t{\n\t\t\tVectorCopy(volume->points[i], w.points[0]);\n\t\t\tVectorCopy(volume->points[(i+1) % volume->numplanes], w.points[1]);\n\t\t\tVectorMA(w.points[1], MAX_WORLD_COORD, invsound, w.points[2]);\n\t\t\tVectorMA(w.points[0], MAX_WORLD_COORD, invsound, w.points[3]);\n\t\t\tw.numpoints = 4;\n\t\t\tDebugNet_DrawWinding(&w, 2);\n\t\t\tVectorMA(volume->points[i], 8, volume->planes[i].normal, p2);\n\t\t\tDebugNet_DrawLine(volume->points[i], p2, 3);\n\t\t}\n\t}\n\telse\n\t{\n\t\t//\n\t\tVectorCopy(light->origin, w.points[0]);\n\t\tw.numpoints = 3;\n\t\tfor (i = 0; i < volume->numplanes; i++)\n\t\t{\n\t\t\tVectorCopy(volume->points[i], w.points[1]);\n\t\t\tVectorCopy(volume->points[(i+1) % volume->numplanes], w.points[2]);\n\t\t\tVS_ChopWinding(&w, &volume->endplane, 0);\n\t\t\tDebugNet_DrawWinding(&w, 2);\n\t\t\tVectorMA(volume->points[i], 8, volume->planes[i].normal, p2);\n\t\t\tDebugNet_DrawLine(volume->points[i], p2, 3);\n\t\t}\n\t}\n}\n\n/*\n=============\nVS_DrawLightmapPixel\n=============\n*/\nvoid VS_DrawLightmapPixel(int surfaceNum, int x, int y, int color)\n{\n\twinding_t w;\n\tdsurface_t *ds;\n\tmesh_t *mesh;\n\n\tds = &drawSurfaces[surfaceNum];\n\n\tif (ds->surfaceType == MST_PATCH)\n\t{\n\t\tmesh = lsurfaceTest[surfaceNum]->detailMesh;\n\t\tVectorCopy( mesh->verts[(y-ds->lightmapY)*mesh->width+x-ds->lightmapX].xyz, w.points[0]);\n\t\tVectorCopy( mesh->verts[(y+1-ds->lightmapY)*mesh->width+x-ds->lightmapX].xyz, w.points[1]);\n\t\tVectorCopy( mesh->verts[(y+1-ds->lightmapY)*mesh->width+x+1-ds->lightmapX].xyz, w.points[2]);\n\t\tVectorCopy( mesh->verts[(y-ds->lightmapY)*mesh->width+x+1-ds->lightmapX].xyz, w.points[3]);\n\t\tw.numpoints = 4;\n\t}\n\telse\n\t{\n\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT - ds->lightmapX, ds->lightmapVecs[0], w.points[0]);\n\t\tVectorMA(w.points[0], (float) y - LIGHTMAP_PIXELSHIFT - ds->lightmapY, ds->lightmapVecs[1], w.points[0]);\n\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT - ds->lightmapX, ds->lightmapVecs[0], w.points[1]);\n\t\tVectorMA(w.points[1], (float) y - LIGHTMAP_PIXELSHIFT + 1 - ds->lightmapY, ds->lightmapVecs[1], w.points[1]);\n\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT + 1 - ds->lightmapX, ds->lightmapVecs[0], w.points[2]);\n\t\tVectorMA(w.points[2], (float) y - LIGHTMAP_PIXELSHIFT + 1 - ds->lightmapY, ds->lightmapVecs[1], w.points[2]);\n\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT + 1 - ds->lightmapX, ds->lightmapVecs[0], w.points[3]);\n\t\tVectorMA(w.points[3], (float) y - LIGHTMAP_PIXELSHIFT - ds->lightmapY, ds->lightmapVecs[1], w.points[3]);\n\t\tw.numpoints = 4;\n\t}\n\tDebugNet_DrawWinding(&w, color);\n}\n\n/*\n============\nVS_DrawPortals\n============\n*/\nvoid VS_DrawPortals(void)\n{\n\tint j;\n\tlportal_t *p;\n\n\tfor (j = 0; j < numportals * 2; j++)\n\t{\n\t\tp = portals + j;\n\t\tDebugNet_DrawWinding(p->winding, 1);\n\t}\n}\n\n/*\n============\nVS_DrawLeaf\n============\n*/\nvoid VS_DrawLeaf(int cluster)\n{\n\tint i;\n\tlleaf_t *leaf;\n\tlportal_t *p;\n\n\tleaf = &leafs[cluster];\n\tfor (i = 0; i < leaf->numportals; i++)\n\t{\n\t\tp = leaf->portals[i];\n\t\tDebugNet_DrawWinding(p->winding, 1);\n\t}\n}\n\n#endif //DEBUGNET\n\n/*\n=============\nVS_SplitWinding\n=============\n*/\nint VS_SplitWinding (winding_t *in, winding_t *back, plane_t *split, float epsilon)\n{\n\tvec_t\tdists[128];\n\tint\t\tsides[128];\n\tint\t\tcounts[3];\n\tvec_t\tdot;\n\tint\t\ti, j;\n\tvec_t\t*p1, *p2;\n\tvec3_t\tmid;\n\twinding_t out;\n\twinding_t\t*neww;\n\n\tcounts[0] = counts[1] = counts[2] = 0;\n\n\t// determine sides for each point\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tdot = DotProduct (in->points[i], split->normal);\n\t\tdot -= split->dist;\n\t\tdists[i] = dot;\n\t\tif (dot > epsilon)\n\t\t\tsides[i] = SIDE_FRONT;\n\t\telse if (dot < -epsilon)\n\t\t\tsides[i] = SIDE_BACK;\n\t\telse\n\t\t{\n\t\t\tsides[i] = SIDE_ON;\n\t\t}\n\t\tcounts[sides[i]]++;\n\t}\n\n\tif (!counts[SIDE_BACK])\n\t{\n\t\tif (!counts[SIDE_FRONT])\n\t\t\treturn SIDE_ON;\n\t\telse\n\t\t\treturn SIDE_FRONT;\n\t}\n\t\n\tif (!counts[SIDE_FRONT])\n\t{\n\t\treturn SIDE_BACK;\n\t}\n\n\tsides[i] = sides[0];\n\tdists[i] = dists[0];\n\t\n\tneww = &out;\n\n\tneww->numpoints = 0;\n\tback->numpoints = 0;\n\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tp1 = in->points[i];\n\n\t\tif (neww->numpoints >= MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\t_printf(\"WARNING: VS_SplitWinding -> MAX_POINTS_ON_FIXED_WINDING overflowed\\n\");\n\t\t\treturn SIDE_FRONT;\t\t// can't chop -- fall back to original\n\t\t}\n\t\tif (back->numpoints >= MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\t_printf(\"WARNING: VS_SplitWinding -> MAX_POINTS_ON_FIXED_WINDING overflowed\\n\");\n\t\t\treturn SIDE_FRONT;\n\t\t}\n\n\t\tif (sides[i] == SIDE_ON)\n\t\t{\n\t\t\tVectorCopy (p1, neww->points[neww->numpoints]);\n\t\t\tneww->numpoints++;\n\t\t\tVectorCopy (p1, back->points[back->numpoints]);\n\t\t\tback->numpoints++;\n\t\t\tcontinue;\n\t\t}\n\t\n\t\tif (sides[i] == SIDE_FRONT)\n\t\t{\n\t\t\tVectorCopy (p1, neww->points[neww->numpoints]);\n\t\t\tneww->numpoints++;\n\t\t}\n\t\tif (sides[i] == SIDE_BACK)\n\t\t{\n\t\t\tVectorCopy (p1, back->points[back->numpoints]);\n\t\t\tback->numpoints++;\n\t\t}\n\t\t\n\t\tif (sides[i+1] == SIDE_ON || sides[i+1] == sides[i])\n\t\t\tcontinue;\n\t\t\t\n\t\tif (neww->numpoints >= MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\t_printf(\"WARNING: VS_SplitWinding -> MAX_POINTS_ON_FIXED_WINDING overflowed\\n\");\n\t\t\treturn SIDE_FRONT;\t\t// can't chop -- fall back to original\n\t\t}\n\n\t\tif (back->numpoints >= MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\t_printf(\"WARNING: VS_SplitWinding -> MAX_POINTS_ON_FIXED_WINDING overflowed\\n\");\n\t\t\treturn SIDE_FRONT;\t\t// can't chop -- fall back to original\n\t\t}\n\n\t\t// generate a split point\n\t\tp2 = in->points[(i+1)%in->numpoints];\n\t\t\n\t\tdot = dists[i] / (dists[i]-dists[i+1]);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\t// avoid round off error when possible\n\t\t\tif (split->normal[j] == 1)\n\t\t\t\tmid[j] = split->dist;\n\t\t\telse if (split->normal[j] == -1)\n\t\t\t\tmid[j] = -split->dist;\n\t\t\telse\n\t\t\t\tmid[j] = p1[j] + dot*(p2[j]-p1[j]);\n\t\t}\n\t\t\t\n\t\tVectorCopy (mid, neww->points[neww->numpoints]);\n\t\tneww->numpoints++;\n\t\tVectorCopy (mid, back->points[back->numpoints]);\n\t\tback->numpoints++;\n\t}\n\tmemcpy(in, &out, sizeof(winding_t));\n\t\n\treturn SIDE_CROSS;\n}\n\n/*\n=====================\nVS_LinkSurfaceIntoCluster\n=====================\n*/\nvoid VS_LinkSurfaceIntoCluster(int cluster, int surfaceNum)\n{\n\tlleaf_t *leaf;\n\tint i;\n\n\tleaf = &leafs[cluster];\n\n\tfor (i = 0; i < leaf->numSurfaces; i++)\n\t{\n\t\tif (clustersurfaces[leaf->firstSurface + i] == surfaceNum)\n\t\t\treturn;\n\t}\n\tfor (i = numclustersurfaces; i > leaf->firstSurface + leaf->numSurfaces; i--)\n\t\tclustersurfaces[i] = clustersurfaces[i-1];\n\tfor (i = 0; i < portalclusters; i++)\n\t{\n\t\tif (i == cluster)\n\t\t\tcontinue;\n\t\tif (leafs[i].firstSurface >= leaf->firstSurface + leaf->numSurfaces)\n\t\t\tleafs[i].firstSurface++;\n\t}\n\tclustersurfaces[leaf->firstSurface + leaf->numSurfaces] = surfaceNum;\n\tleaf->numSurfaces++;\n\tnumclustersurfaces++;\n\tif (numclustersurfaces >= MAX_MAP_LEAFFACES)\n\t\tError(\"MAX_MAP_LEAFFACES\");\n}\n\n/*\n=====================\nVS_R_LinkSurface\n=====================\n*/\nvoid VS_R_LinkSurface(int nodenum, int surfaceNum, winding_t *w)\n{\n\tint leafnum, cluster, res;\n\tdnode_t *node;\n\tdplane_t *plane;\n\twinding_t back;\n\tplane_t split;\n\n\twhile(nodenum >= 0)\n\t{\n\t\tnode = &dnodes[nodenum];\n\t\tplane = &dplanes[node->planeNum];\n\n\t\tVectorCopy(plane->normal, split.normal);\n\t\tsplit.dist = plane->dist;\n\t\tres = VS_SplitWinding (w, &back, &split, 0.1);\n\n\t\tif (res == SIDE_FRONT)\n\t\t{\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t\telse if (res == SIDE_BACK)\n\t\t{\n\t\t\tnodenum = node->children[1];\n\t\t}\n\t\telse if (res == SIDE_ON)\n\t\t{\n\t\t\tmemcpy(&back, w, sizeof(winding_t));\n\t\t\tVS_R_LinkSurface(node->children[1], surfaceNum, &back);\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVS_R_LinkSurface(node->children[1], surfaceNum, &back);\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t}\n\tleafnum = -nodenum - 1;\n\tcluster = dleafs[leafnum].cluster;\n\tif (cluster != -1)\n\t{\n\t\tVS_LinkSurfaceIntoCluster(cluster, surfaceNum);\n\t}\n}\n\n/*\n=====================\nVS_LinkSurfaces\n\nmaybe link each facet seperately instead of the test surfaces?\n=====================\n*/\nvoid VS_LinkSurfaces(void)\n{\n\tint i, j;\n\tlsurfaceTest_t *test;\n\tlFacet_t *facet;\n\twinding_t winding;\n\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ )\n\t{\n\t\ttest = lsurfaceTest[ i ];\n\t\tif (!test)\n\t\t\tcontinue;\n\t\tfor (j = 0; j < test->numFacets; j++)\n\t\t{\n\t\t\tfacet = &test->facets[j];\n\t\t\tmemcpy(winding.points, facet->points, facet->numpoints * sizeof(vec3_t));\n\t\t\twinding.numpoints = facet->numpoints;\n\t\t\tVS_R_LinkSurface(0, i, &winding);\n\t\t}\n\t}\n}\n\n/*\n=====================\nVS_TextureMatrixFromPoints\n=====================\n*/\nvoid VS_TextureMatrixFromPoints( lFacet_t *f, drawVert_t *a, drawVert_t *b, drawVert_t *c ) {\n\tint\t\t\ti, j;\n\tfloat\t\tt;\n\tfloat\t\tm[3][4];\n\tfloat\t\ts;\n\n\t// This is an incredibly stupid way of solving a three variable equation\n\tfor ( i = 0 ; i < 2 ; i++ ) {\n\n\t\tm[0][0] = a->xyz[0];\n\t\tm[0][1] = a->xyz[1];\n\t\tm[0][2] = a->xyz[2];\n\t\tm[0][3] = a->st[i];\n\n\t\tm[1][0] = b->xyz[0];\n\t\tm[1][1] = b->xyz[1];\n\t\tm[1][2] = b->xyz[2];\n\t\tm[1][3] = b->st[i];\n\n\t\tm[2][0] = c->xyz[0];\n\t\tm[2][1] = c->xyz[1];\n\t\tm[2][2] = c->xyz[2];\n\t\tm[2][3] = c->st[i];\n\n\t\tif ( fabs(m[1][0]) > fabs(m[0][0]) && fabs(m[1][0]) > fabs(m[2][0]) ) {\n\t\t\tfor ( j = 0 ; j < 4 ; j ++ ) {\n\t\t\t\tt = m[0][j];\n\t\t\t\tm[0][j] = m[1][j];\n\t\t\t\tm[1][j] = t;\n\t\t\t}\n\t\t} else if ( fabs(m[2][0]) > fabs(m[0][0]) && fabs(m[2][0]) > fabs(m[1][0]) ) {\n\t\t\tfor ( j = 0 ; j < 4 ; j ++ ) {\n\t\t\t\tt = m[0][j];\n\t\t\t\tm[0][j] = m[2][j];\n\t\t\t\tm[2][j] = t;\n\t\t\t}\n\t\t}\n\n\t\ts = 1.0 / m[0][0];\n\t\tm[0][0] *= s;\n\t\tm[0][1] *= s;\n\t\tm[0][2] *= s;\n\t\tm[0][3] *= s;\n\n\t\ts = m[1][0];\n\t\tm[1][0] -= m[0][0] * s;\n\t\tm[1][1] -= m[0][1] * s;\n\t\tm[1][2] -= m[0][2] * s;\n\t\tm[1][3] -= m[0][3] * s;\n\n\t\ts = m[2][0];\n\t\tm[2][0] -= m[0][0] * s;\n\t\tm[2][1] -= m[0][1] * s;\n\t\tm[2][2] -= m[0][2] * s;\n\t\tm[2][3] -= m[0][3] * s;\n\n\t\tif ( fabs(m[2][1]) > fabs(m[1][1]) ) {\n\t\t\tfor ( j = 0 ; j < 4 ; j ++ ) {\n\t\t\t\tt = m[1][j];\n\t\t\t\tm[1][j] = m[2][j];\n\t\t\t\tm[2][j] = t;\n\t\t\t}\n\t\t}\n\n\t\ts = 1.0 / m[1][1];\n\t\tm[1][0] *= s;\n\t\tm[1][1] *= s;\n\t\tm[1][2] *= s;\n\t\tm[1][3] *= s;\n\n\t\ts = m[2][1];// / m[1][1];\n\t\tm[2][0] -= m[1][0] * s;\n\t\tm[2][1] -= m[1][1] * s;\n\t\tm[2][2] -= m[1][2] * s;\n\t\tm[2][3] -= m[1][3] * s;\n\n\t\ts = 1.0 / m[2][2];\n\t\tm[2][0] *= s;\n\t\tm[2][1] *= s;\n\t\tm[2][2] *= s;\n\t\tm[2][3] *= s;\n\n\t\tf->textureMatrix[i][2] = m[2][3];\n\t\tf->textureMatrix[i][1] = m[1][3] - f->textureMatrix[i][2] * m[1][2];\n\t\tf->textureMatrix[i][0] = m[0][3] - f->textureMatrix[i][2] * m[0][2] - f->textureMatrix[i][1] * m[0][1];\n\n\t\tf->textureMatrix[i][3] = 0;\n/*\n\t\ts = fabs( DotProduct( a->xyz, f->textureMatrix[i] ) - a->st[i] );\n\t\tif ( s > 0.01 ) {\n\t\t\tError( \"Bad textureMatrix\" );\n\t\t}\n\t\ts = fabs( DotProduct( b->xyz, f->textureMatrix[i] ) - b->st[i] );\n\t\tif ( s > 0.01 ) {\n\t\t\tError( \"Bad textureMatrix\" );\n\t\t}\n\t\ts = fabs( DotProduct( c->xyz, f->textureMatrix[i] ) - c->st[i] );\n\t\tif ( s > 0.01 ) {\n\t\t\tError( \"Bad textureMatrix\" );\n\t\t}\n*/\n\t}\n}\n\n/*\n=====================\nVS_LightmapMatrixFromPoints\n=====================\n*/\nvoid VS_LightmapMatrixFromPoints( dsurface_t *dsurf, shaderInfo_t *si, lFacet_t *f, drawVert_t *a, drawVert_t *b, drawVert_t *c ) {\n\tint\t\t\ti, j;\n\tfloat\t\tt;\n\tfloat\t\tm[3][4], al, bl, cl;\n\tfloat\t\ts;\n\tint\t\t\th, w, ssize;\n\tvec3_t\t\tmins, maxs, delta, size, planeNormal;\n\tdrawVert_t\t*verts;\n\tstatic int\tmessage;\n\n\t// vertex-lit triangle model\n\tif ( dsurf->surfaceType == MST_TRIANGLE_SOUP ) {\n\t\treturn;\n\t}\n\t\n\tif ( dsurf->lightmapNum < 0 ) {\n\t\treturn;\t\t// doesn't need lighting\n\t}\n\n\tVectorClear(f->mins);\n\tif (dsurf->surfaceType != MST_PATCH)\n\t{\n\t\tssize = samplesize;\n\t\tif (si->lightmapSampleSize)\n\t\t\tssize = si->lightmapSampleSize;\n\t\tClearBounds( mins, maxs );\n\t\tverts = &drawVerts[dsurf->firstVert];\n\t\tfor ( i = 0 ; i < dsurf->numVerts ; i++ ) {\n\t\t\tAddPointToBounds( verts[i].xyz, mins, maxs );\n\t\t}\n\t\t// round to the lightmap resolution\n\t\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\t\tmins[i] = ssize * floor( mins[i] / ssize );\n\t\t\tmaxs[i] = ssize * ceil( maxs[i] / ssize );\n\t\t\tf->mins[i] = mins[i];\n\t\t\tsize[i] = (maxs[i] - mins[i]) / ssize + 1;\n\t\t}\n\t\t// the two largest axis will be the lightmap size\n\t\tVectorClear(f->lightmapMatrix[0]);\n\t\tf->lightmapMatrix[0][3] = 0;\n\t\tVectorClear(f->lightmapMatrix[1]);\n\t\tf->lightmapMatrix[1][3] = 0;\n\n\t\tplaneNormal[0] = fabs( dsurf->lightmapVecs[2][0] );\n\t\tplaneNormal[1] = fabs( dsurf->lightmapVecs[2][1] );\n\t\tplaneNormal[2] = fabs( dsurf->lightmapVecs[2][2] );\n\n\t\tif ( planeNormal[0] >= planeNormal[1] && planeNormal[0] >= planeNormal[2] ) {\n\t\t\tw = size[1];\n\t\t\th = size[2];\n\t\t\tf->lightmapMatrix[0][1] = 1.0 / ssize;\n\t\t\tf->lightmapMatrix[1][2] = 1.0 / ssize;\n\t\t} else if ( planeNormal[1] >= planeNormal[0] && planeNormal[1] >= planeNormal[2] ) {\n\t\t\tw = size[0];\n\t\t\th = size[2];\n\t\t\tf->lightmapMatrix[0][0] = 1.0 / ssize;\n\t\t\tf->lightmapMatrix[1][2] = 1.0 / ssize;\n\t\t} else {\n\t\t\tw = size[0];\n\t\t\th = size[1];\n\t\t\tf->lightmapMatrix[0][0] = 1.0 / ssize;\n\t\t\tf->lightmapMatrix[1][1] = 1.0 / ssize;\n\t\t}\n\t\tif ( w > LIGHTMAP_WIDTH ) {\n\t\t\tVectorScale ( f->lightmapMatrix[0], (float)LIGHTMAP_SIZE/w, f->lightmapMatrix[0] );\n\t\t}\n\t\t\n\t\tif ( h > LIGHTMAP_HEIGHT ) {\n\t\t\tVectorScale ( f->lightmapMatrix[1], (float)LIGHTMAP_SIZE/h, f->lightmapMatrix[1] );\n\t\t}\n\t\tVectorSubtract(a->xyz, f->mins, delta);\n\t\ts = (DotProduct( delta, f->lightmapMatrix[0] ) + dsurf->lightmapX + 0.5) / LIGHTMAP_SIZE;\n\t\tif ( fabs(s - a->lightmap[0]) > 0.01 ) {\n\t\t\t_printf( \"Bad lightmapMatrix\" );\n\t\t}\n\t\tt = (DotProduct( delta, f->lightmapMatrix[1] ) + dsurf->lightmapY + 0.5) / LIGHTMAP_SIZE;\n\t\tif ( fabs(t - a->lightmap[1]) > 0.01 ) {\n\t\t\t_printf( \"Bad lightmapMatrix\" );\n\t\t}\n\t\tVectorSubtract(b->xyz, f->mins, delta);\n\t\ts = (DotProduct( delta, f->lightmapMatrix[0] ) + dsurf->lightmapX + 0.5) / LIGHTMAP_SIZE;\n\t\tif ( fabs(s - b->lightmap[0]) > 0.01 ) {\n\t\t\t_printf( \"Bad lightmapMatrix\" );\n\t\t}\n\t\tt = (DotProduct( delta, f->lightmapMatrix[1] ) + dsurf->lightmapY + 0.5) / LIGHTMAP_SIZE;\n\t\tif ( fabs(t - b->lightmap[1]) > 0.01 ) {\n\t\t\t_printf( \"Bad lightmapMatrix\" );\n\t\t}\n\t\tVectorSubtract(c->xyz, f->mins, delta);\n\t\ts = (DotProduct( delta, f->lightmapMatrix[0] ) + dsurf->lightmapX + 0.5) / LIGHTMAP_SIZE;\n\t\tif ( fabs(s - c->lightmap[0]) > 0.01 ) {\n\t\t\t_printf( \"Bad lightmapMatrix\" );\n\t\t}\n\t\tt = (DotProduct( delta, f->lightmapMatrix[1] ) + dsurf->lightmapY + 0.5) / LIGHTMAP_SIZE;\n\t\tif ( fabs(t - c->lightmap[1]) > 0.01 ) {\n\t\t\t_printf( \"Bad lightmapMatrix\" );\n\t\t}\n\t\tVectorAdd(f->mins, surfaceOrigin[dsurf - drawSurfaces], f->mins);\n\t\treturn;\n\t}\n\t// This is an incredibly stupid way of solving a three variable equation\n\tfor ( i = 0 ; i < 2 ; i++ ) {\n\n\t\tif (i)\n\t\t\tal = a->lightmap[i] - ((float) dsurf->lightmapY + 0.5) / LIGHTMAP_SIZE;\n\t\telse\n\t\t\tal = a->lightmap[i] - ((float) dsurf->lightmapX + 0.5) / LIGHTMAP_SIZE;\n\n\t\tm[0][0] = a->xyz[0] - f->mins[0];\n\t\tm[0][1] = a->xyz[1] - f->mins[1];\n\t\tm[0][2] = a->xyz[2] - f->mins[2];\n\t\tm[0][3] = al;\n\n\t\tif (i)\n\t\t\tbl = b->lightmap[i] - ((float) dsurf->lightmapY + 0.5) / LIGHTMAP_SIZE;\n\t\telse\n\t\t\tbl = b->lightmap[i] - ((float) dsurf->lightmapX + 0.5) / LIGHTMAP_SIZE;\n\n\t\tm[1][0] = b->xyz[0] - f->mins[0];\n\t\tm[1][1] = b->xyz[1] - f->mins[1];\n\t\tm[1][2] = b->xyz[2] - f->mins[2];\n\t\tm[1][3] = bl;\n\n\t\tif (i)\n\t\t\tcl = c->lightmap[i] - ((float) dsurf->lightmapY + 0.5) / LIGHTMAP_SIZE;\n\t\telse\n\t\t\tcl = c->lightmap[i] - ((float) dsurf->lightmapX + 0.5) / LIGHTMAP_SIZE;\n\n\t\tm[2][0] = c->xyz[0] - f->mins[0];\n\t\tm[2][1] = c->xyz[1] - f->mins[1];\n\t\tm[2][2] = c->xyz[2] - f->mins[2];\n\t\tm[2][3] = cl;\n\n\t\tif ( fabs(m[1][0]) > fabs(m[0][0]) && fabs(m[1][0]) >= fabs(m[2][0]) ) {\n\t\t\tfor ( j = 0 ; j < 4 ; j ++ ) {\n\t\t\t\tt = m[0][j];\n\t\t\t\tm[0][j] = m[1][j];\n\t\t\t\tm[1][j] = t;\n\t\t\t}\n\t\t} else if ( fabs(m[2][0]) > fabs(m[0][0]) && fabs(m[2][0]) >= fabs(m[1][0]) ) {\n\t\t\tfor ( j = 0 ; j < 4 ; j ++ ) {\n\t\t\t\tt = m[0][j];\n\t\t\t\tm[0][j] = m[2][j];\n\t\t\t\tm[2][j] = t;\n\t\t\t}\n\t\t}\n\n\t\tif (m[0][0])\n\t\t{\n\t\t\ts = 1.0 / m[0][0];\n\t\t\tm[0][0] *= s;\n\t\t\tm[0][1] *= s;\n\t\t\tm[0][2] *= s;\n\t\t\tm[0][3] *= s;\n\n\t\t\ts = m[1][0];\n\t\t\tm[1][0] -= m[0][0] * s;\n\t\t\tm[1][1] -= m[0][1] * s;\n\t\t\tm[1][2] -= m[0][2] * s;\n\t\t\tm[1][3] -= m[0][3] * s;\n\n\t\t\ts = m[2][0];\n\t\t\tm[2][0] -= m[0][0] * s;\n\t\t\tm[2][1] -= m[0][1] * s;\n\t\t\tm[2][2] -= m[0][2] * s;\n\t\t\tm[2][3] -= m[0][3] * s;\n\t\t}\n\n\t\tif ( fabs(m[2][1]) > fabs(m[1][1]) ) {\n\t\t\tfor ( j = 0 ; j < 4 ; j ++ ) {\n\t\t\t\tt = m[1][j];\n\t\t\t\tm[1][j] = m[2][j];\n\t\t\t\tm[2][j] = t;\n\t\t\t}\n\t\t}\n\n\t\tif (m[1][1])\n\t\t{\n\t\t\ts = 1.0 / m[1][1];\n\t\t\tm[1][0] *= s;\n\t\t\tm[1][1] *= s;\n\t\t\tm[1][2] *= s;\n\t\t\tm[1][3] *= s;\n\n\t\t\ts = m[2][1];\n\t\t\tm[2][0] -= m[1][0] * s;\n\t\t\tm[2][1] -= m[1][1] * s;\n\t\t\tm[2][2] -= m[1][2] * s;\n\t\t\tm[2][3] -= m[1][3] * s;\n\t\t}\n\n\t\tif (m[2][2])\n\t\t{\n\t\t\ts = 1.0 / m[2][2];\n\t\t\tm[2][0] *= s;\n\t\t\tm[2][1] *= s;\n\t\t\tm[2][2] *= s;\n\t\t\tm[2][3] *= s;\n\t\t}\n\n\t\tf->lightmapMatrix[i][2] = m[2][3];\n\t\tf->lightmapMatrix[i][1] = m[1][3] - f->lightmapMatrix[i][2] * m[1][2];\n\t\tf->lightmapMatrix[i][0] = m[0][3] - f->lightmapMatrix[i][2] * m[0][2] - f->lightmapMatrix[i][1] * m[0][1];\n\n\t\tf->lightmapMatrix[i][3] = 0;\n\n\t\tVectorSubtract(a->xyz, f->mins, delta);\n\t\ts = fabs( DotProduct( delta, f->lightmapMatrix[i] ) - al );\n\t\tif ( s > 0.01 ) {\n\t\t\tif (!message)\n\t\t\t\t_printf( \"Bad lightmapMatrix\\n\" );\n\t\t\tmessage = qtrue;\n\t\t}\n\t\tVectorSubtract(b->xyz, f->mins, delta);\n\t\ts = fabs( DotProduct( delta, f->lightmapMatrix[i] ) - bl );\n\t\tif ( s > 0.01 ) {\n\t\t\tif (!message)\n\t\t\t\t_printf( \"Bad lightmapMatrix\\n\" );\n\t\t\tmessage = qtrue;\n\t\t}\n\t\tVectorSubtract(c->xyz, f->mins, delta);\n\t\ts = fabs( DotProduct( delta, f->lightmapMatrix[i] ) - cl );\n\t\tif ( s > 0.01 ) {\n\t\t\tif (!message)\n\t\t\t\t_printf( \"Bad lightmapMatrix\\n\" );\n\t\t\tmessage = qtrue;\n\t\t}\n\t\tVectorAdd(f->mins, surfaceOrigin[dsurf - drawSurfaces], f->mins);\n\t}\n}\n\n/*\n=============\nPlane_Equal\n=============\n*/\n#define\tNORMAL_EPSILON\t0.0001\n#define\tDIST_EPSILON\t0.02\n\nstatic int Plane_Equal(plane_t *a, plane_t *b, int flip)\n{\n\tvec3_t normal;\n\tfloat dist;\n\n\tif (flip) {\n\t\tnormal[0] = - b->normal[0];\n\t\tnormal[1] = - b->normal[1];\n\t\tnormal[2] = - b->normal[2];\n\t\tdist = - b->dist;\n\t}\n\telse {\n\t\tnormal[0] = b->normal[0];\n\t\tnormal[1] = b->normal[1];\n\t\tnormal[2] = b->normal[2];\n\t\tdist = b->dist;\n\t}\n\tif (\n\t   fabs(a->normal[0] - normal[0]) < NORMAL_EPSILON\n\t&& fabs(a->normal[1] - normal[1]) < NORMAL_EPSILON\n\t&& fabs(a->normal[2] - normal[2]) < NORMAL_EPSILON\n\t&& fabs(a->dist - dist) < DIST_EPSILON )\n\t\treturn qtrue;\n\treturn qfalse;\n}\n\n/*\n=============\nVS_PlaneFromPoints\n=============\n*/\nqboolean VS_PlaneFromPoints( plane_t *plane, const vec3_t a, const vec3_t b, const vec3_t c ) {\n\tvec3_t\td1, d2;\n\n\tVectorSubtract( b, a, d1 );\n\tVectorSubtract( c, a, d2 );\n\tCrossProduct( d2, d1, plane->normal );\n\tif ( VectorNormalize( plane->normal, plane->normal ) == 0 ) {\n\t\treturn qfalse;\n\t}\n\n\tplane->dist = DotProduct( a, plane->normal );\n\treturn qtrue;\n}\n\n/*\n=====================\nVS_GenerateBoundaryForPoints\n=====================\n*/\nvoid VS_GenerateBoundaryForPoints( plane_t *boundary, plane_t *plane, vec3_t a, vec3_t b ) {\n\tvec3_t\td1;\n\n\t// make a perpendicular vector to the edge and the surface\n\tVectorSubtract( a, b, d1 );\n\tCrossProduct( plane->normal, d1, boundary->normal );\n\tVectorNormalize( boundary->normal, boundary->normal );\n\tboundary->dist = DotProduct( a, boundary->normal );\n}\n\n/*\n=====================\nVS_GenerateFacetFor3Points\n=====================\n*/\nqboolean VS_GenerateFacetFor3Points( dsurface_t *dsurf, shaderInfo_t *si, lFacet_t *f, drawVert_t *a, drawVert_t *b, drawVert_t *c ) {\n\t//\n\tvec3_t dir;\n\tint i;\n\n\t// if we can't generate a valid plane for the points, ignore the facet\n\tif ( !VS_PlaneFromPoints( &f->plane, a->xyz, b->xyz, c->xyz ) ) {\n\t\tf->numpoints = 0;\n\t\treturn qfalse;\n\t}\n\n\tf->num = numfacets++;\n\n\tVectorAdd( a->xyz, surfaceOrigin[dsurf - drawSurfaces], f->points[0] );\n\tVectorAdd( b->xyz, surfaceOrigin[dsurf - drawSurfaces], f->points[1] );\n\tVectorAdd( c->xyz, surfaceOrigin[dsurf - drawSurfaces], f->points[2] );\n\n\tf->lightmapCoords[0][0] = a->lightmap[0];\n\tf->lightmapCoords[0][1] = a->lightmap[1];\n\tf->lightmapCoords[1][0] = b->lightmap[0];\n\tf->lightmapCoords[1][1] = b->lightmap[1];\n\tf->lightmapCoords[2][0] = c->lightmap[0];\n\tf->lightmapCoords[2][1] = c->lightmap[1];\n\n\tVS_GenerateBoundaryForPoints( &f->boundaries[0], &f->plane, f->points[0], f->points[1] );\n\tVS_GenerateBoundaryForPoints( &f->boundaries[1], &f->plane, f->points[1], f->points[2] );\n\tVS_GenerateBoundaryForPoints( &f->boundaries[2], &f->plane, f->points[2], f->points[0] );\n\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tVectorSubtract(f->points[(i+1)%3], f->points[i], dir);\n\t\tif (VectorLength(dir) < 0.1)\n\t\t\treturn qfalse;\n\t}\n\n\tVS_TextureMatrixFromPoints( f, a, b, c );\n\tVS_LightmapMatrixFromPoints( dsurf, si, f, a, b, c );\n\n\tf->numpoints = 3;\n\n\treturn qtrue;\n}\n\n/*\n=====================\nVS_GenerateFacetFor4Points\n\nAttempts to use four points as a planar quad\n=====================\n*/\n#define\tPLANAR_EPSILON\t0.1\nqboolean VS_GenerateFacetFor4Points( dsurface_t *dsurf, shaderInfo_t *si, lFacet_t *f, drawVert_t *a, drawVert_t *b, drawVert_t *c, drawVert_t *d ) {\n\tfloat\tdist;\n\tvec3_t dir;\n\tint i;\n\tplane_t plane;\n\n\t// if we can't generate a valid plane for the points, ignore the facet\n\tif ( !VS_PlaneFromPoints( &f->plane, a->xyz, b->xyz, c->xyz ) ) {\n\t\tf->numpoints = 0;\n\t\treturn qfalse;\n\t}\n\n\t// if the fourth point is also on the plane, we can make a quad facet\n\tdist = DotProduct( d->xyz, f->plane.normal ) - f->plane.dist;\n\tif ( fabs( dist ) > PLANAR_EPSILON ) {\n\t\tf->numpoints = 0;\n\t\treturn qfalse;\n\t}\n\n\tVectorAdd( a->xyz, surfaceOrigin[dsurf - drawSurfaces], f->points[0] );\n\tVectorAdd( b->xyz, surfaceOrigin[dsurf - drawSurfaces], f->points[1] );\n\tVectorAdd( c->xyz, surfaceOrigin[dsurf - drawSurfaces], f->points[2] );\n\tVectorAdd( d->xyz, surfaceOrigin[dsurf - drawSurfaces], f->points[3] );\n\n\tfor (i = 1; i < 4; i++)\n\t{\n\t\tif ( !VS_PlaneFromPoints( &plane, f->points[i], f->points[(i+1) % 4], f->points[(i+2) % 4]) ) {\n\t\t\tf->numpoints = 0;\n\t\t\treturn qfalse;\n\t\t}\n\n\t\tif (!Plane_Equal(&f->plane, &plane, qfalse)) {\n\t\t\tf->numpoints = 0;\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\tf->lightmapCoords[0][0] = a->lightmap[0];\n\tf->lightmapCoords[0][1] = a->lightmap[1];\n\tf->lightmapCoords[1][0] = b->lightmap[0];\n\tf->lightmapCoords[1][1] = b->lightmap[1];\n\tf->lightmapCoords[2][0] = c->lightmap[0];\n\tf->lightmapCoords[2][1] = c->lightmap[1];\n\tf->lightmapCoords[3][0] = d->lightmap[0];\n\tf->lightmapCoords[3][1] = d->lightmap[1];\n\n\tVS_GenerateBoundaryForPoints( &f->boundaries[0], &f->plane, f->points[0], f->points[1] );\n\tVS_GenerateBoundaryForPoints( &f->boundaries[1], &f->plane, f->points[1], f->points[2] );\n\tVS_GenerateBoundaryForPoints( &f->boundaries[2], &f->plane, f->points[2], f->points[3] );\n\tVS_GenerateBoundaryForPoints( &f->boundaries[3], &f->plane, f->points[3], f->points[0] );\n\n\tfor (i = 0; i < 4; i++)\n\t{\n\t\tVectorSubtract(f->points[(i+1)%4], f->points[i], dir);\n\t\tif (VectorLength(dir) < 0.1)\n\t\t\treturn qfalse;\n\t}\n\n\tVS_TextureMatrixFromPoints( f, a, b, c );\n\tVS_LightmapMatrixFromPoints( dsurf, si, f, a, b, c );\n\n\tf->num = numfacets++;\n\tf->numpoints = 4;\n\n\treturn qtrue;\n}\n\n/*\n===============\nVS_SphereFromBounds\n===============\n*/\nvoid VS_SphereFromBounds( vec3_t mins, vec3_t maxs, vec3_t origin, float *radius ) {\n\tvec3_t\t\ttemp;\n\n\tVectorAdd( mins, maxs, origin );\n\tVectorScale( origin, 0.5, origin );\n\tVectorSubtract( maxs, origin, temp );\n\t*radius = VectorLength( temp );\n}\n\n/*\n====================\nVS_FacetsForTriangleSurface\n====================\n*/\nvoid VS_FacetsForTriangleSurface( dsurface_t *dsurf, shaderInfo_t *si, lsurfaceTest_t *test ) {\n\tint\t\t\ti;\n\tdrawVert_t\t*v1, *v2, *v3, *v4;\n\tint\t\t\tcount;\n\tint\t\t\ti1, i2, i3, i4, i5, i6;\n\n\ttest->patch = qfalse;\n\tif (dsurf->surfaceType == MST_TRIANGLE_SOUP)\n\t\ttest->trisoup = qtrue;\n\telse\n\t\ttest->trisoup = qfalse;\n\ttest->numFacets = dsurf->numIndexes / 3;\n\ttest->facets = malloc( sizeof( test->facets[0] ) * test->numFacets );\n\ttest->shader = si;\n\n\tcount = 0;\n\tfor ( i = 0 ; i < test->numFacets ; i++ ) {\n\t\ti1 = drawIndexes[ dsurf->firstIndex + i*3 ];\n\t\ti2 = drawIndexes[ dsurf->firstIndex + i*3 + 1 ];\n\t\ti3 = drawIndexes[ dsurf->firstIndex + i*3 + 2 ];\n\n\t\tv1 = &drawVerts[ dsurf->firstVert + i1 ];\n\t\tv2 = &drawVerts[ dsurf->firstVert + i2 ];\n\t\tv3 = &drawVerts[ dsurf->firstVert + i3 ];\n\n\t\t// try and make a quad out of two triangles\n\t\tif ( i != test->numFacets - 1 ) {\n\t\t\ti4 = drawIndexes[ dsurf->firstIndex + i*3 + 3 ];\n\t\t\ti5 = drawIndexes[ dsurf->firstIndex + i*3 + 4 ];\n\t\t\ti6 = drawIndexes[ dsurf->firstIndex + i*3 + 5 ];\n\t\t\tif ( i4 == i3 && i5 == i2 ) {\n\t\t\t\tv4 = &drawVerts[ dsurf->firstVert + i6 ];\n\t\t\t\tif ( VS_GenerateFacetFor4Points( dsurf, si, &test->facets[count], v1, v2, v4, v3 ) ) {\n\t\t\t\t\tcount++;\n\t\t\t\t\ti++;\t\t// skip next tri\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (VS_GenerateFacetFor3Points( dsurf, si, &test->facets[count], v1, v2, v3 )) {\n\t\t\tcount++;\n\t\t}\n\t}\t\t\n\n\t// we may have turned some pairs into quads\n\ttest->numFacets = count;\n}\n\n/*\n====================\nVS_FacetsForPatch\n====================\n*/\nvoid VS_FacetsForPatch( dsurface_t *dsurf, int surfaceNum, shaderInfo_t *si, lsurfaceTest_t *test ) {\n\tint\t\t\ti, j, x, y;\n\tdrawVert_t\t*v1, *v2, *v3, *v4;\n\tint\t\t\tcount, ssize;\n\tmesh_t\t\tmesh;\n\tmesh_t\t\t*subdivided, *detailmesh, *newmesh;\n\tint widthtable[LIGHTMAP_SIZE], heighttable[LIGHTMAP_SIZE];\n\n\tmesh.width = dsurf->patchWidth;\n\tmesh.height = dsurf->patchHeight;\n\tmesh.verts = &drawVerts[ dsurf->firstVert ];\n\n\tnewmesh = SubdivideMesh( mesh, 8, 999 );\n\tPutMeshOnCurve( *newmesh );\n\tMakeMeshNormals( *newmesh );\n\n\tsubdivided = RemoveLinearMeshColumnsRows( newmesh );\n\tFreeMesh(newmesh);\n\n\t//\tDebugNet_RemoveAllPolys();\n\t//\tDebugNet_DrawMesh(subdivided);\n\n\tssize = samplesize;\n\tif (si->lightmapSampleSize)\n\t\tssize = si->lightmapSampleSize;\n\n\tif ( dsurf->lightmapNum >= 0 ) {\n\n\t\tdetailmesh = SubdivideMeshQuads( subdivided, ssize, LIGHTMAP_SIZE, widthtable, heighttable);\n\t\ttest->detailMesh = detailmesh;\n\n\t\t// DebugNet_RemoveAllPolys();\n\t\t// DebugNet_DrawMesh(detailmesh);\n\n\t\tif ( detailmesh->width != dsurf->lightmapWidth || detailmesh->height != dsurf->lightmapHeight ) {\n\t\t\tError( \"Mesh lightmap miscount\");\n\t\t}\n\t}\n\telse {\n\t\ttest->detailMesh = NULL;\n\t\tmemset(widthtable, 0, sizeof(widthtable));\n\t\tmemset(heighttable, 0, sizeof(heighttable));\n\t}\n\n\ttest->patch = qtrue;\n\ttest->trisoup = qfalse;\n\ttest->numFacets = ( subdivided->width - 1 ) * ( subdivided->height - 1 ) * 2;\n\ttest->facets = malloc( sizeof( test->facets[0] ) * test->numFacets );\n\ttest->shader = si;\n\n\tcount = 0;\n\tx = 0;\n\tfor ( i = 0 ; i < subdivided->width - 1 ; i++ ) {\n\t\ty = 0;\n\t\tfor ( j = 0 ; j < subdivided->height - 1 ; j++ ) {\n\n\t\t\tv1 = subdivided->verts + j * subdivided->width + i;\n\t\t\tv2 = v1 + 1;\n\t\t\tv3 = v1 + subdivided->width + 1;\n\t\t\tv4 = v1 + subdivided->width;\n\n\t\t\tif ( VS_GenerateFacetFor4Points( dsurf, si, &test->facets[count], v1, v4, v3, v2 ) ) {\n\t\t\t\ttest->facets[count].x = x;\n\t\t\t\ttest->facets[count].y = y;\n\t\t\t\ttest->facets[count].width = widthtable[i];\n\t\t\t\ttest->facets[count].height = heighttable[j];\n\t\t\t\tcount++;\n\t\t\t} else {\n\t\t\t\tif (VS_GenerateFacetFor3Points( dsurf, si, &test->facets[count], v1, v4, v3 )) {\n\t\t\t\t\ttest->facets[count].x = x;\n\t\t\t\t\ttest->facets[count].y = y;\n\t\t\t\t\ttest->facets[count].width = widthtable[i];\n\t\t\t\t\ttest->facets[count].height = heighttable[j];\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t\tif (VS_GenerateFacetFor3Points( dsurf, si, &test->facets[count], v1, v3, v2 )) {\n\t\t\t\t\ttest->facets[count].x = x;\n\t\t\t\t\ttest->facets[count].y = y;\n\t\t\t\t\ttest->facets[count].width = widthtable[i];\n\t\t\t\t\ttest->facets[count].height = heighttable[j];\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\ty += heighttable[j];\n\t\t}\n\t\tx += widthtable[i];\n\t}\n\ttest->numFacets = count;\n\n\tFreeMesh(subdivided);\n}\n\n/*\n=====================\nVS_InitSurfacesForTesting\n=====================\n*/\nvoid VS_InitSurfacesForTesting( void ) {\n\n\tint\t\t\t\ti, j, k;\n\tdsurface_t\t\t*dsurf;\n\tlsurfaceTest_t\t*test;\n\tshaderInfo_t\t*si;\n\tlFacet_t\t\t*facet;\n\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ ) {\n\t\t// don't light the entity surfaces with vsound\n\t\tif ( entitySurface[i] )\n\t\t\tcontinue;\n\t\t//\n\t\tdsurf = &drawSurfaces[ i ];\n\t\tif ( !dsurf->numIndexes && !dsurf->patchWidth ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tsi = ShaderInfoForShader( dshaders[ dsurf->shaderNum].shader );\n\t\t// if the surface is translucent and does not cast an alpha shadow\n\t\tif ( (si->contents & CONTENTS_TRANSLUCENT) && !(si->surfaceFlags & SURF_ALPHASHADOW) ) {\n\t\t\t// if the surface has no lightmap\n\t\t\tif ( dsurf->lightmapNum < 0 )\n\t\t\t\tcontinue;\n\t\t}\n\n\t\ttest = malloc( sizeof( *test ) );\n\t\tmemset(test, 0, sizeof( *test ));\n\t\ttest->mutex = MutexAlloc();\n\t\ttest->numvolumes = 0;\n\t\tif (si->forceTraceLight)\n\t\t\ttest->always_tracelight = qtrue;\n\t\telse if (si->forceVLight)\n\t\t\ttest->always_vsound = qtrue;\n\t\tlsurfaceTest[i] = test;\n\n\t\tif ( dsurf->surfaceType == MST_TRIANGLE_SOUP || dsurf->surfaceType == MST_PLANAR ) {\n\t\t\tVS_FacetsForTriangleSurface( dsurf, si, test );\n\t\t} else if ( dsurf->surfaceType == MST_PATCH ) {\n\t\t\tVS_FacetsForPatch( dsurf, i, si, test );\n\t\t}\n\t\tif (numfacets >= MAX_FACETS)\n\t\t\tError(\"numfacets >= MAX_FACETS (%d)\", MAX_FACETS);\n\n\t\tClearBounds( test->mins, test->maxs );\n\t\tfor (j = 0; j < test->numFacets; j++)\n\t\t{\n\t\t\tfacet = &test->facets[j];\n\t\t\tfor ( k = 0 ; k < facet->numpoints; k++) {\n\t\t\t\tAddPointToBounds( facet->points[k], test->mins, test->maxs );\n\t\t\t}\n\t\t}\n\t\tVS_SphereFromBounds( test->mins, test->maxs, test->origin, &test->radius );\n\t}\n\t_printf(\"%6d facets\\n\", numfacets);\n\t_printf(\"linking surfaces...\\n\");\n\tVS_LinkSurfaces();\n}\n\n/*\n=============\nVS_ChopWinding\n=============\n*/\nint VS_ChopWinding (winding_t *in, plane_t *split, float epsilon)\n{\n\tvec_t\tdists[128];\n\tint\t\tsides[128];\n\tint\t\tcounts[3];\n\tvec_t\tdot;\n\tint\t\ti, j;\n\tvec_t\t*p1, *p2;\n\tvec3_t\tmid;\n\twinding_t out;\n\twinding_t\t*neww;\n\n\tcounts[0] = counts[1] = counts[2] = 0;\n\n\t// determine sides for each point\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tdot = DotProduct (in->points[i], split->normal);\n\t\tdot -= split->dist;\n\t\tdists[i] = dot;\n\t\tif (dot > epsilon)\n\t\t\tsides[i] = SIDE_FRONT;\n\t\telse if (dot < -epsilon)\n\t\t\tsides[i] = SIDE_BACK;\n\t\telse\n\t\t{\n\t\t\tsides[i] = SIDE_ON;\n\t\t}\n\t\tcounts[sides[i]]++;\n\t}\n\n\tif (!counts[SIDE_BACK])\n\t{\n\t\tif (!counts[SIDE_FRONT])\n\t\t\treturn SIDE_ON;\n\t\telse\n\t\t\treturn SIDE_FRONT;\n\t}\n\t\n\tif (!counts[SIDE_FRONT])\n\t{\n\t\treturn SIDE_BACK;\n\t}\n\n\tsides[i] = sides[0];\n\tdists[i] = dists[0];\n\t\n\tneww = &out;\n\n\tneww->numpoints = 0;\n\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tp1 = in->points[i];\n\n\t\tif (neww->numpoints >= MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\t_printf(\"WARNING: VS_ChopWinding -> MAX_POINTS_ON_FIXED_WINDING overflowed\\n\");\n\t\t\treturn SIDE_FRONT;\t\t// can't chop -- fall back to original\n\t\t}\n\n\t\tif (sides[i] == SIDE_ON)\n\t\t{\n\t\t\tVectorCopy (p1, neww->points[neww->numpoints]);\n\t\t\tneww->numpoints++;\n\t\t\tcontinue;\n\t\t}\n\t\n\t\tif (sides[i] == SIDE_FRONT)\n\t\t{\n\t\t\tVectorCopy (p1, neww->points[neww->numpoints]);\n\t\t\tneww->numpoints++;\n\t\t}\n\t\t\n\t\tif (sides[i+1] == SIDE_ON || sides[i+1] == sides[i])\n\t\t\tcontinue;\n\t\t\t\n\t\tif (neww->numpoints >= MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\t_printf(\"WARNING: VS_ChopWinding -> MAX_POINTS_ON_FIXED_WINDING overflowed\\n\");\n\t\t\treturn SIDE_FRONT;\t\t// can't chop -- fall back to original\n\t\t}\n\n\t\t// generate a split point\n\t\tp2 = in->points[(i+1)%in->numpoints];\n\t\t\n\t\tdot = dists[i] / (dists[i]-dists[i+1]);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\t// avoid round off error when possible\n\t\t\tif (split->normal[j] == 1)\n\t\t\t\tmid[j] = split->dist;\n\t\t\telse if (split->normal[j] == -1)\n\t\t\t\tmid[j] = -split->dist;\n\t\t\telse\n\t\t\t\tmid[j] = p1[j] + dot*(p2[j]-p1[j]);\n\t\t}\n\t\t\t\n\t\tVectorCopy (mid, neww->points[neww->numpoints]);\n\t\tneww->numpoints++;\n\t}\n\tmemcpy(in, &out, sizeof(winding_t));\n\t\n\treturn SIDE_CROSS;\n}\n\n/*\n=============\nVS_ChopWindingWithBrush\n\n  returns all winding fragments outside the brush\n=============\n*/\nint VS_ChopWindingWithBrush(winding_t *w, dbrush_t *brush, winding_t *outwindings, int maxout)\n{\n\tint i, res, numout;\n\twinding_t front, back;\n\tplane_t plane;\n\n\tnumout = 0;\n\tmemcpy(front.points, w->points, w->numpoints * sizeof(vec3_t));\n\tfront.numpoints = w->numpoints;\n\tfor (i = 0; i < brush->numSides; i++)\n\t{\n\t\tVectorCopy(dplanes[ dbrushsides[ brush->firstSide + i ].planeNum ].normal, plane.normal);\n\t\tVectorInverse(plane.normal);\n\t\tplane.dist = -dplanes[ dbrushsides[ brush->firstSide + i ].planeNum ].dist;\n\t\tres = VS_SplitWinding(&front, &back, &plane, 0.1);\n\t\tif (res == SIDE_BACK || res == SIDE_ON)\n\t\t{\n\t\t\tmemcpy(outwindings[0].points, w->points, w->numpoints * sizeof(vec3_t));\n\t\t\toutwindings[0].numpoints = w->numpoints;\n\t\t\treturn 1;\t//did not intersect\n\t\t}\n\t\tif (res != SIDE_FRONT)\n\t\t{\n\t\t\tif (numout >= maxout)\n\t\t\t{\n\t\t\t\t_printf(\"WARNING: VS_ChopWindingWithBrush: more than %d windings\\n\", maxout);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tmemcpy(outwindings[numout].points, back.points, back.numpoints * sizeof(vec3_t));\n\t\t\toutwindings[numout].numpoints = back.numpoints;\n\t\t\tnumout++;\n\t\t}\n\t}\n\treturn numout;\n}\n\n/*\n=============\nVS_WindingAreaOutsideBrushes\n=============\n*/\nfloat VS_WindingAreaOutsideBrushes(winding_t *w, int *brushnums, int numbrushes)\n{\n\tint i, j, numwindings[2], n;\n\twinding_t windingsbuf[2][64];\n\tdbrush_t *brush;\n\tfloat area;\n\n\tmemcpy(windingsbuf[0][0].points, w->points, w->numpoints * sizeof(vec3_t));\n\twindingsbuf[0][0].numpoints = w->numpoints;\n\tnumwindings[0] = 1;\n\tfor (i = 0; i < numbrushes; i++)\n\t{\n\t\tbrush = &dbrushes[brushnums[i]];\n\t\tif (!(dshaders[brush->shaderNum].contentFlags & (\n\t\t\t\t\tCONTENTS_LAVA\n\t\t\t\t\t| CONTENTS_SLIME\n\t\t\t\t\t| CONTENTS_WATER\n\t\t\t\t\t| CONTENTS_FOG\n\t\t\t\t\t| CONTENTS_AREAPORTAL\n\t\t\t\t\t| CONTENTS_PLAYERCLIP\n\t\t\t\t\t| CONTENTS_MONSTERCLIP\n\t\t\t\t\t| CONTENTS_CLUSTERPORTAL\n\t\t\t\t\t| CONTENTS_DONOTENTER\n\t\t\t\t\t| CONTENTS_BODY\n\t\t\t\t\t| CONTENTS_CORPSE\n\t\t\t\t\t| CONTENTS_TRANSLUCENT\n\t\t\t\t\t| CONTENTS_TRIGGER\n\t\t\t\t\t| CONTENTS_NODROP) ) &&\n\t\t\t(dshaders[brush->shaderNum].contentFlags & CONTENTS_SOLID) )\n\t\t{\n\t\t\tnumwindings[!(i & 1)] = 0;\n\t\t\tfor (j = 0; j < numwindings[i&1]; j++)\n\t\t\t{\n\t\t\t\tn = VS_ChopWindingWithBrush(&windingsbuf[i&1][j], brush,\n\t\t\t\t\t\t\t\t\t\t\t&windingsbuf[!(i&1)][numwindings[!(i&1)]],\n\t\t\t\t\t\t\t\t\t\t\t64 - numwindings[!(i&1)]);\n\t\t\t\tnumwindings[!(i&1)] += n;\n\t\t\t}\n\t\t\tif (!numwindings[!(i&1)])\n\t\t\t\treturn 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfor (j = 0; j < numwindings[i&1]; j++)\n\t\t\t{\n\t\t\t\twindingsbuf[!(i&1)][j] = windingsbuf[i&1][j];\n\t\t\t}\n\t\t\tnumwindings[!(i&1)] = numwindings[i&1];\n\t\t}\n\t}\n\tarea = 0;\n\tfor (j = 0; j < numwindings[i&1]; j++)\n\t{\n\t\tarea += WindingArea(&windingsbuf[i&1][j]);\n\t}\n\treturn area;\n}\n\n/*\n=============\nVS_R_WindingAreaOutsideSolid\n=============\n*/\nfloat VS_R_WindingAreaOutsideSolid(winding_t *w, vec3_t normal, int nodenum)\n{\n\tint leafnum, res;\n\tfloat area;\n\tdnode_t *node;\n\tdleaf_t *leaf;\n\tdplane_t *plane;\n\twinding_t back;\n\tplane_t split;\n\n\tarea = 0;\n\twhile(nodenum >= 0)\n\t{\n\t\tnode = &dnodes[nodenum];\n\t\tplane = &dplanes[node->planeNum];\n\n\t\tVectorCopy(plane->normal, split.normal);\n\t\tsplit.dist = plane->dist;\n\t\tres = VS_SplitWinding (w, &back, &split, 0.1);\n\n\t\tif (res == SIDE_FRONT)\n\t\t{\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t\telse if (res == SIDE_BACK)\n\t\t{\n\t\t\tnodenum = node->children[1];\n\t\t}\n\t\telse if (res == SIDE_ON)\n\t\t{\n\t\t\tif (DotProduct(normal, plane->normal) > 0)\n\t\t\t\tnodenum = node->children[0];\n\t\t\telse\n\t\t\t\tnodenum = node->children[1];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tarea += VS_R_WindingAreaOutsideSolid(&back, normal, node->children[1]);\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t}\n\tleafnum = -nodenum - 1;\n\tleaf = &dleafs[leafnum];\n\tif (leaf->cluster != -1)\n\t{\n\t\tarea += VS_WindingAreaOutsideBrushes(w, &dleafbrushes[leaf->firstLeafBrush], leaf->numLeafBrushes);\n\t}\n\treturn area;\n}\n\n/*\n=============\nVS_WindingAreaOutsideSolid\n=============\n*/\nfloat VS_WindingAreaOutsideSolid(winding_t *w, vec3_t normal)\n{\n\treturn VS_R_WindingAreaOutsideSolid(w, normal, 0);\n}\n\n/*\n=============\nVS_ChopWindingWithFacet\n=============\n*/\nfloat VS_ChopWindingWithFacet(winding_t *w, lFacet_t *facet)\n{\n\tint i;\n\n\tfor (i = 0; i < facet->numpoints; i++)\n\t{\n\t\tif (VS_ChopWinding(w, &facet->boundaries[i], 0) == SIDE_BACK)\n\t\t\treturn 0;\n\t}\n\tif (nostitching)\n\t\treturn WindingArea(w);\n\telse\n\t\treturn VS_WindingAreaOutsideSolid(w, facet->plane.normal);\n}\n\n/*\n=============\nVS_CalcVisibleLightmapPixelArea\n\nnice brute force ;)\n=============\n*/\nvoid VS_CalcVisibleLightmapPixelArea(void)\n{\n\tint\t\t\t\ti, j, x, y, k;\n\tdsurface_t\t\t*ds;\n\tlsurfaceTest_t\t*test;\n\tmesh_t\t\t\t*mesh;\n\twinding_t w, tmpw;\n\tfloat area;\n\n\t_printf(\"calculating visible lightmap pixel area...\\n\");\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ )\n\t{\n\t\ttest = lsurfaceTest[ i ];\n\t\tif (!test)\n\t\t\tcontinue;\n\t\tds = &drawSurfaces[ i ];\n\n\t\tif ( ds->lightmapNum < 0 )\n\t\t\tcontinue;\n\n\t\tfor (y = 0; y < ds->lightmapHeight; y++)\n\t\t{\n\t\t\tfor (x = 0; x < ds->lightmapWidth; x++)\n\t\t\t{\n\t\t\t\tif (ds->surfaceType == MST_PATCH)\n\t\t\t\t{\n\t\t\t\t\tif (y == ds->lightmapHeight-1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif (x == ds->lightmapWidth-1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tmesh = lsurfaceTest[i]->detailMesh;\n\t\t\t\t\tVectorCopy( mesh->verts[y*mesh->width+x].xyz, w.points[0]);\n\t\t\t\t\tVectorCopy( mesh->verts[(y+1)*mesh->width+x].xyz, w.points[1]);\n\t\t\t\t\tVectorCopy( mesh->verts[(y+1)*mesh->width+x+1].xyz, w.points[2]);\n\t\t\t\t\tVectorCopy( mesh->verts[y*mesh->width+x+1].xyz, w.points[3]);\n\t\t\t\t\tw.numpoints = 4;\n\t\t\t\t\tif (nostitching)\n\t\t\t\t\t\tarea = WindingArea(&w);\n\t\t\t\t\telse\n\t\t\t\t\t\tarea = VS_WindingAreaOutsideSolid(&w, mesh->verts[y*mesh->width+x].normal);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT, ds->lightmapVecs[0], w.points[0]);\n\t\t\t\t\tVectorMA(w.points[0], (float) y - LIGHTMAP_PIXELSHIFT, ds->lightmapVecs[1], w.points[0]);\n\t\t\t\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT, ds->lightmapVecs[0], w.points[3]);\n\t\t\t\t\tVectorMA(w.points[3], (float) y - LIGHTMAP_PIXELSHIFT + 1, ds->lightmapVecs[1], w.points[3]);\n\t\t\t\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT + 1, ds->lightmapVecs[0], w.points[2]);\n\t\t\t\t\tVectorMA(w.points[2], (float) y - LIGHTMAP_PIXELSHIFT + 1, ds->lightmapVecs[1], w.points[2]);\n\t\t\t\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT + 1, ds->lightmapVecs[0], w.points[1]);\n\t\t\t\t\tVectorMA(w.points[1], (float) y - LIGHTMAP_PIXELSHIFT, ds->lightmapVecs[1], w.points[1]);\n\t\t\t\t\tw.numpoints = 4;\n\t\t\t\t\tarea = 0;\n\t\t\t\t\tfor (j = 0; j < test->numFacets; j++)\n\t\t\t\t\t{\n\t\t\t\t\t\tmemcpy(&tmpw, &w, sizeof(winding_t));\n\t\t\t\t\t\tarea += VS_ChopWindingWithFacet(&tmpw, &test->facets[j]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tlightmappixelarea[k] = area;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n=============\nVS_FindAdjacentSurface\n=============\n*/\nint VS_FindAdjacentSurface(int surfaceNum, int facetNum, vec3_t p1, vec3_t p2, int *sNum, int *fNum, int *point)\n{\n\tint i, j, k;\n\tlsurfaceTest_t *test;\n\tlFacet_t *facet;\n\tdsurface_t *ds;\n\tfloat *fp1, *fp2;\n\tvec3_t dir;\n\tplane_t *facetplane;\n\t//\twinding_t w;\n\n\tfacetplane = &lsurfaceTest[surfaceNum]->facets[facetNum].plane;\n\t//\tDebugNet_RemoveAllPolys();\n\t//\tmemcpy(w.points, lsurfaceTest[surfaceNum]->facets[facetNum].points,\n\t//\t\t\tlsurfaceTest[surfaceNum]->facets[facetNum].numpoints * sizeof(vec3_t));\n\t//\tw.numpoints = lsurfaceTest[surfaceNum]->facets[facetNum].numpoints;\n\t//\tDebugNet_DrawWinding(&w, 2);\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ )\n\t{\n\t\tif (i == surfaceNum)\n\t\t\tcontinue;\n\t\ttest = lsurfaceTest[ i ];\n\t\tif (!test)\n\t\t\tcontinue;\n\t\tif (test->trisoup)// || test->patch)\n\t\t\tcontinue;\n\t\tds = &drawSurfaces[i];\n\t\tif ( ds->lightmapNum < 0 )\n\t\t\tcontinue;\n\t\t//if this surface is not even near the edge\n\t\tVectorSubtract(p1, test->origin, dir);\n\t\tif (fabs(dir[0]) > test->radius ||\n\t\t\tfabs(dir[1]) > test->radius ||\n\t\t\tfabs(dir[1]) > test->radius)\n\t\t{\n\t\t\tVectorSubtract(p2, test->origin, dir);\n\t\t\tif (fabs(dir[0]) > test->radius ||\n\t\t\t\tfabs(dir[1]) > test->radius ||\n\t\t\t\tfabs(dir[1]) > test->radius)\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\t//\n\t\tfor (j = 0; j < test->numFacets; j++)\n\t\t{\n\t\t\tfacet = &test->facets[j];\n\t\t\t//\n\t\t\t//if (!Plane_Equal(&facet->plane, facetplane, qfalse))\n\t\t\tif (DotProduct(facet->plane.normal, facetplane->normal) < 0.9)\n\t\t\t{\n\t\t\t\tif (!test->trisoup && !test->patch)\n\t\t\t\t\tbreak;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t//\n\t\t\tfor (k = 0; k < facet->numpoints; k++)\n\t\t\t{\n\t\t\t\tfp1 = facet->points[k];\n\t\t\t\tif (fabs(p2[0] - fp1[0]) < 0.1 &&\n\t\t\t\t\tfabs(p2[1] - fp1[1]) < 0.1 &&\n\t\t\t\t\tfabs(p2[2] - fp1[2]) < 0.1)\n\t\t\t\t{\n\t\t\t\t\tfp2 = facet->points[(k+1) % facet->numpoints];\n\t\t\t\t\tif (fabs(p1[0] - fp2[0]) < 0.1 &&\n\t\t\t\t\t\tfabs(p1[1] - fp2[1]) < 0.1 &&\n\t\t\t\t\t\tfabs(p1[2] - fp2[2]) < 0.1)\n\t\t\t\t\t{\n\t\t\t\t\t\t//\tmemcpy(w.points, facet->points, facet->numpoints * sizeof(vec3_t));\n\t\t\t\t\t\t//\tw.numpoints = facet->numpoints;\n\t\t\t\t\t\t//\tDebugNet_DrawWinding(&w, 1);\n\t\t\t\t\t\t*sNum = i;\n\t\t\t\t\t\t*fNum = j;\n\t\t\t\t\t\t*point = k;\n\t\t\t\t\t\treturn qtrue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t/*\n\t\t\t\telse if (fabs(p1[0] - fp1[0]) < 0.1 &&\n\t\t\t\t\tfabs(p1[1] - fp1[1]) < 0.1 &&\n\t\t\t\t\tfabs(p1[2] - fp1[2]) < 0.1)\n\t\t\t\t{\n\t\t\t\t\tfp2 = facet->points[(k+1) % facet->numpoints];\n\t\t\t\t\tif (fabs(p2[0] - fp2[0]) < 0.1 &&\n\t\t\t\t\t\tfabs(p2[1] - fp2[1]) < 0.1 &&\n\t\t\t\t\t\tfabs(p2[2] - fp2[2]) < 0.1)\n\t\t\t\t\t{\n\t\t\t\t\t\t//\tmemcpy(w.points, facet->points, facet->numpoints * sizeof(vec3_t));\n\t\t\t\t\t\t//\tw.numpoints = facet->numpoints;\n\t\t\t\t\t\t//\tDebugNet_DrawWinding(&w, 1);\n\t\t\t\t\t\t*sNum = i;\n\t\t\t\t\t\t*fNum = j;\n\t\t\t\t\t\t*point = k;\n\t\t\t\t\t\treturn qtrue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t//*/\n\t\t\t}\n\t\t}\n\t}\n\treturn qfalse;\n}\n\n/*\n=============\nVS_SmoothenLightmapEdges\n\nthis code is used to smoothen lightmaps across surface edges\n=============\n*/\nvoid VS_SmoothenLightmapEdges(void)\n{\n\tint i, j, k, coords1[2][2];\n\tfloat coords2[2][2];\n\tint x1, y1, xinc1, yinc1, k1, k2;\n\tfloat x2, y2, xinc2, yinc2, length;\n\tint surfaceNum, facetNum, point;\n\tlsurfaceTest_t *test;\n\tlFacet_t *facet1, *facet2;\n\tdsurface_t *ds1, *ds2;\n\tfloat *p[2], s, t, *color1, *color2;\n\tvec3_t dir, cross;\n\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ )\n\t{\n\t\ttest = lsurfaceTest[ i ];\n\t\tif (!test)\n\t\t\tcontinue;\n\t\tif (test->trisoup)// || test->patch)\n\t\t\tcontinue;\n\t\tds1 = &drawSurfaces[i];\n\t\tif ( ds1->lightmapNum < 0 )\n\t\t\tcontinue;\n\t\tfor (j = 0; j < test->numFacets; j++)\n\t\t{\n\t\t\tfacet1 = &test->facets[j];\n\t\t\t//\n\t\t\tfor (k = 0; k < facet1->numpoints; k++)\n\t\t\t{\n\t\t\t\tp[0] = facet1->points[k];\n\t\t\t\tp[1] = facet1->points[(k+1)%facet1->numpoints];\n\t\t\t\t//\n\t\t\t\tcoords1[0][0] = facet1->lightmapCoords[k][0] * LIGHTMAP_SIZE;\n\t\t\t\tcoords1[0][1] = facet1->lightmapCoords[k][1] * LIGHTMAP_SIZE;\n\t\t\t\tcoords1[1][0] = facet1->lightmapCoords[(k+1)%facet1->numpoints][0] * LIGHTMAP_SIZE;\n\t\t\t\tcoords1[1][1] = facet1->lightmapCoords[(k+1)%facet1->numpoints][1] * LIGHTMAP_SIZE;\n\t\t\t\tif (coords1[0][0] >= LIGHTMAP_SIZE)\n\t\t\t\t\tcoords1[0][0] = LIGHTMAP_SIZE-1;\n\t\t\t\tif (coords1[0][1] >= LIGHTMAP_SIZE)\n\t\t\t\t\tcoords1[0][1] = LIGHTMAP_SIZE-1;\n\t\t\t\tif (coords1[1][0] >= LIGHTMAP_SIZE)\n\t\t\t\t\tcoords1[1][0] = LIGHTMAP_SIZE-1;\n\t\t\t\tif (coords1[1][1] >= LIGHTMAP_SIZE)\n\t\t\t\t\tcoords1[1][1] = LIGHTMAP_SIZE-1;\n\t\t\t\t// try one row or column further because on flat faces the lightmap can\n\t\t\t\t// extend beyond the edge\n\t\t\t\tVectorSubtract(p[1], p[0], dir);\n\t\t\t\tVectorNormalize(dir, dir);\n\t\t\t\tCrossProduct(dir, facet1->plane.normal, cross);\n\t\t\t\t//\n\t\t\t\tif (coords1[0][0] - coords1[1][0] == 0)\n\t\t\t\t{\n\t\t\t\t\ts = DotProduct( cross, facet1->lightmapMatrix[0] );\n\t\t\t\t\tcoords1[0][0] += s < 0 ? 1 : -1;\n\t\t\t\t\tcoords1[1][0] += s < 0 ? 1 : -1;\n\t\t\t\t\tif (coords1[0][0] < ds1->lightmapX || coords1[0][0] >= ds1->lightmapX + ds1->lightmapWidth)\n\t\t\t\t\t{\n\t\t\t\t\t\tcoords1[0][0] += s < 0 ? -1 : 1;\n\t\t\t\t\t\tcoords1[1][0] += s < 0 ? -1 : 1;\n\t\t\t\t\t}\n\t\t\t\t\tlength = fabs(coords1[1][1] - coords1[0][1]);\n\t\t\t\t}\n\t\t\t\telse if (coords1[0][1] - coords1[1][1] == 0)\n\t\t\t\t{\n\t\t\t\t\tt = DotProduct( cross, facet1->lightmapMatrix[1] );\n\t\t\t\t\tcoords1[0][1] += t < 0 ? 1 : -1;\n\t\t\t\t\tcoords1[1][1] += t < 0 ? 1 : -1;\n\t\t\t\t\tif (coords1[0][1] < ds1->lightmapY || coords1[0][1] >= ds1->lightmapY + ds1->lightmapHeight)\n\t\t\t\t\t{\n\t\t\t\t\t\tcoords1[0][1] += t < 0 ? -1 : 1;\n\t\t\t\t\t\tcoords1[1][1] += t < 0 ? -1 : 1;\n\t\t\t\t\t}\n\t\t\t\t\tlength = fabs(coords1[1][0] - coords1[0][0]);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t//the edge is not parallell to one of the lightmap axis\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tx1 = coords1[0][0];\n\t\t\t\ty1 = coords1[0][1];\n\t\t\t\txinc1 = coords1[1][0] - coords1[0][0];\n\t\t\t\tif (xinc1 < 0) xinc1 = -1;\n\t\t\t\tif (xinc1 > 0) xinc1 = 1;\n\t\t\t\tyinc1 = coords1[1][1] - coords1[0][1];\n\t\t\t\tif (yinc1 < 0) yinc1 = -1;\n\t\t\t\tif (yinc1 > 0) yinc1 = 1;\n\t\t\t\t// the edge should be parallell to one of the lightmap axis\n\t\t\t\tif (xinc1 != 0 && yinc1 != 0)\n\t\t\t\t\tcontinue;\n\t\t\t\t//\n\t\t\t\tif (!VS_FindAdjacentSurface(i, j, p[0], p[1], &surfaceNum, &facetNum, &point))\n\t\t\t\t\tcontinue;\n\t\t\t\t//\n\t\t\t\tds2 = &drawSurfaces[surfaceNum];\n\t\t\t\tfacet2 = &lsurfaceTest[surfaceNum]->facets[facetNum];\n\t\t\t\tcoords2[0][0] = facet2->lightmapCoords[(point+1)%facet2->numpoints][0] * LIGHTMAP_SIZE;\n\t\t\t\tcoords2[0][1] = facet2->lightmapCoords[(point+1)%facet2->numpoints][1] * LIGHTMAP_SIZE;\n\t\t\t\tcoords2[1][0] = facet2->lightmapCoords[point][0] * LIGHTMAP_SIZE;\n\t\t\t\tcoords2[1][1] = facet2->lightmapCoords[point][1] * LIGHTMAP_SIZE;\n\t\t\t\tif (coords2[0][0] >= LIGHTMAP_SIZE)\n\t\t\t\t\tcoords2[0][0] = LIGHTMAP_SIZE-1;\n\t\t\t\tif (coords2[0][1] >= LIGHTMAP_SIZE)\n\t\t\t\t\tcoords2[0][1] = LIGHTMAP_SIZE-1;\n\t\t\t\tif (coords2[1][0] >= LIGHTMAP_SIZE)\n\t\t\t\t\tcoords2[1][0] = LIGHTMAP_SIZE-1;\n\t\t\t\tif (coords2[1][1] >= LIGHTMAP_SIZE)\n\t\t\t\t\tcoords2[1][1] = LIGHTMAP_SIZE-1;\n\t\t\t\t//\n\t\t\t\tx2 = coords2[0][0];\n\t\t\t\ty2 = coords2[0][1];\n\t\t\t\txinc2 = coords2[1][0] - coords2[0][0];\n\t\t\t\tif (length)\n\t\t\t\t\txinc2 = xinc2 / length;\n\t\t\t\tyinc2 = coords2[1][1] - coords2[0][1];\n\t\t\t\tif (length)\n\t\t\t\t\tyinc2 = yinc2 / length;\n\t\t\t\t// the edge should be parallell to one of the lightmap axis\n\t\t\t\tif ((int) xinc2 != 0 && (int) yinc2 != 0)\n\t\t\t\t\tcontinue;\n\t\t\t\t//\n\t\t\t\twhile(1)\n\t\t\t\t{\n\t\t\t\t\tk1 = ( ds1->lightmapNum * LIGHTMAP_HEIGHT + y1) * LIGHTMAP_WIDTH + x1;\n\t\t\t\t\tk2 = ( ds2->lightmapNum * LIGHTMAP_HEIGHT + ((int) y2)) * LIGHTMAP_WIDTH + ((int) x2);\n\t\t\t\t\tcolor1 = lightFloats + k1*3;\n\t\t\t\t\tcolor2 = lightFloats + k2*3;\n\t\t\t\t\tif (lightmappixelarea[k1] < 0.01)\n\t\t\t\t\t{\n\t\t\t\t\t\tcolor1[0] = color2[0];\n\t\t\t\t\t\tcolor1[1] = color2[1];\n\t\t\t\t\t\tcolor1[2] = color2[2];\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tcolor1[0] = (float) color2[0] * 0.7 + (float) color1[0] * 0.3;\n\t\t\t\t\t\tcolor1[1] = (float) color2[1] * 0.7 + (float) color1[1] * 0.3;\n\t\t\t\t\t\tcolor1[2] = (float) color2[2] * 0.7 + (float) color1[2] * 0.3;\n\t\t\t\t\t}\n\t\t\t\t\t//\n\t\t\t\t\tif (x1 == coords1[1][0] &&\n\t\t\t\t\t\ty1 == coords1[1][1])\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tx1 += xinc1;\n\t\t\t\t\ty1 += yinc1;\n\t\t\t\t\tx2 += xinc2;\n\t\t\t\t\ty2 += yinc2;\n\t\t\t\t\tif (x2 < ds2->lightmapX)\n\t\t\t\t\t\tx2 = ds2->lightmapX;\n\t\t\t\t\tif (x2 >= ds2->lightmapX + ds2->lightmapWidth)\n\t\t\t\t\t\tx2 = ds2->lightmapX + ds2->lightmapWidth-1;\n\t\t\t\t\tif (y2 < ds2->lightmapY)\n\t\t\t\t\t\ty2 = ds2->lightmapY;\n\t\t\t\t\tif (y2 >= ds2->lightmapY + ds2->lightmapHeight)\n\t\t\t\t\t\ty2 = ds2->lightmapY + ds2->lightmapHeight-1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n=============\nVS_FixLightmapEdges\n=============\n*/\nvoid VS_FixLightmapEdges(void)\n{\n\tint\t\t\t\ti, j, x, y, k, foundvalue, height, width, index;\n\tint\t\t\t\tpos, top, bottom;\n\tdsurface_t\t\t*ds;\n\tlsurfaceTest_t\t*test;\n\tfloat\t\t\tcolor[3];\n\tfloat\t\t\t*ptr;\n\tbyte filled[(LIGHTMAP_SIZE+1) * (LIGHTMAP_SIZE+1) / 8];\n\tfloat lightmap_edge_epsilon;\n\n\tlightmap_edge_epsilon = 0.1 * samplesize;\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ )\n\t{\n\t\ttest = lsurfaceTest[ i ];\n\t\tif (!test)\n\t\t\tcontinue;\n\t\tds = &drawSurfaces[ i ];\n\n\t\tif ( ds->lightmapNum < 0 )\n\t\t\tcontinue;\n\t\tif (ds->surfaceType == MST_PATCH)\n\t\t{\n\t\t\theight = ds->lightmapHeight - 1;\n\t\t\twidth = ds->lightmapWidth - 1;\n\t\t}\n\t\telse\n\t\t{\n\t\t\theight = ds->lightmapHeight;\n\t\t\twidth = ds->lightmapWidth;\n\t\t}\n\t\tmemset(filled, 0, sizeof(filled));\n//\t\tprintf(\"\\n\");\n\t\tfor (x = 0; x < width; x++)\n\t\t{\n\t\t\tfor (y = 0; y < height; y++)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tif (lightmappixelarea[k] > lightmap_edge_epsilon)\n\t\t\t\t{\n\t\t\t\t\tindex = (ds->lightmapY + y) * LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\t\tfilled[index >> 3] |= 1 << (index & 7);\n//\t\t\t\t\tprintf(\"*\");\n\t\t\t\t}\n//\t\t\t\telse\n//\t\t\t\t\tprintf(\"_\");\n\t\t\t}\n//\t\t\tprintf(\"\\n\");\n\t\t}\n\t\tfor (y = 0; y < height; y++)\n\t\t{\n\t\t\tpos = -2;\n\t\t\tfor (x = 0; x < width; x++)\n\t\t\t{\n\t\t\t\tindex = (ds->lightmapY + y) * LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tif (pos == -2)\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t\tpos = -1;\n\t\t\t\t}\n\t\t\t\telse if (pos == -1)\n\t\t\t\t{\n\t\t\t\t\tif (!(filled[index >> 3] & (1 << (index & 7))))\n\t\t\t\t\t\tpos = x - 1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t{\n\t\t\t\t\t\tbottom = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + pos;\n\t\t\t\t\t\ttop = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\t\t\tfor (j = 0; j < (x - pos + 1) / 2; j++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + pos + j + 1;\n\t\t\t\t\t\t\tindex = (ds->lightmapY + y) * LIGHTMAP_WIDTH + ds->lightmapX + pos + j + 1;\n\t\t\t\t\t\t\tfilled[index >> 3] |= 1 << (index & 7);\n\t\t\t\t\t\t\t(lightFloats + k*3)[0] = (lightFloats + top*3)[0];\n\t\t\t\t\t\t\t(lightFloats + k*3)[1] = (lightFloats + top*3)[1];\n\t\t\t\t\t\t\t(lightFloats + k*3)[2] = (lightFloats + top*3)[2];\n\t\t\t\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x - j - 1;\n\t\t\t\t\t\t\tindex = (ds->lightmapY + y) * LIGHTMAP_WIDTH + ds->lightmapX + x - j - 1;\n\t\t\t\t\t\t\tfilled[index >> 3] |= 1 << (index & 7);\n\t\t\t\t\t\t\t(lightFloats + k*3)[0] = (lightFloats + bottom*3)[0];\n\t\t\t\t\t\t\t(lightFloats + k*3)[1] = (lightFloats + bottom*3)[1];\n\t\t\t\t\t\t\t(lightFloats + k*3)[2] = (lightFloats + bottom*3)[2];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpos = -1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (x = 0; x < width; x++)\n\t\t{\n\t\t\tpos = -2;\n\t\t\tfor (y = 0; y < height; y++)\n\t\t\t{\n\t\t\t\tindex = (ds->lightmapY + y) * LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tif (pos == -2)\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t\tpos = -1;\n\t\t\t\t}\n\t\t\t\telse if (pos == -1)\n\t\t\t\t{\n\t\t\t\t\tif (!(filled[index >> 3] & (1 << (index & 7))))\n\t\t\t\t\t\tpos = y - 1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t{\n\t\t\t\t\t\tbottom = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + pos)\n\t\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\t\t\ttop = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\t\t\tfor (j = 0; j < (y - pos + 1) / 2; j++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + pos + j + 1)\n\t\t\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\t\t\t\tindex = (ds->lightmapY + pos + j + 1) * LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\t\t\t\tfilled[index >> 3] |= 1 << (index & 7);\n\t\t\t\t\t\t\t(lightFloats + k*3)[0] = (lightFloats + top*3)[0];\n\t\t\t\t\t\t\t(lightFloats + k*3)[1] = (lightFloats + top*3)[1];\n\t\t\t\t\t\t\t(lightFloats + k*3)[2] = (lightFloats + top*3)[2];\n\t\t\t\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y - j - 1)\n\t\t\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\t\t\t\tindex = (ds->lightmapY + y - j - 1) * LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\t\t\t\tfilled[index >> 3] |= 1 << (index & 7);\n\t\t\t\t\t\t\t(lightFloats + k*3)[0] = (lightFloats + bottom*3)[0];\n\t\t\t\t\t\t\t(lightFloats + k*3)[1] = (lightFloats + bottom*3)[1];\n\t\t\t\t\t\t\t(lightFloats + k*3)[2] = (lightFloats + bottom*3)[2];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpos = -1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (y = 0; y < height; y++)\n\t\t{\n\t\t\tfoundvalue = qfalse;\n\t\t\tfor (x = 0; x < width; x++)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tindex = (ds->lightmapY + y) * LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tif (foundvalue)\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tcolor[0] = ptr[0];\n\t\t\t\t\t\tcolor[1] = ptr[1];\n\t\t\t\t\t\tcolor[2] = ptr[2];\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tptr[0] = color[0];\n\t\t\t\t\t\tptr[1] = color[1];\n\t\t\t\t\t\tptr[2] = color[2];\n\t\t\t\t\t\tfilled[index >> 3] |= 1 << (index & 7);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tcolor[0] = ptr[0];\n\t\t\t\t\t\tcolor[1] = ptr[1];\n\t\t\t\t\t\tcolor[2] = ptr[2];\n\t\t\t\t\t\tfoundvalue = qtrue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfoundvalue = qfalse;\n\t\t\tfor (x = width-1; x >= 0; x--)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tindex = (ds->lightmapY + y) * LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tif (foundvalue)\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tcolor[0] = ptr[0];\n\t\t\t\t\t\tcolor[1] = ptr[1];\n\t\t\t\t\t\tcolor[2] = ptr[2];\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tptr[0] = color[0];\n\t\t\t\t\t\tptr[1] = color[1];\n\t\t\t\t\t\tptr[2] = color[2];\n\t\t\t\t\t\tfilled[index >> 3] |= 1 << (index & 7);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tcolor[0] = ptr[0];\n\t\t\t\t\t\tcolor[1] = ptr[1];\n\t\t\t\t\t\tcolor[2] = ptr[2];\n\t\t\t\t\t\tfoundvalue = qtrue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (x = 0; x < width; x++)\n\t\t{\n\t\t\tfoundvalue = qfalse;\n\t\t\tfor (y = 0; y < height; y++)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tindex = (ds->lightmapY + y) * LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tif (foundvalue)\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tcolor[0] = ptr[0];\n\t\t\t\t\t\tcolor[1] = ptr[1];\n\t\t\t\t\t\tcolor[2] = ptr[2];\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tptr[0] = color[0];\n\t\t\t\t\t\tptr[1] = color[1];\n\t\t\t\t\t\tptr[2] = color[2];\n\t\t\t\t\t\tfilled[index >> 3] |= 1 << (index & 7);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tcolor[0] = ptr[0];\n\t\t\t\t\t\tcolor[1] = ptr[1];\n\t\t\t\t\t\tcolor[2] = ptr[2];\n\t\t\t\t\t\tfoundvalue = qtrue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfoundvalue = qfalse;\n\t\t\tfor (y = height-1; y >= 0; y--)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tindex = (ds->lightmapY + y) * LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tif (foundvalue)\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tcolor[0] = ptr[0];\n\t\t\t\t\t\tcolor[1] = ptr[1];\n\t\t\t\t\t\tcolor[2] = ptr[2];\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tptr[0] = color[0];\n\t\t\t\t\t\tptr[1] = color[1];\n\t\t\t\t\t\tptr[2] = color[2];\n\t\t\t\t\t\tfilled[index >> 3] |= 1 << (index & 7);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (filled[index >> 3] & (1 << (index & 7)))\n\t\t\t\t\t{\n\t\t\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\t\t\tcolor[0] = ptr[0];\n\t\t\t\t\t\tcolor[1] = ptr[1];\n\t\t\t\t\t\tcolor[2] = ptr[2];\n\t\t\t\t\t\tfoundvalue = qtrue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (ds->surfaceType == MST_PATCH)\n\t\t{\n\t\t\tx = ds->lightmapWidth-1;\n\t\t\tfor (y = 0; y < ds->lightmapHeight; y++)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\tptr[0] = (lightFloats + (k-1)*3)[0];\n\t\t\t\tptr[1] = (lightFloats + (k-1)*3)[1];\n\t\t\t\tptr[2] = (lightFloats + (k-1)*3)[2];\n\t\t\t}\n\t\t\ty = ds->lightmapHeight-1;\n\t\t\tfor (x = 0; x < ds->lightmapWidth; x++)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\tptr[0] = (lightFloats + (k-LIGHTMAP_WIDTH)*3)[0];\n\t\t\t\tptr[1] = (lightFloats + (k-LIGHTMAP_WIDTH)*3)[1];\n\t\t\t\tptr[2] = (lightFloats + (k-LIGHTMAP_WIDTH)*3)[2];\n\t\t\t}\n\t\t}\n\t\t/*\n\t\t//colored debug edges\n\t\tif (ds->surfaceType == MST_PATCH)\n\t\t{\n\t\t\tx = ds->lightmapWidth-1;\n\t\t\tfor (y = 0; y < ds->lightmapHeight; y++)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\tptr[0] = 255;\n\t\t\t\tptr[1] = 0;\n\t\t\t\tptr[2] = 0;\n\t\t\t}\n\t\t\ty = ds->lightmapHeight-1;\n\t\t\tfor (x = 0; x < ds->lightmapWidth; x++)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\tptr[0] = 0;\n\t\t\t\tptr[1] = 255;\n\t\t\t\tptr[2] = 0;\n\t\t\t}\n\t\t}\n\t\t//*/\n\t}\n\t//\n\tVS_SmoothenLightmapEdges();\n}\n\n/*\n=============\nVS_ShiftPatchLightmaps\n=============\n*/\nvoid VS_ShiftPatchLightmaps(void)\n{\n\tint\t\t\t\ti, j, x, y, k;\n\tdrawVert_t\t\t*verts;\n\tdsurface_t\t\t*ds;\n\tlsurfaceTest_t\t*test;\n\tfloat\t\t\t*ptr;\n\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ )\n\t{\n\t\ttest = lsurfaceTest[ i ];\n\t\tif (!test)\n\t\t\tcontinue;\n\t\tds = &drawSurfaces[ i ];\n\n\t\tif ( ds->lightmapNum < 0 )\n\t\t\tcontinue;\n\t\tif (ds->surfaceType != MST_PATCH)\n\t\t\tcontinue;\n\t\tfor (x = ds->lightmapWidth; x > 0; x--)\n\t\t{\n\t\t\tfor (y = 0; y <= ds->lightmapHeight; y++)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\tptr[0] = (lightFloats + (k-1)*3)[0];\n\t\t\t\tptr[1] = (lightFloats + (k-1)*3)[1];\n\t\t\t\tptr[2] = (lightFloats + (k-1)*3)[2];\n\t\t\t}\n\t\t}\n\t\tfor (y = ds->lightmapHeight; y > 0; y--)\n\t\t{\n\t\t\tfor (x = 0; x <= ds->lightmapWidth; x++)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tptr = lightFloats + k*3;\n\t\t\t\tptr[0] = (lightFloats + (k-LIGHTMAP_WIDTH)*3)[0];\n\t\t\t\tptr[1] = (lightFloats + (k-LIGHTMAP_WIDTH)*3)[1];\n\t\t\t\tptr[2] = (lightFloats + (k-LIGHTMAP_WIDTH)*3)[2];\n\t\t\t}\n\t\t}\n\t\tverts = &drawVerts[ ds->firstVert ];\n\t\tfor ( j = 0 ; j < ds->patchHeight * ds->patchWidth; j++ )\n\t\t{\n\t\t\tverts[j].lightmap[0] += 0.5 / LIGHTMAP_WIDTH;\n\t\t\tverts[j].lightmap[1] += 0.5 / LIGHTMAP_HEIGHT;\n\t\t}\n\t\tds->lightmapHeight++;\n\t\tds->lightmapWidth++;\n\t}\n}\n\n/*\n=============\nVS_StoreLightmap\n=============\n*/\nvoid VS_StoreLightmap(void)\n{\n\tint\t\t\t\ti, x, y, k;\n\tdsurface_t\t\t*ds;\n\tlsurfaceTest_t\t*test;\n\tfloat\t\t\t*src;\n\tbyte\t\t\t*dst;\n\n\t_printf(\"storing lightmaps...\\n\");\n\t//fix lightmap edges before storing them\n\tVS_FixLightmapEdges();\n\t//\n#ifdef LIGHTMAP_PATCHSHIFT\n\tVS_ShiftPatchLightmaps();\n#endif\n\t//\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ )\n\t{\n\t\ttest = lsurfaceTest[ i ];\n\t\tif (!test)\n\t\t\tcontinue;\n\t\tds = &drawSurfaces[ i ];\n\n\t\tif ( ds->lightmapNum < 0 )\n\t\t\tcontinue;\n\n\t\tfor (y = 0; y < ds->lightmapHeight; y++)\n\t\t{\n\t\t\tfor (x = 0; x < ds->lightmapWidth; x++)\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y)\n\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\t\tVectorAdd((lightFloats + k*3), lightAmbientColor, (lightFloats + k*3));\n\t\t\t\tsrc = &lightFloats[k*3];\n\t\t\t\tdst = lightBytes + k*3;\n\t\t\t\tColorToBytes(src, dst);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n=============\nPointInLeafnum\n=============\n*/\nstatic int\tPointInLeafnum(vec3_t point)\n{\n\tint\t\tnodenum;\n\tvec_t\tdist;\n\tdnode_t\t*node;\n\tdplane_t\t*plane;\n\n\tnodenum = 0;\n\twhile (nodenum >= 0)\n\t{\n\t\tnode = &dnodes[nodenum];\n\t\tplane = &dplanes[node->planeNum];\n\t\tdist = DotProduct (point, plane->normal) - plane->dist;\n\t\tif (dist > 0)\n\t\t\tnodenum = node->children[0];\n\t\telse\n\t\t\tnodenum = node->children[1];\n\t}\n\n\treturn -nodenum - 1;\n}\n\n/*\n=============\nVS_PointInLeafnum_r\n=============\n*/\nint\tVS_PointInLeafnum_r(vec3_t point, int nodenum)\n{\n\tint leafnum;\n\tvec_t\tdist;\n\tdnode_t\t*node;\n\tdplane_t\t*plane;\n\n\twhile (nodenum >= 0)\n\t{\n\t\tnode = &dnodes[nodenum];\n\t\tplane = &dplanes[node->planeNum];\n\t\tdist = DotProduct (point, plane->normal) - plane->dist;\n\t\tif (dist > 0.1)\n\t\t{\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t\telse if (dist < -0.1)\n\t\t{\n\t\t\tnodenum = node->children[1];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tleafnum = VS_PointInLeafnum_r(point, node->children[0]);\n\t\t\tif (dleafs[leafnum].cluster != -1)\n\t\t\t\treturn leafnum;\n\t\t\tnodenum = node->children[1];\n\t\t}\n\t}\n\n\tleafnum = -nodenum - 1;\n\treturn leafnum;\n}\n\n/*\n=============\nVS_PointInLeafnum\n=============\n*/\nint\tVS_PointInLeafnum(vec3_t point)\n{\n\treturn VS_PointInLeafnum_r(point, 0);\n}\n\n/*\n=============\nVS_LightLeafnum\n=============\n*/\nint VS_LightLeafnum(vec3_t point)\n{\n\t/*\n\tint leafnum;\n\tdleaf_t *leaf;\n\tfloat x, y, z;\n\tvec3_t test;\n\n\tleafnum = VS_PointInLeafnum(point);\n\tleaf = &dleafs[leafnum];\n\tif (leaf->cluster != -1)\n\t\treturn leafnum;\n\tfor (z = 1; z >= -1; z -= 1)\n\t{\n\t\tfor (x = 1; x >= -1; x -= 1)\n\t\t{\n\t\t\tfor (y = 1; y >= -1; y -= 1)\n\t\t\t{\n\t\t\t\tVectorCopy(point, test);\n\t\t\t\ttest[0] += x;\n\t\t\t\ttest[1] += y;\n\t\t\t\ttest[2] += z;\n\t\t\t\tleafnum = VS_PointInLeafnum(test);\n\t\t\t\tleaf = &dleafs[leafnum];\n\t\t\t\tif (leaf->cluster != -1)\n\t\t\t\t{\n\t\t\t\t\tVectorCopy(test, point);\n\t\t\t\t\treturn leafnum;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn leafnum;\n\t*/\n\treturn VS_PointInLeafnum(point);\n}\n\n//#define LIGHTPOLYS\n\n#ifdef LIGHTPOLYS\n\nwinding_t *lightwindings[MAX_MAP_DRAW_SURFS];\nint numlightwindings;\n\n/*\n=============\nVS_DrawLightWindings\n=============\n*/\nvoid VS_DrawLightWindings(void)\n{\n\tint i;\n\tfor (i = 0; i < numlightwindings; i++)\n\t{\n#ifdef DEBUGNET\n\t\tDebugNet_DrawWinding(lightwindings[i], 1);\n#endif\n\t}\n}\n\n/*\n=============\nVS_LightSurfaceWithVolume\n=============\n*/\nvoid VS_LightSurfaceWithVolume(int surfaceNum, int facetNum, vsound_t *light, lightvolume_t *volume)\n{\n\twinding_t *w;\n\tlsurfaceTest_t *test;\n\tlFacet_t *facet;\n\tint i;\n\n\ttest = lsurfaceTest[ surfaceNum ];\n\tfacet = &test->facets[ facetNum ];\n\n\t//\n\tw = (winding_t *) malloc(sizeof(winding_t));\n\tmemcpy(w->points, facet->points, sizeof(vec3_t) * facet->numpoints);\n\tw->numpoints = facet->numpoints;\n\n\tfor (i = 0; i < volume->numplanes; i++)\n\t{\n\t\t//if totally on the back\n\t\tif (VS_ChopWinding(w, &volume->planes[i], 0.01) == SIDE_BACK)\n\t\t\treturn;\n\t}\n\tlightwindings[numlightwindings] = w;\n\tnumlightwindings++;\n\tif (numlightwindings >= MAX_MAP_DRAW_SURFS)\n\t\tError(\"MAX_LIGHTWINDINGS\");\n}\n\n#else\n\n/*\n=============\nVS_LightSurfaceWithVolume\n=============\n*/\n/*\nint VS_PointInsideLightVolume(vec3_t point, lightvolume_t *volume)\n{\n\tint i;\n\tfloat d;\n\n\tfor (i = 0; i < volume->numplanes; i++)\n\t{\n\t\td = DotProduct(volume->planes[i].normal, point) - volume->planes[i].dist;\n\t\tif (d < 0) return qfalse;\n\t}\n\treturn qtrue;\n}\n\nvoid VS_LightSurfaceWithVolume( int surfaceNum, int facetNum, vsound_t *light, lightvolume_t *volume )\n{\n\tdsurface_t\t*ds;\n\tint\t\t\ti, j, k;\n\tint\t\t\tnumPositions;\n\tvec3_t\t\tbase, normal, color;\n\tint\t\t\tsampleWidth, sampleHeight;\n\tvec3_t\t\tlightmapOrigin, lightmapVecs[2], dir;\n\tunsigned char *ptr;\n\tfloat add, dist, angle;\n\tmesh_t * mesh;\n\n\tds = &drawSurfaces[surfaceNum];\n\n\t// vertex-lit triangle model\n\tif ( ds->surfaceType == MST_TRIANGLE_SOUP ) {\n\t\treturn;\n\t}\n\t\n\tif ( ds->lightmapNum < 0 ) {\n\t\treturn;\t\t// doesn't need lighting\n\t}\n\n\tif ( ds->surfaceType == MST_PATCH ) {\n\t\tmesh = lsurfaceTest[surfaceNum]->detailMesh;\n\t} else {\n\t\tVectorCopy( ds->lightmapVecs[2], normal );\n\n\t\tVectorCopy( ds->lightmapOrigin, lightmapOrigin );\n\t\tVectorCopy( ds->lightmapVecs[0], lightmapVecs[0] );\n\t\tVectorCopy( ds->lightmapVecs[1], lightmapVecs[1] );\n\t}\n\n\tsampleWidth = ds->lightmapWidth;\n\tsampleHeight = ds->lightmapHeight;\n\n\t//calculate lightmap\n\tfor ( i = 0 ; i < sampleWidth; i++ ) {\n\t\tfor ( j = 0 ; j < sampleHeight; j++ ) {\n\n\t\t\tif ( ds->patchWidth ) {\n\t\t\t\tnumPositions = 9;\n\t\t\t\tVectorCopy( mesh->verts[j*mesh->width+i].normal, normal );\n\t\t\t\t// VectorNormalize( normal, normal );\n\t\t\t\t// push off of the curve a bit\n\t\t\t\tVectorMA( mesh->verts[j*mesh->width+i].xyz, 1, normal, base );\n\n//\t\t\t\tMakeNormalVectors( normal, lightmapVecs[0], lightmapVecs[1] );\n\t\t\t} else {\n\t\t\t\tnumPositions = 9;\n\t\t\t\tfor ( k = 0 ; k < 3 ; k++ ) {\n\t\t\t\t\tbase[k] = lightmapOrigin[k] + normal[k]\n\t\t\t\t\t\t\t\t+ ((float) i) * lightmapVecs[0][k]\n\t\t\t\t\t\t\t\t+ ((float) j) * lightmapVecs[1][k];\n\t\t\t\t}\n\t\t\t}\n\t\t\tVectorAdd( base, surfaceOrigin[ surfaceNum ], base );\n\n\t\t\tVectorSubtract(base, light->origin, dir);\n\t\t\tdist = VectorNormalize(dir, dir);\n\t\t\tif ( dist < 16 ) {\n\t\t\t\tdist = 16;\n\t\t\t}\n\t\t\tangle = 1;//DotProduct( normal, dir ); //1;\n\t\t\tif (angle > 1)\n\t\t\t\tangle = 1;\n\t\t\tif ( light->atten_disttype == LDAT_LINEAR ) {\n\t\t\t\tadd = angle * light->photons * lightLinearScale - dist;\n\t\t\t\tif ( add < 0 ) {\n\t\t\t\t\tadd = 0;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tadd = light->photons / ( dist * dist ) * angle;\n\t\t\t}\n\t\t\tif (add <= 1.0)\n\t\t\t\tcontinue;\n\n\t\t\tif (VS_PointInsideLightVolume(base, volume))\n\t\t\t{\n\t\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + j) \n\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + i;\n\t\t\t\tptr = lightBytes + k*3;\n\t\t\t\tcolor[0] = (float) ptr[0] + add * light->color[0];\n\t\t\t\tcolor[1] = (float) ptr[1] + add * light->color[1];\n\t\t\t\tcolor[2] = (float) ptr[2] + add * light->color[2];\n\t\t\t\tColorToBytes(color, ptr);\n\t\t\t}\n\t\t}\n\t}\n}\n*/\n\n/*\n=============\nVS_GetFilter\n\nFIXME:  don't use a lightmap pixel origin but use the four corner points\n\t\tto map part of a translucent surface onto the lightmap pixel\n=============\n*/\nvoid VS_GetFilter(vsound_t *light, lightvolume_t *volume, vec3_t lmp, vec3_t filter)\n{\n\tlFacet_t *facet;\n\tlsurfaceTest_t *test;\n\tfloat d, d1, d2, frac, s, t, ns;\n\tint i, j, is, it, b;\n\tint x, y, u, v, numsamples, radius, color[4], largest;\n\tbyte *image;\n\tvec3_t point, origin, total;\n\n\tVectorSet(filter, 1, 1, 1);\n\n\tif (noalphashading)\n\t\treturn;\n\n\tif (volume->numtransFacets <= 0)\n\t\treturn;\n\n\tif (light->type == LIGHT_SURFACEDIRECTED)\n\t{\n\t\t// project the light map pixel origin onto the area light source plane\n\t\td = DotProduct(lmp, light->normal) - DotProduct(light->normal, light->w.points[0]);\n\t\tVectorMA(lmp, -d, light->normal, origin);\n\t}\n\telse\n\t{\n\t\tVectorCopy(light->origin, origin);\n\t}\n\tfor (i = 0; i < volume->numtransFacets; i++)\n\t{\n\t\ttest = lsurfaceTest[ volume->transSurfaces[i] ];\n\t\tfacet = &test->facets[ volume->transFacets[i] ];\n\t\t// if this surface does not cast an alpha shadow\n\t\tif ( !(test->shader->surfaceFlags & SURF_ALPHASHADOW) )\n\t\t\tcontinue;\n\t\t// if there are no texture pixel available\n\t\tif ( !test->shader->pixels ) {\n\t\t\tcontinue;\n\t\t}\n\t\t//\n\t\td1 = DotProduct( origin, facet->plane.normal) - facet->plane.dist;\n\t\td2 = DotProduct( lmp, facet->plane.normal ) - facet->plane.dist;\n\t\t// this should never happen because the light volume went through the facet\n\t\tif ( ( d1 < 0 ) == ( d2 < 0 ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// calculate the crossing point\n\t\tfrac = d1 / ( d1 - d2 );\n\n\t\tfor ( j = 0 ; j < 3 ; j++ ) {\n\t\t\tpoint[j] = origin[j] + frac * ( lmp[j] - origin[j] );\n\t\t}\n\n\t\ts = DotProduct( point, facet->textureMatrix[0] ) + facet->textureMatrix[0][3];\n\t\tt = DotProduct( point, facet->textureMatrix[1] ) + facet->textureMatrix[1][3];\n\t\tif (s < 0)\n\t\t\ts = 0;\n\t\tif (t < 0)\n\t\t\tt = 0;\n\n\t\ts = s - floor( s );\n\t\tt = t - floor( t );\n\n\t\tis = s * test->shader->width;\n\t\tit = t * test->shader->height;\n\n\t\t//if old style alpha shading\n\t\tif (nocolorshading) {\n\t\t\timage = test->shader->pixels + 4 * ( it * test->shader->width + is );\n\n\t\t\t// alpha filter\n\t\t\tb = image[3];\n\n\t\t\t// alpha test makes this a binary option\n\t\t\tb = b < 128 ? 0 : 255;\n\n\t\t\tfilter[0] = filter[0] * (255-b) / 255;\n\t\t\tfilter[1] = filter[1] * (255-b) / 255;\n\t\t\tfilter[2] = filter[2] * (255-b) / 255;\n\t\t}\n\t\telse {\n\t\t\tVectorClear(total);\n\t\t\tnumsamples = 0;\n\t\t\tradius = 2;\n\t\t\tfor ( u = -radius; u <= radius; u++ )\n\t\t\t{\n\t\t\t\tx = is + u;\n\t\t\t\tif ( x < 0 || x >= test->shader->width)\n\t\t\t\t\tcontinue;\n\t\t\t\tfor ( v = -radius; v <= radius; v++ )\n\t\t\t\t{\n\t\t\t\t\ty = it + v;\n\t\t\t\t\tif ( y < 0 || y >= test->shader->height)\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\timage = test->shader->pixels + 4 * ( y * test->shader->width + x );\n\t\t\t\t\tcolor[0] = image[0];\n\t\t\t\t\tcolor[1] = image[1];\n\t\t\t\t\tcolor[2] = image[2];\n\t\t\t\t\tlargest = 0;\n\t\t\t\t\tfor (j = 0; j < 3; j++)\n\t\t\t\t\t\tif (image[j] > largest)\n\t\t\t\t\t\t\tlargest = image[j];\n\t\t\t\t\tif (largest <= 0 || image[3] == 0) {\n\t\t\t\t\t\tcolor[0] = 255;\n\t\t\t\t\t\tcolor[1] = 255;\n\t\t\t\t\t\tcolor[2] = 255;\n\t\t\t\t\t\tlargest = 255;\n\t\t\t\t\t}\n\t\t\t\t\ttotal[0] += ((float) color[0]/largest) * (255-image[3]) / 255.0;\n\t\t\t\t\ttotal[1] += ((float) color[1]/largest) * (255-image[3]) / 255.0;\n\t\t\t\t\ttotal[2] += ((float) color[2]/largest) * (255-image[3]) / 255.0;\n\t\t\t\t\tnumsamples++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tns = numsamples;\n\t\t\t//\n\t\t\tfilter[0] *= total[0] / ns;\n\t\t\tfilter[1] *= total[1] / ns;\n\t\t\tfilter[2] *= total[2] / ns;\n\t\t}\n\t}\n}\n\n/*\n=============\nVS_LightSurfaceWithVolume\n=============\n*/\nvoid VS_LightSurfaceWithVolume( int surfaceNum, int facetNum, vsound_t *light, lightvolume_t *volume )\n{\n\tint i;\n\tdsurface_t\t*ds;\n\tlFacet_t *facet;\n\tlsurfaceTest_t *test;\n\twinding_t w;\n\tvec3_t base, dir, delta, normal, filter, origin;\n\tint min_x[LIGHTMAP_SIZE+2], max_x[LIGHTMAP_SIZE+2];\n\tint min_y, max_y, k, x, y, n;\n\tfloat *color, distscale;\n\tfloat d, add, angle, dist, area, insidearea, coords[MAX_POINTS_ON_WINDING+1][2];\n\tmesh_t *mesh;\n\tbyte polygonedges[(LIGHTMAP_SIZE+1) * (LIGHTMAP_SIZE+1) / 8];\n\n\n\tds = &drawSurfaces[surfaceNum];\n\n\t// vertex-lit triangle model\n\tif ( ds->surfaceType == MST_TRIANGLE_SOUP ) {\n\t\treturn;\n\t}\n\t\n\tif ( ds->lightmapNum < 0 ) {\n\t\treturn;\t\t// doesn't need lighting\n\t}\n\n\ttest = lsurfaceTest[ surfaceNum ];\n\tfacet = &test->facets[ facetNum ];\n\n\tif (defaulttracelight && !test->always_vsound)\n\t\treturn;\n\tif (test->always_tracelight)\n\t\treturn;\n\n\tmemcpy(w.points, facet->points, sizeof(vec3_t) * facet->numpoints);\n\tw.numpoints = facet->numpoints;\n\n\tfor (i = 0; i < volume->numplanes; i++)\n\t{\n\t\t//if totally on the back\n\t\tif (VS_ChopWinding(&w, &volume->planes[i], 0.01) == SIDE_BACK)\n\t\t\treturn;\n\t}\n\n\t// only one thread at a time may write to the lightmap of this surface\n\tMutexLock(test->mutex);\n\n\ttest->numvolumes++;\n\n\tif (ds->surfaceType == MST_PATCH)\n\t{\n\t\t// FIXME: reduce size and don't mark all as edge\n\t\tmin_y = ds->lightmapY + facet->y;\n\t\tmax_y = ds->lightmapY + facet->y + facet->height - 1;\n\t\tfor (y = min_y; y <= max_y; y++)\n\t\t{\n\t\t\tmin_x[y] = ds->lightmapX + facet->x;\n\t\t\tmax_x[y] = ds->lightmapX + facet->x + facet->width - 1;\n\t\t\tfor (x = min_x[y]; x <= max_x[y]; x++)\n\t\t\t{\n\t\t\t\tn = y * LIGHTMAP_SIZE + x;\n\t\t\t\tpolygonedges[n >> 3] |= 1 << (n & 7);\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tfor (i = 0; i < w.numpoints; i++)\n\t\t{\n\t\t\tfloat\ts, t;\n\n\t\t\tif (i >= MAX_POINTS_ON_WINDING)\n\t\t\t\t_printf(\"coords overflow\\n\");\n\t\t\tif (ds->surfaceType != MST_PATCH)\n\t\t\t{\n\t\t\t\tVectorSubtract(w.points[i], facet->mins, delta);\n\t\t\t\ts = DotProduct( delta, facet->lightmapMatrix[0] ) + ds->lightmapX + 0.5;\n\t\t\t\tt = DotProduct( delta, facet->lightmapMatrix[1] ) + ds->lightmapY + 0.5;\n\t\t\t\tif (s >= LIGHTMAP_SIZE)\n\t\t\t\t\ts = LIGHTMAP_SIZE - 0.5;\n\t\t\t\tif (s < 0)\n\t\t\t\t\ts = 0;\n\t\t\t\tif (t >= LIGHTMAP_SIZE)\n\t\t\t\t\tt = LIGHTMAP_SIZE - 0.5;\n\t\t\t\tif (t < 0)\n\t\t\t\t\tt = 0;\n\t\t\t\tcoords[i][0] = s;\n\t\t\t\tcoords[i][1] = t;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ts = DotProduct( w.points[i], facet->lightmapMatrix[0] ) + facet->lightmapMatrix[0][3];\n\t\t\t\tt = DotProduct( w.points[i], facet->lightmapMatrix[1] ) + facet->lightmapMatrix[1][3];\n\n\t\t\t\ts = s - floor( s );\n\t\t\t\tt = t - floor( t );\n\n\t\t\t\tcoords[i][0] = ds->lightmapX + s * LIGHTMAP_SIZE;// + 0.5;\n\t\t\t\tcoords[i][1] = ds->lightmapY + t * LIGHTMAP_SIZE;// + 0.5;\n\n\t\t\t\tif (coords[i][0] >= LIGHTMAP_SIZE)\n\t\t\t\t\tcoords[i][0] -= LIGHTMAP_SIZE;\n\t\t\t\tif (coords[i][1] >= LIGHTMAP_SIZE)\n\t\t\t\t\tcoords[i][1] -= LIGHTMAP_SIZE;\n\t\t\t\tif (coords[i][0] < ds->lightmapX)\n\t\t\t\t\tcoords[i][0] = ds->lightmapX;\n\t\t\t\tif (coords[i][1] < ds->lightmapY)\n\t\t\t\t\tcoords[i][1] = ds->lightmapY;\n\t\t\t}\n\t\t\tx = coords[i][0];\n\t\t\ty = coords[i][1];\n\t\t\tif (x < ds->lightmapX || x >= LIGHTMAP_SIZE)\n\t\t\t\t_printf(\"VS_LightSurfaceWithVolume: x outside lightmap\\n\");\n\t\t\tif (y < ds->lightmapY || y >= LIGHTMAP_SIZE)\n\t\t\t\t_printf(\"VS_LightSurfaceWithVolume: y outside lightmap\\n\");\n\t\t}\n\t\tcoords[i][0] = coords[0][0];\n\t\tcoords[i][1] = coords[0][1];\n\n\t\t//\n\t\tmin_y = LIGHTMAP_SIZE;\n\t\tmax_y = 0;\n\t\tfor (i = 0; i < LIGHTMAP_SIZE; i++)\n\t\t{\n\t\t\tmin_x[i] = LIGHTMAP_SIZE;\n\t\t\tmax_x[i] = 0;\n\t\t}\n\t\tmemset(polygonedges, 0, sizeof(polygonedges));\n\t\t// scan convert the polygon onto the lightmap\n\t\t// for each edge it marks *every* lightmap pixel the edge goes through\n\t\t// so no brasenham and no scan conversion used for texture mapping but\n\t\t// more something like ray casting\n\t\t// this is necesary because we need all lightmap pixels totally or partly\n\t\t// inside the light volume. these lightmap pixels are only lit for the part\n\t\t// that they are inside the light volume.\n\t\tfor (i = 0; i < w.numpoints; i++)\n\t\t{\n\t\t\tfloat xf, yf, dx, dy, xstep, ystep, xfrac, yfrac;\n\t\t\tint xinc, yinc;\n\n\t\t\txf = coords[i][0];\n\t\t\tyf = coords[i][1];\n\t\t\tdx = coords[i+1][0] - xf;\n\t\t\tdy = coords[i+1][1] - yf;\n\t\t\t//\n\t\t\tx = (int) xf;\n\t\t\ty = (int) yf;\n\t\t\t//\n\t\t\tif (y < min_y)\n\t\t\t\tmin_y = y;\n\t\t\tif (y > max_y)\n\t\t\t\tmax_y = y;\n\t\t\t//\n\t\t\tif (fabs(dx) > fabs(dy))\n\t\t\t{\n\t\t\t\tif (dx > 0)\n\t\t\t\t{\n\t\t\t\t\t// y fraction at integer x below fractional x\n\t\t\t\t\tyfrac = yf + (floor(xf) - xf) * dy / dx;\n\t\t\t\t\txinc = 1;\n\t\t\t\t}\n\t\t\t\telse if (dx < 0)\n\t\t\t\t{\n\t\t\t\t\t// y fraction at integer x above fractional x\n\t\t\t\t\tyfrac = yf + (floor(xf) + 1 - xf) * dy / dx;\n\t\t\t\t\txinc = -1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tyfrac = yf;\n\t\t\t\t\txinc = 0;\n\t\t\t\t}\n\t\t\t\t// step in y direction per 1 unit in x direction\n\t\t\t\tif (dx)\n\t\t\t\t\tystep = dy / fabs(dx);\n\t\t\t\telse\n\t\t\t\t\tystep = 0;\n\t\t\t\twhile(1)\n\t\t\t\t{\n\t\t\t\t\tif (x < ds->lightmapX || x >= LIGHTMAP_SIZE)\n\t\t\t\t\t\t_printf(\"VS_LightSurfaceWithVolume: x outside lightmap\\n\");\n\t\t\t\t\tif (y < ds->lightmapY || y >= LIGHTMAP_SIZE)\n\t\t\t\t\t\t_printf(\"VS_LightSurfaceWithVolume: y outside lightmap\\n\");\n\t\t\t\t\t//\n\t\t\t\t\tn = y * LIGHTMAP_SIZE + x;\n\t\t\t\t\tpolygonedges[n >> 3] |= 1 << (n & 7);\n\t\t\t\t\tif (x < min_x[y])\n\t\t\t\t\t\tmin_x[y] = x;\n\t\t\t\t\tif (x > max_x[y])\n\t\t\t\t\t\tmax_x[y] = x;\n\t\t\t\t\tif (x == (int) coords[i+1][0])\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tyfrac += ystep;\n\t\t\t\t\tif (dy > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (yfrac > (float) y + 1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ty += 1;\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\tn = y * LIGHTMAP_SIZE + x;\n\t\t\t\t\t\t\tpolygonedges[n >> 3] |= 1 << (n & 7);\n\t\t\t\t\t\t\tif (x < min_x[y])\n\t\t\t\t\t\t\t\tmin_x[y] = x;\n\t\t\t\t\t\t\tif (x > max_x[y])\n\t\t\t\t\t\t\t\tmax_x[y] = x;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tif (yfrac < (float) y)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ty -= 1;\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\tn = y * LIGHTMAP_SIZE + x;\n\t\t\t\t\t\t\tpolygonedges[n >> 3] |= 1 << (n & 7);\n\t\t\t\t\t\t\tif (x < min_x[y])\n\t\t\t\t\t\t\t\tmin_x[y] = x;\n\t\t\t\t\t\t\tif (x > max_x[y])\n\t\t\t\t\t\t\t\tmax_x[y] = x;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tx += xinc;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (dy > 0)\n\t\t\t\t{\n\t\t\t\t\t//x fraction at integer y below fractional y\n\t\t\t\t\txfrac = xf + (floor(yf) - yf) * dx / dy;\n\t\t\t\t\tyinc = 1;\n\t\t\t\t}\n\t\t\t\telse if (dy < 0)\n\t\t\t\t{\n\t\t\t\t\t//x fraction at integer y above fractional y\n\t\t\t\t\txfrac = xf + (floor(yf) + 1 - yf) * dx / dy;\n\t\t\t\t\tyinc = -1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\txfrac = xf;\n\t\t\t\t\tyinc = 0;\n\t\t\t\t}\n\t\t\t\t// step in x direction per 1 unit in y direction\n\t\t\t\tif (dy)\n\t\t\t\t\txstep = dx / fabs(dy);\n\t\t\t\telse\n\t\t\t\t\txstep = 0;\n\t\t\t\twhile(1)\n\t\t\t\t{\n\t\t\t\t\tif (x < ds->lightmapX || x >= LIGHTMAP_SIZE)\n\t\t\t\t\t\t_printf(\"VS_LightSurfaceWithVolume: x outside lightmap\\n\");\n\t\t\t\t\tif (y < ds->lightmapY || y >= LIGHTMAP_SIZE)\n\t\t\t\t\t\t_printf(\"VS_LightSurfaceWithVolume: y outside lightmap\\n\");\n\t\t\t\t\t//\n\t\t\t\t\tn = y * LIGHTMAP_SIZE + x;\n\t\t\t\t\tpolygonedges[n >> 3] |= 1 << (n & 7);\n\t\t\t\t\tif (x < min_x[y])\n\t\t\t\t\t\tmin_x[y] = x;\n\t\t\t\t\tif (x > max_x[y])\n\t\t\t\t\t\tmax_x[y] = x;\n\t\t\t\t\tif (y == (int) coords[i+1][1])\n\t\t\t\t\t\tbreak;\n\t\t\t\t\txfrac += xstep;\n\t\t\t\t\tif (dx > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (xfrac > (float) x + 1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tx += 1;\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\tn = y * LIGHTMAP_SIZE + x;\n\t\t\t\t\t\t\tpolygonedges[n >> 3] |= 1 << (n & 7);\n\t\t\t\t\t\t\tif (x < min_x[y])\n\t\t\t\t\t\t\t\tmin_x[y] = x;\n\t\t\t\t\t\t\tif (x > max_x[y])\n\t\t\t\t\t\t\t\tmax_x[y] = x;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tif (xfrac < (float) x)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tx -= 1;\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\tn = y * LIGHTMAP_SIZE + x;\n\t\t\t\t\t\t\tpolygonedges[n >> 3] |= 1 << (n & 7);\n\t\t\t\t\t\t\tif (x < min_x[y])\n\t\t\t\t\t\t\t\tmin_x[y] = x;\n\t\t\t\t\t\t\tif (x > max_x[y])\n\t\t\t\t\t\t\t\tmax_x[y] = x;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\ty += yinc;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t// map light onto the lightmap\n\tfor (y = min_y; y <= max_y; y++)\n\t{\n\t\tfor (x = min_x[y]; x <= max_x[y]; x++)\n\t\t{\n\t\t\tif (ds->surfaceType == MST_PATCH)\n\t\t\t{\n\t\t\t\tmesh = test->detailMesh;\n\t\t\t\tVectorCopy( mesh->verts[(y-ds->lightmapY)*mesh->width+x-ds->lightmapX].xyz, base);\n\t\t\t\tVectorCopy( mesh->verts[(y-ds->lightmapY)*mesh->width+x-ds->lightmapX].normal, normal);\n\t\t\t\t//VectorCopy(facet->plane.normal, normal);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tVectorMA(ds->lightmapOrigin, (float) x - ds->lightmapX, ds->lightmapVecs[0], base);\n\t\t\t\tVectorMA(base, (float) y - ds->lightmapY, ds->lightmapVecs[1], base);\n\t\t\t\tVectorCopy(facet->plane.normal, normal);\n\t\t\t}\n\t\t\tif (light->type == LIGHT_POINTSPOT)\n\t\t\t{\n\t\t\t\tfloat\tdistByNormal;\n\t\t\t\tvec3_t\tpointAtDist;\n\t\t\t\tfloat\tradiusAtDist;\n\t\t\t\tfloat\tsampleRadius;\n\t\t\t\tvec3_t\tdistToSample;\n\t\t\t\tfloat\tconeScale;\n\n\t\t\t\tVectorSubtract( light->origin, base, dir );\n\n\t\t\t\tdistByNormal = -DotProduct( dir, light->normal );\n\t\t\t\tif ( distByNormal < 0 ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tVectorMA( light->origin, distByNormal, light->normal, pointAtDist );\n\t\t\t\tradiusAtDist = light->radiusByDist * distByNormal;\n\n\t\t\t\tVectorSubtract( base, pointAtDist, distToSample );\n\t\t\t\tsampleRadius = VectorLength( distToSample );\n\n\t\t\t\tif ( sampleRadius >= radiusAtDist ) {\n\t\t\t\t\tcontinue;\t\t// outside the cone\n\t\t\t\t}\n\t\t\t\tif ( sampleRadius <= radiusAtDist - 32 ) {\n\t\t\t\t\tconeScale = 1.0;\t// fully inside\n\t\t\t\t} else {\n\t\t\t\t\tconeScale = ( radiusAtDist - sampleRadius ) / 32.0;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tdist = VectorNormalize( dir, dir );\n\t\t\t\t// clamp the distance to prevent super hot spots\n\t\t\t\tif ( dist < 16 ) {\n\t\t\t\t\tdist = 16;\n\t\t\t\t}\n\t\t\t\tangle = DotProduct( normal, dir );\n\t\t\t\tif (angle > 1)\n\t\t\t\t\tangle = 1;\n\t\t\t\tif (angle > 0) {\n\t\t\t\t\tif ( light->atten_angletype == LAAT_QUADRATIC ) {\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t\tangle *= angle;\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t}\n\t\t\t\t\telse if ( light->atten_angletype == LAAT_DOUBLEQUADRATIC ) {\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t\tangle *= angle * angle;\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (light->atten_anglescale > 0) {\n\t\t\t\t\tangle /= light->atten_anglescale;\n\t\t\t\t\tif (angle > 1)\n\t\t\t\t\t\tangle = 1;\n\t\t\t\t}\n\t\t\t\tif (light->atten_distscale > 0) {\n\t\t\t\t\tdistscale = light->atten_distscale;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdistscale = 1;\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tif ( light->atten_disttype == LDAT_NOSCALE ) {\n\t\t\t\t\tadd = angle * coneScale;\n\t\t\t\t}\n\t\t\t\telse if ( light->atten_disttype == LDAT_LINEAR ) {\n\t\t\t\t\tadd = angle * light->photons * lightLinearScale * coneScale - dist * distscale;\n\t\t\t\t\tif ( add < 0 ) {\n\t\t\t\t\t\tadd = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tadd = light->photons / ( dist * dist * distscale) * angle * coneScale;\n\t\t\t\t}\n\t\t\t\tif (add <= 1.0)\n\t\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse if (light->type == LIGHT_POINTFAKESURFACE)\n\t\t\t{\n\t\t\t\t// calculate the contribution\n\t\t\t\tadd = PointToPolygonFormFactor( base, normal, &light->w );\n\t\t\t\tif ( add <= 0 ) {\n\t\t\t\t\tif ( light->twosided ) {\n\t\t\t\t\t\tadd = -add;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (light->type == LIGHT_SURFACEDIRECTED)\n\t\t\t{\n\t\t\t\t//VectorCopy(light->normal, dir);\n\t\t\t\t//VectorInverse(dir);\n\t\t\t\t// project the light map pixel origin onto the area light source plane\n\t\t\t\td = DotProduct(base, light->normal) - DotProduct(light->normal, light->w.points[0]);\n\t\t\t\tVectorMA(base, -d, light->normal, origin);\n\t\t\t\tVectorSubtract(origin, base, dir);\n\t\t\t\tdist = VectorNormalize(dir, dir);\n\t\t\t\tif ( dist < 16 ) {\n\t\t\t\t\tdist = 16;\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tangle = DotProduct( normal, dir );\n\t\t\t\tif (angle > 1)\n\t\t\t\t\tangle = 1;\n\t\t\t\tif (angle > 0) {\n\t\t\t\t\tif ( light->atten_angletype == LAAT_QUADRATIC ) {\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t\tangle *= angle;\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t}\n\t\t\t\t\telse if ( light->atten_angletype == LAAT_DOUBLEQUADRATIC ) {\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t\tangle *= angle * angle;\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (light->atten_anglescale > 0) {\n\t\t\t\t\tangle /= light->atten_anglescale;\n\t\t\t\t\tif (angle > 1)\n\t\t\t\t\t\tangle = 1;\n\t\t\t\t}\n\t\t\t\tif (light->atten_distscale > 0) {\n\t\t\t\t\tdistscale = light->atten_distscale;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdistscale = 1;\n\t\t\t\t}\n\t\t\t\tif ( light->atten_disttype == LDAT_NOSCALE ) {\n\t\t\t\t\tadd = angle;\n\t\t\t\t}\n\t\t\t\telse if ( light->atten_disttype == LDAT_LINEAR ) {\n\t\t\t\t\tadd = angle * light->photons * lightLinearScale - dist * distscale;\n\t\t\t\t\tif ( add < 0 ) {\n\t\t\t\t\t\tadd = 0;\n\t\t\t\t\t}\n\t\t\t\t} else { //default quadratic\n\t\t\t\t\tadd = light->photons / ( dist * dist * distscale) * angle;\n\t\t\t\t}\n\t\t\t\tif (add <= 0)\n\t\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse //normal radial point light\n\t\t\t{\n\t\t\t\tVectorSubtract(light->origin, base, dir);\n\t\t\t\tdist = VectorNormalize(dir, dir);\n\t\t\t\tif ( dist < 16 ) {\n\t\t\t\t\tdist = 16;\n\t\t\t\t}\n\t\t\t\tangle = DotProduct( normal, dir );\n\t\t\t\tif (angle > 1)\n\t\t\t\t\tangle = 1;\n\t\t\t\tif (angle > 0) {\n\t\t\t\t\tif ( light->atten_angletype == LAAT_QUADRATIC ) {\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t\tangle *= angle;\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t}\n\t\t\t\t\telse if ( light->atten_angletype == LAAT_DOUBLEQUADRATIC ) {\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t\tangle *= angle * angle;\n\t\t\t\t\t\tangle = 1 - angle;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (light->atten_anglescale > 0) {\n\t\t\t\t\tangle /= light->atten_anglescale;\n\t\t\t\t\tif (angle > 1)\n\t\t\t\t\t\tangle = 1;\n\t\t\t\t}\n\t\t\t\tif (light->atten_distscale > 0) {\n\t\t\t\t\tdistscale = light->atten_distscale;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdistscale = 1;\n\t\t\t\t}\n\t\t\t\tif ( light->atten_disttype == LDAT_NOSCALE ) {\n\t\t\t\t\tadd = angle;\n\t\t\t\t}\n\t\t\t\telse if ( light->atten_disttype == LDAT_LINEAR ) {\n\t\t\t\t\tadd = angle * light->photons * lightLinearScale - dist * distscale;\n\t\t\t\t\tif ( add < 0 ) {\n\t\t\t\t\t\tadd = 0;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tadd = light->photons / ( dist * dist * distscale) * angle;\n\t\t\t\t}\n\t\t\t\tif (add <= 1.0)\n\t\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t//\n\t\t\tk = (ds->lightmapNum * LIGHTMAP_HEIGHT + y) * LIGHTMAP_WIDTH + x;\n\t\t\t//if on one of the edges\n\t\t\tn = y * LIGHTMAP_SIZE + x;\n\t\t\tif ((polygonedges[n >> 3] & (1 << (n & 7)) ))\n\t\t\t{\n\t\t\t\t// multiply 'add' by the relative area being lit of the total visible lightmap pixel area\n\t\t\t\t//\n\t\t\t\t// first create a winding for the lightmap pixel\n\t\t\t\tif (ds->surfaceType == MST_PATCH)\n\t\t\t\t{\n\t\t\t\t\tmesh = test->detailMesh;\n\t\t\t\t\tif (y-ds->lightmapY >= mesh->height-1)\n\t\t\t\t\t\t_printf(\"y outside mesh\\n\");\n\t\t\t\t\tif (x-ds->lightmapX >= mesh->width-1)\n\t\t\t\t\t\t_printf(\"x outside mesh\\n\");\n\t\t\t\t\tVectorCopy( mesh->verts[(y-ds->lightmapY)*mesh->width+x-ds->lightmapX].xyz, w.points[0]);\n\t\t\t\t\tVectorCopy( mesh->verts[(y+1-ds->lightmapY)*mesh->width+x-ds->lightmapX].xyz, w.points[1]);\n\t\t\t\t\tVectorCopy( mesh->verts[(y+1-ds->lightmapY)*mesh->width+x+1-ds->lightmapX].xyz, w.points[2]);\n\t\t\t\t\tVectorCopy( mesh->verts[(y-ds->lightmapY)*mesh->width+x+1-ds->lightmapX].xyz, w.points[3]);\n\t\t\t\t\tw.numpoints = 4;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT - ds->lightmapX, ds->lightmapVecs[0], w.points[0]);\n\t\t\t\t\tVectorMA(w.points[0], (float) y - LIGHTMAP_PIXELSHIFT - ds->lightmapY, ds->lightmapVecs[1], w.points[0]);\n\t\t\t\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT - ds->lightmapX, ds->lightmapVecs[0], w.points[1]);\n\t\t\t\t\tVectorMA(w.points[1], (float) y - LIGHTMAP_PIXELSHIFT + 1 - ds->lightmapY, ds->lightmapVecs[1], w.points[1]);\n\t\t\t\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT + 1 - ds->lightmapX, ds->lightmapVecs[0], w.points[2]);\n\t\t\t\t\tVectorMA(w.points[2], (float) y - LIGHTMAP_PIXELSHIFT + 1 - ds->lightmapY, ds->lightmapVecs[1], w.points[2]);\n\t\t\t\t\tVectorMA(ds->lightmapOrigin, (float) x - LIGHTMAP_PIXELSHIFT + 1 - ds->lightmapX, ds->lightmapVecs[0], w.points[3]);\n\t\t\t\t\tVectorMA(w.points[3], (float) y - LIGHTMAP_PIXELSHIFT - ds->lightmapY, ds->lightmapVecs[1], w.points[3]);\n\t\t\t\t\tw.numpoints = 4;\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\t// take the visible area of the lightmap pixel into account\n\t\t\t\t//\n\t\t\t\t//area = WindingArea(&w);\n\t\t\t\tarea = lightmappixelarea[k];\n\t\t\t\tif (area <= 0)\n\t\t\t\t\tcontinue;\n\t\t\t\t// chop the lightmap pixel winding with the light volume\n\t\t\t\tfor (i = 0; i < volume->numplanes; i++)\n\t\t\t\t{\n\t\t\t\t\t//if totally on the back\n\t\t\t\t\tif (VS_ChopWinding(&w, &volume->planes[i], 0) == SIDE_BACK)\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t// if the lightmap pixel is partly inside the light volume\n\t\t\t\tif (i >= volume->numplanes)\n\t\t\t\t{\n\t\t\t\t\tinsidearea = WindingArea(&w);\n\t\t\t\t\tif (insidearea <= 0)\n\t\t\t\t\t\ti = 0;\n\t\t\t\t\tadd = add * insidearea / area;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t//DebugNet_DrawWinding(&w, 2);\n\t\t\t\t\tcontinue;\t// this shouldn't happen\n\t\t\t\t}\n\t\t\t}\n\t\t\t// get the light filter from all the translucent surfaces the light volume went through\n\t\t\tVS_GetFilter(light, volume, base, filter);\n\t\t\t//\n\t\t\tcolor = &lightFloats[k*3];\n\t\t\tcolor[0] += add * light->color[0] * filter[0];\n\t\t\tcolor[1] += add * light->color[1] * filter[1];\n\t\t\tcolor[2] += add * light->color[2] * filter[2];\n\t\t}\n\t}\n\n\tMutexUnlock(test->mutex);\n}\n\n#endif\n\n/*\n=============\nVS_SplitLightVolume\n=============\n*/\nint VS_SplitLightVolume(lightvolume_t *volume, lightvolume_t *back, plane_t *split, float epsilon)\n{\n\tlightvolume_t f, b;\n\tvec_t\tdists[128];\n\tint\t\tsides[128];\n\tint\t\tcounts[3];\n\tvec_t\tdot;\n\tint\t\ti, j;\n\tvec_t\t*p1, *p2;\n\tvec3_t\tmid;\n\n\tcounts[0] = counts[1] = counts[2] = 0;\n\n\t// determine sides for each point\n\tfor (i = 0; i < volume->numplanes; i++)\n\t{\n\t\tdot = DotProduct (volume->points[i], split->normal);\n\t\tdot -= split->dist;\n\t\tdists[i] = dot;\n\t\tif (dot > epsilon)\n\t\t\tsides[i] = SIDE_FRONT;\n\t\telse if (dot < -epsilon)\n\t\t\tsides[i] = SIDE_BACK;\n\t\telse\n\t\t{\n\t\t\tsides[i] = SIDE_ON;\n\t\t}\n\t\tcounts[sides[i]]++;\n\t}\n\n\tif (!counts[1])\n\t\treturn 0;\t\t// completely on front side\n\t\n\tif (!counts[0])\n\t\treturn 1;\t\t// completely on back side\n\n\tsides[i] = sides[0];\n\tdists[i] = dists[0];\n\t\n\tf.numplanes = 0;\n\tb.numplanes = 0;\n\n\tfor (i = 0; i < volume->numplanes; i++)\n\t{\n\t\tp1 = volume->points[i];\n\n\t\tif (f.numplanes >= MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\t_printf(\"WARNING: VS_SplitLightVolume -> MAX_POINTS_ON_FIXED_WINDING overflowed\\n\");\n\t\t\treturn 0;\t\t// can't chop -- fall back to original\n\t\t}\n\t\tif (b.numplanes >= MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\t_printf(\"WARNING: VS_SplitLightVolume -> MAX_POINTS_ON_FIXED_WINDING overflowed\\n\");\n\t\t\treturn 0;\t\t// can't chop -- fall back to original\n\t\t}\n\n\t\tif (sides[i] == SIDE_ON)\n\t\t{\n\t\t\tVectorCopy(p1, f.points[f.numplanes]);\n\t\t\tVectorCopy(p1, b.points[b.numplanes]);\n\t\t\tif (sides[i+1] == SIDE_BACK)\n\t\t\t{\n\t\t\t\tf.planes[f.numplanes] = *split;\n\t\t\t\tb.planes[b.numplanes] = volume->planes[i];\n\t\t\t}\n\t\t\telse if (sides[i+1] == SIDE_FRONT)\n\t\t\t{\n\t\t\t\tf.planes[f.numplanes] = volume->planes[i];\n\t\t\t\tb.planes[b.numplanes] = *split;\n\t\t\t\tVectorInverse(b.planes[b.numplanes].normal);\n\t\t\t\tb.planes[b.numplanes].dist = -b.planes[b.numplanes].dist;\n\t\t\t}\n\t\t\telse //this shouldn't happen\n\t\t\t{\n\t\t\t\tf.planes[f.numplanes] = *split;\n\t\t\t\tb.planes[b.numplanes] = *split;\n\t\t\t\tVectorInverse(b.planes[b.numplanes].normal);\n\t\t\t\tb.planes[b.numplanes].dist = -b.planes[b.numplanes].dist;\n\t\t\t}\n\t\t\tf.numplanes++;\n\t\t\tb.numplanes++;\n\t\t\tcontinue;\n\t\t}\n\t\n\t\tif (sides[i] == SIDE_FRONT)\n\t\t{\n\t\t\tVectorCopy (p1, f.points[f.numplanes]);\n\t\t\tf.planes[f.numplanes] = volume->planes[i];\n\t\t\tf.numplanes++;\n\t\t}\n\t\tif (sides[i] == SIDE_BACK)\n\t\t{\n\t\t\tVectorCopy (p1, b.points[b.numplanes]);\n\t\t\tb.planes[b.numplanes] = volume->planes[i];\n\t\t\tb.numplanes++;\n\t\t}\n\t\t\n\t\tif (sides[i+1] == SIDE_ON || sides[i+1] == sides[i])\n\t\t\tcontinue;\n\t\t\t\n\t\tif (f.numplanes >= MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\t_printf(\"WARNING: VS_SplitLightVolume -> MAX_POINTS_ON_FIXED_WINDING overflowed\\n\");\n\t\t\treturn 0;\t\t// can't chop -- fall back to original\n\t\t}\n\t\tif (b.numplanes >= MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\t_printf(\"WARNING: VS_SplitLightVolume -> MAX_POINTS_ON_FIXED_WINDING overflowed\\n\");\n\t\t\treturn 0;\t\t// can't chop -- fall back to original\n\t\t}\n\n\t\t// generate a split point\n\t\tp2 = volume->points[(i+1)%volume->numplanes];\n\t\t\n\t\tdot = dists[i] / (dists[i]-dists[i+1]);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\t// avoid round off error when possible\n\t\t\tif (split->normal[j] == 1)\n\t\t\t\tmid[j] = split->dist;\n\t\t\telse if (split->normal[j] == -1)\n\t\t\t\tmid[j] = -split->dist;\n\t\t\telse\n\t\t\t\tmid[j] = p1[j] + dot*(p2[j]-p1[j]);\n\t\t}\n\n\t\tVectorCopy (mid, f.points[f.numplanes]);\n\t\tVectorCopy(mid, b.points[b.numplanes]);\n\t\tif (sides[i+1] == SIDE_BACK)\n\t\t{\n\t\t\tf.planes[f.numplanes] = *split;\n\t\t\tb.planes[b.numplanes] = volume->planes[i];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tf.planes[f.numplanes] = volume->planes[i];\n\t\t\tb.planes[b.numplanes] = *split;\n\t\t\tVectorInverse(b.planes[b.numplanes].normal);\n\t\t\tb.planes[b.numplanes].dist = -b.planes[b.numplanes].dist;\n\t\t}\n\t\tf.numplanes++;\n\t\tb.numplanes++;\n\t}\n\tmemcpy(volume->points, f.points, sizeof(vec3_t) * f.numplanes);\n\tmemcpy(volume->planes, f.planes, sizeof(plane_t) * f.numplanes);\n\tvolume->numplanes = f.numplanes;\n\tmemcpy(back->points, b.points, sizeof(vec3_t) * b.numplanes);\n\tmemcpy(back->planes, b.planes, sizeof(plane_t) * b.numplanes);\n\tback->numplanes = b.numplanes;\n\n\treturn 2;\n}\n\n/*\n=============\nVS_PlaneForEdgeToWinding\n=============\n*/\nvoid VS_PlaneForEdgeToWinding(vec3_t p1, vec3_t p2, winding_t *w, int windingonfront, plane_t *plane)\n{\n\tint i, j;\n\tfloat length, d;\n\tvec3_t v1, v2;\n\n\tVectorSubtract(p2, p1, v1);\n\tfor (i = 0; i < w->numpoints; i++)\n\t{\n\t\tVectorSubtract (w->points[i], p1, v2);\n\n\t\tplane->normal[0] = v1[1]*v2[2] - v1[2]*v2[1];\n\t\tplane->normal[1] = v1[2]*v2[0] - v1[0]*v2[2];\n\t\tplane->normal[2] = v1[0]*v2[1] - v1[1]*v2[0];\n\t\t\t\n\t\t// if points don't make a valid plane, skip it\n\t\tlength = plane->normal[0] * plane->normal[0]\n\t\t\t\t\t+ plane->normal[1] * plane->normal[1]\n\t\t\t\t\t+ plane->normal[2] * plane->normal[2];\n\t\t\t\n\t\tif (length < ON_EPSILON)\n\t\t\tcontinue;\n\n\t\tlength = 1/sqrt(length);\n\t\t\t\n\t\tplane->normal[0] *= length;\n\t\tplane->normal[1] *= length;\n\t\tplane->normal[2] *= length;\n\n\t\tplane->dist = DotProduct (w->points[i], plane->normal);\n\t\t//\n\t\tfor (j = 0; j < w->numpoints; j++)\n\t\t{\n\t\t\tif (j == i)\n\t\t\t\tcontinue;\n\t\t\td = DotProduct(w->points[j], plane->normal) - plane->dist;\n\t\t\tif (windingonfront)\n\t\t\t{\n\t\t\t\tif (d < -ON_EPSILON)\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (d > ON_EPSILON)\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (j >= w->numpoints)\n\t\t\treturn;\n\t}\n}\n\n/*\n=============\nVS_R_CastLightAtSurface\n=============\n*/\nvoid VS_R_FloodLight(vsound_t *light, lightvolume_t *volume, int cluster, int firstportal);\n\nvoid VS_R_CastLightAtSurface(vsound_t *light, lightvolume_t *volume)\n{\n\tlsurfaceTest_t *test;\n\tint i, n;\n\n\t// light the surface with this volume\n\tVS_LightSurfaceWithVolume(volume->surfaceNum, volume->facetNum, light, volume);\n\t//\n\ttest = lsurfaceTest[ volume->surfaceNum ];\n\t// if this is not a translucent surface\n\tif ( !(test->shader->surfaceFlags & SURF_ALPHASHADOW) && !(test->shader->contents & CONTENTS_TRANSLUCENT))\n\t\treturn;\n\t//\n\tif (volume->numtransFacets >= MAX_TRANSLUCENTFACETS)\n\t\tError(\"a light valume went through more than %d translucent facets\", MAX_TRANSLUCENTFACETS);\n\t//add this translucent surface to the list\n\tvolume->transSurfaces[volume->numtransFacets] = volume->surfaceNum;\n\tvolume->transFacets[volume->numtransFacets] = volume->facetNum;\n\tvolume->numtransFacets++;\n\t//clear the tested facets except the translucent ones\n\tmemset(volume->facetTested, 0, sizeof(volume->facetTested));\n\tfor (i = 0; i < volume->numtransFacets; i++)\n\t{\n\t\ttest = lsurfaceTest[ volume->transSurfaces[i] ];\n\t\tn = test->facets[volume->transFacets[i]].num;\n\t\tvolume->facetTested[n >> 3] |= 1 << (n & 7);\n\t}\n\tmemset(volume->clusterTested, 0, sizeof(volume->clusterTested));\n\tvolume->endplane = volume->farplane;\n\tvolume->surfaceNum = -1;\n\tvolume->facetNum = 0;\n\tVS_R_FloodLight(light, volume, volume->cluster, 0);\n\tif (volume->surfaceNum >= 0)\n\t{\n\t\tVS_R_CastLightAtSurface(light, volume);\n\t}\n}\n\n/*\n=============\nVS_R_SplitLightVolume\n=============\n*/\nstatic int numvolumes = 0;\n\nint VS_R_SplitLightVolume(vsound_t *light, lightvolume_t *volume, plane_t *split, int cluster, int firstportal)\n{\n\tlightvolume_t back;\n\tint res;\n\n\t//\n\tres = VS_SplitLightVolume(volume, &back, split, 0.1);\n\t// if the volume was split\n\tif (res == 2)\n\t{\n\t\tmemcpy(back.clusterTested, volume->clusterTested, sizeof(back.clusterTested));\n\t\tmemcpy(back.facetTested, volume->facetTested, sizeof(back.facetTested));\n\t\tback.num = numvolumes++;\n\t\tback.endplane = volume->endplane;\n\t\tback.surfaceNum = volume->surfaceNum;\n\t\tback.facetNum = volume->facetNum;\n\t\tback.type = volume->type;\n\t\tback.cluster = volume->cluster;\n\t\tback.farplane = volume->farplane;\n\t\tif (volume->numtransFacets > 0)\n\t\t{\n\t\t\tmemcpy(back.transFacets, volume->transFacets, sizeof(back.transFacets));\n\t\t\tmemcpy(back.transSurfaces, volume->transSurfaces, sizeof(back.transSurfaces));\n\t\t}\n\t\tback.numtransFacets = volume->numtransFacets;\n\t\t//\n\t\t// flood the volume at the back of the split plane\n\t\tVS_R_FloodLight(light, &back, cluster, firstportal);\n\t\t// if the back volume hit a surface\n\t\tif (back.surfaceNum >= 0)\n\t\t{\n\t\t\tVS_R_CastLightAtSurface(light, &back);\n\t\t}\n\t}\n\treturn res;\n}\n\n/*\n=============\nVS_R_FloodLight\n=============\n*/\nvoid VS_R_FloodLight(vsound_t *light, lightvolume_t *volume, int cluster, int firstportal)\n{\n\tint i, j, k, res, surfaceNum, backfaceculled, testculled;\n\tfloat d;\n\twinding_t winding, tmpwinding;\n\tlleaf_t *leaf;\n\tlportal_t *p;\n\tlsurfaceTest_t *test;\n\tlFacet_t *facet;\n\tvec3_t dir1, dir2;\n\tplane_t plane;\n\n\t//\tDebugNet_RemoveAllPolys();\n\t//\tVS_DrawLightVolume(light, volume);\n\n\t// if the first portal is not zero then we've checked all occluders in this leaf already\n\tif (firstportal == 0)\n\t{\n\t\t// check all potential occluders in this leaf\n\t\tfor (i = 0; i < leafs[cluster].numSurfaces; i++)\n\t\t{\n\t\t\tsurfaceNum = clustersurfaces[leafs[cluster].firstSurface + i];\n\t\t\t//\n\t\t\ttest = lsurfaceTest[ surfaceNum ];\n\t\t\tif ( !test )\n\t\t\t\tcontinue;\n\t\t\t//\n\t\t\ttestculled = qfalse;\n\t\t\t// use surface as an occluder\n\t\t\tfor (j = 0; j < test->numFacets; j++)\n\t\t\t{\n\t\t\t\t// use each facet as an occluder\n\t\t\t\tfacet = &test->facets[j];\n\t\t\t\t//\n\t\t\t\t//\tmemcpy(winding.points, facet->points, sizeof(vec3_t) * facet->numpoints);\n\t\t\t\t//\twinding.numpoints = facet->numpoints;\n\t\t\t\t//\tDebugNet_DrawWinding(&winding, 5);\n\t\t\t\t//\n\t\t\t\t// if the facet was tested already\n\t\t\t\tif ( volume->facetTested[facet->num >> 3] & (1 << (facet->num & 7)) )\n\t\t\t\t\tcontinue;\n\t\t\t\tvolume->facetTested[facet->num >> 3] |= 1 << (facet->num & 7);\n\t\t\t\t// backface culling for planar surfaces\n\t\t\t\tbackfaceculled = qfalse;\n\t\t\t\tif (!test->patch && !test->trisoup)\n\t\t\t\t{\n\t\t\t\t\tif (volume->type == VOLUME_NORMAL)\n\t\t\t\t\t{\n\t\t\t\t\t\t// facet backface culling\n\t\t\t\t\t\td = DotProduct(light->origin, facet->plane.normal) - facet->plane.dist;\n\t\t\t\t\t\tif (d < 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// NOTE: this doesn't work too great because of sometimes very bad tesselation\n\t\t\t\t\t\t\t//\t\tof surfaces that are supposed to be flat\n\t\t\t\t\t\t\t// FIXME: to work around this problem we should make sure that all facets\n\t\t\t\t\t\t\t//\t\tcreated from planar surfaces use the lightmapVecs normal vector\n\t\t\t\t\t\t\t/*\n\t\t\t\t\t\t\tif ( !test->shader->twoSided )\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t// skip all other facets of this surface as well because they are in the same plane\n\t\t\t\t\t\t\t\tfor (k = 0; k < test->numFacets; k++)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tfacet = &test->facets[k];\n\t\t\t\t\t\t\t\t\tvolume->facetTested[facet->num >> 3] |= 1 << (facet->num & 7);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}*/\n\t\t\t\t\t\t\tbackfaceculled = qtrue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t// FIXME: if all light source winding points are at the back of the facet\n\t\t\t\t\t\t//\t\t\tplane then backfaceculled = qtrue\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse // backface culling per facet for patches and triangle soups\n\t\t\t\t{\n\t\t\t\t\tif (volume->type == VOLUME_NORMAL)\n\t\t\t\t\t{\n\t\t\t\t\t\t// facet backface culling\n\t\t\t\t\t\td = DotProduct(light->origin, facet->plane.normal) - facet->plane.dist;\n\t\t\t\t\t\tif (d < 0)\n\t\t\t\t\t\t\tbackfaceculled = qtrue;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t// FIXME: if all light source winding points are at the back of the facet\n\t\t\t\t\t\t//\t\t\tplane then backfaceculled = qtrue\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t/* chopping does this already\n\t\t\t\t// check if this facet is totally or partly in front of the volume end plane\n\t\t\t\tfor (k = 0; k < facet->numpoints; k++)\n\t\t\t\t{\n\t\t\t\t\td = DotProduct(volume->endplane.normal, facet->points[k]) - volume->endplane.dist;\n\t\t\t\t\tif (d > ON_EPSILON)\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t// if this facet is outside the light volume\n\t\t\t\tif (k >= facet->numpoints)\n\t\t\t\t\tcontinue;\n\t\t\t\t*/\n\t\t\t\t//\n\t\t\t\tif (backfaceculled)\n\t\t\t\t{\n\t\t\t\t\t// if the facet is not two sided\n\t\t\t\t\tif ( !nobackfaceculling && !test->shader->twoSided )\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t// flip the winding\n\t\t\t\t\tfor (k = 0; k < facet->numpoints; k++)\n\t\t\t\t\t\tVectorCopy(facet->points[k], winding.points[facet->numpoints - k - 1]);\n\t\t\t\t\twinding.numpoints = facet->numpoints;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tmemcpy(winding.points, facet->points, sizeof(vec3_t) * facet->numpoints);\n\t\t\t\t\twinding.numpoints = facet->numpoints;\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tif (!testculled)\n\t\t\t\t{\n\t\t\t\t\ttestculled = qtrue;\n\t\t\t\t\t// fast check if the surface sphere is totally behind the volume end plane\n\t\t\t\t\td = DotProduct(volume->endplane.normal, test->origin) - volume->endplane.dist;\n\t\t\t\t\tif (d < -test->radius)\n\t\t\t\t\t{\n\t\t\t\t\t\tfor (k = 0; k < test->numFacets; k++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfacet = &test->facets[k];\n\t\t\t\t\t\t\tvolume->facetTested[facet->num >> 3] |= 1 << (facet->num & 7);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tfor (k = 0; k < volume->numplanes; k++)\n\t\t\t\t\t{\n\t\t\t\t\t\td = DotProduct(volume->planes[k].normal, test->origin) - volume->planes[k].dist;\n\t\t\t\t\t\tif (d < - test->radius)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfor (k = 0; k < test->numFacets; k++)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfacet = &test->facets[k];\n\t\t\t\t\t\t\t\tvolume->facetTested[facet->num >> 3] |= 1 << (facet->num & 7);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (k < volume->numplanes)\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t//NOTE: we have to chop the facet winding with the volume end plane because\n\t\t\t\t//\t\tthe faces in Q3 are not stitched together nicely\n\t\t\t\tres = VS_ChopWinding(&winding, &volume->endplane, 0.01);\n\t\t\t\t// if the facet is on or at the back of the volume end plane\n\t\t\t\tif (res == SIDE_BACK || res == SIDE_ON)\n\t\t\t\t\tcontinue;\n\t\t\t\t// check if the facet winding is totally or partly inside the light volume\n\t\t\t\tmemcpy(&tmpwinding, &winding, sizeof(winding_t));\n\t\t\t\tfor (k = 0; k < volume->numplanes; k++)\n\t\t\t\t{\n\t\t\t\t\tres = VS_ChopWinding(&tmpwinding, &volume->planes[k], 0.01);\n\t\t\t\t\tif (res == SIDE_BACK || res == SIDE_ON)\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t// if no part of the light volume is occluded by this facet\n\t\t\t\tif (k < volume->numplanes)\n\t\t\t\t\tcontinue;\n\t\t\t\t//\n\t\t\t\tfor (k = 0; k < winding.numpoints; k++)\n\t\t\t\t{\n\t\t\t\t\tif (volume->type == VOLUME_DIRECTED)\n\t\t\t\t\t{\n\t\t\t\t\t\tVectorSubtract(winding.points[(k+1) % winding.numpoints], winding.points[k], dir1);\n\t\t\t\t\t\tCrossProduct(light->normal, dir1, plane.normal);\n\t\t\t\t\t\tVectorNormalize(plane.normal, plane.normal);\n\t\t\t\t\t\tplane.dist = DotProduct(plane.normal, winding.points[k]);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tVectorSubtract(winding.points[(k+1) % winding.numpoints], winding.points[k], dir1);\n\t\t\t\t\t\tVectorSubtract(light->origin, winding.points[k], dir2);\n\t\t\t\t\t\tCrossProduct(dir1, dir2, plane.normal);\n\t\t\t\t\t\tVectorNormalize(plane.normal, plane.normal);\n\t\t\t\t\t\tplane.dist = DotProduct(plane.normal, winding.points[k]);\n\t\t\t\t\t}\n\t\t\t\t\tres = VS_R_SplitLightVolume(light, volume, &plane, cluster, 0);\n\t\t\t\t\tif (res == 1)\n\t\t\t\t\t\tbreak; //the facet wasn't really inside the volume\n\t\t\t\t}\n\t\t\t\tif (k >= winding.numpoints)\n\t\t\t\t{\n\t\t\t\t\tvolume->endplane = facet->plane;\n\t\t\t\t\tif (backfaceculled)\n\t\t\t\t\t{\n\t\t\t\t\t\tVectorInverse(volume->endplane.normal);\n\t\t\t\t\t\tvolume->endplane.dist = -volume->endplane.dist;\n\t\t\t\t\t}\n\t\t\t\t\tvolume->surfaceNum = surfaceNum;\n\t\t\t\t\tvolume->facetNum = j;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t// we've tested all occluders in this cluster\n\tvolume->clusterTested[cluster >> 3] |= 1 << (cluster & 7);\n\t// flood light through the portals of the current leaf\n\tleaf = &leafs[cluster];\n\tfor (i = firstportal; i < leaf->numportals; i++)\n\t{\n\t\tp = leaf->portals[i];\n\t\t//\n\t\t//\tmemcpy(&winding, p->winding, sizeof(winding_t));\n\t\t//\tDebugNet_DrawWinding(&winding, 5);\n\t\t// if already flooded into the cluster this portal leads to\n\t\tif ( volume->clusterTested[p->leaf >> 3] & (1 << (p->leaf & 7)) )\n\t\t\tcontinue;\n\t\t//\n\t\tif (volume->type == VOLUME_NORMAL)\n\t\t{\n\t\t\t// portal backface culling\n\t\t\td = DotProduct(light->origin, p->plane.normal) - p->plane.dist;\n\t\t\tif (d > 0) // portal plane normal points into neighbour cluster\n\t\t\t\tcontinue;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// FIXME: if all light source winding points are at the back of this portal\n\t\t\t//\t\t\tplane then there's no need to flood through\n\t\t}\n\t\t// check if this portal is totally or partly in front of the volume end plane\n\t\t// fast check with portal sphere\n\t\td = DotProduct(volume->endplane.normal, p->origin) - volume->endplane.dist;\n\t\tif (d < -p->radius)\n\t\t\tcontinue;\n\t\tfor (j = 0; j < p->winding->numpoints; j++)\n\t\t{\n\t\t\td = DotProduct(volume->endplane.normal, p->winding->points[j]) - volume->endplane.dist;\n\t\t\tif (d > -0.01)\n\t\t\t\tbreak;\n\t\t}\n\t\t// if this portal is totally behind the light volume end plane\n\t\tif (j >= p->winding->numpoints)\n\t\t\tcontinue;\n\t\t//distance from point light to portal\n\t\td = DotProduct(p->plane.normal, light->origin) - p->plane.dist;\n\t\t// only check if a point light is Not *on* the portal\n\t\tif (volume->type != VOLUME_NORMAL || fabs(d) > 0.1)\n\t\t{\n\t\t\t// check if the portal is partly or totally inside the light volume\n\t\t\tmemcpy(&winding, p->winding, sizeof(winding_t));\n\t\t\tfor (j = 0; j < volume->numplanes; j++)\n\t\t\t{\n\t\t\t\tres = VS_ChopWinding(&winding, &volume->planes[j], 0.01);\n\t\t\t\tif (res == SIDE_BACK || res == SIDE_ON)\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// if the light volume does not go through this portal at all\n\t\t\tif (j < volume->numplanes)\n\t\t\t\tcontinue;\n\t\t}\n\t\t// chop the light volume with the portal\n\t\tfor (k = 0; k < p->winding->numpoints; k++)\n\t\t{\n\t\t\tif (volume->type == VOLUME_DIRECTED)\n\t\t\t{\n\t\t\t\tVectorSubtract(p->winding->points[(k+1) % p->winding->numpoints], p->winding->points[k], dir1);\n\t\t\t\tCrossProduct(light->normal, dir1, plane.normal);\n\t\t\t\tVectorNormalize(plane.normal, plane.normal);\n\t\t\t\tplane.dist = DotProduct(plane.normal, p->winding->points[k]);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tVectorSubtract(p->winding->points[(k+1) % p->winding->numpoints], p->winding->points[k], dir1);\n\t\t\t\tVectorSubtract(light->origin, p->winding->points[k], dir2);\n\t\t\t\tCrossProduct(dir1, dir2, plane.normal);\n\t\t\t\tVectorNormalize(plane.normal, plane.normal);\n\t\t\t\tplane.dist = DotProduct(plane.normal, p->winding->points[k]);\n\t\t\t}\n\t\t\tres = VS_R_SplitLightVolume(light, volume, &plane, cluster, i+1);\n\t\t\tif (res == 1)\n\t\t\t\tbreak; //volume didn't really go through the portal\n\t\t}\n\t\t// if the light volume went through the portal\n\t\tif (k >= p->winding->numpoints)\n\t\t{\n\t\t\t// flood through the portal\n\t\t\tVS_R_FloodLight(light, volume, p->leaf, 0);\n\t\t}\n\t}\n}\n\n/*\n=============\nVS_R_FloodAreaSpotLight\n=============\n*/\nvoid VS_FloodAreaSpotLight(vsound_t *light, winding_t *w, int leafnum)\n{\n}\n\n/*\n=============\nVS_R_SubdivideAreaSpotLight\n=============\n*/\nvoid VS_R_SubdivideAreaSpotLight(vsound_t *light, int nodenum, winding_t *w)\n{\n\tint leafnum, res;\n\tdnode_t *node;\n\tdplane_t *plane;\n\twinding_t back;\n\tplane_t split;\n\n\twhile(nodenum >= 0)\n\t{\n\t\tnode = &dnodes[nodenum];\n\t\tplane = &dplanes[node->planeNum];\n\n\t\tVectorCopy(plane->normal, split.normal);\n\t\tsplit.dist = plane->dist;\n\t\tres = VS_SplitWinding (w, &back, &split, 0.1);\n\n\t\tif (res == SIDE_FRONT)\n\t\t{\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t\telse if (res == SIDE_BACK)\n\t\t{\n\t\t\tnodenum = node->children[1];\n\t\t}\n\t\telse if (res == SIDE_ON)\n\t\t{\n\t\t\tmemcpy(&back, w, sizeof(winding_t));\n\t\t\tVS_R_SubdivideAreaSpotLight(light, node->children[1], &back);\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVS_R_SubdivideAreaSpotLight(light, node->children[1], &back);\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t}\n\tleafnum = -nodenum - 1;\n\tif (dleafs[leafnum].cluster != -1)\n\t{\n\t\tVS_FloodAreaSpotLight(light, w, leafnum);\n\t}\n}\n\n/*\n=============\nVS_R_FloodRadialAreaLight\n=============\n*/\nvoid VS_FloodRadialAreaLight(vsound_t *light, winding_t *w, int leafnum)\n{\n}\n\n/*\n=============\nVS_R_SubdivideRadialAreaLight\n=============\n*/\nvoid VS_R_SubdivideRadialAreaLight(vsound_t *light, int nodenum, winding_t *w)\n{\n\tint leafnum, res;\n\tdnode_t *node;\n\tdplane_t *plane;\n\twinding_t back;\n\tplane_t split;\n\n\twhile(nodenum >= 0)\n\t{\n\t\tnode = &dnodes[nodenum];\n\t\tplane = &dplanes[node->planeNum];\n\n\t\tVectorCopy(plane->normal, split.normal);\n\t\tsplit.dist = plane->dist;\n\t\tres = VS_SplitWinding (w, &back, &split, 0.1);\n\n\t\tif (res == SIDE_FRONT)\n\t\t{\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t\telse if (res == SIDE_BACK)\n\t\t{\n\t\t\tnodenum = node->children[1];\n\t\t}\n\t\telse if (res == SIDE_ON)\n\t\t{\n\t\t\tmemcpy(&back, w, sizeof(winding_t));\n\t\t\tVS_R_SubdivideRadialAreaLight(light, node->children[1], &back);\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVS_R_SubdivideRadialAreaLight(light, node->children[1], &back);\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t}\n\tleafnum = -nodenum - 1;\n\tif (dleafs[leafnum].cluster != -1)\n\t{\n\t\tVS_FloodRadialAreaLight(light, w, leafnum);\n\t}\n}\n\n/*\n=============\nVS_R_FloodDirectedLight\n=============\n*/\nvoid VS_FloodDirectedLight(vsound_t *light, winding_t *w, int leafnum)\n{\n\tint i;\n\tfloat dist;\n\tlightvolume_t volume;\n\tvec3_t dir;\n\n\tif (light->atten_disttype == LDAT_NOSCALE)\n\t{\n\t\t// light travels without decrease in intensity over distance\n\t\tdist = MAX_WORLD_COORD;\n\t}\n\telse\n\t{\n\t\tif ( light->atten_disttype == LDAT_LINEAR )\n\t\t\tdist = light->photons * lightLinearScale;\n\t\telse\n\t\t\tdist = sqrt(light->photons);\n\t}\n\n\tmemset(&volume, 0, sizeof(lightvolume_t));\n\tfor (i = 0; i < w->numpoints; i++)\n\t{\n\t\tVectorMA(w->points[i], dist, light->normal, volume.points[i]);\n\t\tVectorSubtract(w->points[(i+1)%w->numpoints], w->points[i], dir);\n\t\tCrossProduct(light->normal, dir, volume.planes[i].normal);\n\t\tVectorNormalize(volume.planes[i].normal, volume.planes[i].normal);\n\t\tvolume.planes[i].dist = DotProduct(volume.planes[i].normal, w->points[i]);\n\t}\n\tvolume.numplanes = w->numpoints;\n\tVectorCopy(light->normal, volume.endplane.normal);\n\tVectorInverse(volume.endplane.normal);\n\tvolume.endplane.dist = DotProduct(volume.endplane.normal, volume.points[0]);\n\tvolume.farplane = volume.endplane;\n\tvolume.surfaceNum = -1;\n\tvolume.type = VOLUME_DIRECTED;\n\tvolume.cluster = dleafs[leafnum].cluster;\n\tVS_R_FloodLight(light, &volume, volume.cluster, 0);\n\tif (volume.surfaceNum >= 0)\n\t{\n\t\tVS_R_CastLightAtSurface(light, &volume);\n\t}\n}\n\n/*\n=============\nVS_R_SubdivideDirectedAreaLight\n=============\n*/\nvoid VS_R_SubdivideDirectedAreaLight(vsound_t *light, int nodenum, winding_t *w)\n{\n\tint leafnum, res;\n\tdnode_t *node;\n\tdplane_t *plane;\n\twinding_t back;\n\tplane_t split;\n\n\twhile(nodenum >= 0)\n\t{\n\t\tnode = &dnodes[nodenum];\n\t\tplane = &dplanes[node->planeNum];\n\n\t\tVectorCopy(plane->normal, split.normal);\n\t\tsplit.dist = plane->dist;\n\t\tres = VS_SplitWinding (w, &back, &split, 0.1);\n\n\t\tif (res == SIDE_FRONT)\n\t\t{\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t\telse if (res == SIDE_BACK)\n\t\t{\n\t\t\tnodenum = node->children[1];\n\t\t}\n\t\telse if (res == SIDE_ON)\n\t\t{\n\t\t\tmemcpy(&back, w, sizeof(winding_t));\n\t\t\tVS_R_SubdivideDirectedAreaLight(light, node->children[1], &back);\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVS_R_SubdivideDirectedAreaLight(light, node->children[1], &back);\n\t\t\tnodenum = node->children[0];\n\t\t}\n\t}\n\tleafnum = -nodenum - 1;\n\tif (dleafs[leafnum].cluster != -1)\n\t{\n\t\tVS_FloodDirectedLight(light, w, leafnum);\n\t}\n}\n\n/*\n=============\nVS_FloodLight\n=============\n*/\nvoid VS_FloodLight(vsound_t *light)\n{\n\tlightvolume_t volume;\n\tdleaf_t *leaf;\n\tint leafnum, i, j, k, dir[2][4] = {{1, 1, -1, -1}, {1, -1, -1, 1}};\n\tfloat a, step, dist, radius, windingdist;\n\tvec3_t vec, r, p, temp;\n\twinding_t winding;\n\n\tswitch(light->type)\n\t{\n\t\tcase LIGHT_POINTRADIAL:\n\t\t{\n\t\t\t// source is a point\n\t\t\t// light radiates in all directions\n\t\t\t// creates sharp shadows\n\t\t\t//\n\t\t\t// create 6 volumes shining in the axis directions\n\t\t\t// what about: 4 tetrahedrons instead?\n\t\t\t//\n\t\t\tif ( light->atten_disttype == LDAT_LINEAR )\n\t\t\t\tdist = light->photons * lightLinearScale;\n\t\t\telse\n\t\t\t\tdist = sqrt(light->photons);\n\t\t\t//always put the winding at a large distance to avoid epsilon issues\n\t\t\twindingdist = MAX_WORLD_COORD;\n\t\t\tif (dist > windingdist)\n\t\t\t\twindingdist = dist;\n\t\t\t//\n\t\t\tleafnum = VS_LightLeafnum(light->origin);\n\t\t\tleaf = &dleafs[leafnum];\n\t\t\tif (leaf->cluster == -1)\n\t\t\t{\n\t\t\t\tlight->insolid = qtrue;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// for each axis\n\t\t\tfor (i = 0; i < 3; i++)\n\t\t\t{\n\t\t\t\t// for both directions on the axis\n\t\t\t\tfor (j = -1; j <= 1; j += 2)\n\t\t\t\t{\n\t\t\t\t\tmemset(&volume, 0, sizeof(lightvolume_t));\n\t\t\t\t\tvolume.numplanes = 0;\n\t\t\t\t\tfor (k = 0; k < 4; k ++)\n\t\t\t\t\t{\n\t\t\t\t\t\tvolume.points[volume.numplanes][i] = light->origin[i] + j * windingdist;\n\t\t\t\t\t\tvolume.points[volume.numplanes][(i+1)%3] = light->origin[(i+1)%3] + dir[0][k] * windingdist;\n\t\t\t\t\t\tvolume.points[volume.numplanes][(i+2)%3] = light->origin[(i+2)%3] + dir[1][k] * windingdist;\n\t\t\t\t\t\tvolume.numplanes++;\n\t\t\t\t\t}\n\t\t\t\t\tif (j >= 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tVectorCopy(volume.points[0], temp);\n\t\t\t\t\t\tVectorCopy(volume.points[2], volume.points[0]);\n\t\t\t\t\t\tVectorCopy(temp, volume.points[2]);\n\t\t\t\t\t}\n\t\t\t\t\tfor (k = 0; k < volume.numplanes; k++)\n\t\t\t\t\t{\n\t\t\t\t\t\tVS_PlaneFromPoints(&volume.planes[k], light->origin, volume.points[(k+1)%volume.numplanes], volume.points[k]);\n\t\t\t\t\t}\n\t\t\t\t\tVectorCopy(light->origin, temp);\n\t\t\t\t\ttemp[i] += (float) j * dist;\n\t\t\t\t\tVectorClear(volume.endplane.normal);\n\t\t\t\t\tvolume.endplane.normal[i] = -j;\n\t\t\t\t\tvolume.endplane.dist = DotProduct(volume.endplane.normal, temp); //DotProduct(volume.endplane.normal, volume.points[0]);\n\t\t\t\t\tvolume.farplane = volume.endplane;\n\t\t\t\t\tvolume.cluster = leaf->cluster;\n\t\t\t\t\tvolume.surfaceNum = -1;\n\t\t\t\t\tvolume.type = VOLUME_NORMAL;\n\t\t\t\t\t//\n\t\t\t\t\tmemset(volume.facetTested, 0, sizeof(volume.facetTested));\n\t\t\t\t\tmemset(volume.clusterTested, 0, sizeof(volume.clusterTested));\n\t\t\t\t\tVS_R_FloodLight(light, &volume, leaf->cluster, 0);\n\t\t\t\t\tif (volume.surfaceNum >= 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tVS_R_CastLightAtSurface(light, &volume);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase LIGHT_POINTSPOT:\n\t\t{\n\t\t\t// source is a point\n\t\t\t// light is targetted\n\t\t\t// creates sharp shadows\n\t\t\t//\n\t\t\t// what about using brushes to shape spot lights? that'd be pretty cool\n\t\t\t//\n\t\t\tif ( light->atten_disttype == LDAT_LINEAR )\n\t\t\t\tdist = light->photons * lightLinearScale;\n\t\t\telse\n\t\t\t\tdist = sqrt(light->photons);\n\t\t\tdist *= 2;\n\t\t\t//\n\t\t\twindingdist = 4096;\n\t\t\tif (dist > windingdist)\n\t\t\t\twindingdist = dist;\n\t\t\t//take 8 times the cone radius because the spotlight also lights outside the cone\n\t\t\tradius = 8 * windingdist * light->radiusByDist;\n\t\t\t//\n\t\t\tmemset(&volume, 0, sizeof(lightvolume_t));\n\t\t\tleafnum = VS_LightLeafnum(light->origin);\n\t\t\tleaf = &dleafs[leafnum];\n\t\t\tif (leaf->cluster == -1)\n\t\t\t{\n\t\t\t\tlight->insolid = qtrue;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t//\n\t\t\tVectorClear(vec);\n\t\t\tfor (i = 0; i < 3; i++)\n\t\t\t{\n\t\t\t\tif (light->normal[i] > -0.9 && light->normal[i] < 0.9)\n\t\t\t\t{\n\t\t\t\t\tvec[i] = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tCrossProduct(light->normal, vec, r);\n\t\t\tVectorScale(r, radius, p);\n\t\t\tvolume.numplanes = 0;\n\t\t\tstep = 45;\n\t\t\tfor (a = step / 2; a < 360 + step / 2; a += step)\n\t\t\t{\n\t\t\t\tRotatePointAroundVector(volume.points[volume.numplanes], light->normal, p, a);\n\t\t\t\tVectorAdd(light->origin, volume.points[volume.numplanes], volume.points[volume.numplanes]);\n\t\t\t\tVectorMA(volume.points[volume.numplanes], windingdist, light->normal, volume.points[volume.numplanes]);\n\t\t\t\tvolume.numplanes++;\n\t\t\t}\n\t\t\tfor (i = 0; i < volume.numplanes; i++)\n\t\t\t{\n\t\t\t\tVS_PlaneFromPoints(&volume.planes[i], light->origin, volume.points[(i+1)%volume.numplanes], volume.points[i]);\n\t\t\t}\n\t\t\tVectorMA(light->origin, dist, light->normal, temp);\n\t\t\tVectorCopy(light->normal, volume.endplane.normal);\n\t\t\tVectorInverse(volume.endplane.normal);\n\t\t\tvolume.endplane.dist = DotProduct(volume.endplane.normal, temp);//DotProduct(volume.endplane.normal, volume.points[0]);\n\t\t\tvolume.farplane = volume.endplane;\n\t\t\tvolume.cluster = leaf->cluster;\n\t\t\tvolume.surfaceNum = -1;\n\t\t\tvolume.type = VOLUME_NORMAL;\n\t\t\t//\n\t\t\tmemset(volume.facetTested, 0, sizeof(volume.facetTested));\n\t\t\tmemset(volume.clusterTested, 0, sizeof(volume.clusterTested));\n\t\t\tVS_R_FloodLight(light, &volume, leaf->cluster, 0);\n\t\t\tif (volume.surfaceNum >= 0)\n\t\t\t{\n\t\t\t\tVS_R_CastLightAtSurface(light, &volume);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase LIGHT_POINTFAKESURFACE:\n\t\t{\n\t\t\tfloat value;\n\t\t\tint n, axis;\n\t\t\tvec3_t v, vecs[2];\n\n\t\t\tif ( light->atten_disttype == LDAT_LINEAR )\n\t\t\t\tdist = light->photons * lightLinearScale;\n\t\t\telse\n\t\t\t\tdist = sqrt(light->photons);\n\t\t\t//always put the winding at a large distance to avoid epsilon issues\n\t\t\twindingdist = 4096;\n\t\t\tif (dist > windingdist)\n\t\t\t\twindingdist = dist;\n\t\t\t//\n\t\t\tVectorMA(light->origin, 0.1, light->normal, light->origin);\n\t\t\t//\n\t\t\tleafnum = VS_LightLeafnum(light->origin);\n\t\t\tleaf = &dleafs[leafnum];\n\t\t\tif (leaf->cluster == -1)\n\t\t\t{\n\t\t\t\tlight->insolid = qtrue;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tvalue = 0;\n\t\t\tfor (i = 0; i < 3; i++)\n\t\t\t{\n\t\t\t\tif (fabs(light->normal[i]) > value)\n\t\t\t\t{\n\t\t\t\t\tvalue = fabs(light->normal[i]);\n\t\t\t\t\taxis = i;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (i = 0; i < 2; i++)\n\t\t\t{\n\t\t\t\tVectorClear(v);\n\t\t\t\tv[(axis + 1 + i) % 3] = 1;\n\t\t\t\tCrossProduct(light->normal, v, vecs[i]);\n\t\t\t}\n\t\t\t//cast 4 volumes at the front of the surface\n\t\t\tfor (i = -1; i <= 1; i += 2)\n\t\t\t{\n\t\t\t\tfor (j = -1; j <= 1; j += 2)\n\t\t\t\t{\n\t\t\t\t\tfor (n = 0; n < 2; n++)\n\t\t\t\t\t{\n\t\t\t\t\t\tmemset(&volume, 0, sizeof(lightvolume_t));\n\t\t\t\t\t\tvolume.numplanes = 3;\n\t\t\t\t\t\tVectorMA(light->origin, i * windingdist, vecs[0], volume.points[(i == j) == n]);\n\t\t\t\t\t\tVectorMA(light->origin, j * windingdist, vecs[1], volume.points[(i != j) == n]);\n\t\t\t\t\t\tVectorMA(light->origin, windingdist, light->normal, volume.points[2]);\n\t\t\t\t\t\tfor (k = 0; k < volume.numplanes; k++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tVS_PlaneFromPoints(&volume.planes[k], light->origin, volume.points[(k+1)%volume.numplanes], volume.points[k]);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tVS_PlaneFromPoints(&volume.endplane, volume.points[0], volume.points[1], volume.points[2]);\n\t\t\t\t\t\tVectorMA(light->origin, dist, light->normal, temp);\n\t\t\t\t\t\tvolume.endplane.dist = DotProduct(volume.endplane.normal, temp);\n\t\t\t\t\t\tif (DotProduct(light->origin, volume.endplane.normal) - volume.endplane.dist > 0)\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tvolume.farplane = volume.endplane;\n\t\t\t\t\tvolume.cluster = leaf->cluster;\n\t\t\t\t\tvolume.surfaceNum = -1;\n\t\t\t\t\tvolume.type = VOLUME_NORMAL;\n\t\t\t\t\t//\n\t\t\t\t\tmemset(volume.facetTested, 0, sizeof(volume.facetTested));\n\t\t\t\t\tmemset(volume.clusterTested, 0, sizeof(volume.clusterTested));\n\n\t\t\t\t\tVS_R_FloodLight(light, &volume, leaf->cluster, 0);\n\t\t\t\t\tif (volume.surfaceNum >= 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tVS_R_CastLightAtSurface(light, &volume);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase LIGHT_SURFACEDIRECTED:\n\t\t{\n\t\t\t// source is an area defined by a winding\n\t\t\t// the light is unidirectional\n\t\t\t// creates sharp shadows\n\t\t\t// for instance sun light or laser light\n\t\t\t//\n\t\t\tmemcpy(&winding, &light->w, sizeof(winding_t));\n\t\t\tVS_R_SubdivideDirectedAreaLight(light, 0, &winding);\n\t\t\tbreak;\n\t\t}\n\t\tcase LIGHT_SURFACERADIAL:\n\t\t{\n\t\t\t// source is an area defined by a winding\n\t\t\t// the light radiates in all directions at the front of the winding plane\n\t\t\t//\n\t\t\tmemcpy(&winding, &light->w, sizeof(winding_t));\n\t\t\tVS_R_SubdivideRadialAreaLight(light, 0, &winding);\n\t\t\tbreak;\n\t\t}\n\t\tcase LIGHT_SURFACESPOT:\n\t\t{\n\t\t\t// source is an area defined by a winding\n\t\t\t// light is targetted but not unidirectional\n\t\t\t//\n\t\t\tmemcpy(&winding, &light->w, sizeof(winding_t));\n\t\t\tVS_R_SubdivideAreaSpotLight(light, 0, &winding);\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/*\n=============\nVS_FloodLightThread\n=============\n*/\nvoid VS_FloodLightThread(int num)\n{\n\tVS_FloodLight(vsounds[num]);\n}\n\n/*\n=============\nVS_TestLightLeafs\n=============\n*/\nvoid VS_TestLightLeafs(void)\n{\n\tint leafnum, i;\n\tvsound_t *light;\n\tdleaf_t *leaf;\n\n\tfor (i = 0; i < numvsounds; i++)\n\t{\n\t\tlight = vsounds[i];\n\t\tif (light->type != LIGHT_POINTRADIAL &&\n\t\t\tlight->type != LIGHT_POINTSPOT)\n\t\t\tcontinue;\n\t\tleafnum = VS_LightLeafnum(light->origin);\n\t\tleaf = &dleafs[leafnum];\n\t\tif (leaf->cluster == -1)\n\t\t\tif (light->type == LIGHT_POINTRADIAL)\n\t\t\t\tqprintf(\"light in solid at %1.1f %1.1f %1.1f\\n\", light->origin[0], light->origin[1], light->origin[2]);\n\t\t\telse if (light->type == LIGHT_POINTSPOT)\n\t\t\t\tqprintf(\"spot light in solid at %1.1f %1.1f %1.1f\\n\", light->origin[0], light->origin[1], light->origin[2]);\n\t}\n}\n\n\n/*\n=============\nVS_DoForcedTraceLight\n=============\n*/\n// from light.c\nvoid TraceLtm( int num );\n\nvoid VS_DoForcedTraceLight(int num)\n{\n\tdsurface_t\t\t*ds;\n\tshaderInfo_t\t*si;\n\n\tds = &drawSurfaces[num];\n\n\tif ( ds->surfaceType == MST_TRIANGLE_SOUP )\n\t\treturn;\n\n\tif ( ds->lightmapNum < 0 )\n\t\treturn;\n\n\t// always light entity surfaces with the old light algorithm\n\tif ( !entitySurface[num] )\n\t{\n\t\tsi = ShaderInfoForShader( dshaders[ ds->shaderNum].shader );\n\n\t\tif (defaulttracelight)\n\t\t{\n\t\t\tif (si->forceVLight)\n\t\t\t\treturn;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (!si->forceTraceLight)\n\t\t\t\treturn;\n\t\t}\n\t}\n\n\tTraceLtm(num);\n}\n\n/*\n=============\nVS_DoForcedTraceLightSurfaces\n=============\n*/\nvoid VS_DoForcedTraceLightSurfaces(void)\n{\n\t_printf( \"forced trace light\\n\" );\n\tRunThreadsOnIndividual( numDrawSurfaces, qtrue, VS_DoForcedTraceLight );\n}\n\nfloat *oldLightFloats;\n\n/*\n=============\nVS_SurfaceRadiosity\n=============\n*/\nvoid VS_SurfaceRadiosity( int num ) {\n\tdsurface_t\t\t*ds;\n\tmesh_t\t\t\t*mesh;\n\tshaderInfo_t\t*si;\n\tlsurfaceTest_t *test;\n\tint x, y, k;\n\tvec3_t base, normal;\n\tfloat *color, area;\n\tvsound_t vsound;\n\n\tds = &drawSurfaces[num];\n\n\tif ( ds->lightmapNum < 0 ) {\n\t\treturn;\t\t// doesn't have a lightmap\n\t}\n\n\t// vertex-lit triangle model\n\tif ( ds->surfaceType == MST_TRIANGLE_SOUP ) {\n\t\treturn;\n\t}\n\n\tsi = ShaderInfoForShader( dshaders[ ds->shaderNum].shader );\n\ttest = lsurfaceTest[ num ];\n\n\tif (!test) {\n\t\treturn;\n\t}\n\n\tfor (x = 0; x < ds->lightmapWidth; x++) {\n\t\tfor (y = 0; y < ds->lightmapHeight; y++) {\n\t\t\t//\n\t\t\tk = ( ds->lightmapNum * LIGHTMAP_HEIGHT + ds->lightmapY + y) \n\t\t\t\t\t\t\t* LIGHTMAP_WIDTH + ds->lightmapX + x;\n\t\t\tarea = lightmappixelarea[k];\n\t\t\tif (area <= 0)\n\t\t\t\tcontinue;\n\t\t\t//\n\t\t\tif (ds->surfaceType == MST_PATCH)\n\t\t\t{\n\t\t\t\tmesh = test->detailMesh;\n\t\t\t\tVectorCopy( mesh->verts[y*mesh->width+x].xyz, base);\n\t\t\t\tVectorCopy( mesh->verts[y*mesh->width+x].normal, normal);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tVectorMA(ds->lightmapOrigin, (float) x, ds->lightmapVecs[0], base);\n\t\t\t\tVectorMA(base, (float) y, ds->lightmapVecs[1], base);\n\t\t\t\tVectorCopy(test->facets[0].plane.normal, normal);\n\t\t\t}\n\t\t\t// create ligth from base\n\t\t\tmemset(&vsound, 0, sizeof(vsound_t));\n\t\t\tcolor = &oldLightFloats[k*3];\n\t\t\t// a few units away from the surface\n\t\t\tVectorMA(base, 5, normal, vsound.origin);\n\t\t\tColorNormalize(color, vsound.color);\n\t\t\t// ok this is crap\n\t\t\tvsound.photons = VectorLength(color) * 0.05 * lightPointScale / (area * radiosity_scale);\n\t\t\t// what about using a front facing light only ?\n\t\t\tvsound.type = LIGHT_POINTRADIAL;\n\t\t\t// flood the light from this lightmap pixel\n\t\t\tVS_FloodLight(&vsound);\n\t\t\t// only one thread at a time may write to the lightmap of this surface\n\t\t\tMutexLock(test->mutex);\n\t\t\t// don't light the lightmap pixel itself\n\t\t\tlightFloats[k*3] = oldLightFloats[k*3];\n\t\t\tlightFloats[k*3+1] = oldLightFloats[k*3+1];\n\t\t\tlightFloats[k*3+2] = oldLightFloats[k*3+2];\n\t\t\t//\n\t\t\tMutexUnlock(test->mutex);\n\t\t}\n\t}\n}\n\n/*\n=============\nVS_Radiosity\n\nthis aint working real well but it's fun to play with.\n=============\n*/\nvoid VS_Radiosity(void) {\n\n\toldLightFloats = lightFloats;\n\tlightFloats = (float *) malloc(numLightBytes * sizeof(float));\n\tmemcpy(lightFloats, oldLightFloats, numLightBytes * sizeof(float));\n\t_printf(\"%7i surfaces\\n\", numDrawSurfaces);\n\tRunThreadsOnIndividual( numDrawSurfaces, qtrue, VS_SurfaceRadiosity );\n\tfree(oldLightFloats);\n}\n\n/*\n=============\nVS_LightWorld\n=============\n*/\nvoid VS_LightWorld(void)\n{\n\tint i, numcastedvolumes, numvsoundsinsolid;\n\tfloat f;\n\n\t// find the optional world ambient\n\tGetVectorForKey( &entities[0], \"_color\", lightAmbientColor );\n\tf = FloatForKey( &entities[0], \"ambient\" );\n\tVectorScale( lightAmbientColor, f, lightAmbientColor );\n\t/*\n\t_printf(\"\\r%6d lights out of %d\", 0, numvsounds);\n\tfor (i = 0; i < numvsounds; i++)\n\t{\n\t\t_printf(\"\\r%6d\", i);\n\t\tVS_FloodLight(vsounds[i]);\n\t}\n\t_printf(\"\\r%6d lights out of %d\\n\", i, numvsounds);\n\t*/\n\t_printf(\"%7i lights\\n\", numvsounds);\n\tRunThreadsOnIndividual( numvsounds, qtrue, VS_FloodLightThread );\n\n\tnumcastedvolumes = 0;\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ ) {\n\t\tif (lsurfaceTest[i])\n\t\t\tnumcastedvolumes += lsurfaceTest[i]->numvolumes;\n\t}\n\t_printf(\"%7i light volumes casted\\n\", numcastedvolumes);\n\tnumvsoundsinsolid = 0;\n\tfor (i = 0; i < numvsounds; i++)\n\t{\n\t\tif (vsounds[i]->insolid)\n\t\t\tnumvsoundsinsolid++;\n\t}\n\t_printf(\"%7i lights in solid\\n\", numvsoundsinsolid);\n\t//\n\tradiosity_scale = 1;\n\tfor (i = 0; i < radiosity; i++) {\n\t\tVS_Radiosity();\n\t\tradiosity_scale <<= 1;\n\t}\n\t//\n\tVS_StoreLightmap();\n\t// redo surfaces with the old light algorithm when needed\n\tVS_DoForcedTraceLightSurfaces();\n}\n\n/*\n=============\nVS_CreateEntitySpeakers\n=============\n*/\nentity_t *FindTargetEntity( const char *target );\n\nvoid VS_CreateEntitySpeakers (void)\n{\n\tint\t\ti, c_entityLights;\n\tvsound_t\t*dl;\n\tentity_t\t*e, *e2;\n\tconst char\t*name;\n\tconst char\t*target;\n\tvec3_t\tdest;\n\tconst char\t*_color;\n\tfloat\tintensity;\n\tint\t\tspawnflags;\n\n\t//\n\tc_entityLights = 0;\n\t_printf(\"Creating entity lights...\\n\");\n\t//\n\tfor ( i = 0 ; i < num_entities ; i++ ) {\n\t\te = &entities[i];\n\t\tname = ValueForKey (e, \"classname\");\n\t\tif (strncmp (name, \"speaker\", 7))\n\t\t\tcontinue;\n\n\t\tdl = malloc(sizeof(*dl));\n\t\tmemset (dl, 0, sizeof(*dl));\n\n\t\tspawnflags = FloatForKey (e, \"spawnflags\");\n\t\tif ( spawnflags & 1 ) {\n\t\t\tdl->atten_disttype = LDAT_LINEAR;\n\t\t}\n\t\tif ( spawnflags & 2 ) {\n\t\t\tdl->atten_disttype = LDAT_NOSCALE;\n\t\t}\n\t\tif ( spawnflags & 4 ) {\n\t\t\tdl->atten_angletype = LAAT_QUADRATIC;\n\t\t}\n\t\tif ( spawnflags & 8 ) {\n\t\t\tdl->atten_angletype = LAAT_DOUBLEQUADRATIC;\n\t\t}\n\n\t\tdl->atten_distscale = FloatForKey(e, \"atten_distscale\");\n\t\tdl->atten_anglescale = FloatForKey(e, \"atten_anglescale\");\n\n\t\tGetVectorForKey (e, \"origin\", dl->origin);\n\t\tdl->style = FloatForKey (e, \"_style\");\n\t\tif (!dl->style)\n\t\t\tdl->style = FloatForKey (e, \"style\");\n\t\tif (dl->style < 0)\n\t\t\tdl->style = 0;\n\n\t\tintensity = FloatForKey (e, \"light\");\n\t\tif (!intensity)\n\t\t\tintensity = FloatForKey (e, \"_light\");\n\t\tif (!intensity)\n\t\t\tintensity = 300;\n\t\t_color = ValueForKey (e, \"_color\");\n\t\tif (_color && _color[0])\n\t\t{\n\t\t\tsscanf (_color, \"%f %f %f\", &dl->color[0],&dl->color[1],&dl->color[2]);\n\t\t\tColorNormalize (dl->color, dl->color);\n\t\t}\n\t\telse\n\t\t\tdl->color[0] = dl->color[1] = dl->color[2] = 1.0;\n\n\t\tintensity = intensity * lightPointScale;\n\t\tdl->photons = intensity;\n\n\t\tdl->type = LIGHT_POINTRADIAL;\n\n\t\t// lights with a target will be spotlights\n\t\ttarget = ValueForKey (e, \"target\");\n\n\t\tif ( target[0] ) {\n\t\t\tfloat\tradius;\n\t\t\tfloat\tdist;\n\n\t\t\te2 = FindTargetEntity (target);\n\t\t\tif (!e2) {\n\t\t\t\t_printf (\"WARNING: light at (%i %i %i) has missing target\\n\",\n\t\t\t\t(int)dl->origin[0], (int)dl->origin[1], (int)dl->origin[2]);\n\t\t\t} else {\n\t\t\t\tGetVectorForKey (e2, \"origin\", dest);\n\t\t\t\tVectorSubtract (dest, dl->origin, dl->normal);\n\t\t\t\tdist = VectorNormalize (dl->normal, dl->normal);\n\t\t\t\tradius = FloatForKey (e, \"radius\");\n\t\t\t\tif ( !radius ) {\n\t\t\t\t\tradius = 64;\n\t\t\t\t}\n\t\t\t\tif ( !dist ) {\n\t\t\t\t\tdist = 64;\n\t\t\t\t}\n\t\t\t\tdl->radiusByDist = (radius + 16) / dist;\n\t\t\t\tdl->type = LIGHT_POINTSPOT;\n\t\t\t}\n\t\t}\n\t\tvsounds[numvsounds++] = dl;\n\t\tc_entityLights++;\n\t}\n\t_printf(\"%7i entity lights\\n\", c_entityLights);\n}\n\n/*\n==================\nVS_SubdivideAreaLight\n==================\n*/\nvoid VS_SubdivideAreaLight( shaderInfo_t *ls, winding_t *w, vec3_t normal, \n\t\t\t\t\t\tfloat areaSubdivide, qboolean backsplash ) {\n\tfloat\t\t\tarea, value, intensity;\n\tvsound_t\t\t\t*dl, *dl2;\n\tvec3_t\t\t\tmins, maxs;\n\tint\t\t\t\taxis;\n\twinding_t\t\t*front, *back;\n\tvec3_t\t\t\tplaneNormal;\n\tfloat\t\t\tplaneDist;\n\n\tif ( !w ) {\n\t\treturn;\n\t}\n\n\tWindingBounds( w, mins, maxs );\n\n\t// check for subdivision\n\tfor ( axis = 0 ; axis < 3 ; axis++ ) {\n\t\tif ( maxs[axis] - mins[axis] > areaSubdivide ) {\n\t\t\tVectorClear( planeNormal );\n\t\t\tplaneNormal[axis] = 1;\n\t\t\tplaneDist = ( maxs[axis] + mins[axis] ) * 0.5;\n\t\t\tClipWindingEpsilon ( w, planeNormal, planeDist, ON_EPSILON, &front, &back );\n\t\t\tVS_SubdivideAreaLight( ls, front, normal, areaSubdivide, qfalse );\n\t\t\tVS_SubdivideAreaLight( ls, back, normal, areaSubdivide, qfalse );\n\t\t\tFreeWinding( w );\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// create a light from this\n\tarea = WindingArea (w);\n\tif ( area <= 0 || area > 20000000 ) {\n\t\treturn;\n\t}\n\n\tdl = malloc(sizeof(*dl));\n\tmemset (dl, 0, sizeof(*dl));\n\tdl->type = LIGHT_POINTFAKESURFACE;\n\n\tWindingCenter( w, dl->origin );\n\tmemcpy(dl->w.points, w->points, sizeof(vec3_t) * w->numpoints);\n\tdl->w.numpoints = w->numpoints;\n\tVectorCopy ( normal, dl->normal);\n\tVectorCopy ( normal, dl->plane);\n\tdl->plane[3] = DotProduct( dl->origin, normal );\n\n\tvalue = ls->value;\n\tintensity = value * area * lightAreaScale;\n\tVectorAdd( dl->origin, dl->normal, dl->origin );\n\n\tVectorCopy( ls->color, dl->color );\n\n\tdl->photons = intensity;\n\n\t// emitColor is irrespective of the area\n\tVectorScale( ls->color, value*lightFormFactorValueScale*lightAreaScale, dl->emitColor );\n\t//\n\tVectorCopy(dl->emitColor, dl->color);\n\n\tdl->si = ls;\n\n\tif ( ls->contents & CONTENTS_FOG ) {\n\t\tdl->twosided = qtrue;\n\t}\n\n\tvsounds[numvsounds++] = dl;\n\n\t// optionally create a point backsplash light\n\tif ( backsplash && ls->backsplashFraction > 0 ) {\n\n\t\tdl2 = malloc(sizeof(*dl));\n\t\tmemset (dl2, 0, sizeof(*dl2));\n\t\tdl2->type = LIGHT_POINTRADIAL;\n\n\t\tVectorMA( dl->origin, ls->backsplashDistance, normal, dl2->origin );\n\n\t\tVectorCopy( ls->color, dl2->color );\n\n\t\tdl2->photons = dl->photons * ls->backsplashFraction;\n\t\tdl2->si = ls;\n\n\t\tvsounds[numvsounds++] = dl2;\n\t}\n}\n\n/*\n==================\nVS_CreateFakeSurfaceLights\n==================\n*/\nvoid VS_CreateFakeSurfaceLights( void ) {\n\tint\t\t\t\ti, j, side;\n\tdsurface_t\t\t*ds;\n\tshaderInfo_t\t*ls;\n\twinding_t\t\t*w;\n\tlFacet_t\t\t*f;\n\tvsound_t\t\t\t*dl;\n\tvec3_t\t\t\torigin;\n\tdrawVert_t\t\t*dv;\n\tint\t\t\t\tc_surfaceLights;\n\tfloat\t\t\tlightSubdivide;\n\tvec3_t\t\t\tnormal;\n\n\n\tc_surfaceLights = 0;\n\t_printf (\"Creating surface lights...\\n\");\n\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ ) {\n\t\t// see if this surface is light emiting\n\t\tds = &drawSurfaces[i];\n\n\t\tls = ShaderInfoForShader( dshaders[ ds->shaderNum].shader );\n\t\tif ( ls->value == 0 ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// determine how much we need to chop up the surface\n\t\tif ( ls->lightSubdivide ) {\n\t\t\tlightSubdivide = ls->lightSubdivide;\n\t\t} else {\n\t\t\tlightSubdivide = lightDefaultSubdivide;\n\t\t}\n\n\t\tc_surfaceLights++;\n\n\t\t// an autosprite shader will become\n\t\t// a point light instead of an area light\n\t\tif ( ls->autosprite ) {\n\t\t\t// autosprite geometry should only have four vertexes\n\t\t\tif ( lsurfaceTest[i] ) {\n\t\t\t\t// curve or misc_model\n\t\t\t\tf = lsurfaceTest[i]->facets;\n\t\t\t\tif ( lsurfaceTest[i]->numFacets != 1 || f->numpoints != 4 ) {\n\t\t\t\t\t_printf( \"WARNING: surface at (%i %i %i) has autosprite shader but isn't a quad\\n\",\n\t\t\t\t\t\t(int)f->points[0], (int)f->points[1], (int)f->points[2] );\n\t\t\t\t}\n\t\t\t\tVectorAdd( f->points[0], f->points[1], origin );\n\t\t\t\tVectorAdd( f->points[2], origin, origin );\n\t\t\t\tVectorAdd( f->points[3], origin, origin );\n\t\t\t\tVectorScale( origin, 0.25, origin );\n\t\t\t} else {\n\t\t\t\t// normal polygon\n\t\t\t\tdv = &drawVerts[ ds->firstVert ];\n\t\t\t\tif ( ds->numVerts != 4 ) {\n\t\t\t\t\t_printf( \"WARNING: surface at (%i %i %i) has autosprite shader but %i verts\\n\",\n\t\t\t\t\t\t(int)dv->xyz[0], (int)dv->xyz[1], (int)dv->xyz[2] );\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tVectorAdd( dv[0].xyz, dv[1].xyz, origin );\n\t\t\t\tVectorAdd( dv[2].xyz, origin, origin );\n\t\t\t\tVectorAdd( dv[3].xyz, origin, origin );\n\t\t\t\tVectorScale( origin, 0.25, origin );\n\t\t\t}\n\n\t\t\tdl = malloc(sizeof(*dl));\n\t\t\tmemset (dl, 0, sizeof(*dl));\n\t\t\tVectorCopy( origin, dl->origin );\n\t\t\tVectorCopy( ls->color, dl->color );\n\t\t\tdl->photons = ls->value * lightPointScale;\n\t\t\tdl->type = LIGHT_POINTRADIAL;\n\t\t\tvsounds[numvsounds++] = dl;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// possibly create for both sides of the polygon\n\t\tfor ( side = 0 ; side <= ls->twoSided ; side++ ) {\n\t\t\t// create area lights\n\t\t\tif ( lsurfaceTest[i] ) {\n\t\t\t\t// curve or misc_model\n\t\t\t\tfor ( j = 0 ; j < lsurfaceTest[i]->numFacets ; j++ ) {\n\t\t\t\t\tf = lsurfaceTest[i]->facets + j;\n\t\t\t\t\tw = AllocWinding( f->numpoints );\n\t\t\t\t\tw->numpoints = f->numpoints;\n\t\t\t\t\tmemcpy( w->points, f->points, f->numpoints * 12 );\n\n\t\t\t\t\tVectorCopy( f->plane.normal, normal );\n\t\t\t\t\tif ( side ) {\n\t\t\t\t\t\twinding_t\t*t;\n\n\t\t\t\t\t\tt = w;\n\t\t\t\t\t\tw = ReverseWinding( t );\n\t\t\t\t\t\tFreeWinding( t );\n\t\t\t\t\t\tVectorSubtract( vec3_origin, normal, normal );\n\t\t\t\t\t}\n\t\t\t\t\tVS_SubdivideAreaLight( ls, w, normal, lightSubdivide, qtrue );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// normal polygon\n\n\t\t\t\tw = AllocWinding( ds->numVerts );\n\t\t\t\tw->numpoints = ds->numVerts;\n\t\t\t\tfor ( j = 0 ; j < ds->numVerts ; j++ ) {\n\t\t\t\t\tVectorCopy( drawVerts[ds->firstVert+j].xyz, w->points[j] );\n\t\t\t\t}\n\t\t\t\tVectorCopy( ds->lightmapVecs[2], normal );\n\t\t\t\tif ( side ) {\n\t\t\t\t\twinding_t\t*t;\n\n\t\t\t\t\tt = w;\n\t\t\t\t\tw = ReverseWinding( t );\n\t\t\t\t\tFreeWinding( t );\n\t\t\t\t\tVectorSubtract( vec3_origin, normal, normal );\n\t\t\t\t}\n\t\t\t\tVS_SubdivideAreaLight( ls, w, normal, lightSubdivide, qtrue );\n\t\t\t}\n\t\t}\n\t}\n\n\t_printf( \"%7i light emitting surfaces\\n\", c_surfaceLights );\n}\n\n\n/*\n==================\nVS_WindingForBrushSide\n==================\n*/\nwinding_t *VS_WindingForBrushSide(dbrush_t *brush, int side, winding_t *w)\n{\n\tint i, res;\n\twinding_t *tmpw;\n\tplane_t plane;\n\n\tVectorCopy(dplanes[ dbrushsides[ brush->firstSide + side ].planeNum ].normal, plane.normal);\n\tVectorInverse(plane.normal);\n\tplane.dist = -dplanes[ dbrushsides[ brush->firstSide + side ].planeNum ].dist;\n\ttmpw = BaseWindingForPlane( plane.normal, plane.dist );\n\tmemcpy(w->points, tmpw->points, sizeof(vec3_t) * tmpw->numpoints);\n\tw->numpoints = tmpw->numpoints;\n\n\tfor (i = 0; i < brush->numSides; i++)\n\t{\n\t\tif (i == side)\n\t\t\tcontinue;\n\t\tVectorCopy(dplanes[ dbrushsides[ brush->firstSide + i ].planeNum ].normal, plane.normal);\n\t\tVectorInverse(plane.normal);\n\t\tplane.dist = -dplanes[ dbrushsides[ brush->firstSide + i ].planeNum ].dist;\n\t\tres = VS_ChopWinding(w, &plane, 0.1);\n\t\tif (res == SIDE_BACK)\n\t\t\treturn NULL;\n\t}\n\treturn w;\n}\n\n/*\n==================\nVS_CreateSkyLights\n==================\n*/\nvoid VS_CreateSkyLights(void)\n{\n\tint\t\t\t\ti, j, c_skyLights;\n\tdbrush_t\t\t*b;\n\tshaderInfo_t\t*si;\n\tdbrushside_t\t*s;\n\tvsound_t\t\t*dl;\n\tvec3_t sunColor, sunDir = { 0.45, 0.3, 0.9 };\n\tfloat d;\n\n\tVectorNormalize(sunDir, sunDir);\n\tVectorInverse(sunDir);\n\n\tc_skyLights = 0;\n\t_printf(\"Creating sky lights...\\n\");\n\t// find the sky shader\n\tfor ( i = 0 ; i < numDrawSurfaces ; i++ ) {\n\t\tsi = ShaderInfoForShader( dshaders[ drawSurfaces[i].shaderNum ].shader );\n\t\tif ( si->surfaceFlags & SURF_SKY ) {\n\t\t\tVectorCopy( si->sunLight, sunColor );\n\t\t\tVectorCopy( si->sunDirection, sunDir );\n\t\t\tVectorInverse(sunDir);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// find the brushes\n\tfor ( i = 0 ; i < numbrushes ; i++ ) {\n\t\tb = &dbrushes[i];\n\t\tfor ( j = 0 ; j < b->numSides ; j++ ) {\n\t\t\ts = &dbrushsides[ b->firstSide + j ];\n\t\t\tif ( dshaders[ s->shaderNum ].surfaceFlags & SURF_SKY ) {\n\t\t\t\t//if this surface doesn't face in the same direction as the sun\n\t\t\t\td = DotProduct(dplanes[ s->planeNum ].normal, sunDir);\n\t\t\t\tif (d <= 0)\n\t\t\t\t\tcontinue;\n\t\t\t\t//\n\t\t\t\tdl = malloc(sizeof(*dl));\n\t\t\t\tmemset (dl, 0, sizeof(*dl));\n\t\t\t\tVectorCopy(sunColor, dl->color);\n\t\t\t\tVectorCopy(sunDir, dl->normal);\n\t\t\t\tVectorCopy(dplanes[ s->planeNum ].normal, dl->plane);\n\t\t\t\tdl->plane[3] = dplanes[ s->planeNum ].dist;\n\t\t\t\tdl->type = LIGHT_SURFACEDIRECTED;\n\t\t\t\tdl->atten_disttype = LDAT_NOSCALE;\n\t\t\t\tVS_WindingForBrushSide(b, j, &dl->w);\n//\t\t\t\tDebugNet_DrawWinding(&dl->w, 2);\n\t\t\t\t//\n\t\t\t\tvsounds[numvsounds++] = dl;\n\t\t\t\tc_skyLights++;\n\t\t\t}\n\t\t}\n\t}\n\t_printf(\"%7i light emitting sky surfaces\\n\", c_skyLights);\n}\n\n/*\n==================\nVS_SetPortalSphere\n==================\n*/\nvoid VS_SetPortalSphere (lportal_t *p)\n{\n\tint\t\ti;\n\tvec3_t\ttotal, dist;\n\twinding_t\t*w;\n\tfloat\tr, bestr;\n\n\tw = p->winding;\n\tVectorCopy (vec3_origin, total);\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tVectorAdd (total, w->points[i], total);\n\t}\n\t\n\tfor (i=0 ; i<3 ; i++)\n\t\ttotal[i] /= w->numpoints;\n\n\tbestr = 0;\t\t\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tVectorSubtract (w->points[i], total, dist);\n\t\tr = VectorLength (dist);\n\t\tif (r > bestr)\n\t\t\tbestr = r;\n\t}\n\tVectorCopy (total, p->origin);\n\tp->radius = bestr;\n}\n\n/*\n==================\nVS_PlaneFromWinding\n==================\n*/\nvoid VS_PlaneFromWinding (winding_t *w, plane_t *plane)\n{\n\tvec3_t\t\tv1, v2;\n\n\t//calc plane\n\tVectorSubtract (w->points[2], w->points[1], v1);\n\tVectorSubtract (w->points[0], w->points[1], v2);\n\tCrossProduct (v2, v1, plane->normal);\n\tVectorNormalize (plane->normal, plane->normal);\n\tplane->dist = DotProduct (w->points[0], plane->normal);\n}\n\n/*\n==================\nVS_AllocWinding\n==================\n*/\nwinding_t *VS_AllocWinding (int points)\n{\n\twinding_t\t*w;\n\tint\t\t\tsize;\n\t\n\tif (points > MAX_POINTS_ON_WINDING)\n\t\tError (\"NewWinding: %i points\", points);\n\t\n\tsize = (int)((winding_t *)0)->points[points];\n\tw = malloc (size);\n\tmemset (w, 0, size);\n\t\n\treturn w;\n}\n\n/*\n============\nVS_LoadPortals\n============\n*/\nvoid VS_LoadPortals (char *name)\n{\n\tint\t\t\ti, j, hint;\n\tlportal_t\t*p;\n\tlleaf_t\t\t*l;\n\tchar\t\tmagic[80];\n\tFILE\t\t*f;\n\tint\t\t\tnumpoints;\n\twinding_t\t*w;\n\tint\t\t\tleafnums[2];\n\tplane_t\t\tplane;\n\t//\n\t\n\tif (!strcmp(name,\"-\"))\n\t\tf = stdin;\n\telse\n\t{\n\t\tf = fopen(name, \"r\");\n\t\tif (!f)\n\t\t\tError (\"LoadPortals: couldn't read %s\\n\",name);\n\t}\n\n\tif (fscanf (f,\"%79s\\n%i\\n%i\\n%i\\n\",magic, &portalclusters, &numportals, &numfaces) != 4)\n\t\tError (\"LoadPortals: failed to read header\");\n\tif (strcmp(magic, PORTALFILE))\n\t\tError (\"LoadPortals: not a portal file\");\n\n\t_printf (\"%6i portalclusters\\n\", portalclusters);\n\t_printf (\"%6i numportals\\n\", numportals);\n\t_printf (\"%6i numfaces\\n\", numfaces);\n\n\tif (portalclusters >= MAX_CLUSTERS)\n\t\tError (\"more than %d clusters in portal file\\n\", MAX_CLUSTERS);\n\n\t// each file portal is split into two memory portals\n\tportals = malloc(2*numportals*sizeof(lportal_t));\n\tmemset (portals, 0, 2*numportals*sizeof(lportal_t));\n\t\n\tleafs = malloc(portalclusters*sizeof(lleaf_t));\n\tmemset (leafs, 0, portalclusters*sizeof(lleaf_t));\n\n\tfor (i=0, p=portals ; i<numportals ; i++)\n\t{\n\t\tif (fscanf (f, \"%i %i %i \", &numpoints, &leafnums[0], &leafnums[1]) != 3)\n\t\t\tError (\"LoadPortals: reading portal %i\", i);\n\t\tif (numpoints > MAX_POINTS_ON_WINDING)\n\t\t\tError (\"LoadPortals: portal %i has too many points\", i);\n\t\tif ( (unsigned)leafnums[0] > portalclusters\n\t\t|| (unsigned)leafnums[1] > portalclusters)\n\t\t\tError (\"LoadPortals: reading portal %i\", i);\n\t\tif (fscanf (f, \"%i \", &hint) != 1)\n\t\t\tError (\"LoadPortals: reading hint state\");\n\t\t\n\t\tw = p->winding = VS_AllocWinding (numpoints);\n\t\tw->numpoints = numpoints;\n\t\t\n\t\tfor (j=0 ; j<numpoints ; j++)\n\t\t{\n\t\t\tdouble\tv[3];\n\t\t\tint\t\tk;\n\n\t\t\t// scanf into double, then assign to vec_t\n\t\t\t// so we don't care what size vec_t is\n\t\t\tif (fscanf (f, \"(%lf %lf %lf ) \"\n\t\t\t, &v[0], &v[1], &v[2]) != 3)\n\t\t\t\tError (\"LoadPortals: reading portal %i\", i);\n\t\t\tfor (k=0 ; k<3 ; k++)\n\t\t\t\tw->points[j][k] = v[k];\n\t\t}\n\t\tfscanf (f, \"\\n\");\n\t\t\n\t\t// calc plane\n\t\tVS_PlaneFromWinding (w, &plane);\n\n\t\t// create forward portal\n\t\tl = &leafs[leafnums[0]];\n\t\tif (l->numportals == MAX_PORTALS_ON_LEAF)\n\t\t\tError (\"Leaf with too many portals\");\n\t\tl->portals[l->numportals] = p;\n\t\tl->numportals++;\n\t\t\n\t\tp->winding = w;\n\t\tVectorSubtract (vec3_origin, plane.normal, p->plane.normal);\n\t\tp->plane.dist = -plane.dist;\n\t\tp->leaf = leafnums[1];\n\t\tVS_SetPortalSphere (p);\n\t\tp++;\n\t\t\n\t\t// create backwards portal\n\t\tl = &leafs[leafnums[1]];\n\t\tif (l->numportals == MAX_PORTALS_ON_LEAF)\n\t\t\tError (\"Leaf with too many portals\");\n\t\tl->portals[l->numportals] = p;\n\t\tl->numportals++;\n\t\t\n\t\tp->winding = VS_AllocWinding(w->numpoints);\n\t\tp->winding->numpoints = w->numpoints;\n\t\tfor (j=0 ; j<w->numpoints ; j++)\n\t\t{\n\t\t\tVectorCopy (w->points[w->numpoints-1-j], p->winding->points[j]);\n\t\t}\n\n\t\tp->plane = plane;\n\t\tp->leaf = leafnums[0];\n\t\tVS_SetPortalSphere (p);\n\t\tp++;\n\n\t}\n\t\n\tfclose (f);\n}\n\n/*\n============\nVLightMain\n============\n*/\nint VSoundMain (int argc, char **argv) {\n\tint\t\t\ti;\n\tdouble\t\tstart, end;\n\tconst char\t*value;\n\n\t_printf (\"----- VLighting ----\\n\");\n\n\tfor (i=1 ; i<argc ; i++) {\n\t\tif (!strcmp(argv[i],\"-v\")) {\n\t\t\tverbose = qtrue;\n\t\t} else if (!strcmp(argv[i],\"-threads\")) {\n\t\t\tnumthreads = atoi (argv[i+1]);\n\t\t\t_printf(\"num threads = %d\\n\", numthreads);\n\t\t\ti++;\n\t\t} else if (!strcmp(argv[i],\"-area\")) {\n\t\t\tlightAreaScale *= atof(argv[i+1]);\n\t\t\t_printf (\"area light scaling at %f\\n\", lightAreaScale);\n\t\t\ti++;\n\t\t} else if (!strcmp(argv[i],\"-point\")) {\n\t\t\tlightPointScale *= atof(argv[i+1]);\n\t\t\t_printf (\"point light scaling at %f\\n\", lightPointScale);\n\t\t\ti++;\n\t\t} else if (!strcmp(argv[i], \"-samplesize\")) {\n\t\t\tsamplesize = atoi(argv[i+1]);\n\t\t\tif (samplesize < 1) samplesize = 1;\n\t\t\ti++;\n\t\t\t_printf(\"lightmap sample size is %dx%d units\\n\", samplesize, samplesize);\n\t\t} else if (!strcmp(argv[i], \"-nostitching\")) {\n\t\t\tnostitching = qtrue;\n\t\t\t_printf(\"no stitching = true\\n\");\n\t\t} else if (!strcmp(argv[i], \"-noalphashading\")) {\n\t\t\tnoalphashading = qtrue;\n\t\t\t_printf(\"no alpha shading = true\\n\");\n\t\t} else if (!strcmp(argv[i], \"-nocolorshading\")) {\n\t\t\tnocolorshading = qtrue;\n\t\t\t_printf(\"old style alpha shading = true\\n\");\n\t\t} else if (!strcmp(argv[i], \"-nobackfaceculling\")) {\n\t\t\tnobackfaceculling = qtrue;\n\t\t\t_printf(\"no backface culling = true\\n\");\n\t\t} else if (!strcmp(argv[i], \"-tracelight\")) {\n\t\t\tdefaulttracelight = qtrue;\n\t\t\t_printf(\"default trace light = true\\n\");\n\t\t} else if (!strcmp(argv[i], \"-radiosity\")) {\n\t\t\tradiosity = atoi(argv[i+1]);\n\t\t\t_printf(\"radiosity = %d\\n\", radiosity);\n\t\t\ti++;\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tThreadSetDefault ();\n\n\tif (i != argc - 1) {\n\t\t_printf(\"usage: q3map -vsound [-<switch> [-<switch> ...]] <mapname>\\n\"\n\t\t\t\t\"\\n\"\n\t\t\t\t\"Switches:\\n\"\n\t\t\t\t\"   v              = verbose output\\n\"\n\t\t\t\t\"   threads <X>    = set number of threads to X\\n\"\n\t\t\t\t\"   area <V>       = set the area light scale to V\\n\"\n\t\t\t\t\"   point <W>      = set the point light scale to W\\n\"\n\t\t\t\t\"   novertex       = don't calculate vertex lighting\\n\"\n\t\t\t\t\"   nogrid         = don't calculate light grid for dynamic model lighting\\n\"\n\t\t\t\t\"   nostitching    = no polygon stitching before lighting\\n\"\n\t\t\t\t\"   noalphashading = don't use alpha shading\\n\"\n\t\t\t\t\"   nocolorshading = don't use color alpha shading\\n\"\n\t\t\t\t\"   tracelight     = use old light algorithm by default\\n\"\n\t\t\t\t\"   samplesize <N> = set the lightmap pixel size to NxN units\\n\");\n\t\texit(0);\n\t}\n\n\tSetQdirFromPath (argv[i]);\t\n\n#ifdef _WIN32\n\tInitPakFile(gamedir, NULL);\n#endif\n\n\tstrcpy (source, ExpandArg(argv[i]));\n\tStripExtension (source);\n\tDefaultExtension (source, \".bsp\");\n\n\tLoadShaderInfo();\n\n\t_printf (\"reading %s\\n\", source);\n\n\tLoadBSPFile (source);\n\tParseEntities();\n\n\tvalue = ValueForKey( &entities[0], \"gridsize\" );\n\tif (strlen(value)) {\n\t\tsscanf( value, \"%f %f %f\", &gridSize[0], &gridSize[1], &gridSize[2] );\n\t\t_printf(\"grid size = {%1.1f, %1.1f, %1.1f}\\n\", gridSize[0], gridSize[1], gridSize[2]);\n\t}\n\n\tCountLightmaps();\n\n\tStripExtension (source);\n\tDefaultExtension (source, \".prt\");\n\n\tVS_LoadPortals(source);\n\n\t// set surfaceOrigin\n\tSetEntityOrigins();\n\n\t// grid and vertex lighting\n\tGridAndVertexLighting();\n\n#ifdef DEBUGNET\n\tDebugNet_Setup();\n#endif\n\n\tstart = clock();\n\n\tlightFloats = (float *) malloc(numLightBytes * sizeof(float));\n\tmemset(lightFloats, 0, numLightBytes * sizeof(float));\n\n\tVS_InitSurfacesForTesting();\n\n\tVS_CalcVisibleLightmapPixelArea();\n\n\tnumvsounds = 0;\n\tVS_CreateEntitySpeakers();\n\tVS_CreateFakeSurfaceLights();\n\tVS_CreateSkyLights();\n\n\tVS_TestLightLeafs();\n\n\tVS_LightWorld();\n\n#ifndef LIGHTPOLYS\n\tStripExtension (source);\n\tDefaultExtension (source, \".bsp\");\n\t_printf (\"writing %s\\n\", source);\n\tWriteBSPFile (source);\n#endif\n\n\tend = clock();\n\n\t_printf (\"%5.2f seconds elapsed\\n\", (end-start) / CLK_TCK);\n\n#ifdef LIGHTPOLYS\n\tVS_DrawLightWindings();\n#endif\n\n#ifdef DEBUGNET\n\tDebugNet_Shutdown();\n#endif\n\treturn 0;\n}\n"
  },
  {
    "path": "q3map/surface.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"qbsp.h\"\n\n\nmapDrawSurface_t\tmapDrawSurfs[MAX_MAP_DRAW_SURFS];\nint\t\t\tnumMapDrawSurfs;\n\n/*\n=============================================================================\n\nDRAWSURF CONSTRUCTION\n\n=============================================================================\n*/\n\n/*\n=================\nAllocDrawSurf\n=================\n*/\nmapDrawSurface_t\t*AllocDrawSurf( void ) {\n\tmapDrawSurface_t\t*ds;\n\n\tif ( numMapDrawSurfs >= MAX_MAP_DRAW_SURFS ) {\n\t\tError( \"MAX_MAP_DRAW_SURFS\");\n\t}\n\tds = &mapDrawSurfs[ numMapDrawSurfs ];\n\tnumMapDrawSurfs++;\n\n\treturn ds;\n}\n\n/*\n=================\nDrawSurfaceForSide\n=================\n*/\n#define\tSNAP_FLOAT_TO_INT\t8\n#define\tSNAP_INT_TO_FLOAT\t(1.0/SNAP_FLOAT_TO_INT)\n\nmapDrawSurface_t\t*DrawSurfaceForSide( bspbrush_t *b, side_t *s, winding_t *w ) {\n\tmapDrawSurface_t\t*ds;\n\tint\t\t\t\t\ti, j;\n\tshaderInfo_t\t\t*si;\n\tdrawVert_t\t\t\t*dv;\n\tfloat\t\t\t\tmins[2], maxs[2];\n\n\t// brush primitive :\n\t// axis base\n\tvec3_t\t\ttexX,texY;\n\tvec_t\t\tx,y;\n\n\tif ( w->numpoints > 64 ) {\n\t\tError( \"DrawSurfaceForSide: w->numpoints = %i\", w->numpoints );\n\t}\n\n\tsi = s->shaderInfo;\n\n\tds = AllocDrawSurf();\n\n\tds->shaderInfo = si;\n\tds->mapBrush = b;\n\tds->side = s;\n\tds->fogNum = -1;\n\tds->numVerts = w->numpoints;\n\tds->verts = malloc( ds->numVerts * sizeof( *ds->verts ) );\n\tmemset( ds->verts, 0, ds->numVerts * sizeof( *ds->verts ) );\n\n\tmins[0] = mins[1] = 99999;\n\tmaxs[0] = maxs[1] = -99999;\n\n\t// compute s/t coordinates from brush primitive texture matrix\n\t// compute axis base\n\tComputeAxisBase( mapplanes[s->planenum].normal, texX, texY );\n\n\tfor ( j = 0 ; j < w->numpoints ; j++ ) {\n\t\tdv = ds->verts + j;\n\n\t\t// round the xyz to a given precision\n\t\tfor ( i = 0 ; i < 3 ; i++ ) {\n\t\t\tdv->xyz[i] = SNAP_INT_TO_FLOAT * floor( w->p[j][i] * SNAP_FLOAT_TO_INT + 0.5 );\n\t\t}\n\t\n\t\tif (g_bBrushPrimit==BPRIMIT_OLDBRUSHES)\n\t\t{\n\t\t\t// calculate texture s/t\n\t\t\tdv->st[0] = s->vecs[0][3] + DotProduct( s->vecs[0],\tdv->xyz );\n\t\t\tdv->st[1] = s->vecs[1][3] + DotProduct( s->vecs[1],\tdv->xyz );\n\t\t\tdv->st[0] /= si->width;\n\t\t\tdv->st[1] /= si->height;\n\t\t} \n\t\telse\n\t\t{\n\t\t\t// calculate texture s/t from brush primitive texture matrix\n\t\t\tx = DotProduct( dv->xyz, texX );\n\t\t\ty = DotProduct( dv->xyz, texY );\n\t\t\tdv->st[0]=s->texMat[0][0]*x+s->texMat[0][1]*y+s->texMat[0][2];\n\t\t\tdv->st[1]=s->texMat[1][0]*x+s->texMat[1][1]*y+s->texMat[1][2];\n\t\t}\n\n\t\tfor ( i = 0 ; i < 2 ; i++ ) {\n\t\t\tif ( dv->st[i] < mins[i] ) {\n\t\t\t\tmins[i] = dv->st[i];\n\t\t\t}\n\t\t\tif ( dv->st[i] > maxs[i] ) {\n\t\t\t\tmaxs[i] = dv->st[i];\n\t\t\t}\n\t\t}\n\n\t\t// copy normal\n\t\tVectorCopy ( mapplanes[s->planenum].normal, dv->normal );\n\t}\n\n\t// adjust the texture coordinates to be as close to 0 as possible\n\tif ( !si->globalTexture ) {\n\t\tmins[0] = floor( mins[0] );\n\t\tmins[1] = floor( mins[1] );\n\t\tfor ( i = 0 ; i < w->numpoints ; i++ ) {\n\t\t\tdv = ds->verts + i;\n\t\t\tdv->st[0] -= mins[0];\n\t\t\tdv->st[1] -= mins[1];\n\t\t}\n\t}\n\n\treturn ds;\n}\n\n\n//=========================================================================\n\n\n\n\ntypedef struct {\n\tint\t\t\t\tplanenum;\n\tshaderInfo_t\t*shaderInfo;\n\tint\t\t\t\tcount;\n} sideRef_t;\n\n#define\tMAX_SIDE_REFS\tMAX_MAP_PLANES\n\nsideRef_t\tsideRefs[MAX_SIDE_REFS];\nint\t\t\tnumSideRefs;\n\nvoid AddSideRef( side_t *side ) {\n\tint\t\ti;\n\n\tfor ( i = 0 ; i < numSideRefs ; i++ ) {\n\t\tif ( side->planenum == sideRefs[i].planenum\n\t\t\t&& side->shaderInfo == sideRefs[i].shaderInfo ) {\n\t\t\tsideRefs[i].count++;\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif ( numSideRefs == MAX_SIDE_REFS ) {\n\t\tError( \"MAX_SIDE_REFS\" );\n\t}\n\n\tsideRefs[i].planenum = side->planenum;\n\tsideRefs[i].shaderInfo = side->shaderInfo;\n\tsideRefs[i].count++;\n\tnumSideRefs++;\n}\n\n\n/*\n=====================\nMergeSides\n\n=====================\n*/\nvoid MergeSides( entity_t *e, tree_t *tree ) {\n\tint\t\t\t\ti;\n\n\tqprintf( \"----- MergeSides -----\\n\");\n\n\tfor ( i = e->firstDrawSurf ; i < numMapDrawSurfs ; i++ ) {\n//\t\t\tAddSideRef( side );\n\t}\n\n\tqprintf( \"%5i siderefs\\n\", numSideRefs );\n}\n\n//=====================================================================\n\n/*\n===================\nSubdivideDrawSurf\n===================\n*/\nvoid SubdivideDrawSurf( mapDrawSurface_t *ds, winding_t *w, float subdivisions ) {\n\tint\t\t\t\ti;\n\tint\t\t\t\taxis;\n\tvec3_t\t\t\tbounds[2];\n\tconst float\t\tepsilon = 0.1;\n\tint\t\t\t\tsubFloor, subCeil;\n\twinding_t\t\t*frontWinding, *backWinding;\n\tmapDrawSurface_t\t*newds;\n\n\tif ( !w ) {\n\t\treturn;\n\t}\n\tif ( w->numpoints < 3 ) {\n\t\tError( \"SubdivideDrawSurf: Bad w->numpoints\" );\n\t}\n\n\tClearBounds( bounds[0], bounds[1] );\n\tfor ( i = 0 ; i < w->numpoints ; i++ ) {\n\t\tAddPointToBounds( w->p[i], bounds[0], bounds[1] );\n\t}\n\n\tfor ( axis = 0 ; axis < 3 ; axis++ ) {\n\t\tvec3_t planePoint = { 0, 0, 0 };\n\t\tvec3_t planeNormal = { 0, 0, 0 };\n\t\tfloat d;\n\n\t\tsubFloor = floor( bounds[0][axis]  / subdivisions ) * subdivisions;\n\t\tsubCeil = ceil( bounds[1][axis] / subdivisions ) * subdivisions;\n\n\t\tplanePoint[axis] = subFloor + subdivisions;\n\t\tplaneNormal[axis] = -1;\n\n\t\td = DotProduct( planePoint, planeNormal );\n\n\t\t// subdivide if necessary\n\t\tif ( subCeil - subFloor > subdivisions ) {\n\t\t\t// gotta clip polygon into two polygons\n\t\t\tClipWindingEpsilon( w, planeNormal, d, epsilon, &frontWinding, &backWinding );\n\n\t\t\t// the clip may not produce two polygons if it was epsilon close\n\t\t\tif ( !frontWinding ) {\n\t\t\t\tw = backWinding;\n\t\t\t} else if ( !backWinding ) {\n\t\t\t\tw = frontWinding;\n\t\t\t} else {\n\t\t\t\tSubdivideDrawSurf( ds, frontWinding, subdivisions );\n\t\t\t\tSubdivideDrawSurf( ds, backWinding, subdivisions );\n\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\t// emit this polygon\n\tnewds = DrawSurfaceForSide( ds->mapBrush, ds->side, w );\n\tnewds->fogNum = ds->fogNum;\n}\n\n\n/*\n=====================\nSubdivideDrawSurfs\n\nChop up surfaces that have subdivision attributes\n=====================\n*/\nvoid SubdivideDrawSurfs( entity_t *e, tree_t *tree ) {\n\tint\t\t\t\ti;\n\tmapDrawSurface_t\t*ds;\n\tint\t\t\t\tnumBaseDrawSurfs;\n\twinding_t\t\t*w;\n\tfloat\t\t\tsubdivision;\n\tshaderInfo_t\t*si;\n\n\tqprintf( \"----- SubdivideDrawSurfs -----\\n\");\n\tnumBaseDrawSurfs = numMapDrawSurfs;\n\tfor ( i = e->firstDrawSurf ; i < numBaseDrawSurfs ; i++ ) {\n\t\tds = &mapDrawSurfs[i];\n\n\t\t// only subdivide brush sides, not patches or misc_models\n\t\tif ( !ds->side ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// check subdivision for shader\n\t\tsi = ds->side->shaderInfo;\n\t\tif ( !si ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (ds->shaderInfo->autosprite || si->autosprite) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tsubdivision = si->subdivisions;\n\t\tif ( !subdivision ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tw = WindingFromDrawSurf( ds );\n\t\tds->numVerts = 0;\t\t// remove this reference\n\t\tSubdivideDrawSurf( ds, w, subdivision );\n\t}\n\n}\n\n\n//===================================================================================\n\n/*\n====================\nClipSideIntoTree_r\n\nAdds non-opaque leaf fragments to the convex hull\n====================\n*/\nvoid ClipSideIntoTree_r( winding_t *w, side_t *side, node_t *node ) {\n\tplane_t\t\t\t*plane;\n\twinding_t\t\t*front, *back;\n\n\tif ( !w ) {\n\t\treturn;\n\t}\n\n\tif ( node->planenum != PLANENUM_LEAF ) {\n\t\tif ( side->planenum == node->planenum ) {\n\t\t\tClipSideIntoTree_r( w, side, node->children[0] );\n\t\t\treturn;\n\t\t}\n\t\tif ( side->planenum == ( node->planenum ^ 1) ) {\n\t\t\tClipSideIntoTree_r( w, side, node->children[1] );\n\t\t\treturn;\n\t\t}\n\n\t\tplane = &mapplanes[ node->planenum ];\n\t\tClipWindingEpsilon ( w, plane->normal, plane->dist,\n\t\t\t\tON_EPSILON, &front, &back );\n\t\tFreeWinding( w );\n\n\t\tClipSideIntoTree_r( front, side, node->children[0] );\n\t\tClipSideIntoTree_r( back, side, node->children[1] );\n\n\t\treturn;\n\t}\n\n\t// if opaque leaf, don't add\n\tif ( !node->opaque ) {\n\t\tAddWindingToConvexHull( w, &side->visibleHull, mapplanes[ side->planenum ].normal );\n\t}\n\n\tFreeWinding( w );\n\treturn;\n}\n\n\n/*\n=====================\nClipSidesIntoTree\n\nCreates side->visibleHull for all visible sides\n\nThe drawsurf for a side will consist of the convex hull of\nall points in non-opaque clusters, which allows overlaps\nto be trimmed off automatically.\n=====================\n*/\nvoid ClipSidesIntoTree( entity_t *e, tree_t *tree ) {\n\tbspbrush_t\t\t*b;\n\tint\t\t\t\ti;\n\twinding_t\t\t*w;\n\tside_t\t\t\t*side, *newSide;\n\tshaderInfo_t\t*si;\n\n\tqprintf( \"----- ClipSidesIntoTree -----\\n\");\n\n\tfor ( b = e->brushes ; b ; b = b->next ) {\n\t\tfor ( i = 0 ; i < b->numsides ; i++ ) {\n\t\t\tside = &b->sides[i];\n\t\t\tif ( !side->winding) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tw = CopyWinding( side->winding );\n\t\t\tside->visibleHull = NULL;\n\t\t\tClipSideIntoTree_r( w, side, tree->headnode );\n\n\t\t\tw = side->visibleHull;\n\t\t\tif ( !w ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tsi = side->shaderInfo;\n\t\t\tif ( !si ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// don't create faces for non-visible sides\n\t\t\tif ( si->surfaceFlags & SURF_NODRAW ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// always use the original quad winding for auto sprites\n\t\t\tif ( side->shaderInfo->autosprite ) {\n\t\t\t\tw = side->winding;\n\t\t\t}\n\t\t\t//\n\t\t\tif ( side->bevel ) {\n\t\t\t\tError( \"monkey tried to create draw surface for brush bevel\" );\n\t\t\t}\n\t\t\t// save this winding as a visible surface\n\t\t\tDrawSurfaceForSide( b, side, w );\n\n\t\t\t// make a back side for it if needed\n\t\t\tif ( !(si->contents & CONTENTS_FOG) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// duplicate the up-facing side\n\t\t\tw = ReverseWinding( w );\n\t\t\n\t\t\tnewSide = malloc( sizeof( *side ) );\n\t\t\t*newSide = *side;\n\t\t\tnewSide->visibleHull = w;\n\t\t\tnewSide->planenum ^= 1;\n\n\t\t\t// save this winding as a visible surface\n\t\t\tDrawSurfaceForSide( b, newSide, w );\n\n\t\t}\n\t}\n}\n\n/*\n===================================================================================\n\n  FILTER REFERENCES DOWN THE TREE\n\n===================================================================================\n*/\n\n/*\n====================\nFilterDrawSurfIntoTree\n\nPlace a reference to the given drawsurf in every leaf it contacts\nWe assume that the point mesh aproximation to the curve will get a \nreference into all the leafs we need.\n====================\n*/\nint FilterMapDrawSurfIntoTree( vec3_t point, mapDrawSurface_t *ds, node_t *node ) {\n\tdrawSurfRef_t\t*dsr;\n\tfloat\t\t\td;\n\tplane_t\t\t\t*plane;\n\tint\t\t\t\tc;\n\n\tif ( node->planenum != PLANENUM_LEAF ) {\n\t\tplane = &mapplanes[ node->planenum ];\n\t\td = DotProduct( point, plane->normal ) - plane->dist;\n\t\tc = 0;\n\t\tif ( d >= -ON_EPSILON ) {\n\t\t\tc += FilterMapDrawSurfIntoTree( point, ds, node->children[0] );\n\t\t}\n\t\tif ( d <= ON_EPSILON ) {\n\t\t\tc += FilterMapDrawSurfIntoTree( point, ds, node->children[1] );\n\t\t}\n\t\treturn c;\n\t}\n\n\t// if opaque leaf, don't add\n\tif ( node->opaque ) {\n\t\treturn 0;\n\t}\n\n\t// add the drawsurf if it hasn't been already\n\tfor ( dsr = node->drawSurfReferences ; dsr ; dsr = dsr->nextRef ) {\n\t\tif ( dsr->outputNumber == numDrawSurfaces ) {\n\t\t\treturn 0;\t\t// already referenced\n\t\t}\n\t}\n\n\tdsr = malloc( sizeof( *dsr ) );\n\tdsr->outputNumber = numDrawSurfaces;\n\tdsr->nextRef = node->drawSurfReferences;\n\tnode->drawSurfReferences = dsr;\n\treturn 1;\n}\n\n/*\n====================\nFilterDrawSurfIntoTree_r\n\nPlace a reference to the given drawsurf in every leaf it is in\n====================\n*/\nint FilterMapDrawSurfIntoTree_r( winding_t *w, mapDrawSurface_t *ds, node_t *node ) {\n\tdrawSurfRef_t\t*dsr;\n\tplane_t\t\t\t*plane;\n\tint\t\t\t\ttotal;\n\twinding_t\t\t*front, *back;\n\n\tif ( node->planenum != PLANENUM_LEAF ) {\n\t\tplane = &mapplanes[ node->planenum ];\n\t\tClipWindingEpsilon ( w, plane->normal, plane->dist,\n\t\t\t\tON_EPSILON, &front, &back );\n\n\t\ttotal = 0;\n\t\tif ( front ) {\n\t\t\ttotal += FilterMapDrawSurfIntoTree_r( front, ds, node->children[0] );\n\t\t}\n\t\tif ( back ) {\n\t\t\ttotal += FilterMapDrawSurfIntoTree_r( back, ds, node->children[1] );\n\t\t}\n\n\t\tFreeWinding( w );\n\t\treturn total;\n\t}\n\n\t// if opaque leaf, don't add\n\tif ( node->opaque ) {\n\t\treturn 0;\n\t}\n\n\t// add the drawsurf if it hasn't been already\n\tfor ( dsr = node->drawSurfReferences ; dsr ; dsr = dsr->nextRef ) {\n\t\tif ( dsr->outputNumber == numDrawSurfaces ) {\n\t\t\treturn 0;\t\t// already referenced\n\t\t}\n\t}\n\n\tdsr = malloc( sizeof( *dsr ) );\n\tdsr->outputNumber = numDrawSurfaces;\n\tdsr->nextRef = node->drawSurfReferences;\n\tnode->drawSurfReferences = dsr;\n\treturn 1;\n}\n\n/*\n====================\nFilterSideIntoTree_r\n\nPlace a reference to the given drawsurf in every leaf it contacts\n====================\n*/\nint FilterSideIntoTree_r( winding_t *w, side_t *side, mapDrawSurface_t *ds, node_t *node ) {\n\tdrawSurfRef_t\t*dsr;\n\tplane_t\t\t\t*plane;\n\twinding_t\t\t*front, *back;\n\tint\t\t\t\ttotal;\n\n\tif ( !w ) {\n\t\treturn 0;\n\t}\n\n\tif ( node->planenum != PLANENUM_LEAF ) {\n\t\tif ( side->planenum == node->planenum ) {\n\t\t\treturn FilterSideIntoTree_r( w, side, ds, node->children[0] );\n\t\t}\n\t\tif ( side->planenum == ( node->planenum ^ 1) ) {\n\t\t\treturn FilterSideIntoTree_r( w, side, ds, node->children[1] );\n\t\t}\n\n\t\tplane = &mapplanes[ node->planenum ];\n\t\tClipWindingEpsilon ( w, plane->normal, plane->dist,\n\t\t\t\tON_EPSILON, &front, &back );\n\n\t\ttotal = FilterSideIntoTree_r( front, side, ds, node->children[0] );\n\t\ttotal += FilterSideIntoTree_r( back, side, ds, node->children[1] );\n\n\t\tFreeWinding( w );\n\t\treturn total;\n\t}\n\n\t// if opaque leaf, don't add\n\tif ( node->opaque ) {\n\t\treturn 0;\n\t}\n\n\tdsr = malloc( sizeof( *dsr ) );\n\tdsr->outputNumber = numDrawSurfaces;\n\tdsr->nextRef = node->drawSurfReferences;\n\tnode->drawSurfReferences = dsr;\n\n\tFreeWinding( w );\n\treturn 1;\n}\n\n\n/*\n=====================\nFilterFaceIntoTree\n=====================\n*/\nint\tFilterFaceIntoTree( mapDrawSurface_t *ds, tree_t *tree ) {\n\tint\t\t\tl;\n\twinding_t\t*w;\n\n\tw = WindingFromDrawSurf( ds );\n\tl = FilterSideIntoTree_r( w, ds->side, ds, tree->headnode );\n\n\treturn l;\n}\n\n\n\n/*\n=====================\nFilterPatchSurfIntoTree\n=====================\n*/\n#define\tSUBDIVISION_LIMIT\t\t8.0\nint FilterPatchSurfIntoTree( mapDrawSurface_t *ds, tree_t *tree ) {\n\tint\t\t\t\t\ti, j;\n\tint\t\t\t\t\tl;\n\tmesh_t\t\t\t\tbaseMesh, *subdividedMesh;\n\twinding_t\t\t\t*w;\n\n\tbaseMesh.width = ds->patchWidth;\n\tbaseMesh.height = ds->patchHeight;\n\tbaseMesh.verts = ds->verts;\n\tsubdividedMesh = SubdivideMesh( baseMesh, SUBDIVISION_LIMIT, 32 );\n\n\tl = 0;\n\tfor (i = 0; i < subdividedMesh->width-1; i++) {\n\t\tfor (j = 0; j < subdividedMesh->height-1; j++) {\n\t\t\tw = AllocWinding(3);\n\t\t\tVectorCopy(subdividedMesh->verts[j * subdividedMesh->width + i].xyz, w->p[0]);\n\t\t\tVectorCopy(subdividedMesh->verts[j * subdividedMesh->width + i + 1].xyz, w->p[1]);\n\t\t\tVectorCopy(subdividedMesh->verts[(j+1) * subdividedMesh->width + i].xyz, w->p[2]);\n\t\t\tw->numpoints = 3;\n\t\t\tl += FilterMapDrawSurfIntoTree_r( w, ds, tree->headnode );\n\t\t\tw = AllocWinding(3);\n\t\t\tVectorCopy(subdividedMesh->verts[j * subdividedMesh->width + i + 1].xyz, w->p[0]);\n\t\t\tVectorCopy(subdividedMesh->verts[(j+1) * subdividedMesh->width + i + 1].xyz, w->p[1]);\n\t\t\tVectorCopy(subdividedMesh->verts[(j+1) * subdividedMesh->width + i].xyz, w->p[2]);\n\t\t\tw->numpoints = 3;\n\t\t\tl += FilterMapDrawSurfIntoTree_r( w, ds, tree->headnode );\n\t\t}\n\t}\n\n\t// also use the old point filtering into the tree\n\tfor ( i = 0 ; i < subdividedMesh->width * subdividedMesh->height ; i++ ) {\n\t\tl += FilterMapDrawSurfIntoTree( subdividedMesh->verts[i].xyz, ds, tree->headnode );\n\t}\n\n\tfree(subdividedMesh);\n\n\treturn l;\n}\n\n\n/*\n=====================\nFilterMiscModelSurfIntoTree\n=====================\n*/\nint\tFilterMiscModelSurfIntoTree( mapDrawSurface_t *ds, tree_t *tree ) {\n\tint\t\t\ti;\n\tint\t\t\tl;\n\twinding_t *w;\n\n\tl = 0;\n\tfor (i = 0; i < ds->numIndexes-2; i++) {\n\t\tw = AllocWinding(3);\n\t\tVectorCopy(ds->verts[ds->indexes[i]].xyz, w->p[0]);\n\t\tVectorCopy(ds->verts[ds->indexes[i+1]].xyz, w->p[1]);\n\t\tVectorCopy(ds->verts[ds->indexes[i+2]].xyz, w->p[2]);\n\t\tw->numpoints = 3;\n\t\tl += FilterMapDrawSurfIntoTree_r( w, ds, tree->headnode );\n\t}\n\n\t// also use the old point filtering into the tree\n\tfor ( i = 0 ; i < ds->numVerts ; i++ ) {\n\t\tl += FilterMapDrawSurfIntoTree( ds->verts[i].xyz, ds, tree->headnode );\n\t}\n\n\treturn l;\n}\n\n/*\n=====================\nFilterFlareSurfIntoTree\n=====================\n*/\nint\tFilterFlareSurfIntoTree( mapDrawSurface_t *ds, tree_t *tree ) {\n\treturn FilterMapDrawSurfIntoTree( ds->lightmapOrigin, ds, tree->headnode );\n}\n\n\n//======================================================================\n\nint\t\tc_stripSurfaces, c_fanSurfaces;\n\n/*\n==================\nIsTriangleDegenerate\n\nReturns qtrue if all three points are collinear or backwards\n===================\n*/\n#define\tCOLINEAR_AREA\t10\nstatic qboolean\tIsTriangleDegenerate( drawVert_t *points, int a, int b, int c ) {\n\tvec3_t\t\tv1, v2, v3;\n\tfloat\t\td;\n\n\tVectorSubtract( points[b].xyz, points[a].xyz, v1 );\n\tVectorSubtract( points[c].xyz, points[a].xyz, v2 );\n\tCrossProduct( v1, v2, v3 );\n\td = VectorLength( v3 );\n\n\t// assume all very small or backwards triangles will cause problems\n\tif ( d < COLINEAR_AREA ) {\n\t\treturn qtrue;\n\t}\n\n\treturn qfalse;\n}\n\n/*\n===============\nSurfaceAsTriFan\n\nThe surface can't be represented as a single tristrip without\nleaving a degenerate triangle (and therefore a crack), so add\na point in the middle and create (points-1) triangles in fan order\n===============\n*/\nstatic void SurfaceAsTriFan( dsurface_t *ds ) {\n\tint\t\t\t\t\ti;\n\tint\t\t\t\t\tcolorSum[4];\n\tdrawVert_t\t\t\t*mid, *v;\n\n\t// create a new point in the center of the face\n\tif ( numDrawVerts == MAX_MAP_DRAW_VERTS ) {\n\t\tError( \"MAX_MAP_DRAW_VERTS\" );\n\t}\n\tmid = &drawVerts[ numDrawVerts ];\n\tnumDrawVerts++;\n\n\tcolorSum[0] = colorSum[1] = colorSum[2] = colorSum[3] = 0;\n\n\tv = drawVerts + ds->firstVert;\n\tfor (i = 0 ; i < ds->numVerts ; i++, v++ ) {\n\t\tVectorAdd( mid->xyz, v->xyz, mid->xyz );\n\t\tmid->st[0] += v->st[0];\n\t\tmid->st[1] += v->st[1];\n\t\tmid->lightmap[0] += v->lightmap[0];\n\t\tmid->lightmap[1] += v->lightmap[1];\n\n\t\tcolorSum[0] += v->color[0];\n\t\tcolorSum[1] += v->color[1];\n\t\tcolorSum[2] += v->color[2];\n\t\tcolorSum[3] += v->color[3];\n\t}\n\n\tmid->xyz[0] /= ds->numVerts;\n\tmid->xyz[1] /= ds->numVerts;\n\tmid->xyz[2] /= ds->numVerts;\n\n\tmid->st[0] /= ds->numVerts;\n\tmid->st[1] /= ds->numVerts;\n\n\tmid->lightmap[0] /= ds->numVerts;\n\tmid->lightmap[1] /= ds->numVerts;\n\n\tmid->color[0] = colorSum[0] / ds->numVerts;\n\tmid->color[1] = colorSum[1] / ds->numVerts;\n\tmid->color[2] = colorSum[2] / ds->numVerts;\n\tmid->color[3] = colorSum[3] / ds->numVerts;\n\n\tVectorCopy((drawVerts+ds->firstVert)->normal, mid->normal );\n\n\t// fill in indices in trifan order\n\tif ( numDrawIndexes + ds->numVerts*3 > MAX_MAP_DRAW_INDEXES ) {\n\t\tError( \"MAX_MAP_DRAWINDEXES\" );\n\t}\n\tds->firstIndex = numDrawIndexes;\n\tds->numIndexes = ds->numVerts*3;\n\n\t//FIXME\n\t// should be: for ( i = 0 ; i < ds->numVerts ; i++ ) {\n\t// set a break point and test this in a map\n\t//for ( i = 0 ; i < ds->numVerts*3 ; i++ ) {\n\tfor ( i = 0 ; i < ds->numVerts ; i++ ) {\n\t\tdrawIndexes[numDrawIndexes++] = ds->numVerts;\n\t\tdrawIndexes[numDrawIndexes++] = i;\n\t\tdrawIndexes[numDrawIndexes++] = (i+1) % ds->numVerts;\n\t}\n\n\tds->numVerts++;\n}\n\n\n/*\n================\nSurfaceAsTristrip\n\nTry to create indices that make (points-2) triangles in tristrip order\n================\n*/\n#define\tMAX_INDICES\t1024\nstatic void SurfaceAsTristrip( dsurface_t *ds ) {\n\tint\t\t\t\t\ti;\n\tint\t\t\t\t\trotate;\n\tint\t\t\t\t\tnumIndices;\n\tint\t\t\t\t\tni;\n\tint\t\t\t\t\ta, b, c;\n\tint\t\t\t\t\tindices[MAX_INDICES];\n\n\t// determine the triangle strip order\n\tnumIndices = ( ds->numVerts - 2 ) * 3;\n\tif ( numIndices > MAX_INDICES ) {\n\t\tError( \"MAX_INDICES exceeded for surface\" );\n\t}\n\n\t// try all possible orderings of the points looking\n\t// for a strip order that isn't degenerate\n\tfor ( rotate = 0 ; rotate < ds->numVerts ; rotate++ ) {\n\t\tfor ( ni = 0, i = 0 ; i < ds->numVerts - 2 - i ; i++ ) {\n\t\t\ta = ( ds->numVerts - 1 - i + rotate ) % ds->numVerts;\n\t\t\tb = ( i + rotate ) % ds->numVerts;\n\t\t\tc = ( ds->numVerts - 2 - i + rotate ) % ds->numVerts;\n\n\t\t\tif ( IsTriangleDegenerate( drawVerts + ds->firstVert, a, b, c ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tindices[ni++] = a;\n\t\t\tindices[ni++] = b;\n\t\t\tindices[ni++] = c;\n\n\t\t\tif ( i + 1 != ds->numVerts - 1 - i ) {\n\t\t\t\ta = ( ds->numVerts - 2 - i + rotate ) % ds->numVerts;\n\t\t\t\tb = ( i + rotate ) % ds->numVerts;\n\t\t\t\tc = ( i + 1 + rotate ) % ds->numVerts;\n\n\t\t\t\tif ( IsTriangleDegenerate( drawVerts + ds->firstVert, a, b, c ) ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tindices[ni++] = a;\n\t\t\t\tindices[ni++] = b;\n\t\t\t\tindices[ni++] = c;\n\t\t\t}\n\t\t}\n\t\tif ( ni == numIndices ) {\n\t\t\tbreak;\t\t// got it done without degenerate triangles\n\t\t}\n\t}\n\n\t// if any triangle in the strip is degenerate,\n\t// render from a centered fan point instead\n\tif ( ni < numIndices ) {\n\t\tc_fanSurfaces++;\n\t\tSurfaceAsTriFan( ds );\n\t\treturn;\n\t}\n\n\t// a normal tristrip\n\tc_stripSurfaces++;\n\n\tif ( numDrawIndexes + ni > MAX_MAP_DRAW_INDEXES ) {\n\t\tError( \"MAX_MAP_DRAW_INDEXES\" );\n\t}\n\tds->firstIndex = numDrawIndexes;\n\tds->numIndexes = ni;\n\n\tmemcpy( drawIndexes + numDrawIndexes, indices, ni * sizeof(int) );\n\tnumDrawIndexes += ni;\n}\n\n/*\n===============\nEmitPlanarSurf\n===============\n*/\nvoid EmitPlanarSurf( mapDrawSurface_t *ds ) {\n\tint\t\t\t\tj;\n\tdsurface_t\t\t*out;\n\tdrawVert_t\t\t*outv;\n\n\tif ( numDrawSurfaces == MAX_MAP_DRAW_SURFS ) {\n\t\tError( \"MAX_MAP_DRAW_SURFS\" );\n\t}\n\tout = &drawSurfaces[ numDrawSurfaces ];\n\tnumDrawSurfaces++;\n\n\tout->surfaceType = MST_PLANAR;\n\tout->shaderNum = EmitShader( ds->shaderInfo->shader );\n\tout->firstVert = numDrawVerts;\n\tout->numVerts = ds->numVerts;\n\tout->fogNum = ds->fogNum;\n\tout->lightmapNum = ds->lightmapNum;\n\tout->lightmapX = ds->lightmapX;\n\tout->lightmapY = ds->lightmapY;\n\tout->lightmapWidth = ds->lightmapWidth;\n\tout->lightmapHeight = ds->lightmapHeight;\n\n\tVectorCopy( ds->lightmapOrigin, out->lightmapOrigin );\n\tVectorCopy( ds->lightmapVecs[0], out->lightmapVecs[0] );\n\tVectorCopy( ds->lightmapVecs[1], out->lightmapVecs[1] );\n\tVectorCopy( ds->lightmapVecs[2], out->lightmapVecs[2] );\n\n\tfor ( j = 0 ; j < ds->numVerts ; j++ ) {\n\t\tif ( numDrawVerts == MAX_MAP_DRAW_VERTS ) {\n\t\t\tError( \"MAX_MAP_DRAW_VERTS\" );\n\t\t}\n\t\toutv = &drawVerts[ numDrawVerts ];\n\t\tnumDrawVerts++;\n\t\tmemcpy( outv, &ds->verts[ j ], sizeof( *outv ) );\n\t\toutv->color[0] = 255;\n\t\toutv->color[1] = 255;\n\t\toutv->color[2] = 255;\n\t\toutv->color[3] = 255;\n\t}\n\n\t// create the indexes\n\tSurfaceAsTristrip( out );\n}\n\n\n/*\n===============\nEmitPatchSurf\n===============\n*/\nvoid EmitPatchSurf( mapDrawSurface_t *ds ) {\n\tint\t\t\t\tj;\n\tdsurface_t\t\t*out;\n\tdrawVert_t\t\t*outv;\n\n\tif ( numDrawSurfaces == MAX_MAP_DRAW_SURFS ) {\n\t\tError( \"MAX_MAP_DRAW_SURFS\" );\n\t}\n\tout = &drawSurfaces[ numDrawSurfaces ];\n\tnumDrawSurfaces++;\n\n\tout->surfaceType = MST_PATCH;\n\tout->shaderNum = EmitShader( ds->shaderInfo->shader );\n\tout->firstVert = numDrawVerts;\n\tout->numVerts = ds->numVerts;\n\tout->firstIndex = numDrawIndexes;\n\tout->numIndexes = ds->numIndexes;\n\tout->patchWidth = ds->patchWidth;\n\tout->patchHeight = ds->patchHeight;\n\tout->fogNum = ds->fogNum;\n\tout->lightmapNum = ds->lightmapNum;\n\tout->lightmapX = ds->lightmapX;\n\tout->lightmapY = ds->lightmapY;\n\tout->lightmapWidth = ds->lightmapWidth;\n\tout->lightmapHeight = ds->lightmapHeight;\n\n\tVectorCopy( ds->lightmapOrigin, out->lightmapOrigin );\n\tVectorCopy( ds->lightmapVecs[0], out->lightmapVecs[0] );\n\tVectorCopy( ds->lightmapVecs[1], out->lightmapVecs[1] );\n\tVectorCopy( ds->lightmapVecs[2], out->lightmapVecs[2] );\n\n\tfor ( j = 0 ; j < ds->numVerts ; j++ ) {\n\t\tif ( numDrawVerts == MAX_MAP_DRAW_VERTS ) {\n\t\t\tError( \"MAX_MAP_DRAW_VERTS\" );\n\t\t}\n\t\toutv = &drawVerts[ numDrawVerts ];\n\t\tnumDrawVerts++;\n\t\tmemcpy( outv, &ds->verts[ j ], sizeof( *outv ) );\n\t\toutv->color[0] = 255;\n\t\toutv->color[1] = 255;\n\t\toutv->color[2] = 255;\n\t\toutv->color[3] = 255;\n\t}\n\n\tfor ( j = 0 ; j < ds->numIndexes ; j++ ) {\n\t\tif ( numDrawIndexes == MAX_MAP_DRAW_INDEXES ) {\n\t\t\tError( \"MAX_MAP_DRAW_INDEXES\" );\n\t\t}\n\t\tdrawIndexes[ numDrawIndexes ] = ds->indexes[ j ];\n\t\tnumDrawIndexes++;\n\t}\n}\n\n/*\n===============\nEmitFlareSurf\n===============\n*/\nvoid EmitFlareSurf( mapDrawSurface_t *ds ) {\n\tdsurface_t\t\t*out;\n\n\tif ( numDrawSurfaces == MAX_MAP_DRAW_SURFS ) {\n\t\tError( \"MAX_MAP_DRAW_SURFS\" );\n\t}\n\tout = &drawSurfaces[ numDrawSurfaces ];\n\tnumDrawSurfaces++;\n\n\tout->surfaceType = MST_FLARE;\n\tout->shaderNum = EmitShader( ds->shaderInfo->shader );\n\tout->fogNum = ds->fogNum;\n\n\tVectorCopy( ds->lightmapOrigin, out->lightmapOrigin );\n\tVectorCopy( ds->lightmapVecs[0], out->lightmapVecs[0] );\t// color\n\tVectorCopy( ds->lightmapVecs[2], out->lightmapVecs[2] );\n}\n\n\n/*\n===============\nEmitModelSurf\n===============\n*/\nvoid EmitModelSurf( mapDrawSurface_t *ds ) {\n\tint\t\t\t\tj;\n\tdsurface_t\t\t*out;\n\tdrawVert_t\t\t*outv;\n\n\tif ( numDrawSurfaces == MAX_MAP_DRAW_SURFS ) {\n\t\tError( \"MAX_MAP_DRAW_SURFS\" );\n\t}\n\tout = &drawSurfaces[ numDrawSurfaces ];\n\tnumDrawSurfaces++;\n\n\tout->surfaceType = MST_TRIANGLE_SOUP;\n\tout->shaderNum = EmitShader( ds->shaderInfo->shader );\n\tout->firstVert = numDrawVerts;\n\tout->numVerts = ds->numVerts;\n\tout->firstIndex = numDrawIndexes;\n\tout->numIndexes = ds->numIndexes;\n\tout->patchWidth = ds->patchWidth;\n\tout->patchHeight = ds->patchHeight;\n\tout->fogNum = ds->fogNum;\n\tout->lightmapNum = ds->lightmapNum;\n\tout->lightmapX = ds->lightmapX;\n\tout->lightmapY = ds->lightmapY;\n\tout->lightmapWidth = ds->lightmapWidth;\n\tout->lightmapHeight = ds->lightmapHeight;\n\n\tVectorCopy( ds->lightmapOrigin, out->lightmapOrigin );\n\tVectorCopy( ds->lightmapVecs[0], out->lightmapVecs[0] );\n\tVectorCopy( ds->lightmapVecs[1], out->lightmapVecs[1] );\n\tVectorCopy( ds->lightmapVecs[2], out->lightmapVecs[2] );\n\n\tfor ( j = 0 ; j < ds->numVerts ; j++ ) {\n\t\tif ( numDrawVerts == MAX_MAP_DRAW_VERTS ) {\n\t\t\tError( \"MAX_MAP_DRAW_VERTS\" );\n\t\t}\n\t\toutv = &drawVerts[ numDrawVerts ];\n\t\tnumDrawVerts++;\n\t\tmemcpy( outv, &ds->verts[ j ], sizeof( *outv ) );\n\t\toutv->color[0] = 255;\n\t\toutv->color[1] = 255;\n\t\toutv->color[2] = 255;\n\t}\n\n\tfor ( j = 0 ; j < ds->numIndexes ; j++ ) {\n\t\tif ( numDrawIndexes == MAX_MAP_DRAW_INDEXES ) {\n\t\t\tError( \"MAX_MAP_DRAW_INDEXES\" );\n\t\t}\n\t\tdrawIndexes[ numDrawIndexes ] = ds->indexes[ j ];\n\t\tnumDrawIndexes++;\n\t}\n}\n\n//======================================================================\n\n/*\n==================\nCreateFlareSurface\n\nLight flares from surface lights become \n==================\n*/\nvoid CreateFlareSurface( mapDrawSurface_t *faceDs ) {\n\tmapDrawSurface_t\t*ds;\n\tint\t\t\t\t\ti;\n\n\tds = AllocDrawSurf();\n\n\tif ( faceDs->shaderInfo->flareShader[0] ) {\n\t\tds->shaderInfo = ShaderInfoForShader( faceDs->shaderInfo->flareShader );\n\t} else {\n\t\tds->shaderInfo = ShaderInfoForShader( \"flareshader\" );\n\t}\n\tds->flareSurface = qtrue;\n\tVectorCopy( faceDs->lightmapVecs[2], ds->lightmapVecs[2] );\n\n\t// find midpoint\n\tVectorClear( ds->lightmapOrigin );\n\tfor ( i = 0 ; i < faceDs->numVerts ; i++ ) {\n\t\tVectorAdd( ds->lightmapOrigin, faceDs->verts[i].xyz, ds->lightmapOrigin );\n\t}\n\tVectorScale( ds->lightmapOrigin, 1.0/faceDs->numVerts, ds->lightmapOrigin );\n\n\tVectorMA( ds->lightmapOrigin, 2,  ds->lightmapVecs[2], ds->lightmapOrigin );\n\n\tVectorCopy( faceDs->shaderInfo->color, ds->lightmapVecs[0] );\n\n\t// FIXME: fog\n}\n\n/*\n=====================\nFilterDrawsurfsIntoTree\n\nUpon completion, all drawsurfs that actually generate a reference\nwill have been emited to the bspfile arrays, and the references\nwill have valid final indexes\n=====================\n*/\nvoid FilterDrawsurfsIntoTree( entity_t *e, tree_t *tree ) {\n\tint\t\t\t\ti;\n\tmapDrawSurface_t\t*ds;\n\tint\t\t\t\trefs;\n\tint\t\t\t\tc_surfs, c_refs;\n\n\tqprintf( \"----- FilterDrawsurfsIntoTree -----\\n\");\n\n\tc_surfs = 0;\n\tc_refs = 0;\n\tfor ( i = e->firstDrawSurf ; i < numMapDrawSurfs ; i++ ) {\n\t\tds = &mapDrawSurfs[i];\n\n\t\tif ( !ds->numVerts && !ds->flareSurface ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( ds->miscModel ) {\n\t\t\trefs = FilterMiscModelSurfIntoTree( ds, tree );\n\t\t\tEmitModelSurf( ds );\t\t\n\t\t} else if ( ds->patch ) {\n\t\t\trefs = FilterPatchSurfIntoTree( ds, tree );\n\t\t\tEmitPatchSurf( ds );\t\t\n\t\t} else if ( ds->flareSurface ) {\n\t\t\trefs = FilterFlareSurfIntoTree( ds, tree );\n\t\t\tEmitFlareSurf( ds );\t\t\t\t\t\n\t\t} else {\n\t\t\trefs = FilterFaceIntoTree( ds, tree );\n//\t\t\tif ( ds->shaderInfo->value >= 1000 ) { // ds->shaderInfo->flareShader[0] ) {\n\t\t\tif ( ds->shaderInfo->flareShader[0] ) {\n\t\t\t\tCreateFlareSurface( ds );\n\t\t\t}\n\t\t\tEmitPlanarSurf( ds );\t\t\n\t\t}\n\t\tif ( refs > 0 ) {\n\t\t\tc_surfs++;\n\t\t\tc_refs += refs;\n\t\t}\n\t}\n\tqprintf( \"%5i emited drawsurfs\\n\", c_surfs );\n\tqprintf( \"%5i references\\n\", c_refs );\n\tqprintf( \"%5i stripfaces\\n\", c_stripSurfaces );\n\tqprintf( \"%5i fanfaces\\n\", c_fanSurfaces );\n}\n\n\n\n"
  },
  {
    "path": "q3map/terrain.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"qbsp.h\"\n#include <assert.h>\n\n#define SURF_WIDTH\t2048\n#define SURF_HEIGHT 2048\n\n#define GROW_VERTS\t\t512\n#define GROW_INDICES\t512\n#define GROW_SURFACES\t128\n\n#define VectorSet(v, x, y, z)\t\tv[0] = x;v[1] = y;v[2] = z;\n\nvoid QuakeTextureVecs( \tplane_t *plane, vec_t shift[2], vec_t rotate, vec_t scale[2], vec_t mappingVecs[2][4] );\n\ntypedef struct {\n\tshaderInfo_t\t*shader;\n\tint\t\t\t\tx, y;\n\n\tint\t\t\t\tmaxVerts;\n\tint\t\t\t\tnumVerts;\n\tdrawVert_t\t\t*verts;\n\n\tint\t\t\t\tmaxIndexes;\n\tint\t\t\t\tnumIndexes;\n\tint\t\t\t\t*indexes;\n} terrainSurf_t;\n\nstatic terrainSurf_t\t*surfaces = NULL;\nstatic terrainSurf_t\t*lastSurface = NULL;\nstatic int\t\t\t\tnumsurfaces = 0;\nstatic int\t\t\t\tmaxsurfaces = 0;\n\n/*\n================\nShaderForLayer\n================\n*/\nshaderInfo_t *ShaderForLayer( int minlayer, int maxlayer, const char *shadername ) {\n\tchar\tshader[ MAX_QPATH ];\n\n\tif ( minlayer == maxlayer ) {\n\t\tsprintf( shader, \"textures/%s_%d\", shadername, maxlayer );\n\t} else {\n\t\tsprintf( shader, \"textures/%s_%dto%d\", shadername, minlayer, maxlayer );\n\t}\n\n\treturn ShaderInfoForShader( shader );\n}\n\n/*\n================\nCompareVert\n================\n*/\nqboolean CompareVert( drawVert_t *v1, drawVert_t *v2, qboolean checkst ) {\n\tint i;\n\n\tfor( i = 0; i < 3; i++ ) {\n\t\tif ( floor( v1->xyz[ i ] + 0.1 ) != floor( v2->xyz[ i ] + 0.1 ) ) {\n\t\t\treturn qfalse;\n\t\t}\n\t\tif ( checkst && ( ( v1->st[ 0 ] != v2->st[ 0 ] ) || ( v1->st[ 1 ] != v2->st[ 1 ] ) ) ) {\n\t\t\treturn qfalse;\n\t\t}\n\t}\n\n\treturn qtrue;\n}\n\n/*\n================\nLoadAlphaMap\n================\n*/\nbyte *LoadAlphaMap( int *num_layers, int *alphawidth, int *alphaheight ) {\n\tint\t\t\t*alphamap32;\n\tbyte\t\t*alphamap;\n\tconst char\t*alphamapname;\n\tchar\t\text[ 128 ];\n\tint\t\t\twidth;\n\tint\t\t\theight;\n\tint\t\t\tlayers;\n\tint\t\t\tsize;\n\tint\t\t\ti;\n\n\tassert( alphawidth );\n\tassert( alphaheight );\n\tassert( num_layers );\n\n\tlayers = atoi( ValueForKey( mapent, \"layers\" ) );\n\tif ( layers < 1 ) {\n\t\tError (\"SetTerrainTextures: invalid value for 'layers' (%d)\", layers );\n\t}\n\n\talphamapname = ValueForKey( mapent, \"alphamap\" );\n\tif ( !alphamapname[ 0 ] ) {\n\t\tError (\"LoadAlphaMap: No alphamap specified on terrain\" );\n\t}\n\n\tExtractFileExtension( alphamapname, ext);\n\tif ( !Q_stricmp( ext, \"tga\" ) ) {\n\t\tLoad32BitImage( ExpandGamePath( alphamapname ), &alphamap32, &width, &height );\n\n\t\tsize = width * height;\n\t\talphamap = malloc( size );\n\t\tfor( i = 0; i < size; i++ ) {\n\t\t\talphamap[ i ] = ( ( alphamap32[ i ] & 0xff ) * layers ) / 256;\n\t\t\tif ( alphamap[ i ] >= layers ) {\n\t\t\t\talphamap[ i ] = layers - 1;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tLoad256Image( ExpandGamePath( alphamapname ), &alphamap, NULL, &width, &height );\n\t\tsize = width * height;\n\t\tfor( i = 0; i < size; i++ ) {\n\t\t\tif ( alphamap[ i ] >= layers ) {\n\t\t\t\talphamap[ i ] = layers - 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( ( width < 2 ) || ( height < 2 ) ) {\n\t\tError (\"LoadAlphaMap: alphamap width/height must be at least 2x2.\" );\n\t}\n\n\t*num_layers\t\t= layers;\n\t*alphawidth\t\t= width;\n\t*alphaheight\t= height;\n\n\treturn alphamap;\n}\n\n/*\n================\nCalcTerrainSize\n================\n*/\nvoid CalcTerrainSize( vec3_t mins, vec3_t maxs, vec3_t size ) {\n\tbspbrush_t\t*brush;\n\tint\t\t\ti;\n\tconst char  *key;\n\n\t// calculate the size of the terrain\n\tClearBounds( mins, maxs );\n\tfor( brush = mapent->brushes; brush != NULL; brush = brush->next ) {\n\t\tAddPointToBounds( brush->mins, mins, maxs );\n\t\tAddPointToBounds( brush->maxs, mins, maxs );\n\t}\n\n\tkey = ValueForKey( mapent, \"min\" ); \n\tif ( key[ 0 ] ) {\n\t\tGetVectorForKey( mapent, \"min\", mins );\n\t}\n\n\tkey = ValueForKey( mapent, \"max\" ); \n\tif ( key[ 0 ] ) {\n\t\tGetVectorForKey( mapent, \"max\", maxs );\n\t}\n\n\tfor( i = 0; i < 3; i++ ) {\n\t\tmins[ i ] =  floor( mins[ i ] + 0.1 );\n\t\tmaxs[ i ] =  floor( maxs[ i ] + 0.1 );\n\t}\n\n\tVectorSubtract( maxs, mins, size );\n\n\tif ( ( size[ 0 ] <= 0 ) || ( size[ 1 ] <= 0 ) ) {\n\t\tError (\"CalcTerrainSize: Invalid terrain size: %fx%f\", size[ 0 ], size[ 1 ] );\n\t}\n}\n\n/*\n==================\nIsTriangleDegenerate\n\nReturns qtrue if all three points are collinear or backwards\n===================\n*/\n#define\tCOLINEAR_AREA\t10\nstatic qboolean\tIsTriangleDegenerate( drawVert_t *points, int a, int b, int c ) {\n\tvec3_t\t\tv1, v2, v3;\n\tfloat\t\td;\n\n\tVectorSubtract( points[b].xyz, points[a].xyz, v1 );\n\tVectorSubtract( points[c].xyz, points[a].xyz, v2 );\n\tCrossProduct( v1, v2, v3 );\n\td = VectorLength( v3 );\n\n\t// assume all very small or backwards triangles will cause problems\n\tif ( d < COLINEAR_AREA ) {\n\t\treturn qtrue;\n\t}\n\n\treturn qfalse;\n}\n\n/*\n===============\nSideAsTriFan\n\nThe surface can't be represented as a single tristrip without\nleaving a degenerate triangle (and therefore a crack), so add\na point in the middle and create (points-1) triangles in fan order\n===============\n*/\nstatic void SideAsTriFan( terrainSurf_t *surf, int *index, int num ) {\n\tint\t\t\t\t\ti;\n\tint\t\t\t\t\tcolorSum[4];\n\tdrawVert_t\t\t\t*mid, *v;\n\n\t// make sure we have enough space for a new vert\n\tif ( surf->numVerts >= surf->maxVerts ) {\n\t\tsurf->maxVerts += GROW_VERTS;\n\t\tsurf->verts = realloc( surf->verts, surf->maxVerts * sizeof( *surf->verts ) );\n\t}\n\n\t// create a new point in the center of the face\n\tmid = &surf->verts[ surf->numVerts ];\n\tsurf->numVerts++;\n\n\tcolorSum[0] = colorSum[1] = colorSum[2] = colorSum[3] = 0;\n\n\tfor (i = 0 ; i < num; i++ ) {\n\t\tv = &surf->verts[ index[ i ] ];\n\t\tVectorAdd( mid->xyz, v->xyz, mid->xyz );\n\t\tmid->st[0] += v->st[0];\n\t\tmid->st[1] += v->st[1];\n\t\tmid->lightmap[0] += v->lightmap[0];\n\t\tmid->lightmap[1] += v->lightmap[1];\n\n\t\tcolorSum[0] += v->color[0];\n\t\tcolorSum[1] += v->color[1];\n\t\tcolorSum[2] += v->color[2];\n\t\tcolorSum[3] += v->color[3];\n\t}\n\n\tmid->xyz[0] /= num;\n\tmid->xyz[1] /= num;\n\tmid->xyz[2] /= num;\n\n\tmid->st[0] /= num;\n\tmid->st[1] /= num;\n\n\tmid->lightmap[0] /= num;\n\tmid->lightmap[1] /= num;\n\n\tmid->color[0] = colorSum[0] / num;\n\tmid->color[1] = colorSum[1] / num;\n\tmid->color[2] = colorSum[2] / num;\n\tmid->color[3] = colorSum[3] / num;\n\n\t// fill in indices in trifan order\n\tif ( surf->numIndexes + num * 3 > surf->maxIndexes ) {\n\t\tsurf->maxIndexes = surf->numIndexes + num * 3;\n\t\tsurf->indexes = realloc( surf->indexes, surf->maxIndexes * sizeof( *surf->indexes ) );\n\t}\n\n\n\tfor ( i = 0 ; i < num; i++ ) {\n\t\tsurf->indexes[ surf->numIndexes++ ] = surf->numVerts - 1;\n\t\tsurf->indexes[ surf->numIndexes++ ] = index[ i ];\n\t\tsurf->indexes[ surf->numIndexes++ ] = index[ (i+1) % ( surf->numVerts - 1 ) ];\n\t}\n}\n/*\n================\nSideAsTristrip\n\nTry to create indices that make (points-2) triangles in tristrip order\n================\n*/\n#define\tMAX_INDICES\t1024\nstatic void SideAsTristrip( terrainSurf_t *surf, int *index, int num ) {\n\tint\t\t\t\t\ti;\n\tint\t\t\t\t\trotate;\n\tint\t\t\t\t\tnumIndices;\n\tint\t\t\t\t\tni;\n\tint\t\t\t\t\ta, b, c;\n\tint\t\t\t\t\tindices[ MAX_INDICES ];\n\n\t// determine the triangle strip order\n\tnumIndices = ( num - 2 ) * 3;\n\tif ( numIndices > MAX_INDICES ) {\n\t\tError( \"MAX_INDICES exceeded for surface\" );\n\t}\n\n\t// try all possible orderings of the points looking\n\t// for a strip order that isn't degenerate\n\tfor ( rotate = 0 ; rotate < num; rotate++ ) {\n\t\tfor ( ni = 0, i = 0 ; i < num - 2 - i ; i++ ) {\n\t\t\ta = index[ ( num - 1 - i + rotate ) % num ];\n\t\t\tb = index[ ( i + rotate ) % num ];\n\t\t\tc = index[ ( num - 2 - i + rotate ) % num ];\n\n\t\t\tif ( IsTriangleDegenerate( surf->verts, a, b, c ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tindices[ni++] = a;\n\t\t\tindices[ni++] = b;\n\t\t\tindices[ni++] = c;\n\n\t\t\tif ( i + 1 != num - 1 - i ) {\n\t\t\t\ta = index[ ( num - 2 - i + rotate ) % num ];\n\t\t\t\tb = index[ ( i + rotate ) % num ];\n\t\t\t\tc = index[ ( i + 1 + rotate ) % num ];\n\n\t\t\t\tif ( IsTriangleDegenerate( surf->verts, a, b, c ) ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tindices[ni++] = a;\n\t\t\t\tindices[ni++] = b;\n\t\t\t\tindices[ni++] = c;\n\t\t\t}\n\t\t}\n\t\tif ( ni == numIndices ) {\n\t\t\tbreak;\t\t// got it done without degenerate triangles\n\t\t}\n\t}\n\n\t// if any triangle in the strip is degenerate,\n\t// render from a centered fan point instead\n\tif ( ni < numIndices ) {\n\t\tSideAsTriFan( surf, index, num );\n\t\treturn;\n\t}\n\n\t// a normal tristrip\n\tif ( surf->numIndexes + ni > surf->maxIndexes ) {\n\t\tsurf->maxIndexes = surf->numIndexes + ni;\n\t\tsurf->indexes = realloc( surf->indexes, surf->maxIndexes * sizeof( *surf->indexes ) );\n\t}\n\n\tmemcpy( surf->indexes + surf->numIndexes, indices, ni * sizeof( *surf->indexes ) );\n\tsurf->numIndexes += ni;\n}\n\n/*\n================\nCreateTerrainSurface\n================\n*/\nvoid CreateTerrainSurface( terrainSurf_t *surf, shaderInfo_t *shader ) {\n\tint\t\t\t\t\ti, j, k;\n\tdrawVert_t\t\t\t*out;\n\tdrawVert_t\t\t\t*in;\n\tmapDrawSurface_t\t*newsurf;\n\n\tnewsurf = AllocDrawSurf();\n\n\tnewsurf->miscModel\t\t= qtrue;\n\tnewsurf->shaderInfo\t\t= shader;\n\tnewsurf->lightmapNum\t= -1;\n\tnewsurf->fogNum\t\t\t= -1;\n\tnewsurf->numIndexes\t\t= surf->numIndexes;\n\tnewsurf->numVerts\t\t= surf->numVerts;\n\n\t// copy the indices\n\tnewsurf->indexes = malloc( surf->numIndexes * sizeof( *newsurf->indexes ) );\n\tmemcpy( newsurf->indexes, surf->indexes, surf->numIndexes * sizeof( *newsurf->indexes ) );\n\n\t// allocate the vertices\n\tnewsurf->verts = malloc( surf->numVerts * sizeof( *newsurf->verts ) );\n\tmemset( newsurf->verts, 0, surf->numVerts * sizeof( *newsurf->verts ) );\n\n\t// calculate the surface verts\n\tout = newsurf->verts;\n\tfor( i = 0; i < newsurf->numVerts; i++, out++ ) {\n\t\tVectorCopy( surf->verts[ i ].xyz, out->xyz );\n\n\t\t// set the texture coordinates\n\t\tout->st[ 0 ] = surf->verts[ i ].st[ 0 ];\n\t\tout->st[ 1 ] = surf->verts[ i ].st[ 1 ];\n\n\t\t// the colors will be set by the lighting pass\n\t\tout->color[0] = 255;\n\t\tout->color[1] = 255;\n\t\tout->color[2] = 255;\n\t\tout->color[3] = surf->verts[ i ].color[ 3 ];\n\n\t\t// calculate the vertex normal\n\t\tVectorClear( out->normal );\n\t\tfor( j = 0; j < numsurfaces; j++ ) {\n\t\t\tin = surfaces[ j ].verts;\n\t\t\tfor( k = 0; k < surfaces[ j ].numVerts; k++, in++ ) {\n\t\t\t\tif ( CompareVert( out, in, qfalse ) ) {\n\t\t\t\t\tVectorAdd( out->normal, in->normal, out->normal );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tVectorNormalize( out->normal, out->normal );\n\t}\n}\n\n/*\n================\nEmitTerrainVerts\n================\n*/\nvoid EmitTerrainVerts( side_t *side, terrainSurf_t *surf, int maxlayer, int alpha[ MAX_POINTS_ON_WINDING ], qboolean projecttexture ) {\n\tint\t\t\ti;\n\tint\t\t\tj;\n\tdrawVert_t\t*vert;\n\tint\t\t\t*indices;\n\tint\t\t\tnumindices;\n\tint\t\t\tmaxindices;\n\tint\t\t\txyplane;\n\tvec3_t\t\txynorm = { 0, 0, 1 };\n\tvec_t\t\tshift[ 2 ] = { 0, 0 };\n\tvec_t\t\tscale[ 2 ] = { 0.5, 0.5 };\n\tfloat\t\tvecs[ 2 ][ 4 ];\n\tstatic int numtimes = 0;\n\n\tnumtimes++;\n\n\tif ( !surf->verts ) {\n\t\tsurf->numVerts\t\t= 0;\n\t\tsurf->maxVerts\t\t= GROW_VERTS;\n\t\tsurf->verts\t\t\t= malloc( surf->maxVerts * sizeof( *surf->verts ) );\n\n\t\tsurf->numIndexes\t= 0;\n\t\tsurf->maxIndexes\t= GROW_INDICES;\n\t\tsurf->indexes\t\t= malloc( surf->maxIndexes * sizeof( *surf->indexes ) );\n\t}\n\n\t// calculate the texture coordinate vectors\n\txyplane = FindFloatPlane( xynorm, 0 );\n\tQuakeTextureVecs( &mapplanes[ xyplane ], shift, 0, scale, vecs );\n\n\t// emit the vertexes\n\tnumindices = 0;\n\tmaxindices = surf->maxIndexes;\n\tindices = malloc ( maxindices * sizeof( *indices ) );\n\n\tfor ( i = 0; i < side->winding->numpoints; i++ ) {\n\t\tvert = &surf->verts[ surf->numVerts ];\n\n\t\t// set the final alpha value--0 for texture 1, 255 for texture 2\n\t\tif ( alpha[ i ] < maxlayer ) {\n\t\t\tvert->color[3] = 0;\n\t\t} else {\n\t\t\tvert->color[3] = 255;\n\t\t}\n\n\t\tvert->xyz[ 0 ] = floor( side->winding->p[ i ][ 0 ] + 0.1f );\n\t\tvert->xyz[ 1 ] = floor( side->winding->p[ i ][ 1 ] + 0.1f );\n\t\tvert->xyz[ 2 ] = floor( side->winding->p[ i ][ 2 ] + 0.1f );\n\n\t\t// set the texture coordinates\n\t\tif ( projecttexture ) {\n\t\t\tvert->st[0] = ( vecs[0][3] + DotProduct( vecs[ 0 ], vert->xyz ) ) / surf->shader->width;\n\t\t\tvert->st[1] = ( vecs[1][3] + DotProduct( vecs[ 1 ], vert->xyz ) ) / surf->shader->height;\n\t\t} else {\n\t\t\tvert->st[0] = ( side->vecs[0][3] + DotProduct( side->vecs[ 0 ], vert->xyz ) ) / surf->shader->width;\n\t\t\tvert->st[1] = ( side->vecs[1][3] + DotProduct( side->vecs[ 1 ], vert->xyz ) ) / surf->shader->height;\n\t\t}\n\n\t\tVectorCopy( mapplanes[ side->planenum ].normal, vert->normal );\n\n\t\tfor( j = 0; j < surf->numVerts; j++ ) {\n\t\t\tif ( CompareVert( vert, &surf->verts[ j ], qtrue ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif ( numindices >= maxindices ) {\n\t\t\tmaxindices += GROW_INDICES;\n\t\t\tindices = realloc( indices, maxindices * sizeof( *indices ) );\n\t\t}\n\n\t\tif ( j != surf->numVerts ) {\n\t\t\tindices[ numindices++ ] = j;\n\t\t} else {\n\t\t\tindices[ numindices++ ] = surf->numVerts;\n\t\t\tsurf->numVerts++;\n\t\t\tif ( surf->numVerts >= surf->maxVerts ) {\n\t\t\t\tsurf->maxVerts += GROW_VERTS;\n\t\t\t\tsurf->verts = realloc( surf->verts, surf->maxVerts * sizeof( *surf->verts ) );\n\t\t\t}\n\t\t}\n\t}\n\n\tSideAsTristrip( surf, indices, numindices );\n\n\tfree( indices );\n}\n\n/*\n================\nSurfaceForShader\n================\n*/\nterrainSurf_t *SurfaceForShader( shaderInfo_t *shader, int x, int y ) {\n\tint i;\n\n\tif ( lastSurface && ( lastSurface->shader == shader ) && ( lastSurface->x == x ) && ( lastSurface->y == y ) ) {\n\t\treturn lastSurface;\n\t}\n\n\tlastSurface = surfaces;\n\tfor( i = 0; i < numsurfaces; i++, lastSurface++ ) {\n\t\tif ( ( lastSurface->shader == shader ) && ( lastSurface->x == x ) && ( lastSurface->y == y ) ) {\n\t\t\treturn lastSurface;\n\t\t}\n\t}\n\n\tif ( numsurfaces >= maxsurfaces ) {\n\t\tmaxsurfaces += GROW_SURFACES;\n\t\tsurfaces = realloc( surfaces, maxsurfaces * sizeof( *surfaces ) );\n\t\tmemset( surfaces + numsurfaces + 1, 0, ( maxsurfaces - numsurfaces - 1 ) * sizeof( *surfaces ) );\n\t}\n\n\tlastSurface= &surfaces[ numsurfaces++ ];\n\tlastSurface->shader = shader;\n\tlastSurface->x = x;\n\tlastSurface->y = y;\n\n\treturn lastSurface;\n}\n\n/*\n================\nSetTerrainTextures\n================\n*/\nvoid SetTerrainTextures( void ) {\n\tint\t\t\t\ti;\n\tint\t\t\t\tx, y;\n\tint\t\t\t\tlayer;\n\tint\t\t\t\tminlayer, maxlayer;\n\tfloat\t\t\ts, t;\n\tfloat\t\t\tmin_s, min_t;\n\tint\t\t\t\talpha[ MAX_POINTS_ON_WINDING ];\n\tshaderInfo_t\t*si, *terrainShader;\n\tbspbrush_t\t\t*brush;\n\tside_t\t\t\t*side;\n\tconst char\t\t*shadername;\n\tvec3_t\t\t\tmins, maxs;\n\tvec3_t\t\t\tsize;\n\tint\t\t\t\tsurfwidth, surfheight, surfsize;\n\tterrainSurf_t\t*surf;\n\tbyte\t\t\t*alphamap;\n\tint\t\t\t\talphawidth, alphaheight;\n\tint\t\t\t\tnum_layers;\n\textern qboolean\tonlyents;\n\n\tif ( onlyents ) {\n\t\treturn;\n\t}\n\n\tshadername = ValueForKey( mapent, \"shader\" );\n\tif ( !shadername[ 0 ] ) {\n\t\tError (\"SetTerrainTextures: shader not specified\" );\n\t}\n\n\talphamap = LoadAlphaMap( &num_layers, &alphawidth, &alphaheight );\n\n\tmapent->firstDrawSurf = numMapDrawSurfs;\n\n\t// calculate the size of the terrain\n\tCalcTerrainSize( mins, maxs, size );\n\n\tsurfwidth\t= ( size[ 0 ] + SURF_WIDTH - 1 ) / SURF_WIDTH;\n\tsurfheight\t= ( size[ 1 ] + SURF_HEIGHT - 1 ) / SURF_HEIGHT;\n\tsurfsize = surfwidth * surfheight;\n\n\tlastSurface = NULL;\n\tnumsurfaces = 0;\n\tmaxsurfaces = 0;\n\tfor( i = num_layers; i > 0; i-- ) {\n\t\tmaxsurfaces += i * surfsize;\n\t}\n\tsurfaces = malloc( maxsurfaces * sizeof( *surfaces ) );\n\tmemset( surfaces, 0, maxsurfaces * sizeof( *surfaces ) );\n\n\tterrainShader = ShaderInfoForShader( \"textures/common/terrain\" );\n\n\tfor( brush = mapent->brushes; brush != NULL; brush = brush->next ) {\n\t\t// only create surfaces for sides marked as terrain\n\t\tfor( side = brush->sides; side < &brush->sides[ brush->numsides ]; side++ ) {\n\t\t\tif ( !side->shaderInfo ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif ( ( ( side->surfaceFlags | side->shaderInfo->surfaceFlags ) & SURF_NODRAW ) && !strstr( side->shaderInfo->shader, \"terrain\" ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tminlayer = num_layers;\n\t\t\tmaxlayer = 0;\n\n\t\t\t// project each point of the winding onto the alphamap to determine which\n\t\t\t// textures to blend\n\t\t\tmin_s = 1.0;\n\t\t\tmin_t = 1.0;\n\t\t\tfor( i = 0; i < side->winding->numpoints; i++ ) {\n\t\t\t\ts = floor( side->winding->p[ i ][ 0 ] + 0.1f - mins[ 0 ] ) / size[ 0 ];\n\t\t\t\tt = floor( side->winding->p[ i ][ 1 ] + 0.1f - mins[ 0 ] ) / size[ 1 ];\n\n\t\t\t\tif ( s < 0 ) {\n\t\t\t\t\ts = 0;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif ( t < 0 ) {\n\t\t\t\t\tt = 0;\n\t\t\t\t}\n\n\t\t\t\tif ( s >= 1.0 ) {\n\t\t\t\t\ts = 1.0;\n\t\t\t\t}\n\n\t\t\t\tif ( t >= 1.0 ) {\n\t\t\t\t\tt = 1.0;\n\t\t\t\t}\n\n\t\t\t\tif ( s < min_s ) {\n\t\t\t\t\tmin_s = s;\n\t\t\t\t}\n\n\t\t\t\tif ( t < min_t ) {\n\t\t\t\t\tmin_t = t;\n\t\t\t\t}\n\n\t\t\t\tx = ( alphawidth - 1 ) * s;\n\t\t\t\ty = ( alphaheight - 1 ) * t;\n\n\t\t\t\tlayer = alphamap[ x + y * alphawidth ];\n\t\t\t\tif ( layer < minlayer ) {\n\t\t\t\t\tminlayer = layer;\n\t\t\t\t}\n\n\t\t\t\tif ( layer > maxlayer ) {\n\t\t\t\t\tmaxlayer = layer;\n\t\t\t\t}\n\n\t\t\t\talpha[ i ] = layer;\n\t\t\t}\n\n\t\t\tx = min_s * surfwidth;\n\t\t\tif ( x >= surfwidth ) {\n\t\t\t\tx = surfwidth - 1;\n\t\t\t}\n\n\t\t\ty = min_t * surfheight;\n\t\t\tif ( y >= surfheight ) {\n\t\t\t\ty = surfheight - 1;\n\t\t\t}\n\n\t\t\tif ( strstr( side->shaderInfo->shader, \"terrain\" ) ) {\n\t\t\t\tsi = ShaderForLayer( minlayer, maxlayer, shadername );\n\t\t\t\tif ( showseams ) {\n\t\t\t\t\tfor( i = 0; i < side->winding->numpoints; i++ ) {\n\t\t\t\t\t\tif ( ( alpha[ i ] != minlayer ) && ( alpha[ i ] != maxlayer ) ) {\n\t\t\t\t\t\t\tsi = ShaderInfoForShader( \"textures/common/white\" );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsurf = SurfaceForShader( si, x, y );\n\t\t\t\tEmitTerrainVerts( side, surf, maxlayer, alpha, qtrue );\n\t\t\t} else {\n\t\t\t\tsi = side->shaderInfo;\n\t\t\t\tside->shaderInfo = terrainShader;\n\t\t\t\tsurf = SurfaceForShader( si, x, y );\n\t\t\t\tEmitTerrainVerts( side, surf, maxlayer, alpha, qfalse );\n\t\t\t}\n\t\t}\n\t}\n\n\t// create the final surfaces\n\tfor( surf = surfaces, i = 0; i < numsurfaces; i++, surf++ ) {\n\t\tif ( surf->numVerts ) {\n\t\t\tCreateTerrainSurface( surf, surf->shader );\n\t\t}\n\t}\n\n\t//\n\t// clean up any allocated memory\n\t//\n\tfor( surf = surfaces, i = 0; i < numsurfaces; i++, surf++ ) {\n\t\tif ( surf->verts ) {\n\t\t\tfree( surf->verts );\n\t\t\tfree( surf->indexes );\n\t\t}\n\t}\n\tfree( alphamap );\n\tfree( surfaces );\n\n\tsurfaces = NULL;\n\tlastSurface = NULL;\n\tnumsurfaces = 0;\n\tmaxsurfaces = 0;\n}\n\n/*****************************************************************************\n\n\tNew terrain code\n\n******************************************************************************/\n\ntypedef struct terrainFace_s {\n\tshaderInfo_t\t\t\t*shaderInfo;\n\t//texdef_t\t\t\t\ttexdef;\n\n\tfloat\t\t\t\t\tvecs[ 2 ][ 4 ]; // texture coordinate mapping\n} terrainFace_t;\n\ntypedef struct terrainVert_s {\n\tvec3_t\t\t\t\t\txyz;\n\tterrainFace_t\t\t\ttri;\n} terrainVert_t;\n\ntypedef struct terrainMesh_s {\n\tfloat\t\t\t\t\tscale_x;\n\tfloat\t\t\t\t\tscale_y;\n\tvec3_t\t\t\t\t\torigin;\n\n\tint\t\t\t\t\t\twidth, height;\n\tterrainVert_t\t\t\t*map;\n} terrainMesh_t;\n\nterrainVert_t *Terrain_GetVert( terrainMesh_t *pm, int x, int y ) {\n\treturn &pm->map[ x + y * pm->width ];\n}\n\nvoid Terrain_GetTriangles( terrainMesh_t *pm, int x, int y, terrainVert_t **verts ) {\n\tif ( ( x + y ) & 1 ) {\n\t\t// first tri\n\t\tverts[ 0 ] = Terrain_GetVert( pm, x, y );\n\t\tverts[ 1 ] = Terrain_GetVert( pm, x, y + 1 );\n\t\tverts[ 2 ] = Terrain_GetVert( pm, x + 1, y + 1 );\n\n\t\t// second tri\n\t\tverts[ 3 ] = verts[ 2 ];\n\t\tverts[ 4 ] = Terrain_GetVert( pm, x + 1, y );\n\t\tverts[ 5 ] = verts[ 0 ];\n\t} else {\n\t\t// first tri\n\t\tverts[ 0 ] = Terrain_GetVert( pm, x, y );\n\t\tverts[ 1 ] = Terrain_GetVert( pm, x, y + 1 );\n\t\tverts[ 2 ] = Terrain_GetVert( pm, x + 1, y );\n\n\t\t// second tri\n\t\tverts[ 3 ] = verts[ 2 ];\n\t\tverts[ 4 ] = verts[ 1 ];\n\t\tverts[ 5 ] = Terrain_GetVert( pm, x + 1, y + 1 );\n\t}\n}\n\n/*\n================\nEmitTerrainVerts2\n================\n*/\nvoid EmitTerrainVerts2( terrainSurf_t *surf, terrainVert_t **verts, int alpha[ 3 ] ) {\n\tint\t\t\ti;\n\tint\t\t\tj;\n\tdrawVert_t\t*vert;\n\tint\t\t\t*indices;\n\tint\t\t\tnumindices;\n\tint\t\t\tmaxindices;\n\tint\t\t\txyplane;\n\tvec3_t\t\txynorm = { 0, 0, 1 };\n\tvec_t\t\tshift[ 2 ] = { 0, 0 };\n\tvec_t\t\tscale[ 2 ] = { 0.5, 0.5 };\n\tfloat\t\tvecs[ 2 ][ 4 ];\n\tvec4_t\t\tplane;\n\n\tif ( !surf->verts ) {\n\t\tsurf->numVerts\t\t= 0;\n\t\tsurf->maxVerts\t\t= GROW_VERTS;\n\t\tsurf->verts\t\t\t= malloc( surf->maxVerts * sizeof( *surf->verts ) );\n\n\t\tsurf->numIndexes\t= 0;\n\t\tsurf->maxIndexes\t= GROW_INDICES;\n\t\tsurf->indexes\t\t= malloc( surf->maxIndexes * sizeof( *surf->indexes ) );\n\t}\n\n\t// calculate the texture coordinate vectors\n\txyplane = FindFloatPlane( xynorm, 0 );\n\tQuakeTextureVecs( &mapplanes[ xyplane ], shift, 0, scale, vecs );\n\n\t// emit the vertexes\n\tnumindices = 0;\n\tmaxindices = surf->maxIndexes;\n\tassert( maxindices >= 0 );\n\tindices = malloc ( maxindices * sizeof( *indices ) );\n\n\tPlaneFromPoints( plane, verts[ 0 ]->xyz, verts[ 1 ]->xyz, verts[ 2 ]->xyz );\n\n\tfor ( i = 0; i < 3; i++ ) {\n\t\tvert = &surf->verts[ surf->numVerts ];\n\n\t\tif ( alpha[ i ] ) {\n\t\t\tvert->color[3] = 255;\n\t\t} else {\n\t\t\tvert->color[3] = 0;\n\t\t}\n\n\t\tvert->xyz[ 0 ] = floor( verts[ i ]->xyz[ 0 ] + 0.1f );\n\t\tvert->xyz[ 1 ] = floor( verts[ i ]->xyz[ 1 ] + 0.1f );\n\t\tvert->xyz[ 2 ] = floor( verts[ i ]->xyz[ 2 ] + 0.1f );\n\n\t\t// set the texture coordinates\n\t\tvert->st[0] = ( vecs[0][3] + DotProduct( vecs[ 0 ], vert->xyz ) ) / surf->shader->width;\n\t\tvert->st[1] = ( vecs[1][3] + DotProduct( vecs[ 1 ], vert->xyz ) ) / surf->shader->height;\n\n\t\tVectorCopy( plane, vert->normal );\n\n\t\tfor( j = 0; j < surf->numVerts; j++ ) {\n\t\t\tif ( CompareVert( vert, &surf->verts[ j ], qtrue ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif ( numindices >= maxindices ) {\n\t\t\tmaxindices += GROW_INDICES;\n\t\t\tindices = realloc( indices, maxindices * sizeof( *indices ) );\n\t\t}\n\n\t\tif ( j != surf->numVerts ) {\n\t\t\tindices[ numindices++ ] = j;\n\t\t} else {\n\t\t\tindices[ numindices++ ] = surf->numVerts;\n\t\t\tsurf->numVerts++;\n\t\t\tif ( surf->numVerts >= surf->maxVerts ) {\n\t\t\t\tsurf->maxVerts += GROW_VERTS;\n\t\t\t\tsurf->verts = realloc( surf->verts, surf->maxVerts * sizeof( *surf->verts ) );\n\t\t\t}\n\t\t}\n\t}\n\n\tSideAsTristrip( surf, indices, numindices );\n\n\tfree( indices );\n}\n\nint      MapPlaneFromPoints( vec3_t p0, vec3_t p1, vec3_t p2 );\nvoid     QuakeTextureVecs( plane_t *plane, vec_t shift[2], vec_t rotate, vec_t scale[2], vec_t mappingVecs[2][4] );\nqboolean RemoveDuplicateBrushPlanes( bspbrush_t *b );\nvoid     SetBrushContents( bspbrush_t *b );\n\nvoid AddBrushSide( vec3_t v1, vec3_t v2, vec3_t v3, shaderInfo_t *terrainShader ) {\n\tside_t\t*side;\n\tint\t\tplanenum;\n\n\tside = &buildBrush->sides[ buildBrush->numsides ];\n\tmemset( side, 0, sizeof( *side ) );\n\tbuildBrush->numsides++;\n\n\tside->shaderInfo = terrainShader;\n\n\t// find the plane number\n\tplanenum = MapPlaneFromPoints( v1, v2, v3 );\n\tside->planenum = planenum;\n}\n\nvoid MakeBrushFromTriangle( vec3_t v1, vec3_t v2, vec3_t v3, shaderInfo_t *terrainShader ) {\n\tbspbrush_t\t*b;\n\tvec3_t\t\td1;\n\tvec3_t\t\td2;\n\tvec3_t\t\td3;\n\n\tVectorSet( d1, v1[ 0 ], v1[ 1 ], MIN_WORLD_COORD + 10 );\t//FIXME\n\tVectorSet( d2, v2[ 0 ], v2[ 1 ], MIN_WORLD_COORD + 10 );\n\tVectorSet( d3, v3[ 0 ], v3[ 1 ], MIN_WORLD_COORD + 10 );\n\n\tbuildBrush->numsides = 0;\n\tbuildBrush->detail = qfalse;\n\n\tAddBrushSide( v1, v2, v3, terrainShader );\n\tAddBrushSide( v1, d1, v2, terrainShader );\n\tAddBrushSide( v2, d2, v3, terrainShader );\n\tAddBrushSide( v3, d3, v1, terrainShader );\n\tAddBrushSide( d3, d2, d1, terrainShader );\n\n\tbuildBrush->portalareas[0] = -1;\n\tbuildBrush->portalareas[1] = -1;\n\tbuildBrush->entitynum = num_entities-1;\n\tbuildBrush->brushnum = entitySourceBrushes;\n\n\t// if there are mirrored planes, the entire brush is invalid\n\tif ( !RemoveDuplicateBrushPlanes( buildBrush ) ) {\n\t\treturn;\n\t}\n\n\t// get the content for the entire brush\n\tSetBrushContents( buildBrush );\n\tbuildBrush->contents |= CONTENTS_DETAIL;\n\n\tb = FinishBrush();\n\tif ( !b ) {\n\t\treturn;\n\t}\n}\n\nvoid MakeTerrainIntoBrushes( terrainMesh_t *tm ) {\n\tint\t\t\t\tindex[ 6 ];\n\tint\t\t\t\ty;\n\tint\t\t\t\tx;\n\tterrainVert_t\t*verts;\n\tshaderInfo_t\t*terrainShader;\n\n\tterrainShader = ShaderInfoForShader( \"textures/common/terrain\" );\n\n\tverts = tm->map;\n\tfor( y = 0; y < tm->height - 1; y++ ) {\n\t\tfor( x = 0; x < tm->width - 1; x++ ) {\n\t\t\tif ( ( x + y ) & 1 ) {\n\t\t\t\t// first tri\n\t\t\t\tindex[ 0 ] = x + y * tm->width;\n\t\t\t\tindex[ 1 ] = x + ( y + 1 ) * tm->width;\n\t\t\t\tindex[ 2 ] = ( x + 1 ) + ( y + 1 ) * tm->width;\n\t\t\t\tindex[ 3 ] = ( x + 1 ) + ( y + 1 ) * tm->width;\n\t\t\t\tindex[ 4 ] = ( x + 1 ) + y * tm->width;\n\t\t\t\tindex[ 5 ] = x + y * tm->width;\n\t\t\t} else {\n\t\t\t\t// first tri\n\t\t\t\tindex[ 0 ] = x + y * tm->width;\n\t\t\t\tindex[ 1 ] = x + ( y + 1 ) * tm->width;\n\t\t\t\tindex[ 2 ] = ( x + 1 ) + y * tm->width;\n\t\t\t\tindex[ 3 ] = ( x + 1 ) + y * tm->width;\n\t\t\t\tindex[ 4 ] = x + ( y + 1 ) * tm->width;\n\t\t\t\tindex[ 5 ] = ( x + 1 ) + ( y + 1 ) * tm->width;\n\t\t\t}\n\n\t\t\tMakeBrushFromTriangle( verts[ index[ 0 ] ].xyz, verts[ index[ 1 ] ].xyz, verts[ index[ 2 ] ].xyz, terrainShader );\n\t\t\tMakeBrushFromTriangle( verts[ index[ 3 ] ].xyz, verts[ index[ 4 ] ].xyz, verts[ index[ 5 ] ].xyz, terrainShader );\n\t\t}\n\t}\n}\n\nvoid Terrain_ParseFace( terrainFace_t *face ) {\n\tshaderInfo_t\t*si;\n\tvec_t\t\t\tshift[ 2 ];\n\tvec_t\t\t\trotate;\n\tvec_t\t\t\tscale[ 2 ];\n\tchar\t\t\tname[ MAX_QPATH ];\n\tchar\t\t\tshader[ MAX_QPATH ];\n\tplane_t\t\t\tp;\n\n\t// read the texturedef\n\tGetToken( qfalse );\n\tstrcpy( name, token );\n\n\tGetToken( qfalse );\n\tshift[ 0 ] = atof(token);\n\tGetToken( qfalse );\n\tshift[ 1 ] = atof( token ); \n\tGetToken( qfalse );\n\trotate = atof( token );\n\tGetToken( qfalse );\n\tscale[ 0 ] = atof( token );\n\tGetToken( qfalse );\n\tscale[ 1 ] = atof( token );\n\n\t// find default flags and values\n\tsprintf( shader, \"textures/%s\", name );\n\tsi = ShaderInfoForShader( shader );\n\tface->shaderInfo = si;\n\t//face->texdef = si->texdef;\n\n\t// skip over old contents\n\tGetToken( qfalse );\n\n\t// skip over old flags\n\tGetToken( qfalse );\n\n\t// skip over old value\n\tGetToken( qfalse );\n\n\t//Surface_Parse( &face->texdef );\n\t//Surface_BuildTexdef( &face->texdef );\n\n\t// make a fake horizontal plane\n\tVectorSet( p.normal, 0, 0, 1 );\n\tp.dist = 0;\n\tp.type = PlaneTypeForNormal( p.normal );\n\n\tQuakeTextureVecs( &p, shift, rotate, scale, face->vecs );\n}\n\n#define MAX_TERRAIN_TEXTURES 128\nstatic int\t\t\tnumtextures = 0;;\nstatic shaderInfo_t\t*textures[ MAX_TERRAIN_TEXTURES ];\n\nvoid Terrain_AddTexture( shaderInfo_t *texture ) {\n\tint i;\n\n\tif ( !texture ) {\n\t\treturn;\n\t}\n\n\tfor( i = 0; i < numtextures; i++ ) {\n\t\tif ( textures[ i ] == texture ) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif ( numtextures >= MAX_TERRAIN_TEXTURES ) {\n\t\tError( \"Too many textures on terrain\" );\n\t\treturn;\n\t}\n\n\ttextures[ numtextures++ ] = texture;\n}\n\nint LayerForShader( shaderInfo_t *shader ) {\n\tint i;\n\tint l;\n\n\tl = strlen( shader->shader );\n\tfor( i = l - 1; i >= 0; i-- ) {\n\t\tif ( shader->shader[ i ] == '_' ) {\n\t\t\treturn atoi( &shader->shader[ i + 1 ] );\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\n/*\n=================\nParseTerrain\n\nCreates a mapDrawSurface_t from the terrain text\n=================\n*/\n\nvoid ParseTerrain( void ) {\n\tint\t\t\t\ti, j;\n\tint\t\t\t\tx, y;\n\tint\t\t\t\tx1, y1;\n\tterrainMesh_t\tt;\n\tint\t\t\t\tindex;\n\tterrainVert_t\t*verts[ 6 ];\n\tint\t\t\t\tnum_layers;\n\tint\t\t\t\tlayer, minlayer, maxlayer;\n\tint\t\t\t\talpha[ 6 ];\n\tshaderInfo_t\t*si, *terrainShader;\n\tint\t\t\t\tsurfwidth, surfheight, surfsize;\n\tterrainSurf_t\t*surf;\n\tchar\t\t\tshadername[ MAX_QPATH ];\n\n\tmapent->firstDrawSurf = numMapDrawSurfs;\n\n\tmemset( &t, 0, sizeof( t ) );\n\n\tMatchToken( \"{\" );\n\n\t// get width\n\tGetToken( qtrue );\n\tt.width = atoi( token );\n\n\t// get height\n\tGetToken( qfalse );\n\tt.height = atoi( token );\n\n\t// get scale_x\n\tGetToken( qfalse );\n\tt.scale_x = atof( token );\n\n\t// get scale_y\n\tGetToken( qfalse );\n\tt.scale_y = atof( token );\n\n\t// get origin\n\tGetToken( qtrue );\n\tt.origin[ 0 ] = atof( token );\n\tGetToken( qfalse );\n\tt.origin[ 1 ] = atof( token );\n\tGetToken( qfalse );\n\tt.origin[ 2 ] = atof( token );\n\n\tt.map = malloc( t.width * t.height * sizeof( t.map[ 0 ] ) );\n\n\tif ( t.width <= 0 || t.height <= 0 ) {\n\t\tError( \"ParseTerrain: bad size\" );\n\t}\n\n\tnumtextures = 0;\n\tindex = 0;\n\tfor ( i = 0; i < t.height; i++ ) {\n\t\tfor( j = 0; j < t.width; j++, index++ ) {\n\t\t\t// get height\n\t\t\tGetToken( qtrue );\n\t\t\tt.map[ index ].xyz[ 0 ] = t.origin[ 0 ] + t.scale_x * ( float )j;\n\t\t\tt.map[ index ].xyz[ 1 ] = t.origin[ 1 ] + t.scale_y * ( float )i;\n\t\t\tt.map[ index ].xyz[ 2 ] = t.origin[ 2 ] + atof( token );\n\n\t\t\tTerrain_ParseFace( &t.map[ index ].tri );\n\t\t\tTerrain_AddTexture( t.map[ index ].tri.shaderInfo );\n\t\t}\n\t}\n\n\tMatchToken( \"}\" );\n\tMatchToken( \"}\" );\n\n\tMakeTerrainIntoBrushes( &t );\n\n\tsurfwidth\t= ( ( t.scale_x * t.width ) + SURF_WIDTH - 1 ) / SURF_WIDTH;\n\tsurfheight\t= ( ( t.scale_y * t.height ) + SURF_HEIGHT - 1 ) / SURF_HEIGHT;\n\tsurfsize = surfwidth * surfheight;\n\n\t//FIXME\n\tnum_layers = 0;\n\tfor( i = 0; i < numtextures; i++ ) {\n\t\tlayer = LayerForShader( textures[ i ] ) + 1;\n\t\tif ( layer > num_layers ) {\n\t\t\tnum_layers = layer;\n\t\t}\n\t}\n\tnum_layers = 4;\n\n\tmemset( alpha, 0, sizeof( alpha ) );\n\n\tlastSurface = NULL;\n\tnumsurfaces = 0;\n\tmaxsurfaces = 0;\n\tfor( i = num_layers; i > 0; i-- ) {\n\t\tmaxsurfaces += i * surfsize;\n\t}\n\n\tsurfaces = malloc( maxsurfaces * sizeof( *surfaces ) );\n\tmemset( surfaces, 0, maxsurfaces * sizeof( *surfaces ) );\n\n\tterrainShader = ShaderInfoForShader( \"textures/common/terrain\" );\n\n\t// get the shadername\n\tif ( Q_strncasecmp( textures[ 0 ]->shader, \"textures/\", 9 ) == 0 ) {\n\t\tstrcpy( shadername, &textures[ 0 ]->shader[ 9 ] );\n\t} else {\n\t\tstrcpy( shadername, textures[ 0 ]->shader );\n\t}\n\tj = strlen( shadername );\n\tfor( i = j - 1; i >= 0; i-- ) {\n\t\tif ( shadername[ i ] == '_' ) {\n\t\t\tshadername[ i ] = 0;\n\t\t\tbreak;\n\t\t}\n\t}\n\t\n\tfor( y = 0; y < t.height - 1; y++ ) {\n\t\tfor( x = 0; x < t.width - 1; x++ ) {\n\t\t\tTerrain_GetTriangles( &t, x, y, verts );\n\n\t\t\tx1 = ( ( float )x / ( float )( t.width - 1 ) ) * surfwidth;\n\t\t\tif ( x1 >= surfwidth ) {\n\t\t\t\tx1 = surfwidth - 1;\n\t\t\t}\n\n\t\t\ty1 = ( ( float )y / ( float )( t.height - 1 ) ) * surfheight;\n\t\t\tif ( y1 >= surfheight ) {\n\t\t\t\ty1 = surfheight - 1;\n\t\t\t}\n\n\t\t\tmaxlayer = minlayer = LayerForShader( verts[ 0 ]->tri.shaderInfo );\n\t\t\tfor( i = 0; i < 3; i++ ) {\n\t\t\t\tlayer = LayerForShader( verts[ i ]->tri.shaderInfo );\n\t\t\t\tif ( layer < minlayer ) {\n\t\t\t\t\tminlayer = layer;\n\t\t\t\t}\n\t\t\t\tif ( layer > maxlayer ) {\n\t\t\t\t\tmaxlayer = layer;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor( i = 0; i < 3; i++ ) {\n\t\t\t\tlayer = LayerForShader( verts[ i ]->tri.shaderInfo );\n\t\t\t\tif ( layer > minlayer ) {\n\t\t\t\t\talpha[ i ] = 1.0f;\n\t\t\t\t} else {\n\t\t\t\t\talpha[ i ] = 0.0f;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tsi = ShaderForLayer( minlayer, maxlayer, shadername );\n\t\t\tsurf = SurfaceForShader( si, x1, y1 );\n\t\t\tEmitTerrainVerts2( surf, &verts[ 0 ], &alpha[ 0 ] );\n\n\t\t\t// second triangle\n\t\t\tmaxlayer = minlayer = LayerForShader( verts[ 3 ]->tri.shaderInfo );\n\t\t\tfor( i = 3; i < 6; i++ ) {\n\t\t\t\tlayer = LayerForShader( verts[ i ]->tri.shaderInfo );\n\t\t\t\tif ( layer < minlayer ) {\n\t\t\t\t\tminlayer = layer;\n\t\t\t\t}\n\t\t\t\tif ( layer > maxlayer ) {\n\t\t\t\t\tmaxlayer = layer;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor( i = 3; i < 6; i++ ) {\n\t\t\t\tlayer = LayerForShader( verts[ i ]->tri.shaderInfo );\n\t\t\t\tif ( layer > minlayer ) {\n\t\t\t\t\talpha[ i ] = 1.0f;\n\t\t\t\t} else {\n\t\t\t\t\talpha[ i ] = 0.0f;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tsi = ShaderForLayer( minlayer, maxlayer, shadername );\n\t\t\tsurf = SurfaceForShader( si, x1, y1 );\n\t\t\tEmitTerrainVerts2( surf, &verts[ 3 ], &alpha[ 3 ] );\n\t\t}\n\t}\n\n\t// create the final surfaces\n\tfor( surf = surfaces, i = 0; i < numsurfaces; i++, surf++ ) {\n\t\tif ( surf->numVerts ) {\n\t\t\tCreateTerrainSurface( surf, surf->shader );\n\t\t}\n\t}\n\n\t//\n\t// clean up any allocated memory\n\t//\n\tfor( surf = surfaces, i = 0; i < numsurfaces; i++, surf++ ) {\n\t\tif ( surf->verts ) {\n\t\t\tfree( surf->verts );\n\t\t\tfree( surf->indexes );\n\t\t}\n\t}\n\tfree( surfaces );\n\n\tsurfaces = NULL;\n\tlastSurface = NULL;\n\tnumsurfaces = 0;\n\tmaxsurfaces = 0;\n\n    free( t.map );\n}\n\n"
  },
  {
    "path": "q3map/tjunction.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"qbsp.h\"\n\ntypedef struct edgePoint_s {\n\tfloat\t\tintercept;\n\tvec3_t\t\txyz;\n\tstruct edgePoint_s\t*prev, *next;\n} edgePoint_t;\n\ntypedef struct edgeLine_s {\n\tvec3_t\t\tnormal1;\n\tfloat\t\tdist1;\n\t\n\tvec3_t\t\tnormal2;\n\tfloat\t\tdist2;\n\t\n\tvec3_t\t\torigin;\n\tvec3_t\t\tdir;\n\n\tedgePoint_t\tchain;\t\t// unused element of doubly linked list\n} edgeLine_t;\n\ntypedef struct {\n\tfloat\t\tlength;\n\tdrawVert_t\t*dv[2];\n} originalEdge_t;\n\n#define\tMAX_ORIGINAL_EDGES\t0x10000\noriginalEdge_t\toriginalEdges[MAX_ORIGINAL_EDGES];\nint\t\t\t\tnumOriginalEdges;\n\n\n#define\tMAX_EDGE_LINES\t\t0x10000\nedgeLine_t\t\tedgeLines[MAX_EDGE_LINES];\nint\t\t\t\tnumEdgeLines;\n\nint\t\t\t\tc_degenerateEdges;\nint\t\t\t\tc_addedVerts;\nint\t\t\t\tc_totalVerts;\n\nint\t\t\t\tc_natural, c_rotate, c_cant;\n\n// these should be whatever epsilon we actually expect,\n// plus SNAP_INT_TO_FLOAT \n#define\tLINE_POSITION_EPSILON\t0.25\n#define\tPOINT_ON_LINE_EPSILON\t0.25\n\n/*\n====================\nInsertPointOnEdge\n====================\n*/\nvoid InsertPointOnEdge( vec3_t v, edgeLine_t *e ) {\n\tvec3_t\t\tdelta;\n\tfloat\t\td;\n\tedgePoint_t\t*p, *scan;\n\n\tVectorSubtract( v, e->origin, delta );\n\td = DotProduct( delta, e->dir );\n\n\tp = malloc( sizeof(edgePoint_t) );\n\tp->intercept = d;\n\tVectorCopy( v, p->xyz );\n\n\tif ( e->chain.next == &e->chain ) {\n\t\te->chain.next = e->chain.prev = p;\n\t\tp->next = p->prev = &e->chain;\n\t\treturn;\n\t}\n\n\tscan = e->chain.next;\n\tfor ( ; scan != &e->chain ; scan = scan->next ) {\n\t\td = p->intercept - scan->intercept;\n\t\tif ( d > -LINE_POSITION_EPSILON && d < LINE_POSITION_EPSILON ) {\n\t\t\tfree( p );\n\t\t\treturn;\t\t// the point is already set\n\t\t}\n\n\t\tif ( p->intercept < scan->intercept ) {\n\t\t\t// insert here\n\t\t\tp->prev = scan->prev;\n\t\t\tp->next = scan;\n\t\t\tscan->prev->next = p;\n\t\t\tscan->prev = p;\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// add at the end\n\tp->prev = scan->prev;\n\tp->next = scan;\n\tscan->prev->next = p;\n\tscan->prev = p;\n}\n\n\n/*\n====================\nAddEdge\n====================\n*/\nint AddEdge( vec3_t v1, vec3_t v2, qboolean createNonAxial ) {\n\tint\t\t\ti;\n\tedgeLine_t\t*e;\n\tfloat\t\td;\n\tvec3_t\t\tdir;\n\n\tVectorSubtract( v2, v1, dir );\n\td = VectorNormalize( dir, dir );\n\tif ( d < 0.1 ) {\n\t\t// if we added a 0 length vector, it would make degenerate planes\n\t\tc_degenerateEdges++;\n\t\treturn -1;\n\t}\n\n\tif ( !createNonAxial ) {\n\t\tif ( fabs( dir[0] + dir[1] + dir[2] ) != 1.0 ) {\n\t\t\tif ( numOriginalEdges == MAX_ORIGINAL_EDGES ) {\n\t\t\t\tError( \"MAX_ORIGINAL_EDGES\" );\n\t\t\t}\n\t\t\toriginalEdges[ numOriginalEdges ].dv[0] = (drawVert_t *)v1;\n\t\t\toriginalEdges[ numOriginalEdges ].dv[1] = (drawVert_t *)v2;\n\t\t\toriginalEdges[ numOriginalEdges ].length = d;\n\t\t\tnumOriginalEdges++;\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\tfor ( i = 0 ; i < numEdgeLines ; i++ ) {\n\t\te = &edgeLines[i];\n\n\t\td = DotProduct( v1, e->normal1 ) - e->dist1;\n\t\tif ( d < -POINT_ON_LINE_EPSILON || d > POINT_ON_LINE_EPSILON ) {\n\t\t\tcontinue;\n\t\t}\n\t\td = DotProduct( v1, e->normal2 ) - e->dist2;\n\t\tif ( d < -POINT_ON_LINE_EPSILON || d > POINT_ON_LINE_EPSILON ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\td = DotProduct( v2, e->normal1 ) - e->dist1;\n\t\tif ( d < -POINT_ON_LINE_EPSILON || d > POINT_ON_LINE_EPSILON ) {\n\t\t\tcontinue;\n\t\t}\n\t\td = DotProduct( v2, e->normal2 ) - e->dist2;\n\t\tif ( d < -POINT_ON_LINE_EPSILON || d > POINT_ON_LINE_EPSILON ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// this is the edge\n\t\tInsertPointOnEdge( v1, e );\n\t\tInsertPointOnEdge( v2, e );\n\t\treturn i;\n\t}\n\n\t// create a new edge\n\tif ( numEdgeLines >= MAX_EDGE_LINES ) {\n\t\tError( \"MAX_EDGE_LINES\" );\n\t}\n\n\te = &edgeLines[ numEdgeLines ];\n\tnumEdgeLines++;\n\n\te->chain.next = e->chain.prev = &e->chain;\n\n\tVectorCopy( v1, e->origin );\n\tVectorCopy( dir, e->dir );\n\n\tMakeNormalVectors( e->dir, e->normal1, e->normal2 );\n\te->dist1 = DotProduct( e->origin, e->normal1 );\n\te->dist2 = DotProduct( e->origin, e->normal2 );\n\n\tInsertPointOnEdge( v1, e );\n\tInsertPointOnEdge( v2, e );\n\n\treturn numEdgeLines - 1;\n}\n\n/*\n====================\nAddSurfaceEdges\n====================\n*/\nvoid AddSurfaceEdges( mapDrawSurface_t *ds ) {\n\tint\t\ti;\n\n\tfor ( i = 0 ; i < ds->numVerts ; i++ ) {\n\t\t// save the edge number in the lightmap field\n\t\t// so we don't need to look it up again\n\t\tds->verts[i].lightmap[0] = \n\t\t\tAddEdge( ds->verts[i].xyz, ds->verts[(i+1) % ds->numVerts].xyz, qfalse );\n\t}\n}\n\n/*\n================\nColinearEdge\n================\n*/\nqboolean ColinearEdge( vec3_t v1, vec3_t v2, vec3_t v3 ) {\n\tvec3_t\tmidpoint, dir, offset, on;\n\tfloat\td;\n\n\tVectorSubtract( v2, v1, midpoint );\n\tVectorSubtract( v3, v1, dir );\n\td = VectorNormalize( dir, dir );\n\tif ( d == 0 ) {\n\t\treturn qfalse;\t// degenerate\n\t}\n\n\td = DotProduct( midpoint, dir );\n\tVectorScale( dir, d, on );\n\tVectorSubtract( midpoint, on, offset );\n\td = VectorLength ( offset );\n\n\tif ( d < 0.1 ) {\n\t\treturn qtrue;\n\t}\n\n\treturn qfalse;\n}\n\n/*\n====================\nAddPatchEdges\n\nAdd colinear border edges, which will fix some classes of patch to\nbrush tjunctions\n====================\n*/\nvoid AddPatchEdges( mapDrawSurface_t *ds ) {\n\tint\t\ti;\n\tfloat\t*v1, *v2, *v3;\n\n\tfor ( i = 0 ; i < ds->patchWidth - 2; i+=2 ) {\n\t\tv1 = ds->verts[ i ].xyz;\n\t\tv2 = ds->verts[ i + 1 ].xyz;\n\t\tv3 = ds->verts[ i + 2 ].xyz;\n\n\t\t// if v2 is the midpoint of v1 to v3, add an edge from v1 to v3\n\t\tif ( ColinearEdge( v1, v2, v3 ) ) {\n\t\t\tAddEdge( v1, v3, qfalse );\n\t\t}\n\n\t\tv1 = ds->verts[ ( ds->patchHeight - 1 ) * ds->patchWidth + i ].xyz;\n\t\tv2 = ds->verts[ ( ds->patchHeight - 1 ) * ds->patchWidth + i + 1 ].xyz;\n\t\tv3 = ds->verts[ ( ds->patchHeight - 1 ) * ds->patchWidth + i + 2 ].xyz;\n\n\t\t// if v2 is on the v1 to v3 line, add an edge from v1 to v3\n\t\tif ( ColinearEdge( v1, v2, v3 ) ) {\n\t\t\tAddEdge( v1, v3, qfalse );\n\t\t}\n\t}\n\n\tfor ( i = 0 ; i < ds->patchHeight - 2 ; i+=2 ) {\n\t\tv1 = ds->verts[ i * ds->patchWidth ].xyz;\n\t\tv2 = ds->verts[ ( i + 1 ) * ds->patchWidth ].xyz;\n\t\tv3 = ds->verts[ ( i + 2 ) * ds->patchWidth ].xyz;\n\n\t\t// if v2 is the midpoint of v1 to v3, add an edge from v1 to v3\n\t\tif ( ColinearEdge( v1, v2, v3 ) ) {\n\t\t\tAddEdge( v1, v3, qfalse );\n\t\t}\n\n\t\tv1 = ds->verts[ ( ds->patchWidth - 1 ) + i * ds->patchWidth ].xyz;\n\t\tv2 = ds->verts[ ( ds->patchWidth - 1 ) + ( i + 1 ) * ds->patchWidth ].xyz;\n\t\tv3 = ds->verts[ ( ds->patchWidth - 1 ) + ( i + 2 ) * ds->patchWidth ].xyz;\n\n\t\t// if v2 is the midpoint of v1 to v3, add an edge from v1 to v3\n\t\tif ( ColinearEdge( v1, v2, v3 ) ) {\n\t\t\tAddEdge( v1, v3, qfalse );\n\t\t}\n\t}\n\n\n}\n\n\n/*\n====================\nFixSurfaceJunctions\n====================\n*/\n#define\tMAX_SURFACE_VERTS\t256\nvoid FixSurfaceJunctions( mapDrawSurface_t *ds ) {\n\tint\t\t\ti, j, k;\n\tedgeLine_t\t*e;\n\tedgePoint_t\t*p;\n\tint\t\t\toriginalVerts;\n\tint\t\t\tcounts[MAX_SURFACE_VERTS];\n\tint\t\t\toriginals[MAX_SURFACE_VERTS];\n\tint\t\t\tfirstVert[MAX_SURFACE_VERTS];\n\tdrawVert_t\tverts[MAX_SURFACE_VERTS], *v1, *v2;\n\tint\t\t\tnumVerts;\n\tfloat\t\tstart, end, frac;\n\tvec3_t\t\tdelta;\n\n\toriginalVerts = ds->numVerts;\n\n\tnumVerts = 0;\n\tfor ( i = 0 ; i < ds->numVerts ; i++ ) {\n\t\tcounts[i] = 0;\n\t\tfirstVert[i] = numVerts;\n\n\t\t// copy first vert\n\t\tif ( numVerts == MAX_SURFACE_VERTS ) {\n\t\t\tError( \"MAX_SURFACE_VERTS\" );\n\t\t}\n\t\tverts[numVerts] = ds->verts[i];\n\t\toriginals[numVerts] = i;\n\t\tnumVerts++;\n\n\t\t// check to see if there are any t junctions before the next vert\n\t\tv1 = &ds->verts[i];\n\t\tv2 = &ds->verts[ (i+1) % ds->numVerts ];\n\n\t\tj = (int)ds->verts[i].lightmap[0];\n\t\tif ( j == -1 ) {\n\t\t\tcontinue;\t\t// degenerate edge\n\t\t}\n\t\te = &edgeLines[ j ];\n\t\t\n\t\tVectorSubtract( v1->xyz, e->origin, delta );\n\t\tstart = DotProduct( delta, e->dir );\n\n\t\tVectorSubtract( v2->xyz, e->origin, delta );\n\t\tend = DotProduct( delta, e->dir );\n\n\n\t\tif ( start < end ) {\n\t\t\tp = e->chain.next;\n\t\t} else {\n\t\t\tp = e->chain.prev;\n\t\t}\n\n\t\tfor (  ; p != &e->chain ;  ) {\n\t\t\tif ( start < end ) {\n\t\t\t\tif ( p->intercept > end - ON_EPSILON ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( p->intercept < end + ON_EPSILON ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( \n\t\t\t\t( start < end && p->intercept > start + ON_EPSILON ) ||\n\t\t\t\t( start > end && p->intercept < start - ON_EPSILON ) ) {\n\t\t\t\t// insert this point\n\t\t\t\tif ( numVerts == MAX_SURFACE_VERTS ) {\n\t\t\t\t\tError( \"MAX_SURFACE_VERTS\" );\n\t\t\t\t}\n\n\t\t\t\t// take the exact intercept point\n\t\t\t\tVectorCopy( p->xyz, verts[ numVerts ].xyz );\n\n\t\t\t\t// copy the normal\n\t\t\t\tVectorCopy( v1->normal, verts[ numVerts ].normal );\n\n\t\t\t\t// interpolate the texture coordinates\n\t\t\t\tfrac = ( p->intercept - start ) / ( end - start );\n\t\t\t\tfor ( j = 0 ; j < 2 ; j++ ) {\n\t\t\t\t\tverts[ numVerts ].st[j] = v1->st[j] + \n\t\t\t\t\t\tfrac * ( v2->st[j] - v1->st[j] );\n\t\t\t\t}\n\t\t\t\toriginals[numVerts] = i;\n\t\t\t\tnumVerts++;\n\t\t\t\tcounts[i]++;\n\t\t\t}\n\n\t\t\tif ( start < end ) {\n\t\t\t\tp = p->next;\n\t\t\t} else {\n\t\t\t\tp = p->prev;\n\t\t\t}\n\t\t}\n\t}\n\n\tc_addedVerts += numVerts - ds->numVerts;\n\tc_totalVerts += numVerts;\n\n\n\t// FIXME: check to see if the entire surface degenerated\n\t// after snapping\n\n\t// rotate the points so that the initial vertex is between\n\t// two non-subdivided edges\n\tfor ( i = 0 ; i < numVerts ; i++ ) {\n\t\tif ( originals[ (i+1) % numVerts ] == originals[ i ] ) {\n\t\t\tcontinue;\n\t\t}\n\t\tj = (i + numVerts - 1 ) % numVerts;\n\t\tk = (i + numVerts - 2 ) % numVerts;\n\t\tif ( originals[ j ] == originals[ k ] ) {\n\t\t\tcontinue;\n\t\t}\n\t\tbreak;\n\t}\n\n\tif ( i == 0 ) {\n\t\t// fine the way it is\n\t\tc_natural++;\n\n\t\tds->numVerts = numVerts;\n\t\tds->verts = malloc( numVerts * sizeof( *ds->verts ) );\n\t\tmemcpy( ds->verts, verts, numVerts * sizeof( *ds->verts ) );\n\n\t\treturn;\n\t}\n\tif ( i == numVerts ) {\n\t\t// create a vertex in the middle to start the fan\n\t\tc_cant++;\n\n/*\n\t\tmemset ( &verts[numVerts], 0, sizeof( verts[numVerts] ) );\n\t\tfor ( i = 0 ; i < numVerts ; i++ ) {\n\t\t\tfor ( j = 0 ; j < 10 ; j++ ) {\n\t\t\t\tverts[numVerts].xyz[j] += verts[i].xyz[j];\n\t\t\t}\n\t\t}\n\t\tfor ( j = 0 ; j < 10 ; j++ ) {\n\t\t\tverts[numVerts].xyz[j] /= numVerts;\n\t\t}\n\n\t\ti = numVerts;\n\t\tnumVerts++;\n*/\n\t} else {\n\t\t// just rotate the vertexes\n\t\tc_rotate++;\n\n\t}\n\n\tds->numVerts = numVerts;\n\tds->verts = malloc( numVerts * sizeof( *ds->verts ) );\n\n\tfor ( j = 0 ; j < ds->numVerts ; j++ ) {\n\t\tds->verts[j] = verts[ ( j + i ) % ds->numVerts ];\n\t}\n}\n\n/*\n================\nEdgeCompare\n================\n*/\nint EdgeCompare( const void *elem1, const void *elem2 ) {\n\tfloat\td1, d2;\n\n\td1 = ((originalEdge_t *)elem1)->length;\n\td2 = ((originalEdge_t *)elem2)->length;\n\n\tif ( d1 < d2 ) {\n\t\treturn -1;\n\t}\n\tif ( d2 > d1 ) {\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\n\n/*\n================\nFixTJunctions\n\nCall after the surface list has been pruned, but before lightmap allocation\n================\n*/\nvoid FixTJunctions( entity_t *ent ) {\n\tint\t\t\t\t\ti;\n\tmapDrawSurface_t\t*ds;\n\tint\t\t\t\t\taxialEdgeLines;\n\toriginalEdge_t\t\t*e;\n\n\tqprintf(\"----- FixTJunctions -----\\n\");\n\n\tnumEdgeLines = 0;\n\tnumOriginalEdges = 0;\n\n\t// add all the edges\n\t// this actually creates axial edges, but it\n\t// only creates originalEdge_t structures\n\t// for non-axial edges\n\tfor ( i = ent->firstDrawSurf ; i < numMapDrawSurfs ; i++ ) {\n\t\tds = &mapDrawSurfs[i];\n\t\tif ( ds->patch ) {\n\t\t\tAddPatchEdges( ds );\n\t\t} else if ( ds->shaderInfo->autosprite || ds->shaderInfo->notjunc || ds->miscModel ) {\n\t\t\t// miscModels don't add tjunctions\n\t\t} else {\n\t\t\tAddSurfaceEdges( ds );\n\t\t}\n\t}\n\n\taxialEdgeLines = numEdgeLines;\n\n\t// sort the non-axial edges by length\n\tqsort( originalEdges, numOriginalEdges, sizeof(originalEdges[0]), EdgeCompare );\n\n\t// add the non-axial edges, longest first\n\t// this gives the most accurate edge description\n\tfor ( i = 0 ; i < numOriginalEdges ; i++ ) {\n\t\te = &originalEdges[i];\n\t\te->dv[0]->lightmap[0] = AddEdge( e->dv[0]->xyz, e->dv[1]->xyz, qtrue );\n\t}\n\n\tqprintf( \"%6i axial edge lines\\n\", axialEdgeLines );\n\tqprintf( \"%6i non-axial edge lines\\n\", numEdgeLines - axialEdgeLines );\n\tqprintf( \"%6i degenerate edges\\n\", c_degenerateEdges );\n\n\t// insert any needed vertexes\n\tfor ( i = ent->firstDrawSurf ; i < numMapDrawSurfs ; i++ ) {\n\t\tds = &mapDrawSurfs[i];\n\t\tif ( ds->patch ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( ds->shaderInfo->autosprite || ds->shaderInfo->notjunc || ds->miscModel ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tFixSurfaceJunctions( ds );\n\t}\n\n\tqprintf( \"%6i verts added for tjunctions\\n\", c_addedVerts );\n\tqprintf( \"%6i total verts\\n\", c_totalVerts );\n\tqprintf( \"%6i naturally ordered\\n\", c_natural );\n\tqprintf( \"%6i rotated orders\\n\", c_rotate );\n\tqprintf( \"%6i can't order\\n\", c_cant );\n}\n"
  },
  {
    "path": "q3map/tree.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"qbsp.h\"\n\n\nextern\tint\tc_nodes;\n\nvoid RemovePortalFromNode (portal_t *portal, node_t *l);\n\nnode_t *NodeForPoint (node_t *node, vec3_t origin)\n{\n\tplane_t\t*plane;\n\tvec_t\td;\n\n\twhile (node->planenum != PLANENUM_LEAF)\n\t{\n\t\tplane = &mapplanes[node->planenum];\n\t\td = DotProduct (origin, plane->normal) - plane->dist;\n\t\tif (d >= 0)\n\t\t\tnode = node->children[0];\n\t\telse\n\t\t\tnode = node->children[1];\n\t}\n\n\treturn node;\n}\n\n\n\n/*\n=============\nFreeTreePortals_r\n=============\n*/\nvoid FreeTreePortals_r (node_t *node)\n{\n\tportal_t\t*p, *nextp;\n\tint\t\t\ts;\n\n\t// free children\n\tif (node->planenum != PLANENUM_LEAF)\n\t{\n\t\tFreeTreePortals_r (node->children[0]);\n\t\tFreeTreePortals_r (node->children[1]);\n\t}\n\n\t// free portals\n\tfor (p=node->portals ; p ; p=nextp)\n\t{\n\t\ts = (p->nodes[1] == node);\n\t\tnextp = p->next[s];\n\n\t\tRemovePortalFromNode (p, p->nodes[!s]);\n\t\tFreePortal (p);\n\t}\n\tnode->portals = NULL;\n}\n\n/*\n=============\nFreeTree_r\n=============\n*/\nvoid FreeTree_r (node_t *node)\n{\n\t// free children\n\tif (node->planenum != PLANENUM_LEAF)\n\t{\n\t\tFreeTree_r (node->children[0]);\n\t\tFreeTree_r (node->children[1]);\n\t}\n\n\t// free bspbrushes\n\tFreeBrushList (node->brushlist);\n\n\t// free the node\n\tif (node->volume)\n\t\tFreeBrush (node->volume);\n\n\tif (numthreads == 1)\n\t\tc_nodes--;\n\tfree (node);\n}\n\n\n/*\n=============\nFreeTree\n=============\n*/\nvoid FreeTree (tree_t *tree)\n{\n\tFreeTreePortals_r (tree->headnode);\n\tFreeTree_r (tree->headnode);\n\tfree (tree);\n}\n\n//===============================================================\n\nvoid PrintTree_r (node_t *node, int depth)\n{\n\tint\t\ti;\n\tplane_t\t*plane;\n\tbspbrush_t\t*bb;\n\n\tfor (i=0 ; i<depth ; i++)\n\t\t_printf (\"  \");\n\tif (node->planenum == PLANENUM_LEAF)\n\t{\n\t\tif (!node->brushlist)\n\t\t\t_printf (\"NULL\\n\");\n\t\telse\n\t\t{\n\t\t\tfor (bb=node->brushlist ; bb ; bb=bb->next)\n\t\t\t\t_printf (\"%i \", bb->original->brushnum);\n\t\t\t_printf (\"\\n\");\n\t\t}\n\t\treturn;\n\t}\n\n\tplane = &mapplanes[node->planenum];\n\t_printf (\"#%i (%5.2f %5.2f %5.2f):%5.2f\\n\", node->planenum,\n\t\tplane->normal[0], plane->normal[1], plane->normal[2],\n\t\tplane->dist);\n\tPrintTree_r (node->children[0], depth+1);\n\tPrintTree_r (node->children[1], depth+1);\n}\n"
  },
  {
    "path": "q3map/vis.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// vis.c\n\n#include \"vis.h\"\n#include \"threads.h\"\n#include \"stdlib.h\"\n#ifdef _WIN32\n#include \"../libs/pakstuff.h\"\n#endif\n\n\n#define\tVIS_HEADER_SIZE\t8\n\nextern\tchar\t\toutbase[32];\n\nint\t\t\tnumportals;\nint\t\t\tportalclusters;\nint\t\t\tnumfaces;\n\nchar\t\tinbase[32];\n\nvportal_t\t*portals;\nleaf_t\t\t*leafs;\n\nvportal_t\t*faces;\nleaf_t\t\t*faceleafs;\n\nint\t\t\tc_portaltest, c_portalpass, c_portalcheck;\n\nint\t\tleafbytes;\t\t\t\t// (portalclusters+63)>>3\nint\t\tleaflongs;\n\nint\t\tportalbytes, portallongs;\n\nqboolean\t\tfastvis;\nqboolean\t\tnoPassageVis;\nqboolean\t\tpassageVisOnly;\nqboolean\t\tmergevis;\nqboolean\t\tnosort;\nqboolean\t\tsaveprt;\n\nint\t\t\ttestlevel = 2;\n\nint\t\ttotalvis;\n\nvportal_t\t*sorted_portals[MAX_MAP_PORTALS*2];\n\nvoid PassageMemory(void);\n\n\n//=============================================================================\n\nvoid PlaneFromWinding (winding_t *w, plane_t *plane)\n{\n\tvec3_t\t\tv1, v2;\n\n// calc plane\n\tVectorSubtract (w->points[2], w->points[1], v1);\n\tVectorSubtract (w->points[0], w->points[1], v2);\n\tCrossProduct (v2, v1, plane->normal);\n\tVectorNormalize (plane->normal, plane->normal);\n\tplane->dist = DotProduct (w->points[0], plane->normal);\n}\n\n\n/*\n==================\nNewWinding\n==================\n*/\nwinding_t *NewWinding (int points)\n{\n\twinding_t\t*w;\n\tint\t\t\tsize;\n\t\n\tif (points > MAX_POINTS_ON_WINDING)\n\t\tError (\"NewWinding: %i points\", points);\n\t\n\tsize = (int)((winding_t *)0)->points[points];\n\tw = malloc (size);\n\tmemset (w, 0, size);\n\t\n\treturn w;\n}\n\n\n\nvoid prl(leaf_t *l)\n{\n\tint\t\t\ti;\n\tvportal_t\t*p;\n\tplane_t\t\tpl;\n\t\n\tfor (i=0 ; i<l->numportals ; i++)\n\t{\n\t\tp = l->portals[i];\n\t\tpl = p->plane;\n\t\t_printf (\"portal %4i to leaf %4i : %7.1f : (%4.1f, %4.1f, %4.1f)\\n\",(int)(p-portals),p->leaf,pl.dist, pl.normal[0], pl.normal[1], pl.normal[2]);\n\t}\n}\n\n\n//=============================================================================\n\n/*\n=============\nSortPortals\n\nSorts the portals from the least complex, so the later ones can reuse\nthe earlier information.\n=============\n*/\nint PComp (const void *a, const void *b)\n{\n\tif ( (*(vportal_t **)a)->nummightsee == (*(vportal_t **)b)->nummightsee)\n\t\treturn 0;\n\tif ( (*(vportal_t **)a)->nummightsee < (*(vportal_t **)b)->nummightsee)\n\t\treturn -1;\n\treturn 1;\n}\nvoid SortPortals (void)\n{\n\tint\t\ti;\n\t\n\tfor (i=0 ; i<numportals*2 ; i++)\n\t\tsorted_portals[i] = &portals[i];\n\n\tif (nosort)\n\t\treturn;\n\tqsort (sorted_portals, numportals*2, sizeof(sorted_portals[0]), PComp);\n}\n\n\n/*\n==============\nLeafVectorFromPortalVector\n==============\n*/\nint LeafVectorFromPortalVector (byte *portalbits, byte *leafbits)\n{\n\tint\t\t\ti, j, leafnum;\n\tvportal_t\t*p;\n\tint\t\t\tc_leafs;\n\n\n\tfor (i=0 ; i<numportals*2 ; i++)\n\t{\n\t\tif (portalbits[i>>3] & (1<<(i&7)) )\n\t\t{\n\t\t\tp = portals+i;\n\t\t\tleafbits[p->leaf>>3] |= (1<<(p->leaf&7));\n\t\t}\n\t}\n\n\tfor (j = 0; j < portalclusters; j++)\n\t{\n\t\tleafnum = j;\n\t\twhile (leafs[leafnum].merged >= 0)\n\t\t\tleafnum = leafs[leafnum].merged;\n\t\t//if the merged leaf is visible then the original leaf is visible\n\t\tif (leafbits[leafnum>>3] & (1<<(leafnum&7)))\n\t\t{\n\t\t\tleafbits[j>>3] |= (1<<(j&7));\n\t\t}\n\t}\n\n\tc_leafs = CountBits (leafbits, portalclusters);\n\n\treturn c_leafs;\n}\n\n\n/*\n===============\nClusterMerge\n\nMerges the portal visibility for a leaf\n===============\n*/\nvoid ClusterMerge (int leafnum)\n{\n\tleaf_t\t\t*leaf;\n\tbyte\t\tportalvector[MAX_PORTALS/8];\n\tbyte\t\tuncompressed[MAX_MAP_LEAFS/8];\n\tint\t\t\ti, j;\n\tint\t\t\tnumvis, mergedleafnum;\n\tvportal_t\t*p;\n\tint\t\t\tpnum;\n\n\t// OR together all the portalvis bits\n\n\tmergedleafnum = leafnum;\n\twhile(leafs[mergedleafnum].merged >= 0)\n\t\tmergedleafnum = leafs[mergedleafnum].merged;\n\n\tmemset (portalvector, 0, portalbytes);\n\tleaf = &leafs[mergedleafnum];\n\tfor (i = 0; i < leaf->numportals; i++)\n\t{\n\t\tp = leaf->portals[i];\n\t\tif (p->removed)\n\t\t\tcontinue;\n\n\t\tif (p->status != stat_done)\n\t\t\tError (\"portal not done\");\n\t\tfor (j=0 ; j<portallongs ; j++)\n\t\t\t((long *)portalvector)[j] |= ((long *)p->portalvis)[j];\n\t\tpnum = p - portals;\n\t\tportalvector[pnum>>3] |= 1<<(pnum&7);\n\t}\n\n\tmemset (uncompressed, 0, leafbytes);\n\n\tuncompressed[mergedleafnum>>3] |= (1<<(mergedleafnum&7));\n\t// convert portal bits to leaf bits\n\tnumvis = LeafVectorFromPortalVector (portalvector, uncompressed);\n\n//\tif (uncompressed[leafnum>>3] & (1<<(leafnum&7)))\n//\t\t_printf (\"WARNING: Leaf portals saw into leaf\\n\");\n\t\t\n//\tuncompressed[leafnum>>3] |= (1<<(leafnum&7));\n\n\tnumvis++;\t\t// count the leaf itself\n\n\ttotalvis += numvis;\n\n\tqprintf (\"cluster %4i : %4i visible\\n\", leafnum, numvis);\n\n\tmemcpy (visBytes + VIS_HEADER_SIZE + leafnum*leafbytes, uncompressed, leafbytes);\n}\n\n/*\n==================\nCalcPortalVis\n==================\n*/\nvoid CalcPortalVis (void)\n{\n#ifdef MREDEBUG\n\t_printf(\"%6d portals out of %d\", 0, numportals*2);\n\t//get rid of the counter\n\tRunThreadsOnIndividual (numportals*2, qfalse, PortalFlow);\n#else\n\tRunThreadsOnIndividual (numportals*2, qtrue, PortalFlow);\n#endif\n\n}\n\n/*\n==================\nCalcPassageVis\n==================\n*/\nvoid CalcPassageVis(void)\n{\n\tPassageMemory();\n\n#ifdef MREDEBUG\n\t_printf(\"%6d portals out of %d\", 0, numportals*2);\n\tRunThreadsOnIndividual (numportals*2, qfalse, CreatePassages);\n\t_printf(\"\\n\");\n\t_printf(\"%6d portals out of %d\", 0, numportals*2);\n\tRunThreadsOnIndividual (numportals*2, qfalse, PassageFlow);\n\t_printf(\"\\n\");\n#else\n\tRunThreadsOnIndividual (numportals*2, qtrue, CreatePassages);\n\tRunThreadsOnIndividual (numportals*2, qtrue, PassageFlow);\n#endif\n}\n\n/*\n==================\nCalcPassagePortalVis\n==================\n*/\nvoid CalcPassagePortalVis(void)\n{\n\tPassageMemory();\n\n#ifdef MREDEBUG\n\t_printf(\"%6d portals out of %d\", 0, numportals*2);\n\tRunThreadsOnIndividual (numportals*2, qfalse, CreatePassages);\n\t_printf(\"\\n\");\n\t_printf(\"%6d portals out of %d\", 0, numportals*2);\n\tRunThreadsOnIndividual (numportals*2, qfalse, PassagePortalFlow);\n\t_printf(\"\\n\");\n#else\n\tRunThreadsOnIndividual (numportals*2, qtrue, CreatePassages);\n\tRunThreadsOnIndividual (numportals*2, qtrue, PassagePortalFlow);\n#endif\n}\n\n/*\n==================\nCalcFastVis\n==================\n*/\nvoid CalcFastVis(void)\n{\n\tint\t\ti;\n\n\t// fastvis just uses mightsee for a very loose bound\n\tfor (i=0 ; i<numportals*2 ; i++)\n\t{\n\t\tportals[i].portalvis = portals[i].portalflood;\n\t\tportals[i].status = stat_done;\n\t}\n}\n\n/*\n==================\nCalcVis\n==================\n*/\nvoid CalcVis (void)\n{\n\tint\t\ti;\n\n\tRunThreadsOnIndividual (numportals*2, qtrue, BasePortalVis);\n\n//\tRunThreadsOnIndividual (numportals*2, qtrue, BetterPortalVis);\n\n\tSortPortals ();\n\n\tif (fastvis) {\n\t\tCalcFastVis();\n\t}\n\telse if ( noPassageVis ) {\n\t\tCalcPortalVis();\n\t}\n\telse if ( passageVisOnly ) {\n\t\tCalcPassageVis();\n\t}\n\telse {\n\t\tCalcPassagePortalVis();\n\t}\n\t//\n\t// assemble the leaf vis lists by oring and compressing the portal lists\n\t//\n\t_printf(\"creating leaf vis...\\n\");\n\tfor (i=0 ; i<portalclusters ; i++)\n\t\tClusterMerge (i);\n\n\t_printf( \"Total visible clusters: %i\\n\", totalvis );\n\t_printf( \"Average clusters visible: %i\\n\", totalvis / portalclusters );\n}\n\n/*\n==================\nSetPortalSphere\n==================\n*/\nvoid SetPortalSphere (vportal_t *p)\n{\n\tint\t\ti;\n\tvec3_t\ttotal, dist;\n\twinding_t\t*w;\n\tfloat\tr, bestr;\n\n\tw = p->winding;\n\tVectorCopy (vec3_origin, total);\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tVectorAdd (total, w->points[i], total);\n\t}\n\t\n\tfor (i=0 ; i<3 ; i++)\n\t\ttotal[i] /= w->numpoints;\n\n\tbestr = 0;\t\t\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tVectorSubtract (w->points[i], total, dist);\n\t\tr = VectorLength (dist);\n\t\tif (r > bestr)\n\t\t\tbestr = r;\n\t}\n\tVectorCopy (total, p->origin);\n\tp->radius = bestr;\n}\n\n/*\n=============\nWinding_PlanesConcave\n=============\n*/\n#define WCONVEX_EPSILON\t\t0.2\n\nint Winding_PlanesConcave(winding_t *w1, winding_t *w2,\n\t\t\t\t\t\t\t vec3_t normal1, vec3_t normal2,\n\t\t\t\t\t\t\t float dist1, float dist2)\n{\n\tint i;\n\n\tif (!w1 || !w2) return qfalse;\n\n\t// check if one of the points of winding 1 is at the front of the plane of winding 2\n\tfor (i = 0; i < w1->numpoints; i++)\n\t{\n\t\tif (DotProduct(normal2, w1->points[i]) - dist2 > WCONVEX_EPSILON) return qtrue;\n\t}\n\t// check if one of the points of winding 2 is at the front of the plane of winding 1\n\tfor (i = 0; i < w2->numpoints; i++)\n\t{\n\t\tif (DotProduct(normal1, w2->points[i]) - dist1 > WCONVEX_EPSILON) return qtrue;\n\t}\n\n\treturn qfalse;\n}\n\n/*\n============\nTryMergeLeaves\n============\n*/\nint TryMergeLeaves(int l1num, int l2num)\n{\n\tint i, j, k, n, numportals;\n\tplane_t plane1, plane2;\n\tleaf_t *l1, *l2;\n\tvportal_t *p1, *p2;\n\tvportal_t *portals[MAX_PORTALS_ON_LEAF];\n\n\tfor (k = 0; k < 2; k++)\n\t{\n\t\tif (k) l1 = &leafs[l1num];\n\t\telse l1 = &faceleafs[l1num];\n\t\tfor (i = 0; i < l1->numportals; i++)\n\t\t{\n\t\t\tp1 = l1->portals[i];\n\t\t\tif (p1->leaf == l2num) continue;\n\t\t\tfor (n = 0; n < 2; n++)\n\t\t\t{\n\t\t\t\tif (n) l2 = &leafs[l2num];\n\t\t\t\telse l2 = &faceleafs[l2num];\n\t\t\t\tfor (j = 0; j < l2->numportals; j++)\n\t\t\t\t{\n\t\t\t\t\tp2 = l2->portals[j];\n\t\t\t\t\tif (p2->leaf == l1num) continue;\n\t\t\t\t\t//\n\t\t\t\t\tplane1 = p1->plane;\n\t\t\t\t\tplane2 = p2->plane;\n\t\t\t\t\tif (Winding_PlanesConcave(p1->winding, p2->winding, plane1.normal, plane2.normal, plane1.dist, plane2.dist))\n\t\t\t\t\t\treturn qfalse;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor (k = 0; k < 2; k++)\n\t{\n\t\tif (k)\n\t\t{\n\t\t\tl1 = &leafs[l1num];\n\t\t\tl2 = &leafs[l2num];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tl1 = &faceleafs[l1num];\n\t\t\tl2 = &faceleafs[l2num];\n\t\t}\n\t\tnumportals = 0;\n\t\t//the leaves can be merged now\n\t\tfor (i = 0; i < l1->numportals; i++)\n\t\t{\n\t\t\tp1 = l1->portals[i];\n\t\t\tif (p1->leaf == l2num)\n\t\t\t{\n\t\t\t\tp1->removed = qtrue;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tportals[numportals++] = p1;\n\t\t}\n\t\tfor (j = 0; j < l2->numportals; j++)\n\t\t{\n\t\t\tp2 = l2->portals[j];\n\t\t\tif (p2->leaf == l1num)\n\t\t\t{\n\t\t\t\tp2->removed = qtrue;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tportals[numportals++] = p2;\n\t\t}\n\t\tfor (i = 0; i < numportals; i++)\n\t\t{\n\t\t\tl2->portals[i] = portals[i];\n\t\t}\n\t\tl2->numportals = numportals;\n\t\tl1->merged = l2num;\n\t}\n\treturn qtrue;\n}\n\n/*\n============\nUpdatePortals\n============\n*/\nvoid UpdatePortals(void)\n{\n\tint i;\n\tvportal_t *p;\n\n\tfor (i = 0; i < numportals * 2; i++)\n\t{\n\t\tp = &portals[i];\n\t\tif (p->removed)\n\t\t\tcontinue;\n\t\twhile(leafs[p->leaf].merged >= 0)\n\t\t\tp->leaf = leafs[p->leaf].merged;\n\t}\n}\n\n/*\n============\nMergeLeaves\n\ntry to merge leaves but don't merge through hint splitters\n============\n*/\nvoid MergeLeaves(void)\n{\n\tint i, j, nummerges, totalnummerges;\n\tleaf_t *leaf;\n\tvportal_t *p;\n\n\ttotalnummerges = 0;\n\tdo\n\t{\n\t\tnummerges = 0;\n\t\tfor (i = 0; i < portalclusters; i++)\n\t\t{\n\t\t\tleaf = &leafs[i];\n\t\t\t//if this leaf is merged already\n\t\t\tif (leaf->merged >= 0)\n\t\t\t\tcontinue;\n\t\t\t//\n\t\t\tfor (j = 0; j < leaf->numportals; j++)\n\t\t\t{\n\t\t\t\tp = leaf->portals[j];\n\t\t\t\t//\n\t\t\t\tif (p->removed)\n\t\t\t\t\tcontinue;\n\t\t\t\t//never merge through hint portals\n\t\t\t\tif (p->hint)\n\t\t\t\t\tcontinue;\n\t\t\t\tif (TryMergeLeaves(i, p->leaf))\n\t\t\t\t{\n\t\t\t\t\tUpdatePortals();\n\t\t\t\t\tnummerges++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ttotalnummerges += nummerges;\n\t} while (nummerges);\n\t_printf(\"%6d leaves merged\\n\", totalnummerges);\n}\n\n/*\n============\nTryMergeWinding\n============\n*/\n#define\tCONTINUOUS_EPSILON\t0.005\n\nwinding_t *TryMergeWinding (winding_t *f1, winding_t *f2, vec3_t planenormal)\n{\n\tvec_t\t\t*p1, *p2, *p3, *p4, *back;\n\twinding_t\t*newf;\n\tint\t\t\ti, j, k, l;\n\tvec3_t\t\tnormal, delta;\n\tvec_t\t\tdot;\n\tqboolean\tkeep1, keep2;\n\t\n\n\t//\n\t// find a common edge\n\t//\t\n\tp1 = p2 = NULL;\t// stop compiler warning\n\tj = 0;\t\t\t// \n\t\n\tfor (i = 0; i < f1->numpoints; i++)\n\t{\n\t\tp1 = f1->points[i];\n\t\tp2 = f1->points[(i+1) % f1->numpoints];\n\t\tfor (j = 0; j < f2->numpoints; j++)\n\t\t{\n\t\t\tp3 = f2->points[j];\n\t\t\tp4 = f2->points[(j+1) % f2->numpoints];\n\t\t\tfor (k = 0; k < 3; k++)\n\t\t\t{\n\t\t\t\tif (fabs(p1[k] - p4[k]) > 0.1)//EQUAL_EPSILON) //ME\n\t\t\t\t\tbreak;\n\t\t\t\tif (fabs(p2[k] - p3[k]) > 0.1)//EQUAL_EPSILON) //ME\n\t\t\t\t\tbreak;\n\t\t\t} //end for\n\t\t\tif (k==3)\n\t\t\t\tbreak;\n\t\t} //end for\n\t\tif (j < f2->numpoints)\n\t\t\tbreak;\n\t} //end for\n\t\n\tif (i == f1->numpoints)\n\t\treturn NULL;\t\t\t// no matching edges\n\n\t//\n\t// check slope of connected lines\n\t// if the slopes are colinear, the point can be removed\n\t//\n\tback = f1->points[(i+f1->numpoints-1)%f1->numpoints];\n\tVectorSubtract (p1, back, delta);\n\tCrossProduct (planenormal, delta, normal);\n\tVectorNormalize (normal, normal);\n\t\n\tback = f2->points[(j+2)%f2->numpoints];\n\tVectorSubtract (back, p1, delta);\n\tdot = DotProduct (delta, normal);\n\tif (dot > CONTINUOUS_EPSILON)\n\t\treturn NULL;\t\t\t// not a convex polygon\n\tkeep1 = (qboolean)(dot < -CONTINUOUS_EPSILON);\n\t\n\tback = f1->points[(i+2)%f1->numpoints];\n\tVectorSubtract (back, p2, delta);\n\tCrossProduct (planenormal, delta, normal);\n\tVectorNormalize (normal, normal);\n\n\tback = f2->points[(j+f2->numpoints-1)%f2->numpoints];\n\tVectorSubtract (back, p2, delta);\n\tdot = DotProduct (delta, normal);\n\tif (dot > CONTINUOUS_EPSILON)\n\t\treturn NULL;\t\t\t// not a convex polygon\n\tkeep2 = (qboolean)(dot < -CONTINUOUS_EPSILON);\n\n\t//\n\t// build the new polygon\n\t//\n\tnewf = NewWinding (f1->numpoints + f2->numpoints);\n\t\n\t// copy first polygon\n\tfor (k=(i+1)%f1->numpoints ; k != i ; k=(k+1)%f1->numpoints)\n\t{\n\t\tif (k==(i+1)%f1->numpoints && !keep2)\n\t\t\tcontinue;\n\t\t\n\t\tVectorCopy (f1->points[k], newf->points[newf->numpoints]);\n\t\tnewf->numpoints++;\n\t}\n\t\n\t// copy second polygon\n\tfor (l= (j+1)%f2->numpoints ; l != j ; l=(l+1)%f2->numpoints)\n\t{\n\t\tif (l==(j+1)%f2->numpoints && !keep1)\n\t\t\tcontinue;\n\t\tVectorCopy (f2->points[l], newf->points[newf->numpoints]);\n\t\tnewf->numpoints++;\n\t}\n\n\treturn newf;\n}\n\n/*\n============\nMergeLeafPortals\n============\n*/\nvoid MergeLeafPortals(void)\n{\n\tint i, j, k, nummerges, hintsmerged;\n\tleaf_t *leaf;\n\tvportal_t *p1, *p2;\n\twinding_t *w;\n\n\tnummerges = 0;\n\thintsmerged = 0;\n\tfor (i = 0; i < portalclusters; i++)\n\t{\n\t\tleaf = &leafs[i];\n\t\tif (leaf->merged >= 0) continue;\n\t\tfor (j = 0; j < leaf->numportals; j++)\n\t\t{\n\t\t\tp1 = leaf->portals[j];\n\t\t\tif (p1->removed)\n\t\t\t\tcontinue;\n\t\t\tfor (k = j+1; k < leaf->numportals; k++)\n\t\t\t{\n\t\t\t\tp2 = leaf->portals[k];\n\t\t\t\tif (p2->removed)\n\t\t\t\t\tcontinue;\n\t\t\t\tif (p1->leaf == p2->leaf)\n\t\t\t\t{\n\t\t\t\t\tw = TryMergeWinding(p1->winding, p2->winding, p1->plane.normal);\n\t\t\t\t\tif (w)\n\t\t\t\t\t{\n\t\t\t\t\t\tFreeWinding(p1->winding);\n\t\t\t\t\t\tp1->winding = w;\n\t\t\t\t\t\tif (p1->hint && p2->hint)\n\t\t\t\t\t\t\thintsmerged++;\n\t\t\t\t\t\tp1->hint |= p2->hint;\n\t\t\t\t\t\tSetPortalSphere(p1);\n\t\t\t\t\t\tp2->removed = qtrue;\n\t\t\t\t\t\tnummerges++;\n\t\t\t\t\t\ti--;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (k < leaf->numportals)\n\t\t\t\tbreak;\n\t\t}\n\t}\n\t_printf(\"%6d portals merged\\n\", nummerges);\n\t_printf(\"%6d hint portals merged\\n\", hintsmerged);\n}\n\n\n/*\n============\nWritePortals\n============\n*/\nint CountActivePortals(void)\n{\n\tint num, hints, j;\n\tvportal_t *p;\n\n\tnum = 0;\n\thints = 0;\n\tfor (j = 0; j < numportals * 2; j++)\n\t{\n\t\tp = portals + j;\n\t\tif (p->removed)\n\t\t\tcontinue;\n\t\tif (p->hint)\n\t\t\thints++;\n\t\tnum++;\n\t}\n\t_printf(\"%6d active portals\\n\", num);\n\t_printf(\"%6d hint portals\\n\", hints);\n\treturn num;\n}\n\n/*\n============\nWritePortals\n============\n*/\nvoid WriteFloat (FILE *f, vec_t v);\n\nvoid WritePortals(char *filename)\n{\n\tint i, j, num;\n\tFILE *pf;\n\tvportal_t *p;\n\twinding_t *w;\n\n\t// write the file\n\tpf = fopen (filename, \"w\");\n\tif (!pf)\n\t\tError (\"Error opening %s\", filename);\n\n\tnum = 0;\n\tfor (j = 0; j < numportals * 2; j++)\n\t{\n\t\tp = portals + j;\n\t\tif (p->removed)\n\t\t\tcontinue;\n//\t\tif (!p->hint)\n//\t\t\tcontinue;\n\t\tnum++;\n\t}\n\n\tfprintf (pf, \"%s\\n\", PORTALFILE);\n\tfprintf (pf, \"%i\\n\", 0);\n\tfprintf (pf, \"%i\\n\", num);// + numfaces);\n\tfprintf (pf, \"%i\\n\", 0);\n\n\tfor (j = 0; j < numportals * 2; j++)\n\t{\n\t\tp = portals + j;\n\t\tif (p->removed)\n\t\t\tcontinue;\n//\t\tif (!p->hint)\n//\t\t\tcontinue;\n\t\tw = p->winding;\n\t\tfprintf (pf,\"%i %i %i \",w->numpoints, 0, 0);\n\t\tfprintf (pf, \"%d \", p->hint);\n\t\tfor (i=0 ; i<w->numpoints ; i++)\n\t\t{\n\t\t\tfprintf (pf,\"(\");\n\t\t\tWriteFloat (pf, w->points[i][0]);\n\t\t\tWriteFloat (pf, w->points[i][1]);\n\t\t\tWriteFloat (pf, w->points[i][2]);\n\t\t\tfprintf (pf,\") \");\n\t\t}\n\t\tfprintf (pf,\"\\n\");\n\t}\n\n\t/*\n\tfor (j = 0; j < numfaces; j++)\n\t{\n\t\tp = faces + j;\n\t\tw = p->winding;\n\t\tfprintf (pf,\"%i %i %i \",w->numpoints, 0, 0);\n\t\tfprintf (pf, \"0 \");\n\t\tfor (i=0 ; i<w->numpoints ; i++)\n\t\t{\n\t\t\tfprintf (pf,\"(\");\n\t\t\tWriteFloat (pf, w->points[i][0]);\n\t\t\tWriteFloat (pf, w->points[i][1]);\n\t\t\tWriteFloat (pf, w->points[i][2]);\n\t\t\tfprintf (pf,\") \");\n\t\t}\n\t\tfprintf (pf,\"\\n\");\n\t}*/\n\n\tfclose (pf);\n}\n\n/*\n============\nLoadPortals\n============\n*/\nvoid LoadPortals (char *name)\n{\n\tint\t\t\ti, j, hint;\n\tvportal_t\t*p;\n\tleaf_t\t\t*l;\n\tchar\t\tmagic[80];\n\tFILE\t\t*f;\n\tint\t\t\tnumpoints;\n\twinding_t\t*w;\n\tint\t\t\tleafnums[2];\n\tplane_t\t\tplane;\n\t\n\tif (!strcmp(name,\"-\"))\n\t\tf = stdin;\n\telse\n\t{\n\t\tf = fopen(name, \"r\");\n\t\tif (!f)\n\t\t\tError (\"LoadPortals: couldn't read %s\\n\",name);\n\t}\n\n\tif (fscanf (f,\"%79s\\n%i\\n%i\\n%i\\n\",magic, &portalclusters, &numportals, &numfaces) != 4)\n\t\tError (\"LoadPortals: failed to read header\");\n\tif (strcmp(magic,PORTALFILE))\n\t\tError (\"LoadPortals: not a portal file\");\n\n\t_printf (\"%6i portalclusters\\n\", portalclusters);\n\t_printf (\"%6i numportals\\n\", numportals);\n\t_printf (\"%6i numfaces\\n\", numfaces);\n\n\t// these counts should take advantage of 64 bit systems automatically\n\tleafbytes = ((portalclusters+63)&~63)>>3;\n\tleaflongs = leafbytes/sizeof(long);\n\t\n\tportalbytes = ((numportals*2+63)&~63)>>3;\n\tportallongs = portalbytes/sizeof(long);\n\n\t// each file portal is split into two memory portals\n\tportals = malloc(2*numportals*sizeof(vportal_t));\n\tmemset (portals, 0, 2*numportals*sizeof(vportal_t));\n\t\n\tleafs = malloc(portalclusters*sizeof(leaf_t));\n\tmemset (leafs, 0, portalclusters*sizeof(leaf_t));\n\n\tfor (i = 0; i < portalclusters; i++)\n\t\tleafs[i].merged = -1;\n\n\tnumVisBytes = VIS_HEADER_SIZE + portalclusters*leafbytes;\n\n\t((int *)visBytes)[0] = portalclusters;\n\t((int *)visBytes)[1] = leafbytes;\n\t\t\n\tfor (i=0, p=portals ; i<numportals ; i++)\n\t{\n\t\tif (fscanf (f, \"%i %i %i \", &numpoints, &leafnums[0], &leafnums[1]) != 3)\n\t\t\tError (\"LoadPortals: reading portal %i\", i);\n\t\tif (numpoints > MAX_POINTS_ON_WINDING)\n\t\t\tError (\"LoadPortals: portal %i has too many points\", i);\n\t\tif ( (unsigned)leafnums[0] > portalclusters\n\t\t|| (unsigned)leafnums[1] > portalclusters)\n\t\t\tError (\"LoadPortals: reading portal %i\", i);\n\t\tif (fscanf (f, \"%i \", &hint) != 1)\n\t\t\tError (\"LoadPortals: reading hint state\");\n\t\t\n\t\tw = p->winding = NewWinding (numpoints);\n\t\tw->numpoints = numpoints;\n\t\t\n\t\tfor (j=0 ; j<numpoints ; j++)\n\t\t{\n\t\t\tdouble\tv[3];\n\t\t\tint\t\tk;\n\n\t\t\t// scanf into double, then assign to vec_t\n\t\t\t// so we don't care what size vec_t is\n\t\t\tif (fscanf (f, \"(%lf %lf %lf ) \"\n\t\t\t, &v[0], &v[1], &v[2]) != 3)\n\t\t\t\tError (\"LoadPortals: reading portal %i\", i);\n\t\t\tfor (k=0 ; k<3 ; k++)\n\t\t\t\tw->points[j][k] = v[k];\n\t\t}\n\t\tfscanf (f, \"\\n\");\n\t\t\n\t\t// calc plane\n\t\tPlaneFromWinding (w, &plane);\n\n\t\t// create forward portal\n\t\tl = &leafs[leafnums[0]];\n\t\tif (l->numportals == MAX_PORTALS_ON_LEAF)\n\t\t\tError (\"Leaf with too many portals\");\n\t\tl->portals[l->numportals] = p;\n\t\tl->numportals++;\n\t\t\n\t\tp->num = i+1;\n\t\tp->hint = hint;\n\t\tp->winding = w;\n\t\tVectorSubtract (vec3_origin, plane.normal, p->plane.normal);\n\t\tp->plane.dist = -plane.dist;\n\t\tp->leaf = leafnums[1];\n\t\tSetPortalSphere (p);\n\t\tp++;\n\t\t\n\t\t// create backwards portal\n\t\tl = &leafs[leafnums[1]];\n\t\tif (l->numportals == MAX_PORTALS_ON_LEAF)\n\t\t\tError (\"Leaf with too many portals\");\n\t\tl->portals[l->numportals] = p;\n\t\tl->numportals++;\n\t\t\n\t\tp->num = i+1;\n\t\tp->hint = hint;\n\t\tp->winding = NewWinding(w->numpoints);\n\t\tp->winding->numpoints = w->numpoints;\n\t\tfor (j=0 ; j<w->numpoints ; j++)\n\t\t{\n\t\t\tVectorCopy (w->points[w->numpoints-1-j], p->winding->points[j]);\n\t\t}\n\n\t\tp->plane = plane;\n\t\tp->leaf = leafnums[0];\n\t\tSetPortalSphere (p);\n\t\tp++;\n\n\t}\n\n\tfaces = malloc(2*numfaces*sizeof(vportal_t));\n\tmemset (faces, 0, 2*numfaces*sizeof(vportal_t));\n\n\tfaceleafs = malloc(portalclusters*sizeof(leaf_t));\n\tmemset(faceleafs, 0, portalclusters*sizeof(leaf_t));\n\n\tfor (i = 0, p = faces; i < numfaces; i++)\n\t{\n\t\tif (fscanf (f, \"%i %i \", &numpoints, &leafnums[0]) != 2)\n\t\t\tError (\"LoadPortals: reading portal %i\", i);\n\n\t\tw = p->winding = NewWinding (numpoints);\n\t\tw->numpoints = numpoints;\n\t\t\n\t\tfor (j=0 ; j<numpoints ; j++)\n\t\t{\n\t\t\tdouble\tv[3];\n\t\t\tint\t\tk;\n\n\t\t\t// scanf into double, then assign to vec_t\n\t\t\t// so we don't care what size vec_t is\n\t\t\tif (fscanf (f, \"(%lf %lf %lf ) \"\n\t\t\t, &v[0], &v[1], &v[2]) != 3)\n\t\t\t\tError (\"LoadPortals: reading portal %i\", i);\n\t\t\tfor (k=0 ; k<3 ; k++)\n\t\t\t\tw->points[j][k] = v[k];\n\t\t}\n\t\tfscanf (f, \"\\n\");\n\t\t\n\t\t// calc plane\n\t\tPlaneFromWinding (w, &plane);\n\n\t\tl = &faceleafs[leafnums[0]];\n\t\tl->merged = -1;\n\t\tif (l->numportals == MAX_PORTALS_ON_LEAF)\n\t\t\tError (\"Leaf with too many faces\");\n\t\tl->portals[l->numportals] = p;\n\t\tl->numportals++;\n\t\t\n\t\tp->num = i+1;\n\t\tp->winding = w;\n\t\t// normal pointing out of the leaf\n\t\tVectorSubtract (vec3_origin, plane.normal, p->plane.normal);\n\t\tp->plane.dist = -plane.dist;\n\t\tp->leaf = -1;\n\t\tSetPortalSphere (p);\n\t\tp++;\n\t}\n\t\n\tfclose (f);\n}\n\n\n/*\n================\nCalcPHS\n\nCalculate the PHS (Potentially Hearable Set)\nby ORing together all the PVS visible from a leaf\n================\n*/\nvoid CalcPHS (void)\n{\n\tint\t\ti, j, k, l, index;\n\tint\t\tbitbyte;\n\tlong\t*dest, *src;\n\tbyte\t*scan;\n\tint\t\tcount;\n\tbyte\tuncompressed[MAX_MAP_LEAFS/8];\n\n\t_printf (\"Building PHS...\\n\");\n\n\tcount = 0;\n\tfor (i=0 ; i<portalclusters ; i++)\n\t{\n\t\tscan = visBytes + i*leafbytes;\n\t\tmemcpy (uncompressed, scan, leafbytes);\n\t\tfor (j=0 ; j<leafbytes ; j++)\n\t\t{\n\t\t\tbitbyte = scan[j];\n\t\t\tif (!bitbyte)\n\t\t\t\tcontinue;\n\t\t\tfor (k=0 ; k<8 ; k++)\n\t\t\t{\n\t\t\t\tif (! (bitbyte & (1<<k)) )\n\t\t\t\t\tcontinue;\n\t\t\t\t// OR this pvs row into the phs\n\t\t\t\tindex = ((j<<3)+k);\n\t\t\t\tif (index >= portalclusters)\n\t\t\t\t\tError (\"Bad bit in PVS\");\t// pad bits should be 0\n\t\t\t\tsrc = (long *)(visBytes + index*leafbytes);\n\t\t\t\tdest = (long *)uncompressed;\n\t\t\t\tfor (l=0 ; l<leaflongs ; l++)\n\t\t\t\t\t((long *)uncompressed)[l] |= src[l];\n\t\t\t}\n\t\t}\n\t\tfor (j=0 ; j<portalclusters ; j++)\n\t\t\tif (uncompressed[j>>3] & (1<<(j&7)) )\n\t\t\t\tcount++;\n\n\t\t// FIXME: copy it off\n\t}\n\n\t_printf (\"Average clusters hearable: %i\\n\", count/portalclusters);\n}\n\n/*\n===========\nVisMain\n===========\n*/\nint VisMain (int argc, char **argv)\n{\n\tchar\t\tportalfile[1024];\n\tchar\t\tname[1024];\n\tint\t\ti;\n\tdouble\t\tstart, end;\n\t\t\n\t_printf (\"---- vis ----\\n\");\n\n\tverbose = qfalse;\n\tfor (i=1 ; i<argc ; i++) {\n\t\tif (!strcmp(argv[i],\"-threads\")) {\n\t\t\tnumthreads = atoi (argv[i+1]);\n\t\t\ti++;\n\t\t} else if (!strcmp(argv[i],\"-threads\")) {\n\t\t\tnumthreads = atoi (argv[i+1]);\n\t\t\ti++;\n\t\t} else if (!strcmp(argv[i], \"-fast\")) {\n\t\t\t_printf (\"fastvis = true\\n\");\n\t\t\tfastvis = qtrue;\n\t\t} else if (!strcmp(argv[i], \"-merge\")) {\n\t\t\t_printf (\"merge = true\\n\");\n\t\t\tmergevis = qtrue;\n\t\t} else if (!strcmp(argv[i], \"-nopassage\")) {\n\t\t\t_printf (\"nopassage = true\\n\");\n\t\t\tnoPassageVis = qtrue;\n\t\t} else if (!strcmp(argv[i], \"-passageOnly\")) {\n\t\t\t_printf(\"passageOnly = true\\n\");\n\t\t\tpassageVisOnly = qtrue;\n\t\t} else if (!strcmp(argv[i], \"-level\")) {\n\t\t\ttestlevel = atoi(argv[i+1]);\n\t\t\t_printf (\"testlevel = %i\\n\", testlevel);\n\t\t\ti++;\n\t\t} else if (!strcmp(argv[i], \"-v\")) {\n\t\t\t_printf (\"verbose = true\\n\");\n\t\t\tverbose = qtrue;\n\t\t} else if (!strcmp (argv[i],\"-nosort\")) {\n\t\t\t_printf (\"nosort = true\\n\");\n\t\t\tnosort = qtrue;\n\t\t} else if (!strcmp (argv[i],\"-saveprt\")) {\n\t\t\t_printf (\"saveprt = true\\n\");\n\t\t\tsaveprt = qtrue;\n\t\t} else if (!strcmp (argv[i],\"-tmpin\")) {\n\t\t\tstrcpy (inbase, \"/tmp\");\n\t\t} else if (!strcmp (argv[i],\"-tmpout\")) {\n\t\t\tstrcpy (outbase, \"/tmp\");\n\t\t} else if (argv[i][0] == '-') {\n\t\t\tError (\"Unknown option \\\"%s\\\"\", argv[i]);\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (i != argc - 1)\n\t\tError (\"usage: vis [-threads #] [-level 0-4] [-fast] [-v] bspfile\");\n\n#ifdef MREDEBUG\n\tstart = clock();\n#else\n\tstart = I_FloatTime ();\n#endif\n\t\n\tThreadSetDefault ();\n\n\tSetQdirFromPath (argv[i]);\t\n\n#ifdef _WIN32\n  InitPakFile(gamedir, NULL);\n#endif\n\n\t// load the bsp\n\tsprintf (name, \"%s%s\", inbase, ExpandArg(argv[i]));\n\tStripExtension (name);\n\tstrcat (name, \".bsp\");\n\t_printf (\"reading %s\\n\", name);\n\tLoadBSPFile (name);\n\n\t// load the portal file\n\tsprintf (portalfile, \"%s%s\", inbase, ExpandArg(argv[i]));\n\tStripExtension (portalfile);\n\tstrcat (portalfile, \".prt\");\n\t_printf (\"reading %s\\n\", portalfile);\n\tLoadPortals (portalfile);\n\n\tif (mergevis)\n\t{\n\t\tMergeLeaves();\n\t\tMergeLeafPortals();\n\t}\n\n\tCountActivePortals();\n//\tWritePortals(\"maps/hints.prs\");\n\n\t_printf (\"visdatasize:%i\\n\", numVisBytes);\n\n\tCalcVis ();\n\n//\tCalcPHS ();\n\n\t// delete the prt file\n\tif ( !saveprt ) {\n\t\tremove( portalfile );\n\t}\n\n\t// write the bsp file\n\t_printf (\"writing %s\\n\", name);\n\tWriteBSPFile (name);\n\n#ifdef MREDEBUG\n\tend = clock();\n\t_printf (\"%5.2f seconds elapsed\\n\", (end-start) / CLK_TCK);\n#else\n\tend = I_FloatTime ();\n\t_printf (\"%5.2f seconds elapsed\\n\", end-start);\n#endif\n\treturn 0;\n}\n\n"
  },
  {
    "path": "q3map/vis.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// vis.h\n\n#include \"cmdlib.h\"\n#include \"mathlib.h\"\n#include \"bspfile.h\"\n\n#define\tMAX_PORTALS\t32768\n\n#define\tPORTALFILE\t\"PRT1\"\n\n#define\tON_EPSILON\t0.1\n\n//#define MREDEBUG\n\n// seperator caching helps a bit\n#define SEPERATORCACHE\n\n// can't have more seperators than the max number of points on a winding\n#define MAX_SEPERATORS\t\t64\n\ntypedef struct\n{\n\tvec3_t\t\tnormal;\n\tfloat\t\tdist;\n} plane_t;\n\n#define MAX_POINTS_ON_WINDING\t64\n#define\tMAX_POINTS_ON_FIXED_WINDING\t12\n\ntypedef struct\n{\n\tint\t\tnumpoints;\n\tvec3_t\tpoints[MAX_POINTS_ON_FIXED_WINDING];\t\t\t// variable sized\n} winding_t;\n\nwinding_t\t*NewWinding (int points);\nvoid\t\tFreeWinding (winding_t *w);\nwinding_t\t*CopyWinding (winding_t *w);\n\n\ntypedef struct passage_s\n{\n\tstruct passage_s\t*next;\n\tbyte\t\t\t\tcansee[1];\t//all portals that can be seen through this passage\n} passage_t;\n\ntypedef enum {stat_none, stat_working, stat_done} vstatus_t;\ntypedef struct\n{\n\tint\t\t\tnum;\n\tqboolean\thint;\t// true if this portal was created from a hint splitter\n\tqboolean\tremoved;\n\tplane_t\t\tplane;\t// normal pointing into neighbor\n\tint\t\t\tleaf;\t// neighbor\n\t\n\tvec3_t\t\torigin;\t// for fast clip testing\n\tfloat\t\tradius;\n\n\twinding_t\t*winding;\n\tvstatus_t\tstatus;\n\tbyte\t\t*portalfront;\t// [portals], preliminary\n\tbyte\t\t*portalflood;\t// [portals], intermediate\n\tbyte\t\t*portalvis;\t\t// [portals], final\n\n\tint\t\t\tnummightsee;\t// bit count on portalflood for sort\n\tpassage_t\t*passages;\t\t// there are just as many passages as there\n\t\t\t\t\t\t\t\t// are portals in the leaf this portal leads to\n} vportal_t;\n\n#define\tMAX_PORTALS_ON_LEAF\t\t128\ntypedef struct leaf_s\n{\n\tint\t\t\tnumportals;\n\tint\t\t\tmerged;\n\tvportal_t\t*portals[MAX_PORTALS_ON_LEAF];\n} leaf_t;\n\n\t\ntypedef struct pstack_s\n{\n\tbyte\t\tmightsee[MAX_PORTALS/8];\t\t// bit string\n\tstruct pstack_s\t*next;\n\tleaf_t\t\t*leaf;\n\tvportal_t\t*portal;\t// portal exiting\n\twinding_t\t*source;\n\twinding_t\t*pass;\n\n\twinding_t\twindings[3];\t// source, pass, temp in any order\n\tint\t\t\tfreewindings[3];\n\n\tplane_t\t\tportalplane;\n\tint depth;\n#ifdef SEPERATORCACHE\n\tplane_t seperators[2][MAX_SEPERATORS];\n\tint numseperators[2];\n#endif\n} pstack_t;\n\ntypedef struct\n{\n\tvportal_t\t*base;\n\tint\t\t\tc_chains;\n\tpstack_t\tpstack_head;\n} threaddata_t;\n\n\n\nextern\tint\t\t\tnumportals;\nextern\tint\t\t\tportalclusters;\n\nextern\tvportal_t\t*portals;\nextern\tleaf_t\t\t*leafs;\n\nextern\tint\t\t\tc_portaltest, c_portalpass, c_portalcheck;\nextern\tint\t\t\tc_portalskip, c_leafskip;\nextern\tint\t\t\tc_vistest, c_mighttest;\nextern\tint\t\t\tc_chains;\n\nextern\tbyte\t*vismap, *vismap_p, *vismap_end;\t// past visfile\n\nextern\tint\t\t\ttestlevel;\n\nextern\tbyte\t\t*uncompressed;\n\nextern\tint\t\tleafbytes, leaflongs;\nextern\tint\t\tportalbytes, portallongs;\n\n\nvoid LeafFlow (int leafnum);\n\n\nvoid BasePortalVis(int portalnum);\nvoid BetterPortalVis(int portalnum);\nvoid PortalFlow(int portalnum);\nvoid PassagePortalFlow(int portalnum);\nvoid CreatePassages(int portalnum);\nvoid PassageFlow(int portalnum);\n\nextern\tvportal_t\t*sorted_portals[MAX_MAP_PORTALS*2];\n\nint CountBits (byte *bits, int numbits);\n"
  },
  {
    "path": "q3map/visflow.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"vis.h\"\n\n/*\n\n  each portal will have a list of all possible to see from first portal\n\n  if (!thread->portalmightsee[portalnum])\n\n  portal mightsee\n\n  for p2 = all other portals in leaf\n\tget sperating planes\n\tfor all portals that might be seen by p2\n\t\tmark as unseen if not present in seperating plane\n\tflood fill a new mightsee\n\tsave as passagemightsee\n\n\n  void CalcMightSee (leaf_t *leaf, \n*/\n\nint CountBits (byte *bits, int numbits)\n{\n\tint\t\ti;\n\tint\t\tc;\n\n\tc = 0;\n\tfor (i=0 ; i<numbits ; i++)\n\t\tif (bits[i>>3] & (1<<(i&7)) )\n\t\t\tc++;\n\n\treturn c;\n}\n\nint\t\tc_fullskip;\nint\t\tc_portalskip, c_leafskip;\nint\t\tc_vistest, c_mighttest;\n\nint\t\tc_chop, c_nochop;\n\nint\t\tactive;\n\nvoid CheckStack (leaf_t *leaf, threaddata_t *thread)\n{\n\tpstack_t\t*p, *p2;\n\n\tfor (p=thread->pstack_head.next ; p ; p=p->next)\n\t{\n//\t\t_printf (\"=\");\n\t\tif (p->leaf == leaf)\n\t\t\tError (\"CheckStack: leaf recursion\");\n\t\tfor (p2=thread->pstack_head.next ; p2 != p ; p2=p2->next)\n\t\t\tif (p2->leaf == p->leaf)\n\t\t\t\tError (\"CheckStack: late leaf recursion\");\n\t}\n//\t_printf (\"\\n\");\n}\n\n\nwinding_t *AllocStackWinding (pstack_t *stack)\n{\n\tint\t\ti;\n\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tif (stack->freewindings[i])\n\t\t{\n\t\t\tstack->freewindings[i] = 0;\n\t\t\treturn &stack->windings[i];\n\t\t}\n\t}\n\n\tError (\"AllocStackWinding: failed\");\n\n\treturn NULL;\n}\n\nvoid FreeStackWinding (winding_t *w, pstack_t *stack)\n{\n\tint\t\ti;\n\n\ti = w - stack->windings;\n\n\tif (i<0 || i>2)\n\t\treturn;\t\t// not from local\n\n\tif (stack->freewindings[i])\n\t\tError (\"FreeStackWinding: allready free\");\n\tstack->freewindings[i] = 1;\n}\n\n/*\n==============\nVisChopWinding\n\n==============\n*/\nwinding_t\t*VisChopWinding (winding_t *in, pstack_t *stack, plane_t *split)\n{\n\tvec_t\tdists[128];\n\tint\t\tsides[128];\n\tint\t\tcounts[3];\n\tvec_t\tdot;\n\tint\t\ti, j;\n\tvec_t\t*p1, *p2;\n\tvec3_t\tmid;\n\twinding_t\t*neww;\n\n\tcounts[0] = counts[1] = counts[2] = 0;\n\n\t// determine sides for each point\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tdot = DotProduct (in->points[i], split->normal);\n\t\tdot -= split->dist;\n\t\tdists[i] = dot;\n\t\tif (dot > ON_EPSILON)\n\t\t\tsides[i] = SIDE_FRONT;\n\t\telse if (dot < -ON_EPSILON)\n\t\t\tsides[i] = SIDE_BACK;\n\t\telse\n\t\t{\n\t\t\tsides[i] = SIDE_ON;\n\t\t}\n\t\tcounts[sides[i]]++;\n\t}\n\n\tif (!counts[1])\n\t\treturn in;\t\t// completely on front side\n\t\n\tif (!counts[0])\n\t{\n\t\tFreeStackWinding (in, stack);\n\t\treturn NULL;\n\t}\n\n\tsides[i] = sides[0];\n\tdists[i] = dists[0];\n\t\n\tneww = AllocStackWinding (stack);\n\n\tneww->numpoints = 0;\n\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tp1 = in->points[i];\n\n\t\tif (neww->numpoints == MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\tFreeStackWinding (neww, stack);\n\t\t\treturn in;\t\t// can't chop -- fall back to original\n\t\t}\n\n\t\tif (sides[i] == SIDE_ON)\n\t\t{\n\t\t\tVectorCopy (p1, neww->points[neww->numpoints]);\n\t\t\tneww->numpoints++;\n\t\t\tcontinue;\n\t\t}\n\t\n\t\tif (sides[i] == SIDE_FRONT)\n\t\t{\n\t\t\tVectorCopy (p1, neww->points[neww->numpoints]);\n\t\t\tneww->numpoints++;\n\t\t}\n\t\t\n\t\tif (sides[i+1] == SIDE_ON || sides[i+1] == sides[i])\n\t\t\tcontinue;\n\t\t\t\n\t\tif (neww->numpoints == MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\tFreeStackWinding (neww, stack);\n\t\t\treturn in;\t\t// can't chop -- fall back to original\n\t\t}\n\n\t\t// generate a split point\n\t\tp2 = in->points[(i+1)%in->numpoints];\n\t\t\n\t\tdot = dists[i] / (dists[i]-dists[i+1]);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\t// avoid round off error when possible\n\t\t\tif (split->normal[j] == 1)\n\t\t\t\tmid[j] = split->dist;\n\t\t\telse if (split->normal[j] == -1)\n\t\t\t\tmid[j] = -split->dist;\n\t\t\telse\n\t\t\t\tmid[j] = p1[j] + dot*(p2[j]-p1[j]);\n\t\t}\n\t\t\t\n\t\tVectorCopy (mid, neww->points[neww->numpoints]);\n\t\tneww->numpoints++;\n\t}\n\t\n\t// free the original winding\n\tFreeStackWinding (in, stack);\n\t\n\treturn neww;\n}\n\n/*\n==============\nClipToSeperators\n\nSource, pass, and target are an ordering of portals.\n\nGenerates seperating planes canidates by taking two points from source and one\npoint from pass, and clips target by them.\n\nIf target is totally clipped away, that portal can not be seen through.\n\nNormal clip keeps target on the same side as pass, which is correct if the\norder goes source, pass, target.  If the order goes pass, source, target then\nflipclip should be set.\n==============\n*/\nwinding_t\t*ClipToSeperators (winding_t *source, winding_t *pass, winding_t *target, qboolean flipclip, pstack_t *stack)\n{\n\tint\t\t\ti, j, k, l;\n\tplane_t\t\tplane;\n\tvec3_t\t\tv1, v2;\n\tfloat\t\td;\n\tvec_t\t\tlength;\n\tint\t\t\tcounts[3];\n\tqboolean\t\tfliptest;\n\n\t// check all combinations\t\n\tfor (i=0 ; i<source->numpoints ; i++)\n\t{\n\t\tl = (i+1)%source->numpoints;\n\t\tVectorSubtract (source->points[l] , source->points[i], v1);\n\n\t\t// find a vertex of pass that makes a plane that puts all of the\n\t\t// vertexes of pass on the front side and all of the vertexes of\n\t\t// source on the back side\n\t\tfor (j=0 ; j<pass->numpoints ; j++)\n\t\t{\n\t\t\tVectorSubtract (pass->points[j], source->points[i], v2);\n\n\t\t\tplane.normal[0] = v1[1]*v2[2] - v1[2]*v2[1];\n\t\t\tplane.normal[1] = v1[2]*v2[0] - v1[0]*v2[2];\n\t\t\tplane.normal[2] = v1[0]*v2[1] - v1[1]*v2[0];\n\t\t\t\n\t\t\t// if points don't make a valid plane, skip it\n\n\t\t\tlength = plane.normal[0] * plane.normal[0]\n\t\t\t+ plane.normal[1] * plane.normal[1]\n\t\t\t+ plane.normal[2] * plane.normal[2];\n\t\t\t\n\t\t\tif (length < ON_EPSILON)\n\t\t\t\tcontinue;\n\n\t\t\tlength = 1/sqrt(length);\n\t\t\t\n\t\t\tplane.normal[0] *= length;\n\t\t\tplane.normal[1] *= length;\n\t\t\tplane.normal[2] *= length;\n\n\t\t\tplane.dist = DotProduct (pass->points[j], plane.normal);\n\n\t\t\t//\n\t\t\t// find out which side of the generated seperating plane has the\n\t\t\t// source portal\n\t\t\t//\n#if 1\n\t\t\tfliptest = qfalse;\n\t\t\tfor (k=0 ; k<source->numpoints ; k++)\n\t\t\t{\n\t\t\t\tif (k == i || k == l)\n\t\t\t\t\tcontinue;\n\t\t\t\td = DotProduct (source->points[k], plane.normal) - plane.dist;\n\t\t\t\tif (d < -ON_EPSILON)\n\t\t\t\t{\t// source is on the negative side, so we want all\n\t\t\t\t\t// pass and target on the positive side\n\t\t\t\t\tfliptest = qfalse;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse if (d > ON_EPSILON)\n\t\t\t\t{\t// source is on the positive side, so we want all\n\t\t\t\t\t// pass and target on the negative side\n\t\t\t\t\tfliptest = qtrue;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (k == source->numpoints)\n\t\t\t\tcontinue;\t\t// planar with source portal\n#else\n\t\t\tfliptest = flipclip;\n#endif\n\t\t\t//\n\t\t\t// flip the normal if the source portal is backwards\n\t\t\t//\n\t\t\tif (fliptest)\n\t\t\t{\n\t\t\t\tVectorSubtract (vec3_origin, plane.normal, plane.normal);\n\t\t\t\tplane.dist = -plane.dist;\n\t\t\t}\n#if 1\n\t\t\t//\n\t\t\t// if all of the pass portal points are now on the positive side,\n\t\t\t// this is the seperating plane\n\t\t\t//\n\t\t\tcounts[0] = counts[1] = counts[2] = 0;\n\t\t\tfor (k=0 ; k<pass->numpoints ; k++)\n\t\t\t{\n\t\t\t\tif (k==j)\n\t\t\t\t\tcontinue;\n\t\t\t\td = DotProduct (pass->points[k], plane.normal) - plane.dist;\n\t\t\t\tif (d < -ON_EPSILON)\n\t\t\t\t\tbreak;\n\t\t\t\telse if (d > ON_EPSILON)\n\t\t\t\t\tcounts[0]++;\n\t\t\t\telse\n\t\t\t\t\tcounts[2]++;\n\t\t\t}\n\t\t\tif (k != pass->numpoints)\n\t\t\t\tcontinue;\t// points on negative side, not a seperating plane\n\t\t\t\t\n\t\t\tif (!counts[0])\n\t\t\t\tcontinue;\t// planar with seperating plane\n#else\n\t\t\tk = (j+1)%pass->numpoints;\n\t\t\td = DotProduct (pass->points[k], plane.normal) - plane.dist;\n\t\t\tif (d < -ON_EPSILON)\n\t\t\t\tcontinue;\n\t\t\tk = (j+pass->numpoints-1)%pass->numpoints;\n\t\t\td = DotProduct (pass->points[k], plane.normal) - plane.dist;\n\t\t\tif (d < -ON_EPSILON)\n\t\t\t\tcontinue;\t\t\t\n#endif\n\t\t\t//\n\t\t\t// flip the normal if we want the back side\n\t\t\t//\n\t\t\tif (flipclip)\n\t\t\t{\n\t\t\t\tVectorSubtract (vec3_origin, plane.normal, plane.normal);\n\t\t\t\tplane.dist = -plane.dist;\n\t\t\t}\n\n#ifdef SEPERATORCACHE\n\t\t\tstack->seperators[flipclip][stack->numseperators[flipclip]] = plane;\n\t\t\tif (++stack->numseperators[flipclip] >= MAX_SEPERATORS)\n\t\t\t\tError(\"MAX_SEPERATORS\");\n#endif\n\t\t\t//MrE: fast check first\n\t\t\td = DotProduct (stack->portal->origin, plane.normal) - plane.dist;\n\t\t\t//if completely at the back of the seperator plane\n\t\t\tif (d < -stack->portal->radius)\n\t\t\t\treturn NULL;\n\t\t\t//if completely on the front of the seperator plane\n\t\t\tif (d > stack->portal->radius)\n\t\t\t\tbreak;\n\n\t\t\t//\n\t\t\t// clip target by the seperating plane\n\t\t\t//\n\t\t\ttarget = VisChopWinding (target, stack, &plane);\n\t\t\tif (!target)\n\t\t\t\treturn NULL;\t\t// target is not visible\n\n\t\t\tbreak;\t\t// optimization by Antony Suter\n\t\t}\n\t}\n\t\n\treturn target;\n}\n\n/*\n==================\nRecursiveLeafFlow\n\nFlood fill through the leafs\nIf src_portal is NULL, this is the originating leaf\n==================\n*/\nvoid RecursiveLeafFlow (int leafnum, threaddata_t *thread, pstack_t *prevstack)\n{\n\tpstack_t\tstack;\n\tvportal_t\t*p;\n\tplane_t\t\tbackplane;\n\tleaf_t \t\t*leaf;\n\tint\t\t\ti, j, n;\n\tlong\t\t*test, *might, *prevmight, *vis, more;\n\tint\t\t\tpnum;\n\n\tthread->c_chains++;\n\n\tleaf = &leafs[leafnum];\n//\tCheckStack (leaf, thread);\n\n\tprevstack->next = &stack;\n\n\tstack.next = NULL;\n\tstack.leaf = leaf;\n\tstack.portal = NULL;\n\tstack.depth = prevstack->depth + 1;\n\n#ifdef SEPERATORCACHE\n\tstack.numseperators[0] = 0;\n\tstack.numseperators[1] = 0;\n#endif\n\n\tmight = (long *)stack.mightsee;\n\tvis = (long *)thread->base->portalvis;\n\t\n\t// check all portals for flowing into other leafs\t\n\tfor (i = 0; i < leaf->numportals; i++)\n\t{\n\t\tp = leaf->portals[i];\n\t\tif (p->removed)\n\t\t\tcontinue;\n\t\tpnum = p - portals;\n\n\t\t/* MrE: portal trace debug code\n\t\t{\n\t\t\tint portaltrace[] = {13, 16, 17, 37};\n\t\t\tpstack_t *s;\n\n\t\t\ts = &thread->pstack_head;\n\t\t\tfor (j = 0; s->next && j < sizeof(portaltrace)/sizeof(int) - 1; j++, s = s->next)\n\t\t\t{\n\t\t\t\tif (s->portal->num != portaltrace[j])\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (j >= sizeof(portaltrace)/sizeof(int) - 1)\n\t\t\t{\n\t\t\t\tif (p->num == portaltrace[j])\n\t\t\t\t\tn = 0; //traced through all the portals\n\t\t\t}\n\t\t}\n\t\t*/\n\n\t\tif ( ! (prevstack->mightsee[pnum >> 3] & (1<<(pnum&7)) ) )\n\t\t{\n\t\t\tcontinue;\t// can't possibly see it\n\t\t}\n\n\t\t// if the portal can't see anything we haven't allready seen, skip it\n\t\tif (p->status == stat_done)\n\t\t{\n\t\t\ttest = (long *)p->portalvis;\n\t\t}\n\t\telse\n\t\t{\n\t\t\ttest = (long *)p->portalflood;\n\t\t}\n\n\t\tmore = 0;\n\t\tprevmight = (long *)prevstack->mightsee;\n\t\tfor (j=0 ; j<portallongs ; j++)\n\t\t{\n\t\t\tmight[j] = prevmight[j] & test[j];\n\t\t\tmore |= (might[j] & ~vis[j]);\n\t\t}\n\t\t\n\t\tif (!more && \n\t\t\t(thread->base->portalvis[pnum>>3] & (1<<(pnum&7))) )\n\t\t{\t// can't see anything new\n\t\t\tcontinue;\n\t\t}\n\n\t\t// get plane of portal, point normal into the neighbor leaf\n\t\tstack.portalplane = p->plane;\n\t\tVectorSubtract (vec3_origin, p->plane.normal, backplane.normal);\n\t\tbackplane.dist = -p->plane.dist;\n\t\t\n//\t\tc_portalcheck++;\n\t\t\n\t\tstack.portal = p;\n\t\tstack.next = NULL;\n\t\tstack.freewindings[0] = 1;\n\t\tstack.freewindings[1] = 1;\n\t\tstack.freewindings[2] = 1;\n\t\t\n#if 1\n\t\t{\n\t\t\tfloat d;\n\n\t\t\td = DotProduct (p->origin, thread->pstack_head.portalplane.normal);\n\t\t\td -= thread->pstack_head.portalplane.dist;\n\t\t\tif (d < -p->radius)\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse if (d > p->radius)\n\t\t\t{\n\t\t\t\tstack.pass = p->winding;\n\t\t\t}\n\t\t\telse\t\n\t\t\t{\n\t\t\t\tstack.pass = VisChopWinding (p->winding, &stack, &thread->pstack_head.portalplane);\n\t\t\t\tif (!stack.pass)\n\t\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n#else\n\t\tstack.pass = VisChopWinding (p->winding, &stack, &thread->pstack_head.portalplane);\n\t\tif (!stack.pass)\n\t\t\tcontinue;\n#endif\n\n\t\n#if 1\n\t\t{\n\t\t\tfloat d;\n\n\t\t\td = DotProduct (thread->base->origin, p->plane.normal);\n\t\t\td -= p->plane.dist;\n\t\t\t//MrE: vis-bug fix\n\t\t\t//if (d > p->radius)\n\t\t\tif (d > thread->base->radius)\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t//MrE: vis-bug fix\n\t\t\t//if (d < -p->radius)\n\t\t\telse if (d < -thread->base->radius)\n\t\t\t{\n\t\t\t\tstack.source = prevstack->source;\n\t\t\t}\n\t\t\telse\t\n\t\t\t{\n\t\t\t\tstack.source = VisChopWinding (prevstack->source, &stack, &backplane);\n\t\t\t\t//FIXME: shouldn't we create a new source origin and radius for fast checks?\n\t\t\t\tif (!stack.source)\n\t\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n#else\n\t\tstack.source = VisChopWinding (prevstack->source, &stack, &backplane);\n\t\tif (!stack.source)\n\t\t\tcontinue;\n#endif\n\n\t\tif (!prevstack->pass)\n\t\t{\t// the second leaf can only be blocked if coplanar\n\n\t\t\t// mark the portal as visible\n\t\t\tthread->base->portalvis[pnum>>3] |= (1<<(pnum&7));\n\n\t\t\tRecursiveLeafFlow (p->leaf, thread, &stack);\n\t\t\tcontinue;\n\t\t}\n\n#ifdef SEPERATORCACHE\n\t\tif (stack.numseperators[0])\n\t\t{\n\t\t\tfor (n = 0; n < stack.numseperators[0]; n++)\n\t\t\t{\n\t\t\t\tstack.pass = VisChopWinding (stack.pass, &stack, &stack.seperators[0][n]);\n\t\t\t\tif (!stack.pass)\n\t\t\t\t\tbreak;\t\t// target is not visible\n\t\t\t}\n\t\t\tif (n < stack.numseperators[0])\n\t\t\t\tcontinue;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tstack.pass = ClipToSeperators (prevstack->source, prevstack->pass, stack.pass, qfalse, &stack);\n\t\t}\n#else\n\t\tstack.pass = ClipToSeperators (stack.source, prevstack->pass, stack.pass, qfalse, &stack);\n#endif\n\t\tif (!stack.pass)\n\t\t\tcontinue;\n\n#ifdef SEPERATORCACHE\n\t\tif (stack.numseperators[1])\n\t\t{\n\t\t\tfor (n = 0; n < stack.numseperators[1]; n++)\n\t\t\t{\n\t\t\t\tstack.pass = VisChopWinding (stack.pass, &stack, &stack.seperators[1][n]);\n\t\t\t\tif (!stack.pass)\n\t\t\t\t\tbreak;\t\t// target is not visible\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tstack.pass = ClipToSeperators (prevstack->pass, prevstack->source, stack.pass, qtrue, &stack);\n\t\t}\n#else\n\t\tstack.pass = ClipToSeperators (prevstack->pass, stack.source, stack.pass, qtrue, &stack);\n#endif\n\t\tif (!stack.pass)\n\t\t\tcontinue;\n\n\t\t// mark the portal as visible\n\t\tthread->base->portalvis[pnum>>3] |= (1<<(pnum&7));\n\n\t\t// flow through it for real\n\t\tRecursiveLeafFlow (p->leaf, thread, &stack);\n\t\t//\n\t\tstack.next = NULL;\n\t}\t\n}\n\n/*\n===============\nPortalFlow\n\ngenerates the portalvis bit vector\n===============\n*/\nvoid PortalFlow (int portalnum)\n{\n\tthreaddata_t\tdata;\n\tint\t\t\t\ti;\n\tvportal_t\t\t*p;\n\tint\t\t\t\tc_might, c_can;\n\n#ifdef MREDEBUG\n\t_printf(\"\\r%6d\", portalnum);\n#endif\n\n\tp = sorted_portals[portalnum];\n\n\tif (p->removed)\n\t{\n\t\tp->status = stat_done;\n\t\treturn;\n\t}\n\n\tp->status = stat_working;\n\n\tc_might = CountBits (p->portalflood, numportals*2);\n\n\tmemset (&data, 0, sizeof(data));\n\tdata.base = p;\n\t\n\tdata.pstack_head.portal = p;\n\tdata.pstack_head.source = p->winding;\n\tdata.pstack_head.portalplane = p->plane;\n\tdata.pstack_head.depth = 0;\n\tfor (i=0 ; i<portallongs ; i++)\n\t\t((long *)data.pstack_head.mightsee)[i] = ((long *)p->portalflood)[i];\n\n\tRecursiveLeafFlow (p->leaf, &data, &data.pstack_head);\n\n\tp->status = stat_done;\n\n\tc_can = CountBits (p->portalvis, numportals*2);\n\n\tqprintf (\"portal:%4i  mightsee:%4i  cansee:%4i (%i chains)\\n\", \n\t\t(int)(p - portals),\tc_might, c_can, data.c_chains);\n}\n\n/*\n==================\nRecursivePassageFlow\n==================\n*/\nvoid RecursivePassageFlow (vportal_t *portal, threaddata_t *thread, pstack_t *prevstack)\n{\n\tpstack_t\tstack;\n\tvportal_t\t*p;\n\tleaf_t \t\t*leaf;\n\tpassage_t\t*passage, *nextpassage;\n\tint\t\t\ti, j;\n\tlong\t\t*might, *vis, *prevmight, *cansee, *portalvis, more;\n\tint\t\t\tpnum;\n\n\tleaf = &leafs[portal->leaf];\n\n\tprevstack->next = &stack;\n\n\tstack.next = NULL;\n\tstack.depth = prevstack->depth + 1;\n\n\tvis = (long *)thread->base->portalvis;\n\n\tpassage = portal->passages;\n\tnextpassage = passage;\n\t// check all portals for flowing into other leafs\t\n\tfor (i = 0; i < leaf->numportals; i++, passage = nextpassage)\n\t{\n\t\tp = leaf->portals[i];\n\t\tif ( p->removed ) {\n\t\t\tcontinue;\n\t\t}\n\t\tnextpassage = passage->next;\n\t\tpnum = p - portals;\n\n\t\tif ( ! (prevstack->mightsee[pnum >> 3] & (1<<(pnum&7)) ) ) {\n\t\t\tcontinue;\t// can't possibly see it\n\t\t}\n\n\t\t// mark the portal as visible\n\t\tthread->base->portalvis[pnum>>3] |= (1<<(pnum&7));\n\n\t\tprevmight = (long *)prevstack->mightsee;\n\t\tcansee = (long *)passage->cansee;\n\t\tmight = (long *)stack.mightsee;\n\t\tmemcpy(might, prevmight, portalbytes);\n\t\tif (p->status == stat_done)\n\t\t\tportalvis = (long *) p->portalvis;\n\t\telse\n\t\t\tportalvis = (long *) p->portalflood;\n\t\tmore = 0;\n\t\tfor (j = 0; j < portallongs; j++)\n\t\t{\n\t\t\tif (*might)\n\t\t\t{\n\t\t\t\t*might &= *cansee++ & *portalvis++;\n\t\t\t\tmore |= (*might & ~vis[j]);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcansee++;\n\t\t\t\tportalvis++;\n\t\t\t}\n\t\t\tmight++;\n\t\t}\n\n\t\tif ( !more ) {\n\t\t\t// can't see anything new\n\t\t\tcontinue;\n\t\t}\n\n\t\t// flow through it for real\n\t\tRecursivePassageFlow(p, thread, &stack);\n\n\t\tstack.next = NULL;\n\t}\n}\n\n/*\n===============\nPassageFlow\n===============\n*/\nvoid PassageFlow (int portalnum)\n{\n\tthreaddata_t\tdata;\n\tint\t\t\t\ti;\n\tvportal_t\t\t*p;\n//\tint\t\t\t\tc_might, c_can;\n\n#ifdef MREDEBUG\n\t_printf(\"\\r%6d\", portalnum);\n#endif\n\n\tp = sorted_portals[portalnum];\n\n\tif (p->removed)\n\t{\n\t\tp->status = stat_done;\n\t\treturn;\n\t}\n\n\tp->status = stat_working;\n\n//\tc_might = CountBits (p->portalflood, numportals*2);\n\n\tmemset (&data, 0, sizeof(data));\n\tdata.base = p;\n\t\n\tdata.pstack_head.portal = p;\n\tdata.pstack_head.source = p->winding;\n\tdata.pstack_head.portalplane = p->plane;\n\tdata.pstack_head.depth = 0;\n\tfor (i=0 ; i<portallongs ; i++)\n\t\t((long *)data.pstack_head.mightsee)[i] = ((long *)p->portalflood)[i];\n\n\tRecursivePassageFlow (p, &data, &data.pstack_head);\n\n\tp->status = stat_done;\n\n\t/*\n\tc_can = CountBits (p->portalvis, numportals*2);\n\n\tqprintf (\"portal:%4i  mightsee:%4i  cansee:%4i (%i chains)\\n\", \n\t\t(int)(p - portals),\tc_might, c_can, data.c_chains);\n\t*/\n}\n\n/*\n==================\nRecursivePassagePortalFlow\n==================\n*/\nvoid RecursivePassagePortalFlow (vportal_t *portal, threaddata_t *thread, pstack_t *prevstack)\n{\n\tpstack_t\tstack;\n\tvportal_t\t*p;\n\tleaf_t \t\t*leaf;\n\tplane_t\t\tbackplane;\n\tpassage_t\t*passage, *nextpassage;\n\tint\t\t\ti, j, n;\n\tlong\t\t*might, *vis, *prevmight, *cansee, *portalvis, more;\n\tint\t\t\tpnum;\n\n//\tthread->c_chains++;\n\n\tleaf = &leafs[portal->leaf];\n//\tCheckStack (leaf, thread);\n\n\tprevstack->next = &stack;\n\n\tstack.next = NULL;\n\tstack.leaf = leaf;\n\tstack.portal = NULL;\n\tstack.depth = prevstack->depth + 1;\n\n#ifdef SEPERATORCACHE\n\tstack.numseperators[0] = 0;\n\tstack.numseperators[1] = 0;\n#endif\n\n\tvis = (long *)thread->base->portalvis;\n\n\tpassage = portal->passages;\n\tnextpassage = passage;\n\t// check all portals for flowing into other leafs\t\n\tfor (i = 0; i < leaf->numportals; i++, passage = nextpassage)\n\t{\n\t\tp = leaf->portals[i];\n\t\tif (p->removed)\n\t\t\tcontinue;\n\t\tnextpassage = passage->next;\n\t\tpnum = p - portals;\n\n\t\tif ( ! (prevstack->mightsee[pnum >> 3] & (1<<(pnum&7)) ) )\n\t\t\tcontinue;\t// can't possibly see it\n\n\t\tprevmight = (long *)prevstack->mightsee;\n\t\tcansee = (long *)passage->cansee;\n\t\tmight = (long *)stack.mightsee;\n\t\tmemcpy(might, prevmight, portalbytes);\n\t\tif (p->status == stat_done)\n\t\t\tportalvis = (long *) p->portalvis;\n\t\telse\n\t\t\tportalvis = (long *) p->portalflood;\n\t\tmore = 0;\n\t\tfor (j = 0; j < portallongs; j++)\n\t\t{\n\t\t\tif (*might)\n\t\t\t{\n\t\t\t\t*might &= *cansee++ & *portalvis++;\n\t\t\t\tmore |= (*might & ~vis[j]);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcansee++;\n\t\t\t\tportalvis++;\n\t\t\t}\n\t\t\tmight++;\n\t\t}\n\n\t\tif (!more && (thread->base->portalvis[pnum>>3] & (1<<(pnum&7))) )\n\t\t{\t// can't see anything new\n\t\t\tcontinue;\n\t\t}\n\n\t\t// get plane of portal, point normal into the neighbor leaf\n\t\tstack.portalplane = p->plane;\n\t\tVectorSubtract (vec3_origin, p->plane.normal, backplane.normal);\n\t\tbackplane.dist = -p->plane.dist;\n\t\t\n//\t\tc_portalcheck++;\n\t\t\n\t\tstack.portal = p;\n\t\tstack.next = NULL;\n\t\tstack.freewindings[0] = 1;\n\t\tstack.freewindings[1] = 1;\n\t\tstack.freewindings[2] = 1;\n\n#if 1\n\t\t{\n\t\t\tfloat d;\n\n\t\t\td = DotProduct (p->origin, thread->pstack_head.portalplane.normal);\n\t\t\td -= thread->pstack_head.portalplane.dist;\n\t\t\tif (d < -p->radius)\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse if (d > p->radius)\n\t\t\t{\n\t\t\t\tstack.pass = p->winding;\n\t\t\t}\n\t\t\telse\t\n\t\t\t{\n\t\t\t\tstack.pass = VisChopWinding (p->winding, &stack, &thread->pstack_head.portalplane);\n\t\t\t\tif (!stack.pass)\n\t\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n#else\n\t\tstack.pass = VisChopWinding (p->winding, &stack, &thread->pstack_head.portalplane);\n\t\tif (!stack.pass)\n\t\t\tcontinue;\n#endif\n\n\t\n#if 1\n\t\t{\n\t\t\tfloat d;\n\n\t\t\td = DotProduct (thread->base->origin, p->plane.normal);\n\t\t\td -= p->plane.dist;\n\t\t\t//MrE: vis-bug fix\n\t\t\t//if (d > p->radius)\n\t\t\tif (d > thread->base->radius)\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t//MrE: vis-bug fix\n\t\t\t//if (d < -p->radius)\n\t\t\telse if (d < -thread->base->radius)\n\t\t\t{\n\t\t\t\tstack.source = prevstack->source;\n\t\t\t}\n\t\t\telse\t\n\t\t\t{\n\t\t\t\tstack.source = VisChopWinding (prevstack->source, &stack, &backplane);\n\t\t\t\t//FIXME: shouldn't we create a new source origin and radius for fast checks?\n\t\t\t\tif (!stack.source)\n\t\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n#else\n\t\tstack.source = VisChopWinding (prevstack->source, &stack, &backplane);\n\t\tif (!stack.source)\n\t\t\tcontinue;\n#endif\n\n\t\tif (!prevstack->pass)\n\t\t{\t// the second leaf can only be blocked if coplanar\n\n\t\t\t// mark the portal as visible\n\t\t\tthread->base->portalvis[pnum>>3] |= (1<<(pnum&7));\n\n\t\t\tRecursivePassagePortalFlow (p, thread, &stack);\n\t\t\tcontinue;\n\t\t}\n\n#ifdef SEPERATORCACHE\n\t\tif (stack.numseperators[0])\n\t\t{\n\t\t\tfor (n = 0; n < stack.numseperators[0]; n++)\n\t\t\t{\n\t\t\t\tstack.pass = VisChopWinding (stack.pass, &stack, &stack.seperators[0][n]);\n\t\t\t\tif (!stack.pass)\n\t\t\t\t\tbreak;\t\t// target is not visible\n\t\t\t}\n\t\t\tif (n < stack.numseperators[0])\n\t\t\t\tcontinue;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tstack.pass = ClipToSeperators (prevstack->source, prevstack->pass, stack.pass, qfalse, &stack);\n\t\t}\n#else\n\t\tstack.pass = ClipToSeperators (stack.source, prevstack->pass, stack.pass, qfalse, &stack);\n#endif\n\t\tif (!stack.pass)\n\t\t\tcontinue;\n\n#ifdef SEPERATORCACHE\n\t\tif (stack.numseperators[1])\n\t\t{\n\t\t\tfor (n = 0; n < stack.numseperators[1]; n++)\n\t\t\t{\n\t\t\t\tstack.pass = VisChopWinding (stack.pass, &stack, &stack.seperators[1][n]);\n\t\t\t\tif (!stack.pass)\n\t\t\t\t\tbreak;\t\t// target is not visible\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tstack.pass = ClipToSeperators (prevstack->pass, prevstack->source, stack.pass, qtrue, &stack);\n\t\t}\n#else\n\t\tstack.pass = ClipToSeperators (prevstack->pass, stack.source, stack.pass, qtrue, &stack);\n#endif\n\t\tif (!stack.pass)\n\t\t\tcontinue;\n\n\t\t// mark the portal as visible\n\t\tthread->base->portalvis[pnum>>3] |= (1<<(pnum&7));\n\n\t\t// flow through it for real\n\t\tRecursivePassagePortalFlow(p, thread, &stack);\n\t\t//\n\t\tstack.next = NULL;\n\t}\n}\n\n/*\n===============\nPassagePortalFlow\n===============\n*/\nvoid PassagePortalFlow (int portalnum)\n{\n\tthreaddata_t\tdata;\n\tint\t\t\t\ti;\n\tvportal_t\t\t*p;\n//\tint\t\t\t\tc_might, c_can;\n\n#ifdef MREDEBUG\n\t_printf(\"\\r%6d\", portalnum);\n#endif\n\n\tp = sorted_portals[portalnum];\n\n\tif (p->removed)\n\t{\n\t\tp->status = stat_done;\n\t\treturn;\n\t}\n\n\tp->status = stat_working;\n\n//\tc_might = CountBits (p->portalflood, numportals*2);\n\n\tmemset (&data, 0, sizeof(data));\n\tdata.base = p;\n\t\n\tdata.pstack_head.portal = p;\n\tdata.pstack_head.source = p->winding;\n\tdata.pstack_head.portalplane = p->plane;\n\tdata.pstack_head.depth = 0;\n\tfor (i=0 ; i<portallongs ; i++)\n\t\t((long *)data.pstack_head.mightsee)[i] = ((long *)p->portalflood)[i];\n\n\tRecursivePassagePortalFlow (p, &data, &data.pstack_head);\n\n\tp->status = stat_done;\n\n\t/*\n\tc_can = CountBits (p->portalvis, numportals*2);\n\n\tqprintf (\"portal:%4i  mightsee:%4i  cansee:%4i (%i chains)\\n\", \n\t\t(int)(p - portals),\tc_might, c_can, data.c_chains);\n\t*/\n}\n\nwinding_t *PassageChopWinding (winding_t *in, winding_t *out, plane_t *split)\n{\n\tvec_t\tdists[128];\n\tint\t\tsides[128];\n\tint\t\tcounts[3];\n\tvec_t\tdot;\n\tint\t\ti, j;\n\tvec_t\t*p1, *p2;\n\tvec3_t\tmid;\n\twinding_t\t*neww;\n\n\tcounts[0] = counts[1] = counts[2] = 0;\n\n\t// determine sides for each point\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tdot = DotProduct (in->points[i], split->normal);\n\t\tdot -= split->dist;\n\t\tdists[i] = dot;\n\t\tif (dot > ON_EPSILON)\n\t\t\tsides[i] = SIDE_FRONT;\n\t\telse if (dot < -ON_EPSILON)\n\t\t\tsides[i] = SIDE_BACK;\n\t\telse\n\t\t{\n\t\t\tsides[i] = SIDE_ON;\n\t\t}\n\t\tcounts[sides[i]]++;\n\t}\n\n\tif (!counts[1])\n\t\treturn in;\t\t// completely on front side\n\t\n\tif (!counts[0])\n\t{\n\t\treturn NULL;\n\t}\n\n\tsides[i] = sides[0];\n\tdists[i] = dists[0];\n\t\n\tneww = out;\n\n\tneww->numpoints = 0;\n\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tp1 = in->points[i];\n\n\t\tif (neww->numpoints == MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\treturn in;\t\t// can't chop -- fall back to original\n\t\t}\n\n\t\tif (sides[i] == SIDE_ON)\n\t\t{\n\t\t\tVectorCopy (p1, neww->points[neww->numpoints]);\n\t\t\tneww->numpoints++;\n\t\t\tcontinue;\n\t\t}\n\t\n\t\tif (sides[i] == SIDE_FRONT)\n\t\t{\n\t\t\tVectorCopy (p1, neww->points[neww->numpoints]);\n\t\t\tneww->numpoints++;\n\t\t}\n\t\t\n\t\tif (sides[i+1] == SIDE_ON || sides[i+1] == sides[i])\n\t\t\tcontinue;\n\t\t\t\n\t\tif (neww->numpoints == MAX_POINTS_ON_FIXED_WINDING)\n\t\t{\n\t\t\treturn in;\t\t// can't chop -- fall back to original\n\t\t}\n\n\t\t// generate a split point\n\t\tp2 = in->points[(i+1)%in->numpoints];\n\t\t\n\t\tdot = dists[i] / (dists[i]-dists[i+1]);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\t// avoid round off error when possible\n\t\t\tif (split->normal[j] == 1)\n\t\t\t\tmid[j] = split->dist;\n\t\t\telse if (split->normal[j] == -1)\n\t\t\t\tmid[j] = -split->dist;\n\t\t\telse\n\t\t\t\tmid[j] = p1[j] + dot*(p2[j]-p1[j]);\n\t\t}\n\t\t\t\n\t\tVectorCopy (mid, neww->points[neww->numpoints]);\n\t\tneww->numpoints++;\n\t}\n\t\n\treturn neww;\n}\n\n/*\n===============\nAddSeperators\n===============\n*/\nint AddSeperators (winding_t *source, winding_t *pass, qboolean flipclip, plane_t *seperators, int maxseperators)\n{\n\tint\t\t\ti, j, k, l;\n\tplane_t\t\tplane;\n\tvec3_t\t\tv1, v2;\n\tfloat\t\td;\n\tvec_t\t\tlength;\n\tint\t\t\tcounts[3], numseperators;\n\tqboolean\tfliptest;\n\n\tnumseperators = 0;\n\t// check all combinations\t\n\tfor (i=0 ; i<source->numpoints ; i++)\n\t{\n\t\tl = (i+1)%source->numpoints;\n\t\tVectorSubtract (source->points[l] , source->points[i], v1);\n\n\t\t// find a vertex of pass that makes a plane that puts all of the\n\t\t// vertexes of pass on the front side and all of the vertexes of\n\t\t// source on the back side\n\t\tfor (j=0 ; j<pass->numpoints ; j++)\n\t\t{\n\t\t\tVectorSubtract (pass->points[j], source->points[i], v2);\n\n\t\t\tplane.normal[0] = v1[1]*v2[2] - v1[2]*v2[1];\n\t\t\tplane.normal[1] = v1[2]*v2[0] - v1[0]*v2[2];\n\t\t\tplane.normal[2] = v1[0]*v2[1] - v1[1]*v2[0];\n\t\t\t\n\t\t\t// if points don't make a valid plane, skip it\n\n\t\t\tlength = plane.normal[0] * plane.normal[0]\n\t\t\t+ plane.normal[1] * plane.normal[1]\n\t\t\t+ plane.normal[2] * plane.normal[2];\n\t\t\t\n\t\t\tif (length < ON_EPSILON)\n\t\t\t\tcontinue;\n\n\t\t\tlength = 1/sqrt(length);\n\t\t\t\n\t\t\tplane.normal[0] *= length;\n\t\t\tplane.normal[1] *= length;\n\t\t\tplane.normal[2] *= length;\n\n\t\t\tplane.dist = DotProduct (pass->points[j], plane.normal);\n\n\t\t\t//\n\t\t\t// find out which side of the generated seperating plane has the\n\t\t\t// source portal\n\t\t\t//\n#if 1\n\t\t\tfliptest = qfalse;\n\t\t\tfor (k=0 ; k<source->numpoints ; k++)\n\t\t\t{\n\t\t\t\tif (k == i || k == l)\n\t\t\t\t\tcontinue;\n\t\t\t\td = DotProduct (source->points[k], plane.normal) - plane.dist;\n\t\t\t\tif (d < -ON_EPSILON)\n\t\t\t\t{\t// source is on the negative side, so we want all\n\t\t\t\t\t// pass and target on the positive side\n\t\t\t\t\tfliptest = qfalse;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse if (d > ON_EPSILON)\n\t\t\t\t{\t// source is on the positive side, so we want all\n\t\t\t\t\t// pass and target on the negative side\n\t\t\t\t\tfliptest = qtrue;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (k == source->numpoints)\n\t\t\t\tcontinue;\t\t// planar with source portal\n#else\n\t\t\tfliptest = flipclip;\n#endif\n\t\t\t//\n\t\t\t// flip the normal if the source portal is backwards\n\t\t\t//\n\t\t\tif (fliptest)\n\t\t\t{\n\t\t\t\tVectorSubtract (vec3_origin, plane.normal, plane.normal);\n\t\t\t\tplane.dist = -plane.dist;\n\t\t\t}\n#if 1\n\t\t\t//\n\t\t\t// if all of the pass portal points are now on the positive side,\n\t\t\t// this is the seperating plane\n\t\t\t//\n\t\t\tcounts[0] = counts[1] = counts[2] = 0;\n\t\t\tfor (k=0 ; k<pass->numpoints ; k++)\n\t\t\t{\n\t\t\t\tif (k==j)\n\t\t\t\t\tcontinue;\n\t\t\t\td = DotProduct (pass->points[k], plane.normal) - plane.dist;\n\t\t\t\tif (d < -ON_EPSILON)\n\t\t\t\t\tbreak;\n\t\t\t\telse if (d > ON_EPSILON)\n\t\t\t\t\tcounts[0]++;\n\t\t\t\telse\n\t\t\t\t\tcounts[2]++;\n\t\t\t}\n\t\t\tif (k != pass->numpoints)\n\t\t\t\tcontinue;\t// points on negative side, not a seperating plane\n\t\t\t\t\n\t\t\tif (!counts[0])\n\t\t\t\tcontinue;\t// planar with seperating plane\n#else\n\t\t\tk = (j+1)%pass->numpoints;\n\t\t\td = DotProduct (pass->points[k], plane.normal) - plane.dist;\n\t\t\tif (d < -ON_EPSILON)\n\t\t\t\tcontinue;\n\t\t\tk = (j+pass->numpoints-1)%pass->numpoints;\n\t\t\td = DotProduct (pass->points[k], plane.normal) - plane.dist;\n\t\t\tif (d < -ON_EPSILON)\n\t\t\t\tcontinue;\t\t\t\n#endif\n\t\t\t//\n\t\t\t// flip the normal if we want the back side\n\t\t\t//\n\t\t\tif (flipclip)\n\t\t\t{\n\t\t\t\tVectorSubtract (vec3_origin, plane.normal, plane.normal);\n\t\t\t\tplane.dist = -plane.dist;\n\t\t\t}\n\n\t\t\tif (numseperators >= maxseperators)\n\t\t\t\tError(\"max seperators\");\n\t\t\tseperators[numseperators] = plane;\n\t\t\tnumseperators++;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn numseperators;\n}\n\n/*\n===============\nCreatePassages\n\nMrE: create passages from one portal to all the portals in the leaf the portal leads to\n\t every passage has a cansee bit string with all the portals that can be\n\t seen through the passage\n===============\n*/\nvoid CreatePassages(int portalnum)\n{\n\tint i, j, k, n, numseperators, numsee;\n\tfloat d;\n\tvportal_t *portal, *p, *target;\n\tleaf_t *leaf;\n\tpassage_t\t*passage, *lastpassage;\n\tplane_t seperators[MAX_SEPERATORS*2];\n\twinding_t *w;\n\twinding_t in, out, *res;\n\n#ifdef MREDEBUG\n\t_printf(\"\\r%6d\", portalnum);\n#endif\n\n\tportal = sorted_portals[portalnum];\n\n\tif (portal->removed)\n\t{\n\t\tportal->status = stat_done;\n\t\treturn;\n\t}\n\n\tlastpassage = NULL;\n\tleaf = &leafs[portal->leaf];\n\tfor (i = 0; i < leaf->numportals; i++)\n\t{\n\t\ttarget = leaf->portals[i];\n\t\tif (target->removed)\n\t\t\tcontinue;\n\n\t\tpassage = (passage_t *) malloc(sizeof(passage_t) + portalbytes);\n\t\tmemset(passage, 0, sizeof(passage_t) + portalbytes);\n\t\tnumseperators = AddSeperators(portal->winding, target->winding, qfalse, seperators, MAX_SEPERATORS*2);\n\t\tnumseperators += AddSeperators(target->winding, portal->winding, qtrue, &seperators[numseperators], MAX_SEPERATORS*2-numseperators);\n\n\t\tpassage->next = NULL;\n\t\tif (lastpassage)\n\t\t\tlastpassage->next = passage;\n\t\telse\n\t\t\tportal->passages = passage;\n\t\tlastpassage = passage;\n\n\t\tnumsee = 0;\n\t\t//create the passage->cansee\n\t\tfor (j = 0; j < numportals * 2; j++)\n\t\t{\n\t\t\tp = &portals[j];\n\t\t\tif (p->removed)\n\t\t\t\tcontinue;\n\t\t\tif ( ! (target->portalflood[j >> 3] & (1<<(j&7)) ) )\n\t\t\t\tcontinue;\n\t\t\tif ( ! (portal->portalflood[j >> 3] & (1<<(j&7)) ) )\n\t\t\t\tcontinue;\n\t\t\tfor (k = 0; k < numseperators; k++)\n\t\t\t{\n\t\t\t\t//\n\t\t\t\td = DotProduct (p->origin, seperators[k].normal) - seperators[k].dist;\n\t\t\t\t//if completely at the back of the seperator plane\n\t\t\t\tif (d < -p->radius + ON_EPSILON)\n\t\t\t\t\tbreak;\n\t\t\t\tw = p->winding;\n\t\t\t\tfor (n = 0; n < w->numpoints; n++)\n\t\t\t\t{\n\t\t\t\t\td = DotProduct (w->points[n], seperators[k].normal) - seperators[k].dist;\n\t\t\t\t\t//if at the front of the seperator\n\t\t\t\t\tif (d > ON_EPSILON)\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t//if no points are at the front of the seperator\n\t\t\t\tif (n >= w->numpoints)\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (k < numseperators)\n\t\t\t\tcontinue;\n\t\t\tmemcpy(&in, p->winding, sizeof(winding_t));\n\t\t\tfor (k = 0; k < numseperators; k++)\n\t\t\t{\n\t\t\t\tres = PassageChopWinding(&in, &out, &seperators[k]);\n\t\t\t\tif (res == &out)\n\t\t\t\t\tmemcpy(&in, &out, sizeof(winding_t));\n\t\t\t\tif (res == NULL)\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (k < numseperators)\n\t\t\t\tcontinue;\n\t\t\tpassage->cansee[j >> 3] |= (1<<(j&7));\n\t\t\tnumsee++;\n\t\t}\n\t}\n}\n\nvoid PassageMemory(void)\n{\n\tint i, j, totalmem, totalportals;\n\tvportal_t *portal, *target;\n\tleaf_t *leaf;\n\n\ttotalmem = 0;\n\ttotalportals = 0;\n\tfor (i = 0; i < numportals; i++)\n\t{\n\t\tportal = sorted_portals[i];\n\t\tif (portal->removed)\n\t\t\tcontinue;\n\t\tleaf = &leafs[portal->leaf];\n\t\tfor (j = 0; j < leaf->numportals; j++)\n\t\t{\n\t\t\ttarget = leaf->portals[j];\n\t\t\tif (target->removed)\n\t\t\t\tcontinue;\n\t\t\ttotalmem += sizeof(passage_t) + portalbytes;\n\t\t\ttotalportals++;\n\t\t}\n\t}\n\t_printf(\"%7i average number of passages per leaf\\n\", totalportals / numportals);\n\t_printf(\"%7i MB required passage memory\\n\", totalmem >> 10 >> 10);\n}\n\n/*\n===============================================================================\n\nThis is a rough first-order aproximation that is used to trivially reject some\nof the final calculations.\n\n\nCalculates portalfront and portalflood bit vectors\n\nthinking about:\n\ntypedef struct passage_s\n{\n\tstruct passage_s\t*next;\n\tstruct portal_s\t\t*to;\n\tstryct sep_s\t\t*seperators;\n\tbyte\t\t\t\t*mightsee;\n} passage_t;\n\ntypedef struct portal_s\n{\n\tstruct passage_s\t*passages;\n\tint\t\t\t\t\tleaf;\t\t// leaf portal faces into\n} portal_s;\n\nleaf = portal->leaf\nclear \nfor all portals\n\n\ncalc portal visibility\n\tclear bit vector\n\tfor all passages\n\t\tpassage visibility\n\n\nfor a portal to be visible to a passage, it must be on the front of\nall seperating planes, and both portals must be behind the new portal\n\n===============================================================================\n*/\n\nint\t\tc_flood, c_vis;\n\n\n/*\n==================\nSimpleFlood\n\n==================\n*/\nvoid SimpleFlood (vportal_t *srcportal, int leafnum)\n{\n\tint\t\ti;\n\tleaf_t\t*leaf;\n\tvportal_t\t*p;\n\tint\t\tpnum;\n\n\tleaf = &leafs[leafnum];\n\t\n\tfor (i=0 ; i<leaf->numportals ; i++)\n\t{\n\t\tp = leaf->portals[i];\n\t\tif (p->removed)\n\t\t\tcontinue;\n\t\tpnum = p - portals;\n\t\tif ( ! (srcportal->portalfront[pnum>>3] & (1<<(pnum&7)) ) )\n\t\t\tcontinue;\n\n\t\tif (srcportal->portalflood[pnum>>3] & (1<<(pnum&7)) )\n\t\t\tcontinue;\n\n\t\tsrcportal->portalflood[pnum>>3] |= (1<<(pnum&7));\n\t\t\n\t\tSimpleFlood (srcportal, p->leaf);\n\t}\n}\n\n/*\n==============\nBasePortalVis\n==============\n*/\nvoid BasePortalVis (int portalnum)\n{\n\tint\t\t\tj, k;\n\tvportal_t\t*tp, *p;\n\tfloat\t\td;\n\twinding_t\t*w;\n\n\tp = portals+portalnum;\n\n\tif (p->removed)\n\t\treturn;\n\n\tp->portalfront = malloc (portalbytes);\n\tmemset (p->portalfront, 0, portalbytes);\n\n\tp->portalflood = malloc (portalbytes);\n\tmemset (p->portalflood, 0, portalbytes);\n\t\n\tp->portalvis = malloc (portalbytes);\n\tmemset (p->portalvis, 0, portalbytes);\n\t\n\tfor (j=0, tp = portals ; j<numportals*2 ; j++, tp++)\n\t{\n\t\tif (j == portalnum)\n\t\t\tcontinue;\n\t\tif (tp->removed)\n\t\t\tcontinue;\n\t\t/*\n\t\tif (farplanedist >= 0)\n\t\t{\n\t\t\tvec3_t dir;\n\t\t\tVectorSubtract(p->origin, tp->origin, dir);\n\t\t\tif (VectorLength(dir) > farplanedist - p->radius - tp->radius)\n\t\t\t\tcontinue;\n\t\t}\n\t\t*/\n\t\tw = tp->winding;\n\t\tfor (k=0 ; k<w->numpoints ; k++)\n\t\t{\n\t\t\td = DotProduct (w->points[k], p->plane.normal)\n\t\t\t\t- p->plane.dist;\n\t\t\tif (d > ON_EPSILON)\n\t\t\t\tbreak;\n\t\t}\n\t\tif (k == w->numpoints)\n\t\t\tcontinue;\t// no points on front\n\n\t\tw = p->winding;\n\t\tfor (k=0 ; k<w->numpoints ; k++)\n\t\t{\n\t\t\td = DotProduct (w->points[k], tp->plane.normal)\n\t\t\t\t- tp->plane.dist;\n\t\t\tif (d < -ON_EPSILON)\n\t\t\t\tbreak;\n\t\t}\n\t\tif (k == w->numpoints)\n\t\t\tcontinue;\t// no points on front\n\n\t\tp->portalfront[j>>3] |= (1<<(j&7));\n\t}\n\t\n\tSimpleFlood (p, p->leaf);\n\n\tp->nummightsee = CountBits (p->portalflood, numportals*2);\n//\t_printf (\"portal %i: %i mightsee\\n\", portalnum, p->nummightsee);\n\tc_flood += p->nummightsee;\n}\n\n\n\n\n\n/*\n===============================================================================\n\nThis is a second order aproximation \n\nCalculates portalvis bit vector\n\nWAAAAAAY too slow.\n\n===============================================================================\n*/\n\n/*\n==================\nRecursiveLeafBitFlow\n\n==================\n*/\nvoid RecursiveLeafBitFlow (int leafnum, byte *mightsee, byte *cansee)\n{\n\tvportal_t\t*p;\n\tleaf_t \t\t*leaf;\n\tint\t\t\ti, j;\n\tlong\t\tmore;\n\tint\t\t\tpnum;\n\tbyte\t\tnewmight[MAX_PORTALS/8];\n\n\tleaf = &leafs[leafnum];\n\t\n\t// check all portals for flowing into other leafs\n\tfor (i=0 ; i<leaf->numportals ; i++)\n\t{\n\t\tp = leaf->portals[i];\n\t\tif (p->removed)\n\t\t\tcontinue;\n\t\tpnum = p - portals;\n\n\t\t// if some previous portal can't see it, skip\n\t\tif (! (mightsee[pnum>>3] & (1<<(pnum&7)) ) )\n\t\t\tcontinue;\n\n\t\t// if this portal can see some portals we mightsee, recurse\n\t\tmore = 0;\n\t\tfor (j=0 ; j<portallongs ; j++)\n\t\t{\n\t\t\t((long *)newmight)[j] = ((long *)mightsee)[j] \n\t\t\t\t& ((long *)p->portalflood)[j];\n\t\t\tmore |= ((long *)newmight)[j] & ~((long *)cansee)[j];\n\t\t}\n\n\t\tif (!more)\n\t\t\tcontinue;\t// can't see anything new\n\n\t\tcansee[pnum>>3] |= (1<<(pnum&7));\n\n\t\tRecursiveLeafBitFlow (p->leaf, newmight, cansee);\n\t}\t\n}\n\n/*\n==============\nBetterPortalVis\n==============\n*/\nvoid BetterPortalVis (int portalnum)\n{\n\tvportal_t\t*p;\n\n\tp = portals+portalnum;\n\n\tif (p->removed)\n\t\treturn;\n\n\tRecursiveLeafBitFlow (p->leaf, p->portalflood, p->portalvis);\n\n\t// build leaf vis information\n\tp->nummightsee = CountBits (p->portalvis, numportals*2);\n\tc_vis += p->nummightsee;\n}\n\n\n"
  },
  {
    "path": "q3map/writebsp.c",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"qbsp.h\"\n\n/*\n============\nEmitShader\n============\n*/\nint\tEmitShader( const char *shader ) {\n\tint\t\t\t\ti;\n\tshaderInfo_t\t*si;\n\n\tif ( !shader ) {\n\t\tshader = \"noshader\";\n\t}\n\n\tfor ( i = 0 ; i < numShaders ; i++ ) {\n\t\tif ( !Q_stricmp( shader, dshaders[i].shader ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\n\tif ( i == MAX_MAP_SHADERS ) {\n\t\tError( \"MAX_MAP_SHADERS\" );\n\t}\n\tnumShaders++;\n\tstrcpy( dshaders[i].shader, shader );\n\n\tsi = ShaderInfoForShader( shader );\n\tdshaders[i].surfaceFlags = si->surfaceFlags;\n\tdshaders[i].contentFlags = si->contents;\n\n\treturn i;\n}\n\n\n/*\n============\nEmitPlanes\n\nThere is no oportunity to discard planes, because all of the original\nbrushes will be saved in the map.\n============\n*/\nvoid EmitPlanes (void)\n{\n\tint\t\t\ti;\n\tdplane_t\t*dp;\n\tplane_t\t\t*mp;\n\n\tmp = mapplanes;\n\tfor (i=0 ; i<nummapplanes ; i++, mp++)\n\t{\n\t\tdp = &dplanes[numplanes];\n\t\tVectorCopy ( mp->normal, dp->normal);\n\t\tdp->dist = mp->dist;\n\t\tnumplanes++;\n\t}\n}\n\n\n\n/*\n==================\nEmitLeaf\n==================\n*/\nvoid EmitLeaf (node_t *node)\n{\n\tdleaf_t\t\t\t\t*leaf_p;\n\tbspbrush_t\t\t\t*b;\n\tdrawSurfRef_t\t\t*dsr;\n\n\t// emit a leaf\n\tif (numleafs >= MAX_MAP_LEAFS)\n\t\tError (\"MAX_MAP_LEAFS\");\n\n\tleaf_p = &dleafs[numleafs];\n\tnumleafs++;\n\n\tleaf_p->cluster = node->cluster;\n\tleaf_p->area = node->area;\n\n\t//\n\t// write bounding box info\n\t//\t\n\tVectorCopy (node->mins, leaf_p->mins);\n\tVectorCopy (node->maxs, leaf_p->maxs);\n\t\n\t//\n\t// write the leafbrushes\n\t//\n\tleaf_p->firstLeafBrush = numleafbrushes;\n\tfor ( b = node->brushlist ; b ; b = b->next ) {\n\t\tif ( numleafbrushes >= MAX_MAP_LEAFBRUSHES ) {\n\t\t\tError( \"MAX_MAP_LEAFBRUSHES\" );\n\t\t}\n\t\tdleafbrushes[numleafbrushes] = b->original->outputNumber;\n\t\tnumleafbrushes++;\n\t}\n\tleaf_p->numLeafBrushes = numleafbrushes - leaf_p->firstLeafBrush;\n\n\t//\n\t// write the surfaces visible in this leaf\n\t//\n\tif ( node->opaque ) {\n\t\treturn;\t\t// no leaffaces in solids\n\t}\n\t\n\t// add the drawSurfRef_t drawsurfs\n\tleaf_p->firstLeafSurface = numleafsurfaces;\n\tfor ( dsr = node->drawSurfReferences ; dsr ; dsr = dsr->nextRef ) {\n\t\tif ( numleafsurfaces >= MAX_MAP_LEAFFACES)\n\t\t\tError (\"MAX_MAP_LEAFFACES\");\n\t\tdleafsurfaces[numleafsurfaces] = dsr->outputNumber;\n\t\tnumleafsurfaces++;\t\t\t\n\t}\n\n\n\tleaf_p->numLeafSurfaces = numleafsurfaces - leaf_p->firstLeafSurface;\n}\n\n\n/*\n============\nEmitDrawNode_r\n============\n*/\nint EmitDrawNode_r (node_t *node)\n{\n\tdnode_t\t*n;\n\tint\t\ti;\n\n\tif (node->planenum == PLANENUM_LEAF)\n\t{\n\t\tEmitLeaf (node);\n\t\treturn -numleafs;\n\t}\n\n\t// emit a node\t\n\tif (numnodes == MAX_MAP_NODES)\n\t\tError (\"MAX_MAP_NODES\");\n\tn = &dnodes[numnodes];\n\tnumnodes++;\n\n\tVectorCopy (node->mins, n->mins);\n\tVectorCopy (node->maxs, n->maxs);\n\n\tif (node->planenum & 1)\n\t\tError (\"WriteDrawNodes_r: odd planenum\");\n\tn->planeNum = node->planenum;\n\n\t//\n\t// recursively output the other nodes\n\t//\t\n\tfor (i=0 ; i<2 ; i++)\n\t{\n\t\tif (node->children[i]->planenum == PLANENUM_LEAF)\n\t\t{\n\t\t\tn->children[i] = -(numleafs + 1);\n\t\t\tEmitLeaf (node->children[i]);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tn->children[i] = numnodes;\t\n\t\t\tEmitDrawNode_r (node->children[i]);\n\t\t}\n\t}\n\n\treturn n - dnodes;\n}\n\n//=========================================================\n\n\n\n/*\n============\nSetModelNumbers\n============\n*/\nvoid SetModelNumbers (void)\n{\n\tint\t\ti;\n\tint\t\tmodels;\n\tchar\tvalue[10];\n\n\tmodels = 1;\n\tfor ( i=1 ; i<num_entities ; i++ ) {\n\t\tif ( entities[i].brushes || entities[i].patches ) {\n\t\t\tsprintf ( value, \"*%i\", models );\n\t\t\tmodels++;\n\t\t\tSetKeyValue (&entities[i], \"model\", value);\n\t\t}\n\t}\n\n}\n\n/*\n============\nSetLightStyles\n============\n*/\n#define\tMAX_SWITCHED_LIGHTS\t32\nvoid SetLightStyles (void)\n{\n\tint\t\tstylenum;\n\tconst char\t*t;\n\tentity_t\t*e;\n\tint\t\ti, j;\n\tchar\tvalue[10];\n\tchar\tlighttargets[MAX_SWITCHED_LIGHTS][64];\n\n\n\t// any light that is controlled (has a targetname)\n\t// must have a unique style number generated for it\n\n\tstylenum = 0;\n\tfor (i=1 ; i<num_entities ; i++)\n\t{\n\t\te = &entities[i];\n\n\t\tt = ValueForKey (e, \"classname\");\n\t\tif (Q_strncasecmp (t, \"light\", 5))\n\t\t\tcontinue;\n\t\tt = ValueForKey (e, \"targetname\");\n\t\tif (!t[0])\n\t\t\tcontinue;\n\t\t\n\t\t// find this targetname\n\t\tfor (j=0 ; j<stylenum ; j++)\n\t\t\tif (!strcmp (lighttargets[j], t))\n\t\t\t\tbreak;\n\t\tif (j == stylenum)\n\t\t{\n\t\t\tif (stylenum == MAX_SWITCHED_LIGHTS)\n\t\t\t\tError (\"stylenum == MAX_SWITCHED_LIGHTS\");\n\t\t\tstrcpy (lighttargets[j], t);\n\t\t\tstylenum++;\n\t\t}\n\t\tsprintf (value, \"%i\", 32 + j);\n\t\tSetKeyValue (e, \"style\", value);\n\t}\n\n}\n\n//===========================================================\n\n/*\n==================\nBeginBSPFile\n==================\n*/\nvoid BeginBSPFile( void ) {\n\t// these values may actually be initialized\n\t// if the file existed when loaded, so clear them explicitly\n\tnummodels = 0;\n\tnumnodes = 0;\n\tnumbrushsides = 0;\n\tnumleafsurfaces = 0;\n\tnumleafbrushes = 0;\n\n\t// leave leaf 0 as an error, because leafs are referenced as\n\t// negative number nodes\n\tnumleafs = 1;\n}\n\n\n/*\n============\nEndBSPFile\n============\n*/\nvoid EndBSPFile( void ) {\n\tchar\tpath[1024];\n\n\tEmitPlanes ();\n\tUnparseEntities ();\n\n\t// write the map\n\tsprintf (path, \"%s.bsp\", source);\n\t_printf (\"Writing %s\\n\", path);\n\tWriteBSPFile (path);\n}\n\n\n//===========================================================\n\n/*\n============\nEmitBrushes\n============\n*/\nvoid EmitBrushes ( bspbrush_t *brushes ) {\n\tint\t\t\t\tj;\n\tdbrush_t\t\t*db;\n\tbspbrush_t\t\t*b;\n\tdbrushside_t\t*cp;\n\n\tfor ( b = brushes ; b ; b = b->next ) {\n\t\tif ( numbrushes == MAX_MAP_BRUSHES ) {\n\t\t\tError( \"MAX_MAP_BRUSHES\" );\n\t\t}\n\t\tb->outputNumber = numbrushes;\n\t\tdb = &dbrushes[numbrushes];\n\t\tnumbrushes++;\n\n\t\tdb->shaderNum = EmitShader( b->contentShader->shader );\n\t\tdb->firstSide = numbrushsides;\n\n\t\t// don't emit any generated backSide sides\n\t\tdb->numSides = 0;\n\t\tfor ( j=0 ; j<b->numsides ; j++ ) {\n\t\t\tif ( b->sides[j].backSide ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( numbrushsides == MAX_MAP_BRUSHSIDES ) {\n\t\t\t\tError( \"MAX_MAP_BRUSHSIDES \");\n\t\t\t}\n\t\t\tcp = &dbrushsides[numbrushsides];\n\t\t\tdb->numSides++;\n\t\t\tnumbrushsides++;\n\t\t\tcp->planeNum = b->sides[j].planenum;\n\t\t\tcp->shaderNum = EmitShader( b->sides[j].shaderInfo->shader );\n\t\t}\n\t}\n\n}\n\n\n/*\n==================\nBeginModel\n==================\n*/\nvoid BeginModel( void ) {\n\tdmodel_t\t*mod;\n\tbspbrush_t\t*b;\n\tentity_t\t*e;\n\tvec3_t\t\tmins, maxs;\n\tparseMesh_t\t*p;\n\tint\t\t\ti;\n\n\tif ( nummodels == MAX_MAP_MODELS ) {\n\t\tError( \"MAX_MAP_MODELS\" );\n\t}\n\tmod = &dmodels[nummodels];\n\n\t//\n\t// bound the brushes\n\t//\n\te = &entities[entity_num];\n\n\tClearBounds (mins, maxs);\n\tfor ( b = e->brushes ; b ; b = b->next ) {\n\t\tif ( !b->numsides ) {\n\t\t\tcontinue;\t// not a real brush (origin brush, etc)\n\t\t}\n\t\tAddPointToBounds (b->mins, mins, maxs);\n\t\tAddPointToBounds (b->maxs, mins, maxs);\n\t}\n\n\tfor ( p = e->patches ; p ; p = p->next ) {\n\t\tfor ( i = 0 ; i < p->mesh.width * p->mesh.height ; i++ ) {\n\t\t\tAddPointToBounds( p->mesh.verts[i].xyz, mins, maxs );\n\t\t}\n\t}\n\n\tVectorCopy (mins, mod->mins);\n\tVectorCopy (maxs, mod->maxs);\n\n\tmod->firstSurface = numDrawSurfaces;\n\tmod->firstBrush = numbrushes;\n\n\tEmitBrushes( e->brushes );\n}\n\n\n\n\n/*\n==================\nEndModel\n==================\n*/\nvoid EndModel( node_t *headnode ) {\n\tdmodel_t\t*mod;\n\n\tqprintf (\"--- EndModel ---\\n\");\n\n\tmod = &dmodels[nummodels];\n\tEmitDrawNode_r (headnode);\n\tmod->numSurfaces = numDrawSurfaces - mod->firstSurface;\n\tmod->numBrushes = numbrushes - mod->firstBrush;\n\n\tnummodels++;\n}\n\n"
  },
  {
    "path": "q3radiant/BMP.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef _BMP_H\n#define _BMP_H\n\n#define xBI_NONE  0\n#define xBI_RGB   0\n#define xBI_RLE4  2\n#define xBI_RLE8  1\n\n#define BMP_SIGNATURE_WORD  0x4d42\n\n#pragma pack(1)\n\n\n\ntypedef struct {\n    unsigned short    bfType;       // signature - 'BM'\n    unsigned long     bfSize;       // file size in bytes\n    unsigned short    bfReserved1;  // 0\n    unsigned short    bfReserved2;  // 0\n    unsigned long     bfOffBits;    // offset to bitmap\n} bmphd_t;\n\n\n\ntypedef struct {\n    unsigned long     biSize;       // size of this struct\n    long              biWidth;      // bmap width in pixels\n    long              biHeight;     // bmap height in pixels\n    unsigned short    biPlanes;     // num planes - always 1\n    unsigned short    biBitCount;   // bits perpixel\n    unsigned long     biCompression; // compression flag\n    unsigned long     biSizeImage;   // image size in bytes\n    long              biXPelsPerMeter; // horz resolution\n    long              biYPelsPerMeter; // vert resolution\n    unsigned long     biClrUsed;       // 0 -> color table size\n    unsigned long     biClrImportant;  // important color count\n} binfo_t;\n\n\ntypedef struct {\n    unsigned char blue;\n    unsigned char green;\n    unsigned char red;\n    unsigned char reserved;\n} drgb_t;\n\n\n// quake expects its palette to be bgr\n// this is totally backwards but what can you do\ntypedef struct {\n    unsigned char r;\n    unsigned char g;\n    unsigned char b;\n} rgb_t;\n\n\ntypedef struct {\n    unsigned char b;\n    unsigned char g;\n    unsigned char r;\n} bgr_t;\n\n\ntypedef struct {\n\tint            bpp;        // bits per pixel\n    int            width;\n    int            height;\n    unsigned char *data;\n    rgb_t         *palette;\n} bitmap_t;\n\n\nvoid  LoadBMP(char *filename, bitmap_t *bit);\nvoid FreeBMP(bitmap_t *bitmap);\nvoid WriteBMP(char *filename, bitmap_t *bit);\nvoid NewBMP(int width, int height, int bpp, bitmap_t *bit);\n\n\n\n#endif\n"
  },
  {
    "path": "q3radiant/BRUSH.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n// brush.h\n\n// all types moved to qertypes.h\n//--typedef struct\n//--{\n//--\tint\t\tnumpoints;\n//--\tint\t\tmaxpoints;\n//--\tfloat \tpoints[8][5];\t\t\t// variable sized\n//--} winding_t;\n\n\n// the normals on planes point OUT of the brush\n//--#define\tMAXPOINTS\t16\n//--typedef struct face_s\n//--{\n//--\tstruct face_s\t*next;\n//--\tvec3_t\t\tplanepts[3];\n//--  texdef_t\ttexdef;\n//--  plane_t\t\tplane;\n//--\n//--\twinding_t  *face_winding;\n//--\n//--\tvec3_t\t\td_color;\n//--\tqtexture_t *d_texture;\n//--\n//--} face_t;\n//--\n//--typedef struct {\n//--\tvec3_t\txyz;\n//--\tfloat\tsideST[2];\n//--\tfloat\tcapST[2];\n//--} curveVertex_t;\n//--\n//--typedef struct {\n//--\tcurveVertex_t\tv[2];\n//--} sideVertex_t;\n//--\n//--typedef struct brush_s\n//--{\n//--\tstruct brush_s\t*prev, *next;\t// links in active/selected\n//--\tstruct brush_s\t*oprev, *onext;\t// links in entity\n//--\tstruct entity_s\t*owner;\n//--\tvec3_t\tmins, maxs;\n//--\tface_t     *brush_faces;\n//--\n//--\tqboolean bModelFailed;\n//--\t//\n//--\t// curve brush extensions\n//--\t// all are derived from brush_faces\n//--\tqboolean\tcurveBrush;\n//--\tqboolean\tpatchBrush;\n//--    int nPatchID;\n//--} brush_t;\n\nvoid\t\tBrush_AddToList (brush_t *b, brush_t *list);\nvoid\t\tBrush_Build(brush_t *b, bool bSnap = true, bool bMarkMap = true, bool bConvert = false);\nvoid\t\tBrush_BuildWindings( brush_t *b, bool bSnap = true );\nbrush_t*\tBrush_Clone (brush_t *b);\nbrush_t*\tBrush_FullClone(brush_t *b);\nbrush_t*\tBrush_Create (vec3_t mins, vec3_t maxs, texdef_t *texdef);\nvoid\t\tBrush_Draw( brush_t *b );\nvoid\t\tBrush_DrawXY(brush_t *b, int nViewType);\n// set bRemoveNode to false to avoid trying to delete the item in group view tree control\nvoid\t\tBrush_Free (brush_t *b, bool bRemoveNode = true);\nint\t\t\tBrush_MemorySize(brush_t *b);\nvoid\t\tBrush_MakeSided (int sides);\nvoid\t\tBrush_MakeSidedCone (int sides);\nvoid\t\tBrush_Move (brush_t *b, const vec3_t move, bool bSnap = true);\nint\t\t\tBrush_MoveVertex(brush_t *b, vec3_t vertex, vec3_t delta, vec3_t end, bool bSnap = true);\nvoid\t\tBrush_ResetFaceOriginals(brush_t *b);\nbrush_t*\tBrush_Parse (void);\nface_t*\t\tBrush_Ray (vec3_t origin, vec3_t dir, brush_t *b, float *dist);\nvoid\t\tBrush_RemoveFromList (brush_t *b);\nvoid\t\tBrush_SplitBrushByFace (brush_t *in, face_t *f, brush_t **front, brush_t **back);\nvoid\t\tBrush_SelectFaceForDragging (brush_t *b, face_t *f, qboolean shear);\nvoid\t\tBrush_SetTexture (brush_t *b, texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale = false, IPluginTexdef* pPlugTexdef=NULL );\nvoid\t\tBrush_SideSelect (brush_t *b, vec3_t origin, vec3_t dir, qboolean shear);\nvoid\t\tBrush_SnapToGrid(brush_t *pb);\nvoid\t\tBrush_Rotate(brush_t *b, vec3_t vAngle, vec3_t vOrigin, bool bBuild = true);\nvoid\t\tBrush_MakeSidedSphere(int sides);\nvoid\t\tBrush_Write (brush_t *b, FILE *f);\nvoid\t\tBrush_Write (brush_t *b, CMemFile* pMemFile);\nvoid\t\tBrush_RemoveEmptyFaces ( brush_t *b );\nwinding_t*\tBrush_MakeFaceWinding (brush_t *b, face_t *face);\n\nint\t\t\tAddPlanept (float *f);\nfloat\t\tSetShadeForPlane (plane_t *p);\n\nface_t*\t\tFace_Alloc( void );\nvoid\t\tFace_Free( face_t *f );\nface_t*\t\tFace_Clone (face_t *f);\nvoid\t\tFace_MakePlane (face_t *f);\nvoid\t\tFace_Draw( face_t *face );\nvoid\t\tFace_TextureVectors (face_t *f, float STfromXYZ[2][4]);\nvoid\t\tSetFaceTexdef (brush_t *b, face_t *f, texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale = false, IPluginTexdef* pPlugTexdef = NULL );\n\nvoid Face_FitTexture( face_t * face, int nHeight, int nWidth );\nvoid Brush_FitTexture( brush_t *b, int nHeight, int nWidth );\nvoid Brush_SetEpair(brush_t *b, const char *pKey, const char *pValue);\nconst char* Brush_GetKeyValue(brush_t *b, const char *pKey);\nbrush_t *Brush_Alloc();\nconst char* Brush_Name(brush_t *b);\n"
  },
  {
    "path": "q3radiant/BSInput.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// BSInput.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"BSInput.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CBSInput dialog\n\n\nCBSInput::CBSInput(CWnd* pParent /*=NULL*/)\n\t: CDialog(CBSInput::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CBSInput)\n\tm_fField1 = 0.0f;\n\tm_fField2 = 0.0f;\n\tm_fField3 = 0.0f;\n\tm_fField4 = 0.0f;\n\tm_fField5 = 0.0f;\n\tm_strField1 = _T(\"\");\n\tm_strField2 = _T(\"\");\n\tm_strField3 = _T(\"\");\n\tm_strField4 = _T(\"\");\n\tm_strField5 = _T(\"\");\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CBSInput::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CBSInput)\n\tDDX_Text(pDX, IDC_EDIT_FIELD1, m_fField1);\n\tDDX_Text(pDX, IDC_EDIT_FIELD2, m_fField2);\n\tDDX_Text(pDX, IDC_EDIT_FIELD3, m_fField3);\n\tDDX_Text(pDX, IDC_EDIT_FIELD4, m_fField4);\n\tDDX_Text(pDX, IDC_EDIT_FIELD5, m_fField5);\n\tDDX_Text(pDX, IDC_STATIC_FIELD1, m_strField1);\n\tDDX_Text(pDX, IDC_STATIC_FIELD2, m_strField2);\n\tDDX_Text(pDX, IDC_STATIC_FIELD3, m_strField3);\n\tDDX_Text(pDX, IDC_STATIC_FIELD4, m_strField4);\n\tDDX_Text(pDX, IDC_STATIC_FIELD5, m_strField5);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CBSInput, CDialog)\n\t//{{AFX_MSG_MAP(CBSInput)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CBSInput message handlers\n\nBOOL CBSInput::OnInitDialog() \n{\n\tCDialog::OnInitDialog();\n\n  if (m_strField1.GetLength() == 0)\n  {\n    GetDlgItem(IDC_EDIT_FIELD1)->ShowWindow(SW_HIDE);\n    GetDlgItem(IDC_STATIC_FIELD1)->ShowWindow(SW_HIDE);\n  }\n  if (m_strField2.GetLength() == 0)\n  {\n    GetDlgItem(IDC_EDIT_FIELD2)->ShowWindow(SW_HIDE);\n    GetDlgItem(IDC_STATIC_FIELD2)->ShowWindow(SW_HIDE);\n  }\n  if (m_strField3.GetLength() == 0)\n  {\n    GetDlgItem(IDC_EDIT_FIELD3)->ShowWindow(SW_HIDE);\n    GetDlgItem(IDC_STATIC_FIELD3)->ShowWindow(SW_HIDE);\n  }\n  if (m_strField4.GetLength() == 0)\n  {\n    GetDlgItem(IDC_EDIT_FIELD4)->ShowWindow(SW_HIDE);\n    GetDlgItem(IDC_STATIC_FIELD4)->ShowWindow(SW_HIDE);\n  }\n  if (m_strField5.GetLength() == 0)\n  {\n    GetDlgItem(IDC_EDIT_FIELD5)->ShowWindow(SW_HIDE);\n    GetDlgItem(IDC_STATIC_FIELD5)->ShowWindow(SW_HIDE);\n  }\n\t\n\treturn TRUE;  // return TRUE unless you set the focus to a control\n\t              // EXCEPTION: OCX Property Pages should return FALSE\n}\n"
  },
  {
    "path": "q3radiant/BSInput.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_BSINPUT_H__81DF2A32_A552_11D1_B58E_00AA00A410FC__INCLUDED_)\n#define AFX_BSINPUT_H__81DF2A32_A552_11D1_B58E_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// BSInput.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CBSInput dialog\n\nclass CBSInput : public CDialog\n{\n// Construction\npublic:\n\tCBSInput(CWnd* pParent = NULL);   // standard constructor\n\n// Dialog Data\n\t//{{AFX_DATA(CBSInput)\n\tenum { IDD = IDD_DIALOG_INPUT };\n\tfloat\tm_fField1;\n\tfloat\tm_fField2;\n\tfloat\tm_fField3;\n\tfloat\tm_fField4;\n\tfloat\tm_fField5;\n\tCString\tm_strField1;\n\tCString\tm_strField2;\n\tCString\tm_strField3;\n\tCString\tm_strField4;\n\tCString\tm_strField5;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CBSInput)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CBSInput)\n\tvirtual BOOL OnInitDialog();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_BSINPUT_H__81DF2A32_A552_11D1_B58E_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/BSPFILE.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n\n// upper design bounds\n// leaffaces, leafbrushes, planes, and verts are still bounded by\n// 16 bit short limits\n#define\tMAX_MAP_MODELS\t\t1024\n#define\tMAX_MAP_BRUSHES\t\t8192\n#define\tMAX_MAP_ENTITIES\t2048\n#define\tMAX_MAP_PATHS\t\t2048\n#define\tMAX_MAP_ENTSTRING\t0x20000\n#define\tMAX_MAP_TEXTURES\t1024\n#define\tMAX_MAP_TEXINFO\t\t8192\n\n#define\tMAX_MAP_PLANES\t\t65536\n#define\tMAX_MAP_NODES\t\t65536\n#define\tMAX_MAP_BRUSHSIDES\t65536\n#define\tMAX_MAP_LEAFS\t\t65536\n#define\tMAX_MAP_VERTS\t\t65536\n#define\tMAX_MAP_FACES\t\t65536\n#define\tMAX_MAP_LEAFFACES\t65536\n#define\tMAX_MAP_LEAFBRUSHES 65536\n#define\tMAX_MAP_PORTALS\t\t65536\n#define\tMAX_MAP_EDGES\t\t128000\n#define\tMAX_MAP_SURFEDGES\t256000\n#define\tMAX_MAP_MIPTEX\t\t0x200000\n#define\tMAX_MAP_LIGHTING\t0x200000\n#define\tMAX_MAP_VISIBILITY\t0x100000\n\n// key / value pair sizes\n\n#define\tMAX_KEY\t\t32\n#define\tMAX_VALUE\t1024\n\n//=============================================================================\n\n#define BSPVERSION\t34\n\ntypedef struct\n{\n\tint\t\tfileofs, filelen;\n} lump_t;\n\n#define\tLUMP_ENTITIES\t\t0\n#define\tLUMP_PLANES\t\t\t1\n#define\tLUMP_TEXTURES\t\t2\n#define\tLUMP_VERTEXES\t\t3\n#define\tLUMP_VISIBILITY\t\t4\n#define\tLUMP_NODES\t\t\t5\n#define\tLUMP_TEXINFO\t\t6\n#define\tLUMP_FACES\t\t\t7\n#define\tLUMP_LIGHTING\t\t8\n#define\tLUMP_LEAFS\t\t\t9\n#define\tLUMP_LEAFFACES\t\t10\n#define\tLUMP_LEAFBRUSHES\t11\n#define\tLUMP_EDGES\t\t\t12\n#define\tLUMP_SURFEDGES\t\t13\n#define\tLUMP_MODELS\t\t\t14\n#define\tLUMP_PATHS\t\t\t15\n#define\tLUMP_BRUSHES\t\t16\n#define\tLUMP_BRUSHSIDES\t\t17\n#define\tLUMP_POP\t\t\t18\n\n#define\tHEADER_LUMPS\t18\n\ntypedef struct\n{\n\tint\t\t\tversion;\t\n\tlump_t\t\tlumps[HEADER_LUMPS];\n} dheader_t;\n\ntypedef struct\n{\n\tfloat\t\tmins[3], maxs[3];\n\tfloat\t\torigin[3];\t\t// for sounds or lights\n\tint\t\t\theadnode;\n\tint\t\t\tvisleafs;\t\t// not including the solid leaf 0\n\tint\t\t\tfirstface, numfaces;\n} dmodel_t;\n\ntypedef struct\n{\n\tint\t\t\tnummiptex;\n\tint\t\t\tdataofs[4];\t\t// [nummiptex]\n} dmiptexlump_t;\n\n#define\tMIPLEVELS\t4\ntypedef struct miptex_s\n{\n\tchar\t\tname[16];\n\tunsigned\twidth, height;\n\tunsigned\toffsets[MIPLEVELS];\t\t// four mip maps stored\n\tint\t\t\tflags;\n\tint\t\t\tvalue;\n} miptex_t;\n\n\ntypedef struct\n{\n\tfloat\tpoint[3];\n} dvertex_t;\n\n\n// 0-2 are axial planes\n#define\tPLANE_X\t\t\t0\n#define\tPLANE_Y\t\t\t1\n#define\tPLANE_Z\t\t\t2\n\n// 3-5 are non-axial planes snapped to the nearest\n#define\tPLANE_ANYX\t\t3\n#define\tPLANE_ANYY\t\t4\n#define\tPLANE_ANYZ\t\t5\n\n// planes (x&~1) and (x&~1)+1 are allways opposites\n\ntypedef struct\n{\n\tfloat\tnormal[3];\n\tfloat\tdist;\n\tint\t\ttype;\t\t// PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate\n} dplane_t;\n\n\n// contents flags are seperate bits\n// a given brush can contribute multiple content bits\n// multiple brushes can be in a single leaf\n\n// lower bits are stronger, and will eat weaker brushes completely\n#define\tCONTENTS_SOLID\t\t\t1\t\t// an eye is never valid in a solid\n#define\tCONTENTS_WINDOW\t\t\t2\t\t// translucent, but not watery\n#define\tCONTENTS_LAVA\t\t\t8\n#define\tCONTENTS_SLIME\t\t\t16\n#define\tCONTENTS_WATER\t\t\t32\n#define\tCONTENTS_THINWATER\t\t64\t\t// translucent faces\n\n#define\tLAST_VISIBLE_CONTENTS\t64\n\n// remaining contents are non-visible, and don't eat brushes\n#define\tCONTENTS_MONSTER\t\t128\n#define\tCONTENTS_PLAYERCLIP\t\t256\n#define\tCONTENTS_MONSTERCLIP\t512\n\n\n// currents can be added to any other contents, and may be mixed\n#define\tCONTENTS_CURRENT_0\t\t1024\n#define\tCONTENTS_CURRENT_90\t\t2048\n#define\tCONTENTS_CURRENT_180\t4096\n#define\tCONTENTS_CURRENT_270\t8192\n#define\tCONTENTS_CURRENT_UP\t\t16384\n#define\tCONTENTS_CURRENT_DOWN\t32768\n\n#define\tCONTENTS_ORIGIN\t\t\t65536\t\t// removed before processing\n\n\n\n// !!! if this is changed, it must be changed in asm_i386.h too !!!\ntypedef struct\n{\n\tint\t\t\tplanenum;\n\tint\t\t\tchildren[2];\t// negative numbers are -(leafs+1), not nodes\n\tshort\t\tmins[3];\t\t// for frustom culling\n\tshort\t\tmaxs[3];\n\tunsigned short\tfirstface;\n\tunsigned short\tnumfaces;\t// counting both sides\n} dnode_t;\n\ntypedef struct texinfo_s\n{\n\tfloat\t\tvecs[2][4];\t\t// [s/t][xyz offset]\n\tint\t\t\tmiptex;\n\tint\t\t\tflags;\t\t\t// miptex flags + overrides\n\tint\t\t\tvalue;\t\t\t// light emition, etc\n} texinfo_t;\n\n#define\tTEX_SPECIAL\t\t1\t\t// sky or slime, no lightmap or 256 subdivision\n#define\tSURF_LIGHT\t\t2\n\n#define\tSURF_WATER\t\t4\n#define\tSURF_SLIME\t\t8\n#define\tSURF_LAVA\t\t16\n#define\tSURF_WINDOW\t\t32\n\n#define\tSURF_SKY\t\t64\n#define\tSURF_MIRROR\t\t128\n\n#define\tSURF_SLIPPERY\t256\n\n// note that edge 0 is never used, because negative edge nums are used for\n// counterclockwise use of the edge in a face\ntypedef struct\n{\n\tunsigned short\tv[2];\t\t// vertex numbers\n} dedge_t;\n\n#define\tMAXLIGHTMAPS\t4\ntypedef struct\n{\n\tunsigned short\tplanenum;\n\tshort\t\tside;\n\n\tint\t\t\tfirstedge;\t\t// we must support > 64k edges\n\tshort\t\tnumedges;\t\n\tshort\t\ttexinfo;\n\n// lighting info\n\tbyte\t\tstyles[MAXLIGHTMAPS];\n\tint\t\t\tlightofs;\t\t// start of [numstyles*surfsize] samples\n} dface_t;\n\ntypedef struct\n{\n\tint\t\t\tcontents;\t\t\t// OR of all brushes\n\tint\t\t\tvisofs;\t\t\t\t// -1 = no visibility info\n\n\tshort\t\tmins[3];\t\t\t// for frustum culling\n\tshort\t\tmaxs[3];\n\n\tunsigned short\t\tfirstleafface;\n\tunsigned short\t\tnumleaffaces;\n\n\tunsigned short\t\tfirstleafbrush;\n\tunsigned short\t\tnumleafbrushes;\n} dleaf_t;\n\n\ntypedef struct\n{\n\tunsigned short\tplanenum;\t\t// facing out of the leaf\n\tshort\ttexinfo;\n} dbrushside_t;\n\ntypedef struct\n{\n\tint\t\t\tfirstside;\n\tint\t\t\tnumsides;\n\tint\t\t\tcontents;\n} dbrush_t;\n\ntypedef struct\n{\n\tfloat\t\torigin[3];\n\tfloat\t\tangles[3];\n\tint\t\t\tnext, prev;\n\tint\t\t\tflags;\n\tfloat\t\tspeed;\n} dpath_t;\n\n//============================================================================\n\n#ifndef QUAKE_GAME\n\n#define\tANGLE_UP\t-1\n#define\tANGLE_DOWN\t-2\n\n\n// the utilities get to be lazy and just use large static arrays\n\nextern\tint\t\t\tnummodels;\nextern\tdmodel_t\tdmodels[MAX_MAP_MODELS];\n\nextern\tint\t\t\tvisdatasize;\nextern\tbyte\t\tdvisdata[MAX_MAP_VISIBILITY];\n\nextern\tint\t\t\tlightdatasize;\nextern\tbyte\t\tdlightdata[MAX_MAP_LIGHTING];\n\nextern\tint\t\t\ttexdatasize;\nextern\tbyte\t\tdtexdata[MAX_MAP_MIPTEX]; // (dmiptexlump_t)\n\nextern\tint\t\t\tentdatasize;\nextern\tchar\t\tdentdata[MAX_MAP_ENTSTRING];\n\nextern\tint\t\t\tnumleafs;\nextern\tdleaf_t\t\tdleafs[MAX_MAP_LEAFS];\n\nextern\tint\t\t\tnumplanes;\nextern\tdplane_t\tdplanes[MAX_MAP_PLANES];\n\nextern\tint\t\t\tnumvertexes;\nextern\tdvertex_t\tdvertexes[MAX_MAP_VERTS];\n\nextern\tint\t\t\tnumnodes;\nextern\tdnode_t\t\tdnodes[MAX_MAP_NODES];\n\nextern\tint\t\t\tnumtexinfo;\nextern\ttexinfo_t\ttexinfo[MAX_MAP_TEXINFO];\n\nextern\tint\t\t\tnumfaces;\nextern\tdface_t\t\tdfaces[MAX_MAP_FACES];\n\nextern\tint\t\t\tnumedges;\nextern\tdedge_t\t\tdedges[MAX_MAP_EDGES];\n\nextern\tint\t\t\tnumleaffaces;\nextern\tunsigned short\tdleaffaces[MAX_MAP_LEAFFACES];\n\nextern\tint\t\t\tnumleafbrushes;\nextern\tunsigned short\tdleafbrushes[MAX_MAP_LEAFBRUSHES];\n\nextern\tint\t\t\tnumsurfedges;\nextern\tint\t\t\tdsurfedges[MAX_MAP_SURFEDGES];\n\nextern\tint\t\t\tnumpaths;\nextern\tdpath_t\t\tdpaths[MAX_MAP_PATHS];\n\nextern\tint\t\t\tnumbrushes;\nextern\tdbrush_t\tdbrushes[MAX_MAP_BRUSHES];\n\nextern\tint\t\t\tnumbrushsides;\nextern\tdbrushside_t\tdbrushsides[MAX_MAP_BRUSHSIDES];\n\n\nvoid DecompressVis (byte *in, byte *decompressed);\nint CompressVis (byte *vis, byte *dest);\n\nvoid\tLoadBSPFile (char *filename);\nvoid\tWriteBSPFile (char *filename);\nvoid\tPrintBSPFileSizes (void);\n\n//===============\n\n\ntypedef struct epair_s\n{\n\tstruct epair_s\t*next;\n\tchar\t*key;\n\tchar\t*value;\n} epair_t;\n\ntypedef struct\n{\n\tvec3_t\t\torigin;\n\tint\t\t\tfirstbrush;\n\tint\t\t\tnumbrushes;\n\tepair_t\t\t*epairs;\n} entity_t;\n\nextern\tint\t\t\tnum_entities;\nextern\tentity_t\tentities[MAX_MAP_ENTITIES];\n\nvoid\tParseEntities (void);\nvoid\tUnparseEntities (void);\n\nvoid \tSetKeyValue (entity_t *ent, char *key, char *value);\nchar \t*ValueForKey (entity_t *ent, char *key);\n// will return \"\" if not present\n\nvec_t\tFloatForKey (entity_t *ent, char *key);\nvoid \tGetVectorForKey (entity_t *ent, char *key, vec3_t vec);\n\nepair_t *ParseEpair (void);\n\nvoid PrintEntity (entity_t *ent);\n\nextern\tint\t\tr_leaftovis[MAX_MAP_LEAFS];\nextern\tint\t\tr_vistoleaf[MAX_MAP_LEAFS];\nextern\tint\t\tr_numvisleafs;\n\n#endif\n"
  },
  {
    "path": "q3radiant/Bmp.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"stdafx.h\"\n#include <stdio.h>\n#include <malloc.h>\n#include <string.h>\n\n#include \"bmp.h\"\n\n\nvoid Error(char *fmt, ...);\n\n\nstatic int GetColorCount(int nbits)\n{\n    int ncolors = 0;\n\n    if (nbits < 24)\n    {\n \t    ncolors = 1 << nbits;\n    }\n\n    return(ncolors);\n}\n\n\nstatic void BMPLineNone(FILE *f, char *sline, int pixbytes, int width)\n{\n    int nbytes, i, k, j;\n\n\tswitch (pixbytes)\n\t{\n\t    case 1 :\n            nbytes = (width + 3) / 4;\n            nbytes *= 4;\n\n            fread(sline, width, 1, f);\n            nbytes -= width;\n\n            while (nbytes-- > 0) fgetc(f);\n\t\t\treturn;\n\n\t\tcase 3 :\n\t\t\tnbytes = ((width * 3) + 3) / 4;\n\t\t\tnbytes *= 4;\n\n\t\t\tfread(sline, width, 3, f);\n\t\t\tnbytes -= width * 3;\n\n\t\t\twhile (nbytes-- > 0) fgetc(f);\n\n\t\t\t// reorder bgr to rgb\n\t\t\tfor (i = 0, j = 0; i < width; i++, j += 3)\n\t\t\t{\n\t\t\t\tk = sline[j];\n\t\t\t\tsline[j] = sline[j+2];\n\t\t\t\tsline[j+2] = k;\n\t\t\t}\n\n\t\t\treturn;\n\t}\n\n\tError(\"BMPLineNone failed.\");\n}\n\n\nstatic void BMPLineRLE8(FILE *f, char *sline, int pixbytes, int width)\n{\n    Error(\"RLE8 not yet supported.\");\n}\n\n\nstatic void BMPLineRLE4(FILE *f, char *sline, int pixbytes, int width)\n{\n    Error(\"RLE4 not yet supported.\");\n}\n\n\nstatic void BMPLine(FILE *f, char *scanline, int pixbytes, int width, int rle)\n{\n    switch (rle)\n    {\n\t    case xBI_NONE : BMPLineNone(f, scanline, pixbytes, width); return;\n\t    case xBI_RLE8 : BMPLineRLE8(f, scanline, pixbytes, width); return;\n\t    case xBI_RLE4 : BMPLineRLE4(f, scanline, pixbytes, width); return;\n    }\n\n    Error(\"Unknown compression type.\");\n}\n\n\n\nstatic void PrintHeader(binfo_t *b)\n{\n    printf(\"biSize         : %ld\\n\", b->biSize);\n    printf(\"biWidth        : %ld\\n\", b->biWidth);\n    printf(\"biHeight       : %ld\\n\", b->biHeight);\n    printf(\"biPlanes       : %d\\n\", b->biPlanes);\n    printf(\"biBitCount     : %d\\n\", b->biBitCount);\n    printf(\"biCompression  : %ld\\n\", b->biCompression);\n    printf(\"biSizeImage    : %ld\\n\", b->biSizeImage);\n    printf(\"biXPelsPerMeter: %ld\\n\", b->biXPelsPerMeter);\n    printf(\"biYPelsPerMeter: %ld\\n\", b->biYPelsPerMeter);\n    printf(\"biClrUsed      : %ld\\n\", b->biClrUsed);\n    printf(\"biClrImportant : %ld\\n\", b->biClrImportant);\n}\n\n\nvoid LoadBMP(char *filename, bitmap_t *bit)\n{\n    FILE    *f;\n    bmphd_t  bhd;\n    binfo_t  info;\n    int      pxlsize = 1;\n    int      rowbytes, i, pixbytes;\n    char    *scanline;\n\n    // open file\n    if ((f = fopen(filename, \"rb\")) == NULL)\n    {\n\t    Error(\"Unable to open %s.\", filename);\n    }\n\n    // read in bitmap header\n    if (fread(&bhd, sizeof(bhd), 1, f) != 1)\n    {\n\t\tfclose(f);\n\t    Error(\"Unable to read in bitmap header.\");\n    }\n\n    // make sure we have a valid bitmap file\n    if (bhd.bfType != BMP_SIGNATURE_WORD)\n    {\n\t\tfclose(f);\n\t    Error(\"Invalid BMP file: %s\", filename);\n    }\n\n    // load in info header\n    if (fread(&info, sizeof(info), 1, f) != 1)\n    {\n\t\tfclose(f);\n\t    Error(\"Unable to read bitmap info header.\");\n    }\n\n    // make sure this is an info type of bitmap\n    if (info.biSize != sizeof(binfo_t))\n    {\n\t\tfclose(f);\n\t    Error(\"We only support the info bitmap type.\");\n    }\n\n    // PrintHeader(&info);\n\n\tbit->bpp      = info.biBitCount;\n\tbit->width    = info.biWidth;\n    bit->height   = info.biHeight;\n    bit->data     = NULL;\n    bit->palette  = NULL;\n\n    //currently we only read in 8 and 24 bit bmp files\n\tif      (info.biBitCount == 8)  pixbytes = 1;\n\telse if (info.biBitCount == 24) pixbytes = 3;\n\telse\n    {\n\t\tError(\"BPP %d not supported.\", info.biBitCount);\n    }\n\n    // if this is an eight bit image load palette\n\tif (pixbytes == 1)\n    {\n\t    drgb_t q;\n\n\t    bit->palette = reinterpret_cast<rgb_t*>(malloc(sizeof(rgb_t) * 256));\n\n\t    for (i = 0; i < 256; i++)\n\t    {\n\t        if (fread(&q, sizeof(drgb_t), 1, f) != 1)\n\t        {\n\t\t\t\tfclose(f); free(bit->palette);\n\t\t        Error(\"Unable to read palette.\");\n\t\t\t}\n\n\t        bit->palette[i].r   = q.red;\n\t        bit->palette[i].g   = q.green;\n\t        bit->palette[i].b   = q.blue;\n\t\t}\n    }\n\n    // position to start of bitmap\n    fseek(f, bhd.bfOffBits, SEEK_SET);\n\n    // create scanline to read data into\n    rowbytes = ((info.biWidth * pixbytes) + 3) / 4;\n    rowbytes *= 4;\n\n    scanline = reinterpret_cast<char*>(malloc(rowbytes));\n\n    // alloc space for new bitmap\n    bit->data = reinterpret_cast<unsigned char*>(malloc(info.biWidth * pixbytes * info.biHeight));\n\n    // read in image\n    for (i = 0; i < info.biHeight; i++)\n    {\n\t    BMPLine(f, scanline, pixbytes, info.biWidth, info.biCompression);\n\n\t    // store line\n\t    memcpy(&bit->data[info.biWidth * pixbytes * (info.biHeight - i - 1)], scanline, info.biWidth * pixbytes);\n    }\n\n    free(scanline);\n    fclose(f);\n}\n\n\n\nstatic void BMPEncodeLine(FILE *f, unsigned char *data, int npxls, int pixbytes)\n{\n    int nbytes, i, j, k;\n\n\tswitch (pixbytes)\n\t{\n\t    case 1 :\n            nbytes = (npxls + 3) / 4;\n            nbytes *= 4;\n\n            fwrite(data, npxls, 1, f);\n            nbytes -= npxls;\n\n            while (nbytes-- > 0) fputc(0, f);\n\t\t\treturn;\n\n        case 3 :\n\t\t\t// reorder rgb to bgr\n\t\t\tfor (i = 0, j = 0; i < npxls; i++, j+= 3)\n\t\t\t{\n\t\t\t\tk = data[j];\n\t\t\t\tdata[j] = data[j + 2];\n\t\t\t\tdata[j + 2] = k;\n\t\t\t}\n\n\t\t\tnbytes = ((npxls * 3) + 3) / 4;\n\t\t\tnbytes *= 4;\n\n\t\t\tfwrite(data, npxls, 3, f);\n\t\t\tnbytes -= npxls * 3;\n\n\t\t\twhile (nbytes-- > 0) fputc(0, f);\n\t\t\treturn;\n\t}\n\n\tError(\"BMPEncodeLine Failed.\");\n}\n\n\n\nvoid WriteBMP(char *filename, bitmap_t *bit)\n{\n    FILE    *f;\n    bmphd_t  header;\n    binfo_t  info;\n    drgb_t   q;        // palette that gets written\n    long     bmofs;\n    int      w, h, i;\n\tint      pixbytes;\n\n    if      (bit->bpp == 8)  pixbytes = 1;\n\telse if (bit->bpp == 24) pixbytes = 3;\n\n\telse\n    {\n\t\tError(\"BPP %d not supported.\", bit->bpp);\n    }\n\n\n    if ((f = fopen(filename, \"wb\")) == NULL)\n    {\n\t    Error(\"Unable to open %s.\", filename);\n    }\n\n    // write out an empty header as a place holder\n    if (fwrite(&header, sizeof(header), 1, f) != 1)\n    {\n\t    Error(\"Unable to fwrite.\");\n    }\n\n    // init and write info header\n    info.biSize          = sizeof(binfo_t);\n    info.biWidth         = bit->width;\n    info.biHeight        = bit->height;\n    info.biPlanes        = 1;\n    info.biBitCount      = bit->bpp;\n    info.biCompression   = xBI_NONE;\n    info.biSizeImage     = bit->width * bit->height;\n    info.biXPelsPerMeter = 0;\n    info.biYPelsPerMeter = 0;\n    info.biClrUsed       = 256;\n    info.biClrImportant  = 256;\n\n    if (fwrite(&info, sizeof(binfo_t), 1, f) != 1)\n    {\n\t    Error(\"fwrite failed.\");\n    }\n\n    // write out palette if we need to\n\tif (bit->bpp == 8)\n\t{\n        for (i = 0; i < 256; i++)\n        {\n\t        q.red   = bit->palette[i].r;\n\t        q.green = bit->palette[i].g;\n\t        q.blue  = bit->palette[i].b;\n\n\t        fwrite(&q, sizeof(q), 1, f);\n\t\t}\n    }\n\n    // save offset to start of bitmap\n    bmofs = ftell(f);\n\n    // output bitmap\n    w = bit->width;\n    h = bit->height;\n\n    for (i = h - 1; i >= 0; i--)\n    {\n\t    BMPEncodeLine(f, &bit->data[w * pixbytes * i], w, pixbytes);\n    }\n\n    // update and rewrite file header\n    header.bfType    = BMP_SIGNATURE_WORD;\n    header.bfSize    = ftell(f);\n    header.bfOffBits = bmofs;\n\n    fseek(f, 0L, SEEK_SET);\n    fwrite(&header, sizeof(header), 1, f);\n\n    fclose(f);\n}\n\n\nvoid NewBMP(int width, int height, int bpp, bitmap_t *bit)\n{\n\tint pixbytes;\n\n\tif      (bpp == 8)  pixbytes = 1;\n\telse if (bpp == 24) pixbytes = 3;\n\n\telse\n\t{\n\t\tError(\"NewBMP: 8 or 24 bit only.\");\n\t}\n\n\tbit->bpp    = bpp;\n\tbit->width  = width;\n\tbit->height = height;\n\n\tbit->data = reinterpret_cast<unsigned char*>(malloc(width * height * pixbytes));\n\n\tif (bit->data == NULL)\n\t{\n\t\tError(\"NewBMP: malloc failed.\");\n\t}\n\n\t// see if we need to create a palette\n\tif (pixbytes == 1)\n\t{\n\t\tbit->palette = (rgb_t *) malloc(768);\n\n\t\tif (bit->palette == NULL)\n\t\t{\n\t\t\tError(\"NewBMP: unable to malloc palette.\");\n\t\t}\n\t}\n\telse\n\t{\n\t\tbit->palette = NULL;\n\t}\n}\n\n\n\nvoid FreeBMP(bitmap_t *bitmap)\n{\n    if (bitmap->palette)\n    {\n\t    free(bitmap->palette);\n\t    bitmap->palette = NULL;\n    }\n\n    if (bitmap->data)\n    {\n\t    free(bitmap->data);\n\t    bitmap->data = NULL;\n    }\n}\n\n\n"
  },
  {
    "path": "q3radiant/Brush.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n\n#include \"stdafx.h\"\n#include <assert.h>\n#include \"qe3.h\"\n#include \"winding.h\"\n\n\n// globals\n\nint g_nBrushId = 0;\n\nconst char* Brush_Name(brush_t *b)\n{\n  static char cBuff[1024];\n\tb->numberId = g_nBrushId++;\n\tif (g_qeglobals.m_bBrushPrimitMode)\n  {\n    sprintf(cBuff, \"Brush %i\", b->numberId);\n    Brush_SetEpair(b, \"Name\", cBuff);\n  }\n  return cBuff;\n}\n\nbrush_t *Brush_Alloc()\n{\n  brush_t *b = (brush_t*)qmalloc(sizeof(brush_t));\n  return b;\n}\n\n\n\n\nvoid PrintWinding (winding_t *w)\n{\n\tint\t\ti;\n\t\n\tprintf (\"-------------\\n\");\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\tprintf (\"(%5.2f, %5.2f, %5.2f)\\n\", w->points[i][0]\n\t\t, w->points[i][1], w->points[i][2]);\n}\n\nvoid PrintPlane (plane_t *p)\n{\n  printf (\"(%5.2f, %5.2f, %5.2f) : %5.2f\\n\",  p->normal[0],  p->normal[1], \n  p->normal[2],  p->dist);\n}\n\nvoid PrintVector (vec3_t v)\n{\n  printf (\"(%5.2f, %5.2f, %5.2f)\\n\",  v[0],  v[1], v[2]);\n}\n\n\n/*\n=============================================================================\n\n\t\t\tTEXTURE COORDINATES\n\n=============================================================================\n*/\n\n\n/*\n==================\ntextureAxisFromPlane\n==================\n*/\nvec3_t\tbaseaxis[18] =\n{\n{0,0,1}, {1,0,0}, {0,-1,0},\t\t\t// floor\n{0,0,-1}, {1,0,0}, {0,-1,0},\t\t// ceiling\n{1,0,0}, {0,1,0}, {0,0,-1},\t\t\t// west wall\n{-1,0,0}, {0,1,0}, {0,0,-1},\t\t// east wall\n{0,1,0}, {1,0,0}, {0,0,-1},\t\t\t// south wall\n{0,-1,0}, {1,0,0}, {0,0,-1}\t\t\t// north wall\n};\n\nvoid TextureAxisFromPlane(plane_t *pln, vec3_t xv, vec3_t yv)\n{\n\tint\t\tbestaxis;\n\tfloat\tdot,best;\n\tint\t\ti;\n\t\n\tbest = 0;\n\tbestaxis = 0;\n\t\n\tfor (i=0 ; i<6 ; i++)\n\t{\n\t\tdot = DotProduct (pln->normal, baseaxis[i*3]);\n\t\tif (dot > best)\n\t\t{\n\t\t\tbest = dot;\n\t\t\tbestaxis = i;\n\t\t}\n\t}\n\t\n\tVectorCopy (baseaxis[bestaxis*3+1], xv);\n\tVectorCopy (baseaxis[bestaxis*3+2], yv);\n}\n\n\n\nfloat\tlightaxis[3] = {0.6, 0.8, 1.0};\n/*\n================\nSetShadeForPlane\n\nLight different planes differently to\nimprove recognition\n================\n*/\nfloat SetShadeForPlane (plane_t *p)\n{\n\tint\t\ti;\n\tfloat\tf;\n\n\t// axial plane\n\tfor (i=0 ; i<3 ; i++)\n\t\tif (fabs(p->normal[i]) > 0.9)\n\t\t{\n\t\t\tf = lightaxis[i];\n\t\t\treturn f;\n\t\t}\n\n\t// between two axial planes\n\tfor (i=0 ; i<3 ; i++)\n\t\tif (fabs(p->normal[i]) < 0.1)\n\t\t{\n\t\t\tf = (lightaxis[(i+1)%3] + lightaxis[(i+2)%3])/2;\n\t\t\treturn f;\n\t\t}\n\n\t// other\n\tf= (lightaxis[0] + lightaxis[1] + lightaxis[2]) / 3;\n\treturn f;\n}\n\nvec3_t  vecs[2];\nfloat\tshift[2];\n\n/*\n================\nFace_Alloc\n================\n*/\nface_t *Face_Alloc( void )\n{\n\tface_t *f = (face_t*)qmalloc( sizeof( *f ) );\n\t\n\tif (g_qeglobals.bSurfacePropertiesPlugin)\n\t\tf->pData = static_cast<void *>( g_SurfaceTable.m_pfnTexdefAlloc( f ) );\n\n\treturn f;\n}\n\n/*\n================\nFace_Free\n================\n*/\nvoid Face_Free( face_t *f )\n{\n\tassert( f != 0 );\n\n\tif ( f->face_winding )\n\t{\n\t\tfree( f->face_winding );\n\t\tf->face_winding = 0;\n\t}\n\n\tif (g_qeglobals.bSurfacePropertiesPlugin)\n\t{\n#ifdef _DEBUG\n\t\tif ( !f->pData )\n\t\t{\n\t\t\tSys_Printf(\"WARNING: unexpected IPluginTexdef is NULL in Face_Free\\n\");\n\t\t}\n\t\telse\n#endif\n\t\tGETPLUGINTEXDEF(f)->DecRef();\n\t}\n\n\tf->texdef.~texdef_t();;\n\n\tfree( f );\n}\n\n/*\n================\nFace_Clone\n================\n*/\nface_t\t*Face_Clone (face_t *f)\n{\n\tface_t\t*n;\n\n\tn = Face_Alloc();\n\tn->texdef = f->texdef;\n\n\tmemcpy (n->planepts, f->planepts, sizeof(n->planepts));\n\n\t// all other fields are derived, and will be set by Brush_Build\n\treturn n;\n}\n\n/*\n================\nFace_FullClone\n\nmakes an exact copy of the face\n================\n*/\nface_t\t*Face_FullClone (face_t *f)\n{\n\tface_t\t*n;\n\n\tn = Face_Alloc();\n\tn->texdef = f->texdef;\n\tmemcpy(n->planepts, f->planepts, sizeof(n->planepts));\n\tmemcpy(&n->plane, &f->plane, sizeof(plane_t));\n\tif (f->face_winding)\n\t\tn->face_winding = Winding_Clone(f->face_winding);\n\telse\n\t\tn->face_winding = NULL;\n\tn->d_texture = Texture_ForName( n->texdef.name );\n\treturn n;\n}\n\n/*\n================\nClamp\n================\n*/\nvoid Clamp(float& f, int nClamp)\n{\n  float fFrac = f - static_cast<int>(f);\n  f = static_cast<int>(f) % nClamp;\n  f += fFrac;\n}\n\n/*\n================\nFace_MoveTexture\n================\n*/\nvoid Face_MoveTexture(face_t *f, vec3_t delta)\n{\n\tvec3_t vX, vY;\n/*\n#ifdef _DEBUG\n\tif (g_PrefsDlg.m_bBrushPrimitMode)\n\t\tSys_Printf(\"Warning : Face_MoveTexture not done in brush primitive mode\\n\");\n#endif\n*/\n\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\tFace_MoveTexture_BrushPrimit( f, delta );\n\telse\n\t{\n\t\tTextureAxisFromPlane(&f->plane, vX, vY);\n\n\t\tvec3_t vDP, vShift;\n\t\tvDP[0] = DotProduct(delta, vX);\n\t\tvDP[1] = DotProduct(delta, vY);\n\n\t\tdouble fAngle = f->texdef.rotate  / 180 * Q_PI;\n\t\tdouble c = cos(fAngle);\n\t\tdouble s = sin(fAngle);\n\n\t\tvShift[0] = vDP[0] * c - vDP[1] * s;\n\t\tvShift[1] = vDP[0] * s + vDP[1] * c;\n\n\t\tif (!f->texdef.scale[0])\n\t\t\tf->texdef.scale[0] = 1;\n\t\tif (!f->texdef.scale[1])\n\t\t\tf->texdef.scale[1] = 1;\n\n\t\tf->texdef.shift[0] -= vShift[0] / f->texdef.scale[0];\n\t\tf->texdef.shift[1] -= vShift[1] / f->texdef.scale[1];\n  \n\t\t// clamp the shifts\n\t\tClamp(f->texdef.shift[0], f->d_texture->width);\n\t\tClamp(f->texdef.shift[1], f->d_texture->height);\n\t}\n}\n\n/*\n================\nFace_SetColor\n================\n*/\nvoid Face_SetColor (brush_t *b, face_t *f, float fCurveColor) \n{\n\tfloat\tshade;\n\tqtexture_t *q;\n\n\tq = f->d_texture;\n\n\t// set shading for face\n\tshade = SetShadeForPlane (&f->plane);\n\tif (g_pParentWnd->GetCamera()->Camera().draw_mode == cd_texture && !b->owner->eclass->fixedsize)\n\t{\n\t\t//if (b->curveBrush)\n\t\t//  shade = fCurveColor;\n\t\tf->d_color[0] = \n\t\tf->d_color[1] = \n\t\tf->d_color[2] = shade;\n\t}\n\telse\n\t{\n\t\tf->d_color[0] = shade*q->color[0];\n\t\tf->d_color[1] = shade*q->color[1];\n\t\tf->d_color[2] = shade*q->color[2];\n\t}\n}\n\n/*\n================\nFace_TextureVectors\nTTimo: NOTE: this is never to get called while in brush primitives mode\n================\n*/\nvoid Face_TextureVectors (face_t *f, float STfromXYZ[2][4])\n{\n\tvec3_t\t\tpvecs[2];\n\tint\t\t\tsv, tv;\n\tfloat\t\tang, sinv, cosv;\n\tfloat\t\tns, nt;\n\tint\t\t\ti,j;\n\tqtexture_t *q;\n\ttexdef_t\t*td;\n\n#ifdef _DEBUG\n\t//++timo when playing with patches, this sometimes get called and the Warning is displayed\n\t// find some way out ..\n\tif (g_qeglobals.m_bBrushPrimitMode && !g_qeglobals.bNeedConvert)\n\t\tSys_Printf(\"Warning : illegal call of Face_TextureVectors in brush primitive mode\\n\");\n#endif\n\n\ttd = &f->texdef;\n\tq = f->d_texture;\n\n\tmemset (STfromXYZ, 0, 8*sizeof(float));\n\n\tif (!td->scale[0])\n\t\ttd->scale[0] = (g_PrefsDlg.m_bHiColorTextures) ? 0.5 : 1;\n\tif (!td->scale[1])\n\t\ttd->scale[1] = (g_PrefsDlg.m_bHiColorTextures) ? 0.5 : 1;\n\n\t// get natural texture axis\n\tTextureAxisFromPlane(&f->plane, pvecs[0], pvecs[1]);\n\n\t// rotate axis\n\tif (td->rotate == 0)\n\t\t{ sinv = 0 ; cosv = 1; }\n\telse if (td->rotate == 90)\n\t\t{ sinv = 1 ; cosv = 0; }\n\telse if (td->rotate == 180)\n\t\t{ sinv = 0 ; cosv = -1; }\n\telse if (td->rotate == 270)\n\t\t{ sinv = -1 ; cosv = 0; }\n\telse\n\t{\t\n\t\tang = td->rotate / 180 * Q_PI;\n\t\tsinv = sin(ang);\n\t\tcosv = cos(ang);\n\t}\n\n\tif (pvecs[0][0])\n\t\tsv = 0;\n\telse if (pvecs[0][1])\n\t\tsv = 1;\n\telse\n\t\tsv = 2;\n\t\t\t\t\n\tif (pvecs[1][0])\n\t\ttv = 0;\n\telse if (pvecs[1][1])\n\t\ttv = 1;\n\telse\n\t\ttv = 2;\n\t\t\t\t\t\n\tfor (i=0 ; i<2 ; i++) {\n\t\tns = cosv * pvecs[i][sv] - sinv * pvecs[i][tv];\n\t\tnt = sinv * pvecs[i][sv] +  cosv * pvecs[i][tv];\n\t\tSTfromXYZ[i][sv] = ns;\n\t\tSTfromXYZ[i][tv] = nt;\n\t}\n\n\t// scale\n\tfor (i=0 ; i<2 ; i++)\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t\tSTfromXYZ[i][j] = STfromXYZ[i][j] / td->scale[i];\n\n\t// shift\n\tSTfromXYZ[0][3] = td->shift[0];\n\tSTfromXYZ[1][3] = td->shift[1];\n\n\tfor (j=0 ; j<4 ; j++) {\n\t\tSTfromXYZ[0][j] /= q->width;\n\t\tSTfromXYZ[1][j] /= q->height;\n\t}\n}\n\n/*\n================\nFace_MakePlane\n================\n*/\nvoid Face_MakePlane (face_t *f)\n{\n\tint\t\tj;\n\tvec3_t\tt1, t2, t3;\n\n\t// convert to a vector / dist plane\n\tfor (j=0 ; j<3 ; j++)\n\t{\n\t\tt1[j] = f->planepts[0][j] - f->planepts[1][j];\n\t\tt2[j] = f->planepts[2][j] - f->planepts[1][j];\n\t\tt3[j] = f->planepts[1][j];\n\t}\n\t\n\tCrossProduct(t1,t2, f->plane.normal);\n\tif (VectorCompare (f->plane.normal, vec3_origin))\n\t\tprintf (\"WARNING: brush plane with no normal\\n\");\n\tVectorNormalize (f->plane.normal);\n\tf->plane.dist = DotProduct (t3, f->plane.normal);\n}\n\n/*\n================\nEmitTextureCoordinates\n================\n*/\nvoid EmitTextureCoordinates ( float *xyzst, qtexture_t *q, face_t *f)\n{\n\tfloat\tSTfromXYZ[2][4];\n\n\tFace_TextureVectors (f,  STfromXYZ);\n\txyzst[3] = DotProduct (xyzst, STfromXYZ[0]) + STfromXYZ[0][3];\n\txyzst[4] = DotProduct (xyzst, STfromXYZ[1]) + STfromXYZ[1][3];\n}\n\n//==========================================================================\n\n/*\n================\nBrush_MakeFacePlanes\n================\n*/\nvoid Brush_MakeFacePlanes (brush_t *b)\n{\n\tface_t\t*f;\n\n\tfor (f=b->brush_faces ; f ; f=f->next)\n\t{\n\t\tFace_MakePlane (f);\n\t}\n}\n\n/*\n================\nDrawBrushEntityName\n================\n*/\nvoid DrawBrushEntityName (brush_t *b)\n{\n\tchar\t*name;\n\t//float\ta, s, c;\n\t//vec3_t\tmid;\n\t//int\t\ti;\n\n\tif (!b->owner)\n\t\treturn;\t\t// during contruction\n\n\tif (b->owner == world_entity)\n\t\treturn;\n\n\tif (b != b->owner->brushes.onext)\n\t\treturn;\t// not key brush\n\n// MERGEME\n#if 0\n\tif (!(g_qeglobals.d_savedinfo.exclude & EXCLUDE_ANGLES))\n\t{\n\t\t// draw the angle pointer\n\t\ta = FloatForKey (b->owner, \"angle\");\n\t\tif (a)\n\t\t{\n\t\t\ts = sin (a/180*Q_PI);\n\t\t\tc = cos (a/180*Q_PI);\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t\tmid[i] = (b->mins[i] + b->maxs[i])*0.5; \n\n\t\t\tqglBegin (GL_LINE_STRIP);\n\t\t\tqglVertex3fv (mid);\n\t\t\tmid[0] += c*8;\n\t\t\tmid[1] += s*8;\n\t\t\tmid[2] += s*8;\n\t\t\tqglVertex3fv (mid);\n\t\t\tmid[0] -= c*4;\n\t\t\tmid[1] -= s*4;\n\t\t\tmid[2] -= s*4;\n\t\t\tmid[0] -= s*4;\n\t\t\tmid[1] += c*4;\n\t\t\tmid[2] += c*4;\n\t\t\tqglVertex3fv (mid);\n\t\t\tmid[0] += c*4;\n\t\t\tmid[1] += s*4;\n\t\t\tmid[2] += s*4;\n\t\t\tmid[0] += s*4;\n\t\t\tmid[1] -= c*4;\n\t\t\tmid[2] -= c*4;\n\t\t\tqglVertex3fv (mid);\n\t\t\tmid[0] -= c*4;\n\t\t\tmid[1] -= s*4;\n\t\t\tmid[2] -= s*4;\n\t\t\tmid[0] += s*4;\n\t\t\tmid[1] -= c*4;\n\t\t\tmid[2] -= c*4;\n\t\t\tqglVertex3fv (mid);\n\t\t\tqglEnd ();\n\t\t}\n\t}\n#endif\n\n\tif (g_qeglobals.d_savedinfo.show_names)\n\t{\n\t\tname = ValueForKey (b->owner, \"classname\");\n\t\tqglRasterPos3f (b->mins[0]+4, b->mins[1]+4, b->mins[2]+4);\n\t\tqglCallLists (strlen(name), GL_UNSIGNED_BYTE, name);\n\t}\n}\n\n/*\n=================\nBrush_MakeFaceWinding\n\nreturns the visible polygon on a face\n=================\n*/\nwinding_t *Brush_MakeFaceWinding (brush_t *b, face_t *face)\n{\n\twinding_t\t*w;\n\tface_t\t\t*clip;\n\tplane_t\t\t\tplane;\n\tqboolean\t\tpast;\n\n\t// get a poly that covers an effectively infinite area\n\tw = Winding_BaseForPlane (&face->plane);\n\n\t// chop the poly by all of the other faces\n\tpast = false;\n\tfor (clip = b->brush_faces ; clip && w ; clip=clip->next)\n\t{\n\t\tif (clip == face)\n\t\t{\n\t\t\tpast = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (DotProduct (face->plane.normal, clip->plane.normal) > 0.999\n\t\t\t&& fabs(face->plane.dist - clip->plane.dist) < 0.01 )\n\t\t{\t// identical plane, use the later one\n\t\t\tif (past)\n\t\t\t{\n\t\t\t\tfree (w);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// flip the plane, because we want to keep the back side\n\t\tVectorSubtract (vec3_origin,clip->plane.normal, plane.normal);\n\t\tplane.dist = -clip->plane.dist;\n\t\t\n\t\tw = Winding_Clip (w, &plane, false);\n\t\tif (!w)\n\t\t\treturn w;\n\t}\n\t\n\tif (w->numpoints < 3)\n\t{\n\t\tfree(w);\n\t\tw = NULL;\n\t}\n\n\tif (!w)\n\t\tprintf (\"unused plane\\n\");\n\n\treturn w;\n}\n\n/*\n=================\nBrush_SnapPlanepts\n=================\n*/\nvoid Brush_SnapPlanepts (brush_t *b)\n{\n\tint\t\ti, j;\n\tface_t\t*f;\n\n  if (g_PrefsDlg.m_bNoClamp)\n    return;\n\n\tfor (f=b->brush_faces ; f; f=f->next)\n\t\tfor (i=0 ; i<3 ; i++)\n\t\t\tfor (j=0 ; j<3 ; j++)\n\t\t\t\tf->planepts[i][j] = floor (f->planepts[i][j] + 0.5);\n}\n\t\n/*\n** Brush_Build\n**\n** Builds a brush rendering data and also sets the min/max bounds\n*/\n// TTimo\n// added a bConvert flag to convert between old and new brush texture formats\n// TTimo\n// brush grouping: update the group treeview if necessary\nvoid Brush_Build( brush_t *b, bool bSnap, bool bMarkMap, bool bConvert )\n{\n\tbool\t\tbLocalConvert;\n\n#ifdef _DEBUG\n\tif (!g_qeglobals.m_bBrushPrimitMode && bConvert)\n\t\tSys_Printf(\"Warning : conversion from brush primitive to old brush format not implemented\\n\");\n#endif\n\n\t// if bConvert is set and g_qeglobals.bNeedConvert is not, that just means we need convert for this brush only\n\tif (bConvert && !g_qeglobals.bNeedConvert)\n\t{\n\t\tbLocalConvert = true;\n\t\tg_qeglobals.bNeedConvert = true;\n\t}\n\n\t/*\n\t** build the windings and generate the bounding box\n\t*/\n\tBrush_BuildWindings(b, bSnap);\n\n\tPatch_BuildPoints (b);\n\n\t/*\n\t** move the points and edges if in select mode\n\t*/\n\tif (g_qeglobals.d_select_mode == sel_vertex || g_qeglobals.d_select_mode == sel_edge)\n\t\tSetupVertexSelection ();\n\n    if (b->itemOwner == NULL)\n      Group_AddToProperGroup(b);\n\n\tif (bMarkMap)\n\t{\n\t\tSys_MarkMapModified();\n\t}\n\n\tif (bLocalConvert)\n\t\tg_qeglobals.bNeedConvert = false;\n}\n\n/*\n==============\nBrush_SplitBrushByFace\n\nThe incoming brush is NOT freed.\nThe incoming face is NOT left referenced.\n==============\n*/\nvoid Brush_SplitBrushByFace (brush_t *in, face_t *f, brush_t **front, brush_t **back)\n{\n\tbrush_t\t*b;\n\tface_t\t*nf;\n\tvec3_t\ttemp;\n\n\tb = Brush_Clone (in);\n\tnf = Face_Clone (f);\n\n\tnf->texdef = b->brush_faces->texdef;\n\tnf->next = b->brush_faces;\n\tb->brush_faces = nf;\n\n\tBrush_Build( b );\n\tBrush_RemoveEmptyFaces ( b );\n\tif ( !b->brush_faces )\n\t{\t// completely clipped away\n\t\tBrush_Free (b);\n\t\t*back = NULL;\n\t}\n\telse\n\t{\n\t\tEntity_LinkBrush (in->owner, b);\n\t\t*back = b;\n\t}\n\n\tb = Brush_Clone (in);\n\tnf = Face_Clone (f);\n\t// swap the plane winding\n\tVectorCopy (nf->planepts[0], temp);\n\tVectorCopy (nf->planepts[1], nf->planepts[0]);\n\tVectorCopy (temp, nf->planepts[1]);\n\n\tnf->texdef = b->brush_faces->texdef;\n\tnf->next = b->brush_faces;\n\tb->brush_faces = nf;\n\n\tBrush_Build( b );\n\tBrush_RemoveEmptyFaces ( b );\n\tif ( !b->brush_faces )\n\t{\t// completely clipped away\n\t\tBrush_Free (b);\n\t\t*front = NULL;\n\t}\n\telse\n\t{\n\t\tEntity_LinkBrush (in->owner, b);\n\t\t*front = b;\n\t}\n}\n\n/*\n=================\nBrush_BestSplitFace\n\nreturns the best face to split the brush with.\nreturn NULL if the brush is convex\n=================\n*/\nface_t *Brush_BestSplitFace(brush_t *b)\n{\n\tface_t *face, *f, *bestface;\n\twinding_t *front, *back;\n\tint splits, tinywindings, value, bestvalue;\n\n\tbestvalue = 999999;\n\tbestface = NULL;\n\tfor (face = b->brush_faces; face; face = face->next)\n\t{\n\t\tsplits = 0;\n\t\ttinywindings = 0;\n\t\tfor (f = b->brush_faces; f; f = f->next)\n\t\t{\n\t\t\tif (f == face) continue;\n\t\t\t//\n\t\t\tWinding_SplitEpsilon(f->face_winding, face->plane.normal, face->plane.dist, 0.1, &front, &back);\n\n\t\t\tif (!front)\n\t\t\t{\n\t\t\t\tWinding_Free(back);\n\t\t\t}\n\t\t\telse if (!back)\n\t\t\t{\n\t\t\t\tWinding_Free(front);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tsplits++;\n\t\t\t\tif (Winding_IsTiny(front)) tinywindings++;\n\t\t\t\tif (Winding_IsTiny(back)) tinywindings++;\n\t\t\t}\n\t\t}\n\t\tif (splits)\n\t\t{\n\t\t\tvalue = splits + 50 * tinywindings;\n\t\t\tif (value < bestvalue)\n\t\t\t{\n\t\t\t\tbestvalue = value;\n\t\t\t\tbestface = face;\n\t\t\t}\n\t\t}\n\t}\n\treturn bestface;\n}\n\n/*\n=================\nBrush_MakeConvexBrushes\n\nMrE FIXME: this doesn't work because the old\n\t\t   Brush_SplitBrushByFace is used\nTurns the brush into a minimal number of convex brushes.\nIf the input brush is convex then it will be returned.\nOtherwise the input brush will be freed.\nNOTE: the input brush should have windings for the faces.\n=================\n*/\nbrush_t *Brush_MakeConvexBrushes(brush_t *b)\n{\n\tbrush_t *front, *back, *end;\n\tface_t *face;\n\n\tb->next = NULL;\n\tface = Brush_BestSplitFace(b);\n\tif (!face) return b;\n\tBrush_SplitBrushByFace(b, face, &front, &back);\n\t//this should never happen\n\tif (!front && !back) return b;\n\tBrush_Free(b);\n\tif (!front)\n\t\treturn Brush_MakeConvexBrushes(back);\n\tb = Brush_MakeConvexBrushes(front);\n\tif (back)\n\t{\n\t\tfor (end = b; end->next; end = end->next);\n\t\tend->next = Brush_MakeConvexBrushes(back);\n\t}\n\treturn b;\n}\n\n/*\n=================\nBrush_Convex\n=================\n*/\nint Brush_Convex(brush_t *b)\n{\n\tface_t *face1, *face2;\n\n\tfor (face1 = b->brush_faces; face1; face1 = face1->next)\n\t{\n\t\tif (!face1->face_winding) continue;\n\t\tfor (face2 = b->brush_faces; face2; face2 = face2->next)\n\t\t{\n\t\t\tif (face1 == face2) continue;\n\t\t\tif (!face2->face_winding) continue;\n\t\t\tif (Winding_PlanesConcave(face1->face_winding, face2->face_winding,\n\t\t\t\t\t\t\t\t\t\tface1->plane.normal, face2->plane.normal,\n\t\t\t\t\t\t\t\t\t\tface1->plane.dist, face2->plane.dist))\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\treturn true;\n}\n\n/*\n=================\nBrush_MoveVertexes_old1\n\n- The input brush must have face windings.\n- The input brush must be a brush with faces that do not intersect.\n- The input brush does not have to be convex.\n- The vertex will not be moved if the movement either causes the\n  brush to have faces that intersect or causes the brush to be\n  flipped inside out.\n  (For instance a tetrahedron can easily be flipped inside out\n  without having faces that intersect.)\n- The created brush does not have to be convex.\n- Returns true if the vertex movement is performed.\n=================\n*/\n\n#define MAX_MOVE_FACES\t\t64\n#define INTERSECT_EPSILON\t0.1\n#define POINT_EPSILON\t\t0.3\n\nint Brush_MoveVertex_old1(brush_t *b, vec3_t vertex, vec3_t delta, vec3_t end, bool bSnap)\n{\n\tface_t *f, *face, *newface, *lastface, *nextface;\n\tface_t *movefaces[MAX_MOVE_FACES];\n\tint movefacepoints[MAX_MOVE_FACES];\n\twinding_t *w, tmpw;\n\tint i, j, k, nummovefaces, result;\n\tfloat dot;\n\n\tresult = false;\n\t//\n\ttmpw.numpoints = 3;\n\ttmpw.maxpoints = 3;\n\tVectorAdd(vertex, delta, end);\n\t//snap or not?\n\tif (bSnap)\n\t\tfor (i = 0; i < 3; i++)\n\t\t\tend[i] = floor(end[i] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize;\n\t//chop off triangles from all brush faces that use the to be moved vertex\n\t//store pointers to these chopped off triangles in movefaces[]\n\tnummovefaces = 0;\n\tfor (face = b->brush_faces; face; face = face->next)\n\t{\n\t\tw = face->face_winding;\n\t\tif (!w) continue;\n\t\tfor (i = 0; i < w->numpoints; i++)\n\t\t{\n\t\t\tif (Point_Equal(w->points[i], vertex, POINT_EPSILON))\n\t\t\t{\n\t\t\t\tif (face->face_winding->numpoints <= 3)\n\t\t\t\t{\n\t\t\t\t\tmovefacepoints[nummovefaces] = i;\n\t\t\t\t\tmovefaces[nummovefaces++] = face;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdot = DotProduct(end, face->plane.normal) - face->plane.dist;\n\t\t\t\t//if the end point is in front of the face plane\n\t\t\t\tif (dot > 0.1)\n\t\t\t\t{\n\t\t\t\t\t//fanout triangle subdivision\n\t\t\t\t\tfor (k = i; k < i + w->numpoints-3; k++)\n\t\t\t\t\t{\n\t\t\t\t\t\tVectorCopy(w->points[i], tmpw.points[0]);\n\t\t\t\t\t\tVectorCopy(w->points[(k+1) % w->numpoints], tmpw.points[1]);\n\t\t\t\t\t\tVectorCopy(w->points[(k+2) % w->numpoints], tmpw.points[2]);\n\t\t\t\t\t\t//\n\t\t\t\t\t\tnewface = Face_Clone(face);\n\t\t\t\t\t\t//get the original\n\t\t\t\t\t\tfor (f = face; f->original; f = f->original) ;\n\t\t\t\t\t\tnewface->original = f;\n\t\t\t\t\t\t//store the new winding\n\t\t\t\t\t\tif (newface->face_winding) Winding_Free(newface->face_winding);\n\t\t\t\t\t\tnewface->face_winding = Winding_Clone(&tmpw);\n\t\t\t\t\t\t//get the texture\n\t\t\t\t\t\tnewface->d_texture = Texture_ForName( newface->texdef.name );\n\t\t\t\t\t\t//add the face to the brush\n\t\t\t\t\t\tnewface->next = b->brush_faces;\n\t\t\t\t\t\tb->brush_faces = newface;\n\t\t\t\t\t\t//add this new triangle to the move faces\n\t\t\t\t\t\tmovefacepoints[nummovefaces] = 0;\n\t\t\t\t\t\tmovefaces[nummovefaces++] = newface;\n\t\t\t\t\t}\n\t\t\t\t\t//give the original face a new winding\n\t\t\t\t\tVectorCopy(w->points[(i-2+w->numpoints) % w->numpoints], tmpw.points[0]);\n\t\t\t\t\tVectorCopy(w->points[(i-1+w->numpoints) % w->numpoints], tmpw.points[1]);\n\t\t\t\t\tVectorCopy(w->points[i], tmpw.points[2]);\n\t\t\t\t\tWinding_Free(face->face_winding);\n\t\t\t\t\tface->face_winding = Winding_Clone(&tmpw);\n\t\t\t\t\t//add the original face to the move faces\n\t\t\t\t\tmovefacepoints[nummovefaces] = 2;\n\t\t\t\t\tmovefaces[nummovefaces++] = face;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t//chop a triangle off the face\n\t\t\t\t\tVectorCopy(w->points[(i-1+w->numpoints) % w->numpoints], tmpw.points[0]);\n\t\t\t\t\tVectorCopy(w->points[i], tmpw.points[1]);\n\t\t\t\t\tVectorCopy(w->points[(i+1) % w->numpoints], tmpw.points[2]);\n\t\t\t\t\t//remove the point from the face winding\n\t\t\t\t\tWinding_RemovePoint(w, i);\n\t\t\t\t\t//get texture crap right\n\t\t\t\t\tFace_SetColor(b, face, 1.0);\n\t\t\t\t\tfor (j = 0; j < w->numpoints; j++)\n\t\t\t\t\t\tEmitTextureCoordinates(w->points[j], face->d_texture, face);\n\t\t\t\t\t//make a triangle face\n\t\t\t\t\tnewface = Face_Clone(face);\n\t\t\t\t\t//get the original\n\t\t\t\t\tfor (f = face; f->original; f = f->original) ;\n\t\t\t\t\tnewface->original = f;\n\t\t\t\t\t//store the new winding\n\t\t\t\t\tif (newface->face_winding) Winding_Free(newface->face_winding);\n\t\t\t\t\tnewface->face_winding = Winding_Clone(&tmpw);\n\t\t\t\t\t//get the texture\n\t\t\t\t\tnewface->d_texture = Texture_ForName( newface->texdef.name );\n\t\t\t\t\t//add the face to the brush\n\t\t\t\t\tnewface->next = b->brush_faces;\n\t\t\t\t\tb->brush_faces = newface;\n\t\t\t\t\t//\n\t\t\t\t\tmovefacepoints[nummovefaces] = 1;\n\t\t\t\t\tmovefaces[nummovefaces++] = newface;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\t//now movefaces contains pointers to triangle faces that\n\t//contain the to be moved vertex\n\n\t//check if the move is valid\n\tint l;\n\tvec3_t p1, p2;\n\twinding_t *w2;\n\tplane_t plane;\n\n\tface = NULL;\n\tVectorCopy(vertex, tmpw.points[1]);\n\tVectorCopy(end, tmpw.points[2]);\n\tfor (face = b->brush_faces; face; face = face->next)\n\t{\n\t\tfor (i = 0; i < nummovefaces; i++)\n\t\t{\n\t\t\tif (face == movefaces[i])\n\t\t\t\tbreak;\n\t\t}\n\t\tif (i < nummovefaces)\n\t\t\tcontinue;\n\t\t//the delta vector may not intersect with any of the not move faces\n\t\tif (Winding_VectorIntersect(face->face_winding, &face->plane, vertex, end, INTERSECT_EPSILON))\n\t\t\tbreak;\n\t\t//if the end point of the to be moved vertex is near this not move face\n\t\tif (abs(DotProduct(face->plane.normal, end) - face->plane.dist) < 0.5)\n\t\t{\n\t\t\t//the end point may not be inside or very close to the not move face winding\n\t\t\tif (Winding_PointInside(face->face_winding, &face->plane, end, 0.5))\n\t\t\t\tbreak;\n\t\t}\n\t\tfor (i = 0; i < nummovefaces; i++)\n\t\t{\n\t\t\tw = movefaces[i]->face_winding;\n\t\t\tj = movefacepoints[i];\n\t\t\tfor (k = -1; k <= 1; k += 2)\n\t\t\t{\n\t\t\t\t//check if the new edge will not intersect with the not move face\n\t\t\t\tVectorCopy(w->points[(j + k + w->numpoints) % w->numpoints], tmpw.points[0]);\n\t\t\t\tif (Winding_VectorIntersect(face->face_winding, &face->plane, tmpw.points[0], end, INTERSECT_EPSILON))\n\t\t\t\t{\n\t\t\t\t\t//ok the new edge instersects with the not move face\n\t\t\t\t\t//we can't perform the vertex movement\n\t\t\t\t\t//break;\n\t\t\t\t}\n\t\t\t\t//check if the not move face intersects the \"movement winding\"\n\t\t\t\tWinding_Plane(&tmpw, plane.normal, &plane.dist);\n\t\t\t\tw2 = face->face_winding;\n\t\t\t\tfor (l = 0; l < w2->numpoints; l++)\n\t\t\t\t{\n\t\t\t\t\tVectorCopy(w2->points[l], p1);\n\t\t\t\t\tif (Point_Equal(p1, tmpw.points[0], POINT_EPSILON)) continue;\n\t\t\t\t\tVectorCopy(w2->points[(l+1) % w2->numpoints], p2);\n\t\t\t\t\tif (Point_Equal(p2, tmpw.points[0], POINT_EPSILON)) continue;\n\t\t\t\t\tif (Winding_VectorIntersect(&tmpw, &plane, p1, p2, INTERSECT_EPSILON))\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (l < w2->numpoints)\n\t\t\t\t{\n\t\t\t\t\t//ok this not move face intersects the \"movement winding\"\n\t\t\t\t\t//we can't perform the vertex movement\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (k <= 1) break;\n\t\t}\n\t\tif (i < nummovefaces)\n\t\t\tbreak;\n\t}\n\tif (!face)\n\t{\n\t\t//ok the move was valid\n\t\t//now move all the vertexes of the movefaces\n\t\tfor (i = 0; i < nummovefaces; i++)\n\t\t{\n\t\t\tVectorCopy(end, movefaces[i]->face_winding->points[movefacepoints[i]]);\n\t\t\t//create new face plane\n\t\t\tfor (j = 0; j < 3; j++)\n\t\t\t{\n\t\t\t\tVectorCopy(movefaces[i]->face_winding->points[j], movefaces[i]->planepts[j]);\n\t\t\t}\n\t\t\tFace_MakePlane(movefaces[i]);\n\t\t}\n\t\tresult = true;\n\t}\n\t//get texture crap right\n\tfor (i = 0; i < nummovefaces; i++)\n\t{\n\t\tFace_SetColor(b, movefaces[i], 1.0);\n\t\tfor (j = 0; j < movefaces[i]->face_winding->numpoints; j++)\n\t\t\tEmitTextureCoordinates(movefaces[i]->face_winding->points[j], movefaces[i]->d_texture, movefaces[i]);\n\t}\n\n\t//now try to merge faces with their original faces\n\tlastface = NULL;\n\tfor (face = b->brush_faces; face; face = nextface)\n\t{\n\t\tnextface = face->next;\n\t\tif (!face->original)\n\t\t{\n\t\t\tlastface = face;\n\t\t\tcontinue;\n\t\t}\n\t\tif (!Plane_Equal(&face->plane, &face->original->plane, false))\n\t\t{\n\t\t\tlastface = face;\n\t\t\tcontinue;\n\t\t}\n\t\tw = Winding_TryMerge(face->face_winding, face->original->face_winding, face->plane.normal, true);\n\t\tif (!w)\n\t\t{\n\t\t\tlastface = face;\n\t\t\tcontinue;\n\t\t}\n\t\tWinding_Free(face->original->face_winding);\n\t\tface->original->face_winding = w;\n\t\t//get texture crap right\n\t\tFace_SetColor(b, face->original, 1.0);\n\t\tfor (j = 0; j < face->original->face_winding->numpoints; j++)\n\t\t\tEmitTextureCoordinates(face->original->face_winding->points[j], face->original->d_texture, face->original);\n\t\t//remove the face that was merged with the original\n\t\tif (lastface) lastface->next = face->next;\n\t\telse b->brush_faces = face->next;\n\t\tFace_Free(face);\n\t}\n\treturn result;\n}\n\n/*\n=================\nBrush_MoveVertexes_old2\n\n- The input brush must be convex\n- The input brush must have face windings.\n- The output brush will be convex.\n- Returns true if the vertex movement is performed.\n=================\n*/\n\n#define MAX_MOVE_FACES\t\t64\n#define INTERSECT_EPSILON\t0.1\n#define POINT_EPSILON\t\t0.3\n\nint Brush_MoveVertex_old2(brush_t *b, vec3_t vertex, vec3_t delta, vec3_t end, bool bSnap)\n{\n\tface_t *f, *face, *newface, *lastface, *nextface;\n\tface_t *movefaces[MAX_MOVE_FACES];\n\tint movefacepoints[MAX_MOVE_FACES];\n\twinding_t *w, tmpw;\n\tint i, j, k, nummovefaces, result;\n\tfloat dot;\n\n\tresult = true;\n\t//\n\ttmpw.numpoints = 3;\n\ttmpw.maxpoints = 3;\n\tVectorAdd(vertex, delta, end);\n\t//snap or not?\n\tif (bSnap)\n\t\tfor (i = 0; i < 3; i++)\n\t\t\tend[i] = floor(end[i] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize;\n\t//chop off triangles from all brush faces that use the to be moved vertex\n\t//store pointers to these chopped off triangles in movefaces[]\n\tnummovefaces = 0;\n\tfor (face = b->brush_faces; face; face = face->next)\n\t{\n\t\tw = face->face_winding;\n\t\tif (!w) continue;\n\t\tfor (i = 0; i < w->numpoints; i++)\n\t\t{\n\t\t\tif (Point_Equal(w->points[i], vertex, POINT_EPSILON))\n\t\t\t{\n\t\t\t\tif (face->face_winding->numpoints <= 3)\n\t\t\t\t{\n\t\t\t\t\tmovefacepoints[nummovefaces] = i;\n\t\t\t\t\tmovefaces[nummovefaces++] = face;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdot = DotProduct(end, face->plane.normal) - face->plane.dist;\n\t\t\t\t//if the end point is in front of the face plane\n\t\t\t\tif (dot > 0.1)\n\t\t\t\t{\n\t\t\t\t\t//fanout triangle subdivision\n\t\t\t\t\tfor (k = i; k < i + w->numpoints-3; k++)\n\t\t\t\t\t{\n\t\t\t\t\t\tVectorCopy(w->points[i], tmpw.points[0]);\n\t\t\t\t\t\tVectorCopy(w->points[(k+1) % w->numpoints], tmpw.points[1]);\n\t\t\t\t\t\tVectorCopy(w->points[(k+2) % w->numpoints], tmpw.points[2]);\n\t\t\t\t\t\t//\n\t\t\t\t\t\tnewface = Face_Clone(face);\n\t\t\t\t\t\t//get the original\n\t\t\t\t\t\tfor (f = face; f->original; f = f->original) ;\n\t\t\t\t\t\tnewface->original = f;\n\t\t\t\t\t\t//store the new winding\n\t\t\t\t\t\tif (newface->face_winding) Winding_Free(newface->face_winding);\n\t\t\t\t\t\tnewface->face_winding = Winding_Clone(&tmpw);\n\t\t\t\t\t\t//get the texture\n\t\t\t\t\t\tnewface->d_texture = Texture_ForName( newface->texdef.name );\n\t\t\t\t\t\t//add the face to the brush\n\t\t\t\t\t\tnewface->next = b->brush_faces;\n\t\t\t\t\t\tb->brush_faces = newface;\n\t\t\t\t\t\t//add this new triangle to the move faces\n\t\t\t\t\t\tmovefacepoints[nummovefaces] = 0;\n\t\t\t\t\t\tmovefaces[nummovefaces++] = newface;\n\t\t\t\t\t}\n\t\t\t\t\t//give the original face a new winding\n\t\t\t\t\tVectorCopy(w->points[(i-2+w->numpoints) % w->numpoints], tmpw.points[0]);\n\t\t\t\t\tVectorCopy(w->points[(i-1+w->numpoints) % w->numpoints], tmpw.points[1]);\n\t\t\t\t\tVectorCopy(w->points[i], tmpw.points[2]);\n\t\t\t\t\tWinding_Free(face->face_winding);\n\t\t\t\t\tface->face_winding = Winding_Clone(&tmpw);\n\t\t\t\t\t//add the original face to the move faces\n\t\t\t\t\tmovefacepoints[nummovefaces] = 2;\n\t\t\t\t\tmovefaces[nummovefaces++] = face;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t//chop a triangle off the face\n\t\t\t\t\tVectorCopy(w->points[(i-1+w->numpoints) % w->numpoints], tmpw.points[0]);\n\t\t\t\t\tVectorCopy(w->points[i], tmpw.points[1]);\n\t\t\t\t\tVectorCopy(w->points[(i+1) % w->numpoints], tmpw.points[2]);\n\t\t\t\t\t//remove the point from the face winding\n\t\t\t\t\tWinding_RemovePoint(w, i);\n\t\t\t\t\t//get texture crap right\n\t\t\t\t\tFace_SetColor(b, face, 1.0);\n\t\t\t\t\tfor (j = 0; j < w->numpoints; j++)\n\t\t\t\t\t\tEmitTextureCoordinates(w->points[j], face->d_texture, face);\n\t\t\t\t\t//make a triangle face\n\t\t\t\t\tnewface = Face_Clone(face);\n\t\t\t\t\t//get the original\n\t\t\t\t\tfor (f = face; f->original; f = f->original) ;\n\t\t\t\t\tnewface->original = f;\n\t\t\t\t\t//store the new winding\n\t\t\t\t\tif (newface->face_winding) Winding_Free(newface->face_winding);\n\t\t\t\t\tnewface->face_winding = Winding_Clone(&tmpw);\n\t\t\t\t\t//get the texture\n\t\t\t\t\tnewface->d_texture = Texture_ForName( newface->texdef.name );\n\t\t\t\t\t//add the face to the brush\n\t\t\t\t\tnewface->next = b->brush_faces;\n\t\t\t\t\tb->brush_faces = newface;\n\t\t\t\t\t//\n\t\t\t\t\tmovefacepoints[nummovefaces] = 1;\n\t\t\t\t\tmovefaces[nummovefaces++] = newface;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\t//now movefaces contains pointers to triangle faces that\n\t//contain the to be moved vertex\n\n\t//move the vertex\n\tfor (i = 0; i < nummovefaces; i++)\n\t{\n\t\t//move vertex to end position\n\t\tVectorCopy(end, movefaces[i]->face_winding->points[movefacepoints[i]]);\n\t\t//create new face plane\n\t\tfor (j = 0; j < 3; j++)\n\t\t{\n\t\t\tVectorCopy(movefaces[i]->face_winding->points[j], movefaces[i]->planepts[j]);\n\t\t}\n\t\tFace_MakePlane(movefaces[i]);\n\t}\n\t//if the brush is no longer convex\n\tif (!Brush_Convex(b))\n\t{\n\t\tfor (i = 0; i < nummovefaces; i++)\n\t\t{\n\t\t\t//move the vertex back to the initial position\n\t\t\tVectorCopy(vertex, movefaces[i]->face_winding->points[movefacepoints[i]]);\n\t\t\t//create new face plane\n\t\t\tfor (j = 0; j < 3; j++)\n\t\t\t{\n\t\t\t\tVectorCopy(movefaces[i]->face_winding->points[j], movefaces[i]->planepts[j]);\n\t\t\t}\n\t\t\tFace_MakePlane(movefaces[i]);\n\t\t}\n\t\tresult = false;\n\t}\n\t//get texture crap right\n\tfor (i = 0; i < nummovefaces; i++)\n\t{\n\t\tFace_SetColor(b, movefaces[i], 1.0);\n\t\tfor (j = 0; j < movefaces[i]->face_winding->numpoints; j++)\n\t\t\tEmitTextureCoordinates(movefaces[i]->face_winding->points[j], movefaces[i]->d_texture, movefaces[i]);\n\t}\n\n\t//now try to merge faces with their original faces\n\tlastface = NULL;\n\tfor (face = b->brush_faces; face; face = nextface)\n\t{\n\t\tnextface = face->next;\n\t\tif (!face->original)\n\t\t{\n\t\t\tlastface = face;\n\t\t\tcontinue;\n\t\t}\n\t\tif (!Plane_Equal(&face->plane, &face->original->plane, false))\n\t\t{\n\t\t\tlastface = face;\n\t\t\tcontinue;\n\t\t}\n\t\tw = Winding_TryMerge(face->face_winding, face->original->face_winding, face->plane.normal, true);\n\t\tif (!w)\n\t\t{\n\t\t\tlastface = face;\n\t\t\tcontinue;\n\t\t}\n\t\tWinding_Free(face->original->face_winding);\n\t\tface->original->face_winding = w;\n\t\t//get texture crap right\n\t\tFace_SetColor(b, face->original, 1.0);\n\t\tfor (j = 0; j < face->original->face_winding->numpoints; j++)\n\t\t\tEmitTextureCoordinates(face->original->face_winding->points[j], face->original->d_texture, face->original);\n\t\t//remove the face that was merged with the original\n\t\tif (lastface) lastface->next = face->next;\n\t\telse b->brush_faces = face->next;\n\t\tFace_Free(face);\n\t}\n\treturn result;\n}\n\n/*\n=================\nBrush_MoveVertexes\n\n- The input brush must be convex\n- The input brush must have face windings.\n- The output brush will be convex.\n- Returns true if the WHOLE vertex movement is performed.\n=================\n*/\n\n#define MAX_MOVE_FACES\t\t64\n\nint Brush_MoveVertex(brush_t *b, vec3_t vertex, vec3_t delta, vec3_t end, bool bSnap)\n{\n\tface_t *f, *face, *newface, *lastface, *nextface;\n\tface_t *movefaces[MAX_MOVE_FACES];\n\tint movefacepoints[MAX_MOVE_FACES];\n\twinding_t *w, tmpw;\n\tvec3_t start, mid;\n\tplane_t plane;\n\tint i, j, k, nummovefaces, result, done;\n\tfloat dot, front, back, frac, smallestfrac;\n\n\tresult = true;\n\t//\n\ttmpw.numpoints = 3;\n\ttmpw.maxpoints = 3;\n\tVectorCopy(vertex, start);\n\tVectorAdd(vertex, delta, end);\n\t//snap or not?\n\tif (bSnap)\n\t\tfor (i = 0; i < 3; i++)\n\t\t\tend[i] = floor(end[i] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize;\n\t//\n\tVectorCopy(end, mid);\n\t//if the start and end are the same\n\tif (Point_Equal(start, end, 0.3)) return false;\n\t//the end point may not be the same as another vertex\n\tfor (face = b->brush_faces; face; face = face->next)\n\t{\n\t\tw = face->face_winding;\n\t\tif (!w) continue;\n\t\tfor (i = 0; i < w->numpoints; i++)\n\t\t{\n\t\t\tif (Point_Equal(w->points[i], end, 0.3))\n\t\t\t{\n\t\t\t\tVectorCopy(vertex, end);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\t//\n\tdone = false;\n\twhile(!done)\n\t{\n\t\t//chop off triangles from all brush faces that use the to be moved vertex\n\t\t//store pointers to these chopped off triangles in movefaces[]\n\t\tnummovefaces = 0;\n\t\tfor (face = b->brush_faces; face; face = face->next)\n\t\t{\n\t\t\tw = face->face_winding;\n\t\t\tif (!w) continue;\n\t\t\tfor (i = 0; i < w->numpoints; i++)\n\t\t\t{\n\t\t\t\tif (Point_Equal(w->points[i], start, 0.2))\n\t\t\t\t{\n\t\t\t\t\tif (face->face_winding->numpoints <= 3)\n\t\t\t\t\t{\n\t\t\t\t\t\tmovefacepoints[nummovefaces] = i;\n\t\t\t\t\t\tmovefaces[nummovefaces++] = face;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdot = DotProduct(end, face->plane.normal) - face->plane.dist;\n\t\t\t\t\t//if the end point is in front of the face plane\n\t\t\t\t\tif (dot > 0.1)\n\t\t\t\t\t{\n\t\t\t\t\t\t//fanout triangle subdivision\n\t\t\t\t\t\tfor (k = i; k < i + w->numpoints-3; k++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tVectorCopy(w->points[i], tmpw.points[0]);\n\t\t\t\t\t\t\tVectorCopy(w->points[(k+1) % w->numpoints], tmpw.points[1]);\n\t\t\t\t\t\t\tVectorCopy(w->points[(k+2) % w->numpoints], tmpw.points[2]);\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\tnewface = Face_Clone(face);\n\t\t\t\t\t\t\t//get the original\n\t\t\t\t\t\t\tfor (f = face; f->original; f = f->original) ;\n\t\t\t\t\t\t\tnewface->original = f;\n\t\t\t\t\t\t\t//store the new winding\n\t\t\t\t\t\t\tif (newface->face_winding) Winding_Free(newface->face_winding);\n\t\t\t\t\t\t\tnewface->face_winding = Winding_Clone(&tmpw);\n\t\t\t\t\t\t\t//get the texture\n\t\t\t\t\t\t\tnewface->d_texture = Texture_ForName( newface->texdef.name );\n\t\t\t\t\t\t\t//add the face to the brush\n\t\t\t\t\t\t\tnewface->next = b->brush_faces;\n\t\t\t\t\t\t\tb->brush_faces = newface;\n\t\t\t\t\t\t\t//add this new triangle to the move faces\n\t\t\t\t\t\t\tmovefacepoints[nummovefaces] = 0;\n\t\t\t\t\t\t\tmovefaces[nummovefaces++] = newface;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t//give the original face a new winding\n\t\t\t\t\t\tVectorCopy(w->points[(i-2+w->numpoints) % w->numpoints], tmpw.points[0]);\n\t\t\t\t\t\tVectorCopy(w->points[(i-1+w->numpoints) % w->numpoints], tmpw.points[1]);\n\t\t\t\t\t\tVectorCopy(w->points[i], tmpw.points[2]);\n\t\t\t\t\t\tWinding_Free(face->face_winding);\n\t\t\t\t\t\tface->face_winding = Winding_Clone(&tmpw);\n\t\t\t\t\t\t//add the original face to the move faces\n\t\t\t\t\t\tmovefacepoints[nummovefaces] = 2;\n\t\t\t\t\t\tmovefaces[nummovefaces++] = face;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t//chop a triangle off the face\n\t\t\t\t\t\tVectorCopy(w->points[(i-1+w->numpoints) % w->numpoints], tmpw.points[0]);\n\t\t\t\t\t\tVectorCopy(w->points[i], tmpw.points[1]);\n\t\t\t\t\t\tVectorCopy(w->points[(i+1) % w->numpoints], tmpw.points[2]);\n\t\t\t\t\t\t//remove the point from the face winding\n\t\t\t\t\t\tWinding_RemovePoint(w, i);\n\t\t\t\t\t\t//get texture crap right\n\t\t\t\t\t\tFace_SetColor(b, face, 1.0);\n\t\t\t\t\t\tfor (j = 0; j < w->numpoints; j++)\n\t\t\t\t\t\t\tEmitTextureCoordinates(w->points[j], face->d_texture, face);\n\t\t\t\t\t\t//make a triangle face\n\t\t\t\t\t\tnewface = Face_Clone(face);\n\t\t\t\t\t\t//get the original\n\t\t\t\t\t\tfor (f = face; f->original; f = f->original) ;\n\t\t\t\t\t\tnewface->original = f;\n\t\t\t\t\t\t//store the new winding\n\t\t\t\t\t\tif (newface->face_winding) Winding_Free(newface->face_winding);\n\t\t\t\t\t\tnewface->face_winding = Winding_Clone(&tmpw);\n\t\t\t\t\t\t//get the texture\n\t\t\t\t\t\tnewface->d_texture = Texture_ForName( newface->texdef.name );\n\t\t\t\t\t\t//add the face to the brush\n\t\t\t\t\t\tnewface->next = b->brush_faces;\n\t\t\t\t\t\tb->brush_faces = newface;\n\t\t\t\t\t\t//\n\t\t\t\t\t\tmovefacepoints[nummovefaces] = 1;\n\t\t\t\t\t\tmovefaces[nummovefaces++] = newface;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t//now movefaces contains pointers to triangle faces that\n\t\t//contain the to be moved vertex\n\t\t//\n\t\tdone = true;\n\t\tVectorCopy(end, mid);\n\t\tsmallestfrac = 1;\n\t\tfor (face = b->brush_faces; face; face = face->next)\n\t\t{\n\t\t\t//check if there is a move face that has this face as the original\n\t\t\tfor (i = 0; i < nummovefaces; i++)\n\t\t\t{\n\t\t\t\tif (movefaces[i]->original == face) break;\n\t\t\t}\n\t\t\tif (i >= nummovefaces) continue;\n\t\t\t//check if the original is not a move face itself\n\t\t\tfor (j = 0; j < nummovefaces; j++)\n\t\t\t{\n\t\t\t\tif (face == movefaces[j]) break;\n\t\t\t}\n\t\t\t//if the original is not a move face itself\n\t\t\tif (j >= nummovefaces)\n\t\t\t{\n\t\t\t\tmemcpy(&plane, &movefaces[i]->original->plane, sizeof(plane_t));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tk = movefacepoints[j];\n\t\t\t\tw = movefaces[j]->face_winding;\n\t\t\t\tVectorCopy(w->points[(k+1)%w->numpoints], tmpw.points[0]);\n\t\t\t\tVectorCopy(w->points[(k+2)%w->numpoints], tmpw.points[1]);\n\t\t\t\t//\n\t\t\t\tk = movefacepoints[i];\n\t\t\t\tw = movefaces[i]->face_winding;\n\t\t\t\tVectorCopy(w->points[(k+1)%w->numpoints], tmpw.points[2]);\n\t\t\t\tif (!Plane_FromPoints(tmpw.points[0], tmpw.points[1], tmpw.points[2], &plane))\n\t\t\t\t{\n\t\t\t\t\tVectorCopy(w->points[(k+2)%w->numpoints], tmpw.points[2]);\n\t\t\t\t\tif (!Plane_FromPoints(tmpw.points[0], tmpw.points[1], tmpw.points[2], &plane))\n\t\t\t\t\t\t//this should never happen otherwise the face merge did a crappy job a previous pass\n\t\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\t//now we've got the plane to check agains\n\t\t\tfront = DotProduct(start, plane.normal) - plane.dist;\n\t\t\tback = DotProduct(end, plane.normal) - plane.dist;\n\t\t\t//if the whole move is at one side of the plane\n\t\t\tif (front < 0.01 && back < 0.01) continue;\n\t\t\tif (front > -0.01 && back > -0.01) continue;\n\t\t\t//if there's no movement orthogonal to this plane at all\n\t\t\tif (fabs(front-back) < 0.001) continue;\n\t\t\t//ok first only move till the plane is hit\n\t\t\tfrac = front/(front-back);\n\t\t\tif (frac < smallestfrac)\n\t\t\t{\n\t\t\t\tmid[0] = start[0] + (end[0] - start[0]) * frac;\n\t\t\t\tmid[1] = start[1] + (end[1] - start[1]) * frac;\n\t\t\t\tmid[2] = start[2] + (end[2] - start[2]) * frac;\n\t\t\t\tsmallestfrac = frac;\n\t\t\t}\n\t\t\t//\n\t\t\tdone = false;\n\t\t}\n\n\t\t//move the vertex\n\t\tfor (i = 0; i < nummovefaces; i++)\n\t\t{\n\t\t\t//move vertex to end position\n\t\t\tVectorCopy(mid, movefaces[i]->face_winding->points[movefacepoints[i]]);\n\t\t\t//create new face plane\n\t\t\tfor (j = 0; j < 3; j++)\n\t\t\t{\n\t\t\t\tVectorCopy(movefaces[i]->face_winding->points[j], movefaces[i]->planepts[j]);\n\t\t\t}\n\t\t\tFace_MakePlane(movefaces[i]);\n\t\t\tif (VectorLength(movefaces[i]->plane.normal) < 0.1)\n\t\t\t\tresult = false;\n\t\t}\n\t\t//if the brush is no longer convex\n\t\tif (!result || !Brush_Convex(b))\n\t\t{\n\t\t\tfor (i = 0; i < nummovefaces; i++)\n\t\t\t{\n\t\t\t\t//move the vertex back to the initial position\n\t\t\t\tVectorCopy(start, movefaces[i]->face_winding->points[movefacepoints[i]]);\n\t\t\t\t//create new face plane\n\t\t\t\tfor (j = 0; j < 3; j++)\n\t\t\t\t{\n\t\t\t\t\tVectorCopy(movefaces[i]->face_winding->points[j], movefaces[i]->planepts[j]);\n\t\t\t\t}\n\t\t\t\tFace_MakePlane(movefaces[i]);\n\t\t\t}\n\t\t\tresult = false;\n\t\t\tVectorCopy(start, end);\n\t\t\tdone = true;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVectorCopy(mid, start);\n\t\t}\n\t\t//get texture crap right\n\t\tfor (i = 0; i < nummovefaces; i++)\n\t\t{\n\t\t\tFace_SetColor(b, movefaces[i], 1.0);\n\t\t\tfor (j = 0; j < movefaces[i]->face_winding->numpoints; j++)\n\t\t\t\tEmitTextureCoordinates(movefaces[i]->face_winding->points[j], movefaces[i]->d_texture, movefaces[i]);\n\t\t}\n\n\t\t//now try to merge faces with their original faces\n\t\tlastface = NULL;\n\t\tfor (face = b->brush_faces; face; face = nextface)\n\t\t{\n\t\t\tnextface = face->next;\n\t\t\tif (!face->original)\n\t\t\t{\n\t\t\t\tlastface = face;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!Plane_Equal(&face->plane, &face->original->plane, false))\n\t\t\t{\n\t\t\t\tlastface = face;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tw = Winding_TryMerge(face->face_winding, face->original->face_winding, face->plane.normal, true);\n\t\t\tif (!w)\n\t\t\t{\n\t\t\t\tlastface = face;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tWinding_Free(face->original->face_winding);\n\t\t\tface->original->face_winding = w;\n\t\t\t//get texture crap right\n\t\t\tFace_SetColor(b, face->original, 1.0);\n\t\t\tfor (j = 0; j < face->original->face_winding->numpoints; j++)\n\t\t\t\tEmitTextureCoordinates(face->original->face_winding->points[j], face->original->d_texture, face->original);\n\t\t\t//remove the face that was merged with the original\n\t\t\tif (lastface) lastface->next = face->next;\n\t\t\telse b->brush_faces = face->next;\n\t\t\tFace_Free(face);\n\t\t}\n\t}\n\treturn result;\n}\n\n/*\n=================\nBrush_InsertVertexBetween\n=================\n*/\nint Brush_InsertVertexBetween(brush_t *b, vec3_t p1, vec3_t p2)\n{\n\tface_t *face;\n\twinding_t *w, *neww;\n\tvec3_t point;\n\tint i, insert;\n\n\tif (Point_Equal(p1, p2, 0.4))\n\t\treturn false;\n\tVectorAdd(p1, p2, point);\n\tVectorScale(point, 0.5, point);\n\tinsert = false;\n\t//the end point may not be the same as another vertex\n\tfor (face = b->brush_faces; face; face = face->next)\n\t{\n\t\tw = face->face_winding;\n\t\tif (!w) continue;\n\t\tneww = NULL;\n\t\tfor (i = 0; i < w->numpoints; i++)\n\t\t{\n\t\t\tif (!Point_Equal(w->points[i], p1, 0.1))\n\t\t\t\tcontinue;\n\t\t\tif (Point_Equal(w->points[(i+1) % w->numpoints], p2, 0.1))\n\t\t\t{\n\t\t\t\tneww = Winding_InsertPoint(w, point, (i+1) % w->numpoints);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (Point_Equal(w->points[(i-1+w->numpoints) % w->numpoints], p2, 0.3))\n\t\t\t{\n\t\t\t\tneww = Winding_InsertPoint(w, point, i);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (neww)\n\t\t{\n\t\t\tWinding_Free(face->face_winding);\n\t\t\tface->face_winding = neww;\n\t\t\tinsert = true;\n\t\t}\n\t}\n\treturn insert;\n}\n\n\n/*\n=================\nBrush_ResetFaceOriginals\n=================\n*/\nvoid Brush_ResetFaceOriginals(brush_t *b)\n{\n\tface_t *face;\n\n\tfor (face = b->brush_faces; face; face = face->next)\n\t{\n\t\tface->original = NULL;\n\t}\n}\n\n/*\n=================\nBrush_Parse\n\nThe brush is NOT linked to any list\n=================\n*/\n//++timo FIXME: when using old brush primitives, the test loop for \"Brush\" and \"patchDef2\" \"patchDef3\" is ran\n// before each face parsing. It works, but it's a performance hit\nbrush_t *Brush_Parse (void)\n{\n\tbrush_t\t\t*b;\n\tface_t\t\t*f;\n\tint\t\t\ti,j;\n\t\n\tg_qeglobals.d_parsed_brushes++;\n\tb = Brush_Alloc();\n\n\tdo\n\t{\n\t\tif (!GetToken (true))\n\t\t\tbreak;\n\t\tif (!strcmp (token, \"}\") )\n\t\t\tbreak;\n\t\t\n\t\t// handle \"Brush\" primitive\n\t\tif (strcmpi(token, \"brushDef\") == 0)\n\t\t{\n\t\t\t// Timo parsing new brush format\n\t\t\tg_qeglobals.bPrimitBrushes=true;\n\t\t\t// check the map is not mixing the two kinds of brushes\n\t\t\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\t\t{\n\t\t\t\tif (g_qeglobals.bOldBrushes)\n\t\t\t\t\tSys_Printf(\"Warning : old brushes and brush primitive in the same file are not allowed ( Brush_Parse )\\n\");\n\t\t\t}\n\t\t\t//++Timo write new brush primitive -> old conversion code for Q3->Q2 conversions ?\n\t\t\telse\n\t\t\t\tSys_Printf(\"Warning : conversion code from brush primitive not done ( Brush_Parse )\\n\");\n\t\t\t\n\t\t\tBrushPrimit_Parse(b);\n\t\t\tif (b == NULL)\n\t\t\t{\n\t\t\t\tWarning (\"parsing brush primitive\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n        \t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tif ( strcmpi( token, \"terrainDef\" ) == 0 )\n\t\t{\n\t\t\tfree (b);\n\n\t\t\tb = Terrain_Parse();\n\t\t\tif (b == NULL)\n\t\t\t{\n\t\t\t\tWarning (\"parsing terrain/brush\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tif (strcmpi(token, \"patchDef2\") == 0 || strcmpi(token, \"patchDef3\") == 0)\n\t\t{\n\t\t\tfree (b);\n\t\t\t\n\t\t\t// double string compare but will go away soon\n\t\t\tb = Patch_Parse(strcmpi(token, \"patchDef2\") == 0);\n\t\t\tif (b == NULL)\n\t\t\t{\n\t\t\t\tWarning (\"parsing patch/brush\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// handle inline patch\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// Timo parsing old brush format\n\t\t\tg_qeglobals.bOldBrushes=true;\n\t\t\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\t\t{\n\t\t\t\t// check the map is not mixing the two kinds of brushes\n\t\t\t\tif (g_qeglobals.bPrimitBrushes)\n\t\t\t\t\tSys_Printf(\"Warning : old brushes and brush primitive in the same file are not allowed ( Brush_Parse )\\n\");\n\t\t\t\t// set the \"need\" conversion flag\n\t\t\t\tg_qeglobals.bNeedConvert=true;\n\t\t\t}\n\t\t\t\n\t\t\tf = Face_Alloc();\n\t\t\t\n\t\t\t// add the brush to the end of the chain, so\n\t\t\t// loading and saving a map doesn't reverse the order\n\t\t\t\n\t\t\tf->next = NULL;\n\t\t\tif (!b->brush_faces)\n\t\t\t{\n\t\t\t\tb->brush_faces = f;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tface_t *scan;\n\t\t\t\tfor (scan=b->brush_faces ; scan->next ; scan=scan->next)\n\t\t\t\t\t;\n\t\t\t\tscan->next = f;\n\t\t\t}\n\t\t\t\n\t\t\t// read the three point plane definition\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t{\n\t\t\t\tif (i != 0)\n\t\t\t\t\tGetToken (true);\n\t\t\t\tif (strcmp (token, \"(\") )\n\t\t\t\t{\n\t\t\t\t\tWarning (\"parsing brush\");\n\t\t\t\t\treturn NULL;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tfor (j=0 ; j<3 ; j++)\n\t\t\t\t{\n\t\t\t\t\tGetToken (false);\n\t\t\t\t\tf->planepts[i][j] = atof(token);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tGetToken (false);\n\t\t\t\tif (strcmp (token, \")\") )\n\t\t\t\t{\n\t\t\t\t\tWarning (\"parsing brush\");\n\t\t\t\t\treturn NULL;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Timo\n\t\t// if we have a surface plugin, we'll call the plugin parsing\n\t\tif (g_qeglobals.bSurfacePropertiesPlugin)\n\t\t{\n\t\t\tGETPLUGINTEXDEF(f)->ParseTexdef();\n\t\t}\n\t\telse\n\t\t{\n\t\t\t\n\t\t\t// read the texturedef\n\t\t\tGetToken (false);\n\t\t\tf->texdef.SetName(token);\n\t\t\tif (token[0] == '(')\n\t\t\t{\n\t\t\t\tint i = 32;\n\t\t\t}\n\t\t\tGetToken (false);\n\t\t\tf->texdef.shift[0] = atoi(token);\n\t\t\tGetToken (false);\n\t\t\tf->texdef.shift[1] = atoi(token);\n\t\t\tGetToken (false);\n\t\t\tf->texdef.rotate = atoi(token);\t\n\t\t\tGetToken (false);\n\t\t\tf->texdef.scale[0] = atof(token);\n\t\t\tGetToken (false);\n\t\t\tf->texdef.scale[1] = atof(token);\n\t\t\t\t\t\t\n\t\t\t// the flags and value field aren't necessarily present\n\t\t\tf->d_texture = Texture_ForName( f->texdef.name );\n\t\t\tf->texdef.flags = f->d_texture->flags;\n\t\t\tf->texdef.value = f->d_texture->value;\n\t\t\tf->texdef.contents = f->d_texture->contents;\n\t\t\t\n\t\t\tif (TokenAvailable ())\n\t\t\t{\n\t\t\t\tGetToken (false);\n\t\t\t\tf->texdef.contents = atoi(token);\n\t\t\t\tGetToken (false);\n\t\t\t\tf->texdef.flags = atoi(token);\n\t\t\t\tGetToken (false);\n\t\t\t\tf->texdef.value = atoi(token);\n\t\t\t}\n\t\t\t\n\t\t}\n\t} while (1);\n\t\n\treturn b;\n}\n\n/*\n=================\nQERApp_MapPrintf_FILE\ncallback for surface properties plugin\nmust fit a PFN_QERAPP_MAPPRINTF ( see isurfaceplugin.h )\n=================\n*/\n// carefully initialize !\nFILE * g_File;\nvoid WINAPI QERApp_MapPrintf_FILE( char *text, ... )\n{\n\tva_list argptr;\n\tchar\tbuf[32768];\n\n\tva_start (argptr,text);\n\tvsprintf (buf, text,argptr);\n\tva_end (argptr);\n\n\tfprintf( g_File, buf );\n}\n\n\n/*\n==============\nBrush_SetEpair\nsets an epair for the given brush\n==============\n*/\nvoid Brush_SetEpair(brush_t *b, const char *pKey, const char *pValue)\n{\n\tif (g_qeglobals.m_bBrushPrimitMode)\n\t{\n    if (b->patchBrush)\n    {\n      Patch_SetEpair(b->pPatch, pKey, pValue);\n    }\n    else if (b->terrainBrush)\n    {\n      Terrain_SetEpair(b->pTerrain, pKey, pValue);\n    }\n    else\n    {\n\t\t  SetKeyValue(b->epairs, pKey, pValue);\n    }\n\t}\n\telse\n\t{\n\t\tSys_Printf(\"Can only set key/values in Brush primitive mode\\n\");\n\t}\n}\n\n/* \n=================\nBrush_GetKeyValue\n=================\n*/\nconst char* Brush_GetKeyValue(brush_t *b, const char *pKey)\n{\n\tif (g_qeglobals.m_bBrushPrimitMode)\n\t{\n    if (b->patchBrush)\n    {\n      return Patch_GetKeyValue(b->pPatch, pKey);\n    }\n    else if (b->terrainBrush)\n    {\n      return Terrain_GetKeyValue(b->pTerrain, pKey);\n    }\n    else\n    {\n\t\t  return ValueForKey(b->epairs, pKey);\n    }\n\t}\n\telse\n\t{\n\t\tSys_Printf(\"Can only set brush/patch key/values in Brush primitive mode\\n\");\n\t}\n  return \"\";\n}\n\n/*\n=================\nBrush_Write\nsave all brushes as Brush primitive format\n=================\n*/\nvoid Brush_Write (brush_t *b, FILE *f)\n{\n\tepair_t\t*ep;\n\tface_t\t*fa;\n\tchar\t*pname;\n\tint\t\ti;\n\t\n\tif (b->patchBrush)\n\t{\n\t\tPatch_Write(b->pPatch, f);\n\t\treturn;\n\t}\n\tif ( b->pTerrain )\n\t{\n\t\tTerrain_Write(b->pTerrain, f);\n\t\treturn;\n\t}\n\tif (g_qeglobals.m_bBrushPrimitMode)\n\t{\n\t\t// save brush primitive format\n\t\tfprintf (f, \"{\\nbrushDef\\n{\\n\");\n\t\t// brush epairs\n\t\tif (b->epairs)\n\t\t\tfor (ep = b->epairs ; ep ; ep=ep->next)\n\t\t\t\tfprintf (f, \"\\\"%s\\\" \\\"%s\\\"\\n\", ep->key, ep->value);\n\t\tfor (fa=b->brush_faces ; fa ; fa=fa->next)\n\t\t{\n\t\t\t// save planepts\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t{\n\t\t\t\tfprintf(f, \"( \");\n\t\t\t\tfor (int j = 0; j < 3; j++)\n\t\t\t\t\tif (fa->planepts[i][j] == static_cast<int>(fa->planepts[i][j]))\n\t\t\t\t\t\tfprintf(f, \"%i \", static_cast<int>(fa->planepts[i][j]));\n\t\t\t\t\telse\n\t\t\t\t\t\tfprintf(f, \"%f \", fa->planepts[i][j]);\n\t\t\t\tfprintf(f, \") \");\n\t\t\t}\n\t\t\t// save texture coordinates\n\t\t\tfprintf(f,\"( ( \");\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t\tif (fa->brushprimit_texdef.coords[0][i] == static_cast<int>(fa->brushprimit_texdef.coords[0][i]))\n\t\t\t\t\tfprintf(f,\"%i \",static_cast<int>(fa->brushprimit_texdef.coords[0][i]));\n\t\t\t\telse\n\t\t\t\t\tfprintf(f,\"%f \",fa->brushprimit_texdef.coords[0][i]);\n\t\t\tfprintf(f,\") ( \");\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t\tif (fa->brushprimit_texdef.coords[1][i] == static_cast<int>(fa->brushprimit_texdef.coords[1][i]))\n\t\t\t\t\tfprintf(f,\"%i \",static_cast<int>(fa->brushprimit_texdef.coords[1][i]));\n\t\t\t\telse\n\t\t\t\t\tfprintf(f,\"%f \",fa->brushprimit_texdef.coords[1][i]);\n\t\t\tfprintf(f,\") ) \");\n\t\t\t// save texture attribs\n\t\t\t//++timo surface properties plugin not implemented for brush primitives\n\t\t\tif (g_qeglobals.bSurfacePropertiesPlugin)\n\t\t\t\tSys_Printf(\"WARNING: surface properties plugin not supported with brush primitives (yet)\\n\");\n\n      char *pName = strlen(fa->texdef.name) > 0 ? fa->texdef.name : \"unnamed\";\n\t\t\tfprintf(f, \"%s \", pName );\n\t\t\tfprintf(f, \"%i %i %i\\n\", fa->texdef.contents, fa->texdef.flags, fa->texdef.value);\n\t\t}\n\t\tfprintf (f, \"}\\n}\\n\");\n\t}\n\telse\n\t{\n\t\tfprintf (f, \"{\\n\");\n\t\tfor (fa=b->brush_faces ; fa ; fa=fa->next)\n\t\t{\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t{\n\t\t\t\tfprintf(f, \"( \");\n\t\t\t\tfor (int j = 0; j < 3; j++)\n\t\t\t\t{\n\t\t\t\t\tif (fa->planepts[i][j] == static_cast<int>(fa->planepts[i][j]))\n\t\t\t\t\t\tfprintf(f, \"%i \", static_cast<int>(fa->planepts[i][j]));\n\t\t\t\t\telse\n\t\t\t\t\t\tfprintf(f, \"%f \", fa->planepts[i][j]);\n\t\t\t\t}\n\t\t\t\tfprintf(f, \") \");\n\t\t\t}\n\t\t\t\n\t\t\tif (g_qeglobals.bSurfacePropertiesPlugin)\n\t\t\t{\n\t\t\t\tg_File = f;\n#ifdef _DEBUG\n\t\t\t\tif (!fa->pData)\n\t\t\t\t\tSys_Printf(\"ERROR: unexpected IPluginTexdef* is NULL in Brush_Write\\n\");\n\t\t\t\telse\n#endif\n\t\t\t\tGETPLUGINTEXDEF(fa)->WriteTexdef( QERApp_MapPrintf_FILE );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tpname = fa->texdef.name;\n\t\t\t\tif (pname[0] == 0)\n\t\t\t\t\tpname = \"unnamed\";\n\t\t\t\t\n\t\t\t\tfprintf (f, \"%s %i %i %i \", pname,\n\t\t\t\t\t(int)fa->texdef.shift[0], (int)fa->texdef.shift[1],\n\t\t\t\t\t(int)fa->texdef.rotate);\n\t\t\t\t\n\t\t\t\tif (fa->texdef.scale[0] == (int)fa->texdef.scale[0])\n\t\t\t\t\tfprintf (f, \"%i \", (int)fa->texdef.scale[0]);\n\t\t\t\telse\n\t\t\t\t\tfprintf (f, \"%f \", (float)fa->texdef.scale[0]);\n\t\t\t\tif (fa->texdef.scale[1] == (int)fa->texdef.scale[1])\n\t\t\t\t\tfprintf (f, \"%i\", (int)fa->texdef.scale[1]);\n\t\t\t\telse\n\t\t\t\t\tfprintf (f, \"%f\", (float)fa->texdef.scale[1]);\n\t\t\t\t\n\t\t\t\tfprintf (f, \" %i %i %i\", fa->texdef.contents, fa->texdef.flags, fa->texdef.value);\n\t\t\t}\n\t\t\tfprintf (f, \"\\n\");\n\t\t}\n\t\tfprintf (f, \"}\\n\");\n\t}\n}\n\n/*\n=================\nQERApp_MapPrintf_MEMFILE\ncallback for surface properties plugin\nmust fit a PFN_QERAPP_MAPPRINTF ( see isurfaceplugin.h )\n=================\n*/\n// carefully initialize !\nCMemFile * g_pMemFile;\nvoid WINAPI QERApp_MapPrintf_MEMFILE( char *text, ... )\n{\n\tva_list argptr;\n\tchar\tbuf[32768];\n\n\tva_start (argptr,text);\n\tvsprintf (buf, text,argptr);\n\tva_end (argptr);\n\n\tMemFile_fprintf( g_pMemFile, buf );\n}\n\n/*\n=================\nBrush_Write to a CMemFile*\nsave all brushes as Brush primitive format\n=================\n*/\nvoid Brush_Write (brush_t *b, CMemFile *pMemFile)\n{\n\tepair_t *ep;\n\tface_t\t*fa;\n\tchar *pname;\n\tint\t\ti;\n\t\n\tif (b->patchBrush)\n\t{\n\t\tPatch_Write(b->pPatch, pMemFile);\n\t\treturn;\n\t}\n\tif (b->terrainBrush)\n\t{\n\t\tTerrain_Write(b->pTerrain, pMemFile);\n\t\treturn;\n\t}\n\t//++timo NOTE: it's not very difficult to add since the surface properties plugin\n\t// writes throught a printf-style function prototype\n\tif (g_qeglobals.bSurfacePropertiesPlugin)\n\t{\n\t\tSys_Printf(\"WARNING: Brush_Write to a CMemFile and Surface Properties plugin not done\\n\");\n\t}\n\tif (g_qeglobals.m_bBrushPrimitMode)\n\t{\n\t\t// brush primitive format\n\t\tMemFile_fprintf (pMemFile, \"{\\nBrushDef\\n{\\n\");\n\t\t// brush epairs\n\t\tif (b->epairs)\n\t\t\tfor( ep = b->epairs ; ep ; ep=ep->next )\n\t\t\t\tMemFile_fprintf (pMemFile, \"\\\"%s\\\" \\\"%s\\\"\\n\", ep->key, ep->value );\n\t\tfor (fa=b->brush_faces ; fa ; fa=fa->next)\n\t\t{\n\t\t\t// save planepts\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t{\n\t\t\t\tMemFile_fprintf(pMemFile, \"( \");\n\t\t\t\tfor (int j = 0; j < 3; j++)\n\t\t\t\t\tif (fa->planepts[i][j] == static_cast<int>(fa->planepts[i][j]))\n\t\t\t\t\t\tMemFile_fprintf(pMemFile, \"%i \", static_cast<int>(fa->planepts[i][j]));\n\t\t\t\t\telse\n\t\t\t\t\t\tMemFile_fprintf(pMemFile, \"%f \", fa->planepts[i][j]);\n\t\t\t\tMemFile_fprintf(pMemFile, \") \");\n\t\t\t}\n\t\t\t// save texture coordinates\n\t\t\tMemFile_fprintf(pMemFile,\"( ( \");\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t\tif (fa->brushprimit_texdef.coords[0][i] == static_cast<int>(fa->brushprimit_texdef.coords[0][i]))\n\t\t\t\t\tMemFile_fprintf(pMemFile,\"%i \",static_cast<int>(fa->brushprimit_texdef.coords[0][i]));\n\t\t\t\telse\n\t\t\t\t\tMemFile_fprintf(pMemFile,\"%f \",fa->brushprimit_texdef.coords[0][i]);\n\t\t\tMemFile_fprintf(pMemFile,\") ( \");\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t\tif (fa->brushprimit_texdef.coords[1][i] == static_cast<int>(fa->brushprimit_texdef.coords[1][i]))\n\t\t\t\t\tMemFile_fprintf(pMemFile,\"%i \",static_cast<int>(fa->brushprimit_texdef.coords[1][i]));\n\t\t\t\telse\n\t\t\t\t\tMemFile_fprintf(pMemFile,\"%f \",fa->brushprimit_texdef.coords[1][i]);\n\t\t\tMemFile_fprintf(pMemFile,\") ) \");\n\t\t\t// save texture attribs\n      char *pName = strlen(fa->texdef.name) > 0 ? fa->texdef.name : \"unnamed\";\n\t\t\tMemFile_fprintf(pMemFile, \"%s \", pName);\n\t\t\tMemFile_fprintf(pMemFile, \"%i %i %i\\n\", fa->texdef.contents, fa->texdef.flags, fa->texdef.value);\n\t\t}\n\t\tMemFile_fprintf (pMemFile, \"}\\n}\\n\");\n\t}\n\telse\n\t{\n\t\t// old brushes format\n\t\t// also handle surface properties plugin\n\t\tMemFile_fprintf (pMemFile, \"{\\n\");\n\t\tfor (fa=b->brush_faces ; fa ; fa=fa->next)\n\t\t{\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t{\n\t\t\t\tMemFile_fprintf(pMemFile, \"( \");\n\t\t\t\tfor (int j = 0; j < 3; j++)\n\t\t\t\t{\n\t\t\t\t\tif (fa->planepts[i][j] == static_cast<int>(fa->planepts[i][j]))\n\t\t\t\t\t\tMemFile_fprintf(pMemFile, \"%i \", static_cast<int>(fa->planepts[i][j]));\n\t\t\t\t\telse\n\t\t\t\t\t\tMemFile_fprintf(pMemFile, \"%f \", fa->planepts[i][j]);\n\t\t\t\t}\n\t\t\t\tMemFile_fprintf(pMemFile, \") \");\n\t\t\t}\n\t\t\t\n\t\t\tif (g_qeglobals.bSurfacePropertiesPlugin)\n\t\t\t{\n\t\t\t\tg_pMemFile = pMemFile;\n#ifdef _DEBUG\n\t\t\t\tif (!fa->pData)\n\t\t\t\t\tSys_Printf(\"ERROR: unexpected IPluginTexdef* is NULL in Brush_Write\\n\");\n\t\t\t\telse\n#endif\n\t\t\t\tGETPLUGINTEXDEF(fa)->WriteTexdef( QERApp_MapPrintf_MEMFILE );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tpname = fa->texdef.name;\n\t\t\t\tif (pname[0] == 0)\n\t\t\t\t\tpname = \"unnamed\";\n\t\t\t\t\n\t\t\t\tMemFile_fprintf (pMemFile, \"%s %i %i %i \", pname,\n\t\t\t\t\t(int)fa->texdef.shift[0], (int)fa->texdef.shift[1],\n\t\t\t\t\t(int)fa->texdef.rotate);\n\t\t\t\t\n\t\t\t\tif (fa->texdef.scale[0] == (int)fa->texdef.scale[0])\n\t\t\t\t\tMemFile_fprintf (pMemFile, \"%i \", (int)fa->texdef.scale[0]);\n\t\t\t\telse\n\t\t\t\t\tMemFile_fprintf (pMemFile, \"%f \", (float)fa->texdef.scale[0]);\n\t\t\t\tif (fa->texdef.scale[1] == (int)fa->texdef.scale[1])\n\t\t\t\t\tMemFile_fprintf (pMemFile, \"%i\", (int)fa->texdef.scale[1]);\n\t\t\t\telse\n\t\t\t\t\tMemFile_fprintf (pMemFile, \"%f\", (float)fa->texdef.scale[1]);\n\t\t\t\t\n\t\t\t\tMemFile_fprintf (pMemFile, \" %i %i %i\", fa->texdef.contents, fa->texdef.flags, fa->texdef.value);\n\t\t\t}\n\t\t\tMemFile_fprintf (pMemFile, \"\\n\");\n\t\t}\n\t\tMemFile_fprintf (pMemFile, \"}\\n\");\n\t}\n\t\n\t\n}\n\n\n/*\n=============\nBrush_Create\n\nCreate non-textured blocks for entities\nThe brush is NOT linked to any list\n=============\n*/\nbrush_t\t*Brush_Create (vec3_t mins, vec3_t maxs, texdef_t *texdef)\n{\n\tint\t\ti, j;\n\tvec3_t\tpts[4][2];\n\tface_t\t*f;\n\tbrush_t\t*b;\n\n\t// brush primitive mode : convert texdef to brushprimit_texdef ?\n\t// most of the time texdef is empty\n\tif (g_qeglobals.m_bBrushPrimitMode)\n\t{\n\t\t// check texdef is empty .. if there are cases it's not we need to write some conversion code\n\t\tif (texdef->shift[0]!=0 || texdef->shift[1]!=0 || texdef->scale[0]!=0 || texdef->scale[1]!=0 || texdef->rotate!=0)\n\t\t\tSys_Printf(\"Warning : non-zero texdef detected in Brush_Create .. need brush primitive conversion\\n\");\n\t}\n\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tif (maxs[i] < mins[i])\n\t\t\tError (\"Brush_InitSolid: backwards\");\n\t}\n\n\tb = Brush_Alloc();\n\t\n\tpts[0][0][0] = mins[0];\n\tpts[0][0][1] = mins[1];\n\t\n\tpts[1][0][0] = mins[0];\n\tpts[1][0][1] = maxs[1];\n\t\n\tpts[2][0][0] = maxs[0];\n\tpts[2][0][1] = maxs[1];\n\t\n\tpts[3][0][0] = maxs[0];\n\tpts[3][0][1] = mins[1];\n\t\n\tfor (i=0 ; i<4 ; i++)\n\t{\n\t\tpts[i][0][2] = mins[2];\n\t\tpts[i][1][0] = pts[i][0][0];\n\t\tpts[i][1][1] = pts[i][0][1];\n\t\tpts[i][1][2] = maxs[2];\n\t}\n\n\tfor (i=0 ; i<4 ; i++)\n\t{\n\t\tf = Face_Alloc();\n\t\tf->texdef = *texdef;\n\t\tf->texdef.flags &= ~SURF_KEEP;\n\t\tf->texdef.contents &= ~CONTENTS_KEEP;\n\t\tf->next = b->brush_faces;\n\t\tb->brush_faces = f;\n\t\tj = (i+1)%4;\n\n\t\tVectorCopy (pts[j][1], f->planepts[0]);\n\t\tVectorCopy (pts[i][1], f->planepts[1]);\n\t\tVectorCopy (pts[i][0], f->planepts[2]);\n\t}\n\t\n\tf = Face_Alloc();\n\tf->texdef = *texdef;\n\tf->texdef.flags &= ~SURF_KEEP;\n\tf->texdef.contents &= ~CONTENTS_KEEP;\n\tf->next = b->brush_faces;\n\tb->brush_faces = f;\n\n\tVectorCopy (pts[0][1], f->planepts[0]);\n\tVectorCopy (pts[1][1], f->planepts[1]);\n\tVectorCopy (pts[2][1], f->planepts[2]);\n\n\tf = Face_Alloc();\n\tf->texdef = *texdef;\n\tf->texdef.flags &= ~SURF_KEEP;\n\tf->texdef.contents &= ~CONTENTS_KEEP;\n\tf->next = b->brush_faces;\n\tb->brush_faces = f;\n\n\tVectorCopy (pts[2][0], f->planepts[0]);\n\tVectorCopy (pts[1][0], f->planepts[1]);\n\tVectorCopy (pts[0][0], f->planepts[2]);\n\n\treturn b;\n}\n\n/*\n=============\nBrush_CreatePyramid\n\nCreate non-textured pyramid for light entities\nThe brush is NOT linked to any list\n=============\n*/\nbrush_t\t*Brush_CreatePyramid (vec3_t mins, vec3_t maxs, texdef_t *texdef)\n{\n\t//++timo handle new brush primitive ? return here ??\n\treturn Brush_Create(mins, maxs, texdef);\n\n\tfor (int i=0 ; i<3 ; i++)\n\t\tif (maxs[i] < mins[i])\n\t\t\tError (\"Brush_InitSolid: backwards\");\n\n\tbrush_t* b = Brush_Alloc();\n\n\tvec3_t corners[4];\n\n\tfloat fMid = Q_rint(mins[2] + (Q_rint((maxs[2] - mins[2]) / 2)));\n\n\tcorners[0][0] = mins[0];\n\tcorners[0][1] = mins[1];\n\tcorners[0][2] = fMid;\n\n\tcorners[1][0] = mins[0];\n\tcorners[1][1] = maxs[1];\n\tcorners[1][2] = fMid;\n\n\tcorners[2][0] = maxs[0];\n\tcorners[2][1] = maxs[1];\n\tcorners[2][2] = fMid;\n\n\tcorners[3][0] = maxs[0];\n\tcorners[3][1] = mins[1];\n\tcorners[3][2] = fMid;\n\n\tvec3_t top, bottom;\n\n\ttop[0] = Q_rint(mins[0] + ((maxs[0] - mins[0]) / 2));\n\ttop[1] = Q_rint(mins[1] + ((maxs[1] - mins[1]) / 2));\n\ttop[2] = Q_rint(maxs[2]);\n\n\tVectorCopy(top, bottom);\n\tbottom[2] = mins[2];\n\n\t// sides\n\tfor (i = 0; i < 4; i++)\n\t{\n\t\tface_t* f = Face_Alloc();\n\t\tf->texdef = *texdef;\n\t\tf->texdef.flags &= ~SURF_KEEP;\n\t\tf->texdef.contents &= ~CONTENTS_KEEP;\n\t\tf->next = b->brush_faces;\n\t\tb->brush_faces = f;\n\t\tint j = (i+1)%4;\n\n\t\tVectorCopy (top, f->planepts[0]);\n\t\tVectorCopy (corners[i], f->planepts[1]);\n\t\tVectorCopy(corners[j], f->planepts[2]);\n\n\t\tf = Face_Alloc();\n\t\tf->texdef = *texdef;\n\t\tf->texdef.flags &= ~SURF_KEEP;\n\t\tf->texdef.contents &= ~CONTENTS_KEEP;\n\t\tf->next = b->brush_faces;\n\t\tb->brush_faces = f;\n\n\t\tVectorCopy (bottom, f->planepts[2]);\n\t\tVectorCopy (corners[i], f->planepts[1]);\n\t\tVectorCopy(corners[j], f->planepts[0]);\n\t}\n\n\treturn b;\n}\n\n\n\n\n/*\n=============\nBrush_MakeSided\n\nMakes the current brush have the given number of 2d sides\n=============\n*/\nvoid Brush_MakeSided (int sides)\n{\n\tint\t\ti, axis;\n\tvec3_t\tmins, maxs;\n\tbrush_t\t*b;\n\ttexdef_t\t*texdef;\n\tface_t\t*f;\n\tvec3_t\tmid;\n\tfloat\twidth;\n\tfloat\tsv, cv;\n\n\tif (sides < 3)\n\t{\n\t\tSys_Status (\"Bad sides number\", 0);\n\t\treturn;\n\t}\n\n\tif (sides >= MAX_POINTS_ON_WINDING-4)\n\t{\n\t\tSys_Printf(\"too many sides.\\n\");\n\t\treturn;\n\t}\n\n\tif (!QE_SingleBrush ())\n\t{\n\t\tSys_Status (\"Must have a single brush selected\", 0 );\n\t\treturn;\n\t}\n\n\tb = selected_brushes.next;\n\tVectorCopy (b->mins, mins);\n\tVectorCopy (b->maxs, maxs);\n\ttexdef = &g_qeglobals.d_texturewin.texdef;\n\n\tBrush_Free (b);\n\n\tif (g_pParentWnd->ActiveXY())\n\t{\n\t\tswitch(g_pParentWnd->ActiveXY()->GetViewType())\n\t\t{\n\t\t\tcase XY: axis = 2; break;\n\t\t\tcase XZ: axis = 1; break;\n\t\t\tcase YZ: axis = 0; break;\n\t\t}\n\t}\n\telse\n\t{\n\t\taxis = 2;\n\t}\n\n\t// find center of brush\n\twidth = 8;\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tmid[i] = (maxs[i] + mins[i]) * 0.5;\n\t\tif (i == axis) continue;\n\t\tif ((maxs[i] - mins[i]) * 0.5 > width)\n\t\t\twidth = (maxs[i] - mins[i]) * 0.5;\n\t}\n\n\tb = Brush_Alloc();\n\t\t\n\t// create top face\n\tf = Face_Alloc();\n\tf->texdef = *texdef;\n\tf->next = b->brush_faces;\n\tb->brush_faces = f;\n\n\tf->planepts[2][(axis+1)%3] = mins[(axis+1)%3]; f->planepts[2][(axis+2)%3] = mins[(axis+2)%3]; f->planepts[2][axis] = maxs[axis];\n\tf->planepts[1][(axis+1)%3] = maxs[(axis+1)%3]; f->planepts[1][(axis+2)%3] = mins[(axis+2)%3]; f->planepts[1][axis] = maxs[axis];\n\tf->planepts[0][(axis+1)%3] = maxs[(axis+1)%3]; f->planepts[0][(axis+2)%3] = maxs[(axis+2)%3]; f->planepts[0][axis] = maxs[axis];\n\n\t// create bottom face\n\tf = Face_Alloc();\n\tf->texdef = *texdef;\n\tf->next = b->brush_faces;\n\tb->brush_faces = f;\n\n\tf->planepts[0][(axis+1)%3] = mins[(axis+1)%3]; f->planepts[0][(axis+2)%3] = mins[(axis+2)%3]; f->planepts[0][axis] = mins[axis];\n\tf->planepts[1][(axis+1)%3] = maxs[(axis+1)%3]; f->planepts[1][(axis+2)%3] = mins[(axis+2)%3]; f->planepts[1][axis] = mins[axis];\n\tf->planepts[2][(axis+1)%3] = maxs[(axis+1)%3]; f->planepts[2][(axis+2)%3] = maxs[(axis+2)%3]; f->planepts[2][axis] = mins[axis];\n\n\tfor (i=0 ; i<sides ; i++)\n\t{\n\t\tf = Face_Alloc();\n\t\tf->texdef = *texdef;\n\t\tf->next = b->brush_faces;\n\t\tb->brush_faces = f;\n\n\t\tsv = sin (i*3.14159265*2/sides);\n\t\tcv = cos (i*3.14159265*2/sides);\n\n\t\tf->planepts[0][(axis+1)%3] = floor(mid[(axis+1)%3]+width*cv+0.5);\n\t\tf->planepts[0][(axis+2)%3] = floor(mid[(axis+2)%3]+width*sv+0.5);\n\t\tf->planepts[0][axis] = mins[axis];\n\n\t\tf->planepts[1][(axis+1)%3] = f->planepts[0][(axis+1)%3];\n\t\tf->planepts[1][(axis+2)%3] = f->planepts[0][(axis+2)%3];\n\t\tf->planepts[1][axis] = maxs[axis];\n\n\t\tf->planepts[2][(axis+1)%3] = floor(f->planepts[0][(axis+1)%3] - width*sv + 0.5);\n\t\tf->planepts[2][(axis+2)%3] = floor(f->planepts[0][(axis+2)%3] + width*cv + 0.5);\n\t\tf->planepts[2][axis] = maxs[axis];\n\t}\n\n\tBrush_AddToList (b, &selected_brushes);\n\n\tEntity_LinkBrush (world_entity, b);\n\n\tBrush_Build( b );\n\n\tSys_UpdateWindows (W_ALL);\n}\n\n\n\n/*\n=============\nBrush_Free\n\nFrees the brush with all of its faces and display list.\nUnlinks the brush from whichever chain it is in.\nDecrements the owner entity's brushcount.\nRemoves owner entity if this was the last brush\nunless owner is the world.\nRemoves from groups\n=============\n*/\nvoid Brush_Free (brush_t *b, bool bRemoveNode)\n{\n\tface_t\t*f, *next;\n\tepair_t\t*ep, *enext;\n\n\t// remove from group\n\tif (bRemoveNode)\n\t\tGroup_RemoveBrush(b);\n\n\t// free the patch if it's there\n\tif (b->patchBrush)\n\t{\n\t\tPatch_Delete(b->pPatch);\n\t}\n\n\tif( b->terrainBrush )\n\t{\n\t\tTerrain_Delete( b->pTerrain );\n\t}\n\n\t// free faces\n\tfor (f=b->brush_faces ; f ; f=next)\n\t{\n\t\tnext = f->next;\n\t\tFace_Free( f );\n\t}\n\n\t//Timo : free brush epairs\n\tfor (ep = b->epairs ; ep ; ep=enext )\n\t{\n\t\tenext = ep->next;\n\t\tfree (ep->key);\n\t\tfree (ep->value);\n\t\tfree (ep);\n\t}\n\n\t// unlink from active/selected list\n\tif (b->next)\n\t\tBrush_RemoveFromList (b);\n\n\t// unlink from entity list\n\tif (b->onext)\n\t\tEntity_UnlinkBrush (b);\n\n\tfree (b);\n}\n\n/*\n=============\nFace_MemorySize\n=============\n*/\nint Face_MemorySize(face_t *f )\n{\n\tint size = 0;\n\n\tif (f->face_winding)\n\t{\n\t\tsize += _msize(f->face_winding);\n\t}\n\t//f->texdef.~texdef_t();;\n\tsize += _msize(f);\n\treturn size;\n}\n\n/*\n=============\nBrush_MemorySize\n=============\n*/\nint Brush_MemorySize(brush_t *b)\n{\n\tface_t\t*f;\n\tepair_t\t*ep;\n\tint size = 0;\n\n\t//\n\tif (b->patchBrush)\n\t{\n\t\tsize += Patch_MemorySize(b->pPatch);\n\t}\n\tif (b->terrainBrush)\n\t{\n\t\tsize += Terrain_MemorySize(b->pTerrain);\n\t}\n\t//\n\tfor (f = b->brush_faces; f; f = f->next)\n\t{\n\t\tsize += Face_MemorySize(f);\n\t}\n\t//\n\tfor (ep = b->epairs; ep; ep = ep->next )\n\t{\n\t\tsize += _msize(ep->key);\n\t\tsize += _msize(ep->value);\n\t\tsize += _msize(ep);\n\t}\n\tsize += _msize(b);\n\treturn size;\n}\n\n\n/*\n============\nBrush_Clone\n\nDoes NOT add the new brush to any lists\n============\n*/\nbrush_t *Brush_Clone (brush_t *b)\n{\n\tbrush_t\t*n = NULL;\n\tface_t\t*f, *nf;\n\n\tif (b->patchBrush)\n\t{\n\t\tpatchMesh_t *p = Patch_Duplicate(b->pPatch);\n\t\tBrush_RemoveFromList(p->pSymbiot);\n\t\tEntity_UnlinkBrush(p->pSymbiot);\n\t\tn = p->pSymbiot;\n\t}\n\telse if (b->terrainBrush)\n\t{\n\t\tterrainMesh_t *p = Terrain_Duplicate(b->pTerrain);\n\t\tBrush_RemoveFromList(p->pSymbiot);\n\t\tEntity_UnlinkBrush(p->pSymbiot);\n\t\tn = p->pSymbiot;\n\t}\n\telse\n\t{\n  \tn = Brush_Alloc();\n\t  n->numberId = g_nBrushId++;\n\t\tn->owner = b->owner;\n\t\tfor (f=b->brush_faces ; f ; f=f->next)\n\t\t{\n\t\t\tnf = Face_Clone( f );\n\t\t\tnf->next = n->brush_faces;\n\t\t\tn->brush_faces = nf;\n\t\t}\n\t}\n\n\treturn n;\n}\n\n\n\n/*\n============\nBrush_Clone\n\nDoes NOT add the new brush to any lists\n============\n*/\nbrush_t *Brush_FullClone(brush_t *b)\n{\n\tbrush_t\t*n = NULL;\n\tface_t *f, *nf, *f2, *nf2;\n\tint j;\n\n\tif (b->patchBrush)\n\t{\n\t\tpatchMesh_t *p = Patch_Duplicate(b->pPatch);\n\t\tBrush_RemoveFromList(p->pSymbiot);\n\t\tEntity_UnlinkBrush(p->pSymbiot);\n\t\tn = p->pSymbiot;\n\t\tn->owner = b->owner;\n\t\tBrush_Build(n);\n\t}\n\telse if (b->terrainBrush)\n\t{\n\t\tterrainMesh_t *p = Terrain_Duplicate(b->pTerrain);\n\t\tBrush_RemoveFromList(p->pSymbiot);\n\t\tEntity_UnlinkBrush(p->pSymbiot);\n\t\tn = p->pSymbiot;\n\t\tn->owner = b->owner;\n\t\tBrush_Build(n);\n\t}\n\telse\n\t{\n  \tn = Brush_Alloc();\n   \tn->numberId = g_nBrushId++;\n\t\tn->owner = b->owner;\n\t\tVectorCopy(b->mins, n->mins);\n\t\tVectorCopy(b->maxs, n->maxs);\n\t\t//\n\t\tfor (f = b->brush_faces; f; f = f->next)\n\t\t{\n\t\t\tif (f->original) continue;\n\t\t\tnf = Face_FullClone(f);\n\t\t\tnf->next = n->brush_faces;\n\t\t\tn->brush_faces = nf;\n\t\t\t//copy all faces that have the original set to this face\n\t\t\tfor (f2 = b->brush_faces; f2; f2 = f2->next)\n\t\t\t{\n\t\t\t\tif (f2->original == f)\n\t\t\t\t{\n\t\t\t\t\tnf2 = Face_FullClone(f2);\n\t\t\t\t\tnf2->next = n->brush_faces;\n\t\t\t\t\tn->brush_faces = nf2;\n\t\t\t\t\t//set original\n\t\t\t\t\tnf2->original = nf;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (nf = n->brush_faces; nf; nf = nf->next)\n\t\t{\n\t\t\tFace_SetColor(n, nf, 1.0);\n\t\t\tif (nf->face_winding)\n      {\n        if (g_qeglobals.m_bBrushPrimitMode)\n    \t\t\tEmitBrushPrimitTextureCoordinates(nf,nf->face_winding);\n        else\n        {\n\t\t\t\t  for (j = 0; j < nf->face_winding->numpoints; j++)\n  \t\t\t\t\tEmitTextureCoordinates(nf->face_winding->points[j], nf->d_texture, nf);\n        }\n      }\n\t\t}\n  }\n\treturn n;\n}\n\n/*\n==============\nBrush_Ray\n\nItersects a ray with a brush\nReturns the face hit and the distance along the ray the intersection occured at\nReturns NULL and 0 if not hit at all\n==============\n*/\nface_t *Brush_Ray (vec3_t origin, vec3_t dir, brush_t *b, float *dist)\n{\n\tface_t\t*f, *firstface;\n\tvec3_t\tp1, p2;\n\tfloat\tfrac, d1, d2;\n\tint\t\ti;\n\n\tVectorCopy (origin, p1);\n\tfor (i=0 ; i<3 ; i++)\n\t\tp2[i] = p1[i] + dir[i]*16384;\n\n\tfor (f=b->brush_faces ; f ; f=f->next)\n\t{\n\t\td1 = DotProduct (p1, f->plane.normal) - f->plane.dist;\n\t\td2 = DotProduct (p2, f->plane.normal) - f->plane.dist;\n\t\tif (d1 >= 0 && d2 >= 0)\n\t\t{\n\t\t\t*dist = 0;\n\t\t\treturn NULL;\t// ray is on front side of face\n\t\t}\n\t\tif (d1 <=0 && d2 <= 0)\n\t\t\tcontinue;\n\t// clip the ray to the plane\n\t\tfrac = d1 / (d1 - d2);\n\t\tif (d1 > 0)\n\t\t{\n\t\t\tfirstface = f;\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t\tp1[i] = p1[i] + frac *(p2[i] - p1[i]);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t\tp2[i] = p1[i] + frac *(p2[i] - p1[i]);\n\t\t}\n\t}\n\n\t// find distance p1 is along dir\n\tVectorSubtract (p1, origin, p1);\n\td1 = DotProduct (p1, dir);\n\n\t*dist = d1;\n\n\treturn firstface;\n}\n\n//PGM\nface_t *Brush_Point (vec3_t origin, brush_t *b)\n{\n\tface_t\t*f;\n\tfloat\td1;\n\n\tfor (f=b->brush_faces ; f ; f=f->next)\n\t{\n\t\td1 = DotProduct (origin, f->plane.normal) - f->plane.dist;\n\t\tif (d1 > 0)\n\t\t{\n\t\t\treturn NULL;\t// point is on front side of face\n\t\t}\n\t}\n\n\treturn b->brush_faces;\n}\n//PGM\n\n\nvoid\tBrush_AddToList (brush_t *b, brush_t *list)\n{\n\tif (b->next || b->prev)\n\t\tError (\"Brush_AddToList: allready linked\");\n\t\n\tif (list == &selected_brushes || list == &active_brushes)\n\t{\n\t\tif (b->patchBrush && list == &selected_brushes)\n\t\t{\n\t\t\tPatch_Select(b->pPatch);\n\t\t}\n\t\tif (b->terrainBrush && list == &selected_brushes) {\n\t\t\tTerrain_Select(b->pTerrain);\n\t\t}\n\t}\n\tb->next = list->next;\n\tlist->next->prev = b;\n\tlist->next = b;\n\tb->prev = list;\n\t\n\t// TTimo messaging\n\tDispatchRadiantMsg( RADIANT_SELECTION );\t\n}\n\nvoid\tBrush_RemoveFromList (brush_t *b)\n{\n\tif (!b->next || !b->prev)\n\t\tError (\"Brush_RemoveFromList: not linked\");\n\t\n\tif (b->patchBrush)\n\t{\n\t\tPatch_Deselect(b->pPatch);\n\t\t//Patch_Deselect(b->nPatchID);\n\t}\n\tif (b->terrainBrush)\n\t{\n\t\tTerrain_Deselect(b->pTerrain);\n\t}\n\n\tb->next->prev = b->prev;\n\tb->prev->next = b->next;\n\tb->next = b->prev = NULL;\n}\n\n/*\n===============\nSetFaceTexdef\n\nDoesn't set the curve flags\n\nNOTE : ( TTimo )\n\tnever trust f->d_texture here, f->texdef and f->d_texture are out of sync when called by Brush_SetTexture\n\tuse Texture_ForName() to find the right shader\n\tFIXME : send the right shader ( qtexture_t * ) in the parameters ?\n\nTTimo: surface plugin, added an IPluginTexdef* parameter\n\t\tif not NULL, get ->Copy() of it into the face ( and remember to hook )\n\t\tif NULL, ask for a default\n===============\n*/\nvoid SetFaceTexdef (brush_t *b, face_t *f, texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale, IPluginTexdef* pPlugTexdef) {\n\tint\t\toldFlags;\n\tint\t\toldContents;\n\tface_t\t*tf;\n\n\toldFlags = f->texdef.flags;\n\toldContents = f->texdef.contents;\n\tif (g_qeglobals.m_bBrushPrimitMode)\n\t{\n\t\tf->texdef = *texdef;\n\t\tConvertTexMatWithQTexture( brushprimit_texdef, NULL, &f->brushprimit_texdef, Texture_ForName( f->texdef.name ) );\n\t}\n\telse\n\t\tif (bFitScale)\n\t\t{\n\t\t\tf->texdef = *texdef;\n\t\t\t// fit the scaling of the texture on the actual plane\n\t\t\tvec3_t p1,p2,p3; // absolute coordinates\n\t\t\t// compute absolute coordinates\n\t\t\tComputeAbsolute(f,p1,p2,p3);\n\t\t\t// compute the scale\n\t\t\tvec3_t vx,vy;\n\t\t\tVectorSubtract(p2,p1,vx);\n\t\t\tVectorNormalize(vx);\n\t\t\tVectorSubtract(p3,p1,vy);\n\t\t\tVectorNormalize(vy);\n\t\t\t// assign scale\n\t\t\tVectorScale(vx,texdef->scale[0],vx);\n\t\t\tVectorScale(vy,texdef->scale[1],vy);\n\t\t\tVectorAdd(p1,vx,p2);\n\t\t\tVectorAdd(p1,vy,p3);\n\t\t\t// compute back shift scale rot\n\t\t\tAbsoluteToLocal(f->plane,f,p1,p2,p3);\n\t\t}\n\t\telse\n\t\t\tf->texdef = *texdef;\n\tf->texdef.flags = (f->texdef.flags & ~SURF_KEEP) | (oldFlags & SURF_KEEP);\n\tf->texdef.contents = (f->texdef.contents & ~CONTENTS_KEEP) | (oldContents & CONTENTS_KEEP);\n\n\t// surface plugin\n\tif (g_qeglobals.bSurfacePropertiesPlugin)\n\t{\n#ifdef _DEBUG\n\t\tif (!f->pData)\n\t\t\tSys_Printf(\"ERROR: unexpected IPluginTexdef* is NULL in SetFaceTexdef\\n\");\n\t\telse\n#endif\n\t\t\tGETPLUGINTEXDEF(f)->DecRef();\n\t\tIPluginTexdef *pTexdef = NULL;\n\t\tif ( pPlugTexdef )\n\t\t{\n\t\t\tpTexdef = pPlugTexdef->Copy();\n\t\t\tpTexdef->Hook( f );\n\t\t}\n\t\telse\n\t\t\tpTexdef = g_SurfaceTable.m_pfnTexdefAlloc( f );\n\t\tf->pData = pTexdef;\n\t}\n\n\t// if this is a curve face, set all other curve faces to the same texdef\n\tif (f->texdef.flags & SURF_CURVE) \n\t{\n\t\tfor (tf = b->brush_faces ; tf ; tf = tf->next) \n\t\t{\n\t\t\tif (tf->texdef.flags & SURF_CURVE) \n\t\t\t\ttf->texdef = f->texdef;\n\t\t}\n\t}\n}\n\n\nvoid Brush_SetTexture (brush_t *b, texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale, IPluginTexdef* pTexdef)\n{\n\tfor (face_t* f = b->brush_faces ; f ; f = f->next) \n\t{\n\t\tSetFaceTexdef (b, f, texdef, brushprimit_texdef, bFitScale, pTexdef);\n\t}\n\tBrush_Build( b );\n\tif (b->patchBrush)\n\t{\n\t\t//++timo clean\n//\t\tSys_Printf(\"WARNING: Brush_SetTexture needs surface plugin code for patches\\n\");\n\t\tPatch_SetTexture(b->pPatch, texdef, pTexdef );\n\t}\n\tif (b->terrainBrush)\n\t{\n\t\tTerrain_SetTexture(b->pTerrain, texdef);\n\t}\n\n}\n\n\nqboolean ClipLineToFace (vec3_t p1, vec3_t p2, face_t *f)\n{\n\tfloat\td1, d2, fr;\n\tint\t\ti;\n\tfloat\t*v;\n\n\td1 = DotProduct (p1, f->plane.normal) - f->plane.dist;\n\td2 = DotProduct (p2, f->plane.normal) - f->plane.dist;\n\n\tif (d1 >= 0 && d2 >= 0)\n\t\treturn false;\t\t// totally outside\n\tif (d1 <= 0 && d2 <= 0)\n\t\treturn true;\t\t// totally inside\n\n\tfr = d1 / (d1 - d2);\n\n\tif (d1 > 0)\n\t\tv = p1;\n\telse\n\t\tv = p2;\n\n\tfor (i=0 ; i<3 ; i++)\n\t\tv[i] = p1[i] + fr*(p2[i] - p1[i]);\n\n\treturn true;\n}\n\n\nint AddPlanept (float *f)\n{\n\tint\t\ti;\n\n\tfor (i=0 ; i<g_qeglobals.d_num_move_points ; i++)\n\t\tif (g_qeglobals.d_move_points[i] == f)\n\t\t\treturn 0;\n\tg_qeglobals.d_move_points[g_qeglobals.d_num_move_points++] = f;\n\treturn 1;\n}\n\n/*\n==============\nBrush_SelectFaceForDragging\n\nAdds the faces planepts to move_points, and\nrotates and adds the planepts of adjacent face if shear is set\n==============\n*/\nvoid Brush_SelectFaceForDragging (brush_t *b, face_t *f, qboolean shear)\n{\n\tint\t\ti;\n\tface_t\t*f2;\n\twinding_t\t*w;\n\tfloat\td;\n\tbrush_t\t*b2;\n\tint\t\tc;\n\n\tif (b->owner->eclass->fixedsize)\n\t\treturn;\n\n\tc = 0;\n\tfor (i=0 ; i<3 ; i++)\n\t\tc += AddPlanept (f->planepts[i]);\n\tif (c == 0)\n\t\treturn;\t\t// allready completely added\n\n\t// select all points on this plane in all brushes the selection\n\tfor (b2=selected_brushes.next ; b2 != &selected_brushes ; b2 = b2->next)\n\t{\n\t\tif (b2 == b)\n\t\t\tcontinue;\n\t\tfor (f2=b2->brush_faces ; f2 ; f2=f2->next)\n\t\t{\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t\tif (fabs(DotProduct(f2->planepts[i], f->plane.normal)\n\t\t\t\t-f->plane.dist) > ON_EPSILON)\n\t\t\t\t\tbreak;\n\t\t\tif (i==3)\n\t\t\t{\t// move this face as well\n\t\t\t\tBrush_SelectFaceForDragging (b2, f2, shear);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\n\t// if shearing, take all the planes adjacent to \n\t// selected faces and rotate their points so the\n\t// edge clipped by a selcted face has two of the points\n\tif (!shear)\n\t\treturn;\n\n\tfor (f2=b->brush_faces ; f2 ; f2=f2->next)\n\t{\n\t\tif (f2 == f)\n\t\t\tcontinue;\n\t\tw = Brush_MakeFaceWinding (b, f2);\n\t\tif (!w)\n\t\t\tcontinue;\n\n\t\t// any points on f will become new control points\n\t\tfor (i=0 ; i<w->numpoints ; i++)\n\t\t{\n\t\t\td = DotProduct (w->points[i], f->plane.normal) \n\t\t\t\t- f->plane.dist;\n\t\t\tif (d > -ON_EPSILON && d < ON_EPSILON)\n\t\t\t\tbreak;\n\t\t}\n\n\t\t//\n\t\t// if none of the points were on the plane,\n\t\t// leave it alone\n\t\t//\n\t\tif (i != w->numpoints)\n\t\t{\n\t\t\tif (i == 0)\n\t\t\t{\t// see if the first clockwise point was the\n\t\t\t\t// last point on the winding\n\t\t\t\td = DotProduct (w->points[w->numpoints-1]\n\t\t\t\t\t, f->plane.normal) - f->plane.dist;\n\t\t\t\tif (d > -ON_EPSILON && d < ON_EPSILON)\n\t\t\t\t\ti = w->numpoints - 1;\n\t\t\t}\n\n\t\t\tAddPlanept (f2->planepts[0]);\n\n\t\t\tVectorCopy (w->points[i], f2->planepts[0]);\n\t\t\tif (++i == w->numpoints)\n\t\t\t\ti = 0;\n\t\t\t\n\t\t\t// see if the next point is also on the plane\n\t\t\td = DotProduct (w->points[i]\n\t\t\t\t, f->plane.normal) - f->plane.dist;\n\t\t\tif (d > -ON_EPSILON && d < ON_EPSILON)\n\t\t\t\tAddPlanept (f2->planepts[1]);\n\n\t\t\tVectorCopy (w->points[i], f2->planepts[1]);\n\t\t\tif (++i == w->numpoints)\n\t\t\t\ti = 0;\n\n\t\t\t// the third point is never on the plane\n\n\t\t\tVectorCopy (w->points[i], f2->planepts[2]);\n\t\t}\n\n\t\tfree(w);\n\t}\n}\n\n/*\n==============\nBrush_SideSelect\n\nThe mouse click did not hit the brush, so grab one or more side\nplanes for dragging\n==============\n*/\nvoid Brush_SideSelect (brush_t *b, vec3_t origin, vec3_t dir\n\t\t\t\t\t   , qboolean shear)\n{\n\tface_t\t*f, *f2;\n\tvec3_t\tp1, p2;\n\n  //if (b->patchBrush)\n  //  return;\n    //Patch_SideSelect(b->nPatchID, origin, dir);\n\tfor (f=b->brush_faces ; f ; f=f->next)\n\t{\n\t\tVectorCopy (origin, p1);\n\t\tVectorMA (origin, 16384, dir, p2);\n\n\t\tfor (f2=b->brush_faces ; f2 ; f2=f2->next)\n\t\t{\n\t\t\tif (f2 == f)\n\t\t\t\tcontinue;\n\t\t\tClipLineToFace (p1, p2, f2);\n\t\t}\n\n\t\tif (f2)\n\t\t\tcontinue;\n\n\t\tif (VectorCompare (p1, origin))\n\t\t\tcontinue;\n\t\tif (ClipLineToFace (p1, p2, f))\n\t\t\tcontinue;\n\n\t\tBrush_SelectFaceForDragging (b, f, shear);\n\t}\n\n\t\n}\n\nvoid Brush_BuildWindings( brush_t *b, bool bSnap )\n{\n\twinding_t *w;\n\tface_t    *face;\n\tvec_t      v;\n\n\tif (bSnap)\n\t\tBrush_SnapPlanepts( b );\n\n\t// clear the mins/maxs bounds\n\tb->mins[0] = b->mins[1] = b->mins[2] = 99999;\n\tb->maxs[0] = b->maxs[1] = b->maxs[2] = -99999;\n\n\tBrush_MakeFacePlanes (b);\n\n\tface = b->brush_faces;\n\n\tfloat fCurveColor = 1.0;\n\n\tfor ( ; face ; face=face->next)\n\t{\n\t\tint i, j;\n\t\tfree(face->face_winding);\n\t\tw = face->face_winding = Brush_MakeFaceWinding (b, face);\n\t\tface->d_texture = Texture_ForName( face->texdef.name );\n\n\t\tif (!w)\n\t\t\tcontinue;\n\t\n\t\tfor (i=0 ; i<w->numpoints ; i++)\n\t\t{\n\t\t\t// add to bounding box\n\t\t\tfor (j=0 ; j<3 ; j++)\n\t\t\t{\n\t\t\t\tv = w->points[i][j];\n\t\t\t\tif (v > b->maxs[j])\n\t\t\t\t\tb->maxs[j] = v;\n\t\t\t\tif (v < b->mins[j])\n\t\t\t\t\tb->mins[j] = v;\n\t\t\t}\n\t\t}\n\t\t// setup s and t vectors, and set color\n\t\t//if (!g_PrefsDlg.m_bGLLighting)\n    //{\n\t\t  Face_SetColor (b, face, fCurveColor);\n    //}\n\n\t\tfCurveColor -= .10;\n\t\tif (fCurveColor <= 0)\n\t\t\tfCurveColor = 1.0;\n\n\t\t// computing ST coordinates for the windings\n\t\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\t{\n\t\t\tif (g_qeglobals.bNeedConvert)\n\t\t\t{\n\t\t\t\t// we have parsed old brushes format and need conversion\n\t\t\t\t// convert old brush texture representation to new format\n\t\t\t\tFaceToBrushPrimitFace(face);\n#ifdef _DEBUG\n\t\t\t\t// use old texture coordinates code to check against\n\t\t\t    for (i=0 ; i<w->numpoints ; i++)\n\t\t\t\t\tEmitTextureCoordinates( w->points[i], face->d_texture, face);\n#endif\n\t\t\t}\n\t\t\t// use new texture representation to compute texture coordinates\n\t\t\t// in debug mode we will check against old code and warn if there are differences\n\t\t\tEmitBrushPrimitTextureCoordinates(face,w);\n\t\t}\n\t\telse\n\t\t{\n\t\t    for (i=0 ; i<w->numpoints ; i++)\n\t\t\t\tEmitTextureCoordinates( w->points[i], face->d_texture, face);\n\t\t}\n\t}\n}\n\n/*\n==================\nBrush_RemoveEmptyFaces\n\nFrees any overconstraining faces\n==================\n*/\nvoid Brush_RemoveEmptyFaces ( brush_t *b )\n{\n\tface_t\t*f, *next;\n\n\tf = b->brush_faces;\n\tb->brush_faces = NULL;\n\n\tfor ( ; f ; f=next)\n\t{\n\t\tnext = f->next;\n\t\tif (!f->face_winding)\n\t\t\tFace_Free (f);\n\t\telse\n\t\t{\n\t\t\tf->next = b->brush_faces;\n\t\t\tb->brush_faces = f;\n\t\t}\n\n\t}\n}\n\nvoid Brush_SnapToGrid(brush_t *pb)\n{\n\tfor (face_t *f = pb->brush_faces ; f; f = f->next)\n\t{\n\t\tfor (int i = 0 ;i < 3 ;i++)\n\t\t{\n\t\t\tfor (int j = 0 ;j < 3 ; j++)\n\t\t\t{\n\t\t\t\tf->planepts[i][j] = floor (f->planepts[i][j] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize;\n\t\t\t}\n\t\t}\n\t}\n\tBrush_Build(pb);\n}\n\nvoid Brush_Rotate(brush_t *b, vec3_t vAngle, vec3_t vOrigin, bool bBuild)\n{\n\tfor (face_t* f=b->brush_faces ; f ; f=f->next)\n\t{\n\t\tfor (int i=0 ; i<3 ; i++)\n\t\t{\n\t\t\tVectorRotate(f->planepts[i], vAngle, vOrigin, f->planepts[i]);\n\t\t}\n\t}\n\tif (bBuild)\n\t{\n\t\tBrush_Build(b, false, false);\n\t}\n}\n\nvoid Brush_Center(brush_t *b, vec3_t vNewCenter)\n{\n  vec3_t vMid;\n  // get center of the brush\n  for (int j = 0; j < 3; j++)\n  {\n    vMid[j] = b->mins[j] + abs((b->maxs[j] - b->mins[j]) * 0.5);\n  }\n  // calc distance between centers\n  VectorSubtract(vNewCenter, vMid, vMid);\n  Brush_Move(b, vMid, true);\n\n}\n\n// only designed for fixed size entity brushes\nvoid Brush_Resize(brush_t *b, vec3_t vMin, vec3_t vMax)\n{\n  brush_t *b2 = Brush_Create(vMin, vMax, &b->brush_faces->texdef);\n\n  face_t *next;\n\tfor (face_t *f=b->brush_faces ; f ; f=next)\n\t{\n\t\tnext = f->next;\n\t\tFace_Free( f );\n\t}\n\n  b->brush_faces = b2->brush_faces;\n\n\t// unlink from active/selected list\n\tif (b2->next)\n  Brush_RemoveFromList (b2);\n  free(b2);\n  Brush_Build(b, true);\n}\n\n\neclass_t* HasModel(brush_t *b)\n{\n  vec3_t vMin, vMax;\n  vMin[0] = vMin[1] = vMin[2] = 9999;\n  vMax[0] = vMax[1] = vMax[2] = -9999;\n\n  if (b->owner->md3Class != NULL)\n  {\n    return b->owner->md3Class;\n  }\n\n  if (Eclass_hasModel(b->owner->eclass, vMin, vMax))\n  {\n    return b->owner->eclass;\n  }\n\n  eclass_t *e = NULL;\n  // FIXME: entity needs to track whether a cache hit failed and not ask again\n  if (b->owner->eclass->nShowFlags & ECLASS_MISCMODEL)\n  {\n    char *pModel = ValueForKey(b->owner, \"model\");\n    if (pModel != NULL && strlen(pModel) > 0)\n    {\n      e = GetCachedModel(b->owner, pModel, vMin, vMax);\n      if (e != NULL)\n      {\n        // we need to scale the brush to the proper size based on the model load\n        // recreate brush just like in load/save\n\n\t\t    VectorAdd (vMin, b->owner->origin, vMin);\n\t\t    VectorAdd (vMax, b->owner->origin, vMax);\n\n        Brush_Resize(b, vMin, vMax);\n\n/*\n        //\n        vec3_t vTemp, vTemp2;\n        VectorSubtract(b->maxs, b->mins, vTemp);\n        VectorSubtract(vMax, vMin, vTemp2);\n        for (int i = 0; i < 3; i++)\n        {\n          if (vTemp[i] != 0)\n          {\n            vTemp2[i] /= vTemp[i];\n          }\n        }\n        vec3_t vMid, vMid2;\n        vMid[0] = vMid[1] = vMid[2] = 0.0;\n        vMid2[0] = vMid2[1] = vMid2[2] = 0.0;\n\n        for (int j = 0; j < 3; j++)\n        {\n          vMid2[j] = b->mins[j] + abs((b->maxs[j] - b->mins[j]) * 0.5);\n        }\n\n        //VectorSubtract(vMid2, vMid, vMid2);\n\n\t\t    for (face_t* f=b->brush_faces ; f ; f=f->next)\n\t\t    {\n\t\t\t    for (int i=0 ; i<3 ; i++)\n\t\t\t    {\n\n            // scale\n            VectorSubtract(f->planepts[i], vMid2, f->planepts[i]);\n            f->planepts[i][0] *= vTemp2[0];\n            f->planepts[i][1] *= vTemp2[1];\n            f->planepts[i][2] *= vTemp2[2];\n            VectorAdd(f->planepts[i], vMid2, f->planepts[i]);\n          }\n        }\n\n        //Brush_Center(b, b->owner->origin);\n\n        //Brush_SnapToGrid(b);\n/*\n        float a = FloatForKey (b->owner, \"angle\");\n        if (a)\n        {\n          vec3_t vAngle;\n          vAngle[0] = vAngle[1] = 0;\n          vAngle[2] = a;\n          Brush_Rotate(b, vAngle, b->owner->origin);\n        }\n        else\n        {\n          Brush_Build(b, true);\n*/\n//        }\n\n        b->bModelFailed = false;\n      }\n      else\n      {\n        b->bModelFailed = true;\n      }\n    } \n  }\n  return e;\n}\n\nstatic bool g_bInPaintedModel = false;\nstatic bool g_bDoIt = false;\nbool PaintedModel(brush_t *b, bool bOkToTexture)\n{\n    if (g_bInPaintedModel)\n    { \n      return true;\n    }\n    \n    if (g_PrefsDlg.m_nEntityShowState == ENTITY_BOX || b->bModelFailed)\n    {\n      return false;\n    }\n    else if (!IsBrushSelected(b) && (g_PrefsDlg.m_nEntityShowState & ENTITY_SELECTED_ONLY))\n    {\n\t    return false;\n    }\n\n    g_bInPaintedModel = true;\n    bool bReturn = false;\n\n    eclass_t *pEclass = HasModel(b);\n\n    if (pEclass)\n    {\n      qglPushAttrib(GL_ALL_ATTRIB_BITS);\n      entitymodel *model = pEclass->model;\n\n\n      float a = FloatForKey (b->owner, \"angle\");\n      while (model != NULL)\n      {\n        if (bOkToTexture == false || g_PrefsDlg.m_nEntityShowState & ENTITY_WIREFRAME || model->nTextureBind == -1)\t// skinned\n        {\n\t        qglDisable( GL_CULL_FACE );\n\t        qglPolygonMode (GL_FRONT_AND_BACK, GL_LINE);\n\t        qglDisable(GL_TEXTURE_2D);\n          qglColor3fv(pEclass->color);\n        }\n        else\n        {\n          qglColor3f(1, 1, 1);\n          qglEnable(GL_TEXTURE_2D);\n\t        qglBindTexture( GL_TEXTURE_2D, model->nTextureBind );\n        }\n        vec3_t v;\n        \n        int i,j;\n        VectorAdd(b->maxs, b->mins, v);\n        VectorScale(v, 0.5, v);\n        VectorCopy(b->owner->origin, v);\n\n\t      \n        //for (i = 0; i < 3; i++)\n        //{\n        //  v[i] -= (pEclass->mins[i] - b->mins[i]);\n        //}\n\n        //if (model->nModelPosition)\n        //{\n\t\t      //v[2] = b->mins[2] - (pEclass->mins[2]);\n        //}\n\n        float s, c;\n\t      if (a)\n        {\n\t\t      s = sin (a/180*Q_PI);\n\t\t      c = cos (a/180*Q_PI);\n        }\n\n        vec3_t vSin;\n        vec3_t vCos;\n        VectorClear(vSin);\n        VectorClear(vCos);\n        for ( j = 0; j < 3; j++)\n        {\n          if (b->owner->vRotation[j])\n          {\n            vSin[j] = sin(b->owner->vRotation[j]/180*Q_PI);\n            vCos[j] = cos(b->owner->vRotation[j]/180*Q_PI);\n          }\n        }\n\n\n\t      qglBegin (GL_TRIANGLES);\n\n        vec5_t vTest[3];\n        for (i = 0; i < model->nTriCount; i++)\n        {\n          for (j = 0; j < 3; j++)\n          {\n#if 1\n            float x = model->pTriList[i].v[j][0] + v[0];\n            float y = model->pTriList[i].v[j][1] + v[1];\n            if (a)\n            {\n              float x2 = (((x - v[0]) * c) - ((y - v[1]) * s)) + v[0];\n              float y2 = (((x - v[0]) * s) + ((y - v[1]) * c)) + v[1];\n              x = x2;\n              y = y2;\n            }\n            //qglTexCoord2f (pEclass->pTriList[i].st[j][0] / pEclass->nSkinWidth, pEclass->pTriList[i].st[j][1] / pEclass->nSkinHeight);\n            qglTexCoord2f (model->pTriList[i].st[j][0], model->pTriList[i].st[j][1]);\n            qglVertex3f(x, y, model->pTriList[i].v[j][2] + v[2]);\n#else\n            float x = model->pTriList[i].v[j][0] + v[0];\n            float y = model->pTriList[i].v[j][1] + v[1];\n            float z = model->pTriList[i].v[j][2] + v[2];\n\n            if (b->owner->vRotation[0])\n            {\n              float y2 = (((y - v[1]) * vCos[0]) - ((z - v[2]) * vSin[0])) + v[1];\n              float z2 = (((y - v[1]) * vSin[0]) + ((z - v[2]) * vCos[0])) + v[2];\n              y = y2;\n              z = z2;\n            }\n            if (b->owner->vRotation[1])\n            {\n              float z2 = (((z - v[2]) * vCos[1]) - ((x - v[0]) * vSin[1])) + v[2];\n              float x2 = (((z - v[2]) * vSin[1]) + ((x - v[0]) * vCos[1])) + v[0];\n              x = x2;\n              z = z2;\n            }\n            if (b->owner->vRotation[2])\n            {\n              float x2 = (((x - v[0]) * vCos[2]) - ((y - v[1]) * vSin[2])) + v[0];\n              float y2 = (((x - v[0]) * vSin[2]) + ((y - v[1]) * vCos[2])) + v[1];\n              x = x2;\n              y = y2;\n            }\n            qglTexCoord2f (model->pTriList[i].st[j][0], model->pTriList[i].st[j][1]);\n            qglVertex3f(x, y, z);\n#endif\n            if (g_bDoIt)\n            {\n              vTest[j][0] = x;\n              vTest[j][1] = y;\n              vTest[j][2] = model->pTriList[i].v[j][2] + v[2];\n              vTest[j][3] = model->pTriList[i].st[j][0];\n              vTest[j][4] = model->pTriList[i].st[j][1];\n            }\n\n          }\n          if (g_bDoIt)\n          {\n            Patch_FromTriangle(vTest[0], vTest[1], vTest[2]);\n          }\n        }\n        qglEnd();\n        if (g_PrefsDlg.m_nEntityShowState & ENTITY_WIREFRAME)\t// skinned\n        {\n          qglEnable(GL_CULL_FACE );\n          qglEnable(GL_TEXTURE_2D);\n\t        qglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);\n        }\n        else\n        {\n\t        qglDisable(GL_TEXTURE_2D);\n        }\n        model = model->pNext;\n      }\n\n      if (g_bDoIt)\n      {\n        g_bDoIt = false;\n      }\n\n      vec3_t vColor;\n      VectorScale(pEclass->color, 0.50, vColor);\n\n      vec3_t vCenter, vMin, vMax;\n      VectorCopy(b->owner->origin, vCenter);\n\n\t\t  qglColor3fv(vColor);\n      qglPointSize(4);\n\n      qglBegin(GL_POINTS);\n      qglVertex3fv(b->owner->origin);\n      qglEnd();\n\n      qglBegin(GL_LINES);\n      vCenter[0] -= 8;\n      qglVertex3fv(vCenter);\n      vCenter[0] += 16;\n      qglVertex3fv(vCenter);\n      vCenter[0] -= 8;\n      vCenter[1] -= 8;\n      qglVertex3fv(vCenter);\n      vCenter[1] += 16;\n      qglVertex3fv(vCenter);\n      vCenter[1] -= 8;\n      vCenter[2] -= 8;\n      qglVertex3fv(vCenter);\n      vCenter[2] += 16;\n      qglVertex3fv(vCenter);\n      vCenter[2] -= 8;\n      qglEnd();\n\n      VectorCopy(vCenter, vMin);\n      VectorCopy(vCenter, vMax);\n      vMin[0] -= 4;\n      vMin[1] -= 4;\n      vMin[2] -= 4;\n      vMax[0] += 4;\n      vMax[1] += 4;\n      vMax[2] += 4;\n\n\t\t    qglBegin(GL_LINE_LOOP);\n          qglVertex3f(vMin[0],vMin[1],vMin[2]);\n          qglVertex3f(vMax[0],vMin[1],vMin[2]);\n          qglVertex3f(vMax[0],vMax[1],vMin[2]);\n          qglVertex3f(vMin[0],vMax[1],vMin[2]);\n\t\t    qglEnd();\n\t\t    \n\t\t    qglBegin(GL_LINE_LOOP);\n\t        qglVertex3f(vMin[0],vMin[1],vMax[2]);\n\t\t      qglVertex3f(vMax[0],vMin[1],vMax[2]);\n\t\t      qglVertex3f(vMax[0],vMax[1],vMax[2]);\n\t\t      qglVertex3f(vMin[0],vMax[1],vMax[2]);\n\t\t    qglEnd();\n\n\t\t    qglBegin(GL_LINES);\n  \t\t    qglVertex3f(vMin[0],vMin[1],vMin[2]);\n\t\t      qglVertex3f(vMin[0],vMin[1],vMax[2]);\n\t\t      qglVertex3f(vMin[0],vMax[1],vMax[2]);\n\t\t      qglVertex3f(vMin[0],vMax[1],vMin[2]);\n\t\t      qglVertex3f(vMax[0],vMin[1],vMin[2]);\n\t\t      qglVertex3f(vMax[0],vMin[1],vMax[2]);\n\t\t      qglVertex3f(vMax[0],vMax[1],vMax[2]);\n\t\t      qglVertex3f(vMax[0],vMax[1],vMin[2]);\n\t\t    qglEnd();\n\n\n\t    if (g_PrefsDlg.m_nEntityShowState & ENTITY_BOXED)\n\t    {\n\t\t    qglColor3fv(pEclass->color);\n\n        vec3_t mins, maxs;\n        VectorCopy(b->mins, mins);\n        VectorCopy(b->maxs, maxs);\n/*\n        if (a)\n        {\n          vec3_t vAngle;\n          vAngle[0] = vAngle[1] = 0;\n          vAngle[2] = a;\n          VectorRotate(mins, vAngle, b->owner->origin, mins);\n          VectorRotate(maxs, vAngle, b->owner->origin, maxs);\n        }\n*/\n\t\t    qglBegin(GL_LINE_LOOP);\n          qglVertex3f(mins[0],mins[1],mins[2]);\n          qglVertex3f(maxs[0],mins[1],mins[2]);\n          qglVertex3f(maxs[0],maxs[1],mins[2]);\n          qglVertex3f(mins[0],maxs[1],mins[2]);\n\t\t    qglEnd();\n\t\t    \n\t\t    qglBegin(GL_LINE_LOOP);\n\t        qglVertex3f(mins[0],mins[1],maxs[2]);\n\t\t      qglVertex3f(maxs[0],mins[1],maxs[2]);\n\t\t      qglVertex3f(maxs[0],maxs[1],maxs[2]);\n\t\t      qglVertex3f(mins[0],maxs[1],maxs[2]);\n\t\t    qglEnd();\n\n\t\t    qglBegin(GL_LINES);\n  \t\t    qglVertex3f(mins[0],mins[1],mins[2]);\n\t\t      qglVertex3f(mins[0],mins[1],maxs[2]);\n\t\t      qglVertex3f(mins[0],maxs[1],maxs[2]);\n\t\t      qglVertex3f(mins[0],maxs[1],mins[2]);\n\t\t      qglVertex3f(maxs[0],mins[1],mins[2]);\n\t\t      qglVertex3f(maxs[0],mins[1],maxs[2]);\n\t\t      qglVertex3f(maxs[0],maxs[1],maxs[2]);\n\t\t      qglVertex3f(maxs[0],maxs[1],mins[2]);\n\t\t    qglEnd();\n      }\n\t    qglPopAttrib();\n      bReturn = true;\n    }\n    else\n    {\n      b->bModelFailed = true;\n    }\n\n  g_bInPaintedModel = false;\n  return bReturn;\n}\n/*\n//++timo moved out to mahlib.h\n//++timo remove\nvoid AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)\n{\n\tfloat\t\tangle;\n\tstatic float\t\tsr, sp, sy, cr, cp, cy;\n\t// static to help MS compiler fp bugs\n\n\tangle = angles[YAW] * Q_PI / 180;\n\tsy = sin(angle);\n\tcy = cos(angle);\n\tangle = angles[PITCH] * Q_PI / 180;\n\tsp = sin(angle);\n\tcp = cos(angle);\n\tangle = angles[ROLL] * Q_PI / 180;\n\tsr = sin(angle);\n\tcr = cos(angle);\n\n\tif (forward)\n\t{\n\t\tforward[0] = cp*cy;\n\t\tforward[1] = cp*sy;\n\t\tforward[2] = -sp;\n\t}\n\tif (right)\n\t{\n\t\tright[0] = (-1*sr*sp*cy+-1*cr*-sy);\n\t\tright[1] = (-1*sr*sp*sy+-1*cr*cy);\n\t\tright[2] = -1*sr*cp;\n\t}\n\tif (up)\n\t{\n\t\tup[0] = (cr*sp*cy+-sr*-sy);\n\t\tup[1] = (cr*sp*sy+-sr*cy);\n\t\tup[2] = cr*cp;\n\t}\n}\n*/\nvoid FacingVectors (entity_t *e, vec3_t forward, vec3_t right, vec3_t up)\n{\n\tint\t\t\tangleVal;\n\tvec3_t\t\tangles;\n\n\tangleVal = IntForKey(e, \"angle\");\n\tif (angleVal == -1)\t\t\t\t// up\n\t{\n\t\tVectorSet(angles, 270, 0, 0);\n\t}\n\telse if(angleVal == -2)\t\t// down\n\t{\n\t\tVectorSet(angles, 90, 0, 0);\n\t}\n\telse\n\t{\n\t\tVectorSet(angles, 0, angleVal, 0);\n\t}\n\n\tAngleVectors(angles, forward, right, up);\n}\n\nvoid Brush_DrawFacingAngle (brush_t *b, entity_t *e)\n{\n\tvec3_t\tforward, right, up;\n\tvec3_t\tendpoint, tip1, tip2;\n\tvec3_t\tstart;\n\tfloat\tdist;\n\n\tVectorAdd(e->brushes.onext->mins, e->brushes.onext->maxs, start);\n\tVectorScale(start, 0.5, start);\n\tdist = (b->maxs[0] - start[0]) * 2.5;\n\n\tFacingVectors (e, forward, right, up);\n\tVectorMA (start, dist, forward, endpoint);\n\n\tdist = (b->maxs[0] - start[0]) * 0.5;\n\tVectorMA (endpoint, -dist, forward, tip1);\n\tVectorMA (tip1, -dist, up, tip1);\n\tVectorMA (tip1, 2*dist, up, tip2);\n\n\tqglColor4f (1, 1, 1, 1);\n\tqglLineWidth (4);\n\tqglBegin (GL_LINES);\n\tqglVertex3fv (start);\n\tqglVertex3fv (endpoint);\n\tqglVertex3fv (endpoint);\n\tqglVertex3fv (tip1);\n\tqglVertex3fv (endpoint);\n\tqglVertex3fv (tip2);\n\tqglEnd ();\n\tqglLineWidth (1);\n}\n\nvoid DrawLight(brush_t *b)\n{\n\tvec3_t vTriColor;\n\tbool bTriPaint = false;\n\n  vTriColor[0] = vTriColor[2] = 1.0;\n  vTriColor[1]  = 1.0;\n  bTriPaint = true;\n  CString strColor = ValueForKey(b->owner, \"_color\");\n  if (strColor.GetLength() > 0)\n  {\n    float fR, fG, fB;\n\t  int n = sscanf(strColor,\"%f %f %f\", &fR, &fG, &fB);\n    if (n == 3)\n    {\n      vTriColor[0] = fR;\n      vTriColor[1] = fG;\n      vTriColor[2] = fB;\n    }\n  }\n  qglColor3f(vTriColor[0], vTriColor[1], vTriColor[2]);\n\n  vec3_t vCorners[4];\n  float fMid = b->mins[2] + (b->maxs[2] - b->mins[2]) / 2;\n\n  vCorners[0][0] = b->mins[0];\n  vCorners[0][1] = b->mins[1];\n  vCorners[0][2] = fMid;\n\n  vCorners[1][0] = b->mins[0];\n  vCorners[1][1] = b->maxs[1];\n  vCorners[1][2] = fMid;\n\n  vCorners[2][0] = b->maxs[0];\n  vCorners[2][1] = b->maxs[1];\n  vCorners[2][2] = fMid;\n\n  vCorners[3][0] = b->maxs[0];\n  vCorners[3][1] = b->mins[1];\n  vCorners[3][2] = fMid;\n\n  vec3_t vTop, vBottom;\n\n  vTop[0] = b->mins[0] + ((b->maxs[0] - b->mins[0]) / 2);\n  vTop[1] = b->mins[1] + ((b->maxs[1] - b->mins[1]) / 2);\n  vTop[2] = b->maxs[2];\n\n  VectorCopy(vTop, vBottom);\n  vBottom[2] = b->mins[2];\n\n  vec3_t vSave;\n  VectorCopy(vTriColor, vSave);\n\n  qglBegin(GL_TRIANGLE_FAN);\n  qglVertex3fv(vTop);\n  for (int i = 0; i <= 3; i++)\n  {\n    vTriColor[0] *= 0.95;\n    vTriColor[1] *= 0.95;\n    vTriColor[2] *= 0.95;\n    qglColor3f(vTriColor[0], vTriColor[1], vTriColor[2]);\n    qglVertex3fv(vCorners[i]);\n  }\n  qglVertex3fv(vCorners[0]);\n  qglEnd();\n  \n  VectorCopy(vSave, vTriColor);\n  vTriColor[0] *= 0.95;\n  vTriColor[1] *= 0.95;\n  vTriColor[2] *= 0.95;\n\n  qglBegin(GL_TRIANGLE_FAN);\n  qglVertex3fv(vBottom);\n  qglVertex3fv(vCorners[0]);\n  for (i = 3; i >= 0; i--)\n  {\n    vTriColor[0] *= 0.95;\n    vTriColor[1] *= 0.95;\n    vTriColor[2] *= 0.95;\n    qglColor3f(vTriColor[0], vTriColor[1], vTriColor[2]);\n    qglVertex3fv(vCorners[i]);\n  }\n  qglEnd();\n\n  // check for DOOM lights\n  CString str = ValueForKey(b->owner, \"light_right\");\n  if (str.GetLength() > 0) {\n    vec3_t vRight, vUp, vTarget, vTemp;\n    GetVectorForKey (b->owner, \"light_right\", vRight);\n    GetVectorForKey (b->owner, \"light_up\", vUp);\n    GetVectorForKey (b->owner, \"light_target\", vTarget);\n\n    qglColor3f(0, 1, 0);\n\t\tqglBegin(GL_LINE_LOOP);\n    VectorAdd(vTarget, b->owner->origin, vTemp);\n    VectorAdd(vTemp, vRight, vTemp);\n    VectorAdd(vTemp, vUp, vTemp);\n    qglVertex3fv(b->owner->origin);\n    qglVertex3fv(vTemp);\n    VectorAdd(vTarget, b->owner->origin, vTemp);\n    VectorAdd(vTemp, vUp, vTemp);\n    VectorSubtract(vTemp, vRight, vTemp);\n    qglVertex3fv(b->owner->origin);\n    qglVertex3fv(vTemp);\n    VectorAdd(vTarget, b->owner->origin, vTemp);\n    VectorAdd(vTemp, vRight, vTemp);\n    VectorSubtract(vTemp, vUp, vTemp);\n    qglVertex3fv(b->owner->origin);\n    qglVertex3fv(vTemp);\n    VectorAdd(vTarget, b->owner->origin, vTemp);\n    VectorSubtract(vTemp, vUp, vTemp);\n    VectorSubtract(vTemp, vRight, vTemp);\n    qglVertex3fv(b->owner->origin);\n    qglVertex3fv(vTemp);\n    qglEnd();\n\n  }\n\n}\n\nvoid Brush_Draw( brush_t *b )\n{\n\tface_t\t\t\t*face;\n\tint\t\t\t\ti, order;\n\tqtexture_t\t\t*prev = 0;\n\twinding_t *w;\n\n\tif ( b->owner && ( b->owner->eclass->nShowFlags & ECLASS_PLUGINENTITY ) )\n\t{\n\t\tb->owner->pPlugEnt->CamRender();\n\t\treturn;\n\t}\n\t\n\t// (TTimo) NOTE: added by build 173, I check after pPlugEnt so it doesn't interfere ?\n\tif (b->hiddenBrush)\n\t{\n\t\treturn;\n\t}\n\n\tif (b->patchBrush)\n\t{\n\t\t//Patch_DrawCam(b->nPatchID);\n\t\tPatch_DrawCam(b->pPatch);\n\t\t//if (!g_bPatchShowBounds)\n\t\treturn;\n\t}\n\t\n\tif (b->terrainBrush)\n\t{\n\t\tTerrain_DrawCam(b->pTerrain);\n\t\treturn;\n\t}\n\n\tint nDrawMode = g_pParentWnd->GetCamera()->Camera().draw_mode;\n\t\n\tif (b->owner->eclass->fixedsize)\n\t{\n\t\t\n\t\tif (!(g_qeglobals.d_savedinfo.exclude & EXCLUDE_ANGLES) && (b->owner->eclass->nShowFlags & ECLASS_ANGLE))\n\t\t{\n\t\t\tBrush_DrawFacingAngle(b, b->owner);\n\t\t}\n\t\t\n\t\tif (g_PrefsDlg.m_bNewLightDraw && (b->owner->eclass->nShowFlags & ECLASS_LIGHT))\n\t\t{\n\t\t\tDrawLight(b);\n\t\t\treturn;\n\t\t}\n\t\tif (nDrawMode == cd_texture || nDrawMode == cd_light)\n\t\t\tqglDisable (GL_TEXTURE_2D);\n\t\t\n\t\t// if we are wireframing models\n\t\tbool bp = (b->bModelFailed) ? false : PaintedModel(b, true);\n\t\t\n\t\tif (nDrawMode == cd_texture || nDrawMode == cd_light)\n\t\t\tqglEnable (GL_TEXTURE_2D);\n\t\t\n\t\tif (bp)\n\t\t\treturn;\n\t}\n\t\n\t// guarantee the texture will be set first\n\tprev = NULL;\n\tfor (face = b->brush_faces,order = 0 ; face ; face=face->next, order++)\n\t{\n\t\tw = face->face_winding;\n\t\tif (!w)\n\t\t{\n\t\t\tcontinue;\t\t// freed face\n\t\t}\n\t\t\n\t\tif (g_qeglobals.d_savedinfo.exclude & EXCLUDE_CAULK)\n\t\t{\n\t\t\tif (strstr(face->texdef.name, \"caulk\"))\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\t\n#if 0\n\t\tif (b->alphaBrush)\n\t\t{\n\t\t\tif (!(face->texdef.flags & SURF_ALPHA))\n\t\t\t\tcontinue;\n\t\t\t//--qglPushAttrib(GL_ALL_ATTRIB_BITS);\n\t\t\tqglDisable(GL_CULL_FACE);\n\t\t\t//--qglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);\n\t\t\t//--qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\n\t\t\t//--qglDisable(GL_DEPTH_TEST);\n\t\t\t//--qglBlendFunc (GL_SRC_ALPHA, GL_DST_ALPHA);\n\t\t\t//--qglEnable (GL_BLEND);\n\t\t}\n#endif\n\t\t\n\t\tif ((nDrawMode == cd_texture || nDrawMode == cd_light) && face->d_texture != prev)\n\t\t{\n\t\t\t// set the texture for this face\n\t\t\tprev = face->d_texture;\n\t\t\tqglBindTexture( GL_TEXTURE_2D, face->d_texture->texture_number );\n\t\t}\n\t\t\n\t\t\n\t\t\n\t\tif (!b->patchBrush)\n\t\t{\n\t\t\tif (face->texdef.flags & SURF_TRANS33) \n\t\t\t\tqglColor4f ( face->d_color[0], face->d_color[1], face->d_color[2], 0.33 );\n\t\t\telse if ( face->texdef.flags & SURF_TRANS66) \n\t\t\t\tqglColor4f ( face->d_color[0], face->d_color[1], face->d_color[2], 0.66 );\n\t\t\telse\n\t\t\t\tqglColor3fv( face->d_color );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tqglColor4f ( face->d_color[0], face->d_color[1], face->d_color[2], 0.13 );\n\t\t}\n\t\t\n\t\t// shader drawing stuff\n\t\tif (face->d_texture->bFromShader)\n\t\t{\n\t\t\t// setup shader drawing\n\t\t\tqglColor4f ( face->d_color[0], face->d_color[1], face->d_color[2], face->d_texture->fTrans );\n\t\t\t\n\t\t}\n\t\t\n\t\t// draw the polygon\n\t\t\n\t\t//if (nDrawMode == cd_light)\n\t\t//{\n\t\tif (g_PrefsDlg.m_bGLLighting)\n\t\t{\n\t\t\tqglNormal3fv(face->plane.normal);\n\t\t}\n\t\t//}\n\t\t\n\t\tqglBegin(GL_POLYGON);\n\t\t//if (nDrawMode == cd_light)\n\t\t\n\t\tfor (i=0 ; i<w->numpoints ; i++)\n\t\t{\n\t\t\tif (nDrawMode == cd_texture || nDrawMode == cd_light)\n\t\t\t\tqglTexCoord2fv( &w->points[i][3] );\n\t\t\tqglVertex3fv(w->points[i]);\n\t\t}\n\t\tqglEnd();\n\t}\n\t\n#if 0\n\tif (b->alphaBrush)\n\t{\n\t\t//--qglPopAttrib();\n\t\tqglEnable(GL_CULL_FACE);\n\t\t//--qglDisable (GL_BLEND);\n\t\t//--qglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);\n\t}\n#endif\n\t\n\tif (b->owner->eclass->fixedsize && (nDrawMode == cd_texture || nDrawMode == cd_light))\n\t\tqglEnable (GL_TEXTURE_2D);\n\t\n\tqglBindTexture( GL_TEXTURE_2D, 0 );\n}\n\n\n\nvoid Face_Draw( face_t *f )\n{\n\tint i;\n\n\tif ( f->face_winding == 0 )\n\t\treturn;\n\tqglBegin( GL_POLYGON );\n\tfor ( i = 0 ; i < f->face_winding->numpoints; i++)\n\t\tqglVertex3fv( f->face_winding->points[i] );\n\tqglEnd();\n}\n\nvoid Brush_DrawXY(brush_t *b, int nViewType)\n{\n\tface_t *face;\n\tint     order;\n\twinding_t *w;\n\tint        i;\n\n\tif (b->hiddenBrush)\n\t{\n\t\treturn;\n\t}\n\n\tif (b->patchBrush)\n\t{\n\t\t//Patch_DrawXY(b->nPatchID);\n\t\tPatch_DrawXY(b->pPatch);\n\t\tif (!g_bPatchShowBounds)\n\t\t\treturn;\n\t}\n\n\tif (b->terrainBrush)\n\t{\n\t\tTerrain_DrawXY(b->pTerrain, b->owner);\n\t}\n                     \n\n\tif (b->owner->eclass->fixedsize)\n\t{\n\t\tif (g_PrefsDlg.m_bNewLightDraw && (b->owner->eclass->nShowFlags & ECLASS_LIGHT))\n\t\t{\n\t\t\tvec3_t vCorners[4];\n\t\t\tfloat fMid = b->mins[2] + (b->maxs[2] - b->mins[2]) / 2;\n\n\t\t\tvCorners[0][0] = b->mins[0];\n\t\t\tvCorners[0][1] = b->mins[1];\n\t\t\tvCorners[0][2] = fMid;\n\n\t\t\tvCorners[1][0] = b->mins[0];\n\t\t\tvCorners[1][1] = b->maxs[1];\n\t\t\tvCorners[1][2] = fMid;\n\n\t\t\tvCorners[2][0] = b->maxs[0];\n\t\t\tvCorners[2][1] = b->maxs[1];\n\t\t\tvCorners[2][2] = fMid;\n\n\t\t\tvCorners[3][0] = b->maxs[0];\n\t\t\tvCorners[3][1] = b->mins[1];\n\t\t\tvCorners[3][2] = fMid;\n\n\t\t\tvec3_t vTop, vBottom;\n\n\t\t\tvTop[0] = b->mins[0] + ((b->maxs[0] - b->mins[0]) / 2);\n\t\t\tvTop[1] = b->mins[1] + ((b->maxs[1] - b->mins[1]) / 2);\n\t\t\tvTop[2] = b->maxs[2];\n\n\t\t\tVectorCopy(vTop, vBottom);\n\t\t\tvBottom[2] = b->mins[2];\n\n\t\t\tqglPolygonMode (GL_FRONT_AND_BACK, GL_LINE);\n\t\t\tqglBegin(GL_TRIANGLE_FAN);\n\t\t\tqglVertex3fv(vTop);\n\t\t\tqglVertex3fv(vCorners[0]);\n\t\t\tqglVertex3fv(vCorners[1]);\n\t\t\tqglVertex3fv(vCorners[2]);\n\t\t\tqglVertex3fv(vCorners[3]);\n\t\t\tqglVertex3fv(vCorners[0]);\n\t\t\tqglEnd();\n\t\t\tqglBegin(GL_TRIANGLE_FAN);\n\t\t\tqglVertex3fv(vBottom);\n\t\t\tqglVertex3fv(vCorners[0]);\n\t\t\tqglVertex3fv(vCorners[3]);\n\t\t\tqglVertex3fv(vCorners[2]);\n\t\t\tqglVertex3fv(vCorners[1]);\n\t\t\tqglVertex3fv(vCorners[0]);\n\t\t\tqglEnd();\n\t\t\tDrawBrushEntityName (b);\n\t\t\treturn;\n\t\t}\n\t\telse if (b->owner->eclass->nShowFlags & ECLASS_MISCMODEL)\n\t\t{\n\t\t\tif (PaintedModel(b, false))\n\t\t\treturn;\n\t\t}\n\t}\n\n\tfor (face = b->brush_faces,order = 0 ; face ; face=face->next, order++)\n\t{\n\t\t// only draw polygons facing in a direction we care about\n    if (nViewType == XY)\n    {\n\t\t  if (face->plane.normal[2] <= 0)\n\t\t\t  continue;\n    }\n    else\n    {\n      if (nViewType == XZ)\n      {\n        if (face->plane.normal[1] <= 0)\n          continue;\n      }\n      else \n      {\n        if (face->plane.normal[0] <= 0)\n          continue;\n      }\n    }\n\n\t\tw = face->face_winding;\n\t\tif (!w)\n\t\t\tcontinue;\n\n    //if (b->alphaBrush && !(face->texdef.flags & SURF_ALPHA))\n    //  continue;\n\n\t\t// draw the polygon\n\t\tqglBegin(GL_LINE_LOOP);\n    for (i=0 ; i<w->numpoints ; i++)\n\t\t  qglVertex3fv(w->points[i]);\n\t\tqglEnd();\n\t}\n\n\tDrawBrushEntityName (b);\n\n}\n\n/*\n============\nBrush_Move\n============\n*/\nvoid Brush_Move (brush_t *b, const vec3_t move, bool bSnap)\n{\n  int i;\n  face_t *f;\n\n  for (f=b->brush_faces ; f ; f=f->next)\n  {\n    vec3_t vTemp;\n    VectorCopy(move, vTemp);\n\n    if (g_PrefsDlg.m_bTextureLock)\n      Face_MoveTexture(f, vTemp);\n    \n    for (i=0 ; i<3 ; i++)\n      VectorAdd (f->planepts[i], move, f->planepts[i]);\n  }\n  Brush_Build( b, bSnap );\n\n\n  if (b->patchBrush)\n  {\n    //Patch_Move(b->nPatchID, move);\n    Patch_Move(b->pPatch, move);\n  }\n\n  if (b->terrainBrush)\n  {\n    Terrain_Move(b->pTerrain, move);\n  }\n\n\n  // PGM - keep the origin vector up to date on fixed size entities.\n  if(b->owner->eclass->fixedsize)\n  {\n    VectorAdd(b->owner->origin, move, b->owner->origin);\n\t  //VectorAdd(b->maxs, b->mins, b->owner->origin);\n\t  //VectorScale(b->owner->origin, 0.5, b->owner->origin);\n  }\n}\n\n\n\nvoid Brush_Print(brush_t* b)\n{\n  int nFace = 0;\n  for (face_t* f = b->brush_faces ; f ; f=f->next)\n  {\n    Sys_Printf(\"Face %i\\n\", nFace++);\n    Sys_Printf(\"%f %f %f\\n\", f->planepts[0][0], f->planepts[0][1], f->planepts[0][2]);\n    Sys_Printf(\"%f %f %f\\n\", f->planepts[1][0], f->planepts[1][1], f->planepts[1][2]);\n    Sys_Printf(\"%f %f %f\\n\", f->planepts[2][0], f->planepts[2][1], f->planepts[2][2]);\n  }\n }\n\n\n\n/*\n=============\nBrush_MakeSided\n\nMakes the current brushhave the given number of 2d sides and turns it into a cone\n=============\n*/\nvoid Brush_MakeSidedCone(int sides)\n{\n\tint\t\ti;\n\tvec3_t\tmins, maxs;\n\tbrush_t\t*b;\n\ttexdef_t\t*texdef;\n\tface_t\t*f;\n\tvec3_t\tmid;\n\tfloat\twidth;\n\tfloat\tsv, cv;\n\n\tif (sides < 3)\n\t{\n\t\tSys_Status (\"Bad sides number\", 0);\n\t\treturn;\n\t}\n\n\tif (!QE_SingleBrush ())\n\t{\n\t\tSys_Status (\"Must have a single brush selected\", 0 );\n\t\treturn;\n\t}\n\n\tb = selected_brushes.next;\n\tVectorCopy (b->mins, mins);\n\tVectorCopy (b->maxs, maxs);\n\ttexdef = &g_qeglobals.d_texturewin.texdef;\n\n\tBrush_Free (b);\n\n\t// find center of brush\n\twidth = 8;\n\tfor (i=0 ; i<2 ; i++)\n\t{\n\t\tmid[i] = (maxs[i] + mins[i])*0.5;\n\t\tif (maxs[i] - mins[i] > width)\n\t\t\twidth = maxs[i] - mins[i];\n\t}\n\twidth /= 2;\n\n\tb = Brush_Alloc();\n\n\t// create bottom face\n\tf = Face_Alloc();\n\tf->texdef = *texdef;\n\tf->next = b->brush_faces;\n\tb->brush_faces = f;\n\n\tf->planepts[0][0] = mins[0];f->planepts[0][1] = mins[1];f->planepts[0][2] = mins[2];\n\tf->planepts[1][0] = maxs[0];f->planepts[1][1] = mins[1];f->planepts[1][2] = mins[2];\n\tf->planepts[2][0] = maxs[0];f->planepts[2][1] = maxs[1];f->planepts[2][2] = mins[2];\n\n\tfor (i=0 ; i<sides ; i++)\n\t{\n\t\tf = Face_Alloc();\n\t\tf->texdef = *texdef;\n\t\tf->next = b->brush_faces;\n\t\tb->brush_faces = f;\n\n\t\tsv = sin (i*3.14159265*2/sides);\n\t\tcv = cos (i*3.14159265*2/sides);\n\n\n\t\tf->planepts[0][0] = floor(mid[0]+width*cv+0.5);\n\t\tf->planepts[0][1] = floor(mid[1]+width*sv+0.5);\n\t\tf->planepts[0][2] = mins[2];\n\n\t\tf->planepts[1][0] = mid[0];\n\t\tf->planepts[1][1] = mid[1];\n\t\tf->planepts[1][2] = maxs[2];\n\n\t\tf->planepts[2][0] = floor(f->planepts[0][0] - width * sv + 0.5);\n\t\tf->planepts[2][1] = floor(f->planepts[0][1] + width * cv + 0.5);\n\t\tf->planepts[2][2] = maxs[2];\n\n\t}\n\n\tBrush_AddToList (b, &selected_brushes);\n\n\tEntity_LinkBrush (world_entity, b);\n\n\tBrush_Build( b );\n\n\tSys_UpdateWindows (W_ALL);\n}\n\n/*\n=============\nBrush_MakeSided\n\nMakes the current brushhave the given number of 2d sides and turns it into a sphere\n=============\n\n*/\nvoid Brush_MakeSidedSphere(int sides)\n{\n\tint\t\ti,j;\n\tvec3_t\tmins, maxs;\n\tbrush_t\t*b;\n\ttexdef_t\t*texdef;\n\tface_t\t*f;\n\tvec3_t\tmid;\n\n\tif (sides < 4)\n\t{\n\t\tSys_Status (\"Bad sides number\", 0);\n\t\treturn;\n\t}\n\n\tif (!QE_SingleBrush ())\n\t{\n\t\tSys_Status (\"Must have a single brush selected\", 0 );\n\t\treturn;\n\t}\n\n\tb = selected_brushes.next;\n\tVectorCopy (b->mins, mins);\n\tVectorCopy (b->maxs, maxs);\n\ttexdef = &g_qeglobals.d_texturewin.texdef;\n\n\tBrush_Free (b);\n\n\t// find center of brush\n\tfloat radius = 8;\n\tfor (i=0 ; i<2 ; i++)\n\t{\n\t\tmid[i] = (maxs[i] + mins[i])*0.5;\n\t\tif (maxs[i] - mins[i] > radius)\n\t\t\tradius = maxs[i] - mins[i];\n\t}\n\tradius /= 2;\n\n\tb = Brush_Alloc();\n\n\tfloat dt = float(2 * Q_PI / sides);\n\tfloat dp = float(Q_PI / sides);\n  float t,p;\n\tfor(i=0; i <= sides-1; i++)\n  {\n\t\tfor(j=0;j <= sides-2; j++)\n\t\t{\n\t\t\tt = i * dt;\n\t\t\tp = float(j * dp - Q_PI / 2);\n\n      f = Face_Alloc();\n\t    f->texdef = *texdef;\n\t    f->next = b->brush_faces;\n\t    b->brush_faces = f;\n\n      VectorPolar(f->planepts[0], radius, t, p);\n      VectorPolar(f->planepts[1], radius, t, p + dp);\n      VectorPolar(f->planepts[2], radius, t + dt, p + dp);\n\n      for (int k = 0; k < 3; k++)\n        VectorAdd(f->planepts[k], mid, f->planepts[k]);\n\t\t}\n  }\n\n  p = float((sides - 1) * dp - Q_PI / 2);\n\tfor(i = 0; i <= sides-1; i++)\n\t{\n\t\tt = i * dt;\n\n    f = Face_Alloc();\n\t  f->texdef = *texdef;\n\t  f->next = b->brush_faces;\n\t  b->brush_faces = f;\n\n    VectorPolar(f->planepts[0], radius, t, p);\n    VectorPolar(f->planepts[1], radius, t + dt, p + dp);\n    VectorPolar(f->planepts[2], radius, t + dt, p);\n\n    for (int k = 0; k < 3; k++)\n      VectorAdd(f->planepts[k], mid, f->planepts[k]);\n\t}\n\n\tBrush_AddToList (b, &selected_brushes);\n\n\tEntity_LinkBrush (world_entity, b);\n\n\tBrush_Build( b );\n\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid Face_FitTexture( face_t * face, int nHeight, int nWidth )\n{\n  winding_t *w;\n  vec3_t   mins,maxs;\n  int i;\n  float width, height, temp;\n  float rot_width, rot_height;\n  float cosv,sinv,ang;\n  float min_t, min_s, max_t, max_s;\n  float s,t;\n\tvec3_t\tvecs[2];\n  vec3_t   coords[4];\n\ttexdef_t\t*td;\n\n  if (nHeight < 1)\n  {\n    nHeight = 1;\n  }\n  if (nWidth < 1)\n  {\n    nWidth = 1;\n  }\n\n  ClearBounds (mins, maxs);\n\n\ttd = &face->texdef;\n\tw = face->face_winding;\n\tif (!w)\n\t{\n    return;\n\t}\n  for (i=0 ; i<w->numpoints ; i++)\n  {\n    AddPointToBounds( w->points[i], mins, maxs );\n  }\n   // \n   // get the current angle\n   //\n\tang = td->rotate / 180 * Q_PI;\n\tsinv = sin(ang);\n\tcosv = cos(ang);\n\n\t// get natural texture axis\n\tTextureAxisFromPlane(&face->plane, vecs[0], vecs[1]);\n\n  min_s = DotProduct( mins, vecs[0] );\n  min_t = DotProduct( mins, vecs[1] );\n  max_s = DotProduct( maxs, vecs[0] );\n  max_t = DotProduct( maxs, vecs[1] );\n  width = max_s - min_s;\n  height = max_t - min_t;\n  coords[0][0] = min_s;\n  coords[0][1] = min_t;\n  coords[1][0] = max_s;\n  coords[1][1] = min_t;\n  coords[2][0] = min_s;\n  coords[2][1] = max_t;\n  coords[3][0] = max_s;\n  coords[3][1] = max_t;\n  min_s = min_t = 99999;\n  max_s = max_t = -99999;\n  for (i=0; i<4; i++)\n  {\n    s = cosv * coords[i][0] - sinv * coords[i][1];\n\t  t = sinv * coords[i][0] + cosv * coords[i][1];\n    if (i&1)\n    {\n      if (s > max_s) \n      {\n        max_s = s;\n      }\n    }\n    else\n    {\n      if (s < min_s) \n      {\n        min_s = s;\n      }\n      if (i<2)\n      {\n        if (t < min_t) \n        {\n          min_t = t;\n        }\n      }\n      else\n      {\n        if (t > max_t) \n        {\n          max_t = t;\n        }\n      }\n    }\n  }\n  rot_width =  (max_s - min_s);\n  rot_height = (max_t - min_t);\n  td->scale[0] = -(rot_width/((float)(face->d_texture->width*nWidth)));\n  td->scale[1] = -(rot_height/((float)(face->d_texture->height*nHeight)));\n\n  td->shift[0] = min_s/td->scale[0];\n  temp = (int)(td->shift[0] / (face->d_texture->width*nWidth));\n  temp = (temp+1)*face->d_texture->width*nWidth;\n  td->shift[0] = (int)(temp - td->shift[0])%(face->d_texture->width*nWidth);\n\n  td->shift[1] = min_t/td->scale[1];\n  temp = (int)(td->shift[1] / (face->d_texture->height*nHeight));\n  temp = (temp+1)*(face->d_texture->height*nHeight);\n  td->shift[1] = (int)(temp - td->shift[1])%(face->d_texture->height*nHeight);\n}\n\nvoid Brush_FitTexture( brush_t *b, int nHeight, int nWidth )\n{\n\tface_t *face;\n\n\tfor (face = b->brush_faces ; face ; face=face->next)\n  {\n    Face_FitTexture( face, nHeight, nWidth );\n  }\n}\n\n\n"
  },
  {
    "path": "q3radiant/BrushScript.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// BrushScript stuff\n//\n#include \"stdafx.h\"\n#include \"qe3.h\"\n#include \"BSInput.h\"\n#include \"DialogInfo.h\"\n\n\n//\nstruct SVariableDef\n{\n  CString m_strName;\n  CString m_strInput;\n  float m_fValue;\n};\n\nstruct SVecVariableDef\n{\n  CString m_strName;\n  CString m_strInput;\n  vec3_t m_vValue;\n};\n\n\n\nconst int MAX_VARIABLES = 64;\n\nbrush_t* g_pHold1 = NULL;\nbrush_t* g_pHold2 = NULL;\nbrush_t* g_pHold3 = NULL;\nbool g_bRotateAroundSelection;\nint g_nVariableCount;\nint g_nVecVariableCount;\nint g_nLoopCounter;\nfloat g_fDefault = 9999.9;\nvec3_t g_vDefault;\nbool g_bStartLoop;\nchar* g_pLooper;\nbool g_bKeepGoing;\n\nSVariableDef g_Variables[MAX_VARIABLES];\nSVecVariableDef g_VecVariables[MAX_VARIABLES];\n\nvoid InitForScriptRun()\n{\n  g_pHold1 = NULL;\n  g_pHold2 = NULL;\n  g_pHold3 = NULL;\n  g_bRotateAroundSelection = true;\n  g_nVariableCount = 0;\n  g_nVecVariableCount = 0;\n  g_nLoopCounter = 0;\n  g_bStartLoop = false;\n  g_pLooper = NULL;\n  g_bKeepGoing = true;\n}\n\nvoid AddVariable(const char* pName, float fValue, const char* pInput = NULL)\n{\n  if (g_nVariableCount < MAX_VARIABLES)\n  {\n    g_Variables[g_nVariableCount].m_strName = pName;\n    g_Variables[g_nVariableCount].m_strName.MakeLower();\n    g_Variables[g_nVariableCount].m_fValue = fValue;\n    if (pInput)\n      g_Variables[g_nVariableCount].m_strInput = pInput;\n    g_nVariableCount++;\n  }\n  else\n    g_pParentWnd->MessageBox(\"Maximum script variable limit reached!\");\n}\n\nfloat VariableValue(const char* pName)\n{\n  CString strName = pName;\n  strName.MakeLower();\n  for (int n = 0; n < g_nVariableCount; n++)\n  {\n    if (strName == g_Variables[n].m_strName)\n      return g_Variables[n].m_fValue;\n  }\n  //strName.Format(\"Reference to non-existant varirable %s\", pName);\n  //g_pParentWnd->MessageBox(strName);\n  return g_fDefault;\n}\n\nvoid SetVariableValue(const char* pName, float fValue)\n{\n  CString strName = pName;\n  strName.MakeLower();\n  for (int n = 0; n < g_nVariableCount; n++)\n  {\n    if (strName == g_Variables[n].m_strName)\n      g_Variables[n].m_fValue = fValue;\n  }\n}\n\n\n\nvoid AddVectorVariable(const char* pName, const char* pInput = NULL)\n{\n  if (g_nVecVariableCount < MAX_VARIABLES)\n  {\n    g_VecVariables[g_nVecVariableCount].m_strName = pName;\n    g_VecVariables[g_nVecVariableCount].m_strName.MakeLower();\n    if (pInput)\n      g_VecVariables[g_nVariableCount].m_strInput = pInput;\n    g_nVecVariableCount++;\n  }\n  else\n    g_pParentWnd->MessageBox(\"Maximum script variable limit reached!\");\n}\n\nvoid VectorVariableValue(const char* pName, vec3_t& v)\n{\n  CString strName = pName;\n  strName.MakeLower();\n  for (int n = 0; n < g_nVecVariableCount; n++)\n  {\n    if (strName == g_VecVariables[n].m_strName)\n    {\n      VectorCopy(g_VecVariables[n].m_vValue, v);\n      return;\n    }\n  }\n  strName.Format(\"Reference to non-existant variable %s\", pName);\n  g_pParentWnd->MessageBox(strName);\n}\n\nvoid SetVectorVariableValue(const char* pName, vec3_t v)\n{\n  CString strName = pName;\n  strName.MakeLower();\n  for (int n = 0; n < g_nVecVariableCount; n++)\n  {\n    if (strName == g_VecVariables[n].m_strName)\n      VectorCopy(v, g_VecVariables[n].m_vValue);\n  }\n}\n\n\n\n\n\n// commands\n//\n// _CopySelected(nHoldPos)  \n// copies selected brush to hold spot 1, 2 or 3\n//\n// _MoveSelected(x, y, z)\n// moves selected brush by coords provided\n//\n// _RotateSelected(x, y, z)\n// rotates selected brush by coords provided\n//\n// _MoveHold(nHoldPos, x, y, z)\n// moves brush in hold pos by coords provided\n//\n// _RotateHold(nHoldPos, x, y, z)\n// rotates brush in hold pos by coords provided\n//\n// _CopyToMap(nHoldPos)\n// copies hold brush to map\n//\n// _CopyAndSelect(nHoldPos)\n// copies hold brush to map and selects it\n//\n// _Input(VarName1, ... VarNamennn)\n// inputs a list of values from the user\n//\n\ntypedef void (PFNScript)(char*&);\n\n\nstruct SBrushScript\n{\n  const char* m_pName;\n  PFNScript* m_pProc;\n};\n\n\nconst char* GetParam(char*& pBuffer)\n{\n  static CString strParam;\n  bool bStringMode = false;\n\n  while (*pBuffer != NULL && isspace(*pBuffer))   // skip and whitespace\n    pBuffer++;\n\n  if (*pBuffer == '(') // if it's an opening paren, skip it\n    pBuffer++;\n\n  if (*pBuffer == '\\\"') // string ?\n  {\n    pBuffer++;\n    bStringMode = true;\n  }\n\n  strParam = \"\";\n\n  if (bStringMode)\n  {\n    while (*pBuffer != NULL && *pBuffer != '\\\"')\n      strParam += *pBuffer++;\n  }\n  else\n  {\n    while (*pBuffer != NULL && *pBuffer != ' ' && *pBuffer != ')' && *pBuffer != ',')\n      strParam += *pBuffer++;\n  }\n\n  if (*pBuffer != NULL)   // skip last char\n    pBuffer++;\n\n  if (strParam.GetLength() > 0)\n  {\n    if (strParam.GetAt(0) == '$') // ? variable name\n    {\n      float f = VariableValue(strParam);\n      if (f != g_fDefault)\n        strParam.Format(\"%f\", f);\n    }\n  }\n\n  return strParam;\n}\n\nbrush_t* CopyBrush(brush_t* p)\n{                            \n  brush_t* pCopy = Brush_Clone(p);\n\t//Brush_AddToList (pCopy, &active_brushes);\n\t//Entity_LinkBrush (world_entity, pCopy);\n\tBrush_Build(pCopy, false);\n  return pCopy;\n}\n\n\nvoid CopySelected(char*& pBuffer)\n{\n  // expects one param\n  CString strParam = GetParam(pBuffer);\n  int n = atoi(strParam);\n\n  brush_t* pCopy = NULL;\n  if (selected_brushes.next != &selected_brushes && \n      selected_brushes.next->next == &selected_brushes)\n    pCopy = selected_brushes.next;\n\n  if (pCopy)\n  {\n    if (n == 1)\n    {\n      //if (g_pHold1)\n        //Brush_Free(g_pHold1);\n      g_pHold1 = CopyBrush(pCopy);\n    }\n    else if (n == 2)\n    {\n      //if (g_pHold2)\n        //Brush_Free(g_pHold2);\n      g_pHold2 = CopyBrush(pCopy);\n    }\n    else\n    {\n      //if (g_pHold3)\n        //Brush_Free(g_pHold3);\n      g_pHold3 = CopyBrush(pCopy);\n    }\n  }\n}\n\nvoid MoveSelected(char*& pBuffer)\n{\n  vec3_t v;\n  CString strParam = GetParam(pBuffer);\n  v[0] = atof(strParam);\n  strParam = GetParam(pBuffer);\n  v[1] = atof(strParam);\n  strParam = GetParam(pBuffer);\n  v[2] = atof(strParam);\n  Select_Move(v, false);\n  Sys_UpdateWindows(W_ALL);\n}\n\nvoid RotateSelected(char*& pBuffer)\n{\n  vec3_t v;\n\n  if (g_bRotateAroundSelection)\n  {\n    Select_GetTrueMid(v);\n    VectorCopy(v, g_pParentWnd->ActiveXY()->RotateOrigin());\n  }\n\n  CString strParam = GetParam(pBuffer);\n  v[0] = atof(strParam);\n  strParam = GetParam(pBuffer);\n  v[1] = atof(strParam);\n  strParam = GetParam(pBuffer);\n  v[2] = atof(strParam);\n  for (int i = 0; i < 3; i++)\n    if (v[i] != 0.0)\n      Select_RotateAxis(i, v[i], false , true);\n  Sys_UpdateWindows(W_ALL);\n}\n\nvoid MoveHold(char*& pBuffer)\n{\n  CString strParam = GetParam(pBuffer);\n  brush_t* pBrush = NULL;\n  int nHold = atoi(strParam);\n  if (nHold == 1)\n    pBrush = g_pHold1;\n  else if (nHold == 2)\n    pBrush = g_pHold2;\n  else \n    pBrush = g_pHold3;\n\n  if (pBrush)\n  {\n    vec3_t v;\n    strParam = GetParam(pBuffer);\n    v[0] = atof(strParam);\n    strParam = GetParam(pBuffer);\n    v[1] = atof(strParam);\n    strParam = GetParam(pBuffer);\n    v[2] = atof(strParam);\n\t\tBrush_Move (pBrush, v, false);\n  }\n}\n\nvoid RotateHold(char*& pBuffer)\n{\n  CString strParam = GetParam(pBuffer);\n  brush_t* pBrush = NULL;\n  int nHold = atoi(strParam);\n  if (nHold == 1)\n    pBrush = g_pHold1;\n  else if (nHold == 2)\n    pBrush = g_pHold2;\n  else \n    pBrush = g_pHold3;\n\n  if (pBrush)\n  {\n    vec3_t v;\n    strParam = GetParam(pBuffer);\n    v[0] = atof(strParam);\n    strParam = GetParam(pBuffer);\n    v[1] = atof(strParam);\n    strParam = GetParam(pBuffer);\n    v[2] = atof(strParam);\n    for (int i = 0; i < 3; i++)\n      if (v[i] != 0.0)\n        Select_RotateAxis(i, v[i]);\n  }\n}\n\nvoid CopyToMap(char*& pBuffer)\n{\n  CString strParam = GetParam(pBuffer);\n  brush_t* pBrush = NULL;\n  int nHold = atoi(strParam);\n  if (nHold == 1)\n    pBrush = g_pHold1;\n  else if (nHold == 2)\n    pBrush = g_pHold2;\n  else \n    pBrush = g_pHold3;\n\n  if (pBrush)\n  {\n    Brush_AddToList(pBrush, &active_brushes);\n\t\tEntity_LinkBrush (world_entity, pBrush);\n\t\tBrush_Build(pBrush, false);\n    Sys_UpdateWindows(W_ALL);\n  }\n}\n\nvoid CopyAndSelect(char*& pBuffer)\n{\n  CString strParam = GetParam(pBuffer);\n  brush_t* pBrush = NULL;\n  int nHold = atoi(strParam);\n  if (nHold == 1)\n    pBrush = g_pHold1;\n  else if (nHold == 2)\n    pBrush = g_pHold2;\n  else \n    pBrush = g_pHold3;\n\n  if (pBrush)\n  {\n    Select_Deselect();\n    Brush_AddToList(pBrush, &active_brushes);\n\t\tEntity_LinkBrush (world_entity, pBrush);\n\t\tBrush_Build(pBrush, false);\n    Select_Brush(pBrush);\n    Sys_UpdateWindows(W_ALL);\n  }\n}\n\nvoid Input(char*& pBuffer)\n{\n  CBSInput dlg;\n  bool bGo = false;\n  for (int n = 0; n < g_nVariableCount; n++)\n  {\n    if (g_Variables[n].m_strInput.GetLength() > 0)\n    {\n      bGo = true;\n      if (n < 5)\n      {\n        switch (n)\n        {\n          case 0 : dlg.m_strField1 = g_Variables[n].m_strInput; break;\n          case 1 : dlg.m_strField2 = g_Variables[n].m_strInput; break;\n          case 2 : dlg.m_strField3 = g_Variables[n].m_strInput; break;\n          case 3 : dlg.m_strField4 = g_Variables[n].m_strInput; break;\n          case 4 : dlg.m_strField5 = g_Variables[n].m_strInput; break;\n        }\n      }\n    }\n  }\n  if (bGo)\n  {\n    if (dlg.DoModal() == IDOK)\n    {\n      for (int n = 0; n < g_nVariableCount; n++)\n      {\n        if (g_Variables[n].m_strInput.GetLength() > 0)\n        {\n          if (n < 5)\n          {\n            switch (n)\n            {\n              case 0 : g_Variables[n].m_fValue = dlg.m_fField1; break;\n              case 1 : g_Variables[n].m_fValue = dlg.m_fField2; break;\n              case 2 : g_Variables[n].m_fValue = dlg.m_fField3; break;\n              case 3 : g_Variables[n].m_fValue = dlg.m_fField4; break;\n              case 4 : g_Variables[n].m_fValue = dlg.m_fField5; break;\n            }\n          }\n        }\n      }\n    }\n    else g_bKeepGoing = false;\n  }\n}\n\nbool g_bWaiting;\nvoid _3DPointDone(bool b, int n)\n{\n  g_bWaiting = false;\n}\n\nvoid _3DPointInput(char*& pBuffer)\n{\n  CString strParam = GetParam(pBuffer);\n  CString strParam2 = GetParam(pBuffer);\n  ShowInfoDialog(strParam2);\n  AddVectorVariable(strParam, strParam2);\n  g_bWaiting = true;\n  AcquirePath(2, &_3DPointDone);\n  while (g_bWaiting)\n  {\n    MSG msg;\n    if (::PeekMessage( &msg, NULL, 0, 0, PM_REMOVE )) \n    { \n      TranslateMessage(&msg);\n      DispatchMessage(&msg);\n    }\n  }\n  HideInfoDialog();\n  SetVectorVariableValue(strParam, g_PathPoints[0]);\n}\n\nvoid SetRotateOrigin(char*& pBuffer)\n{\n  vec3_t v;\n  CString strParam = GetParam(pBuffer);\n  VectorVariableValue(strParam, v);\n  VectorCopy(v, g_pParentWnd->ActiveXY()->RotateOrigin());\n  g_bRotateAroundSelection = false;\n}\n\nvoid InputVar(char*& pBuffer)\n{\n  CString strParam = GetParam(pBuffer);\n  CString strParam2 = GetParam(pBuffer);\n  AddVariable(strParam, 0.0, strParam2);\n}\n\nvoid LoopCount(char*& pBuffer)\n{\n  CString strParam = GetParam(pBuffer);\n  g_nLoopCounter = atoi(strParam);\n  if (g_nLoopCounter == 0)\n    g_nLoopCounter = VariableValue(strParam);\n  if (g_nLoopCounter > 0)\n    g_pLooper = pBuffer;\n}\n\nvoid LoopRun(char*& pBuffer)\n{\n  if (g_bStartLoop == true)\n  {\n    g_nLoopCounter--;\n    if (g_nLoopCounter == 0)\n    {\n      g_bStartLoop = false;\n      GetParam(pBuffer);\n    }\n    else\n      pBuffer = g_pLooper;\n  }\n  else\n  {\n    if (g_pLooper && g_nLoopCounter > 0)\n    {\n      g_bStartLoop = true;\n      pBuffer = g_pLooper;\n    }\n    else\n    {\n      GetParam(pBuffer);\n    }\n  }\n}\n\n\nvoid ConfirmMessage(char*& pBuffer)\n{\n  CString strParam = GetParam(pBuffer);\n  if (g_pParentWnd->MessageBox(strParam, \"Script Info\", MB_OKCANCEL) == IDCANCEL)\n    g_bKeepGoing = false;\n}\n\nvoid Spherize(char*& pBuffer)\n{\n  g_bScreenUpdates = false;\n  for (int n = 0; n < 120; n += 36)\n  {\n    for (int i = 0; i < 360; i += 36)\n    {\n      Select_RotateAxis(0, i, false , true);\n      CSG_Subtract();\n    }\n    Select_RotateAxis(2, n, false , true);\n  }\n  g_bScreenUpdates = true;\n}\n\nvoid RunIt(char*& pBuffer);\nSBrushScript g_ScriptCmds[] =\n{\n  {\"_CopySelected\", &CopySelected},\n  {\"_MoveSelected\", &MoveSelected},\n  {\"_RotateSelected\", &RotateSelected},\n  {\"_MoveHold\", &MoveHold},\n  {\"_RotateHold\", &RotateHold},\n  {\"_CopyToMap\", &CopyToMap},\n  {\"_CopyAndSelect\", &CopyAndSelect},\n  {\"_Input\", &Input},\n  {\"_3DPointInput\", &_3DPointInput},\n  {\"_SetRotateOrigin\", &SetRotateOrigin},\n  {\"_InputVar\", &InputVar},\n  {\"_LoopCount\", &LoopCount},\n  {\"_LoopRun\", &LoopRun},\n  {\"_ConfirmMessage\", &ConfirmMessage},\n  {\"_Spherize\", &Spherize},\n  {\"_RunScript\", RunIt}\n};\n\nconst int g_nScriptCmdCount = sizeof(g_ScriptCmds) / sizeof(SBrushScript);\n\nvoid RunScript(char* pBuffer)\n{\n  g_pHold1 = NULL;\n  g_pHold2 = NULL;\n  g_pHold3 = NULL;\n\n  while (g_bKeepGoing && pBuffer && *pBuffer)\n  {\n    while (*pBuffer != NULL && *pBuffer != '_')\n      pBuffer++;\n\n    char* pTemp = pBuffer;\n    int nLen = 0;\n    while (*pTemp != NULL && *pTemp != '(')\n    {\n      pTemp++;\n      nLen++;\n    }\n    if (*pBuffer != NULL)\n    {\n      bool bFound = false;\n      for (int i = 0; i < g_nScriptCmdCount; i++)\n      {\n        //if (strnicmp(g_ScriptCmds[i].m_pName, pBuffer, strlen(g_ScriptCmds[i].m_pName)) ==  0)\n        if (strnicmp(g_ScriptCmds[i].m_pName, pBuffer, nLen) ==  0)\n        {\n          pBuffer += strlen(g_ScriptCmds[i].m_pName);\n          g_ScriptCmds[i].m_pProc(pBuffer);\n          if (g_bStartLoop)\n          {\n          }\n          bFound = true;\n          break;\n        }\n      }\n      if (!bFound)\n        pBuffer++;\n    }\n  }\n}\n\n\nvoid RunScriptByName(char* pBuffer, bool bInit)\n{\n  if (bInit)\n    InitForScriptRun();\n  char* pScript = new char[4096];\n  CString strINI = g_strAppPath;\n  strINI += \"\\\\scripts.ini\";\n  GetPrivateProfileSection(pBuffer, pScript, 16384, strINI);\n  CString strScript;\n  char* pWorkScript = pScript;\n  while (*pWorkScript != NULL)\n  {\n    strScript += pWorkScript;\n    pWorkScript += strlen(pWorkScript) + 1;\n  }\n  RunScript(strScript.GetBuffer(0));\n}\n\n\nvoid RunIt(char*& pBuffer)\n{\n  brush_t* p1 = g_pHold1;\n  brush_t* p2 = g_pHold2;\n  brush_t* p3 = g_pHold3;\n\n  CString strParam = GetParam(pBuffer);\n  RunScriptByName(strParam.GetBuffer(0), false);\n\n  g_pHold3 = p3;\n  g_pHold2 = p2;\n  g_pHold1 = p1;\n}\n\n"
  },
  {
    "path": "q3radiant/CAMERA.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n// window system independent camera view code\n\ntypedef enum\n{\n\tcd_wire,\n\tcd_solid,\n\tcd_texture,\n  cd_light,\n\tcd_blend\n} camera_draw_mode;\n\ntypedef struct\n{\n\tint\t\twidth, height;\n\n\tqboolean\ttiming;\n\n\tvec3_t\torigin;\n\tvec3_t\tangles;\n\n\tcamera_draw_mode\tdraw_mode;\n\n\tvec3_t\tcolor;\t\t\t// background \n\n\tvec3_t\tforward, right, up;\t// move matrix\n\n\tvec3_t\tvup, vpn, vright;\t// view matrix\n} camera_t;\n\n"
  },
  {
    "path": "q3radiant/CSG.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"stdafx.h\"\n#include \"qe3.h\"\n#include \"winding.h\"\n\n\n/*\n=============\nCSG_MakeHollow\n=============\n*/\n\nvoid Brush_Scale(brush_t* b)\n{\n  for (face_t* f = b->brush_faces ; f ; f=f->next)\n  {\n\t  for (int i=0 ; i<3 ; i++)\n    {\n      VectorScale (f->planepts[i], g_qeglobals.d_gridsize, f->planepts[i]);\n    }\n  }\n}\n\nvoid CSG_MakeHollow (void)\n{\n\tbrush_t\t\t*b, *front, *back, *next;\n\tface_t\t\t*f;\n\tface_t\t\tsplit;\n\tvec3_t\t\tmove;\n\tint\t\t\ti;\n\n\tfor (b = selected_brushes.next ; b != &selected_brushes ; b=next)\n\t{\n\t\tnext = b->next;\n\n    if (b->owner->eclass->fixedsize || b->patchBrush || b->terrainBrush || b->hiddenBrush)\n\t\t  continue;\n\n\t\tfor (f = b->brush_faces ; f ; f=f->next)\n\t\t{\n\t\t\tsplit = *f;\n\t\t\tVectorScale (f->plane.normal, g_qeglobals.d_gridsize, move);\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t\tVectorSubtract (split.planepts[i], move, split.planepts[i]);\n\n\t\t\tBrush_SplitBrushByFace (b, &split, &front, &back);\n\t\t\tif (back)\n\t\t\t\tBrush_Free (back);\n\t\t\tif (front)\n\t\t\t\tBrush_AddToList (front, &selected_brushes);\n\t\t}\n\t\tBrush_Free (b);\n\t}\n\tSys_UpdateWindows (W_ALL);\n}\n\n/*\n=============\nBrush_Merge\n\n Returns a new brush that is created by merging brush1 and brush2.\n May return NULL if brush1 and brush2 do not create a convex brush when merged.\n The input brushes brush1 and brush2 stay intact.\n\n if onlyshape is true then the merge is allowed based on the shape only\n otherwise the texture/shader references of faces in the same plane have to\n be the same as well.\n=============\n*/\nbrush_t *Brush_Merge(brush_t *brush1, brush_t *brush2, int onlyshape)\n{\n\tint i, shared;\n\tbrush_t *newbrush;\n\tface_t *face1, *face2, *newface, *f;\n\n\t// check for bounding box overlapp\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tif (brush1->mins[i] > brush2->maxs[i] + ON_EPSILON\n\t\t\t\t|| brush1->maxs[i] < brush2->mins[i] - ON_EPSILON)\n\t\t{\n\t\t\t// never merge if the brushes overlap\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t//\n\tshared = 0;\n\t// check if the new brush would be convex... flipped planes make a brush non-convex\n\tfor (face1 = brush1->brush_faces; face1; face1 = face1->next)\n\t{\n\t\t// don't check the faces of brush 1 and 2 touching each other\n\t\tfor (face2 = brush2->brush_faces; face2; face2 = face2->next)\n\t\t{\n\t\t\tif (Plane_Equal(&face1->plane, &face2->plane, true))\n\t\t\t{\n\t\t\t\tshared++;\n\t\t\t\t// there may only be ONE shared side\n\t\t\t\tif (shared > 1)\n\t\t\t\t\treturn NULL;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t// if this face plane is shared\n\t\tif (face2) continue;\n\t\t//\n\t\tfor (face2 = brush2->brush_faces; face2; face2 = face2->next)\n\t\t{\n\t\t\t// don't check the faces of brush 1 and 2 touching each other\n\t\t\tfor (f = brush1->brush_faces; f; f = f->next)\n\t\t\t{\n\t\t\t\tif (Plane_Equal(&face2->plane, &f->plane, true)) break;\n\t\t\t}\n\t\t\tif (f)\n\t\t\t\tcontinue;\n\t\t\t//\n\t\t\tif (Plane_Equal(&face1->plane, &face2->plane, false))\n\t\t\t{\n\t\t\t\t//if the texture/shader references should be the same but are not\n\t\t\t\tif (!onlyshape && stricmp(face1->texdef.name, face2->texdef.name) != 0) return NULL;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t//\n\t\t\tif (Winding_PlanesConcave(face1->face_winding, face2->face_winding,\n\t\t\t\t\t\t\t\t\tface1->plane.normal, face2->plane.normal,\n\t\t\t\t\t\t\t\t\tface1->plane.dist, face2->plane.dist))\n\t\t\t{\n\t\t\t\treturn NULL;\n\t\t\t} //end if\n\t\t} //end for\n\t} //end for\n\t//\n\tnewbrush = Brush_Alloc();\n\t//\n\tfor (face1 = brush1->brush_faces; face1; face1 = face1->next)\n\t{\n\t\t// don't add the faces of brush 1 and 2 touching each other\n\t\tfor (face2 = brush2->brush_faces; face2; face2 = face2->next)\n\t\t{\n\t\t\tif (Plane_Equal(&face1->plane, &face2->plane, true))\n\t\t\t\tbreak;\n\t\t}\n\t\tif (face2)\n\t\t\tcontinue;\n\t\t// don't add faces with the same plane twice\n\t\tfor (f = newbrush->brush_faces; f; f = f->next)\n\t\t{\n\t\t\tif (Plane_Equal(&face1->plane, &f->plane, false))\n\t\t\t\tbreak;\n\t\t\tif (Plane_Equal(&face1->plane, &f->plane, true))\n\t\t\t\tbreak;\n\t\t}\n\t\tif (f)\n\t\t\tcontinue;\n\t\t//\n\t\tnewface = Face_Alloc();\n\t\tnewface->texdef = face1->texdef;\n\t\tVectorCopy(face1->planepts[0], newface->planepts[0]);\n\t\tVectorCopy(face1->planepts[1], newface->planepts[1]);\n\t\tVectorCopy(face1->planepts[2], newface->planepts[2]);\n\t\tnewface->plane = face1->plane;\n\t\tnewface->next = newbrush->brush_faces;\n\t\tnewbrush->brush_faces = newface;\n\t}\n\t//\n\tfor (face2 = brush2->brush_faces; face2; face2 = face2->next)\n\t{\n\t\t// don't add the faces of brush 1 and 2 touching each other\n\t\tfor (face1 = brush1->brush_faces; face1; face1 = face1->next)\n\t\t{\n\t\t\tif (Plane_Equal(&face2->plane, &face1->plane, true))\n\t\t\t\tbreak;\n\t\t}\n\t\tif (face1)\n\t\t\tcontinue;\n\t\t// don't add faces with the same plane twice\n\t\tfor (f = newbrush->brush_faces; f; f = f->next)\n\t\t{\n\t\t\tif (Plane_Equal(&face2->plane, &f->plane, false))\n\t\t\t\tbreak;\n\t\t\tif (Plane_Equal(&face2->plane, &f->plane, true))\n\t\t\t\tbreak;\n\t\t}\n\t\tif (f)\n\t\t\tcontinue;\n\t\t//\n\t\tnewface = Face_Alloc();\n\t\tnewface->texdef = face2->texdef;\n\t\tVectorCopy(face2->planepts[0], newface->planepts[0]);\n\t\tVectorCopy(face2->planepts[1], newface->planepts[1]);\n\t\tVectorCopy(face2->planepts[2], newface->planepts[2]);\n\t\tnewface->plane = face2->plane;\n\t\tnewface->next = newbrush->brush_faces;\n\t\tnewbrush->brush_faces = newface;\n\t}\n\t// link the new brush to an entity\n\tEntity_LinkBrush (brush1->owner, newbrush);\n\t// build windings for the faces\n\tBrush_BuildWindings( newbrush, false);\n\treturn newbrush;\n}\n\n/*\n=============\nBrush_MergeListPairs\n\n  Returns a list with merged brushes.\n  Tries to merge brushes pair wise.\n  The input list is destroyed.\n  Input and output should be a single linked list using .next\n=============\n*/\nbrush_t *Brush_MergeListPairs(brush_t *brushlist, int onlyshape)\n{\n\tint nummerges, merged;\n\tbrush_t *b1, *b2, *tail, *newbrush, *newbrushlist;\n\tbrush_t *lastb2;\n\n\tif (!brushlist) return NULL;\n\n\tnummerges = 0;\n\tdo\n\t{\n\t\tfor (tail = brushlist; tail; tail = tail->next)\n\t\t{\n\t\t\tif (!tail->next) break;\n\t\t}\n\t\tmerged = 0;\n\t\tnewbrushlist = NULL;\n\t\tfor (b1 = brushlist; b1; b1 = brushlist)\n\t\t{\n\t\t\tlastb2 = b1;\n\t\t\tfor (b2 = b1->next; b2; b2 = b2->next)\n\t\t\t{\n\t\t\t\tnewbrush = Brush_Merge(b1, b2, onlyshape);\n\t\t\t\tif (newbrush)\n\t\t\t\t{\n\t\t\t\t\ttail->next = newbrush;\n\t\t\t\t\tlastb2->next = b2->next;\n\t\t\t\t\tbrushlist = brushlist->next;\n\t\t\t\t\tb1->next = b1->prev = NULL;\n\t\t\t\t\tb2->next = b2->prev = NULL;\n\t\t\t\t\tBrush_Free(b1);\n\t\t\t\t\tBrush_Free(b2);\n\t\t\t\t\tfor (tail = brushlist; tail; tail = tail->next)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!tail->next) break;\n\t\t\t\t\t} //end for\n\t\t\t\t\tmerged++;\n\t\t\t\t\tnummerges++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tlastb2 = b2;\n\t\t\t}\n\t\t\t//if b1 can't be merged with any of the other brushes\n\t\t\tif (!b2)\n\t\t\t{\n\t\t\t\tbrushlist = brushlist->next;\n\t\t\t\t//keep b1\n\t\t\t\tb1->next = newbrushlist;\n\t\t\t\tnewbrushlist = b1;\n\t\t\t}\n\t\t}\n\t\tbrushlist = newbrushlist;\n\t} while(merged);\n\treturn newbrushlist;\n}\n\n/*\n=============\nBrush_MergeList\n\n Tries to merge all brushes in the list into one new brush.\n The input brush list stays intact.\n Returns NULL if no merged brush can be created.\n To create a new brush the brushes in the list may not overlap and\n the outer faces of the brushes together should make a new convex brush.\n\n if onlyshape is true then the merge is allowed based on the shape only\n otherwise the texture/shader references of faces in the same plane have to\n be the same as well.\n=============\n*/\nbrush_t *Brush_MergeList(brush_t *brushlist, int onlyshape)\n{\n\tbrush_t *brush1, *brush2, *brush3, *newbrush;\n\tface_t *face1, *face2, *face3, *newface, *f;\n\n\tif (!brushlist) return NULL;\n\tfor (brush1 = brushlist; brush1; brush1 = brush1->next)\n\t{\n\t\t// check if the new brush would be convex... flipped planes make a brush concave\n\t\tfor (face1 = brush1->brush_faces; face1; face1 = face1->next)\n\t\t{\n\t\t\t// don't check face1 if it touches another brush\n\t\t\tfor (brush2 = brushlist; brush2; brush2 = brush2->next)\n\t\t\t{\n\t\t\t\tif (brush2 == brush1) continue;\n\t\t\t\tfor (face2 = brush2->brush_faces; face2; face2 = face2->next)\n\t\t\t\t{\n\t\t\t\t\tif (Plane_Equal(&face1->plane, &face2->plane, true))\n\t\t\t\t\t{\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (face2) break;\n\t\t\t}\n\t\t\t// if face1 touches another brush\n\t\t\tif (brush2) continue;\n\t\t\t//\n\t\t\tfor (brush2 = brush1->next; brush2; brush2 = brush2->next)\n\t\t\t{\n\t\t\t\t// don't check the faces of brush 2 touching another brush\n\t\t\t\tfor (face2 = brush2->brush_faces; face2; face2 = face2->next)\n\t\t\t\t{\n\t\t\t\t\tfor (brush3 = brushlist; brush3; brush3 = brush3->next)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (brush3 == brush2) continue;\n\t\t\t\t\t\tfor (face3 = brush3->brush_faces; face3; face3 = face3->next)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (Plane_Equal(&face2->plane, &face3->plane, true)) break;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (face3) break;\n\t\t\t\t\t}\n\t\t\t\t\t// if face2 touches another brush\n\t\t\t\t\tif (brush3) continue;\n\t\t\t\t\t//\n\t\t\t\t\tif (Plane_Equal(&face1->plane, &face2->plane, false))\n\t\t\t\t\t{\n\t\t\t\t\t\t//if the texture/shader references should be the same but are not\n\t\t\t\t\t\tif (!onlyshape && stricmp(face1->texdef.name, face2->texdef.name) != 0) return NULL;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t//\n\t\t\t\t\tif (Winding_PlanesConcave(face1->face_winding, face2->face_winding,\n\t\t\t\t\t\t\t\t\t\t\tface1->plane.normal, face2->plane.normal,\n\t\t\t\t\t\t\t\t\t\t\tface1->plane.dist, face2->plane.dist))\n\t\t\t\t\t{\n\t\t\t\t\t\treturn NULL;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t//\n\tnewbrush = Brush_Alloc();\n\t//\n\tfor (brush1 = brushlist; brush1; brush1 = brush1->next)\n\t{\n\t\tfor (face1 = brush1->brush_faces; face1; face1 = face1->next)\n\t\t{\n\t\t\t// don't add face1 to the new brush if it touches another brush\n\t\t\tfor (brush2 = brushlist; brush2; brush2 = brush2->next)\n\t\t\t{\n\t\t\t\tif (brush2 == brush1) continue;\n\t\t\t\tfor (face2 = brush2->brush_faces; face2; face2 = face2->next)\n\t\t\t\t{\n\t\t\t\t\tif (Plane_Equal(&face1->plane, &face2->plane, true))\n\t\t\t\t\t{\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (face2) break;\n\t\t\t}\n\t\t\tif (brush2) continue;\n\t\t\t// don't add faces with the same plane twice\n\t\t\tfor (f = newbrush->brush_faces; f; f = f->next)\n\t\t\t{\n\t\t\t\tif (Plane_Equal(&face1->plane, &f->plane, false))\n\t\t\t\t\tbreak;\n\t\t\t\tif (Plane_Equal(&face1->plane, &f->plane, true))\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (f)\n\t\t\t\tcontinue;\n\t\t\t//\n\t\t\tnewface = Face_Alloc();\n\t\t\tnewface->texdef = face1->texdef;\n\t\t\tVectorCopy(face1->planepts[0], newface->planepts[0]);\n\t\t\tVectorCopy(face1->planepts[1], newface->planepts[1]);\n\t\t\tVectorCopy(face1->planepts[2], newface->planepts[2]);\n\t\t\tnewface->plane = face1->plane;\n\t\t\tnewface->next = newbrush->brush_faces;\n\t\t\tnewbrush->brush_faces = newface;\n\t\t}\n\t}\n\t// link the new brush to an entity\n\tEntity_LinkBrush (brushlist->owner, newbrush);\n\t// build windings for the faces\n\tBrush_BuildWindings( newbrush, false);\n\treturn newbrush;\n}\n\n/*\n=============\nBrush_Subtract\n\n Returns a list of brushes that remain after B is subtracted from A.\n May by empty if A is contained inside B.\n The originals are undisturbed.\n=============\n*/\nbrush_t *Brush_Subtract(brush_t *a, brush_t *b)\n{\n\t// a - b = out (list)\n\tbrush_t *front, *back;\n\tbrush_t *in, *out, *next;\n\tface_t *f;\n\n\tin = a;\n\tout = NULL;\n\tfor (f = b->brush_faces; f && in; f = f->next)\n\t{\n\t\tBrush_SplitBrushByFace(in, f, &front, &back);\n\t\tif (in != a) Brush_Free(in);\n\t\tif (front)\n\t\t{\t// add to list\n\t\t\tfront->next = out;\n\t\t\tout = front;\n\t\t}\n\t\tin = back;\n\t}\n\t//NOTE: in != a just in case brush b has no faces\n\tif (in && in != a)\n\t{\n\t\tBrush_Free(in);\n\t}\n\telse\n\t{\t//didn't really intersect\n\t\tfor (b = out; b; b = next)\n\t\t{\n\t\t\tnext = b->next;\n\t\t\tb->next = b->prev = NULL;\n\t\t\tBrush_Free(b);\n\t\t}\n\t\treturn a;\n\t}\n\treturn out;\n}\n\n/*\n=============\nCSG_Subtract\n=============\n*/\nvoid CSG_Subtract (void)\n{\n\tbrush_t\t\t*b, *s, *fragments, *nextfragment, *frag, *next, *snext;\n\tbrush_t\t\tfragmentlist;\n\tint\t\t\ti, numfragments, numbrushes;\n\n\tSys_Printf (\"Subtracting...\\n\");\n\n\tif (selected_brushes.next == &selected_brushes)\n\t{\n\t\tSys_Printf(\"No brushes selected.\\n\");\n\t\treturn;\n\t}\n\n\tfragmentlist.next = &fragmentlist;\n\tfragmentlist.prev = &fragmentlist;\n\n\tnumfragments = 0;\n\tnumbrushes = 0;\n\tfor (b = selected_brushes.next ; b != &selected_brushes ; b=next)\n\t{\n\t\tnext = b->next;\n\n\t\tif (b->owner->eclass->fixedsize)\n\t\t\tcontinue;\t// can't use texture from a fixed entity, so don't subtract\n\n\t\t// chop all fragments further up\n\t\tfor (s = fragmentlist.next; s != &fragmentlist; s = snext)\n\t\t{\n\t\t\tsnext = s->next;\n\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t\tif (b->mins[i] >= s->maxs[i] - ON_EPSILON \n\t\t\t\t|| b->maxs[i] <= s->mins[i] + ON_EPSILON)\n\t\t\t\t\tbreak;\n\t\t\tif (i != 3)\n\t\t\t\tcontinue;\t// definately don't touch\n\t\t\tfragments = Brush_Subtract(s, b);\n\t\t\t// if the brushes did not really intersect\n\t\t\tif (fragments == s)\n\t\t\t\tcontinue;\n\t\t\t// try to merge fragments\n\t\t\tfragments = Brush_MergeListPairs(fragments, true);\n\t\t\t// add the fragments to the list\n\t\t\tfor (frag = fragments; frag; frag = nextfragment)\n\t\t\t{\n\t\t\t\tnextfragment = frag->next;\n\t\t\t\tfrag->next = NULL;\n\t\t\t\tfrag->owner = s->owner;\n\t\t\t\tBrush_AddToList(frag, &fragmentlist);\n\t\t\t}\n\t\t\t// free the original brush\n\t\t\tBrush_Free(s);\n\t\t}\n\n\t\t// chop any active brushes up\n\t\tfor (s = active_brushes.next; s != &active_brushes; s = snext)\n\t\t{\n\t\t\tsnext = s->next;\n\n\t\t\tif (s->owner->eclass->fixedsize || s->patchBrush || s->terrainBrush || s->hiddenBrush)\n\t\t\t\tcontinue;\n\n\t\t\t//face_t *pFace = s->brush_faces;\n\t\t\tif (s->brush_faces->d_texture->bFromShader && (s->brush_faces->d_texture->nShaderFlags & QER_NOCARVE))\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t\tif (b->mins[i] >= s->maxs[i] - ON_EPSILON \n\t\t\t\t|| b->maxs[i] <= s->mins[i] + ON_EPSILON)\n\t\t\t\t\tbreak;\n\t\t\tif (i != 3)\n\t\t\t\tcontinue;\t// definately don't touch\n\n\t\t\tfragments = Brush_Subtract(s, b);\n\t\t\t// if the brushes did not really intersect\n\t\t\tif (fragments == s)\n\t\t\t\tcontinue;\n\t\t\t//\n\t\t\tUndo_AddBrush(s);\n\t\t\t// one extra brush chopped up\n\t\t\tnumbrushes++;\n\t\t\t// try to merge fragments\n\t\t\tfragments = Brush_MergeListPairs(fragments, true);\n\t\t\t// add the fragments to the list\n\t\t\tfor (frag = fragments; frag; frag = nextfragment)\n\t\t\t{\n\t\t\t\tnextfragment = frag->next;\n\t\t\t\tfrag->next = NULL;\n\t\t\t\tfrag->owner = s->owner;\n\t\t\t\tBrush_AddToList(frag, &fragmentlist);\n\t\t\t}\n\t\t\t// free the original brush\n\t\t\tBrush_Free(s);\n\t\t}\n\t}\n\n\t// move all fragments to the active brush list\n\tfor (frag = fragmentlist.next; frag != &fragmentlist; frag = nextfragment)\n\t{\n\t\tnextfragment = frag->next;\n\t\tnumfragments++;\n\t\tBrush_RemoveFromList(frag);\n\t\tBrush_AddToList(frag, &active_brushes);\n\t\tUndo_EndBrush(frag);\n\t}\n\n\tif (numfragments == 0)\n\t{\n\t\tSys_Printf(\"Selected brush%s did not intersect with any other brushes.\\n\",\n\t\t\t\t\t(selected_brushes.next->next == &selected_brushes) ? \"\":\"es\");\n\t\treturn;\n\t}\n\tSys_Printf(\"done. (created %d fragment%s out of %d brush%s)\\n\", numfragments, (numfragments == 1)?\"\":\"s\",\n\t\t\t\t\t\t\tnumbrushes, (numbrushes == 1)?\"\":\"es\");\n\tSys_UpdateWindows(W_ALL);\n}\n\n/*\n=============\nCSG_Merge\n=============\n*/\nvoid CSG_Merge(void)\n{\n\tbrush_t *b, *next, *newlist, *newbrush;\n\tstruct entity_s\t*owner;\n\n\tSys_Printf (\"Merging...\\n\");\n\n\tif (selected_brushes.next == &selected_brushes)\n\t{\n\t\tSys_Printf(\"No brushes selected.\\n\");\n\t\treturn;\n\t}\n\n\tif (selected_brushes.next->next == &selected_brushes)\n\t{\n\t\tSys_Printf(\"At least two brushes have to be selected.\\n\");\n\t\treturn;\n\t}\n\n\towner = selected_brushes.next->owner;\n\n\tfor (b = selected_brushes.next; b != &selected_brushes; b = next)\n\t{\n\t\tnext = b->next;\n\n\t\tif (b->owner->eclass->fixedsize)\n\t\t{\n\t\t\t// can't use texture from a fixed entity, so don't subtract\n\t\t\tSys_Printf(\"Cannot add fixed size entities.\\n\");\n\t\t\treturn;\n\t\t}\n\n\t\tif (b->patchBrush)\n\t\t{\n\t\t\tSys_Printf(\"Cannot add patches.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tif (b->terrainBrush)\n\t\t{\n\t\t\tSys_Printf(\"Cannot add terrains.\\n\");\n\t\t\treturn;\n\t\t}\n\n\t\tif (b->brush_faces->d_texture->bFromShader && (b->brush_faces->d_texture->nShaderFlags & QER_NOCARVE))\n\t\t{\n\t\t\tSys_Printf(\"Cannot add brushes using shaders that don't allows CSG operations.\\n\");\n\t\t\treturn;\n\t\t}\n\n\t\tif (b->owner != owner)\n\t\t{\n\t\t\tSys_Printf(\"Cannot add brushes from different entities.\\n\");\n\t\t\treturn;\n\t\t}\n\n\t}\n\n\tnewlist = NULL;\n\tfor (b = selected_brushes.next; b != &selected_brushes; b = next)\n\t{\n\t\tnext = b->next;\n\n\t\tBrush_RemoveFromList(b);\n\t\tb->next = newlist;\n\t\tb->prev = NULL;\n\t\tnewlist = b;\n\t}\n\n\tnewbrush = Brush_MergeList(newlist, true);\n\t// if the new brush would not be convex\n\tif (!newbrush)\n\t{\n\t\t// add the brushes back into the selection\n\t\tfor (b = newlist; b; b = next)\n\t\t{\n\t\t\tnext = b->next;\n\t\t\tb->next = NULL;\n\t\t\tb->prev = NULL;\n\t\t\tBrush_AddToList(b, &selected_brushes);\n\t\t}\n\t\tSys_Printf(\"Cannot add a set of brushes with a concave hull.\\n\");\n\t\treturn;\n\t}\n\t// free the original brushes\n\tfor (b = newlist; b; b = next)\n\t{\n\t\tnext = b->next;\n\t\tb->next = NULL;\n\t\tb->prev = NULL;\n\t\tBrush_Free(b);\n\t}\n\tBrush_AddToList(newbrush, &selected_brushes);\n\n\tSys_Printf (\"done.\\n\");\n\tSys_UpdateWindows (W_ALL);\n}\n"
  },
  {
    "path": "q3radiant/CamWnd.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// CamWnd.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"XYWnd.h\"\n#include \"CamWnd.h\"\n#include \"qe3.h\"\n#include \"splines/splines.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\nextern void DrawPathLines();\n\nint g_nAngleSpeed = 300;\nint g_nMoveSpeed = 400;\n\n\n/////////////////////////////////////////////////////////////////////////////\n// CCamWnd\nIMPLEMENT_DYNCREATE(CCamWnd, CWnd);\n\nCCamWnd::CCamWnd()\n{\n  m_pXYFriend = NULL;\n  m_nNumTransBrushes = 0;\n  memset(&m_Camera, 0, sizeof(camera_t));\n  m_pSide_select = NULL;\n  m_bClipMode = false;\n  Cam_Init();\n}\n\nCCamWnd::~CCamWnd()\n{\n}\n\n\nBEGIN_MESSAGE_MAP(CCamWnd, CWnd)\n\t//{{AFX_MSG_MAP(CCamWnd)\n\tON_WM_KEYDOWN()\n\tON_WM_PAINT()\n\tON_WM_DESTROY()\n\tON_WM_CLOSE()\n\tON_WM_MOUSEMOVE()\n\tON_WM_LBUTTONDOWN()\n\tON_WM_LBUTTONUP()\n\tON_WM_MBUTTONDOWN()\n\tON_WM_MBUTTONUP()\n\tON_WM_RBUTTONDOWN()\n\tON_WM_RBUTTONUP()\n\tON_WM_CREATE()\n\tON_WM_SIZE()\n\tON_WM_NCCALCSIZE()\n\tON_WM_KILLFOCUS()\n\tON_WM_SETFOCUS()\n\tON_WM_KEYUP()\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n\nLONG WINAPI CamWndProc (\n    HWND    hWnd,\n    UINT    uMsg,\n    WPARAM  wParam,\n    LPARAM  lParam)\n{\n    RECT\trect;\n\n    GetClientRect(hWnd, &rect);\n\n    switch (uMsg)\n    {\n\tcase WM_KILLFOCUS:\n\tcase WM_SETFOCUS:\n\t\tSendMessage( hWnd, WM_NCACTIVATE, uMsg == WM_SETFOCUS, 0 );\n\t\treturn 0;\n\n\tcase WM_NCCALCSIZE:// don't let windows copy pixels\n\t\tDefWindowProc (hWnd, uMsg, wParam, lParam);\n\t\treturn WVR_REDRAW;\n\n    }\n\n\treturn DefWindowProc( hWnd, uMsg, wParam, lParam );\n}\n\n\n/////////////////////////////////////////////////////////////////////////////\n// CCamWnd message handlers\n\nBOOL CCamWnd::PreCreateWindow(CREATESTRUCT& cs) \n{\n  WNDCLASS wc;\n  HINSTANCE hInstance = AfxGetInstanceHandle();\n  if (::GetClassInfo(hInstance, CAMERA_WINDOW_CLASS, &wc) == FALSE)\n  {\n    // Register a new class\n  \tmemset (&wc, 0, sizeof(wc));\n    wc.style         = CS_NOCLOSE | CS_OWNDC;\n    wc.lpszClassName = CAMERA_WINDOW_CLASS;\n    wc.hCursor       = LoadCursor (NULL,IDC_ARROW);\n    wc.lpfnWndProc   = CamWndProc;\n    if (AfxRegisterClass(&wc) == FALSE)\n      Error (\"CCamWnd RegisterClass: failed\");\n  }\n\n  cs.lpszClass = CAMERA_WINDOW_CLASS;\n  cs.lpszName = \"CAM\";\n  if (cs.style != QE3_CHILDSTYLE)\n    cs.style = QE3_SPLITTER_STYLE;\n\n\tBOOL bResult = CWnd::PreCreateWindow(cs);\n\n  // See if the class already exists and if not then we need\n  // to register our new window class.\n  return bResult;\n\t\n}\n\n\nvoid CCamWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) \n{\n  g_pParentWnd->HandleKey(nChar, nRepCnt, nFlags);\n}\n\n\nbrush_t* g_pSplitList = NULL;\n\nvoid CCamWnd::OnPaint() \n{\n\tCPaintDC dc(this); // device context for painting\n  bool bPaint = true;\n  if (!qwglMakeCurrent( dc.m_hDC, g_qeglobals.d_hglrcBase ))\n  {\n    Sys_Printf(\"ERROR: wglMakeCurrent failed..\\n \");\n    Sys_Printf(\"Please restart Q3Radiant if the camera view is not working\\n\");\n  }\n  else\n  {\n    QE_CheckOpenGLForErrors();\n    g_pSplitList = NULL;\n    if (g_bClipMode)\n    {\n      if (g_Clip1.Set() && g_Clip2.Set())\n      {\n        g_pSplitList = ( (g_pParentWnd->ActiveXY()->GetViewType() == XZ) ? !g_bSwitch : g_bSwitch) ? &g_brBackSplits : &g_brFrontSplits;\n      }\n    }\n\t\tCam_Draw ();\n\t\tQE_CheckOpenGLForErrors();\n\t\tqwglSwapBuffers(dc.m_hDC);\n  }\n}\n\n\nvoid CCamWnd::SetXYFriend(CXYWnd * pWnd)\n{\n  m_pXYFriend = pWnd;\n}\n\nvoid CCamWnd::OnDestroy() \n{\n\tQEW_StopGL(GetSafeHwnd(), g_qeglobals.d_hglrcBase, g_qeglobals.d_hdcBase );\n\tCWnd::OnDestroy();\n}\n\nvoid CCamWnd::OnClose() \n{\n\tCWnd::OnClose();\n}\n\nextern void Select_ShiftTexture(int x, int y);\nextern void Select_RotateTexture(int amt);\nextern void Select_ScaleTexture(int x, int y);\nvoid CCamWnd::OnMouseMove(UINT nFlags, CPoint point) \n{\n  CRect r;\n  GetClientRect(r);\n  if (GetCapture() == this && (GetKeyState(VK_MENU) & 0x8000) && !((GetKeyState(VK_SHIFT) & 0x8000) || (GetKeyState(VK_CONTROL) & 0x8000)))\n  {\n    if (GetKeyState(VK_CONTROL) & 0x8000)\n      Select_RotateTexture(point.y - m_ptLastCursor.y);\n    else\n    if (GetKeyState(VK_SHIFT) & 0x8000)\n      Select_ScaleTexture(point.x - m_ptLastCursor.x, m_ptLastCursor.y - point.y);\n    else\n      Select_ShiftTexture(point.x - m_ptLastCursor.x, m_ptLastCursor.y - point.y);\n  }\n  else\n  {\n    Cam_MouseMoved(point.x, r.bottom - 1 - point.y, nFlags);\n  }\n  m_ptLastCursor = point;\n}\n\nvoid CCamWnd::OnLButtonDown(UINT nFlags, CPoint point) \n{\n  m_ptLastCursor = point;\n  OriginalMouseDown(nFlags, point);\n}\n\nvoid CCamWnd::OnLButtonUp(UINT nFlags, CPoint point) \n{\n  OriginalMouseUp(nFlags, point);\n}\n\nvoid CCamWnd::OnMButtonDown(UINT nFlags, CPoint point) \n{\n  OriginalMouseDown(nFlags, point);\n}\n\nvoid CCamWnd::OnMButtonUp(UINT nFlags, CPoint point) \n{\n  OriginalMouseUp(nFlags, point);\n}\n\nvoid CCamWnd::OnRButtonDown(UINT nFlags, CPoint point) \n{\n  OriginalMouseDown(nFlags, point);\n}\n\nvoid CCamWnd::OnRButtonUp(UINT nFlags, CPoint point) \n{\n  OriginalMouseUp(nFlags, point);\n}\n\nint CCamWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) \n{\n  if (CWnd::OnCreate(lpCreateStruct) == -1)\n\t\treturn -1;\n\n\tg_qeglobals.d_hdcBase = GetDC()->m_hDC;\n\tQEW_SetupPixelFormat(g_qeglobals.d_hdcBase, true);\n\n  if ((g_qeglobals.d_hglrcBase = qwglCreateContext(g_qeglobals.d_hdcBase)) == 0)\n\t  Error(\"wglCreateContext failed\");\n  \n  if (!qwglMakeCurrent(g_qeglobals.d_hdcBase, g_qeglobals.d_hglrcBase))\n\t  Error (\"wglMakeCurrent failed\");\n\n\n\t//\n\t// create GL font\n\t//\n  HFONT hfont = ::CreateFont(\n\t  12,\t// logical height of font \n\t\t 6,\t// logical average character width \n\t\t 0,\t// angle of escapement \n\t\t 0,\t// base-line orientation angle \n\t\t 0,\t// font weight \n\t\t 0,\t// italic attribute flag \n\t\t 0,\t// underline attribute flag \n\t\t 0,\t// strikeout attribute flag \n\t\t 0,\t// character set identifier \n\t\t 0,\t// output precision \n\t\t 0,\t// clipping precision \n\t\t 0,\t// output quality \n\t\t 0,\t// pitch and family \n\t\t \"system font\" // pointer to typeface name string \n\t\t \t);\n\n\tif (!hfont)\n\t  Error( \"couldn't create font\" );\n\n  ::SelectObject(g_qeglobals.d_hdcBase, hfont);\n\n\tif ((g_qeglobals.d_font_list = qglGenLists (256)) == 0)\n\t  Error( \"couldn't create font dlists\" );\n\t\t\t\n\t// create the bitmap display lists\n\t// we're making images of glyphs 0 thru 255\n  \n  if (g_PrefsDlg.m_bBuggyICD)\n  {\n\t  if ( !qwglUseFontBitmaps (g_qeglobals.d_hdcBase, 1, 255, g_qeglobals.d_font_list-1) )\n\t    Error( \"wglUseFontBitmaps faileD\" );\n  }\n  else\n  {\n\t  if ( !qwglUseFontBitmaps (g_qeglobals.d_hdcBase, 1, 255, g_qeglobals.d_font_list) )\n\t    Error( \"wglUseFontBitmaps faileD\" );\n  }\n\t\n\t// indicate start of glyph display lists\n\tqglListBase (g_qeglobals.d_font_list);\n\n\t// report OpenGL information\n\tSys_Printf (\"GL_VENDOR: %s\\n\", qglGetString (GL_VENDOR));\n\tSys_Printf (\"GL_RENDERER: %s\\n\", qglGetString (GL_RENDERER));\n\tSys_Printf (\"GL_VERSION: %s\\n\", qglGetString (GL_VERSION));\n\tSys_Printf (\"GL_EXTENSIONS: %s\\n\", qglGetString (GL_EXTENSIONS));\n\n  g_qeglobals.d_hwndCamera = GetSafeHwnd();\n\n\treturn 0;\n}\n\nvoid CCamWnd::OriginalMouseUp(UINT nFlags, CPoint point)\n{\n  CRect r;\n  GetClientRect(r);\n  Cam_MouseUp(point.x, r.bottom - 1 - point.y, nFlags);\n\tif (!(nFlags & (MK_LBUTTON|MK_RBUTTON|MK_MBUTTON)))\n  \tReleaseCapture ();\n}\n\nvoid CCamWnd::OriginalMouseDown(UINT nFlags, CPoint point)\n{\n  //if (GetTopWindow()->GetSafeHwnd() != GetSafeHwnd())\n  //  BringWindowToTop();\n  CRect r;\n  GetClientRect(r);\n  SetFocus();\n\tSetCapture();\n  //if (!(GetKeyState(VK_MENU) & 0x8000))\n\t  Cam_MouseDown (point.x, r.bottom - 1 - point.y, nFlags);\n}\n\nvoid CCamWnd::Cam_Init()\n{\n\t//m_Camera.draw_mode = cd_texture;\n\tm_Camera.timing = false;\n\tm_Camera.origin[0] = 0;\n\tm_Camera.origin[1] = 20;\n\tm_Camera.origin[2] = 46;\n\tm_Camera.color[0] = 0.3;\n\tm_Camera.color[1] = 0.3;\n\tm_Camera.color[2] = 0.3;\n}\n\nvoid CCamWnd::Cam_BuildMatrix()\n{\n\tfloat\txa, ya;\n\tfloat\tmatrix[4][4];\n\tint\t\ti;\n\n\txa = m_Camera.angles[0]/180*Q_PI;\n\tya = m_Camera.angles[1]/180*Q_PI;\n\n\t// the movement matrix is kept 2d\n\n  m_Camera.forward[0] = cos(ya);\n  m_Camera.forward[1] = sin(ya);\n  m_Camera.right[0] = m_Camera.forward[1];\n  m_Camera.right[1] = -m_Camera.forward[0];\n\n\tqglGetFloatv (GL_PROJECTION_MATRIX, &matrix[0][0]);\n\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tm_Camera.vright[i] = matrix[i][0];\n\t\tm_Camera.vup[i] = matrix[i][1];\n\t\tm_Camera.vpn[i] = matrix[i][2];\n\t}\n\n\tVectorNormalize (m_Camera.vright);\n\tVectorNormalize (m_Camera.vup);\n\tVectorNormalize (m_Camera.vpn);\n}\n\n\n\nvoid CCamWnd::Cam_ChangeFloor (qboolean up)\n{\n\tbrush_t\t*b;\n\tfloat\td, bestd, current;\n\tvec3_t\tstart, dir;\n\n\tstart[0] = m_Camera.origin[0];\n\tstart[1] = m_Camera.origin[1];\n\tstart[2] = 8192;\n\tdir[0] = dir[1] = 0;\n\tdir[2] = -1;\n\n\tcurrent = 8192 - (m_Camera.origin[2] - 48);\n\tif (up)\n\t\tbestd = 0;\n\telse\n\t\tbestd = 16384;\n\n\tfor (b=active_brushes.next ; b != &active_brushes ; b=b->next)\n\t{\n\t\tif ( b->pTerrain && !Terrain_Ray( start, dir, b, &d ) )\n\t\t\tcontinue;\n\t\tif ( !b->pTerrain && !Brush_Ray (start, dir, b, &d) )\n\t\t\tcontinue;\n\t\tif (up && d < current && d > bestd)\n\t\t\tbestd = d;\n\t\tif (!up && d > current && d < bestd)\n\t\t\tbestd = d;\n\t}\n\n\tif (bestd == 0 || bestd == 16384)\n\t\treturn;\n\n\tm_Camera.origin[2] += current - bestd;\n\tSys_UpdateWindows (W_CAMERA|W_Z_OVERLAY);\n}\n\n\nvoid CCamWnd::Cam_PositionDrag()\n{\n\tint\tx, y;\n\tSys_GetCursorPos (&x, &y);\n\tif (x != m_ptCursor.x || y != m_ptCursor.y)\n\t{\n\t\tx -= m_ptCursor.x;\n\t\tVectorMA (m_Camera.origin, x, m_Camera.vright, m_Camera.origin);\n\t\ty -= m_ptCursor.y;\n\t\tm_Camera.origin[2] -= y;\n    SetCursorPos(m_ptCursor.x, m_ptCursor.y);\n\t\tSys_UpdateWindows (W_CAMERA | W_XY_OVERLAY);\n\t}\n}\n\n\nvoid CCamWnd::Cam_MouseControl (float dtime)\n{\n\tint\t\txl, xh;\n\tint\t\tyl, yh;\n\tfloat\txf, yf;\n  if (g_PrefsDlg.m_nMouseButtons == 2)\n  {\n    if (m_nCambuttonstate != (MK_RBUTTON | MK_SHIFT))\n      return;\n  }\n  else\n  {\n\t  if (m_nCambuttonstate != MK_RBUTTON)\n      return;\n  }\n\n\txf = (float)(m_ptButton.x - m_Camera.width/2) / (m_Camera.width/2);\n\tyf = (float)(m_ptButton.y - m_Camera.height/2) / (m_Camera.height/2);\n\n\n\txl = m_Camera.width/3;\n\txh = xl*2;\n\tyl = m_Camera.height/3;\n\tyh = yl*2;\n\n  //Sys_Printf(\"xf-%f  yf-%f  xl-%i  xh-i%  yl-i%  yh-i%\\n\",xf,yf,xl,xh,yl,yh);\n#if 0\n\t// strafe\n\tif (buttony < yl && (buttonx < xl || buttonx > xh))\n\t\tVectorMA (camera.origin, xf*dtime*g_nMoveSpeed, camera.right, camera.origin);\n\telse\n#endif\n\t{\n\t\txf *= 1.0 - fabs(yf);\n\t\tif (xf < 0)\n\t\t{\n\t\t\txf += 0.1;\n\t\t\tif (xf > 0)\n\t\t\t\txf = 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\txf -= 0.1;\n\t\t\tif (xf < 0)\n\t\t\t\txf = 0;\n\t\t}\n\t\t\n\t\tVectorMA (m_Camera.origin, yf*dtime*g_nMoveSpeed, m_Camera.forward, m_Camera.origin);\n\t\tm_Camera.angles[YAW] += xf*-dtime*g_nAngleSpeed;\n\t}\n\n#if 0\n  if (g_PrefsDlg.m_bQE4Painting)\n  {\n    MSG msg;\n    if (::PeekMessage( &msg, NULL, 0, 0, PM_REMOVE )) \n    { \n      TranslateMessage(&msg);\n      DispatchMessage(&msg);\n    }\n  }\n#endif\n\n  int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);\n\tSys_UpdateWindows (nUpdate);\n  g_pParentWnd->PostMessage(WM_TIMER, 0, 0);\n\n}\n\n\n\nvoid CCamWnd::Cam_MouseDown(int x, int y, int buttons)\n{\n\tvec3_t\t\tdir;\n\tfloat\t\tf, r, u;\n\tint\t\t\ti;\n\n\t//\n\t// calc ray direction\n\t//\n\tu = (float)(y - m_Camera.height/2) / (m_Camera.width/2);\n\tr = (float)(x - m_Camera.width/2) / (m_Camera.width/2);\n\tf = 1;\n\n\tfor (i=0 ; i<3 ; i++)\n\t\tdir[i] = m_Camera.vpn[i] * f + m_Camera.vright[i] * r + m_Camera.vup[i] * u;\n\tVectorNormalize (dir);\n\n\tGetCursorPos(&m_ptCursor);\n\n\tm_nCambuttonstate = buttons;\n\tm_ptButton.x = x;\n\tm_ptButton.y = y;\n\n\t// LBUTTON = manipulate selection\n\t// shift-LBUTTON = select\n\t// middle button = grab texture\n\t// ctrl-middle button = set entire brush to texture\n\t// ctrl-shift-middle button = set single face to texture\n\tint nMouseButton = g_PrefsDlg.m_nMouseButtons == 2 ? MK_RBUTTON : MK_MBUTTON;\n\tif ((buttons == MK_LBUTTON)\n\t\t        || (buttons == (MK_LBUTTON | MK_SHIFT))\n\t\t        || (buttons == (MK_LBUTTON | MK_CONTROL))\n\t\t        || (buttons == (MK_LBUTTON | MK_CONTROL | MK_SHIFT))\n\t\t        || (buttons == nMouseButton)\n\t\t        || (buttons == (nMouseButton|MK_SHIFT))\n\t\t        || (buttons == (nMouseButton|MK_CONTROL))\n\t\t        || (buttons == (nMouseButton|MK_SHIFT|MK_CONTROL)))\n\t{\n\n    if (g_PrefsDlg.m_nMouseButtons == 2 && (buttons == (MK_RBUTTON | MK_SHIFT)))\n\t\t  Cam_MouseControl (0.1);\n    else\n    {\n      // something global needs to track which window is responsible for stuff\n      Patch_SetView(W_CAMERA);\n\t\t  Drag_Begin (x, y, buttons, m_Camera.vright, m_Camera.vup,\tm_Camera.origin, dir);\n    }\n    return;\n\t}\n\n\tif (buttons == MK_RBUTTON)\n\t{\n\t\tCam_MouseControl (0.1);\n\t\treturn;\n\t}\n}\n\n\nvoid CCamWnd::Cam_MouseUp (int x, int y, int buttons)\n{\n\tm_nCambuttonstate = 0;\n\tDrag_MouseUp (buttons);\n}\n\n\nvoid CCamWnd::Cam_MouseMoved (int x, int y, int buttons)\n{\n\tm_nCambuttonstate = buttons;\n\tif (!buttons) {\n\t\tif ( ( g_qeglobals.d_select_mode == sel_terrainpoint ) || ( g_qeglobals.d_select_mode == sel_terraintexture ) ) {\n\t\t\tvec3_t\t\tdir;\n\t\t\tfloat\t\tf, r, u;\n\t\t\tint\t\t\ti;\n\n\t\t\t//\n\t\t\t// calc ray direction\n\t\t\t//\n\t\t\tu = (float)(y - m_Camera.height/2) / (m_Camera.width/2);\n\t\t\tr = (float)(x - m_Camera.width/2) / (m_Camera.width/2);\n\t\t\tf = 1;\n\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t\tdir[i] = m_Camera.vpn[i] * f + m_Camera.vright[i] * r + m_Camera.vup[i] * u;\n\t\t\tVectorNormalize (dir);\n\n\t\t\tm_ptButton.x = x;\n\t\t\tm_ptButton.y = y;\n\n\t\t\tTerrain_SelectPointByRay( m_Camera.origin, dir, buttons );\n\n\t\t\tSys_UpdateWindows(W_CAMERA);\n\t\t}\n\n\t\treturn;\n\t}\n\tm_ptButton.x = x;\n\tm_ptButton.y = y;\n\n\tif (buttons == (MK_RBUTTON|MK_CONTROL) )\n\t{\n\t\tCam_PositionDrag ();\n\t\tSys_UpdateWindows (W_XY|W_CAMERA|W_Z);\n\t\treturn;\n\t}\n\n\tGetCursorPos(&m_ptCursor);\n\n\tif (buttons & (MK_LBUTTON | MK_MBUTTON) )\n\t{\n\t\tDrag_MouseMoved (x, y, buttons);\n\t\tSys_UpdateWindows (W_XY|W_CAMERA|W_Z);\n\t}\n}\n\n\nvoid CCamWnd::InitCull()\n{\n\tint\t\ti;\n\n\tVectorSubtract (m_Camera.vpn, m_Camera.vright, m_vCull1);\n\tVectorAdd (m_Camera.vpn, m_Camera.vright, m_vCull2);\n\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tif (m_vCull1[i] > 0)\n\t\t\tm_nCullv1[i] = 3+i;\n\t\telse\n\t\t\tm_nCullv1[i] = i;\n\t\tif (m_vCull2[i] > 0)\n\t\t\tm_nCullv2[i] = 3+i;\n\t\telse\n\t\t\tm_nCullv2[i] = i;\n\t}\n}\n\nqboolean CCamWnd::CullBrush (brush_t *b)\n{\n\tint\t\ti;\n\tvec3_t\tpoint;\n\tfloat\td;\n\n\tif (g_PrefsDlg.m_bCubicClipping)\n\t{\n\t\tfloat fLevel = g_PrefsDlg.m_nCubicScale * 64;\n\n\t\tpoint[0] = m_Camera.origin[0] - fLevel;\n\t\tpoint[1] = m_Camera.origin[1] - fLevel;\n\t\tpoint[2] = m_Camera.origin[2] - fLevel;\n\n\t\tfor (i=0; i<3; i++)\n\t\t\tif (b->mins[i] < point[i] && b->maxs[i] < point[i])\n\t\t\t\treturn true;\n\n\t\tpoint[0] = m_Camera.origin[0] + fLevel;\n\t\tpoint[1] = m_Camera.origin[1] + fLevel;\n\t\tpoint[2] = m_Camera.origin[2] + fLevel;\n\t\n\t\tfor (i=0; i<3; i++)\n\t\t\tif (b->mins[i] > point[i] && b->maxs[i] > point[i])\n\t\t\t\treturn true;\n\t}\n\n\n\tfor (i=0 ; i<3 ; i++)\n\t\tpoint[i] = b->mins[m_nCullv1[i]] - m_Camera.origin[i];\n\n\td = DotProduct (point, m_vCull1);\n\tif (d < -1)\n\t\treturn true;\n\n\tfor (i=0 ; i<3 ; i++)\n\t\tpoint[i] = b->mins[m_nCullv2[i]] - m_Camera.origin[i];\n\n\td = DotProduct (point, m_vCull2);\n\tif (d < -1)\n\t\treturn true;\n\n\treturn false;\n}\n\n#if 0\nvoid CCamWnd::DrawLightRadius(brush_t* pBrush)\n{\n  // if lighting\n  int nRadius = Brush_LightRadius(pBrush);\n  if (nRadius > 0)\n  {\n    Brush_SetLightColor(pBrush);\n\t  qglEnable (GL_BLEND);\n\t  qglPolygonMode (GL_FRONT_AND_BACK, GL_LINE);\n\t  qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\n\t  qglDisable (GL_TEXTURE_2D);\n\n    qglEnable(GL_TEXTURE_2D);\n    qglDisable(GL_BLEND);\n    qglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);\n  }\n}\n#endif\n\n/*\n==============\nCam_Draw\n==============\n*/\n\nvoid CCamWnd::Cam_Draw()\n{\n\tbrush_t\t*brush;\n\tface_t\t*face;\n\tfloat\tscreenaspect;\n\tfloat\tyfov;\n\tdouble\tstart, end;\n\tint\t\ti;\n\n\t/*\n  FILE *f = fopen(\"g:/nardo/raduffy/editorhack.dat\", \"w\");\n  if (f != NULL) {\n    fwrite(&m_Camera.origin[0], sizeof(float), 1, f);\n    fwrite(&m_Camera.origin[1], sizeof(float), 1, f);\n    fwrite(&m_Camera.origin[2], sizeof(float), 1, f);\n\t\tfwrite(&m_Camera.angles[PITCH], sizeof(float), 1, f);\n\t\tfwrite(&m_Camera.angles[YAW], sizeof(float), 1, f);\n    fclose(f);\n  }\n\t*/\n\t\n\tif (!active_brushes.next)\n\t\treturn;\t// not valid yet\n\t\n\tif (m_Camera.timing)\n\t\tstart = Sys_DoubleTime ();\n\t\n\t//\n\t// clear\n\t//\n\tQE_CheckOpenGLForErrors();\n\t\n\tqglViewport(0, 0, m_Camera.width, m_Camera.height);\n\tqglScissor(0, 0, m_Camera.width, m_Camera.height);\n\tqglClearColor (g_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][0],\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][1],\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][2], 0);\n\tqglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);\n\t\n\t//\n\t// set up viewpoint\n\t//\n\tvec5_t lightPos;\n\t\n\tif (g_PrefsDlg.m_bGLLighting)\n\t{\n\t\tqglEnable(GL_LIGHTING);\n\t\t//qglEnable(GL_LIGHT0);\n\t\t\n\t\tlightPos[0] = lightPos[1] = lightPos[2] = 3.5;\n\t\tlightPos[3] = 1.0;\n\t\tqglLightModelfv(GL_LIGHT_MODEL_AMBIENT, lightPos);\n\t\t//qglLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);\n\t\t//lightPos[0] = lightPos[1] = lightPos[2] = 3.5;\n    //qglLightfv(GL_LIGHT0, GL_AMBIENT, lightPos);\n\t}\n\telse\n\t{\n\t\tqglDisable(GL_LIGHTING);\n\t}\n\t\n\tqglMatrixMode(GL_PROJECTION);\n\tqglLoadIdentity ();\n\t\n\tscreenaspect = (float)m_Camera.width / m_Camera.height;\n\tyfov = 2*atan((float)m_Camera.height / m_Camera.width)*180/Q_PI;\n\tqgluPerspective (yfov,  screenaspect,  2,  8192);\n\t\n\tqglRotatef (-90,  1, 0, 0);\t    // put Z going up\n\tqglRotatef (90,  0, 0, 1);\t    // put Z going up\n\tqglRotatef (m_Camera.angles[0],  0, 1, 0);\n\tqglRotatef (-m_Camera.angles[1],  0, 0, 1);\n\tqglTranslatef (-m_Camera.origin[0],  -m_Camera.origin[1],  -m_Camera.origin[2]);\n\t\n\tCam_BuildMatrix ();\n\t\n\t\n\t//if (m_Camera.draw_mode == cd_light)\n\t//{\n//\tif (g_PrefsDlg.m_bGLLighting)\n//\t{\n//\t\tVectorCopy(m_Camera.origin, lightPos);\n//\t\tlightPos[3] = 1;\n//\t\tqglLightfv(GL_LIGHT0, GL_POSITION, lightPos);\n//\t}\n\t//}\n\t\n\tInitCull ();\n\t\n\t//\n\t// draw stuff\n\t//\n\tGLfloat lAmbient[] = {1.0, 1.0, 1.0, 1.0};\n\t\n\tswitch (m_Camera.draw_mode)\n\t{\n\tcase cd_wire:\n\t\tqglPolygonMode (GL_FRONT_AND_BACK, GL_LINE);\n\t\tqglDisable(GL_TEXTURE_2D);\n\t\tqglDisable(GL_TEXTURE_1D);\n\t\tqglDisable(GL_BLEND);\n\t\tqglDisable(GL_DEPTH_TEST);\n\t\tqglColor3f(1.0, 1.0, 1.0);\n\t\t//\t\tqglEnable (GL_LINE_SMOOTH);\n\t\tbreak;\n\t\t\n\tcase cd_solid:\n\t\tqglCullFace(GL_FRONT);\n\t\tqglEnable(GL_CULL_FACE);\n\t\tqglShadeModel (GL_FLAT);\n\t\tqglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);\n\t\tqglDisable(GL_TEXTURE_2D);\n\t\tqglDisable(GL_BLEND);\n\t\tqglEnable(GL_DEPTH_TEST);\n\t\tqglDepthFunc (GL_LEQUAL);\n\t\tbreak;\n\t\t\n\tcase cd_texture:\n\t\tqglCullFace(GL_FRONT);\n\t\tqglEnable(GL_CULL_FACE);\n\t\tqglShadeModel (GL_FLAT);\n\t\tqglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);\n\t\tqglEnable(GL_TEXTURE_2D);\n\t\tqglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);\n\t\tqglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);\n\t\tqglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);\n\t\tqglDisable(GL_BLEND);\n\t\tqglEnable(GL_DEPTH_TEST);\n\t\tqglDepthFunc (GL_LEQUAL);\n\t\tbreak;\n\t\t\n\tcase cd_blend:\n\t\tqglCullFace(GL_FRONT);\n\t\tqglEnable(GL_CULL_FACE);\n\t\tqglShadeModel (GL_FLAT);\n\t\tqglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);\n\t\tqglEnable(GL_TEXTURE_2D);\n\t\tqglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);\n\t\tqglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);\n\t\tqglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);\n\t\tqglDisable(GL_DEPTH_TEST);\n\t\tqglEnable (GL_BLEND);\n\t\tqglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\n\t\tbreak;\n\t}\n\t\n\tqglMatrixMode(GL_TEXTURE);\n\t\n\tm_nNumTransBrushes = 0;\n\t\n\tfor (brush = active_brushes.next ; brush != &active_brushes ; brush=brush->next)\n\t{\n\t\t//DrawLightRadius(brush);\n\t\t\n\t\tif (CullBrush (brush))\n\t\t\tcontinue;\n\t\t\n\t\tif (FilterBrush (brush))\n\t\t\tcontinue;\n\t\t\n\t\tif ((brush->brush_faces->texdef.flags & (SURF_TRANS33 | SURF_TRANS66)) || (brush->brush_faces->d_texture->bFromShader && brush->brush_faces->d_texture->fTrans != 1.0))\n\t\t{\n\t\t\tm_TransBrushes [ m_nNumTransBrushes++ ] = brush;\n\t\t} \n\t\telse \n\t\t{\n\t\t\t//--      if (brush->patchBrush)\n\t\t\t//--\t\t\t  m_TransBrushes [ m_nNumTransBrushes++ ] = brush;\n\t\t\t//--      else\n\t\t\tBrush_Draw(brush);\n\t\t}\n\t\t\n\t\t\n\t}\n\t\n\tif (g_PrefsDlg.m_bGLLighting)\n\t{\n\t\tqglDisable (GL_LIGHTING);\n\t}\n\t\n\t//\n\t//qglDepthMask ( 0 ); // Don't write to depth buffer\n\tqglEnable ( GL_BLEND );\n\tqglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\n\tfor ( i = 0; i < m_nNumTransBrushes; i++ ) \n\t\tBrush_Draw (m_TransBrushes[i]);\n\t\n\t//qglDepthMask ( 1 ); // Ok, write now\n\t\n\tqglMatrixMode(GL_PROJECTION);\n\t\n\t//\n\t// now draw selected brushes\n\t//\n\t\n\tif (g_PrefsDlg.m_bGLLighting)\n\t{\n\t\tqglEnable (GL_LIGHTING);\n\t}\n\t\n\tqglTranslatef (g_qeglobals.d_select_translate[0], g_qeglobals.d_select_translate[1], g_qeglobals.d_select_translate[2]);\n\tqglMatrixMode(GL_TEXTURE);\n\t\n\tbrush_t* pList = (g_bClipMode && g_pSplitList) ? g_pSplitList : &selected_brushes;\n\t// draw normally\n\tfor (brush = pList->next ; brush != pList ; brush=brush->next)\n\t{\n\t\t//DrawLightRadius(brush);\n\t\t//if (brush->patchBrush && g_qeglobals.d_select_mode == sel_curvepoint)\n\t\t//  continue;\n\t\t\n\t\tBrush_Draw(brush);\n\t}\n\t\n\t// blend on top\n\tqglMatrixMode(GL_PROJECTION);\n\t\n\t\n\tqglDisable (GL_LIGHTING);\n\tqglColor4f(1.0, 0.0, 0.0, 0.3);\n\tqglEnable (GL_BLEND);\n\tqglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);\n\tqglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\n\tqglDisable (GL_TEXTURE_2D);\n\tfor (brush = pList->next ; brush != pList ; brush=brush->next)\n\t{\n\t\tif ( (brush->patchBrush && g_qeglobals.d_select_mode == sel_curvepoint) || \n\t\t\t(brush->terrainBrush && g_qeglobals.d_select_mode == sel_terrainpoint) )\n\t\t\tcontinue;\n\t\t\n\t\tfor (face=brush->brush_faces ; face ; face=face->next)\n\t\t\tFace_Draw( face );\n\t}\n\t\n \n  int nCount = g_ptrSelectedFaces.GetSize();\n\tif (nCount > 0)\n  {\n    for (int i = 0; i < nCount; i++)\n    {\n      face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(i));\n\t\t  Face_Draw(selFace);\n    }\n  }\n\t\t\n\t// non-zbuffered outline\n\t\n\tqglDisable (GL_BLEND);\n\tqglDisable (GL_DEPTH_TEST);\n\tqglPolygonMode (GL_FRONT_AND_BACK, GL_LINE);\n\tqglColor3f (1, 1, 1);\n\tfor (brush = pList->next ; brush != pList ; brush=brush->next)\n\t{\n\t\tif (g_qeglobals.dontDrawSelectedOutlines || (brush->patchBrush && g_qeglobals.d_select_mode == sel_curvepoint) ||\n\t\t\t(brush->terrainBrush && g_qeglobals.d_select_mode == sel_terrainpoint))\n\t\t\tcontinue;\n\t\t\n\t\tfor (face=brush->brush_faces ; face ; face=face->next)\n\t\t\tFace_Draw( face );\n\t}\n\t\n\t\n\t// edge / vertex flags\n\t\n\tif (g_qeglobals.d_select_mode == sel_vertex)\n\t{\n\t\tqglPointSize (4);\n\t\tqglColor3f (0,1,0);\n\t\tqglBegin (GL_POINTS);\n\t\tfor (i=0 ; i<g_qeglobals.d_numpoints ; i++)\n\t\t\tqglVertex3fv (g_qeglobals.d_points[i]);\n\t\tqglEnd ();\n\t\tqglPointSize (1);\n\t}\n\telse if (g_qeglobals.d_select_mode == sel_edge)\n\t{\n\t\tfloat\t*v1, *v2;\n\t\t\n\t\tqglPointSize (4);\n\t\tqglColor3f (0,0,1);\n\t\tqglBegin (GL_POINTS);\n\t\tfor (i=0 ; i<g_qeglobals.d_numedges ; i++)\n\t\t{\n\t\t\tv1 = g_qeglobals.d_points[g_qeglobals.d_edges[i].p1];\n\t\t\tv2 = g_qeglobals.d_points[g_qeglobals.d_edges[i].p2];\n\t\t\tqglVertex3f ( (v1[0]+v2[0])*0.5,(v1[1]+v2[1])*0.5,(v1[2]+v2[2])*0.5);\n\t\t}\n\t\tqglEnd ();\n\t\tqglPointSize (1);\n\t}\n\t\n\t\n\tg_splineList->draw(static_cast<qboolean>(g_qeglobals.d_select_mode == sel_addpoint || g_qeglobals.d_select_mode == sel_editpoint));\n\tif (g_qeglobals.selectObject && (g_qeglobals.d_select_mode == sel_addpoint || g_qeglobals.d_select_mode == sel_editpoint)) {\n\t\tg_qeglobals.selectObject->drawSelection();\n\t}\n\n\t//\n\t// draw pointfile\n\t//\n\n\tqglEnable(GL_DEPTH_TEST);\n\t\n\n\tDrawPathLines ();\n\t\n\t\n\t\n\tif (g_qeglobals.d_pointfile_display_list)\n\t{\n\t\tPointfile_Draw();\n\t\t//\t\tglCallList (g_qeglobals.d_pointfile_display_list);\n\t}\n\t\n\t// bind back to the default texture so that we don't have problems\n\t// elsewhere using/modifying texture maps between contexts\n\tqglBindTexture( GL_TEXTURE_2D, 0 );\n\t\n#if 0\n\t// area selection hack\n\tif (g_qeglobals.d_select_mode == sel_area)\n\t{\n\t\tqglEnable (GL_BLEND);\n\t\tqglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\n\t\tqglColor4f(0.0, 0.0, 1.0, 0.25);\n\t\tqglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);\n\t\tqglRectfv(g_qeglobals.d_vAreaTL, g_qeglobals.d_vAreaBR);\n\t\tqglDisable (GL_BLEND);\n\t}\n#endif\n\t\n\tqglFinish();\n\tQE_CheckOpenGLForErrors();\n\t//\tSys_EndWait();\n\tif (m_Camera.timing)\n\t{\n\t\tend = Sys_DoubleTime ();\n\t\tSys_Printf (\"Camera: %i ms\\n\", (int)(1000*(end-start)));\n\t}\n}\n\n\nvoid CCamWnd::OnSize(UINT nType, int cx, int cy) \n{\n\tCWnd::OnSize(nType, cx, cy);\n  CRect rect;\n  GetClientRect(rect);\n\tm_Camera.width = rect.right;\n\tm_Camera.height = rect.bottom;\n\tInvalidateRect(NULL, false);\n}\n\nvoid CCamWnd::BenchMark()\n{\n\tPAINTSTRUCT\tps;\n  CRect rct;\n  GetWindowRect(rct);\n  long lStyle = ::GetWindowLong(GetSafeHwnd(), GWL_STYLE);\n  ::SetWindowLong(GetSafeHwnd(), GWL_STYLE, QE3_CHILDSTYLE);\n  CWnd* pParent = GetParent();\n  SetParent(g_pParentWnd);\n  MoveWindow(CRect(30, 30, 400, 400), TRUE);\n\n  BeginPaint(&ps);\n  if (!qwglMakeCurrent(ps.hdc, g_qeglobals.d_hglrcBase))\n\t\tError (\"wglMakeCurrent failed in Benchmark\");\n  \n\tqglDrawBuffer (GL_FRONT);\n\tdouble dStart = Sys_DoubleTime ();\n\tfor (int i=0 ; i < 100 ; i++)\n\t{\n\t\tm_Camera.angles[YAW] = i*4;\n\t\tCam_Draw();\n\t}\n\tqwglSwapBuffers(ps.hdc);\n\tqglDrawBuffer (GL_BACK);\n\tdouble dEnd = Sys_DoubleTime ();\n\tEndPaint(&ps);\n\tSys_Printf (\"%5.2f seconds\\n\", dEnd - dStart);\n  ::SetWindowLong(GetSafeHwnd(), GWL_STYLE, lStyle);\n  SetParent(pParent);\n  MoveWindow(rct, TRUE);\n}\n\nvoid CCamWnd::ReInitGL()\n{\n\n  qwglMakeCurrent(0,0);\n\tQEW_SetupPixelFormat(GetDC()->m_hDC, true);\n  if (!qwglMakeCurrent(g_qeglobals.d_hdcBase, g_qeglobals.d_hglrcBase))\n\t  Error (\"wglMakeCurrent failed\");\n\n  return;\n\n  long lStyle = ::GetWindowLong(GetSafeHwnd(), GWL_STYLE);\n  int nID = ::GetWindowLong(GetSafeHwnd(), GWL_ID);\n  CWnd* pParent = GetParent();\n  CRect rctClient;\n  GetClientRect(rctClient);\n  DestroyWindow();\n  Create(CAMERA_WINDOW_CLASS, \"\", lStyle, rctClient, pParent, nID);\n}\n\nvoid CCamWnd::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) \n{\n  g_pParentWnd->HandleKey(nChar, nRepCnt, nFlags, false);\n}\n\n// Timo\n// brush primitive texture shifting, using camera view to select translations :\nvoid CCamWnd::ShiftTexture_BrushPrimit(face_t *f, int x, int y)\n{\n\tvec3_t texS,texT;\n\tvec3_t viewX,viewY;\n\tint XS,XT,YS,YT;\n\tint outS,outT;\n#ifdef _DEBUG\n\tif (!g_qeglobals.m_bBrushPrimitMode)\n\t{\n\t\tSys_Printf(\"Warning : unexpected call to CCamWnd::ShiftTexture_BrushPrimit with brush primitive mode disbaled\\n\");\n\t\treturn;\n\t}\n#endif\n\t// compute face axis base\n\tComputeAxisBase( f->plane.normal, texS, texT );\n\t// compute camera view vectors\n\tVectorCopy( m_Camera.vup, viewY );\n\tVectorCopy( m_Camera.vright, viewX );\n\t// compute best vectors\n\tComputeBest2DVector( viewX, texS, texT, XS, XT );\n\tComputeBest2DVector( viewY, texS, texT, YS, YT );\n\t// check this is not a degenerate case\n\tif ( ( XS == YS ) && ( XT == YT ) )\n\t{\n#ifdef _DEBUG\n\t\tSys_Printf(\"Warning : degenerate best vectors axis base in CCamWnd::ShiftTexture_BrushPrimit\\n\");\n#endif\n\t\t// forget it\n\t\tSelect_ShiftTexture_BrushPrimit( f, x, y );\n\t\treturn;\n\t}\n\t// compute best fitted translation in face axis base\n\toutS = XS*x + YS*y;\n\toutT = XT*x + YT*y;\n\t// call actual texture shifting code\n\tSelect_ShiftTexture_BrushPrimit( f, outS, outT );\n}\n"
  },
  {
    "path": "q3radiant/CamWnd.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_CAMWND_H__44B4BA03_781B_11D1_B53C_00AA00A410FC__INCLUDED_)\n#define AFX_CAMWND_H__44B4BA03_781B_11D1_B53C_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// CamWnd.h : header file\n//\n/////////////////////////////////////////////////////////////////////////////\n// CCamWnd window\nclass CXYWnd;\n\nclass CCamWnd : public CWnd\n{\n  DECLARE_DYNCREATE(CCamWnd);\n// Construction\npublic:\n\tCCamWnd();\n\n// Attributes\npublic:\n\n// Operations\npublic:\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CCamWnd)\n\tprotected:\n\tvirtual BOOL PreCreateWindow(CREATESTRUCT& cs);\n\t//}}AFX_VIRTUAL\n\n// Implementation\npublic:\n\tvoid ShiftTexture_BrushPrimit(face_t *f, int x, int y);\n\tvoid ReInitGL();\n\tvoid BenchMark();\n\tCXYWnd* m_pXYFriend;\n\tvoid SetXYFriend(CXYWnd* pWnd);\n\tvirtual ~CCamWnd();\n  camera_t& Camera(){return m_Camera;};\n  void Cam_MouseControl(float dtime);\n  void Cam_ChangeFloor(qboolean up);\n\nprotected:\n  void Cam_Init();\n  void Cam_BuildMatrix();\n  void Cam_PositionDrag();\n  void Cam_MouseDown(int x, int y, int buttons);\n  void Cam_MouseUp (int x, int y, int buttons);\n  void Cam_MouseMoved (int x, int y, int buttons);\n  void InitCull();\n  qboolean CullBrush (brush_t *b);\n  void Cam_Draw();\n\n\n  brush_t* m_TransBrushes[MAX_MAP_BRUSHES];\n  int m_nNumTransBrushes;\n  camera_t m_Camera;\n  int\tm_nCambuttonstate;\n  CPoint m_ptButton;\n  CPoint m_ptCursor;\n  CPoint m_ptLastCursor;\n  face_t* m_pSide_select;\n  vec3_t m_vCull1;\n  vec3_t m_vCull2;\n  int m_nCullv1[3];\n  int m_nCullv2[3];\n  bool m_bClipMode;\n\n\t// Generated message map functions\nprotected:\n\tvoid OriginalMouseDown(UINT nFlags, CPoint point);\n\tvoid OriginalMouseUp(UINT nFlags, CPoint point);\n\t//{{AFX_MSG(CCamWnd)\n\tafx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);\n\tafx_msg void OnPaint();\n\tafx_msg void OnDestroy();\n\tafx_msg void OnClose();\n\tafx_msg void OnMouseMove(UINT nFlags, CPoint point);\n\tafx_msg void OnLButtonDown(UINT nFlags, CPoint point);\n\tafx_msg void OnLButtonUp(UINT nFlags, CPoint point);\n\tafx_msg void OnMButtonDown(UINT nFlags, CPoint point);\n\tafx_msg void OnMButtonUp(UINT nFlags, CPoint point);\n\tafx_msg void OnRButtonDown(UINT nFlags, CPoint point);\n\tafx_msg void OnRButtonUp(UINT nFlags, CPoint point);\n\tafx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);\n\tafx_msg void OnSize(UINT nType, int cx, int cy);\n\tafx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n/////////////////////////////////////////////////////////////////////////////\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_CAMWND_H__44B4BA03_781B_11D1_B53C_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/CapDialog.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// CapDialog.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"CapDialog.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CCapDialog dialog\n\n\nCCapDialog::CCapDialog(CWnd* pParent /*=NULL*/)\n\t: CDialog(CCapDialog::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CCapDialog)\n\tm_nCap = 0;\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CCapDialog::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CCapDialog)\n\tDDX_Radio(pDX, IDC_RADIO_CAP, m_nCap);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CCapDialog, CDialog)\n\t//{{AFX_MSG_MAP(CCapDialog)\n\t\t// NOTE: the ClassWizard will add message map macros here\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CCapDialog message handlers\n"
  },
  {
    "path": "q3radiant/CapDialog.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_CAPDIALOG_H__10637162_2BD2_11D2_B030_00AA00A410FC__INCLUDED_)\n#define AFX_CAPDIALOG_H__10637162_2BD2_11D2_B030_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// CapDialog.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CCapDialog dialog\n\nclass CCapDialog : public CDialog\n{\n// Construction\npublic:\n  static enum {BEVEL = 0, ENDCAP, IBEVEL, IENDCAP};\n\tCCapDialog(CWnd* pParent = NULL);   // standard constructor\n\n  int getCapType() {return m_nCap;};\n// Dialog Data\n\t//{{AFX_DATA(CCapDialog)\n\tenum { IDD = IDD_DIALOG_CAP };\n\tint\t\tm_nCap;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CCapDialog)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CCapDialog)\n\t\t// NOTE: the ClassWizard will add member functions here\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_CAPDIALOG_H__10637162_2BD2_11D2_B030_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/CharBuffer.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __CHARBUFFER_HPP\n#define __CHARBUFFER_HPP\n\nclass CCharBuffer\n{\n    char* m_pCharBuffer;\n    unsigned m_uSize;\n  \n  public:\n    CCharBuffer();\n\n    CCharBuffer(unsigned uSize);\n  \n    CCharBuffer(const char* pString);\n  \n    CCharBuffer(const CCharBuffer& rhs);\n  \n   ~CCharBuffer();\n\n    char* Allocate(uint uSize);\n\n    void DeAllocate();\n\n    size_t StringLength()\n      { return strlen(m_pCharBuffer); }\n  \n    void StripTrailing(char c, int nLen);\n  \n    char& operator *()\n      { return *m_pCharBuffer; }\n  \n    char& operator *() const\n      { return *const_cast<CCharBuffer*>(this)->m_pCharBuffer; }\n  \n    operator void*()\n      { return m_pCharBuffer; }\n  \n    operator char*()\n      { return m_pCharBuffer; }\n  \n    operator const char*()\n      { return reinterpret_cast<const char*>(m_pCharBuffer); }\n  \n    operator unsigned char*()\n      { return reinterpret_cast<unsigned char*>(m_pCharBuffer); }\n  \n    operator const unsigned char*()\n      { return reinterpret_cast<const unsigned char*>(m_pCharBuffer); }\n  \n    unsigned SizeOf()\n      { return m_uSize; }\n  \n    CCharBuffer& operator =(const CCharBuffer& rhs);\n  \n    CCharBuffer& operator =(const char* pString);\n  \n    bool operator ==(const CCharBuffer& rhs) const\n      { return strcmp(m_pCharBuffer, rhs.m_pCharBuffer) == 0; }\n  \n    bool operator ==(char* pString) const\n      { return strcmp(m_pCharBuffer, pString) == 0; }\n  \n    bool operator ==(const char* pString) const\n      { return strcmp(m_pCharBuffer, pString) == 0; }\n  \n    bool operator !=(CCharBuffer& rhs) const\n      { return strcmp(m_pCharBuffer, rhs.m_pCharBuffer) != 0; }\n  \n    bool operator !=(char* pString) const\n      { return strcmp(m_pCharBuffer, pString) != 0; }\n  \n    bool operator !=(const char* pString) const\n      { return strcmp(m_pCharBuffer, pString) != 0; }\n  \n    char& operator [](int nIndex)\n      { return m_pCharBuffer[nIndex]; }\n  \n    char& operator [](int nIndex) const\n      { return m_pCharBuffer[nIndex]; }\n  \n    char* Fill(char FillChar)\n      { memset(m_pCharBuffer, FillChar, m_uSize-1); return m_pCharBuffer; }\n};\n//\n//-----------------------------------------------------------------------------\n#endif // __CCHARBUFFER_HPP\n//-----------------------------------------------------------------------------\n//\n"
  },
  {
    "path": "q3radiant/ChildFrm.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// ChildFrm.cpp : implementation of the CChildFrame class\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n\n#include \"ChildFrm.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CChildFrame\n\nIMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)\n\nBEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)\n\t//{{AFX_MSG_MAP(CChildFrame)\n\t\t// NOTE - the ClassWizard will add and remove mapping macros here.\n\t\t//    DO NOT EDIT what you see in these blocks of generated code !\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CChildFrame construction/destruction\n\nCChildFrame::CChildFrame()\n{\n\t// TODO: add member initialization code here\n\t\n}\n\nCChildFrame::~CChildFrame()\n{\n}\n\nBOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)\n{\n\t// TODO: Modify the Window class or styles here by modifying\n\t//  the CREATESTRUCT cs\n\n\treturn CMDIChildWnd::PreCreateWindow(cs);\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// CChildFrame diagnostics\n\n#ifdef _DEBUG\nvoid CChildFrame::AssertValid() const\n{\n\tCMDIChildWnd::AssertValid();\n}\n\nvoid CChildFrame::Dump(CDumpContext& dc) const\n{\n\tCMDIChildWnd::Dump(dc);\n}\n\n#endif //_DEBUG\n\n/////////////////////////////////////////////////////////////////////////////\n// CChildFrame message handlers\n"
  },
  {
    "path": "q3radiant/ChildFrm.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// ChildFrm.h : interface of the CChildFrame class\n//\n/////////////////////////////////////////////////////////////////////////////\n\n#if !defined(AFX_CHILDFRM_H__330BBF0C_731C_11D1_B539_00AA00A410FC__INCLUDED_)\n#define AFX_CHILDFRM_H__330BBF0C_731C_11D1_B539_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n\nclass CChildFrame : public CMDIChildWnd\n{\n\tDECLARE_DYNCREATE(CChildFrame)\npublic:\n\tCChildFrame();\n\n// Attributes\npublic:\n\n// Operations\npublic:\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CChildFrame)\n\tvirtual BOOL PreCreateWindow(CREATESTRUCT& cs);\n\t//}}AFX_VIRTUAL\n\n// Implementation\npublic:\n\tvirtual ~CChildFrame();\n#ifdef _DEBUG\n\tvirtual void AssertValid() const;\n\tvirtual void Dump(CDumpContext& dc) const;\n#endif\n\n// Generated message map functions\nprotected:\n\t//{{AFX_MSG(CChildFrame)\n\t\t// NOTE - the ClassWizard will add and remove member functions here.\n\t\t//    DO NOT EDIT what you see in these blocks of generated code!\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n/////////////////////////////////////////////////////////////////////////////\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_CHILDFRM_H__330BBF0C_731C_11D1_B539_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/CommandsDlg.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// CommandsDlg.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"CommandsDlg.h\"\n#include \"MainFrm.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CCommandsDlg dialog\n\n\nCCommandsDlg::CCommandsDlg(CWnd* pParent /*=NULL*/)\n\t: CDialog(CCommandsDlg::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CCommandsDlg)\n\t\t// NOTE: the ClassWizard will add member initialization here\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CCommandsDlg::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CCommandsDlg)\n\tDDX_Control(pDX, IDC_LIST_COMMANDS, m_lstCommands);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CCommandsDlg, CDialog)\n\t//{{AFX_MSG_MAP(CCommandsDlg)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CCommandsDlg message handlers\n\nBOOL CCommandsDlg::OnInitDialog() \n{\n\tCDialog::OnInitDialog();\n  m_lstCommands.SetTabStops(96);\n  int nCount = g_nCommandCount;\n\n  CFile fileout;\n  fileout.Open(\"c:/commandlist.txt\", CFile::modeCreate | CFile::modeWrite);\n  for (int n = 0; n < nCount; n++)\n  {\n    CString strLine;\n    char c = g_Commands[n].m_nKey;\n    CString strKeys = c;\n    for (int k = 0; k < g_nKeyCount; k++)\n    {\n      if (g_Keys[k].m_nVKKey == g_Commands[n].m_nKey)\n      {\n        strKeys = g_Keys[k].m_strName;\n        break;\n      }\n    }\n    CString strMod(\"\");\n    if (g_Commands[n].m_nModifiers & RAD_SHIFT)\n      strMod = \"Shift\";\n    if (g_Commands[n].m_nModifiers & RAD_ALT)\n      strMod += (strMod.GetLength() > 0) ? \" + Alt\" : \"Alt\";\n    if (g_Commands[n].m_nModifiers & RAD_CONTROL)\n      strMod += (strMod.GetLength() > 0) ? \" + Control\" : \"Control\";\n    if (strMod.GetLength() > 0)\n    {\n      strMod += \" + \";\n    }\n    strLine.Format(\"%s \\t%s%s\", g_Commands[n].m_strCommand, strMod, strKeys);\n    m_lstCommands.AddString(strLine);\n\n    strLine.Format(\"%s \\t\\t\\t%s%s\", g_Commands[n].m_strCommand, strMod, strKeys);\n\n    fileout.Write(strLine, strLine.GetLength());\n    fileout.Write(\"\\r\\n\", 2);\n  }\n\tfileout.Close();\n\treturn TRUE;  // return TRUE unless you set the focus to a control\n\t              // EXCEPTION: OCX Property Pages should return FALSE\n}\n"
  },
  {
    "path": "q3radiant/CommandsDlg.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_COMMANDSDLG_H__C80F6E42_8531_11D1_B548_00AA00A410FC__INCLUDED_)\n#define AFX_COMMANDSDLG_H__C80F6E42_8531_11D1_B548_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// CommandsDlg.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CCommandsDlg dialog\n\nclass CCommandsDlg : public CDialog\n{\n// Construction\npublic:\n\tCCommandsDlg(CWnd* pParent = NULL);   // standard constructor\n\n// Dialog Data\n\t//{{AFX_DATA(CCommandsDlg)\n\tenum { IDD = IDD_DLG_COMMANDLIST };\n\tCListBox\tm_lstCommands;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CCommandsDlg)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CCommandsDlg)\n\tvirtual BOOL OnInitDialog();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_COMMANDSDLG_H__C80F6E42_8531_11D1_B548_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/DRAG.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"stdafx.h\"\n#include \"qe3.h\"\n\n/*\n\n  drag either multiple brushes, or select plane points from\n  a single brush.\n\n*/\n\nqboolean\tdrag_ok;\nvec3_t\tdrag_xvec;\nvec3_t\tdrag_yvec;\n\nstatic\tint\tbuttonstate;\nint\tpressx, pressy;\nstatic\tvec3_t pressdelta;\nstatic\tvec3_t vPressStart;\nstatic\tint\tbuttonx, buttony;\n\n\n//int\t\tnum_move_points;\n//float\t*move_points[1024];\n\nint\t\tlastx, lasty;\n\nqboolean\tdrag_first;\n\n\nvoid\tAxializeVector (vec3_t v)\n{\n\tvec3_t\ta;\n\tfloat\to;\n\tint\t\ti;\n\n\tif (!v[0] && !v[1])\n\t\treturn;\n\tif (!v[1] && !v[2])\n\t\treturn;\n\tif (!v[0] && !v[2])\n\t\treturn;\n\n\tfor (i=0 ; i<3 ; i++)\n\t\ta[i] = fabs(v[i]);\n\tif (a[0] > a[1] && a[0] > a[2])\n\t\ti = 0;\n\telse if (a[1] > a[0] && a[1] > a[2])\n\t\ti = 1;\n\telse\n\t\ti = 2;\n\n\to = v[i];\n\tVectorCopy (vec3_origin, v);\n\tif (o<0)\n\t\tv[i] = -1;\n\telse\n\t\tv[i] = 1;\n\t\n}\n\n\n/*\n===========\nDrag_Setup\n===========\n*/\nvoid Drag_Setup (int x, int y, int buttons,\n\t\t   vec3_t xaxis, vec3_t yaxis,\n\t\t   vec3_t origin, vec3_t dir)\n{\n\ttrace_t\tt;\n\tface_t\t*f;\n\n\tdrag_first = true;\n\t\n\tVectorCopy (vec3_origin, pressdelta);\n\tpressx = x;\n\tpressy = y;\n\n\tVectorCopy (xaxis, drag_xvec);\n\tAxializeVector (drag_xvec);\n\tVectorCopy (yaxis, drag_yvec);\n\tAxializeVector (drag_yvec);\n\n\tif (g_qeglobals.d_select_mode == sel_addpoint) {\n\t\tif (g_qeglobals.selectObject) {\n\t\t\tg_qeglobals.selectObject->addPoint(origin[0], origin[1], origin[2]);\n\t\t} else {\n\t\t\tclearSelection();\n\t\t}\n\t\treturn;\n\t}\n\n\tif (g_qeglobals.d_select_mode == sel_editpoint) {\n\t \n\t\tif (g_qeglobals.selectObject) {\n\t\t\tif (g_qeglobals.selectObject->selectPointByRay(origin[0], origin[1], origin[2], dir[0], dir[1], dir[2], !(buttons == MK_SHIFT)) >= 0) {\n\t\t\t\tdrag_ok = true;\n\t\t\t} \n\t\t\treturn;\n\t\t} else {\n\t\t\tclearSelection();\n\t\t}\n\t\tSys_UpdateWindows(W_ALL);\n\t\tUndo_Start(\"drag object point\");\n\n\t\treturn;\n\t}\n\n\n\textern void SelectCurvePointByRay (vec3_t org, vec3_t dir, int buttons);\n\tif (g_qeglobals.d_select_mode == sel_curvepoint)\n\t{\n\t\t//if ((buttons == MK_LBUTTON))\n\t\t//  g_qeglobals.d_num_move_points = 0;\n\n\t\tSelectCurvePointByRay (origin, dir, buttons);\t\n\t\t\n\t\tif (g_qeglobals.d_num_move_points || g_qeglobals.d_select_mode == sel_area)\n\t\t{\n\t\t\tdrag_ok = true;\n\t\t}\n    \n\t\tSys_UpdateWindows(W_ALL);\n\n\t\tUndo_Start(\"drag curve point\");\n\t\tUndo_AddBrushList(&selected_brushes);\n\n\t\treturn;\n\t}\n\telse if (g_qeglobals.d_select_mode == sel_terrainpoint)\n\t{\n\t\tTerrain_SelectPointByRay( origin, dir, buttons );\n\t\t\n\t\tif (g_qeglobals.d_numterrapoints || g_qeglobals.d_select_mode == sel_area)\n\t\t{\n\t\t\tdrag_ok = true;\n\t\t}\n\n\t\tSys_UpdateWindows(W_ALL);\n\t\t\n\t\tUndo_Start(\"drag terrain point\");\n\t\tUndo_AddBrushList(&selected_brushes);\n\t\treturn;\n\t}\n\telse if (g_qeglobals.d_select_mode == sel_terraintexture)\n\t{\n\t\tTerrain_SelectPointByRay( origin, dir, buttons );\n\t\t\n\t\tif (g_qeglobals.d_numterrapoints || g_qeglobals.d_select_mode == sel_area)\n\t\t{\n\t\t\tdrag_ok = true;\n\t\t}\n\n\t\tSys_UpdateWindows(W_ALL);\n\t\t\n\t\tUndo_Start(\"drag terrain point\");\n\t\tUndo_AddBrushList(&selected_brushes);\n\t\treturn;\n\t}\n\telse\n\t{\n\t\tg_qeglobals.d_num_move_points = 0;\n\t}\n\n\tif (selected_brushes.next == &selected_brushes)\n\t{\n\t\t//in this case a new brush is created when the dragging\n\t\t//takes place in the XYWnd, An useless undo is created\n\t\t//when the dragging takes place in the CamWnd\n\t\tUndo_Start(\"create brush\");\n\n\t\tSys_Status(\"No selection to drag\\n\", 0);\n\t\treturn;\n\t}\n\n\n\tif (g_qeglobals.d_select_mode == sel_vertex)\n\t{\n\t\tSelectVertexByRay (origin, dir);\t\n\t\tif (g_qeglobals.d_num_move_points)\n\t\t{\n\t\t\tdrag_ok = true;\n\t\t\tUndo_Start(\"drag vertex\");\n\t\t\tUndo_AddBrushList(&selected_brushes);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif (g_qeglobals.d_select_mode == sel_edge)\n\t{\n\t\tSelectEdgeByRay (origin, dir);\t\n\t\tif (g_qeglobals.d_num_move_points)\n\t\t{\n\t\t\tdrag_ok = true;\n\t\t\tUndo_Start(\"drag edge\");\n\t\t\tUndo_AddBrushList(&selected_brushes);\n\t\t\treturn;\n\t\t}\n\t}\n\n\n\t//\n\t// check for direct hit first\n\t//\n\tt = Test_Ray (origin, dir, true);\n\tif (t.selected)\n\t{\n\t\tdrag_ok = true;\n\n\t\tUndo_Start(\"drag selection\");\n\t\tUndo_AddBrushList(&selected_brushes);\n\n\t\tif (buttons == (MK_LBUTTON|MK_CONTROL) )\n\t\t{\n\t\t\tSys_Printf (\"Shear dragging face\\n\");\n\t\t\tBrush_SelectFaceForDragging (t.brush, t.face, true);\n\t\t}\n\t\telse if (buttons == (MK_LBUTTON|MK_CONTROL|MK_SHIFT) )\n\t\t{\n\t\t\tSys_Printf (\"Sticky dragging brush\\n\");\n\t\t\tfor (f=t.brush->brush_faces ; f ; f=f->next)\n\t\t\t\tBrush_SelectFaceForDragging (t.brush, f, false);\n\t\t}\n\t\telse\n\t\t\tSys_Printf (\"Dragging entire selection\\n\");\n\t\t\n\t\treturn;\n\t}\n\n\tif (g_qeglobals.d_select_mode == sel_vertex || g_qeglobals.d_select_mode == sel_edge)\n\t\treturn;\n\n\t//\n\t// check for side hit\n\t//\n\t// multiple brushes selected?\n\tif (selected_brushes.next->next != &selected_brushes)\n\t{\n\t\t// yes, special handling\n\t\tbool bOK = (g_PrefsDlg.m_bALTEdge) ? (static_cast<bool>(::GetAsyncKeyState(VK_MENU))) : true;\n\t\tif (bOK)\n\t\t{\n\t\t\tfor (brush_t* pBrush = selected_brushes.next ; pBrush != &selected_brushes ; pBrush = pBrush->next)\n\t\t\t{\n\t\t\t\tif (buttons & MK_CONTROL)\n\t\t\t\t\tBrush_SideSelect (pBrush, origin, dir, true);\n\t\t\t\telse\n\t\t\t\t\tBrush_SideSelect (pBrush, origin, dir, false);\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tSys_Printf (\"press ALT to drag multiple edges\\n\");\n\t\t\treturn;\n\t\t}\n\t}\n\telse\n\t{\n\t\t// single select.. trying to drag fixed entities handle themselves and just move\n\t\tif (buttons & MK_CONTROL)\n\t\t\tBrush_SideSelect (selected_brushes.next, origin, dir, true);\n\t\telse\n\t\t\tBrush_SideSelect (selected_brushes.next, origin, dir, false);\n\t}\n\n\tSys_Printf (\"Side stretch\\n\");\n\tdrag_ok = true;\n\n\tUndo_Start(\"side stretch\");\n\tUndo_AddBrushList(&selected_brushes);\n}\n\nentity_t *peLink;\n\nvoid UpdateTarget(vec3_t origin, vec3_t dir)\n{\n\ttrace_t\tt;\n\tentity_t *pe;\n\tint i;\n\tchar sz[128];\n\n\tt = Test_Ray (origin, dir, 0);\n\n\tif (!t.brush)\n\t\treturn;\n\n\tpe = t.brush->owner;\n\n\tif (pe == NULL)\n\t\treturn;\n\n\t// is this the first?\n\tif (peLink != NULL)\n\t{\n\n\t\t// Get the target id from out current target\n\t\t// if there is no id, make one\n\n\t\ti = IntForKey(pe, \"target\");\n\t\tif (i <= 0)\n\t\t{\n\t\t\ti = GetUniqueTargetId(1);\n\t\t\tsprintf(sz, \"%d\", i);\n\n\t\t\tSetKeyValue(pe, \"target\", sz);\n\t\t}\n\n\t\t// set the target # into our src\n\n\t\tsprintf(sz, \"%d\", i);\n\t\tSetKeyValue(peLink, \"targetname\", sz);\n\n\t\tSys_UpdateWindows(W_ENTITY);\n\n\t}\n\n\t// promote the target to the src\n\n\tpeLink = pe;\n\t\n}\n\n/*\n===========\nDrag_Begin\n//++timo test three button mouse and three button emulation here ?\n===========\n*/\nvoid Drag_Begin (int x, int y, int buttons,\n\t\t   vec3_t xaxis, vec3_t yaxis,\n\t\t   vec3_t origin, vec3_t dir)\n{\n\ttrace_t\tt;\n\tbool altdown;\n\n\tdrag_ok = false;\n\tVectorCopy (vec3_origin, pressdelta);\n\tVectorCopy (vec3_origin, vPressStart);\n\tdrag_first = true;\n\tpeLink = NULL;\n\n\taltdown = static_cast<bool>(::GetAsyncKeyState(VK_MENU));\n\n\t// shift-LBUTTON = select entire brush\n\tif (buttons == (MK_LBUTTON | MK_SHIFT) && g_qeglobals.d_select_mode != sel_curvepoint &&\n\t\tg_qeglobals.d_select_mode != sel_terrainpoint && g_qeglobals.d_select_mode != sel_terraintexture)\n\t{\n\t\tint nFlag = altdown ? SF_CYCLE : 0;\n\t\tif (dir[0] == 0 || dir[1] == 0 || dir[2] == 0)  // extremely low chance of this happening from camera\n\t\t\tSelect_Ray (origin, dir, nFlag | SF_ENTITIES_FIRST);\t// hack for XY\n\t\telse\n\t\t\tSelect_Ray (origin, dir, nFlag);\n\t\treturn;\n\t}\n\n\t// ctrl-alt-LBUTTON = multiple brush select without selecting whole entities\n\tif (buttons == (MK_LBUTTON | MK_CONTROL) && altdown && g_qeglobals.d_select_mode != sel_curvepoint &&\n\t\tg_qeglobals.d_select_mode != sel_terrainpoint && g_qeglobals.d_select_mode != sel_terraintexture)\n\t{\n\t\tif (dir[0] == 0 || dir[1] == 0 || dir[2] == 0)  // extremely low chance of this happening from camera\n\t\t\tSelect_Ray (origin, dir, SF_ENTITIES_FIRST);\t// hack for XY\n\t\telse\n\t\t\tSelect_Ray (origin, dir, 0);\n\t\treturn;\n\t}\n\n\t// ctrl-shift-LBUTTON = select single face\n\tif (buttons == (MK_LBUTTON | MK_CONTROL | MK_SHIFT) && g_qeglobals.d_select_mode != sel_curvepoint &&\n\t\tg_qeglobals.d_select_mode != sel_terrainpoint && g_qeglobals.d_select_mode != sel_terraintexture)\n\t{\n\t\tSelect_Deselect (!static_cast<bool>(::GetAsyncKeyState(VK_MENU)));\n\t\tSelect_Ray (origin, dir, SF_SINGLEFACE);\n\t\treturn;\n\t}\n\n\n\t// LBUTTON + all other modifiers = manipulate selection\n\tif (buttons & MK_LBUTTON)\n\t{\n\t\t//\n\t\tDrag_Setup (x, y, buttons, xaxis, yaxis, origin, dir);\n\t\treturn;\n\t}\n\n\tint nMouseButton = g_PrefsDlg.m_nMouseButtons == 2 ? MK_RBUTTON : MK_MBUTTON;\n\t// middle button = grab texture\n\tif (buttons == nMouseButton)\n\t{\n\t\tt = Test_Ray (origin, dir, false);\n\t\tif (t.face)\n\t\t{\n\t\t\tg_qeglobals.d_new_brush_bottom_z = t.brush->mins[2];\n\t\t\tg_qeglobals.d_new_brush_top_z = t.brush->maxs[2];\n\t\t\t// use a local brushprimit_texdef fitted to a default 2x2 texture\n\t\t\tbrushprimit_texdef_t bp_local;\n\t\t\tConvertTexMatWithQTexture( &t.face->brushprimit_texdef, t.face->d_texture, &bp_local, NULL );\n\t\t\tTexture_SetTexture ( &t.face->texdef, &bp_local, false, GETPLUGINTEXDEF(t.face));\n\t\t\tUpdateSurfaceDialog();\n\t\t\tUpdatePatchInspector();\n\t\t}\n\t\telse\n\t\t\tSys_Printf (\"Did not select a texture\\n\");\n\t\treturn;\n\t}\n\n\t// ctrl-middle button = set entire brush to texture\n\tif (buttons == (nMouseButton|MK_CONTROL) )\n\t{\n\t\tt = Test_Ray (origin, dir, false);\n\t\tif (t.brush)\n\t\t{\n\t\t\tif (t.brush->brush_faces->texdef.name[0] == '(')\n\t\t\t\tSys_Printf (\"Can't change an entity texture\\n\");\n\t\t\telse\n\t\t\t{\n\t\t\t\tBrush_SetTexture (t.brush, &g_qeglobals.d_texturewin.texdef, &g_qeglobals.d_texturewin.brushprimit_texdef, false, static_cast<IPluginTexdef *>( g_qeglobals.d_texturewin.pTexdef ) );\n\t\t\t\tSys_UpdateWindows (W_ALL);\n\t\t\t}\n\t\t}\n\t\telse\n\t\t\tSys_Printf (\"Didn't hit a btrush\\n\");\n\t\treturn;\n\t}\n\n\t// ctrl-shift-middle button = set single face to texture\n\tif (buttons == (nMouseButton|MK_SHIFT|MK_CONTROL) )\n\t{\n\t\tt = Test_Ray (origin, dir, false);\n\t\tif (t.brush)\n\t\t{\n\t\t\tif (t.brush->brush_faces->texdef.name[0] == '(')\n\t\t\t\tSys_Printf (\"Can't change an entity texture\\n\");\n\t\t\telse\n\t\t\t{\n\t\t\t\tSetFaceTexdef (t.brush, t.face, &g_qeglobals.d_texturewin.texdef, &g_qeglobals.d_texturewin.brushprimit_texdef);\n\t\t\t\tBrush_Build( t.brush );\n\t\t\t\tSys_UpdateWindows (W_ALL);\n\t\t\t}\n\t\t}\n\t\telse\n\t\t\tSys_Printf (\"Didn't hit a btrush\\n\");\n\t\treturn;\n\t}\n\n\tif (buttons == (nMouseButton | MK_SHIFT))\n\t{\n\t\tSys_Printf(\"Set brush face texture info\\n\");\n\t\tt = Test_Ray (origin, dir, false);\n\t\tif (t.brush)\n\t\t{\n\t\t\tif (t.brush->brush_faces->texdef.name[0] == '(')\n      {\n        if (t.brush->owner->eclass->nShowFlags & ECLASS_LIGHT)\n        {\n          CString strBuff;\n          qtexture_t* pTex = Texture_ForName(g_qeglobals.d_texturewin.texdef.name);\n          if (pTex)\n          {\n            vec3_t vColor;\n            VectorCopy(pTex->color, vColor);\n\n            float fLargest = 0.0f;\n            for (int i = 0; i < 3; i++)\n            {\n\t\t          if (vColor[i] > fLargest)\n\t\t\t          fLargest = vColor[i];\n            }\n\t\t        \n\t\t        if (fLargest == 0.0f)\n\t\t        {\n              vColor[0] = vColor[1] = vColor[2] = 1.0f;\n            }\n\t\t        else\n\t\t        {\n\t\t\t        float fScale = 1.0f / fLargest;\n              for (int i = 0; i < 3; i++)\n              {\n                vColor[i] *= fScale;\n              }\n            }\n            strBuff.Format(\"%f %f %f\",pTex->color[0], pTex->color[1], pTex->color[2]);\n            SetKeyValue(t.brush->owner, \"_color\", strBuff.GetBuffer(0));\n\t\t\t\t    Sys_UpdateWindows (W_ALL);\n          }\n        }\n        else\n        {\n\t\t\t\t  Sys_Printf (\"Can't select an entity brush face\\n\");\n        }\n      }\n\t\t\telse\n\t\t\t{\n      \t//strcpy(t.face->texdef.name,g_qeglobals.d_texturewin.texdef.name);\n      \tt.face->texdef.SetName(g_qeglobals.d_texturewin.texdef.name);\n\t\t\t\tBrush_Build(t.brush);\n\t\t\t\tSys_UpdateWindows (W_ALL);\n\t\t\t}\n\t\t}\n\t\telse\n\t\t\tSys_Printf (\"Didn't hit a brush\\n\");\n\t\treturn;\n\t}\n\n}\n\n\n//\n//===========\n//MoveSelection\n//===========\n//\nvoid MoveSelection (vec3_t move)\n{\n\tint\t\ti, success;\n\tbrush_t\t*b;\n\tCString strStatus;\n\tvec3_t vTemp, vTemp2, end;\n\n\tif (!move[0] && !move[1] && !move[2])\n\t\treturn;\n\n\tmove[0] = (g_nScaleHow & SCALE_X) ? 0 : move[0];\n\tmove[1] = (g_nScaleHow & SCALE_Y) ? 0 : move[1];\n  move[2] = (g_nScaleHow & SCALE_Z) ? 0 : move[2];\n\n\tif (g_pParentWnd->ActiveXY()->RotateMode() || g_bPatchBendMode)\n\t{\n\t\tfloat fDeg = -move[2];\n\t\tfloat fAdj = move[2];\n\t\tint nAxis = 0;\n\t\tif (g_pParentWnd->ActiveXY()->GetViewType() == XY)\n\t\t{\n\t\t\tfDeg = -move[1];\n\t\t\tfAdj = move[1];\n\t\t\tnAxis = 2;\n\t\t}\n\t\telse \n\t\t\tif (g_pParentWnd->ActiveXY()->GetViewType() == XZ)\n\t\t{\n\t\t\tfDeg = move[2];\n\t\t\tfAdj = move[2];\n\t\t\tnAxis = 1;\n\t\t}\n\t\telse\n\t\t\tnAxis = 0;\n\n\t\tg_pParentWnd->ActiveXY()->Rotation()[nAxis] += fAdj;\n\t\tstrStatus.Format(\"%s x:: %.1f  y:: %.1f  z:: %.1f\", (g_bPatchBendMode) ? \"Bend angle\" : \"Rotation\", g_pParentWnd->ActiveXY()->Rotation()[0], g_pParentWnd->ActiveXY()->Rotation()[1], g_pParentWnd->ActiveXY()->Rotation()[2]);\n\t\tg_pParentWnd->SetStatusText(2, strStatus);\n\n\t\tif (g_bPatchBendMode)\n\t\t{\n\t\t\tPatch_SelectBendNormal();\n\t\t\tSelect_RotateAxis(nAxis, fDeg*2, false, true);\n\t\t\tPatch_SelectBendAxis();\n\t\t\tSelect_RotateAxis(nAxis, fDeg, false, true);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tSelect_RotateAxis(nAxis, fDeg, false, true);\n\t\t}\n\t\treturn;\n\t}\n\n\tif (g_pParentWnd->ActiveXY()->ScaleMode())\n\t{\n\t\tvec3_t v;\n\t\tv[0] = v[1] = v[2] = 1.0;\n\t\tif (move[1] > 0)\n\t\t{\n\t\t\tv[0] = 1.1;\n\t\t\tv[1] = 1.1;\n\t\t\tv[2] = 1.1;\n\t\t}\n\t\telse \n\t\t\tif (move[1] < 0)\n\t\t{\n\t\t\tv[0] = 0.9;\n\t\t\tv[1] = 0.9;\n\t\t\tv[2] = 0.9;\n\t\t}\n\n\t\t\tSelect_Scale((g_nScaleHow & SCALE_X) ? 1.0 : v[0],\n\t\t\t\t\t\t\t\t\t (g_nScaleHow & SCALE_Y) ? 1.0 : v[1],\n  \t\t\t\t\t\t\t\t (g_nScaleHow & SCALE_Z) ? 1.0 : v[2]);\n\t\tSys_UpdateWindows (W_ALL);\n\t\treturn;\n\t}\n\n\n\tvec3_t vDistance;\n\tVectorSubtract(pressdelta, vPressStart, vDistance);\n\tstrStatus.Format(\"Distance x: %.1f  y: %.1f  z: %.1f\", vDistance[0], vDistance[1], vDistance[2]);\n\tg_pParentWnd->SetStatusText(3, strStatus);\n\n\t//\n\t// dragging only a part of the selection\n\t//\n\t//point object selection\n\tif (g_qeglobals.d_select_mode == sel_editpoint) {\n\t\tif (g_qeglobals.selectObject) {\n\t\t\tg_qeglobals.selectObject->updateSelection(move[0], move[1], move[2]);\n\t\t}\n\t\treturn;\n\t}\n\n\n\t// this is fairly crappy way to deal with curvepoint and area selection\n\t// but it touches the smallest amount of code this way\n\t// \n\tif (g_qeglobals.d_num_move_points || g_qeglobals.d_numterrapoints || g_qeglobals.d_select_mode == sel_area)\n\t{\n\t\t//area selection\n\t\tif (g_qeglobals.d_select_mode == sel_area)\n\t\t{\n\t\t\tVectorAdd(g_qeglobals.d_vAreaBR, move, g_qeglobals.d_vAreaBR);\n\t\t\treturn;\n\t\t}\n\t\t//curve point selection\n\t\tif (g_qeglobals.d_select_mode == sel_curvepoint)\n\t\t{\n\t\t\tPatch_UpdateSelected(move);\n\t\t\treturn;\n\t\t}\n\t\t//terrain point selection\n\t\tif ( ( g_qeglobals.d_select_mode == sel_terrainpoint ) || ( g_qeglobals.d_select_mode == sel_terraintexture ) )\n\t\t{\n\t\t\tTerrain_UpdateSelected(move);\n\t\t\treturn;\n\t\t}\n\n\t\t//vertex selection\n\t\tif (g_qeglobals.d_select_mode == sel_vertex)\n\t\t{\n\t\t\tsuccess = true;\n\t\t\tfor (b = selected_brushes.next; b != &selected_brushes; b = b->next)\n\t\t\t{\n\t\t\t\tsuccess &= Brush_MoveVertex(b, g_qeglobals.d_move_points[0], move, end, true);\n\t\t\t}\n\t\t\tif (success)\n\t\t\t\tVectorCopy(end, g_qeglobals.d_move_points[0]);\n\t\t\treturn;\n\t\t}\n\t\t//all other selection types\n\t\tfor (i=0 ; i<g_qeglobals.d_num_move_points ; i++)\n\t\t\tVectorAdd (g_qeglobals.d_move_points[i], move, g_qeglobals.d_move_points[i]);\n\t\t//VectorScale(move, .5, move);\n\t\t//for (i=0 ; i<g_qeglobals.d_num_move_points2 ; i++)\n\t\t//\tVectorAdd (g_qeglobals.d_move_points2[i], move, g_qeglobals.d_move_points2[i]);\n\t\tfor (b = selected_brushes.next; b != &selected_brushes; b = b->next)\n\t\t{\n\t\t\tVectorCopy(b->maxs, vTemp);\n\t\t\tVectorSubtract(vTemp, b->mins, vTemp);\n\t\t\tBrush_Build( b );\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t\tif (b->mins[i] > b->maxs[i]\n\t\t\t\t|| b->maxs[i] - b->mins[i] > MAX_BRUSH_SIZE)\n\t\t\t\t\tbreak;\t// dragged backwards or fucked up\n\t\t\tif (i != 3)\n\t\t\t\tbreak;\n\t\t\tif (b->patchBrush)\n\t\t\t{\n\t\t\t\tVectorCopy(b->maxs, vTemp2);\n\t\t\t\tVectorSubtract(vTemp2, b->mins, vTemp2);\n\t\t\t\tVectorSubtract(vTemp2, vTemp, vTemp2);\n\t\t\t\t//if (!Patch_DragScale(b->nPatchID, vTemp2, move))\n\t\t\t\tif (!Patch_DragScale(b->pPatch, vTemp2, move))\n\t\t\t\t{\n\t\t\t\t\tb = NULL;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (b->terrainBrush)\n\t\t\t{\n\t\t\t\tVectorCopy(b->maxs, vTemp2);\n\t\t\t\tVectorSubtract(vTemp2, b->mins, vTemp2);\n\t\t\t\tVectorSubtract(vTemp2, vTemp, vTemp2);\n\t\t\t\tif (!Terrain_DragScale(b->pTerrain, vTemp2, move))\n\t\t\t\t{\n\t\t\t\t\tb = NULL;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// if any of the brushes were crushed out of existance\n\t\t// calcel the entire move\n\t\tif (b != &selected_brushes)\n\t\t{\n\t\t\tSys_Printf (\"Brush dragged backwards, move canceled\\n\");\n\t\t\tfor (i=0 ; i<g_qeglobals.d_num_move_points ; i++)\n\t\t\t\tVectorSubtract (g_qeglobals.d_move_points[i], move, g_qeglobals.d_move_points[i]);\n\n\t\t\tfor (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n\t\t\t\tBrush_Build( b );\n\t\t}\n\n\t}\n\telse\n\t{\n\t\t// reset face originals from vertex edit mode\n\t\t// this is dirty, but unfortunately necessary because Brush_Build\n\t\t// can remove windings\n\t\tfor (b = selected_brushes.next; b != &selected_brushes; b = b->next)\n\t\t{\n\t\t\tBrush_ResetFaceOriginals(b);\n\t\t}\n\t\t//\n\t\t// if there are lots of brushes selected, just translate instead\n\t\t// of rebuilding the brushes\n\t\t//\n\t\tif (drag_yvec[2] == 0 && selected_brushes.next->next != &selected_brushes)\n\t\t{\n\t\t\tSelect_Move (move);\n\t\t\t//VectorAdd (g_qeglobals.d_select_translate, move, g_qeglobals.d_select_translate);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tSelect_Move (move);\n\t\t}\n\t}\n}\n\n/*\n===========\nDrag_MouseMoved\n===========\n*/\nvoid Drag_MouseMoved (int x, int y, int buttons)\n{\n\tvec3_t\tmove, delta;\n\tint\t\ti;\n\n\tif (!buttons)\n\t{\n\t\tdrag_ok = false;\n\t\treturn;\n\t}\n\tif (!drag_ok)\n\t\treturn;\n\n\t// clear along one axis\n\tif (buttons & MK_SHIFT)\n\t{\n\t\tdrag_first = false;\n\t\tif (abs(x-pressx) > abs(y-pressy))\n\t\t\ty = pressy;\n\t\telse\n\t\t\tx = pressx;\n\t}\n\n\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tmove[i] = drag_xvec[i]*(x - pressx)\t+ drag_yvec[i]*(y - pressy);\n    if (!g_PrefsDlg.m_bNoClamp)\n    {\n\t\t  move[i] = floor(move[i]/g_qeglobals.d_gridsize+0.5)*g_qeglobals.d_gridsize;\n    }\n\t}\n\n\tVectorSubtract (move, pressdelta, delta);\n\tVectorCopy (move, pressdelta);\n\n  MoveSelection (delta);\n\n}\n\n/*\n===========\nDrag_MouseUp\n===========\n*/\nvoid Drag_MouseUp (int nButtons)\n{\n\tSys_Status (\"drag completed.\", 0);\n\n\tif (g_qeglobals.d_select_mode == sel_area)\n\t{\n\t\tif ( OnlyTerrainSelected() )\n\t\t\t{\n\t\t\tTerrain_SelectAreaPoints();\n\t\t\tg_qeglobals.d_select_mode = sel_terrainpoint;\n\t\t\tSys_UpdateWindows (W_ALL);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tPatch_SelectAreaPoints();\n\t\t\tg_qeglobals.d_select_mode = sel_curvepoint;\n\t\t\tSys_UpdateWindows (W_ALL);\n\t\t}\n\t}\n\t\n\tif (g_qeglobals.d_select_translate[0] || g_qeglobals.d_select_translate[1] || g_qeglobals.d_select_translate[2])\n\t{\n\t\tSelect_Move (g_qeglobals.d_select_translate);\n\t\tVectorCopy (vec3_origin, g_qeglobals.d_select_translate);\n\t\tSys_UpdateWindows (W_CAMERA);\n\t}\n  \n\tg_pParentWnd->SetStatusText(3, \"\");\n\n\t//\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n"
  },
  {
    "path": "q3radiant/DialogInfo.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// DialogInfo.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"DialogInfo.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CDialogInfo dialog\nCDialogInfo g_dlgInfo;\n\nvoid ShowInfoDialog(const char* pText)\n{\n  if (g_dlgInfo.GetSafeHwnd())\n  {\n    g_dlgInfo.m_wndInfo.SetWindowText(pText);\n    g_dlgInfo.ShowWindow(SW_SHOW);\n  }\n  else\n  {\n    g_dlgInfo.Create(IDD_DLG_INFORMATION);\n    g_dlgInfo.m_wndInfo.SetWindowText(pText);\n    g_dlgInfo.ShowWindow(SW_SHOW);\n  }\n  g_pParentWnd->SetFocus();\n}\n\nvoid HideInfoDialog()\n{\n  if (g_dlgInfo.GetSafeHwnd())\n    g_dlgInfo.ShowWindow(SW_HIDE);\n}\n\n\nCDialogInfo::CDialogInfo(CWnd* pParent /*=NULL*/)\n\t: CDialog(CDialogInfo::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CDialogInfo)\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CDialogInfo::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CDialogInfo)\n\tDDX_Control(pDX, IDC_EDIT1, m_wndInfo);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CDialogInfo, CDialog)\n\t//{{AFX_MSG_MAP(CDialogInfo)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CDialogInfo message handlers\n\nBOOL CDialogInfo::OnInitDialog() \n{\n\tCDialog::OnInitDialog();\n\t// TODO: Add extra initialization here\n\t\n\treturn TRUE;  // return TRUE unless you set the focus to a control\n\t              // EXCEPTION: OCX Property Pages should return FALSE\n}\n"
  },
  {
    "path": "q3radiant/DialogInfo.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_DIALOGINFO_H__81DF2A33_A552_11D1_B58E_00AA00A410FC__INCLUDED_)\n#define AFX_DIALOGINFO_H__81DF2A33_A552_11D1_B58E_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// DialogInfo.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CDialogInfo dialog\nvoid HideInfoDialog();\nvoid ShowInfoDialog(const char* pText);\n\nclass CDialogInfo : public CDialog\n{\n// Construction\npublic:\n\tCDialogInfo(CWnd* pParent = NULL);   // standard constructor\n\n// Dialog Data\n\t//{{AFX_DATA(CDialogInfo)\n\tenum { IDD = IDD_DLG_INFORMATION };\n\tCEdit\tm_wndInfo;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CDialogInfo)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CDialogInfo)\n\tvirtual BOOL OnInitDialog();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_DIALOGINFO_H__81DF2A33_A552_11D1_B58E_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/DialogTextures.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// DialogTextures.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"DialogTextures.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CDialogTextures dialog\n\n\nCDialogTextures::CDialogTextures(CWnd* pParent /*=NULL*/)\n\t: CDialog(CDialogTextures::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CDialogTextures)\n\t\t// NOTE: the ClassWizard will add member initialization here\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CDialogTextures::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CDialogTextures)\n\tDDX_Control(pDX, IDC_LIST_TEXTURES, m_wndList);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CDialogTextures, CDialog)\n\t//{{AFX_MSG_MAP(CDialogTextures)\n\tON_LBN_DBLCLK(IDC_LIST_TEXTURES, OnDblclkListTextures)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CDialogTextures message handlers\n\nvoid CDialogTextures::OnOK() \n{\n\tm_nSelection = m_wndList.GetCurSel();\n\tCDialog::OnOK();\n}\n\nvoid CDialogTextures::OnDblclkListTextures() \n{\n  OnOK();\n}\n\nBOOL CDialogTextures::OnInitDialog() \n{\n\tCDialog::OnInitDialog();\n  CStringArray sa;\n  FillTextureMenu(&sa);\n  m_nSelection = -1;\n  for (int i = 0; i < sa.GetSize(); i ++)\n  {\n    m_wndList.AddString(sa.GetAt(i));\n  }\n\treturn TRUE;  // return TRUE unless you set the focus to a control\n\t              // EXCEPTION: OCX Property Pages should return FALSE\n}\n"
  },
  {
    "path": "q3radiant/DialogTextures.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_DIALOGTEXTURES_H__F3F3F984_E47E_11D1_B61B_00AA00A410FC__INCLUDED_)\n#define AFX_DIALOGTEXTURES_H__F3F3F984_E47E_11D1_B61B_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// DialogTextures.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CDialogTextures dialog\n\nclass CDialogTextures : public CDialog\n{\n// Construction\npublic:\n\tCDialogTextures(CWnd* pParent = NULL);   // standard constructor\n\n// Dialog Data\n\t//{{AFX_DATA(CDialogTextures)\n\tenum { IDD = IDD_DIALOG_TEXTURELIST };\n\tCListBox\tm_wndList;\n\t//}}AFX_DATA\n  int m_nSelection;\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CDialogTextures)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\t// Generated message map functions\n\t//{{AFX_MSG(CDialogTextures)\n\tvirtual void OnOK();\n\tafx_msg void OnDblclkListTextures();\n\tvirtual BOOL OnInitDialog();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_DIALOGTEXTURES_H__F3F3F984_E47E_11D1_B61B_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/DialogThick.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// DialogThick.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"DialogThick.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CDialogThick dialog\n\n\nCDialogThick::CDialogThick(CWnd* pParent /*=NULL*/)\n\t: CDialog(CDialogThick::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CDialogThick)\n\tm_bSeams = TRUE;\n\tm_nAmount = 8;\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CDialogThick::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CDialogThick)\n\tDDX_Check(pDX, IDC_CHECK_SEAMS, m_bSeams);\n\tDDX_Text(pDX, IDC_EDIT_AMOUNT, m_nAmount);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CDialogThick, CDialog)\n\t//{{AFX_MSG_MAP(CDialogThick)\n\t\t// NOTE: the ClassWizard will add message map macros here\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CDialogThick message handlers\n"
  },
  {
    "path": "q3radiant/DialogThick.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_DIALOGTHICK_H__59F46602_553D_11D2_B082_00AA00A410FC__INCLUDED_)\n#define AFX_DIALOGTHICK_H__59F46602_553D_11D2_B082_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// DialogThick.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CDialogThick dialog\n\nclass CDialogThick : public CDialog\n{\n// Construction\npublic:\n\tCDialogThick(CWnd* pParent = NULL);   // standard constructor\n\n// Dialog Data\n\t//{{AFX_DATA(CDialogThick)\n\tenum { IDD = IDD_DIALOG_THICKEN };\n\tBOOL\tm_bSeams;\n\tint\t\tm_nAmount;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CDialogThick)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CDialogThick)\n\t\t// NOTE: the ClassWizard will add member functions here\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_DIALOGTHICK_H__59F46602_553D_11D2_B082_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/DlgEvent.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// DlgEvent.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"DlgEvent.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CDlgEvent dialog\n\n\nCDlgEvent::CDlgEvent(CWnd* pParent /*=NULL*/)\n\t: CDialog(CDlgEvent::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CDlgEvent)\n\tm_strParm = _T(\"\");\n\tm_event = 0;\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CDlgEvent::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CDlgEvent)\n\tDDX_Text(pDX, IDC_EDIT_PARAM, m_strParm);\n\tDDX_Radio(pDX, IDC_RADIO_EVENT, m_event);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CDlgEvent, CDialog)\n\t//{{AFX_MSG_MAP(CDlgEvent)\n\t\t// NOTE: the ClassWizard will add message map macros here\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CDlgEvent message handlers\n"
  },
  {
    "path": "q3radiant/DlgEvent.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_DLGEVENT_H__B12EEBE1_FB71_407B_9075_50F63B168567__INCLUDED_)\n#define AFX_DLGEVENT_H__B12EEBE1_FB71_407B_9075_50F63B168567__INCLUDED_\n\n#if _MSC_VER > 1000\n#pragma once\n#endif // _MSC_VER > 1000\n// DlgEvent.h : header file\n//\n\n#include \"splines/splines.h\"\n/////////////////////////////////////////////////////////////////////////////\n// CDlgEvent dialog\n\nclass CDlgEvent : public CDialog\n{\n// Construction\npublic:\n\tCDlgEvent(CWnd* pParent = NULL);   // standard constructor\n\n// Dialog Data\n\t//{{AFX_DATA(CDlgEvent)\n\tenum { IDD = IDD_DLG_CAMERAEVENT };\n\tCString\tm_strParm;\n\tint m_event;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CDlgEvent)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CDlgEvent)\n\t\t// NOTE: the ClassWizard will add member functions here\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Visual C++ will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_DLGEVENT_H__B12EEBE1_FB71_407B_9075_50F63B168567__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/ECLASS.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"stdafx.h\"\n#include \"qe3.h\"\n#include \"io.h\"\n#include \"pakstuff.h\"\n//#include \"qertypes.h\"\n\neclass_t\t*eclass = NULL;\neclass_t\t*eclass_bad = NULL;\nchar\t\teclass_directory[1024];\n\n// md3 cache for misc_models\neclass_t *g_md3Cache = NULL;\n\n/*\n\nthe classname, color triple, and bounding box are parsed out of comments\nA ? size means take the exact brush size.\n\n/*QUAKED <classname> (0 0 0) ?\n/*QUAKED <classname> (0 0 0) (-8 -8 -8) (8 8 8)\n\nFlag names can follow the size description:\n\n/*QUAKED func_door (0 .5 .8) ? START_OPEN STONE_SOUND DOOR_DONT_LINK GOLD_KEY SILVER_KEY\n\n*/\n\nvoid CleanEntityList(eclass_t *&pList)\n{\n  while (pList)\n  {\n    eclass_t* pTemp = pList->next;\n\n    entitymodel *model = pList->model;\n    while (model != NULL)\n    {\n      delete []model->pTriList;\n      model = model->pNext;\n    }\n    \n    if (pList->modelpath)\n      free(pList->modelpath);\n\t  if (pList->skinpath)\t\t\t// PGM\n\t\t  free(pList->skinpath);\t\t// PGM\n    \n    free(pList->name);\n    free(pList->comments);\n    free(pList);\n    pList = pTemp;\n  }\n\n  pList = NULL;\n\n}\n\n\nvoid CleanUpEntities()\n{\n  CleanEntityList(eclass);\n  CleanEntityList(g_md3Cache);\n/*\n  while (eclass)\n  {\n    eclass_t* pTemp = eclass->next;\n    delete []eclass->pTriList;\n    \n    if (eclass->modelpath)\n      free(eclass->modelpath);\n\t  if (eclass->skinpath)\t\t\t// PGM\n\t\t  free(eclass->skinpath);\t\t// PGM\n    \n    free(eclass->name);\n    free(eclass->comments);\n    free(eclass);\n    eclass = pTemp;\n  }\n\n  eclass = NULL;\n*/\n  if (eclass_bad)\n  {\n    free(eclass_bad->name);\n    free(eclass_bad->comments);\n    free(eclass_bad);\n    eclass_bad = NULL;\n  }\n}\n\nvoid ExtendBounds(vec3_t v, vec3_t &vMin, vec3_t &vMax)\n{\n\tfor (int i = 0 ;i < 3 ;i++)\n\t{\n\t\tvec_t f = v[i];\n\t\t\n    if (f < vMin[i])\n    {\n\t\t\tvMin[i] = f;\n    }\n\n    if (f > vMax[i])\n    {\n\t\t\tvMax[i] = f;\n    }\n\t}\n}\n\n\n\n// FIXME: this code is a TOTAL clusterfuck\n//\nvoid LoadModel(const char *pLocation, eclass_t *e, vec3_t &vMin, vec3_t &vMax, entitymodel *&pModel, const char *pSkin)\n{\n  // this assumes a path only and uses tris.md2\n  // for the model and skin.pcx for the skin\n  char cPath[1024];\n  char cSkin[1024];\n  char cFullLocation[1024];\n\t//struct _finddata_t fileinfo;\n\n  vMin[0] = vMin[1] = vMin[2] = 99999;\n  vMax[0] = vMax[1] = vMax[2] = -99999;\n\n  bool bMD3 = false;\n  bool bASE = false;\n\n  strcpy( cFullLocation, pLocation );\n\n  if (strstr(pLocation, \".md3\"))\n  {\n    bMD3 = true;\n  }\n  else if (strstr(pLocation, \".md2\") != NULL)\n  {\n\t  sprintf( cFullLocation, \"%stris.md2\", pLocation);\n  }\n  else if (strstr(pLocation, \".ase\") != NULL)\n  {\n    bASE = true;\n  }\n\n  sprintf( cPath, \"%s/%s\", ValueForKey(g_qeglobals.d_project_entity, \"basepath\"), cFullLocation);\n\n  Sys_Printf(\"Loading model %s...\", cPath);\n  unsigned char* p = NULL;\n  bool bOpen = (LoadFile(cPath, reinterpret_cast<void**>(&p)) > 0);\n  if (!bOpen)\n  {\n    Sys_Printf(\" failed. Trying PAK file...\");\n//    sprintf (cPath, \"%stris.md2\", pLocation);\n\t  strcpy (cPath, cFullLocation);\n\t  bOpen = (PakLoadAnyFile(cPath, reinterpret_cast<void**>(&p)) > 0);\n  }\n\n  if (bOpen)\n  {\n    Sys_Printf(\" successful.\\n\");\n\n    if (bASE)\n    {\n/*\n      free(p);\n      CString strOut;\n      ::GetTempPath(1024, strOut.GetBuffer(1024));\n      strOut.ReleaseBuffer();\n      AddSlash(strOut);\n      strOut += \"Temp.ase\";\n      CopyFile(cPath, strOut, false);\n      CString strIn = strOut;\n      FindReplace(strOut, \".ase\", \".md3\");\n      strcpy(cPath, strIn);\n      strcpy(cSkin, strOut);\n      Q3Data_ProduceTempMD3(ValueForKey(g_qeglobals.d_project_entity, \"basepath\"), cPath, cSkin);\n      CString strModel = cPath;\n      if (LoadFile(strOut.GetBuffer(0), reinterpret_cast<void**>(&p)) == 0)\n      {\n        Sys_Printf(\" Conversion from ASE failed.\\n\");\n        return;\n      }\n      bMD3 = true;\n*/\n    }\n\n    if (bMD3)\n    {\n\t    md3Header_t header;\n\t    md3Surface_t *pSurface;\n    \theader = *(md3Header_t *)p;\n      if (pSkin != NULL)\n      {\n        strcpy(cSkin, pSkin);\n      }\n\t    else\n      {\n\t\t    cSkin[0] = '\\0';\n      }\n      int n = header.numFrames;\n    \tpSurface = (md3Surface_t *) (p + header.ofsSurfaces);\n    \tfor (int z = 0; z < header.numSurfaces; z++ )\n\t    {\n        int nTris = pSurface->numTriangles;\n        \n        //unsigned char* pTris = reinterpret_cast<unsigned char*>(pSurface);\n        //pTris += pSurface->ofsTriangles;\n\n        if (nTris > 0)\n        {\n          int nStart = 0;\n          if (pModel->pTriList == NULL)\n          {\n\t\t        pModel->nModelPosition = 0;\n            pModel->pTriList = new trimodel[nTris];\n            pModel->nTriCount = nTris;\n          }\n          else\n          {\n            // already have one so we need to reallocate\n            int nNewCount = pModel->nTriCount + nTris;\n            trimodel* pNewModels = new trimodel[nNewCount];\n            for (int i = 0; i < pModel->nTriCount; i++)\n            {\n              memcpy(&pNewModels[i], &pModel->pTriList[i], sizeof(trimodel));\n            }\n            nStart = pModel->nTriCount;\n            pModel->nTriCount = nNewCount;\n            //nTris = nNewCount;\n            delete [] pModel->pTriList;\n            pModel->pTriList = pNewModels;\n          }\n          \n          md3Triangle_t *pTris = reinterpret_cast<md3Triangle_t*>((reinterpret_cast<unsigned char*>(pSurface) + pSurface->ofsTriangles));\n          md3XyzNormal_t *pXyz = reinterpret_cast<md3XyzNormal_t*>((reinterpret_cast<unsigned char*>(pSurface) + pSurface->ofsXyzNormals));\n          if (e->nFrame < pSurface->numFrames)\n          {\n            pXyz += (e->nFrame * pSurface->numVerts);\n          }\n\n          md3St_t *pST = reinterpret_cast<md3St_t*>((reinterpret_cast<unsigned char*>(pSurface) + pSurface->ofsSt)); \n\n          for (int i = 0; i < nTris; i++)\n          {\n            for (int k = 0; k < 3; k ++)\n            {\n              for (int j = 0; j < 3; j++)\n              {\n                //e->pTriList[i].v[k][j] = (f->verts[tri.index_xyz[k]].v[j] * f->scale[j] + f->translate[j]);\n                pModel->pTriList[nStart].v[k][j] = pXyz[pTris[i].indexes[k]].xyz[j] * MD3_XYZ_SCALE;\n              }\n\t\t          pModel->pTriList[nStart].st[k][0] = pST[pTris[i].indexes[k]].st[0];\n\t\t          pModel->pTriList[nStart].st[k][1] = pST[pTris[i].indexes[k]].st[1];\n \t\t          ExtendBounds (pModel->pTriList[nStart].v[k], vMin, vMax);\n\t\t        }\n            nStart++;\n\t\t      }\n\n        }\n\n        md3Shader_t *pShader = reinterpret_cast<md3Shader_t*>((reinterpret_cast<unsigned char*>(pSurface) + pSurface->ofsShaders)); \n        sprintf (cPath, \"%s/%s\", ValueForKey(g_qeglobals.d_project_entity, \"basepath\"), pShader->name);\n        strlwr(cPath);\n \t      pModel->nTextureBind = Texture_LoadSkin(cPath, &pModel->nSkinWidth, &pModel->nSkinHeight);\n        if (pModel->nTextureBind == -1)\n        {\n          Sys_Printf(\"Model skin load failed on texture %s\\n\", cPath);\n        }\n\t\t    pSurface = (md3Surface_t *) ((( char * ) pSurface) + pSurface->ofsEnd);\n        pModel->pNext = reinterpret_cast<entitymodel_t*>(qmalloc(sizeof(entitymodel_t)));\n        pModel = pModel->pNext;\n      }\n    }\n    else\n    {\n\n      dmdl_t model;\n      daliasframe_t *f;\n      unsigned char* pTris = p;\n      dstvert_t *pST = NULL;\n      int nTris = 0;\n\n      // grab model params\n      memcpy(&model, p, sizeof(dmdl_t));\n      f = (daliasframe_t*)(p + model.ofs_frames);\n      pTris += model.ofs_tris;\n      pST = reinterpret_cast<dstvert_t*>(p + model.ofs_st);\n      nTris = model.num_tris;\n\n\t    if(pSkin)\n\t    {\n\t\t    strcpy (cSkin, pSkin);\n\t\t    if ((cSkin[strlen(cSkin)-1] == '\\\\') || (cSkin[strlen(cSkin)-1] == '/'))\n\t\t\t    strcat(cSkin, \"skin.pcx\\0\");\n\t    }\n\t    else\n      {\n\t\t    strcpy(cSkin, (char *)(p + model.ofs_skins));\n      }\n\n      sprintf (cPath, \"%s/%s\", ValueForKey(g_qeglobals.d_project_entity, \"basepath\"), cSkin);\n      strlwr(cPath);\n      pModel->nTextureBind = Texture_LoadSkin(cPath, &pModel->nSkinWidth, &pModel->nSkinHeight);\n      if (pModel->nTextureBind == -1)\n      {\n        Sys_Printf(\"Model skin load failed on texture %s\\n\", cPath);\n      }\n      int nStart = 0;\n      if (pModel->pTriList == NULL)\n      {\n\t\t    pModel->nModelPosition = 0;\n        pModel->pTriList = new trimodel[nTris];\n        pModel->nTriCount = nTris;\n      }\n      else\n      {\n        // already have one so we need to reallocate\n        int nNewCount = pModel->nTriCount + nTris;\n        trimodel* pNewModels = new trimodel[nNewCount];\n        for (int i = 0; i < pModel->nTriCount; i++)\n        {\n          memcpy(&pNewModels[i], &pModel->pTriList[i], sizeof(trimodel));\n        }\n        nStart = pModel->nTriCount;\n        pModel->nTriCount = nNewCount;\n        nTris = nNewCount;\n        delete [] pModel->pTriList;\n        pModel->pTriList = pNewModels;\n      }\n      \n      for (int i = nStart; i < nTris; i++)\n      {\n        dtriangle_t tri;\n        memcpy(&tri, pTris, sizeof(dtriangle_t));\n        for (int k = 0; k < 3; k ++)\n        {\n          for (int j = 0; j < 3; j++)\n          {\n            pModel->pTriList[i].v[k][j] = (f->verts[tri.index_xyz[k]].v[j] * f->scale[j] + f->translate[j]);\n          }\n\n          pModel->pTriList[i].st[k][0] = pST[tri.index_st[k]].s / pModel->nSkinWidth;\n          pModel->pTriList[i].st[k][1] = pST[tri.index_st[k]].t / pModel->nSkinHeight;;\n          ExtendBounds (pModel->pTriList[i].v[k], vMin, vMax);\n\t\t    }\n        pTris += sizeof(dtriangle_t);\n\t\t  }\n    }\n    free(p);\n  }\n  else\n  {\n    Sys_Printf(\" failed.\\n\");\n  }\n\n#if 0\n  if (pModel->pTriList != NULL && pModel->nTriCount > 0 && !bMD3)\n  {\n\t  if(fabs(vMin[2]) < ((vMax[2]-vMin[2]) / 10.0))\t// > 90% above 0 point.\n\t    pModel->nModelPosition = 1;\n//\tsprintf (cPath, \"%s/%sskin.pcx\", ValueForKey(g_qeglobals.d_project_entity, \"basepath\"), pLocation);\n    sprintf (cPath, \"%s/%s\", ValueForKey(g_qeglobals.d_project_entity, \"basepath\"), cSkin);\n \t  pModel->nTextureBind = Texture_LoadSkin(cPath, &pModel->nSkinWidth, &pModel->nSkinHeight);\n    if (pModel->nTextureBind == -1)\n    {\n//      sprintf (cPath, \"%sskin.pcx\", pLocation);\n\t\t  strcpy (cPath, cSkin);\n      pModel->nTextureBind = Texture_LoadSkin(cPath, &pModel->nSkinWidth, &pModel->nSkinHeight);\n    }\n  }\n#endif\n\n}\n\nvoid setSpecialLoad(eclass_t *e, const char* pWhat, char*& p)\n{\n  CString str = e->comments;\n  int n = str.Find(pWhat);\n  if (n >= 0)\n  {\n    char* pText = e->comments + n + strlen(pWhat);\n    if (*pText == '\\\"')\n      pText++;\n\n    str = \"\";\n    while (*pText != '\\\"' && *pText != '\\0')\n    {\n      str += *pText;\n      pText++;\n    }\n    if (str.GetLength() > 0)\n    {         \n      p = strdup(str);\n      //--LoadModel(str, e);\n    }\n  }\n}\n\nchar\t*debugname;\n\neclass_t *Eclass_InitFromText (char *text)\n{\n\tchar\t*t;\n\tint\t\tlen;\n\tint\t\tr, i;\n\tchar\tparms[256], *p;\n\teclass_t\t*e;\n\tchar\tcolor[128];\n\n\te = (eclass_t*)qmalloc(sizeof(*e));\n\tmemset (e, 0, sizeof(*e));\n\t\n\ttext += strlen(\"/*QUAKED \");\n\t\n// grab the name\n\ttext = COM_Parse (text);\n\te->name = (char*)qmalloc (strlen(com_token)+1);\n\tstrcpy (e->name, com_token);\n\tdebugname = e->name;\n\t\n// grab the color, reformat as texture name\n\tr = sscanf (text,\" (%f %f %f)\", &e->color[0], &e->color[1], &e->color[2]);\n\tif (r != 3)\n\t\treturn e;\n\tsprintf (color, \"(%f %f %f)\", e->color[0], e->color[1], e->color[2]);\n\t//strcpy (e->texdef.name, color);\n\te->texdef.SetName(color);\n\n\twhile (*text != ')')\n\t{\n\t\tif (!*text)\n\t\t\treturn e;\n\t\ttext++;\n\t}\n\ttext++;\n\t\n// get the size\t\n\ttext = COM_Parse (text);\n\tif (com_token[0] == '(')\n\t{\t// parse the size as two vectors\n\t\te->fixedsize = true;\n\t\tr = sscanf (text,\"%f %f %f) (%f %f %f)\", &e->mins[0], &e->mins[1], &e->mins[2],\n\t\t\t&e->maxs[0], &e->maxs[1], &e->maxs[2]);\n\t\tif (r != 6)\n\t\t\treturn e;\n\n\t\tfor (i=0 ; i<2 ; i++)\n\t\t{\n\t\t\twhile (*text != ')')\n\t\t\t{\n\t\t\t\tif (!*text)\n\t\t\t\t\treturn e;\n\t\t\t\ttext++;\n\t\t\t}\n\t\t\ttext++;\n\t\t}\n\t}\n\telse\n\t{\t// use the brushes\n\t}\n\t\n// get the flags\n\t\n\n// copy to the first /n\n\tp = parms;\n\twhile (*text && *text != '\\n')\n\t\t*p++ = *text++;\n\t*p = 0;\n\ttext++;\n\t\n// any remaining words are parm flags\n\tp = parms;\n\tfor (i=0 ; i<8 ; i++)\n\t{\n\t\tp = COM_Parse (p);\n\t\tif (!p)\n\t\t\tbreak;\n\t\tstrcpy (e->flagnames[i], com_token);\n\t} \n\n// find the length until close comment\n\tfor (t=text ; t[0] && !(t[0]=='*' && t[1]=='/') ; t++)\n\t;\n\t\n// copy the comment block out\n\tlen = t-text;\n\te->comments = (char*)qmalloc (len+1);\n\tmemcpy (e->comments, text, len);\n#if 0\n\tfor (i=0 ; i<len ; i++)\n\t\tif (text[i] == '\\n')\n\t\t\te->comments[i] = '\\r';\n\t\telse\n\t\t\te->comments[i] = text[i];\n#endif\n\te->comments[len] = 0;\n\t\n  setSpecialLoad(e, \"model=\", e->modelpath);\n  setSpecialLoad(e, \"skin=\", e->skinpath);\n  char *pFrame = NULL;\n  setSpecialLoad(e, \"frame=\", pFrame);\n  if (pFrame != NULL)\n  {\n    e->nFrame = atoi(pFrame);\n  }\n\n  if(!e->skinpath)\n\t  setSpecialLoad(e, \"texture=\", e->skinpath);\n\n  // setup show flags\n  e->nShowFlags = 0;\n  if (strcmpi(e->name, \"light\") == 0)\n  {\n    e->nShowFlags |= ECLASS_LIGHT;\n  }\n\n  if (  (strnicmp(e->name, \"info_player\", strlen(\"info_player\")) == 0)\n      ||(strnicmp(e->name, \"path_corner\", strlen(\"path_corner\")) == 0) \n      ||(strnicmp(e->name, \"team_ctf\", strlen(\"team_ctf\")) == 0) )\n  {\n    e->nShowFlags |= ECLASS_ANGLE;\n  }\n  if (strcmpi(e->name, \"path\") == 0)\n  {\n    e->nShowFlags |= ECLASS_PATH;\n  }\n  if (strcmpi(e->name, \"misc_model\") == 0)\n  {\n    e->nShowFlags |= ECLASS_MISCMODEL;\n  }\n\n\n  return e;\n}\n\nqboolean Eclass_hasModel(eclass_t *e, vec3_t &vMin, vec3_t &vMax)\n{\n  if (e->modelpath != NULL)\n  {\n    if (e->model == NULL)\n    {\n      e->model = reinterpret_cast<entitymodel_t*>(qmalloc(sizeof(entitymodel_t)));\n    }\n    char *pModelBuff = strdup(e->modelpath);\n    char *pSkinBuff = NULL;\n    if (e->skinpath)\n    {\n      pSkinBuff = strdup(e->skinpath);\n    }\n\n    CStringList Models;\n    CStringList Skins;\n    char* pToken = strtok(pModelBuff, \";\\0\");\n    while (pToken != NULL)\n    {\n      Models.AddTail(pToken);\n      pToken = strtok(NULL, \";\\0\");\n    }\n\n    if (pSkinBuff != NULL)\n    {\n      pToken = strtok(pSkinBuff, \";\\0\");\n      while (pToken != NULL)\n      {\n        Skins.AddTail(pToken);\n        pToken = strtok(NULL, \";\\0\");\n      }\n    }\n\n    entitymodel *model = e->model;\n    for (int i = 0; i < Models.GetCount(); i++)\n    {\n      char *pSkin = NULL;\n      if (i < Skins.GetCount())\n      {\n        pSkin = Skins.GetAt(Skins.FindIndex(i)).GetBuffer(0);\n      }\n      LoadModel(Models.GetAt(Models.FindIndex(i)), e, vMin, vMax, model, pSkin);\n      model->pNext = reinterpret_cast<entitymodel_t*>(qmalloc(sizeof(entitymodel_t)));\n      model = model->pNext;\n    }\n\n    // at this poitn vMin and vMax contain the min max of the model\n    // which needs to be centered at origin 0, 0, 0\n\n    VectorSnap(vMin);\n    VectorSnap(vMax);\n\n    if (vMax[0] - vMin[0] < 2)\n    {\n      vMin[0] -= 1;\n      vMax[0] += 1;\n    }\n\n    if (vMin[1] - vMax[1] < 2)\n    {\n      vMin[1] -= 1;\n      vMax[1] += 1;\n    }\n\n    if (vMax[2] - vMin[2] < 2)\n    {\n      vMax[2] -= 1;\n      vMax[2] += 1;\n    }\n\n    vec3_t vTemp;\n    VectorAdd(vMin, vMax, vTemp);\n    VectorScale(vTemp, 0.5, vTemp);\n    model = e->model;\n    while (model != NULL)\n    {\n      for (i = 0; i < model->nTriCount; i++)\n      {\n        for (int j = 0; j < 3; j++)\n        {\n          ;//VectorSubtract(model->pTriList[i].v[j], vTemp, model->pTriList[i].v[j]);\n        }\n      }\n      model = model->pNext;\n    }\n\n    free(pModelBuff);\n    free(e->modelpath);\n    e->modelpath = NULL;\n\t  \n    if(e->skinpath)\n\t  {\n\t\t  free(e->skinpath);\n\t\t  e->skinpath = NULL;\n      free(pSkinBuff);\n\t  }\n\n  }\n  return (e->model != NULL && e->model->nTriCount > 0);\n}\n\n\nvoid EClass_InsertSortedList(eclass_t *&pList, eclass_t *e)\n{\n\teclass_t\t*s;\n\t\n\tif (!pList)\n\t{\n\t\tpList = e;\n\t\treturn;\n\t}\n\n\n\ts = pList;\n\tif (stricmp (e->name, s->name) < 0)\n\t{\n\t\te->next = s;\n\t\tpList = e;\n\t\treturn;\n\t}\n\n\tdo\n\t{\n\t\tif (!s->next || stricmp (e->name, s->next->name) < 0)\n\t\t{\n\t\t\te->next = s->next;\n\t\t\ts->next = e;\n\t\t\treturn;\n\t\t}\n\t\ts=s->next;\n\t} while (1);\n}\n\n/*\n=================\nEclass_InsertAlphabetized\n=================\n*/\nvoid Eclass_InsertAlphabetized (eclass_t *e)\n{\n#if 1\n  EClass_InsertSortedList(eclass, e);\n#else\n\teclass_t\t*s;\n\t\n\tif (!eclass)\n\t{\n\t\teclass = e;\n\t\treturn;\n\t}\n\n\n\ts = eclass;\n\tif (stricmp (e->name, s->name) < 0)\n\t{\n\t\te->next = s;\n\t\teclass = e;\n\t\treturn;\n\t}\n\n\tdo\n\t{\n\t\tif (!s->next || stricmp (e->name, s->next->name) < 0)\n\t\t{\n\t\t\te->next = s->next;\n\t\t\ts->next = e;\n\t\t\treturn;\n\t\t}\n\t\ts=s->next;\n\t} while (1);\n#endif\n}\n\n\n/*\n=================\nEclass_ScanFile\n=================\n*/\n\nqboolean parsing_single = false;\nqboolean eclass_found;\neclass_t *eclass_e;\n//#ifdef BUILD_LIST\nextern bool g_bBuildList;\nCString strDefFile;\n//#endif\nvoid Eclass_ScanFile (char *filename)\n{\n\tint\t\tsize;\n\tchar\t*data;\n\teclass_t\t*e;\n\tint\t\ti;\n\tchar    temp[1024];\n\t\n\tQE_ConvertDOSToUnixName( temp, filename );\n\t\n\tSys_Printf (\"ScanFile: %s\\n\", temp);\n\t\n\t// BUG\n\tsize = LoadFile (filename, (void**)&data);\n\teclass_found = false;\n\tfor (i=0 ; i<size ; i++)\n\t\tif (!strncmp(data+i, \"/*QUAKED\",8))\n\t\t{\n\t\t\t\n\t\t\t//#ifdef BUILD_LIST\n\t\t\tif (g_bBuildList)\n\t\t\t{\n\t\t\t\tCString strDef = \"\";\n\t\t\t\tint j = i;\n\t\t\t\twhile (1)\n\t\t\t\t{\n\t\t\t\t\tstrDef += *(data+j);\n\t\t\t\t\tif (*(data+j) == '/' && *(data+j-1) == '*')\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tj++;\n\t\t\t\t}\n\t\t\t\tstrDef += \"\\r\\n\\r\\n\\r\\n\";\n\t\t\t\tstrDefFile += strDef;\n\t\t\t}\n\t\t\t//#endif\n\t\t\te = Eclass_InitFromText (data+i);\n\t\t\tif (e)\n\t\t\t\tEclass_InsertAlphabetized (e);\n\t\t\telse\n\t\t\t\tprintf (\"Error parsing: %s in %s\\n\",debugname, filename);\n\n\t\t\t// single ?\n\t\t\teclass_e = e;\n\t\t\teclass_found = true;\n\t\t\tif ( parsing_single )\n\t\t\t\tbreak;\n\t\t}\n\t\t\n\t\tfree (data);\t\t\n}\n\n\n\nvoid Eclass_InitForSourceDirectory (char *path)\n{\n\tstruct _finddata_t fileinfo;\n\tint\t\thandle;\n\tchar\tfilename[1024];\n\tchar\tfilebase[1024];\n\tchar    temp[1024];\n\tchar\t*s;\n\n\tQE_ConvertDOSToUnixName( temp, path );\n\n\tSys_Printf (\"Eclass_InitForSourceDirectory: %s\\n\", temp );\n\n\tstrcpy (filebase, path);\n\ts = filebase + strlen(filebase)-1;\n\twhile (*s != '\\\\' && *s != '/' && s!=filebase)\n\t\ts--;\n\t*s = 0;\n\n  CleanUpEntities();\n\teclass = NULL;\n//#ifdef BUILD_LIST\n  if (g_bBuildList)\n    strDefFile = \"\";\n//#endif\n\thandle = _findfirst (path, &fileinfo);\n\tif (handle != -1)\n\t{\n\t\tdo\n\t\t{\n\t\t\tsprintf (filename, \"%s\\\\%s\", filebase, fileinfo.name);\n\t\t\tEclass_ScanFile (filename);\n\t\t} while (_findnext( handle, &fileinfo ) != -1);\n\n\t\t_findclose (handle);\n\t}\n\n//#ifdef BUILD_LIST\n  if (g_bBuildList)\n  {\n    CFile file;\n    if (file.Open(\"c:\\\\entities.def\", CFile::modeCreate | CFile::modeWrite)) \n    {\n      file.Write(strDefFile.GetBuffer(0), strDefFile.GetLength());\n      file.Close();\n    }\n  }\n//#endif\n\n\teclass_bad = Eclass_InitFromText (\"/*QUAKED UNKNOWN_CLASS (0 0.5 0) ?\");\n}\n\neclass_t *Eclass_ForName (char *name, qboolean has_brushes)\n{\n\teclass_t\t*e;\n\tchar\t\tinit[1024];\n\n#ifdef _DEBUG\n  // grouping stuff, not an eclass\n  if (strcmp(name, \"group_info\")==0)\n    Sys_Printf(\"WARNING: unexpected group_info entity in Eclass_ForName\\n\");\n#endif\n\n\tif (!name)\n\t\treturn eclass_bad;\n\n\tfor (e=eclass ; e ; e=e->next)\n\t\tif (!strcmp (name, e->name))\n\t\t\treturn e;\n\n\t// create a new class for it\n\tif (has_brushes)\n\t{\n\t\tsprintf (init, \"/*QUAKED %s (0 0.5 0) ?\\nNot found in source.\\n\", name);\n\t\te = Eclass_InitFromText (init);\n\t}\n\telse\n\t{\n\t\tsprintf (init, \"/*QUAKED %s (0 0.5 0) (-8 -8 -8) (8 8 8)\\nNot found in source.\\n\", name);\n\t\te = Eclass_InitFromText (init);\n\t}\n\n\tEclass_InsertAlphabetized (e);\n\n\treturn e;\n}\n\n\neclass_t* GetCachedModel(entity_t *pEntity, const char *pName, vec3_t &vMin, vec3_t &vMax)\n{\n\n\teclass_t *e = NULL;\n  if (pName == NULL || strlen(pName) == 0)\n  {\n    return NULL;\n  }\n\n\tfor (e = g_md3Cache; e ; e = e->next)\n  {\n\t\tif (!strcmp (pName, e->name))\n    {\n      pEntity->md3Class = e;\n      VectorCopy(e->mins, vMin);\n      VectorCopy(e->maxs, vMax);\n\t\t\treturn e;\n    }\n  }\n\n\te = (eclass_t*)qmalloc(sizeof(*e));\n\tmemset (e, 0, sizeof(*e));\n  e->name = strdup(pName);\n  e->modelpath = strdup(pName);\n  e->skinpath = strdup(pName);\n  char *p = strstr(e->skinpath, \".md3\");\n  if (p != NULL)\n  {\n    p++;\n    strncpy(p, \"tga\", 3);\n  }\n  else\n  {\n    free(e->skinpath);\n    e->skinpath = NULL;\n  }\n\n  e->color[0] = e->color[2] = 0.85;\n\n  if (Eclass_hasModel(e, vMin, vMax))\n  {\n    EClass_InsertSortedList(g_md3Cache, e);\n    VectorCopy(vMin, e->mins);\n    VectorCopy(vMax, e->maxs);\n    pEntity->md3Class = e;\n    return e;\n  }\n\n  return NULL;\n}\n"
  },
  {
    "path": "q3radiant/ENTITY.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"stdafx.h\"\n#include \"qe3.h\"\n\n//\nint g_entityId = 1;\n\nchar *ValueForKey ( epair_t *&e, const char *key)\n{\n  epair_t *ep;\n  for (ep=e ; ep ; ep=ep->next)\n  {\n\t\tif (!strcmp (ep->key, key) )\n    {\n      return ep->value;\n    }\n  }\n  return \"\";\n}\n\n\nchar *ValueForKey (entity_t *ent, const char *key)\n{\n  return ValueForKey(ent->epairs, key);\n}\n\nvoid TrackMD3Angles(entity_t *e, const char *key, const char *value)\n{\n  if (strcmpi(key, \"angle\") != 0)\n  {\n    return;\n  }\n\n  if (e->eclass->fixedsize && e->eclass->nShowFlags & ECLASS_MISCMODEL)\n  {\n    float a = FloatForKey (e, \"angle\");\n    float b = atof(value);\n    if (a != b)\n    {\n      vec3_t vAngle;\n      vAngle[0] = vAngle[1] = 0;\n      vAngle[2] = -a;\n      Brush_Rotate(e->brushes.onext, vAngle, e->origin, true);\n      vAngle[2] = b;\n      Brush_Rotate(e->brushes.onext, vAngle, e->origin, true);\n    }\n  }\n}\n\nvoid \tSetKeyValue (epair_t *&e, const char *key, const char *value)\n{\n\tepair_t\t*ep;\n  for (ep=e ; ep ; ep=ep->next)\n  {\n\t\tif (!strcmp (ep->key, key) )\n\t\t{\n\t\t\tfree (ep->value);\n\t\t\tep->value = (char*)qmalloc(strlen(value)+1);\n\t\t\tstrcpy (ep->value, value);\n\t\t\treturn;\n\t\t}\n  }\n\tep = (epair_t*)qmalloc (sizeof(*ep));\n\tep->next = e;\n\te = ep;\n\tep->key = (char*)qmalloc(strlen(key)+1);\n\tstrcpy (ep->key, key);\n\tep->value = (char*)qmalloc(strlen(value)+1);\n\tstrcpy (ep->value, value);\n\n}\n\n\nvoid \tSetKeyValue (entity_t *ent, const char *key, const char *value)\n{\n\n\tif (ent == NULL)\n\t\treturn;\n\n\tif (!key || !key[0])\n\t\treturn;\n\n  TrackMD3Angles(ent, key, value);\n\n  SetKeyValue(ent->epairs, key, value);\n\n}\n\nvoid \tDeleteKey (epair_t *&e, const char *key)\n{\n\tepair_t\t**ep, *next;\n\t\n\tep = &e;\n\twhile (*ep)\n\t{\n\t\tnext = *ep;\n\t\tif ( !strcmp (next->key, key) )\n\t\t{\n\t\t\t*ep = next->next;\n\t\t\tfree(next->key);\n\t\t\tfree(next->value);\n\t\t\tfree(next);\n\t\t\treturn;\n\t\t}\n\t\tep = &next->next;\n\t}\n}\n\n\nvoid \tDeleteKey (entity_t *ent, const char *key)\n{\n  DeleteKey(ent->epairs, key);\n}\n\n\n\n\nfloat\tFloatForKey (entity_t *ent, const char *key)\n{\n\tchar\t*k;\n\t\n\tk = ValueForKey (ent, key);\n\treturn atof(k);\n}\n\nint IntForKey (entity_t *ent, const char *key)\n{\n\tchar\t*k;\n\t\n\tk = ValueForKey (ent, key);\n\treturn atoi(k);\n}\n\nvoid \tGetVectorForKey (entity_t *ent, const char *key, vec3_t vec)\n{\n\tchar\t*k;\n\t\n\tk = ValueForKey (ent, key);\n\tsscanf (k, \"%f %f %f\", &vec[0], &vec[1], &vec[2]);\n}\n\n/*\n===============\nEntity_FreeEpairs\n\nFrees the entity epairs.\n===============\n*/\nvoid Entity_FreeEpairs(entity_t *e)\n{\n\tepair_t\t*ep, *next;\n\n\tfor (ep = e->epairs; ep; ep = next)\n\t{\n\t\tnext = ep->next;\n\t\tfree (ep->key);\n\t\tfree (ep->value);\n\t\tfree (ep);\n\t}\n\te->epairs = NULL;\n}\n\n/*\n===========\nEntity_AddToList\n===========\n*/\nvoid Entity_AddToList(entity_t *e, entity_t *list)\n{\n\tif (e->next || e->prev)\n\t\tError (\"Entity_AddToList: allready linked\");\n\te->next = list->next;\n\tlist->next->prev = e;\n\tlist->next = e;\n\te->prev = list;\n}\n\n/*\n===========\nEntity_RemoveFromList\n===========\n*/\nvoid Entity_RemoveFromList (entity_t *e)\n{\n\tif (!e->next || !e->prev)\n\t\tError (\"Entity_RemoveFromList: not linked\");\n\te->next->prev = e->prev;\n\te->prev->next = e->next;\n\te->next = e->prev = NULL;\n}\n\n\n\n/*\n===============\nEntity_Free\n\nFrees the entity and any brushes is has.\nThe entity is removed from the global entities list.\n===============\n*/\nvoid Entity_Free (entity_t *e)\n{\n\t// do we have a plugin entity ?\n\tif ( e->pPlugEnt )\n\t{\n\t\te->pPlugEnt->DecRef();\n\t\te->pPlugEnt = NULL;\n\t}\n\n\twhile (e->brushes.onext != &e->brushes)\n\t\tBrush_Free (e->brushes.onext);\n\n\tif (e->next)\n\t{\n\t\te->next->prev = e->prev;\n\t\te->prev->next = e->next;\n\t}\n\n\tEntity_FreeEpairs(e);\n\n\tfree (e);\n}\n\n/*\n=================\nEntity_MemorySize\n=================\n*/\nint Entity_MemorySize(entity_t *e)\n{\n\tepair_t\t*ep;\n\tint size = 0;\n\n\tfor (ep = e->epairs; ep; ep = ep->next)\n\t{\n\t\tsize += _msize(ep->key);\n\t\tsize += _msize(ep->value);\n\t\tsize += _msize(ep);\n\t}\n\tsize += _msize(e);\n\treturn size;\n}\n\n/*\n=================\nParseEpair\n=================\n*/\nepair_t *ParseEpair (void)\n{\n\tepair_t\t*e;\n\t\n\te = (epair_t*)qmalloc (sizeof(*e));\n\t\n\te->key = (char*)qmalloc(strlen(token)+1);\n\tstrcpy (e->key, token);\n\n\tGetToken (false);\n\te->value = (char*)qmalloc(strlen(token)+1);\n\tstrcpy (e->value, token);\n\n\treturn e;\n}\n\n/*\n================\nEntity_Parse\n\nIf onlypairs is set, the classname info will not\nbe looked up, and the entity will not be added\nto the global list.  Used for parsing the project.\n================\n*/\nentity_t\t*Entity_Parse (qboolean onlypairs, brush_t* pList)\n{\n\tentity_t\t*ent;\n\teclass_t\t*e;\n\tbrush_t\t\t*b;\n\tvec3_t\t\tmins, maxs;\n\tepair_t\t\t*ep;\n\tqboolean\thas_brushes;\n\t\n\tif (!GetToken (true))\n\t\treturn NULL;\n\t\n\tif (strcmp (token, \"{\") )\n\t\tError (\"ParseEntity: { not found\");\n\t\n\tent = (entity_t*)qmalloc (sizeof(*ent));\n\tent->entityId = g_entityId++;\n\tent->brushes.onext = ent->brushes.oprev = &ent->brushes;\n\n  int n = 0;\n\tdo\n\t{\n\t\tif (!GetToken (true))\n\t\t{\n\t\t\tWarning (\"ParseEntity: EOF without closing brace\");\n\t\t\treturn NULL;\n\t\t}\n\t\tif (!strcmp (token, \"}\") )\n\t\t\tbreak;\n\t\tif (!strcmp (token, \"{\") )\n\t\t{\n\t\t\tb = Brush_Parse ();\n\t\t\tif (b != NULL)\n\t\t\t{\n\t\t\t\tb->owner = ent;\n\t\t\t\t// add to the end of the entity chain\n\t\t\t\tb->onext = &ent->brushes;\n\t\t\t\tb->oprev = ent->brushes.oprev;\n\t\t\t\tent->brushes.oprev->onext = b;\n\t\t\t\tent->brushes.oprev = b;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tep = ParseEpair ();\n\t\t\tep->next = ent->epairs;\n\t\t\tent->epairs = ep;\n\t\t}\n\t} while (1);\n\t\n  // group info entity?\n  if (strcmp(ValueForKey (ent, \"classname\"), \"group_info\") == 0)\n    return ent;\n\n\tif (onlypairs)\n\t\treturn ent;\n\t\n\tif (ent->brushes.onext == &ent->brushes)\n\t\thas_brushes = false;\n\telse\n\t\thas_brushes = true;\n\t\n\tGetVectorForKey (ent, \"origin\", ent->origin);\n\t\n\te = Eclass_ForName (ValueForKey (ent, \"classname\"), has_brushes);\n\tent->eclass = e;\n\tif ( e->nShowFlags & ECLASS_PLUGINENTITY )\n\t{\n\t\t// locate the plugin\n\t\tCPlugIn * pPlug = g_pParentWnd->GetPlugInMgr().PluginForModule( e->hPlug );\n\t\tif (pPlug)\n\t\t{\n\t\t\t// create the plugin entity\n\t\t\tIPluginEntity* pPlugEnt = pPlug->CreatePluginEntity( ent );\n\t\t\tif (pPlugEnt)\n\t\t\t{\n\t\t\t\tent->pPlugEnt = pPlugEnt;\n\t\t\t\t// the brush is used to select and move\n\t\t\t\tpPlugEnt->GetBounds( mins, maxs );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t// give it a default bounding box\n\t\t\t\tSetKeyValue (ent, \"model\", \"\");\n\t\t\t\tmins[0] = -4; mins[1] = -4; mins[2] = -4;\n\t\t\t\tmaxs[0] = 4; maxs[1] = 4; maxs[2] = 4;\n\t\t\t\tVectorAdd( mins, ent->origin, mins );\n\t\t\t\tVectorAdd( maxs, ent->origin, maxs );\n\t\t\t}\n\t\t\tb = Brush_Create (mins, maxs, &ent->eclass->texdef);\n\t\t\tEntity_LinkBrush (ent, b);\n\t\t\tBrush_Build( b, true );\n\t\t}\n\t\telse\n\t\t\tSys_Printf(\"WARNING: plugin lookup failed for plugin entities\\n\");\n\t}\n\telse if (e->fixedsize)\n\t{\t// fixed size entity\n\t\tif (ent->brushes.onext != &ent->brushes)\n\t\t{\n\t\t\tprintf (\"Warning: Fixed size entity with brushes\\n\");\n#if 0\n\t\t\twhile (ent->brushes.onext != &ent->brushes)\n\t\t\t{\t// FIXME: this will free the entity and crash!\n\t\t\t\tBrush_Free (b);\n\t\t\t}\n#endif\n\t\t\tent->brushes.next = ent->brushes.prev = &ent->brushes;\n\t\t}\n\t\t\n\t\t// create a custom brush\n\t\tVectorAdd (e->mins, ent->origin, mins);\n\t\tVectorAdd (e->maxs, ent->origin, maxs);\n\t\t\n\t\tfloat a = 0;\n\t\tif (e->nShowFlags & ECLASS_MISCMODEL)\n\t\t{\n\t\t\tchar* p = ValueForKey(ent, \"model\");\n\t\t\tif (p != NULL && strlen(p) > 0)\n\t\t\t{\n\t\t\t\tvec3_t vMin, vMax;\n\t\t\t\ta = FloatForKey (ent, \"angle\");\n\t\t\t\tif (GetCachedModel(ent, p, vMin, vMax))\n\t\t\t\t{\n\t\t\t\t\t// create a custom brush\n\t\t\t\t\tVectorAdd (ent->md3Class->mins, ent->origin, mins);\n\t\t\t\t\tVectorAdd (ent->md3Class->maxs, ent->origin, maxs);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tb = Brush_Create (mins, maxs, &e->texdef);\n\t\t\n\t\tif (a)\n\t\t{\n\t\t\tvec3_t vAngle;\n\t\t\tvAngle[0] = vAngle[1] = 0;\n\t\t\tvAngle[2] = a;\n\t\t\tBrush_Rotate(b, vAngle, ent->origin, false);\n\t\t}\n\t\t\n\t\t\n\t\tb->owner = ent;\n\t\t\n\t\tb->onext = ent->brushes.onext;\n\t\tb->oprev = &ent->brushes;\n\t\tent->brushes.onext->oprev = b;\n\t\tent->brushes.onext = b;\n\t}\n\telse\n\t{\t// brush entity\n\t\tif (ent->brushes.next == &ent->brushes)\n\t\t\tprintf (\"Warning: Brush entity with no brushes\\n\");\n\t}\n\t\n\t// add all the brushes to the main list\n\tif (pList)\n\t{\n\t\tfor (b=ent->brushes.onext ; b != &ent->brushes ; b=b->onext)\n\t\t{\n\t\t\tb->next = pList->next;\n\t\t\tpList->next->prev = b;\n\t\t\tb->prev = pList;\n\t\t\tpList->next = b;\n\t\t}\n\t}\n\t\n\treturn ent;\n}\n\nvoid VectorMidpoint(vec3_t va, vec3_t vb, vec3_t& out)\n{\n  for (int i = 0; i < 3; i++)\n    out[i] = va[i] + ((vb[i] - va[i]) / 2);\n}\n\n\n/*\n============\nEntity_Write\n============\n*/\nvoid Entity_Write (entity_t *e, FILE *f, qboolean use_region)\n{\n\tepair_t\t\t*ep;\n\tbrush_t\t\t*b;\n\tvec3_t\t\torigin;\n\tchar\t\ttext[128];\n\tint\t\t\tcount;\n\n\t// if none of the entities brushes are in the region,\n\t// don't write the entity at all\n\tif (use_region)\n\t{\n\t\t// in region mode, save the camera position as playerstart\n\t\tif ( !strcmp(ValueForKey (e, \"classname\"), \"info_player_start\") )\n\t\t{\n\t\t\tfprintf (f, \"{\\n\");\n\t\t\tfprintf (f, \"\\\"classname\\\" \\\"info_player_start\\\"\\n\");\n\t\t\tfprintf (f, \"\\\"origin\\\" \\\"%i %i %i\\\"\\n\", (int)g_pParentWnd->GetCamera()->Camera().origin[0],\n\t\t\t\t(int)g_pParentWnd->GetCamera()->Camera().origin[1], (int)g_pParentWnd->GetCamera()->Camera().origin[2]);\n\t\t\tfprintf (f, \"\\\"angle\\\" \\\"%i\\\"\\n\", (int)g_pParentWnd->GetCamera()->Camera().angles[YAW]);\n\t\t\tfprintf (f, \"}\\n\");\n\t\t\treturn;\n\t\t}\n\n\t\tfor (b=e->brushes.onext ; b != &e->brushes ; b=b->onext)\n\t\t\tif (!Map_IsBrushFiltered(b))\n\t\t\t\tbreak;\t// got one\n\n\t\tif (b == &e->brushes)\n\t\t\treturn;\t\t// nothing visible\n\t}\n\n\tif ( e->eclass->nShowFlags & ECLASS_PLUGINENTITY )\n\t{\n\t\t// NOTE: the whole brush placement / origin stuff is a mess\n\t\tVectorCopy( e->origin, origin );\n\t\tsprintf (text, \"%i %i %i\", (int)origin[0], (int)origin[1], (int)origin[2]);\n\t\tSetKeyValue (e, \"origin\", text);\n\t}\n\t// if fixedsize, calculate a new origin based on the current\n\t// brush position\n\telse if (e->eclass->fixedsize)\n\t{\n\t\tif (e->eclass->nShowFlags & ECLASS_MISCMODEL && e->md3Class != NULL)\n\t\t{\n\t\t\tVectorCopy(e->origin, origin);\n\t\t\t//VectorSubtract (e->brushes.onext->mins, e->md3Class->mins, origin);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVectorSubtract (e->brushes.onext->mins, e->eclass->mins, origin);\n\t\t}\n\t\tsprintf (text, \"%i %i %i\", (int)origin[0], (int)origin[1], (int)origin[2]);\n\t\tSetKeyValue (e, \"origin\", text);\n\t}\n\n\tfprintf (f, \"{\\n\");\n\tfor (ep = e->epairs ; ep ; ep=ep->next)\n\t\tfprintf (f, \"\\\"%s\\\" \\\"%s\\\"\\n\", ep->key, ep->value);\n\n\tif (!e->eclass->fixedsize)\n\t{\n\t\tcount = 0;\n\t\tfor (b=e->brushes.onext ; b != &e->brushes ; b=b->onext)\n\t\t{\n\t\t\tif (!use_region || !Map_IsBrushFiltered (b))\n      {\n\t\t\t\tfprintf (f, \"// brush %i\\n\", count);\n\t\t\t\tcount++;\n\t\t\t\tBrush_Write (b, f);\n\t\t\t}\n\t\t}\n\t}\n\tfprintf (f, \"}\\n\");\n}\n\n\n\nqboolean IsBrushSelected(brush_t* bSel)\n{\n\tfor (brush_t* b = selected_brushes.next ;b != NULL && b != &selected_brushes; b = b->next)\n  {\n    if (b == bSel)\n      return true;\n  }\n  return false;\n}\n\n//\n//============\n//Entity_WriteSelected\n//============\n//\nvoid Entity_WriteSelected(entity_t *e, FILE *f)\n{\n\tepair_t\t\t*ep;\n\tbrush_t\t\t*b;\n\tvec3_t\t\torigin;\n\tchar\t\ttext[128];\n\tint\t\t\tcount;\n\n\tfor (b=e->brushes.onext ; b != &e->brushes ; b=b->onext)\n\t\tif (IsBrushSelected(b))\n\t\t\tbreak;\t// got one\n\n\tif (b == &e->brushes)\n\t\treturn;\t\t// nothing selected\n\n\t// if fixedsize, calculate a new origin based on the current\n\t// brush position\n\tif (e->eclass->fixedsize)\n\t{\n    if (e->eclass->nShowFlags & ECLASS_MISCMODEL && e->md3Class != NULL)\n    {\n      VectorCopy(e->origin, origin);\n\t\t  //VectorSubtract (e->brushes.onext->mins, e->md3Class->mins, origin);\n    }\n    else\n    {\n\t\t  VectorSubtract (e->brushes.onext->mins, e->eclass->mins, origin);\n    }\n    sprintf (text, \"%i %i %i\", (int)origin[0], (int)origin[1], (int)origin[2]);\n\t\tSetKeyValue (e, \"origin\", text);\n\t}\n\n  fprintf (f, \"{\\n\");\n\tfor (ep = e->epairs ; ep ; ep=ep->next)\n\t  fprintf (f, \"\\\"%s\\\" \\\"%s\\\"\\n\", ep->key, ep->value);\n\n  if (!e->eclass->fixedsize)\n  {\n\t  count = 0;\n\t  for (b=e->brushes.onext ; b != &e->brushes ; b=b->onext)\n\t  {\n\t\t  if (IsBrushSelected(b))\n\t\t  {\n\t\t\t  fprintf (f, \"// brush %i\\n\", count);\n\t\t\t  count++;\n\t\t\t  Brush_Write (b, f);\n\t\t  }\n\t  }\n  }\n\tfprintf (f, \"}\\n\");\n}\n\n\n//\n//============\n//Entity_WriteSelected to a CMemFile\n//============\n//\nvoid Entity_WriteSelected(entity_t *e, CMemFile* pMemFile)\n{\n\tepair_t\t\t*ep;\n\tbrush_t\t\t*b;\n\tvec3_t\t\torigin;\n\tchar\t\ttext[128];\n\tint\t\t\tcount;\n\n\tfor (b=e->brushes.onext ; b != &e->brushes ; b=b->onext)\n\t\tif (IsBrushSelected(b))\n\t\t\tbreak;\t// got one\n\n\tif (b == &e->brushes)\n\t\treturn;\t\t// nothing selected\n\n\t// if fixedsize, calculate a new origin based on the current\n\t// brush position\n\tif (e->eclass->fixedsize)\n\t{\n    if (e->eclass->nShowFlags & ECLASS_MISCMODEL && e->md3Class != NULL)\n    {\n\t\t  //VectorSubtract (e->brushes.onext->mins, e->md3Class->mins, origin);\n      VectorCopy(e->origin, origin);\n    }\n    else\n    {\n\t\t  VectorSubtract (e->brushes.onext->mins, e->eclass->mins, origin);\n    }\n    sprintf (text, \"%i %i %i\", (int)origin[0], (int)origin[1], (int)origin[2]);\n\t\tSetKeyValue (e, \"origin\", text);\n\t}\n\n  MemFile_fprintf(pMemFile, \"{\\n\");\n\tfor (ep = e->epairs ; ep ; ep=ep->next)\n\t  MemFile_fprintf(pMemFile, \"\\\"%s\\\" \\\"%s\\\"\\n\", ep->key, ep->value);\n\n  if (!e->eclass->fixedsize)\n  {\n\t  count = 0;\n\t  for (b=e->brushes.onext ; b != &e->brushes ; b=b->onext)\n\t  {\n\t\t  if (IsBrushSelected(b))\n\t\t  {\n\t\t\t  MemFile_fprintf(pMemFile, \"// brush %i\\n\", count);\n\t\t\t  count++;\n\t\t\t  Brush_Write (b, pMemFile);\n\t\t  }\n\t  }\n  }\n\tMemFile_fprintf(pMemFile, \"}\\n\");\n}\n\n\n\n\n/*\n============\nEntity_Create\n\nCreates a new entity out of the selected_brushes list.\nIf the entity class is fixed size, the brushes are only\nused to find a midpoint.  Otherwise, the brushes have\ntheir ownership transfered to the new entity.\n============\n*/\nentity_t\t*Entity_Create (eclass_t *c)\n{\n\tentity_t\t*e;\n\tbrush_t\t\t*b;\n\tvec3_t\t\tmins, maxs;\n\tint\t\t\ti;\n\n\t// check to make sure the brushes are ok\n\n\tfor (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n  {\n\t\tif (b->owner != world_entity)\n\t\t{\n\t\t\tSys_Printf (\"Entity NOT created, brushes not all from world\\n\");\n\t\t\tSys_Beep ();\n\t\t\treturn NULL;\n\t\t}\n  }\n\n\t// create it\n\n\te = (entity_t*)qmalloc(sizeof(*e));\n\te->entityId = g_entityId++;\n\te->brushes.onext = e->brushes.oprev = &e->brushes;\n\te->eclass = c;\n\tSetKeyValue (e, \"classname\", c->name);\n\n\t// add the entity to the entity list\n  Entity_AddToList(e, &entities);\n\n\t// plugin entity ?\n\tif (c->nShowFlags & ECLASS_PLUGINENTITY)\n\t{\n\t\t// locate the plugin\n\t\tCPlugIn * pPlug = g_pParentWnd->GetPlugInMgr().PluginForModule( c->hPlug );\n\t\tif (pPlug)\n\t\t{\n\t\t\t//\n\t\t\t// just use the selection for positioning\n\t\t\t//\n\t\t\tb = selected_brushes.next;\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t\te->origin[i] = b->mins[i] - c->mins[i];\n\n\t\t\t// create the plugin entity\n\t\t\tIPluginEntity* pPlugEnt = pPlug->CreatePluginEntity( e );\n\t\t\t\n\t\t\tif (pPlugEnt)\n\t\t\t{\n\t\t\t\te->pPlugEnt = pPlugEnt;\n\t\t\t\t// the brush is used to select and move\n\t\t\t\tpPlugEnt->GetBounds( mins, maxs );\n\t\t\t\tb = Brush_Create (mins, maxs, &c->texdef);\n\t\t\t\t\n\t\t\t\tEntity_LinkBrush (e, b);\n\t\t\t\t\n\t\t\t\t// delete the current selection\n\t\t\t\tSelect_Delete ();\n\t\t\t\t\n\t\t\t\t// select the new brush\n\t\t\t\tb->next = b->prev = &selected_brushes;\n\t\t\t\tselected_brushes.next = selected_brushes.prev = b;\n\t\t\t\t\n\t\t\t\tBrush_Build( b );\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tSys_Printf( \"WARNING: plugin lookup failed while creating a plugin entitiy in Entity_Create\\n\" );\n\t\t\treturn NULL;\n\t\t}\n\t}\n\telse if (c->fixedsize)\n\t{\n\t\t//\n\t\t// just use the selection for positioning\n\t\t//\n\t\tb = selected_brushes.next;\n\t\tfor (i=0 ; i<3 ; i++)\n\t\t\te->origin[i] = b->mins[i] - c->mins[i];\n\n\t\t// create a custom brush\n\t\tVectorAdd (c->mins, e->origin, mins);\n\t\tVectorAdd (c->maxs, e->origin, maxs);\n\n\t  b = Brush_Create (mins, maxs, &c->texdef);\n\n\t\tEntity_LinkBrush (e, b);\n\n\t\t// delete the current selection\n\t\tSelect_Delete ();\n\n\t\t// select the new brush\n\t\tb->next = b->prev = &selected_brushes;\n\t\tselected_brushes.next = selected_brushes.prev = b;\n\n\t\tBrush_Build( b );\n\t}\n\telse\n\t{\n\t\t//\n\t\t// change the selected brushes over to the new entity\n\t\t//\n\t\tfor (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n\t\t{\n\t\t\tEntity_UnlinkBrush (b);\n\t\t\tEntity_LinkBrush (e, b);\n\t\t\tBrush_Build( b );\t// so the key brush gets a name\n\t\t}\n\t}\n\n\tSys_UpdateWindows (W_ALL);\n\treturn e;\n}\n\n\n/*\n===========\nEntity_LinkBrush\n===========\n*/\nvoid Entity_LinkBrush (entity_t *e, brush_t *b)\n{\n\tif (b->oprev || b->onext)\n\t\tError (\"Entity_LinkBrush: Allready linked\");\n\tb->owner = e;\n\n\tb->onext = e->brushes.onext;\n\tb->oprev = &e->brushes;\n\te->brushes.onext->oprev = b;\n\te->brushes.onext = b;\n}\n\n/*\n===========\nEntity_UnlinkBrush\n===========\n*/\nvoid Entity_UnlinkBrush (brush_t *b)\n{\n\t//if (!b->owner || !b->onext || !b->oprev)\n\tif (!b->onext || !b->oprev)\n\t\tError (\"Entity_UnlinkBrush: Not currently linked\");\n\tb->onext->oprev = b->oprev;\n\tb->oprev->onext = b->onext;\n\tb->onext = b->oprev = NULL;\n\tb->owner = NULL;\n}\n\n\n/*\n===========\nEntity_Clone\n===========\n*/\nentity_t\t*Entity_Clone (entity_t *e)\n{\n\tentity_t\t*n;\n\tepair_t\t\t*ep, *np;\n\n\tn = (entity_t*)qmalloc(sizeof(*n));\n\tn->entityId = g_entityId++;\n\tn->brushes.onext = n->brushes.oprev = &n->brushes;\n\tn->eclass = e->eclass;\n\n\t// add the entity to the entity list\n\tEntity_AddToList(n, &entities);\n\n\tfor (ep = e->epairs ; ep ; ep=ep->next)\n\t{\n\t\tnp = (epair_t*)qmalloc(sizeof(*np));\n\t\tnp->key = copystring(ep->key);\n\t\tnp->value = copystring(ep->value);\n\t\tnp->next = n->epairs;\n\t\tn->epairs = np;\n\t}\n\treturn n;\n}\n\nint GetUniqueTargetId(int iHint)\n{\n\tint iMin, iMax, i;\n\tBOOL fFound;\n\tentity_t *pe;\n\t\n\tfFound = FALSE;\n\tpe = entities.next;\n\tiMin = 0; \n\tiMax = 0;\n\t\n\tfor (; pe != NULL && pe != &entities ; pe = pe->next)\n\t{\n\t\ti = IntForKey(pe, \"target\");\n\t\tif (i)\n\t\t{\n\t\t\tiMin = min(i, iMin);\n\t\t\tiMax = max(i, iMax);\n\t\t\tif (i == iHint)\n\t\t\t\tfFound = TRUE;\n\t\t}\n\t}\n\n\tif (fFound)\n\t\treturn iMax + 1;\n\telse\n\t\treturn iHint;\n}\n\nentity_t *FindEntity(char *pszKey, char *pszValue)\n{\n\tentity_t *pe;\n\t\n\tpe = entities.next;\n\t\n\tfor (; pe != NULL && pe != &entities ; pe = pe->next)\n\t{\n\t\tif (!strcmp(ValueForKey(pe, pszKey), pszValue))\n\t\t\treturn pe;\n\t}\n\n\treturn NULL;\n}\n\nentity_t *FindEntityInt(char *pszKey, int iValue)\n{\n\tentity_t *pe;\n\t\n\tpe = entities.next;\n\t\n\tfor (; pe != NULL && pe != &entities ; pe = pe->next)\n\t{\n\t\tif (IntForKey(pe, pszKey) == iValue)\n\t\t\treturn pe;\n\t}\n\n\treturn NULL;\n}\n"
  },
  {
    "path": "q3radiant/ENTITY.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n    // entity.h\n\n    void Eclass_InitForSourceDirectory (char *path);\n    eclass_t *Eclass_ForName (char *name, qboolean has_brushes);\n    \n    // forward declare this one\n    class IPluginEntity;\n    \n    typedef struct entity_s\n    {\n    \tstruct entity_s\t*prev, *next;\n    \tbrush_t\t\tbrushes;\t\t\t\t\t// head/tail of list\n     \tint\t\t\tundoId, redoId, entityId;\t// used for undo/redo\n    \tvec3_t\t\torigin;\n    \teclass_t\t*eclass;\n    \tepair_t\t\t*epairs;\n    \teclass_t  *md3Class;\n    \tIPluginEntity *pPlugEnt;\n      vec3_t vRotation;   // valid for misc_models only\n      vec3_t vScale;      // valid for misc_models only\n    } entity_t;\n    \n    char \t*ValueForKey (entity_t *ent, const char *key);\n    void\tSetKeyValue (entity_t *ent, const char *key, const char *value);\n    void \tSetKeyValue (epair_t *&e, const char *key, const char *value);\n    void \tDeleteKey (entity_t *ent, const char *key);\n    void \tDeleteKey (epair_t *&e, const char *key);\n    float\tFloatForKey (entity_t *ent, const char *key);\n    int\t\tIntForKey (entity_t *ent, const char *key);\n    void \tGetVectorForKey (entity_t *ent, const char *key, vec3_t vec);\n    \n    void\t\tEntity_Free (entity_t *e);\n    void\t\tEntity_FreeEpairs(entity_t *e);\n    int\t\t\tEntity_MemorySize(entity_t *e);\n    entity_t\t*Entity_Parse (qboolean onlypairs, brush_t* pList = NULL);\n    void\t\tEntity_Write (entity_t *e, FILE *f, qboolean use_region);\n    void\t\tEntity_WriteSelected(entity_t *e, FILE *f);\n    void\t\tEntity_WriteSelected(entity_t *e, CMemFile*);\n    entity_t\t*Entity_Create (eclass_t *c);\n    entity_t\t*Entity_Clone (entity_t *e);\n    void\t\tEntity_AddToList(entity_t *e, entity_t *list);\n    void\t\tEntity_RemoveFromList(entity_t *e);\n    \n    void\t\tEntity_LinkBrush (entity_t *e, brush_t *b);\n    void\t\tEntity_UnlinkBrush (brush_t *b);\n    entity_t\t*FindEntity(char *pszKey, char *pszValue);\n    entity_t\t*FindEntityInt(char *pszKey, int iValue);\n    \n    int GetUniqueTargetId(int iHint);\n    qboolean Eclass_hasModel(eclass_t *e, vec3_t &vMin, vec3_t &vMax);\n    eclass_t* GetCachedModel(entity_t *pEntity, const char *pName, vec3_t &vMin, vec3_t &vMax);\n    \n    //Timo : used for parsing epairs in brush primitive\n    epair_t* ParseEpair(void);\n    char *ValueForKey ( epair_t *&e, const char *key);\n"
  },
  {
    "path": "q3radiant/ENTITYW.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// entity.h\n\n#define DlgXBorder 5\n#define DlgYBorder 5\n\n\n#define EntList\t\t0\n#define EntComment\t1\n#define EntCheck1\t2\n#define EntCheck2\t3\n#define EntCheck3\t4\n#define EntCheck4\t5\n#define EntCheck5\t6\n#define EntCheck6\t7\n#define EntCheck7\t8\n#define EntCheck8\t9\n#define EntCheck9\t10\n#define EntCheck10\t11\n#define EntCheck11\t12\n#define EntCheck12\t13\n#define EntProps\t14\n#define\tEntDir0\t\t15\n#define\tEntDir45\t16\n#define\tEntDir90\t17\n#define\tEntDir135\t18\n#define\tEntDir180\t19\n#define\tEntDir225\t20\n#define\tEntDir270\t21\n#define\tEntDir315\t22\n#define\tEntDirUp\t23\n#define\tEntDirDown\t24\n#define EntDelProp\t25\n#define\tEntKeyLabel\t26\n#define\tEntKeyField\t27\n#define\tEntValueLabel 28\n#define\tEntValueField 29\n#define EntColor      30\n#define EntAssignSounds 31\n#define EntAssignModels 32\n#define EntTab 33\n\n#define EntLast\t\t34\n\nextern HWND hwndEnt[EntLast];\n\nextern int rgIds[EntLast];\n\n"
  },
  {
    "path": "q3radiant/EPAIRS.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef\tEPAIRS_H_\n#define\tEPAIRS_H_\n\ntypedef struct\n{\n\tchar  *key;\n\tchar  *value;\n} userEpair_t;\n\nuserEpair_t eclassStr[] =\n{\n\t//////////////////////////////\n\t// Worldspawn\n\t//////////////////////////////\n\t{\"classname\",   \"worldspawn\"},\n\t{\"color\",       \"0 0 0\"},\n\t{\"rem\",         \"Only used for the world entity.\"},\n\t{\"rem\",\t\t\t\"cdtrack - number of CD track to play when level starts\"},\n\t{\"rem\",\t\t\t\"fog_value - level of fog for this map\"},\n\t\n\t//////////////////////////////\n\t// Light\n\t//////////////////////////////\n\t{\"classname\",\t\"light\"},\n\t{\"size\",\t\t\"-8 -8 -8 8 8 8\"},\n\t{\"color\",\t\t\"0 1 0\"},\n\t{\"flag\",\t\t\"START_OFF\"},\n\n\t{\"rem\",\t\t\t\"style - number of style to use, 0-63\"},\n\t{\"rem\",\t\t\t\"nelnosmama - string to define lightstyle\"},\n\n\t//////////////////////////////\n\t// light_walltorch\n\t//////////////////////////////\n\t{\"classname\",\t\"light_walltorch\"},\n\t{\"size\",\t\t\"-8 -8 -8 8 8 8\"},\n\t{\"color\",\t\t\"0 1 0\"},\n\t{\"flag\",\t\t\"START_ON\"},\n\n\t{\"rem\",\t\t\t\"style - number of style to use, 0-63\"},\n\t{\"rem\",\t\t\t\"nelnosmama - string to define lightstyle\"},\n\n\t//////////////////////////////\n\t// light_spot\n\t//////////////////////////////\n\t{\"classname\",\t\"light_spot\"},\n\t{\"size\",\t\t\"-8 -8 -8 8 8 8\"},\n\t{\"color\",\t\t\"0 1 0\"},\n\t{\"flag\",\t\t\"START_ON\"},\n\n\t{\"rem\",\t\t\t\"Used to make a spotlight.  If it is targeted at another entity,\"},\n\t{\"rem\",\t\t\t\"the spotlight will point directly at it, otherwise it will point\"},\n\t{\"rem\",\t\t\t\"in the direction of its 'angle' field\"},\n\t{\"rem\",\t\t\t\"\"},\n\t{\"rem\",\t\t\t\"style - number of style to use, 0-63\"},\n\t{\"rem\",\t\t\t\"nelnosmama - string to define lightstyle\"},\n\n\t//////////////////////////////\n\t// light_strobe\n\t//////////////////////////////\n\t{\"classname\",\t\"light_strobe\"},\n\t{\"size\",\t\t\"-8 -8 -8 8 8 8\"},\n\t{\"color\",\t\t\"0 1 0\"},\n\n\t{\"flag\",\t\t\"START_ON\"},\n\t{\"rem\",\t\t\t\"style - number of style to use, 0-63\"},\n\t{\"rem\",\t\t\t\"nelnosmama - string to define lightstyle\"},\n\n\t//////////////////////////////\n\t// effect_fog\n\t//////////////////////////////\n\t{\"classname\",\t\"effect_fog\"},\n\t{\"color\",\t\t\"0 1 0\"},\n\t{\"rem\",\t\t\t\"Duh, fog.\"},\n\t{\"rem\",\t\t\t\"\"},\n\n\t//////////////////////////////\n\t// effect_snow\n\t//////////////////////////////\n\t{\"classname\",\t\"effect_snow\"},\n\t{\"color\",\t\t\"1 1 1\"},\n\t{\"height\",\t\t\"10\"},\n\t{\"rem\",\t\t\t\"Snow!\"},\n\t{\"rem\",\t\t\t\"Do you realize the entire street value of this mountain?\"},\n\t\n\t//////////////////////////////\n\t// effect_rain\n\t//////////////////////////////\n\t{\"classname\",\t\"effect_rain\"},\n\t{\"height\",\t\t\"10\"},\n\t{\"color\",\t\t\"0 0.5 0.8\"},\n\t{\"rem\",\t\t\t\"Rain!\"},\n\t{\"rem\",\t\t\t\"Yellow rain?\"},\n\n\t//////////////////////////////\n\t// func_door\n\t//////////////////////////////\n\t{\"classname\",    \"func_door\"},\n\t{\"color\",        \"0 0.5 0.8\"},\n\t{\"health\",\t\t \"0\"},\n\t{\"speed\",\t\t \"100\"},\n\t{\"wait\",\t\t \"3\"},\n\t{\"lip\",\t\t\t \"8\"},\n\t{\"dmg\",\t\t\t \"2\"},\n\t{\"angle\",\t\t \"0 0 0\"},\n\t{\"message\",\t\t \"you suck\"},\n\t{\"targetname\",\t \"\"},\n\t{\"flag\",         \"START_OPEN\"},\n\t{\"flag\",         \"REVERSE\"},\n\t{\"flag\",         \"DOOR_DONT_LINK\"},\n\t{\"flag\",         \"TOGGLE\"},\n\t{\"flag\",\t\t \"AUTO_OPEN\"},\n\t{\"flag\",\t\t \"USE_TO_CLOSE\"},\n\n\t{\"rem\", \"Doors that touch are linked together to operate as one.\"},\n\t{\"rem\", \"  \"},\n\t{\"rem\", \"message - printed when the door is touched if it is a trigger door and it hasn't been fired yet\"},\n\t{\"rem\", \"angle - determines the opening direction\"},\n\t{\"rem\", \"targetname - if set, no touch field will be spawned and a remote button or trigger field activates the door.\"},\n\t{\"rem\", \"health - if set, door must be shot open\"},\n\t{\"rem\",\t\"speed - movement speed (100 default)\"},\n\t{\"rem\", \"wait - time to wait before returning (3 default, -1 = never return)\"},\n\t{\"rem\",\t\"lip - amount of door visible remaining at end of move (8 default)\"},\n\t{\"rem\",\t\"dmg - damage to inflict when blocked (2 default)\"},\n\t{\"rem\", \"sound_opening - name of the sound to play during opening, ie. doors/creek.wav\"},\n\t{\"rem\",\t\"sound_open_finish - name of the sound to play when opening completes, ie. doors/slam.wav\"},\n\t{\"rem\", \"sound_closing - name of the sound to play when closing starts, ie. doors/creek.wav\"},\n\t{\"rem\",\t\"sound_close_finish - name of the sound to play when closing completes, ie. doors/slam.wav\"},\n\t{\"rem\", \"  \"},\n\t{\"rem\", \"Spawnflags:\"},\n    {\"rem\", \"TOGGLE causes the door to wait in both the start and end states for a\"},\n    {\"rem\", \"trigger event.\"},\n    {\"rem\", \"  \"},\n    {\"rem\", \"START_OPEN causes the door to move to its destination when spawned, and\"},\n    {\"rem\", \"operate in reverse.  It is used to temporarily or permanently close off an\"},\n    {\"rem\", \"area when triggered (not usefull for touch or takedamage doors).\"},\n\t{\"rem\",\t\"AUTO_OPEN will spawn a trigger field around the door that can open it without\"},\n\t{\"rem\", \"its being used.\"},\n\t{\"rem\",\t\"DOOR_DONT_LINK will stop a door from being automatically linked to other doors\"},\n\t{\"rem\", \"that it touches.\"},\n\n\t//////////////////////////////\n\t// func_plat\n\t//////////////////////////////\n\t{\"classname\",    \"func_plat\"},\n\t{\"color\",        \"0 0.5 0.8\"},\n\t{\"flag\",         \"PLAT_START_UP\"},\n\t{\"flag\",         \"\"},\n\t{\"flag\",         \"\"},\n\t{\"flag\",         \"PLAT_TOGGLE\"},\n\n\t{\"rem\", \"Plats should be drawn in the up position to spawn correctly\"},\n\t{\"rem\",\t\" \"},\n\t{\"rem\", \"message - printed when the door is touched if it is a trigger door and it hasn't been fired yet\"},\n\t{\"rem\", \"angle - determines the opening direction\"},\n\t{\"rem\", \"targetname - if set, no touch field will be spawned and a remote button or trigger field activates the door.\"},\n\t{\"rem\", \"health - if set, door must be shot open\"},\n\t{\"rem\",\t\"speed - movement speed (100 default)\"},\n\t{\"rem\", \"wait - time to wait before returning (3 default, -1 = never return)\"},\n\t{\"rem\",\t\"height - number of units to move the platform up from spawn position.  If height is\"},\n\t{\"rem\", \"not specified, then the movement distance is determined based on the vertical size of the platform.\"},\n\t{\"rem\",\t\"dmg - damage to inflict when blocked (2 default)\"},\n\t{\"rem\", \"sound_up - name of the sound to play when going up, ie. doors/creek.wav\"},\n\t{\"rem\",\t\"sound_top - name of the sound to play when plat hits top, ie. doors/slam.wav\"},\n\t{\"rem\", \"sound_down - name of the sound to play when going down, ie. doors/creek.wav\"},\n\t{\"rem\",\t\"sound_bottom - name of the sound to play when plat hits bottom, ie. doors/slam.wav\"},\n\t{\"rem\",\t\" \"},\n\t{\"rem\", \"Spawnflags:\"},\n\t{\"rem\",\t\"PLAT_START_UP starts the platform in the up (drawn) position\"},\n\t{\"rem\",\t\"(height added to drawn position)\"},\n    {\"rem\", \"TOGGLE causes the platform to wait in both the start and end states for a\"},\n    {\"rem\", \"trigger event.\"},\n\n\t//////////////////////////////\n\t// func_door_rotate\n\t//////////////////////////////\n\t{\"classname\",    \"func_door_rotate\"},\n\t{\"distance\",\t \"90.0\"},\n\t{\"color\",        \"0 0.5 0.8\"},\n\t{\"message\",\t\t \"they suck\"},\n\t{\"flag\",         \"START_OPEN\"},\n\t{\"flag\",         \"REVERSE\"},\n\t{\"flag\",         \"DOOR_DONT_LINK\"},\n\t{\"flag\",         \"TOGGLE\"},\n\t{\"flag\",         \"X_AXIS\"},\n\t{\"flag\",         \"Y_AXIS\"},\n\t{\"flag\",\t\t \"AUTO_OPEN\"},\n\t{\"flag\",\t\t \"USE_TO_CLOSE\"},\n//\t{\"flag\",         \"X_AXIS\"},\n//\t{\"flag\",         \"Y_AXIS\"},\n\n\t{\"rem\", \"if two doors touch, they are assumed to be connected and operate as a unit.\"},\n\t{\"rem\", \"  \"},\n    {\"rem\", \"TOGGLE causes the door to wait in both the start and end states for a\"},\n    {\"rem\", \"trigger event.\"},\n    {\"rem\", \"  \"},\n    {\"rem\", \"START_OPEN causes the door to move to its destination when spawned, and\"},\n    {\"rem\", \"operate in reverse.  It is used to temporarily or permanently close off an\"},\n    {\"rem\", \"area when triggered (not usefull for touch or takedamage doors).\"},\n    {\"rem\", \"  \"},\n    {\"rem\", \"Key doors are allways wait -1.\"},\n    {\"rem\", \"  \"},\n    {\"rem\", \"You need to have an origin brush as part of this entity.  The center of\"},\n    {\"rem\", \"that brush will be\"},\n    {\"rem\", \"the point around which it is rotated. It will rotate around the Z axis by\"},\n    {\"rem\", \"default.  You can\"},\n    {\"rem\", \"check either the X_AXIS or Y_AXIS box to change that.\"},\n    {\"rem\", \"  \"},\n    {\"rem\", \"'distance'\tis how many degrees the door will be rotated.\"},\n    {\"rem\", \"'speed'\tdetermines how fast the door moves; default value is 100.\"},\n    {\"rem\", \"  \"},\n    {\"rem\", \"REVERSE will cause the door to rotate in the opposite direction.\"},\n    {\"rem\", \"  \"},\n    {\"rem\", \"'message'\tis printed when the door is touched if it is a trigger door and\"},\n    {\"rem\", \"\t\tit hasn't been fired yet.\"},\n    {\"rem\", \"'targetname'\tif set, no touch field will be spawned and a remote button or\"},\n    {\"rem\", \"\t\t\ttrigger field activates the door.\"},\n    {\"rem\", \"'health'\tif set, door must be shot open\"},\n    {\"rem\", \"'wait'\twait before returning (3 default, -1 = never return)\"},\n    {\"rem\", \"'dmg'\tdamage to inflict when blocked (2 default)\"},\n\t{\"rem\", \"sound_opening - name of the sound to play during opening, ie. doors/creek.wav\"},\n\t{\"rem\",\t\"sound_open_finish - name of the sound to play when opening completes, ie. doors/slam.wav\"},\n\t{\"rem\", \"sound_closing - name of the sound to play when closing starts, ie. doors/creek.wav\"},\n\t{\"rem\",\t\"sound_close_finish - name of the sound to play when closing completes, ie. doors/slam.wav\"},\n\t{\"rem\",\t\"AUTO_OPEN will spawn a trigger field around the door that can open it without\"},\n\t{\"rem\", \"its being used.\"},\n\t{\"rem\",\t\"DOOR_DONT_LINK will stop a door from being automatically linked to other doors\"},\n\t{\"rem\", \"that it touches.\"},\n\n\t//////////////////////////////\n\t// func_rotate\n\t//////////////////////////////\n\t{\"classname\",    \"func_rotate\"},\n\t{\"color\",        \"0.0 0.5 0.8\"},\n\t{\"flag\",         \"START_ON\"},\n\t{\"flag\",         \"REVERSE\"},\n\t{\"flag\",         \"X_AXIS\"},\n\t{\"flag\",         \"Y_AXIS\"},\n\n    {\"rem\", \"You need to have an origin brush as part of this entity.\"},\n\t{\"rem\", \"The center of that brush will be\"},\n    {\"rem\", \"the point around which it is rotated. It will rotate around the Z axis by\"},\n\t{\"rem\", \"default.  You can\"},\n    {\"rem\", \"check either the X_AXIS or Y_AXIS box to change that.\"},\n    {\"rem\", \"  \"},\n    {\"rem\", \"'speed'\tdetermines how fast it moves; default value is 100.\"},\n    {\"rem\", \"'dmg'\tdamage to inflict when blocked (2 default)\"},\n    {\"rem\", \"  \"},\n    {\"rem\", \"REVERSE will cause the it to rotate in the opposite direction.\"},\n\n\t//////////////////////////////\n\t// trigger_multiple\n\t//////////////////////////////\n\t{\"classname\",\t\"trigger_multiple\"},\n\t{\"color\",\t\t\"0.5 0.5 0.5\"},\n\t{\"health\",\t\t\"0\"},\n\t{\"delay\",\t\t\"0\"},\n\t{\"wait\",\t\t\"0.2\"},\n\t{\"sound\",\t\t\"\"},\n\t{\"targetname\",\t\"\"},\n\t{\"target\",\t\t\"\"},\n\t{\"killtarget\",\t\"\"},\n\t{\"message\",\t\t\"\"},\n\t{\"flag\",\t\t\"NOTOUCH\"},\n\n\t{\"rem\",\t\t\t\"a repeatable trigger, targetted at the entity with the name\"},\n\t{\"rem\",\t\t\t\"targetname.\"},\n\t{\"rem\",\t\t\t\"\"},\n\t{\"rem\",\t\t\t\"health - if set the trigger must be killed to activate\"},\n\t{\"rem\",\t\t\t\"delay - time to wait after activation before firing target\"},\n\t{\"rem\",\t\t\t\"wait - time to wait between retriggering (default = 0.2 seconds)\"},\n\t{\"rem\",\t\t\t\"\"},\n\t{\"rem\",\t\t\t\"Spawnflags:\"},\n\t{\"rem\",\t\t\t\"NOTOUCH - if set the trigger is only fired by other entities and\"},\n\t{\"rem\",\t\t\t\"not by touching.\"},\n\n\t//////////////////////////////\n\t// trigger_console\n\t//////////////////////////////\n\t{\"classname\",\t\"trigger_console\"},\n\t{\"color\",\t\t\"0.5 0.5 0.5\"},\n\t{\"wait\",\t\t\"0.2\"},\n\t{\"command\",\t\t\"\"},\n\t{\"rem\",\t\t\t\"\"},\n\t{\"rem\",\t\t\t\"command - the command to send to the console when triggered\"},\n\n\t//////////////////////////////\n\t// trigger_once\n\t//////////////////////////////\n\t{\"classname\",\t\"trigger_once\"},\n\t{\"color\",\t\t\"0.5 0.5 0.5\"},\n\t{\"angle\",\t\t \"0 0 0\"},\n\t{\"health\",\t\t\"0\"},\n\t{\"delay\",\t\t\"0\"},\n\t{\"sound\",\t\t\"\"},\n\t{\"targetname\",\t\"\"},\n\t{\"killtarget\",\t\"\"},\n\t{\"message\",\t\t\"\"},\n\t{\"flag\",\t\t\"NOTOUCH\"},\n\n\t{\"rem\",\t\t\t\"triggers once, then removes itself\"},\n\t{\"rem\",\t\t\t\" \"},\n\t{\"rem\",\t\t\t\"health - if set the trigger must be killed to activate\"},\n\t{\"rem\",\t\t\t\"delay - time to wait after activation before firing target\"},\n\t{\"rem\",\t\t\t\"wait - time to wait between retriggering (default = 0.2 seconds)\"},\n\t{\"rem\",\t\t\t\"sound - name of sound to play upon firing\"},\n\t{\"rem\",\t\t\t\" \"},\n\t{\"rem\",\t\t\t\"Spawnflags:\"},\n\t{\"rem\",\t\t\t\"NOTOUCH - if set the trigger is only fired by other entities and\"},\n\t{\"rem\",\t\t\t\"not by touching.\"},\n\n\t//////////////////////////////\n\t// trigger_relay\n\t//////////////////////////////\n\t{\"classname\",\t\"trigger_relay\"},\n\t{\"color\",\t\t\"0.5 0.5 0.5\"},\n\t{\"delay\",\t\t\"0\"},\n\t{\"sound\",\t\t\"\"},\n\t{\"targetname\",\t\"\"},\n\t{\"killtarget\",\t\"\"},\n\t{\"message\",\t\t\"\"},\n\n\t{\"rem\",\t\t\t\"sound - name of sound to play upon firing\"},\n\n\t//////////////////////////////\n\t// trigger_teleport\n\t//////////////////////////////\n\t{\"classname\",\t\"trigger_teleport\"},\n\t{\"color\",\t\t\"0.5 0.5 0.5\"},\n\t{\"sound\",\t\t\"\"},\n\t{\"targetname\",\t\"\"},\n\t{\"killtarget\",\t\"\"},\n\t{\"message\",\t\t\"\"},\n\t{\"flag\",\t\t\"PLAYER_ONLY\"},\n\t{\"flag\",\t\t\"NO_FLASH\"},\n\t{\"flag\",\t\t\"NO_ANGLE_ADJUST\"},\n\t\n\t{\"rem\",\t\t\t\"sound - name of sound to play upon firing, if not specified, then no\"},\n\t{\"rem\",\t\t\t\"sound will be played\"},\n\t{\"rem\",\t\t\t\"fog_value - sets fog_value to this when a teleporter is used\"},\n\t{\"rem\",\t\t\t\"\"},\n\t{\"rem\",\t\t\t\"Spawnflags:\"},\n\t{\"rem\",\t\t\t\"PLAYER_ONLY - will only teleport players (NOT bots)\"},\n\t{\"rem\",\t\t\t\"NO_FLASH - no spawn fog will be generated when an object teleports\"},\n\t{\"rem\",\t\t\t\"NO_ANGLE_ADJUST - the object's angle will not be adjusted when it is\"},\n\t{\"rem\",\t\t\t\"teleported.\"},\n\n\t//////////////////////////////\n\t// info_teleport_destination\n\t//////////////////////////////\n\t{\"classname\",\t\"info_teleport_destination\"},\n\t{\"color\",\t\t\"0.5 0.5 0.5\"},\n\t{\"size\",\t\t\"-8.0 -8.0 -8.0 8.0 8.0 8.0\"},\n\n\t//////////////////////////////\n\t// trigger_warp\n\t//////////////////////////////\n\t{\"classname\",\t\"trigger_warp\"},\n\t{\"color\",\t\t\"0.5 0.5 0.5\"},\n\t{\"sound\",\t\t\"\"},\n\t{\"targetname\",\t\"\"},\n\t{\"killtarget\",\t\"\"},\n\t{\"message\",\t\t\"\"},\n\t{\"flag\",\t\t\"PLAYER_ONLY\"},\n\t{\"flag\",\t\t\"NO_FLASH\"},\n\t{\"flag\",\t\t\"NO_ANGLE_ADJUST\"},\n\n\t{\"rem\",\t\t\t\"sound - name of sound to play upon firing, if not specified, then no\"},\n\t{\"rem\",\t\t\t\"sound will be played\"},\n\t{\"rem\",\t\t\t\"fog_value - sets fog_value to this when a warp is used\"},\n\t{\"rem\",\t\t\t\"speed - speed from this path point to the next\"},\n\t{\"rem\",\t\t\t\"\"},\n\t{\"rem\",\t\t\t\"Spawnflags:\"},\n\t{\"rem\",\t\t\t\"PLAYER_ONLY - will only teleport players (NOT bots)\"},\n\t{\"rem\",\t\t\t\"NO_FLASH - no spawn fog will be generated when an object teleports\"},\n\t{\"rem\",\t\t\t\"NO_ANGLE_ADJUST - the object's angle will not be adjusted when it is\"},\n\t{\"rem\",\t\t\t\"teleported.\"},\n\n\t//////////////////////////////\n\t//\ttele_cylinder\n\t//////////////////////////////\n\n\t{\"classname\",\t\"warp_cylinder\"},\n\t{\"color\",\t\t\"0.5 0.5 0.5\"},\n\t{\"color\",        \"1 0 1\"},\n\t{\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"rem\",          \"Location player starts in deathmatch\"},\n\n\t//////////////////////////////\n\t// info_warp_destination\n\t//////////////////////////////\n\t{\"classname\",\t\"info_warp_destination\"},\n\t{\"color\",\t\t\"0.5 0.5 0.5\"},\n\t{\"size\",\t\t\"-8.0 -8.0 -8.0 8.0 8.0 8.0\"},\n\n\t{\"rem\",\t\t\t\"target - next target to warp to\"},\n\t{\"rem\",\t\t\t\"speed - speed from this path point to the next\"},\n\n\t//////////////////////////////\n\t// trigger_onlyregistered\n\t//////////////////////////////\n\t{\"classname\",\t\"trigger_onlyregistered\"},\n\t{\"color\",\t\t\"0.5 0.5 0.5\"},\n\t{\"sound\",\t\t\"\"},\n\t{\"wait\",\t\t\"2.0\"},\n\t{\"message\",\t\t\"\"},\n\n\t{\"rem\",\t\t\t\"sound - name of sound to play upon firing\"},\n\t{\"rem\",\t\t\t\"wait - the number of seconds between triggerings and\"},\n\t{\"rem\",\t\t\t\"the length of time the message will be displayed\"},\n\n\t//////////////////////////////\n\t// trigger_hurt\n\t//////////////////////////////\n\t{\"classname\",\t\"trigger_hurt\"},\n\t{\"color\",\t\t\"0.5 0.5 0.5\"},\n\t{\"sound\",\t\t\"\"},\n\t{\"dmg\",\t\t\t\"2.0\"},\n\t{\"wait\",\t\t\"2.0\"},\n\t{\"message\",\t\t\"\"},\n\n\t{\"rem\",\t\t\t\"sound - name of sound to play upon firing\"},\n\t{\"rem\",\t\t\t\"dmg - the amount of damage the trigger will do to an object\"},\n\t{\"rem\",\t\t\t\"wait - the number of seconds between triggerings and\"},\n\n\t//////////////////////////////\n\t// trigger_push\n\t//////////////////////////////\n\t{\"classname\",\t\"trigger_push\"},\n\t{\"color\",\t\t\"0.5 0.5 0.5\"},\n\t{\"sound\",\t\t\"\"},\n\t{\"message\",\t\t\"\"},\n\t{\"speed\",\t\t\"1000.0\"},\n\t{\"flag\",\t\t\"PUSH_ONCE\"},\n\t{\"rem\",\t\t\t\"speed - the velocity to give the object\"},\n\t{\"rem\",\t\t\t\"speed - the velocity to give the object\"},\n\n\t//////////////////////////////\n\t// trigger_counter\n\t//////////////////////////////\n\t{\"classname\",\t\"trigger_counter\"},\n\t{\"color\",\t\t\"0.5 0.5 0.5\"},\n\t{\"sound\",\t\t\"\"},\n\t{\"flag\",\t\t\"NO_MESSAGE\"},\n\n\t{\"rem\",\t\t\t\"sound - name of sound to play upon firing\"},\n\t{\"rem\",\t\t\t\"message - message to display upon last triggering\"},\n\t{\"rem\",\t\t\t\"when NO_MESSAGE is set, no messages are displayed upon triggering\"},\n\n\t//////////////////////////////\n\t// trigger_changelevel\n\t//////////////////////////////\n\t{\"classname\",\t\"trigger_changelevel\"},\n\t{\"color\",\t\t\"0.5 0.5 0.5\"},\n\t{\"sound\",\t\t\"\"},\n\t{\"map\",\t\t\t\"\"},\n\t{\"flag\",\t\t\"NO_INTERMISSION\"},\n\n\t{\"rem\",\t\t\t\"sound - name of sound to play upon firing\"},\n\t{\"rem\",\t\t\t\"message - message to display upon last triggering\"},\n\n\t//////////////////////////////\n\t// func_wall\n\t//////////////////////////////\n\t{\"classname\",\t\"func_wall\"},\n\t{\"color\",\t\t\"0 0.5 0.8\"},\n\t{\"health\",\t\t\"0\"},\n\t{\"message\",\t\t\"\"},\n\t{\"targetname\",\t\"\"},\n\t{\"target\",\t\t\"\"},\n\t{\"killtarget\",\t\"\"},\n\n\t{\"rem\",\t\t\t\"targetname - the name of this wall if it is a target\"},\n\t{\"rem\",\t\t\t\"target - the next entity to trigger when this one is triggered\"},\n\t{\"rem\",\t\t\t\"killtarget - the targetname of the entity to remove when triggered\"},\n\n\t//////////////////////////////\n\t// func_button\n\t//////////////////////////////\n\t{\"classname\",\t\"func_button\"},\n\t{\"color\",\t\t\"0 0.5 0.8\"},\n\t{\"health\",\t\t\"0\"},\n\t{\"targetname\",\t\"\"},\n\t{\"target\",\t\t\"\"},\n\t{\"killtarget\",\t\"\"},\n\t{\"speed\",\t\t\"\"},\n\t{\"wait\",\t\t\"\"},\n\t{\"angle\",\t\t\"\"},\n\t{\"lip\",\t\t\t\"\"},\n\t{\"flag\",\t\t\"PUSH_TOUCH\"},\n\n\t{\"rem\",\t\t\t\"targetname - the name of this wall if it is a target\"},\n\t{\"rem\",\t\t\t\"target - the next entity to trigger when this one is triggered\"},\n\t{\"rem\",\t\t\t\"killtarget - the targetname of the entity to remove when triggered\"},\n\t{\"rem\",\t\t\t\"sound_use - the sound to play when the button is used (defaults to none)\"},\n\t{\"rem\",\t\t\t\"sound_return - the sound to play when the button returns (defaults to none)\"},\n\t{\"rem\",\t\t\t\"speed - rate of travel when button moves\"},\n\t{\"rem\",\t\t\t\"wait - seconds to wait befor returning to useable (-1 = never return)\"},\n\t{\"rem\",\t\t\t\"angle - direction of travel\"},\n\t{\"rem\",\t\t\t\"lip - amount of button left sticking out after being pushed (default 4)\"},\n\t{\"rem\",\t\t\t\"health - when > 0 the button must be killed in order to fire\"},\n\t{\"rem\",\t\t\t\"PUSH_TOUCH will allow the button to be pushed by running into it, Quake style\"},\n\n\t//////////////////////////////\n\t// func_multi_button\n\t//////////////////////////////\n\t{\"classname\",\t\"func_multi_button\"},\n\t{\"color\",\t\t\"0 0.5 0.8\"},\n\t{\"health\",\t\t\"0\"},\n\t{\"targetname\",\t\"\"},\n\t{\"target\",\t\t\"\"},\n\t{\"killtarget\",\t\"\"},\n\t{\"speed\",\t\t\"\"},\n\t{\"wait\",\t\t\"\"},\n\t{\"angle\",\t\t\"\"},\n\t{\"lip\",\t\t\t\"\"},\n\t{\"flag\",\t\t\"PUSH_TOUCH\"},\n\t{\"flag\",\t\t\"CYCLE\"},\n\n\t{\"rem\",\t\t\t\"targetname - the name of this wall if it is a target\"},\n\t{\"rem\",\t\t\t\"target - the next entity to trigger when this one is triggered\"},\n\t{\"rem\",\t\t\t\"killtarget - the targetname of the entity to remove when triggered\"},\n\t{\"rem\",\t\t\t\"sound_use - the sound to play when the button is used (defaults to none)\"},\n\t{\"rem\",\t\t\t\"sound_return - the sound to play when the button returns (defaults to none)\"},\n\t{\"rem\",\t\t\t\"speed - rate of travel when button moves\"},\n\t{\"rem\",\t\t\t\"wait - seconds to wait befor returning to useable (-1 = never return)\"},\n\t{\"rem\",\t\t\t\"angle - direction of travel\"},\n\t{\"rem\",\t\t\t\"health - when > 0 the button must be killed in order to fire\"},\n\t{\"rem\",\t\t\t\"distance - distance button travels on each push\"},\n\t{\"rem\",\t\t\t\"count - number of positions this button has\"},\n\t{\"rem\",\t\t\t\"PUSH_TOUCH will allow the button to be pushed by running into it, Quake style\"},\n\t{\"rem\",\t\t\t\"CYCLE - button will not return to top from last position, but will go back through all positions\"},\n\n\t//////////////////////////////\n\t// func_train\n\t//////////////////////////////\n\t{\"classname\",    \"func_train\"},\n\t{\"distance\",\t \"90.0\"},\n\t{\"color\",        \"0 0.5 0.8\"},\n\t{\"rem\",\t\t\t\"targetname - the name of this train\"},\n\t{\"rem\",\t\t\t\"target - the path_corner that the train will spawn at\"},\n\t{\"rem\",\t\t\t\"killtarget - the targetname of the entity to remove when triggered\"},\n\n\t//////////////////////////////\n\t// func_train\n\t//////////////////////////////\n\t{\"classname\",    \"func_train2\"},\n\t{\"distance\",\t \"90.0\"},\n\t{\"color\",        \"0 0.5 0.8\"},\n\t{\"rem\",\t\t\t\"targetname - the name of this train\"},\n\t{\"rem\",\t\t\t\"target - the path_corner that the train will spawn at\"},\n\t{\"rem\",\t\t\t\"killtarget - the targetname of the entity to remove when triggered\"},\n\t\n\t//////////////////////////////\n\t// path_corner_train\n\t//////////////////////////////\n\t{\"classname\",    \"path_corner_train\"},\n\t{\"distance\",\t \"90.0\"},\n\t{\"color\",        \"0.5 0.3 0\"},\n\t{\"size\",\t\t \"-8 -8 -8 8 8 8\"},\n\t{\"flag\",\t\t\"X_AXIS\"},\n\t{\"flag\",\t\t\"Y_AXIS\"},\n\t{\"flag\",\t\t\"Z_AXIS\"},\n\t{\"flag\",\t\t\"TRIGWAIT\"},\n\t{\"rem\",\t\t\t\"killtarget - the targetname of the entity to remove when this\"},\n\t{\"rem\",\t\t\t\"path_corner is reached\"},\n\t{\"rem\",\t\t\t\"speed - rate of travel from this path_corner to the next\"},\n\t{\"rem\",\t\t\t\"wait - seconds to wait after the actions on this path_corner are complete\"},\n\t{\"rem\",\t\t\t\"sound - sound to play at this path corner\"},\n\t{\"rem\",\t\t\t\"x_distance - distance in degrees to rotate around x axis\"},\n\t{\"rem\",\t\t\t\"y_distance - distance in degrees to rotate around y axis\"},\n\t{\"rem\",\t\t\t\"z_distance - distance in degrees to rotate around z axis\"},\n\t{\"rem\",\t\t\t\"x_speed - speed to rotate along x axis in degrees per second\"},\n\t{\"rem\",\t\t\t\"y_speed - speed to rotate along y axis in degrees per second\"},\n\t{\"rem\",\t\t\t\"z_speed - speed to rotate along z axis in degrees per second\"},\n\t{\"rem\",\t\t\t\"health - if health is set, the train will wait at this path corner\"},\n\t{\"rem\",\t\t\t\"until it is killed.\"},\n\t{\"rem\",\t\t\t\"Spawnflags:\"},\n\t{\"rem\",\t\t\t\"X_AXIS - when checked train will rotate continually around \"},\n\t{\"rem\",\t\t\t\"x axis at x_speed degrees per second\"},\n\t{\"rem\",\t\t\t\"Y_AXIS - when checked train will rotate continually around \"},\n\t{\"rem\",\t\t\t\"y axis at y_speed degrees per second\"},\n\t{\"rem\",\t\t\t\"Z_AXIS - when checked train will rotate continually around \"},\n\t{\"rem\",\t\t\t\"z axis at z_speed degrees per second\"},\n\t{\"rem\",\t\t\t\"TRIGWAIT - wait here until triggered\"},\n\n\t//////////////////////////////\n\t// info_player_start\n\t//////////////////////////////\n\t{\"classname\",    \"info_player_start\"},\n\t{\"color\",        \"1 0 0\"},\n\t{\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"rem\",          \"Location player starts in single play.\"},\n\n\t//////////////////////////////\n\t// info_mikiko_start\n\t//////////////////////////////\n\t{\"classname\",    \"info_mikiko_start\"},\n\t{\"color\",        \"1 0 0\"},\n\t{\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"rem\",          \"Location Mikiko starts in single play.\"},\n\n\t//////////////////////////////\n\t// info_superfly_start\n\t//////////////////////////////\n\t{\"classname\",    \"info_superfly_start\"},\n\t{\"color\",        \"1 0 0\"},\n\t{\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"rem\",          \"Location Superfly starts in single play.\"},\n\n\t//////////////////////////////\n\t// info_null\n\t//////////////////////////////\n\t{\"classname\",    \"info_null\"},\n\t{\"color\",        \"1 0 0\"},\n\t{\"size\",         \"-8 -8 -8 8 8 8\"},\n\t{\"rem\",          \"You can point anything to this as a target\"},\n\n\t//////////////////////////////\n\t// info_player_deathmatch\n\t//////////////////////////////\n\t{\"classname\",    \"info_player_deathmatch\"},\n\t{\"color\",        \"1 0 1\"},\n\t{\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"rem\",          \"Location player starts in deathmatch\"},\n\n\t//////////////////////////////\n\t// info_player_coop\n\t//////////////////////////////\n\t{\"classname\",    \"info_player_coop\"},\n\t{\"color\",        \"1 0 1\"},\n\t{\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"rem\",          \"Location player starts in coop\"},\n\n\t//////////////////////////////\n\t// func_door_secret\n\t//////////////////////////////\n\t{\"classname\",    \"func_door_secret\"},\n\t{\"color\",        \"0 0.5 0.8\"},\n\t{\"health\",\t\t \"0\"},\n\t{\"speed\",\t\t \"100\"},\n\t{\"wait\",\t\t \"3\"},\n\t{\"lip\",\t\t\t \"8\"},\n\t{\"dmg\",\t\t\t \"2\"},\n\t{\"angle\",\t\t \"0 0 0\"},\n\t{\"message\",\t\t \"we all suck\"},\n\t{\"targetname\",\t \"\"},\n\t{\"flag\",         \"OPEN_ONCE\"},\n\t{\"flag\",         \"1ST_LEFT\"},\n\t{\"flag\",         \"1ST_DOWN\"},\n\t{\"flag\",         \"NO_SHOOT\"},\n\t{\"flag\",\t\t \"YES_SHOOT\"},\n\n\t{\"rem\", \"message - printed when the door is touched if it is a trigger door and it hasn't been fired yet\"},\n\t{\"rem\", \"angle - determines the opening direction\"},\n\t{\"rem\", \"targetname - if set, no touch field will be spawned and a remote button or trigger field activates the door.\"},\n\t{\"rem\", \"health - if set, door must be shot open\"},\n\t{\"rem\",\t\"speed - movement speed (100 default)\"},\n\t{\"rem\", \"wait - time to wait before returning (3 default, -1 = never return)\"},\n\t{\"rem\",\t\"dmg - damage to inflict when blocked (2 default)\"},\n\t{\"rem\", \"sound_opening - name of the sound to play during opening, ie. doors/creek.wav\"},\n\t{\"rem\",\t\"sound_open_finish - name of the sound to play when opening completes, ie. doors/slam.wav\"},\n\t{\"rem\", \"sound_closing - name of the sound to play when closing starts, ie. doors/creek.wav\"},\n\t{\"rem\",\t\"sound_close_finish - name of the sound to play when closing completes, ie. doors/slam.wav\"},\n\t{\"rem\", \"  \"},\n\t{\"rem\", \"Spawnflags:\"},\n    {\"rem\", \"SECRET_OPEN_ONCE - door stays open (imagine that...)\"},\n    {\"rem\", \"SECRET_1ST_LEFT - first move is left of move direction\"},\n    {\"rem\", \"SECRET_1ST_DOWN - first move is down from move direction\"},\n    {\"rem\", \"SECRET_NO_SHOOT - only opened by a trigger\"},\n    {\"rem\", \"SECRET_YES_SHOOT - shootable even if targeted\"},\n\n\t//////////////////////////////\n\t// func_wall_explode\n\t//////////////////////////////\n\t{\"classname\",\t\"func_wall_explode\"},\n\t{\"color\",\t\t\"0 0.5 0.8\"},\n\t{\"health\",\t\t\"0\"},\n\t{\"message\",\t\t\"\"},\n\t{\"targetname\",\t\"\"},\n\t{\"target\",\t\t\"\"},\n\t{\"killtarget\",\t\"\"},\n\t{\"model_1\",\t\t\"\"},\n\t{\"model_2\",\t\t\"\"},\n\t{\"model_3\",\t\t\"\"},\n\t{\"flag\",        \"ROCK_CHUNKS\"},\n\t{\"flag\",        \"WOOD_CHUNKS\"},\n\t{\"flag\",        \"EXTRA_CHUNKS\"},\n\t{\"flag\",        \"EXTRA_VELOCITY\"},\n\t{\"flag\",\t\t\"NO_CHUNKS\"},\n\t{\"flag\",\t\t\"NO_SOUND\"},\n\n\t{\"rem\",\t\t\t\"targetname - the name of this wall if it is a target\"},\n\t{\"rem\",\t\t\t\"target - the next entity to trigger when this one is triggered\"},\n\t{\"rem\",\t\t\t\"killtarget - the targetname of the entity to remove when triggered\"},\n\t{\"rem\",\t\t\t\"health - ummm... this would be the health of the wall, if it is 0 then\"},\n\t{\"rem\",\t\t\t\"the wall can only be exploded by targetting it\"},\n\t{\"rem\",\t\t\t\"message - this prints out when wall go boom\"},\n\t{\"rem\",\t\t\t\"model_1 - the specific pathname of the first model to throw when killed\"},\n\t{\"rem\",\t\t\t\"if model_1 is set then spawnflags ROCK_CHUNKS and WOOD_CHUNKS are overridden\"},\n\t{\"rem\",\t\t\t\"model_2 - the pathname of the second model\"},\n\t{\"rem\",\t\t\t\"model_3 - I wouldn't bet on it, but this is probably the name of the 3rd model\"},\n\t{\"rem\",\t\t\t\" \"},\n\t{\"rem\", \"Spawnflags:\"},\n    {\"rem\", \"ROCK_CHUNKS - makes rock chunk wall-gibs fly\"},\n\t{\"rem\",\t\"WOOD_CHUNKS - makes wood chunk wall-gibs fly\"},\n\t{\"rem\",\t\"EXTRA_CHUNKS - makes up to 3 chunks per explosion, instead of just one\"},\n\t{\"rem\",\t\"EXTRA_VELOCITY - gives chunks a higher velocity (good for underwater)\"},\n\t{\"rem\", \"NO_CHUNKS - um, no chunks\"},\n\t{\"rem\", \"NO_SOUND - no sound, use when lots of func walls are activated simultaneously to keep the\"},\n\t{\"rem\", \"Quake engine from choking with too many sounds at once.\"},\n\n\t//////////////////////////////\n\t// func_anim\n\t//////////////////////////////\n\t{\"classname\",\t\"func_anim\"},\n\t{\"color\",\t\t\"0.0 1.0 0.1\"},\n\t{\"flag\",        \"VISIBLE\"},\n\t{\"rem\", \"Spawnflags:\"},\n    {\"rem\", \"VISIBLE - start visible\"},\n\n\t//////////////////////////////\n\t// func_floater\n\t//////////////////////////////\n\t{\"classname\",\t\"func_floater\"},\n\t{\"color\",\t\t\"0 0.5 0.8\"},\n\t{\"size\",\t\t\"-16 -16 -16 16 16 16\"},\n\t{\"model\",\t\t\"\"},\n\n\t{\"rem\",\t\t\t\"model - pathname to model (ie. models/floater.mdl)\"},\n\t{\"rem\",\t\t\t\"velocity_cap - maximum up/down velocity\"},\n\t{\"rem\",\t\t\t\"dissipate - how fast velocity degrades to velocity_cap (default = 0.99)\"},\n\t{\"rem\",\t\t\t\"object_mass - mass of object (mass / volume = density)\"},\n\t{\"rem\",\t\t\t\"object_volume - volume of object (mass / volume = density)\"},\n\n\t//////////////////////////////\n\t// func_debris\n\t//////////////////////////////\n\n\t{\"classname\",\t\"func_debris\"},\n\t{\"color\",\t\t\"0 0.5 0.8\"},\n\t{\"target\",\t\t\"\"},\n\t{\"flag\",\t\t\"GO_TO_ACTIVATOR\"},\n\t{\"flag\",\t\t\"NO_ROTATE\"},\n\t{\"flag\",\t\t\"MOMENTUM_DAMAGE\"},\n\t{\"flag\",\t\t\"NO_ROTATION_ADJUST\"},\n\t{\"flag\",\t\t\"DROP_ONLY\"},\n\t{\"flag\",\t\t\"QUARTER_SIZE\"},\n\n\t{\"rem\",\t\t\t\"target - debris will fly towards targeted entity\"},\n\t{\"rem\",\t\t\t\"fly_sound - sound to play while the entity flies through the air\"},\n\t{\"rem\",\t\t\t\"hit_sound - sound to play when the entity hits something\"},\n\t{\"rem\",\t\t\t\"damage - amount of damage to do when hitting another object\"},\n\t{\"rem\",\t\t\t\"if MOMENTUM_DAMAGE is selected, then damage will be based on the\"},\n\t{\"rem\",\t\t\t\"speed of the debris when it impacts the object and damage becomes\"},\n\t{\"rem\",\t\t\t\"the divisor, so if speed at impact = 300 and damge = 3, then damage done\"},\n\t{\"rem\",\t\t\t\"while 300 / 3 = 100 points.  If damage is not set, then momentum damage\"},\n\t{\"rem\",\t\t\t\"will be the default with a damage divisor of 3.\"},\n\t{\"rem\",\t\t\t\"Spawnflags:\"},\n\t{\"rem\",\t\t\t\"GO_TO_ACTIVATOR - debris will fly at whoever activated it\"},\n\t{\"rem\",\t\t\t\"NO_ROTATE - don't give this debris any random rotation\"},\n\t{\"rem\",\t\t\t\"MOMENTUM_DAMAGE - damage based on velocity\"},\n\t{\"rem\",\t\t\t\"DROP_ONLY - no upward velocity, debris just falls\"},\n\t{\"rem\",\t\t\t\"QUARTER_SIZE - shrink bounding box by 1/4\"},\n\t{\"rem\",\t\t\t\"Notes:\"},\n\t{\"rem\",\t\t\t\"A func debris entity must have an origin brush contained in it,\"},\n\t{\"rem\",\t\t\t\"otherwise it will rotate around the center of the level, not\"},\n\t{\"rem\",\t\t\t\"its own center.  That is bad.\"},\n\n\t//////////////////////////////\n\t// func_debris_visible\n\t//////////////////////////////\n\n\t{\"classname\",\t\"func_debris_visible\"},\n\t{\"color\",\t\t\"0 0.5 0.8\"},\n\t{\"target\",\t\t\"\"},\n\t{\"flag\",\t\t\"GO_TO_ACTIVATOR\"},\n\t{\"flag\",\t\t\"NO_ROTATE\"},\n\t{\"flag\",\t\t\"MOMENTUM_DAMAGE\"},\n\t{\"flag\",\t\t\"NO_ROTATION_ADJUST\"},\n\t{\"flag\",\t\t\"DROP_ONLY\"},\n\t{\"flag\",\t\t\"QUARTER_SIZE\"},\n\n\t{\"rem\",\t\t\t\"SAME AS FUNC_DEBRIS EXCEPT DEBRIS IS VISIBLE BEFORE TARGETTING\"},\n\t{\"rem\",\t\t\t\"target - debris will fly towards targeted entity\"},\n\t{\"rem\",\t\t\t\"fly_sound - sound to play while the entity flies through the air\"},\n\t{\"rem\",\t\t\t\"hit_sound - sound to play when the entity hits something\"},\n\t{\"rem\",\t\t\t\"damage - amount of damage to do when hitting another object\"},\n\t{\"rem\",\t\t\t\"if MOMENTUM_DAMAGE is selected, then damage will be based on the\"},\n\t{\"rem\",\t\t\t\"speed of the debris when it impacts the object and damage becomes\"},\n\t{\"rem\",\t\t\t\"the divisor, so if speed at impact = 300 and damge = 3, then damage done\"},\n\t{\"rem\",\t\t\t\"while 300 / 3 = 100 points.  If damage is not set, then momentum damage\"},\n\t{\"rem\",\t\t\t\"will be the default with a damage divisor of 3.\"},\n\t{\"rem\",\t\t\t\"Spawnflags:\"},\n\t{\"rem\",\t\t\t\"GO_TO_ACTIVATOR - debris will fly at whoever activated it\"},\n\t{\"rem\",\t\t\t\"NO_ROTATE - don't give this debris any random rotation\"},\n\t{\"rem\",\t\t\t\"MOMENTUM_DAMAGE - damage based on velocity\"},\n\t{\"rem\",\t\t\t\"DROP_ONLY - no upward velocity, debris just falls\"},\n\t{\"rem\",\t\t\t\"QUARTER_SIZE - shrink bounding box by 1/4\"},\n\t{\"rem\",\t\t\t\"Notes:\"},\n\t{\"rem\",\t\t\t\"A func debris entity must have an origin brush contained in it,\"},\n\t{\"rem\",\t\t\t\"otherwise it will rotate around the center of the level, not\"},\n\t{\"rem\",\t\t\t\"its own center.  That is bad.\"},\n\n\t//////////////////////////////\n\t// func_particlefield\n\t//////////////////////////////\n\t{\"classname\",\t\"func_particlefield\"},\n\t{\"color\",\t\t\"0 0.5 0.8\"},\n\t{\"flag\",\t\t\"USE_COUNT\"},\n\t{\"rem\",\t\t\t\"count - number of times to trigger before activated\"},\n\t{\"rem\",\t\t\t\"color - color of particles use:\"},\n\t{\"rem\",\t\t\t\"black, blue, green, cyan, red, \"},\n\t{\"rem\",\t\t\t\"purple, brown, ltgray, dkgray, \"},\n\t{\"rem\",\t\t\t\"ltblue, ltgreen, ltcyan, ltpurple,\"},\n\t{\"rem\",\t\t\t\"yellow, white\"},\n\n\t//////////////////////////////\n\t// func_monitor\n\t//////////////////////////////\n\t{\"classname\",\t\"func_monitor\"},\n\t{\"color\",\t\t\"0 0.5 0.8\"},\n\t{\"rem\",\t\t\t\"target - the info_camera that the view will be from\"},\n\t{\"rem\",\t\t\t\"fov - the field of view when looking through this camera\"},\n\n\t//////////////////////////////\n\t// info_camera\n\t//////////////////////////////\n\t{\"classname\",    \"info_camera\"},\n\t{\"color\",        \"1 0 0\"},\n\t{\"size\",         \"-8 -8 -8 8 8 8\"},\n\n\t//////////////////////////////\n\t// misc_lavaball_drop\n\t//////////////////////////////\n\t{\"classname\",\t\"misc_lavaball_drop\"},\n\t{\"size\",\t\t\"-8 -8 -8 8 8 8\"},\n\t{\"color\",\t\t\"1.0 0.5 0.0\"},\n\n\t//////////////////////////////\n\t// misc_lavaball_toss\n\t//////////////////////////////\n\t{\"classname\",\t\"misc_lavaball_toss\"},\n\t{\"size\",\t\t\"-8 -8 -8 8 8 8\"},\n\t{\"color\",\t\t\"1.0 0.5 0.0\"},\n\n\t{\"rem\",\t\t\t\"target = can be triggered\"},\n\t{\"rem\",\t\t\t\"mintime = minimum time between tosses (default = 4.0 seconds)\"},\n\t{\"rem\",\t\t\t\"maxtime = maximum time between tosses (default = 12.0 seconds)\"},\n\t{\"rem\",\t\t\t\"damage = damage to do when an hitting something\"},\n\t{\"rem\",\t\t\t\"upmin = minimum upward velocity (default = 200)\"},\n\t{\"rem\",\t\t\t\"upmax = maximum upward velocity (default = 800)\"},\n\n\t//////////////////////////////\n\t// sound_ambient\n\t//////////////////////////////\n\t\n\t{\"classname\",\t\"sound_ambient\"},\n\t{\"size\",\t\t\"-8 -8 -8 8 8 8\"},\n\t{\"color\",\t\t\"1 0 1\"},\n\n\t{\"rem\",\t\t\t\"sound - path to ambient sound (ie. ambience/sound.wav.\"},\n\t{\"rem\",\t\t\t\"fade - distance multiplier to make sounds fade in further away from source.\"},\n\t{\"rem\",\t\t\t\"1.0 is normal, 2.0 is twice as far.\"},\n\t{\"rem\",\t\t\t\"volume - 0 through 255.  255 is max.\"},\n\n\t//////////////////////////////\n\t// sound_ambient\n\t//////////////////////////////\n\t\n\t{\"classname\",\t\"trigger_fog_value\"},\n\t{\"color\",\t\t\"0 1 0\"},\n\n\t{\"rem\",\t\t\t\"fog_value - the value for fog density 0 - 4.  0 is off, ie. r_drawfog 0\"},\n\n\t//////////////////////////////\n\t// node_node\n\t//////////////////////////////\n\t\n\t{\"classname\",\t\"node_node\"},\n\t{\"color\",\t\t\"0.5 0.5 1\"},\n\t{\"size\",\t\t\"-8 -8 -8 8 8 8\"},\n\t{\"flag\",\t\t\"NODE_DOOR\"},\n\n\t{\"rem\",\t\t\t\"number - the number of this node\"},\n\t{\"rem\",\t\t\t\"link - the number of the node linked to (can be up to four link fields)\"},\n\n\t//////////////////////////////////////////////////////////////////////////////////////////////////////\n\t//\n\t// Monsters\n\t// \n\t//////////////////////////////////////////////////////////////////////////////////////////////////////\n\n\t////////////////////////////////////////\n\t// Episode 1 monsters\n\t////////////////////////////////////////\n\n    {\"classname\",    \"monster_froginator\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A light and refreshing monster.\"},\n\t{\"rem\",          \"One day I will read the spec and know what this\"},\n\t{\"rem\",          \"monster does.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_crox\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A realistic representation of your mother\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_slaughterskeet\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_thunderskeet\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_venomvermin\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_tentaclor\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_sludgeminion\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"flag\",\t\t \"PATHFOLLOW\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_prisoner\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"gib him.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"func_prisoner_respawn\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"rem\",\t\t\t \"time - seconds until a new prisoner is spawned\"},\n\n    {\"classname\",    \"monster_inmater\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-32 -32 -24 32 32 64\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"flag\",\t\t \"PATHFOLLOW\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\t{\"rem\",\t\t\t \"PATH_FOLLOW - begin following a monster path\"},\n\n    {\"classname\",    \"monster_squid\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_trackattack\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"rem\",          \"Track turrets need to have a target\"},\n\t{\"rem\",          \"which is the path_corner_track at which\"},\n\t{\"rem\",          \"they will start.\"},\n\t{\"rem\",          \"Spawn about 16 units below the track to\"},\n\n    {\"classname\",    \"monster_trackdaddy\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"rem\",          \"Track turrets need to have a target\"},\n\t{\"rem\",          \"which is the path_corner_track at which\"},\n\t{\"rem\",          \"they will start.\"},\n\t\n    {\"classname\",    \"monster_lasergat\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"rem\",          \"Track turrets need to have a target\"},\n\t{\"rem\",          \"which is the path_corner_track at which\"},\n\t{\"rem\",          \"they will start.\"},\n\n    {\"classname\",    \"monster_psyclaw\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big dog without a head and a\"},\n\t{\"rem\",\t\t\t \"brain for a back.  Cool, eh?\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_labworker\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"Lab worker.  Your momma.\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_battleboar\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A motorized, cybernetic pig, of course.\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n\t//////////////////////////////\n\t//\tpath_corner_track\n\t//\t\n\t//\tpath corners for tracked turrets only!\n\t//////////////////////////////\n\t\n\t{\"classname\",    \"path_corner_track\"},\n\t{\"distance\",\t \"90.0\"},\n\t{\"color\",        \"0.5 0.3 0\"},\n\t{\"size\",\t\t \"-8 -8 -8 8 8 8\"},\n\n\t////////////////////////////////////////\n\t// Episode 2 monsters\n\t////////////////////////////////////////\n\n    {\"classname\",    \"monster_skeleton\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"Where's he at?  Ahh!  He's in me!\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_spider\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-32 -32 -24 32 32 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"Dumbass.\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_tarantula\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"Dumbass.\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_griffon\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_harpy\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_centurion\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_siren\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_ferryman\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_satyr\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-32 -32 -24 32 32 64\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"This thing will beat you down.\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_column\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-32 -32 -24 32 32 64\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"Look at the tits on that statue!!\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n\t////////////////////////////////////////\n\t// Episode 3 monsters\n\t////////////////////////////////////////\n\n    {\"classname\",    \"monster_plague_rat\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"rem\",          \"I broke you!\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"I broke you!\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_rotworm\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"I beat the dictionary out of your filthy mouth!\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_buboid\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"Dumbass.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_priest\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_doombat\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_lycanthir\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_fletcher\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_dwarf\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_dragonegg\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_babydragon\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n\t////////////////////////////////////////\n\t// Episode 4 monsters\n\t////////////////////////////////////////\n\n    {\"classname\",    \"monster_gang1\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"Less than half a fucking man.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_gang2\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"You're fucking dumb!  Suck it down.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_blackprisoner\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_whiteprisoner\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_femgang\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_rocketdude\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_chaingang\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"A big thing with a big beak.\"},\n\t{\"rem\",          \"radius - wander radius\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monster_labmonkey\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-16 -16 -24 16 16 32\"},\n\t{\"flag\",\t\t \"WANDER\"},\n\t{\"rem\",          \"Lab monkey.  This thing will crack your skull.\"},\n\t{\"rem\",\t\t\t \"Spawnflags:\"},\n\t{\"rem\",\t\t\t \"WANDER - monster will wander around\"},\n\n    {\"classname\",    \"monkey_message\"},\n\t{\"color\",        \"1.0 0.0 0.0\"},\n    {\"size\",         \"-8 -8 -8 8 8 8\"},\n\t{\"rem\",          \"Target this from the monkey switch to display current monkey state.\"},\n\n\t//////////////////////////////////////////////////////////////////\n\t// monster AI markers\n\t//////////////////////////////////////////////////////////////////\n\n\t{\"classname\",\t\"monster_path_corner\"},\n\t{\"distance\",\t\"90.0\"},\n\t{\"color\",\t\t\"0.5 0.3 0\"},\n\t{\"size\",\t\t\"-8 -8 -8 8 8 8\"},\n\t{\"rem\",\t\t\t\"A path corner for a monster to travel along\"},\n\t{\"rem\"\t\t\t\"target1 - target4: \"},\n\t{\"rem\",\t\t\t\"Can have up to 4 targets for the monster\"},\n\t{\"rem\",\t\t\t\"to travel to.  If there is more than one target\"},\n\t{\"rem\",\t\t\t\"the monster will randomly choose the next target\"},\n\t{\"rem\",\t\t\t\"from those available.\"},\n\t{\"rem\",\t\t\t\"action1 - action4: \"},\n\t{\"rem\",\t\t\t\"Use the action field to make a monster perform a\"},\n\t{\"rem\",\t\t\t\"specific action at the path corner.  For example\"},\n\t{\"rem\",\t\t\t\"'action scoop' will make a sludge minion scoop\"},\n\t{\"rem\",\t\t\t\"sludge at that path corner (other monsters will\"},\n\t{\"rem\",\t\t\t\"ignore the scoop command.  You can have multiple\"},\n\t{\"rem\",\t\t\t\"actions on a path corner, for instance:\"},\n\t{\"rem\",\t\t\t\"\taction1\tscoop\"},\n\t{\"rem\",\t\t\t\"\taction2\tinterrogate\"},\n\t{\"rem\",\t\t\t\"Sludge minions reaching this path corner will scoop\"},\n\t{\"rem\",\t\t\t\"while Inmaters will search out nearest prisoner\"},\n\n\n\t//////////////////////////////////////////////////////////////////\n\t// decorations\n\t//////////////////////////////////////////////////////////////////\n\n    {\"classname\",\t\"deco_e1\"},\n\t{\"color\",\t\t\"1.0 0.0 0.0\"},\n    {\"size\",\t\t\"-16 -16 -24 16 16 0\"},\n\t{\"flag\",\t\t\"DECO_EXPLODE\"},\n\t{\"flag\",\t\t\"DECO_NO_EXPLODE\"},\n\t{\"flag\",\t\t\"DECO_PUSHABLE\"},\n\t{\"rem\",\t\t\t\"model - choose model # -- see list.\"},\n\n    {\"classname\",\t\"deco_e2\"},\n\t{\"color\",\t\t\"1.0 0.0 0.0\"},\n    {\"size\",\t\t\"-16 -16 -24 16 16 0\"},\n\t{\"flag\",\t\t\"DECO_EXPLODE\"},\n\t{\"flag\",\t\t\"DECO_NO_EXPLODE\"},\n\t{\"flag\",\t\t\"DECO_PUSHABLE\"},\n\t{\"rem\",\t\t\t\"model - choose model # -- see list.\"},\n\n    {\"classname\",\t\"deco_e3\"},\n\t{\"color\",\t\t\"1.0 0.0 0.0\"},\n    {\"size\",\t\t\"-16 -16 -24 16 16 0\"},\n\t{\"flag\",\t\t\"DECO_EXPLODE\"},\n\t{\"flag\",\t\t\"DECO_NO_EXPLODE\"},\n\t{\"flag\",\t\t\"DECO_PUSHABLE\"},\n\t{\"rem\",\t\t\t\"model - choose model # -- see list.\"},\n\n    {\"classname\",\t\"deco_e4\"},\n\t{\"color\",\t\t\"1.0 0.0 0.0\"},\n    {\"size\",\t\t\"-16 -16 -24 16 16 0\"},\n\t{\"flag\",\t\t\"DECO_EXPLODE\"},\n\t{\"flag\",\t\t\"DECO_NO_EXPLODE\"},\n\t{\"flag\",\t\t\"DECO_PUSHABLE\"},\n\t{\"rem\",\t\t\t\"model - choose model # -- see list.\"},\n\n\t{NULL,            NULL},\n};\n\n#endif"
  },
  {
    "path": "q3radiant/EditWnd.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// EditWnd.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"EditWnd.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CEditWnd\nIMPLEMENT_DYNCREATE(CEditWnd, CWnd);\n\nCEditWnd::CEditWnd()\n{\n}\n\nCEditWnd::~CEditWnd()\n{\n}\n\n\nBEGIN_MESSAGE_MAP(CEditWnd, CEdit)\n\t//{{AFX_MSG_MAP(CEditWnd)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CEditWnd message handlers\n\nBOOL CEditWnd::PreCreateWindow(CREATESTRUCT& cs) \n{\n  cs.style = WS_CHILD | WS_VSCROLL | ES_AUTOHSCROLL | ES_MULTILINE | WS_VISIBLE;\n  cs.lpszClass = \"EDIT\";\n\treturn CEdit::PreCreateWindow(cs);\n}\n"
  },
  {
    "path": "q3radiant/EditWnd.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_EDITWND_H__279AAE22_78C5_11D1_B53C_00AA00A410FC__INCLUDED_)\n#define AFX_EDITWND_H__279AAE22_78C5_11D1_B53C_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// EditWnd.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CEditWnd window\n\nclass CEditWnd : public CEdit\n{\n  DECLARE_DYNCREATE(CEditWnd);\n// Construction\npublic:\n\tCEditWnd();\n\n// Attributes\npublic:\n\n// Operations\npublic:\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CEditWnd)\n\tprotected:\n\tvirtual BOOL PreCreateWindow(CREATESTRUCT& cs);\n\t//}}AFX_VIRTUAL\n\n// Implementation\npublic:\n\tvirtual ~CEditWnd();\n\n\t// Generated message map functions\nprotected:\n\t//{{AFX_MSG(CEditWnd)\n\t//}}AFX_MSG\n\n\tDECLARE_MESSAGE_MAP()\n};\n\n/////////////////////////////////////////////////////////////////////////////\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_EDITWND_H__279AAE22_78C5_11D1_B53C_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/EntityListDlg.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// EntityListDlg.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"EntityListDlg.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CEntityListDlg dialog\n\n\nCEntityListDlg::CEntityListDlg(CWnd* pParent /*=NULL*/)\n\t: CDialog(CEntityListDlg::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CEntityListDlg)\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CEntityListDlg::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CEntityListDlg)\n\tDDX_Control(pDX, IDC_LIST_ENTITY, m_lstEntity);\n\tDDX_Control(pDX, IDC_TREE_ENTITY, m_treeEntity);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CEntityListDlg, CDialog)\n\t//{{AFX_MSG_MAP(CEntityListDlg)\n\tON_BN_CLICKED(IDSELECT, OnSelect)\n\tON_NOTIFY(TVN_SELCHANGED, IDC_TREE_ENTITY, OnSelchangedTreeEntity)\n\tON_NOTIFY(NM_DBLCLK, IDC_TREE_ENTITY, OnDblclkTreeEntity)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CEntityListDlg message handlers\n\nvoid CEntityListDlg::OnSelect() \n{\n  HTREEITEM hItem = m_treeEntity.GetSelectedItem();\n  if (hItem)\n  {\n    entity_t* pEntity = reinterpret_cast<entity_t*>(m_treeEntity.GetItemData(hItem));\n    if (pEntity)\n    {\n      Select_Deselect();\n\t    Select_Brush (pEntity->brushes.onext);\n    }\n\t}\n  Sys_UpdateWindows(W_ALL);\n}\n\nBOOL CEntityListDlg::OnInitDialog() \n{\n\tCDialog::OnInitDialog();\n\t\n  CMapStringToPtr mapEntity;\n\n  HTREEITEM hParent = m_treeEntity.InsertItem(world_entity->eclass->name);\n  HTREEITEM hChild = m_treeEntity.InsertItem(world_entity->eclass->name, hParent);\n  m_treeEntity.SetItemData(hChild, reinterpret_cast<DWORD>(world_entity));\n\n\tfor (entity_t* pEntity=entities.next ; pEntity != &entities ; pEntity=pEntity->next)\n\t{\n    hParent = NULL;\n    if (mapEntity.Lookup(pEntity->eclass->name, reinterpret_cast<void*&>(hParent)) == FALSE)\n    {\n      hParent = m_treeEntity.InsertItem(pEntity->eclass->name);\n      mapEntity.SetAt(pEntity->eclass->name, reinterpret_cast<void*>(hParent));\n    }\n    hChild = m_treeEntity.InsertItem(pEntity->eclass->name, hParent);\n    m_treeEntity.SetItemData(hChild, reinterpret_cast<DWORD>(pEntity));\n  }\n\n  CRect rct;\n  m_lstEntity.GetClientRect(rct);\n  m_lstEntity.InsertColumn(0, \"Key\", LVCFMT_LEFT, rct.Width() / 2);\n  m_lstEntity.InsertColumn(1, \"Value\", LVCFMT_LEFT, rct.Width() / 2);\n  m_lstEntity.DeleteColumn(2);\n  UpdateData(FALSE);\n\t\n\treturn TRUE;  // return TRUE unless you set the focus to a control\n\t              // EXCEPTION: OCX Property Pages should return FALSE\n}\n\nvoid CEntityListDlg::OnSelchangedTreeEntity(NMHDR* pNMHDR, LRESULT* pResult) \n{\n\tNM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;\n  HTREEITEM hItem = m_treeEntity.GetSelectedItem();\n  m_lstEntity.DeleteAllItems();\n  if (hItem)\n  {\n    CString strList;\n    entity_t* pEntity = reinterpret_cast<entity_t*>(m_treeEntity.GetItemData(hItem));\n    if (pEntity)\n    {\n\t    for (epair_t* pEpair = pEntity->epairs ; pEpair ; pEpair = pEpair->next)\n      {\n\t\t    if (strlen(pEpair->key) > 8)\n          strList.Format(\"%s\\t%s\", pEpair->key, pEpair->value);\n        else\n          strList.Format(\"%s\\t\\t%s\", pEpair->key, pEpair->value);\n        int nParent = m_lstEntity.InsertItem(0, pEpair->key);\n        m_lstEntity.SetItem(nParent, 1, LVIF_TEXT, pEpair->value, 0, 0, 0, reinterpret_cast<DWORD>(pEntity));\n\n      }\n    }\n\t}\n\t*pResult = 0;\n}\n\nvoid CEntityListDlg::OnDblclkListInfo() \n{\n\t// TODO: Add your control notification handler code here\n\t\n}\n\nvoid CEntityListDlg::OnDblclkTreeEntity(NMHDR* pNMHDR, LRESULT* pResult) \n{\n  OnSelect();\n\t*pResult = 0;\n}\n"
  },
  {
    "path": "q3radiant/EntityListDlg.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_ENTITYLISTDLG_H__C241B9A3_819F_11D1_B548_00AA00A410FC__INCLUDED_)\n#define AFX_ENTITYLISTDLG_H__C241B9A3_819F_11D1_B548_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// EntityListDlg.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CEntityListDlg dialog\n\nclass CEntityListDlg : public CDialog\n{\n// Construction\npublic:\n\tCEntityListDlg(CWnd* pParent = NULL);   // standard constructor\n\n// Dialog Data\n\t//{{AFX_DATA(CEntityListDlg)\n\tenum { IDD = IDD_DLG_ENTITYLIST };\n\tCListCtrl\tm_lstEntity;\n\tCTreeCtrl\tm_treeEntity;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CEntityListDlg)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CEntityListDlg)\n\tafx_msg void OnSelect();\n\tvirtual BOOL OnInitDialog();\n\tafx_msg void OnSelchangedTreeEntity(NMHDR* pNMHDR, LRESULT* pResult);\n\tafx_msg void OnDblclkListInfo();\n\tafx_msg void OnDblclkTreeEntity(NMHDR* pNMHDR, LRESULT* pResult);\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_ENTITYLISTDLG_H__C241B9A3_819F_11D1_B548_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/EpairsWrapper.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//-----------------------------------------------------------------------------\n//\n// $LogFile$\n// $Revision: 1.1.1.4 $\n// $Author: ttimo $\n// $Date: 2000/01/18 00:17:10 $\n// $Log: EpairsWrapper.h,v $\n// Revision 1.1.1.4  2000/01/18 00:17:10  ttimo\n// merging in for RC\n//\n// Revision 1.3  2000/01/17 23:53:41  TBesset\n// ready for merge in sourceforge (RC candidate)\n//\n// Revision 1.1.1.3  1999/12/29 18:31:25  TBesset\n// Q3Radiant public version\n//\n// DESCRIPTION:\n// virtual class to allow plugin operations on entities epairs\n// this is the internal header for our implementation\n\n#ifndef _EPAIRSWRAPPER_H_\n#define _EPAIRSWRAPPER_H_\n\nclass CEpairsWrapper : public IEpair\n{\npublic:\n\tint refCount;\n\tentity_t *m_pEnt;\n\tvirtual void IncRef() { refCount++; }\n\tvirtual void DecRef() { refCount--; if (refCount <= 0) delete this; }\n\tCEpairsWrapper() { refCount = 0; }\n\tCEpairsWrapper( entity_t* ep ) { refCount = 0; m_pEnt = ep; }\n\tvirtual ~CEpairsWrapper() { }\n\tvirtual void GetVectorForKey( char* key, vec3_t vec );\n\tvirtual float FloatForKey( char *key );\n\tvirtual char* ValueForKey( char *key );\n\tvirtual void SetKeyValue( char *key, char *value );\n\tvirtual void GetEntityOrigin( vec3_t vec );\n\tvirtual void CalculateRotatedBounds( vec3_t mins, vec3_t maxs );\n};\n\n#endif"
  },
  {
    "path": "q3radiant/FNMATCH.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"stdafx.h\"\n#include <stdlib.h>\n\n#define Reg1 register\nint match(char *mask, char *name)\n{\n\tReg1\tunsigned char\t*m = (unsigned char *)mask, *n = (unsigned char *)name;\n\tchar\t*ma = mask, *na = name;\n\tint\twild = 0, q = 0;\n\n\twhile (1)\n\t    {\n\t\tif (*m == '*')\n\t\t   {\n\t\t\twhile (*m == '*')\n\t\t\t\tm++;\n\t\t\twild = 1;\n\t\t\tma = (char *)m;\n\t\t\tna = (char *)n;\n\t\t    }\n\n\t\tif (!*m)\n\t\t    {\n\t  \t\tif (!*n)\n\t\t\t\treturn 0;\n\t  \t\tfor (m--; (m > (unsigned char *)mask) && (*m == '?'); m--)\n\t\t\t\t;\n\t\t\tif ((*m == '*') && (m > (unsigned char *)mask) &&\n\t\t\t    (m[-1] != '\\\\'))\n\t\t\t\treturn 0;\n\t\t\tif (!wild) \n\t\t\t\treturn 1;\n\t\t\tm = (unsigned char *)ma;\n\t\t\tn = (unsigned char *)++na;\n\t\t    }\n\t\telse if (!*n)\n\t\t    {\n\t\t\twhile(*m == '*')\n\t\t\t\tm++;\n\t\t\treturn (*m != 0);\n\t\t    }\n\t\tif ((*m == '\\\\') && ((m[1] == '*') || (m[1] == '?')))\n\t\t    {\n\t\t\tm++;\n\t\t\tq = 1;\n\t\t    }\n\t\telse\n\t\t\tq = 0;\n\n\t\tif ((tolower(*m) != tolower(*n)) && ((*m != '?') || q))\n\t\t    {\n\t\t\tif (!wild)\n\t\t\t\treturn 1;\n\t\t\tm = (unsigned char *)ma;\n\t\t\tn = (unsigned char *)++na;\n\t\t    }\n\t\telse\n\t\t    {\n\t\t\tif (*m)\n\t\t\t\tm++;\n\t\t\tif (*n)\n\t\t\t\tn++;\n\t\t    }\n\t    }\n}\n\n"
  },
  {
    "path": "q3radiant/FNMATCH.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef\t_FNMATCH_H\n#define\t_FNMATCH_H\n\nint match(char *mask, char *name);\n\n#endif /* fnmatch.h */\n"
  },
  {
    "path": "q3radiant/FindTextureDlg.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// FindTextureDlg.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"FindTextureDlg.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CFindTextureDlg dialog\n\nCFindTextureDlg g_TexFindDlg;\nCFindTextureDlg& g_dlgFind = g_TexFindDlg;\nstatic bool g_bFindActive = true;\n\nvoid CFindTextureDlg::updateTextures(const char *p)\n{\n  if (isOpen())\n  {\n    if (g_bFindActive)\n    {\n      setFindStr(p);\n    }\n    else\n    {\n      setReplaceStr(p);\n    }\n  }\n}\n\nCFindTextureDlg::CFindTextureDlg(CWnd* pParent /*=NULL*/)\n\t: CDialog(CFindTextureDlg::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CFindTextureDlg)\n\tm_bSelectedOnly = FALSE;\n\tm_strFind = _T(\"\");\n\tm_strReplace = _T(\"\");\n\tm_bForce = FALSE;\n\tm_bLive = TRUE;\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CFindTextureDlg::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CFindTextureDlg)\n\tDDX_Check(pDX, IDC_CHECK_SELECTED, m_bSelectedOnly);\n\tDDX_Text(pDX, IDC_EDIT_FIND, m_strFind);\n\tDDX_Text(pDX, IDC_EDIT_REPLACE, m_strReplace);\n\tDDX_Check(pDX, IDC_CHECK_FORCE, m_bForce);\n\tDDX_Check(pDX, IDC_CHECK_LIVE, m_bLive);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CFindTextureDlg, CDialog)\n\t//{{AFX_MSG_MAP(CFindTextureDlg)\n\tON_BN_CLICKED(ID_BTN_APPLY, OnBtnApply)\n\tON_EN_SETFOCUS(IDC_EDIT_FIND, OnSetfocusEditFind)\n\tON_EN_SETFOCUS(IDC_EDIT_REPLACE, OnSetfocusEditReplace)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\nvoid CFindTextureDlg::OnBtnApply() \n{\n  UpdateData(TRUE);\n  CRect rct;\n  GetWindowRect(rct);\n  SaveRegistryInfo(\"Radiant::TextureFindWindow\", &rct, sizeof(rct));\n  FindReplaceTextures(m_strFind, m_strReplace, m_bSelectedOnly, m_bForce);\n}\n\nvoid CFindTextureDlg::OnOK() \n{\n  UpdateData(TRUE);\n  CRect rct;\n  GetWindowRect(rct);\n  SaveRegistryInfo(\"Radiant::TextureFindWindow\", &rct, sizeof(rct));\n  FindReplaceTextures(m_strFind, m_strReplace, m_bSelectedOnly, m_bForce);\n\tCDialog::OnOK();\n}\n\nvoid CFindTextureDlg::show()\n{\n  if (g_dlgFind.GetSafeHwnd() == NULL || IsWindow(g_dlgFind.GetSafeHwnd()) == FALSE)\n  {\n    g_dlgFind.Create(IDD_DIALOG_FINDREPLACE);\n    g_dlgFind.ShowWindow(SW_SHOW);\n  }\n  else\n  {\n    g_dlgFind.ShowWindow(SW_SHOW);\n  }\n  CRect rct;\n  LONG lSize = sizeof(rct);\n  if (LoadRegistryInfo(\"Radiant::TextureFindWindow\", &rct, &lSize))\n    g_dlgFind.SetWindowPos(NULL, rct.left, rct.top, 0,0, SWP_NOSIZE | SWP_SHOWWINDOW);\n}\t\t\n\n\nbool CFindTextureDlg::isOpen()\n{\n  return (g_dlgFind.GetSafeHwnd() == NULL || ::IsWindowVisible(g_dlgFind.GetSafeHwnd()) == FALSE) ? false : true;\n}\n\nvoid CFindTextureDlg::setFindStr(const char * p)\n{\n  g_dlgFind.UpdateData(TRUE);\n  if (g_dlgFind.m_bLive)\n  {\n    g_dlgFind.m_strFind = p;\n    g_dlgFind.UpdateData(FALSE);\n  }\n}\n\nvoid CFindTextureDlg::setReplaceStr(const char * p)\n{\n  g_dlgFind.UpdateData(TRUE);\n  if (g_dlgFind.m_bLive)\n  {\n    g_dlgFind.m_strReplace = p;\n    g_dlgFind.UpdateData(FALSE);\n  }\n}\n\n\nvoid CFindTextureDlg::OnCancel() \n{\n  CRect rct;\n  GetWindowRect(rct);\n  SaveRegistryInfo(\"Radiant::TextureFindWindow\", &rct, sizeof(rct));\n\tCDialog::OnCancel();\n}\n\nBOOL CFindTextureDlg::DestroyWindow() \n{\n\treturn CDialog::DestroyWindow();\n}\n\nvoid CFindTextureDlg::OnSetfocusEditFind() \n{\n  g_bFindActive = true;\n}\n\nvoid CFindTextureDlg::OnSetfocusEditReplace() \n{\n  g_bFindActive = false;\n}\n"
  },
  {
    "path": "q3radiant/FindTextureDlg.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_FINDTEXTUREDLG_H__34B75D32_9F3A_11D1_B570_00AA00A410FC__INCLUDED_)\n#define AFX_FINDTEXTUREDLG_H__34B75D32_9F3A_11D1_B570_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// FindTextureDlg.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CFindTextureDlg dialog\n\nclass CFindTextureDlg : public CDialog\n{\n// Construction\npublic:\n\tstatic void setReplaceStr(const char* p);\n\tstatic void setFindStr(const char* p);\n\tstatic bool isOpen();\n  static void show();\n  static void updateTextures(const char* p);\n\tCFindTextureDlg(CWnd* pParent = NULL);   // standard constructor\n\n// Dialog Data\n\t//{{AFX_DATA(CFindTextureDlg)\n\tenum { IDD = IDD_DIALOG_FINDREPLACE };\n\tBOOL\tm_bSelectedOnly;\n\tCString\tm_strFind;\n\tCString\tm_strReplace;\n\tBOOL\tm_bForce;\n\tBOOL\tm_bLive;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CFindTextureDlg)\n\tpublic:\n\tvirtual BOOL DestroyWindow();\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CFindTextureDlg)\n\tafx_msg void OnBtnApply();\n\tvirtual void OnOK();\n\tvirtual void OnCancel();\n\tafx_msg void OnSetfocusEditFind();\n\tafx_msg void OnSetfocusEditReplace();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_FINDTEXTUREDLG_H__34B75D32_9F3A_11D1_B570_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/GLINGR.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// This .h file contains constants, typedefs, etc. for Intergraph\n// extensions to OpenGL.  These extensions are:\n//    \n//            Multiple Palette Extension\n//            Texture Object Extension\n\n#define GL_INGR_multiple_palette        1\n#define GL_EXT_texture_object           1\n\n\n// New constants and typedefs for the Multiple Palette Extension\n#define GL_PALETTE_INGR                 0x80c0\n#define GL_MAX_PALETTES_INGR            0x80c1\n#define GL_MAX_PALETTE_ENTRIES_INGR     0x80c2\n#define GL_CURRENT_PALETTE_INGR         0x80c3\n#define GL_PALETTE_WRITEMASK_INGR       0x80c4\n#define GL_CURRENT_RASTER_PALETTE_INGR\t0x80c5\n#define GL_PALETTE_CLEAR_VALUE_INGR\t0x80c6\n\n// Function prototypes for the Multiple Palette Extension routines\ntypedef void (APIENTRY *PALETTEFUNCPTR)(GLuint);\ntypedef void (APIENTRY *PALETTEMASKFUNCPTR)(GLboolean);\ntypedef void (APIENTRY *WGLLOADPALETTEFUNCPTR)(GLuint, GLsizei, GLuint *);\ntypedef void (APIENTRY *CLEARPALETTEFUNCPTR)(GLuint);\n\n\n// New Constants and typedefs for the Texture Object Extension\n#define GL_TEXTURE_PRIORITY_EXT         0x8066\n#define GL_TEXTURE_RESIDENT_EXT         0x8067\n#define GL_TEXTURE_1D_BINDING_EXT       0x8068\n#define GL_TEXTURE_2D_BINDING_EXT       0x8069\n\n// Function prototypes for the Texture Object Extension routines\ntypedef GLboolean (APIENTRY *ARETEXRESFUNCPTR)(GLsizei, const GLuint *,\n                    const GLboolean *);\ntypedef void (APIENTRY *BINDTEXFUNCPTR)(GLenum, GLuint);\ntypedef void (APIENTRY *DELTEXFUNCPTR)(GLsizei, const GLuint *);\ntypedef void (APIENTRY *GENTEXFUNCPTR)(GLsizei, GLuint *);\ntypedef GLboolean (APIENTRY *ISTEXFUNCPTR)(GLuint);\ntypedef void (APIENTRY *PRIORTEXFUNCPTR)(GLsizei, const GLuint *,\n                    const GLclampf *);\n\n\n/* OpenGL ExtEscape escape function constants */\n#ifndef OPENGL_GETINFO\n#define OPENGL_GETINFO  4353        /* for OpenGL ExtEscape */\n#endif\n\n// OPENGL_GETINFO ExtEscape sub-escape numbers.  They are defined by\n// Microsoft.\n\n#ifndef OPENGL_GETINFO_DRVNAME\n\n#define OPENGL_GETINFO_DRVNAME  0\n\n\n// Input structure for OPENGL_GETINFO ExtEscape.\n\ntypedef struct _OPENGLGETINFO\n{\n    ULONG   ulSubEsc;\n} OPENGLGETINFO, *POPENGLGETINFO;\n\n\n// Output structure for OPENGL_GETINFO_DRVNAME ExtEscape.\n\ntypedef struct _GLDRVNAMERET\n{\n    ULONG   ulVersion;              // must be 1 for this version\n    ULONG   ulDriverVersion;        // driver specific version number\n    WCHAR   awch[MAX_PATH+1];\n} GLDRVNAMERET, *PGLDRVNAMERET;\n\n#endif\n\n\n"
  },
  {
    "path": "q3radiant/GLInterface.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//-----------------------------------------------------------------------------\n//\n// $LogFile$\n// $Revision: 1.1.1.4.2.1 $\n// $Author: ttimo $\n// $Date: 2000/02/04 22:59:34 $\n// $log$\n// Revision 1.1.1.3  1999/12/29 18:31:26  TBesset\n// Q3Radiant public version\n//\n// Revision 1.2  1999/11/22 17:46:45  Timo & Christine\n// merged EARadiant into the main tree\n// bug fixes for Q3Plugin / EAPlugin\n// export for Robert\n//\n// Revision 1.1.4.1  1999/11/03 20:37:59  Timo & Christine\n// MEAN plugin for Q3Radiant, alpha version\n//\n// Revision 1.1.2.1  1999/10/27 08:34:26  Timo & Christine\n// preview version of the texture tools plugin is ready\n// ( TexTool.dll plugin is in Q3Plugin module )\n// plugins can draw in their own window using Radiant's qgl bindings\n//\n//\n// DESCRIPTION:\n// Quick interface hack for selected face interface\n// this one really needs more work, but I'm in a hurry with TexTool\n\n#include \"stdafx.h\"\n\n// stores objects that want to be hooked into drawing in the XY window\n//++timo TODO: add support for camera view, Z view ... (texture view?)\nCPtrArray l_GLWindows;\n\nint WINAPI QERApp_ISelectedFace_GetTextureNumber()\n{\n\tif (g_ptrSelectedFaces.GetSize() > 0)\n\t{\n\t\tface_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));\n\t\treturn selFace->d_texture->texture_number;\n\t}\n\t//++timo hu ? find the appropriate gl bind number\n\treturn 0;\n}\n\nvoid WINAPI QERApp_HookXYGLWindow(IGLWindow* pGLW)\n{\n\tl_GLWindows.Add( pGLW );\n\tpGLW->IncRef();\n}\n\nvoid WINAPI QERApp_UnHookGLWindow(IGLWindow* pGLW)\n{\n\tfor( int i = 0; i < l_GLWindows.GetSize(); i++ )\n\t{\n\t\tif (l_GLWindows.GetAt(i) == pGLW)\n\t\t{\n\t\t\tl_GLWindows.RemoveAt(i);\n\t\t\tpGLW->DecRef();\n\t\t\treturn;\n\t\t}\n\t}\n#ifdef _DEBUG\n\tSys_Printf(\"ERROR: IGLWindow* not found in QERApp_UnHookGLWindow\\n\");\n#endif\n}\n\nvoid DrawPluginEntities( VIEWTYPE vt )\n{\n\tfor(int i = 0; i<l_GLWindows.GetSize(); i++ )\n\t\tstatic_cast<IGLWindow*>(l_GLWindows.GetAt(i))->Draw( vt );\n}"
  },
  {
    "path": "q3radiant/GLW_WIN.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef _WIN32\n#  error You should not be including this file on this platform\n#endif\n\n#ifndef __GLW_WIN_H__\n#define __GLW_WIN_H__\n\ntypedef struct\n{\n\tHINSTANCE\thInstance;\n\tvoid\t*wndproc;\n\n\tHDC     hDC;\t\t\t// handle to device context\n\tHWND    hWnd;\t\t\t// handle to window\n\tHGLRC   hGLRC;\t\t\t// handle to GL rendering context\n\n\tHINSTANCE hinstOpenGL;\t// HINSTANCE for the OpenGL library\n\n\tqboolean minidriver;\n\tqboolean allowdisplaydepthchange;\n\tqboolean mcd_accelerated;\n\n\tFILE *log_fp;\n} glwstate_t;\n\nextern glwstate_t glw_state;\n\n#endif\n"
  },
  {
    "path": "q3radiant/GroupBar.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// GroupBar.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"GroupBar.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CGroupBar dialog\n\n\nCGroupBar::CGroupBar(CWnd* pParent /*=NULL*/)\n\t: CDialogBar()\n{\n\t//{{AFX_DATA_INIT(CGroupBar)\n\t\t// NOTE: the ClassWizard will add member initialization here\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CGroupBar::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialogBar::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CGroupBar)\n\tDDX_Control(pDX, IDC_COMBO_GROUPS, m_wndGroupList);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CGroupBar, CDialogBar)\n\t//{{AFX_MSG_MAP(CGroupBar)\n\tON_BN_CLICKED(IDC_BTN_ADDGROUP, OnBtnAddgroup)\n\tON_BN_CLICKED(IDC_BTN_LISTGROUPS, OnBtnListgroups)\n\tON_BN_CLICKED(IDC_BTN_REMOVEGROUP, OnBtnRemovegroup)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CGroupBar message handlers\n\nvoid CGroupBar::OnBtnAddgroup() \n{\n\t// TODO: Add your control notification handler code here\n\t\n}\n\nvoid CGroupBar::OnBtnListgroups() \n{\n\t// TODO: Add your control notification handler code here\n\t\n}\n\nvoid CGroupBar::OnBtnRemovegroup() \n{\n\t// TODO: Add your control notification handler code here\n\t\n}\n"
  },
  {
    "path": "q3radiant/GroupBar.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_GROUPBAR_H__926379A9_F46B_4E81_AD23_71BDDF55BDB3__INCLUDED_)\n#define AFX_GROUPBAR_H__926379A9_F46B_4E81_AD23_71BDDF55BDB3__INCLUDED_\n\n#if _MSC_VER > 1000\n#pragma once\n#endif // _MSC_VER > 1000\n// GroupBar.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CGroupBar dialog\n\nclass CGroupBar : public CDialogBar\n{\n// Construction\npublic:\n\tCGroupBar(CWnd* pParent = NULL);   // standard constructor\n\n// Dialog Data\n\t//{{AFX_DATA(CGroupBar)\n\tenum { IDD = IDD_GROUPBAR };\n\tCComboBox\tm_wndGroupList;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CGroupBar)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CGroupBar)\n\tafx_msg void OnBtnAddgroup();\n\tafx_msg void OnBtnListgroups();\n\tafx_msg void OnBtnRemovegroup();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Visual C++ will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_GROUPBAR_H__926379A9_F46B_4E81_AD23_71BDDF55BDB3__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/GroupDlg.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// GroupDlg.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"GroupDlg.h\"\n#include \"NameDlg.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n#define IMG_PATCH 0\n#define IMG_BRUSH 1\n#define IMG_GROUP 2\n#define IMG_ENTITY 3\n#define IMG_ENTITYGROUP 4\n#define IMG_MODEL 5\n#define IMG_SCRIPT 6\n\n// misc group support\n#define MAX_GROUPS 4096\n#define GROUP_DELIMETER '@'\n#define GROUPNAME \"QER_Group_%i\"\n\nCGroupDlg g_wndGroup;\nCGroupDlg *g_pGroupDlg = &g_wndGroup;\n\n// group_t are loaded / saved through \"group_info\" entities\n// they hold epairs for group settings and additionnal access info (tree nodes)\ngroup_t *g_pGroups = NULL;\n\nvoid Group_Add(entity_t *e)\n{\n  group_t *g = (group_t*)qmalloc(sizeof(group_t));\n  g->epairs = e->epairs;\n  g->next = NULL;\n  e->epairs = NULL;\n  // create a new group node\n  HTREEITEM hItem = g_wndGroup.m_wndTree.GetSelectedItem();\n  TVINSERTSTRUCT tvInsert;\n  memset(&tvInsert, 0, sizeof(TVINSERTSTRUCT));\n  tvInsert.item.iImage = IMG_GROUP;\n  tvInsert.item.iSelectedImage = tvInsert.item.iImage;\n\t//++timo wasat?\n  // tvInsert.hParent = (hItem) ? hItem : m_hWorld;\n  tvInsert.hParent = g_wndGroup.m_hWorld;\n  tvInsert.hInsertAfter = NULL;\n  tvInsert.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;\n  char *pipo = ValueForKey(e->epairs, \"group\");\n  tvInsert.item.pszText = _T(ValueForKey(g->epairs, \"group\"));\n\tg->itemOwner = g_wndGroup.m_wndTree.InsertItem(&tvInsert);\n  g->next = g_pGroups;\n\tg_pGroups = g;\n}\n\ngroup_t* Group_Alloc(char *name)\n{\n  group_t *g = (group_t*)qmalloc(sizeof(group_t));\n\tSetKeyValue( g->epairs, \"group\", name );\n  return g;\n}\n\ngroup_t* Group_ForName(const char * name)\n{\n\tgroup_t *g = g_pGroups;\n\twhile (g != NULL)\n\t{\n\t\tif (strcmp( ValueForKey(g->epairs,\"group\"), name ) == 0)\n\t\t\tbreak;\n\t\tg = g->next;\n\t}\n\treturn g;\n}\n\nvoid Group_AddToItem(brush_t *b, HTREEITEM item)\n{\n  char cBuff[1024];\n  int nImage = IMG_BRUSH;\n\tif (!g_qeglobals.m_bBrushPrimitMode)\n  {\n    return;\n  }\n  const char *pName = NULL;\n  const char *pNamed = Brush_GetKeyValue(b, \"name\");\n \n  if (!b->owner || (b->owner == world_entity))\n  {\n    if (b->patchBrush) \n    {\n      pName = \"Generic Patch\";\n      nImage = IMG_PATCH;\n    } \n    else \n    {\n      pName = \"Generic Brush\";\n      nImage = IMG_BRUSH;\n    }\n  } \n  else \n  {\n    pName = b->owner->eclass->name;\n    if (b->owner->eclass->fixedsize) \n    {\n      nImage = IMG_ENTITY;\n    } \n    else \n    {\n      nImage = IMG_ENTITYGROUP;\n    }\n  }\n\n  strcpy(cBuff, pName);\n\n  TVINSERTSTRUCT tvInsert;\n  memset(&tvInsert, 0, sizeof(TVINSERTSTRUCT));\n  tvInsert.item.iImage = (b->patchBrush) ? IMG_PATCH : IMG_BRUSH;\n  tvInsert.item.iSelectedImage = tvInsert.item.iImage;\n  tvInsert.hParent = item;\n  tvInsert.hInsertAfter = NULL;\n  tvInsert.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;\n  tvInsert.item.pszText = cBuff;\n  HTREEITEM itemNew = g_pGroupDlg->m_wndTree.InsertItem(&tvInsert);\n  g_pGroupDlg->m_wndTree.SetItemData(itemNew, reinterpret_cast<DWORD>(b));\n  b->itemOwner = itemNew;\n  g_pGroupDlg->m_wndTree.RedrawWindow();\n\n}\n\nvoid Group_RemoveBrush(brush_t *b)\n{\n\tif (!g_qeglobals.m_bBrushPrimitMode)\n\t{\n\t\treturn;\n\t}\n\tif (b->itemOwner)\n\t{\n\t\tg_pGroupDlg->m_wndTree.DeleteItem(b->itemOwner);\n\t\tb->itemOwner = NULL;\n\t\tg_pGroupDlg->m_wndTree.RedrawWindow();\n\t}\n\tDeleteKey(b->epairs, \"group\");\n}\n\nvoid Group_AddToWorld(brush_t *b)\n{\n\tif (!g_qeglobals.m_bBrushPrimitMode)\n  {\n    return;\n  }\n  HTREEITEM itemParent = g_pGroupDlg->m_wndTree.GetRootItem();\n  Group_AddToItem(b, itemParent);\n}\n\nvoid Group_AddToProperGroup(brush_t *b)\n{\n\tif (!g_qeglobals.m_bBrushPrimitMode)\n\t{\n\t\treturn;\n\t}\n\t// NOTE: we do a local copy of the \"group\" key because it gets erased by Group_RemoveBrush\n\tconst char *pGroup = Brush_GetKeyValue(b, \"group\");\n  // remove the entry in the tree if there's one\n  if (b->itemOwner)\n  {\n\t\tg_pGroupDlg->m_wndTree.DeleteItem(b->itemOwner);\n\t\tb->itemOwner = NULL;\n\t\tg_pGroupDlg->m_wndTree.RedrawWindow();\n  }\n\n\tif (*pGroup != 0)\n\t{\n\t\t// find the item\n\t\tgroup_t *g = Group_ForName(pGroup);\n\t\tif (g)\n\t\t\tGroup_AddToItem(b, g->itemOwner);\n#ifdef _DEBUG\n\t\telse\n\t\t\tSys_Printf(\"WARNING: unexpected Group_ForName not found in Group_AddToProperGroup\\n\");\n#endif\n\t}\n\telse\n\t{\n\t\tGroup_AddToWorld(b);\n\t}\n}\n\nvoid Group_AddToSelected(brush_t *b)\n{\n\tif (!g_qeglobals.m_bBrushPrimitMode)\n  {\n    return;\n  }\n  HTREEITEM hItem = g_pGroupDlg->m_wndTree.GetSelectedItem();\n  if (hItem == NULL)\n  {\n    hItem = g_pGroupDlg->m_wndTree.GetRootItem();\n  }\n  Group_AddToItem(b, hItem);\n}\n\nvoid Group_Save(FILE *f)\n{\n\tgroup_t *g = g_pGroups;\n\twhile (g)\n  {\n    fprintf(f,\"{\\n\\\"classname\\\" \\\"group_info\\\"\\n\\\"group\\\" \\\"%s\\\"\\n}\\n\", ValueForKey( g->epairs, \"group\" ));\n    g = g->next;\n  }\n}\n\nvoid Group_Init()\n{\n\tif (!g_qeglobals.m_bBrushPrimitMode)\n  {\n    return;\n  }\n\t// start by cleaning everything\n  // clean the groups\n  //++timo FIXME: we leak, delete the groups on the way (I don't have time to do it now)\n#ifdef _DEBUG\n  Sys_Printf(\"TODO: fix leak in Group_Init\\n\");\n#endif\n  group_t *g = g_pGroups;\n  while (g)\n  {\n    epair_t *ep,*enext;\n\t  for (ep = g->epairs ; ep ; ep=enext )\n\t  {\n\t\t  enext = ep->next;\n\t\t  free (ep->key);\n\t\t  free (ep->value);\n\t\t  free (ep);\n\t  }\n    g = g->next;\n  }\n  g_pGroups = NULL;\n\tg_wndGroup.m_wndTree.DeleteAllItems();\n  TVINSERTSTRUCT tvInsert;\n  memset(&tvInsert, 0, sizeof(TVINSERTSTRUCT));\n  tvInsert.hParent = NULL;\n  tvInsert.hInsertAfter = NULL;\n  tvInsert.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;\n  tvInsert.item.pszText = _T(\"World\");\n  tvInsert.item.iImage = IMG_GROUP;\n  tvInsert.item.iSelectedImage = IMG_GROUP;\n  HTREEITEM hWorld = g_wndGroup.m_wndTree.InsertItem(&tvInsert);\n\t// walk through all the brushes, remove the itemOwner key and add them back where they belong\n\tbrush_t *b;\n\tfor (b = active_brushes.next; b != &active_brushes; b = b->next)\n\t{\n\t\tb->itemOwner = NULL;\n\t\tGroup_AddToProperGroup(b);\n\t}\n\tfor (b = selected_brushes.next ; b != &selected_brushes ; b = b->next)\n\t{\n\t\tb->itemOwner = NULL;\n\t\tGroup_AddToProperGroup(b);\n\t}\n}\n\n// scan through world_entity for groups in this map?\n// we use GROUPNAME \"QER_group_%i\" to look for existing groups and their naming\n//++timo FIXME: is this actually needed for anything?\nvoid Group_GetListFromWorld(CStringArray *pArray)\n{\n\tif (!g_qeglobals.m_bBrushPrimitMode)\n  {\n    return;\n  }\n\n  if (world_entity == NULL)\n  {\n    return;\n  }\n\n  pArray->RemoveAll();\n  char cBuff[1024];\n  for (int i =0; i < MAX_GROUPS; i++)\n  {\n    sprintf(cBuff, GROUPNAME, i);\n    char *pGroup = ValueForKey(world_entity, cBuff);\n    if (pGroup && strlen(pGroup) > 0)\n    {\n      pArray->Add(pGroup);\n    }\n    else\n    {\n      break;\n    }\n  }\n}\n\nvoid Group_RemoveListFromWorld()\n{\n\tif (!g_qeglobals.m_bBrushPrimitMode)\n  {\n    return;\n  }\n  CStringArray array;\n  Group_GetListFromWorld(&array);\n  int nCount = array.GetSize();\n  for (int i = 0; i < nCount; i++)\n  {\n    DeleteKey(world_entity, array.GetAt(i));\n  }\n}\n\n/*\nvoid Group_SetListToWorld(CStringArray *pArray)\n{\n\tif (!g_qeglobals.m_bBrushPrimitMode)\n  {\n    return;\n  }\n  char cBuff[1024];\n  Group_RemoveListFromWorld();\n  int nCount = pArray->GetSize();\n  for (int i = 0; i < nCount; i++)\n  {\n    sprintf(cBuff, GROUPNAME, i);\n    SetKeyValue(world_entity, cBuff, pArray->GetAt(i));\n  }\n}\n*/\n\nint CountChar(const char *p, char c)\n{\n  int nCount = 0;\n  int nLen = strlen(p)-1;\n  while (nLen-- >= 0)\n  {\n    if (p[nLen] == c)\n    {\n      nCount++;\n    }\n  }\n  return nCount;\n}\n\n/*\n// this is not very efficient but should get the job done\n// as our trees should never be too big\nvoid Group_BuildTree(CTreeCtrl *pTree)\n{\n\tif (!g_qeglobals.m_bBrushPrimitMode)\n  {\n    return;\n  }\n  CStringArray array;\n  int i;\n  CString strTemp;\n  CString strRight;\n\n  //++timo WARNING: this is very dangerous! delete all tree items, without checking the brushes\n  pTree->DeleteAllItems();\n  TVINSERTSTRUCT tvInsert;\n  memset(&tvInsert, 0, sizeof(TVINSERTSTRUCT));\n  tvInsert.hParent = NULL;\n  tvInsert.hInsertAfter = NULL;\n  tvInsert.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;\n  tvInsert.item.pszText = _T(\"World\");\n  tvInsert.item.iImage = IMG_GROUP;\n  tvInsert.item.iSelectedImage = IMG_GROUP;\n  HTREEITEM hWorld = pTree->InsertItem(&tvInsert);\n\n  Group_GetListFromWorld(&array);\n\n  // groups use @ to delimit levels, the number of @ signs\n  // start with ROOT item\n  // nothing is a peer with world, it is ancestor to everything \n  // expects things in order so first entry should be a 2nd level item\n  HTREEITEM itemParent = pTree->GetRootItem();\n  HTREEITEM itemLast = itemParent;\n  int nCount = array.GetSize();\n  int nLastLevel = 1;\n  for (i = 0; i < nCount; i++)\n  {\n    strTemp = array.GetAt(i);\n    int nLevel = CountChar(strTemp, GROUP_DELIMETER);\n    if (nLevel < nLastLevel)\n    {\n      int nLevelsUp = nLastLevel - nLevel;\n      while (nLevelsUp-- > 0)\n      {\n        itemParent = pTree->GetParentItem(itemParent);\n      }\n    }\n    else if (nLevel > nLastLevel)\n    {\n      itemParent = itemLast;\n    }\n    nLastLevel = nLevel;\n    char *pLast = strrchr(strTemp, GROUP_DELIMETER);\n    pLast++;\n    itemLast = pTree->InsertItem(pLast, itemParent);\n  }\n}\n*/\n\nvoid DecomposeSiblingList(const char *p, CStringArray *pArray, CTreeCtrl *pTree, HTREEITEM itemChild)\n{\n  CString str = p;\n  str += GROUP_DELIMETER;\n  while (itemChild)\n  {\n    CString strAdd = str;\n    strAdd += pTree->GetItemText(itemChild);\n    // do not want to add brushes or things, just groups \n    if (pTree->GetItemData(itemChild) == 0)\n    {\n      pArray->Add(strAdd);\n    }\n    if (pTree->ItemHasChildren(itemChild))\n    {\n      HTREEITEM itemOffspring = pTree->GetChildItem(itemChild);\n      DecomposeSiblingList(strAdd, pArray, pTree, itemOffspring); \n    }\n    itemChild = pTree->GetNextSiblingItem(itemChild);\n  }\n}\n\n/*\nvoid Group_DecomposeTree(CTreeCtrl *pTree)\n{\n\tif (!g_qeglobals.m_bBrushPrimitMode)\n  {\n    return;\n  }\n  CStringArray array;\n  HTREEITEM itemParent = pTree->GetRootItem();\n  if (pTree->ItemHasChildren(itemParent))\n  {\n    HTREEITEM itemChild = pTree->GetChildItem(itemParent);\n    DecomposeSiblingList(pTree->GetItemText(itemParent), &array, pTree, itemChild);\n  }\n  Group_SetListToWorld(&array);\n}\n*/\n\n/////////////////////////////////////////////////////////////////////////////\n// CGroupDlg dialog\n\n\nCGroupDlg::CGroupDlg(CWnd* pParent /*=NULL*/)\n\t: CDialog(CGroupDlg::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CGroupDlg)\n\t\t// NOTE: the ClassWizard will add member initialization here\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CGroupDlg::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CGroupDlg)\n\tDDX_Control(pDX, IDC_TREE_GROUP, m_wndTree);\n\tDDX_Control(pDX, IDC_BTN_EDIT, m_wndEdit);\n\tDDX_Control(pDX, IDC_BTN_DEL, m_wndDel);\n\tDDX_Control(pDX, IDC_BTN_ADD, m_wndAdd);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CGroupDlg, CDialog)\n\t//{{AFX_MSG_MAP(CGroupDlg)\n\tON_WM_SIZE()\n\tON_BN_CLICKED(IDC_BTN_ADD, OnBtnAdd)\n\tON_BN_CLICKED(IDC_BTN_DEL, OnBtnDel)\n\tON_BN_CLICKED(IDC_BTN_EDIT, OnBtnEdit)\n\tON_NOTIFY(NM_RCLICK, IDC_TREE_GROUP, OnRclickTreeGroup)\n\tON_NOTIFY(TVN_ENDLABELEDIT, IDC_TREE_GROUP, OnEndlabeleditTreeGroup)\n\tON_NOTIFY(NM_CLICK, IDC_TREE_GROUP, OnClickTreeGroup)\n\tON_NOTIFY(TVN_SETDISPINFO, IDC_TREE_GROUP, OnSetdispinfoTreeGroup)\n\tON_NOTIFY(TVN_BEGINDRAG, IDC_TREE_GROUP, OnBegindragTreeGroup)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CGroupDlg message handlers\n\nvoid CGroupDlg::OnSize(UINT nType, int cx, int cy) \n{\n\tCDialog::OnSize(nType, cx, cy);\n\tCRect rct;\n  GetClientRect(rct);\n\n  if ( m_wndAdd.GetSafeHwnd())\n  {\n    //all borders at 4, spacing at 6\n    CRect rctButton;\n    m_wndAdd.GetWindowRect(rctButton);\n    int nWidth = rctButton.Width();\n    int nHeight = rctButton.Height();\n\n    int nTop = rct.Height() - nHeight - 4;\n\n    m_wndAdd.SetWindowPos(NULL, 4, nTop, 0, 0, SWP_NOSIZE);\n    m_wndEdit.SetWindowPos(NULL, 8 + nWidth , nTop, 0, 0, SWP_NOSIZE);\n    m_wndDel.SetWindowPos(NULL, 12 + (nWidth * 2), nTop, 0, 0, SWP_NOSIZE);\n    rct.bottom = nTop;\n    m_wndTree.SetWindowPos(NULL, rct.left + 4, rct.top + 4, rct.Width() - 8, rct.Height() - 8, SWP_SHOWWINDOW);\n  }\n}\n\nBOOL CGroupDlg::OnInitDialog() \n{\n\tCDialog::OnInitDialog();\n\tm_imgList.Create(IDB_BITMAP_GROUPS, 16, 0, ILC_COLOR);\n\tm_wndTree.SetImageList(&m_imgList, TVSIL_NORMAL);\n\tInitGroups();\n\treturn TRUE;  // return TRUE unless you set the focus to a control\n\t// EXCEPTION: OCX Property Pages should return FALSE\n}\n\nvoid CGroupDlg::InitGroups()\n{\n\tGroup_Init();\n}\n\n// add a new group, put all selected brushes into the group\nvoid CGroupDlg::OnBtnAdd() \n{\n  CNameDlg dlg(\"New Group\", this);\n  if (dlg.DoModal() == IDOK)\n  {\n\t\t// create a new group node\n    HTREEITEM hItem = m_wndTree.GetSelectedItem();\n    TVINSERTSTRUCT tvInsert;\n    memset(&tvInsert, 0, sizeof(TVINSERTSTRUCT));\n    tvInsert.item.iImage = IMG_GROUP;\n    tvInsert.item.iSelectedImage = tvInsert.item.iImage;\n\t\t//++timo wasat?\n    // tvInsert.hParent = (hItem) ? hItem : m_hWorld;\n    tvInsert.hParent = m_hWorld;\n    tvInsert.hInsertAfter = NULL;\n    tvInsert.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;\n    tvInsert.item.pszText = _T(dlg.m_strName.GetBuffer(0));\n\t\t// create a new group\n\t\tgroup_t *g = Group_Alloc( dlg.m_strName.GetBuffer(0) );\n\t\tg->itemOwner = m_wndTree.InsertItem(&tvInsert);\n\t\tg->next = g_pGroups;\n\t\tg_pGroups = g;\n\t\t// now add the selected brushes\n\t\t// NOTE: it would be much faster to give the group_t for adding\n\t\t// but Select_AddToGroup is the standard way for all other cases\n\t\tSelect_AddToGroup( dlg.m_strName.GetBuffer(0) );\n  }\n}\n\nvoid CGroupDlg::OnBtnDel() \n{\n}\n\nvoid CGroupDlg::OnBtnEdit() \n{\n}\n\nBOOL CGroupDlg::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult) \n{\n\treturn CDialog::OnChildNotify(message, wParam, lParam, pLResult);\n}\n\nBOOL CGroupDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) \n{\n  return CDialog::OnNotify(wParam, lParam, pResult);\n}\n\nvoid CGroupDlg::OnRclickTreeGroup(NMHDR* pNMHDR, LRESULT* pResult) \n{\n\t// TODO: Add your control notification handler code here\n\t\n\t*pResult = 0;\n}\n\nvoid CGroupDlg::OnEndlabeleditTreeGroup(NMHDR* pNMHDR, LRESULT* pResult) \n{\n\tTV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;\n  const char *pText = pTVDispInfo->item.pszText;\n  if (pText && strlen(pText) > 0)\n  {\n    HTREEITEM item = pTVDispInfo->item.hItem;\n    if (m_wndTree.GetRootItem() != item)\n    {\n      m_wndTree.SetItemText(item, pText);\n      if (pTVDispInfo->item.iImage != IMG_GROUP)\n      {\n        // if it is an entity\n      }\n    }\n    else\n    {\n      Sys_Printf(\"Cannot rename the world\\n\");\n    }\n  }\n  m_wndTree.RedrawWindow();\n\t*pResult = 0;\n}\n\nvoid CGroupDlg::OnClickTreeGroup(NMHDR* pNMHDR, LRESULT* pResult) \n{\n\t// TODO: Add your control notification handler code here\n\t\n\t*pResult = 0;\n}\n\nvoid CGroupDlg::OnSetdispinfoTreeGroup(NMHDR* pNMHDR, LRESULT* pResult) \n{\n\tTV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;\n\t// TODO: Add your control notification handler code here\n\t\n\t*pResult = 0;\n}\n\nvoid CGroupDlg::OnCancel()\n{\n  TreeView_EndEditLabelNow(m_wndTree.GetSafeHwnd(), TRUE);\n}\n\nvoid CGroupDlg::OnOK()\n{\n  TreeView_EndEditLabelNow(m_wndTree.GetSafeHwnd(), FALSE);\n}\n\nvoid CGroupDlg::OnBegindragTreeGroup(NMHDR* pNMHDR, LRESULT* pResult) \n{\n\tNM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;\n\t// TODO: Add your control notification handler code here\n\t\n\t*pResult = 0;\n}\n"
  },
  {
    "path": "q3radiant/GroupDlg.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_GROUPDLG_H__92368487_9E05_454E_A66F_23A9A94A753B__INCLUDED_)\n#define AFX_GROUPDLG_H__92368487_9E05_454E_A66F_23A9A94A753B__INCLUDED_\n\n#if _MSC_VER > 1000\n#pragma once\n#endif // _MSC_VER > 1000\n// GroupDlg.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CGroupDlg dialog\n\nclass CGroupDlg : public CDialog\n{\n  CImageList m_imgList;\n// Construction\npublic:\n\tvirtual void OnOK();\n\tvirtual void OnCancel();\n\tvoid InitGroups();\n\tCGroupDlg(CWnd* pParent = NULL);   // standard constructor\n\n  HTREEITEM m_hWorld;\n\n// Dialog Data\n\t//{{AFX_DATA(CGroupDlg)\n\tenum { IDD = IDD_DLG_GROUP };\n\tCTreeCtrl\tm_wndTree;\n\tCButton\tm_wndEdit;\n\tCButton\tm_wndDel;\n\tCButton\tm_wndAdd;\n\t//}}AFX_DATA\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CGroupDlg)\n\tpublic:\n\tvirtual BOOL OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult);\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\tvirtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CGroupDlg)\n\tafx_msg void OnSize(UINT nType, int cx, int cy);\n\tvirtual BOOL OnInitDialog();\n\tafx_msg void OnBtnAdd();\n\tafx_msg void OnBtnDel();\n\tafx_msg void OnBtnEdit();\n\tafx_msg void OnRclickTreeGroup(NMHDR* pNMHDR, LRESULT* pResult);\n\tafx_msg void OnEndlabeleditTreeGroup(NMHDR* pNMHDR, LRESULT* pResult);\n\tafx_msg void OnClickTreeGroup(NMHDR* pNMHDR, LRESULT* pResult);\n\tafx_msg void OnSetdispinfoTreeGroup(NMHDR* pNMHDR, LRESULT* pResult);\n\tafx_msg void OnBegindragTreeGroup(NMHDR* pNMHDR, LRESULT* pResult);\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Visual C++ will insert additional declarations immediately before the previous line.\n\nextern CGroupDlg *g_pGroupDlg;\n\n\n#endif // !defined(AFX_GROUPDLG_H__92368487_9E05_454E_A66F_23A9A94A753B__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/IBSPFrontend.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//-----------------------------------------------------------------------------\n//\n// $LogFile$\n// $Revision: 1.3 $\n// $Author: ttimo $\n// $Date: 2000/01/18 00:43:59 $\n// $Log: IBSPFrontend.h,v $\n// Revision 1.3  2000/01/18 00:43:59  ttimo\n// RC\n//\n// Revision 1.2  2000/01/13 00:46:41  ttimo\n// Merged in patches in / out\n//\n// Revision 1.1.1.1.2.1  2000/01/13 00:15:41  ttimo\n// beta of patches in / out - tested with GenSurf\n//\n// Revision 1.1.1.1  2000/01/07 17:17:27  ttimo\n// initial import of Q3Radiant module\n//\n// Revision 1.2  2000/01/07 16:40:09  TBesset\n// merged from BSP frontend\n//\n// Revision 1.1.2.4  2000/01/07 00:16:26  TBesset\n// frontend ready for public version\n//\n// Revision 1.1.2.3  2000/01/04 00:26:58  TBesset\n// added a LoadPointFile in BSP frontend\n//\n// Revision 1.1.2.2  1999/12/31 19:43:20  TBesset\n// no message\n//\n// Revision 1.1.2.1  1999/12/29 16:49:39  TBesset\n// adding IBSPFrontend to the repository\n//\n//\n// DESCRIPTION:\n// interface for BSP frontends plugins\n//\n\n// DONE:\t- change BSP menu to Q3Build menu ?\n// DONE:    - detect when Q3Build dies ?\n// DELAYED: - hotkeys !\n// SUCCESS: - try again getting feedback from Q3Build\n\n#ifndef __IBSPFRONTEND_H_\n#define __IBSPFRONTEND_H_\n\n// define a GUID for this interface so plugins can access and reference it\n// {8ED6A480-BA5E-11d3-A3E3-0004AC96D4C3}\nstatic const GUID QERPlugBSPFrontendTable_GUID = \n{ 0x8ed6a480, 0xba5e, 0x11d3, { 0xa3, 0xe3, 0x0, 0x4, 0xac, 0x96, 0xd4, 0xc3 } };\n\n// ask the plugin about the items to show up in the BSP menu\ntypedef char * (WINAPI* PFN_GETBSPMENU)\t();\n// dispatch a BSP menu command\ntypedef void (WINAPI* PFN_DISPATCHBSPCOMMAND) (char *);\n\nstruct _QERPlugBSPFrontendTable\n{\n\tint m_nSize;\n\tPFN_GETBSPMENU\t\t\tm_pfnGetBSPMenu;\n\tPFN_DISPATCHBSPCOMMAND\tm_pfnDispatchBSPCommand;\n};\n\n// interface provided by Radiant to the plugin\n// {A2CCF366-BA60-11d3-A3E3-0004AC96D4C3}\nstatic const GUID QERAppBSPFrontendTable_GUID = \n{ 0xa2ccf366, 0xba60, 0x11d3, { 0xa3, 0xe3, 0x0, 0x4, 0xac, 0x96, 0xd4, 0xc3 } };\n\ntypedef char * (WINAPI* PFN_GETMAPNAME) ();\ntypedef void (WINAPI* PFN_LOADPOINTFILE) ();\n\nstruct _QERAppBSPFrontendTable\n{\n\tint m_nSize;\n\tPFN_GETMAPNAME\t\tm_pfnGetMapName;\n\tPFN_LOADPOINTFILE\tm_pfnLoadPointFile;\n};\n\n#endif"
  },
  {
    "path": "q3radiant/IEpairs.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//-----------------------------------------------------------------------------\n//\n// $LogFile$\n// $Revision: 1.1.1.4 $\n// $Author: ttimo $\n// $Date: 2000/01/18 00:17:12 $\n// $Log: IEpairs.cpp,v $\n// Revision 1.1.1.4  2000/01/18 00:17:12  ttimo\n// merging in for RC\n//\n// Revision 1.3  2000/01/17 23:53:41  TBesset\n// ready for merge in sourceforge (RC candidate)\n//\n// Revision 1.2  2000/01/07 16:40:10  TBesset\n// merged from BSP frontend\n// Revision 1.1.1.3  1999/12/29 18:31:26  TBesset\n// Q3Radiant public version\n//\n//\n// Revision 1.2  1999/11/22 17:46:45  Timo & Christine\n// merged EARadiant into the main tree\n// bug fixes for Q3Plugin / EAPlugin\n// export for Robert\n//\n// Revision 1.1.2.1  1999/11/03 20:37:59  Timo & Christine\n// MEAN plugin for Q3Radiant, alpha version\n//\n//\n// DESCRIPTION:\n// virtual class to allow plugin operations on entities epairs\n//\n\n#include \"stdafx.h\"\n\nvoid CEpairsWrapper::GetVectorForKey( char* key, vec3_t vec )\n{\n\t::GetVectorForKey( m_pEnt, key, vec );\n}\n\nfloat CEpairsWrapper::FloatForKey( char *key )\n{\n\treturn ::FloatForKey( m_pEnt, key );\n}\n\nchar* CEpairsWrapper::ValueForKey( char *key )\n{\n\treturn ::ValueForKey( m_pEnt, key );\n}\n\nvoid CEpairsWrapper::SetKeyValue( char *key, char *value )\n{\n\t::SetKeyValue( m_pEnt, key, value );\n}\n\nvoid CEpairsWrapper::GetEntityOrigin( vec3_t vec )\n{\n\tVectorCopy( m_pEnt->origin, vec );\n}\n\n// taken from Ritual's version of Q3Radiant ( Entity_CalculateRotatedBounds )\nvoid CEpairsWrapper::CalculateRotatedBounds( vec3_t mins, vec3_t maxs )\n{\n\tentity_t *ent = m_pEnt;\n\tint i;\n\tfloat angle;\n\tvec3_t angles;\n\tvec3_t forward,right,up;\n\tvec3_t rotmins, rotmaxs;\n\tfloat trans[3][3];\n\tqboolean changed;\n\tchar tempangles[ 128 ]; \n\t\n\tmemset( angles, 0, sizeof(vec3_t) );\n\t::GetVectorForKey (ent, \"angles\", angles);\n\t\n\tchanged = false;\n\twhile ( angles[0] < 0 )\n\t{\n\t\tchanged = true;\n\t\tangles[0] += 360;\n\t}\n\twhile ( angles[0] > 359 )\n\t{\n\t\tchanged = true;\n\t\tangles[0] -= 360;\n\t}\n\twhile ( angles[1] < 0 )\n\t{\n\t\tchanged = true;\n\t\tangles[1] += 360;\n\t}\n\twhile ( angles[1] > 359 )\n\t{\n\t\tchanged = true;\n\t\tangles[1] -= 360;\n\t}\n\twhile ( angles[2] < 0 )\n\t{\n\t\tchanged = true;\n\t\tangles[2] += 360;\n\t}\n\twhile ( angles[2] > 359 )\n\t{\n\t\tchanged = true;\n\t\tangles[2] -= 360;\n\t}\n\t\n\tif ( changed )\n\t{\n\t\tsprintf( tempangles, \"%d %d %d\", (int)angles[0], (int)angles[1], (int)angles[2] );\n\t\t::SetKeyValue ( ent, \"angles\", tempangles );\n\t}\n\t\n\t\n\tangle = ::FloatForKey (ent, \"angle\");\n\tif ( fabs(angle) > 2 )\n\t{\n\t\tangles[1] = angle;\n\t}\n\telse if (angle == -1)\n\t{\n\t\tangles[0] = -90;\n\t}\n\telse if (angle == -2)\n\t{\n\t\tangles[0] = 90;\n\t}\n\t::AngleVectors( angles, forward, right, up );\n\tfor (i=0 ; i<3 ; i++)\n\t   {\n\t\ttrans[i][0] =  forward[i];\n\t\ttrans[i][1] =  -right[i];\n\t\ttrans[i][2] =  up[i];\n\t   }\n\tClearBounds( rotmins, rotmaxs );\n\tfor ( i = 0; i < 8; i++ )\n   \t{\n\t\tint j;\n\t\tvec3_t   tmp, rottemp;\n\t\t\n\t\tif ( i & 1 )\n\t\t\ttmp[0] = mins[0];\n\t\telse\n\t\t\ttmp[0] = maxs[0];\n\t\t\n\t\tif ( i & 2 )\n\t\t\ttmp[1] = mins[1];\n\t\telse\n\t\t\ttmp[1] = maxs[1];\n\t\t\n\t\tif ( i & 4 )\n\t\t\ttmp[2] = mins[2];\n\t\telse\n\t\t\ttmp[2] = maxs[2];\n\t\t\n\t\tfor (j=0; j<3 ; j++)\n\t\t{\n\t\t\trottemp[j] =  DotProduct( tmp, trans[j] );\n\t\t}\n\t\tAddPointToBounds( rottemp, rotmins, rotmaxs );\n\t}\n\tVectorCopy( rotmins, mins );\n\tVectorCopy( rotmaxs, maxs );\n}\n"
  },
  {
    "path": "q3radiant/IEpairs.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//-----------------------------------------------------------------------------\n//\n// $LogFile$\n// $Revision: 1.1.1.4 $\n// $Author: ttimo $\n// $Date: 2000/01/18 00:17:12 $\n// $Log: IEpairs.h,v $\n// Revision 1.1.1.4  2000/01/18 00:17:12  ttimo\n// merging in for RC\n//\n// Revision 1.3  2000/01/17 23:53:42  TBesset\n// ready for merge in sourceforge (RC candidate)\n//\n// Revision 1.2  2000/01/07 16:40:10  TBesset\n// merged from BSP frontend\n//\n// Revision 1.1.1.3  1999/12/29 18:31:26  TBesset\n// Q3Radiant public version\n//\n// Revision 1.1.1.1.2.1  1999/12/29 21:39:35  TBesset\n// updated to update3 from Robert\n//\n// Revision 1.1.1.3  1999/12/29 18:31:26  TBesset\n// Q3Radiant public version\n//\n// Revision 1.1.1.3  1999/12/29 18:31:26  TBesset\n// Q3Radiant public version\n//\n//\n// Revision 1.2  1999/11/22 17:46:45  Timo & Christine\n// merged EARadiant into the main tree\n// bug fixes for Q3Plugin / EAPlugin\n// export for Robert\n//\n// Revision 1.1.2.1  1999/11/03 20:37:59  Timo & Christine\n// MEAN plugin for Q3Radiant, alpha version\n//\n//\n// DESCRIPTION:\n// virtual class to allow plugin operations on entities epairs\n//\n\n#ifndef _IEPAIRS_H_\n#define _IEPAIRS_H_\n\nclass IEpair\n{\npublic:\n\t// Increment the number of references to this object\n\tvirtual void IncRef () = 0;\n\t// Decrement the reference count\n\tvirtual void DecRef () = 0;\n\tvirtual void GetVectorForKey( char* key, vec3_t vec ) = 0;\n\tvirtual float FloatForKey( char *key ) = 0;\n\tvirtual char* ValueForKey( char *key ) = 0;\n\tvirtual void SetKeyValue( char *key, char *value ) = 0;\n\tvirtual void GetEntityOrigin( vec3_t vec ) = 0;\n\t// compute the rotated bounds of the BBox based on \"angle\" and \"angles\" keys\n\tvirtual void CalculateRotatedBounds( vec3_t mins, vec3_t maxs ) = 0;\n};\n\n#endif "
  },
  {
    "path": "q3radiant/IMessaging.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//-----------------------------------------------------------------------------\n//\n// $LogFile$\n// $Revision: 1.1.2.1 $\n// $Author: ttimo $\n// $Date: 2000/02/04 22:59:34 $\n// $Log: IMessaging.h,v $\n// Revision 1.1.2.1  2000/02/04 22:59:34  ttimo\n// messaging API preview\n//\n//\n// DESCRIPTION:\n// interface for all-purpose messaging in Radiant\n\n#ifndef __IMESSAGING_H_\n#define __IMESSAGING_H_\n\n// this one can be hooked in the GL window procs for customizing GUI through plugins\nclass IWindowListener\n{\npublic:\n\t// Increment the number of references to this object\n\tvirtual void IncRef () = 0;\n\t// Decrement the reference count\n\tvirtual void DecRef () = 0;\n\t// since Radiant is MFC we don't use a WNDPROC, we wrap the MFC handlers\n\t// the handler is called first, if returns false Radiant continues processing\n\t//++timo maybe add more later ? OnKeyUp and OnKeyDown for instance\n\t//++timo TODO: add handlers everywhere\n\tvirtual bool OnLButtonDown(UINT nFlags, int x, int y) = 0;\n\tvirtual bool OnMButtonDown(UINT nFlags, int x, int y) = 0;\n\tvirtual bool OnRButtonDown(UINT nFlags, int x, int y) = 0;\n\tvirtual bool OnLButtonUp(UINT nFlags, int x, int y) = 0;\n\tvirtual bool OnMButtonUp(UINT nFlags, int x, int y) = 0;\n\tvirtual bool OnRButtonUp(UINT nFlags, int x, int y) = 0;\n\tvirtual bool OnMouseMove(UINT nFlags, int x, int y) = 0;\n};\n\n// various Radiant messages --------\n// this one holds the total number of supported messages (this is used to allocate structs)\n#define RADIANT_MSGCOUNT 3\n// they start with a 0, can be indexed in an array\n// something was selected / deselected\n#define RADIANT_SELECTION 0\n// a brush face was selected / deselected\n#define RADIANT_SFACE     1\n// current texture / shader changed\n#define RADIANT_TEXTURE   2\n\n// this one can be used to listen for Radiant-specific events\nclass IListener\n{\npublic:\n\t// Increment the number of references to this object\n\tvirtual void IncRef () = 0;\n\t// Decrement the reference count\n\tvirtual void DecRef () = 0;\n\t// message is one of the RADIANT_* consts\n\tvirtual void DispatchRadiantMsg( int Msg ) = 0;\n};\n\n// this one is provided by Radiant, it's a wrapper for some usefull functions\nclass IXYWndWrapper\n{\npublic:\n\tvirtual void SnapToGrid( int x1, int y1, vec3_t pt ) = 0;\n};\n\n// define a GUID for this interface so plugins can access and reference it\n// {41FD005C-D36B-11d3-A3E9-0004AC96D4C3}\nstatic const GUID QERMessaging_GUID = \n{ 0x41fd005c, 0xd36b, 0x11d3, { 0xa3, 0xe9, 0x0, 0x4, 0xac, 0x96, 0xd4, 0xc3 } };\n\n// will hook the given IWindowListener to the XY window and increment the ref count\n//++timo TODO: add hooking in the CAM view and Z view\ntypedef void (WINAPI* PFN_QERAPP_HOOKWINDOW)\t(IWindowListener *);\n// will unhook the given IWindowListener\ntypedef void (WINAPI* PFN_QERAPP_UNHOOKWINDOW)\t(IWindowListener *);\n// to retrieve the IXYWndWrapper\ntypedef IXYWndWrapper* (WINAPI* PFN_QERAPP_GETXYWNDWRAPPER)\t();\n\n// will hook a given listener into Radiant listening for the given message and increment ref count\n// call several times to listen for several messages\ntypedef void (WINAPI* PFN_QERAPP_HOOKLISTENER)\t(IListener *, int Msg);\n// will unhook the listener and return the number of messages the given listener was removed from\ntypedef int  (WINAPI* PFN_QERAPP_UNHOOKLISTENER)(IListener *);\n\nstruct _QERMessagingTable\n{\n\tint m_nSize;\n\tPFN_QERAPP_HOOKWINDOW\t\tm_pfnHookWindow;\n\tPFN_QERAPP_UNHOOKWINDOW\t\tm_pfnUnHookWindow;\n\tPFN_QERAPP_GETXYWNDWRAPPER\tm_pfnGetXYWndWrapper;\n\tPFN_QERAPP_HOOKLISTENER\t\tm_pfnHookListener;\n\tPFN_QERAPP_UNHOOKLISTENER\tm_pfnUnHookListener;\n};\n\n#endif"
  },
  {
    "path": "q3radiant/IPluginEntities.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//-----------------------------------------------------------------------------\n//\n// $LogFile$\n// $Revision: 1.1.1.4 $\n// $Author: ttimo $\n// $Date: 2000/01/18 00:17:12 $\n// $Log: IPluginEntities.h,v $\n// Revision 1.1.1.4  2000/01/18 00:17:12  ttimo\n// merging in for RC\n//\n// Revision 1.3  2000/01/17 23:53:42  TBesset\n// ready for merge in sourceforge (RC candidate)\n//\n// Revision 1.2  2000/01/07 16:40:10  TBesset\n// merged from BSP frontend\n//\n// Revision 1.1.1.3  1999/12/29 18:31:27  TBesset\n// Q3Radiant public version\n//\n// Revision 1.1.1.1.2.1  1999/12/29 21:39:35  TBesset\n// updated to update3 from Robert\n//\n// Revision 1.1.1.3  1999/12/29 18:31:27  TBesset\n// Q3Radiant public version\n// Revision 1.1.1.3  1999/12/29 18:31:27  TBesset\n// Q3Radiant public version\n//\n// Revision 1.2  1999/11/22 17:46:45  Timo & Christine\n// merged EARadiant into the main tree\n// bug fixes for Q3Plugin / EAPlugin\n// export for Robert\n//\n// Revision 1.1.2.1  1999/11/03 20:37:59  Timo & Christine\n// MEAN plugin for Q3Radiant, alpha version\n//\n//\n// DESCRIPTION:\n// _QERPluginEntitiesTable is used by plugins for various plugin entities commands\n// _QERPlugEntitiesFactory is a set of commands Radiant uses to instanciate plugin entities\n// next are basics for plugin entities ( interfaces )\n\n#ifndef __IPLUGINENTITIES_H_\n#define __IPLUGINENTITIES_H_\n\n// define a GUID for this interface so plugins can access and reference it\n// {9613F500-8C7C-11d3-8EF3-C9EB56B6B7BE}\nstatic const GUID QERPluginEntitiesTable_GUID = \n{ 0x9613f500, 0x8c7c, 0x11d3, { 0x8e, 0xf3, 0xc9, 0xeb, 0x56, 0xb6, 0xb7, 0xbe } };\n\ntypedef int (WINAPI* PFN_ECLASSSCANDIR)\t( char*, HMODULE );\n\nstruct _QERPluginEntitiesTable\n{\n\tint m_nSize;\n\tPFN_ECLASSSCANDIR\tm_pfnEClassScanDir;\n};\n\n// plugin entities\nclass IPluginEntity\n{\npublic:\n\t// Increment the number of references to this object\n\tvirtual void IncRef () = 0;\n\t// Decrement the reference count\n\tvirtual void DecRef () = 0;\n\t// getting bounds of the brush used to select/move the object\n\tvirtual void GetBounds( vec3_t mins, vec3_t maxs ) = 0;\n\t// rendering the object in the camera view\n\tvirtual void CamRender() = 0;\n};\n\n// {DBC6B300-8E4B-11d3-8EF3-BA5E57D56399}\nstatic const GUID QERPlugEntitiesFactory_GUID = \n{ 0xdbc6b300, 0x8e4b, 0x11d3, { 0x8e, 0xf3, 0xba, 0x5e, 0x57, 0xd5, 0x63, 0x99 } };\n\ntypedef IPluginEntity * (WINAPI* PFN_CREATEENTITY) ( eclass_t *, IEpair * );\n\nstruct _QERPlugEntitiesFactory\n{\n\tint m_nSize;\n\tPFN_CREATEENTITY\tm_pfnCreateEntity;\n};\n\n#endif"
  },
  {
    "path": "q3radiant/ISelectedFace.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//-----------------------------------------------------------------------------\n//\n// $LogFile$\n// $Revision: 1.1.1.4.2.1 $\n// $Author: ttimo $\n// $Date: 2000/02/10 03:00:20 $\n// $Log: ISelectedFace.h,v $\n// Revision 1.1.1.4.2.1  2000/02/10 03:00:20  ttimo\n// adding IShaders.h\n//\n// Revision 1.1.1.4  2000/01/18 00:17:12  ttimo\n// merging in for RC\n//\n// Revision 1.3  2000/01/17 23:53:42  TBesset\n// ready for merge in sourceforge (RC candidate)\n//\n// Revision 1.2  2000/01/07 16:40:10  TBesset\n// merged from BSP frontend\n//\n// Revision 1.1.1.3  1999/12/29 18:31:27  TBesset\n// Q3Radiant public version\n//\n// Revision 1.1.1.1.2.1  1999/12/29 21:39:35  TBesset\n// updated to update3 from Robert\n//\n// Revision 1.1.1.3  1999/12/29 18:31:27  TBesset\n// Q3Radiant public version\n// Revision 1.1.1.3  1999/12/29 18:31:27  TBesset\n// Q3Radiant public version\n//\n// Revision 1.2  1999/11/22 17:46:45  Timo & Christine\n// merged EARadiant into the main tree\n// bug fixes for Q3Plugin / EAPlugin\n// export for Robert\n//\n// Revision 1.1.4.3  1999/11/15 22:39:40  Timo & Christine\n// bug fixing / additional features after update 173 from Robert\n//\n// Revision 1.1.4.2  1999/11/14 16:26:10  Timo & Christine\n// first beta of the ritualmap surface plugin\n//\n// Revision 1.1.4.1  1999/11/03 20:37:59  Timo & Christine\n// MEAN plugin for Q3Radiant, alpha version\n//\n// Revision 1.1.2.1  1999/10/27 08:34:26  Timo & Christine\n// preview version of the texture tools plugin is ready\n// ( TexTool.dll plugin is in Q3Plugin module )\n// plugins can draw in their own window using Radiant's qgl bindings\n//\n//\n// DESCRIPTION:\n// Quick interface hack for selected face interface\n// this one really needs more work, but I'm in a hurry with TexTool\n\n#ifndef __ISELECTEDFACE_H_\n#define __ISELECTEDFACE_H_\n\n// define a GUID for this interface so plugins can access and reference it\n// {5416A2A0-8633-11d3-8EF3-88B61F3A3B12}\nstatic const GUID QERSelectedFaceTable_GUID = \n{ 0x5416a2a0, 0x8633, 0x11d3, { 0x8e, 0xf3, 0x88, 0xb6, 0x1f, 0x3a, 0x3b, 0x12 } };\n\n//++timo TODO: this interface needs some cleanup with the new texture / shaders interface\n\n// retrieve the texture number to bind to\ntypedef int\t\t(WINAPI* PFN_GETTEXTURENUMBER)\t();\n// winding_t is assumed to have MAX_POINTS_ON_WINDING allocated\ntypedef int\t\t(WINAPI* PFN_GETFACEINFO)\t\t(_QERFaceData*, winding_t* );\n// tell editor to update the selected face data\ntypedef int\t\t(WINAPI* PFN_SETFACEINFO)\t\t(_QERFaceData*);\n// retrieving some texture information\ntypedef void\t(WINAPI* PFN_GETTEXTURESIZE)\t( int Size[2] );\n// loading the qtexture_t from the texture name\ntypedef qtexture_t* (WINAPI* PFN_TEXTUREFORNAME) ( const char *name );\n// straight func pointer to Select_SetTexture\n// last parameter must be casted to an IPluginTexdef\ntypedef void\t(WINAPI* PFN_SELECT_SETTEXTURE)\t\t(texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale, void* pPlugTexdef );\n\n// NOTE: some things in there are not really related to the selected face\n// having some stuff moved into a textures-dedicated part ?\nstruct _QERSelectedFaceTable\n{\n\tint m_nSize;\n\tPFN_GETTEXTURENUMBER\tm_pfnGetTextureNumber;\n\tPFN_GETFACEINFO\t\t\tm_pfnGetFaceInfo;\n\tPFN_SETFACEINFO\t\t\tm_pfnSetFaceInfo;\n\tPFN_GETTEXTURESIZE\t\tm_pfnGetTextureSize;\n\tPFN_TEXTUREFORNAME\t\tm_pfnTextureForName;\n\tPFN_SELECT_SETTEXTURE\tm_pfnSelect_SetTexture;\n};\n\n#endif"
  },
  {
    "path": "q3radiant/IShaders.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//-----------------------------------------------------------------------------\n//\n// $LogFile$\n// $Revision: 1.1.2.2 $\n// $Author: ttimo $\n// $Date: 2000/02/24 22:24:45 $\n// $Log: IShaders.cpp,v $\n// Revision 1.1.2.2  2000/02/24 22:24:45  ttimo\n// RC2\n//\n// Revision 1.1.2.1  2000/02/11 03:52:30  ttimo\n// working on the IShader interface\n//\n//\n// DESCRIPTION:\n// implementation of the shaders / textures interface\n//\n\n#include \"stdafx.h\"\n\n//++timo NOTE: this whole part is evolving on a seperate branch on SourceForge\n// will eventually turn into a major rewrite of the shader / texture code\n\n// this is a modified version of Texture_ForName\nqtexture_t* WINAPI QERApp_TryTextureForName(const char* name)\n{\n\tqtexture_t *q;\n\tchar filename[1024];\n\tfor (q=g_qeglobals.d_qtextures ; q ; q=q->next)\n\t{\n\t\tif (!strcmp(name,  q->filename))\n\t\t\t\treturn q;\n\t}\n\t// try loading from file .. this is a copy of the worst part of Texture_ForName\n\tchar cWork[1024];\n\tsprintf (filename, \"%s/%s.tga\", ValueForKey (g_qeglobals.d_project_entity, \"texturepath\"), name);\n\tQE_ConvertDOSToUnixName( cWork, filename );\n\tstrcpy(filename, cWork);\n\tunsigned char* pPixels = NULL;\n\tint nWidth;\n\tint nHeight;\n\tLoadImage(filename, &pPixels, &nWidth, &nHeight);\n\tif (pPixels == NULL)\n\t{\n\t\t// try jpg\n\t\t// blatant assumption of .tga should be fine since we sprintf'd it above\n\t\tint nLen = strlen(filename);\n\t\tfilename[nLen-3] = 'j';\n\t\tfilename[nLen-2] = 'p';\n\t\tfilename[nLen-1] = 'g';\n\t\tLoadImage(filename, &pPixels, &nWidth, &nHeight);\n\t}\n\tif (pPixels)\n\t{\n\t\tq = Texture_LoadTGATexture(pPixels, nWidth, nHeight, NULL, 0, 0, 0);\n\t\t//++timo storing the filename .. will be removed by shader code cleanup\n\t\t// this is dirty, and we sure miss some places were we should fill the filename info\n\t\tstrcpy( q->filename, name );\n\t\tSetNameShaderInfo(q, filename, name);\n\t\tSys_Printf (\"done.\\n\", name);\n\t\tfree(pPixels);\n\t\treturn q;\n\t}\n\treturn NULL;\n}\n"
  },
  {
    "path": "q3radiant/IShaders.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//-----------------------------------------------------------------------------\n//\n// $LogFile$\n// $Revision: 1.1.2.3 $\n// $Author: ttimo $\n// $Date: 2000/02/24 22:24:45 $\n// $Log: IShaders.h,v $\n// Revision 1.1.2.3  2000/02/24 22:24:45  ttimo\n// RC2\n//\n// Revision 1.1.2.2  2000/02/11 03:52:30  ttimo\n// working on the IShader interface\n//\n// Revision 1.1.2.1  2000/02/10 03:00:20  ttimo\n// adding IShaders.h\n//\n//\n// DESCRIPTION:\n// a set of functions to manipulate textures in Radiant\n// \n\n#ifndef __ISHADERS_H_\n#define __ISHADERS_H_\n\n// define a GUID for this interface so plugins can access and reference it\n// {D42F798A-DF57-11d3-A3EE-0004AC96D4C3}\nstatic const GUID QERShadersTable_GUID = \n{ 0xd42f798a, 0xdf57, 0x11d3, { 0xa3, 0xee, 0x0, 0x4, 0xac, 0x96, 0xd4, 0xc3 } };\n\n//++timo NOTE: global strategy, when there's try before it means .. if the thing can't be found / loaded it will not\n// create a default one\n\n//++timo TODO: duplicate _QERFuncTable_1::m_pfnHasShader here?\n//++timo FIXME: change the names to fit the changes we wanna do in the Radiant shader / textures code\n//++timo NOTE: for Curry, this shader loading thingy is only provided so that we can update the Radiant texture window?\n//             don't use yet .. will not implement yet\n// get a shader, load it if needed\n// returns NULL if shader doesn't exist\n//++timo will reload the shader if already loaded? .. no, don't do that yet ..\n//++timo I'm not happy with the name?\ntypedef qtexture_t* (WINAPI* PFN_TRYSHADERFORNAME) (const char* name);\n// load a texture\n// will not try loading a shader, will look for the actual image file ..\n// returns NULL on file not found\n// NOTE: don't put the .tga or .jpg filetype extension\n// if returns NULL, it means the texture needs loading, use _QERSelectedFaceTable::m_pfnTextureForName\n//++timo NOTE: all of this is hacks and workarounds, the shader code rewrite is supposed to solve all issues\ntypedef qtexture_t* (WINAPI* PFN_TRYTEXTUREFORNAME) (const char* filename);\n\nstruct _QERShadersTable\n{\n\tint\t\tm_nSize;\n\t// currently disabled\n//\tPFN_TRYLOADSHADER\tm_pfnTryLoadShader;\n\tPFN_TRYTEXTUREFORNAME\tm_pfnTryTextureForName;\n};\n\n#endif"
  },
  {
    "path": "q3radiant/LBMLIB.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// lbmlib.c\n\n#include \"stdafx.h\"\n#include \"cmdlib.h\"\n#include \"lbmlib.h\"\n#include \"bmp.h\"\n#include \"pakstuff.h\"\n#include \"jpeglib.h\"\n\n\n/*\n============================================================================\n\n\t\t\t\t\t\tLBM STUFF\n\n============================================================================\n*/\n\n\ntypedef unsigned char\tUBYTE;\n//conflicts with windows typedef short\t\t\tWORD;\ntypedef unsigned short\tUWORD;\ntypedef long\t\t\tLONG;\n\ntypedef enum\n{\n\tms_none,\n\tms_mask,\n\tms_transcolor,\n\tms_lasso\n} mask_t;\n\ntypedef enum\n{\n\tcm_none,\n\tcm_rle1\n} compress_t;\n\ntypedef struct\n{\n\tUWORD\t\tw,h;\n\tshort\t\tx,y;\n\tUBYTE\t\tnPlanes;\n\tUBYTE\t\tmasking;\n\tUBYTE\t\tcompression;\n\tUBYTE\t\tpad1;\n\tUWORD\t\ttransparentColor;\n\tUBYTE\t\txAspect,yAspect;\n\tshort\t\tpageWidth,pageHeight;\n} bmhd_t;\n\nextern\tbmhd_t\tbmhd;\t\t\t\t\t\t// will be in native byte order\n\n\n\n#define FORMID ('F'+('O'<<8)+((int)'R'<<16)+((int)'M'<<24))\n#define ILBMID ('I'+('L'<<8)+((int)'B'<<16)+((int)'M'<<24))\n#define PBMID  ('P'+('B'<<8)+((int)'M'<<16)+((int)' '<<24))\n#define BMHDID ('B'+('M'<<8)+((int)'H'<<16)+((int)'D'<<24))\n#define BODYID ('B'+('O'<<8)+((int)'D'<<16)+((int)'Y'<<24))\n#define CMAPID ('C'+('M'<<8)+((int)'A'<<16)+((int)'P'<<24))\n\n\nbmhd_t  bmhd;\n\nint    Align (int l)\n{\n\tif (l&1)\n\t\treturn l+1;\n\treturn l;\n}\n\n\n\n/*\n================\nLBMRLEdecompress\n\nSource must be evenly aligned!\n================\n*/\nbyte  *LBMRLEDecompress (byte *source,byte *unpacked, int bpwidth)\n{\n\tint     count;\n\tbyte    b,rept;\n\n\tcount = 0;\n\n\tdo\n\t{\n\t\trept = *source++;\n\n\t\tif (rept > 0x80)\n\t\t{\n\t\t\trept = (rept^0xff)+2;\n\t\t\tb = *source++;\n\t\t\tmemset(unpacked,b,rept);\n\t\t\tunpacked += rept;\n\t\t}\n\t\telse if (rept < 0x80)\n\t\t{\n\t\t\trept++;\n\t\t\tmemcpy(unpacked,source,rept);\n\t\t\tunpacked += rept;\n\t\t\tsource += rept;\n\t\t}\n\t\telse\n\t\t\trept = 0;               // rept of 0x80 is NOP\n\n\t\tcount += rept;\n\n\t} while (count<bpwidth);\n\n\tif (count>bpwidth)\n\t\tError (\"Decompression exceeded width!\\n\");\n\n\n\treturn source;\n}\n\n\n/*\n=================\nLoadLBM\n=================\n*/\nvoid LoadLBM (char *filename, byte **picture, byte **palette)\n{\n\tbyte    *LBMbuffer, *picbuffer, *cmapbuffer;\n\tint             y;\n\tbyte    *LBM_P, *LBMEND_P;\n\tbyte    *pic_p;\n\tbyte    *body_p;\n\n\tint    formtype,formlength;\n\tint    chunktype,chunklength;\n\n// qiet compiler warnings\n\tpicbuffer = NULL;\n\tcmapbuffer = NULL;\n\n//\n// load the LBM\n//\n\tLoadFile (filename, (void **)&LBMbuffer);\n\n  if (LBMbuffer == NULL)\n  {\n    return;\n  }\n//\n// parse the LBM header\n//\n\tLBM_P = LBMbuffer;\n\tif ( *(int *)LBMbuffer != LittleLong(FORMID) )\n\t   Error (\"No FORM ID at start of file!\\n\");\n\n\tLBM_P += 4;\n\tformlength = BigLong( *(int *)LBM_P );\n\tLBM_P += 4;\n\tLBMEND_P = LBM_P + Align(formlength);\n\n\tformtype = LittleLong(*(int *)LBM_P);\n\n\tif (formtype != ILBMID && formtype != PBMID)\n\t\tError (\"Unrecognized form type: %c%c%c%c\\n\", formtype&0xff\n\t\t,(formtype>>8)&0xff,(formtype>>16)&0xff,(formtype>>24)&0xff);\n\n\tLBM_P += 4;\n\n//\n// parse chunks\n//\n\n\twhile (LBM_P < LBMEND_P)\n\t{\n\t\tchunktype = LBM_P[0] + (LBM_P[1]<<8) + (LBM_P[2]<<16) + (LBM_P[3]<<24);\n\t\tLBM_P += 4;\n\t\tchunklength = LBM_P[3] + (LBM_P[2]<<8) + (LBM_P[1]<<16) + (LBM_P[0]<<24);\n\t\tLBM_P += 4;\n\n\t\tswitch ( chunktype )\n\t\t{\n\t\tcase BMHDID:\n\t\t\tmemcpy (&bmhd,LBM_P,sizeof(bmhd));\n\t\t\tbmhd.w = BigShort(bmhd.w);\n\t\t\tbmhd.h = BigShort(bmhd.h);\n\t\t\tbmhd.x = BigShort(bmhd.x);\n\t\t\tbmhd.y = BigShort(bmhd.y);\n\t\t\tbmhd.pageWidth = BigShort(bmhd.pageWidth);\n\t\t\tbmhd.pageHeight = BigShort(bmhd.pageHeight);\n\t\t\tbreak;\n\n\t\tcase CMAPID:\n\t\t\tcmapbuffer = (unsigned char*)malloc (768);\n\t\t\tmemset (cmapbuffer, 0, 768);\n\t\t\tmemcpy (cmapbuffer, LBM_P, chunklength);\n\t\t\tbreak;\n\n\t\tcase BODYID:\n\t\t\tbody_p = LBM_P;\n\n\t\t\tpic_p = picbuffer = (unsigned char*)malloc (bmhd.w*bmhd.h);\n\t\t\tif (formtype == PBMID)\n\t\t\t{\n\t\t\t//\n\t\t\t// unpack PBM\n\t\t\t//\n\t\t\t\tfor (y=0 ; y<bmhd.h ; y++, pic_p += bmhd.w)\n\t\t\t\t{\n\t\t\t\t\tif (bmhd.compression == cm_rle1)\n\t\t\t\t\t\tbody_p = LBMRLEDecompress ((byte *)body_p\n\t\t\t\t\t\t, pic_p , bmhd.w);\n\t\t\t\t\telse if (bmhd.compression == cm_none)\n\t\t\t\t\t{\n\t\t\t\t\t\tmemcpy (pic_p,body_p,bmhd.w);\n\t\t\t\t\t\tbody_p += Align(bmhd.w);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t//\n\t\t\t// unpack ILBM\n\t\t\t//\n\t\t\t\tError (\"%s is an interlaced LBM, not packed\", filename);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tLBM_P += Align(chunklength);\n\t}\n\n\tfree (LBMbuffer);\n\n\t*picture = picbuffer;\n\n\tif (palette)\n\t\t*palette = cmapbuffer;\n}\n\n\n/*\n============================================================================\n\n\t\t\t\t\t\t\tWRITE LBM\n\n============================================================================\n*/\n\n/*\n==============\nWriteLBMfile\n==============\n*/\nvoid WriteLBMfile (char *filename, byte *data,\n\t\t\t\t   int width, int height, byte *palette)\n{\n\tbyte    *lbm, *lbmptr;\n\tint    *formlength, *bmhdlength, *cmaplength, *bodylength;\n\tint    length;\n\tbmhd_t  basebmhd;\n\n\tlbm = lbmptr = (unsigned char*)malloc (width*height+1000);\n\n//\n// start FORM\n//\n\t*lbmptr++ = 'F';\n\t*lbmptr++ = 'O';\n\t*lbmptr++ = 'R';\n\t*lbmptr++ = 'M';\n\n\tformlength = (int*)lbmptr;\n\tlbmptr+=4;                      // leave space for length\n\n\t*lbmptr++ = 'P';\n\t*lbmptr++ = 'B';\n\t*lbmptr++ = 'M';\n\t*lbmptr++ = ' ';\n\n//\n// write BMHD\n//\n\t*lbmptr++ = 'B';\n\t*lbmptr++ = 'M';\n\t*lbmptr++ = 'H';\n\t*lbmptr++ = 'D';\n\n\tbmhdlength = (int *)lbmptr;\n\tlbmptr+=4;                      // leave space for length\n\n\tmemset (&basebmhd,0,sizeof(basebmhd));\n\tbasebmhd.w = BigShort((short)width);\n\tbasebmhd.h = BigShort((short)height);\n\tbasebmhd.nPlanes = 8;\n\tbasebmhd.xAspect = 5;\n\tbasebmhd.yAspect = 6;\n\tbasebmhd.pageWidth = BigShort((short)width);\n\tbasebmhd.pageHeight = BigShort((short)height);\n\n\tmemcpy (lbmptr,&basebmhd,sizeof(basebmhd));\n\tlbmptr += sizeof(basebmhd);\n\n\tlength = lbmptr-(byte *)bmhdlength-4;\n\t*bmhdlength = BigLong(length);\n\tif (length&1)\n\t\t*lbmptr++ = 0;          // pad chunk to even offset\n\n//\n// write CMAP\n//\n\t*lbmptr++ = 'C';\n\t*lbmptr++ = 'M';\n\t*lbmptr++ = 'A';\n\t*lbmptr++ = 'P';\n\n\tcmaplength = (int *)lbmptr;\n\tlbmptr+=4;                      // leave space for length\n\n\tmemcpy (lbmptr,palette,768);\n\tlbmptr += 768;\n\n\tlength = lbmptr-(byte *)cmaplength-4;\n\t*cmaplength = BigLong(length);\n\tif (length&1)\n\t\t*lbmptr++ = 0;          // pad chunk to even offset\n\n//\n// write BODY\n//\n\t*lbmptr++ = 'B';\n\t*lbmptr++ = 'O';\n\t*lbmptr++ = 'D';\n\t*lbmptr++ = 'Y';\n\n\tbodylength = (int *)lbmptr;\n\tlbmptr+=4;                      // leave space for length\n\n\tmemcpy (lbmptr,data,width*height);\n\tlbmptr += width*height;\n\n\tlength = lbmptr-(byte *)bodylength-4;\n\t*bodylength = BigLong(length);\n\tif (length&1)\n\t\t*lbmptr++ = 0;          // pad chunk to even offset\n\n//\n// done\n//\n\tlength = lbmptr-(byte *)formlength-4;\n\t*formlength = BigLong(length);\n\tif (length&1)\n\t\t*lbmptr++ = 0;          // pad chunk to even offset\n\n//\n// write output file\n//\n\tSaveFile (filename, lbm, lbmptr-lbm);\n\tfree (lbm);\n}\n\n/*\n============================================================================\n\nLOAD PCX\n\n============================================================================\n*/\ntypedef struct\n{\n    char\tmanufacturer;\n    char\tversion;\n    char\tencoding;\n    char\tbits_per_pixel;\n    unsigned short\txmin,ymin,xmax,ymax;\n    unsigned short\thres,vres;\n    unsigned char\tpalette[48];\n    char\treserved;\n    char\tcolor_planes;\n    unsigned short\tbytes_per_line;\n    unsigned short\tpalette_type;\n    char\tfiller[58];\n    unsigned char\tdata;\t\t\t// unbounded\n} pcx_t;\n\n/*\n==============\nLoadPCX\n==============\n*/\nvoid LoadPCX (char *filename, byte **pic, byte **palette, int *width, int *height)\n{\n\tbyte\t*raw = 0;\n\tpcx_t\t*pcx;\n\tint\t\tx, y;\n\tint\t\tlen;\n\tint\t\tdataByte, runLength;\n\tbyte\t*out, *pix;\n\n\tif (pic)\n\t\t*pic = NULL;\n\tif (palette)\n\t\t*palette = NULL;\n\tif (width)\n\t\t*width = 0;\n\tif (height)\n\t\t*height = 0;\n\n\t//\n\t// load the file\n\t//\n\tlen = LoadFile (filename, (void **)&raw);\n\tif (len == -1)\n\t\treturn;\n\n\t//\n\t// parse the PCX file\n\t//\n\tpcx = (pcx_t *)raw;\n\traw = &pcx->data;\n\n\tpcx->xmin = LittleShort(pcx->xmin);\n\tpcx->ymin = LittleShort(pcx->ymin);\n\tpcx->xmax = LittleShort(pcx->xmax);\n\tpcx->ymax = LittleShort(pcx->ymax);\n\tpcx->hres = LittleShort(pcx->hres);\n\tpcx->vres = LittleShort(pcx->vres);\n\tpcx->bytes_per_line = LittleShort(pcx->bytes_per_line);\n\tpcx->palette_type = LittleShort(pcx->palette_type);\n\n\tif (pcx->manufacturer != 0x0a\n\t\t|| pcx->version != 5\n\t\t|| pcx->encoding != 1\n\t\t|| pcx->bits_per_pixel != 8\n\t\t|| pcx->xmax >= 640\n\t\t|| pcx->ymax >= 480)\n\t\tError (\"Bad pcx file %s\", filename);\n\t\n\tif (palette)\n\t{\n\t\t*palette = (unsigned char*)malloc(768);\n\t\tmemcpy (*palette, (byte *)pcx + len - 768, 768);\n\t}\n\n\tif (width)\n\t\t*width = pcx->xmax+1;\n\tif (height)\n\t\t*height = pcx->ymax+1;\n\n\tif (!pic)\n  {\n    free(pcx);\n\t\treturn;\n  }\n\n\tout = (unsigned char*)malloc ( (pcx->ymax+1) * (pcx->xmax+1) );\n\tif (!out)\n\t\tError (\"Skin_Cache: couldn't allocate\");\n\n\t*pic = out;\n\n\tpix = out;\n\n\tfor (y=0 ; y<=pcx->ymax ; y++, pix += pcx->xmax+1)\n\t{\n\t\tfor (x=0 ; x<=pcx->xmax ; )\n\t\t{\n\t\t\tdataByte = *raw++;\n\n\t\t\tif((dataByte & 0xC0) == 0xC0)\n\t\t\t{\n\t\t\t\trunLength = dataByte & 0x3F;\n\t\t\t\tdataByte = *raw++;\n\t\t\t}\n\t\t\telse\n\t\t\t\trunLength = 1;\n\n\t\t\twhile(runLength-- > 0)\n\t\t\t\tpix[x++] = dataByte;\n\t\t}\n\n\t}\n\n\tif ( raw - (byte *)pcx > len)\n\t\tError (\"PCX file %s was malformed\", filename);\n\n\tfree (pcx);\n}\n/* \n============== \nWritePCXfile \n============== \n*/ \nvoid WritePCXfile (char *filename, byte *data, \n\t\t\t\t   int width, int height, byte *palette) \n{\n\tint\t\ti, j, length;\n\tpcx_t\t*pcx;\n\tbyte\t\t*pack;\n\t  \n\tpcx = (pcx_t*)malloc (width*height*2+1000);\n\tmemset (pcx, 0, sizeof(*pcx));\n\n\tpcx->manufacturer = 0x0a;\t// PCX id\n\tpcx->version = 5;\t\t\t// 256 color\n \tpcx->encoding = 1;\t\t// uncompressed\n\tpcx->bits_per_pixel = 8;\t\t// 256 color\n\tpcx->xmin = 0;\n\tpcx->ymin = 0;\n\tpcx->xmax = LittleShort((short)(width-1));\n\tpcx->ymax = LittleShort((short)(height-1));\n\tpcx->hres = LittleShort((short)width);\n\tpcx->vres = LittleShort((short)height);\n\tpcx->color_planes = 1;\t\t// chunky image\n\tpcx->bytes_per_line = LittleShort((short)width);\n\tpcx->palette_type = LittleShort(2);\t\t// not a grey scale\n\n\t// pack the image\n\tpack = &pcx->data;\n\t\n\tfor (i=0 ; i<height ; i++)\n\t{\n\t\tfor (j=0 ; j<width ; j++)\n\t\t{\n\t\t\tif ( (*data & 0xc0) != 0xc0)\n\t\t\t\t*pack++ = *data++;\n\t\t\telse\n\t\t\t{\n\t\t\t\t*pack++ = 0xc1;\n\t\t\t\t*pack++ = *data++;\n\t\t\t}\n\t\t}\n\t}\n\t\t\t\n\t// write the palette\n\t*pack++ = 0x0c;\t// palette ID byte\n\tfor (i=0 ; i<768 ; i++)\n\t\t*pack++ = *palette++;\n\t\t\n// write output file \n\tlength = pack - (byte *)pcx;\n\tSaveFile (filename, pcx, length);\n\n\tfree (pcx);\n} \n\n/*\n============================================================================\n\nLOAD IMAGE\n\n============================================================================\n*/\n\n/*\n==============\nLoad256Image\n\nWill load either an lbm or pcx, depending on extension.\nAny of the return pointers can be NULL if you don't want them.\n==============\n*/\nvoid Load256Image (char *name, byte **pixels, byte **palette,\n\t\t\t\t   int *width, int *height)\n{\n\tchar\text[128];\n\tbitmap_t\tbmp;\n\n\tExtractFileExtension (name, ext);\n\tif (stricmp(ext, \"lbm\"))\n\t{\n\t\tLoadLBM (name, pixels, palette);\n\t\tif (width)\n\t\t\t*width = bmhd.w;\n\t\tif (height)\n\t\t\t*height = bmhd.h;\n\t}\n\telse if (stricmp (ext, \"pcx\"))\n\t{\n\t\tLoadPCX (name, pixels, palette, width, height);\n\t}\n\telse if (stricmp (ext, \"bmp\"))\n\t{\n\t\tLoadBMP (name, &bmp);\n\t\tif (bmp.palette)\n\t\t{\n\t\t\t*palette = (unsigned char*)malloc (768);\n\t\t\tmemcpy (*palette, bmp.palette, 768);\n\t\t}\n\t\tFreeBMP (&bmp);\t\t\n\t}\n\telse\n\t\tError (\"%s doesn't have a known image extension\", name);\n}\n\n\n/*\n==============\nSave256Image\n\nWill save either an lbm or pcx, depending on extension.\n==============\n*/\nvoid Save256Image (char *name, byte *pixels, byte *palette,\n\t\t\t\t   int width, int height)\n{\n\tchar\text[128];\n\n\tExtractFileExtension (name, ext);\n\tif (!strcmp (ext, \"lbm\"))\n\t{\n\t\tWriteLBMfile (name, pixels, width, height, palette);\n\t}\n\telse if (!stricmp (ext, \"pcx\"))\n\t{\n\t\tWritePCXfile (name, pixels, width, height, palette);\n\t}\n\telse\n\t\tError (\"%s doesn't have a known image extension\", name);\n}\n\n\n\n/*\n============================================================================\n\nTARGA IMAGE\n\n============================================================================\n*/\ntypedef struct _TargaHeader {\n\tunsigned char \tid_length, colormap_type, image_type;\n\tunsigned short\tcolormap_index, colormap_length;\n\tunsigned char\tcolormap_size;\n\tunsigned short\tx_origin, y_origin, width, height;\n\tunsigned char\tpixel_size, attributes;\n} TargaHeader;\n\nint fgetLittleShort (FILE *f)\n{\n\tbyte\tb1, b2;\n\n\tb1 = fgetc(f);\n\tb2 = fgetc(f);\n\n\treturn (short)(b1 + b2*256);\n}\n\nint getLittleShort (byte*& p)\n{\n\tbyte\tb1, b2;\n\tb1 = *p++;\n\tb2 = *p++;\n\treturn (short)(b1 + b2*256);\n}\n\nint getLittleLong (byte*& p)\n{\n\tbyte\tb1, b2, b3, b4;\n\n\tb1 = *p++;\n\tb2 = *p++;\n\tb3 = *p++;\n\tb4 = *p++;\n\treturn b1 + (b2<<8) + (b3<<16) + (b4<<24);\n}\n\nchar getc(byte*& p)\n{\n  return *p++;\n}\n\n/*\n=========================================================\n\nBMP LOADING\n\n=========================================================\n*/\ntypedef struct\n{\n\tchar id[2];\n\tunsigned long fileSize;\n\tunsigned long reserved0;\n\tunsigned long bitmapDataOffset;\n\tunsigned long bitmapHeaderSize;\n\tunsigned long width;\n\tunsigned long height;\n\tunsigned short planes;\n\tunsigned short bitsPerPixel;\n\tunsigned long compression;\n\tunsigned long bitmapDataSize;\n\tunsigned long hRes;\n\tunsigned long vRes;\n\tunsigned long colors;\n\tunsigned long importantColors;\n\tunsigned char palette[256][4];\n} BMPHeader_t;\n\nstatic void LoadBMP( const char *name, byte **pic, int *width, int *height )\n{\n\tint\t\tcolumns, rows, numPixels;\n\tbyte\t*pixbuf;\n\tint\t\trow, column;\n\tbyte\t*buf_p;\n\tbyte\t*buffer;\n\tunsigned int\t\tlength;\n\tBMPHeader_t bmpHeader;\n\tbyte\t\t*bmpRGBA;\n\n\t*pic = NULL;\n\n\t//\n\t// load the file\n\t//\n\tlength = LoadFile( ( char * ) name, (void **)&buffer);\n\tif (length == -1)\n  {\n    length = PakLoadAnyFile( (char*)name, (void**)&buffer);\n    if (length == -1)\n    {\n\t\t  return;\n    }\n  }\n\n\tbuf_p = buffer;\n\n\tbmpHeader.id[0] = *buf_p++;\n\tbmpHeader.id[1] = *buf_p++;\n\tbmpHeader.fileSize = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.reserved0 = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.bitmapDataOffset = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.bitmapHeaderSize = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.width = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.height = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.planes = LittleShort( * ( short * ) buf_p );\n\tbuf_p += 2;\n\tbmpHeader.bitsPerPixel = LittleShort( * ( short * ) buf_p );\n\tbuf_p += 2;\n\tbmpHeader.compression = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.bitmapDataSize = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.hRes = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.vRes = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.colors = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\tbmpHeader.importantColors = LittleLong( * ( long * ) buf_p );\n\tbuf_p += 4;\n\n\tmemcpy( bmpHeader.palette, buf_p, sizeof( bmpHeader.palette ) );\n\n\tif ( bmpHeader.bitsPerPixel == 8 )\n\t\tbuf_p += 1024;\n\n\tif ( bmpHeader.id[0] != 'B' && bmpHeader.id[1] != 'M' ) \n\t{\n\t\tSys_Printf(\"LoadBMP: only Windows-style BMP files supported (%s)\\n\", name );\n\t}\n\tif ( bmpHeader.fileSize != length )\n\t{\n\t\tSys_Printf(\"LoadBMP: header size does not match file size (%d vs. %d) (%s)\\n\", bmpHeader.fileSize, length, name );\n\t}\n\tif ( bmpHeader.compression != 0 )\n\t{\n\t\tSys_Printf(\"LoadBMP: only uncompressed BMP files supported (%s)\\n\", name );\n\t}\n\tif ( bmpHeader.bitsPerPixel < 8 )\n\t{\n\t\tSys_Printf(\"LoadBMP: monochrome and 4-bit BMP files not supported (%s)\\n\", name );\n\t}\n\n\tcolumns = bmpHeader.width;\n\trows = bmpHeader.height;\n\tif ( rows < 0 )\n\t\trows = -rows;\n\tnumPixels = columns * rows;\n\n\tif ( width ) \n\t\t*width = columns;\n\tif ( height )\n\t\t*height = rows;\n\n\tbmpRGBA = reinterpret_cast<unsigned char*>(malloc( numPixels * 4 ));\n\t*pic = bmpRGBA;\n\n\n\tfor ( row = rows-1; row >= 0; row-- )\n\t{\n\t\tpixbuf = bmpRGBA + row*columns*4;\n\n\t\tfor ( column = 0; column < columns; column++ )\n\t\t{\n\t\t\tunsigned char red, green, blue, alpha;\n\t\t\tint palIndex;\n\t\t\tunsigned short shortPixel;\n\n\t\t\tswitch ( bmpHeader.bitsPerPixel )\n\t\t\t{\n\t\t\tcase 8:\n\t\t\t\tpalIndex = *buf_p++;\n\t\t\t\t*pixbuf++ = bmpHeader.palette[palIndex][2];\n\t\t\t\t*pixbuf++ = bmpHeader.palette[palIndex][1];\n\t\t\t\t*pixbuf++ = bmpHeader.palette[palIndex][0];\n\t\t\t\t*pixbuf++ = 0xff;\n\t\t\t\tbreak;\n\t\t\tcase 16:\n\t\t\t\tshortPixel = * ( unsigned short * ) pixbuf;\n\t\t\t\tpixbuf += 2;\n\t\t\t\t*pixbuf++ = ( shortPixel & ( 31 << 10 ) ) >> 7;\n\t\t\t\t*pixbuf++ = ( shortPixel & ( 31 << 5 ) ) >> 2;\n\t\t\t\t*pixbuf++ = ( shortPixel & ( 31 ) ) << 3;\n\t\t\t\t*pixbuf++ = 0xff;\n\t\t\t\tbreak;\n\n\t\t\tcase 24:\n\t\t\t\tblue = *buf_p++;\n\t\t\t\tgreen = *buf_p++;\n\t\t\t\tred = *buf_p++;\n\t\t\t\t*pixbuf++ = red;\n\t\t\t\t*pixbuf++ = green;\n\t\t\t\t*pixbuf++ = blue;\n\t\t\t\t*pixbuf++ = 255;\n\t\t\t\tbreak;\n\t\t\tcase 32:\n\t\t\t\tblue = *buf_p++;\n\t\t\t\tgreen = *buf_p++;\n\t\t\t\tred = *buf_p++;\n\t\t\t\talpha = *buf_p++;\n\t\t\t\t*pixbuf++ = red;\n\t\t\t\t*pixbuf++ = green;\n\t\t\t\t*pixbuf++ = blue;\n\t\t\t\t*pixbuf++ = alpha;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tSys_Printf(\"LoadBMP: illegal pixel_size '%d' in file '%s'\\n\", bmpHeader.bitsPerPixel, name );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tfree( buffer );\n\n}\n\n\n/*\n=================================================================\n\nPCX LOADING\n\n=================================================================\n*/\n\n\n/*\n==============\nLoadPCX\n==============\n*/\nstatic void LoadPCX ( const char *filename, byte **pic, byte **palette, int *width, int *height)\n{\n\tbyte\t*raw;\n\tpcx_t\t*pcx;\n\tint\t\tx, y;\n\tint\t\tlen;\n\tint\t\tdataByte, runLength;\n\tbyte\t*out, *pix;\n\tint\t\txmax, ymax;\n\n\t*pic = NULL;\n\t*palette = NULL;\n\n\t//\n\t// load the file\n\t//\n\tlen = LoadFile( ( char * ) filename, (void **)&raw);\n\tif (len == -1) \n  {\n    len = PakLoadAnyFile( (char*)filename, (void**)&raw);\n    if (len == -1)\n    {\n\t\t  return;\n    }\n\t}\n\n\t//\n\t// parse the PCX file\n\t//\n\tpcx = (pcx_t *)raw;\n\traw = &pcx->data;\n\n  \txmax = LittleShort(pcx->xmax);\n    ymax = LittleShort(pcx->ymax);\n\n\tif (pcx->manufacturer != 0x0a\n\t\t|| pcx->version != 5\n\t\t|| pcx->encoding != 1\n\t\t|| pcx->bits_per_pixel != 8\n\t\t|| xmax >= 1024\n\t\t|| ymax >= 1024)\n\t{\n\t\tSys_Printf (\"Bad pcx file %s (%i x %i) (%i x %i)\\n\", filename, xmax+1, ymax+1, pcx->xmax, pcx->ymax);\n\t\treturn;\n\t}\n\n\tout = reinterpret_cast<unsigned char*>(malloc ( (ymax+1) * (xmax+1) ));\n\n\t*pic = out;\n\n\tpix = out;\n\n\tif (palette)\n\t{\n\t\t*palette = reinterpret_cast<unsigned char*>(malloc(768));\n\t\tmemcpy (*palette, (byte *)pcx + len - 768, 768);\n\t}\n\n\tif (width)\n\t\t*width = xmax+1;\n\tif (height)\n\t\t*height = ymax+1;\n// FIXME: use bytes_per_line here?\n\n\tfor (y=0 ; y<=ymax ; y++, pix += xmax+1)\n\t{\n\t\tfor (x=0 ; x<=xmax ; )\n\t\t{\n\t\t\tdataByte = *raw++;\n\n\t\t\tif((dataByte & 0xC0) == 0xC0)\n\t\t\t{\n\t\t\t\trunLength = dataByte & 0x3F;\n\t\t\t\tdataByte = *raw++;\n\t\t\t}\n\t\t\telse\n\t\t\t\trunLength = 1;\n\n\t\t\twhile(runLength-- > 0)\n\t\t\t\tpix[x++] = dataByte;\n\t\t}\n\n\t}\n\n\tif ( raw - (byte *)pcx > len)\n\t{\n\t\tSys_Printf (\"PCX file %s was malformed\", filename);\n\t\tfree (*pic);\n\t\t*pic = NULL;\n\t}\n\n\tfree(pcx);\n}\n\n\n/*\n==============\nLoadPCX32\n==============\n*/\nstatic void LoadPCX32 ( const char *filename, byte **pic, int *width, int *height) {\n\tbyte\t*palette;\n\tbyte\t*pic8;\n\tint\t\ti, c, p;\n\tbyte\t*pic32;\n\n\tLoadPCX (filename, &pic8, &palette, width, height);\n\tif (!pic8) {\n\t\t*pic = NULL;\n\t\treturn;\n\t}\n\n\tc = (*width) * (*height);\n\tpic32 = *pic = reinterpret_cast<unsigned char*>(malloc(4 * c ));\n\tfor (i = 0 ; i < c ; i++) {\n\t\tp = pic8[i];\n\t\tpic32[0] = palette[p*3];\n\t\tpic32[1] = palette[p*3 + 1];\n\t\tpic32[2] = palette[p*3 + 2];\n\t\tpic32[3] = 255;\n\t\tpic32 += 4;\n\t}\n\n\tfree (pic8);\n\tfree (palette);\n}\n\n/*\n=========================================================\n\nTARGA LOADING\n\n=========================================================\n*/\n\n/*\n=============\nLoadTGA\n=============\n*/\nvoid LoadTGA ( const char *name, byte **pic, int *width, int *height)\n{\n\tint\t\tcolumns, rows, numPixels;\n\tbyte\t*pixbuf;\n\tint\t\trow, column;\n\tbyte\t*buf_p;\n\tbyte\t*buffer;\n\tTargaHeader\ttarga_header;\n\tbyte\t\t*targa_rgba;\n\n\t*pic = NULL;\n\n\t//\n\t// load the file\n\t//\n\tint nLen = LoadFile ( ( char * ) name, (void **)&buffer);\n\tif (nLen == -1) \n  {\n    nLen = PakLoadAnyFile((char*)name, (void**)&buffer);\n    if (nLen == -1)\n    {\n\t\t  return;\n    }\n\t}\n\n\tbuf_p = buffer;\n\n\ttarga_header.id_length = *buf_p++;\n\ttarga_header.colormap_type = *buf_p++;\n\ttarga_header.image_type = *buf_p++;\n\t\n\ttarga_header.colormap_index = LittleShort ( *(short *)buf_p );\n\tbuf_p += 2;\n\ttarga_header.colormap_length = LittleShort ( *(short *)buf_p );\n\tbuf_p += 2;\n\ttarga_header.colormap_size = *buf_p++;\n\ttarga_header.x_origin = LittleShort ( *(short *)buf_p );\n\tbuf_p += 2;\n\ttarga_header.y_origin = LittleShort ( *(short *)buf_p );\n\tbuf_p += 2;\n\ttarga_header.width = LittleShort ( *(short *)buf_p );\n\tbuf_p += 2;\n\ttarga_header.height = LittleShort ( *(short *)buf_p );\n\tbuf_p += 2;\n\ttarga_header.pixel_size = *buf_p++;\n\ttarga_header.attributes = *buf_p++;\n\n\t//++timo debug\n\tif (targa_header.pixel_size == 32)\n\t\tSys_Printf(\"%s is 32bit\\n\", name);\n\tbool bAlphaOK = false;\n\n\tif (targa_header.image_type!=2 \n\t\t&& targa_header.image_type!=10\n\t\t&& targa_header.image_type != 3 ) \n\t{\n\t\tSys_Printf(\"LoadTGA: Only type 2 (RGB), 3 (gray), and 10 (RGB) TGA images supported\\n\");\n\t}\n\n\tif ( targa_header.colormap_type != 0 )\n\t{\n\t\tSys_Printf(\"LoadTGA: colormaps not supported\\n\" );\n\t}\n\n\tif ( ( targa_header.pixel_size != 32 && targa_header.pixel_size != 24 ) && targa_header.image_type != 3 )\n\t{\n\t\tSys_Printf(\"LoadTGA: Only 32 or 24 bit images supported (no colormaps)\\n\");\n\t}\n\n\tcolumns = targa_header.width;\n\trows = targa_header.height;\n\tnumPixels = columns * rows;\n\n\tif (width)\n\t\t*width = columns;\n\tif (height)\n\t\t*height = rows;\n\n\ttarga_rgba = reinterpret_cast<unsigned char*>(malloc (numPixels*4));\n\t*pic = targa_rgba;\n\n\tif (targa_header.id_length != 0)\n\t\tbuf_p += targa_header.id_length;  // skip TARGA image comment\n\t\n\tif ( targa_header.image_type==2 || targa_header.image_type == 3 )\n\t{ \n\t\t// Uncompressed RGB or gray scale image\n\t\tfor(row=rows-1; row>=0; row--) \n\t\t{\n\t\t\tpixbuf = targa_rgba + row*columns*4;\n\t\t\tfor(column=0; column<columns; column++) \n\t\t\t{\n\t\t\t\tunsigned char red,green,blue,alphabyte;\n\t\t\t\tswitch (targa_header.pixel_size) \n\t\t\t\t{\n\t\t\t\t\t\n\t\t\t\tcase 8:\n\t\t\t\t\tblue = *buf_p++;\n\t\t\t\t\tgreen = blue;\n\t\t\t\t\tred = blue;\n\t\t\t\t\t*pixbuf++ = red;\n\t\t\t\t\t*pixbuf++ = green;\n\t\t\t\t\t*pixbuf++ = blue;\n\t\t\t\t\t*pixbuf++ = 255;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 24:\n\t\t\t\t\tblue = *buf_p++;\n\t\t\t\t\tgreen = *buf_p++;\n\t\t\t\t\tred = *buf_p++;\n\t\t\t\t\t*pixbuf++ = red;\n\t\t\t\t\t*pixbuf++ = green;\n\t\t\t\t\t*pixbuf++ = blue;\n\t\t\t\t\t*pixbuf++ = 255;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 32:\n\t\t\t\t\tblue = *buf_p++;\n\t\t\t\t\tgreen = *buf_p++;\n\t\t\t\t\tred = *buf_p++;\n\t\t\t\t\talphabyte = *buf_p++;\n\t\t\t\t\t//++timo debug: detect if the whole alpha channel is 0\n\t\t\t\t\tif (alphabyte != 0)\n\t\t\t\t\t\tbAlphaOK = true;\n\t\t\t\t\t*pixbuf++ = red;\n\t\t\t\t\t*pixbuf++ = green;\n\t\t\t\t\t*pixbuf++ = blue;\n\t\t\t\t\t*pixbuf++ = alphabyte;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tSys_Printf(\"LoadTGA: illegal pixel_size '%d' in file '%s'\\n\", targa_header.pixel_size, name );\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t//++timo debug\n\t\tif (bAlphaOK)\n\t\t\tSys_Printf(\"alpha channel OK\");\n\t\telse\n\t\t\tSys_Printf(\"empty alpha channel!\");\n\t}\n\telse if (targa_header.image_type==10) {   // Runlength encoded RGB images\n\n\t\t//++timo debug\n\t\tSys_Printf(\"runlength encode RGB image\");\n\n\t\tunsigned char red,green,blue,alphabyte,packetHeader,packetSize,j;\n\n\t\tred = 0;\n\t\tgreen = 0;\n\t\tblue = 0;\n\t\talphabyte = 0xff;\n\n\t\tfor(row=rows-1; row>=0; row--) {\n\t\t\tpixbuf = targa_rgba + row*columns*4;\n\t\t\tfor(column=0; column<columns; ) {\n\t\t\t\tpacketHeader= *buf_p++;\n\t\t\t\tpacketSize = 1 + (packetHeader & 0x7f);\n\t\t\t\tif (packetHeader & 0x80) {        // run-length packet\n\t\t\t\t\tswitch (targa_header.pixel_size) {\n\t\t\t\t\t\tcase 24:\n\t\t\t\t\t\t\t\tblue = *buf_p++;\n\t\t\t\t\t\t\t\tgreen = *buf_p++;\n\t\t\t\t\t\t\t\tred = *buf_p++;\n\t\t\t\t\t\t\t\talphabyte = 255;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 32:\n\t\t\t\t\t\t\t\tblue = *buf_p++;\n\t\t\t\t\t\t\t\tgreen = *buf_p++;\n\t\t\t\t\t\t\t\tred = *buf_p++;\n\t\t\t\t\t\t\t\talphabyte = *buf_p++;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tSys_Printf(\"LoadTGA: illegal pixel_size '%d' in file '%s'\\n\", targa_header.pixel_size, name );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\n\t\t\t\t\tfor(j=0;j<packetSize;j++) {\n\t\t\t\t\t\t*pixbuf++=red;\n\t\t\t\t\t\t*pixbuf++=green;\n\t\t\t\t\t\t*pixbuf++=blue;\n\t\t\t\t\t\t*pixbuf++=alphabyte;\n\t\t\t\t\t\tcolumn++;\n\t\t\t\t\t\tif (column==columns) { // run spans across rows\n\t\t\t\t\t\t\tcolumn=0;\n\t\t\t\t\t\t\tif (row>0)\n\t\t\t\t\t\t\t\trow--;\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tgoto breakOut;\n\t\t\t\t\t\t\tpixbuf = targa_rgba + row*columns*4;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {                            // non run-length packet\n\t\t\t\t\tfor(j=0;j<packetSize;j++) {\n\t\t\t\t\t\tswitch (targa_header.pixel_size) {\n\t\t\t\t\t\t\tcase 24:\n\t\t\t\t\t\t\t\t\tblue = *buf_p++;\n\t\t\t\t\t\t\t\t\tgreen = *buf_p++;\n\t\t\t\t\t\t\t\t\tred = *buf_p++;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = red;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = green;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = blue;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = 255;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 32:\n\t\t\t\t\t\t\t\t\tblue = *buf_p++;\n\t\t\t\t\t\t\t\t\tgreen = *buf_p++;\n\t\t\t\t\t\t\t\t\tred = *buf_p++;\n\t\t\t\t\t\t\t\t\talphabyte = *buf_p++;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = red;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = green;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = blue;\n\t\t\t\t\t\t\t\t\t*pixbuf++ = alphabyte;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tSys_Printf(\"LoadTGA: illegal pixel_size '%d' in file '%s'\\n\", targa_header.pixel_size, name );\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcolumn++;\n\t\t\t\t\t\tif (column==columns) { // pixel packet run spans across rows\n\t\t\t\t\t\t\tcolumn=0;\n\t\t\t\t\t\t\tif (row>0)\n\t\t\t\t\t\t\t\trow--;\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tgoto breakOut;\n\t\t\t\t\t\t\tpixbuf = targa_rgba + row*columns*4;\n\t\t\t\t\t\t}\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreakOut:;\n\t\t}\n\t}\n\n\tfree(buffer);\n}\n\n\n\n\nvoid LoadJPG( const char *filename, unsigned char **pic, int *width, int *height ) \n{\n  byte\t*fbuffer = NULL;\n  int nLen = LoadFile( ( char * ) filename, (void **)&fbuffer);\n  if (nLen == -1) \n  {\n    nLen = PakLoadAnyFile((char*)filename, (void**)&fbuffer);\n    if (nLen == -1)\n    {\n\t\t  return;\n    }\n  }\n  LoadJPGBuff(fbuffer, pic, width, height);\n  free(fbuffer);\n}\n\n//===================================================================\n\n/*\n=================\nLoadImage\n\nLoads any of the supported image types into a cannonical\n32 bit format.\n=================\n*/\nvoid LoadImage( const char *name, byte **pic, int *width, int *height ) \n{\n\tint\t\tlen;\n\t*pic = NULL;\n\t*width = 0;\n\t*height = 0;\n\n\tlen = strlen(name);\n\tif (len<5) \n  {\n\t\treturn;\n\t}\n\n\tif ( !stricmp( name+len-4, \".tga\" ) ) \n  {\n\t  LoadTGA( name, pic, width, height );\n\t}\n  else if ( !stricmp(name+len-4, \".pcx\") ) \n  {\n    LoadPCX32( name, pic, width, height );\n\t} \n  else if ( !stricmp( name+len-4, \".bmp\" ) ) \n  {\n\t\tLoadBMP( name, pic, width, height );\n\t} \n  else if ( !stricmp( name+len-4, \".jpg\" ) ) \n  {\n\t\tLoadJPG( name, pic, width, height ); \n\t}\n}\n\n"
  },
  {
    "path": "q3radiant/LBMLIB.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// piclib.h\n\n\nvoid LoadLBM (char *filename, byte **picture, byte **palette);\nvoid WriteLBMfile (char *filename, byte *data, int width, int height\n\t, byte *palette);\nvoid LoadPCX (char *filename, byte **picture, byte **palette, int *width, int *height);\nvoid WritePCXfile (char *filename, byte *data, int width, int height\n\t, byte *palette);\n\n// loads / saves either lbm or pcx, depending on extension\nvoid Load256Image (char *name, byte **pixels, byte **palette,\n\t\t\t\t   int *width, int *height);\nvoid Save256Image (char *name, byte *pixels, byte *palette,\n\t\t\t\t   int width, int height);\n\n\nvoid LoadTGA (char *filename, byte **pixels, int *width, int *height);\nvoid LoadImage( const char *name, byte **pic, int *width, int *height );\n"
  },
  {
    "path": "q3radiant/LstToolBar.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// LstToolBar.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"LstToolBar.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CLstToolBar\n\nCLstToolBar::CLstToolBar()\n{\n}\n\nCLstToolBar::~CLstToolBar()\n{\n}\n\n\nBEGIN_MESSAGE_MAP(CLstToolBar, CToolBar)\n\t//{{AFX_MSG_MAP(CLstToolBar)\n\tON_WM_PARENTNOTIFY()\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CLstToolBar message handlers\n\nvoid CLstToolBar::OnParentNotify(UINT message, LPARAM lParam) \n{\n\tCToolBar::OnParentNotify(message, lParam);\n}\n"
  },
  {
    "path": "q3radiant/LstToolBar.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_LSTTOOLBAR_H__279AAE23_78C5_11D1_B53C_00AA00A410FC__INCLUDED_)\n#define AFX_LSTTOOLBAR_H__279AAE23_78C5_11D1_B53C_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// LstToolBar.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CLstToolBar window\n\nclass CLstToolBar : public CToolBar\n{\n// Construction\npublic:\n\tCLstToolBar();\n\n// Attributes\npublic:\n\n// Operations\npublic:\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CLstToolBar)\n\t//}}AFX_VIRTUAL\n\n// Implementation\npublic:\n\tvirtual ~CLstToolBar();\n\n\t// Generated message map functions\nprotected:\n\t//{{AFX_MSG(CLstToolBar)\n\tafx_msg void OnParentNotify(UINT message, LPARAM lParam);\n\t//}}AFX_MSG\n\n\tDECLARE_MESSAGE_MAP()\n};\n\n/////////////////////////////////////////////////////////////////////////////\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_LSTTOOLBAR_H__279AAE23_78C5_11D1_B53C_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/MAP.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// map.c\n\n#include \"stdafx.h\"\n#include \"qe3.h\"\n#include \"PrefsDlg.h\"\n\nqboolean\tmodified;\t\t// for quit confirmation (0 = clean, 1 = unsaved,\n\t\t\t\t\t\t\t// 2 = autosaved, but not regular saved) \n\nchar\t\tcurrentmap[1024];\n\n\nbrush_t\tactive_brushes;\t\t// brushes currently being displayed\nbrush_t\tselected_brushes;\t// highlighted\n\nface_t\t*selected_face;\nbrush_t\t*selected_face_brush;\n\nbrush_t\tfiltered_brushes;\t// brushes that have been filtered or regioned\n\nentity_t\tentities;\t\t// head/tail of doubly linked list\n\nentity_t\t*world_entity = NULL; // \"classname\" \"worldspawn\" !\n\nvoid AddRegionBrushes (void);\nvoid RemoveRegionBrushes (void);\n\n\nvoid DupLists()\n{\n  DWORD dw = GetTickCount();\n\n}\n\n/*\n=============================================================\n\n  Cross map selection saving\n\n  this could fuck up if you have only part of a complex entity selected...\n=============================================================\n*/\n\nbrush_t\t\tbetween_brushes;\nentity_t\tbetween_entities;\n\nbool g_bRestoreBetween = false;\n\nvoid Map_SaveBetween (void)\n{\n\n\tif (g_pParentWnd->ActiveXY())\n  {\n    g_bRestoreBetween = true;\n    g_pParentWnd->ActiveXY()->Copy();\n  }\n  return;\n\n#if 0\n\n\tbrush_t\t\t*b;\n\tentity_t\t*e, *e2;\n\n\tbetween_brushes.next = selected_brushes.next;\n\tbetween_brushes.prev = selected_brushes.prev;\n\tbetween_brushes.next->prev = &between_brushes;\n\tbetween_brushes.prev->next = &between_brushes;\n\n\tbetween_entities.next = between_entities.prev = &between_entities;\n\tselected_brushes.next = selected_brushes.prev = &selected_brushes;\n\n\tfor (b=between_brushes.next ; b != &between_brushes ; b=b->next)\n\t{\n\t\te = b->owner;\n\t\tif (e == world_entity)\n\t\t\tb->owner = NULL;\n\t\telse\n\t\t{\n\t\t\tfor (e2=between_entities.next ; e2 != &between_entities ; e2=e2->next)\n\t\t\t\tif (e2 == e)\n\t\t\t\t\tgoto next;\t// allready got the entity\n\t\t\t// move the entity over\n\t\t\te->prev->next = e->next;\n\t\t\te->next->prev = e->prev;\n\t\t\te->next = between_entities.next;\n\t\t\te->prev = &between_entities;\n\t\t\te->next->prev = e;\n\t\t\te->prev->next = e;\n\t\t}\nnext: ;\n\t}\n#endif\n}\n\nvoid Map_RestoreBetween (void)\n{\n\tif (g_pParentWnd->ActiveXY() && g_bRestoreBetween)\n    g_pParentWnd->ActiveXY()->Paste();\n  return;\n\n#if 0  \n  entity_t\t*head, *tail;\n\tbrush_t\t\t*b;\n\n\tif (!between_brushes.next)\n\t\treturn;\n\n\tfor (b=between_brushes.next ; b != &between_brushes ; b=b->next)\n\t{\n\t\tif (!b->owner)\n\t\t{\n\t\t\tb->owner = world_entity;\n\t\t\tb->onext = world_entity->brushes.onext;\n\t\t\tb->oprev = &world_entity->brushes;\n\t\t\tb->onext->oprev = b;\n\t\t\tb->oprev->onext = b;\n\t\t}\n\t}\n\n\tselected_brushes.next = between_brushes.next;\n\tselected_brushes.prev = between_brushes.prev;\n\tselected_brushes.next->prev = &selected_brushes;\n\tselected_brushes.prev->next = &selected_brushes;\n\n\thead = between_entities.next;\n\ttail = between_entities.prev;\n\n\tif (head != tail)\n\t{\n\t\tentities.prev->next = head;\n\t\thead->prev = entities.prev;\n\t\ttail->next = &entities;\n\t\tentities.prev = tail;\n\t}\n\n\tbetween_brushes.next = NULL;\n\tbetween_entities.next = NULL;\n#endif\n}\n\n//============================================================================\n\nbool CheckForTinyBrush(brush_t* b, int n, float fSize)\n{\n  bool bTiny = false;\n\tfor (int i=0 ; i<3 ; i++)\n\t{\n    if (b->maxs[i] - b->mins[i] < fSize)\n      bTiny = true;\n  }\n  if (bTiny)\n    Sys_Printf(\"Possible problem brush (too small) #%i \", n);\n  return bTiny;\n}\n\nvoid Map_BuildBrushData(void)\n{\n\tbrush_t\t*b, *next;\n\n\tif (active_brushes.next == NULL)\n\t\treturn;\n\n\tSys_BeginWait ();\t// this could take a while\n\n  int n = 0;\n\tfor (b=active_brushes.next ; b != NULL && b != &active_brushes ; b=next)\n\t{\n\t\tnext = b->next;\n\t\tBrush_Build( b, true, false, false );\n\t\tif (!b->brush_faces || (g_PrefsDlg.m_bCleanTiny && CheckForTinyBrush(b, n++, g_PrefsDlg.m_fTinySize)))\n\t\t{\n\t\t\tBrush_Free (b);\n\t\t\tSys_Printf (\"Removed degenerate brush\\n\");\n\t\t}\n\t}\n\tSys_EndWait();\n}\n\nentity_t *Map_FindClass (char *cname)\n{\n\tentity_t\t*ent;\n\n\tfor (ent = entities.next ; ent != &entities ; ent=ent->next)\n\t{\n\t\tif (!strcmp(cname, ValueForKey (ent, \"classname\")))\n\t\t\treturn ent;\n\t}\n\treturn NULL;\n}\n\n/*\n================\nMap_Free\n================\n*/\nvoid Map_Free (void)\n{\n  g_bRestoreBetween = false;\n\tif (selected_brushes.next &&\n\t\t(selected_brushes.next != &selected_brushes) )\n\t{\n    if (MessageBox(g_qeglobals.d_hwndMain, \"Copy selection?\", \"\", MB_YESNO) == IDYES)\n\t\t  Map_SaveBetween ();\n\t}\n\n\tTexture_ClearInuse ();\n\tPointfile_Clear ();\n\tstrcpy (currentmap, \"unnamed.map\");\n\tSys_SetTitle (currentmap);\n\tg_qeglobals.d_num_entities = 0;\n\tg_qeglobals.d_numterrapoints = 0;\n\n\tif (!active_brushes.next)\n\t{\t// first map\n\t\tactive_brushes.prev = active_brushes.next = &active_brushes;\n\t\tselected_brushes.prev = selected_brushes.next = &selected_brushes;\n\t\tfiltered_brushes.prev = filtered_brushes.next = &filtered_brushes;\n\n\t\tentities.prev = entities.next = &entities;\n\t}\n\telse\n\t{\n\t\twhile (active_brushes.next != &active_brushes)\n\t\t\tBrush_Free (active_brushes.next);\n\t\twhile (selected_brushes.next != &selected_brushes)\n\t\t\tBrush_Free (selected_brushes.next);\n\t\twhile (filtered_brushes.next != &filtered_brushes)\n\t\t\tBrush_Free (filtered_brushes.next);\n\n\t\twhile (entities.next != &entities)\n\t\t\tEntity_Free (entities.next);\n\t}\n\n  if (world_entity)\n    Entity_Free(world_entity);\n\tworld_entity = NULL;\n}\n\nentity_t *AngledEntity()\n{\n  entity_t *ent = Map_FindClass (\"info_player_start\");\n\tif (!ent)\n  {\n\t\tent = Map_FindClass (\"info_player_deathmatch\");\n  }\n  if (!ent)\n  {\n\t\tent = Map_FindClass (\"info_player_deathmatch\");\n  }\n  if (!ent)\n  {\n    ent = Map_FindClass (\"team_CTF_redplayer\");\n  }\n  if (!ent)\n  {\n    ent = Map_FindClass (\"team_CTF_blueplayer\");\n  }\n  if (!ent)\n  {\n    ent = Map_FindClass (\"team_CTF_redspawn\");\n  }\n  if (!ent)\n  {\n    ent = Map_FindClass (\"team_CTF_bluespawn\");\n  }\n  return ent;\n}\n\n\n\n/*\n================\nMap_LoadFile\n================\n*/\nvoid Map_LoadFile (char *filename)\n{\n    char\t\t*buf;\n\tentity_t\t*ent;\n\tchar         temp[1024];\n\n\tSys_BeginWait ();\n\tSelect_Deselect();\n\t//SetInspectorMode(W_CONSOLE);\n\n\tQE_ConvertDOSToUnixName( temp, filename );\n\tSys_Printf (\"Map_LoadFile: %s\\n\", temp );\n\n\tMap_Free ();\n\t//++timo FIXME: maybe even easier to have Group_Init called from Map_Free?\n\tGroup_Init();\n\n\tg_qeglobals.d_parsed_brushes = 0;\n\tstrcpy (currentmap, filename);\n\n\tif (LoadFile (filename, (void **)&buf) != -1)\n\t{\n\n\t\tStartTokenParsing (buf);\n\t\tg_qeglobals.d_num_entities = 0;\n\n\t\t// Timo\n\t\t// will be used in Entity_Parse to detect if a conversion between brush formats is needed\n\t\tg_qeglobals.bNeedConvert = false;\n\t\tg_qeglobals.bOldBrushes = false;\n\t\tg_qeglobals.bPrimitBrushes = false;\n\n\t\twhile (1)\n\t\t{\n\t\t\tent = Entity_Parse (false, &active_brushes);\n\t\t\tif (!ent)\n\t\t\t\tbreak;\n\t\t\tif (!strcmp(ValueForKey (ent, \"classname\"), \"worldspawn\"))\n\t\t\t{\n\t\t\t\tif (world_entity)\n\t\t\t\t\tSys_Printf (\"WARNING: multiple worldspawn\\n\");\n\t\t\t\tworld_entity = ent;\n\t\t\t}\n\t\t\telse if (!strcmp(ValueForKey (ent, \"classname\"), \"group_info\"))\n      {\n        // it's a group thing!\n        Group_Add(ent);\n        Entity_Free(ent);\n      }\n      else\n\t\t\t{\n\t\t\t\t// add the entity to the end of the entity list\n\t\t\t\tent->next = &entities;\n\t\t\t\tent->prev = entities.prev;\n\t\t\t\tentities.prev->next = ent;\n\t\t\t\tentities.prev = ent;\n\t\t\t\tg_qeglobals.d_num_entities++;\n\t\t\t}\n\t\t}\n\t}\n\n  free (buf);\n\n\tif (!world_entity)\n\t{\n\t\tSys_Printf (\"No worldspawn in map.\\n\");\n\t\tMap_New ();\n\t\treturn;\n\t}\n\n    Sys_Printf (\"--- LoadMapFile ---\\n\");\n    Sys_Printf (\"%s\\n\", temp );\n\n    Sys_Printf (\"%5i brushes\\n\",  g_qeglobals.d_parsed_brushes );\n    Sys_Printf (\"%5i entities\\n\", g_qeglobals.d_num_entities);\n\n\tMap_RestoreBetween ();\n\n\tSys_Printf (\"Map_BuildAllDisplayLists\\n\");\n    Map_BuildBrushData();\n\n\t// reset the \"need conversion\" flag\n\t// conversion to the good format done in Map_BuildBrushData\n\tg_qeglobals.bNeedConvert=false;\n\n\t//\n\t// move the view to a start position\n\t//\n  ent = AngledEntity();\n\n  g_pParentWnd->GetCamera()->Camera().angles[PITCH] = 0;\n\tif (ent)\n\t{\n\t\tGetVectorForKey (ent, \"origin\", g_pParentWnd->GetCamera()->Camera().origin);\n\t\tGetVectorForKey (ent, \"origin\", g_pParentWnd->GetXYWnd()->GetOrigin());\n\t\tg_pParentWnd->GetCamera()->Camera().angles[YAW] = FloatForKey (ent, \"angle\");\n\t}\n\telse\n\t{\n\t\tg_pParentWnd->GetCamera()->Camera().angles[YAW] = 0;\n\t\tVectorCopy (vec3_origin, g_pParentWnd->GetCamera()->Camera().origin);\n\t\tVectorCopy (vec3_origin, g_pParentWnd->GetXYWnd()->GetOrigin());\n\t}\n\n\tMap_RegionOff ();\n\n\n\tmodified = false;\n\tSys_SetTitle (temp);\n\n\tTexture_ShowInuse ();\n\n\tSys_EndWait();\n\tSys_UpdateWindows (W_ALL);\n\n}\n\n/*\n===========\nMap_SaveFile\n===========\n*/\nvoid Map_SaveFile (char *filename, qboolean use_region )\n{\n\tentity_t\t*e, *next;\n\tFILE\t\t*f;\n\tchar         temp[1024];\n\tint\t\t\tcount;\n\n  if (filename == NULL || strlen(filename) == 0)\n  {\n    CFileDialog dlgSave(FALSE, \"map\", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, \"Map Files (*.map)|*.map||\", AfxGetMainWnd());\n    if (dlgSave.DoModal() == IDOK)\n      filename = strdup(dlgSave.m_ofn.lpstrFile);\n    else \n      return;\n  }\n\n\tPointfile_Clear ();\n\tQE_ConvertDOSToUnixName( temp, filename );\n\n\tif (!use_region)\n\t{\n\t\tchar\tbackup[1024];\n\n\t\t// rename current to .bak\n\t\tstrcpy (backup, filename);\n\t\tStripExtension (backup);\n\t\tstrcat (backup, \".bak\");\n\t\t_unlink (backup);\n\t\trename (filename, backup);\n\t}\n\n\tSys_Printf (\"Map_SaveFile: %s\\n\", filename);\n\n\tf = fopen(filename, \"w\");\n\n\tif (!f)\n\t{\n\t\tSys_Printf (\"ERROR!!!! Couldn't open %s\\n\", filename);\n\t\treturn;\n\t}\n\n\tif (use_region)\n  {\n\t\tAddRegionBrushes ();\n  }\n\n\t// write world entity first\n\tEntity_Write (world_entity, f, use_region);\n\n\t// then write all other ents\n\tcount = 1;\n\tfor (e=entities.next ; e != &entities ; e=next)\n\t{\n\t\tnext = e->next;\n\t\tif (e->brushes.onext == &e->brushes)\n    {\n\t\t\tEntity_Free (e);\t// no brushes left, so remove it\n    }\n\t\telse\n    {\n\t   \tfprintf (f, \"// entity %i\\n\", count);\n\t  \tcount++;\n\t\t\tEntity_Write (e, f, use_region);\n    }\n\t}\n\n\t// save the group info stuff\n\tGroup_Save(f);\n\n\tfclose (f);\n\n\tif (use_region)\n\t\tRemoveRegionBrushes ();\n\n\tSys_Printf (\"Saved.\\n\");\n\tmodified = false;\n\n\tif ( !strstr( temp, \"autosave\" ) )\n\t\tSys_SetTitle (temp);\n\n\tif (!use_region)\n\t{\n\t\ttime_t\ttimer;\n\t\tFILE\t*f;\n\n\t\ttime (&timer);\n\t\tMessageBeep (MB_ICONEXCLAMATION);\n\t\tf = fopen (\"c:/tstamps.log\", \"a\");\n\t\tif (f)\n\t\t{\n\t\t\tfprintf (f, \"%s\", filename);\n\t\t\t//fprintf (f, \"%4i : %35s : %s\", g_qeglobals.d_workcount, filename, ctime(&timer));\n\t\t\tfclose (f);\n\t\t\tg_qeglobals.d_workcount = 0;\n\t\t}\n\t\tfclose (f);\n\t\tSys_Status (\"Saved.\\n\", 0);\n\t}\n\t\n  //Curve_WriteFile (filename);\t\t//.trinity\n  //Patch_WriteFile (filename);\n}\n\n/*\n===========\nMap_New\n===========\n*/\nvoid Map_New (void)\n{\n\tSys_Printf (\"Map_New\\n\");\n\tMap_Free ();\n\n  Patch_Cleanup();\n\n\tworld_entity = (entity_s*)qmalloc(sizeof(*world_entity));\n\tworld_entity->brushes.onext = \n\t\tworld_entity->brushes.oprev = &world_entity->brushes;\n\tSetKeyValue (world_entity, \"classname\", \"worldspawn\");\n\tworld_entity->eclass = Eclass_ForName (\"worldspawn\", true);\n\n\tg_pParentWnd->GetCamera()->Camera().angles[YAW] = 0;\n\tg_pParentWnd->GetCamera()->Camera().angles[PITCH] = 0;\n\tVectorCopy (vec3_origin, g_pParentWnd->GetCamera()->Camera().origin);\n\tg_pParentWnd->GetCamera()->Camera().origin[2] = 48;\n\tVectorCopy (vec3_origin, g_pParentWnd->GetXYWnd()->GetOrigin());\n\n\tMap_RestoreBetween ();\n\n  Group_Init();\n\n\tSys_UpdateWindows (W_ALL);\n\tmodified = false;\n}\n\n/*\n===========================================================\n\n  REGION\n\n===========================================================\n*/\n\nqboolean\tregion_active;\nvec3_t\tregion_mins = {MIN_WORLD_COORD, MIN_WORLD_COORD, MIN_WORLD_COORD};\nvec3_t\tregion_maxs = {MAX_WORLD_COORD, MAX_WORLD_COORD, MAX_WORLD_COORD};\n\nbrush_t\t*region_sides[4];\n/*\n===========\nAddRegionBrushes\n\na regioned map will have temp walls put up at the region boundary\n===========\n*/\nvoid AddRegionBrushes (void)\n{\n\tvec3_t\tmins, maxs;\n\tint\t\ti;\n\ttexdef_t\ttd;\n\n\tif (!region_active)\n\t\treturn;\n\n\tmemset (&td, 0, sizeof(td));\n\t//strcpy (td.name, \"REGION\");\n\ttd.SetName(\"REGION\");\n\n\tmins[0] = region_mins[0] - 16;\n\tmaxs[0] = region_mins[0] + 1;\n\tmins[1] = region_mins[1] - 16;\n\tmaxs[1] = region_maxs[1] + 16;\n\tmins[2] = MIN_WORLD_COORD;\n\tmaxs[2] = MAX_WORLD_COORD;\n\tregion_sides[0] = Brush_Create (mins, maxs, &td);\n\n\tmins[0] = region_maxs[0] - 1;\n\tmaxs[0] = region_maxs[0] + 16;\n\tregion_sides[1] = Brush_Create (mins, maxs, &td);\n\n\tmins[0] = region_mins[0] - 16;\n\tmaxs[0] = region_maxs[0] + 16;\n\tmins[1] = region_mins[1] - 16;\n\tmaxs[1] = region_mins[1] + 1;\n\tregion_sides[2] = Brush_Create (mins, maxs, &td);\n\n\tmins[1] = region_maxs[1] - 1;\n\tmaxs[1] = region_maxs[1] + 16;\n\tregion_sides[3] = Brush_Create (mins, maxs, &td);\n\n\tfor (i=0 ; i<4 ; i++)\n\t{\n\t\tBrush_AddToList (region_sides[i], &selected_brushes);\n\t\tEntity_LinkBrush (world_entity, region_sides[i]);\n\t\tBrush_Build( region_sides[i] );\n\t}\n}\n\nvoid RemoveRegionBrushes (void)\n{\n\tint\t\ti;\n\n\tif (!region_active)\n\t\treturn;\n\tfor (i=0 ; i<4 ; i++)\n\t\tBrush_Free (region_sides[i]);\n}\n\n\nqboolean Map_IsBrushFiltered (brush_t *b)\n{\n\tint\t\ti;\n\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tif (b->mins[i] > region_maxs[i])\n\t\t\treturn true;\n\t\tif (b->maxs[i] < region_mins[i])\n\t\t\treturn true;\n\t}\n\treturn false;\n}\n\n/*\n===========\nMap_RegionOff\n\nOther filtering options may still be on\n===========\n*/\nvoid Map_RegionOff (void)\n{\n\tbrush_t\t*b, *next;\n\tint\t\t\ti;\n\n\tregion_active = false;\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tregion_maxs[i] = MAX_WORLD_COORD;//4096;\n\t\tregion_mins[i] = MIN_WORLD_COORD;//-4096;\n\t}\n\t\n\tfor (b=filtered_brushes.next ; b != &filtered_brushes ; b=next)\n\t{\n\t\tnext = b->next;\n\t\tif (Map_IsBrushFiltered (b))\n\t\t\tcontinue;\t\t// still filtered\n\t\tBrush_RemoveFromList (b);\n    if (active_brushes.next == NULL || active_brushes.prev == NULL)\n    {\n      active_brushes.next = &active_brushes;\n      active_brushes.prev = &active_brushes;\n    }\n\t\tBrush_AddToList (b, &active_brushes);\n\t}\n\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid Map_ApplyRegion (void)\n{\n\tbrush_t\t*b, *next;\n\n\tregion_active = true;\n\tfor (b=active_brushes.next ; b != &active_brushes ; b=next)\n\t{\n\t\tnext = b->next;\n\t\tif (!Map_IsBrushFiltered (b))\n\t\t\tcontinue;\t\t// still filtered\n\t\tBrush_RemoveFromList (b);\n\t\tBrush_AddToList (b, &filtered_brushes);\n\t}\n\n\tSys_UpdateWindows (W_ALL);\n}\n\n\n/*\n========================\nMap_RegionSelectedBrushes\n========================\n*/\nvoid Map_RegionSelectedBrushes (void)\n{\n\tMap_RegionOff ();\n\n\tif (selected_brushes.next == &selected_brushes)  // nothing selected\n  {\n    Sys_Printf(\"Tried to region with no selection...\\n\");\n    return;\n  }\n\tregion_active = true;\n\tSelect_GetBounds (region_mins, region_maxs);\n\n\t// move the entire active_brushes list to filtered_brushes\n\tfiltered_brushes.next = active_brushes.next;\n\tfiltered_brushes.prev = active_brushes.prev;\n\tfiltered_brushes.next->prev = &filtered_brushes;\n\tfiltered_brushes.prev->next = &filtered_brushes;\n\n\t// move the entire selected_brushes list to active_brushes\n\tactive_brushes.next = selected_brushes.next;\n\tactive_brushes.prev = selected_brushes.prev;\n\tactive_brushes.next->prev = &active_brushes;\n\tactive_brushes.prev->next = &active_brushes;\n\n\t// clear selected_brushes\n\tselected_brushes.next = selected_brushes.prev = &selected_brushes;\n\n\tSys_UpdateWindows (W_ALL);\n}\n\n\n/*\n===========\nMap_RegionXY\n===========\n*/\nvoid Map_RegionXY (void)\n{\n\tMap_RegionOff ();\n\n\tregion_mins[0] = g_pParentWnd->GetXYWnd()->GetOrigin()[0] - 0.5 * g_pParentWnd->GetXYWnd()->Width() / g_pParentWnd->GetXYWnd()->Scale();\n\tregion_maxs[0] = g_pParentWnd->GetXYWnd()->GetOrigin()[0] + 0.5 * g_pParentWnd->GetXYWnd()->Width() / g_pParentWnd->GetXYWnd()->Scale();\n\tregion_mins[1] = g_pParentWnd->GetXYWnd()->GetOrigin()[1] - 0.5 * g_pParentWnd->GetXYWnd()->Height() / g_pParentWnd->GetXYWnd()->Scale();\n\tregion_maxs[1] = g_pParentWnd->GetXYWnd()->GetOrigin()[1] + 0.5 * g_pParentWnd->GetXYWnd()->Height() / g_pParentWnd->GetXYWnd()->Scale();\n\tregion_mins[2] = -MIN_WORLD_COORD;\n\tregion_maxs[2] = MAX_WORLD_COORD;\n\tMap_ApplyRegion ();\n}\n\n/*\n===========\nMap_RegionTallBrush\n===========\n*/\nvoid Map_RegionTallBrush (void)\n{\n\tbrush_t\t*b;\n\n\tif (!QE_SingleBrush ())\n\t\treturn;\n\n\tb = selected_brushes.next;\n\n\tMap_RegionOff ();\n\n\tVectorCopy (b->mins, region_mins);\n\tVectorCopy (b->maxs, region_maxs);\n\tregion_mins[2] = MIN_WORLD_COORD;\n\tregion_maxs[2] = MAX_WORLD_COORD;\n\n\n\tSelect_Delete ();\n\tMap_ApplyRegion ();\n}\n/*\n===========\nMap_RegionBrush\n===========\n*/\nvoid Map_RegionBrush (void)\n{\n\tbrush_t\t*b;\n\n\tif (!QE_SingleBrush ())\n\t\treturn;\n\n\tb = selected_brushes.next;\n\n\tMap_RegionOff ();\n\n\tVectorCopy (b->mins, region_mins);\n\tVectorCopy (b->maxs, region_maxs);\n\n\tSelect_Delete ();\n\tMap_ApplyRegion ();\n}\n\n\n\nvoid UniqueTargetName(CString& rStr)\n{\n\t// make a unique target value\n\tint maxtarg = 0;\n\tfor (entity_t* e=entities.next ; e != &entities ; e=e->next)\n\t{\n\t\tchar* tn = ValueForKey (e, \"targetname\");\n\t\tif (tn && tn[0])\n\t\t{\n\t\t\tint targetnum = atoi(tn+1);\n\t\t\tif (targetnum > maxtarg)\n\t\t\t\tmaxtarg = targetnum;\n\t\t}\n    else\n    {\n\t\t  tn = ValueForKey (e, \"target\");\n\t\t  if (tn && tn[0])\n\t\t  {\n\t\t\t  int targetnum = atoi(tn+1);\n\t\t\t  if (targetnum > maxtarg)\n\t\t\t\t  maxtarg = targetnum;\n\t\t  }\n    }\n\t}\n  rStr.Format(\"t%i\", maxtarg+1);\n}\n\n//\n//================\n//Map_ImportFile\n// Timo 09/01/99 : called by CXYWnd::Paste & Map_ImportFile\n// if Map_ImportFile ( prefab ), the buffer may contain brushes in old format ( conversion needed )\n//================\n//\nvoid Map_ImportBuffer (char* buf)\n{\n\tentity_t* ent;\n\tbrush_t* b = NULL;\n\tCPtrArray ptrs;\n\n\tSelect_Deselect();\n\n\tUndo_Start(\"import buffer\");\n\n\tg_qeglobals.d_parsed_brushes = 0;\n\tif (buf)\n\t{\n\t\tCMapStringToString mapStr;\n\t\tStartTokenParsing (buf);\n\t\tg_qeglobals.d_num_entities = 0;\n\n\t\t// Timo\n\t\t// will be used in Entity_Parse to detect if a conversion between brush formats is needed\n\t\tg_qeglobals.bNeedConvert = false;\n\t\tg_qeglobals.bOldBrushes = false;\n\t\tg_qeglobals.bPrimitBrushes = false;\n\n\t\twhile (1)\n\t\t{\n\n\t\t\t// use the selected brushes list as it's handy\n\t\t\t//ent = Entity_Parse (false, &selected_brushes);\n\t\t\tent = Entity_Parse (false, &active_brushes);\n\t\t\tif (!ent)\n\t\t\t\tbreak;\n\t\t\t//end entity for undo\n\t\t\tUndo_EndEntity(ent);\n\t\t\t//end brushes for undo\n\t\t\tfor(b = ent->brushes.onext; b && b != &ent->brushes; b = b->onext)\n\t\t\t{\n\t\t\t\tUndo_EndBrush(b);\n\t\t\t}\n\n\t\t\tif (!strcmp(ValueForKey (ent, \"classname\"), \"worldspawn\"))\n\t\t\t{\n\t\t\t\t// world brushes need to be added to the current world entity\n\n\t\t\t\tb=ent->brushes.onext;\n\t\t\t\twhile (b && b != &ent->brushes)\n\t\t\t\t{\n\t\t\t\t\tbrush_t* bNext = b->onext;\n\t\t\t\t\tEntity_UnlinkBrush(b);\n\t\t\t\t\tEntity_LinkBrush(world_entity, b);\n\t\t\t\t\tptrs.Add(b);\n\t\t\t\t\tb = bNext;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t// the following bit remaps conflicting target/targetname key/value pairs\n\t\t\t\tCString str = ValueForKey(ent, \"target\");\n\t\t\t\tCString strKey;\n\t\t\t\tCString strTarget(\"\");\n\t\t\t\tif (str.GetLength() > 0)\n\t\t\t\t{\n\t\t\t\t\tif (FindEntity(\"target\", str.GetBuffer(0)))\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!mapStr.Lookup(str, strKey))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tUniqueTargetName(strKey);\n\t\t\t\t\t\t\tmapStr.SetAt(str, strKey);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstrTarget = strKey;\n\t\t\t\t\t\tSetKeyValue(ent, \"target\", strTarget.GetBuffer(0));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tstr = ValueForKey(ent, \"targetname\");\n\t\t\t\tif (str.GetLength() > 0)\n\t\t\t\t{\n\t\t\t\t\tif (FindEntity(\"targetname\", str.GetBuffer(0)))\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!mapStr.Lookup(str, strKey))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tUniqueTargetName(strKey);\n\t\t\t\t\t\t\tmapStr.SetAt(str, strKey);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tSetKeyValue(ent, \"targetname\", strKey.GetBuffer(0));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t//if (strTarget.GetLength() > 0)\n\t\t\t\t//  SetKeyValue(ent, \"target\", strTarget.GetBuffer(0));\n\n\t\t\t\t// add the entity to the end of the entity list\n\t\t\t\tent->next = &entities;\n\t\t\t\tent->prev = entities.prev;\n\t\t\t\tentities.prev->next = ent;\n\t\t\t\tentities.prev = ent;\n\t\t\t\tg_qeglobals.d_num_entities++;\n\n\t\t\t\tfor (b=ent->brushes.onext ; b != &ent->brushes ; b=b->onext)\n\t\t\t\t{\n\t\t\t\t\tptrs.Add(b);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t//::ShowWindow(g_qeglobals.d_hwndEntity, FALSE);\n\t//::LockWindowUpdate(g_qeglobals.d_hwndEntity);\n\tg_bScreenUpdates = false; \n\tfor (int i = 0; i < ptrs.GetSize(); i++)\n\t{\n\t\tBrush_Build(reinterpret_cast<brush_t*>(ptrs[i]), true, false);\n\t\tSelect_Brush(reinterpret_cast<brush_t*>(ptrs[i]), true, false);\n\t}\n\t//::LockWindowUpdate(NULL);\n\tg_bScreenUpdates = true; \n\n\tptrs.RemoveAll();\n\n\t// reset the \"need conversion\" flag\n\t// conversion to the good format done in Map_BuildBrushData\n\tg_qeglobals.bNeedConvert=false;\n\n\tSys_UpdateWindows (W_ALL);\n  //Sys_MarkMapModified();\n\tmodified = true;\n\n\tUndo_End();\n\n}\n\n\n//\n//================\n//Map_ImportFile\n//================\n//\nvoid Map_ImportFile (char *filename)\n{\n  char* buf;\n\tchar temp[1024];\n\tSys_BeginWait ();\n\tQE_ConvertDOSToUnixName( temp, filename );\n  if (LoadFile (filename, (void **)&buf) != -1)\n  {\n    Map_ImportBuffer(buf);\n    free(buf);\n    Map_BuildBrushData();\n  }\n\tSys_UpdateWindows (W_ALL);\n\tmodified = true;\n\tSys_EndWait();\n}\n\n//\n//===========\n//Map_SaveSelected\n//===========\n//\n// Saves selected world brushes and whole entities with partial/full selections\n//\nvoid Map_SaveSelected(char* pFilename)\n{\n\tentity_t\t*e, *next;\n\tFILE *f;\n\tchar temp[1024];\n\tint count;\n\n\tQE_ConvertDOSToUnixName(temp, pFilename);\n\tf = fopen(pFilename, \"w\");\n\n\tif (!f)\n\t{\n\t\tSys_Printf (\"ERROR!!!! Couldn't open %s\\n\", pFilename);\n\t\treturn;\n\t}\n\n\t// write world entity first\n\tEntity_WriteSelected(world_entity, f);\n\n\t// then write all other ents\n\tcount = 1;\n\tfor (e=entities.next ; e != &entities ; e=next)\n\t{\n  \tfprintf (f, \"// entity %i\\n\", count);\n   \tcount++;\n \t\tEntity_WriteSelected(e, f);\n\t\tnext = e->next;\n\t}\n\tfclose (f);\n}\n\n\n//\n//===========\n//Map_SaveSelected\n//===========\n//\n// Saves selected world brushes and whole entities with partial/full selections\n//\nvoid Map_SaveSelected(CMemFile* pMemFile, CMemFile* pPatchFile)\n{\n\tentity_t\t*e, *next;\n\tint count;\n\tCString strTemp;\n  \n\t// write world entity first\n\tEntity_WriteSelected(world_entity, pMemFile);\n\n\t// then write all other ents\n\tcount = 1;\n\tfor (e=entities.next ; e != &entities ; e=next)\n\t{\n\t\tMemFile_fprintf(pMemFile, \"// entity %i\\n\", count);\n\t\tcount++;\n \t\tEntity_WriteSelected(e, pMemFile);\n\t\tnext = e->next;\n\t}\n\n  //if (pPatchFile)\n  //  Patch_WriteFile(pPatchFile);\n}\n\n\nvoid MemFile_fprintf(CMemFile* pMemFile, const char* pText, ...)\n{\n  char Buffer[4096];\n  va_list args;\n\tva_start (args,pText);\n  vsprintf(Buffer, pText, args);\n  pMemFile->Write(Buffer, strlen(Buffer));\n}"
  },
  {
    "path": "q3radiant/MAP.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// map.h -- the state of the current world that all views are displaying\n\nextern\tchar\t\tcurrentmap[1024];\n\n// head/tail of doubly linked lists\nextern\tbrush_t\tactive_brushes;\t// brushes currently being displayed\nextern\tbrush_t\tselected_brushes;\t// highlighted\n\n\nextern CPtrArray& g_ptrSelectedFaces;\nextern CPtrArray& g_ptrSelectedFaceBrushes;\n//extern\tface_t\t*selected_face;\n//extern\tbrush_t\t*selected_face_brush;\nextern\tbrush_t\tfiltered_brushes;\t// brushes that have been filtered or regioned\n\nextern\tentity_t\tentities;\nextern\tentity_t\t*world_entity;\t// the world entity is NOT included in\n\t\t\t\t\t\t\t\t\t// the entities chain\n\nextern\tqboolean\tmodified;\t\t// for quit confirmations\n\nextern\tvec3_t\tregion_mins, region_maxs;\nextern\tqboolean\tregion_active;\n\nvoid \tMap_LoadFile (char *filename);\nvoid \tMap_SaveFile (char *filename, qboolean use_region);\nvoid\tMap_New (void);\nvoid\tMap_BuildBrushData(void);\n\nvoid\tMap_RegionOff (void);\nvoid\tMap_RegionXY (void);\nvoid\tMap_RegionTallBrush (void);\nvoid\tMap_RegionBrush (void);\nvoid\tMap_RegionSelectedBrushes (void);\nqboolean Map_IsBrushFiltered (brush_t *b);\n\nvoid Map_SaveSelected(CMemFile* pMemFile, CMemFile* pPatchFile = NULL);\nvoid Map_ImportBuffer (char* buf);\n"
  },
  {
    "path": "q3radiant/MATHLIB.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// mathlib.c -- math primitives\n\n#include \"stdafx.h\"\n#include \"cmdlib.h\"\n#include \"mathlib.h\"\n\nvec3_t vec3_origin = {0.0f,0.0f,0.0f};\n\n\nfloat VectorLength(vec3_t v)\n{\n\tint\t\ti;\n\tfloat\tlength;\n\t\n\tlength = 0.0f;\n\tfor (i=0 ; i< 3 ; i++)\n\t\tlength += v[i]*v[i];\n\tlength = (float)sqrt (length);\n\n\treturn length;\n}\n\nqboolean VectorCompare (vec3_t v1, vec3_t v2)\n{\n\tint\t\ti;\n\t\n\tfor (i=0 ; i<3 ; i++)\n\t\tif (fabs(v1[i]-v2[i]) > EQUAL_EPSILON)\n\t\t\treturn false;\n\t\t\t\n\treturn true;\n}\n\nvec_t Q_rint (vec_t in)\n{\n  if (g_PrefsDlg.m_bNoClamp)\n    return in;\n  else\n\t  return (float)floor (in + 0.5);\n}\n\nvoid VectorMA (vec3_t va, float scale, vec3_t vb, vec3_t vc)\n{\n\tvc[0] = va[0] + scale*vb[0];\n\tvc[1] = va[1] + scale*vb[1];\n\tvc[2] = va[2] + scale*vb[2];\n}\n\nvoid CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross)\n{\n\tcross[0] = v1[1]*v2[2] - v1[2]*v2[1];\n\tcross[1] = v1[2]*v2[0] - v1[0]*v2[2];\n\tcross[2] = v1[0]*v2[1] - v1[1]*v2[0];\n}\n\nvec_t _DotProduct (vec3_t v1, vec3_t v2)\n{\n\treturn v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];\n}\n\nvoid _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out)\n{\n\tout[0] = va[0]-vb[0];\n\tout[1] = va[1]-vb[1];\n\tout[2] = va[2]-vb[2];\n}\n\nvoid _VectorAdd (vec3_t va, vec3_t vb, vec3_t out)\n{\n\tout[0] = va[0]+vb[0];\n\tout[1] = va[1]+vb[1];\n\tout[2] = va[2]+vb[2];\n}\n\nvoid _VectorCopy (vec3_t in, vec3_t out)\n{\n\tout[0] = in[0];\n\tout[1] = in[1];\n\tout[2] = in[2];\n}\n\nvec_t VectorNormalize (vec3_t v)\n{\n\tint\t\ti;\n\tfloat\tlength;\n\t\n\tlength = 0.0f;\n\tfor (i=0 ; i< 3 ; i++)\n\t\tlength += v[i]*v[i];\n\tlength = (float)sqrt (length);\n\tif (length == 0)\n\t\treturn (vec_t)0;\n\t\t\n\tfor (i=0 ; i< 3 ; i++)\n\t\tv[i] /= length;\t\n\n\treturn length;\n}\n\nvoid VectorInverse (vec3_t v)\n{\n\tv[0] = -v[0];\n\tv[1] = -v[1];\n\tv[2] = -v[2];\n}\n\nvoid VectorScale (vec3_t v, vec_t scale, vec3_t out)\n{\n\tout[0] = v[0] * scale;\n\tout[1] = v[1] * scale;\n\tout[2] = v[2] * scale;\n}\n\n\nvoid VectorRotate (vec3_t vIn, vec3_t vRotation, vec3_t out)\n{\n  vec3_t vWork, va;\n  VectorCopy(vIn, va);\n  VectorCopy(va, vWork);\n  int nIndex[3][2];\n  nIndex[0][0] = 1; nIndex[0][1] = 2;\n  nIndex[1][0] = 2; nIndex[1][1] = 0;\n  nIndex[2][0] = 0; nIndex[2][1] = 1;\n\n  for (int i = 0; i < 3; i++)\n  {\n    if (vRotation[i] != 0)\n    {\n      double dAngle = vRotation[i] * Q_PI / 180.0;\n\t  double c = cos(dAngle);\n      double s = sin(dAngle);\n      vWork[nIndex[i][0]] = va[nIndex[i][0]] * c - va[nIndex[i][1]] * s;\n      vWork[nIndex[i][1]] = va[nIndex[i][0]] * s + va[nIndex[i][1]] * c;\n    }\n    VectorCopy(vWork, va);\n  }\n  VectorCopy(vWork, out);\n}\n\nvoid VectorRotate (vec3_t vIn, vec3_t vRotation, vec3_t vOrigin, vec3_t out)\n{\n  vec3_t vTemp, vTemp2;\n  VectorSubtract(vIn, vOrigin, vTemp);\n  VectorRotate(vTemp, vRotation, vTemp2);\n  VectorAdd(vTemp2, vOrigin, out);\n}\n\nvoid VectorPolar(vec3_t v, float radius, float theta, float phi)\n{\n \tv[0]=float(radius * cos(theta) * cos(phi));\n\tv[1]=float(radius * sin(theta) * cos(phi));\n\tv[2]=float(radius * sin(phi));\n}\n\nvoid VectorSnap(vec3_t v)\n{\n  for (int i = 0; i < 3; i++)\n  {\n    v[i] = floor (v[i] + 0.5);\n  }\n}\n\n\nvoid _Vector5Add (vec5_t va, vec5_t vb, vec5_t out)\n{\n\tout[0] = va[0]+vb[0];\n\tout[1] = va[1]+vb[1];\n\tout[2] = va[2]+vb[2];\n\tout[3] = va[3]+vb[3];\n\tout[4] = va[4]+vb[4];\n}\n\nvoid _Vector5Scale (vec5_t v, vec_t scale, vec5_t out)\n{\n\tout[0] = v[0] * scale;\n\tout[1] = v[1] * scale;\n\tout[2] = v[2] * scale;\n\tout[3] = v[3] * scale;\n\tout[4] = v[4] * scale;\n}\n\nvoid _Vector53Copy (vec5_t in, vec3_t out)\n{\n\tout[0] = in[0];\n\tout[1] = in[1];\n\tout[2] = in[2];\n}\n\n// NOTE: added these from Ritual's Q3Radiant\nvoid ClearBounds (vec3_t mins, vec3_t maxs)\n{\n\tmins[0] = mins[1] = mins[2] = 99999;\n\tmaxs[0] = maxs[1] = maxs[2] = -99999;\n}\n\nvoid AddPointToBounds (vec3_t v, vec3_t mins, vec3_t maxs)\n{\n\tint\t\ti;\n\tvec_t\tval;\n\t\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tval = v[i];\n\t\tif (val < mins[i])\n\t\t\tmins[i] = val;\n\t\tif (val > maxs[i])\n\t\t\tmaxs[i] = val;\n\t}\n}\n\n#define\tPITCH\t\t\t\t0\t\t// up / down\n#define\tYAW\t\t\t\t\t1\t\t// left / right\n#define\tROLL\t\t\t\t2\t\t// fall over\n#ifndef M_PI\n#define M_PI\t\t3.14159265358979323846\t// matches value in gcc v2 math.h\n#endif\n\nvoid AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)\n{\n\tfloat\t\tangle;\n\tstatic float\t\tsr, sp, sy, cr, cp, cy;\n\t// static to help MS compiler fp bugs\n\t\n\tangle = angles[YAW] * (M_PI*2 / 360);\n\tsy = sin(angle);\n\tcy = cos(angle);\n\tangle = angles[PITCH] * (M_PI*2 / 360);\n\tsp = sin(angle);\n\tcp = cos(angle);\n\tangle = angles[ROLL] * (M_PI*2 / 360);\n\tsr = sin(angle);\n\tcr = cos(angle);\n\t\n\tif (forward)\n\t{\n\t\tforward[0] = cp*cy;\n\t\tforward[1] = cp*sy;\n\t\tforward[2] = -sp;\n\t}\n\tif (right)\n\t{\n\t\tright[0] = -sr*sp*cy+cr*sy;\n\t\tright[1] = -sr*sp*sy-cr*cy;\n\t\tright[2] = -sr*cp;\n\t}\n\tif (up)\n\t{\n\t\tup[0] = cr*sp*cy+sr*sy;\n\t\tup[1] = cr*sp*sy-sr*cy;\n\t\tup[2] = cr*cp;\n\t}\n}\n\nvoid VectorToAngles( vec3_t vec, vec3_t angles )\n{\n\tfloat forward;\n\tfloat yaw, pitch;\n\t\n\tif ( ( vec[ 0 ] == 0 ) && ( vec[ 1 ] == 0 ) )\n\t{\n\t\tyaw = 0;\n\t\tif ( vec[ 2 ] > 0 )\n\t\t{\n\t\t\tpitch = 90;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tpitch = 270;\n\t\t}\n\t}\n\telse\n\t{\n\t\tyaw = atan2( vec[ 1 ], vec[ 0 ] ) * 180 / M_PI;\n\t\tif ( yaw < 0 )\n\t\t{\n\t\t\tyaw += 360;\n\t\t}\n\t\t\n\t\tforward = ( float )sqrt( vec[ 0 ] * vec[ 0 ] + vec[ 1 ] * vec[ 1 ] );\n\t\tpitch = atan2( vec[ 2 ], forward ) * 180 / M_PI;\n\t\tif ( pitch < 0 )\n\t\t{\n\t\t\tpitch += 360;\n\t\t}\n\t}\n\t\n\tangles[ 0 ] = pitch;\n\tangles[ 1 ] = yaw;\n\tangles[ 2 ] = 0;\n}\n"
  },
  {
    "path": "q3radiant/MATHLIB.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __MATHLIB__\n#define __MATHLIB__\n\n// mathlib.h\n\n#include <math.h>\n\ntypedef float vec_t;\ntypedef vec_t vec3_t[3];\ntypedef vec_t vec5_t[5];\n\n#define\tSIDE_FRONT\t\t0\n#define\tSIDE_ON\t\t\t2\n#define\tSIDE_BACK\t\t1\n#define\tSIDE_CROSS\t\t-2\n\n#define\tQ_PI\t3.14159265358979323846\n\nextern vec3_t vec3_origin;\n\n#define\tEQUAL_EPSILON\t0.001\n\nqboolean VectorCompare (vec3_t v1, vec3_t v2);\n\n#define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])\n#define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];}\n#define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];}\n#define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];}\n#define VectorSet(v, a, b, c) {v[0]=a;v[1]=b;v[2]=c;}\n\nvec_t Q_rint (vec_t in);\nvec_t _DotProduct (vec3_t v1, vec3_t v2);\nvoid _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out);\nvoid _VectorAdd (vec3_t va, vec3_t vb, vec3_t out);\nvoid _VectorCopy (vec3_t in, vec3_t out);\n\nfloat VectorLength(vec3_t v);\n\nvoid VectorMA (vec3_t va, float scale, vec3_t vb, vec3_t vc);\n\nvoid CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross);\nvec_t VectorNormalize (vec3_t v);\nvoid VectorInverse (vec3_t v);\nvoid VectorScale (vec3_t v, vec_t scale, vec3_t out);\nvoid VectorPolar(vec3_t v, float radius, float theta, float phi);\nvoid VectorSnap(vec3_t v);\n\nvoid _Vector53Copy (vec5_t in, vec3_t out);\nvoid _Vector5Scale (vec5_t v, vec_t scale, vec5_t out);\nvoid _Vector5Add (vec5_t va, vec5_t vb, vec5_t out);\n\n// NOTE: added these from Ritual's Q3Radiant\nvoid ClearBounds (vec3_t mins, vec3_t maxs);\nvoid AddPointToBounds (vec3_t v, vec3_t mins, vec3_t maxs);\n\nvoid AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);\nvoid VectorToAngles( vec3_t vec, vec3_t angles );\n#define VectorClear(x) {x[0] = x[1] = x[2] = 0;}\n\n#define ZERO_EPSILON 1.0E-6\n#define RAD2DEG( a ) ( ( (a) * 180.0f ) / Q_PI )\n#define DEG2RAD( a ) ( ( (a) * Q_PI ) / 180.0f )\n\n\n#endif\n"
  },
  {
    "path": "q3radiant/MRU.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//*************************************************************\n//  File name: mru.c\n//\n//  Description:\n//\n//      Routines for MRU support\n//\n//  Development Team:\n//\n//      Gilles Vollant (100144.2636@compuserve.com) \n//\n//*************************************************************\n\n#include \"stdafx.h\"\n#include <windows.h>\n#include <windowsx.h>\n#include <string.h>\n\n#include \"mru.h\"\n// CreateMruMenu  : MRUMENU constructor\n// wNbLruShowInit : nb of item showed in menu\n// wNbLruMenuInit : nb of item stored in memory\n// wMaxSizeLruItemInit : size max. of filename\n\n\n//*************************************************************\n//\n//  CreateMruMenu()\n//\n//  Purpose:\n//\n//              Allocate and Initialize an MRU and return a pointer on it\n//\n//\n//  Parameters:\n//\n//      WORD wNbLruShowInit -      Maximum number of item displayed on menu\n//      WORD wNbLruMenuInit -      Maximum number of item stored in memory\n//      WORD wMaxSizeLruItemInit - Maximum size of an item (ie size of pathname)\n//      WORD wIdMruInit -          ID of the first item in the menu (default:IDMRU)\n//\n//\n//  Return: (LPMRUMENU)\n//\n//      Pointer on a MRUMENU structure, used by other function\n//\n//\n//  Comments:\n//      wNbLruShowInit <= wNbLruMenuInit\n//\n//\n//  History:    Date       Author       Comment\n//              09/24/94   G. Vollant   Created\n//\n//*************************************************************\n\nLPMRUMENU CreateMruMenu (WORD wNbLruShowInit,\n            WORD wNbLruMenuInit,WORD wMaxSizeLruItemInit,WORD wIdMruInit)\n{\nLPMRUMENU lpMruMenu;\n  lpMruMenu = (LPMRUMENU)GlobalAllocPtr(GHND,sizeof(MRUMENU));\n\n  lpMruMenu->wNbItemFill = 0;                   \n  lpMruMenu->wNbLruMenu = wNbLruMenuInit;             \n  lpMruMenu->wNbLruShow = wNbLruShowInit;\n  lpMruMenu->wIdMru = wIdMruInit;\n  lpMruMenu->wMaxSizeLruItem = wMaxSizeLruItemInit;\n  lpMruMenu->lpMRU = (LPSTR)GlobalAllocPtr(GHND,\n                      lpMruMenu->wNbLruMenu*(UINT)lpMruMenu->wMaxSizeLruItem);\n  if (lpMruMenu->lpMRU == NULL)\n     {\n       GlobalFreePtr(lpMruMenu);\n       lpMruMenu =  NULL;\n     }\n  return lpMruMenu;\n}\n\n//*************************************************************\n//\n//  CreateMruMenuDefault()\n//\n//  Purpose:\n//\n//              Allocate and Initialize an MRU and return a pointer on it\n//              Use default parameter\n//\n//\n//  Parameters:\n//\n//\n//  Return: (LPMRUMENU)\n//\n//      Pointer on a MRUMENU structure, used by other function\n//\n//\n//  Comments:\n//\n//\n//  History:    Date       Author       Comment\n//              09/24/94   G. Vollant   Created\n//\n//*************************************************************\n\nLPMRUMENU CreateMruMenuDefault()\n{\n  return CreateMruMenu (NBMRUMENUSHOW,NBMRUMENU,MAXSIZEMRUITEM,IDMRU);\n}\n\n\n//*************************************************************\n//\n//  DeleteMruMenu()\n//\n//  Purpose:\n//              Destructor :\n//              Clean and free a MRUMENU structure\n//\n//  Parameters:\n//\n//      LPMRUMENU lpMruMenu -      pointer on MRUMENU, allocated\n//             by CreateMruMenu() or CreateMruMenuDefault()\n//\n//\n//  Return: void\n//\n//\n//  Comments:\n//\n//\n//  History:    Date       Author       Comment\n//              09/24/94   G. Vollant   Created\n//\n//*************************************************************\nvoid DeleteMruMenu(LPMRUMENU lpMruMenu)\n{\n  GlobalFreePtr(lpMruMenu->lpMRU);\n  GlobalFreePtr(lpMruMenu);\n}\n\n//*************************************************************\n//\n//  SetNbLruShow()\n//\n//  Purpose:\n//              Change the maximum number of item displayed on menu\n//\n//  Parameters:\n//      LPMRUMENU lpMruMenu -      pointer on MRUMENU\n//      WORD wNbLruShowInit -      Maximum number of item displayed on menu\n//\n//\n//  Return: void\n//\n//\n//  Comments:\n//\n//\n//  History:    Date       Author       Comment\n//              09/24/94   G. Vollant   Created\n//\n//*************************************************************\nvoid SetNbLruShow   (LPMRUMENU lpMruMenu,WORD wNbLruShowInit)\n{\n  lpMruMenu->wNbLruShow = min(wNbLruShowInit,lpMruMenu->wNbLruMenu);\n}\n\n//*************************************************************\n//\n//  SetMenuItem()\n//\n//  Purpose:\n//              Set the filename of an item \n//\n//  Parameters:\n//      LPMRUMENU lpMruMenu -      pointer on MRUMENU\n//      WORD wItem -               Number of Item to set, zero based\n//      LPSTR lpItem -             String, contain the filename of the item\n//\n//\n//  Return: (BOOL)\n//      TRUE  - Function run successfully\n//      FALSE - Function don't run successfully\n//\n//\n//  Comments:\n//      used when load .INI or reg database\n//\n//  History:    Date       Author       Comment\n//              09/24/94   G. Vollant   Created\n//\n//*************************************************************\nBOOL SetMenuItem    (LPMRUMENU lpMruMenu,WORD wItem,LPSTR lpItem)\n{                                      \n  if (wItem >= NBMRUMENU) \n    return FALSE;\n  _fstrncpy((lpMruMenu->lpMRU) + \n            ((lpMruMenu->wMaxSizeLruItem) * (UINT)wItem),\n            lpItem,lpMruMenu->wMaxSizeLruItem-1);\n  lpMruMenu->wNbItemFill = max(lpMruMenu->wNbItemFill,wItem+1);\n  return TRUE;\n}\n\n//*************************************************************\n//\n//  GetMenuItem()\n//\n//  Purpose:\n//              Get the filename of an item \n//\n//  Parameters:\n//      LPMRUMENU lpMruMenu -      pointer on MRUMENU\n//      WORD wItem -               Number of Item to set, zero based\n//      BOOL fIDMBased -           TRUE :  wItem is based on ID menu item\n//                                 FALSE : wItem is zero-based\n//      LPSTR lpItem -             String where the filename of the item will be\n//                                   stored by GetMenuItem()\n//      UINT  uiSize -             Size of the lpItem buffer\n//\n//\n//  Return: (BOOL)\n//      TRUE  - Function run successfully\n//      FALSE - Function don't run successfully\n//\n//\n//  Comments:\n//      Used for saving in .INI or reg database, or when user select\n//        an MRU in File menu\n//\n//  History:    Date       Author       Comment\n//              09/24/94   G. Vollant   Created\n//\n//*************************************************************\nBOOL GetMenuItem    (LPMRUMENU lpMruMenu,WORD wItem,\n                     BOOL fIDMBased,LPSTR lpItem,UINT uiSize)\n{\n  if (fIDMBased) \n    wItem -= (lpMruMenu->wIdMru + 1);\n  if (wItem >= lpMruMenu->wNbItemFill) \n    return FALSE;\n  _fstrncpy(lpItem,(lpMruMenu->lpMRU) + \n                ((lpMruMenu->wMaxSizeLruItem) * (UINT)(wItem)),uiSize);\n  *(lpItem+uiSize-1) = '\\0';\n  return TRUE;\n}\n\n//*************************************************************\n//\n//  AddNewItem()\n//\n//  Purpose:\n//              Add an item at the begin of the list\n//\n//  Parameters:\n//      LPMRUMENU lpMruMenu -      pointer on MRUMENU\n//      LPSTR lpItem -             String contain the filename to add\n//\n//  Return: (BOOL)\n//      TRUE  - Function run successfully\n//      FALSE - Function don't run successfully\n//\n//\n//  Comments:\n//      Used when used open a file (using File Open common\n//        dialog, Drag and drop or MRU)\n//\n//  History:    Date       Author       Comment\n//              09/24/94   G. Vollant   Created\n//\n//*************************************************************\nvoid AddNewItem     (LPMRUMENU lpMruMenu,LPSTR lpItem)\n{\nWORD i,j;\n  for (i=0;i<lpMruMenu->wNbItemFill;i++)\n    if (lstrcmpi(lpItem,(lpMruMenu->lpMRU) + \n        ((lpMruMenu->wMaxSizeLruItem) * (UINT)i)) == 0)\n      {         \n        // Shift the other items\n        for (j=i;j>0;j--)\n         lstrcpy((lpMruMenu->lpMRU) + (lpMruMenu->wMaxSizeLruItem * (UINT)j),\n                 (lpMruMenu->lpMRU) + (lpMruMenu->wMaxSizeLruItem * (UINT)(j-1)));\n        _fstrncpy(lpMruMenu->lpMRU,lpItem,lpMruMenu->wMaxSizeLruItem-1);  \n        return ;\n      }\n  lpMruMenu->wNbItemFill = min(lpMruMenu->wNbItemFill+1,lpMruMenu->wNbLruMenu);\n  for (i=lpMruMenu->wNbItemFill-1;i>0;i--)\n     lstrcpy(lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem * (UINT)i),\n             lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem * (UINT)(i-1)));\n  _fstrncpy(lpMruMenu->lpMRU,lpItem,lpMruMenu->wMaxSizeLruItem-1);  \n}\n\n//*************************************************************\n//\n//  DelMenuItem()\n//\n//  Purpose:\n//              Delete an item\n//\n//  Parameters:\n//      LPMRUMENU lpMruMenu -      pointer on MRUMENU\n//      WORD wItem -               Number of Item to set, zero based\n//      BOOL fIDMBased -           TRUE :  wItem is based on ID menu item\n//                                 FALSE : wItem is zero-based\n//\n//  Return: (BOOL)\n//      TRUE  - Function run successfully\n//      FALSE - Function don't run successfully\n//\n//\n//  Comments:\n//      Used when used open a file, using MRU, and when an error\n//         occured (by example, when file was deleted)\n//\n//  History:    Date       Author       Comment\n//              09/24/94   G. Vollant   Created\n//\n//*************************************************************\nBOOL DelMenuItem(LPMRUMENU lpMruMenu,WORD wItem,BOOL fIDMBased)\n{ \nWORD i;\n  if (fIDMBased) \n    wItem -= (lpMruMenu->wIdMru + 1);\n  if (lpMruMenu->wNbItemFill <= wItem) \n    return FALSE;\n  lpMruMenu->wNbItemFill--;\n  for (i=wItem;i<lpMruMenu->wNbItemFill;i++)\n     lstrcpy(lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem * (UINT)i),\n             lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem * (UINT)(i+1)));\n  return TRUE;\n}\n                           \n//*************************************************************\n//\n//  PlaceMenuMRUItem()\n//\n//  Purpose:\n//              Add MRU at the end of a menu\n//\n//  Parameters:\n//      LPMRUMENU lpMruMenu -      pointer on MRUMENU\n//      HMENU hMenu -              Handle of menu where MRU must be added\n//      UINT uiItem -              Item of menu entry where MRU must be added\n//\n//  Return: void\n//\n//\n//  Comments:\n//      Used MRU is modified, for refresh the File menu\n//\n//  History:    Date       Author       Comment\n//              09/24/94   G. Vollant   Created\n//\n//*************************************************************\nvoid PlaceMenuMRUItem(LPMRUMENU lpMruMenu,HMENU hMenu,UINT uiItem)\n{\nint  i;   \nWORD wNbShow;\n  if (hMenu == NULL) \n    return;\n  // remove old MRU in menu\n  for (i=0;i<=(int)(lpMruMenu->wNbLruMenu);i++)\n    RemoveMenu(hMenu,i+lpMruMenu->wIdMru,MF_BYCOMMAND);\n\n  if (lpMruMenu->wNbItemFill == 0) \n    return;\n\n  // If they are item, insert a separator before the files\n  InsertMenu(hMenu,uiItem,MF_SEPARATOR,lpMruMenu->wIdMru,NULL);\n\n  wNbShow = min(lpMruMenu->wNbItemFill,lpMruMenu->wNbLruShow);\n  for (i=(int)wNbShow-1;i>=0;i--)\n  {\n  LPSTR lpTxt;\n    if (lpTxt = (LPSTR)GlobalAllocPtr(GHND,lpMruMenu->wMaxSizeLruItem + 20))\n      {\n        wsprintf(lpTxt,\"&%lu %s\",\n                 (DWORD)(i+1),lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem*(UINT)i));\n        InsertMenu(hMenu,(((WORD)i)!=(wNbShow-1)) ? (lpMruMenu->wIdMru+i+2) : lpMruMenu->wIdMru,\n                   MF_STRING,lpMruMenu->wIdMru+i+1,lpTxt);   \n        GlobalFreePtr(lpTxt);\n      }\n  }\n\n}\n\n///////////////////////////////////////////\n\n\n\n//*************************************************************\n//\n//  SaveMruInIni()\n//\n//  Purpose:\n//              Save MRU in a private .INI\n//\n//  Parameters:\n//      LPMRUMENU lpMruMenu -      pointer on MRUMENU\n//      LPSTR lpszSection  -       Points to a null-terminated string containing\n//                                      the name of the section \n//      LPSTR lpszFile -           Points to a null-terminated string that names \n//                                      the initialization file. \n//\n//  Return: (BOOL)\n//      TRUE  - Function run successfully\n//      FALSE - Function don't run successfully\n//\n//\n//  Comments:\n//      See WritePrivateProfileString API for more info on lpszSection and lpszFile\n//\n//  History:    Date       Author       Comment\n//              09/24/94   G. Vollant   Created\n//\n//*************************************************************\nBOOL SaveMruInIni(LPMRUMENU lpMruMenu,LPSTR lpszSection,LPSTR lpszFile)\n{\nLPSTR lpTxt;\nWORD i;\n\n  lpTxt = (LPSTR)GlobalAllocPtr(GHND,lpMruMenu->wMaxSizeLruItem + 20);\n  if (lpTxt == NULL) \n    return FALSE;\n\n  for (i=0;i<lpMruMenu->wNbLruMenu;i++)\n    {\n    char szEntry[16];\n      wsprintf(szEntry,\"File%lu\",(DWORD)i+1);\n      if (!GetMenuItem(lpMruMenu,i,FALSE,lpTxt,lpMruMenu->wMaxSizeLruItem + 10))\n        *lpTxt = '\\0';\n      WritePrivateProfileString(lpszSection,szEntry,lpTxt,lpszFile);\n    }\n  GlobalFreePtr(lpTxt);\n  WritePrivateProfileString(NULL,NULL,NULL,lpszFile); // flush cache \n  return TRUE;\n}\n\n\n//*************************************************************\n//\n//  LoadMruInIni()\n//\n//  Purpose:\n//              Load MRU from a private .INI\n//\n//  Parameters:\n//      LPMRUMENU lpMruMenu -      pointer on MRUMENU\n//      LPSTR lpszSection  -       Points to a null-terminated string containing\n//                                      the name of the section \n//      LPSTR lpszFile -           Points to a null-terminated string that names \n//                                      the initialization file. \n//\n//  Return: (BOOL)\n//      TRUE  - Function run successfully\n//      FALSE - Function don't run successfully\n//\n//\n//  Comments:\n//      See GetPrivateProfileString API for more info on lpszSection and lpszFile\n//\n//  History:    Date       Author       Comment\n//              09/24/94   G. Vollant   Created\n//\n//*************************************************************\nBOOL LoadMruInIni(LPMRUMENU lpMruMenu,LPSTR lpszSection,LPSTR lpszFile)\n{\nLPSTR lpTxt;\nWORD i;\n  lpTxt = (LPSTR)GlobalAllocPtr(GHND,lpMruMenu->wMaxSizeLruItem + 20);\n  if (lpTxt == NULL) \n    return FALSE;\n\n  for (i=0;i<lpMruMenu->wNbLruMenu;i++)\n    {\n    char szEntry[16];\n      \n      wsprintf(szEntry,\"File%lu\",(DWORD)i+1);\n      GetPrivateProfileString(lpszSection,szEntry,\"\",lpTxt,\n                              lpMruMenu->wMaxSizeLruItem + 10,lpszFile);\n      if (*lpTxt == '\\0')\n        break;\n      SetMenuItem(lpMruMenu,i,lpTxt);\n    }\n  GlobalFreePtr(lpTxt);\n  return TRUE;\n}\n\n#ifdef WIN32\n\nBOOL IsWin395OrHigher(void)\n{\n  WORD wVer;\n\n  wVer = LOWORD(GetVersion());\n  wVer = (((WORD)LOBYTE(wVer)) << 8) | (WORD)HIBYTE(wVer);\n\n  return (wVer >= 0x035F);              // 5F = 95 dec\n}\n\n\n//*************************************************************\n//\n//  SaveMruInReg()\n//\n//  Purpose:\n//              Save MRU in the registry\n//\n//  Parameters:\n//      LPMRUMENU lpMruMenu -      pointer on MRUMENU\n//      LPSTR lpszKey  -           Points to a null-terminated string \n//                                      specifying  the name of a key that \n//                                      this function opens or creates.\n//\n//  Return: (BOOL)\n//      TRUE  - Function run successfully\n//      FALSE - Function don't run successfully\n//\n//\n//  Comments:\n//      Win32 function designed for Windows NT and Windows 95\n//      See RegCreateKeyEx API for more info on lpszKey\n//\n//  History:    Date       Author       Comment\n//              09/24/94   G. Vollant   Created\n//\n//*************************************************************\nBOOL SaveMruInReg(LPMRUMENU lpMruMenu,LPSTR lpszKey)\n{\nLPSTR lpTxt;\nWORD i;\nHKEY hCurKey;\nDWORD dwDisp;\n\n  lpTxt = (LPSTR)GlobalAllocPtr(GHND,lpMruMenu->wMaxSizeLruItem + 20);\n  if (lpTxt == NULL) \n    return FALSE;\n\n  RegCreateKeyEx(HKEY_CURRENT_USER,lpszKey,0,NULL,\n                  REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hCurKey,&dwDisp);\n\n  for (i=0;i<lpMruMenu->wNbLruMenu;i++)\n    {\n    char szEntry[16];\n      wsprintf(szEntry,\"File%lu\",(DWORD)i+1);\n      if (!GetMenuItem(lpMruMenu,i,FALSE,lpTxt,lpMruMenu->wMaxSizeLruItem + 10))\n        *lpTxt = '\\0';\n      RegSetValueEx(hCurKey,szEntry,0,REG_SZ,(unsigned char*)lpTxt,lstrlen(lpTxt));\n    }\n  RegCloseKey(hCurKey);\n  GlobalFreePtr(lpTxt);\n  return TRUE;\n}\n\n//*************************************************************\n//\n//  LoadMruInReg()\n//\n//  Purpose:\n//              Load MRU from the registry\n//\n//  Parameters:\n//      LPMRUMENU lpMruMenu -      pointer on MRUMENU\n//      LPSTR lpszKey  -           Points to a null-terminated string \n//                                      specifying  the name of a key that \n//                                      this function opens or creates.\n//\n//  Return: (BOOL)\n//      TRUE  - Function run successfully\n//      FALSE - Function don't run successfully\n//\n//\n//  Comments:\n//      Win32 function designed for Windows NT and Windows 95\n//      See RegOpenKeyEx API for more info on lpszKey\n//\n//  History:    Date       Author       Comment\n//              09/24/94   G. Vollant   Created\n//\n//*************************************************************\nBOOL LoadMruInReg(LPMRUMENU lpMruMenu,LPSTR lpszKey)\n{\nLPSTR lpTxt;\nWORD i;\nHKEY hCurKey;\nDWORD dwType;\n  lpTxt = (LPSTR)GlobalAllocPtr(GHND,lpMruMenu->wMaxSizeLruItem + 20);\n  if (lpTxt == NULL) \n    return FALSE;\n\n  RegOpenKeyEx(HKEY_CURRENT_USER,lpszKey,0,KEY_READ,&hCurKey);\n\n\n  for (i=0;i<lpMruMenu->wNbLruMenu;i++)\n    {\n    char szEntry[16];\n    DWORD dwSizeBuf;  \n      wsprintf(szEntry,\"File%lu\",(DWORD)i+1);\n      *lpTxt = '\\0';\n      dwSizeBuf = lpMruMenu->wMaxSizeLruItem + 10;\n      RegQueryValueEx(hCurKey,szEntry,NULL,&dwType,(LPBYTE)lpTxt,&dwSizeBuf);\n      *(lpTxt+dwSizeBuf)='\\0';\n      if (*lpTxt == '\\0')\n        break;\n      SetMenuItem(lpMruMenu,i,lpTxt);\n    }\n  RegCloseKey(hCurKey);\n  GlobalFreePtr(lpTxt);\n  return TRUE;\n}\n\n\n//*************************************************************\n//\n//  GetWin32Kind()\n//\n//  Purpose:\n//              Get the Win32 platform\n//\n//  Parameters:\n//\n//  Return: (WIN32KIND)\n//      WINNT -           Run under Windows NT\n//      WIN32S -          Run under Windows 3.1x + Win32s\n//      WIN95ORGREATHER - Run under Windows 95\n//\n//\n//  Comments:\n//      Win32 function designed for Windows NT and Windows 95\n//      See RegOpenKeyEx API for more info on lpszKey\n//\n//  History:    Date       Author       Comment\n//              09/24/94   G. Vollant   Created\n//\n//*************************************************************\nWIN32KIND GetWin32Kind()\n{\nBOOL IsWin395OrHigher(void);\n\n  WORD wVer;\n\n  if ((GetVersion() & 0x80000000) == 0)\n    return WINNT;\n  wVer = LOWORD(GetVersion());\n  wVer = (((WORD)LOBYTE(wVer)) << 8) | (WORD)HIBYTE(wVer);\n\n  if (wVer >= 0x035F)\n    return WIN95ORGREATHER;\n  else\n    return WIN32S;\n}\n#endif\n"
  },
  {
    "path": "q3radiant/MRU.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//*************************************************************\n//  File name: mru.h\n//\n//  Description:\n//\n//      Header for MRU support\n//\n//  Development Team:\n//\n//      Gilles Vollant (100144.2636@compuserve.com) \n//\n//*************************************************************\n\n#ifndef __MRU_H__\n#define __MRU_H__\n\n#define NBMRUMENUSHOW   6       // Default number of MRU showed in the menu File\n#define NBMRUMENU       9       // Default number of MRU stored\n#define IDMRU           8000    // Default First ID of MRU\n#ifdef  OFS_MAXPATHNAME\n#define MAXSIZEMRUITEM  OFS_MAXPATHNAME\n#else\n#define MAXSIZEMRUITEM  128     // Default max size of an entry\n#endif\n\ntypedef struct\n{\nWORD wNbItemFill;\nWORD wNbLruShow;\nWORD wNbLruMenu;\nWORD wMaxSizeLruItem;\nWORD wIdMru;\nLPSTR lpMRU;\n} MRUMENU;\n\ntypedef MRUMENU FAR * LPMRUMENU;\n\n#ifdef __cplusplus\nLPMRUMENU       CreateMruMenu  (WORD wNbLruShowInit=NBMRUMENUSHOW,\n                                WORD wNbLruMenuInit=NBMRUMENU,\n                                WORD wMaxSizeLruItemInit=MAXSIZEMRUITEM,\n                                WORD wIdMruInit=IDMRU);\n#else\nLPMRUMENU       CreateMruMenu  (WORD wNbLruShowInit,\n                                WORD wNbLruMenuInit,\n                                WORD wMaxSizeLruItemInit,\n                                WORD wIdMruInit);\n#endif\n\nLPMRUMENU       CreateMruMenuDefault();\nvoid            DeleteMruMenu  (LPMRUMENU lpMruMenu);  \n\nvoid            SetNbLruShow   (LPMRUMENU lpMruMenu,WORD wNbLruShowInit);\nBOOL            SetMenuItem    (LPMRUMENU lpMruMenu,WORD wItem,\n                                LPSTR lpItem);\nBOOL            GetMenuItem    (LPMRUMENU lpMruMenu,WORD wItem,\n                                BOOL fIDMBased,LPSTR lpItem,UINT uiSize);\nBOOL            DelMenuItem    (LPMRUMENU lpMruMenu,WORD wItem,BOOL fIDMBased);\nvoid            AddNewItem     (LPMRUMENU lpMruMenu,LPSTR lpItem);\nvoid            PlaceMenuMRUItem(LPMRUMENU lpMruMenu,HMENU hMenu,UINT uiItem);\n\nBOOL            SaveMruInIni   (LPMRUMENU lpMruMenu,LPSTR lpszSection,LPSTR lpszFile);\nBOOL            LoadMruInIni   (LPMRUMENU lpMruMenu,LPSTR lpszSection,LPSTR lpszFile);\n#ifdef WIN32\nBOOL            SaveMruInReg   (LPMRUMENU lpMruMenu,LPSTR lpszKey);\nBOOL            LoadMruInReg   (LPMRUMENU lpMruMenu,LPSTR lpszKey);\n\ntypedef enum \n{\nWIN32S,\nWINNT,\nWIN95ORGREATHER\n} WIN32KIND;\nWIN32KIND GetWin32Kind();\n#endif\n\n\n//////////////////////////////////////////////////////////////\n#endif\n"
  },
  {
    "path": "q3radiant/MainFrm.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// MainFrm.cpp : implementation of the CMainFrame class\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"qe3.h\"\n#include \"ZWnd.h\"\n#include \"CamWnd.h\"\n#include \"TexWnd.h\"\n#include \"EditWnd.h\"\n#include \"entityw.h\"\n#include \"PrefsDlg.h\"\n#include \"MapInfo.h\"\n#include \"MainFrm.h\"\n#include \"RotateDlg.h\"\n#include \"EntityListDlg.h\"\n#include \"ScriptDlg.h\"\n#include \"NewProjDlg.h\"\n#include \"CommandsDlg.h\"\n#include \"ScaleDialog.h\"\n#include \"FindTextureDlg.h\"\n#include \"SurfaceDlg.h\"\n#include \"shlobj.h\"\n#include \"DialogTextures.h\"\n#include \"PatchDensityDlg.h\"\n#include \"DialogThick.h\"\n#include \"PatchDialog.h\"\n#include \"Undo.h\"\n#include \"NameDlg.h\"\n#include \"../libs/pakstuff.h\"\n#include \"splines/splines.h\"\n#include \"dlgcamera.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n\n// globals\nCString g_strAppPath;                   // holds the full path of the executable\nCEdit* g_pEdit = NULL;                  // used originally to make qe4 work with mfc.. still used\nCMainFrame* g_pParentWnd = NULL;        // used to precast to CMainFrame\nCPrefsDlg g_Preferences;                // global prefs instance\nCPrefsDlg& g_PrefsDlg = g_Preferences;  // reference used throughout\nint g_nUpdateBits = 0;                  // window update flags\nbool g_bScreenUpdates = true;           // whether window painting is active, used in a few places\n                                        // to disable updates for speed reasons\n                                        // both of the above should be made members of CMainFrame\n\n//bool g_bSnapToGrid = true;              // early use, no longer in use, clamping pref will be used\nCString g_strProject;                   // holds the active project filename\n\n\n/////////////////////////////////////////////////////////////////////////////\n// CMainFrame\n\n// command mapping stuff\n//\n// m_strCommand is the command string\n// m_nKey is the windows VK_??? equivelant\n// m_nModifiers are key states as follows\n//  bit\n//    0 - shift\n//    1 - alt\n//    2 - control\n//    4 - press only\n//\n#define\tSPEED_MOVE\t32\n#define\tSPEED_TURN\t22.5\n\n\nSCommandInfo g_Commands[] = \n{\n  {\"ToggleOutlineDraw\", 'J', 0x00, ID_SELECTION_NOOUTLINE},\n  {\"CSGMerge\", 'U', 0x04, ID_SELECTION_CSGMERGE},\n  {\"CSGSubtract\", 'U', 0x01, ID_SELECTION_CSGSUBTRACT},\n  {\"ViewGroups\", 'G', 0x00, ID_VIEW_GROUPS},\n  {\"HideSelected\", 'H', 0x00, ID_VIEW_HIDESHOW_HIDESELECTED},\n  {\"ShowHidden\", 'H', 0x01, ID_VIEW_HIDESHOW_SHOWHIDDEN},\n  {\"BendMode\", 'B', 0x00, ID_PATCH_BEND},\n  {\"FitFace\", 'B', 0x04, ID_FITFACE},\n  {\"FitBrush\", 'B', 0x01, ID_FITBRUSH},\n  {\"FreezePatchVertices\", 'F', 0x00, ID_CURVE_FREEZE},\n  {\"UnFreezePatchVertices\", 'F', 0x04, ID_CURVE_UNFREEZE},\n  {\"UnFreezeAllPatchVertices\", 'F', 0x05, ID_CURVE_UNFREEZEALL},\n  {\"ViewTextures\", 'T', 0, ID_VIEW_TEXTURE},\n  {\"ThickenPatch\", 'T', 0x04, ID_CURVE_THICKEN},\n  {\"MakeOverlayPatch\", 'Y', 0, ID_CURVE_OVERLAY_SET},\n  {\"ClearPatchOverlays\", 'Y', 0x02, ID_CURVE_OVERLAY_CLEAR},\n  {\"SurfaceInspector\", 'S', 0, ID_TEXTURES_INSPECTOR},\n  {\"PatchInspector\", 'S', 0x01, ID_PATCH_INSPECTOR},\n  {\"ToggleShowPatches\", 'P', 0x05, ID_CURVE_CYCLECAP},\n  {\"ToggleShowPatches\", 'P', 0x04, ID_VIEW_SHOWCURVES},\n  {\"RedisperseRows\", 'E', 0x04, ID_CURVE_REDISPERSE_ROWS},\n  {\"RedisperseCols\", 'E', 0x05, ID_CURVE_REDISPERSE_COLS},\n  {\"InvertCurveTextureX\", 'I', 0x05, ID_CURVE_NEGATIVETEXTUREY},\n  {\"InvertCurveTextureY\", 'I', 0x01, ID_CURVE_NEGATIVETEXTUREX},\n  {\"InvertCurve\", 'I', 0x04, ID_CURVE_NEGATIVE},\n  {\"IncPatchColumn\", VK_ADD, 0x05, ID_CURVE_INSERTCOLUMN},\n  {\"IncPatchRow\", VK_ADD, 0x04, ID_CURVE_INSERTROW},\n  {\"DecPatchColumn\", VK_SUBTRACT, 0x05, ID_CURVE_DELETECOLUMN},\n  {\"DecPatchRow\", VK_SUBTRACT, 0x04, ID_CURVE_DELETEROW},\n  {\"Patch TAB\", VK_TAB, 0x00, ID_PATCH_TAB},\n  {\"Patch TAB\", VK_TAB, 0x01, ID_PATCH_TAB},\n  {\"SelectNudgeDown\", VK_DOWN, 0x02, ID_SELECTION_SELECT_NUDGEDOWN},\n  {\"EntityColor\",'K', 0, ID_MISC_SELECTENTITYCOLOR},\n  {\"CameraForward\", VK_UP, 0, ID_CAMERA_FORWARD},\n  {\"CameraBack\", VK_DOWN, 0, ID_CAMERA_BACK},\n  {\"CameraLeft\", VK_LEFT, 0, ID_CAMERA_LEFT},\n  {\"CameraRight\", VK_RIGHT, 0, ID_CAMERA_RIGHT},\n  {\"CameraUp\", 'D', 0, ID_CAMERA_UP},\n  {\"CameraDown\", 'C', 0, ID_CAMERA_DOWN},\n  {\"CameraAngleUp\", 'A', 0, ID_CAMERA_ANGLEUP},\n  {\"CameraAngleDown\", 'Z', 0, ID_CAMERA_ANGLEDOWN},\n  {\"CameraStrafeRight\", VK_PERIOD, 0, ID_CAMERA_STRAFERIGHT},\n  {\"CameraStrafeLeft\", VK_COMMA, 0, ID_CAMERA_STRAFELEFT},\n  {\"ToggleGrid\", '0', 0, ID_GRID_TOGGLE},\n  {\"SetGrid1\", '1', 0, ID_GRID_1},\n  {\"SetGrid2\", '2', 0, ID_GRID_2},\n  {\"SetGrid4\", '3', 0, ID_GRID_4},\n  {\"SetGrid8\", '4', 0, ID_GRID_8},\n  {\"SetGrid16\", '5', 0, ID_GRID_16},\n  {\"SetGrid32\", '6', 0, ID_GRID_32},\n  {\"SetGrid64\", '7', 0, ID_GRID_64},\n  {\"DragEdges\", 'E', 0, ID_SELECTION_DRAGEDGES},\n  {\"DragVertices\", 'V', 0, ID_SELECTION_DRAGVERTECIES},\n  {\"ViewEntityInfo\", 'N', 0, ID_VIEW_ENTITY},\n  {\"ViewConsole\", 'O', 0, ID_VIEW_CONSOLE},\n  {\"CloneSelection\", VK_SPACE, 0, ID_SELECTION_CLONE},\n  {\"DeleteSelection\", VK_BACK, 0, ID_SELECTION_DELETE},\n  {\"UnSelectSelection\", VK_ESCAPE, 0, ID_SELECTION_DESELECT},\n  {\"CenterView\", VK_END, 0, ID_VIEW_CENTER},\n  {\"ZoomOut\", VK_INSERT, 0, ID_VIEW_ZOOMOUT},\n  {\"ZoomIn\", VK_DELETE, 0, ID_VIEW_ZOOMIN},\n  {\"UpFloor\", VK_PRIOR, 0, ID_VIEW_UPFLOOR},\n  {\"DownFloor\", VK_NEXT, 0, ID_VIEW_DOWNFLOOR},\n  {\"ToggleClipper\", 'X', 0, ID_VIEW_CLIPPER},\n  {\"ToggleCrosshairs\", 'X', 0x01, ID_VIEW_CROSSHAIR},\n  {\"TogTexLock\", 'T', 0x01, ID_TOGGLE_LOCK},\n  {\"TogTexRotLock\", 'R', 0x01, ID_TOGGLE_ROTATELOCK},\n  {\"ToggleRealtime\", 'R', 0x04, ID_VIEW_CAMERAUPDATE},\n  {\"RaiseLowerTerrain\", 'T', 0x06, ID_TERRAIN_RAISELOWERTERRAIN},\n  {\"EntityList\", 'L', 0, ID_EDIT_ENTITYINFO},\n  {\"Preferences\", 'P', 0, ID_PREFS},\n  {\"ToggleCamera\", 'C', 0x05, ID_TOGGLECAMERA},\n  {\"ToggleConsole\", 'O', 0, ID_TOGGLECONSOLE},\n  {\"ToggleView\", 'V', 0x05, ID_TOGGLEVIEW},\n  {\"ToggleZ\", 'Z', 0x05, ID_TOGGLEZ},\n  {\"ConnectSelection\", 'K', 0x04, ID_SELECTION_CONNECT},\n  {\"Brush3Sided\", '3', 0x04, ID_BRUSH_3SIDED},\n  {\"Brush4Sided\", '4', 0x04, ID_BRUSH_4SIDED},\n  {\"Brush5Sided\", '5', 0x04, ID_BRUSH_5SIDED},\n  {\"Brush6Sided\", '6', 0x04, ID_BRUSH_6SIDED},\n  {\"Brush7Sided\", '7', 0x04, ID_BRUSH_7SIDED},\n  {\"Brush8Sided\", '8', 0x04, ID_BRUSH_8SIDED},\n  {\"Brush9Sided\", '9', 0x04, ID_BRUSH_9SIDED},\n  {\"ShowDetail\", 'D', 0x04, ID_VIEW_SHOWDETAIL},\n  {\"MakeDetail\", 'M', 0x05, ID_CURVE_MATRIX_TRANSPOSE},\n  {\"MakeDetail\", 'M', 0x04, ID_SELECTION_MAKE_DETAIL},\n  {\"MapInfo\", 'M', 0, ID_EDIT_MAPINFO},\n  {\"NextLeakSpot\", 'K', 0x05, ID_MISC_NEXTLEAKSPOT},\n  {\"PrevLeakSpot\", 'L', 0x05, ID_MISC_PREVIOUSLEAKSPOT},\n  {\"FileOpen\", 'O', 0x04, ID_FILE_OPEN},\n  {\"FileSave\", 'S', 0x04, ID_FILE_SAVE},\n  {\"Exit\", 'X', 0x04, ID_FILE_EXIT},\n  {\"NextView\", VK_TAB, 0x04, ID_VIEW_NEXTVIEW},\n  {\"ClipSelected\", VK_RETURN, 0x00, ID_CLIP_SELECTED},\n  {\"SplitSelected\", VK_RETURN, 0x01, ID_SPLIT_SELECTED},\n  {\"FlipClip\", VK_RETURN, 0x04, ID_FLIP_CLIP},\n  {\"MouseRotate\", 'R', 0x00, ID_SELECT_MOUSEROTATE},\n  {\"Copy\", 'C', 0x04, ID_EDIT_COPYBRUSH},\n  {\"Paste\", 'V', 0x04, ID_EDIT_PASTEBRUSH},\n  {\"Undo\", 'Z', 0x04, ID_EDIT_UNDO},\n  {\"Redo\", 'Y', 0x04, ID_EDIT_REDO}, \n  {\"ZZoomOut\", VK_INSERT, 0x04, ID_VIEW_ZZOOMOUT},\n  {\"ZZoomIn\", VK_DELETE, 0x04, ID_VIEW_ZZOOMIN},\n  {\"TexDecrement\", VK_SUBTRACT, 0x01, ID_SELECTION_TEXTURE_DEC},\n  {\"TexIncrement\", VK_ADD, 0x01, ID_SELECTION_TEXTURE_INC},\n  {\"TextureFit\", '5', 0x01, ID_SELECTION_TEXTURE_FIT},\n  {\"TexRotateClock\", VK_NEXT, 0x01, ID_SELECTION_TEXTURE_ROTATECLOCK},\n  {\"TexRotateCounter\", VK_PRIOR, 0x01, ID_SELECTION_TEXTURE_ROTATECOUNTER},\n  {\"TexScaleUp\", VK_UP, 0x04, ID_SELECTION_TEXTURE_SCALEUP},\n  {\"TexScaleDown\", VK_DOWN, 0x04, ID_SELECTION_TEXTURE_SCALEDOWN},\n  {\"TexShiftLeft\", VK_LEFT, 0x01, ID_SELECTION_TEXTURE_SHIFTLEFT},\n  {\"TexShiftRight\", VK_RIGHT, 0x01, ID_SELECTION_TEXTURE_SHIFTRIGHT},\n  {\"TexShiftUp\", VK_UP, 0x01, ID_SELECTION_TEXTURE_SHIFTUP},\n  {\"TexShiftDown\", VK_DOWN, 0x01, ID_SELECTION_TEXTURE_SHIFTDOWN},\n  {\"GridDown\", 219, 0x00, ID_GRID_PREV},\n  {\"GridUp\", 221, 0x00, ID_GRID_NEXT},\n  {\"TexScaleLeft\", VK_LEFT, 0x04, ID_SELECTION_TEXTURE_SCALELEFT},\n  {\"TexScaleRight\", VK_RIGHT, 0x04, ID_SELECTION_TEXTURE_SCALERIGHT},\n  {\"CubicClipZoomOut\", 219, 0x04, ID_VIEW_CUBEOUT},\n  {\"CubicClipZoomIn\", 221, 0x04, ID_VIEW_CUBEIN},\n  {\"ToggleCubicClip\", 220, 0x04, ID_VIEW_CUBICCLIPPING},\n//  {\"ToggleCubicClip\", '\\\\', 0x04, ID_VIEW_CUBICCLIPPING},\n  {\"MoveSelectionDOWN\", VK_SUBTRACT, 0x00, ID_SELECTION_MOVEDOWN},\n  {\"MoveSelectionUP\", VK_ADD, 0x00, ID_SELECTION_MOVEUP},\n  {\"DumpSelectedBrush\", 'D', 0x01, ID_SELECTION_PRINT},\n  {\"ToggleSizePaint\", 'Q', 0x08, ID_SELECTION_TOGGLESIZEPAINT},\n  {\"SelectNudgeLeft\", VK_LEFT, 0x02, ID_SELECTION_SELECT_NUDGELEFT},\n  {\"SelectNudgeRight\", VK_RIGHT, 0x02, ID_SELECTION_SELECT_NUDGERIGHT},\n  {\"SelectNudgeUp\", VK_UP, 0x02, ID_SELECTION_SELECT_NUDGEUP},\n  {\"CycleCapTexturePatch\", 'N', 0x05, ID_CURVE_CYCLECAP},\n  {\"NaturalizePatch\", 'N', 0x04, ID_PATCH_NATURALIZE},\n  {\"SnapPatchToGrid\", 'G', 0x04, ID_SELECT_SNAPTOGRID},\n  {\"ShowAllTextures\", 'A', 0x04, ID_TEXTURES_SHOWALL},\n  {\"SelectAllOfType\", 'A', 0x01, ID_SELECT_ALL},\n  {\"CapCurrentCurve\", 'C', 0x01, ID_CURVE_CAP},\n  {\"MakeStructural\", 'S', 0x05, ID_SELECTION_MAKE_STRUCTURAL}\n  //{\"ForceCameraWalk\", 'Q', 0x08, ID_CAMERA_ACTIVE}\n};\n\nint g_nCommandCount = sizeof(g_Commands) / sizeof(SCommandInfo);\n\nSKeyInfo g_Keys[] =\n{\n  {\"Space\", VK_SPACE},\n  {\"Backspace\", VK_BACK},\n  {\"Escape\", VK_ESCAPE},\n  {\"End\", VK_END},\n  {\"Insert\", VK_INSERT},\n  {\"Delete\", VK_DELETE},\n  {\"PageUp\", VK_PRIOR},\n  {\"PageDown\", VK_NEXT},\n  {\"Up\", VK_UP},\n  {\"Down\", VK_DOWN},\n  {\"Left\", VK_LEFT},\n  {\"Right\", VK_RIGHT},\n  {\"F1\", VK_F1},\n  {\"F2\", VK_F2},\n  {\"F3\", VK_F3},\n  {\"F4\", VK_F4},\n  {\"F5\", VK_F5},\n  {\"F6\", VK_F6},\n  {\"F7\", VK_F7},\n  {\"F8\", VK_F8},\n  {\"F9\", VK_F9},\n  {\"F10\", VK_F10},\n  {\"F11\", VK_F11},\n  {\"F12\", VK_F12},\n  {\"Tab\", VK_TAB},\n  {\"Return\", VK_RETURN},                           \n  {\"Comma\", VK_COMMA},\n  {\"Period\", VK_PERIOD},\n  {\"Plus\", VK_ADD},\n  {\"Multiply\", VK_MULTIPLY},\n  {\"Subtract\", VK_SUBTRACT},\n  {\"NumPad0\", VK_NUMPAD0},\n  {\"NumPad1\", VK_NUMPAD1},\n  {\"NumPad2\", VK_NUMPAD2},\n  {\"NumPad3\", VK_NUMPAD3},\n  {\"NumPad4\", VK_NUMPAD4},\n  {\"NumPad5\", VK_NUMPAD5},\n  {\"NumPad6\", VK_NUMPAD6},\n  {\"NumPad7\", VK_NUMPAD7},\n  {\"NumPad8\", VK_NUMPAD8},\n  {\"NumPad9\", VK_NUMPAD9},\n  {\"[\", 219},\n  {\"]\", 221},\n  {\"\\\\\", 220}\n};\n\nint g_nKeyCount = sizeof(g_Keys) / sizeof(SKeyInfo);\n\nconst int CMD_TEXTUREWAD_END = CMD_TEXTUREWAD + 127;\nconst int CMD_BSPCOMMAND_END = CMD_BSPCOMMAND + 127;\nconst int IDMRU_END = IDMRU+9;\n\nconst int g_msgBSPDone = RegisterWindowMessage(\"_BSPDone\");\nconst int g_msgBSPStatus = RegisterWindowMessage(\"_BSPStatus\");\n\nIMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd)\n\nBEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)\n\t//{{AFX_MSG_MAP(CMainFrame)\n\tON_WM_PARENTNOTIFY()\n\tON_WM_CREATE()\n\tON_WM_TIMER()\n\tON_WM_DESTROY()\n\tON_WM_CLOSE()\n\tON_WM_KEYDOWN()\n\tON_WM_SIZE()\n  ON_COMMAND(ID_VIEW_CAMERATOGGLE, ToggleCamera)\n\tON_COMMAND(ID_FILE_CLOSE, OnFileClose)\n\tON_COMMAND(ID_FILE_EXIT, OnFileExit)\n\tON_COMMAND(ID_FILE_LOADPROJECT, OnFileLoadproject)\n\tON_COMMAND(ID_FILE_NEW, OnFileNew)\n\tON_COMMAND(ID_FILE_OPEN, OnFileOpen)\n\tON_COMMAND(ID_FILE_POINTFILE, OnFilePointfile)\n\tON_COMMAND(ID_FILE_PRINT, OnFilePrint)\n\tON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview)\n\tON_COMMAND(ID_FILE_SAVE, OnFileSave)\n\tON_COMMAND(ID_FILE_SAVEAS, OnFileSaveas)\n\tON_COMMAND(ID_VIEW_100, OnView100)\n\tON_COMMAND(ID_VIEW_CENTER, OnViewCenter)\n\tON_COMMAND(ID_VIEW_CONSOLE, OnViewConsole)\n\tON_COMMAND(ID_VIEW_DOWNFLOOR, OnViewDownfloor)\n\tON_COMMAND(ID_VIEW_ENTITY, OnViewEntity)\n\tON_COMMAND(ID_VIEW_FRONT, OnViewFront)\n\tON_COMMAND(ID_VIEW_SHOWBLOCKS, OnViewShowblocks)\n\tON_COMMAND(ID_VIEW_SHOWCLIP, OnViewShowclip)\n\tON_COMMAND(ID_VIEW_SHOWCOORDINATES, OnViewShowcoordinates)\n\tON_COMMAND(ID_VIEW_SHOWDETAIL, OnViewShowdetail)\n\tON_COMMAND(ID_VIEW_SHOWENT, OnViewShowent)\n\tON_COMMAND(ID_VIEW_SHOWLIGHTS, OnViewShowlights)\n\tON_COMMAND(ID_VIEW_SHOWNAMES, OnViewShownames)\n\tON_COMMAND(ID_VIEW_SHOWPATH, OnViewShowpath)\n\tON_COMMAND(ID_VIEW_SHOWWATER, OnViewShowwater)\n\tON_COMMAND(ID_VIEW_SHOWWORLD, OnViewShowworld)\n\tON_COMMAND(ID_VIEW_TEXTURE, OnViewTexture)\n\tON_COMMAND(ID_VIEW_UPFLOOR, OnViewUpfloor)\n\tON_COMMAND(ID_VIEW_XY, OnViewXy)\n\tON_COMMAND(ID_VIEW_Z100, OnViewZ100)\n\tON_COMMAND(ID_VIEW_ZOOMIN, OnViewZoomin)\n\tON_COMMAND(ID_VIEW_ZOOMOUT, OnViewZoomout)\n\tON_COMMAND(ID_VIEW_ZZOOMIN, OnViewZzoomin)\n\tON_COMMAND(ID_VIEW_ZZOOMOUT, OnViewZzoomout)\n\tON_COMMAND(ID_VIEW_SIDE, OnViewSide)\n\tON_COMMAND(ID_TEXTURES_SHOWINUSE, OnTexturesShowinuse)\n\tON_COMMAND(ID_TEXTURES_INSPECTOR, OnTexturesInspector)\n\tON_COMMAND(ID_MISC_BENCHMARK, OnMiscBenchmark)\n\tON_COMMAND(ID_MISC_FINDBRUSH, OnMiscFindbrush)\n\tON_COMMAND(ID_MISC_GAMMA, OnMiscGamma)\n\tON_COMMAND(ID_MISC_NEXTLEAKSPOT, OnMiscNextleakspot)\n\tON_COMMAND(ID_MISC_PREVIOUSLEAKSPOT, OnMiscPreviousleakspot)\n\tON_COMMAND(ID_MISC_PRINTXY, OnMiscPrintxy)\n\tON_COMMAND(ID_MISC_SELECTENTITYCOLOR, OnMiscSelectentitycolor)\n\tON_COMMAND(ID_TEXTUREBK, OnTexturebk)\n\tON_COMMAND(ID_COLORS_MAJOR, OnColorsMajor)\n\tON_COMMAND(ID_COLORS_MINOR, OnColorsMinor)\n\tON_COMMAND(ID_COLORS_XYBK, OnColorsXybk)\n\tON_COMMAND(ID_BRUSH_3SIDED, OnBrush3sided)\n\tON_COMMAND(ID_BRUSH_4SIDED, OnBrush4sided)\n\tON_COMMAND(ID_BRUSH_5SIDED, OnBrush5sided)\n\tON_COMMAND(ID_BRUSH_6SIDED, OnBrush6sided)\n\tON_COMMAND(ID_BRUSH_7SIDED, OnBrush7sided)\n\tON_COMMAND(ID_BRUSH_8SIDED, OnBrush8sided)\n\tON_COMMAND(ID_BRUSH_9SIDED, OnBrush9sided)\n\tON_COMMAND(ID_BRUSH_ARBITRARYSIDED, OnBrushArbitrarysided)\n\tON_COMMAND(ID_BRUSH_FLIPX, OnBrushFlipx)\n\tON_COMMAND(ID_BRUSH_FLIPY, OnBrushFlipy)\n\tON_COMMAND(ID_BRUSH_FLIPZ, OnBrushFlipz)\n\tON_COMMAND(ID_BRUSH_ROTATEX, OnBrushRotatex)\n\tON_COMMAND(ID_BRUSH_ROTATEY, OnBrushRotatey)\n\tON_COMMAND(ID_BRUSH_ROTATEZ, OnBrushRotatez)\n\tON_COMMAND(ID_REGION_OFF, OnRegionOff)\n\tON_COMMAND(ID_REGION_SETBRUSH, OnRegionSetbrush)\n\tON_COMMAND(ID_REGION_SETSELECTION, OnRegionSetselection)\n\tON_COMMAND(ID_REGION_SETTALLBRUSH, OnRegionSettallbrush)\n\tON_COMMAND(ID_REGION_SETXY, OnRegionSetxy)\n\tON_COMMAND(ID_SELECTION_ARBITRARYROTATION, OnSelectionArbitraryrotation)\n\tON_COMMAND(ID_SELECTION_CLONE, OnSelectionClone)\n\tON_COMMAND(ID_SELECTION_CONNECT, OnSelectionConnect)\n\tON_COMMAND(ID_SELECTION_CSGSUBTRACT, OnSelectionCsgsubtract)\n\tON_COMMAND(ID_SELECTION_CSGMERGE, OnSelectionCsgmerge)\n\tON_COMMAND(ID_SELECTION_NOOUTLINE, OnSelectionNoOutline)\n\tON_COMMAND(ID_SELECTION_DELETE, OnSelectionDelete)\n\tON_COMMAND(ID_SELECTION_DESELECT, OnSelectionDeselect)\n\tON_COMMAND(ID_SELECTION_DRAGEDGES, OnSelectionDragedges)\n\tON_COMMAND(ID_SELECTION_DRAGVERTECIES, OnSelectionDragvertecies)\n\tON_COMMAND(ID_SELECTION_MAKE_DETAIL, OnSelectionMakeDetail)\n\tON_COMMAND(ID_SELECTION_MAKE_STRUCTURAL, OnSelectionMakeStructural)\n\tON_COMMAND(ID_SELECTION_MAKEHOLLOW, OnSelectionMakehollow)\n\tON_COMMAND(ID_SELECTION_SELECTCOMPLETETALL, OnSelectionSelectcompletetall)\n\tON_COMMAND(ID_SELECTION_SELECTINSIDE, OnSelectionSelectinside)\n\tON_COMMAND(ID_SELECTION_SELECTPARTIALTALL, OnSelectionSelectpartialtall)\n\tON_COMMAND(ID_SELECTION_SELECTTOUCHING, OnSelectionSelecttouching)\n\tON_COMMAND(ID_SELECTION_UNGROUPENTITY, OnSelectionUngroupentity)\n\tON_COMMAND(ID_TEXTURES_POPUP, OnTexturesPopup)\n\tON_COMMAND(ID_SPLINES_POPUP, OnSplinesPopup)\n\tON_COMMAND(ID_POPUP_SELECTION, OnPopupSelection)\n\tON_COMMAND(ID_VIEW_CHANGE, OnViewChange)\n\tON_COMMAND(ID_VIEW_CAMERAUPDATE, OnViewCameraupdate)\n\tON_COMMAND(ID_TERRAIN_RAISELOWERTERRAIN, OnRaiseLowerTerrain)\n\tON_UPDATE_COMMAND_UI(ID_VIEW_CAMERAUPDATE, OnUpdateViewCameraupdate)\n\tON_WM_SIZING()\n\tON_COMMAND(ID_HELP_ABOUT, OnHelpAbout)\n\tON_COMMAND(ID_VIEW_CLIPPER, OnViewClipper)\n\tON_COMMAND(ID_CAMERA_ANGLEDOWN, OnCameraAngledown)\n\tON_COMMAND(ID_CAMERA_ANGLEUP, OnCameraAngleup)\n\tON_COMMAND(ID_CAMERA_BACK, OnCameraBack)\n\tON_COMMAND(ID_CAMERA_DOWN, OnCameraDown)\n\tON_COMMAND(ID_CAMERA_FORWARD, OnCameraForward)\n\tON_COMMAND(ID_CAMERA_LEFT, OnCameraLeft)\n\tON_COMMAND(ID_CAMERA_RIGHT, OnCameraRight)\n\tON_COMMAND(ID_CAMERA_STRAFELEFT, OnCameraStrafeleft)\n\tON_COMMAND(ID_CAMERA_STRAFERIGHT, OnCameraStraferight)\n\tON_COMMAND(ID_CAMERA_UP, OnCameraUp)\n\tON_COMMAND(ID_GRID_TOGGLE, OnGridToggle)\n\tON_COMMAND(ID_PREFS, OnPrefs)\n\tON_COMMAND(ID_TOGGLECAMERA, OnTogglecamera)\n\tON_COMMAND(ID_TOGGLECONSOLE, OnToggleconsole)\n\tON_COMMAND(ID_TOGGLEVIEW, OnToggleview)\n\tON_COMMAND(ID_TOGGLEZ, OnTogglez)\n\tON_COMMAND(ID_TOGGLE_LOCK, OnToggleLock)\n\tON_COMMAND(ID_EDIT_MAPINFO, OnEditMapinfo)\n\tON_COMMAND(ID_EDIT_ENTITYINFO, OnEditEntityinfo)\n\tON_COMMAND(ID_BRUSH_SCRIPTS, OnBrushScripts)\n\tON_COMMAND(ID_VIEW_NEXTVIEW, OnViewNextview)\n\tON_COMMAND(ID_HELP_COMMANDLIST, OnHelpCommandlist)\n\tON_COMMAND(ID_FILE_NEWPROJECT, OnFileNewproject)\n\tON_COMMAND(ID_FLIP_CLIP, OnFlipClip)\n\tON_COMMAND(ID_CLIP_SELECTED, OnClipSelected)\n\tON_COMMAND(ID_SPLIT_SELECTED, OnSplitSelected)\n\tON_COMMAND(ID_TOGGLEVIEW_XZ, OnToggleviewXz)\n\tON_COMMAND(ID_TOGGLEVIEW_YZ, OnToggleviewYz)\n\tON_COMMAND(ID_COLORS_BRUSH, OnColorsBrush)\n\tON_COMMAND(ID_COLORS_CLIPPER, OnColorsClipper)\n\tON_COMMAND(ID_COLORS_GRIDTEXT, OnColorsGridtext)\n\tON_COMMAND(ID_COLORS_SELECTEDBRUSH, OnColorsSelectedbrush)\n\tON_COMMAND(ID_COLORS_GRIDBLOCK, OnColorsGridblock)\n\tON_COMMAND(ID_COLORS_VIEWNAME, OnColorsViewname)\n\tON_COMMAND(ID_COLOR_SETORIGINAL, OnColorSetoriginal)\n\tON_COMMAND(ID_COLOR_SETQER, OnColorSetqer)\n\tON_COMMAND(ID_COLOR_SETBLACK, OnColorSetblack)\n\tON_COMMAND(ID_SNAPTOGRID, OnSnaptogrid)\n\tON_COMMAND(ID_SELECT_SCALE, OnSelectScale)\n\tON_COMMAND(ID_SELECT_MOUSEROTATE, OnSelectMouserotate)\n\tON_COMMAND(ID_EDIT_COPYBRUSH, OnEditCopybrush)\n\tON_COMMAND(ID_EDIT_PASTEBRUSH, OnEditPastebrush)\n\tON_COMMAND(ID_EDIT_UNDO, OnEditUndo)\n\tON_COMMAND(ID_EDIT_REDO, OnEditRedo)\n\tON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo)\n\tON_UPDATE_COMMAND_UI(ID_EDIT_REDO, OnUpdateEditRedo)\n\tON_COMMAND(ID_SELECTION_INVERT, OnSelectionInvert)\n\tON_COMMAND(ID_SELECTION_TEXTURE_DEC, OnSelectionTextureDec)\n\tON_COMMAND(ID_SELECTION_TEXTURE_FIT, OnSelectionTextureFit)\n\tON_COMMAND(ID_SELECTION_TEXTURE_INC, OnSelectionTextureInc)\n\tON_COMMAND(ID_SELECTION_TEXTURE_ROTATECLOCK, OnSelectionTextureRotateclock)\n\tON_COMMAND(ID_SELECTION_TEXTURE_ROTATECOUNTER, OnSelectionTextureRotatecounter)\n\tON_COMMAND(ID_SELECTION_TEXTURE_SCALEDOWN, OnSelectionTextureScaledown)\n\tON_COMMAND(ID_SELECTION_TEXTURE_SCALEUP, OnSelectionTextureScaleup)\n\tON_COMMAND(ID_SELECTION_TEXTURE_SHIFTDOWN, OnSelectionTextureShiftdown)\n\tON_COMMAND(ID_SELECTION_TEXTURE_SHIFTLEFT, OnSelectionTextureShiftleft)\n\tON_COMMAND(ID_SELECTION_TEXTURE_SHIFTRIGHT, OnSelectionTextureShiftright)\n\tON_COMMAND(ID_SELECTION_TEXTURE_SHIFTUP, OnSelectionTextureShiftup)\n\tON_COMMAND(ID_GRID_NEXT, OnGridNext)\n\tON_COMMAND(ID_GRID_PREV, OnGridPrev)\n\tON_COMMAND(ID_SELECTION_TEXTURE_SCALELEFT, OnSelectionTextureScaleLeft)\n\tON_COMMAND(ID_SELECTION_TEXTURE_SCALERIGHT, OnSelectionTextureScaleRight)\n\tON_COMMAND(ID_TEXTURE_REPLACEALL, OnTextureReplaceall)\n\tON_COMMAND(ID_SCALELOCKX, OnScalelockx)\n\tON_COMMAND(ID_SCALELOCKY, OnScalelocky)\n\tON_COMMAND(ID_SCALELOCKZ, OnScalelockz)\n\tON_COMMAND(ID_SELECT_MOUSESCALE, OnSelectMousescale)\n\tON_COMMAND(ID_VIEW_CUBICCLIPPING, OnViewCubicclipping)\n\tON_COMMAND(ID_FILE_IMPORT, OnFileImport)\n\tON_COMMAND(ID_FILE_PROJECTSETTINGS, OnFileProjectsettings)\n\tON_UPDATE_COMMAND_UI(ID_FILE_IMPORT, OnUpdateFileImport)\n\tON_COMMAND(ID_VIEW_CUBEIN, OnViewCubein)\n\tON_COMMAND(ID_VIEW_CUBEOUT, OnViewCubeout)\n\tON_COMMAND(ID_FILE_SAVEREGION, OnFileSaveregion)\n\tON_UPDATE_COMMAND_UI(ID_FILE_SAVEREGION, OnUpdateFileSaveregion)\n\tON_COMMAND(ID_SELECTION_MOVEDOWN, OnSelectionMovedown)\n\tON_COMMAND(ID_SELECTION_MOVEUP, OnSelectionMoveup)\n\tON_COMMAND(ID_TOOLBAR_MAIN, OnToolbarMain)\n\tON_COMMAND(ID_TOOLBAR_TEXTURE, OnToolbarTexture)\n\tON_COMMAND(ID_SELECTION_PRINT, OnSelectionPrint)\n\tON_COMMAND(ID_SELECTION_TOGGLESIZEPAINT, OnSelectionTogglesizepaint)\n\tON_COMMAND(ID_BRUSH_MAKECONE, OnBrushMakecone)\n\tON_COMMAND(ID_TEXTURES_LOAD, OnTexturesLoad)\n\tON_COMMAND(ID_TOGGLE_ROTATELOCK, OnToggleRotatelock)\n\tON_COMMAND(ID_CURVE_BEVEL, OnCurveBevel)\n\tON_COMMAND(ID_CURVE_CYLINDER, OnCurveCylinder)\n\tON_COMMAND(ID_CURVE_EIGHTHSPHERE, OnCurveEighthsphere)\n\tON_COMMAND(ID_CURVE_ENDCAP, OnCurveEndcap)\n\tON_COMMAND(ID_CURVE_HEMISPHERE, OnCurveHemisphere)\n\tON_COMMAND(ID_CURVE_INVERTCURVE, OnCurveInvertcurve)\n\tON_COMMAND(ID_CURVE_QUARTER, OnCurveQuarter)\n\tON_COMMAND(ID_CURVE_SPHERE, OnCurveSphere)\n\tON_COMMAND(ID_FILE_IMPORTMAP, OnFileImportmap)\n\tON_COMMAND(ID_FILE_EXPORTMAP, OnFileExportmap)\n\tON_COMMAND(ID_EDIT_LOADPREFAB, OnEditLoadprefab)\n\tON_COMMAND(ID_VIEW_SHOWCURVES, OnViewShowcurves)\n\tON_COMMAND(ID_SELECTION_SELECT_NUDGEDOWN, OnSelectionSelectNudgedown)\n\tON_COMMAND(ID_SELECTION_SELECT_NUDGELEFT, OnSelectionSelectNudgeleft)\n\tON_COMMAND(ID_SELECTION_SELECT_NUDGERIGHT, OnSelectionSelectNudgeright)\n\tON_COMMAND(ID_SELECTION_SELECT_NUDGEUP, OnSelectionSelectNudgeup)\n\tON_WM_SYSKEYDOWN()\n\tON_COMMAND(ID_TEXTURES_LOADLIST, OnTexturesLoadlist)\n\tON_COMMAND(ID_DONTSELECTCURVE, OnDontselectcurve)\n\tON_COMMAND(ID_CONVERTCURVES, OnConvertcurves)\n\tON_COMMAND(ID_DYNAMIC_LIGHTING, OnDynamicLighting)\n\tON_COMMAND(ID_CURVE_SIMPLEPATCHMESH, OnCurveSimplepatchmesh)\n\tON_COMMAND(ID_PATCH_SHOWBOUNDINGBOX, OnPatchToggleBox)\n\tON_COMMAND(ID_PATCH_WIREFRAME, OnPatchWireframe)\n\tON_COMMAND(ID_CURVE_PATCHCONE, OnCurvePatchcone)\n\tON_COMMAND(ID_CURVE_PATCHTUBE, OnCurvePatchtube)\n\tON_COMMAND(ID_PATCH_WELD, OnPatchWeld)\n\tON_COMMAND(ID_CURVE_PATCHBEVEL, OnCurvePatchbevel)\n\tON_COMMAND(ID_CURVE_PATCHENDCAP, OnCurvePatchendcap)\n\tON_COMMAND(ID_CURVE_PATCHINVERTEDBEVEL, OnCurvePatchinvertedbevel)\n\tON_COMMAND(ID_CURVE_PATCHINVERTEDENDCAP, OnCurvePatchinvertedendcap)\n\tON_COMMAND(ID_PATCH_DRILLDOWN, OnPatchDrilldown)\n\tON_COMMAND(ID_CURVE_INSERTCOLUMN, OnCurveInsertcolumn)\n\tON_COMMAND(ID_CURVE_INSERTROW, OnCurveInsertrow)\n\tON_COMMAND(ID_CURVE_DELETECOLUMN, OnCurveDeletecolumn)\n\tON_COMMAND(ID_CURVE_DELETEROW, OnCurveDeleterow)\n\tON_COMMAND(ID_CURVE_INSERT_ADDCOLUMN, OnCurveInsertAddcolumn)\n\tON_COMMAND(ID_CURVE_INSERT_ADDROW, OnCurveInsertAddrow)\n\tON_COMMAND(ID_CURVE_INSERT_INSERTCOLUMN, OnCurveInsertInsertcolumn)\n\tON_COMMAND(ID_CURVE_INSERT_INSERTROW, OnCurveInsertInsertrow)\n\tON_COMMAND(ID_CURVE_NEGATIVE, OnCurveNegative)\n\tON_COMMAND(ID_CURVE_NEGATIVETEXTUREX, OnCurveNegativeTextureX)\n\tON_COMMAND(ID_CURVE_NEGATIVETEXTUREY, OnCurveNegativeTextureY)\n\tON_COMMAND(ID_CURVE_DELETE_FIRSTCOLUMN, OnCurveDeleteFirstcolumn)\n\tON_COMMAND(ID_CURVE_DELETE_FIRSTROW, OnCurveDeleteFirstrow)\n\tON_COMMAND(ID_CURVE_DELETE_LASTCOLUMN, OnCurveDeleteLastcolumn)\n\tON_COMMAND(ID_CURVE_DELETE_LASTROW, OnCurveDeleteLastrow)\n\tON_COMMAND(ID_PATCH_BEND, OnPatchBend)\n\tON_COMMAND(ID_PATCH_INSDEL, OnPatchInsdel)\n\tON_COMMAND(ID_PATCH_ENTER, OnPatchEnter)\n\tON_COMMAND(ID_PATCH_TAB, OnPatchTab)\n\tON_COMMAND(ID_CURVE_PATCHDENSETUBE, OnCurvePatchdensetube)\n\tON_COMMAND(ID_CURVE_PATCHVERYDENSETUBE, OnCurvePatchverydensetube)\n\tON_COMMAND(ID_CURVE_CAP, OnCurveCap)\n\tON_COMMAND(ID_CURVE_CAP_INVERTEDBEVEL, OnCurveCapInvertedbevel)\n\tON_COMMAND(ID_CURVE_CAP_INVERTEDENDCAP, OnCurveCapInvertedendcap)\n\tON_COMMAND(ID_CURVE_REDISPERSE_COLS, OnCurveRedisperseCols)\n\tON_COMMAND(ID_CURVE_REDISPERSE_ROWS, OnCurveRedisperseRows)\n\tON_COMMAND(ID_PATCH_NATURALIZE, OnPatchNaturalize)\n\tON_COMMAND(ID_SELECT_SNAPTOGRID, OnSnapToGrid)\n\tON_COMMAND(ID_CURVE_PATCHSQUARE, OnCurvePatchsquare)\n\tON_COMMAND(ID_TERRAIN_CREATETERRAINFROMBRUSH, OnTerrainCreateFromBrush)\n\tON_COMMAND(ID_TEXTURES_TEXTUREWINDOWSCALE_10, OnTexturesTexturewindowscale10)\n\tON_COMMAND(ID_TEXTURES_TEXTUREWINDOWSCALE_100, OnTexturesTexturewindowscale100)\n\tON_COMMAND(ID_TEXTURES_TEXTUREWINDOWSCALE_200, OnTexturesTexturewindowscale200)\n\tON_COMMAND(ID_TEXTURES_TEXTUREWINDOWSCALE_25, OnTexturesTexturewindowscale25)\n\tON_COMMAND(ID_TEXTURES_TEXTUREWINDOWSCALE_50, OnTexturesTexturewindowscale50)\n\tON_COMMAND(ID_TEXTURES_FLUSH, OnTexturesFlush)\n\tON_COMMAND(ID_CURVE_OVERLAY_CLEAR, OnCurveOverlayClear)\n\tON_COMMAND(ID_CURVE_OVERLAY_SET, OnCurveOverlaySet)\n\tON_COMMAND(ID_CURVE_THICKEN, OnCurveThicken)\n\tON_COMMAND(ID_CURVE_CYCLECAP, OnCurveCyclecap)\n\tON_COMMAND(ID_CURVE_MATRIX_TRANSPOSE, OnCurveMatrixTranspose)\n\tON_COMMAND(ID_TEXTURES_RELOADSHADERS, OnTexturesReloadshaders)\n\tON_COMMAND(ID_SHOW_ENTITIES, OnShowEntities)\n\tON_COMMAND(ID_VIEW_ENTITIESAS_BOUNDINGBOX, OnViewEntitiesasBoundingbox)\n\tON_COMMAND(ID_VIEW_ENTITIESAS_SELECTEDSKINNED, OnViewEntitiesasSelectedskinned)\n\tON_COMMAND(ID_VIEW_ENTITIESAS_SELECTEDWIREFRAME, OnViewEntitiesasSelectedwireframe)\n\tON_COMMAND(ID_VIEW_ENTITIESAS_SKINNED, OnViewEntitiesasSkinned)\n\tON_COMMAND(ID_VIEW_ENTITIESAS_SKINNEDANDBOXED, OnViewEntitiesasSkinnedandboxed)\n\tON_COMMAND(ID_VIEW_ENTITIESAS_WIREFRAME, OnViewEntitiesasWireframe)\n\tON_COMMAND(ID_PLUGINS_REFRESH, OnPluginsRefresh)\n\tON_COMMAND(ID_VIEW_SHOWHINT, OnViewShowhint)\n\tON_UPDATE_COMMAND_UI(ID_TEXTURES_SHOWINUSE, OnUpdateTexturesShowinuse)\n\tON_COMMAND(ID_TEXTURES_SHOWALL, OnTexturesShowall)\n\tON_COMMAND(ID_PATCH_INSPECTOR, OnPatchInspector)\n\tON_COMMAND(ID_VIEW_OPENGLLIGHTING, OnViewOpengllighting)\n\tON_COMMAND(ID_SELECT_ALL, OnSelectAll)\n\tON_COMMAND(ID_VIEW_SHOWCAULK, OnViewShowcaulk)\n\tON_COMMAND(ID_CURVE_FREEZE, OnCurveFreeze)\n\tON_COMMAND(ID_CURVE_UNFREEZE, OnCurveUnFreeze)\n\tON_COMMAND(ID_CURVE_UNFREEZEALL, OnCurveUnFreezeAll)\n\tON_COMMAND(ID_SELECT_RESELECT, OnSelectReselect)\n\tON_COMMAND(ID_VIEW_SHOWANGLES, OnViewShowangles)\n\tON_COMMAND(ID_EDIT_SAVEPREFAB, OnEditSaveprefab)\n\tON_COMMAND(ID_CURVE_MOREENDCAPSBEVELS_SQUAREBEVEL, OnCurveMoreendcapsbevelsSquarebevel)\n\tON_COMMAND(ID_CURVE_MOREENDCAPSBEVELS_SQUAREENDCAP, OnCurveMoreendcapsbevelsSquareendcap)\n\tON_COMMAND(ID_BRUSH_PRIMITIVES_SPHERE, OnBrushPrimitivesSphere)\n\tON_COMMAND(ID_VIEW_CROSSHAIR, OnViewCrosshair)\n\tON_COMMAND(ID_VIEW_HIDESHOW_HIDESELECTED, OnViewHideshowHideselected)\n\tON_COMMAND(ID_VIEW_HIDESHOW_SHOWHIDDEN, OnViewHideshowShowhidden)\n\tON_COMMAND(ID_TEXTURES_SHADERS_SHOW, OnTexturesShadersShow)\n\tON_COMMAND(ID_TEXTURES_FLUSH_UNUSED, OnTexturesFlushUnused)\n\tON_COMMAND(ID_VIEW_GROUPS, OnViewGroups)\n\tON_COMMAND(ID_DROP_GROUP_ADDTO_WORLD, OnDropGroupAddtoWorld)\n\tON_COMMAND(ID_DROP_GROUP_NAME, OnDropGroupName)\n\tON_COMMAND(ID_DROP_GROUP_NEWGROUP, OnDropGroupNewgroup)\n\tON_COMMAND(ID_DROP_GROUP_REMOVE, OnDropGroupRemove)\n\tON_COMMAND(ID_SPLINES_MODE, OnSplinesMode)\n\tON_COMMAND(ID_SPLINES_LOAD, OnSplinesLoad)\n\tON_COMMAND(ID_SPLINES_SAVE, OnSplinesSave)\n\tON_COMMAND(ID_SPLINES_EDIT, OnSplinesEdit)\n\tON_COMMAND(ID_SPLINE_TEST, OnSplineTest)\n\tON_COMMAND(ID_POPUP_NEWCAMERA_INTERPOLATED, OnPopupNewcameraInterpolated)\n\tON_COMMAND(ID_POPUP_NEWCAMERA_SPLINE, OnPopupNewcameraSpline)\n\tON_COMMAND(ID_POPUP_NEWCAMERA_FIXED, OnPopupNewcameraFixed)\n\t//}}AFX_MSG_MAP\n  ON_COMMAND_RANGE(CMD_TEXTUREWAD, CMD_TEXTUREWAD_END, OnTextureWad)\n  ON_COMMAND_RANGE(CMD_BSPCOMMAND, CMD_BSPCOMMAND_END, OnBspCommand)\n  ON_COMMAND_RANGE(IDMRU, IDMRU_END, OnMru)\n  ON_COMMAND_RANGE(ID_VIEW_NEAREST, ID_TEXTURES_FLATSHADE, OnViewNearest)\n  ON_COMMAND_RANGE(ID_GRID_1, ID_GRID_64, OnGrid1)\n  ON_COMMAND_RANGE(ID_PLUGIN_START, ID_PLUGIN_END, OnPlugIn)\n  ON_REGISTERED_MESSAGE(g_msgBSPDone, OnBSPDone)\n  ON_REGISTERED_MESSAGE(g_msgBSPStatus, OnBSPStatus)\n  ON_MESSAGE(WM_DISPLAYCHANGE, OnDisplayChange)\n\nEND_MESSAGE_MAP()\n\nstatic UINT indicators[] =\n{\n\tID_SEPARATOR,           // status line indicator\n\tID_SEPARATOR,           // status line indicator\n\tID_SEPARATOR,           // status line indicator\n\tID_SEPARATOR,           // status line indicator\n\tID_SEPARATOR,           // status line indicator\n\tID_SEPARATOR,           // status line indicator\n};\n\nLRESULT CMainFrame::OnDisplayChange(UINT wParam, long lParam)\n{\n  int n = wParam;\n  return 0;\n}\n\n\nLRESULT CMainFrame::OnBSPStatus(UINT wParam, long lParam)\n{\n\treturn 0;\n}\n\nLRESULT CMainFrame::OnBSPDone(UINT wParam, long lParam)\n{\n  DLLBuildDone();\n  return 0;\n}\n\n\n/////////////////////////////////////////////////////////////////////////////\n// CMainFrame construction/destruction\n\nCMainFrame::CMainFrame()\n{\n  m_bDoLoop = false;\n  m_bSplittersOK = false;\n  g_pParentWnd = this;\n  m_pXYWnd = NULL;\n  m_pCamWnd = NULL;\n  m_pTexWnd = NULL;\n  m_pZWnd = NULL;\n  m_pEditWnd = NULL;\n  m_pYZWnd = NULL;\n  m_pXZWnd = NULL;\n  m_pActiveXY = NULL;\n  m_bCamPreview = true;\n}\n\nCMainFrame::~CMainFrame()\n{\n}\n\nvoid HandlePopup(CWnd* pWindow, unsigned int uId)\n{\n  // Get the current position of the mouse\n  CPoint ptMouse;\n  GetCursorPos(&ptMouse);\n\n  // Load up a menu that has the options we are looking for in it\n  CMenu mnuPopup;\n  VERIFY(mnuPopup.LoadMenu(uId));\n  mnuPopup.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON |\n      TPM_RIGHTBUTTON, ptMouse.x, ptMouse.y,pWindow);\n  mnuPopup.DestroyMenu();\n\n  // Set focus back to window\n  pWindow->SetFocus();\n}\n\n\nvoid CMainFrame::OnParentNotify(UINT message, LPARAM lParam) \n{\n}\n\nvoid CMainFrame::SetButtonMenuStates()\n{\n  CMenu* pMenu = GetMenu();\n  if (pMenu)\n  {\n\t\t// by default all of these are checked because that's how they're defined in the menu editor\n\t\tif ( !g_qeglobals.d_savedinfo.show_names )\n\t\t\tpMenu->CheckMenuItem(ID_VIEW_SHOWNAMES, MF_BYCOMMAND | MF_UNCHECKED);\n\t\tif ( !g_qeglobals.d_savedinfo.show_coordinates )\n\t\t\tpMenu->CheckMenuItem(ID_VIEW_SHOWCOORDINATES, MF_BYCOMMAND | MF_UNCHECKED );\n\n\t\tif ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_LIGHTS )\n\t\t\tpMenu->CheckMenuItem(ID_VIEW_SHOWLIGHTS, MF_BYCOMMAND | MF_UNCHECKED );\n\t\tif ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_ENT )\n\t\t\tpMenu->CheckMenuItem(ID_VIEW_ENTITY, MF_BYCOMMAND | MF_UNCHECKED );\n\t\tif ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_PATHS )\n\t\t\tpMenu->CheckMenuItem(ID_VIEW_SHOWPATH, MF_BYCOMMAND | MF_UNCHECKED );\n\t\tif ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_WATER )\n\t\t\tpMenu->CheckMenuItem(ID_VIEW_SHOWWATER, MF_BYCOMMAND | MF_UNCHECKED );\n\t\tif ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_WORLD )\n\t\t\tpMenu->CheckMenuItem(ID_VIEW_SHOWWORLD, MF_BYCOMMAND | MF_UNCHECKED );\n\t\tif ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_CLIP )\n\t\t\tpMenu->CheckMenuItem(ID_VIEW_SHOWCLIP, MF_BYCOMMAND | MF_UNCHECKED );\n\t\tif ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_HINT )\n\t\t\tpMenu->CheckMenuItem(ID_VIEW_SHOWHINT, MF_BYCOMMAND | MF_UNCHECKED );\n\t\tif ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_CAULK )\n\t\t\tpMenu->CheckMenuItem(ID_VIEW_SHOWCAULK, MF_BYCOMMAND | MF_UNCHECKED );\n\t\tif ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_ANGLES )\n\t\t\tpMenu->CheckMenuItem(ID_VIEW_SHOWANGLES, MF_BYCOMMAND | MF_UNCHECKED );\n\n\n    pMenu->CheckMenuItem(ID_TOGGLE_LOCK, MF_BYCOMMAND | (g_PrefsDlg.m_bTextureLock) ? MF_CHECKED : MF_UNCHECKED);\n    pMenu->CheckMenuItem(ID_TOGGLE_ROTATELOCK, MF_BYCOMMAND | (g_PrefsDlg.m_bRotateLock) ? MF_CHECKED : MF_UNCHECKED);\n    pMenu->CheckMenuItem(ID_VIEW_CUBICCLIPPING, MF_BYCOMMAND | (g_PrefsDlg.m_bCubicClipping) ? MF_CHECKED : MF_UNCHECKED);\n    pMenu->CheckMenuItem (ID_VIEW_OPENGLLIGHTING, MF_BYCOMMAND | (g_PrefsDlg.m_bGLLighting) ? MF_CHECKED : MF_UNCHECKED );\n    pMenu->CheckMenuItem (ID_SNAPTOGRID, MF_BYCOMMAND | (!g_PrefsDlg.m_bNoClamp) ? MF_CHECKED : MF_UNCHECKED );\n    if (m_wndToolBar.GetSafeHwnd())\n      m_wndToolBar.GetToolBarCtrl().CheckButton(ID_VIEW_CUBICCLIPPING, (g_PrefsDlg.m_bCubicClipping) ? TRUE : FALSE);\n\n    int n = g_PrefsDlg.m_nTextureScale;\n    int id;\n    switch (n)\n    {\n      case 10 : id = ID_TEXTURES_TEXTUREWINDOWSCALE_10; break;\n      case 25 : id = ID_TEXTURES_TEXTUREWINDOWSCALE_25; break;\n      case 50 : id = ID_TEXTURES_TEXTUREWINDOWSCALE_50; break;\n      case 200 : id = ID_TEXTURES_TEXTUREWINDOWSCALE_200; break;\n      default : id = ID_TEXTURES_TEXTUREWINDOWSCALE_100; break;\n    }\n    CheckTextureScale(id);\n\n\n\t}\n  if (g_qeglobals.d_project_entity)\n  {\n    FillTextureMenu();      // redundant but i'll clean it up later.. yeah right.. \n\t  FillBSPMenu();\n\t  LoadMruInReg(g_qeglobals.d_lpMruMenu,\"Software\\\\id\\\\QuakeEd4\\\\MRU\");\n    PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu,::GetSubMenu(::GetMenu(GetSafeHwnd()),0), ID_FILE_EXIT);\n  }\n}\n\nvoid CMainFrame::ShowMenuItemKeyBindings(CMenu *pMenu)\n{\n\tint i, j;\n\tchar key[1024], *ptr;\n\tMENUITEMINFO MenuItemInfo;\n\n\t//return;\n\tfor (i = 0; i < g_nCommandCount; i++)\n\t{\n\t\tmemset(&MenuItemInfo, 0, sizeof(MENUITEMINFO));\n\t\tMenuItemInfo.cbSize = sizeof(MENUITEMINFO);\n\t\tMenuItemInfo.fMask = MIIM_TYPE;\n\t\tMenuItemInfo.dwTypeData = key;\n\t\tMenuItemInfo.cch = sizeof(key);\n\t\tif (!pMenu->GetMenuItemInfo(g_Commands[i].m_nCommand, &MenuItemInfo))\n\t\t\tcontinue;\n\t\tif (MenuItemInfo.fType != MFT_STRING)\n\t\t\tcontinue;\n\t\tptr = strchr(key, '\\t');\n\t\tif (ptr) *ptr = '\\0';\n\t\tstrcat(key, \"\\t\");\n\t\tif (g_Commands[i].m_nModifiers)     // are there modifiers present?\n\t\t{\n\t\t\tif (g_Commands[i].m_nModifiers & RAD_SHIFT)\n\t\t\t\tstrcat(key, \"Shift-\");\n\t\t\tif (g_Commands[i].m_nModifiers & RAD_ALT)\n\t\t\t\tstrcat(key, \"Alt-\");\n\t\t\tif (g_Commands[i].m_nModifiers & RAD_CONTROL)\n\t\t\t\tstrcat(key, \"Ctrl-\");\n\t\t}\n\t\tfor (j = 0; j < g_nKeyCount; j++)\n\t\t{\n\t\t\tif (g_Commands[i].m_nKey == g_Keys[j].m_nVKKey)\n\t\t\t{\n\t\t\t\tstrcat(key, g_Keys[j].m_strName);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (j >= g_nKeyCount)\n\t\t{\n\t\t\tsprintf(&key[strlen(key)], \"%c\", g_Commands[i].m_nKey);\n\t\t}\n\t\tmemset(&MenuItemInfo, 0, sizeof(MENUITEMINFO));\n\t\tMenuItemInfo.cbSize = sizeof(MENUITEMINFO);\n\t\tMenuItemInfo.fMask = MIIM_TYPE;\n\t\tMenuItemInfo.fType = MFT_STRING;\n\t\tMenuItemInfo.dwTypeData = key;\n\t\tMenuItemInfo.cch = strlen(key);\n\t\tSetMenuItemInfo(pMenu->m_hMenu, g_Commands[i].m_nCommand, FALSE, &MenuItemInfo);\n\t}\n}\n\nint CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)\n{\n\n  //Init3Dfx();\n\n  char* pBuffer = g_strAppPath.GetBufferSetLength(_MAX_PATH + 1);\n  int nResult = ::GetModuleFileName(NULL, pBuffer, _MAX_PATH);\n  ASSERT(nResult != 0);\n  pBuffer[g_strAppPath.ReverseFind('\\\\') + 1] = '\\0';\n  g_strAppPath.ReleaseBuffer();\n\n  InitCommonControls ();\n\tg_qeglobals.d_hInstance = AfxGetInstanceHandle();\n  MFCCreate(AfxGetInstanceHandle());\n\n  //g_PrefsDlg.LoadPrefs();\n  \n  if (CFrameWnd::OnCreate(lpCreateStruct) == -1)\n\t\treturn -1;\n\n  UINT nStyle;\n  UINT nID = (g_PrefsDlg.m_bWideToolbar) ? IDR_TOOLBAR_ADVANCED : IDR_TOOLBAR1;\n\n\tif (!m_wndToolBar.Create(this) ||\n\t\t!m_wndToolBar.LoadToolBar(nID))\n\t{\n\t\tTRACE0(\"Failed to create toolbar\\n\");\n\t\treturn -1;      // fail to create\n\t}\n\n\tif (!m_wndStatusBar.Create(this) ||\n\t\t!m_wndStatusBar.SetIndicators(indicators,\n\t\t  sizeof(indicators)/sizeof(UINT)))\n\t{\n\t\tTRACE0(\"Failed to create status bar\\n\");\n\t\treturn -1;      // fail to create\n\t}\n\n#if 0\n\tif (!m_wndScaleBar.Create(this) ||\n\t\t!m_wndScaleBar.LoadToolBar(IDR_TOOLBAR_SCALELOCK))\n\t{\n\t\tTRACE0(\"Failed to create scaling toolbar\\n\");\n\t\treturn -1;      // fail to create\n\t}\n#endif\n\n\t// TODO: Remove this if you don't want tool tips or a resizeable toolbar\n\tm_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |\n\t\tCBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);\n\n\t// TODO: Delete these three lines if you don't want the toolbar to\n\t//  be dockable\n\tm_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);\n\tEnableDocking(CBRS_ALIGN_ANY);\n\tDockControlBar(&m_wndToolBar);\n\n\t//m_wndScaleBar.SetBarStyle(m_wndScaleBar.GetBarStyle() |\tCBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);\n\t//m_wndScaleBar.EnableDocking(CBRS_ALIGN_ANY);\n  //m_wndScaleBar.ShowWindow(SW_HIDE);\n\n  int nImage;\n  int nIndex = m_wndToolBar.CommandToIndex(ID_VIEW_CAMERATOGGLE);\n  if (nIndex >= 0)\n  {\n    m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);\n    m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);\n    m_wndToolBar.GetToolBarCtrl().CheckButton(nID);\n  }\n  m_bCamPreview = true;\n\n  nIndex = m_wndToolBar.CommandToIndex(ID_VIEW_CUBICCLIPPING);\n  if (nIndex >= 0)\n  {\n    m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);\n    m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);\n  }\n  nIndex = m_wndToolBar.CommandToIndex(ID_VIEW_ENTITY);\n  if (nIndex >= 0)\n  {\n    m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);\n    m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);\n  }\n  nIndex = m_wndToolBar.CommandToIndex(ID_VIEW_CLIPPER);\n  if (nIndex >= 0)\n  {\n    m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);\n    m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);\n  }\n  nIndex = m_wndToolBar.CommandToIndex(ID_SELECT_MOUSEROTATE);\n  if (nIndex >= 0)\n  {\n    m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);\n    m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);\n  }\n\n  nIndex = m_wndToolBar.CommandToIndex(ID_SELECT_MOUSESCALE);\n  if (nIndex >= 0)\n  {\n    m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);\n    m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);\n  }\n\n  nIndex = m_wndToolBar.CommandToIndex(ID_SCALELOCKX);\n  if (nIndex >= 0)\n  {\n    m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);\n    m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);\n    m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKX, FALSE);\n  }\n\n  nIndex = m_wndToolBar.CommandToIndex(ID_SCALELOCKY);\n  if (nIndex >= 0)\n  {\n    m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);\n    m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);\n    m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKY, FALSE);\n  }\n\n  nIndex = m_wndToolBar.CommandToIndex(ID_SCALELOCKZ);\n  if (nIndex >= 0)\n  {\n    m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);\n    m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);\n    m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKZ, FALSE);\n  }\n\n#ifdef QUAKE3\n  nIndex = m_wndToolBar.CommandToIndex(ID_DONTSELECTCURVE);\n  if (nIndex >= 0)\n  {\n    m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);\n    m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);\n  }\n  nIndex = m_wndToolBar.CommandToIndex(ID_PATCH_SHOWBOUNDINGBOX);\n  if (nIndex >= 0)\n  {\n    m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);\n    m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);\n    m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_SHOWBOUNDINGBOX, TRUE);\n  }\n  nIndex = m_wndToolBar.CommandToIndex(ID_PATCH_WELD);\n  if (nIndex >= 0)\n  {\n    m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);\n    m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);\n    m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_WELD, TRUE);\n  }\n  nIndex = m_wndToolBar.CommandToIndex(ID_PATCH_DRILLDOWN);\n  if (nIndex >= 0)\n  {\n    m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);\n    m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);\n    m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_DRILLDOWN, TRUE);\n  }\n  nIndex = m_wndToolBar.CommandToIndex(ID_PATCH_BEND);\n  if (nIndex >= 0)\n  {\n    m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);\n    m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);\n  }\n  nIndex = m_wndToolBar.CommandToIndex(ID_PATCH_INSDEL);\n  if (nIndex >= 0)\n  {\n    m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);\n    m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);\n  }\n#else\n  m_wndToolBar.GetToolBarCtrl().HideButton(ID_DONTSELECTCURVE);\n  m_wndToolBar.GetToolBarCtrl().HideButton(ID_PATCH_SHOWBOUNDINGBOX);\n  m_wndToolBar.GetToolBarCtrl().HideButton(ID_PATCH_WELD);\n  m_wndToolBar.GetToolBarCtrl().HideButton(ID_PATCH_WIREFRAME);\n#endif\n  g_nScaleHow = 0;\n\n\n#ifdef QUAKE3\n  g_pParentWnd->GetMenu()->DestroyMenu();\n  CMenu* pMenu = new CMenu();\n  pMenu->LoadMenu(IDR_MENU_QUAKE3);\n  g_pParentWnd->SetMenu(pMenu);\n#else\n  CMenu* pMenu = GetMenu();\n#endif\n\n  m_wndTextureBar.Create(this, IDD_TEXTUREBAR, CBRS_BOTTOM, 7433);\n  m_wndTextureBar.EnableDocking(CBRS_ALIGN_ANY);\n  DockControlBar(&m_wndTextureBar);\n \n  g_qeglobals.d_lpMruMenu = CreateMruMenuDefault();\n\n  m_bAutoMenuEnable = FALSE;\n\n  LoadCommandMap();\n\n  ShowMenuItemKeyBindings(pMenu);\n\n  CFont* pFont = new CFont();\n  pFont->CreatePointFont(g_PrefsDlg.m_nStatusSize * 10, \"Arial\");\n  m_wndStatusBar.SetFont(pFont);\n\n\tOnPluginsRefresh();\n\n  if (g_PrefsDlg.m_bRunBefore == FALSE)\n  {\n    g_PrefsDlg.m_bRunBefore = TRUE;\n    g_PrefsDlg.SavePrefs();\n/*\n    if (MessageBox(\"Would you like QERadiant to build and load a default project? If this is the first time you have run QERadiant or you are not familiar with editing QE4 project files directly, this is HIGHLY recommended\", \"Create a default project?\", MB_YESNO) == IDYES)\n    {\n      OnFileNewproject();\n    }\n*/\n  }\n  else\n  {\n    // hack that keeps SGI OpenGL from crashing on texture load with no map\n#if 0\n    if (g_PrefsDlg.m_bSGIOpenGL)\n    {\n      vec3_t vMin, vMax;\n      vMin[0] = vMin[1] = vMin[2] = 0;\n      vMax[0] = vMax[1] = vMax[2] = 8;\n      brush_t* pBrush = Brush_Create(vMin, vMax, &g_qeglobals.d_texturewin.texdef);\n\t    Entity_LinkBrush (world_entity, pBrush);\n      Brush_Build(pBrush);\n\t    Brush_AddToList (pBrush, &active_brushes);\n      Select_Brush(pBrush);\n      Sys_UpdateWindows(W_ALL);\n      PostMessage(WM_COMMAND, ID_SELECTION_DELETE, 0); \n    }\n#endif\n\t  // load plugins before the first Map_LoadFile\n\t  // required for model plugins\n    if (g_PrefsDlg.m_bLoadLastMap && g_PrefsDlg.m_strLastMap.GetLength() > 0)\n      Map_LoadFile(g_PrefsDlg.m_strLastMap.GetBuffer(0));\n  }\n\n  SetGridStatus();\n  SetTexValStatus();\n  SetButtonMenuStates();\n  LoadBarState(\"RadiantToolBars2\");\n  if (!g_PrefsDlg.m_bTextureBar)\n    ShowControlBar(&m_wndTextureBar, FALSE, TRUE);\n  else\n    ShowControlBar(&m_wndTextureBar, TRUE, TRUE);\n\n  ShowControlBar(&m_wndToolBar, (m_wndToolBar.GetStyle() & WS_VISIBLE), TRUE);\n\n  SetActiveXY(m_pXYWnd);\n  m_pXYWnd->SetFocus();\n\n  PostMessage(WM_KEYDOWN, 'O', NULL);\n\n  return 0;\n}\n\nvoid CMainFrame::LoadCommandMap()\n{\n  CString strINI;\n  char* pBuff = new char[1024];\n  if (g_PrefsDlg.m_strUserPath.GetLength() > 0)\n    strINI = g_PrefsDlg.m_strUserPath;\n  else\n  {\n    strINI = g_strAppPath;\n    strINI += \"\\\\radiant.ini\";\n  }\n\n  for (int i = 0; i < g_nCommandCount; i++)\n  {\n    int nLen = GetPrivateProfileString(\"Commands\", g_Commands[i].m_strCommand, \"\", pBuff, 1024, strINI);\n    if (nLen > 0)\n    {\n      CString strBuff = pBuff;\n      strBuff.TrimLeft();\n      strBuff.TrimRight();\n      int nSpecial = strBuff.Find(\"+alt\");\n      g_Commands[i].m_nModifiers = 0;\n      if (nSpecial >= 0)\n      {\n        g_Commands[i].m_nModifiers |= RAD_ALT;\n        FindReplace(strBuff, \"+alt\", \"\");\n      }\n      nSpecial = strBuff.Find(\"+ctrl\");\n      if (nSpecial >= 0)\n      {\n        g_Commands[i].m_nModifiers |= RAD_CONTROL;\n        FindReplace(strBuff, \"+ctrl\", \"\");\n      }\n      nSpecial = strBuff.Find(\"+shift\");\n      if (nSpecial >= 0)\n      {\n        g_Commands[i].m_nModifiers |= RAD_SHIFT;\n        FindReplace(strBuff, \"+shift\", \"\");\n      }\n      strBuff.TrimLeft();\n      strBuff.TrimRight();\n      strBuff.MakeUpper();\n      if (nLen == 1) // most often case.. deal with first\n      {\n        g_Commands[i].m_nKey = __toascii(strBuff.GetAt(0));\n      }\n      else // special key\n      {\n        for (int j = 0; j < g_nKeyCount; j++)\n        {\n          if (strBuff.CompareNoCase(g_Keys[j].m_strName) == 0)\n          {\n            g_Commands[i].m_nKey = g_Keys[j].m_nVKKey;\n            break;\n          }\n        }\n      }\n    }\n  }\n  delete []pBuff;\n}\n\nBOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)\n{\n\t// TODO: Modify the Window class or styles here by modifying\n\t//  the CREATESTRUCT cs\n\treturn CFrameWnd::PreCreateWindow(cs);\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// CMainFrame diagnostics\n\n#ifdef _DEBUG\nvoid CMainFrame::AssertValid() const\n{\n\tCFrameWnd::AssertValid();\n}\n\nvoid CMainFrame::Dump(CDumpContext& dc) const\n{\n\tCFrameWnd::Dump(dc);\n}\n\n#endif //_DEBUG\n\n/////////////////////////////////////////////////////////////////////////////\n// CMainFrame message handlers\nvoid CMainFrame::CreateQEChildren()\n{\n\t// the project file can be specified on the command line,\n\t// or implicitly found in the scripts directory\n  bool bProjectLoaded = false;\n\tif (AfxGetApp()->m_lpCmdLine && strlen(AfxGetApp()->m_lpCmdLine))\n\t{\n\t\tParseCommandLine (AfxGetApp()->m_lpCmdLine);\n\t\tbProjectLoaded = QE_LoadProject(argv[1]);\n\t}\n\telse \n  {\n    if (g_PrefsDlg.m_bLoadLast && g_PrefsDlg.m_strLastProject.GetLength() > 0)\n    {\n\t    bProjectLoaded = QE_LoadProject(g_PrefsDlg.m_strLastProject.GetBuffer(0));\n    }\n    if (!bProjectLoaded)\n    {\n      CString str = g_strAppPath;\n      AddSlash(str);\n      str += \"../baseq3/scripts/quake.qe4\";\n      char cWork[1024];\n      char *pFile = NULL;\n      GetFullPathName(str, 1024, cWork, &pFile);\n      bProjectLoaded = QE_LoadProject(cWork);\n    }\n    if (!bProjectLoaded)\n    {\n      bProjectLoaded = QE_LoadProject(\"scripts/quake.qe4\");\n    }\n  }\n\n  if (!bProjectLoaded)\n  {\n#if 0\n    // let's try the default project directory..\n    char* pBuff = new char[1024];\n    ::GetCurrentDirectory(1024, pBuff);\n    CString strDefProj = g_strAppPath;\n    AddSlash(strDefProj);\n    strDefProj += \"defproj\";\n    if (::SetCurrentDirectory(strDefProj))\n    {\n\t    bProjectLoaded = QE_LoadProject(\"scripts/quake.qe4\");\n      if (bProjectLoaded)\n      {\n        // setup auto load stuff for the default map\n        g_PrefsDlg.m_bLoadLast = TRUE;\n        AddSlash(strDefProj);\n        strDefProj += \"maps\\\\defproj.map\";\n        g_PrefsDlg.m_strLastMap = strDefProj;\n        g_PrefsDlg.SavePrefs();\n      }\n    }\n    else\n    {\n      ::SetCurrentDirectory(pBuff);\n    }\n    delete []pBuff;\n#endif\n\n    if (!bProjectLoaded)\n    {\n      Sys_Printf (\"Using default.qe4. You may experience problems. See the readme.txt\\n\");\n      CString strProj = g_strAppPath;\n      strProj += \"\\\\default.qe4\";\n      bProjectLoaded = QE_LoadProject(strProj.GetBuffer(0));\n\n      if (!bProjectLoaded)\n      {\n        CFileDialog dlgFile(true, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, \"Q3Radiant Project files (*.qe4, *.prj)|*.qe4|*.prj||\", this);\n        if (dlgFile.DoModal() == IDOK)\n          bProjectLoaded = QE_LoadProject(dlgFile.GetPathName().GetBuffer(0));\n      }\n    }\n  }\n\n  if (!bProjectLoaded)\n    Error(\"Unable to load project file. It was unavailable in the scripts path and the default could not be found\");\n\n\n  if (g_PrefsDlg.m_bPAK == TRUE)\n  {\n    // FIXME: pay attention to Q3 pref\n    //InitPakFile(ValueForKey(g_qeglobals.d_project_entity, \"basepath\"), g_PrefsDlg.m_strPAKFile);\n    InitPakFile(ValueForKey(g_qeglobals.d_project_entity, \"basepath\"), NULL);\n  }\n\n\tQE_Init ();\n  \n\tSys_Printf (\"Entering message loop\\n\");\n\n  m_bDoLoop = true;\n\tSetTimer(QE_TIMER0, 1000, NULL);\n\n}\n\nBOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam) \n{\n\treturn CFrameWnd::OnCommand(wParam, lParam);\n}\n\nLRESULT CMainFrame::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) \n{\n  RoutineProcessing();\n\treturn CFrameWnd::DefWindowProc(message, wParam, lParam);\n}\n\n\nvoid CMainFrame::RoutineProcessing()\n{\n  if (m_bDoLoop)\n  {\n\t  double time = 0.0;\n    double oldtime = 0.0;\n    double delta= 0.0;\n\n    CheckBspProcess ();\n\t  time = Sys_DoubleTime ();\n\t  delta = time - oldtime;\n\t  oldtime = time;\n\t  if (delta > 0.2)\n\t\t  delta = 0.2;\n\t  \n    // run time dependant behavior\n    if (m_pCamWnd)\n\t    m_pCamWnd->Cam_MouseControl(delta);\n\n    if (g_PrefsDlg.m_bQE4Painting && g_nUpdateBits)\n    {\n      int nBits = g_nUpdateBits;      // this is done to keep this routine from being\n      g_nUpdateBits = 0;              // re-entered due to the paint process.. only\n      UpdateWindows(nBits);           // happens in rare cases but causes a stack overflow\n    }\n\n  }\n}\n\nLRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) \n{\n\treturn CFrameWnd::WindowProc(message, wParam, lParam);\n}\n\nbool MouseDown()\n{\n  if (::GetAsyncKeyState(VK_LBUTTON))\n    return true;\n  if (::GetAsyncKeyState(VK_RBUTTON))\n    return true;\n  if (::GetAsyncKeyState(VK_MBUTTON))\n    return true;\n  return false;\n}\n\n\nvoid CMainFrame::OnTimer(UINT nIDEvent) \n{\n  if (!MouseDown())\n  {\n    QE_CountBrushesAndUpdateStatusBar();\n    QE_CheckAutoSave();\n  }\n}\nstruct SplitInfo\n{\n  int m_nMin;\n  int m_nCur;\n};\n\nbool LoadWindowPlacement(HWND hwnd, const char* pName)\n{\n  WINDOWPLACEMENT wp;\n  wp.length = sizeof(WINDOWPLACEMENT);\n\tLONG lSize = sizeof(wp);\n\tif (LoadRegistryInfo(pName, &wp, &lSize))\n  {\n    ::SetWindowPlacement(hwnd, &wp);\n    return true;\n  }\n  return false;\n}\n\nvoid SaveWindowPlacement(HWND hwnd, const char* pName)\n{\n  WINDOWPLACEMENT wp;\n  wp.length = sizeof(WINDOWPLACEMENT);\n  if (::GetWindowPlacement(hwnd, &wp))\n  {\n\t  SaveRegistryInfo(pName, &wp, sizeof(wp));\n  }\n}\n\n\nvoid CMainFrame::OnDestroy() \n{\n  KillTimer(QE_TIMER0);\n\n  SaveBarState(\"RadiantToolBars2\");\n\n  // FIXME\n  // original mru stuff needs replaced with mfc stuff\n\tSaveMruInReg(g_qeglobals.d_lpMruMenu,\"Software\\\\id\\\\QuakeEd4\\\\MRU\");\n\n\tDeleteMruMenu(g_qeglobals.d_lpMruMenu);\n\n  SaveWindowPlacement(GetSafeHwnd(), \"Radiant::MainWindowPlace\");\n  //SaveWindowState(GetSafeHwnd(), \"Radiant::MainWindow\");\n  //if (m_nCurrentStyle == QR_QE4)\n    //SaveWindowPlacement(g_qeglobals.d_hwndEntity, \"EntityWindowPlace\");\n\n  if (m_nCurrentStyle == 0 || m_nCurrentStyle == 3)\n  {\n    SaveWindowState(m_wndSplit.GetSafeHwnd(), \"Radiant::Split\");\n    SaveWindowState(m_wndSplit2.GetSafeHwnd(), \"Radiant::Split2\");\n    SaveWindowState(m_wndSplit3.GetSafeHwnd(), \"Radiant::Split3\");\n\n    SplitInfo spinfo;\n    m_wndSplit.GetRowInfo(0, spinfo.m_nCur, spinfo.m_nMin);\n\t  SaveRegistryInfo(\"Radiant::Split::Row_0\", &spinfo, sizeof(spinfo));\n    m_wndSplit.GetRowInfo(1, spinfo.m_nCur, spinfo.m_nMin);\n\t  SaveRegistryInfo(\"Radiant::Split::Row_1\", &spinfo, sizeof(spinfo));\n\n    m_wndSplit2.GetColumnInfo(0, spinfo.m_nCur, spinfo.m_nMin);\n\t  SaveRegistryInfo(\"Radiant::Split2::Col_0\", &spinfo, sizeof(spinfo));\n    m_wndSplit2.GetColumnInfo(1, spinfo.m_nCur, spinfo.m_nMin);\n\t  SaveRegistryInfo(\"Radiant::Split2::Col_1\", &spinfo, sizeof(spinfo));\n    m_wndSplit2.GetColumnInfo(2, spinfo.m_nCur, spinfo.m_nMin);\n\t  SaveRegistryInfo(\"Radiant::Split2::Col_2\", &spinfo, sizeof(spinfo));\n\n    m_wndSplit3.GetRowInfo(0, spinfo.m_nCur, spinfo.m_nMin);\n\t  SaveRegistryInfo(\"Radiant::Split3::Row_0\", &spinfo, sizeof(spinfo));\n    m_wndSplit3.GetRowInfo(1, spinfo.m_nCur, spinfo.m_nMin);\n\t  SaveRegistryInfo(\"Radiant::Split3::Row_1\", &spinfo, sizeof(spinfo));\n  }\n  else \n  {\n    SaveWindowPlacement(m_pXYWnd->GetSafeHwnd(), \"xywindow\");\n    SaveWindowPlacement(m_pXZWnd->GetSafeHwnd(), \"xzwindow\");\n    SaveWindowPlacement(m_pYZWnd->GetSafeHwnd(), \"yzwindow\");\n\t  SaveWindowPlacement(m_pCamWnd->GetSafeHwnd(), \"camerawindow\");\n\t  SaveWindowPlacement(m_pZWnd->GetSafeHwnd(), \"zwindow\");\n\t  SaveWindowState(m_pTexWnd->GetSafeHwnd(), \"texwindow\");\n\t  SaveWindowState(m_pEditWnd->GetSafeHwnd(), \"editwindow\");\n  }\n\n  if (m_pXYWnd->GetSafeHwnd())\n    m_pXYWnd->SendMessage(WM_DESTROY, 0, 0);\n  delete m_pXYWnd; m_pXYWnd = NULL;\n  \n  if (m_pYZWnd->GetSafeHwnd())\n    m_pYZWnd->SendMessage(WM_DESTROY, 0, 0);\n  delete m_pYZWnd; m_pYZWnd = NULL;\n  \n  if (m_pXZWnd->GetSafeHwnd())\n    m_pXZWnd->SendMessage(WM_DESTROY, 0, 0);\n  delete m_pXZWnd; m_pXZWnd = NULL;\n  \n  if (m_pZWnd->GetSafeHwnd())\n    m_pZWnd->SendMessage(WM_DESTROY, 0, 0);\n  delete m_pZWnd; m_pZWnd = NULL;\n  \n  if (m_pTexWnd->GetSafeHwnd())\n    m_pTexWnd->SendMessage(WM_DESTROY, 0, 0);\n  delete m_pTexWnd; m_pTexWnd = NULL;\n  \n  if (m_pEditWnd->GetSafeHwnd())\n    m_pEditWnd->SendMessage(WM_DESTROY, 0, 0);\n  delete m_pEditWnd; m_pEditWnd = NULL;\n\n  if (m_pCamWnd->GetSafeHwnd())\n    m_pCamWnd->SendMessage(WM_DESTROY, 0, 0);\n  delete m_pCamWnd;m_pCamWnd = NULL;\n\n\tSaveRegistryInfo(\"SavedInfo\", &g_qeglobals.d_savedinfo, sizeof(g_qeglobals.d_savedinfo));\n\n  if (strcmpi(currentmap, \"unnamed.map\") != 0)\n  {\n    g_PrefsDlg.m_strLastMap = currentmap;\n    g_PrefsDlg.SavePrefs();\n  }\n  CleanUpEntities();\n\n  while (active_brushes.next != &active_brushes)\n\t  Brush_Free (active_brushes.next, false);\n\twhile (selected_brushes.next != &selected_brushes)\n\t\tBrush_Free (selected_brushes.next, false);\n\twhile (filtered_brushes.next != &filtered_brushes)\n\t\tBrush_Free (filtered_brushes.next, false);\n\n\twhile (entities.next != &entities)\n\t\tEntity_Free (entities.next);\n\n\tepair_t* pEPair = g_qeglobals.d_project_entity->epairs;\n  while (pEPair)\n  {\n    epair_t* pNextEPair = pEPair->next;\n    free (pEPair->key);\n    free (pEPair->value);\n    free (pEPair);\n    pEPair = pNextEPair;\n  }\n\n\tentity_t* pEntity = g_qeglobals.d_project_entity->next;\n  while (pEntity != NULL && pEntity != g_qeglobals.d_project_entity)\n  {\n    entity_t* pNextEntity = pEntity->next;\n    Entity_Free(pEntity);\n    pEntity = pNextEntity;\n  }\n\n  Texture_Cleanup();\n\n  if (world_entity)\n    Entity_Free(world_entity);\n\n  if (notexture)\n  {\n  // Timo\n  // Surface properties plugin\n#ifdef _DEBUG\n  if ( !notexture->pData )\n\t  Sys_Printf(\"WARNING: found a qtexture_t* with no IPluginQTexture\\n\");\n#endif\n  if ( notexture->pData )\n\tGETPLUGINTEXDEF(notexture)->DecRef();\n\n    free(notexture);\n  }\n\n  //if (current_texture)\n  //  free(current_texture);\n  ClosePakFile();\n\n  FreeShaders();\n\n\tCFrameWnd::OnDestroy();\n}\n\nvoid CMainFrame::OnClose() \n{\n\tif (ConfirmModified())\n\t{\n\t\tCFrameWnd::OnClose();\n\t}\n}\n                        \nvoid CMainFrame::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) \n{\n  // run through our list to see if we have a handler for nChar\n  //\n  for (int i = 0; i < g_nCommandCount; i++)\n  {\n    if (g_Commands[i].m_nKey == nChar)    // find a match?\n    {\n      bool bGo = true;\n      if (g_Commands[i].m_nModifiers & RAD_PRESS)\n      {\n        int nModifiers = g_Commands[i].m_nModifiers & ~RAD_PRESS;\n        if (nModifiers)     // are there modifiers present?\n        {\n          if (nModifiers & RAD_ALT)\n            if (!(GetKeyState(VK_MENU) & 0x8000))\n              bGo = false;\n          if (nModifiers & RAD_CONTROL)\n            if (!(GetKeyState(VK_CONTROL) & 0x8000))\n              bGo = false;\n          if (nModifiers & RAD_SHIFT)\n            if (!(GetKeyState(VK_SHIFT) & 0x8000))\n              bGo = false;\n        }\n        else  // no modifiers make sure none of those keys are pressed\n        {\n          if (GetKeyState(VK_MENU) & 0x8000)\n            bGo = false;\n          if (GetKeyState(VK_CONTROL) & 0x8000)\n            bGo = false;\n          if (GetKeyState(VK_SHIFT) & 0x8000)\n            bGo = false;\n        }\n        if (bGo)\n        {\n          SendMessage(WM_COMMAND, g_Commands[i].m_nCommand, 0);\n          break;\n        }\n      }\n    }\n  }\n}\n\nbool CamOK(unsigned int nKey)\n{\n  if (nKey == VK_UP || nKey == VK_LEFT || nKey == VK_RIGHT || nKey == VK_DOWN)\n  {\n    if (::GetAsyncKeyState(nKey))\n      return true;\n    else\n      return false;\n  }\n  return true;\n}\n\n\nvoid CMainFrame::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) \n{\n\t//OnKeyDown(nChar, nRepCnt, nFlags);\n  if (nChar == VK_DOWN)\n  {\n    OnKeyDown(nChar, nRepCnt, nFlags);\n  }\n\tCFrameWnd::OnSysKeyDown(nChar, nRepCnt, nFlags);\n}\n\nvoid CMainFrame::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) \n{\n    for (int i = 0; i < g_nCommandCount; i++)\n    {\n\t\tif (g_Commands[i].m_nKey == nChar)    // find a match?\n\t\t{\n\t\t\t// check modifiers\n\t\t\tunsigned int nState = 0;\n\t\t\tif (GetKeyState(VK_MENU) & 0x8000)\n\t\t\t\tnState |= RAD_ALT;\n\t\t\tif (GetKeyState(VK_CONTROL) & 0x8000)\n\t\t\t\tnState |= RAD_CONTROL;\n\t\t\tif (GetKeyState(VK_SHIFT) & 0x8000)\n\t\t\t\tnState |= RAD_SHIFT;\n\t\t\tif ((g_Commands[i].m_nModifiers & 0x7) == nState)\n\t\t\t{\n\t\t\t\tSendMessage(WM_COMMAND, g_Commands[i].m_nCommand, 0);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tCFrameWnd::OnKeyDown(nChar, nRepCnt, nFlags);\n}\n\nBOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) \n{\n\tg_qeglobals.d_hwndMain = GetSafeHwnd();\n\tg_qeglobals.d_hwndStatus = GetMessageBar()->GetSafeHwnd();\n\n/*\n  if (g_PrefsDlg.m_bRunBefore == FALSE)\n  {\n    MessageBox(\"In the following dialog, please make sure the Quake2 .exe information is correct.\\nQERadiant will NOT run correctly without this information\");\n    g_PrefsDlg.DoModal();\n  }\n*/\n\n  m_nCurrentStyle = g_PrefsDlg.m_nView;\n  \n  CreateEntityWindow(AfxGetInstanceHandle());\n\n  g_pGroupDlg->Create( IDD_DLG_GROUP, this);\n  g_qeglobals.d_hwndGroup = g_pGroupDlg->GetSafeHwnd();\n  ::SetParent(g_qeglobals.d_hwndGroup, g_qeglobals.d_hwndEntity);\n  g_pGroupDlg->ShowWindow(SW_SHOW);\n  \n  if (!LoadWindowPlacement(GetSafeHwnd(), \"Radiant::MainWindowPlace\"))\n  {\n    LoadWindowState(GetSafeHwnd(), \"Radiant::MainWindow\");\n  }\n  \n  //if (m_nCurrentStyle == QR_QE4)\n  //  LoadWindowPlacement(g_qeglobals.d_hwndEntity, \"EntityWindowPlace\");\n\n  CRect rect(5,25, 100, 100);\n  CRect rctParent;\n  GetClientRect(rctParent);\n\n  if (g_PrefsDlg.m_nView == 0 || g_PrefsDlg.m_nView == 3)\n  {\n    m_wndSplit.CreateStatic(this, 2, 1);\n    m_wndSplit2.CreateStatic(&m_wndSplit, 1, 3);\n    m_wndSplit3.CreateStatic(&m_wndSplit2, 2,1);\n\n    m_wndSplit.CreateView(1,0,RUNTIME_CLASS(CEditWnd), CSize(25, 100), pContext);\n    g_pEdit = dynamic_cast<CEdit*>(m_wndSplit.GetPane(1,0));\n    if (g_pEdit)\n\t    g_qeglobals.d_hwndEdit = g_pEdit->GetSafeHwnd();\n\n    m_wndSplit3.CreateView(0,0,RUNTIME_CLASS(CCamWnd), CSize(25, 100), pContext);\n    m_pCamWnd = dynamic_cast<CCamWnd*>(m_wndSplit3.GetPane(0,0));\n  \n    m_wndSplit2.CreateView(0,1,RUNTIME_CLASS(CXYWnd), CSize(25, 100), pContext);\n    m_pXYWnd = dynamic_cast<CXYWnd*>(m_wndSplit2.GetPane(0,1));\n    m_pXYWnd->SetViewType(XY);\n\n    m_pCamWnd->SetXYFriend(m_pXYWnd);\n\n    m_wndSplit2.CreateView(0,2,RUNTIME_CLASS(CZWnd), CSize(25, 100), pContext);\n    m_pZWnd = dynamic_cast<CZWnd*>(m_wndSplit2.GetPane(0,2));\n\n\t  m_wndSplit3.CreateView(1,0,RUNTIME_CLASS(CTexWnd), CSize(25, 100), pContext);\n    m_pTexWnd = dynamic_cast<CTexWnd*>(m_wndSplit3.GetPane(1,0));\n\n    CreateQEChildren();\n\n    if (g_PrefsDlg.m_nView == 0)\n    {\n      // the following bit switches the left and right views\n      CWnd* pRight = m_wndSplit2.GetPane(0,2);\n      long lRightID = ::GetWindowLong(pRight->GetSafeHwnd(), GWL_ID);\n      long lLeftID = ::GetWindowLong(m_wndSplit3.GetSafeHwnd(), GWL_ID);\n      ::SetWindowLong(pRight->GetSafeHwnd(), GWL_ID, lLeftID);\n      ::SetWindowLong(m_wndSplit3.GetSafeHwnd(), GWL_ID, lRightID);\n    }\n\n    m_wndSplit.SetRowInfo(0, rctParent.Height() * .85, 50);\n    m_wndSplit.SetRowInfo(1, rctParent.Height() * .15, 5);\n\n    float fLeft = (g_PrefsDlg.m_nView == 0) ? .05 : .25;\n    float fRight = (g_PrefsDlg.m_nView == 0) ? .25 : .05;\n    int nMin1 = (g_PrefsDlg.m_nView == 0) ? 10 : 25;\n    int nMin2 = (nMin1 == 10) ? 25 : 10;\n\n    m_wndSplit2.SetColumnInfo(0, rctParent.Width() * fLeft, nMin1);\n    m_wndSplit2.SetColumnInfo(1, rctParent.Width() * .70, 100);\n    m_wndSplit2.SetColumnInfo(2, rctParent.Width() * fRight, nMin2);\n\n    m_wndSplit3.SetRowInfo(1, (rctParent.Height() * .85) * .40, 15);\n    m_wndSplit3.SetRowInfo(0, (rctParent.Height() * .85) * .60, 15);\n\n    LoadWindowState(m_wndSplit.GetSafeHwnd(), \"Radiant::Split\");\n    LoadWindowState(m_wndSplit2.GetSafeHwnd(), \"Radiant::Split2\");\n    LoadWindowState(m_wndSplit3.GetSafeHwnd(), \"Radiant::Split3\");\n    ::ShowWindow(g_qeglobals.d_hwndEntity, SW_HIDE);\n\n    SplitInfo spinfo;\n    long lSize = sizeof(spinfo);\n\t  if (LoadRegistryInfo(\"Radiant::Split::Row_0\", &spinfo, &lSize))\n      m_wndSplit.SetRowInfo(0, spinfo.m_nCur, spinfo.m_nMin);\n\t  if (LoadRegistryInfo(\"Radiant::Split::Row_1\", &spinfo, &lSize))\n      m_wndSplit.SetRowInfo(1, spinfo.m_nCur, spinfo.m_nMin);\n\n\t  if (LoadRegistryInfo(\"Radiant::Split2::Col_0\", &spinfo, &lSize))\n      m_wndSplit2.SetColumnInfo(0, spinfo.m_nCur, spinfo.m_nMin);\n\t  if (LoadRegistryInfo(\"Radiant::Split2::Col_1\", &spinfo, &lSize))\n      m_wndSplit2.SetColumnInfo(1, spinfo.m_nCur, spinfo.m_nMin);\n\t  if (LoadRegistryInfo(\"Radiant::Split2::Col_2\", &spinfo, &lSize))\n      m_wndSplit2.SetColumnInfo(2, spinfo.m_nCur, spinfo.m_nMin);\n\n\t  if (LoadRegistryInfo(\"Radiant::Split3::Row_0\", &spinfo, &lSize))\n      m_wndSplit3.SetRowInfo(0, spinfo.m_nCur, spinfo.m_nMin);\n\t  if (LoadRegistryInfo(\"Radiant::Split3::Row_1\", &spinfo, &lSize))\n      m_wndSplit3.SetRowInfo(1, spinfo.m_nCur, spinfo.m_nMin);\n\n    m_wndSplit.RecalcLayout();\n    m_wndSplit2.RecalcLayout();\n    m_wndSplit3.RecalcLayout();\n  }\n  else if (g_PrefsDlg.m_nView == 1)\n  {\n    m_pCamWnd = new CCamWnd();\n    m_pCamWnd->Create(CAMERA_WINDOW_CLASS, \"\", QE3_CHILDSTYLE, rect, this, 1234);\n  \n    m_pZWnd = new CZWnd();\n    m_pZWnd->Create(Z_WINDOW_CLASS, \"\", QE3_CHILDSTYLE, rect, this, 1238);\n    \n    m_pXYWnd = new CXYWnd();\n    m_pXYWnd->Create(XY_WINDOW_CLASS, \"\", QE3_CHILDSTYLE, rect, this, 1235);\n    m_pXYWnd->SetViewType(XY);\n\n    m_pXZWnd = new CXYWnd();\n    m_pXZWnd->Create(XY_WINDOW_CLASS, \"\", QE3_CHILDSTYLE, rect, this, 1236);\n    m_pXZWnd->SetViewType(XZ);\n\n    m_pYZWnd = new CXYWnd();\n    m_pYZWnd->Create(XY_WINDOW_CLASS, \"\", QE3_CHILDSTYLE, rect, this, 1237);\n    m_pYZWnd->SetViewType(YZ);\n\n    m_pCamWnd->SetXYFriend(m_pXYWnd);\n\n    m_pTexWnd = new CTexWnd();\n    m_pTexWnd->Create(TEXTURE_WINDOW_CLASS, \"\", QE3_SPLITTER_STYLE, rect, this, 1239);\n    ::SetParent(m_pTexWnd->GetSafeHwnd(), g_qeglobals.d_hwndEntity);\n\n    CRect rctWork;\n    // XY and Z windows are 2 pixels off of the height and one down from top so one pixel spacing vertically\n    // Z window takes up 10% of right edge\n    // XY window takes up 60% of middle\n    // TEX and CAM windows take up 30% of left\n#if 0\n    int xTex = 1;\n    int xXY = 1 + xTex + ((float)rctParent.Width()) * .30;\n    int xZ = 1 + xXY + ((float)rctParent.Width()) * .60;\n    int yXY = 1;\n    int yTex = 1 + ((float)rctParent.Height()) * .45;\n    m_pXYWnd->SetWindowPos(NULL, xXY, yXY, ((float)rctParent.Width()) * .60, rctParent.Height() - 2, SWP_SHOWWINDOW);\n    m_pXZWnd->SetWindowPos(NULL, xXY, yXY, ((float)rctParent.Width()) * .60, rctParent.Height() - 2, SWP_SHOWWINDOW);\n    m_pYZWnd->SetWindowPos(NULL, xXY, yXY, ((float)rctParent.Width()) * .60, rctParent.Height() - 2, SWP_SHOWWINDOW);\n    m_pCamWnd->SetWindowPos(NULL, xTex, yXY, ((float)rctParent.Width()) *.30, ((float)rctParent.Height()) * .45, SWP_SHOWWINDOW);\n    m_pTexWnd->SetWindowPos(NULL, xTex, yTex, ((float)rctParent.Width()) *.30, ((float)rctParent.Height()) * .45, SWP_SHOWWINDOW);\n#endif\n\n    LoadWindowPlacement(m_pXYWnd->GetSafeHwnd(), \"xywindow\");\n    LoadWindowPlacement(m_pXZWnd->GetSafeHwnd(), \"xzwindow\");\n    LoadWindowPlacement(m_pYZWnd->GetSafeHwnd(), \"yzwindow\");\n\t  LoadWindowPlacement(m_pCamWnd->GetSafeHwnd(), \"camerawindow\");\n\t  LoadWindowPlacement(m_pZWnd->GetSafeHwnd(), \"zwindow\");\n    \n    if (!g_PrefsDlg.m_bXZVis)\n      m_pXZWnd->ShowWindow(SW_HIDE);\n    if (!g_PrefsDlg.m_bYZVis)\n      m_pYZWnd->ShowWindow(SW_HIDE);\n    if (!g_PrefsDlg.m_bZVis)\n      m_pZWnd->ShowWindow(SW_HIDE);\n\n    CreateQEChildren();\n  }\n  else // 4 way\n  {\n    m_wndSplit.CreateStatic(this, 2, 2);\n\n    m_wndSplit.CreateView(0,0,RUNTIME_CLASS(CCamWnd), CSize(25, 100), pContext);\n    m_pCamWnd = dynamic_cast<CCamWnd*>(m_wndSplit.GetPane(0,0));\n\n    m_wndSplit.CreateView(0,1,RUNTIME_CLASS(CXYWnd), CSize(25, 100), pContext);\n    m_pXYWnd = dynamic_cast<CXYWnd*>(m_wndSplit.GetPane(0,1));\n    m_pXYWnd->SetViewType(XY);\n\n    m_wndSplit.CreateView(1,0,RUNTIME_CLASS(CXYWnd), CSize(25, 100), pContext);\n    m_pYZWnd = dynamic_cast<CXYWnd*>(m_wndSplit.GetPane(1,0));\n    m_pYZWnd->SetViewType(YZ);\n\n    m_wndSplit.CreateView(1,1,RUNTIME_CLASS(CXYWnd), CSize(25, 100), pContext);\n    m_pXZWnd = dynamic_cast<CXYWnd*>(m_wndSplit.GetPane(1,1));\n    m_pXZWnd->SetViewType(XZ);\n\n    m_pCamWnd->SetXYFriend(m_pXYWnd);\n\n    m_pTexWnd = new CTexWnd();\n    m_pTexWnd->Create(TEXTURE_WINDOW_CLASS, \"\", QE3_SPLITTER_STYLE, rect, this, 1237);\n    ::SetParent(m_pTexWnd->GetSafeHwnd(), g_qeglobals.d_hwndEntity);\n\n    m_pZWnd = new CZWnd();\n    m_pZWnd->Create(Z_WINDOW_CLASS, \"\", QE3_CHILDSTYLE, rect, this, 1236);\n    m_pZWnd->ShowWindow(SW_HIDE);\n\n\n    //m_pEditWnd = new CRADEditWnd();\n    //m_pEditWnd->Create(NULL, \"Console\", QE3_STYLE, rect, this, 1238);\n    //g_pEdit = m_pEditWnd->GetEditWnd();\n    //if (g_pEdit)\n\t  //  g_qeglobals.d_hwndEdit = g_pEdit->GetSafeHwnd();\n\n\t  LoadWindowState(m_pTexWnd->GetSafeHwnd(), \"texwindow\");\n\t  LoadWindowState(m_pEditWnd->GetSafeHwnd(), \"editwindow\");\n    ::ShowWindow(g_qeglobals.d_hwndEntity, SW_HIDE);\n\n    CreateQEChildren();\n\n    CRect rctParent;\n    GetClientRect(rctParent);\n\n    m_wndSplit.SetRowInfo(0, rctParent.Height() * .5, 50);\n    m_wndSplit.SetRowInfo(1, rctParent.Height() * .5, 50);\n\n    m_wndSplit.SetColumnInfo(0, rctParent.Width() * .5, 50);\n    m_wndSplit.SetColumnInfo(1, rctParent.Width() * .5, 50);\n\n    LoadWindowState(m_wndSplit.GetSafeHwnd(), \"Radiant::SplitSPLIT\");\n\n    m_wndSplit.RecalcLayout();\n  }\n\n  if (g_pEdit)\n    g_pEdit->SendMessage(WM_SETFONT, (WPARAM)::GetStockObject(DEFAULT_GUI_FONT), (LPARAM)TRUE);\n\n\n  if (m_pXYWnd)\n    m_pXYWnd->SetActive(true);\n  m_bSplittersOK = true;\n\tTexture_SetMode(g_qeglobals.d_savedinfo.iTexMenu);\n\n  return TRUE;\n}\n\nCRect g_rctOld(0,0,0,0);\nvoid CMainFrame::OnSize(UINT nType, int cx, int cy) \n{\n\tCFrameWnd::OnSize(nType, cx, cy);\n\n  CRect rctParent;\n  GetClientRect(rctParent);\n\n  UINT nID;\n  UINT nStyle;\n  int nWidth;\n  if (m_wndStatusBar.GetSafeHwnd())\n  {\n    m_wndStatusBar.GetPaneInfo(0, nID, nStyle, nWidth);\n    m_wndStatusBar.SetPaneInfo(0, nID, nStyle, rctParent.Width() * .19);\n    m_wndStatusBar.GetPaneInfo(1, nID, nStyle, nWidth);\n    m_wndStatusBar.SetPaneInfo(1, nID, nStyle, rctParent.Width() * .19);\n    m_wndStatusBar.GetPaneInfo(2, nID, nStyle, nWidth);\n    m_wndStatusBar.SetPaneInfo(2, nID, nStyle, rctParent.Width() * .19);\n    m_wndStatusBar.GetPaneInfo(3, nID, nStyle, nWidth);\n    m_wndStatusBar.SetPaneInfo(3, nID, nStyle, rctParent.Width() * .19);\n    m_wndStatusBar.GetPaneInfo(4, nID, nStyle, nWidth);\n    m_wndStatusBar.SetPaneInfo(4, nID, nStyle, rctParent.Width() * .13);\n    m_wndStatusBar.GetPaneInfo(5, nID, nStyle, nWidth);\n    m_wndStatusBar.SetPaneInfo(5, nID, nStyle, rctParent.Width() * .01);\n  }\n\n  if (nType == SIZE_RESTORED && m_bSplittersOK && g_rctOld.Width() > 0)\n  {\n    if (m_nCurrentStyle == 0 || m_nCurrentStyle == 3)\n    {\n      SplitInfo spinfo;\n      m_wndSplit.GetRowInfo(0, spinfo.m_nCur, spinfo.m_nMin);\n      float fpc1 = (float)spinfo.m_nCur / g_rctOld.Height();\n      m_wndSplit.GetRowInfo(1, spinfo.m_nCur, spinfo.m_nMin);\n      float fpc2 = (float)spinfo.m_nCur / g_rctOld.Height();\n      m_wndSplit2.GetColumnInfo(0, spinfo.m_nCur, spinfo.m_nMin);\n      float fpc3 = (float)spinfo.m_nCur / g_rctOld.Width();\n      m_wndSplit2.GetColumnInfo(1, spinfo.m_nCur, spinfo.m_nMin);\n      float fpc4 = (float)spinfo.m_nCur / g_rctOld.Width();\n      m_wndSplit2.GetColumnInfo(2, spinfo.m_nCur, spinfo.m_nMin);\n      float fpc5 = (float)spinfo.m_nCur / g_rctOld.Width();\n      m_wndSplit3.GetRowInfo(0, spinfo.m_nCur, spinfo.m_nMin);\n      float fpc6 = (float)spinfo.m_nCur / g_rctOld.Height();\n      m_wndSplit3.GetRowInfo(1, spinfo.m_nCur, spinfo.m_nMin);\n      float fpc7 = (float)spinfo.m_nCur / g_rctOld.Height();\n\n      m_wndSplit.SetRowInfo(0, rctParent.Height() * fpc1, 100);\n      m_wndSplit.SetRowInfo(1, rctParent.Height() * fpc2, 25);\n\n      int nMin1 = (m_nCurrentStyle == 0) ? 10 : 25;\n      int nMin2 = (nMin1 == 10) ? 25 : 10;\n\n      m_wndSplit2.SetColumnInfo(0, rctParent.Width() * fpc3, nMin1);\n      m_wndSplit2.SetColumnInfo(1, rctParent.Width() * fpc4, 100);\n      m_wndSplit2.SetColumnInfo(2, rctParent.Width() * fpc5, nMin2);\n\n      m_wndSplit3.SetRowInfo(0, rctParent.Height() * fpc6, 50);\n      m_wndSplit3.SetRowInfo(1, rctParent.Height() * fpc7, 50);\n\n      m_wndSplit.RecalcLayout();\n      m_wndSplit2.RecalcLayout();\n      m_wndSplit3.RecalcLayout();\n    }\n  }\n\n\t\n}\n\n\nvoid OpenDialog (void);\nvoid SaveAsDialog (bool bRegion);\nvoid  Select_Ungroup (void);\n\nvoid CMainFrame::ToggleCamera()\n{\n  if (m_bCamPreview)\n    m_bCamPreview = false;\n  else\n    m_bCamPreview = true;\n}\n\nvoid CMainFrame::OnFileClose() \n{\n\t\n}\n\nvoid CMainFrame::OnFileExit() \n{\n\tPostMessage (WM_CLOSE, 0, 0L);\n}\n\nvoid CMainFrame::OnFileLoadproject() \n{\n\tif (ConfirmModified())\n\t\tProjectDialog ();\n}\n\nvoid CMainFrame::OnFileNew() \n{\n\tif (ConfirmModified())\n\t\tMap_New ();\n}\n\nvoid CMainFrame::OnFileOpen() \n{\n\tif (ConfirmModified())\n\t\tOpenDialog ();\n}\n\nvoid CMainFrame::OnFilePointfile() \n{\n\tif (g_qeglobals.d_pointfile_display_list)\n\t\tPointfile_Clear ();\n\telse\n\t\tPointfile_Check ();\n}\n\nvoid CMainFrame::OnFilePrint() \n{\n\t\n}\n\nvoid CMainFrame::OnFilePrintPreview() \n{\n\t\n}\n\nvoid CMainFrame::OnFileSave() \n{\n  if (!strcmp(currentmap, \"unnamed.map\"))\n  {\n\t  SaveAsDialog (false);\n  }\n\telse\n  {\n\t\tMap_SaveFile (currentmap, false);\n  }\n}\n\nvoid CMainFrame::OnFileSaveas() \n{\n  SaveAsDialog(false);\n}\n\nvoid CMainFrame::OnView100() \n{\n  if (m_pXYWnd)\n    m_pXYWnd->SetScale(1);\n  if (m_pXZWnd)\n    m_pXZWnd->SetScale(1);\n  if (m_pYZWnd)\n    m_pYZWnd->SetScale(1);\n\tSys_UpdateWindows (W_XY|W_XY_OVERLAY);\n}\n\nvoid CMainFrame::OnViewCenter() \n{\n  m_pCamWnd->Camera().angles[ROLL] = m_pCamWnd->Camera().angles[PITCH] = 0;\n\tm_pCamWnd->Camera().angles[YAW] = 22.5 * \n\tfloor( (m_pCamWnd->Camera().angles[YAW]+11)/22.5 );\n\tSys_UpdateWindows (W_CAMERA | W_XY_OVERLAY);\n}\n\nvoid CMainFrame::OnViewConsole() \n{\n  if (m_nCurrentStyle > 0 && m_nCurrentStyle < 3) // QE4 style\n  {\n    if (inspector_mode == W_CONSOLE && m_nCurrentStyle != QR_QE4) // are we in console mode already?\n    {\n      if (::IsWindowVisible(g_qeglobals.d_hwndEntity))\n        ::ShowWindow(g_qeglobals.d_hwndEntity, SW_HIDE);\n      else\n        ::ShowWindow(g_qeglobals.d_hwndEntity, SW_NORMAL);\n    }\n    else\n    {\n      ::ShowWindow(g_qeglobals.d_hwndEntity, SW_NORMAL);\n      SetInspectorMode(W_CONSOLE);\n    }\n  }\n}\n\nvoid CMainFrame::OnViewDownfloor() \n{\n  m_pCamWnd->Cam_ChangeFloor (false);\n}\n\nvoid CMainFrame::OnViewEntity() \n{\n  if (m_nCurrentStyle == 0 || m_nCurrentStyle == 3)\n  {\n    if (::IsWindowVisible(g_qeglobals.d_hwndEntity) && inspector_mode == W_ENTITY)\n      ::ShowWindow(g_qeglobals.d_hwndEntity, SW_HIDE);\n    else\n    {\n      ::ShowWindow(g_qeglobals.d_hwndEntity, SW_NORMAL);\n      SetInspectorMode(W_ENTITY);\n    }\n  }\n  else\n  {\n    if (inspector_mode == W_ENTITY && m_nCurrentStyle != QR_QE4)\n    {\n      if (::IsWindowVisible(g_qeglobals.d_hwndEntity))\n        ::ShowWindow(g_qeglobals.d_hwndEntity, SW_HIDE);\n      else\n        ::ShowWindow(g_qeglobals.d_hwndEntity, SW_NORMAL);\n    }\n    else\n    {\n      ::ShowWindow(g_qeglobals.d_hwndEntity, SW_NORMAL);\n      SetInspectorMode(W_ENTITY);\n    }\n  }\n}\n\nvoid CMainFrame::OnViewFront() \n{\n  if (m_nCurrentStyle != 2)\n  {\n    m_pXYWnd->SetViewType(YZ);\n    m_pXYWnd->PositionView();\n  }\n\tSys_UpdateWindows (W_XY);\n}\n\nvoid CMainFrame::OnMru(unsigned int nID) \n{\n  DoMru(GetSafeHwnd(),nID);\n}\n\nvoid CMainFrame::OnViewNearest(unsigned int nID) \n{\n  Texture_SetMode(nID);\n}\n\nvoid CMainFrame::OnTextureWad(unsigned int nID) \n{\n  Sys_BeginWait ();\n\tTexture_ShowDirectory (nID);\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnBspCommand(unsigned int nID) \n{\n  if (g_PrefsDlg.m_bSnapShots && stricmp(currentmap, \"unnamed.map\") != 0)\n    Map_Snapshot();\n\n  if (g_qeglobals.bBSPFrontendPlugin)\n  {\n\t  CString foo = g_BSPFrontendCommands.GetAt(nID-CMD_BSPCOMMAND);\n\t  g_BSPFrontendTable.m_pfnDispatchBSPCommand( foo.GetBuffer(0) );\n  }\n  else\n  {\n\t  RunBsp (bsp_commands[LOWORD(nID-CMD_BSPCOMMAND)]);\n  }\n}\n\n\n\nvoid CMainFrame::OnViewShowblocks() \n{\n  g_qeglobals.show_blocks ^= 1;\n  CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWBLOCKS, MF_BYCOMMAND | (g_qeglobals.show_blocks ? MF_CHECKED : MF_UNCHECKED)  );\n\tSys_UpdateWindows (W_XY);\n}\n\nvoid CMainFrame::OnViewShowclip() \n{\n\tif ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_CLIP ) & EXCLUDE_CLIP )\n    CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWCLIP, MF_BYCOMMAND | MF_UNCHECKED );\n\telse\n    CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWCLIP, MF_BYCOMMAND | MF_CHECKED );\n\tSys_UpdateWindows (W_XY|W_CAMERA);\n}\n\nvoid CMainFrame::OnViewShowcoordinates() \n{\n  g_qeglobals.d_savedinfo.show_coordinates ^= 1;\n  CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWCOORDINATES, MF_BYCOMMAND | (g_qeglobals.d_savedinfo.show_coordinates ? MF_CHECKED : MF_UNCHECKED)  );\n\tSys_UpdateWindows (W_XY);\n}\n\nvoid CMainFrame::OnViewShowdetail() \n{\n\tif ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_DETAIL ) & EXCLUDE_DETAIL )\n\t{\n    CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWDETAIL, MF_BYCOMMAND | MF_UNCHECKED );\n    ::SetWindowText (g_qeglobals.d_hwndCamera, \"Camera View (DETAIL EXCLUDED)\");\n\t}\n\telse\n\t{\n    CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWDETAIL, MF_BYCOMMAND | MF_CHECKED );\n    ::SetWindowText (g_qeglobals.d_hwndCamera, \"Camera View\");\n\t}\n\tSys_UpdateWindows (W_XY|W_CAMERA);\n}\n\nvoid CMainFrame::OnViewShowent() \n{\n  if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_ENT ) & EXCLUDE_ENT )\n    CheckMenuItem( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWENT, MF_BYCOMMAND | MF_UNCHECKED);\n\telse\n    CheckMenuItem( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWENT, MF_BYCOMMAND | MF_CHECKED);\n\tSys_UpdateWindows (W_XY|W_CAMERA);\n}\n\nvoid CMainFrame::OnViewShowlights() \n{\n  if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_LIGHTS ) & EXCLUDE_LIGHTS )\n    CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWLIGHTS, MF_BYCOMMAND | MF_UNCHECKED );\n\telse\n    CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWLIGHTS, MF_BYCOMMAND | MF_CHECKED );\t\t\t\t\n\tSys_UpdateWindows (W_XY|W_CAMERA);\n}\n\nvoid CMainFrame::OnViewShownames() \n{\n  g_qeglobals.d_savedinfo.show_names = !g_qeglobals.d_savedinfo.show_names;\n  CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWNAMES, MF_BYCOMMAND | (g_qeglobals.d_savedinfo.show_names ? MF_CHECKED : MF_UNCHECKED)  );\n\tMap_BuildBrushData();\n\tSys_UpdateWindows (W_XY);\n}\n\nvoid CMainFrame::OnViewShowpath() \n{\n  if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_PATHS ) & EXCLUDE_PATHS )\n    CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWPATH, MF_BYCOMMAND | MF_UNCHECKED );\n\telse\n    CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWPATH, MF_BYCOMMAND | MF_CHECKED );\n\tSys_UpdateWindows (W_XY|W_CAMERA);\n}\n\nvoid CMainFrame::OnViewShowwater() \n{\n\tif ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_WATER ) & EXCLUDE_WATER )\n    CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWWATER, MF_BYCOMMAND | MF_UNCHECKED );\n\telse\n    CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWWATER, MF_BYCOMMAND | MF_CHECKED );\n\tSys_UpdateWindows (W_XY|W_CAMERA);\n}\n\nvoid CMainFrame::OnViewShowworld() \n{\n\tif ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_WORLD ) & EXCLUDE_WORLD )\n    CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWWORLD, MF_BYCOMMAND | MF_UNCHECKED );\n\telse\n    CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWWORLD, MF_BYCOMMAND | MF_CHECKED );\n\tSys_UpdateWindows (W_XY|W_CAMERA);\n}\n\nvoid CMainFrame::OnViewTexture() \n{\n  if (m_nCurrentStyle > 0 && m_nCurrentStyle < 3) // QE4 style\n  {\n    if (inspector_mode == W_TEXTURE && m_nCurrentStyle != QR_QE4) // are we in console mode already?\n    {\n      if (::IsWindowVisible(g_qeglobals.d_hwndEntity))\n        ::ShowWindow(g_qeglobals.d_hwndEntity, SW_HIDE);\n      else\n        ::ShowWindow(g_qeglobals.d_hwndEntity, SW_SHOW);\n    }\n    else\n    {\n      ::ShowWindow(g_qeglobals.d_hwndEntity, SW_SHOW);\n      SetInspectorMode(W_TEXTURE);\n    }\n  }\n}\n\nvoid CMainFrame::OnViewUpfloor() \n{\n  m_pCamWnd->Cam_ChangeFloor (true);\n}\n\nvoid CMainFrame::OnViewXy() \n{\n  if (m_nCurrentStyle != 2)\n  {\n    m_pXYWnd->SetViewType(XY);\n    m_pXYWnd->PositionView();\n  }\n\tSys_UpdateWindows (W_XY);\n}\n\nvoid CMainFrame::OnViewZ100() \n{\n  z.scale = 1;\n\tSys_UpdateWindows (W_Z|W_Z_OVERLAY);\n}\n\nvoid CMainFrame::OnViewZoomin() \n{\n  if (m_pXYWnd && m_pXYWnd->Active())\n  {\n    m_pXYWnd->SetScale(m_pXYWnd->Scale() * 5.0 / 4);\n    if (m_pXYWnd->Scale() > 20)\n      m_pXYWnd->SetScale(20);\n  }\n\n  if (m_pXZWnd && m_pXZWnd->Active())\n  {\n    m_pXZWnd->SetScale(m_pXZWnd->Scale() * 5.0 / 4);\n    if (m_pXZWnd->Scale() > 20)\n      m_pXZWnd->SetScale(20);\n  }\n\n  if (m_pYZWnd && m_pYZWnd->Active())\n  {\n    m_pYZWnd->SetScale(m_pYZWnd->Scale() * 5.0 / 4);\n    if (m_pYZWnd->Scale() > 20)\n      m_pYZWnd->SetScale(20);\n  }\n\n\n\tSys_UpdateWindows (W_XY|W_XY_OVERLAY);\n}\n\nvoid CMainFrame::OnViewZoomout() \n{\n\n  if (m_pXYWnd && m_pXYWnd->Active())\n  {\n    m_pXYWnd->SetScale(m_pXYWnd->Scale() * 4.0 / 5);\n    if (m_pXYWnd->Scale() < 0.1 / 32)\n      m_pXYWnd->SetScale(0.1 /32);\n  }\n\n  if (m_pXZWnd && m_pXZWnd->Active())\n  {\n    m_pXZWnd->SetScale(m_pXZWnd->Scale() * 4.0 / 5);\n    if (m_pXZWnd->Scale() < 0.1 / 32)\n      m_pXZWnd->SetScale(0.1 / 32);\n  }\n\n  if (m_pYZWnd && m_pYZWnd->Active())\n  {\n    m_pYZWnd->SetScale(m_pYZWnd->Scale() * 4.0 / 5);\n    if (m_pYZWnd->Scale() < 0.1 / 32)\n      m_pYZWnd->SetScale(0.1 / 32);\n  }\n\tSys_UpdateWindows (W_XY|W_XY_OVERLAY);\n}\n\nvoid CMainFrame::OnViewZzoomin() \n{\n  z.scale *= 5.0/4;\n\tif (z.scale > 4)\n\t  z.scale = 4;\n\tSys_UpdateWindows (W_Z|W_Z_OVERLAY);\n}\n\nvoid CMainFrame::OnViewZzoomout() \n{\n  z.scale *= 4.0/5;\n\tif (z.scale < 0.125)\n\t  z.scale = 0.125;\n\tSys_UpdateWindows (W_Z|W_Z_OVERLAY);\n}\n\nvoid CMainFrame::OnViewSide() \n{\n  if (m_nCurrentStyle != 2)\n  {\n    m_pXYWnd->SetViewType(XZ);\n    m_pXYWnd->PositionView();\n  }\n\tSys_UpdateWindows (W_XY);\n}\n\nvoid CMainFrame::OnGrid1(unsigned int nID) \n{\n  HMENU hMenu = ::GetMenu(GetSafeHwnd());\n\t\n\tCheckMenuItem(hMenu, ID_GRID_1, MF_BYCOMMAND | MF_UNCHECKED);\n\tCheckMenuItem(hMenu, ID_GRID_2, MF_BYCOMMAND | MF_UNCHECKED);\n\tCheckMenuItem(hMenu, ID_GRID_4, MF_BYCOMMAND | MF_UNCHECKED);\n\tCheckMenuItem(hMenu, ID_GRID_8, MF_BYCOMMAND | MF_UNCHECKED);\n\tCheckMenuItem(hMenu, ID_GRID_16, MF_BYCOMMAND | MF_UNCHECKED);\n\tCheckMenuItem(hMenu, ID_GRID_32, MF_BYCOMMAND | MF_UNCHECKED);\n\tCheckMenuItem(hMenu, ID_GRID_64, MF_BYCOMMAND | MF_UNCHECKED);\n\n\tswitch (nID)\n\t{\n\t\tcase ID_GRID_1: g_qeglobals.d_gridsize = 0; break;\n\t\tcase ID_GRID_2: g_qeglobals.d_gridsize = 1; break;\n\t\tcase ID_GRID_4: g_qeglobals.d_gridsize = 2; break;\n\t\tcase ID_GRID_8: g_qeglobals.d_gridsize = 3; break;\n\t\tcase ID_GRID_16: g_qeglobals.d_gridsize = 4; break;\n\t\tcase ID_GRID_32: g_qeglobals.d_gridsize = 5; break;\n\t\tcase ID_GRID_64: g_qeglobals.d_gridsize = 6; break;\n\t}\n\tg_qeglobals.d_gridsize = 1 << g_qeglobals.d_gridsize;\n\n  if (g_PrefsDlg.m_bSnapTToGrid)\n    g_qeglobals.d_savedinfo.m_nTextureTweak = g_qeglobals.d_gridsize;\n\n  SetGridStatus();\n\tCheckMenuItem(hMenu, nID, MF_BYCOMMAND | MF_CHECKED);\n\tSys_UpdateWindows (W_XY|W_Z);\n\t\n}\n\nvoid CMainFrame::OnTexturesShowinuse() \n{\n  Sys_BeginWait ();\n\tTexture_ShowInuse ();\n  if (m_pTexWnd)\n  {\n    m_pTexWnd->RedrawWindow();\n  }\n}\n\n//from TexWnd.cpp\nextern qboolean\ttexture_showinuse;\nvoid CMainFrame::OnUpdateTexturesShowinuse(CCmdUI* pCmdUI) \n{\n  pCmdUI->SetCheck(texture_showinuse);\n}\n\nvoid CMainFrame::OnTexturesInspector() \n{\n  DoSurface ();\n}\n\nvoid CMainFrame::OnMiscBenchmark() \n{\n  m_pCamWnd->BenchMark();\n}\n\nvoid CMainFrame::OnMiscFindbrush() \n{\n  DoFind();\n}\n\nvoid CMainFrame::OnMiscGamma() \n{\n  float fSave = g_qeglobals.d_savedinfo.fGamma;\n  DoGamma();\n  if (fSave != g_qeglobals.d_savedinfo.fGamma)\n  {\n    MessageBox(\"You must restart Q3Radiant for Gamma settings to take place\");\n  }\n}\n\nvoid CMainFrame::OnMiscNextleakspot() \n{\n  Pointfile_Next();\n}\n\nvoid CMainFrame::OnMiscPreviousleakspot() \n{\n  Pointfile_Prev();\n}\n\nvoid CMainFrame::OnMiscPrintxy() \n{\n  WXY_Print();\n}\n\nvoid CMainFrame::OnMiscSelectentitycolor() \n{\n  if (edit_entity)\n  {\n    CString strColor = ValueForKey(edit_entity, \"_color\");\n    if (strColor.GetLength() > 0)\n    {\n      float fR, fG, fB;\n\t    int n = sscanf(strColor,\"%f %f %f\", &fR, &fG, &fB);\n      if (n == 3)\n      {\n        g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][0] = fR;\n        g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][1] = fG;\n        g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][2] = fB;\n      }\n    }\n\n    if (inspector_mode == W_ENTITY && (DoColor(COLOR_ENTITY)))\n    {\n\t    char buffer[100];\n\t    sprintf(buffer, \"%f %f %f\", g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][0],\n\t\t          g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][1],\n\t\t          g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][2]);\n\t  \n      ::SetWindowText( hwndEnt[EntValueField], buffer );\n      ::SetWindowText( hwndEnt[EntKeyField], \"_color\" );\n\t    AddProp();\n//DK - SOF change to get color to entity quickly\n\t\t//--::SetWindowText( hwndEnt[EntValueField], buffer );\n//--\t\t::SetWindowText( hwndEnt[EntKeyField], \"color\" );\n//--\t\tAddProp();\n    }\n    Sys_UpdateWindows( W_ALL );\n  }\n}\n\nvoid CMainFrame::OnTexturebk() \n{\n  DoColor(COLOR_TEXTUREBACK);\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnColorsMajor() \n{\n  DoColor(COLOR_GRIDMAJOR);\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnColorsMinor() \n{\n  DoColor(COLOR_GRIDMINOR);\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnColorsXybk() \n{\n  DoColor(COLOR_GRIDBACK);\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnBrush3sided() \n{\n\tUndo_Start(\"3 sided\");\n\tUndo_AddBrushList(&selected_brushes);\n\tBrush_MakeSided(3);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnBrush4sided() \n{\n\tUndo_Start(\"4 sided\");\n\tUndo_AddBrushList(&selected_brushes);\n\tBrush_MakeSided(4);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnBrush5sided() \n{\n\tUndo_Start(\"5 sided\");\n\tUndo_AddBrushList(&selected_brushes);\n\tBrush_MakeSided(5);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnBrush6sided() \n{\n\tUndo_Start(\"6 sided\");\n\tUndo_AddBrushList(&selected_brushes);\n\tBrush_MakeSided(6);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnBrush7sided() \n{\n\tUndo_Start(\"7 sided\");\n\tUndo_AddBrushList(&selected_brushes);\n\tBrush_MakeSided(7);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnBrush8sided() \n{\n\tUndo_Start(\"8 sided\");\n\tUndo_AddBrushList(&selected_brushes);\n\tBrush_MakeSided(8);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnBrush9sided() \n{\n\tUndo_Start(\"9 sided\");\n\tUndo_AddBrushList(&selected_brushes);\n\tBrush_MakeSided(9);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnBrushArbitrarysided() \n{\n\tUndo_Start(\"arbitrary sided\");\n\tUndo_AddBrushList(&selected_brushes);\n\tDoSides();\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnBrushFlipx() \n{\n\tUndo_Start(\"flip X\");\n\tUndo_AddBrushList(&selected_brushes);\n\n\tSelect_FlipAxis (0);\n\tfor (brush_t *b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n\t{\n\t\tif(b->owner->eclass->fixedsize)\n\t\t{\n\t\t\tchar buf[16];\n\t\t\tfloat a = FloatForKey(b->owner, \"angle\");\n\t\t\ta = div( ( 180 - a ) , 180 ).rem;\n\t\t\tSetKeyValue(b->owner, \"angle\", itoa(a, buf, 10));\n\t\t\tBrush_Build(b);\n\t\t}\n\t}\n\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnBrushFlipy() \n{\n\tUndo_Start(\"flip Y\");\n\tUndo_AddBrushList(&selected_brushes);\n\n\tSelect_FlipAxis (1);\n\tfor (brush_t *b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n\t{\n\t\tif(b->owner->eclass->fixedsize)\n\t\t{\n\t\t\tfloat a = FloatForKey(b->owner, \"angle\");\n\t\t\tif (a == 0 || a == 180 || a == 360)\n\t\t\t\tcontinue;\n\t\t\tif ( a == 90 || a == 270)\n\t\t\t{\n\t\t\t\ta += 180;\n\t\t\t}\n\t\t\telse if (a > 270)\n\t\t\t\ta += 90;\n\t\t\telse if (a > 180)\n\t\t\t\ta -= 90;\n\t\t\telse if (a > 90)\n\t\t\t\ta += 90;\n\t\t\telse\n\t\t\t\ta -= 90;\n\t\t\ta = (int)a % 360;\n\t\t\tchar buf[16];\n\t\t\tSetKeyValue(b->owner, \"angle\", itoa(a, buf, 10));\n\t\t\tBrush_Build(b);\n\t\t}\n\t}\n\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnBrushFlipz() \n{\n\tUndo_Start(\"flip Z\");\n\tUndo_AddBrushList(&selected_brushes);\n\tSelect_FlipAxis (2);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnBrushRotatex() \n{\n\tUndo_Start(\"rotate X\");\n\tUndo_AddBrushList(&selected_brushes);\n\tSelect_RotateAxis (0, 90);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnBrushRotatey() \n{\n\tUndo_Start(\"rotate Y\");\n\tUndo_AddBrushList(&selected_brushes);\n\tSelect_RotateAxis (1, 90);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnBrushRotatez() \n{\n\tUndo_Start(\"rotate Z\");\n\tUndo_AddBrushList(&selected_brushes);\n\tSelect_RotateAxis (2, 90);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnRegionOff() \n{\n\tMap_RegionOff ();\n}\n\nvoid CMainFrame::OnRegionSetbrush() \n{\n\tMap_RegionBrush ();\n}\n\nvoid CMainFrame::OnRegionSetselection() \n{\n\tMap_RegionSelectedBrushes ();\n}\n\nvoid CMainFrame::OnRegionSettallbrush() \n{\n\tMap_RegionTallBrush ();\n}\n\nvoid CMainFrame::OnRegionSetxy() \n{\n\tMap_RegionXY ();\n}\n\nvoid CMainFrame::OnSelectionArbitraryrotation() \n{\n\t//if (ActiveXY())\n\t//\tActiveXY()->UndoCopy();\n\tUndo_Start(\"arbitrary rotation\");\n\tUndo_AddBrushList(&selected_brushes);\n\n\tCRotateDlg dlg;\n\tdlg.DoModal();\n\t//DoRotate ();\n\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnSelectionClone() \n{\n\t//if (ActiveXY())\n\t//\tActiveXY()->UndoCopy();\n\tSelect_Clone();\n}\n\nvoid CMainFrame::OnSelectionConnect() \n{\n\tConnectEntities();\n}\n\nvoid CMainFrame::OnSelectionMakehollow() \n{\n\t//if (ActiveXY())\n\t//\tActiveXY()->UndoCopy();\n\tUndo_Start(\"hollow\");\n\tUndo_AddBrushList(&selected_brushes);\n\tCSG_MakeHollow ();\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnSelectionCsgsubtract() \n{\n\t//if (ActiveXY())\n\t//\tActiveXY()->UndoCopy();\n\tUndo_Start(\"CSG subtract\");\n\tCSG_Subtract();\n\tUndo_End();\n}\n\nvoid CMainFrame::OnSelectionCsgmerge()\n{\n\t//if (ActiveXY())\n\t//\tActiveXY()->UndoCopy();\n\tUndo_Start(\"CSG merge\");\n\tUndo_AddBrushList(&selected_brushes);\n\tCSG_Merge();\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnSelectionNoOutline()\n{\n  g_qeglobals.dontDrawSelectedOutlines ^= 1;\n  Sys_UpdateWindows(W_ALL);\n}\n\nvoid CMainFrame::OnSelectionDelete() \n{\n\tbrush_t *brush;\n\t//if (ActiveXY())\n\t//\tActiveXY()->UndoCopy();\n\tUndo_Start(\"delete\");\n\tUndo_AddBrushList(&selected_brushes);\n\t//add all deleted entities to the undo\n\tfor (brush = selected_brushes.next; brush != &selected_brushes; brush = brush->next)\n\t{\n\t\tUndo_AddEntity(brush->owner);\n\t}\n\t// NOTE: Select_Delete does NOT delete entities\n\tSelect_Delete();\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnSelectionDeselect() \n{\n\tif (!ByeByeSurfaceDialog())\n\t{\n\t\tif (g_bClipMode)\n\t\t\tOnViewClipper();\n\t\telse if (g_bRotateMode)\n\t\t\tOnSelectMouserotate();\n\t\telse if (g_bScaleMode)\n\t\t\tOnSelectMousescale();\n\t\telse if (g_bPathMode)\n\t\t{\n\t\t\tif (ActiveXY())\n\t\t\t\tActiveXY()->KillPathMode();\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (g_qeglobals.d_select_mode == sel_curvepoint && g_qeglobals.d_num_move_points > 0)\n\t\t\t{\n\t\t\t\tg_qeglobals.d_num_move_points = 0;\n\t\t\t\tSys_UpdateWindows(W_ALL);\n\t\t\t}\n\t\t\telse if ( g_qeglobals.d_select_mode == sel_terrainpoint && g_qeglobals.d_numterrapoints > 0 )\n\t\t\t{\n\t\t\t\tg_qeglobals.d_numterrapoints = 0;\n\t\t\t\tSys_UpdateWindows( W_ALL );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tSelect_Deselect ();\n\t\t\t\tSetStatusText(2, \" \");\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid CMainFrame::OnSelectionDragedges() \n{\n\tif (g_qeglobals.d_select_mode == sel_edge)\n\t{\n\t\tclearSelection();\n\t\tSys_UpdateWindows (W_ALL);\n\t}\n\telse\n\t{\n\t\tSetupVertexSelection ();\n\t\tif (g_qeglobals.d_numpoints)\n\t\t\tg_qeglobals.d_select_mode = sel_edge;\n\t\tSys_UpdateWindows (W_ALL);\n\t}\n}\n\nvoid CMainFrame::OnSelectionDragvertecies() \n{\n\tif (g_qeglobals.d_select_mode == sel_vertex || g_qeglobals.d_select_mode == sel_curvepoint ||\n      g_qeglobals.d_select_mode == sel_terrainpoint )\n\t{\n\t\tclearSelection();\n\t\tSys_UpdateWindows (W_ALL);\n\t}\n\telse\n\t{\n\t  //--if (QE_SingleBrush() && selected_brushes.next->patchBrush)\n\tif ( OnlyTerrainSelected() )\n\t{\n\t\t//Terrain_Edit();\n\t}\n    else if (OnlyPatchesSelected())\n    {\n      Patch_EditPatch();\n    }\n\telse if ( !AnyPatchesSelected() && !AnyTerrainSelected() )\n    {\n\t\t  SetupVertexSelection ();\n\t\t  if (g_qeglobals.d_numpoints)\n\t\t    g_qeglobals.d_select_mode = sel_vertex;\n    }\n\t\tSys_UpdateWindows (W_ALL);\n\t}\n}\n\nvoid CMainFrame::OnRaiseLowerTerrain() \n{\n\t//if ( !OnlyTerrainSelected() || ( g_qeglobals.d_select_mode == sel_terrainpoint ) )\n\t//if ( ( g_qeglobals.d_select_mode == sel_terrainpoint ) || ( g_qeglobals.d_select_mode == sel_terraintexture ) )\n\tif ( g_qeglobals.d_select_mode == sel_terrainpoint ) {\n\t\tclearSelection();\n\t\tSys_UpdateWindows (W_ALL);\n\t}\n\telse if ( g_qeglobals.d_select_mode == sel_terraintexture ) {\n\t\tclearSelection();\n\t\tg_qeglobals.d_select_mode = sel_terrainpoint;\n\t\tSys_UpdateWindows (W_ALL);\n\t}\n\telse\n\t{\n\t\t//g_qeglobals.d_select_mode = sel_terrainpoint;\n\t\tclearSelection();\n\t\tg_qeglobals.d_select_mode = sel_terraintexture;\n\t\tSys_UpdateWindows (W_ALL);\n//\t\tTerrain_Edit();\n\t}\n}\n\nvoid CMainFrame::OnSelectionMakeDetail() \n{\n\tUndo_Start(\"make detail\");\n\tUndo_AddBrushList(&selected_brushes);\n\tSelect_MakeDetail ();\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnSelectionMakeStructural() \n{\n\tUndo_Start(\"make structural\");\n\tUndo_AddBrushList(&selected_brushes);\n\tSelect_MakeStructural ();\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnSelectionSelectcompletetall() \n{\n\tif (ActiveXY())\n\t\tActiveXY()->UndoCopy();\n\tSelect_CompleteTall ();\n}\n\nvoid CMainFrame::OnSelectionSelectinside() \n{\n\tSelect_Inside ();\n}\n\nvoid CMainFrame::OnSelectionSelectpartialtall() \n{\n\tSelect_PartialTall();\n}\n\nvoid CMainFrame::OnSelectionSelecttouching() \n{\n\tSelect_Touching();\n}\n\nvoid CMainFrame::OnSelectionUngroupentity() \n{\n\tSelect_Ungroup();\n}\n\nvoid CMainFrame::OnTexturesPopup() \n{\n\tHandlePopup(this, IDR_POPUP_TEXTURE);\n}\n\nvoid CMainFrame::OnSplinesPopup() \n{\n\tHandlePopup(this, IDR_POPUP_SPLINE);\n}\n\nvoid CMainFrame::OnPopupSelection() \n{\n\tHandlePopup(this, IDR_POPUP_SELECTION); \n}\n\nvoid CMainFrame::OnViewChange() \n{\n\tOnViewNextview();\n\t//HandlePopup(this, IDR_POPUP_VIEW); \n}\n\nvoid CMainFrame::OnViewCameraupdate() \n{\n  Sys_UpdateWindows(W_CAMERA);\n}\n\nvoid CMainFrame::OnUpdateViewCameraupdate(CCmdUI* pCmdUI) \n{\n\tpCmdUI->Enable(m_bCamPreview == false);\n}\n\nvoid CMainFrame::OnSizing(UINT fwSide, LPRECT pRect) \n{\n  CFrameWnd::OnSizing(fwSide, pRect);\n\tGetClientRect(g_rctOld);\n}\n\nvoid CMainFrame::OnHelpAbout() \n{\n  DoAbout();\n}\n\nvoid CMainFrame::OnViewClipper() \n{\n  if (ActiveXY())\n  {\n    if (ActiveXY()->ClipMode())\n    {\n      ActiveXY()->SetClipMode(false);\n      m_wndToolBar.GetToolBarCtrl().CheckButton(ID_VIEW_CLIPPER, FALSE);\n    }\n    else\n    {\n      if (ActiveXY()->RotateMode())\n        OnSelectMouserotate();\n      ActiveXY()->SetClipMode(true);\n      m_wndToolBar.GetToolBarCtrl().CheckButton(ID_VIEW_CLIPPER);\n    }\n  }\n}\n\nvoid CMainFrame::OnCameraAngledown() \n{\n  m_pCamWnd->Camera().angles[0] -= SPEED_TURN;\n\tif (m_pCamWnd->Camera().angles[0] < -85)\n\t  m_pCamWnd->Camera().angles[0] = -85;\n\tSys_UpdateWindows (W_CAMERA|W_XY_OVERLAY);\n}\n\nvoid CMainFrame::OnCameraAngleup() \n{\n  m_pCamWnd->Camera().angles[0] += SPEED_TURN;\n  if (m_pCamWnd->Camera().angles[0] > 85)\n\t  m_pCamWnd->Camera().angles[0] = 85;\n  Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY);\n}\n\nvoid CMainFrame::OnCameraBack() \n{\n  VectorMA (m_pCamWnd->Camera().origin, -SPEED_MOVE, m_pCamWnd->Camera().forward, m_pCamWnd->Camera().origin);\n  int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);\n\tSys_UpdateWindows (nUpdate);\n}\n\nvoid CMainFrame::OnCameraDown() \n{\n  m_pCamWnd->Camera().origin[2] -= SPEED_MOVE;\n  int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);\n\tSys_UpdateWindows (nUpdate);\n}\n\nvoid CMainFrame::OnCameraForward() \n{\n  VectorMA (m_pCamWnd->Camera().origin, SPEED_MOVE, m_pCamWnd->Camera().forward, m_pCamWnd->Camera().origin);\n  int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);\n\tSys_UpdateWindows (nUpdate);\n}\n\nvoid CMainFrame::OnCameraLeft() \n{\n  m_pCamWnd->Camera().angles[1] += SPEED_TURN;\n  int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);\n\tSys_UpdateWindows (nUpdate);\n}\n\nvoid CMainFrame::OnCameraRight() \n{\n  m_pCamWnd->Camera().angles[1] -= SPEED_TURN;\n  int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);\n\tSys_UpdateWindows (nUpdate);\n}\n\nvoid CMainFrame::OnCameraStrafeleft() \n{\n  VectorMA (m_pCamWnd->Camera().origin, -SPEED_MOVE, m_pCamWnd->Camera().right, m_pCamWnd->Camera().origin);\n  int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);\n\tSys_UpdateWindows (nUpdate);\n}\n\nvoid CMainFrame::OnCameraStraferight() \n{\n  VectorMA (m_pCamWnd->Camera().origin, SPEED_MOVE, m_pCamWnd->Camera().right, m_pCamWnd->Camera().origin);\n  int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);\n\tSys_UpdateWindows (nUpdate);\n}\n\nvoid CMainFrame::OnCameraUp() \n{\n  m_pCamWnd->Camera().origin[2] += SPEED_MOVE;\n  int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA);\n\tSys_UpdateWindows (nUpdate);\n}\n\nvoid CMainFrame::OnGridToggle() \n{\n  g_qeglobals.d_showgrid = !g_qeglobals.d_showgrid;\n\tSys_UpdateWindows (W_XY|W_Z);\n}\n\nvoid CMainFrame::OnPrefs() \n{\n  int nView = g_PrefsDlg.m_nView;\n  BOOL bToolbar = g_PrefsDlg.m_bWideToolbar;\n  BOOL bTextureBar = g_PrefsDlg.m_bTextureBar;\n  BOOL bSGIOpenGL = g_PrefsDlg.m_bSGIOpenGL;\n  BOOL bBuggyICD = g_PrefsDlg.m_bBuggyICD;\n  int nShader = g_PrefsDlg.m_nShader;\n  g_PrefsDlg.LoadPrefs();\n  if (g_PrefsDlg.DoModal() == IDOK)\n  {\n    if (g_PrefsDlg.m_nView != nView || g_PrefsDlg.m_bWideToolbar != bToolbar \n        || g_PrefsDlg.m_bSGIOpenGL != bSGIOpenGL || g_PrefsDlg.m_bBuggyICD != bBuggyICD || nShader != g_PrefsDlg.m_nShader)\n      MessageBox(\"You need to restart Q3Radiant for the view changes to take place.\");\n    if (m_pTexWnd)\n      m_pTexWnd->UpdatePrefs();\n    if (bTextureBar != g_PrefsDlg.m_bTextureBar)\n    {\n      if (bTextureBar) // was turned on\n        ShowControlBar(&m_wndTextureBar, TRUE, TRUE);\n      else // was turned off\n        ShowControlBar(&m_wndTextureBar, FALSE, TRUE);\n      m_wndTextureBar.Invalidate();\n    }\n    CMenu* pMenu = GetMenu();\n    if (pMenu)\n      pMenu->CheckMenuItem(ID_SNAPTOGRID, MF_BYCOMMAND | (!g_PrefsDlg.m_bNoClamp) ? MF_CHECKED : MF_UNCHECKED);\n  }\n}\n\n// 0 = radiant styel\n// 1 = qe4 style\nvoid CMainFrame::SetWindowStyle(int nStyle)\n{\n}\n\nvoid CMainFrame::OnTogglecamera() \n{\n  if (m_nCurrentStyle > 0 && m_nCurrentStyle < 3) // QE4 style\n  {\n    if (m_pCamWnd && m_pCamWnd->GetSafeHwnd())\n    {\n      if (m_pCamWnd->IsWindowVisible())\n        m_pCamWnd->ShowWindow(SW_HIDE);\n      else\n        m_pCamWnd->ShowWindow(SW_SHOW);\n    }\n  }\n}\n\nvoid CMainFrame::OnToggleconsole() \n{\n  if (m_nCurrentStyle > 0 && m_nCurrentStyle < 3) // QE4 style\n  {\n    if (m_pEditWnd && m_pEditWnd->GetSafeHwnd())\n    {\n      if (m_pEditWnd->IsWindowVisible())\n        m_pEditWnd->ShowWindow(SW_HIDE);\n      else\n        m_pEditWnd->ShowWindow(SW_SHOW);\n    }\n  }\n}\n\nvoid CMainFrame::OnToggleview() \n{\n  if (m_nCurrentStyle == 1) // QE4 style\n  {\n    if (m_pXYWnd && m_pXYWnd->GetSafeHwnd())\n    {\n      if (m_pXYWnd->IsWindowVisible())\n        m_pXYWnd->ShowWindow(SW_HIDE);\n      else\n        m_pXYWnd->ShowWindow(SW_SHOW);\n    }\n  }\n}\n\nvoid CMainFrame::OnTogglez() \n{\n  if (m_nCurrentStyle == 1 || m_nCurrentStyle == 2) // QE4 style\n  {\n    if (m_pZWnd && m_pZWnd->GetSafeHwnd())\n    {\n      if (m_pZWnd->IsWindowVisible())\n        m_pZWnd->ShowWindow(SW_HIDE);\n      else\n        m_pZWnd->ShowWindow(SW_SHOW);\n    }\n  }\n  else\n  {\n\t  Undo_Redo();\n  }\n}\n\nvoid CMainFrame::OnToggleLock() \n{\n  g_PrefsDlg.m_bTextureLock = !g_PrefsDlg.m_bTextureLock;\n  CMenu* pMenu = GetMenu();\n  if (pMenu)\n    pMenu->CheckMenuItem(ID_TOGGLE_LOCK, MF_BYCOMMAND | (g_PrefsDlg.m_bTextureLock) ? MF_CHECKED : MF_UNCHECKED);\n  g_PrefsDlg.SavePrefs();\n  SetGridStatus();\n}\n\nvoid CMainFrame::OnEditMapinfo() \n{\n  CMapInfo dlg;\n  dlg.DoModal();\n}\n\nvoid CMainFrame::OnEditEntityinfo() \n{\n  CEntityListDlg dlg;\n  dlg.DoModal();\n}\n\n\n\nvoid CMainFrame::OnBrushScripts() \n{\n  CScriptDlg dlg;\n  dlg.DoModal();\n}\n\nvoid CMainFrame::OnViewNextview() \n{\n  if (m_nCurrentStyle != 2)\n  {\n    if (m_pXYWnd->GetViewType() == XY)\n      m_pXYWnd->SetViewType(XZ);\n    else \n    if (m_pXYWnd->GetViewType() ==  XZ)\n      m_pXYWnd->SetViewType(YZ);\n    else\n      m_pXYWnd->SetViewType(XY);\n    m_pXYWnd->PositionView();\n\t  Sys_UpdateWindows (W_XY);\n  }\n}\n\nvoid CMainFrame::OnHelpCommandlist() \n{\n  CCommandsDlg dlg;\n  dlg.DoModal();\n#if 0\n  if (g_b3Dfx)\n  {\n    C3DFXCamWnd* pWnd = new C3DFXCamWnd();\n    CRect rect(50,50,400, 400);\n    pWnd->Create(_3DFXCAMERA_WINDOW_CLASS, \"\", QE3_CHILDSTYLE, rect, this, 1234);\n    pWnd->ShowWindow(SW_SHOW);\n  }\n#endif\n}\n\nvoid CMainFrame::OnFileNewproject() \n{\n  CNewProjDlg dlg;\n  if (dlg.DoModal() == IDOK && dlg.m_strName.GetLength() > 0)\n  {\n    CString strQ2;\n    CString strQ2File;\n    ExtractPath_and_Filename(g_PrefsDlg.m_strQuake2, strQ2, strQ2File);\n\n\n    AddSlash(strQ2);\n    strQ2 += dlg.m_strName;\n    CString strProjToLoad;\n    CString strMapToLoad;\n    bool bGood = true;\n    if (::CreateDirectory(strQ2, NULL))\n    {\n      CString strDir = strQ2;\n      strDir += \"\\\\maps\";\n      if (::CreateDirectory(strDir, NULL))\n      {\n        CString strSource = g_strAppPath;\n        AddSlash(strSource);\n        strSource += \"projmap.dat\";\n        CString strDest = strDir;\n        AddSlash(strDest);\n        CString strName;\n        strName.Format(\"%s.map\", dlg.m_strName);\n        strDest += strName;\n        strMapToLoad = strDest;\n        if (!::CopyFile(strSource, strDest, FALSE))\n          bGood = false;\n      }\n      else bGood = false;\n\n      strDir = strQ2;\n      strDir += \"\\\\pics\";\n      if (::CreateDirectory(strDir, NULL))\n      {\n        CString strSource = g_strAppPath;\n        AddSlash(strSource);\n        strSource += \"colormap.pcx\";\n        CString strDest = strDir;\n        AddSlash(strDest);\n        strDest += \"colormap.pcx\";\n        if (!::CopyFile(strSource, strDest, FALSE))\n          bGood = false;\n      }\n      else bGood = false;\n\n      strDir = strQ2;\n      strDir += \"\\\\scripts\";\n      if (::CreateDirectory(strDir, NULL))\n      {\n        CString strSource = g_strAppPath;\n        AddSlash(strSource);\n        strSource += \"projqe4.dat\";\n        CString strDest = strDir;\n        AddSlash(strDest);\n        strDest += \"quake.qe4\";\n        if (!::CopyFile(strSource, strDest, FALSE))\n          bGood = false;\n        else\n          strProjToLoad = strDest;\n      }\n      else bGood = false;\n      if (bGood && strProjToLoad.GetLength() > 0)\n      {\n\t      if (QE_LoadProject(strProjToLoad.GetBuffer(0)))\n        {\n          if (strMapToLoad.GetLength() > 0)\n            Map_LoadFile(strMapToLoad.GetBuffer(0));\n        }\n      }\n    }\n    else \n    {\n      CString strMsg;\n      strMsg.Format(\"Unable to create directory %s\", strQ2);\n      MessageBox(strMsg);\n    }\n\n  }\n}\n\nvoid CMainFrame::UpdateStatusText()\n{\n  for (int n = 0; n < 6; n++)\n  {\n    if (m_strStatus[n].GetLength() >= 0 && m_wndStatusBar.GetSafeHwnd())\n\t\t  m_wndStatusBar.SetPaneText(n, m_strStatus[n]);\n  }\n}\n\nvoid CMainFrame::SetStatusText(int nPane, const char * pText)\n{\n  if (pText && nPane <= 5 && nPane > 0)\n  {\n    m_strStatus[nPane] = pText;\n    UpdateStatusText();\n  }\n}\n\nvoid CMainFrame::UpdateWindows(int nBits)\n{\n\n  if (!g_bScreenUpdates)\n    return;\n\n  if (nBits & (W_XY | W_XY_OVERLAY))\n  {\n\t  if (m_pXYWnd)\n      m_pXYWnd->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);\n\t  if (m_pXZWnd)\n      m_pXZWnd->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);\n\t  if (m_pYZWnd)\n      m_pYZWnd->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);\n  }\n\n\tif (nBits & W_CAMERA || ((nBits & W_CAMERA_IFON) && m_bCamPreview))\n  {\n    if (m_pCamWnd)\n    {\n      m_pCamWnd->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);\n    }\n  }\n\n  if (nBits & (W_Z | W_Z_OVERLAY))\n  {\n    if (m_pZWnd)\n      m_pZWnd->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);\n  }\n\t\t\n\tif (nBits & W_TEXTURE)\n  {\n    if (m_pTexWnd)\n      m_pTexWnd->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);\n  }\n}\n\nvoid WINAPI Sys_UpdateWindows (int nBits)\n{\n  if (g_PrefsDlg.m_bQE4Painting)\n    g_nUpdateBits |= nBits;\n  else\n    g_pParentWnd->UpdateWindows(nBits);\n}\n\n\n\nvoid CMainFrame::OnFlipClip() \n{\n\tif (m_pActiveXY)\n    m_pActiveXY->FlipClip();\n}\n\nvoid CMainFrame::OnClipSelected() \n{\n\tif (m_pActiveXY && m_pActiveXY->ClipMode())\n\t{\n\t\tUndo_Start(\"clip selected\");\n\t\tUndo_AddBrushList(&selected_brushes);\n\t\tm_pActiveXY->Clip();\n\t\tUndo_EndBrushList(&selected_brushes);\n\t\tUndo_End();\n\t}\n\telse\n\t{\n\t\tif (g_bPatchBendMode)\n\t\t\tPatch_BendHandleENTER();\n\t\telse if (g_bPatchBendMode)\n\t\t\tPatch_InsDelHandleENTER();\n\t}\n}\n\nvoid CMainFrame::OnSplitSelected() \n{\n\tif (m_pActiveXY)\n\t{\n\t\tUndo_Start(\"split selected\");\n\t\tUndo_AddBrushList(&selected_brushes);\n\t\tm_pActiveXY->SplitClip();\n\t\tUndo_EndBrushList(&selected_brushes);\n\t\tUndo_End();\n\t}\n}\n\nCXYWnd* CMainFrame::ActiveXY()\n{\n  return m_pActiveXY;\n}\n\n\nvoid CMainFrame::OnToggleviewXz() \n{\n  if (m_nCurrentStyle == 1) // QE4 style\n  {\n    if (m_pXZWnd && m_pXZWnd->GetSafeHwnd())\n    {\n       // get windowplacement doesn't actually save this so we will here\n      g_PrefsDlg.m_bXZVis = m_pXZWnd->IsWindowVisible();\n      if (g_PrefsDlg.m_bXZVis)\n        m_pXZWnd->ShowWindow(SW_HIDE);\n      else\n        m_pXZWnd->ShowWindow(SW_SHOW);\n      g_PrefsDlg.m_bXZVis ^= 1;\n      g_PrefsDlg.SavePrefs();\n    }\n  }\n}\n\nvoid CMainFrame::OnToggleviewYz() \n{\n  if (m_nCurrentStyle == 1) // QE4 style\n  {\n    if (m_pYZWnd && m_pYZWnd->GetSafeHwnd())\n    {\n      g_PrefsDlg.m_bYZVis = m_pYZWnd->IsWindowVisible();\n      if (g_PrefsDlg.m_bYZVis)\n        m_pYZWnd->ShowWindow(SW_HIDE);\n      else\n        m_pYZWnd->ShowWindow(SW_SHOW);\n      g_PrefsDlg.m_bYZVis ^= 1;\n      g_PrefsDlg.SavePrefs();\n    }\n  }\n}\n\nvoid CMainFrame::OnColorsBrush() \n{\n  DoColor(COLOR_BRUSHES);\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnColorsClipper() \n{\n  DoColor(COLOR_CLIPPER);\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnColorsGridtext() \n{\n  DoColor(COLOR_GRIDTEXT);\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnColorsSelectedbrush() \n{\n  DoColor(COLOR_SELBRUSHES);\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnColorsGridblock() \n{\n  DoColor(COLOR_GRIDBLOCK);\n\tSys_UpdateWindows (W_ALL);\n}\n\n\n\nvoid CMainFrame::OnColorsViewname() \n{\n  DoColor(COLOR_VIEWNAME);\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnColorSetoriginal() \n{\n\tfor (int i=0 ; i<3 ; i++)\n\t{\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][i] = 0.25;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][i] = 1.0;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR][i] = 0.75;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][i] = 0.5;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][i] = 0.25;\n\t}\n\n\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][0] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][1] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][2] = 1.0;\n\n\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][0] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][1] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][2] = 0.0;\n\n\tg_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][0] = 1.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][1] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][2] = 0.0;\n\n\tg_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][0] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][1] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][2] = 1.0;\n\n\tg_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][0] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][1] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][2] = 0.0;\n\n\tg_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][0] = 0.5;\n\tg_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][1] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][2] = 0.75;\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnColorSetqer() \n{\n\tfor (int i=0 ; i<3 ; i++)\n\t{\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][i] = 0.25;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][i] = 1.0;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR][i] = 1.0;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][i] = 0.5;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][i] = 0.25;\n\t}\n\n\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][0] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][1] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][2] = 1.0;\n\n\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][0] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][1] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][2] = 0.0;\n\n\tg_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][0] = 1.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][1] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][2] = 0.0;\n\n\tg_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][0] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][1] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][2] = 1.0;\n\n\tg_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][0] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][1] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][2] = 0.0;\n\n\tg_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][0] = 0.5;\n\tg_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][1] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][2] = 0.75;\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnColorSetblack() \n{\n\tfor (int i=0 ; i<3 ; i++)\n\t{\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][i] = 0.25;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][i] = 0.0;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR][i] = 0.0;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][i] = 0.25;\n\t}\n\n\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][0] = 0.3;\n\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][1] = 0.5;\n\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][2] = 0.5;\n\n\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][0] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][1] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][2] = 1.0;\n\n\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][0] = 1.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][1] = 1.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][2] = 1.0;\n\n\tg_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][0] = 1.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][1] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][2] = 0.0;\n\n\tg_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][0] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][1] = 0.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][2] = 1.0;\n\n\tg_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][0] = 1.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][1] = 1.0;\n\tg_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][2] = 1.0;\n\n\tg_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][0] = 0.7;\n\tg_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][1] = 0.7;\n\tg_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][2] = 0.0;\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnSnaptogrid() \n{\n  g_PrefsDlg.m_bNoClamp ^= 1;\n  g_PrefsDlg.SavePrefs();\n  CMenu* pMenu = GetMenu();\n  if (pMenu)\n    pMenu->CheckMenuItem(ID_SNAPTOGRID, MF_BYCOMMAND | (!g_PrefsDlg.m_bNoClamp) ? MF_CHECKED : MF_UNCHECKED);\n}\n\n\nvoid CMainFrame::OnSelectScale() \n{\n\t//if (ActiveXY())\n\t//\tActiveXY()->UndoCopy();\n\tUndo_Start(\"scale\");\n\tUndo_AddBrushList(&selected_brushes);\n\n\tCScaleDialog dlg;\n\tif (dlg.DoModal() == IDOK)\n\t{\n\t\tif (dlg.m_fX > 0 && dlg.m_fY > 0 && dlg.m_fZ > 0)\n\t\t{\n\t\t\tSelect_Scale(dlg.m_fX, dlg.m_fY, dlg.m_fZ);\n\t\t\tSys_UpdateWindows (W_ALL);\n\t\t}\n\t\telse\n\t\t\tSys_Printf(\"Warning.. Tried to scale by a zero value.\");\n\t}\n\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnSelectMouserotate() \n{\n  if (ActiveXY())\n  {\n    if (ActiveXY()->ClipMode())\n      OnViewClipper();\n    if (ActiveXY()->RotateMode())\n    {\n      // SetRotateMode(false) always works\n      ActiveXY()->SetRotateMode(false);\n      m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_MOUSEROTATE, FALSE);\n      Map_BuildBrushData();\n    }\n    else\n    {\n      // may not work if no brush selected, see return value\n      if (ActiveXY()->SetRotateMode(true))\n        m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_MOUSEROTATE, TRUE);\n      else\n        // if MFC called, we need to set back to FALSE ourselves\n        m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_MOUSEROTATE, FALSE);\n    }\n\n  }\n}\n\nvoid CMainFrame::OnEditCopybrush() \n{\n\tif (ActiveXY())\n\t\tActiveXY()->Copy();\n}\n\nvoid CMainFrame::OnEditPastebrush() \n{\n\tif (ActiveXY())\n\t\tActiveXY()->Paste();\n}\n\nvoid CMainFrame::OnEditUndo() \n{\n//\tif (ActiveXY())\n//\t\tActiveXY()->Undo();\n\tUndo_Undo();\n}\n\nvoid CMainFrame::OnEditRedo() \n{\n\tUndo_Redo();\n}\n\nvoid CMainFrame::OnUpdateEditUndo(CCmdUI* pCmdUI) \n{\n\t/*\n  BOOL bEnable = false;\n  if (ActiveXY())\n    bEnable = ActiveXY()->UndoAvailable();\n  pCmdUI->Enable(bEnable);\n  */\n\tpCmdUI->Enable(Undo_UndoAvailable());\n}\n\nvoid CMainFrame::OnUpdateEditRedo(CCmdUI* pCmdUI) \n{\n\tpCmdUI->Enable(Undo_RedoAvailable());\n}\n\nvoid CMainFrame::OnSelectionTextureDec() \n{\n  g_qeglobals.d_savedinfo.m_nTextureTweak--;\n  if (g_qeglobals.d_savedinfo.m_nTextureTweak == 0)\n    g_qeglobals.d_savedinfo.m_nTextureTweak--;\n  SetTexValStatus();\n}\n\nvoid CMainFrame::OnSelectionTextureFit() \n{\n\t// TODO: Add your command handler code here\n\t\n}\n\nvoid CMainFrame::OnSelectionTextureInc() \n{\n  g_qeglobals.d_savedinfo.m_nTextureTweak++;\n  if (g_qeglobals.d_savedinfo.m_nTextureTweak == 0)\n    g_qeglobals.d_savedinfo.m_nTextureTweak++;\n  SetTexValStatus();\n}\n\nvoid CMainFrame::OnSelectionTextureRotateclock() \n{\n  Select_RotateTexture(abs(g_PrefsDlg.m_nRotation));\n}\n\nvoid CMainFrame::OnSelectionTextureRotatecounter() \n{\n  Select_RotateTexture(-abs(g_PrefsDlg.m_nRotation));\n}\n\nvoid CMainFrame::OnSelectionTextureScaledown() \n{\n\tSelect_ScaleTexture(0, -abs(g_qeglobals.d_savedinfo.m_nTextureTweak));\n}\n\nvoid CMainFrame::OnSelectionTextureScaleup() \n{\n\tSelect_ScaleTexture(0, abs(g_qeglobals.d_savedinfo.m_nTextureTweak));\n}\n\nvoid CMainFrame::OnSelectionTextureScaleLeft() \n{\n\tSelect_ScaleTexture(-abs(g_qeglobals.d_savedinfo.m_nTextureTweak),0);\n}\n\nvoid CMainFrame::OnSelectionTextureScaleRight() \n{\n\tSelect_ScaleTexture(abs(g_qeglobals.d_savedinfo.m_nTextureTweak),0);\n}\n\nvoid CMainFrame::OnSelectionTextureShiftdown() \n{\n  Select_ShiftTexture(0, -abs(g_qeglobals.d_savedinfo.m_nTextureTweak));\n}\n\nvoid CMainFrame::OnSelectionTextureShiftleft() \n{\n  Select_ShiftTexture(-abs(g_qeglobals.d_savedinfo.m_nTextureTweak), 0);\n}\n\nvoid CMainFrame::OnSelectionTextureShiftright() \n{\n  Select_ShiftTexture(abs(g_qeglobals.d_savedinfo.m_nTextureTweak), 0);\n}\n\nvoid CMainFrame::OnSelectionTextureShiftup() \n{\n  Select_ShiftTexture(0, abs(g_qeglobals.d_savedinfo.m_nTextureTweak));\n}\n\nvoid CMainFrame::OnGridNext() \n{\n  if (g_qeglobals.d_gridsize < 64)\n  {\n    g_qeglobals.d_gridsize = g_qeglobals.d_gridsize << 1;\n    Sys_UpdateWindows(W_XY | W_Z);\n    SetGridStatus();\n\n    HMENU hMenu = ::GetMenu(GetSafeHwnd());\n\t  CheckMenuItem(hMenu, ID_GRID_1, MF_BYCOMMAND | MF_UNCHECKED);\n\t  CheckMenuItem(hMenu, ID_GRID_2, MF_BYCOMMAND | MF_UNCHECKED);\n\t  CheckMenuItem(hMenu, ID_GRID_4, MF_BYCOMMAND | MF_UNCHECKED);\n\t  CheckMenuItem(hMenu, ID_GRID_8, MF_BYCOMMAND | MF_UNCHECKED);\n\t  CheckMenuItem(hMenu, ID_GRID_16, MF_BYCOMMAND | MF_UNCHECKED);\n\t  CheckMenuItem(hMenu, ID_GRID_32, MF_BYCOMMAND | MF_UNCHECKED);\n\t  CheckMenuItem(hMenu, ID_GRID_64, MF_BYCOMMAND | MF_UNCHECKED);\n\n    int nID;\n\t  switch (g_qeglobals.d_gridsize)\n\t  {\n\t\t  case  1: nID = ID_GRID_1; break;\n\t\t  case  2: nID = ID_GRID_2; break;\n\t\t  case  4: nID = ID_GRID_4; break;\n\t\t  case  8: nID = ID_GRID_8; break;\n\t\t  case  16: nID = ID_GRID_16; break;\n\t\t  case  32: nID = ID_GRID_32; break;\n\t\t  case  64: nID = ID_GRID_64; break;\n\t  }\n\t  CheckMenuItem(hMenu, nID, MF_BYCOMMAND | MF_CHECKED);\n  }\n}\n\nvoid CMainFrame::OnGridPrev() \n{\n  if (g_qeglobals.d_gridsize > 1)\n  {\n    g_qeglobals.d_gridsize = g_qeglobals.d_gridsize >> 1;\n    Sys_UpdateWindows(W_XY | W_Z);\n    SetGridStatus();\n    HMENU hMenu = ::GetMenu(GetSafeHwnd());\n\t  CheckMenuItem(hMenu, ID_GRID_1, MF_BYCOMMAND | MF_UNCHECKED);\n\t  CheckMenuItem(hMenu, ID_GRID_2, MF_BYCOMMAND | MF_UNCHECKED);\n\t  CheckMenuItem(hMenu, ID_GRID_4, MF_BYCOMMAND | MF_UNCHECKED);\n\t  CheckMenuItem(hMenu, ID_GRID_8, MF_BYCOMMAND | MF_UNCHECKED);\n\t  CheckMenuItem(hMenu, ID_GRID_16, MF_BYCOMMAND | MF_UNCHECKED);\n\t  CheckMenuItem(hMenu, ID_GRID_32, MF_BYCOMMAND | MF_UNCHECKED);\n\t  CheckMenuItem(hMenu, ID_GRID_64, MF_BYCOMMAND | MF_UNCHECKED);\n\n    int nID;\n\t  switch (g_qeglobals.d_gridsize)\n\t  {\n\t\t  case  1: nID = ID_GRID_1; break;\n\t\t  case  2: nID = ID_GRID_2; break;\n\t\t  case  4: nID = ID_GRID_4; break;\n\t\t  case  8: nID = ID_GRID_8; break;\n\t\t  case  16: nID = ID_GRID_16; break;\n\t\t  case  32: nID = ID_GRID_32; break;\n\t\t  case  64: nID = ID_GRID_64; break;\n\t  }\n\t  CheckMenuItem(hMenu, nID, MF_BYCOMMAND | MF_CHECKED);\n  }\n}\n\nvoid CMainFrame::SetGridStatus()\n{\n  CString strStatus;\n  char c1;\n  char c2;\n  c1 = (g_PrefsDlg.m_bTextureLock) ? 'M' : ' ';\n  c2 = (g_PrefsDlg.m_bRotateLock) ? 'R' : ' ';\n  strStatus.Format(\"G:%i T:%i R:%i C:%i L:%c%c\", g_qeglobals.d_gridsize, g_qeglobals.d_savedinfo.m_nTextureTweak, g_PrefsDlg.m_nRotation, g_PrefsDlg.m_nCubicScale, c1, c2);\n  SetStatusText(4, strStatus);\n}\n\nvoid CMainFrame::SetTexValStatus()\n{\n  //CString strStatus;\n  //strStatus.Format(\"T: %i C: %i\", g_nTextureTweak, g_nCubicScale);\n  //SetStatusText(5, strStatus.GetBuffer(0));\n  SetGridStatus();\n}\n\nvoid CMainFrame::OnTextureReplaceall() \n{\n  CFindTextureDlg::show();\n}\n\n\nvoid CMainFrame::OnScalelockx() \n{\n  if (g_nScaleHow & SCALE_X)\n  {\n    g_nScaleHow ^= SCALE_X;\n    m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKX, FALSE);\n  }\n  else\n  {\n    g_nScaleHow |= SCALE_X;\n    m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKX);\n  }\n}\n\nvoid CMainFrame::OnScalelocky() \n{\n  if (g_nScaleHow & SCALE_Y)\n  {\n    g_nScaleHow ^= SCALE_Y;\n    m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKY, FALSE);\n  }\n  else\n  {\n    g_nScaleHow |= SCALE_Y;\n    m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKY);\n  }\n}\n\nvoid CMainFrame::OnScalelockz() \n{\n  if (g_nScaleHow & SCALE_Z)\n  {\n    g_nScaleHow ^= SCALE_Z;\n    m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKZ, FALSE);\n  }\n  else\n  {\n    g_nScaleHow |= SCALE_Z;\n    m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKZ);\n  }\n}\n\nvoid CMainFrame::OnSelectMousescale() \n{\n  if (ActiveXY())\n  {\n    if (ActiveXY()->ClipMode())\n      OnViewClipper();\n    if (ActiveXY()->RotateMode())\n    {\n      // SetRotateMode(false) always works\n      ActiveXY()->SetRotateMode(false);\n      m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_MOUSESCALE, FALSE);\n    }\n    if (ActiveXY()->ScaleMode())\n    {\n      ActiveXY()->SetScaleMode(false);\n      m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_MOUSESCALE, FALSE);\n    }\n    else\n    {\n      ActiveXY()->SetScaleMode(true);\n      m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SELECT_MOUSESCALE);\n    }\n  }\n}\n\nvoid CMainFrame::OnFileImport() \n{\n}\n\nvoid CMainFrame::OnFileProjectsettings() \n{\n  DoProjectSettings();\n}\n\nvoid CMainFrame::OnUpdateFileImport(CCmdUI* pCmdUI) \n{\n  pCmdUI->Enable(FALSE);\n}\n\nvoid CMainFrame::OnViewCubein() \n{\n  g_PrefsDlg.m_nCubicScale--;\n  if (g_PrefsDlg.m_nCubicScale < 1)\n    g_PrefsDlg.m_nCubicScale = 1;\n  g_PrefsDlg.SavePrefs();\n\tSys_UpdateWindows(W_CAMERA);\n  SetTexValStatus();\n}\n\nvoid CMainFrame::OnViewCubeout() \n{\n  g_PrefsDlg.m_nCubicScale++;\n\tif (g_PrefsDlg.m_nCubicScale > 22)\n\t  g_PrefsDlg.m_nCubicScale = 22;\n  g_PrefsDlg.SavePrefs();\n\tSys_UpdateWindows(W_CAMERA);\n  SetTexValStatus();\n}\n\nvoid CMainFrame::OnViewCubicclipping() \n{\n  g_PrefsDlg.m_bCubicClipping ^= 1;\n  CMenu* pMenu = GetMenu();\n  if (pMenu)\n    pMenu->CheckMenuItem(ID_VIEW_CUBICCLIPPING, MF_BYCOMMAND | (g_PrefsDlg.m_bCubicClipping) ? MF_CHECKED : MF_UNCHECKED);\n  m_wndToolBar.GetToolBarCtrl().CheckButton(ID_VIEW_CUBICCLIPPING, (g_PrefsDlg.m_bCubicClipping) ? TRUE : FALSE);\n  g_PrefsDlg.SavePrefs();\n  Map_BuildBrushData ();\n  Sys_UpdateWindows(W_CAMERA);\n}\n\n\nvoid CMainFrame::OnFileSaveregion() \n{\n  SaveAsDialog (true);\n}\n\nvoid CMainFrame::OnUpdateFileSaveregion(CCmdUI* pCmdUI) \n{\n  pCmdUI->Enable(static_cast<BOOL>(region_active));\n}\n\nvoid CMainFrame::OnSelectionMovedown() \n{\n\tUndo_Start(\"move up\");\n\tUndo_AddBrushList(&selected_brushes);\n\n\tvec3_t vAmt;\n\tvAmt[0] = vAmt[1] = 0.0;\n\tvAmt[2] = -g_qeglobals.d_gridsize;\n\tSelect_Move (vAmt);\n\tSys_UpdateWindows(W_CAMERA | W_XY | W_Z);\n\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnSelectionMoveup() \n{\n  vec3_t vAmt;\n  vAmt[0] = vAmt[1] = 0.0;\n  vAmt[2] = g_qeglobals.d_gridsize;\n\tSelect_Move (vAmt);\n  Sys_UpdateWindows(W_CAMERA | W_XY | W_Z);\n}\n\nvoid CMainFrame::OnToolbarMain() \n{\n\n}\n\nvoid CMainFrame::OnToolbarTexture() \n{\n\t\n}\n\nvoid CMainFrame::OnSelectionPrint() \n{\n  for (brush_t* b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n    Brush_Print(b);\n}\n\nvoid CMainFrame::UpdateTextureBar()\n{\n  if (m_wndTextureBar.GetSafeHwnd())\n    m_wndTextureBar.GetSurfaceAttributes();\n}\n\nbool g_bTABDown = false;\nbool g_bOriginalFlag;\nvoid CMainFrame::OnSelectionTogglesizepaint() \n{\n  if (::GetAsyncKeyState('Q'))\n  {\n    if (!g_bTABDown)\n    {\n      g_bTABDown = true;\n      g_bOriginalFlag = g_PrefsDlg.m_bSizePaint;\n      g_PrefsDlg.m_bSizePaint = !g_bOriginalFlag;\n      Sys_UpdateWindows(W_XY);\n      return;\n    }\n  }\n  else\n  {\n    g_bTABDown = false;\n    g_PrefsDlg.m_bSizePaint = g_bOriginalFlag;\n    Sys_UpdateWindows(W_XY);\n    return;\n  }\n}\n\nvoid CMainFrame::OnBrushMakecone() \n{\n\tUndo_Start(\"make cone\");\n\tUndo_AddBrushList(&selected_brushes);\n\tDoSides(true);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\n\nvoid CMainFrame::OnTexturesLoad() \n{\n  BROWSEINFO bi;\n  CString strPath;\n  char* p = strPath.GetBuffer(MAX_PATH+1);\n  bi.hwndOwner = GetSafeHwnd();\n  bi.pidlRoot = NULL;\n  bi.pszDisplayName = p;\n  bi.lpszTitle = \"Load textures from path\";\n  bi.ulFlags = 0;\n  bi.lpfn = NULL;\n  bi.lParam = NULL;\n  bi.iImage = 0;\n  LPITEMIDLIST pidlBrowse;\n  pidlBrowse = SHBrowseForFolder(&bi);\n  if (pidlBrowse)\n  {\n    SHGetPathFromIDList(pidlBrowse, p);\n    strPath.ReleaseBuffer();\n    AddSlash(strPath);\n    Texture_ShowDirectory(strPath.GetBuffer(0));\n  }\n}\n\nvoid CMainFrame::OnToggleRotatelock() \n{\n  g_PrefsDlg.m_bRotateLock ^= 1;\n  CMenu* pMenu = GetMenu();\n  if (pMenu)\n    pMenu->CheckMenuItem(ID_TOGGLE_ROTATELOCK, MF_BYCOMMAND | (g_PrefsDlg.m_bRotateLock) ? MF_CHECKED : MF_UNCHECKED);\n  g_PrefsDlg.SavePrefs();\n  SetGridStatus();\n}\n\n\nvoid CMainFrame::OnCurveBevel() \n{\n  //Curve_MakeCurvedBrush (false,\tfalse, false,\tfalse, false, true, true);\n}\n\nvoid CMainFrame::OnCurveCylinder() \n{\n  //Curve_MakeCurvedBrush (false,\tfalse, false,\ttrue, true, true, true);\n}\n\nvoid CMainFrame::OnCurveEighthsphere() \n{\n  //Curve_MakeCurvedBrush (false,\ttrue, false, true, true, false, false);\n}\n\nvoid CMainFrame::OnCurveEndcap() \n{\n  //Curve_MakeCurvedBrush (false,\tfalse, false,\tfalse, true, true, true);\n}\n\nvoid CMainFrame::OnCurveHemisphere() \n{\n  //Curve_MakeCurvedBrush (false,\ttrue, false, true, true, true, true);\n}\n\nvoid CMainFrame::OnCurveInvertcurve() \n{\n  //Curve_Invert ();\n}\n\nvoid CMainFrame::OnCurveQuarter() \n{\n  //Curve_MakeCurvedBrush (false,\ttrue, false, true, true, true, false);\n}\n\nvoid CMainFrame::OnCurveSphere() \n{\n\t//Curve_MakeCurvedBrush (false,\ttrue, true,\ttrue, true, true, true);\n}\n\nvoid CMainFrame::OnFileImportmap() \n{\n  CFileDialog dlgFile(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, \"Map files (*.map)|*.map||\", this);\n  if (dlgFile.DoModal() == IDOK)\n  {\n    Map_ImportFile(dlgFile.GetPathName().GetBuffer(0));\n  }\n}\n\nvoid CMainFrame::OnFileExportmap() \n{\n  CFileDialog dlgFile(FALSE, \"map\", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, \"Map files (*.map)|*.map||\", this);\n  if (dlgFile.DoModal() == IDOK)\n  {\n    Map_SaveSelected(dlgFile.GetPathName().GetBuffer(0));\n  }\n}\n\nvoid CMainFrame::OnViewShowcurves() \n{\n\tif ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_CURVES ) & EXCLUDE_CURVES )\n    CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWCURVES, MF_BYCOMMAND | MF_UNCHECKED );\n\telse\n    CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWCURVES, MF_BYCOMMAND | MF_CHECKED );\n\tSys_UpdateWindows (W_XY|W_CAMERA);\n}\n\nvoid CMainFrame::OnSelectionSelectNudgedown() \n{\n  NudgeSelection(3, g_qeglobals.d_savedinfo.m_nTextureTweak);\n}\n\nvoid CMainFrame::OnSelectionSelectNudgeleft() \n{\n  NudgeSelection(0, g_qeglobals.d_savedinfo.m_nTextureTweak);\n}\n\nvoid CMainFrame::OnSelectionSelectNudgeright() \n{\n  NudgeSelection(2, g_qeglobals.d_savedinfo.m_nTextureTweak);\n}\n\nvoid CMainFrame::OnSelectionSelectNudgeup() \n{\n  NudgeSelection(1, g_qeglobals.d_savedinfo.m_nTextureTweak);\n}\n\nvoid CMainFrame::NudgeSelection(int nDirection, int nAmount)\n{\n  if (ActiveXY()->RotateMode())\n  {\n    int nAxis = 0;\n    if (ActiveXY()->GetViewType() == XY)\n    {\n      nAxis = 2;\n    }\n    else \n    if (g_pParentWnd->ActiveXY()->GetViewType() == XZ)\n    {\n      nAxis = 1;\n      nAmount = -nAmount;\n    }\n\n    if (nDirection == 2 || nDirection == 3)\n    {\n      nAmount = -nAmount;\n    }\n\n    float fDeg = -nAmount;\n    float fAdj = nAmount;\n\n    g_pParentWnd->ActiveXY()->Rotation()[nAxis] += fAdj;\n    CString strStatus;\n    strStatus.Format(\"Rotation x:: %.1f  y:: %.1f  z:: %.1f\", g_pParentWnd->ActiveXY()->Rotation()[0], g_pParentWnd->ActiveXY()->Rotation()[1], g_pParentWnd->ActiveXY()->Rotation()[2]);\n    g_pParentWnd->SetStatusText(2, strStatus);\n    Select_RotateAxis(nAxis, fDeg, false, true);\n    Sys_UpdateWindows (W_ALL);\n  }\n  else\n  if (ActiveXY()->ScaleMode())\n  {\n    if (nDirection == 0 || nDirection == 3)\n    {\n      nAmount = -nAmount;\n    }\n    vec3_t v;\n    v[0] = v[1] = v[2] = 1.0;\n    if (nAmount > 0)\n    {\n      v[0] = 1.1;\n      v[1] = 1.1;\n      v[2] = 1.1;\n    }\n    else \n    {\n      v[0] = 0.9;\n      v[1] = 0.9;\n      v[2] = 0.9;\n    }\n\n    Select_Scale((g_nScaleHow & SCALE_X) ? v[0] : 1.0,\n                 (g_nScaleHow & SCALE_Y) ? v[1] : 1.0,\n                 (g_nScaleHow & SCALE_Z) ? v[2] : 1.0);\n\t  Sys_UpdateWindows (W_ALL);\n  }\n  else\n  {\n    // 0 - left, 1 - up, 2 - right, 3 - down\n    int nDim;\n    if (nDirection == 0)\n    {\n      nDim = ActiveXY()->GetViewType() == YZ ? 1 : 0;\n      nAmount = -nAmount;\n    }\n    else if (nDirection == 1)\n    {\n      nDim = ActiveXY()->GetViewType() == XY ? 1 : 2;\n    }\n    else if (nDirection == 2)\n    {\n      nDim = ActiveXY()->GetViewType() == YZ ? 1 : 0;\n    }\n    else\n    {\n      nDim = ActiveXY()->GetViewType() == XY ? 1 : 2;\n      nAmount = -nAmount;\n    }\n    Nudge(nDim, nAmount);\n  }\n}\n\n\nBOOL CMainFrame::PreTranslateMessage(MSG* pMsg) \n{\n\treturn CFrameWnd::PreTranslateMessage(pMsg);\n}\n\nvoid CMainFrame::Nudge(int nDim, float fNudge)\n{\n  vec3_t vMove;\n  vMove[0] = vMove[1] = vMove[2] = 0;\n  vMove[nDim] = fNudge;\n  Select_Move(vMove, true);\n  Sys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnTexturesLoadlist() \n{\n  CDialogTextures dlg;\n  if (dlg.DoModal() == IDOK && dlg.m_nSelection >= 0)\n  {\n    Texture_ShowDirectory(dlg.m_nSelection + CMD_TEXTUREWAD);\n  }\n}\n\nvoid CMainFrame::OnDontselectcurve() \n{\n  g_PrefsDlg.m_bSelectCurves ^= 1;\n  m_wndToolBar.GetToolBarCtrl().CheckButton(ID_DONTSELECTCURVE, (g_PrefsDlg.m_bSelectCurves) ? FALSE : TRUE);\n}\n\nvoid CMainFrame::OnConvertcurves() \n{\n#if 0\n  Select_Deselect();\n\tfor (brush_t* pb = active_brushes.next ; pb != &active_brushes ; pb = pb->next)\n\t{\n    if (pb->curveBrush)\n    {\n\t    for (face_t* f = pb->brush_faces ; f ; f=f->next) \n      {\n\t\t    if (f->texdef.contents & CONTENTS_LADDER)\n        {\n          f->texdef.contents &= ~CONTENTS_LADDER;\n          f->texdef.contents |= CONTENTS_NEGATIVE_CURVE;\n        }\n      }\n\t\t}\n  }\n  Map_BuildBrushData();\n#endif\n\n}\n\nvoid CMainFrame::OnDynamicLighting() \n{\n\tCCamWnd* pCam = new CCamWnd();\n\tCRect rect(100, 100, 300, 300);\n\tpCam->Create(CAMERA_WINDOW_CLASS, \"\", WS_OVERLAPPEDWINDOW, rect, GetDesktopWindow(), 12345);\n\tpCam->ShowWindow(SW_SHOW);\n}\n\n\nvoid CMainFrame::OnCurveSimplepatchmesh() \n{\n\tUndo_Start(\"make simpe patch mesh\");\n\tUndo_AddBrushList(&selected_brushes);\n\n\tCPatchDensityDlg dlg;\n\tdlg.DoModal();\n\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\n\nvoid CMainFrame::OnPatchToggleBox()\n{\n\tg_bPatchShowBounds ^= 1;\n\tm_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_SHOWBOUNDINGBOX, (g_bPatchShowBounds) ? TRUE : FALSE);\n\tSys_UpdateWindows(W_ALL);\n}\n\nvoid CMainFrame::OnPatchWireframe() \n{\n\tg_bPatchWireFrame ^= 1;\n\tm_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_WIREFRAME, (g_bPatchWireFrame) ? TRUE : FALSE);\n\tSys_UpdateWindows(W_ALL);\n}\n\nvoid CMainFrame::OnCurvePatchcone() \n{\n\tUndo_Start(\"make curve cone\");\n\tUndo_AddBrushList(&selected_brushes);\n\tPatch_BrushToMesh(true);\n\tSys_UpdateWindows (W_ALL);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnCurvePatchtube() \n{\n\tUndo_Start(\"make curve cylinder\");\n\tUndo_AddBrushList(&selected_brushes);\n\tPatch_BrushToMesh(false);\n\tSys_UpdateWindows (W_ALL);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnPatchWeld() \n{\n\tg_bPatchWeld ^= 1;\n\tm_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_WELD, (g_bPatchWeld) ? TRUE : FALSE);\n\tSys_UpdateWindows(W_ALL);\n}\n\nvoid CMainFrame::OnCurvePatchbevel() \n{\n\tUndo_Start(\"make bevel\");\n\tUndo_AddBrushList(&selected_brushes);\n\tPatch_BrushToMesh(false, true, false);\n\tSys_UpdateWindows (W_ALL);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnCurvePatchendcap() \n{\n\tUndo_Start(\"make end cap\");\n\tUndo_AddBrushList(&selected_brushes);\n\tPatch_BrushToMesh(false, false, true);\n\tSys_UpdateWindows (W_ALL);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnCurvePatchinvertedbevel() \n{\n  //Patch_BrushToMesh(false, true, false, true);\n  //Sys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnCurvePatchinvertedendcap() \n{\n  //Patch_BrushToMesh(false, false, true, true);\n  //Sys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnPatchDrilldown() \n{\n\tg_bPatchDrillDown ^= 1;\n\tm_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_DRILLDOWN, (g_bPatchDrillDown) ? TRUE : FALSE);\n\tSys_UpdateWindows(W_ALL);\n}\n\n\nvoid CMainFrame::OnCurveInsertcolumn() \n{\n\tUndo_Start(\"insert colum\");\n\tUndo_AddBrushList(&selected_brushes);\n\t//Patch_AdjustSelectedRowCols(0, 2);\n\tPatch_AdjustSelected(true, true, true);\n\tSys_UpdateWindows(W_ALL);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnCurveInsertrow() \n{\n\tUndo_Start(\"insert row\");\n\tUndo_AddBrushList(&selected_brushes);\n\t//Patch_AdjustSelectedRowCols(2, 0);\n\tPatch_AdjustSelected(true, false, true);\n\tSys_UpdateWindows(W_ALL);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnCurveDeletecolumn() \n{\n\tUndo_Start(\"delete column\");\n\tUndo_AddBrushList(&selected_brushes);\n\tPatch_AdjustSelected(false, true, true);\n\tSys_UpdateWindows(W_ALL);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnCurveDeleterow() \n{\n\tUndo_Start(\"delete row\");\n\tUndo_AddBrushList(&selected_brushes);\n\tPatch_AdjustSelected(false, false, true);\n\tSys_UpdateWindows(W_ALL);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnCurveInsertAddcolumn() \n{\n\tUndo_Start(\"add (2) columns\");\n\tUndo_AddBrushList(&selected_brushes);\n\tPatch_AdjustSelected(true, true, true);\n\tSys_UpdateWindows(W_ALL);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnCurveInsertAddrow() \n{\n\tUndo_Start(\"add (2) rows\");\n\tUndo_AddBrushList(&selected_brushes);\n\tPatch_AdjustSelected(true, false, true);\n\tSys_UpdateWindows(W_ALL);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnCurveInsertInsertcolumn() \n{\n\tUndo_Start(\"insert (2) columns\");\n\tUndo_AddBrushList(&selected_brushes);\n\tPatch_AdjustSelected(true, true, false);\n\tSys_UpdateWindows(W_ALL);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnCurveInsertInsertrow() \n{\n\tUndo_Start(\"insert (2) rows\");\n\tUndo_AddBrushList(&selected_brushes);\n\tPatch_AdjustSelected(true, false, false);\n\tSys_UpdateWindows(W_ALL);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnCurveNegative() \n{\n\tPatch_ToggleInverted();\n\t//Sys_UpdateWindows(W_ALL);\n}\n\nvoid CMainFrame::OnCurveNegativeTextureX() \n{\n\tPatch_InvertTexture(false);\n\t//Sys_UpdateWindows(W_ALL);\n}\n\nvoid CMainFrame::OnCurveNegativeTextureY() \n{\n\tPatch_InvertTexture(true);\n\t//Sys_UpdateWindows(W_ALL);\n}\n\n\nvoid CMainFrame::OnCurveDeleteFirstcolumn() \n{\n\tUndo_Start(\"delete first (2) columns\");\n\tUndo_AddBrushList(&selected_brushes);\n\tPatch_AdjustSelected(false, true, true);\n\tSys_UpdateWindows(W_ALL);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnCurveDeleteFirstrow() \n{\n\tUndo_Start(\"delete first (2) rows\");\n\tUndo_AddBrushList(&selected_brushes);\n\tPatch_AdjustSelected(false, false, true);\n\tSys_UpdateWindows(W_ALL);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnCurveDeleteLastcolumn() \n{\n\tUndo_Start(\"delete last (2) columns\");\n\tUndo_AddBrushList(&selected_brushes);\n\tPatch_AdjustSelected(false, true, false);\n\tSys_UpdateWindows(W_ALL);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnCurveDeleteLastrow() \n{\n\tUndo_Start(\"delete last (2) rows\");\n\tUndo_AddBrushList(&selected_brushes);\n\tPatch_AdjustSelected(false, false, false);\n\tSys_UpdateWindows(W_ALL);\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnPatchBend() \n{\n\tPatch_BendToggle();\n\tm_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_BEND, (g_bPatchBendMode) ? TRUE : FALSE);\n\tSys_UpdateWindows(W_ALL);\n}\n\nvoid CMainFrame::OnPatchInsdel() \n{\n\tPatch_InsDelToggle();\n\tm_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_INSDEL, (g_bPatchInsertMode) ? TRUE : FALSE);\n\tSys_UpdateWindows(W_ALL);\n}\n\nvoid CMainFrame::OnPatchEnter() \n{\n\t\n}\n\nvoid CMainFrame::OnPatchTab() \n{\n  if (g_bPatchBendMode)\n    Patch_BendHandleTAB();\n  else if (g_bPatchInsertMode)\n    Patch_InsDelHandleTAB();\n  else\n  {\n    // check to see if the selected brush is part of a func group\n    // if it is, deselect everything and reselect the next brush \n    // in the group\n\t  brush_t *b = selected_brushes.next;\n    entity_t * e;\n    if (b != &selected_brushes)\n    {\n\t    if (strcmpi(b->owner->eclass->name, \"worldspawn\") != 0)\n      {\n        e = b->owner;\n        Select_Deselect();\n\t\t    for (brush_t * b2 = e->brushes.onext ; b2 != &e->brushes ; b2 = b2->onext)\n\t\t    {\n          if (b == b2)\n          {\n            b2 = b2->onext;\n            break;\n          }\n        }\n        if (b2 == &e->brushes)\n          b2 = b2->onext;\n\n        Select_Brush(b2, false);\n        Sys_UpdateWindows(W_ALL);\n      }\n    }\n  }\n}\n\nvoid CMainFrame::UpdatePatchToolbarButtons() \n{\n  m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_BEND, (g_bPatchBendMode) ? TRUE : FALSE);\n  m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_INSDEL, (g_bPatchInsertMode) ? TRUE : FALSE);\n}\n\nvoid CMainFrame::OnCurvePatchdensetube() \n{\n\tUndo_Start(\"dense cylinder\");\n\tUndo_AddBrushList(&selected_brushes);\n\n\tPatch_BrushToMesh(false);\n\tOnCurveInsertAddrow();\n\tOnCurveInsertInsertrow();\n\tSys_UpdateWindows (W_ALL);\n\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnCurvePatchverydensetube() \n{\n\tUndo_Start(\"very dense cylinder\");\n\tUndo_AddBrushList(&selected_brushes);\n\n\tPatch_BrushToMesh(false);\n\tOnCurveInsertAddrow();\n\tOnCurveInsertInsertrow();\n\tOnCurveInsertAddrow();\n\tOnCurveInsertInsertrow();\n\tSys_UpdateWindows (W_ALL);\n\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnCurveCap() \n{\n  Patch_CapCurrent();\n  Sys_UpdateWindows (W_ALL);\n}\n\n\nvoid CMainFrame::OnCurveCapInvertedbevel() \n{\n  Patch_CapCurrent(true);\n  Sys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnCurveCapInvertedendcap() \n{\n\tPatch_CapCurrent(false, true);\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnCurveRedisperseCols() \n{\n\tPatch_DisperseColumns();\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnCurveRedisperseRows() \n{\n\tPatch_DisperseRows();\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnPatchNaturalize()\n{\n\tPatch_NaturalizeSelected();\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnSnapToGrid()\n{\n\tSelect_SnapToGrid();\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnCurvePatchsquare() \n{\n\tUndo_Start(\"square cylinder\");\n\tUndo_AddBrushList(&selected_brushes);\n\n\tPatch_BrushToMesh(false, false, false, true);\n\tSys_UpdateWindows (W_ALL);\n\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnTerrainCreateFromBrush()\n{\n\tTerrain_BrushToMesh();\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::CheckTextureScale(int id)\n{\n  CMenu* pMenu = GetMenu();\n  if (pMenu)\n  {\n    pMenu->CheckMenuItem(ID_TEXTURES_TEXTUREWINDOWSCALE_10, MF_BYCOMMAND | MF_UNCHECKED);\n    pMenu->CheckMenuItem(ID_TEXTURES_TEXTUREWINDOWSCALE_25, MF_BYCOMMAND | MF_UNCHECKED);\n    pMenu->CheckMenuItem(ID_TEXTURES_TEXTUREWINDOWSCALE_50, MF_BYCOMMAND | MF_UNCHECKED);\n    pMenu->CheckMenuItem(ID_TEXTURES_TEXTUREWINDOWSCALE_100, MF_BYCOMMAND | MF_UNCHECKED);\n    pMenu->CheckMenuItem(ID_TEXTURES_TEXTUREWINDOWSCALE_200, MF_BYCOMMAND | MF_UNCHECKED);\n    pMenu->CheckMenuItem(id, MF_BYCOMMAND | MF_CHECKED);\n  }\n  g_PrefsDlg.SavePrefs();\n\tTexture_ResetPosition();\n  Sys_UpdateWindows(W_TEXTURE);\n}\n\nvoid CMainFrame::OnTexturesTexturewindowscale10() \n{\n  g_PrefsDlg.m_nTextureScale = 10;\n  CheckTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_10);\n}\n\nvoid CMainFrame::OnTexturesTexturewindowscale100() \n{\n  g_PrefsDlg.m_nTextureScale = 100;\n  CheckTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_100);\n}\n\nvoid CMainFrame::OnTexturesTexturewindowscale200() \n{\n  g_PrefsDlg.m_nTextureScale = 200;\n  CheckTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_200);\n}\n\nvoid CMainFrame::OnTexturesTexturewindowscale25() \n{\n  g_PrefsDlg.m_nTextureScale = 25;\n  CheckTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_25);\n}\n\nvoid CMainFrame::OnTexturesTexturewindowscale50() \n{\n  g_PrefsDlg.m_nTextureScale = 50;\n  CheckTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_50);\n}\n\n\n\nvoid CMainFrame::OnTexturesFlush() \n{\n\tTexture_Flush();\n\tSys_UpdateWindows(W_ALL);\n}\n\nvoid CMainFrame::OnCurveOverlayClear() \n{\n\tPatch_ClearOverlays();\n\tSys_UpdateWindows(W_ALL);\n}\n\nvoid CMainFrame::OnCurveOverlaySet() \n{\n\tPatch_SetOverlays();\n\tSys_UpdateWindows(W_ALL);\n}\n\nvoid CMainFrame::OnCurveThicken() \n{\n\tUndo_Start(\"curve thicken\");\n\tUndo_AddBrushList(&selected_brushes);\n\n\tCDialogThick dlg;\n\tif (dlg.DoModal() == IDOK)\n\t{\n\t\tPatch_Thicken(dlg.m_nAmount, dlg.m_bSeams);\n\t\tSys_UpdateWindows(W_ALL);\n\t}\n\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnCurveCyclecap() \n{\n  Patch_NaturalizeSelected(true, true);\n  Sys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnCurveMatrixTranspose() \n{\n  Patch_Transpose();\n  Sys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnTexturesReloadshaders() \n{\n  CWaitCursor wait;\n  ReloadShaders();\n  Sys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::SetEntityCheck()\n{\n  CMenu* pMenu = GetMenu();\n  if (pMenu)\n  {\n    pMenu->CheckMenuItem(ID_VIEW_ENTITIESAS_BOUNDINGBOX, MF_BYCOMMAND | (g_PrefsDlg.m_nEntityShowState == ENTITY_BOX) ? MF_CHECKED : MF_UNCHECKED);\n    pMenu->CheckMenuItem(ID_VIEW_ENTITIESAS_WIREFRAME, MF_BYCOMMAND | (g_PrefsDlg.m_nEntityShowState == ENTITY_WIRE) ? MF_CHECKED : MF_UNCHECKED);\n    pMenu->CheckMenuItem(ID_VIEW_ENTITIESAS_SELECTEDWIREFRAME, MF_BYCOMMAND | (g_PrefsDlg.m_nEntityShowState == ENTITY_SELECTED) ? MF_CHECKED : MF_UNCHECKED);\n    pMenu->CheckMenuItem(ID_VIEW_ENTITIESAS_SELECTEDSKINNED, MF_BYCOMMAND | (g_PrefsDlg.m_nEntityShowState == ENTITY_SELECTED_SKIN) ? MF_CHECKED : MF_UNCHECKED);\n    pMenu->CheckMenuItem(ID_VIEW_ENTITIESAS_SKINNED, MF_BYCOMMAND | (g_PrefsDlg.m_nEntityShowState == ENTITY_SKINNED) ? MF_CHECKED : MF_UNCHECKED);\n    pMenu->CheckMenuItem(ID_VIEW_ENTITIESAS_SKINNEDANDBOXED, MF_BYCOMMAND | (g_PrefsDlg.m_nEntityShowState == ENTITY_SKINNED_BOXED) ? MF_CHECKED : MF_UNCHECKED); \n  }\n}\n\n\nvoid CMainFrame::OnShowEntities() \n{\n  HandlePopup(this, IDR_POPUP_ENTITY); \n}\n\nvoid CMainFrame::OnViewEntitiesasBoundingbox() \n{\n  g_PrefsDlg.m_nEntityShowState = ENTITY_BOX;\n  SetEntityCheck();\n  g_PrefsDlg.SavePrefs();\n  Sys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnViewEntitiesasSelectedskinned() \n{\n  g_PrefsDlg.m_nEntityShowState = ENTITY_SELECTED_SKIN;\n  SetEntityCheck();\n  g_PrefsDlg.SavePrefs();\n  Sys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnViewEntitiesasSelectedwireframe() \n{\n  g_PrefsDlg.m_nEntityShowState = ENTITY_SELECTED;\n  SetEntityCheck();\n  g_PrefsDlg.SavePrefs();\n  Sys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnViewEntitiesasSkinned() \n{\n  g_PrefsDlg.m_nEntityShowState = ENTITY_SKINNED;\n  SetEntityCheck();\n  g_PrefsDlg.SavePrefs();\n  Sys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnViewEntitiesasSkinnedandboxed() \n{\n  g_PrefsDlg.m_nEntityShowState = ENTITY_SKINNED_BOXED;\n  SetEntityCheck();\n  g_PrefsDlg.SavePrefs();\n  Sys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnViewEntitiesasWireframe() \n{\n  g_PrefsDlg.m_nEntityShowState = ENTITY_WIRE;\n  SetEntityCheck();\n  g_PrefsDlg.SavePrefs();\n  Sys_UpdateWindows (W_ALL);\n}\n\n\n\n\n\n\n\nvoid CMainFrame::OnPluginsRefresh() \n{\n  CleanPlugInMenu();\n  CString str(g_strAppPath);\n  AddSlash(str);\n  str += \"plugins\\\\\";\n  m_PlugInMgr.Init(str);\n}\n\nvoid CMainFrame::CleanPlugInMenu()\n{\n\tm_nNextPlugInID = ID_PLUGIN_START;\n\tCMenu* pMenu = GetMenu();\n\t//--pMenu->RemoveMenu(MENU_PLUGIN, MF_BYPOSITION);\n\t//--pMenu->InsertMenu(MENU_PLUGIN, MF_BYPOSITION, 0, \"Plugins\");\n\t//--DrawMenuBar();\n\tCMenu* pSub = pMenu->GetSubMenu(MENU_PLUGIN);\n\tif (pSub)\n\t{\n\t\tint n = pSub->GetMenuItemCount();\n\t\tfor (int i = n; i > 1 ; i--)\n\t\t{\n\t\t\tpSub->RemoveMenu(i, MF_BYPOSITION);\n\t\t}\n\t}\n}\n\nvoid CMainFrame::AddPlugInMenuItem(CPlugIn* pPlugIn)\n{\n\tconst char\t*menuText;\t\t//PGM\n\tCMenu* pMenu = GetMenu();\n\tCMenu* pSub = pMenu->GetSubMenu(MENU_PLUGIN);\n\tif (pSub)\n\t{\n\t\tCMenu* pChild = new CMenu();\n\t\tpChild->CreateMenu();\n\t\tint nCount = pPlugIn->getCommandCount();\n    if (nCount > 0)\n    {\n\t\t  while (nCount > 0)\n\t\t  {\n\t\t\t  menuText = pPlugIn->getCommand(--nCount);\n        if (menuText != NULL && strlen(menuText) > 0)\n        {\n\t\t\t    if(!strcmp(menuText, \"-\"))\n\t\t\t\t    pChild->AppendMenu(MF_SEPARATOR, NULL);\n\t\t\t    else\n\t\t\t\t    pChild->AppendMenu(MF_STRING, m_nNextPlugInID, menuText);\n\t\t\t    pPlugIn->addMenuID(m_nNextPlugInID++);\n        }\n\t\t  }\n\t\t  pSub->AppendMenu(MF_POPUP, reinterpret_cast<unsigned int>(pChild->GetSafeHmenu()), pPlugIn->getMenuName());\n    }\n\t}\n}\n\nvoid CMainFrame::OnPlugIn(unsigned int nID) \n{\n  CMenu* pMenu = GetMenu();\n  CString str;\n  pMenu->GetMenuString(nID, str, MF_BYCOMMAND);\n  m_PlugInMgr.Dispatch(nID, str);\n}\n\nvoid CMainFrame::OnViewShowhint() \n{\n\tif ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_HINT ) & EXCLUDE_HINT )\n    CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWHINT, MF_BYCOMMAND | MF_UNCHECKED );\n\telse\n    CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWHINT, MF_BYCOMMAND | MF_CHECKED );\n\tSys_UpdateWindows (W_XY|W_CAMERA);\n}\n\nvoid CMainFrame::OnTexturesShowall() \n{\n  Texture_ShowAll();\n}\n\nvoid CMainFrame::OnPatchInspector()\n{\n  DoPatchInspector();\n}\n\nvoid CMainFrame::OnViewOpengllighting() \n{\n  g_PrefsDlg.m_bGLLighting ^= 1;\n  g_PrefsDlg.SavePrefs();\n  CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_OPENGLLIGHTING, MF_BYCOMMAND | (g_PrefsDlg.m_bGLLighting) ? MF_CHECKED : MF_UNCHECKED );\n\tSys_UpdateWindows (W_XY|W_CAMERA);\n}\n\nvoid CMainFrame::OnSelectAll()\n{\n  Select_AllOfType();\n}\n\nvoid CMainFrame::OnViewShowcaulk() \n{\n\tif ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_CAULK ) & EXCLUDE_CAULK )\n    CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWCAULK, MF_BYCOMMAND | MF_UNCHECKED );\n\telse\n    CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWCAULK, MF_BYCOMMAND | MF_CHECKED );\n\tSys_UpdateWindows (W_XY|W_CAMERA);\n\t\n}\n\nvoid CMainFrame::OnCurveFreeze()\n{\n  Patch_Freeze();\n}\n\nvoid CMainFrame::OnCurveUnFreeze()\n{\n  Patch_UnFreeze(false);\n}\n\nvoid CMainFrame::OnCurveUnFreezeAll()\n{\n  Patch_UnFreeze(true);\n}\n\nvoid CMainFrame::OnSelectReselect()\n{\n  Select_Reselect();\n}\n\nvoid CMainFrame::OnViewShowangles() \n{\n\tif ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_ANGLES ) & EXCLUDE_ANGLES )\n    CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWANGLES, MF_BYCOMMAND | MF_UNCHECKED );\n\telse\n    CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWANGLES, MF_BYCOMMAND | MF_CHECKED );\n\tSys_UpdateWindows (W_XY|W_CAMERA);\n}\n\nvoid CMainFrame::OnEditSaveprefab() \n{\n  CFileDialog dlgFile(FALSE, \"pfb\", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, \"Prefab files (*.pfb)|*.pfb||\", this);\n  char CurPath[1024];\n  if (g_PrefsDlg.m_strPrefabPath.GetLength() > 0)\n  {\n    strcpy(CurPath, g_PrefsDlg.m_strPrefabPath);\n  }\n  else\n  {\n    ::GetCurrentDirectory(1024, CurPath);\n  }\n  dlgFile.m_ofn.lpstrInitialDir = CurPath;\n  if (dlgFile.DoModal() == IDOK)\n  {\n    Map_SaveSelected(dlgFile.GetPathName().GetBuffer(0));\n  }\n}\n\n\nvoid CMainFrame::OnEditLoadprefab() \n{\n  CFileDialog dlgFile(TRUE, \"pfb\", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, \"Prefab files (*.pfb)|*.pfb||\", this);\n  char CurPath[1024];\n  if (g_PrefsDlg.m_strPrefabPath.GetLength() > 0)\n  {\n    strcpy(CurPath, g_PrefsDlg.m_strPrefabPath);\n  }\n  else\n  {\n    ::GetCurrentDirectory(1024, CurPath);\n  }\n  dlgFile.m_ofn.lpstrInitialDir = CurPath;\n  if (dlgFile.DoModal() == IDOK)\n  {\n    Map_ImportFile(dlgFile.GetPathName().GetBuffer(0));\n  }\n}\n\nvoid CMainFrame::OnCurveMoreendcapsbevelsSquarebevel() \n{\n\tUndo_Start(\"square bevel\");\n\tUndo_AddBrushList(&selected_brushes);\n\n\tPatch_BrushToMesh(false, true, false, true);\n\tSys_UpdateWindows (W_ALL);\n\t\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnCurveMoreendcapsbevelsSquareendcap() \n{\n\tUndo_Start(\"square endcap\");\n\tUndo_AddBrushList(&selected_brushes);\n\n\tPatch_BrushToMesh(false, false, true, true);\n\tSys_UpdateWindows (W_ALL);\n\t\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nvoid CMainFrame::OnBrushPrimitivesSphere() \n{\n\tUndo_Start(\"make sphere\");\n\tUndo_AddBrushList(&selected_brushes);\n\n\tDoSides(false, true);\n\n\tUndo_EndBrushList(&selected_brushes);\n\tUndo_End();\n}\n\nextern bool g_bCrossHairs;\nvoid CMainFrame::OnViewCrosshair() \n{\n\tg_bCrossHairs ^= 1; \n\tSys_UpdateWindows (W_XY);\n}\n\nvoid CMainFrame::OnViewHideshowHideselected() \n{\n  Select_Hide();  \n  Select_Deselect();\n}\n\nvoid CMainFrame::OnViewHideshowShowhidden() \n{\n  Select_ShowAllHidden();\n}\n\nvoid CMainFrame::OnTexturesShadersShow() \n{\n  g_PrefsDlg.m_bShowShaders ^= 1;\n  CheckMenuItem ( ::GetMenu(g_qeglobals.d_hwndMain), ID_TEXTURES_SHADERS_SHOW, MF_BYCOMMAND | ((g_PrefsDlg.m_bShowShaders) ? MF_CHECKED : MF_UNCHECKED ));\n  Sys_UpdateWindows(W_TEXTURE);\n\t\n}\n\nvoid CMainFrame::OnTexturesFlushUnused() \n{\n  Texture_FlushUnused();\n  Sys_UpdateWindows(W_TEXTURE);\n}\n\nvoid CMainFrame::OnSelectionInvert()\n{\n  Select_Invert();\n  Sys_UpdateWindows(W_XY | W_Z | W_CAMERA);\n}\n\n\nvoid CMainFrame::OnViewGroups()\n{\n  if (m_nCurrentStyle == 0 || m_nCurrentStyle == 3)\n  {\n    if (::IsWindowVisible(g_qeglobals.d_hwndEntity) && inspector_mode == W_GROUP)\n      ::ShowWindow(g_qeglobals.d_hwndEntity, SW_HIDE);\n    else\n    {\n      ::ShowWindow(g_qeglobals.d_hwndEntity, SW_NORMAL);\n      SetInspectorMode(W_GROUP);\n    }\n  }\n  else\n  {\n    if (inspector_mode == W_GROUP && m_nCurrentStyle != QR_QE4)\n    {\n      if (::IsWindowVisible(g_qeglobals.d_hwndEntity))\n        ::ShowWindow(g_qeglobals.d_hwndEntity, SW_HIDE);\n      else\n        ::ShowWindow(g_qeglobals.d_hwndEntity, SW_NORMAL);\n    }\n    else\n    {\n      ::ShowWindow(g_qeglobals.d_hwndEntity, SW_NORMAL);\n      SetInspectorMode(W_GROUP);\n    }\n  }\n}\n\nvoid CMainFrame::OnDropGroupAddtoWorld() \n{\n  Select_AddToGroup(\"World\");\n  Sys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnDropGroupName() \n{\n  CNameDlg dlg(\"Name Selection\", this);\n  if (dlg.DoModal() == IDOK)\n  {\n    Select_Name(dlg.m_strName);\n    Sys_UpdateWindows (W_ALL);\n  }\n}\n\nvoid CMainFrame::OnDropGroupNewgroup() \n{\n\n}\n\nvoid CMainFrame::OnDropGroupRemove() \n{\n  Select_AddToGroup(\"World\");\n  Sys_UpdateWindows (W_ALL);\n}\n\nvoid CMainFrame::OnSplinesMode() \n{\n\tg_qeglobals.d_select_mode = sel_addpoint;\n\tg_qeglobals.selectObject = g_splineList->getPositionObj();\n\tg_splineList->clear();\n\tg_splineList->startEdit(true);\n\tshowCameraInspector();\n\tSys_UpdateWindows(W_ALL);\n}\n\nvoid CMainFrame::OnSplinesLoad() \n{\n\tg_splineList->load(\"maps/test.camera\");\n\tg_splineList->buildCamera();\n}\n\nvoid CMainFrame::OnSplinesSave() \n{\n\tg_splineList->save(\"maps/test.camera\");\n}\n\nvoid CMainFrame::OnSplinesEdit() \n{\n\tshowCameraInspector();\n\tSys_UpdateWindows(W_ALL);\n}\n\nextern void testCamSpeed();\nvoid CMainFrame::OnSplineTest() \n{\n\tlong start = GetTickCount();\n\tg_splineList->startCamera(start);\n\tfloat cycle = g_splineList->getTotalTime();\n\tlong msecs = cycle * 1000;\n\tlong current = start;\n\tvec3_t lookat;\n\tVectorClear(lookat);\n\tvec3_t dir;\n\twhile (current < start + msecs) {\n\t\tfloat fov;\n\t\tg_splineList->getCameraInfo(current, &g_pParentWnd->GetCamera()->Camera().origin[0], &dir[0], &fov);\n\t\tg_pParentWnd->GetCamera()->Camera().angles[1] = atan2 (dir[1], dir[0])*180/3.14159;\n\t\tg_pParentWnd->GetCamera()->Camera().angles[0] = asin (dir[2])*180/3.14159;\n\t    g_pParentWnd->UpdateWindows(W_XY | W_CAMERA);\n\t\tcurrent = GetTickCount();\n\t}\n\tg_splineList->setRunning(false);\n}\n\nvoid CMainFrame::OnSplinesTarget() \n{\n}\n\nvoid CMainFrame::OnSplinesTargetPoints() \n{\n}\n\nvoid CMainFrame::OnSplinesCameraPoints() \n{\n}\n\nvoid CMainFrame::OnPopupNewcameraInterpolated() \n{\n\tg_qeglobals.d_select_mode = sel_addpoint;\n\tg_qeglobals.selectObject = g_splineList->startNewCamera(idCameraPosition::INTERPOLATED);\n\tOnSplinesEdit();\n}\n\nvoid CMainFrame::OnPopupNewcameraSpline() \n{\n\tg_qeglobals.d_select_mode = sel_addpoint;\n\tg_qeglobals.selectObject = g_splineList->startNewCamera(idCameraPosition::SPLINE);\n\tOnSplinesEdit();\n}\n\nvoid CMainFrame::OnPopupNewcameraFixed() \n{\n\tg_qeglobals.d_select_mode = sel_addpoint;\n\tg_qeglobals.selectObject = g_splineList->startNewCamera(idCameraPosition::FIXED);\n\tOnSplinesEdit();\n}\n"
  },
  {
    "path": "q3radiant/MainFrm.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// MainFrm.h : interface of the CMainFrame class\n//\n/////////////////////////////////////////////////////////////////////////////\n\n#if !defined(AFX_MAINFRM_H__330BBF0A_731C_11D1_B539_00AA00A410FC__INCLUDED_)\n#define AFX_MAINFRM_H__330BBF0A_731C_11D1_B539_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n\n#include \"LstToolBar.h\"\n#include \"XYWnd.h\"\n#include \"TexWnd.h\"\n#include \"ZWnd.h\"\n#include \"CamWnd.h\"\n#include \"RADEditWnd.h\"\n#include \"TextureBar.h\"\n#include \"PlugInManager.h\"\n#include \"PlugIn.h\"\n#include \"groupdlg.h\"\n\n\nconst int RAD_SHIFT =   0x01;\nconst int RAD_ALT =     0x02;\nconst int RAD_CONTROL = 0x04;\nconst int RAD_PRESS   = 0x08;\n\nstruct SCommandInfo\n{\n  char* m_strCommand;\n  unsigned int   m_nKey;\n  unsigned int   m_nModifiers;\n  unsigned int m_nCommand;\n};\n\nstruct SKeyInfo\n{\n  char* m_strName;\n  unsigned int m_nVKKey;\n};\n\n\n\n\nclass CMainFrame : public CFrameWnd\n{\n\tDECLARE_DYNAMIC(CMainFrame)\npublic:\n\tCMainFrame();\n  void HandleKey(UINT nChar, UINT nRepCnt, UINT nFlags, bool bDown = true) \n  {\n    if (bDown)\n      OnKeyDown(nChar, nRepCnt, nFlags);\n    else\n      OnKeyUp(nChar, nRepCnt, nFlags);\n  };\n\n// Attributes\npublic:\n\n// Operations\npublic:\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CMainFrame)\n\tpublic:\n\tvirtual BOOL PreCreateWindow(CREATESTRUCT& cs);\n\tvirtual BOOL PreTranslateMessage(MSG* pMsg);\n\tprotected:\n\tvirtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);\n\tvirtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);\n\tvirtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);\n\tvirtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);\n\t//}}AFX_VIRTUAL\n\n// Implementation\npublic:\n  void UpdatePatchToolbarButtons();\n  void NudgeSelection(int nDirection, int nAmount);\n\tvoid UpdateTextureBar();\n  void SetButtonMenuStates();\n\tvoid SetTexValStatus();\n\tvoid SetGridStatus();\n\tvoid RoutineProcessing();\n\tCXYWnd* ActiveXY();\n\tvoid UpdateWindows(int nBits);\n\tvoid SetStatusText(int nPane, const char* pText);\n\tvoid UpdateStatusText();\n\tvoid SetWindowStyle(int nStyle);\n\tvirtual ~CMainFrame();\n  CXYWnd* GetXYWnd() {return m_pXYWnd;};\n  CXYWnd* GetXZWnd() {return m_pXZWnd;};\n  CXYWnd* GetYZWnd() {return m_pYZWnd;};\n  CCamWnd* GetCamera() {return m_pCamWnd;};\n  CTexWnd* GetTexWnd() {return m_pTexWnd;};\n  void SetActiveXY(CXYWnd* p) \n  {\n    if (m_pActiveXY)\n      m_pActiveXY->SetActive(false);\n\n    m_pActiveXY = p;\n\n    if (m_pActiveXY)\n      m_pActiveXY->SetActive(true);\n\n  };\n  int CurrentStyle() { return m_nCurrentStyle; };\n#ifdef _DEBUG\n\tvirtual void AssertValid() const;\n\tvirtual void Dump(CDumpContext& dc) const;\n#endif\n\nprotected:  // control bar embedded members\n\tCStatusBar  m_wndStatusBar;\n\tCLstToolBar m_wndToolBar;\n\tCLstToolBar m_wndScaleBar;\n\tCDialogBar m_wndHelpBar;\n\tCTextureBar m_wndTextureBar;\n  CSplitterWnd m_wndSplit;\n  CSplitterWnd m_wndSplit2;\n  CSplitterWnd m_wndSplit3;\n  CXYWnd* m_pXYWnd;\n  CXYWnd* m_pYZWnd;\n  CXYWnd* m_pXZWnd;\n  CCamWnd* m_pCamWnd;\n  CTexWnd* m_pTexWnd;\n  CZWnd* m_pZWnd;\n  CRADEditWnd* m_pEditWnd;\n  int m_nCurrentStyle;\n  CString m_strStatus[15];\n  CXYWnd* m_pActiveXY;\n  bool m_bCamPreview;\n  CPlugInManager m_PlugInMgr;\n  int m_nNextPlugInID;\n\n// Generated message map functions\nprotected:\n\tbool m_bDoLoop;\n\tbool m_bSplittersOK;\n\tvoid CreateQEChildren();\n  \tvoid LoadCommandMap();\n\tvoid ShowMenuItemKeyBindings(CMenu *pMenu);\n  \tvoid SetEntityCheck();\n\tafx_msg LRESULT OnBSPStatus(UINT wParam, long lParam);\n\tafx_msg LRESULT OnBSPDone(UINT wParam, long lParam);\npublic:\n\tvoid Nudge(int nDim, float fNudge);\n\n  \tCPlugInManager &GetPlugInMgr() {return m_PlugInMgr;};\n  \tvoid AddPlugInMenuItem(CPlugIn* pPlugIn);\n\tvoid CleanPlugInMenu();\n\n  // these are public so i can easily reflect messages\n  // from child windows..\n\t//{{AFX_MSG(CMainFrame)\n\tafx_msg void OnParentNotify(UINT message, LPARAM lParam);\n\tafx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);\n\tafx_msg void OnTimer(UINT nIDEvent);\n\tafx_msg void OnDestroy();\n\tafx_msg void OnClose();\n\tafx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);\n\tafx_msg void OnSize(UINT nType, int cx, int cy);\n\tafx_msg void ToggleCamera();\n\tafx_msg void OnFileClose();\n\tafx_msg void OnFileExit();\n\tafx_msg void OnFileLoadproject();\n\tafx_msg void OnFileNew();\n\tafx_msg void OnFileOpen();\n\tafx_msg void OnFilePointfile();\n\tafx_msg void OnFilePrint();\n\tafx_msg void OnFilePrintPreview();\n\tafx_msg void OnFileSave();\n\tafx_msg void OnFileSaveas();\n\tafx_msg void OnView100();\n\tafx_msg void OnViewCenter();\n\tafx_msg void OnViewConsole();\n\tafx_msg void OnViewDownfloor();\n\tafx_msg void OnViewEntity();\n\tafx_msg void OnViewFront();\n\tafx_msg void OnViewShowblocks();\n\tafx_msg void OnViewShowclip();\n\tafx_msg void OnViewShowcoordinates();\n\tafx_msg void OnViewShowdetail();\n\tafx_msg void OnViewShowent();\n\tafx_msg void OnViewShowlights();\n\tafx_msg void OnViewShownames();\n\tafx_msg void OnViewShowpath();\n\tafx_msg void OnViewShowwater();\n\tafx_msg void OnViewShowworld();\n\tafx_msg void OnViewTexture();\n\tafx_msg void OnViewUpfloor();\n\tafx_msg void OnViewXy();\n\tafx_msg void OnViewZ100();\n\tafx_msg void OnViewZoomin();\n\tafx_msg void OnViewZoomout();\n\tafx_msg void OnViewZzoomin();\n\tafx_msg void OnViewZzoomout();\n\tafx_msg void OnViewSide();\n\tafx_msg void OnTexturesShowinuse();\n\tafx_msg void OnTexturesInspector();\n\tafx_msg void OnMiscBenchmark();\n\tafx_msg void OnMiscFindbrush();\n\tafx_msg void OnMiscGamma();\n\tafx_msg void OnMiscNextleakspot();\n\tafx_msg void OnMiscPreviousleakspot();\n\tafx_msg void OnMiscPrintxy();\n\tafx_msg void OnMiscSelectentitycolor();\n\tafx_msg void OnTexturebk();\n\tafx_msg void OnColorsMajor();\n\tafx_msg void OnColorsMinor();\n\tafx_msg void OnColorsXybk();\n\tafx_msg void OnBrush3sided();\n\tafx_msg void OnBrush4sided();\n\tafx_msg void OnBrush5sided();\n\tafx_msg void OnBrush6sided();\n\tafx_msg void OnBrush7sided();\n\tafx_msg void OnBrush8sided();\n\tafx_msg void OnBrush9sided();\n\tafx_msg void OnBrushArbitrarysided();\n\tafx_msg void OnBrushFlipx();\n\tafx_msg void OnBrushFlipy();\n\tafx_msg void OnBrushFlipz();\n\tafx_msg void OnBrushRotatex();\n\tafx_msg void OnBrushRotatey();\n\tafx_msg void OnBrushRotatez();\n\tafx_msg void OnRegionOff();\n\tafx_msg void OnRegionSetbrush();\n\tafx_msg void OnRegionSetselection();\n\tafx_msg void OnRegionSettallbrush();\n\tafx_msg void OnRegionSetxy();\n\tafx_msg void OnSelectionArbitraryrotation();\n\tafx_msg void OnSelectionClone();\n\tafx_msg void OnSelectionConnect();\n\tafx_msg void OnSelectionCsgsubtract();\n\tafx_msg void OnSelectionCsgmerge();\n\tafx_msg void OnSelectionNoOutline();\n\tafx_msg void OnSelectionDelete();\n\tafx_msg void OnSelectionDeselect();\n\tafx_msg void OnSelectionDragedges();\n\tafx_msg void OnSelectionDragvertecies();\n\tafx_msg void OnRaiseLowerTerrain();\n\tafx_msg void OnSelectionMakeDetail();\n\tafx_msg void OnSelectionMakeStructural();\n\tafx_msg void OnSelectionMakehollow();\n\tafx_msg void OnSelectionSelectcompletetall();\n\tafx_msg void OnSelectionSelectinside();\n\tafx_msg void OnSelectionSelectpartialtall();\n\tafx_msg void OnSelectionSelecttouching();\n\tafx_msg void OnSelectionUngroupentity();\n\tafx_msg void OnTexturesPopup();\n\tafx_msg void OnSplinesPopup();\n\tafx_msg void OnPopupSelection();\n\tafx_msg void OnViewChange();\n\tafx_msg void OnViewCameraupdate();\n\tafx_msg void OnUpdateViewCameraupdate(CCmdUI* pCmdUI);\n\tafx_msg void OnSizing(UINT fwSide, LPRECT pRect);\n\tafx_msg void OnHelpAbout();\n\tafx_msg void OnViewClipper();\n\tafx_msg void OnCameraAngledown();\n\tafx_msg void OnCameraAngleup();\n\tafx_msg void OnCameraBack();\n\tafx_msg void OnCameraDown();\n\tafx_msg void OnCameraForward();\n\tafx_msg void OnCameraLeft();\n\tafx_msg void OnCameraRight();\n\tafx_msg void OnCameraStrafeleft();\n\tafx_msg void OnCameraStraferight();\n\tafx_msg void OnCameraUp();\n\tafx_msg void OnGridToggle();\n\tafx_msg void OnPrefs();\n\tafx_msg void OnTogglecamera();\n\tafx_msg void OnToggleconsole();\n\tafx_msg void OnToggleview();\n\tafx_msg void OnTogglez();\n\tafx_msg void OnToggleLock();\n\tafx_msg void OnEditMapinfo();\n\tafx_msg void OnEditEntityinfo();\n\tafx_msg void OnBrushScripts();\n\tafx_msg void OnViewNextview();\n\tafx_msg void OnHelpCommandlist();\n\tafx_msg void OnFileNewproject();\n\tafx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);\n\tafx_msg void OnFlipClip();\n\tafx_msg void OnClipSelected();\n\tafx_msg void OnSplitSelected();\n\tafx_msg void OnToggleviewXz();\n\tafx_msg void OnToggleviewYz();\n\tafx_msg void OnColorsBrush();\n\tafx_msg void OnColorsClipper();\n\tafx_msg void OnColorsGridtext();\n\tafx_msg void OnColorsSelectedbrush();\n\tafx_msg void OnColorsGridblock();\n\tafx_msg void OnColorsViewname();\n\tafx_msg void OnColorSetoriginal();\n\tafx_msg void OnColorSetqer();\n\tafx_msg void OnColorSetblack();\n\tafx_msg void OnSnaptogrid();\n\tafx_msg void OnSelectScale();\n\tafx_msg void OnSelectMouserotate();\n\tafx_msg void OnEditCopybrush();\n\tafx_msg void OnEditPastebrush();\n\tafx_msg void OnEditUndo();\n\tafx_msg void OnEditRedo();\n\tafx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI);\n\tafx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI);\n\tafx_msg void OnSelectionInvert();\n\tafx_msg void OnSelectionTextureDec();\n\tafx_msg void OnSelectionTextureFit();\n\tafx_msg void OnSelectionTextureInc();\n\tafx_msg void OnSelectionTextureRotateclock();\n\tafx_msg void OnSelectionTextureRotatecounter();\n\tafx_msg void OnSelectionTextureScaledown();\n\tafx_msg void OnSelectionTextureScaleup();\n\tafx_msg void OnSelectionTextureShiftdown();\n\tafx_msg void OnSelectionTextureShiftleft();\n\tafx_msg void OnSelectionTextureShiftright();\n\tafx_msg void OnSelectionTextureShiftup();\n\tafx_msg void OnGridNext();\n\tafx_msg void OnGridPrev();\n\tafx_msg void OnSelectionTextureScaleLeft();\n\tafx_msg void OnSelectionTextureScaleRight();\n\tafx_msg void OnTextureReplaceall();\n\tafx_msg void OnScalelockx();\n\tafx_msg void OnScalelocky();\n\tafx_msg void OnScalelockz();\n\tafx_msg void OnSelectMousescale();\n\tafx_msg void OnViewCubicclipping();\n\tafx_msg void OnFileImport();\n\tafx_msg void OnFileProjectsettings();\n\tafx_msg void OnUpdateFileImport(CCmdUI* pCmdUI);\n\tafx_msg void OnViewCubein();\n\tafx_msg void OnViewCubeout();\n\tafx_msg void OnFileSaveregion();\n\tafx_msg void OnUpdateFileSaveregion(CCmdUI* pCmdUI);\n\tafx_msg void OnSelectionMovedown();\n\tafx_msg void OnSelectionMoveup();\n\tafx_msg void OnToolbarMain();\n\tafx_msg void OnToolbarTexture();\n\tafx_msg void OnSelectionPrint();\n\tafx_msg void OnSelectionTogglesizepaint();\n\tafx_msg void OnBrushMakecone();\n\tafx_msg void OnTexturesLoad();\n\tafx_msg void OnToggleRotatelock();\n\tafx_msg void OnCurveBevel();\n\tafx_msg void OnCurveCylinder();\n\tafx_msg void OnCurveEighthsphere();\n\tafx_msg void OnCurveEndcap();\n\tafx_msg void OnCurveHemisphere();\n\tafx_msg void OnCurveInvertcurve();\n\tafx_msg void OnCurveQuarter();\n\tafx_msg void OnCurveSphere();\n\tafx_msg void OnFileImportmap();\n\tafx_msg void OnFileExportmap();\n\tafx_msg void OnEditLoadprefab();\n\tafx_msg void OnViewShowcurves();\n\tafx_msg void OnSelectionSelectNudgedown();\n\tafx_msg void OnSelectionSelectNudgeleft();\n\tafx_msg void OnSelectionSelectNudgeright();\n\tafx_msg void OnSelectionSelectNudgeup();\n\tafx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);\n\tafx_msg void OnTexturesLoadlist();\n\tafx_msg void OnDontselectcurve();\n\tafx_msg void OnConvertcurves();\n\tafx_msg void OnDynamicLighting();\n\tafx_msg void OnCurveSimplepatchmesh();\n\tafx_msg void OnPatchToggleBox();\n\tafx_msg void OnPatchWireframe();\n\tafx_msg void OnCurvePatchcone();\n\tafx_msg void OnCurvePatchtube();\n\tafx_msg void OnPatchWeld();\n\tafx_msg void OnCurvePatchbevel();\n\tafx_msg void OnCurvePatchendcap();\n\tafx_msg void OnCurvePatchinvertedbevel();\n\tafx_msg void OnCurvePatchinvertedendcap();\n\tafx_msg void OnPatchDrilldown();\n\tafx_msg void OnCurveInsertcolumn();\n\tafx_msg void OnCurveInsertrow();\n\tafx_msg void OnCurveDeletecolumn();\n\tafx_msg void OnCurveDeleterow();\n\tafx_msg void OnCurveInsertAddcolumn();\n\tafx_msg void OnCurveInsertAddrow();\n\tafx_msg void OnCurveInsertInsertcolumn();\n\tafx_msg void OnCurveInsertInsertrow();\n\tafx_msg void OnCurveNegative();\n\tafx_msg void OnCurveNegativeTextureX();\n\tafx_msg void OnCurveNegativeTextureY();\n\tafx_msg void OnCurveDeleteFirstcolumn();\n\tafx_msg void OnCurveDeleteFirstrow();\n\tafx_msg void OnCurveDeleteLastcolumn();\n\tafx_msg void OnCurveDeleteLastrow();\n\tafx_msg void OnPatchBend();\n\tafx_msg void OnPatchInsdel();\n\tafx_msg void OnPatchEnter();\n\tafx_msg void OnPatchTab();\n\tafx_msg void OnCurvePatchdensetube();\n\tafx_msg void OnCurvePatchverydensetube();\n\tafx_msg void OnCurveCap();\n\tafx_msg void OnCurveCapInvertedbevel();\n\tafx_msg void OnCurveCapInvertedendcap();\n\tafx_msg void OnCurveRedisperseCols();\n\tafx_msg void OnCurveRedisperseRows();\n\tafx_msg void OnPatchNaturalize();\n\tafx_msg void OnSnapToGrid();\n\tafx_msg void OnCurvePatchsquare();\n\tafx_msg void OnTerrainCreateFromBrush();\n\tafx_msg void OnTexturesTexturewindowscale10();\n\tafx_msg void OnTexturesTexturewindowscale100();\n\tafx_msg void OnTexturesTexturewindowscale200();\n\tafx_msg void OnTexturesTexturewindowscale25();\n\tafx_msg void OnTexturesTexturewindowscale50();\n\tafx_msg void OnTexturesFlush();\n\tafx_msg void OnCurveOverlayClear();\n\tafx_msg void OnCurveOverlaySet();\n\tafx_msg void OnCurveThicken();\n\tafx_msg void OnCurveCyclecap();\n\tafx_msg void OnCurveMatrixTranspose();\n\tafx_msg void OnTexturesReloadshaders();\n\tafx_msg void OnShowEntities();\n\tafx_msg void OnViewEntitiesasBoundingbox();\n\tafx_msg void OnViewEntitiesasSelectedskinned();\n\tafx_msg void OnViewEntitiesasSelectedwireframe();\n\tafx_msg void OnViewEntitiesasSkinned();\n\tafx_msg void OnViewEntitiesasSkinnedandboxed();\n\tafx_msg void OnViewEntitiesasWireframe();\n\tafx_msg void OnPluginsRefresh();\n\tafx_msg void OnViewShowhint();\n\tafx_msg void OnUpdateTexturesShowinuse(CCmdUI* pCmdUI);\n\tafx_msg void OnTexturesShowall();\n\tafx_msg void OnPatchInspector();\n\tafx_msg void OnViewOpengllighting();\n\tafx_msg void OnSelectAll();\n\tafx_msg void OnViewShowcaulk();\n  afx_msg void OnCurveFreeze();\n  afx_msg void OnCurveUnFreeze();\n  afx_msg void OnCurveUnFreezeAll();\n  afx_msg void OnSelectReselect();\n\tafx_msg void OnViewShowangles();\n\tafx_msg void OnEditSaveprefab();\n\tafx_msg void OnCurveMoreendcapsbevelsSquarebevel();\n\tafx_msg void OnCurveMoreendcapsbevelsSquareendcap();\n\tafx_msg void OnBrushPrimitivesSphere();\n\tafx_msg void OnViewCrosshair();\n\tafx_msg void OnViewHideshowHideselected();\n\tafx_msg void OnViewHideshowShowhidden();\n\tafx_msg void OnTexturesShadersShow();\n\tafx_msg void OnTexturesFlushUnused();\n\tafx_msg void OnViewGroups();\n\tafx_msg void OnDropGroupAddtoWorld();\n\tafx_msg void OnDropGroupName();\n\tafx_msg void OnDropGroupNewgroup();\n\tafx_msg void OnDropGroupRemove();\n\tafx_msg void OnSplinesMode();\n\tafx_msg void OnSplinesLoad();\n\tafx_msg void OnSplinesSave();\n\tafx_msg void OnSplinesEdit();\n\tafx_msg void OnSplineTest();\n\tafx_msg void OnSplinesTarget();\n\tafx_msg void OnSplinesTargetPoints();\n\tafx_msg void OnSplinesCameraPoints();\n\tafx_msg void OnPopupNewcameraInterpolated();\n\tafx_msg void OnPopupNewcameraSpline();\n\tafx_msg void OnPopupNewcameraFixed();\n\t//}}AFX_MSG\n  afx_msg void OnMru(unsigned int nID);\n  afx_msg void OnViewNearest(unsigned int nID);\n  afx_msg void OnTextureWad(unsigned int nID);\n  afx_msg void OnBspCommand(unsigned int nID);\n  afx_msg void OnGrid1(unsigned int nID);\n  afx_msg LRESULT OnDisplayChange(WPARAM wp, LPARAM lp);\n  void CheckTextureScale(int id);\n  afx_msg void OnPlugIn(unsigned int nID);\n\n\tDECLARE_MESSAGE_MAP()\n};\n\n/////////////////////////////////////////////////////////////////////////////\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_MAINFRM_H__330BBF0A_731C_11D1_B539_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/MapInfo.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// MapInfo.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"MapInfo.h\"\n#include \"qe3.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CMapInfo dialog\n\n\nCMapInfo::CMapInfo(CWnd* pParent /*=NULL*/)\n\t: CDialog(CMapInfo::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CMapInfo)\n\tm_nNet = 0;\n\tm_nTotalBrushes = 0;\n\tm_nTotalEntities = 0;\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CMapInfo::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CMapInfo)\n\tDDX_Control(pDX, IDC_LIST_ENTITIES, m_lstEntity);\n\tDDX_Text(pDX, IDC_EDIT_NET, m_nNet);\n\tDDX_Text(pDX, IDC_EDIT_TOTALBRUSHES, m_nTotalBrushes);\n\tDDX_Text(pDX, IDC_EDIT_TOTALENTITIES, m_nTotalEntities);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CMapInfo, CDialog)\n\t//{{AFX_MSG_MAP(CMapInfo)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CMapInfo message handlers\n\nBOOL CMapInfo::OnInitDialog() \n{\n\tCDialog::OnInitDialog();\n\n  m_nTotalBrushes = 0;\n  m_nTotalEntities = 0;\n  m_nNet = 0;\n\tfor (brush_t* pBrush=active_brushes.next ; pBrush != &active_brushes ; pBrush=pBrush->next)\n  {\n    m_nTotalBrushes++;\n    if (pBrush->owner == world_entity)\n      m_nNet++;\n  }\n\n\n  CMapStringToPtr mapEntity;\n\n  int nValue = 0;\n\tfor (entity_t* pEntity=entities.next ; pEntity != &entities ; pEntity=pEntity->next)\n\t{\n    m_nTotalEntities++;\n    nValue = 0;\n    mapEntity.Lookup(pEntity->eclass->name, reinterpret_cast<void*&>(nValue));\n    nValue++ ;\n    mapEntity.SetAt(pEntity->eclass->name, reinterpret_cast<void*>(nValue));\n  }\n\n  m_lstEntity.ResetContent();\n  m_lstEntity.SetTabStops(96);\n  CString strKey;\n  POSITION pos = mapEntity.GetStartPosition();\n  while (pos)\n  {\n    mapEntity.GetNextAssoc(pos, strKey, reinterpret_cast<void*&>(nValue));\n    CString strList;\n    strList.Format(\"%s\\t%i\", strKey, nValue);\n    m_lstEntity.AddString(strList);\n  }\n\n  UpdateData(FALSE);\n\t\n\treturn TRUE;  // return TRUE unless you set the focus to a control\n\t              // EXCEPTION: OCX Property Pages should return FALSE\n}\n"
  },
  {
    "path": "q3radiant/MapInfo.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_MAPINFO_H__C241B9A2_819F_11D1_B548_00AA00A410FC__INCLUDED_)\n#define AFX_MAPINFO_H__C241B9A2_819F_11D1_B548_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// MapInfo.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CMapInfo dialog\n\nclass CMapInfo : public CDialog\n{\n// Construction\npublic:\n\tCMapInfo(CWnd* pParent = NULL);   // standard constructor\n\n// Dialog Data\n\t//{{AFX_DATA(CMapInfo)\n\tenum { IDD = IDD_DLG_MAPINFO };\n\tCListBox\tm_lstEntity;\n\tint\t\tm_nNet;\n\tint\t\tm_nTotalBrushes;\n\tint\t\tm_nTotalEntities;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CMapInfo)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CMapInfo)\n\tvirtual BOOL OnInitDialog();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_MAPINFO_H__C241B9A2_819F_11D1_B548_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/Messaging.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//-----------------------------------------------------------------------------\n//\n// $LogFile$\n// $Revision: 1.1.2.1 $\n// $Author: ttimo $\n// $Date: 2000/02/04 22:59:34 $\n// $Log: Messaging.cpp,v $\n// Revision 1.1.2.1  2000/02/04 22:59:34  ttimo\n// messaging API preview\n//\n//\n// DESCRIPTION:\n// implementation of IMessaging specific interface\n// \n\n#include \"stdafx.h\"\n\nCPtrArray l_Listeners[RADIANT_MSGCOUNT];\nCPtrArray l_WindowListeners;\nCXYWndWrapper l_XYWndWrapper;\n\nvoid WINAPI QERApp_HookWindow(IWindowListener* pListen)\n{\n\tl_WindowListeners.Add( pListen );\n\tpListen->IncRef();\n}\n\nvoid WINAPI QERApp_UnHookWindow(IWindowListener* pListen)\n{\n\tfor ( int i = 0; i < l_WindowListeners.GetSize(); i++ )\n\t{\n\t\tif (l_WindowListeners.GetAt(i) == pListen)\n\t\t{\n\t\t\tl_WindowListeners.RemoveAt(i);\n\t\t\tpListen->DecRef();\n\t\t\treturn;\n\t\t}\n\t}\n#ifdef _DEBUG\n\tSys_Printf(\"WARNING: IWindowListener not found in QERApp_UnHookWindow\\n\");\n#endif\n}\n\nvoid DispatchOnMouseMove(UINT nFlags, int x, int y)\n{\n\tfor( int i = 0; i < l_WindowListeners.GetSize(); i++ )\n\t\tstatic_cast<IWindowListener*>(l_WindowListeners.GetAt(i))->OnMouseMove( nFlags, x, y );\n}\n\nbool DispatchOnLButtonDown(UINT nFlags, int x, int y)\n{\n\tfor( int i = 0; i < l_WindowListeners.GetSize(); i++ )\n\t\tif (static_cast<IWindowListener*>(l_WindowListeners.GetAt(i))->OnLButtonDown( nFlags, x, y ))\n\t\t\treturn true;\n\treturn false;\n}\n\nbool DispatchOnLButtonUp(UINT nFlags, int x, int y)\n{\n\tfor( int i = 0; i < l_WindowListeners.GetSize(); i++ )\n\t\tif (static_cast<IWindowListener*>(l_WindowListeners.GetAt(i))->OnLButtonUp( nFlags, x, y ))\n\t\t\treturn true;\n\treturn false;\n}\n\nvoid WINAPI QERApp_HookListener(IListener* pListen, int Msg)\n{\n#ifdef _DEBUG\n\tif (Msg >= RADIANT_MSGCOUNT)\n\t{\n\t\tSys_Printf(\"ERROR: bad index in QERApp_HookListener\\n\");\n\t\treturn;\n\t}\n#endif\n\tl_Listeners[Msg].Add( pListen );\n\tpListen->IncRef();\n}\n\nint  WINAPI QERApp_UnHookListener(IListener* pListen)\n{\n\tint count = 0;\n\tfor( int i = 0; i<RADIANT_MSGCOUNT; i++ )\n\t\tfor( int j = 0; j<l_Listeners[i].GetSize(); j++ )\n\t\t\tif (l_Listeners[i].GetAt(j) == pListen)\n\t\t\t{\n\t\t\t\tl_Listeners[i].RemoveAt(j);\n\t\t\t\tpListen->DecRef();\n\t\t\t\tcount++;\n\t\t\t}\n\treturn count;\n}\n\nvoid DispatchRadiantMsg( int Msg )\n{\n#ifdef _DEBUG\n\tif (Msg >= RADIANT_MSGCOUNT)\n\t{\n\t\tSys_Printf(\"ERROR: bad index in DispatchRadiantMsg\\n\");\n\t\treturn;\n\t}\n#endif\n\tfor(int i = 0; i<l_Listeners[Msg].GetSize(); i++)\n\t\tstatic_cast<IListener *>(l_Listeners[Msg].GetAt(i))->DispatchRadiantMsg(Msg);\n}\n\nvoid CXYWndWrapper::SnapToGrid( int x1, int y1, vec3_t pt )\n{\n\tCRect rctZ;\n\tg_pParentWnd->ActiveXY()->GetClientRect( rctZ );\n\tg_pParentWnd->ActiveXY()->SnapToPoint( x1, rctZ.Height() - 1 - y1, pt );\n}\n\nIXYWndWrapper* WINAPI QERApp_GetXYWndWrapper()\n{\n\treturn &l_XYWndWrapper;\n}\n"
  },
  {
    "path": "q3radiant/Messaging.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//-----------------------------------------------------------------------------\n//\n// $LogFile$\n// $Revision: 1.1.2.1 $\n// $Author: ttimo $\n// $Date: 2000/02/04 22:59:34 $\n// $Log: Messaging.h,v $\n// Revision 1.1.2.1  2000/02/04 22:59:34  ttimo\n// messaging API preview\n//\n//\n// DESCRIPTION:\n// headers for internal classes used in Messaging.cpp\n// \n\n#ifndef __MESSAGING_H_\n#define __MESSAGING_H_\n\nclass CXYWndWrapper : public IXYWndWrapper\n{\npublic:\n\tvoid SnapToGrid( int x1, int y1, vec3_t pt );\n};\n\n#endif"
  },
  {
    "path": "q3radiant/NameDlg.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// NameDlg.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"NameDlg.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CNameDlg dialog\n\n\nCNameDlg::CNameDlg(const char *pName, CWnd* pParent /*=NULL*/)\n\t: CDialog(CNameDlg::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CNameDlg)\n\tm_strName = _T(\"\");\n\t//}}AFX_DATA_INIT\n  m_strCaption = pName;\n}\n\n\nvoid CNameDlg::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CNameDlg)\n\tDDX_Text(pDX, IDC_EDIT_NAME, m_strName);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CNameDlg, CDialog)\n\t//{{AFX_MSG_MAP(CNameDlg)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CNameDlg message handlers\n\nvoid CNameDlg::OnOK() \n{\n\tCDialog::OnOK();\n}\n\nBOOL CNameDlg::OnInitDialog() \n{\n\tCDialog::OnInitDialog();\n\n  SetWindowText(m_strCaption);\n\t\n\treturn TRUE;  // return TRUE unless you set the focus to a control\n\t              // EXCEPTION: OCX Property Pages should return FALSE\n}\n"
  },
  {
    "path": "q3radiant/NameDlg.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_NAMEDLG_H__624F3290_976A_48A9_AE89_50CD1E6E2F9A__INCLUDED_)\n#define AFX_NAMEDLG_H__624F3290_976A_48A9_AE89_50CD1E6E2F9A__INCLUDED_\n\n#if _MSC_VER > 1000\n#pragma once\n#endif // _MSC_VER > 1000\n// NameDlg.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CNameDlg dialog\n\nclass CNameDlg : public CDialog\n{\n  CString m_strCaption;\n// Construction\npublic:\n\tCNameDlg(const char *pName, CWnd* pParent = NULL);   // standard constructor\n\n// Dialog Data\n\t//{{AFX_DATA(CNameDlg)\n\tenum { IDD = IDD_NEWNAME };\n\tCString\tm_strName;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CNameDlg)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CNameDlg)\n\tvirtual void OnOK();\n\tvirtual BOOL OnInitDialog();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Visual C++ will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_NAMEDLG_H__624F3290_976A_48A9_AE89_50CD1E6E2F9A__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/NewProjDlg.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// NewProjDlg.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"NewProjDlg.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CNewProjDlg dialog\n\n\nCNewProjDlg::CNewProjDlg(CWnd* pParent /*=NULL*/)\n\t: CDialog(CNewProjDlg::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CNewProjDlg)\n\tm_strName = _T(\"\");\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CNewProjDlg::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CNewProjDlg)\n\tDDX_Text(pDX, IDC_EDIT_NAME, m_strName);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CNewProjDlg, CDialog)\n\t//{{AFX_MSG_MAP(CNewProjDlg)\n\t\t// NOTE: the ClassWizard will add message map macros here\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CNewProjDlg message handlers\n"
  },
  {
    "path": "q3radiant/NewProjDlg.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_NEWPROJDLG_H__1E2527A2_8447_11D1_B548_00AA00A410FC__INCLUDED_)\n#define AFX_NEWPROJDLG_H__1E2527A2_8447_11D1_B548_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// NewProjDlg.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CNewProjDlg dialog\n\nclass CNewProjDlg : public CDialog\n{\n// Construction\npublic:\n\tCNewProjDlg(CWnd* pParent = NULL);   // standard constructor\n\n// Dialog Data\n\t//{{AFX_DATA(CNewProjDlg)\n\tenum { IDD = IDD_DLG_NEWPROJECT };\n\tCString\tm_strName;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CNewProjDlg)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CNewProjDlg)\n\t\t// NOTE: the ClassWizard will add member functions here\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_NEWPROJDLG_H__1E2527A2_8447_11D1_B548_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/PARSE.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"stdafx.h\"\n#include \"qe3.h\"\n\nchar\ttoken[MAXTOKEN];\nqboolean\tunget;\nchar\t*script_p;\nint\t\tscriptline;\n\nvoid\tStartTokenParsing (char *data)\n{\n\tscriptline = 1;\n\tscript_p = data;\n\tunget = false;\n}\n\nqboolean WINAPI GetToken (qboolean crossline)\n{\n\tchar    *token_p;\n\n\tif (unget)                         // is a token allready waiting?\n\t{\n\t\tunget = false;\n\t\treturn true;\n\t}\n\n//\n// skip space\n//\nskipspace:\n\twhile (*script_p <= 32)\n\t{\n\t\tif (!*script_p)\n\t\t{\n\t\t\tif (!crossline)\n\t\t\t\tSys_Printf(\"Warning: Line %i is incomplete [01]\\n\",scriptline);\n\t\t\treturn false;\n\t\t}\n\t\tif (*script_p++ == '\\n')\n\t\t{\n\t\t\tif (!crossline)\n\t\t\t\tSys_Printf(\"Warning: Line %i is incomplete [02]\\n\",scriptline);\n\t\t\tscriptline++;\n\t\t}\n\t}\n\n\tif (script_p[0] == '/' && script_p[1] == '/')\t// comment field\n\t{\n\t\tif (!crossline)\n\t\t\tSys_Printf(\"Warning: Line %i is incomplete [03]\\n\",scriptline);\n\t\twhile (*script_p++ != '\\n')\n\t\t\tif (!*script_p)\n\t\t\t{\n\t\t\t\tif (!crossline)\n\t\t\t\t\tSys_Printf(\"Warning: Line %i is incomplete [04]\\n\",scriptline);\n\t\t\t\treturn false;\n\t\t\t}\n\t\tgoto skipspace;\n\t}\n\n//\n// copy token\n//\n\ttoken_p = token;\n\n\tif (*script_p == '\"')\n\t{\n\t\tscript_p++;\n    //if (*script_p == '\"')   // handle double quotes i suspect they are put in by other editors cccasionally\n    //  script_p++;\n\t\twhile ( *script_p != '\"' )\n\t\t{\n\t\t\tif (!*script_p)\n\t\t\t\tError (\"EOF inside quoted token\");\n\t\t\t*token_p++ = *script_p++;\n\t\t\tif (token_p == &token[MAXTOKEN])\n\t\t\t\tError (\"Token too large on line %i\",scriptline);\n\t\t}\n\t\tscript_p++;\n    //if (*script_p == '\"')   // handle double quotes i suspect they are put in by other editors cccasionally\n    //  script_p++;\n\t}\n\telse while ( *script_p > 32 )\n\t{\n\t\t*token_p++ = *script_p++;\n\t\tif (token_p == &token[MAXTOKEN])\n\t\t\tError (\"Token too large on line %i\",scriptline);\n\t}\n\n\t*token_p = 0;\n\t\n\treturn true;\n}\n\nvoid WINAPI UngetToken (void)\n{\n\tunget = true;\n}\n\n\n/*\n==============\nTokenAvailable\n\nReturns true if there is another token on the line\n==============\n*/\nqboolean TokenAvailable (void)\n{\n\tchar    *search_p;\n\n\tsearch_p = script_p;\n\n\twhile ( *search_p <= 32)\n\t{\n\t\tif (*search_p == '\\n')\n\t\t\treturn false;\n\t\tif (*search_p == 0)\n\t\t\treturn false;\n\t\tsearch_p++;\n\t}\n\n\tif (*search_p == ';')\n\t\treturn false;\n\n\treturn true;\n}\n\n"
  },
  {
    "path": "q3radiant/PARSE.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// parse.h -- text file parsing routines\n\n#define\tMAXTOKEN\t1024\n\nextern\tchar\ttoken[MAXTOKEN];\nextern\tint\t\tscriptline;\n\n// NOTE: added WINAPI call syntax to export these for plugins in _QERScripLibTable\nvoid\tStartTokenParsing (char *data);\nqboolean WINAPI GetToken (qboolean crossline);\nvoid WINAPI UngetToken (void);\nqboolean TokenAvailable (void);\n\n"
  },
  {
    "path": "q3radiant/PMESH.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// \n// Preliminary patch stuff\n//\n// \n\n#include \"stdafx.h\"\n#include \"qe3.h\"\n#include \"DialogInfo.h\"\n#include \"CapDialog.h\"\n\n// externs\nextern void MemFile_fprintf(CMemFile* pMemFile, const char* pText, ...);\nextern face_t *Face_Alloc( void );\nvoid _Write3DMatrix (FILE *f, int y, int x, int z, float *m);\nvoid _Write3DMatrix (CMemFile *f, int y, int x, int z, float *m);\n\n\n\n#define\tCBLOCK_SUBDIVISIONS\t6 \n\n\npatchMesh_t* MakeNewPatch()\n{\n  patchMesh_t *pm = reinterpret_cast<patchMesh_t*>(qmalloc(sizeof(patchMesh_t)));\n  if (g_qeglobals.bSurfacePropertiesPlugin)\n  {\n\t  pm->pData = static_cast<void *>( g_SurfaceTable.m_pfnPatchAlloc( pm ) );\n  }\n  return pm;\n}\n\n// FIXME: this needs to be dynamic\n//#define\tMAX_PATCH_MESHES\t4096\n//patchMesh_t\t\tpatchMeshes[MAX_PATCH_MESHES];\n//int numPatchMeshes = 0;\n\n// used for a save spot\npatchMesh_t patchSave;\n\n// Tracks the selected patch for point manipulation/update. FIXME: Need to revert back to a generalized \n// brush approach\n//--int  g_nSelectedPatch = -1;  \n\n// HACK: for tracking which view generated the click\n// as we dont want to deselect a point on a same point\n// click if it is from a different view\nint  g_nPatchClickedView = -1;\nbool g_bSameView = false;\n\n\n// globals\nbool g_bPatchShowBounds = true;\nbool g_bPatchWireFrame = false;\nbool g_bPatchWeld = true;\nbool g_bPatchDrillDown = true;\nbool g_bPatchInsertMode = false;\nbool g_bPatchBendMode = false;\nint  g_nPatchBendState = -1;\nint  g_nPatchInsertState = -1;\nint  g_nBendOriginIndex = 0;\nvec3_t g_vBendOrigin;\n\nbool g_bPatchAxisOnRow = true;\nint  g_nPatchAxisIndex = 0;\nbool g_bPatchLowerEdge = true;\n\n// BEND states\nenum\n{\n  BEND_SELECT_ROTATION = 0,\n  BEND_SELECT_ORIGIN,\n  BEND_SELECT_EDGE,\n  BEND_BENDIT,\n  BEND_STATE_COUNT\n};\n\nconst char *g_pBendStateMsg[] =\n{\n  \"Use TAB to cycle through available bend axis. Press ENTER when the desired one is highlighted.\",\n  \"Use TAB to cycle through available rotation axis. This will LOCK around that point. You may also use Shift + Middle Click to select an arbitrary point. Press ENTER when the desired one is highlighted\",\n  \"Use TAB to choose which side to bend. Press ENTER when the desired one is highlighted.\",\n  \"Use the MOUSE to bend the patch. It uses the same ui rules as Free Rotation. Press ENTER to accept the bend, press ESC to abandon it and exit Bend mode\",\n  \"\"\n};\n\n// INSERT states\nenum\n{\n  INSERT_SELECT_EDGE = 0,\n  INSERT_STATE_COUNT\n};\n\nconst char* g_pInsertStateMsg[] =\n{\n  \"Use TAB to cycle through available rows/columns for insertion/deletion. Press INS to insert at the highlight, DEL to remove the pair\"\n};\n\n\nfloat *g_InversePoints[1024];\n\nconst float fFullBright = 1.0;\nconst float fLowerLimit = .50;\nconst float fDec = .05;\nvoid _SetColor(face_t* f, float fColor[3])\n{\n  return;\n  fColor[0] = f->d_color[0];\n  fColor[1] = f->d_color[1];\n  fColor[2] = f->d_color[2];\n  qglColor3fv(fColor);\n}\n\n\nvoid _DecColor(float fColor[3])\n{\n  return;\n  fColor[0] -= fDec;\n  fColor[1] -= fDec ;\n  fColor[2] -= fDec;\n  for (int i = 0; i < 3; i++)\n  {\n    if (fColor[i] <= fLowerLimit)\n    {\n      fColor[0] = fFullBright;\n      fColor[1] = fFullBright;\n      fColor[2] = fFullBright;\n      break;\n    }\n  }\n\tqglColor3fv(fColor);\n}\n\nvec_t __VectorNormalize (vec3_t in, vec3_t out)\n{\n\tvec_t\tlength, ilength;\n\n\tlength = sqrt (in[0]*in[0] + in[1]*in[1] + in[2]*in[2]);\n\tif (length == 0)\n\t{\n\t\tVectorClear (out);\n\t\treturn 0;\n\t}\n\n\tilength = 1.0/length;\n\tout[0] = in[0]*ilength;\n\tout[1] = in[1]*ilength;\n\tout[2] = in[2]*ilength;\n\n\treturn length;\n}\n\n\nvoid Patch_SetType(patchMesh_t *p, int nType)\n{\n  p->type = (p->type & PATCH_STYLEMASK) | nType;\n}\n\nvoid Patch_SetStyle(patchMesh_t *p, int nStyle)\n{\n  p->type = (p->type & PATCH_TYPEMASK) | nStyle;\n}\n\n/*\n==================\nPatch_MemorySize\n==================\n*/\nint Patch_MemorySize(patchMesh_t *p)\n{\n\treturn _msize(p);\n}\n\n\n\n/*\n===============\nInterpolateInteriorPoints\n===============\n*/\nvoid InterpolateInteriorPoints( patchMesh_t *p ) \n{\n\tint\t\ti, j, k;\n\tint\t\tnext, prev;\n\n\tfor ( i = 0 ; i < p->width ; i += 2 ) \n  {\n\n    next = ( i == p->width - 1 ) ? 1 : ( i + 1 ) % p->width;\n    prev = ( i == 0 ) ? p->width - 2 : i - 1;\n\n#if 0\n\t\tif ( i == 0 ) \n    {\n\t\t\tnext = ( i + 1 ) % p->width;\n\t\t\tprev = p->width - 2;\t\t      // joined wrap case\n\t\t} \n    else if ( i == p->width - 1 ) \n    {\n\t\t\tnext = 1;\n\t\t\tprev = i - 1;\n\t\t} \n    else \n    {\n\t\t\tnext = ( i + 1 ) % p->width;\n\t\t\tprev = i - 1;\n\t\t}\n#endif\n\n\t\tfor ( j = 0 ; j < p->height ; j++ ) \n    {\n\t\t\tfor ( k = 0 ; k < 3 ; k++ ) \n      {\n\t\t\t\tp->ctrl[i][j].xyz[k] = ( p->ctrl[next][j].xyz[k] + p->ctrl[prev][j].xyz[k] ) * 0.5;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n=================\nMakeMeshNormals\n\n=================\n*/\nint\tneighbors[8][2] = {\n\t{0,1}, {1,1}, {1,0}, {1,-1}, {0,-1}, {-1,-1}, {-1,0}, {-1,1}\n};\n\nvoid Patch_MeshNormals(patchMesh_t *in ) \n{\n\tint\t\ti, j, k, dist;\n\tvec3_t\tnormal;\n\tvec3_t\tsum;\n\tint\t\tcount;\n\tvec3_t\tbase;\n\tvec3_t\tdelta;\n\tint\t\tx, y;\n\tdrawVert_t\t*dv;\n\tvec3_t\t\taround[8], temp;\n\tqboolean\tgood[8];\n\tqboolean\twrapWidth, wrapHeight;\n\tfloat\t\tlen;\n\n\twrapWidth = false;\n\tfor ( i = 0 ; i < in->height ; i++ ) \n  {\n\n\t\tVectorSubtract( in->ctrl[0][i].xyz, \n\t\t\t              in->ctrl[in->width-1][i].xyz, delta );\n\t\tlen = VectorLength( delta );\n\t\tif ( len > 1.0 ) \n    {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif ( i == in->height ) \n  {\n\t\twrapWidth = true;\n\t}\n\n\twrapHeight = false;\n\tfor ( i = 0 ; i < in->width ; i++ ) \n  {\n\t\tVectorSubtract( in->ctrl[i][0].xyz, \n\t\t\t              in->ctrl[i][in->height-1].xyz, delta );\n\t\tlen = VectorLength( delta );\n\t\tif ( len > 1.0 ) \n    {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif ( i == in->width) \n  {\n\t\twrapHeight = true;\n\t}\n\n\n\tfor ( i = 0 ; i < in->width ; i++ ) \n  {\n\t\tfor ( j = 0 ; j < in->height ; j++ ) \n    {\n\t\t\tcount = 0;\n\t\t\t//--dv = reinterpret_cast<drawVert_t*>(in.ctrl[j*in.width+i]);\n\t\t\tdv = &in->ctrl[i][j];\n\t\t\tVectorCopy( dv->xyz, base );\n\t\t\tfor ( k = 0 ; k < 8 ; k++ ) \n      {\n\t\t\t\tVectorClear( around[k] );\n\t\t\t\tgood[k] = false;\n\n\t\t\t\tfor ( dist = 1 ; dist <= 3 ; dist++ ) \n        {\n\t\t\t\t\tx = i + neighbors[k][0] * dist;\n\t\t\t\t\ty = j + neighbors[k][1] * dist;\n\t\t\t\t\tif ( wrapWidth ) \n          {\n\t\t\t\t\t\tif ( x < 0 ) \n            {\n\t\t\t\t\t\t\tx = in->width - 1 + x;\n\t\t\t\t\t\t} \n            else if ( x >= in->width ) \n            {\n\t\t\t\t\t\t\tx = 1 + x - in->width;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif ( wrapHeight ) \n          {\n\t\t\t\t\t\tif ( y < 0 ) \n            {\n\t\t\t\t\t\t\ty = in->height - 1 + y;\n\t\t\t\t\t\t} \n            else if ( y >= in->height ) \n            {\n\t\t\t\t\t\t\ty = 1 + y - in->height;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( x < 0 || x >= in->width || y < 0 || y >= in->height ) \n          {\n\t\t\t\t\t\tbreak;\t\t\t\t\t// edge of patch\n\t\t\t\t\t}\n\t\t\t\t\t//--VectorSubtract( in.ctrl[y*in.width+x]->xyz, base, temp );\n\t\t\t\t\tVectorSubtract( in->ctrl[x][y].xyz, base, temp );\n\t\t\t\t\tif ( __VectorNormalize( temp, temp ) == 0 ) \n          {\n\t\t\t\t\t\tcontinue;\t\t\t\t// degenerate edge, get more dist\n\t\t\t\t\t} \n          else                 \n          {\n\t\t\t\t\t\tgood[k] = true;\n\t\t\t\t\t\tVectorCopy( temp, around[k] );\n\t\t\t\t\t\tbreak;\t\t\t\t\t// good edge\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tVectorClear( sum );\n\t\t\tfor ( k = 0 ; k < 8 ; k++ ) \n      {\n\t\t\t\tif ( !good[k] || !good[(k+1)&7] ) \n        {\n\t\t\t\t\tcontinue;\t// didn't get two points\n\t\t\t\t}\n\t\t\t\tCrossProduct( around[(k+1)&7], around[k], normal );\n\t\t\t\tif ( __VectorNormalize( normal, normal ) == 0 ) \n        {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tVectorAdd( normal, sum, sum );\n\t\t\t\tcount++;\n\t\t\t}\n\t\t\tif ( count == 0 ) \n      {\n        //printf(\"bad normal\\n\");\n\t\t\t\tcount = 1;\n        //continue;\n\t\t\t}\n\t\t\t__VectorNormalize( sum, dv->normal );\n\t\t}\n\t}\n}\n\n\n\n\n/*\n==================\nPatch_CalcBounds\n==================\n*/\nvoid Patch_CalcBounds(patchMesh_t *p, vec3_t& vMin, vec3_t& vMax)\n{\n  vMin[0] = vMin[1] = vMin[2] = 99999;\n  vMax[0] = vMax[1] = vMax[2] = -99999;\n\n  p->bDirty = true;\n  for (int w = 0; w < p->width; w++)\n  {\n    for (int h = 0; h < p->height; h++)\n    {\n      for (int j = 0; j < 3; j++)\n      {\n        float f = p->ctrl[w][h].xyz[j];\n        if (f < vMin[j])\n          vMin[j] = f;\n        if (f > vMax[j])\n          vMax[j] = f;\n      }\n    }\n  }\n}\n\n/*\n==================\nBrush_RebuildBrush\n==================\n*/\nvoid Brush_RebuildBrush(brush_t *b, vec3_t vMins, vec3_t vMaxs)\n{\n  //\n  // Total hack job \n  // Rebuilds a brush\n\tint\t\ti, j;\n\tface_t\t*f, *next;\n\tvec3_t\tpts[4][2];\n  texdef_t\ttexdef;\n\t// free faces\n\n  for (j = 0; j < 3; j++)\n  {\n    if ((int)vMins[j] == (int)vMaxs[j])\n    {\n      vMins[j] -= 4;\n      vMaxs[j] += 4;\n    }\n  }\n\n  \n  for (f=b->brush_faces ; f ; f=next)\n\t{\n\t\tnext = f->next;\n    if (f)\n      texdef = f->texdef;\n    Face_Free( f );\n\t}\n\n  b->brush_faces = NULL;\n\n  // left the last face so we can use its texdef\n\n\tfor (i=0 ; i<3 ; i++)\n\t\tif (vMaxs[i] < vMins[i])\n\t\t\tError (\"Brush_RebuildBrush: backwards\");\n\n\tpts[0][0][0] = vMins[0];\n\tpts[0][0][1] = vMins[1];\n\t\n\tpts[1][0][0] = vMins[0];\n\tpts[1][0][1] = vMaxs[1];\n\t\n\tpts[2][0][0] = vMaxs[0];\n\tpts[2][0][1] = vMaxs[1];\n\t\n\tpts[3][0][0] = vMaxs[0];\n\tpts[3][0][1] = vMins[1];\n\t\n\tfor (i=0 ; i<4 ; i++)\n\t{\n\t\tpts[i][0][2] = vMins[2];\n\t\tpts[i][1][0] = pts[i][0][0];\n\t\tpts[i][1][1] = pts[i][0][1];\n\t\tpts[i][1][2] = vMaxs[2];\n\t}\n\n\tfor (i=0 ; i<4 ; i++)\n\t{\n\t\tf = Face_Alloc();\n\t\tf->texdef = texdef;\n\t\tf->texdef.flags &= ~SURF_KEEP;\n\t\tf->texdef.contents &= ~CONTENTS_KEEP;\n\t\tif ( b->patchBrush )\n\t\t{\n\t\t\tf->texdef.flags |= SURF_PATCH; \n\t\t}\n\t\tf->next = b->brush_faces;\n\t\tb->brush_faces = f;\n\t\tj = (i+1)%4;\n\n\t\tVectorCopy (pts[j][1], f->planepts[0]);\n\t\tVectorCopy (pts[i][1], f->planepts[1]);\n\t\tVectorCopy (pts[i][0], f->planepts[2]);\n\t}\n\t\n\tf = Face_Alloc();\n\tf->texdef = texdef;\n\tf->texdef.flags &= ~SURF_KEEP;\n\tf->texdef.contents &= ~CONTENTS_KEEP;\n\tif ( b->patchBrush )\n\t{\n\t\tf->texdef.flags |= SURF_PATCH; \n\t}\n\tf->next = b->brush_faces;\n\tb->brush_faces = f;\n\n\tVectorCopy (pts[0][1], f->planepts[0]);\n\tVectorCopy (pts[1][1], f->planepts[1]);\n\tVectorCopy (pts[2][1], f->planepts[2]);\n\n\tf = Face_Alloc();\n\tf->texdef = texdef;\n\tf->texdef.flags &= ~SURF_KEEP;\n\tf->texdef.contents &= ~CONTENTS_KEEP;\n\tif ( b->patchBrush )\n\t{\n\t\tf->texdef.flags |= SURF_PATCH; \n\t}\n\tf->next = b->brush_faces;\n\tb->brush_faces = f;\n\n\tVectorCopy (pts[2][0], f->planepts[0]);\n\tVectorCopy (pts[1][0], f->planepts[1]);\n\tVectorCopy (pts[0][0], f->planepts[2]);\n\n  Brush_Build(b);\n}\n\nvoid WINAPI Patch_Rebuild(patchMesh_t *p)\n{\n  vec3_t vMin, vMax;\n  Patch_CalcBounds(p, vMin, vMax);\n  Brush_RebuildBrush(p->pSymbiot, vMin, vMax);\n  p->bDirty = true;\n}\n\n/*\n==================\nAddBrushForPatch\n==================\n adds a patch brush and ties it to this patch id\n*/\nbrush_t* AddBrushForPatch(patchMesh_t *pm, bool bLinkToWorld )\n{\n  // find the farthest points in x,y,z\n  vec3_t vMin, vMax;\n  Patch_CalcBounds(pm, vMin, vMax);\n\n  for (int j = 0; j < 3; j++)\n  {\n    if (vMin[j] == vMax[j])\n    {\n      vMin[j] -= 4;\n      vMax[j] += 4;\n    }\n  }\n\n  brush_t *b = Brush_Create(vMin, vMax, &g_qeglobals.d_texturewin.texdef);\n\tface_t\t\t*f;\n\tfor (f=b->brush_faces ; f ; f=f->next) \n  {\n\t\tf->texdef.flags |= SURF_PATCH; \n\t}\n\n  // FIXME: this entire type of linkage needs to be fixed\n  b->pPatch = pm;\n  pm->pSymbiot = b;\n  pm->bSelected = false;\n  pm->bOverlay = false;\n  pm->bDirty = true;\n  pm->nListID = -1;\n\n  if (bLinkToWorld)\n  {\n    Brush_AddToList (b, &active_brushes);\n\t  Entity_LinkBrush (world_entity, b);\n    Brush_Build(b);\n  }\n\n  return b;\n}\n\nvoid Patch_SetPointIntensities(int n)\n{\n#if 0\n\tpatchMesh_t\t*p = patchMeshes[n];\n  for (int i = 0; i < p->width; i++)\n  {\n    for (int j = 0; j < p->height; j++)\n    {\n\n    }\n  }\n#endif\n}\n\n// very approximate widths and heights\n\n/*\n==================\nPatch_Width\n==================\n*/\nfloat Patch_Width(patchMesh_t *p)\n{\n  float f = 0;\n  for (int i = 0; i < p->width-1; i++)\n  {\n    vec3_t vTemp;\n    VectorSubtract(p->ctrl[i][0].xyz, p->ctrl[i+1][0].xyz, vTemp);\n    f += VectorLength(vTemp);\n  }\n  return f;\n}\n\nfloat Patch_WidthDistanceTo(patchMesh_t *p, int j)\n{\n  float f = 0;\n  for (int i = 0; i < j; i++)\n  {\n    vec3_t vTemp;\n    VectorSubtract(p->ctrl[i][0].xyz, p->ctrl[i+1][0].xyz, vTemp);\n    f += VectorLength(vTemp);\n  }\n  return f;\n}\n\n\n\n/*\n==================\nPatch_Height\n==================\n*/\nfloat Patch_Height(patchMesh_t *p)\n{\n  float f = 0;\n  for (int i = 0; i < p->height-1; i++)\n  {\n    vec3_t vTemp;\n    VectorSubtract(p->ctrl[0][i].xyz, p->ctrl[0][i+1].xyz, vTemp);\n    f += VectorLength(vTemp);\n  }\n  return f;\n}\n\nfloat Patch_HeightDistanceTo(patchMesh_t *p, int j)\n{\n  float f = 0;\n  for (int i = 0; i < j; i++)\n  {\n    vec3_t vTemp;\n    VectorSubtract(p->ctrl[0][i].xyz, p->ctrl[0][i+1].xyz, vTemp);\n    f += VectorLength(vTemp);\n  }\n  return f;\n}\n\n\n\n/*\n==================\nPatch_Naturalize\n==================\ntexture = TotalTexture * LengthToThisControlPoint / TotalControlPointLength\n\ndist( this control point to first control point ) / dist ( last control pt to first)\n*/\nvoid Patch_Naturalize(patchMesh_t *p)\n{\n  int nWidth = (g_PrefsDlg.m_bHiColorTextures == TRUE) ? p->d_texture->width * 0.5 : p->d_texture->width;\n  int nHeight = (g_PrefsDlg.m_bHiColorTextures == TRUE) ? p->d_texture->height * 0.5 : p->d_texture->height;\n  float fPWidth = Patch_Width(p);\n  float fPHeight = Patch_Height(p);\n  float xAccum = 0;\n  for ( int i = 0 ; i < p->width ; i++ ) \n  {\n    float yAccum = 0;\n\t  for ( int j = 0 ; j < p->height ; j++ ) \n    {\n\t\t  p->ctrl[i][j].st[0] = (fPWidth / nWidth) * xAccum / fPWidth;\n\t\t  p->ctrl[i][j].st[1] = (fPHeight / nHeight) * yAccum / fPHeight;\n\t\t  yAccum = Patch_HeightDistanceTo(p,j+1);\n      //p->ctrl[i][j][3] = (fPWidth / nWidth) * (float)i / (p->width - 1);\n\t\t  //p->ctrl[i][j][4] = (fPHeight/ nHeight) * (float)j / (p->height - 1);\n\t  }\n    xAccum = Patch_WidthDistanceTo(p,i+1);\n  }\n  p->bDirty = true;\n}\n\n/*\n  if (bIBevel)\n  {\n    VectorCopy(p->ctrl[1][0], p->ctrl[1][1]);\n  }\n\n  if (bIEndcap)\n  {\n    VectorCopy(p->ctrl[3][0], p->ctrl[4][1]);\n    VectorCopy(p->ctrl[2][0], p->ctrl[3][1]);\n    VectorCopy(p->ctrl[2][0], p->ctrl[2][1]);\n    VectorCopy(p->ctrl[2][0], p->ctrl[1][1]);\n    VectorCopy(p->ctrl[1][0], p->ctrl[0][1]);\n    VectorCopy(p->ctrl[1][0], p->ctrl[0][2]);\n    VectorCopy(p->ctrl[1][0], p->ctrl[1][2]);\n    VectorCopy(p->ctrl[2][0], p->ctrl[2][2]);\n    VectorCopy(p->ctrl[3][0], p->ctrl[3][2]);\n    VectorCopy(p->ctrl[3][0], p->ctrl[4][2]);\n  }\n*/\n\nint Index3By[][2] =\n{\n  {0,0},\n  {1,0},\n  {2,0},\n  {2,1},\n  {2,2},\n  {1,2},\n  {0,2},\n  {0,1},\n  {0,0},\n  {0,0},\n  {0,0},\n  {0,0},\n  {0,0},\n  {0,0},\n  {0,0}\n};\n\nint Index5By[][2] =\n{\n  {0,0},\n  {1,0},\n  {2,0},\n  {3,0},\n  {4,0},\n  {4,1},\n  {4,2},\n  {4,3},\n  {4,4},\n  {3,4},\n  {2,4},\n  {1,4},\n  {0,4},\n  {0,3},\n  {0,2},\n  {0,1}\n};\n\n\n\nint Interior3By[][2] =\n{\n  {1,1}\n};\n\nint Interior5By[][2] =\n{\n  {1,1},\n  {2,1},\n  {3,1},\n  {1,2},\n  {2,2},\n  {3,2},\n  {1,3},\n  {2,3},\n  {3,3}\n};\n\nint Interior3ByCount = sizeof(Interior3By) / sizeof(int[2]);\nint Interior5ByCount = sizeof(Interior5By) / sizeof(int[2]);\n\nface_t* Patch_GetAxisFace(patchMesh_t *p)\n{\n  face_t *f = NULL;\n  vec3_t vTemp;\n  brush_t *b = p->pSymbiot;\n\n\tfor (f = b->brush_faces ; f ; f = f->next) \n  {\n    VectorSubtract(f->face_winding->points[1], f->face_winding->points[0], vTemp);\n    int nScore = 0;\n\n    // default edge faces on caps are 8 high so\n    // as soon as we hit one that is bigger it should be on the right axis\n    for (int j = 0; j < 3; j++)\n    {\n      if (vTemp[j] > 8)\n        nScore++;\n    }\n\n    if (nScore > 0)\n      break;\n  }\n\n  if (f == NULL)\n    f = b->brush_faces;\n  return f;\n}\n\nint g_nFaceCycle = 0;\n\nface_t* nextFace(patchMesh_t *p)\n{\n  brush_t *b = p->pSymbiot;\n  face_t *f = NULL;\n  int n = 0;\n\tfor (f = b->brush_faces ; f && n <= g_nFaceCycle; f = f->next) \n  {\n    n++;\n  }\n  g_nFaceCycle++;\n  if (g_nFaceCycle > 5)\n  {\n    g_nFaceCycle =0;\n    f = b->brush_faces;\n  }\n\n  return f;\n}\n\n\nextern void EmitTextureCoordinates ( float *xyzst, qtexture_t *q, face_t *f);\nvoid Patch_CapTexture(patchMesh_t *p, bool bFaceCycle = false)\n{\n  Patch_MeshNormals(p);\n  face_t *f = (bFaceCycle) ? nextFace(p) : Patch_GetAxisFace(p);\n  vec3_t vSave;\n  VectorCopy(f->plane.normal, vSave);\n  \n  float fRotate = f->texdef.rotate;\n  f->texdef.rotate = 0;\n  float fScale[2];\n  fScale[0] = f->texdef.scale[0];\n  fScale[1] = f->texdef.scale[1];\n  f->texdef.scale[0] = 0.5;\n  f->texdef.scale[1] = 0.5;\n  float fShift[2];\n  fShift[0] = f->texdef.shift[0];\n  fShift[1] = f->texdef.shift[1];\n  f->texdef.shift[0] = 0;\n  f->texdef.shift[1] = 0;\n  \n  for (int i = 0; i < p->width; i++)\n  {\n    for (int j = 0; j < p->height; j++)\n    {\n      if (!bFaceCycle)\n      {\n        VectorCopy(p->ctrl[i][j].normal, f->plane.normal);\n      }\n\t\t  EmitTextureCoordinates( p->ctrl[i][j].xyz, f->d_texture, f);\n    }\n  }\n  VectorCopy(vSave, f->plane.normal);\n  f->texdef.rotate = fRotate;\n  f->texdef.scale[0] = fScale[0];\n  f->texdef.scale[1] = fScale[1];\n  f->texdef.shift[0] = fShift[0];\n  f->texdef.shift[1] = fShift[1];\n  p->bDirty = true;\n}\n\nvoid FillPatch(patchMesh_t *p, vec3_t v)\n{\n  for (int i = 0; i < p->width; i++)\n  {\n    for (int j = 0; j < p->height; j++)\n    {\n      VectorCopy(v, p->ctrl[i][j].xyz);\n    }\n  }\n}\n\nbrush_t* Cap(patchMesh_t *pParent, bool bByColumn, bool bFirst)\n{\n  brush_t *b;\n  patchMesh_t *p;\n  vec3_t vMin, vMax;\n  int i, j;\n\n  bool bSmall = true;\n  // make a generic patch\n  if (pParent->width <= 9)\n  {\n    b = Patch_GenericMesh(3, 3, 2, false);\n  }\n  else\n  {\n    b = Patch_GenericMesh(5, 5, 2, false);\n    bSmall = false;\n  }\n\n  if (!b)\n  {\n    Sys_Printf(\"Unable to cap. You may need to ungroup the patch.\\n\");\n    return NULL;\n  }\n\n  p = b->pPatch;\n  p->type |= PATCH_CAP;\n\n  vMin[0] = vMin[1] = vMin[2] = 9999;\n  vMax[0] = vMax[1] = vMax[2] = -9999;\n\n  // we seam the column edge, FIXME: this might need to be able to seem either edge\n  // \n  int nSize = (bByColumn) ? pParent->width : pParent->height;\n  int nIndex = (bFirst) ? 0 : (bByColumn) ? pParent->height-1 : pParent->width-1;\n\n  FillPatch(p, pParent->ctrl[0][nIndex].xyz);\n\n  for (i = 0; i < nSize; i++)\n  {\n    if (bByColumn)\n    {\n      if (bSmall)\n      {\n        VectorCopy(pParent->ctrl[i][nIndex].xyz, p->ctrl[Index3By[i][0]][Index3By[i][1]].xyz);\n      }\n      else\n      {\n        VectorCopy(pParent->ctrl[i][nIndex].xyz, p->ctrl[Index5By[i][0]][Index5By[i][1]].xyz);\n      }\n    }\n    else\n    {\n      if (bSmall)\n      {\n        VectorCopy(pParent->ctrl[nIndex][i].xyz, p->ctrl[Index3By[i][0]][Index3By[i][1]].xyz);\n      }\n      else\n      {\n        VectorCopy(pParent->ctrl[nIndex][i].xyz, p->ctrl[Index5By[i][0]][Index5By[i][1]].xyz);\n      }\n    }\n  \n    for (j = 0; j < 3; j++)\n    {\n      float f = (bSmall) ? p->ctrl[Index3By[i][0]][Index3By[i][1]].xyz[j] : p->ctrl[Index5By[i][0]][Index5By[i][1]].xyz[j];\n      if (f < vMin[j])\n        vMin[j] = f;\n      if (f > vMax[j])\n        vMax[j] = f;\n    }\n  }\n\n  vec3_t vTemp;\n  for (j = 0; j < 3; j++)\n  {\n    vTemp[j] = vMin[j] + abs((vMax[j] - vMin[j]) * 0.5);\n  }\n\n  int nCount = (bSmall) ? Interior3ByCount : Interior5ByCount;\n  for (j = 0; j < nCount; j++)\n  {\n    if (bSmall)\n    {\n      VectorCopy(vTemp, p->ctrl[Interior3By[j][0]][Interior3By[j][1]].xyz);\n    }\n    else\n    {\n      VectorCopy(vTemp, p->ctrl[Interior5By[j][0]][Interior5By[j][1]].xyz);\n    }\n  }\n\n  if (bFirst)\n  {\n    drawVert_t vertTemp;\n    for (i = 0; i < p->width; i++)\n    {\n      for (j = 0; j < p->height / 2; j++)\n      {\n        memcpy(&vertTemp, &p->ctrl[i][p->height - 1- j], sizeof (drawVert_t));\n        memcpy(&p->ctrl[i][p->height - 1 - j], &p->ctrl[i][j], sizeof(drawVert_t));\n        memcpy(&p->ctrl[i][j], &vertTemp, sizeof(drawVert_t));\n      }\n    }\n  }\n\n  Patch_Rebuild(p);\n  Patch_CapTexture(p);\n  return p->pSymbiot;\n}\n\nbrush_t* CapSpecial(patchMesh_t *pParent, int nType, bool bFirst)\n{\n  brush_t *b;\n  patchMesh_t *p;\n  vec3_t vMin, vMax, vTemp;\n  int i, j;\n\n  if (nType == CCapDialog::IENDCAP)\n    b = Patch_GenericMesh(5, 3, 2, false);\n  else\n    b = Patch_GenericMesh(3, 3, 2, false);\n\n  if (!b)\n  {\n    Sys_Printf(\"Unable to cap. Make sure you ungroup before re-capping.\");\n    return NULL;\n  }\n\n  p = b->pPatch;\n  p->type |= PATCH_CAP;\n\n  vMin[0] = vMin[1] = vMin[2] = 9999;\n  vMax[0] = vMax[1] = vMax[2] = -9999;\n\n  int nSize = pParent->width;\n  int nIndex = (bFirst) ? 0 : pParent->height-1;\n\n  // parent bounds are used for some things\n  Patch_CalcBounds(pParent, vMin, vMax);\n\n  for (j = 0; j < 3; j++)\n  {\n    vTemp[j] = vMin[j] + abs((vMax[j] - vMin[j]) * 0.5);\n  }\n\n  if (nType == CCapDialog::IBEVEL)\n  {\n    VectorCopy(pParent->ctrl[0][nIndex].xyz, p->ctrl[0][0].xyz);\n    VectorCopy(pParent->ctrl[2][nIndex].xyz, p->ctrl[0][2].xyz);\n    VectorCopy(pParent->ctrl[1][nIndex].xyz, p->ctrl[0][1].xyz);\n    VectorCopy(pParent->ctrl[1][nIndex].xyz, p->ctrl[2][2].xyz);\n    VectorCopy(pParent->ctrl[1][nIndex].xyz, p->ctrl[1][0].xyz);\n    VectorCopy(pParent->ctrl[1][nIndex].xyz, p->ctrl[1][1].xyz);\n    VectorCopy(pParent->ctrl[1][nIndex].xyz, p->ctrl[1][2].xyz);\n    VectorCopy(pParent->ctrl[1][nIndex].xyz, p->ctrl[2][0].xyz);\n    VectorCopy(pParent->ctrl[1][nIndex].xyz, p->ctrl[2][1].xyz);\n  }\n  else if (nType == CCapDialog::BEVEL)\n  {\n    vec3_t p1, p2, p3, p4, temp, dir;\n\n    VectorCopy(pParent->ctrl[0][nIndex].xyz, p3);\n    VectorCopy(pParent->ctrl[1][nIndex].xyz, p1);\n    VectorCopy(pParent->ctrl[2][nIndex].xyz, p2);\n\n    VectorSubtract(p3, p2, dir);\n    VectorNormalize(dir);\n    VectorSubtract(p1, p2, temp);\n    vec_t dist = _DotProduct(temp, dir);\n\n    VectorScale(dir, dist, temp);\n\n    VectorAdd(p2, temp, temp);\n\n    VectorSubtract(temp, p1, temp);\n    VectorScale(temp, 2, temp);\n    VectorAdd(p1, temp, p4);\n\n    VectorCopy(p4, p->ctrl[0][0].xyz);\n    VectorCopy(p4, p->ctrl[1][0].xyz);\n    VectorCopy(p4, p->ctrl[0][1].xyz);\n    VectorCopy(p4, p->ctrl[1][1].xyz);\n    VectorCopy(p4, p->ctrl[0][2].xyz);\n    VectorCopy(p4, p->ctrl[1][2].xyz);\n    VectorCopy(p3, p->ctrl[2][0].xyz);\n    VectorCopy(p1, p->ctrl[2][1].xyz);\n    VectorCopy(p2, p->ctrl[2][2].xyz);\n\n  }\n  else if (nType == CCapDialog::ENDCAP)\n  {\n    VectorAdd(pParent->ctrl[4][nIndex].xyz, pParent->ctrl[0][nIndex].xyz, vTemp);\n    VectorScale(vTemp, 0.5, vTemp);\n    VectorCopy(pParent->ctrl[0][nIndex].xyz, p->ctrl[0][0].xyz);\n                       VectorCopy(vTemp, p->ctrl[1][0].xyz);\n    VectorCopy(pParent->ctrl[4][nIndex].xyz, p->ctrl[2][0].xyz);\n\n    VectorCopy(pParent->ctrl[2][nIndex].xyz, p->ctrl[0][2].xyz);\n    VectorCopy(pParent->ctrl[2][nIndex].xyz, p->ctrl[1][2].xyz);\n    VectorCopy(pParent->ctrl[2][nIndex].xyz, p->ctrl[2][2].xyz);\n    VectorCopy(pParent->ctrl[2][nIndex].xyz, p->ctrl[1][1].xyz);\n    \n    VectorCopy(pParent->ctrl[1][nIndex].xyz, p->ctrl[0][1].xyz);\n    VectorCopy(pParent->ctrl[3][nIndex].xyz, p->ctrl[2][1].xyz);\n  }\n  else\n  {\n    VectorCopy(pParent->ctrl[0][nIndex].xyz, p->ctrl[0][0].xyz);\n    VectorCopy(pParent->ctrl[1][nIndex].xyz, p->ctrl[1][0].xyz);\n    VectorCopy(pParent->ctrl[2][nIndex].xyz, p->ctrl[2][0].xyz);\n    VectorCopy(pParent->ctrl[3][nIndex].xyz, p->ctrl[3][0].xyz);\n    VectorCopy(pParent->ctrl[4][nIndex].xyz, p->ctrl[4][0].xyz);\n    \n    VectorCopy(pParent->ctrl[1][nIndex].xyz, p->ctrl[0][1].xyz);\n    VectorCopy(pParent->ctrl[1][nIndex].xyz, p->ctrl[1][1].xyz);\n    VectorCopy(pParent->ctrl[2][nIndex].xyz, p->ctrl[2][1].xyz);\n    VectorCopy(pParent->ctrl[3][nIndex].xyz, p->ctrl[3][1].xyz);\n    VectorCopy(pParent->ctrl[3][nIndex].xyz, p->ctrl[4][1].xyz);\n\n    VectorCopy(pParent->ctrl[1][nIndex].xyz, p->ctrl[0][2].xyz);\n    VectorCopy(pParent->ctrl[1][nIndex].xyz, p->ctrl[1][2].xyz);\n    VectorCopy(pParent->ctrl[2][nIndex].xyz, p->ctrl[2][2].xyz);\n    VectorCopy(pParent->ctrl[3][nIndex].xyz, p->ctrl[3][2].xyz);\n    VectorCopy(pParent->ctrl[3][nIndex].xyz, p->ctrl[4][2].xyz);\n  }\n\n\n  bool bEndCap = (nType == CCapDialog::ENDCAP || nType == CCapDialog::IENDCAP);\n  if ((!bFirst && !bEndCap) || (bFirst && bEndCap))\n  {\n    drawVert_t vertTemp;\n    for (i = 0; i < p->width; i++)\n    {\n      for (j = 0; j < p->height / 2; j++)\n      {\n        memcpy(&vertTemp, &p->ctrl[i][p->height - 1- j], sizeof (drawVert_t));\n        memcpy(&p->ctrl[i][p->height - 1 - j], &p->ctrl[i][j], sizeof(drawVert_t));\n        memcpy(&p->ctrl[i][j], &vertTemp, sizeof(drawVert_t));\n      }\n    }\n  }\n\n  //--Patch_CalcBounds(p, vMin, vMax);\n  //--Brush_RebuildBrush(p->pSymbiot, vMin, vMax);\n  Patch_Rebuild(p);\n  Patch_CapTexture(p);\n  return p->pSymbiot;\n}\n\n\nvoid Patch_CapCurrent(bool bInvertedBevel, bool bInvertedEndcap)\n{\n  patchMesh_t *pParent = NULL;\n  brush_t *b[4];\n  brush_t *pCap = NULL;\n  b[0] = b[1] = b[2] = b[3] = NULL;\n  int nIndex = 0;\n\n\tif (!QE_SingleBrush())\n  {\n    Sys_Printf(\"Cannot cap multiple selection. Please select a single patch.\\n\");\n\t\treturn;\n  }\n\n\n\tfor (brush_t *pb = selected_brushes.next ; pb != NULL && pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n      pParent = pb->pPatch;\n      // decide which if any ends we are going to cap\n      // if any of these compares hit, it is a closed patch and as such\n      // the generic capping will work.. if we do not find a closed edge \n      // then we need to ask which kind of cap to add\n      if (VectorCompare(pParent->ctrl[0][0].xyz, pParent->ctrl[pParent->width-1][0].xyz))\n      {\n        pCap = Cap(pParent, true, false);\n        if (pCap != NULL)\n        {\n          b[nIndex++] = pCap;\n        }\n      }\n      if (VectorCompare(pParent->ctrl[0][pParent->height-1].xyz, pParent->ctrl[pParent->width-1][pParent->height-1].xyz))\n      {\n        pCap = Cap(pParent, true, true);\n        if (pCap != NULL)\n        {\n          b[nIndex++] = pCap;\n        }\n      }\n      if (VectorCompare(pParent->ctrl[0][0].xyz, pParent->ctrl[0][pParent->height-1].xyz))\n      {\n        pCap = Cap(pParent, false, false);\n        if (pCap != NULL)\n        {\n          b[nIndex++] = pCap;\n        }\n      }\n      if (VectorCompare(pParent->ctrl[pParent->width-1][0].xyz, pParent->ctrl[pParent->width-1][pParent->height-1].xyz))\n      {\n        pCap = Cap(pParent, false, true);\n        if (pCap != NULL)\n        {\n          b[nIndex++] = pCap;\n        }\n      }\n    }\n  }\n\n  if (pParent)\n  {\n    // if we did not cap anything with the above tests\n    if (nIndex == 0)\n    {\n      CCapDialog dlg;\n      if (dlg.DoModal() == IDOK)\n      {\n        b[nIndex++] = CapSpecial(pParent, dlg.getCapType(), false);\n        b[nIndex++] = CapSpecial(pParent, dlg.getCapType(), true);\n      }\n    }\n\n    if (nIndex > 0)\n    {\n      while (nIndex > 0)\n      {\n        nIndex--;\n        if (b[nIndex])\n        {\n          Select_Brush(b[nIndex]);\n        }\n      }\n      eclass_t *pecNew = Eclass_ForName(\"func_group\", false);\n      if (pecNew)\n      {\n        entity_t *e = Entity_Create(pecNew);\n        SetKeyValue(e, \"type\", \"patchCapped\");\n      }\n    }\n  }\n}\n\n\n//FIXME: Table drive all this crap\n//\nvoid GenerateEndCaps(brush_t *brushParent, bool bBevel, bool bEndcap, bool bInverted)\n{\n  brush_t *b, *b2;\n  patchMesh_t *p, *p2, *pParent;\n  vec3_t vTemp, vMin, vMax;\n  int i, j;\n\n  pParent = brushParent->pPatch;\n\n  Patch_CalcBounds(pParent, vMin, vMax);\n  // basically generate two endcaps, place them, and link the three brushes with a func_group\n\n  if (pParent->width > 9)\n    b = Patch_GenericMesh(5, 3, 2, false);\n  else\n    b = Patch_GenericMesh(3, 3, 2, false);\n  p = b->pPatch;\n\n  vMin[0] = vMin[1] = vMin[2] = 9999;\n  vMax[0] = vMax[1] = vMax[2] = -9999;\n\n  for (i = 0; i < pParent->width; i++)\n  {\n    VectorCopy(pParent->ctrl[i][0].xyz, p->ctrl[Index3By[i][0]][Index3By[i][1]].xyz);\n    for (j = 0; j < 3; j++)\n    {\n      if (pParent->ctrl[i][0].xyz[j] < vMin[j])\n        vMin[j] = pParent->ctrl[i][0].xyz[j];\n      if (pParent->ctrl[i][0].xyz[j] > vMax[j])\n        vMax[j] = pParent->ctrl[i][0].xyz[j];\n    }\n  }\n\n  for (j = 0; j < 3; j++)\n  {\n    vTemp[j] = vMin[j] + abs((vMax[j] - vMin[j]) * 0.5);\n  }\n\n  for (i = 0; i < Interior3ByCount; i++)\n  {\n    VectorCopy(vTemp, p->ctrl[Interior3By[i][0]][Interior3By[i][1]].xyz);\n  }\n\n  Patch_CalcBounds(p, vMin, vMax);\n  Brush_RebuildBrush(p->pSymbiot, vMin, vMax);\n  Select_Brush(p->pSymbiot);\n  return;\n\n  bool bCreated = false;\n\n  if (bInverted)\n  {\n    if (bBevel)\n    {\n      b = Patch_GenericMesh(3, 3, 2, false);\n      p = b->pPatch;\n      VectorCopy(p->ctrl[2][2].xyz, p->ctrl[1][2].xyz);\n      VectorCopy(p->ctrl[2][2].xyz, p->ctrl[2][1].xyz);\n      VectorCopy(p->ctrl[2][2].xyz, p->ctrl[0][1].xyz);\n      VectorCopy(p->ctrl[2][2].xyz, p->ctrl[1][0].xyz);\n      VectorCopy(p->ctrl[2][2].xyz, p->ctrl[1][1].xyz);\n      VectorCopy(p->ctrl[2][0].xyz, p->ctrl[0][0].xyz);\n\n      b2 = Patch_GenericMesh(3, 3, 2, false);\n      p2 = b2->pPatch;\n      VectorCopy(p2->ctrl[2][2].xyz, p2->ctrl[1][2].xyz);\n      VectorCopy(p2->ctrl[2][2].xyz, p2->ctrl[2][1].xyz);\n      VectorCopy(p2->ctrl[2][2].xyz, p2->ctrl[0][1].xyz);\n      VectorCopy(p2->ctrl[2][2].xyz, p2->ctrl[1][0].xyz);\n      VectorCopy(p2->ctrl[2][2].xyz, p2->ctrl[1][1].xyz);\n      VectorCopy(p2->ctrl[2][0].xyz, p2->ctrl[0][0].xyz);\n\n\n      bCreated = true;\n\n    }\n    else if (bEndcap)\n    {\n      b = Patch_GenericMesh(5, 5, 2, false);\n      p = b->pPatch;\n      VectorCopy(p->ctrl[4][4].xyz, p->ctrl[4][3].xyz);\n      VectorCopy(p->ctrl[0][4].xyz, p->ctrl[1][4].xyz);\n      VectorCopy(p->ctrl[0][4].xyz, p->ctrl[2][4].xyz);\n      VectorCopy(p->ctrl[0][4].xyz, p->ctrl[3][4].xyz);\n\n      VectorCopy(p->ctrl[4][0].xyz, p->ctrl[4][1].xyz);\n      VectorCopy(p->ctrl[0][0].xyz, p->ctrl[1][0].xyz);\n      VectorCopy(p->ctrl[0][0].xyz, p->ctrl[2][0].xyz);\n      VectorCopy(p->ctrl[0][0].xyz, p->ctrl[3][0].xyz);\n\n      for (i = 1; i < 4; i++)\n      {\n        for (j = 0; j < 4; j++)\n        {\n          VectorCopy(p->ctrl[4][i].xyz, p->ctrl[j][i].xyz);\n        }\n      }\n\n\n      b2 = Patch_GenericMesh(5, 5, 2, false);\n      p2 = b2->pPatch;\n      VectorCopy(p2->ctrl[4][4].xyz, p2->ctrl[4][3].xyz);\n      VectorCopy(p2->ctrl[0][4].xyz, p2->ctrl[1][4].xyz);\n      VectorCopy(p2->ctrl[0][4].xyz, p2->ctrl[2][4].xyz);\n      VectorCopy(p2->ctrl[0][4].xyz, p2->ctrl[3][4].xyz);\n\n      VectorCopy(p2->ctrl[4][0].xyz, p2->ctrl[4][1].xyz);\n      VectorCopy(p2->ctrl[0][0].xyz, p2->ctrl[1][0].xyz);\n      VectorCopy(p2->ctrl[0][0].xyz, p2->ctrl[2][0].xyz);\n      VectorCopy(p2->ctrl[0][0].xyz, p2->ctrl[3][0].xyz);\n\n      for (i = 1; i < 4; i++)\n      {\n        for (j = 0; j < 4; j++)\n        {\n          VectorCopy(p2->ctrl[4][i].xyz, p2->ctrl[j][i].xyz);\n        }\n      }\n\n\n      bCreated = true;\n    }\n  }\n  else\n  {\n    if (bBevel)\n    {\n      b = Patch_GenericMesh(3, 3, 2, false);\n      p = b->pPatch;\n      VectorCopy(p->ctrl[2][0].xyz, p->ctrl[2][1].xyz);\n      VectorCopy(p->ctrl[0][0].xyz, p->ctrl[1][0].xyz);\n      VectorCopy(p->ctrl[0][0].xyz, p->ctrl[2][0].xyz);\n\n      b2 = Patch_GenericMesh(3, 3, 2, false);\n      p2 = b2->pPatch;\n      VectorCopy(p2->ctrl[2][0].xyz, p2->ctrl[2][1].xyz);\n      VectorCopy(p2->ctrl[0][0].xyz, p2->ctrl[1][0].xyz);\n      VectorCopy(p2->ctrl[0][0].xyz, p2->ctrl[2][0].xyz);\n      bCreated = true;\n    }\n    else if (bEndcap)\n    {\n      b = Patch_GenericMesh(5, 5, 2, false);\n      p = b->pPatch;\n      VectorCopy(p->ctrl[0][0].xyz, p->ctrl[1][0].xyz);\n      VectorCopy(p->ctrl[0][0].xyz, p->ctrl[2][0].xyz);\n      VectorCopy(p->ctrl[0][0].xyz, p->ctrl[3][0].xyz);\n      VectorCopy(p->ctrl[4][0].xyz, p->ctrl[4][1].xyz);\n      VectorCopy(p->ctrl[0][0].xyz, p->ctrl[4][0].xyz);\n\n      VectorCopy(p->ctrl[0][4].xyz, p->ctrl[1][4].xyz);\n      VectorCopy(p->ctrl[0][4].xyz, p->ctrl[2][4].xyz);\n      VectorCopy(p->ctrl[0][4].xyz, p->ctrl[3][4].xyz);\n      VectorCopy(p->ctrl[4][4].xyz, p->ctrl[4][3].xyz);\n      VectorCopy(p->ctrl[0][4].xyz, p->ctrl[4][4].xyz);\n\n      b2 = Patch_GenericMesh(5, 5, 2, false);\n      p2 = b2->pPatch;\n      VectorCopy(p2->ctrl[0][0].xyz, p2->ctrl[1][0].xyz);\n      VectorCopy(p2->ctrl[0][0].xyz, p2->ctrl[2][0].xyz);\n      VectorCopy(p2->ctrl[0][0].xyz, p2->ctrl[3][0].xyz);\n      VectorCopy(p2->ctrl[4][0].xyz, p2->ctrl[4][1].xyz);\n      VectorCopy(p2->ctrl[0][0].xyz, p2->ctrl[4][0].xyz);\n\n      VectorCopy(p2->ctrl[0][4].xyz, p2->ctrl[1][4].xyz);\n      VectorCopy(p2->ctrl[0][4].xyz, p2->ctrl[2][4].xyz);\n      VectorCopy(p2->ctrl[0][4].xyz, p2->ctrl[3][4].xyz);\n      VectorCopy(p2->ctrl[4][4].xyz, p2->ctrl[4][3].xyz);\n      VectorCopy(p2->ctrl[0][4].xyz, p2->ctrl[4][4].xyz);\n      bCreated = true;\n    }\n    else\n    {\n      b = Patch_GenericMesh(3, 3, 2, false);\n      p = b->pPatch;\n      \n      VectorCopy(p->ctrl[0][1].xyz, vTemp);\n      VectorCopy(p->ctrl[0][2].xyz, p->ctrl[0][1].xyz)\n      VectorCopy(p->ctrl[1][2].xyz, p->ctrl[0][2].xyz)\n      VectorCopy(p->ctrl[2][2].xyz, p->ctrl[1][2].xyz)\n      VectorCopy(p->ctrl[2][1].xyz, p->ctrl[2][2].xyz)\n      VectorCopy(p->ctrl[2][0].xyz, p->ctrl[2][1].xyz)\n      VectorCopy(p->ctrl[1][0].xyz, p->ctrl[2][0].xyz)\n      VectorCopy(p->ctrl[0][0].xyz, p->ctrl[1][0].xyz)\n      VectorCopy(vTemp, p->ctrl[0][0].xyz)\n\n      b2 = Patch_GenericMesh(3, 3, 2, false);\n      p2 = b2->pPatch;\n      VectorCopy(p2->ctrl[0][1].xyz, vTemp);\n      VectorCopy(p2->ctrl[0][2].xyz, p2->ctrl[0][1].xyz)\n      VectorCopy(p2->ctrl[1][2].xyz, p2->ctrl[0][2].xyz)\n      VectorCopy(p2->ctrl[2][2].xyz, p2->ctrl[1][2].xyz)\n      VectorCopy(p2->ctrl[2][1].xyz, p2->ctrl[2][2].xyz)\n      VectorCopy(p2->ctrl[2][0].xyz, p2->ctrl[2][1].xyz)\n      VectorCopy(p2->ctrl[1][0].xyz, p2->ctrl[2][0].xyz)\n      VectorCopy(p2->ctrl[0][0].xyz, p2->ctrl[1][0].xyz)\n      VectorCopy(vTemp, p2->ctrl[0][0].xyz)\n      bCreated = true;\n    }\n  }\n\n  if (bCreated)\n  {\n    drawVert_t vertTemp;\n    for (i = 0; i < p->width; i++)\n    {\n      for (j = 0; j < p->height; j++)\n      {\n        p->ctrl[i][j].xyz[2] = vMin[2];\n        p2->ctrl[i][j].xyz[2] = vMax[2];\n      }\n\n      for (j = 0; j < p->height / 2; j++)\n      {\n        memcpy(&vertTemp, &p->ctrl[i][p->height - 1- j], sizeof (drawVert_t));\n        memcpy(&p->ctrl[i][p->height - 1 - j], &p->ctrl[i][j], sizeof(drawVert_t));\n        memcpy(&p->ctrl[i][j], &vertTemp, sizeof(drawVert_t));\n      }\n\n    }\n    //Select_Delete();\n\n    Patch_CalcBounds(p, vMin, vMax);\n    Brush_RebuildBrush(p->pSymbiot, vMin, vMax);\n    Patch_CalcBounds(p2, vMin, vMax);\n    Brush_RebuildBrush(p2->pSymbiot, vMin, vMax);\n    Select_Brush(p->pSymbiot);\n    Select_Brush(p2->pSymbiot);\n  }\n  else\n  {\n    Select_Delete();\n  }\n  //Select_Brush(brushParent);\n\n}\n\n\n/*\n===============\nBrushToPatchMesh\n===============\n*/\nvoid Patch_BrushToMesh(bool bCone, bool bBevel, bool bEndcap, bool bSquare, int nHeight)\n{\n\tbrush_t\t\t*b;\n\tpatchMesh_t\t*p;\n\tint\t\t\ti,j;\n\n\tif (!QE_SingleBrush())\n\t\treturn;\n\n\tb = selected_brushes.next;\n\n\tp = MakeNewPatch();\n\n\tp->d_texture = b->brush_faces->d_texture;\n\n  p->height = nHeight;\n\n  p->type = PATCH_CYLINDER;\n  if (bBevel & !bSquare)\n  {\n    p->type = PATCH_BEVEL;\n    p->width = 3;\n    int nStep = (b->maxs[2] - b->mins[2]) / (p->height-1);\n    int nStart = b->mins[2];\n    for (i = 0; i < p->height; i++)\n    {\n\t    p->ctrl[0][i].xyz[0] =  b->mins[0];\n\t    p->ctrl[0][i].xyz[1] =  b->mins[1];\n      p->ctrl[0][i].xyz[2] = nStart;\n\n\t    p->ctrl[1][i].xyz[0] =  b->maxs[0];\n\t    p->ctrl[1][i].xyz[1] =  b->mins[1];\n      p->ctrl[1][i].xyz[2] = nStart;\n\n\t    p->ctrl[2][i].xyz[0] =  b->maxs[0];\n\t    p->ctrl[2][i].xyz[1] =  b->maxs[1];\n      p->ctrl[2][i].xyz[2] = nStart;\n      nStart += nStep;\n    }\n  }\n  else if (bEndcap & !bSquare)\n  {\n    p->type = PATCH_ENDCAP;\n    p->width = 5;\n    int nStep = (b->maxs[2] - b->mins[2]) / (p->height-1);\n    int nStart = b->mins[2];\n    for (i = 0; i < p->height; i++)\n    {\n\t    p->ctrl[0][i].xyz[0] =  b->mins[0];\n\t    p->ctrl[0][i].xyz[1] =  b->mins[1];\n      p->ctrl[0][i].xyz[2] = nStart;\n\n\t    p->ctrl[1][i].xyz[0] =  b->mins[0];\n\t    p->ctrl[1][i].xyz[1] =  b->maxs[1];\n      p->ctrl[1][i].xyz[2] = nStart;\n\n\t    p->ctrl[2][i].xyz[0] =  b->mins[0] + ((b->maxs[0] - b->mins[0]) * 0.5);\n\t    p->ctrl[2][i].xyz[1] =  b->maxs[1];\n      p->ctrl[2][i].xyz[2] = nStart;\n\t   \n      p->ctrl[3][i].xyz[0] =  b->maxs[0];\n\t    p->ctrl[3][i].xyz[1] =  b->maxs[1];\n      p->ctrl[3][i].xyz[2] = nStart;\n\n\t    p->ctrl[4][i].xyz[0] =  b->maxs[0];\n\t    p->ctrl[4][i].xyz[1] =  b->mins[1];\n      p->ctrl[4][i].xyz[2] = nStart;\n      nStart += nStep;\n    }\n  }\n  else\n  {\n    p->width = 9;\n\t  p->ctrl[1][0].xyz[0] =  b->mins[0];\n\t  p->ctrl[1][0].xyz[1] =  b->mins[1];\n\n\t  p->ctrl[3][0].xyz[0] =  b->maxs[0];\n\t  p->ctrl[3][0].xyz[1] =  b->mins[1];\n\n\t  p->ctrl[5][0].xyz[0] =  b->maxs[0];\n\t  p->ctrl[5][0].xyz[1] =  b->maxs[1];\n\n\t  p->ctrl[7][0].xyz[0] =  b->mins[0];\n\t  p->ctrl[7][0].xyz[1] =  b->maxs[1];\n\n\t  for ( i = 1 ; i < p->width - 1 ; i += 2 ) \n    {\n\n      p->ctrl[i][0].xyz[2] =  b->mins[2];\n\n\t\t  VectorCopy( p->ctrl[i][0].xyz, p->ctrl[i][2].xyz );\n\n\t\t  p->ctrl[i][2].xyz[2] =  b->maxs[2];\n\n\t\t  p->ctrl[i][1].xyz[0] = ( p->ctrl[i][0].xyz[0] + p->ctrl[i][2].xyz[0] ) * 0.5;\n\t\t  p->ctrl[i][1].xyz[1] = ( p->ctrl[i][0].xyz[1] + p->ctrl[i][2].xyz[1] ) * 0.5;\n\t\t  p->ctrl[i][1].xyz[2] = ( p->ctrl[i][0].xyz[2] + p->ctrl[i][2].xyz[2] ) * 0.5;\n\t  }\n\t  InterpolateInteriorPoints( p );\n\n    if (bSquare)\n    {\n      if (bBevel || bEndcap)\n      {\n        if (bBevel)\n        {\n          for (i = 0; i < p->height; i++)\n          {\n            VectorCopy(p->ctrl[1][i].xyz, p->ctrl[2][i].xyz);\n            VectorCopy(p->ctrl[7][i].xyz, p->ctrl[6][i].xyz);\n          }\n        }\n        else\n        {\n          for (i = 0; i < p->height; i++)\n          {\n            VectorCopy(p->ctrl[5][i].xyz, p->ctrl[4][i].xyz);\n            VectorCopy(p->ctrl[1][i].xyz, p->ctrl[2][i].xyz);\n            VectorCopy(p->ctrl[7][i].xyz, p->ctrl[6][i].xyz);\n            VectorCopy(p->ctrl[8][i].xyz, p->ctrl[7][i].xyz);\n          }\n        }\n      }\n      else\n      {\n        for (i = 0; i < p->width-1; i ++)\n        {\n          for (j = 0; j < p->height; j++)\n          {\n            VectorCopy(p->ctrl[i+1][j].xyz, p->ctrl[i][j].xyz);\n          }\n        }\n        for (j = 0; j < p->height; j++)\n        {\n          VectorCopy(p->ctrl[0][j].xyz, p->ctrl[8][j].xyz);\n        }\n      }\n    }\n  }\n\n\n  Patch_Naturalize(p);\n\n  if (bCone)\n  {\n    p->type = PATCH_CONE;\n    float xc = (b->maxs[0] + b->mins[0]) * 0.5; \n    float yc = (b->maxs[1] + b->mins[1]) * 0.5; \n\n    for ( i = 0 ; i < p->width ; i ++)\n    {\n      p->ctrl[i][2].xyz[0] = xc;\n      p->ctrl[i][2].xyz[1] = yc;\n    }\n  }\n/*\n  if (bEndcap || bBevel)\n  {\n    if (bInverted)\n    {\n      for ( i = 0 ; i < p->height ; i ++)\n      {\n        if (bBevel)\n        {\n          VectorCopy(p->ctrl[7][i], p->ctrl[0][i]);\n          VectorCopy(p->ctrl[7][i], p->ctrl[8][i]);\n          VectorCopy(p->ctrl[3][i], p->ctrl[2][i]);\n          VectorCopy(p->ctrl[5][i], p->ctrl[1][i]);\n          VectorCopy(p->ctrl[5][i], p->ctrl[4][i]);\n          VectorCopy(p->ctrl[5][i], p->ctrl[6][i]);\n        }\n        else\n        {\n          VectorCopy(p->ctrl[4][i], p->ctrl[8][i]);\n          VectorCopy(p->ctrl[1][i], p->ctrl[0][i]);\n          VectorCopy(p->ctrl[1][i], p->ctrl[10][i]);\n          VectorCopy(p->ctrl[3][i], p->ctrl[2][i]);\n          VectorCopy(p->ctrl[5][i], p->ctrl[4][i]);\n          VectorCopy(p->ctrl[7][i], p->ctrl[6][i]);\n          VectorCopy(p->ctrl[5][i], p->ctrl[7][i]);\n          VectorCopy(p->ctrl[3][i], p->ctrl[9][i]);\n        }\n      }\n    }\n    else\n    {\n      for ( i = 0 ; i < p->height ; i ++)\n      {\n        VectorCopy(p->ctrl[1][i], p->ctrl[2][i]);\n        VectorCopy(p->ctrl[7][i], p->ctrl[6][i]);\n        if (bBevel)\n        {\n          VectorCopy(p->ctrl[5][i], p->ctrl[4][i]);\n        }\n      }\n    }\n  }\n*/\n  \n  b = AddBrushForPatch(p);\n\n\n#if 1\n    Select_Delete();\n    Select_Brush(b);\n#else\n  if (!bCone)\n  {\n    Select_Delete();\n    Select_Brush(b);\n    GenerateEndCaps(b, bBevel, bEndcap, bInverted);\n    eclass_t *pecNew = Eclass_ForName(\"func_group\", false);\n    if (pecNew)\n    {\n      Entity_Create(pecNew);\n    }\n  }\n  else\n  {\n    Select_Delete();\n    Select_Brush(b);\n  }\n#endif\n\n}\n\n/*\n==================\nPatch_GenericMesh\n==================\n*/\nbrush_t* Patch_GenericMesh(int nWidth, int nHeight, int nOrientation, bool bDeleteSource, bool bOverride)\n{\n  int i,j;\n\n  if (nHeight < 3 || nHeight > 15 || nWidth < 3 || nWidth > 15)\n  {\n    Sys_Printf(\"Invalid patch width or height.\\n\");\n    return NULL;\n  }\n\n\tif (! bOverride && !QE_SingleBrush())\n  {\n    Sys_Printf(\"Cannot generate a patch from multiple selections.\\n\");\n\t\treturn NULL;\n  }\n\n\n\n  patchMesh_t* p = MakeNewPatch();\n\tp->d_texture = Texture_ForName(g_qeglobals.d_texturewin.texdef.name);\n\n\tp->width = nWidth;\n\tp->height = nHeight;\n  p->type = PATCH_GENERIC;\n\n  int nFirst = 0;\n  int nSecond = 1;\n  if (nOrientation == 0)\n  {\n    nFirst = 1;\n    nSecond = 2;\n  }\n  else if (nOrientation == 1)\n  {\n    nSecond = 2;\n  }\n\n\tbrush_t *b = selected_brushes.next;\n\n  int xStep = b->mins[nFirst];\n  float xAdj = abs((b->maxs[nFirst] - b->mins[nFirst]) / (nWidth - 1));\n  float yAdj = abs((b->maxs[nSecond] - b->mins[nSecond]) / (nHeight - 1));\n\n  for (i = 0; i < nWidth; i++)\n  {\n    int yStep = b->mins[nSecond];\n    for (j = 0; j < nHeight; j++)\n    {\n      p->ctrl[i][j].xyz[nFirst] = xStep;\n      p->ctrl[i][j].xyz[nSecond] = yStep;\n      p->ctrl[i][j].xyz[nOrientation] = 0;\n      yStep += yAdj;\n    }\n    xStep += xAdj;\n  }\n\n  Patch_Naturalize(p);\n\n  b = AddBrushForPatch(p);\n  if (bDeleteSource)\n  {\n    Select_Delete();\n    Select_Brush(b);\n  }\n\n  return b;\n  //g_qeglobals.d_select_mode = sel_curvepoint;\n}\n\n/*\n==================\nPointInMoveList\n==================\n*/\nint PointInMoveList(float *pf)\n{\n  for (int i = 0; i < g_qeglobals.d_num_move_points; i++)\n  {\n    if (pf == &g_qeglobals.d_move_points[i][0])\n      return i;\n  }\n  return -1;\n}\n\n/*\n==================\nPointValueInMoveList\n==================\n*/\nint PointValueInMoveList(vec3_t v)\n{\n  for (int i = 0; i < g_qeglobals.d_num_move_points; i++)\n  {\n    if (VectorCompare(v, g_qeglobals.d_move_points[i]))\n      return i;\n  }\n  return -1;\n}\n\n\n/*\n==================\nRemovePointFromMoveList\n==================\n*/\nvoid RemovePointFromMoveList(vec3_t v)\n{\n  int n;\n  while ( (n = PointValueInMoveList(v)) >= 0)\n  {\n    for (int i = n; i < g_qeglobals.d_num_move_points-1; i++)\n    {\n      g_qeglobals.d_move_points[i] = g_qeglobals.d_move_points[i+1];\n    }\n    g_qeglobals.d_num_move_points--;\n  }\n}\n\n/*\n==================\nColumnSelected\n==================\n*/\nbool ColumnSelected(patchMesh_t* p, int nCol)\n{\n  for (int i = 0; i < p->height; i++)\n  {\n    if (PointInMoveList(p->ctrl[nCol][i].xyz) == -1)\n      return false;\n  }\n  return true;\n}\n\n/*\n==================\nAddPoint\n==================\n*/\nvoid AddPoint(patchMesh_t* p, vec3_t v, bool bWeldOrDrill = true)\n{\n  int nDim1 = (g_pParentWnd->ActiveXY()->GetViewType() == YZ) ? 1 : 0;\n  int nDim2 = (g_pParentWnd->ActiveXY()->GetViewType() == XY) ? 1 : 2;\n  g_qeglobals.d_move_points[g_qeglobals.d_num_move_points++] = v;\n  if ((g_bPatchWeld || g_bPatchDrillDown) && bWeldOrDrill)\n  {\n\t  for ( int i = 0 ; i < p->width ; i++ ) \n    {\n\t\t  for ( int j = 0 ; j < p->height ; j++ ) \n      {\n        if (g_bPatchWeld)\n        {\n          if ( VectorCompare(v, p->ctrl[i][j].xyz)\n            && PointInMoveList(p->ctrl[i][j].xyz) == -1)\n          {\n            g_qeglobals.d_move_points[g_qeglobals.d_num_move_points++] = p->ctrl[i][j].xyz;\n            continue;\n          }\n        }\n        if (g_bPatchDrillDown && g_nPatchClickedView != W_CAMERA)\n        {\n          if ( (fabs(v[nDim1] - p->ctrl[i][j].xyz[nDim1]) <= EQUAL_EPSILON) \n             &&(fabs(v[nDim2] - p->ctrl[i][j].xyz[nDim2]) <= EQUAL_EPSILON)) \n          {\n            if (PointInMoveList(p->ctrl[i][j].xyz) == -1)\n            {\n              g_qeglobals.d_move_points[g_qeglobals.d_num_move_points++] = p->ctrl[i][j].xyz;\n              continue;\n            }\n          }\n#if 0\n          int l = 0;\n\t        for ( int k = 0; k < 2; k++ )\n          {\n\t\t        if (fabs(v[k] - p->ctrl[i][j].xyz[k]) > EQUAL_EPSILON)\n              continue;\n             l++;\n          }\n          if (l >= 2 && PointInMoveList(p->ctrl[i][j].xyz) == -1)\n          {\n            g_qeglobals.d_move_points[g_qeglobals.d_num_move_points++] = p->ctrl[i][j].xyz;\n            continue;\n          }\n#endif\n        }\n      }\n    }\n  }\n#if 0\n  if (g_qeglobals.d_num_move_points == 1)\n  {\n    // single point selected\n    // FIXME: the two loops can probably be reduced to one\n\t  for ( int i = 0 ; i < p->width ; i++ ) \n    {\n\t\t  for ( int j = 0 ; j < p->height ; j++ ) \n      {\n        int n = PointInMoveList(v);\n        if (n >= 0)\n        {\n          if (((i & 0x01) && (j & 0x01)) == 0)\n          {\n            // put any sibling fixed points\n            // into the inverse list\n            int p1, p2, p3, p4;\n            p1 = i + 2;\n            p2 = i - 2;\n            p3 = j + 2;\n            p4 = j - 2;\n            if (p1 < p->width)\n            {\n\n            }\n            if (p2 >= 0)\n            {\n            }\n            if (p3 < p->height)\n            {\n            }\n            if (p4 >= 0)\n            {\n            }\n          }\n        }\n      }\n    }\n  }\n#endif\n}\n\n/*\n==================\nSelectRow\n==================\n*/\nvoid SelectRow(patchMesh_t* p, int nRow, bool bMulti)\n{\n  if (!bMulti)\n    g_qeglobals.d_num_move_points = 0;\n  for (int i = 0; i < p->width; i++)\n  {\n    AddPoint(p, p->ctrl[i][nRow].xyz, false);\n  }\n  //Sys_Printf(\"Selected Row %d\\n\", nRow);\n}\n\n/*\n==================\nSelectColumn\n==================\n*/\nvoid SelectColumn(patchMesh_t* p, int nCol, bool bMulti)\n{\n  if (!bMulti)\n    g_qeglobals.d_num_move_points = 0;\n  for (int i = 0; i < p->height; i++)\n  {\n    AddPoint(p, p->ctrl[nCol][i].xyz, false);\n  }\n  //Sys_Printf(\"Selected Col %d\\n\", nCol);\n}\n\n\n/*\n==================\nAddPatchMovePoint\n==================\n*/\nvoid AddPatchMovePoint(vec3_t v, bool bMulti, bool bFull)\n{\n  if (!g_bSameView && !bMulti && !bFull)\n  {\n    g_bSameView = true;\n    return;\n  }\n\n\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n\t    patchMesh_t* p = pb->pPatch;\n\t    for ( int i = 0 ; i < p->width ; i++ ) \n      {\n\t\t    for ( int j = 0 ; j < p->height ; j++ ) \n        {\n          if (VectorCompare(v, p->ctrl[i][j].xyz))\n          {\n            if (PointInMoveList(p->ctrl[i][j].xyz) == -1)\n            {\n              if (bFull)        // if we want the full row/col this is on\n              {\n                SelectColumn(p, i, bMulti);\n              }\n              else\n              {\n                if (!bMulti)\n                  g_qeglobals.d_num_move_points = 0;\n                AddPoint(p, p->ctrl[i][j].xyz);\n                //Sys_Printf(\"Selected col:row %d:%d\\n\", i, j);\n              }\n              //--if (!bMulti)\n              return;\n            }\n            else\n            {\n              if (bFull)\n              {\n                if (ColumnSelected(p, i))\n                {\n                  SelectRow(p, j, bMulti);\n                }\n                else\n                {\n                  SelectColumn(p, i, bMulti);\n                }\n                return;\n              }\n              if (g_bSameView)\n              {\n                RemovePointFromMoveList(v);\n                return;\n              }\n            }\n          }\n\t\t    }\n\t    }\n    }\n  }\n}\n\n/*\n==================\nPatch_UpdateSelected\n==================\n*/\nvoid Patch_UpdateSelected(vec3_t vMove)\n{\n  int i, j;\n  for (i=0 ; i < g_qeglobals.d_num_move_points ; i++)\n  {\n\t  VectorAdd (g_qeglobals.d_move_points[i], vMove, g_qeglobals.d_move_points[i]);\n    if (g_qeglobals.d_num_move_points == 1)\n    {\n    }\n  }\n\n\t//--patchMesh_t* p = &patchMeshes[g_nSelectedPatch];\n\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n\t    patchMesh_t* p = pb->pPatch;\n\n\n      g_qeglobals.d_numpoints = 0;\n\t    for (i = 0 ; i < p->width ; i++ ) \n      {\n\t\t    for ( j = 0 ; j < p->height ; j++ ) \n        {\n\t        VectorCopy (p->ctrl[i][j].xyz, g_qeglobals.d_points[g_qeglobals.d_numpoints]);\n          if (g_qeglobals.d_numpoints < MAX_POINTS-1)\n          {\n\t          g_qeglobals.d_numpoints++;\n          }\n\t\t    }\n      }\n\t    \n      vec3_t vMin, vMax;\n      Patch_CalcBounds(p, vMin, vMax);\n      Brush_RebuildBrush(p->pSymbiot, vMin, vMax);\n    }\n  }\n  //Brush_Free(p->pSymbiot);\n  //Select_Brush(AddBrushForPatch(g_nSelectedPatch));\n}\n\n\n\n/*\n===============\nSampleSinglePatch\n===============\n*/\nvoid SampleSinglePatch (float ctrl[3][3][5], float u, float v, float out[5]) {\n\tfloat\tvCtrl[3][5];\n\tint\t\tvPoint;\n\tint\t\taxis;\n\n\t// find the control points for the v coordinate\n\tfor (vPoint = 0 ; vPoint < 3 ; vPoint++) \n  {\n\t\tfor (axis = 0 ; axis < 5 ; axis++) \n    {\n\t\t\tfloat\ta, b, c;\n\t\t\tfloat\tqA, qB, qC;\n\n\t\t\ta = ctrl[0][vPoint][axis];\n\t\t\tb = ctrl[1][vPoint][axis];\n\t\t\tc = ctrl[2][vPoint][axis];\n\t\t\tqA = a - 2 * b + c;\n\t\t\tqB = 2 * b - 2 * a;\n\t\t\tqC = a;\n\n\t\t\tvCtrl[vPoint][axis] = qA * u * u + qB * u + qC;\n\t\t}\n\t}\n\n\t// interpolate the v value\n\tfor (axis = 0 ; axis < 5 ; axis++) \n  {\n\t\tfloat\ta, b, c;\n\t\tfloat\tqA, qB, qC;\n\n\t\ta = vCtrl[0][axis];\n\t\tb = vCtrl[1][axis];\n\t\tc = vCtrl[2][axis];\n\t\tqA = a - 2 * b + c;\n\t\tqB = 2 * b - 2 * a;\n\t\tqC = a;\n\n\t\tout[axis] = qA * v * v + qB * v + qC;\n\t}\n}\n\n/*\n===================\nDrawSinglePatch\n===================\n*/\nvoid DrawSinglePatch (float ctrl[3][3][5], bool bPoints) \n{\n\tint\t\ti, j;\n\tfloat\tu, v;\n\tfloat\tverts[CBLOCK_SUBDIVISIONS+1][CBLOCK_SUBDIVISIONS+1][5];\n\n\tfor (i = 0 ; i <= CBLOCK_SUBDIVISIONS ; i++) \n  {\n\t\tfor (j = 0 ; j <= CBLOCK_SUBDIVISIONS ; j++) \n    {\n\t\t\tu = (float)i / CBLOCK_SUBDIVISIONS;\n\t\t\tv = (float)j / CBLOCK_SUBDIVISIONS;\n\t\t\tSampleSinglePatch (ctrl, u, v, verts[i][j]);\n\t\t}\n\t}\n  // at this point we have \n\n  int nCount = -1;\n\tfor (i = 0 ; i < CBLOCK_SUBDIVISIONS ; i++) \n  {\n    qglBegin (GL_QUAD_STRIP);\n\n\t\tfor (j = 0 ; j <= CBLOCK_SUBDIVISIONS ; j++) \n    {\n\t\t\tqglTexCoord2fv( verts[i+1][j] + 3 );\n\t\t\tqglVertex3fv( verts[i+1][j] );\n/*\n      if (nCount >= 0)\n      {\n        VectorCopy(verts[i+1][j], vNormals[nCount]);\n      }\n      nCount++;\n      if (nCount == 3)\n      {\n        VectorSubtract(vNormals[0], vNormals[1], vNormals[0]);\n        VectorSubtract(vNormals[1], vNormals[2], vNormals[1]);\n        CrossProduct(vNormals[0], vNormals[1], vNormals[2]);\n        //VectorNormalize(vNormals[2]);\n        qglNormal3fv(vNormals[2]);\n        nCount = -1;\n      }\n*/\n      qglTexCoord2fv( verts[i][j] + 3 );\n\t\t\tqglVertex3fv( verts[i][j] );\n/*\n      VectorCopy(verts[i][j], vNormals[nCount]);\n      nCount++;\n      if (nCount == 3)\n      {\n        VectorSubtract(vNormals[0], vNormals[1], vNormals[0]);\n        VectorSubtract(vNormals[1], vNormals[2], vNormals[1]);\n        CrossProduct(vNormals[0], vNormals[1], vNormals[2]);\n        //VectorNormalize(vNormals[2]);\n        qglNormal3fv(vNormals[2]);\n        nCount = -1;\n      }\n*/\n\t\t}\n\t  qglEnd ();\n\t}\n\n}\n\n/*\n=================\nDrawPatchMesh\n=================\n*/\n//FIXME: this routine needs to be reorganized.. should be about 1/4 the size and complexity\nvoid DrawPatchMesh( patchMesh_t *pm, bool bPoints, bool bShade = false ) {\n\tint\t\ti, j, k, l;\n\tfloat\tctrl[3][3][5];\n\n  bool bOverlay = pm->bOverlay;\n\tint nDrawMode = g_pParentWnd->GetCamera()->Camera().draw_mode;\n\n  //--float fColor[3];\n  //--if (bShade)\n  //--{\n  //--  face_t *f = pm->pSymbiot->brush_faces;\n  //--  _SetColor(f, fColor);\n  //--}\n  if (g_PrefsDlg.m_bDisplayLists)\n  {\n    if (pm->bDirty || pm->nListID <= 0)\n    {\n      if (pm->nListID <= 0)\n        pm->nListID = qglGenLists(1);\n      if (pm->nListID > 0)\n      {\n        qglNewList(pm->nListID, GL_COMPILE_AND_EXECUTE);\n      }\n      \n\n\n      if (pm->type != PATCH_TRIANGLE)\n      {\n        //vec3_t *vMeshData = new vec3_t[pm->width * pm->height];\n\n        // wasteful\n        if (g_PrefsDlg.m_bGLLighting)\n        {\n          Patch_MeshNormals(pm);\n          for (i = 0; i < pm->width; i++)\n          {\n            for (j = 0; j < pm->height; j++)\n            {\n              //VectorCopy(pm->ctrl[i][j].xyz, vMeshData[(j * pm->width) + i]);\n              qglNormal3fv(pm->ctrl[i][j].normal);\n            }\n          }\n        }\n\n\t      for ( i = 0 ; i + 2 < pm->width ; i += 2 ) \n        {\n\t\t      for ( j = 0 ; j + 2 < pm->height ; j += 2 ) \n          {\n\n\t\t\t      for ( k = 0 ; k < 3 ; k++ ) \n            {\n              vec3_t vAvg;\n              vAvg[0] = vAvg[1] = vAvg[2] = 0;\n\t\t\t\t      for ( l = 0 ; l < 3 ; l++ ) \n              {\n\t\t\t\t\t      ctrl[k][l][0] = pm->ctrl[ i + k ][ j + l ].xyz[ 0 ];\n\t\t\t\t\t      ctrl[k][l][1] = pm->ctrl[ i + k ][ j + l ].xyz[ 1 ];\n\t\t\t\t\t      ctrl[k][l][2] = pm->ctrl[ i + k ][ j + l ].xyz[ 2 ];\n\t\t\t\t\t      ctrl[k][l][3] = pm->ctrl[ i + k ][ j + l ].xyz[ 3 ];\n\t\t\t\t\t      ctrl[k][l][4] = pm->ctrl[ i + k ][ j + l ].xyz[ 4 ];\n\n                if (g_PrefsDlg.m_bGLLighting)\n                {\n                  qglNormal3fv(pm->ctrl[i+k][j+l].normal);\n                }\n\t\t\t\t      }\n\n\t\t\t      }\n\n//--            if (g_pParentWnd->GetCamera()->Camera().draw_mode == cd_texture)\n//--            {\n//--              VectorCopy(pm->ctrl[i][j].normal, plane.normal);\n//--              float shade = SetShadeForPlane(&plane);\n//--              qtexture_t *q = pm->d_texture;\n//--              vec3_t vColor;\n//--\n//--              vColor[0] = shade;// * q->color[0];\n//--              vColor[1] = shade;// * q->color[1];\n//--              vColor[2] = shade;// * q->color[2];\n//--              qglColor3fv(vColor);\n//--            }\n\n            \n//--            if (g_PrefsDlg.m_bGLLighting)\n//--            {\n//--              //qglNormal3fv(pm->ctrl[i][j].normal);\n//--            }\n            DrawSinglePatch( ctrl, bPoints );\n          }\n        }\n\n        // we have an array of clean control points\n        //\n        /*\n        qglMap2f(GL_MAP2_NORMAL, 0, 1, 3, 3, 0, 1, 9, 3, (float*)&vMeshData);\n        for (i = 0; i < pm->width; i++)\n        {\n          for (j = 0; j < pm->height; j++)\n          {\n            qglEvalPoint2(i, j);\n          }\n        }\n\n        delete []vMeshData;\n        */\n      }\n      else\n      {\n        qglBegin (GL_TRIANGLES);\n   \t    qglTexCoord2fv( pm->ctrl[0][0].st);\n\t\t\t  qglVertex3fv( pm->ctrl[0][0].xyz);\n\t\t\t  qglTexCoord2fv( pm->ctrl[2][0].st);\n\t\t\t  qglVertex3fv( pm->ctrl[2][0].xyz);\n\t\t\t  qglTexCoord2fv( pm->ctrl[2][2].st);\n\t\t\t  qglVertex3fv( pm->ctrl[2][2].xyz);\n        qglEnd();\n      }\n\n      if (pm->nListID > 0)\n      {\n        qglEndList();\n        pm->bDirty = false;\n      }\n    }\n    else\n    {\n      qglCallList(pm->nListID);\n    }\n  }\n  else\n  {\n\t  for ( i = 0 ; i + 2 < pm->width ; i += 2 ) \n    {\n\t\t  for ( j = 0 ; j + 2 < pm->height ; j += 2 ) \n      {\n\t\t\t  for ( k = 0 ; k < 3 ; k++ ) \n        {\n\t\t\t\t  for ( l = 0 ; l < 3 ; l++ ) \n          {\n\t\t\t\t\t  ctrl[k][l][0] = pm->ctrl[ i + k ][ j + l ].xyz[ 0 ];\n\t\t\t\t\t  ctrl[k][l][1] = pm->ctrl[ i + k ][ j + l ].xyz[ 1 ];\n\t\t\t\t\t  ctrl[k][l][2] = pm->ctrl[ i + k ][ j + l ].xyz[ 2 ];\n\t\t\t\t\t  ctrl[k][l][3] = pm->ctrl[ i + k ][ j + l ].xyz[ 3 ];\n\t\t\t\t\t  ctrl[k][l][4] = pm->ctrl[ i + k ][ j + l ].xyz[ 4 ];\n\t\t\t\t  }\n\t\t\t  }\n        //--if (bShade)\n        //--{\n        //--  _DecColor(fColor);\n        //--}\n\t\t\t  DrawSinglePatch( ctrl, bPoints );\n      }\n    }\n  }\n\n  vec3_t* pSelectedPoints[256];\n  int nIndex = 0;\n\n  qglPushAttrib(GL_CURRENT_BIT);\n  //--qglDisable(GL_BLEND);\n  //--qglDisable (GL_DEPTH_TEST);\n  //qglDisable (GL_TEXTURE_2D);\n\n  bool bDisabledLighting = qglIsEnabled(GL_LIGHTING);\n  if (bDisabledLighting)\n  {\n    qglDisable(GL_LIGHTING);\n  }\n\n\n  // FIXME: this bend painting code needs to be rolled up significantly as it is a cluster fuck right now\n  if (bPoints && (g_qeglobals.d_select_mode == sel_curvepoint || g_qeglobals.d_select_mode == sel_area || g_bPatchBendMode || g_bPatchInsertMode))\n  {\n    bOverlay = false;\n\n    // bending or inserting\n    if (g_bPatchBendMode || g_bPatchInsertMode)\n    {\n      qglPointSize(6);\n      if (g_bPatchAxisOnRow)\n      {\n        qglColor3f(1, 0, 1);\n        qglBegin(GL_POINTS);\n        for (i = 0; i < pm->width; i++)\n        {\n\t\t\t    qglVertex3fv(reinterpret_cast<float(*)>(&pm->ctrl[i][g_nPatchAxisIndex].xyz));\n        }\n        qglEnd();\n      \n        // could do all of this in one loop but it was pretty messy\n        if (g_bPatchInsertMode)\n        {\n          qglColor3f(0, 0, 1);\n          qglBegin(GL_POINTS);\n          for (i = 0; i < pm->width; i++)\n          {\n\t\t\t      qglVertex3fv(reinterpret_cast<float(*)>(&pm->ctrl[i][g_nPatchAxisIndex].xyz));\n\t\t\t      qglVertex3fv(reinterpret_cast<float(*)>(&pm->ctrl[i][g_nPatchAxisIndex+1].xyz));\n          }\n          qglEnd();\n        }\n        else\n        {\n          if (g_nPatchBendState == BEND_SELECT_EDGE || g_nPatchBendState == BEND_BENDIT || g_nPatchBendState == BEND_SELECT_ORIGIN)\n          {\n            qglColor3f(0, 0, 1);\n            qglBegin(GL_POINTS);\n            if (g_nPatchBendState == BEND_SELECT_ORIGIN)\n            {\n              qglVertex3fv(g_vBendOrigin);\n            }\n            else\n            {\n              for (i = 0; i < pm->width; i++)\n              {\n                if (g_bPatchLowerEdge)\n                {\n                  for (j = 0; j < g_nPatchAxisIndex; j++)\n\t\t\t              qglVertex3fv(reinterpret_cast<float(*)>(&pm->ctrl[i][j].xyz));\n                }\n                else\n                {\n                  for (j = pm->height-1; j > g_nPatchAxisIndex; j--)\n\t\t\t              qglVertex3fv(reinterpret_cast<float(*)>(&pm->ctrl[i][j].xyz));\n                }\n              }\n            }\n            qglEnd();\n          }\n        }\n      }\n      else\n      {\n        qglColor3f(1, 0, 1);\n        qglBegin(GL_POINTS);\n        for (i = 0; i < pm->height; i++)\n        {\n\t\t\t    qglVertex3fv(reinterpret_cast<float(*)>(&pm->ctrl[g_nPatchAxisIndex][i].xyz));\n        }\n        qglEnd();\n        \n        // could do all of this in one loop but it was pretty messy\n        if (g_bPatchInsertMode)\n        {\n          qglColor3f(0, 0, 1);\n          qglBegin(GL_POINTS);\n          for (i = 0; i < pm->height; i++)\n          {\n\t\t\t      qglVertex3fv(reinterpret_cast<float(*)>(&pm->ctrl[g_nPatchAxisIndex][i].xyz));\n\t\t\t      qglVertex3fv(reinterpret_cast<float(*)>(&pm->ctrl[g_nPatchAxisIndex+1][i].xyz));\n          }\n          qglEnd();\n        }\n        else\n        {\n          if (g_nPatchBendState == BEND_SELECT_EDGE || g_nPatchBendState == BEND_BENDIT || g_nPatchBendState == BEND_SELECT_ORIGIN)\n          {\n            qglColor3f(0, 0, 1);\n            qglBegin(GL_POINTS);\n            for (i = 0; i < pm->height; i++)\n            {\n              if (g_nPatchBendState == BEND_SELECT_ORIGIN)\n              {\n                qglVertex3fv(reinterpret_cast<float(*)>(&pm->ctrl[g_nBendOriginIndex][i].xyz));\n              }\n              else\n              {\n                if (g_bPatchLowerEdge)\n                {\n                  for (j = 0; j < g_nPatchAxisIndex; j++)\n\t\t\t              qglVertex3fv(reinterpret_cast<float(*)>(&pm->ctrl[j][i].xyz));\n                }\n                else\n                {\n                  for (j = pm->width-1; j > g_nPatchAxisIndex; j--)\n\t\t\t              qglVertex3fv(reinterpret_cast<float(*)>(&pm->ctrl[j][i].xyz));\n                }\n              }\n            }\n            qglEnd();\n          }\n        }\n      }\n    }\n    else // just painting the grid for selection\n    {\n      qglPointSize(6);\n\t    for ( i = 0 ; i < pm->width ; i++ )\n      {\n\t\t    for ( j = 0 ; j < pm->height ; j++ ) \n        {\n\t        qglBegin(GL_POINTS);\n          // FIXME: need to not do loop lookups inside here\n          int n = PointValueInMoveList(pm->ctrl[i][j].xyz);\n          if (n >= 0)\n          {\n            pSelectedPoints[nIndex++] = reinterpret_cast<float(*)[3]>(&pm->ctrl[i][j].xyz);\n          }\n\n          if (i & 0x01 || j & 0x01)\n            qglColor3f(1, 0, 1);\n          else\n            qglColor3f(0, 1, 0);\n\t\t\t    qglVertex3fv(pm->ctrl[i][j].xyz);\n\t        qglEnd();\n        }\n      }\n    }\n    if (nIndex > 0)\n    {\n      qglBegin(GL_POINTS);\n      qglColor3f(0, 0, 1);\n      while (nIndex-- > 0)\n      {\n\t\t\t  qglVertex3fv(*pSelectedPoints[nIndex]);\n      }\n      qglEnd();\n    }\n  }\n\n  if (bOverlay)\n  {\n    qglPointSize(6);\n    qglColor3f(0.5, 0.5, 0.5);\n\t  for ( i = 0 ; i < pm->width ; i++ )\n    {\n      qglBegin(GL_POINTS);\n\t\t  for ( j = 0 ; j < pm->height ; j++ ) \n      {\n\t\t\t  if (i & 0x01 || j & 0x01)\n          qglColor3f(0.5, 0, 0.5);\n        else\n          qglColor3f(0, 0.5, 0);\n        qglVertex3fv(pm->ctrl[i][j].xyz);\n      }\n      qglEnd();\n    }\n  }\n\t//--qglEnable (GL_TEXTURE_2D);\n\t//--qglEnable (GL_DEPTH_TEST);\n\n  if (bDisabledLighting)\n  {\n    qglEnable(GL_LIGHTING);\n  }\n\n\tqglPopAttrib();\n\n}\n\n/*\n==================\nPatch_DrawXY\n==================\n*/\nvoid Patch_DrawXY(patchMesh_t *pm)\n{\n\tqglPolygonMode (GL_FRONT_AND_BACK, GL_LINE);\n  if (pm->bSelected)\n  {\n    qglColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES]);\n    //qglDisable (GL_LINE_STIPPLE);\n\t  //qglLineWidth (1);\n  }\n  else\n    qglColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES]);\n\n\tDrawPatchMesh( pm , pm->bSelected );\n\tqglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);\n  if (pm->bSelected)\n  {\n\t  //qglLineWidth (2);\n    //qglEnable (GL_LINE_STIPPLE);\n  }\n}\n\n/*\n==================\nPatch_DrawCam\n==================\n*/\nvoid Patch_DrawCam(patchMesh_t *pm)\n{\n\tqglColor3f (1,1,1);\n  qglPushAttrib(GL_ALL_ATTRIB_BITS);\n\n  if (g_bPatchWireFrame)\n  {\n\t  qglDisable( GL_CULL_FACE );\n\t  qglPolygonMode (GL_FRONT_AND_BACK, GL_LINE);\n\t  qglDisable(GL_TEXTURE_2D);\n    if (g_PrefsDlg.m_bGLLighting)\n    {\n      qglDisable(GL_LIGHTING);\n    }\n\t  DrawPatchMesh( pm , pm->bSelected, true );\n    if (g_PrefsDlg.m_bGLLighting)\n    {\n      qglEnable(GL_LIGHTING);\n    }\n\t  qglEnable( GL_CULL_FACE );\n  }\n  else\n  {\n    if (g_PrefsDlg.m_bGLLighting)\n    {\n      //qglEnable(GL_NORMALIZE);\n    }\n\t  qglEnable( GL_CULL_FACE );\n    qglCullFace(GL_FRONT);\n    qglBindTexture (GL_TEXTURE_2D, pm->d_texture->texture_number);\n\n    if (pm->d_texture->bFromShader && pm->d_texture->fTrans < 1.0)\n    {\n\t    //qglEnable ( GL_BLEND );\n\t    //qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\n      qglColor4f(pm->d_texture->color[0], pm->d_texture->color[1], pm->d_texture->color[2], pm->d_texture->fTrans); \n    }\n    DrawPatchMesh( pm , pm->bSelected, true );\n    \n    qglCullFace(GL_BACK);\n\t  //qglDisable(GL_TEXTURE_2D);\n\t  qglPolygonMode (GL_FRONT_AND_BACK, GL_LINE);\n\n    qglDisable ( GL_BLEND );\n\t  DrawPatchMesh( pm , pm->bSelected, true );\n  }\n\n#if 0 // this paints normal indicators on the ctrl points\n      //--qglDisable (GL_DEPTH_TEST);\n      qglDisable (GL_TEXTURE_2D);\n      qglColor3f (1,1,1);\n\n      for (int i = 0; i < pm->width; i++)\n      {\n        for (int j = 0; j < pm->height; j++)\n        {\n          vec3_t temp;\n\t        qglBegin (GL_LINES);\n\t\t      qglVertex3fv (pm->ctrl[i][j].xyz);\n\t\t      VectorMA (pm->ctrl[i][j].xyz, 8, pm->ctrl[i][j].normal, temp);\n\t\t      qglVertex3fv (temp);\n\t        qglEnd ();\n        }\n      }\n      qglEnable (GL_TEXTURE_2D);\n      //--qglEnable (GL_DEPTH_TEST);\n#endif\n\n\n  qglPopAttrib();\n}\n\n\n\n\nvoid ConvexHullForSection( float section[2][4][7] ) {\n}\n\nvoid BrushesForSection( float section[2][4][7] ) {\n}\n\n//\n//================\n//Patch_BuildPoints\n//================\nvoid Patch_BuildPoints (brush_t *b) \n{\n\tface_t\t\t*f;\n\tb->patchBrush = false;\n\tfor (f=b->brush_faces ; f ; f=f->next) \n  {\n\t\tif (f->texdef.flags & SURF_PATCH) \n    {\n\t\t\tb->patchBrush = true;\n      //vec3_t vMin, vMax;\n      //Patch_CalcBounds(&patchMeshes[b->nPatchID], vMin, vMax);\n      //VectorCopy(vMin, b->mins);\n      //VectorCopy(vMax, b->maxs);\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n\n\n//\n//===============\n//Patch_WriteFile\n//===============\n//\n#if 0\nvoid Patch_WriteFile (char *name) \n{\n\tchar patchName[1024];\n  time_t ltime;\n\tstrcpy(patchName, name);\n\tStripExtension (patchName);\n\tstrcat (patchName, \".patch\");\n\n  FILE *file = fopen(patchName, \"w\");\n  if (file)\n  {\n\t  time(&ltime);\n\t  fprintf (file, \"// %s saved on %s\\n\", name, ctime(&ltime) );\n\n    for (int i = 0; i < numPatchMeshes; i++)\n    {\n\t\t  fprintf(file, \"{\\n\");\n      fprintf(file, \" %s\\n\", patchMeshes[i].d_texture->name);\n      fprintf(file, \" ( %i %i %i ) \\n\", patchMeshes[i].width, patchMeshes[i].height, patchMeshes[i].negative);\n      for (int w = 0; w < patchMeshes[i].width; w++)\n      {\n        for (int h = 0; h < patchMeshes[i].height; h++)\n        {\n          fprintf(file, \" ( \");\n          for (int k = 0; k < 5; k++)\n          {\n            float f = patchMeshes[i].ctrl[w][h][k];\n            if (f == int(f))\n              fprintf(file, \"%i \", (int)f);\n            else\n              fprintf(file, \"%f \", f);\n          }\n          fprintf(file, \")\\n\");\n        }\n      }\n      fprintf(file, \"}\\n\");\n    }\n    fclose(file);\n  }\n}\n#endif\n\n/*\n==================\nPatch_Move\n==================\n*/\nvoid Patch_Move(patchMesh_t *pm, const vec3_t vMove, bool bRebuild)\n{\n  pm->bDirty = true;\n  for (int w = 0; w < pm->width; w++)\n  {\n    for (int h = 0; h < pm->height; h++)\n    {\n      VectorAdd(pm->ctrl[w][h].xyz, vMove, pm->ctrl[w][h].xyz);\n    }\n  }\n  if (bRebuild)\n  {\n    vec3_t vMin, vMax;\n    Patch_CalcBounds(pm, vMin, vMax);\n    //Brush_RebuildBrush(patchMeshes[n].pSymbiot, vMin, vMax);\n  }\n  UpdatePatchInspector();\n\n}\n\n/*\n==================\nPatch_ApplyMatrix\n==================\n*/\nvoid Patch_ApplyMatrix(patchMesh_t *p, const vec3_t vOrigin, const vec3_t vMatrix[3], bool bSnap)\n{\n  vec3_t vTemp;\n\n  for (int w = 0; w < p->width; w++)\n  {\n    for (int h = 0; h < p->height; h++)\n    {\n      if ( (g_qeglobals.d_select_mode == sel_curvepoint || g_bPatchBendMode)\n        && PointInMoveList(p->ctrl[w][h].xyz) == -1)\n        continue;\n\t\t\tVectorSubtract (p->ctrl[w][h].xyz, vOrigin, vTemp);\n\t\t\tfor (int j = 0; j < 3; j++)\n      {\n        p->ctrl[w][h].xyz[j] = DotProduct(vTemp, vMatrix[j]) + vOrigin[j];\n        if (bSnap)\n        {\n          p->ctrl[w][h].xyz[j] = floor(p->ctrl[w][h].xyz[j] + 0.5);\n        }\n      }\n    }\n  }\n  vec3_t vMin, vMax;\n  Patch_CalcBounds(p, vMin, vMax);\n  Brush_RebuildBrush(p->pSymbiot, vMin, vMax);\n}\n\n/*\n==================\nPatch_EditPatch\n==================\n*/\nvoid Patch_EditPatch()\n{\n  //--patchMesh_t* p = &patchMeshes[n];\n  g_qeglobals.d_numpoints = 0;\n  g_qeglobals.d_num_move_points = 0;\n\t\n  for (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n\t    patchMesh_t* p = pb->pPatch;\n\t    for ( int i = 0 ; i < p->width ; i++ ) \n      {\n\t\t    for ( int j = 0 ; j < p->height ; j++ ) \n        {\n\t        VectorCopy (p->ctrl[i][j].xyz, g_qeglobals.d_points[g_qeglobals.d_numpoints]);\n          if (g_qeglobals.d_numpoints < MAX_POINTS-1)\n          {\n\t          g_qeglobals.d_numpoints++;\n          }\n\t\t    }\n      }\n    }\n  }\n  g_qeglobals.d_select_mode = sel_curvepoint;\n  //--g_nSelectedPatch = n;\n}\n\n\n\n/*\n==================\nPatch_Deselect\n==================\n*/\n//FIXME: need all sorts of asserts throughout a lot of this crap\nvoid Patch_Deselect()\n{\n  //--g_nSelectedPatch = -1;\n\tclearSelection();\n\n\tfor (brush_t *b = selected_brushes.next ; b != &selected_brushes ; b=b->next)\n  {\n    if (b->patchBrush)\n    {\n      b->pPatch->bSelected = false;\n    }\n  }\n\n  //for (int i = 0; i < numPatchMeshes; i++)\n  //  patchMeshes[i].bSelected = false;\n\n  if (g_bPatchBendMode)\n    Patch_BendToggle();\n  if (g_bPatchInsertMode)\n    Patch_InsDelToggle();\n}\n\n\n/*\n==================\nPatch_Select\n==================\n*/\nvoid Patch_Select(patchMesh_t *p)\n{\n  // maintained for point manip.. which i need to fix as this \n  // is pf error prone\n  //--g_nSelectedPatch = n;\n  p->bSelected = true;\n}\n\n\n/*\n==================\nPatch_Deselect\n==================\n*/\nvoid Patch_Deselect(patchMesh_t *p)\n{\n  p->bSelected = false;\n}\n\n\n/*\n==================\nPatch_Delete\n==================\n*/\nvoid Patch_Delete(patchMesh_t *p)\n{\n  p->pSymbiot->pPatch = NULL;\n  p->pSymbiot->patchBrush = false;\n  if (g_qeglobals.bSurfacePropertiesPlugin)\n  {\n#ifdef _DEBUG\n\t\tif (!p->pData)\n\t\t\tSys_Printf(\"WARNING: unexpected IPluginTexdef* is NULL in Patch_Delete\\n\");\n\t\telse\n#endif\n\t\t{\n\t\t\tGETPLUGINTEXDEF(p)->DecRef();\n\t\t\tp->pData = NULL;\n\t\t}\n  }\n  free(p);\n  p = NULL;\n\n  // bump the array down\n  //for (int i = n; i < numPatchMeshes; i++)\n  //{\n  //  patchMeshes[i].pSymbiot->nPatchID--;\n  //  patchMeshes[i] = patchMeshes[i+1];\n  //}\n  //numPatchMeshes--;\n  UpdatePatchInspector();\n}\n\n\n/*\n==================\nPatch_Scale\n==================\n*/\nvoid Patch_Scale(patchMesh_t *p, const vec3_t vOrigin, const vec3_t vAmt, bool bRebuild)\n{\n\n  for (int w = 0; w < p->width; w++)\n  {\n    for (int h = 0; h < p->height; h++)\n    {\n      if (g_qeglobals.d_select_mode == sel_curvepoint && PointInMoveList(p->ctrl[w][h].xyz) == -1)\n        continue;\n\t\t\tfor (int i=0 ; i<3 ; i++)\n\t\t\t{\n        p->ctrl[w][h].xyz[i] -= vOrigin[i];\n        p->ctrl[w][h].xyz[i] *= vAmt[i];\n        p->ctrl[w][h].xyz[i] += vOrigin[i];\n      }\n    }\n  }\n  if (bRebuild)\n  {\n    vec3_t vMin, vMax;\n    Patch_CalcBounds(p, vMin, vMax);\n    Brush_RebuildBrush(p->pSymbiot, vMin, vMax);\n  }\n  UpdatePatchInspector();\n}\n\n\n/*\n==================\nPatch_Cleanup\n==================\n*/\nvoid Patch_Cleanup()\n{\n  //--g_nSelectedPatch = -1;\n  //numPatchMeshes = 0;\n}\n\n\n\n/*\n==================\nPatch_SetView\n==================\n*/\nvoid Patch_SetView(int n)\n{\n  g_bSameView = (n == g_nPatchClickedView);\n  g_nPatchClickedView = n;\n}\n\n\n/*\n==================\nPatch_SetTexture\n==================\n*/\n// FIXME: need array validation throughout\nvoid Patch_SetTexture(patchMesh_t *p, texdef_t *tex_def, IPluginTexdef* pPlugTexdef)\n{\n  p->d_texture = Texture_ForName(tex_def->name);\n  if (g_qeglobals.bSurfacePropertiesPlugin)\n  {\n#ifdef _DEBUG\n\t  if (!p->pData)\n\t\t  Sys_Printf(\"WARNING: unexpected p->pData is NULL in Patch_SetTexture\\n\");\n\t  else\n#endif\n\t\t  GETPLUGINTEXDEF(p)->DecRef();\n\t  if (pPlugTexdef)\n\t  {\n\t\tp->pData = pPlugTexdef->Copy();\n\t\tGETPLUGINTEXDEF(p)->Hook(p);\n\t  }\n\t  else\n\t  {\n\t\t  g_SurfaceTable.m_pfnPatchAlloc( p );\n\t\t  GETPLUGINTEXDEF(p)->SetDefaultTexdef();\n\t  }\t  \n  }\n  UpdatePatchInspector();\n}\n\n\n/*\n==================\nPatch_DragScale\n==================\n*/\nbool Patch_DragScale(patchMesh_t *p, vec3_t vAmt, vec3_t vMove)\n{\n  vec3_t vMin, vMax, vScale, vTemp, vMid;\n  int i;\n\n  Patch_CalcBounds(p, vMin, vMax);\n\n  VectorSubtract(vMax, vMin, vTemp);\n\n  // if we are scaling in the same dimension the patch has no depth\n  for (i = 0; i < 3; i ++)\n  {\n    if (vTemp[i] == 0 && vMove[i] != 0)\n    {\n      //Patch_Move(n, vMove, true);\n      return false;\n    }\n  }\n  \n  for (i=0 ; i<3 ; i++)\n    vMid[i] = (vMin[i] + ((vMax[i] - vMin[i]) / 2));\n\n  for (i = 0; i < 3; i++)\n  {\n    if (vAmt[i] != 0)\n    {\n      vScale[i] = 1.0 + vAmt[i] / vTemp[i];\n    }\n    else\n    {\n      vScale[i] = 1.0;\n    }\n  }\n\n  Patch_Scale(p, vMid, vScale, false);\n\n  VectorSubtract(vMax, vMin, vTemp);\n\n  Patch_CalcBounds(p, vMin, vMax);\n  \n  VectorSubtract(vMax, vMin, vMid);\n\n  VectorSubtract(vMid, vTemp, vTemp);\n\n  VectorScale(vTemp, 0.5, vTemp);\n\n  // abs of both should always be equal\n  if (!VectorCompare(vMove, vAmt))\n  {\n    for (i = 0; i < 3; i++)\n    {\n      if (vMove[i] != vAmt[i])\n        vTemp[i] = -(vTemp[i]);\n    }\n  }\n\n  Patch_Move(p, vTemp);\n  return true;\n}\n\n\n/*\n==================\nPatch_AddRow\n==================\n*/\nvoid Patch_AddRow(patchMesh_t *p)\n{\n  vec3_t vMin, vMax, vTemp;\n  int i, j;\n\n\n  if (p->height+2 < MAX_PATCH_HEIGHT)\n  {\n    Patch_CalcBounds(p, vMin, vMax);\n    VectorSubtract(vMax, vMin, vTemp);\n    for (i = 0; i < 3; i++)\n    {\n      vTemp[i] /= p->height + 2;\n    }\n\n    for (j = 0; j < p->width; j++)\n    {\n      VectorCopy(p->ctrl[j][p->height].xyz, p->ctrl[j][p->height+1].xyz);\n      VectorCopy(p->ctrl[j][p->height].xyz, p->ctrl[j][p->height+2].xyz);\n      p->height += 2;\n      i = 1;\n      while (i < p->height)\n      {\n        VectorAdd(p->ctrl[j][i].xyz, vTemp, p->ctrl[j][i].xyz);\n        i++;\n      }\n    }\n    \n    Patch_CalcBounds(p, vMin, vMax);\n    Brush_RebuildBrush(p->pSymbiot, vMin, vMax);\n  }\n  UpdatePatchInspector();\n}\n\n/*\n==================\nPatch_InsertColumn\n==================\n*/\nvoid Patch_InsertColumn(patchMesh_t *p, bool bAdd)\n{\n  int h, w, i, j;\n  vec3_t vTemp;\n  \n  if (p->width + 2 >= MAX_PATCH_WIDTH)\n    return;\n\n  if (bAdd) // add column?\n  {\n    for (h = 0; h < p->height; h++)\n    {\n      j = p->width-1;\n      VectorSubtract(p->ctrl[j][h].xyz, p->ctrl[j-1][h].xyz, vTemp);\n      for (i = 0; i < 3; i++)\n        vTemp[i] /= 3;\n\n      memcpy(&p->ctrl[j+2][h],&p->ctrl[j][h], sizeof(drawVert_t));\n      memcpy(&p->ctrl[j][h],&p->ctrl[j-1][h], sizeof(drawVert_t));\n\n      VectorAdd(p->ctrl[j][h].xyz, vTemp, p->ctrl[j][h].xyz);\n      memcpy(&p->ctrl[j+1][h], &p->ctrl[j][h], sizeof(drawVert_t));\n      VectorAdd(p->ctrl[j+1][h].xyz, vTemp, p->ctrl[j+1][h].xyz);\n    }\n  }\n  else\n  {\n    for (h = 0; h < p->height; h++)\n    {\n      w = p->width-1;\n      while (w >= 0)\n      {\n        memcpy(&p->ctrl[w+2][h],&p->ctrl[w][h], sizeof(drawVert_t));\n        w--;\n      }\n      VectorSubtract(p->ctrl[1][h].xyz, p->ctrl[0][h].xyz, vTemp);\n      for (i = 0; i < 3; i++)\n        vTemp[i] /= 3;\n      VectorCopy(p->ctrl[0][h].xyz, p->ctrl[1][h].xyz);\n      VectorAdd(p->ctrl[1][h].xyz, vTemp, p->ctrl[1][h].xyz);\n      VectorCopy(p->ctrl[1][h].xyz, p->ctrl[2][h].xyz);\n      VectorAdd(p->ctrl[2][h].xyz, vTemp, p->ctrl[2][h].xyz);\n    }\n  }\n  p->width += 2;\n  UpdatePatchInspector();\n}\n\n\n/*\n==================\nPatch_InsertRow\n==================\n*/\nvoid Patch_InsertRow(patchMesh_t *p, bool bAdd)\n{\n  int h, w, i, j;\n  vec3_t vTemp;\n  \n  if (p->height + 2 >= MAX_PATCH_HEIGHT)\n    return;\n\n  if (bAdd) // add column?\n  {\n    for (w = 0; w < p->width; w++)\n    {\n      j = p->height-1;\n      VectorSubtract(p->ctrl[w][j].xyz, p->ctrl[w][j-1].xyz, vTemp);\n      for (i = 0; i < 3; i++)\n        vTemp[i] /= 3;\n\n      memcpy(&p->ctrl[w][j+2],&p->ctrl[w][j], sizeof(drawVert_t));\n      memcpy(&p->ctrl[w][j],&p->ctrl[w][j-1], sizeof(drawVert_t));\n\n      VectorAdd(p->ctrl[w][j].xyz, vTemp, p->ctrl[w][j].xyz);\n      memcpy(&p->ctrl[w][j+1], &p->ctrl[w][j], sizeof(drawVert_t));\n      VectorAdd(p->ctrl[w][j+1].xyz, vTemp, p->ctrl[w][j+1].xyz);\n    }\n  }\n  else\n  {\n    for (w = 0; w < p->width; w++)\n    {\n      h = p->height-1;\n      while (h >= 0)\n      {\n        memcpy(&p->ctrl[w][h+2],&p->ctrl[w][h], sizeof(drawVert_t));\n        h--;\n      }\n      VectorSubtract(p->ctrl[w][1].xyz, p->ctrl[w][0].xyz, vTemp);\n      for (i = 0; i < 3; i++)\n        vTemp[i] /= 3;\n      VectorCopy(p->ctrl[w][0].xyz, p->ctrl[w][1].xyz);\n      VectorAdd(p->ctrl[w][1].xyz, vTemp, p->ctrl[w][1].xyz);\n      VectorCopy(p->ctrl[w][1].xyz, p->ctrl[w][2].xyz);\n      VectorAdd(p->ctrl[w][2].xyz, vTemp, p->ctrl[w][2].xyz);\n    }\n  }\n  p->height += 2;\n  UpdatePatchInspector();\n}\n\n\n/*\n==================\nPatch_RemoveRow\n==================\n*/\nvoid Patch_RemoveRow(patchMesh_t *p, bool bFirst)\n{\n  \n  if (p->height <= MIN_PATCH_HEIGHT)\n    return;\n\n  p->height -= 2;\n\n  if (bFirst)\n  {\n    for (int w = 0; w < p->width; w++)\n    {\n      for (int h = 0; h < p->height; h++)\n      {\n        memcpy(&p->ctrl[w][h], &p->ctrl[w][h+2], sizeof(drawVert_t));\n      }\n    }\n  }\n  UpdatePatchInspector();\n}\n\n\n/*\n==================\nPatch_RemoveColumn\n==================\n*/\nvoid Patch_RemoveColumn(patchMesh_t *p, bool bFirst)\n{\n  \n  if (p->width <= MIN_PATCH_WIDTH)\n    return;\n\n  p->width -= 2;\n\n  if (bFirst)\n  {\n    for (int h = 0; h < p->height; h++)\n    {\n      for (int w = 0; w < p->width; w++)\n      {\n        memcpy(&p->ctrl[w][h], &p->ctrl[w+2][h], sizeof(drawVert_t));\n      }\n    }\n  }\n  UpdatePatchInspector();\n}\n\n\n/*\n==================\nPatch_AdjustColumns\n==================\n*/\nvoid Patch_AdjustColumns(patchMesh_t *p, int nCols)\n{\n  vec3_t vTemp, vTemp2;\n  int i, w, h;\n\n  if (nCols & 0x01 || p->width + nCols < 3 || p->width + nCols > MAX_PATCH_WIDTH)\n    return;\n\n  // add in column adjustment\n  p->width += nCols;\n\n  for (h = 0; h < p->height; h++)\n  {\n    // for each column, we need to evenly disperse p->width number \n    // of points across the old bounds\n    \n    // calc total distance to interpolate \n    VectorSubtract(p->ctrl[p->width - 1 - nCols][h].xyz, p->ctrl[0][h].xyz, vTemp);\n\n    // amount per cycle\n    for (i = 0; i < 3; i ++)\n    {\n      vTemp2[i] = vTemp[i] / (p->width - 1);\n    }\n\n    // move along\n    for (w = 0; w < p->width-1; w++)\n    {\n      VectorAdd(p->ctrl[w][h].xyz, vTemp2, p->ctrl[w+1][h].xyz);\n    }\n\n  }\n\tfor ( w = 0 ; w < p->width ; w++ ) \n  {\n\t\tfor ( h = 0 ; h < p->height ; h++ ) \n    {\n\t\t\tp->ctrl[w][h].st[0] = 4 * (float)w / (p->width - 1);\n\t\t\tp->ctrl[w][h].st[1] = 4 * (float)h / (p->height - 1);\n\t\t}\n\t}\n  UpdatePatchInspector();\n}\n\n\n/*\n==================\nPatch_AdjustRows\n==================\n*/\nvoid Patch_AdjustRows(patchMesh_t *p, int nRows)\n{\n  vec3_t vTemp, vTemp2;\n  int i, w, h;\n\n  if (nRows & 0x01 || p->height + nRows < 3 || p->height + nRows > MAX_PATCH_HEIGHT)\n    return;\n\n  // add in column adjustment\n  p->height += nRows;\n\n  for (w = 0; w < p->width; w++)\n  {\n    // for each row, we need to evenly disperse p->height number \n    // of points across the old bounds\n\n    // calc total distance to interpolate \n    VectorSubtract(p->ctrl[w][p->height - 1 - nRows].xyz, p->ctrl[w][0].xyz, vTemp);\n    \n    //vTemp[0] = vTemp[1] = vTemp[2] = 0;\n    //for (h = 0; h < p->height - nRows; h ++)\n    //{\n    //  VectorAdd(vTemp, p->ctrl[w][h], vTemp);\n    //}\n\n    // amount per cycle\n    for (i = 0; i < 3; i ++)\n    {\n      vTemp2[i] = vTemp[i] / (p->height - 1);\n    }\n\n    // move along\n    for (h = 0; h < p->height-1; h++)\n    {\n      VectorAdd(p->ctrl[w][h].xyz, vTemp2, p->ctrl[w][h+1].xyz);\n    }\n\n  }\n\tfor ( w = 0 ; w < p->width ; w++ ) \n  {\n\t\tfor ( h = 0 ; h < p->height ; h++ ) \n    {\n\t\t\tp->ctrl[w][h].st[0] = 4 * (float)w / (p->width - 1);\n\t\t\tp->ctrl[w][h].st[1] = 4 * (float)h / (p->height - 1);\n\t\t}\n\t}\n  UpdatePatchInspector();\n}\n\n\nvoid Patch_DisperseRows()\n{\n  vec3_t vTemp, vTemp2;\n  int i, w, h;\n\n\n\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n      patchMesh_t *p = pb->pPatch;\n      Patch_Rebuild(p);\n      for (w = 0; w < p->width; w++)\n      {\n        // for each row, we need to evenly disperse p->height number \n        // of points across the old bounds\n\n        // calc total distance to interpolate \n        VectorSubtract(p->ctrl[w][p->height - 1].xyz, p->ctrl[w][0].xyz, vTemp);\n    \n        //vTemp[0] = vTemp[1] = vTemp[2] = 0;\n        //for (h = 0; h < p->height - nRows; h ++)\n        //{\n        //  VectorAdd(vTemp, p->ctrl[w][h], vTemp);\n        //}\n\n        // amount per cycle\n        for (i = 0; i < 3; i ++)\n        {\n          vTemp2[i] = vTemp[i] / (p->height - 1);\n        }\n\n        // move along\n        for (h = 0; h < p->height-1; h++)\n        {\n          VectorAdd(p->ctrl[w][h].xyz, vTemp2, p->ctrl[w][h+1].xyz);\n        }\n        Patch_Naturalize(p);\n\n      }\n    }\n  }\n  UpdatePatchInspector();\n\n}\n\n/*\n==================\nPatch_AdjustColumns\n==================\n*/\nvoid Patch_DisperseColumns()\n{\n  vec3_t vTemp, vTemp2;\n  int i, w, h;\n\n\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n      patchMesh_t *p = pb->pPatch;\n      Patch_Rebuild(p);\n\n      for (h = 0; h < p->height; h++)\n      {\n        // for each column, we need to evenly disperse p->width number \n        // of points across the old bounds\n    \n        // calc total distance to interpolate \n        VectorSubtract(p->ctrl[p->width - 1][h].xyz, p->ctrl[0][h].xyz, vTemp);\n\n        // amount per cycle\n        for (i = 0; i < 3; i ++)\n        {\n          vTemp2[i] = vTemp[i] / (p->width - 1);\n        }\n\n        // move along\n        for (w = 0; w < p->width-1; w++)\n        {\n          VectorAdd(p->ctrl[w][h].xyz, vTemp2, p->ctrl[w+1][h].xyz);\n        }\n\n      }\n      Patch_Naturalize(p);\n    }\n  }\n  UpdatePatchInspector();\n}\n\n\n\n/*\n==================\nPatch_AdjustSelected\n==================\n*/\nvoid Patch_AdjustSelected(bool bInsert, bool bColumn, bool bFlag)\n{\n  bool bUpdate = false;\n\tfor (brush_t* pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n      if (bInsert)\n      {\n        if (bColumn)\n        {\n          Patch_InsertColumn(pb->pPatch, bFlag);\n        }\n        else\n        {\n          Patch_InsertRow(pb->pPatch, bFlag);\n        }\n      }\n      else\n      {\n        if (bColumn)\n        {\n          Patch_RemoveColumn(pb->pPatch, bFlag);\n        }\n        else\n        {\n          Patch_RemoveRow(pb->pPatch, bFlag);\n        }\n      }\n      bUpdate = true;\n      vec3_t vMin, vMax;\n      patchMesh_t *p = pb->pPatch;\n      Patch_CalcBounds(p, vMin, vMax);\n      Brush_RebuildBrush(p->pSymbiot, vMin, vMax);\n    }\n  }\n  if (bUpdate)\n  {\n    Sys_UpdateWindows(W_ALL);\n  }\n}\n\n\n/*\n==================\nPatch_AdjustSelectedRowCols\n==================\n*/\nvoid Patch_AdjustSelectedRowCols(int nRows, int nCols)\n{\n\tfor (brush_t* pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n      Patch_InsertColumn(pb->pPatch, false);\n      if (nRows != 0)\n      {\n        Patch_AdjustRows(pb->pPatch, nRows);\n      }\n      \n      if (nCols != 0)\n      {\n        Patch_AdjustColumns(pb->pPatch, nCols);\n      }\n\t\t}\n  }\n  UpdatePatchInspector();\n}\n\n\n\nvoid Parse1DMatrix(int x, float* p)\n{\n  GetToken(true); // (\n  for (int i = 0; i < x; i++)\n  {\n    GetToken(false);\n    p[i] = atof(token);\n  }\n  GetToken(true); // )\n}\n\nvoid Parse2DMatrix(int y, int x, float* p)\n{\n  GetToken(true); // (\n  for (int i = 0; i < y; i++)\n  {\n    Parse1DMatrix(x, p + i*x);\n  }\n  GetToken(true); // )\n}\n\nvoid Parse3DMatrix(int z, int y, int x, float* p)\n{\n  GetToken(true); // (\n  for (int i = 0; i < z; i++)\n  {\n    Parse2DMatrix(y, x, p + i*(x*MAX_PATCH_HEIGHT));\n  }\n  GetToken(true); // )\n}\n\n// parses a patch\nbrush_t* Patch_Parse(bool bOld)\n{\n    //--if (bOld)\n    //--{\n    //--  return Patch_ParseOld();\n    //--}\n\n  GetToken(true);\n    \n  if (strcmp(token, \"{\"))\n    return NULL;\n\n\tpatchMesh_t *pm = MakeNewPatch();\n\n\tif (g_qeglobals.bSurfacePropertiesPlugin)\n\t{\n\t\tGETPLUGINTEXDEF(pm)->ParsePatchTexdef();\n\t}\n\telse\n\t{\n\t\t// texture def\n\t\tGetToken(true);\n\t\t\n\t\t// band-aid \n\t\tif (strcmp(token, \"(\"))\n\t\t{\n\t\t\tpm->d_texture = Texture_ForName(token);\n\t\t\tGetToken(true);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tpm->d_texture = notexture;\n\t\t\tSys_Printf(\"Warning: Patch read with no texture, using notexture... \\n\");\n\t\t}               \n\t\t\n\t\tif (strcmp(token, \"(\"))\n\t\t\treturn NULL;\n\t\t\n\t\t// width, height, flags (currently only negative)\n\t\tGetToken(false);\n\t\tpm->width = atoi(token);\n\t\t\n\t\tGetToken(false);\n\t\tpm->height = atoi(token);\n\t\t\n\t\tGetToken(false);\n\t\tpm->contents = atoi(token);\n\t\t\n\t\tGetToken(false);\n\t\tpm->flags = atoi(token);\n\t\t\n\t\tGetToken(false);\n\t\tpm->value = atoi(token);\n\t\t\n\t\tif (!bOld)\n\t\t{\n\t\t\tGetToken(false);\n\t\t\tpm->type = atoi(token);\n\t\t}\n\t\t\n\t\tGetToken(false);\n\t\tif (strcmp(token, \")\"))\n\t\t\treturn NULL;\n\t\t\n\t}\n\n\n\n  float ctrl[MAX_PATCH_WIDTH][MAX_PATCH_HEIGHT][5];\n  Parse3DMatrix(pm->width, pm->height, 5, reinterpret_cast<float*>(&ctrl));\n\n  int w, h;\n\n  for (w = 0; w < pm->width; w++)\n  {\n    for (h = 0; h < pm->height; h++)\n    {\n      pm->ctrl[w][h].xyz[0] = ctrl[w][h][0];  \n      pm->ctrl[w][h].xyz[1] = ctrl[w][h][1];  \n      pm->ctrl[w][h].xyz[2] = ctrl[w][h][2];  \n      pm->ctrl[w][h].st[0] = ctrl[w][h][3]; \n      pm->ctrl[w][h].st[1] = ctrl[w][h][4];  \n    }\n  }\n\n  GetToken(true);\n\n\tif (g_qeglobals.m_bBrushPrimitMode)\n  {\n    // we are in brush primit mode, but maybe it's a classic patch that needs converting, test \"}\"\n    if (strcmp(token, \"}\") && strcmp (token, \"(\") )\n\t  {\n\t\t  epair_t *ep = ParseEpair();\n\t\t  ep->next = pm->epairs;\n\t\t  pm->epairs = ep;\n      GetToken(true);\n\t  }\n  }\n\n  if (strcmp(token, \"}\"))\n    return NULL;\n\n  brush_t *b = AddBrushForPatch(pm, false);\n\n  return b;\n}\n\n\n/*\n==================\nPatch_Write \n==================\n*/\nvoid Patch_Write (patchMesh_t *p, CMemFile *file)\n{\n\tif (g_qeglobals.bSurfacePropertiesPlugin)\n\t{\n\t\tSys_Printf(\"WARNING: Patch_Write to a CMemFile and Surface Properties plugin not done\\n\");\n\t}\n  //--MemFile_fprintf(file, \" {\\n  patchDef3\\n  {\\n\");\n  MemFile_fprintf(file, \" {\\n  patchDef2\\n  {\\n\");\n\n  MemFile_fprintf(file, \"   %s\\n\",p->d_texture->name);\n  //--MemFile_fprintf(file, \"   ( %i %i %i %i %i %i ) \\n\", p->width, p->height, p->contents, p->flags, p->value, p->type);\n  MemFile_fprintf(file, \"   ( %i %i %i %i %i ) \\n\", p->width, p->height, p->contents, p->flags, p->value);\n\n\n\tfloat\t\tctrl[MAX_PATCH_WIDTH][MAX_PATCH_HEIGHT][5];\n\n  int w, h;\n  for (w = 0; w < p->width; w++)\n  {\n    for (h = 0; h < p->height; h++)\n    {\n      ctrl[w][h][0] = p->ctrl[w][h].xyz[0];\n      ctrl[w][h][1] = p->ctrl[w][h].xyz[1];\n      ctrl[w][h][2] = p->ctrl[w][h].xyz[2];\n      ctrl[w][h][3] = p->ctrl[w][h].st[0];\n      ctrl[w][h][4] = p->ctrl[w][h].st[1];\n    }\n  }\n\n  _Write3DMatrix(file, p->width, p->height, 5, reinterpret_cast<float*>(&ctrl));\n\n\tif (g_qeglobals.m_bBrushPrimitMode)\n  {\n\t  if (p->epairs)\n    {\n\t\t\tfor (epair_t *ep = p->epairs ; ep ; ep=ep->next)\n      {\n\t\t\t\tMemFile_fprintf (file, \"\\\"%s\\\" \\\"%s\\\"\\n\", ep->key, ep->value);\n      }\n    }\n  }\n\n  MemFile_fprintf(file, \"  }\\n }\\n\");\n}\n\nvoid Patch_Write (patchMesh_t *p, FILE *file)\n{\n\tfprintf(file, \" {\\n  patchDef2\\n  {\\n\");\n\tif (g_qeglobals.bSurfacePropertiesPlugin)\n\t{\n#ifdef _DEBUG\n\t\tif ( !p->pData )\n\t\t\tSys_Printf(\"ERROR: no IPluginTexdef in patch\\n\");\n#endif\n\t\tg_File = file;\n\t\tGETPLUGINTEXDEF(p)->WritePatchTexdef( QERApp_MapPrintf_FILE );\n\t}\n\telse\n\t{\n\t\tfprintf(file, \"   %s\\n\",p->d_texture->name);\n\t\tfprintf(file, \"   ( %i %i %i %i %i ) \\n\", p->width, p->height, p->contents, p->flags, p->value);\n\t}\n\n\tfloat\t\tctrl[MAX_PATCH_WIDTH][MAX_PATCH_HEIGHT][5];\n\n  int w, h;\n  for (w = 0; w < p->width; w++)\n  {\n    for (h = 0; h < p->height; h++)\n    {\n      ctrl[w][h][0] = p->ctrl[w][h].xyz[0];\n      ctrl[w][h][1] = p->ctrl[w][h].xyz[1];\n      ctrl[w][h][2] = p->ctrl[w][h].xyz[2];\n      ctrl[w][h][3] = p->ctrl[w][h].st[0];\n      ctrl[w][h][4] = p->ctrl[w][h].st[1];\n    }\n  }\n\n  _Write3DMatrix(file, p->width, p->height, 5, reinterpret_cast<float*>(&ctrl));\n\n\tif (g_qeglobals.m_bBrushPrimitMode)\n  {\n\t  if (p->epairs)\n    {\n\t\t\tfor (epair_t *ep = p->epairs ; ep ; ep=ep->next)\n      {\n\t\t\t\tfprintf (file, \"\\\"%s\\\" \\\"%s\\\"\\n\", ep->key, ep->value);\n      }\n    }\n  }\n\n  fprintf(file, \"  }\\n }\\n\");\n}\n\n\n/*\n==================\nPatch_RotateTexture\n==================\n*/\nvoid Patch_RotateTexture(patchMesh_t *p, float fAngle)\n{\n  vec3_t vMin, vMax;\n  Patch_CalcBounds(p, vMin, vMax);\n  p->bDirty = true;\n  for (int w = 0; w < p->width; w++)\n  {\n    for (int h = 0; h < p->height; h++)\n    {\n      if (g_qeglobals.d_select_mode == sel_curvepoint && PointInMoveList(p->ctrl[w][h].xyz) == -1)\n        continue;\n\n      float x = p->ctrl[w][h].st[0];\n      float y = p->ctrl[w][h].st[1];\n      p->ctrl[w][h].st[0] = x * cos(fAngle * Q_PI / 180) - y * sin(fAngle * Q_PI / 180);\n      p->ctrl[w][h].st[1] = y * cos(fAngle * Q_PI / 180) + x * sin(fAngle * Q_PI / 180);\n    }\n  }\n}\n\n\n/*\n==================\nPatch_ScaleTexture\n==================\n*/\nvoid Patch_ScaleTexture(patchMesh_t *p, float fx, float fy, bool bFixup)\n{\n  // FIXME:\n  // this hack turns scales into 1.1 or 0.9\n  if (bFixup)\n  {\n    fx = (fx == 0) ? 1.0 : (fx > 0) ? 0.9 : 1.10;\n    fy = (fy == 0) ? 1.0 : (fy > 0) ? 0.9 : 1.10;\n  }\n  else\n  {\n    if (fx == 0)\n      fx = 1.0;\n    if (fy == 0)\n      fy = 1.0;\n  }\n  \n  for (int w = 0; w < p->width; w++)\n  {\n    for (int h = 0; h < p->height; h++)\n    {\n      if (g_qeglobals.d_select_mode == sel_curvepoint && PointInMoveList(p->ctrl[w][h].xyz) == -1)\n        continue;\n\n      p->ctrl[w][h].st[0] *= fx;\n      p->ctrl[w][h].st[1] *= fy;\n    }\n  }\n  p->bDirty = true;\n}\n\n\n/*\n==================\nPatch_ShiftTexture\n==================\n*/\nvoid Patch_ShiftTexture(patchMesh_t *p, float fx, float fy)\n{\n  //if (fx)\n  //  fx = (fx > 0) ? 0.1 : -0.1;\n  //if (fy)\n  //  fy = (fy > 0) ? 0.1 : -0.1;\n\n  fx = (abs(fx) >= 1) ? fx / 10 : fx;\n  fy = (abs(fy) >= 1) ? fy / 10 : fy;\n\n  for (int w = 0; w < p->width; w++)\n  {\n    for (int h = 0; h < p->height; h++)\n    {\n      if (g_qeglobals.d_select_mode == sel_curvepoint && PointInMoveList(p->ctrl[w][h].xyz) == -1)\n        continue;\n\n      p->ctrl[w][h].st[0] += fx;\n      p->ctrl[w][h].st[1] += fy;\n    }\n  }\n  p->bDirty = true;\n}\n\nvoid patchInvert(patchMesh_t *p)\n{\n  drawVert_t vertTemp;\n  p->bDirty = true;\n\tfor ( int i = 0 ; i < p->width ; i++ ) \n  {\n    for (int j = 0; j < p->height / 2; j++)\n    {\n      memcpy(&vertTemp, &p->ctrl[i][p->height - 1- j], sizeof (drawVert_t));\n      memcpy(&p->ctrl[i][p->height - 1 - j], &p->ctrl[i][j], sizeof(drawVert_t));\n      memcpy(&p->ctrl[i][j], &vertTemp, sizeof(drawVert_t));\n\t\t}\n\t}\n}\n\n/*\n==================\nPatch_ToggleInverted\n==================\n*/\nvoid Patch_ToggleInverted()\n{\n  bool bUpdate = false;\n\n\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n      bUpdate = true;\n      patchInvert(pb->pPatch);\n    }\n  }\n\n  if (bUpdate)\n  {\n    Sys_UpdateWindows(W_ALL);\n  }\n  UpdatePatchInspector();\n}\n\n/*\n==================\nPatch_ToggleInverted\n==================\n*/\nvoid Patch_InvertTexture(bool bY)\n{\n  bool bUpdate = false;\n\n  float fTemp[2];\n\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n      bUpdate = true;\n      patchMesh_t *p = pb->pPatch;\n      p->bDirty = true;\n      if (bY)\n      {\n\t      for ( int i = 0 ; i < p->height ; i++ ) \n        {\n          for (int j = 0; j < p->width / 2; j++)\n          {\n            memcpy(fTemp, &p->ctrl[p->width - 1- j][i].st[0], sizeof (float[2]));\n            memcpy(&p->ctrl[p->width - 1- j][i].st[0], &p->ctrl[j][i].st[0], sizeof(float[2]));\n            memcpy(&p->ctrl[j][i].st[0], fTemp, sizeof(float[2]));\n\t\t      }\n\t      }\n      }\n      else\n      {\n\t      for ( int i = 0 ; i < p->width ; i++ ) \n        {\n          for (int j = 0; j < p->height / 2; j++)\n          {\n            memcpy(fTemp, &p->ctrl[i][p->height - 1- j].st[0], sizeof (float[2]));\n            memcpy(&p->ctrl[i][p->height - 1 - j].st[0], &p->ctrl[i][j].st[0], sizeof(float[2]));\n            memcpy(&p->ctrl[i][j].st[0], fTemp, sizeof(float[2]));\n\t\t      }\n\t      }\n      }\n    }\n  }\n\n  if (bUpdate)\n  {\n    Sys_UpdateWindows(W_ALL);\n  }\n  UpdatePatchInspector();\n}\n\n\n\n\n/*\n==================\nPatch_Save\n==================\n Saves patch ctrl info (originally to deal with a \n cancel in the surface dialog\n*/\nvoid Patch_Save(patchMesh_t *p)\n{\n  patchSave.width = p->width;\n  patchSave.height = p->height;\n  memcpy(patchSave.ctrl, p->ctrl, sizeof(p->ctrl));\n}\n\n\n/*\n==================\nPatch_Restore\n==================\n*/\nvoid Patch_Restore(patchMesh_t *p)\n{\n  p->width = patchSave.width;\n  p->height = patchSave.height;\n  memcpy(p->ctrl, patchSave.ctrl, sizeof(p->ctrl));\n}\n\nvoid Patch_ResetTexturing(float fx, float fy)\n{\n\tfor (brush_t* pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n      patchMesh_t *p = pb->pPatch;\n      p->bDirty = true;\n\t    for ( int i = 0 ; i < p->width ; i++ ) \n      {\n\t\t    for ( int j = 0 ; j < p->height ; j++ ) \n        {\n\t\t\t    p->ctrl[i][j].st[0] = fx * (float)i / (p->width - 1);\n\t\t\t    p->ctrl[i][j].st[1] = fy * (float)j / (p->height - 1);\n\t\t    }\n\t    }\n    }\n  }\n}\n\n\nvoid Patch_FitTexturing()\n{\n\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n      patchMesh_t *p = pb->pPatch;\n      p->bDirty = true;\n\t    for ( int i = 0 ; i < p->width ; i++ ) \n      {\n\t\t    for ( int j = 0 ; j < p->height ; j++ ) \n        {\n\t\t\t    p->ctrl[i][j].st[0] = 1 * (float)i / (p->width - 1);\n\t\t\t    p->ctrl[i][j].st[1] = 1 * (float)j / (p->height - 1);\n\t\t    }\n\t    }\n    }\n  }\n}\n\n\nvoid Patch_SetTextureInfo(texdef_t *pt)\n{\n\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n      if (pt->rotate)\n        Patch_RotateTexture(pb->pPatch, pt->rotate);\n\n      if (pt->shift[0] || pt->shift[1])\n        Patch_ShiftTexture(pb->pPatch, pt->shift[0], pt->shift[1]);\n\n      if (pt->scale[0] || pt->scale[1])\n        Patch_ScaleTexture(pb->pPatch, pt->scale[0], pt->scale[1], false);\n\n      patchMesh_t *p = pb->pPatch;\n      p->contents = pt->contents;\n      p->flags = pt->flags;\n      p->value = pt->value;\n    }\n  }\n}\n\nbool WINAPI OnlyPatchesSelected()\n{\n  if (g_ptrSelectedFaces.GetSize() > 0 || selected_brushes.next == &selected_brushes)\n    return false;\n\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (!pb->patchBrush)\n    {\n      return false;\n    }\n  }\n  return true;\n}\n\nbool WINAPI AnyPatchesSelected()\n{\n  if (g_ptrSelectedFaces.GetSize() > 0  || selected_brushes.next == &selected_brushes)\n    return false;\n\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n      return true;\n    }\n  }\n  return false;\n}\n\npatchMesh_t* SinglePatchSelected()\n{\n\tif (selected_brushes.next->patchBrush)\n  {\n    return selected_brushes.next->pPatch;\n  }\n  return NULL;\n}\n\nvoid Patch_BendToggle()\n{\n  if (g_bPatchBendMode)\n  {\n    g_bPatchBendMode = false;\n    HideInfoDialog();\n    g_pParentWnd->UpdatePatchToolbarButtons() ;\n    return;\n  }\n\n\tbrush_t* b = selected_brushes.next;\n\n  if (!QE_SingleBrush() || !b->patchBrush)\n  {\n    Sys_Printf(\"Must bend a single patch\");\n\t\treturn;\n  }\n\n  Patch_Save(b->pPatch);\n\tg_bPatchBendMode = true;\n  g_nPatchBendState = BEND_SELECT_ROTATION;\n  g_bPatchAxisOnRow = true;\n  g_nPatchAxisIndex = 1;\n  ShowInfoDialog(g_pBendStateMsg[BEND_SELECT_ROTATION]);\n}\n\nvoid Patch_BendHandleTAB()\n{\n  if (!g_bPatchBendMode)\n  {\n    return;\n  }\n\n\tbrush_t* b = selected_brushes.next;\n  if (!QE_SingleBrush() || !b->patchBrush)\n  {\n    Patch_BendToggle();\n    Sys_Printf(\"No patch to bend!\");\n\t\treturn;\n  }\n\n  patchMesh_t *p = b->pPatch;\n\n  bool bShift = (GetKeyState(VK_SHIFT) & 0x8000);\n\n  if (g_nPatchBendState == BEND_SELECT_ROTATION)\n  {\n    // only able to deal with odd numbered rows/cols\n    g_nPatchAxisIndex += (bShift) ? -2 : 2;\n    if (g_bPatchAxisOnRow)\n    {\n      if ((bShift) ? g_nPatchAxisIndex <= 0 : g_nPatchAxisIndex >= p->height)\n      {\n        g_bPatchAxisOnRow = false;\n        g_nPatchAxisIndex = (bShift) ? p->width-1 : 1;\n      }\n    }\n    else\n    {\n      if ((bShift) ? g_nPatchAxisIndex <= 0 : g_nPatchAxisIndex >= p->width)\n      {\n        g_bPatchAxisOnRow = true;\n        g_nPatchAxisIndex = (bShift) ? p->height-1 : 1;\n      }\n    }\n  }\n  else\n  if (g_nPatchBendState == BEND_SELECT_ORIGIN)\n  {\n    g_nBendOriginIndex += (bShift) ? -1 : 1;\n    if (g_bPatchAxisOnRow)\n    {\n      if (bShift)\n      {\n        if (g_nBendOriginIndex < 0)\n          g_nBendOriginIndex = p->width-1;\n      }\n      else\n      {\n        if (g_nBendOriginIndex > p->width-1)\n          g_nBendOriginIndex = 0;\n      }\n      VectorCopy(p->ctrl[g_nBendOriginIndex][g_nPatchAxisIndex].xyz, g_vBendOrigin);\n    }\n    else\n    {\n      if (bShift)\n      {\n        if (g_nBendOriginIndex < 0)\n          g_nBendOriginIndex = p->height-1;\n      }\n      else\n      {\n        if (g_nBendOriginIndex > p->height-1)\n          g_nBendOriginIndex = 0;\n      }\n      VectorCopy(p->ctrl[g_nPatchAxisIndex][g_nBendOriginIndex].xyz, g_vBendOrigin);\n    }\n  }\n  else\n  if (g_nPatchBendState == BEND_SELECT_EDGE)\n  {\n    g_bPatchLowerEdge ^= 1;\n  }\n  Sys_UpdateWindows(W_ALL);\n}\n\nvoid Patch_BendHandleENTER()\n{\n  if (!g_bPatchBendMode)\n  {\n    return;\n  }\n\n  if (g_nPatchBendState  < BEND_BENDIT)\n  {\n    g_nPatchBendState++;\n    ShowInfoDialog(g_pBendStateMsg[g_nPatchBendState]);\n    if (g_nPatchBendState == BEND_SELECT_ORIGIN)\n    {\n      g_vBendOrigin[0] = g_vBendOrigin[1] = g_vBendOrigin[2] = 0;\n      g_nBendOriginIndex = 0;\n      Patch_BendHandleTAB();\n    }\n    else\n    if (g_nPatchBendState == BEND_SELECT_EDGE)\n    {\n      g_bPatchLowerEdge = true;\n    }\n    else\n    if (g_nPatchBendState == BEND_BENDIT)\n    {\n      // basically we go into rotation mode, set the axis to the center of the \n    }\n  }\n  else\n  {\n    // done\n    Patch_BendToggle();\n  }\n  Sys_UpdateWindows(W_ALL);\n\n}\n\n\nvoid Patch_BendHandleESC()\n{\n  if (!g_bPatchBendMode)\n  {\n    return;\n  }\n  Patch_BendToggle();\n\tbrush_t* b = selected_brushes.next;\n  if (QE_SingleBrush() && b->patchBrush)\n  {\n    Patch_Restore(b->pPatch);\n  }\n  Sys_UpdateWindows(W_ALL);\n}\n\nvoid Patch_SetBendRotateOrigin(patchMesh_t *p)\n{\n#if 1\n  int nType = g_pParentWnd->ActiveXY()->GetViewType();\n  int nDim3 = (nType == XY) ? 2 : (nType == YZ) ? 0 : 1;\n\n  g_vBendOrigin[nDim3] = 0;\n  VectorCopy(g_vBendOrigin, g_pParentWnd->ActiveXY()->RotateOrigin());\n  return;\n#else\n  int nDim1 = (g_pParentWnd->ActiveXY()->GetViewType() == YZ) ? 1 : 0;\n  int nDim2 = (g_pParentWnd->ActiveXY()->GetViewType() == XY) ? 1 : 2;\n\n  float fxLo, fyLo, fxHi, fyHi;\n  fxLo = fyLo = 9999;\n  fxHi = fyHi = -9999;\n\n  if (g_bPatchAxisOnRow)\n  {\n    for (int i = 0; i < p->width; i++)\n    {\n      if (p->ctrl[i][g_nPatchAxisIndex].xyz[nDim1] < fxLo)\n        fxLo = p->ctrl[i][g_nPatchAxisIndex].xyz[nDim1];\n\n      if (p->ctrl[i][g_nPatchAxisIndex].xyz[nDim1] > fxHi)\n        fxHi = p->ctrl[i][g_nPatchAxisIndex].xyz[nDim1];\n\n      if (p->ctrl[i][g_nPatchAxisIndex].xyz[nDim2] < fyLo)\n        fyLo = p->ctrl[i][g_nPatchAxisIndex].xyz[nDim2];\n\n      if (p->ctrl[i][g_nPatchAxisIndex].xyz[nDim2] > fyHi)\n        fyHi = p->ctrl[i][g_nPatchAxisIndex].xyz[nDim2];\n    }\n  }\n  else\n  {\n    for (int i = 0; i < p->height; i++)\n    {\n      if (p->ctrl[g_nPatchAxisIndex][i].xyz[nDim1] < fxLo)\n        fxLo = p->ctrl[g_nPatchAxisIndex][i].xyz[nDim1];\n\n      if (p->ctrl[g_nPatchAxisIndex][i].xyz[nDim1] > fxHi)\n        fxHi = p->ctrl[g_nPatchAxisIndex][i].xyz[nDim1];\n\n      if (p->ctrl[g_nPatchAxisIndex][i].xyz[nDim2] < fyLo)\n        fyLo = p->ctrl[g_nPatchAxisIndex][i].xyz[nDim2];\n\n      if (p->ctrl[g_nPatchAxisIndex][i].xyz[nDim2] > fyHi)\n        fyHi = p->ctrl[g_nPatchAxisIndex][i].xyz[nDim2];\n    }\n  }\n\n  g_pParentWnd->ActiveXY()->RotateOrigin()[0] = g_pParentWnd->ActiveXY()->RotateOrigin()[1] = g_pParentWnd->ActiveXY()->RotateOrigin()[2] = 0.0;\n  g_pParentWnd->ActiveXY()->RotateOrigin()[nDim1] = (fxLo + fxHi) * 0.5;\n  g_pParentWnd->ActiveXY()->RotateOrigin()[nDim2] = (fyLo + fyHi) * 0.5;\n#endif\n}\n\n// also sets the rotational origin\nvoid Patch_SelectBendAxis()\n{\n\tbrush_t* b = selected_brushes.next;\n  if (!QE_SingleBrush() || !b->patchBrush)\n  {\n    // should not ever happen\n    Patch_BendToggle();\n\t\treturn;\n  }\n\n  patchMesh_t *p = b->pPatch;\n  if (g_bPatchAxisOnRow)\n  {\n    SelectRow(p, g_nPatchAxisIndex, false);\n  }\n  else\n  {\n    SelectColumn(p, g_nPatchAxisIndex, false);\n  }\n\n  //FIXME: this only needs to be set once... \n  Patch_SetBendRotateOrigin(p);\n\n}\n\nvoid Patch_SelectBendNormal()\n{\n\tbrush_t* b = selected_brushes.next;\n  if (!QE_SingleBrush() || !b->patchBrush)\n  {\n    // should not ever happen\n    Patch_BendToggle();\n\t\treturn;\n  }\n\n  patchMesh_t *p = b->pPatch;\n\n  g_qeglobals.d_num_move_points = 0;\n  if (g_bPatchAxisOnRow)\n  {\n    if (g_bPatchLowerEdge)\n    {\n      for (int j = 0; j < g_nPatchAxisIndex; j++)\n        SelectRow(p, j, true);\n    }\n    else\n    {\n      for (int j = p->height-1; j > g_nPatchAxisIndex; j--)\n        SelectRow(p, j, true);\n    }\n  }\n  else\n  {\n    if (g_bPatchLowerEdge)\n    {\n      for (int j = 0; j < g_nPatchAxisIndex; j++)\n        SelectColumn(p, j, true);\n    }\n    else\n    {\n      for (int j = p->width-1; j > g_nPatchAxisIndex; j--)\n        SelectColumn(p, j, true);\n    }\n  }\n  Patch_SetBendRotateOrigin(p);\n}\n\n\n\nvoid Patch_InsDelToggle()\n{\n  if (g_bPatchInsertMode)\n  {\n    g_bPatchInsertMode = false;\n    HideInfoDialog();\n    g_pParentWnd->UpdatePatchToolbarButtons() ;\n    return;\n  }\n\n\tbrush_t* b = selected_brushes.next;\n\n  if (!QE_SingleBrush() || !b->patchBrush)\n  {\n    Sys_Printf(\"Must work with a single patch\");\n\t\treturn;\n  }\n\n  Patch_Save(b->pPatch);\n\tg_bPatchInsertMode = true;\n  g_nPatchInsertState = INSERT_SELECT_EDGE;\n  g_bPatchAxisOnRow = true;\n  g_nPatchAxisIndex = 0;\n  ShowInfoDialog(g_pInsertStateMsg[INSERT_SELECT_EDGE]);\n\n}\n\nvoid Patch_InsDelESC()\n{\n  if (!g_bPatchInsertMode)\n  {\n    return;\n  }\n  Patch_InsDelToggle();\n  Sys_UpdateWindows(W_ALL);\n}\n\n\nvoid Patch_InsDelHandleENTER()\n{\n}\n\nvoid Patch_InsDelHandleTAB()\n{\n  if (!g_bPatchInsertMode)\n  {\n    Patch_InsDelToggle();\n    return;\n  }\n\n\tbrush_t* b = selected_brushes.next;\n  if (!QE_SingleBrush() || !b->patchBrush)\n  {\n    Patch_BendToggle();\n    Sys_Printf(\"No patch to bend!\");\n\t\treturn;\n  }\n\n  patchMesh_t *p = b->pPatch;\n\n  // only able to deal with odd numbered rows/cols\n  g_nPatchAxisIndex += 2;\n  if (g_bPatchAxisOnRow)\n  {\n    if (g_nPatchAxisIndex >= p->height-1)\n    {\n      g_bPatchAxisOnRow = false;\n      g_nPatchAxisIndex = 0;\n    }\n  }\n  else\n  {\n    if (g_nPatchAxisIndex >= p->width-1)\n    {\n      g_bPatchAxisOnRow = true;\n      g_nPatchAxisIndex = 0;\n    }\n  }\n  Sys_UpdateWindows(W_ALL);\n}\n\n\nvoid _Write1DMatrix (FILE *f, int x, float *m) {\n\tint\t\ti;\n\n\tfprintf (f, \"( \");\n\tfor (i = 0 ; i < x ; i++) {\n\t\tif (m[i] == (int)m[i] ) {\n\t\t\tfprintf (f, \"%i \", (int)m[i]);\n\t\t} else {\n\t\t\tfprintf (f, \"%f \", m[i]);\n\t\t}\n\t}\n\tfprintf (f, \")\");\n}\n\nvoid _Write2DMatrix (FILE *f, int y, int x, float *m) {\n\tint\t\ti;\n\n\tfprintf (f, \"( \");\n\tfor (i = 0 ; i < y ; i++) {\n\t\t_Write1DMatrix (f, x, m + i*x);\n\t\tfprintf (f, \" \");\n\t}\n\tfprintf (f, \")\\n\");\n}\n\n\nvoid _Write3DMatrix (FILE *f, int z, int y, int x, float *m) {\n\tint\t\ti;\n\n\tfprintf (f, \"(\\n\");\n\tfor (i = 0 ; i < z ; i++) {\n\t\t_Write2DMatrix (f, y, x, m + i*(x*MAX_PATCH_HEIGHT) );\n\t}\n\tfprintf (f, \")\\n\");\n}\n\nvoid _Write1DMatrix (CMemFile *f, int x, float *m) {\n\tint\t\ti;\n\n\tMemFile_fprintf (f, \"( \");\n\tfor (i = 0 ; i < x ; i++) {\n\t\tif (m[i] == (int)m[i] ) {\n\t\t\tMemFile_fprintf (f, \"%i \", (int)m[i]);\n\t\t} else {\n\t\t\tMemFile_fprintf (f, \"%f \", m[i]);\n\t\t}\n\t}\n\tMemFile_fprintf (f, \")\");\n}\n\nvoid _Write2DMatrix (CMemFile *f, int y, int x, float *m) {\n\tint\t\ti;\n\n\tMemFile_fprintf (f, \"( \");\n\tfor (i = 0 ; i < y ; i++) {\n\t\t_Write1DMatrix (f, x, m + i*x);\n\t\tMemFile_fprintf (f, \" \");\n\t}\n\tMemFile_fprintf (f, \")\\n\");\n}\n\n\nvoid _Write3DMatrix (CMemFile *f, int z, int y, int x, float *m) {\n\tint\t\ti;\n\n\tMemFile_fprintf (f, \"(\\n\");\n\tfor (i = 0 ; i < z ; i++) {\n\t\t_Write2DMatrix (f, y, x, m + i*(x*MAX_PATCH_HEIGHT) );\n\t}\n\tMemFile_fprintf (f, \")\\n\");\n}\n\n\nvoid Patch_NaturalizeSelected(bool bCap, bool bCycleCap)\n{\n\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n      if (bCap)\n        Patch_CapTexture(pb->pPatch, bCycleCap);\n      else\n        Patch_Naturalize(pb->pPatch);\n    }\n  }\n}\n\nbool within(vec3_t vTest, vec3_t vTL, vec3_t vBR)\n{\n  int nDim1 = (g_pParentWnd->ActiveXY()->GetViewType() == YZ) ? 1 : 0;\n  int nDim2 = (g_pParentWnd->ActiveXY()->GetViewType() == XY) ? 1 : 2;\n  if ((vTest[nDim1] > vTL[nDim1] && vTest[nDim1] < vBR[nDim1]) ||\n      (vTest[nDim1] < vTL[nDim1] && vTest[nDim1] > vBR[nDim1]))\n  {\n    if ((vTest[nDim2] > vTL[nDim2] && vTest[nDim2] < vBR[nDim2]) ||\n        (vTest[nDim2] < vTL[nDim2] && vTest[nDim2] > vBR[nDim2]))\n      return true;\n  }\n  return false;\n}\n\n\nvoid Patch_SelectAreaPoints()\n{\n  g_qeglobals.d_num_move_points = 0;\n  g_nPatchClickedView = -1;\n\n\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n      patchMesh_t *p = pb->pPatch;\n      for (int i = 0; i < p->width; i++)\n      {\n        for (int j = 0; j < p->height; j++)\n        {\n          if (within(p->ctrl[i][j].xyz, g_qeglobals.d_vAreaTL, g_qeglobals.d_vAreaBR))\n          {\n            g_qeglobals.d_move_points[g_qeglobals.d_num_move_points++] = p->ctrl[i][j].xyz;\n          }\n        }\n      }\n    }\n  }\n}\n\nconst char* Patch_GetTextureName()\n{\n\tbrush_t* b = selected_brushes.next;\n  if (b->patchBrush)\n  {\n    patchMesh_t *p = b->pPatch;\n    if (p->d_texture->name)\n      return p->d_texture->name;\n  }\n  return \"\";\n}\n\npatchMesh_t* Patch_Duplicate(patchMesh_t *pFrom)\n{\n  patchMesh_t* p = MakeNewPatch();\n  memcpy(p, pFrom , sizeof(patchMesh_t));\n  p->bSelected = false;\n  p->bDirty = true;\n  p->bOverlay = false;\n  p->nListID = -1;\n  // surface plugin\n  if (g_qeglobals.bSurfacePropertiesPlugin)\n  {\n#ifdef _DEBUG\n\tif (!pFrom->pData)\n\t\tSys_Printf(\"WARNING: unexpected pFrom->pData is NULL in Patch_Duplicate\\n\");\n\telse\n#endif\n\t\tp->pData = GETPLUGINTEXDEF(pFrom)->Copy();\n  }\n  AddBrushForPatch(p);\n  return p;\n}\n\n\nvoid Patch_Thicken(int nAmount, bool bSeam)\n{\n  int i, j, h, w;\n  brush_t *b;\n  patchMesh_t *pSeam;\n  vec3_t vMin, vMax;\n  CPtrArray brushes;\n\n  nAmount = -nAmount;\n\n\n\tif (!QE_SingleBrush())\n  {\n    Sys_Printf(\"Cannot thicken multiple patches. Please select a single patch.\\n\");\n\t\treturn;\n  }\n\n\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n      patchMesh_t *p = pb->pPatch;\n      Patch_MeshNormals(p);\n      patchMesh_t *pNew = Patch_Duplicate(p);\n      for (i = 0; i < p->width; i++)\n      {\n        for (j = 0; j < p->height; j++)\n        {\n\t\t      VectorMA (p->ctrl[i][j].xyz, nAmount, p->ctrl[i][j].normal, pNew->ctrl[i][j].xyz);\n        }\n      }\n\n      Patch_Rebuild(pNew);\n      pNew->type |= PATCH_THICK;\n      brushes.Add(pNew->pSymbiot);\n\n      if (bSeam)\n      {\n\n        // FIXME: this should detect if any edges of the patch are closed and act appropriately\n        // \n        if (!(p->type & PATCH_CYLINDER))\n        {\n          b = Patch_GenericMesh(3, p->height, 2, false, true);\n          pSeam = b->pPatch;\n          pSeam->type |= PATCH_SEAM;\n          for (i = 0; i < p->height; i++)\n          {\n            VectorCopy(p->ctrl[0][i].xyz, pSeam->ctrl[0][i].xyz);\n            VectorCopy(pNew->ctrl[0][i].xyz, pSeam->ctrl[2][i].xyz);\n            VectorAdd(pSeam->ctrl[0][i].xyz, pSeam->ctrl[2][i].xyz, pSeam->ctrl[1][i].xyz);\n            VectorScale(pSeam->ctrl[1][i].xyz, 0.5, pSeam->ctrl[1][i].xyz);\n          }\n\n\n          Patch_CalcBounds(pSeam, vMin, vMax);\n          Brush_RebuildBrush(pSeam->pSymbiot, vMin, vMax);\n          //--Patch_CapTexture(pSeam);\n          Patch_Naturalize(pSeam);\n          patchInvert(pSeam);\n          brushes.Add(b);\n\n          w = p->width - 1;\n          b = Patch_GenericMesh(3, p->height, 2, false, true);\n          pSeam = b->pPatch;\n          pSeam->type |= PATCH_SEAM;\n          for (i = 0; i < p->height; i++)\n          {\n            VectorCopy(p->ctrl[w][i].xyz, pSeam->ctrl[0][i].xyz);\n            VectorCopy(pNew->ctrl[w][i].xyz, pSeam->ctrl[2][i].xyz);\n            VectorAdd(pSeam->ctrl[0][i].xyz, pSeam->ctrl[2][i].xyz, pSeam->ctrl[1][i].xyz);\n            VectorScale(pSeam->ctrl[1][i].xyz, 0.5, pSeam->ctrl[1][i].xyz);\n          }\n          Patch_CalcBounds(pSeam, vMin, vMax);\n          Brush_RebuildBrush(pSeam->pSymbiot, vMin, vMax);\n          //--Patch_CapTexture(pSeam);\n          Patch_Naturalize(pSeam);\n          brushes.Add(b);\n        }\n    \n        //--{\n          // otherwise we will add one per end\n          b = Patch_GenericMesh(p->width, 3, 2, false, true);\n          pSeam = b->pPatch;\n          pSeam->type |= PATCH_SEAM;\n          for (i = 0; i < p->width; i++)\n          {\n            VectorCopy(p->ctrl[i][0].xyz, pSeam->ctrl[i][0].xyz);\n            VectorCopy(pNew->ctrl[i][0].xyz, pSeam->ctrl[i][2].xyz);\n            VectorAdd(pSeam->ctrl[i][0].xyz, pSeam->ctrl[i][2].xyz, pSeam->ctrl[i][1].xyz);\n            VectorScale(pSeam->ctrl[i][1].xyz, 0.5, pSeam->ctrl[i][1].xyz);\n          }\n\n\n          Patch_CalcBounds(pSeam, vMin, vMax);\n          Brush_RebuildBrush(pSeam->pSymbiot, vMin, vMax);\n          //--Patch_CapTexture(pSeam);\n          Patch_Naturalize(pSeam);\n          patchInvert(pSeam);\n          brushes.Add(b);\n\n          h = p->height - 1;\n          b = Patch_GenericMesh(p->width, 3, 2, false, true);\n          pSeam = b->pPatch;\n          pSeam->type |= PATCH_SEAM;\n          for (i = 0; i < p->width; i++)\n          {\n            VectorCopy(p->ctrl[i][h].xyz, pSeam->ctrl[i][0].xyz);\n            VectorCopy(pNew->ctrl[i][h].xyz, pSeam->ctrl[i][2].xyz);\n            VectorAdd(pSeam->ctrl[i][0].xyz, pSeam->ctrl[i][2].xyz, pSeam->ctrl[i][1].xyz);\n            VectorScale(pSeam->ctrl[i][1].xyz, 0.5, pSeam->ctrl[i][1].xyz);\n          }\n          Patch_CalcBounds(pSeam, vMin, vMax);\n          Brush_RebuildBrush(pSeam->pSymbiot, vMin, vMax);\n          //--Patch_CapTexture(pSeam);\n          Patch_Naturalize(pSeam);\n          brushes.Add(b);\n\n          eclass_t *pecNew = Eclass_ForName(\"func_group\", false);\n          if (pecNew)\n          {\n            entity_t *e = Entity_Create(pecNew);\n            SetKeyValue(e, \"type\", \"patchThick\");\n          }\n\n        \n        //--}\n      }\n      patchInvert(pNew);\n    }\n  }\n\n  for (i = 0; i < brushes.GetSize(); i++)\n  {\n    Select_Brush(reinterpret_cast<brush_t*>(brushes.GetAt(i)));\n  }\n\n  UpdatePatchInspector();\n}\n\n\n/*\nlets get another list together as far as necessities..\n\n*snapping stuff to the grid (i will only snap movements by the mouse to the grid.. snapping the rotational bend stuff will fubar everything)\n\ncapping bevels/endcaps\n\nhot keys\n\ntexture fix for caps\n\nclear clipboard\n\n*region fix\n\n*surface dialog\n\n*/\n\nvoid Patch_SetOverlays()\n{\n\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n      pb->pPatch->bOverlay = true;\n    }\n  }\n}\n\n\n\nvoid Patch_ClearOverlays()\n{\n  brush_t *pb;\n\tfor (pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n      pb->pPatch->bOverlay = false;\n    }\n  }\n\n\tfor (pb = active_brushes.next ; pb != &active_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n      pb->pPatch->bOverlay = false;\n    }\n  }\n\n}\n\n// freezes selected vertices\nvoid Patch_Freeze()\n{\n  brush_t *pb;\n\tfor (pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n      pb->pPatch->bOverlay = false;\n    }\n  }\n\n\tfor (pb = active_brushes.next ; pb != &active_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n      pb->pPatch->bOverlay = false;\n    }\n  }\n\n}\n\nvoid Patch_UnFreeze(bool bAll)\n{\n}\n\n\n\nvoid Patch_Transpose()\n{\n\tint\t\ti, j, w;\n  drawVert_t dv;\n\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n      patchMesh_t *p = pb->pPatch;\n\n    \tif ( p->width > p->height ) \n      {\n\t\t    for ( i = 0 ; i < p->height ; i++ ) \n        {\n    \t\t\tfor ( j = i + 1 ; j < p->width ; j++ ) \n          {\n    \t\t\t\tif ( j < p->height ) \n            {\n    \t\t\t\t\t// swap the value\n\t\t    \t\t\tmemcpy(&dv,&p->ctrl[j][i],sizeof(drawVert_t));\n\t\t\t\t    \tmemcpy(&p->ctrl[j][i],&p->ctrl[i][j], sizeof(drawVert_t));\n    \t\t\t\t\tmemcpy(&p->ctrl[i][j],&dv, sizeof(drawVert_t));\n    \t\t\t\t} \n            else \n            {\n    \t\t\t\t\t// just copy\n\t\t    \t\t\tmemcpy(&p->ctrl[j][i],&p->ctrl[i][j], sizeof(drawVert_t));\n\t\t    \t\t}\n    \t\t\t}\n  \t\t  }\n\t    } \n      else \n      {\n    \t\tfor ( i = 0 ; i < p->width ; i++ ) \n        {\n\t\t  \t  for ( j = i + 1 ; j < p->height ; j++ ) \n          {\n    \t\t\t\tif ( j < p->width ) \n            {\n\t\t\t\t\t    // swap the value\n\t\t\t\t\t    memcpy(&dv,&p->ctrl[i][j], sizeof(drawVert_t));\n              memcpy(&p->ctrl[i][j],&p->ctrl[j][i], sizeof(drawVert_t));\n    \t\t\t\t\tmemcpy(&p->ctrl[j][i],&dv, sizeof(drawVert_t));\n\t\t    \t\t} \n            else \n            {\n    \t\t\t\t\t// just copy\n    \t\t\t\t\tmemcpy(&p->ctrl[i][j],&p->ctrl[j][i], sizeof(drawVert_t));\n\t\t    \t\t}\n    \t\t\t}\n    \t\t}\n    \t}\n\n      w = p->width;\n      p->width = p->height;\n      p->height = w;\n      patchInvert(p);\n      Patch_Rebuild(p);\n\t\t}\n\t}\n}\n\n\n\nvoid Select_SnapToGrid()\n{\n\tint i,j, k;\n\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    if (pb->patchBrush)\n    {\n      patchMesh_t *p = pb->pPatch;\n#if 0\n\t    float\t\tctrl[MAX_PATCH_WIDTH][MAX_PATCH_HEIGHT][5];\n      memcpy(ctrl, p->ctrl, sizeof(p->ctrl));\n      i = p->width;\n      p->width = p->height;\n      p->height = i;\n      for (i = 0; i < p->width; i++)\n      {\n        int l = p->height-1;\n        for (j = 0; j < p->height; j++)\n        {\n          for (k = 0; k < 5; k++)\n          {\n            p->ctrl[i][l][k] = ctrl[j][i][k];\n          }\n          l--;\n        }\n      }\n#else\n      for (i = 0; i < p->width; i++)\n      {\n        for (j = 0; j < p->height; j++)\n        {\n          for (k = 0; k < 3; k++)\n          {\n            p->ctrl[i][j].xyz[k] = floor(p->ctrl[i][j].xyz[k] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize;\n          }\n        }\n      }\n#endif\n      vec3_t vMin, vMax;\n      Patch_CalcBounds(p, vMin, vMax);\n      Brush_RebuildBrush(p->pSymbiot, vMin, vMax);\n    }\n    else\n    {\n      Brush_SnapToGrid(pb);\n    }\n  }\n}\n\n\nvoid Patch_FindReplaceTexture(brush_t *pb, const char *pFind, const char *pReplace, bool bForce)\n{\n  if (pb->patchBrush)\n  {\n    patchMesh_t *p = pb->pPatch;\n    if (bForce || strcmpi(p->d_texture->name, pFind) == 0)\n    {\n      p->d_texture = Texture_ForName(pReplace);\n      //strcpy(p->d_texture->name, pReplace);\n    }\n  }\n}\n\nvoid Patch_ReplaceQTexture(brush_t *pb, qtexture_t *pOld, qtexture_t *pNew)\n{\n  if (pb->patchBrush)\n  {\n    patchMesh_t *p = pb->pPatch;\n    if (p->d_texture == pOld)\n    {\n      p->d_texture = pNew;\n    }\n  }\n}\n\nvoid Patch_Clone(patchMesh_t *p, brush_t *pNewOwner)\n{\n}\n\nvoid Patch_FromTriangle(vec5_t vx, vec5_t vy, vec5_t vz)\n{\n  patchMesh_t* p = MakeNewPatch();\n\tp->d_texture = Texture_ForName(g_qeglobals.d_texturewin.texdef.name);\n\tp->width = 3;\n\tp->height = 3;\n  p->type = PATCH_TRIANGLE;\n\n  // 0 0 goes to x\n  // 0 1 goes to x\n  // 0 2 goes to x\n\n  // 1 0 goes to mid of x and z\n  // 1 1 goes to mid of x y and z\n  // 1 2 goes to mid of x and y\n\n  // 2 0 goes to z\n  // 2 1 goes to mid of y and z\n  // 2 2 goes to y\n\n  vec5_t vMidXZ;\n  vec5_t vMidXY;\n  vec5_t vMidYZ;\n\n\n  for (int j = 0; j < 3; j++)\n  {\n    _Vector5Add(vx, vz, vMidXZ);\n    _Vector5Scale(vMidXZ, 0.5, vMidXZ);\n    //vMidXZ[j] = vx[j] + abs((vx[j] - vz[j]) * 0.5);\n  }\n\n  for (j = 0; j < 3; j++)\n  {\n    _Vector5Add(vx, vy, vMidXY);\n    _Vector5Scale(vMidXY, 0.5, vMidXY);\n    //vMidXY[j] = vx[j] + abs((vx[j] - vy[j]) * 0.5);\n  }\n\n  for (j = 0; j < 3; j++)\n  {\n    _Vector5Add(vy, vz, vMidYZ);\n    _Vector5Scale(vMidYZ, 0.5, vMidYZ);\n    //vMidYZ[j] = vy[j] + abs((vy[j] - vz[j]) * 0.5);\n  }\n\n  _Vector53Copy(vx, p->ctrl[0][0].xyz);\n  _Vector53Copy(vx, p->ctrl[0][1].xyz);\n  _Vector53Copy(vx, p->ctrl[0][2].xyz);\n  p->ctrl[0][0].st[0] = vx[3];\n  p->ctrl[0][0].st[1] = vx[4];\n  p->ctrl[0][1].st[0] = vx[3];\n  p->ctrl[0][1].st[1] = vx[4];\n  p->ctrl[0][2].st[0] = vx[3];\n  p->ctrl[0][2].st[1] = vx[4];\n\n  _Vector53Copy(vMidXY, p->ctrl[1][0].xyz);\n  _Vector53Copy(vx, p->ctrl[1][1].xyz);\n  _Vector53Copy(vMidXZ, p->ctrl[1][2].xyz);\n  p->ctrl[1][0].st[0] = vMidXY[3];\n  p->ctrl[1][0].st[1] = vMidXY[4];\n  p->ctrl[1][1].st[0] = vx[3];\n  p->ctrl[1][1].st[1] = vx[4];\n  p->ctrl[1][2].st[0] = vMidXZ[3];\n  p->ctrl[1][2].st[1] = vMidXZ[4];\n\n  _Vector53Copy(vy, p->ctrl[2][0].xyz);\n  _Vector53Copy(vMidYZ, p->ctrl[2][1].xyz);\n  _Vector53Copy(vz, p->ctrl[2][2].xyz);\n  p->ctrl[2][0].st[0] = vy[3];\n  p->ctrl[2][0].st[1] = vy[4];\n  p->ctrl[2][1].st[0] = vMidYZ[3];\n  p->ctrl[2][1].st[1] = vMidYZ[4];\n  p->ctrl[2][2].st[0] = vz[3];\n  p->ctrl[2][2].st[1] = vz[4];\n\n\n  //Patch_Naturalize(p);\n\n  brush_t *b = AddBrushForPatch(p);\n\n}\n\n\n/*\n==============\nPatch_SetEpair\nsets an epair for the given patch\n==============\n*/\nvoid Patch_SetEpair(patchMesh_t *p, const char *pKey, const char *pValue)\n{\n\tif (g_qeglobals.m_bBrushPrimitMode)\n\t{\n\t\tSetKeyValue(p->epairs, pKey, pValue);\n\t}\n}\n\n/* \n=================\nPatch_GetKeyValue\n=================\n*/\nconst char* Patch_GetKeyValue(patchMesh_t *p, const char *pKey)\n{\n\tif (g_qeglobals.m_bBrushPrimitMode)\n\t{\n    return ValueForKey(p->epairs, pKey);\n\t}\n  return \"\";\n}\n\n\n//Real nitpicky, but could you make CTRL-S save the current map with the current name? (ie: File/Save)\n/*\nFeature addition.\nWhen reading in textures, please check for the presence of a file called \"textures.link\" or something, which contains one line such as;\n\ng:\\quake3\\baseq3\\textures\\common\n\n So that, when I'm reading in, lets say, my \\eerie directory, it goes through and adds my textures to the palette, along with everything in common.\n\n  Don't forget to add \"Finer texture alignment\" to the list. I'd like to be able to move in 0.1 increments using the Shift-Arrow Keys.\n\n  No. Sometimes textures are drawn the wrong way on patches. We'd like the ability to flip a texture. Like the way X/Y scale -1 used to worked.\n\n  1) Easier way of deleting rows, columns\n2) Fine tuning of textures on patches (X/Y shifts other than with the surface dialog)\n2) Patch matrix transposition\n\n  1) Actually, bump texture flipping on patches to the top of the list of things to do.\n2) When you select a patch, and hit S, it should read in the selected patch texture. Should not work if you multiselect patches and hit S\n3) Brandon has a wierd anomoly. He fine-tunes a patch with caps. It looks fine when the patch is selected, but as soon as he escapes out, it reverts to it's pre-tuned state. When he selects the patch again, it looks tuned\n\n\n*1) Flipping textures on patches\n*2) When you select a patch, and hit S, it should read in the selected patch texture. Should not work if you multiselect patches and hit S\n3) Easier way of deleting rows columns\n*4) Thick Curves\n5) Patch matrix transposition\n6) Inverted cylinder capping\n*7) bugs\n*8) curve speed\n\n  Have a new feature request. \"Compute Bounding Box\" for mapobjects (md3 files). This would be used for misc_mapobject (essentially, drop in 3DS Max models into our maps)\n\n  Ok, Feature Request. Load and draw MD3's in the Camera view with proper bounding boxes. This should be off misc_model\n\n  Feature Addition: View/Hide Hint Brushes -- This should be a specific case.\n*/\n"
  },
  {
    "path": "q3radiant/PMESH.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n"
  },
  {
    "path": "q3radiant/POINTS.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"stdafx.h\"\n\n#include \"qe3.h\"\n\n\n#define\tMAX_POINTFILE\t8192\nstatic vec3_t\ts_pointvecs[MAX_POINTFILE];\nstatic int\t\ts_num_points, s_check_point;\n\nvoid Pointfile_Delete (void)\n{\n\tchar\tname[1024];\n\n\tstrcpy (name, currentmap);\n\tStripExtension (name);\n\tstrcat (name, \".lin\");\n\n\tremove(name);\n}\n\n// advance camera to next point\nvoid Pointfile_Next (void)\n{\n\tvec3_t\tdir;\n\n\tif (s_check_point >= s_num_points-2)\n\t{\n\t\tSys_Status (\"End of pointfile\", 0);\n\t\treturn;\n\t}\n\ts_check_point++;\n\tVectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetCamera()->Camera().origin);\n\tVectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetXYWnd()->GetOrigin());\n\tVectorSubtract (s_pointvecs[s_check_point+1], g_pParentWnd->GetCamera()->Camera().origin, dir);\n\tVectorNormalize (dir);\n\tg_pParentWnd->GetCamera()->Camera().angles[1] = atan2 (dir[1], dir[0])*180/3.14159;\n\tg_pParentWnd->GetCamera()->Camera().angles[0] = asin (dir[2])*180/3.14159;\n\n\tSys_UpdateWindows (W_ALL);\n}\n\n// advance camera to previous point\nvoid Pointfile_Prev (void)\n{\n\tvec3_t\tdir;\n\n\tif ( s_check_point == 0)\n\t{\n\t\tSys_Status (\"Start of pointfile\", 0);\n\t\treturn;\n\t}\n\ts_check_point--;\n\tVectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetCamera()->Camera().origin);\n\tVectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetXYWnd()->GetOrigin());\n\tVectorSubtract (s_pointvecs[s_check_point+1], g_pParentWnd->GetCamera()->Camera().origin, dir);\n\tVectorNormalize (dir);\n\tg_pParentWnd->GetCamera()->Camera().angles[1] = atan2 (dir[1], dir[0])*180/3.14159;\n\tg_pParentWnd->GetCamera()->Camera().angles[0] = asin (dir[2])*180/3.14159;\n\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid WINAPI Pointfile_Check (void)\n{\n\tchar\tname[1024];\n\tFILE\t*f;\n\tvec3_t\tv;\n\n\tstrcpy (name, currentmap);\n\tStripExtension (name);\n\tstrcat (name, \".lin\");\n\n\tf = fopen (name, \"r\");\n\tif (!f)\n\t\treturn;\n\n\tSys_Printf (\"Reading pointfile %s\\n\", name);\n\n\tif (!g_qeglobals.d_pointfile_display_list)\n\t\tg_qeglobals.d_pointfile_display_list = qglGenLists(1);\n\n\ts_num_points = 0;\n  qglNewList (g_qeglobals.d_pointfile_display_list,  GL_COMPILE);\n\tqglColor3f (1, 0, 0);\n\tqglDisable(GL_TEXTURE_2D);\n\tqglDisable(GL_TEXTURE_1D);\n\tqglLineWidth (4);\n\tqglBegin(GL_LINE_STRIP);\n\tdo\n\t{\n\t\tif (fscanf (f, \"%f %f %f\\n\", &v[0], &v[1], &v[2]) != 3)\n\t\t\tbreak;\n\t\tif (s_num_points < MAX_POINTFILE)\n\t\t{\n\t\t\tVectorCopy (v, s_pointvecs[s_num_points]);\n\t\t\ts_num_points++;\n\t\t}\n\t\tqglVertex3fv (v);\n\t} while (1);\n\tqglEnd();\n\tqglLineWidth (1);\n\tqglEndList ();\n\n\ts_check_point = 0;\n\tfclose (f);\n\t//Pointfile_Next ();\n}\n\nvoid Pointfile_Draw( void )\n{\n\tint i;\n\n\tqglColor3f( 1.0F, 0.0F, 0.0F );\n\tqglDisable(GL_TEXTURE_2D);\n\tqglDisable(GL_TEXTURE_1D);\n\tqglLineWidth (4);\n\tqglBegin(GL_LINE_STRIP);\n\tfor ( i = 0; i < s_num_points; i++ )\n\t{\n\t\tqglVertex3fv( s_pointvecs[i] );\n\t}\n\tqglEnd();\n\tqglLineWidth( 1 );\n}\n\nvoid Pointfile_Clear (void)\n{\n\tif (!g_qeglobals.d_pointfile_display_list)\n\t\treturn;\n\n\tqglDeleteLists (g_qeglobals.d_pointfile_display_list, 1);\n\tg_qeglobals.d_pointfile_display_list = 0;\n\tSys_UpdateWindows (W_ALL);\n}\n\n"
  },
  {
    "path": "q3radiant/PatchDensityDlg.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// PatchDensityDlg.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"PatchDensityDlg.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CPatchDensityDlg dialog\n\n\nCPatchDensityDlg::CPatchDensityDlg(CWnd* pParent /*=NULL*/)\n\t: CDialog(CPatchDensityDlg::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CPatchDensityDlg)\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CPatchDensityDlg::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CPatchDensityDlg)\n\tDDX_Control(pDX, IDC_COMBO_WIDTH, m_wndWidth);\n\tDDX_Control(pDX, IDC_COMBO_HEIGHT, m_wndHeight);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CPatchDensityDlg, CDialog)\n\t//{{AFX_MSG_MAP(CPatchDensityDlg)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CPatchDensityDlg message handlers\n\nint g_nXLat[] = {3,5,7,9,11,13,15};\n\nvoid CPatchDensityDlg::OnOK() \n{\n  int nWidth = m_wndWidth.GetCurSel();\n  int nHeight = m_wndHeight.GetCurSel();\n\n  if (nWidth >= 0 && nWidth <= 6 && nHeight >= 0 && nHeight <= 6)\n  {\n\t  Patch_GenericMesh(g_nXLat[nWidth], g_nXLat[nHeight], g_pParentWnd->ActiveXY()->GetViewType());\n    Sys_UpdateWindows(W_ALL);\n  }\n\n  CDialog::OnOK();\n}\n\nBOOL CPatchDensityDlg::OnInitDialog() \n{\n\tCDialog::OnInitDialog();\n\n  m_wndWidth.SetCurSel(0);\n  m_wndHeight.SetCurSel(0);\n\treturn TRUE;  // return TRUE unless you set the focus to a control\n\t              // EXCEPTION: OCX Property Pages should return FALSE\n}\n"
  },
  {
    "path": "q3radiant/PatchDensityDlg.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_PATCHDENSITYDLG_H__509162A1_1023_11D2_AFFB_00AA00A410FC__INCLUDED_)\n#define AFX_PATCHDENSITYDLG_H__509162A1_1023_11D2_AFFB_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// PatchDensityDlg.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CPatchDensityDlg dialog\n\nclass CPatchDensityDlg : public CDialog\n{\n// Construction\npublic:\n\tCPatchDensityDlg(CWnd* pParent = NULL);   // standard constructor\n\n// Dialog Data\n\t//{{AFX_DATA(CPatchDensityDlg)\n\tenum { IDD = IDD_DIALOG_NEWPATCH };\n\tCComboBox\tm_wndWidth;\n\tCComboBox\tm_wndHeight;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CPatchDensityDlg)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CPatchDensityDlg)\n\tvirtual void OnOK();\n\tvirtual BOOL OnInitDialog();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_PATCHDENSITYDLG_H__509162A1_1023_11D2_AFFB_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/PatchDialog.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// PatchDialog.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"PatchDialog.h\"\n#include \"TextureLayout.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CPatchDialog dialog\n\nCPatchDialog g_PatchDialog;\n\nCPatchDialog::CPatchDialog(CWnd* pParent /*=NULL*/)\n\t: CDialog(CPatchDialog::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CPatchDialog)\n\tm_strName = _T(\"\");\n\tm_fS = 0.0f;\n\tm_fT = 0.0f;\n\tm_fX = 0.0f;\n\tm_fY = 0.0f;\n\tm_fZ = 0.0f;\n\tm_fHScale = 0.05f;\n\tm_fHShift = 0.05f;\n\tm_fRotate = 45;\n\tm_fVScale = 0.05f;\n\tm_fVShift = 0.05f;\n\t//}}AFX_DATA_INIT\n\tm_Patch = NULL;\n}\n\n\nvoid CPatchDialog::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CPatchDialog)\n\tDDX_Control(pDX, IDC_SPIN_VSHIFT, m_wndVShift);\n\tDDX_Control(pDX, IDC_SPIN_VSCALE, m_wndVScale);\n\tDDX_Control(pDX, IDC_SPIN_ROTATE, m_wndRotate);\n\tDDX_Control(pDX, IDC_SPIN_HSHIFT, m_wndHShift);\n\tDDX_Control(pDX, IDC_SPIN_HSCALE, m_wndHScale);\n\tDDX_Control(pDX, IDC_COMBO_TYPE, m_wndType);\n\tDDX_Control(pDX, IDC_COMBO_ROW, m_wndRows);\n\tDDX_Control(pDX, IDC_COMBO_COL, m_wndCols);\n\tDDX_Text(pDX, IDC_EDIT_NAME, m_strName);\n\tDDX_Text(pDX, IDC_EDIT_S, m_fS);\n\tDDX_Text(pDX, IDC_EDIT_T, m_fT);\n\tDDX_Text(pDX, IDC_EDIT_X, m_fX);\n\tDDX_Text(pDX, IDC_EDIT_Y, m_fY);\n\tDDX_Text(pDX, IDC_EDIT_Z, m_fZ);\n\tDDX_Text(pDX, IDC_HSCALE, m_fHScale);\n\tDDX_Text(pDX, IDC_HSHIFT, m_fHShift);\n\tDDX_Text(pDX, IDC_ROTATE, m_fRotate);\n\tDDX_Text(pDX, IDC_VSCALE, m_fVScale);\n\tDDX_Text(pDX, IDC_VSHIFT, m_fVShift);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CPatchDialog, CDialog)\n\t//{{AFX_MSG_MAP(CPatchDialog)\n\tON_BN_CLICKED(IDC_BTN_PATCHDETAILS, OnBtnPatchdetails)\n\tON_BN_CLICKED(IDC_BTN_PATCHFIT, OnBtnPatchfit)\n\tON_BN_CLICKED(IDC_BTN_PATCHNATURAL, OnBtnPatchnatural)\n\tON_BN_CLICKED(IDC_BTN_PATCHRESET, OnBtnPatchreset)\n\tON_CBN_SELCHANGE(IDC_COMBO_COL, OnSelchangeComboCol)\n\tON_CBN_SELCHANGE(IDC_COMBO_ROW, OnSelchangeComboRow)\n\tON_CBN_SELCHANGE(IDC_COMBO_TYPE, OnSelchangeComboType)\n\tON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSCALE, OnDeltaposSpin)\n\tON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ROTATE, OnDeltaposSpin)\n\tON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSCALE, OnDeltaposSpin)\n\tON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSHIFT, OnDeltaposSpin)\n\tON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSHIFT, OnDeltaposSpin)\n\tON_WM_DESTROY()\n\tON_BN_CLICKED(ID_APPLY, OnApply)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CPatchDialog message handlers\n\nvoid CPatchDialog::OnBtnPatchdetails() \n{\n  Patch_NaturalizeSelected(true);\n  Sys_UpdateWindows(W_ALL);\n}\n\nvoid CPatchDialog::OnBtnPatchfit() \n{\n  Patch_FitTexturing();\n  Sys_UpdateWindows(W_ALL);\n}\n\nvoid CPatchDialog::OnBtnPatchnatural() \n{\n  Patch_NaturalizeSelected();\n  Sys_UpdateWindows(W_ALL);\n}\n\nvoid CPatchDialog::OnBtnPatchreset() \n{\n  CTextureLayout dlg;\n  if (dlg.DoModal() == IDOK)\n  {\n    Patch_ResetTexturing(dlg.m_fX, dlg.m_fY);\n  }\n  Sys_UpdateWindows(W_ALL);\n}\n\nvoid CPatchDialog::OnSelchangeComboCol() \n{\n  UpdateRowColInfo();\n}\n\nvoid CPatchDialog::OnSelchangeComboRow() \n{\n  UpdateRowColInfo();\n}\n\nvoid CPatchDialog::OnSelchangeComboType() \n{\n\t// TODO: Add your control notification handler code here\n\t\n}\n\nvoid CPatchDialog::OnOK() \n{\n  m_Patch = NULL;\n\t\n\tCDialog::OnOK();\n}\n\nvoid CPatchDialog::OnDeltaposSpin(NMHDR* pNMHDR, LRESULT* pResult) \n{\n\tNM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;\n  UpdateSpinners((pNMUpDown->iDelta > 0), pNMUpDown->hdr.idFrom);\n\t*pResult = 0;\n}\n\nBOOL CPatchDialog::OnInitDialog() \n{\n\tCDialog::OnInitDialog();\n\t\n  m_wndHScale.SetRange(0, 1000);\n  m_wndVScale.SetRange(0, 1000);\n  m_wndHShift.SetRange(0, 1000);\n  m_wndVShift.SetRange(0, 1000);\n  m_wndRotate.SetRange(0, 1000);\n\n  GetPatchInfo();\n\n\t// TODO: Add extra initialization here\n\t\n\treturn TRUE;  // return TRUE unless you set the focus to a control\n\t              // EXCEPTION: OCX Property Pages should return FALSE\n}\n\n\n\nvoid CPatchDialog::GetPatchInfo()\n{\n  m_Patch = SinglePatchSelected();\n  if (m_Patch != NULL)\n  {\n    CString str;\n    int i;\n    m_wndRows.ResetContent();\n    for (i = 0; i < m_Patch->height; i++)\n    {\n      str.Format(\"%i\", i);\n      m_wndRows.AddString(str);\n    }\n    m_wndRows.SetCurSel(0);\n    m_wndCols.ResetContent();\n    for (i = 0; i < m_Patch->width; i++)\n    {\n      str.Format(\"%i\", i);\n      m_wndCols.AddString(str);\n    }\n    m_wndCols.SetCurSel(0);\n  }\n  UpdateRowColInfo();\n}\n\nvoid CPatchDialog::SetPatchInfo()\n{\n\n}\n\nvoid DoPatchInspector()\n{\n  if (g_PatchDialog.GetSafeHwnd() == NULL)\n  {\n    g_PatchDialog.Create(IDD_DIALOG_PATCH);\n    CRect rct;\n\t  LONG lSize = sizeof(rct);\n\t  if (LoadRegistryInfo(\"Radiant::PatchWindow\", &rct, &lSize))\n    {\n      g_PatchDialog.SetWindowPos(NULL, rct.left, rct.top, 0,0, SWP_NOSIZE);\n    }\n  }\n  g_PatchDialog.ShowWindow(SW_SHOW);\n  g_PatchDialog.GetPatchInfo();\n}\n\nvoid UpdatePatchInspector()\n{\n  if (g_PatchDialog.GetSafeHwnd() != NULL)\n  {\n    g_PatchDialog.UpdateInfo();\n  }\n\n}\n\nvoid CPatchDialog::OnDestroy() \n{\n  if (GetSafeHwnd())\n  {\n    CRect rct;\n    GetWindowRect(rct);\n\t  SaveRegistryInfo(\"Radiant::PatchWindow\", &rct, sizeof(rct));\n  }\n\tCDialog::OnDestroy();\n}\n\nvoid CPatchDialog::UpdateRowColInfo()\n{\n  m_fX = m_fY = m_fZ = m_fS = m_fT = 0.0;\n\n  if (m_Patch != NULL)\n  {\n    int r = m_wndRows.GetCurSel();\n    int c = m_wndCols.GetCurSel();\n    if (r >= 0 && r < m_Patch->height && c >= 0 && c < m_Patch->width)\n    {\n      m_fX = m_Patch->ctrl[c][r].xyz[0];\n      m_fY = m_Patch->ctrl[c][r].xyz[1];\n      m_fZ = m_Patch->ctrl[c][r].xyz[2];\n      m_fS = m_Patch->ctrl[c][r].st[0];\n      m_fT = m_Patch->ctrl[c][r].st[1];\n    }\n  }\n  UpdateData(FALSE);\n}\n\nvoid CPatchDialog::UpdateInfo()\n{\n  GetPatchInfo();\n}\n\nvoid CPatchDialog::OnApply() \n{\n\tUpdateData(TRUE);\n  if (m_Patch != NULL)\n  {\n    int r = m_wndRows.GetCurSel();\n    int c = m_wndCols.GetCurSel();\n    if (r >= 0 && r < m_Patch->height && c >= 0 && c < m_Patch->width)\n    {\n      m_Patch->ctrl[c][r].xyz[0] = m_fX;\n      m_Patch->ctrl[c][r].xyz[1] = m_fY;\n      m_Patch->ctrl[c][r].xyz[2] = m_fZ;\n      m_Patch->ctrl[c][r].st[0] = m_fS;\n      m_Patch->ctrl[c][r].st[1] = m_fT;\n      m_Patch->bDirty = true;\n      Sys_UpdateWindows(W_ALL);\n    }\n  }\n}\n\nvoid CPatchDialog::UpdateSpinners(bool bUp, int nID)\n{\n  texdef_t td;\n\n  td.rotate = 0.0;\n  td.scale[0] = td.scale[1] = 0.0;\n  td.shift[0] = td.shift[1] = 0.0;\n  td.contents = 0;\n  td.flags = 0;\n  td.value = 0;\n\n\n  UpdateData(TRUE);\n\n  if (nID == IDC_SPIN_ROTATE)\n  {\n\t  if (bUp)\n\t\t  td.rotate = m_fRotate;\n\t\telse\n\t\t  td.rotate = -m_fRotate;\n\t}\n  else if (nID == IDC_SPIN_HSCALE)\n\t{\n\t  if (bUp)\n\t    td.scale[0] = 1 - m_fHScale;\n\t  else\n\t\t  td.scale[0] = 1 + m_fHScale;\n  } \n  else if (nID == IDC_SPIN_VSCALE)\n\t{\n\t  if (bUp)\n\t\t  td.scale[1] = 1 - m_fVScale;\n\t\telse\n\t\t  td.scale[1] = 1 + m_fVScale;\n  } \n\t  \n  else if (nID == IDC_SPIN_HSHIFT)\n\t{\n\t  if (bUp)\n\t\t  td.shift[0] = m_fHShift;\n\t\telse\n\t\t  td.shift[0] = -m_fHShift;\n\t}\n  else if (nID == IDC_SPIN_VSHIFT)\n\t{\n\t  if (bUp)\n\t    td.shift[1] = m_fVShift;\n\t\telse\n\t\t  td.shift[1] = -m_fVShift;\n\t}\n  \n  Patch_SetTextureInfo(&td);\n  Sys_UpdateWindows(W_CAMERA);\n}\n\n\n"
  },
  {
    "path": "q3radiant/PatchDialog.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_PATCHDIALOG_H__DE62DFB4_E9EC_11D2_A509_0020AFEB881A__INCLUDED_)\n#define AFX_PATCHDIALOG_H__DE62DFB4_E9EC_11D2_A509_0020AFEB881A__INCLUDED_\n\n#if _MSC_VER > 1000\n#pragma once\n#endif // _MSC_VER > 1000\n// PatchDialog.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CPatchDialog dialog\n\nclass CPatchDialog : public CDialog\n{\n  patchMesh_t *m_Patch;\n// Construction\npublic:\n\tvoid UpdateInfo();\n\tvoid SetPatchInfo();\n\tvoid GetPatchInfo();\n\tCPatchDialog(CWnd* pParent = NULL);   // standard constructor\n  void UpdateSpinners(bool bUp, int nID);\n\n// Dialog Data\n\t//{{AFX_DATA(CPatchDialog)\n\tenum { IDD = IDD_DIALOG_PATCH };\n\tCSpinButtonCtrl\tm_wndVShift;\n\tCSpinButtonCtrl\tm_wndVScale;\n\tCSpinButtonCtrl\tm_wndRotate;\n\tCSpinButtonCtrl\tm_wndHShift;\n\tCSpinButtonCtrl\tm_wndHScale;\n\tCComboBox\tm_wndType;\n\tCComboBox\tm_wndRows;\n\tCComboBox\tm_wndCols;\n\tCString\tm_strName;\n\tfloat\tm_fS;\n\tfloat\tm_fT;\n\tfloat\tm_fX;\n\tfloat\tm_fY;\n\tfloat\tm_fZ;\n\tfloat\tm_fHScale;\n\tfloat\tm_fHShift;\n\tfloat\tm_fRotate;\n\tfloat\tm_fVScale;\n\tfloat\tm_fVShift;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CPatchDialog)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\tvoid UpdateRowColInfo();\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CPatchDialog)\n\tafx_msg void OnBtnPatchdetails();\n\tafx_msg void OnBtnPatchfit();\n\tafx_msg void OnBtnPatchnatural();\n\tafx_msg void OnBtnPatchreset();\n\tafx_msg void OnSelchangeComboCol();\n\tafx_msg void OnSelchangeComboRow();\n\tafx_msg void OnSelchangeComboType();\n\tvirtual void OnOK();\n\tafx_msg void OnDeltaposSpin(NMHDR* pNMHDR, LRESULT* pResult);\n\tvirtual BOOL OnInitDialog();\n\tafx_msg void OnDestroy();\n\tafx_msg void OnApply();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Visual C++ will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_PATCHDIALOG_H__DE62DFB4_E9EC_11D2_A509_0020AFEB881A__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/PlugIn.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// PlugIn.cpp: implementation of the CPlugIn class.\n//\n//////////////////////////////////////////////////////////////////////\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"PlugIn.h\"\n\n#ifdef _DEBUG\n#undef THIS_FILE\nstatic char THIS_FILE[]=__FILE__;\n#define new DEBUG_NEW\n#endif\n\n//////////////////////////////////////////////////////////////////////\n// Construction/Destruction\n//////////////////////////////////////////////////////////////////////\n\nCPlugIn::CPlugIn()\n{\n  m_hDLL = NULL;\n  m_pQERPlugEntitiesFactory = NULL;\n}\n\nCPlugIn::~CPlugIn()\n{\n\tif (m_pQERPlugEntitiesFactory)\n\t\tdelete m_pQERPlugEntitiesFactory;\n\tif (m_hDLL != NULL)\n\t\tfree();\n}\n\nbool CPlugIn::load(const char *p)\n{\n\tm_hDLL = ::LoadLibrary(p);\n\tif (m_hDLL != NULL)\n\t{\n\t\tm_pfnInit = reinterpret_cast<PFN_QERPLUG_INIT>(::GetProcAddress(m_hDLL, QERPLUG_INIT));\n\t\tif (m_pfnInit != NULL)\n\t\t{\n\t\t\tm_strVersion = (*m_pfnInit)(AfxGetApp()->m_hInstance, g_pParentWnd->GetSafeHwnd());\n\t\t\tSys_Printf(\"Loaded plugin > %s\\n\", m_strVersion);\n\t\t\t\n\t\t\tm_pfnGetName = reinterpret_cast<PFN_QERPLUG_GETNAME>(::GetProcAddress(m_hDLL, QERPLUG_GETNAME));\n\t\t\tif (m_pfnGetName != NULL)\n\t\t\t{\n\t\t\t\tm_strName = (*m_pfnGetName)();\n\t\t\t}\n\t\t\t\n\t\t\tm_pfnGetCommandList = reinterpret_cast<PFN_QERPLUG_GETCOMMANDLIST>(::GetProcAddress(m_hDLL, QERPLUG_GETCOMMANDLIST));\n\t\t\tif (m_pfnGetCommandList)\n\t\t\t{\n\t\t\t\tCString str = (*m_pfnGetCommandList)();\n\t\t\t\tchar cTemp[1024];\n\t\t\t\tstrcpy(cTemp, str);\n\t\t\t\tchar* token = strtok(cTemp, \",;\");\n\t\t\t\tif (token && *token == ' ')\n\t\t\t\t{\n\t\t\t\t\twhile (*token == ' ')\n\t\t\t\t\t\ttoken++;\n\t\t\t\t}\n\t\t\t\twhile (token != NULL)\n\t\t\t\t{\n\t\t\t\t\tm_CommandStrings.Add(token);\n\t\t\t\t\ttoken = strtok(NULL, \",;\");\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tm_pfnDispatch = reinterpret_cast<PFN_QERPLUG_DISPATCH>(::GetProcAddress(m_hDLL, QERPLUG_DISPATCH));\n\t\t\tm_pfnGetFuncTable = reinterpret_cast<PFN_QERPLUG_GETFUNCTABLE>(::GetProcAddress(m_hDLL, QERPLUG_GETFUNCTABLE));\n\t\t\t\n\t\t\tm_pfnGetTextureInfo = reinterpret_cast<PFN_QERPLUG_GETTEXTUREINFO>(::GetProcAddress(m_hDLL, QERPLUG_GETTEXTUREINFO));\n\t\t\tm_pfnLoadTexture = reinterpret_cast<PFN_QERPLUG_LOADTEXTURE>(::GetProcAddress(m_hDLL, QERPLUG_LOADTEXTURE));\n\t\t\t\n\t\t\tm_pfnGetSurfaceFlags = reinterpret_cast<PFN_QERPLUG_GETSURFACEFLAGS>(::GetProcAddress(m_hDLL, QERPLUG_GETSURFACEFLAGS));\n\t\t\t\n\t\t\tm_pfnRegisterPluginEntities = reinterpret_cast<PFN_QERPLUG_REGISTERPLUGINENTITIES>(::GetProcAddress(m_hDLL, QERPLUG_REGISTERPLUGINENTITIES));\n\t\t\t\n\t\t\tm_pfnInitSurfaceProperties = reinterpret_cast<PFN_QERPLUG_INITSURFACEPROPERTIES>(::GetProcAddress(m_hDLL, QERPLUG_INITSURFACEPROPERTIES));\n\t\t\t\n\t\t\tm_pfnRequestInterface = reinterpret_cast<PFN_QERPLUG_REQUESTINTERFACE>(::GetProcAddress(m_hDLL, QERPLUG_REQUESTINTERFACE));\n\n\t\t\treturn (m_pfnDispatch != NULL && m_pfnGetFuncTable != NULL);\n\t\t\t//--return true;\n\t\t}\n\t\tSys_Printf(\"FAILED to Load plugin > %s\\n\", p);\n\t}\n\tLPVOID lpMsgBuf;\n\tFormatMessage( \n\t    FORMAT_MESSAGE_ALLOCATE_BUFFER | \n\t    FORMAT_MESSAGE_FROM_SYSTEM | \n\t    FORMAT_MESSAGE_IGNORE_INSERTS,\n\t    NULL,\n\t    GetLastError(),\n\t    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language\n\t    (LPTSTR) &lpMsgBuf,\n\t    0,\n\t    NULL \n\t);\n\tSys_Printf(\"LoadLibrary failed on %s: GetLastError: %s\\n\", p, lpMsgBuf );\n\t// Free the buffer.\n\tLocalFree( lpMsgBuf );\n\tfree();\n\treturn false;\n}\n\n_QERTextureInfo* CPlugIn::getTextureInfo()\n{\n  if (m_pfnGetTextureInfo != NULL)\n  {\n    return reinterpret_cast<_QERTextureInfo*>((*m_pfnGetTextureInfo)());\n  }\n  return NULL;\n}\n\nvoid CPlugIn::loadTexture(LPCSTR pFilename)\n{\n  if (m_pfnLoadTexture != NULL)\n  {\n    (*m_pfnLoadTexture)(pFilename);\n  }\n}\n\nLPVOID CPlugIn::getSurfaceFlags()\n{\n  if (m_pfnGetSurfaceFlags != NULL)\n  {\n    return reinterpret_cast<LPVOID>((*m_pfnGetSurfaceFlags)());\n  }\n  return NULL;\n}\n\nvoid CPlugIn::free()\n{\n  if (m_hDLL != NULL)\n    ::FreeLibrary(m_hDLL);\n  m_hDLL = NULL;\n}\n\nconst char* CPlugIn::getVersionStr()\n{\n\treturn m_pfnGetName();\n}\n\nconst char* CPlugIn::getMenuName()\n{\n  return m_strName;\n}\n\nint CPlugIn::getCommandCount()\n{\n  return m_CommandStrings.GetSize();\n}\n\nconst char* CPlugIn::getCommand(int n)\n{\n  return m_CommandStrings.GetAt(n);\n}\n\nvoid CPlugIn::dispatchCommand(const char* p, vec3_t vMin, vec3_t vMax, BOOL bSingleBrush)\n{\n  if (m_pfnDispatch)\n  {\n    (*m_pfnDispatch)(p, vMin, vMax, bSingleBrush);\n  }\n}\n\nvoid CPlugIn::addMenuID(int n)\n{\n  m_CommandIDs.Add(n);\n}\n\nbool CPlugIn::ownsCommandID(int n)\n{\n  for (int i = 0; i < m_CommandIDs.GetSize(); i++)\n  {\n    if (m_CommandIDs.GetAt(i) == n)\n      return true;\n  }\n  return false;\n}\n\nvoid* CPlugIn::getFuncTable()\n{\n  if (m_pfnGetFuncTable)\n  {\n    return (*m_pfnGetFuncTable)();\n  }\n  return NULL;\n}\n\nvoid CPlugIn::RegisterPluginEntities()\n{\n\t// if we found the QERPlug_RegisterPluginEntities export, it means this plugin provides his own entities\n\tif (m_pfnRegisterPluginEntities)\n\t{\n\t\t// resquest a _QERPlugEntitiesFactory\n\t\tif (m_pfnRequestInterface)\n\t\t{\n\t\t\tm_pQERPlugEntitiesFactory = new _QERPlugEntitiesFactory;\n\t\t\tm_pQERPlugEntitiesFactory->m_nSize = sizeof(_QERPlugEntitiesFactory);\n\t\t\tif (m_pfnRequestInterface( QERPlugEntitiesFactory_GUID, m_pQERPlugEntitiesFactory ))\n\t\t\t{\n\t\t\t\t// create an IEpair interface for the project settings\n\t\t\t\tCEpairsWrapper *pProjectEp = new CEpairsWrapper( g_qeglobals.d_project_entity );\n\t\t\t\tm_pfnRegisterPluginEntities( pProjectEp );\n\t\t\t}\n\t\t\telse\n\t\t\t\tSys_Printf( \"WARNING: failed to request QERPlugEntitiesFactory from plugin %s\\n\", m_strName.GetBuffer(0) );\n\t\t}\n\t\telse\n\t\t\tSys_Printf( \"WARNING: QERPlug_RequestInterface not found in %s\\n\", m_strName.GetBuffer(0) );\n\t}\n}\n\nvoid CPlugIn::InitBSPFrontendPlugin()\n{\n\tif (m_pfnRequestInterface)\n\t{\n\t\t// request a _QERPlugBSPFrontendTable\n\t\tg_BSPFrontendTable.m_nSize = sizeof( _QERPlugBSPFrontendTable );\n\t\tif ( m_pfnRequestInterface( QERPlugBSPFrontendTable_GUID, &g_BSPFrontendTable ) )\n\t\t{\n\t\t\tg_qeglobals.bBSPFrontendPlugin = true;\n\t\t}\n\t}\n}\n\nvoid CPlugIn::InitSurfacePlugin()\n{\n\t// if we found the QERPlug_InitSurfaceProperties export, it means this plugin does surface properties\n\tif (m_pfnInitSurfaceProperties)\n\t{\n\t\tif (g_qeglobals.bSurfacePropertiesPlugin)\n\t\t{\n\t\t\tSys_Printf( \"WARNING: conflict for surface properties plugins. %s ignored.\\n\", m_strName );\n\t\t\treturn;\n\t\t}\n\t\tif (m_pfnRequestInterface)\n\t\t{\n\t\t\t// call the plugin surface properties init\n\t\t\tm_pfnInitSurfaceProperties();\n\t\t\t// request filling of the global _QERPlugSurfaceTable\n\t\t\tg_SurfaceTable.m_nSize = sizeof( g_SurfaceTable );\n\t\t\tif ( m_pfnRequestInterface( QERPlugSurfaceTable_GUID, &g_SurfaceTable ) )\n\t\t\t{\n\t\t\t\t// update the global so we know we have a surface properties plugin\n\t\t\t\tg_qeglobals.bSurfacePropertiesPlugin = true;\n\t\t\t}\n\t\t\telse\n\t\t\t\tSys_Printf( \"WARNING: _QERPlugSurfaceTable interface request failed for surface plugin\\n\" );\n\t\t}\n\t\telse\n\t\t\tSys_Printf(\"WARNING: QERPlug_RequestInterface export not found in surface properties plugin.\\n\");\n\t}\n}\n\n// create a plugin entity\n// e is the entity being created\n// e->eclass is the plugin eclass info\n// e->epairs will be accessed by the plugin entity through a IEpair interface\nIPluginEntity * CPlugIn::CreatePluginEntity(entity_t *e)\n{\n\tif (m_pQERPlugEntitiesFactory)\n\t{\n\t\t// create an IEpair interface for e->epairs\n\t\tCEpairsWrapper *pEp = new CEpairsWrapper( e );\n\t\tIPluginEntity *pEnt = m_pQERPlugEntitiesFactory->m_pfnCreateEntity( e->eclass, pEp );\n\t\tif ( pEnt )\n\t\t\treturn pEnt;\n\t\tdelete pEp;\n\t\treturn NULL;\n\t}\n\tSys_Printf(\"WARNING: unexpected m_pQERPlugEntitiesFactory is NULL in CPlugin::CreatePluginEntity\\n\");\n\treturn NULL;\n}\n"
  },
  {
    "path": "q3radiant/PlugIn.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// PlugIn.h: interface for the CPlugIn class.\n//\n//////////////////////////////////////////////////////////////////////\n\n#if !defined(AFX_PLUGIN_H__B501A832_5755_11D2_B084_00AA00A410FC__INCLUDED_)\n#define AFX_PLUGIN_H__B501A832_5755_11D2_B084_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n\nclass CPlugIn : public CObject\n{\nprivate:\n\tHMODULE m_hDLL;\n\tPFN_QERPLUG_INIT m_pfnInit;\n\tPFN_QERPLUG_GETNAME m_pfnGetName;\n\tPFN_QERPLUG_GETCOMMANDLIST m_pfnGetCommandList;\n\tPFN_QERPLUG_DISPATCH m_pfnDispatch;\n\tPFN_QERPLUG_GETFUNCTABLE m_pfnGetFuncTable;\n\tPFN_QERPLUG_GETTEXTUREINFO m_pfnGetTextureInfo;\n\tPFN_QERPLUG_LOADTEXTURE m_pfnLoadTexture;\n\tPFN_QERPLUG_GETSURFACEFLAGS m_pfnGetSurfaceFlags;\n\tPFN_QERPLUG_REGISTERPLUGINENTITIES m_pfnRegisterPluginEntities;\n\tPFN_QERPLUG_INITSURFACEPROPERTIES m_pfnInitSurfaceProperties;\n\tPFN_QERPLUG_REQUESTINTERFACE m_pfnRequestInterface;\n\tCWordArray m_CommandIDs;\n\tCStringArray m_CommandStrings;\n\tCString m_strName;\n\tCString m_strVersion;\n\t\n\t// for plugins that provide plugin entities\n\t_QERPlugEntitiesFactory* m_pQERPlugEntitiesFactory;\n\t\npublic:\n\tvoid InitBSPFrontendPlugin();\n\tIPluginEntity * CreatePluginEntity( entity_t * );\n\tHMODULE GetDLLModule() { return m_hDLL; }\n\tvoid InitSurfacePlugin();\n\tvoid RegisterPluginEntities();\n\tvoid* getFuncTable();\n\tbool ownsCommandID(int n);\n\tvoid addMenuID(int n);\n\tCPlugIn();\n\tvirtual ~CPlugIn();\n\tbool load(const char *p);\n\tvoid free();\n\tconst char* getVersionStr();\n\tconst char* getMenuName();\n\tint getCommandCount();\n\tconst char* getCommand(int n);\n\tvoid dispatchCommand(const char* p, vec3_t vMin, vec3_t vMax, BOOL bSingleBrush);\n\t\n\t_QERTextureInfo *getTextureInfo();\n\tvoid loadTexture(LPCSTR pFilename);\n\t\n\tLPVOID getSurfaceFlags();\n\t\n};\n\n#endif // !defined(AFX_PLUGIN_H__B501A832_5755_11D2_B084_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/PlugInManager.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// PlugInManager.cpp: implementation of the CPlugInManager class.\n//\n//////////////////////////////////////////////////////////////////////\n\n#include \"stdafx.h\"\n#include \"io.h\"\n#include \"Radiant.h\"\n#include \"PlugInManager.h\"\n#include \"PlugIn.h\"\n#include \"DialogInfo.h\"\n#include \"pakstuff.h\"\n\n#ifdef _DEBUG\n#undef THIS_FILE\nstatic char THIS_FILE[]=__FILE__;\n#define new DEBUG_NEW\n#endif\n\n//////////////////////////////////////////////////////////////////////\n// Construction/Destruction\n//////////////////////////////////////////////////////////////////////\n\nCPlugInManager::CPlugInManager()\n{\n  m_pTexturePlug = NULL;\n  m_pSurfaceListPlug = NULL;\n  PatchesMode = EActivePatches;\n}\n\nCPlugInManager::~CPlugInManager()\n{\n  Cleanup();\n}\n\nvoid CPlugInManager::Init(const char * pPath)\n{\n\tCleanup();\n\n\t// set some globals\n\tg_qeglobals.bSurfacePropertiesPlugin = false;\n\tg_qeglobals.bBSPFrontendPlugin = false;\n\t\n\tCString strPath(pPath);\n\tstrPath += \"*.dll\";\n\t\n\tbool bGo = true;\n\t\n\tstruct _finddata_t fileinfo;\n\tint handle = _findfirst (strPath, &fileinfo);\n\tif (handle != -1)\n\t{\n\t\tdo\n\t\t{\n\t\t\tstrPath.Format(\"%s\\\\%s\", pPath, fileinfo.name);\n\t\t\tCPlugIn *pPlug = new CPlugIn();\n\t\t\tif (pPlug->load(strPath))\n\t\t\t{\n\t\t\t\tif(FillFuncTable(pPlug))\t\t// PGM\n\t\t\t\t{\n\t\t\t\t\tm_PlugIns.Add(pPlug);\n\n\t\t\t\t\tpPlug->RegisterPluginEntities();\n\n\t\t\t\t\t// if this thing handles surface properties\n\t\t\t\t\tpPlug->InitSurfacePlugin();\n\t\t\t\t\t\n\t\t\t\t\t// will test and init if it's a BSP frontend\n\t\t\t\t\tpPlug->InitBSPFrontendPlugin();\n\n\t\t\t\t\tg_pParentWnd->AddPlugInMenuItem(pPlug);\n\t\t\t\t\t\n\t\t\t\t\t// if this thing handles textures\n\t\t\t\t\tif (pPlug->getTextureInfo() != NULL)\n\t\t\t\t\t{\n\t\t\t\t\t\tthis->m_pTexturePlug = pPlug;\n\t\t\t\t\t\t\n\t\t\t\t\t\t// if this is a wad style texture extension, have it load everything now\n\t\t\t\t\t\tif (pPlug->getTextureInfo()->m_bWadStyle)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tCString strPath = ValueForKey(g_qeglobals.d_project_entity, \"texturepath\");\n\t\t\t\t\t\t\tpPlug->loadTexture(strPath);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (pPlug->getSurfaceFlags() != NULL)\n\t\t\t\t\t{\n\t\t\t\t\t\tthis->m_pSurfaceListPlug = pPlug;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tdelete pPlug;\t\t\t\t// PGM\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tdelete pPlug;\n\t\t\t}\n\t\t} while (_findnext( handle, &fileinfo ) != -1);\n\t\t_findclose (handle);\n\t}\n\t\n}\n\nvoid CPlugInManager::Cleanup()\n{\n\tint i;\n\tfor (i = 0; i < m_PlugIns.GetSize(); i++)\n\t{\n\t\tCPlugIn *plug = reinterpret_cast<CPlugIn*>(m_PlugIns.GetAt(i));\n\t\tplug->free();\n\t\tdelete plug;\n\t}\n\tm_PlugIns.RemoveAll();\n\t\n\tfor (i = 0; i < m_BrushHandles.GetSize(); i++)\n\t{\n\t\tbrush_t *pb = reinterpret_cast<brush_t*>(m_BrushHandles.GetAt(i));\n\t\tBrush_Free(pb);\n\t}\n\tm_BrushHandles.RemoveAll();\n\t\n\tfor (i = 0; i < m_EntityHandles.GetSize(); i++)\n\t{\n\t\tentity_t *pe = reinterpret_cast<entity_t*>(m_EntityHandles.GetAt(i));\n\t\tEntity_Free(pe);\n\t}\n\tm_EntityHandles.RemoveAll();\n\t\n\t// patches\n\t// these are linked into the map\n\tm_PatchesHandles.RemoveAll();\n\t// these patches were allocated by Radiant on plugin request\n\t// if the list is not empty, it means either the plugin asked for allocation and never commited them to the map\n\t// in which case we are supposed to delete them\n\t// or it commited them but never called m_pfnReleasePatchHandles, in case the patches may have already been\n\t// erased and we are trying a second time, therefore crashing ..\n\t//++timo FIXME: for now I leave a leak warning, we'd need a table to keep track of commited patches\n#ifdef _DEBUG\n\tif (m_PluginPatches.GetSize() != 0)\n\t\tSys_Printf(\"WARNING: m_PluginPatches.GetSize() != 0 in CPlugInManager::Cleanup, possible leak\\n\");\n#endif\n/*\tfor (i = 0; i < m_PluginPatches.GetSize(); i++)\n\t{\n\t\tpatchMesh_t *pMesh = reinterpret_cast<patchMesh_t*>(m_PluginPatches.GetAt(i));\n\t\tif (pMesh->pSymbiot)\n\t\t\tdelete pMesh;\n\t}\n\tm_PluginPatches.RemoveAll(); */\n}\n\nvoid CPlugInManager::Dispatch(int n, const char * p)\n{\n  for (int i = 0; i < m_PlugIns.GetSize(); i++)\n  {\n    CPlugIn *plug = reinterpret_cast<CPlugIn*>(m_PlugIns.GetAt(i));\n    if (plug->ownsCommandID(n))\n    {\n      vec3_t vMin, vMax;\n    \tif (selected_brushes.next == &selected_brushes)\n      {\n        vMin[0] = vMin[1] = vMin[2] = 0;\n        VectorCopy(vMin, vMax);\n      }\n      else\n      {\n        Select_GetBounds (vMin, vMax);\n      }\n      plug->dispatchCommand(p, vMin, vMax, QE_SingleBrush(true));\t// PGM -- added quiet\n      break;\n    }\n  }\n}\n\n// creates a dummy brush in the active brushes list\n// FIXME : is this one really USED ?\nvoid WINAPI QERApp_CreateBrush(vec3_t vMin, vec3_t vMax)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\t\n\tbrush_t* pBrush = Brush_Create(vMin, vMax, &g_qeglobals.d_texturewin.texdef);\n\tEntity_LinkBrush (world_entity, pBrush);\n\tBrush_Build(pBrush);\n\tBrush_AddToList (pBrush, &active_brushes);\n\tSelect_Brush(pBrush);\n\tSys_UpdateWindows(W_ALL);\n}\n\nLPVOID CPlugInManager::CreateBrushHandle()\n{\n\tbrush_t *pb = Brush_Alloc();\n\tpb->numberId = g_nBrushId++;\n  m_BrushHandles.Add(pb);\n  return (LPVOID)pb;\n}\n\nvoid CPlugInManager::DeleteBrushHandle(void * vp)\n{\n  CPtrArray* pHandles[3];\n  pHandles[0] = &m_SelectedBrushHandles;\n  pHandles[1] = &m_ActiveBrushHandles;\n  pHandles[2] = &m_BrushHandles;\n\n  for (int j = 0; j < 3; j++)\n  {\n    for (int i = 0; i < pHandles[j]->GetSize(); i++)\n    {\n      brush_t *pb = reinterpret_cast<brush_t*>(pHandles[j]->GetAt(i));\n      if (pb == reinterpret_cast<brush_t*>(vp))\n      {\n        if (j == 2)\n        {\n          // only remove it from the list if it is work area\n          // this allows the selected and active list indexes to remain constant\n          // throughout a session (i.e. between an allocate and release)\n          pHandles[j]->RemoveAt(i);\n        }\n        Brush_Free(pb);\n\t\tSys_MarkMapModified();\t\t// PGM\n        return;\n      }\n    }\n  }\n}\n\nvoid CPlugInManager::CommitBrushHandleToMap(void * vp)\n{\n  g_bScreenUpdates = false; \n  for (int i = 0; i < m_BrushHandles.GetSize(); i++)\n  {\n    brush_t *pb = reinterpret_cast<brush_t*>(m_BrushHandles.GetAt(i));\n    if (pb == reinterpret_cast<brush_t*>(vp))\n    {\n      m_BrushHandles.RemoveAt(i);\n\t  Entity_LinkBrush (world_entity, pb);\n      Brush_Build(pb);\n\t  Brush_AddToList (pb, &active_brushes);\n      Select_Brush(pb);\n    }\n  }\n  g_bScreenUpdates = true; \n  Sys_UpdateWindows(W_ALL);\n}\n\nvoid CPlugInManager::AddFaceToBrushHandle(void * vp, vec3_t v1, vec3_t v2, vec3_t v3)\n{\n  brush_t *bp = FindBrushHandle(vp);\n  if (bp != NULL)\n  {\n\t\tface_t *f = Face_Alloc();\n\t\tf->texdef = g_qeglobals.d_texturewin.texdef;\n\t\tf->texdef.flags &= ~SURF_KEEP;\n\t\tf->texdef.contents &= ~CONTENTS_KEEP;\n\t\tf->next = bp->brush_faces;\n\t\tbp->brush_faces = f;\n\t\tVectorCopy (v1, f->planepts[0]);\n\t\tVectorCopy (v2, f->planepts[1]);\n\t\tVectorCopy (v3, f->planepts[2]);\n  }\n}\n\nbrush_t* CPlugInManager::FindBrushHandle(void * vp)\n{\n  CPtrArray* pHandles[4];\n  pHandles[0] = &m_SelectedBrushHandles;\n  pHandles[1] = &m_ActiveBrushHandles;\n  pHandles[2] = &m_BrushHandles;\n  pHandles[3] = &m_EntityBrushHandles;\n\n  for (int j = 0; j < 4; j++)\n  {\n    for (int i = 0; i < pHandles[j]->GetSize(); i++)\n    {\n      brush_t *pb = reinterpret_cast<brush_t*>(pHandles[j]->GetAt(i));\n      if (pb == reinterpret_cast<brush_t*>(vp))\n      {\n        return pb;\n      }\n    }\n  }\n  return NULL;\n}\n\npatchMesh_t* CPlugInManager::FindPatchHandle(int index)\n{\n\tswitch (PatchesMode)\n\t{\n\tcase EActivePatches:\n\tcase ESelectedPatches:\n\t\tif ( index < m_PatchesHandles.GetSize() )\n\t\t{\n\t\t\tbrush_t *pb = reinterpret_cast<brush_t *>(m_PatchesHandles.GetAt(index));\n\t\t\treturn pb->pPatch;\n\t\t}\n#ifdef _DEBUG\n\t\tSys_Printf(\"WARNING: out of bounds in CPlugInManager::FindPatchHandle\\n\");\n#endif\n\t\tbreak;\n\tcase EAllocatedPatches:\n\t\tif ( index < m_PluginPatches.GetSize() )\n\t\t{\n\t\t\tpatchMesh_t *pPatch = reinterpret_cast<patchMesh_t *>(m_PluginPatches.GetAt(index));\n\t\t\treturn pPatch;\n\t\t}\n#ifdef _DEBUG\n\t\tSys_Printf(\"WARNING: out of bounds in CPlugInManager::FindPatchHandle\\n\");\n#endif\n\t\tbreak;\n\t}\n\treturn NULL;\n}\n\nLPVOID WINAPI QERApp_CreateBrushHandle()\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  return g_pParentWnd->GetPlugInMgr().CreateBrushHandle();\n}\n\nvoid WINAPI QERApp_DeleteBrushHandle(LPVOID vp)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  g_pParentWnd->GetPlugInMgr().DeleteBrushHandle(vp);\n}\n\nvoid WINAPI QERApp_CommitBrushHandleToMap(LPVOID vp)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  g_pParentWnd->GetPlugInMgr().CommitBrushHandleToMap(vp);\n}\n\nvoid WINAPI QERApp_AddFace(LPVOID vp, vec3_t v1, vec3_t v2, vec3_t v3)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  g_pParentWnd->GetPlugInMgr().AddFaceToBrushHandle(vp, v1, v2, v3);\n}\n\nvoid WINAPI QERApp_DeleteSelection()\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  Select_Delete();\n}\n\nvoid WINAPI QERApp_SysMsg(LPCSTR pMsg)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  CString str = pMsg;\n  Sys_Printf(str.GetBuffer(0));\n}\n\n// NOTE: called only in case of plugin error. We can try a plugin refresh instead of a straight crash ?\nvoid WINAPI QERApp_ErrorMsg(LPCSTR pMsg)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tCString str = pMsg;\n\tError(str.GetBuffer(0));\n}\n\nvoid WINAPI QERApp_InfoMsg(LPCSTR pMsg)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  ShowInfoDialog(pMsg);\n}\n\nvoid WINAPI QERApp_HideInfoMsg()\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  HideInfoDialog();\n}\n\n//=====\n//PGM\nvoid WINAPI QERApp_PositionView(vec3_t\tv1, vec3_t v2)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tg_pParentWnd->ActiveXY()->SetOrigin(v1);\n\t// FIXME - implement this!\n\tSys_UpdateWindows(W_ALL);\n}\n//PGM\n//=====\n\n//FIXME: this AcquirePath stuff is pretty much a mess and needs cleaned up\nbool g_bPlugWait = false;\nbool g_bPlugOK = false;\nint  g_nPlugCount = 0;\n\nvoid _PlugDone(bool b, int n)\n{\n  g_bPlugWait = false;\n  g_bPlugOK = b;\n  g_nPlugCount = n;\n}\n\nvoid WINAPI QERApp_GetPoints(int nMax, _QERPointData *pData, LPCSTR pMsg)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  ShowInfoDialog(pMsg);\n  g_bPlugWait = true;\n  g_bPlugOK = false;\n  g_nPlugCount = 0;\n//  g_nPlugCount=nMax-1;\n  AcquirePath(nMax, &_PlugDone);\n  while (g_bPlugWait)\n  {\n    MSG msg;\n    if (::PeekMessage( &msg, NULL, 0, 0, PM_REMOVE )) \n    { \n      TranslateMessage(&msg);\n      DispatchMessage(&msg);\n    }\n  }\n  HideInfoDialog();\n  \n  pData->m_nCount = 0;\n  pData->m_pVectors = NULL;\n\n  if (g_bPlugOK && g_nPlugCount > 0)\n  {\n    pData->m_nCount = g_nPlugCount;\n    pData->m_pVectors = reinterpret_cast<vec3_t*>(qmalloc(g_nPlugCount * sizeof(vec3_t)));\n    vec3_t *pOut = pData->m_pVectors;\n    for (int i = 0; i < g_nPlugCount; i++)\n    {\n\tmemcpy(pOut, &g_PathPoints[i],sizeof(vec3_t));\n\tpOut++;\n    }\n  }\n}\n\nvoid WINAPI QERApp_AddFaceData(LPVOID pv, _QERFaceData *pData)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\n\tbrush_t* pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle(pv);\n  if (pBrush != NULL)\n  {\n\t\tface_t *f = Face_Alloc();\n\t\tf->texdef = g_qeglobals.d_texturewin.texdef;\n\t\tf->texdef.flags = pData->m_nFlags;\n    f->texdef.contents = pData->m_nContents;\n    f->texdef.value = pData->m_nValue;\n    f->texdef.rotate = pData->m_fRotate;\n    f->texdef.shift[0] = pData->m_fShift[0];\n    f->texdef.shift[1] = pData->m_fShift[1];\n    f->texdef.scale[0] = pData->m_fScale[0];\n    f->texdef.scale[1] = pData->m_fScale[1];\n    //strcpy(f->texdef.name, pData->m_TextureName);\n    f->texdef.SetName(pData->m_TextureName);\n\t\tf->next = pBrush->brush_faces;\n\t\tpBrush->brush_faces = f;\n\t\tVectorCopy (pData->m_v1, f->planepts[0]);\n\t\tVectorCopy (pData->m_v2, f->planepts[1]);\n\t\tVectorCopy (pData->m_v3, f->planepts[2]);\n\t\tSys_MarkMapModified();\t\t// PGM\n  }\n}\n\nint WINAPI QERApp_GetFaceCount(LPVOID pv)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  int n = 0;\n  brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle(pv);\n  if (pBrush != NULL)\n  {\n\t  for (face_t *f = pBrush->brush_faces ; f; f = f->next)\n    {\n      n++;\n    }\n  }\n  return n;\n}\n\n_QERFaceData* WINAPI QERApp_GetFaceData(LPVOID pv, int nFaceIndex)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  static _QERFaceData face;\n  int n = 0;\n  brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle(pv);\n\n  if (pBrush != NULL)\n  {\n    for (face_t *f = pBrush->brush_faces ; f; f = f->next)\n    {\n\n#ifdef _DEBUG\n\t\tif (!pBrush->brush_faces)\n\t\t{\n\t\t\tSys_Printf( \"Warning : pBrush->brush_faces is NULL in QERApp_GetFaceData\\n\" );\n\t\t\treturn NULL;\n\t\t}\n#endif\n\n      if (n == nFaceIndex)\n      {\n        face.m_nContents = f->texdef.contents;\n        face.m_nFlags = f->texdef.flags;\n        face.m_fRotate = f->texdef.rotate;\n        face.m_fScale[0] = f->texdef.scale[0];\n        face.m_fScale[1] = f->texdef.scale[1];\n        face.m_fShift[0] = f->texdef.shift[0];\n        face.m_fShift[1] = f->texdef.shift[1];\n        face.m_nValue = f->texdef.value;\n        strcpy(face.m_TextureName, f->texdef.name);\n        VectorCopy(f->planepts[0], face.m_v1);\n        VectorCopy(f->planepts[1], face.m_v2);\n        VectorCopy(f->planepts[2], face.m_v3);\n        return &face;\n      }\n      n++;\n    }\n  }\n  return NULL;\n}\n\nvoid WINAPI QERApp_SetFaceData(LPVOID pv, int nFaceIndex, _QERFaceData *pData)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tint n = 0;\n\tbrush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle(pv);\n\n\tif (pBrush != NULL)\n\t{\n\t\tfor (face_t *f = pBrush->brush_faces ; f; f = f->next)\n\t\t{\n\t\t\tif (n == nFaceIndex)\n\t\t\t{\n\t\t\t\tf->texdef.flags = pData->m_nFlags;\n\t\t\t\tf->texdef.contents = pData->m_nContents;\n\t\t\t\tf->texdef.value = pData->m_nValue;\n\t\t\t\tf->texdef.rotate = pData->m_fRotate;\n\t\t\t\tf->texdef.shift[0] = pData->m_fShift[0];\n\t\t\t\tf->texdef.shift[1] = pData->m_fShift[1];\n\t\t\t\tf->texdef.scale[0] = pData->m_fScale[0];\n\t\t\t\tf->texdef.scale[1] = pData->m_fScale[1];\n\t\t\t\t//strcpy(f->texdef.name, pData->m_TextureName);\n\t\t\t\tf->texdef.SetName(pData->m_TextureName);\n\t\t\t\tVectorCopy(pData->m_v1, f->planepts[0]);\n\t\t\t\tVectorCopy(pData->m_v2, f->planepts[1]);\n\t\t\t\tVectorCopy(pData->m_v3, f->planepts[2]);\n\t\t\t\tSys_MarkMapModified();\t\t// PGM\n\t\t\t\treturn;\t\t\t\t\t\t// PGM\n\t\t\t}\n\t\t\tn++;\n\t\t}\n\t}\n}\n\nvoid WINAPI QERApp_DeleteFace(LPVOID pv, int nFaceIndex)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  int n = 0;\n  brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle(pv);\n  if (pBrush != NULL)\n  {\n    face_t *pPrev = pBrush->brush_faces;\n\t  for (face_t *f = pBrush->brush_faces; f; f = f->next)\n    {\n      if (n == nFaceIndex)\n      {\n        pPrev->next = f->next;\n\t\t\t  Face_Free (f);\n\t\tSys_MarkMapModified();\t\t// PGM\n        return;\n      }\n      n++;\n      pPrev = f;\n    }\n  }\n}\n\n//==========\n//PGM\nvoid WINAPI QERApp_BuildBrush (LPVOID pv)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tbrush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle(pv);\n\tif (pBrush != NULL)\n\t{\n\t\tBrush_Build(pBrush);\n\t\tSys_UpdateWindows(W_ALL);\n\t}\n}\n\n//Timo : another version with bConvert flag\n//++timo since 1.7 is not compatible with earlier plugin versions, remove this one and update QERApp_BuildBrush\nvoid WINAPI QERApp_BuildBrush2 (LPVOID pv, int bConvert)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tbrush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle(pv);\n\tif (pBrush != NULL)\n\t{\n\t\tBrush_Build( pBrush, true, true, bConvert );\n\t\tSys_UpdateWindows(W_ALL);\n\t}\n}\n\nvoid WINAPI QERApp_SelectBrush (LPVOID pv)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tbrush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle(pv);\n\tif (pBrush != NULL)\n\t{\n\t\tSelect_Brush(pBrush, false);\n\t\tSys_UpdateWindows(W_ALL);\n\t}\n\n}\n\nvoid WINAPI QERApp_DeselectBrush (LPVOID pv)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\t// FIXME - implement this!\n}\n\nvoid WINAPI QERApp_ResetPlugins()\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  g_pParentWnd->OnPluginsRefresh();\n}\n\nvoid WINAPI QERApp_DeselectAllBrushes ()\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tSelect_Deselect();\n\tSys_UpdateWindows(W_ALL);\n}\n//PGM\n//==========\n\nvoid WINAPI QERApp_TextureBrush(LPVOID pv, LPCSTR pName)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle(pv);\n  if (pBrush != NULL)\n  {\n\t  for (face_t *f = pBrush->brush_faces ; f; f = f->next)\n    {\n      //strcpy(f->texdef.name, pName);\n      f->texdef.SetName(pName);\n    }\n    Sys_MarkMapModified();\t\t// PGM\n  }\n}\n\nint WINAPI QERApp_SelectedBrushCount()\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  int n = 0;\n\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    n++;\n  }\n  return n;\n}\n\nint WINAPI QERApp_ActiveBrushCount()\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  int n = 0;\n\tfor (brush_t *pb = active_brushes.next ; pb != &active_brushes ; pb = pb->next)\n\t{\n    n++;\n  }\n  return n;\n}\n\nint WINAPI QERApp_AllocateSelectedBrushHandles()\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  int n = 0;\n\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n    n++;\n    g_pParentWnd->GetPlugInMgr().GetSelectedHandles().Add(pb);\n  }\n  return n;\n}\n\nint WINAPI QERApp_AllocateActiveBrushHandles()\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  int n = 0;\n\tfor (brush_t *pb = active_brushes.next ; pb != &active_brushes ; pb = pb->next)\n\t{\n    n++;\n    g_pParentWnd->GetPlugInMgr().GetActiveHandles().Add(pb);\n  }\n  return n;\n}\n\nvoid WINAPI QERApp_ReleaseSelectedBrushHandles()\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  g_pParentWnd->GetPlugInMgr().GetSelectedHandles().RemoveAll();\n  Sys_UpdateWindows(W_ALL);\n}\n\nvoid WINAPI QERApp_ReleaseActiveBrushHandles()\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  g_pParentWnd->GetPlugInMgr().GetActiveHandles().RemoveAll();\n  Sys_UpdateWindows(W_ALL);\n}\n\nLPVOID WINAPI QERApp_GetActiveBrushHandle(int nIndex)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  if (nIndex < g_pParentWnd->GetPlugInMgr().GetActiveHandles().GetSize())\n  {\n    return reinterpret_cast<LPVOID>(g_pParentWnd->GetPlugInMgr().GetActiveHandles().GetAt(nIndex));\n  }\n  return NULL;\n}\n\nLPVOID WINAPI QERApp_GetSelectedBrushHandle(int nIndex)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  if (nIndex < g_pParentWnd->GetPlugInMgr().GetSelectedHandles().GetSize())\n  {\n    return reinterpret_cast<LPVOID>(g_pParentWnd->GetPlugInMgr().GetSelectedHandles().GetAt(nIndex));\n  }\n  return NULL;\n}\n\nint WINAPI QERApp_TextureCount()\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tTexture_StartPos ();\n  int x, y;\n  int n = 0;\n\twhile (1)\n\t{\n\t\tqtexture_t *q = Texture_NextPos (&x, &y);\n\t\tif (!q)\n\t\t\tbreak;\n    n++;\n  }\n  return n;\n}\n\nLPCSTR WINAPI QERApp_GetTexture(int nIndex)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  static char name[QER_MAX_NAMELEN];\n\tTexture_StartPos ();\n  int x, y;\n  int n = 0;\n\twhile (1)\n\t{\n\t\tqtexture_t *q = Texture_NextPos (&x, &y);\n\t\tif (!q)\n\t\t\tbreak;\n    if (n == nIndex)\n    {\n      strcpy(name, q->name);\n      return name;\n    }\n    n++;\n  }\n  return NULL;\n}\n\nLPCSTR WINAPI QERApp_GetCurrentTexture()\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  return g_qeglobals.d_texturewin.texdef.name;\n}\n\nvoid WINAPI QERApp_SetCurrentTexture(LPCSTR strName)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\t//++timo hu ?? tex is not initialized ?? can be any value ..\n  texdef_t tex;\n  //++timo added a brushprimit_texdef ..\n  // smthg to be done here\n  brushprimit_texdef_t brushprimit_tex;\n  //strcpy(tex.name, strName);\n  tex.SetName(strName);\n  Texture_SetTexture(&tex,&brushprimit_tex);\n}\n\nint WINAPI QERApp_GetEClassCount()\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  int n = 0;\n  for (eclass_t *e = eclass ; e ; e = e->next)\n\t{\n    n++;\n  }\n  return n;\n}\n\nLPCSTR WINAPI QERApp_GetEClass(int nIndex)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n  int n = 0;\n  for (eclass_t *e = eclass ; e ; e = e->next)\n\t{\n    if (n == nIndex)\n    {\n      return e->name;\n    }\n  }\n  return NULL;\n}\n\nvoid WINAPI QERApp_LoadTextureRGBA(LPVOID vp)\n{\n  Texture_LoadFromPlugIn(vp);\n}\n\n// v1.70 code\n// world_entity holds the worldspawn and is indexed as 0\n// other entities are in the entities doubly linked list\n// QERApp_GetEntityCount counts the entities like in any C array: [0..length-1]\nint WINAPI QERApp_GetEntityCount()\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tint n = 1;\n\tfor (entity_t *pe = entities.next ; pe != &entities ; pe = pe->next)\n\t{\n\t\tn++;\n\t}\n\treturn n;\n}\n\n// We don't store entities in CPtrArray, we need to walk the list\nLPVOID WINAPI QERApp_GetEntityHandle(int nIndex)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tif (nIndex==0)\n\t\t// looks for the worldspawn\n\t\treturn static_cast<LPVOID>(world_entity);\n\tentity_t *pe = &entities;\n\tint n = 0;\n\twhile ( n < nIndex )\n\t{\n\t\tpe = pe->next;\n\t\tn++;\n\t}\n\treturn static_cast<LPVOID>(pe);\n}\n\nepair_t** WINAPI QERApp_GetEntityKeyValList(LPVOID vp)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tentity_t *pe = static_cast<entity_t *>(vp);\n\treturn &pe->epairs;\n}\n\nepair_t* WINAPI QERApp_AllocateEpair( char *key, char *val )\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tepair_t *e = (epair_t*)qmalloc (sizeof(*e));\n\te->key = (char*)qmalloc(strlen(key)+1);\n\tstrcpy (e->key, key);\n\te->value = (char*)qmalloc(strlen(val)+1);\n\tstrcpy (e->value, val);\n\treturn e;\n}\n\nvoid WINAPI QERApp_SetEntityKeyValList(LPVOID vp, epair_t* ep)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tentity_t *pe = static_cast<entity_t *>(vp);\n\tif (pe->epairs)\n\t\tSys_Printf( \"Warning : pe->epairs != NULL in QERApp_SetEntityKeyValList, will not set\\n\" );\n\telse\n\t\tpe->epairs = ep;\n}\n\nint WINAPI QERApp_AllocateEntityBrushHandles(LPVOID vp)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tentity_t *pe = static_cast<entity_t *>(vp);\n\tint n = 0;\n\tif (!pe->brushes.onext)\n\t\treturn 0;\n\tg_pParentWnd->GetPlugInMgr().GetEntityBrushHandles().RemoveAll();\n\tfor (brush_t *pb = pe->brushes.onext ; pb != &pe->brushes ; pb=pb->onext)\n\t{\n\t\tn++;\n\t\tg_pParentWnd->GetPlugInMgr().GetEntityBrushHandles().Add(pb);\n\t}\n\treturn n;\n}\n\t\nvoid WINAPI QERApp_ReleaseEntityBrushHandles()\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tg_pParentWnd->GetPlugInMgr().GetEntityBrushHandles().RemoveAll();\n}\n\nLPVOID WINAPI QERApp_GetEntityBrushHandle(int nIndex)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tif (nIndex < g_pParentWnd->GetPlugInMgr().GetEntityBrushHandles().GetSize())\n\t\treturn g_pParentWnd->GetPlugInMgr().GetEntityBrushHandles().GetAt(nIndex);\n\treturn NULL;\n}\n\nLPVOID WINAPI QERApp_CreateEntityHandle()\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tentity_t *pe = reinterpret_cast<entity_t*>(qmalloc(sizeof(entity_t)));\n\tpe->brushes.onext = pe->brushes.oprev = &pe->brushes;\n\tg_pParentWnd->GetPlugInMgr().GetEntityHandles().Add(static_cast<LPVOID>(pe));\n\treturn static_cast<LPVOID>(pe);\n}\n\n// the vpBrush needs to be in m_BrushHandles\n//++timo we don't have allocation nor storage for vpEntity, no checks for this one\nvoid WINAPI QERApp_CommitBrushHandleToEntity(LPVOID vpBrush, LPVOID vpEntity)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tg_pParentWnd->GetPlugInMgr().CommitBrushHandleToEntity(vpBrush, vpEntity);\n\treturn;\n}\n\nchar* WINAPI QERApp_ReadProjectKey(char* key)\n{\n\treturn ValueForKey(g_qeglobals.d_project_entity, key);\n}\n\nint WINAPI QERApp_ScanFileForEClass(char *filename )\n{\n\t// set single class parsing\n\tparsing_single = true;\n\tEclass_ScanFile(filename);\n\tif (eclass_found)\n\t{\n\t\teclass_e->nShowFlags |= ECLASS_PLUGINENTITY;\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\n// the vpBrush needs to be in m_BrushHandles\n//++timo add a debug check to see if we found the brush handle\n// NOTE : seems there's no way to check vpEntity is valid .. this is dangerous\n// links the brush to its entity, everything else is done when commiting the entity to the map\nvoid CPlugInManager::CommitBrushHandleToEntity(LPVOID vpBrush, LPVOID vpEntity)\n{\n\tbrush_t* pb;\n\tentity_t* pe;\n\tfor (int i=0 ; i < m_BrushHandles.GetSize() ; i++)\n\t{\n\t\tif (vpBrush == m_BrushHandles.GetAt(i))\n\t\t{\n\t\t\tm_BrushHandles.RemoveAt(i);\n\t\t\tpb = reinterpret_cast<brush_t*>(vpBrush);\n\t\t\tpe = reinterpret_cast<entity_t *>(vpEntity);\n\t\t\tEntity_LinkBrush (pe, pb);\n\t\t}\n\t}\n\tSys_UpdateWindows(W_ALL);\n}\n\n// the vpEntity must be in m_EntityHandles\nvoid WINAPI QERApp_CommitEntityHandleToMap(LPVOID vpEntity)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tg_pParentWnd->GetPlugInMgr().CommitEntityHandleToMap(vpEntity);\n\treturn;\n}\n\nint WINAPI QERApp_LoadFile( const char *pLocation, void ** buffer )\n{\n\tchar cPath[1024];\n\tsprintf( cPath, \"%s/%s\", ValueForKey(g_qeglobals.d_project_entity, \"basepath\"), pLocation);\n  int nSize = LoadFile( cPath, buffer);\n  if (nSize == -1)\n  {\n    nSize = PakLoadAnyFile(cPath, buffer);\n  }\n\treturn nSize;\n}\n\nchar * WINAPI QERApp_ExpandReletivePath (char *p)\n{\n\treturn ExpandReletivePath(p);\n}\n\n// NOTE: this is a simplified version\nint WINAPI QERApp_HasShader( const char *pName )\n{\n\tCShaderInfo *pInfo = hasShader( pName );\n\tif (pInfo)\n\t\treturn 1;\n\treturn 0;\n}\n\nqtexture_t* WINAPI QERApp_Texture_ForName (const char *name)\n{\n\t// if the texture is not loaded yet, this call will get it loaded\n\t// but: when we assign a GL bind number, we need to be in the g_qeglobals.d_hdcBase , g_qeglobals.d_hglrcBase GL context\n\t// the plugin may set the GL context to whatever he likes, but then load would fail\n\t// NOTE: is context switching time-consuming? then maybe the plugin could handle the context switch and only add a \n\t// sanity check in debug mode here\n\t// read current context\n\tHDC pluginHDC = qwglGetCurrentDC();\n\tHGLRC pluginHGLRC = qwglGetCurrentContext();\n\tqwglMakeCurrent( g_qeglobals.d_hdcBase, g_qeglobals.d_hglrcBase );\n\tqtexture_t* qtex = Texture_ForName( name );\n\treturn qtex;\n\tqwglMakeCurrent( pluginHDC, pluginHGLRC );\n}\n\nvoid WINAPI QERApp_RadiantFree( void * buf )\n{\n\tfree( buf );\n}\n\nchar* WINAPI QERApp_Token()\n{\n\treturn token;\n}\n\nchar* WINAPI QERApp_GetMapName()\n{\n\treturn currentmap;\n}\n\nvoid CPlugInManager::CommitEntityHandleToMap(LPVOID vpEntity)\n{\n\tentity_t *pe;\n\teclass_t *e;\n\tbrush_t\t\t*b;\n\tvec3_t mins,maxs;\n\tbool has_brushes;\n\tfor (int i=0 ; i < m_EntityHandles.GetSize() ; i++ )\n\t{\n\t\tif (vpEntity == m_EntityHandles.GetAt(i))\n\t\t{\n\t\t\tm_EntityHandles.RemoveAt(i);\n\t\t\tpe = reinterpret_cast<entity_t*>(vpEntity);\n\t\t\t// fill additional fields\n\t\t\t// straight copy from Entity_Parse\n\t\t\t// entity_t::origin\n\t\t\tGetVectorForKey (pe, \"origin\", pe->origin);\n\t\t\t// entity_t::eclass\n\t\t\tif (pe->brushes.onext == &pe->brushes)\n\t\t\t\thas_brushes = false;\n\t\t\telse\n\t\t\t\thas_brushes = true;\n\t\t\te = Eclass_ForName (ValueForKey (pe, \"classname\"), has_brushes);\n\t\t\tpe->eclass = e;\n\t\t\t// fixedsize\n\t\t\tif (e->fixedsize)\n\t\t\t{\n\t\t\t\tif (pe->brushes.onext != &pe->brushes)\n\t\t\t\t{\n\t\t\t\t\tSys_Printf(\"Warning : Fixed size entity with brushes in CPlugInManager::CommitEntityHandleToMap\\n\");\n\t\t\t\t}\n\t\t\t\t// create a custom brush\n\t\t\t\tVectorAdd(e->mins, pe->origin, mins);\n\t\t\t\tVectorAdd(e->maxs, pe->origin, maxs);\n\t\t\t\tfloat a = 0;\n\t\t\t\tif (e->nShowFlags & ECLASS_MISCMODEL)\n\t\t\t\t{\n\t\t\t\t\tchar* p = ValueForKey(pe, \"model\");\n\t\t\t\t\tif (p != NULL && strlen(p) > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tvec3_t vMin, vMax;\n\t\t\t\t\t\ta = FloatForKey (pe, \"angle\");\n\t\t\t\t        if (GetCachedModel(pe, p, vMin, vMax))\n\t\t\t\t        {\n\t\t\t\t\t\t      // create a custom brush\n\t\t\t\t\t\t      VectorAdd (pe->md3Class->mins, pe->origin, mins);\n\t\t\t\t\t\t      VectorAdd (pe->md3Class->maxs, pe->origin, maxs);\n\t\t\t\t        }\n\t\t\t\t\t}\n\t\t\t    }\n\t\t\n\t\t\t    b = Brush_Create (mins, maxs, &e->texdef);\n\n\t\t\t    if (a)\n\t\t\t    {\n\t\t\t\t\tvec3_t vAngle;\n\t\t\t\t\tvAngle[0] = vAngle[1] = 0;\n\t\t\t\t\tvAngle[2] = a;\n\t\t\t\t\tBrush_Rotate(b, vAngle, pe->origin, false);\n\t\t\t\t}\n\n\t\t\t\tb->owner = pe;\n\n\t\t\t\tb->onext = pe->brushes.onext;\n\t\t\t\tb->oprev = &pe->brushes;\n\t\t\t\tpe->brushes.onext->oprev = b;\n\t\t\t\tpe->brushes.onext = b;\n\t\t\t}\n\t\t\telse\n\t\t\t{\t// brush entity\n\t\t\t\tif (pe->brushes.next == &pe->brushes)\n\t\t\t\t\tSys_Printf (\"Warning: Brush entity with no brushes in CPlugInManager::CommitEntityHandleToMap\\n\");\n\t\t\t}\n\n\t\t\t// add brushes to the active brushes list\n\t\t\t// and build them along the way\n\t\t\tfor (b=pe->brushes.onext ; b != &pe->brushes ; b=b->onext)\n\t\t\t{\n\t\t\t\t// convert between old brushes and brush primitive\n\t\t\t\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\t\t\t{\n\t\t\t\t\t// we only filled the shift scale rot fields, needs conversion\n\t\t\t\t\tBrush_Build( b, true, true, true );\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t// we are using old brushes\n\t\t\t\t\tBrush_Build( b );\n\t\t\t\t}\n\t\t\t\tb->next = active_brushes.next;\n\t\t\t\tactive_brushes.next->prev = b;\n\t\t\t\tb->prev = &active_brushes;\n\t\t\t\tactive_brushes.next = b;\n\t\t\t}\n\n\t\t\t// handle worldspawn entities\n\t\t\t// if worldspawn has no brushes, use the new one\n\t\t\tif (!strcmp(ValueForKey (pe, \"classname\"), \"worldspawn\"))\n\t\t\t{\n\t\t\t\tif ( world_entity && ( world_entity->brushes.onext != &world_entity->brushes ) )\n\t\t\t\t{\n\t\t\t\t\t// worldspawn already has brushes\n\t\t\t\t\tSys_Printf (\"Commiting worldspawn as func_group\\n\");\n\t\t\t\t\tSetKeyValue(pe, \"classname\", \"func_group\");\n\t\t\t\t\t// add the entity to the end of the entity list\n\t\t\t\t\tpe->next = &entities;\n\t\t\t\t\tpe->prev = entities.prev;\n\t\t\t\t\tentities.prev->next = pe;\n\t\t\t\t\tentities.prev = pe;\n\t\t\t\t\tg_qeglobals.d_num_entities++;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t// there's a worldspawn with no brushes, we assume the map is empty\n\t\t\t\t\tif ( world_entity )\n\t\t\t\t\t{\n\t\t\t\t\t\tEntity_Free( world_entity );\n\t\t\t\t\t\tworld_entity = pe;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tSys_Printf(\"Warning : unexpected world_entity == NULL in CommitEntityHandleToMap\\n\");\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t// add the entity to the end of the entity list\n\t\t\t\tpe->next = &entities;\n\t\t\t\tpe->prev = entities.prev;\n\t\t\t\tentities.prev->next = pe;\n\t\t\t\tentities.prev = pe;\n\t\t\t\tg_qeglobals.d_num_entities++;\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid WINAPI QERApp_SetScreenUpdate(int bScreenUpdates)\n{\n\tg_bScreenUpdates = bScreenUpdates; \n}\n\ntexturewin_t* WINAPI QERApp_QeglobalsTexturewin()\n{\n\treturn &g_qeglobals.d_texturewin;\n}\n\n_QERTextureInfo* CPlugInManager::GetTextureInfo()\n{\n  if (m_pTexturePlug != NULL)\n  {\n    return m_pTexturePlug->getTextureInfo();\n  }\n  else\n  {\n    return NULL;\n  }\n}\n\nLPVOID CPlugInManager::GetSurfaceFlags()\n{\n  if (m_pSurfaceListPlug != NULL)\n  {\n    return m_pSurfaceListPlug->getSurfaceFlags();\n  }\n  else\n  {\n    return NULL;\n  }\n}\n\nvoid CPlugInManager::LoadTexture(const char *pFilename)\n{\n  if (m_pTexturePlug != NULL)\n  {\n    m_pTexturePlug->loadTexture(pFilename);\n  }\n}\n\npatchMesh_t* WINAPI QERApp_GetSelectedPatch( )\n{\n\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n\t\tif (pb->patchBrush)\n\t\t{\n\t\t\treturn pb->pPatch;\n\t\t}\n\t}\n#ifdef _DEBUG\n\tSys_Printf(\"WARNING: QERApp_GetSelectedPatchTexdef called with no patch selected\\n\");\n#endif\n\treturn NULL;\n}\n\nchar* WINAPI QERApp_GetGamePath()\n{\n\treturn g_PrefsDlg.m_strQuake2.GetBuffer(0);\n}\n\nchar* WINAPI QERApp_GetQERPath()\n{\n\treturn g_strAppPath.GetBuffer(0);\n}\n\n// patches in/out -----------------------------------\nint WINAPI QERApp_AllocateActivePatchHandles()\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\treturn g_pParentWnd->GetPlugInMgr().AllocateActivePatchHandles();\n}\n\nint CPlugInManager::AllocateActivePatchHandles()\n{\n\tint n = 0;\n\tfor (brush_t *pb = active_brushes.next ; pb != &active_brushes ; pb = pb->next)\n\t{\n\t\tif (pb->patchBrush)\n\t\t{\n\t\t\tn++;\n\t\t\tm_PatchesHandles.Add(pb);\n\t\t}\n\t}\n\treturn n;\n}\n\nint WINAPI QERApp_AllocateSelectedPatchHandles()\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\treturn g_pParentWnd->GetPlugInMgr().AllocateSelectedPatchHandles();\n}\n\t\nint CPlugInManager::AllocateSelectedPatchHandles()\n{\n\tint n = 0;\n\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n\t\tif (pb->patchBrush)\n\t\t{\n\t\t\tn++;\n\t\t\tm_PatchesHandles.Add(pb);\n\t\t}\n\t}\n\treturn n;\n}\n\nvoid WINAPI QERApp_ReleasePatchHandles()\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tg_pParentWnd->GetPlugInMgr().ReleasePatchesHandles();\n}\n\npatchMesh_t* WINAPI QERApp_GetPatchData(int index)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tstatic patchMesh_t patch;\n\tpatchMesh_t *pPatch = g_pParentWnd->GetPlugInMgr().FindPatchHandle(index);\n\tif (pPatch)\n\t{\n\t\tmemcpy( &patch, pPatch, sizeof(patchMesh_t) );\n\t\treturn &patch;\n\t}\n\treturn NULL;\n}\n\nvoid WINAPI QERApp_DeletePatch(int index)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tpatchMesh_t *pPatch = g_pParentWnd->GetPlugInMgr().FindPatchHandle(index);\n\tif (pPatch)\n\t{\n\t\tbrush_t *pb = pPatch->pSymbiot;\n\t\tPatch_Delete( pPatch );\n\t\tif (pb)\n\t\t\tBrush_Free( pb );\n\t}\n#ifdef _DEBUG\n\tSys_Printf(\"Warning: QERApp_DeletePatch: FindPatchHandle failed\\n\");\n#endif\n}\n\nint WINAPI QERApp_CreatePatchHandle()\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\treturn g_pParentWnd->GetPlugInMgr().CreatePatchHandle();\n}\n\nint CPlugInManager::CreatePatchHandle()\n{\n\t// NOTE: we can't call the AddBrushForPatch until we have filled the patchMesh_t structure\n\tpatchMesh_t *pPatch = MakeNewPatch();\n\tm_PluginPatches.Add( pPatch );\n\t// change mode\n\tPatchesMode = EAllocatedPatches;\n\treturn m_PluginPatches.GetSize()-1;\n}\n\nvoid WINAPI QERApp_CommitPatchHandleToMap(int index, patchMesh_t *pMesh, char *texName)\n{\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\n\tg_pParentWnd->GetPlugInMgr().CommitPatchHandleToMap(index, pMesh, texName);\n}\n\nvoid CPlugInManager::CommitPatchHandleToMap(int index, patchMesh_t *pMesh, char *texName)\n{\n\tif (PatchesMode==EAllocatedPatches)\n\t{\n\t\tpatchMesh_t *pPatch = reinterpret_cast<patchMesh_t *>( m_PluginPatches.GetAt(index) );\n\t\tmemcpy( pPatch, pMesh, sizeof( patchMesh_t ) );\n\t\t// patch texturing, if none given use current texture\n\t\tif (texName)\n\t\t\tpPatch->d_texture = Texture_ForName(texName);\n\t\tif ( !pPatch->d_texture )\n\t\t{\n\t\t\tpPatch->d_texture = Texture_ForName(g_qeglobals.d_texturewin.texdef.name);\n\t\t\t// checking .. just in case\n\t\t\tif (!pPatch->d_texture)\n\t\t\t{\n#ifdef _DEBUG\n\t\t\t\tSys_Printf(\"WARNING: failed to set patch to current texture in CPlugInManager::CommitPatchHandleToMap\\n\");\n#endif\n\t\t\t\tpPatch->d_texture = notexture;\n\t\t\t}\n\t\t}\n\t\tg_bScreenUpdates = false;\n\t\t// the bLinkToWorld flag in AddBrushForPatch takes care of Brush_AddToList Entity_linkBrush and Brush_Build\n\t\tbrush_t *pb = AddBrushForPatch( pPatch, true );\n\t\tSelect_Brush( pb );\n\t\tg_bScreenUpdates = true;\n\t\tSys_UpdateWindows(W_ALL);\n\t}\n\telse\n\t{\n\t\tbrush_t *pBrush = reinterpret_cast<brush_t *>( m_PatchesHandles.GetAt(index) );\n\t\tpatchMesh_t *pPatch = pBrush->pPatch;\n\t\tpPatch->width = pMesh->width;\n\t\tpPatch->height = pMesh->height;\n\t\tpPatch->contents = pMesh->contents;\n\t\tpPatch->flags = pMesh->flags;\n\t\tpPatch->value = pMesh->value;\n\t\tpPatch->type = pMesh->type;\n\t\tmemcpy( pPatch->ctrl, pMesh->ctrl, sizeof(drawVert_t)*MAX_PATCH_HEIGHT*MAX_PATCH_WIDTH );\n\t\tpPatch->bDirty = true;\n\t}\n}\n\n// this gets called when the plugin needs specific services, for example the OpenGL drawing interface\n//++timo plugins should be able to dynamically register their own interfaces in there\nint WINAPI QERApp_RequestInterface( REFGUID refGUID, LPVOID pInterface )\n{\n\tif (IsEqualGUID( refGUID, QERQglTable_GUID ))\n\t{\n\t\t_QERQglTable *pQglTable = static_cast<_QERQglTable *>(pInterface);\n\t\tif ( pQglTable->m_nSize != sizeof(_QERQglTable) )\n\t\t{\n\t\t\tSys_Printf(\"wrong m_nSize in plugin-requested _QERQglTable interface\\n\");\n\t\t\treturn 0;\n\t\t}\n\t\tpQglTable->m_pfn_qglAlphaFunc = qglAlphaFunc;\n\t\tpQglTable->m_pfn_qglBegin = qglBegin;\n\t\tpQglTable->m_pfn_qglBindTexture = qglBindTexture;\n\t\tpQglTable->m_pfn_qglBlendFunc = qglBlendFunc;\n\t\tpQglTable->m_pfn_qglCallList = qglCallList;\n\t\tpQglTable->m_pfn_qglCallLists = qglCallLists;\n\t\tpQglTable->m_pfn_qglClear = qglClear;\n\t\tpQglTable->m_pfn_qglClearColor = qglClearColor;\n\t\tpQglTable->m_pfn_qglClearDepth = qglClearDepth;\n\t\tpQglTable->m_pfn_qglColor3f = qglColor3f;\n\t\tpQglTable->m_pfn_qglColor4f = qglColor4f;\n\t\tpQglTable->m_pfn_qglCullFace = qglCullFace;\n\t\tpQglTable->m_pfn_qglDisable = qglDisable;\n\t\tpQglTable->m_pfn_qglDeleteLists = qglDeleteLists;\n\t\tpQglTable->m_pfn_qglEnable = qglEnable;\n\t\tpQglTable->m_pfn_qglEnd = qglEnd;\n\t\tpQglTable->m_pfn_qglEndList = qglEndList;\n\t\tpQglTable->m_pfn_qglGenLists = qglGenLists;\n\t\tpQglTable->m_pfn_qglListBase = qglListBase;\n\t\tpQglTable->m_pfn_qglLoadIdentity = qglLoadIdentity;\n\t\tpQglTable->m_pfn_qglMatrixMode = qglMatrixMode;\n\t\tpQglTable->m_pfn_qglNewList = qglNewList;\n\t\tpQglTable->m_pfn_qglNormal3f = qglNormal3f;\n\t\tpQglTable->m_pfn_qglOrtho = qglOrtho;\n\t\tpQglTable->m_pfn_qglPointSize = qglPointSize;\n\t\tpQglTable->m_pfn_qglPolygonMode = qglPolygonMode;\n\t\tpQglTable->m_pfn_qglPopMatrix = qglPopMatrix;\n\t\tpQglTable->m_pfn_qglPushMatrix = qglPushMatrix;\n\t\tpQglTable->m_pfn_qglRotated = qglRotated;\n\t\tpQglTable->m_pfn_qglRotatef = qglRotatef;\n\t\tpQglTable->m_pfn_qglScalef = qglScalef;\n\t\tpQglTable->m_pfn_qglTexCoord2f = qglTexCoord2f;\n\t\tpQglTable->m_pfn_qglTexEnvf = qglTexEnvf;\n\t\tpQglTable->m_pfn_qglTexGenf = qglTexGenf;\n\t\tpQglTable->m_pfn_qglTexParameterf = qglTexParameterf;\n\t\tpQglTable->m_pfn_qglTranslated = qglTranslated;\n\t\tpQglTable->m_pfn_qglTranslatef = qglTranslatef;\n\t\tpQglTable->m_pfn_qglVertex2f = qglVertex2f;\n\t\tpQglTable->m_pfn_qglVertex3f = qglVertex3f;\n\t\tpQglTable->m_pfn_qglViewport = qglViewport;\n\t\tpQglTable->m_pfn_QE_CheckOpenGLForErrors = &QE_CheckOpenGLForErrors;\n\t\tpQglTable->m_pfn_QEW_SetupPixelFormat = &QEW_SetupPixelFormat;\n\t\tpQglTable->m_pfn_qwglCreateContext = qwglCreateContext;\n\t\tpQglTable->m_pfn_qwglDeleteContext = qwglDeleteContext;\n\t\tpQglTable->m_pfn_qwglMakeCurrent = qwglMakeCurrent;\n\t\tpQglTable->m_pfn_qwglShareLists = qwglShareLists;\n\t\tpQglTable->m_pfn_qwglSwapBuffers = qwglSwapBuffers;\n\t\tpQglTable->m_pfn_qwglUseFontBitmaps = qwglUseFontBitmaps;\n\t\tpQglTable->m_pfnGetQeglobalsHGLRC = &QERApp_GetQeglobalsHGLRC;\n\t\tpQglTable->m_pfn_qgluPerspective = qgluPerspective;\n\t\tpQglTable->m_pfn_qgluLookAt = qgluLookAt;\n\t\tpQglTable->m_pfnHookXYGLWindow = QERApp_HookXYGLWindow;\n\t\tpQglTable->m_pfnUnHookGLWindow = QERApp_UnHookGLWindow;\n\n\t\treturn 1;\n\t}\n\telse if (IsEqualGUID( refGUID, QERSelectedFaceTable_GUID ))\n\t{\n\t\t_QERSelectedFaceTable *pSelectedFaceTable = static_cast<_QERSelectedFaceTable *>(pInterface);\n\t\tif ( pSelectedFaceTable->m_nSize != sizeof(_QERSelectedFaceTable) )\n\t\t{\n\t\t\tSys_Printf(\"wrong m_nSize in plugin-requested _QERSelectedFaceTable interface\\n\");\n\t\t\treturn 0;\n\t\t}\n\t\tpSelectedFaceTable->m_pfnGetTextureNumber = &QERApp_ISelectedFace_GetTextureNumber;\n\t\tpSelectedFaceTable->m_pfnGetFaceInfo = &QERApp_GetFaceInfo;\n\t\tpSelectedFaceTable->m_pfnSetFaceInfo = &QERApp_SetFaceInfo;\n\t\tpSelectedFaceTable->m_pfnGetTextureSize = &QERApp_GetTextureSize;\n\t\tpSelectedFaceTable->m_pfnTextureForName = &QERApp_Texture_ForName;\n\t\tpSelectedFaceTable->m_pfnSelect_SetTexture = &Select_SetTexture;\n\t\treturn 1;\n\t}\n\telse if (IsEqualGUID( refGUID, QERPluginEntitiesTable_GUID ))\n\t{\n\t\t_QERPluginEntitiesTable *pPluginEntitiesTable = static_cast<_QERPluginEntitiesTable *>(pInterface);\n\t\tif ( pPluginEntitiesTable->m_nSize != sizeof(_QERPluginEntitiesTable) )\n\t\t{\n\t\t\tSys_Printf(\"wrong m_nSize in plugin-requested _QERPluginEntitiesTable interface\\n\");\n\t\t\treturn 0;\n\t\t}\n\t\tpPluginEntitiesTable->m_pfnEClassScanDir = &QERApp_EClassScanDir;\n\t\treturn 1;\n\t}\n\telse if (IsEqualGUID( refGUID, QERScripLibTable_GUID ))\n\t{\n\t\t_QERScripLibTable *pScripLibTable = static_cast<_QERScripLibTable *>(pInterface);\n\t\tif ( pScripLibTable->m_nSize != sizeof( _QERScripLibTable ) )\n\t\t{\n\t\t\tSys_Printf(\"wrong m_nSize in plugin-requested _QERScripLibTable\\n\");\n\t\t\treturn 0;\n\t\t}\n\t\tpScripLibTable->m_pfnGetToken = &GetToken;\n\t\tpScripLibTable->m_pfnToken = &QERApp_Token;\n\t\tpScripLibTable->m_pfnUnGetToken = &UngetToken;\n\t\treturn 1;\n\t}\n\telse if (IsEqualGUID( refGUID, QERAppSurfaceTable_GUID ))\n\t{\n\t\t_QERAppSurfaceTable *pSurfaceTable = static_cast<_QERAppSurfaceTable *>(pInterface);\n\t\tif ( pSurfaceTable->m_nSize != sizeof( _QERAppSurfaceTable ) )\n\t\t{\n\t\t\tSys_Printf(\"wrong m_nSize in plugin-requested _QERAppSurfaceTable\\n\");\n\t\t\treturn 0;\n\t\t}\n\t\tpSurfaceTable->m_pfnAnyPatchesSelected = &AnyPatchesSelected;\n\t\tpSurfaceTable->m_pfnOnlyPatchesSelected = &OnlyPatchesSelected;\n\t\tpSurfaceTable->m_pfnQeglobalsTexturewin = &QERApp_QeglobalsTexturewin;\n\t\tpSurfaceTable->m_pfnGetSelectedPatch = &QERApp_GetSelectedPatch;\n\t\tpSurfaceTable->m_pfnPatchRebuild = &Patch_Rebuild;\n\t\tpSurfaceTable->m_pfnGetTwoSelectedPatch = &QERApp_GetTwoSelectedPatch;\n\t\treturn 1;\n\t}\n\telse if (IsEqualGUID( refGUID, QERAppBSPFrontendTable_GUID ))\n\t{\n\t\t_QERAppBSPFrontendTable *pBSPFrontendTable = static_cast<_QERAppBSPFrontendTable *>(pInterface);\n\t\tif ( pBSPFrontendTable->m_nSize != sizeof( _QERAppBSPFrontendTable ) )\n\t\t{\n\t\t\tSys_Printf(\"wrong m_nSize in plugin-requested _QERAppBSPFrontendTable\\n\");\n\t\t\treturn 0;\n\t\t}\n\t\tpBSPFrontendTable->m_pfnGetMapName = &QERApp_GetMapName;\n\t\tpBSPFrontendTable->m_pfnLoadPointFile = &Pointfile_Check;\n\t\treturn 1;\n\t}\n\telse if (IsEqualGUID( refGUID, QERMessaging_GUID ))\n\t{\n\t\t_QERMessagingTable *pMessagingTable = static_cast<_QERMessagingTable *>(pInterface);\n\t\tif ( pMessagingTable->m_nSize != sizeof( _QERMessagingTable ) )\n\t\t{\n\t\t\tSys_Printf(\"wrong m_nSize in plugin-requested _QERMessagingTable\\n\");\n\t\t\treturn 0;\n\t\t}\n\t\tpMessagingTable->m_pfnHookWindow = QERApp_HookWindow;\n\t\tpMessagingTable->m_pfnUnHookWindow = QERApp_UnHookWindow;\n\t\tpMessagingTable->m_pfnGetXYWndWrapper = QERApp_GetXYWndWrapper;\n\t\tpMessagingTable->m_pfnHookListener = QERApp_HookListener;\n\t\tpMessagingTable->m_pfnUnHookListener = QERApp_UnHookListener;\n\t\treturn 1;\n\t}\n\telse if (IsEqualGUID( refGUID, QERShadersTable_GUID ))\n\t{\n\t\t_QERShadersTable *pShadersTable = static_cast<_QERShadersTable *>(pInterface);\n\t\tif ( pShadersTable->m_nSize != sizeof( _QERShadersTable ) )\n\t\t{\n\t\t\tSys_Printf(\"wring m_nSize in plugin-requested _QERShadersTable\\n\");\n\t\t\treturn 0;\n\t\t}\n\t\tpShadersTable->m_pfnTryTextureForName = QERApp_TryTextureForName;\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\nint CPlugInManager::FillFuncTable(CPlugIn *pPlug)\n{\n  _QERFuncTable_1 *pTable = reinterpret_cast<_QERFuncTable_1*>(pPlug->getFuncTable());\n  if (pTable != NULL)\n  {\n    if (pTable->m_fVersion != QER_PLUG_VERSION)\n    {\n      Sys_Printf(\"Radiant plugin manager was built with version %.2f, Plugin %s is version %.2f\\n\", QER_PLUG_VERSION, pPlug->getVersionStr() , pTable->m_fVersion);\n    }\n    if (pTable->m_fVersion >= QER_PLUG_VERSION_1)\n    {\n      pTable->m_pfnCreateBrush = &QERApp_CreateBrush;\n      pTable->m_pfnCreateBrushHandle = &QERApp_CreateBrushHandle;\n      pTable->m_pfnDeleteBrushHandle = &QERApp_DeleteBrushHandle;\n      pTable->m_pfnCommitBrushHandle = &QERApp_CommitBrushHandleToMap;\n      pTable->m_pfnAddFace = &QERApp_AddFace;\n      pTable->m_pfnAddFaceData = &QERApp_AddFaceData;\n      pTable->m_pfnGetFaceData = &QERApp_GetFaceData;\n      pTable->m_pfnGetFaceCount = &QERApp_GetFaceCount;\n      pTable->m_pfnSetFaceData = &QERApp_SetFaceData;\n      pTable->m_pfnDeleteFace = &QERApp_DeleteFace;\n      pTable->m_pfnTextureBrush = &QERApp_TextureBrush;\n\t  pTable->m_pfnBuildBrush = &QERApp_BuildBrush;\t\t\t\t\t\t// PGM\n  \t  pTable->m_pfnSelectBrush = &QERApp_SelectBrush;\t\t\t\t\t// PGM\n\t  pTable->m_pfnDeselectBrush = &QERApp_DeselectBrush;\t\t\t\t// PGM\n\t  pTable->m_pfnDeselectAllBrushes = &QERApp_DeselectAllBrushes;\t\t// PGM\n      pTable->m_pfnDeleteSelection = &QERApp_DeleteSelection;\n      pTable->m_pfnGetPoints = &QERApp_GetPoints;\n      pTable->m_pfnSysMsg = &QERApp_SysMsg;\n      pTable->m_pfnInfoMsg = &QERApp_InfoMsg;\n      pTable->m_pfnHideInfoMsg = &QERApp_HideInfoMsg;\n      pTable->m_pfnPositionView = &QERApp_PositionView;\t\t\t\t\t// PGM\n      pTable->m_pfnSelectedBrushCount = &QERApp_SelectedBrushCount;\n      pTable->m_pfnAllocateSelectedBrushHandles  = &QERApp_AllocateSelectedBrushHandles;\n      pTable->m_pfnReleaseSelectedBrushHandles  = &QERApp_ReleaseSelectedBrushHandles;\n      pTable->m_pfnGetSelectedBrushHandle = &QERApp_GetSelectedBrushHandle;\n      pTable->m_pfnActiveBrushCount = &QERApp_ActiveBrushCount;\n      pTable->m_pfnAllocateActiveBrushHandles = &QERApp_AllocateActiveBrushHandles;\n      pTable->m_pfnReleaseActiveBrushHandles = &QERApp_ReleaseActiveBrushHandles;\n      pTable->m_pfnGetActiveBrushHandle = &QERApp_GetActiveBrushHandle;\n      pTable->m_pfnTextureCount = &QERApp_TextureCount;\n      pTable->m_pfnGetTexture = &QERApp_GetTexture;\n      pTable->m_pfnGetCurrentTexture = &QERApp_GetCurrentTexture;\n      pTable->m_pfnSetCurrentTexture = &QERApp_SetCurrentTexture;\n      pTable->m_pfnGetEClassCount = &QERApp_GetEClassCount;\n      pTable->m_pfnGetEClass = &QERApp_GetEClass;\n      pTable->m_pfnResetPlugins = &QERApp_ResetPlugins;\n    }\n    // end of v1.00\n    if (pTable->m_fVersion >= 1.5f)\n    {\n      // v1.50 starts\n      pTable->m_pfnLoadTextureRGBA = &QERApp_LoadTextureRGBA;\n      // end of v1.50\n    }\n\tif (pTable->m_fVersion >= 1.7f)\n\t{\n\t\tpTable->m_pfnGetEntityCount = &QERApp_GetEntityCount;\n\t\tpTable->m_pfnGetEntityHandle = &QERApp_GetEntityHandle;\n\t\tpTable->m_pfnGetEntityKeyValList = &QERApp_GetEntityKeyValList;\n\t\tpTable->m_pfnAllocateEpair = &QERApp_AllocateEpair;\n\t\tpTable->m_pfnSetEntityKeyValList = &QERApp_SetEntityKeyValList;\n\t\tpTable->m_pfnAllocateEntityBrushHandles = &QERApp_AllocateEntityBrushHandles;\n\t\tpTable->m_pfnReleaseEntityBrushHandles = &QERApp_ReleaseEntityBrushHandles;\n\t\tpTable->m_pfnGetEntityBrushHandle = &QERApp_GetEntityBrushHandle;\n\t\tpTable->m_pfnCreateEntityHandle = &QERApp_CreateEntityHandle;\n\t\tpTable->m_pfnCommitBrushHandleToEntity = &QERApp_CommitBrushHandleToEntity;\n\t\tpTable->m_pfnCommitEntityHandleToMap = &QERApp_CommitEntityHandleToMap;\n\t\tpTable->m_pfnSetScreenUpdate = &QERApp_SetScreenUpdate;\n\t\tpTable->m_pfnSysUpdateWindows = &Sys_UpdateWindows;\n\t\tpTable->m_pfnBuildBrush2 = &QERApp_BuildBrush2;\n\t\tpTable->m_pfnReadProjectKey = &QERApp_ReadProjectKey;\n\t\tpTable->m_pfnScanFileForEClass = &QERApp_ScanFileForEClass;\n\t\tpTable->m_pfnRequestInterface = &QERApp_RequestInterface;\n\t\tpTable->m_pfnErrorMsg = &QERApp_ErrorMsg;\n\t\tpTable->m_pfnLoadFile = &QERApp_LoadFile;\n\t\tpTable->m_pfnExpandReletivePath = &QERApp_ExpandReletivePath;\n\t\tpTable->m_pfnQE_ConvertDOSToUnixName = &QE_ConvertDOSToUnixName;\n\t\tpTable->m_pfnHasShader = &QERApp_HasShader;\n\t\tpTable->m_pfnTexture_LoadSkin = &Texture_LoadSkin;\n\t\tpTable->m_pfnRadiantFree = &QERApp_RadiantFree;\n\t\tpTable->m_pfnGetGamePath = &QERApp_GetGamePath;\n\t\tpTable->m_pfnGetQERPath = &QERApp_GetQERPath;\n\t\t// patches\n\t\tpTable->m_pfnAllocateActivePatchHandles = &QERApp_AllocateActivePatchHandles;\n\t\tpTable->m_pfnAllocateSelectedPatchHandles = &QERApp_AllocateSelectedPatchHandles;\n\t\tpTable->m_pfnReleasePatchHandles = &QERApp_ReleasePatchHandles;\n\t\tpTable->m_pfnGetPatchData = &QERApp_GetPatchData;\n\t\tpTable->m_pfnDeletePatch = &QERApp_DeletePatch;\n\t\tpTable->m_pfnCreatePatchHandle = &QERApp_CreatePatchHandle;\n\t\tpTable->m_pfnCommitPatchHandleToMap = &QERApp_CommitPatchHandleToMap;\n\t}\n\treturn true;\n  }\n  else\n  {\n    Sys_Printf(\"Unable to load %s because the function tables are not the same size\\n\", pPlug->getVersionStr());\n  }\n  return false;\n}\n\nCPlugIn * CPlugInManager::PluginForModule(HMODULE hPlug)\n{\n\tint i;\n\tfor( i=0; i!=m_PlugIns.GetSize(); i++ )\n\t{\n\t\tif ( reinterpret_cast<CPlugIn *>(m_PlugIns[i])->GetDLLModule() == hPlug )\n\t\t\treturn reinterpret_cast<CPlugIn *>(m_PlugIns[i]);\n\t}\n\treturn NULL;\n}\n\n"
  },
  {
    "path": "q3radiant/PlugInManager.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// PlugInManager.h: interface for the CPlugInManager class.\n//\n//////////////////////////////////////////////////////////////////////\n\n#if !defined(AFX_PLUGINMANAGER_H__CFB18412_55FE_11D2_B082_00AA00A410FC__INCLUDED_)\n#define AFX_PLUGINMANAGER_H__CFB18412_55FE_11D2_B082_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n\n#include \"plugin.h\"\n\nclass CPlugInManager  \n{\nprivate:\n  CObArray m_PlugIns;\n  CPtrArray m_BrushHandles;\n  CPtrArray m_SelectedBrushHandles;\n  CPtrArray m_ActiveBrushHandles;\n\n  CPlugIn *m_pTexturePlug;\n  CPlugIn *m_pSurfaceListPlug;\n\n  // v1.70\n  // brushes of the current entity ( see m_SelectedBrushHandles and m_ActiveBrushHandles )\n  CPtrArray m_EntityBrushHandles;\n  // allocated entities, not commited yet ( see m_BrushHandles )\n  CPtrArray m_EntityHandles;\n\n  // tells in which array to look when given a patch index\n  enum EPatchesMode { EActivePatches, ESelectedPatches, EAllocatedPatches } PatchesMode;\n  // patches handles (brush_t*)\n  CPtrArray m_PatchesHandles;\n  // plugin-allocated patches, not commited yet (patchMesh_t*)\n  CPtrArray m_PluginPatches;\n\npublic:\n\tCPlugIn * PluginForModule( HMODULE hPlug );\n\tCPtrArray& GetActiveHandles() {return m_ActiveBrushHandles; };\n\tCPtrArray& GetSelectedHandles() {return m_SelectedBrushHandles; };\n\tCPtrArray& GetPluginPatches() {return m_PluginPatches; };\n\tbrush_t* FindBrushHandle(void *vp);\n\tpatchMesh_t* FindPatchHandle(int index);\n\tint CreatePatchHandle();\n\tint AllocateActivePatchHandles();\n\tint AllocateSelectedPatchHandles();\n\tvoid CommitPatchHandleToMap(int index, patchMesh_t *pMesh, char *texName);\n\tvoid ReleasePatchesHandles() { m_PatchesHandles.RemoveAll(); m_PluginPatches.RemoveAll(); }\n\tvoid AddFaceToBrushHandle(void *vp, vec3_t v1, vec3_t v2, vec3_t v3);\n\tvoid CommitBrushHandleToMap(void *vp);\n\tvoid DeleteBrushHandle(LPVOID vp);\n\tLPVOID CreateBrushHandle();\n\tvoid Dispatch(int n, const char *p);\n\tvoid Cleanup();\n\tvoid Init(const char* pPath);\n\tCPlugInManager();\n\tvirtual ~CPlugInManager();\n\t\n\t// the texture manager front ends the single load\n\t// addins (texture, model, map formats.. etc.)\n\t_QERTextureInfo* GetTextureInfo();\n\tvoid LoadTexture(const char *pFilename);\n\t\n\tLPVOID GetSurfaceFlags();\n\t\n\t// v1.70\n\tCPtrArray& GetEntityBrushHandles() {return m_EntityBrushHandles; };\n\tCPtrArray& GetEntityHandles() {return m_EntityHandles; };\n\t// the vpBrush needs to be in m_BrushHandles\n\tvoid CommitBrushHandleToEntity( LPVOID vpBrush, LPVOID vpEntity );\n\t// the vpEntity needs to be in m_EntityHandles\n\tvoid CommitEntityHandleToMap( LPVOID vpEntity );\n\nprotected:\n\tint FillFuncTable(CPlugIn *pPlug);\t\t// PGM\n};\n\n#endif // !defined(AFX_PLUGINMANAGER_H__CFB18412_55FE_11D2_B082_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/PluginEntities.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//-----------------------------------------------------------------------------\n//\n// $LogFile$\n// $Revision: 1.1.1.4 $\n// $Author: ttimo $\n// $Date: 2000/01/18 00:17:34 $\n// $Log: PluginEntities.cpp,v $\n// Revision 1.1.1.4  2000/01/18 00:17:34  ttimo\n// merging in for RC\n//\n// Revision 1.3  2000/01/17 23:53:42  TBesset\n// ready for merge in sourceforge (RC candidate)\n//\n// Revision 1.2  2000/01/07 16:40:11  TBesset\n// merged from BSP frontend\n//\n// Revision 1.1.1.3  1999/12/29 18:31:34  TBesset\n// Q3Radiant public version\n//\n// Revision 1.1.1.1.2.1  1999/12/29 21:39:38  TBesset\n// updated to update3 from Robert\n//\n// Revision 1.1.1.3  1999/12/29 18:31:34  TBesset\n// Q3Radiant public version\n// Revision 1.1.1.3  1999/12/29 18:31:34  TBesset\n// Q3Radiant public version\n//\n// Revision 1.2  1999/11/22 17:46:46  Timo & Christine\n// merged EARadiant into the main tree\n// bug fixes for Q3Plugin / EAPlugin\n// export for Robert\n//\n// Revision 1.1.2.1  1999/11/03 20:38:01  Timo & Christine\n// MEAN plugin for Q3Radiant, alpha version\n//\n//\n// DESCRIPTION:\n// implementation of IPluginEntities specific interface\n// \n\n#include \"stdafx.h\"\n#include \"io.h\"\n\n// is Eclass_InitForModelDirectory\nint WINAPI QERApp_EClassScanDir( char *path, HMODULE hPlug )\n{\n\tstruct _finddata_t\tfileinfo;\n\tint\t\t\t\t\thandle;\n\tchar\t\t\t\ttemp[ _MAX_PATH ];\n\tchar\t\t\t\tfilebase[ _MAX_PATH ];\n\tchar\t\t\t\tfilename[ _MAX_PATH ];\n\tchar\t\t\t\t*s;\n\teclass_t\t\t\t*e;\n\tQE_ConvertDOSToUnixName( temp, path );\n\tstrcpy (filebase, path);\n\ts = filebase + strlen(filebase)-1;\n\twhile (*s != '\\\\' && *s != '/' && s!=filebase)\n\t\ts--;\n\t*s = 0;\n\thandle = _findfirst (path, &fileinfo);\n\tif (handle != -1)\n\t   {\n\t\tdo\n\t\t{\t\t\t\n\t\t\tsprintf (filename, \"%s\\\\%s\", filebase, fileinfo.name);\n\t\t\tEclass_ScanFile (filename);\n\t\t\t\n\t\t\tif (eclass_found)\n            {\n\t\t\t\te = eclass_e;\n\t\t\t\te->modelpath = strdup( fileinfo.name );\n\t\t\t\te->nShowFlags |= ECLASS_PLUGINENTITY;\n\t\t\t\te->hPlug = hPlug;\n            }\n\t\t} while (_findnext( handle, &fileinfo ) != -1);\n\t\t\n\t\t_findclose (handle);\n\t   }\n\treturn 0;\n}\n"
  },
  {
    "path": "q3radiant/PrefsDlg.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// PrefsDlg.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"PrefsDlg.h\"\n#include \"shlobj.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n#define PREF_SECTION      \"Prefs\"\n#define INTERNAL_SECTION  \"Internals\"\n#define MOUSE_KEY         \"MouseButtons\"\n#define WINDOW_KEY        \"QE4StyleWindows\"\n#define LAYOUT_KEY        \"WindowLayout\"\n#define Q2_KEY            \"Quake2Dir\"\n#define RUNQ2_KEY         \"RunQuake2Run\"\n#define TLOCK_KEY         \"TextureLock\"\n#define RLOCK_KEY         \"RotateLock\"\n#define LOADLAST_KEY      \"LoadLast\"\n#define LOADLASTMAP_KEY   \"LoadLastMap\"\n#define LASTPROJ_KEY      \"LastProject\"\n#define LASTMAP_KEY       \"LastMap\"\n#define RUN_KEY           \"RunBefore\"\n#define _3DFX_KEY         \"Use3Dfx\"\n#define FACE_KEY          \"NewFaceGrab\"\n#define BSP_KEY           \"InternalBSP\"\n#define RCLICK_KEY        \"NewRightClick\"\n#define VERTEX_KEY        \"NewVertex\"\n#define AUTOSAVE_KEY      \"Autosave\"\n#define AUTOSAVETIME_KEY  \"AutosaveMinutes\"\n#define PAK_KEY           \"UsePAK\"\n#define NEWAPPLY_KEY      \"ApplyDismissesSurface\"\n#define HACK_KEY          \"Gatewayescapehack\"\n#define TEXTURE_KEY       \"NewTextureWindowStuff\"\n#define TINYBRUSH_KEY     \"CleanTinyBrushes\"\n#define TINYSIZE_KEY      \"CleanTinyBrusheSize\"\n#define SNAPSHOT_KEY      \"Snapshots\"\n#define PAKFILE_KEY       \"PAKFile\"\n#define STATUS_KEY        \"StatusPointSize\"\n#define MOVESPEED_KEY     \"MoveSpeed\"\n#define ANGLESPEED_KEY    \"AngleSpeed\"\n#define SETGAME_KEY       \"UseSetGame\"\n#define CAMXYUPDATE_KEY   \"CamXYUpdate\"\n#define LIGHTDRAW_KEY     \"NewLightStyle\"\n#define WHATGAME_KEY      \"WhichGame\"\n#define CUBICCLIP_KEY     \"CubicClipping\"\n#define CUBICSCALE_KEY    \"CubicScale\"\n#define ALTEDGE_KEY       \"ALTEdgeDrag\"\n#define TEXTUREBAR_KEY    \"UseTextureBar\"\n#define FACECOLORS_KEY    \"FaceColors\"\n#define QE4PAINT_KEY      \"QE4Paint\"\n#define SNAPT_KEY         \"SnapT\"\n#define XZVIS_KEY         \"XZVIS\"\n#define YZVIS_KEY         \"YZVIS\"\n#define ZVIS_KEY          \"ZVIS\"\n#define SIZEPAINT_KEY     \"SizePainting\"\n#define DLLENTITIES_KEY   \"DLLEntities\"\n#define WIDETOOLBAR_KEY   \"WideToolBar\"\n#define NOCLAMP_KEY       \"NoClamp\"\n#define PREFAB_KEY        \"PrefabPath\"\n#define USERINI_KEY       \"UserINIPath\"\n#define ROTATION_KEY      \"Rotation\"\n#define SGIOPENGL_KEY     \"SGIOpenGL\"\n#define BUGGYICD_KEY      \"BuggyICD\"\n#define HICOLOR_KEY       \"HiColorTextures\"\n#define CHASEMOUSE_KEY    \"ChaseMouse\"\n#define ENTITYSHOW_KEY    \"EntityShow\"\n#define TEXTURESCALE_KEY  \"TextureScale\"\n#define TEXTURESCROLLBAR_KEY  \"TextureScrollbar\"\n#define DISPLAYLISTS_KEY  \"UseDisplayLists\"\n#define NORMALIZECOLORS_KEY  \"NormalizeColors\"\n#define SHADERS_KEY       \"UseShaders\"\n#define SWITCHCLIP_KEY     \"SwitchClipKey\"\n#define SELWHOLEENTS_KEY\t\t\"SelectWholeEntitiesKey\"\n#define TEXTURESUBSET_KEY\t\t\"UseTextureSubsetLoading\"\n#define TEXTUREQUALITY_KEY \t\"TextureQuality\"\n#define SHOWSHADERS_KEY \t\"ShowShaders\"\n#define SHADERTEST_KEY \t  \"ShaderTest\"\n#define GLLIGHTING_KEY \"UseGLLighting\"\n#define LOADSHADERS_KEY \"LoadShaders\"\n#define NOSTIPPLE_KEY \"NoStipple\"\n#define UNDOLEVELS_KEY \"UndoLevels\"\n\n#define MOUSE_DEF 1\n#define WINDOW_DEF 0\n#define Q2_DEF \"c:\\\\quake2\\\\quake2.exe\"\n#define Q3_DEF \"c:\\\\Program Files\\\\Quake III Arena\\\\quake3.exe\"\n#define PAKFILE_DEF \"c:\\\\quake2\\\\baseq2\\\\pak0.pak\"\n#define RUNQ2_DEF 0\n#define TLOCK_DEF 1\n#define LOADLAST_DEF 1\n#define RUN_DEF 0\n\n/////////////////////////////////////////////////////////////////////////////\n// CPrefsDlg dialog\n\n\nCPrefsDlg::CPrefsDlg(CWnd* pParent /*=NULL*/)\n\t: CDialog(CPrefsDlg::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CPrefsDlg)\n\tm_strQuake2 = _T(\"c:\\\\quake3\\\\\");\n\tm_nMouse = 1;\n\tm_nView = 0;\n\tm_bLoadLast = FALSE;\n\tm_bFace = FALSE;\n\tm_bInternalBSP = FALSE;\n\tm_bRightClick = FALSE;\n\tm_bRunQuake = FALSE;\n\tm_bSetGame = FALSE;\n\tm_bVertex = FALSE;\n\tm_bAutoSave = TRUE;\n  m_bNewApplyHandling = FALSE;\n\tm_strAutoSave = _T(\"5\");\n\tm_bPAK = FALSE;\n\tm_bLoadLastMap = FALSE;\n\tm_bTextureWindow = FALSE;\n\tm_bSnapShots = FALSE;\n  m_fTinySize = 0.5;\n  m_bCleanTiny = FALSE;\n\tm_strPAKFile = _T(\"c:\\\\quake2\\\\baseq2\\\\pak0.pak\");\n\tm_nStatusSize = 10;\n\tm_bCamXYUpdate = FALSE;\n\tm_bNewLightDraw = FALSE;\n\tm_strPrefabPath = _T(\"\");\n\tm_nWhatGame = 0;\n\tm_strWhatGame = _T(\"Quake3\");\n\tm_bALTEdge = FALSE;\n\tm_bTextureBar = FALSE;\n\tm_bFaceColors = FALSE;\n\tm_bQE4Painting = TRUE;\n\tm_bSnapTToGrid = FALSE;\n  m_bXZVis = FALSE;\n  m_bYZVis = FALSE;\n  m_bZVis = FALSE;\n\tm_bSizePaint = FALSE;\n\tm_bDLLEntities = FALSE;\n\tm_bWideToolbar = TRUE;\n\tm_bNoClamp = FALSE;\n\tm_strUserPath = _T(\"\");\n\tm_nRotation = 0;\n\tm_bSGIOpenGL = FALSE;\n\tm_bBuggyICD = FALSE;\n\tm_bHiColorTextures = TRUE;\n\tm_bChaseMouse = FALSE;\n\tm_bTextureScrollbar = TRUE;\n\tm_bDisplayLists = TRUE;\n\tm_bShowShaders = FALSE;\n\tm_nShader = -1;\n\tm_bNoStipple = FALSE;\n\t//}}AFX_DATA_INIT\n  //LoadPrefs();\n  m_bSelectCurves = TRUE;\n  m_bSelectTerrain = TRUE;\n  m_nEntityShowState = 0;\n  m_nTextureScale = 2;\n  m_bSwitchClip = FALSE;\n  m_bSelectWholeEntities = TRUE;\n  m_nTextureQuality = 3;\n  m_bShowShaders = TRUE;\n  m_bGLLighting = FALSE;\n  m_nShader = 0;\n  m_nUndoLevels = 64;\n}\n\n\n\n\nvoid CPrefsDlg::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CPrefsDlg)\n\tDDX_Control(pDX, IDC_SPIN_UNDO, m_wndUndoSpin);\n\tDDX_Control(pDX, IDC_SPIN_POINTSIZE, m_wndFontSpin);\n\tDDX_Control(pDX, IDC_SLIDER_TEXTUREQUALITY, m_wndTexturequality);\n\tDDX_Control(pDX, IDC_COMBO_WHATGAME, m_wndWhatGame);\n\tDDX_Control(pDX, IDC_SLIDER_CAMSPEED, m_wndCamSpeed);\n\tDDX_Control(pDX, IDC_SPIN_AUTOSAVE, m_wndSpin);\n\tDDX_Text(pDX, IDC_EDIT_QUAKE2, m_strQuake2);\n\tDDX_Radio(pDX, IDC_RADIO_MOUSE, m_nMouse);\n\tDDX_Radio(pDX, IDC_RADIO_VIEWTYPE, m_nView);\n\tDDX_Check(pDX, IDC_CHECK_LOADLAST, m_bLoadLast);\n\tDDX_Check(pDX, IDC_CHECK_FACE, m_bFace);\n\tDDX_Check(pDX, IDC_CHECK_INTERNALBSP, m_bInternalBSP);\n\tDDX_Check(pDX, IDC_CHECK_RIGHTCLICK, m_bRightClick);\n\tDDX_Check(pDX, IDC_CHECK_RUNQUAKE, m_bRunQuake);\n\tDDX_Check(pDX, IDC_CHECK_SETGAME, m_bSetGame);\n\tDDX_Check(pDX, IDC_CHECK_VERTEX, m_bVertex);\n\tDDX_Check(pDX, IDC_CHECK_AUTOSAVE, m_bAutoSave);\n\tDDX_Text(pDX, IDC_EDIT_AUTOSAVE, m_strAutoSave);\n\tDDX_Check(pDX, IDC_CHECK_PAK, m_bPAK);\n\tDDX_Check(pDX, IDC_CHECK_LOADLASTMAP, m_bLoadLastMap);\n\tDDX_Check(pDX, IDC_CHECK_TEXTUREWINDOW, m_bTextureWindow);\n\tDDX_Check(pDX, IDC_CHECK_SNAPSHOTS, m_bSnapShots);\n\tDDX_Text(pDX, IDC_EDIT_PAKFILE, m_strPAKFile);\n\tDDX_Text(pDX, IDC_EDIT_STATUSPOINTSIZE, m_nStatusSize);\n\tDDV_MinMaxInt(pDX, m_nStatusSize, 2, 14);\n\tDDX_Check(pDX, IDC_CHECK_CAMXYUPDATE, m_bCamXYUpdate);\n\tDDX_Check(pDX, IDC_CHECK_LIGHTDRAW, m_bNewLightDraw);\n\tDDX_Text(pDX, IDC_EDIT_PREFABPATH, m_strPrefabPath);\n\tDDX_CBString(pDX, IDC_COMBO_WHATGAME, m_strWhatGame);\n\tDDX_Check(pDX, IDC_CHECK_ALTDRAG, m_bALTEdge);\n\tDDX_Check(pDX, IDC_CHECK_TEXTURETOOLBAR, m_bTextureBar);\n\tDDX_Check(pDX, IDC_CHECK_FACECOLOR, m_bFaceColors);\n\tDDX_Check(pDX, IDC_CHECK_QE4PAINTING, m_bQE4Painting);\n\tDDX_Check(pDX, IDC_CHECK_SNAPT, m_bSnapTToGrid);\n\tDDX_Check(pDX, IDC_CHECK_SIZEPAINT, m_bSizePaint);\n\tDDX_Check(pDX, IDC_CHECK_DLLENTITIES, m_bDLLEntities);\n\tDDX_Check(pDX, IDC_CHECK_WIDETOOLBAR, m_bWideToolbar);\n\tDDX_Check(pDX, IDC_CHECK_NOCLAMP, m_bNoClamp);\n\tDDX_Text(pDX, IDC_EDIT_USERPATH, m_strUserPath);\n\tDDX_Text(pDX, IDC_EDIT_ROTATION, m_nRotation);\n\tDDX_Check(pDX, IDC_CHECK_SGIOPENGL, m_bSGIOpenGL);\n\tDDX_Check(pDX, IDC_CHECK_BUGGYICD, m_bBuggyICD);\n\tDDX_Check(pDX, IDC_CHECK_HICOLOR, m_bHiColorTextures);\n\tDDX_Check(pDX, IDC_CHECK_MOUSECHASE, m_bChaseMouse);\n\tDDX_Check(pDX, IDC_CHECK_TEXTURESCROLLBAR, m_bTextureScrollbar);\n\tDDX_Check(pDX, IDC_CHECK_DISPLAYLISTS, m_bDisplayLists);\n\tDDX_CBIndex(pDX, IDC_COMBO_SHADERS, m_nShader);\n\tDDX_Check(pDX, IDC_CHECK_NOSTIPPLE, m_bNoStipple);\n\tDDX_Text(pDX, IDC_EDIT_UNDOLEVELS, m_nUndoLevels);\n\tDDV_MinMaxInt(pDX, m_nUndoLevels, 1, 64);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CPrefsDlg, CDialog)\n\t//{{AFX_MSG_MAP(CPrefsDlg)\n\tON_BN_CLICKED(IDC_BTN_BROWSE, OnBtnBrowse)\n\tON_BN_CLICKED(IDC_BTN_BROWSEPAK, OnBtnBrowsepak)\n\tON_BN_CLICKED(IDC_BTN_BROWSEPREFAB, OnBtnBrowseprefab)\n\tON_BN_CLICKED(IDC_BTN_BROWSEUSERINI, OnBtnBrowseuserini)\n\tON_CBN_SELCHANGE(IDC_COMBO_WHATGAME, OnSelchangeComboWhatgame)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CPrefsDlg message handlers\n\nvoid CPrefsDlg::OnBtnBrowse() \n{\n  UpdateData(TRUE);\n  CFileDialog dlg(true, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, \"Executables (*.exe)|*.exe||\", this);\n  if (dlg.DoModal() == IDOK)\n  {\n    m_strQuake2 = dlg.GetPathName();\n    UpdateData(FALSE);\n  }\n}\n\nBOOL CPrefsDlg::OnInitDialog() \n{\n\tCDialog::OnInitDialog();\n  m_wndSpin.SetRange(1,60);\n  m_wndCamSpeed.SetRange(10, 800);\n  m_wndCamSpeed.SetPos(m_nMoveSpeed);\n\n  this->m_wndTexturequality.SetRange(0, 3);\n  this->m_wndTexturequality.SetPos(m_nTextureQuality);\n\n  m_wndFontSpin.SetRange(4,24);\n  m_wndUndoSpin.SetRange(1,64);\n\n  m_wndWhatGame.AddString(\"Quake2\"); \n  m_wndWhatGame.AddString(\"Quake3\"); \n\n  GetDlgItem(IDC_CHECK_HICOLOR)->EnableWindow(TRUE);\n  GetDlgItem(IDC_CHECK_NOCLAMP)->EnableWindow(TRUE);\n\n  //GetDlgItem(IDC_CHECK_NOCLAMP)->EnableWindow(FALSE);\n\n  m_wndWhatGame.SelectString(-1,m_strWhatGame);\n  if (strstr(m_strWhatGame, \"Quake3\") != NULL)\n  {\n    GetDlgItem(IDC_EDIT_PAKFILE)->EnableWindow(FALSE);\n    GetDlgItem(IDC_BTN_BROWSEPAK)->EnableWindow(FALSE);\n    GetDlgItem(IDC_CHECK_INTERNALBSP)->EnableWindow(FALSE);\n  }\n  else\n  {\n    GetDlgItem(IDC_EDIT_PAKFILE)->EnableWindow(TRUE);\n    GetDlgItem(IDC_BTN_BROWSEPAK)->EnableWindow(TRUE);\n    GetDlgItem(IDC_CHECK_INTERNALBSP)->EnableWindow(TRUE);\n  }\n\n  return TRUE;  // return TRUE unless you set the focus to a control\n\t              // EXCEPTION: OCX Property Pages should return FALSE\n}\n\nvoid CPrefsDlg::OnOK() \n{\n  m_nMoveSpeed = m_wndCamSpeed.GetPos();\n  m_nAngleSpeed = (float)m_nMoveSpeed * 0.50;\n  this->m_nTextureQuality = m_wndTexturequality.GetPos();\n\tSavePrefs();\n\n  if (g_pParentWnd)\n    g_pParentWnd->SetGridStatus();\n  Sys_UpdateWindows(W_ALL);\n  Undo_SetMaxSize(m_nUndoLevels);\n\tCDialog::OnOK();\n}\n\nvoid CPrefsDlg::LoadPrefs()\n{\n  CString strBuff;\n  CString strPrefab = g_strAppPath;\n  AddSlash(strPrefab);\n  strPrefab += \"Prefabs\\\\\";\n  \n  m_nMouse = AfxGetApp()->GetProfileInt(PREF_SECTION, MOUSE_KEY, MOUSE_DEF);\n  if (m_nMouse == 0)\n    m_nMouseButtons = 2;\n  else\n    m_nMouseButtons = 3;\n\n  m_nView = AfxGetApp()->GetProfileInt(PREF_SECTION, WINDOW_KEY, WINDOW_DEF);\n  m_strQuake2 = AfxGetApp()->GetProfileString(PREF_SECTION, Q2_KEY, Q2_DEF);\n  m_bRunQuake = AfxGetApp()->GetProfileInt(PREF_SECTION, RUNQ2_KEY, RUNQ2_DEF);\n  m_bTextureLock = AfxGetApp()->GetProfileInt(PREF_SECTION, TLOCK_KEY, TLOCK_DEF);\n  m_bRotateLock = AfxGetApp()->GetProfileInt(PREF_SECTION, RLOCK_KEY, TLOCK_DEF);\n  m_strLastProject = AfxGetApp()->GetProfileString(PREF_SECTION, LASTPROJ_KEY, \"\");\n  m_strLastMap = AfxGetApp()->GetProfileString(PREF_SECTION, LASTMAP_KEY, \"\");\n  m_bLoadLast = AfxGetApp()->GetProfileInt(PREF_SECTION, LOADLAST_KEY, LOADLAST_DEF);\n  m_bRunBefore = AfxGetApp()->GetProfileInt(INTERNAL_SECTION, RUN_KEY, RUN_DEF);\n  //m_b3Dfx = AfxGetApp()->GetProfileInt(PREF_SECTION, _3DFX_KEY, 0);\n  m_bFace = AfxGetApp()->GetProfileInt(PREF_SECTION, FACE_KEY, 1);\n  m_bInternalBSP = AfxGetApp()->GetProfileInt(PREF_SECTION, BSP_KEY, 0);\n  m_bRightClick = AfxGetApp()->GetProfileInt(PREF_SECTION, RCLICK_KEY, 1);\n  m_bVertex = AfxGetApp()->GetProfileInt(PREF_SECTION, VERTEX_KEY, 1);\n  m_bAutoSave = AfxGetApp()->GetProfileInt(PREF_SECTION, AUTOSAVE_KEY, 1);\n  m_bPAK = AfxGetApp()->GetProfileInt(PREF_SECTION, PAK_KEY, 1);\n  m_bNewApplyHandling = AfxGetApp()->GetProfileInt(PREF_SECTION, NEWAPPLY_KEY, 0);\n  m_bLoadLastMap = AfxGetApp()->GetProfileInt(PREF_SECTION, LOADLASTMAP_KEY, 0);\n  m_bGatewayHack = AfxGetApp()->GetProfileInt(PREF_SECTION, HACK_KEY, 0);\n  m_bTextureWindow = AfxGetApp()->GetProfileInt(PREF_SECTION, TEXTURE_KEY, 0);\n  m_bCleanTiny = AfxGetApp()->GetProfileInt(PREF_SECTION, TINYBRUSH_KEY, 0);\n  strBuff = AfxGetApp()->GetProfileString(PREF_SECTION, TINYSIZE_KEY, \"0.5\");\n  m_fTinySize = atof(strBuff);\n  m_nAutoSave = AfxGetApp()->GetProfileInt(PREF_SECTION, AUTOSAVETIME_KEY, 5);\n  m_strAutoSave.Format(\"%i\", m_nAutoSave);\n  m_bSnapShots = AfxGetApp()->GetProfileInt(PREF_SECTION, SNAPSHOT_KEY, 0);\n  m_strPAKFile = AfxGetApp()->GetProfileString(PREF_SECTION, PAKFILE_KEY, PAKFILE_DEF);\n  m_nStatusSize = AfxGetApp()->GetProfileInt(PREF_SECTION, STATUS_KEY, 10);\n  m_nMoveSpeed = AfxGetApp()->GetProfileInt(PREF_SECTION, MOVESPEED_KEY, 400);\n  m_nAngleSpeed = AfxGetApp()->GetProfileInt(PREF_SECTION, ANGLESPEED_KEY, 300);\n  m_bSetGame = AfxGetApp()->GetProfileInt(PREF_SECTION, SETGAME_KEY, 0);\n\tm_bCamXYUpdate = AfxGetApp()->GetProfileInt(PREF_SECTION, CAMXYUPDATE_KEY, 1);\n  m_bNewLightDraw = AfxGetApp()->GetProfileInt(PREF_SECTION, LIGHTDRAW_KEY, 1);\n  m_bCubicClipping = AfxGetApp()->GetProfileInt(PREF_SECTION, CUBICCLIP_KEY, 1);\n  m_nCubicScale = AfxGetApp()->GetProfileInt(PREF_SECTION, CUBICSCALE_KEY, 13);\n  m_bALTEdge = AfxGetApp()->GetProfileInt(PREF_SECTION, ALTEDGE_KEY, 0);\n  m_bTextureBar = AfxGetApp()->GetProfileInt(PREF_SECTION, TEXTUREBAR_KEY, 0);\n  m_strWhatGame = AfxGetApp()->GetProfileString(PREF_SECTION, WHATGAME_KEY, \"Quake3\");\n  m_bFaceColors = AfxGetApp()->GetProfileInt(PREF_SECTION, FACECOLORS_KEY, 0);\n  m_bQE4Painting = AfxGetApp()->GetProfileInt(PREF_SECTION, QE4PAINT_KEY, 1);\n  m_bSnapTToGrid = AfxGetApp()->GetProfileInt(PREF_SECTION, SNAPT_KEY, 0);\n  m_bXZVis = AfxGetApp()->GetProfileInt(PREF_SECTION, XZVIS_KEY, 0);\n  m_bYZVis = AfxGetApp()->GetProfileInt(PREF_SECTION, YZVIS_KEY, 0);\n  m_bZVis = AfxGetApp()->GetProfileInt(PREF_SECTION, ZVIS_KEY, 1);\n  m_bSizePaint = AfxGetApp()->GetProfileInt(PREF_SECTION, SIZEPAINT_KEY, 0);\n  m_bDLLEntities = AfxGetApp()->GetProfileInt(PREF_SECTION, DLLENTITIES_KEY, 0);\n  m_bWideToolbar = AfxGetApp()->GetProfileInt(PREF_SECTION, WIDETOOLBAR_KEY, 1);\n  m_bNoClamp = AfxGetApp()->GetProfileInt(PREF_SECTION, NOCLAMP_KEY, 0);\n  m_strPrefabPath = AfxGetApp()->GetProfileString(PREF_SECTION, PREFAB_KEY, strPrefab);\n  m_strUserPath = AfxGetApp()->GetProfileString(PREF_SECTION, USERINI_KEY, \"\");\n  m_nRotation = AfxGetApp()->GetProfileInt(PREF_SECTION, ROTATION_KEY, 45);\n  m_bSGIOpenGL = AfxGetApp()->GetProfileInt(PREF_SECTION, SGIOPENGL_KEY, 0);\n  m_bBuggyICD = AfxGetApp()->GetProfileInt(PREF_SECTION, BUGGYICD_KEY, 0);\n  m_bHiColorTextures = AfxGetApp()->GetProfileInt(PREF_SECTION, HICOLOR_KEY, 1);\n  m_bChaseMouse = AfxGetApp()->GetProfileInt(PREF_SECTION, CHASEMOUSE_KEY, 1);\n  m_nEntityShowState = AfxGetApp()->GetProfileInt(PREF_SECTION, ENTITYSHOW_KEY, 0);\n  m_nTextureScale = AfxGetApp()->GetProfileInt(PREF_SECTION, TEXTURESCALE_KEY, 50);\n  m_bTextureScrollbar = AfxGetApp()->GetProfileInt(PREF_SECTION, TEXTURESCROLLBAR_KEY, TRUE);\n  m_bDisplayLists = AfxGetApp()->GetProfileInt(PREF_SECTION, DISPLAYLISTS_KEY, TRUE);\n  m_bSwitchClip = AfxGetApp()->GetProfileInt(PREF_SECTION, SWITCHCLIP_KEY, TRUE);\n  m_bSelectWholeEntities = AfxGetApp()->GetProfileInt(PREF_SECTION, SELWHOLEENTS_KEY, TRUE);\n  m_nTextureQuality = AfxGetApp()->GetProfileInt(PREF_SECTION, TEXTUREQUALITY_KEY, 6);\n  m_bShowShaders = AfxGetApp()->GetProfileInt(PREF_SECTION, SHOWSHADERS_KEY, TRUE);\n  m_bGLLighting = AfxGetApp()->GetProfileInt(PREF_SECTION, GLLIGHTING_KEY, FALSE);\n  m_nShader = AfxGetApp()->GetProfileInt(PREF_SECTION, LOADSHADERS_KEY, 0);\n  m_bNoStipple = AfxGetApp()->GetProfileInt(PREF_SECTION, NOSTIPPLE_KEY, 0);\n  m_nUndoLevels = AfxGetApp()->GetProfileInt(PREF_SECTION, UNDOLEVELS_KEY, 0);\n  \n  if (m_bRunBefore == FALSE)\n  {\n    SetGamePrefs();\n  }\n}\n\n\nvoid CPrefsDlg::SavePrefs()\n{\n  if (GetSafeHwnd())\n    UpdateData(TRUE);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, MOUSE_KEY, m_nMouse);\n  if (m_nMouse == 0)\n    m_nMouseButtons = 2;\n  else\n    m_nMouseButtons = 3;\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, WINDOW_KEY, m_nView);\n  AfxGetApp()->WriteProfileString(PREF_SECTION, Q2_KEY, m_strQuake2);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, RUNQ2_KEY, m_bRunQuake);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, TLOCK_KEY, m_bTextureLock);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, RLOCK_KEY, m_bRotateLock);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, LOADLAST_KEY, m_bLoadLast);\n  AfxGetApp()->WriteProfileString(PREF_SECTION, LASTPROJ_KEY, m_strLastProject);\n  AfxGetApp()->WriteProfileString(PREF_SECTION, LASTMAP_KEY, m_strLastMap);\n  AfxGetApp()->WriteProfileInt(INTERNAL_SECTION, RUN_KEY, m_bRunBefore);\n  //AfxGetApp()->WriteProfileInt(PREF_SECTION, _3DFX_KEY, m_b3Dfx);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, FACE_KEY, m_bFace);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, BSP_KEY, m_bInternalBSP);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, RCLICK_KEY, m_bRightClick);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, VERTEX_KEY, m_bVertex);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, AUTOSAVE_KEY, m_bAutoSave);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, PAK_KEY, m_bPAK);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, LOADLASTMAP_KEY, m_bLoadLastMap);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, TEXTURE_KEY, m_bTextureWindow);\n  m_nAutoSave = atoi(m_strAutoSave);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, AUTOSAVETIME_KEY, m_nAutoSave);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, SNAPSHOT_KEY, m_bSnapShots);\n  AfxGetApp()->WriteProfileString(PREF_SECTION, PAKFILE_KEY, m_strPAKFile);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, STATUS_KEY, m_nStatusSize);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, SETGAME_KEY, m_bSetGame);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, CAMXYUPDATE_KEY, m_bCamXYUpdate);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, LIGHTDRAW_KEY, m_bNewLightDraw);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, MOVESPEED_KEY, m_nMoveSpeed);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, ANGLESPEED_KEY, m_nAngleSpeed);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, CUBICCLIP_KEY, m_bCubicClipping);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, CUBICSCALE_KEY, m_nCubicScale);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, ALTEDGE_KEY, m_bALTEdge);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, TEXTUREBAR_KEY, m_bTextureBar);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, FACECOLORS_KEY, m_bFaceColors);\n  AfxGetApp()->WriteProfileString(PREF_SECTION, WHATGAME_KEY, m_strWhatGame);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, QE4PAINT_KEY, m_bQE4Painting);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, SNAPT_KEY, m_bSnapTToGrid);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, XZVIS_KEY, m_bXZVis);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, YZVIS_KEY, m_bYZVis);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, ZVIS_KEY, m_bZVis);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, SIZEPAINT_KEY, m_bSizePaint);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, DLLENTITIES_KEY, m_bDLLEntities);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, WIDETOOLBAR_KEY, m_bWideToolbar);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, NOCLAMP_KEY, m_bNoClamp);\n  AfxGetApp()->WriteProfileString(PREF_SECTION, PREFAB_KEY, m_strPrefabPath);\n  AfxGetApp()->WriteProfileString(PREF_SECTION, USERINI_KEY, m_strUserPath);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, ROTATION_KEY, m_nRotation);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, SGIOPENGL_KEY, m_bSGIOpenGL);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, BUGGYICD_KEY, m_bBuggyICD);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, HICOLOR_KEY, m_bHiColorTextures);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, CHASEMOUSE_KEY, m_bChaseMouse);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, ENTITYSHOW_KEY, m_nEntityShowState);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, TEXTURESCALE_KEY, m_nTextureScale);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, TEXTURESCROLLBAR_KEY, m_bTextureScrollbar);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, DISPLAYLISTS_KEY, m_bDisplayLists);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, SWITCHCLIP_KEY, m_bSwitchClip);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, SELWHOLEENTS_KEY, m_bSelectWholeEntities);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, TEXTUREQUALITY_KEY, m_nTextureQuality);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, SHOWSHADERS_KEY, m_bShowShaders);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, GLLIGHTING_KEY, m_bGLLighting);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, LOADSHADERS_KEY, m_nShader);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, NOSTIPPLE_KEY, m_bNoStipple);\n  AfxGetApp()->WriteProfileInt(PREF_SECTION, UNDOLEVELS_KEY, m_nUndoLevels);\n}\n\n                        \n\nvoid CPrefsDlg::OnBtnBrowsepak() \n{\n  UpdateData(TRUE);\n  CFileDialog dlg(true, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, \"PAK files (*.pak)|*.pak||\", this);\n  if (dlg.DoModal() == IDOK)\n  {\n    m_strPAKFile = dlg.GetPathName();\n    UpdateData(FALSE);\n  }\n}\n\nvoid CPrefsDlg::OnBtnBrowseprefab() \n{\n  UpdateData(TRUE);\n  BROWSEINFO bi;\n  CString strPath;\n  char* p = strPath.GetBuffer(MAX_PATH+1);\n  bi.hwndOwner = GetSafeHwnd();\n  bi.pidlRoot = NULL;\n  bi.pszDisplayName = p;\n  bi.lpszTitle = \"Load textures from path\";\n  bi.ulFlags = 0;\n  bi.lpfn = NULL;\n  bi.lParam = NULL;\n  bi.iImage = 0;\n  LPITEMIDLIST pidlBrowse;\n  pidlBrowse = SHBrowseForFolder(&bi);\n  if (pidlBrowse)\n  {\n    SHGetPathFromIDList(pidlBrowse, p);\n    strPath.ReleaseBuffer();\n    AddSlash(strPath);\n    m_strPrefabPath = strPath;\n    UpdateData(FALSE);\n  }\n}\n\nvoid CPrefsDlg::OnBtnBrowseuserini() \n{\n  UpdateData(TRUE);\n  CFileDialog dlg(true, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, \"INI files (*.ini)|*.ini||\", this);\n  if (dlg.DoModal() == IDOK)\n  {\n    m_strUserPath = dlg.GetPathName();\n    UpdateData(FALSE);\n  }\n}\n\nvoid CPrefsDlg::OnSelchangeComboWhatgame() \n{\n  int n = m_wndWhatGame.GetCurSel();\n  if (n >= 0)\n  {\n    m_wndWhatGame.GetLBText(n, m_strWhatGame);\n  }\n  SetGamePrefs();\n}\n\nvoid CPrefsDlg::SetGamePrefs()\n{\n  if (strstr(m_strWhatGame, \"Quake3\") != NULL)\n  {\n    m_bHiColorTextures = TRUE;\n  \tm_bWideToolbar = TRUE;\n    m_strPAKFile = \"PK3 files are loaded from the baseq3 path\";\n  \tm_bInternalBSP = FALSE;\n    if (GetSafeHwnd())\n    {\n      GetDlgItem(IDC_EDIT_PAKFILE)->EnableWindow(FALSE);\n      GetDlgItem(IDC_BTN_BROWSEPAK)->EnableWindow(FALSE);\n      GetDlgItem(IDC_CHECK_INTERNALBSP)->EnableWindow(FALSE);\n    }\n  }\n  else\n  {\n    m_bHiColorTextures = FALSE;\n  \tm_bWideToolbar = FALSE;\n    m_strPAKFile = PAKFILE_DEF;\n    if (GetSafeHwnd())\n    {\n      GetDlgItem(IDC_EDIT_PAKFILE)->EnableWindow(TRUE);\n      GetDlgItem(IDC_BTN_BROWSEPAK)->EnableWindow(TRUE);\n      GetDlgItem(IDC_CHECK_INTERNALBSP)->EnableWindow(TRUE);\n    }\n  }\n  SavePrefs();\n}\n"
  },
  {
    "path": "q3radiant/PrefsDlg.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_PREFSDLG_H__DC829122_812D_11D1_B548_00AA00A410FC__INCLUDED_)\n#define AFX_PREFSDLG_H__DC829122_812D_11D1_B548_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// PrefsDlg.h : header file\n//\n\n#include \"resource.h\"\n\n/////////////////////////////////////////////////////////////////////////////\n// CPrefsDlg dialog\n\n#define MAX_TEXTURE_QUALITY 3\n\nclass CPrefsDlg : public CDialog\n{\n// Construction\npublic:\n  // these mirror what goes in the combo box\n  enum {SHADER_NONE = 0, SHADER_COMMON, SHADER_ALL};\n\tvoid LoadPrefs();\n\tvoid SavePrefs();\n  void SetGamePrefs();\n\tCPrefsDlg(CWnd* pParent = NULL);   // standard constructor\n\n// Dialog Data\n\t//{{AFX_DATA(CPrefsDlg)\n\tenum { IDD = IDD_DLG_PREFS };\n\tCSpinButtonCtrl\tm_wndUndoSpin;\n\tCSpinButtonCtrl\tm_wndFontSpin;\n\tCSliderCtrl\tm_wndTexturequality;\n\tCComboBox\tm_wndWhatGame;\n\tCSliderCtrl\tm_wndCamSpeed;\n\tCSpinButtonCtrl\tm_wndSpin;\n\tCString\tm_strQuake2;\n\tint\t\tm_nMouse;\n\tint\t\tm_nView;\n  BOOL   m_bTextureLock;\n\tBOOL\tm_bLoadLast;\n\tBOOL\tm_bRunBefore;\n\tCString\tm_strLastProject;\n\tCString\tm_strLastMap;\n\tBOOL\tm_bFace;\n\tBOOL\tm_bInternalBSP;\n\tBOOL\tm_bRightClick;\n\tBOOL\tm_bRunQuake;\n\tBOOL\tm_bSetGame;\n\tBOOL\tm_bVertex;\n\tBOOL\tm_bAutoSave;\n  BOOL  m_bNewApplyHandling;\n\tCString\tm_strAutoSave;\n\tBOOL\tm_bPAK;\n\tBOOL\tm_bLoadLastMap;\n\tBOOL\tm_bGatewayHack;\n\tBOOL\tm_bTextureWindow;\n\tBOOL\tm_bSnapShots;\n  float m_fTinySize;\n  BOOL  m_bCleanTiny;\n\tCString\tm_strPAKFile;\n\tint\t\tm_nStatusSize;\n\tBOOL\tm_bCamXYUpdate;\n\tBOOL\tm_bNewLightDraw;\n\tCString\tm_strPrefabPath;\n\tint\t\tm_nWhatGame;\n\tCString\tm_strWhatGame;\n\tBOOL\tm_bALTEdge;\n\tBOOL\tm_bTextureBar;\n\tBOOL\tm_bFaceColors;\n\tBOOL\tm_bQE4Painting;\n\tBOOL\tm_bSnapTToGrid;\n\tBOOL\tm_bXZVis;\n\tBOOL\tm_bYZVis;\n\tBOOL\tm_bZVis;\n\tBOOL\tm_bSizePaint;\n\tBOOL\tm_bDLLEntities;\n  BOOL  m_bRotateLock;\n\tBOOL\tm_bWideToolbar;\n\tBOOL\tm_bNoClamp;\n\tCString\tm_strUserPath;\n\tint\t\tm_nRotation;\n\tBOOL\tm_bSGIOpenGL;\n\tBOOL\tm_bBuggyICD;\n\tBOOL\tm_bHiColorTextures;\n\tBOOL\tm_bChaseMouse;\n\tBOOL\tm_bTextureScrollbar;\n\tBOOL\tm_bDisplayLists;\n\tBOOL\tm_bShowShaders;\n\tint\t\tm_nShader;\n\tBOOL\tm_bNoStipple;\n\tint\t\tm_nUndoLevels;\n\t//}}AFX_DATA\n\tint\tm_nMouseButtons;\n  int m_nAngleSpeed;\n  int m_nMoveSpeed;\n  int m_nAutoSave;\n  bool m_bCubicClipping;\n  int m_nCubicScale;\n  BOOL  m_bSelectCurves;\n  BOOL  m_bSelectTerrain;\n  int m_nEntityShowState;\n  int m_nTextureScale;\n  BOOL m_bNormalizeColors;\n  BOOL m_bSwitchClip;\n  BOOL m_bSelectWholeEntities;\n  int m_nTextureQuality;\n\tBOOL\tm_bGLLighting;\n\n\t// brush primitive mode\n\t//++timo moved into g_qeglobals\n//\tBOOL m_bBrushPrimitMode;\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CPrefsDlg)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CPrefsDlg)\n\tafx_msg void OnBtnBrowse();\n\tvirtual BOOL OnInitDialog();\n\tvirtual void OnOK();\n\tafx_msg void OnBtnBrowsepak();\n\tafx_msg void OnBtnBrowseprefab();\n\tafx_msg void OnBtnBrowseuserini();\n\tafx_msg void OnSelchangeComboWhatgame();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_PREFSDLG_H__DC829122_812D_11D1_B548_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/QE3.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"stdafx.h\"\n#include \"qe3.h\"\n#include \"PrefsDlg.h\"\n#include <direct.h>  \n#include <sys\\stat.h> \n\nQEGlobals_t  g_qeglobals;\n\nvoid WINAPI QE_CheckOpenGLForErrors(void)\n{\n  CString strMsg;\n  int i = qglGetError();\n  if (i != GL_NO_ERROR)\n  {\n    if (i == GL_OUT_OF_MEMORY)\n    {\n      //strMsg.Format(\"OpenGL out of memory error %s\\nDo you wish to save before exiting?\", qgluErrorString((GLenum)i));\n      if (MessageBox(g_qeglobals.d_hwndMain, strMsg, \"Q3Radiant Error\", MB_YESNO) == IDYES)\n      {\n        Map_SaveFile(NULL, false);\n      }\n\t\t  exit(1);\n    }\n    else\n    {\n      //strMsg.Format(\"Warning: OpenGL Error %s\\n \", qgluErrorString((GLenum)i));\n\t\t  Sys_Printf (strMsg.GetBuffer(0));\n    }\n  }\n}\n\n\nchar *ExpandReletivePath (char *p)\n{\n\tstatic char\ttemp[1024];\n\tchar\t*base;\n\n\tif (!p || !p[0])\n\t\treturn NULL;\n\tif (p[0] == '/' || p[0] == '\\\\')\n\t\treturn p;\n\n\tbase = ValueForKey(g_qeglobals.d_project_entity, \"basepath\");\n\tsprintf (temp, \"%s/%s\", base, p);\n\treturn temp;\n}\n\nchar *copystring (char *s)\n{\n\tchar\t*b;\n\tb = (char*)malloc(strlen(s)+1);\n\tstrcpy (b,s);\n\treturn b;\n}\n\n\nbool DoesFileExist(const char* pBuff, long& lSize)\n{\n  CFile file;\n  if (file.Open(pBuff, CFile::modeRead | CFile::shareDenyNone))\n  {\n    lSize += file.GetLength();\n    file.Close();\n    return true;\n  }\n  return false;\n}\n\n\nvoid Map_Snapshot()\n{\n  CString strMsg;\n  // we need to do the following\n  // 1. make sure the snapshot directory exists (create it if it doesn't)\n  // 2. find out what the lastest save is based on number\n  // 3. inc that and save the map\n  CString strOrgPath, strOrgFile;\n  ExtractPath_and_Filename(currentmap, strOrgPath, strOrgFile);\n  AddSlash(strOrgPath);\n  strOrgPath += \"snapshots\";\n  bool bGo = true;\n  struct _stat Stat;\n  if (_stat(strOrgPath, &Stat) == -1)\n  {\n    bGo = (_mkdir(strOrgPath) != -1);\n  }\n  AddSlash(strOrgPath);\n  if (bGo)\n  {\n    int nCount = 0;\n    long lSize = 0;\n    CString strNewPath = strOrgPath;\n    strNewPath += strOrgFile;\n    CString strFile;\n    while (bGo)\n    {\n      strFile.Format(\"%s.%i\", strNewPath, nCount);\n      bGo = DoesFileExist(strFile, lSize);\n      nCount++;\n    }\n    // strFile has the next available slot\n    Map_SaveFile(strFile.GetBuffer(0), false);\n\t\tSys_SetTitle (currentmap);\n    if (lSize > 12 * 1024 * 1024) // total size of saves > 4 mb\n    {\n      Sys_Printf(\"The snapshot files in the [%s] directory total more than 4 megabytes. You might consider cleaning the directory up.\", strOrgPath);\n    }\n  }\n  else\n  {\n    strMsg.Format(\"Snapshot save failed.. unabled to create directory\\n%s\", strOrgPath);\n    g_pParentWnd->MessageBox(strMsg);\n  }\n}\n/*\n===============\nQE_CheckAutoSave\n\nIf five minutes have passed since making a change\nand the map hasn't been saved, save it out.\n===============\n*/\n\n\nvoid QE_CheckAutoSave( void )\n{\n\tstatic clock_t s_start;\n\tclock_t        now;\n\n\tnow = clock();\n\n\tif ( modified != 1 || !s_start)\n\t{\n\t\ts_start = now;\n\t\treturn;\n\t}\n\n\tif ( now - s_start > ( CLOCKS_PER_SEC * 60 * g_PrefsDlg.m_nAutoSave))\n\t{\n\n    if (g_PrefsDlg.m_bAutoSave)\n    {\n      CString strMsg = g_PrefsDlg.m_bSnapShots ? \"Autosaving snapshot...\" : \"Autosaving...\";\n\t\t  Sys_Printf(strMsg.GetBuffer(0));\n      Sys_Printf(\"\\n\");\n\t\t  Sys_Status (strMsg.GetBuffer(0),0);\n\n      // only snapshot if not working on a default map\n      if (g_PrefsDlg.m_bSnapShots && stricmp(currentmap, \"unnamed.map\") != 0)\n      {\n        Map_Snapshot();\n      }\n      else\n      {\n\t\t    Map_SaveFile (ValueForKey(g_qeglobals.d_project_entity, \"autosave\"), false);\n      }\n\n\t\t  Sys_Status (\"Autosaving...Saved.\", 0 );\n\t\t  modified = 2;\n    }\n    else\n    {\n\t\t  Sys_Printf (\"Autosave skipped...\\n\");\n\t\t  Sys_Status (\"Autosave skipped...\", 0 );\n    }\n\t\ts_start = now;\n\t}\n}\n\n\nint BuildShortPathName(const char* pPath, char* pBuffer, int nBufferLen)\n{\n  char *pFile = NULL;\n  int nResult = GetFullPathName(pPath, nBufferLen, pBuffer, &pFile); \n  nResult = GetShortPathName(pPath, pBuffer, nBufferLen);\n  if (nResult == 0)\n    strcpy(pBuffer, pPath);                     // Use long filename\n  return nResult;\n}\n\n\n\nconst char *g_pPathFixups[]=\n{\n  \"basepath\",\n  \"remotebasepath\",\n  \"entitypath\",\n  \"texturepath\",\n  \"autosave\",\n  \"mapspath\"\n};\n\nconst int g_nPathFixupCount = sizeof(g_pPathFixups) / sizeof(const char*);\n\n/*\n===========\nQE_LoadProject\n===========\n*/\nqboolean QE_LoadProject (char *projectfile)\n{\n\tchar\t*data;\n\n\tSys_Printf (\"QE_LoadProject (%s)\\n\", projectfile);\n\t\n\tif ( LoadFileNoCrash (projectfile, (void **)&data) == -1)\n\t\treturn false;\n\t\n\tg_strProject = projectfile;\n\t\n\tCString strData = data;\n\tfree(data);\n\t\n\tCString strQ2Path = g_PrefsDlg.m_strQuake2;\n\tCString strQ2File;\n\tExtractPath_and_Filename(g_PrefsDlg.m_strQuake2, strQ2Path, strQ2File);\n\tAddSlash(strQ2Path);\n\t\n\t\n\tchar* pBuff = new char[1024];\n\t\n\tBuildShortPathName(strQ2Path, pBuff, 1024);\n\tFindReplace(strData, \"__Q2PATH\", pBuff);\n\tBuildShortPathName(g_strAppPath, pBuff, 1024);\n\tFindReplace(strData, \"__QERPATH\", pBuff);\n\t\n\tchar* pFile;\n\tif (GetFullPathName(projectfile, 1024, pBuff, &pFile))\n\t{\n\t\tg_PrefsDlg.m_strLastProject = pBuff;\n\t\tBuildShortPathName(g_PrefsDlg.m_strLastProject, pBuff, 1024);\n\t\tg_PrefsDlg.m_strLastProject = pBuff;\n\t\tg_PrefsDlg.SavePrefs();\n\t\t\n\t\tExtractPath_and_Filename(pBuff, strQ2Path, strQ2File);\n\t\tint nLen = strQ2Path.GetLength();\n\t\tif (nLen > 0)\n\t\t{\n\t\t\tif (strQ2Path[nLen - 1] == '\\\\')\n\t\t\t\tstrQ2Path.SetAt(nLen-1,'\\0');\n\t\t\tchar* pBuffer = strQ2Path.GetBufferSetLength(_MAX_PATH + 1);\n\t\t\tint n = strQ2Path.ReverseFind('\\\\');\n\t\t\tif (n >=0 )\n\t\t\t\tpBuffer[n + 1] = '\\0';\n\t\t\tstrQ2Path.ReleaseBuffer();\n\t\t\tFindReplace(strData, \"__QEPROJPATH\", strQ2Path);\n\t\t}\n\t}\n\t\n\t\n\tStartTokenParsing (strData.GetBuffer(0));\n\tg_qeglobals.d_project_entity = Entity_Parse (true);\n\tif (!g_qeglobals.d_project_entity)\n\t\tError (\"Couldn't parse %s\", projectfile);\n\n  for (int i = 0; i < g_nPathFixupCount; i++)\n  {\n    char *pPath = ValueForKey (g_qeglobals.d_project_entity, g_pPathFixups[i]);\n    if (pPath[0] != '\\\\' && pPath[0] != '/')\n    {\n\t    if (GetFullPathName(pPath, 1024, pBuff, &pFile))\n      {\n        SetKeyValue(g_qeglobals.d_project_entity, g_pPathFixups[i], pBuff);\n      }\n    }\n  }\n\n\tdelete []pBuff;\n\n\t// set here some default project settings you need\n\tif ( strlen( ValueForKey( g_qeglobals.d_project_entity, \"brush_primit\" ) ) == 0 )\n\t{\n\t\tSetKeyValue( g_qeglobals.d_project_entity, \"brush_primit\", \"0\" );\n\t}\n\n\tg_qeglobals.m_bBrushPrimitMode = IntForKey( g_qeglobals.d_project_entity, \"brush_primit\" );\n\n\n\tEclass_InitForSourceDirectory (ValueForKey (g_qeglobals.d_project_entity, \"entitypath\"));\n\tFillClassList();\t\t// list in entity window\n\t\n\tMap_New();\n\t\n\t\n\tFillTextureMenu();\n\tFillBSPMenu();\n\t\n\treturn true;\n}\n\n/*\n===========\nQE_SaveProject\n===========\n*/\n//extern char\t*bsp_commands[256];\n\nqboolean QE_SaveProject (const char* pProjectFile)\n{\n\t//char\tfilename[1024];\n\tFILE\t*fp;\n\tepair_t\t*ep;\n\n\t//sprintf (filename, \"%s\\\\%s.prj\", g_projectdir, g_username);\n\n\tif (!(fp = fopen (pProjectFile, \"w+\")))\n\t\tError (\"Could not open project file!\");\n\t\n\tfprintf (fp, \"{\\n\");\n\tfor (ep = g_qeglobals.d_project_entity->epairs; ep; ep=ep->next)\n\t\tfprintf (fp, \"\\\"%s\\\" \\\"%s\\\"\\n\", ep->key, ep->value);\n\tfprintf (fp, \"}\\n\");\n\n\tfclose (fp);\n\t\n\treturn TRUE;\n}\n\n\n\n/*\n===========\nQE_KeyDown\n===========\n*/\n#define\tSPEED_MOVE\t32\n#define\tSPEED_TURN\t22.5\n\n\n/*\n===============\nConnectEntities\n\nSets target / targetname on the two entities selected\nfrom the first selected to the secon\n===============\n*/\nvoid ConnectEntities (void)\n{\n\tentity_t\t*e1, *e2, *e;\n\tchar\t\t*target, *tn;\n\tint\t\t\tmaxtarg, targetnum;\n\tchar\t\tnewtarg[32];\n\n\tif (g_qeglobals.d_select_count != 2)\n\t{\n\t\tSys_Status (\"Must have two brushes selected.\", 0);\n\t\tSys_Beep ();\n\t\treturn;\n\t}\n\n\te1 = g_qeglobals.d_select_order[0]->owner;\n\te2 = g_qeglobals.d_select_order[1]->owner;\n\n\tif (e1 == world_entity || e2 == world_entity)\n\t{\n\t\tSys_Status (\"Can't connect to the world.\", 0);\n\t\tSys_Beep ();\n\t\treturn;\n\t}\n\n\tif (e1 == e2)\n\t{\n\t\tSys_Status (\"Brushes are from same entity.\", 0);\n\t\tSys_Beep ();\n\t\treturn;\n\t}\n\n\ttarget = ValueForKey (e1, \"target\");\n\tif (target && target[0])\n\t\tstrcpy (newtarg, target);\n\telse\n\t{\n\t\ttarget = ValueForKey (e2, \"targetname\");\n\t\tif (target && target[0])\n\t\t\tstrcpy (newtarg, target);\n\t\telse\n\t\t{\n\t\t\t// make a unique target value\n\t\t\tmaxtarg = 0;\n\t\t\tfor (e=entities.next ; e != &entities ; e=e->next)\n\t\t\t{\n\t\t\t\ttn = ValueForKey (e, \"targetname\");\n\t\t\t\tif (tn && tn[0])\n\t\t\t\t{\n\t\t\t\t\ttargetnum = atoi(tn+1);\n\t\t\t\t\tif (targetnum > maxtarg)\n\t\t\t\t\t\tmaxtarg = targetnum;\n\t\t\t\t}\n\t\t\t}\n\t\t\tsprintf (newtarg, \"t%i\", maxtarg+1);\n\t\t}\n\t}\n\n\tSetKeyValue (e1, \"target\", newtarg);\n\tSetKeyValue (e2, \"targetname\", newtarg);\n\tSys_UpdateWindows (W_XY | W_CAMERA);\n\n\tSelect_Deselect();\n\tSelect_Brush (g_qeglobals.d_select_order[1]);\n}\n\nqboolean QE_SingleBrush (bool bQuiet)\n{\n\tif ( (selected_brushes.next == &selected_brushes)\n\t\t|| (selected_brushes.next->next != &selected_brushes) )\n\t{\n\t  if (!bQuiet)\n    {\n\t  \tSys_Printf (\"Error: you must have a single brush selected\\n\");\n\t  }\n\t\treturn false;\n\t}\n\tif (selected_brushes.next->owner->eclass->fixedsize)\n\t{\n\t  if (!bQuiet)\n\t  {\n\t\t  Sys_Printf (\"Error: you cannot manipulate fixed size entities\\n\");\n\t  }\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\nvoid QE_Init (void)\n{\n\t/*\n\t** initialize variables\n\t*/\n\tg_qeglobals.d_gridsize = 8;\n\tg_qeglobals.d_showgrid = true;\n\n\t/*\n\t** other stuff\n\t*/\n\tTexture_Init (true);\n\t//Cam_Init ();\n\t//XY_Init ();\n\tZ_Init ();\n\tTerrain_Init();\n}\n\nvoid WINAPI QE_ConvertDOSToUnixName( char *dst, const char *src )\n{\n\twhile ( *src )\n\t{\n\t\tif ( *src == '\\\\' )\n\t\t\t*dst = '/';\n\t\telse\n\t\t\t*dst = *src;\n\t\tdst++; src++;\n\t}\n\t*dst = 0;\n}\n\nint g_numbrushes, g_numentities;\n\nvoid QE_CountBrushesAndUpdateStatusBar( void )\n{\n\tstatic int      s_lastbrushcount, s_lastentitycount;\n\tstatic qboolean s_didonce;\n\t\n\t//entity_t   *e;\n\tbrush_t\t   *b, *next;\n\n\tg_numbrushes = 0;\n\tg_numentities = 0;\n\t\n\tif ( active_brushes.next != NULL )\n\t{\n\t\tfor ( b = active_brushes.next ; b != NULL && b != &active_brushes ; b=next)\n\t\t{\n\t\t\tnext = b->next;\n\t\t\tif (b->brush_faces )\n\t\t\t{\n\t\t\t\tif ( !b->owner->eclass->fixedsize)\n\t\t\t\t\tg_numbrushes++;\n\t\t\t\telse\n\t\t\t\t\tg_numentities++;\n\t\t\t}\n\t\t}\n\t}\n/*\n\tif ( entities.next != NULL )\n\t{\n\t\tfor ( e = entities.next ; e != &entities && g_numentities != MAX_MAP_ENTITIES ; e = e->next)\n\t\t{\n\t\t\tg_numentities++;\n\t\t}\n\t}\n*/\n\tif ( ( ( g_numbrushes != s_lastbrushcount ) || ( g_numentities != s_lastentitycount ) ) || ( !s_didonce ) )\n\t{\n\t\tSys_UpdateStatusBar();\n\n\t\ts_lastbrushcount = g_numbrushes;\n\t\ts_lastentitycount = g_numentities;\n\t\ts_didonce = true;\n\t}\n}\n\nchar\t\tcom_token[1024];\nqboolean\tcom_eof;\n\n/*\n================\nI_FloatTime\n================\n*/\ndouble I_FloatTime (void)\n{\n\ttime_t\tt;\n\t\n\ttime (&t);\n\t\n\treturn t;\n#if 0\n// more precise, less portable\n\tstruct timeval tp;\n\tstruct timezone tzp;\n\tstatic int\t\tsecbase;\n\n\tgettimeofday(&tp, &tzp);\n\t\n\tif (!secbase)\n\t{\n\t\tsecbase = tp.tv_sec;\n\t\treturn tp.tv_usec/1000000.0;\n\t}\n\t\n\treturn (tp.tv_sec - secbase) + tp.tv_usec/1000000.0;\n#endif\n}\n\n\n/*\n==============\nCOM_Parse\n\nParse a token out of a string\n==============\n*/\nchar *COM_Parse (char *data)\n{\n\tint\t\tc;\n\tint\t\tlen;\n\t\n\tlen = 0;\n\tcom_token[0] = 0;\n\t\n\tif (!data)\n\t\treturn NULL;\n\t\t\n// skip whitespace\nskipwhite:\n\twhile ( (c = *data) <= ' ')\n\t{\n\t\tif (c == 0)\n\t\t{\n\t\t\tcom_eof = true;\n\t\t\treturn NULL;\t\t\t// end of file;\n\t\t}\n\t\tdata++;\n\t}\n\t\n// skip // comments\n\tif (c=='/' && data[1] == '/')\n\t{\n\t\twhile (*data && *data != '\\n')\n\t\t\tdata++;\n\t\tgoto skipwhite;\n\t}\n\t\n\n// handle quoted strings specially\n\tif (c == '\\\"')\n\t{\n\t\tdata++;\n\t\tdo\n\t\t{\n\t\t\tc = *data++;\n\t\t\tif (c=='\\\"')\n\t\t\t{\n\t\t\t\tcom_token[len] = 0;\n\t\t\t\treturn data;\n\t\t\t}\n\t\t\tcom_token[len] = c;\n\t\t\tlen++;\n\t\t} while (1);\n\t}\n\n// parse single characters\n\tif (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\\'' || c==':')\n\t{\n\t\tcom_token[len] = c;\n\t\tlen++;\n\t\tcom_token[len] = 0;\n\t\treturn data+1;\n\t}\n\n// parse a regular word\n\tdo\n\t{\n\t\tcom_token[len] = c;\n\t\tdata++;\n\t\tlen++;\n\t\tc = *data;\n\tif (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\\'' || c==':')\n\t\t\tbreak;\n\t} while (c>32);\n\t\n\tcom_token[len] = 0;\n\treturn data;\n}\n\n\n\n/*\n=============================================================================\n\n\t\t\t\t\t\tMISC FUNCTIONS\n\n=============================================================================\n*/\n\n\nint\t\targc;\nchar\t*argv[MAX_NUM_ARGVS];\n\n/*\n============\nParseCommandLine\n============\n*/\nvoid ParseCommandLine (char *lpCmdLine)\n{\n\targc = 1;\n\targv[0] = \"programname\";\n\n\twhile (*lpCmdLine && (argc < MAX_NUM_ARGVS))\n\t{\n\t\twhile (*lpCmdLine && ((*lpCmdLine <= 32) || (*lpCmdLine > 126)))\n\t\t\tlpCmdLine++;\n\n\t\tif (*lpCmdLine)\n\t\t{\n\t\t\targv[argc] = lpCmdLine;\n\t\t\targc++;\n\n\t\t\twhile (*lpCmdLine && ((*lpCmdLine > 32) && (*lpCmdLine <= 126)))\n\t\t\t\tlpCmdLine++;\n\n\t\t\tif (*lpCmdLine)\n\t\t\t{\n\t\t\t\t*lpCmdLine = 0;\n\t\t\t\tlpCmdLine++;\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n}\n\n\n\n/*\n=================\nCheckParm\n\nChecks for the given parameter in the program's command line arguments\nReturns the argument number (1 to argc-1) or 0 if not present\n=================\n*/\nint CheckParm (char *check)\n{\n\tint             i;\n\n\tfor (i = 1;i<argc;i++)\n\t{\n\t\tif ( stricmp(check, argv[i]) )\n\t\t\treturn i;\n\t}\n\n\treturn 0;\n}\n\n\n\n\n/*\n==============\nParseNum / ParseHex\n==============\n*/\nint ParseHex (char *hex)\n{\n\tchar    *str;\n\tint    num;\n\n\tnum = 0;\n\tstr = hex;\n\n\twhile (*str)\n\t{\n\t\tnum <<= 4;\n\t\tif (*str >= '0' && *str <= '9')\n\t\t\tnum += *str-'0';\n\t\telse if (*str >= 'a' && *str <= 'f')\n\t\t\tnum += 10 + *str-'a';\n\t\telse if (*str >= 'A' && *str <= 'F')\n\t\t\tnum += 10 + *str-'A';\n\t\telse\n\t\t\tError (\"Bad hex number: %s\",hex);\n\t\tstr++;\n\t}\n\n\treturn num;\n}\n\n\nint ParseNum (char *str)\n{\n\tif (str[0] == '$')\n\t\treturn ParseHex (str+1);\n\tif (str[0] == '0' && str[1] == 'x')\n\t\treturn ParseHex (str+2);\n\treturn atol (str);\n}\n\n\n"
  },
  {
    "path": "q3radiant/QE3.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __QE3_H__\n#define __QE3_H__\n\n// disable data conversion warnings for gl\n#pragma warning(disable : 4244)     // MIPS\n#pragma warning(disable : 4136)     // X86\n#pragma warning(disable : 4051)     // ALPHA\n \n#include <windows.h>\n\nextern \"C\"\n{\n#include \"qgl.h\"\n}\n\n#include <math.h>\n#include <stdlib.h>\n#include <malloc.h>\n\n// this define to use HTREEITEM and MFC stuff in the headers\n#define QERTYPES_USE_MFC\n#include \"qertypes.h\"\n#include \"../libs/cmdlib.h\"\n#include \"mathlib.h\"\n#include \"parse.h\"\n#include \"lbmlib.h\"\n\n#include <commctrl.h>\n#include \"afxres.h\"\n#include \"resource.h\"\n\n#include \"qedefs.h\"\n\n#include \"qfiles.h\"\n\n#include \"textures.h\"\n#include \"brush.h\"\n#include \"entity.h\"\n#include \"map.h\"\n#include \"select.h\"\n#include \"splines/splines.h\"\n\n#include \"camera.h\"\n#include \"xy.h\"\n#include \"z.h\"\n#include \"mru.h\"\n\n#include \"undo.h\"\n\n#include \"terrain.h\"\n\n// the dec offsetof macro doesn't work very well...\n#define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier)\n\n\n// set these before calling CheckParm\nextern int myargc;\nextern char **myargv;\n\ndouble I_FloatTime (void);\n\nvoid\tError (char *error, ...);\nvoid\tWarning (char *error, ...);\nint\t\tCheckParm (char *check);\nvoid ParseCommandLine (char *lpCmdLine);\n\n\nint \tParseNum (char *str);\n\n\nchar *COM_Parse (char *data);\n\nextern\tchar\t\tcom_token[1024];\nextern\tqboolean\tcom_eof;\n\n#define\tMAX_NUM_ARGVS\t32\nextern\tint\t\targc;\nextern\tchar\t*argv[MAX_NUM_ARGVS];\n\n\ntypedef struct\n{\n\tint\t\tp1, p2;\n\tface_t\t*f1, *f2;\n} pedge_t;\n\ntypedef struct\n{\n\tint\t\t  iSize;\n\tint\t\t  iTexMenu;\t\t// nearest, linear, etc\n\tfloat\t  fGamma;\t\t\t// gamma for textures\n\tchar\t  szProject[256];\t// last project loaded\n\tvec3_t\tcolors[COLOR_LAST];\n\tqboolean  show_names;\n  qboolean  show_coordinates;\n\tint       exclude;\n  int     m_nTextureTweak;\n} SavedInfo_t;\n\n//\n// system functions\n//\n// TTimo NOTE: WINAPI funcs can be accessed by plugins\nvoid    Sys_UpdateStatusBar( void );\nvoid    WINAPI Sys_UpdateWindows (int bits);\nvoid    Sys_Beep (void);\nvoid    Sys_ClearPrintf (void);\nvoid    Sys_Printf (char *text, ...);\ndouble\tSys_DoubleTime (void);\nvoid    Sys_GetCursorPos (int *x, int *y);\nvoid    Sys_SetCursorPos (int x, int y);\nvoid    Sys_SetTitle (char *text);\nvoid    Sys_BeginWait (void);\nvoid    Sys_EndWait (void);\nvoid    Sys_Status(const char *psz, int part);\n\n/*\n** most of the QE globals are stored in this structure\n*/\ntypedef struct\n{\n\tqboolean d_showgrid;\n\tint      d_gridsize;\n\t\n\tint      d_num_entities;\n\t\n\tentity_t *d_project_entity;\n\t\n\tfloat     d_new_brush_bottom_z,\n\t\t      d_new_brush_top_z;\n\t\n\tHINSTANCE d_hInstance;\n\t\n\tHGLRC     d_hglrcBase;\n\tHDC       d_hdcBase;\n\t\n\tHWND      d_hwndMain;\n\tHWND      d_hwndCamera;\n\tHWND      d_hwndEdit;\n\tHWND      d_hwndEntity;\n\tHWND      d_hwndTexture;\n\tHWND      d_hwndXY;\n\tHWND      d_hwndZ;\n\tHWND      d_hwndStatus;\n\tHWND      d_hwndGroup;\n\tHWND      d_hwndMedia;\n\t\n\tvec3_t    d_points[MAX_POINTS];\n\tint       d_numpoints;\n\tpedge_t   d_edges[MAX_EDGES];\n\tint       d_numedges;\n\n\t// terrain variables\n\tfloat\t\t\t\td_terrainBrushSize;\n\tterrainnoise_t\t\td_terrainNoiseType;\n\tterrainfalloff_t\td_terrainFalloff;\n\tterrainbrush_t\t\td_terrainBrush;\n\tint\t\t\t\t\td_terrainWidth;\n\tint\t\t\t\t\td_terrainHeight;\n\n\tterrainVert_t\t*d_terrapoints[MAX_TERRA_POINTS];\n\tint\t\t\t\td_numterrapoints;\n\n\t\n\tint       d_num_move_points;\n\tfloat    *d_move_points[4096];\n\t\n\tqtexture_t\t*d_qtextures;\n\t\n\ttexturewin_t d_texturewin;\n\t\n\tint\t         d_pointfile_display_list;\n\t\n\txy_t         d_xyOld;\n\t\n\tLPMRUMENU    d_lpMruMenu;\n\t\n\tSavedInfo_t  d_savedinfo;\n\t\n\tint          d_workcount;\n\t\n\t// connect entities uses the last two brushes selected\n\tint\t\t\t d_select_count;\n\tbrush_t\t\t*d_select_order[2];\n\tvec3_t       d_select_translate;    // for dragging w/o making new display lists\n\tselect_t     d_select_mode;\n\tidPointListInterface *selectObject;\t// \n\t\n\tint\t\t     d_font_list;\n\t\n\tint          d_parsed_brushes;\n\t\n\tqboolean\tshow_blocks;\n\t\n\t// Timo\n\t// tells if we are internally using brush primitive (texture coordinates and map format)\n\t// this is a shortcut for IntForKey( g_qeglobals.d_project_entity, \"brush_primit\" )\n\t// NOTE: must keep the two ones in sync\n\tBOOL m_bBrushPrimitMode;\n\n\t// used while importing brush data from file or memory buffer\n\t// tells if conversion between map format and internal preferences ( m_bBrushPrimitMode ) is needed\n\tqboolean\tbNeedConvert;\n\tqboolean\tbOldBrushes;\n\tqboolean\tbPrimitBrushes;\n\t\n\tvec3_t  d_vAreaTL;\n\tvec3_t  d_vAreaBR;\n\t\n\t// tells if we are using .INI files for prefs instead of registry\n\tqboolean\tuse_ini;\n\t// even in .INI mode we use the registry for all void* prefs\n\tchar\t\tuse_ini_registry[64];\n\t\n\t//Timo\n\t// tells we have surface properties plugin\n\tqboolean\tbSurfacePropertiesPlugin;\n\t// tells we are using a BSP frontend plugin\n\tqboolean\tbBSPFrontendPlugin;\n\n\tqboolean dontDrawSelectedOutlines;\n\t\n} QEGlobals_t;\n\n//void *qmalloc (size_t size);\nchar *copystring (char *s);\nchar *ExpandReletivePath (char *p);\n\nvoid Pointfile_Delete (void);\nvoid WINAPI Pointfile_Check (void);\nvoid Pointfile_Next (void);\nvoid Pointfile_Prev (void);\nvoid Pointfile_Clear (void);\nvoid Pointfile_Draw( void );\nvoid Pointfile_Load( void );\n\n//\n// drag.c\n//\nvoid Drag_Begin (int x, int y, int buttons,\n\t\t   vec3_t xaxis, vec3_t yaxis,\n\t\t   vec3_t origin, vec3_t dir);\nvoid Drag_MouseMoved (int x, int y, int buttons);\nvoid Drag_MouseUp (int nButtons = 0);\n\n//\n// csg.c\n//\nvoid CSG_MakeHollow (void);\nvoid CSG_Subtract (void);\nvoid CSG_Merge (void);\n\n//\n// vertsel.c\n//\n\nvoid SetupVertexSelection (void);\nvoid SelectEdgeByRay (vec3_t org, vec3_t dir);\nvoid SelectVertexByRay (vec3_t org, vec3_t dir);\n\nvoid ConnectEntities (void);\n\nextern\tint\tupdate_bits;\n\nextern\tint\tscreen_width;\nextern\tint\tscreen_height;\n\nextern\tHANDLE\tbsp_process;\nextern HANDLE g_hBSPOutput;\nextern HANDLE g_hBSPInput;\n\n\nchar\t*TranslateString (char *buf);\n\nvoid ProjectDialog (void);\n\nvoid FillTextureMenu (CStringArray* pArray = NULL);\nvoid FillBSPMenu (void);\n\nBOOL CALLBACK Win_Dialog (\n    HWND hwndDlg,\t// handle to dialog box\n    UINT uMsg,\t// message\n    WPARAM wParam,\t// first message parameter\n    LPARAM lParam \t// second message parameter\n);\n\n\n//\n// win_cam.c\n//\nvoid WCam_Create (HINSTANCE hInstance);\n\n\n//\n// win_xy.c\n//\nvoid WXY_Create (HINSTANCE hInstance);\n\n//\n// win_z.c\n//\nvoid WZ_Create (HINSTANCE hInstance);\n\n//\n// win_ent.c\n//\n\n\n//\n// win_main.c\n//\nvoid Main_Create (HINSTANCE hInstance);\nextern BOOL SaveWindowState(HWND hWnd, const char *pszName);\nextern BOOL LoadWindowState(HWND hWnd, const char *pszName);\n\nextern BOOL SaveRegistryInfo(const char *pszName, void *pvBuf, long lSize);\nextern BOOL LoadRegistryInfo(const char *pszName, void *pvBuf, long *plSize);\n\n//\n// entityw.c\n//\nBOOL CreateEntityWindow(HINSTANCE hInstance);\nvoid FillClassList (void);\nBOOL UpdateEntitySel(eclass_t *pec);\t\nvoid SetInspectorMode(int iType);\nint DrawTexControls(HWND hWnd);\nvoid SetSpawnFlags(void);\nvoid GetSpawnFlags(void);\nvoid SetKeyValuePairs(bool bClearMD3 = false);\nextern void BuildGammaTable(float g);\nBOOL GetSelectAllCriteria(CString &strKey, CString &strVal);\n\n\n// win_dlg.c\n\nvoid DoGamma(void);\nvoid DoFind(void);\nvoid DoRotate(void);\nvoid DoSides(bool bCone = false, bool bSphere = false, bool bTorus = false);\nvoid DoAbout(void);\nvoid DoSurface();\n\n/*\n** QE function declarations\n*/\nvoid     QE_CheckAutoSave( void );\nvoid     WINAPI QE_ConvertDOSToUnixName( char *dst, const char *src );\nvoid     QE_CountBrushesAndUpdateStatusBar( void );\nvoid     WINAPI QE_CheckOpenGLForErrors(void);\nvoid     QE_ExpandBspString (char *bspaction, char *out, char *mapname, bool useTemps);\nvoid     QE_Init (void);\nqboolean QE_KeyDown (int key, int nFlags = 0);\nqboolean QE_LoadProject (char *projectfile);\nqboolean QE_SingleBrush (bool bQuiet = false);\n\n\n// sys stuff\nvoid Sys_MarkMapModified (void);\n\n/*\n** QE Win32 function declarations\n*/\nint  WINAPI QEW_SetupPixelFormat(HDC hDC, qboolean zbuffer );\nvoid QEW_StopGL( HWND hWnd, HGLRC hGLRC, HDC hDC );\n\n/*\n** extern declarations\n*/\nextern QEGlobals_t   g_qeglobals;\n\n//++timo clean (moved into qertypes.h)\n//enum VIEWTYPE {YZ, XZ, XY};\nqboolean IsBrushSelected(brush_t* bSel);\n\n// curve brushes\n\nvoid Curve_MakeCurvedBrush (qboolean negative, qboolean top, qboolean bottom, \n\t\t\t\t\tqboolean s1, qboolean s2, qboolean s3, qboolean s4);\n\nvoid Curve_Invert (void);\n\nvoid Curve_AddFakePlanes( brush_t *B );\nvoid Curve_StripFakePlanes( brush_t *B );\nvoid Curve_BuildPoints (brush_t *b);\nvoid Curve_XYDraw (brush_t *b);\nvoid Curve_CameraDraw (brush_t *b);\n\nvoid Curve_WriteFile (char *name);\n\n\n// patch stuff\n\nextern bool g_bSameView;\nextern int  g_nPatchClickedView;\nbool within(vec3_t vTest, vec3_t vTL, vec3_t vBR);\n\nvoid Brush_RebuildBrush(brush_t *b, vec3_t vMins, vec3_t vMaxs );\npatchMesh_t* MakeNewPatch();\nbrush_t* AddBrushForPatch(patchMesh_t *pm, bool bLinkToWorld = true);\nbrush_t* Patch_GenericMesh(int nWidth, int nHeight, int nOrientation = 2, bool bDeleteSource = true, bool bOverride = false);\nvoid Patch_ReadFile (char *name);\nvoid Patch_WriteFile (char *name); \nvoid Patch_BuildPoints (brush_t *b);\nvoid Patch_Move(patchMesh_t *p, const vec3_t vMove, bool bRebuild = false);\n//++timo had to add a default value for bSnap (see Patch_ApplyMatrix call from Select_ApplyMatrix in select.cpp)\nvoid Patch_ApplyMatrix(patchMesh_t *p, const vec3_t vOrigin, const vec3_t vMatrix[3], bool bSnap = false);\nvoid Patch_EditPatch();\nvoid Patch_Deselect();\nvoid Patch_Deselect(patchMesh_t *p);\nvoid Patch_Delete(patchMesh_t *p);\nint  Patch_MemorySize(patchMesh_t *p);\nvoid Patch_Select(patchMesh_t *p);\nvoid Patch_Scale(patchMesh_t *p, const vec3_t vOrigin, const vec3_t vAmt, bool bRebuilt = true);\nvoid Patch_Cleanup();\nvoid Patch_SetView(int n);\nvoid Patch_SetTexture(patchMesh_t *p, texdef_t *tex_def, IPluginTexdef* pPlugTexdef = NULL);\nvoid Patch_BrushToMesh(bool bCone = false, bool bBevel = false, bool bEndcap = false, bool bSquare = false, int nHeight = 3);\nbool Patch_DragScale(patchMesh_t *p, vec3_t vAmt, vec3_t vMove);\nvoid Patch_ReadBuffer(char* pBuff, bool bSelect = false);\nvoid Patch_WriteFile (CMemFile* pMemFile);\nvoid Patch_UpdateSelected(vec3_t vMove);\nvoid Patch_AddRow(patchMesh_t *p);\nbrush_t* Patch_Parse(bool bOld);\nvoid Patch_Write (patchMesh_t *p, FILE *f);\nvoid Patch_Write (patchMesh_t *p, CMemFile *file);\nvoid Patch_AdjustColumns(patchMesh_t *p, int nCols);\nvoid Patch_AdjustRows(patchMesh_t *p, int nRows);\nvoid Patch_AdjustSelected(bool bInsert, bool bColumn, bool bFlag);\npatchMesh_t* Patch_Duplicate(patchMesh_t *pFrom);\nvoid Patch_RotateTexture(patchMesh_t *p, float fAngle);\nvoid Patch_ScaleTexture(patchMesh_t *p, float fx, float fy, bool bFixup = true);\nvoid Patch_ShiftTexture(patchMesh_t *p, float fx, float fy);\nvoid Patch_DrawCam(patchMesh_t *p);\nvoid Patch_DrawXY(patchMesh_t *p);\nvoid Patch_InsertColumn(patchMesh_t *p, bool bAdd);\nvoid Patch_InsertRow(patchMesh_t *p, bool bAdd);\nvoid Patch_RemoveRow(patchMesh_t *p, bool bFirst);\nvoid Patch_RemoveColumn(patchMesh_t *p, bool bFirst);\nvoid Patch_ToggleInverted();\nvoid Patch_Restore(patchMesh_t *p);\nvoid Patch_Save(patchMesh_t *p);\nvoid Patch_SetTextureInfo(texdef_t* pt);\nvoid Patch_NaturalTexturing();\nvoid Patch_ResetTexturing(float fx, float fy);\nvoid Patch_FitTexturing();\nvoid Patch_BendToggle();\nvoid Patch_StartInsDel();\nvoid Patch_BendHandleTAB();\nvoid Patch_BendHandleENTER();\nvoid Patch_SelectBendNormal();\nvoid Patch_SelectBendAxis();\nbool WINAPI OnlyPatchesSelected();\nbool WINAPI AnyPatchesSelected();\npatchMesh_t* SinglePatchSelected();\nvoid Patch_CapCurrent(bool bInvertedBevel = false, bool bInvertedEndcap = false);\nvoid Patch_DisperseRows();\nvoid Patch_DisperseColumns();\nvoid Patch_NaturalizeSelected(bool bCap = false, bool bCycleCap = false);\nvoid Patch_SelectAreaPoints();\nvoid Patch_InvertTexture(bool bY);\nvoid Patch_InsDelToggle();\nvoid Patch_InsDelHandleTAB();\nvoid Patch_InsDelHandleENTER();\nvoid Patch_SetOverlays();\nvoid Patch_ClearOverlays();\nvoid Patch_Thicken(int nAmount, bool bSeam);\nvoid Patch_Transpose();\nvoid Patch_Freeze();\nvoid Patch_UnFreeze(bool bAll);\nconst char* Patch_GetTextureName();\nvoid Patch_FindReplaceTexture(brush_t *pb, const char *pFind, const char *pReplace, bool bForce);\nvoid Patch_ReplaceQTexture(brush_t *pb, qtexture_t *pOld, qtexture_t *pNew);\nvoid Select_SnapToGrid();\nextern bool g_bPatchShowBounds;\nextern bool g_bPatchWireFrame;\nextern bool g_bPatchWeld;\nextern bool g_bPatchDrillDown;\nextern bool g_bPatchInsertMode;\nextern bool g_bPatchBendMode;\nextern vec3_t g_vBendOrigin;\nvoid Patch_FromTriangle(vec5_t vx, vec5_t vy, vec5_t vz);\nconst char* Patch_GetKeyValue(patchMesh_t *p, const char *pKey);\nvoid Patch_SetEpair(patchMesh_t *p, const char *pKey, const char *pValue);\n\n\n\n// group stuff\n// group_t are loaded / saved through \"group_info\" entities\n// they hold epairs for group settings and additionnal access info (tree nodes)\ntypedef struct group_s\n{\n\tstruct group_s\t*next;\n\tepair_t *epairs;\n\tHTREEITEM itemOwner;\n} group_t;\n\n// NOTES: grouping only enabled in brush primitives mode\n// grouping works by naming brushes and setting display properties\n// the group hierarchy is not related with the map hierarchy (entity list, brushes etc.)\n// brushes with no group are under the \"world\" node (default for all brushes)\n// void Group_GetListFromWorld(CStringArray *pArray);\nvoid Group_RemoveListFromWorld();\n// void Group_SetListToWorld(CStringArray *pArray);\n// void Group_BuildTree(CTreeCtrl *pTree);\n// void Group_DecomposeTree(CTreeCtrl *pTree);\n// save group_t as \"classname\" \"group_info\" things\nvoid Group_Save(FILE *f);\n// clean the brushes ownerItem, clean the treeview and rebuild everything\n// is usually called when loading a new map, but may be called anytime\nvoid Group_Init();\nvoid Group_Add(entity_t *e);\n\n// remove a brush from it's current group, will erase the \"group\" epair if any, and delete the tree control node\nvoid Group_RemoveBrush(brush_t *b);\nvoid Group_AddToWorld(brush_t *b);\n// will remove brush of it's current group if any, and will add it wherever needed according to it's \"group\" key\nvoid Group_AddToProperGroup(brush_t *b);\nvoid Group_AddToSelected(brush_t *b);\n// allocate a new group, set name\ngroup_t* Group_Alloc(const char *name);\n// we use entities to store information about the groups\n// these entities are not linked into the world, and they have no brushes\n// only loaded / saved in map file\ngroup_t* Group_ForName(const char *name);\n\n// Timo\n// new brush primitive stuff\nvoid ComputeAxisBase(vec3_t normal,vec3_t texS,vec3_t texT );\nvoid FaceToBrushPrimitFace(face_t *f);\nvoid EmitBrushPrimitTextureCoordinates(face_t *, winding_t *);\n// EmitTextureCoordinates, is old code used for brush to brush primitive conversion\nvoid EmitTextureCoordinates ( float *xyzst, qtexture_t *q, face_t *f);\nvoid BrushPrimit_Parse(brush_t *);\n// compute a fake shift scale rot representation from the texture matrix\nvoid TexMatToFakeTexCoords( vec_t texMat[2][3], float shift[2], float *rot, float scale[2] );\nvoid FakeTexCoordsToTexMat( float shift[2], float rot, float scale[2], vec_t texMat[2][3] );\nvoid ConvertTexMatWithQTexture( brushprimit_texdef_t *texMat1, qtexture_t *qtex1, brushprimit_texdef_t *texMat2, qtexture_t *qtex2 );\n// texture locking\nvoid Face_MoveTexture_BrushPrimit(face_t *f, vec3_t delta);\nvoid Select_ShiftTexture_BrushPrimit( face_t *f, int x, int y );\nvoid RotateFaceTexture_BrushPrimit(face_t *f, int nAxis, float fDeg, vec3_t vOrigin );\n// used in CCamWnd::ShiftTexture_BrushPrimit\nvoid ComputeBest2DVector( vec3_t v, vec3_t X, vec3_t Y, int &x, int &y );\n\n\n//\n// eclass.cpp\n//\nextern qboolean parsing_single;\nextern qboolean eclass_found;\nextern eclass_t *eclass_e;\nvoid Eclass_ScanFile( char *filename );\n\n// for interfaces, we require main plugin header included\n#include \"qerplugin.h\"\n\n//\n// SurfaceDlg.cpp and surface properties plugin\n//\n//++timo some patch in/out stuff is in there, needs to be moved out in a dedicated interface\nvoid WINAPI Patch_Rebuild(patchMesh_t *p);\n#include \"isurfaceplugin.h\"\nextern _QERPlugSurfaceTable g_SurfaceTable;\n\n//\n// OpenGL interface\n//\n#include \"igl.h\"\nHGLRC WINAPI QERApp_GetQeglobalsHGLRC();\nvoid WINAPI QERApp_HookXYGLWindow(IGLWindow* pGLW);\nvoid WINAPI QERApp_UnHookGLWindow(IGLWindow* pGLW);\nvoid DrawPluginEntities( VIEWTYPE vt );\n\n//\n// ISelectedFace interface\n//\n#include \"ISelectedFace.h\"\nint WINAPI QERApp_ISelectedFace_GetTextureNumber();\nint WINAPI QERApp_GetFaceInfo(_QERFaceData *pFaceData, winding_t *pWinding);\nint WINAPI QERApp_SetFaceInfo(_QERFaceData *pFaceData);\nvoid WINAPI QERApp_GetTextureSize( int Size[2] );\n\n//\n// IEpairs interface\n//\n#include \"IEpairs.h\"\n#include \"EpairsWrapper.h\"\n\n//\n// IPluginEntities interface\n//\n#include \"IPluginEntities.h\"\nint WINAPI QERApp_EClassScanDir( char *dir, HMODULE plugID );\n\n//\n// ShaderInfo.cpp\n//\n#include \"ShaderInfo.h\"\n\n//\n// TexWnd.cpp\n//\nCShaderInfo* hasShader(const char *pName);\n\n//\n// IScripLib interface\n// GetToken, UnGetToken, etc.\n#include \"IScriplib.h\"\nextern FILE *g_File;\nvoid WINAPI QERApp_MapPrintf_FILE( char *text, ... );\n\n//\n// ISurfacePlugin interface\n//\nvoid WINAPI QERApp_GetTwoSelectedPatch( patchMesh_t **p1, patchMesh_t **p2 );\n\n//\n// IBSPFrontend interface\n//\n#include \"IBSPFrontend.h\"\nextern _QERPlugBSPFrontendTable g_BSPFrontendTable;\nextern CStringArray g_BSPFrontendCommands;\n\n//\n// IMessaging interface\n#include \"IMessaging.h\"\n#include \"Messaging.h\"\nvoid WINAPI QERApp_HookWindow(IWindowListener* pListen);\nvoid WINAPI QERApp_UnHookWindow(IWindowListener* pListen);\nIXYWndWrapper* WINAPI QERApp_GetXYWndWrapper();\nvoid WINAPI QERApp_HookListener(IListener* pListen, int Msg);\nint  WINAPI QERApp_UnHookListener(IListener* pListen);\nvoid DispatchRadiantMsg( int Msg );\n// dispatch for IWindowListener entities\nvoid DispatchOnMouseMove(UINT nFlags, int x, int y);\nbool DispatchOnLButtonDown(UINT nFlags, int x, int y);\nbool DispatchOnLButtonUp(UINT nFlags, int x, int y);\n\n//\n// IShaders interface\nCShaderInfo* SetNameShaderInfo(qtexture_t* q, const char* pPath, const char* pName);\nqtexture_t* Texture_LoadTGATexture (unsigned char* pPixels, int nWidth, int nHeight, char* pPath, int nFlags, int nContents, int nValue );\n#include \"IShaders.h\"\nqtexture_t* WINAPI QERApp_TryTextureForName(const char* name);\n\n\n\n#endif\n"
  },
  {
    "path": "q3radiant/QEDEFS.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __QEDEFS_H__\n#define __QEDEFS_H__\n\n#define QE_VERSION  0x0501\n\n#define QE3_STYLE (WS_OVERLAPPED | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_THICKFRAME | WS_CAPTION | WS_SYSMENU | WS_CHILD)\n#define QE3_STYLE2 (WS_OVERLAPPED | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_MINIMIZEBOX | WS_THICKFRAME | WS_CAPTION | WS_SYSMENU)\n#define QE3_CHILDSTYLE (WS_OVERLAPPED | WS_MINIMIZEBOX | WS_THICKFRAME | WS_CAPTION | WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_MAXIMIZEBOX)\n\n#define QE3_SPLITTER_STYLE (WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS)\n\n\n\n#define QE_AUTOSAVE_INTERVAL  5       // number of minutes between autosaves\n\n#define\t_3DFXCAMERA_WINDOW_CLASS\t\"Q3DFXCamera\"\n#define\tCAMERA_WINDOW_CLASS\t\"QCamera\"\n#define\tXY_WINDOW_CLASS\t    \"QXY\"\n#define\tZ_WINDOW_CLASS   \t\"QZ\"\n#define\tENT_WINDOW_CLASS\t\"QENT\"\n#define\tTEXTURE_WINDOW_CLASS\t\"QTEX\"\n\n#define\tZWIN_WIDTH\t40\n#define CWIN_SIZE\t(0.4)\n\n#define\tMAX_EDGES\t512\n//#define\tMAX_POINTS\t1024\n#define\tMAX_POINTS\t2048\n\n#define\tMAX_TERRA_POINTS 4096\n\n#define\tCMD_TEXTUREWAD\t60000\n#define\tCMD_BSPCOMMAND\t61000\n\n#define\tPITCH\t0\n#define\tYAW\t\t1\n#define\tROLL\t2\n\n#define QE_TIMER0   1\n\n#define\tPLANE_X\t\t0\n#define\tPLANE_Y\t\t1\n#define\tPLANE_Z\t\t2\n#define\tPLANE_ANYX\t3\n#define\tPLANE_ANYY\t4\n#define\tPLANE_ANYZ\t5\n\n#define\tON_EPSILON\t0.01\n\n#define\tKEY_FORWARD\t\t1\n#define\tKEY_BACK\t\t2\n#define\tKEY_TURNLEFT\t4\n#define\tKEY_TURNRIGHT\t8\n#define\tKEY_LEFT\t\t16\n#define\tKEY_RIGHT\t\t32\n#define\tKEY_LOOKUP\t\t64\n#define\tKEY_LOOKDOWN\t128\n#define\tKEY_UP\t\t\t256\n#define\tKEY_DOWN\t\t512\n\n// xy.c\n#define EXCLUDE_LIGHTS\t     0x01\n#define EXCLUDE_ENT\t\t       0x02\n#define EXCLUDE_PATHS\t       0x04\n#define EXCLUDE_WATER\t       0x08\n#define EXCLUDE_WORLD\t       0x10\n#define EXCLUDE_CLIP\t       0x20\n#define\tEXCLUDE_DETAIL\t     0x40\n#define\tEXCLUDE_CURVES\t     0x80\n#define\tINCLUDE_EASY\t      0x100\n#define\tINCLUDE_NORMAL\t    0x200\n#define\tINCLUDE_HARD\t      0x400\n#define\tINCLUDE_DEATHMATCH\t0x800\n#define EXCLUDE_HINT\t     0x1000\n#define EXCLUDE_CAULK      0x2000\n#define EXCLUDE_ANGLES     0x4000\n#define EXCLUDE_TERRAIN    0x8000\n\n\n//\n// menu indexes for modifying menus\n//\n#define\tMENU_VIEW\t\t2\n#define\tMENU_BSP\t\t4\n#define\tMENU_TEXTURE\t6\n#define\tMENU_PLUGIN\t11\n\n\n// odd things not in windows header...\n#define\tVK_COMMA\t\t188\n#define\tVK_PERIOD\t\t190\n\n/*\n** window bits\n*/\n//++timo moved to qertypes.h\n// clean\n/*\n#define\tW_CAMERA\t\t  0x0001\n#define\tW_XY\t\t\t    0x0002\n#define\tW_XY_OVERLAY\t0x0004\n#define\tW_Z\t\t\t\t    0x0008\n#define\tW_TEXTURE\t\t  0x0010\n#define\tW_Z_OVERLAY\t\t0x0020\n#define W_CONSOLE\t\t  0x0040\n#define W_ENTITY\t\t  0x0080\n#define W_CAMERA_IFON 0x0100\n#define W_XZ          0x0200  //--| only used for patch vertex manip stuff\n#define W_YZ          0x0400  //--|\n#define\tW_ALL\t\t\t0xFFFFFFFF\n*/\n\n#define\tCOLOR_TEXTUREBACK\t0\n#define\tCOLOR_GRIDBACK\t\t1\n#define\tCOLOR_GRIDMINOR\t\t2\n#define\tCOLOR_GRIDMAJOR\t\t3\n#define\tCOLOR_CAMERABACK\t4\n#define COLOR_ENTITY      5\n#define COLOR_GRIDBLOCK   6\n#define COLOR_GRIDTEXT    7\n#define COLOR_BRUSHES     8\n#define COLOR_SELBRUSHES  9\n#define COLOR_CLIPPER     10\n#define COLOR_VIEWNAME    11\n#define COLOR_LAST        12\n\n// classes\n#define ENTITY_WIREFRAME\t\t0x00001\n#define ENTITY_SKIN_MODEL\t\t0x00010\n#define ENTITY_SELECTED_ONLY\t0x00100\n#define ENTITY_BOXED\t\t\t0x01000\n\n// menu settings\n#define ENTITY_BOX\t\t\t\t0x01000\n#define ENTITY_WIRE\t\t\t\t0x00001\n#define ENTITY_SELECTED\t\t\t0x00101\n#define ENTITY_SKINNED \t\t\t0x00010\n#define ENTITY_SKINNED_BOXED\t0x01010\n#define ENTITY_SELECTED_SKIN\t0x00110\n\n\n\n#endif\n"
  },
  {
    "path": "q3radiant/QERTYPES.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// qertypes.h\n//\n// common types\n// merged from brush.h, etc. for plugin support\n//\n#ifndef _QERTYPE_H\n#define _QERTYPE_H\n\n#ifndef __BYTEBOOL__\n#define __BYTEBOOL__\ntypedef boolean qboolean;\n//typedef unsigned char byte;\n#endif\n\n#define\tMAXPOINTS\t16\n\ntypedef float vec_t;\ntypedef vec_t vec2_t[2];\ntypedef vec_t vec3_t[3];\n\n#include \"splines/math_vector.h\"\n\n#ifndef M_PI\n#define M_PI\t\t3.14159265358979323846\t// matches value in gcc v2 math.h\n#endif\n\nclass texdef_t\n{\npublic:\n  texdef_t()\n  {\n    name = new char[1];\n    name[0] = '\\0';\n  }\n  ~texdef_t()\n  {\n    delete []name;\n    name = NULL;\n  }\n\n  const char *Name( void )\n  {\n\t  if ( name ) {\n\t\t  return name;\n\t  }\n\n\t  return \"\";\n  }\n\n  void SetName(const char *p)\n  {\n    if (name)\n    {\n      delete []name;\n    }\n    if (p)\n    {\n      name = strcpy(new char[strlen(p)+1], p);\n    }\n    else\n    {\n      name = new char[1];\n      name[0] = '\\0';\n    }\n  }\n\n  texdef_t& operator =(const texdef_t& rhs)\n  {\n    if (&rhs != this)\n    {\n      SetName(rhs.name);\n      shift[0] = rhs.shift[0];\n      shift[1] = rhs.shift[1];\n      rotate = rhs.rotate;\n      scale[0] = rhs.scale[0];\n      scale[1] = rhs.scale[1];\n      contents = rhs.contents;\n      flags = rhs.flags;\n      value = rhs.value;\n    }\n    return *this;\n  }\n\t//char\tname[128];\n\tchar\t*name;\n\tfloat\tshift[2];\n\tfloat\trotate;\n\tfloat\tscale[2];\n\tint\t\tcontents;\n\tint\t\tflags;\n\tint\t\tvalue;\n};\n\n// Timo\n// new brush primitive texdef\ntypedef struct brushprimit_texdef_s\n{\n\tvec_t\tcoords[2][3];\n} brushprimit_texdef_t;\n\nclass texturewin_t\n{\npublic:\n  texturewin_t()\n  {\n  }\n  ~texturewin_t()\n  {\n  }\n\tint\t\t\twidth, height;\n\tint\t\t\toriginy;\n\t// add brushprimit_texdef_t for brush primitive coordinates storage\n\tbrushprimit_texdef_t\tbrushprimit_texdef;\n\tint m_nTotalHeight;\n\t// surface plugin, must be casted to a IPluginTexdef*\n\tvoid* pTexdef;\n\ttexdef_t\ttexdef;\n};\n\n#define QER_TRANS     0x00000001\n#define QER_NOCARVE   0x00000002\n\ntypedef struct qtexture_s\n{\n\tstruct\tqtexture_s *next;\n\tchar\tname[64];\t\t// includes partial directory and extension\n  int\t\twidth,  height;\n\tint\t\tcontents;\n\tint\t\tflags;\n\tint\t\tvalue;\n\tint\t\ttexture_number;\t// gl bind number\n  \n\t// name of the .shader file\n  char  shadername[1024]; // old shader stuff\n  qboolean bFromShader;   // created from a shader\n  float fTrans;           // amount of transparency\n  int   nShaderFlags;     // qer_ shader flags\n\tvec3_t\tcolor;\t\t\t    // for flat shade mode\n\tqboolean\tinuse;\t\t    // true = is present on the level\n\n\t// cast this one to an IPluginQTexture if you are using it\n\t// NOTE: casting can be done with a GETPLUGINQTEXTURE defined in isurfaceplugin.h\n\t// TODO: if the __ISURFACEPLUGIN_H_ header is used, use a union { void *pData; IPluginQTexture *pPluginQTexture } kind of thing ?\n\tvoid\t\t\t\t\t*pData;\n\n\t//++timo FIXME: this is the actual filename of the texture\n\t// this will be removed after shader code cleanup\n\tchar filename[64];\n\n} qtexture_t;\n\n// NOTE: don't trust this definition!\n// you should read float points[..][5]\n// see NewWinding definition\n#define MAX_POINTS_ON_WINDING 64\ntypedef struct\n{\n\tint\t\tnumpoints;\n\tint\t\tmaxpoints;\n\tfloat \tpoints[8][5];\t\t\t// variable sized\n} winding_t;\n\ntypedef struct\n{\n    vec3_t\tnormal;\n    double\tdist;\n    int\t\ttype;\n} plane_t;\n\n//++timo texdef and brushprimit_texdef are static\n// TODO : do dynamic ?\ntypedef struct face_s\n{\n\tstruct face_s\t\t\t*next;\n\tstruct face_s\t\t\t*original;\t\t//used for vertex movement\n\tvec3_t\t\t\t\t\tplanepts[3];\n\ttexdef_t\t\t\t\ttexdef;\n\tplane_t\t\t\t\t\tplane;\n\n\twinding_t\t\t\t\t*face_winding;\n\n\tvec3_t\t\t\t\t\td_color;\n\tqtexture_t\t\t\t\t*d_texture;\n\n\t// Timo new brush primit texdef\n\tbrushprimit_texdef_t\tbrushprimit_texdef;\n\n\t// cast this one to an IPluginTexdef if you are using it\n\t// NOTE: casting can be done with a GETPLUGINTEXDEF defined in isurfaceplugin.h\n\t// TODO: if the __ISURFACEPLUGIN_H_ header is used, use a union { void *pData; IPluginTexdef *pPluginTexdef } kind of thing ?\n\tvoid\t\t\t\t\t*pData;\n} face_t;\n\ntypedef struct {\n\tvec3_t\txyz;\n\tfloat\tsideST[2];\n\tfloat\tcapST[2];\n} curveVertex_t;\n\ntypedef struct {\n\tcurveVertex_t\tv[2];\n} sideVertex_t;\n\n\n#define\tMIN_PATCH_WIDTH\t\t3\n#define\tMIN_PATCH_HEIGHT \t3\n\n#define\tMAX_PATCH_WIDTH\t\t16\n#define\tMAX_PATCH_HEIGHT\t16\n\n// patch type info\n// type in lower 16 bits, flags in upper\n// endcaps directly follow this patch in the list\n\n// types\n#define PATCH_GENERIC     0x00000000    // generic flat patch\n#define PATCH_CYLINDER    0x00000001    // cylinder\n#define PATCH_BEVEL       0x00000002    // bevel\n#define PATCH_ENDCAP      0x00000004    // endcap\n#define PATCH_HEMISPHERE  0x00000008    // hemisphere\n#define PATCH_CONE        0x00000010    // cone\n#define PATCH_TRIANGLE    0x00000020    // simple tri, assumes 3x3 patch\n\n// behaviour styles\n#define PATCH_CAP         0x00001000    // flat patch applied as a cap\n#define PATCH_SEAM        0x00002000    // flat patch applied as a seam\n#define PATCH_THICK       0x00004000    // patch applied as a thick portion\n\n// styles\n#define PATCH_BEZIER      0x00000000    // default bezier\n#define PATCH_BSPLINE     0x10000000    // bspline\n\n#define PATCH_TYPEMASK     0x00000fff    // \n#define PATCH_BTYPEMASK    0x0000f000    // \n#define PATCH_STYLEMASK    0xffff0000    // \n\ntypedef struct {\n\tvec3_t\t\txyz;\n\tfloat\t\tst[2];\n\tfloat\t\tlightmap[2];\n\tvec3_t\t\tnormal;\n} drawVert_t;\n\n// used in brush primitive AND entities\ntypedef struct epair_s\n{\n\tstruct epair_s\t*next;\n\tchar\t*key;\n\tchar\t*value;\n} epair_t;\n\nstruct brush_s;\ntypedef struct brush_s brush_t;\n\ntypedef struct {\n  int\twidth, height;\t\t// in control points, not patches\n  int   contents, flags, value, type;\n  qtexture_t *d_texture;\n  drawVert_t ctrl[MAX_PATCH_WIDTH][MAX_PATCH_HEIGHT];\n  brush_t *pSymbiot;\n  qboolean bSelected;\n  qboolean bOverlay;\n  qboolean bDirty;\n  int  nListID;\n\tepair_t *epairs;\n  // cast this one to an IPluginTexdef if you are using it\n  // NOTE: casting can be done with a GETPLUGINTEXDEF defined in isurfaceplugin.h\n  // TODO: if the __ISURFACEPLUGIN_H_ header is used, use a union { void *pData; IPluginTexdef *pPluginTexdef } kind of thing ?\n  void\t\t\t\t\t*pData;\n} patchMesh_t;\n\ntypedef struct {\n\tint\t\t\t\tindex;\n\tqtexture_t\t\t*texture;\n\ttexdef_t\t\ttexdef;\n} terrainFace_t;\n\ntypedef struct {\n\tfloat\t\t\theight;\n\tfloat\t\t\tscale;\n\tterrainFace_t\ttri;\n\tvec4_t\t\t\trgba;\n\tvec3_t\t\t\tnormal;\n\tvec3_t\t\t\txyz;\n} terrainVert_t;\n\n#define MAX_TERRAIN_TEXTURES 128\ntypedef struct {\n\tint\t\t\t\twidth, height;\n\n\tvec3_t\t\t\tmins, maxs;\n\tvec3_t\t\t\torigin;\n\tfloat\t\t\tscale_x;\n\tfloat\t\t\tscale_y;\n\n\tint\t\t\t\tnumtextures;\n\tqtexture_t\t\t*textures[ MAX_TERRAIN_TEXTURES ];\n\n\tterrainVert_t\t*heightmap;       // width * height\n\n\tepair_t\t\t\t*epairs;\n\n\tbrush_s\t\t\t*pSymbiot;\n\tbool\t\t\tbSelected;\n\tbool\t\t\tbDirty;\n\tint\t\t\t\tnListID;\n} terrainMesh_t;\n\ntypedef struct brush_s\n{\n\tstruct brush_s\t*prev, *next;\t// links in active/selected\n\tstruct brush_s\t*oprev, *onext;\t// links in entity\n\tstruct entity_s\t*owner;\n\tvec3_t\tmins, maxs;\n\tface_t     *brush_faces;\n\n\tqboolean bModelFailed;\n\t//\n\t// curve brush extensions\n\t// all are derived from brush_faces\n\tqboolean\tpatchBrush;\n\tqboolean\thiddenBrush;\n\tqboolean\tterrainBrush;\n  \n  //int nPatchID;\n\n\tpatchMesh_t *pPatch;\n\tterrainMesh_t\t*pTerrain;\n\n\tstruct entity_s *pUndoOwner;\n\n\tint undoId;\t\t\t\t\t\t//undo ID\n\tint redoId;\t\t\t\t\t\t//redo ID\n\tint ownerId;\t\t\t\t\t//entityId of the owner entity for undo\n\n\t// TTimo: HTREEITEM is MFC, some plugins really don't like it\n#ifdef QERTYPES_USE_MFC\n\tint numberId;         // brush number\n\tHTREEITEM itemOwner;  // owner for grouping\n#else\n\tint numberId;\n\tDWORD itemOwner;\n#endif\n\n\t// brush primitive only\n\tepair_t *epairs;\n\n} brush_t;\n\n\n#define\tMAX_FLAGS\t8\n\n\ntypedef struct trimodel_t\n{\n  vec3_t v[3];\n  float  st[3][2];\n} trimodel;\n\ntypedef struct entitymodel_t\n{\n  struct entitymodel_t *pNext;\n  int nTriCount;\n  trimodel *pTriList;\n  int nTextureBind;\n  int nSkinWidth;\n  int nSkinHeight;\n  int\tnModelPosition;\n} entitymodel;\n\n\n// eclass show flags\n\n#define     ECLASS_LIGHT      0x00000001\n#define     ECLASS_ANGLE      0x00000002\n#define     ECLASS_PATH       0x00000004\n#define     ECLASS_MISCMODEL  0x00000008\n#define\t\tECLASS_PLUGINENTITY 0x00000010\n\ntypedef struct eclass_s\n{\n\tstruct eclass_s *next;\n\tchar\t*name;\n\tqboolean\tfixedsize;\n\tqboolean\tunknown;\t\t// wasn't found in source\n\tvec3_t\tmins, maxs;\n\tvec3_t\tcolor;\n\ttexdef_t\ttexdef;\n\tchar\t*comments;\n\tchar\tflagnames[MAX_FLAGS][32];\n\n/*\n  int nTriCount;\n  trimodel *pTriList;\n  int nTextureBind;\n  int nSkinWidth, nSkinHeight;\n*/\n  entitymodel *model;\n  char\t*modelpath;\n  char\t*skinpath;\n  int   nFrame;\n  unsigned int nShowFlags;\n\n  HMODULE\thPlug;\n} eclass_t;\n\nextern\teclass_t\t*eclass;\n\n/*\n** window bits\n*/\n#define\tW_CAMERA\t\t  0x0001\n#define\tW_XY\t\t\t    0x0002\n#define\tW_XY_OVERLAY\t0x0004\n#define\tW_Z\t\t\t\t    0x0008\n#define\tW_TEXTURE\t\t  0x0010\n#define\tW_Z_OVERLAY\t\t0x0020\n#define W_CONSOLE\t\t  0x0040\n#define W_ENTITY\t\t  0x0080\n#define W_CAMERA_IFON 0x0100\n#define W_XZ          0x0200  //--| only used for patch vertex manip stuff\n#define W_YZ          0x0400  //--|\n#define W_GROUP       0x0800 \n#define W_MEDIA       0x1000 \n#define\tW_ALL\t\t\t0xFFFFFFFF\n\n// used in some Drawing routines\nenum VIEWTYPE {YZ, XZ, XY};\n\nenum terrainnoise_t { NOISE_NONE, NOISE_PLUS, NOISE_PLUSMINUS };\nenum terrainbrush_t { TERRAIN_BRUSH_CIRCLE, TERRAIN_BRUSH_SQUARE };\nenum terrainfalloff_t { TERRAIN_FALLOFF_LINEAR, TERRAIN_FALLOFF_CURVED };\n\n#endif"
  },
  {
    "path": "q3radiant/QFILES.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n//\n// qfiles.h: quake file formats\n// This file must be identical in the quake and utils directories\n//\n\n/*\n========================================================================\n\n.MD2 triangle model file format\n\n========================================================================\n*/\n\n#define IDALIASHEADER\t\t(('2'<<24)+('P'<<16)+('D'<<8)+'I')\n#define ALIAS_VERSION\t8\n\n#define\tMAX_TRIANGLES\t4096\n#define MAX_VERTS\t\t2048\n#define MAX_FRAMES\t\t512\n#define MAX_MD2SKINS\t32\n#define\tMAX_SKINNAME\t64\n\ntypedef struct\n{\n\tshort\ts;\n\tshort\tt;\n} dstvert_t;\n\ntypedef struct \n{\n\tshort\tindex_xyz[3];\n\tshort\tindex_st[3];\n} dtriangle_t;\n\ntypedef struct\n{\n\tbyte\tv[3];\t\t\t// scaled byte to fit in frame mins/maxs\n\tbyte\tlightnormalindex;\n} dtrivertx_t;\n\ntypedef struct\n{\n\tfloat\t\tscale[3];\t// multiply byte verts by this\n\tfloat\t\ttranslate[3];\t// then add this\n\tchar\t\tname[16];\t// frame name from grabbing\n\tdtrivertx_t\tverts[1];\t// variable sized\n} daliasframe_t;\n\n\n// the glcmd format:\n// a positive integer starts a tristrip command, followed by that many\n// vertex structures.\n// a negative integer starts a trifan command, followed by -x vertexes\n// a zero indicates the end of the command list.\n// a vertex consists of a floating point s, a floating point t,\n// and an integer vertex index.\n\n\ntypedef struct\n{\n\tint\t\t\tident;\n\tint\t\t\tversion;\n\n\tint\t\t\tskinwidth;\n\tint\t\t\tskinheight;\n\tint\t\t\tframesize;\t\t// byte size of each frame\n\n\tint\t\t\tnum_skins;\n\tint\t\t\tnum_xyz;\n\tint\t\t\tnum_st;\t\t\t// greater than num_xyz for seams\n\tint\t\t\tnum_tris;\n\tint\t\t\tnum_glcmds;\t\t// dwords in strip/fan command list\n\tint\t\t\tnum_frames;\n\n\tint\t\t\tofs_skins;\t\t// each skin is a MAX_SKINNAME string\n\tint\t\t\tofs_st;\t\t\t// byte offset from start for stverts\n\tint\t\t\tofs_tris;\t\t// offset for dtriangles\n\tint\t\t\tofs_frames;\t\t// offset for first frame\n\tint\t\t\tofs_glcmds;\t\n\tint\t\t\tofs_end;\t\t// end of file\n\n} dmdl_t;\n\n#define MD3_IDENT\t\t\t(('3'<<24)+('P'<<16)+('D'<<8)+'I')\n#define\tMAX_QPATH\t\t\t64\t\t// max length of a quake game pathname\n#define\tMD3_XYZ_SCALE\t\t(1.0/64)\n\ntypedef struct {\n\tint\t\t\tident;\n\tint\t\t\tversion;\n\n\tchar\t\tname[MAX_QPATH];\t// model name\n\n\tint\t\t\tflags;\n\n\tint\t\t\tnumFrames;\n\tint\t\t\tnumTags;\t\t\t\n\tint\t\t\tnumSurfaces;\n\n\tint\t\t\tnumSkins;\n\n\tint\t\t\tofsFrames;\t\t\t// offset for first frame\n\tint\t\t\tofsTags;\t\t\t// numFrames * numTags\n\tint\t\t\tofsSurfaces;\t\t// first surface, others follow\n\n\tint\t\t\tofsEnd;\t\t\t\t// end of file\n} md3Header_t;\n\ntypedef struct {\n\tint\t\tident;\t\t\t\t// \n\n\tchar\tname[MAX_QPATH];\t// polyset name\n\n\tint\t\tflags;\n\tint\t\tnumFrames;\t\t\t// all surfaces in a model should have the same\n\n\tint\t\tnumShaders;\t\t\t// all surfaces in a model should have the same\n\tint\t\tnumVerts;\n\n\tint\t\tnumTriangles;\n\tint\t\tofsTriangles;\n\n\tint\t\tofsShaders;\t\t\t// offset from start of md3Surface_t\n\tint\t\tofsSt;\t\t\t\t// texture coords are common for all frames\n\tint\t\tofsXyzNormals;\t\t// numVerts * numFrames\n\n\tint\t\tofsEnd;\t\t\t\t// next surface follows\n\n} md3Surface_t;\n\ntypedef struct {\n\tchar\t\t\tname[MAX_QPATH];\n\tint\t\t\t\tshaderIndex;\t// for in-game use\n} md3Shader_t;\n\ntypedef struct {\n\tint\t\t\tindexes[3];\n} md3Triangle_t;\n\ntypedef struct {\n\tfloat\t\tst[2];\n} md3St_t;\n\ntypedef struct {\n\tshort\t\txyz[3];\n\tshort\t\tnormal;\n} md3XyzNormal_t;\n\n\ntypedef struct\n{\n  float st[2];\n  int   nVertIndex;\n} glst_t;\n\ntypedef struct\n{\n  int     nCount;\n  int     ObjectIndex;\n  glst_t  GlSt;\n} gl_t;\n\n/*\n========================================================================\n\n.SP2 sprite file format\n\n========================================================================\n*/\n\n#define IDSPRITEHEADER\t(('2'<<24)+('S'<<16)+('D'<<8)+'I')\n\t\t// little-endian \"IDS2\"\n#define SPRITE_VERSION\t2\n\ntypedef struct\n{\n\tint\t\twidth, height;\n\tint\t\torigin_x, origin_y;\t\t// raster coordinates inside pic\n\tchar\tname[MAX_SKINNAME];\t\t// name of pcx file\n} dsprframe_t;\n\ntypedef struct {\n\tint\t\t\tident;\n\tint\t\t\tversion;\n\tint\t\t\tnumframes;\n\tdsprframe_t\tframes[1];\t\t\t// variable sized\n} dsprite_t;\n\n/*\n==============================================================================\n\n  .WAL texture file format\n\n==============================================================================\n*/\n\n\n#define\tMIPLEVELS\t4\ntypedef struct miptex_s\n{\n\tchar\t\tname[32];\n\tunsigned\twidth, height;\n\tunsigned\toffsets[MIPLEVELS];\t\t// four mip maps stored\n\tchar\t\tanimname[32];\t\t\t// next frame in animation chain\n\tint\t\t\tflags;\n\tint\t\t\tcontents;\n\tint\t\t\tvalue;\n} miptex_t;\n\n\n\n/*\n==============================================================================\n\n  .BSP file format\n\n==============================================================================\n*/\n\n#define IDBSPHEADER\t(('P'<<24)+('S'<<16)+('B'<<8)+'I')\n\t\t// little-endian \"IBSP\"\n\n#define BSPVERSION\t36\n\n\n// upper design bounds\n// leaffaces, leafbrushes, planes, and verts are still bounded by\n// 16 bit short limits\n#define\tMAX_MAP_MODELS\t\t1024\n#define\tMAX_MAP_BRUSHES\t\t8192\n#define\tMAX_MAP_ENTITIES\t2048\n#define\tMAX_MAP_ENTSTRING\t0x20000\n#define\tMAX_MAP_TEXINFO\t\t8192\n\n#define\tMAX_MAP_PLANES\t\t65536\n#define\tMAX_MAP_NODES\t\t65536\n#define\tMAX_MAP_BRUSHSIDES\t65536\n#define\tMAX_MAP_LEAFS\t\t65536\n#define\tMAX_MAP_VERTS\t\t65536\n#define\tMAX_MAP_FACES\t\t65536\n#define\tMAX_MAP_LEAFFACES\t65536\n#define\tMAX_MAP_LEAFBRUSHES 65536\n#define\tMAX_MAP_PORTALS\t\t65536\n#define\tMAX_MAP_EDGES\t\t128000\n#define\tMAX_MAP_SURFEDGES\t256000\n#define\tMAX_MAP_LIGHTING\t0x200000\n#define\tMAX_MAP_VISIBILITY\t0x100000\n\n#define MAX_WORLD_COORD\t\t( 128*1024 )\n#define MIN_WORLD_COORD\t\t( -128*1024 )\n#define WORLD_SIZE\t\t\t( MAX_WORLD_COORD - MIN_WORLD_COORD )\n\n#define MAX_BRUSH_SIZE\t\t( WORLD_SIZE )\n\n// key / value pair sizes\n\n#define\tMAX_KEY\t\t32\n#define\tMAX_VALUE\t1024\n\n//=============================================================================\n\ntypedef struct\n{\n\tint\t\tfileofs, filelen;\n} lump_t;\n\n#define\tLUMP_ENTITIES\t\t0\n#define\tLUMP_PLANES\t\t\t1\n#define\tLUMP_VERTEXES\t\t2\n#define\tLUMP_VISIBILITY\t\t3\n#define\tLUMP_NODES\t\t\t4\n#define\tLUMP_TEXINFO\t\t5\n#define\tLUMP_FACES\t\t\t6\n#define\tLUMP_LIGHTING\t\t7\n#define\tLUMP_LEAFS\t\t\t8\n#define\tLUMP_LEAFFACES\t\t9\n#define\tLUMP_LEAFBRUSHES\t10\n#define\tLUMP_EDGES\t\t\t11\n#define\tLUMP_SURFEDGES\t\t12\n#define\tLUMP_MODELS\t\t\t13\n#define\tLUMP_BRUSHES\t\t14\n#define\tLUMP_BRUSHSIDES\t\t15\n#define\tLUMP_POP\t\t\t16\n\n#define\tHEADER_LUMPS\t\t17\n\ntypedef struct\n{\n\tint\t\t\tident;\n\tint\t\t\tversion;\t\n\tlump_t\t\tlumps[HEADER_LUMPS];\n} dheader_t;\n\ntypedef struct\n{\n\tfloat\t\tmins[3], maxs[3];\n\tfloat\t\torigin[3];\t\t// for sounds or lights\n\tint\t\t\theadnode;\n\tint\t\t\tfirstface, numfaces;\t// submodels just draw faces\n\t\t\t\t\t\t\t\t\t\t// without walking the bsp tree\n} dmodel_t;\n\n\ntypedef struct\n{\n\tfloat\tpoint[3];\n} dvertex_t;\n\n\n// 0-2 are axial planes\n#define\tPLANE_X\t\t\t0\n#define\tPLANE_Y\t\t\t1\n#define\tPLANE_Z\t\t\t2\n\n// 3-5 are non-axial planes snapped to the nearest\n#define\tPLANE_ANYX\t\t3\n#define\tPLANE_ANYY\t\t4\n#define\tPLANE_ANYZ\t\t5\n\n// planes (x&~1) and (x&~1)+1 are allways opposites\n\ntypedef struct\n{\n\tfloat\tnormal[3];\n\tfloat\tdist;\n\tint\t\ttype;\t\t// PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate\n} dplane_t;\n\n\n// contents flags are seperate bits\n// a given brush can contribute multiple content bits\n// multiple brushes can be in a single leaf\n\n// lower bits are stronger, and will eat weaker brushes completely\n#define\tCONTENTS_SOLID\t\t\t1\t\t// an eye is never valid in a solid\n#define\tCONTENTS_WINDOW\t\t\t2\t\t// translucent, but not watery\n#define\tCONTENTS_AUX\t\t\t4\n#define\tCONTENTS_LAVA\t\t\t8\n#define\tCONTENTS_SLIME\t\t\t16\n#define\tCONTENTS_WATER\t\t\t32\n#define\tCONTENTS_MIST\t\t\t64\n#define\tLAST_VISIBLE_CONTENTS\t64\n\n// remaining contents are non-visible, and don't eat brushes\n#define\tCONTENTS_PLAYERCLIP\t\t0x10000\n#define\tCONTENTS_MONSTERCLIP\t0x20000\n\n// currents can be added to any other contents, and may be mixed\n#define\tCONTENTS_CURRENT_0\t\t0x40000\n#define\tCONTENTS_CURRENT_90\t\t0x80000\n#define\tCONTENTS_CURRENT_180\t0x100000\n#define\tCONTENTS_CURRENT_270\t0x200000\n#define\tCONTENTS_CURRENT_UP\t\t0x400000\n#define\tCONTENTS_CURRENT_DOWN\t0x800000\n\n#define\tCONTENTS_ORIGIN\t\t\t    0x1000000\t  // removed before bsping an entity\n\n#define\tCONTENTS_MONSTER\t\t    0x2000000\t  // should never be on a brush, only in game\n#define\tCONTENTS_DEADMONSTER\t  0x4000000   // corpse\n#define\tCONTENTS_DETAIL\t\t\t    0x8000000\t  // brushes to be added after vis leafs\n#define\tCONTENTS_TRANSLUCENT\t  0x10000000\t// auto set if any surface has trans\n#define\tCONTENTS_LADDER         0x20000000\t// ladder\n#define\tCONTENTS_NEGATIVE_CURVE 0x40000000\t// reverse inside / outside\n\n#define\tCONTENTS_KEEP\t(CONTENTS_DETAIL | CONTENTS_NEGATIVE_CURVE)\n\n\ntypedef struct\n{\n\tint\t\t\tplanenum;\n\tint\t\t\tchildren[2];\t// negative numbers are -(leafs+1), not nodes\n\tshort\t\tmins[3];\t\t// for frustom culling\n\tshort\t\tmaxs[3];\n\tunsigned short\tfirstface;\n\tunsigned short\tnumfaces;\t// counting both sides\n} dnode_t;\n\n\ntypedef struct texinfo_s\n{\n\tfloat\t\tvecs[2][4];\t\t// [s/t][xyz offset]\n\tint\t\t\tflags;\t\t\t// miptex flags + overrides\n\tint\t\t\tvalue;\t\t\t// light emission, etc\n\tchar\t\ttexture[32];\t// texture name (textures/*.wal)\n\tint\t\t\tnexttexinfo;\t// for animations, -1 = end of chain\n} texinfo_t;\n\n\n#define\tSURF_LIGHT\t\t0x1\t\t// value will hold the light strength\n\n#define\tSURF_SLICK\t\t0x2\t\t// effects game physics\n\n#define\tSURF_SKY\t\t0x4\t\t// don't draw, but add to skybox\n#define\tSURF_WARP\t\t0x8\t\t// turbulent water warp\n#define\tSURF_TRANS33\t0x10\n#define\tSURF_TRANS66\t0x20\n#define\tSURF_FLOWING\t0x40\t// scroll towards angle\n#define\tSURF_NODRAW\t\t0x80\t// don't bother referencing the texture\n\n#define SURF_PATCH        0x20000000\n#define\tSURF_CURVE_FAKE\t\t0x40000000\n#define\tSURF_CURVE\t\t    0x80000000\n#define\tSURF_KEEP\t\t(SURF_CURVE | SURF_CURVE_FAKE | SURF_PATCH)\n\n// note that edge 0 is never used, because negative edge nums are used for\n// counterclockwise use of the edge in a face\ntypedef struct\n{\n\tunsigned short\tv[2];\t\t// vertex numbers\n} dedge_t;\n\n#define\tMAXLIGHTMAPS\t4\ntypedef struct\n{\n\tunsigned short\tplanenum;\n\tshort\t\tside;\n\n\tint\t\t\tfirstedge;\t\t// we must support > 64k edges\n\tshort\t\tnumedges;\t\n\tshort\t\ttexinfo;\n\n// lighting info\n\tbyte\t\tstyles[MAXLIGHTMAPS];\n\tint\t\t\tlightofs;\t\t// start of [numstyles*surfsize] samples\n} dface_t;\n\ntypedef struct\n{\n\tint\t\t\tcontents;\t\t\t// OR of all brushes (not needed?)\n\n\tint\t\t\tpvsofs;\t\t\t\t// -1 = no info\n\tint\t\t\tphsofs;\t\t\t\t// -1 = no info\n\n\tshort\t\tmins[3];\t\t\t// for frustum culling\n\tshort\t\tmaxs[3];\n\n\tunsigned short\t\tfirstleafface;\n\tunsigned short\t\tnumleaffaces;\n\n\tunsigned short\t\tfirstleafbrush;\n\tunsigned short\t\tnumleafbrushes;\n} dleaf_t;\n\ntypedef struct\n{\n\tunsigned short\tplanenum;\t\t// facing out of the leaf\n\tshort\ttexinfo;\n} dbrushside_t;\n\ntypedef struct\n{\n\tint\t\t\tfirstside;\n\tint\t\t\tnumsides;\n\tint\t\t\tcontents;\n} dbrush_t;\n\n#define\tANGLE_UP\t-1\n#define\tANGLE_DOWN\t-2\n\n"
  },
  {
    "path": "q3radiant/QGL.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n/*\n** QGL.H\n*/\n\n#ifndef __QGL_H__\n#define __QGL_H__\n\n#ifdef _WIN32\n#  include <windows.h>\n#endif\n\n#include <gl/gl.h>\n#include <gl/glu.h>\n\nint  QGL_Init( const char *dllname, const char* pGluName );\nvoid QGL_Shutdown();\n\n#ifndef APIENTRY\n#  define APIENTRY\n#endif\n\nextern  void ( APIENTRY * qglAccum )(GLenum op, GLfloat value);\nextern  void ( APIENTRY * qglAlphaFunc )(GLenum func, GLclampf ref);\nextern  GLboolean ( APIENTRY * qglAreTexturesResident )(GLsizei n, const GLuint *textures, GLboolean *residences);\nextern  void ( APIENTRY * qglArrayElement )(GLint i);\nextern  void ( APIENTRY * qglBegin )(GLenum mode);\nextern  void ( APIENTRY * qglBindTexture )(GLenum target, GLuint texture);\nextern  void ( APIENTRY * qglBitmap )(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);\nextern  void ( APIENTRY * qglBlendFunc )(GLenum sfactor, GLenum dfactor);\nextern  void ( APIENTRY * qglCallList )(GLuint list);\nextern  void ( APIENTRY * qglCallLists )(GLsizei n, GLenum type, const GLvoid *lists);\nextern  void ( APIENTRY * qglClear )(GLbitfield mask);\nextern  void ( APIENTRY * qglClearAccum )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nextern  void ( APIENTRY * qglClearColor )(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);\nextern  void ( APIENTRY * qglClearDepth )(GLclampd depth);\nextern  void ( APIENTRY * qglClearIndex )(GLfloat c);\nextern  void ( APIENTRY * qglClearStencil )(GLint s);\nextern  void ( APIENTRY * qglClipPlane )(GLenum plane, const GLdouble *equation);\nextern  void ( APIENTRY * qglColor3b )(GLbyte red, GLbyte green, GLbyte blue);\nextern  void ( APIENTRY * qglColor3bv )(const GLbyte *v);\nextern  void ( APIENTRY * qglColor3d )(GLdouble red, GLdouble green, GLdouble blue);\nextern  void ( APIENTRY * qglColor3dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglColor3f )(GLfloat red, GLfloat green, GLfloat blue);\nextern  void ( APIENTRY * qglColor3fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglColor3i )(GLint red, GLint green, GLint blue);\nextern  void ( APIENTRY * qglColor3iv )(const GLint *v);\nextern  void ( APIENTRY * qglColor3s )(GLshort red, GLshort green, GLshort blue);\nextern  void ( APIENTRY * qglColor3sv )(const GLshort *v);\nextern  void ( APIENTRY * qglColor3ub )(GLubyte red, GLubyte green, GLubyte blue);\nextern  void ( APIENTRY * qglColor3ubv )(const GLubyte *v);\nextern  void ( APIENTRY * qglColor3ui )(GLuint red, GLuint green, GLuint blue);\nextern  void ( APIENTRY * qglColor3uiv )(const GLuint *v);\nextern  void ( APIENTRY * qglColor3us )(GLushort red, GLushort green, GLushort blue);\nextern  void ( APIENTRY * qglColor3usv )(const GLushort *v);\nextern  void ( APIENTRY * qglColor4b )(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha);\nextern  void ( APIENTRY * qglColor4bv )(const GLbyte *v);\nextern  void ( APIENTRY * qglColor4d )(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);\nextern  void ( APIENTRY * qglColor4dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglColor4f )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nextern  void ( APIENTRY * qglColor4fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglColor4i )(GLint red, GLint green, GLint blue, GLint alpha);\nextern  void ( APIENTRY * qglColor4iv )(const GLint *v);\nextern  void ( APIENTRY * qglColor4s )(GLshort red, GLshort green, GLshort blue, GLshort alpha);\nextern  void ( APIENTRY * qglColor4sv )(const GLshort *v);\nextern  void ( APIENTRY * qglColor4ub )(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);\nextern  void ( APIENTRY * qglColor4ubv )(const GLubyte *v);\nextern  void ( APIENTRY * qglColor4ui )(GLuint red, GLuint green, GLuint blue, GLuint alpha);\nextern  void ( APIENTRY * qglColor4uiv )(const GLuint *v);\nextern  void ( APIENTRY * qglColor4us )(GLushort red, GLushort green, GLushort blue, GLushort alpha);\nextern  void ( APIENTRY * qglColor4usv )(const GLushort *v);\nextern  void ( APIENTRY * qglColorMask )(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);\nextern  void ( APIENTRY * qglColorMaterial )(GLenum face, GLenum mode);\nextern  void ( APIENTRY * qglColorPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nextern  void ( APIENTRY * qglCopyPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);\nextern  void ( APIENTRY * qglCopyTexImage1D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border);\nextern  void ( APIENTRY * qglCopyTexImage2D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\nextern  void ( APIENTRY * qglCopyTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\nextern  void ( APIENTRY * qglCopyTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nextern  void ( APIENTRY * qglCullFace )(GLenum mode);\nextern  void ( APIENTRY * qglDeleteLists )(GLuint list, GLsizei range);\nextern  void ( APIENTRY * qglDeleteTextures )(GLsizei n, const GLuint *textures);\nextern  void ( APIENTRY * qglDepthFunc )(GLenum func);\nextern  void ( APIENTRY * qglDepthMask )(GLboolean flag);\nextern  void ( APIENTRY * qglDepthRange )(GLclampd zNear, GLclampd zFar);\nextern  void ( APIENTRY * qglDisable )(GLenum cap);\nextern  void ( APIENTRY * qglDisableClientState )(GLenum array);\nextern  void ( APIENTRY * qglDrawArrays )(GLenum mode, GLint first, GLsizei count);\nextern  void ( APIENTRY * qglDrawBuffer )(GLenum mode);\nextern  void ( APIENTRY * qglDrawElements )(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);\nextern  void ( APIENTRY * qglDrawPixels )(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nextern  void ( APIENTRY * qglEdgeFlag )(GLboolean flag);\nextern  void ( APIENTRY * qglEdgeFlagPointer )(GLsizei stride, const GLvoid *pointer);\nextern  void ( APIENTRY * qglEdgeFlagv )(const GLboolean *flag);\nextern  void ( APIENTRY * qglEnable )(GLenum cap);\nextern  void ( APIENTRY * qglEnableClientState )(GLenum array);\nextern  void ( APIENTRY * qglEnd )(void);\nextern  void ( APIENTRY * qglEndList )(void);\nextern  void ( APIENTRY * qglEvalCoord1d )(GLdouble u);\nextern  void ( APIENTRY * qglEvalCoord1dv )(const GLdouble *u);\nextern  void ( APIENTRY * qglEvalCoord1f )(GLfloat u);\nextern  void ( APIENTRY * qglEvalCoord1fv )(const GLfloat *u);\nextern  void ( APIENTRY * qglEvalCoord2d )(GLdouble u, GLdouble v);\nextern  void ( APIENTRY * qglEvalCoord2dv )(const GLdouble *u);\nextern  void ( APIENTRY * qglEvalCoord2f )(GLfloat u, GLfloat v);\nextern  void ( APIENTRY * qglEvalCoord2fv )(const GLfloat *u);\nextern  void ( APIENTRY * qglEvalMesh1 )(GLenum mode, GLint i1, GLint i2);\nextern  void ( APIENTRY * qglEvalMesh2 )(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);\nextern  void ( APIENTRY * qglEvalPoint1 )(GLint i);\nextern  void ( APIENTRY * qglEvalPoint2 )(GLint i, GLint j);\nextern  void ( APIENTRY * qglFeedbackBuffer )(GLsizei size, GLenum type, GLfloat *buffer);\nextern  void ( APIENTRY * qglFinish )(void);\nextern  void ( APIENTRY * qglFlush )(void);\nextern  void ( APIENTRY * qglFogf )(GLenum pname, GLfloat param);\nextern  void ( APIENTRY * qglFogfv )(GLenum pname, const GLfloat *params);\nextern  void ( APIENTRY * qglFogi )(GLenum pname, GLint param);\nextern  void ( APIENTRY * qglFogiv )(GLenum pname, const GLint *params);\nextern  void ( APIENTRY * qglFrontFace )(GLenum mode);\nextern  void ( APIENTRY * qglFrustum )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nextern  GLuint ( APIENTRY * qglGenLists )(GLsizei range);\nextern  void ( APIENTRY * qglGenTextures )(GLsizei n, GLuint *textures);\nextern  void ( APIENTRY * qglGetBooleanv )(GLenum pname, GLboolean *params);\nextern  void ( APIENTRY * qglGetClipPlane )(GLenum plane, GLdouble *equation);\nextern  void ( APIENTRY * qglGetDoublev )(GLenum pname, GLdouble *params);\nextern  GLenum ( APIENTRY * qglGetError )(void);\nextern  void ( APIENTRY * qglGetFloatv )(GLenum pname, GLfloat *params);\nextern  void ( APIENTRY * qglGetIntegerv )(GLenum pname, GLint *params);\nextern  void ( APIENTRY * qglGetLightfv )(GLenum light, GLenum pname, GLfloat *params);\nextern  void ( APIENTRY * qglGetLightiv )(GLenum light, GLenum pname, GLint *params);\nextern  void ( APIENTRY * qglGetMapdv )(GLenum target, GLenum query, GLdouble *v);\nextern  void ( APIENTRY * qglGetMapfv )(GLenum target, GLenum query, GLfloat *v);\nextern  void ( APIENTRY * qglGetMapiv )(GLenum target, GLenum query, GLint *v);\nextern  void ( APIENTRY * qglGetMaterialfv )(GLenum face, GLenum pname, GLfloat *params);\nextern  void ( APIENTRY * qglGetMaterialiv )(GLenum face, GLenum pname, GLint *params);\nextern  void ( APIENTRY * qglGetPixelMapfv )(GLenum map, GLfloat *values);\nextern  void ( APIENTRY * qglGetPixelMapuiv )(GLenum map, GLuint *values);\nextern  void ( APIENTRY * qglGetPixelMapusv )(GLenum map, GLushort *values);\nextern  void ( APIENTRY * qglGetPointerv )(GLenum pname, GLvoid* *params);\nextern  void ( APIENTRY * qglGetPolygonStipple )(GLubyte *mask);\nextern  const GLubyte * ( APIENTRY * qglGetString )(GLenum name);\nextern  void ( APIENTRY * qglGetTexEnvfv )(GLenum target, GLenum pname, GLfloat *params);\nextern  void ( APIENTRY * qglGetTexEnviv )(GLenum target, GLenum pname, GLint *params);\nextern  void ( APIENTRY * qglGetTexGendv )(GLenum coord, GLenum pname, GLdouble *params);\nextern  void ( APIENTRY * qglGetTexGenfv )(GLenum coord, GLenum pname, GLfloat *params);\nextern  void ( APIENTRY * qglGetTexGeniv )(GLenum coord, GLenum pname, GLint *params);\nextern  void ( APIENTRY * qglGetTexImage )(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);\nextern  void ( APIENTRY * qglGetTexLevelParameterfv )(GLenum target, GLint level, GLenum pname, GLfloat *params);\nextern  void ( APIENTRY * qglGetTexLevelParameteriv )(GLenum target, GLint level, GLenum pname, GLint *params);\nextern  void ( APIENTRY * qglGetTexParameterfv )(GLenum target, GLenum pname, GLfloat *params);\nextern  void ( APIENTRY * qglGetTexParameteriv )(GLenum target, GLenum pname, GLint *params);\nextern  void ( APIENTRY * qglHint )(GLenum target, GLenum mode);\nextern  void ( APIENTRY * qglIndexMask )(GLuint mask);\nextern  void ( APIENTRY * qglIndexPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);\nextern  void ( APIENTRY * qglIndexd )(GLdouble c);\nextern  void ( APIENTRY * qglIndexdv )(const GLdouble *c);\nextern  void ( APIENTRY * qglIndexf )(GLfloat c);\nextern  void ( APIENTRY * qglIndexfv )(const GLfloat *c);\nextern  void ( APIENTRY * qglIndexi )(GLint c);\nextern  void ( APIENTRY * qglIndexiv )(const GLint *c);\nextern  void ( APIENTRY * qglIndexs )(GLshort c);\nextern  void ( APIENTRY * qglIndexsv )(const GLshort *c);\nextern  void ( APIENTRY * qglIndexub )(GLubyte c);\nextern  void ( APIENTRY * qglIndexubv )(const GLubyte *c);\nextern  void ( APIENTRY * qglInitNames )(void);\nextern  void ( APIENTRY * qglInterleavedArrays )(GLenum format, GLsizei stride, const GLvoid *pointer);\nextern  GLboolean ( APIENTRY * qglIsEnabled )(GLenum cap);\nextern  GLboolean ( APIENTRY * qglIsList )(GLuint list);\nextern  GLboolean ( APIENTRY * qglIsTexture )(GLuint texture);\nextern  void ( APIENTRY * qglLightModelf )(GLenum pname, GLfloat param);\nextern  void ( APIENTRY * qglLightModelfv )(GLenum pname, const GLfloat *params);\nextern  void ( APIENTRY * qglLightModeli )(GLenum pname, GLint param);\nextern  void ( APIENTRY * qglLightModeliv )(GLenum pname, const GLint *params);\nextern  void ( APIENTRY * qglLightf )(GLenum light, GLenum pname, GLfloat param);\nextern  void ( APIENTRY * qglLightfv )(GLenum light, GLenum pname, const GLfloat *params);\nextern  void ( APIENTRY * qglLighti )(GLenum light, GLenum pname, GLint param);\nextern  void ( APIENTRY * qglLightiv )(GLenum light, GLenum pname, const GLint *params);\nextern  void ( APIENTRY * qglLineStipple )(GLint factor, GLushort pattern);\nextern  void ( APIENTRY * qglLineWidth )(GLfloat width);\nextern  void ( APIENTRY * qglListBase )(GLuint base);\nextern  void ( APIENTRY * qglLoadIdentity )(void);\nextern  void ( APIENTRY * qglLoadMatrixd )(const GLdouble *m);\nextern  void ( APIENTRY * qglLoadMatrixf )(const GLfloat *m);\nextern  void ( APIENTRY * qglLoadName )(GLuint name);\nextern  void ( APIENTRY * qglLogicOp )(GLenum opcode);\nextern  void ( APIENTRY * qglMap1d )(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);\nextern  void ( APIENTRY * qglMap1f )(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);\nextern  void ( APIENTRY * qglMap2d )(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);\nextern  void ( APIENTRY * qglMap2f )(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);\nextern  void ( APIENTRY * qglMapGrid1d )(GLint un, GLdouble u1, GLdouble u2);\nextern  void ( APIENTRY * qglMapGrid1f )(GLint un, GLfloat u1, GLfloat u2);\nextern  void ( APIENTRY * qglMapGrid2d )(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);\nextern  void ( APIENTRY * qglMapGrid2f )(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);\nextern  void ( APIENTRY * qglMaterialf )(GLenum face, GLenum pname, GLfloat param);\nextern  void ( APIENTRY * qglMaterialfv )(GLenum face, GLenum pname, const GLfloat *params);\nextern  void ( APIENTRY * qglMateriali )(GLenum face, GLenum pname, GLint param);\nextern  void ( APIENTRY * qglMaterialiv )(GLenum face, GLenum pname, const GLint *params);\nextern  void ( APIENTRY * qglMatrixMode )(GLenum mode);\nextern  void ( APIENTRY * qglMultMatrixd )(const GLdouble *m);\nextern  void ( APIENTRY * qglMultMatrixf )(const GLfloat *m);\nextern  void ( APIENTRY * qglNewList )(GLuint list, GLenum mode);\nextern  void ( APIENTRY * qglNormal3b )(GLbyte nx, GLbyte ny, GLbyte nz);\nextern  void ( APIENTRY * qglNormal3bv )(const GLbyte *v);\nextern  void ( APIENTRY * qglNormal3d )(GLdouble nx, GLdouble ny, GLdouble nz);\nextern  void ( APIENTRY * qglNormal3dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglNormal3f )(GLfloat nx, GLfloat ny, GLfloat nz);\nextern  void ( APIENTRY * qglNormal3fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglNormal3i )(GLint nx, GLint ny, GLint nz);\nextern  void ( APIENTRY * qglNormal3iv )(const GLint *v);\nextern  void ( APIENTRY * qglNormal3s )(GLshort nx, GLshort ny, GLshort nz);\nextern  void ( APIENTRY * qglNormal3sv )(const GLshort *v);\nextern  void ( APIENTRY * qglNormalPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);\nextern  void ( APIENTRY * qglOrtho )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nextern  void ( APIENTRY * qglPassThrough )(GLfloat token);\nextern  void ( APIENTRY * qglPixelMapfv )(GLenum map, GLsizei mapsize, const GLfloat *values);\nextern  void ( APIENTRY * qglPixelMapuiv )(GLenum map, GLsizei mapsize, const GLuint *values);\nextern  void ( APIENTRY * qglPixelMapusv )(GLenum map, GLsizei mapsize, const GLushort *values);\nextern  void ( APIENTRY * qglPixelStoref )(GLenum pname, GLfloat param);\nextern  void ( APIENTRY * qglPixelStorei )(GLenum pname, GLint param);\nextern  void ( APIENTRY * qglPixelTransferf )(GLenum pname, GLfloat param);\nextern  void ( APIENTRY * qglPixelTransferi )(GLenum pname, GLint param);\nextern  void ( APIENTRY * qglPixelZoom )(GLfloat xfactor, GLfloat yfactor);\nextern  void ( APIENTRY * qglPointSize )(GLfloat size);\nextern  void ( APIENTRY * qglPolygonMode )(GLenum face, GLenum mode);\nextern  void ( APIENTRY * qglPolygonOffset )(GLfloat factor, GLfloat units);\nextern  void ( APIENTRY * qglPolygonStipple )(const GLubyte *mask);\nextern  void ( APIENTRY * qglPopAttrib )(void);\nextern  void ( APIENTRY * qglPopClientAttrib )(void);\nextern  void ( APIENTRY * qglPopMatrix )(void);\nextern  void ( APIENTRY * qglPopName )(void);\nextern  void ( APIENTRY * qglPrioritizeTextures )(GLsizei n, const GLuint *textures, const GLclampf *priorities);\nextern  void ( APIENTRY * qglPushAttrib )(GLbitfield mask);\nextern  void ( APIENTRY * qglPushClientAttrib )(GLbitfield mask);\nextern  void ( APIENTRY * qglPushMatrix )(void);\nextern  void ( APIENTRY * qglPushName )(GLuint name);\nextern  void ( APIENTRY * qglRasterPos2d )(GLdouble x, GLdouble y);\nextern  void ( APIENTRY * qglRasterPos2dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglRasterPos2f )(GLfloat x, GLfloat y);\nextern  void ( APIENTRY * qglRasterPos2fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglRasterPos2i )(GLint x, GLint y);\nextern  void ( APIENTRY * qglRasterPos2iv )(const GLint *v);\nextern  void ( APIENTRY * qglRasterPos2s )(GLshort x, GLshort y);\nextern  void ( APIENTRY * qglRasterPos2sv )(const GLshort *v);\nextern  void ( APIENTRY * qglRasterPos3d )(GLdouble x, GLdouble y, GLdouble z);\nextern  void ( APIENTRY * qglRasterPos3dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglRasterPos3f )(GLfloat x, GLfloat y, GLfloat z);\nextern  void ( APIENTRY * qglRasterPos3fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglRasterPos3i )(GLint x, GLint y, GLint z);\nextern  void ( APIENTRY * qglRasterPos3iv )(const GLint *v);\nextern  void ( APIENTRY * qglRasterPos3s )(GLshort x, GLshort y, GLshort z);\nextern  void ( APIENTRY * qglRasterPos3sv )(const GLshort *v);\nextern  void ( APIENTRY * qglRasterPos4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nextern  void ( APIENTRY * qglRasterPos4dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglRasterPos4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nextern  void ( APIENTRY * qglRasterPos4fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglRasterPos4i )(GLint x, GLint y, GLint z, GLint w);\nextern  void ( APIENTRY * qglRasterPos4iv )(const GLint *v);\nextern  void ( APIENTRY * qglRasterPos4s )(GLshort x, GLshort y, GLshort z, GLshort w);\nextern  void ( APIENTRY * qglRasterPos4sv )(const GLshort *v);\nextern  void ( APIENTRY * qglReadBuffer )(GLenum mode);\nextern  void ( APIENTRY * qglReadPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);\nextern  void ( APIENTRY * qglRectd )(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);\nextern  void ( APIENTRY * qglRectdv )(const GLdouble *v1, const GLdouble *v2);\nextern  void ( APIENTRY * qglRectf )(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);\nextern  void ( APIENTRY * qglRectfv )(const GLfloat *v1, const GLfloat *v2);\nextern  void ( APIENTRY * qglRecti )(GLint x1, GLint y1, GLint x2, GLint y2);\nextern  void ( APIENTRY * qglRectiv )(const GLint *v1, const GLint *v2);\nextern  void ( APIENTRY * qglRects )(GLshort x1, GLshort y1, GLshort x2, GLshort y2);\nextern  void ( APIENTRY * qglRectsv )(const GLshort *v1, const GLshort *v2);\nextern  GLint ( APIENTRY * qglRenderMode )(GLenum mode);\nextern  void ( APIENTRY * qglRotated )(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);\nextern  void ( APIENTRY * qglRotatef )(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);\nextern  void ( APIENTRY * qglScaled )(GLdouble x, GLdouble y, GLdouble z);\nextern  void ( APIENTRY * qglScalef )(GLfloat x, GLfloat y, GLfloat z);\nextern  void ( APIENTRY * qglScissor )(GLint x, GLint y, GLsizei width, GLsizei height);\nextern  void ( APIENTRY * qglSelectBuffer )(GLsizei size, GLuint *buffer);\nextern  void ( APIENTRY * qglShadeModel )(GLenum mode);\nextern  void ( APIENTRY * qglStencilFunc )(GLenum func, GLint ref, GLuint mask);\nextern  void ( APIENTRY * qglStencilMask )(GLuint mask);\nextern  void ( APIENTRY * qglStencilOp )(GLenum fail, GLenum zfail, GLenum zpass);\nextern  void ( APIENTRY * qglTexCoord1d )(GLdouble s);\nextern  void ( APIENTRY * qglTexCoord1dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglTexCoord1f )(GLfloat s);\nextern  void ( APIENTRY * qglTexCoord1fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglTexCoord1i )(GLint s);\nextern  void ( APIENTRY * qglTexCoord1iv )(const GLint *v);\nextern  void ( APIENTRY * qglTexCoord1s )(GLshort s);\nextern  void ( APIENTRY * qglTexCoord1sv )(const GLshort *v);\nextern  void ( APIENTRY * qglTexCoord2d )(GLdouble s, GLdouble t);\nextern  void ( APIENTRY * qglTexCoord2dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglTexCoord2f )(GLfloat s, GLfloat t);\nextern  void ( APIENTRY * qglTexCoord2fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglTexCoord2i )(GLint s, GLint t);\nextern  void ( APIENTRY * qglTexCoord2iv )(const GLint *v);\nextern  void ( APIENTRY * qglTexCoord2s )(GLshort s, GLshort t);\nextern  void ( APIENTRY * qglTexCoord2sv )(const GLshort *v);\nextern  void ( APIENTRY * qglTexCoord3d )(GLdouble s, GLdouble t, GLdouble r);\nextern  void ( APIENTRY * qglTexCoord3dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglTexCoord3f )(GLfloat s, GLfloat t, GLfloat r);\nextern  void ( APIENTRY * qglTexCoord3fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglTexCoord3i )(GLint s, GLint t, GLint r);\nextern  void ( APIENTRY * qglTexCoord3iv )(const GLint *v);\nextern  void ( APIENTRY * qglTexCoord3s )(GLshort s, GLshort t, GLshort r);\nextern  void ( APIENTRY * qglTexCoord3sv )(const GLshort *v);\nextern  void ( APIENTRY * qglTexCoord4d )(GLdouble s, GLdouble t, GLdouble r, GLdouble q);\nextern  void ( APIENTRY * qglTexCoord4dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglTexCoord4f )(GLfloat s, GLfloat t, GLfloat r, GLfloat q);\nextern  void ( APIENTRY * qglTexCoord4fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglTexCoord4i )(GLint s, GLint t, GLint r, GLint q);\nextern  void ( APIENTRY * qglTexCoord4iv )(const GLint *v);\nextern  void ( APIENTRY * qglTexCoord4s )(GLshort s, GLshort t, GLshort r, GLshort q);\nextern  void ( APIENTRY * qglTexCoord4sv )(const GLshort *v);\nextern  void ( APIENTRY * qglTexCoordPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nextern  void ( APIENTRY * qglTexEnvf )(GLenum target, GLenum pname, GLfloat param);\nextern  void ( APIENTRY * qglTexEnvfv )(GLenum target, GLenum pname, const GLfloat *params);\nextern  void ( APIENTRY * qglTexEnvi )(GLenum target, GLenum pname, GLint param);\nextern  void ( APIENTRY * qglTexEnviv )(GLenum target, GLenum pname, const GLint *params);\nextern  void ( APIENTRY * qglTexGend )(GLenum coord, GLenum pname, GLdouble param);\nextern  void ( APIENTRY * qglTexGendv )(GLenum coord, GLenum pname, const GLdouble *params);\nextern  void ( APIENTRY * qglTexGenf )(GLenum coord, GLenum pname, GLfloat param);\nextern  void ( APIENTRY * qglTexGenfv )(GLenum coord, GLenum pname, const GLfloat *params);\nextern  void ( APIENTRY * qglTexGeni )(GLenum coord, GLenum pname, GLint param);\nextern  void ( APIENTRY * qglTexGeniv )(GLenum coord, GLenum pname, const GLint *params);\nextern  void ( APIENTRY * qglTexImage1D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nextern  void ( APIENTRY * qglTexImage2D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nextern  void ( APIENTRY * qglTexParameterf )(GLenum target, GLenum pname, GLfloat param);\nextern  void ( APIENTRY * qglTexParameterfv )(GLenum target, GLenum pname, const GLfloat *params);\nextern  void ( APIENTRY * qglTexParameteri )(GLenum target, GLenum pname, GLint param);\nextern  void ( APIENTRY * qglTexParameteriv )(GLenum target, GLenum pname, const GLint *params);\nextern  void ( APIENTRY * qglTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);\nextern  void ( APIENTRY * qglTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nextern  void ( APIENTRY * qglTranslated )(GLdouble x, GLdouble y, GLdouble z);\nextern  void ( APIENTRY * qglTranslatef )(GLfloat x, GLfloat y, GLfloat z);\nextern  void ( APIENTRY * qglVertex2d )(GLdouble x, GLdouble y);\nextern  void ( APIENTRY * qglVertex2dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglVertex2f )(GLfloat x, GLfloat y);\nextern  void ( APIENTRY * qglVertex2fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglVertex2i )(GLint x, GLint y);\nextern  void ( APIENTRY * qglVertex2iv )(const GLint *v);\nextern  void ( APIENTRY * qglVertex2s )(GLshort x, GLshort y);\nextern  void ( APIENTRY * qglVertex2sv )(const GLshort *v);\nextern  void ( APIENTRY * qglVertex3d )(GLdouble x, GLdouble y, GLdouble z);\nextern  void ( APIENTRY * qglVertex3dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglVertex3f )(GLfloat x, GLfloat y, GLfloat z);\nextern  void ( APIENTRY * qglVertex3fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglVertex3i )(GLint x, GLint y, GLint z);\nextern  void ( APIENTRY * qglVertex3iv )(const GLint *v);\nextern  void ( APIENTRY * qglVertex3s )(GLshort x, GLshort y, GLshort z);\nextern  void ( APIENTRY * qglVertex3sv )(const GLshort *v);\nextern  void ( APIENTRY * qglVertex4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nextern  void ( APIENTRY * qglVertex4dv )(const GLdouble *v);\nextern  void ( APIENTRY * qglVertex4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nextern  void ( APIENTRY * qglVertex4fv )(const GLfloat *v);\nextern  void ( APIENTRY * qglVertex4i )(GLint x, GLint y, GLint z, GLint w);\nextern  void ( APIENTRY * qglVertex4iv )(const GLint *v);\nextern  void ( APIENTRY * qglVertex4s )(GLshort x, GLshort y, GLshort z, GLshort w);\nextern  void ( APIENTRY * qglVertex4sv )(const GLshort *v);\nextern  void ( APIENTRY * qglVertexPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nextern  void ( APIENTRY * qglViewport )(GLint x, GLint y, GLsizei width, GLsizei height);\n\nextern\tvoid ( APIENTRY * qglPointParameterfEXT)( GLenum param, GLfloat value );\nextern\tvoid ( APIENTRY * qglPointParameterfvEXT)( GLenum param, const GLfloat *value );\nextern\tvoid ( APIENTRY * qglColorTableEXT)( int, int, int, int, int, const void * );\n\nextern\tvoid ( APIENTRY * qglMTexCoord2fSGIS)( GLenum, GLfloat, GLfloat );\nextern\tvoid ( APIENTRY * qglSelectTextureSGIS)( GLenum );\n\n#ifdef _WIN32\n\nextern  int   ( WINAPI * qwglChoosePixelFormat )(HDC, CONST PIXELFORMATDESCRIPTOR *);\nextern  int   ( WINAPI * qwglDescribePixelFormat) (HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);\nextern  int   ( WINAPI * qwglGetPixelFormat)(HDC);\nextern  BOOL  ( WINAPI * qwglSetPixelFormat)(HDC, int, CONST PIXELFORMATDESCRIPTOR *);\nextern  BOOL  ( WINAPI * qwglSwapBuffers)(HDC);\n\nextern BOOL  ( WINAPI * qwglCopyContext)(HGLRC, HGLRC, UINT);\nextern HGLRC ( WINAPI * qwglCreateContext)(HDC);\nextern HGLRC ( WINAPI * qwglCreateLayerContext)(HDC, int);\nextern BOOL  ( WINAPI * qwglDeleteContext)(HGLRC);\nextern HGLRC ( WINAPI * qwglGetCurrentContext)(VOID);\nextern HDC   ( WINAPI * qwglGetCurrentDC)(VOID);\nextern PROC  ( WINAPI * qwglGetProcAddress)(LPCSTR);\nextern BOOL  ( WINAPI * qwglMakeCurrent)(HDC, HGLRC);\nextern BOOL  ( WINAPI * qwglShareLists)(HGLRC, HGLRC);\nextern BOOL  ( WINAPI * qwglUseFontBitmaps)(HDC, DWORD, DWORD, DWORD);\n\nextern BOOL  ( WINAPI * qwglUseFontOutlines)(HDC, DWORD, DWORD, DWORD, FLOAT,\n                                           FLOAT, int, LPGLYPHMETRICSFLOAT);\n\nextern BOOL ( WINAPI * qwglDescribeLayerPlane)(HDC, int, int, UINT,\n                                            LPLAYERPLANEDESCRIPTOR);\nextern int  ( WINAPI * qwglSetLayerPaletteEntries)(HDC, int, int, int,\n                                                CONST COLORREF *);\nextern int  ( WINAPI * qwglGetLayerPaletteEntries)(HDC, int, int, int,\n                                                COLORREF *);\nextern BOOL ( WINAPI * qwglRealizeLayerPalette)(HDC, int, BOOL);\nextern BOOL ( WINAPI * qwglSwapLayerBuffers)(HDC, UINT);\n\nextern BOOL ( WINAPI * qwglSwapIntervalEXT)( int interval );\n\nextern BOOL ( WINAPI * qwglGetDeviceGammaRampEXT ) ( unsigned char *pRed, unsigned char *pGreen, unsigned char *pBlue );\nextern BOOL ( WINAPI * qwglSetDeviceGammaRampEXT ) ( const unsigned char *pRed, const unsigned char *pGreen, const unsigned char *pBlue );\n\n#endif\n\n// glu stuff.. radiant only uses a couple\nextern int (APIENTRY* qgluBuild2DMipmaps) (GLenum target, GLint components, GLint width, GLint height, GLenum format, GLenum type, const void  *data);\nextern void (APIENTRY* qgluPerspective) (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);\nextern void (APIENTRY* qgluLookAt)(\n  GLdouble eyex,\n  GLdouble eyey,\n  GLdouble eyez,\n  GLdouble centerx,\n  GLdouble centery,\n  GLdouble centerz,\n  GLdouble upx,\n  GLdouble upy,\n  GLdouble upz);\n\n\n// end of glu stuff\n\n\n/*\n** extension constants\n*/\n#define GL_POINT_SIZE_MIN_EXT\t\t\t\t0x8126\n#define GL_POINT_SIZE_MAX_EXT\t\t\t\t0x8127\n#define GL_POINT_FADE_THRESHOLD_SIZE_EXT\t0x8128\n#define GL_DISTANCE_ATTENUATION_EXT\t\t\t0x8129\n\n#define GL_SHARED_TEXTURE_PALETTE_EXT\t\t0x81FB\n\n#define GL_TEXTURE0_SGIS\t\t\t\t\t0x835E\n#define GL_TEXTURE1_SGIS\t\t\t\t\t0x835F\n\n#endif\n"
  },
  {
    "path": "q3radiant/QGL_WIN.C",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n/*\n** QGL_WIN.C\n**\n** This file implements the operating system binding of GL to QGL function\n** pointers.  When doing a port of Quake2 you must implement the following\n** two functions:\n**\n** QGL_Init() - loads libraries, assigns function pointers, etc.\n** QGL_Shutdown() - unloads libraries, NULLs function pointers\n*/\n#include \"qgl.h\"\n#include <float.h>\n\nHMODULE g_hGLDLL;\nHMODULE g_hGLUDLL;\n\n#\tpragma warning (disable : 4113 4133 4047 )\n\nint   ( WINAPI * qwglChoosePixelFormat )(HDC, CONST PIXELFORMATDESCRIPTOR *);\nint   ( WINAPI * qwglDescribePixelFormat) (HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);\nint   ( WINAPI * qwglGetPixelFormat)(HDC);\nBOOL  ( WINAPI * qwglSetPixelFormat)(HDC, int, CONST PIXELFORMATDESCRIPTOR *);\nBOOL  ( WINAPI * qwglSwapBuffers)(HDC);\n\nBOOL  ( WINAPI * qwglCopyContext)(HGLRC, HGLRC, UINT);\nHGLRC ( WINAPI * qwglCreateContext)(HDC);\nHGLRC ( WINAPI * qwglCreateLayerContext)(HDC, int);\nBOOL  ( WINAPI * qwglDeleteContext)(HGLRC);\nHGLRC ( WINAPI * qwglGetCurrentContext)(VOID);\nHDC   ( WINAPI * qwglGetCurrentDC)(VOID);\nPROC  ( WINAPI * qwglGetProcAddress)(LPCSTR);\nBOOL  ( WINAPI * qwglMakeCurrent)(HDC, HGLRC);\nBOOL  ( WINAPI * qwglShareLists)(HGLRC, HGLRC);\nBOOL  ( WINAPI * qwglUseFontBitmaps)(HDC, DWORD, DWORD, DWORD);\n\nBOOL  ( WINAPI * qwglUseFontOutlines)(HDC, DWORD, DWORD, DWORD, FLOAT,\n                                           FLOAT, int, LPGLYPHMETRICSFLOAT);\n\nBOOL ( WINAPI * qwglDescribeLayerPlane)(HDC, int, int, UINT,\n                                            LPLAYERPLANEDESCRIPTOR);\nint  ( WINAPI * qwglSetLayerPaletteEntries)(HDC, int, int, int,\n                                                CONST COLORREF *);\nint  ( WINAPI * qwglGetLayerPaletteEntries)(HDC, int, int, int,\n                                                COLORREF *);\nBOOL ( WINAPI * qwglRealizeLayerPalette)(HDC, int, BOOL);\nBOOL ( WINAPI * qwglSwapLayerBuffers)(HDC, UINT);\n\nvoid ( APIENTRY * qglAccum )(GLenum op, GLfloat value);\nvoid ( APIENTRY * qglAlphaFunc )(GLenum func, GLclampf ref);\nGLboolean ( APIENTRY * qglAreTexturesResident )(GLsizei n, const GLuint *textures, GLboolean *residences);\nvoid ( APIENTRY * qglArrayElement )(GLint i);\nvoid ( APIENTRY * qglBegin )(GLenum mode);\nvoid ( APIENTRY * qglBindTexture )(GLenum target, GLuint texture);\nvoid ( APIENTRY * qglBitmap )(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);\nvoid ( APIENTRY * qglBlendFunc )(GLenum sfactor, GLenum dfactor);\nvoid ( APIENTRY * qglCallList )(GLuint list);\nvoid ( APIENTRY * qglCallLists )(GLsizei n, GLenum type, const GLvoid *lists);\nvoid ( APIENTRY * qglClear )(GLbitfield mask);\nvoid ( APIENTRY * qglClearAccum )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nvoid ( APIENTRY * qglClearColor )(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);\nvoid ( APIENTRY * qglClearDepth )(GLclampd depth);\nvoid ( APIENTRY * qglClearIndex )(GLfloat c);\nvoid ( APIENTRY * qglClearStencil )(GLint s);\nvoid ( APIENTRY * qglClipPlane )(GLenum plane, const GLdouble *equation);\nvoid ( APIENTRY * qglColor3b )(GLbyte red, GLbyte green, GLbyte blue);\nvoid ( APIENTRY * qglColor3bv )(const GLbyte *v);\nvoid ( APIENTRY * qglColor3d )(GLdouble red, GLdouble green, GLdouble blue);\nvoid ( APIENTRY * qglColor3dv )(const GLdouble *v);\nvoid ( APIENTRY * qglColor3f )(GLfloat red, GLfloat green, GLfloat blue);\nvoid ( APIENTRY * qglColor3fv )(const GLfloat *v);\nvoid ( APIENTRY * qglColor3i )(GLint red, GLint green, GLint blue);\nvoid ( APIENTRY * qglColor3iv )(const GLint *v);\nvoid ( APIENTRY * qglColor3s )(GLshort red, GLshort green, GLshort blue);\nvoid ( APIENTRY * qglColor3sv )(const GLshort *v);\nvoid ( APIENTRY * qglColor3ub )(GLubyte red, GLubyte green, GLubyte blue);\nvoid ( APIENTRY * qglColor3ubv )(const GLubyte *v);\nvoid ( APIENTRY * qglColor3ui )(GLuint red, GLuint green, GLuint blue);\nvoid ( APIENTRY * qglColor3uiv )(const GLuint *v);\nvoid ( APIENTRY * qglColor3us )(GLushort red, GLushort green, GLushort blue);\nvoid ( APIENTRY * qglColor3usv )(const GLushort *v);\nvoid ( APIENTRY * qglColor4b )(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha);\nvoid ( APIENTRY * qglColor4bv )(const GLbyte *v);\nvoid ( APIENTRY * qglColor4d )(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);\nvoid ( APIENTRY * qglColor4dv )(const GLdouble *v);\nvoid ( APIENTRY * qglColor4f )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nvoid ( APIENTRY * qglColor4fv )(const GLfloat *v);\nvoid ( APIENTRY * qglColor4i )(GLint red, GLint green, GLint blue, GLint alpha);\nvoid ( APIENTRY * qglColor4iv )(const GLint *v);\nvoid ( APIENTRY * qglColor4s )(GLshort red, GLshort green, GLshort blue, GLshort alpha);\nvoid ( APIENTRY * qglColor4sv )(const GLshort *v);\nvoid ( APIENTRY * qglColor4ub )(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);\nvoid ( APIENTRY * qglColor4ubv )(const GLubyte *v);\nvoid ( APIENTRY * qglColor4ui )(GLuint red, GLuint green, GLuint blue, GLuint alpha);\nvoid ( APIENTRY * qglColor4uiv )(const GLuint *v);\nvoid ( APIENTRY * qglColor4us )(GLushort red, GLushort green, GLushort blue, GLushort alpha);\nvoid ( APIENTRY * qglColor4usv )(const GLushort *v);\nvoid ( APIENTRY * qglColorMask )(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);\nvoid ( APIENTRY * qglColorMaterial )(GLenum face, GLenum mode);\nvoid ( APIENTRY * qglColorPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglCopyPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);\nvoid ( APIENTRY * qglCopyTexImage1D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border);\nvoid ( APIENTRY * qglCopyTexImage2D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\nvoid ( APIENTRY * qglCopyTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\nvoid ( APIENTRY * qglCopyTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nvoid ( APIENTRY * qglCullFace )(GLenum mode);\nvoid ( APIENTRY * qglDeleteLists )(GLuint list, GLsizei range);\nvoid ( APIENTRY * qglDeleteTextures )(GLsizei n, const GLuint *textures);\nvoid ( APIENTRY * qglDepthFunc )(GLenum func);\nvoid ( APIENTRY * qglDepthMask )(GLboolean flag);\nvoid ( APIENTRY * qglDepthRange )(GLclampd zNear, GLclampd zFar);\nvoid ( APIENTRY * qglDisable )(GLenum cap);\nvoid ( APIENTRY * qglDisableClientState )(GLenum array);\nvoid ( APIENTRY * qglDrawArrays )(GLenum mode, GLint first, GLsizei count);\nvoid ( APIENTRY * qglDrawBuffer )(GLenum mode);\nvoid ( APIENTRY * qglDrawElements )(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);\nvoid ( APIENTRY * qglDrawPixels )(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nvoid ( APIENTRY * qglEdgeFlag )(GLboolean flag);\nvoid ( APIENTRY * qglEdgeFlagPointer )(GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglEdgeFlagv )(const GLboolean *flag);\nvoid ( APIENTRY * qglEnable )(GLenum cap);\nvoid ( APIENTRY * qglEnableClientState )(GLenum array);\nvoid ( APIENTRY * qglEnd )(void);\nvoid ( APIENTRY * qglEndList )(void);\nvoid ( APIENTRY * qglEvalCoord1d )(GLdouble u);\nvoid ( APIENTRY * qglEvalCoord1dv )(const GLdouble *u);\nvoid ( APIENTRY * qglEvalCoord1f )(GLfloat u);\nvoid ( APIENTRY * qglEvalCoord1fv )(const GLfloat *u);\nvoid ( APIENTRY * qglEvalCoord2d )(GLdouble u, GLdouble v);\nvoid ( APIENTRY * qglEvalCoord2dv )(const GLdouble *u);\nvoid ( APIENTRY * qglEvalCoord2f )(GLfloat u, GLfloat v);\nvoid ( APIENTRY * qglEvalCoord2fv )(const GLfloat *u);\nvoid ( APIENTRY * qglEvalMesh1 )(GLenum mode, GLint i1, GLint i2);\nvoid ( APIENTRY * qglEvalMesh2 )(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);\nvoid ( APIENTRY * qglEvalPoint1 )(GLint i);\nvoid ( APIENTRY * qglEvalPoint2 )(GLint i, GLint j);\nvoid ( APIENTRY * qglFeedbackBuffer )(GLsizei size, GLenum type, GLfloat *buffer);\nvoid ( APIENTRY * qglFinish )(void);\nvoid ( APIENTRY * qglFlush )(void);\nvoid ( APIENTRY * qglFogf )(GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglFogfv )(GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglFogi )(GLenum pname, GLint param);\nvoid ( APIENTRY * qglFogiv )(GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglFrontFace )(GLenum mode);\nvoid ( APIENTRY * qglFrustum )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nGLuint ( APIENTRY * qglGenLists )(GLsizei range);\nvoid ( APIENTRY * qglGenTextures )(GLsizei n, GLuint *textures);\nvoid ( APIENTRY * qglGetBooleanv )(GLenum pname, GLboolean *params);\nvoid ( APIENTRY * qglGetClipPlane )(GLenum plane, GLdouble *equation);\nvoid ( APIENTRY * qglGetDoublev )(GLenum pname, GLdouble *params);\nGLenum ( APIENTRY * qglGetError )(void);\nvoid ( APIENTRY * qglGetFloatv )(GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetIntegerv )(GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetLightfv )(GLenum light, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetLightiv )(GLenum light, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetMapdv )(GLenum target, GLenum query, GLdouble *v);\nvoid ( APIENTRY * qglGetMapfv )(GLenum target, GLenum query, GLfloat *v);\nvoid ( APIENTRY * qglGetMapiv )(GLenum target, GLenum query, GLint *v);\nvoid ( APIENTRY * qglGetMaterialfv )(GLenum face, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetMaterialiv )(GLenum face, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetPixelMapfv )(GLenum map, GLfloat *values);\nvoid ( APIENTRY * qglGetPixelMapuiv )(GLenum map, GLuint *values);\nvoid ( APIENTRY * qglGetPixelMapusv )(GLenum map, GLushort *values);\nvoid ( APIENTRY * qglGetPointerv )(GLenum pname, GLvoid* *params);\nvoid ( APIENTRY * qglGetPolygonStipple )(GLubyte *mask);\nconst GLubyte * ( APIENTRY * qglGetString )(GLenum name);\nvoid ( APIENTRY * qglGetTexEnvfv )(GLenum target, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetTexEnviv )(GLenum target, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetTexGendv )(GLenum coord, GLenum pname, GLdouble *params);\nvoid ( APIENTRY * qglGetTexGenfv )(GLenum coord, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetTexGeniv )(GLenum coord, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetTexImage )(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);\nvoid ( APIENTRY * qglGetTexLevelParameterfv )(GLenum target, GLint level, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetTexLevelParameteriv )(GLenum target, GLint level, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetTexParameterfv )(GLenum target, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetTexParameteriv )(GLenum target, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglHint )(GLenum target, GLenum mode);\nvoid ( APIENTRY * qglIndexMask )(GLuint mask);\nvoid ( APIENTRY * qglIndexPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglIndexd )(GLdouble c);\nvoid ( APIENTRY * qglIndexdv )(const GLdouble *c);\nvoid ( APIENTRY * qglIndexf )(GLfloat c);\nvoid ( APIENTRY * qglIndexfv )(const GLfloat *c);\nvoid ( APIENTRY * qglIndexi )(GLint c);\nvoid ( APIENTRY * qglIndexiv )(const GLint *c);\nvoid ( APIENTRY * qglIndexs )(GLshort c);\nvoid ( APIENTRY * qglIndexsv )(const GLshort *c);\nvoid ( APIENTRY * qglIndexub )(GLubyte c);\nvoid ( APIENTRY * qglIndexubv )(const GLubyte *c);\nvoid ( APIENTRY * qglInitNames )(void);\nvoid ( APIENTRY * qglInterleavedArrays )(GLenum format, GLsizei stride, const GLvoid *pointer);\nGLboolean ( APIENTRY * qglIsEnabled )(GLenum cap);\nGLboolean ( APIENTRY * qglIsList )(GLuint list);\nGLboolean ( APIENTRY * qglIsTexture )(GLuint texture);\nvoid ( APIENTRY * qglLightModelf )(GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglLightModelfv )(GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglLightModeli )(GLenum pname, GLint param);\nvoid ( APIENTRY * qglLightModeliv )(GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglLightf )(GLenum light, GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglLightfv )(GLenum light, GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglLighti )(GLenum light, GLenum pname, GLint param);\nvoid ( APIENTRY * qglLightiv )(GLenum light, GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglLineStipple )(GLint factor, GLushort pattern);\nvoid ( APIENTRY * qglLineWidth )(GLfloat width);\nvoid ( APIENTRY * qglListBase )(GLuint base);\nvoid ( APIENTRY * qglLoadIdentity )(void);\nvoid ( APIENTRY * qglLoadMatrixd )(const GLdouble *m);\nvoid ( APIENTRY * qglLoadMatrixf )(const GLfloat *m);\nvoid ( APIENTRY * qglLoadName )(GLuint name);\nvoid ( APIENTRY * qglLogicOp )(GLenum opcode);\nvoid ( APIENTRY * qglMap1d )(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);\nvoid ( APIENTRY * qglMap1f )(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);\nvoid ( APIENTRY * qglMap2d )(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);\nvoid ( APIENTRY * qglMap2f )(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);\nvoid ( APIENTRY * qglMapGrid1d )(GLint un, GLdouble u1, GLdouble u2);\nvoid ( APIENTRY * qglMapGrid1f )(GLint un, GLfloat u1, GLfloat u2);\nvoid ( APIENTRY * qglMapGrid2d )(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);\nvoid ( APIENTRY * qglMapGrid2f )(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);\nvoid ( APIENTRY * qglMaterialf )(GLenum face, GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglMaterialfv )(GLenum face, GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglMateriali )(GLenum face, GLenum pname, GLint param);\nvoid ( APIENTRY * qglMaterialiv )(GLenum face, GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglMatrixMode )(GLenum mode);\nvoid ( APIENTRY * qglMultMatrixd )(const GLdouble *m);\nvoid ( APIENTRY * qglMultMatrixf )(const GLfloat *m);\nvoid ( APIENTRY * qglNewList )(GLuint list, GLenum mode);\nvoid ( APIENTRY * qglNormal3b )(GLbyte nx, GLbyte ny, GLbyte nz);\nvoid ( APIENTRY * qglNormal3bv )(const GLbyte *v);\nvoid ( APIENTRY * qglNormal3d )(GLdouble nx, GLdouble ny, GLdouble nz);\nvoid ( APIENTRY * qglNormal3dv )(const GLdouble *v);\nvoid ( APIENTRY * qglNormal3f )(GLfloat nx, GLfloat ny, GLfloat nz);\nvoid ( APIENTRY * qglNormal3fv )(const GLfloat *v);\nvoid ( APIENTRY * qglNormal3i )(GLint nx, GLint ny, GLint nz);\nvoid ( APIENTRY * qglNormal3iv )(const GLint *v);\nvoid ( APIENTRY * qglNormal3s )(GLshort nx, GLshort ny, GLshort nz);\nvoid ( APIENTRY * qglNormal3sv )(const GLshort *v);\nvoid ( APIENTRY * qglNormalPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglOrtho )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nvoid ( APIENTRY * qglPassThrough )(GLfloat token);\nvoid ( APIENTRY * qglPixelMapfv )(GLenum map, GLsizei mapsize, const GLfloat *values);\nvoid ( APIENTRY * qglPixelMapuiv )(GLenum map, GLsizei mapsize, const GLuint *values);\nvoid ( APIENTRY * qglPixelMapusv )(GLenum map, GLsizei mapsize, const GLushort *values);\nvoid ( APIENTRY * qglPixelStoref )(GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglPixelStorei )(GLenum pname, GLint param);\nvoid ( APIENTRY * qglPixelTransferf )(GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglPixelTransferi )(GLenum pname, GLint param);\nvoid ( APIENTRY * qglPixelZoom )(GLfloat xfactor, GLfloat yfactor);\nvoid ( APIENTRY * qglPointSize )(GLfloat size);\nvoid ( APIENTRY * qglPolygonMode )(GLenum face, GLenum mode);\nvoid ( APIENTRY * qglPolygonOffset )(GLfloat factor, GLfloat units);\nvoid ( APIENTRY * qglPolygonStipple )(const GLubyte *mask);\nvoid ( APIENTRY * qglPopAttrib )(void);\nvoid ( APIENTRY * qglPopClientAttrib )(void);\nvoid ( APIENTRY * qglPopMatrix )(void);\nvoid ( APIENTRY * qglPopName )(void);\nvoid ( APIENTRY * qglPrioritizeTextures )(GLsizei n, const GLuint *textures, const GLclampf *priorities);\nvoid ( APIENTRY * qglPushAttrib )(GLbitfield mask);\nvoid ( APIENTRY * qglPushClientAttrib )(GLbitfield mask);\nvoid ( APIENTRY * qglPushMatrix )(void);\nvoid ( APIENTRY * qglPushName )(GLuint name);\nvoid ( APIENTRY * qglRasterPos2d )(GLdouble x, GLdouble y);\nvoid ( APIENTRY * qglRasterPos2dv )(const GLdouble *v);\nvoid ( APIENTRY * qglRasterPos2f )(GLfloat x, GLfloat y);\nvoid ( APIENTRY * qglRasterPos2fv )(const GLfloat *v);\nvoid ( APIENTRY * qglRasterPos2i )(GLint x, GLint y);\nvoid ( APIENTRY * qglRasterPos2iv )(const GLint *v);\nvoid ( APIENTRY * qglRasterPos2s )(GLshort x, GLshort y);\nvoid ( APIENTRY * qglRasterPos2sv )(const GLshort *v);\nvoid ( APIENTRY * qglRasterPos3d )(GLdouble x, GLdouble y, GLdouble z);\nvoid ( APIENTRY * qglRasterPos3dv )(const GLdouble *v);\nvoid ( APIENTRY * qglRasterPos3f )(GLfloat x, GLfloat y, GLfloat z);\nvoid ( APIENTRY * qglRasterPos3fv )(const GLfloat *v);\nvoid ( APIENTRY * qglRasterPos3i )(GLint x, GLint y, GLint z);\nvoid ( APIENTRY * qglRasterPos3iv )(const GLint *v);\nvoid ( APIENTRY * qglRasterPos3s )(GLshort x, GLshort y, GLshort z);\nvoid ( APIENTRY * qglRasterPos3sv )(const GLshort *v);\nvoid ( APIENTRY * qglRasterPos4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nvoid ( APIENTRY * qglRasterPos4dv )(const GLdouble *v);\nvoid ( APIENTRY * qglRasterPos4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nvoid ( APIENTRY * qglRasterPos4fv )(const GLfloat *v);\nvoid ( APIENTRY * qglRasterPos4i )(GLint x, GLint y, GLint z, GLint w);\nvoid ( APIENTRY * qglRasterPos4iv )(const GLint *v);\nvoid ( APIENTRY * qglRasterPos4s )(GLshort x, GLshort y, GLshort z, GLshort w);\nvoid ( APIENTRY * qglRasterPos4sv )(const GLshort *v);\nvoid ( APIENTRY * qglReadBuffer )(GLenum mode);\nvoid ( APIENTRY * qglReadPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);\nvoid ( APIENTRY * qglRectd )(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);\nvoid ( APIENTRY * qglRectdv )(const GLdouble *v1, const GLdouble *v2);\nvoid ( APIENTRY * qglRectf )(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);\nvoid ( APIENTRY * qglRectfv )(const GLfloat *v1, const GLfloat *v2);\nvoid ( APIENTRY * qglRecti )(GLint x1, GLint y1, GLint x2, GLint y2);\nvoid ( APIENTRY * qglRectiv )(const GLint *v1, const GLint *v2);\nvoid ( APIENTRY * qglRects )(GLshort x1, GLshort y1, GLshort x2, GLshort y2);\nvoid ( APIENTRY * qglRectsv )(const GLshort *v1, const GLshort *v2);\nGLint ( APIENTRY * qglRenderMode )(GLenum mode);\nvoid ( APIENTRY * qglRotated )(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);\nvoid ( APIENTRY * qglRotatef )(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);\nvoid ( APIENTRY * qglScaled )(GLdouble x, GLdouble y, GLdouble z);\nvoid ( APIENTRY * qglScalef )(GLfloat x, GLfloat y, GLfloat z);\nvoid ( APIENTRY * qglScissor )(GLint x, GLint y, GLsizei width, GLsizei height);\nvoid ( APIENTRY * qglSelectBuffer )(GLsizei size, GLuint *buffer);\nvoid ( APIENTRY * qglShadeModel )(GLenum mode);\nvoid ( APIENTRY * qglStencilFunc )(GLenum func, GLint ref, GLuint mask);\nvoid ( APIENTRY * qglStencilMask )(GLuint mask);\nvoid ( APIENTRY * qglStencilOp )(GLenum fail, GLenum zfail, GLenum zpass);\nvoid ( APIENTRY * qglTexCoord1d )(GLdouble s);\nvoid ( APIENTRY * qglTexCoord1dv )(const GLdouble *v);\nvoid ( APIENTRY * qglTexCoord1f )(GLfloat s);\nvoid ( APIENTRY * qglTexCoord1fv )(const GLfloat *v);\nvoid ( APIENTRY * qglTexCoord1i )(GLint s);\nvoid ( APIENTRY * qglTexCoord1iv )(const GLint *v);\nvoid ( APIENTRY * qglTexCoord1s )(GLshort s);\nvoid ( APIENTRY * qglTexCoord1sv )(const GLshort *v);\nvoid ( APIENTRY * qglTexCoord2d )(GLdouble s, GLdouble t);\nvoid ( APIENTRY * qglTexCoord2dv )(const GLdouble *v);\nvoid ( APIENTRY * qglTexCoord2f )(GLfloat s, GLfloat t);\nvoid ( APIENTRY * qglTexCoord2fv )(const GLfloat *v);\nvoid ( APIENTRY * qglTexCoord2i )(GLint s, GLint t);\nvoid ( APIENTRY * qglTexCoord2iv )(const GLint *v);\nvoid ( APIENTRY * qglTexCoord2s )(GLshort s, GLshort t);\nvoid ( APIENTRY * qglTexCoord2sv )(const GLshort *v);\nvoid ( APIENTRY * qglTexCoord3d )(GLdouble s, GLdouble t, GLdouble r);\nvoid ( APIENTRY * qglTexCoord3dv )(const GLdouble *v);\nvoid ( APIENTRY * qglTexCoord3f )(GLfloat s, GLfloat t, GLfloat r);\nvoid ( APIENTRY * qglTexCoord3fv )(const GLfloat *v);\nvoid ( APIENTRY * qglTexCoord3i )(GLint s, GLint t, GLint r);\nvoid ( APIENTRY * qglTexCoord3iv )(const GLint *v);\nvoid ( APIENTRY * qglTexCoord3s )(GLshort s, GLshort t, GLshort r);\nvoid ( APIENTRY * qglTexCoord3sv )(const GLshort *v);\nvoid ( APIENTRY * qglTexCoord4d )(GLdouble s, GLdouble t, GLdouble r, GLdouble q);\nvoid ( APIENTRY * qglTexCoord4dv )(const GLdouble *v);\nvoid ( APIENTRY * qglTexCoord4f )(GLfloat s, GLfloat t, GLfloat r, GLfloat q);\nvoid ( APIENTRY * qglTexCoord4fv )(const GLfloat *v);\nvoid ( APIENTRY * qglTexCoord4i )(GLint s, GLint t, GLint r, GLint q);\nvoid ( APIENTRY * qglTexCoord4iv )(const GLint *v);\nvoid ( APIENTRY * qglTexCoord4s )(GLshort s, GLshort t, GLshort r, GLshort q);\nvoid ( APIENTRY * qglTexCoord4sv )(const GLshort *v);\nvoid ( APIENTRY * qglTexCoordPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglTexEnvf )(GLenum target, GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglTexEnvfv )(GLenum target, GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglTexEnvi )(GLenum target, GLenum pname, GLint param);\nvoid ( APIENTRY * qglTexEnviv )(GLenum target, GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglTexGend )(GLenum coord, GLenum pname, GLdouble param);\nvoid ( APIENTRY * qglTexGendv )(GLenum coord, GLenum pname, const GLdouble *params);\nvoid ( APIENTRY * qglTexGenf )(GLenum coord, GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglTexGenfv )(GLenum coord, GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglTexGeni )(GLenum coord, GLenum pname, GLint param);\nvoid ( APIENTRY * qglTexGeniv )(GLenum coord, GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglTexImage1D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nvoid ( APIENTRY * qglTexImage2D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nvoid ( APIENTRY * qglTexParameterf )(GLenum target, GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglTexParameterfv )(GLenum target, GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglTexParameteri )(GLenum target, GLenum pname, GLint param);\nvoid ( APIENTRY * qglTexParameteriv )(GLenum target, GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);\nvoid ( APIENTRY * qglTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nvoid ( APIENTRY * qglTranslated )(GLdouble x, GLdouble y, GLdouble z);\nvoid ( APIENTRY * qglTranslatef )(GLfloat x, GLfloat y, GLfloat z);\nvoid ( APIENTRY * qglVertex2d )(GLdouble x, GLdouble y);\nvoid ( APIENTRY * qglVertex2dv )(const GLdouble *v);\nvoid ( APIENTRY * qglVertex2f )(GLfloat x, GLfloat y);\nvoid ( APIENTRY * qglVertex2fv )(const GLfloat *v);\nvoid ( APIENTRY * qglVertex2i )(GLint x, GLint y);\nvoid ( APIENTRY * qglVertex2iv )(const GLint *v);\nvoid ( APIENTRY * qglVertex2s )(GLshort x, GLshort y);\nvoid ( APIENTRY * qglVertex2sv )(const GLshort *v);\nvoid ( APIENTRY * qglVertex3d )(GLdouble x, GLdouble y, GLdouble z);\nvoid ( APIENTRY * qglVertex3dv )(const GLdouble *v);\nvoid ( APIENTRY * qglVertex3f )(GLfloat x, GLfloat y, GLfloat z);\nvoid ( APIENTRY * qglVertex3fv )(const GLfloat *v);\nvoid ( APIENTRY * qglVertex3i )(GLint x, GLint y, GLint z);\nvoid ( APIENTRY * qglVertex3iv )(const GLint *v);\nvoid ( APIENTRY * qglVertex3s )(GLshort x, GLshort y, GLshort z);\nvoid ( APIENTRY * qglVertex3sv )(const GLshort *v);\nvoid ( APIENTRY * qglVertex4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nvoid ( APIENTRY * qglVertex4dv )(const GLdouble *v);\nvoid ( APIENTRY * qglVertex4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nvoid ( APIENTRY * qglVertex4fv )(const GLfloat *v);\nvoid ( APIENTRY * qglVertex4i )(GLint x, GLint y, GLint z, GLint w);\nvoid ( APIENTRY * qglVertex4iv )(const GLint *v);\nvoid ( APIENTRY * qglVertex4s )(GLshort x, GLshort y, GLshort z, GLshort w);\nvoid ( APIENTRY * qglVertex4sv )(const GLshort *v);\nvoid ( APIENTRY * qglVertexPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglViewport )(GLint x, GLint y, GLsizei width, GLsizei height);\n\nBOOL ( WINAPI * qwglSwapIntervalEXT)( int interval );\nBOOL ( WINAPI * qwglGetDeviceGammaRampEXT)( unsigned char *, unsigned char *, unsigned char * );\nBOOL ( WINAPI * qwglSetDeviceGammaRampEXT)( const unsigned char *, const unsigned char *, const unsigned char * );\nvoid ( APIENTRY * qglPointParameterfEXT)( GLenum param, GLfloat value );\nvoid ( APIENTRY * qglPointParameterfvEXT)( GLenum param, const GLfloat *value );\nvoid ( APIENTRY * qglColorTableEXT)( int, int, int, int, int, const void * );\nvoid ( APIENTRY * qglSelectTextureSGIS)( GLenum );\nvoid ( APIENTRY * qglMTexCoord2fSGIS)( GLenum, GLfloat, GLfloat );\n\n\n// glu stuff\nvoid (APIENTRY * qgluPerspective) (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);\nint  (APIENTRY * qgluBuild2DMipmaps) (GLenum target, GLint components, GLint width, GLint height, GLenum format, GLenum      type, const void  *data);\n// added for plugins\nvoid (APIENTRY * qgluLookAt)(\n  GLdouble eyex,\n  GLdouble eyey,\n  GLdouble eyez,\n  GLdouble centerx,\n  GLdouble centery,\n  GLdouble centerz,\n  GLdouble upx,\n  GLdouble upy,\n  GLdouble upz);\n\n\n/*\n** QGL_Shutdown\n**\n** Unloads the specified DLL then nulls out all the proc pointers.\n*/\nvoid QGL_Shutdown()\n{\n\tif (g_hGLDLL)\n\t{\n    FreeLibrary(g_hGLDLL);\n    g_hGLDLL = NULL;\n\t}\n\tif (g_hGLUDLL)\n\t{\n    FreeLibrary(g_hGLUDLL);\n    g_hGLUDLL = NULL;\n\t}\n\n\n\tqglAccum                     = NULL;\n\tqglAlphaFunc                 = NULL;\n\tqglAreTexturesResident       = NULL;\n\tqglArrayElement              = NULL;\n\tqglBegin                     = NULL;\n\tqglBindTexture               = NULL;\n\tqglBitmap                    = NULL;\n\tqglBlendFunc                 = NULL;\n\tqglCallList                  = NULL;\n\tqglCallLists                 = NULL;\n\tqglClear                     = NULL;\n\tqglClearAccum                = NULL;\n\tqglClearColor                = NULL;\n\tqglClearDepth                = NULL;\n\tqglClearIndex                = NULL;\n\tqglClearStencil              = NULL;\n\tqglClipPlane                 = NULL;\n\tqglColor3b                   = NULL;\n\tqglColor3bv                  = NULL;\n\tqglColor3d                   = NULL;\n\tqglColor3dv                  = NULL;\n\tqglColor3f                   = NULL;\n\tqglColor3fv                  = NULL;\n\tqglColor3i                   = NULL;\n\tqglColor3iv                  = NULL;\n\tqglColor3s                   = NULL;\n\tqglColor3sv                  = NULL;\n\tqglColor3ub                  = NULL;\n\tqglColor3ubv                 = NULL;\n\tqglColor3ui                  = NULL;\n\tqglColor3uiv                 = NULL;\n\tqglColor3us                  = NULL;\n\tqglColor3usv                 = NULL;\n\tqglColor4b                   = NULL;\n\tqglColor4bv                  = NULL;\n\tqglColor4d                   = NULL;\n\tqglColor4dv                  = NULL;\n\tqglColor4f                   = NULL;\n\tqglColor4fv                  = NULL;\n\tqglColor4i                   = NULL;\n\tqglColor4iv                  = NULL;\n\tqglColor4s                   = NULL;\n\tqglColor4sv                  = NULL;\n\tqglColor4ub                  = NULL;\n\tqglColor4ubv                 = NULL;\n\tqglColor4ui                  = NULL;\n\tqglColor4uiv                 = NULL;\n\tqglColor4us                  = NULL;\n\tqglColor4usv                 = NULL;\n\tqglColorMask                 = NULL;\n\tqglColorMaterial             = NULL;\n\tqglColorPointer              = NULL;\n\tqglCopyPixels                = NULL;\n\tqglCopyTexImage1D            = NULL;\n\tqglCopyTexImage2D            = NULL;\n\tqglCopyTexSubImage1D         = NULL;\n\tqglCopyTexSubImage2D         = NULL;\n\tqglCullFace                  = NULL;\n\tqglDeleteLists               = NULL;\n\tqglDeleteTextures            = NULL;\n\tqglDepthFunc                 = NULL;\n\tqglDepthMask                 = NULL;\n\tqglDepthRange                = NULL;\n\tqglDisable                   = NULL;\n\tqglDisableClientState        = NULL;\n\tqglDrawArrays                = NULL;\n\tqglDrawBuffer                = NULL;\n\tqglDrawElements              = NULL;\n\tqglDrawPixels                = NULL;\n\tqglEdgeFlag                  = NULL;\n\tqglEdgeFlagPointer           = NULL;\n\tqglEdgeFlagv                 = NULL;\n\tqglEnable                    = NULL;\n\tqglEnableClientState         = NULL;\n\tqglEnd                       = NULL;\n\tqglEndList                   = NULL;\n\tqglEvalCoord1d               = NULL;\n\tqglEvalCoord1dv              = NULL;\n\tqglEvalCoord1f               = NULL;\n\tqglEvalCoord1fv              = NULL;\n\tqglEvalCoord2d               = NULL;\n\tqglEvalCoord2dv              = NULL;\n\tqglEvalCoord2f               = NULL;\n\tqglEvalCoord2fv              = NULL;\n\tqglEvalMesh1                 = NULL;\n\tqglEvalMesh2                 = NULL;\n\tqglEvalPoint1                = NULL;\n\tqglEvalPoint2                = NULL;\n\tqglFeedbackBuffer            = NULL;\n\tqglFinish                    = NULL;\n\tqglFlush                     = NULL;\n\tqglFogf                      = NULL;\n\tqglFogfv                     = NULL;\n\tqglFogi                      = NULL;\n\tqglFogiv                     = NULL;\n\tqglFrontFace                 = NULL;\n\tqglFrustum                   = NULL;\n\tqglGenLists                  = NULL;\n\tqglGenTextures               = NULL;\n\tqglGetBooleanv               = NULL;\n\tqglGetClipPlane              = NULL;\n\tqglGetDoublev                = NULL;\n\tqglGetError                  = NULL;\n\tqglGetFloatv                 = NULL;\n\tqglGetIntegerv               = NULL;\n\tqglGetLightfv                = NULL;\n\tqglGetLightiv                = NULL;\n\tqglGetMapdv                  = NULL;\n\tqglGetMapfv                  = NULL;\n\tqglGetMapiv                  = NULL;\n\tqglGetMaterialfv             = NULL;\n\tqglGetMaterialiv             = NULL;\n\tqglGetPixelMapfv             = NULL;\n\tqglGetPixelMapuiv            = NULL;\n\tqglGetPixelMapusv            = NULL;\n\tqglGetPointerv               = NULL;\n\tqglGetPolygonStipple         = NULL;\n\tqglGetString                 = NULL;\n\tqglGetTexEnvfv               = NULL;\n\tqglGetTexEnviv               = NULL;\n\tqglGetTexGendv               = NULL;\n\tqglGetTexGenfv               = NULL;\n\tqglGetTexGeniv               = NULL;\n\tqglGetTexImage               = NULL;\n\tqglGetTexLevelParameterfv    = NULL;\n\tqglGetTexLevelParameteriv    = NULL;\n\tqglGetTexParameterfv         = NULL;\n\tqglGetTexParameteriv         = NULL;\n\tqglHint                      = NULL;\n\tqglIndexMask                 = NULL;\n\tqglIndexPointer              = NULL;\n\tqglIndexd                    = NULL;\n\tqglIndexdv                   = NULL;\n\tqglIndexf                    = NULL;\n\tqglIndexfv                   = NULL;\n\tqglIndexi                    = NULL;\n\tqglIndexiv                   = NULL;\n\tqglIndexs                    = NULL;\n\tqglIndexsv                   = NULL;\n\tqglIndexub                   = NULL;\n\tqglIndexubv                  = NULL;\n\tqglInitNames                 = NULL;\n\tqglInterleavedArrays         = NULL;\n\tqglIsEnabled                 = NULL;\n\tqglIsList                    = NULL;\n\tqglIsTexture                 = NULL;\n\tqglLightModelf               = NULL;\n\tqglLightModelfv              = NULL;\n\tqglLightModeli               = NULL;\n\tqglLightModeliv              = NULL;\n\tqglLightf                    = NULL;\n\tqglLightfv                   = NULL;\n\tqglLighti                    = NULL;\n\tqglLightiv                   = NULL;\n\tqglLineStipple               = NULL;\n\tqglLineWidth                 = NULL;\n\tqglListBase                  = NULL;\n\tqglLoadIdentity              = NULL;\n\tqglLoadMatrixd               = NULL;\n\tqglLoadMatrixf               = NULL;\n\tqglLoadName                  = NULL;\n\tqglLogicOp                   = NULL;\n\tqglMap1d                     = NULL;\n\tqglMap1f                     = NULL;\n\tqglMap2d                     = NULL;\n\tqglMap2f                     = NULL;\n\tqglMapGrid1d                 = NULL;\n\tqglMapGrid1f                 = NULL;\n\tqglMapGrid2d                 = NULL;\n\tqglMapGrid2f                 = NULL;\n\tqglMaterialf                 = NULL;\n\tqglMaterialfv                = NULL;\n\tqglMateriali                 = NULL;\n\tqglMaterialiv                = NULL;\n\tqglMatrixMode                = NULL;\n\tqglMultMatrixd               = NULL;\n\tqglMultMatrixf               = NULL;\n\tqglNewList                   = NULL;\n\tqglNormal3b                  = NULL;\n\tqglNormal3bv                 = NULL;\n\tqglNormal3d                  = NULL;\n\tqglNormal3dv                 = NULL;\n\tqglNormal3f                  = NULL;\n\tqglNormal3fv                 = NULL;\n\tqglNormal3i                  = NULL;\n\tqglNormal3iv                 = NULL;\n\tqglNormal3s                  = NULL;\n\tqglNormal3sv                 = NULL;\n\tqglNormalPointer             = NULL;\n\tqglOrtho                     = NULL;\n\tqglPassThrough               = NULL;\n\tqglPixelMapfv                = NULL;\n\tqglPixelMapuiv               = NULL;\n\tqglPixelMapusv               = NULL;\n\tqglPixelStoref               = NULL;\n\tqglPixelStorei               = NULL;\n\tqglPixelTransferf            = NULL;\n\tqglPixelTransferi            = NULL;\n\tqglPixelZoom                 = NULL;\n\tqglPointSize                 = NULL;\n\tqglPolygonMode               = NULL;\n\tqglPolygonOffset             = NULL;\n\tqglPolygonStipple            = NULL;\n\tqglPopAttrib                 = NULL;\n\tqglPopClientAttrib           = NULL;\n\tqglPopMatrix                 = NULL;\n\tqglPopName                   = NULL;\n\tqglPrioritizeTextures        = NULL;\n\tqglPushAttrib                = NULL;\n\tqglPushClientAttrib          = NULL;\n\tqglPushMatrix                = NULL;\n\tqglPushName                  = NULL;\n\tqglRasterPos2d               = NULL;\n\tqglRasterPos2dv              = NULL;\n\tqglRasterPos2f               = NULL;\n\tqglRasterPos2fv              = NULL;\n\tqglRasterPos2i               = NULL;\n\tqglRasterPos2iv              = NULL;\n\tqglRasterPos2s               = NULL;\n\tqglRasterPos2sv              = NULL;\n\tqglRasterPos3d               = NULL;\n\tqglRasterPos3dv              = NULL;\n\tqglRasterPos3f               = NULL;\n\tqglRasterPos3fv              = NULL;\n\tqglRasterPos3i               = NULL;\n\tqglRasterPos3iv              = NULL;\n\tqglRasterPos3s               = NULL;\n\tqglRasterPos3sv              = NULL;\n\tqglRasterPos4d               = NULL;\n\tqglRasterPos4dv              = NULL;\n\tqglRasterPos4f               = NULL;\n\tqglRasterPos4fv              = NULL;\n\tqglRasterPos4i               = NULL;\n\tqglRasterPos4iv              = NULL;\n\tqglRasterPos4s               = NULL;\n\tqglRasterPos4sv              = NULL;\n\tqglReadBuffer                = NULL;\n\tqglReadPixels                = NULL;\n\tqglRectd                     = NULL;\n\tqglRectdv                    = NULL;\n\tqglRectf                     = NULL;\n\tqglRectfv                    = NULL;\n\tqglRecti                     = NULL;\n\tqglRectiv                    = NULL;\n\tqglRects                     = NULL;\n\tqglRectsv                    = NULL;\n\tqglRenderMode                = NULL;\n\tqglRotated                   = NULL;\n\tqglRotatef                   = NULL;\n\tqglScaled                    = NULL;\n\tqglScalef                    = NULL;\n\tqglScissor                   = NULL;\n\tqglSelectBuffer              = NULL;\n\tqglShadeModel                = NULL;\n\tqglStencilFunc               = NULL;\n\tqglStencilMask               = NULL;\n\tqglStencilOp                 = NULL;\n\tqglTexCoord1d                = NULL;\n\tqglTexCoord1dv               = NULL;\n\tqglTexCoord1f                = NULL;\n\tqglTexCoord1fv               = NULL;\n\tqglTexCoord1i                = NULL;\n\tqglTexCoord1iv               = NULL;\n\tqglTexCoord1s                = NULL;\n\tqglTexCoord1sv               = NULL;\n\tqglTexCoord2d                = NULL;\n\tqglTexCoord2dv               = NULL;\n\tqglTexCoord2f                = NULL;\n\tqglTexCoord2fv               = NULL;\n\tqglTexCoord2i                = NULL;\n\tqglTexCoord2iv               = NULL;\n\tqglTexCoord2s                = NULL;\n\tqglTexCoord2sv               = NULL;\n\tqglTexCoord3d                = NULL;\n\tqglTexCoord3dv               = NULL;\n\tqglTexCoord3f                = NULL;\n\tqglTexCoord3fv               = NULL;\n\tqglTexCoord3i                = NULL;\n\tqglTexCoord3iv               = NULL;\n\tqglTexCoord3s                = NULL;\n\tqglTexCoord3sv               = NULL;\n\tqglTexCoord4d                = NULL;\n\tqglTexCoord4dv               = NULL;\n\tqglTexCoord4f                = NULL;\n\tqglTexCoord4fv               = NULL;\n\tqglTexCoord4i                = NULL;\n\tqglTexCoord4iv               = NULL;\n\tqglTexCoord4s                = NULL;\n\tqglTexCoord4sv               = NULL;\n\tqglTexCoordPointer           = NULL;\n\tqglTexEnvf                   = NULL;\n\tqglTexEnvfv                  = NULL;\n\tqglTexEnvi                   = NULL;\n\tqglTexEnviv                  = NULL;\n\tqglTexGend                   = NULL;\n\tqglTexGendv                  = NULL;\n\tqglTexGenf                   = NULL;\n\tqglTexGenfv                  = NULL;\n\tqglTexGeni                   = NULL;\n\tqglTexGeniv                  = NULL;\n\tqglTexImage1D                = NULL;\n\tqglTexImage2D                = NULL;\n\tqglTexParameterf             = NULL;\n\tqglTexParameterfv            = NULL;\n\tqglTexParameteri             = NULL;\n\tqglTexParameteriv            = NULL;\n\tqglTexSubImage1D             = NULL;\n\tqglTexSubImage2D             = NULL;\n\tqglTranslated                = NULL;\n\tqglTranslatef                = NULL;\n\tqglVertex2d                  = NULL;\n\tqglVertex2dv                 = NULL;\n\tqglVertex2f                  = NULL;\n\tqglVertex2fv                 = NULL;\n\tqglVertex2i                  = NULL;\n\tqglVertex2iv                 = NULL;\n\tqglVertex2s                  = NULL;\n\tqglVertex2sv                 = NULL;\n\tqglVertex3d                  = NULL;\n\tqglVertex3dv                 = NULL;\n\tqglVertex3f                  = NULL;\n\tqglVertex3fv                 = NULL;\n\tqglVertex3i                  = NULL;\n\tqglVertex3iv                 = NULL;\n\tqglVertex3s                  = NULL;\n\tqglVertex3sv                 = NULL;\n\tqglVertex4d                  = NULL;\n\tqglVertex4dv                 = NULL;\n\tqglVertex4f                  = NULL;\n\tqglVertex4fv                 = NULL;\n\tqglVertex4i                  = NULL;\n\tqglVertex4iv                 = NULL;\n\tqglVertex4s                  = NULL;\n\tqglVertex4sv                 = NULL;\n\tqglVertexPointer             = NULL;\n\tqglViewport                  = NULL;\n\n\tqwglCopyContext              = NULL;\n\tqwglCreateContext            = NULL;\n\tqwglCreateLayerContext       = NULL;\n\tqwglDeleteContext            = NULL;\n\tqwglDescribeLayerPlane       = NULL;\n\tqwglGetCurrentContext        = NULL;\n\tqwglGetCurrentDC             = NULL;\n\tqwglGetLayerPaletteEntries   = NULL;\n\tqwglGetProcAddress           = NULL;\n\tqwglMakeCurrent              = NULL;\n\tqwglRealizeLayerPalette      = NULL;\n\tqwglSetLayerPaletteEntries   = NULL;\n\tqwglShareLists               = NULL;\n\tqwglSwapLayerBuffers         = NULL;\n\tqwglUseFontBitmaps           = NULL;\n\tqwglUseFontOutlines          = NULL;\n\n\tqwglChoosePixelFormat        = NULL;\n\tqwglDescribePixelFormat      = NULL;\n\tqwglGetPixelFormat           = NULL;\n\tqwglSetPixelFormat           = NULL;\n\tqwglSwapBuffers              = NULL;\n\n\tqwglSwapIntervalEXT\t= NULL;\n\n\tqwglGetDeviceGammaRampEXT = NULL;\n\tqwglSetDeviceGammaRampEXT = NULL;\n\n  qgluPerspective = NULL;\n  qgluBuild2DMipmaps = NULL;\n\n  qgluLookAt = NULL;\n}\n\n#\tdefine GPA(h, a ) GetProcAddress( h, a )\n\n/*\n** QGL_Init\n**\n** This is responsible for binding our qgl function pointers to \n** the appropriate GL stuff.  In Windows this means doing a \n** LoadLibrary and a bunch of calls to GetProcAddress.  On other\n** operating systems we need to do the right thing, whatever that\n** might be.\n** \n*/\nint QGL_Init(const char *dllname, const char* pGluName )\n{\n\n  g_hGLDLL = LoadLibrary(dllname);\n  if (g_hGLDLL == NULL)\n  {\n    return 0;\n  }\n\n  g_hGLUDLL = LoadLibrary(pGluName);\n  if (g_hGLUDLL == NULL)\n  {\n    FreeLibrary(g_hGLDLL);\n    g_hGLDLL = NULL;\n    return 0;\n  }\n\n\n  qgluPerspective              = GPA(g_hGLUDLL, \"gluPerspective\");\n  qgluBuild2DMipmaps           = GPA(g_hGLUDLL, \"gluBuild2DMipmaps\");\n\t// added for plugins\n\tqgluLookAt                   = GPA(g_hGLUDLL, \"gluLookAt\" );\n\n\tqglAccum                     = GPA(g_hGLDLL, \"glAccum\" );\n\tqglAlphaFunc                 = GPA(g_hGLDLL, \"glAlphaFunc\" );\n\tqglAreTexturesResident       = GPA(g_hGLDLL, \"glAreTexturesResident\" );\n\tqglArrayElement              = GPA(g_hGLDLL, \"glArrayElement\" );\n\tqglBegin                     = GPA(g_hGLDLL, \"glBegin\" );\n\tqglBindTexture               = GPA(g_hGLDLL, \"glBindTexture\" );\n\tqglBitmap                    = GPA(g_hGLDLL, \"glBitmap\" );\n\tqglBlendFunc                 = GPA(g_hGLDLL, \"glBlendFunc\" );\n\tqglCallList                  = GPA(g_hGLDLL, \"glCallList\" );\n\tqglCallLists                 = GPA(g_hGLDLL, \"glCallLists\" );\n\tqglClear                     = GPA(g_hGLDLL, \"glClear\" );\n\tqglClearAccum                = GPA(g_hGLDLL, \"glClearAccum\" );\n\tqglClearColor                = GPA(g_hGLDLL, \"glClearColor\" );\n\tqglClearDepth                = GPA(g_hGLDLL, \"glClearDepth\" );\n\tqglClearIndex                = GPA(g_hGLDLL, \"glClearIndex\" );\n\tqglClearStencil              = GPA(g_hGLDLL, \"glClearStencil\" );\n\tqglClipPlane                 = GPA(g_hGLDLL, \"glClipPlane\" );\n\tqglColor3b                   = GPA(g_hGLDLL, \"glColor3b\" );\n\tqglColor3bv                  = GPA(g_hGLDLL, \"glColor3bv\" );\n\tqglColor3d                   = GPA(g_hGLDLL, \"glColor3d\" );\n\tqglColor3dv                  = GPA(g_hGLDLL, \"glColor3dv\" );\n\tqglColor3f                   = GPA(g_hGLDLL, \"glColor3f\" );\n\tqglColor3fv                  = GPA(g_hGLDLL, \"glColor3fv\" );\n\tqglColor3i                   = GPA(g_hGLDLL, \"glColor3i\" );\n\tqglColor3iv                  = GPA(g_hGLDLL, \"glColor3iv\" );\n\tqglColor3s                   = GPA(g_hGLDLL, \"glColor3s\" );\n\tqglColor3sv                  = GPA(g_hGLDLL, \"glColor3sv\" );\n\tqglColor3ub                  = GPA(g_hGLDLL, \"glColor3ub\" );\n\tqglColor3ubv                 = GPA(g_hGLDLL, \"glColor3ubv\" );\n\tqglColor3ui                  = GPA(g_hGLDLL, \"glColor3ui\" );\n\tqglColor3uiv                 = GPA(g_hGLDLL, \"glColor3uiv\" );\n\tqglColor3us                  = GPA(g_hGLDLL, \"glColor3us\" );\n\tqglColor3usv                 = GPA(g_hGLDLL, \"glColor3usv\" );\n\tqglColor4b                   = GPA(g_hGLDLL, \"glColor4b\" );\n\tqglColor4bv                  = GPA(g_hGLDLL, \"glColor4bv\" );\n\tqglColor4d                   = GPA(g_hGLDLL, \"glColor4d\" );\n\tqglColor4dv                  = GPA(g_hGLDLL, \"glColor4dv\" );\n\tqglColor4f                   = GPA(g_hGLDLL, \"glColor4f\" );\n\tqglColor4fv                  = GPA(g_hGLDLL, \"glColor4fv\" );\n\tqglColor4i                   = GPA(g_hGLDLL, \"glColor4i\" );\n\tqglColor4iv                  = GPA(g_hGLDLL, \"glColor4iv\" );\n\tqglColor4s                   = GPA(g_hGLDLL, \"glColor4s\" );\n\tqglColor4sv                  = GPA(g_hGLDLL, \"glColor4sv\" );\n\tqglColor4ub                  = GPA(g_hGLDLL, \"glColor4ub\" );\n\tqglColor4ubv                 = GPA(g_hGLDLL, \"glColor4ubv\" );\n\tqglColor4ui                  = GPA(g_hGLDLL, \"glColor4ui\" );\n\tqglColor4uiv                 = GPA(g_hGLDLL, \"glColor4uiv\" );\n\tqglColor4us                  = GPA(g_hGLDLL, \"glColor4us\" );\n\tqglColor4usv                 = GPA(g_hGLDLL, \"glColor4usv\" );\n\tqglColorMask                 = GPA(g_hGLDLL, \"glColorMask\" );\n\tqglColorMaterial             = GPA(g_hGLDLL, \"glColorMaterial\" );\n\tqglColorPointer              = GPA(g_hGLDLL, \"glColorPointer\" );\n\tqglCopyPixels                = GPA(g_hGLDLL, \"glCopyPixels\" );\n\tqglCopyTexImage1D            = GPA(g_hGLDLL, \"glCopyTexImage1D\" );\n\tqglCopyTexImage2D            = GPA(g_hGLDLL, \"glCopyTexImage2D\" );\n\tqglCopyTexSubImage1D         = GPA(g_hGLDLL, \"glCopyTexSubImage1D\" );\n\tqglCopyTexSubImage2D         = GPA(g_hGLDLL, \"glCopyTexSubImage2D\" );\n\tqglCullFace                  = GPA(g_hGLDLL, \"glCullFace\" );\n\tqglDeleteLists               = GPA(g_hGLDLL, \"glDeleteLists\" );\n\tqglDeleteTextures            = GPA(g_hGLDLL, \"glDeleteTextures\" );\n\tqglDepthFunc                 = GPA(g_hGLDLL, \"glDepthFunc\" );\n\tqglDepthMask                 = GPA(g_hGLDLL, \"glDepthMask\" );\n\tqglDepthRange                = GPA(g_hGLDLL, \"glDepthRange\" );\n\tqglDisable                   = GPA(g_hGLDLL, \"glDisable\" );\n\tqglDisableClientState        = GPA(g_hGLDLL, \"glDisableClientState\" );\n\tqglDrawArrays                = GPA(g_hGLDLL, \"glDrawArrays\" );\n\tqglDrawBuffer                = GPA(g_hGLDLL, \"glDrawBuffer\" );\n\tqglDrawElements              = GPA(g_hGLDLL, \"glDrawElements\" );\n\tqglDrawPixels                = GPA(g_hGLDLL, \"glDrawPixels\" );\n\tqglEdgeFlag                  = GPA(g_hGLDLL, \"glEdgeFlag\" );\n\tqglEdgeFlagPointer           = GPA(g_hGLDLL, \"glEdgeFlagPointer\" );\n\tqglEdgeFlagv                 = GPA(g_hGLDLL, \"glEdgeFlagv\" );\n\tqglEnable                    = GPA(g_hGLDLL, \"glEnable\" );\n\tqglEnableClientState         = GPA(g_hGLDLL, \"glEnableClientState\" );\n\tqglEnd                       = GPA(g_hGLDLL, \"glEnd\" );\n\tqglEndList                   = GPA(g_hGLDLL, \"glEndList\" );\n\tqglEvalCoord1d\t\t\t\t       = GPA(g_hGLDLL, \"glEvalCoord1d\" );\n\tqglEvalCoord1dv              = GPA(g_hGLDLL, \"glEvalCoord1dv\" );\n\tqglEvalCoord1f               = GPA(g_hGLDLL, \"glEvalCoord1f\" );\n\tqglEvalCoord1fv              = GPA(g_hGLDLL, \"glEvalCoord1fv\" );\n\tqglEvalCoord2d               = GPA(g_hGLDLL, \"glEvalCoord2d\" );\n\tqglEvalCoord2dv              = GPA(g_hGLDLL, \"glEvalCoord2dv\" );\n\tqglEvalCoord2f               = GPA(g_hGLDLL, \"glEvalCoord2f\" );\n\tqglEvalCoord2fv              = GPA(g_hGLDLL, \"glEvalCoord2fv\" );\n\tqglEvalMesh1                 = GPA(g_hGLDLL, \"glEvalMesh1\" );\n\tqglEvalMesh2                 = GPA(g_hGLDLL, \"glEvalMesh2\" );\n\tqglEvalPoint1                = GPA(g_hGLDLL, \"glEvalPoint1\" );\n\tqglEvalPoint2                = GPA(g_hGLDLL, \"glEvalPoint2\" );\n\tqglFeedbackBuffer            = GPA(g_hGLDLL, \"glFeedbackBuffer\" );\n\tqglFinish                    = GPA(g_hGLDLL, \"glFinish\" );\n\tqglFlush                     = GPA(g_hGLDLL, \"glFlush\" );\n\tqglFogf                      = GPA(g_hGLDLL, \"glFogf\" );\n\tqglFogfv                     = GPA(g_hGLDLL, \"glFogfv\" );\n\tqglFogi                      = GPA(g_hGLDLL, \"glFogi\" );\n\tqglFogiv                     = GPA(g_hGLDLL, \"glFogiv\" );\n\tqglFrontFace                 = GPA(g_hGLDLL, \"glFrontFace\" );\n\tqglFrustum                   = GPA(g_hGLDLL, \"glFrustum\" );\n\tqglGenLists                  = GPA(g_hGLDLL, \"glGenLists\" );\n\tqglGenTextures               = GPA(g_hGLDLL, \"glGenTextures\" );\n\tqglGetBooleanv               = GPA(g_hGLDLL, \"glGetBooleanv\" );\n\tqglGetClipPlane              = GPA(g_hGLDLL, \"glGetClipPlane\" );\n\tqglGetDoublev                = GPA(g_hGLDLL, \"glGetDoublev\" );\n\tqglGetError                  = GPA(g_hGLDLL, \"glGetError\" );\n\tqglGetFloatv                 = GPA(g_hGLDLL, \"glGetFloatv\" );\n\tqglGetIntegerv               = GPA(g_hGLDLL, \"glGetIntegerv\" );\n\tqglGetLightfv                = GPA(g_hGLDLL, \"glGetLightfv\" );\n\tqglGetLightiv                = GPA(g_hGLDLL, \"glGetLightiv\" );\n\tqglGetMapdv                  = GPA(g_hGLDLL, \"glGetMapdv\" );\n\tqglGetMapfv                  = GPA(g_hGLDLL, \"glGetMapfv\" );\n\tqglGetMapiv                  = GPA(g_hGLDLL, \"glGetMapiv\" );\n\tqglGetMaterialfv             = GPA(g_hGLDLL, \"glGetMaterialfv\" );\n\tqglGetMaterialiv             = GPA(g_hGLDLL, \"glGetMaterialiv\" );\n\tqglGetPixelMapfv             = GPA(g_hGLDLL, \"glGetPixelMapfv\" );\n\tqglGetPixelMapuiv            = GPA(g_hGLDLL, \"glGetPixelMapuiv\" );\n\tqglGetPixelMapusv            = GPA(g_hGLDLL, \"glGetPixelMapusv\" );\n\tqglGetPointerv               = GPA(g_hGLDLL, \"glGetPointerv\" );\n\tqglGetPolygonStipple         = GPA(g_hGLDLL, \"glGetPolygonStipple\" );\n\tqglGetString                 = GPA(g_hGLDLL, \"glGetString\" );\n\tqglGetTexEnvfv               = GPA(g_hGLDLL, \"glGetTexEnvfv\" );\n\tqglGetTexEnviv               = GPA(g_hGLDLL, \"glGetTexEnviv\" );\n\tqglGetTexGendv               = GPA(g_hGLDLL, \"glGetTexGendv\" );\n\tqglGetTexGenfv               = GPA(g_hGLDLL, \"glGetTexGenfv\" );\n\tqglGetTexGeniv               = GPA(g_hGLDLL, \"glGetTexGeniv\" );\n\tqglGetTexImage               = GPA(g_hGLDLL, \"glGetTexImage\" );\n\tqglGetTexLevelParameterfv    = GPA(g_hGLDLL, \"glGetLevelParameterfv\" );\n\tqglGetTexLevelParameteriv    = GPA(g_hGLDLL, \"glGetLevelParameteriv\" );\n\tqglGetTexParameterfv         = GPA(g_hGLDLL, \"glGetTexParameterfv\" );\n\tqglGetTexParameteriv         = GPA(g_hGLDLL, \"glGetTexParameteriv\" );\n\tqglHint                      = GPA(g_hGLDLL, \"glHint\" );\n\tqglIndexMask                 = GPA(g_hGLDLL, \"glIndexMask\" );\n\tqglIndexPointer              = GPA(g_hGLDLL, \"glIndexPointer\" );\n\tqglIndexd                    = GPA(g_hGLDLL, \"glIndexd\" );\n\tqglIndexdv                   = GPA(g_hGLDLL, \"glIndexdv\" );\n\tqglIndexf                    = GPA(g_hGLDLL, \"glIndexf\" );\n\tqglIndexfv                   = GPA(g_hGLDLL, \"glIndexfv\" );\n\tqglIndexi                    = GPA(g_hGLDLL, \"glIndexi\" );\n\tqglIndexiv                   = GPA(g_hGLDLL, \"glIndexiv\" );\n\tqglIndexs                    = GPA(g_hGLDLL, \"glIndexs\" );\n\tqglIndexsv                   = GPA(g_hGLDLL, \"glIndexsv\" );\n\tqglIndexub                   = GPA(g_hGLDLL, \"glIndexub\" );\n\tqglIndexubv                  = GPA(g_hGLDLL, \"glIndexubv\" );\n\tqglInitNames                 = GPA(g_hGLDLL, \"glInitNames\" );\n\tqglInterleavedArrays         = GPA(g_hGLDLL, \"glInterleavedArrays\" );\n\tqglIsEnabled                 = GPA(g_hGLDLL, \"glIsEnabled\" );\n\tqglIsList                    = GPA(g_hGLDLL, \"glIsList\" );\n\tqglIsTexture                 = GPA(g_hGLDLL, \"glIsTexture\" );\n\tqglLightModelf               = GPA(g_hGLDLL, \"glLightModelf\" );\n\tqglLightModelfv              = GPA(g_hGLDLL, \"glLightModelfv\" );\n\tqglLightModeli               = GPA(g_hGLDLL, \"glLightModeli\" );\n\tqglLightModeliv              = GPA(g_hGLDLL, \"glLightModeliv\" );\n\tqglLightf                    = GPA(g_hGLDLL, \"glLightf\" );\n\tqglLightfv                   = GPA(g_hGLDLL, \"glLightfv\" );\n\tqglLighti                    = GPA(g_hGLDLL, \"glLighti\" );\n\tqglLightiv                   = GPA(g_hGLDLL, \"glLightiv\" );\n\tqglLineStipple               = GPA(g_hGLDLL, \"glLineStipple\" );\n\tqglLineWidth                 = GPA(g_hGLDLL, \"glLineWidth\" );\n\tqglListBase                  = GPA(g_hGLDLL, \"glListBase\" );\n\tqglLoadIdentity              = GPA(g_hGLDLL, \"glLoadIdentity\" );\n\tqglLoadMatrixd               = GPA(g_hGLDLL, \"glLoadMatrixd\" );\n\tqglLoadMatrixf               = GPA(g_hGLDLL, \"glLoadMatrixf\" );\n\tqglLoadName                  = GPA(g_hGLDLL, \"glLoadName\" );\n\tqglLogicOp                   = GPA(g_hGLDLL, \"glLogicOp\" );\n\tqglMap1d                     = GPA(g_hGLDLL, \"glMap1d\" );\n\tqglMap1f                     = GPA(g_hGLDLL, \"glMap1f\" );\n\tqglMap2d                     = GPA(g_hGLDLL, \"glMap2d\" );\n\tqglMap2f                     = GPA(g_hGLDLL, \"glMap2f\" );\n\tqglMapGrid1d                 = GPA(g_hGLDLL, \"glMapGrid1d\" );\n\tqglMapGrid1f                 = GPA(g_hGLDLL, \"glMapGrid1f\" );\n\tqglMapGrid2d                 = GPA(g_hGLDLL, \"glMapGrid2d\" );\n\tqglMapGrid2f                 = GPA(g_hGLDLL, \"glMapGrid2f\" );\n\tqglMaterialf                 = GPA(g_hGLDLL, \"glMaterialf\" );\n\tqglMaterialfv                = GPA(g_hGLDLL, \"glMaterialfv\" );\n\tqglMateriali                 = GPA(g_hGLDLL, \"glMateriali\" );\n\tqglMaterialiv                = GPA(g_hGLDLL, \"glMaterialiv\" );\n\tqglMatrixMode                = GPA(g_hGLDLL, \"glMatrixMode\" );\n\tqglMultMatrixd               = GPA(g_hGLDLL, \"glMultMatrixd\" );\n\tqglMultMatrixf               = GPA(g_hGLDLL, \"glMultMatrixf\" );\n\tqglNewList                   = GPA(g_hGLDLL, \"glNewList\" );\n\tqglNormal3b                  = GPA(g_hGLDLL, \"glNormal3b\" );\n\tqglNormal3bv                 = GPA(g_hGLDLL, \"glNormal3bv\" );\n\tqglNormal3d                  = GPA(g_hGLDLL, \"glNormal3d\" );\n\tqglNormal3dv                 = GPA(g_hGLDLL, \"glNormal3dv\" );\n\tqglNormal3f                  = GPA(g_hGLDLL, \"glNormal3f\" );\n\tqglNormal3fv                 = GPA(g_hGLDLL, \"glNormal3fv\" );\n\tqglNormal3i                  = GPA(g_hGLDLL, \"glNormal3i\" );\n\tqglNormal3iv                 = GPA(g_hGLDLL, \"glNormal3iv\" );\n\tqglNormal3s                  = GPA(g_hGLDLL, \"glNormal3s\" );\n\tqglNormal3sv                 = GPA(g_hGLDLL, \"glNormal3sv\" );\n\tqglNormalPointer             = GPA(g_hGLDLL, \"glNormalPointer\" );\n\tqglOrtho                     = GPA(g_hGLDLL, \"glOrtho\" );\n\tqglPassThrough               = GPA(g_hGLDLL, \"glPassThrough\" );\n\tqglPixelMapfv                = GPA(g_hGLDLL, \"glPixelMapfv\" );\n\tqglPixelMapuiv               = GPA(g_hGLDLL, \"glPixelMapuiv\" );\n\tqglPixelMapusv               = GPA(g_hGLDLL, \"glPixelMapusv\" );\n\tqglPixelStoref               = GPA(g_hGLDLL, \"glPixelStoref\" );\n\tqglPixelStorei               = GPA(g_hGLDLL, \"glPixelStorei\" );\n\tqglPixelTransferf            = GPA(g_hGLDLL, \"glPixelTransferf\" );\n\tqglPixelTransferi            = GPA(g_hGLDLL, \"glPixelTransferi\" );\n\tqglPixelZoom                 = GPA(g_hGLDLL, \"glPixelZoom\" );\n\tqglPointSize                 = GPA(g_hGLDLL, \"glPointSize\" );\n\tqglPolygonMode               = GPA(g_hGLDLL, \"glPolygonMode\" );\n\tqglPolygonOffset             = GPA(g_hGLDLL, \"glPolygonOffset\" );\n\tqglPolygonStipple            = GPA(g_hGLDLL, \"glPolygonStipple\" );\n\tqglPopAttrib                 = GPA(g_hGLDLL, \"glPopAttrib\" );\n\tqglPopClientAttrib           = GPA(g_hGLDLL, \"glPopClientAttrib\" );\n\tqglPopMatrix                 = GPA(g_hGLDLL, \"glPopMatrix\" );\n\tqglPopName                   = GPA(g_hGLDLL, \"glPopName\" );\n\tqglPrioritizeTextures        = GPA(g_hGLDLL, \"glPrioritizeTextures\" );\n\tqglPushAttrib                = GPA(g_hGLDLL, \"glPushAttrib\" );\n\tqglPushClientAttrib          = GPA(g_hGLDLL, \"glPushClientAttrib\" );\n\tqglPushMatrix                = GPA(g_hGLDLL, \"glPushMatrix\" );\n\tqglPushName                  = GPA(g_hGLDLL, \"glPushName\" );\n\tqglRasterPos2d               = GPA(g_hGLDLL, \"glRasterPos2d\" );\n\tqglRasterPos2dv              = GPA(g_hGLDLL, \"glRasterPos2dv\" );\n\tqglRasterPos2f               = GPA(g_hGLDLL, \"glRasterPos2f\" );\n\tqglRasterPos2fv              = GPA(g_hGLDLL, \"glRasterPos2fv\" );\n\tqglRasterPos2i               = GPA(g_hGLDLL, \"glRasterPos2i\" );\n\tqglRasterPos2iv              = GPA(g_hGLDLL, \"glRasterPos2iv\" );\n\tqglRasterPos2s               = GPA(g_hGLDLL, \"glRasterPos2s\" );\n\tqglRasterPos2sv              = GPA(g_hGLDLL, \"glRasterPos2sv\" );\n\tqglRasterPos3d               = GPA(g_hGLDLL, \"glRasterPos3d\" );\n\tqglRasterPos3dv              = GPA(g_hGLDLL, \"glRasterPos3dv\" );\n\tqglRasterPos3f               = GPA(g_hGLDLL, \"glRasterPos3f\" );\n\tqglRasterPos3fv              = GPA(g_hGLDLL, \"glRasterPos3fv\" );\n\tqglRasterPos3i               = GPA(g_hGLDLL, \"glRasterPos3i\" );\n\tqglRasterPos3iv              = GPA(g_hGLDLL, \"glRasterPos3iv\" );\n\tqglRasterPos3s               = GPA(g_hGLDLL, \"glRasterPos3s\" );\n\tqglRasterPos3sv              = GPA(g_hGLDLL, \"glRasterPos3sv\" );\n\tqglRasterPos4d               = GPA(g_hGLDLL, \"glRasterPos4d\" );\n\tqglRasterPos4dv              = GPA(g_hGLDLL, \"glRasterPos4dv\" );\n\tqglRasterPos4f               = GPA(g_hGLDLL, \"glRasterPos4f\" );\n\tqglRasterPos4fv              = GPA(g_hGLDLL, \"glRasterPos4fv\" );\n\tqglRasterPos4i               = GPA(g_hGLDLL, \"glRasterPos4i\" );\n\tqglRasterPos4iv              = GPA(g_hGLDLL, \"glRasterPos4iv\" );\n\tqglRasterPos4s               = GPA(g_hGLDLL, \"glRasterPos4s\" );\n\tqglRasterPos4sv              = GPA(g_hGLDLL, \"glRasterPos4sv\" );\n\tqglReadBuffer                = GPA(g_hGLDLL, \"glReadBuffer\" );\n\tqglReadPixels                = GPA(g_hGLDLL, \"glReadPixels\" );\n\tqglRectd                     = GPA(g_hGLDLL, \"glRectd\" );\n\tqglRectdv                    = GPA(g_hGLDLL, \"glRectdv\" );\n\tqglRectf                     = GPA(g_hGLDLL, \"glRectf\" );\n\tqglRectfv                    = GPA(g_hGLDLL, \"glRectfv\" );\n\tqglRecti                     = GPA(g_hGLDLL, \"glRecti\" );\n\tqglRectiv                    = GPA(g_hGLDLL, \"glRectiv\" );\n\tqglRects                     = GPA(g_hGLDLL, \"glRects\" );\n\tqglRectsv                    = GPA(g_hGLDLL, \"glRectsv\" );\n\tqglRenderMode                = GPA(g_hGLDLL, \"glRenderMode\" );\n\tqglRotated                   = GPA(g_hGLDLL, \"glRotated\" );\n\tqglRotatef                   = GPA(g_hGLDLL, \"glRotatef\" );\n\tqglScaled                    = GPA(g_hGLDLL, \"glScaled\" );\n\tqglScalef                    = GPA(g_hGLDLL, \"glScalef\" );\n\tqglScissor                   = GPA(g_hGLDLL, \"glScissor\" );\n\tqglSelectBuffer              = GPA(g_hGLDLL, \"glSelectBuffer\" );\n\tqglShadeModel                = GPA(g_hGLDLL, \"glShadeModel\" );\n\tqglStencilFunc               = GPA(g_hGLDLL, \"glStencilFunc\" );\n\tqglStencilMask               = GPA(g_hGLDLL, \"glStencilMask\" );\n\tqglStencilOp                 = GPA(g_hGLDLL, \"glStencilOp\" );\n\tqglTexCoord1d                = GPA(g_hGLDLL, \"glTexCoord1d\" );\n\tqglTexCoord1dv               = GPA(g_hGLDLL, \"glTexCoord1dv\" );\n\tqglTexCoord1f                = GPA(g_hGLDLL, \"glTexCoord1f\" );\n\tqglTexCoord1fv               = GPA(g_hGLDLL, \"glTexCoord1fv\" );\n\tqglTexCoord1i                = GPA(g_hGLDLL, \"glTexCoord1i\" );\n\tqglTexCoord1iv               = GPA(g_hGLDLL, \"glTexCoord1iv\" );\n\tqglTexCoord1s                = GPA(g_hGLDLL, \"glTexCoord1s\" );\n\tqglTexCoord1sv               = GPA(g_hGLDLL, \"glTexCoord1sv\" );\n\tqglTexCoord2d                = GPA(g_hGLDLL, \"glTexCoord2d\" );\n\tqglTexCoord2dv               = GPA(g_hGLDLL, \"glTexCoord2dv\" );\n\tqglTexCoord2f                = GPA(g_hGLDLL, \"glTexCoord2f\" );\n\tqglTexCoord2fv               = GPA(g_hGLDLL, \"glTexCoord2fv\" );\n\tqglTexCoord2i                = GPA(g_hGLDLL, \"glTexCoord2i\" );\n\tqglTexCoord2iv               = GPA(g_hGLDLL, \"glTexCoord2iv\" );\n\tqglTexCoord2s                = GPA(g_hGLDLL, \"glTexCoord2s\" );\n\tqglTexCoord2sv               = GPA(g_hGLDLL, \"glTexCoord2sv\" );\n\tqglTexCoord3d                = GPA(g_hGLDLL, \"glTexCoord3d\" );\n\tqglTexCoord3dv               = GPA(g_hGLDLL, \"glTexCoord3dv\" );\n\tqglTexCoord3f                = GPA(g_hGLDLL, \"glTexCoord3f\" );\n\tqglTexCoord3fv               = GPA(g_hGLDLL, \"glTexCoord3fv\" );\n\tqglTexCoord3i                = GPA(g_hGLDLL, \"glTexCoord3i\" );\n\tqglTexCoord3iv               = GPA(g_hGLDLL, \"glTexCoord3iv\" );\n\tqglTexCoord3s                = GPA(g_hGLDLL, \"glTexCoord3s\" );\n\tqglTexCoord3sv               = GPA(g_hGLDLL, \"glTexCoord3sv\" );\n\tqglTexCoord4d                = GPA(g_hGLDLL, \"glTexCoord4d\" );\n\tqglTexCoord4dv               = GPA(g_hGLDLL, \"glTexCoord4dv\" );\n\tqglTexCoord4f                = GPA(g_hGLDLL, \"glTexCoord4f\" );\n\tqglTexCoord4fv               = GPA(g_hGLDLL, \"glTexCoord4fv\" );\n\tqglTexCoord4i                = GPA(g_hGLDLL, \"glTexCoord4i\" );\n\tqglTexCoord4iv               = GPA(g_hGLDLL, \"glTexCoord4iv\" );\n\tqglTexCoord4s                = GPA(g_hGLDLL, \"glTexCoord4s\" );\n\tqglTexCoord4sv               = GPA(g_hGLDLL, \"glTexCoord4sv\" );\n\tqglTexCoordPointer           = GPA(g_hGLDLL, \"glTexCoordPointer\" );\n\tqglTexEnvf                   = GPA(g_hGLDLL, \"glTexEnvf\" );\n\tqglTexEnvfv                  = GPA(g_hGLDLL, \"glTexEnvfv\" );\n\tqglTexEnvi                   = GPA(g_hGLDLL, \"glTexEnvi\" );\n\tqglTexEnviv                  = GPA(g_hGLDLL, \"glTexEnviv\" );\n\tqglTexGend                   = GPA(g_hGLDLL, \"glTexGend\" );\n\tqglTexGendv                  = GPA(g_hGLDLL, \"glTexGendv\" );\n\tqglTexGenf                   = GPA(g_hGLDLL, \"glTexGenf\" );\n\tqglTexGenfv                  = GPA(g_hGLDLL, \"glTexGenfv\" );\n\tqglTexGeni                   = GPA(g_hGLDLL, \"glTexGeni\" );\n\tqglTexGeniv                  = GPA(g_hGLDLL, \"glTexGeniv\" );\n\tqglTexImage1D                = GPA(g_hGLDLL, \"glTexImage1D\" );\n\tqglTexImage2D                = GPA(g_hGLDLL, \"glTexImage2D\" );\n\tqglTexParameterf             = GPA(g_hGLDLL, \"glTexParameterf\" );\n\tqglTexParameterfv            = GPA(g_hGLDLL, \"glTexParameterfv\" );\n\tqglTexParameteri             = GPA(g_hGLDLL, \"glTexParameteri\" );\n\tqglTexParameteriv            = GPA(g_hGLDLL, \"glTexParameteriv\" );\n\tqglTexSubImage1D             = GPA(g_hGLDLL, \"glTexSubImage1D\" );\n\tqglTexSubImage2D             = GPA(g_hGLDLL, \"glTexSubImage2D\" );\n\tqglTranslated                = GPA(g_hGLDLL, \"glTranslated\" );\n\tqglTranslatef                = GPA(g_hGLDLL, \"glTranslatef\" );\n\tqglVertex2d                  = GPA(g_hGLDLL, \"glVertex2d\" );\n\tqglVertex2dv                 = GPA(g_hGLDLL, \"glVertex2dv\" );\n\tqglVertex2f                  = GPA(g_hGLDLL, \"glVertex2f\" );\n\tqglVertex2fv                 = GPA(g_hGLDLL, \"glVertex2fv\" );\n\tqglVertex2i                  = GPA(g_hGLDLL, \"glVertex2i\" );\n\tqglVertex2iv                 = GPA(g_hGLDLL, \"glVertex2iv\" );\n\tqglVertex2s                  = GPA(g_hGLDLL, \"glVertex2s\" );\n\tqglVertex2sv                 = GPA(g_hGLDLL, \"glVertex2sv\" );\n\tqglVertex3d                  = GPA(g_hGLDLL, \"glVertex3d\" );\n\tqglVertex3dv                 = GPA(g_hGLDLL, \"glVertex3dv\" );\n\tqglVertex3f                  = GPA(g_hGLDLL, \"glVertex3f\" );\n\tqglVertex3fv                 = GPA(g_hGLDLL, \"glVertex3fv\" );\n\tqglVertex3i                  = GPA(g_hGLDLL, \"glVertex3i\" );\n\tqglVertex3iv                 = GPA(g_hGLDLL, \"glVertex3iv\" );\n\tqglVertex3s                  = GPA(g_hGLDLL, \"glVertex3s\" );\n\tqglVertex3sv                 = GPA(g_hGLDLL, \"glVertex3sv\" );\n\tqglVertex4d                  = GPA(g_hGLDLL, \"glVertex4d\" );\n\tqglVertex4dv                 = GPA(g_hGLDLL, \"glVertex4dv\" );\n\tqglVertex4f                  = GPA(g_hGLDLL, \"glVertex4f\" );\n\tqglVertex4fv                 = GPA(g_hGLDLL, \"glVertex4fv\" );\n\tqglVertex4i                  = GPA(g_hGLDLL, \"glVertex4i\" );\n\tqglVertex4iv                 = GPA(g_hGLDLL, \"glVertex4iv\" );\n\tqglVertex4s                  = GPA(g_hGLDLL, \"glVertex4s\" );\n\tqglVertex4sv                 = GPA(g_hGLDLL, \"glVertex4sv\" );\n\tqglVertexPointer             = GPA(g_hGLDLL, \"glVertexPointer\" );\n\tqglViewport                  = GPA(g_hGLDLL, \"glViewport\" );\n\n\tqwglCopyContext              = GPA(g_hGLDLL, \"wglCopyContext\" );\n\tqwglCreateContext            = GPA(g_hGLDLL, \"wglCreateContext\" );\n\tqwglCreateLayerContext       = GPA(g_hGLDLL, \"wglCreateLayerContext\" );\n\tqwglDeleteContext            = GPA(g_hGLDLL, \"wglDeleteContext\" );\n\tqwglDescribeLayerPlane       = GPA(g_hGLDLL, \"wglDescribeLayerPlane\" );\n\tqwglGetCurrentContext        = GPA(g_hGLDLL, \"wglGetCurrentContext\" );\n\tqwglGetCurrentDC             = GPA(g_hGLDLL, \"wglGetCurrentDC\" );\n\tqwglGetLayerPaletteEntries   = GPA(g_hGLDLL, \"wglGetLayerPaletteEntries\" );\n\tqwglGetProcAddress           = GPA(g_hGLDLL, \"wglGetProcAddress\" );\n\tqwglMakeCurrent              = GPA(g_hGLDLL, \"wglMakeCurrent\" );\n\tqwglRealizeLayerPalette      = GPA(g_hGLDLL, \"wglRealizeLayerPalette\" );\n\tqwglSetLayerPaletteEntries   = GPA(g_hGLDLL, \"wglSetLayerPaletteEntries\" );\n\tqwglShareLists               = GPA(g_hGLDLL, \"wglShareLists\" );\n\tqwglSwapLayerBuffers         = GPA(g_hGLDLL, \"wglSwapLayerBuffers\" );\n\tqwglUseFontBitmaps           = GPA(g_hGLDLL, \"wglUseFontBitmapsA\" );\n\tqwglUseFontOutlines          = GPA(g_hGLDLL, \"wglUseFontOutlinesA\" );\n\n\tqwglChoosePixelFormat        = GPA(g_hGLDLL, \"wglChoosePixelFormat\" );\n\tqwglDescribePixelFormat      = GPA(g_hGLDLL, \"wglDescribePixelFormat\" );\n\tqwglGetPixelFormat           = GPA(g_hGLDLL, \"wglGetPixelFormat\" );\n\tqwglSetPixelFormat           = GPA(g_hGLDLL, \"wglSetPixelFormat\" );\n\tqwglSwapBuffers              = GPA(g_hGLDLL, \"wglSwapBuffers\" );\n\n\tqwglSwapIntervalEXT = 0;\n\tqglPointParameterfEXT = 0;\n\tqglPointParameterfvEXT = 0;\n\tqglColorTableEXT = 0;\n\tqglSelectTextureSGIS = 0;\n\tqglMTexCoord2fSGIS = 0;\n\n\treturn 1;\n}\n\n#pragma warning (default : 4113 4133 4047 )\n\n\n\n"
  },
  {
    "path": "q3radiant/QGL_WIN.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n/*\n** QGL_WIN.C\n**\n** This file implements the operating system binding of GL to QGL function\n** pointers.  When doing a port of Quake2 you must implement the following\n** two functions:\n**\n** QGL_Init() - loads libraries, assigns function pointers, etc.\n** QGL_Shutdown() - unloads libraries, NULLs function pointers\n*/\n#include \"stdafx.h\"\n#include <float.h>\n\nHMODULE g_hGLDLL = NULL;\n\n#\tpragma warning (disable : 4113 4133 4047 )\n\nint   ( WINAPI * qwglChoosePixelFormat )(HDC, CONST PIXELFORMATDESCRIPTOR *);\nint   ( WINAPI * qwglDescribePixelFormat) (HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);\nint   ( WINAPI * qwglGetPixelFormat)(HDC);\nBOOL  ( WINAPI * qwglSetPixelFormat)(HDC, int, CONST PIXELFORMATDESCRIPTOR *);\nBOOL  ( WINAPI * qwglSwapBuffers)(HDC);\n\nBOOL  ( WINAPI * qwglCopyContext)(HGLRC, HGLRC, UINT);\nHGLRC ( WINAPI * qwglCreateContext)(HDC);\nHGLRC ( WINAPI * qwglCreateLayerContext)(HDC, int);\nBOOL  ( WINAPI * qwglDeleteContext)(HGLRC);\nHGLRC ( WINAPI * qwglGetCurrentContext)(VOID);\nHDC   ( WINAPI * qwglGetCurrentDC)(VOID);\nPROC  ( WINAPI * qwglGetProcAddress)(LPCSTR);\nBOOL  ( WINAPI * qwglMakeCurrent)(HDC, HGLRC);\nBOOL  ( WINAPI * qwglShareLists)(HGLRC, HGLRC);\nBOOL  ( WINAPI * qwglUseFontBitmaps)(HDC, DWORD, DWORD, DWORD);\n\nBOOL  ( WINAPI * qwglUseFontOutlines)(HDC, DWORD, DWORD, DWORD, FLOAT,\n                                           FLOAT, int, LPGLYPHMETRICSFLOAT);\n\nBOOL ( WINAPI * qwglDescribeLayerPlane)(HDC, int, int, UINT,\n                                            LPLAYERPLANEDESCRIPTOR);\nint  ( WINAPI * qwglSetLayerPaletteEntries)(HDC, int, int, int,\n                                                CONST COLORREF *);\nint  ( WINAPI * qwglGetLayerPaletteEntries)(HDC, int, int, int,\n                                                COLORREF *);\nBOOL ( WINAPI * qwglRealizeLayerPalette)(HDC, int, BOOL);\nBOOL ( WINAPI * qwglSwapLayerBuffers)(HDC, UINT);\n\nvoid ( APIENTRY * qglAccum )(GLenum op, GLfloat value);\nvoid ( APIENTRY * qglAlphaFunc )(GLenum func, GLclampf ref);\nGLboolean ( APIENTRY * qglAreTexturesResident )(GLsizei n, const GLuint *textures, GLboolean *residences);\nvoid ( APIENTRY * qglArrayElement )(GLint i);\nvoid ( APIENTRY * qglBegin )(GLenum mode);\nvoid ( APIENTRY * qglBindTexture )(GLenum target, GLuint texture);\nvoid ( APIENTRY * qglBitmap )(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);\nvoid ( APIENTRY * qglBlendFunc )(GLenum sfactor, GLenum dfactor);\nvoid ( APIENTRY * qglCallList )(GLuint list);\nvoid ( APIENTRY * qglCallLists )(GLsizei n, GLenum type, const GLvoid *lists);\nvoid ( APIENTRY * qglClear )(GLbitfield mask);\nvoid ( APIENTRY * qglClearAccum )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nvoid ( APIENTRY * qglClearColor )(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);\nvoid ( APIENTRY * qglClearDepth )(GLclampd depth);\nvoid ( APIENTRY * qglClearIndex )(GLfloat c);\nvoid ( APIENTRY * qglClearStencil )(GLint s);\nvoid ( APIENTRY * qglClipPlane )(GLenum plane, const GLdouble *equation);\nvoid ( APIENTRY * qglColor3b )(GLbyte red, GLbyte green, GLbyte blue);\nvoid ( APIENTRY * qglColor3bv )(const GLbyte *v);\nvoid ( APIENTRY * qglColor3d )(GLdouble red, GLdouble green, GLdouble blue);\nvoid ( APIENTRY * qglColor3dv )(const GLdouble *v);\nvoid ( APIENTRY * qglColor3f )(GLfloat red, GLfloat green, GLfloat blue);\nvoid ( APIENTRY * qglColor3fv )(const GLfloat *v);\nvoid ( APIENTRY * qglColor3i )(GLint red, GLint green, GLint blue);\nvoid ( APIENTRY * qglColor3iv )(const GLint *v);\nvoid ( APIENTRY * qglColor3s )(GLshort red, GLshort green, GLshort blue);\nvoid ( APIENTRY * qglColor3sv )(const GLshort *v);\nvoid ( APIENTRY * qglColor3ub )(GLubyte red, GLubyte green, GLubyte blue);\nvoid ( APIENTRY * qglColor3ubv )(const GLubyte *v);\nvoid ( APIENTRY * qglColor3ui )(GLuint red, GLuint green, GLuint blue);\nvoid ( APIENTRY * qglColor3uiv )(const GLuint *v);\nvoid ( APIENTRY * qglColor3us )(GLushort red, GLushort green, GLushort blue);\nvoid ( APIENTRY * qglColor3usv )(const GLushort *v);\nvoid ( APIENTRY * qglColor4b )(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha);\nvoid ( APIENTRY * qglColor4bv )(const GLbyte *v);\nvoid ( APIENTRY * qglColor4d )(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);\nvoid ( APIENTRY * qglColor4dv )(const GLdouble *v);\nvoid ( APIENTRY * qglColor4f )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nvoid ( APIENTRY * qglColor4fv )(const GLfloat *v);\nvoid ( APIENTRY * qglColor4i )(GLint red, GLint green, GLint blue, GLint alpha);\nvoid ( APIENTRY * qglColor4iv )(const GLint *v);\nvoid ( APIENTRY * qglColor4s )(GLshort red, GLshort green, GLshort blue, GLshort alpha);\nvoid ( APIENTRY * qglColor4sv )(const GLshort *v);\nvoid ( APIENTRY * qglColor4ub )(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);\nvoid ( APIENTRY * qglColor4ubv )(const GLubyte *v);\nvoid ( APIENTRY * qglColor4ui )(GLuint red, GLuint green, GLuint blue, GLuint alpha);\nvoid ( APIENTRY * qglColor4uiv )(const GLuint *v);\nvoid ( APIENTRY * qglColor4us )(GLushort red, GLushort green, GLushort blue, GLushort alpha);\nvoid ( APIENTRY * qglColor4usv )(const GLushort *v);\nvoid ( APIENTRY * qglColorMask )(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);\nvoid ( APIENTRY * qglColorMaterial )(GLenum face, GLenum mode);\nvoid ( APIENTRY * qglColorPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglCopyPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);\nvoid ( APIENTRY * qglCopyTexImage1D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border);\nvoid ( APIENTRY * qglCopyTexImage2D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\nvoid ( APIENTRY * qglCopyTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\nvoid ( APIENTRY * qglCopyTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nvoid ( APIENTRY * qglCullFace )(GLenum mode);\nvoid ( APIENTRY * qglDeleteLists )(GLuint list, GLsizei range);\nvoid ( APIENTRY * qglDeleteTextures )(GLsizei n, const GLuint *textures);\nvoid ( APIENTRY * qglDepthFunc )(GLenum func);\nvoid ( APIENTRY * qglDepthMask )(GLboolean flag);\nvoid ( APIENTRY * qglDepthRange )(GLclampd zNear, GLclampd zFar);\nvoid ( APIENTRY * qglDisable )(GLenum cap);\nvoid ( APIENTRY * qglDisableClientState )(GLenum array);\nvoid ( APIENTRY * qglDrawArrays )(GLenum mode, GLint first, GLsizei count);\nvoid ( APIENTRY * qglDrawBuffer )(GLenum mode);\nvoid ( APIENTRY * qglDrawElements )(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);\nvoid ( APIENTRY * qglDrawPixels )(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nvoid ( APIENTRY * qglEdgeFlag )(GLboolean flag);\nvoid ( APIENTRY * qglEdgeFlagPointer )(GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglEdgeFlagv )(const GLboolean *flag);\nvoid ( APIENTRY * qglEnable )(GLenum cap);\nvoid ( APIENTRY * qglEnableClientState )(GLenum array);\nvoid ( APIENTRY * qglEnd )(void);\nvoid ( APIENTRY * qglEndList )(void);\nvoid ( APIENTRY * qglEvalCoord1d )(GLdouble u);\nvoid ( APIENTRY * qglEvalCoord1dv )(const GLdouble *u);\nvoid ( APIENTRY * qglEvalCoord1f )(GLfloat u);\nvoid ( APIENTRY * qglEvalCoord1fv )(const GLfloat *u);\nvoid ( APIENTRY * qglEvalCoord2d )(GLdouble u, GLdouble v);\nvoid ( APIENTRY * qglEvalCoord2dv )(const GLdouble *u);\nvoid ( APIENTRY * qglEvalCoord2f )(GLfloat u, GLfloat v);\nvoid ( APIENTRY * qglEvalCoord2fv )(const GLfloat *u);\nvoid ( APIENTRY * qglEvalMesh1 )(GLenum mode, GLint i1, GLint i2);\nvoid ( APIENTRY * qglEvalMesh2 )(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);\nvoid ( APIENTRY * qglEvalPoint1 )(GLint i);\nvoid ( APIENTRY * qglEvalPoint2 )(GLint i, GLint j);\nvoid ( APIENTRY * qglFeedbackBuffer )(GLsizei size, GLenum type, GLfloat *buffer);\nvoid ( APIENTRY * qglFinish )(void);\nvoid ( APIENTRY * qglFlush )(void);\nvoid ( APIENTRY * qglFogf )(GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglFogfv )(GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglFogi )(GLenum pname, GLint param);\nvoid ( APIENTRY * qglFogiv )(GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglFrontFace )(GLenum mode);\nvoid ( APIENTRY * qglFrustum )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nGLuint ( APIENTRY * qglGenLists )(GLsizei range);\nvoid ( APIENTRY * qglGenTextures )(GLsizei n, GLuint *textures);\nvoid ( APIENTRY * qglGetBooleanv )(GLenum pname, GLboolean *params);\nvoid ( APIENTRY * qglGetClipPlane )(GLenum plane, GLdouble *equation);\nvoid ( APIENTRY * qglGetDoublev )(GLenum pname, GLdouble *params);\nGLenum ( APIENTRY * qglGetError )(void);\nvoid ( APIENTRY * qglGetFloatv )(GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetIntegerv )(GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetLightfv )(GLenum light, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetLightiv )(GLenum light, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetMapdv )(GLenum target, GLenum query, GLdouble *v);\nvoid ( APIENTRY * qglGetMapfv )(GLenum target, GLenum query, GLfloat *v);\nvoid ( APIENTRY * qglGetMapiv )(GLenum target, GLenum query, GLint *v);\nvoid ( APIENTRY * qglGetMaterialfv )(GLenum face, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetMaterialiv )(GLenum face, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetPixelMapfv )(GLenum map, GLfloat *values);\nvoid ( APIENTRY * qglGetPixelMapuiv )(GLenum map, GLuint *values);\nvoid ( APIENTRY * qglGetPixelMapusv )(GLenum map, GLushort *values);\nvoid ( APIENTRY * qglGetPointerv )(GLenum pname, GLvoid* *params);\nvoid ( APIENTRY * qglGetPolygonStipple )(GLubyte *mask);\nconst GLubyte * ( APIENTRY * qglGetString )(GLenum name);\nvoid ( APIENTRY * qglGetTexEnvfv )(GLenum target, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetTexEnviv )(GLenum target, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetTexGendv )(GLenum coord, GLenum pname, GLdouble *params);\nvoid ( APIENTRY * qglGetTexGenfv )(GLenum coord, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetTexGeniv )(GLenum coord, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetTexImage )(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);\nvoid ( APIENTRY * qglGetTexLevelParameterfv )(GLenum target, GLint level, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetTexLevelParameteriv )(GLenum target, GLint level, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglGetTexParameterfv )(GLenum target, GLenum pname, GLfloat *params);\nvoid ( APIENTRY * qglGetTexParameteriv )(GLenum target, GLenum pname, GLint *params);\nvoid ( APIENTRY * qglHint )(GLenum target, GLenum mode);\nvoid ( APIENTRY * qglIndexMask )(GLuint mask);\nvoid ( APIENTRY * qglIndexPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglIndexd )(GLdouble c);\nvoid ( APIENTRY * qglIndexdv )(const GLdouble *c);\nvoid ( APIENTRY * qglIndexf )(GLfloat c);\nvoid ( APIENTRY * qglIndexfv )(const GLfloat *c);\nvoid ( APIENTRY * qglIndexi )(GLint c);\nvoid ( APIENTRY * qglIndexiv )(const GLint *c);\nvoid ( APIENTRY * qglIndexs )(GLshort c);\nvoid ( APIENTRY * qglIndexsv )(const GLshort *c);\nvoid ( APIENTRY * qglIndexub )(GLubyte c);\nvoid ( APIENTRY * qglIndexubv )(const GLubyte *c);\nvoid ( APIENTRY * qglInitNames )(void);\nvoid ( APIENTRY * qglInterleavedArrays )(GLenum format, GLsizei stride, const GLvoid *pointer);\nGLboolean ( APIENTRY * qglIsEnabled )(GLenum cap);\nGLboolean ( APIENTRY * qglIsList )(GLuint list);\nGLboolean ( APIENTRY * qglIsTexture )(GLuint texture);\nvoid ( APIENTRY * qglLightModelf )(GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglLightModelfv )(GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglLightModeli )(GLenum pname, GLint param);\nvoid ( APIENTRY * qglLightModeliv )(GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglLightf )(GLenum light, GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglLightfv )(GLenum light, GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglLighti )(GLenum light, GLenum pname, GLint param);\nvoid ( APIENTRY * qglLightiv )(GLenum light, GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglLineStipple )(GLint factor, GLushort pattern);\nvoid ( APIENTRY * qglLineWidth )(GLfloat width);\nvoid ( APIENTRY * qglListBase )(GLuint base);\nvoid ( APIENTRY * qglLoadIdentity )(void);\nvoid ( APIENTRY * qglLoadMatrixd )(const GLdouble *m);\nvoid ( APIENTRY * qglLoadMatrixf )(const GLfloat *m);\nvoid ( APIENTRY * qglLoadName )(GLuint name);\nvoid ( APIENTRY * qglLogicOp )(GLenum opcode);\nvoid ( APIENTRY * qglMap1d )(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);\nvoid ( APIENTRY * qglMap1f )(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);\nvoid ( APIENTRY * qglMap2d )(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);\nvoid ( APIENTRY * qglMap2f )(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);\nvoid ( APIENTRY * qglMapGrid1d )(GLint un, GLdouble u1, GLdouble u2);\nvoid ( APIENTRY * qglMapGrid1f )(GLint un, GLfloat u1, GLfloat u2);\nvoid ( APIENTRY * qglMapGrid2d )(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);\nvoid ( APIENTRY * qglMapGrid2f )(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);\nvoid ( APIENTRY * qglMaterialf )(GLenum face, GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglMaterialfv )(GLenum face, GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglMateriali )(GLenum face, GLenum pname, GLint param);\nvoid ( APIENTRY * qglMaterialiv )(GLenum face, GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglMatrixMode )(GLenum mode);\nvoid ( APIENTRY * qglMultMatrixd )(const GLdouble *m);\nvoid ( APIENTRY * qglMultMatrixf )(const GLfloat *m);\nvoid ( APIENTRY * qglNewList )(GLuint list, GLenum mode);\nvoid ( APIENTRY * qglNormal3b )(GLbyte nx, GLbyte ny, GLbyte nz);\nvoid ( APIENTRY * qglNormal3bv )(const GLbyte *v);\nvoid ( APIENTRY * qglNormal3d )(GLdouble nx, GLdouble ny, GLdouble nz);\nvoid ( APIENTRY * qglNormal3dv )(const GLdouble *v);\nvoid ( APIENTRY * qglNormal3f )(GLfloat nx, GLfloat ny, GLfloat nz);\nvoid ( APIENTRY * qglNormal3fv )(const GLfloat *v);\nvoid ( APIENTRY * qglNormal3i )(GLint nx, GLint ny, GLint nz);\nvoid ( APIENTRY * qglNormal3iv )(const GLint *v);\nvoid ( APIENTRY * qglNormal3s )(GLshort nx, GLshort ny, GLshort nz);\nvoid ( APIENTRY * qglNormal3sv )(const GLshort *v);\nvoid ( APIENTRY * qglNormalPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglOrtho )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nvoid ( APIENTRY * qglPassThrough )(GLfloat token);\nvoid ( APIENTRY * qglPixelMapfv )(GLenum map, GLsizei mapsize, const GLfloat *values);\nvoid ( APIENTRY * qglPixelMapuiv )(GLenum map, GLsizei mapsize, const GLuint *values);\nvoid ( APIENTRY * qglPixelMapusv )(GLenum map, GLsizei mapsize, const GLushort *values);\nvoid ( APIENTRY * qglPixelStoref )(GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglPixelStorei )(GLenum pname, GLint param);\nvoid ( APIENTRY * qglPixelTransferf )(GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglPixelTransferi )(GLenum pname, GLint param);\nvoid ( APIENTRY * qglPixelZoom )(GLfloat xfactor, GLfloat yfactor);\nvoid ( APIENTRY * qglPointSize )(GLfloat size);\nvoid ( APIENTRY * qglPolygonMode )(GLenum face, GLenum mode);\nvoid ( APIENTRY * qglPolygonOffset )(GLfloat factor, GLfloat units);\nvoid ( APIENTRY * qglPolygonStipple )(const GLubyte *mask);\nvoid ( APIENTRY * qglPopAttrib )(void);\nvoid ( APIENTRY * qglPopClientAttrib )(void);\nvoid ( APIENTRY * qglPopMatrix )(void);\nvoid ( APIENTRY * qglPopName )(void);\nvoid ( APIENTRY * qglPrioritizeTextures )(GLsizei n, const GLuint *textures, const GLclampf *priorities);\nvoid ( APIENTRY * qglPushAttrib )(GLbitfield mask);\nvoid ( APIENTRY * qglPushClientAttrib )(GLbitfield mask);\nvoid ( APIENTRY * qglPushMatrix )(void);\nvoid ( APIENTRY * qglPushName )(GLuint name);\nvoid ( APIENTRY * qglRasterPos2d )(GLdouble x, GLdouble y);\nvoid ( APIENTRY * qglRasterPos2dv )(const GLdouble *v);\nvoid ( APIENTRY * qglRasterPos2f )(GLfloat x, GLfloat y);\nvoid ( APIENTRY * qglRasterPos2fv )(const GLfloat *v);\nvoid ( APIENTRY * qglRasterPos2i )(GLint x, GLint y);\nvoid ( APIENTRY * qglRasterPos2iv )(const GLint *v);\nvoid ( APIENTRY * qglRasterPos2s )(GLshort x, GLshort y);\nvoid ( APIENTRY * qglRasterPos2sv )(const GLshort *v);\nvoid ( APIENTRY * qglRasterPos3d )(GLdouble x, GLdouble y, GLdouble z);\nvoid ( APIENTRY * qglRasterPos3dv )(const GLdouble *v);\nvoid ( APIENTRY * qglRasterPos3f )(GLfloat x, GLfloat y, GLfloat z);\nvoid ( APIENTRY * qglRasterPos3fv )(const GLfloat *v);\nvoid ( APIENTRY * qglRasterPos3i )(GLint x, GLint y, GLint z);\nvoid ( APIENTRY * qglRasterPos3iv )(const GLint *v);\nvoid ( APIENTRY * qglRasterPos3s )(GLshort x, GLshort y, GLshort z);\nvoid ( APIENTRY * qglRasterPos3sv )(const GLshort *v);\nvoid ( APIENTRY * qglRasterPos4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nvoid ( APIENTRY * qglRasterPos4dv )(const GLdouble *v);\nvoid ( APIENTRY * qglRasterPos4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nvoid ( APIENTRY * qglRasterPos4fv )(const GLfloat *v);\nvoid ( APIENTRY * qglRasterPos4i )(GLint x, GLint y, GLint z, GLint w);\nvoid ( APIENTRY * qglRasterPos4iv )(const GLint *v);\nvoid ( APIENTRY * qglRasterPos4s )(GLshort x, GLshort y, GLshort z, GLshort w);\nvoid ( APIENTRY * qglRasterPos4sv )(const GLshort *v);\nvoid ( APIENTRY * qglReadBuffer )(GLenum mode);\nvoid ( APIENTRY * qglReadPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);\nvoid ( APIENTRY * qglRectd )(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);\nvoid ( APIENTRY * qglRectdv )(const GLdouble *v1, const GLdouble *v2);\nvoid ( APIENTRY * qglRectf )(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);\nvoid ( APIENTRY * qglRectfv )(const GLfloat *v1, const GLfloat *v2);\nvoid ( APIENTRY * qglRecti )(GLint x1, GLint y1, GLint x2, GLint y2);\nvoid ( APIENTRY * qglRectiv )(const GLint *v1, const GLint *v2);\nvoid ( APIENTRY * qglRects )(GLshort x1, GLshort y1, GLshort x2, GLshort y2);\nvoid ( APIENTRY * qglRectsv )(const GLshort *v1, const GLshort *v2);\nGLint ( APIENTRY * qglRenderMode )(GLenum mode);\nvoid ( APIENTRY * qglRotated )(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);\nvoid ( APIENTRY * qglRotatef )(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);\nvoid ( APIENTRY * qglScaled )(GLdouble x, GLdouble y, GLdouble z);\nvoid ( APIENTRY * qglScalef )(GLfloat x, GLfloat y, GLfloat z);\nvoid ( APIENTRY * qglScissor )(GLint x, GLint y, GLsizei width, GLsizei height);\nvoid ( APIENTRY * qglSelectBuffer )(GLsizei size, GLuint *buffer);\nvoid ( APIENTRY * qglShadeModel )(GLenum mode);\nvoid ( APIENTRY * qglStencilFunc )(GLenum func, GLint ref, GLuint mask);\nvoid ( APIENTRY * qglStencilMask )(GLuint mask);\nvoid ( APIENTRY * qglStencilOp )(GLenum fail, GLenum zfail, GLenum zpass);\nvoid ( APIENTRY * qglTexCoord1d )(GLdouble s);\nvoid ( APIENTRY * qglTexCoord1dv )(const GLdouble *v);\nvoid ( APIENTRY * qglTexCoord1f )(GLfloat s);\nvoid ( APIENTRY * qglTexCoord1fv )(const GLfloat *v);\nvoid ( APIENTRY * qglTexCoord1i )(GLint s);\nvoid ( APIENTRY * qglTexCoord1iv )(const GLint *v);\nvoid ( APIENTRY * qglTexCoord1s )(GLshort s);\nvoid ( APIENTRY * qglTexCoord1sv )(const GLshort *v);\nvoid ( APIENTRY * qglTexCoord2d )(GLdouble s, GLdouble t);\nvoid ( APIENTRY * qglTexCoord2dv )(const GLdouble *v);\nvoid ( APIENTRY * qglTexCoord2f )(GLfloat s, GLfloat t);\nvoid ( APIENTRY * qglTexCoord2fv )(const GLfloat *v);\nvoid ( APIENTRY * qglTexCoord2i )(GLint s, GLint t);\nvoid ( APIENTRY * qglTexCoord2iv )(const GLint *v);\nvoid ( APIENTRY * qglTexCoord2s )(GLshort s, GLshort t);\nvoid ( APIENTRY * qglTexCoord2sv )(const GLshort *v);\nvoid ( APIENTRY * qglTexCoord3d )(GLdouble s, GLdouble t, GLdouble r);\nvoid ( APIENTRY * qglTexCoord3dv )(const GLdouble *v);\nvoid ( APIENTRY * qglTexCoord3f )(GLfloat s, GLfloat t, GLfloat r);\nvoid ( APIENTRY * qglTexCoord3fv )(const GLfloat *v);\nvoid ( APIENTRY * qglTexCoord3i )(GLint s, GLint t, GLint r);\nvoid ( APIENTRY * qglTexCoord3iv )(const GLint *v);\nvoid ( APIENTRY * qglTexCoord3s )(GLshort s, GLshort t, GLshort r);\nvoid ( APIENTRY * qglTexCoord3sv )(const GLshort *v);\nvoid ( APIENTRY * qglTexCoord4d )(GLdouble s, GLdouble t, GLdouble r, GLdouble q);\nvoid ( APIENTRY * qglTexCoord4dv )(const GLdouble *v);\nvoid ( APIENTRY * qglTexCoord4f )(GLfloat s, GLfloat t, GLfloat r, GLfloat q);\nvoid ( APIENTRY * qglTexCoord4fv )(const GLfloat *v);\nvoid ( APIENTRY * qglTexCoord4i )(GLint s, GLint t, GLint r, GLint q);\nvoid ( APIENTRY * qglTexCoord4iv )(const GLint *v);\nvoid ( APIENTRY * qglTexCoord4s )(GLshort s, GLshort t, GLshort r, GLshort q);\nvoid ( APIENTRY * qglTexCoord4sv )(const GLshort *v);\nvoid ( APIENTRY * qglTexCoordPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglTexEnvf )(GLenum target, GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglTexEnvfv )(GLenum target, GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglTexEnvi )(GLenum target, GLenum pname, GLint param);\nvoid ( APIENTRY * qglTexEnviv )(GLenum target, GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglTexGend )(GLenum coord, GLenum pname, GLdouble param);\nvoid ( APIENTRY * qglTexGendv )(GLenum coord, GLenum pname, const GLdouble *params);\nvoid ( APIENTRY * qglTexGenf )(GLenum coord, GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglTexGenfv )(GLenum coord, GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglTexGeni )(GLenum coord, GLenum pname, GLint param);\nvoid ( APIENTRY * qglTexGeniv )(GLenum coord, GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglTexImage1D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nvoid ( APIENTRY * qglTexImage2D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nvoid ( APIENTRY * qglTexParameterf )(GLenum target, GLenum pname, GLfloat param);\nvoid ( APIENTRY * qglTexParameterfv )(GLenum target, GLenum pname, const GLfloat *params);\nvoid ( APIENTRY * qglTexParameteri )(GLenum target, GLenum pname, GLint param);\nvoid ( APIENTRY * qglTexParameteriv )(GLenum target, GLenum pname, const GLint *params);\nvoid ( APIENTRY * qglTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);\nvoid ( APIENTRY * qglTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nvoid ( APIENTRY * qglTranslated )(GLdouble x, GLdouble y, GLdouble z);\nvoid ( APIENTRY * qglTranslatef )(GLfloat x, GLfloat y, GLfloat z);\nvoid ( APIENTRY * qglVertex2d )(GLdouble x, GLdouble y);\nvoid ( APIENTRY * qglVertex2dv )(const GLdouble *v);\nvoid ( APIENTRY * qglVertex2f )(GLfloat x, GLfloat y);\nvoid ( APIENTRY * qglVertex2fv )(const GLfloat *v);\nvoid ( APIENTRY * qglVertex2i )(GLint x, GLint y);\nvoid ( APIENTRY * qglVertex2iv )(const GLint *v);\nvoid ( APIENTRY * qglVertex2s )(GLshort x, GLshort y);\nvoid ( APIENTRY * qglVertex2sv )(const GLshort *v);\nvoid ( APIENTRY * qglVertex3d )(GLdouble x, GLdouble y, GLdouble z);\nvoid ( APIENTRY * qglVertex3dv )(const GLdouble *v);\nvoid ( APIENTRY * qglVertex3f )(GLfloat x, GLfloat y, GLfloat z);\nvoid ( APIENTRY * qglVertex3fv )(const GLfloat *v);\nvoid ( APIENTRY * qglVertex3i )(GLint x, GLint y, GLint z);\nvoid ( APIENTRY * qglVertex3iv )(const GLint *v);\nvoid ( APIENTRY * qglVertex3s )(GLshort x, GLshort y, GLshort z);\nvoid ( APIENTRY * qglVertex3sv )(const GLshort *v);\nvoid ( APIENTRY * qglVertex4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nvoid ( APIENTRY * qglVertex4dv )(const GLdouble *v);\nvoid ( APIENTRY * qglVertex4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nvoid ( APIENTRY * qglVertex4fv )(const GLfloat *v);\nvoid ( APIENTRY * qglVertex4i )(GLint x, GLint y, GLint z, GLint w);\nvoid ( APIENTRY * qglVertex4iv )(const GLint *v);\nvoid ( APIENTRY * qglVertex4s )(GLshort x, GLshort y, GLshort z, GLshort w);\nvoid ( APIENTRY * qglVertex4sv )(const GLshort *v);\nvoid ( APIENTRY * qglVertexPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nvoid ( APIENTRY * qglViewport )(GLint x, GLint y, GLsizei width, GLsizei height);\n\nBOOL ( WINAPI * qwglSwapIntervalEXT)( int interval );\nBOOL ( WINAPI * qwglGetDeviceGammaRampEXT)( unsigned char *, unsigned char *, unsigned char * );\nBOOL ( WINAPI * qwglSetDeviceGammaRampEXT)( const unsigned char *, const unsigned char *, const unsigned char * );\nvoid ( APIENTRY * qglPointParameterfEXT)( GLenum param, GLfloat value );\nvoid ( APIENTRY * qglPointParameterfvEXT)( GLenum param, const GLfloat *value );\nvoid ( APIENTRY * qglColorTableEXT)( int, int, int, int, int, const void * );\nvoid ( APIENTRY * qglSelectTextureSGIS)( GLenum );\nvoid ( APIENTRY * qglMTexCoord2fSGIS)( GLenum, GLfloat, GLfloat );\n\nstatic void ( APIENTRY * dllAccum )(GLenum op, GLfloat value);\nstatic void ( APIENTRY * dllAlphaFunc )(GLenum func, GLclampf ref);\nGLboolean ( APIENTRY * dllAreTexturesResident )(GLsizei n, const GLuint *textures, GLboolean *residences);\nstatic void ( APIENTRY * dllArrayElement )(GLint i);\nstatic void ( APIENTRY * dllBegin )(GLenum mode);\nstatic void ( APIENTRY * dllBindTexture )(GLenum target, GLuint texture);\nstatic void ( APIENTRY * dllBitmap )(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);\nstatic void ( APIENTRY * dllBlendFunc )(GLenum sfactor, GLenum dfactor);\nstatic void ( APIENTRY * dllCallList )(GLuint list);\nstatic void ( APIENTRY * dllCallLists )(GLsizei n, GLenum type, const GLvoid *lists);\nstatic void ( APIENTRY * dllClear )(GLbitfield mask);\nstatic void ( APIENTRY * dllClearAccum )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nstatic void ( APIENTRY * dllClearColor )(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);\nstatic void ( APIENTRY * dllClearDepth )(GLclampd depth);\nstatic void ( APIENTRY * dllClearIndex )(GLfloat c);\nstatic void ( APIENTRY * dllClearStencil )(GLint s);\nstatic void ( APIENTRY * dllClipPlane )(GLenum plane, const GLdouble *equation);\nstatic void ( APIENTRY * dllColor3b )(GLbyte red, GLbyte green, GLbyte blue);\nstatic void ( APIENTRY * dllColor3bv )(const GLbyte *v);\nstatic void ( APIENTRY * dllColor3d )(GLdouble red, GLdouble green, GLdouble blue);\nstatic void ( APIENTRY * dllColor3dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllColor3f )(GLfloat red, GLfloat green, GLfloat blue);\nstatic void ( APIENTRY * dllColor3fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllColor3i )(GLint red, GLint green, GLint blue);\nstatic void ( APIENTRY * dllColor3iv )(const GLint *v);\nstatic void ( APIENTRY * dllColor3s )(GLshort red, GLshort green, GLshort blue);\nstatic void ( APIENTRY * dllColor3sv )(const GLshort *v);\nstatic void ( APIENTRY * dllColor3ub )(GLubyte red, GLubyte green, GLubyte blue);\nstatic void ( APIENTRY * dllColor3ubv )(const GLubyte *v);\nstatic void ( APIENTRY * dllColor3ui )(GLuint red, GLuint green, GLuint blue);\nstatic void ( APIENTRY * dllColor3uiv )(const GLuint *v);\nstatic void ( APIENTRY * dllColor3us )(GLushort red, GLushort green, GLushort blue);\nstatic void ( APIENTRY * dllColor3usv )(const GLushort *v);\nstatic void ( APIENTRY * dllColor4b )(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha);\nstatic void ( APIENTRY * dllColor4bv )(const GLbyte *v);\nstatic void ( APIENTRY * dllColor4d )(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);\nstatic void ( APIENTRY * dllColor4dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllColor4f )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nstatic void ( APIENTRY * dllColor4fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllColor4i )(GLint red, GLint green, GLint blue, GLint alpha);\nstatic void ( APIENTRY * dllColor4iv )(const GLint *v);\nstatic void ( APIENTRY * dllColor4s )(GLshort red, GLshort green, GLshort blue, GLshort alpha);\nstatic void ( APIENTRY * dllColor4sv )(const GLshort *v);\nstatic void ( APIENTRY * dllColor4ub )(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);\nstatic void ( APIENTRY * dllColor4ubv )(const GLubyte *v);\nstatic void ( APIENTRY * dllColor4ui )(GLuint red, GLuint green, GLuint blue, GLuint alpha);\nstatic void ( APIENTRY * dllColor4uiv )(const GLuint *v);\nstatic void ( APIENTRY * dllColor4us )(GLushort red, GLushort green, GLushort blue, GLushort alpha);\nstatic void ( APIENTRY * dllColor4usv )(const GLushort *v);\nstatic void ( APIENTRY * dllColorMask )(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);\nstatic void ( APIENTRY * dllColorMaterial )(GLenum face, GLenum mode);\nstatic void ( APIENTRY * dllColorPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nstatic void ( APIENTRY * dllCopyPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);\nstatic void ( APIENTRY * dllCopyTexImage1D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border);\nstatic void ( APIENTRY * dllCopyTexImage2D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\nstatic void ( APIENTRY * dllCopyTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\nstatic void ( APIENTRY * dllCopyTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nstatic void ( APIENTRY * dllCullFace )(GLenum mode);\nstatic void ( APIENTRY * dllDeleteLists )(GLuint list, GLsizei range);\nstatic void ( APIENTRY * dllDeleteTextures )(GLsizei n, const GLuint *textures);\nstatic void ( APIENTRY * dllDepthFunc )(GLenum func);\nstatic void ( APIENTRY * dllDepthMask )(GLboolean flag);\nstatic void ( APIENTRY * dllDepthRange )(GLclampd zNear, GLclampd zFar);\nstatic void ( APIENTRY * dllDisable )(GLenum cap);\nstatic void ( APIENTRY * dllDisableClientState )(GLenum array);\nstatic void ( APIENTRY * dllDrawArrays )(GLenum mode, GLint first, GLsizei count);\nstatic void ( APIENTRY * dllDrawBuffer )(GLenum mode);\nstatic void ( APIENTRY * dllDrawElements )(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);\nstatic void ( APIENTRY * dllDrawPixels )(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nstatic void ( APIENTRY * dllEdgeFlag )(GLboolean flag);\nstatic void ( APIENTRY * dllEdgeFlagPointer )(GLsizei stride, const GLvoid *pointer);\nstatic void ( APIENTRY * dllEdgeFlagv )(const GLboolean *flag);\nstatic void ( APIENTRY * dllEnable )(GLenum cap);\nstatic void ( APIENTRY * dllEnableClientState )(GLenum array);\nstatic void ( APIENTRY * dllEnd )(void);\nstatic void ( APIENTRY * dllEndList )(void);\nstatic void ( APIENTRY * dllEvalCoord1d )(GLdouble u);\nstatic void ( APIENTRY * dllEvalCoord1dv )(const GLdouble *u);\nstatic void ( APIENTRY * dllEvalCoord1f )(GLfloat u);\nstatic void ( APIENTRY * dllEvalCoord1fv )(const GLfloat *u);\nstatic void ( APIENTRY * dllEvalCoord2d )(GLdouble u, GLdouble v);\nstatic void ( APIENTRY * dllEvalCoord2dv )(const GLdouble *u);\nstatic void ( APIENTRY * dllEvalCoord2f )(GLfloat u, GLfloat v);\nstatic void ( APIENTRY * dllEvalCoord2fv )(const GLfloat *u);\nstatic void ( APIENTRY * dllEvalMesh1 )(GLenum mode, GLint i1, GLint i2);\nstatic void ( APIENTRY * dllEvalMesh2 )(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);\nstatic void ( APIENTRY * dllEvalPoint1 )(GLint i);\nstatic void ( APIENTRY * dllEvalPoint2 )(GLint i, GLint j);\nstatic void ( APIENTRY * dllFeedbackBuffer )(GLsizei size, GLenum type, GLfloat *buffer);\nstatic void ( APIENTRY * dllFinish )(void);\nstatic void ( APIENTRY * dllFlush )(void);\nstatic void ( APIENTRY * dllFogf )(GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllFogfv )(GLenum pname, const GLfloat *params);\nstatic void ( APIENTRY * dllFogi )(GLenum pname, GLint param);\nstatic void ( APIENTRY * dllFogiv )(GLenum pname, const GLint *params);\nstatic void ( APIENTRY * dllFrontFace )(GLenum mode);\nstatic void ( APIENTRY * dllFrustum )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nGLuint ( APIENTRY * dllGenLists )(GLsizei range);\nstatic void ( APIENTRY * dllGenTextures )(GLsizei n, GLuint *textures);\nstatic void ( APIENTRY * dllGetBooleanv )(GLenum pname, GLboolean *params);\nstatic void ( APIENTRY * dllGetClipPlane )(GLenum plane, GLdouble *equation);\nstatic void ( APIENTRY * dllGetDoublev )(GLenum pname, GLdouble *params);\nGLenum ( APIENTRY * dllGetError )(void);\nstatic void ( APIENTRY * dllGetFloatv )(GLenum pname, GLfloat *params);\nstatic void ( APIENTRY * dllGetIntegerv )(GLenum pname, GLint *params);\nstatic void ( APIENTRY * dllGetLightfv )(GLenum light, GLenum pname, GLfloat *params);\nstatic void ( APIENTRY * dllGetLightiv )(GLenum light, GLenum pname, GLint *params);\nstatic void ( APIENTRY * dllGetMapdv )(GLenum target, GLenum query, GLdouble *v);\nstatic void ( APIENTRY * dllGetMapfv )(GLenum target, GLenum query, GLfloat *v);\nstatic void ( APIENTRY * dllGetMapiv )(GLenum target, GLenum query, GLint *v);\nstatic void ( APIENTRY * dllGetMaterialfv )(GLenum face, GLenum pname, GLfloat *params);\nstatic void ( APIENTRY * dllGetMaterialiv )(GLenum face, GLenum pname, GLint *params);\nstatic void ( APIENTRY * dllGetPixelMapfv )(GLenum map, GLfloat *values);\nstatic void ( APIENTRY * dllGetPixelMapuiv )(GLenum map, GLuint *values);\nstatic void ( APIENTRY * dllGetPixelMapusv )(GLenum map, GLushort *values);\nstatic void ( APIENTRY * dllGetPointerv )(GLenum pname, GLvoid* *params);\nstatic void ( APIENTRY * dllGetPolygonStipple )(GLubyte *mask);\nconst GLubyte * ( APIENTRY * dllGetString )(GLenum name);\nstatic void ( APIENTRY * dllGetTexEnvfv )(GLenum target, GLenum pname, GLfloat *params);\nstatic void ( APIENTRY * dllGetTexEnviv )(GLenum target, GLenum pname, GLint *params);\nstatic void ( APIENTRY * dllGetTexGendv )(GLenum coord, GLenum pname, GLdouble *params);\nstatic void ( APIENTRY * dllGetTexGenfv )(GLenum coord, GLenum pname, GLfloat *params);\nstatic void ( APIENTRY * dllGetTexGeniv )(GLenum coord, GLenum pname, GLint *params);\nstatic void ( APIENTRY * dllGetTexImage )(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);\nstatic void ( APIENTRY * dllGetTexLevelParameterfv )(GLenum target, GLint level, GLenum pname, GLfloat *params);\nstatic void ( APIENTRY * dllGetTexLevelParameteriv )(GLenum target, GLint level, GLenum pname, GLint *params);\nstatic void ( APIENTRY * dllGetTexParameterfv )(GLenum target, GLenum pname, GLfloat *params);\nstatic void ( APIENTRY * dllGetTexParameteriv )(GLenum target, GLenum pname, GLint *params);\nstatic void ( APIENTRY * dllHint )(GLenum target, GLenum mode);\nstatic void ( APIENTRY * dllIndexMask )(GLuint mask);\nstatic void ( APIENTRY * dllIndexPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);\nstatic void ( APIENTRY * dllIndexd )(GLdouble c);\nstatic void ( APIENTRY * dllIndexdv )(const GLdouble *c);\nstatic void ( APIENTRY * dllIndexf )(GLfloat c);\nstatic void ( APIENTRY * dllIndexfv )(const GLfloat *c);\nstatic void ( APIENTRY * dllIndexi )(GLint c);\nstatic void ( APIENTRY * dllIndexiv )(const GLint *c);\nstatic void ( APIENTRY * dllIndexs )(GLshort c);\nstatic void ( APIENTRY * dllIndexsv )(const GLshort *c);\nstatic void ( APIENTRY * dllIndexub )(GLubyte c);\nstatic void ( APIENTRY * dllIndexubv )(const GLubyte *c);\nstatic void ( APIENTRY * dllInitNames )(void);\nstatic void ( APIENTRY * dllInterleavedArrays )(GLenum format, GLsizei stride, const GLvoid *pointer);\nGLboolean ( APIENTRY * dllIsEnabled )(GLenum cap);\nGLboolean ( APIENTRY * dllIsList )(GLuint list);\nGLboolean ( APIENTRY * dllIsTexture )(GLuint texture);\nstatic void ( APIENTRY * dllLightModelf )(GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllLightModelfv )(GLenum pname, const GLfloat *params);\nstatic void ( APIENTRY * dllLightModeli )(GLenum pname, GLint param);\nstatic void ( APIENTRY * dllLightModeliv )(GLenum pname, const GLint *params);\nstatic void ( APIENTRY * dllLightf )(GLenum light, GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllLightfv )(GLenum light, GLenum pname, const GLfloat *params);\nstatic void ( APIENTRY * dllLighti )(GLenum light, GLenum pname, GLint param);\nstatic void ( APIENTRY * dllLightiv )(GLenum light, GLenum pname, const GLint *params);\nstatic void ( APIENTRY * dllLineStipple )(GLint factor, GLushort pattern);\nstatic void ( APIENTRY * dllLineWidth )(GLfloat width);\nstatic void ( APIENTRY * dllListBase )(GLuint base);\nstatic void ( APIENTRY * dllLoadIdentity )(void);\nstatic void ( APIENTRY * dllLoadMatrixd )(const GLdouble *m);\nstatic void ( APIENTRY * dllLoadMatrixf )(const GLfloat *m);\nstatic void ( APIENTRY * dllLoadName )(GLuint name);\nstatic void ( APIENTRY * dllLogicOp )(GLenum opcode);\nstatic void ( APIENTRY * dllMap1d )(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);\nstatic void ( APIENTRY * dllMap1f )(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);\nstatic void ( APIENTRY * dllMap2d )(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);\nstatic void ( APIENTRY * dllMap2f )(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);\nstatic void ( APIENTRY * dllMapGrid1d )(GLint un, GLdouble u1, GLdouble u2);\nstatic void ( APIENTRY * dllMapGrid1f )(GLint un, GLfloat u1, GLfloat u2);\nstatic void ( APIENTRY * dllMapGrid2d )(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);\nstatic void ( APIENTRY * dllMapGrid2f )(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);\nstatic void ( APIENTRY * dllMaterialf )(GLenum face, GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllMaterialfv )(GLenum face, GLenum pname, const GLfloat *params);\nstatic void ( APIENTRY * dllMateriali )(GLenum face, GLenum pname, GLint param);\nstatic void ( APIENTRY * dllMaterialiv )(GLenum face, GLenum pname, const GLint *params);\nstatic void ( APIENTRY * dllMatrixMode )(GLenum mode);\nstatic void ( APIENTRY * dllMultMatrixd )(const GLdouble *m);\nstatic void ( APIENTRY * dllMultMatrixf )(const GLfloat *m);\nstatic void ( APIENTRY * dllNewList )(GLuint list, GLenum mode);\nstatic void ( APIENTRY * dllNormal3b )(GLbyte nx, GLbyte ny, GLbyte nz);\nstatic void ( APIENTRY * dllNormal3bv )(const GLbyte *v);\nstatic void ( APIENTRY * dllNormal3d )(GLdouble nx, GLdouble ny, GLdouble nz);\nstatic void ( APIENTRY * dllNormal3dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllNormal3f )(GLfloat nx, GLfloat ny, GLfloat nz);\nstatic void ( APIENTRY * dllNormal3fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllNormal3i )(GLint nx, GLint ny, GLint nz);\nstatic void ( APIENTRY * dllNormal3iv )(const GLint *v);\nstatic void ( APIENTRY * dllNormal3s )(GLshort nx, GLshort ny, GLshort nz);\nstatic void ( APIENTRY * dllNormal3sv )(const GLshort *v);\nstatic void ( APIENTRY * dllNormalPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);\nstatic void ( APIENTRY * dllOrtho )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nstatic void ( APIENTRY * dllPassThrough )(GLfloat token);\nstatic void ( APIENTRY * dllPixelMapfv )(GLenum map, GLsizei mapsize, const GLfloat *values);\nstatic void ( APIENTRY * dllPixelMapuiv )(GLenum map, GLsizei mapsize, const GLuint *values);\nstatic void ( APIENTRY * dllPixelMapusv )(GLenum map, GLsizei mapsize, const GLushort *values);\nstatic void ( APIENTRY * dllPixelStoref )(GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllPixelStorei )(GLenum pname, GLint param);\nstatic void ( APIENTRY * dllPixelTransferf )(GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllPixelTransferi )(GLenum pname, GLint param);\nstatic void ( APIENTRY * dllPixelZoom )(GLfloat xfactor, GLfloat yfactor);\nstatic void ( APIENTRY * dllPointSize )(GLfloat size);\nstatic void ( APIENTRY * dllPolygonMode )(GLenum face, GLenum mode);\nstatic void ( APIENTRY * dllPolygonOffset )(GLfloat factor, GLfloat units);\nstatic void ( APIENTRY * dllPolygonStipple )(const GLubyte *mask);\nstatic void ( APIENTRY * dllPopAttrib )(void);\nstatic void ( APIENTRY * dllPopClientAttrib )(void);\nstatic void ( APIENTRY * dllPopMatrix )(void);\nstatic void ( APIENTRY * dllPopName )(void);\nstatic void ( APIENTRY * dllPrioritizeTextures )(GLsizei n, const GLuint *textures, const GLclampf *priorities);\nstatic void ( APIENTRY * dllPushAttrib )(GLbitfield mask);\nstatic void ( APIENTRY * dllPushClientAttrib )(GLbitfield mask);\nstatic void ( APIENTRY * dllPushMatrix )(void);\nstatic void ( APIENTRY * dllPushName )(GLuint name);\nstatic void ( APIENTRY * dllRasterPos2d )(GLdouble x, GLdouble y);\nstatic void ( APIENTRY * dllRasterPos2dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllRasterPos2f )(GLfloat x, GLfloat y);\nstatic void ( APIENTRY * dllRasterPos2fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllRasterPos2i )(GLint x, GLint y);\nstatic void ( APIENTRY * dllRasterPos2iv )(const GLint *v);\nstatic void ( APIENTRY * dllRasterPos2s )(GLshort x, GLshort y);\nstatic void ( APIENTRY * dllRasterPos2sv )(const GLshort *v);\nstatic void ( APIENTRY * dllRasterPos3d )(GLdouble x, GLdouble y, GLdouble z);\nstatic void ( APIENTRY * dllRasterPos3dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllRasterPos3f )(GLfloat x, GLfloat y, GLfloat z);\nstatic void ( APIENTRY * dllRasterPos3fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllRasterPos3i )(GLint x, GLint y, GLint z);\nstatic void ( APIENTRY * dllRasterPos3iv )(const GLint *v);\nstatic void ( APIENTRY * dllRasterPos3s )(GLshort x, GLshort y, GLshort z);\nstatic void ( APIENTRY * dllRasterPos3sv )(const GLshort *v);\nstatic void ( APIENTRY * dllRasterPos4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nstatic void ( APIENTRY * dllRasterPos4dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllRasterPos4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nstatic void ( APIENTRY * dllRasterPos4fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllRasterPos4i )(GLint x, GLint y, GLint z, GLint w);\nstatic void ( APIENTRY * dllRasterPos4iv )(const GLint *v);\nstatic void ( APIENTRY * dllRasterPos4s )(GLshort x, GLshort y, GLshort z, GLshort w);\nstatic void ( APIENTRY * dllRasterPos4sv )(const GLshort *v);\nstatic void ( APIENTRY * dllReadBuffer )(GLenum mode);\nstatic void ( APIENTRY * dllReadPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);\nstatic void ( APIENTRY * dllRectd )(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);\nstatic void ( APIENTRY * dllRectdv )(const GLdouble *v1, const GLdouble *v2);\nstatic void ( APIENTRY * dllRectf )(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);\nstatic void ( APIENTRY * dllRectfv )(const GLfloat *v1, const GLfloat *v2);\nstatic void ( APIENTRY * dllRecti )(GLint x1, GLint y1, GLint x2, GLint y2);\nstatic void ( APIENTRY * dllRectiv )(const GLint *v1, const GLint *v2);\nstatic void ( APIENTRY * dllRects )(GLshort x1, GLshort y1, GLshort x2, GLshort y2);\nstatic void ( APIENTRY * dllRectsv )(const GLshort *v1, const GLshort *v2);\nGLint ( APIENTRY * dllRenderMode )(GLenum mode);\nstatic void ( APIENTRY * dllRotated )(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);\nstatic void ( APIENTRY * dllRotatef )(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);\nstatic void ( APIENTRY * dllScaled )(GLdouble x, GLdouble y, GLdouble z);\nstatic void ( APIENTRY * dllScalef )(GLfloat x, GLfloat y, GLfloat z);\nstatic void ( APIENTRY * dllScissor )(GLint x, GLint y, GLsizei width, GLsizei height);\nstatic void ( APIENTRY * dllSelectBuffer )(GLsizei size, GLuint *buffer);\nstatic void ( APIENTRY * dllShadeModel )(GLenum mode);\nstatic void ( APIENTRY * dllStencilFunc )(GLenum func, GLint ref, GLuint mask);\nstatic void ( APIENTRY * dllStencilMask )(GLuint mask);\nstatic void ( APIENTRY * dllStencilOp )(GLenum fail, GLenum zfail, GLenum zpass);\nstatic void ( APIENTRY * dllTexCoord1d )(GLdouble s);\nstatic void ( APIENTRY * dllTexCoord1dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllTexCoord1f )(GLfloat s);\nstatic void ( APIENTRY * dllTexCoord1fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllTexCoord1i )(GLint s);\nstatic void ( APIENTRY * dllTexCoord1iv )(const GLint *v);\nstatic void ( APIENTRY * dllTexCoord1s )(GLshort s);\nstatic void ( APIENTRY * dllTexCoord1sv )(const GLshort *v);\nstatic void ( APIENTRY * dllTexCoord2d )(GLdouble s, GLdouble t);\nstatic void ( APIENTRY * dllTexCoord2dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllTexCoord2f )(GLfloat s, GLfloat t);\nstatic void ( APIENTRY * dllTexCoord2fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllTexCoord2i )(GLint s, GLint t);\nstatic void ( APIENTRY * dllTexCoord2iv )(const GLint *v);\nstatic void ( APIENTRY * dllTexCoord2s )(GLshort s, GLshort t);\nstatic void ( APIENTRY * dllTexCoord2sv )(const GLshort *v);\nstatic void ( APIENTRY * dllTexCoord3d )(GLdouble s, GLdouble t, GLdouble r);\nstatic void ( APIENTRY * dllTexCoord3dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllTexCoord3f )(GLfloat s, GLfloat t, GLfloat r);\nstatic void ( APIENTRY * dllTexCoord3fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllTexCoord3i )(GLint s, GLint t, GLint r);\nstatic void ( APIENTRY * dllTexCoord3iv )(const GLint *v);\nstatic void ( APIENTRY * dllTexCoord3s )(GLshort s, GLshort t, GLshort r);\nstatic void ( APIENTRY * dllTexCoord3sv )(const GLshort *v);\nstatic void ( APIENTRY * dllTexCoord4d )(GLdouble s, GLdouble t, GLdouble r, GLdouble q);\nstatic void ( APIENTRY * dllTexCoord4dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllTexCoord4f )(GLfloat s, GLfloat t, GLfloat r, GLfloat q);\nstatic void ( APIENTRY * dllTexCoord4fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllTexCoord4i )(GLint s, GLint t, GLint r, GLint q);\nstatic void ( APIENTRY * dllTexCoord4iv )(const GLint *v);\nstatic void ( APIENTRY * dllTexCoord4s )(GLshort s, GLshort t, GLshort r, GLshort q);\nstatic void ( APIENTRY * dllTexCoord4sv )(const GLshort *v);\nstatic void ( APIENTRY * dllTexCoordPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nstatic void ( APIENTRY * dllTexEnvf )(GLenum target, GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllTexEnvfv )(GLenum target, GLenum pname, const GLfloat *params);\nstatic void ( APIENTRY * dllTexEnvi )(GLenum target, GLenum pname, GLint param);\nstatic void ( APIENTRY * dllTexEnviv )(GLenum target, GLenum pname, const GLint *params);\nstatic void ( APIENTRY * dllTexGend )(GLenum coord, GLenum pname, GLdouble param);\nstatic void ( APIENTRY * dllTexGendv )(GLenum coord, GLenum pname, const GLdouble *params);\nstatic void ( APIENTRY * dllTexGenf )(GLenum coord, GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllTexGenfv )(GLenum coord, GLenum pname, const GLfloat *params);\nstatic void ( APIENTRY * dllTexGeni )(GLenum coord, GLenum pname, GLint param);\nstatic void ( APIENTRY * dllTexGeniv )(GLenum coord, GLenum pname, const GLint *params);\nstatic void ( APIENTRY * dllTexImage1D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nstatic void ( APIENTRY * dllTexImage2D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nstatic void ( APIENTRY * dllTexParameterf )(GLenum target, GLenum pname, GLfloat param);\nstatic void ( APIENTRY * dllTexParameterfv )(GLenum target, GLenum pname, const GLfloat *params);\nstatic void ( APIENTRY * dllTexParameteri )(GLenum target, GLenum pname, GLint param);\nstatic void ( APIENTRY * dllTexParameteriv )(GLenum target, GLenum pname, const GLint *params);\nstatic void ( APIENTRY * dllTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);\nstatic void ( APIENTRY * dllTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nstatic void ( APIENTRY * dllTranslated )(GLdouble x, GLdouble y, GLdouble z);\nstatic void ( APIENTRY * dllTranslatef )(GLfloat x, GLfloat y, GLfloat z);\nstatic void ( APIENTRY * dllVertex2d )(GLdouble x, GLdouble y);\nstatic void ( APIENTRY * dllVertex2dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllVertex2f )(GLfloat x, GLfloat y);\nstatic void ( APIENTRY * dllVertex2fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllVertex2i )(GLint x, GLint y);\nstatic void ( APIENTRY * dllVertex2iv )(const GLint *v);\nstatic void ( APIENTRY * dllVertex2s )(GLshort x, GLshort y);\nstatic void ( APIENTRY * dllVertex2sv )(const GLshort *v);\nstatic void ( APIENTRY * dllVertex3d )(GLdouble x, GLdouble y, GLdouble z);\nstatic void ( APIENTRY * dllVertex3dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllVertex3f )(GLfloat x, GLfloat y, GLfloat z);\nstatic void ( APIENTRY * dllVertex3fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllVertex3i )(GLint x, GLint y, GLint z);\nstatic void ( APIENTRY * dllVertex3iv )(const GLint *v);\nstatic void ( APIENTRY * dllVertex3s )(GLshort x, GLshort y, GLshort z);\nstatic void ( APIENTRY * dllVertex3sv )(const GLshort *v);\nstatic void ( APIENTRY * dllVertex4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nstatic void ( APIENTRY * dllVertex4dv )(const GLdouble *v);\nstatic void ( APIENTRY * dllVertex4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nstatic void ( APIENTRY * dllVertex4fv )(const GLfloat *v);\nstatic void ( APIENTRY * dllVertex4i )(GLint x, GLint y, GLint z, GLint w);\nstatic void ( APIENTRY * dllVertex4iv )(const GLint *v);\nstatic void ( APIENTRY * dllVertex4s )(GLshort x, GLshort y, GLshort z, GLshort w);\nstatic void ( APIENTRY * dllVertex4sv )(const GLshort *v);\nstatic void ( APIENTRY * dllVertexPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nstatic void ( APIENTRY * dllViewport )(GLint x, GLint y, GLsizei width, GLsizei height);\n\n/*\n** QGL_Shutdown\n**\n** Unloads the specified DLL then nulls out all the proc pointers.\n*/\nvoid QGL_Shutdown( void )\n{\n\tif (g_hGLDLL)\n\t{\n    ::FreeLibrary(g_hGLDLL);\n    g_hGLDLL = NULL;\n\t}\n\n\tqglAccum                     = NULL;\n\tqglAlphaFunc                 = NULL;\n\tqglAreTexturesResident       = NULL;\n\tqglArrayElement              = NULL;\n\tqglBegin                     = NULL;\n\tqglBindTexture               = NULL;\n\tqglBitmap                    = NULL;\n\tqglBlendFunc                 = NULL;\n\tqglCallList                  = NULL;\n\tqglCallLists                 = NULL;\n\tqglClear                     = NULL;\n\tqglClearAccum                = NULL;\n\tqglClearColor                = NULL;\n\tqglClearDepth                = NULL;\n\tqglClearIndex                = NULL;\n\tqglClearStencil              = NULL;\n\tqglClipPlane                 = NULL;\n\tqglColor3b                   = NULL;\n\tqglColor3bv                  = NULL;\n\tqglColor3d                   = NULL;\n\tqglColor3dv                  = NULL;\n\tqglColor3f                   = NULL;\n\tqglColor3fv                  = NULL;\n\tqglColor3i                   = NULL;\n\tqglColor3iv                  = NULL;\n\tqglColor3s                   = NULL;\n\tqglColor3sv                  = NULL;\n\tqglColor3ub                  = NULL;\n\tqglColor3ubv                 = NULL;\n\tqglColor3ui                  = NULL;\n\tqglColor3uiv                 = NULL;\n\tqglColor3us                  = NULL;\n\tqglColor3usv                 = NULL;\n\tqglColor4b                   = NULL;\n\tqglColor4bv                  = NULL;\n\tqglColor4d                   = NULL;\n\tqglColor4dv                  = NULL;\n\tqglColor4f                   = NULL;\n\tqglColor4fv                  = NULL;\n\tqglColor4i                   = NULL;\n\tqglColor4iv                  = NULL;\n\tqglColor4s                   = NULL;\n\tqglColor4sv                  = NULL;\n\tqglColor4ub                  = NULL;\n\tqglColor4ubv                 = NULL;\n\tqglColor4ui                  = NULL;\n\tqglColor4uiv                 = NULL;\n\tqglColor4us                  = NULL;\n\tqglColor4usv                 = NULL;\n\tqglColorMask                 = NULL;\n\tqglColorMaterial             = NULL;\n\tqglColorPointer              = NULL;\n\tqglCopyPixels                = NULL;\n\tqglCopyTexImage1D            = NULL;\n\tqglCopyTexImage2D            = NULL;\n\tqglCopyTexSubImage1D         = NULL;\n\tqglCopyTexSubImage2D         = NULL;\n\tqglCullFace                  = NULL;\n\tqglDeleteLists               = NULL;\n\tqglDeleteTextures            = NULL;\n\tqglDepthFunc                 = NULL;\n\tqglDepthMask                 = NULL;\n\tqglDepthRange                = NULL;\n\tqglDisable                   = NULL;\n\tqglDisableClientState        = NULL;\n\tqglDrawArrays                = NULL;\n\tqglDrawBuffer                = NULL;\n\tqglDrawElements              = NULL;\n\tqglDrawPixels                = NULL;\n\tqglEdgeFlag                  = NULL;\n\tqglEdgeFlagPointer           = NULL;\n\tqglEdgeFlagv                 = NULL;\n\tqglEnable                    = NULL;\n\tqglEnableClientState         = NULL;\n\tqglEnd                       = NULL;\n\tqglEndList                   = NULL;\n\tqglEvalCoord1d               = NULL;\n\tqglEvalCoord1dv              = NULL;\n\tqglEvalCoord1f               = NULL;\n\tqglEvalCoord1fv              = NULL;\n\tqglEvalCoord2d               = NULL;\n\tqglEvalCoord2dv              = NULL;\n\tqglEvalCoord2f               = NULL;\n\tqglEvalCoord2fv              = NULL;\n\tqglEvalMesh1                 = NULL;\n\tqglEvalMesh2                 = NULL;\n\tqglEvalPoint1                = NULL;\n\tqglEvalPoint2                = NULL;\n\tqglFeedbackBuffer            = NULL;\n\tqglFinish                    = NULL;\n\tqglFlush                     = NULL;\n\tqglFogf                      = NULL;\n\tqglFogfv                     = NULL;\n\tqglFogi                      = NULL;\n\tqglFogiv                     = NULL;\n\tqglFrontFace                 = NULL;\n\tqglFrustum                   = NULL;\n\tqglGenLists                  = NULL;\n\tqglGenTextures               = NULL;\n\tqglGetBooleanv               = NULL;\n\tqglGetClipPlane              = NULL;\n\tqglGetDoublev                = NULL;\n\tqglGetError                  = NULL;\n\tqglGetFloatv                 = NULL;\n\tqglGetIntegerv               = NULL;\n\tqglGetLightfv                = NULL;\n\tqglGetLightiv                = NULL;\n\tqglGetMapdv                  = NULL;\n\tqglGetMapfv                  = NULL;\n\tqglGetMapiv                  = NULL;\n\tqglGetMaterialfv             = NULL;\n\tqglGetMaterialiv             = NULL;\n\tqglGetPixelMapfv             = NULL;\n\tqglGetPixelMapuiv            = NULL;\n\tqglGetPixelMapusv            = NULL;\n\tqglGetPointerv               = NULL;\n\tqglGetPolygonStipple         = NULL;\n\tqglGetString                 = NULL;\n\tqglGetTexEnvfv               = NULL;\n\tqglGetTexEnviv               = NULL;\n\tqglGetTexGendv               = NULL;\n\tqglGetTexGenfv               = NULL;\n\tqglGetTexGeniv               = NULL;\n\tqglGetTexImage               = NULL;\n\tqglGetTexLevelParameterfv    = NULL;\n\tqglGetTexLevelParameteriv    = NULL;\n\tqglGetTexParameterfv         = NULL;\n\tqglGetTexParameteriv         = NULL;\n\tqglHint                      = NULL;\n\tqglIndexMask                 = NULL;\n\tqglIndexPointer              = NULL;\n\tqglIndexd                    = NULL;\n\tqglIndexdv                   = NULL;\n\tqglIndexf                    = NULL;\n\tqglIndexfv                   = NULL;\n\tqglIndexi                    = NULL;\n\tqglIndexiv                   = NULL;\n\tqglIndexs                    = NULL;\n\tqglIndexsv                   = NULL;\n\tqglIndexub                   = NULL;\n\tqglIndexubv                  = NULL;\n\tqglInitNames                 = NULL;\n\tqglInterleavedArrays         = NULL;\n\tqglIsEnabled                 = NULL;\n\tqglIsList                    = NULL;\n\tqglIsTexture                 = NULL;\n\tqglLightModelf               = NULL;\n\tqglLightModelfv              = NULL;\n\tqglLightModeli               = NULL;\n\tqglLightModeliv              = NULL;\n\tqglLightf                    = NULL;\n\tqglLightfv                   = NULL;\n\tqglLighti                    = NULL;\n\tqglLightiv                   = NULL;\n\tqglLineStipple               = NULL;\n\tqglLineWidth                 = NULL;\n\tqglListBase                  = NULL;\n\tqglLoadIdentity              = NULL;\n\tqglLoadMatrixd               = NULL;\n\tqglLoadMatrixf               = NULL;\n\tqglLoadName                  = NULL;\n\tqglLogicOp                   = NULL;\n\tqglMap1d                     = NULL;\n\tqglMap1f                     = NULL;\n\tqglMap2d                     = NULL;\n\tqglMap2f                     = NULL;\n\tqglMapGrid1d                 = NULL;\n\tqglMapGrid1f                 = NULL;\n\tqglMapGrid2d                 = NULL;\n\tqglMapGrid2f                 = NULL;\n\tqglMaterialf                 = NULL;\n\tqglMaterialfv                = NULL;\n\tqglMateriali                 = NULL;\n\tqglMaterialiv                = NULL;\n\tqglMatrixMode                = NULL;\n\tqglMultMatrixd               = NULL;\n\tqglMultMatrixf               = NULL;\n\tqglNewList                   = NULL;\n\tqglNormal3b                  = NULL;\n\tqglNormal3bv                 = NULL;\n\tqglNormal3d                  = NULL;\n\tqglNormal3dv                 = NULL;\n\tqglNormal3f                  = NULL;\n\tqglNormal3fv                 = NULL;\n\tqglNormal3i                  = NULL;\n\tqglNormal3iv                 = NULL;\n\tqglNormal3s                  = NULL;\n\tqglNormal3sv                 = NULL;\n\tqglNormalPointer             = NULL;\n\tqglOrtho                     = NULL;\n\tqglPassThrough               = NULL;\n\tqglPixelMapfv                = NULL;\n\tqglPixelMapuiv               = NULL;\n\tqglPixelMapusv               = NULL;\n\tqglPixelStoref               = NULL;\n\tqglPixelStorei               = NULL;\n\tqglPixelTransferf            = NULL;\n\tqglPixelTransferi            = NULL;\n\tqglPixelZoom                 = NULL;\n\tqglPointSize                 = NULL;\n\tqglPolygonMode               = NULL;\n\tqglPolygonOffset             = NULL;\n\tqglPolygonStipple            = NULL;\n\tqglPopAttrib                 = NULL;\n\tqglPopClientAttrib           = NULL;\n\tqglPopMatrix                 = NULL;\n\tqglPopName                   = NULL;\n\tqglPrioritizeTextures        = NULL;\n\tqglPushAttrib                = NULL;\n\tqglPushClientAttrib          = NULL;\n\tqglPushMatrix                = NULL;\n\tqglPushName                  = NULL;\n\tqglRasterPos2d               = NULL;\n\tqglRasterPos2dv              = NULL;\n\tqglRasterPos2f               = NULL;\n\tqglRasterPos2fv              = NULL;\n\tqglRasterPos2i               = NULL;\n\tqglRasterPos2iv              = NULL;\n\tqglRasterPos2s               = NULL;\n\tqglRasterPos2sv              = NULL;\n\tqglRasterPos3d               = NULL;\n\tqglRasterPos3dv              = NULL;\n\tqglRasterPos3f               = NULL;\n\tqglRasterPos3fv              = NULL;\n\tqglRasterPos3i               = NULL;\n\tqglRasterPos3iv              = NULL;\n\tqglRasterPos3s               = NULL;\n\tqglRasterPos3sv              = NULL;\n\tqglRasterPos4d               = NULL;\n\tqglRasterPos4dv              = NULL;\n\tqglRasterPos4f               = NULL;\n\tqglRasterPos4fv              = NULL;\n\tqglRasterPos4i               = NULL;\n\tqglRasterPos4iv              = NULL;\n\tqglRasterPos4s               = NULL;\n\tqglRasterPos4sv              = NULL;\n\tqglReadBuffer                = NULL;\n\tqglReadPixels                = NULL;\n\tqglRectd                     = NULL;\n\tqglRectdv                    = NULL;\n\tqglRectf                     = NULL;\n\tqglRectfv                    = NULL;\n\tqglRecti                     = NULL;\n\tqglRectiv                    = NULL;\n\tqglRects                     = NULL;\n\tqglRectsv                    = NULL;\n\tqglRenderMode                = NULL;\n\tqglRotated                   = NULL;\n\tqglRotatef                   = NULL;\n\tqglScaled                    = NULL;\n\tqglScalef                    = NULL;\n\tqglScissor                   = NULL;\n\tqglSelectBuffer              = NULL;\n\tqglShadeModel                = NULL;\n\tqglStencilFunc               = NULL;\n\tqglStencilMask               = NULL;\n\tqglStencilOp                 = NULL;\n\tqglTexCoord1d                = NULL;\n\tqglTexCoord1dv               = NULL;\n\tqglTexCoord1f                = NULL;\n\tqglTexCoord1fv               = NULL;\n\tqglTexCoord1i                = NULL;\n\tqglTexCoord1iv               = NULL;\n\tqglTexCoord1s                = NULL;\n\tqglTexCoord1sv               = NULL;\n\tqglTexCoord2d                = NULL;\n\tqglTexCoord2dv               = NULL;\n\tqglTexCoord2f                = NULL;\n\tqglTexCoord2fv               = NULL;\n\tqglTexCoord2i                = NULL;\n\tqglTexCoord2iv               = NULL;\n\tqglTexCoord2s                = NULL;\n\tqglTexCoord2sv               = NULL;\n\tqglTexCoord3d                = NULL;\n\tqglTexCoord3dv               = NULL;\n\tqglTexCoord3f                = NULL;\n\tqglTexCoord3fv               = NULL;\n\tqglTexCoord3i                = NULL;\n\tqglTexCoord3iv               = NULL;\n\tqglTexCoord3s                = NULL;\n\tqglTexCoord3sv               = NULL;\n\tqglTexCoord4d                = NULL;\n\tqglTexCoord4dv               = NULL;\n\tqglTexCoord4f                = NULL;\n\tqglTexCoord4fv               = NULL;\n\tqglTexCoord4i                = NULL;\n\tqglTexCoord4iv               = NULL;\n\tqglTexCoord4s                = NULL;\n\tqglTexCoord4sv               = NULL;\n\tqglTexCoordPointer           = NULL;\n\tqglTexEnvf                   = NULL;\n\tqglTexEnvfv                  = NULL;\n\tqglTexEnvi                   = NULL;\n\tqglTexEnviv                  = NULL;\n\tqglTexGend                   = NULL;\n\tqglTexGendv                  = NULL;\n\tqglTexGenf                   = NULL;\n\tqglTexGenfv                  = NULL;\n\tqglTexGeni                   = NULL;\n\tqglTexGeniv                  = NULL;\n\tqglTexImage1D                = NULL;\n\tqglTexImage2D                = NULL;\n\tqglTexParameterf             = NULL;\n\tqglTexParameterfv            = NULL;\n\tqglTexParameteri             = NULL;\n\tqglTexParameteriv            = NULL;\n\tqglTexSubImage1D             = NULL;\n\tqglTexSubImage2D             = NULL;\n\tqglTranslated                = NULL;\n\tqglTranslatef                = NULL;\n\tqglVertex2d                  = NULL;\n\tqglVertex2dv                 = NULL;\n\tqglVertex2f                  = NULL;\n\tqglVertex2fv                 = NULL;\n\tqglVertex2i                  = NULL;\n\tqglVertex2iv                 = NULL;\n\tqglVertex2s                  = NULL;\n\tqglVertex2sv                 = NULL;\n\tqglVertex3d                  = NULL;\n\tqglVertex3dv                 = NULL;\n\tqglVertex3f                  = NULL;\n\tqglVertex3fv                 = NULL;\n\tqglVertex3i                  = NULL;\n\tqglVertex3iv                 = NULL;\n\tqglVertex3s                  = NULL;\n\tqglVertex3sv                 = NULL;\n\tqglVertex4d                  = NULL;\n\tqglVertex4dv                 = NULL;\n\tqglVertex4f                  = NULL;\n\tqglVertex4fv                 = NULL;\n\tqglVertex4i                  = NULL;\n\tqglVertex4iv                 = NULL;\n\tqglVertex4s                  = NULL;\n\tqglVertex4sv                 = NULL;\n\tqglVertexPointer             = NULL;\n\tqglViewport                  = NULL;\n\n\tqwglCopyContext              = NULL;\n\tqwglCreateContext            = NULL;\n\tqwglCreateLayerContext       = NULL;\n\tqwglDeleteContext            = NULL;\n\tqwglDescribeLayerPlane       = NULL;\n\tqwglGetCurrentContext        = NULL;\n\tqwglGetCurrentDC             = NULL;\n\tqwglGetLayerPaletteEntries   = NULL;\n\tqwglGetProcAddress           = NULL;\n\tqwglMakeCurrent              = NULL;\n\tqwglRealizeLayerPalette      = NULL;\n\tqwglSetLayerPaletteEntries   = NULL;\n\tqwglShareLists               = NULL;\n\tqwglSwapLayerBuffers         = NULL;\n\tqwglUseFontBitmaps           = NULL;\n\tqwglUseFontOutlines          = NULL;\n\n\tqwglChoosePixelFormat        = NULL;\n\tqwglDescribePixelFormat      = NULL;\n\tqwglGetPixelFormat           = NULL;\n\tqwglSetPixelFormat           = NULL;\n\tqwglSwapBuffers              = NULL;\n\n\tqwglSwapIntervalEXT\t= NULL;\n\n\tqwglGetDeviceGammaRampEXT = NULL;\n\tqwglSetDeviceGammaRampEXT = NULL;\n}\n\n#\tdefine GPA(h, a ) GetProcAddress( h, a )\n\n/*\n** QGL_Init\n**\n** This is responsible for binding our qgl function pointers to \n** the appropriate GL stuff.  In Windows this means doing a \n** LoadLibrary and a bunch of calls to GetProcAddress.  On other\n** operating systems we need to do the right thing, whatever that\n** might be.\n** \n*/\nqboolean QGL_Init(const char *dllname )\n{\n\n  g_hGLDLL = ::LoadLibrary(dllname);\n\n\tqglAccum                     = dllAccum = GPA(g_hGLDLL, \"glAccum\" );\n\tqglAlphaFunc                 = dllAlphaFunc = GPA(g_hGLDLL, \"glAlphaFunc\" );\n\tqglAreTexturesResident       = dllAreTexturesResident = GPA(g_hGLDLL, \"glAreTexturesResident\" );\n\tqglArrayElement              = dllArrayElement = GPA(g_hGLDLL, \"glArrayElement\" );\n\tqglBegin                     = dllBegin = GPA(g_hGLDLL, \"glBegin\" );\n\tqglBindTexture               = dllBindTexture = GPA(g_hGLDLL, \"glBindTexture\" );\n\tqglBitmap                    = dllBitmap = GPA(g_hGLDLL, \"glBitmap\" );\n\tqglBlendFunc                 = dllBlendFunc = GPA(g_hGLDLL, \"glBlendFunc\" );\n\tqglCallList                  = dllCallList = GPA(g_hGLDLL, \"glCallList\" );\n\tqglCallLists                 = dllCallLists = GPA(g_hGLDLL, \"glCallLists\" );\n\tqglClear                     = dllClear = GPA(g_hGLDLL, \"glClear\" );\n\tqglClearAccum                = dllClearAccum = GPA(g_hGLDLL, \"glClearAccum\" );\n\tqglClearColor                = dllClearColor = GPA(g_hGLDLL, \"glClearColor\" );\n\tqglClearDepth                = dllClearDepth = GPA(g_hGLDLL, \"glClearDepth\" );\n\tqglClearIndex                = dllClearIndex = GPA(g_hGLDLL, \"glClearIndex\" );\n\tqglClearStencil              = dllClearStencil = GPA(g_hGLDLL, \"glClearStencil\" );\n\tqglClipPlane                 = dllClipPlane = GPA(g_hGLDLL, \"glClipPlane\" );\n\tqglColor3b                   = dllColor3b = GPA(g_hGLDLL, \"glColor3b\" );\n\tqglColor3bv                  = dllColor3bv = GPA(g_hGLDLL, \"glColor3bv\" );\n\tqglColor3d                   = dllColor3d = GPA(g_hGLDLL, \"glColor3d\" );\n\tqglColor3dv                  = dllColor3dv = GPA(g_hGLDLL, \"glColor3dv\" );\n\tqglColor3f                   = dllColor3f = GPA(g_hGLDLL, \"glColor3f\" );\n\tqglColor3fv                  = dllColor3fv = GPA(g_hGLDLL, \"glColor3fv\" );\n\tqglColor3i                   = dllColor3i = GPA(g_hGLDLL, \"glColor3i\" );\n\tqglColor3iv                  = dllColor3iv = GPA(g_hGLDLL, \"glColor3iv\" );\n\tqglColor3s                   = dllColor3s = GPA(g_hGLDLL, \"glColor3s\" );\n\tqglColor3sv                  = dllColor3sv = GPA(g_hGLDLL, \"glColor3sv\" );\n\tqglColor3ub                  = dllColor3ub = GPA(g_hGLDLL, \"glColor3ub\" );\n\tqglColor3ubv                 = dllColor3ubv = GPA(g_hGLDLL, \"glColor3ubv\" );\n\tqglColor3ui                  = dllColor3ui = GPA(g_hGLDLL, \"glColor3ui\" );\n\tqglColor3uiv                 = dllColor3uiv = GPA(g_hGLDLL, \"glColor3uiv\" );\n\tqglColor3us                  = dllColor3us = GPA(g_hGLDLL, \"glColor3us\" );\n\tqglColor3usv                 = dllColor3usv = GPA(g_hGLDLL, \"glColor3usv\" );\n\tqglColor4b                   = dllColor4b = GPA(g_hGLDLL, \"glColor4b\" );\n\tqglColor4bv                  = dllColor4bv = GPA(g_hGLDLL, \"glColor4bv\" );\n\tqglColor4d                   = dllColor4d = GPA(g_hGLDLL, \"glColor4d\" );\n\tqglColor4dv                  = dllColor4dv = GPA(g_hGLDLL, \"glColor4dv\" );\n\tqglColor4f                   = dllColor4f = GPA(g_hGLDLL, \"glColor4f\" );\n\tqglColor4fv                  = dllColor4fv = GPA(g_hGLDLL, \"glColor4fv\" );\n\tqglColor4i                   = dllColor4i = GPA(g_hGLDLL, \"glColor4i\" );\n\tqglColor4iv                  = dllColor4iv = GPA(g_hGLDLL, \"glColor4iv\" );\n\tqglColor4s                   = dllColor4s = GPA(g_hGLDLL, \"glColor4s\" );\n\tqglColor4sv                  = dllColor4sv = GPA(g_hGLDLL, \"glColor4sv\" );\n\tqglColor4ub                  = dllColor4ub = GPA(g_hGLDLL, \"glColor4ub\" );\n\tqglColor4ubv                 = dllColor4ubv = GPA(g_hGLDLL, \"glColor4ubv\" );\n\tqglColor4ui                  = dllColor4ui = GPA(g_hGLDLL, \"glColor4ui\" );\n\tqglColor4uiv                 = dllColor4uiv = GPA(g_hGLDLL, \"glColor4uiv\" );\n\tqglColor4us                  = dllColor4us = GPA(g_hGLDLL, \"glColor4us\" );\n\tqglColor4usv                 = dllColor4usv = GPA(g_hGLDLL, \"glColor4usv\" );\n\tqglColorMask                 = dllColorMask = GPA(g_hGLDLL, \"glColorMask\" );\n\tqglColorMaterial             = dllColorMaterial = GPA(g_hGLDLL, \"glColorMaterial\" );\n\tqglColorPointer              = dllColorPointer = GPA(g_hGLDLL, \"glColorPointer\" );\n\tqglCopyPixels                = dllCopyPixels = GPA(g_hGLDLL, \"glCopyPixels\" );\n\tqglCopyTexImage1D            = dllCopyTexImage1D = GPA(g_hGLDLL, \"glCopyTexImage1D\" );\n\tqglCopyTexImage2D            = dllCopyTexImage2D = GPA(g_hGLDLL, \"glCopyTexImage2D\" );\n\tqglCopyTexSubImage1D         = dllCopyTexSubImage1D = GPA(g_hGLDLL, \"glCopyTexSubImage1D\" );\n\tqglCopyTexSubImage2D         = dllCopyTexSubImage2D = GPA(g_hGLDLL, \"glCopyTexSubImage2D\" );\n\tqglCullFace                  = dllCullFace = GPA(g_hGLDLL, \"glCullFace\" );\n\tqglDeleteLists               = dllDeleteLists = GPA(g_hGLDLL, \"glDeleteLists\" );\n\tqglDeleteTextures            = dllDeleteTextures = GPA(g_hGLDLL, \"glDeleteTextures\" );\n\tqglDepthFunc                 = dllDepthFunc = GPA(g_hGLDLL, \"glDepthFunc\" );\n\tqglDepthMask                 = dllDepthMask = GPA(g_hGLDLL, \"glDepthMask\" );\n\tqglDepthRange                = dllDepthRange = GPA(g_hGLDLL, \"glDepthRange\" );\n\tqglDisable                   = dllDisable = GPA(g_hGLDLL, \"glDisable\" );\n\tqglDisableClientState        = dllDisableClientState = GPA(g_hGLDLL, \"glDisableClientState\" );\n\tqglDrawArrays                = dllDrawArrays = GPA(g_hGLDLL, \"glDrawArrays\" );\n\tqglDrawBuffer                = dllDrawBuffer = GPA(g_hGLDLL, \"glDrawBuffer\" );\n\tqglDrawElements              = dllDrawElements = GPA(g_hGLDLL, \"glDrawElements\" );\n\tqglDrawPixels                = dllDrawPixels = GPA(g_hGLDLL, \"glDrawPixels\" );\n\tqglEdgeFlag                  = dllEdgeFlag = GPA(g_hGLDLL, \"glEdgeFlag\" );\n\tqglEdgeFlagPointer           = dllEdgeFlagPointer = GPA(g_hGLDLL, \"glEdgeFlagPointer\" );\n\tqglEdgeFlagv                 = dllEdgeFlagv = GPA(g_hGLDLL, \"glEdgeFlagv\" );\n\tqglEnable                    = \tdllEnable                    = GPA(g_hGLDLL, \"glEnable\" );\n\tqglEnableClientState         = \tdllEnableClientState         = GPA(g_hGLDLL, \"glEnableClientState\" );\n\tqglEnd                       = \tdllEnd                       = GPA(g_hGLDLL, \"glEnd\" );\n\tqglEndList                   = \tdllEndList                   = GPA(g_hGLDLL, \"glEndList\" );\n\tqglEvalCoord1d\t\t\t\t = \tdllEvalCoord1d\t\t\t\t = GPA(g_hGLDLL, \"glEvalCoord1d\" );\n\tqglEvalCoord1dv              = \tdllEvalCoord1dv              = GPA(g_hGLDLL, \"glEvalCoord1dv\" );\n\tqglEvalCoord1f               = \tdllEvalCoord1f               = GPA(g_hGLDLL, \"glEvalCoord1f\" );\n\tqglEvalCoord1fv              = \tdllEvalCoord1fv              = GPA(g_hGLDLL, \"glEvalCoord1fv\" );\n\tqglEvalCoord2d               = \tdllEvalCoord2d               = GPA(g_hGLDLL, \"glEvalCoord2d\" );\n\tqglEvalCoord2dv              = \tdllEvalCoord2dv              = GPA(g_hGLDLL, \"glEvalCoord2dv\" );\n\tqglEvalCoord2f               = \tdllEvalCoord2f               = GPA(g_hGLDLL, \"glEvalCoord2f\" );\n\tqglEvalCoord2fv              = \tdllEvalCoord2fv              = GPA(g_hGLDLL, \"glEvalCoord2fv\" );\n\tqglEvalMesh1                 = \tdllEvalMesh1                 = GPA(g_hGLDLL, \"glEvalMesh1\" );\n\tqglEvalMesh2                 = \tdllEvalMesh2                 = GPA(g_hGLDLL, \"glEvalMesh2\" );\n\tqglEvalPoint1                = \tdllEvalPoint1                = GPA(g_hGLDLL, \"glEvalPoint1\" );\n\tqglEvalPoint2                = \tdllEvalPoint2                = GPA(g_hGLDLL, \"glEvalPoint2\" );\n\tqglFeedbackBuffer            = \tdllFeedbackBuffer            = GPA(g_hGLDLL, \"glFeedbackBuffer\" );\n\tqglFinish                    = \tdllFinish                    = GPA(g_hGLDLL, \"glFinish\" );\n\tqglFlush                     = \tdllFlush                     = GPA(g_hGLDLL, \"glFlush\" );\n\tqglFogf                      = \tdllFogf                      = GPA(g_hGLDLL, \"glFogf\" );\n\tqglFogfv                     = \tdllFogfv                     = GPA(g_hGLDLL, \"glFogfv\" );\n\tqglFogi                      = \tdllFogi                      = GPA(g_hGLDLL, \"glFogi\" );\n\tqglFogiv                     = \tdllFogiv                     = GPA(g_hGLDLL, \"glFogiv\" );\n\tqglFrontFace                 = \tdllFrontFace                 = GPA(g_hGLDLL, \"glFrontFace\" );\n\tqglFrustum                   = \tdllFrustum                   = GPA(g_hGLDLL, \"glFrustum\" );\n\tqglGenLists                  = \tdllGenLists                  = GPA(g_hGLDLL, \"glGenLists\" );\n\tqglGenTextures               = \tdllGenTextures               = GPA(g_hGLDLL, \"glGenTextures\" );\n\tqglGetBooleanv               = \tdllGetBooleanv               = GPA(g_hGLDLL, \"glGetBooleanv\" );\n\tqglGetClipPlane              = \tdllGetClipPlane              = GPA(g_hGLDLL, \"glGetClipPlane\" );\n\tqglGetDoublev                = \tdllGetDoublev                = GPA(g_hGLDLL, \"glGetDoublev\" );\n\tqglGetError                  = \tdllGetError                  = GPA(g_hGLDLL, \"glGetError\" );\n\tqglGetFloatv                 = \tdllGetFloatv                 = GPA(g_hGLDLL, \"glGetFloatv\" );\n\tqglGetIntegerv               = \tdllGetIntegerv               = GPA(g_hGLDLL, \"glGetIntegerv\" );\n\tqglGetLightfv                = \tdllGetLightfv                = GPA(g_hGLDLL, \"glGetLightfv\" );\n\tqglGetLightiv                = \tdllGetLightiv                = GPA(g_hGLDLL, \"glGetLightiv\" );\n\tqglGetMapdv                  = \tdllGetMapdv                  = GPA(g_hGLDLL, \"glGetMapdv\" );\n\tqglGetMapfv                  = \tdllGetMapfv                  = GPA(g_hGLDLL, \"glGetMapfv\" );\n\tqglGetMapiv                  = \tdllGetMapiv                  = GPA(g_hGLDLL, \"glGetMapiv\" );\n\tqglGetMaterialfv             = \tdllGetMaterialfv             = GPA(g_hGLDLL, \"glGetMaterialfv\" );\n\tqglGetMaterialiv             = \tdllGetMaterialiv             = GPA(g_hGLDLL, \"glGetMaterialiv\" );\n\tqglGetPixelMapfv             = \tdllGetPixelMapfv             = GPA(g_hGLDLL, \"glGetPixelMapfv\" );\n\tqglGetPixelMapuiv            = \tdllGetPixelMapuiv            = GPA(g_hGLDLL, \"glGetPixelMapuiv\" );\n\tqglGetPixelMapusv            = \tdllGetPixelMapusv            = GPA(g_hGLDLL, \"glGetPixelMapusv\" );\n\tqglGetPointerv               = \tdllGetPointerv               = GPA(g_hGLDLL, \"glGetPointerv\" );\n\tqglGetPolygonStipple         = \tdllGetPolygonStipple         = GPA(g_hGLDLL, \"glGetPolygonStipple\" );\n\tqglGetString                 = \tdllGetString                 = GPA(g_hGLDLL, \"glGetString\" );\n\tqglGetTexEnvfv               = \tdllGetTexEnvfv               = GPA(g_hGLDLL, \"glGetTexEnvfv\" );\n\tqglGetTexEnviv               = \tdllGetTexEnviv               = GPA(g_hGLDLL, \"glGetTexEnviv\" );\n\tqglGetTexGendv               = \tdllGetTexGendv               = GPA(g_hGLDLL, \"glGetTexGendv\" );\n\tqglGetTexGenfv               = \tdllGetTexGenfv               = GPA(g_hGLDLL, \"glGetTexGenfv\" );\n\tqglGetTexGeniv               = \tdllGetTexGeniv               = GPA(g_hGLDLL, \"glGetTexGeniv\" );\n\tqglGetTexImage               = \tdllGetTexImage               = GPA(g_hGLDLL, \"glGetTexImage\" );\n\tqglGetTexLevelParameterfv    = \tdllGetTexLevelParameterfv    = GPA(g_hGLDLL, \"glGetLevelParameterfv\" );\n\tqglGetTexLevelParameteriv    = \tdllGetTexLevelParameteriv    = GPA(g_hGLDLL, \"glGetLevelParameteriv\" );\n\tqglGetTexParameterfv         = \tdllGetTexParameterfv         = GPA(g_hGLDLL, \"glGetTexParameterfv\" );\n\tqglGetTexParameteriv         = \tdllGetTexParameteriv         = GPA(g_hGLDLL, \"glGetTexParameteriv\" );\n\tqglHint                      = \tdllHint                      = GPA(g_hGLDLL, \"glHint\" );\n\tqglIndexMask                 = \tdllIndexMask                 = GPA(g_hGLDLL, \"glIndexMask\" );\n\tqglIndexPointer              = \tdllIndexPointer              = GPA(g_hGLDLL, \"glIndexPointer\" );\n\tqglIndexd                    = \tdllIndexd                    = GPA(g_hGLDLL, \"glIndexd\" );\n\tqglIndexdv                   = \tdllIndexdv                   = GPA(g_hGLDLL, \"glIndexdv\" );\n\tqglIndexf                    = \tdllIndexf                    = GPA(g_hGLDLL, \"glIndexf\" );\n\tqglIndexfv                   = \tdllIndexfv                   = GPA(g_hGLDLL, \"glIndexfv\" );\n\tqglIndexi                    = \tdllIndexi                    = GPA(g_hGLDLL, \"glIndexi\" );\n\tqglIndexiv                   = \tdllIndexiv                   = GPA(g_hGLDLL, \"glIndexiv\" );\n\tqglIndexs                    = \tdllIndexs                    = GPA(g_hGLDLL, \"glIndexs\" );\n\tqglIndexsv                   = \tdllIndexsv                   = GPA(g_hGLDLL, \"glIndexsv\" );\n\tqglIndexub                   = \tdllIndexub                   = GPA(g_hGLDLL, \"glIndexub\" );\n\tqglIndexubv                  = \tdllIndexubv                  = GPA(g_hGLDLL, \"glIndexubv\" );\n\tqglInitNames                 = \tdllInitNames                 = GPA(g_hGLDLL, \"glInitNames\" );\n\tqglInterleavedArrays         = \tdllInterleavedArrays         = GPA(g_hGLDLL, \"glInterleavedArrays\" );\n\tqglIsEnabled                 = \tdllIsEnabled                 = GPA(g_hGLDLL, \"glIsEnabled\" );\n\tqglIsList                    = \tdllIsList                    = GPA(g_hGLDLL, \"glIsList\" );\n\tqglIsTexture                 = \tdllIsTexture                 = GPA(g_hGLDLL, \"glIsTexture\" );\n\tqglLightModelf               = \tdllLightModelf               = GPA(g_hGLDLL, \"glLightModelf\" );\n\tqglLightModelfv              = \tdllLightModelfv              = GPA(g_hGLDLL, \"glLightModelfv\" );\n\tqglLightModeli               = \tdllLightModeli               = GPA(g_hGLDLL, \"glLightModeli\" );\n\tqglLightModeliv              = \tdllLightModeliv              = GPA(g_hGLDLL, \"glLightModeliv\" );\n\tqglLightf                    = \tdllLightf                    = GPA(g_hGLDLL, \"glLightf\" );\n\tqglLightfv                   = \tdllLightfv                   = GPA(g_hGLDLL, \"glLightfv\" );\n\tqglLighti                    = \tdllLighti                    = GPA(g_hGLDLL, \"glLighti\" );\n\tqglLightiv                   = \tdllLightiv                   = GPA(g_hGLDLL, \"glLightiv\" );\n\tqglLineStipple               = \tdllLineStipple               = GPA(g_hGLDLL, \"glLineStipple\" );\n\tqglLineWidth                 = \tdllLineWidth                 = GPA(g_hGLDLL, \"glLineWidth\" );\n\tqglListBase                  = \tdllListBase                  = GPA(g_hGLDLL, \"glListBase\" );\n\tqglLoadIdentity              = \tdllLoadIdentity              = GPA(g_hGLDLL, \"glLoadIdentity\" );\n\tqglLoadMatrixd               = \tdllLoadMatrixd               = GPA(g_hGLDLL, \"glLoadMatrixd\" );\n\tqglLoadMatrixf               = \tdllLoadMatrixf               = GPA(g_hGLDLL, \"glLoadMatrixf\" );\n\tqglLoadName                  = \tdllLoadName                  = GPA(g_hGLDLL, \"glLoadName\" );\n\tqglLogicOp                   = \tdllLogicOp                   = GPA(g_hGLDLL, \"glLogicOp\" );\n\tqglMap1d                     = \tdllMap1d                     = GPA(g_hGLDLL, \"glMap1d\" );\n\tqglMap1f                     = \tdllMap1f                     = GPA(g_hGLDLL, \"glMap1f\" );\n\tqglMap2d                     = \tdllMap2d                     = GPA(g_hGLDLL, \"glMap2d\" );\n\tqglMap2f                     = \tdllMap2f                     = GPA(g_hGLDLL, \"glMap2f\" );\n\tqglMapGrid1d                 = \tdllMapGrid1d                 = GPA(g_hGLDLL, \"glMapGrid1d\" );\n\tqglMapGrid1f                 = \tdllMapGrid1f                 = GPA(g_hGLDLL, \"glMapGrid1f\" );\n\tqglMapGrid2d                 = \tdllMapGrid2d                 = GPA(g_hGLDLL, \"glMapGrid2d\" );\n\tqglMapGrid2f                 = \tdllMapGrid2f                 = GPA(g_hGLDLL, \"glMapGrid2f\" );\n\tqglMaterialf                 = \tdllMaterialf                 = GPA(g_hGLDLL, \"glMaterialf\" );\n\tqglMaterialfv                = \tdllMaterialfv                = GPA(g_hGLDLL, \"glMaterialfv\" );\n\tqglMateriali                 = \tdllMateriali                 = GPA(g_hGLDLL, \"glMateriali\" );\n\tqglMaterialiv                = \tdllMaterialiv                = GPA(g_hGLDLL, \"glMaterialiv\" );\n\tqglMatrixMode                = \tdllMatrixMode                = GPA(g_hGLDLL, \"glMatrixMode\" );\n\tqglMultMatrixd               = \tdllMultMatrixd               = GPA(g_hGLDLL, \"glMultMatrixd\" );\n\tqglMultMatrixf               = \tdllMultMatrixf               = GPA(g_hGLDLL, \"glMultMatrixf\" );\n\tqglNewList                   = \tdllNewList                   = GPA(g_hGLDLL, \"glNewList\" );\n\tqglNormal3b                  = \tdllNormal3b                  = GPA(g_hGLDLL, \"glNormal3b\" );\n\tqglNormal3bv                 = \tdllNormal3bv                 = GPA(g_hGLDLL, \"glNormal3bv\" );\n\tqglNormal3d                  = \tdllNormal3d                  = GPA(g_hGLDLL, \"glNormal3d\" );\n\tqglNormal3dv                 = \tdllNormal3dv                 = GPA(g_hGLDLL, \"glNormal3dv\" );\n\tqglNormal3f                  = \tdllNormal3f                  = GPA(g_hGLDLL, \"glNormal3f\" );\n\tqglNormal3fv                 = \tdllNormal3fv                 = GPA(g_hGLDLL, \"glNormal3fv\" );\n\tqglNormal3i                  = \tdllNormal3i                  = GPA(g_hGLDLL, \"glNormal3i\" );\n\tqglNormal3iv                 = \tdllNormal3iv                 = GPA(g_hGLDLL, \"glNormal3iv\" );\n\tqglNormal3s                  = \tdllNormal3s                  = GPA(g_hGLDLL, \"glNormal3s\" );\n\tqglNormal3sv                 = \tdllNormal3sv                 = GPA(g_hGLDLL, \"glNormal3sv\" );\n\tqglNormalPointer             = \tdllNormalPointer             = GPA(g_hGLDLL, \"glNormalPointer\" );\n\tqglOrtho                     = \tdllOrtho                     = GPA(g_hGLDLL, \"glOrtho\" );\n\tqglPassThrough               = \tdllPassThrough               = GPA(g_hGLDLL, \"glPassThrough\" );\n\tqglPixelMapfv                = \tdllPixelMapfv                = GPA(g_hGLDLL, \"glPixelMapfv\" );\n\tqglPixelMapuiv               = \tdllPixelMapuiv               = GPA(g_hGLDLL, \"glPixelMapuiv\" );\n\tqglPixelMapusv               = \tdllPixelMapusv               = GPA(g_hGLDLL, \"glPixelMapusv\" );\n\tqglPixelStoref               = \tdllPixelStoref               = GPA(g_hGLDLL, \"glPixelStoref\" );\n\tqglPixelStorei               = \tdllPixelStorei               = GPA(g_hGLDLL, \"glPixelStorei\" );\n\tqglPixelTransferf            = \tdllPixelTransferf            = GPA(g_hGLDLL, \"glPixelTransferf\" );\n\tqglPixelTransferi            = \tdllPixelTransferi            = GPA(g_hGLDLL, \"glPixelTransferi\" );\n\tqglPixelZoom                 = \tdllPixelZoom                 = GPA(g_hGLDLL, \"glPixelZoom\" );\n\tqglPointSize                 = \tdllPointSize                 = GPA(g_hGLDLL, \"glPointSize\" );\n\tqglPolygonMode               = \tdllPolygonMode               = GPA(g_hGLDLL, \"glPolygonMode\" );\n\tqglPolygonOffset             = \tdllPolygonOffset             = GPA(g_hGLDLL, \"glPolygonOffset\" );\n\tqglPolygonStipple            = \tdllPolygonStipple            = GPA(g_hGLDLL, \"glPolygonStipple\" );\n\tqglPopAttrib                 = \tdllPopAttrib                 = GPA(g_hGLDLL, \"glPopAttrib\" );\n\tqglPopClientAttrib           = \tdllPopClientAttrib           = GPA(g_hGLDLL, \"glPopClientAttrib\" );\n\tqglPopMatrix                 = \tdllPopMatrix                 = GPA(g_hGLDLL, \"glPopMatrix\" );\n\tqglPopName                   = \tdllPopName                   = GPA(g_hGLDLL, \"glPopName\" );\n\tqglPrioritizeTextures        = \tdllPrioritizeTextures        = GPA(g_hGLDLL, \"glPrioritizeTextures\" );\n\tqglPushAttrib                = \tdllPushAttrib                = GPA(g_hGLDLL, \"glPushAttrib\" );\n\tqglPushClientAttrib          = \tdllPushClientAttrib          = GPA(g_hGLDLL, \"glPushClientAttrib\" );\n\tqglPushMatrix                = \tdllPushMatrix                = GPA(g_hGLDLL, \"glPushMatrix\" );\n\tqglPushName                  = \tdllPushName                  = GPA(g_hGLDLL, \"glPushName\" );\n\tqglRasterPos2d               = \tdllRasterPos2d               = GPA(g_hGLDLL, \"glRasterPos2d\" );\n\tqglRasterPos2dv              = \tdllRasterPos2dv              = GPA(g_hGLDLL, \"glRasterPos2dv\" );\n\tqglRasterPos2f               = \tdllRasterPos2f               = GPA(g_hGLDLL, \"glRasterPos2f\" );\n\tqglRasterPos2fv              = \tdllRasterPos2fv              = GPA(g_hGLDLL, \"glRasterPos2fv\" );\n\tqglRasterPos2i               = \tdllRasterPos2i               = GPA(g_hGLDLL, \"glRasterPos2i\" );\n\tqglRasterPos2iv              = \tdllRasterPos2iv              = GPA(g_hGLDLL, \"glRasterPos2iv\" );\n\tqglRasterPos2s               = \tdllRasterPos2s               = GPA(g_hGLDLL, \"glRasterPos2s\" );\n\tqglRasterPos2sv              = \tdllRasterPos2sv              = GPA(g_hGLDLL, \"glRasterPos2sv\" );\n\tqglRasterPos3d               = \tdllRasterPos3d               = GPA(g_hGLDLL, \"glRasterPos3d\" );\n\tqglRasterPos3dv              = \tdllRasterPos3dv              = GPA(g_hGLDLL, \"glRasterPos3dv\" );\n\tqglRasterPos3f               = \tdllRasterPos3f               = GPA(g_hGLDLL, \"glRasterPos3f\" );\n\tqglRasterPos3fv              = \tdllRasterPos3fv              = GPA(g_hGLDLL, \"glRasterPos3fv\" );\n\tqglRasterPos3i               = \tdllRasterPos3i               = GPA(g_hGLDLL, \"glRasterPos3i\" );\n\tqglRasterPos3iv              = \tdllRasterPos3iv              = GPA(g_hGLDLL, \"glRasterPos3iv\" );\n\tqglRasterPos3s               = \tdllRasterPos3s               = GPA(g_hGLDLL, \"glRasterPos3s\" );\n\tqglRasterPos3sv              = \tdllRasterPos3sv              = GPA(g_hGLDLL, \"glRasterPos3sv\" );\n\tqglRasterPos4d               = \tdllRasterPos4d               = GPA(g_hGLDLL, \"glRasterPos4d\" );\n\tqglRasterPos4dv              = \tdllRasterPos4dv              = GPA(g_hGLDLL, \"glRasterPos4dv\" );\n\tqglRasterPos4f               = \tdllRasterPos4f               = GPA(g_hGLDLL, \"glRasterPos4f\" );\n\tqglRasterPos4fv              = \tdllRasterPos4fv              = GPA(g_hGLDLL, \"glRasterPos4fv\" );\n\tqglRasterPos4i               = \tdllRasterPos4i               = GPA(g_hGLDLL, \"glRasterPos4i\" );\n\tqglRasterPos4iv              = \tdllRasterPos4iv              = GPA(g_hGLDLL, \"glRasterPos4iv\" );\n\tqglRasterPos4s               = \tdllRasterPos4s               = GPA(g_hGLDLL, \"glRasterPos4s\" );\n\tqglRasterPos4sv              = \tdllRasterPos4sv              = GPA(g_hGLDLL, \"glRasterPos4sv\" );\n\tqglReadBuffer                = \tdllReadBuffer                = GPA(g_hGLDLL, \"glReadBuffer\" );\n\tqglReadPixels                = \tdllReadPixels                = GPA(g_hGLDLL, \"glReadPixels\" );\n\tqglRectd                     = \tdllRectd                     = GPA(g_hGLDLL, \"glRectd\" );\n\tqglRectdv                    = \tdllRectdv                    = GPA(g_hGLDLL, \"glRectdv\" );\n\tqglRectf                     = \tdllRectf                     = GPA(g_hGLDLL, \"glRectf\" );\n\tqglRectfv                    = \tdllRectfv                    = GPA(g_hGLDLL, \"glRectfv\" );\n\tqglRecti                     = \tdllRecti                     = GPA(g_hGLDLL, \"glRecti\" );\n\tqglRectiv                    = \tdllRectiv                    = GPA(g_hGLDLL, \"glRectiv\" );\n\tqglRects                     = \tdllRects                     = GPA(g_hGLDLL, \"glRects\" );\n\tqglRectsv                    = \tdllRectsv                    = GPA(g_hGLDLL, \"glRectsv\" );\n\tqglRenderMode                = \tdllRenderMode                = GPA(g_hGLDLL, \"glRenderMode\" );\n\tqglRotated                   = \tdllRotated                   = GPA(g_hGLDLL, \"glRotated\" );\n\tqglRotatef                   = \tdllRotatef                   = GPA(g_hGLDLL, \"glRotatef\" );\n\tqglScaled                    = \tdllScaled                    = GPA(g_hGLDLL, \"glScaled\" );\n\tqglScalef                    = \tdllScalef                    = GPA(g_hGLDLL, \"glScalef\" );\n\tqglScissor                   = \tdllScissor                   = GPA(g_hGLDLL, \"glScissor\" );\n\tqglSelectBuffer              = \tdllSelectBuffer              = GPA(g_hGLDLL, \"glSelectBuffer\" );\n\tqglShadeModel                = \tdllShadeModel                = GPA(g_hGLDLL, \"glShadeModel\" );\n\tqglStencilFunc               = \tdllStencilFunc               = GPA(g_hGLDLL, \"glStencilFunc\" );\n\tqglStencilMask               = \tdllStencilMask               = GPA(g_hGLDLL, \"glStencilMask\" );\n\tqglStencilOp                 = \tdllStencilOp                 = GPA(g_hGLDLL, \"glStencilOp\" );\n\tqglTexCoord1d                = \tdllTexCoord1d                = GPA(g_hGLDLL, \"glTexCoord1d\" );\n\tqglTexCoord1dv               = \tdllTexCoord1dv               = GPA(g_hGLDLL, \"glTexCoord1dv\" );\n\tqglTexCoord1f                = \tdllTexCoord1f                = GPA(g_hGLDLL, \"glTexCoord1f\" );\n\tqglTexCoord1fv               = \tdllTexCoord1fv               = GPA(g_hGLDLL, \"glTexCoord1fv\" );\n\tqglTexCoord1i                = \tdllTexCoord1i                = GPA(g_hGLDLL, \"glTexCoord1i\" );\n\tqglTexCoord1iv               = \tdllTexCoord1iv               = GPA(g_hGLDLL, \"glTexCoord1iv\" );\n\tqglTexCoord1s                = \tdllTexCoord1s                = GPA(g_hGLDLL, \"glTexCoord1s\" );\n\tqglTexCoord1sv               = \tdllTexCoord1sv               = GPA(g_hGLDLL, \"glTexCoord1sv\" );\n\tqglTexCoord2d                = \tdllTexCoord2d                = GPA(g_hGLDLL, \"glTexCoord2d\" );\n\tqglTexCoord2dv               = \tdllTexCoord2dv               = GPA(g_hGLDLL, \"glTexCoord2dv\" );\n\tqglTexCoord2f                = \tdllTexCoord2f                = GPA(g_hGLDLL, \"glTexCoord2f\" );\n\tqglTexCoord2fv               = \tdllTexCoord2fv               = GPA(g_hGLDLL, \"glTexCoord2fv\" );\n\tqglTexCoord2i                = \tdllTexCoord2i                = GPA(g_hGLDLL, \"glTexCoord2i\" );\n\tqglTexCoord2iv               = \tdllTexCoord2iv               = GPA(g_hGLDLL, \"glTexCoord2iv\" );\n\tqglTexCoord2s                = \tdllTexCoord2s                = GPA(g_hGLDLL, \"glTexCoord2s\" );\n\tqglTexCoord2sv               = \tdllTexCoord2sv               = GPA(g_hGLDLL, \"glTexCoord2sv\" );\n\tqglTexCoord3d                = \tdllTexCoord3d                = GPA(g_hGLDLL, \"glTexCoord3d\" );\n\tqglTexCoord3dv               = \tdllTexCoord3dv               = GPA(g_hGLDLL, \"glTexCoord3dv\" );\n\tqglTexCoord3f                = \tdllTexCoord3f                = GPA(g_hGLDLL, \"glTexCoord3f\" );\n\tqglTexCoord3fv               = \tdllTexCoord3fv               = GPA(g_hGLDLL, \"glTexCoord3fv\" );\n\tqglTexCoord3i                = \tdllTexCoord3i                = GPA(g_hGLDLL, \"glTexCoord3i\" );\n\tqglTexCoord3iv               = \tdllTexCoord3iv               = GPA(g_hGLDLL, \"glTexCoord3iv\" );\n\tqglTexCoord3s                = \tdllTexCoord3s                = GPA(g_hGLDLL, \"glTexCoord3s\" );\n\tqglTexCoord3sv               = \tdllTexCoord3sv               = GPA(g_hGLDLL, \"glTexCoord3sv\" );\n\tqglTexCoord4d                = \tdllTexCoord4d                = GPA(g_hGLDLL, \"glTexCoord4d\" );\n\tqglTexCoord4dv               = \tdllTexCoord4dv               = GPA(g_hGLDLL, \"glTexCoord4dv\" );\n\tqglTexCoord4f                = \tdllTexCoord4f                = GPA(g_hGLDLL, \"glTexCoord4f\" );\n\tqglTexCoord4fv               = \tdllTexCoord4fv               = GPA(g_hGLDLL, \"glTexCoord4fv\" );\n\tqglTexCoord4i                = \tdllTexCoord4i                = GPA(g_hGLDLL, \"glTexCoord4i\" );\n\tqglTexCoord4iv               = \tdllTexCoord4iv               = GPA(g_hGLDLL, \"glTexCoord4iv\" );\n\tqglTexCoord4s                = \tdllTexCoord4s                = GPA(g_hGLDLL, \"glTexCoord4s\" );\n\tqglTexCoord4sv               = \tdllTexCoord4sv               = GPA(g_hGLDLL, \"glTexCoord4sv\" );\n\tqglTexCoordPointer           = \tdllTexCoordPointer           = GPA(g_hGLDLL, \"glTexCoordPointer\" );\n\tqglTexEnvf                   = \tdllTexEnvf                   = GPA(g_hGLDLL, \"glTexEnvf\" );\n\tqglTexEnvfv                  = \tdllTexEnvfv                  = GPA(g_hGLDLL, \"glTexEnvfv\" );\n\tqglTexEnvi                   = \tdllTexEnvi                   = GPA(g_hGLDLL, \"glTexEnvi\" );\n\tqglTexEnviv                  = \tdllTexEnviv                  = GPA(g_hGLDLL, \"glTexEnviv\" );\n\tqglTexGend                   = \tdllTexGend                   = GPA(g_hGLDLL, \"glTexGend\" );\n\tqglTexGendv                  = \tdllTexGendv                  = GPA(g_hGLDLL, \"glTexGendv\" );\n\tqglTexGenf                   = \tdllTexGenf                   = GPA(g_hGLDLL, \"glTexGenf\" );\n\tqglTexGenfv                  = \tdllTexGenfv                  = GPA(g_hGLDLL, \"glTexGenfv\" );\n\tqglTexGeni                   = \tdllTexGeni                   = GPA(g_hGLDLL, \"glTexGeni\" );\n\tqglTexGeniv                  = \tdllTexGeniv                  = GPA(g_hGLDLL, \"glTexGeniv\" );\n\tqglTexImage1D                = \tdllTexImage1D                = GPA(g_hGLDLL, \"glTexImage1D\" );\n\tqglTexImage2D                = \tdllTexImage2D                = GPA(g_hGLDLL, \"glTexImage2D\" );\n\tqglTexParameterf             = \tdllTexParameterf             = GPA(g_hGLDLL, \"glTexParameterf\" );\n\tqglTexParameterfv            = \tdllTexParameterfv            = GPA(g_hGLDLL, \"glTexParameterfv\" );\n\tqglTexParameteri             = \tdllTexParameteri             = GPA(g_hGLDLL, \"glTexParameteri\" );\n\tqglTexParameteriv            = \tdllTexParameteriv            = GPA(g_hGLDLL, \"glTexParameteriv\" );\n\tqglTexSubImage1D             = \tdllTexSubImage1D             = GPA(g_hGLDLL, \"glTexSubImage1D\" );\n\tqglTexSubImage2D             = \tdllTexSubImage2D             = GPA(g_hGLDLL, \"glTexSubImage2D\" );\n\tqglTranslated                = \tdllTranslated                = GPA(g_hGLDLL, \"glTranslated\" );\n\tqglTranslatef                = \tdllTranslatef                = GPA(g_hGLDLL, \"glTranslatef\" );\n\tqglVertex2d                  = \tdllVertex2d                  = GPA(g_hGLDLL, \"glVertex2d\" );\n\tqglVertex2dv                 = \tdllVertex2dv                 = GPA(g_hGLDLL, \"glVertex2dv\" );\n\tqglVertex2f                  = \tdllVertex2f                  = GPA(g_hGLDLL, \"glVertex2f\" );\n\tqglVertex2fv                 = \tdllVertex2fv                 = GPA(g_hGLDLL, \"glVertex2fv\" );\n\tqglVertex2i                  = \tdllVertex2i                  = GPA(g_hGLDLL, \"glVertex2i\" );\n\tqglVertex2iv                 = \tdllVertex2iv                 = GPA(g_hGLDLL, \"glVertex2iv\" );\n\tqglVertex2s                  = \tdllVertex2s                  = GPA(g_hGLDLL, \"glVertex2s\" );\n\tqglVertex2sv                 = \tdllVertex2sv                 = GPA(g_hGLDLL, \"glVertex2sv\" );\n\tqglVertex3d                  = \tdllVertex3d                  = GPA(g_hGLDLL, \"glVertex3d\" );\n\tqglVertex3dv                 = \tdllVertex3dv                 = GPA(g_hGLDLL, \"glVertex3dv\" );\n\tqglVertex3f                  = \tdllVertex3f                  = GPA(g_hGLDLL, \"glVertex3f\" );\n\tqglVertex3fv                 = \tdllVertex3fv                 = GPA(g_hGLDLL, \"glVertex3fv\" );\n\tqglVertex3i                  = \tdllVertex3i                  = GPA(g_hGLDLL, \"glVertex3i\" );\n\tqglVertex3iv                 = \tdllVertex3iv                 = GPA(g_hGLDLL, \"glVertex3iv\" );\n\tqglVertex3s                  = \tdllVertex3s                  = GPA(g_hGLDLL, \"glVertex3s\" );\n\tqglVertex3sv                 = \tdllVertex3sv                 = GPA(g_hGLDLL, \"glVertex3sv\" );\n\tqglVertex4d                  = \tdllVertex4d                  = GPA(g_hGLDLL, \"glVertex4d\" );\n\tqglVertex4dv                 = \tdllVertex4dv                 = GPA(g_hGLDLL, \"glVertex4dv\" );\n\tqglVertex4f                  = \tdllVertex4f                  = GPA(g_hGLDLL, \"glVertex4f\" );\n\tqglVertex4fv                 = \tdllVertex4fv                 = GPA(g_hGLDLL, \"glVertex4fv\" );\n\tqglVertex4i                  = \tdllVertex4i                  = GPA(g_hGLDLL, \"glVertex4i\" );\n\tqglVertex4iv                 = \tdllVertex4iv                 = GPA(g_hGLDLL, \"glVertex4iv\" );\n\tqglVertex4s                  = \tdllVertex4s                  = GPA(g_hGLDLL, \"glVertex4s\" );\n\tqglVertex4sv                 = \tdllVertex4sv                 = GPA(g_hGLDLL, \"glVertex4sv\" );\n\tqglVertexPointer             = \tdllVertexPointer             = GPA(g_hGLDLL, \"glVertexPointer\" );\n\tqglViewport                  = \tdllViewport                  = GPA(g_hGLDLL, \"glViewport\" );\n\n\tqwglCopyContext              = GPA(g_hGLDLL, \"wglCopyContext\" );\n\tqwglCreateContext            = GPA(g_hGLDLL, \"wglCreateContext\" );\n\tqwglCreateLayerContext       = GPA(g_hGLDLL, \"wglCreateLayerContext\" );\n\tqwglDeleteContext            = GPA(g_hGLDLL, \"wglDeleteContext\" );\n\tqwglDescribeLayerPlane       = GPA(g_hGLDLL, \"wglDescribeLayerPlane\" );\n\tqwglGetCurrentContext        = GPA(g_hGLDLL, \"wglGetCurrentContext\" );\n\tqwglGetCurrentDC             = GPA(g_hGLDLL, \"wglGetCurrentDC\" );\n\tqwglGetLayerPaletteEntries   = GPA(g_hGLDLL, \"wglGetLayerPaletteEntries\" );\n\tqwglGetProcAddress           = GPA(g_hGLDLL, \"wglGetProcAddress\" );\n\tqwglMakeCurrent              = GPA(g_hGLDLL, \"wglMakeCurrent\" );\n\tqwglRealizeLayerPalette      = GPA(g_hGLDLL, \"wglRealizeLayerPalette\" );\n\tqwglSetLayerPaletteEntries   = GPA(g_hGLDLL, \"wglSetLayerPaletteEntries\" );\n\tqwglShareLists               = GPA(g_hGLDLL, \"wglShareLists\" );\n\tqwglSwapLayerBuffers         = GPA(g_hGLDLL, \"wglSwapLayerBuffers\" );\n\tqwglUseFontBitmaps           = GPA(g_hGLDLL, \"wglUseFontBitmapsA\" );\n\tqwglUseFontOutlines          = GPA(g_hGLDLL, \"wglUseFontOutlinesA\" );\n\n\tqwglChoosePixelFormat        = GPA(g_hGLDLL, \"wglChoosePixelFormat\" );\n\tqwglDescribePixelFormat      = GPA(g_hGLDLL, \"wglDescribePixelFormat\" );\n\tqwglGetPixelFormat           = GPA(g_hGLDLL, \"wglGetPixelFormat\" );\n\tqwglSetPixelFormat           = GPA(g_hGLDLL, \"wglSetPixelFormat\" );\n\tqwglSwapBuffers              = GPA(g_hGLDLL, \"wglSwapBuffers\" );\n\n\tqwglSwapIntervalEXT = 0;\n\tqglPointParameterfEXT = 0;\n\tqglPointParameterfvEXT = 0;\n\tqglColorTableEXT = 0;\n\tqglSelectTextureSGIS = 0;\n\tqglMTexCoord2fSGIS = 0;\n\n\treturn true;\n}\n\n#pragma warning (default : 4113 4133 4047 )\n\n\n\n"
  },
  {
    "path": "q3radiant/RADBSP.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//-----------------------------------------------------------------------------\n// #includes follow...\n//-----------------------------------------------------------------------------\n//\n#include \"StdAfx.h\"                       // For: Precompiled Headers\n//\n//-----------------------------------------------------------------------------\n// #defines, consts, etc follow...\n//-----------------------------------------------------------------------------\n//\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n//\n//-----------------------------------------------------------------------------\n// Implementation follows...\n//-----------------------------------------------------------------------------\n//\n\n// msvc 5.xx does not do well optimizing this code\n#pragma optimize(\"\",off)\n\nHINSTANCE g_hQBSPDLL = NULL;\n\ntypedef void (WINAPI* PFN_QBSP)(char*, HWND, const char*);\n\nvoid RunTools(char* pCommandLine, HWND hwnd, const char* pPAKFile)\n{\n  static PFN_QBSP lpfnQBSP = NULL;\n  if (g_hQBSPDLL == NULL)\n    g_hQBSPDLL = ::LoadLibrary(\"qbspdll.dll\");\n  else\n  {\n    ::FreeLibrary(g_hQBSPDLL);\n    g_hQBSPDLL = ::LoadLibrary(\"qbspdll.dll\");\n    lpfnQBSP = NULL;\n  }\n  if (g_hQBSPDLL != NULL)\n  {\n    if (lpfnQBSP == NULL && g_hQBSPDLL != NULL)\n    {\n      FARPROC pFunction = ::GetProcAddress(g_hQBSPDLL, \"FullProcess\");\n      lpfnQBSP = reinterpret_cast<PFN_QBSP>(pFunction);\n    }\n    if (lpfnQBSP != NULL)\n    {\n      (*lpfnQBSP)(pCommandLine, hwnd, pPAKFile);\n    }\n  }\n}\n\n\n#pragma optimize(\"\",on)\n\n"
  },
  {
    "path": "q3radiant/RADEditView.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// RADEditView.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"RADEditView.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CRADEditView\n\nIMPLEMENT_DYNCREATE(CRADEditView, CEditView)\n\nCRADEditView::CRADEditView()\n{\n}\n\nCRADEditView::~CRADEditView()\n{\n}\n\n\nBEGIN_MESSAGE_MAP(CRADEditView, CEditView)\n\t//{{AFX_MSG_MAP(CRADEditView)\n\tON_CONTROL_REFLECT(EN_CHANGE, OnChange)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CRADEditView drawing\n\nvoid CRADEditView::OnDraw(CDC* pDC)\n{\n\tCDocument* pDoc = GetDocument();\n\t// TODO: add draw code here\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// CRADEditView diagnostics\n\n#ifdef _DEBUG\nvoid CRADEditView::AssertValid() const\n{\n\tCEditView::AssertValid();\n}\n\nvoid CRADEditView::Dump(CDumpContext& dc) const\n{\n\tCEditView::Dump(dc);\n}\n#endif //_DEBUG\n\n/////////////////////////////////////////////////////////////////////////////\n// CRADEditView message handlers\n\nvoid CRADEditView::OnChange() \n{\n}\n"
  },
  {
    "path": "q3radiant/RADEditView.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_RADEDITVIEW_H__DC829123_812D_11D1_B548_00AA00A410FC__INCLUDED_)\n#define AFX_RADEDITVIEW_H__DC829123_812D_11D1_B548_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// RADEditView.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CRADEditView view\n\nclass CRADEditView : public CEditView\n{\npublic:\n\tCRADEditView();           // protected constructor used by dynamic creation\n\tDECLARE_DYNCREATE(CRADEditView)\nprotected:\n\n// Attributes\npublic:\n\n// Operations\npublic:\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CRADEditView)\n\tprotected:\n\tvirtual void OnDraw(CDC* pDC);      // overridden to draw this view\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\tvirtual ~CRADEditView();\n#ifdef _DEBUG\n\tvirtual void AssertValid() const;\n\tvirtual void Dump(CDumpContext& dc) const;\n#endif\n\n\t// Generated message map functions\nprotected:\n\t//{{AFX_MSG(CRADEditView)\n\tafx_msg void OnChange();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n/////////////////////////////////////////////////////////////////////////////\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_RADEDITVIEW_H__DC829123_812D_11D1_B548_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/RADEditWnd.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// RADEditWnd.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"RADEditWnd.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CRADEditWnd\n\nCRADEditWnd::CRADEditWnd()\n{\n}\n\nCRADEditWnd::~CRADEditWnd()\n{\n}\n\n\nBEGIN_MESSAGE_MAP(CRADEditWnd, CWnd)\n\t//{{AFX_MSG_MAP(CRADEditWnd)\n\tON_WM_CREATE()\n\tON_WM_SIZE()\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n\n/////////////////////////////////////////////////////////////////////////////\n// CRADEditWnd message handlers\n\nint CRADEditWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) \n{\n\tif (CWnd::OnCreate(lpCreateStruct) == -1)\n\t\treturn -1;\n\n  CRect rctClient;\n  GetClientRect(rctClient);\n  m_wndEdit.Create(WS_CHILD | WS_VSCROLL | ES_AUTOHSCROLL | ES_MULTILINE | WS_VISIBLE, rctClient, this, 101);\n\treturn 0;\n}\n\nvoid CRADEditWnd::OnSize(UINT nType, int cx, int cy) \n{\n\tCWnd::OnSize(nType, cx, cy);\n  CRect rctClient;\n  GetClientRect(rctClient);\n  m_wndEdit.SetWindowPos(NULL, rctClient.left, rctClient.top, rctClient.Width(), rctClient.Height(), SWP_SHOWWINDOW);\n}\n"
  },
  {
    "path": "q3radiant/RADEditWnd.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_RADEDITWND_H__DC829124_812D_11D1_B548_00AA00A410FC__INCLUDED_)\n#define AFX_RADEDITWND_H__DC829124_812D_11D1_B548_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// RADEditWnd.h : header file\n//\n\n#include \"EditWnd.h\"\n/////////////////////////////////////////////////////////////////////////////\n// CRADEditWnd window\n\nclass CRADEditWnd : public CWnd\n{\n// Construction\npublic:\n\tCRADEditWnd();\n\n// Attributes\npublic:\n  CEdit* GetEditWnd() {return dynamic_cast<CEdit*>(&m_wndEdit); };\nprotected:\n  CEditWnd m_wndEdit;\n// Operations\npublic:\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CRADEditWnd)\n\t//}}AFX_VIRTUAL\n\n// Implementation\npublic:\n\tvirtual ~CRADEditWnd();\n\n\n\t// Generated message map functions\nprotected:\n\t//{{AFX_MSG(CRADEditWnd)\n\tafx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);\n\tafx_msg void OnSize(UINT nType, int cx, int cy);\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n/////////////////////////////////////////////////////////////////////////////\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_RADEDITWND_H__DC829124_812D_11D1_B548_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/RADKEYS.INI",
    "content": "; command mapping for QERadiant\n;\n; syntax is as follows\n; Command name = keystroke\n;\n; use +alt, shift or ctrl to modify the keys (you can combine them)\n; i.e.\n; EntityColor = k+ctrl\n;\n; the special keys are as follows\n;\n; UP        = Cursor up\n; DOWN      = Cursor down\n; LEFT      = Cursor left\n; RIGHT     = Cursor right\n; SPACE     = space\n; BACKSPACE = back space\n; ESCAPE    = escape\n; END       = end\n; INSERT    = insert\n; DELETE    = delete\n; PAGEUP    = page up\n; PAGEDOWN  = page down\n; TAB       = tab\n; RETURN    = return (enter)\n; F1..F2    = f1 .. f12\n\n\n[Commands]\nEntityColor = K\nCameraForward = UP\nCameraBack = DOWN\nCameraLeft = LEFT\nCameraRight = RIGHT\nCameraUp = D\nCameraDown = C\nCameraAngleUp = A\nCameraAngleDown = Z\nCameraStrafeRight = ,\nCameraStrafeLeft = .\nToggleGrid = 0\nSetGrid1 = 1\nSetGrid2 = 2\nSetGrid4 = 3\nSetGrid8 = 4\nSetGrid16 = 5\nSetGrid32 = 6\nSetGrid64 = 7\nDragEdges = E\nDragVertices = V\nViewEntityInfo = N\nViewConsole = O\nViewTextures = T\nSurfaceInspector = S\nCloneSelection = SPACE\nDeleteSelection = BACKSPACE\nUnSelectSelection = ESCAPE\nCenterView = END\nZoomOut = INSERT\nZoomIn = DELETE\nUpFloor = PAGEUP\nDownFloor = PAGEDOWN\nToggleClipper = X\nToggleRealtime = R\nEntityList = L\nMapInfo = M\n\n"
  },
  {
    "path": "q3radiant/Radiant.clw",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n; CLW file contains information for the MFC ClassWizard\n\n[General Info]\nVersion=1\nLastClass=CRadiantApp\nLastTemplate=CDialog\nNewFileInclude1=#include \"stdafx.h\"\nNewFileInclude2=#include \"Radiant.h\"\nLastPage=0\n\nClassCount=40\nClass1=CRadiantApp\nClass2=CRadiantDoc\nClass3=CRadiantView\nClass4=CMainFrame\nClass7=CZWnd\nClass8=CCamWnd\n\nResourceCount=56\nResource1=IDR_MENU_DROP\nResource2=IDD_DLG_SCRIPTS\nResource3=IDD_ENTITY\nResource8=IDD_DLG_ENTITYLIST\nResource9=IDR_MENU1\nResource10=IDD_GROUPBAR\nResource11=IDD_PLAYWAVE\nResource12=IDD_GAMMA\nResource13=IDD_DLG_GROUP\nResource4=IDD_DIALOG_NEWPATCH\nResource5=IDR_POPUP_VIEW\nResource6=IDR_POPUP_GROUP\nResource7=IDD_DLG_INFORMATION\nClass9=CXYWnd\nClass10=CTexWnd\nClass11=CEditWnd\nClass5=CAboutDlg\nClass6=CChildFrame\nResource14=IDR_MINIACCEL\nClass12=CLstToolBar\nResource15=IDR_MENU11\nResource16=IDR_TOOLBAR_ADVANCED\nClass13=CRotateDlg\nClass14=CPrefsDlg\nClass15=CRADEditView\nClass16=CRADEditWnd\nResource17=IDD_TEXTUREBAR\nResource18=IDD_SURFACE\nClass17=CMapInfo\nResource19=IDD_DIALOG_CAP\nClass18=CEntityListDlg\nResource20=IDR_RADIANTYPE\nClass19=CScriptDlg\nResource21=IDR_POPUP_TEXTURE\nClass20=CNewProjDlg\nResource22=IDR_TOOLBAR_SCALELOCK\nClass21=CCommandsDlg\nResource23=IDD_DIALOG2\nResource24=IDR_MAINFRAME\nResource25=IDR_POPUP_SELECTION\nClass22=CScaleDialog\nClass23=CTexEdit\nClass24=CSurfaceDlg\nClass25=CFindTextureDlg\nResource26=IDD_DIALOG_PATCH\nResource27=IDD_TEXLIST\nClass26=CBSInput\nResource28=IDD_DIALOG_SCALE\nClass27=CDialogInfo\nResource29=IDD_FINDTEXTURE\nResource30=IDR_ACCEL_SURFACE\nResource31=IDD_DIALOG_TEXTURELIST\nResource32=\"IDD_ADDCMD\"\nResource33=\"IDD_PROJECT\"\nResource34=IDD_NEWNAME\nResource35=IDD_DIALOG_THICKEN\nClass28=CTextureBar\nResource36=IDD_ABOUT\nResource37=IDD_DIALOG_TEXTURELAYOUT\nResource38=IDR_TOOLBAR1\nResource39=IDR_SHADERFRAME\nClass29=CDialogTextures\nResource40=IDD_FINDBRUSH\nClass30=CPatchDensityDlg\nResource41=IDD_DIALOG_INPUT\nClass31=CTextureLayout\nResource42=IDD_PROJECT\nClass32=CCapDialog\nResource43=IDD_DLG_COMMANDLIST\nClass33=CDialogThick\nResource44=IDD_DLG_NEWPROJECT\nClass34=CShaderEdit\nClass35=CShaderFrame\nResource45=IDD_DLG_MAPINFO\nResource46=\"IDR_SHADERFRAME\"\nResource47=\"IDR_SHADERTYPE\"\nResource48=IDR_POPUP_ENTITY\nClass36=CPatchDialog\nClass37=CWaveOpen\nResource49=IDD_DLG_PREFS\nResource50=IDD_DIALOG_STAIRS\nResource51=IDD_ROTATE\nResource52=IDD_ADDCMD\nClass38=CGroupBar\nResource53=IDR_ACCELERATOR1\nClass39=CGroupDlg\nResource54=IDD_SIDES\nResource55=IDD_DIALOG_FINDREPLACE\nClass40=CNameDlg\nResource56=IDR_MENU_QUAKE3\n\n[CLS:CRadiantApp]\nType=0\nHeaderFile=Radiant.h\nImplementationFile=Radiant.cpp\nFilter=N\nLastObject=ID_HELP\nBaseClass=CWinApp\nVirtualFilter=AC\n\n[CLS:CRadiantDoc]\nType=0\nHeaderFile=RadiantDoc.h\nImplementationFile=RadiantDoc.cpp\nFilter=N\nLastObject=CRadiantDoc\n\n[CLS:CRadiantView]\nType=0\nHeaderFile=RadiantView.h\nImplementationFile=RadiantView.cpp\nFilter=C\n\n[CLS:CMainFrame]\nType=0\nHeaderFile=MainFrm.h\nImplementationFile=MainFrm.cpp\nFilter=W\nBaseClass=CFrameWnd\nVirtualFilter=fWC\nLastObject=CMainFrame\n\n\n[CLS:CChildFrame]\nType=0\nHeaderFile=ChildFrm.h\nImplementationFile=ChildFrm.cpp\nFilter=M\n\n[CLS:CAboutDlg]\nType=0\nHeaderFile=Radiant.cpp\nImplementationFile=Radiant.cpp\nFilter=D\n\n[MNU:IDR_MAINFRAME]\nType=1\nClass=CMainFrame\nCommand1=ID_FILE_NEW\nCommand2=ID_FILE_OPEN\nCommand3=ID_FILE_PRINT_SETUP\nCommand4=ID_FILE_MRU_FILE1\nCommand5=ID_APP_EXIT\nCommand6=ID_VIEW_TOOLBAR\nCommand7=ID_VIEW_STATUS_BAR\nCommand8=ID_APP_ABOUT\nCommandCount=8\n\n[TB:IDR_MAINFRAME]\nType=1\nClass=CMainFrame\nCommand1=ID_FILE_NEW\nCommand2=ID_FILE_OPEN\nCommand3=ID_FILE_SAVE\nCommand4=ID_EDIT_CUT\nCommand5=ID_EDIT_COPY\nCommand6=ID_EDIT_PASTE\nCommand7=ID_FILE_PRINT\nCommand8=ID_APP_ABOUT\nCommandCount=8\n\n[MNU:IDR_RADIANTYPE]\nType=1\nClass=CRadiantView\nCommand1=ID_FILE_NEW\nCommand2=ID_FILE_OPEN\nCommand3=ID_FILE_CLOSE\nCommand4=ID_FILE_SAVE\nCommand5=ID_FILE_SAVE_AS\nCommand6=ID_FILE_PRINT\nCommand7=ID_FILE_PRINT_PREVIEW\nCommand8=ID_FILE_PRINT_SETUP\nCommand9=ID_FILE_MRU_FILE1\nCommand10=ID_APP_EXIT\nCommand11=ID_EDIT_UNDO\nCommand12=ID_EDIT_CUT\nCommand13=ID_EDIT_COPY\nCommand14=ID_EDIT_PASTE\nCommand15=ID_VIEW_TOOLBAR\nCommand16=ID_VIEW_STATUS_BAR\nCommand17=ID_WINDOW_NEW\nCommand18=ID_WINDOW_CASCADE\nCommand19=ID_WINDOW_TILE_HORZ\nCommand20=ID_WINDOW_ARRANGE\nCommand21=ID_APP_ABOUT\nCommandCount=21\n\n[TB:IDR_TOOLBAR1]\nType=1\nClass=?\nCommand1=ID_FILE_OPEN\nCommand2=ID_FILE_SAVE\nCommand3=ID_BRUSH_FLIPX\nCommand4=ID_BRUSH_ROTATEX\nCommand5=ID_BRUSH_FLIPY\nCommand6=ID_BRUSH_ROTATEY\nCommand7=ID_BRUSH_FLIPZ\nCommand8=ID_BRUSH_ROTATEZ\nCommand9=ID_POPUP_SELECTION\nCommand10=ID_SELECTION_CSGSUBTRACT\nCommand11=ID_SELECTION_MAKEHOLLOW\nCommand12=ID_VIEW_CHANGE\nCommand13=ID_TEXTURES_POPUP\nCommand14=ID_VIEW_CAMERATOGGLE\nCommand15=ID_VIEW_CAMERAUPDATE\nCommand16=ID_VIEW_CUBICCLIPPING\nCommand17=ID_VIEW_ENTITY\nCommand18=ID_VIEW_CLIPPER\nCommand19=ID_SELECT_MOUSEROTATE\nCommand20=ID_SELECT_MOUSESCALE\nCommand21=ID_SCALELOCKX\nCommand22=ID_SCALELOCKY\nCommand23=ID_SCALELOCKZ\nCommandCount=23\n\n[DLG:IDD_FINDTEXTURE]\nType=1\nClass=?\nControlCount=3\nControl1=IDOK,button,1342242817\nControl2=IDCANCEL,button,1342242816\nControl3=IDC_EDIT1,edit,1350631552\n\n[DLG:IDD_ENTITY]\nType=1\nClass=?\nControlCount=35\nControl1=IDC_E_LIST,listbox,1352729859\nControl2=IDC_E_COMMENT,edit,1352730628\nControl3=IDC_E_135,button,1342242816\nControl4=IDC_E_180,button,1342242816\nControl5=IDC_E_225,button,1342242816\nControl6=IDC_E_270,button,1342242816\nControl7=IDC_E_90,button,1342242816\nControl8=IDC_E_45,button,1342242816\nControl9=IDC_E_0,button,1342242816\nControl10=IDC_E_315,button,1342242816\nControl11=IDC_E_UP,button,1342242816\nControl12=IDC_E_DOWN,button,1342242816\nControl13=IDC_CHECK1,button,1476460547\nControl14=IDC_CHECK2,button,1476460547\nControl15=IDC_CHECK3,button,1476460547\nControl16=IDC_CHECK4,button,1476460547\nControl17=IDC_CHECK5,button,1476460547\nControl18=IDC_CHECK6,button,1476460547\nControl19=IDC_CHECK7,button,1476460547\nControl20=IDC_CHECK8,button,1476460547\nControl21=IDC_CHECK9,button,1342242819\nControl22=IDC_CHECK10,button,1342242819\nControl23=IDC_CHECK11,button,1342242819\nControl24=IDC_CHECK12,button,1342242819\nControl25=IDC_E_PROPS,listbox,1352729987\nControl26=IDC_E_DELPROP,button,1342242816\nControl27=IDC_E_STATUS,edit,1353779396\nControl28=IDC_STATIC_KEY,static,1342308352\nControl29=IDC_STATIC_VALUE,static,1342308352\nControl30=IDC_E_KEY_FIELD,edit,1350631552\nControl31=IDC_E_VALUE_FIELD,edit,1350631552\nControl32=IDC_BTN_HIDE,button,1342242816\nControl33=IDC_BTN_ASSIGNSOUND,button,1342242816\nControl34=IDC_BTN_ASSIGNMODEL,button,1342242816\nControl35=IDC_TAB_MODE,SysTabControl32,1350565890\n\n[DLG:IDD_GAMMA]\nType=1\nClass=?\nControlCount=4\nControl1=IDC_G_EDIT,edit,1350631552\nControl2=IDOK,button,1342242817\nControl3=IDCANCEL,button,1342242816\nControl4=IDC_STATIC,static,1342308352\n\n[DLG:IDD_FINDBRUSH]\nType=1\nClass=?\nControlCount=6\nControl1=IDOK,button,1342242817\nControl2=IDCANCEL,button,1342242816\nControl3=IDC_FIND_ENTITY,edit,1350631552\nControl4=IDC_FIND_BRUSH,edit,1350631552\nControl5=IDC_STATIC,static,1342308352\nControl6=IDC_STATIC,static,1342308352\n\n[DLG:IDD_ROTATE]\nType=1\nClass=CRotateDlg\nControlCount=12\nControl1=IDC_ROTX,edit,1350631552\nControl2=IDC_SPIN1,msctls_updown32,1342177335\nControl3=IDC_ROTY,edit,1350631552\nControl4=IDC_SPIN2,msctls_updown32,1342177335\nControl5=IDC_ROTZ,edit,1350631552\nControl6=IDC_SPIN3,msctls_updown32,1342177335\nControl7=IDOK,button,1342242817\nControl8=IDCANCEL,button,1342242816\nControl9=ID_APPLY,button,1342242816\nControl10=IDC_STATIC,static,1342308354\nControl11=IDC_STATIC,static,1342308354\nControl12=IDC_STATIC,static,1342308354\n\n[DLG:IDD_SIDES]\nType=1\nClass=?\nControlCount=4\nControl1=IDC_SIDES,edit,1350631552\nControl2=IDOK,button,1342242817\nControl3=IDCANCEL,button,1342242816\nControl4=IDC_STATIC,static,1342308352\n\n[DLG:IDD_ABOUT]\nType=1\nClass=?\nControlCount=9\nControl1=IDOK,button,1342242817\nControl2=IDC_STATIC,static,1350572558\nControl3=IDC_STATIC,button,1342177287\nControl4=IDC_ABOUT_GLVENDOR,static,1342308352\nControl5=IDC_ABOUT_GLVERSION,static,1342308352\nControl6=IDC_ABOUT_GLRENDERER,static,1342308352\nControl7=IDC_STATIC,button,1342177287\nControl8=IDC_STATIC,static,1342308364\nControl9=IDC_ABOUT_GLEXTENSIONS,edit,1476462660\n\n[DLG:IDD_SURFACE]\nType=1\nClass=CSurfaceDlg\nControlCount=103\nControl1=IDC_TEXTURE,edit,1350631552\nControl2=IDC_HSHIFT,edit,1350631552\nControl3=IDC_SPIN_HSHIFT,msctls_updown32,1342177332\nControl4=IDC_VSHIFT,edit,1350631552\nControl5=IDC_SPIN_VSHIFT,msctls_updown32,1342177332\nControl6=IDC_HSCALE,edit,1350631552\nControl7=IDC_SPIN_HSCALE,msctls_updown32,1342177332\nControl8=IDC_VSCALE,edit,1350631552\nControl9=IDC_SPIN_VSCALE,msctls_updown32,1342177332\nControl10=IDC_ROTATE,edit,1350631552\nControl11=IDC_SPIN_ROTATE,msctls_updown32,1342177332\nControl12=IDC_VALUE,edit,1350631552\nControl13=IDC_BTN_PATCHDETAILS,button,1342242816\nControl14=IDC_CHECK1,button,1342242819\nControl15=IDC_CHECK2,button,1342242819\nControl16=IDC_CHECK3,button,1342242819\nControl17=IDC_CHECK4,button,1342242819\nControl18=IDC_CHECK5,button,1342242819\nControl19=IDC_CHECK6,button,1342242819\nControl20=IDC_CHECK7,button,1342242819\nControl21=IDC_CHECK8,button,1342242819\nControl22=IDC_CHECK9,button,1342242819\nControl23=IDC_CHECK10,button,1342242819\nControl24=IDC_CHECK11,button,1342242819\nControl25=IDC_CHECK12,button,1342242819\nControl26=IDC_CHECK13,button,1342242819\nControl27=IDC_CHECK14,button,1342242819\nControl28=IDC_CHECK15,button,1342242819\nControl29=IDC_CHECK16,button,1342242819\nControl30=IDC_CHECK17,button,1342242819\nControl31=IDC_CHECK18,button,1342242819\nControl32=IDC_CHECK19,button,1342242819\nControl33=IDC_CHECK20,button,1342242819\nControl34=IDC_CHECK21,button,1342242819\nControl35=IDC_CHECK22,button,1342242819\nControl36=IDC_CHECK23,button,1342242819\nControl37=IDC_CHECK24,button,1342242819\nControl38=IDC_CHECK25,button,1342242819\nControl39=IDC_CHECK26,button,1342242819\nControl40=IDC_CHECK27,button,1342242819\nControl41=IDC_CHECK28,button,1342242819\nControl42=IDC_CHECK29,button,1342242819\nControl43=IDC_CHECK30,button,1342242819\nControl44=IDC_CHECK31,button,1342242819\nControl45=IDC_CHECK32,button,1342242819\nControl46=IDC_CHECK33,button,1342242819\nControl47=IDC_CHECK34,button,1342242819\nControl48=IDC_CHECK35,button,1342242819\nControl49=IDC_CHECK36,button,1342242819\nControl50=IDC_CHECK37,button,1342242819\nControl51=IDC_CHECK38,button,1342242819\nControl52=IDC_CHECK39,button,1342242819\nControl53=IDC_CHECK40,button,1342242819\nControl54=IDC_CHECK41,button,1342242819\nControl55=IDC_CHECK42,button,1342242819\nControl56=IDC_CHECK43,button,1342242819\nControl57=IDC_CHECK44,button,1342242819\nControl58=IDC_CHECK45,button,1342242819\nControl59=IDC_CHECK46,button,1342242819\nControl60=IDC_CHECK47,button,1342242819\nControl61=IDC_CHECK48,button,1342242819\nControl62=IDC_CHECK49,button,1342242819\nControl63=IDC_CHECK50,button,1342242819\nControl64=IDC_CHECK51,button,1342242819\nControl65=IDC_CHECK52,button,1342242819\nControl66=IDC_CHECK53,button,1342242819\nControl67=IDC_CHECK54,button,1342242819\nControl68=IDC_CHECK55,button,1342242819\nControl69=IDC_CHECK56,button,1342242819\nControl70=IDC_CHECK57,button,1342242819\nControl71=IDC_CHECK58,button,1342242819\nControl72=IDC_CHECK59,button,1342242819\nControl73=IDC_CHECK60,button,1342242819\nControl74=IDC_CHECK61,button,1342242819\nControl75=IDC_CHECK62,button,1342242819\nControl76=IDC_CHECK63,button,1342242819\nControl77=IDC_CHECK64,button,1342242819\nControl78=IDOK,button,1342242817\nControl79=IDAPPLY,button,1342242816\nControl80=ID_BTN_CANCEL,button,1342242816\nControl81=IDC_STATIC,static,1342308354\nControl82=IDC_STATIC,static,1342308354\nControl83=IDC_STATIC,static,1342308354\nControl84=IDC_STATIC,static,1342308354\nControl85=IDC_STATIC,static,1342308354\nControl86=IDC_STATIC,static,1342308352\nControl87=IDC_STATIC,button,1342177287\nControl88=IDC_STATIC,button,1342177287\nControl89=IDC_STATIC,static,1342308354\nControl90=IDC_STATIC,button,1342177287\nControl91=IDC_BTN_PATCHRESET,button,1342242816\nControl92=IDC_BTN_PATCHNATURAL,button,1342242816\nControl93=IDC_BTN_PATCHFIT,button,1342242816\nControl94=IDC_STATIC,static,1342308352\nControl95=IDC_STATIC,static,1342308352\nControl96=IDC_BTN_AXIAL,button,1342242816\nControl97=IDC_BTN_FACEFIT,button,1342242816\nControl98=IDC_EDIT_WIDTH,edit,1350639744\nControl99=IDC_SPIN_WIDTH,msctls_updown32,1342177335\nControl100=IDC_EDIT_HEIGHT,edit,1350639744\nControl101=IDC_SPIN_HEIGHT,msctls_updown32,1342177334\nControl102=IDC_STATIC,static,1342308352\nControl103=IDC_STATIC,static,1342308352\n\n[CLS:CZWnd]\nType=0\nHeaderFile=ZWnd.h\nImplementationFile=ZWnd.cpp\nBaseClass=CWnd\nFilter=W\nVirtualFilter=WC\n\n[CLS:CCamWnd]\nType=0\nHeaderFile=CamWnd.h\nImplementationFile=CamWnd.cpp\nBaseClass=CWnd\nFilter=W\nVirtualFilter=WC\nLastObject=CCamWnd\n\n[CLS:CXYWnd]\nType=0\nHeaderFile=XYWnd.h\nImplementationFile=XYWnd.cpp\nBaseClass=CWnd\nFilter=W\nVirtualFilter=WC\nLastObject=ID_SELECT_MOUSEROTATE\n\n[CLS:CTexWnd]\nType=0\nHeaderFile=TexWnd.h\nImplementationFile=TexWnd.cpp\nBaseClass=CWnd\nFilter=W\nVirtualFilter=WC\nLastObject=CTexWnd\n\n[CLS:CEditWnd]\nType=0\nHeaderFile=EditWnd.h\nImplementationFile=EditWnd.cpp\nBaseClass=CEdit\nFilter=W\nVirtualFilter=WC\n\n[CLS:CLstToolBar]\nType=0\nHeaderFile=LstToolBar.h\nImplementationFile=LstToolBar.cpp\nBaseClass=CToolBar\nFilter=W\nLastObject=CLstToolBar\n\n[MNU:IDR_POPUP_TEXTURE]\nType=1\nClass=?\nCommand1=ID_TEXTURES_WIREFRAME\nCommand2=ID_TEXTURES_FLATSHADE\nCommand3=ID_VIEW_NEAREST\nCommand4=ID_VIEW_NEARESTMIPMAP\nCommand5=ID_VIEW_LINEAR\nCommand6=ID_VIEW_BILINEAR\nCommand7=ID_VIEW_BILINEARMIPMAP\nCommand8=ID_VIEW_TRILINEAR\nCommandCount=8\n\n[MNU:IDR_POPUP_SELECTION]\nType=1\nClass=?\nCommand1=ID_SELECTION_SELECTCOMPLETETALL\nCommand2=ID_SELECTION_SELECTTOUCHING\nCommand3=ID_SELECTION_SELECTPARTIALTALL\nCommand4=ID_SELECTION_SELECTINSIDE\nCommandCount=4\n\n[MNU:IDR_POPUP_VIEW]\nType=1\nClass=?\nCommand1=ID_VIEW_XY\nCommand2=ID_VIEW_SIDE\nCommand3=ID_VIEW_FRONT\nCommandCount=3\n\n[CLS:CRotateDlg]\nType=0\nHeaderFile=RotateDlg.h\nImplementationFile=RotateDlg.cpp\nBaseClass=CDialog\nFilter=D\nVirtualFilter=dWC\nLastObject=CRotateDlg\n\n[DLG:IDD_DLG_PREFS]\nType=1\nClass=CPrefsDlg\nControlCount=81\nControl1=IDC_COMBO_WHATGAME,combobox,1344340226\nControl2=IDC_RADIO_MOUSE,button,1342308361\nControl3=IDC_RADIO2,button,1342177289\nControl4=IDC_RADIO_VIEWTYPE,button,1342308361\nControl5=IDC_RADIO_VIEWTYPE2,button,1342177289\nControl6=IDC_RADIO_VIEWTYPE3,button,1342177289\nControl7=IDC_RADIO_VIEWTYPE4,button,1342177289\nControl8=IDC_CHECK_SGIOPENGL,button,1342242819\nControl9=IDC_CHECK_BUGGYICD,button,1342242819\nControl10=IDC_CHECK_DISPLAYLISTS,button,1342242819\nControl11=IDC_CHECK_NOSTIPPLE,button,1342242819\nControl12=IDC_SLIDER_CAMSPEED,msctls_trackbar32,1342242816\nControl13=IDC_CHECK_CAMXYUPDATE,button,1342251011\nControl14=IDC_CHECK_QE4PAINTING,button,1342242819\nControl15=IDC_SLIDER_TEXTUREQUALITY,msctls_trackbar32,1342242817\nControl16=IDC_CHECK_TEXTURETOOLBAR,button,1342242819\nControl17=IDC_CHECK_TEXTURESCROLLBAR,button,1342242819\nControl18=IDC_CHECK_TEXTUREWINDOW,button,1342242819\nControl19=IDC_CHECK_RIGHTCLICK,button,1342242819\nControl20=IDC_CHECK_FACE,button,1342242819\nControl21=IDC_EDIT_ROTATION,edit,1350631552\nControl22=IDC_CHECK_ALTDRAG,button,1342242819\nControl23=IDC_CHECK_SNAPT,button,1342242819\nControl24=IDC_CHECK_MOUSECHASE,button,1342242819\nControl25=IDC_CHECK_WIDETOOLBAR,button,1342242819\nControl26=IDC_CHECK_LIGHTDRAW,button,1342242819\nControl27=IDC_CHECK_SIZEPAINT,button,1342242819\nControl28=IDC_CHECK_HICOLOR,button,1342242819\nControl29=IDC_STATIC,static,1342308352\nControl30=IDC_COMBO_SHADERS,combobox,1344339971\nControl31=IDC_EDIT_QUAKE2,edit,1350631552\nControl32=IDC_BTN_BROWSE,button,1342242816\nControl33=IDC_CHECK_INTERNALBSP,button,1342242819\nControl34=IDC_CHECK_NOCLAMP,button,1342242819\nControl35=IDC_CHECK_SNAPSHOTS,button,1342242819\nControl36=IDC_CHECK_SETGAME,button,1342242819\nControl37=IDC_CHECK_RUNQUAKE,button,1342242819\nControl38=IDC_CHECK_LOADLAST,button,1342242819\nControl39=IDC_CHECK_LOADLASTMAP,button,1342242819\nControl40=IDC_CHECK_AUTOSAVE,button,1342242819\nControl41=IDC_EDIT_AUTOSAVE,edit,1350639744\nControl42=IDC_SPIN_AUTOSAVE,msctls_updown32,1342177335\nControl43=IDC_STATIC,static,1342308352\nControl44=IDC_EDIT_STATUSPOINTSIZE,edit,1350631552\nControl45=IDC_SPIN_POINTSIZE,msctls_updown32,1342177335\nControl46=IDC_STATIC,static,1342308352\nControl47=IDC_EDIT_UNDOLEVELS,edit,1350631552\nControl48=IDC_SPIN_UNDO,msctls_updown32,1342177335\nControl49=IDC_CHECK_PAK,button,1342242819\nControl50=IDC_EDIT_PAKFILE,edit,1350631552\nControl51=IDC_BTN_BROWSEPAK,button,1342242816\nControl52=IDC_EDIT_PREFABPATH,edit,1350631552\nControl53=IDC_BTN_BROWSEPREFAB,button,1342242816\nControl54=IDC_EDIT_USERPATH,edit,1350631552\nControl55=IDC_BTN_BROWSEUSERINI,button,1342242816\nControl56=IDOK,button,1342242817\nControl57=IDCANCEL,button,1342242816\nControl58=IDC_CHECK_DLLENTITIES,button,1208034307\nControl59=IDC_CHECK_FACECOLOR,button,1208025091\nControl60=IDC_STATIC,static,1342308352\nControl61=IDC_CHECK_VERTEX,button,1208025091\nControl62=IDC_STATIC,button,1342177287\nControl63=IDC_STATIC,button,1342177287\nControl64=IDC_STATIC,button,1342177287\nControl65=IDB_VIEWDEFAULT,static,1342177294\nControl66=IDB_VIEWDEFAULT2,static,1342177294\nControl67=IDB_VIEWDEFAULT3,static,1342177294\nControl68=IDC_STATIC,button,1342177287\nControl69=IDB_VIEWDEFAULT_Z,static,1342177294\nControl70=IDC_STATIC,static,1342308352\nControl71=IDC_STATIC,static,1342308352\nControl72=IDC_STATIC,button,1342177287\nControl73=IDC_STATIC,static,1342308352\nControl74=IDC_STATIC,button,1342177287\nControl75=IDC_STATIC,static,1342308352\nControl76=IDC_STATIC,static,1342308352\nControl77=IDC_CHECK_USESHADERS,button,1208025091\nControl78=IDC_STATIC,button,1342177287\nControl79=IDC_STATIC,static,1342308352\nControl80=IDC_STATIC,static,1342308352\nControl81=IDC_STATIC,static,1342308352\n\n[CLS:CPrefsDlg]\nType=0\nHeaderFile=PrefsDlg.h\nImplementationFile=PrefsDlg.cpp\nBaseClass=CDialog\nFilter=D\nLastObject=IDC_SPIN_POINTSIZE\nVirtualFilter=dWC\n\n[CLS:CRADEditView]\nType=0\nHeaderFile=RADEditView.h\nImplementationFile=RADEditView.cpp\nBaseClass=CEditView\nFilter=C\nVirtualFilter=VWC\n\n[CLS:CRADEditWnd]\nType=0\nHeaderFile=RADEditWnd.h\nImplementationFile=RADEditWnd.cpp\nBaseClass=CWnd\nFilter=W\nVirtualFilter=WC\n\n[ACL:IDR_ACCELERATOR1]\nType=1\nClass=?\nCommand1=ID_BRUSH_3SIDED\nCommand2=ID_BRUSH_4SIDED\nCommand3=ID_BRUSH_5SIDED\nCommand4=ID_BRUSH_6SIDED\nCommand5=ID_BRUSH_7SIDED\nCommand6=ID_BRUSH_8SIDED\nCommand7=ID_BRUSH_9SIDED\nCommand8=ID_VIEW_SHOWDETAIL\nCommand9=ID_SELECTION_CONNECT\nCommand10=ID_MISC_NEXTLEAKSPOT\nCommand11=ID_SELECTION_MAKE_DETAIL\nCommand12=ID_FILE_OPEN\nCommand13=ID_MISC_PREVIOUSLEAKSPOT\nCommand14=ID_FILE_SAVE\nCommand15=ID_VIEW_ZZOOMIN\nCommand16=ID_VIEW_ZZOOMOUT\nCommand17=ID_FILE_EXIT\nCommandCount=17\n\n[DLG:IDD_DLG_MAPINFO]\nType=1\nClass=CMapInfo\nControlCount=9\nControl1=IDOK,button,1342242817\nControl2=IDC_STATIC,static,1342308352\nControl3=IDC_EDIT_TOTALBRUSHES,edit,1350639746\nControl4=IDC_STATIC,static,1342308352\nControl5=IDC_EDIT_TOTALENTITIES,edit,1350639746\nControl6=IDC_STATIC,static,1342308352\nControl7=IDC_EDIT_NET,edit,1350639746\nControl8=IDC_LIST_ENTITIES,listbox,1352728963\nControl9=IDC_STATIC,static,1342308352\n\n[CLS:CMapInfo]\nType=0\nHeaderFile=MapInfo.h\nImplementationFile=MapInfo.cpp\nBaseClass=CDialog\nFilter=D\nLastObject=ID_EDIT_MAPINFO\nVirtualFilter=dWC\n\n[ACL:IDR_MAINFRAME]\nType=1\nClass=?\nCommand1=ID_BRUSH_7SIDED\nCommand2=ID_BRUSH_8SIDED\nCommand3=ID_BRUSH_9SIDED\nCommand4=ID_VIEW_SHOWDETAIL\nCommand5=ID_SELECTION_CONNECT\nCommand6=ID_MISC_NEXTLEAKSPOT\nCommand7=ID_SELECTION_MAKE_DETAIL\nCommand8=ID_FILE_OPEN\nCommand9=ID_MISC_PREVIOUSLEAKSPOT\nCommand10=ID_FILE_SAVE\nCommand11=ID_VIEW_ZZOOMIN\nCommand12=ID_SELECTION_SELECT_NUDGEDOWN\nCommand13=ID_VIEW_ZZOOMOUT\nCommand14=ID_FILE_EXIT\nCommandCount=14\n\n[DLG:IDD_DLG_ENTITYLIST]\nType=1\nClass=CEntityListDlg\nControlCount=4\nControl1=IDOK,button,1342242817\nControl2=IDC_TREE_ENTITY,SysTreeView32,1350631431\nControl3=IDSELECT,button,1342242817\nControl4=IDC_LIST_ENTITY,SysListView32,1350664709\n\n[CLS:CEntityListDlg]\nType=0\nHeaderFile=EntityListDlg.h\nImplementationFile=EntityListDlg.cpp\nBaseClass=CDialog\nFilter=D\nVirtualFilter=dWC\nLastObject=IDC_LIST_ENTITY\n\n[DLG:IDD_DLG_SCRIPTS]\nType=1\nClass=CScriptDlg\nControlCount=6\nControl1=ID_NEW,button,1476460545\nControl2=IDOK,button,1342242816\nControl3=IDC_LIST_SCRIPTS,listbox,1352728835\nControl4=ID_EDIT,button,1476460545\nControl5=ID_RUN,button,1342242817\nControl6=IDC_STATIC,static,1342308352\n\n[CLS:CScriptDlg]\nType=0\nHeaderFile=ScriptDlg.h\nImplementationFile=ScriptDlg.cpp\nBaseClass=CDialog\nFilter=D\nVirtualFilter=dWC\nLastObject=IDC_LIST_SCRIPTS\n\n[DLG:IDD_DLG_NEWPROJECT]\nType=1\nClass=CNewProjDlg\nControlCount=6\nControl1=IDC_EDIT_NAME,edit,1350631552\nControl2=IDOK,button,1342242817\nControl3=IDCANCEL,button,1342242816\nControl4=IDC_STATIC,static,1342308352\nControl5=IDC_STATIC,static,1342308352\nControl6=IDC_CHECK1,button,1476460547\n\n[CLS:CNewProjDlg]\nType=0\nHeaderFile=NewProjDlg.h\nImplementationFile=NewProjDlg.cpp\nBaseClass=CDialog\nFilter=D\nLastObject=CNewProjDlg\nVirtualFilter=dWC\n\n[DLG:IDD_DLG_COMMANDLIST]\nType=1\nClass=CCommandsDlg\nControlCount=2\nControl1=IDOK,button,1342242817\nControl2=IDC_LIST_COMMANDS,listbox,1352728963\n\n[CLS:CCommandsDlg]\nType=0\nHeaderFile=CommandsDlg.h\nImplementationFile=CommandsDlg.cpp\nBaseClass=CDialog\nFilter=D\nVirtualFilter=dWC\nLastObject=CCommandsDlg\n\n[MNU:IDR_MENU_DROP]\nType=1\nClass=?\nCommand1=ID_SELECTION_SELECTCOMPLETETALL\nCommand2=ID_SELECTION_SELECTTOUCHING\nCommand3=ID_SELECTION_SELECTPARTIALTALL\nCommand4=ID_SELECTION_SELECTINSIDE\nCommand5=ID_DROP_GROUP_ADDTO\nCommand6=ID_DROP_GROUP_REMOVE\nCommand7=ID_DROP_GROUP_NAME\nCommand8=ID_DROP_GROUP_NEWGROUP\nCommand9=ID_SELECTION_UNGROUPENTITY\nCommand10=ID_SELECTION_MAKE_DETAIL\nCommand11=ID_SELECTION_MAKE_STRUCTURAL\nCommandCount=11\n\n[ACL:IDR_ACCEL_SURFACE]\nType=1\nClass=?\nCommand1=ID_BYEBYE\nCommandCount=1\n\n[DLG:IDD_DIALOG_SCALE]\nType=1\nClass=CScaleDialog\nControlCount=8\nControl1=IDOK,button,1342242817\nControl2=IDCANCEL,button,1342242816\nControl3=IDC_STATIC,static,1342308352\nControl4=IDC_STATIC,static,1342308352\nControl5=IDC_STATIC,static,1342308352\nControl6=IDC_EDIT_X,edit,1350631552\nControl7=IDC_EDIT_Y,edit,1350631552\nControl8=IDC_EDIT_Z,edit,1350631552\n\n[CLS:CScaleDialog]\nType=0\nHeaderFile=ScaleDialog.h\nImplementationFile=ScaleDialog.cpp\nBaseClass=CDialog\nFilter=D\nVirtualFilter=dWC\nLastObject=IDOK\n\n[CLS:CTexEdit]\nType=0\nHeaderFile=TexEdit.h\nImplementationFile=TexEdit.cpp\nBaseClass=CEdit\nFilter=W\nVirtualFilter=WC\nLastObject=CTexEdit\n\n[CLS:CSurfaceDlg]\nType=0\nHeaderFile=SurfaceDlg.h\nImplementationFile=SurfaceDlg.cpp\nBaseClass=CDialog\nFilter=D\nLastObject=CSurfaceDlg\nVirtualFilter=dWC\n\n[DLG:IDD_DIALOG_FINDREPLACE]\nType=1\nClass=CFindTextureDlg\nControlCount=10\nControl1=IDC_EDIT_FIND,edit,1350631552\nControl2=IDC_EDIT_REPLACE,edit,1350631552\nControl3=IDC_CHECK_SELECTED,button,1342242819\nControl4=IDC_CHECK_FORCE,button,1342242819\nControl5=IDOK,button,1342242817\nControl6=IDCANCEL,button,1342242816\nControl7=IDC_STATIC,static,1342308352\nControl8=IDC_STATIC,static,1342308352\nControl9=ID_BTN_APPLY,button,1342242817\nControl10=IDC_CHECK_LIVE,button,1342242819\n\n[CLS:CFindTextureDlg]\nType=0\nHeaderFile=FindTextureDlg.h\nImplementationFile=FindTextureDlg.cpp\nBaseClass=CDialog\nFilter=D\nVirtualFilter=dWC\nLastObject=CFindTextureDlg\n\n[DLG:IDD_DIALOG_STAIRS]\nType=1\nClass=?\nControlCount=6\nControl1=IDOK,button,1342242817\nControl2=IDCANCEL,button,1342242816\nControl3=IDC_STATIC,static,1342308352\nControl4=IDC_STATIC,static,1342308352\nControl5=IDC_STATIC,static,1342308352\nControl6=IDC_EDIT_ROTATION,edit,1350631552\n\n[DLG:IDD_DIALOG_INPUT]\nType=1\nClass=CBSInput\nControlCount=12\nControl1=IDOK,button,1342242817\nControl2=IDCANCEL,button,1342242816\nControl3=IDC_STATIC_FIELD1,static,1342308352\nControl4=IDC_EDIT_FIELD1,edit,1350631552\nControl5=IDC_STATIC_FIELD2,static,1342308352\nControl6=IDC_EDIT_FIELD2,edit,1350631552\nControl7=IDC_STATIC_FIELD3,static,1342308352\nControl8=IDC_EDIT_FIELD3,edit,1350631552\nControl9=IDC_STATIC_FIELD4,static,1342308352\nControl10=IDC_EDIT_FIELD4,edit,1350631552\nControl11=IDC_STATIC_FIELD5,static,1342308352\nControl12=IDC_EDIT_FIELD5,edit,1350631552\n\n[CLS:CBSInput]\nType=0\nHeaderFile=BSInput.h\nImplementationFile=BSInput.cpp\nBaseClass=CDialog\nFilter=D\nVirtualFilter=dWC\nLastObject=CBSInput\n\n[CLS:CDialogInfo]\nType=0\nHeaderFile=DialogInfo.h\nImplementationFile=DialogInfo.cpp\nBaseClass=CDialog\nFilter=D\nVirtualFilter=dWC\nLastObject=ID_SCALELOCKX\n\n[DLG:IDD_DLG_INFORMATION]\nType=1\nClass=CDialogInfo\nControlCount=1\nControl1=IDC_EDIT1,edit,1486946308\n\n[TB:IDR_TOOLBAR_SCALELOCK]\nType=1\nClass=?\nCommand1=ID_SCALELOCKX\nCommand2=ID_SCALELOCKY\nCommand3=ID_SCALELOCKZ\nCommandCount=3\n\n[DLG:\"IDD_PROJECT\"]\nType=1\nControlCount=20\nControl1=IDOK,button,1342242817\nControl2=IDCANCEL,button,1342242816\nControl3=IDC_STATIC,button,1342177287\nControl4=IDC_PRJBASEPATH,edit,1350631552\nControl5=IDC_STATIC,static,1342308352\nControl6=IDC_STATIC,static,1342308352\nControl7=IDC_PRJRSHCMD,edit,1350631552\nControl8=IDC_STATIC,static,1342308352\nControl9=IDC_PRJREMOTEBASE,edit,1350631552\nControl10=IDC_STATIC,static,1342308352\nControl11=IDC_PRJENTITYPATH,edit,1350631552\nControl12=IDC_STATIC,static,1342308352\nControl13=IDC_PRJTEXPATH,edit,1350631552\nControl14=IDC_STATIC,button,1342177287\nControl15=IDC_ADDCMD,button,1342242816\nControl16=IDC_CMD_LIST,listbox,1352728835\nControl17=IDC_REMCMD,button,1342242816\nControl18=IDC_STATIC,static,1342308352\nControl19=IDC_PRJMAPSPATH,edit,1350631552\nControl20=IDC_EDITCMD,button,1342242816\n\n[DLG:\"IDD_ADDCMD\"]\nType=1\nControlCount=6\nControl1=IDOK,button,1342242817\nControl2=IDCANCEL,button,1342242816\nControl3=IDC_CMDMENUTEXT,edit,1350631552\nControl4=IDC_CMDCOMMAND,edit,1350631552\nControl5=IDC_STATIC,static,1342308352\nControl6=IDC_STATIC,static,1342308352\n\n[DLG:IDD_ADDCMD]\nType=1\nClass=?\nControlCount=6\nControl1=IDOK,button,1342242817\nControl2=IDCANCEL,button,1342242816\nControl3=IDC_CMDMENUTEXT,edit,1350631552\nControl4=IDC_CMDCOMMAND,edit,1350631552\nControl5=IDC_STATIC,static,1342308352\nControl6=IDC_STATIC,static,1342308352\n\n[DLG:IDD_PROJECT]\nType=1\nClass=?\nControlCount=22\nControl1=IDC_PRJBASEPATH,edit,1350631552\nControl2=IDC_PRJMAPSPATH,edit,1350631552\nControl3=IDC_PRJRSHCMD,edit,1350631552\nControl4=IDC_PRJREMOTEBASE,edit,1350631552\nControl5=IDC_PRJENTITYPATH,edit,1350631552\nControl6=IDC_PRJTEXPATH,edit,1350631552\nControl7=IDC_CMD_LIST,listbox,1352728835\nControl8=IDC_ADDCMD,button,1342242816\nControl9=IDC_EDITCMD,button,1342242816\nControl10=IDC_REMCMD,button,1342242816\nControl11=IDC_CHECK_BPRIMIT,button,1342242819\nControl12=IDOK,button,1342242817\nControl13=IDCANCEL,button,1342242816\nControl14=IDC_STATIC,button,1342177287\nControl15=IDC_STATIC,static,1342308352\nControl16=IDC_STATIC,static,1342308352\nControl17=IDC_STATIC,static,1342308352\nControl18=IDC_STATIC,static,1342308352\nControl19=IDC_STATIC,static,1342308352\nControl20=IDC_STATIC,button,1342177287\nControl21=IDC_STATIC,static,1342308352\nControl22=IDC_STATIC,button,1342177287\n\n[DLG:IDD_TEXTUREBAR]\nType=1\nClass=CTextureBar\nControlCount=17\nControl1=IDC_HSHIFT,edit,1350631552\nControl2=IDC_SPIN_HSHIFT,msctls_updown32,1342177332\nControl3=IDC_VSHIFT,edit,1350631552\nControl4=IDC_SPIN_VSHIFT,msctls_updown32,1342177332\nControl5=IDC_HSCALE,edit,1350631552\nControl6=IDC_SPIN_HSCALE,msctls_updown32,1342177332\nControl7=IDC_VSCALE,edit,1350631552\nControl8=IDC_SPIN_VSCALE,msctls_updown32,1342177332\nControl9=IDC_ROTATE,edit,1350631552\nControl10=IDC_SPIN_ROTATE,msctls_updown32,1342177332\nControl11=IDC_STATIC,static,1342308352\nControl12=IDC_STATIC,static,1342308352\nControl13=IDC_STATIC,static,1342308352\nControl14=IDC_STATIC,static,1342308352\nControl15=IDC_STATIC,static,1342308352\nControl16=IDC_BTN_APPLYTEXTURESTUFF,button,1073741825\nControl17=IDC_EDIT_ROTATEAMT,edit,1350631552\n\n[CLS:CTextureBar]\nType=0\nHeaderFile=TextureBar.h\nImplementationFile=TextureBar.cpp\nBaseClass=CDialogBar\nFilter=W\nVirtualFilter=dWC\nLastObject=CTextureBar\n\n[TB:IDR_TOOLBAR_ADVANCED]\nType=1\nClass=?\nCommand1=ID_FILE_OPEN\nCommand2=ID_FILE_SAVE\nCommand3=ID_BRUSH_FLIPX\nCommand4=ID_BRUSH_ROTATEX\nCommand5=ID_BRUSH_FLIPY\nCommand6=ID_BRUSH_ROTATEY\nCommand7=ID_BRUSH_FLIPZ\nCommand8=ID_BRUSH_ROTATEZ\nCommand9=ID_SELECTION_SELECTCOMPLETETALL\nCommand10=ID_SELECTION_SELECTTOUCHING\nCommand11=ID_SELECTION_SELECTPARTIALTALL\nCommand12=ID_SELECTION_SELECTINSIDE\nCommand13=ID_SELECTION_CSGSUBTRACT\nCommand14=ID_SELECTION_CSGMERGE\nCommand15=ID_SELECTION_MAKEHOLLOW\nCommand16=ID_VIEW_CLIPPER\nCommand17=ID_VIEW_CHANGE\nCommand18=ID_TEXTURES_POPUP\nCommand19=ID_VIEW_CUBICCLIPPING\nCommand20=ID_SELECT_MOUSEROTATE\nCommand21=ID_SELECT_MOUSESCALE\nCommand22=ID_SCALELOCKX\nCommand23=ID_SCALELOCKY\nCommand24=ID_SCALELOCKZ\nCommand25=ID_DONTSELECTCURVE\nCommand26=ID_PATCH_SHOWBOUNDINGBOX\nCommand27=ID_PATCH_WIREFRAME\nCommand28=ID_PATCH_BEND\nCommand29=ID_PATCH_INSDEL\nCommand30=ID_CURVE_CAP\nCommand31=ID_PATCH_WELD\nCommand32=ID_PATCH_DRILLDOWN\nCommand33=ID_SHOW_ENTITIES\nCommandCount=33\n\n[MNU:IDR_MENU11]\nType=1\nCommand1=ID_FILE_NEW\nCommand2=ID_FILE_OPEN\nCommand3=ID_FILE_SAVE\nCommand4=ID_FILE_SAVEAS\nCommand5=ID_FILE_SAVEREGION\nCommand6=ID_FILE_NEWPROJECT\nCommand7=ID_FILE_LOADPROJECT\nCommand8=ID_FILE_PROJECTSETTINGS\nCommand9=ID_FILE_IMPORT\nCommand10=ID_FILE_POINTFILE\nCommand11=ID_FILE_EXIT\nCommand12=ID_EDIT_UNDO\nCommand13=ID_EDIT_COPYBRUSH\nCommand14=ID_EDIT_PASTEBRUSH\nCommand15=ID_EDIT_MAPINFO\nCommand16=ID_EDIT_ENTITYINFO\nCommand17=ID_BRUSH_SCRIPTS\nCommand18=ID_PREFS\nCommand19=ID_TOGGLECAMERA\nCommand20=ID_TOGGLECONSOLE\nCommand21=ID_VIEW_ENTITY\nCommand22=ID_TOGGLEVIEW\nCommand23=ID_TOGGLEVIEW_YZ\nCommand24=ID_TOGGLEVIEW_XZ\nCommand25=ID_TOGGLEZ\nCommand26=ID_VIEW_CENTER\nCommand27=ID_VIEW_UPFLOOR\nCommand28=ID_VIEW_DOWNFLOOR\nCommand29=ID_VIEW_NEXTVIEW\nCommand30=ID_VIEW_XY\nCommand31=ID_VIEW_SIDE\nCommand32=ID_VIEW_FRONT\nCommand33=ID_VIEW_100\nCommand34=ID_VIEW_ZOOMIN\nCommand35=ID_VIEW_ZOOMOUT\nCommand36=ID_VIEW_Z100\nCommand37=ID_VIEW_ZZOOMIN\nCommand38=ID_VIEW_ZZOOMOUT\nCommand39=ID_VIEW_CUBEIN\nCommand40=ID_VIEW_CUBEOUT\nCommand41=ID_VIEW_SHOWNAMES\nCommand42=ID_VIEW_SHOWBLOCKS\nCommand43=ID_VIEW_SHOWCOORDINATES\nCommand44=ID_VIEW_SHOWENT\nCommand45=ID_VIEW_SHOWPATH\nCommand46=ID_VIEW_SHOWLIGHTS\nCommand47=ID_VIEW_SHOWWATER\nCommand48=ID_VIEW_SHOWCLIP\nCommand49=ID_VIEW_SHOWWORLD\nCommand50=ID_VIEW_SHOWDETAIL\nCommand51=ID_VIEW_CUBICCLIPPING\nCommand52=ID_SELECTION_DRAGEDGES\nCommand53=ID_SELECTION_DRAGVERTECIES\nCommand54=ID_SELECTION_CLONE\nCommand55=ID_SELECTION_DESELECT\nCommand56=ID_SELECTION_DELETE\nCommand57=ID_BRUSH_FLIPX\nCommand58=ID_BRUSH_FLIPY\nCommand59=ID_BRUSH_FLIPZ\nCommand60=ID_BRUSH_ROTATEX\nCommand61=ID_BRUSH_ROTATEY\nCommand62=ID_BRUSH_ROTATEZ\nCommand63=ID_SELECTION_ARBITRARYROTATION\nCommand64=ID_SELECT_SCALE\nCommand65=ID_SELECTION_MAKEHOLLOW\nCommand66=ID_SELECTION_CSGSUBTRACT\nCommand67=ID_SELECTION_SELECTCOMPLETETALL\nCommand68=ID_SELECTION_SELECTTOUCHING\nCommand69=ID_SELECTION_SELECTPARTIALTALL\nCommand70=ID_SELECTION_SELECTINSIDE\nCommand71=ID_VIEW_CLIPPER\nCommand72=ID_CLIP_SELECTED\nCommand73=ID_SPLIT_SELECTED\nCommand74=ID_FLIP_CLIP\nCommand75=ID_SELECTION_CONNECT\nCommand76=ID_SELECTION_UNGROUPENTITY\nCommand77=ID_SELECTION_MAKE_DETAIL\nCommand78=ID_SELECTION_MAKE_STRUCTURAL\nCommand79=ID_GRID_1\nCommand80=ID_GRID_2\nCommand81=ID_GRID_4\nCommand82=ID_GRID_8\nCommand83=ID_GRID_16\nCommand84=ID_GRID_32\nCommand85=ID_GRID_64\nCommand86=ID_SNAPTOGRID\nCommand87=ID_TEXTURES_SHOWINUSE\nCommand88=ID_TEXTURES_INSPECTOR\nCommand89=ID_TEXTURES_WIREFRAME\nCommand90=ID_TEXTURES_FLATSHADE\nCommand91=ID_VIEW_NEAREST\nCommand92=ID_VIEW_NEARESTMIPMAP\nCommand93=ID_VIEW_LINEAR\nCommand94=ID_VIEW_BILINEAR\nCommand95=ID_VIEW_BILINEARMIPMAP\nCommand96=ID_VIEW_TRILINEAR\nCommand97=ID_TEXTURE_REPLACEALL\nCommand98=ID_TOGGLE_LOCK\nCommand99=ID_TOGGLE_ROTATELOCK\nCommand100=ID_TEXTURES_LOAD\nCommand101=ID_MISC_BENCHMARK\nCommand102=ID_COLOR_SETORIGINAL\nCommand103=ID_COLOR_SETQER\nCommand104=ID_COLOR_SETBLACK\nCommand105=ID_TEXTUREBK\nCommand106=ID_COLORS_XYBK\nCommand107=ID_COLORS_MAJOR\nCommand108=ID_COLORS_MINOR\nCommand109=ID_COLORS_GRIDTEXT\nCommand110=ID_COLORS_GRIDBLOCK\nCommand111=ID_COLORS_BRUSH\nCommand112=ID_COLORS_SELECTEDBRUSH\nCommand113=ID_COLORS_CLIPPER\nCommand114=ID_COLORS_VIEWNAME\nCommand115=ID_MISC_GAMMA\nCommand116=ID_MISC_FINDBRUSH\nCommand117=ID_MISC_NEXTLEAKSPOT\nCommand118=ID_MISC_PREVIOUSLEAKSPOT\nCommand119=ID_MISC_PRINTXY\nCommand120=ID_MISC_SELECTENTITYCOLOR\nCommand121=ID_REGION_OFF\nCommand122=ID_REGION_SETXY\nCommand123=ID_REGION_SETTALLBRUSH\nCommand124=ID_REGION_SETBRUSH\nCommand125=ID_REGION_SETSELECTION\nCommand126=ID_BRUSH_3SIDED\nCommand127=ID_BRUSH_4SIDED\nCommand128=ID_BRUSH_5SIDED\nCommand129=ID_BRUSH_6SIDED\nCommand130=ID_BRUSH_7SIDED\nCommand131=ID_BRUSH_8SIDED\nCommand132=ID_BRUSH_9SIDED\nCommand133=ID_BRUSH_ARBITRARYSIDED\nCommand134=ID_BRUSH_MAKECONE\nCommand135=ID_CURVE_CYLINDER\nCommand136=ID_CURVE_ENDCAP\nCommand137=ID_CURVE_BEVEL\nCommand138=ID_CURVE_SPHERE\nCommand139=ID_CURVE_HEMISPHERE\nCommand140=ID_CURVE_QUARTER\nCommand141=ID_CURVE_EIGHTHSPHERE\nCommand142=ID_CURVE_INVERTCURVE\nCommand143=ID_HELP_COMMANDLIST\nCommand144=ID_HELP_ABOUT\nCommandCount=144\n\n[MNU:IDR_MENU_QUAKE3]\nType=1\nClass=?\nCommand1=ID_FILE_NEW\nCommand2=ID_FILE_OPEN\nCommand3=ID_FILE_IMPORTMAP\nCommand4=ID_FILE_SAVE\nCommand5=ID_FILE_SAVEAS\nCommand6=ID_FILE_EXPORTMAP\nCommand7=ID_FILE_SAVEREGION\nCommand8=ID_FILE_NEWPROJECT\nCommand9=ID_FILE_LOADPROJECT\nCommand10=ID_FILE_PROJECTSETTINGS\nCommand11=ID_FILE_POINTFILE\nCommand12=ID_FILE_EXIT\nCommand13=ID_EDIT_UNDO\nCommand14=ID_EDIT_REDO\nCommand15=ID_EDIT_COPYBRUSH\nCommand16=ID_EDIT_PASTEBRUSH\nCommand17=ID_SELECTION_DELETE\nCommand18=ID_EDIT_MAPINFO\nCommand19=ID_EDIT_ENTITYINFO\nCommand20=ID_BRUSH_SCRIPTS\nCommand21=ID_EDIT_LOADPREFAB\nCommand22=ID_EDIT_SAVEPREFAB\nCommand23=ID_PREFS\nCommand24=ID_TOGGLECAMERA\nCommand25=ID_TOGGLECONSOLE\nCommand26=ID_VIEW_ENTITY\nCommand27=ID_VIEW_GROUPS\nCommand28=ID_TOGGLEVIEW\nCommand29=ID_TOGGLEVIEW_YZ\nCommand30=ID_TOGGLEVIEW_XZ\nCommand31=ID_TOGGLEZ\nCommand32=ID_VIEW_CENTER\nCommand33=ID_VIEW_UPFLOOR\nCommand34=ID_VIEW_DOWNFLOOR\nCommand35=ID_VIEW_NEXTVIEW\nCommand36=ID_VIEW_XY\nCommand37=ID_VIEW_SIDE\nCommand38=ID_VIEW_FRONT\nCommand39=ID_VIEW_100\nCommand40=ID_VIEW_ZOOMIN\nCommand41=ID_VIEW_ZOOMOUT\nCommand42=ID_VIEW_Z100\nCommand43=ID_VIEW_ZZOOMIN\nCommand44=ID_VIEW_ZZOOMOUT\nCommand45=ID_VIEW_CUBEIN\nCommand46=ID_VIEW_CUBEOUT\nCommand47=ID_VIEW_SHOWNAMES\nCommand48=ID_VIEW_SHOWBLOCKS\nCommand49=ID_VIEW_SHOWCOORDINATES\nCommand50=ID_VIEW_SHOWENT\nCommand51=ID_VIEW_SHOWPATH\nCommand52=ID_VIEW_SHOWLIGHTS\nCommand53=ID_VIEW_SHOWWATER\nCommand54=ID_VIEW_SHOWCLIP\nCommand55=ID_VIEW_SHOWHINT\nCommand56=ID_VIEW_SHOWWORLD\nCommand57=ID_VIEW_SHOWDETAIL\nCommand58=ID_VIEW_SHOWCURVES\nCommand59=ID_VIEW_SHOWCAULK\nCommand60=ID_VIEW_SHOWANGLES\nCommand61=ID_VIEW_HIDESHOW_HIDESELECTED\nCommand62=ID_VIEW_HIDESHOW_SHOWHIDDEN\nCommand63=ID_VIEW_ENTITIESAS_BOUNDINGBOX\nCommand64=ID_VIEW_ENTITIESAS_WIREFRAME\nCommand65=ID_VIEW_ENTITIESAS_SELECTEDWIREFRAME\nCommand66=ID_VIEW_ENTITIESAS_SELECTEDSKINNED\nCommand67=ID_VIEW_ENTITIESAS_SKINNED\nCommand68=ID_VIEW_ENTITIESAS_SKINNEDANDBOXED\nCommand69=ID_VIEW_CUBICCLIPPING\nCommand70=ID_VIEW_OPENGLLIGHTING\nCommand71=ID_SELECTION_DRAGEDGES\nCommand72=ID_SELECTION_DRAGVERTECIES\nCommand73=ID_SELECTION_CLONE\nCommand74=ID_SELECTION_DESELECT\nCommand75=ID_BRUSH_FLIPX\nCommand76=ID_BRUSH_FLIPY\nCommand77=ID_BRUSH_FLIPZ\nCommand78=ID_BRUSH_ROTATEX\nCommand79=ID_BRUSH_ROTATEY\nCommand80=ID_BRUSH_ROTATEZ\nCommand81=ID_SELECTION_ARBITRARYROTATION\nCommand82=ID_SELECT_SCALE\nCommand83=ID_SELECTION_MAKEHOLLOW\nCommand84=ID_SELECTION_CSGSUBTRACT\nCommand85=ID_SELECTION_CSGMERGE\nCommand86=ID_SELECTION_SELECTCOMPLETETALL\nCommand87=ID_SELECTION_SELECTTOUCHING\nCommand88=ID_SELECTION_SELECTPARTIALTALL\nCommand89=ID_SELECTION_SELECTINSIDE\nCommand90=ID_VIEW_CLIPPER\nCommand91=ID_CLIP_SELECTED\nCommand92=ID_SPLIT_SELECTED\nCommand93=ID_FLIP_CLIP\nCommand94=ID_SELECTION_CONNECT\nCommand95=ID_SELECTION_UNGROUPENTITY\nCommand96=ID_SELECTION_MAKE_DETAIL\nCommand97=ID_SELECTION_MAKE_STRUCTURAL\nCommand98=ID_GRID_1\nCommand99=ID_GRID_2\nCommand100=ID_GRID_4\nCommand101=ID_GRID_8\nCommand102=ID_GRID_16\nCommand103=ID_GRID_32\nCommand104=ID_GRID_64\nCommand105=ID_SNAPTOGRID\nCommand106=ID_TEXTURES_SHOWINUSE\nCommand107=ID_TEXTURES_SHOWALL\nCommand108=ID_TEXTURES_INSPECTOR\nCommand109=ID_TEXTURES_WIREFRAME\nCommand110=ID_TEXTURES_FLATSHADE\nCommand111=ID_VIEW_NEAREST\nCommand112=ID_VIEW_NEARESTMIPMAP\nCommand113=ID_VIEW_LINEAR\nCommand114=ID_VIEW_BILINEAR\nCommand115=ID_VIEW_BILINEARMIPMAP\nCommand116=ID_VIEW_TRILINEAR\nCommand117=ID_TEXTURE_REPLACEALL\nCommand118=ID_TOGGLE_LOCK\nCommand119=ID_TOGGLE_ROTATELOCK\nCommand120=ID_TEXTURES_LOAD\nCommand121=ID_TEXTURES_RELOADSHADERS\nCommand122=ID_TEXTURES_SHADERS_SHOW\nCommand123=ID_TEXTURES_FLUSH\nCommand124=ID_TEXTURES_FLUSH_UNUSED\nCommand125=ID_TEXTURES_TEXTUREWINDOWSCALE_200\nCommand126=ID_TEXTURES_TEXTUREWINDOWSCALE_100\nCommand127=ID_TEXTURES_TEXTUREWINDOWSCALE_50\nCommand128=ID_TEXTURES_TEXTUREWINDOWSCALE_25\nCommand129=ID_TEXTURES_TEXTUREWINDOWSCALE_10\nCommand130=ID_MISC_BENCHMARK\nCommand131=ID_COLOR_SETORIGINAL\nCommand132=ID_COLOR_SETQER\nCommand133=ID_COLOR_SETBLACK\nCommand134=ID_TEXTUREBK\nCommand135=ID_COLORS_XYBK\nCommand136=ID_COLORS_MAJOR\nCommand137=ID_COLORS_MINOR\nCommand138=ID_COLORS_GRIDTEXT\nCommand139=ID_COLORS_GRIDBLOCK\nCommand140=ID_COLORS_BRUSH\nCommand141=ID_COLORS_SELECTEDBRUSH\nCommand142=ID_COLORS_CLIPPER\nCommand143=ID_COLORS_VIEWNAME\nCommand144=ID_MISC_GAMMA\nCommand145=ID_MISC_FINDBRUSH\nCommand146=ID_MISC_NEXTLEAKSPOT\nCommand147=ID_MISC_PREVIOUSLEAKSPOT\nCommand148=ID_MISC_PRINTXY\nCommand149=ID_MISC_SELECTENTITYCOLOR\nCommand150=ID_REGION_OFF\nCommand151=ID_REGION_SETXY\nCommand152=ID_REGION_SETTALLBRUSH\nCommand153=ID_REGION_SETBRUSH\nCommand154=ID_REGION_SETSELECTION\nCommand155=ID_BRUSH_3SIDED\nCommand156=ID_BRUSH_4SIDED\nCommand157=ID_BRUSH_5SIDED\nCommand158=ID_BRUSH_6SIDED\nCommand159=ID_BRUSH_7SIDED\nCommand160=ID_BRUSH_8SIDED\nCommand161=ID_BRUSH_9SIDED\nCommand162=ID_BRUSH_ARBITRARYSIDED\nCommand163=ID_BRUSH_MAKECONE\nCommand164=ID_BRUSH_PRIMITIVES_SPHERE\nCommand165=ID_CURVE_PATCHTUBE\nCommand166=ID_CURVE_PATCHDENSETUBE\nCommand167=ID_CURVE_PATCHVERYDENSETUBE\nCommand168=ID_CURVE_PATCHSQUARE\nCommand169=ID_CURVE_PATCHENDCAP\nCommand170=ID_CURVE_PATCHBEVEL\nCommand171=ID_CURVE_MOREENDCAPSBEVELS_SQUAREBEVEL\nCommand172=ID_CURVE_MOREENDCAPSBEVELS_SQUAREENDCAP\nCommand173=ID_CURVE_PATCHCONE\nCommand174=ID_CURVE_PRIMITIVES_SPHERE\nCommand175=ID_CURVE_SIMPLEPATCHMESH\nCommand176=ID_CURVE_INSERT_INSERTCOLUMN\nCommand177=ID_CURVE_INSERT_ADDCOLUMN\nCommand178=ID_CURVE_INSERT_INSERTROW\nCommand179=ID_CURVE_INSERT_ADDROW\nCommand180=ID_CURVE_DELETE_FIRSTCOLUMN\nCommand181=ID_CURVE_DELETE_LASTCOLUMN\nCommand182=ID_CURVE_DELETE_FIRSTROW\nCommand183=ID_CURVE_DELETE_LASTROW\nCommand184=ID_CURVE_NEGATIVE\nCommand185=ID_CURVE_REDISPERSE_COLS\nCommand186=ID_CURVE_REDISPERSE_ROWS\nCommand187=ID_CURVE_MATRIX_TRANSPOSE\nCommand188=ID_CURVE_CAP\nCommand189=ID_CURVE_CAP_INVERTEDBEVEL\nCommand190=ID_CURVE_CAP_INVERTEDENDCAP\nCommand191=ID_CURVE_CYCLECAP\nCommand192=ID_CURVE_OVERLAY_SET\nCommand193=ID_CURVE_OVERLAY_CLEAR\nCommand194=ID_CURVE_THICKEN\nCommand195=ID_PLUGINS_REFRESH\nCommand196=ID_HELP\nCommand197=ID_HELP_COMMANDLIST\nCommand198=ID_HELP_ABOUT\nCommandCount=198\n\n[MNU:IDR_MENU1]\nType=1\nClass=?\nCommand1=ID_FILE_NEW\nCommand2=ID_FILE_OPEN\nCommand3=ID_FILE_IMPORTMAP\nCommand4=ID_FILE_SAVE\nCommand5=ID_FILE_SAVEAS\nCommand6=ID_FILE_EXPORTMAP\nCommand7=ID_FILE_SAVEREGION\nCommand8=ID_FILE_NEWPROJECT\nCommand9=ID_FILE_LOADPROJECT\nCommand10=ID_FILE_PROJECTSETTINGS\nCommand11=ID_FILE_POINTFILE\nCommand12=ID_FILE_EXIT\nCommand13=ID_EDIT_UNDO\nCommand14=ID_EDIT_COPYBRUSH\nCommand15=ID_EDIT_PASTEBRUSH\nCommand16=ID_EDIT_MAPINFO\nCommand17=ID_EDIT_ENTITYINFO\nCommand18=ID_BRUSH_SCRIPTS\nCommand19=ID_EDIT_LOADPREFAB\nCommand20=ID_PREFS\nCommand21=ID_TOGGLECAMERA\nCommand22=ID_TOGGLECONSOLE\nCommand23=ID_VIEW_ENTITY\nCommand24=ID_TOGGLEVIEW\nCommand25=ID_TOGGLEVIEW_YZ\nCommand26=ID_TOGGLEVIEW_XZ\nCommand27=ID_TOGGLEZ\nCommand28=ID_VIEW_CENTER\nCommand29=ID_VIEW_UPFLOOR\nCommand30=ID_VIEW_DOWNFLOOR\nCommand31=ID_VIEW_NEXTVIEW\nCommand32=ID_VIEW_XY\nCommand33=ID_VIEW_SIDE\nCommand34=ID_VIEW_FRONT\nCommand35=ID_VIEW_100\nCommand36=ID_VIEW_ZOOMIN\nCommand37=ID_VIEW_ZOOMOUT\nCommand38=ID_VIEW_Z100\nCommand39=ID_VIEW_ZZOOMIN\nCommand40=ID_VIEW_ZZOOMOUT\nCommand41=ID_VIEW_CUBEIN\nCommand42=ID_VIEW_CUBEOUT\nCommand43=ID_VIEW_SHOWNAMES\nCommand44=ID_VIEW_SHOWBLOCKS\nCommand45=ID_VIEW_SHOWCOORDINATES\nCommand46=ID_VIEW_SHOWENT\nCommand47=ID_VIEW_SHOWPATH\nCommand48=ID_VIEW_SHOWLIGHTS\nCommand49=ID_VIEW_SHOWWATER\nCommand50=ID_VIEW_SHOWCLIP\nCommand51=ID_VIEW_SHOWWORLD\nCommand52=ID_VIEW_SHOWDETAIL\nCommand53=ID_VIEW_CUBICCLIPPING\nCommand54=ID_DYNAMIC_LIGHTING\nCommand55=ID_SELECTION_DRAGEDGES\nCommand56=ID_SELECTION_DRAGVERTECIES\nCommand57=ID_SELECTION_CLONE\nCommand58=ID_SELECTION_DESELECT\nCommand59=ID_SELECTION_DELETE\nCommand60=ID_BRUSH_FLIPX\nCommand61=ID_BRUSH_FLIPY\nCommand62=ID_BRUSH_FLIPZ\nCommand63=ID_BRUSH_ROTATEX\nCommand64=ID_BRUSH_ROTATEY\nCommand65=ID_BRUSH_ROTATEZ\nCommand66=ID_SELECTION_ARBITRARYROTATION\nCommand67=ID_SELECT_SCALE\nCommand68=ID_SELECTION_MAKEHOLLOW\nCommand69=ID_SELECTION_CSGSUBTRACT\nCommand70=ID_SELECTION_CSGADD\nCommand71=ID_SELECTION_SELECTCOMPLETETALL\nCommand72=ID_SELECTION_SELECTTOUCHING\nCommand73=ID_SELECTION_SELECTPARTIALTALL\nCommand74=ID_SELECTION_SELECTINSIDE\nCommand75=ID_SELECTION_SELECT_NUDGELEFT\nCommand76=ID_SELECTION_SELECT_NUDGERIGHT\nCommand77=ID_SELECTION_SELECT_NUDGEUP\nCommand78=ID_SELECTION_SELECT_NUDGEDOWN\nCommand79=ID_VIEW_CLIPPER\nCommand80=ID_CLIP_SELECTED\nCommand81=ID_SPLIT_SELECTED\nCommand82=ID_FLIP_CLIP\nCommand83=ID_SELECTION_CONNECT\nCommand84=ID_SELECTION_UNGROUPENTITY\nCommand85=ID_SELECTION_MAKE_DETAIL\nCommand86=ID_SELECTION_MAKE_STRUCTURAL\nCommand87=ID_GRID_1\nCommand88=ID_GRID_2\nCommand89=ID_GRID_4\nCommand90=ID_GRID_8\nCommand91=ID_GRID_16\nCommand92=ID_GRID_32\nCommand93=ID_GRID_64\nCommand94=ID_SNAPTOGRID\nCommand95=ID_TEXTURES_SHOWINUSE\nCommand96=ID_TEXTURES_INSPECTOR\nCommand97=ID_TEXTURES_WIREFRAME\nCommand98=ID_TEXTURES_FLATSHADE\nCommand99=ID_VIEW_NEAREST\nCommand100=ID_VIEW_NEARESTMIPMAP\nCommand101=ID_VIEW_LINEAR\nCommand102=ID_VIEW_BILINEAR\nCommand103=ID_VIEW_BILINEARMIPMAP\nCommand104=ID_VIEW_TRILINEAR\nCommand105=ID_TEXTURE_REPLACEALL\nCommand106=ID_TOGGLE_LOCK\nCommand107=ID_TOGGLE_ROTATELOCK\nCommand108=ID_TEXTURES_LOAD\nCommand109=ID_TEXTURES_LOADLIST\nCommand110=ID_MISC_BENCHMARK\nCommand111=ID_COLOR_SETORIGINAL\nCommand112=ID_COLOR_SETQER\nCommand113=ID_COLOR_SETBLACK\nCommand114=ID_TEXTUREBK\nCommand115=ID_COLORS_XYBK\nCommand116=ID_COLORS_MAJOR\nCommand117=ID_COLORS_MINOR\nCommand118=ID_COLORS_GRIDTEXT\nCommand119=ID_COLORS_GRIDBLOCK\nCommand120=ID_COLORS_BRUSH\nCommand121=ID_COLORS_SELECTEDBRUSH\nCommand122=ID_COLORS_CLIPPER\nCommand123=ID_COLORS_VIEWNAME\nCommand124=ID_MISC_GAMMA\nCommand125=ID_MISC_FINDBRUSH\nCommand126=ID_MISC_NEXTLEAKSPOT\nCommand127=ID_MISC_PREVIOUSLEAKSPOT\nCommand128=ID_MISC_PRINTXY\nCommand129=ID_MISC_SELECTENTITYCOLOR\nCommand130=ID_CONVERTCURVES\nCommand131=ID_REGION_OFF\nCommand132=ID_REGION_SETXY\nCommand133=ID_REGION_SETTALLBRUSH\nCommand134=ID_REGION_SETBRUSH\nCommand135=ID_REGION_SETSELECTION\nCommand136=ID_BRUSH_3SIDED\nCommand137=ID_BRUSH_4SIDED\nCommand138=ID_BRUSH_5SIDED\nCommand139=ID_BRUSH_6SIDED\nCommand140=ID_BRUSH_7SIDED\nCommand141=ID_BRUSH_8SIDED\nCommand142=ID_BRUSH_9SIDED\nCommand143=ID_BRUSH_ARBITRARYSIDED\nCommand144=ID_BRUSH_MAKECONE\nCommand145=ID_HELP_COMMANDLIST\nCommand146=ID_HELP_ABOUT\nCommandCount=146\n\n[ACL:IDR_MINIACCEL]\nType=1\nClass=?\nCommand1=ID_SELECTION_SELECT_NUDGEDOWN\nCommand2=ID_SELECTION_SELECT_NUDGELEFT\nCommand3=ID_SELECTION_SELECT_NUDGERIGHT\nCommand4=ID_SELECTION_SELECT_NUDGEUP\nCommandCount=4\n\n[DLG:IDD_DIALOG_TEXTURELIST]\nType=1\nClass=CDialogTextures\nControlCount=3\nControl1=IDOK,button,1342242817\nControl2=IDCANCEL,button,1342242816\nControl3=IDC_LIST_TEXTURES,listbox,1352728835\n\n[CLS:CDialogTextures]\nType=0\nHeaderFile=DialogTextures.h\nImplementationFile=DialogTextures.cpp\nBaseClass=CDialog\nFilter=D\nLastObject=ID_TEXTURES_LOADLIST\nVirtualFilter=dWC\n\n[DLG:IDD_DIALOG_NEWPATCH]\nType=1\nClass=CPatchDensityDlg\nControlCount=6\nControl1=IDOK,button,1342242817\nControl2=IDCANCEL,button,1342242816\nControl3=IDC_STATIC,static,1342308352\nControl4=IDC_STATIC,static,1342308352\nControl5=IDC_COMBO_WIDTH,combobox,1344339971\nControl6=IDC_COMBO_HEIGHT,combobox,1344339971\n\n[CLS:CPatchDensityDlg]\nType=0\nHeaderFile=PatchDensityDlg.h\nImplementationFile=PatchDensityDlg.cpp\nBaseClass=CDialog\nFilter=D\nVirtualFilter=dWC\nLastObject=CPatchDensityDlg\n\n[DLG:IDD_DIALOG_TEXTURELAYOUT]\nType=1\nClass=CTextureLayout\nControlCount=7\nControl1=IDOK,button,1342242817\nControl2=IDCANCEL,button,1342242816\nControl3=IDC_STATIC,static,1342308352\nControl4=IDC_STATIC,static,1342308352\nControl5=IDC_EDIT_X,edit,1350631552\nControl6=IDC_STATIC,static,1342308352\nControl7=IDC_EDIT_Y,edit,1350631552\n\n[CLS:CTextureLayout]\nType=0\nHeaderFile=TextureLayout.h\nImplementationFile=TextureLayout.cpp\nBaseClass=CDialog\nFilter=D\nVirtualFilter=dWC\nLastObject=CTextureLayout\n\n[DLG:IDD_DIALOG_CAP]\nType=1\nClass=CCapDialog\nControlCount=10\nControl1=IDOK,button,1342242817\nControl2=IDCANCEL,button,1342242816\nControl3=IDC_RADIO_CAP,button,1342308361\nControl4=IDC_RADIO_CAP2,button,1342177289\nControl5=IDC_RADIO_CAP3,button,1342177289\nControl6=IDC_RADIO_CAP4,button,1342177289\nControl7=IDC_STATIC,static,1342183438\nControl8=IDC_STATIC,static,1342183438\nControl9=IDC_STATIC,static,1342183438\nControl10=IDC_STATIC,static,1342183438\n\n[CLS:CCapDialog]\nType=0\nHeaderFile=CapDialog.h\nImplementationFile=CapDialog.cpp\nBaseClass=CDialog\nFilter=D\nVirtualFilter=dWC\nLastObject=CCapDialog\n\n[DLG:IDD_DIALOG_THICKEN]\nType=1\nClass=CDialogThick\nControlCount=6\nControl1=IDOK,button,1342242817\nControl2=IDCANCEL,button,1342242816\nControl3=IDC_STATIC,static,1342308352\nControl4=IDC_EDIT_AMOUNT,edit,1350631552\nControl5=IDC_STATIC,static,1342308352\nControl6=IDC_CHECK_SEAMS,button,1342242819\n\n[CLS:CDialogThick]\nType=0\nHeaderFile=DialogThick.h\nImplementationFile=DialogThick.cpp\nBaseClass=CDialog\nFilter=D\nLastObject=IDC_EDIT_AMOUNT\nVirtualFilter=dWC\n\n[MNU:IDR_POPUP_ENTITY]\nType=1\nClass=?\nCommand1=ID_VIEW_ENTITIESAS_BOUNDINGBOX\nCommand2=ID_VIEW_ENTITIESAS_WIREFRAME\nCommand3=ID_VIEW_ENTITIESAS_SELECTEDWIREFRAME\nCommand4=ID_VIEW_ENTITIESAS_SELECTEDSKINNED\nCommand5=ID_VIEW_ENTITIESAS_SKINNED\nCommand6=ID_VIEW_ENTITIESAS_SKINNEDANDBOXED\nCommandCount=6\n\n[CLS:CShaderEdit]\nType=0\nHeaderFile=ShaderEdit.h\nImplementationFile=ShaderEdit.cpp\nBaseClass=CFrameWnd\nFilter=T\nVirtualFilter=fWC\n\n[CLS:CShaderFrame]\nType=0\nHeaderFile=ShaderFrame.h\nImplementationFile=ShaderFrame.cpp\nBaseClass=CFrameWnd\nFilter=T\nVirtualFilter=fWC\nLastObject=IDC_COMBO_TYPE\n\n[MNU:\"IDR_SHADERFRAME\"]\nType=1\nClass=?\nCommand1=ID_FILE_NEW\nCommand2=ID_FILE_OPEN\nCommand3=ID_FILE_PRINT_SETUP\nCommand4=ID_FILE_MRU_FILE1\nCommand5=ID_APP_EXIT\nCommand6=ID_VIEW_TOOLBAR\nCommand7=ID_VIEW_STATUS_BAR\nCommand8=ID_APP_ABOUT\nCommandCount=8\n\n[MNU:\"IDR_SHADERTYPE\"]\nType=1\nClass=?\nCommand1=ID_FILE_NEW\nCommand2=ID_FILE_OPEN\nCommand3=ID_FILE_CLOSE\nCommand4=ID_FILE_SAVE\nCommand5=ID_FILE_SAVE_AS\nCommand6=ID_FILE_PRINT\nCommand7=ID_FILE_PRINT_SETUP\nCommand8=ID_FILE_MRU_FILE1\nCommand9=ID_APP_EXIT\nCommand10=ID_EDIT_UNDO\nCommand11=ID_EDIT_CUT\nCommand12=ID_EDIT_COPY\nCommand13=ID_EDIT_PASTE\nCommand14=ID_EDIT_CLEAR\nCommand15=ID_EDIT_FIND\nCommand16=ID_EDIT_REPEAT\nCommand17=ID_EDIT_REPLACE\nCommand18=ID_EDIT_SELECT_ALL\nCommand19=ID_VIEW_TOOLBAR\nCommand20=ID_VIEW_STATUS_BAR\nCommand21=ID_WINDOW_CASCADE\nCommand22=ID_WINDOW_TILE_HORZ\nCommand23=ID_WINDOW_ARRANGE\nCommand24=ID_APP_ABOUT\nCommandCount=24\n\n[TB:IDR_SHADERFRAME]\nType=1\nClass=?\nCommand1=ID_FILE_OPEN\nCommand2=ID_FILE_SAVE\nCommand3=ID_EDIT_CUT\nCommand4=ID_EDIT_COPY\nCommand5=ID_EDIT_PASTE\nCommandCount=5\n\n[MNU:IDR_SHADERFRAME]\nType=1\nClass=?\nCommand1=ID_FILE_NEW\nCommand2=ID_FILE_OPEN\nCommand3=ID_FILE_SAVE\nCommand4=ID_FILE_SAVE_AS\nCommand5=ID_FILE_CLOSE\nCommand6=ID_EDIT_UNDO\nCommand7=ID_EDIT_CUT\nCommand8=ID_EDIT_COPY\nCommand9=ID_EDIT_PASTE\nCommand10=ID_EDIT_CLEAR\nCommand11=ID_EDIT_FIND\nCommand12=ID_EDIT_REPEAT\nCommand13=ID_EDIT_REPLACE\nCommand14=ID_EDIT_SELECT_ALL\nCommandCount=14\n\n[DLG:IDD_DIALOG_PATCH]\nType=1\nClass=CPatchDialog\nControlCount=41\nControl1=IDC_COMBO_ROW,combobox,1344340227\nControl2=IDC_COMBO_COL,combobox,1344340227\nControl3=IDC_EDIT_X,edit,1350631552\nControl4=IDC_EDIT_Y,edit,1350631552\nControl5=IDC_EDIT_Z,edit,1350631552\nControl6=IDC_EDIT_S,edit,1350631552\nControl7=IDC_EDIT_T,edit,1350631552\nControl8=IDC_COMBO_TYPE,combobox,1344340227\nControl9=IDC_EDIT_NAME,edit,1350631552\nControl10=IDC_HSHIFT,edit,1350631552\nControl11=IDC_SPIN_HSHIFT,msctls_updown32,1342177332\nControl12=IDC_VSHIFT,edit,1350631552\nControl13=IDC_SPIN_VSHIFT,msctls_updown32,1342177332\nControl14=IDC_HSCALE,edit,1350631552\nControl15=IDC_SPIN_HSCALE,msctls_updown32,1342177332\nControl16=IDC_VSCALE,edit,1350631552\nControl17=IDC_SPIN_VSCALE,msctls_updown32,1342177332\nControl18=IDC_ROTATE,edit,1350631552\nControl19=IDC_SPIN_ROTATE,msctls_updown32,1342177332\nControl20=IDC_BTN_PATCHDETAILS,button,1342242816\nControl21=IDC_BTN_PATCHRESET,button,1342242816\nControl22=IDC_BTN_PATCHNATURAL,button,1342242816\nControl23=IDC_BTN_PATCHFIT,button,1342242816\nControl24=ID_APPLY,button,1342242816\nControl25=IDOK,button,1342242817\nControl26=IDC_STATIC,static,1342308352\nControl27=IDC_STATIC,static,1342308352\nControl28=IDC_STATIC,static,1342308352\nControl29=IDC_STATIC,static,1342308352\nControl30=IDC_STATIC,static,1342308352\nControl31=IDC_STATIC,static,1342308352\nControl32=IDC_STATIC,static,1342308352\nControl33=IDC_STATIC,static,1342308352\nControl34=IDC_STATIC,static,1342308352\nControl35=IDC_STATIC,static,1342308352\nControl36=IDC_STATIC,static,1342308352\nControl37=IDC_STATIC,static,1342308352\nControl38=IDC_STATIC,static,1342308352\nControl39=IDC_STATIC,button,1342177287\nControl40=IDC_STATIC,button,1342177287\nControl41=IDC_STATIC,static,1342308352\n\n[CLS:CPatchDialog]\nType=0\nHeaderFile=PatchDialog.h\nImplementationFile=PatchDialog.cpp\nBaseClass=CDialog\nFilter=D\nVirtualFilter=dWC\nLastObject=IDC_HSHIFT\n\n[CLS:CWaveOpen]\nType=0\nHeaderFile=WaveOpen.h\nImplementationFile=WaveOpen.cpp\nBaseClass=CFileDialog\nFilter=D\nLastObject=ID_VIEW_OPENGLLIGHTING\nVirtualFilter=dWC\n\n[DLG:IDD_PLAYWAVE]\nType=1\nClass=?\nControlCount=1\nControl1=IDC_BTN_PLAY,button,1342242816\n\n[DLG:IDD_TEXLIST]\nType=1\nClass=?\nControlCount=3\nControl1=IDOK,button,1342242817\nControl2=IDCANCEL,button,1342242816\nControl3=IDC_LIST_TEXTURES,listbox,1352728835\n\n[DLG:IDD_DIALOG2]\nType=1\nClass=?\nControlCount=2\nControl1=IDOK,button,1342242817\nControl2=IDCANCEL,button,1342242816\n\n[DLG:IDD_GROUPBAR]\nType=1\nClass=CGroupBar\nControlCount=5\nControl1=IDC_COMBO_GROUPS,combobox,1344340226\nControl2=IDC_STATIC,static,1342308352\nControl3=IDC_BTN_ADDGROUP,button,1342242816\nControl4=IDC_BTN_REMOVEGROUP,button,1342242816\nControl5=IDC_BTN_LISTGROUPS,button,1342242816\n\n[CLS:CGroupBar]\nType=0\nHeaderFile=GroupBar.h\nImplementationFile=GroupBar.cpp\nBaseClass=CDialog\nFilter=D\nVirtualFilter=dWC\nLastObject=ID_TEXTURES_FLUSH_UNUSED\n\n[DLG:IDD_DLG_GROUP]\nType=1\nClass=CGroupDlg\nControlCount=4\nControl1=IDC_TREE_GROUP,SysTreeView32,1350631439\nControl2=IDC_BTN_ADD,button,1342242816\nControl3=IDC_BTN_DEL,button,1342242816\nControl4=IDC_BTN_EDIT,button,1342242816\n\n[CLS:CGroupDlg]\nType=0\nHeaderFile=GroupDlg.h\nImplementationFile=GroupDlg.cpp\nBaseClass=CDialog\nFilter=D\nLastObject=IDC_TREE_GROUP\nVirtualFilter=dWC\n\n[MNU:IDR_POPUP_GROUP]\nType=1\nClass=?\nCommand1=ID_VIEW_XY\nCommand2=ID_VIEW_SIDE\nCommand3=ID_VIEW_FRONT\nCommandCount=3\n\n[DLG:IDD_NEWNAME]\nType=1\nClass=CNameDlg\nControlCount=4\nControl1=IDC_EDIT_NAME,edit,1350631552\nControl2=IDOK,button,1342242817\nControl3=IDCANCEL,button,1342242816\nControl4=IDC_STATIC,static,1342308352\n\n[CLS:CNameDlg]\nType=0\nHeaderFile=NameDlg.h\nImplementationFile=NameDlg.cpp\nBaseClass=CDialog\nFilter=D\nLastObject=CNameDlg\nVirtualFilter=dWC\n\n"
  },
  {
    "path": "q3radiant/Radiant.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// Radiant.cpp : Defines the class behaviors for the application.\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n\n#include \"MainFrm.h\"\n#include \"ChildFrm.h\"\n#include \"RadiantDoc.h\"\n#include \"RadiantView.h\"\n#include \"PrefsDlg.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CRadiantApp\n\nBEGIN_MESSAGE_MAP(CRadiantApp, CWinApp)\n\t//{{AFX_MSG_MAP(CRadiantApp)\n\tON_COMMAND(ID_HELP, OnHelp)\n\t//}}AFX_MSG_MAP\n\t// Standard file based document commands\n\tON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)\n\tON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)\n\t// Standard print setup command\n\tON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CRadiantApp construction\n\nCRadiantApp::CRadiantApp()\n{\n\t// TODO: add construction code here,\n\t// Place all significant initialization in InitInstance\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// The one and only CRadiantApp object\n\nCRadiantApp theApp;\n\n/////////////////////////////////////////////////////////////////////////////\n// CRadiantApp initialization\n\nHINSTANCE g_hOpenGL32 = NULL;\nHINSTANCE g_hOpenGL = NULL;\nbool g_bBuildList = false;\n\nBOOL CRadiantApp::InitInstance()\n{\n  //g_hOpenGL32 = ::LoadLibrary(\"opengl32.dll\");\n\t// AfxEnableControlContainer();\n\n\t// Standard initialization\n\t// If you are not using these features and wish to reduce the size\n\t//  of your final executable, you should remove from the following\n\t//  the specific initialization routines you do not need.\n  //AfxEnableMemoryTracking(FALSE);\n\n\t// VC7 says deprecated and no longer necessary\n#if 0\n\n#ifdef _AFXDLL\n\tEnable3dControls();\t\t\t// Call this when using MFC in a shared DLL\n#else\n\tEnable3dControlsStatic();\t// Call this when linking to MFC statically\n#endif\n\n#endif\n\n\t// If there's a .INI file in the directory use it instead of registry\n\tchar RadiantPath[_MAX_PATH];\n\tGetModuleFileName( NULL, RadiantPath, _MAX_PATH );\n\n\t// search for exe\n\tCFileFind Finder;\n\tFinder.FindFile( RadiantPath );\n\tFinder.FindNextFile();\n\t// extract root\n\tCString Root = Finder.GetRoot();\n\t// build root\\*.ini\n\tCString IniPath = Root + \"\\\\REGISTRY.INI\";\n\t// search for ini file\n\tFinder.FindNextFile();\n\tif (Finder.FindFile( IniPath ))\n\t{\n\t\tFinder.FindNextFile();\n\t\t// use the .ini file instead of the registry\n\t\tfree((void*)m_pszProfileName);\n\t\tm_pszProfileName=_tcsdup(_T(Finder.GetFilePath()));\n\t\t// look for the registry key for void* buffers storage ( these can't go into .INI files )\n\t\tint i=0;\n\t\tCString key;\n\t\tHKEY hkResult;\n\t\tDWORD dwDisp;\n\t\tDWORD type;\n\t\tchar iBuf[3];\n\t\tdo\n\t\t{\n\t\t\tsprintf( iBuf, \"%d\", i );\n\t\t\tkey = \"Software\\\\Q3Radiant\\\\IniPrefs\" + CString(iBuf);\n\t\t\t// does this key exists ?\n\t\t\tif ( RegOpenKeyEx( HKEY_CURRENT_USER, key, 0, KEY_ALL_ACCESS, &hkResult ) != ERROR_SUCCESS )\n\t\t\t{\n\t\t\t\t// this key doesn't exist, so it's the one we'll use\n\t\t\t\tstrcpy( g_qeglobals.use_ini_registry, key.GetBuffer(0) );\n\t\t\t\tRegCreateKeyEx( HKEY_CURRENT_USER, key, 0, NULL, \n\t\t\t\t\tREG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkResult, &dwDisp );\n\t\t\t\tRegSetValueEx( hkResult, \"RadiantName\", 0, REG_SZ, reinterpret_cast<CONST BYTE *>(RadiantPath), strlen( RadiantPath )+1 );\n\t\t\t\tRegCloseKey( hkResult );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tchar RadiantAux[ _MAX_PATH ];\n\t\t\t\tunsigned long size = _MAX_PATH;\n\t\t\t\t// the key exists, is it the one we are looking for ?\n\t\t\t\tRegQueryValueEx( hkResult, \"RadiantName\", 0, &type, reinterpret_cast<BYTE *>(RadiantAux), &size );\n\t\t\t\tRegCloseKey( hkResult );\n\t\t\t\tif ( !strcmp( RadiantAux, RadiantPath ) )\n\t\t\t\t{\n\t\t\t\t\t// got it !\n\t\t\t\t\tstrcpy( g_qeglobals.use_ini_registry, key.GetBuffer(0) );\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\ti++;\n\t\t} while (1);\n\t\tg_qeglobals.use_ini = true;\n\t}\n\telse\n\t{\n\t\t// Change the registry key under which our settings are stored.\n\t\t// You should modify this string to be something appropriate\n\t\t// such as the name of your company or organization.\n\t\tSetRegistryKey(\"Q3Radiant\");\n\t\tg_qeglobals.use_ini = false;\n\t}\n\n\tLoadStdProfileSettings();  // Load standard INI file options (including MRU)\n\n\n\t// Register the application's document templates.  Document templates\n\t//  serve as the connection between documents, frame windows and views.\n\n//\tCMultiDocTemplate* pDocTemplate;\n//\tpDocTemplate = new CMultiDocTemplate(\n//\t\tIDR_RADIANTYPE,\n//\t\tRUNTIME_CLASS(CRadiantDoc),\n//\t\tRUNTIME_CLASS(CMainFrame), // custom MDI child frame\n//\t\tRUNTIME_CLASS(CRadiantView));\n//\tAddDocTemplate(pDocTemplate);\n\n\t// create main MDI Frame window\n\n  g_PrefsDlg.LoadPrefs();\n\n  int nMenu = IDR_MENU1;\n\n  CString strOpenGL = (g_PrefsDlg.m_bSGIOpenGL) ? \"opengl.dll\" : \"opengl32.dll\";\n  CString strGLU = (g_PrefsDlg.m_bSGIOpenGL) ? \"glu.dll\" : \"glu32.dll\";\n  \n  if (!QGL_Init(strOpenGL, strGLU))\n  {\n    g_PrefsDlg.m_bSGIOpenGL ^= 1;\n    strOpenGL = (g_PrefsDlg.m_bSGIOpenGL) ? \"opengl.dll\" : \"opengl32.dll\";\n    strGLU = (g_PrefsDlg.m_bSGIOpenGL) ? \"glu.dll\" : \"glu32.dll\";\n    if (!QGL_Init(strOpenGL, strGLU))\n    {\n      AfxMessageBox(\"Failed to load OpenGL libraries. \\\"OPENGL32.DLL\\\" and \\\"OPENGL.DLL\\\" were tried\");\n      return FALSE;\n    }\n    g_PrefsDlg.SavePrefs();\n  }\n\n\tCString strTemp = m_lpCmdLine;\n  strTemp.MakeLower();\n  if (strTemp.Find(\"builddefs\") >= 0)\n    g_bBuildList = true;\n\n\tCMainFrame* pMainFrame = new CMainFrame;\n\tif (!pMainFrame->LoadFrame(nMenu))\n\t\treturn FALSE;\n\n  if (pMainFrame->m_hAccelTable)\n    ::DestroyAcceleratorTable(pMainFrame->m_hAccelTable);\n  \n  pMainFrame->LoadAccelTable(MAKEINTRESOURCE(IDR_MINIACCEL));\n\n\tm_pMainWnd = pMainFrame;\n\n  // Parse command line for standard shell commands, DDE, file open\n\tCCommandLineInfo cmdInfo;\n\tParseCommandLine(cmdInfo);\n\n\t// Dispatch commands specified on the command line\n\t//if (!ProcessShellCommand(cmdInfo))\n\t//\treturn FALSE;\n\n\t// The main window has been initialized, so show and update it.\n\tpMainFrame->ShowWindow(m_nCmdShow);\n\tpMainFrame->UpdateWindow();\n\n  free((void*)m_pszHelpFilePath);\n  CString strHelp = g_strAppPath;\n  AddSlash(strHelp);\n  strHelp += \"Q3RManual.chm\";\n  m_pszHelpFilePath= _tcsdup(strHelp);\n\n\n\treturn TRUE;\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// CRadiantApp commands\n\nint CRadiantApp::ExitInstance() \n{\n\t// TODO: Add your specialized code here and/or call the base class\n  //::FreeLibrary(g_hOpenGL32);\n\tQGL_Shutdown();\n\treturn CWinApp::ExitInstance();\n}\n\nBOOL CRadiantApp::OnIdle(LONG lCount) \n{\n\tif (g_pParentWnd)\n    g_pParentWnd->RoutineProcessing();\n\treturn CWinApp::OnIdle(lCount);\n}\n\nvoid CRadiantApp::OnHelp() \n{\n  ShellExecute(m_pMainWnd->GetSafeHwnd(), \"open\", m_pszHelpFilePath, NULL, NULL, SW_SHOW);\n}\n"
  },
  {
    "path": "q3radiant/Radiant.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// Radiant.h : main header file for the RADIANT application\n//\n\n#if !defined(AFX_RADIANT_H__330BBF06_731C_11D1_B539_00AA00A410FC__INCLUDED_)\n#define AFX_RADIANT_H__330BBF06_731C_11D1_B539_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n\n#ifndef __AFXWIN_H__\n\t#error include 'stdafx.h' before including this file for PCH\n#endif\n\n#include \"resource.h\"       // main symbols\n\n/////////////////////////////////////////////////////////////////////////////\n// CRadiantApp:\n// See Radiant.cpp for the implementation of this class\n//\n\nclass CRadiantApp : public CWinApp\n{\npublic:\n\tCRadiantApp();\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CRadiantApp)\n\tpublic:\n\tvirtual BOOL InitInstance();\n\tvirtual int ExitInstance();\n\tvirtual BOOL OnIdle(LONG lCount);\n\t//}}AFX_VIRTUAL\n\n// Implementation\n\n\t//{{AFX_MSG(CRadiantApp)\n\tafx_msg void OnHelp();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n\n/////////////////////////////////////////////////////////////////////////////\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_RADIANT_H__330BBF06_731C_11D1_B539_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/Radiant.rc",
    "content": "//Microsoft Developer Studio generated resource script.\n//\n#include \"resource.h\"\n\n#define APSTUDIO_READONLY_SYMBOLS\n/////////////////////////////////////////////////////////////////////////////\n//\n// Generated from the TEXTINCLUDE 2 resource.\n//\n#include \"afxres.h\"\n\n/////////////////////////////////////////////////////////////////////////////\n#undef APSTUDIO_READONLY_SYMBOLS\n\n/////////////////////////////////////////////////////////////////////////////\n// English (U.S.) resources\n\n#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\n#ifdef _WIN32\nLANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\n#pragma code_page(1252)\n#endif //_WIN32\n\n#ifdef APSTUDIO_INVOKED\n/////////////////////////////////////////////////////////////////////////////\n//\n// TEXTINCLUDE\n//\n\n1 TEXTINCLUDE DISCARDABLE \nBEGIN\n    \"resource.h\\0\"\nEND\n\n2 TEXTINCLUDE DISCARDABLE \nBEGIN\n    \"#include \"\"afxres.h\"\"\\r\\n\"\n    \"\\0\"\nEND\n\n3 TEXTINCLUDE DISCARDABLE \nBEGIN\n    \"#define _AFX_NO_SPLITTER_RESOURCES\\r\\n\"\n    \"#define _AFX_NO_OLE_RESOURCES\\r\\n\"\n    \"#define _AFX_NO_TRACKER_RESOURCES\\r\\n\"\n    \"#define _AFX_NO_PROPERTY_RESOURCES\\r\\n\"\n    \"\\r\\n\"\n    \"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\\r\\n\"\n    \"#ifdef _WIN32\\r\\n\"\n    \"LANGUAGE 9, 1\\r\\n\"\n    \"#pragma code_page(1252)\\r\\n\"\n    \"#endif\\r\\n\"\n    \"#include \"\"res\\\\Radiant.rc2\"\"  // non-Microsoft Visual C++ edited resources\\r\\n\"\n    \"#include \"\"afxres.rc\"\"         // Standard components\\r\\n\"\n    \"#include \"\"afxprint.rc\"\"       // printing/print preview resources\\r\\n\"\n    \"#endif\\0\"\nEND\n\n1 TEXTINCLUDE DISCARDABLE \nBEGIN\n    \"resource.h\\0\"\nEND\n\n2 TEXTINCLUDE DISCARDABLE \nBEGIN\n    \"#include \"\"afxres.h\"\"\\r\\n\"\n    \"\\0\"\nEND\n\n3 TEXTINCLUDE DISCARDABLE \nBEGIN\n    \"\\r\\n\"\n    \"\\0\"\nEND\n\n#endif    // APSTUDIO_INVOKED\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Icon\n//\n\n// Icon with lowest ID value placed first to ensure application icon\n// remains consistent on all systems.\nIDI_ICON1               ICON    DISCARDABLE     \"res\\\\icon2.ico\"\nIDR_MAINFRAME           ICON    DISCARDABLE     \"res\\\\Radiant.ico\"\nIDR_RADIANTYPE          ICON    DISCARDABLE     \"res\\\\RadiantDoc.ico\"\nIDR_SHADERFRAME         ICON    DISCARDABLE     \"RES\\\\shaderframe.ico\"\nIDR_SHADERTYPE          ICON    DISCARDABLE     \"RES\\\\shaderdoc.ico\"\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Bitmap\n//\n\nIDR_SHADERFRAME         BITMAP  MOVEABLE PURE   \"res\\\\Toolbar.bmp\"\nIDR_TOOLBAR1            BITMAP  DISCARDABLE     \"res\\\\toolbar1.bmp\"\nIDB_BITMAP1             BITMAP  DISCARDABLE     \"res\\\\q.bmp\"\nIDB_VIEWDEFAULT         BITMAP  DISCARDABLE     \"res\\\\bitmap2.bmp\"\nIDB_VIEWQE4             BITMAP  DISCARDABLE     \"res\\\\viewdefa.bmp\"\nIDB_VIEW4WAY            BITMAP  DISCARDABLE     \"res\\\\viewoppo.bmp\"\nIDB_VIEWDEFAULT_Z       BITMAP  DISCARDABLE     \"res\\\\bmp00001.bmp\"\nIDB_3DFX                BITMAP  DISCARDABLE     \"res\\\\logo_sm3dfx.bmp\"\nIDR_TOOLBAR_SCALELOCK   BITMAP  DISCARDABLE     \"res\\\\toolbar2.bmp\"\nIDR_TOOLBAR_ADVANCED    BITMAP  DISCARDABLE     \"res\\\\bmp00002.bmp\"\nIDB_IENDCAP             BITMAP  DISCARDABLE     \"res\\\\iendcap.bmp\"\nIDB_ENDCAP              BITMAP  DISCARDABLE     \"res\\\\endcap.bmp\"\nIDB_BEVEL               BITMAP  DISCARDABLE     \"res\\\\bevel.bmp\"\nIDB_IBEVEL              BITMAP  DISCARDABLE     \"res\\\\ibevel.bmp\"\nIDB_BITMAP_GROUPS       BITMAP  DISCARDABLE     \"res\\\\bmp00003.bmp\"\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Toolbar\n//\n\nIDR_SHADERFRAME TOOLBAR DISCARDABLE  16, 15\nBEGIN\n    BUTTON      ID_FILE_OPEN\n    BUTTON      ID_FILE_SAVE\n    SEPARATOR\n    BUTTON      ID_EDIT_CUT\n    BUTTON      ID_EDIT_COPY\n    BUTTON      ID_EDIT_PASTE\nEND\n\nIDR_TOOLBAR1 TOOLBAR DISCARDABLE  16, 15\nBEGIN\n    BUTTON      ID_FILE_OPEN\n    BUTTON      ID_FILE_SAVE\n    SEPARATOR\n    BUTTON      ID_BRUSH_FLIPX\n    BUTTON      ID_BRUSH_ROTATEX\n    BUTTON      ID_BRUSH_FLIPY\n    BUTTON      ID_BRUSH_ROTATEY\n    BUTTON      ID_BRUSH_FLIPZ\n    BUTTON      ID_BRUSH_ROTATEZ\n    SEPARATOR\n    BUTTON      ID_POPUP_SELECTION\n    SEPARATOR\n    BUTTON      ID_SELECTION_CSGSUBTRACT\n    BUTTON      ID_SELECTION_MAKEHOLLOW\n    SEPARATOR\n    BUTTON      ID_VIEW_CHANGE\n    SEPARATOR\n    BUTTON      ID_TEXTURES_POPUP\n    SEPARATOR\n    BUTTON      ID_VIEW_CAMERATOGGLE\n    BUTTON      ID_VIEW_CAMERAUPDATE\n    BUTTON      ID_VIEW_CUBICCLIPPING\n    SEPARATOR\n    BUTTON      ID_VIEW_ENTITY\n    SEPARATOR\n    BUTTON      ID_VIEW_CLIPPER\n    SEPARATOR\n    BUTTON      ID_SELECT_MOUSEROTATE\n    SEPARATOR\n    BUTTON      ID_SELECT_MOUSESCALE\n    BUTTON      ID_SCALELOCKX\n    BUTTON      ID_SCALELOCKY\n    BUTTON      ID_SCALELOCKZ\nEND\n\nIDR_TOOLBAR_SCALELOCK TOOLBAR DISCARDABLE  16, 15\nBEGIN\n    BUTTON      ID_SCALELOCKX\n    BUTTON      ID_SCALELOCKY\n    BUTTON      ID_SCALELOCKZ\nEND\n\nIDR_TOOLBAR_ADVANCED TOOLBAR DISCARDABLE  16, 15\nBEGIN\n    BUTTON      ID_FILE_OPEN\n    BUTTON      ID_FILE_SAVE\n    SEPARATOR\n    BUTTON      ID_BRUSH_FLIPX\n    BUTTON      ID_BRUSH_ROTATEX\n    BUTTON      ID_BRUSH_FLIPY\n    BUTTON      ID_BRUSH_ROTATEY\n    BUTTON      ID_BRUSH_FLIPZ\n    BUTTON      ID_BRUSH_ROTATEZ\n    SEPARATOR\n    BUTTON      ID_SELECTION_SELECTCOMPLETETALL\n    BUTTON      ID_SELECTION_SELECTTOUCHING\n    BUTTON      ID_SELECTION_SELECTPARTIALTALL\n    BUTTON      ID_SELECTION_SELECTINSIDE\n    SEPARATOR\n    BUTTON      ID_SELECTION_CSGSUBTRACT\n    BUTTON      ID_SELECTION_CSGMERGE\n    BUTTON      ID_SELECTION_MAKEHOLLOW\n    BUTTON      ID_VIEW_CLIPPER\n    SEPARATOR\n    BUTTON      ID_VIEW_CHANGE\n    BUTTON      ID_TEXTURES_POPUP\n    BUTTON      ID_VIEW_CUBICCLIPPING\n    SEPARATOR\n    BUTTON      ID_SELECT_MOUSEROTATE\n    SEPARATOR\n    BUTTON      ID_SELECT_MOUSESCALE\n    SEPARATOR\n    BUTTON      ID_SCALELOCKX\n    BUTTON      ID_SCALELOCKY\n    BUTTON      ID_SCALELOCKZ\n    SEPARATOR\n    BUTTON      ID_DONTSELECTCURVE\n    BUTTON      ID_PATCH_SHOWBOUNDINGBOX\n    BUTTON      ID_PATCH_WIREFRAME\n    BUTTON      ID_PATCH_BEND\n    BUTTON      ID_PATCH_INSDEL\n    BUTTON      ID_CURVE_CAP\n    BUTTON      ID_PATCH_WELD\n    BUTTON      ID_PATCH_DRILLDOWN\n    SEPARATOR\n    BUTTON      ID_SHOW_ENTITIES\n    SEPARATOR\n    BUTTON      ID_SPLINES_POPUP\nEND\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Menu\n//\n\nIDR_SHADERFRAME MENU DISCARDABLE \nBEGIN\n    POPUP \"&File\"\n    BEGIN\n        MENUITEM \"&New\\tCtrl+N\",                ID_FILE_NEW\n        MENUITEM \"&Open...\\tCtrl+O\",            ID_FILE_OPEN\n        MENUITEM \"&Save\\tCtrl+S\",               ID_FILE_SAVE\n        MENUITEM \"Save &As...\",                 ID_FILE_SAVE_AS\n        MENUITEM SEPARATOR\n        MENUITEM \"Close\",                       ID_FILE_CLOSE\n    END\n    POPUP \"&Edit\"\n    BEGIN\n        MENUITEM \"&Undo\\tCtrl+Z\",               ID_EDIT_UNDO\n        MENUITEM SEPARATOR\n        MENUITEM \"Cu&t\\tCtrl+X\",                ID_EDIT_CUT\n        MENUITEM \"&Copy\\tCtrl+C\",               ID_EDIT_COPY\n        MENUITEM \"&Paste\\tCtrl+V\",              ID_EDIT_PASTE\n        MENUITEM \"Delete\\tDel\",                 ID_EDIT_CLEAR\n        MENUITEM SEPARATOR\n        MENUITEM \"&Find...\",                    ID_EDIT_FIND\n        MENUITEM \"Find &Next\\tF3\",              ID_EDIT_REPEAT\n        MENUITEM \"&Replace...\",                 ID_EDIT_REPLACE\n        MENUITEM SEPARATOR\n        MENUITEM \"Select &All\",                 ID_EDIT_SELECT_ALL\n    END\nEND\n\nIDR_MAINFRAME MENU PRELOAD DISCARDABLE \nBEGIN\n    POPUP \"&File\"\n    BEGIN\n        MENUITEM \"&New\\tCtrl+N\",                ID_FILE_NEW\n        MENUITEM \"&Open...\\tCtrl+O\",            ID_FILE_OPEN\n        MENUITEM SEPARATOR\n        MENUITEM \"P&rint Setup...\",             ID_FILE_PRINT_SETUP\n        MENUITEM SEPARATOR\n        MENUITEM \"Recent File\",                 ID_FILE_MRU_FILE1, GRAYED\n        MENUITEM SEPARATOR\n        MENUITEM \"E&xit\",                       ID_APP_EXIT\n    END\n    POPUP \"&View\"\n    BEGIN\n        MENUITEM \"&Toolbar\",                    ID_VIEW_TOOLBAR\n        MENUITEM \"&Status Bar\",                 ID_VIEW_STATUS_BAR\n    END\n    POPUP \"&Help\"\n    BEGIN\n        MENUITEM \"&About Radiant...\",           ID_APP_ABOUT\n    END\nEND\n\nIDR_RADIANTYPE MENU PRELOAD DISCARDABLE \nBEGIN\n    POPUP \"&File\"\n    BEGIN\n        MENUITEM \"&New\\tCtrl+N\",                ID_FILE_NEW\n        MENUITEM \"&Open...\\tCtrl+O\",            ID_FILE_OPEN\n        MENUITEM \"&Close\",                      ID_FILE_CLOSE\n        MENUITEM \"&Save\\tCtrl+S\",               ID_FILE_SAVE\n        MENUITEM \"Save &As...\",                 ID_FILE_SAVE_AS\n        MENUITEM SEPARATOR\n        MENUITEM \"&Print...\\tCtrl+P\",           ID_FILE_PRINT\n        MENUITEM \"Print Pre&view\",              ID_FILE_PRINT_PREVIEW\n        MENUITEM \"P&rint Setup...\",             ID_FILE_PRINT_SETUP\n        MENUITEM SEPARATOR\n        MENUITEM \"Recent File\",                 ID_FILE_MRU_FILE1, GRAYED\n        MENUITEM SEPARATOR\n        MENUITEM \"E&xit\",                       ID_APP_EXIT\n    END\n    POPUP \"&Edit\"\n    BEGIN\n        MENUITEM \"&Undo\\tCtrl+Z\",               ID_EDIT_UNDO\n        MENUITEM SEPARATOR\n        MENUITEM \"Cu&t\\tCtrl+X\",                ID_EDIT_CUT\n        MENUITEM \"&Copy\\tCtrl+C\",               ID_EDIT_COPY\n        MENUITEM \"&Paste\\tCtrl+V\",              ID_EDIT_PASTE\n    END\n    POPUP \"&View\"\n    BEGIN\n        MENUITEM \"&Toolbar\",                    ID_VIEW_TOOLBAR\n        MENUITEM \"&Status Bar\",                 ID_VIEW_STATUS_BAR\n    END\n    POPUP \"&Window\"\n    BEGIN\n        MENUITEM \"&New Window\",                 ID_WINDOW_NEW\n        MENUITEM \"&Cascade\",                    ID_WINDOW_CASCADE\n        MENUITEM \"&Tile\",                       ID_WINDOW_TILE_HORZ\n        MENUITEM \"&Arrange Icons\",              ID_WINDOW_ARRANGE\n    END\n    POPUP \"&Help\"\n    BEGIN\n        MENUITEM \"&About Radiant...\",           ID_APP_ABOUT\n    END\nEND\n\nIDR_MENU_QUAKE3 MENU DISCARDABLE \nBEGIN\n    POPUP \"&File\"\n    BEGIN\n        MENUITEM \"&New map\",                    ID_FILE_NEW\n        MENUITEM SEPARATOR\n        MENUITEM \"&Open...\",                    ID_FILE_OPEN\n        MENUITEM \"&Load...\",                    ID_FILE_IMPORTMAP\n        MENUITEM \"&Save\",                       ID_FILE_SAVE\n        MENUITEM \"Save &as...\",                 ID_FILE_SAVEAS\n        MENUITEM \"Save s&elected...\",           ID_FILE_EXPORTMAP\n        MENUITEM SEPARATOR\n        MENUITEM \"Save re&gion...\",             ID_FILE_SAVEREGION\n        MENUITEM SEPARATOR\n        MENUITEM \"New p&roject...\",             ID_FILE_NEWPROJECT\n        MENUITEM \"Load &project...\",            ID_FILE_LOADPROJECT\n        MENUITEM \"Pro&ject settings...\",        ID_FILE_PROJECTSETTINGS\n        MENUITEM SEPARATOR\n        MENUITEM \"&Pointfile...\",               ID_FILE_POINTFILE\n        MENUITEM SEPARATOR\n        MENUITEM \"E&xit\",                       ID_FILE_EXIT\n    END\n    POPUP \"&Edit\"\n    BEGIN\n        MENUITEM \"&Undo\\tCtrl-Z\",               ID_EDIT_UNDO\n        MENUITEM \"&Redo\\tShift-Ctrl-Z\",         ID_EDIT_REDO\n        MENUITEM SEPARATOR\n        MENUITEM \"&Copy\\tCtrl-C\",               ID_EDIT_COPYBRUSH\n        MENUITEM \"&Paste\\tCtrl-V\",              ID_EDIT_PASTEBRUSH\n        MENUITEM \"&Delete\\tBackspace\",          ID_SELECTION_DELETE\n        MENUITEM SEPARATOR\n        MENUITEM \"Map Info...\",                 ID_EDIT_MAPINFO\n        MENUITEM \"Entity Info...\",              ID_EDIT_ENTITYINFO\n        MENUITEM SEPARATOR\n        MENUITEM \"Brush Scripts...\",            ID_BRUSH_SCRIPTS\n        MENUITEM SEPARATOR\n        MENUITEM \"Load Pre&fab...\",             ID_EDIT_LOADPREFAB\n        MENUITEM \"Save Selection as Prefab...\", ID_EDIT_SAVEPREFAB\n        MENUITEM SEPARATOR\n        MENUITEM \"Preferences...\",              ID_PREFS\n    END\n    POPUP \"&View\"\n    BEGIN\n        POPUP \"Toggle\"\n        BEGIN\n            MENUITEM \"Camera View\",                 ID_TOGGLECAMERA\n            MENUITEM \"Console View\",                ID_TOGGLECONSOLE\n            MENUITEM \"Entity View\",                 ID_VIEW_ENTITY\n            MENUITEM \"Groups View\",                 ID_VIEW_GROUPS\n            MENUITEM \"XY (Top)\",                    ID_TOGGLEVIEW\n            MENUITEM \"YZ (Side)\",                   ID_TOGGLEVIEW_YZ\n            MENUITEM \"XZ (Front)\",                  ID_TOGGLEVIEW_XZ\n            MENUITEM \"Z View\",                      ID_TOGGLEZ\n        END\n        MENUITEM SEPARATOR\n        MENUITEM \"&Center\\tEnd\",                ID_VIEW_CENTER\n        MENUITEM \"&Up Floor\\tPage Up\",          ID_VIEW_UPFLOOR\n        MENUITEM \"&Down Floor\\tPage Down\",      ID_VIEW_DOWNFLOOR\n        MENUITEM SEPARATOR\n        MENUITEM \"&Next (XY, YZ, XY)\\tCtrl-TAB\", ID_VIEW_NEXTVIEW\n        POPUP \"Layout\"\n        BEGIN\n            MENUITEM \"XY (Top)\",                    ID_VIEW_XY\n            MENUITEM \"YZ\",                          ID_VIEW_SIDE\n            MENUITEM \"XZ\",                          ID_VIEW_FRONT\n        END\n        POPUP \"Zoom\"\n        BEGIN\n            MENUITEM \"&XY 100%\",                    ID_VIEW_100\n            MENUITEM \"XY Zoom &In\\tDelete\",         ID_VIEW_ZOOMIN\n            MENUITEM \"XY Zoom &Out\\tInsert\",        ID_VIEW_ZOOMOUT\n            MENUITEM SEPARATOR\n            MENUITEM \"&Z 100%\",                     ID_VIEW_Z100\n            MENUITEM \"Z Zoo&m In\\tctrl-Delete\",     ID_VIEW_ZZOOMIN\n            MENUITEM \"Z Zoom O&ut\\tctrl-Insert\",    ID_VIEW_ZZOOMOUT\n            MENUITEM SEPARATOR\n            MENUITEM \"Cubic Clip Zoom In\\tctrl-]\",  ID_VIEW_CUBEIN\n            MENUITEM \"Cubic Clip Zoom Out\\tctrl-[\", ID_VIEW_CUBEOUT\n        END\n        MENUITEM SEPARATOR\n        POPUP \"Show\"\n        BEGIN\n            MENUITEM \"Show &Names\",                 ID_VIEW_SHOWNAMES\n            , CHECKED\n            MENUITEM \"Show Blocks\",                 ID_VIEW_SHOWBLOCKS\n            MENUITEM \"Show C&oordinates\",           ID_VIEW_SHOWCOORDINATES\n            , CHECKED\n            MENUITEM \"Show &Entities\",              ID_VIEW_SHOWENT, CHECKED\n            MENUITEM \"Show &Path\",                  ID_VIEW_SHOWPATH\n            , CHECKED\n            MENUITEM \"Show &Lights\",                ID_VIEW_SHOWLIGHTS\n            , CHECKED\n            MENUITEM \"Show &Water\",                 ID_VIEW_SHOWWATER\n            , CHECKED\n            MENUITEM \"Show Clip &Brush\",            ID_VIEW_SHOWCLIP\n            , CHECKED\n            MENUITEM \"Show &Hint Brush\",            ID_VIEW_SHOWHINT\n            , CHECKED\n            MENUITEM \"Show Wor&ld\",                 ID_VIEW_SHOWWORLD\n            , CHECKED\n            MENUITEM \"Show Detail\\tctrl-D\",         ID_VIEW_SHOWDETAIL\n            , CHECKED\n            MENUITEM \"Show Curves\",                 ID_VIEW_SHOWCURVES\n            , CHECKED\n            MENUITEM \"Show Caulk\",                  ID_VIEW_SHOWCAULK\n            , CHECKED\n            MENUITEM \"Show Angles\",                 ID_VIEW_SHOWANGLES\n        END\n        POPUP \"Hide/Show\"\n        BEGIN\n            MENUITEM \"Hide Selected\",               ID_VIEW_HIDESHOW_HIDESELECTED\n\n            MENUITEM \"Show Hidden\",                 ID_VIEW_HIDESHOW_SHOWHIDDEN\n\n        END\n        MENUITEM SEPARATOR\n        POPUP \"Entities as\"\n        BEGIN\n            MENUITEM \"Bounding box\",                ID_VIEW_ENTITIESAS_BOUNDINGBOX\n\n            MENUITEM \"Wireframe\",                   ID_VIEW_ENTITIESAS_WIREFRAME\n\n            MENUITEM \"Selected Wireframe\",          ID_VIEW_ENTITIESAS_SELECTEDWIREFRAME\n\n            MENUITEM \"Selected Skinned\",            ID_VIEW_ENTITIESAS_SELECTEDSKINNED\n\n            MENUITEM \"Skinned\",                     ID_VIEW_ENTITIESAS_SKINNED\n\n            MENUITEM \"Skinned and Boxed\",           ID_VIEW_ENTITIESAS_SKINNEDANDBOXED\n\n        END\n        MENUITEM SEPARATOR\n        MENUITEM \"Cubic Clipping\",              ID_VIEW_CUBICCLIPPING\n        , CHECKED\n        MENUITEM SEPARATOR\n        MENUITEM \"OpenGL Lighting\",             ID_VIEW_OPENGLLIGHTING\n    END\n    POPUP \"&Selection\"\n    BEGIN\n        POPUP \"Drag\"\n        BEGIN\n            MENUITEM \"Drag &Edges\",                 ID_SELECTION_DRAGEDGES\n            MENUITEM \"Drag &Vertices\",              ID_SELECTION_DRAGVERTECIES\n\n        END\n        MENUITEM SEPARATOR\n        MENUITEM \"&Clone\",                      ID_SELECTION_CLONE\n        MENUITEM \"Deselect\\tEsc\",               ID_SELECTION_DESELECT\n        MENUITEM SEPARATOR\n        POPUP \"Flip\"\n        BEGIN\n            MENUITEM \"Flip &X\",                     ID_BRUSH_FLIPX\n            MENUITEM \"Flip &Y\",                     ID_BRUSH_FLIPY\n            MENUITEM \"Flip &Z\",                     ID_BRUSH_FLIPZ\n        END\n        MENUITEM SEPARATOR\n        POPUP \"Rotate\"\n        BEGIN\n            MENUITEM \"Rotate X\",                    ID_BRUSH_ROTATEX\n            MENUITEM \"Rotate Y\",                    ID_BRUSH_ROTATEY\n            MENUITEM \"Rotate Z\",                    ID_BRUSH_ROTATEZ\n            MENUITEM \"Arbitrary rotation...\",       ID_SELECTION_ARBITRARYROTATION\n\n        END\n        MENUITEM SEPARATOR\n        MENUITEM \"Scale...\",                    ID_SELECT_SCALE\n        POPUP \"CSG\"\n        BEGIN\n            MENUITEM \"&Hollow\",                     ID_SELECTION_MAKEHOLLOW\n            MENUITEM \"&Subtract\",                   ID_SELECTION_CSGSUBTRACT\n            MENUITEM \"&Merge\",                      ID_SELECTION_CSGMERGE\n        END\n        MENUITEM SEPARATOR\n        POPUP \"Select\"\n        BEGIN\n            MENUITEM \"Select Complete &Tall\",       ID_SELECTION_SELECTCOMPLETETALL\n\n            MENUITEM \"Select T&ouching\",            ID_SELECTION_SELECTTOUCHING\n\n            MENUITEM \"Select &Partial Tall\",        ID_SELECTION_SELECTPARTIALTALL\n\n            MENUITEM \"Select &Inside\",              ID_SELECTION_SELECTINSIDE\n\n        END\n        MENUITEM SEPARATOR\n        POPUP \"Clipper\"\n        BEGIN\n            MENUITEM \"Toggle Clipper\",              ID_VIEW_CLIPPER\n            MENUITEM SEPARATOR\n            MENUITEM \"Clip selection\",              ID_CLIP_SELECTED\n            MENUITEM \"Split selectedion\",           ID_SPLIT_SELECTED\n            MENUITEM \"Flip Clip orientation\",       ID_FLIP_CLIP\n        END\n        MENUITEM SEPARATOR\n        MENUITEM \"Connect entities\",            ID_SELECTION_CONNECT\n        MENUITEM \"Ungroup entity\",              ID_SELECTION_UNGROUPENTITY\n        MENUITEM \"Make detail\",                 ID_SELECTION_MAKE_DETAIL\n        MENUITEM \"Make structural\",             ID_SELECTION_MAKE_STRUCTURAL\n    END\n    POPUP \"&Bsp\"\n    BEGIN\n        MENUITEM SEPARATOR\n    END\n    POPUP \"&Grid\"\n    BEGIN\n        MENUITEM \"Grid1\\t&1\",                   ID_GRID_1\n        MENUITEM \"Grid2\\t&2\",                   ID_GRID_2\n        MENUITEM \"Grid4\\t&3\",                   ID_GRID_4\n        MENUITEM \"Grid8\\t&4\",                   ID_GRID_8, CHECKED\n        MENUITEM \"Grid16\\t&5\",                  ID_GRID_16\n        MENUITEM \"Grid32\\t&6\",                  ID_GRID_32\n        MENUITEM \"Grid64\\t&7\",                  ID_GRID_64\n        MENUITEM SEPARATOR\n        MENUITEM \"Snap to grid\",                ID_SNAPTOGRID, CHECKED\n    END\n    POPUP \"&Textures\"\n    BEGIN\n        MENUITEM \"Show In &Use\\tU\",             ID_TEXTURES_SHOWINUSE\n        MENUITEM \"Show &All\\tCtrl-A\",           ID_TEXTURES_SHOWALL\n        MENUITEM SEPARATOR\n        MENUITEM \"&Surface Inspector\\tS\",       ID_TEXTURES_INSPECTOR\n        MENUITEM SEPARATOR\n        POPUP \"Render Quality\"\n        BEGIN\n            MENUITEM \"&Wireframe\",                  ID_TEXTURES_WIREFRAME\n            MENUITEM \"&Flat shade\",                 ID_TEXTURES_FLATSHADE\n            MENUITEM \"&Nearest\",                    ID_VIEW_NEAREST\n            MENUITEM \"Nearest &Mipmap\",             ID_VIEW_NEARESTMIPMAP\n            MENUITEM \"&Linear\",                     ID_VIEW_LINEAR\n            MENUITEM \"&Bilinear\",                   ID_VIEW_BILINEAR\n            MENUITEM \"B&ilinear Mipmap\",            ID_VIEW_BILINEARMIPMAP\n            MENUITEM \"T&rilinear\",                  ID_VIEW_TRILINEAR\n        END\n        MENUITEM SEPARATOR\n        MENUITEM \"Find / Replace...\",           ID_TEXTURE_REPLACEALL\n        MENUITEM SEPARATOR\n        POPUP \"Texture Lock\"\n        BEGIN\n            MENUITEM \"Moves\",                       ID_TOGGLE_LOCK, CHECKED\n            MENUITEM \"Rotations\",                   ID_TOGGLE_ROTATELOCK\n            , CHECKED\n        END\n        MENUITEM SEPARATOR\n        MENUITEM \"Load...\",                     ID_TEXTURES_LOAD\n        POPUP \"Shaders\"\n        BEGIN\n            MENUITEM \"Load All (Reload)\",           ID_TEXTURES_RELOADSHADERS\n\n            MENUITEM \"Show\",                        ID_TEXTURES_SHADERS_SHOW\n            , CHECKED\n        END\n        MENUITEM SEPARATOR\n        POPUP \"Flush\"\n        BEGIN\n            MENUITEM \"All\",                         ID_TEXTURES_FLUSH\n            MENUITEM \"Unused\",                      ID_TEXTURES_FLUSH_UNUSED\n        END\n        MENUITEM SEPARATOR\n        POPUP \"Texture Window Scale\"\n        BEGIN\n            MENUITEM \"200%\",                        ID_TEXTURES_TEXTUREWINDOWSCALE_200\n\n            MENUITEM \"100%\",                        ID_TEXTURES_TEXTUREWINDOWSCALE_100\n\n            MENUITEM \"50%\",                         ID_TEXTURES_TEXTUREWINDOWSCALE_50\n\n            MENUITEM \"25%\",                         ID_TEXTURES_TEXTUREWINDOWSCALE_25\n\n            MENUITEM \"10%\",                         ID_TEXTURES_TEXTUREWINDOWSCALE_10\n\n        END\n        MENUITEM SEPARATOR\n    END\n    POPUP \"&Misc\"\n    BEGIN\n        MENUITEM \"&Benchmark\",                  ID_MISC_BENCHMARK\n        POPUP \"&Colors\"\n        BEGIN\n            POPUP \"Themes\"\n            BEGIN\n                MENUITEM \"QE4 Original\",                ID_COLOR_SETORIGINAL\n                MENUITEM \"Q3Radiant Original\",          ID_COLOR_SETQER\n                MENUITEM \"Black and Green\",             ID_COLOR_SETBLACK\n            END\n            MENUITEM SEPARATOR\n            MENUITEM \"&Texture Background...\",      ID_TEXTUREBK\n            MENUITEM \"Grid Background...\",          ID_COLORS_XYBK\n            MENUITEM \"Grid Major...\",               ID_COLORS_MAJOR\n            MENUITEM \"Grid Minor...\",               ID_COLORS_MINOR\n            MENUITEM \"Grid Text...\",                ID_COLORS_GRIDTEXT\n            MENUITEM \"Grid Block...\",               ID_COLORS_GRIDBLOCK\n            MENUITEM \"Default Brush...\",            ID_COLORS_BRUSH\n            MENUITEM \"Selected Brush...\",           ID_COLORS_SELECTEDBRUSH\n            MENUITEM \"Clipper...\",                  ID_COLORS_CLIPPER\n            MENUITEM \"Active View name...\",         ID_COLORS_VIEWNAME\n        END\n        MENUITEM \"&Gamma...\",                   ID_MISC_GAMMA\n        MENUITEM \"Find brush...\",               ID_MISC_FINDBRUSH\n        MENUITEM \"Next leak spot\\tctrl-l\",      ID_MISC_NEXTLEAKSPOT\n        MENUITEM \"Previous leak spot\\tctrl-p\",  ID_MISC_PREVIOUSLEAKSPOT\n        MENUITEM \"&Print XY View\",              ID_MISC_PRINTXY\n        MENUITEM \"&Select Entity Color...\\tK\",  ID_MISC_SELECTENTITYCOLOR\n    END\n    POPUP \"&Region\"\n    BEGIN\n        MENUITEM \"&Off\",                        ID_REGION_OFF\n        MENUITEM \"&Set XY\",                     ID_REGION_SETXY\n        MENUITEM \"Set &Tall Brush\",             ID_REGION_SETTALLBRUSH\n        MENUITEM \"Set &Brush\",                  ID_REGION_SETBRUSH\n        MENUITEM \"Set Se&lected Brushes\",       ID_REGION_SETSELECTION\n    END\n    POPUP \"&Brush\"\n    BEGIN\n        MENUITEM \"3 sided\\tctrl-3\",             ID_BRUSH_3SIDED\n        MENUITEM \"4 sided\\tctrl-4\",             ID_BRUSH_4SIDED\n        MENUITEM \"5 sided\\tctrl-5\",             ID_BRUSH_5SIDED\n        MENUITEM \"6 sided\\tctrl-6\",             ID_BRUSH_6SIDED\n        MENUITEM \"7 sided\\tctrl-7\",             ID_BRUSH_7SIDED\n        MENUITEM \"8 sided\\tctrl-8\",             ID_BRUSH_8SIDED\n        MENUITEM \"9 sided\\tctrl-9\",             ID_BRUSH_9SIDED\n        MENUITEM SEPARATOR\n        MENUITEM \"Arbitrary sided...\",          ID_BRUSH_ARBITRARYSIDED\n        MENUITEM SEPARATOR\n        POPUP \"Primitives\"\n        BEGIN\n            MENUITEM \"Cone...\",                     ID_BRUSH_MAKECONE\n            MENUITEM \"Sphere...\",                   ID_BRUSH_PRIMITIVES_SPHERE\n\n        END\n    END\n    POPUP \"&Curve\"\n    BEGIN\n        MENUITEM \"Cylinder\",                    ID_CURVE_PATCHTUBE\n        POPUP \"More Cylinders\"\n        BEGIN\n            MENUITEM \"Dense Cylinder\",              ID_CURVE_PATCHDENSETUBE\n            MENUITEM \"Very Dense Cylinder\",         ID_CURVE_PATCHVERYDENSETUBE\n\n            MENUITEM \"Square Cylinder\",             ID_CURVE_PATCHSQUARE\n        END\n        MENUITEM SEPARATOR\n        MENUITEM \"End cap\",                     ID_CURVE_PATCHENDCAP\n        MENUITEM \"Bevel\",                       ID_CURVE_PATCHBEVEL\n        POPUP \"More End caps, Bevels\"\n        BEGIN\n            MENUITEM \"Square Endcap\",               ID_CURVE_MOREENDCAPSBEVELS_SQUAREBEVEL\n\n            MENUITEM \"Square Bevel\",                ID_CURVE_MOREENDCAPSBEVELS_SQUAREENDCAP\n\n        END\n        MENUITEM SEPARATOR\n        MENUITEM \"Cone\",                        ID_CURVE_PATCHCONE\n        MENUITEM \"Sphere\",                      ID_CURVE_PRIMITIVES_SPHERE\n        , GRAYED\n        MENUITEM SEPARATOR\n        MENUITEM \"Simple Patch Mesh...\",        ID_CURVE_SIMPLEPATCHMESH\n        MENUITEM SEPARATOR\n        POPUP \"Insert\"\n        BEGIN\n            MENUITEM \"Insert (2) Columns\",          ID_CURVE_INSERT_INSERTCOLUMN\n\n            MENUITEM \"Add (2) Columns\",             ID_CURVE_INSERT_ADDCOLUMN\n\n            MENUITEM SEPARATOR\n            MENUITEM \"Insert (2) Rows\",             ID_CURVE_INSERT_INSERTROW\n\n            MENUITEM \"Add (2) Rows\",                ID_CURVE_INSERT_ADDROW\n        END\n        POPUP \"Delete\"\n        BEGIN\n            MENUITEM \"First (2) Columns\",           ID_CURVE_DELETE_FIRSTCOLUMN\n\n            MENUITEM \"Last (2) Columns\",            ID_CURVE_DELETE_LASTCOLUMN\n\n            MENUITEM SEPARATOR\n            MENUITEM \"First (2) Rows\",              ID_CURVE_DELETE_FIRSTROW\n            MENUITEM \"Last (2) Rows\",               ID_CURVE_DELETE_LASTROW\n        END\n        MENUITEM SEPARATOR\n        POPUP \"Matrix\"\n        BEGIN\n            MENUITEM \"Invert\",                      ID_CURVE_NEGATIVE\n            POPUP \"Re-disperse\"\n            BEGIN\n                MENUITEM \"Cols\",                        ID_CURVE_REDISPERSE_COLS\n\n                MENUITEM \"Rows\",                        ID_CURVE_REDISPERSE_ROWS\n\n            END\n            MENUITEM \"Transpose\",                   ID_CURVE_MATRIX_TRANSPOSE\n\n        END\n        MENUITEM SEPARATOR\n        POPUP \"Cap\"\n        BEGIN\n            MENUITEM \"Normal\",                      ID_CURVE_CAP\n            MENUITEM \"Inverted Bevel\",              ID_CURVE_CAP_INVERTEDBEVEL\n\n            MENUITEM \"Inverted Endcap\",             ID_CURVE_CAP_INVERTEDENDCAP\n\n            MENUITEM SEPARATOR\n            MENUITEM \"Cycle Cap Texture\",           ID_CURVE_CYCLECAP\n        END\n        MENUITEM SEPARATOR\n        POPUP \"Overlay\"\n        BEGIN\n            MENUITEM \"Set\",                         ID_CURVE_OVERLAY_SET\n            MENUITEM \"Clear\",                       ID_CURVE_OVERLAY_CLEAR\n        END\n        MENUITEM SEPARATOR\n        MENUITEM \"Thicken...\",                  ID_CURVE_THICKEN\n    END\n    POPUP \"&Terrain\"\n    BEGIN\n        MENUITEM \"Create Terrain from &Brush\",  ID_TERRAIN_CREATETERRAINFROMBRUSH\n\n        MENUITEM \"Raise/Lower Terrain\",         ID_TERRAIN_RAISELOWERTERRAIN\n        , CHECKED\n    END\n    POPUP \"&Plugins\"\n    BEGIN\n        MENUITEM \"Refresh\",                     ID_PLUGINS_REFRESH\n        MENUITEM SEPARATOR\n    END\n    POPUP \"&Help\"\n    BEGIN\n        MENUITEM \"Help\\tF1\",                    ID_HELP\n        MENUITEM SEPARATOR\n        MENUITEM \"Command list...\",             ID_HELP_COMMANDLIST\n        MENUITEM SEPARATOR\n        MENUITEM \"&About...\",                   ID_HELP_ABOUT\n    END\nEND\n\nIDR_POPUP_TEXTURE MENU DISCARDABLE \nBEGIN\n    POPUP \"Popup\"\n    BEGIN\n        MENUITEM \"&Wireframe\",                  ID_TEXTURES_WIREFRAME\n        MENUITEM \"&Flat shade\",                 ID_TEXTURES_FLATSHADE\n        MENUITEM \"&Nearest\",                    ID_VIEW_NEAREST\n        MENUITEM \"Nearest &Mipmap\",             ID_VIEW_NEARESTMIPMAP\n        MENUITEM \"&Linear\",                     ID_VIEW_LINEAR\n        MENUITEM \"&Bilinear\",                   ID_VIEW_BILINEAR\n        MENUITEM \"B&ilinear Mipmap\",            ID_VIEW_BILINEARMIPMAP\n        MENUITEM \"T&rilinear\",                  ID_VIEW_TRILINEAR\n    END\nEND\n\nIDR_POPUP_SELECTION MENU DISCARDABLE \nBEGIN\n    POPUP \"Popup\"\n    BEGIN\n        MENUITEM \"Select Complete &Tall\",       ID_SELECTION_SELECTCOMPLETETALL\n\n        MENUITEM \"Select T&ouching\",            ID_SELECTION_SELECTTOUCHING\n        MENUITEM \"Select &Partial Tall\",        ID_SELECTION_SELECTPARTIALTALL\n\n        MENUITEM \"Select &Inside\",              ID_SELECTION_SELECTINSIDE\n    END\nEND\n\nIDR_POPUP_VIEW MENU DISCARDABLE \nBEGIN\n    POPUP \"Popup\"\n    BEGIN\n        MENUITEM \"XY (Top)\",                    ID_VIEW_XY\n        MENUITEM \"XZ\",                          ID_VIEW_SIDE\n        MENUITEM \"YZ\",                          ID_VIEW_FRONT\n    END\nEND\n\nIDR_MENU_DROP MENU DISCARDABLE \nBEGIN\n    POPUP \"Drop\"\n    BEGIN\n        MENUITEM SEPARATOR\n        POPUP \"Select\"\n        BEGIN\n            MENUITEM \"Select Complete &Tall\",       ID_SELECTION_SELECTCOMPLETETALL\n\n            MENUITEM \"Select T&ouching\",            ID_SELECTION_SELECTTOUCHING\n\n            MENUITEM \"Select &Partial Tall\",        ID_SELECTION_SELECTPARTIALTALL\n\n            MENUITEM \"Select &Inside\",              ID_SELECTION_SELECTINSIDE\n\n        END\n        MENUITEM SEPARATOR\n        POPUP \"Group\"\n        BEGIN\n            MENUITEM \"Add to...\",                   ID_DROP_GROUP_ADDTO\n            MENUITEM \"Remove\",                      ID_DROP_GROUP_REMOVE\n            MENUITEM SEPARATOR\n            MENUITEM \"Name...\",                     ID_DROP_GROUP_NAME\n            MENUITEM SEPARATOR\n            MENUITEM \"New Group...\",                ID_DROP_GROUP_NEWGROUP\n        END\n        MENUITEM \"Ungroup entity\",              ID_SELECTION_UNGROUPENTITY\n        MENUITEM \"Make detail\",                 ID_SELECTION_MAKE_DETAIL\n        MENUITEM \"Make structural\",             ID_SELECTION_MAKE_STRUCTURAL\n    END\nEND\n\nIDR_MENU1 MENU DISCARDABLE \nBEGIN\n    POPUP \"&File\"\n    BEGIN\n        MENUITEM \"&New map\",                    ID_FILE_NEW\n        MENUITEM SEPARATOR\n        MENUITEM \"&Open...\",                    ID_FILE_OPEN\n        MENUITEM \"&Load...\",                    ID_FILE_IMPORTMAP\n        MENUITEM \"&Save\",                       ID_FILE_SAVE\n        MENUITEM \"Save &as...\",                 ID_FILE_SAVEAS\n        MENUITEM \"Save s&elected...\",           ID_FILE_EXPORTMAP\n        MENUITEM SEPARATOR\n        MENUITEM \"Save re&gion...\",             ID_FILE_SAVEREGION\n        MENUITEM SEPARATOR\n        MENUITEM \"New p&roject...\",             ID_FILE_NEWPROJECT\n        MENUITEM \"Load &project...\",            ID_FILE_LOADPROJECT\n        MENUITEM \"Pro&ject settings...\",        ID_FILE_PROJECTSETTINGS\n        MENUITEM SEPARATOR\n        MENUITEM \"&Pointfile...\",               ID_FILE_POINTFILE\n        MENUITEM SEPARATOR\n        MENUITEM \"E&xit\",                       ID_FILE_EXIT\n    END\n    POPUP \"&Edit\"\n    BEGIN\n        MENUITEM \"Undo (no really :-)\",         ID_EDIT_UNDO\n        MENUITEM SEPARATOR\n        MENUITEM \"&Copy brush\",                 ID_EDIT_COPYBRUSH\n        MENUITEM \"&Paste brush\",                ID_EDIT_PASTEBRUSH\n        MENUITEM SEPARATOR\n        MENUITEM \"Map Info...\",                 ID_EDIT_MAPINFO\n        MENUITEM \"Entity Info...\",              ID_EDIT_ENTITYINFO\n        MENUITEM SEPARATOR\n        MENUITEM \"Brush Scripts...\",            ID_BRUSH_SCRIPTS\n        MENUITEM SEPARATOR\n        MENUITEM \"Load Pre&fab...\",             ID_EDIT_LOADPREFAB\n        MENUITEM SEPARATOR\n        MENUITEM \"Preferences...\",              ID_PREFS\n    END\n    POPUP \"&View\"\n    BEGIN\n        POPUP \"Toggle\"\n        BEGIN\n            MENUITEM \"Camera View\",                 ID_TOGGLECAMERA\n            MENUITEM \"Console View\",                ID_TOGGLECONSOLE\n            MENUITEM \"Entity View\",                 ID_VIEW_ENTITY\n            MENUITEM \"XY (Top)\",                    ID_TOGGLEVIEW\n            MENUITEM \"YZ (Side)\",                   ID_TOGGLEVIEW_YZ\n            MENUITEM \"XZ (Front)\",                  ID_TOGGLEVIEW_XZ\n            MENUITEM \"Z View\",                      ID_TOGGLEZ\n        END\n        MENUITEM SEPARATOR\n        MENUITEM \"&Center\\tEnd\",                ID_VIEW_CENTER\n        MENUITEM \"&Up Floor\\tPage Up\",          ID_VIEW_UPFLOOR\n        MENUITEM \"&Down Floor\\tPage Down\",      ID_VIEW_DOWNFLOOR\n        MENUITEM SEPARATOR\n        MENUITEM \"&Next (XY, YZ, XY)\\tCtrl-TAB\", ID_VIEW_NEXTVIEW\n        POPUP \"Layout\"\n        BEGIN\n            MENUITEM \"XY (Top)\",                    ID_VIEW_XY\n            MENUITEM \"YZ\",                          ID_VIEW_SIDE\n            MENUITEM \"XZ\",                          ID_VIEW_FRONT\n        END\n        POPUP \"Zoom\"\n        BEGIN\n            MENUITEM \"&XY 100%\",                    ID_VIEW_100\n            MENUITEM \"XY Zoom &In\\tDelete\",         ID_VIEW_ZOOMIN\n            MENUITEM \"XY Zoom &Out\\tInsert\",        ID_VIEW_ZOOMOUT\n            MENUITEM SEPARATOR\n            MENUITEM \"&Z 100%\",                     ID_VIEW_Z100\n            MENUITEM \"Z Zoo&m In\\tctrl-Delete\",     ID_VIEW_ZZOOMIN\n            MENUITEM \"Z Zoom O&ut\\tctrl-Insert\",    ID_VIEW_ZZOOMOUT\n            MENUITEM SEPARATOR\n            MENUITEM \"Cubic Clip Zoom In\\tctrl-]\",  ID_VIEW_CUBEIN\n            MENUITEM \"Cubic Clip Zoom Out\\tctrl-[\", ID_VIEW_CUBEOUT\n        END\n        MENUITEM SEPARATOR\n        POPUP \"Show\"\n        BEGIN\n            MENUITEM \"Show &Names\",                 ID_VIEW_SHOWNAMES\n            , CHECKED\n            MENUITEM \"Show Blocks\",                 ID_VIEW_SHOWBLOCKS\n            MENUITEM \"Show C&oordinates\",           ID_VIEW_SHOWCOORDINATES\n            , CHECKED\n            MENUITEM \"Show &Entities\",              ID_VIEW_SHOWENT, CHECKED\n            MENUITEM \"Show &Path\",                  ID_VIEW_SHOWPATH\n            , CHECKED\n            MENUITEM \"Show &Lights\",                ID_VIEW_SHOWLIGHTS\n            , CHECKED\n            MENUITEM \"Show &Water\",                 ID_VIEW_SHOWWATER\n            , CHECKED\n            MENUITEM \"Show Clip &Brush\",            ID_VIEW_SHOWCLIP\n            , CHECKED\n            MENUITEM \"Show Wor&ld\",                 ID_VIEW_SHOWWORLD\n            , CHECKED\n            MENUITEM \"Show Detail\\tctrl-D\",         ID_VIEW_SHOWDETAIL\n            , CHECKED\n        END\n        MENUITEM SEPARATOR\n        MENUITEM \"Cubic Clipping\",              ID_VIEW_CUBICCLIPPING\n        , CHECKED\n        MENUITEM SEPARATOR\n        MENUITEM \"Dynamic Lighting\",            ID_DYNAMIC_LIGHTING\n    END\n    POPUP \"&Selection\"\n    BEGIN\n        POPUP \"Drag\"\n        BEGIN\n            MENUITEM \"Drag &Edges\",                 ID_SELECTION_DRAGEDGES\n            MENUITEM \"Drag &Vertices\",              ID_SELECTION_DRAGVERTECIES\n\n        END\n        MENUITEM SEPARATOR\n        MENUITEM \"&Clone\",                      ID_SELECTION_CLONE\n        MENUITEM \"Deselect\",                    ID_SELECTION_DESELECT\n        MENUITEM \"&Delete\",                     ID_SELECTION_DELETE\n        MENUITEM SEPARATOR\n        POPUP \"Flip\"\n        BEGIN\n            MENUITEM \"Flip &X\",                     ID_BRUSH_FLIPX\n            MENUITEM \"Flip &Y\",                     ID_BRUSH_FLIPY\n            MENUITEM \"Flip &Z\",                     ID_BRUSH_FLIPZ\n        END\n        MENUITEM SEPARATOR\n        POPUP \"Rotate\"\n        BEGIN\n            MENUITEM \"Rotate X\",                    ID_BRUSH_ROTATEX\n            MENUITEM \"Rotate Y\",                    ID_BRUSH_ROTATEY\n            MENUITEM \"Rotate Z\",                    ID_BRUSH_ROTATEZ\n            MENUITEM \"Arbitrary rotation...\",       ID_SELECTION_ARBITRARYROTATION\n\n        END\n        MENUITEM SEPARATOR\n        MENUITEM \"Scale...\",                    ID_SELECT_SCALE\n        POPUP \"CSG\"\n        BEGIN\n            MENUITEM \"Make &Hollow\",                ID_SELECTION_MAKEHOLLOW\n            MENUITEM \"CSG &Subtract\",               ID_SELECTION_CSGSUBTRACT\n            MENUITEM \"CSG &Add\",                    ID_SELECTION_CSGADD\n        END\n        MENUITEM SEPARATOR\n        POPUP \"Select\"\n        BEGIN\n            MENUITEM \"Select Complete &Tall\",       ID_SELECTION_SELECTCOMPLETETALL\n\n            MENUITEM \"Select T&ouching\",            ID_SELECTION_SELECTTOUCHING\n\n            MENUITEM \"Select &Partial Tall\",        ID_SELECTION_SELECTPARTIALTALL\n\n            MENUITEM \"Select &Inside\",              ID_SELECTION_SELECTINSIDE\n\n            MENUITEM \"Nudge Left\",                  ID_SELECTION_SELECT_NUDGELEFT\n\n            MENUITEM \"Nudge Right\",                 ID_SELECTION_SELECT_NUDGERIGHT\n\n            MENUITEM \"Nudge Up\",                    ID_SELECTION_SELECT_NUDGEUP\n\n            MENUITEM \"Nudge Down\",                  ID_SELECTION_SELECT_NUDGEDOWN\n\n        END\n        MENUITEM SEPARATOR\n        POPUP \"Clipper\"\n        BEGIN\n            MENUITEM \"Toggle Clipper\",              ID_VIEW_CLIPPER\n            MENUITEM SEPARATOR\n            MENUITEM \"Clip selection\",              ID_CLIP_SELECTED\n            MENUITEM \"Split selectedion\",           ID_SPLIT_SELECTED\n            MENUITEM \"Flip Clip orientation\",       ID_FLIP_CLIP\n        END\n        MENUITEM SEPARATOR\n        MENUITEM \"Connect entities\",            ID_SELECTION_CONNECT\n        MENUITEM \"Ungroup entity\",              ID_SELECTION_UNGROUPENTITY\n        MENUITEM \"Make detail\",                 ID_SELECTION_MAKE_DETAIL\n        MENUITEM \"Make structural\",             ID_SELECTION_MAKE_STRUCTURAL\n    END\n    POPUP \"&Bsp\"\n    BEGIN\n        MENUITEM SEPARATOR\n    END\n    POPUP \"&Grid\"\n    BEGIN\n        MENUITEM \"Grid1\\t&1\",                   ID_GRID_1\n        MENUITEM \"Grid2\\t&2\",                   ID_GRID_2\n        MENUITEM \"Grid4\\t&3\",                   ID_GRID_4\n        MENUITEM \"Grid8\\t&4\",                   ID_GRID_8, CHECKED\n        MENUITEM \"Grid16\\t&5\",                  ID_GRID_16\n        MENUITEM \"Grid32\\t&6\",                  ID_GRID_32\n        MENUITEM \"Grid64\\t&7\",                  ID_GRID_64\n        MENUITEM SEPARATOR\n        MENUITEM \"Snap to grid\",                ID_SNAPTOGRID, CHECKED\n    END\n    POPUP \"&Textures\"\n    BEGIN\n        MENUITEM \"Show In &Use\\tU\",             ID_TEXTURES_SHOWINUSE\n        MENUITEM \"&Surface Inspector\\tS\",       ID_TEXTURES_INSPECTOR\n        MENUITEM SEPARATOR\n        POPUP \"Render Quality\"\n        BEGIN\n            MENUITEM \"&Wireframe\",                  ID_TEXTURES_WIREFRAME\n            MENUITEM \"&Flat shade\",                 ID_TEXTURES_FLATSHADE\n            MENUITEM \"&Nearest\",                    ID_VIEW_NEAREST\n            MENUITEM \"Nearest &Mipmap\",             ID_VIEW_NEARESTMIPMAP\n            MENUITEM \"&Linear\",                     ID_VIEW_LINEAR\n            MENUITEM \"&Bilinear\",                   ID_VIEW_BILINEAR\n            MENUITEM \"B&ilinear Mipmap\",            ID_VIEW_BILINEARMIPMAP\n            MENUITEM \"T&rilinear\",                  ID_VIEW_TRILINEAR\n        END\n        MENUITEM SEPARATOR\n        MENUITEM \"Find / Replace...\",           ID_TEXTURE_REPLACEALL\n        MENUITEM SEPARATOR\n        MENUITEM \"Move Texture Lock\",           ID_TOGGLE_LOCK, CHECKED\n        MENUITEM \"Rotation Texture Lock\",       ID_TOGGLE_ROTATELOCK\n        , CHECKED\n        MENUITEM SEPARATOR\n        MENUITEM \"Load...\",                     ID_TEXTURES_LOAD\n        MENUITEM \"Load from List.. \",           ID_TEXTURES_LOADLIST\n        MENUITEM SEPARATOR\n    END\n    POPUP \"&Misc\"\n    BEGIN\n        MENUITEM \"&Benchmark\",                  ID_MISC_BENCHMARK\n        POPUP \"&Colors\"\n        BEGIN\n            POPUP \"Themes\"\n            BEGIN\n                MENUITEM \"QE4 Original\",                ID_COLOR_SETORIGINAL\n                MENUITEM \"Q3Radiant Original\",          ID_COLOR_SETQER\n                MENUITEM \"Black and Green\",             ID_COLOR_SETBLACK\n            END\n            MENUITEM SEPARATOR\n            MENUITEM \"&Texture Background...\",      ID_TEXTUREBK\n            MENUITEM \"Grid Background...\",          ID_COLORS_XYBK\n            MENUITEM \"Grid Major...\",               ID_COLORS_MAJOR\n            MENUITEM \"Grid Minor...\",               ID_COLORS_MINOR\n            MENUITEM \"Grid Text...\",                ID_COLORS_GRIDTEXT\n            MENUITEM \"Grid Block...\",               ID_COLORS_GRIDBLOCK\n            MENUITEM \"Default Brush...\",            ID_COLORS_BRUSH\n            MENUITEM \"Selected Brush...\",           ID_COLORS_SELECTEDBRUSH\n            MENUITEM \"Clipper...\",                  ID_COLORS_CLIPPER\n            MENUITEM \"Active View name...\",         ID_COLORS_VIEWNAME\n        END\n        MENUITEM \"&Gamma...\",                   ID_MISC_GAMMA\n        MENUITEM \"Find brush...\",               ID_MISC_FINDBRUSH\n        MENUITEM \"Next leak spot\\tctrl-l\",      ID_MISC_NEXTLEAKSPOT\n        MENUITEM \"Previous leak spot\\tctrl-p\",  ID_MISC_PREVIOUSLEAKSPOT\n        MENUITEM \"&Print XY View\",              ID_MISC_PRINTXY\n        MENUITEM \"&Select Entity Color...\\tK\",  ID_MISC_SELECTENTITYCOLOR\n        MENUITEM \"Convert old curves\",          ID_CONVERTCURVES\n    END\n    POPUP \"&Region\"\n    BEGIN\n        MENUITEM \"&Off\",                        ID_REGION_OFF\n        MENUITEM \"&Set XY\",                     ID_REGION_SETXY\n        MENUITEM \"Set &Tall Brush\",             ID_REGION_SETTALLBRUSH\n        MENUITEM \"Set &Brush\",                  ID_REGION_SETBRUSH\n        MENUITEM \"Set Se&lected Brushes\",       ID_REGION_SETSELECTION\n    END\n    POPUP \"&Brush\"\n    BEGIN\n        MENUITEM \"3 sided\\tctrl-3\",             ID_BRUSH_3SIDED\n        MENUITEM \"4 sided\\tctrl-4\",             ID_BRUSH_4SIDED\n        MENUITEM \"5 sided\\tctrl-5\",             ID_BRUSH_5SIDED\n        MENUITEM \"6 sided\\tctrl-6\",             ID_BRUSH_6SIDED\n        MENUITEM \"7 sided\\tctrl-7\",             ID_BRUSH_7SIDED\n        MENUITEM \"8 sided\\tctrl-8\",             ID_BRUSH_8SIDED\n        MENUITEM \"9 sided\\tctrl-9\",             ID_BRUSH_9SIDED\n        MENUITEM SEPARATOR\n        MENUITEM \"Arbitrary sided...\",          ID_BRUSH_ARBITRARYSIDED\n        MENUITEM SEPARATOR\n        POPUP \"Primitives\"\n        BEGIN\n            MENUITEM \"Cone...\",                     ID_BRUSH_MAKECONE\n        END\n    END\n    POPUP \"&Help\"\n    BEGIN\n        MENUITEM \"Command list...\",             ID_HELP_COMMANDLIST\n        MENUITEM SEPARATOR\n        MENUITEM \"&About...\",                   ID_HELP_ABOUT\n    END\nEND\n\nIDR_POPUP_ENTITY MENU DISCARDABLE \nBEGIN\n    POPUP \"Popup\"\n    BEGIN\n        MENUITEM \"Bounding box\",                ID_VIEW_ENTITIESAS_BOUNDINGBOX\n\n        MENUITEM \"Wireframe\",                   ID_VIEW_ENTITIESAS_WIREFRAME\n        MENUITEM \"Selected Wireframe\",          ID_VIEW_ENTITIESAS_SELECTEDWIREFRAME\n\n        MENUITEM \"Selected Skinned\",            ID_VIEW_ENTITIESAS_SELECTEDSKINNED\n\n        MENUITEM \"Skinned\",                     ID_VIEW_ENTITIESAS_SKINNED\n        MENUITEM \"Skinned and Boxed\",           ID_VIEW_ENTITIESAS_SKINNEDANDBOXED\n\n    END\nEND\n\nIDR_POPUP_GROUP MENU DISCARDABLE \nBEGIN\n    POPUP \"Popup\"\n    BEGIN\n        MENUITEM \"XY (Top)\",                    ID_VIEW_XY\n        MENUITEM \"XZ\",                          ID_VIEW_SIDE\n        MENUITEM \"YZ\",                          ID_VIEW_FRONT\n    END\nEND\n\nIDR_POPUP_SPLINE MENU DISCARDABLE \nBEGIN\n    POPUP \"Popup\"\n    BEGIN\n        POPUP \"New Camera\"\n        BEGIN\n            MENUITEM \"Fixed\",                       ID_POPUP_NEWCAMERA_FIXED\n            MENUITEM \"Interpolated\",                ID_POPUP_NEWCAMERA_INTERPOLATED\n\n            MENUITEM \"Spline\",                      ID_POPUP_NEWCAMERA_SPLINE\n\n        END\n        MENUITEM \"Camera Inspector...\",         ID_SPLINES_EDIT\n        MENUITEM SEPARATOR\n        MENUITEM \"Test Camera\",                 ID_SPLINE_TEST\n    END\nEND\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Accelerator\n//\n\nIDR_ACCELERATOR1 ACCELERATORS DISCARDABLE \nBEGIN\n    \"3\",            ID_BRUSH_3SIDED,        VIRTKEY, CONTROL, NOINVERT\n    \"4\",            ID_BRUSH_4SIDED,        VIRTKEY, CONTROL, NOINVERT\n    \"5\",            ID_BRUSH_5SIDED,        VIRTKEY, CONTROL, NOINVERT\n    \"6\",            ID_BRUSH_6SIDED,        VIRTKEY, CONTROL, NOINVERT\n    \"7\",            ID_BRUSH_7SIDED,        VIRTKEY, CONTROL, NOINVERT\n    \"8\",            ID_BRUSH_8SIDED,        VIRTKEY, CONTROL, NOINVERT\n    \"9\",            ID_BRUSH_9SIDED,        VIRTKEY, CONTROL, NOINVERT\n    \"D\",            ID_VIEW_SHOWDETAIL,     VIRTKEY, CONTROL, NOINVERT\n    \"K\",            ID_SELECTION_CONNECT,   VIRTKEY, CONTROL, NOINVERT\n    \"L\",            ID_MISC_NEXTLEAKSPOT,   VIRTKEY, CONTROL, NOINVERT\n    \"M\",            ID_SELECTION_MAKE_DETAIL, VIRTKEY, CONTROL, NOINVERT\n    \"O\",            ID_FILE_OPEN,           VIRTKEY, CONTROL, NOINVERT\n    \"P\",            ID_MISC_PREVIOUSLEAKSPOT, VIRTKEY, CONTROL, NOINVERT\n    \"S\",            ID_FILE_SAVE,           VIRTKEY, CONTROL, NOINVERT\n    VK_DELETE,      ID_VIEW_ZZOOMIN,        VIRTKEY, CONTROL, NOINVERT\n    VK_INSERT,      ID_VIEW_ZZOOMOUT,       VIRTKEY, CONTROL, NOINVERT\n    \"X\",            ID_FILE_EXIT,           VIRTKEY, CONTROL, NOINVERT\nEND\n\nIDR_MAINFRAME ACCELERATORS DISCARDABLE \nBEGIN\n    \"7\",            ID_BRUSH_7SIDED,        VIRTKEY, CONTROL, NOINVERT\n    \"8\",            ID_BRUSH_8SIDED,        VIRTKEY, CONTROL, NOINVERT\n    \"9\",            ID_BRUSH_9SIDED,        VIRTKEY, CONTROL, NOINVERT\n    \"D\",            ID_VIEW_SHOWDETAIL,     VIRTKEY, CONTROL, NOINVERT\n    \"K\",            ID_SELECTION_CONNECT,   VIRTKEY, CONTROL, NOINVERT\n    \"L\",            ID_MISC_NEXTLEAKSPOT,   VIRTKEY, CONTROL, NOINVERT\n    \"M\",            ID_SELECTION_MAKE_DETAIL, VIRTKEY, CONTROL, NOINVERT\n    \"O\",            ID_FILE_OPEN,           VIRTKEY, CONTROL, NOINVERT\n    \"P\",            ID_MISC_PREVIOUSLEAKSPOT, VIRTKEY, CONTROL, NOINVERT\n    \"S\",            ID_FILE_SAVE,           VIRTKEY, CONTROL, NOINVERT\n    VK_DELETE,      ID_VIEW_ZZOOMIN,        VIRTKEY, CONTROL, NOINVERT\n    VK_DOWN,        ID_SELECTION_SELECT_NUDGEDOWN, VIRTKEY, ALT, NOINVERT\n    VK_INSERT,      ID_VIEW_ZZOOMOUT,       VIRTKEY, CONTROL, NOINVERT\n    \"X\",            ID_FILE_EXIT,           VIRTKEY, CONTROL, NOINVERT\nEND\n\nIDR_ACCEL_SURFACE ACCELERATORS DISCARDABLE \nBEGIN\n    VK_ESCAPE,      ID_BYEBYE,              VIRTKEY, NOINVERT\nEND\n\nIDR_MINIACCEL ACCELERATORS DISCARDABLE \nBEGIN\n    VK_DOWN,        ID_SELECTION_SELECT_NUDGEDOWN, VIRTKEY, ALT, NOINVERT\n    VK_LEFT,        ID_SELECTION_SELECT_NUDGELEFT, VIRTKEY, ALT, NOINVERT\n    VK_RIGHT,       ID_SELECTION_SELECT_NUDGERIGHT, VIRTKEY, ALT, NOINVERT\n    VK_UP,          ID_SELECTION_SELECT_NUDGEUP, VIRTKEY, ALT, NOINVERT\nEND\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Dialog\n//\n\nIDD_FINDTEXTURE DIALOG DISCARDABLE  0, 0, 129, 53\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Find Texture\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"OK\",IDOK,10,30,50,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,70,30,50,14\n    EDITTEXT        IDC_EDIT1,10,10,110,14,ES_AUTOHSCROLL\nEND\n\nIDD_ENTITY DIALOGEX 0, 0, 234, 355\nSTYLE DS_3DLOOK | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CLIPSIBLINGS | \n    WS_CAPTION | WS_THICKFRAME\nEXSTYLE WS_EX_TOOLWINDOW | WS_EX_CLIENTEDGE\nCAPTION \"Entity\"\nFONT 8, \"MS Sans Serif\", 0, 0, 0x1\nBEGIN\n    LISTBOX         IDC_E_LIST,5,5,180,94,LBS_SORT | LBS_NOINTEGRALHEIGHT | \n                    LBS_WANTKEYBOARDINPUT | WS_VSCROLL | WS_TABSTOP,\n                    WS_EX_CLIENTEDGE\n    EDITTEXT        IDC_E_COMMENT,5,102,180,45,ES_MULTILINE | ES_READONLY | \n                    WS_VSCROLL,WS_EX_CLIENTEDGE\n    PUSHBUTTON      \"135\",IDC_E_135,5,276,15,15\n    PUSHBUTTON      \"180\",IDC_E_180,5,292,15,15\n    PUSHBUTTON      \"225\",IDC_E_225,5,306,15,15\n    PUSHBUTTON      \"270\",IDC_E_270,21,306,15,15\n    PUSHBUTTON      \"90\",IDC_E_90,21,276,15,15\n    PUSHBUTTON      \"45\",IDC_E_45,35,276,15,15\n    PUSHBUTTON      \"360\",IDC_E_0,35,292,15,15\n    PUSHBUTTON      \"315\",IDC_E_315,35,306,15,15\n    PUSHBUTTON      \"Up\",IDC_E_UP,60,281,15,15\n    PUSHBUTTON      \"Dn\",IDC_E_DOWN,60,297,15,15\n    CONTROL         \"\",IDC_CHECK1,\"Button\",BS_AUTOCHECKBOX | WS_DISABLED | \n                    WS_TABSTOP,5,151,50,8\n    CONTROL         \"\",IDC_CHECK2,\"Button\",BS_AUTOCHECKBOX | WS_DISABLED | \n                    WS_TABSTOP,5,161,50,8\n    CONTROL         \"\",IDC_CHECK3,\"Button\",BS_AUTOCHECKBOX | WS_DISABLED | \n                    WS_TABSTOP,5,171,50,8\n    CONTROL         \"\",IDC_CHECK4,\"Button\",BS_AUTOCHECKBOX | WS_DISABLED | \n                    WS_TABSTOP,5,181,50,8\n    CONTROL         \"\",IDC_CHECK5,\"Button\",BS_AUTOCHECKBOX | WS_DISABLED | \n                    WS_TABSTOP,65,151,50,8\n    CONTROL         \"\",IDC_CHECK6,\"Button\",BS_AUTOCHECKBOX | WS_DISABLED | \n                    WS_TABSTOP,65,161,50,8\n    CONTROL         \"\",IDC_CHECK7,\"Button\",BS_AUTOCHECKBOX | WS_DISABLED | \n                    WS_TABSTOP,65,171,50,8\n    CONTROL         \"\",IDC_CHECK8,\"Button\",BS_AUTOCHECKBOX | WS_DISABLED | \n                    WS_TABSTOP,65,181,50,8\n    CONTROL         \"!Easy\",IDC_CHECK9,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    125,151,50,8\n    CONTROL         \"!Medium\",IDC_CHECK10,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,125,161,50,8\n    CONTROL         \"!Hard\",IDC_CHECK11,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,125,171,50,10\n    CONTROL         \"!DeathMatch\",IDC_CHECK12,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,125,181,55,10\n    LISTBOX         IDC_E_PROPS,5,192,180,50,LBS_SORT | LBS_USETABSTOPS | \n                    LBS_NOINTEGRALHEIGHT | LBS_WANTKEYBOARDINPUT | \n                    WS_VSCROLL | WS_TABSTOP,WS_EX_CLIENTEDGE\n    PUSHBUTTON      \"Del Key/Pair\",IDC_E_DELPROP,105,281,45,15\n    EDITTEXT        IDC_E_STATUS,83,298,95,30,ES_MULTILINE | ES_AUTOVSCROLL | \n                    ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | WS_HSCROLL\n    LTEXT           \"Key\",IDC_STATIC_KEY,5,246,25,10\n    LTEXT           \"Value\",IDC_STATIC_VALUE,5,262,25,10\n    EDITTEXT        IDC_E_KEY_FIELD,40,245,145,12,ES_AUTOHSCROLL\n    EDITTEXT        IDC_E_VALUE_FIELD,40,261,145,12,ES_AUTOHSCROLL\n    PUSHBUTTON      \"Hide\",IDC_BTN_HIDE,190,328,7,6\n    PUSHBUTTON      \"Sound...\",IDC_BTN_ASSIGNSOUND,198,247,36,11\n    PUSHBUTTON      \"Model...\",IDC_BTN_ASSIGNMODEL,198,264,36,11\n    CONTROL         \"Tab1\",IDC_TAB_MODE,\"SysTabControl32\",TCS_BOTTOM | \n                    WS_BORDER,3,338,223,14\nEND\n\nIDD_GAMMA DIALOGEX 0, 0, 135, 94\nSTYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU\nCAPTION \"Gamma\"\nFONT 8, \"MS Sans Serif\", 0, 0, 0x1\nBEGIN\n    EDITTEXT        IDC_G_EDIT,5,8,46,13,ES_AUTOHSCROLL,WS_EX_CLIENTEDGE\n    DEFPUSHBUTTON   \"OK\",IDOK,91,5,39,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,91,23,39,14\n    LTEXT           \"0.0 is brightest\\n1.0 is darkest\\n\\nYou must restart for the settings to take effect\",\n                    IDC_STATIC,7,25,61,55\nEND\n\nIDD_FINDBRUSH DIALOGEX 0, 0, 127, 76\nSTYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU\nCAPTION \"Find brush\"\nFONT 8, \"MS Sans Serif\", 0, 0, 0x1\nBEGIN\n    DEFPUSHBUTTON   \"OK\",IDOK,5,55,50,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,65,55,50,14\n    EDITTEXT        IDC_FIND_ENTITY,80,15,46,13,ES_AUTOHSCROLL,\n                    WS_EX_CLIENTEDGE\n    EDITTEXT        IDC_FIND_BRUSH,80,30,46,13,ES_AUTOHSCROLL,\n                    WS_EX_CLIENTEDGE\n    LTEXT           \"Entity number\",IDC_STATIC,10,15,60,8\n    LTEXT           \"Brush number\",IDC_STATIC,10,30,65,8\nEND\n\nIDD_ROTATE DIALOG DISCARDABLE  0, 0, 129, 65\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Arbitrary rotation\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    EDITTEXT        IDC_ROTX,23,3,29,14,ES_AUTOHSCROLL\n    CONTROL         \"Spin1\",IDC_SPIN1,\"msctls_updown32\",UDS_WRAP | \n                    UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | \n                    UDS_ARROWKEYS,52,3,11,14\n    EDITTEXT        IDC_ROTY,23,21,29,14,ES_AUTOHSCROLL\n    CONTROL         \"Spin1\",IDC_SPIN2,\"msctls_updown32\",UDS_WRAP | \n                    UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | \n                    UDS_ARROWKEYS,53,21,11,14\n    EDITTEXT        IDC_ROTZ,23,39,29,14,ES_AUTOHSCROLL\n    CONTROL         \"Spin1\",IDC_SPIN3,\"msctls_updown32\",UDS_WRAP | \n                    UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | \n                    UDS_ARROWKEYS,53,39,11,14\n    DEFPUSHBUTTON   \"OK\",IDOK,82,3,39,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,82,19,39,14\n    PUSHBUTTON      \"Apply\",ID_APPLY,82,39,39,14\n    RTEXT           \"X\",IDC_STATIC,8,6,8,8\n    RTEXT           \"Y\",IDC_STATIC,8,24,8,8\n    RTEXT           \"Z\",IDC_STATIC,8,42,8,8\nEND\n\nIDD_SIDES DIALOGEX 0, 0, 130, 47\nSTYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU\nCAPTION \"Arbitrrary sides\"\nFONT 8, \"MS Sans Serif\", 0, 0, 0x1\nBEGIN\n    EDITTEXT        IDC_SIDES,27,6,40,14,ES_AUTOHSCROLL,WS_EX_CLIENTEDGE\n    DEFPUSHBUTTON   \"OK\",IDOK,85,4,41,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,85,22,41,14\n    LTEXT           \"Sides:\",IDC_STATIC,6,8,20,8\nEND\n\nIDD_ABOUT DIALOG DISCARDABLE  0, 0, 275, 223\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"About Q3Radiant\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"OK\",IDOK,236,7,35,14\n    CONTROL         127,IDC_STATIC,\"Static\",SS_BITMAP | SS_CENTERIMAGE | \n                    SS_REALSIZEIMAGE | SS_SUNKEN | WS_BORDER,7,7,87,80\n    GROUPBOX        \"OpenGL Properties\",IDC_STATIC,5,93,265,56\n    LTEXT           \"Vendor:\\t\\tWHOEVER\",IDC_ABOUT_GLVENDOR,10,101,253,10\n    LTEXT           \"Version:\\t\\t1.1\",IDC_ABOUT_GLVERSION,10,111,249,10\n    LTEXT           \"Renderer:\\tWHATEVER\",IDC_ABOUT_GLRENDERER,10,121,253,24\n    GROUPBOX        \"OpenGL Extensions\",IDC_STATIC,5,152,265,65\n    CONTROL         \"Q3 Radiant 1.0 Beta build 200f\\nCopyright 1999, 2005 Id Software, Inc.\\n\\n\",\n                    IDC_STATIC,\"Static\",SS_LEFTNOWORDWRAP,99,7,132,78\n    EDITTEXT        IDC_ABOUT_GLEXTENSIONS,10,162,256,53,ES_MULTILINE | \n                    ES_AUTOVSCROLL | ES_READONLY | WS_DISABLED | NOT \n                    WS_BORDER\nEND\n\nIDD_SURFACE DIALOGEX 400, 100, 412, 213\nSTYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_CAPTION | WS_SYSMENU\nEXSTYLE WS_EX_CONTROLPARENT\nCAPTION \"Surface inspector\"\nFONT 8, \"MS Sans Serif\", 0, 0, 0x1\nBEGIN\n    EDITTEXT        IDC_TEXTURE,59,7,107,12,ES_AUTOHSCROLL\n    EDITTEXT        IDC_HSHIFT,121,25,45,12,ES_AUTOHSCROLL\n    CONTROL         \"Spin2\",IDC_SPIN_HSHIFT,\"msctls_updown32\",UDS_ALIGNRIGHT | \n                    UDS_AUTOBUDDY | UDS_ARROWKEYS,155,25,11,14\n    EDITTEXT        IDC_VSHIFT,121,41,45,12,ES_AUTOHSCROLL\n    CONTROL         \"Spin2\",IDC_SPIN_VSHIFT,\"msctls_updown32\",UDS_ALIGNRIGHT | \n                    UDS_AUTOBUDDY | UDS_ARROWKEYS,155,41,11,14\n    EDITTEXT        IDC_HSCALE,121,58,45,12,ES_AUTOHSCROLL\n    CONTROL         \"Spin2\",IDC_SPIN_HSCALE,\"msctls_updown32\",UDS_ALIGNRIGHT | \n                    UDS_AUTOBUDDY | UDS_ARROWKEYS,155,58,11,14\n    EDITTEXT        IDC_VSCALE,121,75,45,12,ES_AUTOHSCROLL\n    CONTROL         \"Spin2\",IDC_SPIN_VSCALE,\"msctls_updown32\",UDS_ALIGNRIGHT | \n                    UDS_AUTOBUDDY | UDS_ARROWKEYS,155,75,11,14\n    EDITTEXT        IDC_ROTATE,121,92,45,12,ES_AUTOHSCROLL\n    CONTROL         \"Spin2\",IDC_SPIN_ROTATE,\"msctls_updown32\",UDS_ALIGNRIGHT | \n                    UDS_AUTOBUDDY | UDS_ARROWKEYS,155,91,11,14\n    EDITTEXT        IDC_VALUE,104,110,62,12,ES_AUTOHSCROLL\n    PUSHBUTTON      \"CAP\",IDC_BTN_PATCHDETAILS,11,174,34,12\n    CONTROL         \"light\",IDC_CHECK1,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    184,10,41,8\n    CONTROL         \"slick\",IDC_CHECK2,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    184,22,41,8\n    CONTROL         \"sky\",IDC_CHECK3,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    184,34,41,8\n    CONTROL         \"warp\",IDC_CHECK4,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    184,46,41,8\n    CONTROL         \"trans33\",IDC_CHECK5,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,184,58,41,8\n    CONTROL         \"trans66\",IDC_CHECK6,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,184,70,41,8\n    CONTROL         \"flowing\",IDC_CHECK7,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,184,82,41,8\n    CONTROL         \"nodraw\",IDC_CHECK8,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,184,94,41,8\n    CONTROL         \"hint\",IDC_CHECK9,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    184,106,41,8\n    CONTROL         \"skip\",IDC_CHECK10,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    184,118,41,8\n    CONTROL         \"400\",IDC_CHECK11,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    184,130,41,8\n    CONTROL         \"800\",IDC_CHECK12,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    184,142,41,8\n    CONTROL         \"1000\",IDC_CHECK13,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    184,154,41,8\n    CONTROL         \"2000\",IDC_CHECK14,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    184,166,41,8\n    CONTROL         \"4000\",IDC_CHECK15,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    184,178,41,8\n    CONTROL         \"8000\",IDC_CHECK16,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    184,190,41,8\n    CONTROL         \"10000\",IDC_CHECK17,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,234,10,48,8\n    CONTROL         \"20000\",IDC_CHECK18,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,234,22,50,8\n    CONTROL         \"40000\",IDC_CHECK19,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,234,34,41,8\n    CONTROL         \"80000\",IDC_CHECK20,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,234,46,41,8\n    CONTROL         \"100000\",IDC_CHECK21,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,234,58,41,8\n    CONTROL         \"200000\",IDC_CHECK22,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,234,70,41,8\n    CONTROL         \"400000\",IDC_CHECK23,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,234,82,41,8\n    CONTROL         \"800000\",IDC_CHECK24,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,234,94,41,8\n    CONTROL         \"1000000\",IDC_CHECK25,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,234,106,41,8\n    CONTROL         \"2000000\",IDC_CHECK26,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,234,118,41,8\n    CONTROL         \"4000000\",IDC_CHECK27,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,234,130,41,8\n    CONTROL         \"8000000\",IDC_CHECK28,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,234,142,41,8\n    CONTROL         \"10000000\",IDC_CHECK29,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,234,154,40,8\n    CONTROL         \"20000000\",IDC_CHECK30,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,234,166,45,8\n    CONTROL         \"40000000\",IDC_CHECK31,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,234,178,45,8\n    CONTROL         \"80000000\",IDC_CHECK32,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,234,190,45,8\n    CONTROL         \"solid\",IDC_CHECK33,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,304,10,41,8\n    CONTROL         \"window\",IDC_CHECK34,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,304,22,41,8\n    CONTROL         \"aux\",IDC_CHECK35,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    304,34,41,8\n    CONTROL         \"lava\",IDC_CHECK36,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    304,46,41,8\n    CONTROL         \"slime\",IDC_CHECK37,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,304,58,41,8\n    CONTROL         \"water\",IDC_CHECK38,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,304,70,41,8\n    CONTROL         \"mist\",IDC_CHECK39,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    304,82,41,8\n    CONTROL         \"80\",IDC_CHECK40,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    304,94,41,8\n    CONTROL         \"100\",IDC_CHECK41,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    304,106,41,8\n    CONTROL         \"200\",IDC_CHECK42,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    304,118,41,8\n    CONTROL         \"400\",IDC_CHECK43,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    304,130,41,8\n    CONTROL         \"800\",IDC_CHECK44,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    304,142,41,8\n    CONTROL         \"1000\",IDC_CHECK45,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    304,154,41,8\n    CONTROL         \"2000\",IDC_CHECK46,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    304,166,41,8\n    CONTROL         \"4000\",IDC_CHECK47,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    304,178,41,8\n    CONTROL         \"8000\",IDC_CHECK48,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    304,190,41,8\n    CONTROL         \"playerclip\",IDC_CHECK49,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,354,10,41,8\n    CONTROL         \"monsterclip\",IDC_CHECK50,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,354,22,50,8\n    CONTROL         \"current_0\",IDC_CHECK51,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,354,34,50,8\n    CONTROL         \"current_90\",IDC_CHECK52,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,354,46,50,8\n    CONTROL         \"current_180\",IDC_CHECK53,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,354,58,50,8\n    CONTROL         \"current_270\",IDC_CHECK54,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,354,70,50,8\n    CONTROL         \"current_up\",IDC_CHECK55,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,354,82,50,8\n    CONTROL         \"current_dn\",IDC_CHECK56,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,354,94,50,8\n    CONTROL         \"origin\",IDC_CHECK57,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,354,106,41,8\n    CONTROL         \"monster\",IDC_CHECK58,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,354,118,41,8\n    CONTROL         \"corpse\",IDC_CHECK59,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,354,130,41,8\n    CONTROL         \"detail\",IDC_CHECK60,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,354,142,41,8\n    CONTROL         \"translucent\",IDC_CHECK61,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,354,154,50,8\n    CONTROL         \"ladder\",IDC_CHECK62,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,354,166,45,8\n    CONTROL         \"40000000\",IDC_CHECK63,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,354,178,45,8\n    CONTROL         \"80000000\",IDC_CHECK64,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,354,190,45,8\n    DEFPUSHBUTTON   \"OK\",IDOK,5,194,40,14\n    PUSHBUTTON      \"Apply\",IDAPPLY,55,194,40,14\n    PUSHBUTTON      \"Cancel\",ID_BTN_CANCEL,105,194,40,14\n    RTEXT           \"Vertical shift\",IDC_STATIC,51,43,65,8\n    RTEXT           \"Horizontal stretch\",IDC_STATIC,51,60,65,8\n    RTEXT           \"Vertical stretch\",IDC_STATIC,51,77,65,8\n    RTEXT           \"Rotate\",IDC_STATIC,86,94,30,8\n    RTEXT           \"Value\",IDC_STATIC,75,112,25,8\n    LTEXT           \"Texture\",IDC_STATIC,27,9,28,8\n    GROUPBOX        \"Surf flags\",IDC_STATIC,174,0,115,204\n    GROUPBOX        \"Content flags\",IDC_STATIC,294,0,115,204\n    RTEXT           \"Horizontal shift\",IDC_STATIC,51,28,65,8\n    GROUPBOX        \"Texturing\",IDC_STATIC,5,124,161,65\n    PUSHBUTTON      \"Set...\",IDC_BTN_PATCHRESET,50,174,34,12\n    PUSHBUTTON      \"Natural\",IDC_BTN_PATCHNATURAL,89,174,34,12\n    PUSHBUTTON      \"Fit\",IDC_BTN_PATCHFIT,128,174,34,12\n    LTEXT           \"Patch\",IDC_STATIC,12,161,20,8\n    LTEXT           \"Brush\",IDC_STATIC,12,135,19,8\n    PUSHBUTTON      \"Axial\",IDC_BTN_AXIAL,12,145,34,12\n    PUSHBUTTON      \"Fit\",IDC_BTN_FACEFIT,51,145,34,12\n    EDITTEXT        IDC_EDIT_WIDTH,93,146,30,12,ES_AUTOHSCROLL | ES_NUMBER\n    CONTROL         \"Spin1\",IDC_SPIN_WIDTH,\"msctls_updown32\",UDS_WRAP | \n                    UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | \n                    UDS_ARROWKEYS,117,143,11,18\n    EDITTEXT        IDC_EDIT_HEIGHT,131,146,30,12,ES_AUTOHSCROLL | ES_NUMBER\n    CONTROL         \"Spin1\",IDC_SPIN_HEIGHT,\"msctls_updown32\",\n                    UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | \n                    UDS_ARROWKEYS,153,140,11,18\n    LTEXT           \"Width\",IDC_STATIC,94,136,20,8\n    LTEXT           \"Height\",IDC_STATIC,131,136,22,8\nEND\n\nIDD_DLG_PREFS DIALOG DISCARDABLE  0, 0, 386, 327\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Q3Radiant Preferences\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    COMBOBOX        IDC_COMBO_WHATGAME,13,18,157,76,CBS_DROPDOWN | CBS_SORT | \n                    WS_VSCROLL | WS_TABSTOP\n    CONTROL         \"&2 button\",IDC_RADIO_MOUSE,\"Button\",BS_AUTORADIOBUTTON | \n                    WS_GROUP,188,17,42,10\n    CONTROL         \"&3 button\",IDC_RADIO2,\"Button\",BS_AUTORADIOBUTTON,235,\n                    17,42,10\n    CONTROL         \"\",IDC_RADIO_VIEWTYPE,\"Button\",BS_AUTORADIOBUTTON | \n                    WS_GROUP,18,69,10,10\n    CONTROL         \"\",IDC_RADIO_VIEWTYPE2,\"Button\",BS_AUTORADIOBUTTON,45,69,\n                    11,10\n    CONTROL         \"\",IDC_RADIO_VIEWTYPE3,\"Button\",BS_AUTORADIOBUTTON,73,69,\n                    11,10\n    CONTROL         \"\",IDC_RADIO_VIEWTYPE4,\"Button\",BS_AUTORADIOBUTTON,99,69,\n                    11,10\n    CONTROL         \"Use SGI OpenGL\",IDC_CHECK_SGIOPENGL,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,15,79,71,10\n    CONTROL         \"Buggy ICD\",IDC_CHECK_BUGGYICD,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,15,90,50,10\n    CONTROL         \"OpenGL display lists\",IDC_CHECK_DISPLAYLISTS,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,15,101,79,10\n    CONTROL         \"Solid selection boxes\",IDC_CHECK_NOSTIPPLE,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,15,112,82,10\n    CONTROL         \"Slider1\",IDC_SLIDER_CAMSPEED,\"msctls_trackbar32\",\n                    WS_TABSTOP,128,57,92,11\n    CONTROL         \"Update XY views during\\nmouse drags\",\n                    IDC_CHECK_CAMXYUPDATE,\"Button\",BS_AUTOCHECKBOX | \n                    BS_MULTILINE | WS_TABSTOP,130,82,91,18\n    CONTROL         \"QE4 update model\",IDC_CHECK_QE4PAINTING,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,130,102,75,10\n    CONTROL         \"Slider1\",IDC_SLIDER_TEXTUREQUALITY,\"msctls_trackbar32\",\n                    TBS_AUTOTICKS | WS_TABSTOP,237,68,127,11\n    CONTROL         \"Texture toolbar\",IDC_CHECK_TEXTURETOOLBAR,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,236,94,63,10\n    CONTROL         \"Texture scrollbar\",IDC_CHECK_TEXTURESCROLLBAR,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,236,105,68,10\n    CONTROL         \"Texture subset\",IDC_CHECK_TEXTUREWINDOW,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,308,94,63,10\n    CONTROL         \"Right click to drop entities\",IDC_CHECK_RIGHTCLICK,\n                    \"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,13,137,95,10\n    CONTROL         \"Face selection\",IDC_CHECK_FACE,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,13,149,62,10\n    EDITTEXT        IDC_EDIT_ROTATION,58,161,24,12,ES_AUTOHSCROLL\n    CONTROL         \"ALT + multi-drag\",IDC_CHECK_ALTDRAG,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,114,137,68,10\n    CONTROL         \"Snap T to Grid\",IDC_CHECK_SNAPT,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,114,149,62,10\n    CONTROL         \"Mouse chaser\",IDC_CHECK_MOUSECHASE,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,114,160,68,10\n    CONTROL         \"Patch Toolbar\",IDC_CHECK_WIDETOOLBAR,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,193,137,61,10\n    CONTROL         \"Light drawing\",IDC_CHECK_LIGHTDRAW,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,193,149,58,10\n    CONTROL         \"Paint sizing info\",IDC_CHECK_SIZEPAINT,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,193,160,65,10\n    CONTROL         \"Hi Color Textures\",IDC_CHECK_HICOLOR,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,281,137,70,10\n    LTEXT           \"Startup Shaders:\",IDC_STATIC,281,150,54,8\n    COMBOBOX        IDC_COMBO_SHADERS,281,160,82,54,CBS_DROPDOWNLIST | \n                    WS_VSCROLL | WS_TABSTOP\n    EDITTEXT        IDC_EDIT_QUAKE2,13,189,229,12,ES_AUTOHSCROLL\n    PUSHBUTTON      \"...\",IDC_BTN_BROWSE,248,190,16,11\n    CONTROL         \"Use internal (DLL) QBSP....\",IDC_CHECK_INTERNALBSP,\n                    \"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,13,208,102,10\n    CONTROL         \"Don't clamp plane points\",IDC_CHECK_NOCLAMP,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,13,220,93,10\n    CONTROL         \"Snapshots\",IDC_CHECK_SNAPSHOTS,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,13,232,49,10\n    CONTROL         \"Use +setgame for run\",IDC_CHECK_SETGAME,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,13,244,83,10\n    CONTROL         \"Run game after QBSP3...\",IDC_CHECK_RUNQUAKE,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,121,208,96,10\n    CONTROL         \"Load last project on open\",IDC_CHECK_LOADLAST,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,121,220,96,10\n    CONTROL         \"Load last map on open\",IDC_CHECK_LOADLASTMAP,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,121,232,88,10\n    CONTROL         \"Auto save every \",IDC_CHECK_AUTOSAVE,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,121,244,66,10\n    EDITTEXT        IDC_EDIT_AUTOSAVE,188,244,27,12,ES_AUTOHSCROLL | \n                    ES_NUMBER\n    CONTROL         \"Spin1\",IDC_SPIN_AUTOSAVE,\"msctls_updown32\",UDS_WRAP | \n                    UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | \n                    UDS_ARROWKEYS,212,242,11,14\n    LTEXT           \"Status point size:\",IDC_STATIC,258,209,54,8\n    EDITTEXT        IDC_EDIT_STATUSPOINTSIZE,315,207,29,12,ES_AUTOHSCROLL\n    CONTROL         \"Spin1\",IDC_SPIN_POINTSIZE,\"msctls_updown32\",UDS_WRAP | \n                    UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | \n                    UDS_ARROWKEYS,344,206,11,14\n    LTEXT           \"Undo Levels:\",IDC_STATIC,258,222,43,8\n    EDITTEXT        IDC_EDIT_UNDOLEVELS,315,220,29,12,ES_AUTOHSCROLL\n    CONTROL         \"Spin1\",IDC_SPIN_UNDO,\"msctls_updown32\",UDS_WRAP | \n                    UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | \n                    UDS_ARROWKEYS,344,220,11,14\n    CONTROL         \"Use PAK/PK3 file(s):\",IDC_CHECK_PAK,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,13,263,81,10\n    EDITTEXT        IDC_EDIT_PAKFILE,95,262,227,12,ES_AUTOHSCROLL\n    PUSHBUTTON      \"...\",IDC_BTN_BROWSEPAK,328,263,16,11\n    EDITTEXT        IDC_EDIT_PREFABPATH,95,279,227,12,ES_AUTOHSCROLL\n    PUSHBUTTON      \"...\",IDC_BTN_BROWSEPREFAB,328,280,16,11\n    EDITTEXT        IDC_EDIT_USERPATH,95,296,227,12,ES_AUTOHSCROLL\n    PUSHBUTTON      \"...\",IDC_BTN_BROWSEUSERINI,328,297,16,11\n    DEFPUSHBUTTON   \"OK\",IDOK,341,7,38,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,341,24,38,14\n    CONTROL         \"Entities are DLL based\",IDC_CHECK_DLLENTITIES,\"Button\",\n                    BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | NOT WS_VISIBLE | \n                    WS_DISABLED | WS_TABSTOP,277,241,88,12\n    CONTROL         \"Write face color info\",IDC_CHECK_FACECOLOR,\"Button\",\n                    BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | \n                    WS_TABSTOP,279,242,79,10\n    LTEXT           \"minutes\",IDC_STATIC,216,245,25,8\n    CONTROL         \"Vertex editing\",IDC_CHECK_VERTEX,\"Button\",\n                    BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | \n                    WS_TABSTOP,296,243,83,10\n    GROUPBOX        \"Mouse\",IDC_STATIC,179,7,103,28\n    GROUPBOX        \"Views / Rendering\",IDC_STATIC,7,38,372,86\n    GROUPBOX        \"Game path / Tool settings / Stuff that wouldn't fit anywhere else\",\n                    IDC_STATIC,7,179,372,139\n    CONTROL         147,IDB_VIEWDEFAULT,\"Static\",SS_BITMAP,13,48,21,19\n    CONTROL         148,IDB_VIEWDEFAULT2,\"Static\",SS_BITMAP,40,48,21,19\n    CONTROL         149,IDB_VIEWDEFAULT3,\"Static\",SS_BITMAP,67,48,21,19\n    GROUPBOX        \"New functionality:\",IDC_STATIC,7,126,372,52\n    CONTROL         150,IDB_VIEWDEFAULT_Z,\"Static\",SS_BITMAP,93,48,21,19\n    LTEXT           \"slow\",IDC_STATIC,131,69,15,8\n    LTEXT           \"fast\",IDC_STATIC,204,69,12,8\n    GROUPBOX        \"Camera \",IDC_STATIC,126,47,100,72\n    LTEXT           \"Prefab path:\",IDC_STATIC,54,280,40,8\n    GROUPBOX        \"Optimize interface for\",IDC_STATIC,7,7,170,28\n    LTEXT           \"User INI path:\",IDC_STATIC,49,298,45,8\n    LTEXT           \"Rotation inc:\",IDC_STATIC,15,163,41,8\n    CONTROL         \"Use Shaders\",IDC_CHECK_USESHADERS,\"Button\",\n                    BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | \n                    WS_TABSTOP,289,242,57,10\n    GROUPBOX        \"Texturing\",IDC_STATIC,231,47,141,72\n    LTEXT           \"Quality\",IDC_STATIC,237,57,22,8\n    LTEXT           \"Low\",IDC_STATIC,239,81,14,8\n    LTEXT           \"High\",IDC_STATIC,347,82,16,8\nEND\n\nIDD_DLG_MAPINFO DIALOG DISCARDABLE  0, 0, 181, 183\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Map Info\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"Close\",IDOK,138,7,36,14\n    LTEXT           \"Total Brushes\",IDC_STATIC,7,14,50,8\n    EDITTEXT        IDC_EDIT_TOTALBRUSHES,66,12,40,12,ES_RIGHT | \n                    ES_AUTOHSCROLL | ES_NUMBER\n    LTEXT           \"Total Entities\",IDC_STATIC,7,30,50,8\n    EDITTEXT        IDC_EDIT_TOTALENTITIES,66,28,40,12,ES_RIGHT | \n                    ES_AUTOHSCROLL | ES_NUMBER\n    LTEXT           \"Net brush count\\n(non entity)\",IDC_STATIC,7,49,57,17\n    EDITTEXT        IDC_EDIT_NET,66,47,40,12,ES_RIGHT | ES_AUTOHSCROLL | \n                    ES_NUMBER\n    LISTBOX         IDC_LIST_ENTITIES,7,81,167,95,LBS_SORT | LBS_USETABSTOPS | \n                    LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP\n    LTEXT           \"Entity breakdown\",IDC_STATIC,7,71,56,8\nEND\n\nIDD_DLG_ENTITYLIST DIALOG DISCARDABLE  0, 0, 294, 226\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Entities\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"Close\",IDOK,248,205,39,14\n    CONTROL         \"Tree1\",IDC_TREE_ENTITY,\"SysTreeView32\",TVS_HASBUTTONS | \n                    TVS_HASLINES | TVS_LINESATROOT | WS_BORDER | WS_TABSTOP,\n                    7,7,148,212\n    DEFPUSHBUTTON   \"Select\",IDSELECT,161,205,39,14\n    CONTROL         \"List2\",IDC_LIST_ENTITY,\"SysListView32\",LVS_REPORT | \n                    LVS_SINGLESEL | LVS_EDITLABELS | LVS_NOSORTHEADER | \n                    WS_BORDER | WS_TABSTOP,161,7,126,187\nEND\n\nIDD_DLG_SCRIPTS DIALOG DISCARDABLE  0, 0, 212, 215\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Available Scripts\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"New...\",ID_NEW,166,74,39,14,WS_DISABLED\n    PUSHBUTTON      \"Close\",IDOK,168,194,37,14\n    LISTBOX         IDC_LIST_SCRIPTS,7,56,146,152,LBS_SORT | \n                    LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP\n    DEFPUSHBUTTON   \"Edit...\",ID_EDIT,166,90,39,14,WS_DISABLED\n    DEFPUSHBUTTON   \"Run\",ID_RUN,166,56,39,14\n    LTEXT           \"WARNING: BrushScripting is in a highly experimental state and is far from complete. If you attempt to use them it is VERY LIKELY that Q3Radiant will crash. Save your work before attempting to make use of any scripting features.\",\n                    IDC_STATIC,7,7,198,38\nEND\n\nIDD_DLG_NEWPROJECT DIALOG DISCARDABLE  0, 0, 246, 74\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"New project\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    EDITTEXT        IDC_EDIT_NAME,57,28,116,12,ES_AUTOHSCROLL\n    DEFPUSHBUTTON   \"OK\",IDOK,189,7,50,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,189,24,50,14\n    LTEXT           \"This will create a new directory beneath your Quake2 path based on the project name you give.\",\n                    IDC_STATIC,7,7,165,19\n    LTEXT           \"Project name:\",IDC_STATIC,7,30,44,8\n    CONTROL         \"Include game dll files\",IDC_CHECK1,\"Button\",\n                    BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,7,49,81,10\nEND\n\nIDD_DLG_COMMANDLIST DIALOG DISCARDABLE  0, 0, 283, 223\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Mapped Commands\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"Close\",IDOK,241,202,35,14\n    LISTBOX         IDC_LIST_COMMANDS,7,7,221,209,LBS_SORT | LBS_USETABSTOPS | \n                    LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP\nEND\n\nIDD_DIALOG_SCALE DIALOG DISCARDABLE  0, 0, 122, 74\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Scale\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"OK\",IDOK,79,7,36,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,79,23,36,14\n    LTEXT           \"X:\",IDC_STATIC,7,15,8,8\n    LTEXT           \"Y:\",IDC_STATIC,7,32,8,8\n    LTEXT           \"Z:\",IDC_STATIC,7,49,8,8\n    EDITTEXT        IDC_EDIT_X,22,13,32,12,ES_AUTOHSCROLL\n    EDITTEXT        IDC_EDIT_Y,22,30,32,12,ES_AUTOHSCROLL\n    EDITTEXT        IDC_EDIT_Z,22,47,32,12,ES_AUTOHSCROLL\nEND\n\nIDD_DIALOG_FINDREPLACE DIALOGEX 0, 0, 222, 98\nSTYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_CAPTION | WS_SYSMENU\nEXSTYLE WS_EX_CONTROLPARENT\nCAPTION \"Find replace texture(s)\"\nFONT 8, \"MS Sans Serif\", 0, 0, 0x1\nBEGIN\n    EDITTEXT        IDC_EDIT_FIND,27,16,132,12,ES_AUTOHSCROLL\n    EDITTEXT        IDC_EDIT_REPLACE,45,31,114,12,ES_AUTOHSCROLL\n    CONTROL         \"Replace within selected brushes only\",\n                    IDC_CHECK_SELECTED,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    7,51,133,10\n    CONTROL         \"Force replacement (ignore current texture name)\",\n                    IDC_CHECK_FORCE,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,7,\n                    63,167,10\n    DEFPUSHBUTTON   \"OK\",IDOK,175,7,40,14\n    PUSHBUTTON      \"Close\",IDCANCEL,175,77,40,14\n    LTEXT           \"Find:\",IDC_STATIC,7,18,16,8\n    LTEXT           \"Replace:\",IDC_STATIC,7,33,30,8\n    DEFPUSHBUTTON   \"Apply\",ID_BTN_APPLY,175,25,40,14\n    CONTROL         \"Live updates from Texture/Camera Windows\",\n                    IDC_CHECK_LIVE,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,7,\n                    79,157,10\nEND\n\nIDD_DIALOG_STAIRS DIALOG DISCARDABLE  0, 0, 196, 143\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Stairs\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"OK\",IDOK,147,7,42,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,136,24,42,14\n    LTEXT           \"This creates a set of stairs using the selected brush as a template. You may optionally specify a rotation angle to be applied to each new step\",\n                    IDC_STATIC,7,7,120,37\n    LTEXT           \"After pressing OK, left click to select a \"\"height\"\" point for the stairs. Enough stairs will be created to consume the hieght (Z) between the selected brush and the point you specify\",\n                    IDC_STATIC,7,46,116,53\n    LTEXT           \"Rotation per step:\",IDC_STATIC,7,104,57,8\n    EDITTEXT        IDC_EDIT_ROTATION,69,102,40,12,ES_AUTOHSCROLL\nEND\n\nIDD_DIALOG_INPUT DIALOG DISCARDABLE  0, 0, 171, 173\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"BrushScript Input\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"OK\",IDOK,127,7,37,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,127,24,37,14\n    LTEXT           \"Field1:\",IDC_STATIC_FIELD1,7,13,96,8\n    EDITTEXT        IDC_EDIT_FIELD1,7,23,47,14,ES_AUTOHSCROLL\n    LTEXT           \"Field1:\",IDC_STATIC_FIELD2,7,41,105,8\n    EDITTEXT        IDC_EDIT_FIELD2,7,51,47,14,ES_AUTOHSCROLL\n    LTEXT           \"Field1:\",IDC_STATIC_FIELD3,7,71,115,8\n    EDITTEXT        IDC_EDIT_FIELD3,7,81,47,14,ES_AUTOHSCROLL\n    LTEXT           \"Field1:\",IDC_STATIC_FIELD4,7,103,129,8\n    EDITTEXT        IDC_EDIT_FIELD4,7,113,47,14,ES_AUTOHSCROLL\n    LTEXT           \"Field1:\",IDC_STATIC_FIELD5,7,133,135,8\n    EDITTEXT        IDC_EDIT_FIELD5,7,142,47,14,ES_AUTOHSCROLL\nEND\n\nIDD_DLG_INFORMATION DIALOG DISCARDABLE  0, 0, 186, 95\nSTYLE WS_POPUP | WS_CAPTION\nCAPTION \"Information\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    EDITTEXT        IDC_EDIT1,7,7,172,81,ES_MULTILINE | WS_DISABLED | \n                    WS_VSCROLL\nEND\n\nIDD_PROJECT DIALOGEX 250, 100, 341, 335\nSTYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU\nCAPTION \"Project Settings\"\nFONT 8, \"MS Sans Serif\", 0, 0, 0x1\nBEGIN\n    EDITTEXT        IDC_PRJBASEPATH,75,20,205,12,ES_AUTOHSCROLL\n    EDITTEXT        IDC_PRJMAPSPATH,75,40,205,12,ES_AUTOHSCROLL\n    EDITTEXT        IDC_PRJRSHCMD,75,60,205,12,ES_AUTOHSCROLL\n    EDITTEXT        IDC_PRJREMOTEBASE,75,80,205,12,ES_AUTOHSCROLL\n    EDITTEXT        IDC_PRJENTITYPATH,75,100,205,12,ES_AUTOHSCROLL\n    EDITTEXT        IDC_PRJTEXPATH,75,120,205,12,ES_AUTOHSCROLL\n    LISTBOX         IDC_CMD_LIST,10,157,270,90,LBS_SORT | \n                    LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP,\n                    WS_EX_CLIENTEDGE\n    PUSHBUTTON      \"Add...\",IDC_ADDCMD,290,150,45,13\n    PUSHBUTTON      \"Change...\",IDC_EDITCMD,290,167,45,13\n    PUSHBUTTON      \"Remove\",IDC_REMCMD,290,184,45,13\n    CONTROL         \"Use brush primitives in MAP files\",IDC_CHECK_BPRIMIT,\n                    \"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,11,270,136,9\n    DEFPUSHBUTTON   \"OK\",IDOK,290,10,45,13\n    PUSHBUTTON      \"Cancel\",IDCANCEL,290,26,45,13\n    GROUPBOX        \"Project settings\",IDC_STATIC,5,7,280,133\n    LTEXT           \"basepath\",IDC_STATIC,42,22,30,8\n    LTEXT           \"rshcmd\",IDC_STATIC,48,62,24,8\n    LTEXT           \"remotebasepath\",IDC_STATIC,20,82,52,8\n    LTEXT           \"entitypath\",IDC_STATIC,40,102,32,8\n    LTEXT           \"texturepath\",IDC_STATIC,36,122,36,8\n    GROUPBOX        \"Menu commands\",IDC_STATIC,5,146,280,105\n    LTEXT           \"mapspath\",IDC_STATIC,40,42,32,8\n    GROUPBOX        \"Misc settings\",IDC_STATIC,5,258,280,73\nEND\n\nIDD_ADDCMD DIALOG DISCARDABLE  300, 200, 312, 65\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Add command\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"OK\",IDOK,116,44,37,13\n    PUSHBUTTON      \"Cancel\",IDCANCEL,159,44,37,13\n    EDITTEXT        IDC_CMDMENUTEXT,44,8,254,12,ES_AUTOHSCROLL\n    EDITTEXT        IDC_CMDCOMMAND,44,26,254,12,ES_AUTOHSCROLL\n    LTEXT           \"Menu text\",IDC_STATIC,5,10,32,8\n    LTEXT           \"Command\",IDC_STATIC,5,28,32,8\nEND\n\nIDD_TEXTUREBAR DIALOG DISCARDABLE  0, 0, 313, 19\nSTYLE WS_CHILD\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    EDITTEXT        IDC_HSHIFT,33,4,32,12,ES_AUTOHSCROLL\n    CONTROL         \"Spin1\",IDC_SPIN_HSHIFT,\"msctls_updown32\",UDS_ALIGNRIGHT | \n                    UDS_AUTOBUDDY | UDS_ARROWKEYS,56,3,10,14\n    EDITTEXT        IDC_VSHIFT,76,4,32,12,ES_AUTOHSCROLL\n    CONTROL         \"Spin1\",IDC_SPIN_VSHIFT,\"msctls_updown32\",UDS_ALIGNRIGHT | \n                    UDS_AUTOBUDDY | UDS_ARROWKEYS,97,3,11,14\n    EDITTEXT        IDC_HSCALE,143,4,32,12,ES_AUTOHSCROLL\n    CONTROL         \"Spin1\",IDC_SPIN_HSCALE,\"msctls_updown32\",UDS_ALIGNRIGHT | \n                    UDS_AUTOBUDDY | UDS_ARROWKEYS,164,3,11,14\n    EDITTEXT        IDC_VSCALE,188,4,32,12,ES_AUTOHSCROLL\n    CONTROL         \"Spin1\",IDC_SPIN_VSCALE,\"msctls_updown32\",UDS_ALIGNRIGHT | \n                    UDS_AUTOBUDDY | UDS_ARROWKEYS,210,3,11,14\n    EDITTEXT        IDC_ROTATE,252,4,32,12,ES_AUTOHSCROLL\n    CONTROL         \"Spin1\",IDC_SPIN_ROTATE,\"msctls_updown32\",UDS_ALIGNRIGHT | \n                    UDS_AUTOBUDDY | UDS_ARROWKEYS,272,3,11,14\n    LTEXT           \"Shift H\",IDC_STATIC,7,6,22,8\n    LTEXT           \"V\",IDC_STATIC,68,6,8,8\n    LTEXT           \"Scale H\",IDC_STATIC,112,6,26,8\n    LTEXT           \"V\",IDC_STATIC,180,6,8,8\n    LTEXT           \"Rotate\",IDC_STATIC,226,6,22,8\n    DEFPUSHBUTTON   \"Button1\",IDC_BTN_APPLYTEXTURESTUFF,278,2,11,8,NOT \n                    WS_VISIBLE | NOT WS_TABSTOP\n    EDITTEXT        IDC_EDIT_ROTATEAMT,287,4,20,12,ES_AUTOHSCROLL\nEND\n\nIDD_DIALOG_TEXTURELIST DIALOG DISCARDABLE  0, 0, 257, 279\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Textures\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"&Load\",IDOK,205,7,45,14\n    PUSHBUTTON      \"Close\",IDCANCEL,205,23,45,14\n    LISTBOX         IDC_LIST_TEXTURES,7,7,189,265,LBS_SORT | \n                    LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP\nEND\n\nIDD_DIALOG_NEWPATCH DIALOG DISCARDABLE  0, 0, 129, 58\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Patch density\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"OK\",IDOK,90,7,32,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,90,24,32,14\n    LTEXT           \"Width:\",IDC_STATIC,9,9,22,8\n    LTEXT           \"Height:\",IDC_STATIC,7,27,24,8\n    COMBOBOX        IDC_COMBO_WIDTH,38,7,33,51,CBS_DROPDOWNLIST | WS_VSCROLL | \n                    WS_TABSTOP\n    COMBOBOX        IDC_COMBO_HEIGHT,38,25,33,51,CBS_DROPDOWNLIST | \n                    WS_VSCROLL | WS_TABSTOP\nEND\n\nIDD_DIALOG_TEXTURELAYOUT DIALOG DISCARDABLE  0, 0, 186, 95\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Patch texture layout\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"OK\",IDOK,141,7,38,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,141,24,38,14\n    LTEXT           \"Texture will be fit across the patch based on the x and y values given. Values of 1x1 will \"\"fit\"\" the texture. 2x2 will repeat it twice, etc.\",\n                    IDC_STATIC,7,7,122,36\n    LTEXT           \"Texture x:\",IDC_STATIC,7,48,32,8\n    EDITTEXT        IDC_EDIT_X,42,46,30,12,ES_AUTOHSCROLL\n    LTEXT           \"Texture y:\",IDC_STATIC,7,64,32,8\n    EDITTEXT        IDC_EDIT_Y,42,62,30,12,ES_AUTOHSCROLL\nEND\n\nIDD_DIALOG_CAP DIALOG DISCARDABLE  0, 0, 171, 84\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Cap\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"OK\",IDOK,123,7,41,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,123,25,41,14\n    CONTROL         \"Bevel\",IDC_RADIO_CAP,\"Button\",BS_AUTORADIOBUTTON | \n                    WS_GROUP,31,10,50,10\n    CONTROL         \"Endcap\",IDC_RADIO_CAP2,\"Button\",BS_AUTORADIOBUTTON,31,\n                    28,50,10\n    CONTROL         \"Inverted Bevel\",IDC_RADIO_CAP3,\"Button\",\n                    BS_AUTORADIOBUTTON,31,47,68,10\n    CONTROL         \"Inverted Endcap\",IDC_RADIO_CAP4,\"Button\",\n                    BS_AUTORADIOBUTTON,31,65,75,10\n    CONTROL         177,IDC_STATIC,\"Static\",SS_BITMAP | SS_REALSIZEIMAGE | \n                    SS_SUNKEN,7,7,18,15\n    CONTROL         178,IDC_STATIC,\"Static\",SS_BITMAP | SS_REALSIZEIMAGE | \n                    SS_SUNKEN,7,44,18,15\n    CONTROL         176,IDC_STATIC,\"Static\",SS_BITMAP | SS_REALSIZEIMAGE | \n                    SS_SUNKEN,7,26,18,15\n    CONTROL         175,IDC_STATIC,\"Static\",SS_BITMAP | SS_REALSIZEIMAGE | \n                    SS_SUNKEN,7,63,17,14\nEND\n\nIDD_DIALOG_THICKEN DIALOG DISCARDABLE  0, 0, 204, 63\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Thicken Patch\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"OK\",IDOK,158,7,39,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,158,24,39,14\n    LTEXT           \"This produces a func_grouped set of patches that contains the original patch along with the 'thick' patch and an optional set of seam patches. \",\n                    IDC_STATIC,7,7,145,33\n    EDITTEXT        IDC_EDIT_AMOUNT,38,42,26,12,ES_AUTOHSCROLL\n    LTEXT           \"Amount:\",IDC_STATIC,7,44,27,8\n    CONTROL         \"Seams\",IDC_CHECK_SEAMS,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,74,43,37,10\nEND\n\nIDD_DIALOG_PATCH DIALOG DISCARDABLE  0, 0, 272, 178\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Patch Properties\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    COMBOBOX        IDC_COMBO_ROW,15,29,34,79,CBS_DROPDOWNLIST | CBS_SORT | \n                    WS_VSCROLL | WS_TABSTOP\n    COMBOBOX        IDC_COMBO_COL,54,29,34,84,CBS_DROPDOWNLIST | CBS_SORT | \n                    WS_VSCROLL | WS_TABSTOP\n    EDITTEXT        IDC_EDIT_X,34,49,54,12,ES_AUTOHSCROLL\n    EDITTEXT        IDC_EDIT_Y,33,64,55,12,ES_AUTOHSCROLL\n    EDITTEXT        IDC_EDIT_Z,33,81,55,12,ES_AUTOHSCROLL\n    EDITTEXT        IDC_EDIT_S,33,98,55,12,ES_AUTOHSCROLL\n    EDITTEXT        IDC_EDIT_T,33,115,55,12,ES_AUTOHSCROLL\n    COMBOBOX        IDC_COMBO_TYPE,33,134,55,79,CBS_DROPDOWNLIST | CBS_SORT | \n                    WS_VSCROLL | WS_TABSTOP\n    EDITTEXT        IDC_EDIT_NAME,106,29,144,12,ES_AUTOHSCROLL\n    EDITTEXT        IDC_HSHIFT,107,48,45,12,ES_AUTOHSCROLL\n    CONTROL         \"Spin2\",IDC_SPIN_HSHIFT,\"msctls_updown32\",UDS_ALIGNRIGHT | \n                    UDS_AUTOBUDDY | UDS_ARROWKEYS,141,48,11,14\n    EDITTEXT        IDC_VSHIFT,107,64,45,12,ES_AUTOHSCROLL\n    CONTROL         \"Spin2\",IDC_SPIN_VSHIFT,\"msctls_updown32\",UDS_ALIGNRIGHT | \n                    UDS_AUTOBUDDY | UDS_ARROWKEYS,141,64,11,14\n    EDITTEXT        IDC_HSCALE,107,81,45,12,ES_AUTOHSCROLL\n    CONTROL         \"Spin2\",IDC_SPIN_HSCALE,\"msctls_updown32\",UDS_ALIGNRIGHT | \n                    UDS_AUTOBUDDY | UDS_ARROWKEYS,141,81,11,14\n    EDITTEXT        IDC_VSCALE,107,98,45,12,ES_AUTOHSCROLL\n    CONTROL         \"Spin2\",IDC_SPIN_VSCALE,\"msctls_updown32\",UDS_ALIGNRIGHT | \n                    UDS_AUTOBUDDY | UDS_ARROWKEYS,141,98,11,14\n    EDITTEXT        IDC_ROTATE,107,115,45,12,ES_AUTOHSCROLL\n    CONTROL         \"Spin2\",IDC_SPIN_ROTATE,\"msctls_updown32\",UDS_ALIGNRIGHT | \n                    UDS_AUTOBUDDY | UDS_ARROWKEYS,141,114,11,14\n    PUSHBUTTON      \"CAP\",IDC_BTN_PATCHDETAILS,109,134,32,13\n    PUSHBUTTON      \"Set...\",IDC_BTN_PATCHRESET,148,134,32,13\n    PUSHBUTTON      \"Natural\",IDC_BTN_PATCHNATURAL,185,134,32,13\n    PUSHBUTTON      \"Fit\",IDC_BTN_PATCHFIT,225,134,32,13\n    PUSHBUTTON      \"Apply\",ID_APPLY,184,159,38,12\n    DEFPUSHBUTTON   \"Done\",IDOK,227,159,38,12\n    LTEXT           \"Row:\",IDC_STATIC,15,17,18,8\n    LTEXT           \"Column:\",IDC_STATIC,54,17,26,8\n    LTEXT           \"X:\",IDC_STATIC,21,51,8,8\n    LTEXT           \"Y:\",IDC_STATIC,21,66,8,8\n    LTEXT           \"Z:\",IDC_STATIC,21,83,8,8\n    LTEXT           \"S:\",IDC_STATIC,21,100,8,8\n    LTEXT           \"T:\",IDC_STATIC,21,117,8,8\n    LTEXT           \"Name:\",IDC_STATIC,106,17,22,8\n    LTEXT           \"Vertical shift\",IDC_STATIC,157,66,65,8\n    LTEXT           \"Horizontal stretch\",IDC_STATIC,157,83,65,8\n    LTEXT           \"Vertical stretch\",IDC_STATIC,157,100,65,8\n    LTEXT           \"Rotate\",IDC_STATIC,157,117,30,8\n    LTEXT           \"Horizontal shift\",IDC_STATIC,157,51,65,8\n    GROUPBOX        \"Texturing\",IDC_STATIC,99,7,166,148\n    GROUPBOX        \"Details\",IDC_STATIC,7,7,87,148\n    LTEXT           \"Type:\",IDC_STATIC,13,136,19,8\nEND\n\nIDD_PLAYWAVE DIALOG DISCARDABLE  0, 0, 33, 15\nSTYLE WS_CHILD\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    PUSHBUTTON      \"Play\",IDC_BTN_PLAY,0,0,33,15\nEND\n\nIDD_TEXLIST DIALOG DISCARDABLE  0, 0, 251, 273\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Load multiple texture paths\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"Load\",IDOK,194,7,50,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,194,24,50,14\n    LISTBOX         IDC_LIST_TEXTURES,7,7,179,259,LBS_SORT | \n                    LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP\nEND\n\nIDD_DLG_GROUP DIALOG DISCARDABLE  0, 0, 194, 241\nSTYLE DS_CONTROL | WS_CHILD | WS_BORDER\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    CONTROL         \"Tree1\",IDC_TREE_GROUP,\"SysTreeView32\",TVS_HASBUTTONS | \n                    TVS_HASLINES | TVS_LINESATROOT | TVS_EDITLABELS | \n                    WS_BORDER | WS_TABSTOP,7,7,180,209\n    PUSHBUTTON      \"Add...\",IDC_BTN_ADD,7,221,33,12\n    PUSHBUTTON      \"Delete\",IDC_BTN_DEL,83,221,33,12\n    PUSHBUTTON      \"Edit...\",IDC_BTN_EDIT,44,221,33,12\nEND\n\nIDD_NEWNAME DIALOG DISCARDABLE  0, 0, 186, 46\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"New\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    EDITTEXT        IDC_EDIT_NAME,31,10,106,12,ES_AUTOHSCROLL\n    DEFPUSHBUTTON   \"OK\",IDOK,143,7,36,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,143,24,36,14\n    LTEXT           \"Name:\",IDC_STATIC,7,12,22,8\nEND\n\nIDD_DLG_CAMERA DIALOG DISCARDABLE  0, 0, 277, 295\nSTYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Camera Inspector\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"Close\",IDOK,220,274,50,14\n    LTEXT           \"Name\",IDC_STATIC,7,14,24,8\n    EDITTEXT        IDC_EDIT_CAM_NAME,32,12,154,12,ES_AUTOHSCROLL\n    LTEXT           \"Edit >\",IDC_STATIC,11,70,20,8\n    COMBOBOX        IDC_COMBO_SPLINES,33,68,154,81,CBS_DROPDOWNLIST | \n                    WS_VSCROLL | WS_TABSTOP\n    PUSHBUTTON      \"Add Target...\",IDC_BTN_ADDTARGET,34,54,53,11\n    SCROLLBAR       IDC_SCROLLBAR_SEGMENT,14,168,165,10\n    LTEXT           \"Length ( seconds )\",IDC_STATIC,14,140,60,8\n    EDITTEXT        IDC_EDIT_LENGTH,75,138,30,12,ES_AUTOHSCROLL\n    LTEXT           \"Current Time:\",IDC_STATIC,14,156,43,8\n    LISTBOX         IDC_LIST_EVENTS,14,207,152,65,LBS_USETABSTOPS | \n                    LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP\n    GROUPBOX        \"Time\",IDC_STATIC,7,129,200,159\n    EDITTEXT        IDC_EDIT_SEGMENT,61,154,40,12,ES_RIGHT | ES_AUTOHSCROLL | \n                    ES_READONLY\n    LTEXT           \"Events\",IDC_STATIC,14,195,23,8\n    PUSHBUTTON      \"Add...\",IDC_BTN_ADDEVENT,171,207,32,11\n    PUSHBUTTON      \"Del\",IDC_BTN_DELEVENT,171,221,32,11\n    DEFPUSHBUTTON   \"Apply\",IDAPPLY,220,91,50,14\n    DEFPUSHBUTTON   \"Load...\",ID_FILE_OPEN,220,26,50,14\n    DEFPUSHBUTTON   \"Save...\",ID_FILE_SAVE,220,42,50,14\n    DEFPUSHBUTTON   \"New\",ID_FILE_NEW,220,7,50,14\n    DEFPUSHBUTTON   \"Preview\",ID_TESTCAMERA,220,109,50,14\n    CONTROL         \"Track Camera\",IDC_CHECK_TRACKCAMERA,\"Button\",\n                    BS_AUTOCHECKBOX | WS_TABSTOP,14,180,61,10\n    LTEXT           \"of\",IDC_STATIC,109,155,11,9\n    EDITTEXT        IDC_EDIT_TOTALSEGMENTS,122,154,35,12,ES_RIGHT | \n                    ES_AUTOHSCROLL | ES_READONLY\n    GROUPBOX        \"Path and Target editing\",IDC_STATIC,7,43,201,83\n    CONTROL         \"Edit Points\",IDC_RADIO_EDITPOINTS,\"Button\",\n                    BS_AUTORADIOBUTTON | WS_GROUP,13,86,52,9\n    CONTROL         \"Add Points\",IDC_RADIO_EDITPOINTS2,\"Button\",\n                    BS_AUTORADIOBUTTON,13,97,52,9\n    PUSHBUTTON      \"Delete Selected\",IDC_BTN_DELETEPOINTS,13,109,61,11\n    LTEXT           \"Type:\",IDC_STATIC,7,30,20,9\n    EDITTEXT        IDC_EDIT_TYPE,32,28,48,12,ES_AUTOHSCROLL | ES_READONLY\n    PUSHBUTTON      \"Select All\",IDC_BTN_SELECTALL,78,109,61,11\nEND\n\nIDD_DLG_CAMERAEVENT DIALOG DISCARDABLE  0, 0, 166, 158\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Camera Event\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    CONTROL         \"Wait\",IDC_RADIO_EVENT,\"Button\",BS_AUTORADIOBUTTON | \n                    WS_GROUP,14,18,31,10\n    CONTROL         \"Target wait\",IDC_RADIO9,\"Button\",BS_AUTORADIOBUTTON,14,\n                    28,51,10\n    CONTROL         \"Speed\",IDC_RADIO10,\"Button\",BS_AUTORADIOBUTTON,14,38,37,\n                    10\n    CONTROL         \"Change target\",IDC_RADIO5,\"Button\",BS_AUTORADIOBUTTON,\n                    14,48,61,10\n    CONTROL         \"Snap target\",IDC_RADIO6,\"Button\",BS_AUTORADIOBUTTON,14,\n                    58,53,10\n    CONTROL         \"FOV\",IDC_RADIO7,\"Button\",BS_AUTORADIOBUTTON,14,68,30,10\n    CONTROL         \"Run script\",IDC_RADIO8,\"Button\",BS_AUTORADIOBUTTON,14,\n                    78,48,10\n    CONTROL         \"Trigger\",IDC_RADIO11,\"Button\",BS_AUTORADIOBUTTON,14,88,\n                    38,10\n    CONTROL         \"Stop\",IDC_RADIO12,\"Button\",BS_AUTORADIOBUTTON,15,99,31,\n                    10\n    EDITTEXT        IDC_EDIT_PARAM,7,133,124,12,ES_AUTOHSCROLL\n    DEFPUSHBUTTON   \"OK\",IDOK,124,7,35,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,123,24,35,14\n    GROUPBOX        \"Type\",IDC_STATIC,7,7,81,109\n    LTEXT           \"Paremeter:\",IDC_STATIC,7,121,35,8\nEND\n\nIDD_DLG_CAMERATARGET DIALOG DISCARDABLE  0, 0, 194, 93\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Camera Target\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    CONTROL         \"Fixed\",IDC_RADIO_FIXED,\"Button\",BS_AUTORADIOBUTTON | \n                    WS_GROUP,15,38,37,10\n    CONTROL         \"Interpolated\",IDC_RADIO2,\"Button\",BS_AUTORADIOBUTTON,15,\n                    49,60,11\n    CONTROL         \"Spline\",IDC_RADIO3,\"Button\",BS_AUTORADIOBUTTON,15,61,60,\n                    11\n    DEFPUSHBUTTON   \"OK\",IDOK,146,7,41,11\n    PUSHBUTTON      \"Cancel\",IDCANCEL,146,21,41,11\n    LTEXT           \"Name:\",IDC_STATIC,7,7,23,10\n    EDITTEXT        IDC_EDIT_NAME,32,7,105,12,ES_AUTOHSCROLL\n    GROUPBOX        \"Type\",IDC_STATIC,7,26,130,53\nEND\n\n\n#ifndef _MAC\n/////////////////////////////////////////////////////////////////////////////\n//\n// Version\n//\n\nVS_VERSION_INFO VERSIONINFO\n FILEVERSION 1,0,0,1\n PRODUCTVERSION 1,0,0,1\n FILEFLAGSMASK 0x3fL\n#ifdef _DEBUG\n FILEFLAGS 0x1L\n#else\n FILEFLAGS 0x0L\n#endif\n FILEOS 0x4L\n FILETYPE 0x1L\n FILESUBTYPE 0x0L\nBEGIN\n    BLOCK \"StringFileInfo\"\n    BEGIN\n        BLOCK \"040904b0\"\n        BEGIN\n            VALUE \"Comments\", \"\\0\"\n            VALUE \"CompanyName\", \"\\0\"\n            VALUE \"FileDescription\", \"Radiant MFC Application\\0\"\n            VALUE \"FileVersion\", \"1, 0, 0, 1\\0\"\n            VALUE \"InternalName\", \"Radiant\\0\"\n            VALUE \"LegalCopyright\", \"Copyright (C) 1997\\0\"\n            VALUE \"LegalTrademarks\", \"\\0\"\n            VALUE \"OriginalFilename\", \"Radiant.EXE\\0\"\n            VALUE \"PrivateBuild\", \"\\0\"\n            VALUE \"ProductName\", \"Radiant Application\\0\"\n            VALUE \"ProductVersion\", \"1, 0, 0, 1\\0\"\n            VALUE \"SpecialBuild\", \"\\0\"\n        END\n    END\n    BLOCK \"VarFileInfo\"\n    BEGIN\n        VALUE \"Translation\", 0x409, 1200\n    END\nEND\n\n#endif    // !_MAC\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// DESIGNINFO\n//\n\n#ifdef APSTUDIO_INVOKED\nGUIDELINES DESIGNINFO DISCARDABLE \nBEGIN\n    IDD_GAMMA, DIALOG\n    BEGIN\n        RIGHTMARGIN, 127\n        BOTTOMMARGIN, 76\n    END\n\n    IDD_SIDES, DIALOG\n    BEGIN\n        RIGHTMARGIN, 126\n        BOTTOMMARGIN, 45\n    END\n\n    IDD_DLG_PREFS, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 379\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 320\n    END\n\n    IDD_DLG_MAPINFO, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 174\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 176\n    END\n\n    IDD_DLG_ENTITYLIST, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 287\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 219\n    END\n\n    IDD_DLG_SCRIPTS, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 205\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 208\n    END\n\n    IDD_DLG_NEWPROJECT, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 239\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 67\n    END\n\n    IDD_DLG_COMMANDLIST, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 276\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 216\n    END\n\n    IDD_DIALOG_SCALE, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 115\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 67\n    END\n\n    IDD_DIALOG_FINDREPLACE, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 215\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 80\n    END\n\n    IDD_DIALOG_STAIRS, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 189\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 136\n    END\n\n    IDD_DIALOG_INPUT, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 164\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 166\n    END\n\n    IDD_DLG_INFORMATION, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 179\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 88\n    END\n\n    IDD_ADDCMD, DIALOG\n    BEGIN\n        BOTTOMMARGIN, 60\n    END\n\n    IDD_DIALOG_TEXTURELIST, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 250\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 272\n    END\n\n    IDD_DIALOG_NEWPATCH, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 122\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 51\n    END\n\n    IDD_DIALOG_TEXTURELAYOUT, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 179\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 88\n    END\n\n    IDD_DIALOG_CAP, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 164\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 77\n    END\n\n    IDD_DIALOG_THICKEN, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 197\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 56\n    END\n\n    IDD_DIALOG_PATCH, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 265\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 171\n    END\n\n    IDD_TEXLIST, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 244\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 266\n    END\n\n    IDD_DLG_GROUP, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 187\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 233\n    END\n\n    IDD_NEWNAME, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 179\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 39\n    END\n\n    IDD_DLG_CAMERA, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 270\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 288\n    END\n\n    IDD_DLG_CAMERAEVENT, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 159\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 151\n    END\n\n    IDD_DLG_CAMERATARGET, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 187\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 86\n    END\nEND\n#endif    // APSTUDIO_INVOKED\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Dialog Info\n//\n\nIDD_DIALOG_NEWPATCH DLGINIT\nBEGIN\n    IDC_COMBO_WIDTH, 0x403, 2, 0\n0x0033, \n    IDC_COMBO_WIDTH, 0x403, 2, 0\n0x0035, \n    IDC_COMBO_WIDTH, 0x403, 2, 0\n0x0037, \n    IDC_COMBO_WIDTH, 0x403, 2, 0\n0x0039, \n    IDC_COMBO_WIDTH, 0x403, 3, 0\n0x3131, \"\\000\" \n    IDC_COMBO_WIDTH, 0x403, 3, 0\n0x3331, \"\\000\" \n    IDC_COMBO_WIDTH, 0x403, 3, 0\n0x3531, \"\\000\" \n    IDC_COMBO_HEIGHT, 0x403, 2, 0\n0x0033, \n    IDC_COMBO_HEIGHT, 0x403, 2, 0\n0x0035, \n    IDC_COMBO_HEIGHT, 0x403, 2, 0\n0x0037, \n    IDC_COMBO_HEIGHT, 0x403, 2, 0\n0x0039, \n    IDC_COMBO_HEIGHT, 0x403, 3, 0\n0x3131, \"\\000\" \n    IDC_COMBO_HEIGHT, 0x403, 3, 0\n0x3331, \"\\000\" \n    IDC_COMBO_HEIGHT, 0x403, 3, 0\n0x3531, \"\\000\" \n    0\nEND\n\nIDD_DLG_PREFS DLGINIT\nBEGIN\n    IDC_COMBO_SHADERS, 0x403, 5, 0\n0x6f4e, 0x656e, \"\\000\" \n    IDC_COMBO_SHADERS, 0x403, 7, 0\n0x6f43, 0x6d6d, 0x6e6f, \"\\000\" \n    IDC_COMBO_SHADERS, 0x403, 4, 0\n0x6c41, 0x006c, \n    0\nEND\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// String Table\n//\n\nSTRINGTABLE PRELOAD DISCARDABLE \nBEGIN\n    IDR_MAINFRAME           \"Q3Radiant\"\n    IDR_RADIANTYPE          \"\\nRadian\\nRadian\\n\\n\\nRadiant.Document\\nRadian Document\"\n    IDS_STRING1             \"DOOM\"\nEND\n\nSTRINGTABLE PRELOAD DISCARDABLE \nBEGIN\n    AFX_IDS_APP_TITLE       \"Radiant\"\n    AFX_IDS_IDLEMESSAGE     \"Ready\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_INDICATOR_EXT        \"EXT\"\n    ID_INDICATOR_CAPS       \"CAP\"\n    ID_INDICATOR_NUM        \"NUM\"\n    ID_INDICATOR_SCRL       \"SCRL\"\n    ID_INDICATOR_OVR        \"OVR\"\n    ID_INDICATOR_REC        \"REC\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_FILE_NEW             \"Create a new document\\nNew\"\n    ID_FILE_OPEN            \"Open an existing map\\nOpen\"\n    ID_FILE_CLOSE           \"Close the active document\\nClose\"\n    ID_FILE_SAVE            \"Save the active map\\nSave\"\n    ID_FILE_SAVE_AS         \"Save the active document with a new name\\nSave As\"\n    ID_FILE_PAGE_SETUP      \"Change the printing options\\nPage Setup\"\n    ID_FILE_PRINT_SETUP     \"Change the printer and printing options\\nPrint Setup\"\n    ID_FILE_PRINT           \"Print the active document\\nPrint\"\n    ID_FILE_PRINT_PREVIEW   \"Display full pages\\nPrint Preview\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_APP_ABOUT            \"Display program information, version number and copyright\\nAbout\"\n    ID_APP_EXIT             \"Quit the application; prompts to save documents\\nExit\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_FILE_MRU_FILE1       \"Open this document\"\n    ID_FILE_MRU_FILE2       \"Open this document\"\n    ID_FILE_MRU_FILE3       \"Open this document\"\n    ID_FILE_MRU_FILE4       \"Open this document\"\n    ID_FILE_MRU_FILE5       \"Open this document\"\n    ID_FILE_MRU_FILE6       \"Open this document\"\n    ID_FILE_MRU_FILE7       \"Open this document\"\n    ID_FILE_MRU_FILE8       \"Open this document\"\n    ID_FILE_MRU_FILE9       \"Open this document\"\n    ID_FILE_MRU_FILE10      \"Open this document\"\n    ID_FILE_MRU_FILE11      \"Open this document\"\n    ID_FILE_MRU_FILE12      \"Open this document\"\n    ID_FILE_MRU_FILE13      \"Open this document\"\n    ID_FILE_MRU_FILE14      \"Open this document\"\n    ID_FILE_MRU_FILE15      \"Open this document\"\n    ID_FILE_MRU_FILE16      \"Open this document\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_NEXT_PANE            \"Switch to the next window pane\\nNext Pane\"\n    ID_PREV_PANE            \"Switch back to the previous window pane\\nPrevious Pane\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_WINDOW_NEW           \"Open another window for the active document\\nNew Window\"\n    ID_WINDOW_ARRANGE       \"Arrange icons at the bottom of the window\\nArrange Icons\"\n    ID_WINDOW_CASCADE       \"Arrange windows so they overlap\\nCascade Windows\"\n    ID_WINDOW_TILE_HORZ     \"Arrange windows as non-overlapping tiles\\nTile Windows\"\n    ID_WINDOW_TILE_VERT     \"Arrange windows as non-overlapping tiles\\nTile Windows\"\n    ID_WINDOW_SPLIT         \"Split the active window into panes\\nSplit\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_EDIT_CLEAR           \"Erase the selection\\nErase\"\n    ID_EDIT_CLEAR_ALL       \"Erase everything\\nErase All\"\n    ID_EDIT_COPY            \"Copy the selection and put it on the Clipboard\\nCopy\"\n    ID_EDIT_CUT             \"Cut the selection and put it on the Clipboard\\nCut\"\n    ID_EDIT_FIND            \"Find the specified text\\nFind\"\n    ID_EDIT_PASTE           \"Insert Clipboard contents\\nPaste\"\n    ID_EDIT_REPEAT          \"Repeat the last action\\nRepeat\"\n    ID_EDIT_REPLACE         \"Replace specific text with different text\\nReplace\"\n    ID_EDIT_SELECT_ALL      \"Select the entire document\\nSelect All\"\n    ID_EDIT_UNDO            \"Undo the last action\\nUndo\"\n    ID_EDIT_REDO            \"Redo the previously undone action\\nRedo\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_VIEW_TOOLBAR         \"Show or hide the toolbar\\nToggle ToolBar\"\n    ID_VIEW_STATUS_BAR      \"Show or hide the status bar\\nToggle StatusBar\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    AFX_IDS_SCSIZE          \"Change the window size\"\n    AFX_IDS_SCMOVE          \"Change the window position\"\n    AFX_IDS_SCMINIMIZE      \"Reduce the window to an icon\"\n    AFX_IDS_SCMAXIMIZE      \"Enlarge the window to full size\"\n    AFX_IDS_SCNEXTWINDOW    \"Switch to the next document window\"\n    AFX_IDS_SCPREVWINDOW    \"Switch to the previous document window\"\n    AFX_IDS_SCCLOSE         \"Close the active window and prompts to save the documents\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    AFX_IDS_SCRESTORE       \"Restore the window to normal size\"\n    AFX_IDS_SCTASKLIST      \"Activate Task List\"\n    AFX_IDS_MDICHILD        \"Activate this window\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    AFX_IDS_PREVIEW_CLOSE   \"Close print preview mode\\nCancel Preview\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_VIEW_XY              \"View original layout (Top)\"\n    ID_VIEW_SIDE            \"Side view\"\n    ID_VIEW_FRONT           \"Front view\"\n    ID_VIEW_CAMERATOGGLE    \"Toggle full time camera preview\\nCamera preview\"\n    ID_TEXTURES_POPUP       \"Texture view mode\\nTexture view mode\"\n    ID_POPUP_SELECTION      \"Selection\\nSelection\"\n    ID_VIEW_CHANGE          \"Change views\\nChange views\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_VIEW_ENTITY          \"Toggle entity inspector\\nEntity inspector\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_BRUSH_FLIPX          \"Flip selected brushes along x-axis\\nx-axis Flip\"\n    ID_BRUSH_FLIPY          \"Flip selected brushes along y-axis\\ny-axis Flip\"\n    ID_BRUSH_FLIPZ          \"Flip selected brushes along z-axis\\nz-axis Flip\"\n    ID_BRUSH_ROTATEX        \"Rotate selected brushes along x-axis\\nx-axis Rotate\"\n    ID_BRUSH_ROTATEY        \"Rotate selected brushes along y-axis\\ny-axis Rotate\"\n    ID_BRUSH_ROTATEZ        \"Rotate selected brushes along z-axis\\nz-axis Rotate\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_SELECTION_SELECTCOMPLETETALL \"Complete Tall\\nComplete Tall\"\n    ID_SELECTION_CSGSUBTRACT \"CSG Subtract\\nCSG Subtract\"\n    ID_SELECTION_SELECTTOUCHING \"Select Touching\\nSelect Touching\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_SELECTION_MAKEHOLLOW \"Hollow Selection\\nHollow\"\n    ID_SELECTION_SELECTPARTIALTALL \"Select Partial Tall\\nSelect Partial Tall\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_VIEW_CAMERAUPDATE    \"Update Camera\\nUpdate Camera\"\n    ID_VIEW_CLIPPER         \"Set clipper mode\\nClipper\"\n    ID_PREFS                \"Preferences\\nPreferences\"\n    ID_EDIT_MAPINFO         \"Entity Information\\nEntity list\"\n    ID_BRUSH_SCRIPTS        \"Define and run BrushScripts\\nBrushScripts\"\n    ID_HELP_COMMANDLIST     \"Provides a list of the currently bound commands\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_SELECT_MOUSEROTATE   \"Free rotation\\nFree Rotation\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_TEXTURE_REPLACESELECTED \n                            \"Find and replace texture names in selected brushes/faces\"\n    ID_TEXTURE_REPLACEALL   \"Find and replace texture names in all brushes/faces\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_SELECT_MOUSESCALE    \"Free Scaling\\nFree Scaling\"\n    ID_SCALELOCKX           \"Lock X\\nLock X\"\n    ID_SCALELOCKY           \"Lock Y\\nLock Y\"\n    ID_SCALELOCKZ           \"Lock Z\\nLock Z\"\n    ID_VIEW_CUBICCLIPPING   \"Cubic clip the camera view\\nCubic clip the camera view\"\n    ID_FILE_PROJECTSETTINGS \"View and edit project attributes\"\n    ID_VIEW_CUBEOUT         \"Zoom cubic clip out\"\n    ID_VIEW_CUBEIN          \"Zoom cubic clip in\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_FILE_SAVEREGION      \"Save defined region\"\n    ID_FILE_LOADREGION      \"Load saved region\"\n    ID_TOOLBAR_MAIN         \"Standard toolbar\"\n    ID_TOOLBAR_TEXTURE      \"Texture control toolbar\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_TEXTURES_LOAD        \"Load from a specific directory\"\n    ID_CURVE_CYLINDER       \"Create a cylinder\"\n    ID_FILE_IMPORTMAP       \"Load map, leaving current map intact\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_SELECTION_SELECTINSIDE \"Select Inside\\nSelect Inside\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_FILE_EXPORTMAP       \"Save selection into map file\"\n    ID_EDIT_LOADPREFAB      \"Load .map from prefab path\"\n    ID_VIEW_SHOWCURVES      \"Show Curved brushes\"\n    ID_TEXTURES_LOADLIST    \"Loads from a list. (Good in case there are too many for the menu)\"\n    ID_DONTSELECTCURVE      \"Don't select curved brushes\\nDon't select curved brushes\"\n    ID_CONVERTCURVES        \"Turns selected brush into a new test curve\"\n    ID_PATCH_SHOWBOUNDINGBOX \n                            \"Show patch bounding box\\nShow patch bounding box\"\n    ID_CURVE_SIMPLEPATCHMESH \"Builds a flat patch mesh, you specify the size\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_PATCH_WIREFRAME      \"Show patches as wireframes\\nShow patches as wireframes\"\n    ID_PATCH_WELD           \"Welds equal patch points during moves\\nWelds equal patch points during moves\"\n    ID_CURVE_PATCHTUBE      \"Create a cylinder\"\n    ID_CURVE_PATCHENDCAP    \"Create an endcap\"\n    ID_CURVE_PATCHBEVEL     \"Create a bevel\"\n    ID_PATCH_DRILLDOWN      \"Selects drill down rows and columns\\nSelects drill down rows and columns\"\n    ID_CURVE_LOADPATCHFILE  \"Load corresponding .patch file\\nLoad corresponding .patch file\"\n    ID_CURVE_INSERTROW      \"Inserts a row in the selected patch(s)\\nInserts a row in the selected patch(s)\"\n    ID_CURVE_INSERTCOLUMN   \"Inserts a column in the selected patch(s)\\nInserts a column in the selected patch(s)\"\n    ID_CURVE_DELETEROW      \"Deletes a row in the current patch(s)\\nDeletes a row in the current patch(s)\"\n    ID_CURVE_DELETECOLUMN   \"Deletes a column in the current Patch(s)\\nDeletes a column in the current Patch(s)\"\n    ID_PATCH_INSDEL         \"Redisperse patch points\\nRedisperse patch points\"\n    ID_CURVE_INSERT_ADDCOLUMN \n                            \"Add a column to the end of the patch\\nAdd a column to the end of the patch\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_CURVE_INSERT_INSERTCOLUMN \n                            \"Insert a column at the beginning of the patch\\nInsert a column at the beginning of the patch\"\n    ID_CURVE_INSERT_ADDROW  \"Add a row at the end of the patch\\nAdd a row at the end of the patch\"\n    ID_CURVE_INSERT_INSERTROW \n                            \"Insert a row at the beginning of the patch\\nInsert a row at the beginning of the patch\"\n    ID_CURVE_DELETE_FIRSTCOLUMN \n                            \"Delete the first (2) columns\\nDelete the first (2) columns\"\n    ID_CURVE_DELETE_LASTCOLUMN \n                            \"Delete the last (2) columns\\nDelete the last (2) columns\"\n    ID_CURVE_DELETE_FIRSTROW \n                            \"Delete the first (2) rows\\nDelete the first (2) rows\"\n    ID_CURVE_DELETE_LASTROW \"Delete the last (2) rows\\nDelete the last (2) rows\"\n    ID_CURVE_NEGATIVE       \"Toggle negative flag\\nToggle negative flag\"\n    ID_PATCH_BEND           \"Patch Bend mode\\nPatch Bend mode\"\n    ID_CURVE_PATCHDENSETUBE \"Create a dense tube\"\n    ID_CURVE_PATCHVERYDENSETUBE \"Create a very dense cylinder\"\n    ID_CURVE_CAP            \"Put caps on the current patch\\nPut caps on the current patch\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_CURVE_REDISPERSE_ROWS \n                            \"Re-disperse rows across the dimensions of the patch\"\n    ID_CURVE_REDISPERSE_COLS \n                            \"Re-disperse columns across the dimensions of the patch\"\n    ID_CURVE_PATCHSQUARE    \"Create a very square cylinder\"\n    ID_TEXTURES_FLUSH       \"Flush texture palette\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_TEXTURES_RELOADSHADERS \n                            \"Reload Shaders and apply visual changes to current map\"\n    ID_SHOW_ENTITIES        \"Show Entities as\\nShow Entities as\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    IDR_SHADERTYPE          \"\\nUntitled\\nSHADER Document\\nShader Files (*.shader)\\n.shader\\nShaderFileType\\nSHADER File Type\\nSHADER\\nShader Files\\n\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_VIEW_OPENGLLIGHTING  \"Toggle OpenGL Lighting\"\nEND\n\nSTRINGTABLE DISCARDABLE \nBEGIN\n    ID_SELECTION_CSGMERGE   \"CSG Merge\\nCSG Merge\"\nEND\n\n#endif    // English (U.S.) resources\n/////////////////////////////////////////////////////////////////////////////\n\n\n\n#ifndef APSTUDIO_INVOKED\n/////////////////////////////////////////////////////////////////////////////\n//\n// Generated from the TEXTINCLUDE 3 resource.\n//\n#define _AFX_NO_SPLITTER_RESOURCES\n#define _AFX_NO_OLE_RESOURCES\n#define _AFX_NO_TRACKER_RESOURCES\n#define _AFX_NO_PROPERTY_RESOURCES\n\n#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\n#ifdef _WIN32\nLANGUAGE 9, 1\n#pragma code_page(1252)\n#endif\n#include \"res\\Radiant.rc2\"  // non-Microsoft Visual C++ edited resources\n#include \"afxres.rc\"         // Standard components\n#include \"afxprint.rc\"       // printing/print preview resources\n#endif\n/////////////////////////////////////////////////////////////////////////////\n#endif    // not APSTUDIO_INVOKED\n\n"
  },
  {
    "path": "q3radiant/Radiant.sln",
    "content": "Microsoft Visual Studio Solution File, Format Version 8.00\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"Radiant\", \"Radiant.vcproj\", \"{D92DD0A3-9D6B-4183-992C-0FF42BC59A62}\"\n\tProjectSection(ProjectDependencies) = postProject\n\t\t{EFB1E65A-E86F-4E0D-845A-E5C7A3DF016F} = {EFB1E65A-E86F-4E0D-845A-E5C7A3DF016F}\n\t\t{63F2947A-5BD9-48C2-8BEA-7AB341F6B48F} = {63F2947A-5BD9-48C2-8BEA-7AB341F6B48F}\n\t\t{B80E7E95-566D-4CB0-8151-0567CB206D5A} = {B80E7E95-566D-4CB0-8151-0567CB206D5A}\n\t\t{706CF09C-D767-4ECD-8CA6-EE7CA6CDA3AE} = {706CF09C-D767-4ECD-8CA6-EE7CA6CDA3AE}\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"Splines\", \"splines\\Splines.vcproj\", \"{63F2947A-5BD9-48C2-8BEA-7AB341F6B48F}\"\n\tProjectSection(ProjectDependencies) = postProject\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"cmdlib\", \"..\\libs\\cmdlib\\cmdlib.vcproj\", \"{EFB1E65A-E86F-4E0D-845A-E5C7A3DF016F}\"\n\tProjectSection(ProjectDependencies) = postProject\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"jpeg6\", \"..\\libs\\jpeg6\\jpeg6.vcproj\", \"{B80E7E95-566D-4CB0-8151-0567CB206D5A}\"\n\tProjectSection(ProjectDependencies) = postProject\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"pak\", \"..\\libs\\pak\\pak.vcproj\", \"{706CF09C-D767-4ECD-8CA6-EE7CA6CDA3AE}\"\n\tProjectSection(ProjectDependencies) = postProject\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"q3map\", \"..\\q3map\\q3map.vcproj\", \"{4D768C46-A503-48DE-BD4C-14D2B50C2739}\"\n\tProjectSection(ProjectDependencies) = postProject\n\tEndProjectSection\nEndProject\nGlobal\n\tGlobalSection(SourceCodeControl) = preSolution\n\t\tSccNumberOfProjects = 6\n\t\tSccProjectUniqueName0 = Radiant.vcproj\n\t\tSccProjectName0 = \\u0022$/source/q3radiant\\u0022,\\u0020FEFAAAAA\n\t\tSccLocalPath0 = .\n\t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM\n\t\tSccProjectUniqueName1 = splines\\\\Splines.vcproj\n\t\tSccProjectName1 = \\u0022$/source/q3radiant/splines\\u0022,\\u0020XINAAAAA\n\t\tSccLocalPath1 = splines\n\t\tSccProvider1 = MSSCCI:Perforce\\u0020SCM\n\t\tSccProjectUniqueName2 = ..\\\\libs\\\\cmdlib\\\\cmdlib.vcproj\n\t\tSccProjectName2 = \\u0022$/source/q3radiant\\u0022,\\u0020FEFAAAAA\n\t\tSccLocalPath2 = .\n\t\tSccProvider2 = MSSCCI:Perforce\\u0020SCM\n\t\tSccProjectFilePathRelativizedFromConnection2 = ..\\\\libs\\\\cmdlib\\\\\n\t\tSccProjectUniqueName3 = ..\\\\libs\\\\jpeg6\\\\jpeg6.vcproj\n\t\tSccProjectName3 = \\u0022$/source/q3radiant\\u0022,\\u0020FEFAAAAA\n\t\tSccLocalPath3 = .\n\t\tSccProvider3 = MSSCCI:Perforce\\u0020SCM\n\t\tSccProjectFilePathRelativizedFromConnection3 = ..\\\\libs\\\\jpeg6\\\\\n\t\tSccProjectUniqueName4 = ..\\\\libs\\\\pak\\\\pak.vcproj\n\t\tSccProjectName4 = \\u0022$/source/q3radiant\\u0022,\\u0020FEFAAAAA\n\t\tSccLocalPath4 = .\n\t\tSccProvider4 = MSSCCI:Perforce\\u0020SCM\n\t\tSccProjectFilePathRelativizedFromConnection4 = ..\\\\libs\\\\pak\\\\\n\t\tSccProjectUniqueName5 = ..\\\\q3map\\\\q3map.vcproj\n\t\tSccProjectName5 = \\u0022$/source/q3map\\u0022,\\u0020PADAAAAA\n\t\tSccLocalPath5 = ..\\\\q3map\n\t\tSccProvider5 = MSSCCI:Perforce\\u0020SCM\n\tEndGlobalSection\n\tGlobalSection(SolutionConfiguration) = preSolution\n\t\tDebug = Debug\n\t\tRelease = Release\n\tEndGlobalSection\n\tGlobalSection(ProjectConfiguration) = postSolution\n\t\t{D92DD0A3-9D6B-4183-992C-0FF42BC59A62}.Debug.ActiveCfg = Debug|Win32\n\t\t{D92DD0A3-9D6B-4183-992C-0FF42BC59A62}.Debug.Build.0 = Debug|Win32\n\t\t{D92DD0A3-9D6B-4183-992C-0FF42BC59A62}.Release.ActiveCfg = Release|Win32\n\t\t{D92DD0A3-9D6B-4183-992C-0FF42BC59A62}.Release.Build.0 = Release|Win32\n\t\t{63F2947A-5BD9-48C2-8BEA-7AB341F6B48F}.Debug.ActiveCfg = Debug|Win32\n\t\t{63F2947A-5BD9-48C2-8BEA-7AB341F6B48F}.Debug.Build.0 = Debug|Win32\n\t\t{63F2947A-5BD9-48C2-8BEA-7AB341F6B48F}.Release.ActiveCfg = Release|Win32\n\t\t{63F2947A-5BD9-48C2-8BEA-7AB341F6B48F}.Release.Build.0 = Release|Win32\n\t\t{EFB1E65A-E86F-4E0D-845A-E5C7A3DF016F}.Debug.ActiveCfg = Debug|Win32\n\t\t{EFB1E65A-E86F-4E0D-845A-E5C7A3DF016F}.Debug.Build.0 = Debug|Win32\n\t\t{EFB1E65A-E86F-4E0D-845A-E5C7A3DF016F}.Release.ActiveCfg = Release|Win32\n\t\t{EFB1E65A-E86F-4E0D-845A-E5C7A3DF016F}.Release.Build.0 = Release|Win32\n\t\t{B80E7E95-566D-4CB0-8151-0567CB206D5A}.Debug.ActiveCfg = Debug|Win32\n\t\t{B80E7E95-566D-4CB0-8151-0567CB206D5A}.Debug.Build.0 = Debug|Win32\n\t\t{B80E7E95-566D-4CB0-8151-0567CB206D5A}.Release.ActiveCfg = Release|Win32\n\t\t{B80E7E95-566D-4CB0-8151-0567CB206D5A}.Release.Build.0 = Release|Win32\n\t\t{706CF09C-D767-4ECD-8CA6-EE7CA6CDA3AE}.Debug.ActiveCfg = Debug|Win32\n\t\t{706CF09C-D767-4ECD-8CA6-EE7CA6CDA3AE}.Debug.Build.0 = Debug|Win32\n\t\t{706CF09C-D767-4ECD-8CA6-EE7CA6CDA3AE}.Release.ActiveCfg = Release|Win32\n\t\t{706CF09C-D767-4ECD-8CA6-EE7CA6CDA3AE}.Release.Build.0 = Release|Win32\n\t\t{4D768C46-A503-48DE-BD4C-14D2B50C2739}.Debug.ActiveCfg = Debug|Win32\n\t\t{4D768C46-A503-48DE-BD4C-14D2B50C2739}.Debug.Build.0 = Debug|Win32\n\t\t{4D768C46-A503-48DE-BD4C-14D2B50C2739}.Release.ActiveCfg = Release|Win32\n\t\t{4D768C46-A503-48DE-BD4C-14D2B50C2739}.Release.Build.0 = Release|Win32\n\tEndGlobalSection\n\tGlobalSection(ExtensibilityGlobals) = postSolution\n\tEndGlobalSection\n\tGlobalSection(ExtensibilityAddIns) = postSolution\n\tEndGlobalSection\nEndGlobal\n"
  },
  {
    "path": "q3radiant/Radiant.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<VisualStudioProject\n\tProjectType=\"Visual C++\"\n\tVersion=\"7.10\"\n\tName=\"Radiant\"\n\tSccProjectName=\"&quot;$/source/q3radiant&quot;, FEFAAAAA\"\n\tSccLocalPath=\".\"\n\tKeyword=\"MFCProj\">\n\t<Platforms>\n\t\t<Platform\n\t\t\tName=\"Win32\"/>\n\t</Platforms>\n\t<Configurations>\n\t\t<Configuration\n\t\t\tName=\"Release|Win32\"\n\t\t\tOutputDirectory=\".\\Release\"\n\t\t\tIntermediateDirectory=\".\\Release\"\n\t\t\tConfigurationType=\"1\"\n\t\t\tUseOfMFC=\"1\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tAdditionalIncludeDirectories=\"../libs,../common,c:\\quake3\\common,c:\\quake3\\libs\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;QUAKE3;Q3RADIANT\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"0\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tRuntimeTypeInfo=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"3\"\n\t\t\t\tPrecompiledHeaderThrough=\"stdafx.h\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release/Radiant.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release/\"\n\t\t\t\tObjectFile=\".\\Release/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"2\"\n\t\t\t\tCompileAs=\"0\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"winmm.lib ..\\libs\\jpeg6.lib ..\\libs\\pak.lib ..\\libs\\cmdlib.lib\"\n\t\t\t\tOutputFile=\"Release\\q3radiant.exe\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tIgnoreDefaultLibraryNames=\"libc.lib msvcrtd.lib\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\Release/q3radiant.pdb\"\n\t\t\t\tSubSystem=\"2\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Release/Radiant.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"ReleaseTTimo|Win32\"\n\t\t\tOutputDirectory=\".\\Radiant___Win32_ReleaseTTimo\"\n\t\t\tIntermediateDirectory=\".\\Radiant___Win32_ReleaseTTimo\"\n\t\t\tConfigurationType=\"1\"\n\t\t\tUseOfMFC=\"1\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tAdditionalIncludeDirectories=\"..\\Libs,../libs,../common,c:\\quake3\\common,c:\\quake3\\libs\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;QUAKE3;Q3RADIANT\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"0\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tRuntimeTypeInfo=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"3\"\n\t\t\t\tPrecompiledHeaderThrough=\"stdafx.h\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Radiant___Win32_ReleaseTTimo/Radiant.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Radiant___Win32_ReleaseTTimo/\"\n\t\t\t\tObjectFile=\".\\Radiant___Win32_ReleaseTTimo/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Radiant___Win32_ReleaseTTimo/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"2\"\n\t\t\t\tCompileAs=\"0\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"winmm.lib jpeg6.lib pak.lib cmdlib.lib\"\n\t\t\t\tOutputFile=\"Radiant___Win32_ReleaseTTimo\\q3radiant.exe\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tAdditionalLibraryDirectories=\"..\\Libs\"\n\t\t\t\tIgnoreDefaultLibraryNames=\"libc.lib msvcrtd.lib\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\Radiant___Win32_ReleaseTTimo/q3radiant.pdb\"\n\t\t\t\tSubSystem=\"2\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Radiant___Win32_ReleaseTTimo/Radiant.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"\n\t\t\t\tDescription=\"Copy to dir...\"\n\t\t\t\tCommandLine=\"copy Radiant___Win32_ReleaseTTimo\\q3radiant.exe E:\\home\\quake3\\q3radiant\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Debug|Win32\"\n\t\t\tOutputDirectory=\".\\Debug\"\n\t\t\tIntermediateDirectory=\".\\Debug\"\n\t\t\tConfigurationType=\"1\"\n\t\t\tUseOfMFC=\"1\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tAdditionalIncludeDirectories=\"../libs,../common,c:\\quake3\\common,c:\\quake3\\libs\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;QUAKE3;Q3RADIANT\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tRuntimeTypeInfo=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"3\"\n\t\t\t\tPrecompiledHeaderThrough=\"stdafx.h\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Debug/Radiant.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug/\"\n\t\t\t\tObjectFile=\".\\Debug/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Debug/\"\n\t\t\t\tBrowseInformation=\"1\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"\n\t\t\t\tCompileAs=\"0\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"winmm.lib ..\\libs\\jpeg6d.lib ..\\libs\\pakd.lib ..\\libs\\cmdlibd.lib\"\n\t\t\t\tOutputFile=\"Debug\\q3radiant.exe\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tIgnoreDefaultLibraryNames=\"libc.lib msvcrtd.lib\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\Debug/q3radiant.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\".\\Debug/q3radiant.map\"\n\t\t\t\tSubSystem=\"2\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Debug/Radiant.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"DebugTTimo|Win32\"\n\t\t\tOutputDirectory=\".\\Radiant___Win32_DebugTTimo\"\n\t\t\tIntermediateDirectory=\".\\Radiant___Win32_DebugTTimo\"\n\t\t\tConfigurationType=\"1\"\n\t\t\tUseOfMFC=\"1\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tAdditionalIncludeDirectories=\"..\\Libs,../libs,../common,c:\\quake3\\common,c:\\quake3\\libs\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;QUAKE3;Q3RADIANT\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tRuntimeTypeInfo=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"3\"\n\t\t\t\tPrecompiledHeaderThrough=\"stdafx.h\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Radiant___Win32_DebugTTimo/Radiant.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Radiant___Win32_DebugTTimo/\"\n\t\t\t\tObjectFile=\".\\Radiant___Win32_DebugTTimo/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Radiant___Win32_DebugTTimo/\"\n\t\t\t\tBrowseInformation=\"1\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"\n\t\t\t\tCompileAs=\"0\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLinkerTool\"\n\t\t\t\tAdditionalDependencies=\"winmm.lib jpeg6d.lib pakd.lib cmdlibd.lib\"\n\t\t\t\tOutputFile=\"Radiant___Win32_DebugTTimo\\q3radiant.exe\"\n\t\t\t\tLinkIncremental=\"1\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tAdditionalLibraryDirectories=\"..\\Libs\"\n\t\t\t\tIgnoreDefaultLibraryNames=\"libc.lib msvcrtd.lib\"\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\n\t\t\t\tProgramDatabaseFile=\".\\Radiant___Win32_DebugTTimo/q3radiant.pdb\"\n\t\t\t\tGenerateMapFile=\"TRUE\"\n\t\t\t\tMapFileName=\".\\Radiant___Win32_DebugTTimo/q3radiant.map\"\n\t\t\t\tSubSystem=\"2\"\n\t\t\t\tTargetMachine=\"1\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tMkTypLibCompatible=\"TRUE\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tTargetEnvironment=\"1\"\n\t\t\t\tTypeLibraryName=\".\\Radiant___Win32_DebugTTimo/Radiant.tlb\"\n\t\t\t\tHeaderFileName=\"\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"\n\t\t\t\tDescription=\"Copy to dir...\"\n\t\t\t\tCommandLine=\"copy Radiant___Win32_DebugTTimo\\q3radiant.exe E:\\home\\quake3\\q3radiant\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t</Configurations>\n\t<References>\n\t</References>\n\t<Files>\n\t\t<Filter\n\t\t\tName=\"Source Files\"\n\t\t\tFilter=\"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"BrushScript.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"BSInput.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cameratargetdlg.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"CamWnd.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"CapDialog.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cbrushstub.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\"\n\t\t\t\t\tExcludedFromBuild=\"TRUE\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"CommandsDlg.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"DialogInfo.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"DialogTextures.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"DialogThick.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"dlgcamera.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"DlgEvent.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"EditWnd.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"EntityListDlg.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"FindTextureDlg.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"GroupDlg.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"LstToolBar.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"MainFrm.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"MapInfo.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"NameDlg.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"NewProjDlg.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"PatchDensityDlg.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"PatchDialog.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"PlugIn.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"PlugInManager.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"PMESH.CPP\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"PrefsDlg.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qgl_win.c\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"radbsp.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"RADEditWnd.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"Radiant.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"Radiant.rc\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"RotateDlg.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ScaleDialog.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ScriptDlg.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ShaderInfo.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"StdAfx.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tUsePrecompiledHeader=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tUsePrecompiledHeader=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tUsePrecompiledHeader=\"1\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tUsePrecompiledHeader=\"1\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"SurfaceDlg.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"TexEdit.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"TextureBar.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"TextureLayout.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"TexWnd.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"Undo.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"WaveOpen.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"Winding.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"XYWnd.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ZWnd.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<Filter\n\t\t\t\tName=\"QE4 Files\"\n\t\t\t\tFilter=\"\">\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"Bmp.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"brush.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"csg.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"drag.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"eclass.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"entity.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"lbmlib.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"map.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"mathlib.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"mru.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"parse.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"points.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"qe3.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"select.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"terrain.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"terrain.h\">\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"vertsel.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"win_dlg.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"win_ent.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"win_main.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"win_qe3.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"z.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t</Filter>\n\t\t\t<Filter\n\t\t\t\tName=\"Brush Primitives\"\n\t\t\t\tFilter=\"\">\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"brush_primit.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t</Filter>\n\t\t\t<Filter\n\t\t\t\tName=\"interfaces\"\n\t\t\t\tFilter=\"\">\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"GLInterface.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"IEpairs.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"IShaders.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"Messaging.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"PluginEntities.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"SelectedFace.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"SurfacePlugin.cpp\">\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"ReleaseTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t\t<FileConfiguration\n\t\t\t\t\t\tName=\"DebugTTimo|Win32\">\n\t\t\t\t\t\t<Tool\n\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\t\tAdditionalIncludeDirectories=\"\"\n\t\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\t\tBrowseInformation=\"1\"/>\n\t\t\t\t\t</FileConfiguration>\n\t\t\t\t</File>\n\t\t\t</Filter>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Header Files\"\n\t\t\tFilter=\"h;hpp;hxx;hm;inl\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"BSInput.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"cameratargetdlg.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"CamWnd.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"CapDialog.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ChildFrm.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"CommandsDlg.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"DialogInfo.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"DialogTextures.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"DialogThick.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"dlgcamera.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"DlgEvent.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"EditWnd.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"EntityListDlg.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"FindTextureDlg.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"GroupBar.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"GroupDlg.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"LstToolBar.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"MainFrm.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"MapInfo.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"NameDlg.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"NewProjDlg.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"PatchDensityDlg.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"PatchDialog.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"PlugIn.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"PlugInManager.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"PrefsDlg.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qe3.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"QEDEFS.H\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"qerplugin.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"QERTYPES.H\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"QFILES.H\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"RADEditWnd.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"Radiant.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"RadiantDoc.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"RadiantView.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"Resource.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"RotateDlg.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ScaleDialog.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ScriptDlg.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"SELECT.H\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ShaderInfo.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"StdAfx.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"SurfaceDlg.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"TexEdit.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"TextureBar.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"TextureLayout.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"TexWnd.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"WaveOpen.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"XYWnd.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"ZWnd.h\">\n\t\t\t</File>\n\t\t\t<Filter\n\t\t\t\tName=\"interface headers\"\n\t\t\t\tFilter=\"\">\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"IEpairs.h\">\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"igl.h\">\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"IMessaging.h\">\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"IPluginEntities.h\">\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"ISelectedFace.h\">\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"IShaders.h\">\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"isurfaceplugin.h\">\n\t\t\t\t</File>\n\t\t\t</Filter>\n\t\t\t<Filter\n\t\t\t\tName=\"internal interface headers\"\n\t\t\t\tFilter=\"\">\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"EpairsWrapper.h\">\n\t\t\t\t</File>\n\t\t\t\t<File\n\t\t\t\t\tRelativePath=\"Messaging.h\">\n\t\t\t\t</File>\n\t\t\t</Filter>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Resource Files\"\n\t\t\tFilter=\"ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"res\\bevel.bmp\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"res\\bitmap2.bmp\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"res\\bmp00001.bmp\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"res\\bmp00002.bmp\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"RES\\bmp00003.bmp\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"res\\endcap.bmp\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"res\\ibevel.bmp\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"RES\\icon2.ico\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"res\\iendcap.bmp\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"res\\logo_sm3dfx.bmp\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"res\\q.bmp\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"q.bmp\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"res\\Radiant.ico\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"res\\Radiant.rc2\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"res\\RadiantDoc.ico\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"RES\\shaderbar.bmp\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"RES\\shaderdoc.ico\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"RES\\shaderframe.ico\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"res\\Toolbar.bmp\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"toolbar1.bmp\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"res\\toolbar1.bmp\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"res\\toolbar2.bmp\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"res\\viewdefa.bmp\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"res\\viewoppo.bmp\">\n\t\t\t</File>\n\t\t</Filter>\n\t</Files>\n\t<Globals>\n\t</Globals>\n</VisualStudioProject>\n"
  },
  {
    "path": "q3radiant/RadiantDoc.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// RadiantDoc.cpp : implementation of the CRadiantDoc class\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n\n#include \"RadiantDoc.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CRadiantDoc\n\nIMPLEMENT_DYNCREATE(CRadiantDoc, CDocument)\n\nBEGIN_MESSAGE_MAP(CRadiantDoc, CDocument)\n\t//{{AFX_MSG_MAP(CRadiantDoc)\n\t\t// NOTE - the ClassWizard will add and remove mapping macros here.\n\t\t//    DO NOT EDIT what you see in these blocks of generated code!\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CRadiantDoc construction/destruction\n\nCRadiantDoc::CRadiantDoc()\n{\n\t// TODO: add one-time construction code here\n\n}\n\nCRadiantDoc::~CRadiantDoc()\n{\n}\n\nBOOL CRadiantDoc::OnNewDocument()\n{\n\tif (!CDocument::OnNewDocument())\n\t\treturn FALSE;\n\n\t// TODO: add reinitialization code here\n\t// (SDI documents will reuse this document)\n\n\treturn TRUE;\n}\n\n\n\n/////////////////////////////////////////////////////////////////////////////\n// CRadiantDoc serialization\n\nvoid CRadiantDoc::Serialize(CArchive& ar)\n{\n\tif (ar.IsStoring())\n\t{\n\t\t// TODO: add storing code here\n\t}\n\telse\n\t{\n\t\t// TODO: add loading code here\n\t}\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// CRadiantDoc diagnostics\n\n#ifdef _DEBUG\nvoid CRadiantDoc::AssertValid() const\n{\n\tCDocument::AssertValid();\n}\n\nvoid CRadiantDoc::Dump(CDumpContext& dc) const\n{\n\tCDocument::Dump(dc);\n}\n#endif //_DEBUG\n\n/////////////////////////////////////////////////////////////////////////////\n// CRadiantDoc commands\n"
  },
  {
    "path": "q3radiant/RadiantDoc.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// RadiantDoc.h : interface of the CRadiantDoc class\n//\n/////////////////////////////////////////////////////////////////////////////\n\n#if !defined(AFX_RADIANTDOC_H__330BBF0E_731C_11D1_B539_00AA00A410FC__INCLUDED_)\n#define AFX_RADIANTDOC_H__330BBF0E_731C_11D1_B539_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n\n\nclass CRadiantDoc : public CDocument\n{\nprotected: // create from serialization only\n\tCRadiantDoc();\n\tDECLARE_DYNCREATE(CRadiantDoc)\n\n// Attributes\npublic:\n\n// Operations\npublic:\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CRadiantDoc)\n\tpublic:\n\tvirtual BOOL OnNewDocument();\n\tvirtual void Serialize(CArchive& ar);\n\t//}}AFX_VIRTUAL\n\n// Implementation\npublic:\n\tvirtual ~CRadiantDoc();\n#ifdef _DEBUG\n\tvirtual void AssertValid() const;\n\tvirtual void Dump(CDumpContext& dc) const;\n#endif\n\nprotected:\n\n// Generated message map functions\nprotected:\n\t//{{AFX_MSG(CRadiantDoc)\n\t\t// NOTE - the ClassWizard will add and remove member functions here.\n\t\t//    DO NOT EDIT what you see in these blocks of generated code !\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n/////////////////////////////////////////////////////////////////////////////\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_RADIANTDOC_H__330BBF0E_731C_11D1_B539_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/RadiantView.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// RadiantView.cpp : implementation of the CRadiantView class\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n\n#include \"RadiantDoc.h\"\n#include \"RadiantView.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CRadiantView\n\nIMPLEMENT_DYNCREATE(CRadiantView, CView)\n\nBEGIN_MESSAGE_MAP(CRadiantView, CView)\n\t//{{AFX_MSG_MAP(CRadiantView)\n\t\t// NOTE - the ClassWizard will add and remove mapping macros here.\n\t\t//    DO NOT EDIT what you see in these blocks of generated code!\n\t//}}AFX_MSG_MAP\n\t// Standard printing commands\n\tON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)\n\tON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)\n\tON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CRadiantView construction/destruction\n\nCRadiantView::CRadiantView()\n{\n\t// TODO: add construction code here\n\n}\n\nCRadiantView::~CRadiantView()\n{\n}\n\nBOOL CRadiantView::PreCreateWindow(CREATESTRUCT& cs)\n{\n\t// TODO: Modify the Window class or styles here by modifying\n\t//  the CREATESTRUCT cs\n\n\treturn CView::PreCreateWindow(cs);\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// CRadiantView drawing\n\nvoid CRadiantView::OnDraw(CDC* pDC)\n{\n\tCRadiantDoc* pDoc = GetDocument();\n\tASSERT_VALID(pDoc);\n\n\t// TODO: add draw code for native data here\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// CRadiantView printing\n\nBOOL CRadiantView::OnPreparePrinting(CPrintInfo* pInfo)\n{\n\t// default preparation\n\treturn DoPreparePrinting(pInfo);\n}\n\nvoid CRadiantView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)\n{\n\t// TODO: add extra initialization before printing\n}\n\nvoid CRadiantView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)\n{\n\t// TODO: add cleanup after printing\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// CRadiantView diagnostics\n\n#ifdef _DEBUG\nvoid CRadiantView::AssertValid() const\n{\n\tCView::AssertValid();\n}\n\nvoid CRadiantView::Dump(CDumpContext& dc) const\n{\n\tCView::Dump(dc);\n}\n\nCRadiantDoc* CRadiantView::GetDocument() // non-debug version is inline\n{\n\tASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CRadiantDoc)));\n\treturn (CRadiantDoc*)m_pDocument;\n}\n#endif //_DEBUG\n\n/////////////////////////////////////////////////////////////////////////////\n// CRadiantView message handlers\n"
  },
  {
    "path": "q3radiant/RadiantView.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// RadiantView.h : interface of the CRadiantView class\n//\n/////////////////////////////////////////////////////////////////////////////\n\n#if !defined(AFX_RADIANTVIEW_H__330BBF10_731C_11D1_B539_00AA00A410FC__INCLUDED_)\n#define AFX_RADIANTVIEW_H__330BBF10_731C_11D1_B539_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n\nclass CRadiantView : public CView\n{\nprotected: // create from serialization only\n\tCRadiantView();\n\tDECLARE_DYNCREATE(CRadiantView)\n\n// Attributes\npublic:\n\tCRadiantDoc* GetDocument();\n\n// Operations\npublic:\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CRadiantView)\n\tpublic:\n\tvirtual void OnDraw(CDC* pDC);  // overridden to draw this view\n\tvirtual BOOL PreCreateWindow(CREATESTRUCT& cs);\n\tprotected:\n\tvirtual BOOL OnPreparePrinting(CPrintInfo* pInfo);\n\tvirtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);\n\tvirtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);\n\t//}}AFX_VIRTUAL\n\n// Implementation\npublic:\n\tvirtual ~CRadiantView();\n#ifdef _DEBUG\n\tvirtual void AssertValid() const;\n\tvirtual void Dump(CDumpContext& dc) const;\n#endif\n\nprotected:\n\n// Generated message map functions\nprotected:\n\t//{{AFX_MSG(CRadiantView)\n\t\t// NOTE - the ClassWizard will add and remove member functions here.\n\t\t//    DO NOT EDIT what you see in these blocks of generated code !\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n#ifndef _DEBUG  // debug version in RadiantView.cpp\ninline CRadiantDoc* CRadiantView::GetDocument()\n   { return (CRadiantDoc*)m_pDocument; }\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_RADIANTVIEW_H__330BBF10_731C_11D1_B539_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/RotateDlg.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// RotateDlg.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"RotateDlg.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CRotateDlg dialog\n\n\nCRotateDlg::CRotateDlg(CWnd* pParent /*=NULL*/)\n\t: CDialog(CRotateDlg::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CRotateDlg)\n\tm_strX = _T(\"\");\n\tm_strY = _T(\"\");\n\tm_strZ = _T(\"\");\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CRotateDlg::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CRotateDlg)\n\tDDX_Control(pDX, IDC_SPIN3, m_wndSpin3);\n\tDDX_Control(pDX, IDC_SPIN2, m_wndSpin2);\n\tDDX_Control(pDX, IDC_SPIN1, m_wndSpin1);\n\tDDX_Text(pDX, IDC_ROTX, m_strX);\n\tDDX_Text(pDX, IDC_ROTY, m_strY);\n\tDDX_Text(pDX, IDC_ROTZ, m_strZ);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CRotateDlg, CDialog)\n\t//{{AFX_MSG_MAP(CRotateDlg)\n\tON_BN_CLICKED(ID_APPLY, OnApply)\n\tON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, OnDeltaposSpin1)\n\tON_NOTIFY(UDN_DELTAPOS, IDC_SPIN2, OnDeltaposSpin2)\n\tON_NOTIFY(UDN_DELTAPOS, IDC_SPIN3, OnDeltaposSpin3)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CRotateDlg message handlers\n\nvoid CRotateDlg::OnOK() \n{\n  OnApply();\n  CDialog::OnOK();\n}\n\nvoid CRotateDlg::OnApply() \n{\n  UpdateData(TRUE);\n\tfloat f = atof(m_strX);\n  if (f != 0.0)\n    Select_RotateAxis(0,f);\n\tf = atof(m_strY);\n  if (f != 0.0)\n    Select_RotateAxis(1,f);\n\tf = atof(m_strZ);\n  if (f != 0.0)\n    Select_RotateAxis(2,f);\n}\n\nBOOL CRotateDlg::OnInitDialog() \n{\n\tCDialog::OnInitDialog();\n\tm_wndSpin1.SetRange(0, 359);\n\tm_wndSpin2.SetRange(0, 359);\n\tm_wndSpin3.SetRange(0, 359);\n\treturn TRUE;  // return TRUE unless you set the focus to a control\n\t              // EXCEPTION: OCX Property Pages should return FALSE\n}\n\nvoid CRotateDlg::OnDeltaposSpin1(NMHDR* pNMHDR, LRESULT* pResult) \n{\n\tNM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;\n\tSelect_RotateAxis(0, pNMUpDown->iDelta);\n\t*pResult = 0;\n}\n\nvoid CRotateDlg::OnDeltaposSpin2(NMHDR* pNMHDR, LRESULT* pResult) \n{\n\tNM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;\n\tSelect_RotateAxis(1, pNMUpDown->iDelta);\n\t*pResult = 0;\n}\n\nvoid CRotateDlg::OnDeltaposSpin3(NMHDR* pNMHDR, LRESULT* pResult) \n{\n\tNM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;\n\tSelect_RotateAxis(2, pNMUpDown->iDelta);\n\t*pResult = 0;\n}\n\nvoid CRotateDlg::ApplyNoPaint()\n{\n\n}\n"
  },
  {
    "path": "q3radiant/RotateDlg.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_ROTATEDLG_H__D4B79152_7A7E_11D1_B541_00AA00A410FC__INCLUDED_)\n#define AFX_ROTATEDLG_H__D4B79152_7A7E_11D1_B541_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// RotateDlg.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CRotateDlg dialog\n\nclass CRotateDlg : public CDialog\n{\n// Construction\npublic:\n\tCRotateDlg(CWnd* pParent = NULL);   // standard constructor\n\n// Dialog Data\n\t//{{AFX_DATA(CRotateDlg)\n\tenum { IDD = IDD_ROTATE };\n\tCSpinButtonCtrl\tm_wndSpin3;\n\tCSpinButtonCtrl\tm_wndSpin2;\n\tCSpinButtonCtrl\tm_wndSpin1;\n\tCString\tm_strX;\n\tCString\tm_strY;\n\tCString\tm_strZ;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CRotateDlg)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\tvoid ApplyNoPaint();\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CRotateDlg)\n\tvirtual void OnOK();\n\tafx_msg void OnApply();\n\tvirtual BOOL OnInitDialog();\n\tafx_msg void OnDeltaposSpin1(NMHDR* pNMHDR, LRESULT* pResult);\n\tafx_msg void OnDeltaposSpin2(NMHDR* pNMHDR, LRESULT* pResult);\n\tafx_msg void OnDeltaposSpin3(NMHDR* pNMHDR, LRESULT* pResult);\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_ROTATEDLG_H__D4B79152_7A7E_11D1_B541_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/SELECT.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// select.c\n#include \"stdafx.h\"\n#include \"qe3.h\"\n\n\n// externs\nCPtrArray g_SelectedFaces;\nCPtrArray g_SelectedFaceBrushes;\nCPtrArray& g_ptrSelectedFaces = g_SelectedFaces;\nCPtrArray& g_ptrSelectedFaceBrushes = g_SelectedFaceBrushes;\n\n\nvoid clearSelection() {\n\tg_qeglobals.d_select_mode = sel_brush;\n\tg_qeglobals.selectObject = NULL;\n}\n\n/*\n===========\nTest_Ray\n===========\n*/\n#define\tDIST_START\t999999\ntrace_t Test_Ray (vec3_t origin, vec3_t dir, int flags)\n{\n\tbrush_t\t*brush;\n\tface_t\t*face;\n\tfloat\tdist;\n\ttrace_t\tt;\n\n\tmemset (&t, 0, sizeof(t));\n\tt.dist = DIST_START;\n\n\tif (flags & SF_CYCLE)\n\t{\n\t\tCPtrArray array;\n\t\tbrush_t *pToSelect = (selected_brushes.next != &selected_brushes) ? selected_brushes.next : NULL;\n\t\tSelect_Deselect();\n\n\t\t// go through active brushes and accumulate all \"hit\" brushes\n\t\tfor (brush = active_brushes.next ; brush != &active_brushes ; brush=brush->next)\n\t\t{\n\t\t\t//if ( (flags & SF_ENTITIES_FIRST) && brush->owner == world_entity)\n\t\t\t//  continue;\n\t\t \n\t\t\tif (FilterBrush (brush))\n\t\t\t\tcontinue;\n\n\t\t\tif (!g_PrefsDlg.m_bSelectCurves && brush->patchBrush)\n\t\t\t\tcontinue;\n\n\t\t\tif( !g_PrefsDlg.m_bSelectTerrain && brush->terrainBrush )\n\t\t\t\tcontinue;\n\n\t\t\t//if (!g_bShowPatchBounds && brush->patchBrush)\n\t\t\t//  continue;\n\n\t\t\tface = Brush_Ray (origin, dir, brush, &dist);\n\n\t\t\tif (face)\n\t\t\t{\n\t\t\t\tif ( brush->terrainBrush )\n\t\t\t\t{\n\t\t\t\t\tTerrain_Ray( origin, dir, brush, &dist );\n\t\t\t\t\tif( dist == 0 )\n\t\t\t\t\t{\n\t\t\t\t\t\t// didn't actually hit the terrain\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tarray.Add(brush);\n\t\t\t}\n\t\t}\n\n\t\tint nSize = array.GetSize();\n\t\tif (nSize > 0)\n\t\t{\n\t\t\tbool bFound = false;\n\t\t\tfor (int i = 0; i < nSize; i++)\n\t\t\t{\n\t\t\t\tbrush_t *b = reinterpret_cast<brush_t*>(array.GetAt(i));\n\t\t\t\t// did we hit the last one selected yet ?\n\t\t\t\tif (b == pToSelect)\n\t\t\t\t{\n\t\t\t\t\t// yes we want to select the next one in the list \n\t\t\t\t\tint n = (i > 0) ? i-1 : nSize-1;\n\t\t\t\t\tpToSelect = reinterpret_cast<brush_t*>(array.GetAt(n));\n\t\t\t\t\tbFound = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!bFound)\n\t\t\t\tpToSelect = reinterpret_cast<brush_t*>(array.GetAt(0));\n\t\t}\n\t\tif (pToSelect)\n\t\t{\n\t\t\tface = Brush_Ray (origin, dir, pToSelect, &dist);\n\t\t\tif ( pToSelect->terrainBrush )\n\t\t\t{\n\t\t\t\tt.terraface = Terrain_Ray( origin, dir, pToSelect, &dist );\n\t\t\t}\n\n\t\t\tt.dist = dist;\n\t\t\tt.brush = pToSelect;\n\t\t\tt.face = face;\n\t\t\tt.selected = false;\n\t\t\treturn t;\n\t\t}\n\t}\n\n\tif (! (flags & SF_SELECTED_ONLY) )\n\t{\n\t\tfor (brush = active_brushes.next ; brush != &active_brushes ; brush=brush->next)\n\t\t{\n\t\t\tif ( (flags & SF_ENTITIES_FIRST) && brush->owner == world_entity)\n\t\t\t\tcontinue;\n\t\t\t\n\t\t\tif (FilterBrush (brush))\n\t\t\t\tcontinue;\n\n\t\t\tif (!g_PrefsDlg.m_bSelectCurves && brush->patchBrush)\n\t\t\t\tcontinue;\n\n\t\t\tif( !g_PrefsDlg.m_bSelectTerrain && brush->terrainBrush )\n\t\t\t\tcontinue;\n\n\t\t\t//if (!g_bShowPatchBounds && brush->patchBrush)\n\t\t\t//  continue;\n\n\t\t\tface = Brush_Ray (origin, dir, brush, &dist);\n\t\t\tif ( face ) {\n\t\t\t\tif ( brush->terrainBrush )\n\t\t\t\t{\n\t\t\t\t\tt.terraface = Terrain_Ray( origin, dir, brush, &dist );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (dist > 0 && dist < t.dist)\n\t\t\t{\n\t\t\t\tt.dist = dist;\n\t\t\t\tt.brush = brush;\n\t\t\t\tt.face = face;\n\t\t\t\tt.selected = false;\n\t\t\t}\n\t\t}\n\t}\n\n\n\tfor (brush = selected_brushes.next ; brush != &selected_brushes ; brush=brush->next)\n\t{\n\t\tif ( (flags & SF_ENTITIES_FIRST) && brush->owner == world_entity)\n\t\t\tcontinue;\n\n\t\tif (FilterBrush (brush))\n\t\t\tcontinue;\n\n\t\tif (!g_PrefsDlg.m_bSelectCurves && brush->patchBrush)\n\t\t\tcontinue;\n\n\t\tif( !g_PrefsDlg.m_bSelectTerrain && brush->terrainBrush )\n\t\t\tcontinue;\n\n\t\tface = Brush_Ray (origin, dir, brush, &dist);\n\t\tif ( face ) {\n\t\t\tif ( brush->terrainBrush )\n\t\t\t{\n\t\t\t\tt.terraface = Terrain_Ray( origin, dir, brush, &dist );\n\t\t\t}\n\t\t}\n\t\tif (dist > 0 && dist < t.dist)\n\t\t{\n\t\t\tt.dist = dist;\n\t\t\tt.brush = brush;\n\t\t\tt.face = face;\n\t\t\tt.selected = true;\n\t\t}\n\t}\n\n\t// if entites first, but didn't find any, check regular\n\n\tif ( (flags & SF_ENTITIES_FIRST) && t.brush == NULL)\n\t\treturn Test_Ray (origin, dir, flags - SF_ENTITIES_FIRST);\n\n\treturn t;\n\n}\n\n\n/*\n============\nSelect_Brush\n\n============\n*/\nvoid Select_Brush (brush_t *brush, bool bComplete, bool bStatus)\n{\n\tbrush_t\t*b;\n\tentity_t\t*e;\n\n  g_ptrSelectedFaces.RemoveAll();\n  g_ptrSelectedFaceBrushes.RemoveAll();\n\t//selected_face = NULL;\n\tif (g_qeglobals.d_select_count < 2)\n\t\tg_qeglobals.d_select_order[g_qeglobals.d_select_count] = brush;\n\tg_qeglobals.d_select_count++;\n\n  //if (brush->patchBrush)\n  //  Patch_Select(brush->nPatchID);\n\n\te = brush->owner;\n\tif (e)\n\t{\n\t\t// select complete entity on first click\n\t\tif (e != world_entity && bComplete == true)\n\t\t{\n\t\t\tfor (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n\t\t\t\tif (b->owner == e)\n\t\t\t\t\tgoto singleselect;\n\t\t\tfor (b=e->brushes.onext ; b != &e->brushes ; b=b->onext)\n\t\t\t{\n        Brush_RemoveFromList (b);\n\t\t\t\tBrush_AddToList (b, &selected_brushes);\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\nsingleselect:\n\t\t\tBrush_RemoveFromList (brush);\n\t\t\tBrush_AddToList (brush, &selected_brushes);\n      UpdateSurfaceDialog();\n      UpdatePatchInspector();\n\t\t}\n\n\t\tif (e->eclass)\n\t\t{\n\t\t\tUpdateEntitySel(brush->owner->eclass);\n\t\t}\n\t}\n  if (bStatus)\n  {\n    vec3_t vMin, vMax, vSize;\n\t  Select_GetBounds (vMin, vMax);\n    VectorSubtract(vMax, vMin, vSize);\n    CString strStatus;\n    strStatus.Format(\"Selection X:: %.1f  Y:: %.1f  Z:: %.1f\", vSize[0], vSize[1], vSize[2]);\n    g_pParentWnd->SetStatusText(2, strStatus);\n  }\n}\n\n\n/*\n============\nSelect_Ray\n\nIf the origin is inside a brush, that brush will be ignored.\n============\n*/\nvoid Select_Ray (vec3_t origin, vec3_t dir, int flags)\n{\n\ttrace_t\tt;\n\n\tt = Test_Ray (origin, dir, flags);\n\tif (!t.brush)\n\t\treturn;\n\n\tif (flags == SF_SINGLEFACE)\n\t{\n\t\tint nCount = g_SelectedFaces.GetSize();\n\t\tbool bOk = true;\n\t\tfor (int i = 0; i < nCount; i++)\n\t\t{\n\t\t\tif (t.face == reinterpret_cast<face_t*>(g_SelectedFaces.GetAt(i)))\n\t\t\t{\n\t\t\t\tbOk = false;\n\t\t\t\t// need to move remove i'th entry\n\t\t\t\tg_SelectedFaces.RemoveAt(i, 1);\n\t\t\t\tg_SelectedFaceBrushes.RemoveAt(i, 1);\n\t\t\t}\n\t\t}\n\t\tif (bOk)\n\t\t{\n\t\t\tg_SelectedFaces.Add(t.face);\n\t\t\tg_SelectedFaceBrushes.Add(t.brush);\n\t\t}\n\t\t//selected_face = t.face;\n\t\t//selected_face_brush = t.brush;\n\t\tSys_UpdateWindows (W_ALL);\n\t\tclearSelection();\n\t\t// Texture_SetTexture requires a brushprimit_texdef fitted to the default width=2 height=2 texture\n\t\tbrushprimit_texdef_t brushprimit_texdef;\n\t\tConvertTexMatWithQTexture ( &t.face->brushprimit_texdef, t.face->d_texture, &brushprimit_texdef, NULL );\n\t\tTexture_SetTexture ( &t.face->texdef, &brushprimit_texdef, false, GETPLUGINTEXDEF(t.face), false );\n\t\tUpdateSurfaceDialog();\n\t\treturn;\n\t}\n\n\t// move the brush to the other list\n\n\tclearSelection();\n\n\tif (t.selected)\n\t{\t\t\n\t\tBrush_RemoveFromList (t.brush);\n\t\tBrush_AddToList (t.brush, &active_brushes);\n\t\tUpdatePatchInspector();\n\t} \n\telse\n\t{\n\t\tSelect_Brush (t.brush, !(GetKeyState(VK_MENU) & 0x8000));\n\t}\n\n\tSys_UpdateWindows (W_ALL);\n}\n\n\nvoid Select_Delete (void)\n{\n\tbrush_t\t*brush;\n\n  g_ptrSelectedFaces.RemoveAll();\n  g_ptrSelectedFaceBrushes.RemoveAll();\n\t//selected_face = NULL;\n\t\n\tclearSelection();\n\n\tg_qeglobals.d_select_count = 0;\n\tg_qeglobals.d_num_move_points = 0;\n\twhile (selected_brushes.next != &selected_brushes)\n\t{\n\t\tbrush = selected_brushes.next;\n    if (brush->patchBrush)\n    {\n      //Patch_Delete(brush->nPatchID);\n      Patch_Delete(brush->pPatch);\n    }\n\tif (brush->terrainBrush)\n\t{\n\t\tTerrain_Delete(brush->pTerrain );\n\t}\n\n\t\tBrush_Free (brush);\n\t}\n\n\t// FIXME: remove any entities with no brushes\n\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid Select_Deselect (bool bDeselectFaces)\n{\n\tbrush_t\t*b;\n\n  Patch_Deselect();\n\n  g_pParentWnd->ActiveXY()->UndoClear();\n\n  g_qeglobals.d_workcount++;\n\tg_qeglobals.d_select_count = 0;\n\tg_qeglobals.d_num_move_points = 0;\n\tb = selected_brushes.next;\n\n\tif (b == &selected_brushes)\n\t{\n\t\tif (bDeselectFaces)\n\t\t{\n\t\t\tg_ptrSelectedFaces.RemoveAll();\n      g_ptrSelectedFaceBrushes.RemoveAll();\n      //selected_face = NULL;\n\t\t}\n \t\tSys_UpdateWindows (W_ALL);\n\t\treturn;\n\t}\n\n  if (bDeselectFaces)\n  {\n  \tg_ptrSelectedFaces.RemoveAll();\n    g_ptrSelectedFaceBrushes.RemoveAll();\n\t  //selected_face = NULL;\n  }\n\n\tclearSelection();\n\n\t// grab top / bottom height for new brushes\n\tif (b->mins[2] < b->maxs[2])\n\t{\n\t\tg_qeglobals.d_new_brush_bottom_z = b->mins[2];\n\t\tg_qeglobals.d_new_brush_top_z = b->maxs[2];\n\t}\n\n\tselected_brushes.next->prev = &active_brushes;\n\tselected_brushes.prev->next = active_brushes.next;\n\tactive_brushes.next->prev = selected_brushes.prev;\n\tactive_brushes.next = selected_brushes.next;\n\tselected_brushes.prev = selected_brushes.next = &selected_brushes;\t\n\n\tSys_UpdateWindows (W_ALL);\n}\n\n/*\n============\nSelect_Move\n============\n*/\nvoid Select_Move (vec3_t delta, bool bSnap)\n{\n\tbrush_t\t*b;\n  \n \n// actually move the selected brushes\n\tfor (b = selected_brushes.next ; b != &selected_brushes ; b=b->next)\n\t\tBrush_Move (b, delta, bSnap);\n\n  vec3_t vMin, vMax;\n\tSelect_GetBounds (vMin, vMax);\n  CString strStatus;\n  strStatus.Format(\"Origin X:: %.1f  Y:: %.1f  Z:: %.1f\", vMin[0], vMax[1], vMax[2]);\n  g_pParentWnd->SetStatusText(2, strStatus);\n\n//\tSys_UpdateWindows (W_ALL);\n}\n\n/*\n============\nSelect_Clone\n\nCreates an exact duplicate of the selection in place, then moves\nthe selected brushes off of their old positions\n============\n*/\nvoid Select_Clone (void)\n{\n#if 1\n  ASSERT(g_pParentWnd->ActiveXY());\n  g_bScreenUpdates = false;  \n  g_pParentWnd->ActiveXY()->Copy();\n  g_pParentWnd->ActiveXY()->Paste();\n  g_pParentWnd->NudgeSelection(2, g_qeglobals.d_gridsize);\n  g_pParentWnd->NudgeSelection(3, g_qeglobals.d_gridsize);\n  g_bScreenUpdates = true;  \n  Sys_UpdateWindows(W_ALL);\n#else\n\n\tbrush_t\t\t*b, *b2, *n, *next, *next2;\n\tvec3_t\t\tdelta;\n\tentity_t\t*e;\n\n\tg_qeglobals.d_workcount++;\n\tclearSelection();\n\n\tdelta[0] = g_qeglobals.d_gridsize;\n\tdelta[1] = g_qeglobals.d_gridsize;\n\tdelta[2] = 0;\n\n\tfor (b=selected_brushes.next ; b != &selected_brushes ; b=next)\n\t{\n\t\tnext = b->next;\n\t\t// if the brush is a world brush, handle simply\n\t\tif (b->owner == world_entity)\n\t\t{\n\t\t\tn = Brush_Clone (b);\n\t\t\tBrush_AddToList (n, &active_brushes);\n\t\t\tEntity_LinkBrush (world_entity, n);\n\t\t\tBrush_Build( n );\n\t\t\tBrush_Move (b, delta);\n\t\t\tcontinue;\n\t\t}\n\n\t\te = Entity_Clone (b->owner);\n\t\t// clear the target / targetname\n\t\tDeleteKey (e, \"target\");\n\t\tDeleteKey (e, \"targetname\");\n\n\t\t// if the brush is a fixed size entity, create a new entity\n\t\tif (b->owner->eclass->fixedsize)\n\t\t{\n\t\t\tn = Brush_Clone (b);\n\t\t\tBrush_AddToList (n, &active_brushes);\n\t\t\tEntity_LinkBrush (e, n);\n\t\t\tBrush_Build( n );\n\t\t\tBrush_Move (b, delta);\n\t\t\tcontinue;\n\t\t}\n        \n\t\t// brush is a complex entity, grab all the other ones now\n\n\t\tnext = &selected_brushes;\n\n\t\tfor ( b2 = b ; b2 != &selected_brushes ; b2=next2)\n\t\t{\n\t\t\tnext2 = b2->next;\n\t\t\tif (b2->owner != b->owner)\n\t\t\t{\n\t\t\t\tif (next == &selected_brushes)\n\t\t\t\t\tnext = b2;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// move b2 to the start of selected_brushes,\n\t\t\t// so it won't be hit again\n\t\t\tBrush_RemoveFromList (b2);\n\t\t\tBrush_AddToList (b2, &selected_brushes);\n\t\t\t\n\t\t\tn = Brush_Clone (b2);\n\t\t\tBrush_AddToList (n, &active_brushes);\n\t\t\tEntity_LinkBrush (e, n);\n\t\t\tBrush_Build( n );\n\t\t\tBrush_Move (b2, delta, true);\n\t\t}\n\n\t}\n\tSys_UpdateWindows (W_ALL);\n#endif\n}\n\n\n\n/*\n============\nSelect_SetTexture\nTimo : bFitScale to compute scale on the plane and counteract plane / axial plane snapping\nTimo :\tbrush primitive texturing\n\t\tthe brushprimit_texdef given must be understood as a qtexture_t width=2 height=2 ( HiRes )\nTimo :  texture plugin, added an IPluginTexdef* parameter\n\t\tmust be casted to an IPluginTexdef!\n\t\tif not NULL, get ->Copy() of it into each face or brush ( and remember to hook )\n\t\tif NULL, means we have no information, ask for a default\n============\n*/\nvoid WINAPI Select_SetTexture (texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale, void* pPlugTexdef )\n{\n\tbrush_t\t*b;\n\tint nCount = g_ptrSelectedFaces.GetSize();\n\tif (nCount > 0)\n\t{\n\t\tUndo_Start(\"set face textures\");\n\t\tASSERT(g_ptrSelectedFaces.GetSize() == g_ptrSelectedFaceBrushes.GetSize());\n\t\tfor (int i = 0; i < nCount; i++)\n\t\t{\n\t\t\tface_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(i));\n\t\t\tbrush_t *selBrush = reinterpret_cast<brush_t*>(g_ptrSelectedFaceBrushes.GetAt(i));\n\t\t\tUndo_AddBrush(selBrush);\n\t\t\tSetFaceTexdef (selBrush, selFace, texdef, brushprimit_texdef, bFitScale, static_cast<IPluginTexdef *>(pPlugTexdef) );\n\t\t\tBrush_Build(selBrush, bFitScale);\n\t\t\tUndo_EndBrush(selBrush);\n\t\t}\n\t\tUndo_End();\n\t}\n\telse if (selected_brushes.next != &selected_brushes)\n\t{\n\t\tUndo_Start(\"set brush textures\");\n\t\tfor (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n\t\t\tif (!b->owner->eclass->fixedsize)\n\t\t\t{\n\t\t\t\tUndo_AddBrush(b);\n\t\t\t\tBrush_SetTexture (b, texdef, brushprimit_texdef, bFitScale, static_cast<IPluginTexdef *>(pPlugTexdef) );\n\t\t\t\tUndo_EndBrush(b);\n\t\t\t}\n\t\tUndo_End();\n\t}\n\tSys_UpdateWindows (W_ALL);\n}\n\n\n/*\n================================================================\n\n  TRANSFORMATIONS\n\n================================================================\n*/\n\nvoid Select_GetBounds (vec3_t mins, vec3_t maxs)\n{\n\tbrush_t\t*b;\n\tint\t\ti;\n\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tmins[i] = 99999;\n\t\tmaxs[i] = -99999;\n\t}\n\n\tfor (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n\t\tfor (i=0 ; i<3 ; i++)\n\t\t{\n\t\t\tif (b->mins[i] < mins[i])\n\t\t\t\tmins[i] = b->mins[i];\n\t\t\tif (b->maxs[i] > maxs[i])\n\t\t\t\tmaxs[i] = b->maxs[i];\n\t\t}\n}\n\n\nvoid Select_GetTrueMid (vec3_t mid)\n{\n\tvec3_t\tmins, maxs;\n\tSelect_GetBounds (mins, maxs);\n\n  for (int i=0 ; i<3 ; i++)\n    mid[i] = (mins[i] + ((maxs[i] - mins[i]) / 2));\n}\n\n\nvoid Select_GetMid (vec3_t mid)\n{\n\tvec3_t\tmins, maxs;\n\tint\t\ti;\n\n  if (g_PrefsDlg.m_bNoClamp)\n  {\n    Select_GetTrueMid(mid);\n    return;\n  }\n\n  Select_GetBounds (mins, maxs);\n\n  for (i=0 ; i<3 ; i++)\n\t\tmid[i] = g_qeglobals.d_gridsize*floor ( ( (mins[i] + maxs[i])*0.5 )/g_qeglobals.d_gridsize );\n\n}\n\nvec3_t\tselect_origin;\nvec3_t\tselect_matrix[3];\nqboolean\tselect_fliporder;\n\nvoid Select_ApplyMatrix (bool bSnap, bool bRotation, int nAxis, float fDeg)\n{\n\tbrush_t\t*b;\n\tface_t\t*f;\n\tint\t\ti, j;\n\tvec3_t\ttemp;\n\n\tfor (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n\t{\n\t\tfor (f=b->brush_faces ; f ; f=f->next)\n\t\t{\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t{\n\t\t\t\tVectorSubtract (f->planepts[i], select_origin, temp);\n\t\t\t\tfor (j=0 ; j<3 ; j++)\n\t\t\t\t\tf->planepts[i][j] = DotProduct(temp, select_matrix[j]) + select_origin[j];\n\t\t\t}\n\t\t\tif (select_fliporder)\n\t\t\t{\n\t\t\t\tVectorCopy (f->planepts[0], temp);\n\t\t\t\tVectorCopy (f->planepts[2], f->planepts[0]);\n\t\t\t\tVectorCopy (temp, f->planepts[2]);\n\t\t\t}\n\t\t}\n\n\t\tif(b->owner->eclass->fixedsize)\n\t\t{\n\t\t\tif (bRotation && b->owner->md3Class)\n\t\t\t{\n\t\t\t\tb->owner->vRotation[nAxis] += fDeg;\n\t\t\t}\n\t\t}\n\n\t\tBrush_Build(b, bSnap);\n    \n\t\tif (b->patchBrush)\n\t\t{\n\t\t\t//Patch_ApplyMatrix(b->nPatchID, select_origin, select_matrix);\n\t\t\tPatch_ApplyMatrix(b->pPatch, select_origin, select_matrix, bSnap);\n\t\t}\n\n\t\tif (b->terrainBrush)\n\t\t{\n\t\t  Terrain_ApplyMatrix(b->pTerrain, select_origin, select_matrix, bSnap);\n\t\t}\n\n\t}\n}\n\nvoid ProjectOnPlane(vec3_t& normal,float dist,vec3_t& ez, vec3_t& p)\n{\n\tif (fabs(ez[0]) == 1)\n\t\tp[0] = (dist - normal[1] * p[1] - normal[2] * p[2]) / normal[0];\n\telse if (fabs(ez[1]) == 1)\n\t\tp[1] = (dist - normal[0] * p[0] - normal[2] * p[2]) / normal[1];\n\telse\n\t\tp[2] = (dist - normal[0] * p[0] - normal[1] * p[1]) / normal[2];\n}\n\nvoid Back(vec3_t& dir, vec3_t& p)\n{\n\tif (fabs(dir[0]) == 1)\n\t\tp[0] = 0;\n\telse if (fabs(dir[1]) == 1)\n\t\tp[1] = 0;\n\telse p[2] = 0;\n}\n\n\n\n// using scale[0] and scale[1]\nvoid ComputeScale(vec3_t& rex, vec3_t& rey, vec3_t& p, face_t* f)\n{\n\tfloat px = DotProduct(rex, p);\n\tfloat py = DotProduct(rey, p);\n\tpx *= f->texdef.scale[0];\n\tpy *= f->texdef.scale[1];\n  vec3_t aux;\n  VectorCopy(rex, aux);\n  VectorScale(aux, px, aux);\n  VectorCopy(aux, p);\n  VectorCopy(rey, aux);\n  VectorScale(aux, py, aux);\n  VectorAdd(p, aux, p);\n}\n\nvoid ComputeAbsolute(face_t* f, vec3_t& p1, vec3_t& p2, vec3_t& p3)\n{\n\tvec3_t ex,ey,ez;\t        // local axis base\n\n#ifdef _DEBUG\n\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\tSys_Printf(\"Warning : illegal call of ComputeAbsolute in brush primitive mode\\n\");\n#endif\n\n  // compute first local axis base\n  TextureAxisFromPlane(&f->plane, ex, ey);\n  CrossProduct(ex, ey, ez);\n\t    \n\tvec3_t aux;\n  VectorCopy(ex, aux);\n  VectorScale(aux, -f->texdef.shift[0], aux);\n  VectorCopy(aux, p1);\n  VectorCopy(ey, aux);\n  VectorScale(aux, -f->texdef.shift[1], aux);\n  VectorAdd(p1, aux, p1);\n  VectorCopy(p1, p2);\n  VectorAdd(p2, ex, p2);\n  VectorCopy(p1, p3);\n  VectorAdd(p3, ey, p3);\n  VectorCopy(ez, aux);\n  VectorScale(aux, -f->texdef.rotate, aux);\n  VectorRotate(p1, aux, p1);\n  VectorRotate(p2, aux, p2);\n  VectorRotate(p3, aux, p3);\n\t// computing rotated local axis base\n\tvec3_t rex,rey;\n  VectorCopy(ex, rex);\n  VectorRotate(rex, aux, rex);\n  VectorCopy(ey, rey);\n  VectorRotate(rey, aux, rey);\n\n  ComputeScale(rex,rey,p1,f);\n\tComputeScale(rex,rey,p2,f);\n\tComputeScale(rex,rey,p3,f);\n\n\t// project on normal plane\n\t// along ez \n\t// assumes plane normal is normalized\n\tProjectOnPlane(f->plane.normal,f->plane.dist,ez,p1);\n\tProjectOnPlane(f->plane.normal,f->plane.dist,ez,p2);\n\tProjectOnPlane(f->plane.normal,f->plane.dist,ez,p3);\n};\n\n\nvoid AbsoluteToLocal(plane_t normal2, face_t* f, vec3_t& p1, vec3_t& p2, vec3_t& p3)\n{\n\tvec3_t ex,ey,ez;\n\n#ifdef _DEBUG\n\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\tSys_Printf(\"Warning : illegal call of AbsoluteToLocal in brush primitive mode\\n\");\n#endif\n\n\t// computing new local axis base\n  TextureAxisFromPlane(&normal2, ex, ey);\n  CrossProduct(ex, ey, ez);\n\n  // projecting back on (ex,ey)\n\tBack(ez,p1);\n\tBack(ez,p2);\n\tBack(ez,p3);\n\n\tvec3_t aux;\n\t// rotation\n  VectorCopy(p2, aux);\n  VectorSubtract(aux, p1,aux);\n\t\n\tfloat x = DotProduct(aux,ex);\n\tfloat y = DotProduct(aux,ey);\n  f->texdef.rotate = 180 * atan2(y,x) / Q_PI;\n\n\tvec3_t rex,rey;\n\t// computing rotated local axis base\n  VectorCopy(ez, aux);\n  VectorScale(aux, f->texdef.rotate, aux);\n  VectorCopy(ex, rex);\n  VectorRotate(rex, aux, rex);\n  VectorCopy(ey, rey);\n  VectorRotate(rey, aux, rey);\n\n\t// scale\n  VectorCopy(p2, aux);\n  VectorSubtract(aux, p1, aux);\n  f->texdef.scale[0] = DotProduct(aux, rex);\n  VectorCopy(p3, aux);\n  VectorSubtract(aux, p1, aux);\n  f->texdef.scale[1] = DotProduct(aux, rey);\n\n\t// shift\n\t// only using p1\n\tx = DotProduct(rex,p1);\n\ty = DotProduct(rey,p1);                 \n\tx /= f->texdef.scale[0];\n\ty /= f->texdef.scale[1];\n\n  VectorCopy(rex, p1);\n  VectorScale(p1, x, p1);\n  VectorCopy(rey, aux);\n  VectorScale(aux, y, aux);\n  VectorAdd(p1, aux, p1);\n  VectorCopy(ez, aux);\n  VectorScale(aux, -f->texdef.rotate, aux);\n  VectorRotate(p1, aux, p1);\n\tf->texdef.shift[0] = -DotProduct(p1, ex);\n\tf->texdef.shift[1] = -DotProduct(p1, ey);\n\n\t// stored rot is good considering local axis base\n\t// change it if necessary\n\tf->texdef.rotate = -f->texdef.rotate;\n\n  Clamp(f->texdef.shift[0], f->d_texture->width);\n  Clamp(f->texdef.shift[1], f->d_texture->height);\n  Clamp(f->texdef.rotate, 360);\n\n}\n\nvoid RotateFaceTexture(face_t* f, int nAxis, float fDeg)\n{\n\tvec3_t p1,p2,p3, rota;   \n\tp1[0] = p1[1] = p1[2] = 0;\n\tVectorCopy(p1, p2);\n\tVectorCopy(p1, p3);\n\tVectorCopy(p1, rota);\n\tComputeAbsolute(f, p1, p2, p3);\n  \n\trota[nAxis] = fDeg;\n\tVectorRotate(p1, rota, select_origin, p1);\n\tVectorRotate(p2, rota, select_origin, p2);\n\tVectorRotate(p3, rota, select_origin, p3);\n\n\tplane_t normal2;\n\tvec3_t vNormal;\n\tvNormal[0] = f->plane.normal[0];\n\tvNormal[1] = f->plane.normal[1];\n\tvNormal[2] = f->plane.normal[2];\n\tVectorRotate(vNormal, rota, vNormal);\n\tnormal2.normal[0] = vNormal[0];\n\tnormal2.normal[1] = vNormal[1];\n\tnormal2.normal[2] = vNormal[2];\n\tAbsoluteToLocal(normal2, f, p1, p2 ,p3);\n\n}\n\nvoid RotateTextures(int nAxis, float fDeg, vec3_t vOrigin)\n{\n\tfor (brush_t* b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n\t{\n\t\tfor (face_t* f=b->brush_faces ; f ; f=f->next)\n\t\t{\n\t\t\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\t\t\tRotateFaceTexture_BrushPrimit( f, nAxis, fDeg, vOrigin );\n\t\t\telse\n\t\t\t\tRotateFaceTexture(f, nAxis, fDeg);\n\t\t\t//++timo removed that call .. works fine .. ???????\n//\t\t\tBrush_Build(b, false);\n\t\t}\n\t\tBrush_Build(b, false);\n\t}\n}\n\n\nvoid Select_FlipAxis (int axis)\n{\n\tint\t\ti;\n\n\tSelect_GetMid (select_origin);\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tVectorCopy (vec3_origin, select_matrix[i]);\n\t\tselect_matrix[i][i] = 1;\n\t}\n\tselect_matrix[axis][axis] = -1;\n\n\tselect_fliporder = true;\n\tSelect_ApplyMatrix (true, false, 0, 0);\n\tSys_UpdateWindows (W_ALL);\n}\n\n\nvoid Select_Scale(float x, float y, float z)\n{\n\tSelect_GetMid (select_origin);\n\tfor (brush_t* b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n\t{\n\t\tfor (face_t* f=b->brush_faces ; f ; f=f->next)\n\t\t{\n\t\t\tfor (int i=0 ; i<3 ; i++)\n\t\t\t{\n\t\t\t\tf->planepts[i][0] -= select_origin[0];\n\t\t\t\tf->planepts[i][1] -= select_origin[1];\n\t\t\t\tf->planepts[i][2] -= select_origin[2];\n\t\t\t\tf->planepts[i][0] *= x;\n\t\t\t\t//f->planepts[i][0] = floor(f->planepts[i][0] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize;\n\n\t\t\t\tf->planepts[i][1] *= y;\n\t\t\t\t//f->planepts[i][1] = floor(f->planepts[i][1] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize;\n\n\t\t\t\tf->planepts[i][2] *= z;\n\t\t        //f->planepts[i][2] = floor(f->planepts[i][2] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize;\n\t\t\n\t\t\t\tf->planepts[i][0] += select_origin[0];\n\t\t\t\tf->planepts[i][1] += select_origin[1];\n\t\t\t\tf->planepts[i][2] += select_origin[2];\n\t\t\t}\n\t\t}\n\t\tBrush_Build(b, false);\n\t\tif (b->patchBrush)\n\t\t{\n\t\t\tvec3_t v;\n\t\t\tv[0] = x;\n\t\t\tv[1] = y;\n\t\t\tv[2] = z;\n\t\t\t//Patch_Scale(b->nPatchID, select_origin, v);\n\t\t\tPatch_Scale(b->pPatch, select_origin, v);\n\t\t}\n\t\tif (b->terrainBrush)\n\t\t{\n\t\t\tvec3_t v;\n\t\t\tv[0] = x;\n\t\t\tv[1] = y;\n\t\t\tv[2] = z;\n\t\t\tTerrain_Scale(b->pTerrain, select_origin, v);\n\t\t}\n\t}\n}\n\nvoid Select_RotateAxis (int axis, float deg, bool bPaint, bool bMouse)\n{\n\tvec3_t\ttemp;\n\tint\t\ti, j;\n\tvec_t\tc, s;\n\n\tif (deg == 0)\n  {\n    //Sys_Printf(\"0 deg\\n\");\n\t\treturn;\n  }\n\n  if (bMouse)\n  {\n    VectorCopy(g_pParentWnd->ActiveXY()->RotateOrigin(), select_origin);\n  }\n  else\n  {\n\t  Select_GetMid (select_origin);\n  }\n\n\tselect_fliporder = false;\n\n\tif (deg == 90)\n\t{\n\t\tfor (i=0 ; i<3 ; i++)\n\t\t{\n\t\t\tVectorCopy (vec3_origin, select_matrix[i]);\n\t\t\tselect_matrix[i][i] = 1;\n\t\t}\n\t\ti = (axis+1)%3;\n\t\tj = (axis+2)%3;\n\t\tVectorCopy (select_matrix[i], temp);\n\t\tVectorCopy (select_matrix[j], select_matrix[i]);\n\t\tVectorSubtract (vec3_origin, temp, select_matrix[j]);\n\t}\n\telse\n\t{\n\t\tdeg = -deg;\n\t\tif (deg == -180.0)\n\t\t{\n\t\t\tc = -1;\n\t\t\ts = 0;\n\t\t}\n\t\telse if (deg == -270.0)\n\t\t{\n\t\t\tc = 0;\n\t\t\ts = -1;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tc = cos(deg * Q_PI / 180.0);\n\t\t\ts = sin(deg * Q_PI / 180.0);\n\t\t}\n\n\t\tfor (i=0 ; i<3 ; i++)\n\t\t{\n\t\t\tVectorCopy (vec3_origin, select_matrix[i]);\n\t\t\tselect_matrix[i][i] = 1;\n\t\t}\n\n\t\tswitch (axis)\n\t\t{\n\t\tcase 0:\n\t\t\tselect_matrix[1][1] = c;\n\t\t\tselect_matrix[1][2] = -s;\n\t\t\tselect_matrix[2][1] = s;\n\t\t\tselect_matrix[2][2] = c;\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\tselect_matrix[0][0] = c;\n\t\t\tselect_matrix[0][2] = s;\n\t\t\tselect_matrix[2][0] = -s;\n\t\t\tselect_matrix[2][2] = c;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tselect_matrix[0][0] = c;\n\t\t\tselect_matrix[0][1] = -s;\n\t\t\tselect_matrix[1][0] = s;\n\t\t\tselect_matrix[1][1] = c;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (g_PrefsDlg.m_bRotateLock)\n\t\tRotateTextures(axis, deg, select_origin);\n\tSelect_ApplyMatrix(!bMouse, true, axis, deg);\n\n\tif (bPaint)\n\t\tSys_UpdateWindows (W_ALL);\n}\n\n/*\n================================================================\n\nGROUP SELECTIONS\n\n================================================================\n*/\n\nvoid Select_CompleteTall (void)\n{\n\tbrush_t\t*b, *next;\n\t//int\t\ti;\n\tvec3_t\tmins, maxs;\n\n\tif (!QE_SingleBrush ())\n\t\treturn;\n\n\tclearSelection();\n\n\tVectorCopy (selected_brushes.next->mins, mins);\n\tVectorCopy (selected_brushes.next->maxs, maxs);\n\tSelect_Delete ();\n\n  int nDim1 = (g_pParentWnd->ActiveXY()->GetViewType() == YZ) ? 1 : 0;\n  int nDim2 = (g_pParentWnd->ActiveXY()->GetViewType() == XY) ? 1 : 2;\n\n\tfor (b=active_brushes.next ; b != &active_brushes ; b=next)\n\t{\n\t\tnext = b->next;\n\n    if ( (b->maxs[nDim1] > maxs[nDim1] || b->mins[nDim1] < mins[nDim1]) \n      || (b->maxs[nDim2] > maxs[nDim2] || b->mins[nDim2] < mins[nDim2]) )\n      continue;\n\n\t \tif (FilterBrush (b))\n\t \t\tcontinue;\n\n\t\tBrush_RemoveFromList (b);\n\t\tBrush_AddToList (b, &selected_brushes);\n#if 0\n    // old stuff\n    for (i=0 ; i<2 ; i++)\n\t\t\tif (b->maxs[i] > maxs[i] || b->mins[i] < mins[i])\n\t\t\t\tbreak;\n\t\tif (i == 2)\n\t\t{\n\t\t\tBrush_RemoveFromList (b);\n\t\t\tBrush_AddToList (b, &selected_brushes);\n\t\t}\n#endif\n\t}\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid Select_PartialTall (void)\n{\n\tbrush_t\t*b, *next;\n\t//int\t\ti;\n\tvec3_t\tmins, maxs;\n\n\tif (!QE_SingleBrush ())\n\t\treturn;\n\n\tclearSelection();\n\n\tVectorCopy (selected_brushes.next->mins, mins);\n\tVectorCopy (selected_brushes.next->maxs, maxs);\n\tSelect_Delete ();\n\n  int nDim1 = (g_pParentWnd->ActiveXY()->GetViewType() == YZ) ? 1 : 0;\n  int nDim2 = (g_pParentWnd->ActiveXY()->GetViewType() == XY) ? 1 : 2;\n\n\tfor (b=active_brushes.next ; b != &active_brushes ; b=next)\n\t{\n\t\tnext = b->next;\n\n    if ( (b->mins[nDim1] > maxs[nDim1] || b->maxs[nDim1] < mins[nDim1]) \n      || (b->mins[nDim2] > maxs[nDim2] || b->maxs[nDim2] < mins[nDim2]) )\n      continue;\n\n\t \tif (FilterBrush (b))\n\t \t\tcontinue;\n\n  \tBrush_RemoveFromList (b);\n\t\tBrush_AddToList (b, &selected_brushes);\n\n\n#if 0\n// old stuff\n\t\tfor (i=0 ; i<2 ; i++)\n\t\t\tif (b->mins[i] > maxs[i] || b->maxs[i] < mins[i])\n\t\t\t\tbreak;\n\t\tif (i == 2)\n\t\t{\n\t\t\tBrush_RemoveFromList (b);\n\t\t\tBrush_AddToList (b, &selected_brushes);\n\t\t}\n#endif\n\t}\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid Select_Touching (void)\n{\n\tbrush_t\t*b, *next;\n\tint\t\ti;\n\tvec3_t\tmins, maxs;\n\n\tif (!QE_SingleBrush ())\n\t\treturn;\n\n\tclearSelection();\n\n\tVectorCopy (selected_brushes.next->mins, mins);\n\tVectorCopy (selected_brushes.next->maxs, maxs);\n\n\tfor (b=active_brushes.next ; b != &active_brushes ; b=next)\n\t{\n\t\tnext = b->next;\n\n\t \tif (FilterBrush (b))\n\t \t\tcontinue;\n\n\t\tfor (i=0 ; i<3 ; i++)\n\t\t\tif (b->mins[i] > maxs[i]+1 || b->maxs[i] < mins[i]-1)\n\t\t\t\tbreak;\n\n\t\tif (i == 3)\n\t\t{\n\t\t\tBrush_RemoveFromList (b);\n\t\t\tBrush_AddToList (b, &selected_brushes);\n\t\t}\n\t}\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid Select_Inside (void)\n{\n\tbrush_t\t*b, *next;\n\tint\t\ti;\n\tvec3_t\tmins, maxs;\n\n\tif (!QE_SingleBrush ())\n\t\treturn;\n\n\tclearSelection();\n\n\tVectorCopy (selected_brushes.next->mins, mins);\n\tVectorCopy (selected_brushes.next->maxs, maxs);\n\tSelect_Delete ();\n\n\tfor (b=active_brushes.next ; b != &active_brushes ; b=next)\n\t{\n\t\tnext = b->next;\n\n\t \tif (FilterBrush (b))\n\t \t\tcontinue;\n\n\t\tfor (i=0 ; i<3 ; i++)\n\t\t\tif (b->maxs[i] > maxs[i] || b->mins[i] < mins[i])\n\t\t\t\tbreak;\n\t\tif (i == 3)\n\t\t{\n\t\t\tBrush_RemoveFromList (b);\n\t\t\tBrush_AddToList (b, &selected_brushes);\n\t\t}\n\t}\n\tSys_UpdateWindows (W_ALL);\n}\n\n/*\n=============\nSelect_Ungroup\n\nTurn the currently selected entity back into normal brushes\n=============\n*/\nvoid Select_Ungroup(void)\n{\n\tint numselectedgroups;\n\tentity_t\t*e;\n\tbrush_t\t\t*b, *sb;\n\n\tnumselectedgroups = 0;\n\tfor (sb = selected_brushes.next; sb != &selected_brushes; sb = sb->next)\n\t{\n\t\te = sb->owner;\n\n\t\tif (!e || e == world_entity || e->eclass->fixedsize)\n\t\t{\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (b = e->brushes.onext; b != &e->brushes; b = e->brushes.onext)\n\t\t{\n\t\t\t//Brush_RemoveFromList (b);\n\t\t\t//Brush_AddToList (b, &active_brushes);\n\t\t\tEntity_UnlinkBrush (b);\n\t\t\tEntity_LinkBrush (world_entity, b);\n\t\t\tBrush_Build( b );\n\t\t\tb->owner = world_entity;\n\t\t}\n\t\tEntity_Free (e);\n\t\tnumselectedgroups++;\n\t}\n\n\tif (numselectedgroups <= 0)\n\t{\n\t\tSys_Printf(\"No grouped entities selected.\\n\");\n\t\treturn;\n\t}\n\tSys_Printf(\"Ungrouped %d entit%s.\\n\", numselectedgroups, (numselectedgroups == 1)?\"y\":\"ies\");\n\tSys_UpdateWindows (W_ALL);\n}\n\n\n/*\n====================\nSelect_MakeStructural\n====================\n*/\nvoid Select_MakeStructural (void)\n{\n\tbrush_t\t*b;\n\tface_t\t*f;\n\n\tfor (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n\t\tfor (f=b->brush_faces ; f ; f=f->next)\n\t\t\tf->texdef.contents &= ~CONTENTS_DETAIL;\n\tSelect_Deselect ();\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid Select_MakeDetail (void)\n{\n\tbrush_t\t*b;\n\tface_t\t*f;\n\n\tfor (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n\t\tfor (f=b->brush_faces ; f ; f=f->next)\n\t\t\tf->texdef.contents |= CONTENTS_DETAIL;\n\tSelect_Deselect ();\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid Select_ShiftTexture(int x, int y)\n{\n\tbrush_t\t\t*b;\n\tface_t\t\t*f;\n\n  int nFaceCount = g_ptrSelectedFaces.GetSize();\n\n\tif(selected_brushes.next == &selected_brushes && nFaceCount == 0)\n\t\treturn;\n\n\tfor (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n\t{\n\t\tfor (f=b->brush_faces ; f ; f=f->next)\n\t\t{\n\t\t\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\t\t{\n\t\t\t\t// use face normal to compute a true translation\n\t\t\t\tSelect_ShiftTexture_BrushPrimit( f, x, y );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tf->texdef.shift[0] += x;\n\t\t\t\tf->texdef.shift[1] += y;\n\t\t\t}\n\t\t}\n\t\tBrush_Build(b);\n\t\tif (b->patchBrush)\n\t\t{\n\t\t\t//Patch_ShiftTexture(b->nPatchID, x, y);\n\t\t\tPatch_ShiftTexture(b->pPatch, x, y);\n\t\t}\n\t}\n\n\tif (nFaceCount > 0)\n\t{\n    for (int i = 0; i < nFaceCount; i++)\n    {\n      face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(i));\n      brush_t *selBrush = reinterpret_cast<brush_t*>(g_ptrSelectedFaceBrushes.GetAt(i));\n  \t\tif (g_qeglobals.m_bBrushPrimitMode)\n\t  \t{\n\n\t\t\t  // use face normal to compute a true translation\n        // Select_ShiftTexture_BrushPrimit( selected_face, x, y );\n\t\t\t  // use camera view to compute texture shift\n\t\t\t  g_pParentWnd->GetCamera()->ShiftTexture_BrushPrimit( selFace, x, y );\n      }\n  \t\telse\n\t  \t{\n\t\t  \tselFace->texdef.shift[0] += x;\n\t\t\t  selFace->texdef.shift[1] += y;\n  \t\t}\n\t  \tBrush_Build(selBrush);\n    }\n\t}\n\n\tSys_UpdateWindows (W_CAMERA);\n}\n\nvoid Select_ScaleTexture(int x, int y)\n{\n\tbrush_t\t\t*b;\n\tface_t\t\t*f;\n\n  int nFaceCount = g_ptrSelectedFaces.GetSize();\n\n  if(selected_brushes.next == &selected_brushes && nFaceCount == 0)\n\t{\n\t\treturn;\n\t}\n\n\tfor (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n\t{\n\t\tfor (f=b->brush_faces ; f ; f=f->next)\n\t\t{\n\t\t\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\t\t{\n\t\t\t\t// apply same scale as the spinner button of the surface inspector\n\t\t\t\tfloat\tshift[2];\n\t\t\t\tfloat\trotate;\n\t\t\t\tfloat\tscale[2];\n\t\t\t\tbrushprimit_texdef_t bp; \n\t\t\t\t// compute normalized texture matrix\n\t\t\t\tConvertTexMatWithQTexture( &f->brushprimit_texdef, f->d_texture, &bp, NULL );\n\t\t\t\t// compute fake shift scale rot\n\t\t\t\tTexMatToFakeTexCoords( bp.coords, shift, &rotate, scale );\n\t\t\t\t// update\n\t\t\t\tscale[0]+=static_cast<float>(x)*0.1;\n\t\t\t\tscale[1]+=static_cast<float>(y)*0.1;\n\t\t\t\t// compute new normalized texture matrix\n\t\t\t\tFakeTexCoordsToTexMat( shift, rotate, scale, bp.coords );\n\t\t\t\t// apply to face texture matrix\n\t\t\t\tConvertTexMatWithQTexture( &bp, NULL, &f->brushprimit_texdef, f->d_texture );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tf->texdef.scale[0] += x;\n\t\t\t\tf->texdef.scale[1] += y;\n\t\t\t}\n\t\t}\n\t\tBrush_Build(b);\n\t\tif (b->patchBrush)\n\t\t{\n\t\t\tPatch_ScaleTexture(b->pPatch, x, y);\n\t\t}\n\t}\n\n\tif (nFaceCount > 0)\n\t{\n    for (int i = 0; i < nFaceCount; i++)\n    {\n      face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(i));\n      brush_t *selBrush = reinterpret_cast<brush_t*>(g_ptrSelectedFaceBrushes.GetAt(i));\n\t\t  if (g_qeglobals.m_bBrushPrimitMode)\n\t\t  {\n\t\t\t  float\tshift[2];\n\t\t\t  float\trotate;\n\t\t\t  float\tscale[2];\n\t\t\t  brushprimit_texdef_t bp; \n\t\t\t  ConvertTexMatWithQTexture( &selFace->brushprimit_texdef, selFace->d_texture, &bp, NULL );\n\t\t\t  TexMatToFakeTexCoords( bp.coords, shift, &rotate, scale );\n\t\t\t  scale[0]+=static_cast<float>(x)*0.1;\n\t\t\t  scale[1]+=static_cast<float>(y)*0.1;\n\t\t\t  FakeTexCoordsToTexMat( shift, rotate, scale, bp.coords );\n\t\t\t  ConvertTexMatWithQTexture( &bp, NULL, &selFace->brushprimit_texdef, selFace->d_texture );\n\t\t  }\n\t\t  else\n\t\t  {\n\t\t\t  selFace->texdef.scale[0] += x;\n\t\t\t  selFace->texdef.scale[1] += y;\n\t\t  }\n\t\t  Brush_Build(selBrush);\n    }\n\t}\n\n\tSys_UpdateWindows (W_CAMERA);\n}\n\nvoid Select_RotateTexture(int amt)\n{\n\tbrush_t\t\t*b;\n\tface_t\t\t*f;\n\n  int nFaceCount = g_ptrSelectedFaces.GetSize();\n\n  if(selected_brushes.next == &selected_brushes && nFaceCount == 0)\n\t{\n\t\treturn;\n\t}\n\n\tfor (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n\t{\n\t\tfor (f=b->brush_faces ; f ; f=f->next)\n\t\t{\n\t\t\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\t\t{\n\t\t\t\t// apply same scale as the spinner button of the surface inspector\n\t\t\t\tfloat\tshift[2];\n\t\t\t\tfloat\trotate;\n\t\t\t\tfloat\tscale[2];\n\t\t\t\tbrushprimit_texdef_t bp; \n\t\t\t\t// compute normalized texture matrix\n\t\t\t\tConvertTexMatWithQTexture( &f->brushprimit_texdef, f->d_texture, &bp, NULL );\n\t\t\t\t// compute fake shift scale rot\n\t\t\t\tTexMatToFakeTexCoords( bp.coords, shift, &rotate, scale );\n\t\t\t\t// update\n\t\t\t\trotate += amt;\n\t\t\t\t// compute new normalized texture matrix\n\t\t\t\tFakeTexCoordsToTexMat( shift, rotate, scale, bp.coords );\n\t\t\t\t// apply to face texture matrix\n\t\t\t\tConvertTexMatWithQTexture( &bp, NULL, &f->brushprimit_texdef, f->d_texture );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tf->texdef.rotate += amt;\n\t\t\t\tf->texdef.rotate = static_cast<int>(f->texdef.rotate) % 360;\n\t\t\t}\n\t\t}\n\t\tBrush_Build(b);\n\t\tif (b->patchBrush)\n\t\t{\n\t\t\t//Patch_RotateTexture(b->nPatchID, amt);\n\t\t\tPatch_RotateTexture(b->pPatch, amt);\n\t\t}\n\t}\n\t\n\tif (nFaceCount > 0)\n\t{\n    for (int i = 0; i < nFaceCount; i++)\n    {\n      face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(i));\n      brush_t *selBrush = reinterpret_cast<brush_t*>(g_ptrSelectedFaceBrushes.GetAt(i));\n\t\t  if (g_qeglobals.m_bBrushPrimitMode)\n\t\t  {\n\t\t\t  float\tshift[2];\n\t\t\t  float\trotate;\n\t\t\t  float\tscale[2];\n\t\t\t  brushprimit_texdef_t bp; \n\t\t\t  ConvertTexMatWithQTexture( &selFace->brushprimit_texdef, selFace->d_texture, &bp, NULL );\n\t\t\t  TexMatToFakeTexCoords( bp.coords, shift, &rotate, scale );\n\t\t\t  rotate += amt;\n\t\t\t  FakeTexCoordsToTexMat( shift, rotate, scale, bp.coords );\n\t\t\t  ConvertTexMatWithQTexture( &bp, NULL, &selFace->brushprimit_texdef, selFace->d_texture );\n\t\t  }\n\t\t  else\n\t\t  {\n\t\t\t  selFace->texdef.rotate += amt;\n\t\t\t  selFace->texdef.rotate = static_cast<int>(selFace->texdef.rotate) % 360;\n\t\t  }\n\t\t  Brush_Build(selBrush);\n    }\n\t}\n\n\tSys_UpdateWindows (W_CAMERA);\n}\n\n\nvoid FindReplaceTextures(const char* pFind, const char* pReplace, bool bSelected, bool bForce)\n{\n\tbrush_t* pList = (bSelected) ? &selected_brushes : &active_brushes;\n\tif (!bSelected)\n\t{\n\t\tSelect_Deselect();\n\t}\n \n\tfor (brush_t* pBrush = pList->next ; pBrush != pList; pBrush = pBrush->next)\n\t{\n\t\tif (pBrush->patchBrush)\n\t\t{\n\t\t\tPatch_FindReplaceTexture(pBrush, pFind, pReplace, bForce);\n\t\t}\n\n\t\tif (pBrush->terrainBrush)\n\t\t{\n\t\t\tTerrain_FindReplaceTexture(pBrush->pTerrain, pFind, pReplace, bForce);\n\t\t}\n\t\tfor (face_t* pFace = pBrush->brush_faces; pFace; pFace = pFace->next)\n\t\t{\n\t\t\tif(bForce || strcmpi(pFace->texdef.name, pFind) == 0)\n\t\t\t{\n\t\t\t\tpFace->d_texture = Texture_ForName(pReplace);\n\t\t\t\t//strcpy(pFace->texdef.name, pReplace);\n\t\t\t\tpFace->texdef.SetName(pReplace);\n\t\t\t}\n\t\t}\n\t\tBrush_Build(pBrush);\n\t}\n\tSys_UpdateWindows (W_CAMERA);\n}\n\n\nvoid Select_AllOfType()\n{\n\tbrush_t\t*b, *next;\n\tentity_t\t*e;\n\tif ( (selected_brushes.next == &selected_brushes)\n\t\t|| (selected_brushes.next->next != &selected_brushes) )\n\t{\n\n    CString strName;\n    if (g_ptrSelectedFaces.GetSize() == 0)\n    {\n      strName = g_qeglobals.d_texturewin.texdef.name;\n    }\n    else\n    {\n      face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));\n      strName = selFace->texdef.name;\n    }\n\n    Select_Deselect();\n\t  for (b=active_brushes.next ; b != &active_brushes ; b=next)\n    {\n\t\t  next = b->next;\n    \t\n      if (FilterBrush (b))\n\t \t    continue;\n\n      if (b->patchBrush)\n      {\n        if (strcmpi(strName, b->pPatch->d_texture->name) == 0)\n        {\n\t\t\t    Brush_RemoveFromList (b);\n\t\t\t    Brush_AddToList (b, &selected_brushes);\n        }\n      }\n      else\n      {\n        for (face_t* pFace = b->brush_faces; pFace; pFace = pFace->next)\n        {\n          if (strcmpi(strName, pFace->texdef.name) == 0)\n          {\n\t\t\t      Brush_RemoveFromList (b);\n\t\t\t      Brush_AddToList (b, &selected_brushes);\n          }\n        }\n      }\n    }\n    Sys_UpdateWindows(W_ALL);\n    return;\n  }\n\n  \n  b = selected_brushes.next;\n\te = b->owner;\n\n  if (e != NULL)\n  {\n    if (e != world_entity)\n    {\n      CString strName = e->eclass->name;\n      CString strKey, strVal;\n      bool bCriteria = GetSelectAllCriteria(strKey, strVal);\n      Sys_Printf(\"Selecting all %s(s)\\n\", strName);\n      Select_Deselect();\n\n\t    for (b=active_brushes.next ; b != &active_brushes ; b=next)\n    \t{\n\t\t    next = b->next;\n    \t \t\n        if (FilterBrush (b))\n\t \t    \tcontinue;\n\n        e = b->owner;\n        if (e != NULL)\n        {\n          if (strcmpi(e->eclass->name, strName) == 0)\n          {\n            bool doIt = true;\n            if (bCriteria) {\n              CString str = ValueForKey (e, strKey);\n              if (str.CompareNoCase(strVal) != 0) {\n                doIt = false;\n              }\n            }\n            if (doIt) {\n  \t\t        Brush_RemoveFromList (b);\n\t  \t        Brush_AddToList (b, &selected_brushes);\n            }\n          }\n        }\n      }\n    }\n  }\n\tSys_UpdateWindows (W_ALL);\n\n}\n\nvoid Select_Reselect()\n{\n  CPtrArray holdArray;\n\tfor (brush_t* b=selected_brushes.next ; b && b != &selected_brushes ; b=b->next)\n\t{\n    holdArray.Add(reinterpret_cast<void*>(b));\n\t}\n\n  int n = holdArray.GetSize();\n  while (n-- > 0)\n  {\n    b = reinterpret_cast<brush_t*>(holdArray.GetAt(n));\n    Select_Brush(b);\n  }\n\tSys_UpdateWindows (W_ALL);\n}\n\n\nvoid Select_FitTexture(int nHeight, int nWidth)\n{\n\tbrush_t\t\t*b;\n\n  int nFaceCount = g_ptrSelectedFaces.GetSize();\n\n  if(selected_brushes.next == &selected_brushes && nFaceCount == 0)\n\t\treturn;\n\n  for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n\t{\n    Brush_FitTexture(b, nHeight, nWidth);\n\t\tBrush_Build(b);\n\t}\n\n\tif (nFaceCount > 0)\n\t{\n    for (int i = 0; i < nFaceCount; i++)\n    {\n      face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(i));\n      brush_t *selBrush = reinterpret_cast<brush_t*>(g_ptrSelectedFaceBrushes.GetAt(i));\n      Face_FitTexture(selFace, nHeight, nWidth);\n\t  \tBrush_Build(selBrush);\n    }\n\t}\n\n\tSys_UpdateWindows (W_CAMERA);\n}\n\nvoid Select_AxialTexture()\n{\n\n}\n\nvoid Select_Hide()\n{\n\tfor (brush_t* b=selected_brushes.next ; b && b != &selected_brushes ; b=b->next)\n\t{\n    b->hiddenBrush = true;\n\t}\n\tSys_UpdateWindows (W_ALL);\n}\n\nvoid Select_ShowAllHidden()\n{\n  brush_t* b;\n\tfor (b=selected_brushes.next ; b && b != &selected_brushes ; b=b->next)\n\t{\n    b->hiddenBrush = false;\n\t}\n\tfor (b=active_brushes.next ; b && b != &active_brushes ; b=b->next)\n\t{\n    b->hiddenBrush = false;\n\t}\n\tSys_UpdateWindows (W_ALL);\n}\n\n\n/*\n============\nSelect_Invert\n============\n*/\nvoid Select_Invert(void)\n{\n\tbrush_t *next, *prev;\n\n\tSys_Printf(\"inverting selection...\\n\");\n\n\tnext = active_brushes.next;\n\tprev = active_brushes.prev;\n\tif (selected_brushes.next != &selected_brushes)\n\t{\n\t\tactive_brushes.next = selected_brushes.next;\n\t\tactive_brushes.prev = selected_brushes.prev;\n\t\tactive_brushes.next->prev = &active_brushes;\n\t\tactive_brushes.prev->next = &active_brushes;\n\t}\n\telse\n\t{\n\t\tactive_brushes.next = &active_brushes;\n\t\tactive_brushes.prev = &active_brushes;\n\t}\n\tif (next != &active_brushes)\n\t{\n\t\tselected_brushes.next = next;\n\t\tselected_brushes.prev = prev;\n\t\tselected_brushes.next->prev = &selected_brushes;\n\t\tselected_brushes.prev->next = &selected_brushes;\n\t}\n\telse\n\t{\n\t\tselected_brushes.next = &selected_brushes;\n\t\tselected_brushes.prev = &selected_brushes;\n\t}\n\n\tSys_UpdateWindows(W_ALL);\n\n\tSys_Printf(\"done.\\n\");\n}\n\n\n/* \n===========\nSelect_Name\n===========\n*/\nvoid Select_Name(const char *pName)\n{\n\tif (g_qeglobals.m_bBrushPrimitMode)\n  {\n\t  for (brush_t* b=selected_brushes.next ; b && b != &selected_brushes ; b=b->next)\n\t  {\n      Brush_SetEpair(b, \"Name\", pName);\n\t  }\n  }\n}\n\n/* \n=================\nSelect_AddToGroup\nadd selected brushes to a group, update the tree\n=================\n*/\nvoid Select_AddToGroup(const char *pName)\n{\n\tif (g_qeglobals.m_bBrushPrimitMode)\n  {\n\t  for (brush_t* b=selected_brushes.next ; b && b != &selected_brushes ; b=b->next)\n\t  {\n      Brush_SetEpair(b, \"group\", pName);\n\t\t\tGroup_AddToProperGroup(b);\n\t  }\n  }\n}\n"
  },
  {
    "path": "q3radiant/SELECT.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\ntypedef enum\n{\n\tsel_brush,\n\t// sel_sticky_brush,\n\t// sel_face,\n\tsel_vertex,\n\tsel_edge,\n\tsel_singlevertex,\n\tsel_curvepoint,\n\tsel_area,\n\tsel_terrainpoint,\n\tsel_terraintexture,\n\tsel_addpoint,\t\t\t// for dropping points\n\tsel_editpoint\t\t\t// for editing points\n\n} select_t;\n\ntypedef struct\n{\n\tbrush_t\t\t*brush;\n\tface_t\t\t*face;\n\tterrainFace_t\t*terraface;\n\tfloat\t\tdist;\n\tqboolean\tselected;\n} trace_t;\n\n\n#define\tSF_SELECTED_ONLY\t 0x01\n#define\tSF_ENTITIES_FIRST\t 0x02\n#define\tSF_SINGLEFACE\t\t   0x04\n#define SF_IGNORECURVES    0x08\n#define SF_IGNOREGROUPS    0x10\n#define SF_CYCLE           0x20\n#define SF_CYCLEKEEP       0x40\n\n\ntrace_t Test_Ray (vec3_t origin, vec3_t dir, int flags);\n\nvoid Select_GetBounds (vec3_t mins, vec3_t maxs);\nvoid Select_Brush (brush_t *b, bool bComplete = true, bool bStatus = true);\nvoid Select_Ray (vec3_t origin, vec3_t dir, int flags);\nvoid Select_Delete (void);\nvoid Select_Deselect (bool bDeselectFaces = true);\nvoid Select_Invert(void);\nvoid Select_Clone (void);\nvoid Select_Move (vec3_t delta, bool bSnap = true);\nvoid WINAPI Select_SetTexture (texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale = false, void* pPlugTexdef = NULL);\nvoid Select_FlipAxis (int axis);\nvoid Select_RotateAxis (int axis, float deg, bool bPaint = true, bool bMouse = false);\nvoid Select_CompleteTall (void);\nvoid Select_PartialTall (void);\nvoid Select_Touching (void);\nvoid Select_Inside (void);\nvoid Select_MakeStructural (void);\nvoid Select_MakeDetail (void);\nvoid Select_AllOfType();\nvoid Select_Reselect();\nvoid Select_FitTexture(int nHeight = 1, int nWidth = 1);\n\n// absolute texture coordinates\n// TTimo NOTE: this is stuff for old brushes format and rotation texture lock .. sort of in-between with bush primitives\nvoid ComputeAbsolute(face_t* f, vec3_t& p1, vec3_t& p2, vec3_t& p3);\nvoid AbsoluteToLocal(plane_t normal2, face_t* f, vec3_t& p1, vec3_t& p2, vec3_t& p3);\nvoid Select_Hide();\nvoid Select_ShowAllHidden();\n// add selected brushes to a group, update the tree\nvoid Select_AddToGroup(const char *pName);\nvoid Select_Name(const char *pName);\nvoid clearSelection();\n"
  },
  {
    "path": "q3radiant/ScaleDialog.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// ScaleDialog.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"ScaleDialog.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CScaleDialog dialog\n\n\nCScaleDialog::CScaleDialog(CWnd* pParent /*=NULL*/)\n\t: CDialog(CScaleDialog::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CScaleDialog)\n\tm_fZ = 1.0f;\n\tm_fX = 1.0f;\n\tm_fY = 1.0f;\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CScaleDialog::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CScaleDialog)\n\tDDX_Text(pDX, IDC_EDIT_Z, m_fZ);\n\tDDX_Text(pDX, IDC_EDIT_X, m_fX);\n\tDDX_Text(pDX, IDC_EDIT_Y, m_fY);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CScaleDialog, CDialog)\n\t//{{AFX_MSG_MAP(CScaleDialog)\n\t\t// NOTE: the ClassWizard will add message map macros here\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CScaleDialog message handlers\n"
  },
  {
    "path": "q3radiant/ScaleDialog.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_SCALEDIALOG_H__8A9B33B2_9922_11D1_B568_00AA00A410FC__INCLUDED_)\n#define AFX_SCALEDIALOG_H__8A9B33B2_9922_11D1_B568_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// ScaleDialog.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CScaleDialog dialog\n\nclass CScaleDialog : public CDialog\n{\n// Construction\npublic:\n\tCScaleDialog(CWnd* pParent = NULL);   // standard constructor\n\n// Dialog Data\n\t//{{AFX_DATA(CScaleDialog)\n\tenum { IDD = IDD_DIALOG_SCALE };\n\tfloat\tm_fZ;\n\tfloat\tm_fX;\n\tfloat\tm_fY;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CScaleDialog)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CScaleDialog)\n\t\t// NOTE: the ClassWizard will add member functions here\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_SCALEDIALOG_H__8A9B33B2_9922_11D1_B568_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/ScriptDlg.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// ScriptDlg.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"ScriptDlg.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CScriptDlg dialog\n\n\nCScriptDlg::CScriptDlg(CWnd* pParent /*=NULL*/)\n\t: CDialog(CScriptDlg::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CScriptDlg)\n\tm_strScript = _T(\"\");\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CScriptDlg::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CScriptDlg)\n\tDDX_Control(pDX, IDC_LIST_SCRIPTS, m_lstScripts);\n\tDDX_LBString(pDX, IDC_LIST_SCRIPTS, m_strScript);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CScriptDlg, CDialog)\n\t//{{AFX_MSG_MAP(CScriptDlg)\n\tON_BN_CLICKED(ID_RUN, OnRun)\n\tON_LBN_DBLCLK(IDC_LIST_SCRIPTS, OnDblclkListScripts)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CScriptDlg message handlers\n\nvoid CScriptDlg::OnRun() \n{\n  UpdateData(TRUE);\n  EndDialog(IDOK);\n  RunScriptByName(m_strScript.GetBuffer(0), true);\n}\n\nBOOL CScriptDlg::OnInitDialog() \n{\n\tCDialog::OnInitDialog();\n\n  char* pBuff = new char[16384];\n  CString strINI = g_strAppPath;\n  strINI += \"\\\\scripts.ini\";\n  int n = GetPrivateProfileSectionNames(pBuff, 16384, strINI);\n\n  // CStringList list;\n  m_lstScripts.ResetContent();\n  char* pWorkBuff = pBuff;\n  while (*pWorkBuff != NULL)\n  {\n    m_lstScripts.AddString(pWorkBuff);\n    pWorkBuff += strlen(pWorkBuff) + 1;\n  }\n  delete []pBuff;\n\treturn TRUE;  // return TRUE unless you set the focus to a control\n\t              // EXCEPTION: OCX Property Pages should return FALSE\n}\n\n\nvoid CScriptDlg::OnDblclkListScripts() \n{\n  UpdateData(TRUE);\n  EndDialog(IDOK);\n  RunScriptByName(m_strScript.GetBuffer(0), true);\n}\n"
  },
  {
    "path": "q3radiant/ScriptDlg.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_SCRIPTDLG_H__C241B9A4_819F_11D1_B548_00AA00A410FC__INCLUDED_)\n#define AFX_SCRIPTDLG_H__C241B9A4_819F_11D1_B548_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// ScriptDlg.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CScriptDlg dialog\n\nclass CScriptDlg : public CDialog\n{\n// Construction\npublic:\n\tCScriptDlg(CWnd* pParent = NULL);   // standard constructor\n\n// Dialog Data\n\t//{{AFX_DATA(CScriptDlg)\n\tenum { IDD = IDD_DLG_SCRIPTS };\n\tCListBox\tm_lstScripts;\n\tCString\tm_strScript;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CScriptDlg)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CScriptDlg)\n\tafx_msg void OnRun();\n\tvirtual BOOL OnInitDialog();\n\tafx_msg void OnDblclkListScripts();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_SCRIPTDLG_H__C241B9A4_819F_11D1_B548_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/SelectedFace.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//-----------------------------------------------------------------------------\n//\n// $LogFile$\n// $Revision: 1.1.1.4 $\n// $Author: ttimo $\n// $Date: 2000/01/18 00:18:13 $\n// $Log: SelectedFace.cpp,v $\n// Revision 1.1.1.4  2000/01/18 00:18:13  ttimo\n// merging in for RC\n//\n// Revision 1.3  2000/01/17 23:53:43  TBesset\n// ready for merge in sourceforge (RC candidate)\n//\n// Revision 1.2  2000/01/07 16:40:12  TBesset\n// merged from BSP frontend\n//\n// Revision 1.1.1.3  1999/12/29 18:31:45  TBesset\n// Q3Radiant public version\n//\n// Revision 1.1.1.1.2.1  1999/12/29 21:39:41  TBesset\n// updated to update3 from Robert\n//\n// Revision 1.1.1.3  1999/12/29 18:31:45  TBesset\n// Q3Radiant public version\n//\n// Revision 1.2  1999/11/22 17:46:47  Timo & Christine\n// merged EARadiant into the main tree\n// bug fixes for Q3Plugin / EAPlugin\n// export for Robert\n//\n// Revision 1.1.4.2  1999/11/14 16:26:13  Timo & Christine\n// first beta of the ritualmap surface plugin\n//\n// Revision 1.1.4.1  1999/11/03 20:38:02  Timo & Christine\n// MEAN plugin for Q3Radiant, alpha version\n//\n// Revision 1.1.2.1  1999/10/27 08:34:28  Timo & Christine\n// preview version of the texture tools plugin is ready\n// ( TexTool.dll plugin is in Q3Plugin module )\n// plugins can draw in their own window using Radiant's qgl bindings\n//\n//\n// DESCRIPTION:\n// Quick interface hack for selected face interface\n// this one really needs more work, but I'm in a hurry with TexTool\n\n#include \"stdafx.h\"\n\nHGLRC WINAPI QERApp_GetQeglobalsHGLRC()\n{\n\treturn g_qeglobals.d_hglrcBase;\n}\n\n// pWinding is supposed to have MAX_POINTS_ON_WINDING\nint WINAPI QERApp_GetFaceInfo(_QERFaceData *pFaceData, winding_t *pWinding)\n{\n\tint size;\n\n\tif (g_ptrSelectedFaces.GetSize() > 0)\n\t{\n\t\tif (!g_qeglobals.m_bBrushPrimitMode)\n\t\t{\n\t\t\tSys_Printf(\"Warning: unexpected QERApp_GetFaceInfo out of brush primitive mode\\n\");\n\t\t\treturn 0;\n\t\t}\n\t\t//++timo NOTE: let's put only what we need for now\n    face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));\n\t\tstrcpy( pFaceData->m_TextureName, selFace->texdef.name );\n\t\tVectorCopy( selFace->planepts[0], pFaceData->m_v1 );\n\t\tVectorCopy( selFace->planepts[1], pFaceData->m_v2 );\n\t\tVectorCopy( selFace->planepts[2], pFaceData->m_v3 );\n\t\tpFaceData->m_bBPrimit = true;\n\t\tmemcpy( &pFaceData->brushprimit_texdef, &selFace->brushprimit_texdef, sizeof(brushprimit_texdef_t) );\n\t\tsize = (int)((winding_t *)0)->points[selFace->face_winding->numpoints];\n\t\tmemcpy( pWinding, selFace->face_winding, size );\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\nint WINAPI QERApp_SetFaceInfo(_QERFaceData *pFaceData)\n{\n\tif (g_ptrSelectedFaces.GetSize() > 0)\n\t{\n\t\tif (!g_qeglobals.m_bBrushPrimitMode)\n\t\t{\n\t\t\tSys_Printf(\"Warning: unexpected QERApp_SetFaceInfo out of brush primitive mode\\n\");\n\t\t\treturn 0;\n\t\t}\n    face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));\n    brush_t *selBrush = reinterpret_cast<brush_t*>(g_ptrSelectedFaceBrushes.GetAt(0));\n\t\t//strcpy( selected_face->texdef.name, pFaceData->m_TextureName );\n\t\tselFace->texdef.SetName(pFaceData->m_TextureName);\n\t\tVectorCopy( pFaceData->m_v1, selFace->planepts[0] );\n\t\tVectorCopy( pFaceData->m_v2, selFace->planepts[1] );\n\t\tVectorCopy( pFaceData->m_v3, selFace->planepts[2] );\n\t\tmemcpy( &selFace->brushprimit_texdef, &pFaceData->brushprimit_texdef, sizeof(brushprimit_texdef_t) );\n\t\tBrush_Build( selBrush );\n\t\tSys_UpdateWindows(W_ALL);\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\nvoid WINAPI QERApp_GetTextureSize( int Size[2] )\n{\n\tif (g_ptrSelectedFaces.GetSize() > 0)\n\t{\n    face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));\n\t\tSize[0] = selFace->d_texture->width;\n\t\tSize[1] = selFace->d_texture->height;\n\t}\n\telse\n\t\tSys_Printf(\"WARNING: unexpected call to QERApp_GetTextureSize with no selected_face\\n\");\n}"
  },
  {
    "path": "q3radiant/ShaderEdit.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// ShaderEdit.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"ShaderEdit.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CShaderEdit\n\nIMPLEMENT_DYNCREATE(CShaderEdit, CFrameWnd)\n\nCShaderEdit::CShaderEdit()\n{\n}\n\nCShaderEdit::~CShaderEdit()\n{\n}\n\n\nBEGIN_MESSAGE_MAP(CShaderEdit, CFrameWnd)\n\t//{{AFX_MSG_MAP(CShaderEdit)\n\tON_WM_CREATE()\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CShaderEdit message handlers\n\nint CShaderEdit::OnCreate(LPCREATESTRUCT lpCreateStruct) \n{\n\tif (CFrameWnd::OnCreate(lpCreateStruct) == -1)\n\t\treturn -1;\n\t\n\t// TODO: Add your specialized creation code here\n\t\n\treturn 0;\n}\n"
  },
  {
    "path": "q3radiant/ShaderEdit.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_SHADEREDIT_H__CFE2CBF1_E980_11D2_A509_0020AFEB881A__INCLUDED_)\n#define AFX_SHADEREDIT_H__CFE2CBF1_E980_11D2_A509_0020AFEB881A__INCLUDED_\n\n#if _MSC_VER > 1000\n#pragma once\n#endif // _MSC_VER > 1000\n// ShaderEdit.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CShaderEdit frame\n\nclass CShaderEdit : public CFrameWnd\n{\n\tDECLARE_DYNCREATE(CShaderEdit)\nprotected:\n\tCShaderEdit();           // protected constructor used by dynamic creation\n\n  CStatusBar  m_StatusBar;\n\tCToolBar    m_ToolBar;\n\n// Attributes\npublic:\n\n// Operations\npublic:\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CShaderEdit)\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\tvirtual ~CShaderEdit();\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CShaderEdit)\n\tafx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n/////////////////////////////////////////////////////////////////////////////\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Visual C++ will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_SHADEREDIT_H__CFE2CBF1_E980_11D2_A509_0020AFEB881A__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/ShaderInfo.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// ShaderInfo.cpp: implementation of the CShaderInfo class.\n//\n//////////////////////////////////////////////////////////////////////\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"ShaderInfo.h\"\n\n#ifdef _DEBUG\n#undef THIS_FILE\nstatic char THIS_FILE[]=__FILE__;\n#define new DEBUG_NEW\n#endif\n\n//////////////////////////////////////////////////////////////////////\n// Construction/Destruction\n//////////////////////////////////////////////////////////////////////\n\nCShaderInfo::CShaderInfo()\n{\n  m_fTransValue = 1.0;\n  m_nFlags = 0;\n  m_pQTexture = NULL;\n}\n\nCShaderInfo::~CShaderInfo()\n{\n\n}\n\nvoid CShaderInfo::Parse(const char *pName)\n{\n\n}\n\nvoid CShaderInfo::setName(char *pName)\n{\n  //--char path[1024];\n  //--strcpy(path, pName);\n  //--DefaultExtension(path, \".tga\");\n  m_strName = pName;\n  m_strName.MakeLower();\n  if (m_strName.Find(\"textures\") == 0)\n  {\n    CString s = m_strName.Right(m_strName.GetLength() - strlen(\"textures\") - 1);\n    m_strName = s;\n  }\n}\n"
  },
  {
    "path": "q3radiant/ShaderInfo.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// ShaderInfo.h: interface for the CShaderInfo class.\n//\n//////////////////////////////////////////////////////////////////////\n\n#if !defined(AFX_SHADERINFO_H__93B64600_A208_11D2_803D_0020AFEB881A__INCLUDED_)\n#define AFX_SHADERINFO_H__93B64600_A208_11D2_803D_0020AFEB881A__INCLUDED_\n\n#if _MSC_VER > 1000\n#pragma once\n#endif // _MSC_VER > 1000\n\nclass CShaderInfo  \n{\npublic:\n\tCString m_strName;\n\tCString m_strShaderName;\n\tCString m_strTextureName;\n\tCStringList m_strEditorParams;\n\tCStringList m_lstSurfaceParams;\n  float m_fTransValue;\n  int m_nFlags;\n  qtexture_t *m_pQTexture;\n\t\n  \n  void Parse(const char *pName);\n\tCShaderInfo();\n\tvirtual ~CShaderInfo();\n  void setName(char *pName);\n\n  \n\n};\n\n#endif // !defined(AFX_SHADERINFO_H__93B64600_A208_11D2_803D_0020AFEB881A__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/StdAfx.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// stdafx.cpp : source file that includes just the standard includes\n//\tRadiant.pch will be the pre-compiled header\n//\tstdafx.obj will contain the pre-compiled type information\n\n#include \"stdafx.h\"\n\n"
  },
  {
    "path": "q3radiant/StdAfx.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// stdafx.h : include file for standard system include files,\n//  or project specific include files that are used frequently, but\n//      are changed infrequently\n//\n\n#if !defined(AFX_STDAFX_H__330BBF08_731C_11D1_B539_00AA00A410FC__INCLUDED_)\n#define AFX_STDAFX_H__330BBF08_731C_11D1_B539_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n\n#pragma warning(disable: 4305)            // For: double to float\n#pragma warning(disable: 4800)            // For: performance warning on bool conversions\n\n#define VC_EXTRALEAN\t\t// Exclude rarely-used stuff from Windows headers\n\n#include <afxwin.h>         // MFC core and standard components\n#include <afxext.h>         // MFC extensions\n#include <afxdisp.h>        // MFC OLE automation classes\n#ifndef _AFX_NO_AFXCMN_SUPPORT\n#include <afxcmn.h>\t\t\t// MFC support for Windows Common Controls\n#endif // _AFX_NO_AFXCMN_SUPPORT\n\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_STDAFX_H__330BBF08_731C_11D1_B539_00AA00A410FC__INCLUDED_)\n\n#include \"MainFrm.h\"\n#include \"PrefsDlg.h\"\n#include \"FindTextureDlg.h\"\n\n\nextern CMainFrame* g_pParentWnd;\nextern CString g_strAppPath;\nextern CPrefsDlg& g_PrefsDlg;\nextern CFindTextureDlg& g_dlgFind;\n\n// layout styles\n#define QR_SPLIT 0\n#define QR_QE4 1\n#define QR_4WAY 2\n#define QR_SPLITZ 3\n\n\n// externs\nextern void AddSlash(CString&);\nextern void DLLBuildDone();\nextern void CleanUpEntities();\nextern void MFCCreate(HINSTANCE);\nextern BOOL Init3Dfx();\nextern void FindReplace(CString& strContents, const char* pTag, const char* pValue);\nextern void CheckBspProcess();\nextern void QE_CountBrushesAndUpdateStatusBar();\nextern void\tQE_CheckAutoSave();\nextern qtexture_t\t*notexture;\nextern qtexture_t\t*current_texture;\nextern BOOL SaveWindowState(HWND hWnd, const char *pszName);\nextern BOOL DoMru(HWND, WORD);\nextern void RunBsp (char *command);\nextern void Map_Snapshot();\nextern void WXY_Print();\nextern void AddProp( void );\nextern qboolean DoColor(int iIndex);\nextern entity_t\t*edit_entity;\nextern int inspector_mode;\nextern bool g_bRotateMode;\nextern bool g_bClipMode;\nextern bool g_bScaleMode;\nextern int g_nScaleHow;\nextern bool g_bPathMode;\nextern bool ByeByeSurfaceDialog();\nextern void RunScript(char* pBuffer);\nextern bool ExtractPath_and_Filename(const char* pPath, CString& strPath, CString& strFilename);\nextern HINSTANCE g_hOpenGL32;\nextern void Select_Scale(float x, float y, float z);\nextern void Select_RotateTexture(int amt);\nextern void Select_ScaleTexture(int x, int y);\nextern void Select_ShiftTexture(int x, int y);\nextern void FindReplaceTextures(const char* pFind, const char* pReplace, bool bSelected, bool bForce);\nextern void DoProjectSettings();\nextern qboolean region_active;\nextern void Brush_Print(brush_t* b);\nextern void\tTexture_ShowDirectory (char* pPath, bool Linked = false);\nextern void Map_ImportFile (char *filename);\nextern void Map_SaveSelected(char* pFilename);\nextern void UpdateSurfaceDialog();\nextern bool g_bNewFace;\nextern void Select_GetTrueMid (vec3_t mid);\nextern bool g_bSwitch;\nextern brush_t g_brFrontSplits;\nextern brush_t g_brBackSplits;\nextern CClipPoint g_Clip1;\nextern CClipPoint g_Clip2;\nextern brush_t* g_pSplitList;\nextern CClipPoint g_PathPoints[256];\nextern void AcquirePath(int nCount, PFNPathCallback* pFunc);\nextern bool g_bScreenUpdates;\nextern SCommandInfo g_Commands[];\nextern int g_nCommandCount;\nextern SKeyInfo g_Keys[];\nextern int g_nKeyCount;\nextern int inspector_mode;\nextern char\t*bsp_commands[256];\nextern void RunScriptByName(char*, bool);\nextern void DoNewColor(int* i1, int* i2, int* i3);\nextern void UpdateSurfaceDialog();\nextern void CSG_SplitBrushByFace (brush_t *in, face_t *f, brush_t **front, brush_t **back);\nextern void HandlePopup(CWnd* pWindow, unsigned int uId);\nextern z_t z;\nextern void Select_Scale(float x, float y, float z);\nextern CString g_strProject;\nextern void TextureAxisFromPlane(plane_t *pln, vec3_t xv, vec3_t yv);\nextern void VectorRotate (vec3_t va, vec3_t vb, vec3_t out);\nextern void VectorRotate (vec3_t vIn, vec3_t vRotation, vec3_t vOrigin, vec3_t out);\nextern qboolean QE_SaveProject (const char* pProjectFile);\nextern void NewBSP(char* pCommandLine, HWND);\nextern void NewVIS(char* pCommandLine, HWND);\nextern void NewRAD(char* pCommandLine, HWND);\nextern void RunTools(char* pCommandLine, HWND, const char*);\nextern void Clamp(float& f, int nClamp);\nextern void MemFile_fprintf(CMemFile* pMemFile, const char* pText, ...);\nextern void SaveWindowPlacement(HWND hwnd, const char* pName);\nextern bool LoadWindowPlacement(HWND hwnd, const char* pName);\nextern qboolean ConfirmModified (void);\nextern void DoPatchInspector();\nvoid UpdatePatchInspector();\nextern int BuildShortPathName(const char* pPath, char* pBuffer, int nBufferLen);\nextern int g_nBrushId;\n\n\n"
  },
  {
    "path": "q3radiant/SurfaceDlg.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// SurfaceDlg.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"SurfaceDlg.h\"\n#include \"PrefsDlg.h\"\n#include \"mainfrm.h\"\n#include \"TextureLayout.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// surface properties plugin\n// global flag for surface properties plugin is g_qeglobals.bSurfacePropertiesPlugin\n_QERPlugSurfaceTable g_SurfaceTable;\n\n/////////////////////////////////////////////////////////////////////////////\n// CSurfaceDlg dialog\n\nCSurfaceDlg g_dlgSurface;\n\n\nCSurfaceDlg::CSurfaceDlg(CWnd* pParent /*=NULL*/)\n\t: CDialog(CSurfaceDlg::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CSurfaceDlg)\n\tm_nHeight = 1;\n\tm_nWidth = 1;\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CSurfaceDlg::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CSurfaceDlg)\n\tDDX_Control(pDX, IDC_SPIN_WIDTH, m_wndWidth);\n\tDDX_Control(pDX, IDC_SPIN_HEIGHT, m_wndHeight);\n\tDDX_Control(pDX, IDC_SPIN_VSHIFT, m_wndVShift);\n\tDDX_Control(pDX, IDC_SPIN_VSCALE, m_wndVScale);\n\tDDX_Control(pDX, IDC_SPIN_ROTATE, m_wndRotate);\n\tDDX_Control(pDX, IDC_SPIN_HSHIFT, m_wndHShift);\n\tDDX_Control(pDX, IDC_SPIN_HSCALE, m_wndHScale);\n\tDDX_Text(pDX, IDC_EDIT_HEIGHT, m_nHeight);\n\tDDV_MinMaxInt(pDX, m_nHeight, 1, 32);\n\tDDX_Text(pDX, IDC_EDIT_WIDTH, m_nWidth);\n\tDDV_MinMaxInt(pDX, m_nWidth, 1, 32);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CSurfaceDlg, CDialog)\n\t//{{AFX_MSG_MAP(CSurfaceDlg)\n\tON_WM_HSCROLL()\n\tON_WM_KEYDOWN()\n\tON_WM_VSCROLL()\n\tON_BN_CLICKED(IDAPPLY, OnApply)\n\tON_WM_CLOSE()\n\tON_WM_DESTROY()\n\tON_BN_CLICKED(ID_BTN_CANCEL, OnBtnCancel)\n\tON_BN_CLICKED(IDC_BTN_COLOR, OnBtnColor)\n\tON_WM_CTLCOLOR()\n\tON_WM_CREATE()\n\tON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSHIFT, OnDeltaPosSpin)\n\tON_BN_CLICKED(IDC_BTN_PATCHDETAILS, OnBtnPatchdetails)\n\tON_BN_CLICKED(IDC_BTN_PATCHNATURAL, OnBtnPatchnatural)\n\tON_BN_CLICKED(IDC_BTN_PATCHRESET, OnBtnPatchreset)\n\tON_BN_CLICKED(IDC_BTN_PATCHFIT, OnBtnPatchfit)\n\tON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSCALE, OnDeltaPosSpin)\n\tON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ROTATE, OnDeltaPosSpin)\n\tON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSCALE, OnDeltaPosSpin)\n\tON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSHIFT, OnDeltaPosSpin)\n\tON_BN_CLICKED(IDC_BTN_AXIAL, OnBtnAxial)\n\tON_BN_CLICKED(IDC_BTN_BRUSHFIT, OnBtnBrushfit)\n\tON_BN_CLICKED(IDC_BTN_FACEFIT, OnBtnFacefit)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CSurfaceDlg message handlers\n\n\n/*\n===================================================\n\n  SURFACE INSPECTOR\n\n===================================================\n*/\n\ntexdef_t\tg_old_texdef;\ntexdef_t\tg_patch_texdef;\nHWND\t\tg_surfwin = NULL;\nqboolean\tg_changed_surface;\n\nint\tg_checkboxes[64] = { \n\tIDC_CHECK1, IDC_CHECK2, IDC_CHECK3, IDC_CHECK4, \n\tIDC_CHECK5, IDC_CHECK6, IDC_CHECK7, IDC_CHECK8, \n\tIDC_CHECK9, IDC_CHECK10, IDC_CHECK11, IDC_CHECK12, \n\tIDC_CHECK13, IDC_CHECK14, IDC_CHECK15, IDC_CHECK16,\n\tIDC_CHECK17, IDC_CHECK18, IDC_CHECK19, IDC_CHECK20,\n\tIDC_CHECK21, IDC_CHECK22, IDC_CHECK23, IDC_CHECK24,\n\tIDC_CHECK25, IDC_CHECK26, IDC_CHECK27, IDC_CHECK28,\n\tIDC_CHECK29, IDC_CHECK30, IDC_CHECK31, IDC_CHECK32,\n\n\tIDC_CHECK33, IDC_CHECK34, IDC_CHECK35, IDC_CHECK36,\n\tIDC_CHECK37, IDC_CHECK38, IDC_CHECK39, IDC_CHECK40,\n\tIDC_CHECK41, IDC_CHECK42, IDC_CHECK43, IDC_CHECK44,\n\tIDC_CHECK45, IDC_CHECK46, IDC_CHECK47, IDC_CHECK48,\n\tIDC_CHECK49, IDC_CHECK50, IDC_CHECK51, IDC_CHECK52,\n\tIDC_CHECK53, IDC_CHECK54, IDC_CHECK55, IDC_CHECK56,\n\tIDC_CHECK57, IDC_CHECK58, IDC_CHECK59, IDC_CHECK60,\n\tIDC_CHECK61, IDC_CHECK62, IDC_CHECK63, IDC_CHECK64\n };\n\n/*\n==============\nSetTexMods\n\nSet the fields to the current texdef\nif one face selected -> will read this face texdef, else current texdef\nif only patches selected, will read the patch texdef\n===============\n*/\n\nbool g_bNewFace = false;\nbool g_bNewApplyHandling = false;\nbool g_bGatewayhack = false;\n\nvoid CSurfaceDlg::SetTexMods()\n{\n\tchar\tsz[128];\n\ttexdef_t *pt;\n\tbrushprimit_texdef_t\t*bpt;\n\t// local copy if a width=2 height=2 qtetxture_t is needed\n\tbrushprimit_texdef_t\tlocal_bp;\n\tint\t\ti;\n\n\tif (!g_surfwin)\n\t\treturn;\n\n\tm_bPatchMode = false;\n\n\tif (OnlyPatchesSelected())\n\t{\n\t\tpt = &g_qeglobals.d_texturewin.texdef;\n\t\tif (QE_SingleBrush())\n    {\n\t\t\t//strcpy(g_patch_texdef.name, Patch_GetTextureName());\n\t\t\tg_patch_texdef.SetName(Patch_GetTextureName());\n    }\n\t\telse\n    {\n\t\t\t//strcpy(g_patch_texdef.name, pt->name);\n\t\t\tg_patch_texdef.SetName(pt->name);\n    }\n\t\tg_patch_texdef.contents = pt->contents;\n\t\tg_patch_texdef.flags = pt->flags;\n\t\tg_patch_texdef.value = pt->value;\n\t\tpt = &g_patch_texdef;\n\t\tm_bPatchMode = true;\n\t}\n\telse\n\t{\n\t\tif (g_bNewFace && g_ptrSelectedFaces.GetSize() > 0)\n\t\t{\n      face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));\n\t\t\tpt = &selFace->texdef;\n\t\t\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\t\t{\n\t\t\t\t// compute a texture matrix related to the default matrix width=2 height=2\n\t\t\t\tConvertTexMatWithQTexture( &selFace->brushprimit_texdef, selFace->d_texture, &local_bp, NULL );\n\t\t\t\tbpt = &local_bp;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tpt = &g_qeglobals.d_texturewin.texdef;\n\t\t\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\t\t{\n\t\t\t\tbpt = &g_qeglobals.d_texturewin.brushprimit_texdef;\n\t\t\t}\n\t\t}\n\t\t// brush primitive mode : compute fake shift scale rot representation\n\t\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\t\tTexMatToFakeTexCoords( bpt->coords, m_shift, &m_rotate, m_scale );\n\t}\n\n\tSendMessage (WM_SETREDRAW, 0, 0);\n\n\t::SetWindowText(GetDlgItem(IDC_TEXTURE)->GetSafeHwnd(), pt->name);\n\n\tif (m_bPatchMode)\n\t\tsprintf(sz, \"%4.6f\", pt->shift[0]);\n\telse\n\t\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\t\tsprintf(sz, \"%d\", (int)m_shift[0]);\n\t\telse\n\t\t\tsprintf(sz, \"%d\", (int)pt->shift[0]);\n\t::SetWindowText(GetDlgItem(IDC_HSHIFT)->GetSafeHwnd(), sz);\n\n\tif (m_bPatchMode)\n\t\tsprintf(sz, \"%4.6f\", pt->shift[1]);\n\telse\n\t\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\t\tsprintf(sz, \"%d\", (int)m_shift[1]);\n\t\telse\n\t\t\tsprintf(sz, \"%d\", (int)pt->shift[1]);\n\t::SetWindowText(GetDlgItem(IDC_VSHIFT)->GetSafeHwnd(), sz);\n\n\tsprintf(sz, m_bPatchMode ? \"%4.6f\" : \"%4.6f\", g_qeglobals.m_bBrushPrimitMode ? m_scale[0] : pt->scale[0]);\n\t::SetWindowText(GetDlgItem(IDC_HSCALE)->GetSafeHwnd(), sz);\n\n\tsprintf(sz, m_bPatchMode ? \"%4.6f\" : \"%4.6f\", g_qeglobals.m_bBrushPrimitMode ? m_scale[1] : pt->scale[1]);\n\t::SetWindowText(GetDlgItem(IDC_VSCALE)->GetSafeHwnd(), sz);\n\n\t//++timo compute BProtate as int ..\n\tsprintf(sz, \"%d\", g_qeglobals.m_bBrushPrimitMode ? (int)m_rotate : (int)pt->rotate);\n\t::SetWindowText(GetDlgItem(IDC_ROTATE)->GetSafeHwnd(), sz);\n\n\tsprintf(sz, \"%d\", (int)pt->value);\n\t::SetWindowText(GetDlgItem(IDC_VALUE)->GetSafeHwnd(), sz);\n\n\tfor (i=0 ; i<32 ; i++)\n\t\t::SendMessage(GetDlgItem(g_checkboxes[i])->GetSafeHwnd(), BM_SETCHECK, !!(pt->flags&(1<<i)), 0 );\n\tfor (i=0 ; i<32 ; i++)\n\t\t::SendMessage(GetDlgItem(g_checkboxes[32+i])->GetSafeHwnd(), BM_SETCHECK, !!(pt->contents&(1<<i)), 0 );\n\n\tSendMessage (WM_SETREDRAW, 1, 0);\n\tInvalidateRect (NULL, true);\n}\n\nvoid CSurfaceDlg::GrabPatchMods()\n{\n\tchar\tsz[128];\n\tint i;\n\tbool b;\n\ttexdef_t *pt = & g_patch_texdef;\n\n  ::GetWindowText (GetDlgItem(IDC_HSHIFT)->GetSafeHwnd(), sz, 127);\n\tpt->shift[0] = atof(sz);\n\n  ::GetWindowText (GetDlgItem(IDC_VSHIFT)->GetSafeHwnd(), sz, 127);\n\tpt->shift[1] = atof(sz);\n\n  ::GetWindowText(GetDlgItem(IDC_HSCALE)->GetSafeHwnd(), sz, 127);\n\tpt->scale[0] = atof(sz);\n\n  ::GetWindowText(GetDlgItem(IDC_VSCALE)->GetSafeHwnd(), sz, 127);\n\tpt->scale[1] = atof(sz);\n\n  ::GetWindowText(GetDlgItem(IDC_ROTATE)->GetSafeHwnd(), sz, 127);\n\tpt->rotate = atof(sz);\n\n  ::GetWindowText(GetDlgItem(IDC_VALUE)->GetSafeHwnd(), sz, 127);\n\tpt->value = atof(sz);\n\n\tpt->flags = 0;\n\tfor (i=0 ; i<32 ; i++)\n\t{\n    b = ::SendMessage(GetDlgItem(g_checkboxes[i])->GetSafeHwnd(), BM_GETCHECK, 0, 0);\n\t\tif (b != 1 && b != 0)\n\t\t\tcontinue;\n\t\tpt->flags |= b<<i;\n\t}\n\n\tpt->contents = 0;\n\tfor (i=0 ; i<32 ; i++)\n\t{\n    b = ::SendMessage(GetDlgItem(g_checkboxes[32+i])->GetSafeHwnd(), BM_GETCHECK, 0, 0);\n\t\tif (b != 1 && b != 0)\n\t\t\tcontinue;\n\t\tpt->contents |= b<<i;\n\t}\n\n}\n\n/*\n==============\nGetTexMods\n\nReads the fields to get the current texdef\nin brush primitive mode, grab the fake shift scale rot and compute a new texture matrix\n===============\n*/\nvoid CSurfaceDlg::GetTexMods()\n{\n\tchar\tsz[128];\n\ttexdef_t *pt;\n\tint\t\tb;\n\tint\t\ti;\n\n\tm_bPatchMode = false;\n\n\tif (OnlyPatchesSelected())\n\t{\n\t\tpt = &g_qeglobals.d_texturewin.texdef;\n\t\tm_bPatchMode = true;\n\t}\n\telse\n\t{\n\t\tif (g_bNewFace && g_ptrSelectedFaces.GetSize() > 0)\n    {\n      face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));\n\t\t\tpt = &selFace->texdef;\n    }\n\t\telse\n    {\n\t\t\tpt = &g_qeglobals.d_texturewin.texdef;\n    }\n\t}\n\n\t::GetWindowText (GetDlgItem(IDC_TEXTURE)->GetSafeHwnd(), sz, 127);\n\t//strncpy (pt->name, sz, sizeof(pt->name)-1);\n\tpt->SetName(sz);\n\tif (pt->name[0] <= ' ')\n\t{\n\t\t//strcpy (pt->name, \"none\");\n\t\tpt->SetName(\"none\");\n\t\t::SetWindowText(GetDlgItem(IDC_TEXTURE)->GetSafeHwnd(), pt->name);\n\t}\n\n\t::GetWindowText (GetDlgItem(IDC_HSHIFT)->GetSafeHwnd(), sz, 127);\n\t( g_qeglobals.m_bBrushPrimitMode ? m_shift[0] : pt->shift[0] ) = atof(sz);\n\n\t::GetWindowText (GetDlgItem(IDC_VSHIFT)->GetSafeHwnd(), sz, 127);\n\t( g_qeglobals.m_bBrushPrimitMode ? m_shift[1] : pt->shift[1] ) = atof(sz);\n\n\t::GetWindowText(GetDlgItem(IDC_HSCALE)->GetSafeHwnd(), sz, 127);\n\t( g_qeglobals.m_bBrushPrimitMode ? m_scale[0] : pt->scale[0] ) = atof(sz);\n\n\t::GetWindowText(GetDlgItem(IDC_VSCALE)->GetSafeHwnd(), sz, 127);\n\t( g_qeglobals.m_bBrushPrimitMode ? m_scale[1] : pt->scale[1] ) = atof(sz);\n\n\t::GetWindowText(GetDlgItem(IDC_ROTATE)->GetSafeHwnd(), sz, 127);\n\t( g_qeglobals.m_bBrushPrimitMode ? m_rotate : pt->rotate ) = atof(sz);\n\n\t::GetWindowText(GetDlgItem(IDC_VALUE)->GetSafeHwnd(), sz, 127);\n\tpt->value = atof(sz);\n\n\tpt->flags = 0;\n\tfor (i=0 ; i<32 ; i++)\n\t{\n\t\tb = ::SendMessage(GetDlgItem(g_checkboxes[i])->GetSafeHwnd(), BM_GETCHECK, 0, 0);\n\t\tif (b != 1 && b != 0)\n\t\t\tcontinue;\n\t\tpt->flags |= b<<i;\n\t}\n\n\tpt->contents = 0;\n\tfor (i=0 ; i<32 ; i++)\n\t{\n\t\tb = ::SendMessage(GetDlgItem(g_checkboxes[32+i])->GetSafeHwnd(), BM_GETCHECK, 0, 0);\n\t\tif (b != 1 && b != 0)\n\t\t\tcontinue;\n\t\tpt->contents |= b<<i;\n\t}\n\n\tg_changed_surface = true;\n\n\t// a local copy of the texture matrix, given for a qtexture_t with width=2 height=2\n\tbrushprimit_texdef_t\tlocal_bp;\n\tbrushprimit_texdef_t\t*bpt;\n\tif (g_qeglobals.m_bBrushPrimitMode)\n\t{\n    face_t *selFace = NULL;\n\t\tif (g_bNewFace && g_ptrSelectedFaces.GetSize() > 0)\n    {\n      selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));\n\t\t\tbpt = &selFace->brushprimit_texdef;\n    }\n\t\telse\n    {\n\t\t\tbpt = &g_qeglobals.d_texturewin.brushprimit_texdef;\n    }\n\t\t// compute texture matrix\n\t\t// the matrix returned must be understood as a qtexture_t with width=2 height=2\n\t\tFakeTexCoordsToTexMat( m_shift, m_rotate, m_scale, local_bp.coords );\n\t\t// copy the texture matrix in the global struct\n\t\t// fit the qtexture if we have a face selected, otherwise g_qeglobals.d_texturewin.brushprimit_texdef uses the basic qtexture_t with width=2 height=2\n\n\t\tConvertTexMatWithQTexture( &local_bp, NULL, bpt, ( ( g_bNewFace && selFace ) ? selFace->d_texture : NULL ) );\n\t}\n\tSelect_SetTexture(pt,&local_bp);\n\n  //if (m_bPatchMode)\n  //{\n  //  Patch_SetTextureInfo(pt);\n  //}\n\n}\n\n/*\n=================\nUpdateSpinners\n=================\n*/\n\nvoid CSurfaceDlg::UpdateSpinners(bool bUp, int nID)\n{\n\ttexdef_t *pt;\n  texdef_t td;\n\n  if (m_bPatchMode)\n  {\n    td.rotate = 0.0;\n    td.scale[0] = td.scale[1] = 0.0;\n    td.shift[0] = td.shift[1] = 0.0;\n    GrabPatchMods();\n\n    pt = &g_patch_texdef;\n    td.contents = pt->contents;\n    td.flags = pt->flags;\n    td.value = pt->value;\n\n    if (nID == IDC_SPIN_ROTATE)\n\t  {\n\t\t  if (bUp)\n\t\t\t  td.rotate = pt->rotate;\n\t\t  else\n\t\t\t  td.rotate = -pt->rotate;\n\t  }\n    else if (nID == IDC_SPIN_HSCALE)\n\t  {\n\t\t  if (bUp)\n\t\t\t  td.scale[0] = 1-pt->scale[0];\n\t\t  else\n\t\t\t  td.scale[0] = 1+pt->scale[0];\n\t  }\n    else if (nID == IDC_SPIN_VSCALE)\n\t  {\n\t\t  if (bUp)\n\t\t\t  td.scale[1] = 1-pt->scale[1];\n\t\t  else\n\t\t\t  td.scale[1] = 1+pt->scale[1];\n\t  } \n\t  \n    else if (nID == IDC_SPIN_HSHIFT)\n\t  {\n\t\t  if (bUp)\n\t\t\t  td.shift[0] = pt->shift[0];\n\t\t  else\n\t\t\t  td.shift[0] = -pt->shift[0];\n\t  }\n    else if (nID == IDC_SPIN_VSHIFT)\n\t  {\n\t\t  if (bUp)\n\t\t\t  td.shift[1] = pt->shift[1];\n\t\t  else\n\t\t\t  td.shift[1] = -pt->shift[1];\n\t  }\n    pt = &g_qeglobals.d_texturewin.texdef;\n    Patch_SetTextureInfo(&td);\n  }\n\telse\n\t{\n\t\t// in brush primitive mode, will read up-to-date m_shift m_rotate m_scale\n\t\tGetTexMods ();\n\t\tif (g_bNewFace && g_ptrSelectedFaces.GetSize() > 0)\n    {\n      face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));\n\t\t\tpt = &selFace->texdef;\n    }\n\t\telse\n    {\n\t\t\tpt = &g_qeglobals.d_texturewin.texdef;\n    }\n\t\tif (nID == IDC_SPIN_ROTATE)\n\t\t{\n\t\t\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\t\t{\n\t\t\t\tif (bUp)\n\t\t\t\t\tm_rotate += 45;\n\t\t\t\telse\n\t\t\t\t\tm_rotate -= 45;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (bUp)\n\t\t\t\t\tpt->rotate += 45;\n\t\t\t\telse\n\t\t\t\t\tpt->rotate -= 45;\n\t\t\t\tif (pt->rotate < 0)\n\t\t\t\t\tpt->rotate += 360;\n\t\t\t\tif (pt->rotate >= 360)\n\t\t\t\t\tpt->rotate -= 360;\n\t\t\t}\n\t\t}\n\t\telse if (nID == IDC_SPIN_HSCALE)\n\t\t{\n\t\t\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\t\t{\n\t\t\t\tif (bUp)\n\t\t\t\t\tm_scale[0] += 0.1;\n\t\t\t\telse\n\t\t\t\t\tm_scale[0] -= 0.1;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (bUp)\n\t\t\t\t\tpt->scale[0] += 0.1;\n\t\t\t\telse\n\t\t\t\t\tpt->scale[0] -= 0.1;\n\t\t\t}\n\t\t}\n\t\telse if (nID == IDC_SPIN_VSCALE)\n\t\t{\n\t\t\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\t\t{\n\t\t\t\tif (bUp)\n\t\t\t\t\tm_scale[1] += 0.1;\n\t\t\t\telse\n\t\t\t\t\tm_scale[1] -= 0.1;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (bUp)\n\t\t\t\t\tpt->scale[1] += 0.1;\n\t\t\t\telse\n\t\t\t\t\tpt->scale[1] -= 0.1;\n\t\t\t}\n\t\t}\n\t\telse if (nID == IDC_SPIN_HSHIFT)\n\t\t{\n\t\t\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\t\t{\n\t\t\t\tif (bUp)\n\t\t\t\t\tm_shift[0] += 8;\n\t\t\t\telse\n\t\t\t\t\tm_shift[0] -= 8;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (bUp)\n\t\t\t\t\tpt->shift[0] += 8;\n\t\t\t\telse\n\t\t\t\t\tpt->shift[0] -= 8;\n\t\t\t}\n\t\t}\n\t\telse if (nID == IDC_SPIN_VSHIFT)\n\t\t{\n\t\t\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\t\t{\n\t\t\t\tif (bUp)\n\t\t\t\t\tm_shift[1] += 8;\n\t\t\t\telse\n\t\t\t\t\tm_shift[1] -= 8;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (bUp)\n\t\t\t\t\tpt->shift[1] += 8;\n\t\t\t\telse\n\t\t\t\t\tpt->shift[1] -= 8;\n\t\t\t}\n\t\t}\n\t}\n\t// a local copy of the texture matrix, given for a qtexture_t with width=2 height=2\n\tbrushprimit_texdef_t\tlocal_bp;\n\tbrushprimit_texdef_t\t*bpt;\n\tif (g_qeglobals.m_bBrushPrimitMode)\n\t{\n    face_t *selFace = NULL;\n\t\tif (g_bNewFace && g_ptrSelectedFaces.GetSize() > 0)\n    {\n      selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));\n\t\t\tbpt = &selFace->brushprimit_texdef;\n    }\n\t\telse\n    {\n\t\t\tbpt = &g_qeglobals.d_texturewin.brushprimit_texdef;\n    }\n\t\t// compute texture matrix\n\t\t// the matrix returned must be understood as a qtexture_t with width=2 height=2\n\t\tFakeTexCoordsToTexMat( m_shift, m_rotate, m_scale, local_bp.coords );\n\t\t// copy the texture matrix in the global struct\n\t\t// fit the qtexture if we have a face selected, otherwise g_qeglobals.d_texturewin.brushprimit_texdef uses the basic qtexture_t with width=2 height=2\n\t\tConvertTexMatWithQTexture( &local_bp, NULL, bpt, ( ( g_bNewFace && selFace ) ? selFace->d_texture : NULL ) );\n\t}\n\t// brush primit : will update the widgets after reading back texture matrix and computing fake shift scale rot\n\tSetTexMods();\n\tg_changed_surface = true;\n\tSelect_SetTexture(pt,&local_bp);\n}\n\nvoid CSurfaceDlg::UpdateSpinners(int nScrollCode, int nPos, CScrollBar* pBar)\n{\n\ttexdef_t *pt;\n\n\tGetTexMods ();\n  if (g_bNewFace && g_ptrSelectedFaces.GetSize() > 0)\n  {\n    face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));\n\t\tpt = &selFace->texdef;\n  }\n  else\n  {\n\t  pt = &g_qeglobals.d_texturewin.texdef;\n  }\n\n\tif ((nScrollCode != SB_LINEUP) && (nScrollCode != SB_LINEDOWN))\n\t\treturn;\n\t\n  if (pBar->GetSafeHwnd() == ::GetDlgItem(GetSafeHwnd(), IDC_ROTATEA))\n\t{\n\t\tif (nScrollCode == SB_LINEUP)\n\t\t\tpt->rotate += 45;\n\t\telse\n\t\t\tpt->rotate -= 45;\n\n\t\tif (pt->rotate < 0)\n\t\t\tpt->rotate += 360;\n\n\t\tif (pt->rotate >= 360)\n\t\t\tpt->rotate -= 360;\n\t}\n\n  else if (pBar->GetSafeHwnd() == ::GetDlgItem(GetSafeHwnd(), IDC_HSCALEA))\n\t{\n\t\tif (nScrollCode == SB_LINEDOWN)\n\t\t\tpt->scale[0] -= 0.1;\n\t\telse\n\t\t\tpt->scale[0] += 0.1;\n\t}\n\t\n  else if (pBar->GetSafeHwnd() == ::GetDlgItem(GetSafeHwnd(), IDC_VSCALEA))\n\t{\n\t\tif (nScrollCode == SB_LINEUP)\n\t\t\tpt->scale[1] += 0.1;\n\t\telse\n\t\t\tpt->scale[1] -= 0.1;\n\t} \n\t\n  else if (pBar->GetSafeHwnd() == ::GetDlgItem(GetSafeHwnd(), IDC_HSHIFTA))\n\t{\n\t\tif (nScrollCode == SB_LINEDOWN)\n\t\t\tpt->shift[0] -= 8;\n\t\telse\n\t\t\tpt->shift[0] += 8;\n\t}\n\t\n  else if (pBar->GetSafeHwnd() == ::GetDlgItem(GetSafeHwnd(), IDC_VSHIFTA))\n\t{\n\t\tif (nScrollCode == SB_LINEUP)\n\t\t\tpt->shift[1] += 8;\n\t\telse\n\t\t\tpt->shift[1] -= 8;\n\t}\n\n\tSetTexMods();\n\tg_changed_surface = true;\n\t//++timo if !g_qeglobals.m_bBrushPrimitMode send a NULL brushprimit_texdef\n\tif (!g_qeglobals.m_bBrushPrimitMode)\n\t{\n\t\tSys_Printf(\"Warning : non brush primitive mode call to CSurfaceDlg::GetTexMods broken\\n\");\n\t\tSys_Printf(\"          ( Select_SetTexture not called )\\n\");\n\t}\n//\tSelect_SetTexture(pt);\n}\n\nvoid UpdateSurfaceDialog()\n{\n\tif (g_qeglobals.bSurfacePropertiesPlugin)\n\t{\n\t\tg_SurfaceTable.m_pfnUpdateSurfaceDialog();\n\t}\n\telse\n\t{\n\t\tif (g_surfwin)\n\t\t\tg_dlgSurface.SetTexMods();\n\t}\n\tg_pParentWnd->UpdateTextureBar();\n}\n\nbool ByeByeSurfaceDialog();\n\nvoid DoSurface (void)\n{\n\t// surface properties plugin ?\n\tif (g_qeglobals.bSurfacePropertiesPlugin)\n\t{\n\t\tg_SurfaceTable.m_pfnDoSurface();\n\t\treturn;\n\t}\n\n  g_bNewFace = g_PrefsDlg.m_bFace;\n  g_bNewApplyHandling = g_PrefsDlg.m_bNewApplyHandling;\n  g_bGatewayhack = g_PrefsDlg.m_bGatewayHack;\n\t// save current state for cancel\n\tg_old_texdef = g_qeglobals.d_texturewin.texdef;\n\tg_changed_surface = false;\n\n  if (g_surfwin == NULL && g_dlgSurface.GetSafeHwnd() == NULL)\n  {\n    g_patch_texdef.scale[0] = 0.05;\n    g_patch_texdef.scale[1] = 0.05;\n    g_patch_texdef.shift[0] = 0.05;\n    g_patch_texdef.shift[1] = 0.05;\n\t// use rotation increment from preferences\n    g_patch_texdef.rotate = g_PrefsDlg.m_nRotation;\n\n    g_dlgSurface.Create(IDD_SURFACE);\n    CRect rct;\n\t  LONG lSize = sizeof(rct);\n\t  if (LoadRegistryInfo(\"Radiant::SurfaceWindow\", &rct, &lSize))\n      g_dlgSurface.SetWindowPos(NULL, rct.left, rct.top, 0,0, SWP_NOSIZE | SWP_SHOWWINDOW);\n\n    Sys_UpdateWindows(W_ALL);\n  }\n  else\n  {\n    g_surfwin = g_dlgSurface.GetSafeHwnd();\n\t  g_dlgSurface.SetTexMods ();\n    g_dlgSurface.ShowWindow(SW_SHOW);\n  }\n}\t\t\n\nbool ByeByeSurfaceDialog()\n{\n\t// surface properties plugin ?\n\tif (g_qeglobals.bSurfacePropertiesPlugin)\n\t{\n\t\treturn g_SurfaceTable.m_pfnByeByeSurfaceDialog();\n\t}\n\n  if (g_surfwin)\n  {\n    if (g_bGatewayhack)\n      PostMessage(g_surfwin, WM_COMMAND, IDAPPLY, 0);\n    else\n      PostMessage(g_surfwin, WM_COMMAND, IDCANCEL, 0);\n    return true;\n  }\n  else return false;\n}\n\nBOOL CSurfaceDlg::OnInitDialog() \n{\n\tCDialog::OnInitDialog();\n\t\n  g_surfwin = GetSafeHwnd();\n\tSetTexMods ();\n\n#ifdef QUAKE3\n  GetDlgItem(IDC_CHECK32)->SetWindowText(\"Curve\");\n  GetDlgItem(IDC_CHECK64)->SetWindowText(\"Inverted\");\n#endif\n\n  m_wndHScale.SetRange(0, 1000);\n  m_wndVScale.SetRange(0, 1000);\n  m_wndHShift.SetRange(0, 1000);\n  m_wndVShift.SetRange(0, 1000);\n  m_wndRotate.SetRange(0, 1000);\n  m_wndWidth.SetRange(1, 32);\n  m_wndHeight.SetRange(1, 32);\n\n  LPVOID lpv = g_pParentWnd->GetPlugInMgr().GetSurfaceFlags();\n  if (lpv != NULL)\n  {\n    int i = 0;\n    char* p = reinterpret_cast<char*>(lpv);\n    char* pBuff = new char[strlen(p)+1];\n    strcpy(pBuff, p);\n    char* pToken = strtok(pBuff, \";\\0\");\n    while (pToken != NULL)\n    {\n      GetDlgItem(g_checkboxes[i++])->SetWindowText(pToken);\n      pToken = strtok(NULL, \";\\0\");\n    }\n  }\n\n  if (strstr(g_PrefsDlg.m_strWhatGame, \"Quake3\") != NULL) {\n    for (int i=0 ; i < 64 ; i++) {\n      ::EnableWindow(GetDlgItem(g_checkboxes[i])->GetSafeHwnd(), FALSE);\n    }\n\n  }\n\n\treturn TRUE;  // return TRUE unless you set the focus to a control\n\t              // EXCEPTION: OCX Property Pages should return FALSE\n}\n\nvoid CSurfaceDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) \n{\n\tCDialog::OnHScroll(nSBCode, nPos, pScrollBar);\n\tUpdateSpinners(nSBCode, nPos, pScrollBar);\n  Sys_UpdateWindows(W_CAMERA);\n}\n\nvoid CSurfaceDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) \n{\n\t\n\tCDialog::OnKeyDown(nChar, nRepCnt, nFlags);\n}\n\nvoid CSurfaceDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) \n{\n\tCDialog::OnVScroll(nSBCode, nPos, pScrollBar);\n\tUpdateSpinners(nSBCode, nPos, pScrollBar);\n\tSys_UpdateWindows(W_CAMERA);\n}\n\nvoid CSurfaceDlg::OnApply() \n{\n\tGetTexMods ();\n  Sys_UpdateWindows(W_CAMERA);\n  if (g_bNewApplyHandling)\n    OnOK();\n}\n\nvoid CSurfaceDlg::OnOK() \n{\n\tGetTexMods();\n  g_surfwin = NULL;\n\tCDialog::OnOK();\n  Sys_UpdateWindows(W_ALL);\n}\n\nvoid CSurfaceDlg::OnClose() \n{\n  g_surfwin = NULL;\n\tCDialog::OnClose();\n}\n\nvoid CSurfaceDlg::OnCancel() \n{\n  if (g_bGatewayhack)\n    OnOK();\n  else\n    OnBtnCancel();\n}\n\nvoid CSurfaceDlg::OnDestroy() \n{\n  if (GetSafeHwnd())\n  {\n    CRect rct;\n    GetWindowRect(rct);\n\t  SaveRegistryInfo(\"Radiant::SurfaceWindow\", &rct, sizeof(rct));\n  }\n\tCDialog::OnDestroy();\n  g_surfwin = NULL;\n  Sys_UpdateWindows(W_ALL);\n}\n\nvoid CSurfaceDlg::OnBtnCancel() \n{\n\tg_qeglobals.d_texturewin.texdef = g_old_texdef;\n\tif (g_changed_surface)\n\t{\n\t\t//++timo if !g_qeglobals.m_bBrushPrimitMode send a NULL brushprimit_texdef\n\t\tif (!g_qeglobals.m_bBrushPrimitMode)\n\t\t{\n\t\t\tSys_Printf(\"Warning : non brush primitive mode call to CSurfaceDlg::GetTexMods broken\\n\");\n\t\t\tSys_Printf(\"          ( Select_SetTexture not called )\\n\");\n\t\t}\n//\t\tSelect_SetTexture(&g_qeglobals.d_texturewin.texdef);\n\t}\n  g_surfwin = NULL;\n  DestroyWindow();\n}\n\nvoid CSurfaceDlg::OnBtnColor() \n{\n}\n\nHBRUSH CSurfaceDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) \n{\n\tHBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);\n\treturn hbr;\n}\n\nint CSurfaceDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) \n{\n\tif (CDialog::OnCreate(lpCreateStruct) == -1)\n\t\treturn -1;\n\t\n\treturn 0;\n}\n\nBOOL CSurfaceDlg::PreCreateWindow(CREATESTRUCT& cs) \n{\n\t// TODO: Add your specialized code here and/or call the base class\n\t\n\treturn CDialog::PreCreateWindow(cs);\n}\n\n\nvoid CSurfaceDlg::OnDeltaPosSpin(NMHDR* pNMHDR, LRESULT* pResult) \n{\n\tNM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;\n  UpdateSpinners((pNMUpDown->iDelta > 0), pNMUpDown->hdr.idFrom);\n\t*pResult = 0;\n}\n\nvoid CSurfaceDlg::OnBtnPatchdetails() \n{\n  Patch_NaturalizeSelected(true);\n  Sys_UpdateWindows(W_ALL);\n}\n\nvoid CSurfaceDlg::OnBtnPatchnatural() \n{\n  Patch_NaturalizeSelected();\n  Sys_UpdateWindows(W_ALL);\n}\n\nvoid CSurfaceDlg::OnBtnPatchreset() \n{\n  CTextureLayout dlg;\n  if (dlg.DoModal() == IDOK)\n  {\n    Patch_ResetTexturing(dlg.m_fX, dlg.m_fY);\n  }\n  Sys_UpdateWindows(W_ALL);\n}\n\nvoid CSurfaceDlg::OnBtnPatchfit() \n{\n  Patch_FitTexturing();\n  Sys_UpdateWindows(W_ALL);\n}\n\nvoid CSurfaceDlg::OnBtnAxial() \n{\n  Select_SetTexture (&g_qeglobals.d_texturewin.texdef, &g_qeglobals.d_texturewin.brushprimit_texdef, true);\n\tg_changed_surface = true;\n  SetTexMods();\n  Sys_UpdateWindows(W_ALL);\n}\n\nvoid CSurfaceDlg::OnBtnBrushfit() \n{\n\t// TODO: Add your control notification handler code here\n\t\n}\n\nvoid CSurfaceDlg::OnBtnFacefit() \n{\n  UpdateData(TRUE);\n  if (g_ptrSelectedFaces.GetSize() == 0)\n  {\n    brush_t *b;\n\t\tfor (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n    {\n      for (face_t* pFace = b->brush_faces; pFace; pFace = pFace->next)\n      {\n        g_ptrSelectedFaces.Add(pFace);\n        g_ptrSelectedFaceBrushes.Add(b);\n      }\n    }\n  }\n  Select_FitTexture(m_nHeight, m_nWidth);\n  SetTexMods();\n\tg_changed_surface = true;\n  Sys_UpdateWindows(W_ALL);\n}\n"
  },
  {
    "path": "q3radiant/SurfaceDlg.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_SURFACEDLG_H__D84E0C22_9EEA_11D1_B570_00AA00A410FC__INCLUDED_)\n#define AFX_SURFACEDLG_H__D84E0C22_9EEA_11D1_B570_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// SurfaceDlg.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CSurfaceDlg dialog\n\nclass CSurfaceDlg : public CDialog\n{\n\tbool m_bPatchMode;\n\t// brush primitive fake shift scale rot coords\n\tfloat\tm_shift[2];\n\tfloat\tm_rotate;\n\tfloat\tm_scale[2];\n\n\t// Construction\npublic:\n\tCSurfaceDlg(CWnd* pParent = NULL);   // standard constructor\n  void SetTexMods();\n  void GetTexMods();\n  void GrabPatchMods();\n\n// Dialog Data\n\t//{{AFX_DATA(CSurfaceDlg)\n\tenum { IDD = IDD_SURFACE };\n\tCSpinButtonCtrl\tm_wndWidth;\n\tCSpinButtonCtrl\tm_wndHeight;\n\tCSpinButtonCtrl\tm_wndVShift;\n\tCSpinButtonCtrl\tm_wndVScale;\n\tCSpinButtonCtrl\tm_wndRotate;\n\tCSpinButtonCtrl\tm_wndHShift;\n\tCSpinButtonCtrl\tm_wndHScale;\n\tint\t\tm_nHeight;\n\tint\t\tm_nWidth;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CSurfaceDlg)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\tvirtual BOOL PreCreateWindow(CREATESTRUCT& cs);\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\n  void UpdateSpinners(int nScrollCode, int nPos, CScrollBar* pBar);\n  void UpdateSpinners(bool bUp, int nID);\n\t// Generated message map functions\n\t//{{AFX_MSG(CSurfaceDlg)\n\tvirtual BOOL OnInitDialog();\n\tafx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);\n\tafx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);\n\tafx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);\n\tafx_msg void OnApply();\n\tvirtual void OnOK();\n\tafx_msg void OnClose();\n\tvirtual void OnCancel();\n\tafx_msg void OnDestroy();\n\tafx_msg void OnBtnCancel();\n\tafx_msg void OnBtnColor();\n\tafx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);\n\tafx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);\n\tafx_msg void OnDeltaPosSpin(NMHDR* pNMHDR, LRESULT* pResult);\n\tafx_msg void OnBtnPatchdetails();\n\tafx_msg void OnBtnPatchnatural();\n\tafx_msg void OnBtnPatchreset();\n\tafx_msg void OnBtnPatchfit();\n\tafx_msg void OnBtnAxial();\n\tafx_msg void OnBtnBrushfit();\n\tafx_msg void OnBtnFacefit();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_SURFACEDLG_H__D84E0C22_9EEA_11D1_B570_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/SurfacePlugin.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//-----------------------------------------------------------------------------\n//\n// $LogFile$\n// $Revision: 1.1.1.4 $\n// $Author: ttimo $\n// $Date: 2000/01/18 00:18:14 $\n// $Log: SurfacePlugin.cpp,v $\n// Revision 1.1.1.4  2000/01/18 00:18:14  ttimo\n// merging in for RC\n//\n// Revision 1.3  2000/01/17 23:53:43  TBesset\n// ready for merge in sourceforge (RC candidate)\n//\n// Revision 1.2  2000/01/07 16:40:12  TBesset\n// merged from BSP frontend\n//\n// Revision 1.1.1.3  1999/12/29 18:31:46  TBesset\n// Q3Radiant public version\n//\n// Revision 1.1.1.1.2.1  1999/12/29 21:39:42  TBesset\n// updated to update3 from Robert\n//\n// Revision 1.1.1.3  1999/12/29 18:31:46  TBesset\n// Q3Radiant public version\n// Revision 1.1.1.3  1999/12/29 18:31:46  TBesset\n// Q3Radiant public version\n//\n// Revision 1.1  1999/12/02 16:11:05  Timo & Christine\n// commit before e-brain dump\n// TexTool v1.1 support\n//\n//\n//\n// DESCRIPTION:\n// implementation of isurfaceplugin-interface specifics\n//++timo FIXME: all the patch related stuff needs moving to qerplugin.h\n\n#include \"stdafx.h\"\n\nvoid WINAPI QERApp_GetTwoSelectedPatch( patchMesh_t **p1, patchMesh_t **p2 )\n{\n\t*p1 = NULL; *p2 = NULL;\n\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next)\n\t{\n\t\tif (pb->patchBrush)\n\t\t{\n\t\t\tif (!(*p1))\n\t\t\t\t*p1 = pb->pPatch;\n\t\t\telse if (!(*p2))\n\t\t\t{\n\t\t\t\t*p2 = pb->pPatch;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n#ifdef _DEBUG\n\tSys_Printf(\"WARNING: QERApp_GetTwoSelectedPatch failed (did not find two patches)\\n\");\n#endif\n\treturn;\n\t\n}\n"
  },
  {
    "path": "q3radiant/TexEdit.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// TexEdit.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"TexEdit.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CTexEdit\n\nCTexEdit::CTexEdit()\n{\n  m_pTexWnd = NULL;\n}\n\nCTexEdit::~CTexEdit()\n{\n}\n\n\nBEGIN_MESSAGE_MAP(CTexEdit, CEdit)\n\t//{{AFX_MSG_MAP(CTexEdit)\n\tON_WM_CTLCOLOR_REFLECT()\n\tON_CONTROL_REFLECT(EN_CHANGE, OnChange)\n\tON_WM_CREATE()\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CTexEdit message handlers\n\nHBRUSH CTexEdit::CtlColor(CDC* pDC, UINT nCtlColor) \n{\n  if (nCtlColor == CTLCOLOR_EDIT)\n  {\n    pDC->SetBkColor(RGB(192,192,192));\n\t  return (HBRUSH)GetStockObject(LTGRAY_BRUSH);\n  }\n  return NULL;\n}\n\nvoid CTexEdit::OnChange() \n{\n  CString str;\n  GetWindowText(str);\n  if (m_pTexWnd)\n    m_pTexWnd->UpdateFilter(str);\n}\n\nint CTexEdit::OnCreate(LPCREATESTRUCT lpCreateStruct) \n{\n\tif (CEdit::OnCreate(lpCreateStruct) == -1)\n\t\treturn -1;\n\n  m_Font.CreatePointFont(100, \"Arial\");\n\tSetFont(&m_Font, FALSE);\n\treturn 0;\n}\n"
  },
  {
    "path": "q3radiant/TexEdit.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_TEXEDIT_H__913F6812_99CD_11D1_B568_00AA00A410FC__INCLUDED_)\n#define AFX_TEXEDIT_H__913F6812_99CD_11D1_B568_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// TexEdit.h : header file\n//\n/////////////////////////////////////////////////////////////////////////////\n// CTexEdit window\n\nclass CTexWnd;\n\nclass CTexEdit : public CEdit\n{\n// Construction\npublic:\n\tCTexEdit();\n\n// Attributes\npublic:\n\nprotected:\n  CTexWnd* m_pTexWnd;\n  CFont m_Font;\n// Operations\npublic:\n  void SetTexWnd(CTexWnd* pTex) {m_pTexWnd = pTex;};\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CTexEdit)\n\t//}}AFX_VIRTUAL\n\n// Implementation\npublic:\n\tvirtual ~CTexEdit();\n\n\t// Generated message map functions\nprotected:\n\t//{{AFX_MSG(CTexEdit)\n\tafx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);\n\tafx_msg void OnChange();\n\tafx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);\n\t//}}AFX_MSG\n\n\tDECLARE_MESSAGE_MAP()\n};\n\n/////////////////////////////////////////////////////////////////////////////\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_TEXEDIT_H__913F6812_99CD_11D1_B568_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/TexWnd.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// TexWnd.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include <assert.h>\n#include \"Radiant.h\"\n#include \"TexWnd.h\"\n#include \"qe3.h\"\n#include \"io.h\"\n#include \"PrefsDlg.h\"\n#include \"shaderinfo.h\"\n#include \"pakstuff.h\"\n#include \"str.h\"\n#include \"PrefsDlg.h\"\n\nStr m_gStr;\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\nqtexture_t *Texture_ForNamePath(char* name, char* pFullPath);\n#define\tTYP_MIPTEX\t68\nstatic unsigned\ttex_palette[256];\n\nqtexture_t\t*notexture = NULL;\nqtexture_t\t*g_pluginTexture = NULL;\n\nstatic qboolean\tnomips = false;\n\n#define\tFONT_HEIGHT\t10\n\nHGLRC s_hglrcTexture = NULL;\nHDC\t s_hdcTexture = NULL;\n\n//int\t\ttexture_mode = GL_NEAREST;\n//int\t\ttexture_mode = GL_NEAREST_MIPMAP_NEAREST;\n//int\t\ttexture_mode = GL_NEAREST_MIPMAP_LINEAR;\n//int\t\ttexture_mode = GL_LINEAR;\n//int\t\ttexture_mode = GL_LINEAR_MIPMAP_NEAREST;\nint\t\ttexture_mode = GL_LINEAR_MIPMAP_LINEAR;\n\n// this is the global counter for GL bind numbers\nint\t\ttexture_extension_number = 1;\nint g_nCurrentTextureMenuName;\n\nint g_nTextureOffset = 0;\n\n// current active texture directory.  if empty, show textures in use\nchar\t\ttexture_directory[128];\t// use if texture_showinuse is false\nqboolean\ttexture_showinuse;\n\nbool g_bFilterEnabled = false;\nCString g_strFilter;\n\n// texture layout functions\nqtexture_t\t*current_texture = NULL;\nint\t\t\tcurrent_x, current_y, current_row;\n\nint\t\t\ttexture_nummenus;\n#define\t\tMAX_TEXTUREDIRS\t128\nchar\t\ttexture_menunames[MAX_TEXTUREDIRS][128];\n\nqboolean\tg_dontuse = true;\t\t// set to true to load the texture but not flag as used\n\n// void SelectTexture (int mx, int my, bool bShift = false);\nvoid SelectTexture (int mx, int my, bool bShift, bool bFitScale=false);\n\nvoid\tTexture_MouseDown (int x, int y, int buttons);\nvoid\tTexture_MouseUp (int x, int y, int buttons);\nvoid\tTexture_MouseMoved (int x, int y, int buttons);\n\nCPtrArray g_lstShaders;\nCPtrArray g_lstSkinCache;\n\nstruct SkinInfo\n{\n  CString m_strName;\n  int m_nTextureBind;\n  SkinInfo(const char *pName, int n)\n  {\n    m_strName = pName;\n    m_nTextureBind = n;\n  };\n  SkinInfo(){};\n};\n\n// checks wether a qtexture_t exists for a given name\n//++timo FIXME: is this really any use? redundant.\nbool ShaderQTextureExists(const char *pName)\n{\n  for (qtexture_t *q=g_qeglobals.d_qtextures ; q ; q=q->next)\n  {\n    if (!strcmp(q->name,  pName))\n    {\n      return true;\n    }\n  }\n  return false;\n\n}\n\nCShaderInfo* hasShader(const char *pName)\n{\n  int nSize = g_lstShaders.GetSize();\n  for (int i = 0; i < nSize; i++)\n  {\n    CShaderInfo *pInfo = reinterpret_cast<CShaderInfo*>(g_lstShaders.ElementAt(i));\n    if (pInfo != NULL)\n    {\n      if (pInfo->m_strName.CompareNoCase(pName) == 0)\n      {\n        return pInfo;\n      }\n    }\n  }\n  return NULL;\n}\n\n// gets active texture extension\n// \n// FIXME: fix this to be generic from project file\n//\nint GetTextureExtensionCount()\n{\n  return 2;\n}\n\nconst char* GetTextureExtension(int nIndex)\n{\n  if ( nIndex == 0)\n  {\n    _QERTextureInfo *pInfo = g_pParentWnd->GetPlugInMgr().GetTextureInfo();\n    const char *pTex = (pInfo != NULL) ? pInfo->m_TextureExtension : NULL;\n    return (pTex == NULL) ? (g_PrefsDlg.m_bHiColorTextures == FALSE) ? \"wal\" : \"tga\" : pTex;\n  }\n  // return jpg for 2nd extension\n  return \"jpg\";\n}\n\nvoid SortTextures(void)\n{\t\n\tqtexture_t\t*q, *qtemp, *qhead, *qcur, *qprev;\n\n\t// standard insertion sort\n\t// Take the first texture from the list and\n\t// add it to our new list\n\tif ( g_qeglobals.d_qtextures == NULL)\n\t\treturn;\t\n\n\tqhead = g_qeglobals.d_qtextures;\n\tq = g_qeglobals.d_qtextures->next;\n\tqhead->next = NULL;\n\t\n\t// while there are still things on the old\n\t// list, keep adding them to the new list\n\twhile (q)\n\t{\n\t\tqtemp = q;\n\t\tq = q->next;\n\t\t\n\t\tqprev = NULL;\n\t\tqcur = qhead;\n\n\t\twhile (qcur)\n\t\t{\n\t\t\t// Insert it here?\n\t\t\tif (strcmp(qtemp->name, qcur->name) < 0)\n\t\t\t{\n\t\t\t\tqtemp->next = qcur;\n\t\t\t\tif (qprev)\n\t\t\t\t\tqprev->next = qtemp;\n\t\t\t\telse\n\t\t\t\t\tqhead = qtemp;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\t// Move on\n\n\t\t\tqprev = qcur;\n\t\t\tqcur = qcur->next;\n\n\n\t\t\t// is this one at the end?\n\n\t\t\tif (qcur == NULL)\n\t\t\t{\n\t\t\t\tqprev->next = qtemp;\n\t\t\t\tqtemp->next = NULL;\n\t\t\t}\n\t\t}\n\n\n\t}\n\n\tg_qeglobals.d_qtextures = qhead;\n}\n\n/*\n==============\nTexture_InitPalette\n==============\n*/\nvoid Texture_InitPalette (byte *pal)\n{\n    int\t\tr,g,b,v;\n    int\t\ti;\n\tint\t\tinf;\n\tbyte\tgammatable[256];\n\tfloat\tgamma;\n\n\tgamma = g_qeglobals.d_savedinfo.fGamma;\n\n\tif (gamma == 1.0)\n\t{\n\t\tfor (i=0 ; i<256 ; i++)\n\t\t\tgammatable[i] = i;\n\t}\n\telse\n\t{\n\t\tfor (i=0 ; i<256 ; i++)\n\t\t{\n\t\t\tinf = 255 * pow ( (float)( (i+0.5)/255.5 ), gamma ) + 0.5;\n\t\t\tif (inf < 0)\n\t\t\t\tinf = 0;\n\t\t\tif (inf > 255)\n\t\t\t\tinf = 255;\n\t\t\tgammatable[i] = inf;\n\t\t}\n\t}\n\n    for (i=0 ; i<256 ; i++)\n    {\n\t\t  r = gammatable[pal[0]];\n\t\t  g = gammatable[pal[1]];\n\t\t  b = gammatable[pal[2]];\n\t\t  pal += 3;\n\t\t\n\t\t  v = (r<<24) + (g<<16) + (b<<8) + 255;\n\t\t  v = BigLong (v);\n\t\t\n\t\t  tex_palette[i] = v;\n    }\n}\n\nvoid SetTexParameters (void)\n{\n\tqglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texture_mode );\n\t\n\tswitch ( texture_mode )\n\t{\n\tcase GL_NEAREST:\n\tcase GL_NEAREST_MIPMAP_NEAREST:\n\tcase GL_NEAREST_MIPMAP_LINEAR:\n\t\tqglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );\n\t\tbreak;\n\tcase GL_LINEAR:\n\tcase GL_LINEAR_MIPMAP_NEAREST:\n\tcase GL_LINEAR_MIPMAP_LINEAR:\n\t\tqglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );\n\t\tbreak;\n\t}\n}\n\n/*\n============\nTexture_SetMode\n============\n*/\nvoid Texture_SetMode(int iMenu)\n{\n\tint\ti, iMode;\n\tHMENU hMenu;\n\tqboolean texturing = true;\n\n\thMenu = GetMenu(g_qeglobals.d_hwndMain);\n\n\tswitch(iMenu) {\n\tcase ID_VIEW_NEAREST:\t\t\t\t\t\n\t\tiMode = GL_NEAREST;\n\t\tbreak;\n\tcase ID_VIEW_NEARESTMIPMAP:\n\t\tiMode = GL_NEAREST_MIPMAP_NEAREST;\n\t\tbreak;\n\tcase ID_VIEW_LINEAR:\n\t\tiMode = GL_NEAREST_MIPMAP_LINEAR;\n\t\tbreak;\n\tcase ID_VIEW_BILINEAR:\n\t\tiMode = GL_LINEAR;\n\t\tbreak;\n\tcase ID_VIEW_BILINEARMIPMAP:\n\t\tiMode = GL_LINEAR_MIPMAP_NEAREST;\n\t\tbreak;\n\tcase ID_VIEW_TRILINEAR:\n\t\tiMode = GL_LINEAR_MIPMAP_LINEAR;\n\t\tbreak;\n\n\tcase ID_TEXTURES_WIREFRAME:\n\t\tiMode = 0;\n\t\ttexturing = false;\n\t\tbreak;\n\n\tcase ID_TEXTURES_FLATSHADE:\n\t\tiMode = 0;\n\t\ttexturing = false;\n\t\tbreak;\n\n\t}\n\n\tCheckMenuItem(hMenu, ID_VIEW_NEAREST, MF_BYCOMMAND | MF_UNCHECKED);\n\tCheckMenuItem(hMenu, ID_VIEW_NEARESTMIPMAP, MF_BYCOMMAND | MF_UNCHECKED);\n\tCheckMenuItem(hMenu, ID_VIEW_LINEAR, MF_BYCOMMAND | MF_UNCHECKED);\n\tCheckMenuItem(hMenu, ID_VIEW_BILINEARMIPMAP, MF_BYCOMMAND | MF_UNCHECKED);\n\tCheckMenuItem(hMenu, ID_VIEW_BILINEAR, MF_BYCOMMAND | MF_UNCHECKED);\n\tCheckMenuItem(hMenu, ID_VIEW_TRILINEAR, MF_BYCOMMAND | MF_UNCHECKED);\n\tCheckMenuItem(hMenu, ID_TEXTURES_WIREFRAME, MF_BYCOMMAND | MF_UNCHECKED);\n\tCheckMenuItem(hMenu, ID_TEXTURES_FLATSHADE, MF_BYCOMMAND | MF_UNCHECKED);\n\n\tCheckMenuItem(hMenu, iMenu, MF_BYCOMMAND | MF_CHECKED);\n\n\tg_qeglobals.d_savedinfo.iTexMenu = iMenu;\n\ttexture_mode = iMode;\n\n  if (g_PrefsDlg.m_bSGIOpenGL)\n  {\n    if (s_hdcTexture && s_hglrcTexture)\n    {\n      //if (!qwglMakeCurrent(g_qeglobals.d_hdcBase, g_qeglobals.d_hglrcBase))\n      if (!qwglMakeCurrent(s_hdcTexture, s_hglrcTexture))\n\t\t    Error (\"wglMakeCurrent in LoadTexture failed\");\n    }\n    else\n      return;\n  }\n\n\tif ( texturing )\n\t\tSetTexParameters ();\n\n\tif ( !texturing && iMenu == ID_TEXTURES_WIREFRAME)\n\t{\n\t\tg_pParentWnd->GetCamera()->Camera().draw_mode = cd_wire;\n\t\tMap_BuildBrushData();\n\t\tSys_UpdateWindows (W_ALL);\n\t\treturn;\n\n\t} else if ( !texturing && iMenu == ID_TEXTURES_FLATSHADE) {\n\n\t\tg_pParentWnd->GetCamera()->Camera().draw_mode = cd_solid;\n\t\tMap_BuildBrushData();\n\t\tSys_UpdateWindows (W_ALL);\n\t\treturn;\n\t}\n\n\tfor (i=1 ; i<texture_extension_number ; i++)\n\t{\n\t\tqglBindTexture( GL_TEXTURE_2D, i );\n\t\tSetTexParameters ();\n\t}\n\n\t// select the default texture\n\tqglBindTexture( GL_TEXTURE_2D, 0 );\n\n\tqglFinish();\n\n\tif (g_pParentWnd->GetCamera()->Camera().draw_mode != cd_texture)\n\t{\n\t\tg_pParentWnd->GetCamera()->Camera().draw_mode = cd_texture;\n\t\tMap_BuildBrushData();\n\t}\n\n\tSys_UpdateWindows (W_ALL);\n}\n\n/*\n================\nR_MipMap\n\nOperates in place, quartering the size of the texture\n================\n*/\nvoid R_MipMap (byte *in, int &width, int &height)\n{\n\tint\t\ti, j;\n\tbyte\t*out;\n\tint\t\trow;\n\t\n\trow = width * 4;\n\twidth >>= 1;\n\theight >>= 1;\n\tout = in;\n\tfor (i=0 ; i<height ; i++, in+=row)\n\t{\n\t\tfor (j=0 ; j<width ; j++, out+=4, in+=8)\n\t\t{\n\t\t\tout[0] = (in[0] + in[4] + in[row+0] + in[row+4])>>2;\n\t\t\tout[1] = (in[1] + in[5] + in[row+1] + in[row+5])>>2;\n\t\t\tout[2] = (in[2] + in[6] + in[row+2] + in[row+6])>>2;\n\t\t\tout[3] = (in[3] + in[7] + in[row+3] + in[row+7])>>2;\n\t\t}\n\t}\n}\n\n/*\n=================\nTexture_LoadTexture\n=================\n*/\n//++timo NOTE: miptex_t is used only for .WAL format .. a bit outdated\nqtexture_t *Texture_LoadTexture (miptex_t *qtex)\n{\n  byte\t\t*source;\n  unsigned\tchar *dest;\n  int\t\t\twidth, height, i, count;\n\tint\t\t\ttotal[3];\n  qtexture_t\t*q;\n      \n  width = LittleLong(qtex->width);\n  height = LittleLong(qtex->height);\n\n  q = (qtexture_t*)qmalloc(sizeof(*q));\n\n  q->width = width;\n  q->height = height;\n\n\tq->flags = qtex->flags;\n\tq->value = qtex->value;\n\tq->contents = qtex->contents;\n\n\tdest = (unsigned char*)qmalloc (width*height*4);\n\n  count = width*height;\n  source = (byte *)qtex + LittleLong(qtex->offsets[0]);\n\n\t// The dib is upside down so we want to copy it into \n\t// the buffer bottom up.\n\n\ttotal[0] = total[1] = total[2] = 0;\n  for (i=0 ; i<count ; i++)\n\t{\n\t\tdest[i] = tex_palette[source[i]];\n\n\t\ttotal[0] += ((byte *)(dest+i))[0];\n\t\ttotal[1] += ((byte *)(dest+i))[1];\n\t\ttotal[2] += ((byte *)(dest+i))[2];\n\t}\n\n\tq->color[0] = (float)total[0]/(count*255);\n\tq->color[1] = (float)total[1]/(count*255);\n\tq->color[2] = (float)total[2]/(count*255);\n\n  q->texture_number = texture_extension_number++;\n\n  if (g_qeglobals.bSurfacePropertiesPlugin)\n  {\n\t  // Timo\n\t  // Surface properties plugins can store their own data in an IPluginQTexture\n\t  q->pData = g_SurfaceTable.m_pfnQTextureAlloc( q );\n\t  GETPLUGINTEXDEF(q)->InitForMiptex( qtex );\n  }\n\n  //++timo is the m_bSGIOpenGL parameter still taken into account?\n  if (g_PrefsDlg.m_bSGIOpenGL)\n  {\n    //if (!qwglMakeCurrent(g_qeglobals.d_hdcBase, g_qeglobals.d_hglrcBase))\n    if (!qwglMakeCurrent(s_hdcTexture, s_hglrcTexture))\n\t\t  Error (\"wglMakeCurrent in LoadTexture failed\");\n  }\n\n  qglBindTexture( GL_TEXTURE_2D, q->texture_number );\n\n  //Handle3DfxTexturing(q, width, height, dest);\n\n  SetTexParameters ();\n\n  int nCount = MAX_TEXTURE_QUALITY - g_PrefsDlg.m_nTextureQuality;\n  while (nCount-- > 0)\n  {\n    if (width > 16 && height > 16)\n    {\n      R_MipMap(dest, width, height);\n    }\n    else\n    {\n      break;\n    }\n  }\n\n  if (g_PrefsDlg.m_bSGIOpenGL)\n  {\n\t  if (nomips)\n    {\n\t\t  qglTexImage2D(GL_TEXTURE_2D, 0, 3, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, dest);\n    }\n\t  else\n\t\t  qgluBuild2DMipmaps(GL_TEXTURE_2D, 3, width, height,GL_RGBA, GL_UNSIGNED_BYTE, dest);\n  }\n  else\n  {\n\t  if (nomips)\n\t\t  qglTexImage2D(GL_TEXTURE_2D, 0, 3, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, dest);\n\t  else\n\t\t  qgluBuild2DMipmaps(GL_TEXTURE_2D, 3, width, height,GL_RGBA, GL_UNSIGNED_BYTE, dest);\n  }\n\n\tfree (dest);\n\n\tqglBindTexture( GL_TEXTURE_2D, 0 );\n\n  return q;\n}\n\n\n\n\n/*\n=================\nTexture_LoadTexture\n=================\n*/\nqtexture_t *Texture_LoadTGATexture (unsigned char* pPixels, int nWidth, int nHeight, char* pPath, int nFlags, int nContents, int nValue )\n{\n  int i, j, inf;\n\tbyte\tgammatable[256];\n\tfloat fGamma = g_qeglobals.d_savedinfo.fGamma;\n\n\n  qtexture_t* q = (qtexture_t*)qmalloc(sizeof(*q));\n  q->width = nWidth;\n  q->height = nHeight;\n\tq->flags = nFlags;\n\tq->value = nValue;\n\tq->contents = nContents;\n\n  int nCount = nWidth * nHeight;\n  float total[3];\n  total[0] = total[1] = total[2] = 0.0f;\n\n  //++timo FIXME: move gamma table initialization somewhere else!\n\tif (fGamma == 1.0)\n\t{\n\t\tfor (i=0 ; i<256 ; i++)\n\t\t\tgammatable[i] = i;\n\t}\n\telse\n\t{\n\t\tfor (i=0 ; i<256 ; i++)\n\t\t{\n\t\t\tinf = 255 * pow ( (float)( (i+0.5)/255.5 ), fGamma ) + 0.5;\n\t\t\tif (inf < 0)\n\t\t\t\tinf = 0;\n\t\t\tif (inf > 255)\n\t\t\t\tinf = 255;\n\t\t\tgammatable[i] = inf;\n\t\t}\n\t}\n\n\n  // all targas are stored internally as 32bit so rgba = 4 bytes\n  for (i = 0 ; i < (nCount * 4) ; i += 4)\n\t{\n    for (j = 0; j < 3; j++)\n    {\n\t    total[j] += (pPixels+i)[j];\n      byte b = (pPixels+i)[j];\n      (pPixels+i)[j] = gammatable[b];\n              \n    }\n\t}\n\n\tq->color[0] = total[0] / (nCount * 255);\n\tq->color[1] = total[1] / (nCount * 255);\n\tq->color[2] = total[2] / (nCount * 255);\n\n\n  q->texture_number = texture_extension_number++;\n\n  if (g_qeglobals.bSurfacePropertiesPlugin)\n  {\n\t  // Timo\n\t  // Surface properties plugins can store their own data in an IPluginQTexture\n\t  q->pData = g_SurfaceTable.m_pfnQTextureAlloc( q );\n\t  GETPLUGINTEXDEF(q)->SetDefaultTexdef();\n  }\n\n  if (g_PrefsDlg.m_bSGIOpenGL)\n  {\n    //if (!qwglMakeCurrent(g_qeglobals.d_hdcBase, g_qeglobals.d_hglrcBase))\n    if (!qwglMakeCurrent(s_hdcTexture, s_hglrcTexture))\n\t\t  Error (\"wglMakeCurrent in LoadTexture failed\");\n  }\n\n  qglBindTexture( GL_TEXTURE_2D, q->texture_number );\n\n  //Handle3DfxTexturing(q, width, height, dest);\n\n  SetTexParameters();\n\n  nCount = MAX_TEXTURE_QUALITY - g_PrefsDlg.m_nTextureQuality;\n  while (nCount-- > 0)\n  {\n    if (nWidth > 16 && nHeight > 16)\n    {\n      R_MipMap(pPixels, nWidth, nHeight);\n    }\n    else\n    {\n      break;\n    }\n  }\n\n  if (g_PrefsDlg.m_bSGIOpenGL)\n  {\n\t  if (nomips)\n    {\n\t\t  qglTexImage2D(GL_TEXTURE_2D, 0, 4, nWidth, nHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, pPixels);\n    }\n\t  else\n\t\t  qgluBuild2DMipmaps(GL_TEXTURE_2D, 4, nWidth, nHeight,GL_RGBA, GL_UNSIGNED_BYTE, pPixels);\n  }\n  else\n  {\n\t  if (nomips)\n\t\t  qglTexImage2D(GL_TEXTURE_2D, 0, 4, nWidth, nHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, pPixels);\n\t  else\n\t\t  qgluBuild2DMipmaps(GL_TEXTURE_2D, 4, nWidth, nHeight,GL_RGBA, GL_UNSIGNED_BYTE, pPixels);\n  }\n\n\tqglBindTexture( GL_TEXTURE_2D, 0 );\n\n  return q;\n}\n\n\nqtexture_t *Texture_LoadTGATexture (unsigned char* pPixels, int nWidth, int nHeight, char *pPath)\n{\n  CString strName;\n  CString strPath;\n  ExtractPath_and_Filename(pPath, strPath, strName);\n  AddSlash(strPath);\n  strPath += \"textureinfo.ini\";\n  strName.MakeLower();\n  StripExtension (strName.GetBuffer(0));\n  strName.ReleaseBuffer();\n  \n  int nFlags = GetPrivateProfileInt(strName, \"Flags\", 0, strPath);\n  int nValue = GetPrivateProfileInt(strName, \"Value\", 0, strPath);\n  int nContents = GetPrivateProfileInt(strName, \"Contents\", 0, strPath);\n  return Texture_LoadTGATexture(pPixels, nWidth, nHeight, pPath, nFlags, nValue, nContents);\n}\n\n\nvoid Texture_LoadFromPlugIn(LPVOID vp)\n{\n  g_pluginTexture = notexture;\n  _QERTextureLoad *pLoad = reinterpret_cast<_QERTextureLoad*>(vp);\n  if (pLoad != NULL)\n  {\n\t  qtexture_t\t*q;\n    q = Texture_LoadTGATexture(pLoad->m_pRGBA, pLoad->m_nWidth, pLoad->m_nHeight, NULL, pLoad->m_nFlags, pLoad->m_nContents, pLoad->m_nValue);\n    if (q != NULL)\n    {\n\t\t// to save duplicate code (since one always ends up getting forgotten and out of sync) this is now done later by caller\n//\t\t  strcpy (q->name, pLoad->m_pName);\n//\t\t  StripExtension (q->name);\n//\t\t  if (!g_dontuse)\n//\t\t\tq->inuse = true;\n//\t    q->next = g_qeglobals.d_qtextures;\n//\t    g_qeglobals.d_qtextures = q;\n      g_pluginTexture = q;\n    }\n  }\n}\n\n\n/*\n===============\nTexture_CreateSolid\n\nCreate a single pixel texture of the apropriate color\n===============\n*/\nqtexture_t *Texture_CreateSolid (const char *name)\n{\n\tbyte\tdata[4];\n\tqtexture_t\t*q;\n\n  q = (qtexture_t*)qmalloc(sizeof(*q));\n\n  if (g_qeglobals.bSurfacePropertiesPlugin)\n  {\n\t  // Timo\n\t  // Surface properties plugins can store their own data in an IPluginQTexture\n\t  q->pData = g_SurfaceTable.m_pfnQTextureAlloc( q );\n\t  GETPLUGINTEXDEF(q)->SetDefaultTexdef();\n  }\n\t\n\tsscanf (name, \"(%f %f %f)\", &q->color[0], &q->color[1], &q->color[2]);\n\n\tdata[0] = q->color[0]*255;\n\tdata[1] = q->color[1]*255;\n\tdata[2] = q->color[2]*255;\n\tdata[3] = 255;\n\n\tq->width = q->height = 1;\n\t//q->width = q->height = 2;\n  q->texture_number = texture_extension_number++;\n\tqglBindTexture( GL_TEXTURE_2D, q->texture_number );\n\tSetTexParameters ();\n\n  if (g_PrefsDlg.m_bSGIOpenGL)\n  {\n\t\tqglTexImage2D(GL_TEXTURE_2D, 0, 3, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);\n  }\n  else\n  {\n\t  if (nomips)\n\t\t  qglTexImage2D(GL_TEXTURE_2D, 0, 3, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);\n\t  else\n\t\t  qgluBuild2DMipmaps(GL_TEXTURE_2D, 3, 1, 1,GL_RGBA, GL_UNSIGNED_BYTE, data);\n  }\n\tqglBindTexture( GL_TEXTURE_2D, 0 );\n\n\treturn q;\n}\n\n\n/*\n=================\nTexture_MakeDefault\n=================\n*/\nqtexture_t* Texture_MakeDefault (void)\n{\n  qtexture_t\t*q;\n  byte\t\tdata[4][4];\n\n  if (g_PrefsDlg.m_bSGIOpenGL)\n  {\n    if (s_hdcTexture && s_hglrcTexture)\n    { \n       //if (!qwglMakeCurrent(g_qeglobals.d_hdcBase, g_qeglobals.d_hglrcBase))\n       if (!qwglMakeCurrent(s_hdcTexture, s_hglrcTexture))\n\t\t     Error (\"wglMakeCurrent in LoadTexture failed\");\n    }\n    else\n      return NULL;\n  }\n\n  q = (qtexture_t*)qmalloc(sizeof(*q));\n  \n  strcpy (q->name, \"notexture\");\n  q->width = q->height = 64;\n  \n  memset (data, 0, sizeof(data));\n  data[0][2] = data[3][2] = 255;\n  \n  q->color[0] = 0;\n  q->color[1] = 0;\n  q->color[2] = 0.5;\n\n  q->texture_number = texture_extension_number++;\n  qglBindTexture( GL_TEXTURE_2D, q->texture_number );\n  SetTexParameters ();\n\n\tif (nomips)\n\t\tqglTexImage2D(GL_TEXTURE_2D, 0, 3, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);\n\telse\n\t\tVERIFY(qgluBuild2DMipmaps(GL_TEXTURE_2D, 3, 2, 2,GL_RGBA, GL_UNSIGNED_BYTE, data) == 0);\n\n  qglBindTexture( GL_TEXTURE_2D, 0 );\n  return q;\n}\n\n\n/*\n=================\nTexture_MakeNotexture\n=================\n*/\nvoid Texture_MakeNotexture (void)\n{\n  notexture = Texture_MakeDefault();\n  // Timo\n  // Surface properties plugins can store their own data in an IPluginQTexture\n  if (g_qeglobals.bSurfacePropertiesPlugin)\n  {\n\t  notexture->pData = g_SurfaceTable.m_pfnQTextureAlloc( notexture );\n\t  GETPLUGINTEXDEF(notexture)->SetDefaultTexdef();\n  }\n}\n\n\nvoid DemandLoadShaderTexture(qtexture_t *q, CShaderInfo *pShader)\n{\n  char cWork[1024];\n  char cWork2[1024];\n  strcpy(cWork, (pShader->m_strTextureName.GetLength() > 0) ? pShader->m_strTextureName  : pShader->m_strName);\n  StripExtension(cWork);\n  // TTimo: if the shader has a m_fTransValue != 1.0f, ignore the alpha channel when loading the texture\n  // in some cases (common/weapclip) the 32bit .tga has an empty alpha channel,\n  // causing a display bug in the camera view (brush does not seemed drawn since alpha==0 for the texture)\n  // NOTE: the workaround is not perfect, the same texture may have been loaded earlier with it's alpha channel\n  q = Texture_ForName (cWork, false, true, pShader->m_fTransValue != 1.0f, true, false);\n\n  if (q == NULL || q == notexture) {\n    sprintf(cWork2, \"%s/%s\",ValueForKey(g_qeglobals.d_project_entity, \"basepath\"), cWork);\n    q = Texture_ForNamePath( cWork, cWork2);\n\n    if (q == NULL || q == notexture) {\n      q = Texture_ForName (cWork, false, true, pShader->m_fTransValue != 1.0f, true, true);\n    }\n  }\n\n  if (q != NULL && q != notexture)\n  {\n    pShader->m_pQTexture = q;\n    strcpy(q->shadername, pShader->m_strShaderName);\n    q->bFromShader = true;\n    q->fTrans = pShader->m_fTransValue;\n    q->nShaderFlags = pShader->m_nFlags;\n    strcpy(q->name, pShader->m_strName );\n  }\n  else\n  {\n    Sys_Printf(\"Could not load shader editor image %s\\n\", cWork);\n  }\n}\n\n\nvoid LoadShader(char* pFilename, qtexture_t *q)\n{\n  char* pBuff = NULL;\n  CString strTexture;\n  int nSize = LoadFile(pFilename, reinterpret_cast<void**>(&pBuff));\n  if (nSize == -1)\n  {\n    nSize = PakLoadAnyFile(pFilename, reinterpret_cast<void**>(&pBuff));\n  }\n  if (nSize > 0)\n  {\n    StartTokenParsing(pBuff);\n    while (GetToken(true))\n    {\n      // first token should be the path + name.. (from base)\n      CShaderInfo *pShader = new CShaderInfo();\n      pShader->setName(token);\n      pShader->m_strShaderName = pFilename;\n      strTexture = token;\n      bool bGood = true;\n      float fTrans = 1.0;\n      GetToken(true);\n      if (strcmp(token, \"{\"))\n      {\n        bGood = false;\n        break;\n      }\n      else\n      {\n        // we need to read until we hit a balanced }\n        int nMatch = 1;\n        while (nMatch > 0 && GetToken(true))\n        {\n          if (strcmp(token, \"{\") == 0)\n          {\n            nMatch++;\n          }\n          else if (strcmp(token, \"}\") == 0)\n          {\n            nMatch--;\n          }\n          else if (strcmpi(token, \"qer_nocarve\") == 0)\n          {\n            pShader->m_nFlags |= QER_NOCARVE;\n          }\n          else if (strcmpi(token, \"qer_trans\") == 0)\n          {\n            if (GetToken(true))\n            {\n              fTrans = atof(token);\n            }\n            pShader->m_nFlags |= QER_TRANS;\n          }\n          else if (strcmpi(token, \"qer_editorimage\") == 0)\n          {\n            if (GetToken(true))\n            {\n              char* pTex = copystring(token);\n          \t\tQE_ConvertDOSToUnixName( pTex, pTex );\n              CString str = pTex;\n              free (pTex);\n              FindReplace(str, \"textures/\", \"\");\n              FindReplace(str, \".tga\", \"\");\n              int nPos = str.Find('/');\n              if (nPos == -1)\n              {\n                nPos = str.Find('\\\\');\n              }\n              if (nPos >= 0)\n              {\n                pShader->m_strTextureName = str;\n\t\t \t\t\t\t\t  pShader->m_strTextureName.MakeLower();\t//avoid problems with case\n/*\n                else\n                {\n                  CString strPath = str.Left(nPos+1);\n                  DeferredShaderLoad *deferred = new DeferredShaderLoad(str, pShader->m_strName, strPath); \n                  g_lstDeferred.Add(deferred);\n                }\n*/\n              }\n            }\n          }\n          else if (strcmpi(token, \"surfaceparm\") == 0)\n          {\n            //--while (GetToken(false))\n            //--{\n            //--\n            //--}\n            if (GetToken(true))\n            {\n              // next token should be a surface parm\n              //--if (strcmpi(token, \"trans\") == 0)\n              //--{\n              //--  fTrans = 0.33;\n              //--}\n              if (strcmpi(token, \"fog\") == 0)\n              {\n                if (fTrans == 1.0) // has not been explicitly set by qer_trans\n                {\n                  fTrans = 0.35;\n                }\n              }\n            }\n          }\n        }\n        if (nMatch != 0)\n        {\n          bGood = false;\n          break;\n        }\n      }\n      //--if (bGood && q)\n      if (bGood)\n      {\n        pShader->m_fTransValue = fTrans;\n        g_lstShaders.Add(pShader);\n\n        int n = g_PrefsDlg.m_nShader;\n        if (g_PrefsDlg.m_nShader == CPrefsDlg::SHADER_ALL || (g_PrefsDlg.m_nShader == CPrefsDlg::SHADER_COMMON && strstr(pShader->m_strName, \"common\" )))\n        {\n// new \n          if (pShader->m_strTextureName.GetLength() > 0)\n          {\n            if (!ShaderQTextureExists(pShader->m_strName))\n            {\n              DemandLoadShaderTexture(q, pShader);\n            }\n          }\n        }\n// end new \n        //--q->bFromShader = true;\n        //--q->fTrans = fTrans;\n\n        //--// good texture here\n        //--//Sys_Printf(\"Test load texture %s\\n\", strTexture);\n        //--// FIXME.. this is a load of crap\n        //--strcpy(dirstring, strTexture);\n        //--QE_ConvertDOSToUnixName(dirstring, dirstring);\n        //--strTexture = dirstring;\n        //--FindReplace(strTexture, \"textures/\", \"\");\n\t\t    //--qtexture_t *q = Texture_ForName (strTexture.GetBuffer(0));\n        //--if (q != NULL)\n        //--{\n        //--  q->bFromShader = true;\n        //--  q->fTrans = fTrans;\n        //--}\n      }\n      else\n      {\n        Sys_Printf(\"Error parsing shader at texture %s\\n\", strTexture);\n      }\n\n    }\n    free (pBuff);\n  }\n  else\n  {\n    Sys_Printf(\"Unabled to read shader %s\\n\", pFilename);\n  }\n}\n\n\nextern bool DoesFileExist(const char* pBuff, long& lSize);\nCShaderInfo* SetNameShaderInfo(qtexture_t* q, const char* pPath, const char* pName)\n{\n  CShaderInfo *pInfo = hasShader(pName);\n  if (pInfo)\n  {\n    strcpy(q->shadername, pInfo->m_strShaderName);\n    q->bFromShader = true;\n    q->fTrans = pInfo->m_fTransValue;\n    q->nShaderFlags = pInfo->m_nFlags;\n  }\n  else\n  {\n    q->shadername[0] = 0;\n  }\n  strncpy (q->name, pName, sizeof(q->name) - 1);\n\tStripExtension (q->name);\n  return pInfo;\n}\n\nvoid ReplaceQTexture(qtexture_t *pOld, qtexture_t *pNew, brush_t *pList)\n{ \n\tfor (brush_t* pBrush = pList->next ; pBrush != pList; pBrush = pBrush->next)\n\t{\n\t\tif (pBrush->patchBrush)\n\t\t{\n\t\t\tPatch_ReplaceQTexture(pBrush, pOld, pNew);\n\t\t}\n\t\tif (pBrush->terrainBrush)\n\t\t{\n\t\t\tTerrain_ReplaceQTexture(pBrush->pTerrain, pOld, pNew);\n\t\t}\n\n\t\tfor (face_t* pFace = pBrush->brush_faces; pFace; pFace = pFace->next)\n\t\t{\n\t\t\tif (pFace->d_texture == pOld)\n\t\t\t{\n\t\t\tpFace->d_texture = pNew;\n\t\t\t}\n\t\t}\n\t\t\n\t\t//Brush_Build(pBrush);\n\t}\n}\n\n\nvoid Texture_Remove(qtexture_t *q)\n{\n  qtexture_t* pTex = g_qeglobals.d_qtextures->next;\n  if (q == g_qeglobals.d_qtextures)   // it is the head\n  {\n    g_qeglobals.d_qtextures->next = q->next->next;\n    g_qeglobals.d_qtextures = q->next;\n  }\n  else\n  {\n    qtexture_t* pLast = g_qeglobals.d_qtextures;\n    while (pTex != NULL && pTex != g_qeglobals.d_qtextures)\n    {\n      if (pTex == q)\n      {\n        pLast->next = q->next;\n        break;\n      }\n      pLast = pTex;\n      pTex = pTex->next;\n    }\n  }\n  qglDeleteTextures(1, reinterpret_cast<const unsigned int*>(&q->texture_number));\n\n  if (g_qeglobals.bSurfacePropertiesPlugin)\n  {\n\t  // Timo\n\t  // Surface properties plugin\n#ifdef _DEBUG\n\t  if ( !q->pData )\n\t\t  Sys_Printf(\"WARNING: found a qtexture_t* with no IPluginQTexture\\n\");\n#endif\n\t  if ( q->pData )\n\t\t  GETPLUGINTEXDEF(q)->DecRef();\n  }\n\n  free(q);\n\n}\n\n/*\n=================\nTexture_MakeNoShadertexture\n\nMake a default black/red check pattern texture\n=================\n*/\nqtexture_t * Texture_MakeNoshadertexture( const char *name )\n{\n\tqtexture_t\t*q;\n\tbyte\t\tdata[4][4];\n\n\tnotexture = q = (qtexture_t*)qmalloc(sizeof(*q));\n\tq->width = q->height = 64;\n\tq->fTrans = 1;\n\n\tq = (qtexture_t*)qmalloc(sizeof(*q));\n  strcpy (q->name, name);\n\n\tq->width = q->height = 64;\n\tq->fTrans = 1;\n\n\tmemset (data, 0, sizeof(data));\n\tdata[0][0] = data[3][0] = 255;\n\n\tq->color[0] = 0;\n\tq->color[1] = 0;\n\tq->color[2] = 0.5;\n\n\tq->texture_number = texture_extension_number++;\n\tqglBindTexture( GL_TEXTURE_2D, q->texture_number );\n\tSetTexParameters ();\n\n\tif (nomips)\n\t\tqglTexImage2D(GL_TEXTURE_2D, 0, 3, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);\n\telse\n\t\tVERIFY(qgluBuild2DMipmaps(GL_TEXTURE_2D, 3, 2, 2,GL_RGBA, GL_UNSIGNED_BYTE, data) == 0);\n\n\tqglBindTexture( GL_TEXTURE_2D, 0 );\n\n\treturn q;\n}\n\n\n\n/*\n===============\nTexture_ForName\n===============\n*/\n//bReload is set to true when called from DemandLoadShaderTexture because it should never re-use\n//an already loaded texture\nqtexture_t *Texture_ForName (const char *name, bool bReplace, bool bShader, bool bNoAlpha, bool bReload, bool makeShader)\n{\n  byte    *lump;\n\tqtexture_t\t*q = NULL;\n\tchar\tfilename[1024];\n\t\n  if (name == NULL || strlen(name) == 0)\n\t\treturn notexture;\n\t\n\tqtexture_t *pRemove = NULL;\n\t\n\tif (!bReload)\n\t{\n\t\tfor (q=g_qeglobals.d_qtextures ; q ; q=q->next)\n\t\t{\n\t\t\tif (!strcmp(name,  q->name))\n\t\t\t{\n\t\t\t\tif (bReplace)\n\t\t\t\t{\n\t\t\t\t\tpRemove = q;\n\t\t\t\t\t//Texture_Remove(q);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n#ifdef _DEBUG\n\t\t\t\t\t// if the texture is already in memory, then the bNoAlpha flag doesn't have any influence\n\t\t\t\t\tif (bNoAlpha)\n\t\t\t\t\t\tSys_Printf(\"WARNING: bNoAlpha flag on an already loaded texture\\n\");\n#endif\n\t\t\t\t\tif (!g_dontuse)\n\t\t\t\t\t{\n\t\t\t\t\t\tq->inuse = true;\n\t\t\t\t\t}\n\t\t\t\t\treturn q;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n  // did not find it in the standard list\n  // skip entity names (\n  if (!bShader && name[0] != '(')\n  {\n    CShaderInfo* pShader = hasShader(name);\n    if (pShader)\n    {\n      if (pShader->m_pQTexture == NULL)\n      {\n        DemandLoadShaderTexture(q, pShader);\n      }\n      q = pShader->m_pQTexture;\n      //Sys_Printf (\"used Shader %s.\\n\", pShader->m_strName);\n    }\n    if ( q != NULL)\n    {\n      return q;\n    }\n  }\n\n\t\n\tif (name[0] == '(')\n\t{\n\t\tq = Texture_CreateSolid (name);\n\t\tstrncpy (q->name, name, sizeof(q->name)-1);\n\t}\n\telse\n\t{\n\t\t// FIXME: this is a mess.. need to move consolidate stuff\n\t\t// down to a single routine.. \n\t\t// \n\t\t// if plugins have a texture loader\n\t\t// {\n\t\t//   \n\t\t// }\n\t\t// else\n\t\t// \n\t\tif (g_pParentWnd->GetPlugInMgr().GetTextureInfo() != NULL)\n\t\t{\n\t\t\t// rad: 12/19/98\n\t\t\t// if the plugin is not a wad style then we need to treat it normally\n\t\t\t// otherwise return without trying to explicitly load the texture\n\t\t\t// as it should have been loaded by the wad style plugin at init time\n\t\t\tCString strTex = GetTextureExtension(0);\n\t\t\tsprintf (filename, \"%s\\\\%s.%s\", ValueForKey (g_qeglobals.d_project_entity, \"texturepath\"), name, strTex);\n\t\t\tif (!g_pParentWnd->GetPlugInMgr().GetTextureInfo()->m_bWadStyle)\n      {   \n\t\t\t\tg_pParentWnd->GetPlugInMgr().LoadTexture(filename);        \n\t\t\t\tif (g_pluginTexture)\n\t\t\t\t\tq = g_pluginTexture;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn notexture;\n\t\t\t\t// wadstyle.. if we get here then we do not have it\n\t\t\t}\n\t\t}\n\t\telse\n      // we need to try several formats here, or would it be better if we are given a complete name\n\t\t\tif (g_PrefsDlg.m_bHiColorTextures == TRUE)\n\t\t\t{\n\t\t    char cWork[1024];\n\t\t  \tsprintf (filename, \"%s/%s.tga\", ValueForKey (g_qeglobals.d_project_entity, \"texturepath\"), name);\n    \t\tQE_ConvertDOSToUnixName( cWork, filename );\n\t\t    strcpy(filename, cWork);\n\t\t\t\tSys_Printf (\"Loading %s...\", name);\n\t\t\t\tunsigned char* pPixels = NULL;\n\t\t\t\tint nWidth;\n\t\t\t\tint nHeight;\n\t\t\t\tLoadImage(filename, &pPixels, &nWidth, &nHeight);\n        if (pPixels == NULL)\n        {\n          // try jpg\n          // blatant assumption of .tga should be fine since we sprintf'd it above\n          int nLen = strlen(filename);\n          filename[nLen-3] = 'j';\n          filename[nLen-2] = 'p';\n          filename[nLen-1] = 'g';\n\t\t\t\t  LoadImage(filename, &pPixels, &nWidth, &nHeight);\n        }\n\t\t\t\tif (pPixels)\n\t\t\t\t{\n\t\t\t\t\t// if we were asked to ignore alpha channel, do it now (.TGA is the only supported file type with alpha channel)\n\t\t\t\t\t//if (bNoAlpha)\n\t\t\t\t\tif (TRUE)\n\t\t\t\t\t{\n\t\t\t\t\t\tunsigned char* iPix = pPixels;\n\t\t\t\t\t\tint nCount = nWidth * nHeight;\n\t\t\t\t\t\tfor(iPix=pPixels+3; iPix-pPixels < nCount*4; iPix+=4)\n\t\t\t\t\t\t\t*iPix = 255;\n\t\t\t\t\t}\n          // we'll be binding the GL texture now\n          // need to check we are using a right GL context\n          // with GL plugins that have their own window, the GL context may be the plugin's, in which case loading textures will bug\n\t        HDC currentHDC = qwglGetCurrentDC();\n\t        HGLRC currentHGLRC = qwglGetCurrentContext();\n          //++timo FIXME: this may duplicate with qtexture_t* WINAPI QERApp_Texture_ForName (const char *name)\n          //++timo FIXME: we need a list of lawfull GL contexts or something?\n          // I'd rather always use the same GL context for binding...\n          if (currentHDC != g_qeglobals.d_hdcBase || currentHGLRC != g_qeglobals.d_hglrcBase)\n\t          qwglMakeCurrent( g_qeglobals.d_hdcBase, g_qeglobals.d_hglrcBase );\n\t\t\t\t\tq = Texture_LoadTGATexture(pPixels, nWidth, nHeight, NULL, 0, 0, 0);\n          //++timo I don't set back the GL context .. I don't know how safe it is\n          //qwglMakeCurrent( currentHDC, currentHGLRC );\n    \t//++timo storing the filename .. will be removed by shader code cleanup\n\t\t// this is dirty, and we sure miss some places were we should fill the filename info\n\t\tstrcpy( q->filename, name );\n\t\t\t\t\tSetNameShaderInfo(q, filename, name);\n\t\t\t\t\tSys_Printf (\"done.\\n\", name);\n\t\t\t\t\tfree(pPixels);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t// load the file\n\t\t\t\tsprintf (filename, \"%s/%s.wal\", ValueForKey (g_qeglobals.d_project_entity, \"texturepath\"),\tname);\n\t\t\t\tSys_Printf (\"Loading %s...\", name);\n\t\t\t\tif (LoadFile (filename, (void**)&lump) == -1)\n\t\t\t\t{\n\t\t\t\t\tsprintf (filename, \"%s.wal\", name);\n\t\t\t\t\tSys_Printf(\"failed.. trying pak0.pak..\");\n\t\t\t\t\tif(!PakLoadFile(filename, (void**)&lump))\n\t\t\t\t\t{\n\t\t\t\t\t\tSys_Printf (\" load failed!\\n\");\n\t\t\t\t\t\treturn notexture;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tSys_Printf(\"successful.\\n\");\n\t\t\t\tq = Texture_LoadTexture ((miptex_t *)lump);\n\t\t\t\tfree (lump);\n\t\t\t\tstrncpy (q->name, name, sizeof(q->name)-1);\n\t\t\t\tStripExtension (q->name);\n\t\t\t}\n\t\t\t\n \t\t\tif (g_PrefsDlg.m_bSGIOpenGL)\n\t\t\t{\n\t\t\t\tif(!q)\n\t\t\t\t\treturn notexture;\n\t\t\t}\n\t\t\t\n\t}// name[0] != '('\n\t\n\tif(!q)\t// safety\n  {\n    if (bShader && !makeShader) {\n      return q;\n    }\n  \n    if (bShader)\n    {\n      q = Texture_MakeNoshadertexture( name );\n\t    Sys_Printf(\"failed, using default shader\\n\");\n    }\n    else\n    {\n      q = Texture_MakeDefault();\n\t    Sys_Printf(\"failed, using default\\n\");\n    }\n  }\n\t\n  strncpy (q->name, name, sizeof(q->name)-1);\n  if (name[0] != '(')\n  {\n    StripExtension (q->name);\n  }\n\n\tif (!g_dontuse)\n\t\tq->inuse = true;\n\tq->next = g_qeglobals.d_qtextures;\n\tg_qeglobals.d_qtextures = q;\n\t\n\tif (pRemove != NULL)\n\t{\n\t\tReplaceQTexture(pRemove, q, &active_brushes);\n\t\tReplaceQTexture(pRemove, q, &filtered_brushes);\n\t\tTexture_Remove(pRemove);\n\t}\n\t\n\treturn q;\n}\n\n/*\n===============\nTexture_ForNamePath\n===============\n*/\nqtexture_t *Texture_ForNamePath(char* name, char* pFullPath)\n{\n  byte    *lump;\n\tqtexture_t\t*q;\n\tchar\tfilename[1024];\n\n  if (strlen(name) == 0)\n    return notexture;\n\n\tfor (q=g_qeglobals.d_qtextures ; q ; q=q->next)\n  {\n\t  if (!strcmp(name,  q->name))\n\t\t{\n\t\t\tif (!g_dontuse)\n\t\t\t\tq->inuse = true;\n\t\t    return q;\n\t\t}\n  }\n\n\tif (name[0] == '(')\n\t{\n\t\tq = Texture_CreateSolid (name);\n\t\tstrncpy (q->name, name, sizeof(q->name)-1);\n\t}\n\telse\n\t{\n\t\t// load the file\n    if (g_PrefsDlg.m_bHiColorTextures == TRUE)\n    {\n      char cWork[1024];\n      if (strstr(pFullPath, \".tga\") == NULL) {\n        sprintf(filename, \"%s%s\", pFullPath, \".tga\");\n      } else {\n        strcpy(filename, pFullPath);\n      }\n  \t\tQE_ConvertDOSToUnixName( cWork, filename );\n\t    strcpy(filename, cWork);\n\t\t  Sys_Printf (\"Loading %s...\", name);\n      unsigned char* pPixels = NULL;\n      int nWidth;\n      int nHeight;\n      LoadImage(filename, &pPixels, &nWidth, &nHeight);\n      if (!pPixels)\n      {\n        // try jpg\n        // blatant assumption of .tga should be fine since we sprintf'd it above\n        int nLen = strlen(filename);\n        filename[nLen-3] = 'j';\n        filename[nLen-2] = 'p';\n        filename[nLen-1] = 'g';\n\t\t\t\tLoadImage(filename, &pPixels, &nWidth, &nHeight);\n      }\n      if (pPixels)\n      {\n        q = Texture_LoadTGATexture(pPixels, nWidth, nHeight, NULL, 0, 0, 0);\n    \t//++timo storing the filename .. will be removed by shader code cleanup\n\t\t// this is dirty, and we sure miss some places were we should fill the filename info\n\t\t// NOTE: we store relative path, need to extract it\n\t\tstrcpy( q->filename, name );\n\n      }\n      else\n      {\n        return notexture;\n      }\n      free(pPixels);\n    }\n    else\n    {\n      sprintf(filename, \"%s%s\", pFullPath, \".wal\");\n\t\t  Sys_Printf (\"Loading %s...\", name);\n\t\t  if (LoadFile (filename, (void**)&lump) == -1)\n      {\n\t\t\t  Sys_Printf (\" load failed!\\n\");\n\t\t\t  return notexture;\n      }\n      Sys_Printf(\"successful.\\n\");\n\t\t  q = Texture_LoadTexture ((miptex_t *)lump);\n\t\t  free (lump);\n    }\n    if (g_PrefsDlg.m_bSGIOpenGL)\n    {\n\t\t  if(!q)\n\t\t\t  return notexture;\n    }\n\t\tstrncpy (q->name, name, sizeof(q->name)-1);\n\t\tStripExtension (q->name);\n\t}\n\n\tif (!g_dontuse)\n\t\tq->inuse = true;\n\tq->next = g_qeglobals.d_qtextures;\n\tg_qeglobals.d_qtextures = q;\n\n  return q;\n}\n\n\n\n/*\n==================\nFillTextureMenu\n\n==================\n*/\nvoid FillTextureMenu (CStringArray* pArray)\n{\n\tHMENU\thmenu;\n\tint\t\ti;\n\tstruct _finddata_t fileinfo;\n\tint\t\thandle;\n\tchar\tdirstring[1024];\n\tchar\t*path;\n\tDIRLIST\t*list = NULL, *temp;\n\n  if (g_pParentWnd->GetPlugInMgr().GetTextureInfo() != NULL)\n  {\n    if (g_pParentWnd->GetPlugInMgr().GetTextureInfo()->m_bWadStyle)\n      return;\n  }\n\n\thmenu = GetSubMenu (GetMenu(g_qeglobals.d_hwndMain), MENU_TEXTURE);\n\n\t// delete everything\n\tfor (i=0 ; i<texture_nummenus ; i++)\n\t\tDeleteMenu (hmenu, CMD_TEXTUREWAD+i, MF_BYCOMMAND);\n\n  texture_nummenus = 0;\n\n\t// add everything\n  if (g_qeglobals.d_project_entity)\n  {\n    //--if (g_PrefsDlg.m_bUseShaders)\n    //--{\n\t  //--  path = ValueForKey (g_qeglobals.d_project_entity, \"basepath\");\n\t  //--  sprintf (dirstring, \"%s/scripts/*.shader\", path);\n    //--\n    //--}\n    //--else\n    //--{\n\t    path = ValueForKey (g_qeglobals.d_project_entity, \"texturepath\");\n\t    sprintf (dirstring, \"%s/*.*\", path);\n    //--}\n\n\t  handle = _findfirst (dirstring, &fileinfo);\n\t  if (handle != -1)\n    {\n\t    do\n\t    {\n        //--if (g_PrefsDlg.m_bUseShaders)\n        //--{\n\t\t    //--  if ((fileinfo.attrib & _A_SUBDIR))\n        //--    continue;\n        //--}\n        //--else\n        //--{\n\t\t      if (!(fileinfo.attrib & _A_SUBDIR))\n\t\t        continue;\n\t\t      if (fileinfo.name[0] == '.')\n\t\t        continue;\n        //--}\n        // add this directory to the menu\n\t      AddToDirListAlphabetized(&list, fileinfo.name, FROMDISK);\n\t    } while (_findnext( handle, &fileinfo ) != -1);\n\n\t    _findclose (handle);\n    }\n\n    //--if (!g_PrefsDlg.m_bUseShaders)\n    //--{\n      GetPackTextureDirs(&list);\n    //--}\n\n\t  for(temp = list; temp; temp = temp->next)\n\t  {\n\t\t  AppendMenu (hmenu, MF_ENABLED|MF_STRING, CMD_TEXTUREWAD+texture_nummenus, (LPCTSTR)temp->dirname);\n\t\t  strcpy (texture_menunames[texture_nummenus], temp->dirname);\n      //--if (!g_PrefsDlg.m_bUseShaders)\n      //--{\n\t\t    strcat (texture_menunames[texture_nummenus], \"/\");\n      //--}\n      if (pArray)\n        pArray->Add(temp->dirname);\n\t\t  if (++texture_nummenus == MAX_TEXTUREDIRS)\n\t\t   break;\n\t  }\n\n\t  ClearDirList(&list);\n  }\n\n\n}\n\n\n/*\n==================\nTexture_ClearInuse\n\nA new map is being loaded, so clear inuse markers\n==================\n*/\nvoid Texture_ClearInuse (void)\n{\n\tqtexture_t\t*q;\n\n\tfor (q=g_qeglobals.d_qtextures ; q ; q=q->next)\n    {\n\t\tq->inuse = false;\n\t}\n}\n\n\n\n\nvoid LoadShadersFromDir(const char *pPath)\n{\n  int nSize = g_lstShaders.GetSize();\n  for (int i = 0; i < nSize; i++)\n  {\n    CShaderInfo *pInfo = reinterpret_cast<CShaderInfo*>(g_lstShaders.ElementAt(i));\n    if (pInfo != NULL)\n    {\n      if (strstr(pInfo->m_strName, pPath) && pInfo->m_pQTexture == NULL && strstr(pInfo->m_strName, \"models/player\") == NULL)\n      {\n        qtexture_t *q = NULL;\n        DemandLoadShaderTexture(q, pInfo);\n      }\n    }\n  }\n}\n\n\n/*\n==============\nTexture_ShowDirectory\n==============\n*/\nvoid\tTexture_ShowDirectory (int menunum, bool bLinked)\n{\n\tstruct _finddata_t fileinfo;\n\tint\t\thandle;\n\tchar\tname[1024];\n\tchar\tdirstring[1024];\n\tchar\tlinkstring[1024];\n\tFILELIST\t\t\t*list = NULL, *temp;\n  CString strTemp;\n\n  //Texture_Flush(false);\n\t//Select_Deselect();\n\tTexture_ClearInuse();\n\ttexture_showinuse = false;\n\tstrcpy (texture_directory, texture_menunames[menunum-CMD_TEXTUREWAD]);\n\n  if (g_pParentWnd->GetPlugInMgr().GetTextureInfo() != NULL)\n  {\n    if (g_pParentWnd->GetPlugInMgr().GetTextureInfo()->m_bWadStyle)\n      return;\n  }\n\n  // new\n/*\n  if (!g_PrefsDlg.m_bShaderTest)\n  {\n\tg_dontuse = true;\t// needed because this next piece of code calls Texture_ForName() internally! -slc\n    LoadDeferred(texture_directory);\n    g_dontuse = false;\n  }\n*/\n  if (g_PrefsDlg.m_bHiColorTextures == FALSE)\n  {\n  }\n\n\tg_qeglobals.d_texturewin.originy = 0;\n\n  //--if (g_PrefsDlg.m_bUseShaders)\n  //--{\n  //--  sprintf (dirstring, \"%s/scripts/%s\", ValueForKey (g_qeglobals.d_project_entity, \"basepath\"), texture_directory);\n\t//--  Sys_Printf(\"loading textures from shader %s\\n\", dirstring);\n  //--  LoadShader(dirstring);\n  //--}\n  //--else\n  //--{\n\t  Sys_Status(\"Loading textures\\n\", 0);\n\n\t  // load all image files\n                                          \n    sprintf (linkstring, \"%s/textures/%stextureinfo.ini\", ValueForKey (g_qeglobals.d_project_entity, \"basepath\"), texture_menunames[menunum-CMD_TEXTUREWAD]);\n\n    for (int nExt = 0; nExt < GetTextureExtensionCount(); nExt++)\n    {\n      sprintf (dirstring, \"%s/textures/%s*.%s\", ValueForKey (g_qeglobals.d_project_entity, \"basepath\"), texture_menunames[menunum-CMD_TEXTUREWAD],GetTextureExtension(nExt));\n      Sys_Printf (\"Scanning %s\\n\", dirstring);\n\t    handle = _findfirst (dirstring, &fileinfo);\n\n      if (handle == -1)\n      {\n        sprintf(dirstring, \"%s/%s*.%s\", ValueForKey (g_qeglobals.d_project_entity, \"texturepath\"), texture_menunames[menunum-CMD_TEXTUREWAD],GetTextureExtension(nExt));\n        handle = _findfirst (dirstring, &fileinfo);\n      }\n      if (handle != -1)\n\t    {\n\t\t    do\n  \t\t  {\n\t  \t\t  sprintf (name, \"%s%s\", texture_directory, fileinfo.name);\n\t\t  \t  AddToFileListAlphabetized(&list, name, FROMDISK, 0, false);\n  \t\t  } while (_findnext( handle, &fileinfo ) != -1);\n\t  \t  _findclose (handle);\n  \t  }\n\t    else\n\t    {\n\t      sprintf (dirstring, \"%s*.%s\", texture_menunames[menunum-CMD_TEXTUREWAD],GetTextureExtension(nExt));\n  \t\t  GetPackFileList(&list, dirstring);\n\t    }\n    }\n\n\t  g_dontuse = true;\n\t  for(temp = list; temp; temp = temp->next)\n\t  {\n\t\t  if(temp->offset == -1)\n\t\t\t  sprintf(name, \"%s\", temp->filename);\n\t\t  else\n\t\t\t  sprintf(name, \"%s%s\", texture_menunames[menunum-CMD_TEXTUREWAD], temp->filename);\n\t\t  StripExtension (name);\n      strTemp = name;\n      strTemp.MakeLower();\n      if ( strTemp.Find(\".specular\") >= 0 ||\n           strTemp.Find(\".glow\") >= 0 ||\n           strTemp.Find(\".bump\") >= 0 ||\n           strTemp.Find(\".diffuse\") >= 0 ||\n           strTemp.Find(\".blend\") >= 0 ||\n           strTemp.Find(\".alpha\") >= 0\n         )\n        continue;\n      else\n      {\n\t\t    Texture_ForName (name, true);\n      }\n\t  }\n\n\t  ClearFileList(&list);\n  //--}\n\n\n\tg_dontuse = false;\n\n  if (!bLinked)\n  {\n\n    for (int k = 0; k < 10; k++)\n    {\n      sprintf(name, \"Path%d\", k);\n      if (GetPrivateProfileString(\"Include\", name, \"\", dirstring, 1024, linkstring) > 0)\n      {\n        Texture_ShowDirectory(dirstring, true);\n      }\n    }\n\n    LoadShadersFromDir(texture_directory);\n\n    SortTextures();\n\t  \n    sprintf (name, \"Textures: %s\", texture_directory);\n\t  SetWindowText(g_qeglobals.d_hwndEntity, name);\n\n\t  // select the first texture in the list\n\t  if (!g_qeglobals.d_texturewin.texdef.name[0])\n\t\t  SelectTexture (16, g_qeglobals.d_texturewin.height -16, false);\n  }\n}\n\n\n// this can be combined with the above, but per usual i am in a hurry\n//\nvoid\tTexture_ShowDirectory (char* pPath, bool bLinked)\n{\n\tstruct _finddata_t fileinfo;\n\tint\t\thandle;\n\tchar\tname[1024];\n\tchar\tdirstring[1024];\n\tchar\tlinkstring[1024];\n\tFILELIST\t\t\t*list = NULL, *temp;\n\n  //Texture_Flush(false);\n\n\ttexture_showinuse = false;\n\tTexture_ClearInuse();\n\tstrcpy (texture_directory, pPath);\n\n  if (g_PrefsDlg.m_bHiColorTextures == FALSE)\n  {\n  }\n\n\tg_qeglobals.d_texturewin.originy = 0;\n\tSys_Status(\"loading all textures\\n\", 0);\n\n\t// load all .wal files\n  for (int nExt = 0; nExt < GetTextureExtensionCount(); nExt++)\n  {\n    sprintf(dirstring, \"%s*.%s\", pPath,GetTextureExtension(nExt));\n                                          \n\t  Sys_Printf (\"Scanning %s\\n\", dirstring);\n\n\t  handle = _findfirst (dirstring, &fileinfo);\n\n    if (handle != -1)\n\t  {\n\t\t  do\n\t\t  {\n\t\t\t  sprintf (name, \"%s%s\", texture_directory, fileinfo.name);\n\t\t\t  AddToFileListAlphabetized(&list, name, FROMDISK, 0, false);\n\t\t  } while (_findnext( handle, &fileinfo ) != -1);\n\t\t  _findclose (handle);\n\t  }\n\t  else\n\t  {\n\t\t  //sprintf (dirstring, \"%s*.wal\", texture_menunames[menunum-CMD_TEXTUREWAD]);\n\t\t  //if(!GetPackFileList(&list, dirstring))\n\t\t\t  return;\n\t  }\n  }\n\n\tg_dontuse = true;\n\tfor(temp = list; temp; temp = temp->next)\n\t{\n\t\tif(temp->offset == -1)\n\t\t\tsprintf(name, \"%s\", temp->filename);\n\t\telse\n\t\t  sprintf(name, \"%s%s\", pPath, temp->filename);\n\t\tStripExtension (name);\n\n    int nLen = strlen(name)-1;\n    ASSERT(nLen > 0);\n    while (name[nLen] != '\\\\')\n      nLen--;\n    // found first one\n    nLen--;\n    ASSERT(nLen > 0);\n    while (name[nLen] != '\\\\')\n      nLen--;\n    ASSERT(nLen >= 0);\n    QE_ConvertDOSToUnixName(name, name);\n    Texture_ForName(&name[nLen+1]);\n\n\t}\n\n\tClearFileList(&list);\n\n\tg_dontuse = false;\n\n  SortTextures();\n\n  if (!bLinked)\n  {\n\n    for (int k = 0; k < 10; k++)\n    {\n      sprintf(name, \"Path%d\", k);\n      if (GetPrivateProfileString(\"Include\", name, \"\", dirstring, 1024, linkstring) > 0)\n      {\n        Texture_ShowDirectory(dirstring, true);\n      }\n    }\n\n\n\t  sprintf (name, \"Textures: %s\", texture_directory);\n\t  SetWindowText(g_qeglobals.d_hwndEntity, name);\n\n\t  // select the first texture in the list\n\t  if (!g_qeglobals.d_texturewin.texdef.name[0])\n\t\t  SelectTexture (16, g_qeglobals.d_texturewin.height -16 ,false);\n  }\n}\n\n\n\nvoid Texture_ResetPosition()\n{\n  SelectTexture (16, g_qeglobals.d_texturewin.height -16 ,false);\n  g_qeglobals.d_texturewin.originy = 0;\n}\n\n\n\n/*\n==================\nTexture_SetInuse\n\n==================\n*/\nvoid Texture_SetInuse (void)\n{\n\tqtexture_t\t*q;\n\n\tfor (q=g_qeglobals.d_qtextures ; q ; q=q->next)\n  {\n\t\tq->inuse = true;\n\t}\n}\n\n\n/*\n==============\nTexture_ShowAll\n==============\n*/\nvoid\tTexture_ShowAll()\n{\n  Texture_SetInuse();\n\tSys_Printf(\"Showing all textures...\\n\");\n\tSys_UpdateWindows (W_TEXTURE);\n}\n\n/*\n==============\nTexture_ShowInuse\n==============\n*/\nvoid\tTexture_ShowInuse (void)\n{\n\tface_t\t*f;\n\tbrush_t\t*b;\n\tchar\tname[1024];\n\n\ttexture_showinuse = true;\n\tg_dontuse = false;\n\n\tg_qeglobals.d_texturewin.originy = 0;\t\n\n\tTexture_ClearInuse();\n\tSys_Status(\"Selecting active textures\\n\", 0);\n\n\tfor (b=active_brushes.next ; b != NULL && b != &active_brushes ; b=b->next)\n  {\n    if (b->patchBrush)\n    {\n      Texture_ForName(b->pPatch->d_texture->name);\n    }\n    else\n    {\n\t\t  for (f=b->brush_faces ; f ; f=f->next)\n      {\n\t\t\t  Texture_ForName (f->texdef.name);\n      }\n    }\n  }\n\n\tfor (b=selected_brushes.next ; b != NULL && b != &selected_brushes ; b=b->next)\n  {\n    if (b->patchBrush)\n    {\n      Texture_ForName(b->pPatch->d_texture->name);\n    }\n    else\n    {\n\t\t  for (f=b->brush_faces ; f ; f=f->next)\n      {\n\t\t\t  Texture_ForName (f->texdef.name);\n      }\n    }\n  }\n\n\tSortTextures();\n\t//SetInspectorMode(W_TEXTURE);\n\tSys_UpdateWindows (W_TEXTURE);\n\n\tsprintf (name, \"Textures: in use\");\n\tSetWindowText(g_qeglobals.d_hwndEntity, name);\n\n\t// select the first texture in the list\n\tif (!g_qeglobals.d_texturewin.texdef.name[0])\n  {\n\t\tSelectTexture (16, g_qeglobals.d_texturewin.height -16, false);\n  }\n}\n\n/*\n============================================================================\n\nTEXTURE LAYOUT\n\n============================================================================\n*/\n\nvoid Texture_StartPos (void)\n{\n\tcurrent_texture = g_qeglobals.d_qtextures;\n\tcurrent_x = 8;\n\tcurrent_y = -8;\n\tcurrent_row = 0;\n}\n\nqtexture_t *Texture_NextPos (int *x, int *y)\n{\n\tqtexture_t\t*q;\n\n\twhile (1)\n\t{\n\t\tq = current_texture;\n\t\tif (!q)\n\t\t\treturn q;\n\t\tcurrent_texture = current_texture->next;\n\t\tif (q->name[0] == '(')\t// fake color texture\n\t\t\tcontinue;\n\n    if (g_bFilterEnabled)\n    {\n      CString strName = q->name;\n      int nPos = strName.Find('\\\\');\n      if (nPos == -1)\n        nPos = strName.Find('/');\n      if (nPos >= 0)\n        strName = strName.Right(strName.GetLength() - nPos - 1);\n      if (strnicmp(g_strFilter.GetBuffer(0), strName, g_strFilter.GetLength()) == 0)\n        break;\n      else\n        continue;\n    }\n\n    if (q->bFromShader && g_PrefsDlg.m_bShowShaders == FALSE)\n    {\n      continue;\n    }\n\n\t\tif (q->inuse)\n\t\t\tbreak;\t\t\t// always show in use\n    \n    if (!texture_showinuse && !strnicmp (q->name, texture_directory, strlen(texture_directory)))\n\t\t\tbreak;\n\t\tcontinue;\n\t}\n\n  int nWidth = (g_PrefsDlg.m_bHiColorTextures == TRUE) ? q->width * ((float)g_PrefsDlg.m_nTextureScale / 100) : q->width;\n  int nHeight = (g_PrefsDlg.m_bHiColorTextures == TRUE) ? q->height * ((float)g_PrefsDlg.m_nTextureScale / 100) : q->height;\n\tif (current_x + nWidth > g_qeglobals.d_texturewin.width-8 && current_row)\n\t{\t// go to the next row unless the texture is the first on the row\n\t\tcurrent_x = 8;\n\t\tcurrent_y -= current_row + FONT_HEIGHT + 4;\n\t\tcurrent_row = 0;\n\t}\n\n\t*x = current_x;\n\t*y = current_y;\n\n\t// Is our texture larger than the row? If so, grow the \n\t// row height to match it\n\n    if (current_row < nHeight)\n\t\t  current_row = nHeight;\n\n\t// never go less than 64, or the names get all crunched up\n\tcurrent_x += nWidth < 64 ? 64 : nWidth;\n\tcurrent_x += 8;\n\n\treturn q;\n}\n\n/*\n============================================================================\n\n  MOUSE ACTIONS\n\n============================================================================\n*/\n\nstatic\tint\ttextures_cursorx, textures_cursory;\n\n\n/*\n============\nTexture_SetTexture\n\nbrushprimit_texdef must be understood as a qtexture_t with width=2 height=2 ( the default one )\n============\n*/\nvoid Texture_SetTexture (texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale, IPluginTexdef *pTexdef, bool bSetSelection )\n{\n\tqtexture_t\t*q;\n\tint\t\t\tx,y;\n\n\tif (texdef->name[0] == '(')\n\t{\n\t\tSys_Status(\"Can't select an entity texture\\n\", 0);\n\t\treturn;\n\t}\n\tg_qeglobals.d_texturewin.texdef = *texdef;\n\tg_qeglobals.d_texturewin.texdef.flags &= ~SURF_KEEP;\n\tg_qeglobals.d_texturewin.texdef.contents &= ~CONTENTS_KEEP;\n\t// store the texture coordinates for new brush primitive mode\n\t// be sure that all the callers are using the default 2x2 texture\n\tif (g_qeglobals.m_bBrushPrimitMode)\n\t{\n\t\tg_qeglobals.d_texturewin.brushprimit_texdef = *brushprimit_texdef;\n\t}\n\t// surface properties plugin\n\tif (g_qeglobals.bSurfacePropertiesPlugin)\n\t{\n\t\tif (g_qeglobals.d_texturewin.pTexdef)\n\t\t{\n\t\t\t// decrement reference count\n\t\t\tstatic_cast<IPluginTexdef *>(g_qeglobals.d_texturewin.pTexdef)->DecRef();\n\t\t\tg_qeglobals.d_texturewin.pTexdef = NULL;\n\t\t}\n\t\tif (pTexdef)\n\t\t{\n\t\t\tg_qeglobals.d_texturewin.pTexdef = pTexdef->Copy();\n\t\t}\n\t}\n\n\tSys_UpdateWindows (W_TEXTURE);\n\n  g_dlgFind.updateTextures(texdef->name);\n\n  if (!g_dlgFind.isOpen() && bSetSelection)\n  {\n    Select_SetTexture(texdef,brushprimit_texdef,bFitScale);\n  }\n\n\n\t//plugins: send a message telling that the selected texture may have changed\n\tDispatchRadiantMsg( RADIANT_TEXTURE );\n\n\t// scroll origin so the texture is completely on screen\n\tTexture_StartPos ();\n\twhile (1)\n\t{\n\t\tq = Texture_NextPos (&x, &y);\n\t\tif (!q)\n\t\t\tbreak;\n\n    int nWidth = (g_PrefsDlg.m_bHiColorTextures == TRUE) ? q->width * ((float)g_PrefsDlg.m_nTextureScale / 100) : q->width;\n    int nHeight = (g_PrefsDlg.m_bHiColorTextures == TRUE) ? q->height * ((float)g_PrefsDlg.m_nTextureScale / 100) : q->height;\n\t\tif (!strcmpi(texdef->name, q->name))\n\t\t{\n\t\t\tif (y > g_qeglobals.d_texturewin.originy)\n\t\t\t{\n\t\t\t\tg_qeglobals.d_texturewin.originy = y;\n\t\t\t\tSys_UpdateWindows (W_TEXTURE);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (y-nHeight-2*FONT_HEIGHT < g_qeglobals.d_texturewin.originy-g_qeglobals.d_texturewin.height)\n\t\t\t{\n\t\t\t\tg_qeglobals.d_texturewin.originy = y-nHeight-2*FONT_HEIGHT+g_qeglobals.d_texturewin.height;\n\t\t\t\tSys_UpdateWindows (W_TEXTURE);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\t}\n}\n\n\nHWND FindEditWindow()\n{\n  HWND hwnd = FindWindow(\"TEditPadForm\", NULL);\n  HWND hwndEdit = NULL;\n  if (hwnd != NULL)\n  {\n    HWND hwndTab = FindWindowEx(hwnd, NULL, \"TTabControl\", NULL);\n    if (hwndTab != NULL)\n    {\n      hwndEdit = FindWindowEx(hwndTab, NULL, \"TRicherEdit\", NULL);\n    }\n  }\n  return hwndEdit;\n}\n\nvoid Delay(float fSeconds)\n{\n  DWORD dw = ::GetTickCount();\n  DWORD dwTil = dw + (fSeconds * 1000);\n  while (::GetTickCount() < dwTil)\n  {\n    MSG msg;\n    if (::PeekMessage( &msg, NULL, 0, 0, PM_REMOVE )) \n    { \n      TranslateMessage(&msg);\n      DispatchMessage(&msg);\n    }\n  }\n}\n\n\nvoid ViewShader(const char *pFile, const char *pName)\n{\n  CString str;\n  char* pBuff = NULL;\n  int nSize = LoadFile(pFile, reinterpret_cast<void**>(&pBuff));\n  if (nSize == -1)\n  {\n    nSize = PakLoadAnyFile(pFile, reinterpret_cast<void**>(&pBuff));\n  }\n  if (nSize > 0)\n  {\n    str = pBuff;\n  }\n  int nStart = 0; \n  if (str.GetLength() > 0)\n  {\n    CString strFind = pName;\n    CString strLook = str;\n    strLook.MakeLower();\n    strFind.MakeLower();\n    int n = strLook.Find(strFind);\n    if (n >= 0)\n    {\n      nStart = n;\n    }\n  }\n\n  CString s= \"editpad \";\n  s += pFile;\n  WinExec(s, SW_SHOWNORMAL);\n\n  Delay(1.5);\n\n  HWND hwndEdit = FindEditWindow();\n\n  if (hwndEdit != NULL)\n  {\n    PostMessage(hwndEdit, EM_SETSEL, nStart, nStart);\n  }\n  else\n  {\n    Sys_Printf(\"Unable to load shader editor.\\n\");\n  }\n\n\n}\n\n/*\n==============\nSelectTexture\n\n  By mouse click\n==============\n*/\nvoid SelectTexture (int mx, int my, bool bShift, bool bFitScale)\n{\n\tint\t\tx, y;\n\tqtexture_t\t*q;\n\ttexdef_t\ttex;\n\tbrushprimit_texdef_t brushprimit_tex;\n\n\tmy += g_qeglobals.d_texturewin.originy-g_qeglobals.d_texturewin.height;\n\t\n\tTexture_StartPos ();\n\twhile (1)\n\t{\n\t\tq = Texture_NextPos (&x, &y);\n\t\tif (!q)\n\t\t\tbreak;\n\t\tint nWidth = (g_PrefsDlg.m_bHiColorTextures == TRUE) ? q->width * ((float)g_PrefsDlg.m_nTextureScale / 100) : q->width;\n\t\tint nHeight = (g_PrefsDlg.m_bHiColorTextures == TRUE) ? q->height * ((float)g_PrefsDlg.m_nTextureScale / 100) : q->height;\n\t\tif (mx > x && mx - x < nWidth\n\t\t\t&& my < y && y - my < nHeight + FONT_HEIGHT)\n\t\t{\n\t\t\tif (bShift)\n\t\t\t{\n\t\t\t\tif (g_PrefsDlg.m_bHiColorTextures && q->shadername[0] != 0)\n\t\t\t\t{\n\t\t\t\t\t//CString s = \"notepad \";\n\t\t\t\t\t//s += q->shadername;\n\t\t\t\t\t//WinExec(s, SW_SHOWNORMAL);\t\n\t\n\t\t\t\t\tViewShader(q->shadername, q->name);\t\t\t\t\n\n\t\t\t\t}\n\t\t\t}\n\t\t\tmemset (&tex, 0, sizeof(tex));\n\t\t\tmemset (&brushprimit_tex, 0, sizeof(brushprimit_tex));\n\t\t\tif (g_qeglobals.m_bBrushPrimitMode)\n\t\t\t{\n\t\t\t\t// brushprimit fitted to a 2x2 texture\n\t\t\t\tbrushprimit_tex.coords[0][0] = 1.0f;\n\t\t\t\tbrushprimit_tex.coords[1][1] = 1.0f;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttex.scale[0] = (g_PrefsDlg.m_bHiColorTextures) ? 0.5 : 1;\n\t\t\t\ttex.scale[1] = (g_PrefsDlg.m_bHiColorTextures) ? 0.5 : 1;\n\t\t\t}\n\t\t\ttex.flags = q->flags;\n\t\t\ttex.value = q->value;\n\t\t\ttex.contents = q->contents;\n\t\t\t//strcpy (tex.name, q->name);\n\t\t\ttex.SetName(q->name);\n\t\t\tTexture_SetTexture ( &tex, &brushprimit_tex, bFitScale, GETPLUGINTEXDEF(q));\n\t\t\tCString strTex;\n\t\t\tCString strName = q->name;\n\t\t\t//int nPos = strName.Find('\\\\');\n\t\t\t//if (nPos == -1)\n\t\t\t//  nPos = strName.Find('/');\n\t\t\t//if (nPos >= 0)\n\t\t\t//  strName = strName.Right(strName.GetLength() - nPos - 1);\n\t\t\tstrTex.Format(\"%s W: %i H: %i\", strName.GetBuffer(0), q->width, q->height);\n\t\t\tg_pParentWnd->SetStatusText(3, strTex);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tSys_Status(\"Did not select a texture\\n\", 0);\n}\n\n/*\n==============\nTexture_MouseDown\n==============\n*/\nvoid Texture_MouseDown (int x, int y, int buttons)\n{\n\tSys_GetCursorPos (&textures_cursorx, &textures_cursory);\n\n\t// lbutton = select texture\n\tif (buttons == MK_LBUTTON || buttons == (MK_LBUTTON | MK_SHIFT) || buttons == (MK_LBUTTON | MK_CONTROL))\n\t{\n    SelectTexture (x, g_qeglobals.d_texturewin.height - 1 - y, buttons & MK_SHIFT, buttons & MK_CONTROL);\n    UpdateSurfaceDialog();\n    UpdatePatchInspector();\n\t}\n}\n\n/*\n==============\nTexture_MouseUp\n==============\n*/\nvoid Texture_MouseUp (int x, int y, int buttons)\n{\n}\n\n/*\n==============\nTexture_MouseMoved\n==============\n*/\nvoid Texture_MouseMoved (int x, int y, int buttons)\n{\n\tint scale = 1;\n\n\tif ( buttons & MK_SHIFT )\n\t\tscale = 4;\n\n\t// rbutton = drag texture origin\n\tif (buttons & MK_RBUTTON)\n\t{\n\t\tSys_GetCursorPos (&x, &y);\n\t\tif ( y != textures_cursory)\n\t\t{\n\t\t\tg_qeglobals.d_texturewin.originy += ( y-textures_cursory) * scale;\n\t\t\tif (g_qeglobals.d_texturewin.originy > 0)\n\t\t\t\tg_qeglobals.d_texturewin.originy = 0;\n\t\t\tSys_SetCursorPos (textures_cursorx, textures_cursory);\n      CWnd *pWnd = CWnd::FromHandle(g_qeglobals.d_hwndTexture);\n      if (g_PrefsDlg.m_bTextureScrollbar && pWnd != NULL)\n      {\n        pWnd->SetScrollPos(SB_VERT, abs(g_qeglobals.d_texturewin.originy));\n      }\n\t\t  InvalidateRect(g_qeglobals.d_hwndTexture, NULL, false);\n\t\t  UpdateWindow (g_qeglobals.d_hwndTexture);\n\t\t}\n\t\treturn;\n\t}\n}\n\n\n/*\n============================================================================\n\nDRAWING\n\n============================================================================\n*/\n\nint imax(int iFloor, int i) { if (i>iFloor) return iFloor; return i; }\nHFONT ghFont = NULL;\n\n/*\n============\nTexture_Draw2\n============\n*/\nvoid Texture_Draw2 (int width, int height)\n{\n\tqtexture_t\t*q;\n\tint\t\t\tx, y;\n\tchar\t\t*name;\n\n\tqglClearColor (\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][0],\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][1],\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][2],\n\t\t0);\n\tqglViewport (0,0,width,height);\n\tqglMatrixMode(GL_PROJECTION);\n\tqglLoadIdentity ();\n\n\tqglClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);\n\tqglDisable (GL_DEPTH_TEST);\n\tqglDisable(GL_BLEND);\n\tqglOrtho (0, width, g_qeglobals.d_texturewin.originy-height, g_qeglobals.d_texturewin.originy, -100, 100);\n\tqglEnable (GL_TEXTURE_2D);\n\n\tqglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);\n\tg_qeglobals.d_texturewin.width = width;\n\tg_qeglobals.d_texturewin.height = height;\n\tTexture_StartPos ();\n\n\twhile (1)\n\t{\n\t\tq = Texture_NextPos (&x, &y);\n\t\tif (!q)\n\t\t\tbreak;\n\n    int nWidth = (g_PrefsDlg.m_bHiColorTextures == TRUE) ? q->width * ((float)g_PrefsDlg.m_nTextureScale / 100) : q->width;\n    int nHeight = (g_PrefsDlg.m_bHiColorTextures == TRUE) ? q->height * ((float)g_PrefsDlg.m_nTextureScale / 100) : q->height;\n\t\t// Is this texture visible?\n\t\tif ( (y-nHeight-FONT_HEIGHT < g_qeglobals.d_texturewin.originy)\n\t\t\t&& (y > g_qeglobals.d_texturewin.originy - height) )\n\t\t{\n\n\t\t\t// if in use, draw a background\n\t\t\tif ((q->inuse && !texture_showinuse) || q->bFromShader)\n\t\t\t{\n\t\t\t\tqglLineWidth (1);\n\n        if (q->bFromShader)\n        {\n\t\t\t\t  qglColor3f (1,1,1);\n        }\n        else\n        {\n\t\t\t\t  qglColor3f (0.5,1,0.5);\n        }\n\t\t\t\tqglDisable (GL_TEXTURE_2D);\n\n\t\t\t\tqglBegin (GL_LINE_LOOP);\n\t\t\t\tqglVertex2f (x-1,y+1-FONT_HEIGHT);\n\t\t\t\tqglVertex2f (x-1,y-nHeight-1-FONT_HEIGHT);\n\t\t\t\tqglVertex2f (x+1+nWidth,y-nHeight-1-FONT_HEIGHT);\n\t\t\t\tqglVertex2f (x+1+nWidth,y+1-FONT_HEIGHT);\n\t\t\t\tqglEnd ();\n\n\t\t\t\tqglEnable (GL_TEXTURE_2D);\n\t\t\t}\n\n\t\t\t// Draw the texture\n      float fScale = (g_PrefsDlg.m_bHiColorTextures == TRUE) ? ((float)g_PrefsDlg.m_nTextureScale / 100) : 1.0;\n\n\t\t\tqglBindTexture( GL_TEXTURE_2D, q->texture_number );\n      QE_CheckOpenGLForErrors();\n\t\t\tqglColor3f (1,1,1);\n\t\t\tqglBegin (GL_QUADS);\n\t\t\tqglTexCoord2f (0,0);\n\t\t\tqglVertex2f (x,y-FONT_HEIGHT);\n\t\t\tqglTexCoord2f (1,0);\n\t\t\tqglVertex2f (x+nWidth,y-FONT_HEIGHT);\n\t\t\tqglTexCoord2f (1,1);\n\t\t\tqglVertex2f (x+nWidth,y-FONT_HEIGHT-nHeight);\n\t\t\tqglTexCoord2f (0,1);\n\t\t\tqglVertex2f (x,y-FONT_HEIGHT-nHeight);\n\t\t\tqglEnd ();\n\n\t\t\t// draw the selection border\n\t\t\tif (!strcmpi(g_qeglobals.d_texturewin.texdef.name, q->name))\n\t\t\t{\n\t\t\t\tqglLineWidth (3);\n\t\t\t\tqglColor3f (1,0,0);\n\t\t\t\tqglDisable (GL_TEXTURE_2D);\n\n\t\t\t\tqglBegin (GL_LINE_LOOP);\n\t\t\t\tqglVertex2f (x-4,y-FONT_HEIGHT+4);\n\t\t\t\tqglVertex2f (x-4,y-FONT_HEIGHT-nHeight-4);\n\t\t\t\tqglVertex2f (x+4+nWidth,y-FONT_HEIGHT-nHeight-4);\n\t\t\t\tqglVertex2f (x+4+nWidth,y-FONT_HEIGHT+4);\n\t\t\t\tqglEnd ();\n\n\t\t\t\tqglEnable (GL_TEXTURE_2D);\n\t\t\t\tqglLineWidth (1);\n\t\t\t}\n\n\t\t\t// draw the texture name\n  \t  qglColor3f (0,0,0);\n\t\t\t\n      qglRasterPos2f (x, y-FONT_HEIGHT+2);\n\n\t\t\t// don't draw the directory name\n\t\t\tfor (name = q->name ; *name && *name != '/' && *name != '\\\\' ; name++)\n\t\t\t\t;\n\t\t\tif (!*name)\n\t\t\t\tname = q->name;\n\t\t\telse\n\t\t\t\tname++;\n\n      if (g_PrefsDlg.m_bHiColorTextures && q->shadername[0] != 0)\n      {\n        // slow as shit\n        CString s = \"[\";\n        s += name;\n        s += \"]\";\n\t\t\t  qglCallLists (s.GetLength(), GL_UNSIGNED_BYTE, s.GetBuffer(0));\n      }\n      else\n      {\n\t\t\t  qglCallLists (strlen(name), GL_UNSIGNED_BYTE, name);\n      }\n\t\t}\n\t}\n\n\tg_qeglobals.d_texturewin.m_nTotalHeight = abs(y) + 100;\n\t// reset the current texture\n\tqglBindTexture( GL_TEXTURE_2D, 0 );\n\tqglFinish();\n}\n\n\nvoid Texture_Init (bool bHardInit)\n{\n\tchar\tname[1024];\n\tbyte\t*pal = NULL;\n\n  if (g_PrefsDlg.m_bHiColorTextures == FALSE)\n  {\n\t  // load the palette\n\t  sprintf (name, \"%s/pics/colormap.pcx\", ValueForKey (g_qeglobals.d_project_entity, \"basepath\"));\n\n\t  Load256Image (name, NULL, &pal, NULL, NULL);\n\t  if (!pal)\n    {\n      // before dropping out, try to load it from the QERadiant directory\n      CString strFile = g_strAppPath;\n      AddSlash(strFile);\n      strFile += \"colormap.pcx\";\n\t    Load256Image (strFile.GetBuffer(0), NULL, &pal, NULL, NULL);\n\t    if (!pal)\n\t\t    Sys_Printf (\"Couldn't load %s or %s\", name, strFile);\n    }\n    else\n    {\n\t    Texture_InitPalette (pal);\n\t    free (pal);\n    }\n  }\n\n\t// create the fallback texture\n\n  if (bHardInit)\n  {\n\t  Texture_MakeNotexture();\n\t  g_qeglobals.d_qtextures = NULL;\n  }\n  LoadShaders();\n\n}\n\nvoid Texture_FlushUnused()\n{\n  CWaitCursor cursor;\n  Texture_ShowInuse();\n  if (g_qeglobals.d_qtextures)\n  {\n\t  qtexture_t* pTex = g_qeglobals.d_qtextures->next;\n    qtexture_t *pPrev = g_qeglobals.d_qtextures;\n    while (pTex != NULL && pTex != g_qeglobals.d_qtextures)\n    {\n      qtexture_t* pNextTex = pTex->next;\n  \t  if (g_qeglobals.bSurfacePropertiesPlugin)\n\t    {\n\t\t    // Timo\n\t\t    // Surface properties plugin\n#ifdef _DEBUG\n  \t\t  if ( !pTex->pData )\n\t  \t\t  Sys_Printf(\"WARNING: found a qtexture_t* with no IPluginQTexture\\n\");\n#endif\n  \t\t  if ( pTex->pData && pTex->inuse )\n\t  \t\t  GETPLUGINTEXDEF(pTex)->DecRef();\n  \t  }\n\n      if (!pTex->inuse)\n      {\n        unsigned int nTexture = pTex->texture_number;\n        qglDeleteTextures(1, &nTexture);\n        pPrev->next = pNextTex;\n\t      free(pTex);\n      }\n      else\n      {\n        pPrev = pTex;\n      }\n      pTex = pNextTex;\n    }\n  }\n}\n\nvoid Texture_Cleanup(CStringList *pList)\n{\n  if (g_qeglobals.d_qtextures)\n  {\n\t  qtexture_t* pTex = g_qeglobals.d_qtextures->next;\n    while (pTex != NULL && pTex != g_qeglobals.d_qtextures)\n    {\n      qtexture_t* pNextTex = pTex->next;\n      if (pList)\n      {\n        if (pTex->name[0] != '(')\n        {\n          pList->AddTail(pTex->name);\n        }\n      }\n\n  \t  if (g_qeglobals.bSurfacePropertiesPlugin)\n\t    {\n\t\t    // Timo\n\t\t    // Surface properties plugin\n#ifdef _DEBUG\n  \t\t  if ( !pTex->pData )\n\t  \t\t  Sys_Printf(\"WARNING: found a qtexture_t* with no IPluginQTexture\\n\");\n#endif\n  \t\t  if ( pTex->pData )\n\t  \t\t  GETPLUGINTEXDEF(pTex)->DecRef();\n  \t  }\n\t    free(pTex);\n      pTex = pNextTex;\n    }\n  }\n\n  int nSize = g_lstSkinCache.GetSize();\n  for (int i = 0; i < nSize; i++)\n  {\n    SkinInfo *pInfo = reinterpret_cast<SkinInfo*>(g_lstSkinCache.GetAt(i));\n    delete pInfo;\n  }\n\n}\n\n/*\n==================\nTexture_Flush\n==================\n*/\nvoid Texture_Flush (bool bReload)\n{\n  if (!ConfirmModified())\n    return;\n\n  Map_New ();\n\n  CWaitCursor cursor;\n  CStringList strList;\n  Texture_Init(false);\n  Texture_Cleanup(&strList);\n\n  GLuint* pGln = new GLuint[texture_extension_number-1];\n  qglGenTextures(texture_extension_number-1, pGln);\n  QE_CheckOpenGLForErrors();\n  qglDeleteTextures(texture_extension_number-1, pGln);\n  QE_CheckOpenGLForErrors();\n  delete []pGln;\n  texture_extension_number = 1;\n\tg_qeglobals.d_qtextures = NULL;\n\n  if (bReload)\n  {\n    POSITION pos = strList.GetHeadPosition();\n    while (pos)\n    {\n      CString strTex = strList.GetNext(pos);\n\t\t  Texture_ForName (strTex.GetBuffer(0));\n    }\n  }\n\n}\n\n\n\n/////////////////////////////////////////////////////////////////////////////\n// CTexWnd\nIMPLEMENT_DYNCREATE(CTexWnd, CWnd);\n\nCTexWnd::CTexWnd()\n{\n  m_bNeedRange = true;\n}\n\nCTexWnd::~CTexWnd()\n{\n}\n\n\nBEGIN_MESSAGE_MAP(CTexWnd, CWnd)\n\t//{{AFX_MSG_MAP(CTexWnd)\n\tON_WM_CREATE()\n\tON_WM_SIZE()\n\tON_WM_PARENTNOTIFY()\n\tON_WM_TIMER()\n\tON_WM_KEYDOWN()\n\tON_WM_KEYUP()\n\tON_WM_PAINT()\n\tON_WM_VSCROLL()\n\tON_COMMAND(ID_TEXTURES_FLUSH, OnTexturesFlush)\n  ON_BN_CLICKED(1200, OnShaderClick)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n\n/////////////////////////////////////////////////////////////////////////////\n// CTexWnd message handlers\n\n/*\n============\nWTexWndProc\n============\n*/\nLONG WINAPI TexWndProc (\n    HWND    hWnd,\n    UINT    uMsg,\n    WPARAM  wParam,\n    LPARAM  lParam)\n{\n\tint\t\txPos, yPos;\n    RECT\trect;\n\n    GetClientRect(hWnd, &rect);\n\n    switch (uMsg)\n    {\n\tcase WM_CREATE:\n    s_hdcTexture = GetDC(hWnd);\n\t\tQEW_SetupPixelFormat(s_hdcTexture, false);\n\n\t\tif ( ( s_hglrcTexture = qwglCreateContext( s_hdcTexture ) ) == 0 )\n\t\t\tError( \"wglCreateContext in WTex_WndProc failed\" );\n\n\t\tif (!qwglShareLists( g_qeglobals.d_hglrcBase, s_hglrcTexture ) )\n\t\t\tError( \"wglShareLists in WTex_WndProc failed\" );\n\n    if (!qwglMakeCurrent( s_hdcTexture, s_hglrcTexture ))\n\t\t  Error (\"wglMakeCurrent in WTex_WndProc failed\");\n\n\t  g_qeglobals.d_hwndTexture = hWnd;\n\t\treturn 0;\n\n\tcase WM_DESTROY:\n\t\t//wglMakeCurrent( NULL, NULL );\n\t\t//wglDeleteContext( s_hglrcTexture );\n\t\t ReleaseDC( hWnd, s_hdcTexture );\n\t\treturn 0;\n#if 0\n\tcase WM_PAINT:\n        { \n\t\t    PAINTSTRUCT\tps;\n\n\t\t    BeginPaint(hWnd, &ps);\n\n        if ( !qwglMakeCurrent( s_hdcTexture, s_hglrcTexture ) )\n        //if ( !wglMakeCurrent( ps.hdc, s_hglrcTexture ) )\n        {\n          Sys_Printf(\"ERROR: wglMakeCurrent failed..\\n \");\n          Sys_Printf(\"Please restart Q3Radiant if the Texture view is not working\\n\");\n        }\n        else\n        {\n\t\t\t    Texture_Draw2 (rect.right-rect.left, rect.bottom-rect.top - g_nTextureOffset);\n\t\t\t    qwglSwapBuffers(s_hdcTexture);\n          TRACE(\"Texture Paint\\n\");\n        }\n\t\t    EndPaint(hWnd, &ps);\n        }\n\t\treturn 0;\n#endif\n\tcase WM_MBUTTONDOWN:\n\tcase WM_RBUTTONDOWN:\n\tcase WM_LBUTTONDOWN:\n\t\tSetCapture( g_qeglobals.d_hwndTexture );\n\t\txPos = (short)LOWORD(lParam);  // horizontal position of cursor \n\t\tyPos = (short)HIWORD(lParam);  // vertical position of cursor \n\t\t\n\t\tTexture_MouseDown (xPos, yPos - g_nTextureOffset, wParam);\n\t\treturn 0;\n\n\tcase WM_MBUTTONUP:\n\tcase WM_RBUTTONUP:\n\tcase WM_LBUTTONUP:\n\t\txPos = (short)LOWORD(lParam);  // horizontal position of cursor \n\t\tyPos = (short)HIWORD(lParam);  // vertical position of cursor \n\t\t\n\t\tTexture_MouseUp (xPos, yPos - g_nTextureOffset, wParam);\n\t\tif (! (wParam & (MK_LBUTTON|MK_RBUTTON|MK_MBUTTON)))\n\t\t\tReleaseCapture ();\n\t\treturn 0;\n\n\tcase WM_MOUSEMOVE:\n\t\txPos = (short)LOWORD(lParam);  // horizontal position of cursor \n\t\tyPos = (short)HIWORD(lParam);  // vertical position of cursor \n\t\t\n\t\tTexture_MouseMoved (xPos, yPos - g_nTextureOffset, wParam);\n\t\treturn 0;\n    }\n\n    return DefWindowProc (hWnd, uMsg, wParam, lParam);\n}\n\n\n\nBOOL CTexWnd::PreCreateWindow(CREATESTRUCT& cs) \n{\n  WNDCLASS wc;\n  HINSTANCE hInstance = AfxGetInstanceHandle();\n  if (::GetClassInfo(hInstance, TEXTURE_WINDOW_CLASS, &wc) == FALSE)\n  {\n    // Register a new class\n  \tmemset (&wc, 0, sizeof(wc));\n    wc.style         = CS_NOCLOSE | CS_OWNDC;\n    wc.lpszClassName = TEXTURE_WINDOW_CLASS;\n    wc.hCursor       = LoadCursor (NULL,IDC_ARROW);\n    wc.lpfnWndProc = TexWndProc;\n    if (AfxRegisterClass(&wc) == FALSE)\n      Error (\"CZWnd RegisterClass: failed\");\n  }\n\n  cs.lpszClass = TEXTURE_WINDOW_CLASS;\n  cs.lpszName = \"TEX\";\n  if (cs.style != QE3_CHILDSTYLE && cs.style != QE3_STYLE)\n    cs.style = QE3_SPLITTER_STYLE;\n\n\treturn CWnd::PreCreateWindow(cs);\n}\n\nint CTexWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) \n{\n\tif (CWnd::OnCreate(lpCreateStruct) == -1)\n\t\treturn -1;\n\n  CRect rctEdit(8, 5, 20, 20);\n  g_nTextureOffset = 0;\n\n/*\n  if (g_PrefsDlg.m_bShaderTest)\n  {\n    m_wndShaders.Create(\"Show Shaders\", WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, rctEdit, this, 1200);\n    m_wndShaders.ModifyStyleEx(0, WS_EX_CLIENTEDGE, 0);\n    m_wndShaders.SetCheck(g_PrefsDlg.m_bShowShaders);\n    g_nTextureOffset = 25;\n  }\n*/\n  rctEdit.SetRect(8, g_nTextureOffset, 20, 20);\n  m_wndFilter.Create(WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | ES_LEFT, rctEdit, this, 1201);\n  m_wndFilter.ModifyStyleEx(0, WS_EX_CLIENTEDGE, 0);\n  m_wndFilter.SetTexWnd(this);\n\n  g_nTextureOffset += 25;\n  if (!g_PrefsDlg.m_bTextureWindow)\n  {\n    m_wndFilter.ShowWindow(SW_HIDE);\n    g_nTextureOffset -= 25;\n  }\n\n  ShowScrollBar(SB_VERT, g_PrefsDlg.m_bTextureScrollbar);\n  m_bNeedRange = true;\n\n\treturn 0;\n}\n\nvoid CTexWnd::OnSize(UINT nType, int cx, int cy) \n{\n\tCWnd::OnSize(nType, cx, cy);\n  CRect rctClient;\n  GetClientRect(rctClient);\n/*\n  if (g_PrefsDlg.m_bShaderTest && m_wndShaders.GetSafeHwnd())\n  {\n    m_wndShaders.SetWindowPos(NULL, rctClient.left + 8, rctClient.top + 5, rctClient.right - 16, 20, 0);\n  }\n*/\n  m_wndFilter.SetWindowPos(NULL, rctClient.left + 8, rctClient.top + 25, rctClient.right - 16, 20, 0);\n  m_bNeedRange = true;\n}\n\nvoid CTexWnd::OnShaderClick()\n{\n  g_PrefsDlg.m_bShowShaders = (m_wndShaders.GetCheck() != 0);\n  g_PrefsDlg.SavePrefs();\n\tRedrawWindow();\n}\n\nvoid CTexWnd::OnParentNotify(UINT message, LPARAM lParam) \n{\n\tCWnd::OnParentNotify(message, lParam);\n}\n\nint g_nLastLen = 0;\nint g_nTimerHandle = -1;\nchar g_cLastChar;\n\nvoid CTexWnd::UpdateFilter(const char* pFilter)\n{\n  if (g_nTimerHandle > 0)\n    KillTimer(1);\n  g_bFilterEnabled = false;\n  if (pFilter)\n  {\n    g_strFilter = pFilter;\n    if (g_strFilter.GetLength() > 0)\n    {\n      g_bFilterEnabled = true;\n      if (g_pParentWnd->CurrentStyle() == QR_QE4 || g_pParentWnd->CurrentStyle() == QR_4WAY)\n      {\n        if (g_strFilter.GetLength() > g_nLastLen)\n        {\n          g_cLastChar = toupper(g_strFilter.GetAt(g_strFilter.GetLength()-1));\n          if (g_cLastChar == 'N' || g_cLastChar == 'O') // one of the other popups\n          {\n            g_nTimerHandle = SetTimer(1, 800, NULL);   // half second timer\n          }\n        }\n      }\n    }\n    g_nLastLen = g_strFilter.GetLength();\n\t  SortTextures();\n  }\n  Sys_UpdateWindows (W_TEXTURE);\n}\n\nvoid CTexWnd::UpdatePrefs()\n{\n  if (!g_PrefsDlg.m_bTextureWindow)\n  {\n    m_wndFilter.ShowWindow(SW_HIDE);\n    g_nTextureOffset = 0;\n  }\n  else\n  {\n    m_wndFilter.ShowWindow(SW_SHOW);\n    g_nTextureOffset = 25;\n  }\n  ShowScrollBar(SB_VERT, g_PrefsDlg.m_bTextureScrollbar);\n  m_bNeedRange = true;\n  Invalidate();\n  UpdateWindow();\n}\n\nvoid CTexWnd::FocusEdit()\n{\n  if (m_wndFilter.IsWindowVisible())\n    m_wndFilter.SetFocus();\n}\n\nvoid CTexWnd::OnTimer(UINT nIDEvent) \n{\n  KillTimer(1);\n  g_nLastLen = 0;\n  g_nTimerHandle = -1;\n  ::SetFocus(g_qeglobals.d_hwndEntity);\n  ::PostMessage(g_qeglobals.d_hwndEntity, WM_CHAR, g_cLastChar, 0);\n}\n\nvoid CTexWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) \n{\n  g_pParentWnd->HandleKey(nChar, nRepCnt, nFlags);\n\t//CWnd::OnKeyDown(nChar, nRepCnt, nFlags);\n}\n\nvoid CTexWnd::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) \n{\n  g_pParentWnd->HandleKey(nChar, nRepCnt, nFlags, false);\n}\n\nvoid CTexWnd::OnPaint() \n{\n\tCPaintDC dc(this); // device context for painting\n  CRect rctClient;\n  GetClientRect(rctClient);\n  int nOld = g_qeglobals.d_texturewin.m_nTotalHeight;\n  if (!qwglMakeCurrent(s_hdcTexture, s_hglrcTexture))\n  //if ( !qwglMakeCurrent(dc.m_hDC, s_hglrcTexture ) )\n  {\n    Sys_Printf(\"ERROR: wglMakeCurrent failed..\\n \");\n    Sys_Printf(\"Please restart Q3Radiant if the Texture view is not working\\n\");\n  }\n  else\n  {\n    Texture_Draw2 (rctClient.right-rctClient.left, rctClient.bottom-rctClient.top - g_nTextureOffset);\n\t\tqwglSwapBuffers(s_hdcTexture);\n    TRACE(\"Texture Paint\\n\");\n  }\n  if (g_PrefsDlg.m_bTextureScrollbar && (m_bNeedRange || g_qeglobals.d_texturewin.m_nTotalHeight != nOld))\n  {\n    m_bNeedRange = false;\n    SetScrollRange(SB_VERT, 0, g_qeglobals.d_texturewin.m_nTotalHeight, TRUE);\n  }\n}\n\nvoid CTexWnd::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) \n{\n\tCWnd::OnVScroll(nSBCode, nPos, pScrollBar);\n\n  int n = GetScrollPos(SB_VERT);;\n  switch (nSBCode)\n  {\n    case SB_LINEUP :\n    {\n      n = (n - 15 >  0) ? n - 15 : 0; \n      break;\n    }\n    case SB_LINEDOWN :\n    {\n      n = (n + 15 < g_qeglobals.d_texturewin.m_nTotalHeight) ? n + 15 : n; \n      break;\n    }\n    case SB_PAGEUP :\n    {\n      n = (n - g_qeglobals.d_texturewin.height >  0) ? n - g_qeglobals.d_texturewin.height : 0; \n      break;\n    }\n    case SB_PAGEDOWN :\n    {\n      n = (n + g_qeglobals.d_texturewin.height < g_qeglobals.d_texturewin.m_nTotalHeight) ? n + g_qeglobals.d_texturewin.height : n; \n      break;\n    }\n    case SB_THUMBPOSITION :\n    {\n      n = nPos;\n      break;\n    }\n    case SB_THUMBTRACK :\n    {\n      n = nPos;\n      break;\n    }\n  }\n  SetScrollPos(SB_VERT, n);\n\tg_qeglobals.d_texturewin.originy = -((int)n);\n  Invalidate();\n  UpdateWindow();\n  //Sys_UpdateWindows(W_TEXTURE);\n}\n\n/*\nand are the caps new caps?  anything done with older stuff will be fubar'd.. which brings up the point if you ever naturalize a cap, you cannot force it back to cap texturing.. i will add that too\n*/\n\nvoid CTexWnd::OnTexturesFlush() \n{\n\t// TODO: Add your command handler code here\n\t\n}\n\nvoid LoadShaders()\n{\n\tchar\tdirstring[1024];\n\tchar\t*path;\n\t//struct _finddata_t fileinfo;\n\t//int\t\thandle;\n  path = ValueForKey (g_qeglobals.d_project_entity, \"basepath\");\n  sprintf (dirstring, \"%s/scripts/shaderlist.txt\", path);\n  char *pBuff = NULL;\n  \n  int nLen = LoadFile(dirstring, reinterpret_cast<void**>(&pBuff));\n  if (nLen == -1)\n  {\n    nLen = PakLoadAnyFile(dirstring, reinterpret_cast<void**>(&pBuff));\n  }\n  if (nLen > 0)\n  {\n    CStringList lst;\n    StartTokenParsing(pBuff);\n    nLen = 0;\n    while (GetToken(true))\n    {\n      // each token should be a shader filename\n      sprintf(dirstring, \"%s/scripts/%s.shader\", path, token);\n      lst.AddTail(dirstring);\n      nLen++;\n    }\n    POSITION pos = lst.GetHeadPosition();\n    while (pos != NULL)\n    {\n      LoadShader(lst.GetAt(pos).GetBuffer(0), NULL);\n      lst.GetNext(pos);\n    }\n    free(pBuff);\n  }\n  else\n  {\n    Sys_Printf(\"Unable to load shaderlist.txt, shaders not loaded!\");\n  }\n\n/*\n  handle = _findfirst (dirstring, &fileinfo);\n  if (handle != -1)\n  {\n    do\n    {\n      if ((fileinfo.attrib & _A_SUBDIR))\n        continue;\n      sprintf(dirstring, \"%s/scripts/%s\", path, fileinfo.name);\n      LoadShader(dirstring, NULL);\n\t  } while (_findnext( handle, &fileinfo ) != -1);\n\n\t  _findclose (handle);\n  }\n*/\n}\n\nvoid FreeShaders()\n{\n  int nSize = g_lstShaders.GetSize();\n  for (int i = 0; i < nSize; i++)\n  {\n    CShaderInfo *pInfo = reinterpret_cast<CShaderInfo*>(g_lstShaders.ElementAt(i));\n    delete pInfo;\n  }\n\n  g_lstShaders.RemoveAll();\n}\n\nvoid ReloadShaders()\n{\n  FreeShaders();\n  LoadShaders();\n  qtexture_t* pTex = g_qeglobals.d_qtextures;\n  while (pTex != NULL)\n  {\n    SetNameShaderInfo(pTex, NULL, pTex->name);\n    pTex = pTex->next;\n  }\n\n}\n\nint WINAPI Texture_LoadSkin(char *pName, int *pnWidth, int *pnHeight)\n{\n  byte *pic = NULL;\n  byte *pic32 = NULL;\n  int nTex = -1;\n\n  strlwr(pName);\n  QE_ConvertDOSToUnixName(pName, pName);\n\n  int nSize = g_lstSkinCache.GetSize();\n  for (int i = 0; i < nSize; i++)\n  {\n    SkinInfo *pInfo = reinterpret_cast<SkinInfo*>(g_lstSkinCache.GetAt(i));\n    if (pInfo)\n    {\n      if (stricmp(pName, pInfo->m_strName) == 0)\n      {\n        return pInfo->m_nTextureBind;\n      }\n    }\n  }\n\n  LoadImage( pName, &pic32, pnWidth, pnHeight);\n  if (pic32 != NULL)\n  {\n\n    nTex = texture_extension_number++;\n    if (g_PrefsDlg.m_bSGIOpenGL)\n    {\n      //if (!qwglMakeCurrent(g_qeglobals.d_hdcBase, g_qeglobals.d_hglrcBase))\n      if (!qwglMakeCurrent(s_hdcTexture, s_hglrcTexture))\n\t\t    Error (\"wglMakeCurrent in LoadTexture failed\");\n    }\n\n    qglBindTexture( GL_TEXTURE_2D, nTex);\n    SetTexParameters ();\n\n\t  int nCount = MAX_TEXTURE_QUALITY - g_PrefsDlg.m_nTextureQuality;\n\t  while (nCount-- > 0)\n\t  {\n\t    if (*pnWidth > 16 && *pnHeight > 16)\n\t    {\n\t      R_MipMap(pic32, *pnWidth, *pnHeight);\n\t    }\n\t    else\n\t    {\n\t      break;\n\t    }\n\t  }\n\n    if (g_PrefsDlg.m_bSGIOpenGL)\n    {\n\t    if (nomips)\n      {\n\t\t    qglTexImage2D(GL_TEXTURE_2D, 0, 3, *pnWidth, *pnHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, pic32);\n      }\n\t    else\n\t\t    qgluBuild2DMipmaps(GL_TEXTURE_2D, 3, *pnWidth, *pnHeight,GL_RGBA, GL_UNSIGNED_BYTE, pic32);\n    }\n    else\n    {\n\t    if (nomips)\n\t\t    qglTexImage2D(GL_TEXTURE_2D, 0, 3, *pnWidth, *pnHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, pic32);\n\t    else\n\t\t    qgluBuild2DMipmaps(GL_TEXTURE_2D, 3, *pnWidth, *pnHeight,GL_RGBA, GL_UNSIGNED_BYTE, pic32);\n    }\n\t  free (pic32);\n\t  qglBindTexture( GL_TEXTURE_2D, 0 );\n  }\n\n  SkinInfo *pInfo = new SkinInfo(pName, nTex);\n  g_lstSkinCache.Add(pInfo);\n\n  return nTex;\n}\n\n\n"
  },
  {
    "path": "q3radiant/TexWnd.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_TEXWND_H__44B4BA05_781B_11D1_B53C_00AA00A410FC__INCLUDED_)\n#define AFX_TEXWND_H__44B4BA05_781B_11D1_B53C_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// TexWnd.h : header file\n//\n#include \"texedit.h\"\n\n/////////////////////////////////////////////////////////////////////////////\n// CTexWnd window\n\nclass CTexWnd : public CWnd\n{\n  DECLARE_DYNCREATE(CTexWnd);\n// Construction\npublic:\n\tCTexWnd();\n  void UpdateFilter(const char* pFilter);\n  void UpdatePrefs();\n  void FocusEdit();\n\n// Attributes\npublic:\n\n// Operations\npublic:\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CTexWnd)\n\tprotected:\n\tvirtual BOOL PreCreateWindow(CREATESTRUCT& cs);\n\t//}}AFX_VIRTUAL\n\n// Implementation\npublic:\n\tvirtual ~CTexWnd();\n\nprotected:\n  CTexEdit m_wndFilter;\n  CButton  m_wndShaders;\n  bool m_bNeedRange;\n\t// Generated message map functions\nprotected:\n\t//{{AFX_MSG(CTexWnd)\n\tafx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);\n\tafx_msg void OnSize(UINT nType, int cx, int cy);\n\tafx_msg void OnParentNotify(UINT message, LPARAM lParam);\n\tafx_msg void OnTimer(UINT nIDEvent);\n\tafx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);\n\tafx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);\n\tafx_msg void OnPaint();\n\tafx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);\n\tafx_msg void OnTexturesFlush();\n\t//}}AFX_MSG\n\tafx_msg void OnShaderClick();\n\tDECLARE_MESSAGE_MAP()\n};\n\n/////////////////////////////////////////////////////////////////////////////\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_TEXWND_H__44B4BA05_781B_11D1_B53C_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/TextureBar.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//++timo TODO : the whole CTextureBar has to be modified for the new texture code\n\n// TextureBar.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"TextureBar.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CTextureBar dialog\n\n\nCTextureBar::CTextureBar()\n\t: CDialogBar()\n{\n\t//{{AFX_DATA_INIT(CTextureBar)\n\tm_nHShift = 0;\n\tm_nHScale = 0;\n\tm_nRotate = 0;\n\tm_nVShift = 0;\n\tm_nVScale = 0;\n\tm_nRotateAmt = 45;\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CTextureBar::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialogBar::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CTextureBar)\n\tDDX_Control(pDX, IDC_SPIN_ROTATE, m_spinRotate);\n\tDDX_Control(pDX, IDC_SPIN_VSCALE, m_spinVScale);\n\tDDX_Control(pDX, IDC_SPIN_VSHIFT, m_spinVShift);\n\tDDX_Control(pDX, IDC_SPIN_HSCALE, m_spinHScale);\n\tDDX_Control(pDX, IDC_SPIN_HSHIFT, m_spinHShift);\n\tDDX_Text(pDX, IDC_HSHIFT, m_nHShift);\n\tDDX_Text(pDX, IDC_HSCALE, m_nHScale);\n\tDDX_Text(pDX, IDC_ROTATE, m_nRotate);\n\tDDX_Text(pDX, IDC_VSHIFT, m_nVShift);\n\tDDX_Text(pDX, IDC_VSCALE, m_nVScale);\n\tDDX_Text(pDX, IDC_EDIT_ROTATEAMT, m_nRotateAmt);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CTextureBar, CDialogBar)\n\t//{{AFX_MSG_MAP(CTextureBar)\n\tON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSHIFT, OnDeltaposSpinHshift)\n\tON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSHIFT, OnDeltaposSpinVshift)\n\tON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSCALE, OnDeltaposSpinHScale)\n\tON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSCALE, OnDeltaposSpinVScale)\n\tON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ROTATE, OnDeltaposSpinRotate)\n\tON_COMMAND(ID_SELECTION_PRINT, OnSelectionPrint)\n\tON_WM_CREATE()\n\tON_BN_CLICKED(IDC_BTN_APPLYTEXTURESTUFF, OnBtnApplytexturestuff)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CTextureBar message handlers\n\nvoid CTextureBar::OnDeltaposSpinHshift(NMHDR* pNMHDR, LRESULT* pResult) \n{\n\tNM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;\n\t*pResult = 0;\n\n  if (pNMUpDown->iDelta < 0)\n    Select_ShiftTexture(abs(g_qeglobals.d_savedinfo.m_nTextureTweak), 0);\n  else\n    Select_ShiftTexture(-abs(g_qeglobals.d_savedinfo.m_nTextureTweak), 0);\n  GetSurfaceAttributes();\n}\n\nvoid CTextureBar::OnDeltaposSpinVshift(NMHDR* pNMHDR, LRESULT* pResult) \n{\n\tNM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;\n\t// TODO: Add your control notification handler code here\n\t\n\t*pResult = 0;\n  if (pNMUpDown->iDelta < 0)\n    Select_ShiftTexture(0, abs(g_qeglobals.d_savedinfo.m_nTextureTweak));\n  else\n    Select_ShiftTexture(0, -abs(g_qeglobals.d_savedinfo.m_nTextureTweak));\n  GetSurfaceAttributes();\n}\n\nvoid CTextureBar::OnDeltaposSpinHScale(NMHDR* pNMHDR, LRESULT* pResult) \n{\n\tNM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;\n\t// TODO: Add your control notification handler code here\n\t\n\t*pResult = 0;\n  if (pNMUpDown->iDelta < 0)\n\t  Select_ScaleTexture(abs(g_qeglobals.d_savedinfo.m_nTextureTweak),0);\n  else\n\t  Select_ScaleTexture(-abs(g_qeglobals.d_savedinfo.m_nTextureTweak),0);\n  GetSurfaceAttributes();\n}\n\nvoid CTextureBar::OnDeltaposSpinVScale(NMHDR* pNMHDR, LRESULT* pResult) \n{\n\tNM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;\n\t// TODO: Add your control notification handler code here\n\t\n\t*pResult = 0;\n  if (pNMUpDown->iDelta < 0)\n\t  Select_ScaleTexture(0, abs(g_qeglobals.d_savedinfo.m_nTextureTweak));\n  else\n\t  Select_ScaleTexture(0, -abs(g_qeglobals.d_savedinfo.m_nTextureTweak));\n  GetSurfaceAttributes();\n}\n\nvoid CTextureBar::OnDeltaposSpinRotate(NMHDR* pNMHDR, LRESULT* pResult) \n{\n\tNM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;\n\t*pResult = 0;\n  UpdateData(TRUE);\n  if (pNMUpDown->iDelta < 0)\n    Select_RotateTexture(abs(m_nRotateAmt));\n  else\n    Select_RotateTexture(-abs(m_nRotateAmt));\n  GetSurfaceAttributes();\n}\n\n\nvoid CTextureBar::OnSelectionPrint() \n{\n\t// TODO: Add your command handler code here\n\t\n}\n\nint CTextureBar::OnCreate(LPCREATESTRUCT lpCreateStruct) \n{\n\tif (CDialogBar::OnCreate(lpCreateStruct) == -1)\n\t\treturn -1;\n\treturn 0;\n}\n\n\nvoid CTextureBar::OnBtnApplytexturestuff() \n{\n  SetSurfaceAttributes();\n}\n\nvoid CTextureBar::GetSurfaceAttributes()\n{\n  texdef_t* pt = (g_ptrSelectedFaces.GetSize() > 0) ? &(reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0)))->texdef : &g_qeglobals.d_texturewin.texdef;\n\n  if (pt)\n  {\n    m_nHShift = pt->shift[0];\n    m_nVShift = pt->shift[1];\n    m_nHScale = pt->scale[0];\n    m_nVScale = pt->scale[1];\n    m_nRotate = pt->rotate;\n    UpdateData(FALSE);\n  }\n}\n\n//++timo implement brush primitive here\nvoid CTextureBar::SetSurfaceAttributes()\n{\n  if (g_ptrSelectedFaces.GetSize() > 0)\n  {\n\t  if (g_qeglobals.m_bBrushPrimitMode)\n    {\n\t\t  Sys_Printf(\"Warning : brush primitive mode not implemented in CTextureBar\");\n    }\n    face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));\n\n\t  texdef_t* pt = &selFace->texdef;\n    UpdateData(TRUE);\n    pt->shift[0] = m_nHShift;\n    pt->shift[1] = m_nVShift;\n    pt->scale[0] = m_nHScale; \n    pt->scale[1] = m_nVScale; \n    pt->rotate = m_nRotate; \n    Sys_UpdateWindows(W_CAMERA);\n  }\n}\n"
  },
  {
    "path": "q3radiant/TextureBar.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_TEXTUREBAR_H__86220273_B656_11D1_B59F_00AA00A410FC__INCLUDED_)\n#define AFX_TEXTUREBAR_H__86220273_B656_11D1_B59F_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// TextureBar.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CTextureBar dialog\n\nclass CTextureBar : public CDialogBar\n{\n// Construction\npublic:\n\tvoid GetSurfaceAttributes();\n\tvoid SetSurfaceAttributes();\n\tCTextureBar();\n\n// Dialog Data\n\t//{{AFX_DATA(CTextureBar)\n\tenum { IDD = IDD_TEXTUREBAR };\n\tCSpinButtonCtrl\tm_spinRotate;\n\tCSpinButtonCtrl\tm_spinVScale;\n\tCSpinButtonCtrl\tm_spinVShift;\n\tCSpinButtonCtrl\tm_spinHScale;\n\tCSpinButtonCtrl\tm_spinHShift;\n\tint\tm_nHShift;\n\tint\tm_nHScale;\n\tint\tm_nRotate;\n\tint\tm_nVShift;\n\tint\tm_nVScale;\n\tint\t\tm_nRotateAmt;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CTextureBar)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\t// Generated message map functions\n\t//{{AFX_MSG(CTextureBar)\n\tafx_msg void OnDeltaposSpinHshift(NMHDR* pNMHDR, LRESULT* pResult);\n\tafx_msg void OnDeltaposSpinVshift(NMHDR* pNMHDR, LRESULT* pResult);\n\tafx_msg void OnDeltaposSpinHScale(NMHDR* pNMHDR, LRESULT* pResult);\n\tafx_msg void OnDeltaposSpinVScale(NMHDR* pNMHDR, LRESULT* pResult);\n\tafx_msg void OnDeltaposSpinRotate(NMHDR* pNMHDR, LRESULT* pResult);\n\tafx_msg void OnSelectionPrint();\n\tafx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);\n\tafx_msg void OnBtnApplytexturestuff();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_TEXTUREBAR_H__86220273_B656_11D1_B59F_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/TextureLayout.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// TextureLayout.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"TextureLayout.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CTextureLayout dialog\n\n\nCTextureLayout::CTextureLayout(CWnd* pParent /*=NULL*/)\n\t: CDialog(CTextureLayout::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CTextureLayout)\n\tm_fX = 4.0f;\n\tm_fY = 4.0f;\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CTextureLayout::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CTextureLayout)\n\tDDX_Text(pDX, IDC_EDIT_X, m_fX);\n\tDDX_Text(pDX, IDC_EDIT_Y, m_fY);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CTextureLayout, CDialog)\n\t//{{AFX_MSG_MAP(CTextureLayout)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CTextureLayout message handlers\n\nvoid CTextureLayout::OnOK() \n{\n\tCDialog::OnOK();\n}\n\nBOOL CTextureLayout::OnInitDialog() \n{\n\tCDialog::OnInitDialog();\n\t\n\t// TODO: Add extra initialization here\n\t\n\treturn TRUE;  // return TRUE unless you set the focus to a control\n\t              // EXCEPTION: OCX Property Pages should return FALSE\n}\n"
  },
  {
    "path": "q3radiant/TextureLayout.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_TEXTURELAYOUT_H__5EA4C722_173F_11D2_B024_00AA00A410FC__INCLUDED_)\n#define AFX_TEXTURELAYOUT_H__5EA4C722_173F_11D2_B024_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// TextureLayout.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CTextureLayout dialog\n\nclass CTextureLayout : public CDialog\n{\n// Construction\npublic:\n\tCTextureLayout(CWnd* pParent = NULL);   // standard constructor\n\n// Dialog Data\n\t//{{AFX_DATA(CTextureLayout)\n\tenum { IDD = IDD_DIALOG_TEXTURELAYOUT };\n\tfloat\tm_fX;\n\tfloat\tm_fY;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CTextureLayout)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CTextureLayout)\n\tvirtual void OnOK();\n\tvirtual BOOL OnInitDialog();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_TEXTURELAYOUT_H__5EA4C722_173F_11D2_B024_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/TextureLoad.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// TextureLoad.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"TextureLoad.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CTextureLoad dialog\n\n\nCTextureLoad::CTextureLoad(CWnd* pParent /*=NULL*/)\n\t: CDialog(CTextureLoad::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CTextureLoad)\n\t\t// NOTE: the ClassWizard will add member initialization here\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CTextureLoad::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CTextureLoad)\n\tDDX_Control(pDX, IDC_LIST_TEXTURES, m_wndList);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CTextureLoad, CDialog)\n\t//{{AFX_MSG_MAP(CTextureLoad)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CTextureLoad message handlers\n\nBOOL CTextureLoad::OnInitDialog() \n{\n\tCDialog::OnInitDialog();\n\t\n\n\t\n\treturn TRUE;  // return TRUE unless you set the focus to a control\n\t              // EXCEPTION: OCX Property Pages should return FALSE\n}\n\nvoid CTextureLoad::OnOK() \n{\n\t// TODO: Add extra validation here\n\t\n\tCDialog::OnOK();\n}\n"
  },
  {
    "path": "q3radiant/TextureLoad.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_TEXTURELOAD_H__E53749E6_AAE3_47B8_B909_84C7982E35C9__INCLUDED_)\n#define AFX_TEXTURELOAD_H__E53749E6_AAE3_47B8_B909_84C7982E35C9__INCLUDED_\n\n#if _MSC_VER > 1000\n#pragma once\n#endif // _MSC_VER > 1000\n// TextureLoad.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CTextureLoad dialog\n\nclass CTextureLoad : public CDialog\n{\n// Construction\npublic:\n\tCTextureLoad(CWnd* pParent = NULL);   // standard constructor\n\n// Dialog Data\n\t//{{AFX_DATA(CTextureLoad)\n\tenum { IDD = IDD_TEXLIST };\n\tCListBox\tm_wndList;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CTextureLoad)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CTextureLoad)\n\tvirtual BOOL OnInitDialog();\n\tvirtual void OnOK();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Visual C++ will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_TEXTURELOAD_H__E53749E6_AAE3_47B8_B909_84C7982E35C9__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/Textures.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n//--typedef struct texdef_s\n//--{\n//--\tchar\tname[32];\n//--\tfloat\tshift[2];\n//--\tfloat\trotate;\n//--\tfloat\tscale[2];\n//--\tint\t\tcontents;\n//--\tint\t\tflags;\n//--\tint\t\tvalue;\n//--} texdef_t;\n//--\n//--typedef struct\n//--{\n//--\tint\t\t\twidth, height;\n//--\tint\t\t\toriginy;\n//--\ttexdef_t\ttexdef;\n//--  int m_nTotalHeight;\n//--} texturewin_t;\n//--\n//--#define QER_TRANS     0x00000001\n//--#define QER_NOCARVE   0x00000002\n//--\n//--typedef struct qtexture_s\n//--{\n//--\tstruct\tqtexture_s *next;\n//--\tchar\tname[64];\t\t// includes partial directory and extension\n//--  int\t\twidth,  height;\n//--\tint\t\tcontents;\n//--\tint\t\tflags;\n//--\tint\t\tvalue;\n//--\tint\t\ttexture_number;\t// gl bind number\n//--  \n//--  char  shadername[1024]; // old shader stuff\n//--  qboolean bFromShader;   // created from a shader\n//--  float fTrans;           // amount of transparency\n//--  int   nShaderFlags;     // qer_ shader flags\n//--\tvec3_t\tcolor;\t\t\t    // for flat shade mode\n//--\tqboolean\tinuse;\t\t    // true = is present on the level\n//--} qtexture_t;\n//--\n\n// a texturename of the form (0 0 0) will\n// create a solid color texture\n\nvoid\tTexture_Init (bool bHardInit = true);\nvoid\tTexture_FlushUnused ();\nvoid\tTexture_Flush (bool bReload = false);\nvoid\tTexture_ClearInuse (void);\nvoid\tTexture_ShowInuse (void);\nvoid\tTexture_ShowDirectory (int menunum, bool bLinked = false);\nvoid\tTexture_ShowAll();\nvoid Texture_Cleanup(CStringList *pList = NULL);\n\n// TTimo: added bNoAlpha flag to ignore alpha channel when parsing a .TGA file, transparency is usually achieved through qer_trans keyword in shaders\n// in some cases loading an empty alpha channel causes display bugs (brushes not seen)\nqtexture_t *Texture_ForName (const char *name, bool bReplace = false, bool bShader = false, bool bNoAlpha = false, bool bReload = false, bool makeShader = true);\n\nvoid\tTexture_Init (void);\n// Timo\n// added an optional IPluginTexdef when one is available\n// we need a forward declaration, this is crap\nclass IPluginTexdef;\nvoid\tTexture_SetTexture (texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale = false, IPluginTexdef *pTexdef = NULL, bool bSetSelection = true);\n\nvoid\tTexture_SetMode(int iMenu);\t// GL_TEXTURE_NEAREST, etc..\nvoid Texture_ResetPosition();\n\nvoid FreeShaders();\nvoid LoadShaders();\nvoid ReloadShaders();\nint  WINAPI Texture_LoadSkin(char *pName, int *pnWidth, int *pnHeight);\nvoid Texture_LoadFromPlugIn(LPVOID vp);\nvoid Texture_StartPos (void);\nqtexture_t *Texture_NextPos (int *x, int *y);\n"
  },
  {
    "path": "q3radiant/ToolWnd.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// ToolWnd.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"ToolWnd.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CToolWnd\n\nCToolWnd::CToolWnd()\n{\n}\n\nCToolWnd::~CToolWnd()\n{\n}\n\n\nBEGIN_MESSAGE_MAP(CToolWnd, CWnd)\n\t//{{AFX_MSG_MAP(CToolWnd)\n\t\t// NOTE - the ClassWizard will add and remove mapping macros here.\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n\n/////////////////////////////////////////////////////////////////////////////\n// CToolWnd message handlers\n"
  },
  {
    "path": "q3radiant/ToolWnd.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_TOOLWND_H__5E29A4F9_A20C_4056_950F_9AA8842F53B7__INCLUDED_)\n#define AFX_TOOLWND_H__5E29A4F9_A20C_4056_950F_9AA8842F53B7__INCLUDED_\n\n#if _MSC_VER > 1000\n#pragma once\n#endif // _MSC_VER > 1000\n// ToolWnd.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CToolWnd window\n\nclass CToolWnd : public CWnd\n{\n// Construction\npublic:\n\tCToolWnd();\n\n// Attributes\npublic:\n\n// Operations\npublic:\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CToolWnd)\n\t//}}AFX_VIRTUAL\n\n// Implementation\npublic:\n\tvirtual ~CToolWnd();\n\n\t// Generated message map functions\nprotected:\n\t//{{AFX_MSG(CToolWnd)\n\t\t// NOTE - the ClassWizard will add and remove member functions here.\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n/////////////////////////////////////////////////////////////////////////////\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Visual C++ will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_TOOLWND_H__5E29A4F9_A20C_4056_950F_9AA8842F53B7__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/Undo.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n/*\n\n  QERadiant Undo/Redo\n\n\nbasic setup:\n\n<-g_undolist---------g_lastundo> <---map data---> <-g_lastredo---------g_redolist->\n\n\n  undo/redo on the world_entity is special, only the epair changes are remembered\n  and the world entity never gets deleted.\n\n  FIXME: maybe reset the Undo system at map load\n\t\t maybe also reset the entityId at map load\n*/\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"qe3.h\"\n\ntypedef struct undo_s\n{\n\tdouble time;\t\t\t\t//time operation was performed\n\tint id;\t\t\t\t\t\t//every undo has an unique id\n\tint done;\t\t\t\t\t//true when undo is build\n\tchar *operation;\t\t\t//name of the operation\n\tbrush_t brushlist;\t\t\t//deleted brushes\n\tentity_t entitylist;\t\t//deleted entities\n\tstruct undo_s *prev, *next;\t//next and prev undo in list\n} undo_t;\n\nundo_t *g_undolist;\t\t\t\t\t\t//first undo in the list\nundo_t *g_lastundo;\t\t\t\t\t\t//last undo in the list\nundo_t *g_redolist;\t\t\t\t\t\t//first redo in the list\nundo_t *g_lastredo;\t\t\t\t\t\t//last undo in list\nint g_undoMaxSize = 64;\t\t\t\t\t//maximum number of undos\nint g_undoSize = 0;\t\t\t\t\t\t//number of undos in the list\nint g_undoMaxMemorySize = 2*1024*1024;\t//maximum undo memory (default 2 MB)\nint g_undoMemorySize = 0;\t\t\t\t//memory size of undo buffer\nint g_undoId = 1;\t\t\t\t\t\t//current undo ID (zero is invalid id)\nint g_redoId = 1;\t\t\t\t\t\t//current redo ID (zero is invalid id)\n\n\n/*\n=============\nUndo_MemorySize\n=============\n*/\nint Undo_MemorySize(void)\n{\n\t/*\n\tint size;\n\tundo_t *undo;\n\tbrush_t *pBrush;\n\tentity_t *pEntity;\n\n\tsize = 0;\n\tfor (undo = g_undolist; undo; undo = undo->next)\n\t{\n\t\tfor (pBrush = undo->brushlist.next ; pBrush != NULL && pBrush != &undo->brushlist ; pBrush = pBrush->next)\n\t\t{\n\t\t\tsize += Brush_MemorySize(pBrush);\n\t\t}\n\t\tfor (pEntity = undo->entitylist.next; pEntity != NULL && pEntity != &undo->entitylist; pEntity = pEntity->next)\n\t\t{\n\t\t\tsize += Entity_MemorySize(pEntity);\n\t\t}\n\t\tsize += sizeof(undo_t);\n\t}\n\treturn size;\n\t*/\n\treturn g_undoMemorySize;\n}\n\n/*\n=============\nUndo_ClearRedo\n=============\n*/\nvoid Undo_ClearRedo(void)\n{\n\tundo_t *redo, *nextredo;\n\tbrush_t *pBrush, *pNextBrush;\n\tentity_t *pEntity, *pNextEntity;\n\n\tfor (redo = g_redolist; redo; redo = nextredo)\n\t{\n\t\tnextredo = redo->next;\n\t\tfor (pBrush = redo->brushlist.next ; pBrush != NULL && pBrush != &redo->brushlist ; pBrush = pNextBrush)\n\t\t{\n\t\t\tpNextBrush = pBrush->next;\n\t\t\tBrush_Free(pBrush);\n\t\t}\n\t\tfor (pEntity = redo->entitylist.next; pEntity != NULL && pEntity != &redo->entitylist; pEntity = pNextEntity)\n\t\t{\n\t\t\tpNextEntity = pEntity->next;\n\t\t\tEntity_Free(pEntity);\n\t\t}\n\t\tfree(redo);\n\t}\n\tg_redolist = NULL;\n\tg_lastredo = NULL;\n\tg_redoId = 1;\n}\n\n/*\n=============\nUndo_Clear\n\n  Clears the undo buffer.\n=============\n*/\nvoid Undo_Clear(void)\n{\n\tundo_t *undo, *nextundo;\n\tbrush_t *pBrush, *pNextBrush;\n\tentity_t *pEntity, *pNextEntity;\n\n\tUndo_ClearRedo();\n\tfor (undo = g_undolist; undo; undo = nextundo)\n\t{\n\t\tnextundo = undo->next;\n\t\tfor (pBrush = undo->brushlist.next ; pBrush != NULL && pBrush != &undo->brushlist ; pBrush = pNextBrush)\n\t\t{\n\t\t\tpNextBrush = pBrush->next;\n\t\t\tg_undoMemorySize -= Brush_MemorySize(pBrush);\n\t\t\tBrush_Free(pBrush);\n\t\t}\n\t\tfor (pEntity = undo->entitylist.next; pEntity != NULL && pEntity != &undo->entitylist; pEntity = pNextEntity)\n\t\t{\n\t\t\tpNextEntity = pEntity->next;\n\t\t\tg_undoMemorySize -= Entity_MemorySize(pEntity);\n\t\t\tEntity_Free(pEntity);\n\t\t}\n\t\tg_undoMemorySize -= sizeof(undo_t);\n\t\tfree(undo);\n\t}\n\tg_undolist = NULL;\n\tg_lastundo = NULL;\n\tg_undoSize = 0;\n\tg_undoMemorySize = 0;\n\tg_undoId = 1;\n}\n\n/*\n=============\nUndo_SetMaxSize\n=============\n*/\nvoid Undo_SetMaxSize(int size)\n{\n\tUndo_Clear();\n\tif (size < 1) g_undoMaxSize = 1;\n\telse g_undoMaxSize = size;\n}\n\n/*\n=============\nUndo_GetMaxSize\n=============\n*/\nint Undo_GetMaxSize(void)\n{\n\treturn g_undoMaxSize;\n}\n\n/*\n=============\nUndo_SetMaxMemorySize\n=============\n*/\nvoid Undo_SetMaxMemorySize(int size)\n{\n\tUndo_Clear();\n\tif (size < 1024) g_undoMaxMemorySize = 1024;\n\telse g_undoMaxMemorySize = size;\n}\n\n/*\n=============\nUndo_GetMaxMemorySize\n=============\n*/\nint Undo_GetMaxMemorySize(void)\n{\n\treturn g_undoMaxMemorySize;\n}\n\n/*\n=============\nUndo_FreeFirstUndo\n=============\n*/\nvoid Undo_FreeFirstUndo(void)\n{\n\tundo_t *undo;\n\tbrush_t *pBrush, *pNextBrush;\n\tentity_t *pEntity, *pNextEntity;\n\n\t//remove the oldest undo from the undo buffer\n\tundo = g_undolist;\n\tg_undolist = g_undolist->next;\n\tg_undolist->prev = NULL;\n\t//\n\tfor (pBrush = undo->brushlist.next ; pBrush != NULL && pBrush != &undo->brushlist ; pBrush = pNextBrush)\n\t{\n\t\tpNextBrush = pBrush->next;\n\t\tg_undoMemorySize -= Brush_MemorySize(pBrush);\n\t\tBrush_Free(pBrush);\n\t}\n\tfor (pEntity = undo->entitylist.next; pEntity != NULL && pEntity != &undo->entitylist; pEntity = pNextEntity)\n\t{\n\t\tpNextEntity = pEntity->next;\n\t\tg_undoMemorySize -= Entity_MemorySize(pEntity);\n\t\tEntity_Free(pEntity);\n\t}\n\tg_undoMemorySize -= sizeof(undo_t);\n\tfree(undo);\n\tg_undoSize--;\n}\n\n/*\n=============\nUndo_GeneralStart\n=============\n*/\nvoid Undo_GeneralStart(char *operation)\n{\n\tundo_t *undo;\n\tbrush_t *pBrush;\n\tentity_t *pEntity;\n\n\n\tif (g_lastundo)\n\t{\n\t\tif (!g_lastundo->done)\n\t\t{\n\t\t\tSys_Printf(\"Undo_Start: WARNING last undo not finished.\\n\");\n\t\t}\n\t}\n\n\tundo = (undo_t *) malloc(sizeof(undo_t));\n\tif (!undo) return;\n\tmemset(undo, 0, sizeof(undo_t));\n\tundo->brushlist.next = &undo->brushlist;\n\tundo->brushlist.prev = &undo->brushlist;\n\tundo->entitylist.next = &undo->entitylist;\n\tundo->entitylist.prev = &undo->entitylist;\n\tif (g_lastundo) g_lastundo->next = undo;\n\telse g_undolist = undo;\n\tundo->prev = g_lastundo;\n\tundo->next = NULL;\n\tg_lastundo = undo;\n\t\n\tundo->time = Sys_DoubleTime();\n\t//\n\tif (g_undoId > g_undoMaxSize * 2) g_undoId = 1;\n\tif (g_undoId <= 0) g_undoId = 1;\n\tundo->id = g_undoId++;\n\tundo->done = false;\n\tundo->operation = operation;\n\t//reset the undo IDs of all brushes using the new ID\n\tfor (pBrush = active_brushes.next; pBrush != NULL && pBrush != &active_brushes; pBrush = pBrush->next)\n\t{\n\t\tif (pBrush->undoId == undo->id)\n\t\t{\n\t\t\tpBrush->undoId = 0;\n\t\t}\n\t}\n\tfor (pBrush = selected_brushes.next; pBrush != NULL && pBrush != &selected_brushes; pBrush = pBrush->next)\n\t{\n\t\tif (pBrush->undoId == undo->id)\n\t\t{\n\t\t\tpBrush->undoId = 0;\n\t\t}\n\t}\n\t//reset the undo IDs of all entities using thew new ID\n\tfor (pEntity = entities.next; pEntity != NULL && pEntity != &entities; pEntity = pEntity->next)\n\t{\n\t\tif (pEntity->undoId == undo->id)\n\t\t{\n\t\t\tpEntity->undoId = 0;\n\t\t}\n\t}\n\tg_undoMemorySize += sizeof(undo_t);\n\tg_undoSize++;\n\t//undo buffer is bound to a max\n\tif (g_undoSize > g_undoMaxSize)\n\t{\n\t\tUndo_FreeFirstUndo();\n\t}\n}\n\n/*\n=============\nUndo_BrushInUndo\n=============\n*/\nint Undo_BrushInUndo(undo_t *undo, brush_t *brush)\n{\n\tbrush_t *b;\n\n\tfor (b = undo->brushlist.next; b != &undo->brushlist; b = b->next)\n\t{\n\t\tif (b == brush) return true;\n\t}\n\treturn false;\n}\n\n/*\n=============\nUndo_EntityInUndo\n=============\n*/\nint Undo_EntityInUndo(undo_t *undo, entity_t *ent)\n{\n\tentity_t *e;\n\n\tfor (e = undo->entitylist.next; e != &undo->entitylist; e = e->next)\n\t{\n\t\tif (e == ent) return true;\n\t}\n\treturn false;\n}\n\n/*\n=============\nUndo_Start\n=============\n*/\nvoid Undo_Start(char *operation)\n{\n\tUndo_ClearRedo();\n\tUndo_GeneralStart(operation);\n}\n\n/*\n=============\nUndo_AddBrush\n=============\n*/\nvoid Undo_AddBrush(brush_t *pBrush)\n{\n\tif (!g_lastundo)\n\t{\n\t\tSys_Printf(\"Undo_AddBrushList: no last undo.\\n\");\n\t\treturn;\n\t}\n\tif (g_lastundo->entitylist.next != &g_lastundo->entitylist)\n\t{\n\t\tSys_Printf(\"Undo_AddBrushList: WARNING adding brushes after entity.\\n\");\n\t}\n\t//if the brush is already in the undo\n\tif (Undo_BrushInUndo(g_lastundo, pBrush))\n\t\treturn;\n\t//clone the brush\n\tbrush_t* pClone = Brush_FullClone(pBrush);\n\t//save the ID of the owner entity\n\tpClone->ownerId = pBrush->owner->entityId;\n\t//save the old undo ID for previous undos\n\tpClone->undoId = pBrush->undoId;\n\tBrush_AddToList (pClone, &g_lastundo->brushlist);\n\t//\n\tg_undoMemorySize += Brush_MemorySize(pClone);\n}\n\n/*\n=============\nUndo_AddBrushList\n=============\n*/\nvoid Undo_AddBrushList(brush_t *brushlist)\n{\n\tbrush_t *pBrush;\n\n\tif (!g_lastundo)\n\t{\n\t\tSys_Printf(\"Undo_AddBrushList: no last undo.\\n\");\n\t\treturn;\n\t}\n\tif (g_lastundo->entitylist.next != &g_lastundo->entitylist)\n\t{\n\t\tSys_Printf(\"Undo_AddBrushList: WARNING adding brushes after entity.\\n\");\n\t}\n\t//copy the brushes to the undo\n\tfor (pBrush = brushlist->next ; pBrush != NULL && pBrush != brushlist; pBrush=pBrush->next)\n\t{\n\t\t//if the brush is already in the undo\n\t\tif (Undo_BrushInUndo(g_lastundo, pBrush))\n\t\t\tcontinue;\n\t\t// do we need to store this brush's entity in the undo?\n\t\t// if it's a fixed size entity, the brush that reprents it is not really relevant, it's used for selecting and moving around\n\t\t// what we want to store for undo is the owner entity, epairs and origin/angle stuff\n\t\t//++timo FIXME: if the entity is not fixed size I don't know, so I don't do it yet\n\t\tif (pBrush->owner->eclass->fixedsize == 1)\n\t\t\tUndo_AddEntity( pBrush->owner );\n\t\t//clone the brush\n\t\tbrush_t* pClone = Brush_FullClone(pBrush);\n\t\t//save the ID of the owner entity\n\t\tpClone->ownerId = pBrush->owner->entityId;\n\t\t//save the old undo ID from previous undos\n\t\tpClone->undoId = pBrush->undoId;\n\t\tBrush_AddToList (pClone, &g_lastundo->brushlist);\n\t\t//\n\t\tg_undoMemorySize += Brush_MemorySize(pClone);\n\t}\n}\n\n/*\n=============\nUndo_EndBrush\n=============\n*/\nvoid Undo_EndBrush(brush_t *pBrush)\n{\n\tif (!g_lastundo)\n\t{\n\t\t//Sys_Printf(\"Undo_End: no last undo.\\n\");\n\t\treturn;\n\t}\n\tif (g_lastundo->done)\n\t{\n\t\t//Sys_Printf(\"Undo_End: last undo already finished.\\n\");\n\t\treturn;\n\t}\n\tpBrush->undoId = g_lastundo->id;\n}\n\n/*\n=============\nUndo_EndBrushList\n=============\n*/\nvoid Undo_EndBrushList(brush_t *brushlist)\n{\n\tif (!g_lastundo)\n\t{\n\t\t//Sys_Printf(\"Undo_End: no last undo.\\n\");\n\t\treturn;\n\t}\n\tif (g_lastundo->done)\n\t{\n\t\t//Sys_Printf(\"Undo_End: last undo already finished.\\n\");\n\t\treturn;\n\t}\n\tfor (brush_t* pBrush = brushlist->next; pBrush != NULL && pBrush != brushlist; pBrush=pBrush->next)\n\t{\n\t\tpBrush->undoId = g_lastundo->id;\n\t}\n}\n\n/*\n=============\nUndo_AddEntity\n=============\n*/\nvoid Undo_AddEntity(entity_t *entity)\n{\n\tentity_t* pClone;\n\n\tif (!g_lastundo)\n\t{\n\t\tSys_Printf(\"Undo_AddEntity: no last undo.\\n\");\n\t\treturn;\n\t}\n\t//if the entity is already in the undo\n\tif (Undo_EntityInUndo(g_lastundo, entity))\n\t\treturn;\n\t//clone the entity\n\tpClone = Entity_Clone(entity);\n\t//NOTE: Entity_Clone adds the entity to the entity list\n\t//\t\tso we remove it from that list here\n\tEntity_RemoveFromList(pClone);\n\t//save the old undo ID for previous undos\n\tpClone->undoId = entity->undoId;\n\t//save the entity ID (we need a full clone)\n\tpClone->entityId = entity->entityId;\n\t//\n\tEntity_AddToList(pClone, &g_lastundo->entitylist);\n\t//\n\tg_undoMemorySize += Entity_MemorySize(pClone);\n}\n\n/*\n=============\nUndo_EndEntity\n=============\n*/\nvoid Undo_EndEntity(entity_t *entity)\n{\n\tif (!g_lastundo)\n\t{\n\t\t//Sys_Printf(\"Undo_End: no last undo.\\n\");\n\t\treturn;\n\t}\n\tif (g_lastundo->done)\n\t{\n\t\t//Sys_Printf(\"Undo_End: last undo already finished.\\n\");\n\t\treturn;\n\t}\n\tif (entity == world_entity)\n\t{\n\t\t//Sys_Printf(\"Undo_AddEntity: undo on world entity.\\n\");\n\t\t//NOTE: we never delete the world entity when undoing an operation\n\t\t//\t\twe only transfer the epairs\n\t\treturn;\n\t}\n\tentity->undoId = g_lastundo->id;\n}\n\n/*\n=============\nUndo_End\n=============\n*/\nvoid Undo_End(void)\n{\n\tif (!g_lastundo)\n\t{\n\t\t//Sys_Printf(\"Undo_End: no last undo.\\n\");\n\t\treturn;\n\t}\n\tif (g_lastundo->done)\n\t{\n\t\t//Sys_Printf(\"Undo_End: last undo already finished.\\n\");\n\t\treturn;\n\t}\n\tg_lastundo->done = true;\n\n\t//undo memory size is bound to a max\n\twhile (g_undoMemorySize > g_undoMaxMemorySize)\n\t{\n\t\t//always keep one undo\n\t\tif (g_undolist == g_lastundo) break;\n\t\tUndo_FreeFirstUndo();\n\t}\n\t//\n\t//Sys_Printf(\"undo size = %d, undo memory = %d\\n\", g_undoSize, g_undoMemorySize);\n}\n\n/*\n=============\nUndo_Undo\n=============\n*/\nvoid Undo_Undo(void)\n{\n\tundo_t *undo, *redo;\n\tbrush_t *pBrush, *pNextBrush;\n\tentity_t *pEntity, *pNextEntity, *pUndoEntity;\n\n\tif (!g_lastundo)\n\t{\n\t\tSys_Printf(\"Nothing left to undo.\\n\");\n\t\treturn;\n\t}\n\tif (!g_lastundo->done)\n\t{\n\t\tSys_Printf(\"Undo_Undo: WARNING: last undo not yet finished!\\n\");\n\t}\n\t// get the last undo\n\tundo = g_lastundo;\n\tif (g_lastundo->prev) g_lastundo->prev->next = NULL;\n\telse g_undolist = NULL;\n\tg_lastundo = g_lastundo->prev;\n\n\t//allocate a new redo\n\tredo = (undo_t *) malloc(sizeof(undo_t));\n\tif (!redo) return;\n\tmemset(redo, 0, sizeof(undo_t));\n\tredo->brushlist.next = &redo->brushlist;\n\tredo->brushlist.prev = &redo->brushlist;\n\tredo->entitylist.next = &redo->entitylist;\n\tredo->entitylist.prev = &redo->entitylist;\n\tif (g_lastredo) g_lastredo->next = redo;\n\telse g_redolist = redo;\n\tredo->prev = g_lastredo;\n\tredo->next = NULL;\n\tg_lastredo = redo;\n\tredo->time = Sys_DoubleTime();\n\tredo->id = g_redoId++;\n\tredo->done = true;\n\tredo->operation = undo->operation;\n\n\t//reset the redo IDs of all brushes using the new ID\n\tfor (pBrush = active_brushes.next; pBrush != NULL && pBrush != &active_brushes; pBrush = pBrush->next)\n\t{\n\t\tif (pBrush->redoId == redo->id)\n\t\t{\n\t\t\tpBrush->redoId = 0;\n\t\t}\n\t}\n\tfor (pBrush = selected_brushes.next; pBrush != NULL && pBrush != &selected_brushes; pBrush = pBrush->next)\n\t{\n\t\tif (pBrush->redoId == redo->id)\n\t\t{\n\t\t\tpBrush->redoId = 0;\n\t\t}\n\t}\n\t//reset the redo IDs of all entities using thew new ID\n\tfor (pEntity = entities.next; pEntity != NULL && pEntity != &entities; pEntity = pEntity->next)\n\t{\n\t\tif (pEntity->redoId == redo->id)\n\t\t{\n\t\t\tpEntity->redoId = 0;\n\t\t}\n\t}\n\n\t// remove current selection\n\tSelect_Deselect();\n\t// move \"created\" brushes to the redo\n\tfor (pBrush = active_brushes.next; pBrush != NULL && pBrush != &active_brushes; pBrush=pNextBrush)\n\t{\n\t\tpNextBrush = pBrush->next;\n\t\tif (pBrush->undoId == undo->id)\n\t\t{\n\t\t\t//Brush_Free(pBrush);\n\t\t\t//move the brush to the redo\n\t\t\tBrush_RemoveFromList(pBrush);\n\t\t\tBrush_AddToList(pBrush, &redo->brushlist);\n\t\t\t//make sure the ID of the owner is stored\n\t\t\tpBrush->ownerId = pBrush->owner->entityId;\n\t\t\t//unlink the brush from the owner entity\n\t\t\tEntity_UnlinkBrush(pBrush);\n\t\t}\n\t}\n\t// move \"created\" entities to the redo\n\tfor (pEntity = entities.next; pEntity != NULL && pEntity != &entities; pEntity = pNextEntity)\n\t{\n\t\tpNextEntity = pEntity->next;\n\t\tif (pEntity->undoId == undo->id)\n\t\t{\n\t\t\t// check if this entity is in the undo\n\t\t\tfor (pUndoEntity = undo->entitylist.next; pUndoEntity != NULL && pUndoEntity != &undo->entitylist; pUndoEntity = pUndoEntity->next)\n\t\t\t{\n\t\t\t\t// move brushes to the undo entity\n\t\t\t\tif (pUndoEntity->entityId == pEntity->entityId)\n\t\t\t\t{\n\t\t\t\t\tpUndoEntity->brushes.next = pEntity->brushes.next;\n\t\t\t\t\tpUndoEntity->brushes.prev = pEntity->brushes.prev;\n\t\t\t\t\tpEntity->brushes.next = &pEntity->brushes;\n\t\t\t\t\tpEntity->brushes.prev = &pEntity->brushes;\n\t\t\t\t}\n\t\t\t}\n\t\t\t//\n\t\t\t//Entity_Free(pEntity);\n\t\t\t//move the entity to the redo\n\t\t\tEntity_RemoveFromList(pEntity);\n\t\t\tEntity_AddToList(pEntity, &redo->entitylist);\n\t\t}\n\t}\n\t// add the undo entities back into the entity list\n\tfor (pEntity = undo->entitylist.next; pEntity != NULL && pEntity != &undo->entitylist; pEntity = undo->entitylist.next)\n\t{\n\t\tg_undoMemorySize -= Entity_MemorySize(pEntity);\n\t\t//if this is the world entity\n\t\tif (pEntity->entityId == world_entity->entityId)\n\t\t{\n\t\t\t//free the epairs of the world entity\n\t\t\tEntity_FreeEpairs(world_entity);\n\t\t\t//set back the original epairs\n\t\t\tworld_entity->epairs = pEntity->epairs;\n\t\t\t// unhook the epairs and free the world_entity clone that stored the epairs\n\t\t\tpEntity->epairs = NULL;\n\t\t\tEntity_Free(pEntity);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tEntity_RemoveFromList(pEntity);\n\t\t\tEntity_AddToList(pEntity, &entities);\n\t\t\tpEntity->redoId = redo->id;\n\t\t}\n\t}\n\t// add the undo brushes back into the selected brushes\n\tfor (pBrush = undo->brushlist.next; pBrush != NULL && pBrush != &undo->brushlist; pBrush = undo->brushlist.next)\n\t{\n\t\tg_undoMemorySize -= Brush_MemorySize(pBrush);\n\t\tBrush_RemoveFromList(pBrush);\n    \tBrush_AddToList(pBrush, &active_brushes);\n\t\tfor (pEntity = entities.next; pEntity != NULL && pEntity != &entities; pEntity = pNextEntity)\n\t\t{\n\t\t\tif (pEntity->entityId == pBrush->ownerId)\n\t\t\t{\n\t\t\t\tEntity_LinkBrush(pEntity, pBrush);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t//if the brush is not linked then it should be linked into the world entity\n\t\tif (pEntity == NULL || pEntity == &entities)\n\t\t{\n\t\t\tEntity_LinkBrush(world_entity, pBrush);\n\t\t}\n\t\t//build the brush\n\t\t//Brush_Build(pBrush);\n\t\tSelect_Brush(pBrush);\n\t\tpBrush->redoId = redo->id;\n    }\n\t//\n\tSys_Printf(\"%s undone.\\n\", undo->operation);\n\t// free the undo\n\tg_undoMemorySize -= sizeof(undo_t);\n\tfree(undo);\n\tg_undoSize--;\n\tg_undoId--;\n\tif (g_undoId <= 0) g_undoId = 2 * g_undoMaxSize;\n\t//\n    g_bScreenUpdates = true; \n    Sys_UpdateWindows(W_ALL);\n}\n\n/*\n=============\nUndo_Redo\n=============\n*/\nvoid Undo_Redo(void)\n{\n\tundo_t *redo;\n\tbrush_t *pBrush, *pNextBrush;\n\tentity_t *pEntity, *pNextEntity, *pRedoEntity;\n\n\tif (!g_lastredo)\n\t{\n\t\tSys_Printf(\"Nothing left to redo.\\n\");\n\t\treturn;\n\t}\n\tif (g_lastundo)\n\t{\n\t\tif (!g_lastundo->done)\n\t\t{\n\t\t\tSys_Printf(\"WARNING: last undo not finished.\\n\");\n\t\t}\n\t}\n\t// get the last redo\n\tredo = g_lastredo;\n\tif (g_lastredo->prev) g_lastredo->prev->next = NULL;\n\telse g_redolist = NULL;\n\tg_lastredo = g_lastredo->prev;\n\t//\n\tUndo_GeneralStart(redo->operation);\n\t// remove current selection\n\tSelect_Deselect();\n\t// move \"created\" brushes back to the last undo\n\tfor (pBrush = active_brushes.next; pBrush != NULL && pBrush != &active_brushes; pBrush = pNextBrush)\n\t{\n\t\tpNextBrush = pBrush->next;\n\t\tif (pBrush->redoId == redo->id)\n\t\t{\n\t\t\t//move the brush to the undo\n\t\t\tBrush_RemoveFromList(pBrush);\n\t\t\tBrush_AddToList(pBrush, &g_lastundo->brushlist);\n\t\t\tg_undoMemorySize += Brush_MemorySize(pBrush);\n\t\t\tpBrush->ownerId = pBrush->owner->entityId;\n\t\t\tEntity_UnlinkBrush(pBrush);\n\t\t}\n\t}\n\t// move \"created\" entities back to the last undo\n\tfor (pEntity = entities.next; pEntity != NULL && pEntity != &entities; pEntity = pNextEntity)\n\t{\n\t\tpNextEntity = pEntity->next;\n\t\tif (pEntity->redoId == redo->id)\n\t\t{\n\t\t\t// check if this entity is in the redo\n\t\t\tfor (pRedoEntity = redo->entitylist.next; pRedoEntity != NULL && pRedoEntity != &redo->entitylist; pRedoEntity = pRedoEntity->next)\n\t\t\t{\n\t\t\t\t// move brushes to the redo entity\n\t\t\t\tif (pRedoEntity->entityId == pEntity->entityId)\n\t\t\t\t{\n\t\t\t\t\tpRedoEntity->brushes.next = pEntity->brushes.next;\n\t\t\t\t\tpRedoEntity->brushes.prev = pEntity->brushes.prev;\n\t\t\t\t\tpEntity->brushes.next = &pEntity->brushes;\n\t\t\t\t\tpEntity->brushes.prev = &pEntity->brushes;\n\t\t\t\t}\n\t\t\t}\n\t\t\t//\n\t\t\t//Entity_Free(pEntity);\n\t\t\t//move the entity to the redo\n\t\t\tEntity_RemoveFromList(pEntity);\n\t\t\tEntity_AddToList(pEntity, &g_lastundo->entitylist);\n\t\t\tg_undoMemorySize += Entity_MemorySize(pEntity);\n\t\t}\n\t}\n\t// add the undo entities back into the entity list\n\tfor (pEntity = redo->entitylist.next; pEntity != NULL && pEntity != &redo->entitylist; pEntity = redo->entitylist.next)\n\t{\n\t\t//if this is the world entity\n\t\tif (pEntity->entityId == world_entity->entityId)\n\t\t{\n\t\t\t//free the epairs of the world entity\n\t\t\tEntity_FreeEpairs(world_entity);\n\t\t\t//set back the original epairs\n\t\t\tworld_entity->epairs = pEntity->epairs;\n\t\t\t//free the world_entity clone that stored the epairs\n\t\t\tEntity_Free(pEntity);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tEntity_RemoveFromList(pEntity);\n\t\t\tEntity_AddToList(pEntity, &entities);\n\t\t}\n\t}\n\t// add the redo brushes back into the selected brushes\n\tfor (pBrush = redo->brushlist.next; pBrush != NULL && pBrush != &redo->brushlist; pBrush = redo->brushlist.next)\n\t{\n\t\tBrush_RemoveFromList(pBrush);\n    \tBrush_AddToList(pBrush, &active_brushes);\n\t\tfor (pEntity = entities.next; pEntity != NULL && pEntity != &entities; pEntity = pNextEntity)\n\t\t{\n\t\t\tif (pEntity->entityId == pBrush->ownerId)\n\t\t\t{\n\t\t\t\tEntity_LinkBrush(pEntity, pBrush);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t//if the brush is not linked then it should be linked into the world entity\n\t\tif (pEntity == NULL || pEntity == &entities)\n\t\t{\n\t\t\tEntity_LinkBrush(world_entity, pBrush);\n\t\t}\n\t\t//build the brush\n\t\t//Brush_Build(pBrush);\n\t\tSelect_Brush(pBrush);\n    }\n\t//\n\tUndo_End();\n\t//\n\tSys_Printf(\"%s redone.\\n\", redo->operation);\n\t//\n\tg_redoId--;\n\t// free the undo\n\tfree(redo);\n\t//\n    g_bScreenUpdates = true; \n    Sys_UpdateWindows(W_ALL);\n}\n\n/*\n=============\nUndo_RedoAvailable\n=============\n*/\nint Undo_RedoAvailable(void)\n{\n\tif (g_lastredo) return true;\n\treturn false;\n}\n\n/*\n=============\nUndo_UndoAvailable\n=============\n*/\nint Undo_UndoAvailable(void)\n{\n\tif (g_lastundo)\n\t{\n\t\tif (g_lastundo->done)\n\t\t\treturn true;\n\t}\n\treturn false;\n}\n"
  },
  {
    "path": "q3radiant/Undo.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//\n//\n// QERadiant Multilevel Undo/Redo\n//\n// \n\n//start operation\nvoid Undo_Start(char *operation);\n//end operation\nvoid Undo_End(void);\n//add brush to the undo\nvoid Undo_AddBrush(brush_t *pBrush);\n//add a list with brushes to the undo\nvoid Undo_AddBrushList(brush_t *brushlist);\n//end a brush after the operation is performed\nvoid Undo_EndBrush(brush_t *pBrush);\n//end a list with brushes after the operation is performed\nvoid Undo_EndBrushList(brush_t *brushlist);\n//add entity to undo\nvoid Undo_AddEntity(entity_t *entity);\n//end an entity after the operation is performed\nvoid Undo_EndEntity(entity_t *entity);\n//undo last operation\nvoid Undo_Undo(void);\n//redo last undone operation\nvoid Undo_Redo(void);\n//returns true if there is something to be undone available\nint  Undo_UndoAvailable(void);\n//returns true if there is something to redo available\nint  Undo_RedoAvailable(void);\n//clear the undo buffer\nvoid Undo_Clear(void);\n//set maximum undo size (default 64)\nvoid Undo_SetMaxSize(int size);\n//get maximum undo size\nint  Undo_GetMaxSize(void);\n//set maximum undo memory in bytes (default 2 MB)\nvoid Undo_SetMaxMemorySize(int size);\n//get maximum undo memory in bytes\nint  Undo_GetMaxMemorySize(void);\n//returns the amount of memory used by undo\nint  Undo_MemorySize(void);\n\n"
  },
  {
    "path": "q3radiant/VERTSEL.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"stdafx.h\"\n#include \"qe3.h\"\n#include \"winding.h\"\n\n#define NEWEDGESEL 1\n\n\nint\tFindPoint (vec3_t point)\n{\n\tint\t\ti, j;\n\n\tfor (i=0 ; i<g_qeglobals.d_numpoints ; i++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t\tif (fabs(point[j] - g_qeglobals.d_points[i][j]) > 0.1)\n\t\t\t\tbreak;\n\t\tif (j == 3)\n\t\t\treturn i;\n\t}\n\n\tVectorCopy (point, g_qeglobals.d_points[g_qeglobals.d_numpoints]);\n  if (g_qeglobals.d_numpoints < MAX_POINTS-1)\n  {\n\t  g_qeglobals.d_numpoints++;\n  }\n\n\treturn g_qeglobals.d_numpoints-1;\n}\n\nint FindEdge (int p1, int p2, face_t *f)\n{\n\tint\t\ti;\n\n\tfor (i=0 ; i<g_qeglobals.d_numedges ; i++)\n\t\tif (g_qeglobals.d_edges[i].p1 == p2 && g_qeglobals.d_edges[i].p2 == p1)\n\t\t{\n\t\t\tg_qeglobals.d_edges[i].f2 = f;\n\t\t\treturn i;\n\t\t}\n\n\tg_qeglobals.d_edges[g_qeglobals.d_numedges].p1 = p1;\n\tg_qeglobals.d_edges[g_qeglobals.d_numedges].p2 = p2;\n\tg_qeglobals.d_edges[g_qeglobals.d_numedges].f1 = f;\n\n  if (g_qeglobals.d_numedges < MAX_EDGES-1)\n  {\n\t  g_qeglobals.d_numedges++;\n  }\n\n\treturn g_qeglobals.d_numedges-1;\n}\n\n#ifdef NEWEDGESEL\nvoid MakeFace (brush_t* b, face_t *f)\n#else\nvoid MakeFace (face_t *f)\n#endif\n{\n\twinding_t\t*w;\n\tint\t\t\ti;\n\tint\t\t\tpnum[128];\n\n#ifdef NEWEDGESEL\n\tw = Brush_MakeFaceWinding (b, f);\n#else\n\tw = Brush_MakeFaceWinding (selected_brushes.next, f);\n#endif\n\tif (!w)\n\t\treturn;\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\tpnum[i] = FindPoint (w->points[i]);\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\tFindEdge (pnum[i], pnum[(i+1)%w->numpoints], f);\n\n\tfree (w);\n}\n\nvoid SetupVertexSelection (void)\n{\n\tface_t\t*f;\n\tbrush_t *b;\n\n\tg_qeglobals.d_numpoints = 0;\n\tg_qeglobals.d_numedges = 0;\n\n#ifdef NEWEDGESEL\n\tfor (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n  {\n\t  for (f=b->brush_faces ; f ; f=f->next)\n\t\t  MakeFace (b,f);\n  }\n#else\n\tif (!QE_SingleBrush())\n\t\treturn;\n\n  b = selected_brushes.next;\n  for (f=b->brush_faces ; f ; f=f->next)\n    MakeFace (b,f);\n#endif\n\n}\n\n\n#ifdef NEWEDGESEL\nvoid SelectFaceEdge (brush_t* b, face_t *f, int p1, int p2)\n#else\nvoid SelectFaceEdge (face_t *f, int p1, int p2)\n#endif\n{\n\twinding_t\t*w;\n\tint\t\t\ti, j, k;\n\tint\t\t\tpnum[128];\n\n#ifdef NEWEDGESEL\n\tw = Brush_MakeFaceWinding (b, f);\n#else\n\tw = Brush_MakeFaceWinding (selected_brushes.next, f);\n#endif\n\tif (!w)\n\t\treturn;\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t\tpnum[i] = FindPoint (w->points[i]);\n\n  for (i=0 ; i<w->numpoints ; i++)\n\t\tif (pnum[i] == p1 && pnum[(i+1)%w->numpoints] == p2)\n\t\t{\n\t\t\tVectorCopy (g_qeglobals.d_points[pnum[i]], f->planepts[0]);\n\t\t\tVectorCopy (g_qeglobals.d_points[pnum[(i+1)%w->numpoints]], f->planepts[1]);\n\t\t\tVectorCopy (g_qeglobals.d_points[pnum[(i+2)%w->numpoints]], f->planepts[2]);\n\t\t\tfor (j=0 ; j<3 ; j++)\n\t\t\t{\n\t\t\t\tfor (k=0 ; k<3 ; k++)\n\t\t\t\t{\n\t\t\t\t\tf->planepts[j][k] = floor(f->planepts[j][k]/g_qeglobals.d_gridsize+0.5)*g_qeglobals.d_gridsize;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tAddPlanept (f->planepts[0]);\n\t\t\tAddPlanept (f->planepts[1]);\n\t\t\tbreak;\n\t\t}\n\n\tif (i == w->numpoints)\n\t\tSys_Printf (\"SelectFaceEdge: failed\\n\");\n\tfree (w);\n}\n\n\nvoid SelectVertex (int p1)\n{\n\tbrush_t\t\t*b;\n\twinding_t\t*w;\n\tint\t\t\ti, j, k;\n\tface_t\t\t*f;\n\n#ifdef NEWEDGESEL\n\tfor (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n  {\n\t  for (f=b->brush_faces ; f ; f=f->next)\n\t  {\n\t\t  w =  Brush_MakeFaceWinding (b, f);\n\t\t  if (!w)\n\t\t\t  continue;\n\t\t  for (i=0 ; i<w->numpoints ; i++)\n\t\t  {\n\t\t\t  if (FindPoint (w->points[i]) == p1)\n\t\t\t  {\n\t\t\t\t  VectorCopy (w->points[(i+w->numpoints-1)%w->numpoints], f->planepts[0]);\n\t\t\t\t  VectorCopy (w->points[i], f->planepts[1]);\n\t\t\t\t  VectorCopy (w->points[(i+1)%w->numpoints], f->planepts[2]);\n\t\t\t    for (j=0 ; j<3 ; j++)\n          {\n\t\t\t\t    for (k=0 ; k<3 ; k++)\n            {\n\t\t\t\t\t    ;//f->planepts[j][k] = floor(f->planepts[j][k]/g_qeglobals.d_gridsize+0.5)*g_qeglobals.d_gridsize;\n            } \n          }\n\n\t\t\t    AddPlanept (f->planepts[1]);\n          //MessageBeep(-1);\n\n\t\t\t    break;\n        }\n\t\t  }\n\t\t  free (w);\n\t  }\n  }\n#else\n\tb = selected_brushes.next;\n\tfor (f=b->brush_faces ; f ; f=f->next)\n\t{\n\t\tw =  Brush_MakeFaceWinding (b, f);\n\t\tif (!w)\n\t\t\tcontinue;\n\t\tfor (i=0 ; i<w->numpoints ; i++)\n\t\t{\n\t\t\tif (FindPoint (w->points[i]) == p1)\n\t\t\t{\n\t\t\t\tVectorCopy (w->points[(i+w->numpoints-1)%w->numpoints], f->planepts[0]);\n\t\t\t\tVectorCopy (w->points[i], f->planepts[1]);\n\t\t\t\tVectorCopy (w->points[(i+1)%w->numpoints], f->planepts[2]);\n\t\t\t  for (j=0 ; j<3 ; j++)\n        {\n\t\t\t\t  for (k=0 ; k<3 ; k++)\n          {\n\t\t\t\t\t  ;//f->planepts[j][k] = floor(f->planepts[j][k]/g_qeglobals.d_gridsize+0.5)*g_qeglobals.d_gridsize;\n          } \n        }\n\n\t\t\t  AddPlanept (f->planepts[1]);\n        //MessageBeep(-1);\n\n\t\t\t  break;\n      }\n\t\t}\n\t\tfree (w);\n\t}\n#endif\n}\n\nvoid SelectEdgeByRay (vec3_t org, vec3_t dir)\n{\n\tint\t\ti, j, besti;\n\tfloat\td, bestd;\n\tvec3_t\tmid, temp;\n\tpedge_t\t*e;\n\n\t// find the edge closest to the ray\n\tbesti = -1;\n\tbestd = 8;\n\n\tfor (i=0 ; i<g_qeglobals.d_numedges ; i++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t\tmid[j] = 0.5*(g_qeglobals.d_points[g_qeglobals.d_edges[i].p1][j] + g_qeglobals.d_points[g_qeglobals.d_edges[i].p2][j]);\n\n\t\tVectorSubtract (mid, org, temp);\n\t\td = DotProduct (temp, dir);\n\t\tVectorMA (org, d, dir, temp);\n\t\tVectorSubtract (mid, temp, temp);\n\t\td = VectorLength (temp);\n\t\tif (d < bestd)\n\t\t{\n\t\t\tbestd = d;\n\t\t\tbesti = i;\n\t\t}\n\t}\n\n\tif (besti == -1)\n\t{\n\t\tSys_Printf (\"Click didn't hit an edge\\n\");\n\t\treturn;\n\t}\n\tSys_Printf (\"hit edge\\n\");\n\n\t// make the two faces that border the edge use the two edge points\n\t// as primary drag points\n\tg_qeglobals.d_num_move_points = 0;\n\te = &g_qeglobals.d_edges[besti];\n#ifdef NEWEDGESEL\n\tfor (brush_t* b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n  {\n    SelectFaceEdge (b, e->f1, e->p1, e->p2);\n\t  SelectFaceEdge (b, e->f2, e->p2, e->p1);\n  }\n#else\n  SelectFaceEdge (e->f1, e->p1, e->p2);\n\tSelectFaceEdge (e->f2, e->p2, e->p1);\n#endif\n\n\n}\n\nvoid SelectVertexByRay (vec3_t org, vec3_t dir)\n{\n\tint\t\ti, besti;\n\tfloat\td, bestd;\n\tvec3_t\ttemp;\n\n\t// find the point closest to the ray\n\tbesti = -1;\n\tbestd = 8;\n\n\tfor (i=0 ; i<g_qeglobals.d_numpoints ; i++)\n\t{\n\t\tVectorSubtract (g_qeglobals.d_points[i], org, temp);\n\t\td = DotProduct (temp, dir);\n\t\tVectorMA (org, d, dir, temp);\n\t\tVectorSubtract (g_qeglobals.d_points[i], temp, temp);\n\t\td = VectorLength (temp);\n\t\tif (d < bestd)\n\t\t{\n\t\t\tbestd = d;\n\t\t\tbesti = i;\n\t\t}\n\t}\n\n\tif (besti == -1)\n\t{\n\t\tSys_Printf (\"Click didn't hit a vertex\\n\");\n\t\treturn;\n\t}\n\tSys_Printf (\"hit vertex\\n\");\n\tg_qeglobals.d_move_points[g_qeglobals.d_num_move_points++] = g_qeglobals.d_points[besti];\n\t//SelectVertex (besti);\n}\n\n\n\nextern void AddPatchMovePoint(vec3_t v, bool bMulti, bool bFull);\nvoid SelectCurvePointByRay (vec3_t org, vec3_t dir, int buttons)\n{\n\tint\t\ti, besti;\n\tfloat\td, bestd;\n\tvec3_t\ttemp;\n\n\t// find the point closest to the ray\n\tbesti = -1;\n\tbestd = 8;\n\n\tfor (i=0 ; i<g_qeglobals.d_numpoints ; i++)\n\t{\n\t\tVectorSubtract (g_qeglobals.d_points[i], org, temp);\n\t\td = DotProduct (temp, dir);\n\t\tVectorMA (org, d, dir, temp);\n\t\tVectorSubtract (g_qeglobals.d_points[i], temp, temp);\n\t\td = VectorLength (temp);\n\t\tif (d <= bestd)\n\t\t{\n\t\t\tbestd = d;\n\t\t\tbesti = i;\n\t\t}\n\t}\n\n\tif (besti == -1)\n\t{\n    if (g_pParentWnd->ActiveXY()->AreaSelectOK())\n    {\n      g_qeglobals.d_select_mode = sel_area;\n      VectorCopy(org, g_qeglobals.d_vAreaTL);\n      VectorCopy(org, g_qeglobals.d_vAreaBR);\n    }\n\t\treturn;\n\t}\n\t//Sys_Printf (\"hit vertex\\n\");\n  AddPatchMovePoint(g_qeglobals.d_points[besti], buttons & MK_CONTROL, buttons & MK_SHIFT);\n}\n\n\n\n"
  },
  {
    "path": "q3radiant/VIEW.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n\ntypedef struct\n{\n\tint\t\tx, y;\n\tint\t\tw, h;\n\n\tint\t\tredraws;\t// clear to 0 when need update\n\n\tvec3_t\tcolor;\n\n\tvec3_t\torigin;\n\tvec3_t\tangles;\n\tvec3_t\tforward, right, up;\n\n\tint\t\tdraw_filtered;\n\tint\t\tdraw_wire;\n\tint\t\tdraw_solid;\n\tint\t\tdraw_textured;\n\tint\t\tdraw_blend;\n} vieworg_t;\n\nextern\tvieworg_t\t*view_org;\nextern\tint\t\t\tkeysdown;\n\nvoid View_Init (void);\nvoid View_Draw (void);\nvoid View_MouseDown (int x, int y, int buttons);\nvoid View_KeyUp (int key);\nvoid View_KeyDown (int key);\nvoid View_Reshape(int w, int h);\n\n"
  },
  {
    "path": "q3radiant/WIN_CAM.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// win_cam.c -- windows specific camera view code\n\n#include \"stdafx.h\"\n#include \"qe3.h\"\n\n/*\n============\nCameraWndProc\n============\n*/\nLONG WINAPI WCam_WndProc (\n    HWND    hWnd,\n    UINT    uMsg,\n    WPARAM  wParam,\n    LPARAM  lParam)\n{\n\tint\t\tfwKeys, xPos, yPos;\n    RECT\trect;\n\n    GetClientRect(hWnd, &rect);\n\n    switch (uMsg)\n    {\n\tcase WM_CREATE:\n\t\t{\n\t\t\tHFONT\thfont;\n\t\t\t\n            g_qeglobals.d_hdcBase = GetDC(hWnd);\n\t\t\tQEW_SetupPixelFormat(g_qeglobals.d_hdcBase, true);\n\n            if ( ( g_qeglobals.d_hglrcBase = wglCreateContext( g_qeglobals.d_hdcBase ) ) == 0 )\n\t\t\t\tError (\"wglCreateContext failed\");\n            if (!wglMakeCurrent( g_qeglobals.d_hdcBase, g_qeglobals.d_hglrcBase ))\n\t\t\t\tError (\"wglMakeCurrent failed\");\n\n\t\t\tTexture_SetMode(g_qeglobals.d_savedinfo.iTexMenu);\n\n\t\t\t//\n\t\t\t// create GL font\n\t\t\t//\n\t\t\thfont = CreateFont(\n\t\t\t\t10,\t// logical height of font \n\t\t\t\t7,\t// logical average character width \n\t\t\t\t0,\t// angle of escapement \n\t\t\t\t0,\t// base-line orientation angle \n\t\t\t\t0,\t// font weight \n\t\t\t\t0,\t// italic attribute flag \n\t\t\t\t0,\t// underline attribute flag \n\t\t\t\t0,\t// strikeout attribute flag \n\t\t\t\t0,\t// character set identifier \n\t\t\t\t0,\t// output precision \n\t\t\t\t0,\t// clipping precision \n\t\t\t\t0,\t// output quality \n\t\t\t\t0,\t// pitch and family \n\t\t\t\t0 \t// pointer to typeface name string \n\t\t\t\t);\n\n\t\t\tif ( !hfont )\n\t\t\t\tError( \"couldn't create font\" );\n\n\t\t\tSelectObject (g_qeglobals.d_hdcBase, hfont);\n\n\t\t\tif ( ( g_qeglobals.d_font_list = glGenLists (256) ) == 0 )\n\t\t\t\tError( \"couldn't create font dlists\" );\n\t\t\t\n\t\t\t// create the bitmap display lists\n\t\t\t// we're making images of glyphs 0 thru 255\n\t\t\tif ( !wglUseFontBitmaps (g_qeglobals.d_hdcBase, 1, 255, g_qeglobals.d_font_list) )\n\t\t\t\tError( \"wglUseFontBitmaps faileD\" );\n\t\t\t\n\t\t\t// indicate start of glyph display lists\n\t\t\tglListBase (g_qeglobals.d_font_list);\n\n\t\t\t// report OpenGL information\n\t\t\tSys_Printf (\"GL_VENDOR: %s\\n\", glGetString (GL_VENDOR));\n\t\t\tSys_Printf (\"GL_RENDERER: %s\\n\", glGetString (GL_RENDERER));\n\t\t\tSys_Printf (\"GL_VERSION: %s\\n\", glGetString (GL_VERSION));\n\t\t\tSys_Printf (\"GL_EXTENSIONS: %s\\n\", glGetString (GL_EXTENSIONS));\n\t\t}\n\t\treturn 0;\n\tcase WM_PAINT:\n        { \n\t\t\tPAINTSTRUCT\tps;\n\t\t\t\n            if (!wglMakeCurrent( g_qeglobals.d_hdcBase, g_qeglobals.d_hglrcBase ))\n\t\t\t\tError (\"wglMakeCurrent failed\");\n\n\t\t\tif ( BeginPaint(hWnd, &ps) )\n\t\t\t{\n\t\t\t\tQE_CheckOpenGLForErrors();\n\t\t\t\tCam_Draw ();\n\t\t\t\tQE_CheckOpenGLForErrors();\n\n\t\t\t\tEndPaint(hWnd, &ps);\n\t\t\t\tSwapBuffers(g_qeglobals.d_hdcBase);\n\t\t\t}\n        }\n\t\treturn 0;\n\t\t\n\tcase WM_USER+267:\t// benchmark\n        { \n\t\t\tPAINTSTRUCT\tps;\n\t\t\tWINDOWPLACEMENT wp;\n\t\t\tdouble\tstart, end;\n\t\t\tint\t\ti;\n\t\t\t\n\t\t\tmemset( &wp, 0, sizeof( wp ) );\n\t\t\twp.length = sizeof( wp );\n\t\t\tGetWindowPlacement( g_qeglobals.d_hwndCamera, &wp );\n\t\t\t\n\t\t\tMoveWindow( g_qeglobals.d_hwndCamera, 30, 30, 400, 400, TRUE );\n\t\t\t\n\t\t\tBeginPaint(hWnd, &ps);\n            if (!wglMakeCurrent( g_qeglobals.d_hdcBase, g_qeglobals.d_hglrcBase))\n\t\t\t\tError (\"wglMakeCurrent failed\");\n\t\t\tglDrawBuffer (GL_FRONT);\n\t\t\t\n\t\t\tstart = Sys_DoubleTime ();\n\t\t\tfor (i=0 ; i<100 ; i++)\n\t\t\t{\n\t\t\t\tcamera.angles[YAW] = i*4;\n\t\t\t\tCam_Draw ();\n\t\t\t}\n\t\t\twglSwapBuffers(g_qeglobals.d_hdcBase);\n\t\t\tglDrawBuffer (GL_BACK);\n\t\t\tend = Sys_DoubleTime ();\n\t\t\tEndPaint(hWnd, &ps);\n\t\t\tSys_Printf (\"%5.2f seconds\\n\", end-start);\n\n\t\t\tSetWindowPlacement( g_qeglobals.d_hwndCamera, &wp );\n        }\n\t\tbreak;\n\t\t\n\tcase WM_KEYDOWN:\n\t\tif ( QE_KeyDown (wParam) )\n\t\t\treturn 0;\n\t\telse \n\t\t\treturn DefWindowProc( hWnd, uMsg, wParam, lParam );\n\t\t\n\tcase WM_MBUTTONDOWN:\n\tcase WM_RBUTTONDOWN:\n\tcase WM_LBUTTONDOWN:\n\t\tif (GetTopWindow(g_qeglobals.d_hwndMain) != hWnd)\n\t\t\tBringWindowToTop(hWnd);\n\t\t\n\t\tSetFocus (g_qeglobals.d_hwndCamera);\n\t\tSetCapture (g_qeglobals.d_hwndCamera);\n\t\tfwKeys = wParam;        // key flags \n\t\txPos = (short)LOWORD(lParam);  // horizontal position of cursor \n\t\tyPos = (short)HIWORD(lParam);  // vertical position of cursor \n\t\tyPos = (int)rect.bottom - 1 - yPos;\n\t\tCam_MouseDown (xPos, yPos, fwKeys);\n\t\treturn 0;\n\t\t\n\tcase WM_MBUTTONUP:\n\tcase WM_RBUTTONUP:\n\tcase WM_LBUTTONUP:\n\t\tfwKeys = wParam;        // key flags \n\t\txPos = (short)LOWORD(lParam);  // horizontal position of cursor \n\t\tyPos = (short)HIWORD(lParam);  // vertical position of cursor \n\t\tyPos = (int)rect.bottom - 1 - yPos;\n\t\tCam_MouseUp (xPos, yPos, fwKeys);\n\t\tif (! (fwKeys & (MK_LBUTTON|MK_RBUTTON|MK_MBUTTON)))\n\t\t\tReleaseCapture ();\n\t\treturn 0;\n\t\t\n\tcase WM_MOUSEMOVE:\n\t\tfwKeys = wParam;        // key flags \n\t\txPos = (short)LOWORD(lParam);  // horizontal position of cursor \n\t\tyPos = (short)HIWORD(lParam);  // vertical position of cursor \n\t\tyPos = (int)rect.bottom - 1 - yPos;\n\t\tCam_MouseMoved (xPos, yPos, fwKeys);\n\t\treturn 0;\n\t\t\n\tcase WM_SIZE:\n\t\tcamera.width = rect.right;\n\t\tcamera.height = rect.bottom;\n\t\tInvalidateRect(g_qeglobals.d_hwndCamera, NULL, false);\n\t\treturn 0;\n\n\tcase WM_KILLFOCUS:\n\tcase WM_SETFOCUS:\n\t\tSendMessage( hWnd, WM_NCACTIVATE, uMsg == WM_SETFOCUS, 0 );\n\t\treturn 0;\n\n\tcase WM_NCCALCSIZE:// don't let windows copy pixels\n\t\tDefWindowProc (hWnd, uMsg, wParam, lParam);\n\t\treturn WVR_REDRAW;\n\n\tcase WM_CLOSE:\n\t\tDestroyWindow (hWnd);\n\t\treturn 0;\n\t\t\n\tcase WM_DESTROY:\n\t\tQEW_StopGL( hWnd, g_qeglobals.d_hglrcBase, g_qeglobals.d_hdcBase );\n\t\treturn 0;\n    }\n\n\treturn DefWindowProc( hWnd, uMsg, wParam, lParam );\n}\n\n\n/*\n==============\nWCam_Create\n==============\n*/\nvoid WCam_Create (HINSTANCE hInstance)\n{\n    WNDCLASS   wc;\n\tchar\t\t*title;\n\n    /* Register the camera class */\n\tmemset (&wc, 0, sizeof(wc));\n\n    wc.style         = CS_NOCLOSE;\n    wc.lpfnWndProc   = (WNDPROC)WCam_WndProc;\n    wc.cbClsExtra    = 0;\n    wc.cbWndExtra    = 0;\n    wc.hInstance     = hInstance;\n    wc.hIcon         = 0;\n    wc.hCursor       = LoadCursor (NULL,IDC_ARROW);\n    wc.hbrBackground = NULL;\n    wc.lpszMenuName  = 0;\n    wc.lpszClassName = CAMERA_WINDOW_CLASS;\n\n    if (!RegisterClass (&wc) )\n        Error (\"WCam_Register: failed\");\n\n\tif (  g_qeglobals.d_savedinfo.exclude & EXCLUDE_DETAIL )\n\t\ttitle = \"Camera View (DETAIL EXCLUDED)\";\n\telse\n\t\ttitle = \"Camera View\";\n\n\tg_qeglobals.d_hwndCamera = CreateWindow (CAMERA_WINDOW_CLASS ,\n\t\ttitle,\n\t\tQE3_STYLE,\n\t\tZWIN_WIDTH,\n\t\t20,\n\t\t(int)(screen_width*CWIN_SIZE),\n\t\t(int)(screen_height*CWIN_SIZE),\t// size\n\n\t\tg_qeglobals.d_hwndMain,\t// parent window\n\t\t0,\t\t// no menu\n\t\thInstance,\n\t\t0);\n\n  if (!g_qeglobals.d_hwndCamera)\n\t\tError (\"Couldn't create g_qeglobals.d_hwndCamera\");\n\n\tLoadWindowState(g_qeglobals.d_hwndCamera, \"camerawindow\");\n    ShowWindow (g_qeglobals.d_hwndCamera, SW_SHOWDEFAULT);\n}\n"
  },
  {
    "path": "q3radiant/WIN_DLG.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"stdafx.h\"\n#include \"qe3.h\"\n#include \"PrefsDlg.h\"\n\nBOOL CALLBACK EditCommandDlgProc (\n    HWND hwndDlg,\t// handle to dialog box\n    UINT uMsg,\t// message\n    WPARAM wParam,\t// first message parameter\n    LPARAM lParam \t// second message parameter\n   )\n{\n\tchar\tkey[1024];\n\tchar\tvalue[1024];\n\tchar\t*temp;\n\tint\t\tindex;\n\tHWND\thOwner;\n\t\n\thOwner = GetParent (hwndDlg);\n\n\tswitch (uMsg)\n    {\n\tcase WM_INITDIALOG:\n\t\tindex = SendDlgItemMessage (hOwner, IDC_CMD_LIST, LB_GETCURSEL, 0, 0);\n    if (index >= 0)\n    {\n\t\t  SendDlgItemMessage(hOwner, IDC_CMD_LIST, LB_GETTEXT, index, (LPARAM) (LPCTSTR) key);\n\t\t  temp = ValueForKey (g_qeglobals.d_project_entity, key);\n\t\t  strcpy (value, temp);\n\t\t  SetDlgItemText(hwndDlg, IDC_CMDMENUTEXT, key);\n\t\t  SetDlgItemText(hwndDlg, IDC_CMDCOMMAND, value);\n    }\n\t\treturn FALSE;\n\t\tbreak;\n\n\tcase WM_COMMAND: \n\t\tswitch (LOWORD(wParam)) \n\t\t{ \n\t\t\tcase IDOK:\n\t\t\t\tif (!GetDlgItemText(hwndDlg, IDC_CMDMENUTEXT, key, 64))\n\t\t\t\t{\n\t\t\t\t\tSys_Printf (\"Command not added\\n\");\n\t\t\t\t\treturn FALSE;\n\t\t\t\t}\n\n\t\t\t\tif (!GetDlgItemText(hwndDlg, IDC_CMDCOMMAND, value, 64))\n\t\t\t\t{\n\t\t\t\t\tSys_Printf (\"Command not added\\n\");\n\t\t\t\t\treturn FALSE;\n\t\t\t\t}\n\n\t\t\t\t//if (key[0] == 'b' && key[1] == 's' && key[2] == 'p')\n\t\t\t\t//{\n\t\t\t\t\tSetKeyValue (g_qeglobals.d_project_entity, key, value);\n\t\t\t\t\tFillBSPMenu ();\n\t\t\t\t//}\n\t\t\t\t//else\n\t\t\t\t//\tSys_Printf (\"BSP commands must be preceded by \\\"bsp\\\"\");\n\n\t\t\t\tEndDialog(hwndDlg, 1);\n\t\t\t\treturn TRUE;\n\n\t\t\tcase IDCANCEL:\n\t\t\t\tEndDialog(hwndDlg, 0);\n\t\t\t\treturn TRUE;\n\t\t}\n\t}\n\treturn FALSE;\n}\n\nBOOL CALLBACK AddCommandDlgProc (\n    HWND hwndDlg,\t// handle to dialog box\n    UINT uMsg,\t// message\n    WPARAM wParam,\t// first message parameter\n    LPARAM lParam \t// second message parameter\n   )\n{\n\tchar\tkey[64];\n\tchar\tvalue[128];\n\n\tswitch (uMsg)\n    {\n\tcase WM_COMMAND: \n\t\tswitch (LOWORD(wParam)) \n\t\t{ \n\t\t\tcase IDOK:\n\t\t\t\tif (!GetDlgItemText(hwndDlg, IDC_CMDMENUTEXT, key, 64))\n\t\t\t\t{\n\t\t\t\t\tSys_Printf (\"Command not added\\n\");\n\t\t\t\t\treturn FALSE;\n\t\t\t\t}\n\n\t\t\t\tif (!GetDlgItemText(hwndDlg, IDC_CMDCOMMAND, value, 64))\n\t\t\t\t{\n\t\t\t\t\tSys_Printf (\"Command not added\\n\");\n\t\t\t\t\treturn FALSE;\n\t\t\t\t}\n\n\t\t\t\tif (key[0] == 'b' && key[1] == 's' && key[2] == 'p')\n\t\t\t\t{\n\t\t\t\t\tSetKeyValue (g_qeglobals.d_project_entity, key, value);\n\t\t\t\t\tFillBSPMenu ();\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tSys_Printf (\"BSP commands must be preceded by \\\"bsp\\\"\");\n\n\t\t\t\tEndDialog(hwndDlg, 1);\n\t\t\t\treturn TRUE;\n\n\t\t\tcase IDCANCEL:\n\t\t\t\tEndDialog(hwndDlg, 0);\n\t\t\t\treturn TRUE;\n\t\t}\n\t}\n\treturn FALSE;\n}\n\nvoid UpdateBSPCommandList (HWND hwndDlg)\n{\n\tint\t\t\ti;\n\tepair_t\t\t*ep;\n\n\tSendDlgItemMessage(hwndDlg, IDC_CMD_LIST, LB_RESETCONTENT, 0 , 0);\n\n\ti = 0;\n\tfor (ep = g_qeglobals.d_project_entity->epairs ; ep ; ep=ep->next)\n\t{\n\t\tif (ep->key[0] == 'b' && ep->key[1] == 's' && ep->key[2] == 'p')\n\t\t{\n\t\t\tSendDlgItemMessage(hwndDlg, IDC_CMD_LIST, LB_ADDSTRING, i , (LPARAM) ep->key);\n\t\t\ti++;\n\t\t}\n\t}\n}\n\n\n// FIXME: turn this into an MFC dialog\nBOOL CALLBACK ProjectDlgProc (\n    HWND hwndDlg,\t// handle to dialog box\n    UINT uMsg,\t// message\n    WPARAM wParam,\t// first message parameter\n    LPARAM lParam \t// second message parameter\n   )\n{\n\tchar\t\tkey[1024];\n\tchar\t\tvalue[1024];\n\tint\t\t\tindex;\n\n\tswitch (uMsg)\n    {\n\tcase WM_INITDIALOG:\n\t\tSetDlgItemText(hwndDlg, IDC_PRJBASEPATH, ValueForKey (g_qeglobals.d_project_entity, \"basepath\"));\n\t\tSetDlgItemText(hwndDlg, IDC_PRJMAPSPATH, ValueForKey (g_qeglobals.d_project_entity, \"mapspath\"));\n\t\tSetDlgItemText(hwndDlg, IDC_PRJRSHCMD, ValueForKey (g_qeglobals.d_project_entity, \"rshcmd\"));\n\t\tSetDlgItemText(hwndDlg, IDC_PRJREMOTEBASE, ValueForKey (g_qeglobals.d_project_entity, \"remotebasepath\"));\n\t\tSetDlgItemText(hwndDlg, IDC_PRJENTITYPATH, ValueForKey (g_qeglobals.d_project_entity, \"entitypath\"));\n\t\tSetDlgItemText(hwndDlg, IDC_PRJTEXPATH, ValueForKey (g_qeglobals.d_project_entity, \"texturepath\"));\n\t\tUpdateBSPCommandList (hwndDlg);\n\t\t// Timo\n\t\t// additional fields\n\t\tCheckDlgButton( hwndDlg, IDC_CHECK_BPRIMIT, (g_qeglobals.m_bBrushPrimitMode) ? BST_CHECKED : BST_UNCHECKED );\n//\t\tSendMessage( ::GetDlgItem( hwndDlg, IDC_CHECK_BPRIMIT ), BM_SETCHECK, (WPARAM) g_qeglobals.m_bBrushPrimitMode, 0 );\n\t\treturn TRUE;\n\n\tcase WM_COMMAND: \n\t\tswitch (LOWORD(wParam)) \n\t\t{ \n\t\t\tcase IDC_ADDCMD:\n//\t\t\t\tDialogBox(g_qeglobals.d_hInstance, (char *)IDD_ADDCMD, g_qeglobals.d_hwndMain, AddCommandDlgProc);\n\t\t\t\tDialogBox(g_qeglobals.d_hInstance, (char *)IDD_ADDCMD, hwndDlg, AddCommandDlgProc);\n\t\t\t\tUpdateBSPCommandList (hwndDlg);\n\t\t\t\tbreak;\n\n\t\t\tcase IDC_EDITCMD:\n//\t\t\t\tDialogBox(g_qeglobals.d_hInstance, (char *)IDD_ADDCMD, g_qeglobals.d_hwndMain, EditCommandDlgProc);\n\t\t\t\tDialogBox(g_qeglobals.d_hInstance, (char *)IDD_ADDCMD, hwndDlg, EditCommandDlgProc);\n\t\t\t\tUpdateBSPCommandList (hwndDlg);\n\t\t\t\tbreak;\n\n\t\t\tcase IDC_REMCMD:\n\t\t\t\tindex = SendDlgItemMessage (hwndDlg, IDC_CMD_LIST, LB_GETCURSEL, 0, 0);\n\t\t\t\tSendDlgItemMessage(hwndDlg, IDC_CMD_LIST, LB_GETTEXT, index, (LPARAM) (LPCTSTR) key);\n\t\t\t\tDeleteKey (g_qeglobals.d_project_entity, key);\n\t\t\t\tSys_Printf (\"Selected %d\\n\", index);\n\t\t\t\tUpdateBSPCommandList (hwndDlg);\n\t\t\t\tbreak;\n\n\t\t\tcase IDOK:\n\t\t\t\tGetDlgItemText(hwndDlg, IDC_PRJBASEPATH, value, 1024);\n\t\t\t\tSetKeyValue (g_qeglobals.d_project_entity, \"basepath\", value);\n\t\t\t\tGetDlgItemText(hwndDlg, IDC_PRJMAPSPATH, value, 1024);\n\t\t\t\tSetKeyValue (g_qeglobals.d_project_entity, \"mapspath\", value);\n\t\t\t\tGetDlgItemText(hwndDlg, IDC_PRJRSHCMD, value, 1024);\n\t\t\t\tSetKeyValue (g_qeglobals.d_project_entity, \"rshcmd\", value);\n\t\t\t\tGetDlgItemText(hwndDlg, IDC_PRJREMOTEBASE, value, 1024);\n\t\t\t\tSetKeyValue (g_qeglobals.d_project_entity, \"remotebasepath\", value);\n\t\t\t\tGetDlgItemText(hwndDlg, IDC_PRJENTITYPATH, value, 1024);\n\t\t\t\tSetKeyValue (g_qeglobals.d_project_entity, \"entitypath\", value);\n\t\t\t\tGetDlgItemText(hwndDlg, IDC_PRJTEXPATH, value, 1024);\n\t\t\t\tSetKeyValue (g_qeglobals.d_project_entity, \"texturepath\", value);\n\t\t\t\t// Timo\n\t\t\t\t// read additional fields\n\t\t\t\tif ( IsDlgButtonChecked( hwndDlg, IDC_CHECK_BPRIMIT ) )\n\t\t\t\t{\n\t\t\t\t\tg_qeglobals.m_bBrushPrimitMode = TRUE;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tg_qeglobals.m_bBrushPrimitMode = FALSE;\n\t\t\t\t}\n\t\t\t\tSetKeyValue ( g_qeglobals.d_project_entity, \"brush_primit\", ( g_qeglobals.m_bBrushPrimitMode ? \"1\" : \"0\" ) );\n\n\t\t\t\tEndDialog(hwndDlg, 1);\n\t\t\t\tQE_SaveProject(g_strProject);\n\t\t\t\treturn TRUE;\n\n\t\t\tcase IDCANCEL:\n\t\t\t\tEndDialog(hwndDlg, 0);\n\t\t\t\treturn TRUE;\n\t\t}\n\t}\n\treturn FALSE;\n}\n\nvoid DoProjectSettings()\n{\n\tDialogBox(g_qeglobals.d_hInstance, (char *)IDD_PROJECT, g_qeglobals.d_hwndMain, ProjectDlgProc);\n}\n\n\n\nBOOL CALLBACK GammaDlgProc (\n    HWND hwndDlg,\t// handle to dialog box\n    UINT uMsg,\t// message\n    WPARAM wParam,\t// first message parameter\n    LPARAM lParam \t// second message parameter\n   )\n{\n\tchar sz[256];\n\n\tswitch (uMsg)\n    {\n\tcase WM_INITDIALOG:\n\t\tsprintf(sz, \"%1.1f\", g_qeglobals.d_savedinfo.fGamma);\t\t\n\t\tSetWindowText(GetDlgItem(hwndDlg, IDC_G_EDIT), sz);\n\t\treturn TRUE;\n\tcase WM_COMMAND: \n\t\tswitch (LOWORD(wParam)) \n\t\t{ \n\t\t\n\t\tcase IDOK:\n\t\t\tGetWindowText(GetDlgItem(hwndDlg, IDC_G_EDIT), sz, 255);\n\t\t\tg_qeglobals.d_savedinfo.fGamma = atof(sz);\n\t\t\tEndDialog(hwndDlg, 1);\n\t\t\treturn TRUE;\n\n\t\tcase IDCANCEL:\n\t\t\tEndDialog(hwndDlg, 0);\n\t\t\treturn TRUE;\n\t\t}\n\t}\n\treturn FALSE;\n}\n\n\n\nvoid DoGamma(void)\n{\n\tif ( DialogBox(g_qeglobals.d_hInstance, (char *)IDD_GAMMA, g_qeglobals.d_hwndMain, GammaDlgProc))\n\t{\n\t}\n}\t\t\n\n//================================================\n\n\nvoid SelectBrush (int entitynum, int brushnum)\n{\n\tentity_t\t*e;\n\tbrush_t\t\t*b;\n\tint\t\t\ti;\n\n\tif (entitynum == 0)\n\t\te = world_entity;\n\telse\n\t{\n\t\te = entities.next;\n\t\twhile (--entitynum)\n\t\t{\n\t\t\te=e->next;\n\t\t\tif (e == &entities)\n\t\t\t{\n\t\t\t\tSys_Status (\"No such entity.\", 0);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\tb = e->brushes.onext;\n\tif (b == &e->brushes)\n\t{\n\t\tSys_Status (\"No such brush.\", 0);\n\t\treturn;\n\t}\n\twhile (brushnum--)\n\t{\n\t\tb=b->onext;\n\t\tif (b == &e->brushes)\n\t\t{\n\t\t\tSys_Status (\"No such brush.\", 0);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tBrush_RemoveFromList (b);\n\tBrush_AddToList (b, &selected_brushes);\n\n\n\tSys_UpdateWindows (W_ALL);\n\tfor (i=0 ; i<3 ; i++)\n  {\n    if (g_pParentWnd->GetXYWnd())\n      g_pParentWnd->GetXYWnd()->GetOrigin()[i] = (b->mins[i] + b->maxs[i])/2;\n\n    if (g_pParentWnd->GetXZWnd())\n      g_pParentWnd->GetXZWnd()->GetOrigin()[i] = (b->mins[i] + b->maxs[i])/2;\n    \n    if (g_pParentWnd->GetYZWnd())\n      g_pParentWnd->GetYZWnd()->GetOrigin()[i] = (b->mins[i] + b->maxs[i])/2;\n  }\n\n\tSys_Status (\"Selected.\", 0);\n}\n\n/*\n=================\nGetSelectionIndex\n=================\n*/\nvoid GetSelectionIndex (int *ent, int *brush)\n{\n\tbrush_t\t\t*b, *b2;\n\tentity_t\t*entity;\n\n\t*ent = *brush = 0;\n\n\tb = selected_brushes.next;\n\tif (b == &selected_brushes)\n\t\treturn;\n\n\t// find entity\n\tif (b->owner != world_entity)\n\t{\n\t\t(*ent)++;\n\t\tfor (entity = entities.next ; entity != &entities \n\t\t\t; entity=entity->next, (*ent)++)\n\t\t;\n\t}\n\n\t// find brush\n\tfor (b2=b->owner->brushes.onext \n\t\t; b2 != b && b2 != &b->owner->brushes\n\t\t; b2=b2->onext, (*brush)++)\n\t;\n}\n\nBOOL CALLBACK FindBrushDlgProc (\n    HWND hwndDlg,\t// handle to dialog box\n    UINT uMsg,\t// message\n    WPARAM wParam,\t// first message parameter\n    LPARAM lParam \t// second message parameter\n   )\n{\n\tchar entstr[256];\n\tchar brushstr[256];\n\tHWND\th;\n\tint\t\tent, brush;\n\n\tswitch (uMsg)\n    {\n\tcase WM_INITDIALOG:\n\t\t// set entity and brush number\n\t\tGetSelectionIndex (&ent, &brush);\n\t\tsprintf (entstr, \"%i\", ent);\n\t\tsprintf (brushstr, \"%i\", brush);\n\t\tSetWindowText(GetDlgItem(hwndDlg, IDC_FIND_ENTITY), entstr);\n\t\tSetWindowText(GetDlgItem(hwndDlg, IDC_FIND_BRUSH), brushstr);\n\n\t\th = GetDlgItem(hwndDlg, IDC_FIND_ENTITY);\n\t\tSetFocus (h);\n\t\treturn FALSE;\n\n\tcase WM_COMMAND: \n\t\tswitch (LOWORD(wParam)) \n\t\t{ \n\t\t\tcase IDOK:\n\t\t\t\tGetWindowText(GetDlgItem(hwndDlg, IDC_FIND_ENTITY), entstr, 255);\n\t\t\t\tGetWindowText(GetDlgItem(hwndDlg, IDC_FIND_BRUSH), brushstr, 255);\n\t\t\t\tSelectBrush (atoi(entstr), atoi(brushstr));\n\t\t\t\tEndDialog(hwndDlg, 1);\n\t\t\t\treturn TRUE;\n\n\t\t\tcase IDCANCEL:\n\t\t\t\tEndDialog(hwndDlg, 0);\n\t\t\t\treturn TRUE;\n\t\t}\t\n\t}\n\treturn FALSE;\n}\n\n\n\nvoid DoFind(void)\n{\n\tDialogBox(g_qeglobals.d_hInstance, (char *)IDD_FINDBRUSH, g_qeglobals.d_hwndMain, FindBrushDlgProc);\n}\t\n\t\n/*\n===================================================\n\n  ARBITRARY ROTATE\n\n===================================================\n*/\n\n\nBOOL CALLBACK RotateDlgProc (\n    HWND hwndDlg,\t// handle to dialog box\n    UINT uMsg,\t// message\n    WPARAM wParam,\t// first message parameter\n    LPARAM lParam \t// second message parameter\n   )\n{\n\tchar\tstr[256];\n\tHWND\th;\n\tfloat\tv;\n\n\tswitch (uMsg)\n    {\n\tcase WM_INITDIALOG:\n\t\th = GetDlgItem(hwndDlg, IDC_FIND_ENTITY);\n\t\tSetFocus (h);\n\t\treturn FALSE;\n\n\tcase WM_COMMAND: \n\t\tswitch (LOWORD(wParam)) \n\t\t{ \n\t\t\n\t\tcase IDOK:\n\t\t\tGetWindowText(GetDlgItem(hwndDlg, IDC_ROTX), str, 255);\n\t\t\tv = atof(str);\n\t\t\tif (v)\n\t\t\t\tSelect_RotateAxis (0, v);\n\n\t\t\tGetWindowText(GetDlgItem(hwndDlg, IDC_ROTY), str, 255);\n\t\t\tv = atof(str);\n\t\t\tif (v)\n\t\t\t\tSelect_RotateAxis (1, v);\n\n\t\t\tGetWindowText(GetDlgItem(hwndDlg, IDC_ROTZ), str, 255);\n\t\t\tv = atof(str);\n\t\t\tif (v)\n\t\t\t\tSelect_RotateAxis (2, v);\n\n\t\t\tEndDialog(hwndDlg, 1);\n\t\t\treturn TRUE;\n\n\t\tcase IDCANCEL:\n\t\t\tEndDialog(hwndDlg, 0);\n\t\t\treturn TRUE;\n\t\t}\t\n\t}\n\n\treturn FALSE;\n}\n\n\n\nvoid DoRotate(void)\n{\n\tDialogBox(g_qeglobals.d_hInstance, (char *)IDD_ROTATE, g_qeglobals.d_hwndMain, RotateDlgProc);\n}\n\t\t\n/*\n===================================================\n\n  ARBITRARY SIDES\n\n===================================================\n*/\n\nbool g_bDoCone = false;\nbool g_bDoSphere = false;\nBOOL CALLBACK SidesDlgProc (\n    HWND hwndDlg,\t// handle to dialog box\n    UINT uMsg,\t// message\n    WPARAM wParam,\t// first message parameter\n    LPARAM lParam \t// second message parameter\n   )\n{\n\tchar str[256];\n\tHWND\th;\n\n\tswitch (uMsg)\n    {\n\tcase WM_INITDIALOG:\n\t\th = GetDlgItem(hwndDlg, IDC_SIDES);\n\t\tSetFocus (h);\n\t\treturn FALSE;\n\n\tcase WM_COMMAND: \n\t\tswitch (LOWORD(wParam)) { \n\t\t\n\t\tcase IDOK:\n\t\t\tGetWindowText(GetDlgItem(hwndDlg, IDC_SIDES), str, 255);\n      if (g_bDoCone)\n\t\t\t  Brush_MakeSidedCone(atoi(str));\n      else if (g_bDoSphere)\n\t\t\t  Brush_MakeSidedSphere(atoi(str));\n      else\n\t\t\t  Brush_MakeSided (atoi(str));\n\n\t\t\tEndDialog(hwndDlg, 1);\n\t\tbreak;\n\n\t\tcase IDCANCEL:\n\t\t\tEndDialog(hwndDlg, 0);\n\t\tbreak;\n\t}\t\n\tdefault:\n\t\treturn FALSE;\n\t}\n}\n\n\nvoid DoSides(bool bCone, bool bSphere, bool bTorus)\n{\n  g_bDoCone = bCone;\n  g_bDoSphere = bSphere;\n  //g_bDoTorus = bTorus;\n\tDialogBox(g_qeglobals.d_hInstance, (char *)IDD_SIDES, g_qeglobals.d_hwndMain, SidesDlgProc);\n}\t\t\n\n\n//======================================================================\n\n/*\n===================\nDoAbout\n===================\n*/\nBOOL CALLBACK AboutDlgProc( HWND hwndDlg,\n\t\t\t\t\t\t    UINT uMsg,\n\t\t\t\t\t\t    WPARAM wParam,\n\t\t\t\t\t\t    LPARAM lParam )\n{\n\tswitch (uMsg)\n    {\n\tcase WM_INITDIALOG:\n\t\t{\n\t\t\tchar renderer[1024];\n\t\t\tchar version[1024];\n\t\t\tchar vendor[1024];\n\t\t\tchar extensions[4096];\n\n\t\t\tsprintf( renderer, \"Renderer:\\t%s\", qglGetString( GL_RENDERER ) );\n\t\t\tsprintf( version, \"Version:\\t\\t%s\", qglGetString( GL_VERSION ) );\n\t\t\tsprintf( vendor, \"Vendor:\\t\\t%s\", qglGetString( GL_VENDOR ) );\n\t\t\tsprintf( extensions, \"%s\", qglGetString( GL_EXTENSIONS ) );\n\n\t\t\tSetWindowText( GetDlgItem( hwndDlg, IDC_ABOUT_GLRENDERER ),   renderer );\n\t\t\tSetWindowText( GetDlgItem( hwndDlg, IDC_ABOUT_GLVERSION ),    version );\n\t\t\tSetWindowText( GetDlgItem( hwndDlg, IDC_ABOUT_GLVENDOR ),     vendor );\n\t\t\tSetWindowText( GetDlgItem( hwndDlg, IDC_ABOUT_GLEXTENSIONS ), extensions );\n\n\t\t}\n\t\treturn TRUE;\n\n\tcase WM_CLOSE:\n\t\tEndDialog( hwndDlg, 1 );\n\t\treturn TRUE;\n\n\tcase WM_COMMAND:\n\t\tif ( LOWORD( wParam ) == IDOK )\n\t\t\tEndDialog(hwndDlg, 1);\n\t\treturn TRUE;\n\t}\n\treturn FALSE;\n}\n\nvoid DoAbout(void)\n{\n\tDialogBox( g_qeglobals.d_hInstance, ( char * ) IDD_ABOUT, g_qeglobals.d_hwndMain, AboutDlgProc );\n}\n\n\n"
  },
  {
    "path": "q3radiant/WIN_QE3.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"stdafx.h\"\n#include \"qe3.h\"\n#include \"mru.h\"\n#include \"PrefsDlg.h\"\n\n////////////////////////////////////////////////////////////////////////////\n// BSP frontend plugin\n// global flag for BSP frontend plugin is g_qeglobals.bBSPFrontendPlugin\n_QERPlugBSPFrontendTable g_BSPFrontendTable;\nCStringArray g_BSPFrontendCommands;\n\nextern CEdit* g_pEdit;\n\nint\tscreen_width;\nint\tscreen_height;\nqboolean\thave_quit;\n\nint\tupdate_bits;\n\nHANDLE\tbsp_process;\n\n//===========================================\n\nvoid Sys_MarkMapModified (void)\n{\n\tchar\t\t\ttitle[1024];\n\n\tif (modified != 1)\n\t{\n\t\tmodified = true;\t// mark the map as changed\n\t\tsprintf (title, \"%s *\", currentmap);\n\n\t\tQE_ConvertDOSToUnixName( title, title );\n\t\tSys_SetTitle (title);\n\t}\n}\n\n\nvoid Sys_SetTitle (char *text)\n{\n\tSetWindowText (g_qeglobals.d_hwndMain, text);\n}\n\nHCURSOR\twaitcursor;\n\nvoid Sys_BeginWait (void)\n{\n\twaitcursor = SetCursor (LoadCursor (NULL, IDC_WAIT));\n}\n\nvoid Sys_EndWait (void)\n{\n\tif (waitcursor)\n\t{\n\t\tSetCursor (waitcursor);\n\t\twaitcursor = NULL;\n\t}\n}\n\n\nvoid Sys_GetCursorPos (int *x, int *y)\n{\n\tPOINT lpPoint;\n\n\tGetCursorPos (&lpPoint);\n\t*x = lpPoint.x;\n\t*y = lpPoint.y;\n}\n\nvoid Sys_SetCursorPos (int x, int y)\n{\n\tSetCursorPos (x, y);\n}\n\n\nvoid Sys_Beep (void)\n{\n\tMessageBeep (MB_ICONASTERISK);\n}\n\nchar\t*TranslateString (char *buf)\n{\n\tstatic\tchar\tbuf2[32768];\n\tint\t\ti, l;\n\tchar\t*out;\n\n\tl = strlen(buf);\n\tout = buf2;\n\tfor (i=0 ; i<l ; i++)\n\t{\n\t\tif (buf[i] == '\\n')\n\t\t{\n\t\t\t*out++ = '\\r';\n\t\t\t*out++ = '\\n';\n\t\t}\n\t\telse\n\t\t\t*out++ = buf[i];\n\t}\n\t*out++ = 0;\n\n\treturn buf2;\n}\n\n\nvoid Sys_ClearPrintf (void)\n{\n\tchar\ttext[4];\n\ttext[0] = 0;\n\n  SendMessage (g_qeglobals.d_hwndEdit, WM_SETTEXT, 0,\t(LPARAM)text);\n}\n\n\n#define SCROLLBACK_MAX_LINES\t600\n#define SCROLLBACK_DEL_CHARS\t500\n\nvoid Sys_Printf (char *text, ...)\n{\n\tva_list argptr;\n\tchar\tbuf[32768];\n\tchar\t*out;\n\tLRESULT\tresult;\t\t\t\t// PGM\n\tDWORD\toldPosS, oldPosE;\t// PGM\n\n\tva_start (argptr,text);\n\tvsprintf (buf, text,argptr);\n\tva_end (argptr);\n\n\tout = TranslateString (buf);\n\n#ifdef LATER\n\tSys_Status(out);\n#else\n//PGM\n\tresult = SendMessage (g_qeglobals.d_hwndEdit, EM_GETLINECOUNT, 0, 0);\n\tif(result > SCROLLBACK_MAX_LINES)\n\t{\n\t\tchar\treplaceText[5];\n\t\t\n\t\treplaceText[0] = '\\0';\n\n\t\tSendMessage (g_qeglobals.d_hwndEdit, WM_SETREDRAW, (WPARAM)0, (LPARAM)0);\n\t\tSendMessage (g_qeglobals.d_hwndEdit, EM_GETSEL, (WPARAM)&oldPosS, (LPARAM)&oldPosE);\n\t\tSendMessage (g_qeglobals.d_hwndEdit, EM_SETSEL, 0, SCROLLBACK_DEL_CHARS);\n\t\tSendMessage (g_qeglobals.d_hwndEdit, EM_REPLACESEL, (WPARAM)0, (LPARAM)replaceText);\n\t\tSendMessage (g_qeglobals.d_hwndEdit, EM_SETSEL, oldPosS, oldPosE);\n\t\tSendMessage (g_qeglobals.d_hwndEdit, WM_SETREDRAW, (WPARAM)1, (LPARAM)0);\n\t}\n//PGM\n\n\tSendMessage (g_qeglobals.d_hwndEdit, EM_REPLACESEL, 0, (LPARAM)out);\n#endif\n\n}\n\n\ndouble Sys_DoubleTime (void)\n{\n\treturn clock()/ 1000.0;\n}\n\nvoid PrintPixels (HDC hDC)\n{\n\tint\t\ti;\n\tPIXELFORMATDESCRIPTOR p[64];\n\n\tprintf (\"### flags color layer\\n\");\n\tfor (i=1 ; i<64 ; i++)\n\t{\n\t\tif (!DescribePixelFormat ( hDC, i, sizeof(p[0]), &p[i]))\n\t\t\tbreak;\n\t\tprintf (\"%3i %5i %5i %5i\\n\", i,\n\t\t\tp[i].dwFlags,\n\t\t\tp[i].cColorBits,\n\t\t\tp[i].bReserved);\n\t}\n\tprintf (\"%i modes\\n\", i-1);\n}\n\n\n\n//==========================================================================\n\nvoid QEW_StopGL( HWND hWnd, HGLRC hGLRC, HDC hDC )\n{\n  qwglMakeCurrent( NULL, NULL );\n  qwglDeleteContext( hGLRC );\n\tReleaseDC( hWnd, hDC );\n}\n\t\t\nint WINAPI QEW_SetupPixelFormat(HDC hDC, qboolean zbuffer )\n{\n    static PIXELFORMATDESCRIPTOR pfd = {\n\t\tsizeof(PIXELFORMATDESCRIPTOR),\t// size of this pfd\n\t\t1,\t\t\t\t\t\t\t\t              // version number\n\t\tPFD_DRAW_TO_WINDOW |\t\t\t      // support window\n\t\tPFD_SUPPORT_OPENGL |\t\t\t      // support OpenGL\n\t\tPFD_DOUBLEBUFFER,\t\t\t\t        // double buffered\n\t\tPFD_TYPE_RGBA,\t\t\t\t\t        // RGBA type\n\t\t24,\t\t\t\t\t\t\t\t              // 24-bit color depth\n\t\t0, 0, 0, 0, 0, 0,\t              // color bits ignored\n\t\t0,\t\t\t\t\t\t\t\t              // no alpha buffer\n\t\t0,\t\t\t\t\t\t\t\t              // shift bit ignored\n\t\t0,\t\t\t\t\t\t\t\t              // no accumulation buffer\n\t\t0, 0, 0, 0,\t\t\t\t\t\t          // accum bits ignored\n\t\t32,\t\t\t\t\t\t\t                // depth bits\n\t\t0,\t\t\t\t\t\t\t\t              // no stencil buffer\n\t\t0,\t\t\t\t\t\t\t\t              // no auxiliary buffer\n\t\tPFD_MAIN_PLANE,\t\t\t\t\t        // main layer\n\t\t0,\t\t\t\t\t\t\t\t              // reserved\n\t\t0, 0, 0\t\t\t\t\t\t\t            // layer masks ignored\n    };                              //\n    int pixelformat = 0;            \n\n\tzbuffer = true;\n\tif ( !zbuffer )\n\t\tpfd.cDepthBits = 0;\n\n  if (g_PrefsDlg.m_bSGIOpenGL)\n  {\n    if ( (pixelformat = qwglChoosePixelFormat(hDC, &pfd)) == 0 )\n    {\n\t    printf(\"%d\",GetLastError());\n      Error (\"ChoosePixelFormat failed\");\n    }\n  \n    if (!qwglSetPixelFormat(hDC, pixelformat, &pfd))\n      Error (\"SetPixelFormat failed\");\n  }\n  else\n  {\n    if ( (pixelformat = ChoosePixelFormat(hDC, &pfd)) == 0 )\n    {\n\t    printf(\"%d\",GetLastError());\n      Error (\"ChoosePixelFormat failed\");\n    }\n\n    if (!SetPixelFormat(hDC, pixelformat, &pfd))\n      Error (\"SetPixelFormat failed\");\n  }\n\n\treturn pixelformat;\n}\n\n/*\n=================\nError\n\nFor abnormal program terminations\n=================\n*/\nvoid Error (char *error, ...)\n{\n\tva_list argptr;\n\tchar\ttext[1024];\n\tchar\ttext2[1024];\n\tint\t\terr;\n\t\n\terr = GetLastError ();\n\tint i = qglGetError();\n\t\n\tva_start (argptr,error);\n\tvsprintf (text, error,argptr);\n\tva_end (argptr);\n\t\n\tsprintf (text2, \"%s\\nGetLastError() = %i - %i\\nAn unrecoverable error has occured. Would you like to edit Preferences before exiting Q3Radiant?\", text, err, i);\n\t\n\tif (MessageBox(g_qeglobals.d_hwndMain, text2, \"Error\", MB_YESNO) == IDYES)\n\t{\n\t\tg_PrefsDlg.LoadPrefs();\n\t\tg_PrefsDlg.DoModal();\n\t}\n\t\n\texit (1);\n}\n\n\nvoid Warning (char *error, ...)\n{\n\tva_list argptr;\n\tchar\ttext[1024];\n\tint\t\terr;\n\n\terr = GetLastError ();\n  int i = qglGetError();\n\n\tva_start (argptr,error);\n\tvsprintf (text, error,argptr);\n\tva_end (argptr);\n\n  Sys_Printf(text);\n}\n\n\n/*\n======================================================================\n\nFILE DIALOGS\n\n======================================================================\n*/\n \nqboolean ConfirmModified (void)\n{\n\tif (!modified)\n\t\treturn true;\n\n\tif (MessageBox (g_qeglobals.d_hwndMain, \"This will lose changes to the map\"\n\t\t, \"warning\", MB_OKCANCEL) == IDCANCEL)\n\t\treturn false;\n\treturn true;\n}\n\nstatic OPENFILENAME ofn;       /* common dialog box structure   */ \nstatic char szDirName[MAX_PATH];    /* directory string              */ \nstatic char szFile[260];       /* filename string               */ \nstatic char szFileTitle[260];  /* file title string             */ \nstatic char szFilter[260] =     /* filter string                 */ \n\t\"Map file (*.map, *.reg)\\0*.map\\0*.reg\\0\\0\";\nstatic char szProjectFilter[260] =     /* filter string                 */ \n\t\"Q3Radiant project (*.qe4, *.prj)\\0*.qe4\\0*.prj\\0\\0\";\nstatic char chReplace;         /* string separator for szFilter */ \nstatic int i, cbString;        /* integer count variables       */ \nstatic HANDLE hf;              /* file handle                   */ \n\nvoid OpenDialog (void)\n{\n\t/* \n\t * Obtain the system directory name and \n\t * store it in szDirName. \n\t */ \n \n\tstrcpy (szDirName, ValueForKey (g_qeglobals.d_project_entity, \"mapspath\") );\n  if (strlen(szDirName) == 0)\n  {\n\t  strcpy (szDirName, ValueForKey (g_qeglobals.d_project_entity, \"basepath\") );\n\t  strcat (szDirName, \"\\\\maps\");\n  }\n\n\t/* Place the terminating null character in the szFile. */ \n \n\tszFile[0] = '\\0'; \n \n\t/* Set the members of the OPENFILENAME structure. */ \n \n\tofn.lStructSize = sizeof(OPENFILENAME); \n\tofn.hwndOwner = g_qeglobals.d_hwndCamera;\n\tofn.lpstrFilter = szFilter; \n\tofn.nFilterIndex = 1; \n\tofn.lpstrFile = szFile; \n\tofn.nMaxFile = sizeof(szFile); \n\tofn.lpstrFileTitle = szFileTitle; \n\tofn.nMaxFileTitle = sizeof(szFileTitle); \n\tofn.lpstrInitialDir = szDirName; \n\tofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | \n\t\tOFN_FILEMUSTEXIST; \n\n\t/* Display the Open dialog box. */ \n \n\tif (!GetOpenFileName(&ofn))\n\t\treturn;\t// canceled\n \n\t// Add the file in MRU.\n  //FIXME\n\tAddNewItem( g_qeglobals.d_lpMruMenu, ofn.lpstrFile);\n\n\t// Refresh the File menu.\n  //FIXME\n\tPlaceMenuMRUItem(g_qeglobals.d_lpMruMenu,GetSubMenu(GetMenu(g_qeglobals.d_hwndMain),0), \n\t\t\tID_FILE_EXIT);\n\n\t/* Open the file. */ \n \n\tMap_LoadFile (ofn.lpstrFile);\t\n}\n\nvoid ProjectDialog (void)\n{\n\t/* \n\t * Obtain the system directory name and \n\t * store it in szDirName. \n\t */ \n \n\tstrcpy (szDirName, ValueForKey(g_qeglobals.d_project_entity, \"basepath\") );\n\tstrcat (szDirName, \"\\\\scripts\");\n\n\t/* Place the terminating null character in the szFile. */ \n \n\tszFile[0] = '\\0'; \n \n\t/* Set the members of the OPENFILENAME structure. */ \n \n\tofn.lStructSize = sizeof(OPENFILENAME); \n\tofn.hwndOwner = g_qeglobals.d_hwndCamera;\n\tofn.lpstrFilter = szProjectFilter; \n\tofn.nFilterIndex = 1; \n\tofn.lpstrFile = szFile; \n\tofn.nMaxFile = sizeof(szFile); \n\tofn.lpstrFileTitle = szFileTitle; \n\tofn.nMaxFileTitle = sizeof(szFileTitle); \n\tofn.lpstrInitialDir = szDirName; \n\tofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | \n\t\tOFN_FILEMUSTEXIST; \n\n\t/* Display the Open dialog box. */ \n \n\tif (!GetOpenFileName(&ofn))\n\t\treturn;\t// canceled\n \n\t// Refresh the File menu.\n\tPlaceMenuMRUItem(g_qeglobals.d_lpMruMenu,GetSubMenu(GetMenu(g_qeglobals.d_hwndMain),0), \n\t\t\tID_FILE_EXIT);\n\n\t/* Open the file. */ \n\tif (!QE_LoadProject(ofn.lpstrFile))\n\t\tError (\"Couldn't load project file\");\n}\n\n\nextern void AddSlash(CString& strPath);\nvoid SaveAsDialog (bool bRegion)\n{ \n\tstrcpy (szDirName, ValueForKey (g_qeglobals.d_project_entity, \"basepath\") );\n  CString strPath = szDirName;\n  AddSlash(strPath);\n  strPath += \"maps\";\n\n\t/* Place the terminating null character in the szFile. */ \n \n\tszFile[0] = '\\0'; \n \n\t/* Set the members of the OPENFILENAME structure. */ \n \n\tofn.lStructSize = sizeof(OPENFILENAME); \n\tofn.hwndOwner = g_qeglobals.d_hwndCamera;\n\tofn.lpstrFilter = szFilter; \n\tofn.nFilterIndex = 1; \n\tofn.lpstrFile = szFile; \n\tofn.nMaxFile = sizeof(szFile); \n\tofn.lpstrFileTitle = szFileTitle; \n\tofn.nMaxFileTitle = sizeof(szFileTitle); \n\tofn.lpstrInitialDir = strPath; \n\tofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | \n\t\tOFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT; \n\n\t/* Display the Open dialog box. */ \n \n\tif (!GetSaveFileName(&ofn))\n\t\treturn;\t// canceled\n\n  if (bRegion)\n\t  DefaultExtension (ofn.lpstrFile, \".reg\");\n  else\n\t  DefaultExtension (ofn.lpstrFile, \".map\");\n\n  if (!bRegion)\n  {\n\t  strcpy (currentmap, ofn.lpstrFile);\n    AddNewItem(g_qeglobals.d_lpMruMenu, ofn.lpstrFile);\n\t  PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu,GetSubMenu(GetMenu(g_qeglobals.d_hwndMain),0),\tID_FILE_EXIT);\n  }\n\tMap_SaveFile (ofn.lpstrFile, bRegion);\t// ignore region\n}\n\n/*\n=======================================================\n\nMenu modifications\n\n=======================================================\n*/\n\n/*\n==================\nFillBSPMenu\n\n==================\n*/\nchar\t*bsp_commands[256];\n\nvoid FillBSPMenu (void)\n{\n\tHMENU\thmenu;\n\tepair_t\t*ep;\n\tint\t\ti;\n\tstatic int count;\n\n\thmenu = GetSubMenu (GetMenu(g_qeglobals.d_hwndMain), MENU_BSP);\n\n\tfor (i=0 ; i<count ; i++)\n\t\tDeleteMenu (hmenu, CMD_BSPCOMMAND+i, MF_BYCOMMAND);\n\tcount = 0;\n\n\tif ( g_qeglobals.bBSPFrontendPlugin )\n\t{\n\t\tCString str = g_BSPFrontendTable.m_pfnGetBSPMenu();\n\t\tchar cTemp[1024];\n\t\tstrcpy(cTemp, str);\n\t\tchar* token = strtok(cTemp, \",;\");\n\t\tif (token && *token == ' ')\n\t\t{\n\t\t\twhile (*token == ' ')\n\t\t\t\ttoken++;\n\t\t}\n\t\ti = 0;\n\t\t// first token is menu name\n\t\tModifyMenu( GetMenu(g_qeglobals.d_hwndMain), MENU_BSP, MF_BYPOSITION, MENU_BSP, (LPCTSTR)token );\n\t\t// redraw the menu bar\n\t\tDrawMenuBar( g_qeglobals.d_hwndMain );\n\t\ttoken = strtok(NULL, \",;\");\n\t\twhile (token != NULL)\n\t\t{\n\t\t\tg_BSPFrontendCommands.Add(token);\n\t\t\tAppendMenu (hmenu, MF_ENABLED|MF_STRING, CMD_BSPCOMMAND+i, (LPCTSTR)token );\n\t\t\ttoken = strtok(NULL, \",;\");\n\t\t\ti++;\n\t\t}\n\t\tcount = i;\n\t}\n\telse\n\t{\n\t\ti = 0;\n\t\tfor (ep = g_qeglobals.d_project_entity->epairs ; ep ; ep=ep->next)\n\t\t{\n\t\t\tif (ep->key[0] == 'b' && ep->key[1] == 's' && ep->key[2] == 'p')\n\t\t\t{\n\t\t\t\tbsp_commands[i] = ep->key;\n\t\t\t\tAppendMenu (hmenu, MF_ENABLED|MF_STRING,\n\t\t\t\t\tCMD_BSPCOMMAND+i, (LPCTSTR)ep->key);\n\t\t\t\ti++;\n\t\t\t}\n\t\t}\n\t\tcount = i;\n\t}\n}\n\n//==============================================\nvoid AddSlash(CString& strPath)\n{\n  if (strPath.GetLength() > 0)\n  {\n    if (strPath.GetAt(strPath.GetLength()-1) != '\\\\')\n      strPath += '\\\\';\n  }\n}\n\n\nbool ExtractPath_and_Filename(const char* pPath, CString& strPath, CString& strFilename)\n{\n  CString strPathName = pPath;\n  int nSlash = strPathName.ReverseFind('\\\\');\n  if (nSlash >= 0)\n  {\n    strPath = strPathName.Left(nSlash+1);\n    strFilename = strPathName.Right(strPathName.GetLength() - nSlash - 1);\n  }\n  else strFilename = pPath;\n  return true;\n}\n\n\n/*\n===============\nCheckBspProcess\n\nSee if the BSP is done yet\n===============\n*/\nextern void FindReplace(CString& strContents, const char* pTag, const char* pValue);\nextern CTime g_tBegin;\n\nvoid CheckBspProcess (void)\n{\n\tchar\toutputpath[1024];\n\tchar\ttemppath[512];\n\tDWORD\texitcode;\n\tchar\t*out;\n\tBOOL\tret;\n\n\tif (!bsp_process)\n\t\treturn;\n\n\tret = GetExitCodeProcess (bsp_process, &exitcode);\n\tif (!ret)\n\t\tError (\"GetExitCodeProcess failed\");\n\tif (exitcode == STILL_ACTIVE)\n\t\treturn;\n\n\tbsp_process = 0;\n\n\tGetTempPath(512, temppath);\n\tsprintf (outputpath, \"%sjunk.txt\", temppath);\n\n\tLoadFile (outputpath, (void **)&out);\n\tSys_Printf (\"%s\", out);\n\tSys_Printf (\"\\ncompleted.\\n\");\n\tfree (out);\n\n\tCTime tEnd = CTime::GetCurrentTime();\n\tCTimeSpan tElapsed = tEnd - g_tBegin;\n\tCString strElapsed;\n\tstrElapsed.Format(\"Run time was %i hours, %i minutes and %i seconds\", tElapsed.GetHours(), tElapsed.GetMinutes(), tElapsed.GetSeconds());\n\tSys_Printf(strElapsed.GetBuffer(0));\n\n\n\tSys_Beep ();\n\tPointfile_Check();\n\t// run game if no PointFile and pref is set\n\t//++timo needs to stop after BSP if leaked .. does run through vis and light instead ..\n\tif (g_PrefsDlg.m_bRunQuake == TRUE  && !g_qeglobals.d_pointfile_display_list)\n\t{\n\t\tchar cCurDir[1024];\n\t\tGetCurrentDirectory(1024, cCurDir);\n\t\tCString strExePath = g_PrefsDlg.m_strQuake2;\n\t\tCString strOrgPath;\n\t\tCString strOrgFile;\n\t\tExtractPath_and_Filename(currentmap, strOrgPath, strOrgFile);\n\t\tif (g_PrefsDlg.m_bSetGame == TRUE) // run in place with set game.. don't copy map\n\t\t{\n\t\t\tCString strBasePath = ValueForKey(g_qeglobals.d_project_entity, \"basepath\");\n\t\t\tstrExePath += \" +set game \";\n\t\t\tstrExePath += strBasePath;\n\t\t\tWinExec(strExePath, SW_SHOW);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tCString strCopyPath = strExePath;\n\t\t\tchar* pBuffer = strCopyPath.GetBufferSetLength(_MAX_PATH + 1);\n\t\t\tpBuffer[strCopyPath.ReverseFind('\\\\') + 1] = '\\0';\n\t\t\tstrCopyPath.ReleaseBuffer();\n\t\t\tSetCurrentDirectory(strCopyPath);\n\t\t\tCString strOrgPath;\n\t\t\tCString strOrgFile;\n\t\t\tExtractPath_and_Filename(currentmap, strOrgPath, strOrgFile);\n\t\t\tAddSlash(strCopyPath);\n\t\t\tFindReplace(strOrgFile, \".map\", \".bsp\");\n\t\t\t//++timo modified for Quake3 !!\n\t\t\tstrCopyPath += \"baseq3\\\\maps\\\\\";\n\t\t\tstrCopyPath += strOrgFile;\n\t\t\tAddSlash(strOrgPath);\n\t\t\tstrOrgPath += strOrgFile;\n\t\t\tbool bRun = (strOrgPath.CompareNoCase(strCopyPath) == 0);\n\t\t\tif (!bRun)\n\t\t\t\tbRun = (CopyFile(strOrgPath, strCopyPath, FALSE) == TRUE);\n\t\t\tif (bRun)\n\t\t\t{\n\t\t\t\tFindReplace(strOrgFile, \".bsp\", \"\");\n\t\t\t\tstrExePath += \" +map \";\n\t\t\t\tstrExePath += strOrgFile;\n\t\t\t\tWinExec(strExePath, SW_SHOW);\n\t\t\t}\n\t\t}\n\t\tSetCurrentDirectory(cCurDir);\n\t}\n}\n\nextern int\tcambuttonstate;\n\nextern \"C\" {\nvoid *Com_Allocate( int bytes ) {\n\treturn malloc(bytes);\n}\n\nvoid Com_Dealloc( void *ptr ) {\n\tfree(ptr);\n}\n\n\nvoid Com_Printf( const char *msg, ... ) {\n\tva_list argptr;\n\tchar\tbuf[32768];\n\tchar\t*out;\n\n\tva_start (argptr,msg);\n\tvsprintf (buf, msg,argptr);\n\tva_end (argptr);\n\n\tout = TranslateString (buf);\n\n\tSys_Printf(buf);\n}\n\nvoid Com_Error( int level, const char *error, ... ) {\n\tva_list argptr;\n\tchar\tbuf[32768];\n\tchar\t*out;\n\n\tva_start (argptr,error);\n\tvsprintf (buf, error,argptr);\n\tva_end (argptr);\n\n\tout = TranslateString (buf);\n\n\tSys_Printf(buf);\n}\n\nvoid Com_DPrintf( const char *msg, ... ) {\n\treturn;\n}\n\nint FS_Write( const void *buffer, int len, fileHandle_t h ) {\n\tSafeWrite(reinterpret_cast<FILE*>(h), buffer, len);\n\treturn len;\n}\n\nint FS_ReadFile( const char *qpath, void **buffer ) {\n\tCString strPath = ValueForKey(g_qeglobals.d_project_entity, \"basepath\");\n\tAddSlash(strPath);\n\tstrPath += qpath;\n\treturn LoadFile(strPath, buffer);\n}\n\nvoid FS_FreeFile( void *buffer ) {\n\tCom_Dealloc(buffer);\n}\n\nfileHandle_t FS_FOpenFileWrite( const char *filename ) {\n\tCString strPath = ValueForKey(g_qeglobals.d_project_entity, \"basepath\");\n\tAddSlash(strPath);\n\tstrPath += filename;\n\t// bad casting ptr to int\n\treturn reinterpret_cast<fileHandle_t>(SafeOpenWrite(strPath));\n}\n\nvoid FS_FCloseFile( fileHandle_t f ) {\n\tfclose(reinterpret_cast<FILE*>(f));\n}\n\n\n\n}\n\n"
  },
  {
    "path": "q3radiant/WIN_QE3.RC2",
    "content": "//Microsoft Developer Studio generated resource script.\n//\n#include \"resource.h\"\n\n#define APSTUDIO_READONLY_SYMBOLS\n/////////////////////////////////////////////////////////////////////////////\n//\n// Generated from the TEXTINCLUDE 2 resource.\n//\n#include \"afxres.h\"\n\n/////////////////////////////////////////////////////////////////////////////\n#undef APSTUDIO_READONLY_SYMBOLS\n\n/////////////////////////////////////////////////////////////////////////////\n// English (U.S.) resources\n\n#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\n#ifdef _WIN32\nLANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\n#pragma code_page(1252)\n#endif //_WIN32\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Menu\n//\n\nIDR_MENU1 MENU DISCARDABLE \nBEGIN\n    POPUP \"&File\"\n    BEGIN\n        MENUITEM \"&New\",                        ID_FILE_NEW\n        MENUITEM \"&Open\",                       ID_FILE_OPEN\n        MENUITEM \"&Save\",                       ID_FILE_SAVE\n        MENUITEM \"Save &as...\",                 ID_FILE_SAVEAS\n        MENUITEM \"&Pointfile\",                  ID_FILE_POINTFILE\n        MENUITEM \"Load &project\",               ID_FILE_LOADPROJECT\n        MENUITEM \"E&xit\",                       ID_FILE_EXIT\n    END\n    POPUP \"&Edit\"\n    BEGIN\n        MENUITEM \"&Copy brush\",                 ID_EDIT_COPYBRUSH, GRAYED\n        MENUITEM \"&Paste brush\",                ID_EDIT_PASTEBRUSH, GRAYED\n    END\n    POPUP \"&View\"\n    BEGIN\n        MENUITEM \"Texture View\\tT\",             ID_VIEW_TEXTURE\n        MENUITEM \"Console View\\tO\",             ID_VIEW_CONSOLE\n        MENUITEM \"Entity View\\tN\",              ID_VIEW_ENTITY\n        MENUITEM SEPARATOR\n        MENUITEM \"&Center\\tEnd\",                ID_VIEW_CENTER\n        MENUITEM \"&Up Floor\\tPage Up\",          ID_VIEW_UPFLOOR\n        MENUITEM \"&Down Floor\\tPage Down\",      ID_VIEW_DOWNFLOOR\n        MENUITEM SEPARATOR\n        MENUITEM \"&XY 100%\",                    ID_VIEW_100\n        MENUITEM \"XY Zoom &In\\tDelete\",         ID_VIEW_ZOOMIN\n        MENUITEM \"XY Zoom &Out\\tInsert\",        ID_VIEW_ZOOMOUT\n        MENUITEM SEPARATOR\n        MENUITEM \"Show &Names\",                 ID_VIEW_SHOWNAMES, CHECKED\n        MENUITEM \"Show Blocks\",                 ID_VIEW_SHOWBLOCKS\n        MENUITEM \"Show C&oordinates\",           ID_VIEW_SHOWCOORDINATES\n        , CHECKED\n        MENUITEM \"Show &Entities\",              ID_VIEW_SHOWENT, CHECKED\n        MENUITEM \"Show &Path\",                  ID_VIEW_SHOWPATH, CHECKED\n        MENUITEM \"Show &Lights\",                ID_VIEW_SHOWLIGHTS, CHECKED\n        MENUITEM \"Show &Water\",                 ID_VIEW_SHOWWATER, CHECKED\n        MENUITEM \"Show Clip &Brush\",            ID_VIEW_SHOWCLIP, CHECKED\n        MENUITEM \"Show Wor&ld\",                 ID_VIEW_SHOWWORLD, CHECKED\n        MENUITEM \"Show Detail\\tctrl-D\",         ID_VIEW_SHOWDETAIL, CHECKED\n        MENUITEM SEPARATOR\n        MENUITEM \"&Z 100%\",                     ID_VIEW_Z100\n        MENUITEM \"Z Zoo&m In\\tctrl-Delete\",     ID_VIEW_ZZOOMIN\n        MENUITEM \"Z Zoom O&ut\\tctrl-Insert\",    ID_VIEW_ZZOOMOUT\n    END\n    POPUP \"&Selection\"\n    BEGIN\n        MENUITEM \"Drag &Edges\\tE\",              ID_SELECTION_DRAGEDGES\n        MENUITEM \"Drag &Vertecies\\tV\",          ID_SELECTION_DRAGVERTECIES\n        MENUITEM \"&Clone\\tspace\",               ID_SELECTION_CLONE\n        MENUITEM \"Deselect\\tEsc\",               ID_SELECTION_DESELECT\n        MENUITEM \"&Delete\\tBackspace\",          ID_SELECTION_DELETE\n        MENUITEM \"Flip &X\",                     ID_BRUSH_FLIPX\n        MENUITEM \"Flip &Y\",                     ID_BRUSH_FLIPY\n        MENUITEM \"Flip &Z\",                     ID_BRUSH_FLIPZ\n        MENUITEM \"Rotate X\",                    ID_BRUSH_ROTATEX\n        MENUITEM \"Rotate Y\",                    ID_BRUSH_ROTATEY\n        MENUITEM \"Rotate Z\",                    ID_BRUSH_ROTATEZ\n        MENUITEM \"Arbitrary rotation\",          ID_SELECTION_ARBITRARYROTATION\n\n        MENUITEM \"Make &Hollow\",                ID_SELECTION_MAKEHOLLOW\n        MENUITEM \"CSG &Subtract\",               ID_SELECTION_CSGSUBTRACT\n        MENUITEM \"Select Complete &Tall\",       ID_SELECTION_SELECTCOMPLETETALL\n\n        MENUITEM \"Select T&ouching\",            ID_SELECTION_SELECTTOUCHING\n        MENUITEM \"Select &Partial Tall\",        ID_SELECTION_SELECTPARTIALTALL\n\n        MENUITEM \"Select &Inside\",              ID_SELECTION_SELECTINSIDE\n        MENUITEM \"Connect entities\\tCtrl-k\",    ID_SELECTION_CONNECT\n        MENUITEM \"Ungroup entity\",              ID_SELECTION_UNGROUPENTITY\n        MENUITEM \"Make detail\\tCtrl-m\",         ID_SELECTION_MAKE_DETAIL\n        MENUITEM \"Make structural\",             ID_SELECTION_MAKE_STRUCTURAL\n    END\n    POPUP \"&Bsp\"\n    BEGIN\n        MENUITEM SEPARATOR\n    END\n    POPUP \"&Grid\"\n    BEGIN\n        MENUITEM \"Grid1\\t&1\",                   ID_GRID_1\n        MENUITEM \"Grid2\\t&2\",                   ID_GRID_2\n        MENUITEM \"Grid4\\t&3\",                   ID_GRID_4\n        MENUITEM \"Grid8\\t&4\",                   ID_GRID_8, CHECKED\n        MENUITEM \"Grid16\\t&5\",                  ID_GRID_16\n        MENUITEM \"Grid32\\t&6\",                  ID_GRID_32\n        MENUITEM \"Grid64\\t&7\",                  ID_GRID_64\n    END\n    POPUP \"&Textures\"\n    BEGIN\n        MENUITEM \"Show In &Use\\tU\",             ID_TEXTURES_SHOWINUSE\n        MENUITEM \"&Surface inspector\\tS\",       ID_TEXTURES_INSPECTOR\n        MENUITEM SEPARATOR\n        MENUITEM \"&Wireframe\",                  ID_TEXTURES_WIREFRAME\n        MENUITEM \"&Flat shade\",                 ID_TEXTURES_FLATSHADE\n        MENUITEM \"&Nearest\",                    ID_VIEW_NEAREST\n        MENUITEM \"Nearest &Mipmap\",             ID_VIEW_NEARESTMIPMAP\n        MENUITEM \"&Linear\",                     ID_VIEW_LINEAR\n        MENUITEM \"&Bilinear\",                   ID_VIEW_BILINEAR\n        MENUITEM \"B&ilinear Mipmap\",            ID_VIEW_BILINEARMIPMAP\n        MENUITEM \"T&rilinear\",                  ID_VIEW_TRILINEAR\n        MENUITEM SEPARATOR\n    END\n    POPUP \"&Misc\"\n    BEGIN\n        MENUITEM \"&Benchmark\",                  ID_MISC_BENCHMARK\n        POPUP \"&Colors\"\n        BEGIN\n            MENUITEM \"&Texture Background\",         ID_TEXTUREBK\n            MENUITEM \"Grid Background\",             ID_COLORS_XYBK\n            MENUITEM \"Grid Major\",                  ID_COLORS_MAJOR\n            MENUITEM \"Grid Minor\",                  ID_COLORS_MINOR\n        END\n        MENUITEM \"&Gamma\",                      ID_MISC_GAMMA\n        MENUITEM \"Find brush\",                  ID_MISC_FINDBRUSH\n        MENUITEM \"Next leak spot\\tctrl-l\",      ID_MISC_NEXTLEAKSPOT\n        MENUITEM \"Previous leak spot\\tctrl-p\",  ID_MISC_PREVIOUSLEAKSPOT\n        MENUITEM \"&Print XY View\",              ID_MISC_PRINTXY\n        MENUITEM \"&Select Entity Color\\tK\",     ID_MISC_SELECTENTITYCOLOR\n    END\n    POPUP \"&Region\"\n    BEGIN\n        MENUITEM \"&Off\",                        ID_REGION_OFF\n        MENUITEM \"&Set XY\",                     ID_REGION_SETXY\n        MENUITEM \"Set &Tall Brush\",             ID_REGION_SETTALLBRUSH\n        MENUITEM \"Set &Brush\",                  ID_REGION_SETBRUSH\n        MENUITEM \"Set Se&lected Brushes\",       ID_REGION_SETSELECTION\n    END\n    POPUP \"&Brush\"\n    BEGIN\n        MENUITEM \"3 sided\\tctrl-3\",             ID_BRUSH_3SIDED\n        MENUITEM \"4 sided\\tctrl-4\",             ID_BRUSH_4SIDED\n        MENUITEM \"5 sided\\tctrl-5\",             ID_BRUSH_5SIDED\n        MENUITEM \"6 sided\\tctrl-6\",             ID_BRUSH_6SIDED\n        MENUITEM \"7 sided\\tctrl-7\",             ID_BRUSH_7SIDED\n        MENUITEM \"8 sided\\tctrl-8\",             ID_BRUSH_8SIDED\n        MENUITEM \"9 sided\\tctrl-9\",             ID_BRUSH_9SIDED\n        MENUITEM \"Arbitrary sided\",             ID_BRUSH_ARBITRARYSIDED\n    END\n    POPUP \"&Help\"\n    BEGIN\n        MENUITEM \"&About\",                      ID_HELP_ABOUT\n    END\nEND\n\n\n#ifdef APSTUDIO_INVOKED\n/////////////////////////////////////////////////////////////////////////////\n//\n// TEXTINCLUDE\n//\n\n1 TEXTINCLUDE DISCARDABLE \nBEGIN\n    \"resource.h\\0\"\nEND\n\n2 TEXTINCLUDE DISCARDABLE \nBEGIN\n    \"#include \"\"afxres.h\"\"\\r\\n\"\n    \"\\0\"\nEND\n\n3 TEXTINCLUDE DISCARDABLE \nBEGIN\n    \"\\r\\n\"\n    \"\\0\"\nEND\n\n#endif    // APSTUDIO_INVOKED\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Dialog\n//\n\nIDD_FINDTEXTURE DIALOG DISCARDABLE  0, 0, 129, 53\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Find Texture\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"OK\",IDOK,10,30,50,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,70,30,50,14\n    EDITTEXT        IDC_EDIT1,10,10,110,14,ES_AUTOHSCROLL\nEND\n\nIDD_ENTITY DIALOGEX 0, 0, 234, 389\nSTYLE DS_3DLOOK | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CLIPSIBLINGS | \n    WS_CAPTION | WS_THICKFRAME\nEXSTYLE WS_EX_TOOLWINDOW | WS_EX_CLIENTEDGE\nCAPTION \"Entity\"\nFONT 8, \"MS Sans Serif\", 0, 0, 0x1\nBEGIN\n    LISTBOX         IDC_E_LIST,5,5,180,99,LBS_SORT | LBS_NOINTEGRALHEIGHT | \n                    LBS_WANTKEYBOARDINPUT | WS_VSCROLL | WS_TABSTOP,\n                    WS_EX_CLIENTEDGE\n    EDITTEXT        IDC_E_COMMENT,5,106,180,50,ES_MULTILINE | ES_READONLY | \n                    WS_VSCROLL,WS_EX_CLIENTEDGE\n    PUSHBUTTON      \"135\",IDC_E_135,5,290,15,15\n    PUSHBUTTON      \"180\",IDC_E_180,5,305,15,15\n    PUSHBUTTON      \"225\",IDC_E_225,5,320,15,15\n    PUSHBUTTON      \"270\",IDC_E_270,21,320,15,15\n    PUSHBUTTON      \"90\",IDC_E_90,21,290,15,15\n    PUSHBUTTON      \"45\",IDC_E_45,35,290,15,15\n    PUSHBUTTON      \"0\",IDC_E_0,35,305,15,15\n    PUSHBUTTON      \"315\",IDC_E_315,35,320,15,15\n    PUSHBUTTON      \"Up\",IDC_E_UP,60,295,15,15\n    PUSHBUTTON      \"Dn\",IDC_E_DOWN,60,310,15,15\n    CONTROL         \"\",IDC_CHECK1,\"Button\",BS_AUTOCHECKBOX | WS_DISABLED | \n                    WS_TABSTOP,5,160,50,8\n    CONTROL         \"\",IDC_CHECK2,\"Button\",BS_AUTOCHECKBOX | WS_DISABLED | \n                    WS_TABSTOP,5,170,50,8\n    CONTROL         \"\",IDC_CHECK3,\"Button\",BS_AUTOCHECKBOX | WS_DISABLED | \n                    WS_TABSTOP,5,180,50,8\n    CONTROL         \"\",IDC_CHECK4,\"Button\",BS_AUTOCHECKBOX | WS_DISABLED | \n                    WS_TABSTOP,5,190,50,8\n    CONTROL         \"\",IDC_CHECK5,\"Button\",BS_AUTOCHECKBOX | WS_DISABLED | \n                    WS_TABSTOP,65,160,50,8\n    CONTROL         \"\",IDC_CHECK6,\"Button\",BS_AUTOCHECKBOX | WS_DISABLED | \n                    WS_TABSTOP,65,170,50,8\n    CONTROL         \"\",IDC_CHECK7,\"Button\",BS_AUTOCHECKBOX | WS_DISABLED | \n                    WS_TABSTOP,65,180,50,8\n    CONTROL         \"\",IDC_CHECK8,\"Button\",BS_AUTOCHECKBOX | WS_DISABLED | \n                    WS_TABSTOP,65,190,50,8\n    CONTROL         \"!Easy\",IDC_CHECK9,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    125,160,50,8\n    CONTROL         \"!Medium\",IDC_CHECK10,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,125,170,50,8\n    CONTROL         \"!Hard\",IDC_CHECK11,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,125,180,50,10\n    CONTROL         \"!DeathMatch\",IDC_CHECK12,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,125,190,55,10\n    LISTBOX         IDC_E_PROPS,5,205,180,50,LBS_SORT | LBS_USETABSTOPS | \n                    LBS_NOINTEGRALHEIGHT | LBS_WANTKEYBOARDINPUT | \n                    WS_VSCROLL | WS_TABSTOP,WS_EX_CLIENTEDGE\n    PUSHBUTTON      \"Del Key/Pair\",IDC_E_DELPROP,105,295,45,15\n    EDITTEXT        IDC_E_STATUS,83,312,95,30,ES_MULTILINE | ES_AUTOVSCROLL | \n                    ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | WS_HSCROLL\n    LTEXT           \"Key\",IDC_STATIC_KEY,5,260,25,10\n    LTEXT           \"Value\",IDC_STATIC_VALUE,5,275,25,10\n    EDITTEXT        IDC_E_KEY_FIELD,40,260,135,14,ES_AUTOHSCROLL\n    EDITTEXT        IDC_E_VALUE_FIELD,40,275,135,14,ES_AUTOHSCROLL\nEND\n\nIDD_GAMMA DIALOGEX 0, 0, 127, 76\nSTYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU\nCAPTION \"Gamma\"\nFONT 8, \"MS Sans Serif\", 0, 0, 0x1\nBEGIN\n    DEFPUSHBUTTON   \"OK\",IDOK,10,40,50,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,65,40,50,14\n    EDITTEXT        IDC_G_EDIT,30,15,66,13,ES_AUTOHSCROLL,WS_EX_CLIENTEDGE\nEND\n\nIDD_FINDBRUSH DIALOGEX 0, 0, 127, 76\nSTYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU\nCAPTION \"Find brush\"\nFONT 8, \"MS Sans Serif\", 0, 0, 0x1\nBEGIN\n    DEFPUSHBUTTON   \"OK\",IDOK,5,55,50,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,65,55,50,14\n    EDITTEXT        IDC_FIND_ENTITY,80,15,46,13,ES_AUTOHSCROLL,\n                    WS_EX_CLIENTEDGE\n    EDITTEXT        IDC_FIND_BRUSH,80,30,46,13,ES_AUTOHSCROLL,\n                    WS_EX_CLIENTEDGE\n    LTEXT           \"Entity number\",IDC_STATIC,10,15,60,8\n    LTEXT           \"Brush number\",IDC_STATIC,10,30,65,8\nEND\n\nIDD_ROTATE DIALOG DISCARDABLE  0, 0, 186, 71\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Arbitrary rotation\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"OK\",IDOK,129,7,50,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,129,24,50,14\n    EDITTEXT        IDC_ROTX,30,5,40,14,ES_AUTOHSCROLL\n    LTEXT           \"x\",IDC_STATIC,5,10,8,8\n    EDITTEXT        IDC_ROTZ,30,45,40,14,ES_AUTOHSCROLL\n    LTEXT           \"y\",IDC_STATIC,5,25,8,8\n    EDITTEXT        IDC_ROTY,30,25,40,14,ES_AUTOHSCROLL\n    LTEXT           \"z\",IDC_STATIC,5,45,8,8\nEND\n\nIDD_SIDES DIALOG DISCARDABLE  0, 0, 186, 55\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Arbitrrary sides\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"OK\",IDOK,129,7,50,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,129,24,50,14\n    EDITTEXT        IDC_SIDES,50,15,40,14,ES_AUTOHSCROLL\n    LTEXT           \"Sides\",IDC_STATIC,15,15,18,8\nEND\n\nIDD_ABOUT DIALOG DISCARDABLE  0, 0, 274, 212\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"About QuakeEd\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"OK\",IDOK,217,7,50,14\n    CONTROL         127,IDC_STATIC,\"Static\",SS_BITMAP,7,7,83,58\n    CONTROL         \"Q3Radiant\\nCopyright (C) 1997, 2005 id Software, Inc.\",\n                    IDC_STATIC,\"Static\",SS_LEFTNOWORDWRAP | WS_GROUP,100,10,\n                    110,23\n    GROUPBOX        \"OpenGL Properties\",IDC_STATIC,5,75,265,50\n    LTEXT           \"Vendor:\\t\\tWHOEVER\",IDC_ABOUT_GLVENDOR,10,90,125,10\n    LTEXT           \"Version:\\t\\t1.1\",IDC_ABOUT_GLVERSION,10,100,125,10\n    LTEXT           \"Renderer:\\tWHATEVER\",IDC_ABOUT_GLRENDERER,10,110,125,10\n    LTEXT           \"WHATEVER\",IDC_ABOUT_GLEXTENSIONS,10,140,255,60\n    GROUPBOX        \"OpenGL Extensions\",IDC_STATIC,5,130,265,80\nEND\n\nIDD_SURFACE DIALOG DISCARDABLE  400, 100, 392, 181\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU\nCAPTION \"Surface inspector\"\nFONT 8, \"MS Sans Serif\"\nBEGIN\n    DEFPUSHBUTTON   \"OK\",IDOK,5,155,40,14\n    PUSHBUTTON      \"Cancel\",IDCANCEL,105,155,40,14\n    EDITTEXT        IDC_HSHIFT,85,45,35,15,ES_AUTOHSCROLL\n    SCROLLBAR       IDC_HSHIFTA,120,45,10,15,SBS_VERT\n    LTEXT           \"Horizontal shift\",IDC_STATIC,10,45,65,8\n    LTEXT           \"Vertical shift\",IDC_STATIC,10,60,65,8\n    LTEXT           \"Horizontal stretch\",IDC_STATIC,10,75,65,8\n    LTEXT           \"Vertical stretch\",IDC_STATIC,10,90,65,8\n    LTEXT           \"Rotate\",IDC_STATIC,10,105,65,8\n    LTEXT           \"value\",IDC_STATIC,10,120,65,8\n    EDITTEXT        IDC_VSHIFT,85,60,35,15,ES_AUTOHSCROLL\n    SCROLLBAR       IDC_VSHIFTA,120,60,10,15,SBS_VERT\n    EDITTEXT        IDC_HSCALE,85,75,35,15,ES_AUTOHSCROLL\n    SCROLLBAR       IDC_HSCALEA,120,75,10,15,SBS_VERT\n    EDITTEXT        IDC_VSCALE,85,90,35,15,ES_AUTOHSCROLL\n    SCROLLBAR       IDC_VSCALEA,120,90,10,15,SBS_VERT\n    EDITTEXT        IDC_ROTATE,85,105,35,15,ES_AUTOHSCROLL\n    SCROLLBAR       IDC_ROTATEA,120,105,10,15,SBS_VERT\n    EDITTEXT        IDC_VALUE,85,120,35,15,ES_AUTOHSCROLL\n    EDITTEXT        IDC_TEXTURE,50,15,80,14,ES_AUTOHSCROLL\n    CONTROL         \"light\",IDC_CHECK1,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    160,10,41,8\n    CONTROL         \"slick\",IDC_CHECK2,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    160,20,41,8\n    CONTROL         \"sky\",IDC_CHECK3,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    160,30,41,8\n    CONTROL         \"warp\",IDC_CHECK4,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    160,40,41,8\n    CONTROL         \"trans33\",IDC_CHECK5,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,160,50,41,8\n    CONTROL         \"trans66\",IDC_CHECK6,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,160,60,41,8\n    CONTROL         \"flowing\",IDC_CHECK7,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,160,70,41,8\n    CONTROL         \"nodraw\",IDC_CHECK8,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,160,80,41,8\n    CONTROL         \"100\",IDC_CHECK9,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    160,90,41,8\n    CONTROL         \"200\",IDC_CHECK10,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    160,100,41,8\n    CONTROL         \"400\",IDC_CHECK11,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    160,110,41,8\n    CONTROL         \"800\",IDC_CHECK12,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    160,120,41,8\n    CONTROL         \"1000\",IDC_CHECK13,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    160,130,41,8\n    CONTROL         \"2000\",IDC_CHECK14,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    160,140,41,8\n    CONTROL         \"4000\",IDC_CHECK15,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    160,150,41,8\n    CONTROL         \"8000\",IDC_CHECK16,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    160,160,41,8\n    LTEXT           \"Texture\",IDC_STATIC,10,18,30,8\n    PUSHBUTTON      \"Apply\",IDAPPLY,55,155,40,14\n    CONTROL         \"10000\",IDC_CHECK17,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,210,10,41,8\n    CONTROL         \"20000\",IDC_CHECK18,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,210,20,41,8\n    CONTROL         \"40000\",IDC_CHECK19,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,210,30,41,8\n    CONTROL         \"80000\",IDC_CHECK20,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,210,40,41,8\n    CONTROL         \"100000\",IDC_CHECK21,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,210,50,41,8\n    CONTROL         \"200000\",IDC_CHECK22,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,210,60,41,8\n    CONTROL         \"400000\",IDC_CHECK23,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,210,70,41,8\n    CONTROL         \"800000\",IDC_CHECK24,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,210,80,41,8\n    CONTROL         \"1000000\",IDC_CHECK25,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,210,90,41,8\n    CONTROL         \"2000000\",IDC_CHECK26,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,210,100,41,8\n    CONTROL         \"4000000\",IDC_CHECK27,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,210,110,41,8\n    CONTROL         \"8000000\",IDC_CHECK28,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,210,120,41,8\n    CONTROL         \"10000000\",IDC_CHECK29,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,210,130,40,8\n    CONTROL         \"20000000\",IDC_CHECK30,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,210,140,45,8\n    CONTROL         \"40000000\",IDC_CHECK31,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,210,150,45,8\n    CONTROL         \"80000000\",IDC_CHECK32,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,210,160,45,8\n    CONTROL         \"solid\",IDC_CHECK33,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,280,10,41,8\n    CONTROL         \"window\",IDC_CHECK34,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,280,20,41,8\n    CONTROL         \"aux\",IDC_CHECK35,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    280,31,41,8\n    CONTROL         \"lava\",IDC_CHECK36,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    280,41,41,8\n    CONTROL         \"slime\",IDC_CHECK37,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,280,50,41,8\n    CONTROL         \"water\",IDC_CHECK38,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,280,60,41,8\n    CONTROL         \"mist\",IDC_CHECK39,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    280,71,41,8\n    CONTROL         \"80\",IDC_CHECK40,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    280,81,41,8\n    CONTROL         \"100\",IDC_CHECK41,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    280,90,41,8\n    CONTROL         \"200\",IDC_CHECK42,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    280,100,41,8\n    CONTROL         \"400\",IDC_CHECK43,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    280,111,41,8\n    CONTROL         \"800\",IDC_CHECK44,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    280,121,41,8\n    CONTROL         \"1000\",IDC_CHECK45,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    280,130,41,8\n    CONTROL         \"2000\",IDC_CHECK46,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    280,140,41,8\n    CONTROL         \"4000\",IDC_CHECK47,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    280,151,41,8\n    CONTROL         \"8000\",IDC_CHECK48,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,\n                    280,161,41,8\n    CONTROL         \"playerclip\",IDC_CHECK49,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,330,10,41,8\n    CONTROL         \"monsterclip\",IDC_CHECK50,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,330,20,50,8\n    CONTROL         \"current_0\",IDC_CHECK51,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,330,31,50,8\n    CONTROL         \"current_90\",IDC_CHECK52,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,330,41,50,8\n    CONTROL         \"current_180\",IDC_CHECK53,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,330,50,50,8\n    CONTROL         \"current_270\",IDC_CHECK54,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,330,60,50,8\n    CONTROL         \"current_up\",IDC_CHECK55,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,330,71,50,8\n    CONTROL         \"current_dn\",IDC_CHECK56,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,330,81,50,8\n    CONTROL         \"origin\",IDC_CHECK57,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,330,90,41,8\n    CONTROL         \"monster\",IDC_CHECK58,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,330,100,41,8\n    CONTROL         \"corpse\",IDC_CHECK59,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,330,111,41,8\n    CONTROL         \"detail\",IDC_CHECK60,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,330,121,41,8\n    CONTROL         \"translucent\",IDC_CHECK61,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,330,130,50,8\n    CONTROL         \"ladder\",IDC_CHECK62,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,330,140,45,8\n    CONTROL         \"40000000\",IDC_CHECK63,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,330,151,45,8\n    CONTROL         \"80000000\",IDC_CHECK64,\"Button\",BS_AUTOCHECKBOX | \n                    WS_TABSTOP,330,161,45,8\n    GROUPBOX        \"Surf flags\",IDC_STATIC,150,0,115,175\n    GROUPBOX        \"Content flags\",IDC_STATIC,270,0,115,175\nEND\n\n\n#ifndef _MAC\n/////////////////////////////////////////////////////////////////////////////\n//\n// Version\n//\n\nVS_VERSION_INFO VERSIONINFO\n FILEVERSION 1,0,0,1\n PRODUCTVERSION 1,0,0,1\n FILEFLAGSMASK 0x3fL\n#ifdef _DEBUG\n FILEFLAGS 0x1L\n#else\n FILEFLAGS 0x0L\n#endif\n FILEOS 0x40004L\n FILETYPE 0x1L\n FILESUBTYPE 0x0L\nBEGIN\n    BLOCK \"StringFileInfo\"\n    BEGIN\n        BLOCK \"040904b0\"\n        BEGIN\n            VALUE \"CompanyName\", \"Id Software\\0\"\n            VALUE \"FileDescription\", \"qe3\\0\"\n            VALUE \"FileVersion\", \"1, 0, 0, 1\\0\"\n            VALUE \"InternalName\", \"qe3\\0\"\n            VALUE \"LegalCopyright\", \"Copyright  1996\\0\"\n            VALUE \"OriginalFilename\", \"qe3.exe\\0\"\n            VALUE \"ProductName\", \"Id Software qe3\\0\"\n            VALUE \"ProductVersion\", \"1, 0, 0, 1\\0\"\n        END\n    END\n    BLOCK \"VarFileInfo\"\n    BEGIN\n        VALUE \"Translation\", 0x409, 1200\n    END\nEND\n\n#endif    // !_MAC\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Accelerator\n//\n\nIDR_ACCELERATOR1 ACCELERATORS DISCARDABLE \nBEGIN\n    \"3\",            ID_BRUSH_3SIDED,        VIRTKEY, CONTROL, NOINVERT\n    \"4\",            ID_BRUSH_4SIDED,        VIRTKEY, CONTROL, NOINVERT\n    \"5\",            ID_BRUSH_5SIDED,        VIRTKEY, CONTROL, NOINVERT\n    \"6\",            ID_BRUSH_6SIDED,        VIRTKEY, CONTROL, NOINVERT\n    \"7\",            ID_BRUSH_7SIDED,        VIRTKEY, CONTROL, NOINVERT\n    \"8\",            ID_BRUSH_8SIDED,        VIRTKEY, CONTROL, NOINVERT\n    \"9\",            ID_BRUSH_9SIDED,        VIRTKEY, CONTROL, NOINVERT\n    \"D\",            ID_VIEW_SHOWDETAIL,     VIRTKEY, CONTROL, NOINVERT\n    \"K\",            ID_SELECTION_CONNECT,   VIRTKEY, CONTROL, NOINVERT\n    \"L\",            ID_MISC_NEXTLEAKSPOT,   VIRTKEY, CONTROL, NOINVERT\n    \"M\",            ID_SELECTION_MAKE_DETAIL, VIRTKEY, CONTROL, NOINVERT\n    \"O\",            ID_FILE_OPEN,           VIRTKEY, CONTROL, NOINVERT\n    \"P\",            ID_MISC_PREVIOUSLEAKSPOT, VIRTKEY, CONTROL, NOINVERT\n    \"S\",            ID_FILE_SAVE,           VIRTKEY, CONTROL, NOINVERT\n    VK_DELETE,      ID_VIEW_ZZOOMIN,        VIRTKEY, CONTROL, NOINVERT\n    VK_INSERT,      ID_VIEW_ZZOOMOUT,       VIRTKEY, CONTROL, NOINVERT\n    \"X\",            ID_FILE_EXIT,           VIRTKEY, CONTROL, NOINVERT\nEND\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Toolbar\n//\n\nIDR_TOOLBAR1 TOOLBAR DISCARDABLE  16, 15\nBEGIN\n    BUTTON      ID_BRUSH_FLIPX\n    BUTTON      ID_BRUSH_ROTATEX\n    BUTTON      ID_BRUSH_FLIPY\n    BUTTON      ID_BRUSH_ROTATEY\n    BUTTON      ID_BRUSH_FLIPZ\n    BUTTON      ID_BRUSH_ROTATEZ\n    BUTTON      ID_SELECTION_SELECTCOMPLETETALL\n    BUTTON      ID_SELECTION_SELECTTOUCHING\n    BUTTON      ID_SELECTION_SELECTPARTIALTALL\n    BUTTON      ID_SELECTION_SELECTINSIDE\n    BUTTON      ID_SELECTION_CSGSUBTRACT\n    BUTTON      ID_SELECTION_MAKEHOLLOW\n    BUTTON      ID_TEXTURES_WIREFRAME\n    BUTTON      ID_TEXTURES_FLATSHADE\n    BUTTON      ID_VIEW_TRILINEAR\nEND\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Bitmap\n//\n\nIDR_TOOLBAR1            BITMAP  DISCARDABLE     \"toolbar1.bmp\"\nIDB_BITMAP1             BITMAP  DISCARDABLE     \"q.bmp\"\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// DESIGNINFO\n//\n\n#ifdef APSTUDIO_INVOKED\nGUIDELINES DESIGNINFO DISCARDABLE \nBEGIN\n    IDD_ENTITY, DIALOG\n    BEGIN\n        RIGHTMARGIN, 227\n        BOTTOMMARGIN, 387\n    END\n\n    IDD_GAMMA, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 120\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 68\n    END\n\n    IDD_FINDBRUSH, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 120\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 68\n    END\n\n    IDD_ROTATE, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 179\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 64\n    END\n\n    IDD_SIDES, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 179\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 48\n    END\n\n    IDD_ABOUT, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 267\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 205\n    END\n\n    IDD_SURFACE, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 385\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 174\n    END\nEND\n#endif    // APSTUDIO_INVOKED\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Icon\n//\n\n// Icon with lowest ID value placed first to ensure application icon\n// remains consistent on all systems.\nIDI_ICON1               ICON    DISCARDABLE     \"icon1.ico\"\n#endif    // English (U.S.) resources\n/////////////////////////////////////////////////////////////////////////////\n\n\n\n#ifndef APSTUDIO_INVOKED\n/////////////////////////////////////////////////////////////////////////////\n//\n// Generated from the TEXTINCLUDE 3 resource.\n//\n\n\n/////////////////////////////////////////////////////////////////////////////\n#endif    // not APSTUDIO_INVOKED\n\n"
  },
  {
    "path": "q3radiant/WIN_XY.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// win_xy.c -- windows specific xy view code\n\n#include \"stdafx.h\"\n#include \"qe3.h\"\n\nstatic HDC   s_hdcXY;\nstatic HGLRC s_hglrcXY;\n\nstatic unsigned s_stipple[32] =\n{\n\t0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,\n\t0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,\n\t0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,\n\t0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,\n\t0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,\n\t0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,\n\t0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,\n\t0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,\n};\n\n/*\n============\nWXY_WndProc\n============\n*/\nLONG WINAPI XYWndProc (\n    HWND    hWnd,\n    UINT    uMsg,\n    WPARAM  wParam,\n    LPARAM  lParam)\n{\n\tint\t\tfwKeys, xPos, yPos;\n    RECT\trect;\n\n\n    GetClientRect(hWnd, &rect);\n\n    switch (uMsg)\n    {\n\tcase WM_CREATE:\n\n    s_hdcXY = GetDC(hWnd);\n\t\tQEW_SetupPixelFormat(s_hdcXY, false);\n\n\t\tif ( ( s_hglrcXY = wglCreateContext( s_hdcXY ) ) == 0 )\n\t\t\tError( \"wglCreateContext in WXY_WndProc failed\" );\n\n        if (!wglMakeCurrent( s_hdcXY, s_hglrcXY ))\n\t\t\tError (\"wglMakeCurrent failed\");\n\n\t\tif (!wglShareLists( g_qeglobals.d_hglrcBase, s_hglrcXY ) )\n\t\t\tError( \"wglShareLists in WXY_WndProc failed\" );\n\n\t\tglPolygonStipple ((unsigned char *)s_stipple);\n\t\tglLineStipple (3, 0xaaaa);\n\n\t\treturn 0;\n\n\tcase WM_DESTROY:\n\t\tQEW_StopGL( hWnd, s_hglrcXY, s_hdcXY );\n\t\treturn 0;\n\n\tcase WM_PAINT:\n        { \n\t\t    PAINTSTRUCT\tps;\n\n\t\t    BeginPaint(hWnd, &ps);\n\n            if (!wglMakeCurrent( s_hdcXY, s_hglrcXY ))\n\t\t\t\tError (\"wglMakeCurrent failed\");\n\n\t\t\tQE_CheckOpenGLForErrors();\n\t\t\tXY_Draw ();\n\t\t\tQE_CheckOpenGLForErrors();\n\n\t\t\tSwapBuffers(s_hdcXY);\n\n\t\t\tEndPaint(hWnd, &ps);\n        }\n\t\treturn 0;\n\n\tcase WM_KEYDOWN:\n\t\treturn QE_KeyDown (wParam);\n\t\t\n\tcase WM_MBUTTONDOWN:\n\tcase WM_RBUTTONDOWN:\n\tcase WM_LBUTTONDOWN:\n\t\tif ( GetTopWindow( g_qeglobals.d_hwndMain ) != hWnd)\n\t\t\tBringWindowToTop(hWnd);\n\t\tSetFocus( g_qeglobals.d_hwndXY );\n\t\tSetCapture( g_qeglobals.d_hwndXY );\n\t\tfwKeys = wParam;        // key flags \n\t\txPos = (short)LOWORD(lParam);  // horizontal position of cursor \n\t\tyPos = (short)HIWORD(lParam);  // vertical position of cursor \n\t\tyPos = (int)rect.bottom - 1 - yPos;\n\t\tXY_MouseDown (xPos, yPos, fwKeys);\n\t\treturn 0;\n\n\tcase WM_MBUTTONUP:\n\tcase WM_RBUTTONUP:\n\tcase WM_LBUTTONUP:\n\t\tfwKeys = wParam;        // key flags \n\t\txPos = (short)LOWORD(lParam);  // horizontal position of cursor \n\t\tyPos = (short)HIWORD(lParam);  // vertical position of cursor \n\t\tyPos = (int)rect.bottom - 1 - yPos;\n\t\tXY_MouseUp (xPos, yPos, fwKeys);\n\t\tif (! (fwKeys & (MK_LBUTTON|MK_RBUTTON|MK_MBUTTON)))\n\t\t\tReleaseCapture ();\n\t\treturn 0;\n\n\tcase WM_MOUSEMOVE:\n    if (::GetFocus() != hWnd)\n      ::SetFocus(hWnd);\n\t\tfwKeys = wParam;        // key flags \n\t\txPos = (short)LOWORD(lParam);  // horizontal position of cursor \n\t\tyPos = (short)HIWORD(lParam);  // vertical position of cursor \n\t\tyPos = (int)rect.bottom - 1 - yPos;\n\t\tXY_MouseMoved (xPos, yPos, fwKeys);\n\t\treturn 0;\n\n    case WM_SIZE:\n\t\tg_qeglobals.d_xy.width = rect.right;\n\t\tg_qeglobals.d_xy.height = rect.bottom - 16;\n\t\tInvalidateRect( g_qeglobals.d_hwndXY, NULL, false);\n\t\treturn 0;\n\n\tcase WM_NCCALCSIZE:// don't let windows copy pixels\n\t\tDefWindowProc (hWnd, uMsg, wParam, lParam);\n\t\treturn WVR_REDRAW;\n\n\tcase WM_KILLFOCUS:\n\tcase WM_SETFOCUS:\n\t\tSendMessage( hWnd, WM_NCACTIVATE, uMsg == WM_SETFOCUS, 0 );\n\t\treturn 0;\n\n   \tcase WM_CLOSE:\n        DestroyWindow (hWnd);\n\t\treturn 0;\n    }\n\n\treturn DefWindowProc (hWnd, uMsg, wParam, lParam);\n}\n\n\n/*\n==============\nWXY_Create\n==============\n*/\nvoid WXY_Create (HINSTANCE hInstance)\n{\n  ASSERT(0);\n#if 0\n    WNDCLASS   wc;\n\n    /* Register the camera class */\n\tmemset (&wc, 0, sizeof(wc));\n\n    wc.style         = CS_NOCLOSE;\n    wc.lpfnWndProc   = (WNDPROC)WXY_WndProc;\n    wc.cbClsExtra    = 0;\n    wc.cbWndExtra    = 0;\n    wc.hInstance     = hInstance;\n    wc.hIcon         = 0;\n    wc.hCursor       = LoadCursor (NULL,IDC_ARROW);\n    wc.hbrBackground = NULL; //(HBRUSH)(COLOR_WINDOW+1);\n    wc.lpszMenuName  = NULL;\n    wc.lpszClassName = XY_WINDOW_CLASS;\n\n    if (!RegisterClass (&wc) )\n        Error (\"RegisterClass: failed\");\n\n\tg_qeglobals.d_hwndXY = CreateWindow (XY_WINDOW_CLASS ,\n\t\t\"XY View\",\n\t\tQE3_STYLE ,\n\t\tZWIN_WIDTH,\n\t\t(int)(screen_height*CWIN_SIZE)-20,\n\t\tscreen_width-ZWIN_WIDTH,\n\t\t(int)(screen_height*(1.0-CWIN_SIZE)-38),\t// size\n\n\t\tg_qeglobals.d_hwndMain,\t// parent\n\t\t0,\t\t// no menu\n\t\thInstance,\n\t\tNULL);\n\n\tif (!g_qeglobals.d_hwndXY )\n\t\tError (\"Couldn't create XY View\");\n\n\tLoadWindowState(g_qeglobals.d_hwndXY, \"xywindow\");\n    ShowWindow(g_qeglobals.d_hwndXY, SW_SHOWDEFAULT);\n#endif\n}\n\nstatic void WXY_InitPixelFormat( PIXELFORMATDESCRIPTOR *pPFD )\n{\n\tmemset( pPFD, 0, sizeof( *pPFD ) );\n\n\tpPFD->nSize    = sizeof( PIXELFORMATDESCRIPTOR );\n\tpPFD->nVersion = 1;\n\tpPFD->dwFlags  = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;\n\tpPFD->iPixelType = PFD_TYPE_RGBA;\n\tpPFD->cColorBits = 24;\n\tpPFD->cDepthBits = 32;\n\tpPFD->iLayerType = PFD_MAIN_PLANE;\n\n}\n\nvoid WXY_Print( void )\n{\n\tDOCINFO di;\n\n\tPRINTDLG pd;\n\n\t/*\n\t** initialize the PRINTDLG struct and execute it\n\t*/\n\tmemset( &pd, 0, sizeof( pd ) );\n\tpd.lStructSize = sizeof( pd );\n\tpd.hwndOwner = g_qeglobals.d_hwndXY;\n\tpd.Flags = PD_RETURNDC;\n\tpd.hInstance = 0;\n\tif ( !PrintDlg( &pd ) || !pd.hDC )\n\t{\n\t\tMessageBox( g_qeglobals.d_hwndMain, \"Could not PrintDlg()\", \"QE4 Print Error\", MB_OK | MB_ICONERROR );\n\t\treturn;\n\t}\n\n\t/*\n\t** StartDoc\n\t*/\n\tmemset( &di, 0, sizeof( di ) );\n\tdi.cbSize = sizeof( di );\n\tdi.lpszDocName = \"QE4\";\n\tif ( StartDoc( pd.hDC, &di ) <= 0 )\n\t{\n\t\tMessageBox( g_qeglobals.d_hwndMain, \"Could not StartDoc()\", \"QE4 Print Error\", MB_OK | MB_ICONERROR );\n\t\treturn;\n\t}\n\n\t/*\n\t** StartPage\n\t*/\n\tif ( StartPage( pd.hDC ) <= 0 )\n\t{\n\t\tMessageBox( g_qeglobals.d_hwndMain, \"Could not StartPage()\", \"QE4 Print Error\", MB_OK | MB_ICONERROR );\n\t\treturn;\n\t}\n\n\t/*\n\t** read pixels from the XY window\n\t*/\n\t{\n\t\tint bmwidth = 320, bmheight = 320;\n\t\tint pwidth, pheight;\n\n\t\tRECT r;\n\n\t\tGetWindowRect( g_qeglobals.d_hwndXY, &r );\n\n\t\tbmwidth  = r.right - r.left;\n\t\tbmheight = r.bottom - r.top;\n\n\t\tpwidth  = GetDeviceCaps( pd.hDC, PHYSICALWIDTH ) - GetDeviceCaps( pd.hDC, PHYSICALOFFSETX );\n\t\tpheight = GetDeviceCaps( pd.hDC, PHYSICALHEIGHT ) - GetDeviceCaps( pd.hDC, PHYSICALOFFSETY );\n\n\t\tStretchBlt( pd.hDC,\n\t\t\t0, 0,\n\t\t\tpwidth, pheight,\n\t\t\ts_hdcXY,\n\t\t\t0, 0,\n\t\t\tbmwidth, bmheight,\n\t\t\tSRCCOPY );\n\t}\n\n\t/*\n\t** EndPage and EndDoc\n\t*/\n\tif ( EndPage( pd.hDC ) <= 0 )\n\t{\n\t\tMessageBox( g_qeglobals.d_hwndMain, \"QE4 Print Error\", \"Could not EndPage()\", MB_OK | MB_ICONERROR );\n\t\treturn;\n\t}\n\n\tif ( EndDoc( pd.hDC ) <= 0 )\n\t{\n\t\tMessageBox( g_qeglobals.d_hwndMain, \"QE4 Print Error\", \"Could not EndDoc()\", MB_OK | MB_ICONERROR );\n\t\treturn;\n\t}\n}\n"
  },
  {
    "path": "q3radiant/WIN_Z.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// win_cam.c -- windows specific camera view code\n\n#include \"stdafx.h\"\n#include \"qe3.h\"\n\nstatic HDC   s_hdcZ;\nstatic HGLRC s_hglrcZ;\n\n/*\n============\nWZ_WndProc\n============\n*/\nLONG WINAPI WZ_WndProc (\n    HWND    hWnd,\n    UINT    uMsg,\n    WPARAM  wParam,\n    LPARAM  lParam)\n{\n\tint\t\tfwKeys, xPos, yPos;\n    RECT\trect;\n\n    GetClientRect(hWnd, &rect);\n\n    switch (uMsg)\n    {\n\n\tcase WM_DESTROY:\n\t\tQEW_StopGL( hWnd, s_hglrcZ, s_hdcZ );\n\t\treturn 0;\n\n\tcase WM_CREATE:\n        s_hdcZ = GetDC(hWnd);\n\t    QEW_SetupPixelFormat( s_hdcZ, false);\n\t\tif ( ( s_hglrcZ = wglCreateContext( s_hdcZ ) ) == 0 )\n\t\t\tError( \"wglCreateContext in WZ_WndProc failed\" );\n\n        if (!wglMakeCurrent( s_hdcZ, s_hglrcZ ))\n\t\t\tError (\"wglMakeCurrent in WZ_WndProc failed\");\n\n\t\tif (!wglShareLists( g_qeglobals.d_hglrcBase, s_hglrcZ ) )\n\t\t\tError( \"wglShareLists in WZ_WndProc failed\" );\n\t\treturn 0;\n\n\tcase WM_PAINT:\n        { \n\t\t    PAINTSTRUCT\tps;\n\n\t\t    BeginPaint(hWnd, &ps);\n\n            if ( !wglMakeCurrent( s_hdcZ, s_hglrcZ ) )\n\t\t\t\tError (\"wglMakeCurrent failed\");\n\t\t\tQE_CheckOpenGLForErrors();\n\n\t\t\tZ_Draw ();\n\t\t    SwapBuffers(s_hdcZ);\n\n\t\t\tEndPaint(hWnd, &ps);\n        }\n\t\treturn 0;\n\n\n\tcase WM_KEYDOWN:\n\t\tQE_KeyDown (wParam);\n\t\treturn 0;\n\n\tcase WM_MBUTTONDOWN:\n\tcase WM_RBUTTONDOWN:\n\tcase WM_LBUTTONDOWN:\n\t\tif (GetTopWindow(g_qeglobals.d_hwndMain) != hWnd)\n\t\t\tBringWindowToTop(hWnd);\n\n\t\tSetFocus( g_qeglobals.d_hwndZ );\n\t\tSetCapture( g_qeglobals.d_hwndZ );\n\t\tfwKeys = wParam;        // key flags \n\t\txPos = (short)LOWORD(lParam);  // horizontal position of cursor \n\t\tyPos = (short)HIWORD(lParam);  // vertical position of cursor \n\t\tyPos = (int)rect.bottom - 1 - yPos;\n\t\tZ_MouseDown (xPos, yPos, fwKeys);\n\t\treturn 0;\n\n\tcase WM_MBUTTONUP:\n\tcase WM_RBUTTONUP:\n\tcase WM_LBUTTONUP:\n\t\tfwKeys = wParam;        // key flags \n\t\txPos = (short)LOWORD(lParam);  // horizontal position of cursor \n\t\tyPos = (short)HIWORD(lParam);  // vertical position of cursor \n\t\tyPos = (int)rect.bottom - 1 - yPos;\n\t\tZ_MouseUp (xPos, yPos, fwKeys);\n\t\tif (! (fwKeys & (MK_LBUTTON|MK_RBUTTON|MK_MBUTTON)))\n\t\t\tReleaseCapture ();\n\t\treturn 0;\n\n\tcase WM_GETMINMAXINFO:\n\t{\n\t\tMINMAXINFO *pmmi = (LPMINMAXINFO) lParam;\n\n\t\tpmmi->ptMinTrackSize.x = ZWIN_WIDTH;\n\t\treturn 0;\n\t}\n\n\tcase WM_MOUSEMOVE:\n\t\tfwKeys = wParam;        // key flags \n\t\txPos = (short)LOWORD(lParam);  // horizontal position of cursor \n\t\tyPos = (short)HIWORD(lParam);  // vertical position of cursor \n\t\tyPos = (int)rect.bottom - 1 - yPos;\n\t\tZ_MouseMoved (xPos, yPos, fwKeys);\n\t\treturn 0;\n\n    case WM_SIZE:\n\t\tz.width = rect.right;\n\t\tz.height = rect.bottom;\n\t\tInvalidateRect( g_qeglobals.d_hwndZ, NULL, false);\n\t\treturn 0;\n\n\tcase WM_NCCALCSIZE:// don't let windows copy pixels\n\t\tDefWindowProc (hWnd, uMsg, wParam, lParam);\n\t\treturn WVR_REDRAW;\n\n\tcase WM_KILLFOCUS:\n\tcase WM_SETFOCUS:\n\t\tSendMessage( hWnd, WM_NCACTIVATE, uMsg == WM_SETFOCUS, 0 );\n\t\treturn 0;\n\n   \tcase WM_CLOSE:\n        /* call destroy window to cleanup and go away */\n        DestroyWindow (hWnd);\n\t\treturn 0;\n    }\n\n\treturn DefWindowProc (hWnd, uMsg, wParam, lParam);\n}\n\n\n/*\n==============\nWZ_Create\n==============\n*/\nvoid WZ_Create (HINSTANCE hInstance)\n{\n  WNDCLASS   wc;\n\tmemset (&wc, 0, sizeof(wc));\n  wc.style         = CS_NOCLOSE;\n  wc.lpfnWndProc   = (WNDPROC)WZ_WndProc;\n  wc.cbClsExtra    = 0;\n  wc.cbWndExtra    = 0;\n  wc.hInstance     = hInstance;\n  wc.hIcon         = 0;\n  wc.hCursor       = LoadCursor (NULL,IDC_ARROW);\n  wc.hbrBackground = NULL;\n  wc.lpszMenuName  = NULL;\n  wc.lpszClassName = Z_WINDOW_CLASS;\n\n    if (!RegisterClass (&wc) )\n        Error (\"WCam_Register: failed\");\n\n\tg_qeglobals.d_hwndZ = CreateWindow (Z_WINDOW_CLASS ,\n\t\t\"Z\",\n\t\tQE3_STYLE,\n\t\t0,20,ZWIN_WIDTH,screen_height-38,\t// size\n\t\tg_qeglobals.d_hwndMain,\t// parent\n\t\t0,\t\t// no menu\n\t\thInstance,\n\t\tNULL);\n\tif (!g_qeglobals.d_hwndZ)\n\t\tError (\"Couldn't create zwindow\");\n\n\tLoadWindowState(g_qeglobals.d_hwndZ, \"zwindow\");\n    ShowWindow (g_qeglobals.d_hwndZ, SW_SHOWDEFAULT);\n}\n"
  },
  {
    "path": "q3radiant/WaveOpen.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// WaveOpen.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"WaveOpen.h\"\n#include \"mmsystem.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CWaveOpen\n\nIMPLEMENT_DYNAMIC(CWaveOpen, CFileDialog)\n\nCWaveOpen::CWaveOpen(BOOL bOpenFileDialog, LPCTSTR lpszDefExt, LPCTSTR lpszFileName,\n\t\tDWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd) :\n\t\tCFileDialog(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd)\n{\n  m_ofn.Flags |= (OFN_EXPLORER | OFN_ENABLETEMPLATE);\n  m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_PLAYWAVE);\n}\n\n\nBEGIN_MESSAGE_MAP(CWaveOpen, CFileDialog)\n\t//{{AFX_MSG_MAP(CWaveOpen)\n\tON_BN_CLICKED(IDC_BTN_PLAY, OnBtnPlay)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n\nvoid CWaveOpen::OnFileNameChange()\n{\n  CString str = GetPathName();\n  str.MakeLower();\n  CWnd *pWnd = GetDlgItem(IDC_BTN_PLAY);\n  if (pWnd == NULL)\n  {\n    return;\n  }\n  if (str.Find(\".wav\") >= 0)\n  {\n    pWnd->EnableWindow(TRUE);\n  }\n  else\n  {\n    pWnd->EnableWindow(FALSE);\n  }\n}\n\nvoid CWaveOpen::OnBtnPlay() \n{\n  sndPlaySound(NULL, NULL);\n  CString str = GetPathName();\n  if (str.GetLength() > 0)\n  {\n    sndPlaySound(str, SND_FILENAME | SND_ASYNC);\n  }\n}\n\nBOOL CWaveOpen::OnInitDialog() \n{\n\tCFileDialog::OnInitDialog();\n\t\n  CWnd *pWnd = GetDlgItem(IDC_BTN_PLAY);\n  if (pWnd != NULL)\n  {\n    pWnd->EnableWindow(FALSE);\n  }\n\t\n\treturn TRUE;  // return TRUE unless you set the focus to a control\n\t              // EXCEPTION: OCX Property Pages should return FALSE\n}\n"
  },
  {
    "path": "q3radiant/WaveOpen.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_WAVEOPEN_H__0FB9DA11_EB02_11D2_A50A_0020AFEB881A__INCLUDED_)\n#define AFX_WAVEOPEN_H__0FB9DA11_EB02_11D2_A50A_0020AFEB881A__INCLUDED_\n\n#if _MSC_VER > 1000\n#pragma once\n#endif // _MSC_VER > 1000\n// WaveOpen.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CWaveOpen dialog\n\nclass CWaveOpen : public CFileDialog\n{\n\tDECLARE_DYNAMIC(CWaveOpen)\n\npublic:\n\tCWaveOpen(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs\n\t\tLPCTSTR lpszDefExt = NULL,\n\t\tLPCTSTR lpszFileName = NULL,\n\t\tDWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,\n\t\tLPCTSTR lpszFilter = NULL,\n\t\tCWnd* pParentWnd = NULL);\n\n  virtual void OnFileNameChange( );\nprotected:\n\t//{{AFX_MSG(CWaveOpen)\n\tafx_msg void OnBtnPlay();\n\tvirtual BOOL OnInitDialog();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Visual C++ will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_WAVEOPEN_H__0FB9DA11_EB02_11D2_A50A_0020AFEB881A__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/Win_ent.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"stdafx.h\"\n#include \"qe3.h\"\n#include \"entityw.h\"\n#include \"TexWnd.h\"\n#include \"WaveOpen.h\"\n\nint rgIds[EntLast] = {\n\tIDC_E_LIST,\n\tIDC_E_COMMENT,\n\tIDC_CHECK1,\n\tIDC_CHECK2,\n\tIDC_CHECK3,\n\tIDC_CHECK4,\n\tIDC_CHECK5,\n\tIDC_CHECK6,\n\tIDC_CHECK7,\n\tIDC_CHECK8,\n\tIDC_CHECK9,\n\tIDC_CHECK10,\n\tIDC_CHECK11,\n\tIDC_CHECK12,\n\tIDC_E_PROPS,\n\tIDC_E_0,\n\tIDC_E_45,\n\tIDC_E_90,\n\tIDC_E_135,\n\tIDC_E_180,\n\tIDC_E_225,\n\tIDC_E_270,\n\tIDC_E_315,\n\tIDC_E_UP,\n\tIDC_E_DOWN,\n\tIDC_E_DELPROP,\n\n\tIDC_STATIC_KEY,\n\tIDC_E_KEY_FIELD,\n\tIDC_STATIC_VALUE,\n\tIDC_E_VALUE_FIELD,\n\n\tIDC_E_COLOR,\n\n  IDC_BTN_ASSIGNSOUND, \n  IDC_BTN_ASSIGNMODEL\n\n};\n\nHWND hwndEnt[EntLast];\nCTabCtrl g_wndTabs;\n\nint\t\tinspector_mode;\t\t// W_TEXTURE, W_ENTITY, or W_CONSOLE\n\nqboolean\tmultiple_entities;\n\nentity_t\t*edit_entity;\n\n\nBOOL CALLBACK EntityWndProc(\n    HWND hwndDlg,\t// handle to dialog box\n    UINT uMsg,\t\t// message\n    WPARAM wParam,\t// first message parameter\n    LPARAM lParam);\t// second message parameter\n\nvoid SizeEntityDlg(int iWidth, int iHeight);\nvoid AddProp();\nvoid GetTexMods(void);\n\n\nLRESULT (CALLBACK* OldFieldWindowProc) (HWND, UINT, WPARAM, LPARAM);\nLRESULT (CALLBACK* OldEntityListWindowProc) (HWND, UINT, WPARAM, LPARAM);\n\n/*\n=========================\nFieldWndProc\n\nJust to handle tab and enter...\n=========================\n*/\nBOOL CALLBACK FieldWndProc(\n    HWND hwnd,\n    UINT uMsg,\n    WPARAM wParam,\n    LPARAM lParam)\n{\n    switch (uMsg)\n    {\n\tcase WM_CHAR:\n\t\tif (LOWORD(wParam) == VK_TAB)\n\t\t\treturn FALSE;\n\t\tif (LOWORD(wParam) == VK_RETURN)\n\t\t\treturn FALSE;\n\t\tif (LOWORD(wParam) == VK_ESCAPE)\n\t\t{\n\t\t\tSetFocus (g_qeglobals.d_hwndCamera);\n\t\t\treturn FALSE;\n\t\t}\n\t\tbreak;\n\n\tcase WM_KEYDOWN:\n\t\tif (LOWORD(wParam) == VK_TAB)\n\t\t{\n\t\t\tif (hwnd == hwndEnt[EntKeyField])\n\t\t\t{\n\t\t\t\tSendMessage (hwndEnt[EntValueField], WM_SETTEXT, 0, (long)\"\");\n\t\t\t\tSetFocus (hwndEnt[EntValueField]);\n\t\t\t}\n\t\t\telse\n\t\t\t\tSetFocus (hwndEnt[EntKeyField]);\n\t\t}\n\t\tif (LOWORD(wParam) == VK_RETURN)\n\t\t{\n\t\t\tif (hwnd == hwndEnt[EntKeyField])\n\t\t\t{\n\t\t\t\tSendMessage (hwndEnt[EntValueField], WM_SETTEXT, 0, (long)\"\");\n\t\t\t\tSetFocus (hwndEnt[EntValueField]);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tAddProp ();\n\t\t\t\tSetFocus (g_qeglobals.d_hwndCamera);\n\t\t\t}\n\t\t}\n\t\tbreak;\n//\tcase WM_NCHITTEST:\n\tcase WM_LBUTTONDOWN:\n\t\tSetFocus (hwnd);\n\t\tbreak;\n\t}\n\treturn CallWindowProc (OldFieldWindowProc, hwnd, uMsg, wParam, lParam);\n}\n\n\n/*\n=========================\nEntityListWndProc\n\nJust to handle enter...\n=========================\n*/\nBOOL CALLBACK EntityListWndProc(\n    HWND hwnd,\n    UINT uMsg,\n    WPARAM wParam,\n    LPARAM lParam)\n{\n    switch (uMsg)\n    {\n\tcase WM_KEYDOWN:\n\t\tif (LOWORD(wParam) == VK_RETURN)\n\t\t{\n\t\t\tSendMessage ( g_qeglobals.d_hwndEntity, \n\t\t\t\t          WM_COMMAND, \n\t\t\t              (LBN_DBLCLK<<16) + IDC_E_LIST, \n\t\t\t\t\t\t  0 );\n\t\t\treturn 0;\n\t\t}\n\t\tbreak;\n\t}\n\treturn CallWindowProc (OldEntityListWindowProc, hwnd, uMsg, wParam, lParam);\n}\n\n\n/*\n================\nGetEntityControls\n\nFinds the controls from the dialog and\nmoves them to the window\n================\n*/\nvoid GetEntityControls(HWND ghwndEntity)\n{\n\tint i;\n\n\tfor (i = 0; i < EntLast; i++)\n\t{\n\t\tif (i == EntList || i == EntProps || i == EntComment)\n\t\t\tcontinue;\n\t\tif (i == EntKeyField || i == EntValueField)\n\t\t\tcontinue;\n\t\thwndEnt[i] = GetDlgItem(ghwndEntity, rgIds[i]);\t\t\n\t\tif (hwndEnt[i])\n    {\n\t\t\tSetParent (hwndEnt[i], g_qeglobals.d_hwndEntity );\n\t\t\tSendMessage(hwndEnt[i], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), (LPARAM)TRUE);\n    }\n\t}\n\n\n\t// SetParent apears to not modify some internal state\n\t// on listboxes, so create it from scratch...\n\n\thwndEnt[EntList] = CreateWindow (\"listbox\", NULL, \n\t\tLBS_STANDARD | LBS_NOINTEGRALHEIGHT | LBS_WANTKEYBOARDINPUT \n\t\t| WS_VSCROLL | WS_CHILD | WS_VISIBLE,\n\t\t5, 5, 180, 99,\n\t\tg_qeglobals.d_hwndEntity,\n\t\t(HMENU)IDC_E_LIST,\n\t\tg_qeglobals.d_hInstance,\n\t\tNULL);\n\tif (!hwndEnt[EntList])\n\t\tError (\"CreateWindow failed\");\n\n\thwndEnt[EntProps] = CreateWindow (\"listbox\", NULL, \n\t\tLBS_STANDARD | LBS_NOINTEGRALHEIGHT | LBS_USETABSTOPS\n\t\t| WS_VSCROLL | WS_CHILD | WS_VISIBLE,\n\t\t5, 100, 180, 99,\n\t\tg_qeglobals.d_hwndEntity,\n\t\t(HMENU)IDC_E_PROPS,\n\t\tg_qeglobals.d_hInstance,\n\t\tNULL);\n\tif (!hwndEnt[EntProps])\n\t\tError (\"CreateWindow failed\");\n\n\thwndEnt[EntComment] = CreateWindow (\"edit\", NULL, \n\t\tES_MULTILINE | ES_READONLY | WS_VSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER,\n\t\t5, 100, 180, 99,\n\t\tg_qeglobals.d_hwndEntity,\n\t\t(HMENU)IDC_E_COMMENT,\n\t\tg_qeglobals.d_hInstance,\n\t\tNULL);\n\tif (!hwndEnt[EntComment])\n\t\tError (\"CreateWindow failed\");\n\n\thwndEnt[EntKeyField] = CreateWindow (\"edit\", NULL, \n\t\tWS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL,\n\t\t5, 100, 180, 99,\n\t\tg_qeglobals.d_hwndEntity,\n\t\t(HMENU)IDC_E_KEY_FIELD,\n\t\tg_qeglobals.d_hInstance,\n\t\tNULL);\n\tif (!hwndEnt[EntKeyField])\n\t\tError (\"CreateWindow failed\");\n\n\thwndEnt[EntValueField] = CreateWindow (\"edit\", NULL, \n\t\tWS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL,\n\t\t5, 100, 180, 99,\n\t\tg_qeglobals.d_hwndEntity,\n\t\t(HMENU)IDC_E_VALUE_FIELD,\n\t\tg_qeglobals.d_hInstance,\n\t\tNULL);\n\tif (!hwndEnt[EntValueField])\n\t\tError (\"CreateWindow failed\");\n\n  g_wndTabs.SubclassDlgItem(IDC_TAB_MODE, CWnd::FromHandle(ghwndEntity));\n  hwndEnt[EntTab] = g_wndTabs.GetSafeHwnd();\n  g_wndTabs.InsertItem(0, \"Groups\");\n  ::SetParent(g_wndTabs.GetSafeHwnd(), g_qeglobals.d_hwndEntity);\n\n  if (g_pParentWnd->CurrentStyle() > 0 && g_pParentWnd->CurrentStyle() < 3)\n  {\n\t  g_qeglobals.d_hwndEdit = CreateWindow (\"edit\", NULL, ES_MULTILINE | ES_READONLY | WS_VSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER,\n\t\t                                       5, 100, 180, 99, g_qeglobals.d_hwndEntity, (HMENU)IDC_E_STATUS,\n\t\t                                       g_qeglobals.d_hInstance, NULL);\n\t  if (!g_qeglobals.d_hwndEdit)\n\t\t  Error (\"CreateWindow failed\");\n    g_wndTabs.InsertItem(0, \"Console\");\n    g_wndTabs.InsertItem(0, \"Textures\");\n  }\n  g_wndTabs.InsertItem(0, \"Entities\");\n  g_wndTabs.ShowWindow(SW_SHOW);\n\n#if 0\n\tfor (i=0 ; i<12 ; i++)\n\t{\n\t\thwndEnt[EntCheck1 + i] = CreateWindow (\"button\", NULL, \n\t\tBS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE,\n\t\t5, 100, 180, 99,\n\t\tentwindow,\n\t\t(HMENU)IDC_E_STATUS,\n\t\tmain_instance,\n\t\tNULL);\n\t\tif (!hwndEnt[EntCheck1 + i])\n\t\t\tError (\"CreateWindow failed\");\n\t}\n#endif\n\tSendMessage(hwndEnt[EntList], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), (LPARAM)TRUE);\n\tSendMessage(hwndEnt[EntProps], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), (LPARAM)TRUE);\n\tSendMessage(hwndEnt[EntComment], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), (LPARAM)TRUE);\n\tSendMessage(hwndEnt[EntKeyField], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), (LPARAM)TRUE);\n\tSendMessage(hwndEnt[EntValueField], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), (LPARAM)TRUE);\n\tSendMessage(hwndEnt[EntTab], WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), (LPARAM)TRUE);\n\n\tif (g_pParentWnd->CurrentStyle() > 0 && g_pParentWnd->CurrentStyle() < 3)\n\t\tSendMessage(g_qeglobals.d_hwndEdit, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), (LPARAM)TRUE);\n}\n\n\n\n/*\n===============================================================\n\nENTITY WINDOW\n\n===============================================================\n*/\n\n\nvoid FillClassList (void)\n{\n\teclass_t\t*pec;\n\tint\t\t\tiIndex;\n\n\tSendMessage(hwndEnt[EntList], LB_RESETCONTENT, 0 , 0);\n\n\tfor (pec = eclass ; pec ; pec = pec->next)\n\t{\n\t\tiIndex = SendMessage(hwndEnt[EntList], LB_ADDSTRING, 0 , (LPARAM)pec->name);\n\t\tSendMessage(hwndEnt[EntList], LB_SETITEMDATA, iIndex, (LPARAM)pec);\n\t}\t\n\n}\n\n\n/*\n==============\nWEnt_Create\n==============\n*/\nvoid WEnt_Create (HINSTANCE hInstance)\n{\n    WNDCLASS   wc;\n\n    /* Register the camera class */\n\tmemset (&wc, 0, sizeof(wc));\n\n    wc.style         = CS_NOCLOSE | CS_OWNDC;\n    wc.lpfnWndProc   = (WNDPROC)EntityWndProc;\n    wc.cbClsExtra    = 0;\n    wc.cbWndExtra    = 0;\n    wc.hInstance     = hInstance;\n    wc.hIcon         = 0;\n    wc.hCursor       = LoadCursor (NULL,IDC_ARROW);\n    wc.hbrBackground = (HBRUSH)GetStockObject (LTGRAY_BRUSH);\n    wc.lpszMenuName  = NULL;\n    wc.lpszClassName = ENT_WINDOW_CLASS;\n\n    RegisterClass (&wc);\n\n    int nStyle = (g_pParentWnd->CurrentStyle() == QR_QE4) ? QE3_STYLE : QE3_STYLE2;\n\t  g_qeglobals.d_hwndEntity = CreateWindow (ENT_WINDOW_CLASS ,\n\t\t\"Entity\",\n\t\tnStyle,\n\t\t20,\n\t\t20,\n\t\t100,\n\t\t480,\t// size\n\n\t\tg_qeglobals.d_hwndMain,\t// parent\n\t\t0,\t\t// no menu\n\t\thInstance,\n\t\tNULL);\n\n\tif (!g_qeglobals.d_hwndEntity )\n\t\tError (\"Couldn't create Entity window\");\n}\n\n/*\n==============\nCreateEntityWindow\n==============\n*/\nBOOL CreateEntityWindow(HINSTANCE hInstance)\n{\n\tHWND hwndEntityPalette;\n\n\tinspector_mode = W_ENTITY;\n\n\tWEnt_Create (hInstance);\n\n\thwndEntityPalette = CreateDialog(hInstance, (char *)IDD_ENTITY, g_qeglobals.d_hwndMain, (DLGPROC)NULL);\n\tif (!hwndEntityPalette)\n\t\tError (\"CreateDialog failed\");\n\n\tGetEntityControls (hwndEntityPalette);\n\tDestroyWindow (hwndEntityPalette);\n\n\tOldFieldWindowProc = (WNDPROC)GetWindowLong (hwndEnt[EntKeyField], GWL_WNDPROC);\n\tSetWindowLong (hwndEnt[EntKeyField], GWL_WNDPROC, (long)FieldWndProc);\n\tSetWindowLong (hwndEnt[EntValueField], GWL_WNDPROC, (long)FieldWndProc);\n\n\tOldEntityListWindowProc = (WNDPROC)GetWindowLong (hwndEnt[EntList], GWL_WNDPROC);\n\tSetWindowLong (hwndEnt[EntList], GWL_WNDPROC, (long)EntityListWndProc);\n\n\tFillClassList ();\n\n\n\tLoadWindowPlacement(g_qeglobals.d_hwndEntity, \"EntityWindowPlace\");\n\tShowWindow (g_qeglobals.d_hwndEntity, SW_HIDE);\n\tSetInspectorMode (W_CONSOLE);\n\n\treturn TRUE;\n}\n\n/*\n==============\nSetInspectorMode\n==============\n*/\nvoid SetInspectorMode(int iType)\n{\n\tRECT rc;\n\tHMENU hMenu = GetMenu( g_qeglobals.d_hwndMain );\n\n  if ((g_pParentWnd->CurrentStyle() == QR_SPLIT || g_pParentWnd->CurrentStyle() == QR_SPLITZ) && (iType == W_TEXTURE || iType == W_CONSOLE))\n    return;\n\n\n\t// Is the caller asking us to cycle to the next window?\n\n\tif (iType == -1)\n\t{\n\t\tif (inspector_mode == W_ENTITY)\n\t\t\tiType = W_TEXTURE;\n\t\telse if (inspector_mode == W_TEXTURE)\n\t\t\tiType = W_CONSOLE;\n\t\telse if (inspector_mode == W_CONSOLE)\n      iType = W_GROUP;\n    else\n\t\t\tiType = W_ENTITY;\n\t}\t\t\n\n\tinspector_mode = iType;\n\tswitch(iType)\n\t{\n\t\t\n\tcase W_ENTITY:\n\t\tSetWindowText(g_qeglobals.d_hwndEntity, \"Entity\");\n\t\tEnableMenuItem( hMenu, ID_MISC_SELECTENTITYCOLOR, MF_ENABLED | MF_BYCOMMAND );\n    // entity is always first in the inspector\n    g_wndTabs.SetCurSel(0);\n\t\tbreak;\n\n\tcase W_TEXTURE:\n    SetWindowText(g_qeglobals.d_hwndEntity, \"Textures\");\n    g_pParentWnd->GetTexWnd()->FocusEdit();\n\t\tEnableMenuItem( hMenu, ID_MISC_SELECTENTITYCOLOR, MF_GRAYED | MF_DISABLED | MF_BYCOMMAND );\n    if (g_pParentWnd->CurrentStyle() > 0 && g_pParentWnd->CurrentStyle() < 3)\n      g_wndTabs.SetCurSel(1);\n\t\tbreak;\n\n\tcase W_CONSOLE:\n\t\tSetWindowText(g_qeglobals.d_hwndEntity, \"Console\");\t\t\n\t\tEnableMenuItem( hMenu, ID_MISC_SELECTENTITYCOLOR, MF_GRAYED | MF_DISABLED | MF_BYCOMMAND );\n    if (g_pParentWnd->CurrentStyle() > 0 && g_pParentWnd->CurrentStyle() < 3)\n      g_wndTabs.SetCurSel(2);\n\t\tbreak;\n\n  case W_GROUP:\n\t\tSetWindowText(g_qeglobals.d_hwndEntity, \"Groups\");\t\t\n\t\tEnableMenuItem( hMenu, ID_MISC_SELECTENTITYCOLOR, MF_GRAYED | MF_DISABLED | MF_BYCOMMAND );\n    if (g_pParentWnd->CurrentStyle() > 0 && g_pParentWnd->CurrentStyle() < 3)\n      g_wndTabs.SetCurSel(3);\n    else\n      g_wndTabs.SetCurSel(1);\n\t\tbreak;\n\n\n\tdefault:\n\t\tbreak;\n\t}\n\n\tGetWindowRect (g_qeglobals.d_hwndEntity, &rc);\n\tSizeEntityDlg( rc.right - rc.left - 8, rc.bottom - rc.top - 20);\n\n\n//\tInvalidateRect(entwindow, NULL, true);\n//\tShowWindow (entwindow, SW_SHOW);\n//\tUpdateWindow (entwindow);\n\n  HWND hFlag = (g_pParentWnd->CurrentStyle() == QR_QE4) ? HWND_TOP : HWND_TOPMOST;\n\tSetWindowPos( g_qeglobals.d_hwndEntity, hFlag, rc.left, rc.top,  rc.right - rc.left, rc.bottom - rc.top, SWP_NOSIZE | SWP_NOMOVE );\n\tRedrawWindow (g_qeglobals.d_hwndEntity, NULL, NULL, RDW_ERASE | RDW_INVALIDATE| RDW_ERASENOW | RDW_UPDATENOW | RDW_ALLCHILDREN);\n}\n\n\n\n\n\n// SetKeyValuePairs\n//\n// Reset the key/value (aka property) listbox and fill it with the \n// k/v pairs from the entity being edited.\n//\n\nvoid SetKeyValuePairs (bool bClearMD3)\n{\n\tepair_t\t*pep;\n\tRECT\trc;\n\tchar\tsz[4096];\n\t\n\tif (edit_entity == NULL)\n\t\treturn;\n\t\n\t// set key/value pair list\n\t\n\tGetWindowRect(hwndEnt[EntProps], &rc);\n\tSendMessage(hwndEnt[EntProps], LB_SETCOLUMNWIDTH, (rc.right - rc.left)/2, 0);\n\tSendMessage(hwndEnt[EntProps], LB_RESETCONTENT, 0, 0);\n\t\n\t// Walk through list and add pairs\n\t\n\tfor (pep = edit_entity->epairs ; pep ; pep = pep->next)\n\t{\n\t\t// if the key is less than 8 chars, add a tab for alignment\n\t\tif (strlen(pep->key) > 8)\n\t\t\tsprintf (sz, \"%s\\t%s\", pep->key, pep->value);\n\t\telse\n\t\t\tsprintf (sz, \"%s\\t\\t%s\", pep->key, pep->value);\n\t\tSendMessage(hwndEnt[EntProps], LB_ADDSTRING, 0, (LPARAM)sz);\n\t}\n\t\n\tif (edit_entity->eclass->nShowFlags & ECLASS_MISCMODEL)\n\t{\n\t\t// if this is a misc_model\n\t\t// cache the md3 for display later\n\t\tif (bClearMD3)\n\t\t{\n\t\t\tedit_entity->md3Class = NULL;\n\t\t}\n\t\t//char *pModel = ValueForKey(edit_entity, \"model\");\n\t\t\n\t\t/*\n\t\tif (pModel != NULL)\n\t\t{\n\t\tGetCachedModel(pModel, vMin, vMax);\n\t\t}\n\t\t*/\n\t}\n\t\t\n\tSys_UpdateWindows(W_CAMERA | W_XY);\n\t\n}\n\n// SetSpawnFlags\n// \n// Update the checkboxes to reflect the flag state of the entity\n//\nvoid SetSpawnFlags(void)\n{\n\tint\t\tf;\n\tint\t\ti;\n\tint\t\tv;\n\n\tf = atoi(ValueForKey (edit_entity, \"spawnflags\"));\n\tfor (i=0 ; i<12 ; i++)\n\t{\n\t\tv = !!(f&(1<<i));\n\t\tSendMessage(hwndEnt[EntCheck1+i], BM_SETCHECK, v, 0);\n\t}\n}\n\n\n// GetSpawnFlags\n// \n// Update the entity flags to reflect the state of the checkboxes\n//\nvoid GetSpawnFlags(void)\n{\n\tint\t\tf;\n\tint\t\ti, v;\n\tchar\tsz[32];\n\n\tf = 0;\n\tfor (i=0 ; i<12 ; i++)\n\t{\n\t\tv = SendMessage(hwndEnt[EntCheck1+i], BM_GETCHECK, 0, 0);\n\t\tf |= v<<i;\n\t}\n\n\tsprintf (sz, \"%i\", f);\n\n\tif (multiple_entities)\n\t{\n\t\tbrush_t\t*b;\n\n\t\tfor (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n\t\t\tSetKeyValue(b->owner, \"spawnflags\", sz);\n\t}\n\telse\n\t\tSetKeyValue (edit_entity, \"spawnflags\", sz);\n\tSetKeyValuePairs ();\n}\n\n// UpdateSel\n//\n// Update the listbox, checkboxes and k/v pairs to reflect the new selection\n//\nBOOL UpdateSel(int iIndex, eclass_t *pec)\n{\n\tint\t\ti;\n\tbrush_t\t*b;\n\n\tif (selected_brushes.next == &selected_brushes)\n\t{\n\t\tedit_entity = world_entity;\n\t\tmultiple_entities = false;\n\t}\n\telse\n\t{\n\t\tedit_entity = selected_brushes.next->owner;\n\t\tfor (b=selected_brushes.next->next ; b != &selected_brushes ; b=b->next)\n\t\t{\n\t\t\tif (b->owner != edit_entity)\n\t\t\t{\n\t\t\t\tmultiple_entities = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (iIndex != LB_ERR)\n\t\tSendMessage(hwndEnt[EntList], LB_SETCURSEL, iIndex, 0);\n\n\tif (pec == NULL)\n\t\treturn TRUE;\n\n\t// Set up the description\n\n\tSendMessage(hwndEnt[EntComment], WM_SETTEXT, 0, \n\t\t\t(LPARAM)TranslateString(pec->comments));\n\n\tfor (i=0 ; i<8 ; i++)\n\t{\n\t\tHWND hwnd = hwndEnt[EntCheck1+i];\n\t\tif (pec->flagnames[i] && pec->flagnames[i][0] != 0)\n\t\t{\n\t\t\tEnableWindow(hwnd, TRUE);\n\t\t\tSendMessage(hwnd, WM_SETTEXT, 0, (LPARAM)pec->flagnames[i]);\n\t\t} else {\n\n\t\t\t// disable check box\n\t\t\tSendMessage(hwnd, WM_SETTEXT, 0, (LPARAM)\" \");\n\t\t\tEnableWindow(hwnd, FALSE);\n\t\t}\n\t}\n\n\tSetSpawnFlags();\n\tSetKeyValuePairs();\n\treturn TRUE;\n}\n\nBOOL UpdateEntitySel(eclass_t *pec)\n{\n\tint iIndex;\n\n\tiIndex = (int)SendMessage(hwndEnt[EntList], LB_FINDSTRINGEXACT, \n\t\t\t(WPARAM)-1, (LPARAM)pec->name);\n\n\treturn UpdateSel(iIndex, pec);\n}\n\n// CreateEntity\n//\n// Creates a new entity based on the currently selected brush and entity type.\n//\n\nvoid CreateEntity(void)\n{\n\teclass_t *pecNew;\n\tentity_t *petNew;\n\tint i;\n\tHWND hwnd;\n\tchar sz[1024];\n\n\t// check to make sure we have a brush\n\n\tif (selected_brushes.next == &selected_brushes)\n\t{\n\t    MessageBox(g_qeglobals.d_hwndMain, \"You must have a selected brush to create an entity\"\n\t\t\t, \"info\", 0);\n\t\treturn;\n\t}\n\n\n\t// find out what type of entity we are trying to create\n\n\thwnd = hwndEnt[EntList];\n\n\ti = SendMessage(hwndEnt[EntList], LB_GETCURSEL, 0, 0);\n\n\tif (i < 0)\n\t{\n\t    MessageBox(g_qeglobals.d_hwndMain, \"You must have a selected class to create an entity\"\n\t\t\t, \"info\", 0);\n\t\treturn;\n\t}\n\n\tSendMessage(hwnd, LB_GETTEXT, i, (LPARAM)sz);\n\n\tif (!stricmp(sz, \"worldspawn\"))\n\t{\n\t    MessageBox(g_qeglobals.d_hwndMain, \"Can't create an entity with worldspawn.\", \"info\", 0);\n\t\treturn;\n\t}\n\n\tpecNew = Eclass_ForName(sz, false);\n\n\t// create it\n\n\tpetNew = Entity_Create(pecNew);\n\n\tif (petNew == NULL)\n\t{\n\t    MessageBox(g_qeglobals.d_hwndMain, \"Failed to create entity.\", \"info\", 0);\n\t\treturn;\n\t}\n\n\tif (selected_brushes.next == &selected_brushes)\n\t\tedit_entity = world_entity;\n\telse\n\t\tedit_entity = selected_brushes.next->owner;\n\n\tSetKeyValuePairs();\n\tSelect_Deselect ();\n\tSelect_Brush (edit_entity->brushes.onext);\n  Sys_UpdateWindows(W_ALL);\n\n}\n\n\n\n/*\n===============\nAddProp\n\n===============\n*/\nvoid AddProp()\n{\n\tchar\tkey[4096];\n\tchar\tvalue[4096];\n\n\tif (edit_entity == NULL)\n\t\treturn;\n\n\t// Get current selection text\n\n\tSendMessage(hwndEnt[EntKeyField], WM_GETTEXT, sizeof(key)-1, (LPARAM)key);\t\n\tSendMessage(hwndEnt[EntValueField], WM_GETTEXT, sizeof(value)-1, (LPARAM)value);\t\n\n\tif (multiple_entities)\n\t{\n\t\tbrush_t\t*b;\n\n\t\tfor (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n\t\t\tSetKeyValue(b->owner, key, value);\n\t}\n\telse\n\t\tSetKeyValue(edit_entity, key, value);\n\n\t// refresh the prop listbox\n\tSetKeyValuePairs();\t\n\n\t// if it's a plugin entity, perhaps we need to update some drawing parameters\n\t// NOTE: perhaps moving this code to a seperate func would help if we need it in other places\n\t// TODO: we need to call some update func in the IPluginEntity in case model name changes etc.\n\t// ( for the moment only bounding brush is updated ), see UpdateModelBrush in Ritual's Q3Radiant\n\tif (edit_entity->eclass->nShowFlags & ECLASS_PLUGINENTITY)\n\t{\n\t\tvec3_t\tmins, maxs;\n\t\tedit_entity->pPlugEnt->GetBounds( mins, maxs );\n\t\t// replace old bounding brush by newly computed one\n\t\t// NOTE: this part is similar to Entity_BuildModelBrush in Ritual's Q3Radiant, it can be\n\t\t// usefull moved into a seperate func\n\t\tbrush_t *b,*oldbrush;\n\t\tif (edit_entity->brushes.onext != &edit_entity->brushes)\n\t\t\toldbrush = edit_entity->brushes.onext;\n\t\tb = Brush_Create (mins, maxs, &edit_entity->eclass->texdef);\n\t\tEntity_LinkBrush (edit_entity, b);\n\t\tBrush_Build( b, true );\n\t\tSelect_Deselect();\n\t\tBrush_AddToList (edit_entity->brushes.onext, &selected_brushes);\n\t\tif (oldbrush)\n\t\t\tBrush_Free( oldbrush );\n\t}\n\n}\n\n/*\n===============\nDelProp\n\n===============\n*/\nvoid DelProp(void)\n{\n\tchar\tsz[4096];\n\n\tif (edit_entity == NULL)\n\t\treturn;\n\n\t// Get current selection text\n\n\tSendMessage(hwndEnt[EntKeyField], WM_GETTEXT, sizeof(sz)-1, (LPARAM)sz);\t\n\n\tif (multiple_entities)\n\t{\n\t\tbrush_t\t*b;\n\n\t\tfor (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)\n\t\t\tDeleteKey(b->owner, sz);\n\t}\n\telse\n\t\tDeleteKey(edit_entity, sz);\n\n\t// refresh the prop listbox\n\n\tSetKeyValuePairs();\t\n}\n\nBOOL GetSelectAllCriteria(CString &strKey, CString &strVal) {\n\tchar\tsz[4096];\n\tHWND hwnd = hwndEnt[EntProps];\n\tint i = SendMessage(hwnd, LB_GETCURSEL, 0, 0);\t\n  if (i >= 0 && inspector_mode == W_ENTITY) {\n\t  SendMessage(hwndEnt[EntKeyField], WM_GETTEXT, sizeof(sz), (LPARAM)sz);\t\n    strKey = sz;\n\t  SendMessage(hwndEnt[EntValueField], WM_GETTEXT, sizeof(sz), (LPARAM)sz);\t\n    strVal = sz;\n    return TRUE;\n  }\n  return FALSE;\n}\n\n/*\n===============\nEditProp\n\n===============\n*/\nvoid EditProp(void)\n{\n\tint i;\n\tHWND hwnd;\n\tchar\tsz[4096];\n\tchar\t*val;\n\n\tif (edit_entity == NULL)\n\t\treturn;\n\n\thwnd = hwndEnt[EntProps];\n\n\t// Get current selection text\n\n\ti = SendMessage(hwnd, LB_GETCURSEL, 0, 0);\t\n\n\tif (i < 0)\n\t\treturn;\n\n\tSendMessage(hwnd, LB_GETTEXT, i, (LPARAM)sz);\t\n\n\t// strip it down to the key name\n\n\tfor(i=0;sz[i] != '\\t';i++)\n\t;\n\n\tsz[i] = '\\0';\n\n\tval = sz + i + 1;\n\tif (*val == '\\t')\n\t\tval++;\n\n\tSendMessage(hwndEnt[EntKeyField], WM_SETTEXT, 0, (LPARAM)sz);\t\n\tSendMessage(hwndEnt[EntValueField], WM_SETTEXT, 0, (LPARAM)val);\t\n}\n\n\nHDWP\tdefer;\nint\t\tcol;\nvoid MOVE(HWND e, int x, int y, int w, int h, HWND hwndPlacement = HWND_TOP, int swp = SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOZORDER)\n{\n//\tdefer=DeferWindowPos(defer,e,HWND_TOP,col+(x),y,w,h,SWP_SHOWWINDOW);\n//\tMoveWindow (e, col+x, y, w, h, FALSE);\n\tSetWindowPos (e, hwndPlacement, col+x, y, w, h, swp);\n}\n\n\n/*\n===============\nSizeEnitityDlg\n\nPositions all controls so that the active inspector\nis displayed correctly and the inactive ones are\noff the side\n===============\n*/\nvoid SizeEntityDlg(int iWidth, int iHeight)\n{\n\tint y, x, xCheck, yCheck;\n\tint i, iRow;\n\tint\tw, h;\n\n\tif (iWidth < 32 || iHeight < 32)\n\t\treturn;\n\n\tSendMessage( g_qeglobals.d_hwndEntity, WM_SETREDRAW, 0, 0);\n  iHeight -= 24;\n\n\n\t//==========================================\n\n\n  //\n\t// console\n\t//\n  if (inspector_mode == W_CONSOLE)\n  {\n    col = 0;\n  }\n  else\n  {\n    col = iWidth;\n  }\n\n  if (g_pParentWnd->CurrentStyle() > 0 && g_pParentWnd->CurrentStyle() < 3)\n\t  MOVE(g_qeglobals.d_hwndEdit,\tDlgXBorder, DlgYBorder, iWidth - (2 * DlgXBorder), iHeight - (2 * DlgYBorder) );\n\n\t//==========================================\n\n\t//\n\t// texture controls\n\t//\n  if (inspector_mode == W_TEXTURE)\n  {\n    col = 0;\n  }\n  else\n  {\n    col = iWidth;\n  }\n\n  if (g_pParentWnd->CurrentStyle() > 0 && g_pParentWnd->CurrentStyle() < 3)\n\t  MOVE(g_qeglobals.d_hwndTexture,\tDlgXBorder, DlgYBorder, iWidth - (2 * DlgXBorder), iHeight - (2 * DlgYBorder) );\n\n  if (inspector_mode == W_GROUP)\n  {\n    col = 0;\n  }\n  else\n  {\n    col = iWidth;\n  }\n\n  MOVE(g_qeglobals.d_hwndGroup,\tDlgXBorder, DlgYBorder, iWidth - (2 * DlgXBorder), iHeight - (2 * DlgYBorder) );\n\n\t//==========================================\n\n\t//\n\t// entity controls\n\t//\n  if (inspector_mode == W_ENTITY)\n  {\n    col = 0;\n  }\n  else\n  {\n    col = iWidth;\n  }\n\n\n\n\t// top half includes the entity list (2/3) and the \n\t// comments (1/3) - 2 gaps, above and below.\n\n\ty = iHeight/2;\n\ty -= 2 * DlgYBorder;\n\ty = y / 3;\n\tw = iWidth - (2 * DlgXBorder);\n\tMOVE(hwndEnt[EntList], DlgXBorder, DlgYBorder, w, 2 * y);\n\t\n\tMOVE(hwndEnt[EntComment], DlgXBorder, 2 * DlgYBorder + 2 * y, w, y - (2 * DlgYBorder));\n\n\t// bottom half includes flags (fixed), k/v pairs,\n\t// and buttons (fixed).\n\n\t// xCheck = width of a single check box\n\t// yCheck = distance from top of one check to the next\n\n\txCheck = (iWidth - (2 * DlgXBorder)) / 3;\n\tyCheck = 18;\n\n\tx = DlgXBorder;\n\n\tfor (iRow = 0; iRow <= 12; iRow += 4)\n\t{\n\t\ty = iHeight/2;\n\t\n\t\tfor (i = 0; i < 4; i++)\n\t\t{\n\t\t\tMOVE(hwndEnt[EntCheck1 + i + iRow],\n\t\t\t\tx, y, xCheck, yCheck);\n\t\t\ty += yCheck;\n\t\t}\n\n\t\tx += xCheck;\n\t}\n\n\t//\n\t// properties scroll box\n\t//\n\ty = iHeight/2 + 4 * yCheck;\n\n\tw = iWidth - (2 * DlgXBorder);\n\th = (iHeight - (yCheck * 5 + 2 * DlgYBorder) ) - y;\n\n\tMOVE(hwndEnt[EntProps], DlgXBorder, y, w, h);\n\n\ty += h + DlgYBorder;\n\t\n\t//\n\t// key / value fields\n\t//\n\tw = iWidth-(DlgXBorder+45);\n\tMOVE(hwndEnt[EntKeyLabel], DlgXBorder, y, 40, yCheck);\n\tMOVE(hwndEnt[EntKeyField], DlgXBorder+40, y, w, yCheck);\n\ty += yCheck;\t\t\n\n\tMOVE(hwndEnt[EntValueLabel], DlgXBorder, y, 40, yCheck);\n\tMOVE(hwndEnt[EntValueField], DlgXBorder+40, y, w, yCheck);\n\ty += yCheck;\t\t\n\n\t//\n\t// angle check boxes\n\t//\n  y += 2;\n\ti = y;\n\tx = DlgXBorder;\n\n\txCheck = yCheck*2;\n\n\tMOVE(hwndEnt[EntDir135], x, y, xCheck, yCheck);\n\ty += yCheck;\t\t\n\t\n\tMOVE(hwndEnt[EntDir180], x, y, xCheck, yCheck);\n\ty += yCheck;\t\t\n\t\n\tMOVE(hwndEnt[EntDir225], x, y, xCheck, yCheck);\n\n\ty = i;\n\tx += xCheck;\n\n\t\n\tMOVE(hwndEnt[EntDir90], x, y, xCheck, yCheck);\n\ty += yCheck;\t\t\n\ty += yCheck;\t\t\n\t\n\tMOVE(hwndEnt[EntDir270], x, y, xCheck, yCheck);\n\n\ty = i;\n\tx += xCheck;\n\n\t\n\tMOVE(hwndEnt[EntDir45], x, y, xCheck, yCheck);\n\ty += yCheck;\t\t\n\t\n\tMOVE(hwndEnt[EntDir0], x, y, xCheck, yCheck);\n\ty += yCheck;\t\t\n\t\n\tMOVE(hwndEnt[EntDir315], x, y, xCheck, yCheck);\n\n\ty = i + yCheck/2;\n\tx += xCheck + xCheck/2;\n\n\t\n\tMOVE(hwndEnt[EntDirUp], x, y, xCheck, yCheck);\n\ty += yCheck;\t\t\n\t\n\tMOVE(hwndEnt[EntDirDown], x, y, xCheck, yCheck);\n\n\ty = i;\n\tx += 1.5 * xCheck;\n\t\n\tMOVE(hwndEnt[EntDelProp], x, y, xCheck*2, yCheck);\n\ty += yCheck + 4;\t\t\n\n  MOVE(hwndEnt[EntAssignSounds], x, y, xCheck*2, yCheck);\n\ty += yCheck;\t\t\n  MOVE(hwndEnt[EntAssignModels], x, y, xCheck*2, yCheck);\n\n  // tab selector is always visible\n  col = 0;\n  iHeight += 24;\n  MOVE(hwndEnt[EntTab], 0,0,iWidth,iHeight, HWND_BOTTOM, SWP_NOACTIVATE | SWP_NOCOPYBITS);\n\n\tSendMessage( g_qeglobals.d_hwndEntity, WM_SETREDRAW, 1, 0);\n//\tInvalidateRect(entwindow, NULL, TRUE);\n}\n\nvoid AssignSound()\n{\n  CString strBasePath = ValueForKey(g_qeglobals.d_project_entity, \"basepath\");\n  AddSlash(strBasePath);\n  CString strPath = strBasePath;\n  strPath += \"sound\\\\\";\n\n  CWaveOpen dlgFile(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, \"Sound files (*.wav)|*.wav||\", g_pParentWnd);\n  dlgFile.m_ofn.lpstrInitialDir = strPath;\n  if (dlgFile.DoModal() == IDOK)\n  {\n\t  SendMessage(hwndEnt[EntKeyField], WM_SETTEXT, 0, (LPARAM)\"noise\");\t\n    CString str = dlgFile.GetPathName().GetBuffer(0);\n    str.MakeLower();\n    strBasePath.MakeLower();\n    QE_ConvertDOSToUnixName(str.GetBuffer(0), str.GetBuffer(0));\n    QE_ConvertDOSToUnixName(strBasePath.GetBuffer(0), strBasePath.GetBuffer(0));\n    int n = str.Find(strBasePath);\n    if (n == 0)\n    {\n      str = str.Right(str.GetLength() - strBasePath.GetLength());\n    }\n\n\t  SendMessage(hwndEnt[EntValueField], WM_SETTEXT, 0, (LPARAM)str.GetBuffer(0));\t\n    AddProp();\n    g_pParentWnd->GetXYWnd()->SetFocus();\n  }\n}\n\nvoid AssignModel()\n{\n  CString strBasePath = ValueForKey(g_qeglobals.d_project_entity, \"basepath\");\n  AddSlash(strBasePath);\n  CString strPath = strBasePath;\n  strPath += \"models\\\\mapobjects\\\\\";\n\n  CFileDialog dlgFile(TRUE, NULL, NULL, OFN_OVERWRITEPROMPT, \"Model files (*.md3)|*.md3||\", g_pParentWnd);\n  dlgFile.m_ofn.lpstrInitialDir = strPath;\n  if (dlgFile.DoModal() == IDOK)\n  {\n\t  SendMessage(hwndEnt[EntKeyField], WM_SETTEXT, 0, (LPARAM)\"model\");\n    CString str = dlgFile.GetPathName().GetBuffer(0);\n    str.MakeLower();\n    strBasePath.MakeLower();\n    QE_ConvertDOSToUnixName(str.GetBuffer(0), str.GetBuffer(0));\n    QE_ConvertDOSToUnixName(strBasePath.GetBuffer(0), strBasePath.GetBuffer(0));\n    int n = str.Find(strBasePath);\n    if (n == 0)\n    {\n      str = str.Right(str.GetLength() - strBasePath.GetLength());\n    }\n\n\t  SendMessage(hwndEnt[EntValueField], WM_SETTEXT, 0, (LPARAM)str.GetBuffer(0));\t\n    AddProp();\n    edit_entity->md3Class = NULL;\n    edit_entity->brushes.onext->bModelFailed = false;\n    g_pParentWnd->GetXYWnd()->SetFocus();\n  }\n}\n\n\n/*\n=========================\nEntityWndProc\n=========================\n*/\nBOOL CALLBACK EntityWndProc(\n    HWND hwndDlg,\t// handle to dialog box\n    UINT uMsg,\t\t// message\n    WPARAM wParam,\t// first message parameter\n    LPARAM lParam)\t// second message parameter\n{\n  LPNMHDR lpnmh = NULL;\n\tRECT\trc;\n\n\tGetClientRect(hwndDlg, &rc);\n\n    switch (uMsg)\n    {\n\n      case WM_CHAR :\n      {\n        char c = toupper(LOWORD(wParam));\n        // escape: hide the window\n\t\t    if (c == 27)\n\t\t\t    ShowWindow(hwndDlg, SW_HIDE);\n        if (c == 'N')\n          g_pParentWnd->PostMessage(WM_COMMAND, ID_VIEW_ENTITY, 0);\n        else\n        if (c == 'O')\n          g_pParentWnd->PostMessage(WM_COMMAND, ID_VIEW_CONSOLE, 0);\n        else\n        if (c == 'T')\n          g_pParentWnd->PostMessage(WM_COMMAND, ID_VIEW_TEXTURE, 0);\n        else\n        if (c == 'G')\n          g_pParentWnd->PostMessage(WM_COMMAND, ID_VIEW_GROUPS, 0);\n        else\n\t\t\t    DefWindowProc (hwndDlg, uMsg, wParam, lParam);\n        break;\n      }\n\n      case WM_NOTIFY:\n        lpnmh = reinterpret_cast<LPNMHDR>(lParam);\n        if (lpnmh->hwndFrom == g_wndTabs.GetSafeHwnd()) {\n          if ( lpnmh->code == TCN_SELCHANGE)\n          {\n            int n = g_wndTabs.GetCurSel();\n            if (g_pParentWnd->CurrentStyle() == 2 || g_pParentWnd->CurrentStyle() == 1)\n            {\n              if (n == 0) {\n                SetInspectorMode(W_ENTITY);\n              } else if (n == 1) {\n                SetInspectorMode(W_TEXTURE);\n              } else if (n == 2) {\n                SetInspectorMode(W_CONSOLE);\n              } else {\n                SetInspectorMode(W_GROUP);\n              }\n            }\n            else\n            {\n              if (n == 0) {\n                SetInspectorMode(W_ENTITY);\n              } else if (n == 1) {\n                SetInspectorMode(W_GROUP);\n              }\n            }\n          }\n        }\n        break;\n        \n\tcase WM_SIZE:\n\n\t\t\tDefWindowProc (hwndDlg, uMsg, wParam, lParam);\n      break;\n\n  case WM_DESTROY:\n      SaveWindowPlacement(g_qeglobals.d_hwndEntity, \"EntityWindowPlace\");\n      DefWindowProc(hwndDlg, uMsg, wParam, lParam);\n      break;\n\n\tcase WM_GETMINMAXINFO:\n\t\t{\n\t\t\tLPMINMAXINFO\tlpmmi;\n\n\t\t\tlpmmi = (LPMINMAXINFO) lParam;\n\t\t\tlpmmi->ptMinTrackSize.x = 320;\n\t\t\tlpmmi->ptMinTrackSize.y = 500;\n\t\t}\n\t\treturn 0;\n\n\tcase WM_WINDOWPOSCHANGING:\n\t\t{\n\t\t\tLPWINDOWPOS\tlpwp;\n\t\t\tlpwp = (LPWINDOWPOS) lParam;\n\n\t\t\tDefWindowProc (hwndDlg, uMsg, wParam, lParam);\n\n\t\t\tlpwp->flags |= SWP_NOCOPYBITS;\n\t\t\tSizeEntityDlg(lpwp->cx-8, lpwp->cy-32);\n\t\t\treturn 0;\n\n\t\t}\n\t\treturn 0;\n\n\n\tcase WM_COMMAND: \n\t\tswitch (LOWORD(wParam)) { \n\n    case IDC_BTN_ASSIGNSOUND:\n      AssignSound();\n      break;\n\n    case IDC_BTN_ASSIGNMODEL:\n      AssignModel();\n      break;\n\n\t\tcase IDC_E_DELPROP:\n\t\t\tDelProp();\n\t\t\tSetFocus (g_qeglobals.d_hwndCamera);\n\t\t\tbreak;\n\n\t\tcase IDC_E_0:\n\t\t\tSetKeyValue (edit_entity, \"angle\", \"360\");\n\t\t\tSetFocus (g_qeglobals.d_hwndCamera);\n\t\t\tSetKeyValuePairs ();\n\t\t\tbreak;\n\t\tcase IDC_E_45:\n\t\t\tSetKeyValue (edit_entity, \"angle\", \"45\");\n\t\t\tSetFocus (g_qeglobals.d_hwndCamera);\n\t\t\tSetKeyValuePairs ();\n\t\t\tbreak;\n\t\tcase IDC_E_90:\n\t\t\tSetKeyValue (edit_entity, \"angle\", \"90\");\n\t\t\tSetFocus (g_qeglobals.d_hwndCamera);\n\t\t\tSetKeyValuePairs ();\n\t\t\tbreak;\n\t\tcase IDC_E_135:\n\t\t\tSetKeyValue (edit_entity, \"angle\", \"135\");\n\t\t\tSetFocus (g_qeglobals.d_hwndCamera);\n\t\t\tSetKeyValuePairs ();\n\t\t\tbreak;\n\t\tcase IDC_E_180:\n\t\t\tSetKeyValue (edit_entity, \"angle\", \"180\");\n\t\t\tSetFocus (g_qeglobals.d_hwndCamera);\n\t\t\tSetKeyValuePairs ();\n\t\t\tbreak;\n\t\tcase IDC_E_225:\n\t\t\tSetKeyValue (edit_entity, \"angle\", \"225\");\n\t\t\tSetFocus (g_qeglobals.d_hwndCamera);\n\t\t\tSetKeyValuePairs ();\n\t\t\tbreak;\n\t\tcase IDC_E_270:\n\t\t\tSetKeyValue (edit_entity, \"angle\", \"270\");\n\t\t\tSetFocus (g_qeglobals.d_hwndCamera);\n\t\t\tSetKeyValuePairs ();\n\t\t\tbreak;\n\t\tcase IDC_E_315:\n\t\t\tSetKeyValue (edit_entity, \"angle\", \"315\");\n\t\t\tSetFocus (g_qeglobals.d_hwndCamera);\n\t\t\tSetKeyValuePairs ();\n\t\t\tbreak;\n\t\tcase IDC_E_UP:\n\t\t\tSetKeyValue (edit_entity, \"angle\", \"-1\");\n\t\t\tSetFocus (g_qeglobals.d_hwndCamera);\n\t\t\tSetKeyValuePairs ();\n\t\t\tbreak;\n\t\tcase IDC_E_DOWN:\n\t\t\tSetKeyValue (edit_entity, \"angle\", \"-2\");\n\t\t\tSetFocus (g_qeglobals.d_hwndCamera);\n\t\t\tSetKeyValuePairs ();\n\t\t\tbreak;\n\n    case IDC_BTN_HIDE:\n      ::PostMessage(g_qeglobals.d_hwndMain, WM_COMMAND, ID_VIEW_CAMERATOGGLE, 0);\n      break;\n\n\t\tcase IDC_CHECK1:\n\t\tcase IDC_CHECK2:\n\t\tcase IDC_CHECK3:\n\t\tcase IDC_CHECK4:\n\t\tcase IDC_CHECK5:\n\t\tcase IDC_CHECK6:\n\t\tcase IDC_CHECK7:\n\t\tcase IDC_CHECK8:\n\t\tcase IDC_CHECK9:\n\t\tcase IDC_CHECK10:\n\t\tcase IDC_CHECK11:\n\t\tcase IDC_CHECK12:\n\t\t\tGetSpawnFlags();\n\t\t\tSetFocus (g_qeglobals.d_hwndCamera);\n\t\t\tbreak;\n\n\n\t\tcase IDC_E_PROPS: \n\t\t\tswitch (HIWORD(wParam))\n\t\t\t{ \n\t\t\tcase LBN_SELCHANGE:\n\n\t\t\t\tEditProp();\n\t\t\t\treturn TRUE; \n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase IDC_E_LIST: \n\t   \n\t\t\tswitch (HIWORD(wParam)) { \n\t\t\t\n\t\t\tcase LBN_SELCHANGE: \n\t\t\t{\n\t\t\t\tint iIndex;\n\t\t\t\teclass_t *pec;\n\t\t\t\t\n\t\t\t\tiIndex = SendMessage(hwndEnt[EntList], LB_GETCURSEL, 0, 0);\t\n\t\t\t\tpec = (eclass_t *)SendMessage(hwndEnt[EntList], LB_GETITEMDATA, \n\t\t\t\t\t\tiIndex, 0); \n\t\t\t\n\t\t\t\tUpdateSel(iIndex, pec);\n\n\t\t\t\treturn TRUE; \n\t\t\t\tbreak; \n\t\t\t}\n\n\t\t\tcase LBN_DBLCLK: \n\t\t\t\tCreateEntity ();\n\t\t\t\tSetFocus (g_qeglobals.d_hwndCamera);\n\t\t\t\tbreak; \n\t\t\t} \n            break; \n\n\n            default: \n              return DefWindowProc( hwndDlg, uMsg, wParam, lParam ); \n        } \n\n\t\treturn 0;\n\t}\n\n    return DefWindowProc (hwndDlg, uMsg, wParam, lParam);\n}\n\n"
  },
  {
    "path": "q3radiant/Win_main.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"stdafx.h\"\n#include \"qe3.h\"\n#include <process.h>\n#include \"mru.h\"\n#include \"entityw.h\"\n#include \"PrefsDlg.h\"\n\nstatic HWND      s_hwndToolbar;\n\nBOOL SaveRegistryInfo(const char *pszName, void *pvBuf, long lSize);\nBOOL LoadRegistryInfo(const char *pszName, void *pvBuf, long *plSize);\n\nstatic HWND CreateMyStatusWindow(HINSTANCE hInst);\nstatic HWND CreateToolBar(HINSTANCE hinst);\n\nextern void WXY_Print( void );\n\n/*\n==============================================================================\n\n  MENU\n\n==============================================================================\n*/\n\nvoid OpenDialog (void);\nvoid SaveAsDialog (bool bRegion);\nqboolean ConfirmModified (void);\nvoid  Select_Ungroup (void);\n\nvoid QE_ExpandBspString (char *bspaction, char *out, char *mapname, bool useTemps)\n{\n\tchar\t*in;\n\tchar\tsrc[2048];\n\tchar\trsh[2048];\n\tchar\tbase[2048];\n\n\tstrcpy(src, mapname);\n\tstrlwr(src);\n\tin = strstr(src, \"maps/\");\n\tif (!in)\n\t{\n\t\tin = strstr(src, \"maps\\\\\");\n\t}\n\tif (in)\n\t{\n\t\tin += 5;\n\t\tstrcpy(base, in);\n\t\tin = base;\n\t\twhile (*in)\n\t\t{\n\t\t\tif (*in == '\\\\')\n\t\t\t{\n\t\t\t\t*in = '/';\n\t\t\t}\n\t\t\tin++;\n\t\t}\n\t}\n\telse\n\t{\n\t\tExtractFileName (mapname, base);\n\t}\n\n  if (useTemps) {\n    CString str;\n    CString strExt = \"map\";\n    if ( strstr(mapname, \".reg\") ) {\n      strExt = \"reg\";\n    }\n    str.Format(\"%s/maps/%i.%s\", ValueForKey(g_qeglobals.d_project_entity, \"remotebasepath\"), ::GetTickCount(), strExt);\n    CopyFile(mapname, str, FALSE);\n\t  sprintf (src, \"-tempname %s %s/maps/%s\", str, ValueForKey(g_qeglobals.d_project_entity, \"remotebasepath\"), base);\n  } else {\n\t  sprintf (src, \"%s/maps/%s\", ValueForKey(g_qeglobals.d_project_entity, \"remotebasepath\"), base);\n  }\n\tstrcpy (rsh, ValueForKey(g_qeglobals.d_project_entity, \"rshcmd\"));\n\n  QE_ConvertDOSToUnixName(src, src);\n\n\tin = ValueForKey( g_qeglobals.d_project_entity, bspaction );\n\twhile (*in)\n\t{\n\t\tif (in[0] == '!')\n\t\t{\n\t\t\tstrcpy (out, rsh);\n\t\t\tout += strlen(rsh);\n\t\t\tin++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (in[0] == '$')\n\t\t{\n\t\t\tstrcpy (out, src);\n\t\t\tout += strlen(src);\n\t\t\tin++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (in[0] == '@')\n\t\t{\n\t\t\t*out++ = '\"';\n\t\t\tin++;\n\t\t\tcontinue;\n\t\t}\n\t\t*out++ = *in++;\n\t}\n\t*out = 0;\n}\n\nvoid FindReplace(CString& strContents, const char* pTag, const char* pValue)\n{\n  if (strcmp(pTag, pValue) == 0)\n    return;\n  for (int nPos = strContents.Find(pTag); nPos >= 0; nPos = strContents.Find(pTag))\n  {\n    int nRightLen = strContents.GetLength() - strlen(pTag) - nPos;\n    CString strLeft = strContents.Left(nPos);\n    CString strRight = strContents.Right(nRightLen);\n    strLeft += pValue;\n    strLeft += strRight;\n    strContents = strLeft;\n  }\n}\n\n\n\nHWND g_hWnd = NULL;\nHANDLE g_hToolThread = NULL;\nCString g_strParams;\n\nUINT ToolThread(LPVOID pParam)\n{\n  char* p = reinterpret_cast<char*>(pParam);\n  if (g_PrefsDlg.m_bPAK)\n    RunTools(p, g_hWnd, g_PrefsDlg.m_strPAKFile);\n  else\n    RunTools(p, g_hWnd, \"\");\n  g_hToolThread = NULL;\n  delete []p;\n  return 0;\n}\n\nvoid ThreadTools(char* p)\n{\n  CWinThread* pThread = AfxBeginThread(ToolThread, reinterpret_cast<LPVOID>(p));\n  g_hToolThread = pThread->m_hThread;\n}\n\nHWND g_hwndFoundIt = NULL;\n\nBOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam) {\n  char buff[1024];\n  const char* p = reinterpret_cast<const char*>(lParam);\n  GetWindowText(hwnd, buff, 1024);\n  if (!strcmpi(p, buff)) {\n    g_hwndFoundIt = hwnd;\n    return 1;\n  }\n  return 1;\n}\n\n\nHWND FindAnyWindow(const char *pTitle) {\n  HWND hwndDesktop = GetDesktopWindow();\n  g_hwndFoundIt = NULL;\n  if ( hwndDesktop ) {\n    EnumChildWindows(hwndDesktop, (WNDENUMPROC)EnumChildProc, reinterpret_cast<LPARAM>(pTitle));\n  }\n  return g_hwndFoundIt;\n}\n\n\nconst UINT wm_AddCommand = RegisterWindowMessage( \"Q3MPC_AddCommand\" );\n\nCTime g_tBegin;\nvoid RunBsp (char *command)\n{\n\tchar\tsys[2048];\n\tchar\tbatpath[2048];\n\tchar\toutputpath[2048];\n\tchar\ttemppath[1024];\n\tchar\tname[2048];\n\tchar\tcWork[2048];\n\tFILE\t*hFile;\n\tBOOL\tret;\n\tPROCESS_INFORMATION ProcessInformation;\n\tSTARTUPINFO\tstartupinfo;\n  HWND hwndPClient = NULL;\n\n  g_hWnd = g_pParentWnd->GetSafeHwnd();\n\tSetInspectorMode(W_CONSOLE);\n  g_tBegin = CTime::GetCurrentTime();\n\n\t\n\tDWORD\tdwExitcode;\n  ret = GetExitCodeProcess (g_hToolThread, &dwExitcode);\n  if (dwExitcode != STILL_ACTIVE)\n    g_hToolThread = NULL;\n\n\tif (bsp_process || g_hToolThread)\n\t{\n\t\tSys_Printf (\"BSP is still going...\\n\");\n\t\treturn;\n\t}\n\n  outputpath[0] = '\\0';\n\tGetTempPath(512, temppath);\n\n  CString strOutFile = temppath;\n  AddSlash(strOutFile);\n  strOutFile += \"junk.txt\";\n\n\tsprintf (outputpath, \" >>%s\\r\\n\", strOutFile);\n\n  strcpy (name, currentmap);\n\tif (region_active)\n\t{\n\t\tMap_SaveFile (name, false);\n\t\tStripExtension (name);\n\t\tstrcat (name, \".reg\");\n\t}\n\n\tMap_SaveFile (name, region_active);\n\n  // FIXME: this code just gets worse and worse\n  CString strPath, strFile;\n\n  char *rsh = ValueForKey(g_qeglobals.d_project_entity, \"rshcmd\");\n  if (rsh == NULL)\n  {\n    ExtractPath_and_Filename(name, strPath, strFile);\n    AddSlash(strPath);\n    BuildShortPathName(strPath, cWork, 1024);\n    strcat(cWork, strFile);\n  }\n  else\n  {\n    strcpy(cWork, name);\n  }\n\n  hwndPClient = FindWindow(NULL, \"Q3Map Process Client\");\n  if ( hwndPClient == NULL ) {\n    hwndPClient = FindAnyWindow(\"Q3Map Process Client\");\n  }\n\n  Sys_Printf(\"Window info for Process Client %i\\n\", reinterpret_cast<int>(hwndPClient));\n\n  bool processServer = (rsh && strlen(rsh) > 0 && hwndPClient);\n\n  QE_ExpandBspString (command, sys, cWork, processServer);\n\n  // if we can find the q3map process server running \n  // we will submit maps to it instead of via createprocess\n  //\n  if (processServer)\n  {\n    CString str;\n    char cBuff[2048];\n    char *pStart = sys;\n    char *pEnd = strstr(pStart, \"&&\");\n    while (pEnd)\n    {\n      int nLen = pEnd-pStart-1;\n      strncpy(cBuff, pStart, nLen);\n      cBuff[nLen] = 0;\n      str = cBuff;\n      FindReplace(str, rsh, \"\");\n      str.TrimLeft(' ');\n      str.TrimRight(' ');\n      ATOM a = GlobalAddAtom(str);\n      PostMessage(hwndPClient, wm_AddCommand, 0, (LPARAM)a);\n      pStart = pEnd+2;\n      pEnd = strstr(pStart, \"&&\");\n    }\n    str = pStart;\n    FindReplace(str, rsh, \"\");\n    str.TrimLeft(' ');\n    str.TrimRight(' ');\n    ATOM a = GlobalAddAtom(str);\n    PostMessage(hwndPClient, wm_AddCommand, 0, (LPARAM)a);\n    Sys_Printf(\"Commands sent to Q3Map Process Client\\n\");\n    return;\n  }\n\n  CString strSys = sys;\n\n  FindReplace(strSys, \"&&\", outputpath);\n  strcpy(sys, strSys);\n  strcat(sys, outputpath);\n\n  if (g_PrefsDlg.m_bInternalBSP)\n  {\n    g_tBegin = CTime::GetCurrentTime();\n    strSys.MakeLower();\n    char* p = new char[strSys.GetLength()+1];\n    strcpy(p, strSys.GetBuffer(0));\n    ThreadTools(p);\n  }\n  else\n  {\n\t  Sys_ClearPrintf ();\n\t  Sys_Printf (\"==================\\nRunning bsp command...\\n\");\n\t  Sys_Printf (\"\\n%s\\n\", sys);\n\n\t  //++timo removed the old way BSP commands .. dumping to junk.txt doesn't work on my win98 box\n\t  // FIXME : will most likely break Quake2 BSP commands, is fitted to a one-lined sys command\n\t  //\n\t  // write qe3bsp.bat\n\t  //\n\n\t  sprintf (batpath, \"%sqe3bsp.bat\", temppath);\n\t  hFile = fopen(batpath, \"w\");\n\t  if (!hFile)\n\t\t  Error (\"Can't write to %s\", batpath);\n\t  fprintf (hFile, sys);\n\t  fclose (hFile);\n\n\t  Pointfile_Delete ();\n\n\t  // delete junk.txt file\n\t  remove(strOutFile);\n\n\t  GetStartupInfo (&startupinfo);\n\n\t  ret = CreateProcess(\n\t\t  batpath,\n\t\t  NULL,\n\t\t  NULL,\n\t\t  NULL,\n\t\t  FALSE,\n\t\t  0,\n\t\t  NULL,\n\t\t  NULL,\n\t\t  &startupinfo,\n\t\t  &ProcessInformation\n\t\t  );\n\n\t  if (!ret)\n\t\t  Error (\"CreateProcess failed\");\n\n\t  bsp_process = ProcessInformation.hProcess;\n\n\t  Sleep (100);\t// give the new process a chance to open it's window\n\n\t  BringWindowToTop( g_qeglobals.d_hwndMain );\t// pop us back on top\n#if 0\n\t  //\n\t  // write qe3bsp.bat\n\t  //\n\t  sprintf (batpath, \"%sqe3bsp.bat\", temppath);\n\t  hFile = fopen(batpath, \"w\");\n\t  if (!hFile)\n\t\t  Error (\"Can't write to %s\", batpath);\n\t  fprintf (hFile, sys);\n\t  fclose (hFile);\n\n\t  //\n\t  // write qe3bsp2.bat\n\t  //\n\t  sprintf (batpath, \"%sqe3bsp2.bat\", temppath);\n\t  hFile = fopen(batpath, \"w\");\n\t  if (!hFile)\n\t\t  Error (\"Can't write to %s\", batpath);\n\t  fprintf (hFile, \"%sqe3bsp.bat > %s\", temppath, outputpath);\n\t  fclose (hFile);\n\n\t  Pointfile_Delete ();\n\n\t  GetStartupInfo (&startupinfo);\n\n\t  ret = CreateProcess(\n      batpath,\t\t// pointer to name of executable module \n      NULL,\t\t\t// pointer to command line string\n      NULL,\t\t\t// pointer to process security attributes \n      NULL,\t\t\t// pointer to thread security attributes \n      FALSE,\t\t\t// handle inheritance flag \n      0 /*DETACHED_PROCESS*/,\t\t// creation flags\n      NULL,\t\t\t// pointer to new environment block \n      NULL,\t\t\t// pointer to current directory name \n      &startupinfo,\t// pointer to STARTUPINFO \n      &ProcessInformation \t// pointer to PROCESS_INFORMATION  \n     );\n\n\t  if (!ret)\n\t\t  Error (\"CreateProcess failed\");\n\n\t  bsp_process = ProcessInformation.hProcess;\n\n\t  Sleep (100);\t// give the new process a chance to open it's window\n\n\t  //BringWindowToTop( g_qeglobals.d_hwndMain );\t// pop us back on top\n\t  //SetFocus (g_qeglobals.d_hwndCamera);\n#endif\n  }\n}\n\nvoid DLLBuildDone()\n{\n  g_hToolThread = NULL;\n  CTime tEnd = CTime::GetCurrentTime();\n  CTimeSpan tElapsed = tEnd - g_tBegin;\n  CString strElapsed;\n  strElapsed.Format(\"Run time was %i hours, %i minutes and %i seconds\", tElapsed.GetHours(), tElapsed.GetMinutes(), tElapsed.GetSeconds());\n\tSys_Printf(strElapsed.GetBuffer(0));\n\tPointfile_Check();\n\n  if (g_PrefsDlg.m_bRunQuake == TRUE)\n  {\n    char cCurDir[1024];\n    GetCurrentDirectory(1024, cCurDir);\n    CString strExePath = g_PrefsDlg.m_strQuake2;\n    CString strOrgPath;\n    CString strOrgFile;\n    ExtractPath_and_Filename(currentmap, strOrgPath, strOrgFile);\n    if (g_PrefsDlg.m_bSetGame == TRUE) // run in place with set game.. don't copy map\n    {\n\t    CString strBasePath = ValueForKey(g_qeglobals.d_project_entity, \"basepath\");\n      strExePath += \" +set game \";\n      strExePath += strBasePath;\n      WinExec(strExePath, SW_SHOW);\n    }\n    else\n    {\n      CString strCopyPath = strExePath;\n      char* pBuffer = strCopyPath.GetBufferSetLength(_MAX_PATH + 1);\n      pBuffer[strCopyPath.ReverseFind('\\\\') + 1] = '\\0';\n      strCopyPath.ReleaseBuffer();\n      SetCurrentDirectory(strCopyPath);\n      CString strOrgPath;\n      CString strOrgFile;\n      ExtractPath_and_Filename(currentmap, strOrgPath, strOrgFile);\n      AddSlash(strCopyPath);\n      FindReplace(strOrgFile, \".map\", \".bsp\");\n      strCopyPath += \"\\\\baseq2\\\\maps\\\\\";\n      strCopyPath += strOrgFile;\n      AddSlash(strOrgPath);\n      strOrgPath += strOrgFile;\n      bool bRun = (strOrgPath.CompareNoCase(strCopyPath) == 0);\n      if (!bRun)\n        bRun = (CopyFile(strOrgPath, strCopyPath, FALSE) == TRUE);\n      if (bRun)\n      {\n        FindReplace(strOrgFile, \".bsp\", \"\");\n        strExePath += \" +map \";\n        strExePath += strOrgFile;\n        WinExec(strExePath, SW_SHOW);\n      }\n    }\n    SetCurrentDirectory(cCurDir);\n  }\n\n}\n\n/*\n=============\nDoColor\n\n=============\n*/\n\nclass CMyColorDialog : public CColorDialog \n{\n  DECLARE_DYNCREATE(CMyColorDialog);\n     // Construction\npublic:\n     CMyColorDialog( COLORREF clrInit = 0, DWORD dwFlags = 0, CWnd*\npParentWnd = NULL );\n     // Statics\nprotected:\n     enum { NCUSTCOLORS = 16 };\n     static COLORREF c_CustColors[NCUSTCOLORS];\n     static COLORREF c_LastCustColors[NCUSTCOLORS];\n     static bool c_NeedToInitCustColors;\nprotected:\n     static void InitCustColors();\n     static void SaveCustColors();\n     // Dialog Data\nprotected:\n     //{{AFX_DATA(CMyColorDialog)\n     //}}AFX_DATA\n     // Overrides\nprotected:\n     // ClassWizard generate virtual function overrides\n     //{{AFX_VIRTUAL(CMyColorDialog)\npublic:\n     virtual int DoModal();\nprotected:\n     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n     //}}AFX_VIRTUAL\n     // Implementation\nprotected:\n     // Generated message map functions\n     //{{AFX_MSG(CMyColorDialog)\n     //}}AFX_MSG\n     DECLARE_MESSAGE_MAP()\n};\n\nIMPLEMENT_DYNCREATE(CMyColorDialog, CColorDialog)\n\nbool CMyColorDialog::c_NeedToInitCustColors = true;\nCOLORREF CMyColorDialog::c_CustColors[];\nCOLORREF CMyColorDialog::c_LastCustColors[];\n\n#define SECTION _T(\"Custom Colors\")\n\nvoid CMyColorDialog::InitCustColors() {\n     for (int i = 0; i < NCUSTCOLORS; i++) {\n          CString entry; entry.Format(\"%d\",i);\n          c_LastCustColors[i] = c_CustColors[i] =\n\t\t::AfxGetApp()->GetProfileInt(SECTION,entry,RGB(255,255,255));\n     }\n     c_NeedToInitCustColors= false;\n}\n\nvoid CMyColorDialog::SaveCustColors() {\n     for (int i = 0; i < NCUSTCOLORS; i++) {\n          if (c_LastCustColors[i] != c_CustColors[i]) {\n               CString entry; entry.Format(\"%d\",i);\n               if (c_CustColors[i] == RGB(255,255,255)) {\n                    ::AfxGetApp()->WriteProfileString(SECTION,entry,NULL);\n               } else {\n                    ::AfxGetApp()->WriteProfileInt(SECTION, entry,c_CustColors[i]);\n               }\n               c_LastCustColors[i] = c_CustColors[i];\n          }\n     }\n}\n\nCMyColorDialog::CMyColorDialog( COLORREF clrInit, DWORD dwFlags, \n\t\tCWnd* pParentWnd) : CColorDialog(clrInit,dwFlags,pParentWnd)\n{\n     //{{AFX_DATA_INIT(CMyColorDialog)\n     //}}AFX_DATA_INIT\n     if (c_NeedToInitCustColors) {\n          InitCustColors();\n     }\n     m_cc.lpCustColors = c_CustColors;\n}\n\nint CMyColorDialog::DoModal() {\n     int code = CColorDialog::DoModal();\n     SaveCustColors();\n     return code;\n}\n\nvoid CMyColorDialog::DoDataExchange(CDataExchange* pDX) {\n     // overridden (calls this base class)\n     CColorDialog::DoDataExchange(pDX);\n     //{{AFX_DATA_MAP(CMyColorDialog)\n     //}}AFX_DATA_MAP\n}\n\nBEGIN_MESSAGE_MAP(CMyColorDialog, CColorDialog)\n//{{AFX_MSG_MAP(CMyColorDialog)\n//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\nvoid DoNewColor(int* i1, int* i2, int* i3)\n{\n\tCOLORREF cr = (*i1) +\n                ((*i2) <<8) +\n\t\t            ((*i3) <<16);\n  CMyColorDialog dlg(cr, CC_FULLOPEN | CC_RGBINIT);\n  if (dlg.DoModal() == IDOK)\n  {\n\t  *i1 = (dlg.m_cc.rgbResult & 255);\n\t  *i2 = ((dlg.m_cc.rgbResult >> 8) & 255);\n\t  *i3 = ((dlg.m_cc.rgbResult >> 16) & 255);\n  }\n\n}\n\n\nqboolean DoColor(int iIndex)\n{\n\n\tCOLORREF cr = (int)(g_qeglobals.d_savedinfo.colors[iIndex][0]*255) +\n                (((int)(g_qeglobals.d_savedinfo.colors[iIndex][1]*255))<<8) +\n\t\t            (((int)(g_qeglobals.d_savedinfo.colors[iIndex][2]*255))<<16);\n  CMyColorDialog dlg(cr, CC_FULLOPEN | CC_RGBINIT);\n  if (dlg.DoModal() == IDOK)\n  {\n\t  g_qeglobals.d_savedinfo.colors[iIndex][0] = (dlg.m_cc.rgbResult&255)/255.0;\n\t  g_qeglobals.d_savedinfo.colors[iIndex][1] = ((dlg.m_cc.rgbResult>>8)&255)/255.0;\n\t  g_qeglobals.d_savedinfo.colors[iIndex][2] = ((dlg.m_cc.rgbResult>>16)&255)/255.0;\n\n\t  /* \n\t  ** scale colors so that at least one component is at 1.0F \n\t  ** if this is meant to select an entity color\n\t  */\n\t  if ( iIndex == COLOR_ENTITY )\n\t  {\n\t\t  float largest = 0.0F;\n\n\t\t  if ( g_qeglobals.d_savedinfo.colors[iIndex][0] > largest )\n\t\t\t  largest = g_qeglobals.d_savedinfo.colors[iIndex][0];\n\t\t  if ( g_qeglobals.d_savedinfo.colors[iIndex][1] > largest )\n\t\t\t  largest = g_qeglobals.d_savedinfo.colors[iIndex][1];\n\t\t  if ( g_qeglobals.d_savedinfo.colors[iIndex][2] > largest )\n\t\t\t  largest = g_qeglobals.d_savedinfo.colors[iIndex][2];\n\n\t\t  if ( largest == 0.0F )\n\t\t  {\n\t\t\t  g_qeglobals.d_savedinfo.colors[iIndex][0] = 1.0F;\n\t\t\t  g_qeglobals.d_savedinfo.colors[iIndex][1] = 1.0F;\n\t\t\t  g_qeglobals.d_savedinfo.colors[iIndex][2] = 1.0F;\n\t\t  }\n\t\t  else\n\t\t  {\n\t\t\t  float scaler = 1.0F / largest;\n\n\t\t\t  g_qeglobals.d_savedinfo.colors[iIndex][0] *= scaler;\n\t\t\t  g_qeglobals.d_savedinfo.colors[iIndex][1] *= scaler;\n\t\t\t  g_qeglobals.d_savedinfo.colors[iIndex][2] *= scaler;\n\t\t  }\n\t  }\n\n\t  Sys_UpdateWindows (W_ALL);\n\t  return true;\n  }\n  else return false;\n\n}\n\n\n/* Copied from MSDN */\n\nBOOL DoMru(HWND hWnd,WORD wId)\n{\n\tchar szFileName[128];\n\tOFSTRUCT of;\n\tBOOL fExist;\n\n\tGetMenuItem(g_qeglobals.d_lpMruMenu, wId, TRUE, szFileName, sizeof(szFileName));\n\n\t// Test if the file exists.\n\n\tfExist = OpenFile(szFileName ,&of,OF_EXIST) != HFILE_ERROR;\n\n\tif (fExist) {\n\n\t\t// Place the file on the top of MRU.\n\t\tAddNewItem(g_qeglobals.d_lpMruMenu,(LPSTR)szFileName);\n\n\t\t// Now perform opening this file !!!\n\t\tMap_LoadFile (szFileName);\t\n\t}\n\telse\n\t\t// Remove the file on MRU.\n\t\tDelMenuItem(g_qeglobals.d_lpMruMenu,wId,TRUE);\n\n\t// Refresh the File menu.\n\tPlaceMenuMRUItem(g_qeglobals.d_lpMruMenu,GetSubMenu(GetMenu(hWnd),0),\n\t\t\tID_FILE_EXIT);\n\n\treturn fExist;\n}\n\n\n\n/*\n==============\nMain_Create\n==============\n*/\n\nvoid MFCCreate (HINSTANCE hInstance)\n{\n\tHMENU hMenu = NULL;\n\tint i = sizeof(g_qeglobals.d_savedinfo);\n  long l = i;\n\n  g_qeglobals.d_savedinfo.exclude |= (EXCLUDE_HINT | EXCLUDE_CLIP);\n\tLoadRegistryInfo(\"SavedInfo\", &g_qeglobals.d_savedinfo, &l);\n\n  int nOldSize = g_qeglobals.d_savedinfo.iSize;\n\tif (g_qeglobals.d_savedinfo.iSize != sizeof(g_qeglobals.d_savedinfo))\n\t{\n\t\t// fill in new defaults\n\t\tg_qeglobals.d_savedinfo.iSize = sizeof(g_qeglobals.d_savedinfo);\n\t\tg_qeglobals.d_savedinfo.fGamma = 1.0;\n\t\tg_qeglobals.d_savedinfo.iTexMenu = ID_VIEW_BILINEARMIPMAP;\n    g_qeglobals.d_savedinfo.m_nTextureTweak = 1;\n  \n\t\t//g_qeglobals.d_savedinfo.exclude = INCLUDE_EASY | INCLUDE_NORMAL | INCLUDE_HARD | INCLUDE_DEATHMATCH;\n\t\tg_qeglobals.d_savedinfo.show_coordinates = true;\n\t\tg_qeglobals.d_savedinfo.show_names       = false;\n\n\t\tfor (i=0 ; i<3 ; i++)\n\t\t{\n\t\t\tg_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][i] = 0.25;\n\t\t\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][i] = 1.0;\n\t\t\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR][i] = 0.75;\n\t\t\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][i] = 0.5;\n\t\t\tg_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][i] = 0.25;\n\t\t}\n\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][0] = 0.0;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][1] = 0.0;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][2] = 1.0;\n\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][0] = 0.0;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][1] = 0.0;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][2] = 0.0;\n\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][0] = 1.0;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][1] = 0.0;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][2] = 0.0;\n\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][0] = 0.0;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][1] = 0.0;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][2] = 1.0;\n\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][0] = 0.0;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][1] = 0.0;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][2] = 0.0;\n\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][0] = 0.5;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][1] = 0.0;\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][2] = 0.75;\n\n\n    // old size was smaller, reload original prefs\n    if (nOldSize < sizeof(g_qeglobals.d_savedinfo))\n    {\n      long l = nOldSize;\n\t    LoadRegistryInfo(\"SavedInfo\", &g_qeglobals.d_savedinfo, &l);\n    }\n\n\t}\n\tif ( ( hMenu = GetMenu( g_qeglobals.d_hwndMain ) ) != 0 )\n\t{\n\t\t// by default all of these are checked because that's how they're defined in the menu editor\n\t\tif ( !g_qeglobals.d_savedinfo.show_names )\n\t\t\tCheckMenuItem( hMenu, ID_VIEW_SHOWNAMES, MF_BYCOMMAND | MF_UNCHECKED );\n\t\tif ( !g_qeglobals.d_savedinfo.show_coordinates )\n\t\t\tCheckMenuItem( hMenu, ID_VIEW_SHOWCOORDINATES, MF_BYCOMMAND | MF_UNCHECKED );\n\n\t\tif ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_LIGHTS )\n\t\t\tCheckMenuItem( hMenu, ID_VIEW_SHOWLIGHTS, MF_BYCOMMAND | MF_UNCHECKED );\n\t\tif ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_ENT )\n\t\t\tCheckMenuItem( hMenu, ID_VIEW_ENTITY, MF_BYCOMMAND | MF_UNCHECKED );\n\t\tif ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_PATHS )\n\t\t\tCheckMenuItem( hMenu, ID_VIEW_SHOWPATH, MF_BYCOMMAND | MF_UNCHECKED );\n\t\tif ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_WATER )\n\t\t\tCheckMenuItem( hMenu, ID_VIEW_SHOWWATER, MF_BYCOMMAND | MF_UNCHECKED );\n\t\tif ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_WORLD )\n\t\t\tCheckMenuItem( hMenu, ID_VIEW_SHOWWORLD, MF_BYCOMMAND | MF_UNCHECKED );\n\t\tif ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_CLIP )\n\t\t\tCheckMenuItem( hMenu, ID_VIEW_SHOWCLIP, MF_BYCOMMAND | MF_UNCHECKED );\n\t\tif ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_HINT )\n\t\t\tCheckMenuItem( hMenu, ID_VIEW_SHOWHINT, MF_BYCOMMAND | MF_UNCHECKED );\n\t\tif ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_CAULK )\n\t\t\tCheckMenuItem( hMenu, ID_VIEW_SHOWCAULK, MF_BYCOMMAND | MF_UNCHECKED );\n\t}\n\n}\n\n\n/*\n=============================================================\n\nREGISTRY INFO\n\n=============================================================\n*/\n\nBOOL SaveRegistryInfo(const char *pszName, void *pvBuf, long lSize)\n{\n\tLONG lres;\n\tDWORD dwDisp;\n\tHKEY  hKeyId;\n\n\tif (g_qeglobals.use_ini)\n\t{\n\t\tlres = RegCreateKeyEx(HKEY_CURRENT_USER, g_qeglobals.use_ini_registry, 0, NULL,\n\t\t\tREG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKeyId, &dwDisp);\n\t}\n\telse\n\t{\n\t\tlres = RegCreateKeyEx(HKEY_CURRENT_USER, \"Software\\\\Q3Radiant\\\\Q3Radiant\", 0, NULL, \n\t\t\t\tREG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKeyId, &dwDisp);\n\t}\n    \n\tif (lres != ERROR_SUCCESS)\n\t\treturn FALSE;\n\n\tlres = RegSetValueEx(hKeyId, pszName, 0, REG_BINARY, (unsigned char*)pvBuf, lSize);\n    \n\tRegCloseKey(hKeyId);\n\n\tif (lres != ERROR_SUCCESS)\n\t\treturn FALSE;\n\n\treturn TRUE;\n}\n\nBOOL LoadRegistryInfo(const char *pszName, void *pvBuf, long *plSize)\n{\n\tHKEY  hKey;\n\tlong lres, lType, lSize;\n\n\tif (plSize == NULL)\n\t\tplSize = &lSize;\n\n\tif (g_qeglobals.use_ini)\n\t{\n\t\tlres = RegOpenKeyEx(HKEY_CURRENT_USER, g_qeglobals.use_ini_registry, 0, KEY_READ, &hKey);\n\t}\n\telse\n\t{\n\t\tlres = RegOpenKeyEx(HKEY_CURRENT_USER, \"Software\\\\Q3Radiant\\\\Q3Radiant\", 0, KEY_READ, &hKey);\n  }\n\n\tlres = RegQueryValueEx(hKey, pszName, NULL, (unsigned long*)&lType, (unsigned char*)pvBuf, (unsigned long*)plSize);\n\n\tRegCloseKey(hKey);\n\n\tif (lres != ERROR_SUCCESS)\n\t{\n#ifdef _DEBUG\n\t\tchar Message[1024];\n\t\tFormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, 0, lres, 0, &(Message[0]), 1024, NULL );\n\t\tSys_Printf( \"WARNING: RegQueryValueEx failed in LoadRegistryInfo for %s : %s\", pszName, Message );\n#endif\n\t\treturn FALSE;\n\t}\n\n\treturn TRUE;\n}\n\nBOOL SaveWindowState(HWND hWnd, const char *pszName)\n{\n\tRECT rc;\n\tGetWindowRect(hWnd, &rc);\n\tif (hWnd != g_qeglobals.d_hwndMain) // && g_pParentWnd->CurrentStyle() == QR_QE4)\n  {\n    if (::GetParent(hWnd) != g_qeglobals.d_hwndMain)\n    {\n      ::SetParent(hWnd, g_qeglobals.d_hwndMain);\n    }\n\t\tMapWindowPoints(NULL, g_qeglobals.d_hwndMain, (POINT *)&rc, 2);\n\n  }\n\tBOOL b = SaveRegistryInfo(pszName, &rc, sizeof(rc));\n  return b;\n}\n\n\nBOOL LoadWindowState(HWND hWnd, const char *pszName)\n{\n\tRECT rc;\n  LONG lSize = sizeof(rc);\n\n\tif (LoadRegistryInfo(pszName, &rc, &lSize))\n\t{\n\t\tif (rc.left < 0)\n\t\t\trc.left = 0;\n\t\tif (rc.top < 0)\n\t\t\trc.top = 0;\n\t\tif (rc.right < rc.left + 16)\n\t\t\trc.right = rc.left + 16;\n\t\tif (rc.bottom < rc.top + 16)\n\t\t\trc.bottom = rc.top + 16;\n\n\t\tMoveWindow(hWnd, rc.left, rc.top, rc.right - rc.left, \n\t\t\t\trc.bottom - rc.top, FALSE);\n\t\treturn TRUE;\n\t}\n\n\treturn FALSE;\n}\n\n/*\n===============================================================\n\n  STATUS WINDOW\n\n===============================================================\n*/\n\nvoid Sys_UpdateStatusBar( void )\n{\n\textern int   g_numbrushes, g_numentities;\n\n\tchar numbrushbuffer[100]=\"\";\n\n\tsprintf( numbrushbuffer, \"Brushes: %d Entities: %d\", g_numbrushes, g_numentities );\n  g_pParentWnd->SetStatusText(2, numbrushbuffer);\n\t//Sys_Status( numbrushbuffer, 2 );\n}\n\nvoid Sys_Status(const char *psz, int part )\n{\n\tSendMessage(g_qeglobals.d_hwndStatus, SB_SETTEXT, part, (LPARAM)psz);\n}\n\nstatic HWND CreateMyStatusWindow(HINSTANCE hInst)\n{\n\tHWND hWnd;\n\tint partsize[3] = { 300, 1100, -1 };\n\n\thWnd = CreateWindowEx( WS_EX_TOPMOST, // no extended styles\n            STATUSCLASSNAME,                 // status bar\n            \"\",                              // no text \n            WS_CHILD | WS_BORDER | WS_VISIBLE,  // styles\n            -100, -100, 10, 10,              // x, y, cx, cy\n            g_qeglobals.d_hwndMain,          // parent window\n            (HMENU)100,                      // window ID\n            hInst,                           // instance\n            NULL);\t\t\t\t\t\t\t // window data\n\n\tSendMessage( hWnd, SB_SETPARTS, 3, ( long ) partsize );\n    \n\treturn hWnd;\n}\n\n//==============================================================\n\n#define NUMBUTTONS 15\nHWND CreateToolBar(HINSTANCE hinst)\n{ \n    HWND hwndTB; \n    TBADDBITMAP tbab; \n    TBBUTTON tbb[NUMBUTTONS]; \n    \n     // Ensure that the common control DLL is loaded. \n\n    InitCommonControls(); \n \n    // Create a toolbar that the user can customize and that has a \n    // tooltip associated with it. \n\n    hwndTB = CreateWindowEx(0, TOOLBARCLASSNAME, (LPSTR) NULL, \n        WS_CHILD | TBSTYLE_TOOLTIPS | CCS_ADJUSTABLE | WS_BORDER, \n        0, 0, 0, 0, g_qeglobals.d_hwndMain, (HMENU) IDR_TOOLBAR1, hinst, NULL); \n \n    // Send the TB_BUTTONSTRUCTSIZE message, which is required for \n    // backward compatibility. \n\n    SendMessage(hwndTB, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);\n \n    // Add the bitmap containing button images to the toolbar. \n\n    tbab.hInst = hinst; \n    tbab.nID   = IDR_TOOLBAR1; \n    SendMessage(hwndTB, TB_ADDBITMAP, (WPARAM)NUMBUTTONS, (WPARAM) &tbab); \n \n    // Fill the TBBUTTON array with button information, and add the \n    // buttons to the toolbar. \n\n    tbb[0].iBitmap = 0; \n    tbb[0].idCommand = ID_BRUSH_FLIPX; \n    tbb[0].fsState = TBSTATE_ENABLED; \n    tbb[0].fsStyle = TBSTYLE_BUTTON; \n    tbb[0].dwData = 0; \n    tbb[0].iString = 0; \n \n    tbb[1].iBitmap = 2; \n    tbb[1].idCommand = ID_BRUSH_FLIPY; \n    tbb[1].fsState = TBSTATE_ENABLED; \n    tbb[1].fsStyle = TBSTYLE_BUTTON; \n    tbb[1].dwData = 0; \n    tbb[1].iString = 0; \n \n    tbb[2].iBitmap = 4; \n    tbb[2].idCommand = ID_BRUSH_FLIPZ; \n    tbb[2].fsState = TBSTATE_ENABLED;\n    tbb[2].fsStyle = TBSTYLE_BUTTON; \n    tbb[2].dwData = 0; \n    tbb[2].iString = 0; \n \n    tbb[3].iBitmap = 1; \n    tbb[3].idCommand = ID_BRUSH_ROTATEX; \n    tbb[3].fsState = TBSTATE_ENABLED; \n    tbb[3].fsStyle = TBSTYLE_BUTTON; \n    tbb[3].dwData = 0; \n    tbb[3].iString = 0; \n \n    tbb[4].iBitmap = 3; \n    tbb[4].idCommand = ID_BRUSH_ROTATEY; \n    tbb[4].fsState = TBSTATE_ENABLED; \n    tbb[4].fsStyle = TBSTYLE_BUTTON; \n    tbb[4].dwData = 0; \n    tbb[4].iString = 0; \n\n    tbb[5].iBitmap = 5; \n    tbb[5].idCommand = ID_BRUSH_ROTATEZ; \n    tbb[5].fsState = TBSTATE_ENABLED; \n    tbb[5].fsStyle = TBSTYLE_BUTTON; \n    tbb[5].dwData = 0; \n    tbb[5].iString = 0; \n\n    tbb[6].iBitmap = 6; \n    tbb[6].idCommand = ID_SELECTION_SELECTCOMPLETETALL; \n    tbb[6].fsState = TBSTATE_ENABLED; \n    tbb[6].fsStyle = TBSTYLE_BUTTON; \n    tbb[6].dwData = 0; \n    tbb[6].iString = 0; \n\n    tbb[7].iBitmap = 7; \n    tbb[7].idCommand = ID_SELECTION_SELECTTOUCHING; \n    tbb[7].fsState = TBSTATE_ENABLED; \n    tbb[7].fsStyle = TBSTYLE_BUTTON; \n    tbb[7].dwData = 0; \n    tbb[7].iString = 0; \n\n    tbb[8].iBitmap = 8; \n    tbb[8].idCommand = ID_SELECTION_SELECTPARTIALTALL; \n    tbb[8].fsState = TBSTATE_ENABLED; \n    tbb[8].fsStyle = TBSTYLE_BUTTON; \n    tbb[8].dwData = 0; \n    tbb[8].iString = 0; \n\n\n    tbb[9].iBitmap = 9; \n    tbb[9].idCommand = ID_SELECTION_SELECTINSIDE; \n    tbb[9].fsState = TBSTATE_ENABLED; \n    tbb[9].fsStyle = TBSTYLE_BUTTON; \n    tbb[9].dwData = 0; \n    tbb[9].iString = 0; \n\n    tbb[10].iBitmap = 10; \n    tbb[10].idCommand = ID_SELECTION_CSGSUBTRACT; \n    tbb[10].fsState = TBSTATE_ENABLED; \n    tbb[10].fsStyle = TBSTYLE_BUTTON; \n    tbb[10].dwData = 0; \n    tbb[10].iString = 0; \n\n\n    tbb[11].iBitmap = 11;\n    tbb[11].idCommand = ID_SELECTION_MAKEHOLLOW; \n    tbb[11].fsState = TBSTATE_ENABLED; \n    tbb[11].fsStyle = TBSTYLE_BUTTON; \n    tbb[11].dwData = 0; \n    tbb[11].iString = 0; \n\n    tbb[12].iBitmap = 12;\n    tbb[12].idCommand = ID_TEXTURES_WIREFRAME; \n    tbb[12].fsState = TBSTATE_ENABLED; \n    tbb[12].fsStyle = TBSTYLE_BUTTON; \n    tbb[12].dwData = 0; \n    tbb[12].iString = 0; \n\n    tbb[13].iBitmap = 13;\n    tbb[13].idCommand = ID_TEXTURES_FLATSHADE; \n    tbb[13].fsState = TBSTATE_ENABLED; \n    tbb[13].fsStyle = TBSTYLE_BUTTON; \n    tbb[13].dwData = 0; \n    tbb[13].iString = 0; \n\n    tbb[14].iBitmap = 14;\n    tbb[14].idCommand = ID_VIEW_TRILINEAR; \n    tbb[14].fsState = TBSTATE_ENABLED; \n    tbb[14].fsStyle = TBSTYLE_BUTTON; \n    tbb[14].dwData = 0; \n    tbb[14].iString = 0; \n\n    SendMessage(hwndTB, TB_ADDBUTTONS, (WPARAM)NUMBUTTONS,\n        (LPARAM) (LPTBBUTTON) &tbb); \n \n    ShowWindow(hwndTB, SW_SHOW); \n\n    return hwndTB; \n} \n\n"
  },
  {
    "path": "q3radiant/Winding.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n\n#include \"stdafx.h\"\n#include <assert.h>\n#include \"qe3.h\"\n#include \"winding.h\"\n\n#define\tBOGUS_RANGE\t18000\n\n/*\n=============\nPlane_Equal\n=============\n*/\n#define\tNORMAL_EPSILON\t0.0001\n#define\tDIST_EPSILON\t0.02\n\nint Plane_Equal(plane_t *a, plane_t *b, int flip)\n{\n\tvec3_t normal;\n\tfloat dist;\n\n\tif (flip) {\n\t\tnormal[0] = - b->normal[0];\n\t\tnormal[1] = - b->normal[1];\n\t\tnormal[2] = - b->normal[2];\n\t\tdist = - b->dist;\n\t}\n\telse {\n\t\tnormal[0] = b->normal[0];\n\t\tnormal[1] = b->normal[1];\n\t\tnormal[2] = b->normal[2];\n\t\tdist = b->dist;\n\t}\n\tif (\n\t   fabs(a->normal[0] - normal[0]) < NORMAL_EPSILON\n\t&& fabs(a->normal[1] - normal[1]) < NORMAL_EPSILON\n\t&& fabs(a->normal[2] - normal[2]) < NORMAL_EPSILON\n\t&& fabs(a->dist - dist) < DIST_EPSILON )\n\t\treturn true;\n\treturn false;\n}\n\n/*\n============\nPlane_FromPoints\n============\n*/\nint Plane_FromPoints(vec3_t p1, vec3_t p2, vec3_t p3, plane_t *plane)\n{\n\tvec3_t v1, v2;\n\n\tVectorSubtract(p2, p1, v1);\n\tVectorSubtract(p3, p1, v2);\n\t//CrossProduct(v2, v1, plane->normal);\n\tCrossProduct(v1, v2, plane->normal);\n\tif (VectorNormalize(plane->normal) < 0.1) return false;\n\tplane->dist = DotProduct(p1, plane->normal);\n\treturn true;\n}\n\n/*\n=================\nPoint_Equal\n=================\n*/\nint Point_Equal(vec3_t p1, vec3_t p2, float epsilon)\n{\n\tint i;\n\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tif (fabs(p1[i] - p2[i]) > epsilon) return false;\n\t}\n\treturn true;\n}\n\n\n/*\n=================\nWinding_BaseForPlane\n=================\n*/\nwinding_t *Winding_BaseForPlane (plane_t *p)\n{\n\tint\t\ti, x;\n\tvec_t\tmax, v;\n\tvec3_t\torg, vright, vup;\n\twinding_t\t*w;\n\t\n\t// find the major axis\n\n\tmax = -BOGUS_RANGE;\n\tx = -1;\n\tfor (i=0 ; i<3; i++)\n\t{\n\t\tv = fabs(p->normal[i]);\n\t\tif (v > max)\n\t\t{\n\t\t\tx = i;\n\t\t\tmax = v;\n\t\t}\n\t}\n\tif (x==-1)\n\t\tError (\"Winding_BaseForPlane: no axis found\");\n\t\t\n\tVectorCopy (vec3_origin, vup);\t\n\tswitch (x)\n\t{\n\tcase 0:\n\tcase 1:\n\t\tvup[2] = 1;\n\t\tbreak;\t\t\n\tcase 2:\n\t\tvup[0] = 1;\n\t\tbreak;\t\t\n\t}\n\n\n\tv = DotProduct (vup, p->normal);\n\tVectorMA (vup, -v, p->normal, vup);\n\tVectorNormalize (vup);\n\t\t\n\tVectorScale (p->normal, p->dist, org);\n\t\n\tCrossProduct (vup, p->normal, vright);\n\t\n\tVectorScale (vup, BOGUS_RANGE, vup);\n\tVectorScale (vright, BOGUS_RANGE, vright);\n\n\t// project a really big\taxis aligned box onto the plane\n\tw = Winding_Alloc (4);\n\t\n\tVectorSubtract (org, vright, w->points[0]);\n\tVectorAdd (w->points[0], vup, w->points[0]);\n\t\n\tVectorAdd (org, vright, w->points[1]);\n\tVectorAdd (w->points[1], vup, w->points[1]);\n\t\n\tVectorAdd (org, vright, w->points[2]);\n\tVectorSubtract (w->points[2], vup, w->points[2]);\n\t\n\tVectorSubtract (org, vright, w->points[3]);\n\tVectorSubtract (w->points[3], vup, w->points[3]);\n\t\n\tw->numpoints = 4;\n\t\n\treturn w;\t\n}\n\n/*\n==================\nWinding_Alloc\n==================\n*/\nwinding_t *Winding_Alloc (int points)\n{\n\twinding_t\t*w;\n\tint\t\t\tsize;\n\t\n\tif (points > MAX_POINTS_ON_WINDING)\n\t\tError (\"Winding_Alloc: %i points\", points);\n\t\n\tsize = (int)((winding_t *)0)->points[points];\n\tw = (winding_t*) malloc (size);\n\tmemset (w, 0, size);\n\tw->maxpoints = points;\n\t\n\treturn w;\n}\n\n\nvoid Winding_Free (winding_t *w)\n{\n\tfree(w);\n}\n\n\n/*\n==================\nWinding_Clone\n==================\n*/\nwinding_t *Winding_Clone(winding_t *w)\n{\n\tint\t\t\tsize;\n\twinding_t\t*c;\n\t\n\tsize = (int)((winding_t *)0)->points[w->numpoints];\n\tc = (winding_t*)qmalloc (size);\n\tmemcpy (c, w, size);\n\treturn c;\n}\n\n/*\n==================\nReverseWinding\n==================\n*/\nwinding_t *Winding_Reverse(winding_t *w)\n{\n\tint\t\t\ti;\n\twinding_t\t*c;\n\n\tc = Winding_Alloc(w->numpoints);\n\tfor (i = 0; i < w->numpoints; i++)\n\t{\n\t\tVectorCopy (w->points[w->numpoints-1-i], c->points[i]);\n\t}\n\tc->numpoints = w->numpoints;\n\treturn c;\n}\n\n\n/*\n==============\nWinding_RemovePoint\n==============\n*/\nvoid Winding_RemovePoint(winding_t *w, int point)\n{\n\tif (point < 0 || point >= w->numpoints)\n\t\tError(\"Winding_RemovePoint: point out of range\");\n\n\tif (point < w->numpoints-1)\n\t{\n\t\tmemmove(&w->points[point], &w->points[point+1], (int)((winding_t *)0)->points[w->numpoints - point - 1]);\n\t}\n\tw->numpoints--;\n}\n\n/*\n=============\nWinding_InsertPoint\n=============\n*/\nwinding_t *Winding_InsertPoint(winding_t *w, vec3_t point, int spot)\n{\n\tint i, j;\n\twinding_t *neww;\n\n\tif (spot > w->numpoints)\n\t{\n\t\tError(\"Winding_InsertPoint: spot > w->numpoints\");\n\t} //end if\n\tif (spot < 0)\n\t{\n\t\tError(\"Winding_InsertPoint: spot < 0\");\n\t} //end if\n\tneww = Winding_Alloc(w->numpoints + 1);\n\tneww->numpoints = w->numpoints + 1;\n\tfor (i = 0, j = 0; i < neww->numpoints; i++)\n\t{\n\t\tif (i == spot)\n\t\t{\n\t\t\tVectorCopy(point, neww->points[i]);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVectorCopy(w->points[j], neww->points[i]);\n\t\t\tj++;\n\t\t}\n\t}\n\treturn neww;\n}\n\n/*\n==============\nWinding_IsTiny\n==============\n*/\n#define\tEDGE_LENGTH\t0.2\n\nint Winding_IsTiny (winding_t *w)\n{\n\tint\t\ti, j;\n\tvec_t\tlen;\n\tvec3_t\tdelta;\n\tint\t\tedges;\n\n\tedges = 0;\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tj = i == w->numpoints - 1 ? 0 : i+1;\n\t\tVectorSubtract (w->points[j], w->points[i], delta);\n\t\tlen = VectorLength (delta);\n\t\tif (len > EDGE_LENGTH)\n\t\t{\n\t\t\tif (++edges == 3)\n\t\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/*\n==============\nWinding_IsHuge\n==============\n*/\nint Winding_IsHuge(winding_t *w)\n{\n\tint\t\ti, j;\n\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t\tif (w->points[i][j] < -BOGUS_RANGE+1 || w->points[i][j] > BOGUS_RANGE-1)\n\t\t\t\treturn true;\n\t}\n\treturn false;\n}\n\n/*\n=============\nWinding_PlanesConcave\n=============\n*/\n#define WCONVEX_EPSILON\t\t0.2\n\nint Winding_PlanesConcave(winding_t *w1, winding_t *w2,\n\t\t\t\t\t\t\t vec3_t normal1, vec3_t normal2,\n\t\t\t\t\t\t\t float dist1, float dist2)\n{\n\tint i;\n\n\tif (!w1 || !w2) return false;\n\n\t// check if one of the points of winding 1 is at the back of the plane of winding 2\n\tfor (i = 0; i < w1->numpoints; i++)\n\t{\n\t\tif (DotProduct(normal2, w1->points[i]) - dist2 > WCONVEX_EPSILON) return true;\n\t}\n\t// check if one of the points of winding 2 is at the back of the plane of winding 1\n\tfor (i = 0; i < w2->numpoints; i++)\n\t{\n\t\tif (DotProduct(normal1, w2->points[i]) - dist1 > WCONVEX_EPSILON) return true;\n\t}\n\n\treturn false;\n}\n\n/*\n==================\nWinding_Clip\n\nClips the winding to the plane, returning the new winding on the positive side\nFrees the input winding.\nIf keepon is true, an exactly on-plane winding will be saved, otherwise\nit will be clipped away.\n==================\n*/\nwinding_t *Winding_Clip (winding_t *in, plane_t *split, qboolean keepon)\n{\n\tvec_t\tdists[MAX_POINTS_ON_WINDING];\n\tint\t\tsides[MAX_POINTS_ON_WINDING];\n\tint\t\tcounts[3];\n\tvec_t\tdot;\n\tint\t\ti, j;\n\tvec_t\t*p1, *p2;\n\tvec3_t\tmid;\n\twinding_t\t*neww;\n\tint\t\tmaxpts;\n\t\n\tcounts[0] = counts[1] = counts[2] = 0;\n\n\t// determine sides for each point\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tdot = DotProduct (in->points[i], split->normal);\n\t\tdot -= split->dist;\n\t\tdists[i] = dot;\n\t\tif (dot > ON_EPSILON)\n\t\t\tsides[i] = SIDE_FRONT;\n\t\telse if (dot < -ON_EPSILON)\n\t\t\tsides[i] = SIDE_BACK;\n\t\telse\n\t\t{\n\t\t\tsides[i] = SIDE_ON;\n\t\t}\n\t\tcounts[sides[i]]++;\n\t}\n\tsides[i] = sides[0];\n\tdists[i] = dists[0];\n\t\n\tif (keepon && !counts[0] && !counts[1])\n\t\treturn in;\n\t\t\n\tif (!counts[0])\n\t{\n\t\tWinding_Free (in);\n\t\treturn NULL;\n\t}\n\tif (!counts[1])\n\t\treturn in;\n\t\n\tmaxpts = in->numpoints+4;\t// can't use counts[0]+2 because\n\t\t\t\t\t\t\t\t// of fp grouping errors\n\tneww = Winding_Alloc (maxpts);\n\t\t\n\tfor (i=0 ; i<in->numpoints ; i++)\n\t{\n\t\tp1 = in->points[i];\n\t\t\n\t\tif (sides[i] == SIDE_ON)\n\t\t{\n\t\t\tVectorCopy (p1, neww->points[neww->numpoints]);\n\t\t\tneww->numpoints++;\n\t\t\tcontinue;\n\t\t}\n\t\n\t\tif (sides[i] == SIDE_FRONT)\n\t\t{\n\t\t\tVectorCopy (p1, neww->points[neww->numpoints]);\n\t\t\tneww->numpoints++;\n\t\t}\n\t\t\n\t\tif (sides[i+1] == SIDE_ON || sides[i+1] == sides[i])\n\t\t\tcontinue;\n\t\t\t\n\t\t// generate a split point\n\t\tp2 = in->points[(i+1)%in->numpoints];\n\t\t\n\t\tdot = dists[i] / (dists[i]-dists[i+1]);\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\t// avoid round off error when possible\n\t\t\tif (split->normal[j] == 1)\n\t\t\t\tmid[j] = split->dist;\n\t\t\telse if (split->normal[j] == -1)\n\t\t\t\tmid[j] = -split->dist;\n\t\t\telse\n\t\t\t\tmid[j] = p1[j] + dot*(p2[j]-p1[j]);\n\t\t}\n\t\t\t\n\t\tVectorCopy (mid, neww->points[neww->numpoints]);\n\t\tneww->numpoints++;\n\t}\n\t\n\tif (neww->numpoints > maxpts)\n\t\tError (\"Winding_Clip: points exceeded estimate\");\n\t\t\n\t// free the original winding\n\tWinding_Free (in);\n\t\n\treturn neww;\n}\n\n/*\n=============\nWinding_SplitEpsilon\n\n  split the input winding with the plane\n  the input winding stays untouched\n=============\n*/\nvoid Winding_SplitEpsilon (winding_t *in, vec3_t normal, double dist, \n\t\t\t\tvec_t epsilon, winding_t **front, winding_t **back)\n{\n\tvec_t\tdists[MAX_POINTS_ON_WINDING+4];\n\tint\t\tsides[MAX_POINTS_ON_WINDING+4];\n\tint\t\tcounts[3];\n\tvec_t\tdot;\n\tint\t\ti, j;\n\tvec_t\t*p1, *p2;\n\tvec3_t\tmid;\n\twinding_t\t*f, *b;\n\tint\t\tmaxpts;\n\t\n\tcounts[0] = counts[1] = counts[2] = 0;\n\n\t// determine sides for each point\n\tfor (i = 0; i < in->numpoints; i++)\n\t{\n\t\tdot = DotProduct (in->points[i], normal);\n\t\tdot -= dist;\n\t\tdists[i] = dot;\n\t\tif (dot > epsilon)\n\t\t\tsides[i] = SIDE_FRONT;\n\t\telse if (dot < -epsilon)\n\t\t\tsides[i] = SIDE_BACK;\n\t\telse\n\t\t{\n\t\t\tsides[i] = SIDE_ON;\n\t\t}\n\t\tcounts[sides[i]]++;\n\t}\n\tsides[i] = sides[0];\n\tdists[i] = dists[0];\n\t\n\t*front = *back = NULL;\n\n\tif (!counts[0])\n\t{\n\t\t*back = Winding_Clone(in);\n\t\treturn;\n\t}\n\tif (!counts[1])\n\t{\n\t\t*front = Winding_Clone(in);\n\t\treturn;\n\t}\n\n\tmaxpts = in->numpoints+4;\t// cant use counts[0]+2 because\n\t\t\t\t\t\t\t\t// of fp grouping errors\n\n\t*front = f = Winding_Alloc (maxpts);\n\t*back = b = Winding_Alloc (maxpts);\n\t\t\n\tfor (i = 0; i < in->numpoints; i++)\n\t{\n\t\tp1 = in->points[i];\n\t\t\n\t\tif (sides[i] == SIDE_ON)\n\t\t{\n\t\t\tVectorCopy (p1, f->points[f->numpoints]);\n\t\t\tf->numpoints++;\n\t\t\tVectorCopy (p1, b->points[b->numpoints]);\n\t\t\tb->numpoints++;\n\t\t\tcontinue;\n\t\t}\n\t\n\t\tif (sides[i] == SIDE_FRONT)\n\t\t{\n\t\t\tVectorCopy (p1, f->points[f->numpoints]);\n\t\t\tf->numpoints++;\n\t\t}\n\t\tif (sides[i] == SIDE_BACK)\n\t\t{\n\t\t\tVectorCopy (p1, b->points[b->numpoints]);\n\t\t\tb->numpoints++;\n\t\t}\n\n\t\tif (sides[i+1] == SIDE_ON || sides[i+1] == sides[i])\n\t\t\tcontinue;\n\t\t\t\n\t\t// generate a split point\n\t\tp2 = in->points[(i+1)%in->numpoints];\n\t\t\n\t\tdot = dists[i] / (dists[i]-dists[i+1]);\n\t\tfor (j = 0; j < 3; j++)\n\t\t{\n\t\t\t// avoid round off error when possible\n\t\t\tif (normal[j] == 1)\n\t\t\t\tmid[j] = dist;\n\t\t\telse if (normal[j] == -1)\n\t\t\t\tmid[j] = -dist;\n\t\t\telse\n\t\t\t\tmid[j] = p1[j] + dot*(p2[j]-p1[j]);\n\t\t}\n\t\t\t\n\t\tVectorCopy (mid, f->points[f->numpoints]);\n\t\tf->numpoints++;\n\t\tVectorCopy (mid, b->points[b->numpoints]);\n\t\tb->numpoints++;\n\t}\n\t\n\tif (f->numpoints > maxpts || b->numpoints > maxpts)\n\t\tError (\"Winding_Clip: points exceeded estimate\");\n\tif (f->numpoints > MAX_POINTS_ON_WINDING || b->numpoints > MAX_POINTS_ON_WINDING)\n\t\tError (\"Winding_Clip: MAX_POINTS_ON_WINDING\");\n}\n\n/*\n=============\nWinding_TryMerge\n\nIf two windings share a common edge and the edges that meet at the\ncommon points are both inside the other polygons, merge them\n\nReturns NULL if the windings couldn't be merged, or the new winding.\nThe originals will NOT be freed.\n\nif keep is true no points are ever removed\n=============\n*/\n#define\tCONTINUOUS_EPSILON\t0.005\n\nwinding_t *Winding_TryMerge(winding_t *f1, winding_t *f2, vec3_t planenormal, int keep)\n{\n\tvec_t\t\t*p1, *p2, *p3, *p4, *back;\n\twinding_t\t*newf;\n\tint\t\t\ti, j, k, l;\n\tvec3_t\t\tnormal, delta;\n\tvec_t\t\tdot;\n\tqboolean\tkeep1, keep2;\n\t\n\n\t//\n\t// find a common edge\n\t//\t\n\tp1 = p2 = NULL;\t// stop compiler warning\n\tj = 0;\t\t\t// \n\t\n\tfor (i = 0; i < f1->numpoints; i++)\n\t{\n\t\tp1 = f1->points[i];\n\t\tp2 = f1->points[(i+1) % f1->numpoints];\n\t\tfor (j = 0; j < f2->numpoints; j++)\n\t\t{\n\t\t\tp3 = f2->points[j];\n\t\t\tp4 = f2->points[(j+1) % f2->numpoints];\n\t\t\tfor (k = 0; k < 3; k++)\n\t\t\t{\n\t\t\t\tif (fabs(p1[k] - p4[k]) > 0.1)//EQUAL_EPSILON) //ME\n\t\t\t\t\tbreak;\n\t\t\t\tif (fabs(p2[k] - p3[k]) > 0.1)//EQUAL_EPSILON) //ME\n\t\t\t\t\tbreak;\n\t\t\t} //end for\n\t\t\tif (k==3)\n\t\t\t\tbreak;\n\t\t} //end for\n\t\tif (j < f2->numpoints)\n\t\t\tbreak;\n\t} //end for\n\t\n\tif (i == f1->numpoints)\n\t\treturn NULL;\t\t\t// no matching edges\n\n\t//\n\t// check slope of connected lines\n\t// if the slopes are colinear, the point can be removed\n\t//\n\tback = f1->points[(i+f1->numpoints-1)%f1->numpoints];\n\tVectorSubtract (p1, back, delta);\n\tCrossProduct (planenormal, delta, normal);\n\tVectorNormalize (normal);\n\t\n\tback = f2->points[(j+2)%f2->numpoints];\n\tVectorSubtract (back, p1, delta);\n\tdot = DotProduct (delta, normal);\n\tif (dot > CONTINUOUS_EPSILON)\n\t\treturn NULL;\t\t\t// not a convex polygon\n\tkeep1 = (qboolean)(dot < -CONTINUOUS_EPSILON);\n\t\n\tback = f1->points[(i+2)%f1->numpoints];\n\tVectorSubtract (back, p2, delta);\n\tCrossProduct (planenormal, delta, normal);\n\tVectorNormalize (normal);\n\n\tback = f2->points[(j+f2->numpoints-1)%f2->numpoints];\n\tVectorSubtract (back, p2, delta);\n\tdot = DotProduct (delta, normal);\n\tif (dot > CONTINUOUS_EPSILON)\n\t\treturn NULL;\t\t\t// not a convex polygon\n\tkeep2 = (qboolean)(dot < -CONTINUOUS_EPSILON);\n\n\t//\n\t// build the new polygon\n\t//\n\tnewf = Winding_Alloc (f1->numpoints + f2->numpoints);\n\t\n\t// copy first polygon\n\tfor (k=(i+1)%f1->numpoints ; k != i ; k=(k+1)%f1->numpoints)\n\t{\n\t\tif (!keep && k==(i+1)%f1->numpoints && !keep2)\n\t\t\tcontinue;\n\t\t\n\t\tVectorCopy (f1->points[k], newf->points[newf->numpoints]);\n\t\tnewf->numpoints++;\n\t}\n\t\n\t// copy second polygon\n\tfor (l= (j+1)%f2->numpoints ; l != j ; l=(l+1)%f2->numpoints)\n\t{\n\t\tif (!keep && l==(j+1)%f2->numpoints && !keep1)\n\t\t\tcontinue;\n\t\tVectorCopy (f2->points[l], newf->points[newf->numpoints]);\n\t\tnewf->numpoints++;\n\t}\n\n\treturn newf;\n}\n\n/*\n============\nWinding_Plane\n============\n*/\nvoid Winding_Plane (winding_t *w, vec3_t normal, double *dist)\n{\n\tvec3_t v1, v2;\n\tint i;\n\n\t//find two vectors each longer than 0.5 units\n\tfor (i = 0; i < w->numpoints; i++)\n\t{\n\t\tVectorSubtract(w->points[(i+1) % w->numpoints], w->points[i], v1);\n\t\tVectorSubtract(w->points[(i+2) % w->numpoints], w->points[i], v2);\n\t\tif (VectorLength(v1) > 0.5 && VectorLength(v2) > 0.5) break;\n\t}\n\tCrossProduct(v2, v1, normal);\n\tVectorNormalize(normal);\n\t*dist = DotProduct(w->points[0], normal);\n}\n\n/*\n=============\nWinding_Area\n=============\n*/\nfloat Winding_Area (winding_t *w)\n{\n\tint\t\ti;\n\tvec3_t\td1, d2, cross;\n\tfloat\ttotal;\n\n\ttotal = 0;\n\tfor (i=2 ; i<w->numpoints ; i++)\n\t{\n\t\tVectorSubtract (w->points[i-1], w->points[0], d1);\n\t\tVectorSubtract (w->points[i], w->points[0], d2);\n\t\tCrossProduct (d1, d2, cross);\n\t\ttotal += 0.5 * VectorLength ( cross );\n\t}\n\treturn total;\n}\n\n/*\n=============\nWinding_Bounds\n=============\n*/\nvoid Winding_Bounds (winding_t *w, vec3_t mins, vec3_t maxs)\n{\n\tvec_t\tv;\n\tint\t\ti,j;\n\n\tmins[0] = mins[1] = mins[2] = 99999;\n\tmaxs[0] = maxs[1] = maxs[2] = -99999;\n\n\tfor (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tfor (j=0 ; j<3 ; j++)\n\t\t{\n\t\t\tv = w->points[i][j];\n\t\t\tif (v < mins[j])\n\t\t\t\tmins[j] = v;\n\t\t\tif (v > maxs[j])\n\t\t\t\tmaxs[j] = v;\n\t\t}\n\t}\n}\n\n\n/*\n=================\nWinding_PointInside\n=================\n*/\nint Winding_PointInside(winding_t *w, plane_t *plane, vec3_t point, float epsilon)\n{\n\tint i;\n\tvec3_t dir, normal, pointvec;\n\n\tfor (i = 0; i < w->numpoints; i++)\n\t{\n\t\tVectorSubtract(w->points[(i+1) % w->numpoints], w->points[i], dir);\n\t\tVectorSubtract(point, w->points[i], pointvec);\n\t\t//\n\t\tCrossProduct(dir, plane->normal, normal);\n\t\t//\n\t\tif (DotProduct(pointvec, normal) < -epsilon) return false;\n\t}\n\treturn true;\n}\n\n/*\n=================\nWinding_VectorIntersect\n=================\n*/\nint Winding_VectorIntersect(winding_t *w, plane_t *plane, vec3_t p1, vec3_t p2, float epsilon)\n{\n\tfloat front, back, frac;\n\tvec3_t mid;\n\n\tfront = DotProduct(p1, plane->normal) - plane->dist;\n\tback = DotProduct(p2, plane->normal) - plane->dist;\n\t//if both points at the same side of the plane\n\tif (front < -epsilon && back < -epsilon) return false;\n\tif (front > epsilon && back > epsilon) return false;\n\t//get point of intersection with winding plane\n\tif (fabs(front-back) < 0.001)\n\t{\n\t\tVectorCopy(p2, mid);\n\t}\n\telse\n\t{\n\t\tfrac = front/(front-back);\n\t\tmid[0] = p1[0] + (p2[0] - p1[0]) * frac;\n\t\tmid[1] = p1[1] + (p2[1] - p1[1]) * frac;\n\t\tmid[2] = p1[2] + (p2[2] - p1[2]) * frac;\n\t}\n\treturn Winding_PointInside(w, plane, mid, epsilon);\n}\n\n"
  },
  {
    "path": "q3radiant/Winding.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n\n\n//returns true if the planes are equal\nint\t\t\tPlane_Equal(plane_t *a, plane_t *b, int flip);\n//returns false if the points are colinear\nint\t\t\tPlane_FromPoints(vec3_t p1, vec3_t p2, vec3_t p3, plane_t *plane);\n//returns true if the points are equal\nint\t\t\tPoint_Equal(vec3_t p1, vec3_t p2, float epsilon);\n\n//allocate a winding\nwinding_t*\tWinding_Alloc(int points);\n//free the winding\nvoid\t\tWinding_Free(winding_t *w);\n//create a base winding for the plane\nwinding_t*\tWinding_BaseForPlane (plane_t *p);\n//make a winding clone\nwinding_t*\tWinding_Clone(winding_t *w );\n//creates the reversed winding\nwinding_t*\tWinding_Reverse(winding_t *w);\n//remove a point from the winding\nvoid\t\tWinding_RemovePoint(winding_t *w, int point);\n//inserts a point to a winding, creating a new winding\nwinding_t*\tWinding_InsertPoint(winding_t *w, vec3_t point, int spot);\n//returns true if the planes are concave\nint\t\t\tWinding_PlanesConcave(winding_t *w1, winding_t *w2,\n\t\t\t\t\t\t\t\t\t vec3_t normal1, vec3_t normal2,\n\t\t\t\t\t\t\t\t\t float dist1, float dist2);\n//returns true if the winding is tiny\nint\t\t\tWinding_IsTiny(winding_t *w);\n//returns true if the winding is huge\nint\t\t\tWinding_IsHuge(winding_t *w);\n//clip the winding with the plane\nwinding_t*\tWinding_Clip(winding_t *in, plane_t *split, qboolean keepon);\n//split the winding with the plane\nvoid\t\tWinding_SplitEpsilon(winding_t *in, vec3_t normal, double dist, \n\t\t\t\t\t\t\t\tvec_t epsilon, winding_t **front, winding_t **back);\n//try to merge the windings, returns the new merged winding or NULL\nwinding_t *Winding_TryMerge(winding_t *f1, winding_t *f2, vec3_t planenormal, int keep);\n//create a plane for the winding\nvoid\t\tWinding_Plane(winding_t *w, vec3_t normal, double *dist);\n//returns the winding area\nfloat\t\tWinding_Area(winding_t *w);\n//returns the bounds of the winding\nvoid\t\tWinding_Bounds(winding_t *w, vec3_t mins, vec3_t maxs);\n//returns true if the point is inside the winding\nint\t\t\tWinding_PointInside(winding_t *w, plane_t *plane, vec3_t point, float epsilon);\n//returns true if the vector intersects with the winding\nint\t\t\tWinding_VectorIntersect(winding_t *w, plane_t *plane, vec3_t p1, vec3_t p2, float epsilon);\n"
  },
  {
    "path": "q3radiant/XY.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n// window system independent camera view code\n\ntypedef struct\n{\n\tint\t\twidth, height;\n\n\tqboolean\ttiming;\n\n\tvec3_t\torigin;\t\t\t// at center of window\n\tfloat\tscale;\n\n\tfloat\ttopclip, bottomclip;\n\n\tqboolean d_dirty;\n} xy_t;\n\nBOOL FilterBrush(brush_t *pb);\n"
  },
  {
    "path": "q3radiant/XYWnd.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// XYWnd.cpp : implementation file\n//\n// QERadiant\n//\n// \n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"XYWnd.h\"\n#include \"qe3.h\"\n#include \"PrefsDlg.h\"\n#include \"DialogInfo.h\"\n#include \"splines/splines.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n#define\tPAGEFLIPS\t2\n\n\nconst char* g_pDimStrings[] = {\"x:%.f\", \"y:%.f\", \"z:%.f\"};\nconst char* g_pOrgStrings[] = {\"(x:%.f  y:%.f)\", \"(x:%.f  z:%.f)\", \"(y:%.f  z:%.f)\"};\nCString g_strDim;\nCString g_strStatus;\n\nbool g_bCrossHairs = false;\nbool g_bScaleMode;\nint g_nScaleHow;\nbool g_bRotateMode;\nbool g_bClipMode;\nbool g_bRogueClipMode;\nbool g_bSwitch;\nCClipPoint g_Clip1;\nCClipPoint g_Clip2;\nCClipPoint g_Clip3;\nCClipPoint* g_pMovingClip;\nbrush_t g_brFrontSplits;\nbrush_t g_brBackSplits;\n\nbrush_t g_brClipboard;\nbrush_t g_brUndo;\nentity_t\tg_enClipboard;\n\nvec3_t g_vRotateOrigin;\nvec3_t g_vRotation;\n\nbool g_bPathMode;\nCClipPoint g_PathPoints[256];\nCClipPoint* g_pMovingPath;\nint g_nPathCount;\nint g_nPathLimit;\n\nbool g_bSmartGo;\n\nbool g_bPointMode;\nCClipPoint g_PointPoints[512];\nCClipPoint* g_pMovingPoint;\nint g_nPointCount;\nint g_nPointLimit;\n\n\nconst int XY_LEFT = 0x01;\nconst int XY_RIGHT = 0x02;\nconst int XY_UP = 0x04;\nconst int XY_DOWN = 0x08;\n\nPFNPathCallback* g_pPathFunc = NULL;\n\nvoid AcquirePath(int nCount, PFNPathCallback* pFunc)\n{\n  g_nPathCount = 0;\n  g_nPathLimit = nCount;\n  g_pPathFunc = pFunc;\n  g_bPathMode = true;\n}\n\n\nCPtrArray g_ptrMenus;\n\nCMemFile g_Clipboard(4096);\nCMemFile g_PatchClipboard(4096);\n\nextern int pressx;\nextern int pressy;\n\n\n/////////////////////////////////////////////////////////////////////////////\n// CXYWnd\n\nIMPLEMENT_DYNCREATE(CXYWnd, CWnd);\n\nCXYWnd::CXYWnd()\n{\n  g_brClipboard.next = &g_brClipboard;\n  g_brUndo.next = &g_brUndo;\n  g_nScaleHow = 0;\n  g_bRotateMode = false;\n  g_bClipMode = false;\n  g_bRogueClipMode = false;\n  g_bSwitch = true;\n  g_pMovingClip = NULL;\n  g_pMovingPath = NULL;\n  g_brFrontSplits.next = &g_brFrontSplits;\n  g_brBackSplits.next = &g_brBackSplits;\n  m_bActive = false;\n  //m_bTiming = true;\n  m_bTiming = false;\n  m_bRButtonDown = false;\n  m_nUpdateBits = W_XY;\n  g_bPathMode = false;\n  g_nPathCount = 0;\n  g_nPathLimit = 0;\n  m_nTimerID = -1;\n  XY_Init();\n}\n\nCXYWnd::~CXYWnd()\n{\n  int nSize = g_ptrMenus.GetSize();\n  while (nSize > 0)\n  {\n    CMenu* pMenu = reinterpret_cast<CMenu*>(g_ptrMenus.GetAt(nSize-1));\n    ASSERT(pMenu);\n    pMenu->DestroyMenu();\n    delete pMenu;\n    nSize--;\n  }\n  g_ptrMenus.RemoveAll();\n  m_mnuDrop.DestroyMenu();\n}\n\n\nBEGIN_MESSAGE_MAP(CXYWnd, CWnd)\n\t//{{AFX_MSG_MAP(CXYWnd)\n\tON_WM_CREATE()\n\tON_WM_LBUTTONDOWN()\n\tON_WM_MBUTTONDOWN()\n\tON_WM_RBUTTONDOWN()\n\tON_WM_LBUTTONUP()\n\tON_WM_MBUTTONUP()\n\tON_WM_RBUTTONUP()\n\tON_WM_MOUSEMOVE()\n\tON_WM_PAINT()\n\tON_WM_KEYDOWN()\n\tON_WM_SIZE()\n\tON_WM_DESTROY()\n\tON_COMMAND(ID_SELECT_MOUSEROTATE, OnSelectMouserotate)\n\tON_WM_TIMER()\n\tON_WM_KEYUP()\n\tON_WM_NCCALCSIZE()\n\tON_WM_KILLFOCUS()\n\tON_WM_SETFOCUS()\n\tON_WM_CLOSE()\n\tON_COMMAND(ID_SELECTION_MAKE_DETAIL, CMainFrame::OnSelectionMakeDetail)\n\tON_COMMAND(ID_SELECTION_MAKE_STRUCTURAL, CMainFrame::OnSelectionMakeStructural)\n\tON_COMMAND(ID_SELECTION_SELECTCOMPLETETALL, CMainFrame::OnSelectionSelectcompletetall)\n\tON_COMMAND(ID_SELECTION_SELECTINSIDE, CMainFrame::OnSelectionSelectinside)\n\tON_COMMAND(ID_SELECTION_SELECTPARTIALTALL, CMainFrame::OnSelectionSelectpartialtall)\n\tON_COMMAND(ID_SELECTION_SELECTTOUCHING, CMainFrame::OnSelectionSelecttouching)\n\tON_COMMAND(ID_SELECTION_UNGROUPENTITY, CMainFrame::OnSelectionUngroupentity)\n\t//}}AFX_MSG_MAP\n  ON_COMMAND_RANGE(ID_ENTITY_START, ID_ENTITY_END, OnEntityCreate)\nEND_MESSAGE_MAP()\n\n\n/////////////////////////////////////////////////////////////////////////////\n// CXYWnd message handlers\nLONG WINAPI XYWndProc(HWND, UINT, WPARAM, LPARAM);\nBOOL CXYWnd::PreCreateWindow(CREATESTRUCT& cs) \n{\n  WNDCLASS wc;\n  HINSTANCE hInstance = AfxGetInstanceHandle();\n  if (::GetClassInfo(hInstance, XY_WINDOW_CLASS, &wc) == FALSE)\n  {\n    // Register a new class\n  \tmemset (&wc, 0, sizeof(wc));\n    wc.style         = CS_NOCLOSE | CS_OWNDC;\n    wc.lpszClassName = XY_WINDOW_CLASS;\n    wc.hCursor       = NULL; //LoadCursor (NULL,IDC_ARROW);\n    wc.lpfnWndProc   = ::DefWindowProc;\n    if (AfxRegisterClass(&wc) == FALSE)\n      Error (\"CCamWnd RegisterClass: failed\");\n  }\n\n  cs.lpszClass = XY_WINDOW_CLASS;\n  cs.lpszName = \"VIEW\";\n  if (cs.style != QE3_CHILDSTYLE)\n    cs.style = QE3_SPLITTER_STYLE;\n\n\treturn CWnd::PreCreateWindow(cs);\n}\n\nHDC   s_hdcXY;\nHGLRC s_hglrcXY;\n\nstatic unsigned s_stipple[32] =\n{\n\t0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,\n\t0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,\n\t0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,\n\t0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,\n\t0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,\n\t0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,\n\t0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,\n\t0xaaaaaaaa, 0x55555555,0xaaaaaaaa, 0x55555555,\n};\n\n/*\n============\nWXY_WndProc\n============\n*/\nLONG WINAPI XYWndProc (\n    HWND    hWnd,\n    UINT    uMsg,\n    WPARAM  wParam,\n    LPARAM  lParam)\n{\n    switch (uMsg)\n    {\n\tcase WM_DESTROY:\n\t\tQEW_StopGL( hWnd, s_hglrcXY, s_hdcXY );\n\t\treturn 0;\n\n\tcase WM_NCCALCSIZE:// don't let windows copy pixels\n\t\tDefWindowProc (hWnd, uMsg, wParam, lParam);\n\t\treturn WVR_REDRAW;\n\n\tcase WM_KILLFOCUS:\n\tcase WM_SETFOCUS:\n\t\tSendMessage( hWnd, WM_NCACTIVATE, uMsg == WM_SETFOCUS, 0 );\n\t\treturn 0;\n\n   \tcase WM_CLOSE:\n        DestroyWindow (hWnd);\n\t\treturn 0;\n    }\n\n\treturn DefWindowProc (hWnd, uMsg, wParam, lParam);\n}\n\n\nstatic void WXY_InitPixelFormat( PIXELFORMATDESCRIPTOR *pPFD )\n{\n\tmemset( pPFD, 0, sizeof( *pPFD ) );\n\n\tpPFD->nSize    = sizeof( PIXELFORMATDESCRIPTOR );\n\tpPFD->nVersion = 1;\n\tpPFD->dwFlags  = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;\n\tpPFD->iPixelType = PFD_TYPE_RGBA;\n\tpPFD->cColorBits = 24;\n\tpPFD->cDepthBits = 32;\n\tpPFD->iLayerType = PFD_MAIN_PLANE;\n\n}\n\nvoid WXY_Print( void )\n{\n\tDOCINFO di;\n\n\tPRINTDLG pd;\n\n\t/*\n\t** initialize the PRINTDLG struct and execute it\n\t*/\n\tmemset( &pd, 0, sizeof( pd ) );\n\tpd.lStructSize = sizeof( pd );\n\tpd.hwndOwner = g_qeglobals.d_hwndXY;\n\tpd.Flags = PD_RETURNDC;\n\tpd.hInstance = 0;\n\tif ( !PrintDlg( &pd ) || !pd.hDC )\n\t{\n\t\tMessageBox( g_qeglobals.d_hwndMain, \"Could not PrintDlg()\", \"QE4 Print Error\", MB_OK | MB_ICONERROR );\n\t\treturn;\n\t}\n\n\t/*\n\t** StartDoc\n\t*/\n\tmemset( &di, 0, sizeof( di ) );\n\tdi.cbSize = sizeof( di );\n\tdi.lpszDocName = \"QE4\";\n\tif ( StartDoc( pd.hDC, &di ) <= 0 )\n\t{\n\t\tMessageBox( g_qeglobals.d_hwndMain, \"Could not StartDoc()\", \"QE4 Print Error\", MB_OK | MB_ICONERROR );\n\t\treturn;\n\t}\n\n\t/*\n\t** StartPage\n\t*/\n\tif ( StartPage( pd.hDC ) <= 0 )\n\t{\n\t\tMessageBox( g_qeglobals.d_hwndMain, \"Could not StartPage()\", \"QE4 Print Error\", MB_OK | MB_ICONERROR );\n\t\treturn;\n\t}\n\n\t/*\n\t** read pixels from the XY window\n\t*/\n\t{\n\t\tint bmwidth = 320, bmheight = 320;\n\t\tint pwidth, pheight;\n\n\t\tRECT r;\n\n\t\tGetWindowRect( g_qeglobals.d_hwndXY, &r );\n\n\t\tbmwidth  = r.right - r.left;\n\t\tbmheight = r.bottom - r.top;\n\n\t\tpwidth  = GetDeviceCaps( pd.hDC, PHYSICALWIDTH ) - GetDeviceCaps( pd.hDC, PHYSICALOFFSETX );\n\t\tpheight = GetDeviceCaps( pd.hDC, PHYSICALHEIGHT ) - GetDeviceCaps( pd.hDC, PHYSICALOFFSETY );\n\n\t\tStretchBlt( pd.hDC,\n\t\t\t0, 0,\n\t\t\tpwidth, pheight,\n\t\t\ts_hdcXY,\n\t\t\t0, 0,\n\t\t\tbmwidth, bmheight,\n\t\t\tSRCCOPY );\n\t}\n\n\t/*\n\t** EndPage and EndDoc\n\t*/\n\tif ( EndPage( pd.hDC ) <= 0 )\n\t{\n\t\tMessageBox( g_qeglobals.d_hwndMain, \"QE4 Print Error\", \"Could not EndPage()\", MB_OK | MB_ICONERROR );\n\t\treturn;\n\t}\n\n\tif ( EndDoc( pd.hDC ) <= 0 )\n\t{\n\t\tMessageBox( g_qeglobals.d_hwndMain, \"QE4 Print Error\", \"Could not EndDoc()\", MB_OK | MB_ICONERROR );\n\t\treturn;\n\t}\n}\n\nint CXYWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) \n{\n\tif (CWnd::OnCreate(lpCreateStruct) == -1)\n\t\treturn -1;\n\n  s_hdcXY = ::GetDC(GetSafeHwnd());\n\tQEW_SetupPixelFormat(s_hdcXY, false);\n\tif ( ( s_hglrcXY = qwglCreateContext( s_hdcXY ) ) == 0 )\n\t  Error( \"wglCreateContext in WXY_WndProc failed\" );\n\n\tif (!qwglShareLists( g_qeglobals.d_hglrcBase, s_hglrcXY ) )\n\t  Error( \"wglShareLists in WXY_WndProc failed\" );\n\n  if (!qwglMakeCurrent( s_hdcXY, s_hglrcXY ))\n\t  Error (\"wglMakeCurrent failed\");\n\n\tqglPolygonStipple ((unsigned char *)s_stipple);\n\tqglLineStipple (3, 0xaaaa);\n  g_qeglobals.d_hwndXY = GetSafeHwnd();\n\treturn 0;\n}\n\nfloat ptSum(vec3_t pt)\n{\n  return pt[0] + pt[1] + pt[2];\n}\n\nvoid CXYWnd::DropClipPoint(UINT nFlags, CPoint point)\n{\n  CRect rctZ;\n  GetClientRect(rctZ);\n  if (g_pMovingClip)\n  {\n    SetCapture();\n    SnapToPoint (point.x, rctZ.Height() - 1 - point.y , *g_pMovingClip);\n  }\n  else\n  {\n    vec3_t* pPt = NULL;\n    if (g_Clip1.Set() == false)\n    {\n      pPt = g_Clip1;\n      g_Clip1.Set(true);\n      g_Clip1.m_ptScreen = point;\n    }\n    else \n    if (g_Clip2.Set() == false)\n    {\n      pPt = g_Clip2;\n      g_Clip2.Set(true);\n      g_Clip2.m_ptScreen = point;\n    }\n    else \n    if (g_Clip3.Set() == false)\n    {\n      pPt = g_Clip3;\n      g_Clip3.Set(true);\n      g_Clip3.m_ptScreen = point;\n    }\n    else \n    {\n      RetainClipMode(true);\n      pPt = g_Clip1;\n      g_Clip1.Set(true);\n      g_Clip1.m_ptScreen = point;\n    }\n    SnapToPoint (point.x, rctZ.Height() - 1 - point.y , *pPt);\n  }\n  Sys_UpdateWindows(XY | W_CAMERA_IFON);\n}\n\n\nvoid CXYWnd::DropPathPoint(UINT nFlags, CPoint point)\n{\n  CRect rctZ;\n  GetClientRect(rctZ);\n  if (g_pMovingPath)\n  {\n    SetCapture();\n    SnapToPoint (point.x, rctZ.Height() - 1 - point.y , *g_pMovingPath);\n  }\n  else\n  {\n    g_PathPoints[g_nPathCount].Set(true);\n    g_PathPoints[g_nPathCount].m_ptScreen = point;\n    SnapToPoint(point.x, rctZ.Height() - 1 - point.y, g_PathPoints[g_nPathCount]);\n    g_nPathCount++;\n    if (g_nPathCount == g_nPathLimit)\n    {\n      if (g_pPathFunc)\n        g_pPathFunc(true, g_nPathCount);\n      g_nPathCount = 0;\n      g_bPathMode = false;\n      g_pPathFunc = NULL;\n    }\n  }\n  Sys_UpdateWindows(XY | W_CAMERA_IFON);\n}\n\nvoid CXYWnd::AddPointPoint(UINT nFlags, vec3_t* pVec)\n{\n  g_PointPoints[g_nPointCount].Set(true);\n  //g_PointPoints[g_nPointCount].m_ptScreen = point;\n  _VectorCopy(*pVec, g_PointPoints[g_nPointCount]);\n  g_PointPoints[g_nPointCount].SetPointPtr(pVec);\n  g_nPointCount++;\n  Sys_UpdateWindows(XY | W_CAMERA_IFON);\n}\n\n\nvoid CXYWnd::OnLButtonDown(UINT nFlags, CPoint point) \n{\n  g_pParentWnd->SetActiveXY(this);\n  UndoCopy();\n\n\t// plugin entities\n\tif (DispatchOnLButtonDown(nFlags, point.x, point.y ))\n\t\treturn;\n\n  if (ClipMode() && !RogueClipMode())\n  {\n    DropClipPoint(nFlags, point);\n  }\n  else if (PathMode())\n  {\n    DropPathPoint(nFlags, point);\n  }\n  else OriginalButtonDown(nFlags, point);\n}\n\nvoid CXYWnd::OnMButtonDown(UINT nFlags, CPoint point) \n{\n  OriginalButtonDown(nFlags, point);\n}\n\n\nfloat Betwixt(float f1, float f2)\n{\n  if (f1 > f2)\n    return f2 + ((f1 - f2) / 2);\n  else\n    return f1 + ((f2 - f1) / 2);\n}\n\nvoid CXYWnd::ProduceSplits(brush_t** pFront, brush_t** pBack)\n{\n  *pFront = NULL;\n  *pBack = NULL;\n  if (ClipMode())\n  {\n    if (g_Clip1.Set() && g_Clip2.Set())\n    {\n      face_t face;\n      VectorCopy(g_Clip1.m_ptClip,face.planepts[0]);\n      VectorCopy(g_Clip2.m_ptClip,face.planepts[1]);\n      VectorCopy(g_Clip3.m_ptClip,face.planepts[2]);\n      if (selected_brushes.next && (selected_brushes.next->next == &selected_brushes))\n      {\n        if (g_Clip3.Set() == false)\n        {\n          if (m_nViewType == XY)\n          {\n            face.planepts[0][2] = selected_brushes.next->mins[2];\n            face.planepts[1][2] = selected_brushes.next->mins[2];\n            face.planepts[2][0] = Betwixt(g_Clip1.m_ptClip[0], g_Clip2.m_ptClip[0]);\n            face.planepts[2][1] = Betwixt(g_Clip1.m_ptClip[1], g_Clip2.m_ptClip[1]);\n            face.planepts[2][2] = selected_brushes.next->maxs[2];\n          }\n          else if (m_nViewType == YZ)\n          {\n            face.planepts[0][0] = selected_brushes.next->mins[0];\n            face.planepts[1][0] = selected_brushes.next->mins[0];\n            face.planepts[2][1] = Betwixt(g_Clip1.m_ptClip[1], g_Clip2.m_ptClip[1]);\n            face.planepts[2][2] = Betwixt(g_Clip1.m_ptClip[2], g_Clip2.m_ptClip[2]);\n            face.planepts[2][0] = selected_brushes.next->maxs[0];\n          }\n          else\n          {\n            face.planepts[0][1] = selected_brushes.next->mins[1];\n            face.planepts[1][1] = selected_brushes.next->mins[1];\n            face.planepts[2][0] = Betwixt(g_Clip1.m_ptClip[0], g_Clip2.m_ptClip[0]);\n            face.planepts[2][2] = Betwixt(g_Clip1.m_ptClip[2], g_Clip2.m_ptClip[2]);\n            face.planepts[2][1] = selected_brushes.next->maxs[1];\n          }\n        }\n\n        Brush_SplitBrushByFace (selected_brushes.next, &face, pFront, pBack);\n      }\n\n    }\n  }\n}\n\nvoid CleanList(brush_t* pList)\n{\n  brush_t* pBrush = pList->next; \n  while (pBrush != NULL && pBrush != pList)\n  {\n    brush_t* pNext = pBrush->next;\n    Brush_Free(pBrush);\n    pBrush = pNext;\n  }\n}\n\nvoid CXYWnd::ProduceSplitLists()\n{\n\tif (AnyPatchesSelected())\n\t{\n\t\tSys_Printf(\"Deslecting patches for clip operation.\\n\");\n\t\tbrush_t *next;\n\t\tfor (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = next)\n\t\t{\n\t\t\tnext = pb->next;\n\t\t\tif (pb->patchBrush)\n\t\t\t{\n\t\t\t\tBrush_RemoveFromList (pb);\n\t\t\t\tBrush_AddToList (pb, &active_brushes);\n\t\t\t\tUpdatePatchInspector();\n\t\t\t}\n\t\t\tif (pb->terrainBrush)\n\t\t\t{\n\t\t\t\tBrush_RemoveFromList (pb);\n\t\t\t\tBrush_AddToList (pb, &active_brushes);\n\t\t\t\tUpdateTerrainInspector();\n\t\t\t}\n\t\t}\n\t}\n\n\tCleanList(&g_brFrontSplits);\n\tCleanList(&g_brBackSplits);\n\tg_brFrontSplits.next = &g_brFrontSplits;\n\tg_brBackSplits.next = &g_brBackSplits;\n\tbrush_t* pBrush;\n\tfor (pBrush = selected_brushes.next ; pBrush != NULL && pBrush != &selected_brushes ; pBrush=pBrush->next)\n\t{\n\t\tbrush_t* pFront = NULL;\n\t\tbrush_t* pBack = NULL;\n\t\tif (ClipMode())\n\t\t{\n\t\t\tif (g_Clip1.Set() && g_Clip2.Set())\n\t\t\t{\n\t\t\t\tface_t face;\n\t\t\t\tVectorCopy(g_Clip1.m_ptClip,face.planepts[0]);\n\t\t\t\tVectorCopy(g_Clip2.m_ptClip,face.planepts[1]);\n\t\t\t\tVectorCopy(g_Clip3.m_ptClip,face.planepts[2]);\n\t\t\t\tif (g_Clip3.Set() == false)\n\t\t\t\t{\n\t\t\t\t\tif (g_pParentWnd->ActiveXY()->GetViewType() == XY)\n\t\t\t\t\t{\n\t\t\t\t\t\tface.planepts[0][2] = pBrush->mins[2];\n\t\t\t\t\t\tface.planepts[1][2] = pBrush->mins[2];\n\t\t\t\t\t\tface.planepts[2][0] = Betwixt(g_Clip1.m_ptClip[0], g_Clip2.m_ptClip[0]);\n\t\t\t\t\t\tface.planepts[2][1] = Betwixt(g_Clip1.m_ptClip[1], g_Clip2.m_ptClip[1]);\n\t\t\t\t\t\tface.planepts[2][2] = pBrush->maxs[2];\n\t\t\t\t\t}\n\t\t\t\t\telse if (g_pParentWnd->ActiveXY()->GetViewType() == YZ)\n\t\t\t\t\t{\n\t\t\t\t\t\tface.planepts[0][0] = pBrush->mins[0];\n\t\t\t\t\t\tface.planepts[1][0] = pBrush->mins[0];\n\t\t\t\t\t\tface.planepts[2][1] = Betwixt(g_Clip1.m_ptClip[1], g_Clip2.m_ptClip[1]);\n\t\t\t\t\t\tface.planepts[2][2] = Betwixt(g_Clip1.m_ptClip[2], g_Clip2.m_ptClip[2]);\n\t\t\t\t\t\tface.planepts[2][0] = pBrush->maxs[0];\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tface.planepts[0][1] = pBrush->mins[1];\n\t\t\t\t\t\tface.planepts[1][1] = pBrush->mins[1];\n\t\t\t\t\t\tface.planepts[2][0] = Betwixt(g_Clip1.m_ptClip[0], g_Clip2.m_ptClip[0]);\n\t\t\t\t\t\tface.planepts[2][2] = Betwixt(g_Clip1.m_ptClip[2], g_Clip2.m_ptClip[2]);\n\t\t\t\t\t\tface.planepts[2][1] = pBrush->maxs[1];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tBrush_SplitBrushByFace (pBrush, &face, &pFront, &pBack);\n\t\t\t\tif (pBack)\n\t\t\t\t\tBrush_AddToList(pBack, &g_brBackSplits);\n\t\t\t\tif (pFront)\n\t\t\t\t\tBrush_AddToList(pFront, &g_brFrontSplits);\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid Brush_CopyList (brush_t* pFrom, brush_t* pTo)\n{\n\tbrush_t* pBrush = pFrom->next; \n\twhile (pBrush != NULL && pBrush != pFrom)\n\t{\n\t\tbrush_t* pNext = pBrush->next;\n\t\tBrush_RemoveFromList(pBrush);\n\t\tBrush_AddToList(pBrush, pTo);\n\t\tpBrush = pNext;\n\t}\n}\n\nvoid CXYWnd::OnRButtonDown(UINT nFlags, CPoint point) \n{\n  g_pParentWnd->SetActiveXY(this);\n  m_ptDown = point;\n  m_bRButtonDown = true;\n\n  if (g_PrefsDlg.m_nMouseButtons == 3) // 3 button mouse \n  {\n    if ((GetKeyState(VK_CONTROL) & 0x8000))\n    {\n      if (ClipMode()) // already there?\n        DropClipPoint(nFlags, point);\n      else\n      {\n        SetClipMode(true);\n        g_bRogueClipMode = true;\n        DropClipPoint(nFlags, point);\n      }\n      return;\n    }\n  }\n  OriginalButtonDown(nFlags, point);\n}\n\nvoid CXYWnd::OnLButtonUp(UINT nFlags, CPoint point) \n{\n\t// plugin entities\n\tif (DispatchOnLButtonUp(nFlags, point.x, point.y ))\n\t\treturn;\n\n\tif (ClipMode())\n  {\n    if (g_pMovingClip)\n    {\n      ReleaseCapture();\n      g_pMovingClip = NULL;\n    }\n  }\n  OriginalButtonUp(nFlags, point);\n}\n\nvoid CXYWnd::OnMButtonUp(UINT nFlags, CPoint point) \n{\n  OriginalButtonUp(nFlags, point);\n}\n\nvoid CXYWnd::OnRButtonUp(UINT nFlags, CPoint point) \n{\n  m_bRButtonDown = false;\n  if (point == m_ptDown)    // mouse didn't move\n  {\n    bool bGo = true;\n    if ((GetKeyState(VK_MENU) & 0x8000))\n      bGo = false;\n    if ((GetKeyState(VK_CONTROL) & 0x8000))\n      bGo = false;\n    if ((GetKeyState(VK_SHIFT) & 0x8000))\n      bGo = false;\n    if (bGo)\n      HandleDrop();\n  }\n  OriginalButtonUp(nFlags, point);\n}\n\nvoid CXYWnd::OriginalButtonDown(UINT nFlags, CPoint point)\n{\n  CRect rctZ;\n  GetClientRect(rctZ);\n  SetWindowPos(&wndTop, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);\n  if (::GetTopWindow( g_qeglobals.d_hwndMain ) != GetSafeHwnd())\n    ::BringWindowToTop(GetSafeHwnd());\n\tSetFocus();\n\tSetCapture();\n\tXY_MouseDown (point.x, rctZ.Height() - 1 - point.y , nFlags);\n  m_nScrollFlags = nFlags;\n}          \n\nvoid CXYWnd::OriginalButtonUp(UINT nFlags, CPoint point)\n{\n  CRect rctZ;\n  GetClientRect(rctZ);\n  XY_MouseUp (point.x, rctZ.Height() - 1 - point.y , nFlags);\n\tif (! (nFlags & (MK_LBUTTON|MK_RBUTTON|MK_MBUTTON)))\n\t\tReleaseCapture ();\n}\n\n\nfloat fDiff(float f1, float f2)\n{\n  if (f1 > f2)\n    return f1 - f2;\n  else\n    return f2 - f1;\n}\n\n\nvec3_t tdp;\nvoid CXYWnd::OnMouseMove(UINT nFlags, CPoint point) \n{\n\t// plugin entities\n\t//++timo TODO: handle return code\n\tDispatchOnMouseMove( nFlags, point.x, point.y );\n\n  m_ptDown.x = 0;\n  m_ptDown.y = 0;\n\n  if ( g_PrefsDlg.m_bChaseMouse == TRUE &&\n       (point.x < 0 || point.y < 0 || \n       point.x > m_nWidth || point.y > m_nHeight) &&\n       GetCapture() == this)\n  {\n    float fAdjustment = (g_qeglobals.d_gridsize / 8 * 64) / m_fScale;\n    //m_ptDrag = point;\n    m_ptDragAdj.x = 0;\n    m_ptDragAdj.y = 0;\n    if (point.x < 0)\n    {\n      m_ptDragAdj.x = -fAdjustment;\n    }\n    else \n    if (point.x > m_nWidth)\n    {\n      m_ptDragAdj.x = fAdjustment;\n    }\n    if (point.y < 0)\n    {\n      m_ptDragAdj.y = -fAdjustment;\n    }\n    else\n    if (point.y > m_nHeight)\n    {\n      m_ptDragAdj.y = fAdjustment;\n    }\n    if (m_nTimerID == -1)\n    {\n      m_nTimerID = SetTimer(100, 50, NULL);\n      m_ptDrag = point;\n      m_ptDragTotal = 0;\n    }\n    return;\n  }\n  //else if (m_nTimerID != -1)\n  if (m_nTimerID != -1)\n  {\n    KillTimer(m_nTimerID);\n    pressx -= m_ptDragTotal.x;\n    pressy += m_ptDragTotal.y;\n    m_nTimerID = -1;\n    //return;\n  }\n\n  bool bCrossHair = false;\n  if (!m_bRButtonDown)\n  {\n    tdp[0] = tdp[1] = tdp[2] = 0.0;\n    SnapToPoint (point.x, m_nHeight - 1 - point.y , tdp);\n\n    g_strStatus.Format(\"x:: %.1f  y:: %.1f  z:: %.1f\", tdp[0], tdp[1], tdp[2]);\n    g_pParentWnd->SetStatusText(1, g_strStatus);\n\n    // i need to generalize the point code.. having 3 flavors pretty much sucks.. \n    // once the new curve stuff looks like it is going to stick i will \n    // rationalize this down to a single interface.. \n    if (PointMode())\n    {\n      if (g_pMovingPoint && GetCapture() == this)\n      {\n        bCrossHair = true;\n        SnapToPoint (point.x, m_nHeight - 1 - point.y , g_pMovingPoint->m_ptClip);\n        g_pMovingPoint->UpdatePointPtr();\n        Sys_UpdateWindows(XY | W_CAMERA_IFON);\n      }\n      else\n      {\n        g_pMovingPoint = NULL;\n        int nDim1 = (m_nViewType == YZ) ? 1 : 0;\n        int nDim2 = (m_nViewType == XY) ? 1 : 2;\n        for (int n = 0; n < g_nPointCount; n++)\n        {\n          if ( fDiff(g_PointPoints[n].m_ptClip[nDim1], tdp[nDim1]) < 3 &&\n               fDiff(g_PointPoints[n].m_ptClip[nDim2], tdp[nDim2]) < 3 )\n          {\n            bCrossHair = true;\n            g_pMovingPoint = &g_PointPoints[n];\n          }\n        }\n      }\n    }\n    else if (ClipMode())\n    {\n      if (g_pMovingClip && GetCapture() == this)\n      {\n        bCrossHair = true;\n        SnapToPoint (point.x, m_nHeight - 1 - point.y , g_pMovingClip->m_ptClip);\n        Sys_UpdateWindows(XY | W_CAMERA_IFON);\n      }\n      else\n      {\n        g_pMovingClip = NULL;\n        int nDim1 = (m_nViewType == YZ) ? 1 : 0;\n        int nDim2 = (m_nViewType == XY) ? 1 : 2;\n        if (g_Clip1.Set())\n        {\n          if ( fDiff(g_Clip1.m_ptClip[nDim1], tdp[nDim1]) < 3 &&\n               fDiff(g_Clip1.m_ptClip[nDim2], tdp[nDim2]) < 3 )\n          {\n            bCrossHair = true;\n            g_pMovingClip = &g_Clip1;\n          }\n        }\n        if (g_Clip2.Set())\n        {\n          if ( fDiff(g_Clip2.m_ptClip[nDim1], tdp[nDim1]) < 3 &&\n               fDiff(g_Clip2.m_ptClip[nDim2], tdp[nDim2]) < 3 )\n          {\n            bCrossHair = true;\n            g_pMovingClip = &g_Clip2;\n          }\n        }\n        if (g_Clip3.Set())\n        {\n          if ( fDiff(g_Clip3.m_ptClip[nDim1], tdp[nDim1]) < 3 &&\n               fDiff(g_Clip3.m_ptClip[nDim2], tdp[nDim2]) < 3 )\n          {\n            bCrossHair = true;\n            g_pMovingClip = &g_Clip3;\n          }\n        }\n      }\n      if (bCrossHair == false)\n        XY_MouseMoved (point.x, m_nHeight - 1 - point.y , nFlags);\n    }\n    else if (PathMode())\n    {\n      if (g_pMovingPath && GetCapture() == this)\n      {\n        bCrossHair = true;\n        SnapToPoint (point.x, m_nHeight - 1 - point.y , g_pMovingPath->m_ptClip);\n        Sys_UpdateWindows(XY | W_CAMERA_IFON);\n      }\n      else\n      {\n        g_pMovingPath = NULL;\n        int nDim1 = (m_nViewType == YZ) ? 1 : 0;\n        int nDim2 = (m_nViewType == XY) ? 1 : 2;\n        for (int n = 0; n < g_nPathCount; n++)\n        {\n          if ( fDiff(g_PathPoints[n].m_ptClip[nDim1], tdp[nDim1]) < 3 &&\n               fDiff(g_PathPoints[n].m_ptClip[nDim2], tdp[nDim2]) < 3 )\n          {\n            bCrossHair = true;\n            g_pMovingPath = &g_PathPoints[n];\n          }\n        }\n      }\n    }\n    else\n    {\n      XY_MouseMoved (point.x, m_nHeight - 1 - point.y , nFlags);\n    }\n  }\n  else \n  {\n    XY_MouseMoved (point.x, m_nHeight - 1 - point.y , nFlags);\n  }\n  if (bCrossHair)\n    SetCursor(::LoadCursor(NULL, IDC_CROSS));\n  else\n    SetCursor(::LoadCursor(NULL, IDC_ARROW));\n}\n\nvoid CXYWnd::RetainClipMode(bool bMode)\n{\n  bool bSave = g_bRogueClipMode;\n  SetClipMode(bMode);\n  if (bMode == true)\n    g_bRogueClipMode = bSave;\n  else\n    g_bRogueClipMode = false;\n}\n\nvoid CXYWnd::SetClipMode(bool bMode)\n{\n  g_bClipMode = bMode;\n  g_bRogueClipMode = false;\n  if (bMode)\n  {\n    g_Clip1.Reset();\n    g_Clip2.Reset();\n    g_Clip3.Reset();\n    CleanList(&g_brFrontSplits);\n    CleanList(&g_brBackSplits);\n    g_brFrontSplits.next = &g_brFrontSplits;\n    g_brBackSplits.next = &g_brBackSplits;\n  }\n  else\n  {\n    if (g_pMovingClip)\n    {\n      ReleaseCapture();\n      g_pMovingClip = NULL;\n    }\n    CleanList(&g_brFrontSplits);\n    CleanList(&g_brBackSplits);\n    g_brFrontSplits.next = &g_brFrontSplits;\n    g_brBackSplits.next = &g_brBackSplits;\n    Sys_UpdateWindows(XY | W_CAMERA_IFON);\n  }\n}\n\nbool CXYWnd::ClipMode()\n{\n  return g_bClipMode;\n}\n\nbool CXYWnd::RogueClipMode()\n{\n  return g_bRogueClipMode;\n}\n\nbool CXYWnd::PathMode()\n{\n  return g_bPathMode;\n}\n\n\nbool CXYWnd::PointMode()\n{\n  return g_bPointMode;\n}\n\nvoid CXYWnd::SetPointMode(bool b)\n{\n  g_bPointMode = b;\n  if (!b)\n    g_nPointCount = 0;\n}\n\n\nvoid CXYWnd::OnPaint() \n{\n\tCPaintDC dc(this); // device context for painting\n  bool bPaint = true;\n  if (!qwglMakeCurrent(dc.m_hDC, s_hglrcXY))\n  {\n    Sys_Printf(\"ERROR: wglMakeCurrent failed.. Error:%i\\n\",qglGetError());\n    Sys_Printf(\"Please restart Q3Radiant if the Map view is not working\\n\");\n    bPaint = false;\n  }\n  if (bPaint)\n  {\n    QE_CheckOpenGLForErrors();\n\t\tXY_Draw ();\n    QE_CheckOpenGLForErrors();\n\n    if (m_nViewType != XY)\n    {\n      qglPushMatrix();\n      if (m_nViewType == YZ)\n        qglRotatef (-90,  0, 1, 0);\t    // put Z going up\n      qglRotatef (-90,  1, 0, 0);\t    // put Z going up\n    }\n \n    if (g_bCrossHairs)\n    {\n\t    qglColor4f(0.2, 0.9, 0.2, 0.8);\n\t\t  qglBegin (GL_LINES);\n      if (m_nViewType == XY)\n      {\n        qglVertex2f(-16384, tdp[1]);\n        qglVertex2f(16384, tdp[1]);\n        qglVertex2f(tdp[0], -16384);\n        qglVertex2f(tdp[0], 16384);\n      }\n      else if (m_nViewType == YZ)\n      {\n        qglVertex3f(tdp[0], -16384, tdp[2]);\n        qglVertex3f(tdp[0], 16384, tdp[2]);\n        qglVertex3f(tdp[0], tdp[1], -16384);\n        qglVertex3f(tdp[0], tdp[1], 16384);\n      }\n      else\n      {\n        qglVertex3f(-16384, tdp[1], tdp[2]);\n        qglVertex3f( 16384, tdp[1], tdp[2]);\n        qglVertex3f(tdp[0], tdp[1], -16384);\n        qglVertex3f(tdp[0], tdp[1], 16384);\n      }\n\t\t  qglEnd();\n    }\n\n    if (ClipMode())\n    {\n      qglPointSize (4);\n\t\t  qglColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER]);\n\t\t  qglBegin (GL_POINTS);\n      if (g_Clip1.Set())\n\t\t\t  qglVertex3fv (g_Clip1);\n      if (g_Clip2.Set())\n\t\t\t  qglVertex3fv (g_Clip2);\n      if (g_Clip3.Set())\n\t\t\t  qglVertex3fv (g_Clip3);\n\t\t  qglEnd ();\n\t\t  qglPointSize (1);\n\n      CString strMsg;\n      if (g_Clip1.Set())\n      {\n        qglRasterPos3f (g_Clip1.m_ptClip[0]+2, g_Clip1.m_ptClip[1]+2, g_Clip1.m_ptClip[2]+2);\n        strMsg = \"1\";\n        //strMsg.Format(\"1 (%f, %f, %f)\", g_Clip1[0], g_Clip1[1], g_Clip1[2]);\n\t      qglCallLists (strMsg.GetLength(), GL_UNSIGNED_BYTE, strMsg);\n      }\n      if (g_Clip2.Set())\n      {\n        qglRasterPos3f (g_Clip2.m_ptClip[0]+2, g_Clip2.m_ptClip[1]+2, g_Clip2.m_ptClip[2]+2);\n        strMsg = \"2\";\n        //strMsg.Format(\"2 (%f, %f, %f)\", g_Clip2[0], g_Clip2[1], g_Clip2[2]);\n\t      qglCallLists (strMsg.GetLength(), GL_UNSIGNED_BYTE, strMsg);\n      }\n      if (g_Clip3.Set())\n      {\n        qglRasterPos3f (g_Clip3.m_ptClip[0]+2, g_Clip3.m_ptClip[1]+2, g_Clip3.m_ptClip[2]+2);\n        strMsg = \"3\";\n        //strMsg.Format(\"3 (%f, %f, %f)\", g_Clip3[0], g_Clip3[1], g_Clip3[2]);\n\t      qglCallLists (strMsg.GetLength(), GL_UNSIGNED_BYTE, strMsg);\n      }\n      if (g_Clip1.Set() && g_Clip2.Set())\n      {\n        ProduceSplitLists();\n        brush_t* pBrush;\n        brush_t* pList = ( (m_nViewType == XZ) ? !g_bSwitch : g_bSwitch) ? &g_brBackSplits : &g_brFrontSplits;\n\t      for (pBrush = pList->next ; pBrush != NULL && pBrush != pList ; pBrush=pBrush->next)\n        {\n\t\t      qglColor3f (1,1,0);\n\t        face_t *face;\n\t        int order;\n\t        for (face = pBrush->brush_faces,order = 0 ; face ; face=face->next, order++)\n\t        {\n\t\t        winding_t* w = face->face_winding;\n\t\t        if (!w)\n\t\t\t        continue;\n\t\t        // draw the polygon\n\t\t        qglBegin(GL_LINE_LOOP);\n            for (int i=0 ; i<w->numpoints ; i++)\n\t\t          qglVertex3fv(w->points[i]);\n\t\t        qglEnd();\n\t        }\n        }\n      }\n\n    }\n\n\n\n    if (PathMode())\n    {\n      qglPointSize (4);\n\t\t  qglColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER]);\n\t\t  qglBegin (GL_POINTS);\n\n      for (int n = 0; n < g_nPathCount; n++)\n        qglVertex3fv(g_PathPoints[n]);\n\t\t  qglEnd ();\n\t\t  qglPointSize (1);\n\n      CString strMsg;\n      for (n = 0; n < g_nPathCount; n++)\n      {\n        qglRasterPos3f (g_PathPoints[n].m_ptClip[0]+2, g_PathPoints[n].m_ptClip[1]+2, g_PathPoints[n].m_ptClip[2]+2);\n        strMsg.Format(\"%i\", n+1);\n\t      qglCallLists (strMsg.GetLength(), GL_UNSIGNED_BYTE, strMsg);\n      }\n\n    }\n    if (m_nViewType != XY)\n      qglPopMatrix();\n\n\t\tqwglSwapBuffers(dc.m_hDC);\n    TRACE(\"XY Paint\\n\");\n  }\n }\n\nvoid CXYWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) \n{\n  g_pParentWnd->HandleKey(nChar, nRepCnt, nFlags);\n}\n\n\n\n// FIXME: the brush_t *pBrush is never used. ( Entity_Create uses selected_brushes )\nvoid CreateEntityFromName(char* pName, brush_t* pBrush)\n{\n\teclass_t *pecNew;\n\tentity_t *petNew;\n\tif (stricmp(pName, \"worldspawn\") == 0)\n\t{\n\t\tMessageBox(g_qeglobals.d_hwndMain, \"Can't create an entity with worldspawn.\", \"info\", 0);\n\t\treturn;\n\t}\n\t\n\tpecNew = Eclass_ForName(pName, false);\n\t\n\t// create it\n\tpetNew = Entity_Create(pecNew);\n\tif (petNew == NULL)\n\t{\n\t\tif (!((selected_brushes.next == &selected_brushes)||(selected_brushes.next->next != &selected_brushes)))\n\t\t{\n\t\t\tbrush_t* b = selected_brushes.next;\n\t\t\tif (b->owner != world_entity && b->owner->eclass->fixedsize && pecNew->fixedsize)\n\t\t\t{\n\t\t\t\tvec3_t mins, maxs;\n\t\t\t\tvec3_t origin;\n\t\t\t\tfor (int i=0 ; i<3 ; i++)\n\t\t\t\t\torigin[i] = b->mins[i] - pecNew->mins[i];\n\t\t\t\t\n\t\t\t\tVectorAdd (pecNew->mins, origin, mins);\n\t\t\t\tVectorAdd (pecNew->maxs, origin, maxs);\n\t\t\t\tbrush_t* nb = Brush_Create (mins, maxs, &pecNew->texdef);\n\t\t\t\tEntity_LinkBrush (b->owner, nb);\n\t\t\t\tnb->owner->eclass = pecNew;\n\t\t\t\tSetKeyValue (nb->owner, \"classname\", pName);\n\t\t\t\tBrush_Free(b);\n\t\t\t\tBrush_Build(nb);\n\t\t\t\tBrush_AddToList (nb, &active_brushes);\n\t\t\t\tSelect_Brush(nb);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tMessageBox(g_qeglobals.d_hwndMain, \"Failed to create entity.\", \"info\", 0);\n\t\treturn;\n\t}\n\t\n\tSelect_Deselect ();\n\t//entity_t* pEntity = world_entity;\n\t//if (selected_brushes.next != &selected_brushes)\n\t//\tpEntity = selected_brushes.next->owner;\n\tSelect_Brush (petNew->brushes.onext);\n\t\n\tif (stricmp(pName, \"misc_model\") == 0)\n\t{\n\t\tSetInspectorMode(W_ENTITY);\n\t\tPostMessage(g_qeglobals.d_hwndEntity, WM_COMMAND, IDC_BTN_ASSIGNMODEL, 0);\n\t}\n\t\n}\n\n\nbrush_t* CreateEntityBrush(int x, int y, CXYWnd* pWnd)\n{\n\tvec3_t\tmins, maxs;\n\tint\t\ti;\n\tfloat\ttemp;\n\tbrush_t\t*n;\n\n\tpWnd->SnapToPoint (x, y, mins);\n  x += 32;\n  y += 32;\n\tpWnd->SnapToPoint (x, y, maxs);\n\n  int nDim = (pWnd->GetViewType() == XY) ? 2 : (pWnd->GetViewType() == YZ) ? 0 : 1;\n\tmins[nDim] = g_qeglobals.d_gridsize * ((int)(g_qeglobals.d_new_brush_bottom_z/g_qeglobals.d_gridsize));\n\tmaxs[nDim] = g_qeglobals.d_gridsize * ((int)(g_qeglobals.d_new_brush_top_z/g_qeglobals.d_gridsize));\n\n  if (maxs[nDim] <= mins[nDim])\n\t\tmaxs[nDim] = mins[nDim] + g_qeglobals.d_gridsize;\n\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tif (mins[i] == maxs[i])\n\t\t\tmaxs[i] += 16;\t// don't create a degenerate brush\n\t\tif (mins[i] > maxs[i])\n\t\t{\n\t\t\ttemp = mins[i];\n\t\t\tmins[i] = maxs[i];\n\t\t\tmaxs[i] = temp;\n\t\t}\n\t}\n\n\tn = Brush_Create (mins, maxs, &g_qeglobals.d_texturewin.texdef);\n\tif (!n)\n\t\treturn NULL;\n\n\tBrush_AddToList (n, &selected_brushes);\n\tEntity_LinkBrush (world_entity, n);\n\tBrush_Build( n );\n  return n;\n}\n\nvoid CreateRightClickEntity(CXYWnd* pWnd, int x, int y, char* pName)\n{\n  CRect rctZ;\n  pWnd->GetClientRect(rctZ);\n  brush_t* pBrush = (selected_brushes.next == &selected_brushes) ? CreateEntityBrush(x, rctZ.Height() - 1 - y, pWnd) : selected_brushes.next;\n  CreateEntityFromName(pName, pBrush);\n  //Select_Brush(pBrush);\n}\n\nbrush_t* CreateSmartBrush(vec3_t v)\n{\n\tvec3_t\tmins, maxs;\n\tint\t\ti;\n\tbrush_t\t*n;\n\n\tfor (i=0 ; i<3 ; i++)\n\t{\n    mins[i] = v[i] - 16;\n    maxs[i] = v[i] + 16;\n  }\n\n\tn = Brush_Create (mins, maxs, &g_qeglobals.d_texturewin.texdef);\n\tif (!n)\n\t\treturn NULL;\n\n\tBrush_AddToList(n, &selected_brushes);\n\t//Entity_LinkBrush(world_entity, n);\n\tBrush_Build(n);\n  return n;\n}\n\n\n\n\nCString g_strSmartEntity;\nint g_nSmartX;\nint g_nSmartY;\nbool g_bSmartWaiting;\nvoid _SmartPointDone(bool b, int n)\n{\n  g_bSmartWaiting = false;\n}\n\nvoid CreateSmartEntity(CXYWnd* pWnd, int x, int y, const char* pName)\n{\n  g_nSmartX = x;\n  g_nSmartY = y;\n  g_strSmartEntity = pName;\n  if (g_strSmartEntity.Find(\"Smart_Train\") >= 0)\n  {\n    ShowInfoDialog(\"Select the path of the train by left clicking in XY, YZ and/or XZ views. You can move an already dropped point by grabbing and moving it. When you are finished, press ENTER to accept and create the entity and path(s), press ESC to abandon the creation\");\n    g_bPathMode = true;\n    g_nPathLimit = 0;\n    g_nPathCount = 0;\n    g_bSmartGo = true;\n  }\n  else\n  if (g_strSmartEntity.Find(\"Smart_Monster...\") >= 0)\n  {\n    g_bPathMode = true;\n    g_nPathLimit = 0;\n    g_nPathCount = 0;\n  }\n  else\n  if (g_strSmartEntity.Find(\"Smart_Rotating\") >= 0)\n  {\n    g_bSmartWaiting = true;\n    ShowInfoDialog(\"Left click to specify the rotation origin\");\n    AcquirePath(1, &_SmartPointDone);\n    while (g_bSmartWaiting)\n    {\n      MSG msg;\n      if (::PeekMessage( &msg, NULL, 0, 0, PM_REMOVE )) \n      { \n        TranslateMessage(&msg);\n        DispatchMessage(&msg);\n      }\n    }\n    HideInfoDialog();\n    CPtrArray array;\n    g_bScreenUpdates = false;\n    CreateRightClickEntity(g_pParentWnd->ActiveXY(), g_nSmartX, g_nSmartY, \"func_rotating\");\n    array.Add(reinterpret_cast<void*>(selected_brushes.next));\n    Select_Deselect();\n    brush_t* pBrush = CreateSmartBrush(g_PathPoints[0]);\n    array.Add(pBrush);\n    Select_Deselect();\n    Select_Brush(reinterpret_cast<brush_t*>(array.GetAt(0)));\n    Select_Brush(reinterpret_cast<brush_t*>(array.GetAt(1)));\n    ConnectEntities();\n    g_bScreenUpdates = true;\n  }\n}\n\n\nvoid FinishSmartCreation()\n{\n  CPtrArray array;\n  HideInfoDialog();\n  brush_t* pEntities = NULL;\n  if (g_strSmartEntity.Find(\"Smart_Train\") >= 0)\n  {\n    g_bScreenUpdates = false;\n    CreateRightClickEntity(g_pParentWnd->ActiveXY(), g_nSmartX, g_nSmartY, \"func_train\");\n    array.Add(reinterpret_cast<void*>(selected_brushes.next));\n    for (int n = 0; n < g_nPathCount; n++)\n    {\n      Select_Deselect();\n      CreateRightClickEntity(g_pParentWnd->ActiveXY(), g_PathPoints[n].m_ptScreen.x,g_PathPoints[n].m_ptScreen.y, \"path_corner\");\n      array.Add(reinterpret_cast<void*>(selected_brushes.next));\n    }\n\n    for (n = 0; n < g_nPathCount; n++)\n    {\n      Select_Deselect();\n      Select_Brush(reinterpret_cast<brush_t*>(array.GetAt(n)));\n      Select_Brush(reinterpret_cast<brush_t*>(array.GetAt(n+1)));\n      ConnectEntities();\n    }\n    g_bScreenUpdates = true;\n\n  }\n  g_nPathCount = 0;\n  g_bPathMode = false;\n  Sys_UpdateWindows(W_ALL);\n}\n\nvoid CXYWnd::KillPathMode()\n{\n  g_bSmartGo = false;\n  g_bPathMode = false;\n  if (g_pPathFunc)\n    g_pPathFunc(false, g_nPathCount);\n  g_nPathCount = 0;\n  g_pPathFunc = NULL;\n  Sys_UpdateWindows(W_ALL);\n}\n\n// gets called for drop down menu messages\n// TIP: it's not always about EntityCreate\nvoid CXYWnd::OnEntityCreate(unsigned int nID) \n{\n  if (m_mnuDrop.GetSafeHmenu())\n  {\n    CString strItem;\n    m_mnuDrop.GetMenuString(nID, strItem, MF_BYCOMMAND);\n\n\t\tif (strItem.CompareNoCase(\"Add to...\") == 0)\n\t\t{\n\t\t\t//++timo TODO: fill the menu with current groups?\n\t\t\t// this one is for adding to existing groups only\n\t\t\tSys_Printf(\"TODO: Add to... in CXYWnd::OnEntityCreate\\n\");\n\t\t}\n\t\telse if (strItem.CompareNoCase(\"Remove\") == 0)\n\t\t{\n\t\t\t// remove selected brushes from their current group\n\t\t\tbrush_t *b;\n\t\t\tfor( b = selected_brushes.next; b != &selected_brushes; b = b->next )\n\t\t\t{\n\t\t\t\t\n\t\t\t}\n\t\t}\n\n\t\t//++timo FIXME: remove when all hooks are in\n\t\tif (strItem.CompareNoCase(\"Add to...\") == 0\n\t\t\t|| strItem.CompareNoCase(\"Remove\") == 0\n\t\t\t|| strItem.CompareNoCase(\"Name...\") == 0\n\t\t\t|| strItem.CompareNoCase(\"New group...\") == 0)\n\t\t{\n\t\t\tSys_Printf(\"TODO: hook drop down group menu\\n\");\n\t\t\treturn;\n\t\t}\n\t\t\n    if (strItem.Find(\"Smart_\") >= 0)\n    {\n      CreateSmartEntity(this, m_ptDown.x, m_ptDown.y, strItem);\n    }\n    else\n    {\n      CreateRightClickEntity(this, m_ptDown.x, m_ptDown.y, strItem.GetBuffer(0));\n    }\n\t\t\n    Sys_UpdateWindows(W_ALL);\n    //OnLButtonDown((MK_LBUTTON | MK_SHIFT), CPoint(m_ptDown.x+2, m_ptDown.y+2));\n  }\n}\n\n\nvoid CXYWnd::HandleDrop()\n{\n  if (g_PrefsDlg.m_bRightClick == false)\n    return;\n  if (!m_mnuDrop.GetSafeHmenu()) // first time, load it up\n  {\n    m_mnuDrop.CreatePopupMenu();\n    int nID = ID_ENTITY_START;\n\n    CMenu* pChild2 = new CMenu;\n    pChild2->CreateMenu();\n    pChild2->AppendMenu(MF_STRING, ID_SELECTION_SELECTCOMPLETETALL, \"Select Complete Tall\");\n    pChild2->AppendMenu(MF_STRING, ID_SELECTION_SELECTTOUCHING, \"Select Touching\");\n    pChild2->AppendMenu(MF_STRING, ID_SELECTION_SELECTPARTIALTALL, \"Select Partial Tall\");\n    pChild2->AppendMenu(MF_STRING, ID_SELECTION_SELECTINSIDE, \"Select Inside\");\n    m_mnuDrop.AppendMenu(MF_POPUP, reinterpret_cast<unsigned int>(pChild2->GetSafeHmenu()), \"Select\");\n    m_mnuDrop.AppendMenu(MF_SEPARATOR, nID++, \"\");\n\n    CMenu* pChild3 = new CMenu;\n    pChild3->CreateMenu();\n    pChild3->AppendMenu(MF_STRING, ID_DROP_GROUP_ADDTO, \"Add to...\");\n    pChild3->AppendMenu(MF_STRING, ID_DROP_GROUP_REMOVE, \"Remove\");\n    pChild3->AppendMenu(MF_STRING, ID_DROP_GROUP_NAME, \"Name...\");\n    pChild3->AppendMenu(MF_SEPARATOR, nID++, \"\");\n    pChild3->AppendMenu(MF_STRING, ID_DROP_GROUP_NEWGROUP, \"New Group...\");\n    m_mnuDrop.AppendMenu(MF_POPUP, reinterpret_cast<unsigned int>(pChild3->GetSafeHmenu()), \"Group\");\n    m_mnuDrop.AppendMenu(MF_SEPARATOR, nID++, \"\");\n\n    m_mnuDrop.AppendMenu(MF_STRING, ID_SELECTION_UNGROUPENTITY, \"Ungroup Entity\");\n    m_mnuDrop.AppendMenu(MF_STRING, ID_SELECTION_MAKE_DETAIL, \"Make Detail\");\n    m_mnuDrop.AppendMenu(MF_STRING, ID_SELECTION_MAKE_STRUCTURAL, \"Make Structural\");\n    m_mnuDrop.AppendMenu(MF_SEPARATOR, nID++, \"\");\n\n    CMenu* pChild = new CMenu;\n    pChild->CreateMenu();\n    pChild->AppendMenu(MF_STRING, nID++, \"Smart_Train\");\n    //pChild->AppendMenu(MF_STRING, nID++, \"Smart_Rotating\");\n    m_mnuDrop.AppendMenu(MF_POPUP, reinterpret_cast<unsigned int>(pChild->GetSafeHmenu()), \"Smart Entities\");\n    m_mnuDrop.AppendMenu(MF_SEPARATOR, nID++, \"\");\n\n    pChild = NULL;\n\t  eclass_t\t*e;\n    CString strActive;\n    CString strLast;\n    CString strName;\n\t  for (e=eclass ; e ; e=e->next)\n    {\n      strLast = strName;\n      strName = e->name;\n      int n_ = strName.Find(\"_\");\n      if (n_ > 0)\n      {\n        CString strLeft = strName.Left(n_);\n        CString strRight = strName.Right(strName.GetLength() - n_ - 1);\n        if (strLeft == strActive) // this is a child\n        {\n          ASSERT(pChild);\n          pChild->AppendMenu(MF_STRING, nID++, strName);\n        }\n        else\n        {\n          if (pChild)\n          {\n            m_mnuDrop.AppendMenu(MF_POPUP, reinterpret_cast<unsigned int>(pChild->GetSafeHmenu()), strActive);\n            g_ptrMenus.Add(pChild);\n            //pChild->DestroyMenu();\n            //delete pChild;\n            pChild = NULL;\n          }\n          strActive = strLeft;\n          pChild = new CMenu;\n          pChild->CreateMenu();\n          pChild->AppendMenu(MF_STRING, nID++, strName);\n        }\n      }\n      else\n      {\n        if (pChild)\n        {\n          m_mnuDrop.AppendMenu(MF_POPUP, reinterpret_cast<unsigned int>(pChild->GetSafeHmenu()), strActive);\n          g_ptrMenus.Add(pChild);\n          //pChild->DestroyMenu();\n          //delete pChild;\n          pChild = NULL;\n        }\n        strActive = \"\";\n        m_mnuDrop.AppendMenu(MF_STRING, nID++, strName);\n      }\n    }\n  }\n\n  CPoint ptMouse;\n  GetCursorPos(&ptMouse);\n  m_mnuDrop.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON, ptMouse.x, ptMouse.y, this);\n}\n\nvoid CXYWnd::XY_Init()\n{\n\tm_vOrigin[0] = 0;\n\tm_vOrigin[1] = 20;\n  m_vOrigin[2] = 46;\n  m_fScale = 1;\n}\n\nvoid CXYWnd::SnapToPoint (int x, int y, vec3_t point)\n{\n  if (g_PrefsDlg.m_bNoClamp)\n  {\n    XY_ToPoint(x, y, point);\n  }\n  else\n  {\n    XY_ToGridPoint(x, y, point);\n  }\n//--  else\n//--    XY_ToPoint(x, y, point);\n//--    //XY_ToPoint(x, y, point);\n}\n\n\nvoid CXYWnd::XY_ToPoint (int x, int y, vec3_t point)\n{\n  float fx = x;\n  float fy = y;\n  float fw = m_nWidth;\n  float fh = m_nHeight;\n  if (m_nViewType == XY)\n  {\n\t  point[0] = m_vOrigin[0] + (fx - fw / 2) / m_fScale;\n\t  point[1] = m_vOrigin[1] + (fy - fh / 2) / m_fScale;\n\t  //point[2] = 0;\n  }\n  else if (m_nViewType == YZ)\n  {\n    ////point[0] = 0;\n\t  //point[1] = m_vOrigin[0] + (fx - fw / 2) / m_fScale;\n\t  //point[2] = m_vOrigin[1] + (fy - fh / 2 ) / m_fScale;\n\t  point[1] = m_vOrigin[1] + (fx - fw / 2) / m_fScale;\n\t  point[2] = m_vOrigin[2] + (fy - fh / 2 ) / m_fScale;\n  }\n  else\n  {\n\t  //point[0] = m_vOrigin[0] + (fx - fw / 2) / m_fScale;\n\t  ////point[1] = 0;\n\t  //point[2] = m_vOrigin[1] + (fy - fh / 2) / m_fScale;\n\t  point[0] = m_vOrigin[0] + (fx - fw / 2) / m_fScale;\n\t  //point[1] = 0;\n\t  point[2] = m_vOrigin[2] + (fy - fh / 2) / m_fScale;\n  }\n}\n\n\nvoid CXYWnd::XY_ToGridPoint (int x, int y, vec3_t point)\n{\n  if (m_nViewType == XY)\n  {\n\t  point[0] = m_vOrigin[0] + (x - m_nWidth / 2) / m_fScale;\n\t  point[1] = m_vOrigin[1] + (y - m_nHeight / 2) / m_fScale;\n\t  //point[2] = 0;\n\t  point[0] = floor(point[0] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize;\n\t  point[1] = floor(point[1] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize;\n  }\n  else if (m_nViewType == YZ)\n  {\n\t  //point[0] = 0;\n\t  //point[1] = m_vOrigin[0] + (x - m_nWidth / 2) / m_fScale;\n\t  //point[2] = m_vOrigin[1] + (y - m_nHeight / 2) / m_fScale;\n\t  point[1] = m_vOrigin[1] + (x - m_nWidth / 2) / m_fScale;\n\t  point[2] = m_vOrigin[2] + (y - m_nHeight / 2) / m_fScale;\n\t  point[1] = floor(point[1] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize;\n\t  point[2] = floor(point[2] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize;\n  }\n  else\n  {\n\t  //point[1] = 0;\n\t  //point[0] = m_vOrigin[0] + (x - m_nWidth / 2) / m_fScale;\n\t  //point[2] = m_vOrigin[1] + (y - m_nHeight / 2) / m_fScale;\n\t  point[0] = m_vOrigin[0] + (x - m_nWidth / 2) / m_fScale;\n\t  point[2] = m_vOrigin[2] + (y - m_nHeight / 2) / m_fScale;\n\t  point[0] = floor(point[0] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize;\n\t  point[2] = floor(point[2] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize;\n  }\n}\n\n\nvoid CXYWnd::XY_MouseDown (int x, int y, int buttons)\n{\n\n\tvec3_t\tpoint;\n\tvec3_t\torigin, dir, right, up;\n\n\tm_nButtonstate = buttons;\n  m_nPressx = x;\n\tm_nPressy = y;\n\tVectorCopy (vec3_origin, m_vPressdelta);\n\n\tXY_ToPoint (x, y, point);\n\t\n  VectorCopy (point, origin);\n\n\tdir[0] = 0; dir[1] = 0; dir[2] = 0;\n  if (m_nViewType == XY)\n  {\n\t  origin[2] = 8192;\n    dir[2] = -1;\n  \tright[0] = 1 / m_fScale; \n    right[1] = 0; \n    right[2] = 0;\n\t  up[0] = 0; \n    up[1] = 1 / m_fScale;\n    up[2] = 0;\n  }\n  else if (m_nViewType == YZ)\n  {\n    origin[0] = 8192;\n    dir[0] = -1;\n  \tright[1] = 1 / m_fScale; \n    right[2] = 0; \n    right[0] = 0;\n   \tup[0] = 0; \n    up[2] = 1 / m_fScale;\n    up[1] = 0;\n  }\n  else\n  {\n    origin[1] = 8192;\n    dir[1] = -1;\n  \tright[0] = 1 / m_fScale;\n    right[2] = 0; \n    right[1] = 0;\n\t  up[0] = 0; \n    up[2] = 1 / m_fScale;\n    up[1] = 0;\n  }\n\n\n\tm_bPress_selection = (selected_brushes.next != &selected_brushes);\n\n  GetCursorPos(&m_ptCursor);\n\t//Sys_GetCursorPos (&m_ptCursor.x, &m_ptCursor.y);\n\n\t// lbutton = manipulate selection\n\t// shift-LBUTTON = select\n\tif ( (buttons == MK_LBUTTON)\n\t\t|| (buttons == (MK_LBUTTON | MK_SHIFT))\n\t\t|| (buttons == (MK_LBUTTON | MK_CONTROL))\n\t\t|| (buttons == (MK_LBUTTON | MK_CONTROL | MK_SHIFT)) )\n\t{\t\n\t\tif (g_qeglobals.d_select_mode == sel_addpoint) {\n\t\t\tXY_ToGridPoint(x, y, point);\n\t\t\tif (g_qeglobals.selectObject) {\n\t\t\t\tg_qeglobals.selectObject->addPoint(point[0], point[1], point[2]);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n    Patch_SetView( (m_nViewType == XY) ? W_XY : (m_nViewType == YZ) ? W_YZ : W_XZ);\n\t\tDrag_Begin (x, y, buttons, right, up,\torigin, dir);\n\t\treturn;\n\t}\n\n  int nMouseButton = g_PrefsDlg.m_nMouseButtons == 2 ? MK_RBUTTON : MK_MBUTTON;\n\n\t// control mbutton = move camera\n\tif (m_nButtonstate == (MK_CONTROL|nMouseButton) )\n\t{\t\n\t  VectorCopyXY(point, g_pParentWnd->GetCamera()->Camera().origin);\n\t\tSys_UpdateWindows (W_CAMERA|W_XY_OVERLAY);\n\t}\n\n\t// mbutton = angle camera\n\tif ((g_PrefsDlg.m_nMouseButtons == 3 && m_nButtonstate == MK_MBUTTON) ||\n      (g_PrefsDlg.m_nMouseButtons == 2 && m_nButtonstate == (MK_SHIFT|MK_CONTROL|MK_RBUTTON)))\n\t{\t\n\t\tVectorSubtract (point, g_pParentWnd->GetCamera()->Camera().origin, point);\n\n    int n1 = (m_nViewType == XY) ? 1 : 2;\n    int n2 = (m_nViewType == YZ) ? 1 : 0;\n    int nAngle = (m_nViewType == XY) ? YAW : PITCH;\n    if (point[n1] || point[n2])\n    {\n\t\t  g_pParentWnd->GetCamera()->Camera().angles[nAngle] = 180/Q_PI*atan2 (point[n1], point[n2]);\n\t\t  Sys_UpdateWindows (W_CAMERA_IFON|W_XY_OVERLAY);\n    }\n\t}\n\n\t// shift mbutton = move z checker\n\tif (m_nButtonstate == (MK_SHIFT | nMouseButton))\n\t{\n    if (RotateMode() || g_bPatchBendMode)\n    {\n\t\t  SnapToPoint (x, y, point);\n\t    VectorCopyXY(point, g_vRotateOrigin);\n      if (g_bPatchBendMode)\n      {\n        VectorCopy(point, g_vBendOrigin);\n      }\n\t\t  Sys_UpdateWindows (W_XY);\n      return;\n    }\n    else\n    {\n\t\t  SnapToPoint (x, y, point);\n      if (m_nViewType == XY)\n      {\n\t\t    z.origin[0] = point[0];\n\t\t    z.origin[1] = point[1];\n      }\n      else if (m_nViewType == YZ)\n      {\n\t\t    z.origin[0] = point[1];\n\t\t    z.origin[1] = point[2];\n      }\n      else\n      {\n\t\t    z.origin[0] = point[0];\n\t\t    z.origin[1] = point[2];\n      }\n\t\t  Sys_UpdateWindows (W_XY_OVERLAY|W_Z);\n\t\t  return;\n    }\n\t}\n}\n\n\nvoid CXYWnd::XY_MouseUp(int x, int y, int buttons)\n{\n\tDrag_MouseUp (buttons);\n\tif (!m_bPress_selection)\n\t\tSys_UpdateWindows (W_ALL);\n\tm_nButtonstate = 0;\n  while (::ShowCursor(TRUE) < 0)\n    ;\n}\n\nqboolean CXYWnd::DragDelta (int x, int y, vec3_t move)\n{\n\tvec3_t\txvec, yvec, delta;\n\tint\t\ti;\n\n\txvec[0] = 1 / m_fScale;\n\txvec[1] = xvec[2] = 0;\n\tyvec[1] = 1 / m_fScale;\n\tyvec[0] = yvec[2] = 0;\n\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tdelta[i] = xvec[i] * (x - m_nPressx) + yvec[i] * (y - m_nPressy);\n    if (!g_PrefsDlg.m_bNoClamp)\n    {\n\t\t  delta[i] = floor(delta[i] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize;\n    }\n\t}\n\tVectorSubtract (delta, m_vPressdelta, move);\n\tVectorCopy (delta, m_vPressdelta);\n\n\tif (move[0] || move[1] || move[2])\n\t\treturn true;\n\treturn false;\n}\n\n\n/*\n==============\nNewBrushDrag\n==============\n*/\nvoid CXYWnd::NewBrushDrag (int x, int y)\n{\n\tvec3_t\tmins, maxs, junk;\n\tint\t\ti;\n\tfloat\ttemp;\n\tbrush_t\t*n;\n\n\tif (!DragDelta (x,y, junk))\n\t\treturn;\n\n  // delete the current selection\n\tif (selected_brushes.next != &selected_brushes)\n\t\tBrush_Free (selected_brushes.next);\n\t\n  SnapToPoint (m_nPressx, m_nPressy, mins);\n\n  int nDim = (m_nViewType == XY) ? 2 : (m_nViewType == YZ) ? 0 : 1;\n\n\tmins[nDim] = g_qeglobals.d_gridsize * ((int)(g_qeglobals.d_new_brush_bottom_z / g_qeglobals.d_gridsize));\n\tSnapToPoint (x, y, maxs);\n\tmaxs[nDim] = g_qeglobals.d_gridsize * ((int)(g_qeglobals.d_new_brush_top_z / g_qeglobals.d_gridsize));\n\tif (maxs[nDim] <= mins[nDim])\n\t\tmaxs[nDim] = mins[nDim] + g_qeglobals.d_gridsize;\n\n\tfor (i=0 ; i<3 ; i++)\n\t{\n\t\tif (mins[i] == maxs[i])\n\t\t\treturn;\t// don't create a degenerate brush\n\t\tif (mins[i] > maxs[i])\n\t\t{\n\t\t\ttemp = mins[i];\n\t\t\tmins[i] = maxs[i];\n\t\t\tmaxs[i] = temp;\n\t\t}\n\t}\n\n\tn = Brush_Create (mins, maxs, &g_qeglobals.d_texturewin.texdef);\n\tif (!n)\n\t\treturn;\n\n  vec3_t vSize;\n  VectorSubtract(maxs, mins, vSize);\n  g_strStatus.Format(\"Size X:: %.1f  Y:: %.1f  Z:: %.1f\", vSize[0], vSize[1], vSize[2]);\n  g_pParentWnd->SetStatusText(2, g_strStatus);\n\n\tBrush_AddToList (n, &selected_brushes);\n\n\tEntity_LinkBrush (world_entity, n);\n\n\tBrush_Build( n );\n\n  //\tSys_UpdateWindows (W_ALL);\n\tSys_UpdateWindows (W_XY| W_CAMERA);\n\n}\n\n/*\n==============\nXY_MouseMoved\n==============\n*/\nvoid CXYWnd::XY_MouseMoved (int x, int y, int buttons)\n{\n\tvec3_t\tpoint;\n\n\n\tif (!m_nButtonstate)\n  {\n    if (g_bCrossHairs)\n    {\n      ::ShowCursor(FALSE);\n  \t\tSys_UpdateWindows (W_XY | W_XY_OVERLAY);\n      ::ShowCursor(TRUE);\n    }\n\t\treturn;\n  }\n\n\t// lbutton without selection = drag new brush\n\t//if (m_nButtonstate == MK_LBUTTON && !m_bPress_selection && g_qeglobals.d_select_mode != sel_curvepoint && g_qeglobals.d_select_mode != sel_splineedit)\n\tif (m_nButtonstate == MK_LBUTTON && !m_bPress_selection && g_qeglobals.d_select_mode == sel_brush)\n\t{\n\t\tNewBrushDrag (x, y);\n\t\treturn;\n\t}\n\n\t// lbutton (possibly with control and or shift)\n\t// with selection = drag selection\n\tif (m_nButtonstate & MK_LBUTTON)\n\t{\n\t\tDrag_MouseMoved (x, y, buttons);\n\t\tSys_UpdateWindows (W_XY_OVERLAY | W_CAMERA_IFON | W_Z);\n\t\treturn;\n\t}\n\n  int nMouseButton = g_PrefsDlg.m_nMouseButtons == 2 ? MK_RBUTTON : MK_MBUTTON;\n\t// control mbutton = move camera\n\tif (m_nButtonstate == (MK_CONTROL|nMouseButton) )\n\t{\n\t\tSnapToPoint (x, y, point);\n\t  VectorCopyXY(point, g_pParentWnd->GetCamera()->Camera().origin);\n\t\tSys_UpdateWindows (W_XY_OVERLAY | W_CAMERA);\n\t\treturn;\n\t}\n\n\t// shift mbutton = move z checker\n\tif (m_nButtonstate == (MK_SHIFT|nMouseButton) )\n\t{\n    if (RotateMode() || g_bPatchBendMode)\n    {\n\t\t  SnapToPoint (x, y, point);\n\t    VectorCopyXY(point, g_vRotateOrigin);\n      if (g_bPatchBendMode)\n      {\n        VectorCopy(point, g_vBendOrigin);\n      }\n\t\t  Sys_UpdateWindows (W_XY);\n      return;\n    }\n    else\n    {\n\t\t  SnapToPoint (x, y, point);\n      if (m_nViewType == XY)\n      {\n\t\t    z.origin[0] = point[0];\n\t\t    z.origin[1] = point[1];\n      }\n      else if (m_nViewType == YZ)\n      {\n\t\t    z.origin[0] = point[1];\n\t\t    z.origin[1] = point[2];\n      }\n      else\n      {\n\t\t    z.origin[0] = point[0];\n\t\t    z.origin[1] = point[2];\n      }\n    }\n\t\tSys_UpdateWindows (W_XY_OVERLAY|W_Z);\n\t\treturn;\n\t}\n\n\t// mbutton = angle camera\n\tif ((g_PrefsDlg.m_nMouseButtons == 3 && m_nButtonstate == MK_MBUTTON) ||\n      (g_PrefsDlg.m_nMouseButtons == 2 && m_nButtonstate == (MK_SHIFT|MK_CONTROL|MK_RBUTTON)))\n\t{\t\n\t\tSnapToPoint (x, y, point);\n\t\tVectorSubtract (point, g_pParentWnd->GetCamera()->Camera().origin, point);\n\n    int n1 = (m_nViewType == XY) ? 1 : 2;\n    int n2 = (m_nViewType == YZ) ? 1 : 0;\n    int nAngle = (m_nViewType == XY) ? YAW : PITCH;\n    if (point[n1] || point[n2])\n    {\n\t\t  g_pParentWnd->GetCamera()->Camera().angles[nAngle] = 180/Q_PI*atan2 (point[n1], point[n2]);\n\t\t  Sys_UpdateWindows (W_CAMERA_IFON|W_XY_OVERLAY);\n    }\n\t\treturn;\n\t}\n\n\n\t// rbutton = drag xy origin\n\tif (m_nButtonstate == MK_RBUTTON)\n\t{\n\t\tSys_GetCursorPos (&x, &y);\n\t\tif (x != m_ptCursor.x || y != m_ptCursor.y)\n\t\t{\n      int nDim1 = (m_nViewType == YZ) ? 1 : 0;\n      int nDim2 = (m_nViewType == XY) ? 1 : 2;\n\t\t\tm_vOrigin[nDim1] -= (x - m_ptCursor.x) / m_fScale;\n\t\t\tm_vOrigin[nDim2] += (y - m_ptCursor.y) / m_fScale;\n\t    SetCursorPos (m_ptCursor.x, m_ptCursor.y);\n      ::ShowCursor(FALSE);\n      //XY_Draw();\n      //RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);\n\t\t\tSys_UpdateWindows (W_XY | W_XY_OVERLAY);\n      //::ShowCursor(TRUE);\n\t\t}\n\t\treturn;\n\t}\n\n}\n\n\n/*\n============================================================================\n\nDRAWING\n\n============================================================================\n*/\n\n\n/*\n==============\nXY_DrawGrid\n==============\n*/\nvoid CXYWnd::XY_DrawGrid()\n{\n\tfloat\tx, y, xb, xe, yb, ye;\n\tint\t\tw, h;\n\tchar\ttext[32];\n\n\tqglDisable(GL_TEXTURE_2D);\n\tqglDisable(GL_TEXTURE_1D);\n\tqglDisable(GL_DEPTH_TEST);\n\tqglDisable(GL_BLEND);\n\n\tw = m_nWidth / 2 / m_fScale;\n\th = m_nHeight / 2 / m_fScale;\n\n\n  int nDim1 = (m_nViewType == YZ) ? 1 : 0;\n  int nDim2 = (m_nViewType == XY) ? 1 : 2;\n  //int nDim1 = 0;\n  //int nDim2 = 1;\n\n\n\txb = m_vOrigin[nDim1] - w;\n\tif (xb < region_mins[nDim1])\n\t\txb = region_mins[nDim1];\n\txb = 64 * floor (xb/64);\n\n\txe = m_vOrigin[nDim1] + w;\n\tif (xe > region_maxs[nDim1])\n\t\txe = region_maxs[nDim1];\n\txe = 64 * ceil (xe/64);\n\n\tyb = m_vOrigin[nDim2] - h;\n\tif (yb < region_mins[nDim2])\n\t\tyb = region_mins[nDim2];\n\tyb = 64 * floor (yb/64);\n\n\tye = m_vOrigin[nDim2] + h;\n\tif (ye > region_maxs[nDim2])\n\t\tye = region_maxs[nDim2];\n\tye = 64 * ceil (ye/64);\n\n\t// draw major blocks\n\n\tqglColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR]);\n\n\tint stepSize = 64 * 0.1 / m_fScale;\n\tif (stepSize < 64) {\n\t\tstepSize = 64;\n\t} else {\n\t\tint i;\n\t\tfor (i = 1; i < stepSize; i <<= 1) {\n\t\t}\n\t\tstepSize = i;\n\t}\n\n\tif ( g_qeglobals.d_showgrid )\n\t{\n\t\t\n\t\tqglBegin (GL_LINES);\n\t\t\n\t\tfor (x=xb ; x<=xe ; x+=stepSize)\n\t\t{\n\t\t\tqglVertex2f (x, yb);\n\t\t\tqglVertex2f (x, ye);\n\t\t}\n\t\tfor (y=yb ; y<=ye ; y+=stepSize)\n\t\t{\n\t\t\tqglVertex2f (xb, y);\n\t\t\tqglVertex2f (xe, y);\n\t\t}\n\t\t\n\t\tqglEnd ();\n\t\t\n\t}\n\n\t// draw minor blocks\n\tif ( m_fScale > .1 && g_qeglobals.d_showgrid && g_qeglobals.d_gridsize * m_fScale >= 4 && \n       g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR] != g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK])\n\t{\n\t\tqglColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR]);\n\n\t\tqglBegin (GL_LINES);\n\t\tfor (x=xb ; x<xe ; x += g_qeglobals.d_gridsize)\n\t\t{\n\t\t\tif ( ! ((int)x & 63) )\n\t\t\t\tcontinue;\n\t\t\tqglVertex2f (x, yb);\n\t\t\tqglVertex2f (x, ye);\n\t\t}\n\t\tfor (y=yb ; y<ye ; y+=g_qeglobals.d_gridsize)\n\t\t{\n\t\t\tif ( ! ((int)y & 63) )\n\t\t\t\tcontinue;\n\t\t\tqglVertex2f (xb, y);\n\t\t\tqglVertex2f (xe, y);\n\t\t}\n\t\tqglEnd ();\n\t}\n\n\t// draw coordinate text if needed\n\n\tif ( g_qeglobals.d_savedinfo.show_coordinates)\n\t{\n\t\t//glColor4f(0, 0, 0, 0);\n\t\tqglColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT]);\n\n\t\tfor (x=xb ; x<xe ; x+=stepSize)\n\t\t{\n\t\t\tqglRasterPos2f (x, m_vOrigin[nDim2] + h - 6 / m_fScale);\n\t\t\tsprintf (text, \"%i\",(int)x);\n\t\t\tqglCallLists (strlen(text), GL_UNSIGNED_BYTE, text);\n\t\t}\n\t\tfor (y=yb ; y<ye ; y+=stepSize)\n\t\t{\n\t\t\tqglRasterPos2f (m_vOrigin[nDim1] - w + 1, y);\n\t\t\tsprintf (text, \"%i\",(int)y);\n\t\t\tqglCallLists (strlen(text), GL_UNSIGNED_BYTE, text);\n\t\t}\n\n\n    if (Active())\n\t\t  qglColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME]);\n\n    qglRasterPos2f ( m_vOrigin[nDim1] - w + 35 / m_fScale, m_vOrigin[nDim2] + h - 20 / m_fScale );\n\n    char cView[20];\n    if (m_nViewType == XY)\n      strcpy(cView, \"XY Top\");\n    else \n    if (m_nViewType == XZ)\n      strcpy(cView, \"XZ Front\");\n    else\n      strcpy(cView, \"YZ Side\");\n\n\t\tqglCallLists (strlen(cView), GL_UNSIGNED_BYTE, cView);\n    \n\n  }\n\n\n/*\n  if (true)\n  {\n\t\tqglColor3f(g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR]);\n\t\tqglBegin (GL_LINES);\n  \tqglVertex2f (x, yb);\n\t\tqglVertex2f (x, ye);\n    qglEnd();\n  }\n  */\n\n}\n\n/*\n==============\nXY_DrawBlockGrid\n==============\n*/\nvoid CXYWnd::XY_DrawBlockGrid()\n{\n\tfloat\tx, y, xb, xe, yb, ye;\n\tint\t\tw, h;\n\tchar\ttext[32];\n\n\tqglDisable(GL_TEXTURE_2D);\n\tqglDisable(GL_TEXTURE_1D);\n\tqglDisable(GL_DEPTH_TEST);\n\tqglDisable(GL_BLEND);\n\n\tw = m_nWidth / 2 / m_fScale;\n\th = m_nHeight / 2 / m_fScale;\n\n  int nDim1 = (m_nViewType == YZ) ? 1 : 0;\n  int nDim2 = (m_nViewType == XY) ? 1 : 2;\n\n  xb = m_vOrigin[nDim1] - w;\n\tif (xb < region_mins[nDim1])\n\t\txb = region_mins[nDim1];\n\txb = 1024 * floor (xb/1024);\n\n\txe = m_vOrigin[nDim1] + w;\n\tif (xe > region_maxs[nDim1])\n\t\txe = region_maxs[nDim1];\n\txe = 1024 * ceil (xe/1024);\n\n\tyb = m_vOrigin[nDim2] - h;\n\tif (yb < region_mins[nDim2])\n\t\tyb = region_mins[nDim2];\n\tyb = 1024 * floor (yb/1024);\n\n\tye = m_vOrigin[nDim2] + h;\n\tif (ye > region_maxs[nDim2])\n\t\tye = region_maxs[nDim2];\n\tye = 1024 * ceil (ye/1024);\n\n\t// draw major blocks\n\n  qglColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK]);\n\tqglLineWidth (2);\n\n\tqglBegin (GL_LINES);\n\t\n\tfor (x=xb ; x<=xe ; x+=1024)\n\t{\n\t\tqglVertex2f (x, yb);\n\t\tqglVertex2f (x, ye);\n\t}\n\tfor (y=yb ; y<=ye ; y+=1024)\n\t{\n\t\tqglVertex2f (xb, y);\n\t\tqglVertex2f (xe, y);\n\t}\n\t\n\tqglEnd ();\n\tqglLineWidth (1);\n\n\t// draw coordinate text if needed\n\n\tfor (x=xb ; x<xe ; x+=1024)\n\t\tfor (y=yb ; y<ye ; y+=1024)\n\t\t{\n\t\t\tqglRasterPos2f (x+512, y+512);\n\t\t\tsprintf (text, \"%i,%i\",(int)floor(x/1024), (int)floor(y/1024) );\n\t\t\tqglCallLists (strlen(text), GL_UNSIGNED_BYTE, text);\n\t\t}\n\n\tqglColor4f(0, 0, 0, 0);\n}\n\nvoid CXYWnd::DrawRotateIcon()\n{\n\tfloat\tx, y;\n\n  if (m_nViewType == XY)\n  {\n    x = g_vRotateOrigin[0];\n    y = g_vRotateOrigin[1];\n  }\n  else if (m_nViewType == YZ)\n  {\n    x = g_vRotateOrigin[1];\n    y = g_vRotateOrigin[2];\n  }\n  else\n  {\n    x = g_vRotateOrigin[0];\n    y = g_vRotateOrigin[2];\n  }\n\n\tqglEnable (GL_BLEND);\n\tqglDisable (GL_TEXTURE_2D);\n\tqglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);\n\tqglDisable (GL_CULL_FACE);\n\tqglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\n\tqglColor4f (0.8, 0.1, 0.9, 0.25);\n\n  qglBegin(GL_QUADS);\n\tqglVertex3f (x-4,y-4,0);\n\tqglVertex3f (x+4,y-4,0);\n\tqglVertex3f (x+4,y+4,0);\n\tqglVertex3f (x-4,y+4,0);\n\tqglEnd ();\n\tqglDisable (GL_BLEND);\n\n\tqglColor4f (1.0, 0.2, 1.0, 1);\n\tqglBegin(GL_POINTS);\n\tqglVertex3f (x,y,0);\n\tqglEnd ();\n\n#if 0\n\tqglBegin(GL_LINES);\n\tqglVertex3f (x-6,y+6,0);\n\tqglVertex3f (x+6,y+6,0);\n\tqglVertex3f (x-6,y-6,0);\n\tqglVertex3f (x+6,y-6,0);\n\tqglEnd ();\n#endif\n\n}\n\nvoid CXYWnd::DrawCameraIcon()\n{\n\tfloat\tx, y, a;\n\n  if (m_nViewType == XY)\n  {\n    x = g_pParentWnd->GetCamera()->Camera().origin[0];\n\t\ty = g_pParentWnd->GetCamera()->Camera().origin[1];\n\t  a = g_pParentWnd->GetCamera()->Camera().angles[YAW]/180*Q_PI;\n  }\n  else if (m_nViewType == YZ)\n  {\n\t  x = g_pParentWnd->GetCamera()->Camera().origin[1];\n\t\ty = g_pParentWnd->GetCamera()->Camera().origin[2];\n\t  a = g_pParentWnd->GetCamera()->Camera().angles[PITCH]/180*Q_PI;\n  }\n  else\n  {\n\t  x = g_pParentWnd->GetCamera()->Camera().origin[0];\n\t\ty = g_pParentWnd->GetCamera()->Camera().origin[2];\n\t  a = g_pParentWnd->GetCamera()->Camera().angles[PITCH]/180*Q_PI;\n  }\n\n\tqglColor3f (0.0, 0.0, 1.0);\n\tqglBegin(GL_LINE_STRIP);\n\tqglVertex3f (x-16,y,0);\n\tqglVertex3f (x,y+8,0);\n\tqglVertex3f (x+16,y,0);\n\tqglVertex3f (x,y-8,0);\n\tqglVertex3f (x-16,y,0);\n\tqglVertex3f (x+16,y,0);\n\tqglEnd ();\n\t\n\tqglBegin(GL_LINE_STRIP);\n\tqglVertex3f (x+48*cos(a+Q_PI/4), y+48*sin(a+Q_PI/4), 0);\n\tqglVertex3f (x, y, 0);\n\tqglVertex3f (x+48*cos(a-Q_PI/4), y+48*sin(a-Q_PI/4), 0);\n\tqglEnd ();\n\n#if 0\n  char text[128];\n\tqglRasterPos2f (x+64, y+64);\n\tsprintf (text, \"%f\",g_pParentWnd->GetCamera()->Camera().angles[YAW]);\n\tqglCallLists (strlen(text), GL_UNSIGNED_BYTE, text);\n#endif\n\n}\n\nvoid CXYWnd::DrawZIcon (void)\n{\n  if (m_nViewType == XY)\n  {\n\t  float x = z.origin[0];\n\t  float y = z.origin[1];\n\t  qglEnable (GL_BLEND);\n\t  qglDisable (GL_TEXTURE_2D);\n\t  qglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);\n\t  qglDisable (GL_CULL_FACE);\n\t  qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\n\t  qglColor4f (0.0, 0.0, 1.0, 0.25);\n\t  qglBegin(GL_QUADS);\n\t  qglVertex3f (x-8,y-8,0);\n\t  qglVertex3f (x+8,y-8,0);\n\t  qglVertex3f (x+8,y+8,0);\n\t  qglVertex3f (x-8,y+8,0);\n\t  qglEnd ();\n\t  qglDisable (GL_BLEND);\n\n\t  qglColor4f (0.0, 0.0, 1.0, 1);\n\n\t  qglBegin(GL_LINE_LOOP);\n\t  qglVertex3f (x-8,y-8,0);\n\t  qglVertex3f (x+8,y-8,0);\n\t  qglVertex3f (x+8,y+8,0);\n\t  qglVertex3f (x-8,y+8,0);\n\t  qglEnd ();\n\n    qglBegin(GL_LINE_STRIP);\n\t  qglVertex3f (x-4,y+4,0);\n\t  qglVertex3f (x+4,y+4,0);\n\t  qglVertex3f (x-4,y-4,0);\n\t  qglVertex3f (x+4,y-4,0);\n\t  qglEnd ();\n  }\n}\n\n\n/*\n==================\nFilterBrush\n==================\n*/\nBOOL FilterBrush(brush_t *pb)\n{\n\tif (!pb->owner)\n\t\treturn FALSE;\t\t// during construction\n\n  if (pb->hiddenBrush)\n  {\n    return TRUE;\n  }\n\n\tif (g_qeglobals.d_savedinfo.exclude & EXCLUDE_CAULK)\n  {\n    // filter out the brush only if all faces are caulk\n    // if not don't hide the whole brush, proceed on a per-face basis (Cam_Draw)\n    //++timo TODO: set this as a preference .. show caulk: hide any brush with caulk // don't draw caulk faces\n    face_t *f;\n    f=pb->brush_faces;\n    while (f)\n    {\n      if (!strstr(f->texdef.name, \"caulk\"))\n        break;\n      f = f->next;\n    }\n    if (!f)\n      return TRUE;\n\n#if 0\n    if (strstr(pb->brush_faces->texdef.name, \"caulk\"))\n      return TRUE;\n#endif\n\n    //++timo FIXME: .. same deal here?\n    if (strstr(pb->brush_faces->texdef.name, \"donotenter\"))\n      return TRUE;\n  }\n\n\tif (g_qeglobals.d_savedinfo.exclude & EXCLUDE_HINT)\n  {\n    if (strstr(pb->brush_faces->texdef.name, \"hint\"))\n      return TRUE;\n  }\n\n\tif (g_qeglobals.d_savedinfo.exclude & EXCLUDE_CLIP)\n\t{\n    if (strstr(pb->brush_faces->texdef.name, \"clip\"))\n      return TRUE;\n\n    if (strstr(pb->brush_faces->texdef.name, \"skip\"))\n      return TRUE;\n\n\t\t//if (!strncmp(pb->brush_faces->texdef.name, \"clip\", 4))\n\t\t//\treturn TRUE;\n\t}\n\n\tif (g_qeglobals.d_savedinfo.exclude & EXCLUDE_WATER)\n\t{\n\t\tfor (face_t* f = pb->brush_faces ; f ; f=f->next)\n    {\n      if (f->texdef.contents & (CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA))\n        return TRUE;\n    }\n\t}\n\n\tif (g_qeglobals.d_savedinfo.exclude & EXCLUDE_DETAIL)\n\t{\n\t\tif (pb->brush_faces->texdef.contents & CONTENTS_DETAIL)\n\t\t\treturn TRUE;\n\t}\n\n\tif (g_qeglobals.d_savedinfo.exclude & EXCLUDE_CURVES)\n\t{\n\t\tif (pb->patchBrush)\n\t\t\treturn TRUE;\n\t}\n\n\tif( g_qeglobals.d_savedinfo.exclude & EXCLUDE_TERRAIN )\n\t{\n\t\tif( pb->terrainBrush )\n\t\t{\n\t\t\treturn TRUE;\n\t\t}\n\t}\n\n\tif (pb->owner == world_entity)\n\t{\n\t\tif (g_qeglobals.d_savedinfo.exclude & EXCLUDE_WORLD)\n\t\t\treturn TRUE;\n\t\treturn FALSE;\n\t}\n\telse \n  {\n    if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_ENT)\n    {\n\t\t  return (strncmp(pb->owner->eclass->name, \"func_group\", 10));\n    }\n  }\n\n\tif (g_qeglobals.d_savedinfo.exclude & EXCLUDE_LIGHTS)\n\t{\n    return (pb->owner->eclass->nShowFlags & ECLASS_LIGHT);\n\t\t//if (!strncmp(pb->owner->eclass->name, \"light\", 5))\n\t\t//\treturn TRUE;\n\t}\n\n\tif (g_qeglobals.d_savedinfo.exclude & EXCLUDE_PATHS)\n\t{\n    return (pb->owner->eclass->nShowFlags & ECLASS_PATH);\n\t\t//if (!strncmp(pb->owner->eclass->name, \"path\", 4))\n\t\t//\treturn TRUE;\n\t}\n\n\treturn FALSE;\n}\n\n/*\n=============================================================\n\n  PATH LINES\n\n=============================================================\n*/\n\n/*\n==================\nDrawPathLines\n\nDraws connections between entities.\nNeeds to consider all entities, not just ones on screen,\nbecause the lines can be visible when neither end is.\nCalled for both camera view and xy view.\n==================\n*/\nvoid DrawPathLines (void)\n{\n\tint\t\ti, j, k;\n\tvec3_t\tmid, mid1;\n\tentity_t *se, *te;\n\tbrush_t\t*sb, *tb;\n\tchar\t*psz;\n\tvec3_t\tdir, s1, s2;\n\tvec_t\tlen, f;\n\tint\t\tarrows;\n\tint\t\t\tnum_entities;\n\tchar\t\t*ent_target[MAX_MAP_ENTITIES];\n\tentity_t\t*ent_entity[MAX_MAP_ENTITIES];\n\n\tif (g_qeglobals.d_savedinfo.exclude & EXCLUDE_PATHS)\n    return;\n\n\tnum_entities = 0;\n\tfor (te = entities.next ; te != &entities && num_entities != MAX_MAP_ENTITIES ; te = te->next)\n\t{\n\t\tent_target[num_entities] = ValueForKey (te, \"target\");\n\t\tif (ent_target[num_entities][0])\n\t\t{\n\t\t\tent_entity[num_entities] = te;\n\t\t\tnum_entities++;\n\t\t}\n\t}\n\n\tfor (se = entities.next ; se != &entities ; se = se->next)\n\t{\n\t\tpsz = ValueForKey(se, \"targetname\");\n\t\n\t\tif (psz == NULL || psz[0] == '\\0')\n\t\t\tcontinue;\n\t\t\n\t\tsb = se->brushes.onext;\n\t\tif (sb == &se->brushes)\n\t\t\tcontinue;\n\n\t\tfor (k=0 ; k<num_entities ; k++)\n\t\t{\n\t\tif (strcmp (ent_target[k], psz))\n\t\t\t\tcontinue;\n\n\t\t\tte = ent_entity[k];\n\t\t\ttb = te->brushes.onext;\n\t\t\tif (tb == &te->brushes)\n\t\t\t\tcontinue;\n\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t\tmid[i] = (sb->mins[i] + sb->maxs[i])*0.5; \n\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t\tmid1[i] = (tb->mins[i] + tb->maxs[i])*0.5; \n\n\t\t\tVectorSubtract (mid1, mid, dir);\n\t\t\tlen = VectorNormalize (dir);\n\t\t\ts1[0] = -dir[1]*8 + dir[0]*8;\n\t\t\ts2[0] = dir[1]*8 + dir[0]*8;\n\t\t\ts1[1] = dir[0]*8 + dir[1]*8;\n\t\t\ts2[1] = -dir[0]*8 + dir[1]*8;\n\n\t\t\tqglColor3f (se->eclass->color[0], se->eclass->color[1], se->eclass->color[2]);\n\n\t\t\tqglBegin(GL_LINES);\n\t\t\tqglVertex3fv(mid);\n\t\t\tqglVertex3fv(mid1);\n\n\t\t\tarrows = (int)(len / 256) + 1;\n\n\t\t\tfor (i=0 ; i<arrows ; i++)\n\t\t\t{\n\t\t\t\tf = len * (i + 0.5) / arrows;\n\n\t\t\t\tfor (j=0 ; j<3 ; j++)\n\t\t\t\t\tmid1[j] = mid[j] + f*dir[j];\n\t\t\t\tqglVertex3fv (mid1);\n\t\t\t\tqglVertex3f (mid1[0] + s1[0], mid1[1] + s1[1], mid1[2]);\n\t\t\t\tqglVertex3fv (mid1);\n\t\t\t\tqglVertex3f (mid1[0] + s2[0], mid1[1] + s2[1], mid1[2]);\n\t\t\t}\n\n\t\t\tqglEnd();\n\t\t}\n\t}\n\n\treturn;\n}\n\n//=============================================================\n\n// can be greatly simplified but per usual i am in a hurry \n// which is not an excuse, just a fact\nvoid CXYWnd::PaintSizeInfo(int nDim1, int nDim2, vec3_t vMinBounds, vec3_t vMaxBounds)\n{\n\n  vec3_t vSize;\n  VectorSubtract(vMaxBounds, vMinBounds, vSize);\n\n  qglColor3f(g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][0] * .65, \n            g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][1] * .65,\n            g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][2] * .65);\n\n  if (m_nViewType == XY)\n  {\n\t\tqglBegin (GL_LINES);\n\n    qglVertex3f(vMinBounds[nDim1], vMinBounds[nDim2] - 6.0f  / m_fScale, 0.0f);\n    qglVertex3f(vMinBounds[nDim1], vMinBounds[nDim2] - 10.0f / m_fScale, 0.0f);\n\n    qglVertex3f(vMinBounds[nDim1], vMinBounds[nDim2] - 10.0f  / m_fScale, 0.0f);\n    qglVertex3f(vMaxBounds[nDim1], vMinBounds[nDim2] - 10.0f  / m_fScale, 0.0f);\n\n    qglVertex3f(vMaxBounds[nDim1], vMinBounds[nDim2] - 6.0f  / m_fScale, 0.0f);\n    qglVertex3f(vMaxBounds[nDim1], vMinBounds[nDim2] - 10.0f / m_fScale, 0.0f);\n  \n\n    qglVertex3f(vMaxBounds[nDim1] + 6.0f  / m_fScale, vMinBounds[nDim2], 0.0f);\n    qglVertex3f(vMaxBounds[nDim1] + 10.0f  / m_fScale, vMinBounds[nDim2], 0.0f);\n\n    qglVertex3f(vMaxBounds[nDim1] + 10.0f  / m_fScale, vMinBounds[nDim2], 0.0f);\n    qglVertex3f(vMaxBounds[nDim1] + 10.0f  / m_fScale, vMaxBounds[nDim2], 0.0f);\n  \n    qglVertex3f(vMaxBounds[nDim1] + 6.0f  / m_fScale, vMaxBounds[nDim2], 0.0f);\n    qglVertex3f(vMaxBounds[nDim1] + 10.0f  / m_fScale, vMaxBounds[nDim2], 0.0f);\n\n    qglEnd();\n\n    qglRasterPos3f (Betwixt(vMinBounds[nDim1], vMaxBounds[nDim1]),  vMinBounds[nDim2] - 20.0  / m_fScale, 0.0f);\n    g_strDim.Format(g_pDimStrings[nDim1], vSize[nDim1]);\n\t  qglCallLists (g_strDim.GetLength(), GL_UNSIGNED_BYTE, g_strDim);\n    \n    qglRasterPos3f (vMaxBounds[nDim1] + 16.0  / m_fScale, Betwixt(vMinBounds[nDim2], vMaxBounds[nDim2]), 0.0f);\n    g_strDim.Format(g_pDimStrings[nDim2], vSize[nDim2]);\n\t  qglCallLists (g_strDim.GetLength(), GL_UNSIGNED_BYTE, g_strDim);\n\n    qglRasterPos3f (vMinBounds[nDim1] + 4, vMaxBounds[nDim2] + 8 / m_fScale, 0.0f);\n    g_strDim.Format(g_pOrgStrings[0], vMinBounds[nDim1], vMaxBounds[nDim2]);\n\t  qglCallLists (g_strDim.GetLength(), GL_UNSIGNED_BYTE, g_strDim);\n\n  }\n  else\n  if (m_nViewType == XZ)\n  {\n\t\tqglBegin (GL_LINES);\n\n    qglVertex3f(vMinBounds[nDim1], 0, vMinBounds[nDim2] - 6.0f  / m_fScale);\n    qglVertex3f(vMinBounds[nDim1], 0, vMinBounds[nDim2] - 10.0f / m_fScale);\n\n    qglVertex3f(vMinBounds[nDim1], 0,vMinBounds[nDim2] - 10.0f  / m_fScale);\n    qglVertex3f(vMaxBounds[nDim1], 0,vMinBounds[nDim2] - 10.0f  / m_fScale);\n\n    qglVertex3f(vMaxBounds[nDim1], 0,vMinBounds[nDim2] - 6.0f  / m_fScale);\n    qglVertex3f(vMaxBounds[nDim1], 0,vMinBounds[nDim2] - 10.0f / m_fScale);\n  \n\n    qglVertex3f(vMaxBounds[nDim1] + 6.0f  / m_fScale, 0,vMinBounds[nDim2]);\n    qglVertex3f(vMaxBounds[nDim1] + 10.0f  / m_fScale, 0,vMinBounds[nDim2]);\n\n    qglVertex3f(vMaxBounds[nDim1] + 10.0f  / m_fScale, 0,vMinBounds[nDim2]);\n    qglVertex3f(vMaxBounds[nDim1] + 10.0f  / m_fScale, 0,vMaxBounds[nDim2]);\n  \n    qglVertex3f(vMaxBounds[nDim1] + 6.0f  / m_fScale, 0,vMaxBounds[nDim2]);\n    qglVertex3f(vMaxBounds[nDim1] + 10.0f  / m_fScale, 0,vMaxBounds[nDim2]);\n\n    qglEnd();\n\n    qglRasterPos3f (Betwixt(vMinBounds[nDim1], vMaxBounds[nDim1]), 0, vMinBounds[nDim2] - 20.0  / m_fScale);\n    g_strDim.Format(g_pDimStrings[nDim1], vSize[nDim1]);\n\t  qglCallLists (g_strDim.GetLength(), GL_UNSIGNED_BYTE, g_strDim);\n    \n    qglRasterPos3f (vMaxBounds[nDim1] + 16.0  / m_fScale, 0, Betwixt(vMinBounds[nDim2], vMaxBounds[nDim2]));\n    g_strDim.Format(g_pDimStrings[nDim2], vSize[nDim2]);\n\t  qglCallLists (g_strDim.GetLength(), GL_UNSIGNED_BYTE, g_strDim);\n\n    qglRasterPos3f (vMinBounds[nDim1] + 4, 0, vMaxBounds[nDim2] + 8 / m_fScale);\n    g_strDim.Format(g_pOrgStrings[1], vMinBounds[nDim1], vMaxBounds[nDim2]);\n\t  qglCallLists (g_strDim.GetLength(), GL_UNSIGNED_BYTE, g_strDim);\n\n  }\n  else\n  {\n\t\tqglBegin (GL_LINES);\n\n    qglVertex3f(0, vMinBounds[nDim1], vMinBounds[nDim2] - 6.0f  / m_fScale);\n    qglVertex3f(0, vMinBounds[nDim1], vMinBounds[nDim2] - 10.0f / m_fScale);\n\n    qglVertex3f(0, vMinBounds[nDim1], vMinBounds[nDim2] - 10.0f  / m_fScale);\n    qglVertex3f(0, vMaxBounds[nDim1], vMinBounds[nDim2] - 10.0f  / m_fScale);\n\n    qglVertex3f(0, vMaxBounds[nDim1], vMinBounds[nDim2] - 6.0f  / m_fScale);\n    qglVertex3f(0, vMaxBounds[nDim1], vMinBounds[nDim2] - 10.0f / m_fScale);\n  \n\n    qglVertex3f(0, vMaxBounds[nDim1] + 6.0f  / m_fScale, vMinBounds[nDim2]);\n    qglVertex3f(0, vMaxBounds[nDim1] + 10.0f  / m_fScale, vMinBounds[nDim2]);\n\n    qglVertex3f(0, vMaxBounds[nDim1] + 10.0f  / m_fScale, vMinBounds[nDim2]);\n    qglVertex3f(0, vMaxBounds[nDim1] + 10.0f  / m_fScale, vMaxBounds[nDim2]);\n  \n    qglVertex3f(0, vMaxBounds[nDim1] + 6.0f  / m_fScale, vMaxBounds[nDim2]);\n    qglVertex3f(0, vMaxBounds[nDim1] + 10.0f  / m_fScale, vMaxBounds[nDim2]);\n\n    qglEnd();\n\n    qglRasterPos3f (0, Betwixt(vMinBounds[nDim1], vMaxBounds[nDim1]),  vMinBounds[nDim2] - 20.0  / m_fScale);\n    g_strDim.Format(g_pDimStrings[nDim1], vSize[nDim1]);\n\t  qglCallLists (g_strDim.GetLength(), GL_UNSIGNED_BYTE, g_strDim);\n    \n    qglRasterPos3f (0, vMaxBounds[nDim1] + 16.0  / m_fScale, Betwixt(vMinBounds[nDim2], vMaxBounds[nDim2]));\n    g_strDim.Format(g_pDimStrings[nDim2], vSize[nDim2]);\n\t  qglCallLists (g_strDim.GetLength(), GL_UNSIGNED_BYTE, g_strDim);\n\n    qglRasterPos3f (0, vMinBounds[nDim1] + 4.0, vMaxBounds[nDim2] + 8 / m_fScale);\n    g_strDim.Format(g_pOrgStrings[2], vMinBounds[nDim1], vMaxBounds[nDim2]);\n\t  qglCallLists (g_strDim.GetLength(), GL_UNSIGNED_BYTE, g_strDim);\n\n  }\n}\n\n\n\n/*\n==============\nXY_Draw\n==============\n*/\nlong g_lCount = 0;\nlong g_lTotal = 0;\nextern void DrawBrushEntityName (brush_t *b);\n\nvoid CXYWnd::XY_Draw()\n{\n  brush_t\t*brush;\n\tfloat\tw, h;\n\tentity_t\t*e;\n\tdouble\tstart, end;\n\tdouble\tstart2, end2;\n\tvec3_t\tmins, maxs;\n\tint\t\tdrawn, culled;\n\tint\t\ti;\n\n\tif (!active_brushes.next)\n\t\treturn;\t// not valid yet\n\n\tif (m_bTiming)\n\t\tstart = Sys_DoubleTime();\n\t//\n\t// clear\n\t//\n\tm_bDirty = false;\n\n\tqglViewport(0, 0, m_nWidth, m_nHeight);\n\tqglClearColor (g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][0],\n\t\t            g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][1],\n\t\t            g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][2],0);\n\n  qglClear(GL_COLOR_BUFFER_BIT);\n\n\t//\n\t// set up viewpoint\n\t//\n\tqglMatrixMode(GL_PROJECTION);\n  qglLoadIdentity ();\n\n\tw = m_nWidth / 2 / m_fScale;\n\th = m_nHeight / 2/ m_fScale;\n  int nDim1 = (m_nViewType == YZ) ? 1 : 0;\n  int nDim2 = (m_nViewType == XY) ? 1 : 2;\n\tmins[0] = m_vOrigin[nDim1] - w;\n\tmaxs[0] = m_vOrigin[nDim1] + w;\n\tmins[1] = m_vOrigin[nDim2] - h;\n\tmaxs[1] = m_vOrigin[nDim2] + h;\n\n\n\tqglOrtho (mins[0], maxs[0], mins[1], maxs[1], -8192, 8192);\n  //glRotatef\n\t//\n\t// now draw the grid\n\t//\n\tXY_DrawGrid ();\n\n\t//\n\t// draw stuff\n\t//\n  qglShadeModel (GL_FLAT);\n\tqglDisable(GL_TEXTURE_2D);\n\tqglDisable(GL_TEXTURE_1D);\n\tqglDisable(GL_DEPTH_TEST);\n\tqglDisable(GL_BLEND);\n\tqglColor3f(0, 0, 0);\n\n  //glEnable (GL_LINE_SMOOTH);\n\n\tdrawn = culled = 0;\n\n  if (m_nViewType != XY)\n  {\n    qglPushMatrix();\n    if (m_nViewType == YZ)\n      qglRotatef (-90,  0, 1, 0);\t    // put Z going up\n    //else\n      qglRotatef (-90,  1, 0, 0);\t    // put Z going up\n  }\n\n\te = world_entity;\n\t\n  if (m_bTiming)\n\t\tstart2 = Sys_DoubleTime();\n\n\tfor (brush = active_brushes.next ; brush != &active_brushes ; brush=brush->next)\n\t{\n\t\tif (brush->mins[nDim1] > maxs[0] || \n        brush->mins[nDim2] > maxs[1] || \n        brush->maxs[nDim1] < mins[0] || \n        brush->maxs[nDim2] < mins[1])\n\t\t{\n\t\t  culled++;\n\t\t  continue;\t\t// off screen\n\t\t}\n\n\t \tif (FilterBrush (brush))\n\t \t\tcontinue;\n\n    drawn++;\n\n    if (brush->owner != e && brush->owner)\n\t\t{\n\n\t\t\tqglColor3fv(brush->owner->eclass->color);\n\t\t}\n    else\n    {\n\t\t  qglColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES]);\n    }\n\n    Brush_DrawXY(brush, m_nViewType);\n\t}\n  \n  \n  if (m_bTiming)\n\t\tend2 = Sys_DoubleTime();\n\n\n  DrawPathLines ();\n\n\t//\n\t// draw pointfile\n\t//\n\tif ( g_qeglobals.d_pointfile_display_list)\n\t\tqglCallList (g_qeglobals.d_pointfile_display_list);\n\n\n  if (!(m_nViewType == XY))\n    qglPopMatrix();\n\n  //\n\t// draw block grid\n\t//\n\tif ( g_qeglobals.show_blocks)\n\t\tXY_DrawBlockGrid ();\n\n\t//\n\t// now draw selected brushes\n\t//\n  if (m_nViewType != XY)\n  {\n    qglPushMatrix();\n    if (m_nViewType == YZ)\n      qglRotatef (-90,  0, 1, 0);\t    // put Z going up\n    //else\n      qglRotatef (-90,  1, 0, 0);\t    // put Z going up\n  }\n\n\n  qglPushMatrix();\n\tqglTranslatef( g_qeglobals.d_select_translate[0], g_qeglobals.d_select_translate[1], g_qeglobals.d_select_translate[2]);\n\n  if (RotateMode())\n    qglColor3f(0.8, 0.1, 0.9);\n  else\n  if (ScaleMode())\n    qglColor3f(0.1, 0.8, 0.1);\n  else\n    qglColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES]);\n\n\n  if (g_PrefsDlg.m_bNoStipple == FALSE)\n  {\n    qglEnable (GL_LINE_STIPPLE);\n\t  qglLineStipple (3, 0xaaaa);\n  }\n\tqglLineWidth (2);\n\n  vec3_t vMinBounds;\n  vec3_t vMaxBounds;\n  vMinBounds[0] = vMinBounds[1] = vMinBounds[2] = 9999.9f;\n  vMaxBounds[0] = vMaxBounds[1] = vMaxBounds[2] = -9999.9f;\n\n  int nSaveDrawn = drawn;\n  bool bFixedSize = false;\n\tfor (brush = selected_brushes.next ; brush != &selected_brushes ; brush=brush->next)\n\t{\n\t\tdrawn++;\n\t\tBrush_DrawXY(brush, m_nViewType);\n\n    if (!bFixedSize)\n    {\n      if (brush->owner->eclass->fixedsize)\n        bFixedSize = true;\n      if (g_PrefsDlg.m_bSizePaint)\n      {\n        for (i = 0; i < 3; i ++)\n        {\n          if (brush->mins[i] < vMinBounds[i])\n            vMinBounds[i] = brush->mins[i];\n          if (brush->maxs[i] > vMaxBounds[i])\n            vMaxBounds[i] = brush->maxs[i];\n        }\n      }\n    }\n\t}\n\n  if (g_PrefsDlg.m_bNoStipple == FALSE)\n  {\n\t  qglDisable (GL_LINE_STIPPLE);\n  }\n\tqglLineWidth (1);\n\n  if (!bFixedSize && !RotateMode() && !ScaleMode() && drawn - nSaveDrawn > 0 && g_PrefsDlg.m_bSizePaint)\n    PaintSizeInfo(nDim1, nDim2, vMinBounds, vMaxBounds);\n\n\n\t// edge / vertex flags\n\n\tif (g_qeglobals.d_select_mode == sel_vertex)\n\t{\n\t\tqglPointSize (4);\n\t\tqglColor3f (0,1,0);\n\t\tqglBegin (GL_POINTS);\n\t\tfor (i=0 ; i<g_qeglobals.d_numpoints ; i++)\n\t\t\tqglVertex3fv (g_qeglobals.d_points[i]);\n\t\tqglEnd ();\n\t\tqglPointSize (1);\n\t}\n\telse if (g_qeglobals.d_select_mode == sel_edge)\n\t{\n\t\tfloat\t*v1, *v2;\n\n\t\tqglPointSize (4);\n\t\tqglColor3f (0,0,1);\n\t\tqglBegin (GL_POINTS);\n\t\tfor (i=0 ; i<g_qeglobals.d_numedges ; i++)\n\t\t{\n\t\t\tv1 = g_qeglobals.d_points[g_qeglobals.d_edges[i].p1];\n\t\t\tv2 = g_qeglobals.d_points[g_qeglobals.d_edges[i].p2];\n\t\t\tqglVertex3f ( (v1[0]+v2[0])*0.5,(v1[1]+v2[1])*0.5,(v1[2]+v2[2])*0.5);\n\t\t}\n\t\tqglEnd ();\n\t\tqglPointSize (1);\n\t}\n\n\n\tg_splineList->draw(static_cast<qboolean>(g_qeglobals.d_select_mode == sel_editpoint || g_qeglobals.d_select_mode == sel_addpoint));\n\n  qglPopMatrix();\n\n\tqglTranslatef (-g_qeglobals.d_select_translate[0], -g_qeglobals.d_select_translate[1], -g_qeglobals.d_select_translate[2]);\n\n\n  if (!(m_nViewType == XY))\n    qglPopMatrix();\n\n  // area selection hack\n  if (g_qeglobals.d_select_mode == sel_area)\n  {\n\t  qglEnable (GL_BLEND);\n\t  qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\n\t  qglColor4f(0.0, 0.0, 1.0, 0.25);\n    qglRectf(g_qeglobals.d_vAreaTL[nDim1], g_qeglobals.d_vAreaTL[nDim2], g_qeglobals.d_vAreaBR[nDim1], g_qeglobals.d_vAreaBR[nDim2]);\n\t  qglDisable (GL_BLEND);\n  }\n\n\n  //\n\t// now draw camera point\n\t//\n\tDrawCameraIcon ();\n\tDrawZIcon ();\n\n  if (RotateMode())\n  {\n    DrawRotateIcon();\n  }\n\n  // plugin entities\n  //++timo TODO: use an object for the 2D view\n  DrawPluginEntities( (VIEWTYPE)m_nViewType );\n\n  qglFinish();\n\t//QE_CheckOpenGLForErrors();\n\n  if (m_bTiming)\n\t{\n\t\tend = Sys_DoubleTime ();\n    i = (int)(1000*(end-start));\n    int i3 = (int)(1000*(end2-start2));\n    g_lCount++;\n    g_lTotal += i;\n    int i2 = g_lTotal / g_lCount;\n\t\tSys_Printf (\"xy: %i ab: %i  avg: %i\\n\", i, i3, i2);\n\t}\n}\n\n/*\n==============\nXY_Overlay\n==============\n*/\nvoid CXYWnd::XY_Overlay()\n{\n\tint\tw, h;\n\tint\tr[4];\n\tstatic\tvec3_t\tlastz;\n\tstatic\tvec3_t\tlastcamera;\n\n\n\tqglViewport(0, 0, m_nWidth, m_nHeight);\n\n\t//\n\t// set up viewpoint\n\t//\n\tqglMatrixMode(GL_PROJECTION);\n  qglLoadIdentity ();\n\n\tw = m_nWidth / 2 / m_fScale;\n\th = m_nHeight / 2 / m_fScale;\n\n  qglOrtho (m_vOrigin[0] - w, m_vOrigin[0] + w\t, m_vOrigin[1] - h, m_vOrigin[1] + h, -8000, 8000);\n\t//\n\t// erase the old camera and z checker positions\n\t// if the entire xy hasn't been redrawn\n\t//\n\tif (m_bDirty)\n\t{\n\t\tqglReadBuffer (GL_BACK);\n\t\tqglDrawBuffer (GL_FRONT);\n\n\t\tqglRasterPos2f (lastz[0]-9, lastz[1]-9);\n\t\tqglGetIntegerv (GL_CURRENT_RASTER_POSITION,r);\n\t\tqglCopyPixels(r[0], r[1], 18,18, GL_COLOR);\n\n\t\tqglRasterPos2f (lastcamera[0]-50, lastcamera[1]-50);\n\t\tqglGetIntegerv (GL_CURRENT_RASTER_POSITION,r);\n\t\tqglCopyPixels(r[0], r[1], 100,100, GL_COLOR);\n\t}\n\tm_bDirty = true;\n\n\t//\n\t// save off underneath where we are about to draw\n\t//\n\tVectorCopy (z.origin, lastz);\n\tVectorCopy (g_pParentWnd->GetCamera()->Camera().origin, lastcamera);\n\n\tqglReadBuffer (GL_FRONT);\n\tqglDrawBuffer (GL_BACK);\n\n\tqglRasterPos2f (lastz[0]-9, lastz[1]-9);\n\tqglGetIntegerv (GL_CURRENT_RASTER_POSITION,r);\n\tqglCopyPixels(r[0], r[1], 18,18, GL_COLOR);\n\n\tqglRasterPos2f (lastcamera[0]-50, lastcamera[1]-50);\n\tqglGetIntegerv (GL_CURRENT_RASTER_POSITION,r);\n\tqglCopyPixels(r[0], r[1], 100,100, GL_COLOR);\n\n\t//\n\t// draw the new icons\n\t//\n\tqglDrawBuffer (GL_FRONT);\n\n  qglShadeModel (GL_FLAT);\n\tqglDisable(GL_TEXTURE_2D);\n\tqglDisable(GL_TEXTURE_1D);\n\tqglDisable(GL_DEPTH_TEST);\n\tqglDisable(GL_BLEND);\n\tqglColor3f(0, 0, 0);\n\n\tDrawCameraIcon ();\n\tDrawZIcon ();\n\n\tqglDrawBuffer (GL_BACK);\n  qglFinish();\n}\n\n\nvec3_t& CXYWnd::GetOrigin()\n{\n  return m_vOrigin;\n}\n\nvoid CXYWnd::SetOrigin(vec3_t org)\n{\n\tm_vOrigin[0] = org[0];\n\tm_vOrigin[1] = org[1];\n\tm_vOrigin[2] = org[2];\n}\n\nvoid CXYWnd::OnSize(UINT nType, int cx, int cy) \n{\n\tCWnd::OnSize(nType, cx, cy);\n  CRect rect;\n  GetClientRect(rect);\n  m_nWidth = rect.Width();\n  m_nHeight = rect.Height();\n}\n\nbrush_t hold_brushes;\nvoid CXYWnd::Clip()\n{\n  if (ClipMode())\n  {\n    hold_brushes.next = &hold_brushes;\n    ProduceSplitLists();\n    //brush_t* pList = (g_bSwitch) ? &g_brFrontSplits : &g_brBackSplits;\n    brush_t* pList;\n\tif (g_PrefsDlg.m_bSwitchClip)\n\t\tpList = ( (m_nViewType == XZ) ? g_bSwitch: !g_bSwitch) ? &g_brFrontSplits : &g_brBackSplits;\n\telse\n\t\tpList = ( (m_nViewType == XZ) ? !g_bSwitch: g_bSwitch) ? &g_brFrontSplits : &g_brBackSplits;\n\n    \n\tif (pList->next != pList)\n    {\n      Brush_CopyList(pList, &hold_brushes);\n      CleanList(&g_brFrontSplits);\n      CleanList(&g_brBackSplits);\n      Select_Delete();\n      Brush_CopyList(&hold_brushes, &selected_brushes);\n      if (RogueClipMode())\n        RetainClipMode(false);\n      else\n        RetainClipMode(true);\n      Sys_UpdateWindows(W_ALL);\n    }\n  }\n  else if (PathMode())\n  {\n    FinishSmartCreation();\n    if (g_pPathFunc)\n      g_pPathFunc(true, g_nPathCount);\n    g_pPathFunc = NULL;\n    g_nPathCount = 0;\n    g_bPathMode = false;\n  }\n}\n\nvoid CXYWnd::SplitClip()\n{\n\tProduceSplitLists();\n\tif ((g_brFrontSplits.next != &g_brFrontSplits) &&\n\t\t(g_brBackSplits.next != &g_brBackSplits))\n\t{\n\t\tSelect_Delete();\n\t\tBrush_CopyList(&g_brFrontSplits, &selected_brushes);\n\t\tBrush_CopyList(&g_brBackSplits, &selected_brushes);\n\t\tCleanList(&g_brFrontSplits);\n\t\tCleanList(&g_brBackSplits);\n\t\tif (RogueClipMode())\n\t\t\tRetainClipMode(false);\n\t\telse\n\t\t\tRetainClipMode(true);\n\t}\n}\n\nvoid CXYWnd::FlipClip()\n{\n  g_bSwitch = !g_bSwitch;\n  Sys_UpdateWindows(XY | W_CAMERA_IFON);\n}\n\n\n// makes sure the selected brush or camera is in view\nvoid CXYWnd::PositionView()\n{\n  int nDim1 = (m_nViewType == YZ) ? 1 : 0;\n  int nDim2 = (m_nViewType == XY) ? 1 : 2;\n  brush_t* b = selected_brushes.next;\n  if (b && b->next != b)\n  {\n\t  m_vOrigin[nDim1] = b->mins[nDim1];\n\t  m_vOrigin[nDim2] = b->mins[nDim2];\n  }\n  else\n  {\n\t  m_vOrigin[nDim1] = g_pParentWnd->GetCamera()->Camera().origin[nDim1];\n\t  m_vOrigin[nDim2] = g_pParentWnd->GetCamera()->Camera().origin[nDim2];\n  }\n}\n\nvoid CXYWnd::VectorCopyXY(vec3_t in, vec3_t out)\n{\n  if (m_nViewType == XY)\n  {\n\t  out[0] = in[0];\n\t  out[1] = in[1];\n  }\n  else\n  if (m_nViewType == XZ)\n  {\n\t  out[0] = in[0];\n\t  out[2] = in[2];\n  }\n  else\n  {\n\t  out[1] = in[1];\n\t  out[2] = in[2];\n  }\n}\n\n\nvoid CXYWnd::OnDestroy() \n{\n\tQEW_StopGL( GetSafeHwnd(), s_hglrcXY, s_hdcXY );\n\tCWnd::OnDestroy();\n  // delete this;\n}\n\nvoid CXYWnd::SetViewType(int n) \n{ \n  m_nViewType = n; \n  if (g_pParentWnd->CurrentStyle() == QR_QE4)\n  {\n    CString str = \"YZ Side\";\n    if (m_nViewType == XY)\n      str = \"XY Top\";\n    else if (m_nViewType == XZ)\n      str = \"XZ Front\";\n    SetWindowText(str);\n  }\n};\n\nvoid CXYWnd::Redraw(unsigned int nBits)\n{\n  m_nUpdateBits = nBits;\n  RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);\n  m_nUpdateBits = W_XY;\n}\n\nbool CXYWnd::RotateMode()\n{\n  return g_bRotateMode;\n}\n\nbool CXYWnd::ScaleMode()\n{\n  return g_bScaleMode;\n}\n\nbool CXYWnd::SetRotateMode(bool bMode)\n{\n  if (bMode && selected_brushes.next != &selected_brushes)\n  {\n    g_bRotateMode = true;\n    Select_GetTrueMid(g_vRotateOrigin);\n    g_vRotation[0] = g_vRotation[1] = g_vRotation[2] = 0.0;\n  }\n  else \n  {\n    if (bMode)\n      Sys_Printf(\"Need a brush selected to turn on Mouse Rotation mode\\n\");\n    g_bRotateMode = false;\n  }\n  RedrawWindow();\n  return g_bRotateMode;\n}\n\nvoid CXYWnd::SetScaleMode(bool bMode)\n{\n  g_bScaleMode = bMode;\n  RedrawWindow();\n}\n\n\n\n\n// xy - z\n// xz - y\n// yz - x\n\nvoid CXYWnd::OnSelectMouserotate() \n{\n\t// TODO: Add your command handler code here\n\t\n}\n\nvoid CleanCopyEntities()\n{\n\tentity_t* pe = g_enClipboard.next;\n  while (pe != NULL && pe != &g_enClipboard)\n  {\n    entity_t* next = pe->next;\n    epair_t* enext = NULL;\n\t  for (epair_t* ep = pe->epairs ; ep ; ep=enext)\n    {\n\t\t  enext = ep->next;\n      free (ep->key);\n      free (ep->value);\n\t\t  free (ep);\n    }\n\t  free (pe);\n    pe = next;\n  }\n  g_enClipboard.next = g_enClipboard.prev = &g_enClipboard;\n}\n\nentity_t\t*Entity_CopyClone (entity_t *e)\n{\n\tentity_t\t*n;\n\tepair_t\t\t*ep, *np;\n\n\tn = (entity_t*)qmalloc(sizeof(*n));\n\tn->brushes.onext = n->brushes.oprev = &n->brushes;\n\tn->eclass = e->eclass;\n\n\t// add the entity to the entity list\n\tn->next = g_enClipboard.next;\n\tg_enClipboard.next = n;\n\tn->next->prev = n;\n\tn->prev = &g_enClipboard;\n\n\tfor (ep = e->epairs ; ep ; ep=ep->next)\n\t{\n\t\tnp = (epair_t*)qmalloc(sizeof(*np));\n\t\tnp->key = copystring(ep->key);\n\t\tnp->value = copystring(ep->value);\n\t\tnp->next = n->epairs;\n\t\tn->epairs = np;\n\t}\n\treturn n;\n}\n\nbool OnList(entity_t* pFind, CPtrArray* pList)\n{\n  int nSize = pList->GetSize();\n  while (nSize-- > 0)\n  {\n    entity_t* pEntity = reinterpret_cast<entity_t*>(pList->GetAt(nSize));\n    if (pEntity == pFind)\n      return true;\n  }\n  return false;\n}\n\nvoid CXYWnd::Copy()\n{\n#if 1\n  CWaitCursor WaitCursor; \n  g_Clipboard.SetLength(0);\n  g_PatchClipboard.SetLength(0);\n  \n  Map_SaveSelected(&g_Clipboard, &g_PatchClipboard);\n  bool bClipped = false;\n  UINT nClipboard = ::RegisterClipboardFormat(\"RadiantClippings\");\n  if (nClipboard > 0)\n  {\n    if (OpenClipboard())\n    {\n      ::EmptyClipboard();\n  \t\tlong lSize = g_Clipboard.GetLength();\n      HANDLE h = ::GlobalAlloc(GMEM_ZEROINIT | GMEM_MOVEABLE | GMEM_DDESHARE, lSize + sizeof(long));\n      if (h != NULL)\n      {\n        unsigned char *cp = reinterpret_cast<unsigned char*>(::GlobalLock(h));\n\t\t\t\tmemcpy(cp, &lSize, sizeof(long));\n\t\t\t\tcp += sizeof(long);\n        g_Clipboard.SeekToBegin();\n        g_Clipboard.Read(cp, lSize);\n        ::GlobalUnlock(h);\n        ::SetClipboardData(nClipboard, h);\n        ::CloseClipboard();\n        bClipped = true;\n      }\n    }\n  }\n\n  if (!bClipped)\n  {\n    Sys_Printf(\"Unable to register Windows clipboard formats, copy/paste between editors will not be possible\");\n  }\n\n/*\n  CString strOut;\n  ::GetTempPath(1024, strOut.GetBuffer(1024));\n  strOut.ReleaseBuffer();\n  AddSlash(strOut);\n  strOut += \"RadiantClipboard.$$$\";\n  Map_SaveSelected(strOut.GetBuffer(0));\n*/\n\n#else\n  CPtrArray holdArray;\n  CleanList(&g_brClipboard);\n  CleanCopyEntities();\n\tfor (brush_t* pBrush = selected_brushes.next ; pBrush != NULL && pBrush != &selected_brushes ; pBrush=pBrush->next)\n  {\n\t\tif (pBrush->owner == world_entity)\n    {\n      brush_t* pClone = Brush_Clone(pBrush);\n      pClone->owner = NULL;\n  \t  Brush_AddToList (pClone, &g_brClipboard);\n    }\n    else\n    {\n      if (!OnList(pBrush->owner, &holdArray))\n      {\n        entity_t* e = pBrush->owner;\n        holdArray.Add(reinterpret_cast<void*>(e));\n        entity_t* pEClone = Entity_CopyClone(e);\n\t\t\t  for (brush_t* pEB = e->brushes.onext ; pEB != &e->brushes ; pEB=pEB->onext)\n\t\t\t  {\n          brush_t* pClone = Brush_Clone(pEB);\n\t        //Brush_AddToList (pClone, &g_brClipboard);\n          Entity_LinkBrush(pEClone, pClone);\n          Brush_Build(pClone);\n\t\t\t  }\n      }\n    }\n  }\n#endif\n}\n\nvoid CXYWnd::Undo()\n{\n/*\n  if (g_brUndo.next != &g_brUndo)\n  {\n    g_bScreenUpdates = false; \n    Select_Delete();\n\t  for (brush_t* pBrush = g_brUndo.next ; pBrush != NULL && pBrush != &g_brUndo ; pBrush=pBrush->next)\n    {\n      brush_t* pClone = Brush_Clone(pBrush);\n    \tBrush_AddToList (pClone, &active_brushes);\n\t\t\tEntity_LinkBrush (pBrush->pUndoOwner, pClone);\n      Brush_Build(pClone);\n      Select_Brush(pClone);\n    }\n    CleanList(&g_brUndo);\n    g_bScreenUpdates = true; \n    Sys_UpdateWindows(W_ALL);\n  }\n  else Sys_Printf(\"Nothing to undo.../n\");\n*/\n}\n\nvoid CXYWnd::UndoClear()\n{\n/*  \n  CleanList(&g_brUndo);\n*/\n}\n\nvoid CXYWnd::UndoCopy()\n{\n/*\n  CleanList(&g_brUndo);\n\tfor (brush_t* pBrush = selected_brushes.next ; pBrush != NULL && pBrush != &selected_brushes ; pBrush=pBrush->next)\n  {\n    brush_t* pClone = Brush_Clone(pBrush);\n    pClone->pUndoOwner = pBrush->owner;\n\t  Brush_AddToList (pClone, &g_brUndo);\n  }\n*/\n}\n\nbool CXYWnd::UndoAvailable()\n{\n  return (g_brUndo.next != &g_brUndo);\n}\n\n\n\nvoid CXYWnd::Paste()\n{\n#if 1\n\n  CWaitCursor WaitCursor; \n  bool bPasted = false;\n  UINT nClipboard = ::RegisterClipboardFormat(\"RadiantClippings\");\n  if (nClipboard > 0 && OpenClipboard() && ::IsClipboardFormatAvailable(nClipboard))\n  {\n    HANDLE h = ::GetClipboardData(nClipboard);\n    if (h)\n    {\n      g_Clipboard.SetLength(0);\n\t\t\tunsigned char *cp = reinterpret_cast<unsigned char*>(::GlobalLock(h));\n\t\t\tlong lSize = 0;\n\t\t\tmemcpy(&lSize, cp, sizeof(long));\n\t\t\tcp += sizeof(long);\n      g_Clipboard.Write(cp, lSize);\n    }\n    ::GlobalUnlock(h);\n    ::CloseClipboard();\n  }\n\n  if (g_Clipboard.GetLength() > 0)\n  {\n    g_Clipboard.SeekToBegin();\n    int nLen = g_Clipboard.GetLength();\n    char* pBuffer = new char[nLen+1];\n\t  memset( pBuffer, 0, sizeof(pBuffer) );\n    g_Clipboard.Read(pBuffer, nLen);\n    pBuffer[nLen] = '\\0';\n    Map_ImportBuffer(pBuffer);\n    delete []pBuffer;\n  }\n\n#if 0\n  if (g_PatchClipboard.GetLength() > 0)\n  {\n    g_PatchClipboard.SeekToBegin();\n    int nLen = g_PatchClipboard.GetLength();\n    char* pBuffer = new char[nLen+1];\n    g_PatchClipboard.Read(pBuffer, nLen);\n    pBuffer[nLen] = '\\0';\n    Patch_ReadBuffer(pBuffer, true);\n    delete []pBuffer;\n  }\n#endif\n\n#else\n  if (g_brClipboard.next != &g_brClipboard || g_enClipboard.next != &g_enClipboard)\n  {\n    Select_Deselect();\n\n\t  for (brush_t* pBrush = g_brClipboard.next ; pBrush != NULL && pBrush != &g_brClipboard ; pBrush=pBrush->next)\n    {\n      brush_t* pClone = Brush_Clone(pBrush);\n\t    //pClone->owner = pBrush->owner;\n      if (pClone->owner == NULL)\n\t\t\t  Entity_LinkBrush (world_entity, pClone);\n    \t\n      Brush_AddToList (pClone, &selected_brushes);\n      Brush_Build(pClone);\n    }\n\n    for (entity_t* pEntity = g_enClipboard.next; pEntity != NULL && pEntity != &g_enClipboard; pEntity = pEntity->next)\n    {\n      entity_t* pEClone = Entity_Clone(pEntity);\n\t\t\tfor (brush_t* pEB = pEntity->brushes.onext ; pEB != &pEntity->brushes ; pEB=pEB->onext)\n\t\t\t{\n        brush_t* pClone = Brush_Clone(pEB);\n\t      Brush_AddToList (pClone, &selected_brushes);\n        Entity_LinkBrush(pEClone, pClone);\n        Brush_Build(pClone);\n        if (pClone->owner && pClone->owner != world_entity)\n        {\n\t\t\t    UpdateEntitySel(pClone->owner->eclass);\n        }\n\t\t\t}\n    }\n\n    Sys_UpdateWindows(W_ALL);\n  }\n  else Sys_Printf(\"Nothing to paste.../n\");\n#endif\n}\n\n\nvec3_t& CXYWnd::Rotation()\n{\n  return g_vRotation;\n}\n\nvec3_t& CXYWnd::RotateOrigin()\n{\n  return g_vRotateOrigin;\n}\n\n\nvoid CXYWnd::OnTimer(UINT nIDEvent) \n{\n  int nDim1 = (m_nViewType == YZ) ? 1 : 0;\n  int nDim2 = (m_nViewType == XY) ? 1 : 2;\n\tm_vOrigin[nDim1] += m_ptDragAdj.x / m_fScale;\n\tm_vOrigin[nDim2] -= m_ptDragAdj.y / m_fScale;\n  Sys_UpdateWindows(W_XY | W_CAMERA);\n  //int nH = (m_ptDrag.y == 0) ? -1 : m_ptDrag.y;\n  m_ptDrag += m_ptDragAdj;\n  m_ptDragTotal += m_ptDragAdj;\n  XY_MouseMoved (m_ptDrag.x, m_nHeight - 1 - m_ptDrag.y , m_nScrollFlags);\n\t//m_vOrigin[nDim1] -= m_ptDrag.x / m_fScale;\n\t//m_vOrigin[nDim1] -= m_ptDrag.x / m_fScale;\n}\n\nvoid CXYWnd::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) \n{\n  g_pParentWnd->HandleKey(nChar, nRepCnt, nFlags, false);\n  //CWnd::OnKeyUp(nChar, nRepCnt, nFlags);\n}\n\nvoid CXYWnd::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp) \n{\n\tCWnd::OnNcCalcSize(bCalcValidRects, lpncsp);\n}\n\nvoid CXYWnd::OnKillFocus(CWnd* pNewWnd) \n{\n\tCWnd::OnKillFocus(pNewWnd);\n\tSendMessage(WM_NCACTIVATE, FALSE , 0 );\n}\n\nvoid CXYWnd::OnSetFocus(CWnd* pOldWnd) \n{\n\tCWnd::OnSetFocus(pOldWnd);\n\tSendMessage(WM_NCACTIVATE, TRUE , 0 );\n}\n\nvoid CXYWnd::OnClose() \n{\n\tCWnd::OnClose();\n}\n\n// should be static as should be the rotate scale stuff\nbool CXYWnd::AreaSelectOK()\n{\n  return RotateMode() ? false : ScaleMode() ? false : true;\n}"
  },
  {
    "path": "q3radiant/XYWnd.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_XYWND_H__44B4BA04_781B_11D1_B53C_00AA00A410FC__INCLUDED_)\n#define AFX_XYWND_H__44B4BA04_781B_11D1_B53C_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// XYWnd.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CXYWnd window\n\n#include \"qe3.h\"\n#include \"CamWnd.h\"\n\nconst int SCALE_X = 0x01;\nconst int SCALE_Y = 0x02;\nconst int SCALE_Z = 0x04;\n\n\ntypedef void (PFNPathCallback)(bool, int);\n// as i didn't really encapsulate anything this\n// should really be a struct..\nclass CClipPoint\n{\npublic:\n  CClipPoint(){ Reset(); };\n  void Reset(){ m_ptClip[0] = m_ptClip[1] = m_ptClip[2] = 0.0; m_bSet = false; m_pVec3 = NULL;};\n  bool Set(){ return m_bSet; };\n  void Set(bool b) { m_bSet = b; };\n  void UpdatePointPtr() { if (m_pVec3) VectorCopy(m_ptClip, *m_pVec3); };\n  void SetPointPtr(vec3_t* p) { m_pVec3 = p; };\n  vec3_t m_ptClip;      // the 3d point\n  vec3_t* m_pVec3;      // optional ptr for 3rd party updates\n  CPoint m_ptScreen;    // the onscreen xy point (for mousability)\n  bool m_bSet;\n  operator vec3_t&() {return m_ptClip;};\n  operator vec3_t*() {return &m_ptClip;};\n};\n\nclass CXYWnd : public CWnd\n{\n  DECLARE_DYNCREATE(CXYWnd);\n// Construction\npublic:\n\tCXYWnd();\n\n// Attributes\npublic:\n\n// Operations\npublic:\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CXYWnd)\n\tprotected:\n\tvirtual BOOL PreCreateWindow(CREATESTRUCT& cs);\n\t//}}AFX_VIRTUAL\n\n// Implementation\npublic:\n  bool AreaSelectOK();\n  vec3_t& RotateOrigin();\n  vec3_t& Rotation();\n  void UndoClear();\n  bool UndoAvailable();\n  void KillPathMode();\n  void Undo();\n  void UndoCopy();\n  void Copy();\n  void Paste();\n  void Redraw(unsigned int nBits);\n  void VectorCopyXY(vec3_t in, vec3_t out);\n\tvoid PositionView();\n\tvoid FlipClip();\n\tvoid SplitClip();\n\tvoid Clip();\n\tvec3_t& GetOrigin();\n\tvoid SetOrigin(vec3_t org);\t\t// PGM\n\tvoid XY_Init();\n  void XY_Overlay();\n  void XY_Draw();\n  void DrawZIcon();\n  void DrawRotateIcon();\n  void DrawCameraIcon();\n  void XY_DrawBlockGrid();\n  void XY_DrawGrid();\n  void XY_MouseMoved (int x, int y, int buttons);\n  void NewBrushDrag (int x, int y);\n  qboolean DragDelta (int x, int y, vec3_t move);\n  void XY_MouseUp(int x, int y, int buttons);\n  void XY_MouseDown (int x, int y, int buttons);\n  void XY_ToGridPoint (int x, int y, vec3_t point);\n  void XY_ToPoint (int x, int y, vec3_t point);\n  void SnapToPoint (int x, int y, vec3_t point);\n  void SetActive(bool b) {m_bActive = b;};\n  bool Active() {return m_bActive;};\n  void DropClipPoint(UINT nFlags, CPoint point);\n\n  bool RogueClipMode();\n\tbool ClipMode();\n\tvoid SetClipMode(bool bMode);\n\tvoid RetainClipMode(bool bMode);\n\n  bool RotateMode();\n  bool SetRotateMode(bool bMode);\n  bool ScaleMode();\n  void SetScaleMode(bool bMode);\n\n  bool PathMode();\n  void DropPathPoint(UINT nFlags, CPoint point);\n\n  bool PointMode();\n  void AddPointPoint(UINT nFlags, vec3_t* pVec);\n  void SetPointMode(bool b);\n\n\n\tvirtual ~CXYWnd();\n  void SetViewType(int n);\n  int GetViewType() {return  m_nViewType; };\n  void SetScale(float f) {m_fScale = f;};\n  float Scale() {return m_fScale;};\n  int Width() {return m_nWidth;}\n  int Height() {return m_nHeight;}\n  bool m_bActive;\n\n\t// Generated message map functions\nprotected:\n\tint m_nUpdateBits;\n\tint m_nWidth;\n  int m_nHeight;\n  bool m_bTiming;\n\tfloat\tm_fScale;\n\tfloat\tm_TopClip;\n  float m_BottomClip;\n  bool m_bDirty;\n\tvec3_t m_vOrigin;\n\tCPoint m_ptCursor;\n  bool m_bRButtonDown;\n\n  int\tm_nButtonstate;\n  int m_nPressx;\n  int m_nPressy;\n  vec3_t m_vPressdelta;\n  bool m_bPress_selection;\n\n  friend CCamWnd;\n  //friend C3DFXCamWnd;\n\n  CMenu m_mnuDrop;\n  int m_nViewType;\n\n  unsigned int m_nTimerID;\n  int m_nScrollFlags;\n  CPoint m_ptDrag;\n  CPoint m_ptDragAdj;\n  CPoint m_ptDragTotal;\n\n\tvoid OriginalButtonUp(UINT nFlags, CPoint point);\n\tvoid OriginalButtonDown(UINT nFlags, CPoint point);\n  void ProduceSplits(brush_t** pFront, brush_t** pBack);\n  void ProduceSplitLists();\n  void HandleDrop();\n  void PaintSizeInfo(int nDim1, int nDim2, vec3_t vMinBounds, vec3_t vMaxBounds);\n\n  void OnEntityCreate(unsigned int nID);\n  CPoint m_ptDown;\n\t//{{AFX_MSG(CXYWnd)\n\tafx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);\n\tafx_msg void OnLButtonDown(UINT nFlags, CPoint point);\n\tafx_msg void OnMButtonDown(UINT nFlags, CPoint point);\n\tafx_msg void OnRButtonDown(UINT nFlags, CPoint point);\n\tafx_msg void OnLButtonUp(UINT nFlags, CPoint point);\n\tafx_msg void OnMButtonUp(UINT nFlags, CPoint point);\n\tafx_msg void OnRButtonUp(UINT nFlags, CPoint point);\n\tafx_msg void OnMouseMove(UINT nFlags, CPoint point);\n\tafx_msg void OnPaint();\n\tafx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);\n\tafx_msg void OnSize(UINT nType, int cx, int cy);\n\tafx_msg void OnDestroy();\n\tafx_msg void OnSelectMouserotate();\n\tafx_msg void OnTimer(UINT nIDEvent);\n\tafx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);\n\tafx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp);\n\tafx_msg void OnKillFocus(CWnd* pNewWnd);\n\tafx_msg void OnSetFocus(CWnd* pOldWnd);\n\tafx_msg void OnClose();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n/////////////////////////////////////////////////////////////////////////////\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_XYWND_H__44B4BA04_781B_11D1_B53C_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/Z.CPP",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#include \"stdafx.h\"\n#include \"qe3.h\"\n\n#define\tPAGEFLIPS\t2\n\nz_t\t\tz;\n\n/*\n============\nZ_Init\n============\n*/\nvoid Z_Init (void)\n{\n\tz.origin[0] = 0;\n\tz.origin[1] = 20;\n\tz.origin[2] = 46;\n\n\tz.scale = 1;\n}\n\n\n\n/*\n============================================================================\n\n  MOUSE ACTIONS\n\n============================================================================\n*/\n\nstatic\tint\tcursorx, cursory;\n\n/*\n==============\nZ_MouseDown\n==============\n*/\nvoid Z_MouseDown (int x, int y, int buttons)\n{\n\tvec3_t\torg, dir, vup, vright;\n\tbrush_t\t*b;\n\n\tSys_GetCursorPos (&cursorx, &cursory);\n\n\tvup[0] = 0; vup[1] = 0; vup[2] = 1/z.scale;\n\n\tVectorCopy (z.origin, org);\n\torg[2] += (y - (z.height/2))/z.scale;\n\torg[1] = -8192;\n\n\tb = selected_brushes.next;\n\tif (b != &selected_brushes)\n\t{\n\t\torg[0] = (b->mins[0] + b->maxs[0])/2;\n\t}\n\n\tdir[0] = 0; dir[1] = 1; dir[2] = 0;\n\n\tvright[0] = 0; vright[1] = 0; vright[2] = 0;\n\n\t// LBUTTON = manipulate selection\n\t// shift-LBUTTON = select\n\t// middle button = grab texture\n\t// ctrl-middle button = set entire brush to texture\n\t// ctrl-shift-middle button = set single face to texture\n\n  int nMouseButton = g_PrefsDlg.m_nMouseButtons == 2 ? MK_RBUTTON : MK_MBUTTON;\n\tif ( (buttons == MK_LBUTTON)\n\t\t|| (buttons == (MK_LBUTTON | MK_SHIFT))\n\t\t|| (buttons == MK_MBUTTON)\n//\t\t|| (buttons == (MK_MBUTTON|MK_CONTROL))\n\t\t|| (buttons == (nMouseButton|MK_SHIFT|MK_CONTROL)) )\n\t{\n\t\tDrag_Begin (x, y, buttons,\n\t\t\tvright, vup,\n\t\t\torg, dir);\n\t\treturn;\n\t}\n\n\t// control mbutton = move camera\n\tif ((buttons == (MK_CONTROL|nMouseButton) ) || (buttons == (MK_CONTROL|MK_LBUTTON)))\n\t{\t\n\t\tg_pParentWnd->GetCamera()->Camera().origin[2] = org[2] ;\n\t\tSys_UpdateWindows (W_CAMERA|W_XY_OVERLAY|W_Z);\n\t}\n\n\n}\n\n/*\n==============\nZ_MouseUp\n==============\n*/\nvoid Z_MouseUp (int x, int y, int buttons)\n{\n\tDrag_MouseUp ();\n}\n\n/*\n==============\nZ_MouseMoved\n==============\n*/\nvoid Z_MouseMoved (int x, int y, int buttons)\n{\n\tif (!buttons)\n\t\treturn;\n\tif (buttons == MK_LBUTTON)\n\t{\n\t\tDrag_MouseMoved (x, y, buttons);\n\t\tSys_UpdateWindows (W_Z|W_CAMERA_IFON|W_XY);\n\t\treturn;\n\t}\n\t// rbutton = drag z origin\n\tif (buttons == MK_RBUTTON)\n\t{\n\t\tSys_GetCursorPos (&x, &y);\n\t\tif ( y != cursory)\n\t\t{\n\t\t\tz.origin[2] += y-cursory;\n\t\t\tSys_SetCursorPos (cursorx, cursory);\n\t\t\tSys_UpdateWindows (W_Z);\n\t\t}\n\t\treturn;\n\t}\n\t\t// control mbutton = move camera\n  int nMouseButton = g_PrefsDlg.m_nMouseButtons == 2 ? MK_RBUTTON : MK_MBUTTON;\n\tif ((buttons == (MK_CONTROL|nMouseButton) ) || (buttons == (MK_CONTROL|MK_LBUTTON)))\n\t{\t\n\t\tg_pParentWnd->GetCamera()->Camera().origin[2] = (y - (z.height/2))/z.scale;\n\t\tSys_UpdateWindows (W_CAMERA|W_XY_OVERLAY|W_Z);\n\t}\n\n}\n\n\n/*\n============================================================================\n\nDRAWING\n\n============================================================================\n*/\n\n\n/*\n==============\nZ_DrawGrid\n==============\n*/\nvoid Z_DrawGrid (void)\n{\n\tfloat\tzz, zb, ze;\n\tint\t\tw, h;\n\tchar\ttext[32];\n\n\tw = z.width/2 / z.scale;\n\th = z.height/2 / z.scale;\n\n\tzb = z.origin[2] - h;\n\tif (zb < region_mins[2])\n\t\tzb = region_mins[2];\n\tzb = 64 * floor (zb/64);\n\n\tze = z.origin[2] + h;\n\tif (ze > region_maxs[2])\n\t\tze = region_maxs[2];\n\tze = 64 * ceil (ze/64);\n\n\t// draw major blocks\n\n\tqglColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR]);\n\n\tqglBegin (GL_LINES);\n\n\tqglVertex2f (0, zb);\n\tqglVertex2f (0, ze);\n\n\tfor (zz=zb ; zz<ze ; zz+=64)\n\t{\n\t\tqglVertex2f (-w, zz);\n\t\tqglVertex2f (w, zz);\n\t}\n\n\tqglEnd ();\n\n\t// draw minor blocks\n\tif (g_qeglobals.d_showgrid && g_qeglobals.d_gridsize*z.scale >= 4 &&\n      g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR] != g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK])\n\t{\n\t\tqglColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR]);\n\n\t\tqglBegin (GL_LINES);\n\t\tfor (zz=zb ; zz<ze ; zz+=g_qeglobals.d_gridsize)\n\t\t{\n\t\t\tif ( ! ((int)zz & 63) )\n\t\t\t\tcontinue;\n\t\t\tqglVertex2f (-w, zz);\n\t\t\tqglVertex2f (w, zz);\n\t\t}\n\t\tqglEnd ();\n\t}\n\n\t// draw coordinate text if needed\n\n\tqglColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT]);\n\n\tfor (zz=zb ; zz<ze ; zz+=64)\n\t{\n\t\tqglRasterPos2f (-w+1, zz);\n\t\tsprintf (text, \"%i\",(int)zz);\n\t\tqglCallLists (strlen(text), GL_UNSIGNED_BYTE, text);\n\t}\n}\n\n#define CAM_HEIGHT\t\t48 // height of main part\n#define CAM_GIZMO\t\t8\t// height of the gizmo\n\nvoid ZDrawCameraIcon (void)\n{\n\tfloat\tx, y;\n\tint\txCam = z.width/4;\n\n\tx = 0;\n\ty = g_pParentWnd->GetCamera()->Camera().origin[2];\n\n\tqglColor3f (0.0, 0.0, 1.0);\n\tqglBegin(GL_LINE_STRIP);\n\tqglVertex3f (x-xCam,y,0);\n\tqglVertex3f (x,y+CAM_GIZMO,0);\n\tqglVertex3f (x+xCam,y,0);\n\tqglVertex3f (x,y-CAM_GIZMO,0);\n\tqglVertex3f (x-xCam,y,0);\n\tqglVertex3f (x+xCam,y,0);\n\tqglVertex3f (x+xCam,y-CAM_HEIGHT,0);\n\tqglVertex3f (x-xCam,y-CAM_HEIGHT,0);\n\tqglVertex3f (x-xCam,y,0);\n\tqglEnd ();\n\n}\n\nGLbitfield glbitClear = GL_COLOR_BUFFER_BIT; //HACK\n\n/*\n==============\nZ_Draw\n==============\n*/\nvoid Z_Draw (void)\n{\n    brush_t\t*brush;\n\tfloat\tw, h;\n\tdouble\tstart, end;\n\tqtexture_t\t*q;\n\tfloat\ttop, bottom;\n\tvec3_t\torg_top, org_bottom, dir_up, dir_down;\n\tint xCam = z.width/3;\n\n\tif (!active_brushes.next)\n\t\treturn;\t// not valid yet\n\n\tif (z.timing)\n\t\tstart = Sys_DoubleTime ();\n\n\t//\n\t// clear\n\t//\n\tqglViewport(0, 0, z.width, z.height);\n\n\tqglClearColor (\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][0],\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][1],\n\t\tg_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][2],\n\t\t0);\n\n    /* GL Bug */ \n\t/* When not using hw acceleration, gl will fault if we clear the depth \n\tbuffer bit on the first pass. The hack fix is to set the GL_DEPTH_BUFFER_BIT\n\tonly after Z_Draw() has been called once. Yeah, right. */\n\tqglClear(glbitClear); \n\tglbitClear |= GL_DEPTH_BUFFER_BIT;\n\n\tqglMatrixMode(GL_PROJECTION);\n\n  qglLoadIdentity ();\n\tw = z.width/2 / z.scale;\n\th = z.height/2 / z.scale;\n\tqglOrtho (-w, w, z.origin[2]-h, z.origin[2]+h, -8, 8);\n\n\tqglDisable(GL_TEXTURE_2D);\n\tqglDisable(GL_TEXTURE_1D);\n\tqglDisable(GL_DEPTH_TEST);\n\tqglDisable(GL_BLEND);\n\n\n\t//\n\t// now draw the grid\n\t//\n\tZ_DrawGrid ();\n\n\t//\n\t// draw stuff\n\t//\n\n\tqglDisable(GL_CULL_FACE);\n\n\tqglShadeModel (GL_FLAT);\n\n\tqglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);\n\n\tqglDisable(GL_TEXTURE_2D);\n\tqglDisable(GL_BLEND);\n\tqglDisable(GL_DEPTH_TEST);\n\n\n\t// draw filled interiors and edges\n\tdir_up[0] = 0 ; dir_up[1] = 0; dir_up[2] = 1;\n\tdir_down[0] = 0 ; dir_down[1] = 0; dir_down[2] = -1;\n\tVectorCopy (z.origin, org_top);\n\torg_top[2] = 4096;\n\tVectorCopy (z.origin, org_bottom);\n\torg_bottom[2] = -4096;\n\n\tfor (brush = active_brushes.next ; brush != &active_brushes ; brush=brush->next)\n\t{\n\t\tif (brush->mins[0] >= z.origin[0]\n\t\t\t|| brush->maxs[0] <= z.origin[0]\n\t\t\t|| brush->mins[1] >= z.origin[1]\n\t\t\t|| brush->maxs[1] <= z.origin[1])\n\t\t\tcontinue;\n\n\t\tif (!Brush_Ray (org_top, dir_down, brush, &top))\n\t\t\tcontinue;\n\t\ttop = org_top[2] - top;\n\t\tif (!Brush_Ray (org_bottom, dir_up, brush, &bottom))\n\t\t\tcontinue;\n\t\tbottom = org_bottom[2] + bottom;\n\n\t\tq = Texture_ForName (brush->brush_faces->texdef.name);\n\t\tqglColor3f (q->color[0], q->color[1], q->color[2]);\n\t\tqglBegin (GL_QUADS);\n\t\tqglVertex2f (-xCam, bottom);\n\t\tqglVertex2f (xCam, bottom);\n\t\tqglVertex2f (xCam, top);\n\t\tqglVertex2f (-xCam, top);\n\t\tqglEnd ();\n\n\t\tqglColor3f (1,1,1);\n\t\tqglBegin (GL_LINE_LOOP);\n\t\tqglVertex2f (-xCam, bottom);\n\t\tqglVertex2f (xCam, bottom);\n\t\tqglVertex2f (xCam, top);\n\t\tqglVertex2f (-xCam, top);\n\t\tqglEnd ();\n\t}\n\n\t//\n\t// now draw selected brushes\n\t//\n\tfor (brush = selected_brushes.next ; brush != &selected_brushes ; brush=brush->next)\n\t{\n\t\tif ( !(brush->mins[0] >= z.origin[0]\n\t\t\t|| brush->maxs[0] <= z.origin[0]\n\t\t\t|| brush->mins[1] >= z.origin[1]\n\t\t\t|| brush->maxs[1] <= z.origin[1]) )\n\t\t{\n\t\t\tif (Brush_Ray (org_top, dir_down, brush, &top))\n\t\t\t{\n\t\t\t\ttop = org_top[2] - top;\n\t\t\t\tif (Brush_Ray (org_bottom, dir_up, brush, &bottom))\n\t\t\t\t{\n\t\t\t\t\tbottom = org_bottom[2] + bottom;\n\n\t\t\t\t\tq = Texture_ForName (brush->brush_faces->texdef.name);\n\t\t\t\t\tqglColor3f (q->color[0], q->color[1], q->color[2]);\n\t\t\t\t\tqglBegin (GL_QUADS);\n\t\t\t\t\tqglVertex2f (-xCam, bottom);\n\t\t\t\t\tqglVertex2f (xCam, bottom);\n\t\t\t\t\tqglVertex2f (xCam, top);\n\t\t\t\t\tqglVertex2f (-xCam, top);\n\t\t\t\t\tqglEnd ();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t  qglColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES]);\n\t\tqglBegin (GL_LINE_LOOP);\n\t\tqglVertex2f (-xCam, brush->mins[2]);\n\t\tqglVertex2f (xCam, brush->mins[2]);\n\t\tqglVertex2f (xCam, brush->maxs[2]);\n\t\tqglVertex2f (-xCam, brush->maxs[2]);\n\t\tqglEnd ();\n\t}\n\n\n\tZDrawCameraIcon ();\n\n  qglFinish();\n\tQE_CheckOpenGLForErrors();\n\n\tif (z.timing)\n\t{\n\t\tend = Sys_DoubleTime ();\n\t\tSys_Printf (\"z: %i ms\\n\", (int)(1000*(end-start)));\n\t}\n}\n\n"
  },
  {
    "path": "q3radiant/Z.H",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n// window system independent camera view code\n\ntypedef struct\n{\n\tint\t\twidth, height;\n\n\tqboolean\ttiming;\n\n\tvec3_t\torigin;\t\t\t// at center of window\n\tfloat\tscale;\n} z_t;\n\nextern z_t z;\n\nvoid Z_Init (void);\nvoid Z_MouseDown (int x, int y, int buttons);\nvoid Z_MouseUp (int x, int y, int buttons);\nvoid Z_MouseMoved (int x, int y, int buttons);\nvoid Z_Draw (void);\n\n"
  },
  {
    "path": "q3radiant/ZView.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// ZView.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"ZView.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CZView\n\nIMPLEMENT_DYNCREATE(CZView, CView)\n\nCZView::CZView()\n{\n}\n\nCZView::~CZView()\n{\n}\n\n\nBEGIN_MESSAGE_MAP(CZView, CView)\n\t//{{AFX_MSG_MAP(CZView)\n\tON_WM_CREATE()\n\tON_WM_KEYDOWN()\n\tON_WM_SIZE()\n\tON_WM_DESTROY()\n\tON_WM_LBUTTONUP()\n\tON_WM_LBUTTONDOWN()\n\tON_WM_RBUTTONUP()\n\tON_WM_RBUTTONDOWN()\n\tON_WM_MOUSEMOVE()\n\tON_WM_GETMINMAXINFO()\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CZView drawing\n\nvoid CZView::OnDraw(CDC* pDC)\n{\n\tCDocument* pDoc = GetDocument();\n\t// TODO: add draw code here\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// CZView diagnostics\n\n#ifdef _DEBUG\nvoid CZView::AssertValid() const\n{\n\tCView::AssertValid();\n}\n\nvoid CZView::Dump(CDumpContext& dc) const\n{\n\tCView::Dump(dc);\n}\n#endif //_DEBUG\n\n/////////////////////////////////////////////////////////////////////////////\n// CZView message handlers\n\nint CZView::OnCreate(LPCREATESTRUCT lpCreateStruct) \n{\n\tif (CView::OnCreate(lpCreateStruct) == -1)\n\t\treturn -1;\n\t\n\t\n\treturn 0;\n}\n\nvoid CZView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) \n{\n\t// TODO: Add your message handler code here and/or call default\n\t\n\tCView::OnKeyDown(nChar, nRepCnt, nFlags);\n}\n\nvoid CZView::OnSize(UINT nType, int cx, int cy) \n{\n\tCView::OnSize(nType, cx, cy);\n\t\n\t// TODO: Add your message handler code here\n\t\n}\n\nvoid CZView::OnDestroy() \n{\n\tCView::OnDestroy();\n\t\n\t// TODO: Add your message handler code here\n\t\n}\n\nvoid CZView::OnLButtonUp(UINT nFlags, CPoint point) \n{\n\t// TODO: Add your message handler code here and/or call default\n\t\n\tCView::OnLButtonUp(nFlags, point);\n}\n\nvoid CZView::OnLButtonDown(UINT nFlags, CPoint point) \n{\n\t// TODO: Add your message handler code here and/or call default\n\t\n\tCView::OnLButtonDown(nFlags, point);\n}\n\nvoid CZView::OnRButtonUp(UINT nFlags, CPoint point) \n{\n\t// TODO: Add your message handler code here and/or call default\n\t\n\tCView::OnRButtonUp(nFlags, point);\n}\n\nvoid CZView::OnRButtonDown(UINT nFlags, CPoint point) \n{\n\t// TODO: Add your message handler code here and/or call default\n\t\n\tCView::OnRButtonDown(nFlags, point);\n}\n\nvoid CZView::OnMouseMove(UINT nFlags, CPoint point) \n{\n\t// TODO: Add your message handler code here and/or call default\n\t\n\tCView::OnMouseMove(nFlags, point);\n}\n\nvoid CZView::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) \n{\n\t// TODO: Add your message handler code here and/or call default\n\t\n\tCView::OnGetMinMaxInfo(lpMMI);\n}\n"
  },
  {
    "path": "q3radiant/ZView.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_ZVIEW_H__5B906AE2_76E3_11D1_8A6E_0000C0B006B6__INCLUDED_)\n#define AFX_ZVIEW_H__5B906AE2_76E3_11D1_8A6E_0000C0B006B6__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// ZView.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CZView view\n\nclass CZView : public CView\n{\nprotected:\n\tCZView();           // protected constructor used by dynamic creation\n\tDECLARE_DYNCREATE(CZView)\n\n// Attributes\npublic:\n\n// Operations\npublic:\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CZView)\n\tprotected:\n\tvirtual void OnDraw(CDC* pDC);      // overridden to draw this view\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\tvirtual ~CZView();\n#ifdef _DEBUG\n\tvirtual void AssertValid() const;\n\tvirtual void Dump(CDumpContext& dc) const;\n#endif\n\n\t// Generated message map functions\nprotected:\n\t//{{AFX_MSG(CZView)\n\tafx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);\n\tafx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);\n\tafx_msg void OnSize(UINT nType, int cx, int cy);\n\tafx_msg void OnDestroy();\n\tafx_msg void OnLButtonUp(UINT nFlags, CPoint point);\n\tafx_msg void OnLButtonDown(UINT nFlags, CPoint point);\n\tafx_msg void OnRButtonUp(UINT nFlags, CPoint point);\n\tafx_msg void OnRButtonDown(UINT nFlags, CPoint point);\n\tafx_msg void OnMouseMove(UINT nFlags, CPoint point);\n\tafx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n/////////////////////////////////////////////////////////////////////////////\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_ZVIEW_H__5B906AE2_76E3_11D1_8A6E_0000C0B006B6__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/ZWnd.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// ZWnd.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"Radiant.h\"\n#include \"ZWnd.h\"\n#include \"qe3.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CZWnd\nIMPLEMENT_DYNCREATE(CZWnd, CWnd);\n\n\nCZWnd::CZWnd()\n{\n}\n\nCZWnd::~CZWnd()\n{\n}\n\n\nBEGIN_MESSAGE_MAP(CZWnd, CWnd)\n\t//{{AFX_MSG_MAP(CZWnd)\n\tON_WM_CREATE()\n\tON_WM_DESTROY()\n\tON_WM_KEYDOWN()\n\tON_WM_LBUTTONDOWN()\n\tON_WM_MBUTTONDOWN()\n\tON_WM_RBUTTONDOWN()\n\tON_WM_PAINT()\n\tON_WM_GETMINMAXINFO()\n\tON_WM_MOUSEMOVE()\n\tON_WM_SIZE()\n\tON_WM_NCCALCSIZE()\n\tON_WM_KILLFOCUS()\n\tON_WM_SETFOCUS()\n\tON_WM_CLOSE()\n\tON_WM_LBUTTONUP()\n\tON_WM_MBUTTONUP()\n\tON_WM_RBUTTONUP()\n\tON_WM_KEYUP()\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n\n/////////////////////////////////////////////////////////////////////////////\n// CZWnd message handlers\n\nint CZWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) \n{\n\tif (CWnd::OnCreate(lpCreateStruct) == -1)\n\t\treturn -1;\n\n\tg_qeglobals.d_hwndZ = GetSafeHwnd();\n\n  m_dcZ = ::GetDC(GetSafeHwnd());\n  QEW_SetupPixelFormat(m_dcZ, false);\n\tif ((m_hglrcZ = qwglCreateContext(m_dcZ )) == 0)\n\t  Error(\"wglCreateContext in CZWnd::OnCreate failed\");\n\n\tif (!qwglShareLists(g_qeglobals.d_hglrcBase, m_hglrcZ))\n\t  Error( \"wglShareLists in CZWnd::OnCreate failed\");\n\n  if (!qwglMakeCurrent(m_dcZ, m_hglrcZ))\n\t  Error (\"wglMakeCurrent in CZWnd::OnCreate failed\");\n\n\treturn 0;\n}\n\nvoid CZWnd::OnDestroy() \n{\n  QEW_StopGL(GetSafeHwnd(), m_hglrcZ, m_dcZ);\n\tCWnd::OnDestroy();\n}\n\nvoid CZWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) \n{\n  g_pParentWnd->HandleKey(nChar, nRepCnt, nFlags);\n}\n\nvoid CZWnd::OnLButtonDown(UINT nFlags, CPoint point) \n{\n  SetFocus();\n  SetCapture();\n  CRect rctZ;\n  GetClientRect(rctZ);\n\tZ_MouseDown (point.x, rctZ.Height() - 1 - point.y , nFlags);\n}\n\nvoid CZWnd::OnMButtonDown(UINT nFlags, CPoint point) \n{\n  SetFocus();\n  SetCapture();\n  CRect rctZ;\n  GetClientRect(rctZ);\n\tZ_MouseDown (point.x, rctZ.Height() - 1 - point.y , nFlags);\n}\n\nvoid CZWnd::OnRButtonDown(UINT nFlags, CPoint point) \n{\n  SetFocus();\n  SetCapture();\n  CRect rctZ;\n  GetClientRect(rctZ);\n\tZ_MouseDown (point.x, rctZ.Height() - 1 - point.y , nFlags);\n}\n\nvoid CZWnd::OnPaint() \n{\n\tCPaintDC dc(this); // device context for painting\n  //if (!wglMakeCurrent(m_dcZ, m_hglrcZ))\n  if (!qwglMakeCurrent(dc.m_hDC, m_hglrcZ))\n  {\n    Sys_Printf(\"ERROR: wglMakeCurrent failed..\\n \");\n    Sys_Printf(\"Please restart Q3Radiant if the Z view is not working\\n\");\n  }\n  else\n  {\n\t  QE_CheckOpenGLForErrors();\n    Z_Draw ();\n\t  //qwglSwapBuffers(m_dcZ);\n\t  qwglSwapBuffers(dc.m_hDC);\n    TRACE(\"Z Paint\\n\");\n  }\n}\n\nvoid CZWnd::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) \n{\n\tlpMMI->ptMinTrackSize.x = ZWIN_WIDTH;\n}\n\nvoid CZWnd::OnMouseMove(UINT nFlags, CPoint point) \n{\n  CRect rctZ;\n  GetClientRect(rctZ);\n  float fz = z.origin[2] + ((rctZ.Height() - 1 - point.y) - (z.height/2)) / z.scale;\n\tfz = floor(fz / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize;\n  CString strStatus;\n  strStatus.Format(\"Z:: %.1f\", fz);\n  g_pParentWnd->SetStatusText(1, strStatus);\n  Z_MouseMoved (point.x, rctZ.Height() - 1 - point.y, nFlags);\n}\n\nvoid CZWnd::OnSize(UINT nType, int cx, int cy) \n{\n\tCWnd::OnSize(nType, cx, cy);\n  CRect rctZ;\n  GetClientRect(rctZ);\n  z.width = rctZ.right;\n\tz.height = rctZ.bottom;\n  if (z.width < 10)\n    z.width = 10;\n  if (z.height < 10)\n    z.height = 10;\n  Invalidate();\n}\n\nvoid CZWnd::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp) \n{\n\tCWnd::OnNcCalcSize(bCalcValidRects, lpncsp);\n}\n\nvoid CZWnd::OnKillFocus(CWnd* pNewWnd) \n{\n\tCWnd::OnKillFocus(pNewWnd);\n\tSendMessage(WM_NCACTIVATE, FALSE , 0 );\n}\n\nvoid CZWnd::OnSetFocus(CWnd* pOldWnd) \n{\n\tCWnd::OnSetFocus(pOldWnd);\n\tSendMessage(WM_NCACTIVATE, TRUE , 0 );\n}\n\nvoid CZWnd::OnClose() \n{\n\tCWnd::OnClose();\n}\n\nvoid CZWnd::OnLButtonUp(UINT nFlags, CPoint point) \n{\n  CRect rctZ;\n  GetClientRect(rctZ);\n\tZ_MouseUp (point.x, rctZ.bottom - 1 - point.y, nFlags);\n\tif (! (nFlags & (MK_LBUTTON|MK_RBUTTON|MK_MBUTTON)))\n  \tReleaseCapture ();\n}\n\nvoid CZWnd::OnMButtonUp(UINT nFlags, CPoint point) \n{\n  CRect rctZ;\n  GetClientRect(rctZ);\n\tZ_MouseUp (point.x, rctZ.bottom - 1 - point.y, nFlags);\n\tif (! (nFlags & (MK_LBUTTON|MK_RBUTTON|MK_MBUTTON)))\n  \tReleaseCapture ();\n}\n\nvoid CZWnd::OnRButtonUp(UINT nFlags, CPoint point) \n{\n  CRect rctZ;\n  GetClientRect(rctZ);\n\tZ_MouseUp (point.x, rctZ.bottom - 1 - point.y, nFlags);\n\tif (! (nFlags & (MK_LBUTTON|MK_RBUTTON|MK_MBUTTON)))\n  \tReleaseCapture ();\n}\n\n\nBOOL CZWnd::PreCreateWindow(CREATESTRUCT& cs) \n{\n  WNDCLASS wc;\n  HINSTANCE hInstance = AfxGetInstanceHandle();\n  if (::GetClassInfo(hInstance, Z_WINDOW_CLASS, &wc) == FALSE)\n  {\n    // Register a new class\n  \tmemset (&wc, 0, sizeof(wc));\n    wc.style         = CS_NOCLOSE | CS_OWNDC;\n    wc.lpszClassName = Z_WINDOW_CLASS;\n    wc.hCursor       = LoadCursor (NULL,IDC_ARROW);\n    wc.lpfnWndProc = ::DefWindowProc;\n    if (AfxRegisterClass(&wc) == FALSE)\n      Error (\"CZWnd RegisterClass: failed\");\n  }\n\n  cs.lpszClass = Z_WINDOW_CLASS;\n  cs.lpszName = \"Z\";\n  if (cs.style != QE3_CHILDSTYLE)\n    cs.style = QE3_SPLITTER_STYLE;\n\n\treturn CWnd::PreCreateWindow(cs);\n}\n\n\nvoid CZWnd::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) \n{\n  g_pParentWnd->HandleKey(nChar, nRepCnt, nFlags, false);\n}\n"
  },
  {
    "path": "q3radiant/ZWnd.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_ZWND_H__44B4BA02_781B_11D1_B53C_00AA00A410FC__INCLUDED_)\n#define AFX_ZWND_H__44B4BA02_781B_11D1_B53C_00AA00A410FC__INCLUDED_\n\n#if _MSC_VER >= 1000\n#pragma once\n#endif // _MSC_VER >= 1000\n// ZWnd.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CZWnd window\n\nclass CZWnd : public CWnd\n{\n  DECLARE_DYNCREATE(CZWnd);\n// Construction\npublic:\n\tCZWnd();\n\n// Attributes\npublic:\n\n// Operations\npublic:\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CZWnd)\n\tprotected:\n\tvirtual BOOL PreCreateWindow(CREATESTRUCT& cs);\n\t//}}AFX_VIRTUAL\n\n// Implementation\npublic:\n\tvirtual ~CZWnd();\n\n\t// Generated message map functions\nprotected:\n  HDC m_dcZ;\n  HGLRC m_hglrcZ;\n\t//{{AFX_MSG(CZWnd)\n\tafx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);\n\tafx_msg void OnDestroy();\n\tafx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);\n\tafx_msg void OnLButtonDown(UINT nFlags, CPoint point);\n\tafx_msg void OnMButtonDown(UINT nFlags, CPoint point);\n\tafx_msg void OnRButtonDown(UINT nFlags, CPoint point);\n\tafx_msg void OnPaint();\n\tafx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);\n\tafx_msg void OnMouseMove(UINT nFlags, CPoint point);\n\tafx_msg void OnSize(UINT nType, int cx, int cy);\n\tafx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp);\n\tafx_msg void OnKillFocus(CWnd* pNewWnd);\n\tafx_msg void OnSetFocus(CWnd* pOldWnd);\n\tafx_msg void OnClose();\n\tafx_msg void OnLButtonUp(UINT nFlags, CPoint point);\n\tafx_msg void OnMButtonUp(UINT nFlags, CPoint point);\n\tafx_msg void OnRButtonUp(UINT nFlags, CPoint point);\n\tafx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n/////////////////////////////////////////////////////////////////////////////\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Developer Studio will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_ZWND_H__44B4BA02_781B_11D1_B53C_00AA00A410FC__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/brush_primit.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"stdafx.h\"\n#include \"qe3.h\"\n\n// compute a determinant using Sarrus rule\n//++timo \"inline\" this with a macro\n// NOTE : the three vec3_t are understood as columns of the matrix\nvec_t SarrusDet(vec3_t a, vec3_t b, vec3_t c)\n{\n\treturn a[0]*b[1]*c[2]+b[0]*c[1]*a[2]+c[0]*a[1]*b[2]\n\t\t-c[0]*b[1]*a[2]-a[1]*b[0]*c[2]-a[0]*b[2]*c[1];\n}\n\n//++timo replace everywhere texX by texS etc. ( ----> and in q3map !) \n// NOTE : ComputeAxisBase here and in q3map code must always BE THE SAME !\n// WARNING : special case behaviour of atan2(y,x) <-> atan(y/x) might not be the same everywhere when x == 0\n// rotation by (0,RotY,RotZ) assigns X to normal\nvoid ComputeAxisBase(vec3_t normal,vec3_t texS,vec3_t texT )\n{\n\tvec_t RotY,RotZ;\n\t// do some cleaning\n\tif (fabs(normal[0])<1e-6)\n\t\tnormal[0]=0.0f;\n\tif (fabs(normal[1])<1e-6)\n\t\tnormal[1]=0.0f;\n\tif (fabs(normal[2])<1e-6)\n\t\tnormal[2]=0.0f;\n\tRotY=-atan2(normal[2],sqrt(normal[1]*normal[1]+normal[0]*normal[0]));\n\tRotZ=atan2(normal[1],normal[0]);\n\t// rotate (0,1,0) and (0,0,1) to compute texS and texT\n\ttexS[0]=-sin(RotZ);\n\ttexS[1]=cos(RotZ);\n\ttexS[2]=0;\n\t// the texT vector is along -Z ( T texture coorinates axis )\n\ttexT[0]=-sin(RotY)*cos(RotZ);\n\ttexT[1]=-sin(RotY)*sin(RotZ);\n\ttexT[2]=-cos(RotY);\n}\n\nvoid FaceToBrushPrimitFace(face_t *f)\n{\n\tvec3_t texX,texY;\n\tvec3_t proj;\n\t// ST of (0,0) (1,0) (0,1)\n\tvec_t ST[3][5]; // [ point index ] [ xyz ST ]\n\t//++timo not used as long as brushprimit_texdef and texdef are static\n/*\tf->brushprimit_texdef.contents=f->texdef.contents;\n\tf->brushprimit_texdef.flags=f->texdef.flags;\n\tf->brushprimit_texdef.value=f->texdef.value;\n\tstrcpy(f->brushprimit_texdef.name,f->texdef.name); */\n#ifdef _DEBUG\n\tif ( f->plane.normal[0]==0.0f && f->plane.normal[1]==0.0f && f->plane.normal[2]==0.0f )\n\t{\n\t\tSys_Printf(\"Warning : f->plane.normal is (0,0,0) in FaceToBrushPrimitFace\\n\");\n\t}\n\t// check d_texture\n\tif (!f->d_texture)\n\t{\n\t\tSys_Printf(\"Warning : f.d_texture is NULL in FaceToBrushPrimitFace\\n\");\n\t\treturn;\n\t}\n#endif\n\t// compute axis base\n\tComputeAxisBase(f->plane.normal,texX,texY);\n\t// compute projection vector\n\tVectorCopy(f->plane.normal,proj);\n\tVectorScale(proj,f->plane.dist,proj);\n\t// (0,0) in plane axis base is (0,0,0) in world coordinates + projection on the affine plane\n\t// (1,0) in plane axis base is texX in world coordinates + projection on the affine plane\n\t// (0,1) in plane axis base is texY in world coordinates + projection on the affine plane\n\t// use old texture code to compute the ST coords of these points\n\tVectorCopy(proj,ST[0]);\n\tEmitTextureCoordinates(ST[0], f->d_texture, f);\n\tVectorCopy(texX,ST[1]);\n\tVectorAdd(ST[1],proj,ST[1]);\n\tEmitTextureCoordinates(ST[1], f->d_texture, f);\n\tVectorCopy(texY,ST[2]);\n\tVectorAdd(ST[2],proj,ST[2]);\n\tEmitTextureCoordinates(ST[2], f->d_texture, f);\n\t// compute texture matrix\n\tf->brushprimit_texdef.coords[0][2]=ST[0][3];\n\tf->brushprimit_texdef.coords[1][2]=ST[0][4];\n\tf->brushprimit_texdef.coords[0][0]=ST[1][3]-f->brushprimit_texdef.coords[0][2];\n\tf->brushprimit_texdef.coords[1][0]=ST[1][4]-f->brushprimit_texdef.coords[1][2];\n\tf->brushprimit_texdef.coords[0][1]=ST[2][3]-f->brushprimit_texdef.coords[0][2];\n\tf->brushprimit_texdef.coords[1][1]=ST[2][4]-f->brushprimit_texdef.coords[1][2];\n}\n\n// compute texture coordinates for the winding points\nvoid EmitBrushPrimitTextureCoordinates(face_t * f, winding_t * w)\n{\n\tvec3_t texX,texY;\n\tvec_t x,y;\n\t// compute axis base\n\tComputeAxisBase(f->plane.normal,texX,texY);\n\t// in case the texcoords matrix is empty, build a default one\n\t// same behaviour as if scale[0]==0 && scale[1]==0 in old code\n\tif (f->brushprimit_texdef.coords[0][0]==0 && f->brushprimit_texdef.coords[1][0]==0 && f->brushprimit_texdef.coords[0][1]==0 && f->brushprimit_texdef.coords[1][1]==0)\n\t{\n\t\tf->brushprimit_texdef.coords[0][0] = 1.0f;\n\t\tf->brushprimit_texdef.coords[1][1] = 1.0f;\n\t\tConvertTexMatWithQTexture( &f->brushprimit_texdef, NULL, &f->brushprimit_texdef, f->d_texture );\n\t}\n\tint i;\n    for (i=0 ; i<w->numpoints ; i++)\n\t{\n\t\tx=DotProduct(w->points[i],texX);\n\t\ty=DotProduct(w->points[i],texY);\n#ifdef _DEBUG\n\t\tif (g_qeglobals.bNeedConvert)\n\t\t{\n\t\t\t// check we compute the same ST as the traditional texture computation used before\n\t\t\tvec_t S=f->brushprimit_texdef.coords[0][0]*x+f->brushprimit_texdef.coords[0][1]*y+f->brushprimit_texdef.coords[0][2];\n\t\t\tvec_t T=f->brushprimit_texdef.coords[1][0]*x+f->brushprimit_texdef.coords[1][1]*y+f->brushprimit_texdef.coords[1][2];\n\t\t\tif ( fabs(S-w->points[i][3])>1e-2 || fabs(T-w->points[i][4])>1e-2 )\n\t\t\t{\n\t\t\t\tif ( fabs(S-w->points[i][3])>1e-4 || fabs(T-w->points[i][4])>1e-4 )\n\t\t\t\t\tSys_Printf(\"Warning : precision loss in brush -> brush primitive texture computation\\n\");\n\t\t\t\telse\n\t\t\t\t\tSys_Printf(\"Warning : brush -> brush primitive texture computation bug detected\\n\");\n\t\t\t}\n\t\t}\n#endif\n\t\tw->points[i][3]=f->brushprimit_texdef.coords[0][0]*x+f->brushprimit_texdef.coords[0][1]*y+f->brushprimit_texdef.coords[0][2];\n\t\tw->points[i][4]=f->brushprimit_texdef.coords[1][0]*x+f->brushprimit_texdef.coords[1][1]*y+f->brushprimit_texdef.coords[1][2];\n\t}\n}\n\n// parse a brush in brush primitive format\nvoid BrushPrimit_Parse(brush_t\t*b)\n{\n\tepair_t\t\t*ep;\n\tface_t\t\t*f;\n\tint\t\t\ti,j;\n\tGetToken (true);\n\tif (strcmp (token, \"{\"))\n\t{\n\t\tWarning (\"parsing brush primitive\");\n\t\treturn;\n\t}\n\tdo\n\t{\n\t\tif (!GetToken (true))\n\t\t\tbreak;\n\t\tif (!strcmp (token, \"}\") )\n\t\t\tbreak;\n\t\t// reading of b->epairs if any\n\t\tif (strcmp (token, \"(\") )\n\t\t{\n\t\t\tep = ParseEpair();\n\t\t\tep->next = b->epairs;\n\t\t\tb->epairs = ep;\n\t\t}\n\t\telse\n\t\t// it's a face\n\t\t{\n\t\t\tf = Face_Alloc();\n\t\t\tf->next = NULL;\n\t\t\tif (!b->brush_faces)\n\t\t\t  \tb->brush_faces = f;\n\t\t  \telse\n\t\t\t{\n\t\t\t\tface_t *scan;\n\t\t\t\tfor (scan=b->brush_faces ; scan->next ; scan=scan->next)\n\t\t\t\t\t;\n\t\t\t\tscan->next = f;\n\t\t  \t}\n\n\t\t\t// read the three point plane definition\n\t\t\tfor (i=0 ; i<3 ; i++)\n\t\t\t{\n\t\t\t\tif (i != 0)\n\t\t\t\t\tGetToken (true);\n\t\t\t\tif (strcmp (token, \"(\") )\n\t\t\t\t{\n\t\t\t\t\tWarning (\"parsing brush\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfor (j=0 ; j<3 ; j++)\n\t\t\t\t{\n\t\t\t\t\tGetToken (false);\n\t\t\t\t\tf->planepts[i][j] = atof(token);\n\t\t\t\t}\n\t\t\t\tGetToken (false);\n\t\t\t\tif (strcmp (token, \")\") )\n\t\t\t\t{\n\t\t\t\t\tWarning (\"parsing brush\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// texture coordinates\n\t\t\tGetToken (false);\n\t\t\tif (strcmp(token, \"(\"))\n\t\t\t{\n\t\t\t\tWarning (\"parsing brush primitive\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tGetToken (false);\n\t\t\tif (strcmp(token, \"(\"))\n\t\t\t{\n\t\t\t\tWarning (\"parsing brush primitive\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor (j=0;j<3;j++)\n\t\t\t{\n\t\t\t\tGetToken(false);\n\t\t\t\tf->brushprimit_texdef.coords[0][j]=atof(token);\n\t\t\t}\n\t\t\tGetToken (false);\n\t\t\tif (strcmp(token, \")\"))\n\t\t\t{\n\t\t\t\tWarning (\"parsing brush primitive\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tGetToken (false);\n\t\t\tif (strcmp(token, \"(\"))\n\t\t\t{\n\t\t\t\tWarning (\"parsing brush primitive\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor (j=0;j<3;j++)\n\t\t\t{\n\t\t\t\tGetToken(false);\n\t\t\t\tf->brushprimit_texdef.coords[1][j]=atof(token);\n\t\t\t}\n\t\t\tGetToken (false);\n\t\t\tif (strcmp(token, \")\"))\n\t\t\t{\n\t\t\t\tWarning (\"parsing brush primitive\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tGetToken (false);\n\t\t\tif (strcmp(token, \")\"))\n\t\t\t{\n\t\t\t\tWarning (\"parsing brush primitive\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// read the texturedef\n\t\t\tGetToken (false);\n\t\t\t//strcpy(f->texdef.name, token);\n\t\t\tf->texdef.SetName(token);\n\t\t\tif (TokenAvailable ())\n\t\t\t{\n\t\t\t\tGetToken (false);\n\t\t\t\tf->texdef.contents = atoi(token);\n        GetToken (false);\n\t\t\t\tf->texdef.flags = atoi(token);\n\t\t\t\tGetToken (false);\n\t\t\t\tf->texdef.value = atoi(token);\n\t\t\t}\n\t\t}\n\t} while (1);\n}\n\n// compute a fake shift scale rot representation from the texture matrix\n// these shift scale rot values are to be understood in the local axis base\nvoid TexMatToFakeTexCoords( vec_t texMat[2][3], float shift[2], float *rot, float scale[2] )\n{\n#ifdef _DEBUG\n\t// check this matrix is orthogonal\n\tif (fabs(texMat[0][0]*texMat[0][1]+texMat[1][0]*texMat[1][1])>ZERO_EPSILON)\n\t\tSys_Printf(\"Warning : non orthogonal texture matrix in TexMatToFakeTexCoords\\n\");\n#endif\n\tscale[0]=sqrt(texMat[0][0]*texMat[0][0]+texMat[1][0]*texMat[1][0]);\n\tscale[1]=sqrt(texMat[0][1]*texMat[0][1]+texMat[1][1]*texMat[1][1]);\n#ifdef _DEBUG\n\tif (scale[0]<ZERO_EPSILON || scale[1]<ZERO_EPSILON)\n\t\tSys_Printf(\"Warning : unexpected scale==0 in TexMatToFakeTexCoords\\n\");\n#endif\n\t// compute rotate value\n\tif (fabs(texMat[0][0])<ZERO_EPSILON)\n\t{\n#ifdef _DEBUG\n\t\t// check brushprimit_texdef[1][0] is not zero\n\t\tif (fabs(texMat[1][0])<ZERO_EPSILON)\n\t\t\tSys_Printf(\"Warning : unexpected texdef[1][0]==0 in TexMatToFakeTexCoords\\n\");\n#endif\n\t\t// rotate is +-90\n\t\tif (texMat[1][0]>0)\n\t\t\t*rot=90.0f;\n\t\telse\n\t\t\t*rot=-90.0f;\n\t}\n\telse\n\t*rot = RAD2DEG( atan2( texMat[1][0], texMat[0][0] ) );\n\tshift[0] = -texMat[0][2];\n\tshift[1] = texMat[1][2];\n}\n\n// compute back the texture matrix from fake shift scale rot\n// the matrix returned must be understood as a qtexture_t with width=2 height=2 ( the default one )\nvoid FakeTexCoordsToTexMat( float shift[2], float rot, float scale[2], vec_t texMat[2][3] )\n{\n\ttexMat[0][0] = scale[0] * cos( DEG2RAD( rot ) );\n\ttexMat[1][0] = scale[0] * sin( DEG2RAD( rot ) );\n\ttexMat[0][1] = -1.0f * scale[1] * sin( DEG2RAD( rot ) );\n\ttexMat[1][1] = scale[1] * cos( DEG2RAD( rot ) );\n\ttexMat[0][2] = -shift[0];\n\ttexMat[1][2] = shift[1];\n}\n\n// convert a texture matrix between two qtexture_t\n// if NULL for qtexture_t, basic 2x2 texture is assumed ( straight mapping between s/t coordinates and geometric coordinates )\nvoid ConvertTexMatWithQTexture( brushprimit_texdef_t *texMat1, qtexture_t *qtex1, brushprimit_texdef_t *texMat2, qtexture_t *qtex2 )\n{\n\tfloat s1,s2;\n\ts1 = ( qtex1 ? static_cast<float>( qtex1->width ) : 2.0f ) / ( qtex2 ? static_cast<float>( qtex2->width ) : 2.0f );\n\ts2 = ( qtex1 ? static_cast<float>( qtex1->height ) : 2.0f ) / ( qtex2 ? static_cast<float>( qtex2->height ) : 2.0f );\n\ttexMat2->coords[0][0]=s1*texMat1->coords[0][0];\n\ttexMat2->coords[0][1]=s1*texMat1->coords[0][1];\n\ttexMat2->coords[0][2]=s1*texMat1->coords[0][2];\n\ttexMat2->coords[1][0]=s2*texMat1->coords[1][0];\n\ttexMat2->coords[1][1]=s2*texMat1->coords[1][1];\n\ttexMat2->coords[1][2]=s2*texMat1->coords[1][2];\n}\n\n// texture locking\nvoid Face_MoveTexture_BrushPrimit(face_t *f, vec3_t delta)\n{\n\tvec3_t texS,texT;\n\tvec_t tx,ty;\n\tvec3_t M[3]; // columns of the matrix .. easier that way\n\tvec_t det;\n\tvec3_t D[2];\n\t// compute plane axis base ( doesn't change with translation )\n\tComputeAxisBase( f->plane.normal, texS, texT );\n\t// compute translation vector in plane axis base\n\ttx = DotProduct( delta, texS );\n\tty = DotProduct( delta, texT );\n\t// fill the data vectors\n\tM[0][0]=tx; M[0][1]=1.0f+tx; M[0][2]=tx;\n\tM[1][0]=ty; M[1][1]=ty; M[1][2]=1.0f+ty;\n\tM[2][0]=1.0f; M[2][1]=1.0f; M[2][2]=1.0f;\n\tD[0][0]=f->brushprimit_texdef.coords[0][2];\n\tD[0][1]=f->brushprimit_texdef.coords[0][0]+f->brushprimit_texdef.coords[0][2];\n\tD[0][2]=f->brushprimit_texdef.coords[0][1]+f->brushprimit_texdef.coords[0][2];\n\tD[1][0]=f->brushprimit_texdef.coords[1][2];\n\tD[1][1]=f->brushprimit_texdef.coords[1][0]+f->brushprimit_texdef.coords[1][2];\n\tD[1][2]=f->brushprimit_texdef.coords[1][1]+f->brushprimit_texdef.coords[1][2];\n\t// solve\n\tdet = SarrusDet( M[0], M[1], M[2] );\n\tf->brushprimit_texdef.coords[0][0] = SarrusDet( D[0], M[1], M[2] ) / det;\n\tf->brushprimit_texdef.coords[0][1] = SarrusDet( M[0], D[0], M[2] ) / det;\n\tf->brushprimit_texdef.coords[0][2] = SarrusDet( M[0], M[1], D[0] ) / det;\n\tf->brushprimit_texdef.coords[1][0] = SarrusDet( D[1], M[1], M[2] ) / det;\n\tf->brushprimit_texdef.coords[1][1] = SarrusDet( M[0], D[1], M[2] ) / det;\n\tf->brushprimit_texdef.coords[1][2] = SarrusDet( M[0], M[1], D[1] ) / det;\n}\n\n// call Face_MoveTexture_BrushPrimit after vec3_t computation\nvoid Select_ShiftTexture_BrushPrimit( face_t *f, int x, int y )\n{\n\tvec3_t texS,texT;\n\tvec3_t delta;\n\tComputeAxisBase( f->plane.normal, texS, texT );\n\tVectorScale( texS, static_cast<float>(x), texS );\n\tVectorScale( texT, static_cast<float>(y), texT );\n\tVectorCopy( texS, delta );\n\tVectorAdd( delta, texT, delta );\n\tFace_MoveTexture_BrushPrimit( f, delta );\n}\n\n// texture locking\n// called before the points on the face are actually rotated\nvoid RotateFaceTexture_BrushPrimit(face_t *f, int nAxis, float fDeg, vec3_t vOrigin )\n{\n\tvec3_t texS,texT;\t\t\t// axis base of the initial plane\n\tvec3_t vRotate;\t\t\t\t// rotation vector\n\tvec3_t Orig;\n\tvec3_t rOrig,rvecS,rvecT;\t// (0,0) (1,0) (0,1) ( initial plane axis base ) after rotation ( world axis base )\n\tvec3_t rNormal;\t\t\t\t// normal of the plane after rotation\n\tvec3_t rtexS,rtexT;\t\t\t// axis base of the rotated plane\n\tvec3_t lOrig,lvecS,lvecT;\t// [2] are not used ( but usefull for debugging )\n\tvec3_t M[3];\n\tvec_t det;\n\tvec3_t D[2];\n\t// compute plane axis base\n\tComputeAxisBase( f->plane.normal, texS, texT );\n\t// compute coordinates of (0,0) (1,0) (0,1) ( initial plane axis base ) after rotation\n\t// (0,0) (1,0) (0,1) ( initial plane axis base ) <-> (0,0,0) texS texT ( world axis base )\n\t// rotation vector\n\tVectorSet( vRotate, 0.0f, 0.0f, 0.0f );\n\tvRotate[nAxis]=fDeg;\n\tVectorSet( Orig, 0.0f, 0.0f, 0.0f );\n\tVectorRotate( Orig, vRotate, vOrigin, rOrig );\n\tVectorRotate( texS, vRotate, vOrigin, rvecS );\n\tVectorRotate( texT, vRotate, vOrigin, rvecT );\n\t// compute normal of plane after rotation\n\tVectorRotate( f->plane.normal, vRotate, rNormal );\n\t// compute rotated plane axis base\n\tComputeAxisBase( rNormal, rtexS, rtexT );\n\t// compute S/T coordinates of the three points in rotated axis base ( in M matrix )\n\tlOrig[0] = DotProduct( rOrig, rtexS );\n\tlOrig[1] = DotProduct( rOrig, rtexT );\n\tlvecS[0] = DotProduct( rvecS, rtexS );\n\tlvecS[1] = DotProduct( rvecS, rtexT );\n\tlvecT[0] = DotProduct( rvecT, rtexS );\n\tlvecT[1] = DotProduct( rvecT, rtexT );\n\tM[0][0] = lOrig[0]; M[1][0] = lOrig[1]; M[2][0] = 1.0f;\n\tM[0][1] = lvecS[0]; M[1][1] = lvecS[1]; M[2][1] = 1.0f;\n\tM[0][2] = lvecT[0]; M[1][2] = lvecT[1]; M[2][2] = 1.0f;\n\t// fill data vector\n\tD[0][0]=f->brushprimit_texdef.coords[0][2];\n\tD[0][1]=f->brushprimit_texdef.coords[0][0]+f->brushprimit_texdef.coords[0][2];\n\tD[0][2]=f->brushprimit_texdef.coords[0][1]+f->brushprimit_texdef.coords[0][2];\n\tD[1][0]=f->brushprimit_texdef.coords[1][2];\n\tD[1][1]=f->brushprimit_texdef.coords[1][0]+f->brushprimit_texdef.coords[1][2];\n\tD[1][2]=f->brushprimit_texdef.coords[1][1]+f->brushprimit_texdef.coords[1][2];\n\t// solve\n\tdet = SarrusDet( M[0], M[1], M[2] );\n\tf->brushprimit_texdef.coords[0][0] = SarrusDet( D[0], M[1], M[2] ) / det;\n\tf->brushprimit_texdef.coords[0][1] = SarrusDet( M[0], D[0], M[2] ) / det;\n\tf->brushprimit_texdef.coords[0][2] = SarrusDet( M[0], M[1], D[0] ) / det;\n\tf->brushprimit_texdef.coords[1][0] = SarrusDet( D[1], M[1], M[2] ) / det;\n\tf->brushprimit_texdef.coords[1][1] = SarrusDet( M[0], D[1], M[2] ) / det;\n\tf->brushprimit_texdef.coords[1][2] = SarrusDet( M[0], M[1], D[1] ) / det;\n}\n\n// best fitted 2D vector is x.X+y.Y\nvoid ComputeBest2DVector( vec3_t v, vec3_t X, vec3_t Y, int &x, int &y )\n{\n\tdouble sx,sy;\n\tsx = DotProduct( v, X );\n\tsy = DotProduct( v, Y );\n\tif ( fabs(sy) > fabs(sx) )\n\t{\n\t\tx = 0;\n\t\tif ( sy > 0.0 )\n\t\t\ty =  1;\n\t\telse\n\t\t\ty = -1;\n\t}\n\telse\n\t{\n\t\ty = 0;\n\t\tif ( sx > 0.0 )\n\t\t\tx =  1;\n\t\telse\n\t\t\tx = -1;\n\t}\n}\n"
  },
  {
    "path": "q3radiant/cameratargetdlg.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// CameraTargetDlg.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"CameraTargetDlg.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n// CCameraTargetDlg dialog\n\n\nCCameraTargetDlg::CCameraTargetDlg(CWnd* pParent /*=NULL*/)\n\t: CDialog(CCameraTargetDlg::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CCameraTargetDlg)\n\tm_nType = 0;\n\tm_strName = _T(\"\");\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CCameraTargetDlg::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CCameraTargetDlg)\n\tDDX_Radio(pDX, IDC_RADIO_FIXED, m_nType);\n\tDDX_Text(pDX, IDC_EDIT_NAME, m_strName);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CCameraTargetDlg, CDialog)\n\t//{{AFX_MSG_MAP(CCameraTargetDlg)\n\tON_COMMAND(ID_POPUP_NEWCAMERA_FIXED, OnPopupNewcameraFixed)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CCameraTargetDlg message handlers\n\nvoid CCameraTargetDlg::OnPopupNewcameraFixed() \n{\n\t// TODO: Add your command handler code here\n\t\n}\n"
  },
  {
    "path": "q3radiant/cameratargetdlg.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_CAMERATARGETDLG_H__DE6597C1_1F63_4835_8949_5D2D5F208C6B__INCLUDED_)\n#define AFX_CAMERATARGETDLG_H__DE6597C1_1F63_4835_8949_5D2D5F208C6B__INCLUDED_\n\n#if _MSC_VER > 1000\n#pragma once\n#endif // _MSC_VER > 1000\n// CameraTargetDlg.h : header file\n//\n\n/////////////////////////////////////////////////////////////////////////////\n// CCameraTargetDlg dialog\n\nclass CCameraTargetDlg : public CDialog\n{\n// Construction\npublic:\n\tCCameraTargetDlg(CWnd* pParent = NULL);   // standard constructor\n\n// Dialog Data\n\t//{{AFX_DATA(CCameraTargetDlg)\n\tenum { IDD = IDD_DLG_CAMERATARGET };\n\tint\t\tm_nType;\n\tCString\tm_strName;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CCameraTargetDlg)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\n\t// Generated message map functions\n\t//{{AFX_MSG(CCameraTargetDlg)\n\tafx_msg void OnPopupNewcameraFixed();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Visual C++ will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_CAMERATARGETDLG_H__DE6597C1_1F63_4835_8949_5D2D5F208C6B__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/cbrushstub.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"stdafx.h\"\n#include \"qe3.h\"\n\nvoid Curve_Invert (void) \n{\n}\n\nvoid Curve_MakeCurvedBrush (qboolean negative, qboolean top, qboolean bottom, \n\t\t\t\t\tqboolean s1, qboolean s2, qboolean s3, qboolean s4) \n{\n}\n\n\nvoid Curve_BuildPoints (brush_t *b) \n{\n}\n\nvoid Curve_CameraDraw (brush_t *b) \n{\n}\n\nvoid Curve_XYDraw (brush_t *b) \n{\n}\n\nvoid Curve_WriteFile (char *name) \n{\n}\n\nvoid Curve_StripFakePlanes( brush_t *b )\n{\n}\n\nvoid Curve_AddFakePlanes( brush_t *b ) \n{\n}\n\n\nvoid Patch_BrushToMesh(){};\nvoid Patch_GenericMesh(int nWidth, int nHeight, int nOrientation){};\nvoid Patch_ReadFile (char *name){};\nvoid Patch_WriteFile (char *name){}; \nvoid Patch_BuildPoints (brush_t *b){};\nvoid Patch_Move(int n, const vec3_t vMove){};\nvoid Patch_ApplyMatrix(int n, const vec3_t vOrigin, const vec3_t vMatrix[3]){};\nvoid Patch_EditPatch(int n){};\nvoid Patch_Deselect(){};\nvoid Patch_Delete(int n){};\nvoid Patch_Select(int n){};\nvoid Patch_Scale(int n, const vec3_t vOrigin, const vec3_t vAmt){};\nvoid Patch_Cleanup(){};\nbool g_bShowPatchBounds;\nbool g_bPatchWireFrame;\n\n\n"
  },
  {
    "path": "q3radiant/dlgcamera.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// DlgCamera.cpp : implementation file\n//\n\n#include \"stdafx.h\"\n#include \"DlgCamera.h\"\n#include \"DlgEvent.h\"\n#include \"NameDlg.h\"\n#include \"splines/splines.h\"\n#include \"CameraTargetDlg.h\"\n\n#ifdef _DEBUG\n#define new DEBUG_NEW\n#undef THIS_FILE\nstatic char THIS_FILE[] = __FILE__;\n#endif\n\nCDlgCamera g_dlgCamera;\n\n/*\n============\nva\n\ndoes a varargs printf into a temp buffer, so I don't need to have\nvarargs versions of all text functions.\nFIXME: make this buffer size safe someday\n============\n*/\nchar\t*va( char *format, ... ) {\n\tva_list\t\targptr;\n\tstatic char\t\tstring[2][32000];\t// in case va is called by nested functions\n\tstatic int\t\tindex = 0;\n\tchar\t*buf;\n\n\tbuf = string[index & 1];\n\tindex++;\n\n\tva_start (argptr, format);\n\tvsprintf (buf, format,argptr);\n\tva_end (argptr);\n\n\treturn buf;\n}\n\n\nvoid showCameraInspector() {\n\tif (g_dlgCamera.GetSafeHwnd() == NULL) {\n\t\tg_dlgCamera.Create(IDD_DLG_CAMERA);\n\t\tCRect rct;\n\t\tLONG lSize = sizeof(rct);\n\t\tif (LoadRegistryInfo(\"Radiant::CameraInspector\", &rct, &lSize)) {\n\t\t\tg_dlgCamera.SetWindowPos(NULL, rct.left, rct.top, 0,0, SWP_NOSIZE | SWP_SHOWWINDOW);\n\t\t}\n\t\tSys_UpdateWindows(W_ALL);\n\t} \n\tg_dlgCamera.ShowWindow(SW_SHOW);\n\tg_dlgCamera.setupFromCamera();\n}\n/////////////////////////////////////////////////////////////////////////////\n// CDlgCamera dialog\n\n\nCDlgCamera::CDlgCamera(CWnd* pParent /*=NULL*/)\n\t: CDialog(CDlgCamera::IDD, pParent)\n{\n\t//{{AFX_DATA_INIT(CDlgCamera)\n\tm_strName = _T(\"\");\n\tm_fSeconds = 0.0f;\n\tm_trackCamera = TRUE;\n\tm_numSegments = 0;\n\tm_currentSegment = 0;\n\tm_strType = _T(\"\");\n\tm_editPoints = 0;\n\t//}}AFX_DATA_INIT\n}\n\n\nvoid CDlgCamera::DoDataExchange(CDataExchange* pDX)\n{\n\tCDialog::DoDataExchange(pDX);\n\t//{{AFX_DATA_MAP(CDlgCamera)\n\tDDX_Control(pDX, IDC_SCROLLBAR_SEGMENT, m_wndSegments);\n\tDDX_Control(pDX, IDC_LIST_EVENTS, m_wndEvents);\n\tDDX_Control(pDX, IDC_COMBO_SPLINES, m_wndSplines);\n\tDDX_Text(pDX, IDC_EDIT_CAM_NAME, m_strName);\n\tDDX_Text(pDX, IDC_EDIT_LENGTH, m_fSeconds);\n\tDDX_Check(pDX, IDC_CHECK_TRACKCAMERA, m_trackCamera);\n\tDDX_Text(pDX, IDC_EDIT_TOTALSEGMENTS, m_numSegments);\n\tDDX_Text(pDX, IDC_EDIT_SEGMENT, m_currentSegment);\n\tDDX_Text(pDX, IDC_EDIT_TYPE, m_strType);\n\tDDX_Radio(pDX, IDC_RADIO_EDITPOINTS, m_editPoints);\n\t//}}AFX_DATA_MAP\n}\n\n\nBEGIN_MESSAGE_MAP(CDlgCamera, CDialog)\n\t//{{AFX_MSG_MAP(CDlgCamera)\n\tON_BN_CLICKED(IDC_BTN_ADDEVENT, OnBtnAddevent)\n\tON_BN_CLICKED(IDC_BTN_ADDTARGET, OnBtnAddtarget)\n\tON_BN_CLICKED(IDC_BTN_DELEVENT, OnBtnDelevent)\n\tON_CBN_DBLCLK(IDC_COMBO_SPLINES, OnDblclkComboSplines)\n\tON_CBN_SELCHANGE(IDC_COMBO_SPLINES, OnSelchangeComboSplines)\n\tON_LBN_SELCHANGE(IDC_LIST_EVENTS, OnSelchangeListEvents)\n\tON_LBN_DBLCLK(IDC_LIST_EVENTS, OnDblclkListEvents)\n\tON_WM_DESTROY()\n\tON_BN_CLICKED(IDAPPLY, OnApply)\n\tON_WM_HSCROLL()\n\tON_BN_CLICKED(ID_FILE_NEW, OnFileNew)\n\tON_BN_CLICKED(ID_FILE_OPEN, OnFileOpen)\n\tON_BN_CLICKED(ID_FILE_SAVE, OnFileSave)\n\tON_BN_CLICKED(ID_TESTCAMERA, OnTestcamera)\n\tON_BN_CLICKED(IDC_BTN_DELETEPOINTS, OnBtnDeletepoints)\n\tON_BN_CLICKED(IDC_BTN_SELECTALL, OnBtnSelectall)\n\tON_BN_CLICKED(IDC_RADIO_EDITPOINTS, OnRadioEditpoints)\n\tON_BN_CLICKED(IDC_RADIO_EDITPOINTS2, OnRadioAddPoints)\n\t//}}AFX_MSG_MAP\nEND_MESSAGE_MAP()\n\n/////////////////////////////////////////////////////////////////////////////\n// CDlgCamera message handlers\n\nvoid CDlgCamera::OnBtnAddevent() \n{\n\tCDlgEvent dlg;\n\tif (dlg.DoModal() == IDOK) {\n\t\tlong n = m_wndSegments.GetScrollPos() / 4 * 1000;\n\t\tg_splineList->addEvent(static_cast<idCameraEvent::eventType>(dlg.m_event+1), dlg.m_strParm, n);\n\t\tsetupFromCamera();\n\t}\n}\n\nvoid CDlgCamera::OnBtnAddtarget() \n{\n\tCCameraTargetDlg dlg;\n\tif (dlg.DoModal() == IDOK) {\n\t\tg_splineList->addTarget(dlg.m_strName, static_cast<idCameraPosition::positionType>(dlg.m_nType));\n\t\tsetupFromCamera();\n\t\tm_wndSplines.SetCurSel(g_splineList->numTargets());\n\t\tOnSelchangeComboSplines();\n\t\tOnRadioAddPoints();\n\t}\n}\n\nvoid CDlgCamera::OnBtnDelevent() \n{\n\t// TODO: Add your control notification handler code here\n\t\n}\n\nvoid CDlgCamera::OnBtnDeltarget() \n{\n\t// TODO: Add your control notification handler code here\n\t\n}\n\nvoid CDlgCamera::OnDblclkComboSplines() \n{\n\t// TODO: Add your control notification handler code here\n\t\n}\n\nvoid CDlgCamera::OnSelchangeComboSplines() \n{\n\tUpdateData(TRUE);\n\tg_qeglobals.d_select_mode = (m_editPoints == 0) ? sel_editpoint : sel_addpoint;\n\tg_qeglobals.d_numpoints = 0;\n\tg_qeglobals.d_num_move_points = 0;\n\tint i = m_wndSplines.GetCurSel();\n\tif (i > 0) {\n\t\tg_splineList->setActiveTarget(i-1);\n\t\tg_qeglobals.selectObject = g_splineList->getActiveTarget(i-1);\n\t\tg_splineList->startEdit(false);\n\t} else {\n\t\tg_splineList->startEdit(true);\n\t\tg_qeglobals.selectObject = g_splineList->getPositionObj();\n\t}\n\n\t// * 4.0 to set increments in quarter seconds\n\tm_wndSegments.SetScrollRange(0, g_splineList->getTotalTime() * 4.0);\n\n\tSys_UpdateWindows(W_ALL);\n}\n\nvoid CDlgCamera::OnSelchangeListEvents() \n{\n\tint sel = m_wndEvents.GetCurSel();\n\t//g_splineList->setActiveSegment(sel >= 0 ? sel : 0);\n}\n\nvoid CDlgCamera::OnDblclkListEvents() \n{\n\t// TODO: Add your control notification handler code here\n\t\n}\n\nvoid CDlgCamera::setupFromCamera()\n{\n\tif (m_wndSplines.GetSafeHwnd()) {\n\t\tint i;\n\t\tidStr str;\n\t\tm_strName = g_splineList->getName();\n\t\tm_strType = g_splineList->getPositionObj()->typeStr();\n\t\tm_wndSplines.ResetContent();\n\t\tm_wndSplines.AddString(\"Path\");\n\t\tfor (i = 0; i < g_splineList->numTargets(); i++) {\n\t\t\tm_wndSplines.AddString(g_splineList->getActiveTarget(i)->getName());\n\t\t}\n\t\tm_wndSplines.SetCurSel(0);\n\t\tm_fSeconds = g_splineList->getBaseTime();\n\t\tm_wndSegments.SetScrollRange(0, g_splineList->getTotalTime() * 4.0);\n\n\t\tm_wndEvents.ResetContent();\n\t\tfor (i = 0; i < g_splineList->numEvents(); i++) {\n\t\t\tstr = va(\"%s\\t%s\", g_splineList->getEvent(i)->typeStr(), g_splineList->getEvent(i)->getParam());\n\t\t\tm_wndEvents.AddString(str);\n\t\t}\n\t\t//m_currentSegment = g_splineList->getActiveSegment();\n\t\t//m_numSegments = g_splineList->numSegments();\n\t}\n\tg_splineList->startEdit(true);\n\tUpdateData(FALSE);\n}\n\nBOOL CDlgCamera::OnInitDialog() \n{\n\tCDialog::OnInitDialog();\n\tsetupFromCamera();\n\treturn TRUE;  // return TRUE unless you set the focus to a control\n\t              // EXCEPTION: OCX Property Pages should return FALSE\n}\n\nvoid CDlgCamera::OnOK() \n{\n\tg_dlgCamera.ShowWindow(SW_HIDE);\n\tclearSelection();\n\tg_splineList->stopEdit();\n\tSys_UpdateWindows(W_ALL);\n}\n\nvoid CDlgCamera::OnDestroy() \n{\n\tif (GetSafeHwnd()) {\n\t\tCRect rct;\n\t\tGetWindowRect(rct);\n\t\tSaveRegistryInfo(\"Radiant::CameraInspector\", &rct, sizeof(rct));\n\t}\n\tCDialog::OnDestroy();\n\tSys_UpdateWindows(W_ALL);\n}\n\n\nvoid CDlgCamera::OnApply() \n{\n\tUpdateData(TRUE);\n\tg_splineList->setBaseTime(m_fSeconds);\n\tg_splineList->setName(m_strName);\n\tg_splineList->buildCamera();\n\tm_wndSegments.SetScrollRange(0, g_splineList->getTotalTime() * 4.0);\n}\n\nvoid CDlgCamera::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) \n{\n\tCDialog::OnHScroll(nSBCode, nPos, pScrollBar);\n\tint max = g_splineList->getTotalTime() * 4;\n\tif (max == 0) {\n\t\tmax = 1;\n\t}\n\tint n = pScrollBar->GetScrollPos();\n\tswitch (nSBCode) {\n\t\tcase SB_LINEUP : {\n\t\t\tn--;\n\t\t}\n\t\tbreak;\n\t\tcase SB_LINEDOWN : {\n\t\t\tn++;\n\t\t}\n\t\tbreak;\n\t\tcase SB_PAGEUP : {\n\t\t\tn -= (float)max * 0.10;\n\t\t}\n\t\tbreak;\n\t\tcase SB_PAGEDOWN : {\n\t\t\tn += (float)max * 0.10;\n\t\t}\n\t\tbreak;\n\t\tcase SB_THUMBPOSITION : {\n\t\t\tn = nPos;\n\t\t}\n\t\tbreak;\n\t\tcase SB_THUMBTRACK : {\n\t\t\tn = nPos;\n\t\t}\n\t}\n//\tif (n < 0) {\n//\t\tn = 0;\n//\t} else if (n >= g_splineList->numSegments()) {\n//\t\tif (g_splineList->numSegments() == 0) {\n//\t\t\tg_splineList->buildCamera();\n//\t\t}\n//\t\tn = g_splineList->numSegments() - 1;\n//\t}\n\tpScrollBar->SetScrollPos(n);\n\tif (m_trackCamera) {\n\t\tfloat p = (float)n / max;\n\t\tp *= g_splineList->getTotalTime() * 1000;\n\t\tg_splineList->startCamera(0);\n\t\tg_splineList->buildCamera();\n\t\tvec3_t dir;\n\t\tfloat fov;\n\t\tg_splineList->getCameraInfo(p, g_pParentWnd->GetCamera()->Camera().origin, dir, &fov);\n\t\tg_pParentWnd->GetCamera()->Camera().angles[1] = atan2 (dir[1], dir[0])*180/3.14159;\n\t\tg_pParentWnd->GetCamera()->Camera().angles[0] = asin (dir[2])*180/3.14159;\n\n\t}\n\tUpdateData(FALSE);\n\tSys_UpdateWindows(W_XY | W_CAMERA);\n}\n\nvoid CDlgCamera::OnFileNew() \n{\n\tg_splineList->clear();\n\tg_qeglobals.selectObject = g_splineList->getPositionObj();\n\tsetupFromCamera();\n\tSys_UpdateWindows(W_ALL);\n}\n\nvoid CDlgCamera::OnFileOpen() \n{\n\tCNameDlg dlg(\"Open Camera File\");\n\tif (dlg.DoModal() == IDOK) {\n\t\tg_splineList->clear();\n\t\tg_qeglobals.selectObject = g_splineList->getPositionObj();\n\t\tg_splineList->load(va(\"%s.camera\", dlg.m_strName));\n\t\tsetupFromCamera();\n\t\tSys_UpdateWindows(W_ALL);\n\t}\n}\n\nvoid CDlgCamera::OnFileSave() \n{\n\tCNameDlg dlg(\"Save Camera File\");\n\tif (dlg.DoModal() == IDOK) {\n\t\tg_splineList->save(va(\"%s.camera\", dlg.m_strName));\n\t}\n}\n\nvoid CDlgCamera::OnTestcamera() \n{\n\t// TODO: Add your control notification handler code here\n\t\n}\n\nvoid CDlgCamera::OnBtnDeletepoints() \n{\n\t// TODO: Add your control notification handler code here\n\t\n}\n\nvoid CDlgCamera::OnBtnSelectall() \n{\n\t// TODO: Add your control notification handler code here\n\t\n}\n\nvoid CDlgCamera::OnRadioEditpoints() \n{\n\tUpdateData(TRUE);\n\tg_qeglobals.d_select_mode = sel_editpoint;\n}\n\nvoid CDlgCamera::OnRadioAddPoints() \n{\n\tUpdateData(TRUE);\n\tg_qeglobals.d_select_mode = sel_addpoint;\n}\n"
  },
  {
    "path": "q3radiant/dlgcamera.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#if !defined(AFX_DLGCAMERA_H__59C12359_E3EB_4081_9F28_01793D75CF20__INCLUDED_)\n#define AFX_DLGCAMERA_H__59C12359_E3EB_4081_9F28_01793D75CF20__INCLUDED_\n\n#if _MSC_VER > 1000\n#pragma once\n#endif // _MSC_VER > 1000\n// DlgCamera.h : header file\n//\n\nextern void showCameraInspector();\n\n/////////////////////////////////////////////////////////////////////////////\n// CDlgCamera dialog\n\nclass CDlgCamera : public CDialog\n{\n// Construction\npublic:\n\tCDlgCamera(CWnd* pParent = NULL);   // standard constructor\n\tvoid setupFromCamera();\n\n// Dialog Data\n\t//{{AFX_DATA(CDlgCamera)\n\tenum { IDD = IDD_DLG_CAMERA };\n\tCScrollBar\tm_wndSegments;\n\tCListBox\tm_wndEvents;\n\tCComboBox\tm_wndSplines;\n\tCString\tm_strName;\n\tfloat\tm_fSeconds;\n\tBOOL\tm_trackCamera;\n\tint\t\tm_numSegments;\n\tint\t\tm_currentSegment;\n\tCString\tm_strType;\n\tint\t\tm_editPoints;\n\t//}}AFX_DATA\n\n\n// Overrides\n\t// ClassWizard generated virtual function overrides\n\t//{{AFX_VIRTUAL(CDlgCamera)\n\tprotected:\n\tvirtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\n\t//}}AFX_VIRTUAL\n\n// Implementation\nprotected:\n\t// Generated message map functions\n\t//{{AFX_MSG(CDlgCamera)\n\tafx_msg void OnBtnAddevent();\n\tafx_msg void OnBtnAddtarget();\n\tafx_msg void OnBtnDelevent();\n\tafx_msg void OnBtnDeltarget();\n\tafx_msg void OnDblclkComboSplines();\n\tafx_msg void OnSelchangeComboSplines();\n\tafx_msg void OnSelchangeListEvents();\n\tafx_msg void OnDblclkListEvents();\n\tvirtual BOOL OnInitDialog();\n\tvirtual void OnOK();\n\tafx_msg void OnDestroy();\n\tafx_msg void OnApply();\n\tafx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);\n\tafx_msg void OnFileNew();\n\tafx_msg void OnFileOpen();\n\tafx_msg void OnFileSave();\n\tafx_msg void OnTestcamera();\n\tafx_msg void OnBtnDeletepoints();\n\tafx_msg void OnBtnSelectall();\n\tafx_msg void OnRadioEditpoints();\n\tafx_msg void OnRadioAddPoints();\n\t//}}AFX_MSG\n\tDECLARE_MESSAGE_MAP()\n};\n\n//{{AFX_INSERT_LOCATION}}\n// Microsoft Visual C++ will insert additional declarations immediately before the previous line.\n\n#endif // !defined(AFX_DLGCAMERA_H__59C12359_E3EB_4081_9F28_01793D75CF20__INCLUDED_)\n"
  },
  {
    "path": "q3radiant/igl.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//-----------------------------------------------------------------------------\n//\n// $LogFile$\n// $Revision: 1.7.2.3 $\n// $Author: ttimo $\n// $Date: 2000/02/16 15:43:14 $\n// $Log: igl.h,v $\n// Revision 1.7.2.3  2000/02/16 15:43:14  ttimo\n// Curry bug #101996: added glTexParameterf and glNormal3f\n//\n// Revision 1.7.2.2  2000/02/13 17:48:07  ttimo\n// Curry bug #101874 - added glTexGenf to GL interface\n//\n// Revision 1.7.2.1  2000/02/04 22:59:34  ttimo\n// messaging API preview\n//\n// Revision 1.7  2000/01/18 00:43:59  ttimo\n// RC\n//\n// Revision 1.6  2000/01/13 00:46:41  ttimo\n// Merged in patches in / out\n// Revision 1.1.1.4  2000/01/18 00:17:12  ttimo\n// merging in for RC\n//\n// Revision 1.5  2000/01/11 22:14:48  ttimo\n// cleaning up after merging and thinks badly fucked up\n//\n// Revision 1.2  2000/01/09 04:39:14  ttimo\n// added some bindings to the GL table\n//\n// Revision 1.1.1.3  2000/01/11 16:43:15  ttimo\n// merged version from old reposit and Robert update\n//\n// Revision 1.1.1.1  2000/01/07 17:17:30  ttimo\n// initial import of Q3Radiant module\n//\n// Revision 1.1.1.1  2000/01/07 17:17:30  ttimo\n// initial import of Q3Radiant module\n//\n// Revision 1.3  2000/01/17 23:53:44  TBesset\n// ready for merge in sourceforge (RC candidate)\n//\n// Revision 1.2  2000/01/07 16:40:13  TBesset\n// merged from BSP frontend\n//\n// Revision 1.1.1.3  1999/12/29 18:31:27  TBesset\n// Q3Radiant public version\n//\n// Revision 1.1.1.1.2.1  1999/12/29 21:39:45  TBesset\n// updated to update3 from Robert\n//\n// Revision 1.1.1.3  1999/12/29 18:31:27  TBesset\n// Q3Radiant public version\n// Revision 1.1.1.3  1999/12/29 18:31:27  TBesset\n// Q3Radiant public version\n//\n// Revision 1.2  1999/11/22 17:46:48  Timo & Christine\n// merged EARadiant into the main tree\n// bug fixes for Q3Plugin / EAPlugin\n// export for Robert\n//\n// Revision 1.1.2.2  1999/11/03 20:38:04  Timo & Christine\n// MEAN plugin for Q3Radiant, alpha version\n//\n// Revision 1.1.2.1.2.1  1999/10/27 08:34:29  Timo & Christine\n// preview version of the texture tools plugin is ready\n// ( TexTool.dll plugin is in Q3Plugin module )\n// plugins can draw in their own window using Radiant's qgl bindings\n//\n// Revision 1.1.2.1  1999/10/08 16:28:14  Timo & Christine\n// started plugin extensions for EA features support in Q3Radiant\n// MEAN files plugin, and Surface Properties plugin\n//\n//\n// DESCRIPTION:\n// all purpose OpenGL interface for Q3Radiant plugins\n//\n\n#ifndef __IGL_H__\n#define __IGL_H__\n\n// we use this class to let plugins draw inside the Radiant windows\nclass IGLWindow\n{\npublic:\n\t// Increment the number of references to this object\n\tvirtual void IncRef () = 0;\n\t// Decrement the reference count\n\tvirtual void DecRef () = 0;\n\tvirtual void Draw( VIEWTYPE vt ) = 0;\n};\n\n// define a GUID for this interface so plugins can access and reference it\n// {0F237620-854B-11d3-8EF3-A2DFBD53251B}\nstatic const GUID QERQglTable_GUID = \n{ 0xf237620, 0x854b, 0x11d3, { 0x8e, 0xf3, 0xa2, 0xdf, 0xbd, 0x53, 0x25, 0x1b } };\n\n#include <gl/gl.h>\n#include <gl/glu.h>\n\ntypedef void (APIENTRY* PFN_QGLALPHAFUNC)\t\t(GLenum func, GLclampf ref);\ntypedef void (APIENTRY* PFN_QGLBEGIN)\t\t\t(GLenum);\ntypedef void (APIENTRY* PFN_QGLBINDTEXTURE)\t\t(GLenum target, GLuint texture);\ntypedef void (APIENTRY* PFN_QGLBLENDFUNC)       (GLenum sfactor, GLenum dfactor);\ntypedef void (APIENTRY* PFN_QGLCALLLIST)        (GLuint list);\ntypedef void (APIENTRY* PFN_QGLCALLLISTS)       (GLsizei n, GLenum type, const GLvoid *lists);\ntypedef void (APIENTRY* PFN_QGLCLEAR)\t\t\t(GLbitfield mask);\ntypedef void (APIENTRY* PFN_QGLCLEARCOLOR)\t\t(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);\ntypedef void (APIENTRY* PFN_QGLCLEARDEPTH)      (GLclampd depth);\ntypedef void (APIENTRY* PFN_QGLCOLOR3F)\t\t\t(GLfloat red, GLfloat green, GLfloat blue);\ntypedef void (APIENTRY* PFN_QGLCOLOR4F)\t\t\t(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\ntypedef void (APIENTRY* PFN_QGLCULLFACE)        (GLenum mode);\ntypedef void (APIENTRY* PFN_QGLDELETELISTS)     (GLuint list, GLsizei range);\ntypedef void (APIENTRY* PFN_QGLDISABLE)\t\t\t(GLenum cap);\ntypedef void (APIENTRY* PFN_QGLENABLE)\t\t\t(GLenum cap);\ntypedef void (APIENTRY* PFN_QGLEND)\t\t\t\t();\ntypedef void (APIENTRY* PFN_QGLENDLIST)         (void);\ntypedef GLuint (APIENTRY* PFN_QGLGENLISTS)      (GLsizei range);\ntypedef void (APIENTRY* PFN_QGLLISTBASE)        (GLuint base);\ntypedef void (APIENTRY* PFN_QGLLOADIDENTITY)\t();\ntypedef void (APIENTRY* PFN_QGLMATRIXMODE)\t\t(GLenum mode);\ntypedef void (APIENTRY* PFN_QGLNEWLIST)         (GLuint list, GLenum mode);\ntypedef void (APIENTRY* PFN_QGLNORMAL3F)\t\t(GLfloat nx, GLfloat ny, GLfloat nz);\ntypedef void (APIENTRY* PFN_QGLORTHO)\t\t\t(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\ntypedef void (APIENTRY*\tPFN_QGLPOINTSIZE)\t\t(GLfloat size);\ntypedef void (APIENTRY* PFN_QGLPOLYGONMODE)\t\t(GLenum face, GLenum mode);\ntypedef void (APIENTRY* PFN_QGLPOPMATRIX)\t\t();\ntypedef void (APIENTRY* PFN_QGLPUSHMATRIX)\t\t();\ntypedef void (APIENTRY* PFN_QGLROTATED)         (GLdouble angle, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (APIENTRY* PFN_QGLROTATEF)\t\t\t(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRY* PFN_QGLSCALEF)\t\t\t(GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRY* PFN_QGLTEXCOORD2F)\t\t(GLfloat s, GLfloat t);\ntypedef void (APIENTRY* PFN_QGLTEXENVF)\t\t\t(GLenum target, GLenum pname, GLfloat param);\ntypedef void (APIENTRY* PFN_QGLTEXGENF)\t\t\t(GLenum coord, GLenum pname, GLfloat param);\ntypedef void (APIENTRY* PFN_QGLTEXPARAMETERF)\t(GLenum target, GLenum pname, GLfloat param);\ntypedef void (APIENTRY* PFN_QGLTRANSLATED)      (GLdouble x, GLdouble y, GLdouble z);\ntypedef void (APIENTRY* PFN_QGLTRANSLATEF)\t\t(GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRY* PFN_QGLVERTEX2F)\t\t(GLfloat x, GLfloat y);\ntypedef void (APIENTRY* PFN_QGLVERTEX3F)\t\t(GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRY* PFN_QGLVIEWPORT)\t\t(GLint x, GLint y, GLsizei width, GLsizei height);\n\ntypedef void\t(WINAPI* PFN_QE_CHECKOPENGLFORERRORS)\t();\ntypedef int\t\t(WINAPI* PFN_QEW_SETUPPIXELFORMAT)\t\t(HDC hDC, qboolean zbuffer );\ntypedef HGLRC\t(WINAPI* PFN_QWGL_CREATECONTEXT)\t\t(HDC);\ntypedef BOOL\t(WINAPI* PFN_QWGL_DELETECONTEXT)        (HGLRC);\ntypedef BOOL\t(WINAPI* PFN_QWGL_MAKECURRENT)\t\t\t(HDC, HGLRC);\ntypedef BOOL\t(WINAPI* PFN_QWGL_SHARELISTS)\t\t\t(HGLRC, HGLRC);\ntypedef BOOL\t(WINAPI* PFN_QWGL_SWAPBUFFERS)\t\t\t(HDC);\ntypedef BOOL    (WINAPI* PFN_QWGL_USEFONTBITMAPS)       (HDC, DWORD, DWORD, DWORD);\n\n// glu stuff\ntypedef void (APIENTRY * PFN_QGLUPERSPECTIVE) (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);\ntypedef void (APIENTRY * PFN_QGLULOOKAT)(\n  GLdouble eyex,\n  GLdouble eyey,\n  GLdouble eyez,\n  GLdouble centerx,\n  GLdouble centery,\n  GLdouble centerz,\n  GLdouble upx,\n  GLdouble upy,\n  GLdouble upz);\n\n\n// specially provided by the editor for plugins\ntypedef HGLRC\t(WINAPI* PFN_QERAPP_GETQEGLOBALSHGLRC)\t();\n\n// plugins drawing inside the GL windows\n//++timo TODO: add hooking into other windows\n//+timo NOTE: this could be moved to the messaging system instead of having a dedicated interface\ntypedef void (WINAPI* PFN_QERAPP_HOOKXYGLWINDOW) (IGLWindow *);\ntypedef void (WINAPI* PFN_QERAPP_UNHOOKGLWINDOW) (IGLWindow *);\n\nstruct _QERQglTable\n{\n\t//++timo do we really wanna play with versions ?\n//\tfloat m_fVersion;\n\tint m_nSize;\n\tPFN_QGLALPHAFUNC\t\tm_pfn_qglAlphaFunc;\n\tPFN_QGLBEGIN\t\t\tm_pfn_qglBegin;\n\tPFN_QGLBINDTEXTURE\t\tm_pfn_qglBindTexture;\n\tPFN_QGLBLENDFUNC\t\tm_pfn_qglBlendFunc;\n\tPFN_QGLCALLLIST\t\t\tm_pfn_qglCallList;\n\tPFN_QGLCLEAR\t\t\tm_pfn_qglClear;\n\tPFN_QGLCLEARCOLOR\t\tm_pfn_qglClearColor;\n\tPFN_QGLCALLLISTS\t\tm_pfn_qglCallLists;\n\tPFN_QGLCLEARDEPTH\t\tm_pfn_qglClearDepth;\n\tPFN_QGLCOLOR3F\t\t\tm_pfn_qglColor3f;\n\tPFN_QGLCOLOR4F\t\t\tm_pfn_qglColor4f;\n\tPFN_QGLCULLFACE\t\t\tm_pfn_qglCullFace;\n\tPFN_QGLDELETELISTS\t\tm_pfn_qglDeleteLists;\n\tPFN_QGLDISABLE\t\t\tm_pfn_qglDisable;\n\tPFN_QGLENABLE\t\t\tm_pfn_qglEnable;\n\tPFN_QGLEND\t\t\t\tm_pfn_qglEnd;\n\tPFN_QGLENDLIST\t\t\tm_pfn_qglEndList;\n\tPFN_QGLGENLISTS\t\t\tm_pfn_qglGenLists;\n\tPFN_QGLLISTBASE\t\t\tm_pfn_qglListBase;\n\tPFN_QGLLOADIDENTITY\t\tm_pfn_qglLoadIdentity;\n\tPFN_QGLMATRIXMODE\t\tm_pfn_qglMatrixMode;\n\tPFN_QGLNEWLIST\t\t\tm_pfn_qglNewList;\n\tPFN_QGLNORMAL3F\t\t\tm_pfn_qglNormal3f;\n\tPFN_QGLORTHO\t\t\tm_pfn_qglOrtho;\n\tPFN_QGLPOINTSIZE\t\tm_pfn_qglPointSize;\n\tPFN_QGLPOLYGONMODE\t\tm_pfn_qglPolygonMode;\n\tPFN_QGLPOPMATRIX\t\tm_pfn_qglPopMatrix;\n\tPFN_QGLPUSHMATRIX\t\tm_pfn_qglPushMatrix;\n\tPFN_QGLROTATED\t\t\tm_pfn_qglRotated;\n\tPFN_QGLROTATEF\t\t\tm_pfn_qglRotatef;\n\tPFN_QGLSCALEF\t\t\tm_pfn_qglScalef;\n\tPFN_QGLTEXCOORD2F\t\tm_pfn_qglTexCoord2f;\n\tPFN_QGLTEXENVF\t\t\tm_pfn_qglTexEnvf;\n\tPFN_QGLTEXGENF\t\t\tm_pfn_qglTexGenf;\n\tPFN_QGLTEXPARAMETERF\tm_pfn_qglTexParameterf;\n\tPFN_QGLTRANSLATED\t\tm_pfn_qglTranslated;\n\tPFN_QGLTRANSLATEF\t\tm_pfn_qglTranslatef;\n\tPFN_QGLVERTEX2F\t\t\tm_pfn_qglVertex2f;\n\tPFN_QGLVERTEX3F\t\t\tm_pfn_qglVertex3f;\n\tPFN_QGLVIEWPORT\t\t\tm_pfn_qglViewport;\n\n\tPFN_QE_CHECKOPENGLFORERRORS\tm_pfn_QE_CheckOpenGLForErrors;\n\tPFN_QEW_SETUPPIXELFORMAT\tm_pfn_QEW_SetupPixelFormat;\n\tPFN_QWGL_CREATECONTEXT\t\tm_pfn_qwglCreateContext;\n\tPFN_QWGL_DELETECONTEXT      m_pfn_qwglDeleteContext;\n\tPFN_QWGL_MAKECURRENT\t\tm_pfn_qwglMakeCurrent;\n\tPFN_QWGL_SHARELISTS\t\t\tm_pfn_qwglShareLists;\n\tPFN_QWGL_SWAPBUFFERS\t\tm_pfn_qwglSwapBuffers;\n\tPFN_QWGL_USEFONTBITMAPS\t\tm_pfn_qwglUseFontBitmaps;\n\n\tPFN_QERAPP_GETQEGLOBALSHGLRC\tm_pfnGetQeglobalsHGLRC;\n\n\t// glu stuff\n\tPFN_QGLUPERSPECTIVE\t\t\tm_pfn_qgluPerspective;\n\tPFN_QGLULOOKAT\t\t\t\tm_pfn_qgluLookAt;\n\n\t// plugin entities drawing inside Radiant windows\n\tPFN_QERAPP_HOOKXYGLWINDOW\tm_pfnHookXYGLWindow;\n\tPFN_QERAPP_UNHOOKGLWINDOW\tm_pfnUnHookGLWindow;\n};\n\n#endif"
  },
  {
    "path": "q3radiant/iscriplib.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//-----------------------------------------------------------------------------\n//\n// $LogFile$\n// $Revision: 1.1.1.4 $\n// $Author: ttimo $\n// $Date: 2000/01/18 00:17:12 $\n// $Log: iscriplib.h,v $\n// Revision 1.1.1.4  2000/01/18 00:17:12  ttimo\n// merging in for RC\n//\n// Revision 1.3  2000/01/17 23:53:44  TBesset\n// ready for merge in sourceforge (RC candidate)\n//\n// Revision 1.2  2000/01/07 16:40:13  TBesset\n// merged from BSP frontend\n//\n// Revision 1.1.1.3  1999/12/29 18:31:27  TBesset\n// Q3Radiant public version\n//\n// Revision 1.1.1.1.2.1  1999/12/29 21:39:45  TBesset\n// updated to update3 from Robert\n//\n// Revision 1.1.1.3  1999/12/29 18:31:27  TBesset\n// Q3Radiant public version\n// Revision 1.1.1.3  1999/12/29 18:31:27  TBesset\n// Q3Radiant public version\n//\n// Revision 1.2  1999/11/22 17:46:48  Timo & Christine\n// merged EARadiant into the main tree\n// bug fixes for Q3Plugin / EAPlugin\n// export for Robert\n//\n// Revision 1.1.2.2  1999/11/14 16:26:14  Timo & Christine\n// first beta of the ritualmap surface plugin\n//\n// Revision 1.1.2.1  1999/10/08 16:28:15  Timo & Christine\n// started plugin extensions for EA features support in Q3Radiant\n// MEAN files plugin, and Surface Properties plugin\n//\n//\n// DESCRIPTION:\n// all purpose scriplib interface for Q3Radiant plugins (cf. parse.h)\n//\n\n#ifndef __ISCRIPLIB_H_\n#define __ISCRIPLIB_H_\n\n// {4B115280-95FC-11d3-8EF3-0000E8E8657B}\nstatic const GUID QERScripLibTable_GUID = \n{ 0x4b115280, 0x95fc, 0x11d3, { 0x8e, 0xf3, 0x0, 0x0, 0xe8, 0xe8, 0x65, 0x7b } };\n\ntypedef qboolean\t(WINAPI* PFN_GETTOKEN)\t\t(qboolean crossline);\ntypedef void\t\t(WINAPI* PFN_UNGETTOKEN)\t();\n// only used to retrieve &token\ntypedef char*\t\t(WINAPI* PFN_TOKEN) ();\n\nstruct _QERScripLibTable\n{\n\tfloat m_fVersion;\n\tint m_nSize;\n\tPFN_GETTOKEN\tm_pfnGetToken;\n\tPFN_UNGETTOKEN\tm_pfnUnGetToken;\n\tPFN_TOKEN\t\tm_pfnToken;\n};\n\n#endif"
  },
  {
    "path": "q3radiant/isurfaceplugin.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//-----------------------------------------------------------------------------\n//\n// $LogFile$\n// $Revision: 1.1.1.4.2.1 $\n// $Author: ttimo $\n// $Date: 2000/02/13 17:25:04 $\n// $Log: isurfaceplugin.h,v $\n// Revision 1.1.1.4.2.1  2000/02/13 17:25:04  ttimo\n// started cleanup\n//\n// Revision 1.1.1.4  2000/01/18 00:17:13  ttimo\n// merging in for RC\n//\n// Revision 1.3  2000/01/17 23:53:44  TBesset\n// ready for merge in sourceforge (RC candidate)\n//\n// Revision 1.2  2000/01/07 16:40:13  TBesset\n// merged from BSP frontend\n//\n// Revision 1.1.1.3  1999/12/29 18:31:28  TBesset\n// Q3Radiant public version\n//\n// Revision 1.1.1.1.2.1  1999/12/29 21:39:45  TBesset\n// updated to update3 from Robert\n//\n// Revision 1.1.1.3  1999/12/29 18:31:28  TBesset\n// Q3Radiant public version\n// Revision 1.1.1.3  1999/12/29 18:31:28  TBesset\n// Q3Radiant public version\n//\n// Revision 1.2  1999/11/22 17:46:48  Timo & Christine\n// merged EARadiant into the main tree\n// bug fixes for Q3Plugin / EAPlugin\n// export for Robert\n//\n// Revision 1.1.2.4  1999/11/20 12:13:02  Timo & Christine\n// first release to Wolfen and Spog\n// with TexTool and DeQbsp3 plugin\n//\n// Revision 1.1.2.3  1999/11/16 14:23:13  Timo & Christine\n// merged 173 into Q3Radiant, EARadiant branch\n// see Timo\\changelog.txt for merge log\n//\n// Revision 1.1.2.2  1999/11/14 16:26:15  Timo & Christine\n// first beta of the ritualmap surface plugin\n//\n// Revision 1.1.2.1  1999/10/08 16:28:15  Timo & Christine\n// started plugin extensions for EA features support in Q3Radiant\n// MEAN files plugin, and Surface Properties plugin\n//\n//\n// DESCRIPTION:\n// \n//\n\n#ifndef __ISURFACEPLUGIN_H_\n#define __ISURFACEPLUGIN_H_\n\n#ifndef Q3RADIANT\n\n// this is plugin included, define miptex_t\n//++timo FIXME: move definition into qertypes.h ? or assume plugin knows ?\n#define\tMIPLEVELS\t4\ntypedef struct miptex_s\n{\n\tchar\t\tname[32];\n\tunsigned\twidth, height;\n\tunsigned\toffsets[MIPLEVELS];\t\t// four mip maps stored\n\tchar\t\tanimname[32];\t\t\t// next frame in animation chain\n\tint\t\t\tflags;\n\tint\t\t\tcontents;\n\tint\t\t\tvalue;\n} miptex_t;\n\n#endif\n\n/*\n// there's a void* in each qtexture_t, must be casted to a IPluginQTexture*\nclass IPluginQTexture\n{\npublic:\n\t// Increment the number of references to this object\n\tvirtual void IncRef () = 0;\n\t// Decrement the reference count\n\tvirtual void DecRef () = 0;\n\t// Init for a miptex_t\n\tvirtual void InitForMiptex( miptex_t* ) = 0;\n\t// set default texdef\n\tvirtual void SetDefaultTexdef() = 0;\n};\n\n// use this macro\n#define GETPLUGINQTEXTURE(pQTexture) (static_cast<IPluginQTexture *>(pQTexture->pData))\n*/\n\n// there's a void* in each qtexture_t, must be casted to a IPluginTexdef*\n// there's a void* in each face_t, must be casted to a IPluginTexdef*\n// NOTE: IPluginTexdef stores a pointer to the qtexture_t or face_t it's stored in\n// members of IPluginTexdef often access the qtexture_t or face_t they are connected to\n\n// Write texdef needs a function pointer, because Radiant either writes into a FILE or a CMemFile\ntypedef void (WINAPI* PFN_QERAPP_MAPPRINTF) ( char *text, ... );\n\nclass IPluginTexdef\n{\npublic:\n\t// Increment the number of references to this object\n\tvirtual void IncRef () = 0;\n\t// Decrement the reference count\n\tvirtual void DecRef () = 0;\n\t// Build a copy of this one, sets refCount to 1\n\tvirtual IPluginTexdef* Copy() = 0;\n\t// refers to a face_t -----------------------\n\t// Parse texdef\n\tvirtual void ParseTexdef () = 0;\n\t// Write texdef\n\tvirtual void WriteTexdef (PFN_QERAPP_MAPPRINTF MapPrintf) = 0;\n\t// hook to a face\n\tvirtual void Hook( face_t* ) = 0;\n\t// ------------------------------------------\n\t// refers to a qtexture_t -------------------\n\t// Init for a miptex_t\n\t//++timo NOTE: miptex_t is used only for .WAL format .. a bit outdated\n\tvirtual void InitForMiptex( miptex_t* ) = 0;\n\t// set default texdef\n\tvirtual void SetDefaultTexdef() = 0;\n\t// ------------------------------------------\n\t// refers to a patchMesh_t ------------------\n\tvirtual void ParsePatchTexdef () = 0;\n\t// write texdef for a patch\n\tvirtual void WritePatchTexdef (PFN_QERAPP_MAPPRINTF MapPrintf) = 0;\n\t// hook to a patch\n\tvirtual void Hook( patchMesh_t* ) = 0;\n\t// ------------------------------------------\n};\n\n// use this macro\n#define GETPLUGINTEXDEF(pFace) (static_cast<IPluginTexdef *>(pFace->pData))\n\n// this one is used by Radiant to access the surface plugin\n\n// {7DA59920-93D8-11d3-8EF3-0000E8E8657B}\nstatic const GUID QERPlugSurfaceTable_GUID = \n{ 0x7da59920, 0x93d8, 0x11d3, { 0x8e, 0xf3, 0x0, 0x0, 0xe8, 0xe8, 0x65, 0x7b } };\n\ntypedef void (WINAPI* PFN_QERPLUG_DOSURFACE)\t\t\t();\ntypedef bool (WINAPI* PFN_QERPLUG_BYEBYESURFACEDIALOG)\t();\ntypedef void (WINAPI* PFN_QERPLUG_UPDATESURFACEDIALOG)\t();\n// allocates a new IPluginTexdef, linked to a face_t, refCount is set to 1\ntypedef IPluginTexdef* (WINAPI* PFN_QERPLUG_TEXDEFALLOC)\t( face_t* );\n// allocates a new IPluginTexdef, linked to a qtexture_t, refCount is set to 1\ntypedef IPluginTexdef* (WINAPI* PFN_QERPLUG_QTEXTUREALLOC)\t( qtexture_t* );\n// allocates a new IPluginTexdef, linked to a patchMesh_t, refCount is set to 1\ntypedef IPluginTexdef* (WINAPI* PFN_QERPLUG_PATCHALLOC)\t\t( patchMesh_t* );\n\nstruct _QERPlugSurfaceTable\n{\n\tint m_nSize;\n\tPFN_QERPLUG_BYEBYESURFACEDIALOG\t\tm_pfnByeByeSurfaceDialog;\n\tPFN_QERPLUG_DOSURFACE\t\t\t\tm_pfnDoSurface;\n\tPFN_QERPLUG_UPDATESURFACEDIALOG\t\tm_pfnUpdateSurfaceDialog;\n\tPFN_QERPLUG_TEXDEFALLOC\t\t\t\tm_pfnTexdefAlloc;\n\tPFN_QERPLUG_QTEXTUREALLOC\t\t\tm_pfnQTextureAlloc;\n\tPFN_QERPLUG_PATCHALLOC\t\t\t\tm_pfnPatchAlloc;\n};\n\n// this one is used by the plugin to access some Radiant stuff\n\n// {42BAE4C0-9787-11d3-8EF3-0000E8E8657B}\nstatic const GUID QERAppSurfaceTable_GUID = \n{ 0x42bae4c0, 0x9787, 0x11d3, { 0x8e, 0xf3, 0x0, 0x0, 0xe8, 0xe8, 0x65, 0x7b } };\n\ntypedef bool (WINAPI* PFN_PATCHESSELECTED)\t();\n// retrieve g_qeglobals.texturewin_t\n//++timo FIXME: this should move in a dedicated table for all g_qeglobals stuff\ntypedef texturewin_t* (WINAPI* PFN_QEGLOBALSTEXTUREWIN) ();\n// look for the first selected patch mesh\n//++timo FIXME: this is a convenient func since there's no way to scan patches ( yet )\ntypedef patchMesh_t* (WINAPI* PFN_GETSELECTEDPATCH) ();\ntypedef void (WINAPI* PFN_PATCHREBUILD) (patchMesh_t *p);\n//++timo FIXME: this one in particular is a hack\ntypedef void (WINAPI* PFN_GETTWOSELECTEDPATCH) (patchMesh_t **p1, patchMesh_t **p2);\n\nstruct _QERAppSurfaceTable\n{\n\tint m_nSize;\n\tPFN_PATCHESSELECTED\t\tm_pfnOnlyPatchesSelected;\n\tPFN_PATCHESSELECTED\t\tm_pfnAnyPatchesSelected;\n\tPFN_QEGLOBALSTEXTUREWIN\tm_pfnQeglobalsTexturewin;\n\tPFN_GETSELECTEDPATCH\tm_pfnGetSelectedPatch;\n\tPFN_PATCHREBUILD\t\tm_pfnPatchRebuild;\n\tPFN_GETTWOSELECTEDPATCH\tm_pfnGetTwoSelectedPatch;\n};\n\n#endif"
  },
  {
    "path": "q3radiant/qerplugin.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// QERadiant PlugIns\n//\n//\n\n#ifndef __QERPLUGIN_H__\n#define __QERPLUGIN_H__\n\n#include <windows.h>\n#include \"qertypes.h\"\n\n#define QER_PLUG_VERSION_1 1.00\n#define QER_PLUG_VERSION 1.70f\n\n#define QER_MAX_NAMELEN 1024\n\n// the editor will look for plugins in two places, the plugins path \n// under the application path, and the path under the basepath as defined\n// in the project (.qe4) file.\n//\n// you can drop any number of new texture, model format DLL's in the standard plugin path\n// but only one plugin that overrides map loading/saving, surface dialog, surface flags, etc.. \n// should be used at one time.. if multiples are loaded then the last one loaded will be the \n// active one\n//\n// type of services the plugin supplies, pass any combo of these flags\n// it is assumed the plugin will have a matching function as defined below\n// to correlate to the implied functionality\n// \n// FIXME: after specing this crap i went to a simpler model so this may disappear\n#define QER_PLUG_GAME_TEXTURE       0x0001      // defines new texture format\n#define QER_PLUG_GAME_MODEL         0x0002      // defines new model format\n#define QER_PLUG_GAME_MAP           0x0004      // handles map load/save\n#define QER_PLUG_GAME_SURFACEDLG    0x0008      // handles surface dialog\n#define QER_PLUG_GAME_SURFACEFLAGS  0x0010      // renames surface/content names\n\n// basics\n#define QERPLUG_INIT \"QERPlug_Init\"\n#define QERPLUG_GETNAME \"QERPlug_GetName\"\n#define QERPLUG_GETCOMMANDLIST \"QERPlug_GetCommandList\"\n#define QERPLUG_DISPATCH \"QERPlug_Dispatch\"\n#define QERPLUG_GETFUNCTABLE \"QERPlug_GetFuncTable\"\n\n// FIXME: not used, probably should remove\n#define QERPLUG_GETSERVICETPE \"QERPlug_GetServiceType\"\n\n// game stuff\n#define QERPLUG_GETTEXTUREINFO \"QERPlug_GetTextureInfo\"   // gets a texture info structure\n#define QERPLUG_LOADTEXTURE    \"QERPlug_LoadTexture\"      // loads a texture, will return an RGBA structure\n                                                          // and any surface flags/contents for it\n#define QERPLUG_GETTMODELINFO \"QERPlug_GetModelInfo\"      // gets a model info structure\n#define QERPLUG_LOADMODEL     \"QERPlug_LoadModel\"         // loads model data from a plugin\n#define QERPLUG_DOSURFACEDLG  \"QERPlug_DoSurfaceDlg\"      // runs the surface dialog in a plugin\n                                                          // this is going to get icky\n#define QERPLUG_GETSURFACEFLAGS \"QERPlug_GetSurfaceFlags\" // gets a list of surface/content flag names from a plugin\n\nstruct _QERTextureInfo\n{\n  char m_TextureExtension[QER_MAX_NAMELEN];   // the extension these textures have\n  qboolean m_bHiColor;    // if textures are NOT high color, the default \n                      // palette (as described inthe qe4 file will be used for gamma correction)\n                      // if they are high color, gamma and shading are computed on the fly \n                      // based on the rgba data\n  //--bool m_bIsShader;   // will probably do q3 shaders this way when i merge\n  qboolean m_bWadStyle;   // if this is true, the plugin will be presented with the texture path\n                      // defined in the .qe4 file and is expected to preload all the textures\n  qboolean m_bHalfLife;   // causes brushes to be saved/parsed without the surface contents/flags/value\n};\n\nstruct _QERTextureLoad    // returned by a plugin\n{\n  _QERTextureLoad()\n  { \n    memset(reinterpret_cast<void*>(this), 0, sizeof(_QERTextureLoad));\n  };\n\n  ~_QERTextureLoad()\n  {\n    delete []m_pRGBA;\n    delete []m_pName;\n  };\n\n  void makeSpace(int nSize)\n  {\n    m_pRGBA = new unsigned char[nSize+1];\n  };\n\n  void setName(const char* p)\n  {\n    m_pName = new char[strlen(p)+1];\n    strcpy(m_pName, p);\n  };\n\n\n  unsigned char *m_pRGBA; // rgba data (alpha channel is supported and drawn appropriately)\n  int m_nWidth;           // width\n  int m_nHeight;          // height\n  int m_nContents;        // default contents\n  int m_nFlags;           // \"\" flags\n  int m_nValue;           // \"\" value\n  char *m_pName;          // name to be referenced in map, build tools, etc.\n};\n\nstruct _QERModelInfo\n{\n  char m_ModelExtension[QER_MAX_NAMELEN];\n  bool m_bSkinned;\n  bool m_bMultipart;\n};\n\nstruct _QERModelLoad\n{\n  // vertex and skin data\n};\n\n\n// hook functions\n// FIXME: none of the hook stuff works for v1.00\n#define  QERPLUG_MAPLOAD \"QERPlug_MapLoad\"\n#define  QERPLUG_MAPSAVE \"QERPlug_MapSave\"\n\n//=========================================\n// plugin functions version 1.0\ntypedef LPCSTR (WINAPI* PFN_QERPLUG_INIT)(HMODULE hApp, HWND hwndMain);\ntypedef LPCSTR (WINAPI* PFN_QERPLUG_GETNAME)();\ntypedef LPCSTR (WINAPI* PFN_QERPLUG_GETCOMMANDLIST)();\ntypedef void (WINAPI* PFN_QERPLUG_DISPATCH)(LPCSTR p, vec3_t vMin, vec3_t vMax, BOOL bSingleBrush);\ntypedef LPVOID (WINAPI* PFN_QERPLUG_GETFUNCTABLE)();\ntypedef void (WINAPI* PFN_QERPLUG_MAPLOAD)();\ntypedef void (WINAPI* PFN_QERPLUG_MAPSAVE)();\n\n// editor defined plugin dispatches\n// these are used to signal the completion after a 'Get' function is called in the editor\n#define QERPLUG_DISPATCH_POINTDONE \"PointDone\"\n#define QERPLUG_DISPATCH_BRUSHDONE \"BrushDone\"\n\n// v1.5\n//\n// Texture loading\n// returns a ptr to _QERTextureInfo\ntypedef LPVOID (WINAPI* PFN_QERPLUG_GETTEXTUREINFO)();\n//\n// loads a texture by calling the texture load func in the editor (defined below)\n// transparency (for water, fog, lava, etc.. ) can be emulated in the editor\n// by passing in appropriate alpha data or by setting the appropriate surface flags\n// expected by q2 (which the editor will use.. )\ntypedef void (WINAPI* PFN_QERPLUG_LOADTEXTURE)(LPCSTR pFilename); \n\n// v1.6\ntypedef LPVOID (WINAPI* PFN_QERPLUG_GETSURFACEFLAGS)();\n\n// v1.7\n// if exists in plugin, gets called between INIT and GETCOMMANDLIST\n// the plugin can register the EClasses he wants to handle\n//++timo TODO: this has got to move into the table, and be requested by QERPlug_RequestInterface\n//++timo FIXME: the LPVOID parameter must be casted to an IEpair interface\n#define QERPLUG_REGISTERPLUGINENTITIES \"QERPlug_RegisterPluginEntities\"\ntypedef void (WINAPI* PFN_QERPLUG_REGISTERPLUGINENTITIES)( LPVOID );\n// if exists in plugin, gets called between INIT and GETCOMMANDLIST\n// the plugin can Init all it needs for surface properties\n#define QERPLUG_INITSURFACEPROPERTIES \"QERPlug_InitSurfaceProperties\"\ntypedef void (WINAPI* PFN_QERPLUG_INITSURFACEPROPERTIES)();\n// if Radiant needs to use a particular set of commands, it can request the plugin to fill a func table\n// this is similar to PFN_QERAPP_REQUESTINTERFACE\n#define QERPLUG_REQUESTINTERFACE \"QERPlug_RequestInterface\"\ntypedef int (WINAPI* PFN_QERPLUG_REQUESTINTERFACE)( REFGUID, LPVOID );\n\n//=========================================\n// editor functions\n\n// There are 3 potential brush handle lists\n// 1. the list that contains brushes a plugin creates using CreateBrushHandle\n// 2. the selected brush list (brushes the user has selected)\n// 3. the active brush list (brushes in the map that are not selected)\n// \n// In general, the same things can be done to brush handles (face manip, delete brushhandle, etc.. ) in each\n// list. There are a few exceptions. \n// 1. You cannot commit a selected or active brush handle to the map. This is because it is already in the map. \n// 2. You cannot bind brush handles from the selected or active brush list to an entity. As of v1.0 of the plugins\n// the only way for a plugin to create entities is to create a brush handles (or a list of handles) and then bind\n// them to an entity. This will commit the brush(s) and/or the entities to the map as well.\n// \n// To use the active or selected brush lists, you must first allocate them (which returns a count) and then\n// release them when you are finish manipulating brushes in one of those lists. \n\n//++timo NOTE : the #defines here are never used, but can help finding where things are done in the editor\n\n// brush manipulation routines\n#define QERAPP_CREATEBRUSH \"QERApp_CreateBrush\"\n#define QERAPP_CREATEBRUSHHANDLE \"QERApp_CreateBrushHandle\"\n#define QERAPP_DELETEBRUSHHANDLE \"QERApp_DeleteBrushHandle\"\n#define QERAPP_COMMITBRUSHHANDLETOMAP \"QERApp_CommitBrushHandleToMap\"\n//++timo not implemented .. remove\n// #define QERAPP_BINDHANDLESTOENTITY \"QERApp_BindHandlesToEntity\"\n#define QERAPP_ADDFACE \"QERApp_AddFace\"\n#define QERAPP_ADDFACEDATA \"QERApp_AddFaceData\"\n#define QERAPP_GETFACECOUNT \"QERApp_GetFaceCount\"\n#define QERAPP_GETFACEDATA \"QERApp_GetFaceData\"\n#define QERAPP_SETFACEDATA \"QERApp_SetFaceData\"\n#define QERAPP_DELETEFACE \"QERApp_DeleteFace\"\n#define QERAPP_TEXTUREBRUSH \"QERApp_TextureBrush\"\n#define QERAPP_BUILDBRUSH \"QERApp_BuildBrush\"\t\t\t\t\t// PGM\n#define QERAPP_SELECTEDBRUSHCOUNT \"QERApp_SelectedBrushCount\"\n#define QERAPP_ALLOCATESELECTEDBRUSHHANDLES \"QERApp_AllocateSelectedBrushHandles\"\n#define QERAPP_RELEASESELECTEDBRUSHHANDLES \"QERApp_ReleaseSelectedBrushHandles\"\n#define QERAPP_GETSELECTEDBRUSHHANDLE \"QERApp_GetSelectedBrushHandle\"\n#define QERAPP_ACTIVEBRUSHCOUNT \"QERApp_ActiveBrushCount\"\n#define QERAPP_ALLOCATEACTIVEBRUSHHANDLES \"QERApp_AllocateActiveBrushHandles\"\n#define QERAPP_RELEASEACTIVEBRUSHHANDLES \"QERApp_ReleaseActiveBrushHandles\"\n#define QERAPP_GETACTIVEBRUSHHANDLE \"QERApp_GetActiveBrushHandle\"\n\n// texture stuff\n#define QERAPP_TEXTURECOUNT \"QERApp_TextureCount\"\n#define QERAPP_GETTEXTURE \"QERApp_GetTexture\"\n#define QERAPP_GETCURRENTTEXTURE \"QERApp_GetCurrentTexture\"\n#define QERAPP_SETCURRENTTEXTURE \"QERApp_SetCurrentTexture\"\n\n// selection \n#define QERAPP_DELETESELECTION \"QERApp_DeleteSelection\"\n#define QERAPP_SELECTBRUSH \"QERApp_SelectBrush\"\t\t\t\t\t// PGM\n#define QERAPP_DESELECTBRUSH \"QERApp_DeselectBrush\"\t\t\t\t// PGM\n#define QERAPP_DESELECTALLBRUSHES \"QERApp_DeselectAllBrushes\"\t// PGM\n\n// data gathering\n#define QERAPP_GETPOINTS \"QERApp_GetPoints\"\n#define QERAPP_SELECTBRUSHES \"QERApp_GetBrushes\"\n\n// entity class stuff\n// the entity handling is very basic for 1.0\n#define QERAPP_GETECLASSCOUNT \"QERApp_GetEClassCount\"\n#define QERAPP_GETECLASS \"QERApp_GetEClass\"\n\n// misc\n#define QERAPP_SYSMSG \"QERApp_SysMsg\"\n#define QERAPP_INFOMSG \"QERApp_InfoMsg\"\n#define QERAPP_HIDEINFOMSG \"QERApp_HideInfoMsg\"\n#define QERAPP_POSITIONVIEW\t\"QERApp_PositionView\"\t\t\t// PGM\n#define QERAPP_RESET_PLUGINS \"QERApp_ResetPlugins\"\n\n// texture loading\n#define QERAPP_LOADTEXTURERGBA \"QERApp_LoadTextureRGBA\"\n\n// FIXME: the following are not implemented yet\n// hook registrations\n#define QERAPP_REGISTER_MAPLOADFUNC \"QERApp_Register_MapLoadFunc\"\n#define QERAPP_REGISTER_MAPSAVEFUNC \"QERApp_Register_MapSaveFunc\"\n\n// FIXME: the following are not implemented yet\n#define QERAPP_REGISTER_PROJECTLOADFUNC \"QERApp_Register_ProjectLoadFunc\"\n#define QERAPP_REGISTER_MOUSEHANDLER \"QERApp_Register_MouseHandler\"\n#define QERAPP_REGISTER_KEYHANDLER \"QERApp_Register_KeyHandler\"\n\n// FIXME: new primtives do not work in v1.00\n// primitives are new types of things in the map\n// for instance, the Q3 curves could have been done as \n// primitives instead of being built in \n// it will be a plugins responsibility to hook the map load and save funcs to load\n// and/or save any additional data (like new primitives of some type)\n// the editor will call each registered renderer during the rendering process to repaint\n// any primitives the plugin owns\n// each primitive object has a temporary sibling brush that lives in the map\n// FIXME: go backwards on this a bit.. orient it more towards the temp brush mode as it will be cleaner\n// basically a plugin will hook the map load and save and will add the primitives to the map.. this will\n// produce a temporary 'primitive' brush and the appropriate renderer will be called as well as the \n// edit handler (for edge drags, sizes, rotates, etc.. ) and the vertex maker will be called when vertex\n// mode is attemped on the brush.. there will need to be a GetPrimitiveBounds callback in the edit handler\n// so the brush can resize appropriately as needed.. this might be the plugins responsibility to set the \n// sibling brushes size.. it will then be the plugins responsibility to hook map save to save the primitives\n// as the editor will discard any temp primitive brushes.. (there probably needs to be some kind of sanity check\n// here as far as keeping the brushes and the plugin in sync.. i suppose the edit handler can deal with all of that\n// crap but it looks like a nice place for a mess)\n#define QERAPP_REGISTER_PRIMITIVE \"QERApp_Register_Primitive\"\n#define QERAPP_REGISTER_RENDERER \"QERApp_Register_Renderer\"\n#define QERAPP_REGISTER_EDITHANDLER \"QERApp_Register_EditHandler\"\n#define QERAPP_REGISTER_VERTEXMAKER \"QERApp_Register_VertexMaker\"\n#define QERAPP_ADDPRIMITIVE \"QERApp_AddPrimitive\"\n\n// v1.70\n#define QERAPP_GETENTITYCOUNT \"QERApp_GetEntityCount\"\n#define QERAPP_GETENTITYHANDLE \"QERApp_GetEntityHandle\"\n//++timo not implemented for the moment\n// #define QERAPP_GETENTITYINFO \"QERApp_GetEntityInfo\"\n//++timo does the keyval need some more funcs to add/remove ?\n// get the pointer and do the changes yourself\n#define QERAPP_GETENTITYKEYVALLIST \"QERApp_GetKeyValList\"\n#define QERAPP_ALLOCATEEPAIR \"QERApp_AllocateEpair\"\n// will check current KeyVal list is NULL, otherwise use GetKeyValList\n#define QERAPP_SETENTITYKEYVALLIST \"QERApp_SetKeyValList\"\n#define QERAPP_ALLOCATEENTITYBRUSHHANDLES \"QERApp_AllocateEntityBrushHandles\"\n#define QERAPP_RELEASEENTITYBRUSHHANDLES \"QERApp_ReleaseEntityBrushHandles\"\n#define QERAPP_GETENTITYBRUSHHANDLE \"QERApp_GetEntityBrushHandle\"\n#define QERAPP_CREATEENTITYHANDLE \"QERApp_CreateEntityHandle\"\n#define QERAPP_COMMITBRUSHHANDLETOENTITY \"QERApp_CommitBrushHandleToEntity\"\n#define QERAPP_COMMITENTITYHANDLETOMAP \"QERApp_CommitEntityHandleToMap\"\n#define QERAPP_SETSCREENUPDATE \"QERApp_SetScreenUpdate\"\n#define QERAPP_BUILDBRUSH2 \"QERApp_BuildBrush2\"\n\nstruct _QERPointData\n{\n  int     m_nCount;\n  vec3_t *m_pVectors;\n};\n\nstruct _QERFaceData\n{\n  char  m_TextureName[QER_MAX_NAMELEN];\n  int   m_nContents;\n  int   m_nFlags;\n  int   m_nValue;\n  float m_fShift[2];\n  float m_fRotate;\n  float m_fScale[2];\n  vec3_t m_v1, m_v2, m_v3;\n  // brush primitive additions\n  qboolean m_bBPrimit;\n  brushprimit_texdef_t brushprimit_texdef;\n};\n\ntypedef void (WINAPI* PFN_QERAPP_CREATEBRUSH)(vec3_t vMin, vec3_t vMax);\n\ntypedef LPVOID (WINAPI* PFN_QERAPP_CREATEBRUSHHANDLE)();\ntypedef void (WINAPI* PFN_QERAPP_DELETEBRUSHHANDLE)(LPVOID pv);\ntypedef void (WINAPI* PFN_QERAPP_COMMITBRUSHHANDLETOMAP)(LPVOID pv);\ntypedef void (WINAPI* PFN_QERAPP_ADDFACE)(LPVOID pv, vec3_t v1, vec3_t v2, vec3_t v3);\n\ntypedef void (WINAPI* PFN_QERAPP_ADDFACEDATA)(LPVOID pv, _QERFaceData *pData);\ntypedef int  (WINAPI* PFN_QERAPP_GETFACECOUNT)(LPVOID pv);\ntypedef _QERFaceData* (WINAPI* PFN_QERAPP_GETFACEDATA)(LPVOID pv, int nFaceIndex);\ntypedef void (WINAPI* PFN_QERAPP_SETFACEDATA)(LPVOID pv, int nFaceIndex, _QERFaceData *pData);\ntypedef void (WINAPI* PFN_QERAPP_DELETEFACE)(LPVOID pv, int nFaceIndex);\ntypedef void (WINAPI* PFN_QERAPP_TEXTUREBRUSH)(LPVOID pv, LPCSTR pName);\ntypedef void (WINAPI* PFN_QERAPP_BUILDBRUSH)(LPVOID pv);\t\t// PGM\ntypedef void (WINAPI* PFN_QERAPP_SELECTBRUSH)(LPVOID pv);\t\t// PGM\ntypedef void (WINAPI* PFN_QERAPP_DESELECTBRUSH)(LPVOID pv);\t\t// PGM\ntypedef void (WINAPI* PFN_QERAPP_DESELECTALLBRUSHES)();\t\t\t// PGM\n\ntypedef void (WINAPI* PFN_QERAPP_DELETESELECTION)();\ntypedef void (WINAPI* PFN_QERAPP_GETPOINTS)(int nMax, _QERPointData *pData, LPCSTR pMsg);\ntypedef void (WINAPI* PFN_QERAPP_SYSMSG)(LPCSTR pMsg);\ntypedef void (WINAPI* PFN_QERAPP_INFOMSG)(LPCSTR pMsg);\ntypedef void (WINAPI* PFN_QERAPP_HIDEINFOMSG)();\ntypedef void (WINAPI* PFN_QERAPP_POSITIONVIEW)(vec3_t v1, vec3_t v2);\t//PGM\n\ntypedef int  (WINAPI* PFN_QERAPP_SELECTEDBRUSHCOUNT)();\ntypedef int (WINAPI* PFN_QERAPP_ALLOCATESELECTEDBRUSHHANDLES)();\ntypedef void (WINAPI* PFN_QERAPP_RELEASESELECTEDBRUSHHANDLES)();\ntypedef LPVOID (WINAPI* PFN_QERAPP_GETSELECTEDBRUSHHANDLE)(int nIndex);\n\ntypedef int  (WINAPI* PFN_QERAPP_ACTIVEBRUSHCOUNT)();\ntypedef int (WINAPI* PFN_QERAPP_ALLOCATEACTIVEBRUSHHANDLES)();\ntypedef void (WINAPI* PFN_QERAPP_RELEASEACTIVEBRUSHHANDLES)();\ntypedef LPVOID (WINAPI* PFN_QERAPP_GETACTIVEBRUSHHANDLE)(int nIndex);\n\ntypedef int  (WINAPI* PFN_QERAPP_TEXTURECOUNT)();\ntypedef LPCSTR (WINAPI* PFN_QERAPP_GETTEXTURE)(int nIndex);\ntypedef LPCSTR (WINAPI* PFN_QERAPP_GETCURRENTTEXTURE)();\ntypedef void (WINAPI* PFN_QERAPP_SETCURRENTTEXTURE)(LPCSTR pName);\n\ntypedef void (WINAPI* PFN_QERAPP_REGISTERMAPLOAD)(LPVOID vp);\ntypedef void (WINAPI* PFN_QERAPP_REGISTERMAPSAVE)(LPVOID vp);\n\ntypedef int (WINAPI* PFN_QERAPP_GETECLASSCOUNT)();\ntypedef LPCSTR (WINAPI* PFN_QERAPP_GETECLASS)(int nIndex);\n\ntypedef void (WINAPI* PFN_QERAPP_RESETPLUGINS)();\n//--typedef int (WINAPI* PFN_QERAPP_GETENTITYCOUNT)();\n\n\n// called by texture loaders for each texture loaded\ntypedef void (WINAPI* PFN_QERAPP_LOADTEXTURERGBA)(LPVOID vp);\n\n//--typedef LPCSTR (WINAPI* PFN_QERAPP_GETENTITY)(int nIndex);\n\n// v1.70\ntypedef int (WINAPI* PFN_QERAPP_GETENTITYCOUNT)();\ntypedef LPVOID (WINAPI* PFN_QERAPP_GETENTITYHANDLE)(int nIndex);\ntypedef epair_t** (WINAPI* PFN_QERAPP_GETENTITYKEYVALLIST)(LPVOID vp);\ntypedef epair_t* (WINAPI* PFN_QERAPP_ALLOCATEEPAIR)( char*, char* );\ntypedef void (WINAPI* PFN_QERAPP_SETENTITYKEYVALLIST)(LPVOID vp, epair_t* ep);\ntypedef int (WINAPI* PFN_QERAPP_ALLOCATEENTITYBRUSHHANDLES)(LPVOID vp);\ntypedef void (WINAPI* PFN_QERAPP_RELEASEENTITYBRUSHHANDLES)();\ntypedef LPVOID (WINAPI* PFN_QERAPP_GETENTITYBRUSHHANDLE)(int nIndex);\ntypedef LPVOID (WINAPI* PFN_QERAPP_CREATEENTITYHANDLE)();\ntypedef void (WINAPI* PFN_QERAPP_COMMITBRUSHHANDLETOENTITY)( LPVOID vpBrush, LPVOID vpEntity);\ntypedef void (WINAPI* PFN_QERAPP_COMMITENTITYHANDLETOMAP)(LPVOID vp);\ntypedef void (WINAPI* PFN_QERAPP_SETSCREENUPDATE)(int bScreenUpdate);\n// this one uses window flags defined in qertypes.h\ntypedef void (WINAPI* PFN_QERAPP_SYSUPDATEWINDOWS)(int bits);\n//++timo remove this one\ntypedef void (WINAPI* PFN_QERAPP_BUILDBRUSH2)(LPVOID vp, int bConvert);\n// Radiant functions for Plugin Entities\n// will look for the value of the correponding key in the project epairs\ntypedef char* (WINAPI* PFN_QERAPP_READPROJECTKEY)(char* );\n// will scan the file, parse the first EClass found, and associate it to the caller plugin\n// will only read first EClass in the file, and return true/false\ntypedef int (WINAPI* PFN_QERAPP_SCANFILEFORECLASS)(char* );\n// plugins can request additional interfaces from the editor when they need specific services\ntypedef int (WINAPI* PFN_QERAPP_REQUESTINTERFACE)( REFGUID, LPVOID );\n// use this one for errors, Radiant will stop after the \"edit preferences\" dialog\ntypedef void (WINAPI* PFN_QERAPP_ERRORMSG)(LPCSTR pMsg);\n// use to gain read access to the project epairs\n// FIXME: removed, accessed through QERPlug_RegisterPluginEntities with the IEpair interface\n// typedef void (WINAPI* PFN_QERAPP_GETPROJECTEPAIR)(epair_t **);\n// used to allocate and read a buffer\n//++timo NOTE: perhaps this would need moving to some kind of dedicated interface\ntypedef int (WINAPI* PFN_QERAPP_LOADFILE)(const char *pLocation, void ** buffer);\ntypedef char* (WINAPI* PFN_QERAPP_EXPANDRELETIVEPATH)(char *);\ntypedef void (WINAPI* PFN_QERAPP_QECONVERTDOSTOUNIXNAME)( char *dst, const char *src );\ntypedef int (WINAPI* PFN_QERAPP_HASSHADER)(const char *);\ntypedef int (WINAPI* PFN_QERAPP_TEXTURELOADSKIN)(char *pName, int *pnWidth, int *pnHeight);\n// free memory previously allocated by Radiant\n// NOTE: this is dirty\ntypedef void (WINAPI* PFN_QERAPP_RADIANTFREE)( void * );\n// retrieves the path to the engine from the preferences dialog box\ntypedef char* (WINAPI* PFN_QERAPP_GETGAMEPATH)();\n// retrieves full Radiant path\ntypedef char* (WINAPI* PFN_QERAPP_GETQERPATH)();\n\n// patches in/out\n// NOTE: this is a bit different from the brushes in/out, no LPVOID handles this time\n// use int indexes instead\n// if you call AllocateActivePatchHandles, you'll be playing with active patches\n// AllocateSelectedPatcheHandles for selected stuff\n// a call to CreatePatchHandle will move you to a seperate index table\ntypedef int\t\t\t\t(WINAPI* PFN_QERAPP_ALLOCATEACTIVEPATCHHANDLES)\t\t();\ntypedef int\t\t\t\t(WINAPI* PFN_QERAPP_ALLOCATESELECTEDPATCHHANDLES)\t();\ntypedef void\t\t\t(WINAPI* PFN_QERAPP_RELEASEPATCHHANDLES)\t\t\t();\ntypedef patchMesh_t*\t(WINAPI* PFN_QERAPP_GETPATCHDATA)\t\t\t\t\t(int);\ntypedef void\t\t\t(WINAPI* PFN_QERAPP_DELETEPATCH)\t\t\t\t\t(int);\ntypedef int\t\t\t\t(WINAPI* PFN_QERAPP_CREATEPATCHHANDLE)\t\t\t\t();\n// when commiting, only a few patchMesh_t members are relevant:\n//  int\twidth, height;\t\t// in control points, not patches\n//  int   contents, flags, value, type;\n//  drawVert_t ctrl[MAX_PATCH_WIDTH][MAX_PATCH_HEIGHT];\n// once you have commited the index is still available, if the patch handle was allocated by you\n//   then you can re-use the index to commit other patches .. otherwise you can change existing patches\n// NOTE: the handle thing for plugin-allocated patches is a bit silly (nobody's perfect)\n// TODO: change current behaviour to an index = 0 to tell Radiant to allocate, other indexes to existing patches\n// patch is selected after a commit\n// you can add an optional texture / shader name .. if NULL will use the current texture\ntypedef void\t\t\t(WINAPI* PFN_QERAPP_COMMITPATCHHANDLETOMAP)\t\t\t(int, patchMesh_t* pMesh, char *texName);\n\n// FIXME:\n// add map format extensions\n// add texture format handlers\n// add surface dialog handler\n// add model handler/displayer\n\n// v1 func table\n// Plugins need to declare one of these and implement the getfunctable as described above\nstruct _QERFuncTable_1\n{\n  float m_fVersion;\n  int   m_nSize;\n  PFN_QERAPP_CREATEBRUSH            m_pfnCreateBrush;\n  PFN_QERAPP_CREATEBRUSHHANDLE      m_pfnCreateBrushHandle;\n  PFN_QERAPP_DELETEBRUSHHANDLE      m_pfnDeleteBrushHandle;\n  PFN_QERAPP_COMMITBRUSHHANDLETOMAP m_pfnCommitBrushHandle;\n  PFN_QERAPP_ADDFACE                m_pfnAddFace;\n  PFN_QERAPP_ADDFACEDATA            m_pfnAddFaceData;\n  PFN_QERAPP_GETFACEDATA            m_pfnGetFaceData;\n  PFN_QERAPP_GETFACECOUNT           m_pfnGetFaceCount;\n  PFN_QERAPP_SETFACEDATA            m_pfnSetFaceData;\n  PFN_QERAPP_DELETEFACE             m_pfnDeleteFace;\n  PFN_QERAPP_TEXTUREBRUSH           m_pfnTextureBrush;\n  PFN_QERAPP_BUILDBRUSH\t\t\t\tm_pfnBuildBrush;\t\t\t\t// PGM\n  PFN_QERAPP_SELECTBRUSH\t\t\tm_pfnSelectBrush;\t\t\t\t// PGM\n  PFN_QERAPP_DESELECTBRUSH\t\t\tm_pfnDeselectBrush;\t\t\t\t// PGM\n  PFN_QERAPP_DESELECTALLBRUSHES\t\tm_pfnDeselectAllBrushes;\t\t// PGM\n\n  PFN_QERAPP_DELETESELECTION        m_pfnDeleteSelection;\n  PFN_QERAPP_GETPOINTS              m_pfnGetPoints;\n  PFN_QERAPP_SYSMSG                 m_pfnSysMsg;\n  PFN_QERAPP_INFOMSG                m_pfnInfoMsg;\n  PFN_QERAPP_HIDEINFOMSG            m_pfnHideInfoMsg;\n  PFN_QERAPP_POSITIONVIEW\t\t\tm_pfnPositionView;\t\t\t\t// PGM\n\n  PFN_QERAPP_SELECTEDBRUSHCOUNT           m_pfnSelectedBrushCount;\n  PFN_QERAPP_ALLOCATESELECTEDBRUSHHANDLES m_pfnAllocateSelectedBrushHandles;\n  PFN_QERAPP_RELEASESELECTEDBRUSHHANDLES  m_pfnReleaseSelectedBrushHandles;\n  PFN_QERAPP_GETSELECTEDBRUSHHANDLE       m_pfnGetSelectedBrushHandle;\n\n  PFN_QERAPP_ACTIVEBRUSHCOUNT             m_pfnActiveBrushCount;\n  PFN_QERAPP_ALLOCATEACTIVEBRUSHHANDLES   m_pfnAllocateActiveBrushHandles;\n  PFN_QERAPP_RELEASEACTIVEBRUSHHANDLES    m_pfnReleaseActiveBrushHandles;\n  PFN_QERAPP_GETACTIVEBRUSHHANDLE         m_pfnGetActiveBrushHandle;\n\n  //++timo this would need to be removed and replaced by the IShaders interface\n  PFN_QERAPP_TEXTURECOUNT                 m_pfnTextureCount;\n  PFN_QERAPP_GETTEXTURE                   m_pfnGetTexture;\n  PFN_QERAPP_GETCURRENTTEXTURE            m_pfnGetCurrentTexture;\n  PFN_QERAPP_SETCURRENTTEXTURE            m_pfnSetCurrentTexture;\n\n  PFN_QERAPP_GETECLASSCOUNT         m_pfnGetEClassCount;\n  PFN_QERAPP_GETECLASS              m_pfnGetEClass;\n  PFN_QERAPP_RESETPLUGINS           m_pfnResetPlugins;\n  // v1.00 ends here\n  // v1.50 starts here\n  PFN_QERAPP_LOADTEXTURERGBA        m_pfnLoadTextureRGBA;\n  // v1.50 ends here\n  // v1.70 starts here\n  PFN_QERAPP_GETENTITYCOUNT\t\t\tm_pfnGetEntityCount;\n  PFN_QERAPP_GETENTITYHANDLE\t\tm_pfnGetEntityHandle;\n  PFN_QERAPP_GETENTITYKEYVALLIST\tm_pfnGetEntityKeyValList;\n  PFN_QERAPP_SETENTITYKEYVALLIST\tm_pfnSetEntityKeyValList;\n  PFN_QERAPP_ALLOCATEENTITYBRUSHHANDLES\tm_pfnAllocateEntityBrushHandles;\n  PFN_QERAPP_RELEASEENTITYBRUSHHANDLES\tm_pfnReleaseEntityBrushHandles;\n  PFN_QERAPP_GETENTITYBRUSHHANDLE\tm_pfnGetEntityBrushHandle;\n  PFN_QERAPP_CREATEENTITYHANDLE\t\tm_pfnCreateEntityHandle;\n  PFN_QERAPP_COMMITBRUSHHANDLETOENTITY\tm_pfnCommitBrushHandleToEntity;\n  PFN_QERAPP_COMMITENTITYHANDLETOMAP\tm_pfnCommitEntityHandleToMap;\n  PFN_QERAPP_ALLOCATEEPAIR\t\t\tm_pfnAllocateEpair;\n  PFN_QERAPP_SETSCREENUPDATE\t\tm_pfnSetScreenUpdate;\n  PFN_QERAPP_SYSUPDATEWINDOWS\t\tm_pfnSysUpdateWindows;\n  PFN_QERAPP_BUILDBRUSH2\t\t\tm_pfnBuildBrush2;\n  // Radiant functions for Plugin Entities\n  PFN_QERAPP_READPROJECTKEY\t\t\tm_pfnReadProjectKey;\n  PFN_QERAPP_SCANFILEFORECLASS\t\tm_pfnScanFileForEClass;\n  // plugins can request additional interfaces\n  PFN_QERAPP_REQUESTINTERFACE\t\tm_pfnRequestInterface;\n  PFN_QERAPP_ERRORMSG\t\t\t\tm_pfnErrorMsg;\n  // loading a file into a buffer\n  PFN_QERAPP_LOADFILE\t\t\t\tm_pfnLoadFile;\n  PFN_QERAPP_EXPANDRELETIVEPATH\t\tm_pfnExpandReletivePath;\n  PFN_QERAPP_QECONVERTDOSTOUNIXNAME\tm_pfnQE_ConvertDOSToUnixName;\n  PFN_QERAPP_HASSHADER\t\t\t\tm_pfnHasShader;\n  PFN_QERAPP_TEXTURELOADSKIN\t\tm_pfnTexture_LoadSkin;\n  PFN_QERAPP_RADIANTFREE\t\t\tm_pfnRadiantFree;\n  PFN_QERAPP_GETGAMEPATH\t\t\tm_pfnGetGamePath;\n  PFN_QERAPP_GETQERPATH\t\t\t\tm_pfnGetQERPath;\n  // patches in / out\n  PFN_QERAPP_ALLOCATEACTIVEPATCHHANDLES\t\tm_pfnAllocateActivePatchHandles;\n  PFN_QERAPP_ALLOCATESELECTEDPATCHHANDLES\tm_pfnAllocateSelectedPatchHandles;\n  PFN_QERAPP_RELEASEPATCHHANDLES\t\t\tm_pfnReleasePatchHandles;\n  PFN_QERAPP_GETPATCHDATA\t\t\t\t\tm_pfnGetPatchData;\n  PFN_QERAPP_DELETEPATCH\t\t\t\t\tm_pfnDeletePatch;\n  PFN_QERAPP_CREATEPATCHHANDLE\t\t\t\tm_pfnCreatePatchHandle;\n  PFN_QERAPP_COMMITPATCHHANDLETOMAP\t\t\tm_pfnCommitPatchHandleToMap;\n};\n\n\n//--typedef int (WINAPI*      PFN_QERAPP_BRUSHCOUNT     )();\n//--typedef brush_t* (WINAPI* PFN_QERAPP_GETBRUSH       )();\n//--typedef void (WINAPI*     PFN_QERAPP_DELETEBRUSH    )();\n\n#endif"
  },
  {
    "path": "q3radiant/res/Radiant.rc2",
    "content": "//\n// RADIANT.RC2 - resources Microsoft Visual C++ does not edit directly\n//\n\n#ifdef APSTUDIO_INVOKED\n\t#error this file is not editable by Microsoft Visual C++\n#endif //APSTUDIO_INVOKED\n\n\n/////////////////////////////////////////////////////////////////////////////\n// Add manually edited resources here...\n\n/////////////////////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "q3radiant/resource.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//{{NO_DEPENDENCIES}}\n// Microsoft Developer Studio generated include file.\n// Used by Radiant.rc\n//\n#define IDSELECT                        2\n#define IDOK2                           2\n#define ID_APPLY                        3\n#define IDD_ABOUTBOX                    100\n#define IDR_ACCELERATOR1                104\n#define IDD_CREATE_ENTITY               107\n#define IDD_EDIT_ENTITY                 108\n#define IDR_TOOLBAR1                    109\n#define IDD_FINDTEXTURE                 111\n#define IDD_ENTITY                      115\n#define IDR_E_MENU                      116\n#define IDD_EDITPROP                    117\n#define IDD_GAMMA                       118\n#define IDD_FINDBRUSH                   119\n#define IDI_ICON1                       120\n#define IDD_ROTATE                      121\n#define IDD_SIDES                       122\n#define IDD_ABOUT                       123\n#define IDB_BITMAP1                     127\n#define IDD_SURFACE                     129\n#define IDR_MAINFRAME                   130\n#define IDR_RADIANTYPE                  131\n#define IDAPPLY                         132\n#define IDS_STRING1                     132\n#define ID_BTN_APPLY                    133\n#define ID_TESTCAMERA                   133\n#define IDC_CHECK_LIVE                  134\n#define IDR_POPUP_TEXTURE               135\n#define IDR_POPUP_SELECTION             136\n#define IDR_POPUP_VIEW                  137\n#define IDD_DLG_PREFS                   139\n#define IDD_DLG_MAPINFO                 141\n#define IDD_DLG_ENTITYLIST              142\n#define IDD_DLG_SCRIPTS                 143\n#define IDD_DLG_NEWPROJECT              144\n#define IDD_DLG_COMMANDLIST             145\n#define IDR_MENU_DROP                   146\n#define IDB_VIEWDEFAULT                 147\n#define IDR_MENU_DAIKATANA              147\n#define IDB_VIEWQE4                     148\n#define IDB_VIEWDEFAULT2                148\n#define IDR_MENU11                      148\n#define IDR_MENU_QUAKE3                 148\n#define IDB_VIEW4WAY                    149\n#define IDB_VIEWDEFAULT3                149\n#define IDB_VIEWDEFAULT_Z               150\n#define IDB_3DFX                        154\n#define IDR_ACCEL_SURFACE               155\n#define IDD_DIALOG_SCALE                156\n#define IDR_MINIACCEL                   156\n#define IDD_DIALOG_FINDREPLACE          159\n#define IDD_DIALOG_STAIRS               160\n#define IDD_DIALOG_INPUT                161\n#define IDD_DLG_INFORMATION             162\n#define IDR_TOOLBAR_SCALELOCK           163\n#define IDR_TOOLBAR_ADVANCED            164\n#define IDD_PROJECT                     165\n#define IDD_TEXTUREBAR                  166\n#define IDD_ADDCMD                      167\n#define IDD_DIALOG_TEXTURELIST          168\n#define IDD_DIALOG_NEWPATCH             169\n#define IDR_MENU1                       170\n#define IDD_DIALOG_TEXTURELAYOUT        171\n#define IDR_POPUP_ENTITY                171\n#define IDD_DIALOG_CAP                  173\n#define IDB_IENDCAP                     175\n#define IDB_ENDCAP                      176\n#define IDD_DIALOG_THICKEN              176\n#define IDB_BEVEL                       177\n#define IDB_IBEVEL                      178\n#define IDR_SHADERFRAME                 179\n#define IDR_SHADERTYPE                  180\n#define IDR_POPUP_GROUP                 180\n#define IDR_POPUP_SPLINE                181\n#define IDD_DIALOG1                     182\n#define IDD_DIALOG_PATCH                182\n#define IDD_PLAYWAVE                    183\n#define IDD_TEXLIST                     184\n#define IDD_DIALOG2                     186\n#define IDD_DLG_GROUPS                  186\n#define IDD_DLG_GROUP                   188\n#define IDD_NEWNAME                     189\n#define IDB_BITMAP_GROUPS               190\n#define IDD_DLG_CAMERA                  194\n#define IDD_DLG_CAMERAEVENT             195\n#define IDD_DLG_CAMERATARGET            196\n#define IDC_BTN_HIDE                    1000\n#define IDC_SPIN1                       1001\n#define IDC_SPIN2                       1002\n#define IDC_RADIO_MOUSE                 1002\n#define IDC_SPIN3                       1003\n#define IDC_RADIO2                      1003\n#define IDC_RADIO_VIEWTYPE              1004\n#define IDC_RADIO3                      1004\n#define IDC_RADIO_FALLOFF2              1004\n#define IDC_RADIO_VIEWTYPE2             1005\n#define IDC_BTN_BROWSE                  1006\n#define IDC_EDIT_QUAKE2                 1007\n#define IDC_RADIO_VIEWTYPE3             1008\n#define IDC_LIST_ENTITIES               1009\n#define IDC_RADIO_VIEWTYPE4             1009\n#define IDC_EDIT_TOTALBRUSHES           1010\n#define IDC_EDIT_PAKFILE                1010\n#define IDC_RADIO_RUNQUAKE              1011\n#define IDC_BTN_BROWSEPAK               1011\n#define IDC_RADIO_RUNQUAKE2             1012\n#define IDC_EDIT_PREFABPATH             1012\n#define IDC_RADIO_RUNQUAKE3             1013\n#define IDC_BTN_BROWSEPREFAB            1013\n#define IDC_CHECK_LOADLAST              1014\n#define IDC_TREE_ENTITY                 1015\n#define IDC_CHECK_AUTOSAVE              1015\n#define IDC_CHECK_LOADLASTMAP           1016\n#define IDC_LIST_ENTITY                 1017\n#define IDC_EDIT_USERPATH               1017\n#define IDC_ENTITY_COMMENT              1018\n#define IDC_LIST_SCRIPTS                1018\n#define IDC_BTN_BROWSEUSERINI           1018\n#define ID_NEW                          1019\n#define IDC_CHECK_USESHADERS            1019\n#define ID_EDIT                         1020\n#define IDC_EDIT_NAME                   1020\n#define IDC_VALUE                       1021\n#define ID_RUN                          1021\n#define IDC_LIST_COMMANDS               1021\n#define IDC_KEY                         1022\n#define IDC_EDIT_COLOR                  1022\n#define IDC_ENTITY_LIST                 1023\n#define IDC_CHECK_FACE                  1023\n#define IDC_PAIRS                       1024\n#define IDC_CHECK_RIGHTCLICK            1024\n#define IDC_CHECK_VERTEX                1025\n#define IDC_CHECK1                      1026\n#define IDC_CHECK_TEXTUREWINDOW         1026\n#define IDC_CHECK2                      1027\n#define IDC_CHECK_TEXTURETOOLBAR        1027\n#define IDC_CHECK3                      1028\n#define IDC_CHECK_LIGHTDRAW             1028\n#define IDC_CHECK4                      1029\n#define IDC_CHECK_SNAPT                 1029\n#define IDC_CHECK5                      1030\n#define IDC_CHECK_3DFX                  1030\n#define IDC_CHECK_TEXTURESCROLLBAR      1030\n#define IDC_CHECK6                      1031\n#define IDC_CHECK_INTERNALBSP           1031\n#define IDC_CHECK7                      1032\n#define IDC_CHECK_RUNQUAKE              1032\n#define IDC_CHECK8                      1033\n#define IDC_CHECK_SETGAME               1033\n#define IDC_CHECK9                      1034\n#define IDC_CHECK_3DFX2                 1034\n#define IDC_CHECK_DISPLAYLISTS          1034\n#define IDC_CHECK10                     1035\n#define IDC_EDIT_AUTOSAVE               1035\n#define IDC_CHECK11                     1036\n#define IDC_CHECK_PAK                   1036\n#define IDC_CHECK12                     1037\n#define IDC_BUTTON1                     1037\n#define IDC_BTN_APPLYTEXTURESTUFF       1037\n#define IDC_CHECK_QE4PAINTING           1037\n#define IDC_BTN_PLAY                    1037\n#define IDC_BTN_ADD                     1037\n#define IDC_BTN_TEXTURE                 1037\n#define IDC_BTN_PREVIEW                 1037\n#define IDC_BTN_ADDTARGET               1037\n#define IDC_ANGLE90                     1038\n#define IDC_CHECK13                     1038\n#define IDC_SPIN_AUTOSAVE               1038\n#define IDC_BTN_DEL                     1038\n#define IDC_ANGLE45                     1039\n#define IDC_CHECK14                     1039\n#define IDC_BUTTON_CREDITS              1039\n#define IDC_CHECK_SIZEPAINT             1039\n#define IDC_BTN_ADD3                    1039\n#define IDC_BTN_EDIT                    1039\n#define IDC_ANGLE135                    1040\n#define IDC_CHECK15                     1040\n#define IDC_EDIT_X                      1040\n#define IDC_CHECK_TEXTURELOCALAXIS      1040\n#define IDC_SPIN_UNDO                   1040\n#define IDC_ANGLE225                    1041\n#define IDC_CHECK16                     1041\n#define IDC_CHECK_SNAPSHOTS             1041\n#define IDC_ANGLEUP                     1042\n#define IDC_CHECK17                     1042\n#define IDC_EDIT_FIND                   1042\n#define IDC_SPIN_POINTSIZE              1042\n#define IDC_ANGLE180                    1043\n#define IDC_CHECK18                     1043\n#define IDC_EDIT_REPLACE                1043\n#define IDC_EDIT_S                      1043\n#define IDC_ANGLE315                    1044\n#define IDC_CHECK19                     1044\n#define IDC_CHECK_SELECTED              1044\n#define IDC_EDIT_T                      1044\n#define IDC_ANGLE0                      1045\n#define IDC_CHECK20                     1045\n#define IDC_CHECK_FORCE                 1045\n#define IDC_ANGLE270                    1046\n#define IDC_CHECK21                     1046\n#define IDC_ANGLEDOWN                   1047\n#define IDC_CHECK22                     1047\n#define IDC_DELETEKEY                   1048\n#define IDC_ADDPAIR                     1048\n#define IDC_CHECK23                     1048\n#define IDC_DELETEPAIR                  1049\n#define IDC_CHECK24                     1049\n#define IDC_CHECK25                     1050\n#define IDC_SPAWN1                      1051\n#define IDC_CHECK26                     1051\n#define IDC_SPAWN2                      1052\n#define IDC_CHECK27                     1052\n#define IDC_SPAWN3                      1053\n#define IDC_CHECK28                     1053\n#define IDC_SPAWN4                      1054\n#define IDC_CHECK29                     1054\n#define IDC_SPAWN5                      1055\n#define IDC_CHECK30                     1055\n#define IDC_SPAWN6                      1056\n#define IDC_CHECK31                     1056\n#define IDC_SPAWN7                      1057\n#define IDC_CHECK32                     1057\n#define IDC_SPAWN8                      1058\n#define IDC_CHECK33                     1058\n#define IDC_EDIT1                       1059\n#define IDC_CHECK34                     1059\n#define IDC_ROTATE_BOX                  1060\n#define IDC_ROTZ                        1060\n#define IDC_CHECK35                     1060\n#define IDC_EDIT_TOTALENTITIES          1060\n#define IDC_EDIT_Y                      1060\n#define IDC_SCALE_BOX                   1061\n#define IDC_ROTY                        1061\n#define IDC_CHECK36                     1061\n#define IDC_EDIT_NET                    1061\n#define IDC_EDIT_Z                      1061\n#define IDC_E_VALUE_FIELD               1062\n#define IDC_CHECK37                     1062\n#define IDC_CHECK38                     1063\n#define IDC_E_LIST                      1064\n#define IDC_CHECK39                     1064\n#define IDC_E_COMMENT                   1065\n#define IDC_CHECK40                     1065\n#define IDC_CHECK41                     1066\n#define IDC_E_PROPS                     1067\n#define IDC_CHECK42                     1067\n#define IDC_E_135                       1068\n#define IDC_CHECK43                     1068\n#define IDC_E_180                       1069\n#define IDC_CHECK44                     1069\n#define IDC_E_225                       1070\n#define IDC_CHECK45                     1070\n#define IDC_E_270                       1071\n#define IDC_CHECK46                     1071\n#define IDC_E_90                        1072\n#define IDC_CHECK47                     1072\n#define IDC_E_45                        1073\n#define IDC_CHECK48                     1073\n#define IDC_E_0                         1074\n#define IDC_CHECK49                     1074\n#define IDC_E_315                       1075\n#define IDC_CHECK50                     1075\n#define IDC_E_UP                        1076\n#define IDC_CHECK51                     1076\n#define IDC_E_DOWN                      1077\n#define IDC_CHECK52                     1077\n#define IDC_CHECK53                     1078\n#define IDC_CHECK54                     1079\n#define IDC_E_ADDPROP                   1080\n#define IDC_CHECK55                     1080\n#define IDC_E_DELPROP                   1081\n#define IDC_CHECK56                     1081\n#define IDC_E_CREATE                    1082\n#define IDC_CHECK57                     1082\n#define IDC_E_STATUS                    1083\n#define IDC_CHECK58                     1083\n#define IDC_CHECK59                     1084\n#define IDC_CHECK60                     1085\n#define IDC_CHECK61                     1086\n#define IDC_CHECK62                     1087\n#define IDC_CHECK63                     1088\n#define IDC_CHECK64                     1089\n#define IDC_SHIFT_BOX                   1090\n#define IDC_HSHIFT                      1090\n#define IDC_VSHIFT                      1091\n#define IDC_ROTATEV                     1092\n#define ID_BTN_CANCEL                   1092\n#define IDC_HSTRETCH                    1092\n#define IDC_SCALEV                      1093\n#define IDC_EDIT_STATUSPOINTSIZE        1093\n#define IDC_VSTRETCH                    1093\n#define IDC_SCALEH                      1094\n#define IDC_EDIT_ROTATION               1094\n#define IDC_SHIFTV                      1095\n#define IDC_HSHIFTA                     1095\n#define IDC_STATIC_FIELD1               1095\n#define IDC_EDIT_UNDOLEVELS             1095\n#define IDC_SHIFTH                      1096\n#define IDC_VSHIFTA                     1097\n#define IDC_HSCALE                      1098\n#define IDC_HSCALEA                     1099\n#define IDC_VSCALE                      1100\n#define IDC_EDIT_FIELD1                 1100\n#define IDC_VSCALEA                     1101\n#define IDC_STATIC_FIELD2               1101\n#define IDC_ROTATE                      1102\n#define IDC_EDIT_FIELD2                 1102\n#define IDC_SLIDER_CAMSPEED             1102\n#define IDC_G_EDIT                      1103\n#define IDC_ROTATEA                     1103\n#define IDC_STATIC_FIELD3               1103\n#define IDC_CHECK_CAMXYUPDATE           1103\n#define IDC_STATIC_KEY                  1104\n#define IDC_FIND_BRUSH                  1104\n#define IDC_EDIT_FIELD3                 1104\n#define IDC_STATIC_VALUE                1105\n#define IDC_STATIC_FIELD4               1105\n#define IDC_E_KEY_FIELD                 1106\n#define IDC_EDIT_FIELD4                 1106\n#define IDC_FIND_ENTITY                 1107\n#define IDC_STATIC_FIELD5               1107\n#define IDC_SIDES                       1108\n#define IDC_EDIT_FIELD5                 1108\n#define IDC_COMBO_WHATGAME              1108\n#define IDC_ROTX                        1109\n#define IDC_BTN_COLOR                   1109\n#define IDC_STATIC_COLOR                1110\n#define IDC_E_COLOR                     1111\n#define IDC_ABOUT_GLVENDOR              1112\n#define IDC_ABOUT_GLVERSION             1113\n#define IDC_BTN_THECOLOR                1113\n#define IDC_ABOUT_GLRENDERER            1114\n#define IDC_STATIC_STUFF                1115\n#define IDC_TEXTURE                     1116\n#define IDC_CHECK_ALTDRAG               1116\n#define IDC_PRJRSHCMD                   1117\n#define IDC_SPIN_HSHIFT                 1117\n#define IDC_CHECK_MOUSECHASE            1117\n#define IDC_PRJREMOTEBASE               1118\n#define IDC_SPIN_VSHIFT                 1118\n#define IDC_CHECK_FACECOLOR             1118\n#define IDC_PRJENTITYPATH               1119\n#define IDC_SPIN_VSCALE                 1119\n#define IDC_CHECK_NOCLAMP               1119\n#define IDC_PRJTEXPATH                  1120\n#define IDC_SPIN_HSCALE                 1120\n#define IDC_PRJAUTOSAVE                 1121\n#define IDC_SPIN_ROTATE                 1121\n#define IDC_ADDCMD                      1122\n#define IDC_EDIT_ROTATEAMT              1122\n#define IDC_CMD_LIST                    1123\n#define IDC_CHECK_DLLENTITIES           1123\n#define IDC_PRJBASEPATH                 1124\n#define IDC_CHECK_WIDETOOLBAR           1124\n#define IDC_CMDCOMMAND                  1125\n#define IDC_CHECK_BUGGYICD              1125\n#define IDC_CMDMENUTEXT                 1126\n#define IDC_CHECK_SGIOPENGL             1126\n#define IDC_REMCMD                      1127\n#define IDC_PRJINTERVAL                 1128\n#define IDC_CHECK_HICOLOR               1128\n#define IDC_PRJMAPSPATH                 1129\n#define IDC_CHECK_SHADERTEST            1129\n#define IDC_EDITCMD                     1130\n#define IDC_CHECK_SHOWSHADERS           1130\n#define IDC_ABOUT_GLEXTENSIONS          1131\n#define IDC_LIST_TEXTURES               1132\n#define IDC_COMBO_WIDTH                 1136\n#define IDC_COMBO_HEIGHT                1137\n#define IDC_BTN_PATCHDETAILS            1137\n#define IDC_BTN_PATCHRESET              1138\n#define IDC_BTN_PATCHNATURAL            1139\n#define IDC_RADIO_CAP                   1139\n#define IDC_BTN_PATCHFIT                1140\n#define IDC_RADIO_CAP2                  1140\n#define IDC_CHECK_SEAMS                 1140\n#define IDC_RADIO_CAP3                  1141\n#define IDC_EDIT_AMOUNT                 1141\n#define IDC_RADIO_CAP4                  1142\n#define IDC_BTN_ASSIGNSOUND             1142\n#define IDC_BTN_AXIAL                   1142\n#define IDC_BTN_ASSIGNMODEL             1143\n#define IDC_BTN_FACEFIT                 1143\n#define IDC_SLIDER_TEXTUREQUALITY       1144\n#define IDC_LIST1                       1144\n#define IDC_BTN_BRUSHFIT                1144\n#define IDC_LIST_EVENTS                 1144\n#define IDC_TREE1                       1145\n#define IDC_COMBO_ROW                   1147\n#define IDC_COMBO_COL                   1148\n#define IDC_COMBO_TYPE                  1149\n#define IDC_EDIT_WIDTH                  1151\n#define IDC_CHECK_BPRIMIT               1151\n#define IDC_EDIT_HEIGHT                 1152\n#define IDC_SPIN_WIDTH                  1154\n#define IDC_SPIN_HEIGHT                 1155\n#define IDC_COMBO_SHADERS               1157\n#define IDC_TREE_GROUP                  1158\n#define IDC_CHECK_NOSTIPPLE             1159\n#define IDC_TAB_MODE                    1159\n#define IDC_SLIDER_FALLOFF              1161\n#define IDC_CHECK_POINT                 1162\n#define IDC_CHECK_EQUALRADIUS           1163\n#define IDC_RADIO_FALLOFF               1164\n#define IDC_CHECK_PROJECTED             1165\n#define IDC_CHECK_EXPLICITFALLOFF       1166\n#define IDC_EDIT_FALLOFF                1167\n#define IDC_STATIC_TEXTURE              1168\n#define IDC_CHECK_STROBE                1169\n#define IDC_EDIT_STROBE                 1170\n#define IDC_CHECK_ROTATE                1171\n#define IDC_EDIT_ROTATE                 1172\n#define IDC_BTN_FOG                     1174\n#define IDC_CHECK_FOG                   1175\n#define IDC_EDIT_ALPHA                  1176\n#define IDC_CHECK_SHADOWS               1178\n#define IDC_CHECK_DIFFUSE               1179\n#define IDC_CHECK_SPECULAR              1180\n#define IDC_EDIT_RADIUSY                1184\n#define IDC_EDIT_RADIUSZ                1185\n#define IDC_EDIT_RADIUSX                1186\n#define IDC_EDIT_TARGETX                1187\n#define IDC_EDIT_TARGETY                1188\n#define IDC_EDIT_TARGETZ                1189\n#define IDC_EDIT_RIGHTX                 1190\n#define IDC_EDIT_RIGHTY                 1191\n#define IDC_EDIT_RIGHTZ                 1192\n#define IDC_EDIT_UPX                    1193\n#define IDC_EDIT_UPY                    1194\n#define IDC_EDIT_UPZ                    1195\n#define IDC_EDIT_STARTX                 1196\n#define IDC_EDIT_STARTY                 1197\n#define IDC_EDIT_STARTZ                 1198\n#define IDC_EDIT_ENDX                   1199\n#define IDC_EDIT_ENDY                   1200\n#define IDC_EDIT_ENDZ                   1201\n#define IDC_COMBO_TEXTURE               1203\n#define IDC_EDIT_MAPS                   1205\n#define IDC_EDIT_CAM_NAME               1208\n#define IDC_COMBO_SPLINES               1209\n#define IDC_SCROLLBAR_SEGMENT           1210\n#define IDC_EDIT_LENGTH                 1212\n#define IDC_EDIT_SEGMENT                1213\n#define IDC_BTN_ADDEVENT                1214\n#define IDC_BTN_DELEVENT                1215\n#define IDC_CHECK_TRACKCAMERA           1216\n#define IDC_RADIO_EVENT                 1217\n#define IDC_EDIT_TOTALSEGMENTS          1217\n#define IDC_RADIO5                      1218\n#define IDC_RADIO6                      1219\n#define IDC_RADIO7                      1220\n#define IDC_RADIO8                      1221\n#define IDC_EDIT_PARAM                  1222\n#define IDC_RADIO9                      1223\n#define IDC_RADIO_FIXED                 1223\n#define IDC_RADIO10                     1224\n#define IDC_RADIO11                     1225\n#define IDC_RADIO_EDITPOINTS            1225\n#define IDC_RADIO12                     1226\n#define IDC_RADIO_EDITPOINTS2           1226\n#define IDC_BTN_DELETEPOINTS            1227\n#define IDC_EDIT_TYPE                   1228\n#define IDC_BTN_SELECTALL               1229\n#define ID_ENTITY_START                 22800\n#define ID_FILE_IMPORT                  32771\n#define ID_VIEW_XY                      32772\n#define ID_VIEW_SIDE                    32773\n#define ID_VIEW_FRONT                   32774\n#define ID_CAMERATOGGLE                 32775\n#define ID_VIEW_CAMERATOGGLE            32776\n#define ID_BUTTON32777                  32777\n#define ID_BUTTON32778                  32778\n#define ID_TEXTURES_POPUP               32780\n#define ID_POPUP_SELECTION              32782\n#define ID_VIEW_CHANGE                  32783\n#define ID_VIEW_CAMERAUPDATE            32784\n#define ID_VIEW_CLIPPER                 32785\n#define ID_PREFS                        32786\n#define ID_TOGGLE_LOCK                  32787\n#define ID_EDIT_MAPINFO                 32788\n#define ID_EDIT_ENTITYINFO              32789\n#define ID_BRUSH_SCRIPTS                32790\n#define ID_VIEW_NEXTVIEW                32791\n#define ID_HELP_COMMANDLIST             32792\n#define ID_FILE_NEWPROJECT              32793\n#define ID_MENUITEM32795                32795\n#define ID_SNAPTOGRID                   32795\n#define ID_SPLIT_SELECTED               32823\n#define ID_CLIP_SELECTED                32824\n#define ID_FLIP_CLIP                    32825\n#define ID_TOGGLEVIEW_YZ                32831\n#define ID_TOGGLEVIEW_XZ                32832\n#define ID_COLORS_GRIDTEXT              32833\n#define ID_COLORS_BRUSH                 32834\n#define ID_COLORS_SELECTEDBRUSH         32835\n#define ID_COLORS_CLIPPER               32836\n#define ID_COLORS_GRIDBLOCK             32837\n#define ID_COLORS_VIEWNAME              32838\n#define ID_COLOR_SETORIGINAL            32839\n#define ID_COLOR_SETQER                 32840\n#define ID_COLOR_SETBLACK               32841\n#define ID_BYEBYE                       32842\n#define ID_SELECT_SCALE                 32843\n#define ID_SELECT_MOUSEROTATE           32844\n#define ID_TEXTURE_REPLACESELECTED      32859\n#define ID_TEXTURE_REPLACEALL           32860\n#define ID_SELECT_MOUSESCALE            32866\n#define ID_SCALELOCKX                   32867\n#define ID_SCALELOCKY                   32868\n#define ID_SCALELOCKZ                   32869\n#define ID_VIEW_CUBICCLIPPING           32870\n#define ID_FILE_PROJECTSETTINGS         32875\n#define ID_VIEW_CUBEOUT                 32876\n#define ID_VIEW_CUBEIN                  32877\n#define ID_NODES_LOADNODES              32878\n#define ID_NODES_SHOWNODES              32879\n#define ID_NODES_SHOWLINKS              32880\n#define ID_NODES_REMOVEALLNODES         32881\n#define ID_NODES_COUNTNODES             32882\n#define ID_NODES_GIVEMONEYTONELNO       32883\n#define ID_FILE_SAVEREGION              32887\n#define ID_FILE_LOADREGION              32888\n#define ID_SELECTION_MOVEDOWN           32890\n#define ID_TOOLBAR_MAIN                 32891\n#define ID_SELECTION_MOVEUP             32892\n#define ID_TOOLBAR_TEXTURE              32892\n#define ID_BRUSH_MAKECONE               32896\n#define ID_TEXTURES_LOAD                32897\n#define ID_TOGGLE_ROTATELOCK            32898\n#define ID_CURVE_CYLINDER               32903\n#define ID_CURVE_ENDCAP                 32904\n#define ID_CURVE_BEVEL                  32905\n#define ID_CURVE_SPHERE                 32906\n#define ID_CURVE_HEMISPHERE             32907\n#define ID_CURVE_QUARTER                32908\n#define ID_CURVE_EIGHTHSPHERE           32909\n#define ID_CURVE_INVERTCURVE            32910\n#define ID_FILE_IMPORTMAP               32911\n#define ID_FILE_EXPORTMAP               32912\n#define ID_EDIT_LOADPREFAB              32913\n#define ID_VIEW_SHOWCURVES              32914\n#define ID_SELECTION_SELECT_NUDGELEFT   32916\n#define ID_SELECTION_SELECT_NUDGERIGHT  32917\n#define ID_SELECTION_SELECT_NUDGEUP     32918\n#define ID_SELECTION_SELECT_NUDGEDOWN   32919\n#define ID_TEXTURES_LOADLIST            32920\n#define ID_DONTSELECTCURVE              32923\n#define ID_CONVERTCURVES                32924\n#define ID_DYNAMIC_LIGHTING             32925\n#define ID_PATCH_SHOWBOUNDINGBOX        32926\n#define ID_CURVE_SIMPLEPATCHMESH        32927\n#define ID_PATCH_WIREFRAME              32928\n#define ID_PATCH_WELD                   32929\n#define ID_CURVE_PATCHTUBE              32930\n#define ID_CURVE_PATCHCONE              32931\n#define ID_CURVE_PATCHENDCAP            32932\n#define ID_CURVE_PATCHBEVEL             32933\n#define ID_CURVE_PATCHINVERTEDENDCAP    32934\n#define ID_CURVE_PATCHINVERTEDBEVEL     32935\n#define ID_PATCH_DRILLDOWN              32936\n#define ID_CURVE_LOADPATCHFILE          32937\n#define ID_CURVE_INSERTROW              32938\n#define ID_CURVE_INSERTCOLUMN           32939\n#define ID_CURVE_DELETEROW              32940\n#define ID_CURVE_DELETECOLUMN           32941\n#define ID_BUTTON32942                  32942\n#define ID_PATCH_INSDEL                 32942\n#define ID_CURVE_INSERT_ADDCOLUMN       32943\n#define ID_CURVE_INSERT_INSERTCOLUMN    32944\n#define ID_CURVE_INSERT_ADDROW          32945\n#define ID_CURVE_INSERT_INSERTROW       32946\n#define ID_CURVE_DELETE_FIRSTCOLUMN     32947\n#define ID_CURVE_DELETE_LASTCOLUMN      32948\n#define ID_CURVE_DELETE_FIRSTROW        32949\n#define ID_CURVE_DELETE_LASTROW         32950\n#define ID_CURVE_NEGATIVE               32951\n#define ID_PATCH_BEND                   32952\n#define ID_CURVE_PATCHDENSETUBE         32955\n#define ID_CURVE_PATCHVERYDENSETUBE     32956\n#define ID_CURVE_CAP                    32957\n#define ID_CURVE_CAP_INVERTEDBEVEL      32959\n#define ID_CURVE_CAP_INVERTEDENDCAP     32960\n#define ID_CURVE_REDISPERSE_ROWS        32961\n#define ID_CURVE_REDISPERSE_COLS        32962\n#define ID_PATCH_NATURALIZE             32963\n#define ID_CURVE_PATCHSQUARE            32964\n#define ID_BRUSH_PRIMITIVES_SPHERE      32965\n#define ID_BRUSH_PRIMITIVES_TORUS       32966\n#define ID_TEXTURES_TEXTUREWINDOWSCALE_200 32967\n#define ID_TEXTURES_TEXTUREWINDOWSCALE_100 32968\n#define ID_TEXTURES_TEXTUREWINDOWSCALE_50 32969\n#define ID_TEXTURES_TEXTUREWINDOWSCALE_25 32970\n#define ID_TEXTURES_TEXTUREWINDOWSCALE_10 32971\n#define ID_CURVE_NEGATIVETEXTUREX       32972\n#define ID_TEXTURES_FLUSH               32973\n#define ID_CURVE_OVERLAY_SET            32974\n#define ID_CURVE_OVERLAY_CLEAR          32975\n#define ID_CURVE_NEGATIVETEXTUREY       32976\n#define ID_CURVE_THICKEN                32977\n#define ID_CURVE_CYCLECAP               32978\n#define ID_CURVE_MATRIX_TRANSPOSE       32981\n#define ID_PLUGINS_REFRESH              32982\n#define ID_TEXTURES_RELOADSHADERS       32983\n#define ID_VIEW_ENTITIESAS_BOUNDINGBOX  32984\n#define ID_VIEW_ENTITIESAS_WRITEFRAME   32985\n#define ID_VIEW_ENTITIESAS_SELECTEDWIREFRAME 32986\n#define ID_VIEW_ENTITIESAS_SELECTEDSKINNED 32987\n#define ID_VIEW_ENTITIESAS_SKINNED      32988\n#define ID_VIEW_ENTITIESAS_SKINNEDANDBOXED 32989\n#define ID_SHOW_ENTITIES                32990\n#define ID_VIEW_ENTITIESAS_WIREFRAME    32991\n#define ID_VIEW_SHOWHINT                32993\n#define ID_VIEW_OPENGLLIGHTING          32998\n#define ID_VIEW_SHOWCAULK               32999\n#define ID_VIEW_SHOWANGLES              33000\n#define ID_EDIT_SAVEPREFAB              33001\n#define ID_CURVE_MOREENDCAPSBEVELS_SQUAREENDCAP 33002\n#define ID_CURVE_MOREENDCAPSBEVELS_SQUAREBEVEL 33003\n#define ID_CURVE_PRIMITIVES_SPHERE      33005\n#define ID_VIEW_HIDESHOW_HIDESELECTED   33006\n#define ID_VIEW_HIDESHOW_SHOWHIDDEN     33007\n#define ID_TEXTURES_SHADERS_SHOW        33008\n#define ID_SELECTION_CSGADD             33009\n#define ID_SELECTION_CSGMERGE           33011\n#define ID_TEXTURES_FLUSH_UNUSED        33014\n#define ID_DROP_GROUP_REMOVE            33016\n#define ID_DROP_GROUP_ADDTO_WORLD       33017\n#define ID_DROP_GROUP_NEWGROUP          33018\n#define ID_DROP_GROUP_NAME              33019\n#define ID_DROP_GROUP_ADDTO             33020\n#define ID_TERRAIN_CREATETERRAINFROMBRUSH 33022\n#define ID_TERRAIN_RAISELOWERTERRAIN    33023\n#define ID_SPLINES_MODE                 33027\n#define ID_SPLINES_LOAD                 33028\n#define ID_SPLINES_SAVE                 33029\n#define ID_SPLINES_EDIT                 33030\n#define ID_SPLINE_TEST                  33031\n#define ID_POPUP_NEWCAMERA_INTERPOLATED 33034\n#define ID_POPUP_NEWCAMERA_SPLINE       33035\n#define ID_POPUP_NEWCAMERA_FIXED        33036\n#define ID_ENTITY_END                   33500\n#define ID_PLUGIN_START                 33800\n#define ID_PLUGIN_END                   33999\n#define ID_FILE_EXIT                    40002\n#define ID_FILE_SAVEAS                  40004\n#define ID_VIEW_CENTER                  40005\n#define ID_VIEW_UPFLOOR                 40006\n#define ID_VIEW_DOWNFLOOR               40007\n#define ID_BRUSH_FLIPX                  40008\n#define ID_BRUSH_FLIPY                  40009\n#define ID_BRUSH_FLIPZ                  40010\n#define ID_BRUSH_ROTATEX                40011\n#define ID_BRUSH_ROTATEY                40012\n#define ID_BRUSH_ROTATEZ                40013\n#define ID_BSP_FULLVIS                  40016\n#define ID_BSP_FASTVIS                  40017\n#define ID_BSP_NOVIS                    40018\n#define ID_BSP_RELIGHT                  40019\n#define ID_BSP_ENTITIES                 40020\n#define ID_FILE_POINTFILE               40021\n#define ID_VIEW_100                     40022\n#define ID_VIEW_75                      40023\n#define ID_VIEW_50                      40024\n#define ID_VIEW_25                      40025\n#define ID_VIEW_12                      40026\n#define ID_TEXTURES_SHOWALL             40033\n#define ID_TEXTURES_SHOWINUSE           40034\n#define ID_TEXTURES_TOGGLEVIEW          40037\n#define ID_SELECTION_CREATEENTITY       40039\n#define ID_SELECTION_EDITENTITY         40040\n#define ID_MISC_BENCHMARK               40041\n#define ID_REGION_OFF                   40043\n#define ID_REGION_SETXY                 40044\n#define ID_REGION_SETBRUSH              40045\n#define ID_SELECTION_MAKEHOLLOW         40046\n#define ID_SELECTION_SELECTPARTIALTALL  40047\n#define ID_SELECTION_SELECTCOMPLETETALL 40048\n#define ID_SELECTION_CSGSUBTRACT        40049\n#define ID_SELECTION_SELECTTOUCHING     40050\n#define ID_VIEW_NEAREST                 40052\n#define ID_VIEW_NEARESTMIPMAP           40053\n#define ID_VIEW_LINEAR                  40054\n#define ID_VIEW_BILINEAR                40055\n#define ID_VIEW_BILINEARMIPMAP          40056\n#define ID_VIEW_TRILINEAR               40057\n#define ID_TEXTURES_WIREFRAME           40058\n#define ID_TEXTURES_FLATSHADE           40059\n#define ID_VIEW_SHOWNAMES               40060\n#define ID_VIEW_ZOOMIN                  40061\n#define ID_VIEW_ZOOMOUT                 40062\n#define ID_VIEW_SHOWCOORDINATES         40063\n#define ID_VIEW_Z100                    40064\n#define ID_VIEW_ZZOOMIN                 40065\n#define ID_VIEW_ZZOOMOUT                40066\n#define ID_SELECTION_CLONE              40067\n#define ID_SELECTION_DESELECT           40068\n#define ID_SELECTION_DELETE             40069\n#define ID_BUTTON40068                  40070\n#define ID_SELECTION_DRAGVERTECIES      40074\n#define ID_SELECTION_DRAGEDGES          40075\n#define ID_REGION_SETTALLBRUSH          40076\n#define ID_SELECTION_SELECTINSIDE       40092\n#define ID_PROJECT_RELEAD               40094\n#define ID_PROJECT_CHANGE               40095\n#define ID_MISC_GAMMA                   40097\n#define ID_VIEW_SHOWENT                 40098\n#define ID_VIEW_SHOWPATH                40099\n#define ID_VIEW_SHOWLIGHTS              40100\n#define ID_VIEW_SHOWCLIP                40101\n#define ID_VIEW_SHOWWATER               40102\n#define ID_VIEW_SHOWWORLD               40103\n#define ID_MISC_TEXTUREBACKGROUN        40104\n#define ID_TEXTUREBK                    40105\n#define ID_COLORS_XYBK                  40106\n#define ID_FILE_ABOUT                   40107\n#define ID_VIEW_CONSOLE                 40108\n#define ID_VIEW_ENTITY                  40109\n#define ID_VIEW_TEXTURE                 40110\n#define ID_COLORS_MAJOR                 40111\n#define ID_COLORS_MINOR                 40113\n#define ID_SELECTION_CONNECT            40114\n#define ID_FILE_LOADPROJECT             40115\n#define ID_MISC_FINDBRUSH               40116\n#define ID_MISC_NEXTLEAKSPOT            40117\n#define ID_MISC_PREVIOUSLEAKSPOT        40118\n#define ID_BRUSH_3SIDED                 40119\n#define ID_BRUSH_4SIDED                 40120\n#define ID_BRUSH_5SIDED                 40121\n#define ID_BRUSH_6SIDED                 40122\n#define ID_BRUSH_7SIDED                 40123\n#define ID_BRUSH_8SIDED                 40124\n#define ID_BRUSH_9SIDED                 40125\n#define ID_SELECTION_ARBITRARYROTATION  40126\n#define ID_BRUSH_ARBITRARYSIDED         40127\n#define ID_SELECTION_UNGROUPENTITY      40130\n#define ID_MISC_SELECTENTITYCOLOR       40131\n#define ID_MISC_PRINTXY                 40132\n#define ID_HELP_ABOUT                   40134\n#define ID_EDIT_COPYBRUSH               40135\n#define ID_EDIT_PASTEBRUSH              40136\n#define ID_TEXTURES_INSPECTOR           40137\n#define ID_VIEW_SHOWDETAIL              40138\n#define ID_SELECTION_MAKE_DETAIL        40139\n#define ID_SELECTION_MAKE_STRUCTURAL    40140\n#define ID_REGION_SETSELECTION          40142\n#define ID_VIEW_SHOWBLOCKS              40143\n#define ID_GRID_1                       40144\n#define ID_GRID_2                       40145\n#define ID_GRID_4                       40146\n#define ID_GRID_8                       40147\n#define ID_GRID_16                      40148\n#define ID_GRID_32                      40149\n#define ID_GRID_64                      40150\n#define ID_CAMERA_UP                    40151\n#define ID_CAMERA_DOWN                  40152\n#define ID_CAMERA_LEFT                  40153\n#define ID_CAMERA_RIGHT                 40155\n#define ID_CAMERA_FORWARD               40156\n#define ID_CAMERA_BACK                  40157\n#define ID_CAMERA_ANGLEUP               40158\n#define ID_CAMERA_ANGLEDOWN             40159\n#define ID_CAMERA_STRAFELEFT            40160\n#define ID_CAMERA_STRAFERIGHT           40161\n#define ID_GRID_TOGGLE                  40162\n#define ID_ENTITYLIST                   40163\n#define ID_MAPINFO                      40164\n#define ID_TOGGLECONSOLE                40165\n#define ID_TOGGLECAMERA                 40166\n#define ID_TOGGLEZ                      40167\n#define ID_TOGGLEVIEW                   40168\n#define ID_SELECTION_TEXTURE_DEC        40169\n#define ID_SELECTION_TEXTURE_INC        40170\n#define ID_SELECTION_TEXTURE_FIT        40171\n#define ID_SELECTION_TEXTURE_ROTATECLOCK 40172\n#define ID_SELECTION_TEXTURE_ROTATECOUNTER 40173\n#define ID_SELECTION_TEXTURE_SCALEUP    40174\n#define ID_SELECTION_TEXTURE_SCALEDOWN  40175\n#define ID_SELECTION_TEXTURE_SHIFTLEFT  40176\n#define ID_SELECTION_TEXTURE_SHIFTRIGHT 40177\n#define ID_SELECTION_TEXTURE_SHIFTUP    40178\n#define ID_SELECTION_TEXTURE_SHIFTDOWN  40179\n#define ID_GRID_NEXT                    40180\n#define ID_GRID_PREV                    40181\n#define ID_SELECTION_TEXTURE_SCALELEFT  40182\n#define ID_SELECTION_TEXTURE_SCALERIGHT 40183\n#define ID_SELECTION_PRINT              40184\n#define ID_SELECTION_TOGGLESIZEPAINT    40185\n#define ID_PATCH_TAB                    40186\n#define ID_PATCH_ENTER                  40187\n#define ID_SELECT_SNAPTOGRID            40188\n#define ID_PATCH_INSPECTOR              40189\n#define ID_SELECT_ALL                   40190\n#define ID_CURVE_FREEZE                 40191\n#define ID_CURVE_UNFREEZE               40192\n#define ID_CURVE_UNFREEZEALL            40193\n#define ID_SELECT_RESELECT              40194\n#define ID_FITBRUSH                     40195\n#define ID_FITFACE                      40196\n#define ID_VIEW_CROSSHAIR               40197\n#define ID_SELECTION_INVERT             40198\n#define ID_VIEW_GROUPS                  40199\n#define ID_SELECTION_NOOUTLINE          40200\n#define ID_SPLINES_POPUP                40201\n\n// Next default values for new objects\n// \n#ifdef APSTUDIO_INVOKED\n#ifndef APSTUDIO_READONLY_SYMBOLS\n#define _APS_3D_CONTROLS                     1\n#define _APS_NEXT_RESOURCE_VALUE        192\n#define _APS_NEXT_COMMAND_VALUE         33024\n#define _APS_NEXT_CONTROL_VALUE         1160\n#define _APS_NEXT_SYMED_VALUE           101\n#endif\n#endif\n"
  },
  {
    "path": "q3radiant/splines/Splines.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<VisualStudioProject\n\tProjectType=\"Visual C++\"\n\tVersion=\"7.10\"\n\tName=\"Splines\"\n\tSccProjectName=\"&quot;$/source/q3radiant/splines&quot;, XINAAAAA\"\n\tSccLocalPath=\".\">\n\t<Platforms>\n\t\t<Platform\n\t\t\tName=\"Win32\"/>\n\t</Platforms>\n\t<Configurations>\n\t\t<Configuration\n\t\t\tName=\"Release|Win32\"\n\t\t\tOutputDirectory=\".\\Release\"\n\t\t\tIntermediateDirectory=\".\\Release\"\n\t\t\tConfigurationType=\"4\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"2\"\n\t\t\t\tInlineFunctionExpansion=\"1\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_LIB;Q3RADIANT\"\n\t\t\t\tStringPooling=\"TRUE\"\n\t\t\t\tRuntimeLibrary=\"4\"\n\t\t\t\tEnableFunctionLevelLinking=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Release/Splines.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Release/\"\n\t\t\t\tObjectFile=\".\\Release/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Release/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLibrarianTool\"\n\t\t\t\tOutputFile=\".\\Release\\Splines.lib\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"NDEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t\t<Configuration\n\t\t\tName=\"Debug|Win32\"\n\t\t\tOutputDirectory=\".\\Debug\"\n\t\t\tIntermediateDirectory=\".\\Debug\"\n\t\t\tConfigurationType=\"4\"\n\t\t\tUseOfMFC=\"0\"\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n\t\t\tCharacterSet=\"2\">\n\t\t\t<Tool\n\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\tOptimization=\"0\"\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_LIB;Q3RADIANT\"\n\t\t\t\tBasicRuntimeChecks=\"3\"\n\t\t\t\tRuntimeLibrary=\"1\"\n\t\t\t\tRuntimeTypeInfo=\"TRUE\"\n\t\t\t\tUsePrecompiledHeader=\"2\"\n\t\t\t\tPrecompiledHeaderFile=\".\\Debug/Splines.pch\"\n\t\t\t\tAssemblerListingLocation=\".\\Debug/\"\n\t\t\t\tObjectFile=\".\\Debug/\"\n\t\t\t\tProgramDataBaseFileName=\".\\Debug/\"\n\t\t\t\tWarningLevel=\"3\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"\n\t\t\t\tDebugInformationFormat=\"4\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCLibrarianTool\"\n\t\t\t\tOutputFile=\".\\Debug\\Splines.lib\"\n\t\t\t\tSuppressStartupBanner=\"TRUE\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCResourceCompilerTool\"\n\t\t\t\tPreprocessorDefinitions=\"_DEBUG\"\n\t\t\t\tCulture=\"1033\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\n\t\t\t<Tool\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\n\t\t</Configuration>\n\t</Configurations>\n\t<References>\n\t</References>\n\t<Files>\n\t\t<Filter\n\t\t\tName=\"Source Files\"\n\t\t\tFilter=\"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"math_angles.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"math_matrix.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"math_quaternion.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"math_vector.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"q_parse.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"q_shared.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"splines.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"util_str.cpp\">\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Release|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"2\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t\t<FileConfiguration\n\t\t\t\t\tName=\"Debug|Win32\">\n\t\t\t\t\t<Tool\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n\t\t\t\t\t\tOptimization=\"0\"\n\t\t\t\t\t\tPreprocessorDefinitions=\"\"\n\t\t\t\t\t\tBasicRuntimeChecks=\"3\"/>\n\t\t\t\t</FileConfiguration>\n\t\t\t</File>\n\t\t</Filter>\n\t\t<Filter\n\t\t\tName=\"Header Files\"\n\t\t\tFilter=\"h;hpp;hxx;hm;inl\">\n\t\t\t<File\n\t\t\t\tRelativePath=\"math_angles.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"math_matrix.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"math_quaternion.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"math_vector.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"q_shared.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"splines.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"util_list.h\">\n\t\t\t</File>\n\t\t\t<File\n\t\t\t\tRelativePath=\"util_str.h\">\n\t\t\t</File>\n\t\t</Filter>\n\t</Files>\n\t<Globals>\n\t</Globals>\n</VisualStudioProject>\n"
  },
  {
    "path": "q3radiant/splines/math_angles.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"q_shared.h\"\n#include <float.h>\n\nangles_t ang_zero( 0.0f, 0.0f, 0.0f );\n\nvoid toAngles( mat3_t &src, angles_t &dst ) {\n\tdouble\t\ttheta;\n\tdouble\t\tcp;\n\tdouble\t\tsp;\n\n\tsp = src[ 0 ][ 2 ];\n\n\t// cap off our sin value so that we don't get any NANs\n\tif ( sp > 1.0 ) {\n\t\tsp = 1.0;\n\t} else if ( sp < -1.0 ) {\n\t\tsp = -1.0;\n\t}\n\n\ttheta = -asin( sp );\n\tcp = cos( theta );\n\n\tif ( cp > 8192 * FLT_EPSILON ) {\n\t\tdst.pitch\t= theta * 180 / M_PI;\n\t\tdst.yaw\t\t= atan2( src[ 0 ][ 1 ], src[ 0 ][ 0 ] ) * 180 / M_PI;\n\t\tdst.roll\t= atan2( src[ 1 ][ 2 ], src[ 2 ][ 2 ] ) * 180 / M_PI;\n\t} else {\n\t\tdst.pitch\t= theta * 180 / M_PI;\n\t\tdst.yaw\t\t= -atan2( src[ 1 ][ 0 ], src[ 1 ][ 1 ] ) * 180 / M_PI;\n\t\tdst.roll\t= 0;\n\t}\n}\n\nvoid toAngles( quat_t &src, angles_t &dst ) {\n\tmat3_t temp;\n\n\ttoMatrix( src, temp );\n\ttoAngles( temp, dst );\n}\n\nvoid toAngles( idVec3_t &src, angles_t &dst ) {\n\tdst.pitch\t= src[ 0 ];\n\tdst.yaw\t\t= src[ 1 ];\n\tdst.roll\t= src[ 2 ];\n}\n\nvoid angles_t::toVectors( idVec3_t *forward, idVec3_t *right, idVec3_t *up ) {\n\tfloat\t\t\tangle;\n\tstatic float\tsr, sp, sy, cr, cp, cy; // static to help MS compiler fp bugs\n\t\n\tangle = yaw * ( M_PI * 2 / 360 );\n\tsy = sin( angle );\n\tcy = cos( angle );\n\n\tangle = pitch * ( M_PI * 2 / 360 );\n\tsp = sin( angle );\n\tcp = cos( angle );\n\n\tangle = roll * ( M_PI * 2 / 360 );\n\tsr = sin( angle );\n\tcr = cos( angle );\n\n\tif ( forward ) {\n\t\tforward->set( cp * cy, cp * sy, -sp );\n\t}\n\n\tif ( right ) {\n\t\tright->set( -sr * sp * cy + cr * sy, -sr * sp * sy + -cr * cy, -sr * cp );\n\t}\n\n\tif ( up ) {\n\t\tup->set( cr * sp * cy + -sr * -sy, cr * sp * sy + -sr * cy, cr * cp );\n\t}\n}\n\nidVec3_t angles_t::toForward( void ) {\n\tfloat\t\t\tangle;\n\tstatic float\tsp, sy, cp, cy; // static to help MS compiler fp bugs\n\t\n\tangle = yaw * ( M_PI * 2 / 360 );\n\tsy = sin( angle );\n\tcy = cos( angle );\n\n\tangle = pitch * ( M_PI * 2 / 360 );\n\tsp = sin( angle );\n\tcp = cos( angle );\n\n\treturn idVec3_t( cp * cy, cp * sy, -sp );\n}\n\n/*\n=================\nNormalize360\n\nreturns angles normalized to the range [0 <= angle < 360]\n=================\n*/\nangles_t& angles_t::Normalize360( void ) {\n\tpitch\t= (360.0 / 65536) * ( ( int )( pitch\t* ( 65536 / 360.0 ) ) & 65535 );\n\tyaw\t\t= (360.0 / 65536) * ( ( int )( yaw\t\t* ( 65536 / 360.0 ) ) & 65535 );\n\troll\t= (360.0 / 65536) * ( ( int )( roll\t\t* ( 65536 / 360.0 ) ) & 65535 );\n\n\treturn *this;\n}\n\n\n/*\n=================\nNormalize180\n\nreturns angles normalized to the range [-180 < angle <= 180]\n=================\n*/\nangles_t& angles_t::Normalize180( void ) {\n\tNormalize360();\n\n\tif ( pitch > 180.0 ) {\n\t\tpitch -= 360.0;\n\t}\n\t\n\tif ( yaw > 180.0 ) {\n\t\tyaw  -= 360.0;\n\t}\n\n\tif ( roll > 180.0 ) {\n\t\troll -= 360.0;\n\t}\n\treturn *this;\n}\n"
  },
  {
    "path": "q3radiant/splines/math_angles.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __MATH_ANGLES_H__\n#define __MATH_ANGLES_H__\n\n#include <stdlib.h>\n#include <assert.h>\n\n#include \"math_vector.h\"\n\nclass mat3_t;\nclass quat_t;\nclass idVec3_t;\ntypedef idVec3_t &vec3_p;\n\nclass angles_t {\npublic:\n\tfloat\t\t\tpitch;\n\tfloat\t\t\tyaw;\n\tfloat\t\t\troll;\n\n\t\t\t\t\tangles_t();\n\t\t\t\t\tangles_t( float pitch, float yaw, float roll );\n\t\t\t\t\tangles_t( const idVec3_t &vec );\n\n\tfriend void\t\ttoAngles( idVec3_t &src, angles_t &dst );\n\tfriend void\t\ttoAngles( quat_t &src, angles_t &dst );\n\tfriend void\t\ttoAngles( mat3_t &src, angles_t &dst );\n\n\t\t\t\t\toperator vec3_p();\n\n\tfloat\t\t\toperator[]( int index ) const;\n\tfloat&\t\t\toperator[]( int index );\n\n\tvoid \t\t\tset( float pitch, float yaw, float roll );\n\n\tvoid\t\t\toperator=( angles_t const &a );\n\tvoid\t\t\toperator=( idVec3_t const &a );\n\n\tfriend angles_t\toperator+( const angles_t &a, const angles_t &b );\n\tangles_t\t\t&operator+=( angles_t const &a );\n\tangles_t\t\t&operator+=( idVec3_t const &a );\n\n\tfriend angles_t\toperator-( angles_t &a, angles_t &b );\n\tangles_t\t\t&operator-=( angles_t &a );\n\n\tfriend angles_t\toperator*( const angles_t &a, float b );\n\tfriend angles_t\toperator*( float a, const angles_t &b );\n\tangles_t\t\t&operator*=( float a );\n\n\tfriend int\t\toperator==(\tangles_t &a, angles_t &b );\n\t\t\t\t\t\n\tfriend int\t\toperator!=(\tangles_t &a, angles_t &b );\n\n\tvoid\t\t\ttoVectors( idVec3_t *forward, idVec3_t *right = NULL, idVec3_t *up = NULL );\n\tidVec3_t\t\t\ttoForward( void );\n\n\tangles_t\t\t&Zero( void );\n\n\tangles_t\t\t&Normalize360( void );\n\tangles_t\t\t&Normalize180( void );\n};\n\nextern angles_t ang_zero;\n\ninline angles_t::angles_t() {}\n\ninline angles_t::angles_t( float pitch, float yaw, float roll ) {\n\tthis->pitch = pitch;\n\tthis->yaw\t= yaw;\n\tthis->roll\t= roll;\n}\n\ninline angles_t::angles_t( const idVec3_t &vec ) {\n\tthis->pitch = vec.x;\n\tthis->yaw\t= vec.y;\n\tthis->roll\t= vec.z;\n}\n\ninline float angles_t::operator[]( int index ) const {\n\tassert( ( index >= 0 ) && ( index < 3 ) );\n\treturn ( &pitch )[ index ];\n}\n\ninline float& angles_t::operator[]( int index ) {\n\tassert( ( index >= 0 ) && ( index < 3 ) );\n\treturn ( &pitch )[ index ];\n}\n\ninline angles_t::operator vec3_p( void ) {\n\treturn *( idVec3_t * )&pitch;\n}\n\ninline void angles_t::set( float pitch, float yaw, float roll ) {\n\tthis->pitch = pitch;\n\tthis->yaw\t= yaw;\n\tthis->roll\t= roll;\n}\n\ninline void angles_t::operator=( angles_t const &a ) {\n\tpitch\t= a.pitch;\n\tyaw\t\t= a.yaw;\n\troll\t= a.roll;\n}\n\ninline void angles_t::operator=( idVec3_t const &a ) {\n\tpitch\t= a[ 0 ];\n\tyaw\t\t= a[ 1 ];\n\troll\t= a[ 2 ];\n}\n\ninline angles_t operator+( const angles_t &a, const angles_t &b ) {\n\treturn angles_t( a.pitch + b.pitch, a.yaw + b.yaw, a.roll + b.roll );\n}\n\ninline angles_t& angles_t::operator+=( angles_t const &a ) {\n\tpitch\t+= a.pitch;\n\tyaw\t\t+= a.yaw;\n\troll\t+= a.roll;\n\n\treturn *this;\n}\n\ninline angles_t& angles_t::operator+=( idVec3_t const &a ) {\n\tpitch\t+= a.x;\n\tyaw\t+= a.y;\n\troll\t+= a.z;\n\n\treturn *this;\n}\n\ninline angles_t operator-( angles_t &a, angles_t &b ) {\n\treturn angles_t( a.pitch - b.pitch, a.yaw - b.yaw, a.roll - b.roll );\n}\n\ninline angles_t& angles_t::operator-=( angles_t &a ) {\n\tpitch\t-= a.pitch;\n\tyaw\t\t-= a.yaw;\n\troll\t-= a.roll;\n\n\treturn *this;\n}\n\ninline angles_t operator*( const angles_t &a, float b ) {\n\treturn angles_t( a.pitch * b, a.yaw * b, a.roll * b );\n}\n\ninline angles_t operator*( float a, const angles_t &b ) {\n\treturn angles_t( a * b.pitch, a * b.yaw, a * b.roll );\n}\n\ninline angles_t& angles_t::operator*=( float a ) {\n\tpitch\t*= a;\n\tyaw\t\t*= a;\n\troll\t*= a;\n\n\treturn *this;\n}\n\ninline int operator==( angles_t &a, angles_t &b ) {\n\treturn ( ( a.pitch == b.pitch ) && ( a.yaw == b.yaw ) && ( a.roll == b.roll ) );\n}\n\ninline int operator!=( angles_t &a, angles_t &b ) {\n\treturn ( ( a.pitch != b.pitch ) || ( a.yaw != b.yaw ) || ( a.roll != b.roll ) );\n}\n\ninline angles_t& angles_t::Zero( void ) {\n\tpitch\t= 0.0f;\n\tyaw\t\t= 0.0f;\n\troll\t= 0.0f;\n\n\treturn *this;\n}\n\n#endif /* !__MATH_ANGLES_H__ */\n"
  },
  {
    "path": "q3radiant/splines/math_matrix.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"q_shared.h\"\n\nmat3_t mat3_default( idVec3_t( 1, 0, 0 ), idVec3_t( 0, 1, 0 ), idVec3_t( 0, 0, 1 ) );\n\nvoid toMatrix( quat_t const &src, mat3_t &dst ) {\n\tfloat\twx, wy, wz;\n\tfloat\txx, yy, yz;\n\tfloat\txy, xz, zz;\n\tfloat\tx2, y2, z2;\n\n\tx2 = src.x + src.x;\n\ty2 = src.y + src.y;\n\tz2 = src.z + src.z;\n\n\txx = src.x * x2;\n\txy = src.x * y2;\n\txz = src.x * z2;\n\n\tyy = src.y * y2;\n\tyz = src.y * z2;\n\tzz = src.z * z2;\n\n\twx = src.w * x2;\n\twy = src.w * y2;\n\twz = src.w * z2;\n\n\tdst[ 0 ][ 0 ] = 1.0f - ( yy + zz );\n\tdst[ 0 ][ 1 ] = xy - wz;\n\tdst[ 0 ][ 2 ] = xz + wy;\n\n\tdst[ 1 ][ 0 ] = xy + wz;\n\tdst[ 1 ][ 1 ] = 1.0f - ( xx + zz );\n\tdst[ 1 ][ 2 ] = yz - wx;\n\n\tdst[ 2 ][ 0 ] = xz - wy;\n\tdst[ 2 ][ 1 ] = yz + wx;\n\tdst[ 2 ][ 2 ] = 1.0f - ( xx + yy );\n}\n\nvoid toMatrix( angles_t const &src, mat3_t &dst ) {\n\tfloat\t\t\tangle;\n\tstatic float\tsr, sp, sy, cr, cp, cy; // static to help MS compiler fp bugs\n\t\t\n\tangle = src.yaw * ( M_PI * 2.0f / 360.0f );\n\tsy = sin( angle );\n\tcy = cos( angle );\n\n\tangle = src.pitch * ( M_PI * 2.0f / 360.0f );\n\tsp = sin( angle );\n\tcp = cos( angle );\n\n\tangle = src.roll * ( M_PI * 2.0f / 360.0f );\n\tsr = sin( angle );\n\tcr = cos( angle );\n\n\tdst[ 0 ].set( cp * cy, cp * sy, -sp );\n\tdst[ 1 ].set( sr * sp * cy + cr * -sy, sr * sp * sy + cr * cy, sr * cp );\n\tdst[ 2 ].set( cr * sp * cy + -sr * -sy, cr * sp * sy + -sr * cy, cr * cp );\n}\n\nvoid toMatrix( idVec3_t const &src, mat3_t &dst ) {\n        angles_t sup = src;\n        toMatrix(sup, dst);\n}\n\nvoid mat3_t::ProjectVector( const idVec3_t &src, idVec3_t &dst ) const {\n\tdst.x = src * mat[ 0 ];\n\tdst.y = src * mat[ 1 ];\n\tdst.z = src * mat[ 2 ];\n}\n\nvoid mat3_t::UnprojectVector( const idVec3_t &src, idVec3_t &dst ) const {\n\tdst = mat[ 0 ] * src.x + mat[ 1 ] * src.y + mat[ 2 ] * src.z;\n}\n\nvoid mat3_t::Transpose( mat3_t &matrix ) {\n\tint\ti;\n\tint\tj;\n   \n\tfor( i = 0; i < 3; i++ ) {\n\t\tfor( j = 0; j < 3; j++ ) {\n\t\t\tmatrix[ i ][ j ] = mat[ j ][ i ];\n        }\n\t}\n}\n\nvoid mat3_t::Transpose( void ) {\n\tfloat\ttemp;\n\tint\t\ti;\n\tint\t\tj;\n   \n\tfor( i = 0; i < 3; i++ ) {\n\t\tfor( j = i + 1; j < 3; j++ ) {\n\t\t\ttemp = mat[ i ][ j ];\n\t\t\tmat[ i ][ j ] = mat[ j ][ i ];\n\t\t\tmat[ j ][ i ] = temp;\n        }\n\t}\n}\n\nmat3_t mat3_t::Inverse( void ) const {\n\tmat3_t inv( *this );\n\n\tinv.Transpose();\n\n\treturn inv;\n}\n\nvoid mat3_t::Clear( void ) {\n\tmat[0].set( 1, 0, 0 );\n\tmat[1].set( 0, 1, 0 );\n\tmat[2].set( 0, 0, 1 );\n}\n"
  },
  {
    "path": "q3radiant/splines/math_matrix.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __MATH_MATRIX_H__\n#define __MATH_MATRIX_H__\n\n#include <string.h>\n#include \"math_vector.h\"\n\n#ifndef ID_INLINE\n#ifdef _WIN32\n#define ID_INLINE __inline \n#else\n#define ID_INLINE inline\n#endif\n#endif\n\nclass quat_t;\nclass angles_t;\n\nclass mat3_t {\npublic:\n\tidVec3_t\t\t\tmat[ 3 ];\n\n\t\t\t\t\tmat3_t();\n\t\t\t\t\tmat3_t( float src[ 3 ][ 3 ] );\n\t\t\t\t\tmat3_t( idVec3_t const &x, idVec3_t const &y, idVec3_t const &z );\n\t\t\t\t\tmat3_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 );\n\n\tfriend void\t\ttoMatrix( quat_t const &src, mat3_t &dst );\n\tfriend void\t\ttoMatrix( angles_t const &src, mat3_t &dst );\n\tfriend void\t\ttoMatrix( idVec3_t const &src, mat3_t &dst );\n\n\tidVec3_t\t\t\toperator[]( int index ) const;\n\tidVec3_t\t\t\t&operator[]( int index );\n\n\tidVec3_t\t\t\toperator*( const idVec3_t &vec ) const;\n\tmat3_t\t\t\toperator*( const mat3_t &a ) const;\n\tmat3_t\t\t\toperator*( float a ) const;\n\tmat3_t\t\t\toperator+( mat3_t const &a ) const;\n\tmat3_t\t\t\toperator-( mat3_t const &a ) const;\n\n\tfriend idVec3_t\toperator*( const idVec3_t &vec, const mat3_t &mat );\n\tfriend mat3_t\toperator*( float a, mat3_t const &b );\n\n\tmat3_t\t\t\t&operator*=( float a );\n\tmat3_t\t\t\t&operator+=( mat3_t const &a );\n\tmat3_t\t\t\t&operator-=( mat3_t const &a );\n\n\tvoid\t\t\tClear( void );\n\n\tvoid\t\t\tProjectVector( const idVec3_t &src, idVec3_t &dst ) const;\n\tvoid\t\t\tUnprojectVector( const idVec3_t &src, idVec3_t &dst ) const;\n\n\tvoid\t\t\tOrthoNormalize( void );\n\tvoid\t\t\tTranspose( mat3_t &matrix );\n\tvoid\t\t\tTranspose( void );\n\tmat3_t\t\t\tInverse( void ) const;\n\tvoid\t\t\tIdentity( void );\n\n\tfriend void\t\tInverseMultiply( const mat3_t &inv, const mat3_t &b, mat3_t &dst );\n\tfriend mat3_t\tSkewSymmetric( idVec3_t const &src );\n};\n\nID_INLINE mat3_t::mat3_t() {\n}\n\nID_INLINE mat3_t::mat3_t( float src[ 3 ][ 3 ] ) {\n\tmemcpy( mat, src, sizeof( src ) );\n}\n\nID_INLINE mat3_t::mat3_t( idVec3_t const &x, idVec3_t const &y, idVec3_t const &z ) {\n\tmat[ 0 ].x = x.x; mat[ 0 ].y = x.y; mat[ 0 ].z = x.z;\n\tmat[ 1 ].x = y.x; mat[ 1 ].y = y.y; mat[ 1 ].z = y.z;\n\tmat[ 2 ].x = z.x; mat[ 2 ].y = z.y; mat[ 2 ].z = z.z;\n}\n\nID_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 ) {\n\tmat[ 0 ].x = xx; mat[ 0 ].y = xy; mat[ 0 ].z = xz;\n\tmat[ 1 ].x = yx; mat[ 1 ].y = yy; mat[ 1 ].z = yz;\n\tmat[ 2 ].x = zx; mat[ 2 ].y = zy; mat[ 2 ].z = zz;\n}\n\nID_INLINE idVec3_t mat3_t::operator[]( int index ) const {\n\tassert( ( index >= 0 ) && ( index < 3 ) );\n\treturn mat[ index ];\n}\n\nID_INLINE idVec3_t& mat3_t::operator[]( int index ) {\n\tassert( ( index >= 0 ) && ( index < 3 ) );\n\treturn mat[ index ];\n}\n\nID_INLINE idVec3_t mat3_t::operator*( const idVec3_t &vec ) const {\n\treturn idVec3_t( \n\t\tmat[ 0 ].x * vec.x + mat[ 1 ].x * vec.y + mat[ 2 ].x * vec.z,\n\t\tmat[ 0 ].y * vec.x + mat[ 1 ].y * vec.y + mat[ 2 ].y * vec.z,\n\t\tmat[ 0 ].z * vec.x + mat[ 1 ].z * vec.y + mat[ 2 ].z * vec.z );\n}\n\nID_INLINE mat3_t mat3_t::operator*( const mat3_t &a ) const {\n\treturn mat3_t( \n\t\tmat[0].x * a[0].x + mat[0].y * a[1].x + mat[0].z * a[2].x,\n\t\tmat[0].x * a[0].y + mat[0].y * a[1].y + mat[0].z * a[2].y,\n\t\tmat[0].x * a[0].z + mat[0].y * a[1].z + mat[0].z * a[2].z,\n\t\tmat[1].x * a[0].x + mat[1].y * a[1].x + mat[1].z * a[2].x,\n\t\tmat[1].x * a[0].y + mat[1].y * a[1].y + mat[1].z * a[2].y,\n\t\tmat[1].x * a[0].z + mat[1].y * a[1].z + mat[1].z * a[2].z,\n\t\tmat[2].x * a[0].x + mat[2].y * a[1].x + mat[2].z * a[2].x,\n\t\tmat[2].x * a[0].y + mat[2].y * a[1].y + mat[2].z * a[2].y,\n\t\tmat[2].x * a[0].z + mat[2].y * a[1].z + mat[2].z * a[2].z );\n}\n\nID_INLINE mat3_t mat3_t::operator*( float a ) const {\n\treturn mat3_t( \n\t\tmat[0].x * a, mat[0].y * a, mat[0].z * a, \n\t\tmat[1].x * a, mat[1].y * a, mat[1].z * a, \n\t\tmat[2].x * a, mat[2].y * a, mat[2].z * a );\n}\n\nID_INLINE mat3_t mat3_t::operator+( mat3_t const &a ) const {\n\treturn mat3_t( \n\t\tmat[0].x + a[0].x, mat[0].y + a[0].y, mat[0].z + a[0].z, \n\t\tmat[1].x + a[1].x, mat[1].y + a[1].y, mat[1].z + a[1].z, \n\t\tmat[2].x + a[2].x, mat[2].y + a[2].y, mat[2].z + a[2].z );\n}\n    \nID_INLINE mat3_t mat3_t::operator-( mat3_t const &a ) const {\n\treturn mat3_t( \n\t\tmat[0].x - a[0].x, mat[0].y - a[0].y, mat[0].z - a[0].z, \n\t\tmat[1].x - a[1].x, mat[1].y - a[1].y, mat[1].z - a[1].z, \n\t\tmat[2].x - a[2].x, mat[2].y - a[2].y, mat[2].z - a[2].z );\n}\n\nID_INLINE idVec3_t operator*( const idVec3_t &vec, const mat3_t &mat ) {\n\treturn idVec3_t( \n\t\tmat[ 0 ].x * vec.x + mat[ 1 ].x * vec.y + mat[ 2 ].x * vec.z,\n\t\tmat[ 0 ].y * vec.x + mat[ 1 ].y * vec.y + mat[ 2 ].y * vec.z,\n\t\tmat[ 0 ].z * vec.x + mat[ 1 ].z * vec.y + mat[ 2 ].z * vec.z );\n}\n\nID_INLINE mat3_t operator*( float a, mat3_t const &b ) {\n\treturn mat3_t( \n\t\tb[0].x * a, b[0].y * a, b[0].z * a, \n\t\tb[1].x * a, b[1].y * a, b[1].z * a, \n\t\tb[2].x * a, b[2].y * a, b[2].z * a );\n}\n\nID_INLINE mat3_t &mat3_t::operator*=( float a ) {\n\tmat[0].x *= a; mat[0].y *= a; mat[0].z *= a;\n\tmat[1].x *= a; mat[1].y *= a; mat[1].z *= a; \n\tmat[2].x *= a; mat[2].y *= a; mat[2].z *= a;\n\n    return *this;\n}\n\nID_INLINE mat3_t &mat3_t::operator+=( mat3_t const &a ) {\n\tmat[0].x += a[0].x; mat[0].y += a[0].y; mat[0].z += a[0].z;\n\tmat[1].x += a[1].x; mat[1].y += a[1].y; mat[1].z += a[1].z;\n\tmat[2].x += a[2].x; mat[2].y += a[2].y; mat[2].z += a[2].z;\n\n    return *this;\n}\n\nID_INLINE mat3_t &mat3_t::operator-=( mat3_t const &a ) {\n\tmat[0].x -= a[0].x; mat[0].y -= a[0].y; mat[0].z -= a[0].z;\n\tmat[1].x -= a[1].x; mat[1].y -= a[1].y; mat[1].z -= a[1].z;\n\tmat[2].x -= a[2].x; mat[2].y -= a[2].y; mat[2].z -= a[2].z;\n\n    return *this;\n}\n\nID_INLINE void mat3_t::OrthoNormalize( void ) {\n\tmat[ 0 ].Normalize();\n\tmat[ 2 ].Cross( mat[ 0 ], mat[ 1 ] );\n\tmat[ 2 ].Normalize();\n\tmat[ 1 ].Cross( mat[ 2 ], mat[ 0 ] );\n\tmat[ 1 ].Normalize();\n}\n\nID_INLINE void mat3_t::Identity( void ) {\n\tmat[ 0 ].x = 1.f; mat[ 0 ].y = 0.f; mat[ 0 ].z = 0.f;\n\tmat[ 1 ].x = 0.f; mat[ 1 ].y = 1.f; mat[ 1 ].z = 0.f;\n\tmat[ 2 ].x = 0.f; mat[ 2 ].y = 0.f; mat[ 2 ].z = 1.f;\n}\n\nID_INLINE void InverseMultiply( const mat3_t &inv, const mat3_t &b, mat3_t &dst ) {\n\tdst[0].x = inv[0].x * b[0].x + inv[1].x * b[1].x + inv[2].x * b[2].x;\n\tdst[0].y = inv[0].x * b[0].y + inv[1].x * b[1].y + inv[2].x * b[2].y;\n\tdst[0].z = inv[0].x * b[0].z + inv[1].x * b[1].z + inv[2].x * b[2].z;\n\tdst[1].x = inv[0].y * b[0].x + inv[1].y * b[1].x + inv[2].y * b[2].x;\n\tdst[1].y = inv[0].y * b[0].y + inv[1].y * b[1].y + inv[2].y * b[2].y;\n\tdst[1].z = inv[0].y * b[0].z + inv[1].y * b[1].z + inv[2].y * b[2].z;\n\tdst[2].x = inv[0].z * b[0].x + inv[1].z * b[1].x + inv[2].z * b[2].x;\n\tdst[2].y = inv[0].z * b[0].y + inv[1].z * b[1].y + inv[2].z * b[2].y;\n\tdst[2].z = inv[0].z * b[0].z + inv[1].z * b[1].z + inv[2].z * b[2].z;\n}\n\nID_INLINE mat3_t SkewSymmetric( idVec3_t const &src ) {\n\treturn mat3_t( 0.0f, -src.z,  src.y, src.z,   0.0f, -src.x, -src.y,  src.x,   0.0f );\n}\n\nextern mat3_t mat3_default;\n\n#endif /* !__MATH_MATRIX_H__ */\n"
  },
  {
    "path": "q3radiant/splines/math_quaternion.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#include \"math_quaternion.h\"\n#include \"math_matrix.h\"\n\nvoid toQuat( idVec3_t &src, quat_t &dst ) {\n\tdst.x = src.x;\n\tdst.y = src.y;\n\tdst.z = src.z;\n\tdst.w = 0.0f;\n}\n\nvoid toQuat( angles_t &src, quat_t &dst ) {\n\tmat3_t temp;\n\n\ttoMatrix( src, temp );\n\ttoQuat( temp, dst );\n}\n\nvoid toQuat( mat3_t &src, quat_t &dst ) {\n\tfloat\t\ttrace;\n\tfloat\t\ts;\n\tint     \ti;\n\tint\t\t\tj;\n\tint\t\t\tk;\n\n\tstatic int \tnext[ 3 ] = { 1, 2, 0 };\n\n\ttrace = src[ 0 ][ 0 ] + src[ 1 ][ 1 ] + src[ 2 ][ 2 ];\n\tif ( trace > 0.0f ) {\n\t\ts = ( float )sqrt( trace + 1.0f );\n\t\tdst.w = s * 0.5f;\n\t\ts = 0.5f / s;\n    \n\t\tdst.x = ( src[ 2 ][ 1 ] - src[ 1 ][ 2 ] ) * s;\n\t\tdst.y = ( src[ 0 ][ 2 ] - src[ 2 ][ 0 ] ) * s;\n\t\tdst.z = ( src[ 1 ][ 0 ] - src[ 0 ][ 1 ] ) * s;\n\t} else {\n\t\ti = 0;\n\t\tif ( src[ 1 ][ 1 ] > src[ 0 ][ 0 ] ) {\n\t\t\ti = 1;\n\t\t}\n\t\tif ( src[ 2 ][ 2 ] > src[ i ][ i ] ) {\n\t\t\ti = 2;\n\t\t}\n\n\t\tj = next[ i ];  \n\t\tk = next[ j ];\n    \n\t\ts = ( float )sqrt( ( src[ i ][ i ] - ( src[ j ][ j ] + src[ k ][ k ] ) ) + 1.0f );\n\t\tdst[ i ] = s * 0.5f;\n    \n\t\ts = 0.5f / s;\n    \n\t\tdst.w\t\t= ( src[ k ][ j ] - src[ j ][ k ] ) * s;\n\t\tdst[ j ]\t= ( src[ j ][ i ] + src[ i ][ j ] ) * s;\n\t\tdst[ k ]\t= ( src[ k ][ i ] + src[ i ][ k ] ) * s;\n\t}\n}\n"
  },
  {
    "path": "q3radiant/splines/math_quaternion.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __MATH_QUATERNION_H__\n#define __MATH_QUATERNION_H__\n\n#include <assert.h>\n#include <math.h>\n\nclass idVec3_t;\nclass angles_t;\nclass mat3_t;\n\nclass quat_t {\npublic:\n\tfloat\t\t\tx;\n\tfloat\t\t\ty;\n\tfloat\t\t\tz;\n\tfloat\t\t\tw;\n\n\t\t\t\t\tquat_t();\n\t\t\t\t\tquat_t( float x, float y, float z, float w );\n\n\tfriend void\t\ttoQuat( idVec3_t &src, quat_t &dst );\n\tfriend void\t\ttoQuat( angles_t &src, quat_t &dst );\n\tfriend void\t\ttoQuat( mat3_t &src, quat_t &dst );\n\n\tfloat\t\t\t*vec4( void );\n\t\t\t\n\tfloat\t\t\toperator[]( int index ) const;\n\tfloat\t\t\t&operator[]( int index );\n\n\tvoid \t\t\tset( float x, float y, float z, float w );\n\n\tvoid\t\t\toperator=( quat_t a );\n\n\tfriend quat_t\toperator+( quat_t a, quat_t b );\n\tquat_t\t\t\t&operator+=( quat_t a );\n\n\tfriend quat_t\toperator-( quat_t a, quat_t b );\n\tquat_t\t\t\t&operator-=( quat_t a );\n\n\tfriend quat_t\toperator*( quat_t a, float b );\n\tfriend quat_t\toperator*( float a, quat_t b );\n\tquat_t\t\t\t&operator*=( float a );\n\n\tfriend int\t\toperator==(\tquat_t a, quat_t b );\n\tfriend int\t\toperator!=(\tquat_t a, quat_t b );\n\n\tfloat\t\t\tLength( void );\n\tquat_t\t\t\t&Normalize( void );\n\n\tquat_t\t\t\toperator-();\n};\n\ninline quat_t::quat_t() {\n}\n\ninline quat_t::quat_t( float x, float y, float z, float w ) {\n\tthis->x = x;\n\tthis->y = y;\n\tthis->z = z;\n\tthis->w = w;\n}\n\ninline float *quat_t::vec4( void ) {\n\treturn &x;\n}\n\ninline float quat_t::operator[]( int index ) const {\n\tassert( ( index >= 0 ) && ( index < 4 ) );\n\treturn ( &x )[ index ];\n}\n\ninline float& quat_t::operator[]( int index ) {\n\tassert( ( index >= 0 ) && ( index < 4 ) );\n\treturn ( &x )[ index ];\n}\n\ninline void quat_t::set( float x, float y, float z, float w ) {\n\tthis->x = x;\n\tthis->y = y;\n\tthis->z = z;\n\tthis->w = w;\n}\n\ninline void quat_t::operator=( quat_t a ) {\n\tx = a.x;\n\ty = a.y;\n\tz = a.z;\n\tw = a.w;\n}\n\ninline quat_t operator+( quat_t a, quat_t b ) {\n\treturn quat_t( a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w );\n}\n\ninline quat_t& quat_t::operator+=( quat_t a ) {\n\tx += a.x;\n\ty += a.y;\n\tz += a.z;\n\tw += a.w;\n\n\treturn *this;\n}\n\ninline quat_t operator-( quat_t a, quat_t b ) {\n\treturn quat_t( a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w );\n}\n\ninline quat_t& quat_t::operator-=( quat_t a ) {\n\tx -= a.x;\n\ty -= a.y;\n\tz -= a.z;\n\tw -= a.w;\n\n\treturn *this;\n}\n\ninline quat_t operator*( quat_t a, float b ) {\n\treturn quat_t( a.x * b, a.y * b, a.z * b, a.w * b );\n}\n\ninline quat_t operator*( float a, quat_t b ) {\n\treturn b * a;\n}\n\ninline quat_t& quat_t::operator*=( float a ) {\n\tx *= a;\n\ty *= a;\n\tz *= a;\n\tw *= a;\n\n\treturn *this;\n}\n\ninline int operator==( quat_t a, quat_t b ) {\n\treturn ( ( a.x == b.x ) && ( a.y == b.y ) && ( a.z == b.z ) && ( a.w == b.w ) );\n}\n\ninline int operator!=( quat_t a, quat_t b ) {\n\treturn ( ( a.x != b.x ) || ( a.y != b.y ) || ( a.z != b.z ) && ( a.w != b.w ) );\n}\n\ninline float quat_t::Length( void ) {\n\tfloat length;\n\t\n\tlength = x * x + y * y + z * z + w * w;\n\treturn ( float )sqrt( length );\n}\n\ninline quat_t& quat_t::Normalize( void ) {\n\tfloat length;\n\tfloat ilength;\n\n\tlength = this->Length();\n\tif ( length ) {\n\t\tilength = 1 / length;\n\t\tx *= ilength;\n\t\ty *= ilength;\n\t\tz *= ilength;\n\t\tw *= ilength;\n\t}\n\t\t\n\treturn *this;\n}\n\ninline quat_t quat_t::operator-() {\n\treturn quat_t( -x, -y, -z, -w );\n}\n\n#endif /* !__MATH_QUATERNION_H__ */\n"
  },
  {
    "path": "q3radiant/splines/math_vector.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//#include \"../game/q_shared.h\"\n#include \"math_vector.h\"\n#include <assert.h>\n#include <math.h>\n#include <stdio.h>\n#include <stdarg.h>\n#include <string.h>\n#include <stdlib.h>\n#include <time.h>\n#include <ctype.h>\n\n#define M_PI\t\t3.14159265358979323846\t// matches value in gcc v2 math.h\n\n#define LERP_DELTA 1e-6\n\nidVec3_t vec_zero( 0.0f, 0.0f, 0.0f );\n\nBounds\tboundsZero;\n\nfloat idVec3_t::toYaw( void ) {\n\tfloat yaw;\n\t\n\tif ( ( y == 0 ) && ( x == 0 ) ) {\n\t\tyaw = 0;\n\t} else {\n\t\tyaw = atan2( y, x ) * 180 / M_PI;\n\t\tif ( yaw < 0 ) {\n\t\t\tyaw += 360;\n\t\t}\n\t}\n\n\treturn yaw;\n}\n\nfloat idVec3_t::toPitch( void ) {\n\tfloat\tforward;\n\tfloat\tpitch;\n\t\n\tif ( ( x == 0 ) && ( y == 0 ) ) {\n\t\tif ( z > 0 ) {\n\t\t\tpitch = 90;\n\t\t} else {\n\t\t\tpitch = 270;\n\t\t}\n\t} else {\n\t\tforward = ( float )idSqrt( x * x + y * y );\n\t\tpitch = atan2( z, forward ) * 180 / M_PI;\n\t\tif ( pitch < 0 ) {\n\t\t\tpitch += 360;\n\t\t}\n\t}\n\n\treturn pitch;\n}\n\n/*\nangles_t idVec3_t::toAngles( void ) {\n\tfloat forward;\n\tfloat yaw;\n\tfloat pitch;\n\t\n\tif ( ( x == 0 ) && ( y == 0 ) ) {\n\t\tyaw = 0;\n\t\tif ( z > 0 ) {\n\t\t\tpitch = 90;\n\t\t} else {\n\t\t\tpitch = 270;\n\t\t}\n\t} else {\n\t\tyaw = atan2( y, x ) * 180 / M_PI;\n\t\tif ( yaw < 0 ) {\n\t\t\tyaw += 360;\n\t\t}\n\n\t\tforward = ( float )idSqrt( x * x + y * y );\n\t\tpitch = atan2( z, forward ) * 180 / M_PI;\n\t\tif ( pitch < 0 ) {\n\t\t\tpitch += 360;\n\t\t}\n\t}\n\n\treturn angles_t( -pitch, yaw, 0 );\n}\n*/\n\nidVec3_t LerpVector( idVec3_t &w1, idVec3_t &w2, const float t ) {\n\tfloat omega, cosom, sinom, scale0, scale1;\n\n\tcosom = w1 * w2;\n\tif ( ( 1.0 - cosom ) > LERP_DELTA ) {\n\t\tomega = acos( cosom );\n\t\tsinom = sin( omega );\n\t\tscale0 = sin( ( 1.0 - t ) * omega ) / sinom;\n\t\tscale1 = sin( t * omega ) / sinom;\n\t} else {\n\t\tscale0 = 1.0 - t;\n\t\tscale1 = t;\n\t}\n\n\treturn ( w1 * scale0 + w2 * scale1 );\n}\n\n/*\n=============\nidVec3_t::string\n\nThis is just a convenience function\nfor printing vectors\n=============\n*/\nchar *idVec3_t::string( void ) {\n\tstatic\tint\t\tindex = 0;\n\tstatic\tchar\tstr[ 8 ][ 36 ];\n\tchar\t*s;\n\n\t// use an array so that multiple toString's won't collide\n\ts = str[ index ];\n\tindex = (index + 1)&7;\n\n\tsprintf( s, \"%.2f %.2f %.2f\", x, y, z );\n\n\treturn s;\n}\n"
  },
  {
    "path": "q3radiant/splines/math_vector.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __MATH_VECTOR_H__\n#define __MATH_VECTOR_H__\n\n#pragma warning(disable : 4244)\n\n#include <math.h>\n#include <assert.h>\n\n//#define DotProduct(a,b)\t\t\t((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2])\n//#define VectorSubtract(a,b,c)\t((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2])\n//#define VectorAdd(a,b,c)\t\t((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2])\n//#define VectorCopy(a,b)\t\t\t((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2])\n//#define VectorCopy(a,b)\t\t\t((b).x=(a).x,(b).y=(a).y,(b).z=(a).z])\n\n//#define\tVectorScale(v, s, o)\t((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s))\n#define\t__VectorMA(v, s, b, o)\t((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s))\n//#define CrossProduct(a,b,c)\t\t((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])\n\n#define DotProduct4(x,y)\t\t((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]+(x)[3]*(y)[3])\n#define VectorSubtract4(a,b,c)\t((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2],(c)[3]=(a)[3]-(b)[3])\n#define VectorAdd4(a,b,c)\t\t((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2],(c)[3]=(a)[3]+(b)[3])\n#define VectorCopy4(a,b)\t\t((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])\n#define\tVectorScale4(v, s, o)\t((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s),(o)[3]=(v)[3]*(s))\n#define\tVectorMA4(v, s, b, o)\t((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))\n\n\n//#define VectorClear(a)\t\t\t((a)[0]=(a)[1]=(a)[2]=0)\n#define VectorNegate(a,b)\t\t((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2])\n//#define VectorSet(v, x, y, z)\t((v)[0]=(x), (v)[1]=(y), (v)[2]=(z))\n#define Vector4Copy(a,b)\t\t((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])\n\n#define\tSnapVector(v) {v[0]=(int)v[0];v[1]=(int)v[1];v[2]=(int)v[2];}\n\n\n//#include \"util_heap.h\"\n\n#ifndef EQUAL_EPSILON\n#define EQUAL_EPSILON\t0.001\n#endif\n\nfloat Q_fabs( float f );\n\n#ifndef ID_INLINE\n#ifdef _WIN32\n#define ID_INLINE __inline \n#else\n#define ID_INLINE inline\n#endif\n#endif\n\n// if this is defined, vec3 will take four elements, which may allow\n// easier SIMD optimizations\n//#define\tFAT_VEC3\n//#ifdef __ppc__\n//#pragma align(16)\n//#endif\n\nclass angles_t;\n#ifdef __ppc__\n// Vanilla PPC code, but since PPC has a reciprocal square root estimate instruction, \n// runs *much* faster than calling sqrt(). We'll use two Newton-Raphson \n// refinement steps to get bunch more precision in the 1/sqrt() value for very little cost. \n// We'll then multiply 1/sqrt times the original value to get the sqrt. \n// This is about 12.4 times faster than sqrt() and according to my testing (not exhaustive) \n// it returns fairly accurate results (error below 1.0e-5 up to 100000.0 in 0.1 increments). \n\nstatic inline float idSqrt(float x) {\n    const float half = 0.5;\n    const float one = 1.0;\n    float B, y0, y1;\n\n    // This'll NaN if it hits frsqrte. Handle both +0.0 and -0.0\n    if (fabs(x) == 0.0)\n        return x;\n    B = x;\n    \n#ifdef __GNUC__\n    asm(\"frsqrte %0,%1\" : \"=f\" (y0) : \"f\" (B));\n#else\n    y0 = __frsqrte(B);\n#endif\n    /* First refinement step */\n    \n    y1 = y0 + half*y0*(one - B*y0*y0);\n    \n    /* Second refinement step -- copy the output of the last step to the input of this step */\n    \n    y0 = y1;\n    y1 = y0 + half*y0*(one - B*y0*y0);\n    \n    /* Get sqrt(x) from x * 1/sqrt(x) */\n    return x * y1;\n}\n#else\nstatic inline double idSqrt(double x) {\n    return sqrt(x);\n}\n#endif\n\n\n//class idVec3_t  : public idHeap<idVec3_t> {\nclass idVec3_t {\npublic:\t\n#ifndef\tFAT_VEC3\n\t    float x,y,z;\n#else\n\t    float x,y,z,dist;\n#endif\n\n#ifndef\tFAT_VEC3\n\t\t\t\t\tidVec3_t() {};\n#else\n\t\t\t\t\tidVec3_t() {dist = 0.0f;};\n#endif\n\t\t\t\t\tidVec3_t( const float x, const float y, const float z );\n\n\t\t\t\t\toperator float *();\n\n\tfloat\t\t\toperator[]( const int index ) const;\n\tfloat\t\t\t&operator[]( const int index );\n\n\tvoid \t\t\tset( const float x, const float y, const float z );\n\n\tidVec3_t\t\t\toperator-() const;\n\n\tidVec3_t\t\t\t&operator=( const idVec3_t &a );\n\n\tfloat\t\t\toperator*( const idVec3_t &a ) const;\n\tidVec3_t\t\t\toperator*( const float a ) const;\n\tfriend idVec3_t\toperator*( float a, idVec3_t b );\n\n\tidVec3_t\t\t\toperator+( const idVec3_t &a ) const;\n\tidVec3_t\t\t\toperator-( const idVec3_t &a ) const;\n\t\n\tidVec3_t\t\t\t&operator+=( const idVec3_t &a );\n\tidVec3_t\t\t\t&operator-=( const idVec3_t &a );\n\tidVec3_t\t\t\t&operator*=( const float a );\n\n\tint\t\t\t\toperator==(\tconst idVec3_t &a ) const;\n\tint\t\t\t\toperator!=(\tconst idVec3_t &a ) const;\n\n\tidVec3_t\t\t\tCross( const idVec3_t &a ) const;\n\tidVec3_t\t\t\t&Cross( const idVec3_t &a, const idVec3_t &b );\n\n\tfloat\t\t\tLength( void ) const;\n\tfloat\t\t\tNormalize( void );\n\n\tvoid\t\t\tZero( void );\n\tvoid\t\t\tSnap( void );\n\tvoid\t\t\tSnapTowards( const idVec3_t &to );\n\n\tfloat\t\t\ttoYaw( void );\n\tfloat\t\t\ttoPitch( void );\n\tangles_t\t\ttoAngles( void );\n\tfriend idVec3_t\tLerpVector( const idVec3_t &w1, const idVec3_t &w2, const float t );\n\n\tchar\t\t\t*string( void );\n};\n\nextern idVec3_t vec_zero;\n\nID_INLINE idVec3_t::idVec3_t( const float x, const float y, const float z ) {\n\tthis->x = x;\n\tthis->y = y;\n\tthis->z = z;\n#ifdef\tFAT_VEC3\n\tthis->dist = 0.0f;\n#endif\n}\n\nID_INLINE float idVec3_t::operator[]( const int index ) const {\n\treturn ( &x )[ index ];\n}\n\nID_INLINE float &idVec3_t::operator[]( const int index ) {\n\treturn ( &x )[ index ];\n}\n\nID_INLINE idVec3_t::operator float *( void ) {\n\treturn &x;\n}\n\nID_INLINE idVec3_t idVec3_t::operator-() const {\n\treturn idVec3_t( -x, -y, -z );\n}\n\t\nID_INLINE idVec3_t &idVec3_t::operator=( const idVec3_t &a ) { \n\tx = a.x;\n\ty = a.y;\n\tz = a.z;\n\t\n\treturn *this;\n}\n\nID_INLINE void idVec3_t::set( const float x, const float y, const float z ) {\n\tthis->x = x;\n\tthis->y = y;\n\tthis->z = z;\n}\n\nID_INLINE idVec3_t idVec3_t::operator-( const idVec3_t &a ) const {\n\treturn idVec3_t( x - a.x, y - a.y, z - a.z );\n}\n\nID_INLINE float idVec3_t::operator*( const idVec3_t &a ) const {\n\treturn x * a.x + y * a.y + z * a.z;\n}\n\nID_INLINE idVec3_t idVec3_t::operator*( const float a ) const {\n\treturn idVec3_t( x * a, y * a, z * a );\n}\n\nID_INLINE idVec3_t operator*( const float a, const idVec3_t b ) {\n\treturn idVec3_t( b.x * a, b.y * a, b.z * a );\n}\n\nID_INLINE idVec3_t idVec3_t::operator+( const idVec3_t &a ) const {\n\treturn idVec3_t( x + a.x, y + a.y, z + a.z );\n}\n\nID_INLINE idVec3_t &idVec3_t::operator+=( const idVec3_t &a ) {\n\tx += a.x;\n\ty += a.y;\n\tz += a.z;\n\n\treturn *this;\n}\n\nID_INLINE idVec3_t &idVec3_t::operator-=( const idVec3_t &a ) {\n\tx -= a.x;\n\ty -= a.y;\n\tz -= a.z;\n\n\treturn *this;\n}\n\nID_INLINE idVec3_t &idVec3_t::operator*=( const float a ) {\n\tx *= a;\n\ty *= a;\n\tz *= a;\n\n\treturn *this;\n}\n\nID_INLINE int idVec3_t::operator==( const idVec3_t &a ) const {\n\tif ( Q_fabs( x - a.x ) > EQUAL_EPSILON ) {\n\t\treturn false;\n\t}\n\t\t\t\n\tif ( Q_fabs( y - a.y ) > EQUAL_EPSILON ) {\n\t\treturn false;\n\t}\n\n\tif ( Q_fabs( z - a.z ) > EQUAL_EPSILON ) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\nID_INLINE int idVec3_t::operator!=( const idVec3_t &a ) const {\n\tif ( Q_fabs( x - a.x ) > EQUAL_EPSILON ) {\n\t\treturn true;\n\t}\n\t\t\t\n\tif ( Q_fabs( y - a.y ) > EQUAL_EPSILON ) {\n\t\treturn true;\n\t}\n\n\tif ( Q_fabs( z - a.z ) > EQUAL_EPSILON ) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nID_INLINE idVec3_t idVec3_t::Cross( const idVec3_t &a ) const {\n\treturn idVec3_t( y * a.z - z * a.y, z * a.x - x * a.z, x * a.y - y * a.x );\n}\n\nID_INLINE idVec3_t &idVec3_t::Cross( const idVec3_t &a, const idVec3_t &b ) {\n\tx = a.y * b.z - a.z * b.y;\n\ty = a.z * b.x - a.x * b.z;\n\tz = a.x * b.y - a.y * b.x;\n\n\treturn *this;\n}\n\nID_INLINE float idVec3_t::Length( void ) const {\n\tfloat length;\n\t\n\tlength = x * x + y * y + z * z;\n\treturn ( float )idSqrt( length );\n}\n\nID_INLINE float idVec3_t::Normalize( void ) {\n\tfloat length;\n\tfloat ilength;\n\n\tlength = this->Length();\n\tif ( length ) {\n\t\tilength = 1.0f / length;\n\t\tx *= ilength;\n\t\ty *= ilength;\n\t\tz *= ilength;\n\t}\n\t\t\n\treturn length;\n}\n\nID_INLINE void idVec3_t::Zero( void ) {\n\tx = 0.0f;\n\ty = 0.0f;\n\tz = 0.0f;\n}\n\nID_INLINE void idVec3_t::Snap( void ) {\n\tx = float( int( x ) );\n\ty = float( int( y ) );\n\tz = float( int( z ) );\n}\n\n/*\n======================\nSnapTowards\n\nRound a vector to integers for more efficient network\ntransmission, but make sure that it rounds towards a given point\nrather than blindly truncating.  This prevents it from truncating \ninto a wall.\n======================\n*/\nID_INLINE void idVec3_t::SnapTowards( const idVec3_t &to ) {\n\tif ( to.x <= x ) {\n\t\tx = float( int( x ) );\n\t} else {\n\t\tx = float( int( x ) + 1 );\n\t}\n\n\tif ( to.y <= y ) {\n\t\ty = float( int( y ) );\n\t} else {\n\t\ty = float( int( y ) + 1 );\n\t}\n\n\tif ( to.z <= z ) {\n\t\tz = float( int( z ) );\n\t} else {\n\t\tz = float( int( z ) + 1 );\n\t}\n}\n\n//===============================================================\n\nclass Bounds {\npublic:\n\tidVec3_t\tb[2];\n\n\t\t\tBounds();\n\t\t\tBounds( const idVec3_t &mins, const idVec3_t &maxs );\n\n\tvoid\tClear();\n\tvoid\tZero();\n\tfloat\tRadius();\t\t// radius from origin, not from center\n\tidVec3_t\tCenter();\n\tvoid\tAddPoint( const idVec3_t &v );\n\tvoid\tAddBounds( const Bounds &bb );\n\tbool\tIsCleared();\n\tbool\tContainsPoint( const idVec3_t &p );\n\tbool\tIntersectsBounds( const Bounds &b2 );\t// touching is NOT intersecting\n};\n\nextern Bounds\tboundsZero;\n\nID_INLINE Bounds::Bounds(){\n}\n\nID_INLINE bool Bounds::IsCleared() {\n\treturn b[0][0] > b[1][0];\n}\n\nID_INLINE bool Bounds::ContainsPoint( const idVec3_t &p ) {\n\tif ( p[0] < b[0][0] || p[1] < b[0][1] || p[2] < b[0][2]\n\t\t|| p[0] > b[1][0] || p[1] > b[1][1] || p[2] > b[1][2] ) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\nID_INLINE bool Bounds::IntersectsBounds( const Bounds &b2 ) {\n\tif ( b2.b[1][0] < b[0][0] || b2.b[1][1] < b[0][1] || b2.b[1][2] < b[0][2]\n\t\t|| b2.b[0][0] > b[1][0] || b2.b[0][1] > b[1][1] || b2.b[0][2] > b[1][2] ) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\nID_INLINE Bounds::Bounds( const idVec3_t &mins, const idVec3_t &maxs ) {\n\tb[0] = mins;\n\tb[1] = maxs;\n}\n\nID_INLINE idVec3_t Bounds::Center() {\n\treturn 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 );\n}\n\nID_INLINE void Bounds::Clear() {\n\tb[0][0] = b[0][1] = b[0][2] = 99999;\n\tb[1][0] = b[1][1] = b[1][2] = -99999;\n}\n\nID_INLINE void Bounds::Zero() {\n\tb[0][0] = b[0][1] = b[0][2] =\n\tb[1][0] = b[1][1] = b[1][2] = 0;\n}\n\nID_INLINE void Bounds::AddPoint( const idVec3_t &v ) {\n\tif ( v[0] < b[0][0]) {\n\t\tb[0][0] = v[0];\n\t}\n\tif ( v[0] > b[1][0]) {\n\t\tb[1][0] = v[0];\n\t}\n\tif ( v[1] < b[0][1] ) {\n\t\tb[0][1] = v[1];\n\t}\n\tif ( v[1] > b[1][1]) {\n\t\tb[1][1] = v[1];\n\t}\n\tif ( v[2] < b[0][2] ) {\n\t\tb[0][2] = v[2];\n\t}\n\tif ( v[2] > b[1][2]) {\n\t\tb[1][2] = v[2];\n\t}\n}\n\n\nID_INLINE void Bounds::AddBounds( const Bounds &bb ) {\n\tif ( bb.b[0][0] < b[0][0]) {\n\t\tb[0][0] = bb.b[0][0];\n\t}\n\tif ( bb.b[0][1] < b[0][1]) {\n\t\tb[0][1] = bb.b[0][1];\n\t}\n\tif ( bb.b[0][2] < b[0][2]) {\n\t\tb[0][2] = bb.b[0][2];\n\t}\n\n\tif ( bb.b[1][0] > b[1][0]) {\n\t\tb[1][0] = bb.b[1][0];\n\t}\n\tif ( bb.b[1][1] > b[1][1]) {\n\t\tb[1][1] = bb.b[1][1];\n\t}\n\tif ( bb.b[1][2] > b[1][2]) {\n\t\tb[1][2] = bb.b[1][2];\n\t}\n}\n\nID_INLINE float Bounds::Radius( ) {\n\tint\t\ti;\n\tfloat\ttotal;\n\tfloat\ta, aa;\n\n\ttotal = 0;\n\tfor (i=0 ; i<3 ; i++) {\n\t\ta = (float)fabs( b[0][i] );\n\t\taa = (float)fabs( b[1][i] );\n\t\tif ( aa > a ) {\n\t\t\ta = aa;\n\t\t}\n\t\ttotal += a * a;\n\t}\n\n\treturn (float)idSqrt( total );\n}\n\n//===============================================================\n\n\nclass idVec2_t {\npublic:\n\tfloat\t\t\tx;\n\tfloat\t\t\ty;\n\n\t\t\t\t\toperator float *();\n\tfloat\t\t\toperator[]( int index ) const;\n\tfloat\t\t\t&operator[]( int index );\n};\n\nID_INLINE float idVec2_t::operator[]( int index ) const {\n\treturn ( &x )[ index ];\n}\n\nID_INLINE float& idVec2_t::operator[]( int index ) {\n\treturn ( &x )[ index ];\n}\n\nID_INLINE idVec2_t::operator float *( void ) {\n\treturn &x;\n}\n\nclass vec4_t : public idVec3_t {\npublic:\n#ifndef\tFAT_VEC3\n\tfloat\t\t\tdist;\n#endif\n\tvec4_t();\n\t~vec4_t() {};\n\t\n\tvec4_t( float x, float y, float z, float dist );\n\tfloat\t\t\toperator[]( int index ) const;\n\tfloat\t\t\t&operator[]( int index );\n};\n\nID_INLINE vec4_t::vec4_t() {}\nID_INLINE vec4_t::vec4_t( float x, float y, float z, float dist ) {\n\tthis->x = x;\n\tthis->y = y;\n\tthis->z = z;\n\tthis->dist = dist;\n}\n\nID_INLINE float vec4_t::operator[]( int index ) const {\n\treturn ( &x )[ index ];\n}\n\nID_INLINE float& vec4_t::operator[]( int index ) {\n\treturn ( &x )[ index ];\n}\n\n\nclass idVec5_t : public idVec3_t {\npublic:\n\tfloat\t\t\ts;\n\tfloat\t\t\tt;\n\tfloat\t\t\toperator[]( int index ) const;\n\tfloat\t\t\t&operator[]( int index );\n};\n\n\nID_INLINE float idVec5_t::operator[]( int index ) const {\n\treturn ( &x )[ index ];\n}\n\nID_INLINE float& idVec5_t::operator[]( int index ) {\n\treturn ( &x )[ index ];\n}\n\n#endif /* !__MATH_VECTOR_H__ */\n"
  },
  {
    "path": "q3radiant/splines/q_parse.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// q_parse.c -- support for parsing text files\n\n#include \"q_shared.h\"\n\n/*\n============================================================================\n\nPARSING\n\n============================================================================\n*/\n\n// multiple character punctuation tokens\nstatic const char *punctuation[] = {\n\t\"+=\", \"-=\",  \"*=\",  \"/=\", \"&=\", \"|=\", \"++\", \"--\",\n\t\t\"&&\", \"||\",  \"<=\",  \">=\", \"==\", \"!=\",\n\tNULL\n};\n\ntypedef struct {\n\tchar\ttoken[MAX_TOKEN_CHARS];\n\tint\t\tlines;\n\tqboolean\tungetToken;\n\tchar\tparseFile[MAX_QPATH];\n} parseInfo_t;\n\n#define\tMAX_PARSE_INFO\t16\nstatic parseInfo_t\tparseInfo[MAX_PARSE_INFO];\nstatic int\t\t\tparseInfoNum;\nstatic parseInfo_t\t*pi = &parseInfo[0];\n\n/*\n===================\nCom_BeginParseSession\n===================\n*/\nvoid Com_BeginParseSession( const char *filename ) {\n\tif ( parseInfoNum == MAX_PARSE_INFO - 1 ) {\n\t\tCom_Error( ERR_FATAL, \"Com_BeginParseSession: session overflow\" );\n\t}\n\tparseInfoNum++;\n\tpi = &parseInfo[parseInfoNum];\n\n\tpi->lines = 1;\n\tQ_strncpyz( pi->parseFile, filename, sizeof( pi->parseFile ) );\n}\n\n/*\n===================\nCom_EndParseSession\n===================\n*/\nvoid Com_EndParseSession( void ) {\n\tif ( parseInfoNum == 0 ) {\n\t\tCom_Error( ERR_FATAL, \"Com_EndParseSession: session underflow\" );\n\t}\n\tparseInfoNum--;\n\tpi = &parseInfo[parseInfoNum];\n}\n\n/*\n===================\nCom_GetCurrentParseLine\n===================\n*/\nint Com_GetCurrentParseLine( void ) {\n\treturn pi->lines;\n}\n\n/*\n===================\nCom_ScriptError\n\nPrints the script name and line number in the message\n===================\n*/\nvoid Com_ScriptError( const char *msg, ... ) {\n\tva_list\t\targptr;\n\tchar\t\tstring[32000];\n\n\tva_start( argptr, msg );\n\tvsprintf( string, msg,argptr );\n\tva_end( argptr );\n\n\tCom_Error( ERR_DROP, \"File %s, line %i: %s\", pi->parseFile, pi->lines, string );\n}\n\nvoid Com_ScriptWarning( const char *msg, ... ) {\n\tva_list\t\targptr;\n\tchar\t\tstring[32000];\n\n\tva_start( argptr, msg );\n\tvsprintf( string, msg,argptr );\n\tva_end( argptr );\n\n\tCom_Printf( \"File %s, line %i: %s\", pi->parseFile, pi->lines, string );\n}\n\n\n/*\n===================\nCom_UngetToken\n\nCalling this will make the next Com_Parse return\nthe current token instead of advancing the pointer\n===================\n*/\nvoid Com_UngetToken( void ) {\n\tif ( pi->ungetToken ) {\n\t\tCom_ScriptError( \"UngetToken called twice\" );\n\t}\n\tpi->ungetToken = qtrue;\n}\n\n\nstatic const char *SkipWhitespace( const char (*data), qboolean *hasNewLines ) {\n\tint c;\n\n\twhile( (c = *data) <= ' ') {\n\t\tif( !c ) {\n\t\t\treturn NULL;\n\t\t}\n\t\tif( c == '\\n' ) {\n\t\t\tpi->lines++;\n\t\t\t*hasNewLines = qtrue;\n\t\t}\n\t\tdata++;\n\t}\n\n\treturn data;\n}\n\n/*\n==============\nCom_ParseExt\n\nParse a token out of a string\nWill never return NULL, just empty strings.\nAn empty string will only be returned at end of file.\n\nIf \"allowLineBreaks\" is qtrue then an empty\nstring will be returned if the next token is\na newline.\n==============\n*/\nstatic char *Com_ParseExt( const char *(*data_p), qboolean allowLineBreaks ) {\n\tint c = 0, len;\n\tqboolean hasNewLines = qfalse;\n\tconst char *data;\n\tconst char **punc;\n\n\tif ( !data_p ) {\n\t\tCom_Error( ERR_FATAL, \"Com_ParseExt: NULL data_p\" );\n\t}\n\n\tdata = *data_p;\n\tlen = 0;\n\tpi->token[0] = 0;\n\n\t// make sure incoming data is valid\n\tif ( !data ) {\n\t\t*data_p = NULL;\n\t\treturn pi->token;\n\t}\n\n\t// skip any leading whitespace\n\twhile ( 1 ) {\n\t\t// skip whitespace\n\t\tdata = SkipWhitespace( data, &hasNewLines );\n\t\tif ( !data ) {\n\t\t\t*data_p = NULL;\n\t\t\treturn pi->token;\n\t\t}\n\t\tif ( hasNewLines && !allowLineBreaks ) {\n\t\t\t*data_p = data;\n\t\t\treturn pi->token;\n\t\t}\n\n\t\tc = *data;\n\n\t\t// skip double slash comments\n\t\tif ( c == '/' && data[1] == '/' ) {\n\t\t\twhile (*data && *data != '\\n') {\n\t\t\t\tdata++;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// skip /* */ comments\n\t\tif ( c=='/' && data[1] == '*' ) {\n\t\t\twhile ( *data && ( *data != '*' || data[1] != '/' ) ) {\n\t\t\t\tif( *data == '\\n' ) {\n\t\t\t\t\tpi->lines++;\n\t\t\t\t}\n\t\t\t\tdata++;\n\t\t\t}\n\t\t\tif ( *data ) {\n\t\t\t\tdata += 2;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// a real token to parse\n\t\tbreak;\n\t}\n\n\t// handle quoted strings\n\tif ( c == '\\\"' ) {\n\t\tdata++;\n\t\twhile( 1 ) {\n\t\t\tc = *data++;\n\t\t\tif ( ( c=='\\\\' ) && ( *data == '\\\"' ) ) {\n\t\t\t\t// allow quoted strings to use \\\" to indicate the \" character\n\t\t\t\tdata++;\n\t\t\t} else if ( c=='\\\"' || !c ) {\n\t\t\t\tpi->token[len] = 0;\n\t\t\t\t*data_p = ( char * ) data;\n\t\t\t\treturn pi->token;\n\t\t\t} else if( *data == '\\n' ) {\n\t\t\t\tpi->lines++;\n\t\t\t}\n\t\t\tif ( len < MAX_TOKEN_CHARS - 1 ) {\n\t\t\t\tpi->token[len] = c;\n\t\t\t\tlen++;\n\t\t\t}\n\t\t}\n\t}\n\n\t// check for a number\n\t// is this parsing of negative numbers going to cause expression problems\n\tif ( ( c >= '0' && c <= '9' ) || ( c == '-' && data[ 1 ] >= '0' && data[ 1 ] <= '9' ) || \n\t\t( c == '.' && data[ 1 ] >= '0' && data[ 1 ] <= '9' ) ) {\n\t\tdo  {\n\n\t\t\tif (len < MAX_TOKEN_CHARS - 1) {\n\t\t\t\tpi->token[len] = c;\n\t\t\t\tlen++;\n\t\t\t}\n\t\t\tdata++;\n\n\t\t\tc = *data;\n\t\t} while ( ( c >= '0' && c <= '9' ) || c == '.' );\n\n\t\t// parse the exponent\n\t\tif ( c == 'e' || c == 'E' ) {\n\t\t\tif (len < MAX_TOKEN_CHARS - 1) {\n\t\t\t\tpi->token[len] = c;\n\t\t\t\tlen++;\n\t\t\t}\n\t\t\tdata++;\n\t\t\tc = *data;\n\n\t\t\tif ( c == '-' || c == '+' ) {\n\t\t\t\tif (len < MAX_TOKEN_CHARS - 1) {\n\t\t\t\t\tpi->token[len] = c;\n\t\t\t\t\tlen++;\n\t\t\t\t}\n\t\t\t\tdata++;\n\t\t\t\tc = *data;\n\t\t\t}\n\n\t\t\tdo  {\n\t\t\t\tif (len < MAX_TOKEN_CHARS - 1) {\n\t\t\t\t\tpi->token[len] = c;\n\t\t\t\t\tlen++;\n\t\t\t\t}\n\t\t\t\tdata++;\n\n\t\t\t\tc = *data;\n\t\t\t} while ( c >= '0' && c <= '9' );\n\t\t}\n\n\t\tif (len == MAX_TOKEN_CHARS) {\n\t\t\tlen = 0;\n\t\t}\n\t\tpi->token[len] = 0;\n\n\t\t*data_p = ( char * ) data;\n\t\treturn pi->token;\n   \t}\n\n\t// check for a regular word\n\t// we still allow forward and back slashes in name tokens for pathnames\n\t// and also colons for drive letters\n\tif ( ( c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z' ) || c == '_' || c == '/' || c == '\\\\' ) {\n\t\tdo  {\n\t\t\tif (len < MAX_TOKEN_CHARS - 1) {\n\t\t\t\tpi->token[len] = c;\n\t\t\t\tlen++;\n\t\t\t}\n\t\t\tdata++;\n\n\t\t\tc = *data;\n\t\t} while ( ( c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z' ) || c == '_' \n\t\t\t|| ( c >= '0' && c <= '9' ) || c == '/' || c == '\\\\' || c == ':' || c == '.' );\n\n\t\tif (len == MAX_TOKEN_CHARS) {\n\t\t\tlen = 0;\n\t\t}\n\t\tpi->token[len] = 0;\n\n\t\t*data_p = ( char * ) data;\n\t\treturn pi->token;\n\t}\n\n\t// check for multi-character punctuation token\n\tfor ( punc = punctuation ; *punc ; punc++ ) {\n\t\tint\t\tl;\n\t\tint\t\tj;\n\n\t\tl = strlen( *punc );\n\t\tfor ( j = 0 ; j < l ; j++ ) {\n\t\t\tif ( data[j] != (*punc)[j] ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif ( j == l ) {\n\t\t\t// a valid multi-character punctuation\n\t\t\tmemcpy( pi->token, *punc, l );\n\t\t\tpi->token[l] = 0;\n\t\t\tdata += l;\n\t\t\t*data_p = (char *)data;\n\t\t\treturn pi->token;\n\t\t}\n\t}\n\n\t// single character punctuation\n\tpi->token[0] = *data;\n\tpi->token[1] = 0;\n\tdata++;\n\t*data_p = (char *)data;\n\n\treturn pi->token;\n}\n\n/*\n===================\nCom_Parse\n===================\n*/\nconst char *Com_Parse( const char *(*data_p) ) {\n\tif ( pi->ungetToken ) {\n\t\tpi->ungetToken = qfalse;\n\t\treturn pi->token;\n\t}\n\treturn Com_ParseExt( data_p, qtrue );\n}\n\n/*\n===================\nCom_ParseOnLine\n===================\n*/\nconst char *Com_ParseOnLine( const char *(*data_p) ) {\n\tif ( pi->ungetToken ) {\n\t\tpi->ungetToken = qfalse;\n\t\treturn pi->token;\n\t}\n\treturn Com_ParseExt( data_p, qfalse );\n}\n\n\n\n/*\n==================\nCom_MatchToken\n==================\n*/\nvoid Com_MatchToken( const char *(*buf_p), const char *match, qboolean warning ) {\n\tconst char\t*token;\n\n\ttoken = Com_Parse( buf_p );\n\tif ( strcmp( token, match ) ) {\n\t\tif (warning) {\n\t\t\tCom_ScriptWarning( \"MatchToken: %s != %s\", token, match );\n\t\t} else {\n\t\t\tCom_ScriptError( \"MatchToken: %s != %s\", token, match );\n\t\t}\n\t}\n}\n\n\n/*\n=================\nCom_SkipBracedSection\n\nThe next token should be an open brace.\nSkips until a matching close brace is found.\nInternal brace depths are properly skipped.\n=================\n*/\nvoid Com_SkipBracedSection( const char *(*program) ) {\n\tconst char\t\t\t*token;\n\tint\t\t\t\tdepth;\n\n\tdepth = 0;\n\tdo {\n\t\ttoken = Com_Parse( program );\n\t\tif( token[1] == 0 ) {\n\t\t\tif( token[0] == '{' ) {\n\t\t\t\tdepth++;\n\t\t\t}\n\t\t\telse if( token[0] == '}' ) {\n\t\t\t\tdepth--;\n\t\t\t}\n\t\t}\n\t} while( depth && *program );\n}\n\n/*\n=================\nCom_SkipRestOfLine\n=================\n*/\nvoid Com_SkipRestOfLine ( const char *(*data) ) {\n\tconst char\t*p;\n\tint\t\tc;\n\n\tp = *data;\n\twhile ( (c = *p++) != 0 ) {\n\t\tif ( c == '\\n' ) {\n\t\t\tpi->lines++;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t*data = p;\n}\n\n/*\n====================\nCom_ParseRestOfLine\n====================\n*/\nconst char *Com_ParseRestOfLine( const char *(*data_p) ) {\n\tstatic char\tline[MAX_TOKEN_CHARS];\n\tconst char *token;\n\n\tline[0] = 0;\n\twhile( 1 ) {\n\t\ttoken = Com_ParseOnLine( data_p );\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( line[0] ) {\n\t\t\tQ_strcat( line, sizeof(line), \" \" );\n\t\t}\n\t\tQ_strcat( line, sizeof(line), token );\n\t}\n\n\treturn line;\n}\n\n\nfloat Com_ParseFloat( const char *(*buf_p) ) {\n\tconst char\t\t*token;\n\n\ttoken = Com_Parse( buf_p );\n\tif ( !token[0] ) {\n\t\treturn 0;\n\t}\n\treturn atof( token );\n}\n\nint Com_ParseInt( const char *(*buf_p) ) {\n\tconst char\t\t*token;\n\n\ttoken = Com_Parse( buf_p );\n\tif ( !token[0] ) {\n\t\treturn 0;\n\t}\n\treturn atof( token );\n}\n\n\n\nvoid Com_Parse1DMatrix( const char *(*buf_p), int x, float *m ) {\n\tconst char\t*token;\n\tint\t\ti;\n\n\tCom_MatchToken( buf_p, \"(\" );\n\n\tfor (i = 0 ; i < x ; i++) {\n\t\ttoken = Com_Parse(buf_p);\n\t\tm[i] = atof(token);\n\t}\n\n\tCom_MatchToken( buf_p, \")\" );\n}\n\nvoid Com_Parse2DMatrix( const char *(*buf_p), int y, int x, float *m ) {\n\tint\t\ti;\n\n\tCom_MatchToken( buf_p, \"(\" );\n\n\tfor (i = 0 ; i < y ; i++) {\n\t\tCom_Parse1DMatrix (buf_p, x, m + i * x);\n\t}\n\n\tCom_MatchToken( buf_p, \")\" );\n}\n\nvoid Com_Parse3DMatrix( const char *(*buf_p), int z, int y, int x, float *m ) {\n\tint\t\ti;\n\n\tCom_MatchToken( buf_p, \"(\" );\n\n\tfor (i = 0 ; i < z ; i++) {\n\t\tCom_Parse2DMatrix (buf_p, y, x, m + i * x*y);\n\t}\n\n\tCom_MatchToken( buf_p, \")\" );\n}\n\n"
  },
  {
    "path": "q3radiant/splines/q_shared.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n// q_shared.c -- stateless support routines that are included in each code dll\n#include \"q_shared.h\"\n\n/*\n============================================================================\n\nGROWLISTS\n\n============================================================================\n*/\n\n// malloc / free all in one place for debugging\nextern \"C\" void *Com_Allocate( int bytes );\nextern \"C\" void Com_Dealloc( void *ptr );\n\nvoid Com_InitGrowList( growList_t *list, int maxElements ) {\n\tlist->maxElements = maxElements;\n\tlist->currentElements = 0;\n\tlist->elements = (void **)Com_Allocate( list->maxElements * sizeof( void * ) );\n}\n\nint Com_AddToGrowList( growList_t *list, void *data ) {\n\tvoid\t**old;\n\n\tif ( list->currentElements != list->maxElements ) {\n\t\tlist->elements[list->currentElements] = data;\n\t\treturn list->currentElements++;\n\t}\n\n\t// grow, reallocate and move\n\told = list->elements;\n\n\tif ( list->maxElements < 0 ) {\n\t\tCom_Error( ERR_FATAL, \"Com_AddToGrowList: maxElements = %i\", list->maxElements );\n\t}\n\n\tif ( list->maxElements == 0 ) {\n\t\t// initialize the list to hold 100 elements\n\t\tCom_InitGrowList( list, 100 );\n\t\treturn Com_AddToGrowList( list, data );\n\t}\n\n\tlist->maxElements *= 2;\n\n\tCom_DPrintf( \"Resizing growlist to %i maxElements\\n\", list->maxElements );\n\n\tlist->elements = (void **)Com_Allocate( list->maxElements * sizeof( void * ) );\n\n\tif ( !list->elements ) {\n\t\tCom_Error( ERR_DROP, \"Growlist alloc failed\" );\n\t}\n\n\tmemcpy( list->elements, old, list->currentElements * sizeof( void * ) );\n\n\tCom_Dealloc( old );\n\n\treturn Com_AddToGrowList( list, data );\n}\n\nvoid *Com_GrowListElement( const growList_t *list, int index ) {\n\tif ( index < 0 || index >= list->currentElements ) {\n\t\tCom_Error( ERR_DROP, \"Com_GrowListElement: %i out of range of %i\", \n\t\t\tindex, list->currentElements );\n\t}\n\treturn list->elements[index];\n}\n\nint Com_IndexForGrowListElement( const growList_t *list, const void *element ) {\n\tint\t\ti;\n\n\tfor ( i = 0 ; i < list->currentElements ; i++ ) {\n\t\tif ( list->elements[i] == element ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n//============================================================================\n\n\nfloat Com_Clamp( float min, float max, float value ) {\n\tif ( value < min ) {\n\t\treturn min;\n\t}\n\tif ( value > max ) {\n\t\treturn max;\n\t}\n\treturn value;\n}\n\n/*\n============\nCom_StringContains\n============\n*/\nconst char *Com_StringContains( const char *str1, const char *str2, int casesensitive) {\n\tint len, i, j;\n\n\tlen = strlen(str1) - strlen(str2);\n\tfor (i = 0; i <= len; i++, str1++) {\n\t\tfor (j = 0; str2[j]; j++) {\n\t\t\tif (casesensitive) {\n\t\t\t\tif (str1[j] != str2[j]) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (toupper(str1[j]) != toupper(str2[j])) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!str2[j]) {\n\t\t\treturn str1;\n\t\t}\n\t}\n\treturn NULL;\n}\n\n/*\n============\nCom_Filter\n============\n*/\nint Com_Filter( const char *filter, const char *name, int casesensitive)\n{\n\tchar buf[MAX_TOKEN_CHARS];\n\tconst char *ptr;\n\tint i, found;\n\n\twhile(*filter) {\n\t\tif (*filter == '*') {\n\t\t\tfilter++;\n\t\t\tfor (i = 0; *filter; i++) {\n\t\t\t\tif (*filter == '*' || *filter == '?') break;\n\t\t\t\tbuf[i] = *filter;\n\t\t\t\tfilter++;\n\t\t\t}\n\t\t\tbuf[i] = '\\0';\n\t\t\tif (strlen(buf)) {\n\t\t\t\tptr = Com_StringContains(name, buf, casesensitive);\n\t\t\t\tif (!ptr) return qfalse;\n\t\t\t\tname = ptr + strlen(buf);\n\t\t\t}\n\t\t}\n\t\telse if (*filter == '?') {\n\t\t\tfilter++;\n\t\t\tname++;\n\t\t}\n\t\telse if (*filter == '[' && *(filter+1) == '[') {\n\t\t\tfilter++;\n\t\t}\n\t\telse if (*filter == '[') {\n\t\t\tfilter++;\n\t\t\tfound = qfalse;\n\t\t\twhile(*filter && !found) {\n\t\t\t\tif (*filter == ']' && *(filter+1) != ']') break;\n\t\t\t\tif (*(filter+1) == '-' && *(filter+2) && (*(filter+2) != ']' || *(filter+3) == ']')) {\n\t\t\t\t\tif (casesensitive) {\n\t\t\t\t\t\tif (*name >= *filter && *name <= *(filter+2)) found = qtrue;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (toupper(*name) >= toupper(*filter) &&\n\t\t\t\t\t\t\ttoupper(*name) <= toupper(*(filter+2))) found = qtrue;\n\t\t\t\t\t}\n\t\t\t\t\tfilter += 3;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (casesensitive) {\n\t\t\t\t\t\tif (*filter == *name) found = qtrue;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (toupper(*filter) == toupper(*name)) found = qtrue;\n\t\t\t\t\t}\n\t\t\t\t\tfilter++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!found) return qfalse;\n\t\t\twhile(*filter) {\n\t\t\t\tif (*filter == ']' && *(filter+1) != ']') break;\n\t\t\t\tfilter++;\n\t\t\t}\n\t\t\tfilter++;\n\t\t\tname++;\n\t\t}\n\t\telse {\n\t\t\tif (casesensitive) {\n\t\t\t\tif (*filter != *name) return qfalse;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (toupper(*filter) != toupper(*name)) return qfalse;\n\t\t\t}\n\t\t\tfilter++;\n\t\t\tname++;\n\t\t}\n\t}\n\treturn qtrue;\n}\n\n\n/*\n================\nCom_HashString\n\n================\n*/\nint Com_HashString( const char *fname ) {\n\tint\t\ti;\n\tlong\thash;\n\tchar\tletter;\n\n\thash = 0;\n\ti = 0;\n\twhile (fname[i] != '\\0') {\n\t\tletter = tolower(fname[i]);\n\t\tif (letter =='.') break;\t\t\t\t// don't include extension\n\t\tif (letter =='\\\\') letter = '/';\t\t// damn path names\n\t\thash+=(long)(letter)*(i+119);\n\t\ti++;\n\t}\n\thash &= (FILE_HASH_SIZE-1);\n\treturn hash;\n}\n\n\n/*\n============\nCom_SkipPath\n============\n*/\nchar *Com_SkipPath (char *pathname)\n{\n\tchar\t*last;\n\t\n\tlast = pathname;\n\twhile (*pathname)\n\t{\n\t\tif (*pathname=='/')\n\t\t\tlast = pathname+1;\n\t\tpathname++;\n\t}\n\treturn last;\n}\n\n/*\n============\nCom_StripExtension\n============\n*/\nvoid Com_StripExtension( const char *in, char *out ) {\n\twhile ( *in && *in != '.' ) {\n\t\t*out++ = *in++;\n\t}\n\t*out = 0;\n}\n\n\n/*\n==================\nCom_DefaultExtension\n==================\n*/\nvoid Com_DefaultExtension (char *path, int maxSize, const char *extension ) {\n\tchar\toldPath[MAX_QPATH];\n\tchar    *src;\n\n//\n// if path doesn't have a .EXT, append extension\n// (extension should include the .)\n//\n\tsrc = path + strlen(path) - 1;\n\n\twhile (*src != '/' && src != path) {\n\t\tif ( *src == '.' ) {\n\t\t\treturn;                 // it has an extension\n\t\t}\n\t\tsrc--;\n\t}\n\n\tQ_strncpyz( oldPath, path, sizeof( oldPath ) );\n\tCom_sprintf( path, maxSize, \"%s%s\", oldPath, extension );\n}\n\n/*\n============================================================================\n\n\t\t\t\t\tBYTE ORDER FUNCTIONS\n\n============================================================================\n*/\n\n// can't just use function pointers, or dll linkage can\n// mess up when qcommon is included in multiple places\nstatic short\t(*_BigShort) (short l);\nstatic short\t(*_LittleShort) (short l);\nstatic int\t\t(*_BigLong) (int l);\nstatic int\t\t(*_LittleLong) (int l);\nstatic float\t(*_BigFloat) (float l);\nstatic float\t(*_LittleFloat) (float l);\n\nshort\tBigShort(short l){return _BigShort(l);}\nshort\tLittleShort(short l) {return _LittleShort(l);}\nint\t\tBigLong (int l) {return _BigLong(l);}\nint\t\tLittleLong (int l) {return _LittleLong(l);}\nfloat\tBigFloat (float l) {return _BigFloat(l);}\nfloat\tLittleFloat (float l) {return _LittleFloat(l);}\n\nshort   ShortSwap (short l)\n{\n\tbyte    b1,b2;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\n\treturn (b1<<8) + b2;\n}\n\nshort\tShortNoSwap (short l)\n{\n\treturn l;\n}\n\nint    LongSwap (int l)\n{\n\tbyte    b1,b2,b3,b4;\n\n\tb1 = l&255;\n\tb2 = (l>>8)&255;\n\tb3 = (l>>16)&255;\n\tb4 = (l>>24)&255;\n\n\treturn ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;\n}\n\nint\tLongNoSwap (int l)\n{\n\treturn l;\n}\n\nfloat FloatSwap (float f)\n{\n\tunion\n\t{\n\t\tfloat\tf;\n\t\tbyte\tb[4];\n\t} dat1, dat2;\n\t\n\t\n\tdat1.f = f;\n\tdat2.b[0] = dat1.b[3];\n\tdat2.b[1] = dat1.b[2];\n\tdat2.b[2] = dat1.b[1];\n\tdat2.b[3] = dat1.b[0];\n\treturn dat2.f;\n}\n\nfloat FloatNoSwap (float f)\n{\n\treturn f;\n}\n\n/*\n================\nSwap_Init\n================\n*/\nvoid Swap_Init (void)\n{\n\tbyte\tswaptest[2] = {1,0};\n\n// set the byte swapping variables in a portable manner\t\n\tif ( *(short *)swaptest == 1)\n\t{\n\t\t_BigShort = ShortSwap;\n\t\t_LittleShort = ShortNoSwap;\n\t\t_BigLong = LongSwap;\n\t\t_LittleLong = LongNoSwap;\n\t\t_BigFloat = FloatSwap;\n\t\t_LittleFloat = FloatNoSwap;\n\t}\n\telse\n\t{\n\t\t_BigShort = ShortNoSwap;\n\t\t_LittleShort = ShortSwap;\n\t\t_BigLong = LongNoSwap;\n\t\t_LittleLong = LongSwap;\n\t\t_BigFloat = FloatNoSwap;\n\t\t_LittleFloat = FloatSwap;\n\t}\n\n}\n\n/*\n===============\nCom_ParseInfos\n===============\n*/\nint Com_ParseInfos( const char *buf, int max, char infos[][MAX_INFO_STRING] ) {\n\tconst char\t*token;\n\tint\t\tcount;\n\tchar\tkey[MAX_TOKEN_CHARS];\n\n\tcount = 0;\n\n\twhile ( 1 ) {\n\t\ttoken = Com_Parse( &buf );\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( strcmp( token, \"{\" ) ) {\n\t\t\tCom_Printf( \"Missing { in info file\\n\" );\n\t\t\tbreak;\n\t\t}\n\n\t\tif ( count == max ) {\n\t\t\tCom_Printf( \"Max infos exceeded\\n\" );\n\t\t\tbreak;\n\t\t}\n\n\t\tinfos[count][0] = 0;\n\t\twhile ( 1 ) {\n\t\t\ttoken = Com_Parse( &buf );\n\t\t\tif ( !token[0] ) {\n\t\t\t\tCom_Printf( \"Unexpected end of info file\\n\" );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( !strcmp( token, \"}\" ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tQ_strncpyz( key, token, sizeof( key ) );\n\n\t\t\ttoken = Com_ParseOnLine( &buf );\n\t\t\tif ( !token[0] ) {\n\t\t\t\ttoken = \"<NULL>\";\n\t\t\t}\n\t\t\tInfo_SetValueForKey( infos[count], key, token );\n\t\t}\n\t\tcount++;\n\t}\n\n\treturn count;\n}\n\n\n\n/*\n============================================================================\n\n\t\t\t\t\tLIBRARY REPLACEMENT FUNCTIONS\n\n============================================================================\n*/\n\nint Q_isprint( int c )\n{\n\tif ( c >= 0x20 && c <= 0x7E )\n\t\treturn ( 1 );\n\treturn ( 0 );\n}\n\nint Q_islower( int c )\n{\n\tif (c >= 'a' && c <= 'z')\n\t\treturn ( 1 );\n\treturn ( 0 );\n}\n\nint Q_isupper( int c )\n{\n\tif (c >= 'A' && c <= 'Z')\n\t\treturn ( 1 );\n\treturn ( 0 );\n}\n\nint Q_isalpha( int c )\n{\n\tif ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))\n\t\treturn ( 1 );\n\treturn ( 0 );\n}\n\nchar* Q_strrchr( const char* string, int c )\n{\n\tchar cc = c;\n\tchar *s;\n\tchar *sp=(char *)0;\n\n\ts = (char*)string;\n\n\twhile (*s)\n\t{\n\t\tif (*s == cc)\n\t\t\tsp = s;\n\t\ts++;\n\t}\n\tif (cc == 0)\n\t\tsp = s;\n\n\treturn sp;\n}\n\n/*\n=============\nQ_strncpyz\n \nSafe strncpy that ensures a trailing zero\n=============\n*/\nvoid Q_strncpyz( char *dest, const char *src, int destsize ) {\n\tif ( !src ) {\n\t\tCom_Error( ERR_FATAL, \"Q_strncpyz: NULL src\" );\n\t}\n\tif ( destsize < 1 ) {\n\t\tCom_Error(ERR_FATAL,\"Q_strncpyz: destsize < 1\" ); \n\t}\n\n\tstrncpy( dest, src, destsize-1 );\n    dest[destsize-1] = 0;\n}\n                 \nint Q_stricmpn (const char *s1, const char *s2, int n) {\n\tint\t\tc1, c2;\n\t\n\tdo {\n\t\tc1 = *s1++;\n\t\tc2 = *s2++;\n\n\t\tif (!n--) {\n\t\t\treturn 0;\t\t// strings are equal until end point\n\t\t}\n\t\t\n\t\tif (c1 != c2) {\n\t\t\tif (c1 >= 'a' && c1 <= 'z') {\n\t\t\t\tc1 -= ('a' - 'A');\n\t\t\t}\n\t\t\tif (c2 >= 'a' && c2 <= 'z') {\n\t\t\t\tc2 -= ('a' - 'A');\n\t\t\t}\n\t\t\tif (c1 != c2) {\n\t\t\t\treturn c1 < c2 ? -1 : 1;\n\t\t\t}\n\t\t}\n\t} while (c1);\n\t\n\treturn 0;\t\t// strings are equal\n}\n\nint Q_strncmp (const char *s1, const char *s2, int n) {\n\tint\t\tc1, c2;\n\t\n\tdo {\n\t\tc1 = *s1++;\n\t\tc2 = *s2++;\n\n\t\tif (!n--) {\n\t\t\treturn 0;\t\t// strings are equal until end point\n\t\t}\n\t\t\n\t\tif (c1 != c2) {\n\t\t\treturn c1 < c2 ? -1 : 1;\n\t\t}\n\t} while (c1);\n\t\n\treturn 0;\t\t// strings are equal\n}\n\nint Q_stricmp (const char *s1, const char *s2) {\n\treturn Q_stricmpn (s1, s2, 99999);\n}\n\n\nchar *Q_strlwr( char *s1 ) {\n    char\t*s;\n\n    s = s1;\n\twhile ( *s ) {\n\t\t*s = tolower(*s);\n\t\ts++;\n\t}\n    return s1;\n}\n\nchar *Q_strupr( char *s1 ) {\n    char\t*s;\n\n    s = s1;\n\twhile ( *s ) {\n\t\t*s = toupper(*s);\n\t\ts++;\n\t}\n    return s1;\n}\n\n\n// never goes past bounds or leaves without a terminating 0\nvoid Q_strcat( char *dest, int size, const char *src ) {\n\tint\t\tl1;\n\n\tl1 = strlen( dest );\n\tif ( l1 >= size ) {\n\t\tCom_Error( ERR_FATAL, \"Q_strcat: already overflowed\" );\n\t}\n\tQ_strncpyz( dest + l1, src, size - l1 );\n}\n\n\nint Q_PrintStrlen( const char *string ) {\n\tint\t\t\tlen;\n\tconst char\t*p;\n\n\tif( !string ) {\n\t\treturn 0;\n\t}\n\n\tlen = 0;\n\tp = string;\n\twhile( *p ) {\n\t\tif( Q_IsColorString( p ) ) {\n\t\t\tp += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tp++;\n\t\tlen++;\n\t}\n\n\treturn len;\n}\n\n\nchar *Q_CleanStr( char *string ) {\n\tchar*\td;\n\tchar*\ts;\n\tint\t\tc;\n\n\ts = string;\n\td = string;\n\twhile ((c = *s) != 0 ) {\n\t\tif ( Q_IsColorString( s ) ) {\n\t\t\ts++;\n\t\t}\t\t\n\t\telse if ( c >= 0x20 && c <= 0x7E ) {\n\t\t\t*d++ = c;\n\t\t}\n\t\ts++;\n\t}\n\t*d = '\\0';\n\n\treturn string;\n}\n\n\nvoid QDECL Com_sprintf( char *dest, int size, const char *fmt, ...) {\n\tint\t\tlen;\n\tva_list\t\targptr;\n\tchar\tbigbuffer[32000];\t// big, but small enough to fit in PPC stack\n\n\tva_start (argptr,fmt);\n\tlen = vsprintf (bigbuffer,fmt,argptr);\n\tva_end (argptr);\n\tif ( len >= sizeof( bigbuffer ) ) {\n\t\tCom_Error( ERR_FATAL, \"Com_sprintf: overflowed bigbuffer\" );\n\t}\n\tif (len >= size) {\n\t\tCom_Printf (\"Com_sprintf: overflow of %i in %i\\n\", len, size);\n\t}\n\tQ_strncpyz (dest, bigbuffer, size );\n}\n\n\n/*\n============\nva\n\ndoes a varargs printf into a temp buffer, so I don't need to have\nvarargs versions of all text functions.\nFIXME: make this buffer size safe someday\n============\n*/\nchar\t* QDECL va( char *format, ... ) {\n\tva_list\t\targptr;\n\tstatic char\t\tstring[2][32000];\t// in case va is called by nested functions\n\tstatic int\t\tindex = 0;\n\tchar\t*buf;\n\n\tbuf = string[index & 1];\n\tindex++;\n\n\tva_start (argptr, format);\n\tvsprintf (buf, format,argptr);\n\tva_end (argptr);\n\n\treturn buf;\n}\n\n\n/*\n=====================================================================\n\n  INFO STRINGS\n\n=====================================================================\n*/\n\n/*\n===============\nInfo_ValueForKey\n\nSearches the string for the given\nkey and returns the associated value, or an empty string.\nFIXME: overflow check?\n===============\n*/\nchar *Info_ValueForKey( const char *s, const char *key ) {\n\tchar\tpkey[MAX_INFO_KEY];\n\tstatic\tchar value[2][MAX_INFO_VALUE];\t// use two buffers so compares\n\t\t\t\t\t\t\t\t\t\t\t// work without stomping on each other\n\tstatic\tint\tvalueindex = 0;\n\tchar\t*o;\n\t\n\tif ( !s || !key ) {\n\t\treturn \"\";\n\t}\n\n\tif ( strlen( s ) >= MAX_INFO_STRING ) {\n\t\tCom_Error( ERR_DROP, \"Info_ValueForKey: oversize infostring\" );\n\t}\n\n\tvalueindex ^= 1;\n\tif (*s == '\\\\')\n\t\ts++;\n\twhile (1)\n\t{\n\t\to = pkey;\n\t\twhile (*s != '\\\\')\n\t\t{\n\t\t\tif (!*s)\n\t\t\t\treturn \"\";\n\t\t\t*o++ = *s++;\n\t\t}\n\t\t*o = 0;\n\t\ts++;\n\n\t\to = value[valueindex];\n\n\t\twhile (*s != '\\\\' && *s)\n\t\t{\n\t\t\t*o++ = *s++;\n\t\t}\n\t\t*o = 0;\n\n\t\tif (!Q_stricmp (key, pkey) )\n\t\t\treturn value[valueindex];\n\n\t\tif (!*s)\n\t\t\tbreak;\n\t\ts++;\n\t}\n\n\treturn \"\";\n}\n\n\n/*\n===================\nInfo_NextPair\n\nUsed to itterate through all the key/value pairs in an info string\n===================\n*/\nvoid Info_NextPair( const char *(*head), char key[MAX_INFO_KEY], char value[MAX_INFO_VALUE] ) {\n\tchar\t*o;\n\tconst char\t*s;\n\n\ts = *head;\n\n\tif ( *s == '\\\\' ) {\n\t\ts++;\n\t}\n\tkey[0] = 0;\n\tvalue[0] = 0;\n\n\to = key;\n\twhile ( *s != '\\\\' ) {\n\t\tif ( !*s ) {\n\t\t\t*o = 0;\n\t\t\t*head = s;\n\t\t\treturn;\n\t\t}\n\t\t*o++ = *s++;\n\t}\n\t*o = 0;\n\ts++;\n\n\to = value;\n\twhile ( *s != '\\\\' && *s ) {\n\t\t*o++ = *s++;\n\t}\n\t*o = 0;\n\n\t*head = s;\n}\n\n\n/*\n===================\nInfo_RemoveKey\n===================\n*/\nvoid Info_RemoveKey( char *s, const char *key ) {\n\tchar\t*start;\n\tchar\tpkey[MAX_INFO_KEY];\n\tchar\tvalue[MAX_INFO_VALUE];\n\tchar\t*o;\n\n\tif ( strlen( s ) >= MAX_INFO_STRING ) {\n\t\tCom_Error( ERR_DROP, \"Info_RemoveKey: oversize infostring\" );\n\t}\n\n\tif (strchr (key, '\\\\')) {\n\t\treturn;\n\t}\n\n\twhile (1)\n\t{\n\t\tstart = s;\n\t\tif (*s == '\\\\')\n\t\t\ts++;\n\t\to = pkey;\n\t\twhile (*s != '\\\\')\n\t\t{\n\t\t\tif (!*s)\n\t\t\t\treturn;\n\t\t\t*o++ = *s++;\n\t\t}\n\t\t*o = 0;\n\t\ts++;\n\n\t\to = value;\n\t\twhile (*s != '\\\\' && *s)\n\t\t{\n\t\t\tif (!*s)\n\t\t\t\treturn;\n\t\t\t*o++ = *s++;\n\t\t}\n\t\t*o = 0;\n\n\t\tif (!strcmp (key, pkey) )\n\t\t{\n\t\t\tstrcpy (start, s);\t// remove this part\n\t\t\treturn;\n\t\t}\n\n\t\tif (!*s)\n\t\t\treturn;\n\t}\n\n}\n\n\n/*\n==================\nInfo_Validate\n\nSome characters are illegal in info strings because they\ncan mess up the server's parsing\n==================\n*/\nqboolean Info_Validate( const char *s ) {\n\tif ( strchr( s, '\\\"' ) ) {\n\t\treturn qfalse;\n\t}\n\tif ( strchr( s, ';' ) ) {\n\t\treturn qfalse;\n\t}\n\treturn qtrue;\n}\n\n/*\n==================\nInfo_SetValueForKey\n\nChanges or adds a key/value pair\n==================\n*/\nvoid Info_SetValueForKey( char *s, const char *key, const char *value ) {\n\tchar\tnewi[MAX_INFO_STRING];\n\n\tif ( strlen( s ) >= MAX_INFO_STRING ) {\n\t\tCom_Error( ERR_DROP, \"Info_SetValueForKey: oversize infostring\" );\n\t}\n\n\tif (strchr (key, '\\\\') || strchr (value, '\\\\'))\n\t{\n\t\tCom_Printf (\"Can't use keys or values with a \\\\\\n\");\n\t\treturn;\n\t}\n\n\tif (strchr (key, ';') || strchr (value, ';'))\n\t{\n\t\tCom_Printf (\"Can't use keys or values with a semicolon\\n\");\n\t\treturn;\n\t}\n\n\tif (strchr (key, '\\\"') || strchr (value, '\\\"'))\n\t{\n\t\tCom_Printf (\"Can't use keys or values with a \\\"\\n\");\n\t\treturn;\n\t}\n\n\tInfo_RemoveKey (s, key);\n\tif (!value || !strlen(value))\n\t\treturn;\n\n\tCom_sprintf (newi, sizeof(newi), \"\\\\%s\\\\%s\", key, value);\n\n\tif (strlen(newi) + strlen(s) > MAX_INFO_STRING)\n\t{\n\t\tCom_Printf (\"Info string length exceeded\\n\");\n\t\treturn;\n\t}\n\n\tstrcat (s, newi);\n}\n\n//====================================================================\n\n\n/*\n===============\nParseHex\n===============\n*/\nint\tParseHex( const char *text ) {\n\tint\t\tvalue;\n\tint\t\tc;\n\n\tvalue = 0;\n\twhile ( ( c = *text++ ) != 0 ) {\n\t\tif ( c >= '0' && c <= '9' ) {\n\t\t\tvalue = value * 16 + c - '0';\n\t\t\tcontinue;\n\t\t}\n\t\tif ( c >= 'a' && c <= 'f' ) {\n\t\t\tvalue = value * 16 + 10 + c - 'a';\n\t\t\tcontinue;\n\t\t}\n\t\tif ( c >= 'A' && c <= 'F' ) {\n\t\t\tvalue = value * 16 + 10 + c - 'A';\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\treturn value;\n}\n"
  },
  {
    "path": "q3radiant/splines/q_shared.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __Q_SHARED_H\n#define __Q_SHARED_H\n\n// q_shared.h -- included first by ALL program modules.\n// these are the definitions that have no dependance on\n// central system services, and can be used by any part\n// of the program without any state issues.\n\n// A user mod should never modify this file\n\n#define\tQ3_VERSION\t\t\"DOOM 0.01\"\n\n// alignment macros for SIMD\n#define\tALIGN_ON\n#define\tALIGN_OFF\n\n#ifdef _WIN32\n\n#pragma warning(disable : 4018)     // signed/unsigned mismatch\n#pragma warning(disable : 4032)\n#pragma warning(disable : 4051)\n#pragma warning(disable : 4057)\t\t// slightly different base types\n#pragma warning(disable : 4100)\t\t// unreferenced formal parameter\n#pragma warning(disable : 4115)\n#pragma warning(disable : 4125)\t\t// decimal digit terminates octal escape sequence\n#pragma warning(disable : 4127)\t\t// conditional expression is constant\n#pragma warning(disable : 4136)\n#pragma warning(disable : 4201)\n#pragma warning(disable : 4214)\n#pragma warning(disable : 4244)\n#pragma warning(disable : 4305)\t\t// truncation from const double to float\n#pragma warning(disable : 4310)\t\t// cast truncates constant value\n#pragma warning(disable : 4514)\n#pragma warning(disable : 4711)\t\t// selected for automatic inline expansion\n#pragma warning(disable : 4220)\t\t// varargs matches remaining parameters\n\n#endif\n\n#include <assert.h>\n#include <math.h>\n#include <stdio.h>\n#include <stdarg.h>\n#include <string.h>\n#include <stdlib.h>\n#include <time.h>\n#include <ctype.h>\n#ifdef WIN32\t\t\t\t// mac doesn't have malloc.h\n#include <malloc.h>\t\t\t// for _alloca()\n#endif\n#ifdef _WIN32\n\n//#pragma intrinsic( memset, memcpy )\n\n#endif\n\n\n// this is the define for determining if we have an asm version of a C function\n#if (defined _M_IX86 || defined __i386__) && !defined __sun__  && !defined __LCC__\n#define id386\t1\n#else\n#define id386\t0\n#endif\n\n// for windows fastcall option\n\n#define\tQDECL\n\n//======================= WIN32 DEFINES =================================\n\n#ifdef WIN32\n\n#define\tMAC_STATIC\n\n#undef QDECL\n#define\tQDECL\t__cdecl\n\n// buildstring will be incorporated into the version string\n#ifdef NDEBUG\n#ifdef _M_IX86\n#define\tCPUSTRING\t\"win-x86\"\n#elif defined _M_ALPHA\n#define\tCPUSTRING\t\"win-AXP\"\n#endif\n#else\n#ifdef _M_IX86\n#define\tCPUSTRING\t\"win-x86-debug\"\n#elif defined _M_ALPHA\n#define\tCPUSTRING\t\"win-AXP-debug\"\n#endif\n#endif\n\n\n#define\tPATH_SEP '\\\\'\n\n#endif\n\n//======================= MAC OS X SERVER DEFINES =====================\n\n#if defined(__MACH__) && defined(__APPLE__)\n\n#define MAC_STATIC\n\n#ifdef __ppc__\n#define CPUSTRING\t\"MacOSXS-ppc\"\n#elif defined __i386__\n#define CPUSTRING\t\"MacOSXS-i386\"\n#else\n#define CPUSTRING\t\"MacOSXS-other\"\n#endif\n\n#define\tPATH_SEP\t'/'\n\n#define\tGAME_HARD_LINKED\n#define\tCGAME_HARD_LINKED\n#define\tUI_HARD_LINKED\n#define _alloca alloca\n\n#undef ALIGN_ON\n#undef ALIGN_OFF\n#define\tALIGN_ON\t\t#pragma align(16)\n#define\tALIGN_OFF\t\t#pragma align()\n\n#ifdef __cplusplus\n\textern \"C\" {\n#endif\n\nvoid *osxAllocateMemory(long size);\nvoid osxFreeMemory(void *pointer);\n\n#ifdef __cplusplus\n        }\n#endif\n\n#endif\n\n//======================= MAC DEFINES =================================\n\n#ifdef __MACOS__\n\n#define\tMAC_STATIC static\n\n#define\tCPUSTRING\t\"MacOS-PPC\"\n\n#define\tPATH_SEP ':'\n\nvoid Sys_PumpEvents( void );\n\n#endif\n\n#ifdef __MRC__\n\n#define\tMAC_STATIC\n\n#define\tCPUSTRING\t\"MacOS-PPC\"\n\n#define\tPATH_SEP ':'\n\nvoid Sys_PumpEvents( void );\n\n#undef QDECL\n#define\tQDECL\t__cdecl\n\n#define _alloca alloca\n#endif\n\n//======================= LINUX DEFINES =================================\n\n// the mac compiler can't handle >32k of locals, so we\n// just waste space and make big arrays static...\n#ifdef __linux__\n\n#define\tMAC_STATIC\n\n#ifdef __i386__\n#define\tCPUSTRING\t\"linux-i386\"\n#elif defined __axp__\n#define\tCPUSTRING\t\"linux-alpha\"\n#else\n#define\tCPUSTRING\t\"linux-other\"\n#endif\n\n#define\tPATH_SEP '/'\n\n#endif\n\n//=============================================================\n\n\n  \ntypedef enum {qfalse, qtrue}\tqboolean;\n\ntypedef unsigned char \t\tbyte;\n\n#define\tEQUAL_EPSILON\t0.001\n\ntypedef int\t\tqhandle_t;\ntypedef int\t\tsfxHandle_t;\ntypedef int\t\tfileHandle_t;\ntypedef int\t\tclipHandle_t;\n\ntypedef enum {\n\tINVALID_JOINT = -1\n} jointHandle_t;\n\n#ifndef NULL\n#define NULL ((void *)0)\n#endif\n\n#define\tMAX_QINT\t\t\t0x7fffffff\n#define\tMIN_QINT\t\t\t(-MAX_QINT-1)\n\n#ifndef max\n#define max( x, y ) ( ( ( x ) > ( y ) ) ? ( x ) : ( y ) )\n#define min( x, y ) ( ( ( x ) < ( y ) ) ? ( x ) : ( y ) )\n#endif\n\n#ifndef sign\n#define sign( f )\t( ( f > 0 ) ? 1 : ( ( f < 0 ) ? -1 : 0 ) )\n#endif\n\n// angle indexes\n#define\tPITCH\t\t\t\t0\t\t// up / down\n#define\tYAW\t\t\t\t\t1\t\t// left / right\n#define\tROLL\t\t\t\t2\t\t// fall over\n\n// the game guarantees that no string from the network will ever\n// exceed MAX_STRING_CHARS\n#define\tMAX_STRING_CHARS\t1024\t// max length of a string passed to Cmd_TokenizeString\n#define\tMAX_STRING_TOKENS\t256\t\t// max tokens resulting from Cmd_TokenizeString\n#define\tMAX_TOKEN_CHARS\t\t1024\t// max length of an individual token\n\n#define\tMAX_INFO_STRING\t\t1024\n#define\tMAX_INFO_KEY\t\t1024\n#define\tMAX_INFO_VALUE\t\t1024\n\n\n#define\tMAX_QPATH\t\t\t64\t\t// max length of a quake game pathname\n#define\tMAX_OSPATH\t\t\t128\t\t// max length of a filesystem pathname\n\n#define\tMAX_NAME_LENGTH\t\t32\t\t// max length of a client name\n\n// paramters for command buffer stuffing\ntypedef enum {\n\tEXEC_NOW,\t\t\t// don't return until completed, a VM should NEVER use this,\n\t\t\t\t\t\t// because some commands might cause the VM to be unloaded...\n\tEXEC_INSERT,\t\t// insert at current position, but don't run yet\n\tEXEC_APPEND\t\t\t// add to end of the command buffer (normal case)\n} cbufExec_t;\n\n\n//\n// these aren't needed by any of the VMs.  put in another header?\n//\n#define\tMAX_MAP_AREA_BYTES\t\t32\t\t// bit vector of area visibility\n\n#undef ERR_FATAL\t\t\t\t\t\t// malloc.h on unix\n\n// parameters to the main Error routine\ntypedef enum {\n\tERR_NONE,\n\tERR_FATAL,\t\t\t\t\t// exit the entire game with a popup window\n\tERR_DROP,\t\t\t\t\t// print to console and disconnect from game\n\tERR_DISCONNECT,\t\t\t\t// don't kill server\n\tERR_NEED_CD\t\t\t\t\t// pop up the need-cd dialog\n} errorParm_t;\n\n\n// font rendering values used by ui and cgame\n\n#define PROP_GAP_WIDTH\t\t\t3\n#define PROP_SPACE_WIDTH\t\t8\n#define PROP_HEIGHT\t\t\t\t27\n#define PROP_SMALL_SIZE_SCALE\t0.75\n\n#define BLINK_DIVISOR\t\t\t200\n#define PULSE_DIVISOR\t\t\t75\n\n#define UI_LEFT\t\t\t0x00000000\t// default\n#define UI_CENTER\t\t0x00000001\n#define UI_RIGHT\t\t0x00000002\n#define UI_FORMATMASK\t0x00000007\n#define UI_SMALLFONT\t0x00000010\n#define UI_BIGFONT\t\t0x00000020\t// default\n#define UI_GIANTFONT\t0x00000040\n#define UI_DROPSHADOW\t0x00000800\n#define UI_BLINK\t\t0x00001000\n#define UI_INVERSE\t\t0x00002000\n#define UI_PULSE\t\t0x00004000\n\n\n/*\n==============================================================\n\nMATHLIB\n\n==============================================================\n*/\n#ifdef __cplusplus\t\t\t// so we can include this in C code\n#define\tSIDE_FRONT\t\t0\n#define\tSIDE_BACK\t\t1\n#define\tSIDE_ON\t\t\t2\n#define\tSIDE_CROSS\t\t3\n\n#define\tQ_PI\t3.14159265358979323846\n#ifndef M_PI\n#define M_PI\t\t3.14159265358979323846\t// matches value in gcc v2 math.h\n#endif\n\n#include \"math_vector.h\"\n#include \"math_angles.h\"\n#include \"math_matrix.h\"\n#include \"math_quaternion.h\"\n\nclass idVec3_t;\t\t\t\t\t\t// for defining vectors\ntypedef idVec3_t &vec3_p;\t\t\t\t// for passing vectors as function arguments\ntypedef const idVec3_t &vec3_c;\t\t// for passing vectors as const function arguments\n\t\t\t\t\t\t\t\t\t\nclass angles_t;\t\t\t\t\t\t// for defining angle vectors\ntypedef angles_t &angles_p;\t\t\t// for passing angles as function arguments\ntypedef const angles_t &angles_c;\t// for passing angles as const function arguments\n\nclass mat3_t;\t\t\t\t\t\t// for defining matrices\ntypedef mat3_t &mat3_p;\t\t\t\t// for passing matrices as function arguments\ntypedef const mat3_t &mat3_c;\t\t// for passing matrices as const function arguments\n\n\n\n#define NUMVERTEXNORMALS\t162\nextern\tidVec3_t\tbytedirs[NUMVERTEXNORMALS];\n\n// all drawing is done to a 640*480 virtual screen size\n// and will be automatically scaled to the real resolution\n#define\tSCREEN_WIDTH\t\t640\n#define\tSCREEN_HEIGHT\t\t480\n\n#define TINYCHAR_WIDTH\t\t(SMALLCHAR_WIDTH)\n#define TINYCHAR_HEIGHT\t\t(SMALLCHAR_HEIGHT/2)\n\n#define SMALLCHAR_WIDTH\t\t8\n#define SMALLCHAR_HEIGHT\t16\n\n#define BIGCHAR_WIDTH\t\t16\n#define BIGCHAR_HEIGHT\t\t16\n\n#define\tGIANTCHAR_WIDTH\t\t32\n#define\tGIANTCHAR_HEIGHT\t48\n\nextern\tvec4_t\t\tcolorBlack;\nextern\tvec4_t\t\tcolorRed;\nextern\tvec4_t\t\tcolorGreen;\nextern\tvec4_t\t\tcolorBlue;\nextern\tvec4_t\t\tcolorYellow;\nextern\tvec4_t\t\tcolorMagenta;\nextern\tvec4_t\t\tcolorCyan;\nextern\tvec4_t\t\tcolorWhite;\nextern\tvec4_t\t\tcolorLtGrey;\nextern\tvec4_t\t\tcolorMdGrey;\nextern\tvec4_t\t\tcolorDkGrey;\n\n#define Q_COLOR_ESCAPE\t'^'\n#define Q_IsColorString(p)\t( p && *(p) == Q_COLOR_ESCAPE && *((p)+1) && *((p)+1) != Q_COLOR_ESCAPE )\n\n#define COLOR_BLACK\t\t'0'\n#define COLOR_RED\t\t'1'\n#define COLOR_GREEN\t\t'2'\n#define COLOR_YELLOW\t'3'\n#define COLOR_BLUE\t\t'4'\n#define COLOR_CYAN\t\t'5'\n#define COLOR_MAGENTA\t'6'\n#define COLOR_WHITE\t\t'7'\n#define ColorIndex(c)\t( ( (c) - '0' ) & 7 )\n\n#define S_COLOR_BLACK\t\"^0\"\n#define S_COLOR_RED\t\t\"^1\"\n#define S_COLOR_GREEN\t\"^2\"\n#define S_COLOR_YELLOW\t\"^3\"\n#define S_COLOR_BLUE\t\"^4\"\n#define S_COLOR_CYAN\t\"^5\"\n#define S_COLOR_MAGENTA\t\"^6\"\n#define S_COLOR_WHITE\t\"^7\"\n\nextern vec4_t\tg_color_table[8];\n\n#define\tMAKERGB( v, r, g, b ) v[0]=r;v[1]=g;v[2]=b\n#define\tMAKERGBA( v, r, g, b, a ) v[0]=r;v[1]=g;v[2]=b;v[3]=a\n\n#define DEG2RAD( a ) ( ( (a) * M_PI ) / 180.0F )\n#define RAD2DEG( a ) ( ( (a) * 180.0f ) / M_PI )\n\nstruct cplane_s;\n\nextern\tidVec3_t\tvec3_origin;\nextern\tvec4_t\tvec4_origin;\nextern\tmat3_t\taxisDefault;\n\n#define\tnanmask (255<<23)\n\n#define\tIS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)\n\nfloat Q_fabs( float f );\nfloat Q_rsqrt( float f );\t\t// reciprocal square root\n\n#define SQRTFAST( x ) ( 1.0f / Q_rsqrt( x ) )\n\nsigned char ClampChar( int i );\nsigned short ClampShort( int i );\n\n// this isn't a real cheap function to call!\nint DirToByte( const idVec3_t &dir );\nvoid ByteToDir( int b, vec3_p dir );\n\n#define DotProduct(a,b)\t\t\t((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2])\n#define VectorSubtract(a,b,c)\t((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2])\n#define VectorAdd(a,b,c)\t\t((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2])\n#define VectorCopy(a,b)\t\t\t((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2])\n//#define VectorCopy(a,b)\t\t\t((b).x=(a).x,(b).y=(a).y,(b).z=(a).z])\n\n#define\tVectorScale(v, s, o)\t((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s))\n#define\tVectorMA(v, s, b, o)\t((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s))\n#define CrossProduct(a,b,c)\t\t((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])\n\n#define DotProduct4(x,y)\t\t((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]+(x)[3]*(y)[3])\n#define VectorSubtract4(a,b,c)\t((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2],(c)[3]=(a)[3]-(b)[3])\n#define VectorAdd4(a,b,c)\t\t((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2],(c)[3]=(a)[3]+(b)[3])\n#define VectorCopy4(a,b)\t\t((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])\n#define\tVectorScale4(v, s, o)\t((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s),(o)[3]=(v)[3]*(s))\n#define\tVectorMA4(v, s, b, o)\t((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))\n\n\n#define VectorClear(a)\t\t\t((a)[0]=(a)[1]=(a)[2]=0)\n#define VectorNegate(a,b)\t\t((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2])\n#define VectorSet(v, x, y, z)\t((v)[0]=(x), (v)[1]=(y), (v)[2]=(z))\n#define Vector4Copy(a,b)\t\t((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])\n\n#define\tSnapVector(v) {v[0]=(int)v[0];v[1]=(int)v[1];v[2]=(int)v[2];}\n\nfloat NormalizeColor( vec3_c in, vec3_p out );\n\nint VectorCompare( vec3_c v1, vec3_c v2 );\nfloat VectorLength( vec3_c v );\nfloat Distance( vec3_c p1, vec3_c p2 );\nfloat DistanceSquared( vec3_c p1, vec3_c p2 );\nfloat VectorNormalize (vec3_p v);\t\t// returns vector length\nvoid VectorNormalizeFast(vec3_p v);\t\t// does NOT return vector length, uses rsqrt approximation\nfloat VectorNormalize2( vec3_c v, vec3_p out );\nvoid VectorInverse (vec3_p v);\nvoid VectorRotate( vec3_c in, mat3_c matrix, vec3_p out );\nvoid VectorPolar(vec3_p v, float radius, float theta, float phi);\nvoid VectorSnap(vec3_p v);\nvoid Vector53Copy( const idVec5_t &in, vec3_p out);\nvoid Vector5Scale( const idVec5_t &v, float scale, idVec5_t &out);\nvoid Vector5Add( const idVec5_t &va, const idVec5_t &vb, idVec5_t &out);\nvoid VectorRotate3( vec3_c vIn, vec3_c vRotation, vec3_p out);\nvoid VectorRotate3Origin(vec3_c vIn, vec3_c vRotation, vec3_c vOrigin, vec3_p out);\n\n\nint Q_log2(int val);\n\nint\t\tQ_rand( int *seed );\nfloat\tQ_random( int *seed );\nfloat\tQ_crandom( int *seed );\n\n#define random()\t((rand () & 0x7fff) / ((float)0x7fff))\n#define crandom()\t(2.0 * (random() - 0.5))\n\nfloat Q_rint( float in );\n\nvoid vectoangles( vec3_c value1, angles_p angles);\nvoid AnglesToAxis( angles_c angles, mat3_p axis );\n\nvoid AxisCopy( mat3_c in, mat3_p out );\nqboolean AxisRotated( mat3_c in );\t\t\t// assumes a non-degenerate axis\n\nint SignbitsForNormal( vec3_c normal );\nint BoxOnPlaneSide( const Bounds &b, struct cplane_s *p );\n\nfloat\tAngleMod(float a);\nfloat\tLerpAngle (float from, float to, float frac);\nfloat\tAngleSubtract( float a1, float a2 );\nvoid\tAnglesSubtract( angles_c v1, angles_c v2, angles_p v3 );\n\nfloat AngleNormalize360 ( float angle );\nfloat AngleNormalize180 ( float angle );\nfloat AngleDelta ( float angle1, float angle2 );\n\nqboolean PlaneFromPoints( vec4_t &plane, vec3_c a, vec3_c b, vec3_c c );\nvoid ProjectPointOnPlane( vec3_p dst, vec3_c p, vec3_c normal );\nvoid RotatePointAroundVector( vec3_p dst, vec3_c dir, vec3_c point, float degrees );\nvoid RotateAroundDirection( mat3_p axis, float yaw );\nvoid MakeNormalVectors( vec3_c forward, vec3_p right, vec3_p up );\n// perpendicular vector could be replaced by this\n\nint\tPlaneTypeForNormal( vec3_c normal );\n\nvoid MatrixMultiply( mat3_c in1, mat3_c in2, mat3_p out );\nvoid MatrixInverseMultiply( mat3_c in1, mat3_c in2, mat3_p out );\t// in2 is transposed during multiply\nvoid MatrixTransformVector( vec3_c in, mat3_c matrix, vec3_p out );\nvoid MatrixProjectVector( vec3_c in, mat3_c matrix, vec3_p out ); // Places the vector into a new coordinate system.\nvoid AngleVectors( angles_c angles, vec3_p forward, vec3_p right, vec3_p up);\nvoid PerpendicularVector( vec3_p dst, vec3_c src );\n\nfloat TriangleArea( vec3_c a, vec3_c b, vec3_c c );\n#endif\t\t\t\t\t\t\t\t\t\t// __cplusplus\n\n//=============================================\n\nfloat Com_Clamp( float min, float max, float value );\n\n#define FILE_HASH_SIZE\t\t1024\nint Com_HashString( const char *fname );\n\nchar\t*Com_SkipPath( char *pathname );\n\n// it is ok for out == in\nvoid\tCom_StripExtension( const char *in, char *out );\n\n// \"extension\" should include the dot: \".map\"\nvoid\tCom_DefaultExtension( char *path, int maxSize, const char *extension );\n\nint\t\tCom_ParseInfos( const char *buf, int max, char infos[][MAX_INFO_STRING] );\n\n/*\n=====================================================================================\n\nSCRIPT PARSING\n\n=====================================================================================\n*/\n\n// this just controls the comment printing, it doesn't actually load a file\nvoid Com_BeginParseSession( const char *filename );\nvoid Com_EndParseSession( void );\n\nint Com_GetCurrentParseLine( void );\n\n// Will never return NULL, just empty strings.\n// An empty string will only be returned at end of file.\n// ParseOnLine will return empty if there isn't another token on this line\n\n// this funny typedef just means a moving pointer into a const char * buffer\nconst char *Com_Parse( const char *(*data_p) );\nconst char *Com_ParseOnLine( const char *(*data_p) );\nconst char *Com_ParseRestOfLine( const char *(*data_p) );\n\nvoid Com_UngetToken( void );\n\n#ifdef __cplusplus\nvoid Com_MatchToken( const char *(*buf_p), const char *match, qboolean warning = qfalse );\n#else\nvoid Com_MatchToken( const char *(*buf_p), const char *match, qboolean warning );\n#endif\n\nvoid Com_ScriptError( const char *msg, ... );\nvoid Com_ScriptWarning( const char *msg, ... );\n\nvoid Com_SkipBracedSection( const char *(*program) );\nvoid Com_SkipRestOfLine( const char *(*data) );\n\nfloat Com_ParseFloat( const char *(*buf_p) );\nint\tCom_ParseInt( const char *(*buf_p) );\n\nvoid Com_Parse1DMatrix( const char *(*buf_p), int x, float *m );\nvoid Com_Parse2DMatrix( const char *(*buf_p), int y, int x, float *m );\nvoid Com_Parse3DMatrix( const char *(*buf_p), int z, int y, int x, float *m );\n\n//=====================================================================================\n#ifdef __cplusplus\n\textern \"C\" {\n#endif\n\nvoid\tQDECL Com_sprintf (char *dest, int size, const char *fmt, ...);\n\n\n// mode parm for FS_FOpenFile\ntypedef enum {\n\tFS_READ,\n\tFS_WRITE,\n\tFS_APPEND,\n\tFS_APPEND_SYNC\n} fsMode_t;\n\ntypedef enum {\n\tFS_SEEK_CUR,\n\tFS_SEEK_END,\n\tFS_SEEK_SET\n} fsOrigin_t;\n\n//=============================================\n\nint Q_isprint( int c );\nint Q_islower( int c );\nint Q_isupper( int c );\nint Q_isalpha( int c );\n\n// portable case insensitive compare\nint\t\tQ_stricmp (const char *s1, const char *s2);\nint\t\tQ_strncmp (const char *s1, const char *s2, int n);\nint\t\tQ_stricmpn (const char *s1, const char *s2, int n);\nchar\t*Q_strlwr( char *s1 );\nchar\t*Q_strupr( char *s1 );\nchar\t*Q_strrchr( const char* string, int c );\n\n// buffer size safe library replacements\nvoid\tQ_strncpyz( char *dest, const char *src, int destsize );\nvoid\tQ_strcat( char *dest, int size, const char *src );\n\n// strlen that discounts Quake color sequences\nint Q_PrintStrlen( const char *string );\n// removes color sequences from string\nchar *Q_CleanStr( char *string );\n\nint\t\t\tCom_Filter( const char *filter, const char *name, int casesensitive );\nconst char *Com_StringContains( const char *str1, const char *str2, int casesensitive );\n\n\n//=============================================\n\nshort\tBigShort(short l);\nshort\tLittleShort(short l);\nint\t\tBigLong (int l);\nint\t\tLittleLong (int l);\nfloat\tBigFloat (float l);\nfloat\tLittleFloat (float l);\n\nvoid\tSwap_Init (void);\nchar\t* QDECL va(char *format, ...);\n\n#ifdef __cplusplus\n    }\n#endif\n\n\n//=============================================\n#ifdef __cplusplus\n//\n// mapfile parsing\n//\ntypedef struct ePair_s {\n\tchar\t*key;\n\tchar\t*value;\n} ePair_t;\n\ntypedef struct mapSide_s {\n\tchar\t\tmaterial[MAX_QPATH];\n\tvec4_t\t\tplane;\n\tvec4_t\t\ttextureVectors[2];\n} mapSide_t;\n\ntypedef struct {\n\tint\t\t\tnumSides;\n\tmapSide_t\t**sides;\n} mapBrush_t;\n\ntypedef struct {\n\tidVec3_t\t\txyz;\n\tfloat\t\tst[2];\n} patchVertex_t;\n\ntypedef struct {\n\tchar\t\tmaterial[MAX_QPATH];\n\tint\t\t\twidth, height;\n\tpatchVertex_t\t*patchVerts;\n} mapPatch_t;\n\ntypedef struct {\n\tchar\t\tmodelName[MAX_QPATH];\n\tfloat\t\tmatrix[16];\n} mapModel_t;\n\ntypedef struct mapPrimitive_s {\n\tint\t\t\t\tnumEpairs;\n\tePair_t\t\t\t**ePairs;\n\n\t// only one of these will be non-NULL\n\tmapBrush_t\t\t*brush;\n\tmapPatch_t\t\t*patch;\n\tmapModel_t\t\t*model;\n} mapPrimitive_t;\n\ntypedef struct mapEntity_s {\n\tint\t\t\t\tnumPrimitives;\n\tmapPrimitive_t\t**primitives;\n\n\tint\t\t\t\tnumEpairs;\n\tePair_t\t\t\t**ePairs;\n} mapEntity_t;\n\ntypedef struct {\n\tint\t\t\t\tnumEntities;\n\tmapEntity_t\t\t**entities;\n} mapFile_t;\n\n\n// the order of entities, brushes, and sides will be maintained, the\n// lists won't be swapped on each load or save\nmapFile_t *ParseMapFile( const char *text );\nvoid FreeMapFile( mapFile_t *mapFile );\nvoid WriteMapFile( const mapFile_t *mapFile, FILE *f );\n\n// key names are case-insensitive\nconst char \t*ValueForMapEntityKey( const mapEntity_t *ent, const char *key );\nfloat\tFloatForMapEntityKey( const mapEntity_t *ent, const char *key );\nqboolean \tGetVectorForMapEntityKey( const mapEntity_t *ent, const char *key, idVec3_t &vec );\n\ntypedef struct {\n\tidVec3_t\t\txyz;\n\tidVec2_t\t\tst;\n\tidVec3_t\t\tnormal;\n\tidVec3_t\t\ttangents[2];\n\tbyte\t\tsmoothing[4];\t\t// colors for silhouette smoothing\n} drawVert_t;\n\ntypedef struct {\n\tint\t\t\twidth, height;\n\tdrawVert_t\t*verts;\n} drawVertMesh_t;\n\n// Tesselate a map patch into smoothed, drawable vertexes\n// MaxError of around 4 is reasonable\ndrawVertMesh_t *SubdivideMapPatch( const mapPatch_t *patch, float maxError );\n#endif\t\t\t// __cplusplus\n\n//=========================================\n\n#ifdef __cplusplus\n\textern \"C\" {\n#endif\n\nvoid\tQDECL Com_Error( int level, const char *error, ... );\nvoid\tQDECL Com_Printf( const char *msg, ... );\nvoid\tQDECL Com_DPrintf( const char *msg, ... );\n\n#ifdef __cplusplus\n\t}\n#endif\n\n\ntypedef struct {\n\tqboolean\tframeMemory;\n\tint\t\tcurrentElements;\n\tint\t\tmaxElements;\t\t// will reallocate and move when exceeded\n\tvoid\t**elements;\n} growList_t;\n\n// you don't need to init the growlist if you don't mind it growing and moving\n// the list as it expands\nvoid\t\tCom_InitGrowList( growList_t *list, int maxElements );\nint\t\t\tCom_AddToGrowList( growList_t *list, void *data );\nvoid\t\t*Com_GrowListElement( const growList_t *list, int index );\nint\t\t\tCom_IndexForGrowListElement( const growList_t *list, const void *element );\n\n\n//\n// key / value info strings\n//\nchar *Info_ValueForKey( const char *s, const char *key );\nvoid Info_RemoveKey( char *s, const char *key );\nvoid Info_SetValueForKey( char *s, const char *key, const char *value );\nqboolean Info_Validate( const char *s );\nvoid Info_NextPair( const char *(*s), char key[MAX_INFO_KEY], char value[MAX_INFO_VALUE] );\n\n// get cvar defs, collision defs, etc\n//#include \"../shared/interface.h\"\n\n// get key code numbers for events\n//#include \"../shared/keycodes.h\"\n\n#ifdef __cplusplus\n// get the polygon winding functions\n//#include \"../shared/windings.h\"\n\n// get the flags class\n//#include \"../shared/idflags.h\"\n#endif\t// __cplusplus\n\n#endif\t// __Q_SHARED_H\n\n"
  },
  {
    "path": "q3radiant/splines/splines.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n//#include \"stdafx.h\"\n//#include \"qe3.h\"\n\n#include \"q_shared.h\"\n#include \"splines.h\"\n\nextern \"C\" {\nint FS_Write( const void *buffer, int len, fileHandle_t h );\nint FS_ReadFile( const char *qpath, void **buffer );\nvoid FS_FreeFile( void *buffer );\nfileHandle_t FS_FOpenFileWrite( const char *filename );\nvoid FS_FCloseFile( fileHandle_t f );\n}\n\nfloat Q_fabs( float f ) {\n\tint tmp = * ( int * ) &f;\n\ttmp &= 0x7FFFFFFF;\n\treturn * ( float * ) &tmp;\n}\n\n\n//#include \"../shared/windings.h\"\n//#include \"../qcommon/qcommon.h\"\n//#include \"../sys/sys_public.h\"\n//#include \"../game/game_entity.h\"\n\nidCameraDef splineList;\nidCameraDef *g_splineList = &splineList;\n\nidVec3_t idSplineList::zero(0,0,0);\n\nvoid glLabeledPoint(idVec3_t &color, idVec3_t &point, float size, const char *label) {\n\tqglColor3fv(color);\n\tqglPointSize(size);\n\tqglBegin(GL_POINTS);\n\tqglVertex3fv(point);\n\tqglEnd();\n\tidVec3_t v = point;\n\tv.x += 1;\n\tv.y += 1;\n\tv.z += 1;\n\tqglRasterPos3fv (v);\n\tqglCallLists (strlen(label), GL_UNSIGNED_BYTE, label);\n}\n\n\nvoid glBox(idVec3_t &color, idVec3_t &point, float size) {\n\tidVec3_t mins(point);\n\tidVec3_t maxs(point);\n\tmins[0] -= size;\n\tmins[1] += size;\n\tmins[2] -= size;\n\tmaxs[0] += size;\n\tmaxs[1] -= size;\n\tmaxs[2] += size;\n\tqglColor3fv(color);\n\tqglBegin(GL_LINE_LOOP);\n\tqglVertex3f(mins[0],mins[1],mins[2]);\n\tqglVertex3f(maxs[0],mins[1],mins[2]);\n\tqglVertex3f(maxs[0],maxs[1],mins[2]);\n\tqglVertex3f(mins[0],maxs[1],mins[2]);\n\tqglEnd();\n\tqglBegin(GL_LINE_LOOP);\n\tqglVertex3f(mins[0],mins[1],maxs[2]);\n\tqglVertex3f(maxs[0],mins[1],maxs[2]);\n\tqglVertex3f(maxs[0],maxs[1],maxs[2]);\n\tqglVertex3f(mins[0],maxs[1],maxs[2]);\n\tqglEnd();\n\n\tqglBegin(GL_LINES);\n  \tqglVertex3f(mins[0],mins[1],mins[2]);\n\tqglVertex3f(mins[0],mins[1],maxs[2]);\n\tqglVertex3f(mins[0],maxs[1],maxs[2]);\n\tqglVertex3f(mins[0],maxs[1],mins[2]);\n\tqglVertex3f(maxs[0],mins[1],mins[2]);\n\tqglVertex3f(maxs[0],mins[1],maxs[2]);\n\tqglVertex3f(maxs[0],maxs[1],maxs[2]);\n\tqglVertex3f(maxs[0],maxs[1],mins[2]);\n\tqglEnd();\n\n}\n\nvoid splineTest() {\n\t//g_splineList->load(\"p:/doom/base/maps/test_base1.camera\");\n}\n\nvoid splineDraw() {\n\t//g_splineList->addToRenderer();\n}\n\n\n//extern void D_DebugLine( const idVec3_t &color, const idVec3_t &start, const idVec3_t &end );\n\nvoid debugLine(idVec3_t &color, float x, float y, float z, float x2, float y2, float z2) {\n\tidVec3_t from(x, y, z);\n\tidVec3_t to(x2, y2, z2);\n\t//D_DebugLine(color, from, to);\n}\n\nvoid idSplineList::addToRenderer() {\n\n\tif (controlPoints.Num() == 0) {\n\t\treturn;\n\t}\n\n\tidVec3_t mins, maxs;\n\tidVec3_t yellow(1.0, 1.0, 0);\n\tidVec3_t white(1.0, 1.0, 1.0);\n        int i;\n        \n\tfor(i = 0; i < controlPoints.Num(); i++) {\n\t\tVectorCopy(*controlPoints[i], mins);\n\t\tVectorCopy(mins, maxs);\n\t\tmins[0] -= 8;\n\t\tmins[1] += 8;\n\t\tmins[2] -= 8;\n\t\tmaxs[0] += 8;\n\t\tmaxs[1] -= 8;\n\t\tmaxs[2] += 8;\n\t\tdebugLine( yellow, mins[0], mins[1], mins[2], maxs[0], mins[1], mins[2]);\n\t\tdebugLine( yellow, maxs[0], mins[1], mins[2], maxs[0], maxs[1], mins[2]);\n\t\tdebugLine( yellow, maxs[0], maxs[1], mins[2], mins[0], maxs[1], mins[2]);\n\t\tdebugLine( yellow, mins[0], maxs[1], mins[2], mins[0], mins[1], mins[2]);\n\t\t\n\t\tdebugLine( yellow, mins[0], mins[1], maxs[2], maxs[0], mins[1], maxs[2]);\n\t\tdebugLine( yellow, maxs[0], mins[1], maxs[2], maxs[0], maxs[1], maxs[2]);\n\t\tdebugLine( yellow, maxs[0], maxs[1], maxs[2], mins[0], maxs[1], maxs[2]);\n\t\tdebugLine( yellow, mins[0], maxs[1], maxs[2], mins[0], mins[1], maxs[2]);\n\t    \n\t}\n\n\tint step = 0;\n\tidVec3_t step1;\n\tfor(i = 3; i < controlPoints.Num(); i++) {\n\t\tfor (float tension = 0.0f; tension < 1.001f; tension += 0.1f) {\n\t\t\tfloat x = 0;\n\t\t\tfloat y = 0;\n\t\t\tfloat z = 0;\n\t\t\tfor (int j = 0; j < 4; j++) {\n\t\t\t\tx += controlPoints[i - (3 - j)]->x * calcSpline(j, tension);\n\t\t\t\ty += controlPoints[i - (3 - j)]->y * calcSpline(j, tension);\n\t\t\t\tz += controlPoints[i - (3 - j)]->z * calcSpline(j, tension);\n\t\t\t}\n\t\t\tif (step == 0) {\n\t\t\t\tstep1[0] = x;\n\t\t\t\tstep1[1] = y;\n\t\t\t\tstep1[2] = z;\n\t\t\t\tstep = 1;\n\t\t\t} else {\n\t\t\t\tdebugLine( white, step1[0], step1[1], step1[2], x, y, z);\n\t\t\t\tstep = 0;\n\t\t\t}\n\n\t\t}\n\t}\n}\n\nvoid idSplineList::buildSpline() {\n\t//int start = Sys_Milliseconds();\n\tclearSpline();\n\tfor(int i = 3; i < controlPoints.Num(); i++) {\n\t\tfor (float tension = 0.0f; tension < 1.001f; tension += granularity) {\n\t\t\tfloat x = 0;\n\t\t\tfloat y = 0;\n\t\t\tfloat z = 0;\n\t\t\tfor (int j = 0; j < 4; j++) {\n\t\t\t\tx += controlPoints[i - (3 - j)]->x * calcSpline(j, tension);\n\t\t\t\ty += controlPoints[i - (3 - j)]->y * calcSpline(j, tension);\n\t\t\t\tz += controlPoints[i - (3 - j)]->z * calcSpline(j, tension);\n\t\t\t}\n\t\t\tsplinePoints.Append(new idVec3_t(x, y, z));\n\t\t}\n\t}\n\tdirty = false;\n\t//Com_Printf(\"Spline build took %f seconds\\n\", (float)(Sys_Milliseconds() - start) / 1000);\n}\n\n\nvoid idSplineList::draw(bool editMode) {\n\tint i;\n\tvec4_t yellow(1, 1, 0, 1);\n        \n\tif (controlPoints.Num() == 0) {\n\t\treturn;\n\t}\n\n\tif (dirty) {\n\t\tbuildSpline();\n\t}\n\n\n\tqglColor3fv(controlColor);\n\tqglPointSize(5);\n\t\n\tqglBegin(GL_POINTS);\n\tfor (i = 0; i < controlPoints.Num(); i++) {\n\t\tqglVertex3fv(*controlPoints[i]);\n\t}\n\tqglEnd();\n\t\n\tif (editMode) {\n\t\tfor(i = 0; i < controlPoints.Num(); i++) {\n\t\t\tglBox(activeColor, *controlPoints[i], 4);\n\t\t}\n\t}\n\n\t//Draw the curve\n\tqglColor3fv(pathColor);\n\tqglBegin(GL_LINE_STRIP);\n\tint count = splinePoints.Num();\n\tfor (i = 0; i < count; i++) {\n\t\tqglVertex3fv(*splinePoints[i]);\n\t}\n\tqglEnd();\n\n\tif (editMode) {\n\t\tqglColor3fv(segmentColor);\n\t\tqglPointSize(3);\n\t\tqglBegin(GL_POINTS);\n\t\tfor (i = 0; i < count; i++) {\n\t\t\tqglVertex3fv(*splinePoints[i]);\n\t\t}\n\t\tqglEnd();\n\t}\n\tif (count > 0) {\n\t\t//assert(activeSegment >=0 && activeSegment < count);\n\t\tif (activeSegment >=0 && activeSegment < count) {\n\t\t\tglBox(activeColor, *splinePoints[activeSegment], 6);\n\t\t\tglBox(yellow, *splinePoints[activeSegment], 8);\n\t\t}\n\t}\n\n}\n\nfloat idSplineList::totalDistance() {\n\n\tif (controlPoints.Num() == 0) {\n\t\treturn 0.0;\n\t}\n\n\tif (dirty) {\n\t\tbuildSpline();\n\t}\n\n\tfloat dist = 0.0;\n\tidVec3_t temp;\n\tint count = splinePoints.Num();\n\tfor(int i = 1; i < count; i++) {\n\t\ttemp = *splinePoints[i-1];\n\t\ttemp -= *splinePoints[i];\n\t\tdist += temp.Length();\n\t}\n\treturn dist;\n}\n\nvoid idSplineList::initPosition(long bt, long totalTime) {\n\n\tif (dirty) {\n\t\tbuildSpline();\n\t}\n\n\tif (splinePoints.Num() == 0) {\n\t\treturn;\n\t}\n\n\tbaseTime = bt;\n\ttime = totalTime;\n\n\t// calc distance to travel ( this will soon be broken into time segments )\n\tsplineTime.Clear();\n\tsplineTime.Append(0);\n\tfloat dist = totalDistance();\n\tfloat distSoFar = 0.0;\n\tidVec3_t temp;\n\tint count = splinePoints.Num();\n\t//for(int i = 2; i < count - 1; i++) {\n\tfor(int i = 1; i < count; i++) {\n\t\ttemp = *splinePoints[i-1];\n\t\ttemp -= *splinePoints[i];\n\t\tdistSoFar += temp.Length();\n\t\tfloat percent = distSoFar / dist;\n\t\tpercent *= totalTime;\n\t\tsplineTime.Append(percent + bt);\n\t}\n\tassert(splineTime.Num() == splinePoints.Num());\n\tactiveSegment = 0;\n}\n\n\n\nfloat idSplineList::calcSpline(int step, float tension) {\n\tswitch(step) {\n\t\tcase 0:\treturn (pow(1 - tension, 3)) / 6;\n\t\tcase 1:\treturn (3 * pow(tension, 3) - 6 * pow(tension, 2) + 4) / 6;\n\t\tcase 2:\treturn (-3 * pow(tension, 3) + 3 * pow(tension, 2) + 3 * tension + 1) / 6;\n\t\tcase 3:\treturn pow(tension, 3) / 6;\n\t}\n\treturn 0.0;\n}\n\n\n\nvoid idSplineList::updateSelection(const idVec3_t &move) {\n\tif (selected) {\n\t\tdirty = true;\n\t\tVectorAdd(*selected, move, *selected);\n\t}\n}\n\n\nvoid idSplineList::setSelectedPoint(idVec3_t *p) {\n\tif (p) {\n\t\tp->Snap();\n\t\tfor(int i = 0; i < controlPoints.Num(); i++) {\n\t\t\tif (*p == *controlPoints[i]) {\n\t\t\t\tselected = controlPoints[i];\n\t\t\t}\n\t\t}\n\t} else {\n\t\tselected = NULL;\n\t}\n}\n\nconst idVec3_t *idSplineList::getPosition(long t) {\n\tstatic idVec3_t interpolatedPos;\n\n\tint count = splineTime.Num();\n\tif (count == 0) {\n\t\treturn &zero;\n\t}\n\n\tassert(splineTime.Num() == splinePoints.Num());\n\n\twhile (activeSegment < count) {\n\t\tif (splineTime[activeSegment] >= t) {\n\t\t\tif (activeSegment > 0 && activeSegment < count - 1) {\n\t\t\t\tfloat timeHi = splineTime[activeSegment + 1];\n\t\t\t\tfloat timeLo = splineTime[activeSegment - 1];\n\t\t\t\t//float percent = (float)(baseTime + time - t) / time;\n\t\t\t\tfloat percent = (timeHi - t) / (timeHi - timeLo); \n\t\t\t\t// pick two bounding points\n\t\t\t\tidVec3_t v1 = *splinePoints[activeSegment-1];\n\t\t\t\tidVec3_t v2 = *splinePoints[activeSegment+1];\n\t\t\t\tv2 *= (1.0 - percent);\n\t\t\t\tv1 *= percent;\n\t\t\t\tv2 += v1;\n\t\t\t\tinterpolatedPos = v2;\n\t\t\t\treturn &interpolatedPos;\n\t\t\t}\n\t\t\treturn splinePoints[activeSegment];\n\t\t} else {\n\t\t\tactiveSegment++;\n\t\t}\n\t}\n\treturn splinePoints[count-1];\n}\n\nvoid idSplineList::parse(const char *(*text)  ) {\n\tconst char *token;\n\t//Com_MatchToken( text, \"{\" );\n\tdo {\n\t\ttoken = Com_Parse( text );\n\t\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( !Q_stricmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdo {\n\t\t\t// if token is not a brace, it is a key for a key/value pair\n\t\t\tif ( !token[0] || !Q_stricmp (token, \"(\") || !Q_stricmp(token, \"}\")) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tCom_UngetToken();\n\t\t\tidStr key = Com_ParseOnLine(text);\n\t\t\tconst char *token = Com_Parse(text);\n\t\t\tif (Q_stricmp(key.c_str(), \"granularity\") == 0) {\n\t\t\t\tgranularity = atof(token);\n\t\t\t} else if (Q_stricmp(key.c_str(), \"name\") == 0) {\n\t\t\t\tname = token;\n\t\t\t}\n\t\t\ttoken = Com_Parse(text);\n\n\t\t} while (1);\n\n\t\tif ( !Q_stricmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tCom_UngetToken();\n\t\t// read the control point\n\t\tidVec3_t point;\n\t\tCom_Parse1DMatrix( text, 3, point );\n\t\taddPoint(point.x, point.y, point.z);\n\t} while (1);\n \n\t//Com_UngetToken();\n\t//Com_MatchToken( text, \"}\" );\n\tdirty = true;\n}\n\nvoid idSplineList::write(fileHandle_t file, const char *p) {\n\tidStr s = va(\"\\t\\t%s {\\n\", p);\n\tFS_Write(s.c_str(), s.length(), file);\n\t//s = va(\"\\t\\tname %s\\n\", name.c_str());\n\t//FS_Write(s.c_str(), s.length(), file);\n\ts = va(\"\\t\\t\\tgranularity %f\\n\", granularity);\n\tFS_Write(s.c_str(), s.length(), file);\n\tint count = controlPoints.Num();\n\tfor (int i = 0; i < count; i++) {\n\t\ts = va(\"\\t\\t\\t( %f %f %f )\\n\", controlPoints[i]->x, controlPoints[i]->y, controlPoints[i]->z);\n\t\tFS_Write(s.c_str(), s.length(), file);\n\t}\n\ts = \"\\t\\t}\\n\";\n\tFS_Write(s.c_str(), s.length(), file);\n}\n\n\nvoid idCameraDef::getActiveSegmentInfo(int segment, idVec3_t &origin, idVec3_t &direction, float *fov) {\n#if 0\n\tif (!cameraSpline.validTime()) {\n\t\tbuildCamera();\n\t}\n\tdouble d = (double)segment / numSegments();\n\tgetCameraInfo(d * totalTime * 1000, origin, direction, fov);\n#endif\n/*\n\tif (!cameraSpline.validTime()) {\n\t\tbuildCamera();\n\t}\n\torigin = *cameraSpline.getSegmentPoint(segment);\n\t\n\n\tidVec3_t temp;\n\n\tint numTargets = getTargetSpline()->controlPoints.Num();\n\tint count = cameraSpline.splineTime.Num();\n\tif (numTargets == 0) {\n\t\t// follow the path\n\t\tif (cameraSpline.getActiveSegment() < count - 1) {\n\t\t\ttemp = *cameraSpline.splinePoints[cameraSpline.getActiveSegment()+1];\n\t\t}\n\t} else if (numTargets == 1) {\n\t\ttemp = *getTargetSpline()->controlPoints[0];\n\t} else {\n\t\ttemp = *getTargetSpline()->getSegmentPoint(segment);\n\t}\n\n\ttemp -= origin;\n\ttemp.Normalize();\n\tdirection = temp;\n*/\n}\n\nbool idCameraDef::getCameraInfo(long time, idVec3_t &origin, idVec3_t &direction, float *fv) {\n\n\n\tif ((time - startTime) / 1000 > totalTime) {\n\t\treturn false;\n\t}\n\n\n\tfor (int i = 0; i < events.Num(); i++) {\n\t\tif (time >= startTime + events[i]->getTime() && !events[i]->getTriggered()) {\n\t\t\tevents[i]->setTriggered(true);\n\t\t\tif (events[i]->getType() == idCameraEvent::EVENT_TARGET) {\n\t\t\t\tsetActiveTargetByName(events[i]->getParam());\n\t\t\t\tgetActiveTarget()->start(startTime + events[i]->getTime());\n\t\t\t\t//Com_Printf(\"Triggered event switch to target: %s\\n\",events[i]->getParam());\n\t\t\t} else if (events[i]->getType() == idCameraEvent::EVENT_TRIGGER) {\n\t\t\t\t//idEntity *ent = NULL;\n\t\t\t\t//ent = level.FindTarget( ent, events[i]->getParam());\n\t\t\t\t//if (ent) {\n\t\t\t\t//\tent->signal( SIG_TRIGGER );\n\t\t\t\t//\tent->ProcessEvent( &EV_Activate, world );\n\t\t\t\t//}\n\t\t\t} else if (events[i]->getType() == idCameraEvent::EVENT_FOV) {\n\t\t\t\t//*fv = fov = atof(events[i]->getParam());\n\t\t\t} else if (events[i]->getType() == idCameraEvent::EVENT_STOP) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\n\torigin = *cameraPosition->getPosition(time);\n\t\n\t*fv = fov.getFOV(time);\n\n\tidVec3_t temp = origin;\n\n\tint numTargets = targetPositions.Num();\n\tif (numTargets == 0) {\n/*\n\t\t// follow the path\n\t\tif (cameraSpline.getActiveSegment() < count - 1) {\n\t\t\ttemp = *cameraSpline.splinePoints[cameraSpline.getActiveSegment()+1];\n\t\t\tif (temp == origin) {\n\t\t\t\tint index = cameraSpline.getActiveSegment() + 2;\n\t\t\t\twhile (temp == origin && index < count - 1) {\n\t\t\t\t\ttemp = *cameraSpline.splinePoints[index++];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n*/\n\t} else {\n\t\ttemp = *getActiveTarget()->getPosition(time);\n\t}\n\t\n\ttemp -= origin;\n\ttemp.Normalize();\n\tdirection = temp;\n\n\treturn true;\n}\n\nbool idCameraDef::waitEvent(int index) {\n\t//for (int i = 0; i < events.Num(); i++) {\n\t//\tif (events[i]->getSegment() == index && events[i]->getType() == idCameraEvent::EVENT_WAIT) {\n\t//\t\treturn true;\n\t//\t}\n    //}\n\treturn false;\n}\n\n\n#define NUM_CCELERATION_SEGS 10\n#define CELL_AMT 5\n\nvoid idCameraDef::buildCamera() {\n\tint i;\n\tint lastSwitch = 0;\n\tidList<float> waits;\n\tidList<int> targets;\n\n\ttotalTime = baseTime;\n\tcameraPosition->setTime(totalTime * 1000);\n\t// we have a base time layout for the path and the target path\n\t// now we need to layer on any wait or speed changes\n\tfor (i = 0; i < events.Num(); i++) {\n\t\tidCameraEvent *ev = events[i];\n\t\tevents[i]->setTriggered(false);\n\t\tswitch (events[i]->getType()) {\n\t\t\tcase idCameraEvent::EVENT_TARGET : {\n\t\t\t\ttargets.Append(i);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase idCameraEvent::EVENT_WAIT : {\n\t\t\t\twaits.Append(atof(events[i]->getParam()));\n\t\t\t\tcameraPosition->addVelocity(events[i]->getTime(), atof(events[i]->getParam()) * 1000, 0);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase idCameraEvent::EVENT_TARGETWAIT : {\n\t\t\t\t//targetWaits.Append(i);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase idCameraEvent::EVENT_SPEED : {\n/*\n\t\t\t\t// take the average delay between up to the next five segments\n\t\t\t\tfloat adjust = atof(events[i]->getParam());\n\t\t\t\tint index = events[i]->getSegment();\n\t\t\t\ttotal = 0;\n\t\t\t\tcount = 0;\n\n\t\t\t\t// get total amount of time over the remainder of the segment\n\t\t\t\tfor (j = index; j < cameraSpline.numSegments() - 1; j++) {\n\t\t\t\t\ttotal += cameraSpline.getSegmentTime(j + 1) - cameraSpline.getSegmentTime(j);\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\n\t\t\t\t// multiply that by the adjustment\n\t\t\t\tdouble newTotal = total * adjust;\n\t\t\t\t// what is the difference.. \n\t\t\t\tnewTotal -= total;\n\t\t\t\ttotalTime += newTotal / 1000;\n\n\t\t\t\t// per segment difference\n\t\t\t\tnewTotal /= count;\n\t\t\t\tint additive = newTotal;\n\n\t\t\t\t// now propogate that difference out to each segment\n\t\t\t\tfor (j = index; j < cameraSpline.numSegments(); j++) {\n\t\t\t\t\tcameraSpline.addSegmentTime(j, additive);\n\t\t\t\t\tadditive += newTotal;\n\t\t\t\t}\n\t\t\t\tbreak;\n*/\n\t\t\t}\n\t\t}\n\t}\n\n\n\tfor (i = 0; i < waits.Num(); i++) {\n\t\ttotalTime += waits[i];\n\t}\n\n\t// on a new target switch, we need to take time to this point ( since last target switch ) \n\t// and allocate it across the active target, then reset time to this point\n\tlong timeSoFar = 0;\n\tlong total = totalTime * 1000;\n\tfor (i = 0; i < targets.Num(); i++) {\n\t\tlong t;\n\t\tif (i < targets.Num() - 1) {\n\t\t\tt = events[targets[i+1]]->getTime();\n\t\t} else {\n\t\t\tt = total - timeSoFar;\n\t\t}\n\t\t// t is how much time to use for this target\n\t\tsetActiveTargetByName(events[targets[i]]->getParam());\n\t\tgetActiveTarget()->setTime(t);\n\t\ttimeSoFar += t;\n\t}\n\n\t\n}\n\nvoid idCameraDef::startCamera(long t) {\n\tbuildCamera();\n\tcameraPosition->start(t);\n\t//for (int i = 0; i < targetPositions.Num(); i++) {\n\t//\ttargetPositions[i]->\n\t//}\n\tstartTime = t;\n\tcameraRunning = true;\n}\n\n\nvoid idCameraDef::parse(const char *(*text)  ) {\n\n\tconst char\t*token;\n\tdo {\n\t\ttoken = Com_Parse( text );\n\t\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( !Q_stricmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (Q_stricmp(token, \"time\") == 0) {\n\t\t\tbaseTime = Com_ParseFloat(text);\n\t\t}\n\n\t\tif (Q_stricmp(token, \"camera_fixed\") == 0) {\n\t\t\tcameraPosition = new idFixedPosition();\n\t\t\tcameraPosition->parse(text);\n\t\t}\n\n\t\tif (Q_stricmp(token, \"camera_interpolated\") == 0) {\n\t\t\tcameraPosition = new idInterpolatedPosition();\n\t\t\tcameraPosition->parse(text);\n\t\t}\n\n\t\tif (Q_stricmp(token, \"camera_spline\") == 0) {\n\t\t\tcameraPosition = new idSplinePosition();\n\t\t\tcameraPosition->parse(text);\n\t\t}\n\n\t\tif (Q_stricmp(token, \"target_fixed\") == 0) {\n\t\t\tidFixedPosition *pos = new idFixedPosition();\n\t\t\tpos->parse(text);\n\t\t\ttargetPositions.Append(pos);\n\t\t}\n\t\t\n\t\tif (Q_stricmp(token, \"target_interpolated\") == 0) {\n\t\t\tidInterpolatedPosition *pos = new idInterpolatedPosition();\n\t\t\tpos->parse(text);\n\t\t\ttargetPositions.Append(pos);\n\t\t}\n\n\t\tif (Q_stricmp(token, \"target_spline\") == 0) {\n\t\t\tidSplinePosition *pos = new idSplinePosition();\n\t\t\tpos->parse(text);\n\t\t\ttargetPositions.Append(pos);\n\t\t}\n\n\t\tif (Q_stricmp(token, \"fov\") == 0) {\n\t\t\tfov.parse(text);\n\t\t}\n\n\t\tif (Q_stricmp(token, \"event\") == 0) {\n\t\t\tidCameraEvent *event = new idCameraEvent();\n\t\t\tevent->parse(text);\n\t\t\taddEvent(event);\n\t\t}\n\n\n\t} while (1);\n\n\tCom_UngetToken();\n\tCom_MatchToken( text, \"}\" );\n\n}\n\nbool idCameraDef::load(const char *filename) {\n\tchar *buf;\n\tconst char *buf_p;\n\tint length = FS_ReadFile( filename, (void **)&buf );\n\tif ( !buf ) {\n\t\treturn false;\n\t}\n\n\tclear();\n\tCom_BeginParseSession( filename );\n\tbuf_p = buf;\n\tparse(&buf_p);\n\tCom_EndParseSession();\n\tFS_FreeFile( buf );\n\n\treturn true;\n}\n\nvoid idCameraDef::save(const char *filename) {\n\tfileHandle_t file = FS_FOpenFileWrite(filename);\n\tif (file) {\n\t\tint i;\n\t\tidStr s = \"cameraPathDef { \\n\"; \n\t\tFS_Write(s.c_str(), s.length(), file);\n\t\ts = va(\"\\ttime %f\\n\", baseTime);\n\t\tFS_Write(s.c_str(), s.length(), file);\n\n\t\tcameraPosition->write(file, va(\"camera_%s\",cameraPosition->typeStr()));\n\n\t\tfor (i = 0; i < numTargets(); i++) {\n\t\t\ttargetPositions[i]->write(file, va(\"target_%s\", targetPositions[i]->typeStr()));\n\t\t}\n\n\t\tfor (i = 0; i < events.Num(); i++) {\n\t\t\tevents[i]->write(file, \"event\");\n\t\t}\n\n\t\tfov.write(file, \"fov\");\n\n\t\ts = \"}\\n\";\n\t\tFS_Write(s.c_str(), s.length(), file);\n\t}\n\tFS_FCloseFile(file);\n}\n\nint idCameraDef::sortEvents(const void *p1, const void *p2) {\n\tidCameraEvent *ev1 = (idCameraEvent*)(p1);\n\tidCameraEvent *ev2 = (idCameraEvent*)(p2);\n\n\tif (ev1->getTime() > ev2->getTime()) {\n\t\treturn -1;\n\t}\n\tif (ev1->getTime() < ev2->getTime()) {\n\t\treturn 1;\n\t}\n\treturn 0; \n}\n\nvoid idCameraDef::addEvent(idCameraEvent *event) {\n\tevents.Append(event);\n\t//events.Sort(&sortEvents);\n\n}\nvoid idCameraDef::addEvent(idCameraEvent::eventType t, const char *param, long time) {\n\taddEvent(new idCameraEvent(t, param, time));\n\tbuildCamera();\n}\n\n\nconst char *idCameraEvent::eventStr[] = {\n\t\"NA\",\n\t\"WAIT\",\n\t\"TARGETWAIT\",\n\t\"SPEED\",\n\t\"TARGET\",\n\t\"SNAPTARGET\",\n\t\"FOV\",\n\t\"SCRIPT\",\n\t\"TRIGGER\",\n\t\"STOP\"\n};\n\nvoid idCameraEvent::parse(const char *(*text)  ) {\n\tconst char *token;\n\tCom_MatchToken( text, \"{\" );\n\tdo {\n\t\ttoken = Com_Parse( text );\n\t\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( !strcmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// here we may have to jump over brush epairs ( only used in editor )\n\t\tdo {\n\t\t\t// if token is not a brace, it is a key for a key/value pair\n\t\t\tif ( !token[0] || !strcmp (token, \"(\") || !strcmp(token, \"}\")) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tCom_UngetToken();\n\t\t\tidStr key = Com_ParseOnLine(text);\n\t\t\tconst char *token = Com_Parse(text);\n\t\t\tif (Q_stricmp(key.c_str(), \"type\") == 0) {\n\t\t\t\ttype = static_cast<idCameraEvent::eventType>(atoi(token));\n\t\t\t} else if (Q_stricmp(key.c_str(), \"param\") == 0) {\n\t\t\t\tparamStr = token;\n\t\t\t} else if (Q_stricmp(key.c_str(), \"time\") == 0) {\n\t\t\t\ttime = atoi(token);\n\t\t\t}\n\t\t\ttoken = Com_Parse(text);\n\n\t\t} while (1);\n\n\t\tif ( !strcmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t} while (1);\n \n\tCom_UngetToken();\n\tCom_MatchToken( text, \"}\" );\n}\n\nvoid idCameraEvent::write(fileHandle_t file, const char *name) {\n\tidStr s = va(\"\\t%s {\\n\", name);\n\tFS_Write(s.c_str(), s.length(), file);\n\ts = va(\"\\t\\ttype %d\\n\", static_cast<int>(type));\n\tFS_Write(s.c_str(), s.length(), file);\n\ts = va(\"\\t\\tparam %s\\n\", paramStr.c_str());\n\tFS_Write(s.c_str(), s.length(), file);\n\ts = va(\"\\t\\ttime %d\\n\", time);\n\tFS_Write(s.c_str(), s.length(), file);\n\ts = \"\\t}\\n\";\n\tFS_Write(s.c_str(), s.length(), file);\n}\n\n\nconst char *idCameraPosition::positionStr[] = {\n\t\"Fixed\",\n\t\"Interpolated\",\n\t\"Spline\",\n};\n\n\n\nconst idVec3_t *idInterpolatedPosition::getPosition(long t) { \n\tstatic idVec3_t interpolatedPos;\n\n\tfloat velocity = getVelocity(t);\n\tfloat timePassed = t - lastTime;\n\tlastTime = t;\n\n\t// convert to seconds\t\n\ttimePassed /= 1000;\n\n\tfloat distToTravel = timePassed *= velocity;\n\n\tidVec3_t temp = startPos;\n\ttemp -= endPos;\n\tfloat distance = temp.Length();\n\n\tdistSoFar += distToTravel;\n\tfloat percent = (float)(distSoFar) / distance;\n\n\tif (percent > 1.0) {\n\t\tpercent = 1.0;\n\t} else if (percent < 0.0) {\n\t\tpercent = 0.0;\n\t}\n\n\t// the following line does a straigt calc on percentage of time\n\t// float percent = (float)(startTime + time - t) / time;\n\n\tidVec3_t v1 = startPos;\n\tidVec3_t v2 = endPos;\n\tv1 *= (1.0 - percent);\n\tv2 *= percent;\n\tv1 += v2;\n\tinterpolatedPos = v1;\n\treturn &interpolatedPos;\n}\n\n\nvoid idCameraFOV::parse(const char *(*text)  ) {\n\tconst char *token;\n\tCom_MatchToken( text, \"{\" );\n\tdo {\n\t\ttoken = Com_Parse( text );\n\t\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( !strcmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// here we may have to jump over brush epairs ( only used in editor )\n\t\tdo {\n\t\t\t// if token is not a brace, it is a key for a key/value pair\n\t\t\tif ( !token[0] || !strcmp (token, \"(\") || !strcmp(token, \"}\")) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tCom_UngetToken();\n\t\t\tidStr key = Com_ParseOnLine(text);\n\t\t\tconst char *token = Com_Parse(text);\n\t\t\tif (Q_stricmp(key.c_str(), \"fov\") == 0) {\n\t\t\t\tfov = atof(token);\n\t\t\t} else if (Q_stricmp(key.c_str(), \"startFOV\") == 0) {\n\t\t\t\tstartFOV = atof(token);\n\t\t\t} else if (Q_stricmp(key.c_str(), \"endFOV\") == 0) {\n\t\t\t\tendFOV = atof(token);\n\t\t\t} else if (Q_stricmp(key.c_str(), \"time\") == 0) {\n\t\t\t\ttime = atoi(token);\n\t\t\t}\n\t\t\ttoken = Com_Parse(text);\n\n\t\t} while (1);\n\n\t\tif ( !strcmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t} while (1);\n \n\tCom_UngetToken();\n\tCom_MatchToken( text, \"}\" );\n}\n\nbool idCameraPosition::parseToken(const char *key, const char *(*text)) {\n\tconst char *token = Com_Parse(text);\n\tif (Q_stricmp(key, \"time\") == 0) {\n\t\ttime = atol(token);\n\t\treturn true;\n\t} else if (Q_stricmp(key, \"type\") == 0) {\n\t\ttype = static_cast<idCameraPosition::positionType>(atoi(token));\n\t\treturn true;\n\t} else if (Q_stricmp(key, \"velocity\") == 0) {\n\t\tlong t = atol(token);\n\t\ttoken = Com_Parse(text);\n\t\tlong d = atol(token);\n\t\ttoken = Com_Parse(text);\n\t\tfloat s = atof(token);\n\t\taddVelocity(t, d, s);\n\t\treturn true;\n\t} else if (Q_stricmp(key, \"baseVelocity\") == 0) {\n\t\tbaseVelocity = atof(token);\n\t\treturn true;\n\t} else if (Q_stricmp(key, \"name\") == 0) {\n\t\tname = token;\n\t\treturn true;\n\t} else if (Q_stricmp(key, \"time\") == 0) {\n\t\ttime = atoi(token);\n\t\treturn true;\n\t}\n\tCom_UngetToken();\n\treturn false;\n}\n\n\n\nvoid idFixedPosition::parse(const char *(*text)  ) {\n\tconst char *token;\n\tCom_MatchToken( text, \"{\" );\n\tdo {\n\t\ttoken = Com_Parse( text );\n\t\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( !strcmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// here we may have to jump over brush epairs ( only used in editor )\n\t\tdo {\n\t\t\t// if token is not a brace, it is a key for a key/value pair\n\t\t\tif ( !token[0] || !strcmp (token, \"(\") || !strcmp(token, \"}\")) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tCom_UngetToken();\n\t\t\tidStr key = Com_ParseOnLine(text);\n\t\t\t\n\t\t\tconst char *token = Com_Parse(text);\n\t\t\tif (Q_stricmp(key.c_str(), \"pos\") == 0) {\n\t\t\t\tCom_UngetToken();\n\t\t\t\tCom_Parse1DMatrix( text, 3, pos );\n\t\t\t} else {\n\t\t\t\tCom_UngetToken();\n\t\t\t\tidCameraPosition::parseToken(key.c_str(), text);\t\n\t\t\t}\n\t\t\ttoken = Com_Parse(text);\n\n\t\t} while (1);\n\n\t\tif ( !strcmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t} while (1);\n \n\tCom_UngetToken();\n\tCom_MatchToken( text, \"}\" );\n}\n\nvoid idInterpolatedPosition::parse(const char *(*text)  ) {\n\tconst char *token;\n\tCom_MatchToken( text, \"{\" );\n\tdo {\n\t\ttoken = Com_Parse( text );\n\t\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( !strcmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// here we may have to jump over brush epairs ( only used in editor )\n\t\tdo {\n\t\t\t// if token is not a brace, it is a key for a key/value pair\n\t\t\tif ( !token[0] || !strcmp (token, \"(\") || !strcmp(token, \"}\")) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tCom_UngetToken();\n\t\t\tidStr key = Com_ParseOnLine(text);\n\t\t\t\n\t\t\tconst char *token = Com_Parse(text);\n\t\t\tif (Q_stricmp(key.c_str(), \"startPos\") == 0) {\n\t\t\t\tCom_UngetToken();\n\t\t\t\tCom_Parse1DMatrix( text, 3, startPos );\n\t\t\t} else if (Q_stricmp(key.c_str(), \"endPos\") == 0) {\n\t\t\t\tCom_UngetToken();\n\t\t\t\tCom_Parse1DMatrix( text, 3, endPos );\n\t\t\t} else {\n\t\t\t\tCom_UngetToken();\n\t\t\t\tidCameraPosition::parseToken(key.c_str(), text);\t\n\t\t\t}\n\t\t\ttoken = Com_Parse(text);\n\n\t\t} while (1);\n\n\t\tif ( !strcmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t} while (1);\n \n\tCom_UngetToken();\n\tCom_MatchToken( text, \"}\" );\n}\n\n\nvoid idSplinePosition::parse(const char *(*text)  ) {\n\tconst char *token;\n\tCom_MatchToken( text, \"{\" );\n\tdo {\n\t\ttoken = Com_Parse( text );\n\t\n\t\tif ( !token[0] ) {\n\t\t\tbreak;\n\t\t}\n\t\tif ( !strcmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// here we may have to jump over brush epairs ( only used in editor )\n\t\tdo {\n\t\t\t// if token is not a brace, it is a key for a key/value pair\n\t\t\tif ( !token[0] || !strcmp (token, \"(\") || !strcmp(token, \"}\")) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tCom_UngetToken();\n\t\t\tidStr key = Com_ParseOnLine(text);\n\t\t\t\n\t\t\tconst char *token = Com_Parse(text);\n\t\t\tif (Q_stricmp(key.c_str(), \"target\") == 0) {\n\t\t\t\ttarget.parse(text);\n\t\t\t} else {\n\t\t\t\tCom_UngetToken();\n\t\t\t\tidCameraPosition::parseToken(key.c_str(), text);\t\n\t\t\t}\n\t\t\ttoken = Com_Parse(text);\n\n\t\t} while (1);\n\n\t\tif ( !strcmp (token, \"}\") ) {\n\t\t\tbreak;\n\t\t}\n\n\t} while (1);\n \n\tCom_UngetToken();\n\tCom_MatchToken( text, \"}\" );\n}\n\n\n\nvoid idCameraFOV::write(fileHandle_t file, const char *p) {\n\tidStr s = va(\"\\t%s {\\n\", p);\n\tFS_Write(s.c_str(), s.length(), file);\n\t\n\ts = va(\"\\t\\tfov %f\\n\", fov);\n\tFS_Write(s.c_str(), s.length(), file);\n\n\ts = va(\"\\t\\tstartFOV %f\\n\", startFOV);\n\tFS_Write(s.c_str(), s.length(), file);\n\n\ts = va(\"\\t\\tendFOV %f\\n\", endFOV);\n\tFS_Write(s.c_str(), s.length(), file);\n\n\ts = va(\"\\t\\ttime %i\\n\", time);\n\tFS_Write(s.c_str(), s.length(), file);\n\n\ts = \"\\t}\\n\";\n\tFS_Write(s.c_str(), s.length(), file);\n}\n\n\nvoid idCameraPosition::write(fileHandle_t file, const char *p) {\n\t\n\tidStr s = va(\"\\t\\ttime %i\\n\", time);\n\tFS_Write(s.c_str(), s.length(), file);\n\n\ts = va(\"\\t\\ttype %i\\n\", static_cast<int>(type));\n\tFS_Write(s.c_str(), s.length(), file);\n\n\ts = va(\"\\t\\tname %s\\n\", name.c_str());\n\tFS_Write(s.c_str(), s.length(), file);\n\n\ts = va(\"\\t\\tbaseVelocity %f\\n\", baseVelocity);\n\tFS_Write(s.c_str(), s.length(), file);\n\n\tfor (int i = 0; i < velocities.Num(); i++) {\n\t\ts = va(\"\\t\\tvelocity %i %i %f\\n\", velocities[i]->startTime, velocities[i]->time, velocities[i]->speed);\n\t\tFS_Write(s.c_str(), s.length(), file);\n\t}\n\n}\n\nvoid idFixedPosition::write(fileHandle_t file, const char *p) {\n\tidStr s = va(\"\\t%s {\\n\", p);\n\tFS_Write(s.c_str(), s.length(), file);\n\tidCameraPosition::write(file, p);\n\ts = va(\"\\t\\tpos ( %f %f %f )\\n\", pos.x, pos.y, pos.z);\n\tFS_Write(s.c_str(), s.length(), file);\n\ts = \"\\t}\\n\";\n\tFS_Write(s.c_str(), s.length(), file);\n}\n\nvoid idInterpolatedPosition::write(fileHandle_t file, const char *p) {\n\tidStr s = va(\"\\t%s {\\n\", p);\n\tFS_Write(s.c_str(), s.length(), file);\n\tidCameraPosition::write(file, p);\n\ts = va(\"\\t\\tstartPos ( %f %f %f )\\n\", startPos.x, startPos.y, startPos.z);\n\tFS_Write(s.c_str(), s.length(), file);\n\ts = va(\"\\t\\tendPos ( %f %f %f )\\n\", endPos.x, endPos.y, endPos.z);\n\tFS_Write(s.c_str(), s.length(), file);\n\ts = \"\\t}\\n\";\n\tFS_Write(s.c_str(), s.length(), file);\n}\n\nvoid idSplinePosition::write(fileHandle_t file, const char *p) {\n\tidStr s = va(\"\\t%s {\\n\", p);\n\tFS_Write(s.c_str(), s.length(), file);\n\tidCameraPosition::write(file, p);\n\ttarget.write(file, \"target\");\n\ts = \"\\t}\\n\";\n\tFS_Write(s.c_str(), s.length(), file);\n}\n\nvoid idCameraDef::addTarget(const char *name, idCameraPosition::positionType type) {\n\tconst char *text = (name == NULL) ? va(\"target0%d\", numTargets()+1) : name;\n\tidCameraPosition *pos = newFromType(type);\n\tif (pos) {\n\t\tpos->setName(name);\n\t\ttargetPositions.Append(pos);\n\t\tactiveTarget = numTargets()-1;\n\t\tif (activeTarget == 0) {\n\t\t\t// first one\n\t\t\taddEvent(idCameraEvent::EVENT_TARGET, name, 0);\n\t\t}\n\t}\n}\n\n\n\nidCameraDef camera;\n\nextern \"C\" {\nqboolean loadCamera(const char *name) {\n  camera.clear();\n  return static_cast<qboolean>(camera.load(name));\n}\n\nqboolean getCameraInfo(int time, float *origin, float*angles) {\n\tidVec3_t dir, org;\n\torg[0] = origin[0];\n\torg[1] = origin[1];\n\torg[2] = origin[2];\n\tfloat fov = 90;\n\tif (camera.getCameraInfo(time, org, dir, &fov)) {\n\t\torigin[0] = org[0];\n\t\torigin[1] = org[1];\n\t\torigin[2] = org[2];\n\t\tangles[1] = atan2 (dir[1], dir[0])*180/3.14159;\n\t\tangles[0] = asin (dir[2])*180/3.14159;\n\t\treturn qtrue;\n\t}\n\treturn qfalse;\n}\n\nvoid startCamera(int time) {\n\tcamera.startCamera(time);\n}\n\n}\n\n\n"
  },
  {
    "path": "q3radiant/splines/splines.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __SPLINES_H\n#define __SPLINES_H\n\nextern \"C\" {\n#ifdef Q3RADIANT\n#include \"../qgl.h\"\n#else\n#include \"../renderer/qgl.h\"\n#endif\n}\n#include \"util_list.h\"\n#include \"util_str.h\"\n#include \"math_vector.h\"\n\ntypedef int fileHandle_t;\n\nextern void glBox(idVec3_t &color, idVec3_t &point, float size);\nextern void glLabeledPoint(idVec3_t &color, idVec3_t &point, float size, const char *label);\n\nstatic vec4_t blue(0, 0, 1, 1);\nstatic vec4_t red(1, 0, 0, 1);\n\nclass idPointListInterface {\npublic:\n\tidPointListInterface() {\n\t\tselectedPoints.Clear();\n\t};\n\t~idPointListInterface() {};\n\t\n\tvirtual int numPoints() {\n\t\treturn 0;\n\t}\n\t\n\tvirtual void addPoint(const float x, const float y, const float z) {}\n\tvirtual void addPoint(const idVec3_t &v) {}\n\tvirtual void removePoint(int index) {}\n\tvirtual idVec3_t *getPoint(int index) { return NULL; }\n\t\n\tint\tselectPointByRay(float ox, float oy, float oz, float dx, float dy, float dz, bool single) {\n\t\tidVec3_t origin(ox, oy, oz);\n\t\tidVec3_t dir(dx, dy, dz);\n\t\treturn selectPointByRay(origin, dir, single);\n\t}\n\n\tint\tselectPointByRay(const idVec3_t origin, const idVec3_t direction, bool single) {\n\t\tint\t\ti, besti, count;\n\t\tfloat\td, bestd;\n\t\tidVec3_t\ttemp, temp2;\n\n\t\t// find the point closest to the ray\n\t\tbesti = -1;\n\t\tbestd = 8;\n\t\tcount = numPoints();\n\n\t\tfor (i=0; i < count; i++) {\n\t\t\ttemp = *getPoint(i);\n\t\t\ttemp2 = temp;\n\t\t\ttemp -= origin;\n\t\t\td = DotProduct(temp, direction);\n\t\t\t__VectorMA (origin, d, direction, temp);\n\t\t\ttemp2 -= temp;\n\t\t\td = temp2.Length();\n\t\t\tif (d <= bestd) {\n\t\t\t\tbestd = d;\n\t\t\t\tbesti = i;\n\t\t\t}\n\t\t}\n\n\t\tif (besti >= 0) {\n\t\t\tselectPoint(besti, single);\n\t\t}\n\n\t\treturn besti;\n\t}\n\n\tint isPointSelected(int index) {\n\t\tint count = selectedPoints.Num();\n\t\tfor (int i = 0; i < count; i++) {\n\t\t\tif (selectedPoints[i] == index) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t}\n\t\n\tint selectPoint(int index, bool single) {\n\t\tif (index >= 0 && index < numPoints()) {\n\t\t\tif (single) {\n\t\t\t\tdeselectAll();\n\t\t\t} else {\n\t\t\t\tif (isPointSelected(index) >= 0) {\n\t\t\t\t\tselectedPoints.Remove(index);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn selectedPoints.Append(index);\n\t\t}\n\t\treturn -1;\n\t}\n\t\n\tvoid selectAll() {\n\t\tselectedPoints.Clear();\n\t\tfor (int i = 0; i < numPoints(); i++) {\n\t\t\tselectedPoints.Append(i);\n\t\t}\n\t}\n\n\tvoid deselectAll() {\n\t\tselectedPoints.Clear();\n\t}\n\n\tint numSelectedPoints();\n    \n\tidVec3_t *getSelectedPoint(int index) {\n\t\tassert(index >= 0 && index < numSelectedPoints());\n\t\treturn getPoint(selectedPoints[index]);\n\t}\n\t\n\tvirtual void updateSelection(float x, float y, float z) {\n\t\tidVec3_t move(x, y, z);\n\t\tupdateSelection(move);\n\t}\n\n\tvirtual void updateSelection(const idVec3_t &move) {\n\t\tint count = selectedPoints.Num();\n\t\tfor (int i = 0; i < count; i++) {\n\t\t\t*getPoint(selectedPoints[i]) += move;\n\t\t}\n\t}\n\n\tvoid drawSelection() {\n\t\tint count = selectedPoints.Num();\n\t\tfor (int i = 0; i < count; i++) {\n\t\t\tglBox(red, *getPoint(selectedPoints[i]), 4);\n\t\t}\n\t}\n\nprotected:\n\tidList<int> selectedPoints;\n\n};\n\n\nclass idSplineList {\n\npublic:\n\n\tidSplineList() {\n\t\tclear();\n\t}\n\n\tidSplineList(const char *p) {\n\t\tclear();\n\t\tname = p;\n\t};\n\n\t~idSplineList() {\n\t\tclear();\n\t};\n\n\tvoid clearControl() {\n\t\tfor (int i = 0; i < controlPoints.Num(); i++) {\n\t\t\tdelete controlPoints[i];\n\t\t}\n\t\tcontrolPoints.Clear();\n\t}\n\n\tvoid clearSpline() {\n\t\tfor (int i = 0; i < splinePoints.Num(); i++) {\n\t\t\tdelete splinePoints[i];\n\t\t}\n\t\tsplinePoints.Clear();\n\t}\n\n\tvoid parse(const char *(*text));\n\tvoid write(fileHandle_t file, const char *name);\n\n\tvoid clear() {\n\t\tclearControl();\n\t\tclearSpline();\n\t\tsplineTime.Clear();\n\t\tselected = NULL;\n\t\tdirty = true;\n\t\tactiveSegment = 0;\n\t\tgranularity = 0.025;\n\t\tpathColor.set(1.0, 0.5, 0.0);\n\t\tcontrolColor.set(0.7, 0.0, 1.0);\n\t\tsegmentColor.set(0.0, 0.0, 1.0);\n\t\tactiveColor.set(1.0, 0.0, 0.0);\n\t}\n\n\tvoid initPosition(long startTime, long totalTime);\n\tconst idVec3_t *getPosition(long time);\n\n\n\tvoid draw(bool editMode);\n\tvoid addToRenderer();\n\n\tvoid setSelectedPoint(idVec3_t *p);\n\tidVec3_t *getSelectedPoint() {\n\t  return selected;\n\t}\n\n\tvoid addPoint(const idVec3_t &v) {\n\t\tcontrolPoints.Append(new idVec3_t(v));\n\t\tdirty = true;\n\t}\n\n\tvoid addPoint(float x, float y, float z) {\n\t\tcontrolPoints.Append(new idVec3_t(x, y, z));\n\t\tdirty = true;\n\t}\n\n\tvoid updateSelection(const idVec3_t &move);\n\n\tvoid startEdit() {\n\t\teditMode = true;\n\t}\n\t\t\n\tvoid stopEdit() {\n\t\teditMode = false;\n\t}\n\n\tvoid buildSpline();\n\n\tvoid setGranularity(float f) {\n\t\tgranularity = f;\n\t}\n\n\tfloat getGranularity() {\n\t\treturn granularity;\n\t}\n\n\tint numPoints() {\n\t\treturn controlPoints.Num();\n\t}\n\n\tidVec3_t *getPoint(int index) {\n\t\tassert(index >= 0 && index < controlPoints.Num());\n\t\treturn controlPoints[index];\n\t}\n\n\tidVec3_t *getSegmentPoint(int index) {\n\t\tassert(index >= 0 && index < splinePoints.Num());\n\t\treturn splinePoints[index];\n\t}\n\n\n\tvoid setSegmentTime(int index, int time) {\n\t\tassert(index >= 0 && index < splinePoints.Num());\n\t\tsplineTime[index] = time;\n\t}\n\n\tint getSegmentTime(int index) {\n\t\tassert(index >= 0 && index < splinePoints.Num());\n\t\treturn splineTime[index];\n\t}\n\tvoid addSegmentTime(int index, int time) {\n\t\tassert(index >= 0 && index < splinePoints.Num());\n\t\tsplineTime[index] += time;\n\t}\n\n\tfloat totalDistance();\n\n\tstatic idVec3_t zero;\n\n\tint getActiveSegment() {\n\t\treturn activeSegment;\n\t}\n\n\tvoid setActiveSegment(int i) {\n\t\t//assert(i >= 0 && (splinePoints.Num() > 0 && i < splinePoints.Num()));\n\t\tactiveSegment = i;\n\t}\n\n\tint numSegments() {\n\t\treturn splinePoints.Num();\n\t}\n\n\tvoid setColors(idVec3_t &path, idVec3_t &segment, idVec3_t &control, idVec3_t &active) {\n\t\tpathColor = path;\n\t\tsegmentColor = segment;\n\t\tcontrolColor = control;\n\t\tactiveColor = active;\n\t}\n\n\tconst char *getName() {\n\t\treturn name.c_str();\n\t}\n\n\tvoid setName(const char *p) {\n\t\tname = p;\n\t}\n\n\tbool validTime() {\n\t\tif (dirty) {\n\t\t\tbuildSpline();\n\t\t}\n\t\t// gcc doesn't allow static casting away from bools\n\t\t// why?  I've no idea...\n\t\treturn (bool)(splineTime.Num() > 0 && splineTime.Num() == splinePoints.Num());\n\t}\n\n\tvoid setTime(long t) {\n\t\ttime = t;\n\t}\n\n\tvoid setBaseTime(long t) {\n\t\tbaseTime = t;\n\t}\n\nprotected:\n\tidStr name;\n\tfloat calcSpline(int step, float tension);\n\tidList<idVec3_t*> controlPoints;\n\tidList<idVec3_t*> splinePoints;\n\tidList<float> splineTime;\n\tidVec3_t *selected;\n\tidVec3_t pathColor, segmentColor, controlColor, activeColor;\n\tfloat granularity;\n\tbool editMode;\n\tbool dirty;\n\tint activeSegment;\n\tlong baseTime;\n\tlong time;\n\tfriend class idCamera;\n};\n\n// time in milliseconds \n// velocity where 1.0 equal rough walking speed\nstruct idVelocity {\n\tidVelocity(long start, long duration, float s) {\n\t\tstartTime = start;\n\t\ttime = duration;\n\t\tspeed = s;\n\t}\n\tlong\tstartTime;\n\tlong\ttime;\n\tfloat\tspeed;\n};\n\n// can either be a look at or origin position for a camera\n// \nclass idCameraPosition : public idPointListInterface {\npublic:\n\t\n\tvirtual void clear() {\n\t\teditMode = false;\n\t\tfor (int i = 0; i < velocities.Num(); i++) {\n\t\t\tdelete velocities[i];\n\t\t\tvelocities[i] = NULL;\n\t\t}\n\t\tvelocities.Clear();\n\t}\n\n\tidCameraPosition(const char *p) {\n\t\tname = p;\n\t}\n\n\tidCameraPosition() {\n\t\ttime = 0;\n\t\tname = \"position\";\n\t}\n\n\tidCameraPosition(long t) {\n\t\ttime = t;\n\t}\n\n\tvirtual ~idCameraPosition() {\n\t\tclear();\n\t}\n\n\t\n\t// this can be done with RTTI syntax but i like the derived classes setting a type\n\t// makes serialization a bit easier to see\n\t//\n\tenum positionType {\n\t\tFIXED = 0x00,\n\t\tINTERPOLATED,\n\t\tSPLINE,\n\t\tPOSITION_COUNT\n\t};\n\n\n\tvirtual void start(long t) {\n\t\tstartTime = t;\n\t}\n\n\tlong getTime() {\n\t\treturn time;\n\t}\n\n\tvirtual void setTime(long t) {\n\t\ttime = t;\n\t}\n\n\tfloat getVelocity(long t) {\n\t\tlong check = t - startTime;\n\t\tfor (int i = 0; i < velocities.Num(); i++) {\n\t\t\tif (check >= velocities[i]->startTime && check <= velocities[i]->startTime + velocities[i]->time) {\n\t\t\t\treturn velocities[i]->speed;\n\t\t\t}\n\t\t}\n\t\treturn baseVelocity;\n\t}\n\n\tvoid addVelocity(long start, long duration, float speed) {\n\t\tvelocities.Append(new idVelocity(start, duration, speed));\n\t}\n\n\tvirtual const idVec3_t *getPosition(long t) { \n\t\tassert(true);\n\t\treturn NULL;\n\t}\n\n\tvirtual void draw(bool editMode) {};\n\n\tvirtual void parse(const char *(*text)) {};\n\tvirtual void write(fileHandle_t file, const char *name);\n\tvirtual bool parseToken(const char *key, const char *(*text));\n\n\tconst char *getName() {\n\t\treturn name.c_str();\n\t}\n\n\tvoid setName(const char *p) {\n\t\tname = p;\n\t}\n\n\tvirtual startEdit() {\n\t\teditMode = true;\n\t}\n\n\tvirtual stopEdit() {\n\t\teditMode = false;\n\t}\n\n\tvirtual void draw() {};\n\n\tconst char *typeStr() {\n\t\treturn positionStr[static_cast<int>(type)];\n\t}\n\n\tvoid calcVelocity(float distance) {\n\t\tfloat secs = (float)time / 1000;\n\t\tbaseVelocity = distance / secs;\n\t}\n\nprotected:\n\tstatic const char* positionStr[POSITION_COUNT];\n\tlong\t\tstartTime;\n\tlong\t\ttime;\n\tidCameraPosition::positionType type;\n\tidStr\t\tname;\n\tbool\teditMode;\n\tidList<idVelocity*> velocities;\n\tfloat\t\tbaseVelocity;\n};\n\nclass idFixedPosition : public idCameraPosition {\npublic:\n\n\tvoid init() {\n\t\tpos.Zero();\n\t\ttype = idCameraPosition::FIXED;\n\t}\n\t\n\tidFixedPosition() : idCameraPosition() {\n\t\tinit();\n\t}\n\t\n\tidFixedPosition(idVec3_t p) : idCameraPosition() {\n\t\tinit();\n\t\tpos = p;\n\t}\n\n\tvirtual void addPoint(const idVec3_t &v) {\n\t\tpos = v;\n\t}\n\t\n\tvirtual void addPoint(const float x, const float y, const float z) {\n\t\tpos.set(x, y, z);\n\t}\n\n\n\t~idFixedPosition() {\n\t}\n\n\tvirtual const idVec3_t *getPosition(long t) { \n\t\treturn &pos;\n\t}\n\n\tvoid parse(const char *(*text));\n\tvoid write(fileHandle_t file, const char *name);\n\n\tvirtual int numPoints() {\n\t\treturn 1;\n\t}\n\n\tvirtual idVec3_t *getPoint(int index) {\n\t\tif (index != 0) {\n\t\t\tassert(true);\n\t\t};\n\t\treturn &pos;\n\t}\n\n\tvirtual void draw(bool editMode) {\n\t\tglLabeledPoint(blue, pos, (editMode) ? 5 : 3, \"Fixed point\");\n\t}\n\nprotected:\n\tidVec3_t pos;\n};\n\nclass idInterpolatedPosition : public idCameraPosition {\npublic:\n\n\tvoid init() {\n\t\ttype = idCameraPosition::INTERPOLATED;\n\t\tfirst = true;\n\t\tstartPos.Zero();\n\t\tendPos.Zero();\n\t}\n\t\n\tidInterpolatedPosition() : idCameraPosition() {\n\t\tinit();\n\t}\n\t\n\tidInterpolatedPosition(idVec3_t start, idVec3_t end, long time) : idCameraPosition(time) {\n\t\tinit();\n\t\tstartPos = start;\n\t\tendPos = end;\n\t}\n\n\t~idInterpolatedPosition() {\n\t}\n\n\tvirtual const idVec3_t *getPosition(long t);\n\n\tvoid parse(const char *(*text));\n\tvoid write(fileHandle_t file, const char *name);\n\n\tvirtual int numPoints() {\n\t\treturn 2;\n\t}\n\n\tvirtual idVec3_t *getPoint(int index) {\n\t\tassert(index >= 0 && index < 2);\n\t\tif (index == 0) {\n\t\t\treturn &startPos;\n\t\t}\n\t\treturn &endPos;\n\t}\n\n\tvirtual void addPoint(const float x, const float y, const float z) {\n\t\tif (first) {\n\t\t\tstartPos.set(x, y, z);\n\t\t\tfirst = false;\n\t\t} else {\n\t\t\tendPos.set(x, y, z);\n\t\t\tfirst = true;\n\t\t}\n\t}\n\n\tvirtual void addPoint(const idVec3_t &v) {\n\t\tif (first) {\n\t\t\tstartPos = v;\n\t\t\tfirst = false;\n\t\t} else {\n\t\t\tendPos = v;\n\t\t\tfirst = true;\n\t\t}\n\t}\n\n\tvirtual void draw(bool editMode) {\n\t\tglLabeledPoint(blue, startPos, (editMode) ? 5 : 3, \"Start interpolated\");\n\t\tglLabeledPoint(blue, endPos, (editMode) ? 5 : 3, \"End interpolated\");\n\t\tqglBegin(GL_LINES);\n\t\tqglVertex3fv(startPos);\n\t\tqglVertex3fv(endPos);\n\t\tqglEnd();\n\t}\n\n\tvirtual void start(long t) {\n\t\tidCameraPosition::start(t);\n\t\tlastTime = startTime;\n\t\tdistSoFar = 0.0;\n\t\tidVec3_t temp = startPos;\n\t\ttemp -= endPos;\n\t\tcalcVelocity(temp.Length());\n\t}\n\nprotected:\n\tbool first;\n\tidVec3_t startPos;\n\tidVec3_t endPos;\n\tlong lastTime;\n\tfloat distSoFar;\n};\n\nclass idSplinePosition : public idCameraPosition {\npublic:\n\n\tvoid init() {\n\t\ttype = idCameraPosition::SPLINE;\n\t}\n\t\n\tidSplinePosition() : idCameraPosition() {\n\t\tinit();\n\t}\n\t\n\tidSplinePosition(long time) : idCameraPosition(time) {\n\t\tinit();\n\t}\n\n\t~idSplinePosition() {\n\t}\n\n\tvirtual void start(long t) {\n\t\tidCameraPosition::start(t);\n\t\ttarget.initPosition(t, time);\n\t\tcalcVelocity(target.totalDistance());\n\t}\n\n\tvirtual const idVec3_t *getPosition(long t) { \n\t\treturn target.getPosition(t);\n\t}\n\n\t//virtual const idVec3_t *getPosition(long t) const { \n\n\tvoid addControlPoint(idVec3_t &v) {\n\t\ttarget.addPoint(v);\n\t}\n\n\tvoid parse(const char *(*text));\n\tvoid write(fileHandle_t file, const char *name);\n\n\tvirtual int numPoints() {\n\t\treturn target.numPoints();\n\t}\n\n\tvirtual idVec3_t *getPoint(int index) {\n\t\treturn target.getPoint(index);\n\t}\n\n\tvirtual void addPoint(const idVec3_t &v) {\n\t\ttarget.addPoint(v);\n\t}\n\n\tvirtual void addPoint(const float x, const float y, const float z) {\n\t\ttarget.addPoint(x, y, z);\n\t}\n\n\tvirtual void draw(bool editMode) {\n\t\ttarget.draw(editMode);\n\t}\n\n\tvirtual void updateSelection(const idVec3_t &move) {\n\t\tidCameraPosition::updateSelection(move);\n\t\ttarget.buildSpline();\n\t}\n\nprotected:\n\tidSplineList target;\n};\n\nclass idCameraFOV {\npublic:\n\t\n\tidCameraFOV() {\n\t\ttime = 0;\n\t\tfov = 90;\n\t}\n\n\tidCameraFOV(int v) {\n\t\ttime = 0;\n\t\tfov = v;\n\t}\n\n\tidCameraFOV(int s, int e, long t) {\n\t\tstartFOV = s;\n\t\tendFOV = e;\n\t\ttime = t;\n\t}\n\n\n\t~idCameraFOV(){}\n\n\tvoid setFOV(float f) {\n\t\tfov = f;\n\t}\n\n\tfloat getFOV(long t) {\n\t\tif (time) {\n\t\t\tassert(startTime);\n\t\t\tfloat percent = t / startTime;\n\t\t\tfloat temp = startFOV - endFOV;\n\t\t\ttemp *= percent;\n\t\t\tfov = startFOV + temp;\n\t\t}\n\t\treturn fov;\n\t}\n\n\tint start(long t) {\n\t\tstartTime = t;\n\t}\n\n\tvoid parse(const char *(*text));\n\tvoid write(fileHandle_t file, const char *name);\n\nprotected:\n\tfloat fov;\n\tfloat startFOV;\n\tfloat endFOV;\n\tint startTime;\n\tint time;\n};\n\n\n\n\nclass idCameraEvent {\npublic:\n\tenum eventType {\n\t\tEVENT_NA = 0x00,\n\t\tEVENT_WAIT,\n\t\tEVENT_TARGETWAIT,\n\t\tEVENT_SPEED,\n\t\tEVENT_TARGET,\n\t\tEVENT_SNAPTARGET,\n\t\tEVENT_FOV,\n\t\tEVENT_SCRIPT,\n\t\tEVENT_TRIGGER,\n\t\tEVENT_STOP,\n\t\tEVENT_COUNT\n\t};\n\n\tstatic const char* eventStr[EVENT_COUNT];\n\n\tidCameraEvent() {\n\t\tparamStr = \"\";\n\t\ttype = EVENT_NA;\n\t\ttime = 0;\n\t}\n\n\tidCameraEvent(eventType t, const char *param, long n) {\n\t\ttype = t;\n\t\tparamStr = param;\n\t\ttime = n;\n\t}\n\n\t~idCameraEvent() {};\n\n\teventType getType() {\n\t\treturn type;\n\t}\n\n\tconst char *typeStr() {\n\t\treturn eventStr[static_cast<int>(type)];\n\t}\n\n\tconst char *getParam() {\n\t\treturn paramStr.c_str();\n\t}\n\n\tlong getTime() {\n\t\treturn time;\n\t}\n\n\tvoid setTime(long n) {\n\t\ttime = n;\n\t}\n\n\tvoid parse(const char *(*text));\n\tvoid write(fileHandle_t file, const char *name);\n\n\tvoid setTriggered(bool b) {\n\t\ttriggered = b;\n\t}\n\n\tbool getTriggered() {\n\t\treturn triggered;\n\t}\n\nprotected:\n\teventType type;\n\tidStr paramStr;\n\tlong time;\n\tbool triggered;\n\n};\n\nclass idCameraDef {\npublic:\n\n\tvoid clear() {\n\t\tcurrentCameraPosition = 0;\n\t\tcameraRunning = false;\n\t\tlastDirection.Zero();\n\t\tbaseTime = 30;\n\t\tactiveTarget = 0;\n\t\tname = \"camera01\";\n\t\tfov.setFOV(90);\n\t\tint i;\n\t\tfor (i = 0; i < targetPositions.Num(); i++) {\n\t\t\tdelete targetPositions[i];\n\t\t}\n\t\tfor (i = 0; i < events.Num(); i++) {\n\t\t\tdelete events[i];\n\t\t}\n\t\tdelete cameraPosition;\n\t\tcameraPosition = NULL;\n\t\tevents.Clear();\n\t\ttargetPositions.Clear();\n\t}\n\n\tidCameraPosition *startNewCamera(idCameraPosition::positionType type) {\n\t\tclear();\n\t\tif (type == idCameraPosition::SPLINE) {\n\t\t\tcameraPosition = new idSplinePosition();\n\t\t} else if (type == idCameraPosition::INTERPOLATED) {\n\t\t\tcameraPosition = new idInterpolatedPosition();\n\t\t} else {\n\t\t\tcameraPosition = new idFixedPosition();\n\t\t}\n\t\treturn cameraPosition;\n\t}\n\n\tidCameraDef() {\n\t\tclear();\n\t}\n\n\t~idCameraDef() {\n\t\tclear();\n\t}\n\n\tvoid addEvent(idCameraEvent::eventType t, const char *param, long time);\n\n\tvoid addEvent(idCameraEvent *event);\n\n\tstatic int sortEvents(const void *p1, const void *p2);\n\n\tint numEvents() {\n\t\treturn events.Num();\n\t}\n\n\tidCameraEvent *getEvent(int index) {\n\t\tassert(index >= 0 && index < events.Num());\n\t\treturn events[index];\n\t}\n\n\tvoid parse(const char *(*text));\n\tbool load(const char *filename);\n\tvoid save(const char *filename);\n\n\tvoid buildCamera();\n\n\t//idSplineList *getcameraPosition() {\n\t//\treturn &cameraPosition;\n\t//}\n\n\tstatic idCameraPosition *newFromType(idCameraPosition::positionType t) {\n\t\tswitch (t) {\n\t\t\tcase idCameraPosition::FIXED : return new idFixedPosition();\n\t\t\tcase idCameraPosition::INTERPOLATED : return new idInterpolatedPosition();\n\t\t\tcase idCameraPosition::SPLINE : return new idSplinePosition();\n\t\t};\n\t\treturn NULL;\n\t}\n\n\tvoid addTarget(const char *name, idCameraPosition::positionType type);\n\n\tidCameraPosition *getActiveTarget() {\n\t\tif (targetPositions.Num() == 0) {\n\t\t\taddTarget(NULL, idCameraPosition::FIXED);\n\t\t}\n\t\treturn targetPositions[activeTarget];\n\t}\n\n\tidCameraPosition *getActiveTarget(int index) {\n\t\tif (targetPositions.Num() == 0) {\n\t\t\taddTarget(NULL, idCameraPosition::FIXED);\n\t\t\treturn targetPositions[0];\n\t\t}\n\t\treturn targetPositions[index];\n\t}\n\n\tint numTargets() {\n\t\treturn targetPositions.Num();\n\t}\n\n\n\tvoid setActiveTargetByName(const char *name) {\n\t\tfor (int i = 0; i < targetPositions.Num(); i++) {\n\t\t\tif (stricmp(name, targetPositions[i]->getName()) == 0) {\n\t\t\t\tsetActiveTarget(i);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\tvoid setActiveTarget(int index) {\n\t\tassert(index >= 0 && index < targetPositions.Num());\n\t\tactiveTarget = index;\n\t}\n\n\tvoid setRunning(bool b) {\n\t\tcameraRunning = b;\n\t}\n\n\tvoid setBaseTime(float f) {\n\t\tbaseTime = f;\n\t}\n\n\tfloat getBaseTime() {\n\t\treturn baseTime;\n\t}\n\n\tfloat getTotalTime() {\n\t\treturn totalTime;\n\t}\n\t\n\tvoid startCamera(long t);\n\tvoid stopCamera() {\n\t\tcameraRunning = true;\n\t}\n\tvoid getActiveSegmentInfo(int segment, idVec3_t &origin, idVec3_t &direction, float *fv);\n\n\tbool getCameraInfo(long time, idVec3_t &origin, idVec3_t &direction, float *fv);\n\tbool getCameraInfo(long time, float *origin, float *direction, float *fv) {\n\t\tidVec3_t org, dir;\n\t\torg[0] = origin[0];\n\t\torg[1] = origin[1];\n\t\torg[2] = origin[2];\n\t\tdir[0] = direction[0];\n\t\tdir[1] = direction[1];\n\t\tdir[2] = direction[2];\n\t\tbool b = getCameraInfo(time, org, dir, fv);\n\t\torigin[0] = org[0];\n\t\torigin[1] = org[1];\n\t\torigin[2] = org[2];\n\t\tdirection[0] = dir[0];\n\t\tdirection[1] = dir[1];\n\t\tdirection[2] = dir[2];\n\t\treturn b;\n\t}\n\n\tvoid draw(bool editMode) {\n                // gcc doesn't allow casting away from bools\n                // why?  I've no idea...\n\t\tif (cameraPosition) {\n\t\t\tcameraPosition->draw((bool)((editMode || cameraRunning) && cameraEdit));\n\t\t\tint count = targetPositions.Num();\n\t\t\tfor (int i = 0; i < count; i++) {\n\t\t\t\ttargetPositions[i]->draw((bool)((editMode || cameraRunning) && i == activeTarget && !cameraEdit));\n\t\t\t}\n\t\t}\n\t}\n\n/*\n\tint numSegments() {\n\t\tif (cameraEdit) {\n\t\t\treturn cameraPosition.numSegments();\n\t\t}\n\t\treturn getTargetSpline()->numSegments();\n\t}\n\n\tint getActiveSegment() {\n\t\tif (cameraEdit) {\n\t\t\treturn cameraPosition.getActiveSegment();\n\t\t}\n\t\treturn getTargetSpline()->getActiveSegment();\n\t}\n\n\tvoid setActiveSegment(int i) {\n\t\tif (cameraEdit) {\n\t\t\tcameraPosition.setActiveSegment(i);\n\t\t} else {\n\t\t\tgetTargetSpline()->setActiveSegment(i);\n\t\t}\n\t}\n*/\n\tint numPoints() {\n\t\tif (cameraEdit) {\n\t\t\treturn cameraPosition->numPoints();\n\t\t}\n\t\treturn getActiveTarget()->numPoints();\n\t}\n\n\tconst idVec3_t *getPoint(int index) {\n\t\tif (cameraEdit) {\n\t\t\treturn cameraPosition->getPoint(index);\n\t\t}\n\t\treturn getActiveTarget()->getPoint(index);\n\t}\n\n\tvoid stopEdit() {\n\t\teditMode = false;\n\t\tif (cameraEdit) {\n\t\t\tcameraPosition->stopEdit();\n\t\t} else {\n\t\t\tgetActiveTarget()->stopEdit();\n\t\t}\n\t}\n\n\tvoid startEdit(bool camera) {\n\t\tcameraEdit = camera;\n\t\tif (camera) {\n\t\t\tcameraPosition->startEdit();\n\t\t\tfor (int i = 0; i < targetPositions.Num(); i++) {\n\t\t\t\ttargetPositions[i]->stopEdit();\n\t\t\t}\n\t\t} else {\n\t\t\tgetActiveTarget()->startEdit();\n\t\t\tcameraPosition->stopEdit();\n\t\t}\n\t\teditMode = true;\n\t}\n\n\tbool waitEvent(int index);\n\n\tconst char *getName() {\n\t\treturn name.c_str();\n\t}\n\n\tvoid setName(const char *p) {\n\t\tname = p;\n\t}\n\n\tidCameraPosition *getPositionObj() {\n\t\tif (cameraPosition == NULL) {\n\t\t\tcameraPosition = new idFixedPosition();\n\t\t}\n\t\treturn cameraPosition;\n\t}\n\nprotected:\n\tidStr name;\n\tint currentCameraPosition;\n\tidVec3_t lastDirection;\n\tbool cameraRunning;\n\tidCameraPosition *cameraPosition;\n\tidList<idCameraPosition*> targetPositions;\n\tidList<idCameraEvent*> events;\n\tidCameraFOV fov;\n\tint activeTarget;\n\tfloat totalTime;\n\tfloat baseTime;\n\tlong startTime;\n\n\tbool cameraEdit;\n\tbool editMode;\n};\n\nextern bool g_splineMode;\n\nextern idCameraDef *g_splineList;\n\n\n#endif"
  },
  {
    "path": "q3radiant/splines/util_list.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __UTIL_LIST_H__\n#define __UTIL_LIST_H__\n\n#include <stdlib.h>\n#include <assert.h>\n\ntemplate< class type >\nclass idList {\nprivate:\n\tint\t\t\tm_num;\n\tint\t\t\tm_size;\n\tint\t\t\tm_granularity;\n\ttype\t\t*m_list;\n\npublic:\n\t\t\t\tidList( int granularity = 16 );\n\t\t\t\t~idList<type>();\n\tvoid\t\tClear( void );\n\tint\t\t\tNum( void );\n\tvoid\t\tSetNum( int num );\n\tvoid\t\tSetGranularity( int granularity );\n\tvoid\t\tCondense( void );\n\tint\t\t\tSize( void );\n\tvoid\t\tResize( int size );\n\ttype\t\toperator[]( int index ) const;\n\ttype\t\t&operator[]( int index );\n\tint\t\t\tAppend( type const & obj );\n\tint\t\t\tAddUnique( type const & obj );\n\ttype\t\t*Find( type const & obj, int *index = NULL );\n\tbool\t\tRemoveIndex( int index );\n\tbool\t\tRemove( type const & obj );\n\ttypedef int cmp_t(const void *, const void *);\n\tvoid\t\tSort( cmp_t *compare );\n};\n\n/*\n================\nidList<type>::idList( int )\n================\n*/\ntemplate< class type >\ninline idList<type>::idList( int granularity ) {\n\tassert( granularity > 0 );\n\n\tm_list\t\t\t= NULL;\n\tm_granularity\t= granularity;\n\tClear();\n}\n\n/*\n================\nidList<type>::~idList<type>\n================\n*/\ntemplate< class type >\ninline idList<type>::~idList() {\n\tClear();\n}\n\n/*\n================\nidList<type>::Clear\n================\n*/\ntemplate< class type >\ninline void idList<type>::Clear( void ) {\n\tif ( m_list ) {\n\t\tdelete[] m_list;\n\t}\n\n\tm_list\t= NULL;\n\tm_num\t= 0;\n\tm_size\t= 0;\n}\n\n/*\n================\nidList<type>::Num\n================\n*/\ntemplate< class type >\ninline int idList<type>::Num( void ) {\n\treturn m_num;\n}\n\n/*\n================\nidList<type>::SetNum\n================\n*/\ntemplate< class type >\ninline void idList<type>::SetNum( int num ) {\n\tassert( num >= 0 );\n\tif ( num > m_size ) {\n\t\t// resize it up to the closest level of granularity\n\t\tResize( ( ( num + m_granularity - 1 ) / m_granularity ) * m_granularity );\n\t}\n\tm_num = num;\n}\n\n/*\n================\nidList<type>::SetGranularity\n================\n*/\ntemplate< class type >\ninline void idList<type>::SetGranularity( int granularity ) {\n\tint newsize;\n\n\tassert( granularity > 0 );\n\tm_granularity = granularity;\n\n\tif ( m_list ) {\n\t\t// resize it to the closest level of granularity\n\t\tnewsize = ( ( m_num + m_granularity - 1 ) / m_granularity ) * m_granularity;\n\t\tif ( newsize != m_size ) {\n\t\t\tResize( newsize );\n\t\t}\n\t}\n}\n\n/*\n================\nidList<type>::Condense\n\nResizes the array to exactly the number of elements it contains\n================\n*/\ntemplate< class type >\ninline void idList<type>::Condense( void ) {\n\tif ( m_list ) {\n\t\tif ( m_num ) {\n\t\t\tResize( m_num );\n\t\t} else {\n\t\t\tClear();\n\t\t}\n\t}\n}\n\n/*\n================\nidList<type>::Size\n================\n*/\ntemplate< class type >\ninline int idList<type>::Size( void ) {\n\treturn m_size;\n}\n\n/*\n================\nidList<type>::Resize\n================\n*/\ntemplate< class type >\ninline void idList<type>::Resize( int size ) {\n\ttype\t*temp;\n\tint\t\ti;\n\n\tassert( size > 0 );\n\n\tif ( size <= 0 ) {\n\t\tClear();\n\t\treturn;\n\t}\n\n\ttemp\t= m_list;\n\tm_size\t= size;\n\tif ( m_size < m_num ) {\n\t\tm_num = m_size;\n\t}\n\n\tm_list = new type[ m_size ];\n\tfor( i = 0; i < m_num; i++ ) {\n\t\tm_list[ i ] = temp[ i ];\n\t}\n\n\tif ( temp ) {\n\t\tdelete[] temp;\n\t}\n}\n\n/*\n================\nidList<type>::operator[] const\n================\n*/\ntemplate< class type >\ninline type idList<type>::operator[]( int index ) const {\n\tassert( index >= 0 );\n\tassert( index < m_num );\n\n\treturn m_list[ index ];\n}\n\n/*\n================\nidList<type>::operator[]\n================\n*/\ntemplate< class type >\ninline type &idList<type>::operator[]( int index ) {\n\tassert( index >= 0 );\n\tassert( index < m_num );\n\n\treturn m_list[ index ];\n}\n\n/*\n================\nidList<type>::Append\n================\n*/\ntemplate< class type >\ninline int idList<type>::Append( type const & obj ) {\n\tif ( !m_list ) {\n\t\tResize( m_granularity );\n\t}\n\n\tif ( m_num == m_size ) {\n\t\tResize( m_size + m_granularity );\n\t}\n\n\tm_list[ m_num ] = obj;\n\tm_num++;\n\n\treturn m_num - 1;\n}\n\n/*\n================\nidList<type>::AddUnique\n================\n*/\ntemplate< class type >\ninline int idList<type>::AddUnique( type const & obj ) {\n\tint index;\n\n\tif ( !Find( obj, &index ) ) {\n\t\tindex = Append( obj );\n\t}\n\n\treturn index;\n}\n\n/*\n================\nidList<type>::Find\n================\n*/\ntemplate< class type >\ninline type *idList<type>::Find( type const & obj, int *index ) {\n\tint i;\n\n\tfor( i = 0; i < m_num; i++ ) {\n\t\tif ( m_list[ i ] == obj ) {\n\t\t\tif ( index ) {\n\t\t\t\t*index = i;\n\t\t\t}\n\t\t\treturn &m_list[ i ];\n\t\t}\n\t}\n\n\treturn NULL;\n}\n\n/*\n================\nidList<type>::RemoveIndex\n================\n*/\ntemplate< class type >\ninline bool idList<type>::RemoveIndex( int index ) {\n\tint i;\n\n\tif ( !m_list || !m_num ) {\n\t\treturn false;\n\t}\n\n\tassert( index >= 0 );\n\tassert( index < m_num );\n\n\tif ( ( index < 0 ) || ( index >= m_num ) ) {\n\t\treturn false;\n\t}\n\n\tm_num--;\n\tfor( i = index; i < m_num; i++ ) {\n\t\tm_list[ i ] = m_list[ i + 1 ];\n\t}\n\n\treturn true;\n}\n\n/*\n================\nidList<type>::Remove\n================\n*/\ntemplate< class type >\ninline bool idList<type>::Remove( type const & obj ) {\n\tint index;\n\n\tif ( Find( obj, &index ) ) {\n\t\treturn RemoveIndex( index );\n\t}\n\t\n\treturn false;\n}\n\n/*\n================\nidList<type>::Sort\n================\n*/\ntemplate< class type >\ninline void idList<type>::Sort( cmp_t *compare ) {\n\tif ( !m_list ) {\n\t\treturn;\n\t}\n\n\tqsort( ( void * )m_list, ( size_t )m_num, sizeof( type ), compare );\n}\n\n#endif /* !__UTIL_LIST_H__ */\n"
  },
  {
    "path": "q3radiant/splines/util_str.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//need to rewrite this\n\n#include \"util_str.h\"\n#include <stdlib.h>\n#include <ctype.h>\n#include <stdio.h>\n#include <stdarg.h>\n\n#ifdef _WIN32\n#pragma warning(disable : 4244)     // 'conversion' conversion from 'type1' to 'type2', possible loss of data\n#pragma warning(disable : 4710)     // function 'blah' not inlined\n#endif\n\nstatic const int STR_ALLOC_GRAN = 20;\n\nchar *idStr::tolower\n   (\n   char *s1\n   )\n   \n   {\n   char *s;\n\n   s = s1;\n\twhile( *s )\n      {\n      *s = ::tolower( *s );\n\t\ts++;\n\t   }\n   \n   return s1;\n   }\n\nchar *idStr::toupper\n   (\n   char *s1\n   )\n   \n   {\n   char *s;\n\n   s = s1;\n\twhile( *s )\n      {\n      *s = ::toupper( *s );\n\t\ts++;\n\t   }\n   \n   return s1;\n   }\n\nint idStr::icmpn\n   (\n   const char *s1, \n   const char *s2, \n   int n\n   )\n   \n   {\n\tint c1;\n   int c2;\n\t\n\tdo \n      {\n\t\tc1 = *s1++;\n\t\tc2 = *s2++;\n\n\t\tif ( !n-- )\n         {\n         // idStrings are equal until end point\n\t\t\treturn 0;\n\t\t   }\n\t\t\n\t\tif ( c1 != c2 )\n         {\n\t\t\tif ( c1 >= 'a' && c1 <= 'z' )\n            {\n\t\t\t\tc1 -= ( 'a' - 'A' );\n\t\t\t   }\n\n\t\t\tif ( c2 >= 'a' && c2 <= 'z' )\n            {\n\t\t\t\tc2 -= ( 'a' - 'A' );\n\t\t\t   }\n\n\t\t\tif ( c1 < c2 )\n            {\n            // strings less than\n\t\t\t\treturn -1;\n\t\t\t   }\n         else if ( c1 > c2 ) \n            {\n            // strings greater than\n            return 1;\n            }\n\t\t   }\n\t   } \n   while( c1 );\n\t\n   // strings are equal\n\treturn 0;\n   }\n\nint idStr::icmp\n   (\n   const char *s1,\n   const char *s2\n   )\n   \n   {\n\tint c1;\n   int c2;\n\t\n\tdo \n      {\n\t\tc1 = *s1++;\n\t\tc2 = *s2++;\n\n\t\tif ( c1 != c2 )\n         {\n\t\t\tif ( c1 >= 'a' && c1 <= 'z' )\n            {\n\t\t\t\tc1 -= ( 'a' - 'A' );\n\t\t\t   }\n\n\t\t\tif ( c2 >= 'a' && c2 <= 'z' )\n            {\n\t\t\t\tc2 -= ( 'a' - 'A' );\n\t\t\t   }\n\n\t\t\tif ( c1 < c2 )\n            {\n            // strings less than\n\t\t\t\treturn -1;\n\t\t\t   }\n         else if ( c1 > c2 ) \n            {\n            // strings greater than\n            return 1;\n            }\n\t\t   }\n\t   } \n   while( c1 );\n\t\n   // strings are equal\n\treturn 0;\n   }\n\nint idStr::cmpn\n   (\n   const char *s1, \n   const char *s2, \n   int n\n   )\n   \n   {\n\tint c1;\n   int c2;\n\t\n\tdo \n      {\n\t\tc1 = *s1++;\n\t\tc2 = *s2++;\n\n\t\tif ( !n-- )\n         {\n         // strings are equal until end point\n\t\t\treturn 0;\n\t\t   }\n\t\t\n\t\tif ( c1 < c2 )\n         {\n         // strings less than\n\t\t\treturn -1;\n\t\t\t}\n      else if ( c1 > c2 ) \n         {\n         // strings greater than\n         return 1;\n         }\n\t   } \n   while( c1 );\n\t\n   // strings are equal\n\treturn 0;\n   }\n\nint idStr::cmp\n   (\n   const char *s1, \n   const char *s2\n   )\n   \n   {\n\tint c1;\n   int c2;\n\t\n\tdo \n      {\n\t\tc1 = *s1++;\n\t\tc2 = *s2++;\n\n\t\tif ( c1 < c2 )\n         {\n         // strings less than\n\t\t\treturn -1;\n\t\t\t}\n      else if ( c1 > c2 ) \n         {\n         // strings greater than\n         return 1;\n         }\n\t   } \n   while( c1 );\n\t\n   // strings are equal\n\treturn 0;\n   }\n\n/*\n============\nIsNumeric\n\nChecks a string to see if it contains only numerical values.\n============\n*/\nbool idStr::isNumeric\n   (\n   const char *str\n   )\n\n   {\n\tint len;\n\tint i;\n\tbool dot;\n\n\tif ( *str == '-' )\n\t\t{\n\t\tstr++;\n\t\t}\n\n\tdot = false;\n\tlen = strlen( str );\n\tfor( i = 0; i < len; i++ )\n\t\t{\n\t\tif ( !isdigit( str[ i ] ) )\n\t\t\t{\n\t\t\tif ( ( str[ i ] == '.' ) && !dot )\n\t\t\t\t{\n\t\t\t\tdot = true;\n\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\treturn true;\n   }\n\nidStr operator+\n   (\n   const idStr& a,\n   const float b\n   )\n\n   {\n   char text[ 20 ];\n\n\tidStr result( a );\n\n   sprintf( text, \"%f\", b );\n\tresult.append( text );\n\n\treturn result;\n   }\n\nidStr operator+\n   (\n   const idStr& a,\n   const int b\n   )\n\n   {\n   char text[ 20 ];\n\n\tidStr result( a );\n\n   sprintf( text, \"%d\", b );\n\tresult.append( text );\n\n\treturn result;\n   }\n\nidStr operator+\n   (\n   const idStr& a,\n   const unsigned b\n   )\n\n   {\n   char text[ 20 ];\n\n\tidStr result( a );\n\n   sprintf( text, \"%u\", b );\n\tresult.append( text );\n\n\treturn result;\n   }\n\nidStr& idStr::operator+=\n\t(\n\tconst float a\n\t)\n\n\t{\n   char text[ 20 ];\n\n   sprintf( text, \"%f\", a );\n\tappend( text );\n\n   return *this;\n\t}\n\nidStr& idStr::operator+=\n\t(\n\tconst int a\n\t)\n\n\t{\n   char text[ 20 ];\n\n   sprintf( text, \"%d\", a );\n\tappend( text );\n\n   return *this;\n\t}\n\nidStr& idStr::operator+=\n\t(\n\tconst unsigned a\n\t)\n\n\t{\n   char text[ 20 ];\n\n   sprintf( text, \"%u\", a );\n\tappend( text );\n\n   return *this;\n\t}\n\nvoid idStr::CapLength \n   (\n   int newlen \n   )\n\n   {\n   assert ( m_data );\n   \n   if ( length() <= newlen )\n      return;\n\n   EnsureDataWritable ();\n\n   m_data->data[newlen] = 0;\n   m_data->len = newlen;\n   }\n\nvoid idStr::EnsureDataWritable \n   (\n   void\n   )\n\n   {\n   assert ( m_data );\n   strdata *olddata;\n   int len;\n\n   if ( !m_data->refcount )\n      return;\n\n   olddata = m_data;\n   len = length();\n\n   m_data = new strdata;\n\n   EnsureAlloced ( len + 1, false );\n   strncpy ( m_data->data, olddata->data, len+1 );\n   m_data->len = len;\n\n   olddata->DelRef ();\n   }\n\nvoid idStr::EnsureAlloced (int amount, bool keepold) {\n\n\tif ( !m_data ) {\n      m_data = new strdata();\n\t}\n   \n\t// Now, let's make sure it's writable\n\tEnsureDataWritable ();\n\n\tchar *newbuffer;\n\tbool wasalloced = ( m_data->alloced != 0 );\n\n\tif ( amount < m_data->alloced ) {\n\t\treturn;\n\t}\n\n\tassert ( amount );\n\tif ( amount == 1 ) {\n\t\tm_data->alloced = 1;\n\t} else {\n\t\tint newsize, mod;\n\t\tmod = amount % STR_ALLOC_GRAN;\n\t\tif ( !mod ) {\n\t\t\tnewsize = amount;\n\t\t} else {\n         newsize = amount + STR_ALLOC_GRAN - mod;\n\t\t}\n\t\tm_data->alloced = newsize;\n\t}\n\n\tnewbuffer = new char[m_data->alloced];\n\tif ( wasalloced && keepold ) {\n\t\tstrcpy ( newbuffer, m_data->data );\n\t}\n\n\tif ( m_data->data ) {\n\t\tdelete [] m_data->data;\n    }\n\tm_data->data = newbuffer;\n}\n\nvoid idStr::BackSlashesToSlashes\n   (\n   void\n   )\n\n   {\n   int i;\n\n   EnsureDataWritable ();\n\n   for ( i=0; i < m_data->len; i++ )\n      {\n      if ( m_data->data[i] == '\\\\' )\n         m_data->data[i] = '/';\n      }\n   }\n\nvoid idStr::snprintf \n   (\n   char *dst,\n   int size,\n   const char *fmt, \n   ...\n   )\n\n   {\n   char buffer[0x10000];\n\tint\t\tlen;\n\tva_list\t\targptr;\n\n\tva_start (argptr,fmt);\n\tlen = vsprintf (buffer,fmt,argptr);\n\tva_end (argptr);\n\t\n   assert ( len < size );\n\n   strncpy (dst, buffer, size-1);\n   }\n\n#ifdef _WIN32\n#pragma warning(disable : 4189)\t\t// local variable is initialized but not referenced\n#endif\n\n/*\n=================\nTestStringClass\n\nThis is a fairly rigorous test of the idStr class's functionality.\nBecause of the fairly global and subtle ramifications of a bug occuring\nin this class, it should be run after any changes to the class.\nAdd more tests as functionality is changed.  Tests should include\nany possible bounds violation and NULL data tests.\n=================\n*/\nvoid TestStringClass\n\t(\n\tvoid \n\t)\n\n\t{\n\tchar\tch;\t\t\t\t\t\t\t// ch == ?\n\tidStr\t*t;\t\t\t\t\t\t\t// t == ?\n\tidStr\ta;\t\t\t\t\t\t\t\t// a.len == 0, a.data == \"\\0\"\n\tidStr\tb;\t\t\t\t\t\t\t\t// b.len == 0, b.data == \"\\0\"\n\tidStr\tc( \"test\" );\t\t\t\t// c.len == 4, c.data == \"test\\0\"\n\tidStr\td( c );\t\t\t\t\t\t// d.len == 4, d.data == \"test\\0\"\n\tidStr\te( reinterpret_cast<const char *>(NULL) );\t\t\t\t\t\n                                 // e.len == 0, e.data == \"\\0\"\t\t\t\t\tASSERT!\n\tint\ti;\t\t\t\t\t\t\t\t// i == ?\n\n\ti = a.length();\t\t\t\t\t// i == 0\n\ti = c.length();\t\t\t\t\t// i == 4\n\n\tconst char *s1 = a.c_str();\t// s1 == \"\\0\"\n\tconst char *s2 = c.c_str();\t// s2 == \"test\\0\"\n\n\tt = new idStr();\t\t\t\t\t\t// t->len == 0, t->data == \"\\0\"\n\tdelete t;\t\t\t\t\t\t\t// t == ?\n\n\tb = \"test\";\t\t\t\t\t\t\t// b.len == 4, b.data == \"test\\0\"\n\tt = new idStr( \"test\" );\t\t\t// t->len == 4, t->data == \"test\\0\"\n\tdelete t;\t\t\t\t\t\t\t// t == ?\n\n\ta = c;\t\t\t\t\t\t\t\t// a.len == 4, a.data == \"test\\0\"\n//   a = \"\";\n   a = NULL;\t\t\t\t\t\t\t// a.len == 0, a.data == \"\\0\"\t\t\t\t\tASSERT!\n\ta = c + d;\t\t\t\t\t\t\t// a.len == 8, a.data == \"testtest\\0\"\n\ta = c + \"wow\";\t\t\t\t\t\t// a.len == 7, a.data == \"testwow\\0\"\n\ta = c + reinterpret_cast<const char *>(NULL);\n                                 // a.len == 4, a.data == \"test\\0\"\t\t\tASSERT!\n\ta = \"this\" + d;\t\t\t\t\t// a.len == 8, a.data == \"thistest\\0\"\n\ta = reinterpret_cast<const char *>(NULL) + d;\n                                 // a.len == 4, a.data == \"test\\0\"\t\t\tASSERT!\n\ta += c;\t\t\t\t\t\t\t\t// a.len == 8, a.data == \"testtest\\0\"\n\ta += \"wow\";\t\t\t\t\t\t\t// a.len == 11, a.data == \"testtestwow\\0\"\n\ta += reinterpret_cast<const char *>(NULL);\n                                 // a.len == 11, a.data == \"testtestwow\\0\"\tASSERT!\n\n\ta = \"test\";\t\t\t\t\t\t\t// a.len == 4, a.data == \"test\\0\"\n\tch = a[ 0 ];\t\t\t\t\t\t// ch == 't'\n\tch = a[ -1 ];\t\t\t\t\t\t// ch == 0\t\t\t\t\t\t\t\t\t\t\tASSERT!\n\tch = a[ 1000 ];\t\t\t\t\t// ch == 0\t\t\t\t\t\t\t\t\t\t\tASSERT!\n\tch = a[ 0 ];\t\t\t\t\t\t// ch == 't'\n\tch = a[ 1 ];\t\t\t\t\t\t// ch == 'e'\n\tch = a[ 2 ];\t\t\t\t\t\t// ch == 's'\n\tch = a[ 3 ];\t\t\t\t\t\t// ch == 't'\n\tch = a[ 4 ];\t\t\t\t\t\t// ch == '\\0'\t\t\t\t\t\t\t\t\t\tASSERT!\n\tch = a[ 5 ];\t\t\t\t\t\t// ch == '\\0'\t\t\t\t\t\t\t\t\t\tASSERT!\n\n\ta[ 1 ] = 'b';\t\t\t\t\t\t// a.len == 4, a.data == \"tbst\\0\"\n\ta[ -1 ] = 'b';\t\t\t\t\t\t// a.len == 4, a.data == \"tbst\\0\"\t\t\tASSERT!\n\ta[ 0 ] = '0';\t\t\t\t\t\t// a.len == 4, a.data == \"0bst\\0\"\n\ta[ 1 ] = '1';\t\t\t\t\t\t// a.len == 4, a.data == \"01st\\0\"\n\ta[ 2 ] = '2';\t\t\t\t\t\t// a.len == 4, a.data == \"012t\\0\"\n\ta[ 3 ] = '3';\t\t\t\t\t\t// a.len == 4, a.data == \"0123\\0\"\n\ta[ 4 ] = '4';\t\t\t\t\t\t// a.len == 4, a.data == \"0123\\0\"\t\t\tASSERT!\n\ta[ 5 ] = '5';\t\t\t\t\t\t// a.len == 4, a.data == \"0123\\0\"\t\t\tASSERT!\n\ta[ 7 ] = '7';\t\t\t\t\t\t// a.len == 4, a.data == \"0123\\0\"\t\t\tASSERT!\n\n\ta = \"test\";\t\t\t\t\t\t\t// a.len == 4, a.data == \"test\\0\"\n\tb = \"no\";\t\t\t\t\t\t\t// b.len == 2, b.data == \"no\\0\"\n\n\ti = ( a == b );\t\t\t\t\t// i == 0\n\ti = ( a == c );\t\t\t\t\t// i == 1\n\n\ti = ( a == \"blow\" );\t\t\t\t// i == 0\n\ti = ( a == \"test\" );\t\t\t\t// i == 1\n\ti = ( a == NULL );\t\t\t\t// i == 0\t\t\t\t\t\t\t\t\t\t\tASSERT!\n\n\ti = ( \"test\" == b );\t\t\t\t// i == 0\n\ti = ( \"test\" == a );\t\t\t\t// i == 1\n\ti = ( NULL == a );\t\t\t\t// i == 0\t\t\t\t\t\t\t\t\t\t\tASSERT!\n\n\ti = ( a != b );\t\t\t\t\t// i == 1\n\ti = ( a != c );\t\t\t\t\t// i == 0\n\n\ti = ( a != \"blow\" );\t\t\t\t// i == 1\n\ti = ( a != \"test\" );\t\t\t\t// i == 0\n\ti = ( a != NULL );\t\t\t\t// i == 1\t\t\t\t\t\t\t\t\t\t\tASSERT!\n\n\ti = ( \"test\" != b );\t\t\t\t// i == 1\n\ti = ( \"test\" != a );\t\t\t\t// i == 0\n\ti = ( NULL != a );\t\t\t\t// i == 1\t\t\t\t\t\t\t\t\t\t\tASSERT!\n\n   a = \"test\";                   // a.data == \"test\"\n   b = a;                        // b.data == \"test\"\n\n   a = \"not\";                   // a.data == \"not\", b.data == \"test\"\n\n   a = b;                        // a.data == b.data == \"test\"\n\n   a += b;                       // a.data == \"testtest\", b.data = \"test\"\n\n   a = b;\n\n   a[1] = '1';                   // a.data = \"t1st\", b.data = \"test\"\n\t}\n\n#ifdef _WIN32\n#pragma warning(default : 4189)\t\t// local variable is initialized but not referenced\n#pragma warning(disable : 4514)     // unreferenced inline function has been removed\n#endif\n"
  },
  {
    "path": "q3radiant/splines/util_str.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n//need to rewrite this\n\n#ifndef __UTIL_STR_H__\n#define __UTIL_STR_H__\n\n#include <assert.h>\n#include <string.h>\n#include <stdio.h>\n\n#ifdef _WIN32\n#pragma warning(disable : 4710)     // function 'blah' not inlined\n#endif\n\nvoid TestStringClass ();\n\nclass strdata\n   {\n   public:\n      strdata () : len( 0 ), refcount ( 0 ), data ( NULL ), alloced ( 0 ) {}\n      ~strdata () \n         {\n         if ( data )\n            delete [] data;\n         }\n\n      void AddRef () { refcount++; }\n      bool DelRef () // True if killed\n         {\n         refcount--;\n         if ( refcount < 0 )\n            {\n            delete this;\n            return true;\n            }\n         \n         return false;\n         }\n\n      int len;\n      int refcount;\n      char *data;\n      int alloced;\n   };\n\nclass idStr {\nprotected:\n\tstrdata\t*m_data;\n\tvoid EnsureAlloced ( int, bool keepold = true );\n\tvoid EnsureDataWritable ();\n\npublic:\n\t~idStr();\n\tidStr();\n\tidStr( const char *text );\n\tidStr( const idStr& string );\n\tidStr( const idStr string, int start, int end );\n\tidStr( const char ch );\n\tidStr( const int num );\n\tidStr( const float num );\n\tidStr( const unsigned num );\n\tint\tlength( void ) const;\n\tint\tallocated( void ) const;\n\tconst char * c_str( void ) const;\n\n\tvoid\t\tappend( const char *text );\n\tvoid\t\tappend( const idStr& text );\n\tchar\t\toperator[]( int index ) const;\n\tchar&\t\toperator[]( int index );\n\n\tvoid\t\toperator=( const idStr& text );\n\tvoid\t\toperator=( const char *text );\n\n\tfriend\tidStr\t\toperator+( const idStr& a, const idStr& b );\n\tfriend\tidStr\t\toperator+( const idStr& a, const char *b );\n\tfriend\tidStr\t\toperator+( const char *a, const idStr& b );\n\n    friend\tidStr\t\toperator+( const idStr& a, const float b );\n    friend\tidStr\t\toperator+( const idStr& a, const int b );\n    friend\tidStr\t\toperator+( const idStr& a, const unsigned b );\n    friend\tidStr\t\toperator+( const idStr& a, const bool b );\n    friend\tidStr\t\toperator+( const idStr& a, const char b );\n\n\tidStr&\t\toperator+=( const idStr& a );\n\tidStr&\t\toperator+=( const char *a );\n\tidStr&\t\toperator+=( const float a );\n\tidStr&\t\toperator+=( const char a );\n\tidStr&\t\toperator+=( const int a );\n\tidStr&\t\toperator+=( const unsigned a );\n\tidStr&\t\toperator+=( const bool a );\n\n\tfriend\tbool\t\toperator==(\tconst idStr& a, const idStr& b );\n\tfriend\tbool\t\toperator==(\tconst idStr& a, const char *b );\n\tfriend\tbool\t\toperator==(\tconst char *a, const idStr& b );\n\n\tfriend\tbool\t\toperator!=(\tconst idStr& a, const idStr& b );\n\tfriend\tbool\t\toperator!=(\tconst idStr& a, const char *b );\n\tfriend\tbool\t\toperator!=(\tconst char *a, const idStr& b );\n\n\toperator const char * () const;\n\toperator const char * ();\n\n    int      icmpn( const char *text, int n ) const;\n\tint      icmpn( const idStr& text, int n ) const;\n\tint      icmp( const char *text ) const;\n\tint      icmp( const idStr& text ) const;\n\tint      cmpn( const char *text, int n ) const;\n\tint      cmpn( const idStr& text, int n ) const;\n\tint      cmp( const char *text ) const;\n\tint      cmp( const idStr& text ) const;\n\n\tvoid     tolower( void );\n\tvoid     toupper( void );\n\n\tstatic   char     *tolower( char *s1 );\n\tstatic   char     *toupper( char *s1 );\n\n\tstatic   int      icmpn( const char *s1, const char *s2, int n );\n\tstatic   int      icmp( const char *s1, const char *s2 );\n\tstatic   int      cmpn( const char *s1, const char *s2, int n );\n\tstatic   int      cmp( const char *s1, const char *s2 );\n\n\tstatic   void     snprintf ( char *dst, int size, const char *fmt, ... );\n\n\tstatic   bool\t   isNumeric( const char *str );\n    bool    isNumeric( void ) const;\n\n\tvoid     CapLength ( int );\n\n\tvoid     BackSlashesToSlashes ();\n\n};\n\ninline idStr::~idStr()\n\t{\n   if ( m_data )\n      {\n      m_data->DelRef ();\n      m_data = NULL;\n      }\n\t}\n\ninline idStr::idStr() : m_data ( NULL )\n\t{\n   EnsureAlloced ( 1 );\n\tm_data->data[ 0 ] = 0;\n\t}\n\ninline idStr::idStr\n\t(\n\tconst char *text\n   ) : m_data ( NULL )\n\n\t{\n   int len;\n\n\tassert( text );\n\n\tif ( text )\n\t\t{\n      len = strlen( text );\n\t\tEnsureAlloced ( len + 1 );\n\t\tstrcpy( m_data->data, text );\n      m_data->len = len;\n\t\t}\n\telse\n\t\t{\n      EnsureAlloced ( 1 );\n\t\tm_data->data[ 0 ] = 0;\n\t\tm_data->len = 0;\n\t\t}\n\t}\n\ninline idStr::idStr\n\t(\n\tconst idStr& text\n   ) : m_data ( NULL )\n\n\t{\n   m_data = text.m_data;\n   m_data->AddRef ();\n   }\n\ninline idStr::idStr\n\t(\n\tconst idStr text, \n\tint start,\n\tint end\n   ) : m_data ( NULL )\n\n\t{\n\tint i;\n   int len;\n\n\tif ( end > text.length() )\n\t\t{\n\t\tend = text.length();\n\t\t}\n\n\tif ( start > text.length() )\n\t\t{\n\t\tstart = text.length();\n\t\t}\n\n\tlen = end - start;\n\tif ( len < 0 )\n\t\t{\n\t\tlen = 0;\n\t\t}\n\n   EnsureAlloced ( len + 1 );\n\n\tfor( i = 0; i < len; i++ )\n\t\t{\n\t\tm_data->data[ i ] = text[ start + i ];\n\t\t}\n\n\tm_data->data[ len ] = 0;\n   m_data->len = len;\n\t}\n\ninline idStr::idStr\n   (\n   const char ch\n   ) : m_data ( NULL )\n\n   {\n   EnsureAlloced ( 2 );\n\n   m_data->data[ 0 ] = ch;\n   m_data->data[ 1 ] = 0;\n   m_data->len = 1;\n   }\n\ninline idStr::idStr\n   (\n   const float num\n   ) : m_data ( NULL )\n\n   {\n   char text[ 32 ];\n   int len;\n\n   sprintf( text, \"%.3f\", num );\n   len = strlen( text );\n   EnsureAlloced( len + 1 );\n   strcpy( m_data->data, text );\n   m_data->len = len;\n   }\n\ninline idStr::idStr\n   (\n   const int num\n   ) : m_data ( NULL )\n\n   {\n   char text[ 32 ];\n   int len;\n\n   sprintf( text, \"%d\", num );\n   len = strlen( text );\n   EnsureAlloced( len + 1 );\n   strcpy( m_data->data, text );\n   m_data->len = len;\n   }\n\ninline idStr::idStr\n   (\n   const unsigned num\n   ) : m_data ( NULL )\n\n   {\n   char text[ 32 ];\n   int len;\n\n   sprintf( text, \"%u\", num );\n   len = strlen( text );\n   EnsureAlloced( len + 1 );\n   strcpy( m_data->data, text );\n   m_data->len = len;\n   }\n\ninline int idStr::length( void ) const\n\t{\n   return ( m_data != NULL ) ? m_data->len : 0;\n\t}\n\ninline int idStr::allocated( void ) const\n\t{\n   return ( m_data != NULL ) ? m_data->alloced + sizeof( *m_data ) : 0;\n\t}\n\ninline const char *idStr::c_str( void ) const\n\t{\n\tassert( m_data );\n\n\treturn m_data->data;\n\t}\n\ninline void idStr::append\n\t(\n\tconst char *text\n\t)\n\n\t{\n   int len;\n\n\tassert( text );\n\n\tif ( text )\n\t\t{\n\t\tlen = length() + strlen( text );\n\t\tEnsureAlloced( len + 1 );\n\n      strcat( m_data->data, text );\n      m_data->len = len;\n\t\t}\n\t}\n\ninline void idStr::append\n\t(\n\tconst idStr& text\n\t)\n\n\t{\n   int len;\n\n   len = length() + text.length();\n   EnsureAlloced ( len + 1 );\n\n   strcat ( m_data->data, text.c_str () );\n   m_data->len = len;\n\t}\n\ninline char idStr::operator[]( int index ) const\n\t{\n   assert ( m_data );\n   \n   if ( !m_data )\n      return 0;\n\n\t// don't include the '/0' in the test, because technically, it's out of bounds\n\tassert( ( index >= 0 ) && ( index < m_data->len ) );\n\n\t// In release mode, give them a null character\n\t// don't include the '/0' in the test, because technically, it's out of bounds\n\tif ( ( index < 0 ) || ( index >= m_data->len ) )\n\t\t{\n\t\treturn 0;\n\t\t}\n\n\treturn m_data->data[ index ];\n\t}\n\ninline char& idStr::operator[]\n\t(\n\tint index\n\t)\n\n\t{\n\t// Used for result for invalid indices\n\tstatic char dummy = 0;\n   assert ( m_data );\n\n   // We don't know if they'll write to it or not\n   // if it's not a const object\n   EnsureDataWritable ();\n\n   if ( !m_data )\n      return dummy;\n\n\t// don't include the '/0' in the test, because technically, it's out of bounds\n\tassert( ( index >= 0 ) && ( index < m_data->len ) );\n\n\t// In release mode, let them change a safe variable\n\t// don't include the '/0' in the test, because technically, it's out of bounds\n\tif ( ( index < 0 ) || ( index >= m_data->len ) )\n\t\t{\n\t\treturn dummy;\n\t\t}\n\n\treturn m_data->data[ index ];\n\t}\n\ninline void idStr::operator=\n\t(\n\tconst idStr& text\n\t)\n\n\t{\n   // adding the reference before deleting our current reference prevents\n   // us from deleting our string if we are copying from ourself\n   text.m_data->AddRef();\n   m_data->DelRef();\n   m_data = text.m_data;\n   }\n\ninline void idStr::operator=\n\t(\n\tconst char *text\n\t)\n\n\t{\n   int len;\n\n\tassert( text );\n\n\tif ( !text )\n\t\t{\n\t\t// safe behaviour if NULL\n\t\tEnsureAlloced ( 1, false );\n      m_data->data[0] = 0;\n      m_data->len = 0;\n      return;\n\t\t}\n\n   if ( !m_data )\n      {\n      len = strlen ( text );\n      EnsureAlloced( len + 1, false );\n      strcpy ( m_data->data, text );\n      m_data->len = len;\n      return;\n      }\n\n   if ( text == m_data->data )\n      return; // Copying same thing.  Punt.\n\n   // If we alias and I don't do this, I could corrupt other strings...  This \n   // will get called with EnsureAlloced anyway\n   EnsureDataWritable ();\n\n   // Now we need to check if we're aliasing..\n   if ( text >= m_data->data && text <= m_data->data + m_data->len )\n      {\n      // Great, we're aliasing.  We're copying from inside ourselves.\n      // This means that I don't have to ensure that anything is alloced,\n      // though I'll assert just in case.\n      int diff = text - m_data->data;\n      int i;\n\n      assert ( strlen ( text ) < (unsigned) m_data->len );\n      \n      for ( i = 0; text[i]; i++ )\n         {\n         m_data->data[i] = text[i];\n         }\n\n      m_data->data[i] = 0;\n\n      m_data->len -= diff;\n\n      return;\n      }\n\n\tlen = strlen( text );\n   EnsureAlloced ( len + 1, false );\n\tstrcpy( m_data->data, text );\n   m_data->len = len;\n\t}\n\ninline idStr operator+\n\t(\n\tconst idStr& a,\n\tconst idStr& b\n\t)\n\n\t{\n\tidStr result( a );\n\n\tresult.append( b );\n\n\treturn result;\n\t}\n\ninline idStr operator+\n\t(\n\tconst idStr& a,\n\tconst char *b\n\t)\n\n\t{\n\tidStr result( a );\n\n\tresult.append( b );\n\n\treturn result;\n\t}\n\ninline idStr operator+\n\t(\n\tconst char *a,\n\tconst idStr& b\n\t)\n\n\t{\n\tidStr result( a );\n\n\tresult.append( b );\n\n\treturn result;\n\t}\n\ninline idStr operator+\n   (\n   const idStr& a,\n   const bool b\n   )\n\n   {\n\tidStr result( a );\n\n   result.append( b ? \"true\" : \"false\" );\n\n\treturn result;\n   }\n\ninline idStr operator+\n\t(\n   const idStr& a,\n\tconst char b\n\t)\n\n\t{\n   char text[ 2 ];\n\n   text[ 0 ] = b;\n   text[ 1 ] = 0;\n\n\treturn a + text;\n\t}\n\ninline idStr& idStr::operator+=\n\t(\n\tconst idStr& a\n\t)\n\n\t{\n\tappend( a );\n\treturn *this;\n\t}\n\ninline idStr& idStr::operator+=\n\t(\n\tconst char *a\n\t)\n\n\t{\n\tappend( a );\n\treturn *this;\n\t}\n\ninline idStr& idStr::operator+=\n\t(\n\tconst char a\n\t)\n\n\t{\n   char text[ 2 ];\n\n   text[ 0 ] = a;\n   text[ 1 ] = 0;\n\tappend( text );\n\n   return *this;\n\t}\n\ninline idStr& idStr::operator+=\n\t(\n\tconst bool a\n\t)\n\n\t{\n   append( a ? \"true\" : \"false\" );\n\treturn *this;\n\t}\n\ninline bool operator==\n\t(\n\tconst idStr& a,\n\tconst idStr& b\n\t)\n\n\t{\n\treturn ( !strcmp( a.c_str(), b.c_str() ) );\n\t}\n\ninline bool operator==\n\t(\n\tconst idStr& a,\n\tconst char *b\n\t)\n\n\t{\n\tassert( b );\n\tif ( !b )\n\t\t{\n\t\treturn false;\n\t\t}\n\treturn ( !strcmp( a.c_str(), b ) );\n\t}\n\ninline bool operator==\n\t(\n\tconst char *a,\n\tconst idStr& b\n\t)\n\n\t{\n\tassert( a );\n\tif ( !a )\n\t\t{\n\t\treturn false;\n\t\t}\n\treturn ( !strcmp( a, b.c_str() ) );\n\t}\n\ninline bool operator!=\n\t(\n\tconst idStr& a,\n\tconst idStr& b\n\t)\n\n\t{\n\treturn !( a == b );\n\t}\n\ninline bool operator!=\n\t(\n\tconst idStr& a,\n\tconst char *b\n\t)\n\n\t{\n\treturn !( a == b );\n\t}\n\ninline bool operator!=\n\t(\n\tconst char *a,\n\tconst idStr& b\n\t)\n\n\t{\n\treturn !( a == b );\n\t}\n\ninline int idStr::icmpn\n   (\n   const char *text, \n   int n\n   ) const\n\n   {\n\tassert( m_data );\n\tassert( text );\n\n   return idStr::icmpn( m_data->data, text, n );\n   }\n\ninline int idStr::icmpn\n   (\n   const idStr& text, \n   int n\n   ) const\n\n   {\n\tassert( m_data );\n\tassert( text.m_data );\n\n   return idStr::icmpn( m_data->data, text.m_data->data, n );\n   }\n\ninline int idStr::icmp\n   (\n   const char *text\n   ) const\n\n   {\n\tassert( m_data );\n\tassert( text );\n\n   return idStr::icmp( m_data->data, text );\n   }\n\ninline int idStr::icmp\n   (\n   const idStr& text\n   ) const\n\n   {\n\tassert( c_str () );\n\tassert( text.c_str () );\n\n   return idStr::icmp( c_str () , text.c_str () );\n   }\n\ninline int idStr::cmp\n   (\n   const char *text\n   ) const\n\n   {\n\tassert( m_data );\n\tassert( text );\n\n   return idStr::cmp( m_data->data, text );\n   }\n\ninline int idStr::cmp\n   (\n   const idStr& text\n   ) const\n\n   {\n\tassert( c_str () );\n\tassert( text.c_str () );\n\n   return idStr::cmp( c_str () , text.c_str () );\n   }\n\ninline int idStr::cmpn\n   (\n   const char *text, \n   int n\n   ) const\n\n   {\n\tassert( c_str () );\n\tassert( text );\n\n   return idStr::cmpn( c_str () , text, n );\n   }\n\ninline int idStr::cmpn\n   (\n   const idStr& text, \n   int n\n   ) const\n\n   {\n\tassert( c_str () );\n\tassert( text.c_str ()  );\n\n   return idStr::cmpn( c_str () , text.c_str () , n );\n   }\n\ninline void idStr::tolower\n   (\n   void\n   )\n\n   {\n   assert( m_data );\n\n   EnsureDataWritable ();\n\n   idStr::tolower( m_data->data );\n   }\n\ninline void idStr::toupper\n   (\n   void\n   )\n\n   {\n   assert( m_data );\n\n   EnsureDataWritable ();\n\n   idStr::toupper( m_data->data );\n   }\n\ninline bool idStr::isNumeric\n   (\n   void\n   ) const\n\n   {\n   assert( m_data );\n   return idStr::isNumeric( m_data->data );\n   }\n\ninline idStr::operator const char *() {\n\treturn c_str();\n}\n\ninline idStr::operator const char *\n   (\n   void\n   ) const\n\n   {\n   return c_str ();\n   }\n\n#endif"
  },
  {
    "path": "q3radiant/terrain.cpp",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n/*\n\nTodo:\n\nimmediate:\nTexture placement\nNew map format\nq3map\n\n\nlater:\nSmoothing brush\nStitching terrains together\nCross terrain selection\n\n\n\n\n\nTerrain_ApplyMatrix\nUpdateTerrainInspector\n\n*/\n\n#include \"stdafx.h\"\n#include \"qe3.h\"\n#include \"DialogInfo.h\"\n#include \"assert.h\"\n\n//random in the range [0, 1]\n#define random()\t\t\t((rand () & 0x7fff) / ((float)0x7fff))\n\n//random in the range [-1, 1]\n#define crandom()\t\t\t(2.0 * (random() - 0.5))\n\ntypedef struct {\n\tint\t\tindex;\n\tvec3_t\txyz;\n\tvec4_t\trgba;\n\tvec2_t\ttc;\n} terravert_t;\n\n/*\n==============\nTerrain_SetEpair\nsets an epair for the given patch\n==============\n*/\nvoid Terrain_SetEpair( terrainMesh_t *p, const char *pKey, const char *pValue ) {\n\tif ( g_qeglobals.m_bBrushPrimitMode ) {\n\t\tSetKeyValue( p->epairs, pKey, pValue );\n\t}\n}\n\n/* \n=================\nTerrain_GetKeyValue\n=================\n*/\nconst char *Terrain_GetKeyValue( terrainMesh_t *p, const char *pKey ) {\n\tif ( g_qeglobals.m_bBrushPrimitMode ) {\n\t\treturn ValueForKey( p->epairs, pKey );\n\t}\n\treturn \"\";\n}\n\n/*\n==================\nTerrain_MemorySize\n==================\n*/\nint Terrain_MemorySize( terrainMesh_t *p ) {\n\treturn _msize( p );\n}\n\nvoid Terrain_GetVert( terrainMesh_t *pm, int x, int y, float s, float t, terravert_t *v, qtexture_t *texture = NULL ) {\n\tterrainVert_t *cell;\n\n\tv->index = x + y * pm->width;\n\n\tcell = &pm->heightmap[ v->index ];\n\n\tv->xyz[ 0 ] = pm->origin[ 0 ] + x * pm->scale_x;\n\tv->xyz[ 1 ] = pm->origin[ 1 ] + y * pm->scale_y;\n\tv->xyz[ 2 ] = pm->origin[ 2 ] + cell->height;\n\n\tVectorCopy( cell->rgba, v->rgba );\n\n\tif ( !texture || ( texture == cell->tri.texture ) ) {\n\t\tv->rgba[ 3 ] = 1.0f;\n\t} else {\n\t\tv->rgba[ 3 ] = 0.0f;\n\t}\n\n\tv->tc[ 0 ] = s;\n\tv->tc[ 1 ] = t;\n}\n\nvoid Terrain_GetTriangles( terrainMesh_t *pm, int x, int y, terravert_t *a0, terravert_t *a1, terravert_t *a2, terravert_t *b0, terravert_t *b1, terravert_t *b2, qtexture_t *texture ) {\n\tif ( ( x + y ) & 1 ) {\n\t\t// first tri\n\t\tTerrain_GetVert( pm, x, y, 1.0f, 1.0f, a0, texture );\n\t\tTerrain_GetVert( pm, x, y + 1, 1.0f, 0.0f, a1, texture );\n\t\tTerrain_GetVert( pm, x + 1, y + 1, 0.0f, 0.0f, a2, texture );\n\n\t\t// second tri\n\t\t*b0 = *a2;\n\t\tTerrain_GetVert( pm, x + 1, y, 0.0f, 1.0f, b1, texture );\n\t\t*b2 = *a0;\n\t} else {\n\t\t// first tri\n\t\tTerrain_GetVert( pm, x, y, 1.0f, 1.0f, a0, texture );\n\t\tTerrain_GetVert( pm, x, y + 1, 1.0f, 0.0f, a1, texture );\n\t\tTerrain_GetVert( pm, x + 1, y, 0.0f, 1.0f, a2, texture );\n\n\t\t// second tri\n\t\t*b0 = *a2;\n\t\t*b1 = *a1;\n\t\tTerrain_GetVert( pm, x + 1, y + 1, 0.0f, 0.0f, b2, texture );\n\t}\n}\n\nvoid Terrain_GetTriangle( terrainMesh_t *pm, int index, terravert_t *a0, terravert_t *a1, terravert_t *a2 ) {\n\tint x;\n\tint y;\n\tint which;\n\n\twhich = index & 1;\n\tindex >>= 1;\n\ty = index / pm->width;\n\tx = index % pm->width;\n\n\tif ( ( x + y ) & 1 ) {\n\t\tif ( !which ) {\n\t\t\t// first tri\n\t\t\tTerrain_GetVert( pm, x, y, 1.0f, 1.0f, a0 );\n\t\t\tTerrain_GetVert( pm, x, y + 1, 1.0f, 0.0f, a1 );\n\t\t\tTerrain_GetVert( pm, x + 1, y + 1, 0.0f, 0.0f, a2 );\n\t\t} else {\n\t\t\tTerrain_GetVert( pm, x + 1, y + 1, 0.0f, 0.0f, a0 );\n\t\t\tTerrain_GetVert( pm, x + 1, y, 0.0f, 1.0f, a1 );\n\t\t\tTerrain_GetVert( pm, x, y, 1.0f, 1.0f, a2 );\n\t\t}\n\t} else {\n\t\tif ( !which ) {\n\t\t\t// first tri\n\t\t\tTerrain_GetVert( pm, x, y, 1.0f, 1.0f, a0 );\n\t\t\tTerrain_GetVert( pm, x, y + 1, 1.0f, 0.0f, a1 );\n\t\t\tTerrain_GetVert( pm, x + 1, y, 0.0f, 1.0f, a2 );\n\t\t} else {\n\t\t\tTerrain_GetVert( pm, x + 1, y, 0.0f, 1.0f, a0 );\n\t\t\tTerrain_GetVert( pm, x, y + 1, 1.0f, 0.0f, a1 );\n\t\t\tTerrain_GetVert( pm, x + 1, y + 1, 0.0f, 0.0f, a2 );\n\t\t}\n\t}\n}\n\nvoid Terrain_Delete( terrainMesh_t *p ) {\n\tif ( p->pSymbiot ) {\n\t\tp->pSymbiot->pTerrain = NULL;\n\t\tp->pSymbiot->terrainBrush = false;\n\t}\n\n\tfree( p );\n\n\tp = NULL;\n   \n\tUpdateTerrainInspector();\n}\n\nvoid Terrain_AddTexture( terrainMesh_t *pm, qtexture_t *texture ) {\n\tint i;\n\n\tif ( !texture ) {\n\t\treturn;\n\t}\n\n\tfor( i = 0; i < pm->numtextures; i++ ) {\n\t\tif ( pm->textures[ i ] == texture ) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif ( pm->numtextures >= MAX_TERRAIN_TEXTURES ) {\n\t\tWarning( \"Too many textures on terrain\" );\n\t\treturn;\n\t}\n\n\tpm->textures[ pm->numtextures++ ] = texture;\n}\n\nvoid Terrain_RemoveTexture( terrainMesh_t *p, qtexture_t *texture ) {\n\tint i;\n\n\tfor( i = 0; i < p->numtextures; i++ ) {\n\t\tif ( p->textures[ i ] == texture ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif ( i < p->numtextures ) {\n\t\t// shift all textures down to remove the texture from the list\n\t\tp->numtextures--;\n\t\tfor( ; i < p->numtextures; i++ ) {\n\t\t\tp->textures[ i ] = p->textures[ i + 1 ];\n\t\t}\n\t}\n}\n\nterrainMesh_t *MakeNewTerrain( int width, int height, qtexture_t *texture ) {\n\tint\t\t\t\th;\n\tint\t\t\t\tw;\n\tterrainMesh_t\t*pm;\n\tsize_t\t\t\tsize;\n\tsize_t\t\t\theightmapsize;\n\tterrainVert_t\t*vert;\n\tint\t\t\t\tindex;\n\n\theightmapsize  = sizeof( terrainVert_t ) * width * height;\n\tsize           = sizeof( terrainMesh_t ) + heightmapsize;\n   \n\tpm = reinterpret_cast< terrainMesh_t * >( qmalloc( size ) );\n   \n\tmemset( pm, 0x00, size );\n\n\tpm->numtextures = 0;\n\tpm->width      = width;\n\tpm->height     = height;\n\tpm->heightmap  = reinterpret_cast< terrainVert_t * >( pm + 1 );\n\n\tif ( texture ) {\n\t\tTerrain_AddTexture( pm, texture );\n\t}\n\n\tindex = 0;\n\tvert = pm->heightmap;\n\tfor( h = 0; h < pm->height; h++ ) {\n\t\tfor( w = 0; w < pm->width; w++, vert++ ) {\n\t\t\tvert->tri.index = index++;\n\t\t\tvert->tri.texture = texture;\n\t\t\tif ( texture ) {\n\t\t\t\tvert->tri.texdef.SetName( texture->name );\n\t\t\t}\n\n\t\t\tvert->height = 0;\n\n\t\t\tVectorClear( vert->normal );\n\t\t\tVectorSet( vert->rgba, 1.0f, 1.0f, 1.0f );\n\t\t\tvert->rgba[ 3 ] = 1.0f;\n\t\t}\n\t}\n   \n\treturn pm;\n}\n\nbrush_t *AddBrushForTerrain( terrainMesh_t *pm, bool bLinkToWorld ) {\n\tint\t\tj;\n\tvec3_t\tvMin;\n\tvec3_t\tvMax;\n\tbrush_t\t*b;\n\tface_t\t*f;\n\n\t// calculate the face normals\n\tTerrain_CalcNormals( pm );\n   \n\t// find the farthest points in x,y,z\n\tTerrain_CalcBounds( pm, vMin, vMax );\n\n\tfor( j = 0; j < 3; j++ ) {\n\t\tif ( vMin[ j ] == vMax[ j ] ) {\n\t\t\tvMin[ j ] -= 4;\n\t\t\tvMax[ j ] += 4;\n\t\t}\n\t}\n\n\tb = Brush_Create( vMin, vMax, &pm->heightmap->tri.texdef );\n\n\tfor( f = b->brush_faces; f != NULL; f = f->next ) {\n\t\t// copy the texdef to the brush faces texdef\n\t\tf->texdef = pm->heightmap->tri.texdef;\n\t}\n\n\t// FIXME: this entire type of linkage needs to be fixed\n\tb->pTerrain\t\t= pm;\n\tb->terrainBrush = true;\n\tpm->pSymbiot    = b;\n\tpm->bSelected   = false;\n\tpm->bDirty      = true;\n\tpm->nListID\t\t= -1;\n\n\tif ( bLinkToWorld ) {\n\t\tBrush_AddToList( b, &active_brushes );\n\t\tEntity_LinkBrush( world_entity, b );\n\t\tBrush_Build( b, true );\n\t}\n  \n\treturn b;\n}\n\nterrainMesh_t *Terrain_Duplicate( terrainMesh_t *pFrom ) {\n\tterrainMesh_t *p;\n\tint w;\n\tint h;\n\tint index;\n\n\tp = MakeNewTerrain( pFrom->width, pFrom->height );\n   \n\tVectorCopy( pFrom->origin, p->origin );\n\tVectorCopy( pFrom->mins, p->mins );\n\tVectorCopy( pFrom->maxs, p->maxs );\n\n\tp->scale_x  = pFrom->scale_x;\n\tp->scale_y  = pFrom->scale_y;\n\tp->pSymbiot = pFrom->pSymbiot;\n\n\tfor( index = 0; index < pFrom->numtextures; index++ ) {\n\t\tTerrain_AddTexture( p, pFrom->textures[ index ] );\n\t}\n\n\tindex = 0;\n\tfor( h = 0; h < p->height; h++ ) {\n\t\tfor( w = 0; w < p->width; w++, index++ ) {\n\t\t\tp->heightmap[ index ] = pFrom->heightmap[ index ];\n\t\t}\n\t}\n   \n\tp->bSelected   = false;\n\tp->bDirty      = true;\n\tp->nListID     = -1;\n\n\tAddBrushForTerrain( p );\n\n\treturn p;\n}\n\nvoid Terrain_BrushToMesh( void ) {\n\tbrush_t\t\t\t*b;\n\tterrainMesh_t\t*p;\n\n\tif ( !QE_SingleBrush() ) {\n\t\treturn;\n\t}\n\n\tb = selected_brushes.next;\n\n\tif ( g_qeglobals.d_terrainWidth\t< 1 ) {\n\t\tg_qeglobals.d_terrainWidth = 1;\n\t}\n\n\tif ( g_qeglobals.d_terrainHeight < 1 ) {\n\t\tg_qeglobals.d_terrainHeight = 1;\n\t}\n\n\tp = MakeNewTerrain( g_qeglobals.d_terrainWidth + 1, g_qeglobals.d_terrainHeight + 1, b->brush_faces->d_texture );\n\tp->scale_x = ( b->maxs[ 0 ] - b->mins[ 0 ] ) / float( p->width - 1 );\n\tp->scale_y = ( b->maxs[ 1 ] - b->mins[ 1 ] ) / float( p->height - 1 );\n\n\tVectorCopy( b->mins, p->origin );\n\n\tb = AddBrushForTerrain( p );\n\tSelect_Delete();\n\tSelect_Brush( b );\n}\n\nterrainFace_t *Terrain_ParseFace( terrainFace_t *f ) {\n\t// read the texturename\n\tGetToken( false );\n\tf->texdef.SetName( token );\n\n\t// Load the texture, and set the face to that texture's defaults\n\tf->texture = Texture_ForName( f->texdef.Name() );\n\n\t// read the texturedef\n\tGetToken( false );\n\tf->texdef.shift[ 0 ] = ( float )atoi( token );\n\tGetToken( false );\n\tf->texdef.shift[ 1 ] = ( float )atoi( token );\n\tGetToken( false );\n\tf->texdef.rotate = atof( token );\n\tGetToken( false );\n\tf->texdef.scale[ 0 ] = atof( token );\n\tGetToken( false );\n\tf->texdef.scale[ 1 ] = atof( token );\n\n\t// the flags and value field aren't necessarily present\n\t//f->texture = Texture_ForName( f->texdef.Name() );\n\tf->texdef.flags = f->texture->flags;\n\tf->texdef.value = f->texture->value;\n\tf->texdef.contents = f->texture->contents;\n\t\n\tif ( TokenAvailable () ) {\n\t\tGetToken (false);\n\t\tf->texdef.contents = atoi(token);\n\t\tGetToken (false);\n\t\tf->texdef.flags = atoi(token);\n\t\tGetToken (false);\n\t\tf->texdef.value = atoi(token);\n\t}\n\n\treturn f;\n}\n\nbrush_t *Terrain_Parse( void ) {\n\tterrainMesh_t *pm;\n\tterrainVert_t *vert;\n\tint w;\n\tint h;\n\n\tGetToken( true );\n    if ( strcmp( token, \"{\" ) ) {\n\t\treturn NULL;\n\t}\n\n\t// get width\n\tGetToken( false );\n\tw = atoi( token );\n\n\t// get height\n\tGetToken( false );\n\th = atoi( token );\n\n\tpm = MakeNewTerrain( w, h );\n\n\t// get scale_x\n\tGetToken( false );\n\tpm->scale_x = atoi( token );\n\n\t// get scale_y\n\tGetToken( false );\n\tpm->scale_y = atoi( token );\n\n\t// get origin\n\tGetToken( true );\n\tpm->origin[ 0 ] = atoi( token );\n\tGetToken( false );\n\tpm->origin[ 1 ] = atoi( token );\n\tGetToken( false );\n\tpm->origin[ 2 ] = atoi( token );\n\n\t// get the height map\n\tvert = pm->heightmap;\n\tfor( h = 0; h < pm->height; h++ ) {\n\t\tfor( w = 0; w < pm->width; w++, vert++ ) {\n\t\t\tGetToken( true );\n\t\t\tvert->height = atoi( token );\n\n\t\t\tif ( !Terrain_ParseFace( &vert->tri ) ) {\n\t\t\t\tTerrain_Delete( pm );\n\t\t\t\treturn NULL;\n\t\t\t}\n\n\t\t\tTerrain_AddTexture( pm, vert->tri.texture );\n\t\t}\n\t}\n\n\tGetToken( true );\n\tif ( strcmp( token, \"}\" ) ) {\n\t\tTerrain_Delete( pm );\n\t\treturn NULL;\n\t}\n\n\treturn AddBrushForTerrain( pm, false );\n}\n\nCString Terrain_SurfaceString( terrainFace_t *face ) {\n\tchar\t\ttemp[ 1024 ];\n\tCString\t\ttext;\n\tconst char\t*pname;\n\n\tpname = face->texdef.Name();\n\tif ( pname[ 0 ] == 0 ) {\n\t\tpname = \"unnamed\";\n\t}\n\n\tsprintf( temp, \"%s %i %i %.2f \", pname, ( int )face->texdef.shift[ 0 ], ( int )face->texdef.shift[ 1 ], face->texdef.rotate );\n\ttext += temp;\n\n\tif ( face->texdef.scale[ 0 ] == ( int )face->texdef.scale[ 0 ] ) {\n\t\tsprintf( temp, \"%i \", ( int )face->texdef.scale[ 0 ] );\n\t} else {\n\t\tsprintf( temp, \"%f \", ( float )face->texdef.scale[ 0 ] );\n\t}\n\ttext += temp;\n\n\tif ( face->texdef.scale[ 1 ] == (int)face->texdef.scale[ 1 ] ) {\n\t\tsprintf( temp, \"%i\", ( int )face->texdef.scale[ 1 ] );\n\t} else {\n\t\tsprintf( temp, \"%f\", ( float )face->texdef.scale[ 1 ] );\n\t}\n\ttext += temp;\n\n\t// only output flags and value if not default\n\tsprintf( temp, \" %i %i %i \", face->texdef.contents, face->texdef.flags, face->texdef.value );\n\ttext += temp;\n   \n\treturn text;\n}\n\nvoid Terrain_Write( terrainMesh_t *p, CMemFile *file ) {\n\tint w;\n\tint h;\n\tterrainVert_t *vert;\n\n\tMemFile_fprintf( file, \" {\\n  terrainDef\\n  {\\n\" );\n\tMemFile_fprintf( file, \"   %d %d %f %f\\n\", p->width, p->height, p->scale_x, p->scale_y );\n\tMemFile_fprintf( file, \"   %f %f %f\\n\", p->origin[ 0 ], p->origin[ 1 ], p->origin[ 2 ] );\n\n\tvert = p->heightmap;\n\tfor( h = 0; h < p->height; h++ ) {\n\t\tfor( w = 0; w < p->width; w++, vert++ ) {\n\t\t\tMemFile_fprintf( file, \"   %f %s\\n\", vert->height, ( const char * )Terrain_SurfaceString( &vert->tri ) );\n\t\t}\n\t}\n   \n\tMemFile_fprintf( file, \"  }\\n }\\n\" );\n}\n\nvoid Terrain_Write( terrainMesh_t *p, FILE *file ) {\n\tint w;\n\tint h;\n\tterrainVert_t *vert;\n\n\tfprintf( file, \" {\\n  terrainDef\\n  {\\n\" );\n\tfprintf( file, \"   %d %d %f %f\\n\", p->width, p->height, p->scale_x, p->scale_y );\n\tfprintf( file, \"   %f %f %f\\n\", p->origin[ 0 ], p->origin[ 1 ], p->origin[ 2 ] );\n\n\tvert = p->heightmap;\n\tfor( h = 0; h < p->height; h++ ) {\n\t\tfor( w = 0; w < p->width; w++, vert++ ) {\n\t\t\tfprintf( file, \"   %f %s\\n\", vert->height, ( const char * )Terrain_SurfaceString( &vert->tri ) );\n\t\t}\n\t}\n   \n\tfprintf( file, \"  }\\n }\\n\" );\n}\n\nvoid Terrain_Select( terrainMesh_t *p ) {\n\tp->bSelected = true;\n}\n\nvoid Terrain_Deselect( terrainMesh_t *p ) {\n\tp->bSelected = false;\n}\n\nvoid Terrain_Move( terrainMesh_t *pm, const vec3_t vMove, bool bRebuild ) {\n\tpm->bDirty = true;\n\n\tVectorAdd( pm->origin, vMove, pm->origin );\n\n\tif ( bRebuild ) {\n\t\tvec3_t vMin; \n\t\tvec3_t vMax;\n\n\t\tTerrain_CalcBounds( pm, vMin, vMax );\n\t}\n  \n\tUpdateTerrainInspector();\n}\n\nvoid UpdateTerrainInspector( void ) {\n\t// not written yet\n}\n\nvoid Terrain_CalcBounds( terrainMesh_t *p, vec3_t &vMin, vec3_t &vMax ) {\n\tint w;\n\tint h;\n\tfloat f;\n\tterrainVert_t *vert;\n\n\tvMin[ 0 ] = p->origin[ 0 ];\n\tvMin[ 1 ] = p->origin[ 1 ];\n\tvMin[ 2 ] = MAX_WORLD_COORD;\n\n\tvMax[ 0 ] = p->origin[ 0 ] + ( p->width - 1 ) * p->scale_x;\n\tvMax[ 1 ] = p->origin[ 1 ] + ( p->height - 1 ) * p->scale_y;\n\tvMax[ 2 ] = MIN_WORLD_COORD;\n\n\tp->bDirty = true;\n\tvert = p->heightmap;\n\tfor( h = 0; h < p->height; h++ ) {\n\t\tfor( w = 0; w < p->width; w++, vert++ ) {\n\t\t\tf = p->origin[ 2 ] + vert->height;\n\t\t\tif ( f < vMin[ 2 ] ) {\n\t\t\t\tvMin[ 2 ] = f;\n\t\t\t}\n\n\t\t\tif ( f > vMax[ 2 ] ) {\n\t\t\t\tvMax[ 2 ] = f;\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid CalcTriNormal( const vec3_t a, const vec3_t b, const vec3_t c, vec3_t o ) {\n\tvec3_t a1;\n\tvec3_t b1;\n\n\tVectorSubtract( b, a, a1 );\n\tVectorNormalize( a1 );\n\n\tVectorSubtract( c, a, b1 );\n\tVectorNormalize( b1 );\n\n\tCrossProduct( a1, b1, o );\n\tVectorNormalize( o );\n}\n\ninline void Terrain_CalcVertPos( terrainMesh_t *p, int x, int y, vec3_t vert ) {\n\tint index;\n\n\tindex = x + y * p->width;\n\tvert[ 0 ] = p->origin[ 0 ] + x * p->scale_x;\n\tvert[ 1 ] = p->origin[ 1 ] + y * p->scale_y;\n\tvert[ 2 ] = p->origin[ 2 ] + p->heightmap[ index ].height;\n\t\n\tVectorCopy( vert, p->heightmap[ index ].xyz );\n}\n   \nvoid Terrain_CalcNormals( terrainMesh_t *p ) {\n\tint\t\t\t\tx;\n\tint\t\t\t\ty;\n\tint\t\t\t\twidth;\n\tint\t\t\t\tnum;\n\tterrainVert_t\t*vert;\n\tvec3_t\t\t\tnorm;\n\tterravert_t\t\ta0;\n\tterravert_t\t\ta1;\n\tterravert_t\t\ta2;\n\tterravert_t\t\tb0;\n\tterravert_t\t\tb1;\n\tterravert_t\t\tb2;\n\n\tp->bDirty = true;\n\n\tnum = p->height * p->width;\n\tvert = p->heightmap;\n\t//for( x = 0; x < num; x++, vert++ ) {\n\tfor( y = 0; y < p->height - 1; y++ ) {\n\t\tfor( x = 0; x < p->width - 1; x++, vert++ ) {\n\t\t\tVectorClear( vert->normal );\n\t\t\tTerrain_CalcVertPos( p, x, y, norm );\n\t\t}\n\t}\n\n\twidth = p->width;\n\tvert = p->heightmap;\n   \n\tfor( y = 0; y < p->height - 1; y++ ) {\n\t\tfor( x = 0; x < width - 1; x++ ) {\n\t\t\tTerrain_GetTriangles( p, x, y, &a0, &a1, &a2, &b0, &b1, &b2, NULL );\n\n\t\t\tCalcTriNormal( a0.xyz, a2.xyz, a1.xyz, norm );\n\n\t\t\tVectorAdd( vert[ a0.index ].normal, norm, vert[ a0.index ].normal );\n\t\t\tVectorAdd( vert[ a1.index ].normal, norm, vert[ a1.index ].normal );\n\t\t\tVectorAdd( vert[ a2.index ].normal, norm, vert[ a2.index ].normal );\n\n\t\t\tCalcTriNormal( b0.xyz, b2.xyz, b1.xyz, norm );\n\n\t\t\tVectorAdd( vert[ b0.index ].normal, norm, vert[ b0.index ].normal );\n\t\t\tVectorAdd( vert[ b1.index ].normal, norm, vert[ b1.index ].normal );\n\t\t\tVectorAdd( vert[ b2.index ].normal, norm, vert[ b2.index ].normal );\n\t\t}\n\t}\n   \n\tfor( x = 0; x < num; x++, vert++ ) {\n\t\tVectorNormalize( vert->normal );\n\t\t//FIXME\n\t\tvert->normal[ 2 ] += 0.5;\n\t\tVectorNormalize( vert->normal );\n\t\tassert( vert->normal[ 2 ] > 0 );\n\t\tVectorSet( vert->rgba, vert->normal[ 2 ], vert->normal[ 2 ], vert->normal[ 2 ] );\n\t\tvert->rgba[ 3 ] = 1.0f;\n\t}\n}\n\nvoid Terrain_FindReplaceTexture( terrainMesh_t *p, const char *pFind, const char *pReplace, bool bForce ) {\n\tint\t\t\t\tw;\n\tint\t\t\t\th;\n\tterrainVert_t\t*vert;\n\tqtexture_t\t\t*texture;\n\n\ttexture = Texture_ForName( pReplace );\n\n\tvert = p->heightmap;\n\tfor( h = 0; h < p->height; h++ ) {\n\t\tfor( w = 0; w < p->width; w++, vert++ ) {\n\t\t\tif ( bForce || strcmpi( vert->tri.texture->name, pFind ) == 0 ) {\n\t\t\t\tvert->tri.texture = texture;\n\t\t\t\tvert->tri.texdef.SetName( texture->name );\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( bForce ) {\n\t\tp->numtextures = 0;\n\t\tTerrain_AddTexture( p, Texture_ForName( pReplace ) );\n\t} else {\n\t\tTerrain_RemoveTexture( p, Texture_ForName( pFind ) );\n\t\tTerrain_AddTexture( p, texture );\n\t}\n}\n\nbool Terrain_HasTexture( terrainMesh_t *p, const char *name ) {\n\tint w;\n\tint h;\n\tterrainVert_t *vert;\n\n\tvert = p->heightmap;\n\tfor( h = 0; h < p->height; h++ ) {\n\t\tfor( w = 0; w < p->width; w++, vert++ ) {\n\t\t\tif ( strcmpi( vert->tri.texture->name, name ) == 0 ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false;\n}\n\nvoid Terrain_ReplaceQTexture( terrainMesh_t *p, qtexture_t *pOld, qtexture_t *pNew ) {\n\tint w;\n\tint h;\n\tterrainVert_t *vert;\n\n\tvert = p->heightmap;\n\tfor( h = 0; h < p->height; h++ ) {\n\t\tfor( w = 0; w < p->width; w++, vert++ ) {\n\t\t\tif ( vert->tri.texture == pOld ) {\n\t\t\t\tvert->tri.texture = pNew;\n\t\t\t\tvert->tri.texdef.SetName( pNew->name );\n\t\t\t}\n\t\t}\n\t}\n\n\tTerrain_RemoveTexture( p, pOld );\n\tTerrain_AddTexture( p, pNew );\n}\n\nvoid Terrain_SetTexture( terrainMesh_t *p, texdef_t *tex_def ) {\n\tint w;\n\tint h;\n\tqtexture_t *newtex;\n\tterrainVert_t *vert;\n\n\tp->bDirty = 1;\n  \n\tnewtex = Texture_ForName( tex_def->name );\n\n\tp->numtextures = 0;\n\tTerrain_AddTexture( p, newtex );\n\n\tvert = p->heightmap;\n\tfor( h = 0; h < p->height; h++ ) {\n\t\tfor( w = 0; w < p->width; w++, vert++ ) {\n\t\t\tvert->tri.texture = newtex;\n\t\t\tvert->tri.texdef.SetName( newtex->name );\n\t\t}\n\t}\n   \n\tUpdateTerrainInspector();\n}\n\nvoid Terrain_Scale( terrainMesh_t *p, const vec3_t vOrigin, const vec3_t vAmt, bool bRebuild ) {\n\tint    w;\n\tint    h;\n\tvec3_t pos;\n\tterrainVert_t *vert;\n\tvec3_t vMin;\n\tvec3_t vMax;\n\n\tvert = p->heightmap;\n\tfor( h = 0; h < p->height; h++ ) {\n\t\tpos[ 1 ] = p->origin[ 1 ] + h * p->scale_y;\n\t\tfor( w = 0; w < p->width; w++, vert++ ) {\n\t\t\tpos[ 0 ] = p->origin[ 0 ] + w * p->scale_x;\n\t\t\tpos[ 2 ] = vert->height;\n\n\t\t\tif ( ( g_qeglobals.d_select_mode == sel_terrainpoint ) && ( Terrain_PointInMoveList( vert ) == -1 ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tvert->height -= vOrigin[ 2 ] - p->origin[ 2 ];\n\t\t\tvert->height *= vAmt[ 2 ];\n\t\t\tvert->height += vOrigin[ 2 ] - p->origin[ 2 ];\n\t\t}\n\t}\n\n\tif ( g_qeglobals.d_select_mode != sel_terrainpoint ) {\n\t\tp->scale_x *= vAmt[ 0 ];\n\t\tp->scale_y *= vAmt[ 1 ];\n      \n\t\tp->origin[ 0 ] -= vOrigin[ 0 ];\n\t\tp->origin[ 0 ] *= vAmt[ 0 ];\n\t\tp->origin[ 0 ] += vOrigin[ 0 ];\n\n\t\tp->origin[ 1 ] -= vOrigin[ 1 ];\n\t\tp->origin[ 1 ] *= vAmt[ 1 ];\n\t\tp->origin[ 1 ] += vOrigin[ 1 ];\n\t}\n\n\tif ( bRebuild ) {\n\t\tTerrain_CalcBounds( p, vMin, vMax );\n\t\tTerrain_CalcNormals( p );\n\t\tBrush_RebuildBrush( p->pSymbiot, vMin, vMax );\n\t}\n\n\tUpdateTerrainInspector();\n}\n\nbool Terrain_DragScale( terrainMesh_t *p, vec3_t vAmt, vec3_t vMove ) {\n\tvec3_t\tvMin;\n\tvec3_t\tvMax;\n\tvec3_t\tvScale;\n\tvec3_t\tvTemp;\n\tvec3_t\tvMid;\n\tint\t\ti;\n\n\tTerrain_CalcBounds( p, vMin, vMax );\n\n\tVectorSubtract( vMax, vMin, vTemp );\n\n\t// if we are scaling in the same dimension the terrain has no depth\n\tfor( i = 0; i < 3; i++ ) {\n\t\tif ( ( vTemp[ i ] == 0 ) && ( vMove[ i ] != 0 ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n  \n\tfor( i = 0; i < 3; i++ ) {\n\t\tvMid[ i ] = ( vMin[ i ] + vMax[ i ] ) / 2;\n\t}\n\n\tfor( i = 0; i < 3; i++ ) {\n\t\tif ( vAmt[ i ] != 0 ) {\n\t\t\tvScale[i] = 1.0 + vAmt[i] / vTemp[i];\n\t\t} else {\n\t\t\tvScale[i] = 1.0;\n\t\t}\n\t}\n\n\tTerrain_Scale( p, vMid, vScale, false );\n\tVectorSubtract( vMax, vMin, vTemp );\n\tTerrain_CalcBounds( p, vMin, vMax );\n  \tVectorSubtract( vMax, vMin, vMid );\n\tVectorSubtract( vMid, vTemp, vTemp );\n\tVectorScale( vTemp, 0.5f, vTemp );\n\n\t// abs of both should always be equal\n\tif ( !VectorCompare( vMove, vAmt ) ) {\n\t\tfor( i = 0; i < 3; i++ ) {\n\t\t\tif ( vMove[ i ] != vAmt[ i ] ) {\n\t\t\t\tvTemp[ i ] = -vTemp[ i ];\n\t\t\t}\n\t\t}\n\t}\n\n\tTerrain_CalcNormals( p );\n\tTerrain_Move( p, vTemp );\n\n\treturn true;\n}\n\nvoid Terrain_ApplyMatrix( terrainMesh_t *p, const vec3_t vOrigin, const vec3_t vMatrix[ 3 ], bool bSnap ) {\n}\n\nvoid Terrain_DrawFace( brush_t *brush, terrainFace_t *terraface ) {\n\tterrainMesh_t\t*pm;\n\tterravert_t\t\ta0;\n\tterravert_t\t\ta1;\n\tterravert_t\t\ta2;\n\n\tpm = brush->pTerrain;\n   \n\tTerrain_GetTriangle( pm, terraface->index, &a0, &a1, &a2 );\n\n\tqglBindTexture( GL_TEXTURE_2D, terraface->texture->texture_number );\n\tqglBegin( GL_TRIANGLES );\n\n\t// first tri\n\tqglColor4fv( a0.rgba );\n\tqglTexCoord2fv( a0.tc );\n\tqglVertex3fv( a0.xyz );\n\n\tqglColor4fv( a1.rgba );\n\tqglTexCoord2fv( a1.tc );\n\tqglVertex3fv( a1.xyz );\n\n\tqglColor4fv( a2.rgba );\n\tqglTexCoord2fv( a2.tc );\n\tqglVertex3fv( a2.xyz );\n\n\tqglEnd ();\n}\n\nvoid DrawTerrain( terrainMesh_t *pm, bool bPoints, bool bShade ) {\n\tint\t\t\t\ti;\n\tint\t\t\t\tw;\n\tint\t\t\t\th;\n\tint\t\t\t\tx;\n\tint\t\t\t\ty;\n\t//int\t\t\tn;\n\t//float\t\t\tx1;\n\t//float\t\t\ty1;\n\tfloat\t\t\tscale_x;\n\tfloat\t\t\tscale_y;\n\t//vec3_t\t\tpSelectedPoints[ MAX_TERRA_POINTS ];\n\t//int\t\t\tnIndex;\n\tterravert_t\t\ta0;\n\tterravert_t\t\ta1;\n\tterravert_t\t\ta2;\n\tterravert_t\t\tb0;\n\tterravert_t\t\tb1;\n\tterravert_t\t\tb2;\n\tterrainVert_t\t*vert;\n\tqtexture_t\t\t*texture;\n\n\th = pm->height - 1;\n\tw = pm->width - 1;\n   \n\tscale_x = pm->scale_x;\n\tscale_y = pm->scale_y;\n\n\tqglShadeModel (GL_SMOOTH);\n\n\tif ( bShade ) {\n\t\tfor( i = 0; i < pm->numtextures; i++ ) {\n\t\t\ttexture = pm->textures[ i ];\n\n\t\t\tqglBindTexture( GL_TEXTURE_2D, texture->texture_number );\n\n\t\t\tvert = pm->heightmap;\n\t\t\tfor( y = 0; y < h; y++ ) {\n\t\t\t\tqglBegin( GL_TRIANGLES );\n\n\t\t\t\tfor( x = 0; x < w; x++, vert++ ) {\n\t\t\t\t\tTerrain_GetTriangles( pm, x, y, &a0, &a1, &a2, &b0, &b1, &b2, texture );\n\n\t\t\t\t\t// first tri\n\t\t\t\t\tif ( a0.rgba[ 3 ] || a1.rgba[ 3 ] || a2.rgba[ 3 ] ) {\n\t\t\t\t\t\tqglColor4fv( a0.rgba );\n\t\t\t\t\t\tqglTexCoord2fv( a0.tc );\n\t\t\t\t\t\tqglVertex3fv( a0.xyz );\n\n\t\t\t\t\t\tqglColor4fv( a1.rgba );\n\t\t\t\t\t\tqglTexCoord2fv( a1.tc );\n\t\t\t\t\t\tqglVertex3fv( a1.xyz );\n\n\t\t\t\t\t\tqglColor4fv( a2.rgba );\n\t\t\t\t\t\tqglTexCoord2fv( a2.tc );\n\t\t\t\t\t\tqglVertex3fv( a2.xyz );\n\t\t\t\t\t}\n\n\t\t\t\t\t// second tri\n\t\t\t\t\tif ( b0.rgba[ 3 ] || b1.rgba[ 3 ] || b2.rgba[ 3 ] ) {\n\t\t\t\t\t\tqglColor4fv( b0.rgba );\n\t\t\t\t\t\tqglTexCoord2fv( b0.tc );\n\t\t\t\t\t\tqglVertex3fv( b0.xyz );\n\n\t\t\t\t\t\tqglColor4fv( b1.rgba );\n\t\t\t\t\t\tqglTexCoord2fv( b1.tc );\n\t\t\t\t\t\tqglVertex3fv( b1.xyz );\n\n\t\t\t\t\t\tqglColor4fv( b2.rgba );\n\t\t\t\t\t\tqglTexCoord2fv( b2.tc );\n\t\t\t\t\t\tqglVertex3fv( b2.xyz );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\tqglEnd ();\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor( i = 0; i < pm->numtextures; i++ ) {\n\t\t\ttexture = pm->textures[ i ];\n\n\t\t\tqglBindTexture( GL_TEXTURE_2D, texture->texture_number );\n\n\t\t\tvert = pm->heightmap;\n\t\t\tfor( y = 0; y < h; y++ ) {\n\t\t\t\tqglBegin( GL_TRIANGLES );\n\n\t\t\t\tfor( x = 0; x < w; x++, vert++ ) {\n\t\t\t\t\tTerrain_GetTriangles( pm, x, y, &a0, &a1, &a2, &b0, &b1, &b2, texture );\n\n\t\t\t\t\t// first tri\n\t\t\t\t\tif ( a0.rgba[ 3 ] || a1.rgba[ 3 ] || a2.rgba[ 3 ] ) {\n\t\t\t\t\t\tqglColor4fv( a0.rgba );\n\t\t\t\t\t\tqglTexCoord2fv( a0.tc );\n\t\t\t\t\t\tqglVertex3fv( a0.xyz );\n\n\t\t\t\t\t\tqglColor4fv( a1.rgba );\n\t\t\t\t\t\tqglTexCoord2fv( a1.tc );\n\t\t\t\t\t\tqglVertex3fv( a1.xyz );\n\n\t\t\t\t\t\tqglColor4fv( a2.rgba );\n\t\t\t\t\t\tqglTexCoord2fv( a2.tc );\n\t\t\t\t\t\tqglVertex3fv( a2.xyz );\n\t\t\t\t\t}\n\n\t\t\t\t\t// second tri\n\t\t\t\t\tif ( b0.rgba[ 3 ] || b1.rgba[ 3 ] || b2.rgba[ 3 ] ) {\n\t\t\t\t\t\tqglColor4fv( b0.rgba );\n\t\t\t\t\t\tqglTexCoord2fv( b0.tc );\n\t\t\t\t\t\tqglVertex3fv( b0.xyz );\n\n\t\t\t\t\t\tqglColor4fv( b1.rgba );\n\t\t\t\t\t\tqglTexCoord2fv( b1.tc );\n\t\t\t\t\t\tqglVertex3fv( b1.xyz );\n\n\t\t\t\t\t\tqglColor4fv( b2.rgba );\n\t\t\t\t\t\tqglTexCoord2fv( b2.tc );\n\t\t\t\t\t\tqglVertex3fv( b2.xyz );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tqglEnd ();\n\t\t\t}\n\t\t}\n\t}\n\n\tqglPushAttrib( GL_CURRENT_BIT );\n\n\tbool bDisabledLighting = qglIsEnabled( GL_LIGHTING );\n\tif ( bDisabledLighting ) {\n\t\tqglDisable( GL_LIGHTING );\n\t}\n\n#if 0\n\tterrainVert_t\t*currentrow;\n\tterrainVert_t\t*nextrow;\n\tfloat\t\t\tx2;\n\tfloat\t\t\ty2;\n\n\t// Draw normals\n\tqglDisable( GL_TEXTURE_2D );\n\tqglDisable( GL_BLEND );\n\tqglColor3f( 1, 1, 1 );\n\tqglBegin( GL_LINES );\n\n\ty2 = pm->origin[ 1 ];\n\tnextrow = pm->heightmap;\n\tfor( y = 0; y < h; y++ ) {\n\t\ty1 = y2;\n\t\ty2 += scale_y;\n\n\t\tx2 = pm->origin[ 0 ];\n\t\tcurrentrow = nextrow;\n\t\tnextrow = currentrow + pm->width;\n\t\tfor( x = 0; x < w; x++ ) {\n\t\t\tx1 = x2;\n\t\t\tx2 += scale_x;\n\n\t\t\t// normals\n\t\t\tqglVertex3f( x1, y1, pm->origin[ 2 ] + currentrow[ x ].height );\n\t\t\tqglVertex3f( x1 + currentrow[ x ].normal[ 0 ] * 16.0f, y1 + currentrow[ x ].normal[ 1 ] * 16.0f, pm->origin[ 2 ] + currentrow[ x ].height + currentrow[ x ].normal[ 2 ] * 16.0f );\n\n\t\t\tqglVertex3f( x2, y1, pm->origin[ 2 ] + currentrow[ x + 1 ].height );\n\t\t\tqglVertex3f( x2 + currentrow[ x + 1 ].normal[ 0 ] * 16.0f, y1 + currentrow[ x + 1 ].normal[ 1 ] * 16.0f, pm->origin[ 2 ] + currentrow[ x + 1 ].height + currentrow[ x + 1 ].normal[ 2 ] * 16.0f );\n\n\t\t\tqglVertex3f( x1, y2, pm->origin[ 2 ] + nextrow[ x ].height );\n\t\t\tqglVertex3f( x1 + nextrow[ x ].normal[ 0 ] * 16.0f, y2 + nextrow[ x ].normal[ 1 ] * 16.0f, pm->origin[ 2 ] + nextrow[ x ].height + nextrow[ x ].normal[ 2 ] * 16.0f );\n\n\t\t\tqglVertex3f( x2, y2, pm->origin[ 2 ] + nextrow[ x + 1 ].height );\n\t\t\tqglVertex3f( x2 + nextrow[ x + 1 ].normal[ 0 ] * 16.0f, y2 + nextrow[ x + 1 ].normal[ 1 ] * 16.0f, pm->origin[ 2 ] + nextrow[ x + 1 ].height + nextrow[ x + 1 ].normal[ 2 ] * 16.0f );\n\t\t}\n\t}\n\n\tqglEnd ();\n\tqglEnable( GL_TEXTURE_2D );\n#endif\n\n#if 0\n\tif ( bPoints && ( g_qeglobals.d_select_mode == sel_terrainpoint || g_qeglobals.d_select_mode == sel_area ) ) {\n\t\tqglPointSize( 6 );\n\t\tqglDisable( GL_TEXTURE_2D );\n\t\tqglDisable( GL_BLEND );\n\n\t\tqglBegin( GL_POINTS );\n\n\t\tnIndex = 0;\n\n\t\tqglColor4f( 1, 0, 1, 1 );\n\n\t\ty1 = pm->origin[ 1 ];\n\t\tfor ( y = 0; y < pm->height; y++, y1 += pm->scale_y ) {\n\t\t\tx1 = pm->origin[ 0 ];\n\t\t\tfor( x = 0; x < pm->width; x++, x1 += pm->scale_x ) {\n\t\t\t\t// FIXME: need to not do loop lookups inside here\n\t\t\t\tn = Terrain_PointInMoveList( &pm->heightmap[ x + y * pm->width ] );\n\t\t\t\tif ( n >= 0 ) {\n\t\t\t\t\tVectorSet( pSelectedPoints[ nIndex ], x1, y1, pm->heightmap[ x + y * pm->width ].height + pm->origin[ 2 ] );\n\t\t\t\t\tnIndex++;\n\t\t\t\t} else {\n\t\t\t\t\tqglVertex3f( x1, y1, pm->origin[ 2 ] + pm->heightmap[ x + y * pm->width ].height );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tqglEnd();\n\t\t\n\t\tqglEnable( GL_TEXTURE_2D );\n\n\t\tif ( nIndex > 0 ) {\n\t\t\tqglBegin( GL_POINTS );\n\t\t\tqglColor4f( 0, 0, 1, 1 );\n\t\t\twhile( nIndex-- > 0 ) {\n\t\t\t\tqglVertex3fv( pSelectedPoints[ nIndex ] );\n\t\t\t}\n\t\t\n\t\t\tqglEnd();\n\t\t}\n\t}\n#endif\n\n\tif ( g_qeglobals.d_numterrapoints && ( ( g_qeglobals.d_select_mode == sel_terrainpoint ) || ( g_qeglobals.d_select_mode == sel_terraintexture ) ) ) {\n#if 0 \n\t\tqglPointSize( 6 );\n\t\tqglDisable( GL_TEXTURE_2D );\n\t\tqglDisable( GL_BLEND );\n\n\t\tqglBegin( GL_POINTS );\n\n\t\tqglColor4f( 1, 0, 1, 1 );\n\n\t\tfor( i = 0; i < g_qeglobals.d_numterrapoints; i++ ) {\n\t\t\tqglVertex3fv( g_qeglobals.d_terrapoints[ i ]->xyz );\n\t\t}\n\n\t\tqglEnd();\n\t\t\t\n\t\tqglEnable( GL_TEXTURE_2D );\n#endif\n\n\t\tbrush_t\t\t\t*pb;\n\t\tterrainMesh_t\t*pm;\n\n\t\tpm = NULL;\n\t\tfor( pb = active_brushes .next; pb != &active_brushes; pb = pb->next ) {\n\t\t\tif ( pb->terrainBrush ) {\n\t\t\t\tpm = pb->pTerrain;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif ( pm ) {\n\t\t\tqglDisable( GL_TEXTURE_2D );\n\t\t\tqglBegin( GL_TRIANGLES );\n\t\t\tqglEnable( GL_BLEND );\n\n\t\t\tqglColor4f( 0.25, 0.5, 1, 0.35 );\n\n\t\t\tfor( i = 0; i < g_qeglobals.d_numterrapoints; i++ ) {\n\t\t\t\tterravert_t\t\ta0;\n\t\t\t\tterravert_t\t\ta1;\n\t\t\t\tterravert_t\t\ta2;\n\n\t\t\t\tqglColor4f( 0.25, 0.5, 1, g_qeglobals.d_terrapoints[ i ]->scale * 0.75 + 0.25 );\n\t\t\t\tTerrain_GetTriangle( pm, g_qeglobals.d_terrapoints[ i ]->tri.index * 2, &a0, &a1, &a2 );\n\n\t\t\t\tqglVertex3fv( a0.xyz );\n\t\t\t\tqglVertex3fv( a1.xyz );\n\t\t\t\tqglVertex3fv( a2.xyz );\n\n\t\t\t\tTerrain_GetTriangle( pm, g_qeglobals.d_terrapoints[ i ]->tri.index * 2 + 1, &a0, &a1, &a2 );\n\n\t\t\t\tqglVertex3fv( a0.xyz );\n\t\t\t\tqglVertex3fv( a1.xyz );\n\t\t\t\tqglVertex3fv( a2.xyz );\n\t\t\t}\n\t\t\tqglEnd();\n\t\t\t\n\t\t\tqglDisable( GL_BLEND );\n\t\t\tqglEnable( GL_TEXTURE_2D );\n\t\t}\n\t}\n}\n\nvoid Terrain_DrawCam( terrainMesh_t *pm ) {\n\tqglColor3f( 1,1,1 );\n\tqglPushAttrib( GL_ALL_ATTRIB_BITS );\n\n\tif ( g_bPatchWireFrame ) {\n\t\tif( pm->bSelected ) {\n\t\t\tqglLineWidth( 2 );\n\t\t} else {\n\t\t\tqglLineWidth( 1 );\n\t\t}\n\n\t\tqglDisable( GL_CULL_FACE );\n\t\tqglPolygonMode( GL_FRONT_AND_BACK, GL_LINE );\n\t\tqglDisable( GL_TEXTURE_2D );\n\n\t\tif ( g_PrefsDlg.m_bGLLighting ) {\n\t\t\tqglDisable( GL_LIGHTING );\n\t\t}\n\n\t\tDrawTerrain( pm, pm->bSelected, true );\n\n\t\tif ( g_PrefsDlg.m_bGLLighting ) {\n\t\t\tqglEnable( GL_LIGHTING );\n\t\t}\n\n\t\tqglEnable( GL_CULL_FACE );\n\t\tqglLineWidth( 1 );\n\t} else {\n\t\tqglEnable( GL_CULL_FACE );\n\t\tqglCullFace( GL_FRONT );\n\n\t\t// draw the textured polys\n\t\tDrawTerrain( pm, pm->bSelected, true );\n\n\t\t// if selected, draw the red tint on the polys\n\t\tif( pm->bSelected ) { // && ( g_qeglobals.d_savedinfo.include & INCLUDE_CAMERATINT ) ) {\n\t\t\tqglColor4f( 1.0, 0.0, 0.0, 0.3 );\n\t\t\tqglEnable( GL_BLEND );\n\t\t\tqglPolygonMode( GL_FRONT_AND_BACK, GL_FILL );\n\t\t\tqglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );\n\n\t\t\tDrawTerrain( pm, pm->bSelected );\n\n\t\t\tqglColor3f( 1, 1, 1 );\n\t\t}\n\n\t\t// draw the backside poly outlines\n\t\tqglCullFace( GL_BACK );\n\t\tqglPolygonMode( GL_FRONT_AND_BACK, GL_LINE );\n\t\tqglDisable( GL_BLEND );\n\t\tDrawTerrain( pm, pm->bSelected, true );\n\t}\n\n\tqglPopAttrib();\n}\n\nvoid Terrain_DrawXY( terrainMesh_t *pm, entity_t *owner ) {\n\tqglPolygonMode( GL_FRONT_AND_BACK, GL_LINE );\n   \n\tif ( pm->bSelected ) {\n\t\tqglColor3fv( g_qeglobals.d_savedinfo.colors[ COLOR_SELBRUSHES ] );\n\t} else if ( owner != world_entity && _stricmp( owner->eclass->name, \"func_group\" ) ) {\n\t\tqglColor3fv( owner->eclass->color );\n\t} else {\n\t\t//FIXME\n\t\tqglColor3fv( g_qeglobals.d_savedinfo.colors[ COLOR_BRUSHES ] );\n\t}\n\t\n\tqglLineWidth( 1 );\n\n\tDrawTerrain( pm, pm->bSelected );\n\n\tqglPolygonMode( GL_FRONT_AND_BACK, GL_FILL );\n}\n\nbool OnlyTerrainSelected( void ) {\n\tbrush_t *pb;\n\n\t//if ( numselfaces || selected_brushes.next == &selected_brushes )\n\tif ( selected_brushes.next == &selected_brushes ) {\n\t\treturn false;\n\t}\n\n\tfor( pb = selected_brushes.next; pb != &selected_brushes; pb = pb->next ) {\n\t\tif ( !pb->terrainBrush ) {\n\t\t\treturn false;\n\t\t}\n\t}\n   \n\treturn true;\n}\n\nbool AnyTerrainSelected( void ) {\n\tbrush_t *pb;\n\n\t//if ( numselfaces || selected_brushes.next == &selected_brushes )\n\tif ( selected_brushes.next == &selected_brushes ) {\n\t\treturn false;\n\t}\n\n\tfor( pb = selected_brushes.next; pb != &selected_brushes; pb = pb->next ) {\n\t\tif ( pb->terrainBrush ) {\n\t\t\treturn true;\n\t\t}\n\t}\n  \n\treturn false;\n}\n\nterrainMesh_t *SingleTerrainSelected( void ) {\n\tif ( selected_brushes.next->terrainBrush ) {\n\t\treturn selected_brushes.next->pTerrain;\n\t}\n\n\treturn NULL;\n}\n\nvoid Terrain_Edit( void ) {\n\t//brush_t *pb;\n\t//terrainMesh_t *p;\n\t//int i;\n\t//int j;\n\n//\tg_qeglobals.d_numpoints = 0;\n\tg_qeglobals.d_numterrapoints = 0;\n#if 0\t\n\tfor( pb = selected_brushes.next; pb != &selected_brushes ; pb = pb->next ) {\n\t\tif ( pb->terrainBrush ) {\n\t\t\tp = pb->pTerrain;\n\n\t\t\tif ( ( g_qeglobals.d_numpoints + p->width * p->height ) > MAX_POINTS ) {\n\t\t\t\tWarning( \"Too many points on terrain\\n\" );\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfor( i = 0; i < p->width; i++ ) {\n\t\t\t\tfor( j = 0; j < p->height; j++ ) {\n\t\t\t\t\tTerrain_CalcVertPos( p, i, j, g_qeglobals.d_points[ g_qeglobals.d_numpoints ] );\n\t\t\t\t\tg_qeglobals.d_numpoints++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n#endif\n   \n\tg_qeglobals.d_select_mode = sel_terrainpoint;\n}\n\nvoid Terrain_SelectPointByRay( vec3_t org, vec3_t dir, int buttons ) {\n\tfloat\t\t\tbestd;\n\tterrainFace_t\t*face;\n\tterrainFace_t\t*bestface;\n\tbrush_t\t\t\t*pb;\n\tfloat\t\t\tdist;\n\tvec3_t\t\t\tvec;\n\n\t// find the point closest to the ray\n\tbestface = NULL;\n\tbestd = WORLD_SIZE * 4;\n\tfor( pb = selected_brushes.next; pb != &selected_brushes; pb = pb->next ) {\n\t\tif ( pb->terrainBrush ) {\n\t\t\tface = Terrain_Ray( org, dir, pb, &dist );\n\t\t\tif ( face && ( dist < bestd ) ) {\n\t\t\t\tbestface = face;\n\t\t\t\tbestd = dist;\n\t\t\t}\n\t\t}\n\t}\n\n\tfor( pb = active_brushes .next; pb != &active_brushes; pb = pb->next ) {\n\t\tif ( pb->terrainBrush ) {\n\t\t\tface = Terrain_Ray( org, dir, pb, &dist );\n\t\t\tif ( face && ( dist < bestd ) ) {\n\t\t\t\tbestface = face;\n\t\t\t\tbestd = dist;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( !bestface ) {\n\t\treturn;\n\t}\n\t\n\tVectorMA( org, bestd, dir, vec );\n\tTerrain_AddMovePoint( vec, buttons & MK_CONTROL, buttons & MK_SHIFT, buttons );\n}\n\nvoid Terrain_AddMovePoint( vec3_t v, bool bMulti, bool bFull, int buttons  ) {\n\tbrush_t\t\t\t*pb;\n\tterrainMesh_t\t*p;\n\tterrainVert_t\t*vert;\n\tint\t\t\t\tx;\n\tint\t\t\t\ty;\n\tint\t\t\t\tx1, y1;\n\tfloat\t\t\tdx, dy;\n\tfloat\t\t\tdist;\n\tfloat\t\t\tpd;\n\n\tif ( !g_bSameView && !bMulti && !bFull ) {\n\t\tg_bSameView = true;\n\t\treturn;\n\t}\n\t\n\tg_qeglobals.d_numterrapoints = 0;\n\tfor( pb = active_brushes .next; pb != &active_brushes; pb = pb->next ) {\n\t//for( pb = selected_brushes.next; pb != &selected_brushes; pb = pb->next ) {\n\t\tif ( pb->terrainBrush ) {\n\t\t\tp = pb->pTerrain;\n\t    \n\t\t\tx = ( v[ 0 ] - p->origin[ 0 ] ) / p->scale_x;\n\t\t\ty = ( v[ 1 ] - p->origin[ 1 ] ) / p->scale_x;\n\t\t\tif ( ( x < 0 ) || ( x >= p->width ) || ( y < 0 ) || ( y >= p->height ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tvert = p->heightmap;\n\t\t\tfor( y1 = 0; y1 < p->height; y1++ ) {\n\t\t\t\tfor( x1 = 0; x1 < p->width; x1++, vert++ ) {\n\n\t\t\t\t\tif ( g_qeglobals.d_terrainBrush == TERRAIN_BRUSH_CIRCLE ) {\n\t\t\t\t\t\tdx = x1 - x;\n\t\t\t\t\t\tdy = y1 - y;\n\t\t\t\t\t\tdist = sqrt( dx * dx + dy * dy );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdx = abs( x1 - x );\n\t\t\t\t\t\tdy = abs( y1 - y );\n\t\t\t\t\t\tif ( dx > dy ) {\n\t\t\t\t\t\t\tdist = dx;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdist = dy;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tpd = dist * 2.0f / g_qeglobals.d_terrainBrushSize;\n\t\t\t\t\tif ( fabs( pd ) <= 1.0f ) {\n\t\t\t\t\t\tTerrain_AddPoint( p, vert );\n\n\t\t\t\t\t\tif ( ( buttons & MK_LBUTTON ) && ( g_qeglobals.d_select_mode == sel_terraintexture ) ) {\n\t\t\t\t\t\t\tvert->tri.texture = Texture_ForName( g_qeglobals.d_texturewin.texdef.name );\n\t\t\t\t\t\t\tvert->tri.texdef.SetName( vert->tri.texture->name );\n\t\t\t\t\t\t\tTerrain_AddTexture( p, vert->tri.texture );\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( g_qeglobals.d_terrainFalloff == TERRAIN_FALLOFF_CURVED ) {\n\t\t\t\t\t\t\tif ( g_qeglobals.d_terrainBrush == TERRAIN_BRUSH_CIRCLE ) {\n\t\t\t\t\t\t\t\tvert->scale = ( 0.5f + cos( pd * M_PI ) * 0.5f );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tvert->scale = ( 0.5f + cos( dx/ g_qeglobals.d_terrainBrushSize * M_PI ) * 0.5f ) * ( 0.5f + cos( dy/ g_qeglobals.d_terrainBrushSize * M_PI ) * 0.5f ) - 0.25;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tvert->scale = 1.0f - pd;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tswitch( g_qeglobals.d_terrainNoiseType ) {\n\t\t\t\t\t\tcase NOISE_PLUS :\n\t\t\t\t\t\t\tvert->scale *= crandom();\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase NOISE_PLUSMINUS :\n\t\t\t\t\t\t\tvert->scale *= random();\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid Terrain_UpdateSelected( vec3_t vMove ) {\n\tint\t\t\t\ti;\n\tbrush_t\t\t\t*pb;\n\tterrainMesh_t\t*p;\n\tvec3_t\t\t\tvMin;\n\tvec3_t\t\t\tvMax;\n\n\tif ( g_qeglobals.d_select_mode == sel_terrainpoint ) {\n\t\tfor( i = 0; i < g_qeglobals.d_numterrapoints; i++ ) {\n\t\t\tg_qeglobals.d_terrapoints[ i ]->height += vMove[ 2 ] * g_qeglobals.d_terrapoints[ i ]->scale;\n\t\t}\n\t}\n\n\tfor( pb = active_brushes .next; pb != &active_brushes; pb = pb->next ) {\n//\tfor( pb = selected_brushes.next; pb != &selected_brushes; pb = pb->next ) {\n\t\tif ( pb->terrainBrush ) {\n\t\t\tp = pb->pTerrain;\n\n\t\t\tTerrain_CalcBounds( p, vMin, vMax );\n\t\t\tTerrain_CalcNormals( p );\n\t\t\tBrush_RebuildBrush( p->pSymbiot, vMin, vMax );\n\t\t}\n\t}\n}\n\nint Terrain_PointInMoveList( terrainVert_t *pf ) {\n\tint i;\n\n\tfor( i = 0; i < g_qeglobals.d_numterrapoints; i++ ) {\n\t\tif ( pf == g_qeglobals.d_terrapoints[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\n\treturn -1;\n}\n\nvoid Terrain_RemovePointFromMoveList( terrainVert_t *v ) {\n\tint n;\n\tint i;\n   \n\twhile( ( n = Terrain_PointInMoveList( v ) ) >= 0 ) {\n\t\tfor( i = n; i < g_qeglobals.d_numterrapoints - 1; i++ ) {\n\t\t\tg_qeglobals.d_terrapoints[ i ] = g_qeglobals.d_terrapoints[ i + 1 ];\n\t\t}\n    \n\t\tg_qeglobals.d_numterrapoints--;\n\t}\n}\n\nvoid Terrain_AddPoint( terrainMesh_t *p, terrainVert_t *v ) {\n\tif ( g_qeglobals.d_numterrapoints < MAX_TERRA_POINTS ) {\n\t\tg_qeglobals.d_terrapoints[ g_qeglobals.d_numterrapoints++ ] = v;\n\t}\n}\n\nvoid Terrain_SelectAreaPoints( void ) {\n\tbrush_t\t\t\t*pb;\n\tterrainMesh_t\t*p;\n\tint\t\t\t\tx;\n\tint\t\t\t\ty;\n\tvec3_t\t\t\tvec;\n\n\tg_qeglobals.d_numterrapoints = 0;\n\tg_nPatchClickedView = -1;\n\n\tfor( pb = selected_brushes.next; pb != &selected_brushes; pb = pb->next ) {\n\t\tif ( pb->terrainBrush ) {\n\t\t\tp = pb->pTerrain;\n\t\t\tfor( x = 0; x < p->width; x++ ) {\n\t\t\t\tfor( y = 0; y < p->height; y++ ) {\n\t\t\t\t\tTerrain_CalcVertPos( p, x, y, vec );\n\t\t\t\t\tif ( within( vec, g_qeglobals.d_vAreaTL, g_qeglobals.d_vAreaBR ) ) {\n\t\t\t\t\t\tif ( g_qeglobals.d_numterrapoints < MAX_TERRA_POINTS ) {\n\t\t\t\t\t\t\tg_qeglobals.d_terrapoints[ g_qeglobals.d_numterrapoints++ ] = &p->heightmap[ x + y * p->width ];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n#define EPSILON 0.0001\n\nbool RayTriangleIntersect( vec3_t orig, vec3_t dir, vec3_t vert1, vec3_t vert2, vec3_t vert3, float *t ) {\n\tfloat   u;\n\tfloat   v;\n\tvec3_t  edge1;\n\tvec3_t  edge2;\n\tvec3_t  tvec;\n\tvec3_t\tpvec;\n\tvec3_t\tqvec;\n\tfloat\tdet;\n\n\tVectorSubtract( vert2, vert1, edge1 );\n\tVectorSubtract( vert3, vert1, edge2 );\n\n\t// begin calculating determinant - also used to calculate U parameter\n\tCrossProduct( dir, edge2, pvec );\n\n\t// if determinant is near zero, ray lies in plane of triangle\n\tdet = DotProduct( edge1, pvec );\n\tif ( det < EPSILON ) {\n\t\treturn false;\n\t}\n\n\t// calculate distance from vert1 to ray origin\n\tVectorSubtract( orig, vert1, tvec );\n\n\t// calculate U parameter and test bounds\n\tu = DotProduct( tvec, pvec );\n\tif ( ( u < 0.0f ) || ( u > det ) ) {\n\t\treturn false;\n\t}\n\n\t// prepare to test V parameter\n\tCrossProduct( tvec, edge1, qvec );\n\n\t// calculate V parameter and test bounds\n\tv = DotProduct( dir, qvec );\n\tif ( ( v < 0.0f ) || ( u + v > det ) ) {\n\t\treturn false;\n\t}\n\n\t// calculate t, scale parameters, ray intersects triangle\n\t*t = DotProduct( edge2, qvec ) / det;\n\n\treturn true;\n}\n\n/*\n==============\nTerrain_Ray\n\nItersects a ray with a terrain\nReturns the face hit and the distance along the ray the intersection occured at\nReturns NULL and 0 if not hit at all\n==============\n*/\nterrainFace_t *Terrain_Ray( vec3_t origin, vec3_t dir, brush_t *b, float *dist ) {\n\tterrainMesh_t\t*pm;\n\tint\t\t\t\th;\n\tint\t\t\t\tw;\n\tint\t\t\t\tx;\n\tint\t\t\t\ty;\n\tfloat\t\t\tbest_t;\n\tfloat\t\t\tt;\n\tterravert_t\t\ta0;\n\tterravert_t\t\ta1;\n\tterravert_t\t\ta2;\n\tterravert_t\t\tb0;\n\tterravert_t\t\tb1;\n\tterravert_t\t\tb2;\n\tterrainVert_t\t*vert;\n\tterrainFace_t\t*best;\n\n\tbest = NULL;\n\tbest_t = WORLD_SIZE * 2;\n\n\tpm = b->pTerrain;\n\th = pm->height - 1;\n\tw = pm->width - 1;\n   \n\tvert = pm->heightmap;\n\tfor( y = 0; y < h; y++, vert++ ) {\n\t\tfor( x = 0; x < w; x++, vert++ ) {\n\t\t\tTerrain_GetTriangles( pm, x, y, &a0, &a1, &a2, &b0, &b1, &b2, NULL );\n\n\t\t\tt = WORLD_SIZE * 2;\n\t\t\tif ( RayTriangleIntersect( origin, dir, a2.xyz, a1.xyz, a0.xyz, &t ) ) {\n\t\t\t\tif ( ( t >= 0 ) && ( t < best_t ) ) {\n\t\t\t\t\tbest = &vert->tri;\n\t\t\t\t\tbest_t = t;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tt = WORLD_SIZE * 2;\n\t\t\tif ( RayTriangleIntersect( origin, dir, b2.xyz, b1.xyz, b0.xyz, &t ) ) {\n\t\t\t\tif ( ( t >= 0 ) && ( t < best_t ) ) {\n\t\t\t\t\tbest = &vert->tri;\n\t\t\t\t\tbest_t = t;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( !best ) {\n\t\t*dist = 0;\n\t\treturn NULL;\n\t}\n\n\t*dist = best_t;\n\n\treturn best;\n}\n\n/*\n============\nSelect_TerrainFace\n\nSelect the face\n============\n*/\nvoid Select_TerrainFace ( brush_t * brush, terrainFace_t *terraface ) {\n#if 0\n\tUnSelect_Brush( brush );\n\n\tif( numselfaces < MAX_SEL_FACES ) {\n\t\tselfaces[numselfaces].face = NULL;\n\t\tselfaces[numselfaces].brush = brush;\n\t\tselfaces[numselfaces].terraface = terraface;\n\t\tnumselfaces++;\n\t}\n#endif\n}\n\nvoid Select_TerrainFacesFromBrush( brush_t *brush ) {\n\tterrainMesh_t\t*pm;\n\tint\t\t\t\th;\n\tint\t\t\t\tw;\n\tint\t\t\t\tx;\n\tint\t\t\t\ty;\n\n\tpm = brush->pTerrain;\n\th = pm->height - 1;\n\tw = pm->width - 1;\n   \n\tfor( y = 0; y < h; y++ ) {\n\t\tfor( x = 0; x < w; x++ ) {\n\t\t\tSelect_TerrainFace( brush, &brush->pTerrain->heightmap[ x + y * pm->width ].tri );\n\t\t}\n\t}\n}\n\nvoid SetTerrainTexdef( brush_t *brush, terrainFace_t *face, texdef_t *texdef ) {\n\tint\toldFlags;\n\tint\toldContents;\n\n\toldFlags = face->texdef.flags;\n\toldContents = face->texdef.contents;\n\n\tface->texdef = *texdef;\n\n\tface->texdef.flags = ( face->texdef.flags & ~SURF_KEEP ) | ( oldFlags & SURF_KEEP );\n\tface->texdef.contents = ( face->texdef.contents & ~CONTENTS_KEEP ) | ( oldContents & CONTENTS_KEEP );\n   \n\tface->texture = Texture_ForName( texdef->name );\n\n\t//Terrain_AddTexture( face->texture );\n}\n\nvoid RotateTerrainFaceTexture( terrainFace_t *vert, int nAxis, float fDeg ) {\n}\n\nvoid TerrainFace_FitTexture( terrainFace_t *vert ) {\n}\n\nvoid Terrain_Init( void ) {\n\tg_qeglobals.d_terrainWidth\t\t= 64;\n\tg_qeglobals.d_terrainHeight\t\t= 64;\n\tg_qeglobals.d_terrainBrushSize\t= 12;\n\tg_qeglobals.d_terrainNoiseType\t= NOISE_NONE;\n\t//g_qeglobals.d_terrainFalloff\t= TERRAIN_FALLOFF_LINEAR;\n\tg_qeglobals.d_terrainFalloff\t= TERRAIN_FALLOFF_CURVED;\n\tg_qeglobals.d_terrainBrush\t\t= TERRAIN_BRUSH_CIRCLE;\n\t//g_qeglobals.d_terrainBrush\t\t= TERRAIN_BRUSH_SQUARE;\n}\n"
  },
  {
    "path": "q3radiant/terrain.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n#ifndef __TERRAIN_H__\n#define __TERRAIN_H__\n\nvoid\t\t\tTerrain_SetEpair( terrainMesh_t *p, const char *pKey, const char *pValue );\nconst char*\t\tTerrain_GetKeyValue( terrainMesh_t *p, const char *pKey );\nint\t\t\t\tTerrain_MemorySize( terrainMesh_t *p );\nvoid\t\t\tTerrain_Delete( terrainMesh_t *p );\nterrainMesh_t\t*MakeNewTerrain( int width, int height, qtexture_t *texture = NULL );\nbrush_t\t\t\t*AddBrushForTerrain( terrainMesh_t *pm, bool bLinkToWorld = true );\nterrainMesh_t\t*Terrain_Duplicate( terrainMesh_t *pFrom );\nvoid\t\t\tTerrain_BrushToMesh( void );\nbrush_t\t\t\t*Terrain_Parse( void );\nvoid\t\t\tTerrain_Write( terrainMesh_t *p, CMemFile *file );\nvoid\t\t\tTerrain_Write( terrainMesh_t *p, FILE *file );\nvoid\t\t\tTerrain_Select( terrainMesh_t *p );\nvoid\t\t\tTerrain_Deselect( terrainMesh_t *p );\nvoid\t\t\tTerrain_Move( terrainMesh_t *pm, const vec3_t vMove, bool bRebuild = false );\nvoid\t\t\tUpdateTerrainInspector( void );\nvoid\t\t\tTerrain_CalcBounds( terrainMesh_t *p, vec3_t &vMin, vec3_t &vMax );\nvoid\t\t\tCalcTriNormal( const vec3_t a, const vec3_t b, const vec3_t c, vec3_t o );\nvoid\t\t\tTerrain_CalcVertPos( terrainMesh_t *p, int x, int y, vec3_t vert );\nvoid\t\t\tTerrain_CalcNormals( terrainMesh_t *p );\nvoid\t\t\tTerrain_FindReplaceTexture( terrainMesh_t *p, const char *pFind, const char *pReplace, bool bForce );\nbool\t\t\tTerrain_HasTexture( terrainMesh_t *p, const char *name );\nvoid\t\t\tTerrain_ReplaceQTexture( terrainMesh_t *p, qtexture_t *pOld, qtexture_t *pNew );\nvoid\t\t\tTerrain_SetTexture( terrainMesh_t *p, texdef_t *tex_def );\nvoid\t\t\tTerrain_Scale( terrainMesh_t *p, const vec3_t vOrigin, const vec3_t vAmt, bool bRebuild = true );\nbool\t\t\tTerrain_DragScale( terrainMesh_t *p, vec3_t vAmt, vec3_t vMove );\nvoid\t\t\tTerrain_ApplyMatrix( terrainMesh_t *p, const vec3_t vOrigin, const vec3_t vMatrix[ 3 ], bool bSnap );\nvoid\t\t\tTerrain_DrawFace( brush_t *brush, terrainFace_t *terraface );\nvoid\t\t\tDrawTerrain( terrainMesh_t *pm, bool bPoints, bool bShade = false );\nvoid\t\t\tTerrain_DrawCam( terrainMesh_t *pm );\nvoid\t\t\tTerrain_DrawXY( terrainMesh_t *pm, entity_t *owner );\nbool\t\t\tOnlyTerrainSelected( void );\nbool\t\t\tAnyTerrainSelected( void );\nterrainMesh_t\t*SingleTerrainSelected( void );\nvoid\t\t\tTerrain_Edit( void );\nvoid\t\t\tTerrain_SelectPointByRay ( vec3_t org, vec3_t dir, int buttons );\nvoid\t\t\tTerrain_AddMovePoint( vec3_t v, bool bMulti, bool bFull, int buttons );\nvoid\t\t\tTerrain_UpdateSelected( vec3_t vMove );\nint\t\t\t\tTerrain_PointInMoveList( terrainVert_t *pf );\nvoid\t\t\tTerrain_AddPoint( terrainMesh_t *p, terrainVert_t *v );\nvoid\t\t\tTerrain_RemovePointFromMoveList( terrainVert_t *v );\nvoid\t\t\tTerrain_SelectAreaPoints( void );\nbool\t\t\tRayTriangleIntersect( vec3_t orig, vec3_t dir, vec3_t vert1, vec3_t vert2, vec3_t vert3, float *t );\nterrainFace_t\t*Terrain_Ray( vec3_t origin, vec3_t dir, brush_t *b, float *dist );\nvoid\t\t\tSelect_TerrainFacesFromBrush( brush_t *brush );\nvoid\t\t\tSetTerrainTexdef( brush_t *brush, terrainFace_t *vert, texdef_t *texdef );\nvoid\t\t\tRotateTerrainFaceTexture( terrainFace_t *vert, int nAxis, float fDeg );\nvoid\t\t\tTerrainFace_FitTexture( terrainFace_t *vert );\nvoid\t\t\tSelect_TerrainFace( brush_t * brush, terrainFace_t *terraface );\nvoid\t\t\tTerrain_Init( void );\n\n#endif\n"
  },
  {
    "path": "ui/hud.txt",
    "content": "// hud menu defs\n// \n{\n\tloadMenu { \"ui/hud.menu\" }\n \tloadMenu { \"ui/score.menu\" }\n\tloadMenu { \"ui/teamscore.menu\" }\n}\n"
  },
  {
    "path": "ui/hud2.txt",
    "content": "// hud menu defs\n// \n{\n\tloadMenu { \"ui/min_hud.menu\" }\n \tloadMenu { \"ui/score.menu\" }\n\tloadMenu { \"ui/teamscore.menu\" }\n}\n"
  },
  {
    "path": "ui/ingame.txt",
    "content": "// menu defs\n// \n{\t\n \tloadMenu { \"ui/ingame.menu\" }\n\tloadMenu { \"ui/ingame_vote.menu\" }\n\tloadMenu { \"ui/ingame_about.menu\" }\n\tloadMenu { \"ui/ingame_controls.menu\" }\n\tloadMenu { \"ui/ingame_join.menu\" }\n\tloadMenu { \"ui/ingame_options.menu\" }\n\tloadMenu { \"ui/ingame_system.menu\" }\n\tloadMenu { \"ui/ingame_leave.menu\" }\n\tloadMenu { \"ui/ingame_player.menu\" }\n\tloadMenu { \"ui/ingame_addbot.menu\" }\n\tloadMenu { \"ui/ingame_callvote.menu\" }\n\tloadMenu { \"ui/ingame_orders.menu\" }\n}\n"
  },
  {
    "path": "ui/menudef.h",
    "content": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc.\n\nThis file is part of Quake III Arena source code.\n\nQuake III Arena source code is free software; you can redistribute it\nand/or modify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation; either version 2 of the License,\nor (at your option) any later version.\n\nQuake III Arena source code is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Foobar; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n===========================================================================\n*/\n\n#define ITEM_TYPE_TEXT 0                  // simple text\n#define ITEM_TYPE_BUTTON 1                // button, basically text with a border \n#define ITEM_TYPE_RADIOBUTTON 2           // toggle button, may be grouped \n#define ITEM_TYPE_CHECKBOX 3              // check box\n#define ITEM_TYPE_EDITFIELD 4             // editable text, associated with a cvar\n#define ITEM_TYPE_COMBO 5                 // drop down list\n#define ITEM_TYPE_LISTBOX 6               // scrollable list  \n#define ITEM_TYPE_MODEL 7                 // model\n#define ITEM_TYPE_OWNERDRAW 8             // owner draw, name specs what it is\n#define ITEM_TYPE_NUMERICFIELD 9          // editable text, associated with a cvar\n#define ITEM_TYPE_SLIDER 10               // mouse speed, volume, etc.\n#define ITEM_TYPE_YESNO 11                // yes no cvar setting\n#define ITEM_TYPE_MULTI 12                // multiple list setting, enumerated\n#define ITEM_TYPE_BIND 13\t\t              // multiple list setting, enumerated\n    \n#define ITEM_ALIGN_LEFT 0                 // left alignment\n#define ITEM_ALIGN_CENTER 1               // center alignment\n#define ITEM_ALIGN_RIGHT 2                // right alignment\n\n#define ITEM_TEXTSTYLE_NORMAL 0           // normal text\n#define ITEM_TEXTSTYLE_BLINK 1            // fast blinking\n#define ITEM_TEXTSTYLE_PULSE 2            // slow pulsing\n#define ITEM_TEXTSTYLE_SHADOWED 3         // drop shadow ( need a color for this )\n#define ITEM_TEXTSTYLE_OUTLINED 4         // drop shadow ( need a color for this )\n#define ITEM_TEXTSTYLE_OUTLINESHADOWED 5  // drop shadow ( need a color for this )\n#define ITEM_TEXTSTYLE_SHADOWEDMORE 6         // drop shadow ( need a color for this )\n                          \n#define WINDOW_BORDER_NONE 0              // no border\n#define WINDOW_BORDER_FULL 1              // full border based on border color ( single pixel )\n#define WINDOW_BORDER_HORZ 2              // horizontal borders only\n#define WINDOW_BORDER_VERT 3              // vertical borders only \n#define WINDOW_BORDER_KCGRADIENT 4        // horizontal border using the gradient bars\n  \n#define WINDOW_STYLE_EMPTY 0              // no background\n#define WINDOW_STYLE_FILLED 1             // filled with background color\n#define WINDOW_STYLE_GRADIENT 2           // gradient bar based on background color \n#define WINDOW_STYLE_SHADER   3           // gradient bar based on background color \n#define WINDOW_STYLE_TEAMCOLOR 4          // team color\n#define WINDOW_STYLE_CINEMATIC 5          // cinematic\n\n#define MENU_TRUE 1                       // uh.. true\n#define MENU_FALSE 0                      // and false\n\n#define HUD_VERTICAL\t\t\t\t0x00\n#define HUD_HORIZONTAL\t\t\t\t0x01\n\n// list box element types\n#define LISTBOX_TEXT  0x00\n#define LISTBOX_IMAGE 0x01\n\n// list feeders\n#define FEEDER_HEADS\t\t\t\t\t\t0x00\t\t\t// model heads\n#define FEEDER_MAPS\t\t\t\t\t\t\t0x01\t\t\t// text maps based on game type\n#define FEEDER_SERVERS\t\t\t\t\t\t0x02\t\t\t// servers\n#define FEEDER_CLANS\t\t\t\t\t\t0x03\t\t\t// clan names\n#define FEEDER_ALLMAPS\t\t\t\t\t\t0x04\t\t\t// all maps available, in graphic format\n#define FEEDER_REDTEAM_LIST\t\t\t\t\t0x05\t\t\t// red team members\n#define FEEDER_BLUETEAM_LIST\t\t\t\t0x06\t\t\t// blue team members\n#define FEEDER_PLAYER_LIST\t\t\t\t\t0x07\t\t\t// players\n#define FEEDER_TEAM_LIST\t\t\t\t\t0x08\t\t\t// team members for team voting\n#define FEEDER_MODS\t\t\t\t\t\t\t0x09\t\t\t// team members for team voting\n#define FEEDER_DEMOS \t\t\t\t\t\t0x0a\t\t\t// team members for team voting\n#define FEEDER_SCOREBOARD\t\t\t\t\t0x0b\t\t\t// team members for team voting\n#define FEEDER_Q3HEADS\t\t \t\t\t\t0x0c\t\t\t// model heads\n#define FEEDER_SERVERSTATUS\t\t\t\t\t0x0d\t\t\t// server status\n#define FEEDER_FINDPLAYER\t\t\t\t\t0x0e\t\t\t// find player\n#define FEEDER_CINEMATICS\t\t\t\t\t0x0f\t\t\t// cinematics\n\n// display flags\n#define CG_SHOW_BLUE_TEAM_HAS_REDFLAG     0x00000001\n#define CG_SHOW_RED_TEAM_HAS_BLUEFLAG     0x00000002\n#define CG_SHOW_ANYTEAMGAME               0x00000004\n#define CG_SHOW_HARVESTER                 0x00000008\n#define CG_SHOW_ONEFLAG                   0x00000010\n#define CG_SHOW_CTF                       0x00000020\n#define CG_SHOW_OBELISK                   0x00000040\n#define CG_SHOW_HEALTHCRITICAL            0x00000080\n#define CG_SHOW_SINGLEPLAYER              0x00000100\n#define CG_SHOW_TOURNAMENT                0x00000200\n#define CG_SHOW_DURINGINCOMINGVOICE       0x00000400\n#define CG_SHOW_IF_PLAYER_HAS_FLAG\t\t\t\t0x00000800\n#define CG_SHOW_LANPLAYONLY\t\t\t\t\t\t\t\t0x00001000\n#define CG_SHOW_MINED\t\t\t\t\t\t\t\t\t\t\t0x00002000\n#define CG_SHOW_HEALTHOK\t\t\t            0x00004000\n#define CG_SHOW_TEAMINFO\t\t\t            0x00008000\n#define CG_SHOW_NOTEAMINFO\t\t            0x00010000\n#define CG_SHOW_OTHERTEAMHASFLAG          0x00020000\n#define CG_SHOW_YOURTEAMHASENEMYFLAG      0x00040000\n#define CG_SHOW_ANYNONTEAMGAME            0x00080000\n#define CG_SHOW_2DONLY\t\t\t\t\t\t\t\t\t\t0x10000000\n\n\n#define UI_SHOW_LEADER\t\t\t\t            0x00000001\n#define UI_SHOW_NOTLEADER\t\t\t            0x00000002\n#define UI_SHOW_FAVORITESERVERS\t\t\t\t\t\t0x00000004\n#define UI_SHOW_ANYNONTEAMGAME\t\t\t\t\t\t0x00000008\n#define UI_SHOW_ANYTEAMGAME\t\t\t\t\t\t\t\t0x00000010\n#define UI_SHOW_NEWHIGHSCORE\t\t\t\t\t\t\t0x00000020\n#define UI_SHOW_DEMOAVAILABLE\t\t\t\t\t\t\t0x00000040\n#define UI_SHOW_NEWBESTTIME\t\t\t\t\t\t\t\t0x00000080\n#define UI_SHOW_FFA\t\t\t\t\t\t\t\t\t\t\t\t0x00000100\n#define UI_SHOW_NOTFFA\t\t\t\t\t\t\t\t\t\t0x00000200\n#define UI_SHOW_NETANYNONTEAMGAME\t \t\t\t\t0x00000400\n#define UI_SHOW_NETANYTEAMGAME\t\t \t\t\t\t0x00000800\n#define UI_SHOW_NOTFAVORITESERVERS\t\t\t\t0x00001000\n\n\n\n\n// owner draw types\n// ideally these should be done outside of this file but\n// this makes it much easier for the macro expansion to \n// convert them for the designers ( from the .menu files )\n#define CG_OWNERDRAW_BASE 1\n#define CG_PLAYER_ARMOR_ICON 1              \n#define CG_PLAYER_ARMOR_VALUE 2\n#define CG_PLAYER_HEAD 3\n#define CG_PLAYER_HEALTH 4\n#define CG_PLAYER_AMMO_ICON 5\n#define CG_PLAYER_AMMO_VALUE 6\n#define CG_SELECTEDPLAYER_HEAD 7\n#define CG_SELECTEDPLAYER_NAME 8\n#define CG_SELECTEDPLAYER_LOCATION 9\n#define CG_SELECTEDPLAYER_STATUS 10\n#define CG_SELECTEDPLAYER_WEAPON 11\n#define CG_SELECTEDPLAYER_POWERUP 12\n\n#define CG_FLAGCARRIER_HEAD 13\n#define CG_FLAGCARRIER_NAME 14\n#define CG_FLAGCARRIER_LOCATION 15\n#define CG_FLAGCARRIER_STATUS 16\n#define CG_FLAGCARRIER_WEAPON 17\n#define CG_FLAGCARRIER_POWERUP 18\n\n#define CG_PLAYER_ITEM 19\n#define CG_PLAYER_SCORE 20\n\n#define CG_BLUE_FLAGHEAD 21\n#define CG_BLUE_FLAGSTATUS 22\n#define CG_BLUE_FLAGNAME 23\n#define CG_RED_FLAGHEAD 24\n#define CG_RED_FLAGSTATUS 25\n#define CG_RED_FLAGNAME 26\n\n#define CG_BLUE_SCORE 27\n#define CG_RED_SCORE 28\n#define CG_RED_NAME 29\n#define CG_BLUE_NAME 30\n#define CG_HARVESTER_SKULLS 31\t\t\t\t\t// only shows in harvester\n#define CG_ONEFLAG_STATUS 32\t\t\t\t\t\t// only shows in one flag\n#define CG_PLAYER_LOCATION 33\n#define CG_TEAM_COLOR 34\n#define CG_CTF_POWERUP 35\n                                        \n#define CG_AREA_POWERUP\t36\n#define CG_AREA_LAGOMETER\t37            // painted with old system\n#define CG_PLAYER_HASFLAG 38            \n#define CG_GAME_TYPE 39                 // not done\n\n#define CG_SELECTEDPLAYER_ARMOR 40      \n#define CG_SELECTEDPLAYER_HEALTH 41\n#define CG_PLAYER_STATUS 42\n#define CG_FRAGGED_MSG 43               // painted with old system\n#define CG_PROXMINED_MSG 44             // painted with old system\n#define CG_AREA_FPSINFO 45              // painted with old system\n#define CG_AREA_SYSTEMCHAT 46           // painted with old system\n#define CG_AREA_TEAMCHAT 47             // painted with old system\n#define CG_AREA_CHAT 48                 // painted with old system\n#define CG_GAME_STATUS 49\n#define CG_KILLER 50\n#define CG_PLAYER_ARMOR_ICON2D 51              \n#define CG_PLAYER_AMMO_ICON2D 52\n#define CG_ACCURACY 53\n#define CG_ASSISTS 54\n#define CG_DEFEND 55\n#define CG_EXCELLENT 56\n#define CG_IMPRESSIVE 57\n#define CG_PERFECT 58\n#define CG_GAUNTLET 59\n#define CG_SPECTATORS 60\n#define CG_TEAMINFO 61\n#define CG_VOICE_HEAD 62\n#define CG_VOICE_NAME 63\n#define CG_PLAYER_HASFLAG2D 64            \n#define CG_HARVESTER_SKULLS2D 65\t\t\t\t\t// only shows in harvester\n#define CG_CAPFRAGLIMIT 66\t \n#define CG_1STPLACE 67\n#define CG_2NDPLACE 68\n#define CG_CAPTURES 69\n\n\n\n\n#define UI_OWNERDRAW_BASE 200\n#define UI_HANDICAP 200\n#define UI_EFFECTS 201\n#define UI_PLAYERMODEL 202\n#define UI_CLANNAME 203\n#define UI_CLANLOGO 204\n#define UI_GAMETYPE 205\n#define UI_MAPPREVIEW 206\n#define UI_SKILL 207\n#define UI_BLUETEAMNAME 208\n#define UI_REDTEAMNAME 209\n#define UI_BLUETEAM1 210\n#define UI_BLUETEAM2 211\n#define UI_BLUETEAM3 212\n#define UI_BLUETEAM4 213\n#define UI_BLUETEAM5 214\n#define UI_REDTEAM1 215\n#define UI_REDTEAM2 216\n#define UI_REDTEAM3 217\n#define UI_REDTEAM4 218\n#define UI_REDTEAM5 219\n#define UI_NETSOURCE 220\n#define UI_NETMAPPREVIEW 221\n#define UI_NETFILTER 222\n#define UI_TIER 223\n#define UI_OPPONENTMODEL 224\n#define UI_TIERMAP1 225\n#define UI_TIERMAP2 226\n#define UI_TIERMAP3 227\n#define UI_PLAYERLOGO 228\n#define UI_OPPONENTLOGO 229\n#define UI_PLAYERLOGO_METAL 230\n#define UI_OPPONENTLOGO_METAL 231\n#define UI_PLAYERLOGO_NAME 232\n#define UI_OPPONENTLOGO_NAME 233\n#define UI_TIER_MAPNAME 234\n#define UI_TIER_GAMETYPE 235\n#define UI_ALLMAPS_SELECTION 236\n#define UI_OPPONENT_NAME 237\n#define UI_VOTE_KICK 238\n#define UI_BOTNAME 239\n#define UI_BOTSKILL 240\n#define UI_REDBLUE 241\n#define UI_CROSSHAIR 242\n#define UI_SELECTEDPLAYER 243\n#define UI_MAPCINEMATIC 244\n#define UI_NETGAMETYPE 245\n#define UI_NETMAPCINEMATIC 246\n#define UI_SERVERREFRESHDATE 247\n#define UI_SERVERMOTD 248\n#define UI_GLINFO  249\n#define UI_KEYBINDSTATUS 250\n#define UI_CLANCINEMATIC 251\n#define UI_MAP_TIMETOBEAT 252\n#define UI_JOINGAMETYPE 253\n#define UI_PREVIEWCINEMATIC 254\n#define UI_STARTMAPCINEMATIC 255\n#define UI_MAPS_SELECTION 256\n\n#define VOICECHAT_GETFLAG\t\t\t\"getflag\"\t\t\t\t// command someone to get the flag\n#define VOICECHAT_OFFENSE\t\t\t\"offense\"\t\t\t\t// command someone to go on offense\n#define VOICECHAT_DEFEND\t\t\t\"defend\"\t\t\t\t// command someone to go on defense\n#define VOICECHAT_DEFENDFLAG\t\t\"defendflag\"\t\t\t// command someone to defend the flag\n#define VOICECHAT_PATROL\t\t\t\"patrol\"\t\t\t\t// command someone to go on patrol (roam)\n#define VOICECHAT_CAMP\t\t\t\t\"camp\"\t\t\t\t\t// command someone to camp (we don't have sounds for this one)\n#define VOICECHAT_FOLLOWME\t\t\t\"followme\"\t\t\t\t// command someone to follow you\n#define VOICECHAT_RETURNFLAG\t\t\"returnflag\"\t\t\t// command someone to return our flag\n#define VOICECHAT_FOLLOWFLAGCARRIER\t\"followflagcarrier\"\t\t// command someone to follow the flag carrier\n#define VOICECHAT_YES\t\t\t\t\"yes\"\t\t\t\t\t// yes, affirmative, etc.\n#define VOICECHAT_NO\t\t\t\t\"no\"\t\t\t\t\t// no, negative, etc.\n#define VOICECHAT_ONGETFLAG\t\t\t\"ongetflag\"\t\t\t\t// I'm getting the flag\n#define VOICECHAT_ONOFFENSE\t\t\t\"onoffense\"\t\t\t\t// I'm on offense\n#define VOICECHAT_ONDEFENSE\t\t\t\"ondefense\"\t\t\t\t// I'm on defense\n#define VOICECHAT_ONPATROL\t\t\t\"onpatrol\"\t\t\t\t// I'm on patrol (roaming)\n#define VOICECHAT_ONCAMPING\t\t\t\"oncamp\"\t\t\t\t// I'm camping somewhere\n#define VOICECHAT_ONFOLLOW\t\t\t\"onfollow\"\t\t\t\t// I'm following\n#define VOICECHAT_ONFOLLOWCARRIER\t\"onfollowcarrier\"\t\t// I'm following the flag carrier\n#define VOICECHAT_ONRETURNFLAG\t\t\"onreturnflag\"\t\t\t// I'm returning our flag\n#define VOICECHAT_INPOSITION\t\t\"inposition\"\t\t\t// I'm in position\n#define VOICECHAT_IHAVEFLAG\t\t\t\"ihaveflag\"\t\t\t\t// I have the flag\n#define VOICECHAT_BASEATTACK\t\t\"baseattack\"\t\t\t// the base is under attack\n#define VOICECHAT_ENEMYHASFLAG\t\t\"enemyhasflag\"\t\t\t// the enemy has our flag (CTF)\n#define VOICECHAT_STARTLEADER\t\t\"startleader\"\t\t\t// I'm the leader\n#define VOICECHAT_STOPLEADER\t\t\"stopleader\"\t\t\t// I resign leadership\n#define VOICECHAT_TRASH\t\t\t\t\"trash\"\t\t\t\t\t// lots of trash talk\n#define VOICECHAT_WHOISLEADER\t\t\"whoisleader\"\t\t\t// who is the team leader\n#define VOICECHAT_WANTONDEFENSE\t\t\"wantondefense\"\t\t\t// I want to be on defense\n#define VOICECHAT_WANTONOFFENSE\t\t\"wantonoffense\"\t\t\t// I want to be on offense\n#define VOICECHAT_KILLINSULT\t\t\"kill_insult\"\t\t\t// I just killed you\n#define VOICECHAT_TAUNT\t\t\t\t\"taunt\"\t\t\t\t\t// I want to taunt you\n#define VOICECHAT_DEATHINSULT\t\t\"death_insult\"\t\t\t// you just killed me\n#define VOICECHAT_KILLGAUNTLET\t\t\"kill_gauntlet\"\t\t\t// I just killed you with the gauntlet\n#define VOICECHAT_PRAISE\t\t\t\"praise\"\t\t\t\t// you did something good\n"
  },
  {
    "path": "ui/menus.txt",
    "content": "// menu defs\n// \n{\t\n\tloadMenu { \"ui/main.menu\" }\n \tloadMenu { \"ui/joinserver.menu\" }\n \tloadMenu { \"ui/filter.menu\" }\n\tloadMenu { \"ui/punkbuster.menu\" }\n \tloadMenu { \"ui/player.menu\" }\n \tloadMenu { \"ui/setup.menu\" }\n \tloadMenu { \"ui/fight.menu\" }\n \tloadMenu { \"ui/skirmish.menu\" }\n \tloadMenu { \"ui/createserver.menu\" }\n\tloadMenu { \"ui/controls.menu\" }\n\tloadMenu { \"ui/cdkey.menu\" }\n\tloadMenu { \"ui/system.menu\" }\n\tloadMenu { \"ui/options.menu\" }\n\tloadMenu { \"ui/help.menu\" }\n\tloadMenu { \"ui/ordershelp.menu\" }\n \tloadMenu { \"ui/mod.menu\" }\n\tloadMenu { \"ui/demo.menu\" }\n\tloadMenu { \"ui/cinematicmenu.menu\" }\n\tloadMenu { \"ui/credit.menu\" }\n\tloadMenu { \"ui/demo_quit.menu\" }\n\tloadMenu { \"ui/connect.menu\" }\n\tloadMenu { \"ui/powerup.menu\" } \n\tloadMenu { \"ui/password.menu\" }\n\tloadMenu { \"ui/quake3.menu\" }\n\tloadMenu { \"ui/quit.menu\" }\n\tloadMenu { \"ui/vid_restart.menu\" }\n\tloadMenu { \"ui/default.menu\" }\n\tloadMenu { \"ui/addfilter.menu\" }\n\tloadMenu { \"ui/error.menu\" }\n\tloadMenu { \"ui/serverinfo.menu\" }\n\tloadMenu { \"ui/findplayer.menu\" }\n\tloadMenu { \"ui/endofgame.menu\" }\n\tloadMenu { \"ui/quitcredit.menu\" }\n\tloadMenu { \"ui/resetscore.menu\" }\n\tloadMenu { \"ui/createfavorite.menu\" }\n}\n"
  }
]